BufferGeometry
Object3D
Raycaster
Camera
CubeCamera
PerspectiveCamera
OrthographicCamera
StereoCamera
Clock
Curve
CurvePath
Path
Shape
ShapePath
ArrowHelper
AxesHelper
BoxHelper
Box3Helper
CameraHelper
DirectionalLightHelper
GridHelper
PolarGridHelper
HemisphereLightHelper
PlaneHelper
PointLightHelper
SkeletonHelper
SpotLightHelper
Light
PointLight
RectAreaLight
SpotLight
DirectionalLight
HemisphereLight
LightShadow
PointLightShadow
AnimationLoader
AudioLoader
BufferGeometryLoader
CompressedTextureLoader
CubeTextureLoader
DataTextureLoader
FileLoader
ImageBitmapLoader
ImageLoader
Loader
LoaderUtils
MaterialLoader
ObjectLoader
TextureLoader
LoadingManager
Material
Box2
Box3
Color
Cylindrical
Euler
Frustum
Interpolant
Line3
MathUtils
Matrix3
Matrix4
Plane
Quaternion
AnimationAction
AnimationClip
AnimationMixer
AnimationObjectGroup
AnimationUtils
keyframeTrack
PropertyBinding
PropertyMixer
BooleanKeyframeTrack
QuaternionKeyframeTrack
StringKeyframeTrack
Audio
AudioAnalyser
AudioContext
AudioListener
PositionalAudio

AnimationMixer.update()

AnimationMixer.update() is a method in the Three.js library that allows the user to update the mixer's animation data.

Syntax

animationMixer.update( deltaTime );

Parameters

  • deltaTime [optional] : A number that indicates the delta time since the last update, in seconds. If not provided, the value is computed automatically.

Return Value

  • None

Description

The AnimationMixer class is responsible for handling all of the animations within a given scene. The update() method is an essential component of the animation system, as it updates the animation data by invoking the animate() function on all the animations that are currently being controlled by the mixer.

When the update() method is called, it takes the delta time as a parameter. Delta time is simply the amount of time that has passed since the last time the update() method was called. If no delta time is specified, the method will automatically calculate the delta time using the current system time.

By updating the mixer's animation data, the update() method ensures that all the animations within the scene are played back correctly. Additionally, the method can also be used to pause or stop an animation if needed.

Examples

var mixer = new THREE.AnimationMixer( mesh )

var animation = THREE.AnimationClip.findByName( animations, 'animation1' )
var action = mixer.clipAction( animation )

action.play()

function animate() {
  requestAnimationFrame( animate )

  // update the mixer with proper delta time
  mixer.update( clock.getDelta() )

  renderer.render( scene, camera )
}

This example shows how the update() method is used to update the mixer's animation data in a rendering loop. Notice how the mixer is created and used to play an animation, while the update() method is called in the animate() function. Also, note that clock.getDelta() is passed as the delta time parameter to the update() method to ensure correct playback timing.

Remarks

  • The update() method should be called on every animation frame to ensure correct playback timing.
  • If the delta time is not provided, the method will automatically calculate it.