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

BufferGeometry.computeBoundingBox()

简介

BufferGeometry.computeBoundingBox() 是 Three.js 中 BufferGeometry 对象的一个方法,用于计算缓冲几何体(BufferGeometry)的边界框(bounding box)。

边界框是一个将物体包围在内部的最小矩形框,通常用于确定需要进行渲染的区域。计算边界框时,会考虑物体中所有顶点的位置、旋转、缩放等因素。

语法

BufferGeometry.computeBoundingBox();

返回值

该方法无返回值,但会将计算得到的边界框存储在 BufferGeometry.boundingBox 属性中。

示例

var geometry = new THREE.BoxBufferGeometry( 10, 20, 30 );
geometry.computeBoundingBox();
console.log( geometry.boundingBox );

执行上述代码后,会在控制台中输出如下信息:

Box3 {
    min: Vector3 { x: -5, y: -10, z: -15 },
    max: Vector3 { x: 5, y: 10, z: 15 }
}

注意事项

  • 如果没有调用 computeBoundingBox() 方法,BufferGeometry.boundingBox 属性的值为 undefined。

参考文献