restrict the use of tzoff to cam mode

This commit is contained in:
Stewart Allen 2025-11-22 11:47:47 -05:00
commit e71d8157a4
2 changed files with 19 additions and 21 deletions

View file

@ -163,19 +163,19 @@ function platformUpdateTopZ() {
const wzmax = bounds.max.z;
const zdelta = process.camZOffset || 0;
switch (process.camZAnchor) {
case 'top':
widget.setTopZ(stock.z - zdelta);
break;
case 'middle':
if (widget.isIndexed) {
widget.setTopZ(zdelta);
} else {
widget.setTopZ(stock.z - (stock.z - wzmax) / 2 + zdelta);
}
break;
case 'bottom':
widget.setTopZ(wzmax + zdelta);
break;
case 'top':
widget.setTopZ(stock.z - zdelta, true);
break;
case 'middle':
if (widget.isIndexed) {
widget.setTopZ(zdelta, true);
} else {
widget.setTopZ(stock.z - (stock.z - wzmax) / 2 + zdelta, true);
}
break;
case 'bottom':
widget.setTopZ(wzmax + zdelta, true);
break;
}
} else {
widget.setTopZ(0);

View file

@ -473,10 +473,12 @@ class Widget {
/**
* moves top of widget to given Z
* only non-zero in CAM mode
*
* @param {number} z position
* @param {boolean} cam mode
*/
setTopZ(z) {
setTopZ(z, cam) {
let mesh = this.mesh,
track = this.track,
mbb = mesh.getBoundingBox(),
@ -488,7 +490,7 @@ class Widget {
track.top = mbz;
}
// difference between top of stock/bounds and top of widget (cam mode)
track.tzoff = mbz - z;
track.tzoff = cam ? mbz - z : 0;
this._updateMeshPosition();
}
@ -503,8 +505,7 @@ class Widget {
}
_move(x, y, z, abs) {
let mesh = this.mesh,
mat = this.getMaterial(),
let mat = this.getMaterial(),
pos = this.track.pos;
// do not allow moves in pure slice view
if (!mat.visible) return;
@ -528,13 +529,10 @@ class Widget {
track = this.track,
tzoff = track.tzoff,
top = track.top,
tz = tzoff !== top ? -tzoff : 0,
tz = -tzoff,
{ x, y, z } = track.pos;
if (track.indexed) {
let rad = track.indexRad;
let ln = track.box.d / 2;
let dx = Math.sin(rad) * ln;
let dy = ln - Math.cos(rad) * ln;
this.mesh.rotation.x = -rad;
z = top;
} else {