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.clone()

The Box2.clone() method creates a new Box2 instance with the same dimensions and position as the original Box2 instance. The newly created box is an exact replica of the original one and can be modified independently.

Syntax

box2.clone()

Return Value

This method returns a new Box2 instance with the same dimensions and position as the original Box2 instance.

Examples

const originalBox = new THREE.Box2(new THREE.Vector2(-1, -1), new THREE.Vector2(1, 1));
const clonedBox = originalBox.clone();
clonedBox.expandByScalar(0.5);

console.log(originalBox.min); // Output: (-1, -1)
console.log(originalBox.max); // Output: (1, 1)

console.log(clonedBox.min); // Output: (-1.5, -1.5)
console.log(clonedBox.max); // Output: (1.5, 1.5)

In this example, we create an original Box2 instance with a minimum point of (-1, -1) and a maximum point of (1, 1). Then, we clone the box and expand the cloned box by 0.5 units in all directions. When we log the minimum and maximum points of the original and cloned boxes, we can see that the cloned box is an exact replica of the original one, except that it has been expanded.

See Also

  • Box2: The Box2 class represents a 2D axis-aligned bounding box.