在vue.js 使用threejs,用for循环循环出多个模型,但只有最有一个模型有动画?
for (let i = 0; i < 3; i++) {
that.loader.load('https://threejs.org/examples/models/fbx/Samba%20Dancing.fbx', (object) => {
object.position.set(-100 + i * 150, 0, 0)
object.children[0].position.set(0, 100, 0)
object.traverse((child) => {
if (child.isMesh) {
child.castShadow = true
child.receiveShadow = true
}
})
that.mixer = new THREE.AnimationMixer(object)
that.actions = that.mixer.clipAction(object.animations[0])
that.actions.play()
that.scene.add(object)
that.animate()
}
})
}
实际结果:只有最后一个模型加载动画,其他的都是定格的
要实现的效果:10个模型都同时加载动画