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

时间:2015-11-27 14:09:19

标签: html animation three.js blender

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

2 个答案:

答案 0 :(得分:2)

旧问题,但如果有人需要,解决方案是设置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()
})

我指的是ThreeJS r84

答案 1 :(得分:0)

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

文档:http://threejs.org/docs/#Reference/Extras.Animation/Animation