D J Y 2022-08-01 14:56 采纳率: 0%
浏览 143
已结题

如何在vue.js 使用threejs,用for循环循环出多个模型?

在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个模型都同时加载动画
  • 写回答

2条回答 默认 最新

  • 崽崽的谷雨 2022-08-01 15:12
    关注

    let 换成var 试试

    评论

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 8月3日
  • 修改了问题 8月3日
  • 修改了问题 8月1日
  • 修改了问题 8月1日
  • 展开全部