Options
All
  • Public
  • Public/Protected
  • All
Menu

A special class of Polygon which implements a limited angle of emission for a Point Source. The shape is defined by a point origin, radius, angle, and rotation. The shape is further customized by a configurable density which informs the approximation. An optional secondary externalRadius can be provided which adds supplementary visibility outside the primary angle.

Hierarchy

Index

Constructors

  • new LimitedAnglePolygon(origin: any, __namedParameters?: { radius: any; angle: number; rotation: number; density: any; externalRadius: number }): LimitedAnglePolygon
  • Parameters

    • origin: any
    • __namedParameters: { radius: any; angle: number; rotation: number; density: any; externalRadius: number } = {}
      • radius: any
      • angle: number
      • rotation: number
      • density: any
      • externalRadius: number

    Returns LimitedAnglePolygon

Properties

origin: Point

The origin point of the Polygon

radius: number

The radius of the emitted cone.

angle: number

The angle of the Polygon in degrees.

rotation: number

The direction of rotation at the center of the emitted angle in degrees.

density: number

The density of rays which approximate the cone, defined as rays per PI.

externalRadius: number

An optional "external radius" which is included in the polygon for the supplementary area outside the cone.

aMin: number

The angle of the left (counter-clockwise) edge of the emitted cone in radians.

aMax: number

The angle of the right (clockwise) edge of the emitted cone in radians.

externalBounds: Rectangle

The bounding box of the circle defined by the externalRadius, if any

isClosed: boolean

Methods

  • _includeEdge(a: Point, b: Point): boolean
  • Restrict the edges which should be included in a PointSourcePolygon based on this specialized shape. We use two tests to jointly keep or reject edges.

    1. If this shape uses an externalRadius, keep edges which collide with the bounding box of that circle.
    2. Keep edges which are contained within or collide with one of the primary angle boundary rays.
    internal

    Parameters

    • a: Point

      The first edge vertex

    • b: Point

      The second edge vertex

    Returns boolean

    Should the edge be included in the PointSourcePolygon computation?

  • 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

  • #generatePoints(): void
  • Generate the points of the LimitedAnglePolygon using the provided configuration parameters.

    Returns void

  • pointBetweenRays(point: Point, rMin: Ray, rMax: Ray, angle: number): boolean
  • Test whether a vertex lies between two boundary rays. If the angle is greater than 180, test for points between rMax and rMin (inverse). Otherwise, keep vertices that are between the rays directly.

    Parameters

    • point: Point

      The candidate point

    • rMin: Ray

      The counter-clockwise bounding ray

    • rMax: Ray

      The clockwise bounding ray

    • angle: number

      The angle being tested, in degrees

    Returns boolean

    Is the vertex between the two rays?

  • 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

Accessors

isClosed