Get position of object in scene

Those are good questions. It’s basics, so it’s a bit difficult to explain, since the concepts are quite broad. In three.js you have Object3D graph, what that means is that Object3D can have other Object3D inside of it, like a DOM tree in HTML, where a <div> can have another <div> inside of it. So, there’s a thing called Mesh, it’s a sub-class of Object3D. Your "blender object"s are Meshes grouped together in some kind of hierarchy. A Mesh is just a normal Object3D, but it also has 2 new things:

  • material
  • geometry

so let’s say you have following hierarchy:

scene{
   mesh{
       geometry,
       material
   }
}

to find the center of that mesh object, we will need to find it’s global position - that you already know how to do. But this will give you only it’s position, not the center of the object. Position is basically like point 0 on an axis plot, it can be anywhere relative to the object’s center, it can be even very very far away from any point on the object itself.

1 Like