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

该方法用于获取一个视窗和透视相机的世界空间中的边框范围内的最小半径的球体。

语法

Box3.getBoundingSphere( sphere : Sphere ) : Sphere

参数

  • sphere: 一个Sphere类型的实例,用于输出计算结果。

返回值

  • Sphere: sphere输入参数,填充计算出的包围球。

描述

该方法通过获取Box3的尺寸和中心点,计算出一个最小外切圆,并将最终结果存储到给定的Sphere实例中。

用例

const box = new THREE.Box3(
  new THREE.Vector3(-1, -1, -1),
  new THREE.Vector3(1, 1, 1)
);

const sphere = new THREE.Sphere();
const radius = box.getBoundingSphere(sphere).radius;

源代码

getBoundingSphere: function ( sphere ) {

    const vector = new Vector3();
    this.getCenter( sphere.center );
    sphere.radius = this.getSize( vector ).length() * 0.5;

    return sphere;

},

参考链接