@ifc-lite/geometry 1.1.7 → 1.2.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.
- package/LICENSE +373 -0
- package/dist/default-materials.d.ts.map +1 -1
- package/dist/default-materials.js +12 -1
- package/dist/default-materials.js.map +1 -1
- package/dist/ifc-lite-bridge.d.ts +1 -0
- package/dist/ifc-lite-bridge.d.ts.map +1 -1
- package/dist/ifc-lite-bridge.js.map +1 -1
- package/dist/ifc-lite-mesh-collector.d.ts +12 -2
- package/dist/ifc-lite-mesh-collector.d.ts.map +1 -1
- package/dist/ifc-lite-mesh-collector.js +63 -7
- package/dist/ifc-lite-mesh-collector.js.map +1 -1
- package/dist/index.d.ts +31 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +58 -64
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/wasm-memory-manager.d.ts +178 -0
- package/dist/wasm-memory-manager.d.ts.map +1 -0
- package/dist/wasm-memory-manager.js +86 -0
- package/dist/wasm-memory-manager.js.map +1 -0
- package/dist/zero-copy-collector.d.ts +158 -0
- package/dist/zero-copy-collector.d.ts.map +1 -0
- package/dist/zero-copy-collector.js +224 -0
- package/dist/zero-copy-collector.js.map +1 -0
- package/package.json +8 -8
- package/dist/geometry.worker.d.ts +0 -2
- package/dist/geometry.worker.d.ts.map +0 -1
- package/dist/geometry.worker.js +0 -116
- package/dist/geometry.worker.js.map +0 -1
- package/dist/worker-pool.d.ts +0 -56
- package/dist/worker-pool.d.ts.map +0 -1
- package/dist/worker-pool.js +0 -160
- package/dist/worker-pool.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -3,22 +3,38 @@
|
|
|
3
3
|
* Now powered by IFC-Lite native Rust WASM (1.9x faster than web-ifc)
|
|
4
4
|
*/
|
|
5
5
|
export { IfcLiteBridge } from './ifc-lite-bridge.js';
|
|
6
|
-
export { IfcLiteMeshCollector } from './ifc-lite-mesh-collector.js';
|
|
6
|
+
export { IfcLiteMeshCollector, type StreamingColorUpdateEvent } from './ifc-lite-mesh-collector.js';
|
|
7
7
|
export { BufferBuilder } from './buffer-builder.js';
|
|
8
8
|
export { CoordinateHandler } from './coordinate-handler.js';
|
|
9
|
-
export { WorkerPool } from './worker-pool.js';
|
|
10
9
|
export { GeometryQuality } from './progressive-loader.js';
|
|
11
10
|
export { LODGenerator, type LODConfig, type LODMesh } from './lod.js';
|
|
12
11
|
export { deduplicateMeshes, getDeduplicationStats, type InstancedMeshData, type DeduplicationStats } from './geometry-deduplicator.js';
|
|
13
12
|
export * from './types.js';
|
|
14
13
|
export * from './default-materials.js';
|
|
14
|
+
export { WasmMemoryManager, type GpuGeometryHandle, type GpuMeshMetadataHandle, type GpuInstancedGeometryHandle, type GpuInstancedGeometryCollectionHandle, type GpuInstancedGeometryRefHandle } from './wasm-memory-manager.js';
|
|
15
|
+
export { ZeroCopyMeshCollector, ZeroCopyInstancedCollector, type ZeroCopyStreamingProgress, type ZeroCopyBatchResult, type ZeroCopyCompleteStats, type ZeroCopyMeshMetadata, type ZeroCopyBatch, type ZeroCopyInstancedBatch, } from './zero-copy-collector.js';
|
|
15
16
|
export { IfcLiteBridge as WebIfcBridge } from './ifc-lite-bridge.js';
|
|
16
17
|
import { GeometryQuality } from './progressive-loader.js';
|
|
17
18
|
import type { GeometryResult, MeshData } from './types.js';
|
|
18
19
|
export interface GeometryProcessorOptions {
|
|
19
|
-
useWorkers?: boolean;
|
|
20
20
|
quality?: GeometryQuality;
|
|
21
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Dynamic batch configuration for ramp-up streaming
|
|
24
|
+
* Starts with small batches for fast first frame, ramps up for throughput
|
|
25
|
+
*/
|
|
26
|
+
export interface DynamicBatchConfig {
|
|
27
|
+
/** Initial batch size for first 3 batches (default: 50) */
|
|
28
|
+
initialBatchSize?: number;
|
|
29
|
+
/** Maximum batch size for batches 11+ (default: 500) */
|
|
30
|
+
maxBatchSize?: number;
|
|
31
|
+
/** File size in MB for adaptive sizing (optional) */
|
|
32
|
+
fileSizeMB?: number;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Calculate dynamic batch size based on batch number
|
|
36
|
+
*/
|
|
37
|
+
export declare function calculateDynamicBatchSize(batchNumber: number, initialBatchSize?: number, maxBatchSize?: number): number;
|
|
22
38
|
export type StreamingGeometryEvent = {
|
|
23
39
|
type: 'start';
|
|
24
40
|
totalEstimate: number;
|
|
@@ -30,6 +46,9 @@ export type StreamingGeometryEvent = {
|
|
|
30
46
|
meshes: MeshData[];
|
|
31
47
|
totalSoFar: number;
|
|
32
48
|
coordinateInfo?: import('./types.js').CoordinateInfo;
|
|
49
|
+
} | {
|
|
50
|
+
type: 'colorUpdate';
|
|
51
|
+
updates: Map<number, [number, number, number, number]>;
|
|
33
52
|
} | {
|
|
34
53
|
type: 'complete';
|
|
35
54
|
totalMeshes: number;
|
|
@@ -56,16 +75,14 @@ export declare class GeometryProcessor {
|
|
|
56
75
|
private bridge;
|
|
57
76
|
private bufferBuilder;
|
|
58
77
|
private coordinateHandler;
|
|
59
|
-
private workerPool;
|
|
60
|
-
private useWorkers;
|
|
61
78
|
constructor(options?: GeometryProcessorOptions);
|
|
62
79
|
/**
|
|
63
|
-
* Initialize IFC-Lite WASM
|
|
80
|
+
* Initialize IFC-Lite WASM
|
|
64
81
|
* WASM is automatically resolved from the package location - no path needed
|
|
65
82
|
*/
|
|
66
83
|
init(_wasmPath?: string): Promise<void>;
|
|
67
84
|
/**
|
|
68
|
-
* Process IFC file and extract geometry
|
|
85
|
+
* Process IFC file and extract geometry (synchronous, use processStreaming for large files)
|
|
69
86
|
* @param buffer IFC file buffer
|
|
70
87
|
* @param entityIndex Optional entity index for priority-based loading
|
|
71
88
|
*/
|
|
@@ -79,9 +96,9 @@ export declare class GeometryProcessor {
|
|
|
79
96
|
* Uses IFC-Lite for native Rust geometry processing (1.9x faster)
|
|
80
97
|
* @param buffer IFC file buffer
|
|
81
98
|
* @param entityIndex Optional entity index for priority-based loading
|
|
82
|
-
* @param
|
|
99
|
+
* @param batchConfig Dynamic batch configuration or fixed batch size
|
|
83
100
|
*/
|
|
84
|
-
processStreaming(buffer: Uint8Array, _entityIndex?: Map<number, any>,
|
|
101
|
+
processStreaming(buffer: Uint8Array, _entityIndex?: Map<number, any>, batchConfig?: number | DynamicBatchConfig): AsyncGenerator<StreamingGeometryEvent>;
|
|
85
102
|
/**
|
|
86
103
|
* Process IFC file with streaming instanced geometry output for progressive rendering
|
|
87
104
|
* Groups identical geometries by hash (before transformation) for GPU instancing
|
|
@@ -101,9 +118,13 @@ export declare class GeometryProcessor {
|
|
|
101
118
|
*/
|
|
102
119
|
processAdaptive(buffer: Uint8Array, options?: {
|
|
103
120
|
sizeThreshold?: number;
|
|
104
|
-
batchSize?: number;
|
|
121
|
+
batchSize?: number | DynamicBatchConfig;
|
|
105
122
|
entityIndex?: Map<number, any>;
|
|
106
123
|
}): AsyncGenerator<StreamingGeometryEvent>;
|
|
124
|
+
/**
|
|
125
|
+
* Get the WASM API instance for advanced operations (e.g., entity scanning)
|
|
126
|
+
*/
|
|
127
|
+
getApi(): import("@ifc-lite/wasm").IfcAPI | null;
|
|
107
128
|
/**
|
|
108
129
|
* Cleanup resources
|
|
109
130
|
*/
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA;;;GAGG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA;;;GAGG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,KAAK,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,EAAE,cAAc,CAAA;CAAE,CAAC;AAE/H,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,iBAAiB,CAAoB;gBAEjC,OAAO,GAAE,wBAA6B;IAQlD;;;OAGG;IACG,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI7C;;;;OAIG;IACG,OAAO,CAAC,MAAM,EAAE,UAAU,EAAE,WAAW,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC;IA8B1F;;OAEG;YACW,uBAAuB;IAWrC;;;;;;OAMG;IACI,gBAAgB,CACrB,MAAM,EAAE,UAAU,EAClB,YAAY,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,EAC/B,WAAW,GAAE,MAAM,GAAG,kBAAuB,GAC5C,cAAc,CAAC,sBAAsB,CAAC;IA4DzC;;;;;OAKG;IACI,yBAAyB,CAC9B,MAAM,EAAE,UAAU,EAClB,SAAS,GAAE,MAAW,GACrB,cAAc,CAAC,+BAA+B,CAAC;IAuElD;;;;;;;;;OASG;IACI,eAAe,CACpB,MAAM,EAAE,UAAU,EAClB,OAAO,GAAE;QACP,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,SAAS,CAAC,EAAE,MAAM,GAAG,kBAAkB,CAAC;QACxC,WAAW,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KAC3B,GACL,cAAc,CAAC,sBAAsB,CAAC;IA2CzC;;OAEG;IACH,MAAM;IAON;;OAEG;IACH,OAAO,IAAI,IAAI;CAGhB"}
|
package/dist/index.js
CHANGED
|
@@ -11,45 +11,54 @@ export { IfcLiteMeshCollector } from './ifc-lite-mesh-collector.js';
|
|
|
11
11
|
// Support components
|
|
12
12
|
export { BufferBuilder } from './buffer-builder.js';
|
|
13
13
|
export { CoordinateHandler } from './coordinate-handler.js';
|
|
14
|
-
export { WorkerPool } from './worker-pool.js';
|
|
15
14
|
export { GeometryQuality } from './progressive-loader.js';
|
|
16
15
|
export { LODGenerator } from './lod.js';
|
|
17
16
|
export { deduplicateMeshes, getDeduplicationStats } from './geometry-deduplicator.js';
|
|
18
17
|
export * from './types.js';
|
|
19
18
|
export * from './default-materials.js';
|
|
19
|
+
// Zero-copy GPU upload (new - faster, less memory)
|
|
20
|
+
export { WasmMemoryManager } from './wasm-memory-manager.js';
|
|
21
|
+
export { ZeroCopyMeshCollector, ZeroCopyInstancedCollector, } from './zero-copy-collector.js';
|
|
20
22
|
// Legacy exports for compatibility (deprecated)
|
|
21
23
|
export { IfcLiteBridge as WebIfcBridge } from './ifc-lite-bridge.js';
|
|
22
24
|
import { IfcLiteBridge } from './ifc-lite-bridge.js';
|
|
23
25
|
import { IfcLiteMeshCollector } from './ifc-lite-mesh-collector.js';
|
|
24
26
|
import { BufferBuilder } from './buffer-builder.js';
|
|
25
27
|
import { CoordinateHandler } from './coordinate-handler.js';
|
|
26
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Calculate dynamic batch size based on batch number
|
|
30
|
+
*/
|
|
31
|
+
export function calculateDynamicBatchSize(batchNumber, initialBatchSize = 50, maxBatchSize = 500) {
|
|
32
|
+
if (batchNumber <= 3) {
|
|
33
|
+
return initialBatchSize; // Fast first frame
|
|
34
|
+
}
|
|
35
|
+
else if (batchNumber <= 6) {
|
|
36
|
+
return Math.floor((initialBatchSize + maxBatchSize) / 2); // Quick ramp
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
return maxBatchSize; // Full throughput earlier
|
|
40
|
+
}
|
|
41
|
+
}
|
|
27
42
|
export class GeometryProcessor {
|
|
28
43
|
bridge;
|
|
29
44
|
bufferBuilder;
|
|
30
45
|
coordinateHandler;
|
|
31
|
-
workerPool = null;
|
|
32
|
-
useWorkers = false;
|
|
33
46
|
constructor(options = {}) {
|
|
34
47
|
this.bridge = new IfcLiteBridge();
|
|
35
48
|
this.bufferBuilder = new BufferBuilder();
|
|
36
49
|
this.coordinateHandler = new CoordinateHandler();
|
|
37
|
-
|
|
38
|
-
// Note: quality option is accepted for API compatibility but IFC-Lite always processes at full quality
|
|
50
|
+
// Note: options accepted for API compatibility
|
|
39
51
|
void options.quality;
|
|
40
52
|
}
|
|
41
53
|
/**
|
|
42
|
-
* Initialize IFC-Lite WASM
|
|
54
|
+
* Initialize IFC-Lite WASM
|
|
43
55
|
* WASM is automatically resolved from the package location - no path needed
|
|
44
56
|
*/
|
|
45
57
|
async init(_wasmPath) {
|
|
46
58
|
await this.bridge.init();
|
|
47
|
-
// Initialize worker pool if available (lazy - only when needed)
|
|
48
|
-
// Don't initialize workers upfront to avoid overhead
|
|
49
|
-
// Workers will be initialized on first use if needed
|
|
50
59
|
}
|
|
51
60
|
/**
|
|
52
|
-
* Process IFC file and extract geometry
|
|
61
|
+
* Process IFC file and extract geometry (synchronous, use processStreaming for large files)
|
|
53
62
|
* @param buffer IFC file buffer
|
|
54
63
|
* @param entityIndex Optional entity index for priority-based loading
|
|
55
64
|
*/
|
|
@@ -57,50 +66,10 @@ export class GeometryProcessor {
|
|
|
57
66
|
if (!this.bridge.isInitialized()) {
|
|
58
67
|
await this.init();
|
|
59
68
|
}
|
|
60
|
-
// entityIndex is used in collectMeshesMainThread for priority-based loading
|
|
61
69
|
void entityIndex;
|
|
62
|
-
|
|
63
|
-
//
|
|
64
|
-
|
|
65
|
-
if (this.useWorkers) {
|
|
66
|
-
// Try to use worker pool if available (lazy init)
|
|
67
|
-
if (!this.workerPool) {
|
|
68
|
-
try {
|
|
69
|
-
let workerUrl;
|
|
70
|
-
try {
|
|
71
|
-
workerUrl = new URL('./geometry.worker.ts', import.meta.url);
|
|
72
|
-
}
|
|
73
|
-
catch (e) {
|
|
74
|
-
workerUrl = './geometry.worker.ts';
|
|
75
|
-
}
|
|
76
|
-
this.workerPool = new WorkerPool(workerUrl, 1); // Use single worker for now
|
|
77
|
-
await this.workerPool.init();
|
|
78
|
-
}
|
|
79
|
-
catch (error) {
|
|
80
|
-
console.warn('[GeometryProcessor] Worker pool initialization failed, will use main thread:', error);
|
|
81
|
-
this.workerPool = null;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
if (this.workerPool?.isAvailable()) {
|
|
85
|
-
try {
|
|
86
|
-
meshes = await this.workerPool.submit('mesh-collection', {
|
|
87
|
-
buffer: buffer.buffer,
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
catch (error) {
|
|
91
|
-
console.warn('[Geometry] Worker pool failed, falling back to main thread:', error);
|
|
92
|
-
meshes = await this.collectMeshesMainThread(buffer);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
// Fallback to main thread
|
|
97
|
-
meshes = await this.collectMeshesMainThread(buffer);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
// Use main thread (faster for total time, but blocks UI)
|
|
102
|
-
meshes = await this.collectMeshesMainThread(buffer);
|
|
103
|
-
}
|
|
70
|
+
// Synchronous processing on main thread
|
|
71
|
+
// For large files, use processStreaming() instead which uses a dedicated worker
|
|
72
|
+
const meshes = await this.collectMeshesMainThread(buffer);
|
|
104
73
|
// const meshCollectionTime = performance.now() - meshCollectionStart;
|
|
105
74
|
// Handle large coordinates by shifting to origin
|
|
106
75
|
const coordinateInfo = this.coordinateHandler.processMeshes(meshes);
|
|
@@ -131,24 +100,43 @@ export class GeometryProcessor {
|
|
|
131
100
|
* Uses IFC-Lite for native Rust geometry processing (1.9x faster)
|
|
132
101
|
* @param buffer IFC file buffer
|
|
133
102
|
* @param entityIndex Optional entity index for priority-based loading
|
|
134
|
-
* @param
|
|
103
|
+
* @param batchConfig Dynamic batch configuration or fixed batch size
|
|
135
104
|
*/
|
|
136
|
-
async *processStreaming(buffer, _entityIndex,
|
|
137
|
-
) {
|
|
105
|
+
async *processStreaming(buffer, _entityIndex, batchConfig = 25) {
|
|
138
106
|
if (!this.bridge.isInitialized()) {
|
|
139
107
|
await this.init();
|
|
140
108
|
}
|
|
141
109
|
// Reset coordinate handler for new file
|
|
142
110
|
this.coordinateHandler.reset();
|
|
111
|
+
// Yield start event FIRST so UI can update before heavy processing
|
|
143
112
|
yield { type: 'start', totalEstimate: buffer.length / 1000 };
|
|
113
|
+
// Yield to main thread before heavy decode operation
|
|
114
|
+
await new Promise(resolve => setTimeout(resolve, 0));
|
|
144
115
|
// Convert buffer to string (IFC files are text)
|
|
116
|
+
// This is blocking but unavoidable - WASM API expects string
|
|
145
117
|
const decoder = new TextDecoder();
|
|
146
118
|
const content = decoder.decode(buffer);
|
|
147
119
|
// Use a placeholder model ID (IFC-Lite doesn't use model IDs)
|
|
148
120
|
yield { type: 'model-open', modelID: 0 };
|
|
149
121
|
const collector = new IfcLiteMeshCollector(this.bridge.getApi(), content);
|
|
150
122
|
let totalMeshes = 0;
|
|
151
|
-
|
|
123
|
+
// Determine optimal WASM batch size based on file size
|
|
124
|
+
// Larger batches = fewer callbacks = faster processing
|
|
125
|
+
const fileSizeMB = typeof batchConfig !== 'number' && batchConfig.fileSizeMB
|
|
126
|
+
? batchConfig.fileSizeMB
|
|
127
|
+
: buffer.length / (1024 * 1024);
|
|
128
|
+
// Use WASM batches directly - no JS accumulation layer
|
|
129
|
+
// WASM already prioritizes simple geometry (walls, slabs) for fast first frame
|
|
130
|
+
const wasmBatchSize = fileSizeMB < 10 ? 100 : fileSizeMB < 50 ? 200 : fileSizeMB < 100 ? 300 : 500;
|
|
131
|
+
// Use WASM batches directly for maximum throughput
|
|
132
|
+
for await (const item of collector.collectMeshesStreaming(wasmBatchSize)) {
|
|
133
|
+
// Handle color update events
|
|
134
|
+
if (item && typeof item === 'object' && 'type' in item && item.type === 'colorUpdate') {
|
|
135
|
+
yield { type: 'colorUpdate', updates: item.updates };
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
// Handle mesh batches
|
|
139
|
+
const batch = item;
|
|
152
140
|
// Process coordinate shifts incrementally (will accumulate bounds)
|
|
153
141
|
this.coordinateHandler.processMeshesIncremental(batch);
|
|
154
142
|
totalMeshes += batch.length;
|
|
@@ -234,7 +222,7 @@ export class GeometryProcessor {
|
|
|
234
222
|
*/
|
|
235
223
|
async *processAdaptive(buffer, options = {}) {
|
|
236
224
|
const sizeThreshold = options.sizeThreshold ?? 2 * 1024 * 1024; // Default 2MB
|
|
237
|
-
const
|
|
225
|
+
const batchConfig = options.batchSize ?? 25;
|
|
238
226
|
if (!this.bridge.isInitialized()) {
|
|
239
227
|
await this.init();
|
|
240
228
|
}
|
|
@@ -264,17 +252,23 @@ export class GeometryProcessor {
|
|
|
264
252
|
else {
|
|
265
253
|
// Large files: Stream for fast first frame
|
|
266
254
|
// processStreaming will emit its own start and model-open events
|
|
267
|
-
yield* this.processStreaming(buffer, options.entityIndex,
|
|
255
|
+
yield* this.processStreaming(buffer, options.entityIndex, batchConfig);
|
|
268
256
|
}
|
|
269
257
|
}
|
|
258
|
+
/**
|
|
259
|
+
* Get the WASM API instance for advanced operations (e.g., entity scanning)
|
|
260
|
+
*/
|
|
261
|
+
getApi() {
|
|
262
|
+
if (!this.bridge.isInitialized()) {
|
|
263
|
+
return null;
|
|
264
|
+
}
|
|
265
|
+
return this.bridge.getApi();
|
|
266
|
+
}
|
|
270
267
|
/**
|
|
271
268
|
* Cleanup resources
|
|
272
269
|
*/
|
|
273
270
|
dispose() {
|
|
274
|
-
|
|
275
|
-
this.workerPool.terminate();
|
|
276
|
-
this.workerPool = null;
|
|
277
|
-
}
|
|
271
|
+
// No cleanup needed
|
|
278
272
|
}
|
|
279
273
|
}
|
|
280
274
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D;;;GAGG;AAEH,6CAA6C;AAC7C,OA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B,cAAc,EAAE,IAAI,CAAC;IACrB,aAAa,EAAE,IAAI,CAAC;IACpB,eAAe,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,QAAQ,EAAE,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,cAAc,CAAC;CAChC"}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WASM Memory Manager - manages zero-copy views into WASM linear memory
|
|
3
|
+
*
|
|
4
|
+
* This module provides safe access to WASM memory for zero-copy GPU uploads.
|
|
5
|
+
* Views are created directly into WASM linear memory, avoiding data copies.
|
|
6
|
+
*
|
|
7
|
+
* IMPORTANT: Views become INVALID when WASM memory grows (any allocation).
|
|
8
|
+
* Use the "immediate upload" pattern:
|
|
9
|
+
* 1. Create view
|
|
10
|
+
* 2. Upload to GPU immediately
|
|
11
|
+
* 3. Discard view reference
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const manager = new WasmMemoryManager(api.getMemory());
|
|
16
|
+
*
|
|
17
|
+
* // SAFE: View created and used immediately
|
|
18
|
+
* const vertexView = manager.createFloat32View(ptr, len);
|
|
19
|
+
* device.queue.writeBuffer(gpuBuffer, 0, vertexView);
|
|
20
|
+
* // View may be invalid now, but we're done with it
|
|
21
|
+
*
|
|
22
|
+
* // UNSAFE: Don't store views across async boundaries!
|
|
23
|
+
* const view = manager.createFloat32View(ptr, len);
|
|
24
|
+
* await someAsyncOp(); // WASM could allocate here!
|
|
25
|
+
* // view might be INVALID now - use would crash!
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export interface WasmMemory {
|
|
29
|
+
buffer: ArrayBuffer;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Manages zero-copy TypedArray views into WASM linear memory
|
|
33
|
+
*/
|
|
34
|
+
export declare class WasmMemoryManager {
|
|
35
|
+
private memory;
|
|
36
|
+
private cachedBuffer;
|
|
37
|
+
constructor(memory: WasmMemory);
|
|
38
|
+
/**
|
|
39
|
+
* Get current memory buffer, detecting if it has changed (grown)
|
|
40
|
+
*/
|
|
41
|
+
private getBuffer;
|
|
42
|
+
/**
|
|
43
|
+
* Create a Float32Array view directly into WASM memory (NO COPY!)
|
|
44
|
+
*
|
|
45
|
+
* WARNING: View becomes invalid if WASM memory grows!
|
|
46
|
+
* Use immediately and discard.
|
|
47
|
+
*
|
|
48
|
+
* @param byteOffset Byte offset into WASM memory (ptr value from Rust)
|
|
49
|
+
* @param length Number of f32 elements (not bytes)
|
|
50
|
+
*/
|
|
51
|
+
createFloat32View(byteOffset: number, length: number): Float32Array;
|
|
52
|
+
/**
|
|
53
|
+
* Create a Uint32Array view directly into WASM memory (NO COPY!)
|
|
54
|
+
*
|
|
55
|
+
* @param byteOffset Byte offset into WASM memory
|
|
56
|
+
* @param length Number of u32 elements (not bytes)
|
|
57
|
+
*/
|
|
58
|
+
createUint32View(byteOffset: number, length: number): Uint32Array;
|
|
59
|
+
/**
|
|
60
|
+
* Create a Float64Array view directly into WASM memory (NO COPY!)
|
|
61
|
+
*
|
|
62
|
+
* @param byteOffset Byte offset into WASM memory
|
|
63
|
+
* @param length Number of f64 elements (not bytes)
|
|
64
|
+
*/
|
|
65
|
+
createFloat64View(byteOffset: number, length: number): Float64Array;
|
|
66
|
+
/**
|
|
67
|
+
* Create a Uint8Array view directly into WASM memory (NO COPY!)
|
|
68
|
+
*
|
|
69
|
+
* @param byteOffset Byte offset into WASM memory
|
|
70
|
+
* @param length Number of bytes
|
|
71
|
+
*/
|
|
72
|
+
createUint8View(byteOffset: number, length: number): Uint8Array;
|
|
73
|
+
/**
|
|
74
|
+
* Check if a view is still valid (memory hasn't grown)
|
|
75
|
+
*/
|
|
76
|
+
isViewValid(view: ArrayBufferView): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Get raw ArrayBuffer (for advanced use cases)
|
|
79
|
+
*/
|
|
80
|
+
getRawBuffer(): ArrayBuffer;
|
|
81
|
+
/**
|
|
82
|
+
* Check if memory has grown since last access
|
|
83
|
+
*/
|
|
84
|
+
hasMemoryGrown(): boolean;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* GPU-ready geometry data with pointer access
|
|
88
|
+
* Wraps the WASM GpuGeometry struct for TypeScript use
|
|
89
|
+
*/
|
|
90
|
+
export interface GpuGeometryHandle {
|
|
91
|
+
/** Pointer to interleaved vertex data [px,py,pz,nx,ny,nz,...] */
|
|
92
|
+
vertexDataPtr: number;
|
|
93
|
+
/** Length of vertex data in f32 elements */
|
|
94
|
+
vertexDataLen: number;
|
|
95
|
+
/** Byte length of vertex data (for GPU buffer creation) */
|
|
96
|
+
vertexDataByteLength: number;
|
|
97
|
+
/** Pointer to index data */
|
|
98
|
+
indicesPtr: number;
|
|
99
|
+
/** Length of indices in u32 elements */
|
|
100
|
+
indicesLen: number;
|
|
101
|
+
/** Byte length of indices */
|
|
102
|
+
indicesByteLength: number;
|
|
103
|
+
/** Number of meshes in this geometry batch */
|
|
104
|
+
meshCount: number;
|
|
105
|
+
/** Total vertex count */
|
|
106
|
+
totalVertexCount: number;
|
|
107
|
+
/** Total triangle count */
|
|
108
|
+
totalTriangleCount: number;
|
|
109
|
+
/** Check if geometry is empty */
|
|
110
|
+
isEmpty: boolean;
|
|
111
|
+
/** Get metadata for a specific mesh */
|
|
112
|
+
getMeshMetadata(index: number): GpuMeshMetadataHandle | undefined;
|
|
113
|
+
/** Free the geometry (allows WASM to reuse memory) */
|
|
114
|
+
free(): void;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Mesh metadata for draw calls and selection
|
|
118
|
+
*/
|
|
119
|
+
export interface GpuMeshMetadataHandle {
|
|
120
|
+
expressId: number;
|
|
121
|
+
ifcTypeIdx: number;
|
|
122
|
+
vertexOffset: number;
|
|
123
|
+
vertexCount: number;
|
|
124
|
+
indexOffset: number;
|
|
125
|
+
indexCount: number;
|
|
126
|
+
color: number[];
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* GPU-ready instanced geometry with pointer access
|
|
130
|
+
*/
|
|
131
|
+
export interface GpuInstancedGeometryHandle {
|
|
132
|
+
/** Geometry ID (hash for deduplication) */
|
|
133
|
+
geometryId: bigint;
|
|
134
|
+
/** Pointer to interleaved vertex data */
|
|
135
|
+
vertexDataPtr: number;
|
|
136
|
+
vertexDataLen: number;
|
|
137
|
+
vertexDataByteLength: number;
|
|
138
|
+
/** Pointer to index data */
|
|
139
|
+
indicesPtr: number;
|
|
140
|
+
indicesLen: number;
|
|
141
|
+
indicesByteLength: number;
|
|
142
|
+
/** Pointer to instance data [transform(16) + color(4)] per instance */
|
|
143
|
+
instanceDataPtr: number;
|
|
144
|
+
instanceDataLen: number;
|
|
145
|
+
instanceDataByteLength: number;
|
|
146
|
+
/** Pointer to express IDs for each instance */
|
|
147
|
+
instanceExpressIdsPtr: number;
|
|
148
|
+
instanceCount: number;
|
|
149
|
+
/** Vertex and triangle counts */
|
|
150
|
+
vertexCount: number;
|
|
151
|
+
triangleCount: number;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Collection of instanced geometries with pointer access
|
|
155
|
+
*/
|
|
156
|
+
export interface GpuInstancedGeometryCollectionHandle {
|
|
157
|
+
length: number;
|
|
158
|
+
get(index: number): GpuInstancedGeometryHandle | undefined;
|
|
159
|
+
getRef(index: number): GpuInstancedGeometryRefHandle | undefined;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Reference to instanced geometry (avoids cloning)
|
|
163
|
+
*/
|
|
164
|
+
export interface GpuInstancedGeometryRefHandle {
|
|
165
|
+
geometryId: bigint;
|
|
166
|
+
vertexDataPtr: number;
|
|
167
|
+
vertexDataLen: number;
|
|
168
|
+
vertexDataByteLength: number;
|
|
169
|
+
indicesPtr: number;
|
|
170
|
+
indicesLen: number;
|
|
171
|
+
indicesByteLength: number;
|
|
172
|
+
instanceDataPtr: number;
|
|
173
|
+
instanceDataLen: number;
|
|
174
|
+
instanceDataByteLength: number;
|
|
175
|
+
instanceExpressIdsPtr: number;
|
|
176
|
+
instanceCount: number;
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=wasm-memory-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wasm-memory-manager.d.ts","sourceRoot":"","sources":["../src/wasm-memory-manager.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,WAAW,CAAC;CACrB;AAED;;GAEG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,MAAM,CAAa;IAC3B,OAAO,CAAC,YAAY,CAA4B;gBAEpC,MAAM,EAAE,UAAU;IAI9B;;OAEG;IACH,OAAO,CAAC,SAAS;IASjB;;;;;;;;OAQG;IACH,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,YAAY;IAKnE;;;;;OAKG;IACH,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,WAAW;IAKjE;;;;;OAKG;IACH,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,YAAY;IAKnE;;;;;OAKG;IACH,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,UAAU;IAK/D;;OAEG;IACH,WAAW,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO;IAI3C;;OAEG;IACH,YAAY,IAAI,WAAW;IAI3B;;OAEG;IACH,cAAc,IAAI,OAAO;CAG1B;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,iEAAiE;IACjE,aAAa,EAAE,MAAM,CAAC;IACtB,4CAA4C;IAC5C,aAAa,EAAE,MAAM,CAAC;IACtB,2DAA2D;IAC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M,CAAC;IAEtB,iCAAiC;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,oCAAoC;IACnD,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,0BAA0B,GAAG,SAAS,CAAC;IAC3D,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,6BAA6B,GAAG,SAAS,CAAC;CAClE;AAED;;GAEG;AACH,MAAM,WAAW,6BAA6B;IAC5C,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,qBAAqB,EAAE,MAAM,CAAC;IAC9B,aAAa,EAAE,MAAM,CAAC;CACvB"}
|
|
@@ -0,0 +1,86 @@
|
|
|
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
|
+
* Manages zero-copy TypedArray views into WASM linear memory
|
|
6
|
+
*/
|
|
7
|
+
export class WasmMemoryManager {
|
|
8
|
+
memory;
|
|
9
|
+
cachedBuffer = null;
|
|
10
|
+
constructor(memory) {
|
|
11
|
+
this.memory = memory;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Get current memory buffer, detecting if it has changed (grown)
|
|
15
|
+
*/
|
|
16
|
+
getBuffer() {
|
|
17
|
+
const currentBuffer = this.memory.buffer;
|
|
18
|
+
if (this.cachedBuffer !== currentBuffer) {
|
|
19
|
+
// Memory has grown - all existing views are invalid!
|
|
20
|
+
this.cachedBuffer = currentBuffer;
|
|
21
|
+
}
|
|
22
|
+
return currentBuffer;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Create a Float32Array view directly into WASM memory (NO COPY!)
|
|
26
|
+
*
|
|
27
|
+
* WARNING: View becomes invalid if WASM memory grows!
|
|
28
|
+
* Use immediately and discard.
|
|
29
|
+
*
|
|
30
|
+
* @param byteOffset Byte offset into WASM memory (ptr value from Rust)
|
|
31
|
+
* @param length Number of f32 elements (not bytes)
|
|
32
|
+
*/
|
|
33
|
+
createFloat32View(byteOffset, length) {
|
|
34
|
+
const buffer = this.getBuffer();
|
|
35
|
+
return new Float32Array(buffer, byteOffset, length);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Create a Uint32Array view directly into WASM memory (NO COPY!)
|
|
39
|
+
*
|
|
40
|
+
* @param byteOffset Byte offset into WASM memory
|
|
41
|
+
* @param length Number of u32 elements (not bytes)
|
|
42
|
+
*/
|
|
43
|
+
createUint32View(byteOffset, length) {
|
|
44
|
+
const buffer = this.getBuffer();
|
|
45
|
+
return new Uint32Array(buffer, byteOffset, length);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Create a Float64Array view directly into WASM memory (NO COPY!)
|
|
49
|
+
*
|
|
50
|
+
* @param byteOffset Byte offset into WASM memory
|
|
51
|
+
* @param length Number of f64 elements (not bytes)
|
|
52
|
+
*/
|
|
53
|
+
createFloat64View(byteOffset, length) {
|
|
54
|
+
const buffer = this.getBuffer();
|
|
55
|
+
return new Float64Array(buffer, byteOffset, length);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Create a Uint8Array view directly into WASM memory (NO COPY!)
|
|
59
|
+
*
|
|
60
|
+
* @param byteOffset Byte offset into WASM memory
|
|
61
|
+
* @param length Number of bytes
|
|
62
|
+
*/
|
|
63
|
+
createUint8View(byteOffset, length) {
|
|
64
|
+
const buffer = this.getBuffer();
|
|
65
|
+
return new Uint8Array(buffer, byteOffset, length);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Check if a view is still valid (memory hasn't grown)
|
|
69
|
+
*/
|
|
70
|
+
isViewValid(view) {
|
|
71
|
+
return view.buffer === this.memory.buffer;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Get raw ArrayBuffer (for advanced use cases)
|
|
75
|
+
*/
|
|
76
|
+
getRawBuffer() {
|
|
77
|
+
return this.getBuffer();
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Check if memory has grown since last access
|
|
81
|
+
*/
|
|
82
|
+
hasMemoryGrown() {
|
|
83
|
+
return this.cachedBuffer !== null && this.cachedBuffer !== this.memory.buffer;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=wasm-memory-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wasm-memory-manager.js","sourceRoot":"","sources":["../src/wasm-memory-manager.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAkC/D;;GAEG;AACH,MAAM,OAAO,iBAAiB;IACpB,MAAM,CAAa;IACnB,YAAY,GAAuB,IAAI,CAAC;IAEhD,YAAY,MAAkB;QAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;OAEG;IACK,SAAS;QACf,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;QACzC,IAAI,IAAI,CAAC,YAAY,KAAK,aAAa,EAAE,CAAC;YACxC,qDAAqD;YACrD,IAAI,CAAC,YAAY,GAAG,aAAa,CAAC;QACpC,CAAC;QACD,OAAO,aAAa,CAAC;IACvB,CAAC;IAED;;;;;;;;OAQG;IACH,iBAAiB,CAAC,UAAkB,EAAE,MAAc;QAClD,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QAChC,OAAO,IA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