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场景编辑器

Box2

表示二维空间中的一个包围盒。

构造函数(Constructor)

Box2( min : Vector2, max : Vector2 )

min - (可选) Vector2 表示该盒子的下边界(x, y)。默认值为( + Infinity, + Infinity )。
max - (可选) Vector2 表示该盒子的上边界(x, y)。默认值为( - Infinity, - Infinity )。

创建一个介于最小和最大值之间的Box2。

属性(Properties)

# .min : Vector2

Vector2 表示该盒子的下边界(x, y)。
默认值为( + Infinity, + Infinity )。

# .max : Vector2

Vector2 表示该盒子的上边界(x, y)。
默认值为( - Infinity, - Infinity )。

方法(Methods)

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

point - clamp 的位置 (Vector2)
target — 结果会被复制到该二维向量中。

在该盒子范围内夹紧(Clamps))point。

# .clone () : Box2

返回一个新的Box2,其min和max与此盒子相同。

# .containsBox ( box : Box2 ) : Boolean

box - 要检查是否被包含的盒子。

如果盒子包含整个被检查盒子,则返回true。如果两者重叠,
也会返回true。

# .containsPoint ( point : Vector2 ) : Boolean

point - 要检查是否被包含的点Vector2。

如果指定的点(point)位于盒子的边界内或边界上,则返回true。

# .copy ( box : Box2 ) : Box2

将box的min 和 max复制到此盒子中。

# .distanceToPoint ( point : Vector2 ) : Float

point - 要测量距离的点(Vector2)。

返回这个盒子的任何边缘到指定点的距离。如果这个点(point)位于这个盒子里,距离将是0。

# .equals ( box : Box2 ) : Boolean

box - 要对比的盒子

如果这个盒子和被对比盒子具有相同的上下边界,则返回true。

# .expandByPoint ( point : Vector2 ) : Box2

point - 应该被盒子包含的点。

扩展盒子的边界来包含该点。

# .expandByScalar ( scalar : float ) : Box2

scalar - 盒子扩展的距离。

在每个维度上扩展参数scalar所指定的距离,如果为负数,则盒子空间将收缩。

# .expandByVector ( vector : Vector2 ) : Box2

vector - 按照该向量扩展。

在每个维度中按vector的数值进行扩展。宽度在两个方向上的扩展将由vector的x分量确定, 高度在两个方向上的扩展则由y分量确定。

# .getCenter ( target : Vector2 ) : Vector2

target — 结果将被复制到此二维向量中。

以二维向量形式返回盒子的中心点。

# .getParameter ( point : Vector2, target : Vector2 ) : Vector2

point - 二维向量(Vector2).
target — 结果将被复制到此二维向量中。

返回一个点作为此盒子的宽度和高度的比例。

# .getSize ( target : Vector2 ) : Vector2

target — 结果将被复制到此二维向量中。

返回此盒子的宽度和高度。

# .intersect ( box : Box2 ) : Box2

box - 要相交的盒子。

返回两者的相交后的盒子,并将相交后的盒子的上限设置为两者的上限中的较小者,将下限设置为两者的下限中的较大者。

# .intersectsBox ( box : Box2 ) : Boolean

box - 用来检查相交的盒子。

确定该盒子是否和其相交。

# .isEmpty () : Boolean

如果这个盒子包含0个顶点,则返回true。
请注意,一个下上边界相等的的盒子仍然包括一个点,一个两个边界共享的点。

# .makeEmpty () : Box2

使此盒子为空。

# .set ( min : Vector2, max : Vector2 ) : Box2

min - (必须 ) 表示该盒子的下边界(x, y)。
max - (必须) 表示该盒子的上边界(x, y)。

设置这个盒子的上下(x, y)的界限。

# .setFromCenterAndSize ( center : Vector2, size : Vector2 ) : Box2

center - 盒子所要设置的中心位置。 (Vector2).
size - 盒子所要设置的x和y尺寸 (Vector2).

使盒子的中心点位于center,并设置宽高为size中指定的值。

# .setFromPoints ( points : Array ) : Box2

points - 点的集合,由这些点确定的空间将被盒子包围。

设置这个盒子的上下边界,来包含所有设置在points参数中的点。

# .translate ( offset : Vector2 ) : Box2

offset - 偏移方向和距离。

添加 offset 到这个盒子的上下边界,实际上在2D空间移动这个盒子offset个单位。

# .union ( box : Box2 ) : Box2

box - 将要与该盒子联合的盒子

在box参数的上边界和该盒子的上边界之间取较大者,而对两者的下边界取较小者,这样获得一个新的较大的联合盒子。

源码(Source)

src/math/Box2.js