Skip to content

Animations

getAnimations

getAnimations(callback: Function)

Returns the list of animations in the scene.

js
api.getAnimations(function(animations){
  console.log(animations); // Result: [{ name: 'Animation', speedRatio: 1 }]
});

playAnimation

playAnimation(animationId: string, callback: Function)

Plays the animation by animationId. Get the animationId from the getAnimations list.

js
api.playAnimation('walk', function(){
  console.log('Animation playing');
});

pauseAnimation

pauseAnimation(animationId: string, callback: Function)

Pauses the animation by animationId. Get the animationId from the getAnimations list.

js
api.pauseAnimation('walk', function(){
  console.log('Animation paused');
});

stopAnimation

stopAnimation(animationId: string, callback: Function)

Stops the animation by animationId. Get the animationId from the getAnimations list.

js
api.stopAnimation('walk', function(){
  console.log('Animation stopped');
});

stopAnimations

stopAnimations(callback: Function)

Stops all the animations.

js
api.stopAnimation('walk', function(){
  console.log('Animation stopped');
});

setAnimationCycleMode

setAnimationCycleMode(animationId: string, mode: 'loop' | 'once' , callback: Function)

Sets the animation cycle mode. (Default is once). Get the animationId from the getAnimations list.

js
api.setAnimationCycleMode('walk', 'loop', function(){
  console.log('Animation cycle mode changed');
});

setAnimationSpeed

setAnimationSpeed(speed: number, callback: Function)

Sets the global animation speed.

speed is a speed factor (a number, default is 1). A negative value will play the animation in reverse.

js
api.setAnimationSpeed(1.5, function(){
  console.log('Animation speed changed');
});