gaussian-splat-lite 0.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.
- package/CHANGELOG.md +17 -0
- package/CONTRIBUTING.md +79 -0
- package/Gaussian-Splat-Lite.svg +104 -0
- package/LICENSE +202 -0
- package/NOTICE +10 -0
- package/README.md +272 -0
- package/THIRD_PARTY_LICENSES.md +53 -0
- package/dist/assets/worker-7HrXsEvI.js.map +1 -0
- package/dist/assets/worker-XHJGFfdJ.js.map +1 -0
- package/dist/gaussian-splat-lite.cjs +3039 -0
- package/dist/gaussian-splat-lite.cjs.map +1 -0
- package/dist/gaussian-splat-lite.min.cjs +886 -0
- package/dist/gaussian-splat-lite.min.cjs.map +1 -0
- package/dist/gaussian-splat-lite.module.js +3023 -0
- package/dist/gaussian-splat-lite.module.js.map +1 -0
- package/dist/gaussian-splat-lite.module.min.js +2840 -0
- package/dist/gaussian-splat-lite.module.min.js.map +1 -0
- package/dist/types/GaussianSplatRenderer.d.cts +385 -0
- package/dist/types/GaussianSplatRenderer.d.ts +385 -0
- package/dist/types/SplatAccumulator.d.cts +72 -0
- package/dist/types/SplatAccumulator.d.ts +72 -0
- package/dist/types/SplatEdit.d.cts +86 -0
- package/dist/types/SplatEdit.d.ts +86 -0
- package/dist/types/SplatGeometry.d.cts +4 -0
- package/dist/types/SplatGeometry.d.ts +4 -0
- package/dist/types/SplatLoader.d.cts +31 -0
- package/dist/types/SplatLoader.d.ts +31 -0
- package/dist/types/SplatMesh.d.cts +74 -0
- package/dist/types/SplatMesh.d.ts +74 -0
- package/dist/types/SplatSource.d.cts +23 -0
- package/dist/types/SplatSource.d.ts +23 -0
- package/dist/types/SplatWorker.d.cts +30 -0
- package/dist/types/SplatWorker.d.ts +30 -0
- package/dist/types/Splats.d.cts +54 -0
- package/dist/types/Splats.d.ts +54 -0
- package/dist/types/cameraRelative.d.cts +22 -0
- package/dist/types/cameraRelative.d.ts +22 -0
- package/dist/types/defines.d.cts +22 -0
- package/dist/types/defines.d.ts +22 -0
- package/dist/types/index.d.cts +12 -0
- package/dist/types/index.d.mts +1 -0
- package/dist/types/index.d.ts +12 -0
- package/dist/types/shaders.d.cts +1 -0
- package/dist/types/shaders.d.ts +1 -0
- package/dist/types/splatTransform.d.cts +10 -0
- package/dist/types/splatTransform.d.ts +10 -0
- package/dist/types/utils.d.cts +33 -0
- package/dist/types/utils.d.ts +33 -0
- package/dist/types/wasm.d.cts +2 -0
- package/dist/types/wasm.d.ts +2 -0
- package/dist/types/worker.d.cts +42 -0
- package/dist/types/worker.d.ts +42 -0
- package/docs/GaussianSplatRenderer.md +107 -0
- package/docs/SplatAccumulator.md +44 -0
- package/docs/SplatEdit.md +84 -0
- package/docs/SplatFileType.md +30 -0
- package/docs/SplatLoader.md +28 -0
- package/docs/SplatMesh.md +80 -0
- package/docs/SplatSource.md +26 -0
- package/docs/Splats.md +58 -0
- package/package.json +109 -0
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
import { SplatAccumulator } from './SplatAccumulator.cjs';
|
|
2
|
+
import { SplatWorker } from './SplatWorker.cjs';
|
|
3
|
+
import * as THREE from "three";
|
|
4
|
+
export interface GaussianSplatRendererOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Pass in your THREE.WebGLRenderer instance so Gaussian Splat Lite can perform work
|
|
7
|
+
* outside the usual render loop. Should be created with antialias: false
|
|
8
|
+
* (default setting) as WebGL anti-aliasing doesn't improve Gaussian Splatting
|
|
9
|
+
* rendering and significantly reduces performance.
|
|
10
|
+
*/
|
|
11
|
+
renderer: THREE.WebGLRenderer;
|
|
12
|
+
/**
|
|
13
|
+
* Callback function to be called when GaussianSplatRenderer needs to re-render,
|
|
14
|
+
* for example when a splat sort completes.
|
|
15
|
+
*/
|
|
16
|
+
onDirty?: () => void;
|
|
17
|
+
/**
|
|
18
|
+
* Whether to use premultiplied alpha when accumulating splat RGB
|
|
19
|
+
* @default true
|
|
20
|
+
*/
|
|
21
|
+
premultipliedAlpha?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Pass in a THREE.Timer to synchronize time-based effects across different
|
|
24
|
+
* systems. A supplied timer remains owned and updated by the caller.
|
|
25
|
+
* @default new THREE.Timer()
|
|
26
|
+
*/
|
|
27
|
+
timer?: THREE.Timer;
|
|
28
|
+
/**
|
|
29
|
+
* Controls whether to check and automatically update Gsplat collection
|
|
30
|
+
* each frame render.
|
|
31
|
+
* @default true
|
|
32
|
+
*/
|
|
33
|
+
autoUpdate?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Controls whether to update the Gsplats before or after rendering. For WebXR
|
|
36
|
+
* this is set to false in order to complete rendering as soon as possible.
|
|
37
|
+
* @default true (if not WebXR)
|
|
38
|
+
*/
|
|
39
|
+
preUpdate?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Maximum standard deviations from the center to render Gaussians. Values
|
|
42
|
+
* Math.sqrt(4)..Math.sqrt(9) produce acceptable results and can be tweaked for
|
|
43
|
+
* performance.
|
|
44
|
+
* @default Math.sqrt(8)
|
|
45
|
+
*/
|
|
46
|
+
maxStdDev?: number;
|
|
47
|
+
minPixelRadius?: number;
|
|
48
|
+
/**
|
|
49
|
+
* Maximum pixel radius for splat rendering.
|
|
50
|
+
* @default 512.0
|
|
51
|
+
*/
|
|
52
|
+
maxPixelRadius?: number;
|
|
53
|
+
/**
|
|
54
|
+
* Whether to use compressed Packed Splats for intermediary accumulator data.
|
|
55
|
+
* Changing this at runtime regenerates the accumulator on the next update.
|
|
56
|
+
* @default false
|
|
57
|
+
*/
|
|
58
|
+
accumPackedSplats?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Minimum alpha value for splat rendering.
|
|
61
|
+
* @default 0.5 * (1.0 / 255.0)
|
|
62
|
+
*/
|
|
63
|
+
minAlpha?: number;
|
|
64
|
+
/**
|
|
65
|
+
* Enable 2D Gaussian splatting rendering ability. When this mode is enabled,
|
|
66
|
+
* any scale x/y/z component that is exactly 0 (minimum quantized value) results
|
|
67
|
+
* in the other two non-0 axis being interpreted as an oriented 2D Gaussian Splat,
|
|
68
|
+
* rather instead of the usual projected 3DGS Z-slice. When reading PLY files,
|
|
69
|
+
* scale values less than e^-30 will be interpreted as 0.
|
|
70
|
+
* @default false
|
|
71
|
+
*/
|
|
72
|
+
enable2DGS?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Scalar value to add to 2D splat covariance diagonal, effectively blurring +
|
|
75
|
+
* enlarging splats. In scenes trained without the Gsplat anti-aliasing tweak
|
|
76
|
+
* this value was typically 0.3, but with anti-aliasing it is 0.0
|
|
77
|
+
* @default 0.0
|
|
78
|
+
*/
|
|
79
|
+
preBlurAmount?: number;
|
|
80
|
+
/**
|
|
81
|
+
* Scalar value to add to 2D splat covarianve diagonal, with opacity adjustment
|
|
82
|
+
* to correctly account for "blurring" when anti-aliasing. Typically 0.3
|
|
83
|
+
* (equivalent to approx 0.5 pixel radius) in scenes trained with anti-aliasing.
|
|
84
|
+
*/
|
|
85
|
+
blurAmount?: number;
|
|
86
|
+
/**
|
|
87
|
+
* Depth-of-field distance to focal plane
|
|
88
|
+
*/
|
|
89
|
+
focalDistance?: number;
|
|
90
|
+
/**
|
|
91
|
+
* Full-width angle of aperture opening (in radians), 0.0 to disable
|
|
92
|
+
* @default 0.0
|
|
93
|
+
*/
|
|
94
|
+
apertureAngle?: number;
|
|
95
|
+
/**
|
|
96
|
+
* X/Y clipping boundary factor for Gsplat centers against view frustum.
|
|
97
|
+
* 1.0 clips any centers that are exactly out of bounds, while 1.25 clips
|
|
98
|
+
* centers that are 25% beyond the bounds.
|
|
99
|
+
* @default 1.25
|
|
100
|
+
*/
|
|
101
|
+
clipXY?: number;
|
|
102
|
+
/**
|
|
103
|
+
* Parameter to adjust projected splat scale calculation to match other renderers,
|
|
104
|
+
* similar to the same parameter in the MKellogg 3DGS renderer. Higher values will
|
|
105
|
+
* tend to sharpen the splats. A value 2.0 can be used to match the behavior of
|
|
106
|
+
* the PlayCanvas renderer.
|
|
107
|
+
* @default 2.0
|
|
108
|
+
*/
|
|
109
|
+
focalAdjustment?: number;
|
|
110
|
+
/**
|
|
111
|
+
* Whether to sort splats radially (geometric distance) from the viewpoint (true)
|
|
112
|
+
* or by Z-depth (false). Most scenes are trained with the Z-depth sort metric
|
|
113
|
+
* and will render more accurately at certain viewpoints. However, radial sorting
|
|
114
|
+
* is more stable under viewpoint rotations.
|
|
115
|
+
* @default false
|
|
116
|
+
*/
|
|
117
|
+
sortRadial?: boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Minimum interval between sort calls in milliseconds.
|
|
120
|
+
* @default 0
|
|
121
|
+
*/
|
|
122
|
+
minSortIntervalMs?: number;
|
|
123
|
+
/**
|
|
124
|
+
* Configures an offline render target for the GaussianSplatRenderer (as opposed to
|
|
125
|
+
* rendering to the canvas). This is useful for rendering environment maps,
|
|
126
|
+
* additional viewpoints, or video frame rendering.
|
|
127
|
+
* @default undefined
|
|
128
|
+
*/
|
|
129
|
+
target?: {
|
|
130
|
+
/**
|
|
131
|
+
* Width of the render target in pixels.
|
|
132
|
+
*/
|
|
133
|
+
width: number;
|
|
134
|
+
/**
|
|
135
|
+
* Height of the render target in pixels.
|
|
136
|
+
*/
|
|
137
|
+
height: number;
|
|
138
|
+
/**
|
|
139
|
+
* If you want to be able to render a scene that depends on this target's
|
|
140
|
+
* output (for example, a recursive viewport), set this to true to enable
|
|
141
|
+
* double buffering.
|
|
142
|
+
* @default false
|
|
143
|
+
*/
|
|
144
|
+
doubleBuffer?: boolean;
|
|
145
|
+
/**
|
|
146
|
+
* Super-sampling factor for the render target. Values 1-4 are supported.
|
|
147
|
+
* Note that re-sampling back down to .width x .height is done on the CPU
|
|
148
|
+
* with simple averaging only when calling readTarget().
|
|
149
|
+
* @default 1
|
|
150
|
+
*/
|
|
151
|
+
superXY?: number;
|
|
152
|
+
} & THREE.RenderTargetOptions;
|
|
153
|
+
/**
|
|
154
|
+
* Extra uniform values to pass to the shader.
|
|
155
|
+
* @default undefined = no extra uniforms
|
|
156
|
+
*/
|
|
157
|
+
extraUniforms?: Record<string, unknown>;
|
|
158
|
+
/**
|
|
159
|
+
* Replace the default `splatVertex.glsl` splat shader with a custom one.
|
|
160
|
+
* @default undefined = use the default `splatVertex.glsl` shader
|
|
161
|
+
*/
|
|
162
|
+
vertexShader?: string;
|
|
163
|
+
/**
|
|
164
|
+
* Replace the default `splatFragment.glsl` splat shader with a custom one.
|
|
165
|
+
* @default undefined = use the default `splatFragment.glsl` shader
|
|
166
|
+
*/
|
|
167
|
+
fragmentShader?: string;
|
|
168
|
+
/**
|
|
169
|
+
* Set the splat shader material to be transparent which determines if the
|
|
170
|
+
* splats are rendered during the first opaque THREE.js render pass or the
|
|
171
|
+
* second transparent render pass.
|
|
172
|
+
* @default undefined = true
|
|
173
|
+
*/
|
|
174
|
+
transparent?: boolean;
|
|
175
|
+
/**
|
|
176
|
+
* Set the splat shader material to enable depth testing which determines if the
|
|
177
|
+
* splats respect the Z depth buffer and blend with other opaque objects in the scene.
|
|
178
|
+
* @default undefined = true
|
|
179
|
+
*/
|
|
180
|
+
depthTest?: boolean;
|
|
181
|
+
/**
|
|
182
|
+
* Set the splat shader material to enable depth writing which determines if the
|
|
183
|
+
* splats write to the Z depth buffer. Note that enabling this may produce
|
|
184
|
+
* undesirable results because most of the Gsplat is transparent.
|
|
185
|
+
* @default undefined = false
|
|
186
|
+
*/
|
|
187
|
+
depthWrite?: boolean;
|
|
188
|
+
}
|
|
189
|
+
export declare class GaussianSplatRenderer extends THREE.Mesh {
|
|
190
|
+
readonly renderer: THREE.WebGLRenderer;
|
|
191
|
+
readonly material: THREE.ShaderMaterial;
|
|
192
|
+
readonly uniforms: ReturnType<typeof GaussianSplatRenderer.makeUniforms>;
|
|
193
|
+
autoUpdate: boolean;
|
|
194
|
+
preUpdate: boolean;
|
|
195
|
+
static gaussianSplatOverride?: GaussianSplatRenderer;
|
|
196
|
+
renderSize: THREE.Vector2;
|
|
197
|
+
maxStdDev: number;
|
|
198
|
+
minPixelRadius: number;
|
|
199
|
+
maxPixelRadius: number;
|
|
200
|
+
private accumPackedSplatsValue;
|
|
201
|
+
minAlpha: number;
|
|
202
|
+
enable2DGS: boolean;
|
|
203
|
+
preBlurAmount: number;
|
|
204
|
+
blurAmount: number;
|
|
205
|
+
focalDistance: number;
|
|
206
|
+
apertureAngle: number;
|
|
207
|
+
clipXY: number;
|
|
208
|
+
focalAdjustment: number;
|
|
209
|
+
sortRadial: boolean;
|
|
210
|
+
minSortIntervalMs: number;
|
|
211
|
+
readonly timer: THREE.Timer;
|
|
212
|
+
private readonly ownsTimer;
|
|
213
|
+
lastFrame: number;
|
|
214
|
+
updateTimeoutId: number;
|
|
215
|
+
onDirty?: () => void;
|
|
216
|
+
dirty: boolean;
|
|
217
|
+
orderingTexture: THREE.DataTexture | null;
|
|
218
|
+
maxSplats: number;
|
|
219
|
+
activeSplats: number;
|
|
220
|
+
display: SplatAccumulator;
|
|
221
|
+
current: SplatAccumulator;
|
|
222
|
+
accumulators: SplatAccumulator[];
|
|
223
|
+
sorting: boolean;
|
|
224
|
+
sortDirty: boolean;
|
|
225
|
+
lastSortTime: number;
|
|
226
|
+
sortWorker: SplatWorker | null;
|
|
227
|
+
sortedCenter: THREE.Vector3;
|
|
228
|
+
sortedDir: THREE.Vector3;
|
|
229
|
+
private sortedRadial;
|
|
230
|
+
private sortCentersRevision;
|
|
231
|
+
private uploadedSortCentersRevision;
|
|
232
|
+
private updateRunning;
|
|
233
|
+
private updatePromise;
|
|
234
|
+
private queuedUpdate;
|
|
235
|
+
private disposed;
|
|
236
|
+
target?: THREE.WebGLRenderTarget;
|
|
237
|
+
backTarget?: THREE.WebGLRenderTarget;
|
|
238
|
+
superPixels?: Uint8Array;
|
|
239
|
+
targetPixels?: Uint8Array;
|
|
240
|
+
superXY: number;
|
|
241
|
+
constructor(options: GaussianSplatRendererOptions);
|
|
242
|
+
raycast(_raycaster: THREE.Raycaster, _intersects: THREE.Intersection[]): void;
|
|
243
|
+
static makeUniforms(): {
|
|
244
|
+
renderSize: {
|
|
245
|
+
value: THREE.Vector2;
|
|
246
|
+
};
|
|
247
|
+
near: {
|
|
248
|
+
value: number;
|
|
249
|
+
};
|
|
250
|
+
far: {
|
|
251
|
+
value: number;
|
|
252
|
+
};
|
|
253
|
+
renderToViewQuat: {
|
|
254
|
+
value: THREE.Quaternion;
|
|
255
|
+
};
|
|
256
|
+
renderToViewPos: {
|
|
257
|
+
value: THREE.Vector3;
|
|
258
|
+
};
|
|
259
|
+
renderToViewScale: {
|
|
260
|
+
value: number;
|
|
261
|
+
};
|
|
262
|
+
maxStdDev: {
|
|
263
|
+
value: number;
|
|
264
|
+
};
|
|
265
|
+
minPixelRadius: {
|
|
266
|
+
value: number;
|
|
267
|
+
};
|
|
268
|
+
maxPixelRadius: {
|
|
269
|
+
value: number;
|
|
270
|
+
};
|
|
271
|
+
minAlpha: {
|
|
272
|
+
value: number;
|
|
273
|
+
};
|
|
274
|
+
enable2DGS: {
|
|
275
|
+
value: boolean;
|
|
276
|
+
};
|
|
277
|
+
preBlurAmount: {
|
|
278
|
+
value: number;
|
|
279
|
+
};
|
|
280
|
+
blurAmount: {
|
|
281
|
+
value: number;
|
|
282
|
+
};
|
|
283
|
+
focalDistance: {
|
|
284
|
+
value: number;
|
|
285
|
+
};
|
|
286
|
+
apertureAngle: {
|
|
287
|
+
value: number;
|
|
288
|
+
};
|
|
289
|
+
clipXY: {
|
|
290
|
+
value: number;
|
|
291
|
+
};
|
|
292
|
+
focalAdjustment: {
|
|
293
|
+
value: number;
|
|
294
|
+
};
|
|
295
|
+
encodeLinear: {
|
|
296
|
+
value: boolean;
|
|
297
|
+
};
|
|
298
|
+
ordering: {
|
|
299
|
+
type: string;
|
|
300
|
+
value: THREE.DataTexture;
|
|
301
|
+
};
|
|
302
|
+
enablePackedSplats: {
|
|
303
|
+
value: boolean;
|
|
304
|
+
};
|
|
305
|
+
splats: {
|
|
306
|
+
type: string;
|
|
307
|
+
value: THREE.DataArrayTexture;
|
|
308
|
+
};
|
|
309
|
+
splats2: {
|
|
310
|
+
type: string;
|
|
311
|
+
value: THREE.DataArrayTexture;
|
|
312
|
+
};
|
|
313
|
+
splatShape: {
|
|
314
|
+
type: string;
|
|
315
|
+
value: THREE.DataArrayTexture;
|
|
316
|
+
};
|
|
317
|
+
time: {
|
|
318
|
+
value: number;
|
|
319
|
+
};
|
|
320
|
+
deltaTime: {
|
|
321
|
+
value: number;
|
|
322
|
+
};
|
|
323
|
+
debugFlag: {
|
|
324
|
+
value: boolean;
|
|
325
|
+
};
|
|
326
|
+
};
|
|
327
|
+
dispose(): void;
|
|
328
|
+
setDirty(): void;
|
|
329
|
+
private createAccumulator;
|
|
330
|
+
private takeAccumulator;
|
|
331
|
+
private releaseAccumulator;
|
|
332
|
+
onBeforeRender(renderer: THREE.WebGLRenderer, scene: THREE.Scene, camera: THREE.Camera): void;
|
|
333
|
+
clearSplats(): void;
|
|
334
|
+
update({ scene, camera, }: {
|
|
335
|
+
scene: THREE.Scene;
|
|
336
|
+
camera: THREE.Camera;
|
|
337
|
+
}): Promise<void>;
|
|
338
|
+
private updateInternal;
|
|
339
|
+
private drainUpdates;
|
|
340
|
+
private performUpdate;
|
|
341
|
+
private driveSort;
|
|
342
|
+
private static emptyOrdering;
|
|
343
|
+
render(scene: THREE.Scene, camera: THREE.Camera): void;
|
|
344
|
+
renderTarget({ scene, camera, }: {
|
|
345
|
+
scene: THREE.Scene;
|
|
346
|
+
camera: THREE.Camera;
|
|
347
|
+
}): THREE.WebGLRenderTarget;
|
|
348
|
+
readTarget(): Promise<Uint8Array>;
|
|
349
|
+
renderReadTarget({ scene, camera, }: {
|
|
350
|
+
scene: THREE.Scene;
|
|
351
|
+
camera: THREE.Camera;
|
|
352
|
+
}): Promise<Uint8Array>;
|
|
353
|
+
private static cubeRender;
|
|
354
|
+
private static pmrem;
|
|
355
|
+
renderCubeMap({ scene, worldCenter, size, near, far, hideObjects, update, filter, }: {
|
|
356
|
+
scene: THREE.Scene;
|
|
357
|
+
worldCenter: THREE.Vector3;
|
|
358
|
+
size?: number;
|
|
359
|
+
near?: number;
|
|
360
|
+
far?: number;
|
|
361
|
+
hideObjects: THREE.Object3D[];
|
|
362
|
+
update: boolean;
|
|
363
|
+
filter: boolean;
|
|
364
|
+
}): Promise<THREE.CubeTexture>;
|
|
365
|
+
readCubeTargets(): Promise<Uint8Array[]>;
|
|
366
|
+
renderEnvMap({ scene, worldCenter, size, near, far, hideObjects, update, }: {
|
|
367
|
+
scene: THREE.Scene;
|
|
368
|
+
worldCenter: THREE.Vector3;
|
|
369
|
+
size?: number;
|
|
370
|
+
near?: number;
|
|
371
|
+
far?: number;
|
|
372
|
+
hideObjects: THREE.Object3D[];
|
|
373
|
+
update: boolean;
|
|
374
|
+
}): Promise<THREE.Texture>;
|
|
375
|
+
recurseSetEnvMap(root: THREE.Object3D, envMap: THREE.Texture): void;
|
|
376
|
+
get premultipliedAlpha(): boolean;
|
|
377
|
+
set premultipliedAlpha(value: boolean);
|
|
378
|
+
/**
|
|
379
|
+
* Whether intermediate accumulator data uses the compressed Packed Splat
|
|
380
|
+
* encoding. Changing this preserves the current display until the replacement
|
|
381
|
+
* accumulator is generated by the next automatic or explicit update.
|
|
382
|
+
*/
|
|
383
|
+
get accumPackedSplats(): boolean;
|
|
384
|
+
set accumPackedSplats(value: boolean);
|
|
385
|
+
}
|