mirror of
https://github.com/CesiumGS/obj2gltf.git
synced 2025-03-03 06:51:43 -05:00
Fix texture index when texture is shared by multiple material values
This commit is contained in:
parent
8d491afc70
commit
b8c5ebc8aa
@ -201,9 +201,7 @@ function addTexture(gltf, image) {
|
|||||||
source : imageIndex
|
source : imageIndex
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return textureIndex;
|
||||||
index : textureIndex
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTexture(gltf, image) {
|
function getTexture(gltf, image) {
|
||||||
@ -225,7 +223,9 @@ function getTexture(gltf, image) {
|
|||||||
if (!defined(textureIndex)) {
|
if (!defined(textureIndex)) {
|
||||||
textureIndex = addTexture(gltf, image);
|
textureIndex = addTexture(gltf, image);
|
||||||
}
|
}
|
||||||
return textureIndex;
|
return {
|
||||||
|
index : textureIndex
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function addColors(left, right) {
|
function addColors(left, right) {
|
||||||
@ -407,7 +407,7 @@ function createMetallicRoughnessTexture(gltf, metallicImage, roughnessImage, occ
|
|||||||
extension : '.png'
|
extension : '.png'
|
||||||
};
|
};
|
||||||
|
|
||||||
return addTexture(gltf, image);
|
return getTexture(gltf, image);
|
||||||
}
|
}
|
||||||
|
|
||||||
function createSpecularGlossinessTexture(gltf, specularImage, glossinessImage, options) {
|
function createSpecularGlossinessTexture(gltf, specularImage, glossinessImage, options) {
|
||||||
@ -471,7 +471,7 @@ function createSpecularGlossinessTexture(gltf, specularImage, glossinessImage, o
|
|||||||
extension : '.png'
|
extension : '.png'
|
||||||
};
|
};
|
||||||
|
|
||||||
return addTexture(gltf, image);
|
return getTexture(gltf, image);
|
||||||
}
|
}
|
||||||
|
|
||||||
function createSpecularGlossinessMaterial(gltf, images, material, options) {
|
function createSpecularGlossinessMaterial(gltf, images, material, options) {
|
||||||
@ -574,7 +574,7 @@ function createMetallicRoughnessMaterial(gltf, images, material, options) {
|
|||||||
metallicRoughnessTexture = createMetallicRoughnessTexture(gltf, metallicImage, roughnessImage, occlusionImage, 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 occlusionTexture = packOcclusion ? metallicRoughnessTexture : getTexture(gltf, occlusionImage);
|
||||||
|
|
||||||
var emissiveFactor = getEmissiveFactor(material);
|
var emissiveFactor = getEmissiveFactor(material);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user