1. A concise explanation of the problem you’re experiencing.
Hello, I’m trying to sample terrain with sampleTerrainMostDetailed function. My aim is to create a tool that measures height from the ground. For example, you click on a building and you display height of the clicked point from the ground.
The problem is that there is always some gap between the sampled ground point and displayed terrain. Even when I zoom very close to the building where the best terrain should be loaded. I always thought that the sampled terrain point should correspond to the displayed point with no gap.
The same problem comes when I click on the ground which I demonstrate below.
I came up with an idea that the displayed terrain is not the most detailed one. However, I don’t know how can I check this or if it is possible to enforce the most detailed terrain level to be displayed.
There is measurement in the default Cesium world terrain:
And there is our terrain where the difference is even more visible:
Just a note - the displayed cube goes bellow the terrain.
Am I missing something or there is some trick that can handle this?
2. A minimal code example. If you’ve found a bug, this helps us reproduce and repair it.
const terrainPositionWgs = Cesium.Cartographic.fromCartesian(pickPosition);
Cesium.sampleTerrainMostDetailed(this.viewer.terrainProvider, [terrainPositionWgs]).then(() => {
const pickPositionWgs = Cesium.Cartographic.fromCartesian(pickPosition);
const distance = pickPositionWgs.height - terrainPositionWgs.height;
console.log('DISTANCE: ', distance);
});
3. Context. Why do you need to do this? We might know a better way to accomplish your goal.
I want to measure height from the terrain when a user clicks on a building.
4. The Cesium version you’re using, your operating system and browser.
Cesium 1.51