add sketch poly group and ungroup
This commit is contained in:
parent
54ffc506bd
commit
5f001f3050
2 changed files with 23 additions and 4 deletions
|
|
@ -433,8 +433,8 @@ function ui_build() {
|
|||
h.button({ _: 'intersect', onclick: sketch.boolean.intersect }),
|
||||
h.button({ _: 'difference', onclick: sketch.boolean.difference }),
|
||||
h.hr(),
|
||||
h.button({ _: 'group', onclick: sketch.boolean.union }),
|
||||
h.button({ _: 'ungroup', onclick: sketch.boolean.union }),
|
||||
h.button({ _: 'group', onclick: sketch.boolean.group }),
|
||||
h.button({ _: 'ungroup', onclick: sketch.boolean.ungroup }),
|
||||
])
|
||||
]),
|
||||
h.div({ class: "sketch-off" }, [
|
||||
|
|
|
|||
|
|
@ -170,11 +170,30 @@ mesh.sketch = class MeshSketch extends mesh.object {
|
|||
let items = sketch.selection.mesh_items();
|
||||
let polys = items.map(i => i.sketch_item.poly);
|
||||
let union = POLYS.union(polys, 0, true);
|
||||
console.log('sketch union', union);
|
||||
sketch.selection.delete();
|
||||
for (let poly of union) {
|
||||
sketch.add_polygon({ poly });
|
||||
}
|
||||
},
|
||||
|
||||
group() {
|
||||
let items = sketch.selection.mesh_items();
|
||||
let polys = items.map(i => i.sketch_item.poly).clone(true);
|
||||
let union = POLYS.nest(POLYS.flatten(polys, [], true));
|
||||
sketch.selection.delete();
|
||||
for (let poly of union) {
|
||||
sketch.add_polygon({ poly });
|
||||
}
|
||||
},
|
||||
|
||||
ungroup() {
|
||||
let items = sketch.selection.mesh_items();
|
||||
let polys = items.map(i => i.sketch_item.poly).clone(true);
|
||||
let flat = POLYS.flatten(polys, [], true);
|
||||
sketch.selection.delete();
|
||||
for (let poly of flat) {
|
||||
sketch.add_polygon({ poly });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -287,7 +306,7 @@ mesh.sketch = class MeshSketch extends mesh.object {
|
|||
}
|
||||
|
||||
add_polygon(opt = {}) {
|
||||
log(this.file || this.id, '| add polygon');
|
||||
// log(this.file || this.id, '| add polygon');
|
||||
Object.assign(opt, { center: {x:0, y:0, z:0} }, opt);
|
||||
this.items.push({ type: "polygon", ...opt, ...opt.poly.toObject() });
|
||||
this.render();
|
||||
|
|
|
|||
Loading…
Reference in a new issue