AnimationMixer
Quick answer
AnimationMixer binds AnimationClips to an object hierarchy and advances their playback over time. You create actions with clipAction(), play them, and call update(deltaTime) every frame in seconds, making it the entry point for glTF or FBX skeletal animation. Use it whenever a loaded model contains clips that must loop, blend, or cross-fade.
new THREE.AnimationMixer ( rootObject )
Key points
- clipAction(clip) returns a reusable AnimationAction; call play(), setLoop(), and fadeIn() on it to control playback.
- Pass delta time in seconds to update(); setTime() jumps to a specific point for scrubbing.
- Listen for the 'finished' event on the mixer to detect when non-looping actions end.
Example
const loader = new GLTFLoader();
loader.load('/models/escalator.glb', function (gltf) {
scene.add(gltf.scene);
const mixer = new THREE.AnimationMixer(gltf.scene);
gltf.animations.forEach(function (clip) {
const action = mixer.clipAction(clip);
action.setLoop(THREE.LoopRepeat, Infinity);
action.play();
});
mixer.addEventListener('finished', function (event) {
console.log('播放结束', event.action.getClip().name);
});
clock.start();
renderer.setAnimationLoop(function () {
const delta = clock.getDelta();
mixer.update(delta);
renderer.render(scene, camera);
});
});const idle = mixer.clipAction(idleClip);
const walk = mixer.clipAction(walkClip);
idle.play();
walk.play();
walk.setEffectiveWeight(0); // 先挂上,权重为 0
function blendToWalk(t) {
walk.setEffectiveWeight(t);
idle.setEffectiveWeight(1 - t);
}
Notes
- stopAllAction() freezes the model on its last pose; reset action time to 0 and call update(0) to restore the bind pose.
- Mixers are per root object, so animated models loaded separately need separate AnimationMixer instances.
English edition written for Atlaslog. Code is taken from the original Chinese page and runs unchanged.
Atlaslog (2026). AnimationMixer. https://www.jingweizhi.com/en/three/api/animation-mixer.html (accessed 2026-11-03).