Skip to content

@relu-interactives/spatial-ecs


@relu-interactives/spatial-ecs / components / TerrainComponent

Class: TerrainComponent ​

Defined in: components/Terrain.ts:69

Ground you can sculpt and paint: a heightmap drawn in chunks that get simpler with distance, painted in up to four colour layers, with a physics collider and an optional occluder role (hills hide what's behind them).

Its shape comes from dataPath (a .terrain file the editor writes when you sculpt or paint) or, without one, from noise: the same settings always make the same terrain, so a big world can start with no file at all. The entity's origin is the terrain's centre; it spans size metres on X and Z.

Add GrassComponent and ScatterComponent to the same entity for grass, trees and rocks on it. Scripts read the ground with this.world.terrain?.heightAt(x, z).

Extends ​

Constructors ​

Constructor ​

ts
new TerrainComponent(options?): TerrainComponent;

Defined in: components/Terrain.ts:94

Parameters ​

ParameterType
optionsTerrainOptions

Returns ​

TerrainComponent

Overrides ​

Component.constructor

Properties ​

PropertyTypeDefault valueDescriptionDefined in
sizenumber256Metres per side.components/Terrain.ts:71
resolutionnumber257Height samples per side (65 to 2049). More is finer and heavier.components/Terrain.ts:73
dataPathstring""A .terrain file with sculpted heights and paint. Empty: made from noise.components/Terrain.ts:75
noiseTerrainNoiseundefined-components/Terrain.ts:76
layersTerrainLayer[]undefined-components/Terrain.ts:77
autoPaintbooleantruePainted by height and slope instead of by hand (only without a file).components/Terrain.ts:79
paintRulesTerrainPaintRule[]undefined-components/Terrain.ts:80
chunkQuadsnumber64Grid squares per chunk side. Each chunk is one draw.components/Terrain.ts:82
lodDistancenumber80Metres from the camera at which chunks drop to half detail, then quarter at twice that, and so on. 0: always full.components/Terrain.ts:84
flatShadingbooleanfalseFaceted, low-poly shading.components/Terrain.ts:86
castShadowbooleanfalse-components/Terrain.ts:87
receiveShadowbooleantrue-components/Terrain.ts:88
colliderbooleantrueA physics heightfield collider (fixed) that follows the terrain.components/Terrain.ts:90
occluderbooleantrueHills hide what's behind them (occlusion culling).components/Terrain.ts:92