UPDATE: Added simple sandbox version of the problem here → https://playground.babylonjs.com/#JLVTO4#1
Hi, for the last two days I’ve been sort of stuck on this problem and I don’t really know where to look any more to solve this. I’ve tried going through examples, documentation, youtube, etc. all the usual places. I guess I’m missing something? The closest I’ve seen is Babylon.js Playground but that seems to be not quite what I want to achieve.
I load a mesh from a glb file through assetsManager addContainerTask. This works fine. The asset is loaded and the first of three possible animations is rendered. So far so good.
const containerTask = this.assetsManager.addContainerTask(
name
,
[“meshName”],
".\folder",
“file”,
);
containerTask.onSuccess = (task) => {
const container = task.loadedContainer;
container.meshes.forEach((loadedMesh) => {
loadedMesh.setEnabled(true);
this.scene.addMesh(loadedMesh);
});
this.meshAnimationGroups.set(“name”, container.animationGroups);
container.animationGroups.forEach((animationGroup) => {
animationGroup.stop();
this.scene.addAnimationGroup(animationGroup);
});
};
Then I clone the mesh and I want to have it play e.g. the second animation, independently of the animation playing on the original mesh.
const mesh = this.scene.getMeshByName(currentMeshName) as Mesh;
const clonedMesh = mesh.clone(clonedMeshName);
clonedMesh.position.set(0,0,0);
This does in fact clone the mesh but it also just duplicates whatever animation is playing on the original mesh (no new AnimationGroups are added).
I want my clones to be able to individually play their animations.
My guess is that the AnimationGroup must also be cloned and then set to the new mesh? But how do I achieve that? And if this is incorrect, what is the proper way of doing having animations play independently on cloned meshes?
Any pointers on this would be much appreciated.