@gridspace/raster-path 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -681,18 +681,32 @@ export class RasterPath {
681
681
  }
682
682
 
683
683
  // Flatten triangle indices for GPU
684
- const triangleIndices = [];
684
+ // Pre-calculate total size for optimal performance
685
+ let totalIndices = 0;
686
+ for (let i = 0; i < buckets.length; i++) {
687
+ totalIndices += buckets[i].triangleIndices.length;
688
+ }
689
+
690
+ // Pre-allocate array to avoid resizing overhead
691
+ const triangleIndices = new Array(totalIndices);
685
692
  const bucketInfo = [];
693
+ let offset = 0;
686
694
 
687
695
  for (let i = 0; i < buckets.length; i++) {
688
696
  const bucket = buckets[i];
697
+ const indices = bucket.triangleIndices;
698
+
689
699
  bucketInfo.push({
690
700
  minX: bucket.minX,
691
701
  maxX: bucket.maxX,
692
- startIndex: triangleIndices.length,
693
- count: bucket.triangleIndices.length
702
+ startIndex: offset,
703
+ count: indices.length
694
704
  });
695
- triangleIndices.push(...bucket.triangleIndices);
705
+
706
+ // Copy indices using fast indexed access
707
+ for (let j = 0; j < indices.length; j++) {
708
+ triangleIndices[offset++] = indices[j];
709
+ }
696
710
  }
697
711
 
698
712
  return {
@@ -2387,7 +2387,7 @@ async function generateRadialToolpaths({
2387
2387
  if (!strip.positions || strip.positions.length === 0)
2388
2388
  continue;
2389
2389
  if (diagnostic && (globalStripIdx === 0 || globalStripIdx === 360)) {
2390
- debug.log(`E1ZZPX44 | Strip ${globalStripIdx} (${strip.angle.toFixed(1)}\xB0) INPUT terrain first 5 Z values: ${strip.positions.slice(0, 5).map((v) => v.toFixed(3)).join(",")}`);
2390
+ debug.log(`ES2VU471 | Strip ${globalStripIdx} (${strip.angle.toFixed(1)}\xB0) INPUT terrain first 5 Z values: ${strip.positions.slice(0, 5).map((v) => v.toFixed(3)).join(",")}`);
2391
2391
  }
2392
2392
  const stripToolpathResult = await runToolpathComputeWithBuffers(
2393
2393
  strip.positions,
@@ -2400,7 +2400,7 @@ async function generateRadialToolpaths({
2400
2400
  pipelineStartTime
2401
2401
  );
2402
2402
  if (diagnostic && (globalStripIdx === 0 || globalStripIdx === 360)) {
2403
- debug.log(`E1ZZPX44 | Strip ${globalStripIdx} (${strip.angle.toFixed(1)}\xB0) OUTPUT toolpath first 5 Z values: ${stripToolpathResult.pathData.slice(0, 5).map((v) => v.toFixed(3)).join(",")}`);
2403
+ debug.log(`ES2VU471 | Strip ${globalStripIdx} (${strip.angle.toFixed(1)}\xB0) OUTPUT toolpath first 5 Z values: ${stripToolpathResult.pathData.slice(0, 5).map((v) => v.toFixed(3)).join(",")}`);
2404
2404
  }
2405
2405
  allStripToolpaths.push({
2406
2406
  angle: strip.angle,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gridspace/raster-path",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "private": false,
5
5
  "description": "Terrain and Tool Raster Path Finder using WebGPU",
6
6
  "type": "module",
@@ -681,18 +681,32 @@ export class RasterPath {
681
681
  }
682
682
 
683
683
  // Flatten triangle indices for GPU
684
- const triangleIndices = [];
684
+ // Pre-calculate total size for optimal performance
685
+ let totalIndices = 0;
686
+ for (let i = 0; i < buckets.length; i++) {
687
+ totalIndices += buckets[i].triangleIndices.length;
688
+ }
689
+
690
+ // Pre-allocate array to avoid resizing overhead
691
+ const triangleIndices = new Array(totalIndices);
685
692
  const bucketInfo = [];
693
+ let offset = 0;
686
694
 
687
695
  for (let i = 0; i < buckets.length; i++) {
688
696
  const bucket = buckets[i];
697
+ const indices = bucket.triangleIndices;
698
+
689
699
  bucketInfo.push({
690
700
  minX: bucket.minX,
691
701
  maxX: bucket.maxX,
692
- startIndex: triangleIndices.length,
693
- count: bucket.triangleIndices.length
702
+ startIndex: offset,
703
+ count: indices.length
694
704
  });
695
- triangleIndices.push(...bucket.triangleIndices);
705
+
706
+ // Copy indices using fast indexed access
707
+ for (let j = 0; j < indices.length; j++) {
708
+ triangleIndices[offset++] = indices[j];
709
+ }
696
710
  }
697
711
 
698
712
  return {