@speridlabs/visus 1.0.2 → 1.0.4

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/dist/main.d.ts CHANGED
@@ -1,320 +1,328 @@
1
- import * as THREE from 'three';
2
-
3
- /**
4
- * Simplified bounding box class that tracks min/max points
5
- */
6
- export declare class BoundingBox {
7
- min: THREE.Vector3;
8
- max: THREE.Vector3;
9
- center: THREE.Vector3;
10
- /** Half extents (size/2) */
11
- halfExtents: THREE.Vector3;
12
- /**
13
- * Reset the bounding box to its initial state
14
- */
15
- reset(): void;
16
- /**
17
- * Expand the bounding box to include the given point
18
- * @param point Point to include in the bounding box
19
- */
20
- expandByPoint(point: THREE.Vector3): void;
21
- /**
22
- * Expand this bounding box to include another bounding box
23
- * @param box Bounding box to include
24
- */
25
- expandByBox(box: BoundingBox): void;
26
- /**
27
- * Update the center and half extents based on min/max
28
- */
29
- private updateDerived;
30
- /**
31
- * Check if this box contains a point
32
- * @param point Point to check
33
- * @returns True if the point is inside the box
34
- */
35
- containsPoint(point: THREE.Vector3): boolean;
36
- /**
37
- * Create a Three.js Box3 from this bounding box
38
- * @returns THREE.Box3 representation
39
- */
40
- toBox3(): THREE.Box3;
41
- /**
42
- * Create a clone of this bounding box
43
- * @returns New bounding box with the same values
44
- */
45
- clone(): BoundingBox;
46
- }
47
-
48
- /**
49
- * Class for loading PLY files with Gaussian Splat data
50
- */
51
- export declare class PlyLoader extends THREE.Loader {
52
- /**
53
- * Load a PLY file with Gaussian Splat data
54
- * @param url URL of the PLY file
55
- * @param onLoad Optional callback when loading is complete
56
- * @param onProgress Optional progress callback
57
- * @param onError Optional error callback
58
- */
59
- load(url: string, onLoad?: (data: SplatData) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void;
60
- /**
61
- * Load a PLY file asynchronously and return a Promise
62
- * @param url URL of the PLY file
63
- * @param onProgress Optional progress callback
64
- * @returns A Promise that resolves with the parsed SplatData
65
- */
66
- loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise<SplatData>;
67
- /**
68
- * Parse PLY buffer data into SplatData
69
- * @param buffer ArrayBuffer containing PLY data
70
- * @returns Parsed SplatData
71
- */
72
- parse(buffer: ArrayBuffer): SplatData;
73
- }
74
-
75
- export declare class SplatData {
76
- numSplats: number;
77
- positions: Float32Array;
78
- rotations: Float32Array;
79
- scales: Float32Array;
80
- colors: Float32Array;
81
- opacities: Float32Array;
82
- centers: Float32Array;
83
- boundingBox: BoundingBox;
84
- constructor(numSplats?: number);
85
- private allocateBuffers;
86
- /**
87
- * Set data for a specific splat
88
- * @param index Splat index
89
- * @param position Position vector
90
- * @param rotation Quaternion
91
- * @param scale Scale vector (expects LOG SCALE)
92
- * @param color Color
93
- * @param opacity Opacity value
94
- */
95
- setSplat(index: number, position: THREE.Vector3, rotation: THREE.Quaternion, scale: THREE.Vector3, color: THREE.Color, opacity: number): void;
96
- /**
97
- * Get a splat's data
98
- * @param index Splat index
99
- * @returns Object containing splat data (linear scale)
100
- */
101
- getSplat(index: number): {
102
- position: THREE.Vector3;
103
- rotation: THREE.Quaternion;
104
- scale: THREE.Vector3;
105
- color: THREE.Color;
106
- opacity: number;
107
- };
108
- /**
109
- * Calculate the bounding box for all splats
110
- * NOTE: Currently it only uses positions, not the actual splat bounds
111
- */
112
- calculateBoundingBox(): BoundingBox;
113
- /**
114
- * Create a Three.js BufferGeometry from this splat data
115
- * This is for visualization/debugging purposes only, not for rendering
116
- */
117
- createDebugGeometry(): THREE.BufferGeometry;
118
- }
119
-
120
- export declare class SplatMaterial extends THREE.ShaderMaterial {
121
- constructor(options?: SplatMaterialOptions);
122
- /**
123
- * Update the viewport size
124
- * @param width Viewport width
125
- * @param height Viewport height
126
- */
127
- updateViewport(width: number, height: number): void;
128
- /**
129
- * Set transform texture A (positions)
130
- * @param texture Texture containing positions
131
- */
132
- setTransformA(texture: THREE.Texture): void;
133
- /**
134
- * Set transform texture B (rotation, scale)
135
- * @param texture Texture containing rotation and scale data
136
- */
137
- setTransformB(texture: THREE.Texture): void;
138
- /**
139
- * Set color texture
140
- * @param texture Texture containing colors
141
- */
142
- setColorTexture(texture: THREE.Texture): void;
143
- /**
144
- * Set order texture
145
- * @param texture Texture containing sort order
146
- */
147
- setOrderTexture(texture: THREE.Texture): void;
148
- /**
149
- * Set number of splats to render
150
- * @param count Number of splats
151
- */
152
- setNumSplats(count: number): void;
153
- }
154
-
155
- export declare interface SplatMaterialOptions {
156
- alphaTest?: number;
157
- alphaHash?: boolean;
158
- toneMapped?: boolean;
159
- }
160
-
161
- /**
162
- * A mesh that renders Gaussian splats
163
- * Not a real MESH, but a custom geometry with instancing
164
- */
165
- export declare class SplatMesh extends THREE.Mesh {
166
- sorter: SplatSorter;
167
- splatData: SplatData;
168
- options: SplatMeshOptions;
169
- textureManager: TextureManager;
170
- material: SplatMaterial;
171
- geometry: THREE.InstancedBufferGeometry;
172
- private lastCameraPositionLocal;
173
- private lastCameraDirectionLocal;
174
- private invModelMatrix;
175
- /** Number of splats combined into a single instanced draw call. */
176
- private static INSTANCE_SIZE;
177
- /**
178
- * Create a new SplatMesh for rendering Gaussian splats
179
- * @param splatData The splat data to render
180
- * @param options Rendering options
181
- */
182
- constructor(splatData: SplatData, options?: SplatMeshOptions);
183
- /**
184
- * Creates the instanced geometry for rendering splats.
185
- * @param totalSplats Total number of splats in the data.
186
- * @param instanceSize Number of splats per instance.
187
- * @returns InstancedBufferGeometry
188
- */
189
- private static createInstancedGeometry;
190
- /**
191
- * Create chunks data (bounding box min/max) for the sorter.
192
- * @returns Float32Array containing chunk data [minX, minY, minZ, maxX, maxY, maxZ] or null.
193
- */
194
- private createChunks;
195
- /**
196
- * Update the viewport size
197
- * @param width Viewport width
198
- * @param height Viewport height
199
- */
200
- updateViewport(width: number, height: number): void;
201
- /**
202
- * Sorts splats based on camera position and direction.
203
- * @param camera The camera to sort against.
204
- */
205
- sort(camera: THREE.Camera): void;
206
- /**
207
- * THREE.js hook called before rendering the object.
208
- * Used here to trigger sorting and update viewport.
209
- * @param renderer The renderer
210
- * @param scene The scene
211
- * @param camera The camera
212
- */
213
- onBeforeRender(renderer: THREE.WebGLRenderer, scene: THREE.Scene, camera: THREE.Camera): void;
214
- /**
215
- * Dispose of resources
216
- */
217
- dispose(): void;
218
- }
219
-
220
- export declare interface SplatMeshOptions extends SplatMaterialOptions {
221
- autoSort?: boolean;
222
- }
223
-
224
- /**
225
- * Manages sorting of splats based on camera view using a Web Worker.
226
- */
227
- export declare class SplatSorter extends THREE.EventDispatcher<{
228
- updated: SplatSortUpdateEvent;
229
- }> {
230
- private worker;
231
- private centers;
232
- private orderTexture;
233
- /** Bounding box data for optimization */
234
- private chunks;
235
- private lastCameraPosition;
236
- private lastCameraDirection;
237
- constructor();
238
- /**
239
- * Handles messages received from the sorting worker.
240
- * @param event The message event from the worker.
241
- */
242
- private onWorkerMessage;
243
- /**
244
- * Initializes the sorter with necessary data and textures.
245
- * @param orderTexture The THREE.DataTexture (R32UI) to store the sorted splat indices.
246
- * @param centers A Float32Array containing the center position (x, y, z) for each splat.
247
- * @param chunks Optional: A Float32Array containing bounding box chunk data [minX, minY, minZ, maxX, maxY, maxZ, ...] for optimization.
248
- */
249
- init(orderTexture: THREE.DataTexture, centers: Float32Array, chunks?: Float32Array): void;
250
- /**
251
- * Applies an optional mapping to filter or reorder splats before sorting.
252
- * The sorter will only consider splats whose original indices are present in the mapping.
253
- * @param mapping A Uint32Array where each element is the *original* index of a splat to include, or null to reset mapping.
254
- */
255
- setMapping(mapping: Uint32Array | null): void;
256
- /**
257
- * Updates the camera parameters used for sorting.
258
- * @param position The camera's position in the sorter's local coordinate space.
259
- * @param direction The camera's forward direction in the sorter's local coordinate space.
260
- */
261
- setCamera(position: THREE.Vector3, direction: THREE.Vector3): void;
262
- /**
263
- * Terminates the Web Worker and cleans up resources.
264
- */
265
- dispose(): void;
266
- /**
267
- * Creates the self-contained code for the sorting Web Worker.
268
- * @returns A string containing the JavaScript code for the worker.
269
- */
270
- private createWorkerCode;
271
- }
272
-
273
- /** Event dispatched when the sort is updated */
274
- declare interface SplatSortUpdateEvent extends THREE.Event {
275
- type: 'updated';
276
- count: number;
277
- }
278
-
279
- export declare class TextureManager {
280
- transformA: THREE.DataTexture;
281
- transformB: THREE.DataTexture;
282
- colorTexture: THREE.DataTexture;
283
- orderTexture: THREE.DataTexture;
284
- textureWidth: number;
285
- textureHeight: number;
286
- /**
287
- * Create a new TextureManager for a set of splats
288
- * @param splatData The splat data to manage textures for
289
- */
290
- constructor(splatData: SplatData);
291
- /**
292
- * Create the transform A texture (positions and quaternion w component)
293
- * @param splatData The splat data
294
- * @returns DataTexture containing position data
295
- */
296
- private createTransformATexture;
297
- /**
298
- * Create the transform B texture (scale and rotation xyz)
299
- * @param splatData The splat data
300
- * @returns DataTexture containing scale and rotation data
301
- */
302
- private createTransformBTexture;
303
- /**
304
- * Create the color texture (RGB and opacity)
305
- * @param splatData The splat data
306
- * @returns DataTexture containing color data
307
- */
308
- private createColorTexture;
309
- /**
310
- * Create the order texture for sorting
311
- * @param numSplats Number of splats
312
- * @returns DataTexture for storing order indices
313
- */
314
- private createOrderTexture;
315
- dispose(): void;
316
- }
317
-
318
- export declare const VERSION = "0.3.0";
319
-
320
- export { }
1
+ import * as THREE from 'three';
2
+
3
+ /**
4
+ * Simplified bounding box class that tracks min/max points
5
+ */
6
+ export declare class BoundingBox {
7
+ min: THREE.Vector3;
8
+ max: THREE.Vector3;
9
+ center: THREE.Vector3;
10
+ /** Half extents (size/2) */
11
+ halfExtents: THREE.Vector3;
12
+ /**
13
+ * Reset the bounding box to its initial state
14
+ */
15
+ reset(): void;
16
+ /**
17
+ * Expand the bounding box to include the given point
18
+ * @param point Point to include in the bounding box
19
+ */
20
+ expandByPoint(point: THREE.Vector3): void;
21
+ /**
22
+ * Expand this bounding box to include another bounding box
23
+ * @param box Bounding box to include
24
+ */
25
+ expandByBox(box: BoundingBox): void;
26
+ /**
27
+ * Update the center and half extents based on min/max
28
+ */
29
+ private updateDerived;
30
+ /**
31
+ * Check if this box contains a point
32
+ * @param point Point to check
33
+ * @returns True if the point is inside the box
34
+ */
35
+ containsPoint(point: THREE.Vector3): boolean;
36
+ /**
37
+ * Create a Three.js Box3 from this bounding box
38
+ * @returns THREE.Box3 representation
39
+ */
40
+ toBox3(): THREE.Box3;
41
+ /**
42
+ * Create a clone of this bounding box
43
+ * @returns New bounding box with the same values
44
+ */
45
+ clone(): BoundingBox;
46
+ }
47
+
48
+ /**
49
+ * Class for loading PLY files with Gaussian Splat data
50
+ */
51
+ export declare class PlyLoader extends THREE.Loader {
52
+ /**
53
+ * Load a PLY file with Gaussian Splat data
54
+ * @param url URL of the PLY file
55
+ * @param onLoad Optional callback when loading is complete
56
+ * @param onProgress Optional progress callback
57
+ * @param onError Optional error callback
58
+ */
59
+ load(url: string, onLoad?: (data: SplatData) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void;
60
+ /**
61
+ * Load a PLY file asynchronously and return a Promise
62
+ * @param url URL of the PLY file
63
+ * @param onProgress Optional progress callback
64
+ * @returns A Promise that resolves with the parsed SplatData
65
+ */
66
+ loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise<SplatData>;
67
+ /**
68
+ * Parse PLY buffer data into SplatData
69
+ * @param buffer ArrayBuffer containing PLY data
70
+ * @returns Parsed SplatData
71
+ */
72
+ parse(buffer: ArrayBuffer): SplatData;
73
+ }
74
+
75
+ export declare class SplatData {
76
+ numSplats: number;
77
+ positions: Float32Array;
78
+ rotations: Float32Array;
79
+ scales: Float32Array;
80
+ colors: Float32Array;
81
+ opacities: Float32Array;
82
+ centers: Float32Array;
83
+ boundingBox: BoundingBox;
84
+ constructor(numSplats?: number);
85
+ private allocateBuffers;
86
+ /**
87
+ * Set data for a specific splat
88
+ * @param index Splat index
89
+ * @param position Position vector
90
+ * @param rotation Quaternion
91
+ * @param scale Scale vector (expects LOG SCALE)
92
+ * @param color Color
93
+ * @param opacity Opacity value
94
+ */
95
+ setSplat(index: number, position: THREE.Vector3, rotation: THREE.Quaternion, scale: THREE.Vector3, color: THREE.Color, opacity: number): void;
96
+ /**
97
+ * Get a splat's data
98
+ * @param index Splat index
99
+ * @returns Object containing splat data (linear scale)
100
+ */
101
+ getSplat(index: number): {
102
+ position: THREE.Vector3;
103
+ rotation: THREE.Quaternion;
104
+ scale: THREE.Vector3;
105
+ color: THREE.Color;
106
+ opacity: number;
107
+ };
108
+ /**
109
+ * Calculate the bounding box for all splats
110
+ * NOTE: Currently it only uses positions, not the actual splat bounds
111
+ */
112
+ calculateBoundingBox(): BoundingBox;
113
+ /**
114
+ * Create a Three.js BufferGeometry from this splat data
115
+ * This is for visualization/debugging purposes only, not for rendering
116
+ */
117
+ createDebugGeometry(): THREE.BufferGeometry;
118
+ }
119
+
120
+ export declare class SplatMaterial extends THREE.ShaderMaterial {
121
+ constructor(options?: SplatMaterialOptions);
122
+ /**
123
+ * Update the viewport size
124
+ * @param width Viewport width
125
+ * @param height Viewport height
126
+ */
127
+ updateViewport(width: number, height: number): void;
128
+ /**
129
+ * Set transform texture A (positions)
130
+ * @param texture Texture containing positions
131
+ */
132
+ setTransformA(texture: THREE.Texture): void;
133
+ /**
134
+ * Set transform texture B (rotation, scale)
135
+ * @param texture Texture containing rotation and scale data
136
+ */
137
+ setTransformB(texture: THREE.Texture): void;
138
+ /**
139
+ * Set color texture
140
+ * @param texture Texture containing colors
141
+ */
142
+ setColorTexture(texture: THREE.Texture): void;
143
+ /**
144
+ * Set order texture
145
+ * @param texture Texture containing sort order
146
+ */
147
+ setOrderTexture(texture: THREE.Texture): void;
148
+ /**
149
+ * Set number of splats to render
150
+ * @param count Number of splats
151
+ */
152
+ setNumSplats(count: number): void;
153
+ }
154
+
155
+ export declare interface SplatMaterialOptions {
156
+ alphaTest?: number;
157
+ alphaHash?: boolean;
158
+ toneMapped?: boolean;
159
+ }
160
+
161
+ /**
162
+ * A mesh that renders Gaussian splats
163
+ * Not a real MESH, but a custom geometry with instancing
164
+ */
165
+ export declare class SplatMesh extends THREE.Mesh {
166
+ sorter: SplatSorter;
167
+ splatData: SplatData;
168
+ options: SplatMeshOptions;
169
+ textureManager: TextureManager;
170
+ material: SplatMaterial;
171
+ geometry: THREE.InstancedBufferGeometry;
172
+ private lastCameraPositionLocal;
173
+ private lastCameraDirectionLocal;
174
+ private invModelMatrix;
175
+ private _vpW;
176
+ private _vpH;
177
+ private _size;
178
+ private _camPosW;
179
+ private _camDirW;
180
+ private _camPosL;
181
+ private _camDirL;
182
+ /** Number of splats combined into a single instanced draw call. */
183
+ private static INSTANCE_SIZE;
184
+ /**
185
+ * Create a new SplatMesh for rendering Gaussian splats
186
+ * @param splatData The splat data to render
187
+ * @param options Rendering options
188
+ */
189
+ constructor(splatData: SplatData, options?: SplatMeshOptions);
190
+ private onSorterUpdated;
191
+ /**
192
+ * Creates the instanced geometry for rendering splats.
193
+ * @param totalSplats Total number of splats in the data.
194
+ * @param instanceSize Number of splats per instance.
195
+ * @returns InstancedBufferGeometry
196
+ */
197
+ private static createInstancedGeometry;
198
+ /**
199
+ * Create chunks data (bounding box min/max) for the sorter.
200
+ * @returns Float32Array containing chunk data [minX, minY, minZ, maxX, maxY, maxZ] or null.
201
+ */
202
+ private createChunks;
203
+ /**
204
+ * Update the viewport size
205
+ * @param width Viewport width
206
+ * @param height Viewport height
207
+ */
208
+ updateViewport(width: number, height: number): void;
209
+ /**
210
+ * Sorts splats based on camera position and direction.
211
+ * @param camera The camera to sort against.
212
+ */
213
+ sort(camera: THREE.Camera): void;
214
+ /**
215
+ * THREE.js hook called before rendering the object.
216
+ * Used here to trigger sorting and update viewport.
217
+ * @param renderer The renderer
218
+ * @param scene The scene
219
+ * @param camera The camera
220
+ */
221
+ onBeforeRender(renderer: THREE.WebGLRenderer, scene: THREE.Scene, camera: THREE.Camera): void;
222
+ /**
223
+ * Dispose of resources
224
+ */
225
+ dispose(): void;
226
+ }
227
+
228
+ export declare interface SplatMeshOptions extends SplatMaterialOptions {
229
+ autoSort?: boolean;
230
+ }
231
+
232
+ /**
233
+ * Manages sorting of splats based on camera view using a Web Worker.
234
+ */
235
+ export declare class SplatSorter extends THREE.EventDispatcher<{
236
+ updated: SplatSortUpdateEvent;
237
+ }> {
238
+ private worker;
239
+ private centers;
240
+ private orderTexture;
241
+ /** Bounding box data for optimization */
242
+ private chunks;
243
+ private lastCameraPosition;
244
+ private lastCameraDirection;
245
+ constructor();
246
+ /**
247
+ * Handles messages received from the sorting worker.
248
+ * @param event The message event from the worker.
249
+ */
250
+ private onWorkerMessage;
251
+ /**
252
+ * Initializes the sorter with necessary data and textures.
253
+ * @param orderTexture The THREE.DataTexture (R32UI) to store the sorted splat indices.
254
+ * @param centers A Float32Array containing the center position (x, y, z) for each splat.
255
+ * @param chunks Optional: A Float32Array containing bounding box chunk data [minX, minY, minZ, maxX, maxY, maxZ, ...] for optimization.
256
+ */
257
+ init(orderTexture: THREE.DataTexture, centers: Float32Array, chunks?: Float32Array): void;
258
+ /**
259
+ * Applies an optional mapping to filter or reorder splats before sorting.
260
+ * The sorter will only consider splats whose original indices are present in the mapping.
261
+ * @param mapping A Uint32Array where each element is the *original* index of a splat to include, or null to reset mapping.
262
+ */
263
+ setMapping(mapping: Uint32Array | null): void;
264
+ /**
265
+ * Updates the camera parameters used for sorting.
266
+ * @param position The camera's position in the sorter's local coordinate space.
267
+ * @param direction The camera's forward direction in the sorter's local coordinate space.
268
+ */
269
+ setCamera(position: THREE.Vector3, direction: THREE.Vector3): void;
270
+ /**
271
+ * Terminates the Web Worker and cleans up resources.
272
+ */
273
+ dispose(): void;
274
+ /**
275
+ * Creates the self-contained code for the sorting Web Worker.
276
+ * @returns A string containing the JavaScript code for the worker.
277
+ */
278
+ private createWorkerCode;
279
+ }
280
+
281
+ /** Event dispatched when the sort is updated */
282
+ declare interface SplatSortUpdateEvent extends THREE.Event {
283
+ type: 'updated';
284
+ count: number;
285
+ }
286
+
287
+ export declare class TextureManager {
288
+ transformA: THREE.DataTexture;
289
+ transformB: THREE.DataTexture;
290
+ colorTexture: THREE.DataTexture;
291
+ orderTexture: THREE.DataTexture;
292
+ textureWidth: number;
293
+ textureHeight: number;
294
+ /**
295
+ * Create a new TextureManager for a set of splats
296
+ * @param splatData The splat data to manage textures for
297
+ */
298
+ constructor(splatData: SplatData);
299
+ /**
300
+ * Create the transform A texture (positions and quaternion w component)
301
+ * @param splatData The splat data
302
+ * @returns DataTexture containing position data
303
+ */
304
+ private createTransformATexture;
305
+ /**
306
+ * Create the transform B texture (scale and rotation xyz)
307
+ * @param splatData The splat data
308
+ * @returns DataTexture containing scale and rotation data
309
+ */
310
+ private createTransformBTexture;
311
+ /**
312
+ * Create the color texture (RGB and opacity)
313
+ * @param splatData The splat data
314
+ * @returns DataTexture containing color data
315
+ */
316
+ private createColorTexture;
317
+ /**
318
+ * Create the order texture for sorting
319
+ * @param numSplats Number of splats
320
+ * @returns DataTexture for storing order indices
321
+ */
322
+ private createOrderTexture;
323
+ dispose(): void;
324
+ }
325
+
326
+ export declare const VERSION = "0.3.0";
327
+
328
+ export { }