sampleHeight

fun sampleHeight(position: Cartographic, objectsToExclude: ReadonlyArray<Any>? = definedExternally, width: Double? = definedExternally): Double(source)

Returns the height of scene geometry at the given cartographic position or undefined if there was no scene geometry to sample height from. The height of the input position is ignored. May be used to clamp objects to the globe, 3D Tiles, or primitives in the scene.

This function only samples height from globe tiles and 3D Tiles that are rendered in the current view. Samples height from all other primitives regardless of their visibility.

const position = new Cartographic(-1.31968, 0.698874);
const height = viewer.scene.sampleHeight(position);
console.log(height);

Return

The height. This may be undefined if there was no scene geometry to sample height from.

Parameters

position

The cartographic position to sample height from.

objectsToExclude

A list of primitives, entities, or 3D Tiles features to not sample height from.

width

Width of the intersection volume in meters. Default value - 0.1

See also