TerrainMaterial
TerrainMaterial holds the render options for a terrain layer’s mesh. It is set via the terrain key and applies regardless of the source’s data format: raster-dem (RGB-encoded elevation) or quantized-mesh. All fetch/geometry config (zoom range, tiling scheme, elevation decoder, extensions, token) lives on the referenced source, not here.
Properties
Section titled “Properties”Type: boolean | undefined
Default: true
Description: Whether to draw the terrain mesh. With false the globe surface is not drawn, and neither is anything rendered onto it: raster layers, hillshade and draped vector features. The terrain data keeps loading, so everything that reads terrain heights keeps working, such as points, billboards and text with clampToGround: true and terrain height sampling.
{ terrain: { show: false } }castShadow
Section titled “castShadow”Type: boolean | undefined
Default: false
Description: Whether the terrain casts shadows.
{ terrain: { castShadow: true } }receiveShadow
Section titled “receiveShadow”Type: boolean | undefined
Default: false
Description: Whether the terrain receives shadows.
{ terrain: { receiveShadow: true } }Type: boolean | undefined
Default: undefined (follows view.lit)
Description: Applies the lighting equation to the color output. When false, the terrain renders as plain albedo. The rest of the lit pipeline still runs, so normals and the shadow G-buffer keep being written. Leaving it unset follows the scene default, view.lit. Setting it explicitly overrides that default in either direction.
{ terrain: { lit: false } }showBoundingBox
Section titled “showBoundingBox”Type: boolean | undefined
Default: false
Description: Whether to show per-tile bounding boxes. Used for debugging.
{ terrain: { showBoundingBox: true } }Type: boolean | undefined
Default: true
Description: Whether to render skirts along tile boundaries to hide gaps between neighboring tiles at different LODs. Disable this if you want to visualize underground models.
{ terrain: { skirt: true } }skirtExaggeration
Section titled “skirtExaggeration”Type: number | undefined
Default: 1.0
Description: Multiplier applied to the auto-calculated skirt height. 1.0 uses the default calculated height.
{ terrain: { skirtExaggeration: 1.5 } }exaggeration
Section titled “exaggeration”Type: number | undefined
Default: 1
Description: Vertical exaggeration of the terrain. Terrain heights are multiplied by this factor around exaggerationRelativeHeight, and level of detail and culling follow the exaggerated surface. sampleTerrainHeight, observeTerrainHeightAt, sampleTerrainHeightRange, observeTerrainHeightRange, and sampleTerrainMostDetailed return exaggerated heights, so clamp-to-ground features and meshes with heightReference: "terrain" stay on the surface. 3D Tiles and glTF models are not stretched, and elevation heatmaps and hillshade keep using the source heights. A negative value is treated as 0, which flattens the terrain to exaggerationRelativeHeight. Can be changed at runtime with layer.update(), and the exaggeration is reset when the terrain layer is deleted.
const terrainLayer = view.addLayer({ type: "terrain", source: terrain, terrain: { exaggeration: 2 },});
// Change it at runtimeterrainLayer.update({ terrain: { exaggeration: 3 } });exaggerationRelativeHeight
Section titled “exaggerationRelativeHeight”Type: number | undefined
Default: 0
Description: Height in meters that stays in place while the terrain is exaggerated. It is an absolute height measured like the terrain heights themselves (height above the WGS84 ellipsoid, which for a raster-dem source is the decoded elevation value as is), not an offset from the camera or the ground. A terrain height h is rendered at (h - exaggerationRelativeHeight) * exaggeration + exaggerationRelativeHeight. With the default 0, high regions are lifted as a whole, so set it to the elevation of the ground you are looking at (for example a valley floor on a plateau, or the ground under 3D Tiles or models, which are not exaggerated) to emphasize the relief around it while that ground stays in place. Keep 0 when the view spans from the coast to the mountains, so the sea level does not move.
// Exaggerate relief around a basin at 1000 m without moving the basin floorterrainLayer.update({ terrain: { exaggeration: 2, exaggerationRelativeHeight: 1000 },});waterMaskColor
Section titled “waterMaskColor”Type: Color | undefined
Description: Body color of the water that the source’s watermask marks, which requires requestWaterMask on a quantized-mesh source. The water shows this color beneath its sky and sun reflections. When it is not set, the imagery or the globe color beneath the water is used, and aerial imagery often shows the open sea in a bright flat blue. A dark color such as #0d1c2c matches deep open water. Passing undefined uses the imagery or the globe color beneath the water.
terrainLayer.update({ terrain: { waterMaskColor: new Color().setStyle("#0d1c2c") },});waveExaggeration
Section titled “waveExaggeration”Type: number | undefined
Description: Scales the slopes of the waves on the water that the source’s watermask marks, keeping their size and speed. 0 makes a still, mirror-like surface. It requires requestWaterMask on a quantized-mesh source.
Default: 1
waveStrength
Section titled “waveStrength”Type: number | undefined
Description: Sets the size, steepness, and speed of the waves on the water that the source’s watermask marks, which requires requestWaterMask on a quantized-mesh source. About 1 is a calm ripple, 5 is moderate, and 20 is a storm.
Default: 5
waveDirection
Section titled “waveDirection”Type: number | undefined
Description: The direction the waves on the watermask’s water travel, in degrees clockwise from north.
Default: 0
flowSpeed
Section titled “flowSpeed”Type: number | undefined
Description: The speed in m/s of a current that carries the waves on the watermask’s water along waveDirection, without changing their size or slope.
Default: 0
terrainLayer.update({ terrain: { waveStrength: 12, waveDirection: 225, flowSpeed: 2 },});Combining with other layers
Section titled “Combining with other layers”A terrain layer provides only the 3D surface. Drape imagery or shaded relief on top with a raster layer:
| Over terrain | Supported | Notes |
|---|---|---|
raster (imagery) | ✅ Yes | Raster imagery is reprojected and draped onto the mesh. Multiple can be stacked. |
raster (hillshade) | ✅ Yes | Shaded relief computed from DEM tiles, rendered over the 3D surface. |
vector (vector tiles) | ❌ Not yet | Vector tiles cannot currently be draped onto quantized-mesh terrain. |
Related Resources
Section titled “Related Resources”- Terrain Layer: how to use this material
- Raster DEM Source / Quantized Mesh Source: terrain data sources
- CesiumIonPlugin: Cesium Ion quantized-mesh assets