@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,288 @@
1
+ import { BufferGeometry } from 'three';
2
+ import { Vec2 } from '../types/common';
3
+ import { PlanarPolygonGeometry } from './planar-geometry';
4
+ /** Options shared by the ocean geometry builders. */
5
+ export type OceanGeometryOptions = {
6
+ /**
7
+ * Horizontal extent in world units (meters): a single number for a square, or
8
+ * `[width (X), length (Z)]`. Default 100000 (100 km).
9
+ */
10
+ size?: number | Vec2;
11
+ /**
12
+ * Water-surface tessellation: a single number for both axes, or `[X, Z]`.
13
+ * The default `0` uses the fewest triangles needed to fill the footprint
14
+ * outline (a flat surface needs no interior grid — the waves are shaded
15
+ * per-pixel). A positive value lays down a regular subdivision grid, which
16
+ * only matters when vertex displacement is enabled. Default 0.
17
+ */
18
+ surfaceSegments?: number | Vec2;
19
+ /** Center offset in world X/Z (meters). Default `[0, 0]`. */
20
+ origin?: Vec2;
21
+ /**
22
+ * Orientation in degrees, rotating the geometry about the +Y axis around
23
+ * {@link origin} (counter-clockwise viewed from above). Default 0.
24
+ */
25
+ rotation?: number;
26
+ };
27
+ /** Options for {@link createOceanPlane}. */
28
+ export type OceanPlaneOptions = OceanGeometryOptions;
29
+ /** Options for {@link createOceanBox}. */
30
+ export type OceanBoxOptions = OceanGeometryOptions & {
31
+ /**
32
+ * Mean water depth in meters: distance from the surface (y = 0) down to the
33
+ * sea bed. Default 150.
34
+ */
35
+ waterDepth?: number;
36
+ /**
37
+ * Sea-bed depth variation in meters (±) around {@link waterDepth}. With the
38
+ * defaults the bed varies between 100 m and 200 m. Default 50.
39
+ */
40
+ depthVariation?: number;
41
+ /**
42
+ * Sea-bed tessellation: a single number for both axes, or `[X, Z]`. Controls
43
+ * how finely the depth variation is resolved. Default 32.
44
+ */
45
+ bedSegments?: number | Vec2;
46
+ /** Seed for the procedural sea-bed variation. Default 0. */
47
+ seed?: number;
48
+ };
49
+ /**
50
+ * The three separate geometries produced by {@link createOceanBox}. Each is a
51
+ * standalone {@link BufferGeometry} so they can be rendered as independent
52
+ * meshes (and routed independently through transparency / OIT).
53
+ */
54
+ export type OceanBox = {
55
+ /** Top face (y = 0, normal +Y), tessellated for the waves. */
56
+ surface: BufferGeometry;
57
+ /** The four side walls (outward normals) forming the water body volume. */
58
+ body: BufferGeometry;
59
+ /** The displaced sea-bed bottom face (normals follow the bed slope). */
60
+ bed: BufferGeometry;
61
+ };
62
+ /**
63
+ * Build a flat ocean surface plane lying in the world X/Z plane (normal +Y) at
64
+ * y = 0, centered on `origin`. UVs span [0, 1] across the plane.
65
+ *
66
+ * The ocean animation is evaluated in world space, so this could equally be a
67
+ * set of tiled patches; this helper just provides a convenient single plane.
68
+ *
69
+ * @group Geometries
70
+ */
71
+ export declare function createOceanPlane(options?: OceanPlaneOptions): BufferGeometry;
72
+ /**
73
+ * Build an ocean box volume for a more complete water emulation. Returns three
74
+ * separate geometries so each can be rendered as its own mesh and routed
75
+ * independently through transparency / OIT:
76
+ *
77
+ * - **surface** — the top face (y = 0, normal +Y), tessellated for the waves.
78
+ * - **body** — the four side walls (outward normals); render with a
79
+ * double-sided volume material so the interior reads as a tinted water body.
80
+ * - **bed** — the bottom face, displaced to a procedurally varying depth
81
+ * between `waterDepth - depthVariation` and `waterDepth + depthVariation`
82
+ * (default 100–200 m), with normals following the bed slope.
83
+ *
84
+ * Pair with `<Ocean>` by passing `geometry={box.surface}` plus
85
+ * `bodyGeometry={box.body}` and `bedGeometry={box.bed}`.
86
+ *
87
+ * @group Geometries
88
+ */
89
+ export declare function createOceanBox(options?: OceanBoxOptions): OceanBox;
90
+ /** Options for {@link createOceanEllipseBox}. */
91
+ export type OceanEllipseOptions = Omit<OceanGeometryOptions, 'surfaceSegments'> & {
92
+ /**
93
+ * Mean water depth in meters: distance from the surface (y = 0) down to the
94
+ * sea bed. Default 150.
95
+ */
96
+ waterDepth?: number;
97
+ /**
98
+ * Sea-bed depth variation in meters (±) around {@link waterDepth}. With the
99
+ * defaults the bed varies between 100 m and 200 m. Default 50.
100
+ */
101
+ depthVariation?: number;
102
+ /** Seed for the procedural sea-bed variation. Default 0. */
103
+ seed?: number;
104
+ /**
105
+ * Number of segments around the perimeter. Higher values give a rounder,
106
+ * smoother outline. Default 96.
107
+ */
108
+ perimeterSegments?: number;
109
+ /**
110
+ * Number of segments from the center out to the edge (concentric rings).
111
+ * Higher values resolve the sea-bed depth variation more finely and give
112
+ * smoother wave displacement. The default `0` is auto: just enough rings to
113
+ * keep the radial spacing close to the perimeter spacing (so triangles stay
114
+ * well-shaped without an excessive count). Default 0.
115
+ */
116
+ radialSegments?: number;
117
+ };
118
+ /**
119
+ * Build a round ocean box: a circular footprint when `size` is a single number
120
+ * (or an equal `[width, height]` pair), or an oval/ellipse when width and height
121
+ * differ. Returns the same three independent geometries as {@link createOceanBox}
122
+ * (surface, body walls, sea bed).
123
+ *
124
+ * A rounded outline avoids the hard corners of a rectangular box, so a very
125
+ * large body of water reads as endless / gently curving (like the curvature of
126
+ * the earth) rather than a visibly cut rectangle.
127
+ *
128
+ * `size` is the diameter on each axis: `[width (X), height (Z)]` (a single
129
+ * number means both). The footprint is `width/2` × `height/2` radii, centered on
130
+ * `origin` and optionally spun by `rotation` degrees about +Y.
131
+ *
132
+ * Pair with `<Ocean>` by passing `geometry={box.surface}` plus
133
+ * `bodyGeometry={box.body}` and `bedGeometry={box.bed}`.
134
+ *
135
+ * @group Geometries
136
+ */
137
+ export declare function createOceanEllipseBox(options?: OceanEllipseOptions): OceanBox;
138
+ /**
139
+ * Header describing the regular grid of a depth surface (a subset of a
140
+ * `SurfaceMeta` header). Distances are in world units (meters); `rot` is in
141
+ * degrees, matching the surface data convention.
142
+ */
143
+ export type SurfaceGridHeader = {
144
+ /** Number of columns (samples along X). */
145
+ nx: number;
146
+ /** Number of rows (samples along Z). */
147
+ ny: number;
148
+ /** Column spacing in meters. */
149
+ xinc: number;
150
+ /** Row spacing in meters. */
151
+ yinc: number;
152
+ /** Grid rotation in degrees (about +Y), as stored in the surface header. */
153
+ rot: number;
154
+ };
155
+ /** Options for {@link createOceanBoxFromSurface}. */
156
+ export type OceanBoxFromSurfaceOptions = {
157
+ /** Value marking missing/hole samples in `values`. Default -1. */
158
+ nullValue?: number;
159
+ /**
160
+ * Depth used to fill *internal* holes (invalid samples fully enclosed by
161
+ * valid data) so the box stays watertight. Invalid samples connected to the
162
+ * grid border are treated as outside the surface footprint (the outer rim)
163
+ * and are left as holes, so the sea bed follows the true surface outline.
164
+ * Defaults to the deepest (maximum) valid sample in `values`.
165
+ */
166
+ fillDepth?: number;
167
+ /**
168
+ * Reference depth (datum) of the input values, in meters. Surface grids are
169
+ * often stored *depth-normalized* — e.g. as `referenceDepth - trueDepth` (the
170
+ * convention used by this repo's IRAP parser, where `referenceDepth` is the
171
+ * surface's maximum/deepest sample) — so the shallowest sample sits at 0
172
+ * instead of its true depth below sea level. When set, the true positive-down
173
+ * depth of each sample is recovered as `referenceDepth - value` before the bed
174
+ * and walls are built, so the sea bed sits at its real depth (matching the
175
+ * `Surface` component). Leave undefined when `values` already hold true,
176
+ * positive-down depths (the bed is then built directly from them).
177
+ */
178
+ referenceDepth?: number;
179
+ /**
180
+ * Target water-surface tessellation (a single number for both axes, or
181
+ * `[X, Z]`). The default `0` builds the surface from the same simplified
182
+ * triangulation as the sea bed, flattened to `y = 0` — the fewest triangles
183
+ * that still trace the surface outline (the waves are shaded per-pixel, so no
184
+ * interior grid is needed). A positive value instead lays down a regular grid
185
+ * at that density, clipped to and stitched to the exact data outline (which is
186
+ * kept intact), so the interior is uniform — useful only when the surface is
187
+ * vertex-displaced. The rim is shared with the walls and bed either way.
188
+ * Default 0.
189
+ */
190
+ surfaceSegments?: number | Vec2;
191
+ /** Sea-bed TIN simplification error (meters) passed to the triangulator. Default 5. */
192
+ maxError?: number;
193
+ /**
194
+ * Optional rim smoothing strength. `0` (default) keeps the grid-aligned rim,
195
+ * which can look pixelated since the surface follows a regular grid; `1`–`3`
196
+ * progressively smooth it. The outline (rim) vertices of the water surface
197
+ * and sea bed are filtered with a windowed moving average whose window grows
198
+ * with this value, so long staircase runs collapse onto their straight centre
199
+ * line and the rim reads as one continuous curve (rather than a chain of small
200
+ * arcs). Only the X/Z position of the existing boundary vertices is moved —
201
+ * their depth (Y), the sea-bed TIN and every interior vertex are left
202
+ * untouched, so bathymetry detail (and the triangulator's efficiency) is
203
+ * preserved.
204
+ */
205
+ rimSmoothing?: number;
206
+ };
207
+ /**
208
+ * Build an ocean box whose sea bed is the bathymetry of a depth surface,
209
+ * extracted (e.g. from an IRAP binary grid) as a row-major `Float32Array` plus
210
+ * the grid `header`. The function is data-agnostic — it takes the raw values
211
+ * and header, so it can be called from a generator or anywhere else.
212
+ *
213
+ * The result is positioned in the same local space as the `Surface` component
214
+ * (the far row is centered on the rotation pivot and the grid is rotated by
215
+ * `header.rot`; the world `xori`/`yori` origin is **not** baked in, so position
216
+ * the resulting `<Ocean>` exactly as you would a `Surface`). Sea level is the
217
+ * reference: the water surface lies at `y = 0` and the bed at `y = -depth`
218
+ * (depths are positive-down).
219
+ *
220
+ * Invalid samples connected to the grid border are treated as the outer rim
221
+ * (outside the surface footprint) and kept as holes, so the bed and walls
222
+ * follow the true surface outline; invalid samples fully enclosed by valid data
223
+ * are internal holes and get filled so the box stays watertight.
224
+ *
225
+ * - **surface** — flat water plane at `y = 0` tracing the same valid-region
226
+ * outline as the walls and bed (not a plain rectangle).
227
+ * - **body** — walls tracing the outline of the valid region, from `y = 0`
228
+ * down to the bathymetry.
229
+ * - **bed** — a simplified TIN of the (internal-hole-filled) bathymetry.
230
+ *
231
+ * Set `rimSmoothing` to relax the grid-aligned outline into a smooth, curved
232
+ * rim by moving only the existing boundary vertices in place (the sea-bed TIN
233
+ * and all interior detail are preserved).
234
+ *
235
+ * Set `referenceDepth` when the input grid is depth-normalized (e.g. stored as
236
+ * `referenceDepth - trueDepth`, as produced by this repo's IRAP parser) so the
237
+ * bed is placed at its true depth below sea level instead of being anchored to
238
+ * the shallowest sample; leave it undefined when `values` already hold true,
239
+ * positive-down depths.
240
+ *
241
+ * @group Geometries
242
+ */
243
+ export declare function createOceanBoxFromSurface(values: Float32Array, header: SurfaceGridHeader, options?: OceanBoxFromSurfaceOptions): OceanBox;
244
+ /** Options for {@link createOceanBoxFromPolygon}. */
245
+ export type OceanBoxFromPolygonOptions = {
246
+ /** Mean water depth in meters (bed sits at `y = -waterDepth` on average). Default 150. */
247
+ waterDepth?: number;
248
+ /** Sea-bed depth variation in meters (±) around {@link waterDepth}. Default 50. */
249
+ depthVariation?: number;
250
+ /** Seed for the procedural sea-bed variation. Default 0. */
251
+ seed?: number;
252
+ /**
253
+ * Target water-surface tessellation (a single number for both axes, or
254
+ * `[X, Z]`). The default `0` triangulates the footprint straight from its
255
+ * outline (the fewest triangles that fill the shape — the waves are shaded
256
+ * per-pixel). A positive value instead lays down a regular grid at that
257
+ * density clipped to the outline, with a thin triangle band stitching the
258
+ * grid to the exact outline — so the interior stays a uniform grid (only
259
+ * deviating at the rim) for clean vertex displacement. Default 0.
260
+ */
261
+ surfaceSegments?: number | Vec2;
262
+ /**
263
+ * Target sea-bed tessellation (a single number for both axes, or `[X, Z]`).
264
+ * The default lays a regular grid at this density clipped to and stitched to
265
+ * the exact polygon outline, displaced to the procedural depth. It shares the
266
+ * exact outline rim with the surface and walls (so the box stays watertight)
267
+ * while resolving the bathymetry more finely than the flat surface. A value of
268
+ * `0` triangulates the footprint straight from its outline instead. Default
269
+ * 48.
270
+ */
271
+ bedSegments?: number | Vec2;
272
+ };
273
+ /**
274
+ * Build an ocean box whose footprint matches a 2D polygon outline (e.g. a field
275
+ * boundary parsed from GeoJSON). Supports multiple polygon rings, each with
276
+ * zero or more holes. The polygon's `[x, y]` coordinates map to world
277
+ * `(x, 0, -y)` — the same `rotateX(-PI/2)` convention used elsewhere — so the
278
+ * northing axis becomes -Z.
279
+ *
280
+ * - **surface** — flat water plane at `y = 0`, tessellated to the outline.
281
+ * - **body** — a vertical wall around every ring (outer boundaries and holes),
282
+ * from `y = 0` down to the bed.
283
+ * - **bed** — the same outline tessellation displaced to a procedurally varying
284
+ * depth (reusing the {@link createOceanBox} sea-bed model).
285
+ *
286
+ * @group Geometries
287
+ */
288
+ export declare function createOceanBoxFromPolygon(polygon: PlanarPolygonGeometry, options?: OceanBoxFromPolygonOptions): OceanBox;
@@ -33,7 +33,7 @@ export type PackedBufferGeometry = {
33
33
  userData?: any;
34
34
  };
