Skip to content

Interface: BodySimulation

Authoritative simulation state for a single celestial body.

Pure data-layer result of initBodySimulation — captures per-tile elevation (quantised into integer bands), sea level, liquid coverage and the dominant surface liquid type. Independent from any render layer so it can run in a headless environment. Resource distribution is an entirely off-lib concern: consumers run their own strategy against the returned sim and keep the result wherever fits their domain.

Properties

tiles

ts
readonly tiles: readonly Tile[];

tileStates

ts
readonly tileStates: ReadonlyMap<number, TileState>;

config

ts
readonly config: BodyConfig;

atmoTiles

ts
readonly atmoTiles: readonly Tile[];

Atmosphere board tiles — independent hexasphere from the sol board, with its own subdivision count (derived from the atmosphere outer radius rather than the sol surface radius). Empty array when the body carries no atmosphere (hasAtmosphere(config) === false).

Atmo tile ids are NOT comparable to sol tile ids: a sol tile 42 has no relation to an atmo tile 42 — they live on separate hexaspheres. Resource distribution on the atmo board is an off-lib concern; the lib exposes the tiles, consumers paint them through the atmo board mesh.


elevationAt

ts
readonly elevationAt: (x, y, z) => number;

Returns the integer elevation band [0, N-1] at any world-space point on the planet. Uses the same seeded simplex + quantisation as tile elevations, so a point placed on a tile center resolves to that tile's band. Safe for smooth-sphere vertex colouring which then looks up the palette by band index.

Parameters

ParameterType
xnumber
ynumber
znumber

Returns

number


seaLevelNoise

ts
readonly seaLevelNoise: number;

Simplex-space threshold where the sea waterline sits, for shaders that reuse the raw simplex noise (smooth-sphere ocean mask). Use seaLevelElevation everywhere else — the band-space value is the canonical one for tile logic.

Equals -1 on dry bodies (no ocean), so > -1 works as the "has water" test like before.


bandToNoiseThreshold

ts
readonly bandToNoiseThreshold: (band) => number;

Inverse of the band-quantisation: maps a (possibly fractional) band value to the corresponding simplex-noise threshold. Used at runtime to push a moving sea level into the ocean-mask shader uniform.

Returns -1 on dry bodies (no quantisation table available).

Parameters

ParameterType
bandnumber

Returns

number


liquidCoverage

ts
readonly liquidCoverage: number;

Fraction of tiles below sea level (0..1). 0 for stars / gaseous / dry worlds.


seaLevelElevation

ts
readonly seaLevelElevation: number;

Sea waterline expressed in band space [0, N-1] (can be fractional — the waterline may sit between two bands). -1 on dry bodies. Callers mutating this at runtime (UI sliders, external mutators) drive submerged reclassification via elevation < seaLevelElevation.


hasLiquidSurface

ts
readonly hasLiquidSurface: boolean;

true when the body carries a surface liquid (rocky with liquidState !== 'none'). Dry worlds, gaseous, metallic and stars all report false. Substance identity is caller-owned and not surfaced here — consumers that need a label look up their own catalogue keyed on the original config they passed in.

Distribué sous la licence indiquée dans le dépôt.