THREE.Raycaster turns a 2D screen coordinate into a line through 3D space. raycaster.setFromCamera(pointerNDC, camera) sets up a ray from the camera in that direction, and raycaster.intersectObjects(objects) returns whichever objects the ray hit, sorted nearest-to-camera first.
Pointer coordinates must be normalized device coordinates (NDC, -1 to 1), not pixels — x is (clientX/width)*2-1, y is -(clientY/height)*2+1. The flipped y sign is easy to forget.
Since the card preview has pointer-events disabled and can’t receive real mouse input, this demo follows the house rule: a virtual pointer sweeps the grid along a Lissajous curve until a real pointermove event arrives, at which point control hands over. Whatever box the ray hits changes color and grows slightly.
When to use
Whenever objects in a 3D scene need to be clicked or hovered — editors, product configurators, in-game UI.