Hi team,
I am in a scenario where I have identical armatures meshes, I am thinking if its possible to clone skeleton and animationGroup of one mesh to another, for example I am loading an armature’s gltf model like this, please see comments at last here I am not sure how to copy animation group and start playing ?
:
var firstArmatureMesh = false;
//below I just get the mesh from first task, it doesn't have skeleton/animations
const firstPerson = assetsManager.addMeshTask('firstPerson', '', '/assets/', 'firstPerson.glb');
firstPerson.onSuccess = (task) => {
firstArmatureMesh = task.loadedMeshes[0];
}
// next I need to copy skeleton and animations to first
const secondPerson = assetsManager.addMeshTask('secondPerson', '', '/assets/', 'secondPerson.glb');
secondPerson.onSuccess = (task) => {
let skeleton = task.loadedSkeletons[0];
let secondArmatureMesh = task.loadedMeshes[0];
let animations = task.loadedAnimationGroups;
// here I am playing second animation, which works fine
animations[0].stop();
animations[1].play(true);
// here I have check if first armature model is loaded and copy skeleton and animations to it
if(firstArmatureMesh){
firstArmatureMesh.skelton = skeleton.clone("copy");
// here I am not sure how to copy animation group and start playing, something like below ?
firstArmatureMesh.animations = animations.clone("copy");
}
}
Thanks
Edit:
I found about cloning animation group, but it doesn’t effect anything.
let idle = animations[0].clone('idle01', (target) => {
let idx = firstArmatureMesh.skeleton.getBoneIndexByName(target.name)
return firstArmatureMesh.skeleton.bones[idx]
})
let walk = animations[1].clone('walk01', (target) => {
let idx = firstArmatureMesh.skeleton.getBoneIndexByName(target.name)
return firstArmatureMesh.skeleton.bones[idx]
})
walk.play(true);