How to limit the loading distance of Cesium

I’ve found that Cesium has an infinite loading distance in unity. My 3dtile file size is huge, so the frame rate will be low when all of them are loaded.

How do I limit the loading distance of Cesium in Unity?

I used a very foolish approach.
Enable the “Show Tiles In Hierarchy” option.
image
Calculate the distance from all mesh to the camera anchor point, and then enable and disable the “Mesh Renderer” component

Hi @1532167917, welcome to the community!

I’m glad you found a solution that works for you. I’d still like to leave some tips in case this continues to be a problem, or if the needs of your application change.

First, Cesium does not actually have an infinite loading distance. The distance depends on the frustum size of the Main Camera. You could technically adjust the Near / Far clip planes to change this, but that will affect how the camera renders the entire scene, so that may not be desired.

Secondly, 3D Tiles is meant to optimize streaming a lot of data. If you’re experiencing frame rate issues, you can always increase the Maximum Screen Space Error value on your tileset. That will lessen the amount of detail that the tileset attempts to load. You can also decrease the Maximum Simultaneous Tile Loads, which will affect the number of tiles that are loading in the background.

Third, we offer a tile exclusion interface called CesiumTileExcluder, which allows you to exclude tiles based on custom C# logic. This pull request contains an example of how to implement this interface.

The CesiumTileExcluder can do what you’re already doing, but a bit more robustly – it can save a bit on performance, because it won’t try to handle tiles that are entirely excluded. :smile:

Let us know if you have any follow-up questions!

Thanks, that’s exactly what I needed.

Disabling the mesh renderer should be a last resort.
It would be nicer to set the LOD level of the tiles by distance. Is that possible?

@krumelmonster selecting LOD based on distance is default behavior. Can you clarify what you’re looking for?

Technically, LOD is selected by projection of the geometric error onto the screen, which will roughly correspond to distance.

Cutting off rendering at a particular distance is not currently supported, if that’s what you’re after. We get this request a lot, but it won’t actually help as much as people think it will. LOD drops off rapidly in the distance, so cutting off distant tiles entirely will only reduce rendering load very slightly. Reducing the maximum screen-space error, on the other hand, will drastically reduce the time it takes to load and render (at the cost of quality).