complete body separation code

This commit is contained in:
Stewart Allen 2022-04-05 09:40:25 -07:00
commit 406cacc453
5 changed files with 72 additions and 9 deletions

View file

@ -400,6 +400,26 @@ const tool = {
});
},
isolate(models) {
models = fallback(models);
api.log.emit('isolating bodies').pin();
let promises = [];
let mcore = new Matrix4().makeRotationX(Math.PI / 2);
for (let m of models) {
let p = worker.model_isolate({ id: m.id }).then(bodies => {
bodies = bodies.map(vert => new mesh.model({
file: m.file,
mesh: vert.toFloat32()
})).map( nm => nm.applyMatrix4(mcore.clone().multiply(m.mesh.matrixWorld)) );
mesh.api.group.new(bodies, undefined, "isolate").setSelected();
});
promises.push(p);
}
Promise.all(promises).then(() => {
api.log.emit('isolation complete').unpin();
});
},
mapFaces(models) {
models = fallback(models);
api.log.emit('mapping faces').pin();