Clamping To Latitude Longitude position

My use case is that I want to pick some points and then have objects anchored to those latitude/longitude positions (even if the terrain or 3d tiles under them changes).

Using {enableCollision:true} lets me do that with picking and clamping the billboards to the ground, but in some case there are performance issues in CesiumJS that make it unusable.

Has anyone ran into this problem? What approach did you take?

Here is what I am going to try do to (I’ll let you know if this works out).

  1. Pick the point using useDepthPicking to get the visual point the user clicked on. This Sandcastle shows picking Google 3D Tiles.

  2. Raise an event whenver the loaded assets or terrian change and then re-clamp everything using Scene.clampToHeightMostDetailed. This is probably going to be the most work to thread the event through the application and then update the heights.

Got this implemented and working.

Scene.sampleHeightMostDetailed was a finicky depending on where the assets were in the loading process. I ended up doing two things to try and make this have more consistent returns regardless of how much imagery or terrain had loaded:

  • Waiting for at least one render (Scene.postRender) before trying to query the heights
  • Fallback to global sampleHeightsMostDetailed using the terrain provider (doesn’t work with EllipsoidTerrainProvider though so need to check that before calling)