generateHeightfield

function generateHeightfield
universe/src/terrain.ts:1095
generateHeightfield(surface: SurfaceParameters, request: HeightfieldRequest) → Heightfield

Generate one terrain patch.

This is the meaningful CPU work that runs in a worker: a bordered 65×65 patch is 4,761 samples and each is six bands and a crater ladder — 32 ms on a rocky airless world, 34 on an icy dead one, 38 on an atmosphered one where the erosion damping reads the analytic gradient. A world with no craters at all is 9.5. The crater neighborhood is nearly all of that spread and most of the total: it walks about five cells an axis, which is what containing the ejecta reach costs (craters.ts). The result is a Float32Array precisely so it can be transferred rather than copied back to the main thread.

The border samples run s and t outside [0,1], which regionDirection answers on the neighboring face — so the outer ring of a patch at the edge of a cube face is the first interior row of a patch on a different face, exactly equal to what that patch generates for itself. Nothing here knows that happened.

surfaceSurfaceParameters
Undocumented
requestHeightfieldRequest
Undocumented