In three.js, can you reuse THREE.AnimationMixer between models? If not, why not just…
- User
In three.js, can you reuse THREE.AnimationMixer between models? If not, why not just have them be part of the mesh they are controlling?
Assistant
In three.js, you typically shouldn't reuse a single AnimationMixer between different models for a few key reasons:
- Each AnimationMixer maintains its own internal time and update state
- Mixers are designed to handle the animation system for a specific object hierarchy
- Using one mixer for multiple unrelated models would mean they all share the same timeline and update cycle
The reason AnimationMixer isn't built directly into mesh objects follows three.js's component-based design philosophy:
- Not all meshes need animation capabilities
- One mixer can control animations for an entire character (which might be composed of multiple meshes)
- This separation allows for more flexible animation control, like blending between animations or coordinating complex hierarchies
The standard pattern is to create one AnimationMixer per animated model or character:
// Create a mixer for each model const mixer1 = new THREE.AnimationMixer(model1); const mixer2 = new THREE.AnimationMixer(model2); // Update them independently function animate(time) { mixer1.update(deltaTime); mixer2.update(deltaTime); }Would you like me to explain more about how AnimationMixer works with complex models?
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.