ThreeJS AnimationMixer

The AnimationMixer is a player that allows you to play animations on a specific object in the scene. When many items in a scene are animated individually, each object may have its own AnimationMixer.

The "Animation System" page in the "Next Steps" part of the handbook provides an overview of the various elements of the three.js animation system.

Constructor

AnimationMixer( rootObject : Object3D )

rootObject - the object whose animations shall be played by this mixer.

Properties

.time : Number

The global mixer time (in seconds; starting with 0 on the mixer's creation).

.timeScale : Number

A scaling factor for the global mixer time.

Note: You can pause/unpause all activities controlled by this mixer by setting the mixer's timeScale to 0 and then back to 1.

Methods

.clipAction (clip : AnimationClip, optionalRoot : Object3D) : AnimationAction

Returns an AnimationAction for the provided clip, with the option to use a different root object than the mixer's default root. An AnimationClip object or the name of an AnimationClip can be used as the first parameter.

This method will build an action that fits the clip and root parameters if one doesn't already exist. When this method is called multiple times with the same clip and root arguments, the result is always the same clip instance.

.existingAction (clip : AnimationClip, optionalRoot : Object3D) : AnimationAction

Returns an existing AnimationAction for the provided clip, with the option of selecting a different root object than the mixer's default root.

An AnimationClip object or the name of an AnimationClip can be used as the first parameter.

.getRoot () : Object3D

Returns this mixer's root object.

.stopAllAction () : this

Deactivates all previously scheduled actions on this mixer.

.update (deltaTimeInSeconds : Number) : this

Advances the global mixer time and updates the animation.

This is usually done in the render loop, passing clock.getDelta scaled by the mixer's timeScale).

.setTime (timeInSeconds : Number) : this

The global mixer is set to a specified time and the animation is updated accordingly.

This comes in handy when you need to jump to a specific point in an animation. The timeScale of the mixer will scale the input parameter.

.uncacheClip (clip : AnimationClip) : undefined

All memory resources for a clip are released. Make sure to call AnimationAction.stop() for all connected actions before utilising this function.

.uncacheRoot (root : Object3D) : undefined

All memory resources for a root item are released. Make sure to call AnimationAction.stop() for all connected actions before utilising this function.

.uncacheAction (clip : AnimationClip, optionalRoot : Object3D) : undefined

All memory resources for an action are released. Make sure to call AnimationAction before utilising this function. To deactivate the action, use stop().