Remove o3dv test files without nodes.
This commit is contained in:
parent
94e8f15a24
commit
addc8dfbac
@ -1,12 +0,0 @@
|
||||
{
|
||||
"meshes" : [
|
||||
{
|
||||
"type" : "cuboid",
|
||||
"parameters" : {
|
||||
"size_x" : 1.0,
|
||||
"size_y" : 1.0,
|
||||
"size_z" : 1.0
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -1,11 +0,0 @@
|
||||
{
|
||||
"meshes" : [
|
||||
{
|
||||
"type" : "cylinder",
|
||||
"parameters" : {
|
||||
"radius" : 0.5,
|
||||
"height" : 1.0
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -1,45 +0,0 @@
|
||||
{
|
||||
"meshes" : [
|
||||
{
|
||||
"type" : "cylinder",
|
||||
"parameters" : {
|
||||
"radius" : 0.5,
|
||||
"height" : 1.0
|
||||
}
|
||||
},
|
||||
{
|
||||
"type" : "cylinder",
|
||||
"parameters" : {
|
||||
"radius" : 0.8,
|
||||
"height" : 1.2
|
||||
},
|
||||
"transformation" : {
|
||||
"translation" : [2.0, 0.0, 0.0]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type" : "cylinder",
|
||||
"parameters" : {
|
||||
"radius" : 0.5,
|
||||
"height" : 1.0,
|
||||
"smooth" : false,
|
||||
"segments" : 5
|
||||
},
|
||||
"transformation" : {
|
||||
"translation" : [2.0, 2.0, 0.0]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type" : "cylinder",
|
||||
"parameters" : {
|
||||
"radius" : 0.5,
|
||||
"height" : 1.0,
|
||||
"smooth" : false,
|
||||
"segments" : 10
|
||||
},
|
||||
"transformation" : {
|
||||
"translation" : [0.0, 2.0, 0.0]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -1,70 +0,0 @@
|
||||
{
|
||||
"materials" : [
|
||||
{
|
||||
"name" : "Material 1",
|
||||
"color" : [200, 0, 0],
|
||||
"metalness" : 1.0,
|
||||
"roughness" : 0.0
|
||||
},
|
||||
{
|
||||
"name" : "Material 2",
|
||||
"color" : [0, 200, 0],
|
||||
"metalness" : 1.0,
|
||||
"roughness" : 0.25
|
||||
},
|
||||
{
|
||||
"name" : "Material 3",
|
||||
"color" : [0, 0, 200],
|
||||
"metalness" : 1.0,
|
||||
"roughness" : 0.5
|
||||
},
|
||||
{
|
||||
"name" : "Material 4",
|
||||
"color" : [200, 200, 0],
|
||||
"metalness" : 1.0,
|
||||
"roughness" : 0.75
|
||||
}
|
||||
],
|
||||
"meshes" : [
|
||||
{
|
||||
"type" : "sphere",
|
||||
"parameters" : {
|
||||
"radius" : 0.5
|
||||
},
|
||||
"transformation" : {
|
||||
"translation" : [0.0, 0.0, 0.0]
|
||||
},
|
||||
"material" : 0
|
||||
},
|
||||
{
|
||||
"type" : "sphere",
|
||||
"parameters" : {
|
||||
"radius" : 0.5
|
||||
},
|
||||
"transformation" : {
|
||||
"translation" : [1.5, 0.0, 0.0]
|
||||
},
|
||||
"material" : 1
|
||||
},
|
||||
{
|
||||
"type" : "sphere",
|
||||
"parameters" : {
|
||||
"radius" : 0.5
|
||||
},
|
||||
"transformation" : {
|
||||
"translation" : [3.0, 0.0, 0.0]
|
||||
},
|
||||
"material" : 2
|
||||
},
|
||||
{
|
||||
"type" : "sphere",
|
||||
"parameters" : {
|
||||
"radius" : 0.5
|
||||
},
|
||||
"transformation" : {
|
||||
"translation" : [4.5, 0.0, 0.0]
|
||||
},
|
||||
"material" : 3
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -1,54 +0,0 @@
|
||||
{
|
||||
"meshes" : [
|
||||
{
|
||||
"type" : "platonic",
|
||||
"parameters" : {
|
||||
"solid_type" : "tetrahedron",
|
||||
"radius" : 1.0
|
||||
},
|
||||
"transformation" : {
|
||||
"translation" : [0.0, 0.0, 0.0]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type" : "platonic",
|
||||
"parameters" : {
|
||||
"solid_type" : "hexahedron",
|
||||
"radius" : 1.0
|
||||
},
|
||||
"transformation" : {
|
||||
"translation" : [0.0, 0.0, 3.0]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type" : "platonic",
|
||||
"parameters" : {
|
||||
"solid_type" : "octahedron",
|
||||
"radius" : 1.0
|
||||
},
|
||||
"transformation" : {
|
||||
"translation" : [3.0, 0.0, 0.0]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type" : "platonic",
|
||||
"parameters" : {
|
||||
"solid_type" : "dodecahedron",
|
||||
"radius" : 1.0
|
||||
},
|
||||
"transformation" : {
|
||||
"translation" : [3.0, 0.0, 3.0]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type" : "platonic",
|
||||
"parameters" : {
|
||||
"solid_type" : "icosahedron",
|
||||
"radius" : 1.0
|
||||
},
|
||||
"transformation" : {
|
||||
"translation" : [6.0, 0.0, 1.5]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
{
|
||||
"meshes" : [
|
||||
{
|
||||
"type" : "sphere",
|
||||
"parameters" : {
|
||||
"radius" : 0.5
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -1,41 +0,0 @@
|
||||
{
|
||||
"meshes" : [
|
||||
{
|
||||
"type" : "sphere",
|
||||
"parameters" : {
|
||||
"radius" : 0.5
|
||||
}
|
||||
},
|
||||
{
|
||||
"type" : "sphere",
|
||||
"parameters" : {
|
||||
"radius" : 0.8
|
||||
},
|
||||
"transformation" : {
|
||||
"translation" : [2.0, 0.0, 0.0]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type" : "sphere",
|
||||
"parameters" : {
|
||||
"radius" : 0.5,
|
||||
"smooth" : false,
|
||||
"segments" : 5
|
||||
},
|
||||
"transformation" : {
|
||||
"translation" : [2.0, 2.0, 0.0]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type" : "sphere",
|
||||
"parameters" : {
|
||||
"radius" : 0.5,
|
||||
"smooth" : false,
|
||||
"segments" : 10
|
||||
},
|
||||
"transformation" : {
|
||||
"translation" : [0.0, 2.0, 0.0]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -1,74 +0,0 @@
|
||||
{
|
||||
"materials" : [
|
||||
{
|
||||
"name" : "Material 1",
|
||||
"color" : [200, 0, 0]
|
||||
},
|
||||
{
|
||||
"name" : "Material 2",
|
||||
"color" : [0, 200, 0]
|
||||
},
|
||||
{
|
||||
"name" : "Material 3",
|
||||
"color" : [0, 0, 200]
|
||||
},
|
||||
{
|
||||
"name" : "Material 4",
|
||||
"color" : [200, 200, 0]
|
||||
}
|
||||
],
|
||||
"meshes" : [
|
||||
{
|
||||
"name" : "Cube",
|
||||
"material" : 0,
|
||||
"type" : "cuboid",
|
||||
"parameters" : {
|
||||
"size_x" : 1.0,
|
||||
"size_y" : 1.0,
|
||||
"size_z" : 1.0
|
||||
}
|
||||
},
|
||||
{
|
||||
"name" : "Cube T",
|
||||
"material" : 1,
|
||||
"transformation" : {
|
||||
"translation" : [2.0, 0.0, 0.0]
|
||||
},
|
||||
"type" : "cuboid",
|
||||
"parameters" : {
|
||||
"size_x" : 1.0,
|
||||
"size_y" : 1.0,
|
||||
"size_z" : 1.0
|
||||
}
|
||||
},
|
||||
{
|
||||
"name" : "Cube TR",
|
||||
"material" : 2,
|
||||
"transformation" : {
|
||||
"translation" : [4.0, 0.0, 0.0],
|
||||
"rotation" : [0.0, 0.0, 0.3826834323650898, 0.9238795325112867]
|
||||
},
|
||||
"type" : "cuboid",
|
||||
"parameters" : {
|
||||
"size_x" : 1.0,
|
||||
"size_y" : 1.0,
|
||||
"size_z" : 1.0
|
||||
}
|
||||
},
|
||||
{
|
||||
"name" : "Cube TRS",
|
||||
"material" : 3,
|
||||
"transformation" : {
|
||||
"translation" : [6.0, 0.0, 0.0],
|
||||
"rotation" : [0.0, 0.0, 0.3826834323650898, 0.9238795325112867],
|
||||
"scale" : [1.5, 2.0, 2.5]
|
||||
},
|
||||
"type" : "cuboid",
|
||||
"parameters" : {
|
||||
"size_x" : 1.0,
|
||||
"size_y" : 1.0,
|
||||
"size_z" : 1.0
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -16,7 +16,7 @@
|
||||
},
|
||||
"children" : [
|
||||
{
|
||||
"name" : "Translated",
|
||||
"name" : "Translated and Rotated",
|
||||
"transformation" : {
|
||||
"translation" : [2.0, 0.0, 0.0]
|
||||
},
|
||||
|
||||
@ -3,94 +3,36 @@ var testFiles = require ('../utils/testfiles.js');
|
||||
var testUtils = require ('../utils/testutils.js');
|
||||
|
||||
describe ('O3dv Importer', function () {
|
||||
it ('cube.o3dv', function (done) {
|
||||
testFiles.ImportO3dvFile ('cube.o3dv', function (model) {
|
||||
it ('translateandrotate.o3dv', function (done) {
|
||||
testFiles.ImportO3dvFile ('translateandrotate.o3dv', function (model) {
|
||||
assert (OV.CheckModel (model));
|
||||
assert.deepStrictEqual (testUtils.ModelToObjectSimple (model), {
|
||||
name : '',
|
||||
materials : [
|
||||
{ name : '' }
|
||||
],
|
||||
meshes : [
|
||||
assert.deepStrictEqual (testUtils.ModelNodesToTree (model), {
|
||||
name : '<Root>',
|
||||
childNodes : [
|
||||
{
|
||||
name : '',
|
||||
vertexCount : 8,
|
||||
normalCount : 12,
|
||||
uvCount : 0,
|
||||
triangleCount : 12,
|
||||
boundingBox : {
|
||||
min : [0, 0, 0],
|
||||
max : [1, 1, 1]
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
done ();
|
||||
});
|
||||
});
|
||||
|
||||
it ('cylinder.o3dv', function (done) {
|
||||
testFiles.ImportO3dvFile ('cylinder.o3dv', function (model) {
|
||||
assert (OV.CheckModel (model));
|
||||
assert.deepStrictEqual (testUtils.ModelToObjectSimple (model), {
|
||||
name : '',
|
||||
materials : [
|
||||
{ name : '' }
|
||||
],
|
||||
meshes : [
|
||||
name : 'Translated',
|
||||
childNodes : [],
|
||||
meshNames : ['Cube']
|
||||
},
|
||||
{
|
||||
name : '',
|
||||
vertexCount : 50,
|
||||
normalCount : 196,
|
||||
uvCount : 0,
|
||||
triangleCount : 96,
|
||||
boundingBox : {
|
||||
min : [-0.49605735065723894, -0.4990133642141358, 0],
|
||||
max : [0.5, 0.4990133642141358, 1]
|
||||
}
|
||||
name : 'Rotated',
|
||||
childNodes : [
|
||||
{
|
||||
name : 'Translated and Rotated',
|
||||
childNodes : [],
|
||||
meshNames : ['Cube']
|
||||
}
|
||||
],
|
||||
meshNames : []
|
||||
}
|
||||
]
|
||||
});
|
||||
done ();
|
||||
});
|
||||
});
|
||||
|
||||
it ('sphere.o3dv', function (done) {
|
||||
testFiles.ImportO3dvFile ('sphere.o3dv', function (model) {
|
||||
assert (OV.CheckModel (model));
|
||||
assert.deepStrictEqual (testUtils.ModelToObjectSimple (model), {
|
||||
name : '',
|
||||
materials : [
|
||||
{ name : '' }
|
||||
],
|
||||
meshes : [
|
||||
{
|
||||
name : '',
|
||||
vertexCount : 382,
|
||||
normalCount : 2280,
|
||||
uvCount : 0,
|
||||
triangleCount : 760,
|
||||
boundingBox : {
|
||||
min : [-0.5, -0.5, -0.5],
|
||||
max : [0.5, 0.5, 0.5]
|
||||
}
|
||||
}
|
||||
]
|
||||
meshNames : ['Cube']
|
||||
});
|
||||
done ();
|
||||
});
|
||||
});
|
||||
|
||||
it ('transformation.o3dv', function (done) {
|
||||
testFiles.ImportO3dvFile ('transformation.o3dv', function (model) {
|
||||
assert (OV.CheckModel (model));
|
||||
assert.deepStrictEqual (testUtils.ModelToObjectSimple (model), {
|
||||
name : '',
|
||||
materials : [
|
||||
{ name : 'Material 1' },
|
||||
{ name : 'Material 2' },
|
||||
{ name : 'Material 3' },
|
||||
{ name : 'Material 4' }
|
||||
{ name : 'Green' }
|
||||
],
|
||||
meshes : [
|
||||
{
|
||||
@ -103,42 +45,13 @@ describe ('O3dv Importer', function () {
|
||||
min : [0, 0, 0],
|
||||
max : [1, 1, 1]
|
||||
}
|
||||
},
|
||||
{
|
||||
name : 'Cube T',
|
||||
vertexCount : 8,
|
||||
normalCount : 12,
|
||||
uvCount : 0,
|
||||
triangleCount : 12,
|
||||
boundingBox : {
|
||||
min : [2, 0, 0],
|
||||
max : [3, 1, 1]
|
||||
}
|
||||
},
|
||||
{
|
||||
name : 'Cube TR',
|
||||
vertexCount : 8,
|
||||
normalCount : 12,
|
||||
uvCount : 0,
|
||||
triangleCount : 12,
|
||||
boundingBox : {
|
||||
min : [3.2928932188134525, 0, 0],
|
||||
max : [4.707106781186548, 1.414213562373095, 1]
|
||||
}
|
||||
},
|
||||
{
|
||||
name : 'Cube TRS',
|
||||
vertexCount : 8,
|
||||
normalCount : 12,
|
||||
uvCount : 0,
|
||||
triangleCount : 12,
|
||||
boundingBox : {
|
||||
min : [4.585786437626905, 0, 0],
|
||||
max : [7.060660171779821, 2.4748737341529163, 2.5]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
assert.strictEqual (model.MeshInstanceCount (), 3);
|
||||
let boundingBox = OV.GetBoundingBox (model);
|
||||
assert (OV.CoordIsEqual3D (boundingBox.min, new OV.Coord3D (-1.0, 0.0, 0.0)));
|
||||
assert (OV.CoordIsEqual3D (boundingBox.max, new OV.Coord3D (3.0, 3.0, 1.0)));
|
||||
done ();
|
||||
});
|
||||
});
|
||||
|
||||
@ -253,33 +253,10 @@ describe ('Color Conversion', function () {
|
||||
});
|
||||
});
|
||||
|
||||
function GetModelTree (model)
|
||||
{
|
||||
function AddNodeToModelTree (model, node, modelTree)
|
||||
{
|
||||
modelTree.name = node.HasParent () ? node.GetName () : '<Root>';
|
||||
modelTree.childNodes = [];
|
||||
for (const childNode of node.GetChildNodes ()) {
|
||||
let childTree = {};
|
||||
AddNodeToModelTree (model, childNode, childTree);
|
||||
modelTree.childNodes.push (childTree);
|
||||
}
|
||||
modelTree.meshNames = [];
|
||||
for (const meshIndex of node.GetMeshIndices ()) {
|
||||
modelTree.meshNames.push (model.GetMesh (meshIndex).GetName ());
|
||||
}
|
||||
}
|
||||
|
||||
let modelTree = {};
|
||||
let root = model.GetRootNode ();
|
||||
AddNodeToModelTree (model, root, modelTree);
|
||||
return modelTree;
|
||||
}
|
||||
|
||||
describe ('Node Hierarchy', function () {
|
||||
it ('Enumerate hierarchy', function () {
|
||||
let model = testUtils.GetHierarchicalModelNoFinalization ();
|
||||
let modelTree = GetModelTree (model);
|
||||
let modelTree = testUtils.ModelNodesToTree (model);
|
||||
assert.deepStrictEqual (modelTree, {
|
||||
name : '<Root>',
|
||||
childNodes : [
|
||||
@ -312,7 +289,7 @@ describe ('Node Hierarchy', function () {
|
||||
it ('Remove mesh', function () {
|
||||
let model = testUtils.GetHierarchicalModelNoFinalization ();
|
||||
model.RemoveMesh (2);
|
||||
let modelTree = GetModelTree (model);
|
||||
let modelTree = testUtils.ModelNodesToTree (model);
|
||||
assert.deepStrictEqual (modelTree, {
|
||||
name : '<Root>',
|
||||
childNodes : [
|
||||
@ -347,7 +324,7 @@ describe ('Node Hierarchy', function () {
|
||||
let mesh = new OV.Mesh ();
|
||||
mesh.SetName ('Mesh 8');
|
||||
model.AddMeshToIndex (mesh, 3);
|
||||
let modelTree = GetModelTree (model);
|
||||
let modelTree = testUtils.ModelNodesToTree (model);
|
||||
assert.deepStrictEqual (modelTree, {
|
||||
name : '<Root>',
|
||||
childNodes : [
|
||||
@ -379,7 +356,7 @@ describe ('Node Hierarchy', function () {
|
||||
|
||||
it ('Enumerate mesh instances', function () {
|
||||
let model = testUtils.GetTranslatedRotatedCubesModel ();
|
||||
let modelTree = GetModelTree (model);
|
||||
let modelTree = testUtils.ModelNodesToTree (model);
|
||||
assert.deepStrictEqual (modelTree, {
|
||||
name : '<Root>',
|
||||
childNodes : [
|
||||
@ -426,7 +403,7 @@ describe ('Node Hierarchy', function () {
|
||||
|
||||
it ('Enumerate transformed mesh instances', function () {
|
||||
let model = testUtils.GetTranslatedRotatedCubesModel ();
|
||||
let modelTree = GetModelTree (model);
|
||||
let modelTree = testUtils.ModelNodesToTree (model);
|
||||
assert.deepStrictEqual (modelTree, {
|
||||
name : '<Root>',
|
||||
childNodes : [
|
||||
|
||||
@ -25,6 +25,29 @@ module.exports =
|
||||
return arrayBuffer
|
||||
},
|
||||
|
||||
ModelNodesToTree : function (model)
|
||||
{
|
||||
function AddNodeToModelTree (model, node, modelTree)
|
||||
{
|
||||
modelTree.name = node.HasParent () ? node.GetName () : '<Root>';
|
||||
modelTree.childNodes = [];
|
||||
for (const childNode of node.GetChildNodes ()) {
|
||||
let childTree = {};
|
||||
AddNodeToModelTree (model, childNode, childTree);
|
||||
modelTree.childNodes.push (childTree);
|
||||
}
|
||||
modelTree.meshNames = [];
|
||||
for (const meshIndex of node.GetMeshIndices ()) {
|
||||
modelTree.meshNames.push (model.GetMesh (meshIndex).GetName ());
|
||||
}
|
||||
}
|
||||
|
||||
let modelTree = {};
|
||||
let root = model.GetRootNode ();
|
||||
AddNodeToModelTree (model, root, modelTree);
|
||||
return modelTree;
|
||||
},
|
||||
|
||||
ModelToObject : function (model)
|
||||
{
|
||||
var obj = {
|
||||
@ -137,7 +160,7 @@ module.exports =
|
||||
return obj;
|
||||
},
|
||||
|
||||
GetTwoCubesConnectingInOneVertexModel ()
|
||||
GetTwoCubesConnectingInOneVertexModel : function ()
|
||||
{
|
||||
let model = new OV.Model ();
|
||||
|
||||
@ -152,7 +175,7 @@ module.exports =
|
||||
return model;
|
||||
},
|
||||
|
||||
GetTwoCubesConnectingInOneEdgeModel ()
|
||||
GetTwoCubesConnectingInOneEdgeModel : function ()
|
||||
{
|
||||
let model = new OV.Model ();
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user