35
35
  export type PackedBufferGeometryCollection = Record<string, PackedBufferGeometry>;
36
- export declare function getTypedArrayType(array: ArrayBufferLike | TypedArray): "Uint8Array" | "Float64Array" | "Uint16Array" | "Uint32Array" | "Int8Array" | "Int16Array" | "Int32Array" | "Float32Array";
36
+ export declare function getTypedArrayType(array: ArrayBufferLike | TypedArray): "Uint8Array" | "Float32Array" | "Float64Array" | "Uint16Array" | "Uint32Array" | "Int8Array" | "Int16Array" | "Int32Array";
37
37
  export declare function getTypedArrayFromBuffer(buffer: ArrayBufferLike, type: string): Float32Array<ArrayBufferLike> | Int8Array<ArrayBufferLike> | Uint8Array<ArrayBufferLike> | Int16Array<ArrayBufferLike> | Uint16Array<ArrayBufferLike> | Int32Array<ArrayBufferLike> | Uint32Array<ArrayBufferLike> | Float64Array<ArrayBufferLike>;
38
38
  export declare function packAttribute(typedArray: TypedArray, itemSize?: number): PackedBufferAttribute;
39
39
  export declare function packBufferGeometryLike(geometry: BufferGeometryLike): [PackedBufferGeometry, ArrayBufferLike[]];
