@speridlabs/visus 2.4.3 → 2.5.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/dist/main.d.ts CHANGED
@@ -1,344 +1,454 @@
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
- private requestId;
53
- private worker;
54
- private pendingCallbacks;
55
- constructor(manager?: THREE.LoadingManager, options?: PlyLoaderOptions);
56
- /**
57
- * Handles messages received from the parsing worker
58
- * @param event The message event from the worker
59
- */
60
- private onWorkerMessage;
61
- /**
62
- * Load a PLY file with Gaussian Splat data
63
- * @param url URL of the PLY file
64
- * @param onLoad Optional callback when loading is complete
65
- * @param onProgress Optional progress callback
66
- * @param onError Optional error callback
67
- */
68
- load(url: string, onLoad?: (data: SplatData) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void;
69
- /**
70
- * Load a PLY file asynchronously and return a Promise
71
- * @param url URL of the PLY file
72
- * @param onProgress Optional progress callback
73
- * @returns A Promise that resolves with the parsed SplatData
74
- */
75
- loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise<SplatData>;
76
- /**
77
- * Parse PLY buffer data asynchronously using Web Worker
78
- * @param buffer ArrayBuffer containing PLY data
79
- * @returns Promise that resolves with parsed SplatData
80
- */
81
- private parseAsync;
82
- /**
83
- * Terminate the Web Worker and clean up resources
84
- */
85
- dispose(): void;
86
- /**
87
- * Creates the self-contained code for the parsing Web Worker
88
- * @returns A string containing the JavaScript code for the worker
89
- */
90
- private createWorkerCode;
91
- }
92
-
93
- export declare interface PlyLoaderOptions {
94
- withCredentials?: boolean;
95
- }
96
-
97
- /**
98
- * Class for loading SOGS (Self Organizing Gaussians) files
99
- */
100
- export declare class SogsLoader extends THREE.Loader {
101
- constructor(manager?: THREE.LoadingManager, options?: SogsLoaderOptions);
102
- /**
103
- * Detect if a buffer is a ZIP file by checking magic bytes
104
- * ZIP files start with signature: PK\x03\x04 (0x50 0x4B 0x03 0x04)
105
- */
106
- private isZipBuffer;
107
- /**
108
- * Load a SOGS file (meta.json + textures)
109
- * @param url URL of the meta.json file
110
- * @param onLoad Optional callback when loading is complete
111
- * @param onProgress Optional progress callback
112
- * @param onError Optional error callback
113
- */
114
- load(url: string, onLoad?: (data: SplatData) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void;
115
- /**
116
- * Load a SOGS file asynchronously and return a Promise
117
- * @param url URL of the meta.json file
118
- * @param onProgress Optional progress callback
119
- * @returns A Promise that resolves with the parsed SplatData
120
- */
121
- loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise<SplatData>;
122
- private parseAsync;
123
- private parseMetaAsync;
124
- private parseZipAsync;
125
- }
126
-
127
- export declare interface SogsLoaderOptions {
128
- withCredentials?: boolean;
129
- }
130
-
131
- export declare class SplatData {
132
- numSplats: number;
133
- textureWidth: number;
134
- textureHeight: number;
135
- ranges: SplatRanges;
136
- centers: Float32Array;
137
- boundingBox: BoundingBox;
138
- packedColor: Uint8Array;
139
- packedGeometry: Uint32Array;
140
- constructor(numSplats: number, textureWidth: number, textureHeight: number, centers: Float32Array, packedGeometry: Uint32Array, packedColor: Uint8Array, ranges: SplatRanges, boundingBox: BoundingBox);
141
- /**
142
- * Optional: Reconstruct a full JS object for a specific splat.
143
- * Useful for raycasting or debugging.
144
- */
145
- dispose(): void;
146
- }
147
-
148
- export declare class SplatMaterial extends THREE.ShaderMaterial {
149
- constructor(options?: SplatMaterialOptions);
150
- setTexWidth(w: number): void;
151
- /**
152
- * Update the viewport size
153
- * @param width Viewport width
154
- * @param height Viewport height
155
- */
156
- updateViewport(width: number, height: number): void;
157
- /**
158
- * Set the main packed geometry texture (RGBA32UI)
159
- */
160
- setPackedGeometry(texture: THREE.Texture): void;
161
- /**
162
- * Set the packed color texture (RGBA8)
163
- */
164
- setPackedColor(texture: THREE.Texture): void;
165
- /**
166
- * Set order texture for sorting
167
- */
168
- setOrderTexture(texture: THREE.Texture): void;
169
- /**
170
- * Set the ranges needed to decompress the packed floats
171
- */
172
- setRanges(ranges: SplatRanges): void;
173
- /**
174
- * Set number of splats to render
175
- * @param count Number of splats
176
- */
177
- setNumSplats(count: number): void;
178
- }
179
-
180
- export declare interface SplatMaterialOptions {
181
- alphaTest?: number;
182
- alphaHash?: boolean;
183
- toneMapped?: boolean;
184
- }
185
-
186
- /**
187
- * A mesh that renders Gaussian splats
188
- * Not a real MESH, but a custom geometry with instancing
189
- */
190
- export declare class SplatMesh extends THREE.Mesh {
191
- sorter: SplatSorter;
192
- options: SplatMeshOptions;
193
- splatData: SplatData | null;
194
- textureManager: TextureManager;
195
- material: SplatMaterial;
196
- geometry: THREE.InstancedBufferGeometry;
197
- private lastCameraPositionLocal;
198
- private lastCameraDirectionLocal;
199
- private invModelMatrix;
200
- private _vpW;
201
- private _vpH;
202
- private _size;
203
- private _camPosW;
204
- private _camDirW;
205
- private _camPosL;
206
- private _camDirL;
207
- /** Number of splats combined into a single instanced draw call. */
208
- private static INSTANCE_SIZE;
209
- /**
210
- * Create a new SplatMesh for rendering Gaussian splats
211
- * @param splatData The splat data to render
212
- * @param options Rendering options
213
- */
214
- constructor(splatData: SplatData, options?: SplatMeshOptions);
215
- private onSorterUpdated;
216
- /**
217
- * Creates the instanced geometry for rendering splats.
218
- * @param totalSplats Total number of splats in the data.
219
- * @param instanceSize Number of splats per instance.
220
- * @returns InstancedBufferGeometry
221
- */
222
- private static createInstancedGeometry;
223
- /**
224
- * Create chunks data (bounding box min/max) for the sorter.
225
- * @returns Float32Array containing chunk data [minX, minY, minZ, maxX, maxY, maxZ] or null.
226
- */
227
- private createChunks;
228
- /**
229
- * Update the viewport size
230
- * @param width Viewport width
231
- * @param height Viewport height
232
- */
233
- updateViewport(width: number, height: number): void;
234
- /**
235
- * Sorts splats based on camera position and direction.
236
- * @param camera The camera to sort against.
237
- */
238
- sort(camera: THREE.Camera): void;
239
- /**
240
- * THREE.js hook called before rendering the object.
241
- * Used here to trigger sorting and update viewport.
242
- * @param renderer The renderer
243
- * @param scene The scene
244
- * @param camera The camera
245
- */
246
- onBeforeRender(renderer: THREE.WebGLRenderer, scene: THREE.Scene, camera: THREE.Camera): void;
247
- /**
248
- * Dispose of resources
249
- */
250
- dispose(): void;
251
- }
252
-
253
- export declare interface SplatMeshOptions extends SplatMaterialOptions {
254
- autoSort?: boolean;
255
- keepSplatData?: boolean;
256
- }
257
-
258
- declare interface SplatRanges {
259
- sh0: {
260
- min: THREE.Vector3;
261
- max: THREE.Vector3;
262
- };
263
- means: {
264
- min: THREE.Vector3;
265
- max: THREE.Vector3;
266
- };
267
- scales: {
268
- min: THREE.Vector3;
269
- max: THREE.Vector3;
270
- };
271
- }
272
-
273
- /**
274
- * Manages sorting of splats based on camera view using a Web Worker.
275
- */
276
- export declare class SplatSorter extends THREE.EventDispatcher<{
277
- updated: SplatSortUpdateEvent;
278
- }> {
279
- private worker;
280
- private centers;
281
- private orderTexture;
282
- /** Bounding box data for optimization */
283
- private chunks;
284
- private lastCameraPosition;
285
- private lastCameraDirection;
286
- constructor();
287
- /**
288
- * Handles messages received from the sorting worker.
289
- * @param event The message event from the worker.
290
- */
291
- private onWorkerMessage;
292
- /**
293
- * Initializes the sorter with necessary data and textures.
294
- * @param orderTexture The THREE.DataTexture (R32UI) to store the sorted splat indices.
295
- * @param centers A Float32Array containing the center position (x, y, z) for each splat.
296
- * @param chunks Optional: A Float32Array containing bounding box chunk data [minX, minY, minZ, maxX, maxY, maxZ, ...] for optimization.
297
- * @param transferOwnership Optional: If true, transfers ownership of centers buffer to worker (saves memory, main thread loses access). Default: false.
298
- */
299
- init(orderTexture: THREE.DataTexture, centers: Float32Array, chunks?: Float32Array, transferOwnership?: boolean): void;
300
- /**
301
- * Applies an optional mapping to filter or reorder splats before sorting.
302
- * The sorter will only consider splats whose original indices are present in the mapping.
303
- * @param mapping A Uint32Array where each element is the *original* index of a splat to include, or null to reset mapping.
304
- */
305
- setMapping(mapping: Uint32Array | null): void;
306
- /**
307
- * Updates the camera parameters used for sorting.
308
- * @param position The camera's position in the sorter's local coordinate space.
309
- * @param direction The camera's forward direction in the sorter's local coordinate space.
310
- */
311
- setCamera(position: THREE.Vector3, direction: THREE.Vector3): void;
312
- /**
313
- * Terminates the Web Worker and cleans up resources.
314
- */
315
- dispose(): void;
316
- /**
317
- * Creates the self-contained code for the sorting Web Worker.
318
- * @returns A string containing the JavaScript code for the worker.
319
- */
320
- private createWorkerCode;
321
- }
322
-
323
- /** Event dispatched when the sort is updated */
324
- declare interface SplatSortUpdateEvent extends THREE.Event {
325
- type: 'updated';
326
- count: number;
327
- }
328
-
329
- export declare class TextureManager {
330
- packedGeometry: THREE.DataTexture;
331
- packedColor: THREE.DataTexture;
332
- orderTexture: THREE.DataTexture;
333
- width: number;
334
- height: number;
335
- constructor(data: SplatData);
336
- private createGeometryTexture;
337
- private createColorTexture;
338
- private createOrderTexture;
339
- dispose(): void;
340
- }
341
-
342
- export declare const VERSION = "0.3.0";
343
-
344
- export { }
1
+ import * as THREE from 'three';
2
+
3
+ export declare class AnimationController implements AnimationState {
4
+ private _progress;
5
+ private _isPlaying;
6
+ private _isComplete;
7
+ private _startTime;
8
+ private _duration;
9
+ private _delay;
10
+ private _easing;
11
+ private _type;
12
+ private _autoPlay;
13
+ private _center;
14
+ constructor(options: AnimationOptions);
15
+ /** Current progress 0-1 (eased) */
16
+ get progress(): number;
17
+ get isPlaying(): boolean;
18
+ get isComplete(): boolean;
19
+ get type(): AnimationType;
20
+ get center(): THREE.Vector3;
21
+ /** Set the animation center point (typically bounding box center) */
22
+ setCenter(center: THREE.Vector3): void;
23
+ play(): void;
24
+ stop(): void;
25
+ reset(): void;
26
+ /** Skip to end state */
27
+ complete(): void;
28
+ /** Called from onBeforeRender - returns true if uniforms need update */
29
+ update(currentTime: number): boolean;
30
+ /** Should auto-play be triggered on load? */
31
+ shouldAutoPlay(): boolean;
32
+ }
33
+
34
+ /**
35
+ * Animation effect definition - SELF-CONTAINED
36
+ *
37
+ * Each effect provides its own GLSL code implementing the standard
38
+ * `applyAnimation` function signature. This code gets injected into
39
+ * the vertex shader template.
40
+ */
41
+ declare interface AnimationEffect_2 {
42
+ type: AnimationType;
43
+ defaultDuration: number;
44
+ /**
45
+ * GLSL code defining the applyAnimation function.
46
+ *
47
+ * MUST implement this exact signature:
48
+ * ```glsl
49
+ * void applyAnimation(
50
+ * inout vec3 position,
51
+ * inout vec3 scale,
52
+ * inout vec4 color,
53
+ * float progress,
54
+ * vec3 center
55
+ * )
56
+ * ```
57
+ *
58
+ * - position: splat center in model space
59
+ * - scale: splat scales in LOG SPACE (exp() applied AFTER animation)
60
+ * - color: RGBA color
61
+ * - progress: animation progress 0-1 (already eased)
62
+ * - center: bounding box center point
63
+ *
64
+ * **IMPORTANT**: `SplatMaterial.setAnimation()` injects a guard
65
+ * `if (animationProgress < 1.0)` around the call to `applyAnimation()`,
66
+ * so effect code will NEVER run at exactly `progress == 1.0`.
67
+ * Effects should be designed such that they converge to a no-op state
68
+ * as progress approaches 1.0 (e.g., all splats fully revealed, no
69
+ * additional transformations applied).
70
+ */
71
+ shaderCode: string;
72
+ }
73
+ export { AnimationEffect_2 as AnimationEffect }
74
+
75
+ export declare interface AnimationOptions {
76
+ delay?: number;
77
+ duration?: number;
78
+ autoPlay?: boolean;
79
+ easing?: EasingType;
80
+ type: AnimationType;
81
+ }
82
+
83
+ export declare interface AnimationState {
84
+ readonly progress: number;
85
+ readonly isPlaying: boolean;
86
+ readonly isComplete: boolean;
87
+ }
88
+
89
+ export declare type AnimationType = 'spread' | 'wave' | 'none';
90
+
91
+ /**
92
+ * Simplified bounding box class that tracks min/max points
93
+ */
94
+ export declare class BoundingBox {
95
+ min: THREE.Vector3;
96
+ max: THREE.Vector3;
97
+ center: THREE.Vector3;
98
+ /** Half extents (size/2) */
99
+ halfExtents: THREE.Vector3;
100
+ /**
101
+ * Reset the bounding box to its initial state
102
+ */
103
+ reset(): void;
104
+ /**
105
+ * Expand the bounding box to include the given point
106
+ * @param point Point to include in the bounding box
107
+ */
108
+ expandByPoint(point: THREE.Vector3): void;
109
+ /**
110
+ * Expand this bounding box to include another bounding box
111
+ * @param box Bounding box to include
112
+ */
113
+ expandByBox(box: BoundingBox): void;
114
+ /**
115
+ * Update the center and half extents based on min/max
116
+ */
117
+ private updateDerived;
118
+ /**
119
+ * Check if this box contains a point
120
+ * @param point Point to check
121
+ * @returns True if the point is inside the box
122
+ */
123
+ containsPoint(point: THREE.Vector3): boolean;
124
+ /**
125
+ * Create a Three.js Box3 from this bounding box
126
+ * @returns THREE.Box3 representation
127
+ */
128
+ toBox3(): THREE.Box3;
129
+ /**
130
+ * Create a clone of this bounding box
131
+ * @returns New bounding box with the same values
132
+ */
133
+ clone(): BoundingBox;
134
+ }
135
+
136
+ export declare type EasingType = 'linear' | 'easeInQuad' | 'easeOutQuad' | 'easeInOutQuad' | 'easeInCubic' | 'easeOutCubic' | 'easeInOutCubic' | 'easeOutExpo';
137
+
138
+ export declare const getEffect: (type: AnimationType) => AnimationEffect_2;
139
+
140
+ /**
141
+ * Class for loading PLY files with Gaussian Splat data
142
+ */
143
+ export declare class PlyLoader extends THREE.Loader {
144
+ private requestId;
145
+ private worker;
146
+ private pendingCallbacks;
147
+ constructor(manager?: THREE.LoadingManager, options?: PlyLoaderOptions);
148
+ /**
149
+ * Handles messages received from the parsing worker
150
+ * @param event The message event from the worker
151
+ */
152
+ private onWorkerMessage;
153
+ /**
154
+ * Load a PLY file with Gaussian Splat data
155
+ * @param url URL of the PLY file
156
+ * @param onLoad Optional callback when loading is complete
157
+ * @param onProgress Optional progress callback
158
+ * @param onError Optional error callback
159
+ */
160
+ load(url: string, onLoad?: (data: SplatData) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void;
161
+ /**
162
+ * Load a PLY file asynchronously and return a Promise
163
+ * @param url URL of the PLY file
164
+ * @param onProgress Optional progress callback
165
+ * @returns A Promise that resolves with the parsed SplatData
166
+ */
167
+ loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise<SplatData>;
168
+ /**
169
+ * Parse PLY buffer data asynchronously using Web Worker
170
+ * @param buffer ArrayBuffer containing PLY data
171
+ * @returns Promise that resolves with parsed SplatData
172
+ */
173
+ private parseAsync;
174
+ /**
175
+ * Terminate the Web Worker and clean up resources
176
+ */
177
+ dispose(): void;
178
+ /**
179
+ * Creates the self-contained code for the parsing Web Worker
180
+ * @returns A string containing the JavaScript code for the worker
181
+ */
182
+ private createWorkerCode;
183
+ }
184
+
185
+ export declare interface PlyLoaderOptions {
186
+ withCredentials?: boolean;
187
+ }
188
+
189
+ /**
190
+ * Class for loading SOGS (Self Organizing Gaussians) files
191
+ */
192
+ export declare class SogsLoader extends THREE.Loader {
193
+ constructor(manager?: THREE.LoadingManager, options?: SogsLoaderOptions);
194
+ /**
195
+ * Detect if a buffer is a ZIP file by checking magic bytes
196
+ * ZIP files start with signature: PK\x03\x04 (0x50 0x4B 0x03 0x04)
197
+ */
198
+ private isZipBuffer;
199
+ /**
200
+ * Load a SOGS file (meta.json + textures)
201
+ * @param url URL of the meta.json file
202
+ * @param onLoad Optional callback when loading is complete
203
+ * @param onProgress Optional progress callback
204
+ * @param onError Optional error callback
205
+ */
206
+ load(url: string, onLoad?: (data: SplatData) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void;
207
+ /**
208
+ * Load a SOGS file asynchronously and return a Promise
209
+ * @param url URL of the meta.json file
210
+ * @param onProgress Optional progress callback
211
+ * @returns A Promise that resolves with the parsed SplatData
212
+ */
213
+ loadAsync(url: string, onProgress?: (event: ProgressEvent) => void): Promise<SplatData>;
214
+ private parseAsync;
215
+ private parseMetaAsync;
216
+ private parseZipAsync;
217
+ }
218
+
219
+ export declare interface SogsLoaderOptions {
220
+ withCredentials?: boolean;
221
+ }
222
+
223
+ export declare class SplatData {
224
+ numSplats: number;
225
+ textureWidth: number;
226
+ textureHeight: number;
227
+ ranges: SplatRanges;
228
+ centers: Float32Array;
229
+ boundingBox: BoundingBox;
230
+ packedColor: Uint8Array;
231
+ packedGeometry: Uint32Array;
232
+ constructor(numSplats: number, textureWidth: number, textureHeight: number, centers: Float32Array, packedGeometry: Uint32Array, packedColor: Uint8Array, ranges: SplatRanges, boundingBox: BoundingBox);
233
+ /**
234
+ * Optional: Reconstruct a full JS object for a specific splat.
235
+ * Useful for raycasting or debugging.
236
+ */
237
+ dispose(): void;
238
+ }
239
+
240
+ export declare class SplatMaterial extends THREE.ShaderMaterial {
241
+ constructor(options?: SplatMaterialOptions);
242
+ private _shaderTemplate;
243
+ setTexWidth(w: number): void;
244
+ /**
245
+ * Update the viewport size
246
+ * @param width Viewport width
247
+ * @param height Viewport height
248
+ */
249
+ updateViewport(width: number, height: number): void;
250
+ /**
251
+ * Set the main packed geometry texture (RGBA32UI)
252
+ */
253
+ setPackedGeometry(texture: THREE.Texture): void;
254
+ /**
255
+ * Set the packed color texture (RGBA8)
256
+ */
257
+ setPackedColor(texture: THREE.Texture): void;
258
+ /**
259
+ * Set order texture for sorting
260
+ */
261
+ setOrderTexture(texture: THREE.Texture): void;
262
+ /**
263
+ * Set the ranges needed to decompress the packed floats
264
+ */
265
+ setRanges(ranges: SplatRanges): void;
266
+ /**
267
+ * Set number of splats to render
268
+ * @param count Number of splats
269
+ */
270
+ setNumSplats(count: number): void;
271
+ /**
272
+ * Configure animation effect. Rebuilds shader with effect's GLSL code.
273
+ * @param effect - Animation effect to use (null to disable)
274
+ */
275
+ setAnimation(effect: AnimationEffect_2 | null): void;
276
+ /**
277
+ * Set animation progress (0 = start, 1 = complete/no animation)
278
+ */
279
+ setAnimationProgress(progress: number): void;
280
+ /**
281
+ * Set animation center point
282
+ */
283
+ setAnimationCenter(center: THREE.Vector3): void;
284
+ }
285
+
286
+ export declare interface SplatMaterialOptions {
287
+ alphaTest?: number;
288
+ alphaHash?: boolean;
289
+ toneMapped?: boolean;
290
+ }
291
+
292
+ /**
293
+ * A mesh that renders Gaussian splats
294
+ * Not a real MESH, but a custom geometry with instancing
295
+ */
296
+ export declare class SplatMesh extends THREE.Mesh {
297
+ sorter: SplatSorter;
298
+ options: SplatMeshOptions;
299
+ splatData: SplatData | null;
300
+ textureManager: TextureManager;
301
+ /** Animation controller (null if no animation configured) */
302
+ animation: AnimationController | null;
303
+ material: SplatMaterial;
304
+ geometry: THREE.InstancedBufferGeometry;
305
+ private lastCameraPositionLocal;
306
+ private lastCameraDirectionLocal;
307
+ private invModelMatrix;
308
+ private _vpW;
309
+ private _vpH;
310
+ private _size;
311
+ private _camPosW;
312
+ private _camDirW;
313
+ private _camPosL;
314
+ private _camDirL;
315
+ /** Number of splats combined into a single instanced draw call. */
316
+ private static INSTANCE_SIZE;
317
+ /**
318
+ * Create a new SplatMesh for rendering Gaussian splats
319
+ * @param splatData The splat data to render
320
+ * @param options Rendering options
321
+ */
322
+ constructor(splatData: SplatData, options?: SplatMeshOptions);
323
+ private onSorterUpdated;
324
+ /**
325
+ * Creates the instanced geometry for rendering splats.
326
+ * @param totalSplats Total number of splats in the data.
327
+ * @param instanceSize Number of splats per instance.
328
+ * @returns InstancedBufferGeometry
329
+ */
330
+ private static createInstancedGeometry;
331
+ /**
332
+ * Create chunks data (bounding box min/max) for the sorter.
333
+ * @returns Float32Array containing chunk data [minX, minY, minZ, maxX, maxY, maxZ] or null.
334
+ */
335
+ private createChunks;
336
+ /**
337
+ * Update the viewport size
338
+ * @param width Viewport width
339
+ * @param height Viewport height
340
+ */
341
+ updateViewport(width: number, height: number): void;
342
+ /**
343
+ * Sorts splats based on camera position and direction.
344
+ * @param camera The camera to sort against.
345
+ */
346
+ sort(camera: THREE.Camera): void;
347
+ /**
348
+ * THREE.js hook called before rendering the object.
349
+ * Used here to trigger sorting and update viewport.
350
+ * @param renderer The renderer
351
+ * @param scene The scene
352
+ * @param camera The camera
353
+ */
354
+ onBeforeRender(renderer: THREE.WebGLRenderer, scene: THREE.Scene, camera: THREE.Camera): void;
355
+ /**
356
+ * Dispose of resources
357
+ */
358
+ dispose(): void;
359
+ }
360
+
361
+ export declare interface SplatMeshOptions extends SplatMaterialOptions {
362
+ autoSort?: boolean;
363
+ keepSplatData?: boolean;
364
+ /** Animation configuration */
365
+ animation?: AnimationOptions;
366
+ }
367
+
368
+ declare interface SplatRanges {
369
+ sh0: {
370
+ min: THREE.Vector3;
371
+ max: THREE.Vector3;
372
+ };
373
+ means: {
374
+ min: THREE.Vector3;
375
+ max: THREE.Vector3;
376
+ };
377
+ scales: {
378
+ min: THREE.Vector3;
379
+ max: THREE.Vector3;
380
+ };
381
+ }
382
+
383
+ /**
384
+ * Manages sorting of splats based on camera view using a Web Worker.
385
+ */
386
+ export declare class SplatSorter extends THREE.EventDispatcher<{
387
+ updated: SplatSortUpdateEvent;
388
+ }> {
389
+ private worker;
390
+ private centers;
391
+ private orderTexture;
392
+ /** Bounding box data for optimization */
393
+ private chunks;
394
+ private lastCameraPosition;
395
+ private lastCameraDirection;
396
+ constructor();
397
+ /**
398
+ * Handles messages received from the sorting worker.
399
+ * @param event The message event from the worker.
400
+ */
401
+ private onWorkerMessage;
402
+ /**
403
+ * Initializes the sorter with necessary data and textures.
404
+ * @param orderTexture The THREE.DataTexture (R32UI) to store the sorted splat indices.
405
+ * @param centers A Float32Array containing the center position (x, y, z) for each splat.
406
+ * @param chunks Optional: A Float32Array containing bounding box chunk data [minX, minY, minZ, maxX, maxY, maxZ, ...] for optimization.
407
+ * @param transferOwnership Optional: If true, transfers ownership of centers buffer to worker (saves memory, main thread loses access). Default: false.
408
+ */
409
+ init(orderTexture: THREE.DataTexture, centers: Float32Array, chunks?: Float32Array, transferOwnership?: boolean): void;
410
+ /**
411
+ * Applies an optional mapping to filter or reorder splats before sorting.
412
+ * The sorter will only consider splats whose original indices are present in the mapping.
413
+ * @param mapping A Uint32Array where each element is the *original* index of a splat to include, or null to reset mapping.
414
+ */
415
+ setMapping(mapping: Uint32Array | null): void;
416
+ /**
417
+ * Updates the camera parameters used for sorting.
418
+ * @param position The camera's position in the sorter's local coordinate space.
419
+ * @param direction The camera's forward direction in the sorter's local coordinate space.
420
+ */
421
+ setCamera(position: THREE.Vector3, direction: THREE.Vector3): void;
422
+ /**
423
+ * Terminates the Web Worker and cleans up resources.
424
+ */
425
+ dispose(): void;
426
+ /**
427
+ * Creates the self-contained code for the sorting Web Worker.
428
+ * @returns A string containing the JavaScript code for the worker.
429
+ */
430
+ private createWorkerCode;
431
+ }
432
+
433
+ /** Event dispatched when the sort is updated */
434
+ declare interface SplatSortUpdateEvent extends THREE.Event {
435
+ type: 'updated';
436
+ count: number;
437
+ }
438
+
439
+ export declare class TextureManager {
440
+ packedGeometry: THREE.DataTexture;
441
+ packedColor: THREE.DataTexture;
442
+ orderTexture: THREE.DataTexture;
443
+ width: number;
444
+ height: number;
445
+ constructor(data: SplatData);
446
+ private createGeometryTexture;
447
+ private createColorTexture;
448
+ private createOrderTexture;
449
+ dispose(): void;
450
+ }
451
+
452
+ export declare const VERSION = "0.3.0";
453
+
454
+ export { }