@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,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,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;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { Color, ShaderMaterial, ShaderMaterialParameters, Vector2, Vector3 } from 'three';
|
|
2
|
+
export type OceanMaterialParameters = ShaderMaterialParameters & {
|
|
3
|
+
waveCount?: number;
|
|
4
|
+
detailOctaves?: number;
|
|
5
|
+
contactCount?: number;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* An oriented footprint of a floating object resting on the ocean surface, used
|
|
9
|
+
* to spread contact foam around it. All values are in the ocean's local frame
|
|
10
|
+
* (sea level = local y 0).
|
|
11
|
+
*/
|
|
12
|
+
export type OceanContact = {
|
|
13
|
+
/** Footprint centre X (local). */
|
|
14
|
+
x: number;
|
|
15
|
+
/** Footprint centre Z (local). */
|
|
16
|
+
z: number;
|
|
17
|
+
/** Heading in radians (rotation about +Y). */
|
|
18
|
+
heading: number;
|
|
19
|
+
/** Half-extent along the heading (e.g. half the hull length). */
|
|
20
|
+
halfLength: number;
|
|
21
|
+
/** Half-extent across the heading (e.g. half the beam). */
|
|
22
|
+
halfWidth: number;
|
|
23
|
+
/** Width (m) of the foam band straddling the footprint edge. */
|
|
24
|
+
foamWidth: number;
|
|
25
|
+
/**
|
|
26
|
+
* Foam strength multiplier (0 = none, 1 = full). Contact foam is independent
|
|
27
|
+
* of the wind-driven `foamAmount`, so this controls how much foam the object
|
|
28
|
+
* generates. Default `1`.
|
|
29
|
+
*/
|
|
30
|
+
intensity?: number;
|
|
31
|
+
/**
|
|
32
|
+
* How much the foam is reduced toward the bow/stern (the forward axis), 0..1.
|
|
33
|
+
* 0 = an even collar all around; 1 = foam only along the sides (where a hull
|
|
34
|
+
* pushes the most water). Default `0`.
|
|
35
|
+
*/
|
|
36
|
+
endFalloff?: number;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Stylized, OIT-compatible ocean surface material.
|
|
40
|
+
*
|
|
41
|
+
* The wave field is a discrete set of directional components sampled from a
|
|
42
|
+
* JONSWAP spectrum tuned for the North Sea (gamma = 3.3), driven by a single
|
|
43
|
+
* physical input: the wind speed (m/s, U10). Peak frequency, wavelength and
|
|
44
|
+
* significant wave height follow the standard Pierson-Moskowitz/JONSWAP
|
|
45
|
+
* relations, so the wave sizes and spacing are physically plausible (e.g.
|
|
46
|
+
* U = 10 m/s gives Hs ~ 2.1 m and a peak wavelength ~ 88 m). The spectrum is
|
|
47
|
+
* sampled on the CPU whenever the wind changes and uploaded as uniform arrays;
|
|
48
|
+
* the shaders just sum the components.
|
|
49
|
+
*
|
|
50
|
+
* All wave/foam animation is evaluated in world X/Z space so it tiles
|
|
51
|
+
* seamlessly across patched geometry. The material is wired for the
|
|
52
|
+
* OITRenderPass via {@link attachOitVariants}; because its OIT variants share
|
|
53
|
+
* this material's `uniforms` object by reference, animated uniforms (time,
|
|
54
|
+
* wind, colours) stay live through every transparency pass.
|
|
55
|
+
*/
|
|
56
|
+
export declare class OceanMaterial extends ShaderMaterial {
|
|
57
|
+
isOceanMaterial: boolean;
|
|
58
|
+
private _waveCount;
|
|
59
|
+
private _waveHeightScale;
|
|
60
|
+
private _directionalSpread;
|
|
61
|
+
private _contactCount;
|
|
62
|
+
constructor(parameters?: OceanMaterialParameters);
|
|
63
|
+
/**
|
|
64
|
+
* (Re)sample the JONSWAP spectrum into the wave-component uniform arrays from
|
|
65
|
+
* the current wind speed/direction. Cheap (a few iterations) and only called
|
|
66
|
+
* when the wind/height inputs change, never per frame.
|
|
67
|
+
*/
|
|
68
|
+
private updateWaves;
|
|
69
|
+
get time(): number;
|
|
70
|
+
set time(value: number);
|
|
71
|
+
get windDirection(): Vector2;
|
|
72
|
+
set windDirection(value: Vector2);
|
|
73
|
+
get windSpeed(): number;
|
|
74
|
+
set windSpeed(value: number);
|
|
75
|
+
/** Wave height multiplier applied on top of the spectrum's physical Hs. */
|
|
76
|
+
get amplitude(): number;
|
|
77
|
+
set amplitude(value: number);
|
|
78
|
+
/** Angular spread (radians) of the wave directions around the wind. */
|
|
79
|
+
get directionalSpread(): number;
|
|
80
|
+
set directionalSpread(value: number);
|
|
81
|
+
/** Significant wave height (m) derived from the current wind/height scale. */
|
|
82
|
+
get significantHeight(): number;
|
|
83
|
+
get steepness(): number;
|
|
84
|
+
set steepness(value: number);
|
|
85
|
+
get displacement(): number;
|
|
86
|
+
set displacement(value: number);
|
|
87
|
+
get deepColor(): Color;
|
|
88
|
+
set deepColor(value: Color | string | number);
|
|
89
|
+
get shallowColor(): Color;
|
|
90
|
+
set shallowColor(value: Color | string | number);
|
|
91
|
+
get waterOpacity(): number;
|
|
92
|
+
set waterOpacity(value: number);
|
|
93
|
+
/** Strength of the large-scale tonal variation (currents / slicks). */
|
|
94
|
+
get tonalVariation(): number;
|
|
95
|
+
set tonalVariation(value: number);
|
|
96
|
+
/**
|
|
97
|
+
* Approximate size of the large-scale tonal variation patches, in kilometers.
|
|
98
|
+
* Larger values give broader, slower-changing current/slick fields; smaller
|
|
99
|
+
* values break the water up into finer patches.
|
|
100
|
+
*/
|
|
101
|
+
get tonalScale(): number;
|
|
102
|
+
set tonalScale(value: number);
|
|
103
|
+
/**
|
|
104
|
+
* Crispness of the tonal variation patch boundaries. 0 keeps the soft FBM
|
|
105
|
+
* gradient; higher values (up to 1) narrow the transition band so the
|
|
106
|
+
* currents/slicks read as distinct, well-defined regions.
|
|
107
|
+
*/
|
|
108
|
+
get tonalSharpness(): number;
|
|
109
|
+
set tonalSharpness(value: number);
|
|
110
|
+
/** Colour the water drifts toward in the tonal variation (current / algae / pollution tint). */
|
|
111
|
+
get tonalColor(): Color;
|
|
112
|
+
set tonalColor(value: Color | string | number);
|
|
113
|
+
get skyColor(): Color;
|
|
114
|
+
set skyColor(value: Color | string | number);
|
|
115
|
+
get horizonColor(): Color;
|
|
116
|
+
set horizonColor(value: Color | string | number);
|
|
117
|
+
get reflectionIntensity(): number;
|
|
118
|
+
set reflectionIntensity(value: number);
|
|
119
|
+
get sunDirection(): Vector3;
|
|
120
|
+
set sunDirection(value: Vector3);
|
|
121
|
+
get sunColor(): Color;
|
|
122
|
+
set sunColor(value: Color | string | number);
|
|
123
|
+
get sunShininess(): number;
|
|
124
|
+
set sunShininess(value: number);
|
|
125
|
+
get foamColor(): Color;
|
|
126
|
+
set foamColor(value: Color | string | number);
|
|
127
|
+
get foamAmount(): number;
|
|
128
|
+
set foamAmount(value: number);
|
|
129
|
+
get fresnelPower(): number;
|
|
130
|
+
set fresnelPower(value: number);
|
|
131
|
+
get detailScale(): number;
|
|
132
|
+
set detailScale(value: number);
|
|
133
|
+
get detailStrength(): number;
|
|
134
|
+
set detailStrength(value: number);
|
|
135
|
+
/** Maximum number of contact footprints this material can render at once. */
|
|
136
|
+
get contactCount(): number;
|
|
137
|
+
/**
|
|
138
|
+
* Upload the current set of floating-object contact footprints. Excess
|
|
139
|
+
* entries beyond {@link contactCount} are ignored. Cheap: it only copies into
|
|
140
|
+
* the preallocated uniform vectors, so it is safe to call every frame.
|
|
141
|
+
*/
|
|
142
|
+
setContacts(contacts: OceanContact[]): void;
|
|
143
|
+
/** Clear all contact footprints (no contact foam). */
|
|
144
|
+
clearContacts(): void;
|
|
145
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
import { Object3D } from 'three';
|
|
3
|
+
import { OceanMaterial } from './ocean-material';
|
|
4
|
+
/**
|
|
5
|
+
* Read-only sampler for the live ocean surface. Lets non-rendering code (e.g.
|
|
6
|
+
* floating objects) query the water height at any world X/Z, in sync with the
|
|
7
|
+
* animated wave field shown on screen.
|
|
8
|
+
*
|
|
9
|
+
* The height is summed from the same spectral wave components the shader uses
|
|
10
|
+
* (`uWaveA`/`uWaveB` + `uTime`, read by reference from the material), so it
|
|
11
|
+
* always matches the current sea state, wind and animation time. The optional
|
|
12
|
+
* Gerstner horizontal displacement and the render-time footprint LOD fade are
|
|
13
|
+
* intentionally ignored — they are visual-only refinements, not needed for a
|
|
14
|
+
* plausible floating response, and skipping them keeps sampling cheap.
|
|
15
|
+
*
|
|
16
|
+
* Coordinates are in the Ocean group's local frame (sea level = local y 0),
|
|
17
|
+
* which equals world space for the typical flat, unrotated planar ocean.
|
|
18
|
+
*/
|
|
19
|
+
export interface OceanSampler {
|
|
20
|
+
/** Water surface height (local y) at the given local X/Z. */
|
|
21
|
+
getHeightAt(x: number, z: number): number;
|
|
22
|
+
/** Significant wave height (m) of the current sea state. */
|
|
23
|
+
readonly significantHeight: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Create an {@link OceanSampler} bound to an {@link OceanMaterial}. The sampler
|
|
27
|
+
* reads the material's wave uniforms by reference, so it reflects sea-state and
|
|
28
|
+
* time changes without any extra wiring.
|
|
29
|
+
*/
|
|
30
|
+
export declare function createOceanSampler(material: OceanMaterial): OceanSampler;
|
|
31
|
+
/**
|
|
32
|
+
* Context carrying the current {@link OceanSampler}. An `<Ocean>` provides this
|
|
33
|
+
* to its children; floating components read it (directly or via
|
|
34
|
+
* {@link useBuoyancy}) to follow the waves. `null` when the component is not
|
|
35
|
+
* rendered inside an `<Ocean>` (so consumers can fall back to a static pose).
|
|
36
|
+
*/
|
|
37
|
+
export declare const OceanSamplerContext: import('react').Context<OceanSampler | null>;
|
|
38
|
+
/**
|
|
39
|
+
* Access the {@link OceanSampler} provided by an enclosing `<Ocean>`, or `null`
|
|
40
|
+
* when there is none.
|
|
41
|
+
*/
|
|
42
|
+
export declare function useOceanSampler(): OceanSampler | null;
|
|
43
|
+
/** A body-frame sample point `[x, z]` taken at the object's waterline (y 0). */
|
|
44
|
+
export type BuoyancyPoint = [x: number, z: number];
|
|
45
|
+
/**
|
|
46
|
+
* Options for {@link useBuoyancy}.
|
|
47
|
+
*/
|
|
48
|
+
export type BuoyancyOptions = {
|
|
49
|
+
/**
|
|
50
|
+
* Sample points in the object's local X/Z (at its waterline). Required.
|
|
51
|
+
*
|
|
52
|
+
* Place them at the true hull extents (e.g. bow / stern / port / starboard):
|
|
53
|
+
* this is how the object's length and width feed into the motion. Waves
|
|
54
|
+
* shorter than the span between points decorrelate, so the fitted plane
|
|
55
|
+
* yields little pitch/roll (a long ship barely reacts to short chop), while
|
|
56
|
+
* swells longer than the object move it as a whole.
|
|
57
|
+
*/
|
|
58
|
+
points: BuoyancyPoint[];
|
|
59
|
+
/** Master switch; when `false` the object is left untouched. Default `true`. */
|
|
60
|
+
enabled?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Response rate (per second) of the heave/pitch/roll smoothing. Higher snaps
|
|
63
|
+
* to the waves faster; lower is more sluggish. Default `3`.
|
|
64
|
+
*/
|
|
65
|
+
damping?: number;
|
|
66
|
+
/**
|
|
67
|
+
* Relative mass / inertia of the object (default `1`). Models how heavy the
|
|
68
|
+
* object is: the effective response rate is divided by this, so a heavier
|
|
69
|
+
* object follows the surface more slowly and its motion amplitude shrinks for
|
|
70
|
+
* fast waves it cannot keep up with. Use a value relative to a "typical"
|
|
71
|
+
* object of its kind (e.g. `weight / referenceWeight`).
|
|
72
|
+
*/
|
|
73
|
+
mass?: number;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Make an object float on the ocean by following the wave field provided by an
|
|
77
|
+
* enclosing `<Ocean>`. Reusable for any floating component: pass a ref to the
|
|
78
|
+
* object's group and a few body-frame sample points (e.g. bow / stern / port /
|
|
79
|
+
* starboard at the waterline).
|
|
80
|
+
*
|
|
81
|
+
* Each frame the water height is sampled at those points (accounting for the
|
|
82
|
+
* object's current heading and X/Z position) and a plane is fitted to them to
|
|
83
|
+
* drive:
|
|
84
|
+
* - heave → `position.y` (mean surface height),
|
|
85
|
+
* - pitch → `rotation.z` (fore/aft slope),
|
|
86
|
+
* - roll → `rotation.x` (port/starboard slope),
|
|
87
|
+
* each critically-damped toward its target so the motion stays smooth and
|
|
88
|
+
* frame-rate independent. The object's heading (`rotation.y`) is left untouched.
|
|
89
|
+
*
|
|
90
|
+
* No-op when there is no enclosing `<Ocean>` (the object keeps its static pose).
|
|
91
|
+
* Allocation-free and only a handful of cheap samples per frame.
|
|
92
|
+
*/
|
|
93
|
+
export declare function useBuoyancy(ref: RefObject<Object3D | null>, options: BuoyancyOptions): void;
|