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
The rectangular bounds of this polygon
The origin point of the source polygon.
The configuration of this polygon.
Private
#rayThe squared maximum distance of a ray that is needed for this Scene.
Private
#rayssince v11
Static
WALL_Customize how wall direction of one-way walls is applied
An indicator for whether this polygon is constrained by some boundary shape?
Create a clone of this polygon. This overrides the default PIXI.Polygon#clone behavior.
A cloned instance
Compute the polygon using the origin and configuration options.
The computed polygon
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.
The constraining boundary shape
Optional
intersectionOptions: object = {}Options passed to the shape intersection method
A new constrained polygon
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.
Optional
options: { Options which affect how clipper points are generated
A scaling factor used to preserve floating point precision
An array of points to be used by clipper
Intersect this PIXI.Polygon with another PIXI.Polygon using the clipper library.
Another PIXI.Polygon
Optional
options: { Options which configure how the intersection is computed
The clipper clip type
A scaling factor passed to Polygon#toClipperPoints to preserve precision
The intersected polygon
Intersect this PIXI.Polygon with an array of ClipperPoints.
Array of clipper points generated by PIXI.Polygon.toClipperPoints()
Optional
options: { Options which configure how the intersection is computed
The clipper clip type
A scaling factor passed to Polygon#toClipperPoints to preserve precision
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.
A PIXI.Circle
Optional
options: { Options which configure how the intersection is computed
The number of points which defines the density of approximation
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.
A PIXI.Rectangle
Optional
options: objectOptions which configure how the intersection is computed
The intersected polygon
Protected
_identifyProtected
_determineProtected
_testProtected
Test whether a wall should be included in the computed polygon for a given origin and type
The Edge being considered
Which types of edges are being used? 0=no, 1=maybe, 2=always
The overall bounding box
Should the edge be included?
Protected
_defineProtected
_identifyProtected
_identifyProtected
_constrainPrivate
_executePrivate
#includePrivate
#updateUpdate active edges at a given vertex Remove counter-clockwise edges which have now concluded. Add clockwise edges which are ongoing or beginning.
The current vertex
A set of currently active edges
Private
_initializePrivate
_sortPrivate
_isPrivate
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.
The target vertex
The set of active edges
Is the target vertex behind some closer edge?
Private
_determinePrivate
Determine the result for the sweep at a given vertex
The target vertex
The set of active edges
Are there collinear vertices behind the target vertex?
Private
_switchPrivate
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.
The pending collision result
The set of currently active edges
Private
#addPrivate
_visualizePrivate
Visualize the polygon, displaying its computed area, rays, and collision points
Private
#configurePrivate
#configureStatic
benchmarkBenchmark the performance of polygon computation for this source
The number of test iterations to perform
The origin point to benchmark
The polygon configuration to benchmark
Static
createCompute the polygon given a point origin and radius
The origin source point
Optional
config: PointSourcePolygonConfig = {}Configuration options which customize the polygon computation
The computed polygon instance
Static
testTest 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.
An origin point
A destination point
The configuration that defines a certain Polygon type
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
Static
applyAugment a PointSourcePolygon by adding additional coverage for shapes permitted by threshold walls.
The computed polygon
The augmented polygon
Static
fromConstruct a PIXI.Polygon instance from an array of clipper points [{X,Y}, ...].
An array of points returned by clipper
Optional
options: { Options which affect how canvas points are generated
A scaling factor used to preserve floating point precision
The resulting PIXI.Polygon
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