Merge branch 'rel-4.3' into helical-op

This commit is contained in:
bakedpotatolord 2025-07-17 13:50:34 -06:00
commit 45ba762d1e
60 changed files with 1116 additions and 639 deletions

View file

@ -88,6 +88,7 @@ export function prepEach(widget, settings, print, firstPoint, update) {
engageFactor = process.camFullEngage,
arcTolerance = process.camArcTolerance,
arcRes = toRadians(process.camArcResolution),
arcEnabled = process.camArcEnabled && arcTolerance > 0 && arcRes > 0,
tolerance = 0,
drillDown = 0,
drillLift = 0,
@ -177,6 +178,7 @@ export function prepEach(widget, settings, print, firstPoint, update) {
}
feedRate = feed || feedRate || plunge;
plungeRate = Math.min(feedRate || plunge, plunge || plungeRate || feedRate);
// console.log({ setTool: toolID, feed, plunge, plungeRate });
}
function setLasering(bool, power = 0) {
@ -241,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) {
@ -249,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();
}
@ -317,7 +319,7 @@ export function prepEach(widget, settings, print, firstPoint, update) {
p.x + wmx,
p.y + wmy,
p.z + zadd
)
).setA(p.a ?? lastPoint?.a);
}
/**
@ -342,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);
@ -354,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) {
@ -461,16 +462,27 @@ export function prepEach(widget, settings, print, firstPoint, update) {
}
// set new plunge rate
if (!lasering && deltaZ < -tolerance && !isLathe) {
if (!lasering && !isLathe && deltaZ < -tolerance) {
let threshold = Math.min(deltaXY / 2, absDeltaZ),
modifier = threshold / absDeltaZ;
if (synthPlunge && threshold && modifier && deltaXY > tolerance) {
// use modifier to speed up long XY move plunge rates
// console.log('modifier', modifier);
rate = Math.round(plungeRate + ((feedRate - plungeRate) * modifier));
cut = 1;
rate = Math.max(
plungeRate,
Math.round(plungeRate + ((feedRate - plungeRate) * modifier))
);
} else {
rate = 1 / Math.hypot(deltaXY / feedRate, absDeltaZ / plungeRate);
let L = Math.hypot(deltaXY, absDeltaZ);
let limXY = feedRate * L / deltaXY;
let limZ = plungeRate * L / Math.abs(deltaZ);
rate = Math.min(feedRate, limXY, limZ);
// let zps = len / absDeltaZ;
// rate = Math.max(
// plungeRate,
// 1 / Math.hypot(deltaXY / feedRate, absDeltaZ / plungeRate)
// );
// console.log({ rate, deltaXY, deltaZ });
}
}
@ -765,7 +777,7 @@ export function prepEach(widget, settings, print, firstPoint, update) {
if (indexA == startIndex) {
camOut(pointA.clone(), 0, { factor: engageFactor });
// if first point, move to and call export function
arcQ.push(pointA);
if (arcEnabled) arcQ.push(pointA);
}
lastPoint = arcExport(pointB, pointA);
}, !poly.isClosed(), startIndex);
@ -782,7 +794,7 @@ export function prepEach(widget, settings, print, firstPoint, update) {
function arcExport(point, lastp) {
let dist = lastp ? point.distTo2D(lastp) : 0;
if (lastp) {
if (dist > lineTolerance && lastp) {
if (arcEnabled && dist > lineTolerance && lastp) {
let rec = Object.assign(point, { dist });
arcQ.push(rec);