Foundry Virtual Tabletop - API Documentation - Version 14
    Preparing search index...

    Class PointSourcePolygon<PolygonConfig>

    An extension of Polygon which is used to represent the line of sight for a point source.

    Type Parameters

    Hierarchy (View Summary)

    Index

    Properties

    bounds: Rectangle = ...

    The rectangular bounds of this polygon

    config: PolygonConfig = {}

    The configuration of this polygon.

    The origin point of the source polygon.

    surfaceExposure: any

    The area of surfaces that is visible to this polygon, if any.

    Accessors

    • get isConstrained(): boolean

      An indicator for whether this polygon is constrained by some boundary shape?

      Returns boolean

    Methods

    • Apply a constraining boundary shape to an existing PointSourcePolygon. Return a new instance of the polygon with the constraint applied. The new instance is only a "shallow clone", as it shares references to component properties with the original.

      Parameters

      • constraint: Rectangle | Polygon | Circle

        The constraining boundary shape

      • OptionalintersectionOptions: object = {}

        Options passed to the shape intersection method

      Returns PointSourcePolygon<PointSourcePolygonConfig>

      A new constrained polygon

    • Parameters

      • x: any
      • y: any

      Returns boolean

    • Customize the provided configuration object for this polygon type.

      Parameters

      • origin: Point | ElevatedPoint

        The provided polygon origin. The elevation defaults to the elevation of config.source if passed and otherwise 0.

      • config: PolygonConfig

        The provided configuration object

      Returns void

    • Determine if the shape is a complete circle. The config object must have an angle and a radius properties.

      Returns boolean

    • Visualize the polygon, displaying its computed area and applied boundary shapes.

      Returns Graphics | undefined

      The rendered debugging shape

    • Protected

      Perform the implementation-specific computation

      Returns void

    • Protected

      Constrain polygon points by applying boundary shapes.

      Returns void

    • Protected

      Determine the set of collisions which occurs for a Ray.

      Parameters

      • ray: Ray

        The Ray to test

      • mode: "any" | "closest" | "all"

        The collision mode being tested

      • destination: ElevatedPoint

        The destination

      • tMin: number

        Intersections of the ray and an edge with t-value at most tMin are not considered collisions. Default: 0.

      • tMax: number

        Intersections of the ray and an edge with t-value greater than tMax are not considered collisions. Default: 1.

      Returns any

      The collision test result

    • Benchmark the performance of polygon computation for this source

      Parameters

      • iterations: number

        The number of test iterations to perform

      • origin: Point | ElevatedPoint

        The origin point to benchmark

      • config: PolygonConfig

        The polygon configuration to benchmark

      Returns Promise<void>

    • Test whether a Ray between the origin and destination points would collide with a boundary of this Polygon. A valid wall restriction type is compulsory and must be passed into the config options.

      Parameters

      • origin: Point | ElevatedPoint

        An origin point. The elevation defaults to the elevation of config.source if passed and otherwise 0.

      • destination: Point | ElevatedPoint

        A destination point. The elevation defaults to the elevation of the origin.

      • config: PolygonConfig = {}

        The configuration that defines a certain Polygon type

        • mode

          The collision mode to test: "any", "all", or "closest"

        • tMin

          Intersections of the ray and an edge with t-value at most tMin are not considered collisions. Default: 0.

        • tMax

          Intersections of the ray and an edge with t-value greater than tMax are not considered collisions. Default: 1.

      Returns any

      The collision result depends on the mode of the test: * any: returns a boolean for whether any collision occurred * all: returns a sorted array of PolygonVertex instances * closest: returns a PolygonVertex instance or null