mesh.alphaIndex not working anymore when using scene.setRenderingOrder

Hi everyone,

Please see this playground:

To reproduce: Click the wall, wait for red confirm flash, then click the wall again.

The display order of the decals is reversed. It only happens when I use scene.setRenderingOrder (L17).

Also note: there needs to be added and disposed another mesh in between clicks (L76).

I think the main problem is that I do not really know what the sort function does. I copy and pasted it in order to make occlusion queries work. As I understand it, when the sort function returns 0, it should not reorder. And since, in the playground, it always returns 0, it always should not mess with render order. But it does?

Best wishes

Your sort function is not a sort, it always return 0. You should implement a real sort function, that compares the two elements passed to the function and returns -1, 0 or 1 depending on the ordering of the two elements. This function is passed to the javascript sort function, more explanation here:

You generally don’t need to overwrite the default sorting functions, so I’m not sure why you have to do it in the first place?

No, there’s always a sort performed by the rendering manager, and the sort function should return -1, 0 or 1, as explained above.

1 Like

Thanks for the clarification @Evgeni_Popov

I removed the sort function and it does not seem to break anything else anymore.