I am trying to place an object in front of my camera, facing the camera.
The object should be placed 1.1m in front of, and 0.4m under the camera’s position.
The object should not get tilted by the cameras rotation, and always have it’s up-vector in the Vector3.up direction.
This is what I have currently:
I placed the obj at camera.position. Then I rotated it at y-axis to face the same direction as the camera. After that I translated the object in this direction.
obj.position.set(camera.position.x, camera.position.y, camera.position.z); obj.rotation.set(0, camera.rotation.y, 0); obj.translateZ(-1.1); obj.translateY(-0.4);
This works, but only if the y-rotation of the camera is between 90 and -90 degrees.
If the camera’s rotation is something like 110 degrees, the object gets placed at 70 degrees instead of 110.
So the mistake is probaly in this line:
obj.rotation.set(0, camera.rotation.y, 0);
How can I get the ‘real’ y-axis rotation of the camera (0-360) degrees?