From b8c5ebc8aa8c601ed48a43ac0a51a48f9a447927 Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Tue, 25 Jul 2017 11:41:39 -0400 Subject: [PATCH] Fix texture index when texture is shared by multiple material values --- lib/createGltf.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/createGltf.js b/lib/createGltf.js index 7c20b35..f26bee2 100644 --- a/lib/createGltf.js +++ b/lib/createGltf.js @@ -201,9 +201,7 @@ function addTexture(gltf, image) { source : imageIndex }); - return { - index : textureIndex - }; + return textureIndex; } function getTexture(gltf, image) { @@ -225,7 +223,9 @@ function getTexture(gltf, image) { if (!defined(textureIndex)) { textureIndex = addTexture(gltf, image); } - return textureIndex; + return { + index : textureIndex + }; } function addColors(left, right) { @@ -407,7 +407,7 @@ function createMetallicRoughnessTexture(gltf, metallicImage, roughnessImage, occ extension : '.png' }; - return addTexture(gltf, image); + return getTexture(gltf, image); } function createSpecularGlossinessTexture(gltf, specularImage, glossinessImage, options) { @@ -471,7 +471,7 @@ function createSpecularGlossinessTexture(gltf, specularImage, glossinessImage, o extension : '.png' }; - return addTexture(gltf, image); + return getTexture(gltf, image); } function createSpecularGlossinessMaterial(gltf, images, material, options) { @@ -574,7 +574,7 @@ function createMetallicRoughnessMaterial(gltf, images, material, options) { metallicRoughnessTexture = createMetallicRoughnessTexture(gltf, metallicImage, roughnessImage, occlusionImage, options); } - var packOcclusion = defined(occlusionImage) && options.packOcclusion || defined(options.metallicRoughnessOcclusionTexture); + var packOcclusion = (defined(occlusionImage) && options.packOcclusion) || defined(options.metallicRoughnessOcclusionTexture); var occlusionTexture = packOcclusion ? metallicRoughnessTexture : getTexture(gltf, occlusionImage); var emissiveFactor = getEmissiveFactor(material);