diff --git a/src/geo/polygon.js b/src/geo/polygon.js index 4b2a52f6..add36b53 100644 --- a/src/geo/polygon.js +++ b/src/geo/polygon.js @@ -794,11 +794,12 @@ export class Polygon { return [this.first().key, this.last().key, this.length].join('~~'); } - applyRotations() { + applyRotations(deg) { for (let point of this.points) { - if (point.a) { + let angleDeg = deg ?? point.a; + if (angleDeg) { let p2 = new Vector3(point.x, point.y, point.z) - .applyAxisAngle(XAXIS, point.a * DEG2RAD); + .applyAxisAngle(XAXIS, angleDeg * DEG2RAD); point.x = p2.x; point.y = p2.y; point.z = p2.z; diff --git a/src/kiri/mode/cam/op-area.js b/src/kiri/mode/cam/op-area.js index 7764f07d..4e1aad80 100644 --- a/src/kiri/mode/cam/op-area.js +++ b/src/kiri/mode/cam/op-area.js @@ -29,7 +29,7 @@ class OpArea extends CamOp { let { op, state } = this; let { direction, down, expand, flats, flatOff, follow } = op; let { mode, outline, over, rename, smooth, tool } = op; - let { addSlices, color, cutTabs, settings } = state; + let { addSlices, axisIndex, color, cutTabs, settings } = state; let { shadowAt, setToolDiam, tabs, widget, workarea } = state; let areaTool = new Tool(settings, tool); @@ -75,6 +75,10 @@ class OpArea extends CamOp { let poly = newPolygon().fromArray(arr); aminz = Math.min(aminz, poly.minZ()); polys.push(poly); + if (axisIndex) { + // traces come from unrotatead widget edges + poly.applyRotations(axisIndex); + } } // connect open poly edge segments into closed loops (when possible) diff --git a/src/kiri/mode/cam/slice.js b/src/kiri/mode/cam/slice.js index 4c260399..9cd12de4 100644 --- a/src/kiri/mode/cam/slice.js +++ b/src/kiri/mode/cam/slice.js @@ -180,6 +180,8 @@ export async function cam_slice(settings, widget, onupdate, ondone) { let slicer; let state = { addSlices, + axisIndex, + axisRotation, bounds, color, computeShadows, @@ -261,8 +263,8 @@ export async function cam_slice(settings, widget, onupdate, ondone) { } async function setAxisIndex(degrees = 0, absolute = true) { - axisIndex = absolute ? degrees : (axisIndex || 0) + degrees; - axisRotation = (Math.PI / 180) * axisIndex; + state.axisIndex = axisIndex = absolute ? degrees : (axisIndex || 0) + degrees; + state.axisRotation = axisRotation = (Math.PI / 180) * axisIndex; widget.setAxisIndex(isIndexed ? -axisIndex : 0); state.tabs = tabs = []; for (let tab of tabW) {