update to v3 raster gpu api

This commit is contained in:
Stewart Allen 2025-11-07 00:06:40 -05:00
commit 8fdd16979b
4 changed files with 19 additions and 19 deletions

View file

@ -54,6 +54,7 @@ self.kiri.load(api => {
return;
}
let ws_url = api.onshape ? `ws://${local_host}/bambu` : "/bambu";
console.log({ bambu_ws_url: ws_url });
let ws = socket.ws = new WebSocket(ws_url);
ws.onerror = (error) => {
socket.open = false;

View file

@ -37,7 +37,7 @@ class OpLathe extends CamOp {
async slice(progress) {
let { op, state } = this;
let { addSlices } = state;
let { addSlices, color } = state;
let filter = createFilter(op);
this.topo = await topo4_generate({
op,

View file

@ -143,21 +143,23 @@ export class Topo {
let xStep = density;
let yStep = Math.ceil(toolStep / resolution);
let epsilon = 10e-5;
let terrainData = await gpu.rasterizeModel({
await gpu.loadTool({
sparseData: toolData
});
let terrain = await gpu.loadTerrain({
triangles: vertices,
boundsOverride: wbounds
});
let { gridWidth, positions } = terrain;
let output = await gpu.generateToolpaths({
terrainData,
toolData,
xStep,
yStep,
zFloor: zBottom - 1,
onProgress(pct) { console.log({ pct }); onupdate(pct/100, 100) }
});
gpu.terminate();
let { numScanlines, pointsPerLine, pathData } = output;
let { positions, gridWidth } = terrainData;
let xmult = xStep * resolution;
let ymult = yStep * resolution;
let xoff = wbounds.min.x;

View file

@ -22,7 +22,7 @@ export class Topo {
async generate(opt = {}) {
let { state, op, onupdate, ondone } = opt;
let { widget, settings, tabs } = opt.state;
let { widget, settings, tabs, color } = state;
let { controller, process } = settings;
let { webGPU } = controller;
@ -64,7 +64,7 @@ export class Topo {
this.zoff = widget.track.top || 0;
this.leave = op.leave || 0;
this.linear = op.linear || false;
this.lineColor = controller.dark ? 0xffff00 : 0x555500;
this.lineColor = color;//controller.dark ? 0xffff00 : 0x555500;
this.offStart = op.offStart ?? 0;
this.offEnd = op.offEnd ?? 0;
this.bounds = bounds;
@ -79,9 +79,6 @@ export class Topo {
for (let slice of slices) {
range.min = Math.min(range.min, slice.z);
range.max = Math.max(range.max, slice.z);
slice.output()
.setLayer("lathe", { line: 0x888888 })
.addPolys(slice.topPolys());
}
const lathe = await this.lathe(scale(onupdate, parts[1], parts[0]));
@ -195,14 +192,15 @@ export class Topo {
let boundsOverride = this.bounds.clone();
boundsOverride.min.x += offStart * units;
boundsOverride.max.x -= offEnd * units;
let terrainData = await gpu.rasterizeModel({
await gpu.loadTool({
sparseData: toolData
});
await gpu.loadTerrain({
triangles: vertices,
boundsOverride,
onProgress(pct) { onupdate(pct/100) }
});
let output = await gpu.generateToolpaths({
terrainData,
toolData,
xStep,
yStep: 1,
zFloor: zBottom,
@ -210,15 +208,14 @@ export class Topo {
});
gpu.terminate();
let { numScanlines, pointsPerLine, pathData } = output;
let degPerRow = 360 / numScanlines;
let { numStrips, strips } = output;
let degPerRow = 360 / numStrips;
let slices = this.gpu_slices = [];
let xmult = resolution * xStep;
let xoff = output.generationBounds.min.x;
let xoff = boundsOverride.min.x;
let rows = [];
for (let i=0; i<numScanlines; i++) {
let lineData = pathData.slice(i * pointsPerLine, i * pointsPerLine + pointsPerLine);
let points = Array.from(lineData).map((v,j) => newPoint(j * xmult + xoff, 0, v).setA(-i * degPerRow));
for (let i=0; i<numStrips; i++) {
let points = Array.from(strips[i].pathData).map((v,j) => newPoint(j * xmult + xoff, 0, v).setA(-i * degPerRow));
rows.push(points);
}
if (linear) {