add boolean intersect

This commit is contained in:
Stewart Allen 2022-04-20 19:35:57 -04:00
commit 275666459e
3 changed files with 27 additions and 3 deletions

View file

@ -79,7 +79,7 @@ const selection = {
// if model, remove selcted group
if (selected.contains(object.group)) {
selection.remove(object.group);
tools.remove(objec.group);
tools.remove(object.group);
}
}
selected.addOnce(object);
@ -369,7 +369,7 @@ const tool = {
}))
.then(data => {
let group = api.group.new([new mesh.model({
file: `unioned`,
file: `union`,
mesh: data
})]).promote();
api.selection.set([group]);
@ -377,6 +377,22 @@ const tool = {
});
},
intersect(models) {
models = fallback(models);
api.log.emit(`intersect ${models.length} model(s)`).pin();
worker.model_intersect(models.map(m => {
return { id: m.id, matrix: m.matrix }
}))
.then(data => {
let group = api.group.new([new mesh.model({
file: `intersect`,
mesh: data
})]).promote();
api.selection.set([group]);
api.log.emit('intersect complete').unpin();
});
},
subtract(models) {
models = fallback(models);
api.log.emit(`subtract ${models.length} model(s)`).pin();
@ -385,7 +401,7 @@ const tool = {
}))
.then(data => {
let group = api.group.new([new mesh.model({
file: `subtracted`,
file: `subtract`,
mesh: data
})]).promote();
api.selection.set([group]);