fixes for engine stock origin and center

This commit is contained in:
Stewart Allen 2026-01-24 00:27:48 -05:00
commit cd33794819
2 changed files with 11 additions and 5 deletions

View file

@ -141,7 +141,7 @@ export async function cam_slice(settings, widget, onupdate, ondone) {
bottom_stock, bottom_part, bottom_gap, bottom_z,
}, 3);
// console.log({ bounds, stock, track, workarea });
// console.log({ bounds, stock, track, workarea, camZBottom });
return structuredClone(workarea);
};

View file

@ -38,6 +38,7 @@ class Engine {
new load.STL().load(url, vertices => {
this.listener({ loaded: url, vertices });
this.widget.loadVertices(vertices).center();
this.setTopOffset(0);
accept(this);
});
} catch (error) {
@ -93,7 +94,6 @@ class Engine {
device: conf.defaults[lmode].d,
process: conf.defaults[lmode].p,
});
console.log({ settings: this.settings });
return this;
}
@ -130,17 +130,24 @@ class Engine {
process.camStockX = stock.x;
process.camStockY = stock.y;
process.camStockZ = stock.z;
if (this.origin) settings.stock.center = origin;
settings.stock.center = {
x: stock.x / 2,
y: stock.y / 2,
z: stock.z / 2
};
return this;
}
setTopOffset(offset = 0) {
this.topOffset = offset;
let wbb = this.widget.getBoundingBox();
this.widget.setTopZ(wbb.max.z - offset);
return this;
}
setOrigin(x, y, z) {
this.origin = { x, y, z };
if (this.settings.stock) this.settings.stock.center = { x, y, z };
this.settings.origin = this.origin;
return this;
}
@ -165,7 +172,6 @@ class Engine {
}
slice() {
this.widget.setTopZ((this.settings?.stock?.z || 0) - (this.topOffset || 0));
return new Promise((accept, reject) => {
client.clear();
client.sync([this.widget]);