@@ -0,0 +1,25 @@
1
+ import { BufferGeometry } from 'three';
2
+ /**
3
+ * Midpoint-subdivide an indexed geometry `iterations` times, splitting every
4
+ * triangle into four (each edge midpoint is shared between adjacent triangles).
5
+ * Only the `position` attribute is interpolated; stale `normal`/`uv` attributes
6
+ * are dropped (recompute them afterwards). A no-op when the geometry has no
7
+ * index or `iterations <= 0`.
8
+ *
9
+ * @group Geometries
10
+ */
11
+ export declare function subdivideGeometry(geometry: BufferGeometry, iterations: number): void;
12
+ /**
13
+ * Refine an indexed triangle mesh `iterations` times by splitting only its
14
+ * INTERIOR edges, leaving boundary edges — and therefore the exact outline and
15
+ * its vertex count — untouched. Each interior edge contributes one midpoint that
16
+ * is shared by the two triangles adjacent to it, so the mesh stays conforming
17
+ * (no T-junctions) while the boundary loop is preserved exactly. This is what
18
+ * lets a surface or sea bed be densified for vertex displacement / detail while
19
+ * its rim still matches, vertex-for-vertex, walls extruded from the same
20
+ * outline. Only `position` is interpolated; stale `normal`/`uv` are dropped
21
+ * (recompute afterwards). A no-op without an index or when `iterations <= 0`.
22
+ *
23
+ * @group Geometries
24
+ */
25
+ export declare function refineInteriorEdges(geometry: BufferGeometry, iterations: number): void;
@@ -7,13 +7,18 @@ export * from './data/helpers/formations-helpers';
7
7
  export * from './data/helpers/well-helpers';
