Hello everyone,
My model is loading 1000 meters (I think 1 unit in my scene is 1 meter) away from the (0,0,0) point and it’s rotated 90 degres. So I hardcoded it and when I’m loading model I am doing those fixes:
Promise.all(
tilesArray.map((asset) =>
BABYLON.SceneLoader.ImportMeshAsync(
"",
`${MESH_BASE_URL}/${asset}/`,
"model.glb",
scene,
handleMeshLoading
).then((mesh) => {
// FIRST FIX
// First rotate tower 90 degrees, model originally is set horizontally
mesh.meshes[0].rotate(
BABYLON.Axis.X,
Math.PI / 2,
BABYLON.Space.LOCAL
);
// SECOND FIX
// Then move it to (0,0,0) position (kind of hardcode here - different models can be in different positions at start)
mesh.meshes[0].translate(BABYLON.Axis.Y, -1007, BABYLON.Space.WORLD);
return mesh;
})
)
)
.then(this.handleComplete)
Is there any way to move the camera to the model so I shouldn’t move it with given offset (-1007)? I’ll have to handle multiple model’s which can have differet offsets.
When I do something like this:
camera.position = mesh.meshes[0].position
it doesn’t make anything because mesh.meshes[0].position shows the LOCAL position of this mesh and it’s (0,0,0) but in global axis it’s (0, -1007, 0) .
It’s good bcuz a2.getBoundingInfo().boundingBox.centerWorld takes global position of mesh
Cameras now jumps from mesh to mesh (till every mesh is loaded) so I guess what I’m going to do is just take first mesh position and then stop taking new positions. And move it back a lil bit from it.