@pixiv/three-vrm v2.1.2
@pixiv/three-vrm
v1
three-vrm v1 has been released!
three-vrm v1 supports VRM1.0, which is a new version of VRM format (the previous version of VRM is also supported, don't worry!). It also adopts the GLTFLoader plugin system which is a relatively new feature of GLTFLoader.
There are a lot of breaking changes! See the migration guide for more info.
How to Use
from HTML
You will need:
- Three.js build
- GLTFLoader
- A build of @pixiv/three-vrm
.module
ones are ESM, otherwise it's UMD and injects its modules into globalTHREE
.min
ones are minified (for production), otherwise it's not minified and it comes with source maps
You can import all of them via CDN. See the example below.
Code like this:
<script type="importmap">
{
"imports": {
"three": "https://cdn.jsdelivr.net/npm/three@0.164.1/build/three.module.js",
"three/addons/": "https://cdn.jsdelivr.net/npm/three@0.164.1/examples/jsm/",
"@pixiv/three-vrm": "three-vrm.module.js"
}
}
</script>
<script type="module">
import * as THREE from 'three';
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
import { VRMLoaderPlugin } from '@pixiv/three-vrm';
const scene = new THREE.Scene();
const loader = new GLTFLoader();
// Install GLTFLoader plugin
loader.register((parser) => {
return new VRMLoaderPlugin(parser);
});
loader.load(
// URL of the VRM you want to load
'/models/VRM1_Constraint_Twist_Sample.vrm',
// called when the resource is loaded
(gltf) => {
// retrieve a VRM instance from gltf
const vrm = gltf.userData.vrm;
// add the loaded vrm to the scene
scene.add(vrm.scene);
// deal with vrm features
console.log(vrm);
},
// called while loading is progressing
(progress) => console.log('Loading model...', 100.0 * (progress.loaded / progress.total), '%'),
// called when loading has errors
(error) => console.error(error),
);
</script>
via npm
Install three
and @pixiv/three-vrm
:
npm install three @pixiv/three-vrm
Code like this:
import * as THREE from 'three';
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader';
import { VRMLoaderPlugin } from '@pixiv/three-vrm';
const scene = new THREE.Scene();
const loader = new GLTFLoader();
// Install GLTFLoader plugin
loader.register((parser) => {
return new VRMLoaderPlugin(parser);
});
loader.load(
// URL of the VRM you want to load
'/models/VRM1_Constraint_Twist_Sample.vrm',
// called when the resource is loaded
(gltf) => {
// retrieve a VRM instance from gltf
const vrm = gltf.userData.vrm;
// add the loaded vrm to the scene
scene.add(vrm.scene);
// deal with vrm features
console.log(vrm);
},
// called while loading is progressing
(progress) => console.log('Loading model...', 100.0 * (progress.loaded / progress.total), '%'),
// called when loading has errors
(error) => console.error(error),
);
Contributing
See: CONTRIBUTING.md
LICENSE
4 days ago
3 months ago
3 months ago
3 months ago
3 months ago
4 months ago
4 months ago
4 months ago
4 months ago
6 months ago
9 months ago
8 months ago
9 months ago
10 months ago
8 months ago
8 months ago
8 months ago
9 months ago
6 months ago
7 months ago
10 months ago
6 months ago
11 months ago
11 months ago
12 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago