How to get the coordinates (? ,?, Z),when the mouse click the screen, the click point may be a blank area without any object
Maybe this thread might help you:
export function transformCoordToThree(mouse, camera, renderer) {
const ray = new THREE.Ray();
const {domElement} = renderer;
const threePoint = {
x: (mouse.x / domElement.clientWidth) * 2 - 1,
y: -(mouse.y / domElement.clientHeight) * 2 + 1
};
ray.origin.setFromMatrixPosition(camera.matrixWorld);
ray.direction.set(threePoint.x, threePoint.y, 0.5).unproject(camera).sub(ray.origin).normalize();
const plane = new THREE.Plane(new THREE.Vector3(0, 0, 1))
return ray.intersectPlane(plane, new THREE.Vector3(0, 0, 0))
}
Thank you i get it