add sketch poly group and ungroup
This commit is contained in:
parent
54ffc506bd
commit
5f001f3050
2 changed files with 23 additions and 4 deletions
|
|
@ -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