Hi! I'm looking for an equivalent to disableDepthTestDistance in https://cesiumjs.org/Cesium/Build/Documentation/PointGraphics.html for polylines and polygons. Even if the solution is less than elegant for the time being, I'll take it. Here are the current restrictions I'm working under:
-All polylines and polygons must display on top of the globe and other entities.
-Feature picking needs to still operate on these polylines and polygons.
3. Context. Why do you need to do this? We might know a better way to accomplish your goal.
Polylines and polygons are being used to draw geometry on a mesh entity. Unfortunately, that means they render partially clipped through the mesh in many places. Hovering the lines above the surface of the mesh slightly alleviates the issue in lucky scenarios (the right zoom level for the hover offset), but isn't really a sufficient solution. The desirable behavior is to always draw the illustrations to the screen on top of all other content.
Is there a way I can modify the underlying primitives to draw them on top? An official solution through the API would be great, but I realize this may be an unconventional need and I don't expect it to be a high priority for you.
// Modify polylines so that their depth test is always disabled.
var oldPolylineUpdate = Cesium.PolylineCollection.prototype.update;
Cesium.PolylineCollection.prototype.update = function(frameState) {
var oldMorphTime = frameState.morphTime;
frameState.morphTime = 0.0;
oldPolylineUpdate.call(this, frameState);
frameState.morphTime = oldMorphTime;
};
// Modify polygons (and all other primitive objects) so that their depth test is always disabled.
var oldPrimitiveUpdate = Cesium.Primitive.prototype.update;
Cesium.Primitive.prototype.update = function (frameState) {
this.appearance._renderState.depthTest.enabled = false;
oldPrimitiveUpdate.call(this, frameState);
};
Not very pretty, but effective at least. I'm not particularly happy with the PolylineCollection trick, but I couldn't find a better way to access and modify the render states in PolylineCollection.js before createCommandLists is called. As far as I'm aware, the update call does not otherwise need access to morphTime and I haven't seen any ill effects.