Simulation
Terrain
32 symbols, imported from @driftengine/terrain.
Explained in Terrain.
Classes
Interfaces
ClipmapFrame- Everything a per-patch decision needs, computed once for a camera.
ClipmapOptionsClipmapPatch- A selected patch, in exactly the terms
heightfieldPatchtakes. HeightfieldOptions- A heightfield, and the two questions everything else asks it.
HeightfieldPatchOptions- One square of a heightfield, as geometry, at a level of detail — and matched to its neighbours.
TerrainHeightLayerTerrainMaterial- Several materials blended across one field, as vertex colour.
TerrainMaterialsOptionsTerrainSplatLayer
Functions
clipmapFrame- Snap a camera to each level's block, once, for a frame.
clipmapLevelAt- The level whose drawn patch covers a field cell, or
-1where nothing draws it. clipmapPatchAt- Decide one patch, by index, writing it into
out. clipmapPatchCount- Patches a frame decides about: every index a compute pass would launch a thread for.
clipmapPatchOptions- A selected patch as the options
heightfieldPatchtakes, with nothing added or renamed. decodeTerrainHeights- Decode every sample of a height layer into
out, in metres, row-major with x fastest. decodeTerrainSplat- Sample the four weights at a field coordinate, renormalised so they sum to one.
emptyClipmapPatch- A patch to write into, so a caller looping over indices allocates nothing.
encodeTerrainHeights- Encode a terrain's samples into a height layer.
encodeTerrainSplat- Encode four material weights per sample.
heightfieldPatchselectClipmap- Every drawn patch, as a list. The convenience over
clipmapPatchAt, not a second rule. terrainFromHeightLayer- The terrain a layer describes: the same class every consumer already queries, built from the decoded samples.
terrainHeightTolerance- The most a decoded height can differ from the one encoded.
terrainMaterialWeights- The normalised weights at a point in the field's own
0..1extent.
Constants
CLIPMAP_LEVELS- Levels a frame builds when the caller does not say.
CLIPMAP_PATCH_CELLS- Drawn cells along one edge of every patch, at every level.
CLIPMAP_PATCHES_ACROSS- Patches along one edge of a level's block. A multiple of four, for the reason above.
TERRAIN_HEIGHT_LEVELS- Quantisation levels a height layer carries: sixteen bits.
TERRAIN_SPLAT_CHANNELS- Materials a splat layer blends. Four, because that is one texel.
TERRAIN_SPLAT_LEVELS- Quantisation levels one splat weight carries: eight bits, four of them to a texel.