Hello everyone,
I’m currently facing two issues in Cesium and would really appreciate your help.
1. Z-index ordering in 2D view
I have the following entities:
-
A moving
.glb
model entity -
A constant-color polyline
-
A custom shader-based polyline (with arrow head)
-
A canvas-based billboard entity
What I want in 2D view is this specific rendering order (z-index style):
-
Model on top
-
Billboard beneath it
-
Polylines at the bottom
To achieve this, I’ve been using separate CustomDataSources, each holding only one type of entity (one for the model, one for the billboard, and one for the polylines).
This approach sometimes works, but only under certain conditions:
-
If I assign all positions using a
CallbackProperty
and replace the shader polyline with a constant-color polyline, the order is correct. -
Alternatively, if I keep the shader polyline, it only works if I temporarily switch to 3D view, add all entities via
viewer.entities.add
, and then return to 2D.
The problem with the second method is that when I switch back from 3D, the trackedEntity
is lost, which is a big issue for my use case.
So, my first question is: Is there a reliable way to enforce this rendering order in 2D view without switching back and forth to 3D?
2. Forcing a model to always render on top
My second issue is related to the .glb
model in 3D view.
Billboards have the disableDepthTestDistance
property, which makes them always appear on top. I want the same behavior for my model entity.
What I need is:
-
The model should always render above all other entities (similar to
disableDepthTestDistance
for billboards). -
At the same time, the model must still render correctly within itself (i.e., its own parts should respect depth order, so that its geometry doesn’t break).
I tried overriding the model’s update function, but that caused some parts of the model to render incorrectly over others, which is not acceptable.
So my second question is: Is there a supported way (or workaround) to achieve billboard-like “always on top” rendering for models in Cesium?
I’m currently on Cesium 1.126 (because I initially started this project with that version and I haven’t seen any new z-index-related features since then).
Any guidance, ideas, or workarounds would be greatly appreciated.
Thanks in advance!