Skip to content

Commit

Permalink
Set texture api (google#2379)
Browse files Browse the repository at this point in the history
* clone textures to prevent all like objects from pointing at the same texture instance

* Adds bespoke api for setting texture maps

* added nullness checks

* removed metallicRoughness setters from material

* removing API additions for now

Co-authored-by: Emmett Lalish <[email protected]>
  • Loading branch information
SrirachaSource and elalish authored May 14, 2021
1 parent 2baee76 commit 4d766f7
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,24 @@ export class ModelViewerGLTFInstance extends GLTFInstance {
}

const clone = material.clone() as MeshStandardMaterial;
if (material.map != null) {
material.map = material.map.clone();
}
if (material.normalMap != null) {
material.normalMap = material.normalMap.clone();
}
if (material.aoMap != null) {
material.aoMap = material.aoMap.clone();
}
if (material.emissiveMap != null) {
material.emissiveMap = material.emissiveMap.clone();
}
if (material.metalnessMap != null) {
material.metalnessMap = material.metalnessMap.clone();
}
if (material.roughnessMap != null) {
material.roughnessMap = material.roughnessMap.clone();
}

// This allows us to patch three's materials, on top of patches already
// made, for instance GLTFLoader patches SpecularGlossiness materials.
Expand Down

0 comments on commit 4d766f7

Please sign in to comment.