@equinor/videx-3d 2.0.0 → 3.0.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/chunk-DKAquGKk.js +2820 -0
- package/dist/chunk-DsUZyEG_.js +16 -0
- package/dist/generators.js +512 -727
- package/dist/main.js +6940 -10553
- package/dist/sdk.js +2 -787
- package/dist/types/components/Ocean/Ocean.d.ts +333 -0
- package/dist/types/components/Ocean/index.d.ts +6 -0
- package/dist/types/components/Ocean/ocean-bed-material.d.ts +60 -0
- package/dist/types/components/Ocean/ocean-contact.d.ts +39 -0
- package/dist/types/components/Ocean/ocean-material.d.ts +145 -0
- package/dist/types/components/Ocean/ocean-sampler.d.ts +93 -0
- package/dist/types/components/Ocean/ocean-volume-material.d.ts +54 -0
- package/dist/types/components/Tanker/Tanker.d.ts +47 -0
- package/dist/types/components/Tanker/TankerSuperstructure.d.ts +23 -0
- package/dist/types/components/Tanker/tanker-geometry-builder.d.ts +21 -0
- package/dist/types/main.d.ts +1 -0
- package/dist/types/rendering/Pass.d.ts +10 -1
- package/dist/types/rendering/RenderingPipeline.d.ts +10 -1
- package/dist/types/rendering/debug/DebugBoxOutputPass.d.ts +22 -0
- package/dist/types/rendering/debug/DebugPatternPass.d.ts +30 -0
- package/dist/types/rendering/fxaa-resolver.d.ts +25 -0
- package/dist/types/rendering/index.d.ts +1 -0
- package/dist/types/rendering/passes/AnnotationsPass.d.ts +1 -0
- package/dist/types/rendering/passes/FXAAPass.d.ts +11 -6
- package/dist/types/rendering/passes/OITRenderPass.d.ts +147 -0
- package/dist/types/rendering/passes/OutputPass.d.ts +9 -0
- package/dist/types/rendering/passes/RenderPass.d.ts +2 -0
- package/dist/types/rendering/passes/index.d.ts +0 -2
- package/dist/types/rendering/smaa-resolver.d.ts +58 -0
- package/dist/types/rendering/taa-resolver.d.ts +161 -0
- package/dist/types/rendering/temporal-resolver.d.ts +152 -0
- package/dist/types/sdk/geometries/boundary-loops.d.ts +38 -0
- package/dist/types/sdk/geometries/geometry-attributes.d.ts +37 -0
- package/dist/types/sdk/geometries/grid-sampling.d.ts +50 -0
- package/dist/types/sdk/geometries/ocean-geometry.d.ts +288 -0
- package/dist/types/sdk/geometries/packing.d.ts +1 -1
- package/dist/types/sdk/geometries/tessellation.d.ts +25 -0
- package/dist/types/sdk/index.d.ts +5 -0
- package/dist/types/sdk/utils/vector-operations.d.ts +7 -0
- package/package.json +9 -10
- package/dist/chunk-61X6qE5N.js +0 -981
- package/dist/chunk-ChG5d4HC.js +0 -675
- package/dist/chunk-DuRASjkF.js +0 -17
- package/dist/chunk-M-Pcc_Yg.js +0 -689
- package/dist/types/rendering/passes/SMAAPass.d.ts +0 -40
- package/dist/types/rendering/passes/TAAPass.d.ts +0 -94
- /package/dist/{shaderLib → src/sdk/materials/shaderLib}/color-conversion.glsl +0 -0
- /package/dist/{shaderLib → src/sdk/materials/shaderLib}/colors.glsl +0 -0
- /package/dist/{shaderLib → src/sdk/materials/shaderLib}/glyphs.glsl +0 -0
- /package/dist/{shaderLib → src/sdk/materials/shaderLib}/oit.glsl +0 -0
- /package/dist/{shaderLib → src/sdk/materials/shaderLib}/random.glsl +0 -0
- /package/dist/{shaderLib → src/sdk/materials/shaderLib}/remap.glsl +0 -0
- /package/dist/{shaderLib → src/sdk/materials/shaderLib}/render-number.glsl +0 -0
- /package/dist/{shaderLib → src/sdk/materials/shaderLib}/render-text.glsl +0 -0
- /package/dist/{shaderLib → src/sdk/materials/shaderLib}/rotation.glsl +0 -0
- /package/dist/{shaderLib → src/sdk/materials/shaderLib}/sdf-functions.glsl +0 -0
- /package/dist/textures/{normal_map.jpg → public/normal_map.jpg} +0 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { Camera, Texture, WebGLRenderer, WebGLRenderTarget } from 'three';
|
|
2
|
+
/**
|
|
3
|
+
* Reprojected temporal anti-aliasing (TAA) resolver for the {@link OITRenderPass}.
|
|
4
|
+
*
|
|
5
|
+
* Unlike {@link TemporalResolver} (which only accumulates while the camera is
|
|
6
|
+
* still), this reprojects the history every frame using the depth of the nearest
|
|
7
|
+
* visible surface, so anti-aliasing is retained *during* camera motion. The app's
|
|
8
|
+
* world is effectively static — only the camera moves — so no per-object velocity
|
|
9
|
+
* buffer is required; a depth-only camera reprojection recovers the motion.
|
|
10
|
+
*
|
|
11
|
+
* The reprojection depth is the nearer of the opaque hardware depth and the OIT
|
|
12
|
+
* front-layer's view-space linear depth (passed in from the pass). Transparent
|
|
13
|
+
* surfaces write no hardware depth, so reprojecting them by the opaque depth behind
|
|
14
|
+
* them is precisely what makes a naive TAA ghost transparent content; using the OIT
|
|
15
|
+
* front depth reprojects the visible transparent surface at its true position.
|
|
16
|
+
*
|
|
17
|
+
* Ghosting from content the reprojection cannot follow (additive highlights,
|
|
18
|
+
* animated objects, disocclusions) is bounded in the shader by clamping the
|
|
19
|
+
* reprojected history into the current frame's local 3x3 colour range and by
|
|
20
|
+
* falling back to the current frame where the reprojection lands off-screen. It is
|
|
21
|
+
* offered as an *optional* AA mode alongside `temporal`/`smaa`, not a replacement.
|
|
22
|
+
*
|
|
23
|
+
* Like {@link TemporalResolver}, the owning pass drives it: {@link applyJitter}
|
|
24
|
+
* before the scene render, {@link restoreJitter} + {@link resolve} after. The jitter
|
|
25
|
+
* is applied to the shared camera only between those calls, so it never leaks to
|
|
26
|
+
* later passes.
|
|
27
|
+
*
|
|
28
|
+
* @group Rendering
|
|
29
|
+
* @see {@link OITRenderPass}
|
|
30
|
+
*/
|
|
31
|
+
export declare class TaaResolver {
|
|
32
|
+
/**
|
|
33
|
+
* Number of unique sub-pixel jitter samples to cycle through (the length of the
|
|
34
|
+
* Halton sequence used).
|
|
35
|
+
*/
|
|
36
|
+
sampleCount: number;
|
|
37
|
+
/**
|
|
38
|
+
* History weight when the reprojection is valid (the current frame contributes
|
|
39
|
+
* `1 - feedback`). Higher = smoother/more stable but slower to react and more
|
|
40
|
+
* prone to ghosting; lower = crisper but noisier. Typical range 0.85–0.95.
|
|
41
|
+
*/
|
|
42
|
+
feedback: number;
|
|
43
|
+
/**
|
|
44
|
+
* Per-frame camera motion, in screen pixels (largest reprojected frustum-corner
|
|
45
|
+
* displacement), at/below which the neighbourhood clip is fully relaxed. Below this
|
|
46
|
+
* the camera is treated as still and the reprojected history is trusted verbatim
|
|
47
|
+
* (pure exponential average), so heavily aliased static geometry converges instead
|
|
48
|
+
* of wobbling against a single jittered frame's colour box.
|
|
49
|
+
*/
|
|
50
|
+
stillPixelThreshold: number;
|
|
51
|
+
/**
|
|
52
|
+
* Camera motion, in screen pixels, at/above which the neighbourhood clip is fully
|
|
53
|
+
* applied (history clipped into the current frame's local colour range, bounding
|
|
54
|
+
* ghosting from disocclusions and untrackable content). Between this and
|
|
55
|
+
* {@link stillPixelThreshold} the clip strength ramps smoothly, so there is no pop
|
|
56
|
+
* as the camera starts or stops moving.
|
|
57
|
+
*/
|
|
58
|
+
motionPixelThreshold: number;
|
|
59
|
+
/**
|
|
60
|
+
* Neighbourhood-clip strength retained while the camera is *still* (the floor the
|
|
61
|
+
* motion ramp starts from). **Default 0.2** — a low floor that stays firmly on the
|
|
62
|
+
* static-favoured side of the scale: heavily aliased near-Nyquist detail still
|
|
63
|
+
* converges to a near-supersampled result, while a touch of clip already bounds the
|
|
64
|
+
* worst ghost trails. Raise it (typically 0.6-0.9) to more aggressively suppress the
|
|
65
|
+
* trail an object animating under a still camera leaves — its history lands far
|
|
66
|
+
* outside the current frame's local colour box and is pulled in, while correctly
|
|
67
|
+
* converged static geometry (whose history sits *inside* the box, widened by
|
|
68
|
+
* {@link restBoxGamma}/{@link restNeighbourhoodRadius} for exactly this reason) is
|
|
69
|
+
* left untouched. 0 trusts history verbatim at rest; 1 clips fully even when still.
|
|
70
|
+
* Camera-motion protection is unaffected by this floor — the clip still ramps up on
|
|
71
|
+
* motion regardless.
|
|
72
|
+
*/
|
|
73
|
+
restClampStrength: number;
|
|
74
|
+
/**
|
|
75
|
+
* Neighbourhood colour-box half-width (in sigmas) used while the camera is still.
|
|
76
|
+
* Wider than {@link motionBoxGamma} so a converged near-Nyquist feature stays inside
|
|
77
|
+
* the box (the rest clip is then a no-op on it) while a moving object's history is
|
|
78
|
+
* still caught.
|
|
79
|
+
*/
|
|
80
|
+
restBoxGamma: number;
|
|
81
|
+
/** Neighbourhood colour-box half-width (in sigmas) used while the camera moves. */
|
|
82
|
+
motionBoxGamma: number;
|
|
83
|
+
/**
|
|
84
|
+
* Neighbourhood sampling stride (in texels) used while the camera is still. Wider
|
|
85
|
+
* than {@link motionNeighbourhoodRadius} so a field of thin bars is always
|
|
86
|
+
* represented in the box and its converged value is not falsely rejected.
|
|
87
|
+
*/
|
|
88
|
+
restNeighbourhoodRadius: number;
|
|
89
|
+
/** Neighbourhood sampling stride (in texels) used while the camera moves. */
|
|
90
|
+
motionNeighbourhoodRadius: number;
|
|
91
|
+
private historyRead;
|
|
92
|
+
private historyWrite;
|
|
93
|
+
private resolveMaterial;
|
|
94
|
+
private blitMaterial;
|
|
95
|
+
private fullscreenRenderer;
|
|
96
|
+
private width;
|
|
97
|
+
private height;
|
|
98
|
+
/** Index into the jitter sequence for the current frame. */
|
|
99
|
+
private sampleIndex;
|
|
100
|
+
/** False until the first frame has been accumulated (and after a resize). */
|
|
101
|
+
private hasHistory;
|
|
102
|
+
/** True while a sub-pixel jitter is applied to the shared camera projection. */
|
|
103
|
+
private jittered;
|
|
104
|
+
/** The camera the jitter was applied to (restored in {@link restoreJitter}). */
|
|
105
|
+
private camera;
|
|
106
|
+
/** Snapshot of the clean projection matrix, restored exactly after the render. */
|
|
107
|
+
private savedProjection;
|
|
108
|
+
/** Snapshot of the clean projection inverse, restored alongside the projection. */
|
|
109
|
+
private savedProjectionInverse;
|
|
110
|
+
/** Scratch: current (un-jittered) world-space view-projection. */
|
|
111
|
+
private curViewProj;
|
|
112
|
+
/** Previous frame's (un-jittered) world-space view-projection (world -> clip). */
|
|
113
|
+
private prevViewProj;
|
|
114
|
+
/** Inverse of the previous frame's view-projection (clip -> world), for motion. */
|
|
115
|
+
private prevViewProjInverse;
|
|
116
|
+
/** Scratch: `curViewProj * prevViewProjInverse` (prev NDC -> cur NDC). */
|
|
117
|
+
private motionMatrix;
|
|
118
|
+
/** Scratch vector reused while reprojecting the frustum corners. */
|
|
119
|
+
private motionScratch;
|
|
120
|
+
constructor(sampleCount?: number, feedback?: number);
|
|
121
|
+
setSize(width: number, height: number): void;
|
|
122
|
+
/** Force the accumulation to restart on the next frame. */
|
|
123
|
+
reset(): void;
|
|
124
|
+
/**
|
|
125
|
+
* Apply this frame's sub-pixel jitter to the camera projection. Called by the
|
|
126
|
+
* owning pass immediately before it renders the scene; paired with
|
|
127
|
+
* {@link restoreJitter} after the render. Reprojection TAA jitters *every* frame
|
|
128
|
+
* (the history is reprojected, so a still and a moving frame are treated the
|
|
129
|
+
* same), unlike the still-only temporal accumulation.
|
|
130
|
+
*/
|
|
131
|
+
applyJitter(camera: Camera): void;
|
|
132
|
+
/**
|
|
133
|
+
* Restore the camera projection (matrix + cached inverse) to the snapshot taken
|
|
134
|
+
* in {@link applyJitter}. Idempotent and safe to call when no jitter is applied.
|
|
135
|
+
*/
|
|
136
|
+
restoreJitter(): void;
|
|
137
|
+
/**
|
|
138
|
+
* Reproject the running history to the current view and blend it with the freshly
|
|
139
|
+
* composited frame in `buffer`, writing the result back into `buffer`. Must be
|
|
140
|
+
* called after {@link restoreJitter} so the camera matrices are the clean
|
|
141
|
+
* (un-jittered) transform.
|
|
142
|
+
*
|
|
143
|
+
* `frontDepth` is the OIT front-layer's view-space linear depth (normalised by
|
|
144
|
+
* `camera.far`); pass `null` when it was not written this frame (front peel
|
|
145
|
+
* disabled or no transparent content), in which case only the opaque hardware
|
|
146
|
+
* depth is used for reprojection.
|
|
147
|
+
*/
|
|
148
|
+
resolve(renderer: WebGLRenderer, buffer: WebGLRenderTarget, camera: Camera, frontDepth: Texture | null): void;
|
|
149
|
+
/**
|
|
150
|
+
* Per-frame camera-motion amount in `[0, 1]`, used to ramp the neighbourhood clip
|
|
151
|
+
* (strength, box width and sampling stride) between its still and full-motion
|
|
152
|
+
* settings. Builds `M = curViewProj * prevViewProjInverse` (prev NDC -> cur NDC; the
|
|
153
|
+
* identity when the camera is still), reprojects the 8 frustum corners through it and
|
|
154
|
+
* takes the largest corner displacement in pixels, then maps it through a smoothstep
|
|
155
|
+
* from {@link stillPixelThreshold} (0 = still) to {@link motionPixelThreshold}
|
|
156
|
+
* (1 = full motion). Working in NDC/pixels makes it independent of world scale and
|
|
157
|
+
* zoom. Returns 1 on the first frame (before any history exists).
|
|
158
|
+
*/
|
|
159
|
+
private computeMotionAmount;
|
|
160
|
+
dispose(): void;
|
|
161
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { Camera, WebGLRenderer, WebGLRenderTarget } from 'three';
|
|
2
|
+
/**
|
|
3
|
+
* Temporal supersampling resolver for the {@link OITRenderPass}.
|
|
4
|
+
*
|
|
5
|
+
* This is *not* reprojected TAA. Each frame the camera projection is offset by a
|
|
6
|
+
* sub-pixel Halton jitter (so a thin feature lands on different sub-pixel positions
|
|
7
|
+
* over time) and the freshly composited frame is blended into a running history
|
|
8
|
+
* average — but **only while the camera is still**. There is no depth/velocity
|
|
9
|
+
* reprojection: as soon as the camera moves the history is dropped (the current
|
|
10
|
+
* frame is shown), so nothing can ghost. When the camera comes to rest the average
|
|
11
|
+
* accumulates again and the static view converges to a genuinely supersampled
|
|
12
|
+
* image. This is the right trade for an inspection-heavy app (zoom in, hold still)
|
|
13
|
+
* and, crucially, it works identically for opaque, transparent (OIT) and additive
|
|
14
|
+
* content because it never tries to track any of it through motion.
|
|
15
|
+
*
|
|
16
|
+
* The {@link OITRenderPass} owns one of these and drives it: it calls
|
|
17
|
+
* {@link applyJitter} before rendering the scene and {@link restoreJitter} +
|
|
18
|
+
* {@link resolve} afterwards. The jitter is applied to the shared camera only
|
|
19
|
+
* between those two calls (inside the pass's own `render`), so it never leaks to
|
|
20
|
+
* later passes (annotations, picking) or other `useFrame` consumers.
|
|
21
|
+
*
|
|
22
|
+
* @group Rendering
|
|
23
|
+
* @see {@link OITRenderPass}
|
|
24
|
+
*/
|
|
25
|
+
export declare class TemporalResolver {
|
|
26
|
+
/**
|
|
27
|
+
* Number of unique sub-pixel jitter samples to cycle through (the length of the
|
|
28
|
+
* Halton sequence used). Higher spreads coverage over more sub-pixel positions.
|
|
29
|
+
*/
|
|
30
|
+
sampleCount: number;
|
|
31
|
+
/**
|
|
32
|
+
* History weight while the camera is still (the current frame contributes
|
|
33
|
+
* `1 - feedback`). A fixed-feedback exponential average converges to a stable
|
|
34
|
+
* supersampled image without the endless `1 / n` wobble that previously needed a
|
|
35
|
+
* freeze, and - paired with the resolve shader's motion-adaptive rejection - lets
|
|
36
|
+
* content that animates under a still camera blend in immediately instead of
|
|
37
|
+
* freezing. Higher = smoother/slower to react; typical range 0.85-0.95.
|
|
38
|
+
*/
|
|
39
|
+
feedback: number;
|
|
40
|
+
/**
|
|
41
|
+
* Threshold, in screen pixels, on the per-frame motion of the reprojected
|
|
42
|
+
* frustum corners (see {@link NDC_MOTION_CORNERS}) above which the camera is
|
|
43
|
+
* treated as moving (history dropped). Measured directly in pixels, so it behaves
|
|
44
|
+
* identically at any zoom level or scene/world scale. Kept slightly above the
|
|
45
|
+
* sub-pixel residual left by damped camera controls (which otherwise resets the
|
|
46
|
+
* accumulation every few frames as the view settles, pulsing the still image
|
|
47
|
+
* between an aliased and a converged frame). Motion this small is far below any
|
|
48
|
+
* visible blur, so treating it as still is safe. Lower = accumulates sooner after
|
|
49
|
+
* motion stops; higher = tolerates more residual drift before dropping history.
|
|
50
|
+
*/
|
|
51
|
+
motionPixelThreshold: number;
|
|
52
|
+
/**
|
|
53
|
+
* Strength of the anti-ghost neighbourhood clip applied while the camera is still
|
|
54
|
+
* (the mode only accumulates while still). **Default 0.2** — a low floor that stays
|
|
55
|
+
* firmly on the static-favoured side of the scale: the still image still converges
|
|
56
|
+
* to a near-supersampled result, while a touch of clip already bounds the worst fade
|
|
57
|
+
* trails. Raise it (typically 0.6-0.9) to more aggressively suppress the trail an
|
|
58
|
+
* object animating under a still camera leaves — the clip pulls history that lands
|
|
59
|
+
* *far outside* the current frame's local colour box back in. It is a no-op for
|
|
60
|
+
* correctly converged static geometry: the box is deliberately widened (see the
|
|
61
|
+
* resolve shader's `BOX_GAMMA`/`NEIGHBOURHOOD_RADIUS`) so a heavily aliased
|
|
62
|
+
* near-Nyquist feature's converged value stays *inside* it and is never rejected.
|
|
63
|
+
* 0 restores the pure exponential average; 1 clips fully.
|
|
64
|
+
*/
|
|
65
|
+
clampStrength: number;
|
|
66
|
+
private historyRead;
|
|
67
|
+
private historyWrite;
|
|
68
|
+
private resolveMaterial;
|
|
69
|
+
private blitMaterial;
|
|
70
|
+
private fullscreenRenderer;
|
|
71
|
+
private width;
|
|
72
|
+
private height;
|
|
73
|
+
/** Index into the jitter sequence for the current frame. */
|
|
74
|
+
private sampleIndex;
|
|
75
|
+
/** False until the first frame has been accumulated (and after a resize). */
|
|
76
|
+
private hasHistory;
|
|
77
|
+
/**
|
|
78
|
+
* Whether the camera was moving as of the last {@link resolve}. Read by
|
|
79
|
+
* {@link applyJitter} (which runs before motion can be detected for the current
|
|
80
|
+
* frame) to decide whether to jitter: moving frames are shown raw, so jittering
|
|
81
|
+
* them would read as the whole scene shaking. Starts `true` so the very first
|
|
82
|
+
* frame renders at its true position.
|
|
83
|
+
*/
|
|
84
|
+
private moving;
|
|
85
|
+
/**
|
|
86
|
+
* Whether the camera was moving as of the last {@link resolve}. Lets the owning
|
|
87
|
+
* pass restrict a spatial AA pass (SMAA) to moving frames only, leaving the still
|
|
88
|
+
* frames to the temporal accumulation.
|
|
89
|
+
*/
|
|
90
|
+
get isMoving(): boolean;
|
|
91
|
+
/** True while a sub-pixel jitter is applied to the shared camera projection. */
|
|
92
|
+
private jittered;
|
|
93
|
+
/** The camera the jitter was applied to (restored in {@link restoreJitter}). */
|
|
94
|
+
private camera;
|
|
95
|
+
/** Snapshot of the clean projection matrix, restored exactly after the render. */
|
|
96
|
+
private savedProjection;
|
|
97
|
+
/** Snapshot of the clean projection inverse, restored alongside the projection. */
|
|
98
|
+
private savedProjectionInverse;
|
|
99
|
+
/** Scratch: current (un-jittered) view-projection, for motion detection. */
|
|
100
|
+
private curViewProj;
|
|
101
|
+
/** Inverse of the previous frame's (un-jittered) view-projection. */
|
|
102
|
+
private prevViewProjInverse;
|
|
103
|
+
/** Scratch: `curViewProj * prevViewProjInverse` (prev NDC -> cur NDC). */
|
|
104
|
+
private motionMatrix;
|
|
105
|
+
/** Scratch vector reused while reprojecting the frustum corners. */
|
|
106
|
+
private motionScratch;
|
|
107
|
+
constructor(sampleCount?: number, feedback?: number);
|
|
108
|
+
setSize(width: number, height: number): void;
|
|
109
|
+
/** Force the accumulation to restart on the next frame. */
|
|
110
|
+
reset(): void;
|
|
111
|
+
/**
|
|
112
|
+
* Apply this frame's sub-pixel jitter to the camera projection. Called by the
|
|
113
|
+
* owning pass immediately before it renders the scene; paired with
|
|
114
|
+
* {@link restoreJitter} after the render. The clean projection (matrix + cached
|
|
115
|
+
* inverse) is snapshotted so it can be restored exactly, leaving no drift.
|
|
116
|
+
*
|
|
117
|
+
* The jitter is only applied while the camera is still ({@link moving} is false).
|
|
118
|
+
* While the camera moves, frames are displayed raw (blend = 1), so a per-frame
|
|
119
|
+
* sub-pixel offset would show up as the entire scene shaking; rendering moving
|
|
120
|
+
* frames at their true (un-jittered) position keeps them rock-steady. Sub-pixel
|
|
121
|
+
* coverage is only needed once the view holds still and the average accumulates.
|
|
122
|
+
*/
|
|
123
|
+
applyJitter(camera: Camera): void;
|
|
124
|
+
/**
|
|
125
|
+
* Restore the camera projection (matrix + cached inverse) to the snapshot taken
|
|
126
|
+
* in {@link applyJitter}. Idempotent and safe to call when no jitter is applied.
|
|
127
|
+
*/
|
|
128
|
+
restoreJitter(): void;
|
|
129
|
+
/**
|
|
130
|
+
* Blend the freshly composited frame in `buffer` with the running history and
|
|
131
|
+
* write the result back into `buffer`. Must be called after {@link restoreJitter}
|
|
132
|
+
* so the camera matrices sampled for motion detection are the clean transform.
|
|
133
|
+
*
|
|
134
|
+
* Reads `buffer.texture` as the current frame and writes the average into the
|
|
135
|
+
* history target, then copies that back into `buffer` (an overwrite blit, so the
|
|
136
|
+
* buffer's alpha is replaced rather than blended). The history targets are
|
|
137
|
+
* ping-ponged for the next frame.
|
|
138
|
+
*/
|
|
139
|
+
resolve(renderer: WebGLRenderer, buffer: WebGLRenderTarget, camera: Camera): void;
|
|
140
|
+
/**
|
|
141
|
+
* True when the rendered image moved more than {@link motionPixelThreshold}
|
|
142
|
+
* pixels since the last frame. Builds `M = curViewProj * prevViewProjInverse`,
|
|
143
|
+
* which maps the previous frame's NDC back to the current frame's NDC (the
|
|
144
|
+
* identity when the camera is still), reprojects the 8 frustum corners through it
|
|
145
|
+
* and takes the largest corner displacement converted to pixels. Operating in
|
|
146
|
+
* NDC/pixels makes this independent of world scale and zoom, unlike a raw
|
|
147
|
+
* view-projection matrix delta (whose magnitude grows with camera distance and so
|
|
148
|
+
* goes undetected when zoomed out).
|
|
149
|
+
*/
|
|
150
|
+
private detectMotion;
|
|
151
|
+
dispose(): void;
|
|
152
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { BufferGeometry } from 'three';
|
|
2
|
+
import { Vec2 } from '../types/common';
|
|
3
|
+
/**
|
|
4
|
+
* Extract the boundary loops of an indexed triangle mesh as ordered arrays of
|
|
5
|
+
* vertex indices. A boundary edge is one used by a single triangle, so the
|
|
6
|
+
* loops include both the outer outline and any internal hole rings. Useful for
|
|
7
|
+
* outlining a mesh or relaxing/snapping only its rim vertices.
|
|
8
|
+
*
|
|
9
|
+
* @group Geometries
|
|
10
|
+
*/
|
|
11
|
+
export declare function extractBoundaryLoops(geometry: BufferGeometry): number[][];
|
|
12
|
+
/**
|
|
13
|
+
* Smooth the given vertex loops (e.g. from {@link extractBoundaryLoops}) in
|
|
14
|
+
* place with an iterated windowed moving average, moving only the X/Z position
|
|
15
|
+
* of the existing boundary vertices and leaving their Y untouched. Unlike a
|
|
16
|
+
* local corner-cutting pass (which only rounds individual steps into small
|
|
17
|
+
* arcs), the averaging window spans several vertices, so long grid-aligned
|
|
18
|
+
* staircase runs collapse onto their straight centre line — the rim reads as one
|
|
19
|
+
* continuous curve rather than a chain of little bumps. The window grows with
|
|
20
|
+
* `strength`.
|
|
21
|
+
*
|
|
22
|
+
* @group Geometries
|
|
23
|
+
*/
|
|
24
|
+
export declare function smoothBoundaryLoops(geometry: BufferGeometry, loops: number[][], strength: number): void;
|
|
25
|
+
/**
|
|
26
|
+
* Snap the boundary (rim) vertices of an indexed mesh onto the nearest point of
|
|
27
|
+
* a set of reference polylines (closed world-X/Z outlines). Used to pull a mesh
|
|
28
|
+
* rim exactly onto a shared outline, so two meshes that meet at an edge (e.g. a
|
|
29
|
+
* surface and the floor it bounds) share one rim curve instead of two
|
|
30
|
+
* independently triangulated (and diverging) ones.
|
|
31
|
+
*
|
|
32
|
+
* When `getY` is provided, each snapped rim vertex's Y is also set to
|
|
33
|
+
* `getY(x, z)` at its new position, so the rim can be pinned to a shared height
|
|
34
|
+
* as well as X/Z. When omitted, only X/Z are moved and Y is left as-is.
|
|
35
|
+
*
|
|
36
|
+
* @group Geometries
|
|
37
|
+
*/
|
|
38
|
+
export declare function snapBoundaryToOutline(geometry: BufferGeometry, polylines: Vec2[][], getY?: (x: number, z: number) => number): void;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { BufferGeometry } from 'three';
|
|
2
|
+
import { Vec2 } from '../types/common';
|
|
3
|
+
/**
|
|
4
|
+
* Assemble an indexed {@link BufferGeometry} from flat `position`, `normal` and
|
|
5
|
+
* `uv` arrays plus a triangle index list. The index buffer is automatically
|
|
6
|
+
* `Uint16Array` or `Uint32Array` depending on the vertex count, and bounding
|
|
7
|
+
* volumes are computed. Optional draw `groups` (`[start, count, materialIndex]`)
|
|
8
|
+
* may be supplied for multi-material meshes.
|
|
9
|
+
*
|
|
10
|
+
* @group Geometries
|
|
11
|
+
*/
|
|
12
|
+
export declare function createIndexedGeometry(positions: ArrayLike<number>, normals: ArrayLike<number>, uvs: ArrayLike<number>, indices: ArrayLike<number>, groups?: number[][] | null): BufferGeometry;
|
|
13
|
+
/**
|
|
14
|
+
* Rotate a geometry about the +Y axis by `degrees`, pivoting around `origin`
|
|
15
|
+
* (world X/Z, default `[0, 0]`). Both the position and normal attributes are
|
|
16
|
+
* rotated. A no-op when `degrees` is 0. Bounding volumes are refreshed.
|
|
17
|
+
*
|
|
18
|
+
* @group Geometries
|
|
19
|
+
*/
|
|
20
|
+
export declare function rotateGeometryY(geometry: BufferGeometry, degrees: number, origin?: Vec2): void;
|
|
21
|
+
/**
|
|
22
|
+
* Set per-vertex UVs in `[0, 1]` from the X/Z bounding box of the geometry,
|
|
23
|
+
* giving a planar projection onto the world X/Z plane (suitable for flat or
|
|
24
|
+
* near-flat meshes such as terrain, water and ground planes).
|
|
25
|
+
*
|
|
26
|
+
* @group Geometries
|
|
27
|
+
*/
|
|
28
|
+
export declare function computePlanarXZUv(geometry: BufferGeometry): void;
|
|
29
|
+
/**
|
|
30
|
+
* Compute smooth vertex normals and ensure they point up (+Y). After a height
|
|
31
|
+
* field is mirrored through `y = 0` or comes from an arbitrary triangulation the
|
|
32
|
+
* winding may yield downward normals; if so the index winding is reversed and
|
|
33
|
+
* the normals recomputed. Bounding volumes are refreshed.
|
|
34
|
+
*
|
|
35
|
+
* @group Geometries
|
|
36
|
+
*/
|
|
37
|
+
export declare function computeUpwardNormals(geometry: BufferGeometry): void;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { BufferGeometry } from 'three';
|
|
2
|
+
/**
|
|
3
|
+
* Flag the invalid samples of a row-major grid that are connected (4-neighbour)
|
|
4
|
+
* to the grid border, returning a mask where `1` marks a border-connected
|
|
5
|
+
* ("external") invalid sample. Invalid samples fully enclosed by valid data
|
|
6
|
+
* (internal holes) are left as `0`, so the caller can distinguish the outer rim
|
|
7
|
+
* of a footprint from holes punched inside it (e.g. to fill the latter while
|
|
8
|
+
* keeping the former as the true outline).
|
|
9
|
+
*
|
|
10
|
+
* @param values row-major grid of length `nx * ny`
|
|
11
|
+
* @param nx number of columns
|
|
12
|
+
* @param ny number of rows
|
|
13
|
+
* @param isInvalid predicate marking a sample value as missing/hole
|
|
14
|
+
*
|
|
15
|
+
* @group Geometries
|
|
16
|
+
*/
|
|
17
|
+
export declare function floodFillExternalHoles(values: ArrayLike<number>, nx: number, ny: number, isInvalid: (v: number) => boolean): Uint8Array;
|
|
18
|
+
/**
|
|
19
|
+
* Bilinear sample of a row-major grid that ignores hole/invalid samples: only
|
|
20
|
+
* the valid corners contribute (re-normalised by their weights). Sampling on or
|
|
21
|
+
* just outside a footprint outline therefore returns the true edge value instead
|
|
22
|
+
* of blending in a far-away `fallback`. When all four corners are invalid the
|
|
23
|
+
* nearest valid sample (within a small search radius) is used, falling back to
|
|
24
|
+
* `fallback` only if none is found nearby.
|
|
25
|
+
*
|
|
26
|
+
* @param fx fractional column coordinate (`worldX / cellW`)
|
|
27
|
+
* @param fz fractional row coordinate (`worldZ / cellH`)
|
|
28
|
+
*
|
|
29
|
+
* @group Geometries
|
|
30
|
+
*/
|
|
31
|
+
export declare function sampleValidGrid(values: ArrayLike<number>, nx: number, ny: number, fx: number, fz: number, isInvalid: (v: number) => boolean, fallback: number): number;
|
|
32
|
+
/**
|
|
33
|
+
* Build a flat plane at `y = 0` covering the cells of a regular grid for which a
|
|
34
|
+
* `present` predicate holds at all four corners, so the plane follows the
|
|
35
|
+
* outline of an arbitrary (possibly holed) footprint rather than a plain
|
|
36
|
+
* rectangle. Unused grid vertices are dropped (compacted) so the result can be
|
|
37
|
+
* cheaply subdivided afterwards. UVs span `[0, 1]` across the full grid extent.
|
|
38
|
+
*
|
|
39
|
+
* @param nx number of columns of grid vertices
|
|
40
|
+
* @param ny number of rows of grid vertices
|
|
41
|
+
* @param cellW column spacing in world units
|
|
42
|
+
* @param cellH row spacing in world units
|
|
43
|
+
* @param present `(c, r) => boolean`, whether the grid vertex at column `c`,
|
|
44
|
+
* row `r` lies inside the footprint
|
|
45
|
+
* @param originX world X of column 0 (default 0)
|
|
46
|
+
* @param originZ world Z of row 0 (default 0)
|
|
47
|
+
*
|
|
48
|
+
* @group Geometries
|
|
49
|
+
*/
|
|
50
|
+
export declare function buildMaskedGridPlane(nx: number, ny: number, cellW: number, cellH: number, present: (c: number, r: number) => boolean, originX?: number, originZ?: number): BufferGeometry;
|