How to clone and retarget an animation group containing MorphTargets

My use case involves spawning a number of entities, and then removing them and some time later, respawning another batch. Some of these entities now contain ShapeKey/MorphTarget animation. If I don’t clone the MorphTarget itself, when the animation plays for one mesh clone, it is repeated on all clones of that mesh. I have not been able to get the MorphTarget to clone properly.

I’ve attached a playground showing both the assignment of the animation group, which plays the same animation on each mesh clone, as well as the attempt to clone the AnimationGroup containing the morptarget:


Retargeting is a complex task :slight_smile: I recommend using AssetContainer which is equipped for that task:

I was initially concerned about using this method due to some Material and Shader manipulation I was doing after the containers load (and to be frank, continuing to follow patterns we had from before our move from ThreeJS), but I was able to get everything remapping the textures to the meshes inside the container, and then using instantiateModelsToScene() to instantiate.

Thank you for the suggestion! The animations seem to be behaving as expected now.

1 Like