How can I convert mouse screen coordinates to ThreeJS world coordinates on the XZ plane?
I came across a code snippet that successfully converts mouse position to XY world coordinates, but I'm not sure how to modify it for XZ coordinates:
var vector = new THREE.Vector3();
vector.set((event.clientX / window.innerWidth) * 2 - 1, - (event.clientY / window.innerHeight) * 2 + 1, 0.5);
vector.unproject(camera);
var dir = vector.sub(camera.position).normalize();
var distance = - camera.position.z / dir.z;
var position = camera.position.clone().add(dir.multiplyScalar(distance));
console.log("x: " + position.x + " y: " + position.y);