Projects a normalized-device-coordinate point (−1…1 on both axes, +Y up) through the camera onto a horizontal plane.
Returns null when the ray is parallel to the plane or points away from it — i.e. the pixel shows sky, not ground.
null
const ndcX = (event.offsetX / rect.width) * 2 - 1;const ndcY = (event.offsetY / rect.height) * -2 + 1;const hit = groundPointFromNdc(camera, ndcX, ndcY); Copy
const ndcX = (event.offsetX / rect.width) * 2 - 1;const ndcY = (event.offsetY / rect.height) * -2 + 1;const hit = groundPointFromNdc(camera, ndcX, ndcY);
Projects a normalized-device-coordinate point (−1…1 on both axes, +Y up) through the camera onto a horizontal plane.
Returns
nullwhen the ray is parallel to the plane or points away from it — i.e. the pixel shows sky, not ground.