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.

rays: Ray[] = []

A cached array of SightRay objects used to compute the polygon.

isClosed: boolean

Accessors

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

    Returns boolean

isClosed

Methods

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

    Parameters

    • x: any
    • y: any

    Returns any

  • 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

  • visualize(): void
  • Visualize the polygon, displaying its computed area, rays, and collision points

    Returns void

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

    } 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

  • 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

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

  • 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

  • fromClipperPoints(points: { X: number; Y: number }[], [options]?: { scalingFactor: number }): Polygon
  • Construct a PIXI.Polygon instance from an array of clipper points [{X,Y}, ...].

    Parameters

    • points: { X: number; Y: number }[]
    • [options]: { scalingFactor: number } = {}

      Options which affect how canvas points are generated

      • scalingFactor: number

    Returns Polygon

    The resulting PIXI.Polygon