meshTask + clone + animationGroups

I’m trying to figure out how to clone a mesh and the animationGroup for use in duplicate meshes throughout the world while using addMeshTask from the assetManager.

Here’s a PG: https://playground.babylonjs.com/#ZQPDEF#12

I can’t figure out how to clone the animationGroup properly for use in the second (cloned) mesh.

Thanks!

I’m not sure how this can be done using AnimationGroup, which is why I switched to using Skeletons and AnimationRanges imported from .babylon files, as shown in the demo: Dancers Performance demo. You can view the source code inside the .html file in the tag.

https://playground.babylonjs.com/#ZQPDEF#18

add method “addContainerTask” for BABYLON.AssetsManager (lines: 1 - 57)
use method “addContainerTask” (line: 83)

managing loaded object (lines: 107 - 114)

read this documentation:
https://doc.babylonjs.com/how_to/load_from_any_file_type
https://doc.babylonjs.com/how_to/how_to_use_assetcontainer

3 Likes

Thank you, @gbz and @Shaft_Dg, for these elegant demos and solutions!

1 Like

To follow up, I was able to successfully implement the solution provided by @Shaft_Dg to solve the issue. Thanks again!

This is so good, this should be in the documentation. Saved my day after I was trying to manually clone Transform Nodes for an animated modular mesh.