Class Box3

Represents an axis-aligned bounding box (AABB) in 3D space.

Hierarchy

  • Base
    • Box3

Constructors

  • Creates a Box3 bounded by min and max.

    Parameters

    • Optional min: Vector3

      (optional) Vector3 representing the lower (x, y, z) boundary of the box. Default is ( + Infinity, + Infinity, + Infinity ).

    • Optional max: Vector3

      (optional) Vector3 representing the upper (x, y, z) boundary of the box. Default is ( - Infinity, - Infinity, - Infinity ).

    Returns Box3

Properties

max: Vector3

Vector3 representing the upper (x, y, z) boundary of the box. Default is ( - Infinity, - Infinity, - Infinity ).

min: Vector3

Vector3 representing the lower (x, y, z) boundary of the box. Default is ( + Infinity, + Infinity, + Infinity ).

Accessors

  • get isBox2(): boolean
  • Returns boolean

  • get isBox3(): boolean
  • Read-only flag to check if a given object is of type Box3.

    Returns boolean

  • get isColor(): boolean
  • Returns boolean

  • get isCylindrical(): boolean
  • Returns boolean

  • get isEuler(): boolean
  • Returns boolean

  • get isLine3(): boolean
  • Returns boolean

  • get isMatrix3(): boolean
  • Returns boolean

  • get isMatrix4(): boolean
  • Returns boolean

  • get isPlane(): boolean
  • Returns boolean

  • get isQuaternion(): boolean
  • Returns boolean

  • get isRay(): boolean
  • Returns boolean

  • get isSphere(): boolean
  • Returns boolean

  • get isSpherical(): boolean
  • Returns boolean

  • get isTriangle(): boolean
  • Returns boolean

  • get isVector2(): boolean
  • Returns boolean

  • get isVector3(): boolean
  • Returns boolean

  • get isVector4(): boolean
  • Returns boolean

Methods

  • Transforms this Box3 with the supplied matrix.

    Returns

    This instance.

    Parameters

    • matrix: Matrix4

      The Matrix4 to apply

    Returns Box3

  • Clamps the point within the bounds of this box.

    Returns

    A new clamped Vector3.

    Parameters

    • point: Vector3

      Vector3 to clamp.

    • Optional target: Vector3

      — the result will be copied into this Vector3.

    Returns Vector3

  • Returns a new Box3 with the same min and max as this one.

    Returns

    A new instance.

    Returns Box3

  • Test if this box includes the entirety of box.

    Returns

    True if this box includes the entirety of box. If this and box are identical, this function also returns true.

    Parameters

    • box: Box3

      Box3 to test for inclusion.

    Returns boolean

  • Test if the specified point lies within or on the boundaries of this box.

    Returns

    True if the specified point lies within or on the boundaries of this box.

    Parameters

    • point: Vector3

      Vector3 to check for inclusion.

    Returns boolean

  • Copies the min and max from box to this box.

    Returns

    This instance.

    Parameters

    • box: Box3

      Box3 to copy.

    Returns Box3

  • Find the distance from any edge of this box to the specified point. If the point lies inside of this box, the distance will be 0.

    Returns

    Returns the distance.

    Parameters

    • point: Vector3

      Vector3 to measure distance to.

    Returns number

  • Test if this box and box share the same lower and upper bounds.

    Returns

    True if this box and box share the same lower and upper bounds.

    Parameters

    • box: Box3

      Box to compare with this one.

    Returns boolean

  • Expands the boundaries of this box to include point.

    Returns

    This instance.

    Parameters

    • point: Vector3

      Vector3 that should be included in the box.

    Returns Box3

  • Expands each dimension of the box by scalar. If negative, the dimensions of the box will be contracted.

    Returns

    This instance.

    Parameters

    • scalar: number

      Distance to expand the box by.

    Returns Box3

  • Expands this box equilaterally by vector. The width of this box will be expanded by the x component of vector in both directions. The height of this box will be expanded by the y component of vector in both directions. The depth of this box will be expanded by the z component of vector in both directions.

    Returns

    This instance.

    Parameters

    • vector: Vector3

      Vector3 to expand the box by.

    Returns Box3

  • Gets a Sphere that bounds the box.

    Returns

    The bounding sphere.

    Parameters

    • target: Sphere

      The result will be copied into this Sphere.

    Returns Sphere

  • Find the center point of the box as a Vector3.

    Returns

    The center point.

    Parameters

    • Optional target: Vector3

      The result will be copied into this Vector3.

    Returns Vector3

  • Given a point inside a box, find it's relative proportion to the box's width, height and depth.

    Returns

    The 3D propportions.

    Parameters

    • point: Vector3

      A point inside the box

    • Optional target: Vector3

      The result will be copied into this Vector3.

    Returns Vector3

  • Get the width, height and depth of this box.

    Returns

    The box dimensions.

    Parameters

    • Optional target: Vector3

      The result will be copied into this Vector3.

    Returns Vector3

  • Computes the intersection of this and box, setting the upper bound of this box to the lesser of the two boxes' upper bounds and the lower bound of this box to the greater of the two boxes' lower bounds. If there's no overlap, makes this box empty.

    Returns

    This instance.

    Parameters

    • box: Box3

      Box to intersect with.

    Returns Box3

  • Determines whether or not this box intersects box.

    Returns

    True if box intersects this box.

    Parameters

    • box: Box3

      Box to check for intersection against.

    Returns boolean

  • Determines whether or not this box intersects plane.

    Returns

    True if this box intersects the plane.

    Parameters

    • plane: Plane

      Plane to check for intersection against.

    Returns boolean

  • Determines whether or not this box intersects sphere.

    Returns

    True if this box overlaps any part of a sphere.

    Parameters

    • sphere: Sphere

      Sphere to check for intersection against.

    Returns boolean

  • Determines whether or not this box intersects triangle.

    Returns

    True if this box overlaps triangle anywhere.

    Parameters

    • triangle: Triangle

      Triangle to check for intersection against.

    Returns boolean

  • Returns true if this box includes zero points within its bounds. Note that a box with equal lower and upper bounds still includes one point, the one both bounds share.

    Returns

    True if box includes zero points.

    Returns boolean

  • Sets the lower and upper (x, y, z) boundaries of this box. Note that this method only copies the values from the given objects.

    Returns

    This instance.

    Parameters

    • min: Vector3

      Vector3 representing the lower (x, y, z) boundary of the box.

    • max: Vector3

      Vector3 representing the upper (x, y, z) boundary of the box.

    Returns Box3

  • Sets the upper and lower bounds of this box to include all of the data in array.

    Returns

    This instance.

    Parameters

    • array: number[]

      An array of position data that the resulting box will envelop.

    Returns Box3

  • Centers this box on center and sets this box's width, height and depth to the values specified in size.

    Returns

    This instance.

    Parameters

    • center: Vector3

      Desired center position of the box.

    • size: Vector3

      Desired x, y and z dimensions of the box.

    Returns Box3

  • Sets the upper and lower bounds of this box to include all of the points in points.

    Returns

    This instance.

    Parameters

    • points: Vector3[]

      Array of Vector3s that the resulting box will contain.

    Returns Box3

  • Adds offset to both the upper and lower bounds of this box, effectively moving this box offset units in 3D space.

    Returns

    This instance.

    Parameters

    • offset: Vector3

      Direction and distance of offset.

    Returns Box3

  • Computes the union of this box and box, setting the upper bound of this box to the greater of the two boxes' upper bounds and the lower bound of this box to the lesser of the two boxes' lower bounds.

    Returns

    This instance.

    Parameters

    • box: Box3

      Box that will be unioned with this box.

    Returns Box3