UNPKG

malwoden

Version:

![alt text](./coverage/badge-lines.svg) ![alt text](./coverage/badge-statements.svg) ![alt text](./coverage/badge-functions.svg) ![alt text](./coverage/badge-branches.svg)

56 lines (55 loc) 2.12 kB
import { Vector2 } from "../struct/vector"; interface LightPassesCallback { (pos: Vector2): boolean; } interface VisibilityCallback { (pos: Vector2, range: number, visibility: number): void; } interface VisibilityStruct { pos: Vector2; r: number; visibility: number; } interface PreciseShadowcastingConfig { lightPasses: LightPassesCallback; topology: "four" | "eight"; returnAll?: boolean; cartesianRange?: boolean; } /** FOV Algorithm that calculates angles of shadows and merges them together. */ export declare class PreciseShadowcasting { private lightPasses; private getRing; private returnAll; private cartesianRange; /** * Creates a new PreciseShadowcasting object * which can calulate viewsheds. * * @param config * @param config.lightPasses Vector2 => Boolean - Whether a position is visible * @param config.topology "four" | "eight" | "free" - The topology to use * @param config.returnAll Return all spaces in range, even if not visible. Default false. * @param config.cartesianRange If set, will calculate range as a^2 + b^2 = c^2. Results in round shape. Default false. */ constructor(config: PreciseShadowcastingConfig); /** * Calculates an array of visible Vectors. Same as calculateCallback, * but returns an Array instead. * * @param origin Vector2 - The position to start from. * @param range Number - The range of vision */ calculateArray(origin: Vector2, range: number): VisibilityStruct[]; /** * Calculates visible positions, and invokes the given callback for each one. * * @param origin Vector2 - The position to start from * @param range Number - The range of vision * @param callback (pos: Vector2, range: number, visibility: number) => void - The function to call for each visible tile */ calculateCallback(origin: Vector2, range: number, callback: VisibilityCallback): void; private checkVisibility; private checkShadowVisibility; } export {};