Skip to content

Commit 2236516

Browse files
committed
Use a skinned model that shows off skinning
1 parent f9ae989 commit 2236516

File tree

4 files changed

+21
-31
lines changed

4 files changed

+21
-31
lines changed

examples/models/gltf/Michelle.glb

3.13 MB
Binary file not shown.

examples/webgpu_skinning.html

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
<script type="module">
2828

2929
import * as THREE from 'three';
30-
import { toneMapping, MeshStandardNodeMaterial } from 'three/nodes';
30+
import { toneMapping } from 'three/nodes';
3131

32-
import { FBXLoader } from 'three/addons/loaders/FBXLoader.js';
32+
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
3333

3434
import WebGPU from 'three/addons/capabilities/WebGPU.js';
3535
import WebGPURenderer from 'three/addons/renderers/webgpu/WebGPURenderer.js';
@@ -54,38 +54,27 @@
5454
camera.position.set( 1, 2, 3 );
5555

5656
scene = new THREE.Scene();
57+
scene.background = new THREE.Color( 'lightblue' );
5758
camera.lookAt( 0, 1, 0 );
5859

5960
clock = new THREE.Clock();
6061

6162
//lights
6263

6364
const light = new THREE.PointLight( 0xffffff, 1, 100 );
64-
light.power = 1700; // 100W
65+
light.power = 2500;
6566
camera.add( light );
6667
scene.add( camera );
6768

68-
const loader = new FBXLoader();
69-
loader.load( 'models/fbx/Samba Dancing.fbx', function ( object ) {
70-
71-
object.scale.setScalar( .01 );
69+
const loader = new GLTFLoader();
70+
loader.load( 'models/gltf/Michelle.glb', function ( gltf ) {
7271

72+
const object = gltf.scene;
7373
mixer = new THREE.AnimationMixer( object );
7474

75-
const action = mixer.clipAction( object.animations[ 0 ] );
75+
const action = mixer.clipAction( gltf.animations[ 0 ] );
7676
action.play();
7777

78-
object.traverse( function ( child ) {
79-
80-
if ( child.isMesh ) {
81-
82-
child.material = new MeshStandardNodeMaterial();
83-
child.material.roughness = .1;
84-
85-
}
86-
87-
} );
88-
8978
scene.add( object );
9079

9180
} );

examples/webgpu_skinning_instancing.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import * as THREE from 'three';
3030
import { mix, range, color, oscSine, timerLocal, toneMapping, MeshStandardNodeMaterial } from 'three/nodes';
3131

32-
import { FBXLoader } from 'three/addons/loaders/FBXLoader.js';
32+
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
3333

3434
import WebGPU from 'three/addons/capabilities/WebGPU.js';
3535
import WebGPURenderer from 'three/addons/renderers/webgpu/WebGPURenderer.js';
@@ -71,14 +71,14 @@
7171
camera.add( cameraLight );
7272
scene.add( camera );
7373

74-
const loader = new FBXLoader();
75-
loader.load( 'models/fbx/Samba Dancing.fbx', ( object ) => {
74+
const loader = new GLTFLoader();
75+
loader.load( 'models/gltf/Michelle.glb', function ( gltf ) {
7676

77-
object.scale.setScalar( .01 );
77+
const object = gltf.scene;
7878

7979
mixer = new THREE.AnimationMixer( object );
8080

81-
const action = mixer.clipAction( object.animations[ 0 ] );
81+
const action = mixer.clipAction( gltf.animations[ 0 ] );
8282
action.play();
8383

8484
const instanceCount = 30;
@@ -108,7 +108,7 @@
108108
for ( let i = 0; i < instanceCount; i ++ ) {
109109

110110
dummy.position.x = - 200 + ( ( i % 5 ) * 70 );
111-
dummy.position.z = Math.floor( i / 5 ) * - 200;
111+
dummy.position.y = Math.floor( i / 5 ) * - 200;
112112

113113
dummy.updateMatrix();
114114

examples/webgpu_skinning_points.html

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import * as THREE from 'three';
3030
import { uniform, skinning, PointsNodeMaterial } from 'three/nodes';
3131

32-
import { FBXLoader } from 'three/addons/loaders/FBXLoader.js';
32+
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
3333

3434
import WebGPU from 'three/addons/capabilities/WebGPU.js';
3535
import WebGPURenderer from 'three/addons/renderers/webgpu/WebGPURenderer.js';
@@ -51,19 +51,20 @@
5151
}
5252

5353
camera = new THREE.PerspectiveCamera( 50, window.innerWidth / window.innerHeight, 1, 1000 );
54-
camera.position.set( 100, 200, 300 );
54+
camera.position.set( 0, 300, -85 );
5555

5656
scene = new THREE.Scene();
57-
camera.lookAt( 0, 100, 0 );
57+
camera.lookAt( 0, 0, -85 );
5858

5959
clock = new THREE.Clock();
6060

61-
const loader = new FBXLoader();
62-
loader.load( 'models/fbx/Samba Dancing.fbx', function ( object ) {
61+
const loader = new GLTFLoader();
62+
loader.load( 'models/gltf/Michelle.glb', function ( gltf ) {
6363

64+
const object = gltf.scene;
6465
mixer = new THREE.AnimationMixer( object );
6566

66-
const action = mixer.clipAction( object.animations[ 0 ] );
67+
const action = mixer.clipAction( gltf.animations[ 0 ] );
6768
action.play();
6869

6970
object.traverse( function ( child ) {

0 commit comments

Comments
 (0)