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);
``