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.uncacheRoot()

The uncacheRoot() method of the AnimationMixer class is used to remove the cached root object of the animation mixer. This method is called automatically when a new animation is added to the mixer, but can also be called manually when necessary.

Syntax

mixer.uncacheRoot()

Usage

Before explaining the usage of this method, it's important to understand what the "root object" of an animation mixer is. The root object is the highest level object in the hierarchy of objects that are being animated. For example, if you have an animated model with multiple meshes and bones, the root object would be the top-level object that contains all the meshes and bones as children.

When an animation is added to an animation mixer, the uncacheRoot() method is automatically called to cache the root object of the animated hierarchy. This is done so that the mixer can efficiently update the animation data for the entire hierarchy when necessary.

If you make changes to the hierarchy of objects being animated (for example, if you add or remove a mesh), you will need to call uncacheRoot() manually to ensure that the mixer has the correct root object for the updated hierarchy. Calling this method will clear the cached root object and force the mixer to recalculate the root object the next time it is needed.

Here is an example of how to use the uncacheRoot() method:

// Create an animation mixer
const mixer = new THREE.AnimationMixer(scene);

// Load an animated model and add it to the scene
const loader = new THREE.GLTFLoader();
loader.load('model.gltf', (gltf) => {
  scene.add(gltf.scene);

  // Get the root object of the animated hierarchy
  const root = gltf.scene.children[0];

  // Add the animation to the mixer
  const animation = mixer.clipAction(gltf.animations[0]);
  animation.play();

  // Make changes to the hierarchy of objects being animated
  root.add(new THREE.Mesh());

  // Uncache the root object to ensure that the mixer has the correct hierarchy
  mixer.uncacheRoot();
});

Parameters

This method doesn't take any parameters.

Return Value

This method doesn't return any value.

Exceptions

This method doesn't throw any exception.

Browser Support

This method is supported in all modern browsers.

See Also