Sort UI elements by linkedMesh depth?

image

In a situation like this what would be the best way to sort the labels, I have a distance calculation that I am doing for each one to zoom them independently. I assume this would be where I should also try to sort them?

I think you can use your distance (or inverse distance) as the z-index value for those labels.

I tried that to no avail.

I did camera.maxZ - Math.floor(distance)

I guess a PG is the next step!

a bit of sorting should do the trick :wink:
https://playground.babylonjs.com/#3VMTI9#231

i’ll leave optimizing to you, maybe add label reference to separate array rather than advtexture children, stop/start sorting on demand, etc.

1 Like

boss solution!