how to get the height of STK World Terrain?

I added STK World Terrain as my terrain provider as I tried to get the height of the terrain. When I was loading KML files using the mean sea level scale, the KML are floating above the terrain ground. But when I set the height to 0, the objects are floating under the ground.
In this case, how could i get the proper height of STK world terrain?


We don’t really have support for loading KML entities onto yet. You might be able to query the terrain for the correct heights by looping through the entities generated by the KML and adjusting the positions. You can use the function Cesium.sampleTerrain to get the height of the terrain at different positions.

Take a look at this demo:

Scroll to the bottom where it says ‘Sample Everest Terrain’ to see how to use the sample terrain function.

For an example of how to loop through the entities created by your datasource, see this demo:

See the third ‘Custom Styling’ example.

That example uses a GeoJsonDataSource, but a KMLDataSource should work the same way.