Merge branch 'dev' into ifcimporter
This commit is contained in:
commit
f2c5bffa9b
@ -19,6 +19,19 @@ OV.TaskRunner = class
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RunBatch (count, batchCount, callbacks)
|
||||||
|
{
|
||||||
|
const stepCount = parseInt ((count - 1) / batchCount, 10) + 1;
|
||||||
|
this.Run (stepCount, {
|
||||||
|
runTask : function (index, ready) {
|
||||||
|
const firstIndex = index * batchCount;
|
||||||
|
const lastIndex = Math.min ((index + 1) * batchCount, count) - 1;
|
||||||
|
callbacks.runTask (firstIndex, lastIndex, ready);
|
||||||
|
},
|
||||||
|
onReady : callbacks.onReady
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
RunOnce ()
|
RunOnce ()
|
||||||
{
|
{
|
||||||
let obj = this;
|
let obj = this;
|
||||||
|
|||||||
18
source/external/threeconverter.js
vendored
18
source/external/threeconverter.js
vendored
@ -189,16 +189,16 @@ OV.ConvertModelToThreeMeshes = function (model, params, callbacks)
|
|||||||
|
|
||||||
let threeMeshes = [];
|
let threeMeshes = [];
|
||||||
let taskRunner = new OV.TaskRunner ();
|
let taskRunner = new OV.TaskRunner ();
|
||||||
taskRunner.Run (model.MeshCount (), {
|
taskRunner.RunBatch (model.MeshCount (), 100, {
|
||||||
runTask : function (index, ready) {
|
runTask : function (firstIndex, lastIndex, ready) {
|
||||||
let mesh = model.GetMesh (index);
|
for (let meshIndex = firstIndex; meshIndex <= lastIndex; meshIndex++) {
|
||||||
if (mesh.TriangleCount () === 0) {
|
let mesh = model.GetMesh (meshIndex);
|
||||||
ready ();
|
if (mesh.TriangleCount () > 0) {
|
||||||
} else {
|
let threeMesh = CreateThreeMesh (model, meshIndex, modelThreeMaterials);
|
||||||
let threeMesh = CreateThreeMesh (model, index, modelThreeMaterials);
|
threeMeshes.push (threeMesh);
|
||||||
threeMeshes.push (threeMesh);
|
}
|
||||||
ready ();
|
|
||||||
}
|
}
|
||||||
|
ready ();
|
||||||
},
|
},
|
||||||
onReady : function () {
|
onReady : function () {
|
||||||
callbacks.onModelLoaded (threeMeshes);
|
callbacks.onModelLoaded (threeMeshes);
|
||||||
|
|||||||
@ -29,5 +29,20 @@ describe ('Task Runner', function () {
|
|||||||
done ();
|
done ();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it ('Run task batched', function (done) {
|
||||||
|
var tr = new OV.TaskRunner ();
|
||||||
|
var indices = [];
|
||||||
|
tr.RunBatch (10, 3, {
|
||||||
|
runTask : function (firstIndex, lastIndex, ready) {
|
||||||
|
indices.push ([firstIndex, lastIndex]);
|
||||||
|
ready ();
|
||||||
|
},
|
||||||
|
onReady : function () {
|
||||||
|
assert.deepStrictEqual (indices, [[0, 2], [3, 5], [6, 8], [9, 9]]);
|
||||||
|
done ();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user