marcofugaro / three-projected-material

📽 Three.js Material which lets you do Texture Projection on a 3d Model
https://marcofugaro.github.io/three-projected-material/
MIT License
671 stars 57 forks source link

Clone material to re-used it #24

Closed vignalbrice closed 2 years ago

vignalbrice commented 2 years ago

Hi everyone, My issue is the next one, i want to clone my ProjectMaterial, but when I do material.clone() I get this error :

"Error: Invalid camera passed to the ProjectedMaterial"

This is my code:

        let cloneActiveMaterial;
        let cloneMaterial;
        if (this.activeMesh.name === mesh.name) {
          mesh.camera = projectionCamera
          cloneActiveMaterial = mesh.material.clone();
        } else {
          cloneMaterial = mesh.material.clone()
        }
         if (this.activeMesh.name === mesh.name && properties.elem === "Texture") {
          this.activeMesh.material.map = currTexture;
          this.activeMesh.material.camera = projectionCamera
          this.activeMesh.material.needsUpdate = true;
        }