apply axis rotations to trace lines in op area
This commit is contained in:
parent
69493a0daf
commit
07da144aee
3 changed files with 13 additions and 6 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue