Box3

A 3D box represents by min and max.

Core Class

A 3D box represents by min and max.

Constructors

Properties

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.

planes: Plane[]

An array of Planes represents the six faces of the box.

corners: Vector3[]

The position of eight box's vertexes.

isBox3: boolean

Check the type whether it belongs to Box3. This value should not be changed by user.

Methods

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

    Parameters

    • min: Vector3

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

    • max: Vector3

      Vector3 representing the lower 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.

    Parameters

    • array: ArrayLike<number>

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

    Returns Box3

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

    Parameters

    • attribute: BufferAttribute

      A buffer attribute of position data that the resulting box will envelop.

    Returns Box3

  • Sets the upper and lower bounds of this box by a part of attributes.

    Parameters

    • attribute: BufferAttribute

      A buffer attribute of position data that the resulting box will envelop.

    • start: number

      The start attributes of range.

    • count: number

      The count of attributes in range.

    Returns Box3

  • Sets the upper and lower bounds of this box by a part of vertexes' index.

    Parameters

    • positionAttribute: BufferAttribute

      A buffer of vertex data.

    • indexAttribute: BufferAttribute

      A buffer of vertex' index.

    • start: number

      The start indexes of range.

    • count: number

      The count of indexes in range.

    Returns Box3

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

    Parameters

    Returns Box3

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

    Parameters

    • _center: Vector3
    • size: Vector3

      Desired x, y and z dimensions of the box.

    Returns Box3

  • Computes the world-axis-aligned bounding box of an Object3D (including its children), accounting for the object's, and children's, world transforms. The function may result in a larger box than strictly necessary.

    Parameters

    Returns Box3

  • Makes this box empty.

    Returns Box3

  • 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 boolean

  • Returns the center point of the box as a Vector3. this method returns the center whatever the values of box' min is over than max.

    Parameters

    • target: Vector3

      the result will be copied into this Vector3.

    Returns void

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

    Parameters

    • target: Vector3

      the result will be copied into this Vector3.

    Returns Vector3

  • Return the position of eight box's vertexes.

    Returns Vector3[]

  • Return an array of planes of eight box's surface.

    Returns Plane[]

  • 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.

    Parameters

    Returns Box3

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

    Parameters

    • scalar: number

      Distance to expand the box by.

    Returns Box3

  • Expands the boundaries of this box to include object and its children, accounting for the object's, and children's, world transforms. The function may result in a larger box than strictly necessary.

    Parameters

    Returns Box3

  • Parameters

    • triangle: Triangle

      Triangle| Triangle to check for intersection against. Determines whether or not this box intersects Triangle| triangle.

    Returns boolean

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

    Parameters

    Returns boolean

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

    Parameters

    Returns boolean

  • box Box to check for intersection against. Determines whether or not this box intersects box.

    Parameters

    Returns boolean

  • Determines whether or not this box intersects sphere.

    Parameters

    Returns boolean

  • Determines whether or not this box intersects plane.

    Parameters

    • plane: Plane

      Plane to check for intersection against.

    Returns boolean

  • If the point lies inside of this box, the distance will be 0.

    Parameters

    Returns number

    the distance from any edge of this box to the specified point.

  • Gets a Sphere that bounds the box.

    Parameters

    • target: Sphere

      the result will be copied into this Sphere.

    Returns Sphere

  • 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.

    Parameters

    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.

    Parameters

    • box: Box3

      Box that will be unioned with this box.

    Returns Box3

  • If NaN exists in three values of min and max, return true.

    Returns boolean

  • Check the given box is valid and let this box can contain it.

    Parameters

    Returns Box3

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

    Parameters

    • offset: Vector3

      Direction and distance of offset.

    Returns Box3

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

    Parameters

    • box: Box3

      Box to compare with this one.

    Returns boolean

  • Return the Bounding on plane XY.

    Parameters

    • box2: Box2

    Returns Box2