Hi. I have some UI elements in my app, that I would like to avoid intersect with geometry. The UI compoent is made up of 3 Elements - two who are of type ELEMENTTYPE_IMAGE and one of type ELEMENTTYPE_TEXT.
I’ve set depthTest = false on the materials of the image elements, but how can I achieve the same result on the text element?
There could be better solutions. But one option would be to create a new Layer, that renders after the World layer, and make it clear depth buffer Layer | PlayCanvas API Reference
Put all my three Elements on this new Layer (together with being on UI and Texts)
Added a HotspotHandler script to do this on Initialize:
// Clear the depth buffer on hotspot layer
var layerComposition = this.app.scene.layers;
var hotspotLayer = layerComposition.getLayerByName(this.hotspotLayerName);
if (hotspotLayer !== null) {
hotspotLayer.clearDepthBuffer = true;
}
Ah, thanks for having a look. Your example does work. But it’s using the built in Layer Text. I wonder if that makes a difference. I modifed your example slightly to make it similar to my setup, using a nested image element with a text element. I came to the conclusion that i can make it work if I place my things on UIand Textlayers respectively and then turn off depthClear for both of them like so:
Another option might be to us 2D screen elements with corresponding entities in the 3d space. That way you could just check if the world entity was visible and screenToWorld the position of the hotspots over the appropriate spot on the geometry.