03 - Two sources at once

Drag purple rectangles or the ring. The cross marks the destination and follows the pointer.

new ShapeSet()
A second kind of source, holding loose rectangles in world coordinates rather than tiles in a grid. None of these is 32 wide and none starts on a cell boundary.

new Raycaster([grid, shapes])
The caster owns no geometry. It takes any number of sources, asks each of them in turn and keeps the nearest answer, shortening the ray as it goes.

The hit says which source answered. collider and userData come from a shape set, tileId and cellX and cellY from a grid.