@equinor/videx-3d 1.1.1 → 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.
Files changed (74) hide show
  1. package/README.md +120 -120
  2. package/dist/chunk-DKAquGKk.js +2820 -0
  3. package/dist/chunk-DsUZyEG_.js +16 -0
  4. package/dist/generators.js +512 -716
  5. package/dist/main.js +6909 -8947
  6. package/dist/sdk.js +2 -785
  7. package/dist/src/sdk/materials/shaderLib/oit.glsl +106 -0
  8. package/dist/types/components/Annotations/AutoUpdate.d.ts +1 -1
  9. package/dist/types/components/Annotations/index.d.ts +2 -2
  10. package/dist/types/components/Annotations/types.d.ts +3 -1
  11. package/dist/types/components/Annotations/update-annotations.d.ts +10 -0
  12. package/dist/types/components/EventEmitter/picking-helper.d.ts +23 -1
  13. package/dist/types/components/Ocean/Ocean.d.ts +333 -0
  14. package/dist/types/components/Ocean/index.d.ts +6 -0
  15. package/dist/types/components/Ocean/ocean-bed-material.d.ts +60 -0
  16. package/dist/types/components/Ocean/ocean-contact.d.ts +39 -0
  17. package/dist/types/components/Ocean/ocean-material.d.ts +145 -0
  18. package/dist/types/components/Ocean/ocean-sampler.d.ts +93 -0
  19. package/dist/types/components/Ocean/ocean-volume-material.d.ts +54 -0
  20. package/dist/types/components/Surfaces/Surface.d.ts +8 -1
  21. package/dist/types/components/Surfaces/SurfaceMaterial.d.ts +3 -0
  22. package/dist/types/components/Surfaces/surface-defs.d.ts +1 -0
  23. package/dist/types/components/Tanker/Tanker.d.ts +47 -0
  24. package/dist/types/components/Tanker/TankerSuperstructure.d.ts +23 -0
  25. package/dist/types/components/Tanker/tanker-geometry-builder.d.ts +21 -0
  26. package/dist/types/generators/surface-generator.d.ts +1 -1
  27. package/dist/types/layers/layers.d.ts +4 -0
  28. package/dist/types/main.d.ts +1 -0
  29. package/dist/types/rendering/OitMaterial.d.ts +59 -0
  30. package/dist/types/rendering/Pass.d.ts +16 -0
  31. package/dist/types/rendering/RenderingPipeline.d.ts +46 -0
  32. package/dist/types/rendering/debug/DebugBoxOutputPass.d.ts +22 -0
  33. package/dist/types/rendering/debug/DebugPatternPass.d.ts +30 -0
  34. package/dist/types/rendering/fullscreen-renderer.d.ts +1 -0
  35. package/dist/types/rendering/fxaa-resolver.d.ts +25 -0
  36. package/dist/types/rendering/gpu-timer.d.ts +46 -0
  37. package/dist/types/rendering/index.d.ts +8 -1
  38. package/dist/types/rendering/oit-material.d.ts +122 -0
  39. package/dist/types/{components/Annotations/annotations-renderer.d.ts → rendering/passes/AnnotationsPass.d.ts} +14 -4
  40. package/dist/types/rendering/passes/FXAAPass.d.ts +17 -0
  41. package/dist/types/rendering/passes/OITRenderPass.d.ts +429 -0
  42. package/dist/types/rendering/passes/OutputPass.d.ts +19 -0
  43. package/dist/types/rendering/passes/RenderPass.d.ts +10 -0
  44. package/dist/types/rendering/passes/index.d.ts +4 -0
  45. package/dist/types/rendering/rendering-state.d.ts +59 -0
  46. package/dist/types/rendering/smaa-resolver.d.ts +58 -0
  47. package/dist/types/rendering/taa-resolver.d.ts +161 -0
  48. package/dist/types/rendering/temporal-resolver.d.ts +152 -0
  49. package/dist/types/sdk/geometries/boundary-loops.d.ts +38 -0
  50. package/dist/types/sdk/geometries/geometry-attributes.d.ts +37 -0
  51. package/dist/types/sdk/geometries/grid-sampling.d.ts +50 -0
  52. package/dist/types/sdk/geometries/ocean-geometry.d.ts +288 -0
  53. package/dist/types/sdk/geometries/packing.d.ts +1 -1
  54. package/dist/types/sdk/geometries/tessellation.d.ts +25 -0
  55. package/dist/types/sdk/index.d.ts +5 -0
  56. package/dist/types/sdk/utils/elevation-map.d.ts +23 -0
  57. package/dist/types/sdk/utils/trigonometry.d.ts +4 -1
  58. package/dist/types/sdk/utils/vector-operations.d.ts +7 -0
  59. package/package.json +9 -10
  60. package/dist/chunk-BlPg4RjP.js +0 -689
  61. package/dist/chunk-CnY6Tmof.js +0 -358
  62. package/dist/chunk-DuRASjkF.js +0 -17
  63. package/dist/chunk-iY0wQ9Z6.js +0 -887
  64. package/dist/types/rendering/render-passes.d.ts +0 -16
  65. /package/dist/{shaderLib → src/sdk/materials/shaderLib}/color-conversion.glsl +0 -0
  66. /package/dist/{shaderLib → src/sdk/materials/shaderLib}/colors.glsl +0 -0
  67. /package/dist/{shaderLib → src/sdk/materials/shaderLib}/glyphs.glsl +0 -0
  68. /package/dist/{shaderLib → src/sdk/materials/shaderLib}/random.glsl +0 -0
  69. /package/dist/{shaderLib → src/sdk/materials/shaderLib}/remap.glsl +0 -0
  70. /package/dist/{shaderLib → src/sdk/materials/shaderLib}/render-number.glsl +0 -0
  71. /package/dist/{shaderLib → src/sdk/materials/shaderLib}/render-text.glsl +0 -0
  72. /package/dist/{shaderLib → src/sdk/materials/shaderLib}/rotation.glsl +0 -0
  73. /package/dist/{shaderLib → src/sdk/materials/shaderLib}/sdf-functions.glsl +0 -0
  74. /package/dist/textures/{normal_map.jpg → public/normal_map.jpg} +0 -0
