An axis aligned Bounding Box.

This object contains a center and the half extent of the resulting box.


Maths

Constructors

  • Creates an axis aligned bounding box.

    If omitted, pCenter will be set to the origin (0,0,0). If omitted, pHalfExtent will be set to (0,0,0), this is an invalid box.

    Parameters

    • Optional pCenter: Vector3
      in
      The center of the AABB.
    • Optional pHalfExtent: Vector3
      in
      The half extent on each axis of the AABB.

    Returns AABB

    The newly constructed AABB.

Properties

mCenter: Vector3

The center of the axis aligned bounding box (x,y and z in this order).

mHalfExtent: Vector3

The half extent on each axis (x,y and z in this order).

Methods

  • Clamps the given AABB with the given limit AABB.

    If the boxes intersect, then the result is the intersection of the 2 boxes. If the 2 boxes do not intersect, then the AABB is restricted to the intersection of each axis in each direction. The result is therefore not the intersection of the two boxes, but the union of the intersection in each axis. If there is no intersection in this axis, the extent in this axis is left unchanged.

    Parameters

    • pLimitAABB: AABB
      in
      The AABB to clamp with.

    Returns boolean

    true if pLimitAABB is valid.

  • Copies this to pOut AABB. If pOut is not supplied, a new AABB is allocated.

    Parameters

    • Optional pOut: AABB
      out
      The AABB to copy to.

    Returns AABB

    The copied AABB.

  • Tells if the two AABB are strictly identical.

    Parameters

    • pOtherAABB: AABB
      in
      The other AABB to compare to.

    Returns boolean

    true if the two AABB are strictly identical.

  • Sets the content of the AABB from a former call to toJSON.

    Parameters

    • pAABBData: string | Object
      in
      Internal AABB data to set.

    Returns boolean

    true if the data is set.

  • Gets the AABB min max.

    Parameters

    • pMin: Vector3
      out
      The min point of the AABB.
    • pMax: Vector3
      out
      The max point of the AABB.

    Returns void

  • Gets the radius of the sphere centered on the center of the box which contains the box.

    This is equal to √(mHalfExtent.mHalfExtent).

    Returns number

    The box radius.

  • Grows the AABB to contain the box defined by Min : (pMinX,pMinY,pMinZ), Max : (pMaxX,pMaxY,pMaxZ).

    There is no check that pMinX <= pMaxX, pMinY <= pMaxY, pMinZ <= pMaxZ.

    Parameters

    • pMinX: number
      in
      Min x coordinate of the box to include.
    • pMinY: number
      in
      Min y coordinate of the box to include.
    • pMinZ: number
      in
      Min z coordinate of the box to include.
    • pMaxX: number
      in
      Max x coordinate of the box to include.
    • pMaxY: number
      in
      Max y coordinate of the box to include.
    • pMaxZ: number
      in
      Max z coordinate of the box to include.

    Returns boolean

    false is the pMax is lower than pMin else true.

  • Grows the AABB to contain the box pBox.

    Parameters

    • pBox: AABB
      in
      The box to include.

    Returns boolean

    false is the pBox is invalid else true.

  • Grows the AABB to contain the box expressed as center pBoxCenter and half extent pHalfExtent.

    Parameters

    • pBoxCenter: Vector3
      in
      The center of the box to include.
    • pHalfExtent: Vector3
      in
      The half extent of the box to include.

    Returns boolean

    false if the pHalfExtent contains negative value else true.

  • Grows the AABB to contain the box defined by pMin, pMax.

    There is no check that pMin <= pMax.

    Parameters

    • pMin: Vector3
      in
      Min point of the box to include.
    • pMax: Vector3
      in
      Max point of the box to include.

    Returns boolean

    false if pMax is lower than pMin else true.

  • Return if the AABB is valid ie all values of the half extent must be positive.

    Returns boolean

    true if all HalfExtent values are positive.

  • Initializes the AABB with pMin,pMax.

    Parameters

    • pMin: Vector3
      in
      The min point of the AABB.
    • pMax: Vector3
      in
      The max point of the AABB.

    Returns boolean

    false if the pMax is lower than pMin else true.

  • Tests if a point is in the box.

    Parameters

    • pPosition: Vector3
      in
      The point to test.

    Returns boolean

    true if point is in the AABB, else false.

  • Serializes the given AABB to JSON.

    Parameters

    • Optional pKey: any
      in
      Unused.

    Returns Object

    The JSON representation of the object.

  • Transforms the given AABB by multiplying all the extent points of the given AABB, and stores the AABB that contains this Oriented Bounding Box (OBB).

    If pOut is omitted, then the resulting AABB is stored in this.

    Parameters

    • pXForm: Matrix4
      in
      The matrix to multiply the extents point with.
    • Optional pOut: AABB
      out
      The resulting AABB (this if omitted).

    Returns AABB

    The transformed AABB pOut.

  • Tells where the box is located relative to the plane defined by the equation pPlane : (ax+by+cz=d).

    The positive side is given by the normal vector of the plane : (a,b,c) which are the three first parameters of pPlane. If the box is strictly included in the area of the normal, then 1 is returned, if the box is strictly included in the area opposite to the normal of the plane, -1 is returned. If the box intersects the plan, 0 is returned.

    Parameters

    • pPlane: Vector4
      in
      The plan to test with (equation of the plane ax+by+cz=d).

    Returns -1 | 0 | 1

    1 on positive side, -1 on negative side, 0 if it intersects the plane.