Can i create contaioners?

Hi Guys,

I am new to Babylonjs
I was looking if we can create containers in Babylonjs?
(I have gone through Assets Container and GUI - Container)

What i want to do is -
Within a scene, create some containers.
containers will contain similar objects e.g.
container #1: for Buttons
container #2: for packedSprirte animations
container #3: for some 3D Mesh

Now on run time i want to -
change the x & y coordinates of these containers
change visibility
change scale … etc…

Thanks in advance

Welcome to the Babylon community!

For buttons a GUI container is definitely the way to go.

Looking more into asset containers I don’t think that is how to go about doing this. (please correct me if I’m wrong). You could iterate through all the meshes in a container and just set your properties. Another suggestion is make a mesh and have other meshes parented to that one.

Thanks, but i don’t think if i can change x and y coordinates of container. Can I?

AH! I misspoke. I meant a stack panel. Checkout this example here :slight_smile:

https://playground.babylonjs.com/#XCPP9Y#11
You can simply move then entire stack panel. For example: panel.topInPixels = 50;

1 Like

You can make a new BABYLON.TransformNode() as the container, then you set mesh.parent to that node for all the children.

1 Like

Stack panel does solve the problem to an extent but it’s limited to GUI only.
Can’t add a 3D object to it.

What is someone wants to add a GUI and a 3D obj/mesh in same container?

You can link a GUI to track a mesh. This may go some way to do what you need The Babylon GUI | Babylon.js Documentation

1 Like

@JohnK , track a mesh is a workaround to this problem but there is no option to have everything within one roof? i.e. like global container which can contain GUI and Mesh etc. (basically add any item to the container/node which Babylon supports)?

nope gui are their own tree and often done in screen space. Maybe you would prefer to use 3d GUI in your case: Babylon 3D GUI | Babylon.js Documentation

Thanks @sebavan
Do you think it’s possible to include such functionality (global container) in upcoming versions?
This could be helpful for many projects.