@@ -0,0 +1,106 @@
1
+ // Order-independent transparency (OIT) shared shader chunk.
2
+ //
3
+ // Provides the uniforms and the per-pass output logic used by the OITRenderPass
4
+ // hybrid pipeline (exact depth-peeled front layer + weighted-blended OIT tail).
5
+ //
6
+ // Usage (library ShaderMaterials, GLSL1 / gl_FragColor):
7
+ // #include <this file> // brings uniforms + oitProcess()
8
+ // ...
9
+ // gl_FragColor = ...; // compute final straight (non-premultiplied) color
10
+ // #ifdef USE_OIT
11
+ // gl_FragColor = oitProcess(gl_FragColor);
12
+ // #endif
13
+ //
14
+ // The fragment shader must have `vViewPosition` (view-space position) available.
15
+ //
16
+ // Pass selection is driven by defines set on the per-pass variant materials:
17
+ // USE_OIT enables the whole block
18
+ // OIT_DEPTH_PASS min-depth pre-pass (writes linear view-space depth)
19
+ // OIT_FRONT_PASS exact front layer (alpha-over, discards tail fragments)
20
+ // (none of the above, USE_OIT only) => single-buffer weighted-blended OIT tail
21
+ //
22
+ // The WBOIT tail uses a single RGBA16F accumulation target with optical-depth
23
+ // weighting: each fragment contributes weight b = -ln(1 - alpha), so
24
+ // accum.rgb = sum(rgb * b), accum.a = sum(b).
25
+ // The composite recovers the weighted-average colour as accum.rgb / accum.a and the
26
+ // coverage as 1 - exp(-accum.a) = 1 - prod(1 - alpha) -- identical to a separate
27
+ // (ZERO, ONE_MINUS_SRC_COLOR) reveal pass, but without the extra rasterisation.
28
+ //
29
+ // The `oitSkipFront` uniform (1) disables front peeling so the tail pass keeps the
30
+ // front fragments too (debug: everything resolved through WBOIT).
31
+
32
+ #ifdef USE_OIT
33
+
34
+ uniform float oitDepthFar; // normalisation factor for view-space depth
35
+ uniform vec2 oitScreenSize; // render target size in pixels
36
+ uniform sampler2D oitMinDepthTexture; // per-pixel min linear depth (front layer)
37
+ uniform int oitSkipFront; // 1 = disable front peeling (debug: all WBOIT)
38
+ uniform float oitOcclusionThreshold; // occlusion-stamp pass: min alpha to write depth
39
+
40
+ // Process the straight (non-premultiplied) fragment color for the active pass.
41
+ vec4 oitProcess(vec4 color) {
42
+ #ifdef OIT_OCCLUSION_PASS
43
+ // Occlusion depth stamp: write depth only where this surface is opaque enough
44
+ // (its own alpha clears the threshold). Colour writes are disabled on the
45
+ // variant, so the returned colour is ignored; discarding skips the depth write.
46
+ // Lets sufficiently-opaque transparent surfaces occlude annotation labels even
47
+ // though they don't write depth in the regular OIT passes.
48
+ if(color.a < oitOcclusionThreshold)
49
+ discard;
50
+ return color;
51
+ #endif
52
+
53
+ // View-space linear depth, normalised. Independent of the (logarithmic) depth
54
+ // buffer encoding, so the partition is correct at any camera scale.
55
+ float linZ = abs(vViewPosition.z) / oitDepthFar;
56
+
57
+ #ifdef OIT_DEPTH_PASS
58
+
59
+ // Written into an R32F target with MinEquation blending => per-pixel minimum.
60
+ return vec4(linZ, 0.0, 0.0, 1.0);
61
+
62
+ #else
63
+
64
+ // Gradient-relative tolerance: only the surface that produced the per-pixel
65
+ // minimum qualifies as "front". A fixed epsilon would form a depth slab and let
66
+ // distinct surfaces grazing within it bleed into each other.
67
+ vec2 uv = gl_FragCoord.xy / oitScreenSize;
68
+ float minZ = texture2D(oitMinDepthTexture, uv).r;
69
+ // Depth-relative tolerance. The min-depth pre-pass and this pass rasterise the
70
+ // SAME geometry with the SAME vertex transform, so the genuine front fragment's
71
+ // linZ matches the stored minZ to near bit-exactness; a tiny epsilon suffices.
72
+ // Avoid fwidth(linZ) here: at self-overlap silhouettes the 2x2 derivative quads
73
+ // straddle the depth discontinuity between layers, so fwidth spikes and inflates
74
+ // the tolerance, misclassifying back-layer fragments as front (visible edges).
75
+ float tol = minZ * 1e-3 + 1e-6;
76
+ bool isFront = (linZ - minZ) <= tol;
77
+
78
+ #ifdef OIT_FRONT_PASS
79
+
80
+ // Exact front layer: keep only the nearest fragment, blended alpha-over.
81
+ if(!isFront)
82
+ discard;
83
+ return color;
84
+
85
+ #else
86
+
87
+ // Tail pass: exclude the front fragment (handled exactly by the front pass),
88
+ // unless front peeling is disabled (debug: every fragment goes through WBOIT).
89
+ if(isFront && oitSkipFront == 0)
90
+ discard;
91
+
92
+ float alpha = color.a;
93
+
94
+ // Optical-depth weight b = -ln(1 - alpha). Additive (ONE, ONE) blending then gives
95
+ // accum.rgb = sum(rgb * b), accum.a = sum(b). The composite reconstructs both the
96
+ // weighted-average colour (accum.rgb / accum.a) and the coverage
97
+ // (1 - exp(-accum.a) = 1 - prod(1 - alpha)) from this single buffer, so no separate
98
+ // reveal pass is needed. alpha is clamped below 1 to keep b finite.
99
+ float b = -log(1.0 - clamp(alpha, 0.0, 0.9999));
100
+ return vec4(color.rgb * b, b);
101
+
102
+ #endif // OIT_FRONT_PASS
103
+ #endif // OIT_DEPTH_PASS
104
+ }
105
+
106
+ #endif // USE_OIT
@@ -1,3 +1,3 @@
1
1
  export declare const AutoUpdate: ({ maxVisible }: {
2
2
  maxVisible: number;
3
- }) => null;
3
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -1,8 +1,8 @@
1
1
  import { Vec3 } from '../../sdk';
