On the imported GLB model, all the meshes inside of it has the same .matrixWorld values.
I want to get world position of some of them, how should I do it then?
Hi Oliver.
I’ve tried it, still no result
@Mugen87 Hi I guess that you’re aware of this. Could you please help me with this?
Try it with:
const worldPosition = new THREE.Vector3();
obj.getWorldPosition( worldPosition );
console.log( worldPosition );
If that does not work, please share an editable live example that demonstrates the issue.
Thanks for your response.
here’s the example
and here’s the .glb file that I’m testing
P.S. You have to upload .glb manually
The objects in your scene have initial position, rotation and scale values since the geometries are shifted from the origin. You see the exact same result when importing the glTF asset into Blender.
So how I can get the position of a specific mesh (lets say position of the wall ) from the center of scene ( global 0,0,0 )?
You can compute the AABB around your object and then use its center point. Something like:
const aabb = new THREE.Box3().setFromObject( object );
const center = aabb.getCenter( new THREE.Vector3() );