Animations
getAnimations
getAnimations(geometryId: string, callback: Function)
Returns the list of animations in the scene.
The geometryId
is the ID of the geometry, which can be found via getGeometries.
api.getAnimations(geometryId, function(animations){
console.log(animations); // Result: [{ name: 'Animation', speedRatio: 1 }]
});
playAnimation
playAnimation(geometryId: string, animationId: string, callback: Function)
Plays the animation by animationId. Get the animationId from the getAnimations list.
The geometryId
is the ID of the geometry, which can be found via getGeometries.
api.playAnimation(geometryId, 'walk', function(){
console.log('Animation playing');
});
pauseAnimation
pauseAnimation(geometryId: string, animationId: string, callback: Function)
Pauses the animation by animationId. Get the animationId from the getAnimations list.
The geometryId
is the ID of the geometry, which can be found via getGeometries.
api.pauseAnimation(geometryId, 'walk', function(){
console.log('Animation paused');
});
stopAnimation
stopAnimation(geometryId: string, animationId: string, callback: Function)
Stops the animation by animationId. Get the animationId from the getAnimations list.
The geometryId
is the ID of the geometry, which can be found via getGeometries.
api.stopAnimation(geometryId, 'walk', function(){
console.log('Animation stopped');
});
stopAnimations
stopAnimations(geometryId: string, callback: Function)
Stops all the animations.
The geometryId
is the ID of the geometry, which can be found via getGeometries.
api.stopAnimation(geometryId, 'walk', function(){
console.log('Animation stopped');
});
setAnimationCycleMode
setAnimationCycleMode(geometryId: string, animationId: string, mode: 'loop' | 'once' , callback: Function)
Sets the animation cycle mode. (Default is once
). Get the animationId from the getAnimations list.
The geometryId
is the ID of the geometry, which can be found via getGeometries.
api.setAnimationCycleMode(geometryId, 'walk', 'loop', function(){
console.log('Animation cycle mode changed');
});
setAnimationSpeed
setAnimationSpeed(geometryId: string, speed: number, callback: Function)
Sets the global animation speed.
The geometryId
is the ID of the geometry, which can be found via getGeometries.
speed
is a speed factor (a number, default is 1). A negative value will play the animation in reverse.
api.setAnimationSpeed(geometryId, 1.5, function(){
console.log('Animation speed changed');
});