ImportMeshAsync loaded position

For my project, I need to now exactly where is every mesh after loaded async from the obj file. Is it possible, since meshes in results from promise result always gives position as 0,0,0 as well as getAbsolutePosition.

You can get their boundingInfo to get where they are physically (mesh.getBoundingInfo())

Oh, man. That worked fine. Thanks a lot.

Since Y axis differs from CAD models (ie. Y axis is Z axis), I need to change loading Axis, ie, model to load has Z axis as Y, or get meshes loaded coordinates to change positition after loaded.
Thanks i n advance.

is it not simply a rotation around x of either 90 or -90 degrees in this case ?

No, also, getBoundingInfo(), do not let me get the coordinates in order to move the components either. At least need the exact coordinates for displacement, anyway.

Please provide a repro in the playground as I do not understand how rotating model would not result in something similar ?

I am not sure what you mean by getBoundingInfo do not let get the coordinates ?

Please, does not mind, I was wrong. Rotation around BABYLON X axis really works.

Still, need real position during and after loading obj models, since getBoundnigInfo() method gives me geometry but not position.

Is mesh.getBoundingInfo().boundingBox and get centerWorld-position what you are looking for?

Or use Max-Min position to get center world position:

Or if mesh.getAbsolutePosition() does not work:

mesh.computeWorldMatrix(true)
var worldPosition = BABYLON.Vector3.TransformCoordinates(mesh.position, mesh.getWorldMatrix())

Ok, that would give real coordinates, but wthat about to change it?

Examples to change in local space:

mesh.position = new BABYLON.Vector3(x, y, z)
mesh.position.x += 1

Example to change in world space:

var worldPosition = new BABYLON.Vector3(x, y, z) // wanted world pos
mesh.position = BABYLON.Vector3.TransformCoordinates(worldPosition, BABYLON.Matrix.Invert(mesh.getWorldMatrix()))

Nop, your answer does not gives me the location of meshes during loading, so, don’t know if BABYLON would ever let me change the position of meshes during loading.
Given the fact that the operation, I’m trying to achieve, is to change location of meshes during CAD produced OBJ loading, or after that, I really need where is every single mesh, or it’s useless the OBJ file.

@Takemura answer is correct and should definitely work.

@Leonardo_Villalobos, please share a repro in the playground as it is impossible to understand why it would not work in your case without more info.

How to make a repro in playground with an obj file in my pc, not possible, How would I load it?
The issue is the same, need to assure to know exact position of loaded mesh in whatever (local or global) corrdinates, since normal loading inverts Z, when rotating obj around X axis.
Gonna try with fbx format to gtlf from facebook and convert it, anyway think would be the same result.

Just try out any non axis symetric obj file obtained from any CAD and you’ll see that does not work and try to get the position of any mesh during loading and, again, will not work.
image

You can use external assets in the playground: Using External Assets In the Playground | Babylon.js Documentation and if any none symetrical obj it should not take long for you to recreate it.

You can then load obj in the playground like this https://playground.babylonjs.com/#SYQW69#1185

The issue is no the code i’m using, it’s the axis definition that does not match vector product operation as in a CAD program, thats the main reason to know where the meshes are, but, if location of non axis symetrics model where loaded as in a CAD app, then no need of coordinates.
When a model is exported to an obj from a CAD app, since it’s heavy loaded, it’s make no sence to change orientation neither in the CAD app nor Babylom, due time consumed by both. So, if can’t find a way to change axes Y and Z to its correpondant Y an Z of CAD app, then no sence to try other way to get around the issue and any Babylon CAD loading app makes no sence.

Since CAD standard apps uses X axis as “East”, Y axis as “North”, and “Z” axis as “Elevation”, (X and Y in horizontal plane), it makes no sence to go on with a Web CAD app with gLTF standard industry going in different direction.