Skip to content

Interface: BodyTypeStrategy

Data + builders for a single BodyType.

Fields are deliberately flat data when possible — flatSurface, atmoLayerMode, metallicSheen are read-only constants the consumer lifts straight off the strategy, no function call. The two builders (buildPalette, buildShaderParams) wrap the per-type logic that's too large for a flat record.

Properties

displayName

ts
readonly displayName: string;

Human-readable name — used for logs / panels, not for dispatch.


shaderType

ts
readonly shaderType: LibBodyType;

Shader family used by the procedural material — selects which fragment shader runs (rocky.frag, gas.frag, metallic.frag, star.frag). Decoupled from the public BodyType so the shader catalogue can keep its current names while the public taxonomy moves to 'planetary' | 'star' + SurfaceLook.


flatSurface

ts
readonly flatSurface: boolean;

true when the smooth-sphere display should be flat (no vertex displacement) — currently only stars, whose granulation is a shader effect rather than terrain relief.


displayMeshIsAtmosphere

ts
readonly displayMeshIsAtmosphere: boolean;

true when the smooth display sphere plays the role of the atmosphere itself (gas-giant case) instead of being an inert sol backdrop. Drives four downstream behaviours:

  • the smooth sphere stretches to config.radius (atmospheric silhouette)
  • it stays visible as a backdrop dome in the playable surface view
  • its Side flips to BackSide in surface view (inner curvature read)
  • default vertex paint is skipped (caller paints atmo-flavoured colours)

solVariationRanges?

ts
readonly optional solVariationRanges?: SolVariationRanges;

Per-type sol-side variation ranges. Omitted by every strategy that matches the lib's defaults — only metallic bodies override.


defaultAtmosphereOpacity

ts
readonly defaultAtmosphereOpacity: number;

Default atmosphere opacity for the 'shader' view, in [0, 1]. The config can override via BodyConfig.atmosphereOpacity. Gas giants land at 1 (opaque envelope, smooth sphere can be skipped); rocky bodies use a translucent halo (~0.45); metallic and stars default to 0 (no atmo halo on shader view).


canHaveRings

ts
readonly canHaveRings: boolean;

Whether this body type can ever carry a decorative ring system.


metallicSheen

ts
readonly metallicSheen: number;

Metallic sheen coefficient passed to the legacy hex shader. 1.0 for metallic bodies, 0.0 otherwise. Lifted into the strategy so the shader override receives a single numeric input.

Methods

tileRefRadius()

ts
tileRefRadius(config): number;

Returns the tile-reference radius used to derive the hexasphere subdivision count. Stars use STAR_TILE_REF keyed by spectral class (so tile counts stay stable across O/B/A/F/G/K/M); planets use their own visual radius.

Parameters

ParameterType
configBodyConfig

Returns

number


buildPalette()

ts
buildPalette(
   config, 
   count, 
   coreRadiusRatio): TerrainLevel[];

Builds the terrain palette at the given band count. Each strategy is responsible for densification + re-mapping to the integer band model used downstream — the function returns the final palette (length === count, threshold i+1 per band, Infinity on the last band, height = i × layout.unit or 0 when flatSurface).

Parameters

ParameterType
configBodyConfig
countnumber
coreRadiusRationumber

Returns

TerrainLevel[]


buildShaderParams()

ts
buildShaderParams(
   config, 
   seed, 
   variation?): ParamMap;

Builds the shader uniform map for this body's procedural material. Combines the type's default param block with caller-supplied physics + variation. Receives the deterministic seed so each strategy can stamp it on its own field naming.

Parameters

ParameterType
configBodyConfig
seednumber
variation?BodyVariation

Returns

ParamMap

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