@ifc-lite/geometry 1.19.0 → 2.1.0

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.
Files changed (66) hide show
  1. package/dist/geometry-coordinate.d.ts +0 -5
  2. package/dist/geometry-coordinate.d.ts.map +1 -1
  3. package/dist/geometry-coordinate.js +0 -19
  4. package/dist/geometry-coordinate.js.map +1 -1
  5. package/dist/geometry-parallel.d.ts +4 -26
  6. package/dist/geometry-parallel.d.ts.map +1 -1
  7. package/dist/geometry-parallel.js +5 -23
  8. package/dist/geometry-parallel.js.map +1 -1
  9. package/dist/geometry.worker.d.ts +0 -1
  10. package/dist/geometry.worker.d.ts.map +1 -1
  11. package/dist/geometry.worker.js.map +1 -1
  12. package/dist/ifc-lite-bridge.d.ts +9 -58
  13. package/dist/ifc-lite-bridge.d.ts.map +1 -1
  14. package/dist/ifc-lite-bridge.js +22 -118
  15. package/dist/ifc-lite-bridge.js.map +1 -1
  16. package/dist/index.d.ts +26 -46
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +117 -293
  19. package/dist/index.js.map +1 -1
  20. package/dist/platform-bridge.d.ts +6 -3
  21. package/dist/platform-bridge.d.ts.map +1 -1
  22. package/dist/platform-bridge.js +7 -7
  23. package/dist/platform-bridge.js.map +1 -1
  24. package/dist/progressive-loader.d.ts +5 -56
  25. package/dist/progressive-loader.d.ts.map +1 -1
  26. package/dist/progressive-loader.js +7 -132
  27. package/dist/progressive-loader.js.map +1 -1
  28. package/dist/types.d.ts +0 -29
  29. package/dist/types.d.ts.map +1 -1
  30. package/package.json +5 -14
  31. package/dist/default-materials.d.ts +0 -22
  32. package/dist/default-materials.d.ts.map +0 -1
  33. package/dist/default-materials.js +0 -124
  34. package/dist/default-materials.js.map +0 -1
  35. package/dist/geometry-controller.worker.d.ts +0 -4
  36. package/dist/geometry-controller.worker.d.ts.map +0 -1
  37. package/dist/geometry-controller.worker.js +0 -402
  38. package/dist/geometry-controller.worker.js.map +0 -1
  39. package/dist/geometry-deduplicator.d.ts +0 -42
  40. package/dist/geometry-deduplicator.d.ts.map +0 -1
  41. package/dist/geometry-deduplicator.js +0 -80
  42. package/dist/geometry-deduplicator.js.map +0 -1
  43. package/dist/ifc-lite-mesh-collector.d.ts +0 -111
  44. package/dist/ifc-lite-mesh-collector.d.ts.map +0 -1
  45. package/dist/ifc-lite-mesh-collector.js +0 -455
  46. package/dist/ifc-lite-mesh-collector.js.map +0 -1
  47. package/dist/lod.d.ts +0 -60
  48. package/dist/lod.d.ts.map +0 -1
  49. package/dist/lod.js +0 -113
  50. package/dist/lod.js.map +0 -1
  51. package/dist/style-cache.d.ts +0 -36
  52. package/dist/style-cache.d.ts.map +0 -1
  53. package/dist/style-cache.js +0 -127
  54. package/dist/style-cache.js.map +0 -1
  55. package/dist/wasm-bridge.d.ts +0 -22
  56. package/dist/wasm-bridge.d.ts.map +0 -1
  57. package/dist/wasm-bridge.js +0 -120
  58. package/dist/wasm-bridge.js.map +0 -1
  59. package/dist/wasm-memory-manager.d.ts +0 -178
  60. package/dist/wasm-memory-manager.d.ts.map +0 -1
  61. package/dist/wasm-memory-manager.js +0 -86
  62. package/dist/wasm-memory-manager.js.map +0 -1
  63. package/dist/zero-copy-collector.d.ts +0 -158
  64. package/dist/zero-copy-collector.d.ts.map +0 -1
  65. package/dist/zero-copy-collector.js +0 -224
  66. package/dist/zero-copy-collector.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"ifc-lite-mesh-collector.d.ts","sourceRoot":"","sources":["../src/ifc-lite-mesh-collector.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,MAAM,EAAc,iBAAiB,EAAkB,MAAM,gBAAgB,CAAC;AAC5F,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAI3C,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MA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tF;;;;;;;;;OASG;IACH,OAAO,CAAC,wBAAwB;IAShC;;;;OAIG;IACH,OAAO,CAAC,eAAe;IAUvB;;;;;OAKG;IACH,OAAO,CAAC,mBAAmB;IAkB3B;;;OAGG;IACH,aAAa,IAAI,QAAQ,EAAE;IAwF3B;;OAEG;IACH,mBAAmB,IAAI,MAAM,GAAG,SAAS;IAIzC;;;;OAIG;IACI,sBAAsB,CAAC,SAAS,GAAE,MAAW,GAAG,cAAc,CAAC,QAAQ,EAAE,GAAG,yBAAyB,GAAG,uBAAuB,CAAC;IAkMvI;;;;OAIG;IACI,6BAA6B,CAClC,YAAY,EAAE,MAAM,MAAM,GACzB,cAAc,CAAC,QAAQ,EAAE,CAAC;IAmC7B;;;;;OAKG;IACI,iCAAiC,CAAC,SAAS,GAAE,MAAW,GAAG,cAAc,CAAC,iBAAiB,EAAE,CAAC;CAkFtG"}
