@equinor/videx-3d 2.0.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/dist/chunk-DKAquGKk.js +2820 -0
  2. package/dist/chunk-DsUZyEG_.js +16 -0
  3. package/dist/generators.js +512 -727
  4. package/dist/main.js +7182 -10552
  5. package/dist/sdk.js +2 -787
  6. package/dist/src/sdk/materials/shaderLib/procedural-normal.glsl +274 -0
  7. package/dist/types/components/Ocean/Ocean.d.ts +333 -0
  8. package/dist/types/components/Ocean/index.d.ts +6 -0
  9. package/dist/types/components/Ocean/ocean-bed-material.d.ts +60 -0
  10. package/dist/types/components/Ocean/ocean-contact.d.ts +39 -0
  11. package/dist/types/components/Ocean/ocean-material.d.ts +145 -0
  12. package/dist/types/components/Ocean/ocean-sampler.d.ts +93 -0
  13. package/dist/types/components/Ocean/ocean-volume-material.d.ts +54 -0
  14. package/dist/types/components/Tanker/Tanker.d.ts +47 -0
  15. package/dist/types/components/Tanker/TankerSuperstructure.d.ts +23 -0
  16. package/dist/types/components/Tanker/tanker-geometry-builder.d.ts +21 -0
  17. package/dist/types/components/Wellbores/Casings/CasingMaterial.d.ts +229 -1
  18. package/dist/types/components/Wellbores/Casings/CasingSection.d.ts +6 -1
  19. package/dist/types/components/Wellbores/Casings/Casings.d.ts +45 -4
  20. package/dist/types/components/Wellbores/Casings/casings-defs.d.ts +44 -0
  21. package/dist/types/components/Wellbores/Casings/index.d.ts +2 -1
  22. package/dist/types/main.d.ts +1 -0
  23. package/dist/types/rendering/Pass.d.ts +10 -1
  24. package/dist/types/rendering/RenderingPipeline.d.ts +10 -1
  25. package/dist/types/rendering/debug/DebugBoxOutputPass.d.ts +22 -0
  26. package/dist/types/rendering/debug/DebugPatternPass.d.ts +30 -0
  27. package/dist/types/rendering/fxaa-resolver.d.ts +25 -0
  28. package/dist/types/rendering/index.d.ts +1 -0
  29. package/dist/types/rendering/passes/AnnotationsPass.d.ts +1 -0
  30. package/dist/types/rendering/passes/FXAAPass.d.ts +11 -6
  31. package/dist/types/rendering/passes/OITRenderPass.d.ts +147 -0
  32. package/dist/types/rendering/passes/OutputPass.d.ts +9 -0
  33. package/dist/types/rendering/passes/RenderPass.d.ts +2 -0
  34. package/dist/types/rendering/passes/index.d.ts +0 -2
  35. package/dist/types/rendering/smaa-resolver.d.ts +58 -0
  36. package/dist/types/rendering/taa-resolver.d.ts +161 -0
  37. package/dist/types/rendering/temporal-resolver.d.ts +152 -0
  38. package/dist/types/sdk/geometries/boundary-loops.d.ts +38 -0
  39. package/dist/types/sdk/geometries/geometry-attributes.d.ts +37 -0
  40. package/dist/types/sdk/geometries/grid-sampling.d.ts +50 -0
  41. package/dist/types/sdk/geometries/ocean-geometry.d.ts +288 -0
  42. package/dist/types/sdk/geometries/packing.d.ts +1 -1
  43. package/dist/types/sdk/geometries/tessellation.d.ts +25 -0
  44. package/dist/types/sdk/index.d.ts +5 -0
  45. package/dist/types/sdk/utils/vector-operations.d.ts +7 -0
  46. package/package.json +11 -18
  47. package/dist/chunk-61X6qE5N.js +0 -981
  48. package/dist/chunk-ChG5d4HC.js +0 -675
  49. package/dist/chunk-DuRASjkF.js +0 -17
  50. package/dist/chunk-M-Pcc_Yg.js +0 -689
  51. package/dist/types/rendering/passes/SMAAPass.d.ts +0 -40
  52. package/dist/types/rendering/passes/TAAPass.d.ts +0 -94
  53. /package/dist/{shaderLib → src/sdk/materials/shaderLib}/color-conversion.glsl +0 -0
  54. /package/dist/{shaderLib → src/sdk/materials/shaderLib}/colors.glsl +0 -0
  55. /package/dist/{shaderLib → src/sdk/materials/shaderLib}/glyphs.glsl +0 -0
  56. /package/dist/{shaderLib → src/sdk/materials/shaderLib}/oit.glsl +0 -0
  57. /package/dist/{shaderLib → src/sdk/materials/shaderLib}/random.glsl +0 -0
  58. /package/dist/{shaderLib → src/sdk/materials/shaderLib}/remap.glsl +0 -0
  59. /package/dist/{shaderLib → src/sdk/materials/shaderLib}/render-number.glsl +0 -0
  60. /package/dist/{shaderLib → src/sdk/materials/shaderLib}/render-text.glsl +0 -0
  61. /package/dist/{shaderLib → src/sdk/materials/shaderLib}/rotation.glsl +0 -0
  62. /package/dist/{shaderLib → src/sdk/materials/shaderLib}/sdf-functions.glsl +0 -0
  63. /package/dist/textures/{normal_map.jpg → public/normal_map.jpg} +0 -0
