Build an ocean box whose sea bed is the bathymetry of a depth surface,
extracted (e.g. from an IRAP binary grid) as a row-major Float32Array plus
the grid header. The function is data-agnostic — it takes the raw values
and header, so it can be called from a generator or anywhere else.
The result is positioned in the same local space as the Surface component
(the far row is centered on the rotation pivot and the grid is rotated by
header.rot; the world xori/yori origin is not baked in, so position
the resulting <Ocean> exactly as you would a Surface). Sea level is the
reference: the water surface lies at y = 0 and the bed at y = -depth
(depths are positive-down).
Invalid samples connected to the grid border are treated as the outer rim
(outside the surface footprint) and kept as holes, so the bed and walls
follow the true surface outline; invalid samples fully enclosed by valid data
are internal holes and get filled so the box stays watertight.
surface — flat water plane at y = 0 tracing the same valid-region
outline as the walls and bed (not a plain rectangle).
body — walls tracing the outline of the valid region, from y = 0
down to the bathymetry.
bed — a simplified TIN of the (internal-hole-filled) bathymetry.
Set rimSmoothing to relax the grid-aligned outline into a smooth, curved
rim by moving only the existing boundary vertices in place (the sea-bed TIN
and all interior detail are preserved).
Set referenceDepth when the input grid is depth-normalized (e.g. stored as
referenceDepth - trueDepth, as produced by this repo's IRAP parser) so the
bed is placed at its true depth below sea level instead of being anchored to
the shallowest sample; leave it undefined when values already hold true,
positive-down depths.
Build an ocean box whose sea bed is the bathymetry of a depth surface, extracted (e.g. from an IRAP binary grid) as a row-major
Float32Arrayplus the gridheader. The function is data-agnostic — it takes the raw values and header, so it can be called from a generator or anywhere else.The result is positioned in the same local space as the
Surfacecomponent (the far row is centered on the rotation pivot and the grid is rotated byheader.rot; the worldxori/yoriorigin is not baked in, so position the resulting<Ocean>exactly as you would aSurface). Sea level is the reference: the water surface lies aty = 0and the bed aty = -depth(depths are positive-down).Invalid samples connected to the grid border are treated as the outer rim (outside the surface footprint) and kept as holes, so the bed and walls follow the true surface outline; invalid samples fully enclosed by valid data are internal holes and get filled so the box stays watertight.
y = 0tracing the same valid-region outline as the walls and bed (not a plain rectangle).y = 0down to the bathymetry.Set
rimSmoothingto relax the grid-aligned outline into a smooth, curved rim by moving only the existing boundary vertices in place (the sea-bed TIN and all interior detail are preserved).Set
referenceDepthwhen the input grid is depth-normalized (e.g. stored asreferenceDepth - trueDepth, as produced by this repo's IRAP parser) so the bed is placed at its true depth below sea level instead of being anchored to the shallowest sample; leave it undefined whenvaluesalready hold true, positive-down depths.