When using a raycaster, I can successfully obtain the current object (in this case, a plane) under the mouse. However, I am seeking a more precise X and Y value for the mouse position INSIDE the plane.
var vector = new THREE.Vector3( ( event.clientX / window.innerWidth ) * 2 - 1, - ( event.clientY / window.innerHeight ) * 2 + 1,
0.5 );
projector.unprojectVector( vector, camera );
var raycaster = new THREE.Raycaster( camera.position, vector.sub( camera.position ).normalize() );
var intersects = raycaster.intersectObject(plane, true);
if (intersects.length > 0) {
console.log(intersects[0].point);
}
For example, with a 200x200 plane facing the camera directly, intersects[0].point.x
ranges from -100 to +100 as expected. However, when I rotate the plane, the results become inconsistent.
Is there a way to consistently get an x value ranging from -100 to +100, regardless of the plane's position in the scene?