mirror of
https://github.com/CesiumGS/obj2gltf.git
synced 2025-03-02 14:34:03 -05:00
Tests
This commit is contained in:
parent
721198557a
commit
50f1366689
13
specs/data/box-mixed-attributes-2/box-mixed-attributes-2.mtl
Normal file
13
specs/data/box-mixed-attributes-2/box-mixed-attributes-2.mtl
Normal file
@ -0,0 +1,13 @@
|
||||
# Blender MTL File: 'None'
|
||||
# Material Count: 1
|
||||
|
||||
newmtl Material
|
||||
Ns 96.078431
|
||||
Ka 0.100000 0.000000 0.000000
|
||||
Kd 0.640000 0.640000 0.640000
|
||||
Ks 0.500000 0.500000 0.500000
|
||||
Ke 0.000000 0.000000 0.100000
|
||||
Ni 1.000000
|
||||
d 1.000000
|
||||
illum 2
|
||||
map_Kd cesium.png
|
67
specs/data/box-mixed-attributes-2/box-mixed-attributes-2.obj
Normal file
67
specs/data/box-mixed-attributes-2/box-mixed-attributes-2.obj
Normal file
@ -0,0 +1,67 @@
|
||||
# Blender v2.78 (sub 0) OBJ File: ''
|
||||
# www.blender.org
|
||||
mtllib box-mixed-attributes-2.mtl
|
||||
o Cube
|
||||
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
|
||||
vt 0.0000 0.0000
|
||||
vt 1.0000 0.0000
|
||||
vt 1.0000 1.0000
|
||||
vt 0.0000 1.0000
|
||||
vt 0.0000 0.0000
|
||||
vt 1.0000 0.0000
|
||||
vt 1.0000 1.0000
|
||||
vt 0.0000 1.0000
|
||||
vt 0.0000 0.0000
|
||||
vt 1.0000 0.0000
|
||||
vt 1.0000 1.0000
|
||||
vt 0.0000 1.0000
|
||||
vt 0.0000 0.0000
|
||||
vt 1.0000 0.0000
|
||||
vt 1.0000 1.0000
|
||||
vt 0.0000 1.0000
|
||||
vt 1.0000 0.0000
|
||||
vt 1.0000 1.0000
|
||||
vt 0.0000 0.0000
|
||||
vt 0.0000 1.0000
|
||||
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
|
||||
# Using default material
|
||||
f 1/1/1 2/2/1 4/3/1 3/4/1
|
||||
f 3/5/2 4/6/2 8/7/2 7/8/2
|
||||
f 7/9 8/10 6/11 5/12
|
||||
f 5/13 6/14 2/15 1/16
|
||||
f 3//5 7//5 5//5 1//5
|
||||
f 8//6 4//6 2//6 6//6
|
||||
usemtl Material
|
||||
f 1/1/1 2/2/1 4/3/1 3/4/1
|
||||
f 3/5/2 4/6/2 8/7/2 7/8/2
|
||||
f 7/9 8/10 6/11 5/12
|
||||
f 5/13 6/14 2/15 1/16
|
||||
f 3//5 7//5 5//5 1//5
|
||||
f 8//6 4//6 2//6 6//6
|
||||
usemtl Missing
|
||||
f 1/1/1 2/2/1 4/3/1 3/4/1
|
||||
f 3/5/2 4/6/2 8/7/2 7/8/2
|
||||
f 7/9 8/10 6/11 5/12
|
||||
f 5/13 6/14 2/15 1/16
|
||||
f 3//5 7//5 5//5 1//5
|
||||
f 8//6 4//6 2//6 6//6
|
||||
o CubeCopy
|
||||
usemtl Material
|
||||
f 1/1/1 2/2/1 4/3/1 3/4/1
|
||||
f 3/5/2 4/6/2 8/7/2 7/8/2
|
||||
f 7/9 8/10 6/11 5/12
|
||||
f 5/13 6/14 2/15 1/16
|
||||
f 3//5 7//5 5//5 1//5
|
||||
f 8//6 4//6 2//6 6//6
|
BIN
specs/data/box-mixed-attributes-2/cesium.png
Normal file
BIN
specs/data/box-mixed-attributes-2/cesium.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.5 KiB |
@ -12,10 +12,12 @@ var WebGLConstants = Cesium.WebGLConstants;
|
||||
|
||||
var boxObjUrl = 'specs/data/box/box.obj';
|
||||
var groupObjUrl = 'specs/data/box-objects-groups-materials/box-objects-groups-materials.obj';
|
||||
var mixedAttributesObjUrl = 'specs/data/box-mixed-attributes-2/box-mixed-attributes-2.obj';
|
||||
var diffuseTextureUrl = 'specs/data/box-textured/cesium.png';
|
||||
var transparentDiffuseTextureUrl = 'specs/data/box-complex-material/diffuse.png';
|
||||
|
||||
var defaultOptions = obj2gltf.defaults;
|
||||
var defined = Cesium.defined;
|
||||
var checkTransparencyOptions = clone(defaultOptions);
|
||||
checkTransparencyOptions.checkTransparency = true;
|
||||
|
||||
@ -23,6 +25,7 @@ describe('createGltf', function() {
|
||||
var boxObjData;
|
||||
var duplicateBoxObjData;
|
||||
var groupObjData;
|
||||
var mixedAttributesObjData;
|
||||
var diffuseTexture;
|
||||
var transparentDiffuseTexture;
|
||||
|
||||
@ -47,7 +50,12 @@ describe('createGltf', function() {
|
||||
loadImage(transparentDiffuseTextureUrl, checkTransparencyOptions)
|
||||
.then(function(image) {
|
||||
transparentDiffuseTexture = image;
|
||||
}),
|
||||
loadObj(mixedAttributesObjUrl, defaultOptions)
|
||||
.then(function(data) {
|
||||
mixedAttributesObjData = data;
|
||||
})
|
||||
|
||||
]).then(done);
|
||||
});
|
||||
|
||||
@ -309,6 +317,62 @@ describe('createGltf', function() {
|
||||
expect(attributes.TEXCOORD_0).toBeUndefined();
|
||||
});
|
||||
|
||||
function getDiffuse(material) {
|
||||
return material.extensions.KHR_materials_common.values.diffuse;
|
||||
}
|
||||
|
||||
fit('splits incompatible materials', function() {
|
||||
var gltf = createGltf(mixedAttributesObjData, defaultOptions);
|
||||
var materials = gltf.materials;
|
||||
var materialNames = Object.keys(materials).sort();
|
||||
|
||||
// Expect three copies of each material for
|
||||
// * positions/normals/uvs
|
||||
// * positions/normals
|
||||
// * positions/uvs
|
||||
expect(materialNames).toEqual([
|
||||
'Material',
|
||||
'Material-2',
|
||||
'Material-3',
|
||||
'Missing',
|
||||
'Missing-2',
|
||||
'Missing-3',
|
||||
'default',
|
||||
'default-2',
|
||||
'default-3'
|
||||
]);
|
||||
console.log(materials['Material']);
|
||||
console.log(materials['Material-2']);
|
||||
console.log(materials['Material-3']);
|
||||
|
||||
|
||||
expect(getDiffuse(materials['Material'])).toBe('texture_cesium');
|
||||
expect(getDiffuse(materials['Material-2'])).toEqual('texture_cesium');
|
||||
//expect(getDiffuse(materials['Material-3'])).toBe('texture_cesium');
|
||||
// expect(getDiffuse(materials['Missing'])).toEqual([0.0, 0.0, 0.0, 1.0]);
|
||||
// expect(getDiffuse(materials['Missing-2'])).toEqual([0.0, 0.0, 0.0, 1.0]);
|
||||
// expect(getDiffuse(materials['Missing-3'])).toEqual([0.0, 0.0, 0.0, 1.0]);
|
||||
// expect(getDiffuse(materials['default'])).toEqual([0.0, 0.0, 0.0, 1.0]);
|
||||
// expect(getDiffuse(materials['default-2'])).toEqual([0.0, 0.0, 0.0, 1.0]);
|
||||
// expect(getDiffuse(materials['default-3'])).toEqual([0.0, 0.0, 0.0, 1.0]);
|
||||
|
||||
// // Test that primitives without uvs reference materials without textures
|
||||
// for (var meshName in meshes) {
|
||||
// if (meshes.hasOwnProperty(meshName)) {
|
||||
// var mesh = meshes[meshName];
|
||||
// var primitives = mesh.primitives;
|
||||
// var primitivesLength = primitives.length;
|
||||
// for (var i = 0; i < primitivesLength; ++i) {
|
||||
// var primitive = primitives[i];
|
||||
// var material = materials[primitive.material];
|
||||
// if (!defined(primitive.attributes.TEXCOORD_0)) {
|
||||
// expect(material.extensions.KHR_materials_common.diffuse).toEqual([ 0.5, 0.5, 0.5, 1 ]);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
});
|
||||
|
||||
function expandObjData(objData, duplicatesLength) {
|
||||
var primitive = objData.nodes[0].meshes[0].primitives[0];
|
||||
var indices = primitive.indices;
|
||||
|
Loading…
x
Reference in New Issue
Block a user