hex-world
    Preparing search index...

    Function groundPointFromNdc

    • 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.

      Parameters

      Returns Vector3 | null

      const ndcX = (event.offsetX / rect.width)  * 2 - 1;
      const ndcY = (event.offsetY / rect.height) * -2 + 1;
      const hit = groundPointFromNdc(camera, ndcX, ndcY);