Recursive Shadow Casting based on Björn Bergström's algorithm.
You can find an idea of how it works here: http://www.roguebasin.com/index.php?title=FOV_using_recursive_shadowcasting
const grid = [ [1, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0] ]; const fov = new RecursiveShadowCasting(grid, (c) => c === 0, { radius: 2 }); const result = fov.compute({ x: 0, y: 0 }); console.log(result); { status: 'Success', positions: [ { x: 0, y: 0 }, { x: 1, y: 1 }, { x: 1, y: 0 }, { x: 0, y: 1 } ] }
Any type of data.
The grid for which to compute the FOV.
A callback function used to determine if a cell doesn't let the "light" passes through.
The options related to the computation.
Computes the FOV on the given position, using the Recursive Shadow Casting strategy.
The Position on which to start the computation.
The FOV computation result.
Generated using TypeDoc
Recursive Shadow Casting based on Björn Bergström's algorithm.
You can find an idea of how it works here: http://www.roguebasin.com/index.php?title=FOV_using_recursive_shadowcasting