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

Box3.containsPoint()

The Box3.containsPoint(point) method is used to determine whether a given point is inside or outside the bounding box. This method is a part of the Three.js library, which is a 3D graphics library for creating WebGL-powered applications.

Syntax

box.containsPoint( point )

Parameters

point: An instance of the Vector3 class representing the point to be tested.

Return Value

A boolean value (true or false) representing whether the point is inside or outside of the bounding box.

Description

The Box3.containsPoint() method is used to test whether a given point lies within the bounding box defined by a Box3 object. The method takes a single parameter, which is an instance of the Vector3 class representing the point to be tested.

Example

const box = new THREE.Box3( new THREE.Vector3( -1, -1, -1 ), new THREE.Vector3( 1, 1, 1 ) );
const pointInside = new THREE.Vector3( 0, 0, 0 );
const pointOutside = new THREE.Vector3( 2, 2, 2 );

console.log( box.containsPoint( pointInside ) ); // true
console.log( box.containsPoint( pointOutside ) ); // false

In this example, we define a new Box3 object that represents a box extending from (-1,-1,-1) to (1,1,1). We then define two points, pointInside and pointOutside, and use the containsPoint() method to test whether each point is inside or outside of the bounding box. The method returns true for pointInside, since it lies within the bounding box, and false for pointOutside, since it lies outside of the bounding box.

Notes

  • The Box3.containsPoint() method only works with instances of the Vector3 class. If you have a point defined as an array of numbers, you can create a Vector3 object from it using the constructor of the Vector3 class, like so: new THREE.Vector3( x, y, z ).
  • This method only works with non-empty boxes. If you want to check whether a point is inside a box with no volume (i.e., one of the dimensions is 0), you will need to use a different method.
  • This method can be used in conjunction with other methods such as Box3.intersectsBox() and Box3.containsBox() to perform more complex geometric tests on bounding boxes.