I added a 3D Tileset model at this location, and when I used these two methods to get the model’s height at the same coordinate point, the two methods returned different heights.
I’m using the latest version of Cesium, 1.136.
I added a 3D Tileset model at this location, and when I used these two methods to get the model’s height at the same coordinate point, the two methods returned different heights.
I’m using the latest version of Cesium, 1.136.
This is the expected behavior. (If both functions returned the same value, then it wouldn’t be necessary two have two functions, for what it’s worth).
Assuming some familiarity with the concept of “Level Of Detail” in 3D Tiles (and in general):
The sampleHeight function computes the height based on the representation of the terrain that is currently rendered.
The sampleHeightMostDetailed computes the height based on the most detailed representation of the terrain that is available. (Hence the name…). This means that this function may internally make additional web requests to load the most detailed data that is available for the given point.
A crude attempt to illustrate where the different heights are coming from:
The “most detailed” height may be slightly smaller or larger than the “simple” height. The magnitude of the difference should depend on (or be limited by) the “geometric error” of the tile, but that’s not something that can be taken for granted.
Oh, I thought sampleHeightMostDetailed was an asynchronous batch method for getting positions, which would be faster and more performance-efficient than getting them one by one. Well, but using this sampleHeightMostDetailed can cause some undesirable behavior. For example, I’m drawing a path on a 3D tileset, and I want to calculate interpolation points along this path. I expect all the interpolated points to be on the 3D tileset, but some of the calculated points end up on the ground.
When you are computing the interpolated points using sampleHeightMostDetailed, then they should not be on the ground. There has been an issue at Terrain with multiple layers loading higher LOD tiles inconsistantly · Issue #11312 · CesiumGS/cesium · GitHub where it sometimes returned wrong results, and some forum threads indicating that this issue - even though it was closed - may not be resolved in all cases, but I’m not aware of actual test cases or investigations here.
Wait, hang on, just to clearify something; you sample on a 3D model, and not on the “ground”, so to speak? Because a model is stationary, unless you move it to match the terrain levels?
The main difference between the two functions is what zoom level you’re currently at for the first (ie. the terrain already loaded), while the second will ask for the highest details straight away (with a Promise, hopefully when said detail levels are loaded) and different zoom levels might have different accuracy (in fact, they do, there’s tons of interpolation going on, especially in lazy-loaded DEMs/DTMs. This “level of detail based on what you’re looking at, and where the cache is at that time” applies to terrain and 3D tiles. I hope 3D tiles are part of the equation of “mostDetailed”, but my experience is mostly with sampling on terrain / ground.
Cheers,
Alex