I see methods like .uncacheRoot
, .uncacheAction,
and .uncacheClip
on AnimationMixer.
Usually I wind up calling all three of these when I want to cleanup animations, but I want to better understand the rule of thumb for when to use each.
For instance, both .uncacheAction
and .uncacheClip
take an AnimationClip as their argument, so I’m not sure the difference between calling these. Typically I only have one action per clip so almost always call them both just to be safe, but I notice Drei’s “useAnimations” only calls .uncacheAction
when cleaning up animations (source).
In general, you use these methods to free internal resources for actions, clips and the root object itself. The difference between uncacheAction()
and uncacheClip()
is that a clip can have multiple actions (but not the other way around). So if you want to free resources for a single action use uncacheAction()
, for the entire clip (with all of its actions) use uncacheClip()
.
You don’t have to call uncacheAction()
if you call uncacheClip()
.
2 Likes
The caching of an animation also takes a little bit of time since it iterates through the keyframes and creates property bindings to the actual bone layout/skeleton and properties that the animation is being played on.
So generally I think you only want to uncache animations/clips when you’re sure you won’t be needing them again (soon).
For instance in an editor of some kind… when you load a new document in the editor, that might be a good time to uncache any existing animations/actions.
Alternatively, leaving them cached means next time you play the animation it will fire up a little quicker.
I don’t think the data being cached is very large. The property bindings are cached more for performance rather than memory reasons.