Options
All
  • Public
  • Public/Protected
  • All
Menu

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

Hierarchy

Index

Constructors

Properties

bounds: Rectangle = ...

The rectangular bounds of this polygon

origin: Point

The origin point of the source polygon.

The configuration of this polygon.

points: any
isClosed: boolean
#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

Accessors

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

    Returns boolean

isClosed

Methods

  • Create a clone of this polygon. This overrides the default PIXI.Polygon#clone behavior.

    override

    Returns PointSourcePolygon

    A cloned instance

  • Compute the polygon using the origin and configuration options.

    Returns PointSourcePolygon

    The computed polygon

  • 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

    Returns PointSourcePolygon

    A new constrained polygon

  • contains(x: any, y: any): any
  • inheritdoc

    Parameters

    • x: any
    • y: any

    Returns any

  • visualize(): any
  • Visualize the polygon, displaying its computed area and applied boundary shapes.

    Returns any

    The rendered debugging shape

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

    Returns any

  • toClipperPoints([options]?: { scalingFactor: number }): ClipperPoint[]
  • 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

    • [options]: { scalingFactor: number } = {}

      Options which affect how clipper points are generated

      • scalingFactor: number

    Returns ClipperPoint[]

    An array of points to be used by clipper

  • intersectPolygon(other: Polygon, [options]?: { clipType: number; scalingFactor: number }): Polygon
  • Intersect this PIXI.Polygon with another PIXI.Polygon using the clipper library.

    Parameters

    • other: Polygon

      Another PIXI.Polygon

    • [options]: { clipType: number; scalingFactor: number } = {}

      Options which configure how the intersection is computed

      • clipType: number
      • scalingFactor: number

    Returns Polygon

    The intersected polygon or null if no solution was present

  • intersectClipper(clipperPoints: ClipperPoint[], [options]?: { clipType: number; scalingFactor: number }): ClipperPoint[]
  • Intersect this PIXI.Polygon with an array of ClipperPoints.

    Parameters

    • clipperPoints: ClipperPoint[]

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

    • [options]: { clipType: number; scalingFactor: number } = {}

      Options which configure how the intersection is computed

      • clipType: number
      • scalingFactor: number

    Returns ClipperPoint[]

    The resulting ClipperPaths

  • intersectCircle(circle: Circle, options: { density: number }): Polygon
  • 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

    • options: { density: number }
      • density: number

    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

    • options: any

    Returns Polygon

    The intersected polygon

  • _compute(): void
  • Perform the implementation-specific computation

    Returns void

  • _getWalls(): Set<Wall>
  • Get the super-set of walls which could potentially apply to this polygon. Define a custom collision test used by the Quadtree to obtain candidate Walls.

    Returns Set<Wall>

  • Test whether a wall should be included in the computed polygon for a given origin and type

    Parameters

    • wall: Wall

      The Wall being considered

    • bounds: Rectangle

      The overall bounding box

    Returns boolean

    Should the wall be included?

  • Compute the aggregate bounding box which is the intersection of all boundary shapes. Round and pad the resulting rectangle by 1 pixel to ensure it always contains the origin.

    Returns Rectangle

  • _constrainBoundaryShapes(): void
  • Constrain polygon points by applying boundary shapes.

    Returns void

  • _testCollision(ray: Ray, mode: string): boolean | PolygonVertex | PolygonVertex[]
  • Determine the set of collisions which occurs for a Ray.

    abstract

    Parameters

    • ray: Ray

      The Ray to test

    • mode: string

      The collision mode being tested

    Returns boolean | PolygonVertex | PolygonVertex[]

    The collision test result

  • #configureLimitedAngle(): void
  • Configure a limited angle and rotation into a triangular polygon boundary shape.

    Returns void

  • #configureLimitedRadius(): 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>

  • testCollision(origin: Point, destination: Point, config?: PointSourcePolygonConfig): boolean | PolygonVertex | PolygonVertex[]
  • 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 boolean | PolygonVertex | PolygonVertex[]

    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

  • Augment a PointSourcePolygon by adding additional coverage for shapes permitted by threshold walls.

    Parameters

    Returns PointSourcePolygon

    The augmented polygon

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

    Parameters

    • points: ClipperPoint[]

      An array of points returned by clipper

    • [options]: { scalingFactor: number } = {}

      Options which affect how canvas points are generated

      • scalingFactor: number

    Returns Polygon

    The resulting PIXI.Polygon

  • #getThresholdWalls(origin: Point, config: any): { thresholdWalls: Wall[]; nAttenuated: number }
  • Identify walls in the Scene which include an active threshold.

    Parameters

    • origin: Point
    • config: any

    Returns { thresholdWalls: Wall[]; nAttenuated: number }

    • thresholdWalls: Wall[]
    • 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

    • thresholdWalls: Wall[]

      The identified array of threshold walls

    Returns ClipperPoints[]

    The resulting array of intersected threshold shapes

  • #calculateThresholdAttenuation(wall: Wall, origin: Point, radius: number, externalRadius: number, type: string): { inside: number; outside: number }
  • 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

    • wall: Wall

      The wall 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