gaussian-splat-lite 1.2.0 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/CHANGELOG.md +44 -2
  2. package/README.md +22 -13
  3. package/dist/gaussian-splat-lite.cjs +819 -88
  4. package/dist/gaussian-splat-lite.cjs.map +1 -1
  5. package/dist/gaussian-splat-lite.min.cjs +81 -20
  6. package/dist/gaussian-splat-lite.min.cjs.map +1 -1
  7. package/dist/gaussian-splat-lite.module.js +821 -90
  8. package/dist/gaussian-splat-lite.module.js.map +1 -1
  9. package/dist/gaussian-splat-lite.module.min.js +2984 -2427
  10. package/dist/gaussian-splat-lite.module.min.js.map +1 -1
  11. package/dist/types/addons/TAANode.d.cts +4 -2
  12. package/dist/types/addons/TAANode.d.ts +4 -2
  13. package/dist/types/addons/TAAPass.d.cts +6 -15
  14. package/dist/types/addons/TAAPass.d.ts +6 -15
  15. package/dist/types/addons/taaShared.d.cts +4 -2
  16. package/dist/types/addons/taaShared.d.ts +4 -2
  17. package/dist/types/capture/SplatCapture.d.cts +66 -0
  18. package/dist/types/capture/SplatCapture.d.ts +66 -0
  19. package/dist/types/capture/WebGLCapture.d.cts +13 -0
  20. package/dist/types/capture/WebGLCapture.d.ts +13 -0
  21. package/dist/types/capture/WebGPUCapture.d.cts +17 -0
  22. package/dist/types/capture/WebGPUCapture.d.ts +17 -0
  23. package/dist/types/capture/pixels.d.cts +5 -0
  24. package/dist/types/capture/pixels.d.ts +5 -0
  25. package/dist/types/capture/rendererState.d.cts +3 -0
  26. package/dist/types/capture/rendererState.d.ts +3 -0
  27. package/dist/types/capture/sceneView.d.cts +3 -0
  28. package/dist/types/capture/sceneView.d.ts +3 -0
  29. package/dist/types/index.d.cts +1 -1
  30. package/dist/types/index.d.ts +1 -1
  31. package/dist/types/rendering/GaussianSplatRenderer.d.cts +17 -11
  32. package/dist/types/rendering/GaussianSplatRenderer.d.ts +17 -11
  33. package/dist/types/rendering/SplatAccumulator.d.cts +2 -1
  34. package/dist/types/rendering/SplatAccumulator.d.ts +2 -1
  35. package/dist/types/rendering/backend.d.cts +1 -1
  36. package/dist/types/rendering/backend.d.ts +1 -1
  37. package/dist/types/rendering/rendererUtils.d.cts +1 -5
  38. package/dist/types/rendering/rendererUtils.d.ts +1 -5
  39. package/dist/types/rendering/tsl/ProjectionProgram.d.cts +2 -0
  40. package/dist/types/rendering/tsl/ProjectionProgram.d.ts +2 -0
  41. package/dist/types/rendering/tsl/SplatMaterial.d.cts +1 -0
  42. package/dist/types/rendering/tsl/SplatMaterial.d.ts +1 -0
  43. package/dist/types/rendering/tsl/tslCompat.d.cts +1 -0
  44. package/dist/types/rendering/tsl/tslCompat.d.ts +1 -0
  45. package/dist/types/rendering/uniforms.d.cts +3 -3
  46. package/dist/types/rendering/uniforms.d.ts +3 -3
  47. package/dist/types/scene/SplatMesh.d.cts +1 -1
  48. package/dist/types/scene/SplatMesh.d.ts +1 -1
  49. package/docs/Architecture.md +54 -3
  50. package/docs/GaussianSplatRenderer.md +71 -55
  51. package/docs/PostDecode.md +52 -36
  52. package/docs/RadStreamScheduler.md +53 -41
  53. package/docs/SogStreamScheduler.md +49 -39
  54. package/docs/SplatCapture.md +147 -0
  55. package/docs/SplatEdit.md +33 -26
  56. package/docs/SplatFileType.md +11 -13
  57. package/docs/SplatLoader.md +19 -14
  58. package/docs/SplatMesh.md +69 -49
  59. package/docs/Splats.md +33 -26
  60. package/docs/StochasticRendering.md +27 -30
  61. package/docs/TAAPass.md +98 -73
  62. package/package.json +1 -1
  63. package/docs/SplatAccumulator.md +0 -37
