Material.clone() not working

Hi I’m need to clone a material, so I can have two independent shaders.
But when I do it the maps linked to the material seems not to be included in the new copy.
The code is some like

var mat1=new THREE.MeshPhongMaterial({ … });
var mat2=mat1.clone();

In mat1 (left sphere) I’m using only an envMap.
But the right sphere which uses mat2, has no envMap.


Any idea on how to create a complete clone? I using Three.js release 106

I’m afraid I’m not able to reproduce with this fiddle:

I found the problem. I was assigning the CubeTexture to material.envMap after texture load completes, so
when clone() was called envMap was null.