HeightmapTessellator

HeightmapTessellator

Contains functions to create a mesh from a heightmap image.

Members

staticHeightmapTessellator.DEFAULT_STRUCTURE

The default structure of a heightmap, as given to HeightmapTessellator.computeVertices.

Methods

staticHeightmapTessellator.computeVertices()

Fills an array of vertices from a heightmap image. On return, the vertex data is in the order [X, Y, Z, H, U, V], where X, Y, and Z represent the Cartesian position of the vertex, H is the height above the ellipsoid, and U and V are the texture coordinates.
Name Type Default Description
options.vertices Array | Float32Array The array to use to store computed vertices. If options.skirtHeight is 0.0, the array should have options.width * options.height * 6 elements. If options.skirtHeight is greater than 0.0, the array should have (options.width + 2) * (options.height * 2) * 6 elements.
options.heightmap TypedArray The heightmap to tessellate.
options.width Number The width of the heightmap, in height samples.
options.height Number The height of the heightmap, in height samples.
options.skirtHeight Number The height of skirts to drape at the edges of the heightmap.
options.nativeRectangle Rectangle An rectangle in the native coordinates of the heightmap's projection. For a heightmap with a geographic projection, this is degrees. For the web mercator projection, this is meters.
options.rectangle Rectangle optional The rectangle covered by the heightmap, in geodetic coordinates with north, south, east and west properties in radians. Either rectangle or nativeRectangle must be provided. If both are provided, they're assumed to be consistent.
options.isGeographic Boolean true optional True if the heightmap uses a GeographicProjection, or false if it uses a WebMercatorProjection.
options.relativetoCenter Cartesian3 Cartesian3.ZERO optional The positions will be computed as Cartesian3.subtract(worldPosition, relativeToCenter).
options.ellipsoid Ellipsoid Ellipsoid.WGS84 optional The ellipsoid to which the heightmap applies.
options.structure Object optional An object describing the structure of the height data.
Name Type Default Description
heightScale Number 1.0 optional 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 0.0 optional 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 1 optional 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 1 optional 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 256.0 optional 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 false optional 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.
Example:
var width = 5;
var height = 5;
var vertices = new Float32Array(width * height * 6);
var options = ;
Cesium.HeightmapTessellator.computeVertices({
    vertices : vertices,
    heightmap : [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0],
    width : width,
    height : height,
    skirtHeight : 0.0,
    nativeRectangle : {
        west : 10.0,
        east : 20.0,
        south : 30.0,
        north : 40.0
    }
});