# Material.clone() not working

**URL:** <https://discourse.threejs.org/t/material-clone-not-working/8614>\
**Category:** Questions\
**Tags:** materials, textures\
**Created:** [July 20, 2019, 1:49pm UTC](https://discourse.threejs.org/t/material-clone-not-working/8614 "2019-07-20T13:49:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fedeMarino](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/fedemarino/32/51061_2.png) [@fedeMarino](https://discourse.threejs.org/u/fedeMarino)\
**Post date:** [July 20, 2019, 1:49pm UTC](https://discourse.threejs.org/t/material-clone-not-working/8614/1 "2019-07-20T13:49:06Z")

</div>

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.

(CubeMap)

 ![Captura](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/2X/b/b78cf3ba90545b744ba110f74fa5b029717a8cae.jpeg)

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

---

<div class="post-metadata">

**Author:** ![Mugen87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mugen87/32/5645_2.png) [@Mugen87](https://discourse.threejs.org/u/Mugen87)\
**Post date:** [July 20, 2019, 2:08pm UTC](https://discourse.threejs.org/t/material-clone-not-working/8614/2 "2019-07-20T14:08:48Z")

</div>

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

[https://jsfiddle.net/8ay5eo24/1/](https://jsfiddle.net/8ay5eo24/1/)

---

<div class="post-metadata">

**Author:** ![fedeMarino](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/fedemarino/32/51061_2.png) [@fedeMarino](https://discourse.threejs.org/u/fedeMarino)\
**Post date:** [July 20, 2019, 2:29pm UTC](https://discourse.threejs.org/t/material-clone-not-working/8614/3 "2019-07-20T14:29:41Z")

</div>

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

Thanks!
