restrict the use of tzoff to cam mode
This commit is contained in:
parent
604af6ff1f
commit
e71d8157a4
2 changed files with 19 additions and 21 deletions
|
|
@ -164,17 +164,17 @@ function platformUpdateTopZ() {
|
||||||
const zdelta = process.camZOffset || 0;
|
const zdelta = process.camZOffset || 0;
|
||||||
switch (process.camZAnchor) {
|
switch (process.camZAnchor) {
|
||||||
case 'top':
|
case 'top':
|
||||||
widget.setTopZ(stock.z - zdelta);
|
widget.setTopZ(stock.z - zdelta, true);
|
||||||
break;
|
break;
|
||||||
case 'middle':
|
case 'middle':
|
||||||
if (widget.isIndexed) {
|
if (widget.isIndexed) {
|
||||||
widget.setTopZ(zdelta);
|
widget.setTopZ(zdelta, true);
|
||||||
} else {
|
} else {
|
||||||
widget.setTopZ(stock.z - (stock.z - wzmax) / 2 + zdelta);
|
widget.setTopZ(stock.z - (stock.z - wzmax) / 2 + zdelta, true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'bottom':
|
case 'bottom':
|
||||||
widget.setTopZ(wzmax + zdelta);
|
widget.setTopZ(wzmax + zdelta, true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -473,10 +473,12 @@ class Widget {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* moves top of widget to given Z
|
* moves top of widget to given Z
|
||||||
|
* only non-zero in CAM mode
|
||||||
*
|
*
|
||||||
* @param {number} z position
|
* @param {number} z position
|
||||||
|
* @param {boolean} cam mode
|
||||||
*/
|
*/
|
||||||
setTopZ(z) {
|
setTopZ(z, cam) {
|
||||||
let mesh = this.mesh,
|
let mesh = this.mesh,
|
||||||
track = this.track,
|
track = this.track,
|
||||||
mbb = mesh.getBoundingBox(),
|
mbb = mesh.getBoundingBox(),
|
||||||
|
|
@ -488,7 +490,7 @@ class Widget {
|
||||||
track.top = mbz;
|
track.top = mbz;
|
||||||
}
|
}
|
||||||
// difference between top of stock/bounds and top of widget (cam mode)
|
// difference between top of stock/bounds and top of widget (cam mode)
|
||||||
track.tzoff = mbz - z;
|
track.tzoff = cam ? mbz - z : 0;
|
||||||
this._updateMeshPosition();
|
this._updateMeshPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -503,8 +505,7 @@ class Widget {
|
||||||
}
|
}
|
||||||
|
|
||||||
_move(x, y, z, abs) {
|
_move(x, y, z, abs) {
|
||||||
let mesh = this.mesh,
|
let mat = this.getMaterial(),
|
||||||
mat = this.getMaterial(),
|
|
||||||
pos = this.track.pos;
|
pos = this.track.pos;
|
||||||
// do not allow moves in pure slice view
|
// do not allow moves in pure slice view
|
||||||
if (!mat.visible) return;
|
if (!mat.visible) return;
|
||||||
|
|
@ -528,13 +529,10 @@ class Widget {
|
||||||
track = this.track,
|
track = this.track,
|
||||||
tzoff = track.tzoff,
|
tzoff = track.tzoff,
|
||||||
top = track.top,
|
top = track.top,
|
||||||
tz = tzoff !== top ? -tzoff : 0,
|
tz = -tzoff,
|
||||||
{ x, y, z } = track.pos;
|
{ x, y, z } = track.pos;
|
||||||
if (track.indexed) {
|
if (track.indexed) {
|
||||||
let rad = track.indexRad;
|
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;
|
this.mesh.rotation.x = -rad;
|
||||||
z = top;
|
z = top;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue