fix z clear and ordering on index command

This commit is contained in:
Stewart Allen 2023-02-17 18:33:18 -05:00
commit bf2bd6cdfd
5 changed files with 25 additions and 10 deletions

View file

@ -45,6 +45,16 @@ class Point {
return this;
}
setX(x) {
this.x = x;
return this;
}
setY(y) {
this.y = y;
return this;
}
setZ(z) {
this.z = z;
return this;

View file

@ -515,7 +515,7 @@ CAM.init = function(kiri, api) {
let inside = true;
let popped = false;
let poprec = popOp[rec.type];
if (type === 'index' & indexing && !rec.disabled) {
if (type === 'index' && indexing && !rec.disabled) {
index = rec.absolute ? rec.degrees : index + rec.degrees;
}
el.rec = rec;
@ -819,9 +819,9 @@ CAM.init = function(kiri, api) {
iw = int.object.widget;
ic = int.point;
// only near vertical faces
if (Math.abs(n.z) > 0.3) {
return;
}
// if (Math.abs(n.z) > 0.3) {
// return;
// }
showTab = createTabBox(iw, ic, n);
};
func.tabHoverUp = function(int) {

View file

@ -49,17 +49,20 @@ class OpIndex extends CamOp {
if (!state.isIndexed) {
throw 'index op requires indexed stock';
}
state.setAxisIndex(op.degrees, op.absolute);
this.degrees = state.setAxisIndex(op.degrees, op.absolute);
}
prepare(ops, progress) {
const { lastPoint, zmax, camOut, stock } = ops;
// max point of stock corner radius when rotating (safe z when indexing)
const last = lastPoint();
const { lastPoint, zmax, zclear, camOut, stock } = ops;
let last = lastPoint();
if (last) {
const rzmax = (Math.max(stock.y, stock.z) * Math.sqrt(2)) / 2;
// max point of stock corner radius when rotating (safe z when indexing)
const rzmax = (Math.max(stock.y, stock.z) * Math.sqrt(2)) / 2 + zclear;
const zmove = Math.max(rzmax, zmax);
camOut(last.clone().setZ(zmove), 0);
// move above rotating stock
camOut(last = last.clone().setZ(zmove), 0);
// issue rotation command
camOut(last = last.clone().setY(0).setA(this.degrees), 0);
}
}
}

View file

@ -453,6 +453,7 @@ function prepEach(widget, settings, print, firstPoint, update) {
emitDrills,
emitTrace,
bounds,
zclear,
zmax,
lastPoint: () => { return lastPoint }
};

View file

@ -146,6 +146,7 @@ CAM.slice = async function(settings, widget, onupdate, ondone) {
axisIndex = absolute ? degrees : axisIndex + degrees;
axisRotation = (Math.PI / 180) * axisIndex;
widget.setAxisIndex(isIndexed ? -axisIndex : 0);
return isIndexed ? -axisIndex : 0;
}
function addPolyIndexing(poly, a) {