log split

This commit is contained in:
Stewart Allen 2022-01-15 16:55:26 -05:00
commit 9149376874
3 changed files with 9 additions and 2 deletions

View file

@ -175,8 +175,13 @@ let split = {
},
select() {
let { log } = mesh.api;
let { models, plane } = split.state;
Promise.all(models.map(m => m.split(plane))).then(split.end);
log.emit(`splitting ${models.length} model(s) at ${plane.z.round(3)}`).pin();
Promise.all(models.map(m => m.split(plane))).then(() => {
log.emit('split complete').unpin();
split.end();
});
},
end() {

View file

@ -348,7 +348,7 @@ mesh.model = class MeshModel extends mesh.object {
// new model becomes top
if (o2.length)
this.group.add(new mesh.model({
file: `${this.file}-split`,
file: `${this.file}`,
mesh: o2
}).applyMatrix4(m4)).select();
// this becomes bottom

View file

@ -83,6 +83,8 @@ let model = {
return data;
},
// split a model along an axis at a given point
// return two arrays of vertices for each resulting object
split(data) {
let { id, matrix, z } = data;
let o1 = [];