Performance question GUI : isVisible or dispose container

I have a container with a lot of Control in it that displays information on player profiles. This containers will regularly show and hide (Depending on the number of players facing the camera).

Question 1
So I wonder if for performance reasons it was better to :

  1. contener.dispose () then recreate if necessary
  2. contener.isVisible = false to hide it and contener.isVisible = true to display it.

I wonder if there is a lot of player info on the screen (not visible, but present on the scene) How much does it cost ?
with dispose (), does it cost more to recreate each time?

What is your opinion?

Question 2
And do you have any idea how to display a GUI container when it sees an object and hide it when the camera does not see an object ?


Hey @Dad72,

I will try to answer since I have some experience with the BJS GUI.

Question 1
I have taken a different approach which was quite performant for me. I dettached the control and reattached when needed while also changing visibility. I didn’t want to deal with the references afterwards.

I have used the “camera.isInFrustum(mesh)”. When true I have dettached the GUI container, otherwise I have attached it. Hope this helps you as well.


Thank you. That answers my questions perfectly. I’m going to do like this.

1 Like

Solution here :

Move the camera to no longer see the sphere and the GUI is detached. Then reappears as soon as the camera sees the sphere :


Thanks again to @Null for the explanations

Glad it helped ! :slight_smile: