Skip to content

Animations

getAnimations

getAnimations(nodeId: string, callback: Function)

Returns the list of animations in the scene.

The nodeId is the ID of the node, which can be found via getNodeList.

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

playAnimation

playAnimation(nodeId: string, animationId: string, callback: Function)

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

The nodeId is the ID of the node, which can be found via getNodeList.

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

pauseAnimation

pauseAnimation(nodeId: string, animationId: string, callback: Function)

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

The nodeId is the ID of the node, which can be found via getNodeList.

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

stopAnimation

stopAnimation(nodeId: string, animationId: string, callback: Function)

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

The nodeId is the ID of the node, which can be found via getNodeList.

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

stopAnimations

stopAnimations(nodeId: string, callback: Function)

Stops all the animations.

The nodeId is the ID of the node, which can be found via getNodeList.

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

setAnimationCycleMode

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

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

The nodeId is the ID of the node, which can be found via getNodeList.

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

setAnimationSpeed

setAnimationSpeed(nodeId: string, speed: number, callback: Function)

Sets the global animation speed.

The nodeId is the ID of the node, which can be found via getNodeList.

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

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