compensate for cam origin offset on export / import

This commit is contained in:
Stewart Allen 2025-09-04 20:56:35 -04:00
commit 06459f18b8
2 changed files with 8 additions and 8 deletions

View file

@ -53,8 +53,6 @@ export function cam_export(print, online) {
lasering = false, lasering = false,
laserOp, laserOp,
stock = settings.stock || {}, stock = settings.stock || {},
ztOff = stock.z - widget.track.top,
bounds = widget.getBoundingBox(),
zmax = stock.z, zmax = stock.z,
runbox = { runbox = {
max: { x: -Infinity, y: -Infinity, z: -Infinity }, max: { x: -Infinity, y: -Infinity, z: -Infinity },
@ -411,7 +409,7 @@ export function cam_export(print, online) {
// collect tool info to add to header // collect tool info to add to header
let toolz = {}, ctool; let toolz = {}, ctool;
const isOffset = offset && (offset.x || offset.y); const isOffset = offset && (offset.x || offset.y || offset.z);
// remap points as necessary for origins, offsets, inversions // remap points as necessary for origins, offsets, inversions
print.output.forEach(layer => { print.output.forEach(layer => {
if (!Array.isArray(layer)) { if (!Array.isArray(layer)) {
@ -430,8 +428,9 @@ export function cam_export(print, online) {
// ensure not point is modified twice // ensure not point is modified twice
point.mod = 1; point.mod = 1;
if (isOffset) { if (isOffset) {
point.x += offset.x; point.x += offset.x ?? 0;
point.y += offset.y; point.y += offset.y ?? 0;
point.z -= offset.z ?? 0;
} }
if (scale) { if (scale) {
point.x *= scale.x; point.x *= scale.x;

View file

@ -546,11 +546,12 @@ const dispatch = {
parse(args, send) { parse(args, send) {
const { settings, code, type } = args; const { settings, code, type } = args;
const { process } = settings;
const origin = settings.origin; const origin = settings.origin;
const offset = { const offset = {
x: origin.x, x: origin.x - (process.camOriginOffX ?? 0),
y: -origin.y, y: -origin.y - (process.camOriginOffY ?? 0),
z: origin.z z: origin.z - (process.camOriginOffZ ?? 0)
}; };
const device = settings.device; const device = settings.device;
const print = current.print = newPrint(settings, Object.values(wcache)); const print = current.print = newPrint(settings, Object.values(wcache));