add sketch and sketch item centering
This commit is contained in:
parent
522103a0a6
commit
c7fed8da3b
3 changed files with 26 additions and 4 deletions
|
|
@ -223,7 +223,7 @@ function space_init(data) {
|
||||||
case 'KeyC':
|
case 'KeyC':
|
||||||
return selection.centerXY().focus();
|
return selection.centerXY().focus();
|
||||||
case 'KeyF':
|
case 'KeyF':
|
||||||
return selection.floor().focus();
|
return shiftKey ? selection.focus() : selection.floor().focus();
|
||||||
case 'KeyM':
|
case 'KeyM':
|
||||||
return shiftKey ? api.tool.merge() : api.tool.mirror();
|
return shiftKey ? api.tool.merge() : api.tool.mirror();
|
||||||
case 'KeyU':
|
case 'KeyU':
|
||||||
|
|
|
||||||
|
|
@ -256,7 +256,7 @@ const selection = {
|
||||||
},
|
},
|
||||||
|
|
||||||
centerXY() {
|
centerXY() {
|
||||||
for (let s of selection.groups()) {
|
for (let s of [...selection.groups(), ...selection.sketches()]) {
|
||||||
s.centerXY(...arguments);
|
s.centerXY(...arguments);
|
||||||
}
|
}
|
||||||
return selection;
|
return selection;
|
||||||
|
|
|
||||||
|
|
@ -168,6 +168,15 @@ mesh.sketch = class MeshSketch extends mesh.object {
|
||||||
broker.publish('sketch_selections');
|
broker.publish('sketch_selections');
|
||||||
}
|
}
|
||||||
return sel.length;
|
return sel.length;
|
||||||
|
},
|
||||||
|
|
||||||
|
centerXY() {
|
||||||
|
let sel = sketch.items.filter(i => i.selected);
|
||||||
|
for (let s of sel) {
|
||||||
|
s.center.x = 0;
|
||||||
|
s.center.y = 0;
|
||||||
|
}
|
||||||
|
return sel.length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -311,7 +320,15 @@ mesh.sketch = class MeshSketch extends mesh.object {
|
||||||
this.center = {x, y, z};
|
this.center = {x, y, z};
|
||||||
this.update();
|
this.update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
centerXY() {
|
||||||
|
if (!this.selection.centerXY()) {
|
||||||
|
this.center.x = 0;
|
||||||
|
this.center.y = 0;
|
||||||
|
}
|
||||||
|
this.render();
|
||||||
|
}
|
||||||
|
|
||||||
drag(opt = {}) {
|
drag(opt = {}) {
|
||||||
let { items } = this;
|
let { items } = this;
|
||||||
|
|
@ -369,7 +386,6 @@ mesh.sketch = class MeshSketch extends mesh.object {
|
||||||
}
|
}
|
||||||
|
|
||||||
extrude(opt = {}) {
|
extrude(opt = {}) {
|
||||||
console.log({ opt });
|
|
||||||
let { selection, height, chamfer, chamfer_top, chamfer_bottom } = opt;
|
let { selection, height, chamfer, chamfer_top, chamfer_bottom } = opt;
|
||||||
let models = [];
|
let models = [];
|
||||||
let items = this.group.children
|
let items = this.group.children
|
||||||
|
|
@ -421,6 +437,12 @@ class SketchItem {
|
||||||
return this.poly.extrude(z, opt);
|
return this.poly.extrude(z, opt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
centerXY() {
|
||||||
|
let { center } = this.item;
|
||||||
|
center.x = 0;
|
||||||
|
center.y = 0;
|
||||||
|
}
|
||||||
|
|
||||||
update() {
|
update() {
|
||||||
let bump = 0.0025;
|
let bump = 0.0025;
|
||||||
let { item, sketch, order } = this;
|
let { item, sketch, order } = this;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue