Axis-Aligned Bounding Box.

Constructors

  • Create a new BoundingBox instance. The bounding box is axis-aligned.

    Parameters

    • Optionalcenter: Vec3 = ...

      Center of box. The constructor takes a reference of this parameter.

    • OptionalhalfExtents: Vec3 = ...

      Half the distance across the box in each axis. The constructor takes a reference of this parameter. Defaults to 0.5 on each axis.

    Returns BoundingBox

Properties

center: Vec3

Center of box.

halfExtents: Vec3

Half the distance across the box in each axis.

Methods

  • Compute the size of the AABB to encapsulate all specified vertices.

    Parameters

    • vertices: number[] | Float32Array

      The vertices used to compute the new size for the AABB.

    • OptionalnumVerts: number

      Number of vertices to use from the beginning of vertices array. All vertices are used if not specified.

    Returns void

  • Test if a ray intersects with the AABB.

    Parameters

    • ray: Ray

      Ray to test against (direction must be normalized).

    • Optionalpoint: Vec3

      If there is an intersection, the intersection point will be copied into here.

    Returns boolean

    True if there is an intersection.

  • Set an AABB to enclose the specified AABB if it were to be transformed by the specified 4x4 matrix.

    Parameters

    • aabb: BoundingBox

      Box to transform and enclose.

    • m: Mat4

      Transformation matrix to apply to source AABB.

    • ignoreScale: boolean = false

      If true is specified, a scale from the matrix is ignored. Defaults to false.

    Returns void

  • Compute the min and max bounding values to encapsulate all specified vertices.

    Parameters

    • vertices: number[] | Float32Array

      The vertices used to compute the new size for the AABB.

    • min: Vec3

      Stored computed min value.

    • max: Vec3

      Stored computed max value.

    • OptionalnumVerts: number = ...

      Number of vertices to use from the beginning of vertices array. All vertices are used if not specified.

    Returns void