Currently, I am in the process of working on a modified version of the threeJS editor. One specific feature I am focusing on requires me to determine the exact world point that the center of the camera is directed towards.
I speculate that if I can ascertain the equation of the line originating from the camera's center and extending in its forward direction, I should be able to pinpoint the intersection point at y=0, ultimately giving me the point on the plane.
Although I initially attempted the code below, it seems to converge towards the axis of the plane at (0,0,0):
let forward = new THREE.Vector3();
camera.getWorldDirection(forward)
let firstPoint = camera.position.clone();
let secondPoint = new THREE.Vector3();
secondPoint.addVectors(firstPoint, forward);
I have since refactored the code to:
let camera = scene.getObjectByProperty("uuid", scene.userData.activeCamera);
let plane = new THREE.Plane( new THREE.Vector3( 0, 1, 0 ), 0 );
let ray = new THREE.Ray();
let cameraPos = new THREE.Vector3();
let cameraDir = new THREE.Vector3();
camera.getWorldPosition(cameraPos);
camera.getWorldDirection(cameraDir);
ray.set(cameraPos, cameraDir);
let target = new THREE.Vector3();
ray.intersectPlane(plane, target);
this.controls.target = target;
However, even with this revised code, the resulting target still seems to approach zero as illustrated below:
x: 1.7763568394002505e-15
y: 0
z: 8.881784197001252e-15
The image provided below depicts the exact direction in which the camera is focused within the editor: https://i.sstatic.net/KY3Ay.png