diff --git a/src/geo/point.js b/src/geo/point.js index b441af28..1bf6133b 100644 --- a/src/geo/point.js +++ b/src/geo/point.js @@ -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; diff --git a/src/kiri-mode/cam/client.js b/src/kiri-mode/cam/client.js index 0b1ca54b..16a9a756 100644 --- a/src/kiri-mode/cam/client.js +++ b/src/kiri-mode/cam/client.js @@ -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) { diff --git a/src/kiri-mode/cam/ops.js b/src/kiri-mode/cam/ops.js index 9a6270a7..f81124f1 100644 --- a/src/kiri-mode/cam/ops.js +++ b/src/kiri-mode/cam/ops.js @@ -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); } } } diff --git a/src/kiri-mode/cam/prepare.js b/src/kiri-mode/cam/prepare.js index b0fdca69..4ebbf0a3 100644 --- a/src/kiri-mode/cam/prepare.js +++ b/src/kiri-mode/cam/prepare.js @@ -453,6 +453,7 @@ function prepEach(widget, settings, print, firstPoint, update) { emitDrills, emitTrace, bounds, + zclear, zmax, lastPoint: () => { return lastPoint } }; diff --git a/src/kiri-mode/cam/slice.js b/src/kiri-mode/cam/slice.js index 953c33c1..f0d4dc1c 100644 --- a/src/kiri-mode/cam/slice.js +++ b/src/kiri-mode/cam/slice.js @@ -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) {