We are in the process of writing a collection of drawing tools on top of Cesium.
In that context, we define a set of visual aids/widgets to help the user interact with the drawings.
Notably, we use PointGraphics to represent vertices that can be interacted with.
Ideally, these control vertices should be drawn on top of the final rendered frame (they should ignore the depth-buffer and be rendered last).
We can ensure that the vertices ignore the depth buffer (via the disableDepthTestDistance property). However, some of our drawing shapes define a depthTestFailMaterial, which we use to make them visible when they intersect with their environment (3D tilesets). In this case, when the drawing renders its “depth test failed” part, it seems to be drawn last, after the vertices, i.e. on top of the vertices.
Is there a way to control the rendering order in that situation?
I guess we could render the vertex control dots on top of Cesium’s canvas, either with dom elements or another canvas, but I wanted to make sure I was not missing something before going that route.
The following sandcastle illustrates the situation.
Hi @david-hodgetts, have you considered using a BillboardCollection instead of PointGraphics
? This would give you the option of setting eyeOffset
. Note that there are some issues with this approach. But it might be more efficient than layering another canvas.
Hi @jjhembd,
Thanks for getting back to me.
I did try the BillboardCollection
approach (with an eyeOffset
). Unless I am doing something wrong, this leads to the same visual result. See following sandcastle for reference.
I did start to look at writing a fully custom primitive, thereby hoping to be able to use a custom DrawCommand
to specify the primitive as being drawn in the OVERLAY
pass. But I have not been able to give this idea sufficient time to obtain a successful result. I am also a bit weary about this approach since it involves using Cesium’s internal apis.
Best regards,
Hi @david-hodgetts, that new Sandcastle does clarify things.
I think by setting a depthFailAppearance
on the polygon, we are basically requesting to “render this polygon on top no matter what.” Once we make that request, we don’t really have a way to add an exception, i.e., “but not if there is a Point on top of it.”
This level of control is what a z-index is for. Perhaps you could add your use case to the issue about z-ordering of entities.
Hi @jjhembd, I came to same conclusion as you.
I will do as you suggest, and add this case to the github issue you mention.
Thanks for your time,
Best regards,
David
1 Like