HeightmapTerrainData

HeightmapTerrainData

new

Terrain data for a single tile where the terrain data is represented as a heightmap. A heightmap is a rectangular array of heights in row-major order from south to north and west to east.

Parameters:
Name Type Argument Default Description
description.buffer TypedArray The buffer containing height data.
description.width Number The width (longitude direction) of the heightmap, in samples.
description.height Number The height (latitude direction) of the heightmap, in samples.
description.childTileMask Number <optional>
15 A bit mask indicating which of this tile's four children exist. If a child's bit is set, geometry will be requested for that tile as well when it is needed. If the bit is cleared, the child tile is not requested and geometry is instead upsampled from the parent. The bit values are as follows:
Bit PositionBit ValueChild Tile
01Southwest
12Southeast
24Northwest
38Northeast
description.structure Object <optional>
An object describing the structure of the height data.
Properties
Name Type Argument Default Description
heightScale Number <optional>
1.0 The factor by which to multiply height samples in order to obtain the height above the heightOffset, in meters. The heightOffset is added to the resulting height after multiplying by the scale.
heightOffset Number <optional>
0.0 The offset to add to the scaled height to obtain the final height in meters. The offset is added after the height sample is multiplied by the heightScale.
elementsPerHeight Number <optional>
1 The number of elements in the buffer that make up a single height sample. This is usually 1, indicating that each element is a separate height sample. If it is greater than 1, that number of elements together form the height sample, which is computed according to the structure.elementMultiplier and structure.isBigEndian properties.
stride Number <optional>
1 The number of elements to skip to get from the first element of one height to the first element of the next height.
elementMultiplier Number <optional>
256.0 The multiplier used to compute the height value when the stride property is greater than 1. For example, if the stride is 4 and the strideMultiplier is 256, the height is computed as follows: `height = buffer[index] + buffer[index + 1] * 256 + buffer[index + 2] * 256 * 256 + buffer[index + 3] * 256 * 256 * 256` This is assuming that the isBigEndian property is false. If it is true, the order of the elements is reversed.
isBigEndian Boolean <optional>
false Indicates endianness of the elements in the buffer when the stride property is greater than 1. If this property is false, the first element is the low-order element. If it is true, the first element is the high-order element.
description.createdByUpsampling Boolean <optional>
false True if this instance was created by upsampling another instance; otherwise, false.
Example
var buffer = ...
var heightBuffer = new Uint16Array(buffer, 0, that._heightmapWidth * that._heightmapWidth);
var childTileMask = new Uint8Array(buffer, heightBuffer.byteLength, 1)[0];
var waterMask = new Uint8Array(buffer, heightBuffer.byteLength + 1, buffer.byteLength - heightBuffer.byteLength - 1);
var structure = Cesium.HeightmapTessellator.DEFAULT_STRUCTURE;
var terrainData = new Cesium.HeightmapTerrainData({
  buffer : heightBuffer,
  width : 65,
  height : 65,
  childTileMask : childTileMask,
  structure : structure,
  waterMask : waterMask
});
See:
Source:

Members

:Uint8Array|Image|Canvas

The water mask included in this terrain data, if any. A water mask is a rectangular Uint8Array or image where a value of 255 indicates water and a value of 0 indicates land. Values in between 0 and 255 are allowed as well to smoothly blend between land and water.

Methods

Creates a TerrainMesh from this terrain data.

Parameters:
Name Type Description
tilingScheme TilingScheme The tiling scheme to which this tile belongs.
x Number The X coordinate of the tile for which to create the terrain data.
y Number The Y coordinate of the tile for which to create the terrain data.
level Number The level of the tile for which to create the terrain data.
Returns:
Promise | TerrainMesh A promise for the terrain mesh, or undefined if too many asynchronous mesh creations are already in progress and the operation should be retried later.

Computes the terrain height at a specified longitude and latitude.

Parameters:
Name Type Description
rectangle Rectangle The rectangle covered by this terrain data.
longitude Number The longitude in radians.
latitude Number The latitude in radians.
Returns:
Number The terrain height at the specified position. If the position is outside the rectangle, this method will extrapolate the height, which is likely to be wildly incorrect for positions far outside the rectangle.

Determines if a given child tile is available, based on the HeightmapTerrainData.childTileMask. The given child tile coordinates are assumed to be one of the four children of this tile. If non-child tile coordinates are given, the availability of the southeast child tile is returned.

Parameters:
Name Type Description
thisX Number The tile X coordinate of this (the parent) tile.
thisY Number The tile Y coordinate of this (the parent) tile.
childX Number The tile X coordinate of the child tile to check for availability.
childY Number The tile Y coordinate of the child tile to check for availability.
Returns:
Boolean True if the child tile is available; otherwise, false.

Upsamples this terrain data for use by a descendant tile. The resulting instance will contain a subset of the height samples in this instance, interpolated if necessary.

Parameters:
Name Type Description
tilingScheme TilingScheme The tiling scheme of this terrain data.
thisX Number The X coordinate of this tile in the tiling scheme.
thisY Number The Y coordinate of this tile in the tiling scheme.
thisLevel Number The level of this tile in the tiling scheme.
descendantX Number The X coordinate within the tiling scheme of the descendant tile for which we are upsampling.
descendantY Number The Y coordinate within the tiling scheme of the descendant tile for which we are upsampling.
descendantLevel Number The level within the tiling scheme of the descendant tile for which we are upsampling.
Returns:
Promise | HeightmapTerrainData A promise for upsampled heightmap terrain data for the descendant tile, or undefined if too many asynchronous upsample operations are in progress and the request has been deferred.

Gets a value indicating whether or not this terrain data was created by upsampling lower resolution terrain data. If this value is false, the data was obtained from some other source, such as by downloading it from a remote server. This method should return true for instances returned from a call to HeightmapTerrainData#upsample.

Returns:
Boolean True if this instance was created by upsampling; otherwise, false.