8
8
  export * from './data/Store';
9
9
  export * from './data/types';
10
+ export * from './geometries/boundary-loops';
10
11
  export * from './geometries/curve/curve-3d';
11
12
  export * from './geometries/curve/tube-geometry';
12
13
  export * from './geometries/delatin';
13
14
  export * from './geometries/fence';
14
15
  export * from './geometries/geometry';
16
+ export * from './geometries/geometry-attributes';
17
+ export * from './geometries/grid-sampling';
18
+ export * from './geometries/ocean-geometry';
15
19
  export * from './geometries/packing';
16
20
  export * from './geometries/planar-geometry';
21
+ export * from './geometries/tessellation';
17
22
  export * from './geometries/triangulate-grid';
18
23
  export * from './geometries/triangulate-grid-delaunay';
19
24
  export * from './managers/CameraManager';
@@ -13,3 +13,26 @@ export declare function createNormalTexture(buffer: Uint8Array, width: number, h
13
13
  * Create a data texture from RGBA encoded depth values
14
14
  */
15
15
  export declare function createElevationTexture(buffer: Float32Array, width: number, height: number): DataTexture;
16
+ /**
17
+ * Compute geometric surface normals from an elevation grid, encoded as a compact
18
+ * RG8 buffer (2 bytes/texel) using a hemisphere encoding: only the grid-local
19
+ * `x` and `z` components are stored (mapped to [0, 1]); the consumer reconstructs
20
+ * `y = sqrt(1 - x^2 - z^2)`.
21
+ *
22
+ * This replicates the per-fragment normal that `SurfaceMaterial`'s shader derives
23
+ * from the elevation texture (same four diagonal neighbours, cross products and
24
+ * hole handling), but pays the cost once on the CPU instead of in every OIT pass.
25
+ * The result is laid out to match the elevation buffer (row-major, intended for a
26
+ * `flipY = true` texture), so it samples 1:1 with the same grid UVs.
27
+ *
28
+ * @param data elevation values (row-major, holes < 0)
29
+ * @param columns number of columns (nx)
30
+ * @param rows number of rows (ny)
31
+ * @param xScale column spacing (xinc)
32
+ * @param yScale row spacing (yinc)
33
+ */
34
+ export declare function computeSurfaceNormalsRG(data: Float32Array, columns: number, rows: number, xScale: number, yScale: number): Uint8Array<ArrayBuffer>;
35
+ /**
36
+ * Create an RG8 data texture from a buffer produced by {@link computeSurfaceNormalsRG}.
37
+ */
38
+ export declare function createPackedNormalTexture(buffer: Uint8Array, width: number, height: number): DataTexture;
@@ -8,5 +8,8 @@ export declare const PI8: number;
8
8
  * Given a 2D rectangle and an angle off the center, find the point
9
9
  * of the closest corner. Used for anchoring connector lines
10
10
  * to annotation labels.
11
+ *
12
+ * Pass an optional `target` array to write the result into, avoiding
13
+ * an allocation in hot paths.
11
14
  */
12
- export declare function edgeOfRectangle(rect: Vec2, theta: number): Vec2;
15
+ export declare function edgeOfRectangle(rect: Vec2, theta: number, target?: Vec2): Vec2;
@@ -15,6 +15,13 @@ export declare function angleVec3(v1: Vec3, v2: Vec3): number;
15
15
  export declare function rotateVec3(vector: Vec3, axis?: Vec3, angle?: number): Vec3;
16
16
  export declare function directionVec3(v1: Vec3, v2: Vec3): Vec3;
17
17
  export declare function distanceVec3(v1: Vec3, v2: Vec3): number;
18
+ /**
19
+ * Resolve a `number | Vec2 | undefined` parameter into a concrete `Vec2`. A
20
+ * single number is expanded to `[n, n]`; `undefined` falls back to
21
+ * `[fallback, fallback]`. Useful for options that accept either a uniform value
22
+ * or independent X/Z (or width/height) components.
23
+ */
24
+ export declare function asVec2(value: number | Vec2 | undefined, fallback: number): Vec2;
18
25
  export declare function getVec2(buffer: number[], id: number): Vec2;
19
26
  export declare function setVec2(buffer: number[], id: number, value: Vec2): void;
20
27
  export declare function normalizeVec2(v: Vec2): Vec2;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/videx-3d",
3
- "version": "1.1.1",
3
+ "version": "3.0.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -68,12 +68,12 @@
68
68
  "zustand": "^5.0.3"
69
69
  },
