From e8ba6aa492ae2407db40c17070e8df91011e2338 Mon Sep 17 00:00:00 2001 From: bakedpotatolord Date: Mon, 21 Jul 2025 21:25:31 -0600 Subject: [PATCH 1/3] fix multi-widget bounding box accuracy --- src/kiri/core/selection.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/kiri/core/selection.js b/src/kiri/core/selection.js index 8349cd26..8f74f751 100644 --- a/src/kiri/core/selection.js +++ b/src/kiri/core/selection.js @@ -49,8 +49,13 @@ function update_info() { const ui = api.ui; let bounds = new THREE.Box3(), track; for_meshes(mesh => { - bounds = bounds.union(mesh.getBoundingBox()); + let box = mesh.getBoundingBox().clone(); track = mesh.widget.track; + let {pos} = track + box.min.add(pos); + box.max.add(pos); + console.log(structuredClone({pos})) + bounds = bounds.union(box); }); if (bounds.min.x === Infinity) { if (selectedMeshes.length === 0) { From bf7022f4f5fd393e71987ff7193a6a9f1cc3365d Mon Sep 17 00:00:00 2001 From: bakedpotatolord Date: Mon, 21 Jul 2025 21:27:11 -0600 Subject: [PATCH 2/3] remove console log --- src/kiri/core/selection.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/kiri/core/selection.js b/src/kiri/core/selection.js index 8f74f751..f5fb2a91 100644 --- a/src/kiri/core/selection.js +++ b/src/kiri/core/selection.js @@ -54,7 +54,6 @@ function update_info() { let {pos} = track box.min.add(pos); box.max.add(pos); - console.log(structuredClone({pos})) bounds = bounds.union(box); }); if (bounds.min.x === Infinity) { From 9b809382eca4ea3f55e15a455d5a5d7795f7c0d8 Mon Sep 17 00:00:00 2001 From: bakedpotatolord Date: Tue, 19 Aug 2025 15:58:15 -0600 Subject: [PATCH 3/3] port bugfix from 4.2 --- src/kiri/mode/cam/op-rough.js | 2 +- src/kiri/mode/cam/prepare.js | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/kiri/mode/cam/op-rough.js b/src/kiri/mode/cam/op-rough.js index 7145bb73..e778ca0c 100644 --- a/src/kiri/mode/cam/op-rough.js +++ b/src/kiri/mode/cam/op-rough.js @@ -302,7 +302,7 @@ class OpRough extends CamOp { // set winding specified in output POLY.setWinding(level, cutdir, false); poly2polyEmit(level, printPoint, (poly, index, count) => { - printPoint = polyEmit(poly, index, count, printPoint); + printPoint = polyEmit(poly, index, count, printPoint, {cutFromLast: true}); }); newLayer(); } diff --git a/src/kiri/mode/cam/prepare.js b/src/kiri/mode/cam/prepare.js index d57bf66e..969f23c8 100644 --- a/src/kiri/mode/cam/prepare.js +++ b/src/kiri/mode/cam/prepare.js @@ -736,10 +736,15 @@ export function prepEach(widget, settings, print, firstPoint, update) { * @param {number} index - unused * @param {number} count - 1 to set engage factor * @param {Point} fromPoint - the point to rapid move from - * @param {Object} camOutOpts - optional parameters to pass to camOut + * @param {boolean} ops.cutFromLast - whether to emit a 1 when moving from last point. Defaults to false * @returns {Point} - the last point of the polygon */ - function polyEmit(poly, index, count, fromPoint) { + function polyEmit(poly, index, count, fromPoint,ops) { + let { + cutFromLast, + } = ops ?? { + cutFromLast: false + }; let arcQ = [], arcMax = Infinity, // no max arc radius lineTolerance = 0.001, // do not consider points under 0.001mm for arcs @@ -775,7 +780,8 @@ export function prepEach(widget, settings, print, firstPoint, update) { // if(offset == 0) console.log("forEachPoint",point,pidx,points) // console.log({pointA, pointB, indexA, indexB,startIndex}) if (indexA == startIndex) { - camOut(pointA.clone(), 0, { factor: engageFactor }); + //if cutFromLast is true, emit a 1 for a cutting move + camOut(pointA.clone(), cutFromLast ? 1 : 0, { factor: engageFactor }); // if first point, move to and call export function if (arcEnabled) arcQ.push(pointA); }