Options
All
  • Public
  • Public/Protected
  • All
Menu

Axis Aligned collision primitive for Excalibur.

Hierarchy

  • BoundingBox

Index

Constructors

constructor

  • Constructor allows passing of either an object with all coordinate components, or the coordinate components passed separately.

    Parameters

    • Default value leftOrOptions: number | BoundingBoxOptions = 0

      Either x coordinate of the left edge or an options object containing the four coordinate components.

    • Default value top: number = 0

      y coordinate of the top edge

    • Default value right: number = 0

      x coordinate of the right edge

    • Default value bottom: number = 0

      y coordinate of the bottom edge

    Returns BoundingBox

Properties

bottom

bottom: number

left

left: number

right

right: number

top

top: number

Accessors

center

dimensions

height

  • get height(): number

width

  • get width(): number

Methods

combine

contains

debugDraw

  • debugDraw(ctx: CanvasRenderingContext2D, color?: Color): void

getPerimeter

  • getPerimeter(): number

getPoints

intersect

  • 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

    Returns Vector

    A Vector in the direction of the current BoundingBox, this <- other

intersectWithSide

  • Test whether the bounding box has intersected with another bounding box, returns the side of the current bb that intersected.

    Parameters

    Returns Side

rayCast

  • rayCast(ray: Ray, farClipDistance?: number): boolean
  • Determines whether a ray intersects with a bounding box

    Parameters

    • ray: Ray
    • Default value farClipDistance: number = Infinity

    Returns boolean

rayCastTime

  • rayCastTime(ray: Ray, farClipDistance?: number): number

rotate

  • 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
    • Default value point: Vector = Vector.Zero

    Returns BoundingBox

scale

toPolygon

translate

Static fromDimension

Static fromPoints

Static getSideFromIntersection

  • getSideFromIntersection(intersection: Vector): Side
  • Given bounding box A & B, returns the side relative to A when intersection is performed.

    Parameters

    • intersection: Vector

      Intersection vector between 2 bounding boxes

    Returns Side