mirror of
https://github.com/CesiumGS/obj2gltf.git
synced 2025-01-30 19:42:59 -05:00
Treat alpha of 0 as 1
This commit is contained in:
parent
4f2e2add43
commit
e36668ab14
@ -118,10 +118,10 @@ function loadMtl(mtlPath, options) {
|
||||
material.specularShininess = parseFloat(value);
|
||||
} else if (/^d /i.test(line)) {
|
||||
value = line.substring(2).trim();
|
||||
material.alpha = parseFloat(value);
|
||||
material.alpha = correctAlpha(parseFloat(value));
|
||||
} else if (/^Tr /i.test(line)) {
|
||||
value = line.substring(3).trim();
|
||||
material.alpha = 1.0 - parseFloat(value);
|
||||
material.alpha = correctAlpha(1.0 - parseFloat(value));
|
||||
} else if (/^map_Ka /i.test(line)) {
|
||||
if (!defined(overridingAmbientTexture)) {
|
||||
texturePath = path.resolve(mtlDirectory, line.substring(7).trim());
|
||||
@ -164,6 +164,11 @@ function loadMtl(mtlPath, options) {
|
||||
});
|
||||
}
|
||||
|
||||
function correctAlpha(alpha) {
|
||||
// An alpha of 0.0 usually implies a problem in the export, change to 1.0 instead
|
||||
return alpha === 0.0 ? 1.0 : alpha;
|
||||
}
|
||||
|
||||
function Material() {
|
||||
this.name = undefined;
|
||||
this.ambientColor = [0.0, 0.0, 0.0, 1.0]; // Ka
|
||||
|
Loading…
x
Reference in New Issue
Block a user