package/docs/TAAPass.md CHANGED
@@ -1,105 +1,104 @@
1
- # TAAPass
1
+ # TAAPass and TAANode
2
2
 
3
3
  [Back to documentation](../README.md#documentation)
4
4
 
5
- Temporal anti-aliasing for **WebGLRenderer**. Import `TAAPass` from `gaussian-splat-lite`. For **WebGPURenderer**, including its WebGL2 fallback, use the library's [TAANode](#webgpurenderer-tsl-version).
5
+ Temporal anti-aliasing (TAA) blends each frame with the ones before it. It smooths edges and the noise of [stochastic rendering](StochasticRendering.md). Use the version that matches your renderer:
6
6
 
7
- The pass is based on Three.js TRAA and needs no velocity texture. Camera motion is supported; independent object motion and changes to individual Splats are not tracked.
7
+ | Renderer | Use |
8
+ | --- | --- |
9
+ | `WebGLRenderer` | [`TAAPass`](#taapass-webglrenderer) with `EffectComposer` |
10
+ | `WebGPURenderer`, on WebGPU or its WebGL2 fallback | [`TAANode`](#taanode-webgpurenderer) with `RenderPipeline` |
8
11
 
9
- ## Constructor
12
+ Both render the scene themselves and need no velocity buffer or other scene setup.
10
13
 
11
- ```ts
12
- import { TAAPass } from "gaussian-splat-lite";
14
+ ## Before you start
13
15
 
14
- const taa = new TAAPass(scene, camera);
15
- ```
16
+ - **One camera.** A `PerspectiveCamera` or `OrthographicCamera`, including custom projections, scaled camera rigs, reversed depth, and logarithmic depth. WebXR is not supported.
17
+ - **Camera movement only.** Moving objects and changes to individual Splats are not tracked, and may leave a faint trail.
18
+ - **Stencil follows your renderer.** Create the Three.js renderer with `stencil: true` and stencil masks work as they do without TAA, including the stencil settings on your Splat renderer's `material`.
19
+ - **Reset after a jump.** Call `taa.reset()` after a camera cut or after replacing the scene. Resizing resets automatically.
20
+ - **Keep rendering while the image settles.** With on-demand rendering, render several more frames after each change. The viewer renders 32.
16
21
 
17
- `scene` is a Three.js `Scene`, and `camera` is a `PerspectiveCamera` or `OrthographicCamera`. The pass renders the scene itself and manages camera jitter internally. It supports one non-XR camera.
22
+ ## TAAPass (WebGLRenderer)
18
23
 
19
- ## WebGLRenderer setup
20
-
21
- This example assumes an existing `renderer`, `scene`, and `camera`. If smoothing [stochastic rendering](StochasticRendering.md), also set `splatRenderer.stochastic = true`. The repository's `examples/viewer/viewerTAA.js` uses this same setup.
24
+ This example assumes an existing `renderer`, `scene`, and `camera`. `TAAPass` takes the place of `RenderPass`, and Three.js's `OutputPass` finishes the image for display.
22
25
 
23
26
  ```js
24
27
  import { TAAPass } from "gaussian-splat-lite";
28
+ import { EffectComposer } from "three/addons/postprocessing/EffectComposer.js";
29
+ import { OutputPass } from "three/addons/postprocessing/OutputPass.js";
25
30
 
26
31
  const taa = new TAAPass(scene, camera);
32
+ const output = new OutputPass();
33
+ const composer = new EffectComposer(renderer);
34
+ composer.addPass(taa);
35
+ composer.addPass(output);
27
36
 
28
37
  renderer.setAnimationLoop(() => {
29
38
  // Update controls / animation here.
30
- taa.render(renderer);
39
+ composer.render();
31
40
  });
32
41
 
33
- // On resize: update the renderer size and camera projection.
42
+ // On resize: update the renderer size and camera projection,
43
+ // then call composer.setSize(width, height) in CSS pixels.
34
44
  // On a camera cut or scene replacement: taa.reset().
35
45
  // On cleanup:
36
46
  // renderer.setAnimationLoop(null);
47
+ // composer.dispose();
48
+ // output.dispose();
37
49
  // taa.dispose();
38
50
  ```
39
51
 
40
- `TAAPass` renders the scene and presents the result directly; no composer is needed. To add linear effects such as Bloom, see [Color space](#color-space).
41
-
42
- The pass follows the canvas size. Call `reset()` after a camera cut or scene replacement; resizing clears history automatically. For on-demand rendering, keep rendering for several frames after each change; the viewer uses 32.
43
-
44
- ### EffectComposer and offscreen rendering
45
-
46
- For a postprocessing chain, add the pass to an `EffectComposer`:
47
-
48
- ```js
49
- import { EffectComposer } from "three/addons/postprocessing/EffectComposer.js";
52
+ Dispose the passes as well as the composer when you are done. The repository's `examples/viewer/viewerTAA.js` uses this setup.
50
53
 
51
- const composer = new EffectComposer(renderer);
52
- composer.addPass(taa);
53
- // Render with composer.render(); update composer.setSize() on resize.
54
- ```
55
-
56
- `TAAPass` replaces `RenderPass` and follows the composer's size. Its result is ready for display, so do not add `OutputPass` unless using linear effects as described below. Dispose both `taa` and `composer` when finished.
54
+ ### Add effects
57
55
 
58
- To render offscreen directly, pass a target; the pass follows its size:
56
+ Insert Bloom and similar effects between `TAAPass` and `OutputPass`:
59
57
 
60
58
  ```js
61
- taa.render(renderer, target);
59
+ import { Vector2 } from "three";
60
+ import { UnrealBloomPass } from "three/addons/postprocessing/UnrealBloomPass.js";
61
+
62
+ const bloom = new UnrealBloomPass(
63
+ renderer.getSize(new Vector2()), 0.6, 0.4, 0.8,
64
+ );
65
+ composer.insertPass(bloom, 1);
66
+ // On cleanup: bloom.dispose().
62
67
  ```
63
68
 
64
- Without a target, the pass follows the canvas size. Call `taa.dispose()` when finished.
69
+ The order is `TAAPass → effects → OutputPass`. Effects work on the smoothed image.
65
70
 
66
- ### Color space
71
+ ### Use depth in effects
67
72
 
68
- By default, `accumulateInOutputSpace = true`: the pass renders and accumulates in `renderer.outputColorSpace`, so Splats look the same as when drawn directly to the canvas. The result is ready for display. Adding `OutputPass` would convert the colors a second time.
69
-
70
- For Bloom and other linear effects, set `accumulateInOutputSpace = false` and finish the chain with `OutputPass`:
73
+ `taa.depthTexture` gives later effects the scene depth of the current frame. Set it up once when building the chain:
71
74
 
72
75
  ```js
73
- import { OutputPass } from "three/addons/postprocessing/OutputPass.js";
76
+ depthEffect.uniforms.tDepth.value = taa.depthTexture;
77
+ depthEffect.uniforms.captureProjection.value = taa.projectionMatrix;
74
78
 
75
- taa.accumulateInOutputSpace = false;
79
+ const composer = new EffectComposer(renderer);
76
80
  composer.addPass(taa);
77
- // Add Bloom or other linear effects here.
81
+ composer.addPass(depthEffect);
78
82
  composer.addPass(new OutputPass());
79
83
  ```
80
84
 
81
- In this mode, Splats blend in linear space, which makes partially transparent areas slightly brighter than direct canvas rendering.
85
+ Here `depthEffect` is your own pass that reads those uniforms. Both objects stay the same across frames and resizes.
82
86
 
83
- ### Depth effects
87
+ This depth is not smoothed, and it is rendered with a small per-frame camera offset. Convert it with `taa.projectionMatrix`, not `camera.projectionMatrix`. Treat both as read-only.
84
88
 
85
- `taa.depthTexture` exposes the current scene capture's depth for subsequent effects. When building the chain, bind it once and run the effect after `TAAPass`:
89
+ ### Render to your own target
86
90
 
87
- ```js
88
- depthEffect.uniforms.tDepth.value = taa.depthTexture;
89
- depthEffect.uniforms.captureProjection.value = taa.projectionMatrix;
91
+ To get the smoothed image offscreen, pass a render target; the pass follows the target's size:
90
92
 
91
- const composer = new EffectComposer(renderer);
92
- composer.addPass(taa);
93
- composer.addPass(depthEffect);
93
+ ```js
94
+ taa.render(renderer, target);
94
95
  ```
95
96
 
96
- Here `depthEffect` is a custom pass that consumes those uniforms. Both objects stay the same across frames and resizes, so bind them once.
97
-
98
- The depth is the current frame's raw depth, rendered with camera jitter and not temporally smoothed. Use `taa.projectionMatrix` to decode it, not `camera.projectionMatrix`, which no longer includes the jitter. Treat both as read-only.
97
+ The result is in the working color space, without tone mapping. Calling `taa.render(renderer)` without a target is not supported; use `EffectComposer` to draw to the screen.
99
98
 
100
- ## WebGPURenderer TSL version
99
+ ## TAANode (WebGPURenderer)
101
100
 
102
- `TAANode` implements the same camera/depth reprojection, 32-frame Halton jitter, depth rejection, neighborhood clipping, and luminance-aware blending for native WebGPU and WebGPURenderer's WebGL2 fallback. It captures the scene itself and uses two history targets, with no velocity attachment or history copies.
101
+ Use this setup on both WebGPU and the WebGL2 fallback, after `await renderer.init()`:
103
102
 
104
103
  ```js
105
104
  import { TAANode } from "gaussian-splat-lite";
@@ -107,36 +106,62 @@ import { RenderPipeline } from "three/webgpu";
107
106
 
108
107
  const taa = new TAANode(scene, camera);
109
108
  const pipeline = new RenderPipeline(renderer, taa);
110
- pipeline.render();
111
- // On a camera cut / scene replacement: taa.reset().
109
+
110
+ renderer.setAnimationLoop(() => {
111
+ // Update controls / animation here.
112
+ pipeline.render();
113
+ });
114
+
115
+ // On a camera cut or scene replacement: taa.reset().
112
116
  // On cleanup: pipeline.dispose(); taa.dispose();
113
117
  ```
114
118
 
115
- Chain TSL effects from the node or `taa.getTextureNode()`. Accumulation stays in the working color space; `RenderPipeline` applies tone mapping and output conversion at the end. `accumulateInOutputSpace` and the classic `Pass` properties apply only to `TAAPass`.
119
+ The pipeline follows the renderer's size by itself.
120
+
121
+ Chain effects from the node or from `taa.getTextureNode()`. For Bloom, create the pipeline like this instead:
122
+
123
+ ```js
124
+ import { bloom } from "three/addons/tsl/display/BloomNode.js";
125
+
126
+ const color = taa.getTextureNode();
127
+ const pipeline = new RenderPipeline(renderer, color.add(bloom(color, 0.6, 0.4, 0.8)));
128
+ ```
116
129
 
117
- `TAANode` exposes the same `depthThreshold`, `edgeDepthDiff`, `maxMotionLength`, `useSubpixelCorrection`, `depthTexture`, and `projectionMatrix`. Both implementations support one non-XR perspective or orthographic camera, including custom projections, scaled camera rigs, reversed depth, and logarithmic depth. They track camera movement, not independent object motion.
130
+ `TAANode` has the same `depthTexture`, `projectionMatrix`, and tuning properties as `TAAPass`.
131
+
132
+ ## Color and tone mapping
133
+
134
+ **`TAAPass`** shows Splats with the same colors as `WebGLRenderer` drawing straight to the canvas.
135
+
136
+ - `OutputPass` applies the renderer's tone mapping and exposure to the whole image, Splats included. Drawing straight to the canvas does not tone-map Splats.
137
+ - If `TAAPass` is the last enabled pass, it shows its image as it is, without tone mapping.
138
+ - On a transparent canvas, tone mapping and effects are approximate where pixels are partly transparent. Opaque pixels are unaffected.
139
+
140
+ **`TAANode`** follows `WebGPURenderer`'s color handling: `RenderPipeline` applies tone mapping and the output color space at the end. With Three.js's default linear working color space, partly transparent Splats look slightly brighter than on `WebGLRenderer`.
141
+
142
+ Both keep colors brighter than white, so effects such as Bloom work as expected. Changing the renderer's output color space with `TAAPass`, or Three.js's working color space with `TAANode`, restarts the smoothing.
118
143
 
119
144
  ## Properties
120
145
 
121
146
  | Property | Default | Description |
122
147
  | --- | --- | --- |
123
- | `scene` | Constructor scene | Scene to render; call `reset()` when replacing it. |
124
- | `camera` | Constructor camera | Camera used for jitter and reprojection; call `reset()` when replacing it. |
125
- | `accumulateInOutputSpace` | `true` | Accumulate in the output color space for direct display. Set `false` for linear effects and finish with `OutputPass`. |
126
- | `depthTexture` | Read-only | Current frame's scene depth. |
127
- | `projectionMatrix` | Read-only | Jittered projection matching `depthTexture`. |
128
- | `depthThreshold` | `0.0005` | Reject non-edge history when the depth difference exceeds this value. |
129
- | `edgeDepthDiff` | `0.001` | Depth range within the 3×3 neighborhood that identifies an edge. |
130
- | `maxMotionLength` | `128` | Camera motion in pixels at which history loses all weight. |
131
- | `useSubpixelCorrection` | `true` | Increase current-frame weight for subpixel camera motion. |
132
-
133
- The standard Three.js `Pass` properties, including `enabled` and `renderToScreen`, also apply. `EffectComposer` sets `renderToScreen` for its last enabled pass.
148
+ | `scene` | Constructor scene | Scene to render; call `reset()` when replacing it |
149
+ | `camera` | Constructor camera | Camera to render with; call `reset()` when replacing it |
150
+ | `depthTexture` | Read-only | Scene depth of the current frame |
151
+ | `projectionMatrix` | Read-only | Projection that matches `depthTexture` |
152
+ | `depthThreshold` | `0.0005` | Depth change above which a pixel's earlier frames are discarded |
153
+ | `edgeDepthDiff` | `0.001` | Depth difference between neighboring pixels that marks an edge. Edges are exempt from `depthThreshold` |
154
+ | `maxMotionLength` | `128` | Camera movement, in pixels, at which earlier frames are ignored entirely |
155
+ | `useSubpixelCorrection` | `true` | Give the current frame more weight during very small camera movements |
156
+
157
+ The defaults suit most scenes. `TAAPass` also has the standard Three.js `Pass` properties.
134
158
 
135
159
  ## Methods
136
160
 
137
161
  | Method | Description |
138
162
  | --- | --- |
139
- | `setSize(width, height)` | Resize in physical pixels. Called automatically; a size change clears history. |
140
- | `render(renderer, writeBuffer = null)` | Render the scene and resolve TAA to the canvas or a supplied target. Also called by `EffectComposer`. |
141
- | `reset()` | Clear history and restart the jitter sequence. |
142
- | `dispose()` | Release the pass's GPU resources. The scene is not disposed. |
163
+ | `reset()` | Discard earlier frames and start smoothing again |
164
+ | `dispose()` | Release the resources it holds. The scene is not disposed |
165
+ | `setSize(width, height)` | Resize in physical pixels. Called for you; a size change resets |
166
+ | `render(renderer, target)` | `TAAPass` only. Called for you by `EffectComposer` |
167
+ | `getTextureNode()` | `TAANode` only. The smoothed image, for chaining effects |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gaussian-splat-lite",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "Three.js Gaussian Splatting renderer with WebGPU/WebGL2, GPU sorting, streaming LOD, and high-precision GIS/ECEF support. Supports PLY, SPZ, SOG and RAD.",
5
5
  "author": "William Liu <lyz15972107087@gmail.com>",
6
6
  "type": "module",
@@ -1,37 +0,0 @@
1
- # SplatAccumulator
2
-
3
- [Back to documentation](../README.md#documentation)
4
-
5
- Combines visible Splat models for rendering. `GaussianSplatRenderer` manages this automatically; most applications only need its `update()` method.
6
-
7
- For custom integrations, the methods below expose the combined scene data. `ensureGenerate()` and `generate()` support WebGL only.
8
-
9
- ## Constructor
10
-
11
- ```ts
12
- new SplatAccumulator()
13
- ```
14
-
15
- ## Common state
16
-
17
- | Property | Description |
18
- | --- | --- |
19
- | `numSplats` | Number of Splats in the combined data |
20
- | `maxSplats` | Allocated Splat capacity |
21
- | `mapping` | Models and their ranges in the combined data |
22
- | `version` | Combined data version |
23
- | `mappingVersion` | Model mapping version |
24
- | `viewOrigin` / `viewDirection` | Camera position and direction used for the current data |
25
- | `time` / `deltaTime` | Timer values used for per-frame mesh updates |
26
-
27
- ## Common methods
28
-
29
- | API | Description |
30
- | --- | --- |
31
- | `getTextures()` | Return the combined Splat textures |
32
- | `generateMapping(splatCounts, compact?)` | Assign model ranges and return the required capacity; `compact` reduces unused space |
33
- | `ensureGenerate({ maxSplats, renderer?, shrinkResources?, stochasticSeeds? })` | Prepare storage for the requested capacity; optionally shrink unused resources or reserve storage for stochastic rendering |
34
- | `generate({ mesh, base, count, renderer })` | Update one model's range at its current world position |
35
- | `prepareGenerate({ renderer, scene, timer, camera, layerCamera?, previous })` | Collect visible models and prepare their updates; `layerCamera` (default `camera`) decides which layers are visible |
36
- | `checkVersions(mapping)` | Check whether data, model ranges, or sorting need updating |
37
- | `dispose()` | Release this accumulator's resources |