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

简介

Box2.intersectsBox(box)是一个three.js中的Box2对象方法,用于判断当前Box2对象与另一个Box2对象是否相交。

语法

Box2.intersectsBox( box: Box2 ): Boolean
  • box - 另一个Box2对象。

返回值

  • 如果两个Box2对象相交,返回 true
  • 否则,返回 false

示例

const box1 = new THREE.Box2(new THREE.Vector2(0, 0), new THREE.Vector2(1, 1));
const box2 = new THREE.Box2(new THREE.Vector2(0.5,0.5), new THREE.Vector2(2, 2));

const result = box1.intersectsBox(box2);
console.log(result); // 输出 true

注意事项

  • 该方法只能判断两个Box2对象是否相交,不能判断其他类型的几何体是否相交。

参考文献