Three.js API手册

动画
AnimationAction AnimationClip AnimationMixer AnimationObjectGroup AnimationUtils KeyframeTrack PropertyBinding PropertyMixer
动画 / 轨道
BooleanKeyframeTrack ColorKeyframeTrack NumberKeyframeTrack QuaternionKeyframeTrack StringKeyframeTrack VectorKeyframeTrack
音频
Audio AudioAnalyser AudioContext AudioListener PositionalAudio
摄像机
ArrayCamera Camera CubeCamera OrthographicCamera PerspectiveCamera StereoCamera
常量
Animation Core CustomBlendingEquation DrawModes Materials Renderer Textures
核心
BufferAttribute BufferGeometry Clock DirectGeometry EventDispatcher Face3 Geometry InstancedBufferAttribute InstancedBufferGeometry InstancedInterleavedBuffer InterleavedBuffer InterleavedBufferAttribute Layers Object3D Raycaster Uniform
核心 / BufferAttributes
BufferAttribute_Types
弃用列表
DeprecatedList
附件
Earcut ShapeUtils
附件 / 核心
Curve CurvePath Font Interpolations Path Shape ShapePath
附件 / 曲线
ArcCurve CatmullRomCurve3 CubicBezierCurve CubicBezierCurve3 EllipseCurve LineCurve LineCurve3 QuadraticBezierCurve QuadraticBezierCurve3 SplineCurve
附件 / 物体
ImmediateRenderObject
几何体
BoxBufferGeometry BoxGeometry CircleBufferGeometry CircleGeometry ConeBufferGeometry ConeGeometry CylinderBufferGeometry CylinderGeometry DodecahedronBufferGeometry DodecahedronGeometry EdgesGeometry ExtrudeBufferGeometry ExtrudeGeometry IcosahedronBufferGeometry IcosahedronGeometry LatheBufferGeometry LatheGeometry OctahedronBufferGeometry OctahedronGeometry ParametricBufferGeometry ParametricGeometry PlaneBufferGeometry PlaneGeometry PolyhedronBufferGeometry PolyhedronGeometry RingBufferGeometry RingGeometry ShapeBufferGeometry ShapeGeometry SphereBufferGeometry SphereGeometry TetrahedronBufferGeometry TetrahedronGeometry TextBufferGeometry TextGeometry TorusBufferGeometry TorusGeometry TorusKnotBufferGeometry TorusKnotGeometry TubeBufferGeometry TubeGeometry WireframeGeometry
辅助对象
ArrowHelper AxesHelper BoxHelper Box3Helper CameraHelper DirectionalLightHelper FaceNormalsHelper GridHelper PolarGridHelper PositionalAudioHelper HemisphereLightHelper PlaneHelper PointLightHelper RectAreaLightHelper SkeletonHelper SpotLightHelper VertexNormalsHelper
灯光
AmbientLight DirectionalLight HemisphereLight Light PointLight RectAreaLight SpotLight
灯光 / 阴影
DirectionalLightShadow LightShadow SpotLightShadow
加载器
AnimationLoader AudioLoader BufferGeometryLoader Cache CompressedTextureLoader CubeTextureLoader DataTextureLoader FileLoader FontLoader ImageBitmapLoader ImageLoader Loader LoaderUtils MaterialLoader ObjectLoader TextureLoader
加载器 / 管理器
DefaultLoadingManager LoadingManager
材质
LineBasicMaterial LineDashedMaterial Material MeshBasicMaterial MeshDepthMaterial MeshDistanceMaterial MeshLambertMaterial MeshMatcapMaterial MeshNormalMaterial MeshPhongMaterial MeshPhysicalMaterial MeshStandardMaterial MeshToonMaterial PointsMaterial RawShaderMaterial ShaderMaterial ShadowMaterial SpriteMaterial
数学库
Box2 Box3 Color Cylindrical Euler Frustum Interpolant Line3 Math Matrix3 Matrix4 Plane Quaternion Ray Sphere Spherical Triangle Vector2 Vector3 Vector4
数学库 / 插值
CubicInterpolant DiscreteInterpolant LinearInterpolant QuaternionLinearInterpolant
物体
Bone Group Line LineLoop LineSegments LOD Mesh Points Skeleton SkinnedMesh Sprite
渲染器
WebGLMultisampleRenderTarget WebGLRenderer WebGLRenderTarget WebGLRenderTargetCube
渲染器 / 着色器
ShaderChunk ShaderLib UniformsLib UniformsUtils
场景
Fog FogExp2 Scene
纹理贴图
CanvasTexture CompressedTexture CubeTexture DataTexture DataTexture3D DepthTexture Texture VideoTexture
在线工具推荐: Three.js AI纹理开发包 - YOLO合成数据生成器 - GLTF/GLB在线编辑 - 3D模型格式在线转换 - 可编程3D场景编辑器

