update to v3 raster gpu api
This commit is contained in:
parent
17e40ceed0
commit
8fdd16979b
4 changed files with 19 additions and 19 deletions
|
|
@ -54,6 +54,7 @@ self.kiri.load(api => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let ws_url = api.onshape ? `ws://${local_host}/bambu` : "/bambu";
|
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);
|
let ws = socket.ws = new WebSocket(ws_url);
|
||||||
ws.onerror = (error) => {
|
ws.onerror = (error) => {
|
||||||
socket.open = false;
|
socket.open = false;
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ class OpLathe extends CamOp {
|
||||||
|
|
||||||
async slice(progress) {
|
async slice(progress) {
|
||||||
let { op, state } = this;
|
let { op, state } = this;
|
||||||
let { addSlices } = state;
|
let { addSlices, color } = state;
|
||||||
let filter = createFilter(op);
|
let filter = createFilter(op);
|
||||||
this.topo = await topo4_generate({
|
this.topo = await topo4_generate({
|
||||||
op,
|
op,
|
||||||
|
|
|
||||||
|
|
@ -143,21 +143,23 @@ export class Topo {
|
||||||
let xStep = density;
|
let xStep = density;
|
||||||
let yStep = Math.ceil(toolStep / resolution);
|
let yStep = Math.ceil(toolStep / resolution);
|
||||||
let epsilon = 10e-5;
|
let epsilon = 10e-5;
|
||||||
let terrainData = await gpu.rasterizeModel({
|
await gpu.loadTool({
|
||||||
|
sparseData: toolData
|
||||||
|
});
|
||||||
|
let terrain = await gpu.loadTerrain({
|
||||||
triangles: vertices,
|
triangles: vertices,
|
||||||
boundsOverride: wbounds
|
boundsOverride: wbounds
|
||||||
});
|
});
|
||||||
|
let { gridWidth, positions } = terrain;
|
||||||
let output = await gpu.generateToolpaths({
|
let output = await gpu.generateToolpaths({
|
||||||
terrainData,
|
|
||||||
toolData,
|
|
||||||
xStep,
|
xStep,
|
||||||
yStep,
|
yStep,
|
||||||
zFloor: zBottom - 1,
|
zFloor: zBottom - 1,
|
||||||
onProgress(pct) { console.log({ pct }); onupdate(pct/100, 100) }
|
onProgress(pct) { console.log({ pct }); onupdate(pct/100, 100) }
|
||||||
});
|
});
|
||||||
gpu.terminate();
|
gpu.terminate();
|
||||||
|
|
||||||
let { numScanlines, pointsPerLine, pathData } = output;
|
let { numScanlines, pointsPerLine, pathData } = output;
|
||||||
let { positions, gridWidth } = terrainData;
|
|
||||||
let xmult = xStep * resolution;
|
let xmult = xStep * resolution;
|
||||||
let ymult = yStep * resolution;
|
let ymult = yStep * resolution;
|
||||||
let xoff = wbounds.min.x;
|
let xoff = wbounds.min.x;
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ export class Topo {
|
||||||
|
|
||||||
async generate(opt = {}) {
|
async generate(opt = {}) {
|
||||||
let { state, op, onupdate, ondone } = opt;
|
let { state, op, onupdate, ondone } = opt;
|
||||||
let { widget, settings, tabs } = opt.state;
|
let { widget, settings, tabs, color } = state;
|
||||||
let { controller, process } = settings;
|
let { controller, process } = settings;
|
||||||
let { webGPU } = controller;
|
let { webGPU } = controller;
|
||||||
|
|
||||||
|
|
@ -64,7 +64,7 @@ export class Topo {
|
||||||
this.zoff = widget.track.top || 0;
|
this.zoff = widget.track.top || 0;
|
||||||
this.leave = op.leave || 0;
|
this.leave = op.leave || 0;
|
||||||
this.linear = op.linear || false;
|
this.linear = op.linear || false;
|
||||||
this.lineColor = controller.dark ? 0xffff00 : 0x555500;
|
this.lineColor = color;//controller.dark ? 0xffff00 : 0x555500;
|
||||||
this.offStart = op.offStart ?? 0;
|
this.offStart = op.offStart ?? 0;
|
||||||
this.offEnd = op.offEnd ?? 0;
|
this.offEnd = op.offEnd ?? 0;
|
||||||
this.bounds = bounds;
|
this.bounds = bounds;
|
||||||
|
|
@ -79,9 +79,6 @@ export class Topo {
|
||||||
for (let slice of slices) {
|
for (let slice of slices) {
|
||||||
range.min = Math.min(range.min, slice.z);
|
range.min = Math.min(range.min, slice.z);
|
||||||
range.max = Math.max(range.max, 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]));
|
const lathe = await this.lathe(scale(onupdate, parts[1], parts[0]));
|
||||||
|
|
@ -195,14 +192,15 @@ export class Topo {
|
||||||
let boundsOverride = this.bounds.clone();
|
let boundsOverride = this.bounds.clone();
|
||||||
boundsOverride.min.x += offStart * units;
|
boundsOverride.min.x += offStart * units;
|
||||||
boundsOverride.max.x -= offEnd * units;
|
boundsOverride.max.x -= offEnd * units;
|
||||||
let terrainData = await gpu.rasterizeModel({
|
await gpu.loadTool({
|
||||||
|
sparseData: toolData
|
||||||
|
});
|
||||||
|
await gpu.loadTerrain({
|
||||||
triangles: vertices,
|
triangles: vertices,
|
||||||
boundsOverride,
|
boundsOverride,
|
||||||
onProgress(pct) { onupdate(pct/100) }
|
onProgress(pct) { onupdate(pct/100) }
|
||||||
});
|
});
|
||||||
let output = await gpu.generateToolpaths({
|
let output = await gpu.generateToolpaths({
|
||||||
terrainData,
|
|
||||||
toolData,
|
|
||||||
xStep,
|
xStep,
|
||||||
yStep: 1,
|
yStep: 1,
|
||||||
zFloor: zBottom,
|
zFloor: zBottom,
|
||||||
|
|
@ -210,15 +208,14 @@ export class Topo {
|
||||||
});
|
});
|
||||||
gpu.terminate();
|
gpu.terminate();
|
||||||
|
|
||||||
let { numScanlines, pointsPerLine, pathData } = output;
|
let { numStrips, strips } = output;
|
||||||
let degPerRow = 360 / numScanlines;
|
let degPerRow = 360 / numStrips;
|
||||||
let slices = this.gpu_slices = [];
|
let slices = this.gpu_slices = [];
|
||||||
let xmult = resolution * xStep;
|
let xmult = resolution * xStep;
|
||||||
let xoff = output.generationBounds.min.x;
|
let xoff = boundsOverride.min.x;
|
||||||
let rows = [];
|
let rows = [];
|
||||||
for (let i=0; i<numScanlines; i++) {
|
for (let i=0; i<numStrips; i++) {
|
||||||
let lineData = pathData.slice(i * pointsPerLine, i * pointsPerLine + pointsPerLine);
|
let points = Array.from(strips[i].pathData).map((v,j) => newPoint(j * xmult + xoff, 0, v).setA(-i * degPerRow));
|
||||||
let points = Array.from(lineData).map((v,j) => newPoint(j * xmult + xoff, 0, v).setA(-i * degPerRow));
|
|
||||||
rows.push(points);
|
rows.push(points);
|
||||||
}
|
}
|
||||||
if (linear) {
|
if (linear) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue