sampleHeightMostDetailed
* Initiates an asynchronous query for an array of positions using the maximum level of detail for 3D Tilesets in the scene. The height of the input positions is ignored.Returns a promise that is resolved when the query completes. Each point height is modified in place.
使用场景中3D Tilesets的最大细节级别启动对位置数组 的异步查询。输入位置的高度被忽略。返回查询完成时解析的promise,每个点的高度都被就地修改。
If a height cannot be determined because no geometry can be sampled at that location, or another error occurs, the height is set to undefined.
* @example
* const positions = [
* new Cesium.Cartographic(-1.31968, 0.69887),
* new Cesium.Cartographic(-1.10489, 0.83923)
* ];
* const promise = viewer.scene.sampleHeightMostDetailed(positions);
* promise.then(function(updatedPosition) {
* // positions[0].height and positions[1].height have been updated.
* // updatedPositions is just a reference to positions.
* }
-------------------------------------------------------------------------------
Scene.prototype.sampleHeightMostDetailed = function (
positions,
objectsToExclude,
width
) {
return this._picking.sampleHeightMostDetailed(
this,
positions,
objectsToExclude,
width
);
};
实验案例
const positions = [new Cesium.Cartographic.fromDegrees(longitude, latitude),
new Cesium.Cartographic.fromDegrees(longitude, latitude + 0.0001) ];
const promise = scene.sampleHeightMostDetailed(positions);
promise.then(function(updatedPositions) {
positions[0].height = updatedPositions[0].height;
console.log('Height at point:', height);
});