AnimationMixer.uncacheAction() 方法用于从 AnimationMixer 缓存中移除指定的 AnimationAction 对象。这样可以节省一些内存资源。
AnimationMixer.uncacheAction( action : AnimationAction ) : void
action:欲被移除缓存的 AnimationAction 对象。以下示例演示了如何使用 uncacheAction() 方法从缓存中移除 AnimationAction 对象:
// 创建 AnimationMixer 对象
const mixer = new THREE.AnimationMixer( scene );
// 创建 AnimationAction 对象
const action = mixer.clipAction( animationClip );
// 添加到缓存中
mixer.clipAction( action );
// 从缓存中移除
mixer.uncacheAction( action );
在此示例中,我们先创建了一个 AnimationMixer 对象和一个 AnimationAction 对象。然后将 AnimationAction 对象添加到 AnimationMixer 对象的缓存中。最后,使用 uncacheAction() 方法从缓存中移除 AnimationAction 对象。
AnimationAction 添加到 AnimationMixer 的缓存中,那么 uncacheAction() 方法将不起作用。AnimationAction 对象在缓存中只有一份拷贝。如果移除多个指向相同 AnimationAction 对象的引用,那么缓存中仍然只有一份拷贝。