球(Sphere)

一个球由球心和半径所定义。

构造函数

Sphere( center : Vector3, radius : Float )

center - 球心的位置,默认值是一个位于(0, 0, 0)的Vector3。
radius - 球的半径,默认值是0。

创建一个新的Sphere。

属性

# .center : Vector3

A Vector3定义了球心的位置,默认值位于(0, 0, 0)。

# .radius : Float

球的半径,默认值为0。

方法

# .applyMatrix4 ( matrix : Matrix4 ) : Sphere

matrix - 将被应用的Matrix4矩阵。

使用所传入的Matrix4矩阵来对球进行变换。

# .clampPoint ( point : Vector3, target : Vector3 ) : Vector3

point - Vector3 将要夹取的点。
target — 结果将被复制到这个Vector3中。

从球中夹取一个点。若这一点位于球外,则将会夹取到该点球边缘最近的点。已位于球中的点将不会受到影响。

# .clone () : Sphere

返回一个新的球,新的球与这个球具有相同的center和radius。

# .containsPoint ( point : Vector3 ) : Boolean

point - the Vector3 to be checked

检查球体中是否包含所传入的point点,包括球的表面。

# .copy ( sphere : Sphere ) : Sphere

复制所传入的球的center和radius到这个球上。

# .distanceToPoint ( point : Vector3 ) : Float

返回球的边界到所传入的point点的最近距离。 若这个点,则距离将为负值。

# .empty () : Boolean

检查球是否为空(其半径设为了0).

# .equals ( sphere : Sphere ) : Boolean

检查这两个球的球心与半径是否相等。

# .getBoundingBox ( target : Box3 ) : Box3

target — 结果将被复制到这个Box3中。

返回这个球的Minimum Bounding Box(最小包围盒)。

# .intersectsBox ( box : Box3 ) : Boolean

box - 将被用于测试是否与这个球有交集的Box3。

检测这个球与所传入的box是否有交集。

# .intersectsPlane ( plane : Plane ) : Boolean

plane - 将被用于测试是否与这个球有交集的Plane。

检测这个球与所传入的plane是否有交集。

# .intersectsSphere ( sphere : Sphere ) : Boolean

sphere - 将被用于测试是否与这个球有交集的Sphere。

检测两球之间是否有交集。

# .set ( center : Vector3, radius : Float ) : Sphere

center - 球心位置。
radius - 球的半径。

设置球的center和radius属性。

# .setFromPoints ( points : Array, optionalCenter : Vector3 ) : Sphere

points - 一个包含有Vector3位置的Array。
optionalCenter - 可选, Vector3 球心位置。

计算一个points数组(中的点)的最小边界球。如果给定了optionalCenter,则它将被用作该球的球心; 否则,环绕points的包围盒的轴心将通过计算来得到。

# .translate ( offset : Vector3 ) : Sphere

使用所给定Vector3 offset(偏移量)平移球心。

源代码

src/math/Sphere.js