mirror of https://github.com/CesiumGS/obj2gltf.git
Fixes errors when `materialOverrides` is not passed to `loadMtl`
This commit is contained in:
parent
4251c8491c
commit
b056b84ec6
|
@ -48,6 +48,7 @@ function loadMtl(mtlPath, options) {
|
||||||
const overridingDiffuseTexture = overridingTextures.baseColorTexture;
|
const overridingDiffuseTexture = overridingTextures.baseColorTexture;
|
||||||
const overridingEmissiveTexture = overridingTextures.emissiveTexture;
|
const overridingEmissiveTexture = overridingTextures.emissiveTexture;
|
||||||
const overridingAlphaTexture = overridingTextures.alphaTexture;
|
const overridingAlphaTexture = overridingTextures.alphaTexture;
|
||||||
|
const materialOverrides = defined(options.materialOverrides) ? options.materialOverrides : {};
|
||||||
|
|
||||||
// Textures that are packed into PBR textures need to be decoded first
|
// Textures that are packed into PBR textures need to be decoded first
|
||||||
const decodeOptions = {
|
const decodeOptions = {
|
||||||
|
@ -68,17 +69,17 @@ function loadMtl(mtlPath, options) {
|
||||||
};
|
};
|
||||||
|
|
||||||
function createMaterial(name) {
|
function createMaterial(name) {
|
||||||
const materialOverrides = options.materialOverrides[name] || {};
|
const thisMaterialOverrides = defined(materialOverrides[name]) ? materialOverrides[name] : {};
|
||||||
material = new Material();
|
material = new Material();
|
||||||
material.name = name;
|
material.name = name;
|
||||||
material.specularShininess = options.metallicRoughness ? 1.0 : 0.0;
|
material.specularShininess = options.metallicRoughness ? 1.0 : 0.0;
|
||||||
material.specularTexture = materialOverrides.specularTexture || overridingSpecularTexture;
|
material.specularTexture = thisMaterialOverrides.specularTexture || overridingSpecularTexture;
|
||||||
material.specularShininessTexture = materialOverrides.specularShininessTexture || overridingSpecularShininessTexture;
|
material.specularShininessTexture = thisMaterialOverrides.specularShininessTexture || overridingSpecularShininessTexture;
|
||||||
material.diffuseTexture = materialOverrides.diffuseTexture || overridingDiffuseTexture;
|
material.diffuseTexture = thisMaterialOverrides.diffuseTexture || overridingDiffuseTexture;
|
||||||
material.ambientTexture = materialOverrides.ambientTexture || overridingAmbientTexture;
|
material.ambientTexture = thisMaterialOverrides.ambientTexture || overridingAmbientTexture;
|
||||||
material.normalTexture = materialOverrides.normalTexture || overridingNormalTexture;
|
material.normalTexture = thisMaterialOverrides.normalTexture || overridingNormalTexture;
|
||||||
material.emissiveTexture = materialOverrides.emissiveTexture || overridingEmissiveTexture;
|
material.emissiveTexture = thisMaterialOverrides.emissiveTexture || overridingEmissiveTexture;
|
||||||
material.alphaTexture = materialOverrides.alphaTexture || overridingAlphaTexture;
|
material.alphaTexture = thisMaterialOverrides.alphaTexture || overridingAlphaTexture;
|
||||||
materials.push(material);
|
materials.push(material);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue