add sketch item(s) duplication

This commit is contained in:
Stewart Allen 2024-07-27 20:01:13 -04:00
commit a6c4f8aff1
3 changed files with 81 additions and 50 deletions

View file

@ -405,34 +405,37 @@ mesh.sketch = class MeshSketch extends mesh.object {
add_circle(opt = {}) {
log(this.file || this.id, '| add circle');
this.items.push({
this.add_item({
type: "circle",
selected: true,
...Object.assign({}, { center: {x:0, y:0, z:0}, radius:5 }, opt)
});
this.render();
}
add_rectangle(opt = {}) {
log(this.file || this.id, '| add rectangle');
this.items.push({
this.add_item({
type: "rectangle",
selected: true,
...Object.assign({}, { center: {x:0, y:0, z:0}, width:15, height:10 }, opt)
});
this.render();
}
add_polygon(opt = {}) {
// log(this.file || this.id, '| add polygon');
let poly = opt.poly;
delete opt.poly;
this.items.push({
this.add_item({
type: "polygon",
selected: true,
...Object.assign({}, { center: {x:0, y:0, z:0} }, opt),
...poly.toObject()
});
}
add_item(item, opt = {}) {
item.selected = opt.select || false;
this.items.push(item);
this.render();
}