@@ -0,0 +1,274 @@
1
+ // Procedural (texture-free) normal-detail helpers.
2
+ //
3
+ // Pure functions - no uniforms, no varyings - so any material can reuse them by
4
+ // supplying its own inputs and controls. Include this file in a FRAGMENT shader
5
+ // (it relies on screen-space derivatives, dFdx/dFdy).
6
+ //
7
+ // Dependencies the consuming material must provide when calling perturbNormalHeight:
8
+ // - normal : the shading normal to perturb, in VIEW space
9
+ // - viewPos : the surface position in VIEW space (e.g. -vViewPosition)
10
+ // - height : a scalar height field sampled at this fragment (produced by the
11
+ // pnGranular / pnGrain / pnScratches helpers below, summed); the caller
12
+ // scales it to taste (its "strength"/bump amount) and may fade it by
13
+ // distance
14
+ // And when sampling a pattern height (pnGranular / pnGrain / pnScratches):
15
+ // - uv : a 2D coordinate ALREADY scaled by the caller's frequency. The
16
+ // caller owns the units (world distance, normalized, radius-based,
17
+ // ...) and which axis maps to uv.y (the grain/stretch axis).
18
+ // - octaves : fbm octave count for pnGranular / pnGrain (1..N). pnScratches is
19
+ // segment-based and takes NO octave count.
20
+ // - periodX : if > 0, the noise tiles seamlessly every `periodX` cells in x (pass
21
+ // the number of cells around a circumference to remove the wrap seam
22
+ // on a closed cylinder; pass 0 to disable). Tiling is exact for
23
+ // granular and for grain/scratches at angle 0.
24
+ // The patterns return scalar heights; combine several by summing (optionally weighted)
25
+ // and feed the result to perturbNormalHeight.
26
+ //
27
+ // "width" of the features is controlled by the caller's frequency/anisotropy/angle
28
+ // folded into uv; "height" of the bump is the caller-owned scalar passed to
29
+ // perturbNormalHeight. No CPU data or vertex attributes are required beyond whatever
30
+ // the material already uses to build its uv.
31
+
32
+ // Lattice wrap period (cells). The value-noise lattice (and the scratch seed grid) repeat
33
+ // every PN_WRAP cells per axis, so a caller that reduces a very large sample coordinate
34
+ // into [0, PN_WRAP) - to keep floor()/fract() float-precise at oilfield scale, where
35
+ // metres-along-trajectory x frequency reaches ~1e5 and fract() quantises into visible
36
+ // banding - still tiles SEAMLESSLY at the wrap. Large enough (4096 cells) that the repeat
37
+ // is invisible for fine detail; a no-op (mod = identity) for the small coords normal use
38
+ // produces.
39
+ #define PN_WRAP 4096.0
40
+
41
+ // Precision-robust 2D->1D hash (Dave Hoskins). fract() is applied BEFORE any multiply/
42
+ // dot so the working values stay in [0,1) - this survives the large sample coordinates
43
+ // that occur at oilfield scale (a pattern sampled by metres-along-trajectory times a
44
+ // frequency reaches ~1e5+), where the older fract(p*c) + dot(p, p) form overflowed
45
+ // float32 precision so fract() returned near-constant values and the noise collapsed /
46
+ // stretched with distance down the well.
47
+ float pnHash2(vec2 p) {
48
+ vec3 p3 = fract(vec3(p.xyx) * 0.1031);
49
+ p3 += dot(p3, p3.yzx + 33.33);
50
+ return fract((p3.x + p3.y) * p3.z);
51
+ }
52
+
53
+ // 2D value noise (smoothstep-interpolated).
54
+ float pnValueNoise2(vec2 p) {
55
+ vec2 i = floor(p);
56
+ vec2 f = fract(p);
57
+ f = f * f * (3.0 - 2.0 * f);
58
+ // Wrap the integer lattice at PN_WRAP so the noise tiles seamlessly when a caller reduces
59
+ // a huge coordinate into [0, PN_WRAP) (identity for the small coords normal use produces).
60
+ vec2 i0 = mod(i, PN_WRAP);
61
+ vec2 i1 = mod(i + 1.0, PN_WRAP);
62
+ float a = pnHash2(i0);
63
+ float b = pnHash2(vec2(i1.x, i0.y));
64
+ float c = pnHash2(vec2(i0.x, i1.y));
65
+ float d = pnHash2(i1);
66
+ return mix(mix(a, b, f.x), mix(c, d, f.x), f.y);
67
+ }
68
+
69
+ // Fractional Brownian motion with a dynamic (uniform-driven) octave count. The loop
70
+ // bound is a compile-time constant (GLSL requirement); `octaves` clamps it at runtime.
71
+ float pnFbm2(vec2 p, int octaves) {
72
+ float sum = 0.0;
73
+ float amp = 0.5;
74
+ float norm = 0.0;
75
+ for(int o = 0; o < 8; o++) {
76
+ if(o >= octaves)
77
+ break;
78
+ sum += amp * pnValueNoise2(p);
79
+ norm += amp;
80
+ p *= 2.02;
81
+ amp *= 0.5;
82
+ }
83
+ return norm > 0.0 ? sum / norm : 0.0;
84
+ }
85
+
86
+ // Tiling value noise: the integer lattice wraps at `periodX` cells in x, so a pattern
87
+ // sampled over exactly `periodX` units in x is seamless (used to wrap around a
88
+ // cylinder's circumference). y is not tiled.
89
+ float pnValueNoise2Tiled(vec2 p, float periodX) {
90
+ vec2 i = floor(p);
91
+ vec2 f = fract(p);
92
+ f = f * f * (3.0 - 2.0 * f);
93
+ float x0 = mod(i.x, periodX);
94
+ float x1 = mod(i.x + 1.0, periodX);
95
+ float y0 = mod(i.y, PN_WRAP);
96
+ float y1 = mod(i.y + 1.0, PN_WRAP);
97
+ float a = pnHash2(vec2(x0, y0));
98
+ float b = pnHash2(vec2(x1, y0));
99
+ float c = pnHash2(vec2(x0, y1));
100
+ float d = pnHash2(vec2(x1, y1));
101
+ return mix(mix(a, b, f.x), mix(c, d, f.x), f.y);
102
+ }
103
+
104
+ // fbm on the x-tiling noise; lacunarity 2.0 so every octave's period stays integer.
105
+ float pnFbm2Tiled(vec2 p, float periodX, int octaves) {
106
+ float sum = 0.0;
107
+ float amp = 0.5;
108
+ float norm = 0.0;
109
+ float per = max(periodX, 1.0);
110
+ for(int o = 0; o < 8; o++) {
111
+ if(o >= octaves)
112
+ break;
113
+ sum += amp * pnValueNoise2Tiled(p, per);
114
+ norm += amp;
115
+ p *= 2.0;
116
+ per *= 2.0;
117
+ amp *= 0.5;
118
+ }
119
+ return norm > 0.0 ? sum / norm : 0.0;
120
+ }
121
+
122
+ // fbm that tiles in x when periodX > 0, else plain (non-tiling) fbm.
123
+ float pnFbm2Auto(vec2 p, int octaves, float periodX) {
124
+ return periodX > 0.5 ? pnFbm2Tiled(p, periodX, octaves) : pnFbm2(p, octaves);
125
+ }
126
+
127
+ // GRANULAR: isotropic value-noise bumps; `anisotropy` (0..1) stretches the cells along
128
+ // uv.y. Signed height. periodX > 0 tiles x (e.g. a circumference).
129
+ float pnGranular(vec2 uv, float anisotropy, int octaves, float periodX) {
130
+ vec2 p = vec2(uv.x, uv.y * mix(1.0, 0.04, anisotropy));
131
+ return pnFbm2Auto(p, octaves, periodX) - 0.5;
132
+ }
133
+
134
+ // BRUSHED: a directional fine grain - thin parallel ridges running at `angle` (radians;
135
+ // 0 = along uv.y). `sharpness` (0..1) thins the ridges (their "width"); `uniformity`
136
+ // (0..1) blends from an irregular grain to perfectly regular flutes. Positive height.
137
+ // Tiling is exact only for angle == 0; other angles degrade gracefully (a faint seam).
138
+ float pnGrain(vec2 uv, float angle, float sharpness, float uniformity, int octaves, float periodX) {
139
+ float ca = cos(angle), sa = sin(angle);
140
+ vec2 r = vec2(uv.x * ca - uv.y * sa, uv.x * sa + uv.y * ca);
141
+ float tile = abs(angle) < 1e-3 ? periodX : 0.0;
142
+ float n = pnFbm2Auto(vec2(r.x, r.y * 0.06), octaves, tile);
143
+ // Irregular grain (fbm-smooth, so it has no cusp to alias); `sharpness` thins the ridges.
144
+ float irregular = pow(1.0 - abs(2.0 * n - 1.0), mix(2.0, 8.0, clamp(sharpness, 0.0, 1.0)));
145
+ // Regular flutes: footprint-anti-aliased evenly-spaced ridges (period 1 in r.x). A
146
+ // smoothstep whose transition is never narrower than the pixel footprint (fwidth)
147
+ // keeps the ridge crisp up close WITHOUT the sharp cusp of the old (1-|sin|)^pow form
148
+ // - that cusp under-sampled the normal and shimmered even close up - and naturally
149
+ // band-limits into a flat tone once a flute drops below a pixel far away. `sharpness`
150
+ // sets the ridge width.
151
+ float dCentre = abs(r.x - floor(r.x + 0.5)); // 0 at a flute centre .. 0.5 between
152
+ float hw = mix(0.35, 0.05, clamp(sharpness, 0.0, 1.0));
153
+ float aaw = max(fwidth(r.x), 1e-4);
154
+ float regular = 1.0 - smoothstep(hw - aaw, hw + aaw, dCentre);
155
+ // Once a flute period approaches the pixel footprint (fwidth ~ 0.5, i.e. the sine is
156
+ // near screen-Nyquist at the grazing sides of the shell), flatten the flutes toward
157
+ // their duty-cycle mean (~2*hw). Without this the ridge stays a smooth-but-undersampled
158
+ // sine there and still shimmers even though the edges are footprint-AA'd.
159
+ regular = mix(regular, 2.0 * hw, smoothstep(0.3, 0.5, aaw));
160
+ return mix(irregular, regular, clamp(uniformity, 0.0, 1.0));
161
+ }
162
+
163
+ // SCRATCHES: sparse, thin grooves crossing at varied angles/lengths - a cell/segment
164
+ // field rather than parallel lanes, so it reads like real scuffing. `density` (0..1) =
165
+ // fraction of seed cells that carry a scratch; `angle` = orientation bias and `wander`
166
+ // (0..1) widens the spread of directions around it (0 = all parallel, 1 = fully random);
167
+ // `lengthScale` (>0) scales each groove's length; `halfWidth` sets the groove width in
168
+ // sample (uv) units - pass (world-width x frequency) to get a FREQUENCY-INDEPENDENT width
169
+ // so lowering the frequency lengthens/thins-out the scratches without widening them. Two
170
+ // families are summed by pnScratches:
171
+ // a fine layer (short/medium scratches) plus a coarse layer (fewer, much longer ones).
172
+ // Each groove is analytically anti-aliased (edge widened to the pixel footprint).
173
+ // Negative height.
174
+
175
+ // One scratch "family": line segments seeded on an integer grid at the coordinate scale
176
+ // of `r`. Each present cell (gated by `density`) spawns a groove with a random midpoint,
177
+ // direction (biased toward `angle`, spread by `wander`), half-length, width and depth. A
178
+ // 3x3 neighbourhood is scanned so segments crossing in from adjacent cells are caught;
179
+ // half-length is capped below the search radius so grooves stay unbroken. `seed`
180
+ // decorrelates layers; x wraps at `periodX` cells (when angle ~ 0) for a seamless
181
+ // circumference seam.
182
+ float pnScratchLayer(vec2 r, float angle, float density, float lengthScale, float halfWidth, float wander, float periodX, float seed) {
183
+ float aaw = max(length(fwidth(r)), 1e-4);
184
+ vec2 cell = floor(r);
185
+ float acc = 0.0;
186
+ bool tile = periodX > 0.5 && abs(angle) < 1e-3;
187
+ for(int j = -1; j <= 1; j++) {
188
+ for(int i = -1; i <= 1; i++) {
189
+ vec2 c = cell + vec2(float(i), float(j));
190
+ vec2 h = mod(c, PN_WRAP); // keep hash coords small/precise + seamless at the axial wrap
191
+ if(tile)
192
+ // max() keeps the divisor provably non-zero: callers that disable tiling pass
193
+ // periodX = 0.0, and some backends (ANGLE/D3D) constant-fold the mod() division
194
+ // inside this branch BEFORE dead-code elimination and warn "X4008: floating
195
+ // point division by zero". Only reached when tile (periodX > 0.5), so this is a
196
+ // no-op at runtime.
197
+ h.x = mod(c.x, max(periodX, 1.0)); // seamless wrap around the circumference
198
+ h += seed;
199
+ if(pnHash2(h + 3.1) > density)
200
+ continue; // sparsity
201
+ vec2 mid = c + vec2(pnHash2(h + 7.3), pnHash2(h + 13.7));
202
+ float a = angle + (pnHash2(h + 21.1) - 0.5) * 3.14159265 * clamp(wander, 0.0, 1.0);
203
+ vec2 d = vec2(cos(a), sin(a));
204
+ vec2 perp = vec2(-d.y, d.x);
205
+ float hl = clamp(mix(0.1, 0.55, pnHash2(h + 29.3)) * max(lengthScale, 0.05), 0.03, 0.92);
206
+ float w = halfWidth * mix(0.7, 1.3, pnHash2(h + 41.7)); // world-scaled half-width (freq-independent)
207
+ float rStr = mix(0.3, 1.0, pnHash2(h + 37.7)); // random depth/brightness
208
+ float bend = (pnHash2(h + 51.9) - 0.5) * 0.7; // shallow curvature so lines aren't dead straight
209
+ vec2 pr = r - mid;
210
+ float t = clamp(dot(pr, d), -hl, hl); // nearest point on the straight axis
211
+ float u = t / max(hl, 1e-3);
212
+ vec2 foot = d * t + perp * (bend * u * u * hl); // bow the centre-line across its length
213
+ float dist = length(pr - foot);
214
+ acc = max(acc, (1.0 - smoothstep(w - aaw, w + aaw, dist)) * rStr);
215
+ }
216
+ }
217
+ return acc;
218
+ }
219
+
220
+ float pnScratches(vec2 uv, float angle, float density, float lengthScale, float halfWidth, float wander, float periodX, float coarseWeight) {
221
+ float ca = cos(angle), sa = sin(angle);
222
+ vec2 r = vec2(uv.x * ca - uv.y * sa, uv.x * sa + uv.y * ca);
223
+
224
+ // Fine family: many short/medium scratches at the caller's frequency.
225
+ float fine = pnScratchLayer(r, angle, density, lengthScale, halfWidth, wander, periodX, 0.0);
226
+
227
+ // Coarse family: a few much longer grooves, seeded on a ~3x larger grid (bigger cells
228
+ // => longer scratches within the same 3x3 search). x is rescaled to an INTEGER period
229
+ // so the circumference seam stays seamless; y (never tiled) is just divided down. The
230
+ // half-width is scaled by the same factor so the coarse grooves keep the SAME world
231
+ // width as the fine ones (longer, not fatter). It is the most repetition-prone / "big"
232
+ // family AND doubles the per-fragment cost, so `coarseWeight` lets the caller drop it
233
+ // entirely (pass 0 - the whole 3x3 loop is then skipped): the branch is expected to be
234
+ // driven by a uniform (e.g. a quality knob) so it stays divergence-free.
235
+ float coarse = 0.0;
236
+ if(coarseWeight > 0.0) {
237
+ float coarsePeriod = max(floor(periodX / 3.0 + 0.5), 1.0);
238
+ float scale = coarsePeriod / max(periodX, 1.0);
239
+ vec2 rc = vec2(r.x * scale, r.y / 3.0);
240
+ coarse = pnScratchLayer(rc, angle, density * 0.5, lengthScale, halfWidth * scale, wander, coarsePeriod, 7.0) * coarseWeight;
241
+ }
242
+
243
+ return -max(fine, coarse);
244
+ }
245
+
246
+ // Footprint anti-aliasing factor (1 near .. 0 sub-pixel). Fades a pattern out as its
247
+ // finest octave shrinks toward a pixel - with distance or at grazing angles - so the
248
+ // high-frequency detail never becomes a shimmering/aliasing signal. `uv` is the
249
+ // (frequency-scaled) sample coordinate; `octaves` is the fbm octave count. Must be
250
+ // called under uniform control flow (uses screen-space derivatives).
251
+ float pnFootprintFade(vec2 uv, int octaves) {
252
+ // cells per pixel of the sample coordinate (mildly boosted for finer octaves). Fade
253
+ // BEFORE the Nyquist limit: a cell must stay >~2 px to sample cleanly, so start fading
254
+ // around 2.5 px/cell and reach zero by ~1 px/cell. (A looser threshold left the pattern
255
+ // near full strength at ~1 cell/pixel, so it stippled/aliased on thin, minified faces
256
+ // such as the end caps and slice faces.)
257
+ float cellsPerPixel = max(fwidth(uv.x), fwidth(uv.y)) * (1.0 + 0.5 * float(octaves - 1));
258
+ return 1.0 - smoothstep(0.4, 1.0, cellsPerPixel);
259
+ }
260
+
261
+ // Perturb a view-space normal by a scalar height field using the screen-space surface
262
+ // gradient (Mikkelsen) - no tangent/bitangent attributes needed. `height` must be the
263
+ // value sampled at THIS fragment; its screen-space derivatives give the slope.
264
+ vec3 perturbNormalHeight(vec3 normal, vec3 viewPos, float height) {
265
+ vec3 sx = dFdx(viewPos);
266
+ vec3 sy = dFdy(viewPos);
267
+ float hx = dFdx(height);
268
+ float hy = dFdy(height);
269
+ vec3 r1 = cross(sy, normal);
270
+ vec3 r2 = cross(normal, sx);
271
+ float det = dot(sx, r1);
272
+ vec3 grad = sign(det) * (hx * r1 + hy * r2);
273
+ return normalize(abs(det) * normal - grad);
274
+ }
@@ -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
+ }