- PointSourcePolygon
- ClockwiseSweepPolygon

initialize
clone
_compute
_testCollision
visualize
compute
applyConstraint
contains
isCompleteCircle
toClipperPoints
intersectPolygon
intersectClipper
intersectCircle
intersectRectangle
_identifyEdges
_determineEdgeTypes
_testEdgeInclusion
_defineBoundingBox
_identifyVertices
_identifyIntersections
_constrainBoundaryShapes
_executeSweep
#includeCollinearVertices
#updateActiveEdges
_initializeActiveEdges
_sortVertices
_isVertexBehindActiveEdges
_determineSweepResult
_switchEdge
#addInternalEdgeCollisions
_visualizeCollision
#configureLimitedAngle
#configureLimitedRadius
benchmark
create
testCollision
applyThresholdAttenuation
fromClipperPoints

A mapping of vertices which define potential collision points

The set of edges which define potential boundaries of the polygon

A collection of rays which are fired at vertices

bounds: Rectangle = ...

The rectangular bounds of this polygon

origin: Point

The origin point of the source polygon.

The configuration of this polygon.

`Private`

#ray#rayDistance2 : number

The squared maximum distance of a ray that is needed for this Scene.

`Private`

#rays#rays: any[] = []

since v11

`Static`

WALL_WALL_DIRECTION_MODES : Readonly<{

NORMAL: 0;

REVERSED: 1;

BOTH: 2;

}> = ...

NORMAL: 0;

REVERSED: 1;

BOTH: 2;

}> = ...

Customize how wall direction of one-way walls is applied

##### NORMAL: 0

##### REVERSED: 1

##### BOTH: 2

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

#### Returns boolean

- clone(): PointSourcePolygon
Create a clone of this polygon. This overrides the default PIXI.Polygon#clone behavior.

#### Returns PointSourcePolygon

A cloned instance

- compute(): PointSourcePolygon
Compute the polygon using the origin and configuration options.

#### Returns PointSourcePolygon

The computed polygon

- apply
Constraint (constraint, intersectionOptions?): PointSourcePolygon 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

- constraint: Rectangle | Polygon | Circle

- to
Clipper (options?): ClipperPoint[]Points 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

##### scaling

Factor : numberA scaling factor used to preserve floating point precision

#### Returns ClipperPoint[]

An array of points to be used by clipper

- intersect
Polygon (other, options?): Polygon 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

##### clip

Type : numberThe clipper clip type

##### scaling

Factor : numberA scaling factor passed to Polygon#toClipperPoints to preserve precision

#### Returns Polygon

The intersected polygon

- other: Polygon

- intersect
Clipper (clipperPoints, options?): ClipperPoint[] 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

##### clip

Type : numberThe clipper clip type

##### scaling

Factor : numberA scaling factor passed to Polygon#toClipperPoints to preserve precision

#### Returns ClipperPoint[]

The resulting ClipperPaths

- clipperPoints: ClipperPoint[]

- intersect
Circle (circle, options?): 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

`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

- circle: Circle

- intersect
Rectangle (rect, options?): 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: objectOptions which configure how the intersection is computed

#### Returns Polygon

The intersected polygon

- rect: Rectangle

`Protected`

_identify`Protected`

_determine`Protected`

_test- _test
Edge (edge, edgeTypes, bounds): booleanInclusion `Protected`

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

#### Parameters

- edge: Edge
The Edge being considered

- edgeTypes: Record<EdgeTypes, 0 | 1 | 2>
Which types of edges are being used? 0=no, 1=maybe, 2=always

- bounds: Rectangle
The overall bounding box

#### Returns boolean

Should the edge be included?

- edge: Edge

`Protected`

_define`Protected`

_identify`Protected`

_identify`Protected`

_constrain`Private`

_execute`Private`

#include`Private`

#update- #update
Active (vertex, activeEdges): voidEdges Update active edges at a given vertex Remove counter-clockwise edges which have now concluded. Add clockwise edges which are ongoing or beginning.

#### Parameters

- vertex: PolygonVertex
The current vertex

- activeEdges: EdgeSet
A set of currently active edges

#### Returns void

- vertex: PolygonVertex

`Private`

_initialize`Private`

_sort`Private`

_is- _is
Vertex (vertex, activeEdges): {Behind Active Edges

isBehind: boolean;

wasLimited: boolean;

} `Private`

Test whether a target vertex is behind some closer active edge. If the vertex is to the left of the edge, is must be behind the edge relative to origin. If the vertex is collinear with the edge, it should be considered "behind" and ignored. We know edge.vertexA is ccw to edge.vertexB because of the logic in _identifyVertices.

#### Parameters

- vertex: PolygonVertex
The target vertex

- activeEdges: EdgeSet
The set of active edges

#### Returns {

isBehind: boolean;

wasLimited: boolean;

}Is the target vertex behind some closer edge?

##### is

Behind : boolean##### was

Limited : boolean

- vertex: PolygonVertex

`Private`

_determine- _determine
Sweep (vertex, activeEdges, hasCollinear?): voidResult `Private`

Determine the result for the sweep at a given vertex

#### Parameters

- vertex: PolygonVertex
The target vertex

- activeEdges: EdgeSet
The set of active edges

- hasCollinear: boolean = false
Are there collinear vertices behind the target vertex?

#### Returns void

- vertex: PolygonVertex

`Private`

_switch- _switch
Edge (result, activeEdges): void `Private`

Switch to a new active edge. Moving from the origin, a collision that first blocks a side must be stored as a polygon point. Subsequent collisions blocking that side are ignored. Once both sides are blocked, we are done.

Collisions that limit a side will block if that side was previously limited.

If neither side is blocked and the ray internally collides with a non-limited edge, n skip without adding polygon endpoints. Sight is unaffected before this edge, and the internal collision can be ignored.

#### Parameters

- result: CollisionResult
The pending collision result

- activeEdges: EdgeSet
The set of currently active edges

#### Returns void

- result: CollisionResult

`Private`

#add`Private`

_visualize- _visualize
Collision (ray, collisions): void `Private`

Visualize the polygon, displaying its computed area, rays, and collision points

#### Parameters

- ray: Ray
- collisions: PolygonVertex[]

#### Returns void

`Private`

#configure`Private`

#configure`Static`

benchmark- benchmark(iterations, origin, config): Promise<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>

- iterations: number

`Static`

create- create(origin, config?): PointSourcePolygon
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

- origin: Point

`Static`

test- test
Collision (origin, destination, config?): any 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

- origin: Point

`Static`

apply- apply
Threshold (polygon): PointSourcePolygonAttenuation Augment a PointSourcePolygon by adding additional coverage for shapes permitted by threshold walls.

#### Parameters

- polygon: PointSourcePolygon
The computed polygon

#### Returns PointSourcePolygon

The augmented polygon

- polygon: PointSourcePolygon

`Static`

from- from
Clipper (points, options?): PolygonPoints 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

##### scaling

Factor : numberA scaling factor used to preserve floating point precision

#### Returns Polygon

The resulting PIXI.Polygon

- points: ClipperPoint[]

A PointSourcePolygon implementation that uses CCW (counter-clockwise) geometry orientation. Sweep around the origin, accumulating collision points based on the set of active walls. This algorithm was created with valuable contributions from https://github.com/caewok