Bounding sphere for polygons/ellipses on ground incorrectly computed?

I’m creating a ellipse entities to mark locations of buildings of interest, and doing viewer.flyTo(entity) to find the building with specific properties (like the one that has the most energy use for example).

The problem is that the camera seems to fly to a position that’s further away than expected when using geometry that’s clamped to the ground (like ellipses/polygon), but works as expected for a box/point. This makes it hard to actually find the building especially if it’s a small building in the middle of the city.

Here’s a Sandcastle reproducing it. Click “Zoom to entities” (you’ll need to click Zoom again after the terrain loads). When you have an ellipse or a polygon, the camera flies much further away than if you had a box with roughly the same size.

It seems that the problem is that the center of geometry isn’t in the right place? If you click on the ellipse you see the selection indicator is high up in the air:

But for the box it works as expected:

image

I could fix this by, instead of zooming to the entity, zooming to its position (and sampling the ground height) but I’m curious if this behavior is expected or if this is a bug.

Thanks to Hannah for pointing out offline that the issue here is that when a polygon is clamped to the ground in CesiumJS, this happens at the shader level. So if there was a cliff or a tower in the middle of that polygon, it’ll get “draped” on top of that. So part of the polygon will be very high up and part of it will be on the ground.

When you do viewer.flyTo() in CesiumJS it flies to the bounding box, which is typically the min/max of what the terrain could be: