Get object position in a three.js scene dynamically

hi

how can i get object position after its initialize?
lets say i have a mash- box that attach to the camera when the camera move the box move with it but
when the camera move forward the x,y,z coordinate of the box stay the same as 0,0,0

thanks for the help

Since the box is a child of the camera, you have to access the world position of the box, not its local position. Object3D.position always returns the local position. There are several ways to obtain the world position. I would recommend you start with Object3D.getWorldPosition(). Code would look like so:

const worldPosition = new THREE.Vector3();
box.getWorldPosition( worldPosition );

Try to reuse the Vector3 object worldPosition for each invocation of Object3D.getWorldPosition().