Hey, it seems that cesium is rendering entities even when they are outside of the view (like wheen you zoom in), I’m using 2D view mode. this casues massive performance hit.
is there any way to tell cesium it should not render entities (more specifically point / billBoard) if they are outside of the viewing zone?
Are your points/billboards using a
CLAMP_TO_GROUND height reference? If so, I think you could be effected by this bug: Clamped billboard has incorrect bounding sphere in 2D and Columbus View · Issue #5042 · CesiumGS/cesium · GitHub
Cesium is usually really good at culling entities that are outside of the view when the bounding sphere is correct. However, we have a bug where bounding spheres are computed incorrectly for billboards that are clamped to ground, so Cesium thinks they are still in view when they are now.
Otherwise, could you please provide a small code example to reproduce your bug?
Hey @hannah, I am using the default height reference.
please check out the following sand castle example:
- when there are only 10 entities on the map I am getting high fps
- when I put 10000 entities on the map and zoom in so I only see 10 I expect to also get high fps but I’m not.
- after 12 seconds I hide all entities but 10 and then I do get good fps, which makes me wonder why cesium wastes resources on rendering entities that are out of view
I have a pretty elaborate setup where I retain source data to build Entities elsewhere in memory, and hook the camera “move-end” event. When it fires, I manually cull offscreen Entities from the DataSource, then add new onscreen ones. This means the user doesn’t see new entities while dragging but that’s OK for our use-case. If I could count on Cesium to completely ignore “out of view” Entities – if performance only depended on visible entities – I could get rid of all that extra infrastructure.
For fun I I set up a test here using my ‘billboard speedup’ library. Getting 48 fps with all the billboards. Is this more like the performance you are expecting?
I do that too, my IsInView check is pretty slow because it uses wgs84ToWindowCoordinates (cartesianToCanvasCoordinates), did you @James_B find a fast way to check if an entity is in screen?
like I tried to find the geo position of all screen corner and then directley check IsInView with entity Cartesian3 instead of window (x, y) but I couldn’t figure out how to check if Cartesian3 is inside a Cartesian3 Rectangle
Kobe, maybe this bounds-computation function I made would be helpful? It’s Typescript, but if you just take out any type annotations it becomes valid JS. What you get is a point or Rectangle that contains the Entity – well, the
position plus all the points that make up position-independent shapes like Polyline, but not the extruded surfaces of positoin-dependent shapes like Ellipse or Cylinder. It’s not perfect, but if the bounding Rectangle doesn’t overlap with the viewport, you know that at least you can’t see the center of any graphic owned by the Entity.
To determine overlap, I had to use separate functions depending on map mode, due to a number of bugs with the functions that go between screenspace coordinates and world coordinates in various modes. This is most of it, though do note my comment at the bottom about how I’m assuming you already figured out how to get a Rectangle representing your viewport.
Hopefully this helps you!