How to obtain the actual position of model nodes

As shown in the figure, I want to obtain the actual position of this chair node, but it is displayed as 0,0,0 in our sandbox. Why does this happen and how can I solve it?


The position where the gizmos arrow appears is also incorrect

This is the information of its parent node

I really want to share the model, but the size is limited

Get the Absolute Position

var sphereAP = youNode.getAbsolutePosition();

To avoid problems, I would try to clean up the object hierarchy in your usual software (Blender, 3DsMax…)

If you delete all the groups, when importing in BJS it would create you Base Node root and it will surely be easier to access the objects and their properties

3 Likes

Thank you very much for your reply. Even though I used getAbsolutePosition(), the value I obtained was still not correct. I wonder if it’s because his parent is a transformnode that I’m confused about

getAbsolutePosition should return the correct result, as it takes the entire mesh’s hierarchy into account, including all transform nodes.

Since your model is offset far from its origin, you may want to get not the position but the center of the model.

// Get the center of the node, 
// all mesh and nodes under the node will be calculated.
let { max, min } = node.getHierarchyBoundingVectors()
let center = max.add(min).scale(0.5)

// Or 
// Get the center of the mesh, valid only for the current mesh.
let center =  mesh.getBoundingInfo().boundingBox.centerWorld

3 Likes

Thank you very much for your answer. Your response is exactly what I need. Perhaps it was because I haven’t figured out the position that caused this problem