Hi, I am very new to Cesium and am looking for some advice.
We already have an application set up to stream data into CesiumForUnreal.
What we want to do now is automatically clip specific areas on the map; these areas are set up in 3D software and exported with the scene (now they are represented by simple plane meshes).
I think I can read the tileset data in C++ and somehow get the mesh data, then generate Catographic Polygons based on that.
But the tiles only load when the camera is close enough, and they will be unload/reload frequently, so I am wondering if this is the best way to do it.
We are on CesiumForUnreal v2.16.1. What would be a better approach here?
What I can think of now is if we can stream JSON (like GeoJSON) into CesiumForUnreal, then generate Catographic Polygons using the point data. But CesiumForUnreal doesn’t seem to support GeoJSON?
Hi @isseychen,
This should be possible in the latest versions of Cesium for Unreal! v2.16.1 is a fairly old version of the plugin; since then, we have added:
- Support for reading GeoJSON documents in v2.18.0
- Support for generating a polygon from an array of coordinates at runtime in v2.23.0
With this, it should be possible to pass in a GeoJSON document, iterate over its line strings, and set the resulting array of points on a CesiumCartographicPolygon. Let us know if this works for your use case!
Ah thanks!
I don’t think we can upgrade now, but I will check the latest Cesium for Unreal to see if there are any functions we can use.
Thanks for the reply!
A follow-up question.
Do you think it’s a good idea for CesiumCartographicPolygon to be created/destroyed dynamically, like the streaming of 3DTiles?
We are discussing this because we are not sure of the performance cost of just creating a lot of CesiumCartographicPolygon on Earth and leaving them there, even though they might be on the other side of the Earth.
If we want to load/unload them dynamically, is that a function of Cesium?
Hey @isseychen,
Good question. The short answer: polygons on the other side of the Earth should have minimal performance impact because the CesiumPolygonRasterOverlay only needs to rasterize polygons for tiles that are actually loaded. Since tiles far from the camera aren’t loaded, those distant polygons effectively do nothing at render time.
The main cost is the per-frame check of each polygon against each loaded tile’s bounds to determine if rasterization is needed. For a moderate number of polygons (tens to low hundreds), this should be negligible. If you’re looking at thousands, you’d want to profile it.
So for your case, I’d suggest:
-
Start with keeping them all active. If your polygon count is reasonable, the simplicity of “create them all and leave them” likely outweighs the engineering cost of a dynamic loading system.
-
Profile if you notice issues. Use Unreal’s stat tools to check if the overlay is taking significant frame time. If it is, then dynamic creation/destruction becomes worthwhile.
-
Dynamic creation is supported (as Janine mentioned, v2.23.0 added SetPolygonPoints at runtime), so you have the option to build a streaming system around it if needed. But I’d only go there if profiling shows a problem.
There isn’t currently a built-in “stream polygons like tiles” system in the plugin, so that would be something you’d build on your end if needed.
Hope that helps frame the decision!
Ah, thanks for the reply!
That’s very helpful!