Skip to content

Commit c25dc35

Browse files
authored
Use JSDoc for documenting SparkRenderer and SparkViewpoint options (#123)
1 parent 8abae95 commit c25dc35

2 files changed

Lines changed: 154 additions & 75 deletions

File tree

src/SparkRenderer.ts

Lines changed: 81 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -78,62 +78,101 @@ THREE.Scene.prototype.onBeforeRender = function (
7878
};
7979

8080
export type SparkRendererOptions = {
81-
// Pass in your THREE.WebGLRenderer instance so Spark can perform work
82-
// outside the usual render loop. Should be created with antialias: false
83-
// (default setting) as WebGL anti-aliasing doesn't improve Gaussian Splatting
84-
// rendering and significantly reduces performance.
81+
/**
82+
* Pass in your THREE.WebGLRenderer instance so Spark can perform work
83+
* outside the usual render loop. Should be created with antialias: false
84+
* (default setting) as WebGL anti-aliasing doesn't improve Gaussian Splatting
85+
* rendering and significantly reduces performance.
86+
*/
8587
renderer: THREE.WebGLRenderer;
86-
// Pass in a THREE.Clock to synchronize time-based effects across different
87-
// systems. Alternatively, you can set the SparkRenderer properties time and
88-
// deltaTime directly. (default: new THREE.Clock)
88+
/**
89+
* Pass in a THREE.Clock to synchronize time-based effects across different
90+
* systems. Alternatively, you can set the SparkRenderer properties time and
91+
* deltaTime directly. (default: new THREE.Clock)
92+
*/
8993
clock?: THREE.Clock;
90-
// Controls whether to check and automatically update Gsplat collection after
91-
// each frame render. (default: true)
94+
/**
95+
* Controls whether to check and automatically update Gsplat collection after
96+
* each frame render.
97+
* @default true
98+
*/
9299
autoUpdate?: boolean;
93-
// Controls whether to update the Gsplats before or after rendering. For WebXR
94-
// this must be false in order to complete rendering as soon as possible.
95-
// (default: false)
100+
/**
101+
* Controls whether to update the Gsplats before or after rendering. For WebXR
102+
* this must be false in order to complete rendering as soon as possible.
103+
* @default false
104+
*/
96105
preUpdate?: boolean;
97-
// Distance threshold for SparkRenderer movement triggering a Gsplat update at
98-
// the new origin. (default: 1.0)
106+
/**
107+
* Distance threshold for SparkRenderer movement triggering a Gsplat update at
108+
* the new origin.
109+
* @default 1.0
110+
*/
99111
originDistance?: number;
100-
// Maximum standard deviations from the center to render Gaussians. Values
101-
// Math.sqrt(5)..Math.sqrt(8) produce good results and can be tweaked for
102-
// performance. (default: Math.sqrt(8))
112+
/**
113+
* Maximum standard deviations from the center to render Gaussians. Values
114+
* Math.sqrt(5)..Math.sqrt(8) produce good results and can be tweaked for
115+
* performance.
116+
* @default Math.sqrt(8)
117+
*/
103118
maxStdDev?: number;
104-
// Enable 2D Gaussian splatting rendering ability. When this mode is enabled,
105-
// any scale x/y/z component that is exactly 0 (minimum quantized value) results
106-
// in the other two non-0 axis being interpreted as an oriented 2D Gaussian Splat,
107-
// rather instead of the usual projected 3DGS Z-slice. When reading PLY files,
108-
// scale values less than e^-30 will be interpreted as 0. (default: false)
119+
/**
120+
* Enable 2D Gaussian splatting rendering ability. When this mode is enabled,
121+
* any scale x/y/z component that is exactly 0 (minimum quantized value) results
122+
* in the other two non-0 axis being interpreted as an oriented 2D Gaussian Splat,
123+
* rather instead of the usual projected 3DGS Z-slice. When reading PLY files,
124+
* scale values less than e^-30 will be interpreted as 0.
125+
* @default false
126+
*/
109127
enable2DGS?: boolean;
110-
// Scalar value to add to 2D splat covariance diagonal, effectively blurring +
111-
// enlarging splats. In scenes trained without the Gsplat anti-aliasing tweak
112-
// this value was typically 0.3, but with anti-aliasing it is 0.0 (default: 0.0)
128+
/**
129+
* Scalar value to add to 2D splat covariance diagonal, effectively blurring +
130+
* enlarging splats. In scenes trained without the Gsplat anti-aliasing tweak
131+
* this value was typically 0.3, but with anti-aliasing it is 0.0
132+
* @default 0.0
133+
*/
113134
preBlurAmount?: number;
114-
// Scalar value to add to 2D splat covarianve diagonal, with opacity adjustment
115-
// to correctly account for "blurring" when anti-aliasing. Typically 0.3
116-
// (equivalent to approx 0.5 pixel radius) in scenes trained with anti-aliasing.
135+
/**
136+
* Scalar value to add to 2D splat covarianve diagonal, with opacity adjustment
137+
* to correctly account for "blurring" when anti-aliasing. Typically 0.3
138+
* (equivalent to approx 0.5 pixel radius) in scenes trained with anti-aliasing.
139+
*/
117140
blurAmount?: number;
118-
// Depth-of-field distance to focal plane
141+
/**
142+
* Depth-of-field distance to focal plane
143+
*/
119144
focalDistance?: number;
120-
// Full-width angle of aperture opening (in radians), default 0.0 to disable
145+
/**
146+
* Full-width angle of aperture opening (in radians), 0.0 to disable
147+
* @default 0.0
148+
*/
121149
apertureAngle?: number;
122-
// Modulate Gaussian kernel falloff. 0 means "no falloff, flat shading",
123-
// while 1 is the normal Gaussian kernel. (default: 1.0)
150+
/**
151+
* Modulate Gaussian kernel falloff. 0 means "no falloff, flat shading",
152+
* while 1 is the normal Gaussian kernel.
153+
* @default 1.0
154+
*/
124155
falloff?: number;
125-
// X/Y clipping boundary factor for Gsplat centers against view frustum.
126-
// 1.0 clips any centers that are exactly out of bounds, while 1.4 clips
127-
// centers that are 40% beyond the bounds. (default: 1.4)
156+
/**
157+
* X/Y clipping boundary factor for Gsplat centers against view frustum.
158+
* 1.0 clips any centers that are exactly out of bounds, while 1.4 clips
159+
* centers that are 40% beyond the bounds.
160+
* @default 1.4
161+
*/
128162
clipXY?: number;
129-
// Parameter to adjust projected splat scale calculation to match other renderers,
130-
// similar to the same parameter in the MKellogg 3DGS renderer. Higher values will
131-
// tend to sharpen the splats. A value 2.0 can be used to match the behavior of
132-
// the PlayCanvas renderer. (default: 1.0)
163+
/**
164+
* Parameter to adjust projected splat scale calculation to match other renderers,
165+
* similar to the same parameter in the MKellogg 3DGS renderer. Higher values will
166+
* tend to sharpen the splats. A value 2.0 can be used to match the behavior of
167+
* the PlayCanvas renderer.
168+
* @default 1.0
169+
*/
133170
focalAdjustment?: number;
134-
// Configures the SparkViewpointOptions for the default SparkViewpoint
135-
// associated with this SparkRenderer. Notable option: sortRadial (sort by
136-
// radial distance or Z-depth)
171+
/**
172+
* Configures the SparkViewpointOptions for the default SparkViewpoint
173+
* associated with this SparkRenderer. Notable option: sortRadial (sort by
174+
* radial distance or Z-depth)
175+
*/
137176
view?: SparkViewpointOptions;
138177
};
139178

src/SparkViewpoint.ts

Lines changed: 73 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -29,53 +29,93 @@ import { withWorker } from "./splatWorker";
2929
import { FreeList, withinCoorientDist } from "./utils";
3030

3131
export type SparkViewpointOptions = {
32-
// Controls whether to auto-update its sort order whenever the SparkRenderer
33-
// updates the Gsplats. If you expect to render/display from this viewpoint
34-
// most frames, set this to true. (default: false)
32+
/**
33+
* Controls whether to auto-update its sort order whenever the SparkRenderer
34+
* updates the Gsplats. If you expect to render/display from this viewpoint
35+
* most frames, set this to true.
36+
* @default false
37+
*/
3538
autoUpdate?: boolean;
36-
// Set a THREE.Camera for this viewpoint to follow. (default: undefined)
39+
/**
40+
* Set a THREE.Camera for this viewpoint to follow.
41+
* @default undefined
42+
*/
3743
camera?: THREE.Camera;
38-
// Set an explicit view-to-world transformation matrix for this viewpoint (equivalent
39-
// to camera.matrixWorld), overrides any camera setting. (default: undefined)
44+
/**
45+
* Set an explicit view-to-world transformation matrix for this viewpoint (equivalent
46+
* to camera.matrixWorld), overrides any camera setting.
47+
* @default undefined
48+
*/
4049
viewToWorld?: THREE.Matrix4;
41-
// Configure viewpoint with an off-screen render target. (default: undefined)
50+
/**
51+
* Configure viewpoint with an off-screen render target.
52+
* @default undefined
53+
*/
4254
target?: {
43-
// Width of the render target in pixels.
55+
/**
56+
* Width of the render target in pixels.
57+
*/
4458
width: number;
45-
// Height of the render target in pixels.
59+
/**
60+
* Height of the render target in pixels.
61+
*/
4662
height: number;
47-
// If you want to be able to render a scene that depends on this target's
48-
// output (for example, a recursive viewport), set this to true to enable
49-
// double buffering. (default: false)
63+
/**
64+
* If you want to be able to render a scene that depends on this target's
65+
* output (for example, a recursive viewport), set this to true to enable
66+
* double buffering.
67+
* @default false
68+
*/
5069
doubleBuffer?: boolean;
51-
// Super-sampling factor for the render target. Values 1-4 are supported.
52-
// Note that re-sampling back down to .width x .height is done on the CPU
53-
// with simple averaging only when calling readTarget(). (default: 1)
70+
/**
71+
* Super-sampling factor for the render target. Values 1-4 are supported.
72+
* Note that re-sampling back down to .width x .height is done on the CPU
73+
* with simple averaging only when calling readTarget().
74+
* @default 1
75+
*/
5476
superXY?: number;
5577
};
56-
// Callback function that is called when the render target texture is updated.
57-
// Receives the texture as a parameter. Use this to update a viewport with
58-
// the latest viewpoint render each frame. (default: undefined)
78+
/**
79+
* Callback function that is called when the render target texture is updated.
80+
* Receives the texture as a parameter. Use this to update a viewport with
81+
* the latest viewpoint render each frame.
82+
* @default undefined
83+
*/
5984
onTextureUpdated?: (texture: THREE.Texture) => void;
60-
// Whether to sort splats radially (geometric distance) from the viewpoint (true)
61-
// or by Z-depth (false). Most scenes are trained with the Z-depth sort metric
62-
// and will render more accurately at certain viewpoints. However, radial sorting
63-
// is more stable under viewpoint rotations. (default: true)
85+
/**
86+
* Whether to sort splats radially (geometric distance) from the viewpoint (true)
87+
* or by Z-depth (false). Most scenes are trained with the Z-depth sort metric
88+
* and will render more accurately at certain viewpoints. However, radial sorting
89+
* is more stable under viewpoint rotations.
90+
* @default true
91+
*/
6492
sortRadial?: boolean;
65-
// Distance threshold for re-sorting splats. If the viewpoint moves more than
66-
// this distance, splats will be re-sorted. (default: 0.01 units)
93+
/**
94+
* Distance threshold for re-sorting splats. If the viewpoint moves more than
95+
* this distance, splats will be re-sorted.
96+
* @default 0.01 units
97+
*/
6798
sortDistance?: number;
68-
// View direction dot product threshold for re-sorting splats. For
69-
// sortRadial: true we use 0.99 while sortRadial: false uses 0.999 because it is
70-
// more sensitive to view direction. (default: 0.99 if sortRadial else 0.999)
99+
/**
100+
* View direction dot product threshold for re-sorting splats. For
101+
* sortRadial: true we use 0.99 while sortRadial: false uses 0.999 because it is
102+
* more sensitive to view direction.
103+
* @default 0.99 if sortRadial else 0.999
104+
*/
71105
sortCoorient?: boolean;
72-
// Constant added to Z-depth to bias values into the positive range for
73-
// sortRadial: false, but also used for culling Gsplats "well behind"
74-
// the viewpoint origin (default: 1.0)
106+
/**
107+
* Constant added to Z-depth to bias values into the positive range for
108+
* sortRadial: false, but also used for culling Gsplats "well behind"
109+
* the viewpoint origin
110+
* @default 1.0
111+
*/
75112
depthBias?: number;
76-
// Set this to true if rendering a 360 to disable "behind the viewpoint"
77-
// culling during sorting. This is set automatically when rendering 360 envMaps
78-
// using the SparkRenderer.renderEnvMap() utility function. (default: false)
113+
/**
114+
* Set this to true if rendering a 360 to disable "behind the viewpoint"
115+
* culling during sorting. This is set automatically when rendering 360 envMaps
116+
* using the SparkRenderer.renderEnvMap() utility function.
117+
* @default false
118+
*/
79119
sort360?: boolean;
80120
};
81121

0 commit comments

Comments
 (0)