ixfx
    Preparing search index...

    Function raycast2d

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

      An index property is given for each coordinate, which corresponds to the lines array. This allows correspondence between hits and lines.

      Parameters

      Returns (light: Point) => RaycastHit[]