70
70
  "devDependencies": {
71
- "@chromatic-com/storybook": "^5.0.1",
71
+ "@chromatic-com/storybook": "^5.2.1",
72
72
  "@eslint/js": "^9.39.3",
73
73
  "@react-three/drei": "^10.7.7",
74
74
  "@react-three/fiber": "^9.5.0",
75
- "@storybook/addon-docs": "^10.2.13",
76
- "@storybook/react-vite": "^10.2.13",
75
+ "@storybook/addon-docs": "^10.4.6",
76
+ "@storybook/react-vite": "^10.4.6",
77
77
  "@types/d3-array": "^3.2.1",
78
78
  "@types/d3-axis": "^3.0.6",
79
79
  "@types/d3-drag": "^3.0.7",
@@ -90,13 +90,13 @@
90
90
  "@types/react-dom": "^19.0.4",
91
91
  "@typescript-eslint/eslint-plugin": "^8.56.1",
92
92
  "@typescript-eslint/parser": "8.56.1",
93
- "@vitejs/plugin-react": "^5.1.4",
93
+ "@vitejs/plugin-react": "^6.0.3",
94
94
  "@vitest/coverage-v8": "^4.0.18",
95
95
  "@vitest/ui": "^4.0.18",
96
96
  "eslint": "^9.39.3",
97
97
  "eslint-plugin-react-hooks": "^7.0.1",
98
98
  "eslint-plugin-react-refresh": "^0.5.2",
99
- "eslint-plugin-storybook": "^10.2.13",
99
+ "eslint-plugin-storybook": "^10.4.6",
100
100
  "globals": "^17.4.0",
101
101
  "lodash": "^4.17.23",
102
102
  "minimist": "^1.2.8",
@@ -105,16 +105,15 @@
105
105
  "react-dom": "^19.2.4",
106
106
  "rimraf": "^6.1.3",
107
107
  "sass": "^1.97.3",
108
- "storybook": "^10.2.13",
108
+ "storybook": "^10.4.6",
109
109
  "typedoc": "^0.28.17",
110
110
  "typescript": "^5.9.3",
111
111
  "typescript-eslint": "^8.56.1",
112
112
  "unplugin-dts": "^1.0.0-beta.6",
113
- "vite": "^7.3.1",
113
+ "vite": "^8.1.3",
114
114
  "vite-plugin-css-injected-by-js": "^4.0.1",
115
- "vite-plugin-externalize-deps": "^0.10.0",
116
115
  "vite-plugin-glsl": "^1.5.5",
117
- "vite-plugin-static-copy": "^3.2.0",
116
+ "vite-plugin-static-copy": "^4.1.1",
118
117
  "vitest": "^4.0.18"
119
118
  },
120
119
  "peerDependencies": {