Hi everyone,
I’m currently working on a measurement tool in CesiumJS. I have:
-
A Polyline entity
-
A PointCollection for vertices
-
Some Label entities
All of them are using depthFailMaterial so that they remain visible when behind terrain or 3D tiles.
The Issue
When the polyline has a depthFailMaterial, it always renders on top of:
-
Other entities’
depthFailMaterial -
PointCollection -
Labels
Even when those entities also define their own depthFailMaterial.
It looks like the polyline’s depth fail pass overrides everything else visually.
Simplified Code Example
Polyline
const polylineEntity = viewer.entities.add({
polyline: {
positions: positions,
width: 4,
material: Cesium.Color.YELLOW,
depthFailMaterial: Cesium.Color.YELLOW,
}
});
PointCollection
const pointCollection = viewer.scene.primitives.add(
new Cesium.PointPrimitiveCollection()
);
pointCollection.add({
id: "PointId",
position: somePosition,
color: Cesium.Color.CYAN,
pixelSize: 15,
scaleByDistance: new Cesium.NearFarScalar(1.5, 2.0, 1.5e7, 1.5),
disableDepthTestDistance: Number.POSITIVE_INFINITY,
});
Label
viewer.entities.add({
position: somePosition,
label: {
font: "14px monospace",
showBackground: true,
horizontalOrigin: Cesium.HorizontalOrigin.LEFT,
verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
pixelOffset: new Cesium.Cartesian2(0, -10),
eyeOffset: new Cesium.Cartesian3(0, 0, -1),
disableDepthTestDistance: Number.POSITIVE_INFINITY,
fillColor: Cesium.Color.WHITE,
text: "Test"
}
});
Observed Behavior
Whenever the polyline is behind terrain or objects:
-
Its
depthFailMaterialis rendered -
That depthFail pass appears on top of everything else
-
Even if the point or label should visually appear above it
It seems like the polyline’s depth fail pass ignores normal depth ordering relative to other depth-fail-rendered primitives.
Questions
-
Is this expected behavior in CesiumJS?
-
Is there a way to control render order between depthFail materials?
-
Would using separate
Primitiveinstead ofEntityhelp? -
Is this related to render pass ordering internally?
Any suggestions or recommended approach would be greatly appreciated.
Thanks!
