Changing material causes rest position to mesh and loading pose from json

Hello! I have two questions:

  1. I am using a GLTFLoader for loading my 3d model with armature and special pose

    loader.load( ‘./untitled17.glb’, function ( gltf ) {

     /*gltf.scene.traverse((o) => {
       if (o.isMesh) {
     	o.material = new THREE.MeshPhongMaterial({color: 0x46C6E7});
     	o.updateMatrix();
       }
     });*/
     scene.add( gltf.scene );
    
     gltf.scene.castShadow = true;
     gltf.scene.rotateX(-1.5708);
     gltf.scene.position.set(0, -3.65, 0);
     
     console.log(gltf.scene.children[0].children[0]);
     
     var helper = new THREE.SkeletonHelper( gltf.scene );
     scene.add( helper );
    

    }, undefined, function ( error ) {
    console.error( error );
    } );

But when I try to change material with that commented piece of code, my model became in rest position, but skeletonhelper shows that skeleton is in the right pose. What do I do wrong?

  1. I was trying to JSON.stringify() bones object from gltf.scene to save skeleton and then load it with JSON.parse() but it breaks functions inside object, throws a lot ‘uncaught TypeError: children[i].updateMatrixWorld is not a function’ erros and doesnt work at all. Is there any way to load dynamicly pose for model from json string?

I will be very glad if someone answers me.

What happens if you leave this commented out?

model became in rest position too.
https://dropmefiles.com/PqjkN

I wasn’t able to reproduce your problem.
See this example where you can change the material.

1st - Press the ‘bellydance’ button so that the pose changes,
2nd - Press the ‘Change Texture’ button.

It doesn’t reset the pose.

Maybe create a working example somewhere.

Unfortunately I cant upload now it somewhere so I will give you source code with model https://dropmefiles.com/hslqy

add
o.material.skinning = true
to your traverse

Thank you very much! Do you know something about my second question or can you tell me some keywords which can help me in googling ? I found only suggestions to receive full model with skeleton and load it, but I think there must be a better solution.