The Box3.set()
method is used in the Three.js library to set the dimensions of a 3D bounding box. It is a member of the THREE.Box3
class, which represents an axis-aligned bounding box with minimum and maximum points.
.set( min: Vector3, max: Vector3 ) : this
min
: The minimum point of the bounding box, defined as a THREE.Vector3
object.max
: The maximum point of the bounding box, defined as a THREE.Vector3
object.The set()
method returns the modified Box3
object.
The set()
method is used to modify the minimum and maximum point coordinates of a Box3
object. This updates the dimensions of the bounding box and recalculates its center point and size.
If no parameters are provided to the set()
method, the min
and max
points of the bounding box will default to (Infinity, Infinity, Infinity)
and (-Infinity, -Infinity, -Infinity)
, respectively.
Creating a bounding box and updating its dimensions using Box3.set()
:
const boundingBox = new THREE.Box3();
const minPoint = new THREE.Vector3( -10, -10, -10 );
const maxPoint = new THREE.Vector3( 10, 10, 10 );
boundingBox.set( minPoint, maxPoint );
min
and max
vectors can be modified individually using the Box3.min
and Box3.max
properties.Box3
class provides several other methods for updating and querying bounding box dimensions, including Box3.expandByPoint()
, Box3.union()
, and Box3.intersectsBox()
.