Fix texture index when texture is shared by multiple material values

This commit is contained in:
Sean Lilley 2017-07-25 11:41:39 -04:00
parent 8d491afc70
commit b8c5ebc8aa
1 changed files with 7 additions and 7 deletions

View File

@ -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);