How to set position (nothing works for me)

Hi none of these .position .absolutePosition .setPosition .setAbsolutePosition properties/functions for work me to set the position of a skybox or a container?

BABYLON.SceneLoader.LoadAssetContainer(path, file, scene, function (container) {
                var meshes = container.meshes;
                var materials = container.materials;                                                   

                container.addAllToScene();   
                
                console.log(container)
                container.setAbsolutePosition(BABYLON.Vector3(5, 0, 5));                                                                
            });

I logged the container into the console and it has _position properties and such but how do I move it…

Want to reproduce this on the playground? we will be able to help better with a live example.

The container itself doesn’t have a position, it just adds the loaded meshes to the scene. setting the position of the root mesh of your loaded model will move the entire loaded gltf to a new position:

https://www.babylonjs-playground.com/#PFI1T8#1

Oh okay like that, didn’t see it done like that anywhere…
I was trying to load two models and two skyboxes, but If I give it a far away position I can’t see them anymore? Or is it just the far plane or something…

https://www.babylonjs-playground.com/#PFI1T8#4

Oh alright I can still see the blue guy but trying to move the skybox doesn’t work like this?

Two skyboxes in one scene won’t render as you expect (or at least as I assume you expect).

Anything you define outside of the skybox will not be visible (as the skybox will hide it). Make the skybox larger, and remove the second one - https://playground.babylonjs.com/#PFI1T8#5 , this way you see both

1 Like

Oh alright the thing is I was trying to get two models with two viewports/camera.
I already got this working now but I thought if I would put both of them in a box you wouldn’t be able to see the model from camera1 with camera2 and vice versa.

Oh, of course, if you actually need two different locations with two different skyboxes it will work! :slight_smile: You have the freedom to define whatever you need. Another way would be to save resources and have the models enabled/disabled when you switch cameras.

If you really want to optimize your scene, clone the loaded model instead of loading it twice.