PolygonCollider
Hierarchy
- Collider
- PolygonCollider
Index
Constructors
Properties
Accessors
Methods
Constructors
constructor
Parameters
options: PolygonColliderOptions
Returns PolygonCollider
Properties
publiccomposite
Composite collider if any this collider is attached to
WARNING do not tamper with this property
publicevents
publicreadonlyid
publicoffset
Pixel offset relative to a collider's body transform position.
publicowner
Accessors
publicaxes
Get the axis associated with the convex polygon
Returns Vector[]
publicbounds
Get the axis aligned bounding box for the polygon collider in world coordinates
Returns BoundingBox
publiccenter
Get the center of the collider in world coordinates
Returns Vector
publiclocalBounds
Get the axis aligned bounding box for the polygon collider in local coordinates
Returns BoundingBox
publicnormals
Returns readonly Vector[]
publicpoints
Points in the polygon in order around the perimeter in local coordinates. These are relative from the body transform position. Excalibur stores these in counter-clockwise order
Returns Vector[]
Points in the polygon in order around the perimeter in local coordinates. These are relative from the body transform position. Excalibur stores these in counter-clockwise order
Parameters
points: Vector[]
Returns void
publictransform
Returns Transform
publicworldPos
Returns the world position of the collider, which is the current body transform plus any defined offset
Returns Vector
Methods
public_isCounterClockwiseWinding
Parameters
points: Vector[]
Returns boolean
publicclone
Returns a clone of this ConvexPolygon, not associated with any collider
Returns PolygonCollider
publiccollide
Returns a collision contact if the 2 colliders collide, otherwise collide will return null.
Parameters
collider: Collider
Returns CollisionContact[]
publiccontains
Tests if a point is contained in this collider in world space
Parameters
point: Vector
Returns boolean
publicdebug
Parameters
ex: ExcaliburGraphicsContext
color: Color
optionaloptions: { lineWidth: number; pointSize: number }
Returns void
publicfindLocalSide
Given a direction vector find the local space side that is most in that direction
Parameters
direction: Vector
Returns LineSegment
publicfindSide
Given a direction vector find the world space side that is most in that direction
Parameters
direction: Vector
Returns LineSegment
publicflagDirty
Returns void
publicgetClosestFace
Finds the closes face to the point using perpendicular distance
Parameters
point: Vector
point to test against polygon
Returns { distance: Vector; face: LineSegment }
distance: Vector
face: LineSegment
publicgetClosestLineBetween
Returns the closest line between the surfaces this collider and another
Parameters
collider: Collider
Returns LineSegment
publicgetFurthestLocalPoint
publicgetFurthestPoint
publicgetInertia
Get the moment of inertia for an arbitrary polygon https://en.wikipedia.org/wiki/List_of_moments_of_inertia
Parameters
mass: number
Returns number
publicgetLocalSides
Returns the local coordinate space sides
Returns LineSegment[]
publicgetSides
Gets the sides of the polygon in world space
Returns LineSegment[]
publicgetTransformedPoints
Gets the points that make up the polygon in world space, from actor relative space (if specified)
Returns Vector[]
publicisConvex
Returns if the polygon collider is convex, Excalibur does not handle non-convex collision shapes. Call Polygon.triangulate to generate a CompositeCollider from this non-convex shape
Returns boolean
publicproject
Project the edges of the polygon along a specified axis
Parameters
axis: Vector
Returns Projection
publicrayCast
Casts a ray into the polygon and returns a vector representing the point of contact (in world space) or null if no collision.
Parameters
ray: Ray
max: number = Infinity
Returns RayCastHit
publictessellate
Tessellates the polygon into a triangle fan as a CompositeCollider of triangle polygons
Returns CompositeCollider
publictouching
publictriangulate
Triangulate the polygon collider using the "Ear Clipping" algorithm. Returns a new CompositeCollider made up of smaller triangles.
Returns CompositeCollider
publicupdate
Updates the transform for the collision geometry
Collision geometry (points/bounds) will not change until this is called.
Parameters
transform: Transform
Returns void
Polygon collider for detecting collisions