Adjust rendering order to draw label always above polyline even if depth test is disabled

Is there a way to draw a label always above polyline, even depth test is disabled to prevent text or polyline is hidden by 3d tiles? Normally it should work if I draw as first polyline and then polyline, but it does not work with Cesium if material is a bit translucent.

My code:

var viewer = new Cesium.Viewer(‘cesiumContainer’);

var material = new Cesium.Material({

fabric : {

type : ‘Color’,

uniforms : {

color : new Cesium.Color(1.0, 0.0, 0.0, 0.75) //works with Cesium.Color.RED

}

}

});

//1: draw line

viewer.scene.primitives.add(new Cesium.Primitive({

geometryInstances : new Cesium.GeometryInstance({

geometry : new Cesium.PolylineGeometry({

positions : Cesium.Cartesian3.fromDegreesArrayHeights([

0.0, 0.0, 0,

90.0, 0.0, 0

]),

followSurface: true,

width : 2.0,

vertexFormat : Cesium.PolylineMaterialAppearance.VERTEX_FORMAT

})

}),

appearance : new Cesium.PolylineMaterialAppearance({

material : material,

renderState : {

depthTest : {

enabled : false

},

cull : {

enabled : true,

face : Cesium.CullFace.BACK

}

}

})

}));

//2: draw label

var labelCollection = new Cesium.LabelCollection();

labelCollection.add({

position: Cesium.Cartesian3.fromDegrees(45.0, 0.0, 0.0),

text: ‘Test’,

font: ‘20px sans-serif’,

style: Cesium.LabelStyle.FILL_AND_OUTLINE,

outlineWidth: 4.0,

horizontalOrigin: Cesium.HorizontalOrigin.CENTER,

verticalOrigin: Cesium.VerticalOrigin.CENTER,

disableDepthTestDistance: Number.POSITIVE_INFINITY

});

viewer.scene.primitives.add(labelCollection);

``

Hi there,

This were some issues with depthTestDistance introduced in 1.36, but are not fixed and will be released in 1.37 on September 1st (see the changelog).

If you need a workaround, maybe checkout Label.eyeOffset, which will update the position of the label so it’s always moved closer relative to the viewer.

Thanks,

Gabby