mirror of
https://github.com/CesiumGS/obj2gltf.git
synced 2025-01-31 03:53:13 -05:00
Fix ambient of 1,1,1
This commit is contained in:
parent
9afaf48a61
commit
20bbd17cd9
@ -86,6 +86,13 @@ function createGltf(objData) {
|
||||
transparent = diffuse[3] < 1.0;
|
||||
}
|
||||
|
||||
if (Array.isArray(ambient)) {
|
||||
// If ambient color is [1, 1, 1] assume it is a multiplier and instead change to [0, 0, 0]
|
||||
if (ambient[0] === 1.0 && ambient[1] === 1.0 && ambient[2] === 1.0) {
|
||||
ambient = [0.0, 0.0, 0.0, 1.0];
|
||||
}
|
||||
}
|
||||
|
||||
var doubleSided = transparent;
|
||||
|
||||
if (!hasNormals) {
|
||||
|
@ -359,4 +359,13 @@ describe('createGltf', function() {
|
||||
var positionAccessor = gltf.accessors[primitive.attributes.POSITION];
|
||||
expect(positionAccessor.count).toBe(vertexCount);
|
||||
});
|
||||
|
||||
it('ambient of [1, 1, 1] is treated as [0, 0, 0]', function() {
|
||||
boxObjData.materials.Material.ambientColor = [1.0, 1.0, 1.0, 1.0];
|
||||
|
||||
var gltf = createGltf(boxObjData);
|
||||
var ambient = gltf.materials.Material.extensions.KHR_materials_common.values.ambient;
|
||||
|
||||
expect(ambient).toEqual([0.0, 0.0, 0.0, 1.0]);
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user