@pixiv/three-vrm 3.0.0-beta.1 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -20,23 +20,21 @@ Use [VRM](https://vrm.dev/) on [three.js](https://threejs.org/)
20
20
 
21
21
  You will need:
22
22
 
23
- - [Three.js build](https://github.com/mrdoob/three.js/blob/master/build/three.js)
24
- - [GLTFLoader](https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/GLTFLoader.js)
25
- - [A build of @pixiv/three-vrm](https://www.jsdelivr.com/package/npm/@pixiv/three-vrm?tab=files&path=lib)
23
+ - Three.js build
24
+ - GLTFLoader
25
+ - A build of @pixiv/three-vrm
26
26
  - `.module` ones are ESM, otherwise it's UMD and injects its modules into global `THREE`
27
27
  - `.min` ones are minified (for production), otherwise it's not minified and it comes with source maps
28
28
 
29
- You can import all of them via CDN. See the example below.
30
-
31
- Code like this:
29
+ You can import all the dependencies via CDN like [jsDelivr](https://www.jsdelivr.com/).
32
30
 
33
31
  ```html
34
32
  <script type="importmap">
35
33
  {
36
34
  "imports": {
37
- "three": "https://cdn.jsdelivr.net/npm/three@0.164.1/build/three.module.js",
38
- "three/addons/": "https://cdn.jsdelivr.net/npm/three@0.164.1/examples/jsm/",
39
- "@pixiv/three-vrm": "three-vrm.module.js"
35
+ "three": "https://cdn.jsdelivr.net/npm/three@0.167.0/build/three.module.js",
36
+ "three/addons/": "https://cdn.jsdelivr.net/npm/three@0.167.0/examples/jsm/",
37
+ "@pixiv/three-vrm": "https://cdn.jsdelivr.net/npm/@pixiv/three-vrm@3/lib/three-vrm.module.min.js"
40
38
  }
41
39
  }
42
40
  </script>
@@ -46,11 +44,12 @@ Code like this:
46
44
  import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
47
45
  import { VRMLoaderPlugin } from '@pixiv/three-vrm';
48
46
 
49
- const scene = new THREE.Scene();
47
+ // ... Setup renderer, camera, scene ...
50
48
 
49
+ // Create a GLTFLoader - The loader for loading VRM models
51
50
  const loader = new GLTFLoader();
52
51
 
53
- // Install GLTFLoader plugin
52
+ // Install a GLTFLoader plugin that enables VRM support
54
53
  loader.register((parser) => {
55
54
  return new VRMLoaderPlugin(parser);
56
55
  });
@@ -77,9 +76,15 @@ Code like this:
77
76
  // called when loading has errors
78
77
  (error) => console.error(error),
79
78
  );
79
+
80
+ // ... Perform the render loop ...
80
81
  </script>
81
82
  ```
82
83
 
84
+ See the Three.js document if you are not familiar with Three.js yet: https://threejs.org/docs/#manual/en/introduction/Creating-a-scene
85
+
86
+ See the example for the complete code: https://github.com/pixiv/three-vrm/blob/release/packages/three-vrm/examples/basic.html
87
+
83
88
  ### via npm
84
89
 
85
90
  Install [`three`](https://www.npmjs.com/package/three) and [`@pixiv/three-vrm`](https://www.npmjs.com/package/@pixiv/three-vrm) :
@@ -88,59 +93,22 @@ Install [`three`](https://www.npmjs.com/package/three) and [`@pixiv/three-vrm`](
88
93
  npm install three @pixiv/three-vrm
89
94
  ```
90
95
 
91
- Code like this:
92
-
93
- ```javascript
94
- import * as THREE from 'three';
95
- import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
96
- import { VRMLoaderPlugin } from '@pixiv/three-vrm';
97
-
98
- const scene = new THREE.Scene();
99
-
100
- const loader = new GLTFLoader();
101
-
102
- // Install GLTFLoader plugin
103
- loader.register((parser) => {
104
- return new VRMLoaderPlugin(parser);
105
- });
106
-
107
- loader.load(
108
- // URL of the VRM you want to load
109
- '/models/VRM1_Constraint_Twist_Sample.vrm',
110
-
111
- // called when the resource is loaded
112
- (gltf) => {
113
- // retrieve a VRM instance from gltf
114
- const vrm = gltf.userData.vrm;
115
-
116
- // add the loaded vrm to the scene
117
- scene.add(vrm.scene);
118
-
119
- // deal with vrm features
120
- console.log(vrm);
121
- },
122
-
123
- // called while loading is progressing
124
- (progress) => console.log('Loading model...', 100.0 * (progress.loaded / progress.total), '%'),
125
-
126
- // called when loading has errors
127
- (error) => console.error(error),
128
- );
129
- ```
130
-
131
96
  ### Use with WebGPURenderer
132
97
 
133
98
  Starting from v3, we provide [WebGPURenderer](https://github.com/mrdoob/three.js/blob/master/examples/jsm/renderers/webgpu/WebGPURenderer.js) compatibility.
134
99
  To use three-vrm with WebGPURenderer, specify the WebGPU-compatible `MToonNodeMaterial` for the `materialType` option of `MToonMaterialLoaderPlugin`.
135
100
 
136
- `MToonNodeMaterial` only supports Three.js r161 or later.
101
+ `MToonNodeMaterial` only supports Three.js r167 or later.
137
102
  The NodeMaterial system of Three.js is still under development, so we may break compatibility with older versions of Three.js more frequently than other parts of three-vrm.
138
103
 
139
104
  ```js
140
105
  import { VRMLoaderPlugin } from '@pixiv/three-vrm';
141
106
  import { MToonNodeMaterial } from '@pixiv/three-vrm/nodes';
142
107
 
143
- // ...
108
+ // ... Setup renderer, camera, scene ...
109
+
110
+ // Create a GLTFLoader
111
+ const loader = new GLTFLoader();
144
112
 
145
113
  // Register a VRMLoaderPlugin
146
114
  loader.register((parser) => {
@@ -161,8 +129,12 @@ loader.register((parser) => {
161
129
  });
162
130
 
163
131
  });
132
+
133
+ // ... Load the VRM and perform the render loop ...
164
134
  ```
165
135
 
136
+ See the example for the complete code: https://github.com/pixiv/three-vrm/blob/release/packages/three-vrm/examples/webgpu-dnd.html
137
+
166
138
  ## Contributing
167
139
 
168
140
  See: [CONTRIBUTING.md](CONTRIBUTING.md)