terrain
terrain
The terrain static module provides methods to query and manipulate voxel/heightmap terrain at any world position.
Overview
Methods (8)
| Method Signature | Returns | Summary |
|---|---|---|
terrain.getControl(position)
|
number
|
Gets the terrain control map pixel value. |
terrain.getDominantTexture(position)
|
number
|
Gets the dominant terrain texture layer index at position. |
terrain.getHeight(position)
|
number
|
Gets terrain elevation height at position. |
terrain.getNormal(position)
|
vector3
|
Gets the terrain surface normal vector. |
terrain.getSteepness(position)
|
number
|
Gets the steepness of the terrain at position. |
terrain.getSurfacePosition(position)
|
vector3
|
Calculates the 3D surface point on ground. |
terrain.getSurfaceRotation(position)
|
vector3
|
Calculates Euler rotation aligned to terrain slope. |
terrain.setHeight(position, height)
|
void
|
Sets terrain surface height at the given coordinate. |
Detailed Reference
terrain.getControl(position)| Parameter | Type | Default | Description |
|---|---|---|---|
position | vector3 | Query coordinates. |
numberControl map raw uint value.
Reads raw splatmap / control data used for terrain blending.
terrain.getDominantTexture(position)| Parameter | Type | Default | Description |
|---|---|---|---|
position | vector3 | Query coordinates. |
numberTexture layer index.
Returns the texture layer index with the highest weight (e.g. sand, grass, rock).
terrain.getHeight(position)| Parameter | Type | Default | Description |
|---|---|---|---|
position | vector3 | Horizontal 3D coordinates. |
numberTerrain height (Y value).
Returns the terrain Y elevation at the given X/Z coordinates.
terrain.getNormal(position)| Parameter | Type | Default | Description |
|---|---|---|---|
position | vector3 | Query coordinates. |
vector3Surface normal unit vector.
Returns the normalized 3D normal perpendicular to the terrain at position.
terrain.getSteepness(position)| Parameter | Type | Default | Description |
|---|---|---|---|
position | vector3 | Query coordinates. |
numberNormalized steepness factor (0.0 flat to 1.0 vertical).
Returns a normalized slope factor.
terrain.getSurfacePosition(position)| Parameter | Type | Default | Description |
|---|---|---|---|
position | vector3 | Query coordinates. |
vector3Exact point on ground surface.
Returns a vector3 with the terrain height as the Y coordinate.
terrain.getSurfaceRotation(position)| Parameter | Type | Default | Description |
|---|---|---|---|
position | vector3 | Query coordinates. |
vector3Euler rotation in degrees aligned with slope.
Computes the pitch and roll angles matching the ground normal at position.
terrain.setHeight(position, height)| Parameter | Type | Default | Description |
|---|---|---|---|
position | vector3 | Horizontal 3D coordinates. | |
height | number | New height value in world units. |
Modifies the terrain elevation at position.