@@ -1,455 +0,0 @@
1
- /* This Source Code Form is subject to the terms of the Mozilla Public
2
- * License, v. 2.0. If a copy of the MPL was not distributed with this
3
- * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
- /**
5
- * IFC-Lite Mesh Collector - extracts triangle data from IFC-Lite WASM
6
- * Replaces mesh-collector.ts - uses native Rust geometry processing (1.9x faster)
7
- */
8
- import { createLogger } from '@ifc-lite/data';
9
- const log = createLogger('MeshCollector');
10
- export class IfcLiteMeshCollector {
11
- ifcApi;
12
- content;
13
- _buildingRotation;
14
- mergeLayers;
15
- mergeLayersApplied = false;
16
- constructor(ifcApi, content, options = {}) {
17
- this.ifcApi = ifcApi;
18
- this.content = content;
19
- this.mergeLayers = options.mergeLayers === true;
20
- }
21
- /**
22
- * Forward the cached `mergeLayers` flag to the IfcAPI once per
23
- * collector instance. The Rust agent's contract is "state on the
24
- * IfcAPI carries forward to subsequent parseMeshes* calls", so we
25
- * only need to push the flag once before the first parse call.
26
- *
27
- * When the WASM build pre-dates the Rust agent's contract, the
28
- * method is missing — we tolerate that silently because the bridge
29
- * already logged a warning on its own `applyMergeLayers` path.
30
- */
31
- ensureMergeLayersApplied() {
32
- if (this.mergeLayersApplied)
33
- return;
34
- this.mergeLayersApplied = true;
35
- const api = this.ifcApi;
36
- if (typeof api.setMergeLayers === 'function') {
37
- api.setMergeLayers(this.mergeLayers);
38
- }
39
- }
40
- /**
41
- * Convert IFC Z-up coordinates to WebGL Y-up coordinates
42
- * IFC uses Z-up (Z points up), WebGL uses Y-up (Y points up)
43
- * Transformation: swap Y and Z, then negate new Z to maintain right-handedness
44
- */
45
- convertZUpToYUp(coords) {
46
- for (let i = 0; i < coords.length; i += 3) {
47
- const y = coords[i + 1];
48
- const z = coords[i + 2];
49
- // Swap Y and Z: Z-up → Y-up
50
- coords[i + 1] = z; // New Y = old Z (vertical)
51
- coords[i + 2] = -y; // New Z = -old Y (depth, negated for right-hand rule)
52
- }
53
- }
54
- /**
55
- * Reverse triangle winding order to correct for handedness flip.
56
- * The Z-up to Y-up conversion includes a reflection (Z negation),
57
- * which flips the handedness. This reverses winding to compensate,
58
- * ensuring triangles face the correct direction after transformation.
59
- */
60
- reverseWindingOrder(indices) {
61
- // Calculate last valid triangle index to avoid out-of-bounds access
62
- const remainder = indices.length % 3;
63
- const end = indices.length - remainder;
64
- // Warn if indices array has trailing non-triangle entries
65
- if (remainder !== 0) {
66
- console.warn(`[reverseWindingOrder] Index buffer has ${remainder} trailing entries (not divisible by 3)`);
67
- }
68
- for (let i = 0; i < end; i += 3) {
69
- // Swap second and third vertex of each triangle
70
- const temp = indices[i + 1];
71
- indices[i + 1] = indices[i + 2];
72
- indices[i + 2] = temp;
73
- }
74
- }
75
- /**
76
- * Collect all meshes from IFC-Lite
77
- * Much faster than web-ifc (~1.9x speedup)
78
- */
79
- collectMeshes() {
80
- this.ensureMergeLayersApplied();
81
- let collection;
82
- try {
83
- collection = this.ifcApi.parseMeshes(this.content);
84
- }
85
- catch (error) {
86
- log.error('WASM mesh parsing failed', error, { operation: 'collectMeshes' });
87
- throw error;
88
- }
89
- const meshes = [];
90
- let failedMeshes = 0;
91
- // Convert MeshCollection to MeshData[]
92
- for (let i = 0; i < collection.length; i++) {
93
- let mesh = null;
94
- try {
95
- mesh = collection.get(i);
96
- if (!mesh) {
97
- failedMeshes++;
98
- continue;
99
- }
100
- // Get color array [r, g, b, a]
101
- const colorArray = mesh.color;
102
- const color = [
103
- colorArray[0],
104
- colorArray[1],
105
- colorArray[2],
106
- colorArray[3],
107
- ];
108
- // Optional SurfaceColour for the GLB exporter's "Shading" mode.
109
- // Absent when the file didn't author a distinct DiffuseColour
110
- // (the common case) — the exporter falls back to `color`.
111
- const shadingArray = mesh.shadingColor;
112
- const shadingColor = shadingArray && shadingArray.length === 4
113
- ? [shadingArray[0], shadingArray[1], shadingArray[2], shadingArray[3]]
114
- : undefined;
115
- // Z-up→Y-up conversion and winding order reversal are now done
116
- // in Rust (MeshDataJs::new) for performance.
117
- meshes.push({
118
- expressId: mesh.expressId,
119
- ifcType: mesh.ifcType,
120
- positions: mesh.positions,
121
- normals: mesh.normals,
122
- indices: mesh.indices,
123
- color,
124
- ...(shadingColor ? { shadingColor } : {}),
125
- });
126
- // Free the individual mesh to avoid memory leaks
127
- mesh.free();
128
- mesh = null; // Mark as freed
129
- }
130
- catch (error) {
131
- failedMeshes++;
132
- log.caught(`Failed to process mesh ${i}`, error, { operation: 'collectMeshes' });
133
- // Ensure mesh is freed even on error
134
- if (mesh) {
135
- try {
136
- mesh.free();
137
- }
138
- catch {
139
- // Ignore errors during cleanup
140
- }
141
- }
142
- }
143
- }
144
- // Extract building rotation before freeing collection
145
- const buildingRotation = collection.buildingRotation ?? undefined;
146
- // Free the collection
147
- collection.free();
148
- if (failedMeshes > 0) {
149
- log.warn(`Skipped ${failedMeshes} meshes due to errors`, { operation: 'collectMeshes' });
150
- }
151
- log.debug(`Collected ${meshes.length} meshes`, { operation: 'collectMeshes' });
152
- // Store building rotation for later use (will be added to CoordinateInfo)
153
- this._buildingRotation = buildingRotation;
154
- return meshes;
155
- }
156
- /**
157
- * Get building rotation extracted from IfcSite placement
158
- */
159
- getBuildingRotation() {
160
- return this._buildingRotation;
161
- }
162
- /**
163
- * Collect meshes incrementally, yielding batches for progressive rendering
164
- * Uses fast-first-frame streaming: simple geometry (walls, slabs) first
165
- * @param batchSize Number of meshes per batch (default: 25 for faster first frame)
166
- */
167
- async *collectMeshesStreaming(batchSize = 25) {
168
- this.ensureMergeLayersApplied();
169
- // Queue to hold batches produced by async callback
170
- const batchQueue = [];
171
- let resolveWaiting = null;
172
- let isComplete = false;
173
- let processingError = null;
174
- // Map to store color updates for pending batches
175
- const colorUpdates = new Map();
176
- let totalMeshesProcessed = 0;
177
- let failedMeshCount = 0;
178
- // Start async processing
179
- // NOTE: WASM now automatically defers style building for faster first frame
180
- const processingPromise = this.ifcApi.parseMeshesAsync(this.content, {
181
- batchSize,
182
- onRtcOffset: (rtc) => {
183
- // Emit RTC offset event so consumer can capture it
184
- batchQueue.push({
185
- type: 'rtcOffset',
186
- rtcOffset: { x: rtc.x, y: rtc.y, z: rtc.z },
187
- hasRtc: rtc.hasRtc,
188
- });
189
- // Wake up the generator if it's waiting
190
- if (resolveWaiting) {
191
- resolveWaiting();
192
- resolveWaiting = null;
193
- }
194
- },
195
- onColorUpdate: (updates) => {
196
- // Store color updates
197
- for (const [expressId, color] of updates) {
198
- colorUpdates.set(expressId, color);
199
- }
200
- // Emit color update event
201
- batchQueue.push({
202
- type: 'colorUpdate',
203
- updates: new Map(updates),
204
- });
205
- // Wake up the generator if it's waiting
206
- if (resolveWaiting) {
207
- resolveWaiting();
208
- resolveWaiting = null;
209
- }
210
- },
211
- onBatch: (meshes, _progress) => {
212
- // Convert WASM meshes to MeshData[]
213
- const convertedBatch = [];
214
- for (const mesh of meshes) {
215
- try {
216
- // Use updated color if available, otherwise use mesh color
217
- const expressId = mesh.expressId;
218
- const color = colorUpdates.get(expressId) ?? [
219
- mesh.color[0],
220
- mesh.color[1],
221
- mesh.color[2],
222
- mesh.color[3],
223
- ];
224
- // Capture arrays once — Z-up→Y-up conversion and winding order
225
- // reversal are now done in Rust (MeshDataJs::new) for performance.
226
- convertedBatch.push({
227
- expressId,
228
- ifcType: mesh.ifcType,
229
- positions: mesh.positions,
230
- normals: mesh.normals,
231
- indices: mesh.indices,
232
- color,
233
- });
234
- // Free the mesh to avoid memory leaks
235
- mesh.free();
236
- totalMeshesProcessed++;
237
- }
238
- catch (error) {
239
- failedMeshCount++;
240
- log.caught(`Failed to process mesh #${mesh.expressId}`, error, {
241
- operation: 'collectMeshesStreaming',
242
- entityId: mesh.expressId,
243
- });
244
- try {
245
- mesh.free();
246
- }
247
- catch {
248
- // Ignore free errors
249
- }
250
- }
251
- }
252
- // Add batch to queue
253
- if (convertedBatch.length > 0) {
254
- batchQueue.push(convertedBatch);
255
- }
256
- // Wake up the generator if it's waiting
257
- if (resolveWaiting) {
258
- resolveWaiting();
259
- resolveWaiting = null;
260
- }
261
- },
262
- onComplete: (stats) => {
263
- isComplete = true;
264
- // Store building rotation if present
265
- if (stats.buildingRotation !== undefined) {
266
- this._buildingRotation = stats.buildingRotation;
267
- }
268
- log.debug(`Streaming complete: ${stats.totalMeshes} meshes, ${stats.totalVertices} vertices, ${stats.totalTriangles} triangles`, {
269
- operation: 'collectMeshesStreaming',
270
- });
271
- if (failedMeshCount > 0) {
272
- log.warn(`Skipped ${failedMeshCount} meshes due to errors`, { operation: 'collectMeshesStreaming' });
273
- }
274
- // T1.3 / classifier-fix diagnostics: surface the structured CSG
275
- // diagnostics object the WASM bindings attach to `stats`. Logged
276
- // here on the JS side too because `web_sys::console::*` from
277
- // inside the WASM streaming path can be invisible in some
278
- // browser/build combos (worker boundary, log-level filtering).
279
- // A JS console.warn is the most reliable "always shows up" channel.
280
- const diag = stats.csgDiagnostics;
281
- if (diag) {
282
- const totalFailures = diag.totalFailures ?? 0;
283
- // Only surface a `console.warn` when the kernel actually dropped
284
- // a cut — successful parses shouldn't add noise to host apps
285
- // embedding the viewer. The full diagnostics object is still
286
- // attached to `stats.csgDiagnostics` for callers that want it.
287
- if (totalFailures > 0) {
288
- const c = diag.classification ?? {};
289
- // eslint-disable-next-line no-console
290
- console.warn(`[IFC-LITE] CSG diagnostics (JS): classifier=${JSON.stringify(c)}, ` +
291
- `totalFailures=${totalFailures}, ` +
292
- `productsWithFailures=${diag.productsWithFailures ?? 0}, ` +
293
- `hostsWithOpenings=${diag.hostsWithOpenings ?? 0}`);
294
- }
295
- }
296
- // Wake up the generator if it's waiting
297
- if (resolveWaiting) {
298
- resolveWaiting();
299
- resolveWaiting = null;
300
- }
301
- },
302
- }).catch((error) => {
303
- processingError = error instanceof Error ? error : new Error(String(error));
304
- log.error('WASM streaming parsing failed', processingError, { operation: 'collectMeshesStreaming' });
305
- isComplete = true;
306
- if (resolveWaiting) {
307
- resolveWaiting();
308
- resolveWaiting = null;
309
- }
310
- });
311
- // Yield batches as they become available
312
- let yieldedBatchCount = 0;
313
- while (true) {
314
- // Yield any queued batches
315
- while (batchQueue.length > 0) {
316
- yieldedBatchCount++;
317
- yield batchQueue.shift();
318
- }
319
- // Check for errors
320
- if (processingError) {
321
- throw processingError;
322
- }
323
- // Check if we're done
324
- if (isComplete && batchQueue.length === 0) {
325
- break;
326
- }
327
- // Wait for more batches
328
- await new Promise((resolve) => {
329
- resolveWaiting = resolve;
330
- });
331
- }
332
- // Warn if WASM returned 0 results for a non-trivially-sized file
333
- // This typically indicates WASM ran out of memory during parsing
334
- if (yieldedBatchCount === 0 && this.content.length > 1000) {
335
- const sizeMB = (this.content.length / (1024 * 1024)).toFixed(1);
336
- log.warn(`WASM streaming returned 0 batches for ${sizeMB}MB file - ` +
337
- `this may indicate insufficient memory for large file processing`, { operation: 'collectMeshesStreaming', data: { contentLength: this.content.length } });
338
- }
339
- // Ensure processing is complete
340
- await processingPromise;
341
- }
342
- /**
343
- * Collect meshes with dynamic batch sizing (ramp-up approach)
344
- * Accumulates meshes from WASM and yields them in dynamically-sized batches
345
- * @param getBatchSize Function that returns batch size for current batch number
346
- */
347
- async *collectMeshesStreamingDynamic(getBatchSize) {
348
- let batchNumber = 0;
349
- let accumulatedMeshes = [];
350
- let currentBatchSize = getBatchSize();
351
- // Use larger WASM batches to reduce callback overhead
352
- // First frame responsiveness comes from WASM's internal simple/complex ordering
353
- // For huge files (>100MB), use 500 to minimize callbacks (20x fewer than 25)
354
- const wasmBatchSize = 500; // Larger batches = fewer callbacks = faster
355
- for await (const item of this.collectMeshesStreaming(wasmBatchSize)) {
356
- // Skip color update events in dynamic batching
357
- if (item && typeof item === 'object' && 'type' in item && item.type === 'colorUpdate') {
358
- continue;
359
- }
360
- const wasmBatch = item;
361
- for (let i = 0; i < wasmBatch.length; i++)
362
- accumulatedMeshes.push(wasmBatch[i]);
363
- // Yield when we've accumulated enough for current dynamic batch size
364
- while (accumulatedMeshes.length >= currentBatchSize) {
365
- const batchToYield = accumulatedMeshes.splice(0, currentBatchSize);
366
- yield batchToYield;
367
- // Update batch size for next batch
368
- batchNumber++;
369
- currentBatchSize = getBatchSize();
370
- }
371
- }
372
- // Yield remaining meshes
373
- if (accumulatedMeshes.length > 0) {
374
- yield accumulatedMeshes;
375
- }
376
- }
377
- /**
378
- * Collect instanced geometry incrementally, yielding batches for progressive rendering
379
- * Groups identical geometries by hash (before transformation) for GPU instancing
380
- * Uses fast-first-frame streaming: simple geometry (walls, slabs) first
381
- * @param batchSize Number of unique geometries per batch (default: 25)
382
- */
383
- async *collectInstancedGeometryStreaming(batchSize = 25) {
384
- this.ensureMergeLayersApplied();
385
- // Queue to hold batches produced by async callback
386
- const batchQueue = [];
387
- let resolveWaiting = null;
388
- let isComplete = false;
389
- let processingError = null;
390
- // Start async processing
391
- const processingPromise = this.ifcApi.parseMeshesInstancedAsync(this.content, {
392
- batchSize,
393
- onBatch: (geometries, _progress) => {
394
- // NOTE: Do NOT convert Z-up to Y-up here for instanced geometry!
395
- // Instance transforms position geometry in world space.
396
- // If we convert local positions but not transforms, geometry breaks.
397
- // The viewer handles coordinate system in the camera/shader.
398
- // Add batch directly to queue without modification
399
- batchQueue.push(geometries);
400
- // Wake up the generator if it's waiting
401
- if (resolveWaiting) {
402
- resolveWaiting();
403
- resolveWaiting = null;
404
- }
405
- },
406
- onComplete: (_stats) => {
407
- isComplete = true;
408
- // Wake up the generator if it's waiting
409
- if (resolveWaiting) {
410
- resolveWaiting();
411
- resolveWaiting = null;
412
- }
413
- },
414
- }).catch((error) => {
415
- processingError = error instanceof Error ? error : new Error(String(error));
416
- log.error('WASM instanced streaming parsing failed', processingError, { operation: 'collectInstancedGeometryStreaming' });
417
- isComplete = true;
418
- if (resolveWaiting) {
419
- resolveWaiting();
420
- resolveWaiting = null;
421
- }
422
- });
423
- // Yield batches as they become available
424
- let yieldedBatchCount = 0;
425
- while (true) {
426
- // Yield any queued batches
427
- while (batchQueue.length > 0) {
428
- yieldedBatchCount++;
429
- yield batchQueue.shift();
430
- }
431
- // Check for errors
432
- if (processingError) {
433
- throw processingError;
434
- }
435
- // Check if we're done
436
- if (isComplete && batchQueue.length === 0) {
437
- break;
438
- }
439
- // Wait for more batches
440
- await new Promise((resolve) => {
441
- resolveWaiting = resolve;
442
- });
443
- }
444
- // Warn if WASM returned 0 results for a non-trivially-sized file
445
- // This typically indicates WASM ran out of memory during parsing
446
- if (yieldedBatchCount === 0 && this.content.length > 1000) {
447
- const sizeMB = (this.content.length / (1024 * 1024)).toFixed(1);
448
- log.warn(`WASM instanced streaming returned 0 batches for ${sizeMB}MB file - ` +
449
- `this may indicate insufficient memory for large file processing`, { operation: 'collectInstancedGeometryStreaming', data: { contentLength: this.content.length } });
450
- }
451
- // Ensure processing is complete
452
- await processingPromise;
453
- }
454
- }
455
- //# sourceMappingURL=ifc-lite-mesh-collector.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ifc-lite-mesh-collector.js","sourceRoot":"","sources":["../src/ifc-lite-mesh-collector.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,gBA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1D,MAAM,MAAM,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;YAChE,GAAG,CAAC,IAAI,CACN,mDAAmD,MAAM,YAAY;gBACrE,iEAAiE,EACjE,EAAE,SAAS,EAAE,mCAAmC,EAAE,IAAI,EAAE,EAAE,aAAa,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CACjG,CAAC;QACJ,CAAC;QAED,gCAAgC;QAChC,MAAM,iBAAiB,CAAC;IAC1B,CAAC;CACF"}
package/dist/lod.d.ts DELETED
@@ -1,60 +0,0 @@
1
- /**
2
- * Level of Detail (LOD) system for geometry optimization
3
- * Uses screen-space size culling for performance
4
- */
5
- import type { MeshData } from './types.js';
6
- import type { Vec3 } from './types.js';
7
- export interface LODConfig {
8
- /**
9
- * Minimum screen-space size (in pixels) to render at full detail
10
- * Objects smaller than this will be culled
11
- */
12
- minScreenSize?: number;
13
- /**
14
- * Distance thresholds for LOD levels (in world units)
15
- * [near, mid, far] - objects beyond far threshold are culled
16
- */
17
- distanceThresholds?: [number, number, number];
18
- }
19
- export interface LODMesh {
20
- lod0: MeshData;
21
- lod1?: MeshData;
22
- lod2?: MeshData;
23
- bounds: {
24
- min: Vec3;
25
- max: Vec3;
26
- };
27
- }
28
- export declare class LODGenerator {
29
- private config;
30
- constructor(config?: LODConfig);
31
- /**
32
- * Calculate screen-space size of a mesh from camera position
33
- */
34
- calculateScreenSize(meshBounds: {
35
- min: Vec3;
36
- max: Vec3;
37
- }, cameraPosition: Vec3, _viewProjMatrix: Float32Array, _viewportWidth: number, viewportHeight: number): number;
38
- /**
39
- * Determine if mesh should be rendered based on screen size
40
- */
41
- shouldRender(meshBounds: {
42
- min: Vec3;
43
- max: Vec3;
44
- }, cameraPosition: Vec3, viewProjMatrix: Float32Array, viewportWidth: number, viewportHeight: number): boolean;
45
- /**
46
- * Get LOD level based on distance (0 = full detail, 1 = medium, 2 = low, -1 = cull)
47
- */
48
- getLODLevel(meshBounds: {
49
- min: Vec3;
50
- max: Vec3;
51
- }, cameraPosition: Vec3): number;
52
- /**
53
- * Compute bounds from mesh data
54
- */
55
- static computeBounds(mesh: MeshData): {
56
- min: Vec3;
57
- max: Vec3;
58
- };
59
- }
60
- //# sourceMappingURL=lod.d.ts.map
package/dist/lod.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"lod.d.ts","sourceRoot":"","sources":["../src/lod.ts"],"names":[],"mappings":"AAIA;;;GAGG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC,MAAM,WAAW,SAAS;IACxB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;;OAGG;IACH,kBAAkB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;CAC/C;AAED,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,MAAM,EAAE;QAAE,GAAG,EAAE,IAAI,CAAC;QAAC,GAAG,EAAE,IAAI,CAAA;KAAE,CAAC;CAClC;AAED,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAsB;gBAExB,MAAM,GAAE,SAAc;IAOlC;;OAEG;IACH,mBAAmB,CACjB,UAAU,EAAE;QAAE,GAAG,EAAE,IAAI,CAAC;QAAC,GAAG,EAAE,IAAI,CAAA;KAAE,EACpC,cAAc,EAAE,IAAI,EACpB,eAAe,EAAE,YAAY,EAC7B,cAAc,EAAE,MAAM,EACtB,cAAc,EAAE,MAAM,GACrB,MAAM;IAkCT;;OAEG;IACH,YAAY,CACV,UAAU,EAAE;QAAE,GAAG,EAAE,IAAI,CAAC;QAAC,GAAG,EAAE,IAAI,CAAA;KAAE,EACpC,cAAc,EAAE,IAAI,EACpB,cAAc,EAAE,YAAY,EAC5B,aAAa,EAAE,MAAM,EACrB,cAAc,EAAE,MAAM,GACrB,OAAO;IAWV;;OAEG;IACH,WAAW,CACT,UAAU,EAAE;QAAE,GAAG,EAAE,IAAI,CAAC;QAAC,GAAG,EAAE,IAAI,CAAA;KAAE,EACpC,cAAc,EAAE,IAAI,GACnB,MAAM;IA2BT;;OAEG;IACH,MAAM,CAAC,aAAa,CAAC,IAAI,EAAE,QAAQ,GAAG;QAAE,GAAG,EAAE,IAAI,CAAC;QAAC,GAAG,EAAE,IAAI,CAAA;KAAE;CAkC/D"}
package/dist/lod.js DELETED
@@ -1,113 +0,0 @@
1
- /* This Source Code Form is subject to the terms of the Mozilla Public
2
- * License, v. 2.0. If a copy of the MPL was not distributed with this
3
- * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
- export class LODGenerator {
5
- config;
6
- constructor(config = {}) {
7
- this.config = {
8
- minScreenSize: config.minScreenSize ?? 2.0, // 2 pixels minimum
9
- distanceThresholds: config.distanceThresholds ?? [50, 200, 1000], // near, mid, far
10
- };
11
- }
12
- /**
13
- * Calculate screen-space size of a mesh from camera position
14
- */
15
- calculateScreenSize(meshBounds, cameraPosition, _viewProjMatrix, _viewportWidth, viewportHeight) {
16
- // Calculate center of bounds
17
- const center = {
18
- x: (meshBounds.min.x + meshBounds.max.x) / 2,
19
- y: (meshBounds.min.y + meshBounds.max.y) / 2,
20
- z: (meshBounds.min.z + meshBounds.max.z) / 2,
21
- };
22
- // Calculate size of bounds
23
- const size = {
24
- x: meshBounds.max.x - meshBounds.min.x,
25
- y: meshBounds.max.y - meshBounds.min.y,
26
- z: meshBounds.max.z - meshBounds.min.z,
27
- };
28
- // Approximate radius (half diagonal)
29
- const radius = Math.sqrt(size.x ** 2 + size.y ** 2 + size.z ** 2) / 2;
30
- // Distance from camera to center
31
- const dx = center.x - cameraPosition.x;
32
- const dy = center.y - cameraPosition.y;
33
- const dz = center.z - cameraPosition.z;
34
- const distance = Math.sqrt(dx ** 2 + dy ** 2 + dz ** 2);
35
- if (distance === 0)
36
- return Infinity;
37
- // Project radius to screen space
38
- // Simplified: assume FOV of 45 degrees (tan(22.5) ≈ 0.414)
39
- const fovFactor = 0.414;
40
- const screenSize = (radius / distance) * viewportHeight * fovFactor;
41
- return screenSize;
42
- }
43
- /**
44
- * Determine if mesh should be rendered based on screen size
45
- */
46
- shouldRender(meshBounds, cameraPosition, viewProjMatrix, viewportWidth, viewportHeight) {
47
- const screenSize = this.calculateScreenSize(meshBounds, cameraPosition, viewProjMatrix, viewportWidth, viewportHeight);
48
- return screenSize >= this.config.minScreenSize;
49
- }
50
- /**
51
- * Get LOD level based on distance (0 = full detail, 1 = medium, 2 = low, -1 = cull)
52
- */
53
- getLODLevel(meshBounds, cameraPosition) {
54
- // Calculate center of bounds
55
- const center = {
56
- x: (meshBounds.min.x + meshBounds.max.x) / 2,
57
- y: (meshBounds.min.y + meshBounds.max.y) / 2,
58
- z: (meshBounds.min.z + meshBounds.max.z) / 2,
59
- };
60
- // Distance from camera to center
61
- const dx = center.x - cameraPosition.x;
62
- const dy = center.y - cameraPosition.y;
63
- const dz = center.z - cameraPosition.z;
64
- const distance = Math.sqrt(dx ** 2 + dy ** 2 + dz ** 2);
65
- const [near, mid, far] = this.config.distanceThresholds;
66
- if (distance < near) {
67
- return 0; // Full detail
68
- }
69
- else if (distance < mid) {
70
- return 1; // Medium detail
71
- }
72
- else if (distance < far) {
73
- return 2; // Low detail
74
- }
75
- else {
76
- return -1; // Cull
77
- }
78
- }
79
- /**
80
- * Compute bounds from mesh data
81
- */
82
- static computeBounds(mesh) {
83
- const positions = mesh.positions;
84
- if (positions.length === 0) {
85
- return {
86
- min: { x: 0, y: 0, z: 0 },
87
- max: { x: 0, y: 0, z: 0 },
88
- };
89
- }
90
- let minX = positions[0];
91
- let minY = positions[1];
92
- let minZ = positions[2];
93
- let maxX = positions[0];
94
- let maxY = positions[1];
95
- let maxZ = positions[2];
96
- for (let i = 3; i < positions.length; i += 3) {
97
- const x = positions[i];
98
- const y = positions[i + 1];
99
- const z = positions[i + 2];
100
- minX = Math.min(minX, x);
101
- minY = Math.min(minY, y);
102
- minZ = Math.min(minZ, z);
103
- maxX = Math.max(maxX, x);
104
- maxY = Math.max(maxY, y);
105
- maxZ = Math.max(maxZ, z);
106
- }
107
- return {
108
- min: { x: minX, y: minY, z: minZ },
109
- max: { x: maxX, y: maxY, z: maxZ },
110
- };
111
- }
112
- }
113
- //# sourceMappingURL=lod.js.map