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

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

Methods

  • Internal

    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.

    Parameters

    • a: Point

      The first edge vertex

    • b: Point

      The second edge vertex

    Returns boolean

    Should the edge be included in the PointSourcePolygon computation?

  • 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

  • Generate the points of the LimitedAnglePolygon using the provided configuration parameters.

    Returns void

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

  • 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