Returns a function that performs raycasting.
The raycast function takes in the position of a ray source, and returns the x,y coordinates of where rays land on a provided list of lines.
const raycaster = raycast2d(lines);const light = { x: 10, y: 20 }raycaster(light); // Yields: { x, y, index } Copy
const raycaster = raycast2d(lines);const light = { x: 10, y: 20 }raycaster(light); // Yields: { x, y, index }
An index property is given for each coordinate, which corresponds to the lines array. This allows correspondence between hits and lines.
index
lines
Returns a function that performs raycasting.
The raycast function takes in the position of a ray source, and returns the x,y coordinates of where rays land on a provided list of lines.
An
indexproperty is given for each coordinate, which corresponds to thelinesarray. This allows correspondence between hits and lines.