BufferGeometry
Object3D
Raycaster
Camera
CubeCamera
PerspectiveCamera
OrthographicCamera
StereoCamera
Clock
Curve
CurvePath
Path
Shape
ShapePath
ArrowHelper
AxesHelper
BoxHelper
Box3Helper
CameraHelper
DirectionalLightHelper
GridHelper
PolarGridHelper
HemisphereLightHelper
PlaneHelper
PointLightHelper
SkeletonHelper
SpotLightHelper
Light
PointLight
RectAreaLight
SpotLight
DirectionalLight
HemisphereLight
LightShadow
PointLightShadow
AnimationLoader
AudioLoader
BufferGeometryLoader
CompressedTextureLoader
CubeTextureLoader
DataTextureLoader
FileLoader
ImageBitmapLoader
ImageLoader
Loader
LoaderUtils
MaterialLoader
ObjectLoader
TextureLoader
LoadingManager
Material
Box2
Box3
Color
Cylindrical
Euler
Frustum
Interpolant
Line3
MathUtils
Matrix3
Matrix4
Plane
Quaternion
AnimationAction
AnimationClip
AnimationMixer
AnimationObjectGroup
AnimationUtils
keyframeTrack
PropertyBinding
PropertyMixer
BooleanKeyframeTrack
QuaternionKeyframeTrack
StringKeyframeTrack
Audio
AudioAnalyser
AudioContext
AudioListener
PositionalAudio

Box2.getSize()

The Box2.getSize() method returns a Vector2 representing the width and height of a box.

Syntax

box.getSize(out: Vector2): Vector2

Parameters

  • out (optional): a Vector2 to store the result in. If not provided, a new Vector2 will be created.

Return Value

  • Returns a Vector2 object representing the width and height of the box.

Examples

const box = new THREE.Box2(new THREE.Vector2(-1, -1), new THREE.Vector2(1, 1));

const size = box.getSize();
// size.x === 2, size.y === 2

const myVector = new THREE.Vector2();
box.getSize(myVector);
// myVector.x === 2, myVector.y === 2

In this example, we create a new Box2 object representing a square centered at the origin with side length 2. We then use the getSize() method to retrieve its dimensions.

Remarks

The Box2 object represents a 2D bounding box. The getSize() method computes the size of this box by subtracting the minimum position from the maximum position along each axis. The resulting Vector2 represents the width and height of the box.

See Also