allow z middle anchor offsetting, mostly driven by lathe requirements

This commit is contained in:
Stewart Allen 2023-02-14 19:37:51 -05:00
commit c1386ded5c
5 changed files with 30 additions and 15 deletions

View file

@ -147,7 +147,7 @@ function platformUpdateMidZ() {
space.platform.setMaxZ(topZ);
}
function platformUpdateTopZ(zdelta) {
function platformUpdateTopZ() {
const { process, stock } = current();
const MODE = get_mode();
api.widgets.each(widget => {
@ -160,7 +160,11 @@ function platformUpdateTopZ(zdelta) {
widget.setTopZ(stock.z - zdelta);
break;
case 'middle':
widget.setTopZ(stock.z - (stock.z - wzmax) / 2);
if (widget.isIndexed) {
widget.setTopZ(zdelta);
} else {
widget.setTopZ(stock.z - (stock.z - wzmax) / 2 + zdelta);
}
break;
case 'bottom':
widget.setTopZ(wzmax + zdelta);

View file

@ -430,6 +430,10 @@ class Widget {
}
}
get isIndexed() {
return this.track.indexed ? true : false;
}
setIndexed(z) {
if (z !== this.track.indexed) {
this.track.indexed = z;
@ -456,7 +460,7 @@ class Widget {
track = this.track,
mbb = mesh.getBoundingBox(),
mbz = mbb.max.z;
if (z) {
if (z != undefined) {
track.top = z;
} else {
track.top = mbz;
@ -510,7 +514,7 @@ class Widget {
let dx = Math.sin(rad) * ln;
let dy = ln - Math.cos(rad) * ln;
this.mesh.rotation.x = -rad;
z = 0;
z = top;
} else {
this.mesh.rotation.x = 0;
z += tz;