Add is empty function to node.
This commit is contained in:
parent
19ca7a697b
commit
7875457785
@ -68,7 +68,7 @@ OV.RunTasks = function (count, callbacks)
|
||||
taskRunner.Run (count, callbacks);
|
||||
};
|
||||
|
||||
OV.RunTaskBatch = function (count, batchCount, callbacks)
|
||||
OV.RunTasksBatch = function (count, batchCount, callbacks)
|
||||
{
|
||||
let taskRunner = new OV.TaskRunner ();
|
||||
taskRunner.RunBatch (count, batchCount, callbacks);
|
||||
|
||||
@ -9,6 +9,11 @@ OV.Node = class
|
||||
this.meshIndices = [];
|
||||
}
|
||||
|
||||
IsEmpty ()
|
||||
{
|
||||
return this.childNodes.length === 0 && this.meshIndices.length === 0;
|
||||
}
|
||||
|
||||
GetName ()
|
||||
{
|
||||
return this.name;
|
||||
@ -57,6 +62,16 @@ OV.Node = class
|
||||
return this.meshIndices.length - 1;
|
||||
}
|
||||
|
||||
MeshIndexCount ()
|
||||
{
|
||||
return this.meshIndices.length;
|
||||
}
|
||||
|
||||
GetMeshIndex (index)
|
||||
{
|
||||
return this.meshIndices[index];
|
||||
}
|
||||
|
||||
GetMeshIndices ()
|
||||
{
|
||||
return this.meshIndices;
|
||||
|
||||
@ -247,6 +247,25 @@ OV.ConvertModelToThreeObject = function (model, params, output, callbacks)
|
||||
return threeMesh;
|
||||
}
|
||||
|
||||
function ConvertMeshList (threeObject, model, modelThreeMaterials, stateHandler)
|
||||
{
|
||||
OV.RunTasksBatch (model.MeshCount (), 100, {
|
||||
runTask : (firstIndex, lastIndex, ready) => {
|
||||
for (let meshIndex = firstIndex; meshIndex <= lastIndex; meshIndex++) {
|
||||
let mesh = model.GetMesh (meshIndex);
|
||||
if (mesh.TriangleCount () > 0) {
|
||||
let threeMesh = CreateThreeMesh (model, meshIndex, modelThreeMaterials);
|
||||
threeObject.add (threeMesh);
|
||||
}
|
||||
}
|
||||
ready ();
|
||||
},
|
||||
onReady : () => {
|
||||
stateHandler.OnModelLoaded (threeObject);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
let stateHandler = new OV.ThreeConversionStateHandler (callbacks);
|
||||
|
||||
let modelThreeMaterials = [];
|
||||
@ -256,19 +275,5 @@ OV.ConvertModelToThreeObject = function (model, params, output, callbacks)
|
||||
}
|
||||
|
||||
let threeObject = new THREE.Object3D ();
|
||||
OV.RunTaskBatch (model.MeshCount (), 100, {
|
||||
runTask : (firstIndex, lastIndex, ready) => {
|
||||
for (let meshIndex = firstIndex; meshIndex <= lastIndex; meshIndex++) {
|
||||
let mesh = model.GetMesh (meshIndex);
|
||||
if (mesh.TriangleCount () > 0) {
|
||||
let threeMesh = CreateThreeMesh (model, meshIndex, modelThreeMaterials);
|
||||
threeObject.add (threeMesh);
|
||||
}
|
||||
}
|
||||
ready ();
|
||||
},
|
||||
onReady : () => {
|
||||
stateHandler.OnModelLoaded (threeObject);
|
||||
}
|
||||
});
|
||||
ConvertMeshList (threeObject, model, modelThreeMaterials, stateHandler);
|
||||
};
|
||||
|
||||
@ -8,6 +8,18 @@ describe ('Node', function() {
|
||||
assert.deepStrictEqual (node.GetMeshIndices (), []);
|
||||
});
|
||||
|
||||
it ('Is Empty', function () {
|
||||
let node = new OV.Node ();
|
||||
assert (node.IsEmpty ());
|
||||
node.AddMeshIndex (0);
|
||||
assert (!node.IsEmpty ());
|
||||
|
||||
let node2 = new OV.Node ();
|
||||
assert (node2.IsEmpty ());
|
||||
node2.AddChildNode (new OV.Node ());
|
||||
assert (!node2.IsEmpty ());
|
||||
});
|
||||
|
||||
it ('Set Name', function () {
|
||||
let node = new OV.Node ();
|
||||
node.SetName ('New Name');
|
||||
|
||||
@ -31,7 +31,7 @@ describe ('Task Runner', function () {
|
||||
|
||||
it ('Run task batched', function (done) {
|
||||
var indices = [];
|
||||
OV.RunTaskBatch (10, 3, {
|
||||
OV.RunTasksBatch (10, 3, {
|
||||
runTask : function (firstIndex, lastIndex, ready) {
|
||||
indices.push ([firstIndex, lastIndex]);
|
||||
ready ();
|
||||
@ -45,7 +45,7 @@ describe ('Task Runner', function () {
|
||||
|
||||
it ('Run task batched zero times', function (done) {
|
||||
var indices = [];
|
||||
OV.RunTaskBatch (0, 3, {
|
||||
OV.RunTasksBatch (0, 3, {
|
||||
runTask : function (firstIndex, lastIndex, ready) {
|
||||
indices.push ([firstIndex, lastIndex]);
|
||||
ready ();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user