lovr.physics.newTerrainShape
EditCreates a new TerrainShape.
Create a flat floor collider.
Arguments
Name | Type | Description |
scale | number | The width and depth of the terrain, in meters. |
Returns
Name | Type | Description |
terrain | TerrainShape | The new TerrainShape. |
Create terrain from a heightmap image.
Arguments
Name | Type | Default | Description |
scale | number | The width and depth of the terrain, in meters. | |
heightmap | Image | A heightmap image describing the terrain elevation at different points. The red channel brightness of each pixel determines the elevation at corresponding coordinates. | |
stretch | number | 1.0 | A vertical multiplier for height values to obtain terrain height. When the image format has pixel values only in the 0 to 1 range, this can be used to scale the height to meters. |
Returns
Name | Type | Description |
terrain | TerrainShape | The new TerrainShape. |
Create terrain defined with a callback function.
Arguments
Name | Type | Default | Description |
scale | number | The width and depth of the terrain, in meters. | |
callback | function |
A function that computes terrain height from x and z coordinates. The x and z inputs will range from -scale / 2 to scale / 2 .
| |
samples | number | 100 | The number of samples taken across the x and z dimensions. More samples will result in higher terrain fidelity, but use more CPU and memory. |
Returns
Name | Type | Description |
terrain | TerrainShape | The new TerrainShape. |
Notes
A Shape can be attached to a Collider using Collider:addShape
. For immobile terrain use the Collider:setKinematic
.