2
2
  import { AnnotationProps } from './types';
3
+ export * from '../../rendering/passes/AnnotationsPass';
3
4
  export * from './Annotations';
4
- export * from './annotations-renderer';
5
5
  export * from './annotations-state';
6
6
  export * from './AnnotationsLayer';
7
7
  export * from './types';
8
- export declare const getAnnotationPosition: (annotation: AnnotationProps) => Vec3;
8
+ export declare const getAnnotationPosition: (annotation: AnnotationProps, target?: Vec3) => Vec3;
@@ -55,7 +55,7 @@ export type AnnotationInstanceState = {
55
55
  kill?: boolean;
56
56
  cooldown?: number;
57
57
  opacity?: number;
58
- labelWidht: number;
58
+ labelWidth: number;
59
59
  labelHeight: number;
60
60
  labelX?: number;
61
61
  labelY?: number;
@@ -68,6 +68,8 @@ export type AnnotationInstanceState = {
68
68
  _zIndex?: string;
69
69
  _transform?: string;
70
70
  _needsUpdate?: boolean;
71
+ _connPrevX?: number;
72
+ _connPrevY?: number;
71
73
  };
72
74
  export type AnnotationInstance = {
73
75
  id: string;
@@ -1,6 +1,16 @@
1
1
  import { Clock, PerspectiveCamera } from 'three';
2
2
  import { Vec2 } from '../../sdk';
3
3
  import { AnnotationInstance } from './types';
4
+ /**
5
+ * Activity flags updated by preprocessInstances each frame. Used by
6
+ * AnnotationsPass to skip the expensive post-process/overlay work when the
7
+ * scene is settled (camera static and no animations in progress).
8
+ */
9
+ export declare const annotationsActivity: {
10
+ animating: boolean;
11
+ positionChanged: boolean;
12
+ deltaTime: number;
13
+ };
4
14
  /**
5
15
  * PRE-PROCESS INSTANCES
6
16
  */
@@ -19,10 +19,26 @@ export declare class PickingHelper {
19
19
  private _radius;
20
20
  private _pbo;
21
21
  private _buffer;
22
+ private _prevClearColor;
22
23
  private _material;
24
+ /**
25
+ * Dedicated camera used for the picking render so the shared scene camera is
26
+ * never mutated. `setViewOffset` rebuilds a camera's projection (it remaps the
27
+ * frustum to the tiny patch under the cursor), and that mutation would clobber
28
+ * any external modification of the real camera's projection — e.g. the
29
+ * sub-pixel jitter a TAA pass bakes in. Each pick this camera is `copy()`d from
30
+ * the real camera (which faithfully mirrors `matrixWorld`,
31
+ * `matrixWorldInverse`, the projection and all intrinsics) and the view offset
32
+ * is applied here instead. `matrixWorldAutoUpdate` is disabled so the renderer
33
+ * uses the copied world matrix verbatim rather than recomputing it.
34
+ */
35
+ private _camera;
23
36
  private _listeners;
24
37
  private _emitters;
25
- private _currentObjectMap;
38
+ private _mapStarts;
39
+ private _mapObjectIds;
40
+ private _objectMapLength;
41
+ private _objectMapCount;
26
42
  constructor(options?: {});
27
43
  private traverseObject;
28
44
  updateListeners: () => void;
@@ -30,6 +46,12 @@ export declare class PickingHelper {
30
46
  getListener: (id: number) => Listener | undefined;
31
47
  removeListener: (id: number) => void;
32
48
  render(pointer: Vector2, renderer: WebGLRenderer, scene: Scene, camera: PerspectiveCamera): Promise<PickResult>;
49
+ /**
50
+ * Locate the emitter owning a flat id via binary search. Emitter ranges are
51
+ * contiguous and sorted by start, so the owner is the rightmost entry whose
52
+ * start is `<= flatId`.
53
+ */
54
+ private findEmitterIndex;
33
55
  private pick;
34
56
  dispose(): void;
35
57
  }
@@ -0,0 +1,333 @@
1
+ import { ReactNode } from 'react';
2
+ import { BufferGeometry, Group } from 'three';
3
+ import { CommonComponentProps, CustomMaterialProps } from '../../common/types';
4
+ import { Vec2, Vec3 } from '../../sdk/types/common';
5
+ /**
6
+ * Ocean props
7
+ * @expand
8
+ */
9
+ export type OceanProps = CommonComponentProps & CustomMaterialProps & {
10
+ /**
11
+ * Geometry to render as the ocean surface. Typically a large plane lying in
12
+ * the world X/Z plane at sea level (e.g. `createOceanBox(...).surface`). All
13
+ * wave/foam animation is evaluated in world coordinates, so tiled/patched
14
+ * geometry aligns seamlessly.
15
+ */
16
+ geometry: BufferGeometry;
17
+ /**
18
+ * Optional water-body (side walls) geometry, e.g.
19
+ * `createOceanBox(...).body`. When provided, it is rendered as a separate,
20
+ * double-sided, transparent-blue volume mesh so the water reads as a body.
21
+ */
22
+ bodyGeometry?: BufferGeometry;
23
+ /**
24
+ * Optional sea-bed geometry, e.g. `createOceanBox(...).bed`. When provided,
25
+ * it is rendered as a separate sun-shaded mesh below the surface.
26
+ */
27
+ bedGeometry?: BufferGeometry;
28
+ /** Wind direction in world X/Z (drives wave + foam direction). */
29
+ windDirection?: Vec2;
30
+ /**
31
+ * Wind speed in m/s (U10). Primary driver of the sea state: wave height,
32
+ * wavelength and foam all follow North-Sea JONSWAP/Pierson-Moskowitz
33
+ * relations (e.g. ~10 m/s ⇒ Hs ~ 2.1 m, peak wavelength ~ 88 m).
34
+ */
35
+ windSpeed?: number;
36
+ /** Wave height multiplier on top of the spectrum's physical Hs. */
37
+ amplitude?: number;
38
+ /** Angular spread (radians) of the wave directions around the wind. */
39
+ directionalSpread?: number;
40
+ /** Apparent surface choppiness (normal exaggeration / Gerstner sharpness). */
41
+ steepness?: number;
42
+ /**
43
+ * Enables vertex displacement (`false` = off / flat, per-pixel normals
44
+ * only). Off by default; at oilfield scale real displacement is
45
+ * imperceptible except very close to the surface, where only the longest
46
+ * swells displace. Mainly useful to let floating objects follow the surface
47
+ * height.
48
+ */
49
+ displacement?: boolean;
50
+ /** Number of summed spectral wave components (compile-time). */
51
+ waveCount?: number;
52
+ /** Number of FBM micro-ripple octaves (compile-time). */
53
+ detailOctaves?: number;
54
+ /** Deep water colour (seen looking straight down). */
55
+ deepColor?: string;
56
+ /** Shallow/scatter water colour (seen at grazing angles). */
57
+ shallowColor?: string;
58
+ /** Base body opacity looking straight down (0 = clear, 1 = opaque). */
59
+ waterOpacity?: number;
60
+ /** Strength of the large-scale tonal variation (currents / slicks), 0 = off. */
61
+ tonalVariation?: number;
62
+ /** Approximate size of the tonal variation patches, in kilometers. */
63
+ tonalScale?: number;
64
+ /** Crispness of the tonal variation patch edges (0 = soft, 1 = hard). */
65
+ tonalSharpness?: number;
66
+ /** Colour the water drifts toward in the tonal variation (current / algae / pollution tint). */
67
+ tonalColor?: string;
68
+ /** Zenith sky colour used for the procedural reflection. */
69
+ skyColor?: string;
70
+ /** Horizon sky colour used for the procedural reflection. */
71
+ horizonColor?: string;
72
+ /** Reflection intensity multiplier. */
73
+ reflectionIntensity?: number;
74
+ /** Sun direction in world space (specular highlight + reflected glow). */
75
+ sunDirection?: Vec3;
76
+ /** Sun colour. */
77
+ sunColor?: string;
78
+ /** Sun specular shininess exponent. */
79
+ sunShininess?: number;
80
+ /** Foam colour. */
81
+ foamColor?: string;
82
+ /** Foam amount, 0 = none. */
83
+ foamAmount?: number;
84
+ /** Fresnel exponent (higher = reflections concentrated near the horizon). */
85
+ fresnelPower?: number;
86
+ /** Micro-ripple frequency (waves per world unit) for close-up detail. */
87
+ detailScale?: number;
88
+ /** Micro-ripple normal strength. */
89
+ detailStrength?: number;
90
+ /**
91
+ * Sea-bed base (sandy/yellowish) colour. Only used when `bedGeometry` is
92
+ * provided. Default `#b8a06a`.
93
+ */
94
+ seaBedColor?: string;
95
+ /**
96
+ * Strength of the water-colour tint applied to the water-facing (top) side
97
+ * of the sea bed (0..1). Only used when `bedGeometry` is provided.
98
+ */
99
+ seaBedWaterTint?: number;
100
+ /**
101
+ * Sea-bed opacity (0..1). Only used when `bedGeometry` is provided. The sea
102
+ * bed is OIT-routed, so values below 1 let the subsurface geometry below it
103
+ * show through; 1 (default) makes it a solid occluder.
104
+ */
105
+ seaBedOpacity?: number;
106
+ /**
107
+ * Sea-bed sand-dune relief strength (0 = off). Only used when `bedGeometry`
108
+ * is provided. Perturbs the bed's shading normal by a procedural,
109
+ * footprint-anti-aliased dune height field, adding a subtle sense of depth
110
+ * and scale that resolves up close and fades to flat far out. Default 0.15.
111
+ */
112
+ seaBedDuneStrength?: number;
113
+ /**
114
+ * Base sand-dune crest spacing in meters. Only used when `bedGeometry` is
115
+ * provided. Default 180.
116
+ */
117
+ seaBedDuneWavelength?: number;
118
+ /**
119
+ * Sand-dune ridge direction in world X/Z. Only used when `bedGeometry` is
120
+ * provided. Default `[1, 0.6]`.
121
+ */
122
+ seaBedDuneDirection?: Vec2;
123
+ /**
124
+ * Extra sand-dune crest/trough albedo banding (0 = off). Only used when
125
+ * `bedGeometry` is provided. Lightens the dune crests and darkens the
126
+ * troughs on top of the relief shading for a stronger depth cue; fades out
127
+ * far away like the rest of the dune detail. Default 0.
128
+ */
129
+ seaBedDuneSharpness?: number;
130
+ /**
131
+ * Per-meter tint build-up of the water body. Only used when `bodyGeometry`
132
+ * is provided.
133
+ */
134
+ bodyFogDensity?: number;
135
+ /** Densest water-body tint reached far through the water (0..1). */
136
+ bodyMaxOpacity?: number;
137
+ /** Animated shimmer amount of the water body, 0 = off. */
138
+ bodyShimmer?: number;
139
+ /** Master opacity multiplier (also drives OIT routing). */
140
+ opacity?: number;
141
+ /** Toggles visibility of the water-surface mesh. Default `true`. */
142
+ surfaceVisible?: boolean;
143
+ /**
144
+ * Toggles visibility of the water-body (side walls) mesh. Only has an effect
145
+ * when `bodyGeometry` is provided. Default `true`.
146
+ */
147
+ bodyVisible?: boolean;
148
+ /**
149
+ * Toggles visibility of the sea-bed mesh. Only has an effect when
150
+ * `bedGeometry` is provided. Default `true`.
151
+ */
152
+ bedVisible?: boolean;
153
+ /** Debug: render all ocean materials (surface, body, sea bed) as wireframe. */
154
+ wireframe?: boolean;
155
+ /**
156
+ * Children rendered inside the ocean's group, in its local frame. They
157
+ * receive an {@link OceanSampler} via context (see `useOceanSampler` /
158
+ * `useBuoyancy`) so floating objects (e.g. a vessel) can follow the waves.
159
+ */
160
+ children?: ReactNode;
161
+ };
162
+ /**
163
+ * Stylized animated ocean surface.
164
+ *
165
+ * Renders the provided geometry as a procedurally animated, OIT-compatible
166
+ * water surface. The wave field is sampled from a North-Sea JONSWAP spectrum
167
+ * driven by the wind speed (m/s); the visible waves are reconstructed per-pixel
168
+ * as surface normals (plus a fine micro-ripple layer up close), all evaluated
169
+ * in world X/Z space so the pattern is continuous across tiled patches with no
170
+ * repeating texture assets. Level-of-detail uses per-wave footprint
171
+ * anti-aliasing, so there is no visible LOD ring. Transparency is Fresnel-driven
172
+ * (see-through looking down, reflective at grazing angles) and composites
173
+ * correctly with the other transparent subsurface geometry through the
174
+ * OITRenderPass.
175
+ *
176
+ * @example
177
+ * <Ocean geometry={planeGeometry} windDirection={[1, 0.3]} windSpeed={10} />
178
+ *
179
+ * @group Components
180
+ */
181
+ export declare const Ocean: import('react').ForwardRefExoticComponent<CommonComponentProps & CustomMaterialProps & {
182
+ /**
183
+ * Geometry to render as the ocean surface. Typically a large plane lying in
184
+ * the world X/Z plane at sea level (e.g. `createOceanBox(...).surface`). All
185
+ * wave/foam animation is evaluated in world coordinates, so tiled/patched
186
+ * geometry aligns seamlessly.
187
+ */
188
+ geometry: BufferGeometry;
189
+ /**
190
+ * Optional water-body (side walls) geometry, e.g.
191
+ * `createOceanBox(...).body`. When provided, it is rendered as a separate,
192
+ * double-sided, transparent-blue volume mesh so the water reads as a body.
193
+ */
194
+ bodyGeometry?: BufferGeometry;
195
+ /**
196
+ * Optional sea-bed geometry, e.g. `createOceanBox(...).bed`. When provided,
197
+ * it is rendered as a separate sun-shaded mesh below the surface.
198
+ */
199
+ bedGeometry?: BufferGeometry;
200
+ /** Wind direction in world X/Z (drives wave + foam direction). */
201
+ windDirection?: Vec2;
202
+ /**
203
+ * Wind speed in m/s (U10). Primary driver of the sea state: wave height,
204
+ * wavelength and foam all follow North-Sea JONSWAP/Pierson-Moskowitz
205
+ * relations (e.g. ~10 m/s ⇒ Hs ~ 2.1 m, peak wavelength ~ 88 m).
206
+ */
207
+ windSpeed?: number;
208
+ /** Wave height multiplier on top of the spectrum's physical Hs. */
209
+ amplitude?: number;
210
+ /** Angular spread (radians) of the wave directions around the wind. */
211
+ directionalSpread?: number;
212
+ /** Apparent surface choppiness (normal exaggeration / Gerstner sharpness). */
213
+ steepness?: number;
214
+ /**
215
+ * Enables vertex displacement (`false` = off / flat, per-pixel normals
216
+ * only). Off by default; at oilfield scale real displacement is
217
+ * imperceptible except very close to the surface, where only the longest
218
+ * swells displace. Mainly useful to let floating objects follow the surface
219
+ * height.
220
+ */
221
+ displacement?: boolean;
222
+ /** Number of summed spectral wave components (compile-time). */
223
+ waveCount?: number;
224
+ /** Number of FBM micro-ripple octaves (compile-time). */
225
+ detailOctaves?: number;
226
+ /** Deep water colour (seen looking straight down). */
227
+ deepColor?: string;
228
+ /** Shallow/scatter water colour (seen at grazing angles). */
229
+ shallowColor?: string;
230
+ /** Base body opacity looking straight down (0 = clear, 1 = opaque). */
231
+ waterOpacity?: number;
232
+ /** Strength of the large-scale tonal variation (currents / slicks), 0 = off. */
233
+ tonalVariation?: number;
234
+ /** Approximate size of the tonal variation patches, in kilometers. */
235
+ tonalScale?: number;
236
+ /** Crispness of the tonal variation patch edges (0 = soft, 1 = hard). */
237
+ tonalSharpness?: number;
238
+ /** Colour the water drifts toward in the tonal variation (current / algae / pollution tint). */
239
+ tonalColor?: string;
240
+ /** Zenith sky colour used for the procedural reflection. */
241
+ skyColor?: string;
242
+ /** Horizon sky colour used for the procedural reflection. */
243
+ horizonColor?: string;
244
+ /** Reflection intensity multiplier. */
245
+ reflectionIntensity?: number;
246
+ /** Sun direction in world space (specular highlight + reflected glow). */
247
+ sunDirection?: Vec3;
248
+ /** Sun colour. */
249
+ sunColor?: string;
250
+ /** Sun specular shininess exponent. */
251
+ sunShininess?: number;
252
+ /** Foam colour. */
253
+ foamColor?: string;
254
+ /** Foam amount, 0 = none. */
255
+ foamAmount?: number;
256
+ /** Fresnel exponent (higher = reflections concentrated near the horizon). */
257
+ fresnelPower?: number;
258
+ /** Micro-ripple frequency (waves per world unit) for close-up detail. */
259
+ detailScale?: number;
260
+ /** Micro-ripple normal strength. */
261
+ detailStrength?: number;
262
+ /**
263
+ * Sea-bed base (sandy/yellowish) colour. Only used when `bedGeometry` is
264
+ * provided. Default `#b8a06a`.
265
+ */
266
+ seaBedColor?: string;
267
+ /**
268
+ * Strength of the water-colour tint applied to the water-facing (top) side
269
+ * of the sea bed (0..1). Only used when `bedGeometry` is provided.
270
+ */
271
+ seaBedWaterTint?: number;
272
+ /**
273
+ * Sea-bed opacity (0..1). Only used when `bedGeometry` is provided. The sea
274
+ * bed is OIT-routed, so values below 1 let the subsurface geometry below it
275
+ * show through; 1 (default) makes it a solid occluder.
276
+ */
277
+ seaBedOpacity?: number;
278
+ /**
279
+ * Sea-bed sand-dune relief strength (0 = off). Only used when `bedGeometry`
280
+ * is provided. Perturbs the bed's shading normal by a procedural,
281
+ * footprint-anti-aliased dune height field, adding a subtle sense of depth
282
+ * and scale that resolves up close and fades to flat far out. Default 0.15.
283
+ */
284
+ seaBedDuneStrength?: number;
285
+ /**
286
+ * Base sand-dune crest spacing in meters. Only used when `bedGeometry` is
287
+ * provided. Default 180.
288
+ */
289
+ seaBedDuneWavelength?: number;
290
+ /**
291
+ * Sand-dune ridge direction in world X/Z. Only used when `bedGeometry` is
292
+ * provided. Default `[1, 0.6]`.
293
+ */
294
+ seaBedDuneDirection?: Vec2;
295
+ /**
296
+ * Extra sand-dune crest/trough albedo banding (0 = off). Only used when
297
+ * `bedGeometry` is provided. Lightens the dune crests and darkens the
298
+ * troughs on top of the relief shading for a stronger depth cue; fades out
299
+ * far away like the rest of the dune detail. Default 0.
300
+ */
301
+ seaBedDuneSharpness?: number;
302
+ /**
303
+ * Per-meter tint build-up of the water body. Only used when `bodyGeometry`
304
+ * is provided.
305
+ */
306
+ bodyFogDensity?: number;
307
+ /** Densest water-body tint reached far through the water (0..1). */
308
+ bodyMaxOpacity?: number;
309
+ /** Animated shimmer amount of the water body, 0 = off. */
310
+ bodyShimmer?: number;
311
+ /** Master opacity multiplier (also drives OIT routing). */
312
+ opacity?: number;
313
+ /** Toggles visibility of the water-surface mesh. Default `true`. */
314
+ surfaceVisible?: boolean;
315
+ /**
316
+ * Toggles visibility of the water-body (side walls) mesh. Only has an effect
317
+ * when `bodyGeometry` is provided. Default `true`.
318
+ */
319
+ bodyVisible?: boolean;
320
+ /**
321
+ * Toggles visibility of the sea-bed mesh. Only has an effect when
322
+ * `bedGeometry` is provided. Default `true`.
323
+ */
324
+ bedVisible?: boolean;
325
+ /** Debug: render all ocean materials (surface, body, sea bed) as wireframe. */
326
+ wireframe?: boolean;
327
+ /**
328
+ * Children rendered inside the ocean's group, in its local frame. They
329
+ * receive an {@link OceanSampler} via context (see `useOceanSampler` /
330
+ * `useBuoyancy`) so floating objects (e.g. a vessel) can follow the waves.
331
+ */
332
+ children?: ReactNode;
333
+ } & import('react').RefAttributes<Group<import('three').Object3DEventMap>>>;
@@ -0,0 +1,6 @@
1
+ export * from './Ocean';
2
+ export * from './ocean-bed-material';
3
+ export * from './ocean-contact';
4
+ export * from './ocean-material';
5
+ export * from './ocean-sampler';
6
+ export * from './ocean-volume-material';
@@ -0,0 +1,60 @@
1
+ import { Color, ShaderMaterial, ShaderMaterialParameters, Vector2, Vector3 } from 'three';
2
+ export type OceanBedMaterialParameters = ShaderMaterialParameters;
3
+ /**
4
+ * OIT-compatible sea-bed material for the bottom face of an ocean box. Applies
5
+ * simple sun-direction diffuse shading so the procedural bed relief is visible,
6
+ * tints the water-facing (top) side toward the water colour, and keeps the
7
+ * underside a light sandy/yellowish colour. Rendered double-sided.
8
+ *
9
+ * At opacity 1 the OITRenderPass routes it through the opaque pass (writing
10
+ * depth), so it occludes geometry below it; lower opacity keeps it in the
11
+ * transparency passes so subsurface geometry shows through. Because the material
12
+ * has no `opacity` uniform, callers must mirror the alpha onto `material.opacity`
13
+ * to drive that routing.
14
+ *
15
+ * Wired for the OITRenderPass via {@link attachOitVariants} (variants share this
16
+ * material's `uniforms` by reference, so animated uniforms stay live).
17
+ */
18
+ export declare class OceanBedMaterial extends ShaderMaterial {
19
+ isOceanBedMaterial: boolean;
20
+ constructor(parameters?: OceanBedMaterialParameters);
21
+ get color(): Color;
22
+ set color(value: Color | string | number);
23
+ get waterColor(): Color;
24
+ set waterColor(value: Color | string | number);
25
+ /** Strength of the water tint on the water-facing side (0..1). */
26
+ get waterTint(): number;
27
+ set waterTint(value: number);
28
+ get sunDirection(): Vector3;
29
+ set sunDirection(value: Vector3);
30
+ get sunColor(): Color;
31
+ set sunColor(value: Color | string | number);
32
+ /** Ambient light floor (0..1). */
33
+ get ambient(): number;
34
+ set ambient(value: number);
35
+ /** Bed opacity (also mirror onto `material.opacity` for OIT routing). */
36
+ get bedOpacity(): number;
37
+ set bedOpacity(value: number);
38
+ get masterOpacity(): number;
39
+ set masterOpacity(value: number);
40
+ /**
41
+ * Sand-dune relief strength (0 = off). Perturbs the shading normal by the
42
+ * analytic slope of a procedural, footprint-anti-aliased dune height field, so
43
+ * the bed reads with subtle relief up close and fades to flat far out.
44
+ */
45
+ get duneStrength(): number;
46
+ set duneStrength(value: number);
47
+ /** Base dune crest spacing in meters. */
48
+ get duneWavelength(): number;
49
+ set duneWavelength(value: number);
50
+ /** Dune ridge propagation direction in world X/Z. */
51
+ get duneDirection(): Vector2;
52
+ set duneDirection(value: Vector2);
53
+ /**
54
+ * Extra crest/trough albedo banding (0 = off). Lightens the dune crests and
55
+ * darkens the troughs on top of the normal-based shading for a stronger sense
56
+ * of relief; follows the same footprint fade so it also vanishes far out.
57
+ */
58
+ get duneSharpness(): number;
59
+ set duneSharpness(value: number);
60
+ }
@@ -0,0 +1,39 @@
1
+ import { OceanContact } from './ocean-material';
2
+ /**
3
+ * A function returning a floating object's current contact footprint (in the
4
+ * ocean's local frame), or `null` when it is temporarily not touching the water
5
+ * (so it can be skipped). Read every frame by the enclosing `<Ocean>`, so it
6
+ * should reflect the object's live position/heading.
7
+ */
8
+ export type OceanContactSource = () => OceanContact | null;
9
+ /**
10
+ * Registry provided by an `<Ocean>` so its floating children can contribute
11
+ * contact-foam footprints. Floating components register a source and are
12
+ * unregistered automatically on unmount.
13
+ */
14
+ export interface OceanContactRegistry {
15
+ /** Register a footprint source; returns a function that unregisters it. */
16
+ register(source: OceanContactSource): () => void;
17
+ }
18
+ /**
19
+ * Context carrying the enclosing `<Ocean>`'s {@link OceanContactRegistry}, or
20
+ * `null` when the component is not rendered inside an `<Ocean>`.
21
+ */
22
+ export declare const OceanContactContext: import('react').Context<OceanContactRegistry | null>;
23
+ /**
24
+ * Register a floating object's contact footprint with the enclosing `<Ocean>`
25
+ * so it spreads foam where it meets the water. Reusable by any floating
26
+ * component: pass a function that returns the object's current footprint (centre,
27
+ * heading and half-extents) each frame.
28
+ *
29
+ * No-op when there is no enclosing `<Ocean>` or when `enabled` is `false`. The
30
+ * source function is read through a ref, so it can close over changing values
31
+ * without re-registering every render.
32
+ *
33
+ * @example
34
+ * useOceanContact(
35
+ * () => ({ x, z, heading, halfLength, halfWidth, foamWidth }),
36
+ * enabled,
37
+ * );
38
+ */
39
+ export declare function useOceanContact(getContact: OceanContactSource, enabled?: boolean): void;