mirror of
https://github.com/CesiumGS/obj2gltf.git
synced 2024-11-23 08:34:14 -05:00
Added test
This commit is contained in:
parent
5fc3ff8d6e
commit
49df1a0655
@ -0,0 +1,10 @@
|
|||||||
|
# Blender MTL File: 'None'
|
||||||
|
# Material Count: 1
|
||||||
|
|
||||||
|
newmtl None
|
||||||
|
Ns 0
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.8 0.8 0.8
|
||||||
|
Ks 0.8 0.8 0.8
|
||||||
|
d 1
|
||||||
|
illum 2
|
@ -0,0 +1,32 @@
|
|||||||
|
# Blender v2.78 (sub 0) OBJ File: ''
|
||||||
|
# www.blender.org
|
||||||
|
mtllib box-incorrect-winding-order.mtl
|
||||||
|
o Cube_Cube.001
|
||||||
|
v -1.000000 -1.000000 1.000000
|
||||||
|
v -1.000000 1.000000 1.000000
|
||||||
|
v -1.000000 -1.000000 -1.000000
|
||||||
|
v -1.000000 1.000000 -1.000000
|
||||||
|
v 1.000000 -1.000000 1.000000
|
||||||
|
v 1.000000 1.000000 1.000000
|
||||||
|
v 1.000000 -1.000000 -1.000000
|
||||||
|
v 1.000000 1.000000 -1.000000
|
||||||
|
vn -1.0000 0.0000 0.0000
|
||||||
|
vn 0.0000 0.0000 -1.0000
|
||||||
|
vn 1.0000 0.0000 0.0000
|
||||||
|
vn 0.0000 0.0000 1.0000
|
||||||
|
vn 0.0000 -1.0000 0.0000
|
||||||
|
vn 0.0000 1.0000 0.0000
|
||||||
|
usemtl None
|
||||||
|
s off
|
||||||
|
f 1//1 3//1 2//1
|
||||||
|
f 4//2 7//2 3//2
|
||||||
|
f 8//3 5//3 7//3
|
||||||
|
f 6//4 1//4 5//4
|
||||||
|
f 7//5 1//5 3//5
|
||||||
|
f 4//6 6//6 8//6
|
||||||
|
f 2//1 4//1 3//1
|
||||||
|
f 4//2 8//2 7//2
|
||||||
|
f 8//3 6//3 5//3
|
||||||
|
f 6//4 2//4 1//4
|
||||||
|
f 7//5 5//5 1//5
|
||||||
|
f 4//6 2//6 6//6
|
@ -46,6 +46,7 @@ const objMissingAttributesPath = 'specs/data/box-missing-attributes/box-missing-
|
|||||||
const objIncompletePositionsPath = 'specs/data/box-incomplete-attributes/box-incomplete-positions.obj';
|
const objIncompletePositionsPath = 'specs/data/box-incomplete-attributes/box-incomplete-positions.obj';
|
||||||
const objIncompleteNormalsPath = 'specs/data/box-incomplete-attributes/box-incomplete-normals.obj';
|
const objIncompleteNormalsPath = 'specs/data/box-incomplete-attributes/box-incomplete-normals.obj';
|
||||||
const objIncompleteUvsPath = 'specs/data/box-incomplete-attributes/box-incomplete-uvs.obj';
|
const objIncompleteUvsPath = 'specs/data/box-incomplete-attributes/box-incomplete-uvs.obj';
|
||||||
|
const objIncorrectWindingOrderPath = 'specs/data/box-incorrect-winding-order/box-incorrect-winding-order.obj';
|
||||||
const objInvalidPath = 'invalid.obj';
|
const objInvalidPath = 'invalid.obj';
|
||||||
|
|
||||||
function getMeshes(data) {
|
function getMeshes(data) {
|
||||||
@ -511,6 +512,29 @@ describe('loadObj', () => {
|
|||||||
expect(primitive.uvs.length).toBe(0);
|
expect(primitive.uvs.length).toBe(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
async function loadAndGetIndices(objPath, options) {
|
||||||
|
const data = await loadObj(objPath, options);
|
||||||
|
const primitive = getPrimitives(data)[0];
|
||||||
|
const indices = primitive.indices;
|
||||||
|
return new Uint16Array(indices.toUint16Buffer().buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
it('applies triangle winding order sanitization', async () => {
|
||||||
|
options.triangleWindingOrderSanitization = false;
|
||||||
|
const indicesIncorrect = await loadAndGetIndices(objIncorrectWindingOrderPath, options);
|
||||||
|
|
||||||
|
options.triangleWindingOrderSanitization = true;
|
||||||
|
const indicesCorrect = await loadAndGetIndices(objIncorrectWindingOrderPath, options);
|
||||||
|
|
||||||
|
expect(indicesIncorrect[0]).toBe(0);
|
||||||
|
expect(indicesIncorrect[2]).toBe(2);
|
||||||
|
expect(indicesIncorrect[1]).toBe(1);
|
||||||
|
|
||||||
|
expect(indicesCorrect[0]).toBe(0);
|
||||||
|
expect(indicesCorrect[2]).toBe(1);
|
||||||
|
expect(indicesCorrect[1]).toBe(2);
|
||||||
|
});
|
||||||
|
|
||||||
it('throws when position index is out of bounds', async () => {
|
it('throws when position index is out of bounds', async () => {
|
||||||
let thrownError;
|
let thrownError;
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user