From 256e9fcf7332ecbd01e1cc1d1a08739c6c101780 Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Sun, 16 Nov 2025 19:05:42 -0500 Subject: [PATCH] disable gpu for pocket contour, update defaults --- src/kiri/core/conf.js | 2 +- src/kiri/mode/cam/op-pocket.js | 47 +++++++++++++++++++--------------- src/kiri/mode/cam/topo3.js | 5 ++-- src/main/kiri.js | 4 --- 4 files changed, 30 insertions(+), 28 deletions(-) diff --git a/src/kiri/core/conf.js b/src/kiri/core/conf.js index af6e70f9..04a0f130 100644 --- a/src/kiri/core/conf.js +++ b/src/kiri/core/conf.js @@ -537,7 +537,7 @@ export const conf = { camPocketOver: 0.25, camPocketPlunge: 200, camPocketRefine: 20, - camPocketSmooth: 0, + camPocketSmooth: 1, camPocketSpeed: 250, camPocketSpindle: 1000, camPocketTool: 1000, diff --git a/src/kiri/mode/cam/op-pocket.js b/src/kiri/mode/cam/op-pocket.js index 2e63becd..45f84599 100644 --- a/src/kiri/mode/cam/op-pocket.js +++ b/src/kiri/mode/cam/op-pocket.js @@ -38,23 +38,14 @@ class OpPocket extends CamOp { let smoothVal = (smooth ?? 0) / 10; if (contour) { down = 0; - this.topo = await Topo({ - // onupdate: (update, msg) => { - onupdate: (index, total, msg) => { - progress((index / total) * 0.9, msg); - }, - ondone: (slices) => { - // console.log({ contour: slices }); - }, - contour: { - tool, - step: toolOver, - tolerance, - inside: true, - axis: "-" - }, - state: state - }); + this.contour = { + axis: "-", + inside: true, + nogpu: true, + step: toolOver, + tolerance, + tool, + }; } updateToolDiams(toolDiam); if (tabs) { @@ -70,7 +61,7 @@ class OpPocket extends CamOp { sliceOut.push(slice); return slice; } - function clearZ(polys, z, down) { + async function clearZ(polys, z, down) { if (down) { // adjust step down to a value <= down that // ends on the lowest z specified @@ -131,7 +122,7 @@ class OpPocket extends CamOp { } POLY.setWinding(slice.camLines, cutdir, false); if (contour) { - slice.camLines = pocket.conform(slice.camLines, op.refine, engrave, pct => { + slice.camLines = await pocket.conform(slice.camLines, op.refine, engrave, pct => { progress(0.9 + (zpro + zinc * pct) * 0.1, "conform"); }); } @@ -176,7 +167,7 @@ class OpPocket extends CamOp { if (op.outline) { POLY.clearInner(outline); } - clearZ(outline, zmin + 0.0001, down); + await clearZ(outline, zmin + 0.0001, down); if (devel && sliceOut?.length) sliceOut[0].output() .setLayer("pocket area", {line: 0x1188ff}, false) .addPolys(outline) @@ -185,7 +176,21 @@ class OpPocket extends CamOp { } // mold cam output lines to the surface of the topo offset by tool geometry - conform(camLines, refine, engrave, progress) { + async conform(camLines, refine, engrave, progress) { + if (!this.topo) { + console.log('deferred topo'); + this.topo = await Topo({ + // onupdate: (update, msg) => { + onupdate: (index, total, msg) => { + progress((index / total) * 0.9, msg); + }, + ondone: (slices) => { + // console.log({ contour: slices }); + }, + contour: this.contour, + state: this.state + }); + } const topo = this.topo; // re-segment polygon to a higher resolution const hirez = camLines.map(p => p.segment(topo.tolerance * 2)); diff --git a/src/kiri/mode/cam/topo3.js b/src/kiri/mode/cam/topo3.js index 110c86a9..e42f31ef 100644 --- a/src/kiri/mode/cam/topo3.js +++ b/src/kiri/mode/cam/topo3.js @@ -102,7 +102,7 @@ export class Topo { newslices.push(debug); } - if (webGPU) { + if (webGPU && !contour.nogpu) { // invert tool Z offset for gpu code let toolBounds = new THREE.Box3() .expandByPoint({ x: -toolDiameter/2, y: -toolDiameter/2, z: 0 }) @@ -137,8 +137,9 @@ export class Topo { // console.timeEnd('swap XY vertices'); } + let trace = contour.trace; let gpu = await self.get_raster_gpu({ - mode: "planar", + mode: trace ? "tracing" : "planar", resolution }); let xStep = density; diff --git a/src/main/kiri.js b/src/main/kiri.js index 12dcd558..918898a5 100644 --- a/src/main/kiri.js +++ b/src/main/kiri.js @@ -58,10 +58,6 @@ function checkReady() { bootctrl.postMessage({ clear: true, disable: true }); location.reload(); } - } else if (api.onshape) { - $('install').classList.add('hide'); - $('uninstall').classList.add('hide'); - $('app-quit').classList.add('hide'); } else { $('install').onclick = () => { location.replace('/boot');