How to set the 3D viewer center for the meshes after loaded obj file using BABYLON.SceneLoader

Hi,

I have an obj file. When I load in Babylon Sandbox, the meshes objects in the scene is shown in the centre of the viewer.
When I load the obj file through BABYLON.SceneLoader in my code, I cannot able to see the mesh objects in the scene in the centre. I need to zoom and pan to find the mesh objects.
How to set it to the centre of the viewer?

Thanks

We do not center the object in the sandbox, but we are creating the camera at the right spot.

if you use scene.createDefaultCamera after loading your model it should do just that :slight_smile:

We are using
scene.createDefaultCameraOrLight(true);
after loading the model.
Is it the same method or a different one?

Thanks

Yup that is the same it is interesting it does not correctly place it :slight_smile: Could you repro in the playground ?

Hi,

I have replicate the our code in playground.

But in our Babylon 3D viewer, the obj model is not shown in center.

Thanks.

This will unfortunately not help us to find your issue :slight_smile:

Hi,

How to add our obj file to a playground?

So that I can try to replicate this issue.

Thanks

This doc explains how to do it: Using External Assets In the Playground | Babylon.js Documentation