Cloning a rigged mesh and dealing with skinned materials Ask Question

I have a scene with multiple rigged meshes uploaded from a .json file. To create independent meshes I use .copy(). I want all these meshes to have different materials, every material must have different color.


jsonLoader.load("models/player.json", function (geometry, materials) {
    materials.forEach(function (material) {
        material.skinning = true;
        material.side = THREE.FrontSide;
    meshes.player = new THREE.SkinnedMesh(geometry, materials);
    meshes.player.castShadow = true;
    meshes.player.receiveShadow = true;

Than clone it:

mesh = meshes.player.clone();
mesh.material[0] = meshes.player.material[0].clone();
mesh.material[0].color.setHex( randomColor );

But it works very weird: if I add to the scene one mesh with random color and than add second mesh with the other color, the first mesh changes it’s color to the color of the second mesh.

All my materials use skinning, every mesh must have it’s own skeleton. I found this page on GitHub, maybe I have the same issue. But I still don’t realise how skeleton affects material.

Leave a Reply

Your email address will not be published. Required fields are marked *