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

Hierarchy (view full)

Properties

bounds: Rectangle = ...

The rectangular bounds of this polygon

origin: Point

The origin point of the source polygon.

The configuration of this polygon.

#rays: any[] = []

Deprecated

since v11

WALL_DIRECTION_MODES: Readonly<{
    NORMAL: 0;
    REVERSED: 1;
    BOTH: 2;
}> = ...

Customize how wall direction of one-way walls is applied

Type declaration

  • NORMAL: 0
  • REVERSED: 1
  • BOTH: 2

Accessors

  • get isConstrained(): boolean
  • An indicator for whether this polygon is constrained by some boundary shape?

    Returns boolean

Methods

  • Customize the provided configuration object for this polygon type.

    Parameters

    Returns void

  • 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

    • Optional intersectionOptions: object = {}

      Options passed to the shape intersection method

    Returns PointSourcePolygon

    A new constrained polygon

  • Parameters

    • x: any
    • y: any

    Returns any

    Inherit Doc

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

    Returns Graphics

    The rendered debugging shape

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

    Returns any

  • Convert a PIXI.Polygon into an array of clipper points [{X,Y}, ...]. Note that clipper points must be rounded to integers. In order to preserve some amount of floating point precision, an optional scaling factor may be provided.

    Parameters

    • Optional options: {
          scalingFactor: number;
      } = {}

      Options which affect how clipper points are generated

      • scalingFactor: number

        A scaling factor used to preserve floating point precision

    Returns ClipperPoint[]

    An array of points to be used by clipper

  • Intersect this PIXI.Polygon with another PIXI.Polygon using the clipper library.

    Parameters

    • other: Polygon

      Another PIXI.Polygon

    • Optional options: {
          clipType: number;
          scalingFactor: number;
      } = {}

      Options which configure how the intersection is computed

      • clipType: number

        The clipper clip type

      • scalingFactor: number

        A scaling factor passed to Polygon#toClipperPoints to preserve precision

    Returns Polygon

    The intersected polygon

  • Intersect this PIXI.Polygon with an array of ClipperPoints.

    Parameters

    • clipperPoints: ClipperPoint[]

      Array of clipper points generated by PIXI.Polygon.toClipperPoints()

    • Optional options: {
          clipType: number;
          scalingFactor: number;
      } = {}

      Options which configure how the intersection is computed

      • clipType: number

        The clipper clip type

      • scalingFactor: number

        A scaling factor passed to Polygon#toClipperPoints to preserve precision

    Returns ClipperPoint[]

    The resulting ClipperPaths

  • Intersect this PIXI.Polygon with a PIXI.Circle. For now, convert the circle to a Polygon approximation and use intersectPolygon. In the future we may replace this with more specialized logic which uses the line-circle intersection formula.

    Parameters

    • circle: Circle

      A PIXI.Circle

    • Optional options: {
          density: number;
      }

      Options which configure how the intersection is computed

      • density: number

        The number of points which defines the density of approximation

    Returns Polygon

    The intersected polygon

  • Intersect this PIXI.Polygon with a PIXI.Rectangle. For now, convert the rectangle to a Polygon and use intersectPolygon. In the future we may replace this with more specialized logic which uses the line-line intersection formula.

    Parameters

    • rect: Rectangle

      A PIXI.Rectangle

    • Optional options: object

      Options which configure how the intersection is computed

    Returns Polygon

    The intersected polygon

  • 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: string

      The collision mode being tested

    Returns any

    The collision test result

    Abstract

  • Configure a limited angle and rotation into a triangular polygon boundary shape.

    Returns void

  • Configure a provided limited radius as a circular polygon boundary shape.

    Returns void

  • Benchmark the performance of polygon computation for this source

    Parameters

    • iterations: number

      The number of test iterations to perform

    • origin: Point

      The origin point to benchmark

    • config: PointSourcePolygonConfig

      The polygon configuration to benchmark

    Returns Promise<void>

  • Compute the polygon given a point origin and radius

    Parameters

    • origin: Point

      The origin source point

    • Optional config: PointSourcePolygonConfig = {}

      Configuration options which customize the polygon computation

    Returns PointSourcePolygon

    The computed polygon instance

  • 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

      An origin point

    • destination: Point

      A destination point

    • config: PointSourcePolygonConfig = {}

      The configuration that defines a certain Polygon type

    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

  • Construct a PIXI.Polygon instance from an array of clipper points [{X,Y}, ...].

    Parameters

    • points: ClipperPoint[]

      An array of points returned by clipper

    • Optional options: {
          scalingFactor: number;
      } = {}

      Options which affect how canvas points are generated

      • scalingFactor: number

        A scaling factor used to preserve floating point precision

    Returns Polygon

    The resulting PIXI.Polygon

  • Identify edges in the Scene which include an active threshold.

    Parameters

    • origin: Point
    • config: object

    Returns {
        edges: Edge[];
        nAttenuated: number;
    }

    • edges: Edge[]
    • nAttenuated: number
  • For each threshold wall that this source passes through construct a shape representing the attenuated source. The attenuated shape is a circle with a radius modified by origin proximity to the threshold wall. Intersect the attenuated shape against the LOS with threshold walls considered. The result is the LOS for the attenuated light source.

    Parameters

    • thresholdPolygon: PointSourcePolygon

      The computed polygon with thresholds applied

    • edges: Edge[]

      The identified array of threshold walls

    Returns ClipperPoints[]

    The resulting array of intersected threshold shapes

  • Calculate the attenuation of the source as it passes through the threshold wall. The distance of perception through the threshold wall depends on proximity of the source from the wall.

    Parameters

    • edge: Edge

      The Edge for which this threshold applies

    • origin: Point

      Origin point on the canvas for this source

    • radius: number

      Radius to use for this source, before considering attenuation

    • externalRadius: number

      The external radius of the source

    • type: string

      Sense type for the source

    Returns {
        inside: number;
        outside: number;
    }

    The inside and outside portions of the radius

    • inside: number
    • outside: number
  • Union the attenuated shape-LOS intersections with the closed LOS. The portion of the light sources "inside" the threshold walls are not modified from their default radius or shape. Clipper can union everything at once. Use a positive fill to avoid checkerboard; fill any overlap.

    Parameters

    Returns Polygon

    The combined LOS polygon with threshold shapes