fix slice state, drill zmax, contour tool diam, point.a clone in move
This commit is contained in:
parent
e1358fe566
commit
095a539efa
6 changed files with 34 additions and 25 deletions
|
|
@ -4,6 +4,7 @@ import { api } from '../../core/api.js';
|
|||
import { env, isDark } from './client.js';
|
||||
import { addbox, delbox, clearboxes } from '../../core/boxes.js';
|
||||
import { traceDone } from './cl-trace.js';
|
||||
import { space as SPACE } from '../../../moto/space.js';
|
||||
|
||||
let showTab, lastTab, tab, iw, ic;
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import { Layers } from '../../core/layers.js';
|
|||
import { Stack } from '../../core/stack.js';
|
||||
import { updateStock } from './cl-stock.js';
|
||||
import { createPopOps } from './cl-ops.js';
|
||||
import { tabAdd, tabDone, tabClear, restoreTabs, updateTabs } from './cl-tab.js';
|
||||
import { tabAdd, tabDone, tabClear, restoreTabs, rotateTabs, updateTabs } from './cl-tab.js';
|
||||
import { traceOn, traceDone, unselectTraces } from './cl-trace.js';
|
||||
import { holeSelOn, selectHolesDone, clearHolesRec } from './cl-hole.js';
|
||||
import { surfaceOn, surfaceDone } from './cl-surface.js';
|
||||
|
|
|
|||
|
|
@ -38,8 +38,10 @@ class OpContour extends CamOp {
|
|||
|
||||
async slice(progress) {
|
||||
let { op, state } = this;
|
||||
let { addSlices } = state;
|
||||
let { addSlices, settings, updateToolDiams } = state;
|
||||
let filter = createFilter(op);
|
||||
let toolDiam = this.toolDiam = new Tool(settings, op.tool).fluteDiameter();
|
||||
updateToolDiams(toolDiam);
|
||||
// we need topo for safe travel moves when roughing and outlining
|
||||
// not generated when drilling-only. then all z moves use bounds max.
|
||||
// also generates x and y contouring when selected
|
||||
|
|
@ -69,7 +71,7 @@ class OpContour extends CamOp {
|
|||
let { camOut, polyEmit, newLayer, printPoint, lastPoint } = ops;
|
||||
let { bounds, zmax } = ops;
|
||||
|
||||
let toolDiam = this.toolDiam = new Tool(settings, op.tool).fluteDiameter();
|
||||
let toolDiam = this.toolDiam;
|
||||
let stepover = toolDiam * op.step * 2;
|
||||
let depthFirst = process.camDepthFirst;
|
||||
let depthData = [];
|
||||
|
|
|
|||
|
|
@ -243,7 +243,7 @@ export function prepEach(widget, settings, print, firstPoint, update) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
camOut(point.clone().setZ(zmax));
|
||||
camOut(point.clone().setZ(zmax_outer));
|
||||
points.forEach(function (point, index) {
|
||||
camOut(point, 1);
|
||||
if (index > 0 && index < points.length - 1) {
|
||||
|
|
@ -251,7 +251,7 @@ export function prepEach(widget, settings, print, firstPoint, update) {
|
|||
if (lift) camOut(point.clone().setZ(point.z + lift), 0);
|
||||
}
|
||||
})
|
||||
camOut(point.clone().setZ(zmax), 0);
|
||||
camOut(point.clone().setZ(zmax_outer), 0);
|
||||
newLayer();
|
||||
}
|
||||
|
||||
|
|
@ -319,7 +319,7 @@ export function prepEach(widget, settings, print, firstPoint, update) {
|
|||
p.x + wmx,
|
||||
p.y + wmy,
|
||||
p.z + zadd
|
||||
).setA(p.a);
|
||||
).setA(p.a ?? lastPoint?.a);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -344,7 +344,8 @@ export function prepEach(widget, settings, print, firstPoint, update) {
|
|||
// console.log({radius})
|
||||
const isArc = emit == 2 || emit == 3;
|
||||
|
||||
//apply widget movement pos
|
||||
// apply widget movement pos
|
||||
const pointA = point.a;
|
||||
point = applyWidgetMovement(point);
|
||||
|
||||
// console.log(point.z);
|
||||
|
|
@ -356,15 +357,13 @@ export function prepEach(widget, settings, print, firstPoint, update) {
|
|||
let rate = feedRate * factor;
|
||||
|
||||
// carry rotation forward when not overridden
|
||||
if (point.a === undefined && lastPoint) {
|
||||
point.a = lastPoint.a;
|
||||
} else if (lastPoint && point.a !== undefined && lastPoint.a !== undefined) {
|
||||
let DA = lastPoint.a - point.a;
|
||||
if (lastPoint && pointA !== undefined && lastPoint.a !== undefined) {
|
||||
let DA = lastPoint.a - pointA;
|
||||
let MZ = Math.max(lastPoint.z, point.z)
|
||||
// find arc length
|
||||
let AL = (Math.abs(DA) / 360) * (2 * Math.PI * MZ);
|
||||
if (AL >= 1) {
|
||||
let lerp = base.util.lerp(lastPoint.a, point.a, 1);
|
||||
let lerp = base.util.lerp(lastPoint.a, pointA, 1);
|
||||
// create interpolated point set for rendering and animation
|
||||
// console.log({ DA, MZ, AL }, lerp.length);
|
||||
for (let a of lerp) {
|
||||
|
|
|
|||
|
|
@ -33,6 +33,15 @@ export async function cam_slice(settings, widget, onupdate, ondone) {
|
|||
top_stock, top_part, top_gap, top_z,
|
||||
workarea;
|
||||
|
||||
axisRotation = axisIndex = undefined;
|
||||
dark = settings.controller.dark;
|
||||
color = dark ? 0xbbbbbb : 0;
|
||||
minToolDiam = Infinity;
|
||||
maxToolDiam = -Infinity;
|
||||
tabs = widget.anno.tab;
|
||||
unsafe = proc.camExpertFast;
|
||||
units = settings.controller.units === 'in' ? 25.4 : 1;
|
||||
|
||||
// allow recomputing later if widget or settings changes
|
||||
const var_compute = () => {
|
||||
let { camStockX, camStockY, camStockZ, camStockOffset } = proc;
|
||||
|
|
@ -45,9 +54,9 @@ export async function cam_slice(settings, widget, onupdate, ondone) {
|
|||
x: camStockX,
|
||||
y: camStockY,
|
||||
z: camStockZ
|
||||
}
|
||||
track = widget.track;
|
||||
};
|
||||
({ camZTop, camZBottom, camZThru } = proc);
|
||||
track = widget.track;
|
||||
wztop = track.top;
|
||||
ztOff = isIndexed ? (stock.z - bounds.dim.z) / 2 : (stock.z - wztop);
|
||||
zbOff = isIndexed ? (stock.z - bounds.dim.z) / 2 : (wztop - track.box.d);
|
||||
|
|
@ -56,14 +65,6 @@ export async function cam_slice(settings, widget, onupdate, ondone) {
|
|||
zMax = bounds.max.z;
|
||||
zThru = camZThru;
|
||||
zTop = zMax + ztOff;
|
||||
minToolDiam = Infinity;
|
||||
maxToolDiam = -Infinity;
|
||||
dark = !!settings.controller.dark;
|
||||
color = dark ? 0xbbbbbb : 0;
|
||||
tabs = widget.anno.tab;
|
||||
unsafe = proc.camExpertFast;
|
||||
units = settings.controller.units === 'in' ? 25.4 : 1;
|
||||
axisRotation = axisIndex = undefined;
|
||||
part_size = bounds.dim;
|
||||
bottom_gap = zbOff;
|
||||
bottom_part = 0;
|
||||
|
|
|
|||
Loading…
Reference in a new issue