Computing camera extents in 2D and 3D

To figure out the region visible to the camera, there is a Camera.computeViewRectangle method, but this doesn’t always produce the correct result, see https://github.com/CesiumGS/cesium/issues/4346.

One workaround is to extract all the loaded globe tiles, which each have a rectangle bounding box, and get the union of those. This will be an over estimate of the view, but if you’re using it as a way to figure out what the view area is to load data from a server, this should be a good option since you’ll never get any gaps.

Here is a Sandcastle that implements this. It draws a rectangle with the Cesium logo on it.

2 Likes