The wording of this question might be unclear, but I'm struggling to phrase it concisely.
Here's the scenario: there is a perspective camera in the scene along with a mesh. The mesh is positioned away from the origin of the axis.
The camera is pointed directly at the center of this object, and its position (the "position" property of the Three.js camera object) is based on the object's center, not the origin; therefore, it operates within a different coordinate system.
My query is: how can I determine the camera's position relative to the origin of the "global" coordinate system rather than the object's center?
To illustrate, consider this image. It shows a hand mesh positioned far from the origin of the coordinate system. When I check the camera's position, I get these values: x: -53.46980763626004; y: -2.7201492246619283; z: -9.814480359970839 yet what I require are positions relative to the origin (which would yield different values).
UPDATE: I followed @leota's advice and used the localToWorld method like this:
var camera = scene.getCamera();
var viewPos = camera.position;
var newView = new THREE.Vector3();
newView.copy(viewPos);
camera.localToWorld(newView);
I tested this with this mesh. The mesh isn't centered on the origin either. The regular camera position results are: x: 0; y: 0; z: 15
After applying the code above, the positions change to: x: 0; y: 0; z: 30
This output is inaccurate, as the camera's x and y coordinates should not be zero based on the image shown.
If I adjust the camera so it's closer to the origin, such as in this image, where it's behind the origin with negative coordinates for x, y, z, the positional data when considering the object's center become:
x: -4.674180744175711; y: -4.8370441591630255; z: -4.877951155147168
Yet after using the code, they shift to: x: 3.6176076166961373; y: -4.98753160894295; z: -4.365141278155379
The positive x value indicates an error despite possibly accurate y and z values.
I'll keep exploring solutions, but this could be a step forward. Any more suggestions are welcome!
UPDATE 2:
A solution has been found. While @leota provided the correct approach to obtaining absolute camera coordinates, I discovered a hidden line of code in the project that scaled everything according to a specific rule. Thus, I had to adjust the camera position based on that rule.
Since @leota's answer solved the original issue, it's being accepted as the correct response.