播放一次动画而不是循环三个.js

Aru*_*mar 4 html animation blender three.js

我已将 Blender JSON 动画导出到 THREE.js,一切正常,但我只想播放一次动画并停止而不是循环播放动画。

a.b*_*eri 7

老问题,但万一有人需要它,解决方案是设置 animation.setLoop( THREE.LoopOnce )

let objLoader = new THREE.ObjectLoader()

objLoader.load('./your.json', function( obj )
{
  scene.add( obj )

  animationMixer = new THREE.AnimationMixer( obj )
  animation = animationMixer.clipAction( obj.animations[ 0 ] )
  animation.setLoop( THREE.LoopOnce )
  animation.clampWhenFinished = true
  animation.enable = true

  animation.play()
})
Run Code Online (Sandbox Code Playgroud)

我指的是 ThreeJS r84

  • 我发现我需要在“play”之后执行“reset”,所以“animation.play().reset();” (4认同)

Ten*_*n H 1

loop将对象的属性设置Animation为 false。

此处的文档:http :// Threejs.org/docs/#Reference/Extras.Animation/Animation