BoundingBox
Index
Constructors
Properties
Accessors
Methods
Constructors
constructor
Constructor allows passing of either an object with all coordinate components, or the coordinate components passed separately.
Parameters
leftOrOptions: number | BoundingBoxOptions = 0
Either x coordinate of the left edge or an options object containing the four coordinate components.
top: number = 0
y coordinate of the top edge
right: number = 0
x coordinate of the right edge
bottom: number = 0
y coordinate of the bottom edge
Returns BoundingBox
Properties
publicbottom
publicleft
publicright
publictop
Accessors
publicbottomLeft
Returns Vector
publicbottomRight
Returns Vector
publiccenter
Returns the center of the bounding box
Returns Vector
publicdimensions
Returns Vector
publicheight
Returns the calculated height of the bounding box
Returns number
publictopLeft
Returns Vector
publictopRight
Returns Vector
publicwidth
Returns the calculated width of the bounding box
Returns number
Methods
publicclone
Returns a new instance of BoundingBox that is a copy of the current instance
Parameters
optionaldest: BoundingBox
Returns BoundingBox
publiccombine
Combines this bounding box and another together returning a new bounding box
Parameters
other: BoundingBox
The bounding box to combine
optionaldest: BoundingBox
Returns BoundingBox
publiccontains
Tests whether a point is contained within the bounding box
Parameters
p: Vector
The point to test
Returns boolean
publicdraw
Draw a debug bounding box
Parameters
ex: ExcaliburGraphicsContext
color: Color = Color.Yellow
Returns void
publicgetPerimeter
Returns the perimeter of the bounding box
Returns number
publicgetPoints
Returns the world space points that make up the corners of the bounding box as a polygon
Returns Vector[]
publichasZeroDimensions
Return whether the bounding box has zero dimensions in height,width or both
Returns boolean
publicintersect
Test wether this bounding box intersects with another returning the intersection vector that can be used to resolve the collision. If there is no intersection null is returned.
Parameters
other: BoundingBox
Other BoundingBox to test intersection with
Returns Vector
A Vector in the direction of the current BoundingBox, this <- other
publicintersectWithSide
Test whether the bounding box has intersected with another bounding box, returns the side of the current bb that intersected.
Parameters
bb: BoundingBox
The other actor to test
Returns Side
publicoverlaps
Returns true if the bounding boxes overlap.
Parameters
other: BoundingBox
optionalepsilon: number
Optionally specify a small epsilon (default 0) as amount of overlap to ignore as overlap. This epsilon is useful in stable collision simulations.
Returns boolean
publicrayCast
Determines whether a ray intersects with a bounding box
Parameters
ray: Ray
farClipDistance: number = Infinity
Returns boolean
publicrayCastTime
Parameters
ray: Ray
farClipDistance: number = Infinity
Returns number
publicreset
Resets the bounds to a zero width/height box
Returns void
publicrotate
Rotates a bounding box by and angle and around a point, if no point is specified (0, 0) is used by default. The resulting bounding box is also axis-align. This is useful when a new axis-aligned bounding box is needed for rotated geometry.
Parameters
angle: number
point: Vector = Vector.Zero
Returns BoundingBox
publicscale
Scale a bounding box by a scale factor, optionally provide a point
Parameters
Returns BoundingBox
publictransform
Transform the axis aligned bounding box by a Matrix, producing a new axis aligned bounding box
Parameters
matrix: AffineMatrix
Returns BoundingBox
publictranslate
Parameters
pos: Vector
Returns BoundingBox
publicstaticfromDimension
Creates a bounding box from a width and height
Parameters
width: number
height: number
anchor: Vector = Vector.Half
Default Vector.Half
pos: Vector = Vector.Zero
Default Vector.Zero
Returns BoundingBox
publicstaticfromPoints
Parameters
points: Vector[]
Returns BoundingBox
Axis Aligned collision primitive for Excalibur.