diff --git a/lib/loadMtl.js b/lib/loadMtl.js index 17a31e7..e220536 100644 --- a/lib/loadMtl.js +++ b/lib/loadMtl.js @@ -387,7 +387,7 @@ function createDiffuseAlphaTexture(diffuseTexture, alphaTexture, options) { return diffuseTexture; } - if (diffuseTexture.path === alphaTexture.path) { + if (diffuseTexture === alphaTexture) { return diffuseTexture; } @@ -590,7 +590,7 @@ function createSpecularGlossinessMaterial(material, options) { emissiveFactor = [1.0, 1.0, 1.0]; } - if (defined(diffuseAlphaTexture)) { + if (defined(diffuseTexture)) { diffuseFactor = [1.0, 1.0, 1.0, 1.0]; } @@ -611,8 +611,8 @@ function createSpecularGlossinessMaterial(material, options) { transparent = alpha < 1.0; } - if (defined(diffuseAlphaTexture)) { - transparent = transparent || diffuseAlphaTexture.transparent; + if (defined(diffuseTexture)) { + transparent = transparent || diffuseTexture.transparent; } const doubleSided = transparent; @@ -662,7 +662,7 @@ function createMetallicRoughnessMaterial(material, options) { emissiveFactor = [1.0, 1.0, 1.0]; } - if (defined(diffuseAlphaTexture)) { + if (defined(baseColorTexture)) { baseColorFactor = [1.0, 1.0, 1.0, 1.0]; } @@ -683,8 +683,8 @@ function createMetallicRoughnessMaterial(material, options) { transparent = alpha < 1.0; } - if (defined(diffuseAlphaTexture)) { - transparent = transparent || diffuseAlphaTexture.transparent; + if (defined(baseColorTexture)) { + transparent = transparent || baseColorTexture.transparent; } const doubleSided = transparent; diff --git a/specs/lib/loadMtlSpec.js b/specs/lib/loadMtlSpec.js index 6d7eb7e..fb46c90 100644 --- a/specs/lib/loadMtlSpec.js +++ b/specs/lib/loadMtlSpec.js @@ -322,18 +322,16 @@ describe('loadMtl', () => { expect(material.doubleSided).toBe(true); }); - it('uses diffuse texture if diffuse and alpha are the same', async () => { + it('uses diffuse texture if diffuse and alpha are the same', () => { options.metallicRoughness = true; - // The transparent property will be modified so make a copy - const diffuseTextureCopy = await loadTexture(diffuseTexturePath, decodeOptions); const material = loadMtl._createMaterial({ - diffuseTexture : diffuseTextureCopy, + diffuseTexture : diffuseTexture, alphaTexture : diffuseTexture }, options); const pbr = material.pbrMetallicRoughness; - expect(pbr.baseColorTexture).toBe(diffuseTextureCopy); + expect(pbr.baseColorTexture).toBe(diffuseTexture); expect(material.alphaMode).toBe('BLEND'); expect(material.doubleSided).toBe(true); }); @@ -433,18 +431,16 @@ describe('loadMtl', () => { expect(material.doubleSided).toBe(true); }); - it('uses diffuse texture if diffuse and alpha are the same', async () => { + it('uses diffuse texture if diffuse and alpha are the same', () => { options.specularGlossiness = true; - // The transparent property will be modified so make a copy - const diffuseTextureCopy = await loadTexture(diffuseTexturePath, decodeOptions); const material = loadMtl._createMaterial({ - diffuseTexture : diffuseTextureCopy, + diffuseTexture : diffuseTexture, alphaTexture : diffuseTexture }, options); const pbr = material.extensions.KHR_materials_pbrSpecularGlossiness; - expect(pbr.diffuseTexture).toEqual(diffuseTextureCopy); + expect(pbr.diffuseTexture).toEqual(diffuseTexture); expect(material.alphaMode).toBe('BLEND'); expect(material.doubleSided).toBe(true); });