fix subtract

This commit is contained in:
Stewart Allen 2022-04-20 17:26:01 -04:00
commit b82c411313
4 changed files with 10 additions and 6 deletions

View file

@ -29,7 +29,7 @@
"connect": "^3.7.0",
"earcut": "^2.2.3",
"express-useragent": "^1.0.13",
"@jscad/modeling": "^2.9.0",
"@jscad/modeling": "^2.9.2",
"jszip": "^3.7.1",
"moment": "^2.24.0",
"pixi.js": "^4.8.9",

View file

@ -31,6 +31,9 @@ const CSG = {
},
toPositionArray(geom) {
if (!geom || geom.length === 0) {
return [].toFloat32();
}
const out = [];
const poly = jscadModeling.geometries.geom3
.toPolygons(geom)

View file

@ -384,10 +384,10 @@ const tool = {
return { id: m.id, matrix: m.matrix, tool: m.tool() }
}))
.then(data => {
let group = api.group.new([new mesh.model({
let group = api.group.new(data.map(el => new mesh.model({
file: `subtracted`,
mesh: data
})]).promote();
mesh: el
}) )).promote();
api.selection.set([group]);
api.log.emit('subtract complete').unpin();
});

View file

@ -159,9 +159,10 @@ let model = {
.map(a => base.CSG.fromPositionArray(a));
let subs = [];
for (let obj of bases) {
subs.appendAll(base.CSG.subtract(obj, ...tools));
let sub = base.CSG.subtract(obj, ...tools);
subs.append(base.CSG.toPositionArray(sub));
}
return base.CSG.toPositionArray(subs);
return subs;
},
// used to generate a list for split snapping