Theme:

Box3

An axis-aligned bounding box (AABB) in 3D space defined by min and max vectors.

Constructor

const box = new Box3(min?, max?)
// defaults: min=(+Inf,+Inf,+Inf), max=(-Inf,-Inf,-Inf) (empty)

Properties

  • min, max — Vector3 bounds
  • isBox3 — Type flag (true)

Methods

Setting

  • set(min, max) — Set bounds
  • setFromArray(array) — From flat position array
  • setFromBufferAttribute(attribute) — From position buffer attribute
  • setFromPoints(points) — From array of Vector3
  • setFromCenterAndSize(center, size) — From center + dimensions
  • setFromObject(object, precise?) — From Object3D hierarchy
  • copy(box), makeEmpty()

Queries

  • isEmpty() — True if box encloses zero volume
  • getCenter(target) — Center point
  • getSize(target) — Dimensions
  • getParameter(point, target) — Point as proportion of box size
  • getBoundingSphere(target) — Enclosing sphere

Testing

  • containsPoint(point), containsBox(box)
  • intersectsBox(box), intersectsSphere(sphere), intersectsPlane(plane), intersectsTriangle(triangle)

Operations

  • expandByPoint(point), expandByVector(vector), expandByScalar(scalar), expandByObject(object, precise?)
  • intersect(box) — Intersect with another box
  • union(box) — Union with another box
  • clampPoint(point, target) — Clamp point to box bounds
  • distanceToPoint(point) — Distance from box edge to point
  • applyMatrix4(matrix) — Transform box
  • translate(offset) — Translate box

Other

  • equals(box), clone()
  • toJSON(), fromJSON(json)