swap vertices for gpu compute, fix progress

This commit is contained in:
Stewart Allen 2025-10-31 19:39:46 -04:00
commit 007d03b629

View file

@ -162,11 +162,21 @@ export class Topo {
async sliceGPU(onupdate) { async sliceGPU(onupdate) {
const { angle, linear, offStart, offEnd, resolution, tool, unit, vertices, zBottom } = this; const { angle, linear, offStart, offEnd, resolution, tool, unit, vertices, zBottom } = this;
// invert tool Z offset for gpu code
let gputool = tool.slice(); let gputool = tool.slice();
for (let i=0; i<gputool.length; i+= 3) { for (let i=0; i<gputool.length; i+= 3) {
gputool[i+2] *= -1; gputool[i+2] *= -1;
} }
console.time('swap XZ vertices');
// swap XZ vertices for gpu code
for (let i=0; i<vertices.length; i+= 3) {
let tmp = vertices[i+2];
vertices[i+2] = vertices[i+0];
vertices[i+0] = tmp;
}
console.timeEnd('swap XZ vertices');
let gpu = await self.get_raster_gpu(); let gpu = await self.get_raster_gpu();
let tickperstep = Math.round(this.step / resolution); let tickperstep = Math.round(this.step / resolution);
let bounds = this.bounds.clone(); let bounds = this.bounds.clone();
@ -180,7 +190,7 @@ export class Topo {
zBottom, zBottom,
resolution, resolution,
bounds, bounds,
(pct, msg) => { console.log({ pct, msg }) } { onProgress(pct, msg) { onupdate(pct/100) } }
); );
let { numRotations, pointsPerLine, pathData } = output; let { numRotations, pointsPerLine, pathData } = output;