Skip to content

Function: generateTerrainPalette()

ts
function generateTerrainPalette(
   levelCount, 
   radius?, 
   coreRadiusRatio?, 
   lowColor?, 
   highColor?, 
   atmosphereThickness?): TerrainLevel[];

Generate a rocky terrain palette as a linear gradient from lowColor at the shortest band (i = 0, prism collapsed) to highColor at the tallest band (i = N - 1, silhouette at radius). Caller-side classifications (biomes, climate zones…) are handled by a later pass; this palette is intentionally monochromatic so the hex mesh communicates altitude alone.

Emits exactly levelCount bands. Band i caps at world height i * unit above the core, so the staircase is strictly uniform: height[0] = 0 (collapsed to the core), height[N - 1] = shell (at radius), and every adjacent pair is separated by exactly unit. Thresholds are band indices ([1, 2, ..., N-1, Infinity]), so getTileLevel(elevation, palette) with integer elevation ∈ [0, N-1] returns palette[elevation] exactly.

Parameters

ParameterTypeDefault valueDescription
levelCountnumberundefinedDesired total level count (≥ MIN_TERRAIN_LEVEL_COUNT). Typically resolved via resolveTerrainLevelCount so each band stays proportionate to the tile size.
radiusnumber1Planet visual radius — combined with coreRadiusRatio to derive the world-space step unit = shell / (N - 1).
coreRadiusRationumber0Fraction of radius occupied by the inner core.
lowColorColorRepresentationDEFAULT_TERRAIN_LOW_COLORLow anchor (band 0). Defaults to DEFAULT_TERRAIN_LOW_COLOR.
highColorColorRepresentationDEFAULT_TERRAIN_HIGH_COLORHigh anchor (band N - 1). Defaults to DEFAULT_TERRAIN_HIGH_COLOR.
atmosphereThicknessnumber0-

Returns

TerrainLevel[]

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