@gridspace/raster-path 1.0.3 → 1.0.5
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.
- package/README.md +3 -5
- package/build/app.js +363 -39
- package/build/index.html +40 -2
- package/build/raster-path.js +16 -24
- package/build/raster-worker.js +2450 -0
- package/build/style.css +65 -0
- package/package.json +12 -4
- package/scripts/build-shaders.js +32 -8
- package/src/core/path-planar.js +788 -0
- package/src/core/path-radial.js +651 -0
- package/src/core/raster-config.js +185 -0
- package/src/{index.js → core/raster-path.js} +16 -24
- package/src/core/raster-planar.js +754 -0
- package/src/core/raster-tool.js +104 -0
- package/src/core/raster-worker.js +152 -0
- package/src/core/workload-calibrate.js +416 -0
- package/src/shaders/{radial-raster-v2.wgsl → radial-raster.wgsl} +8 -2
- package/src/shaders/workload-calibrate.wgsl +106 -0
- package/src/test/batch-divisor-benchmark.cjs +286 -0
- package/src/test/calibrate-test.cjs +136 -0
- package/src/test/extreme-work-test.cjs +167 -0
- package/src/test/lathe-cylinder-2-debug.cjs +334 -0
- package/src/test/lathe-cylinder-2-test.cjs +157 -0
- package/src/test/lathe-cylinder-test.cjs +198 -0
- package/src/test/radial-thread-limit-test.cjs +152 -0
- package/src/test/work-estimation-profile.cjs +406 -0
- package/src/test/workload-calculator-demo.cjs +113 -0
- package/src/test/workload-calibration.cjs +310 -0
- package/src/web/app.js +363 -39
- package/src/web/index.html +40 -2
- package/src/web/style.css +65 -0
- package/src/workload-calculator.js +318 -0
- package/build/webgpu-worker.js +0 -3011
- package/src/web/webgpu-worker.js +0 -2520
package/build/index.html
CHANGED
|
@@ -8,7 +8,45 @@
|
|
|
8
8
|
</head>
|
|
9
9
|
<body>
|
|
10
10
|
<div id="container">
|
|
11
|
-
<!--
|
|
11
|
+
<!-- Left Panel - Model Manipulation -->
|
|
12
|
+
<div class="model-controls">
|
|
13
|
+
<div class="section">
|
|
14
|
+
<h3>Model Rotation</h3>
|
|
15
|
+
<div class="rotation-controls">
|
|
16
|
+
<div class="rotation-row">
|
|
17
|
+
<span class="rotation-label">X:</span>
|
|
18
|
+
<button class="rotate-btn" data-axis="x" data-dir="-1">-90°</button>
|
|
19
|
+
<button class="rotate-btn" data-axis="x" data-dir="1">+90°</button>
|
|
20
|
+
</div>
|
|
21
|
+
<div class="rotation-row">
|
|
22
|
+
<span class="rotation-label">Y:</span>
|
|
23
|
+
<button class="rotate-btn" data-axis="y" data-dir="-1">-90°</button>
|
|
24
|
+
<button class="rotate-btn" data-axis="y" data-dir="1">+90°</button>
|
|
25
|
+
</div>
|
|
26
|
+
<div class="rotation-row">
|
|
27
|
+
<span class="rotation-label">Z:</span>
|
|
28
|
+
<button class="rotate-btn" data-axis="z" data-dir="-1">-90°</button>
|
|
29
|
+
<button class="rotate-btn" data-axis="z" data-dir="1">+90°</button>
|
|
30
|
+
</div>
|
|
31
|
+
<button id="reset-rotation" class="btn btn-small">Reset</button>
|
|
32
|
+
</div>
|
|
33
|
+
</div>
|
|
34
|
+
|
|
35
|
+
<div class="section">
|
|
36
|
+
<h3>Tool Size</h3>
|
|
37
|
+
<select id="tool-size">
|
|
38
|
+
<option value="1.0">1.0mm</option>
|
|
39
|
+
<option value="2.0">2.0mm</option>
|
|
40
|
+
<option value="2.5" selected>2.5mm</option>
|
|
41
|
+
<option value="3.0">3.0mm</option>
|
|
42
|
+
<option value="4.0">4.0mm</option>
|
|
43
|
+
<option value="5.0">5.0mm</option>
|
|
44
|
+
</select>
|
|
45
|
+
<div id="tool-size-status" class="status">No tool loaded</div>
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
|
|
49
|
+
<!-- Right Panel - Controls -->
|
|
12
50
|
<div class="controls">
|
|
13
51
|
<div class="section">
|
|
14
52
|
<h3>Mode</h3>
|
|
@@ -87,6 +125,6 @@
|
|
|
87
125
|
}
|
|
88
126
|
</script>
|
|
89
127
|
<script type="module" src="app.js"></script>
|
|
90
|
-
<!-- <script type="module" src="
|
|
128
|
+
<!-- <script type="module" src="raster-worker.js"></script> -->
|
|
91
129
|
</body>
|
|
92
130
|
</html>
|
package/build/raster-path.js
CHANGED
|
@@ -48,13 +48,10 @@
|
|
|
48
48
|
* @property {'planar'|'radial'} mode - Rasterization mode (default: 'planar')
|
|
49
49
|
* @property {boolean} autoTiling - Automatically tile large datasets (default: true)
|
|
50
50
|
* @property {number} gpuMemorySafetyMargin - Safety margin as percentage (default: 0.8 = 80%)
|
|
51
|
-
* @property {number} maxConcurrentTiles - Max concurrent tiles for radial rasterization (default: 50)
|
|
52
51
|
* @property {number} maxGPUMemoryMB - Maximum GPU memory per tile (default: 256MB)
|
|
53
|
-
* @property {number} minTileSize - Minimum tile dimension (default: 50mm)
|
|
54
|
-
* @property {number} radialRotationOffset - Radial mode: rotation offset in degrees (default: 0, use 90 to start at Z-axis)
|
|
55
52
|
* @property {number} resolution - Grid step size in mm (required)
|
|
56
53
|
* @property {number} rotationStep - Radial mode only: degrees between rays (e.g., 1.0 = 360 rays)
|
|
57
|
-
* @property {number}
|
|
54
|
+
* @property {number} batchDivisor - Testing parameter to artificially divide batch size (default: 1)
|
|
58
55
|
* @property {boolean} debug - Enable debug logging (default: false)
|
|
59
56
|
* @property {boolean} quiet - Suppress log output (default: false)
|
|
60
57
|
*/
|
|
@@ -103,26 +100,22 @@ export class RasterPath {
|
|
|
103
100
|
this.deviceCapabilities = null;
|
|
104
101
|
|
|
105
102
|
// Configure debug output
|
|
106
|
-
let urlOpt = [];
|
|
107
103
|
if (config.quiet) {
|
|
108
104
|
debug.log = function() {};
|
|
109
|
-
urlOpt.push('quiet');
|
|
110
|
-
}
|
|
111
|
-
if (config.debug) {
|
|
112
|
-
urlOpt.push('debug');
|
|
113
105
|
}
|
|
114
106
|
|
|
115
107
|
// Configuration with defaults
|
|
116
108
|
this.config = {
|
|
117
|
-
workerName:
|
|
109
|
+
workerName: config.workerName ?? "raster-worker.js",
|
|
118
110
|
maxGPUMemoryMB: config.maxGPUMemoryMB ?? 256,
|
|
119
111
|
gpuMemorySafetyMargin: config.gpuMemorySafetyMargin ?? 0.8,
|
|
120
112
|
autoTiling: config.autoTiling ?? true,
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
radialRotationOffset: config.radialRotationOffset ?? 0, // degrees
|
|
113
|
+
batchDivisor: config.batchDivisor ?? 1, // For testing batching overhead
|
|
114
|
+
debug: config.debug,
|
|
115
|
+
quiet: config.quiet
|
|
125
116
|
};
|
|
117
|
+
|
|
118
|
+
debug.log('config', this.config);
|
|
126
119
|
}
|
|
127
120
|
|
|
128
121
|
/**
|
|
@@ -137,14 +130,14 @@ export class RasterPath {
|
|
|
137
130
|
|
|
138
131
|
return new Promise((resolve, reject) => {
|
|
139
132
|
try {
|
|
140
|
-
// Create worker from the
|
|
133
|
+
// Create worker from the raster-worker.js file
|
|
141
134
|
const workerName = this.config.workerName;
|
|
142
135
|
const isBuildVersion = import.meta.url.includes('/build/') || import.meta.url.includes('raster-path.js');
|
|
143
136
|
const workerPath = workerName
|
|
144
137
|
? new URL(workerName, import.meta.url)
|
|
145
138
|
: isBuildVersion
|
|
146
|
-
? new URL(`./
|
|
147
|
-
: new URL(
|
|
139
|
+
? new URL(`./raster-worker.js`, import.meta.url)
|
|
140
|
+
: new URL(`../core/raster-worker.js`, import.meta.url);
|
|
148
141
|
this.worker = new Worker(workerPath, { type: 'module' });
|
|
149
142
|
|
|
150
143
|
// Set up message handler
|
|
@@ -238,8 +231,8 @@ export class RasterPath {
|
|
|
238
231
|
const originalBounds = boundsOverride || this.#calculateBounds(triangles);
|
|
239
232
|
|
|
240
233
|
// Center model in YZ plane (required for radial rasterization)
|
|
241
|
-
// Radial mode casts rays from
|
|
242
|
-
//
|
|
234
|
+
// Radial mode casts rays from max_radius distance inward toward the X-axis,
|
|
235
|
+
// and centering ensures the geometry is symmetric around the rotation axis
|
|
243
236
|
const centerY = (originalBounds.min.y + originalBounds.max.y) / 2;
|
|
244
237
|
const centerZ = (originalBounds.min.z + originalBounds.max.z) / 2;
|
|
245
238
|
|
|
@@ -273,12 +266,10 @@ export class RasterPath {
|
|
|
273
266
|
* @param {number} params.xStep - Sample every Nth point in X direction
|
|
274
267
|
* @param {number} params.yStep - Sample every Nth point in Y direction
|
|
275
268
|
* @param {number} params.zFloor - Z floor value for out-of-bounds areas
|
|
276
|
-
* @param {number} params.radiusOffset - (Radial mode only) Distance from terrain surface to tool tip in mm.
|
|
277
|
-
* Used to calculate radial collision offset. Default: 20mm
|
|
278
269
|
* @param {function} params.onProgress - Optional progress callback (progress: number, info?: string) => void
|
|
279
270
|
* @returns {Promise<object>} Planar: {pathData, width, height} | Radial: {strips[], numStrips, totalPoints}
|
|
280
271
|
*/
|
|
281
|
-
async generateToolpaths({ xStep, yStep, zFloor,
|
|
272
|
+
async generateToolpaths({ xStep, yStep, zFloor, onProgress }) {
|
|
282
273
|
if (!this.isInitialized) {
|
|
283
274
|
throw new Error('RasterPath not initialized. Call init() first.');
|
|
284
275
|
}
|
|
@@ -287,6 +278,8 @@ export class RasterPath {
|
|
|
287
278
|
throw new Error('Tool not loaded. Call loadTool() first.');
|
|
288
279
|
}
|
|
289
280
|
|
|
281
|
+
debug.log('gen.paths', { xStep, yStep, zFloor });
|
|
282
|
+
|
|
290
283
|
if (this.mode === 'planar') {
|
|
291
284
|
if (!this.terrainData) {
|
|
292
285
|
throw new Error('Terrain not loaded. Call loadTerrain() first.');
|
|
@@ -444,8 +437,7 @@ export class RasterPath {
|
|
|
444
437
|
zFloor: zFloor,
|
|
445
438
|
bounds,
|
|
446
439
|
xStep,
|
|
447
|
-
yStep
|
|
448
|
-
gridStep: this.resolution
|
|
440
|
+
yStep
|
|
449
441
|
},
|
|
450
442
|
'radial-toolpaths-complete',
|
|
451
443
|
completionHandler
|