SelectionOutlineLayer doubles the number of draw calls despite having no selection

Simply having a SelectionOutlineLayer registered in the scene doubles the number of draw calls, even when nothing is selected.

To work around this, I currently dispose of the SelectionOutlineLayer whenever there are no selections left, and create a new one whenever a selection is needed.

minimum repro: Babylon.js Playground

In this scene, the number of draw calls is around 60, but if you comment out the selectionOutlineLayer, it drops to 30.

Is this a bug?

Thank you for this great framework!

1 Like

Looking at Babylon’s code, it appears that this._shouldRender does not become true until addSelection is called, so it seems that the code is designed to prevent unnecessary rendering.

So it’s strange that the number of draw calls actually changes in the Inspector.

Great catch!

Here’s the fix:

1 Like

Thank you for the quick fix!