play animation once instead of looping three.js

I have exported blender JSON animation into THREE.js, everything works fine, but I want to play the animation only once and stop instead of looping the animation.

Answers


Old question, but in case anyone needs it the solution is to set 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()
})

I'm referring to ThreeJS r84.


Set the loop property on the Animation object to false.

documentation here: http://threejs.org/docs/#Reference/Extras.Animation/Animation


Need Your Help

Get product ID on product compare page in Magento?

php magento magento-1.7

I would like to separate some attributes according to product category ID.

Where Is DrawingBrush In Windows Metro for XAML

wpf xaml windows-runtime winrt-xaml

Im writing a Windows Metro XAML based app in C#, and I want to draw grid lines with a brush on my custom grid control.