Dear Deltakosh, I can’t share all code, it is very big, but i will insert the method i use for cloning. my mesh is a character from Mixamo, how I can clone the color material?
BABYLON.SceneLoader.ImportMesh("",root_path,data,this.scene,(meshes, particleSystems, skeletons)=>{
for(let i=0; i< meshes.length; i++){
meshes[i].rotation.x = -Math.PI/2;
meshes[i].rotation.y = Math.PI;
meshes[i].material.needDepthPrePass = true;//is ture????
meshes[i].convertToUnIndexedMesh(); //is ture????
meshes[i].actionManager = new BABYLON.ActionManager(scene);
meshes[i].actionManager.registerAction(
new BABYLON.ExecuteCodeAction({
trigger: BABYLON.ActionManager.OnPickTrigger,
},
function () { showAvatarPanel(AVATARS[mesh_name]); }
)
);
if( (x&&z) || x ==0 || z == 0)
moveOBJToPositionXZ(meshes,x,z);
if( babylon_name == 'paladin' || babylon_name == 'vampire' )
meshes[i].scaling = new BABYLON.Vector3(0.2,0.2,0.2);
else if(babylon_name == 'eva' || babylon_name == 'maw')
meshes[i].scaling = new BABYLON.Vector3(0.22,0.22,0.22);
else if( babylon_name == 'demon')
meshes[i].scaling = new BABYLON.Vector3(0.18,0.18,0.18);
else if(babylon_name == 'knight' || babylon_name == 'akai' || babylon_name == 'ganfaul' || babylon_name == 'nightshade' )
meshes[i].scaling = new BABYLON.Vector3(0.15,0.15,0.15);
else
meshes[i].scaling = new BABYLON.Vector3(0.11,0.11,0.11);
//["akai","castle_guard","demon","eva","ganfaul","goblin","knight","maw","nightshade","paladin","vampire"];
}
for (var count = 0; count < 50; count++) {
var offsetX = 200 * Math.random() - 100;
var offsetZ = 200 * Math.random() - 100;
for (index = 0; index < meshes.length; index++) {
var instance = meshes[index].createInstance("instance" + count);
instance.parent = meshes[index].parent;
instance.position = meshes[index].position.clone();
// if (!instance.parent.subMeshes) {
instance.position.x += offsetX;
instance.position.z -= offsetZ;
// }
}
}
if(setCameraForThis)
camera.setTarget(meshes[0]);
stopAvatar(mesh_name,AVATARS,scene);
// playAnimation(scene,skeletons[0],3,94,true,1.0);
// playAnimation(scene,skeletons[0],101,133,true,1.0);
// playAnimation(scene,skeletons[0],142,156,true,1.0);
scene.setRenderingAutoClearDepthStencil(meshes.index, false, false, false);
});