Q&A
three.jsでモデルを読み込んでアニメーションをさせたいのですが、モデルは読み込めるのですが、動作しません。
GLTFLoaderはCDNで読み込んでいます。
以下のようなコードです。
Javascript
1/** 2 * Models 3 */ 4 5const gltfLoader = new THREE.GLTFLoader(); 6 7let mixer = null 8 9gltfLoader.load( 10 '../static/models/Fox/glTF/Fox.gltf', 11 (gltf) => { 12 13 gltf.scene.scale.set(0.025, 0.025, 0.025) 14 scene.add(gltf.scene) 15 16 // Animation 17 mixer = new THREE.AnimationMixer(gltf.scene) 18 const action = mixer.clipAction(gltf.animations[0]) 19 action.play() 20 21 } 22 23) 24 25const clock = new THREE.Clock() 26let previousTime = 0 27 28const tick = () => 29{ 30 31 32 // Mixer 33 if(mixer) 34 { 35 mixer.update(deltaTime) 36 } 37 38 39 40 // Render 41 renderer.render(scene, camera) 42 43 // Call tick again on the next frame 44 window.requestAnimationFrame(tick) 45} 46 47tick()
回答よろしくお願いします。
回答1件
下記のような回答は推奨されていません。
このような回答には修正を依頼しましょう。
2022/01/15 05:49
2022/01/15 05:57
2022/01/15 07:34
2022/01/15 07:58
2022/01/15 08:46 編集
2022/01/15 09:05