When I’m trying to zoom to an entity added to viewer with heightReference set to CLAMP_TO_GROUND Its behaving weirdly , first it zooms but since its clamped to ground the model gets clamped to ground after zooming.
So im again zooming to entity to solve this.What is the reason its occuring.I shared a sandcastle example.Is the model taking time to clamp after adding.
You are correct that the issue here is that clamping to terrain is asynchronous. You can try to zoom in to the entity, check for when the tiles have finished loading:
https://cesium.com/docs/cesiumjs-ref-doc/Globe.html?classFilter=Globe#tilesLoaded
And then trigger any camera zoom to fly to the entity. Alternately, using the primitive API would let you access the ready promise to check when the geometry has finished loading and is ready, and then zoom to it.