3. Context. Why do you need to do this? We might know a better way to accomplish your goal.
we display multiple layers of translucent polygons and a layer of images. All layers should be on ground (no terrain is currently used).
The order of layers is important - some layers should be above the image layer while other layers should be below the image. Since non-image layer are all translucent relative ordering is not important.
Polygons and images are added/removed dynamically (on user actions)
Some polygons should have outlines
Layers are GeoJsonDataSource
1. A concise explanation of the problem you're experiencing.
We the following issue also see attached image:
1. setting entity height to undefined disables outlines (and prints warning [Entity geometry outlines are unsupported on terrain]). Artifacts on entity edges. The artifact changes when panned left to right
2. setting height of all items to 0 enables outlines, but creates artifacts on overlapping translucent entities and we cannot control order of images - they get buried under other layers.
2. A minimal code example. If you've found a bug, this helps us reproduce and repair it.
Sandcastle code
4. The Cesium version you're using, your operating system and browser.
1.54, but also in older versions. Chromium and Edge, Windows 10, Nvidia Quadro K2000
If your layers can all be images, you could use the SingleTileImageryProvider and treat them as imagery layers which will give you full control over the drawing order without artifacts:
Otherwise, for overlapping entities with height 0 what you’re seeing is z-fighting which is a common 3D engine artifact when two objects are in the exact same depth position. Moving one to a height of 0.1 seems to be enough to fix this.
As for the last artifact for the ones with height undefined (which means they’re clamped to the terrain), the good news is this was actually just recently fixed with this PR:
It didn’t make it into the CesiumJS 1.54 release but it will be there in 1.55 next month. In the mean time, you can use the master branch of Cesium on GitHub to get the fix.
We still encounter the artifact on entity edges, but it is slightly different now:
It happens only on large number of polygons (over ~100) (we we load them as shown in code sample previously) We create multiple adjacent polygons. The same polygons when we create fewer of them do not have issues.
It does not happen in 2D view
And here is the most interesting part: if we use GEODESIC arc type there are no issues
entity.polygon.arcType = Cesium.ArcType.GEODESIC;