123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302 |
- <!DOCTYPE html>
- <html lang="zh">
- <head>
- <meta charset="utf-8" />
- <base href="../../../" />
- <script src="page.js"></script>
- <link type="text/css" rel="stylesheet" href="page.css" />
- </head>
- <body>
- <h1>[name]</h1>
- <p class="desc">
- 表示三维空间中的一个轴对齐包围盒(axis-aligned bounding box,AABB)。
- </p>
- <h2>代码示例</h2>
- <code>
- const box = new THREE.Box3();
- const mesh = new THREE.Mesh(
- new THREE.SphereGeometry(),
- new THREE.MeshBasicMaterial()
- );
- // ensure the bounding box is computed for its geometry
- // this should be done only once (assuming static geometries)
- mesh.geometry.computeBoundingBox();
- // ...
- // in the animation loop, compute the current bounding box with the world matrix
- box.copy( mesh.geometry.boundingBox ).applyMatrix4( mesh.matrixWorld );
- </code>
- <h2>构造器(Constructor)</h2>
- <h3>[name]( [param:Vector3 min], [param:Vector3 max] )</h3>
- <p>
- [page:Vector3 min] - (参数可选) [page:Vector3] 表示包围盒的下边界。
- 默认值是( + Infinity, + Infinity, + Infinity )。<br>
- [page:Vector3 max] - (参数可选) [page:Vector3] 表示包围盒的上边界。
- 默认值是( - Infinity, - Infinity, - Infinity )。<br /><br />
- 创建一个以max和min为边界的包围盒。
- </p>
- <h2>属性(Properties)</h2>
- <h3>[property:Boolean isBox3]</h3>
- <p>
- Read-only flag to check if a given object is of type [name].
- </p>
- <h3>[property:Vector3 min]</h3>
- <p>
- [page:Vector3] 表示包围盒的下边界。<br />
- 默认值是( + Infinity, + Infinity, + Infinity )。
- </p>
- <h3>[property:Vector3 max]</h3>
- <p>
- [page:Vector3] 包围盒的(x, y, z)上边界。<br />
- 默认值是 ( - Infinity, - Infinity, - Infinity ).
- </p>
- <h2>方法(Methods)</h2>
- <h3>[method:this applyMatrix4]( [param:Matrix4 matrix] )</h3>
- <p>
- [page:Matrix4 matrix] - 要应用的 [page:Matrix4] <br /><br />
- 使用传入的矩阵变换Box3(包围盒8个顶点都会乘以这个变换矩阵)。
- </p>
- <h3>[method:Vector3 clampPoint]( [param:Vector3 point], [param:Vector3 target] )</h3>
- <p>
- [page:Vector3 point] - 需要做clamp 的坐标 [page:Vector3]。 <br>
- [page:Vector3 target] — 结果将会被拷贝到这个对象中<br /><br />
- 使这个点[page:Vector3 point] [link:https://en.wikipedia.org/wiki/Clamping_(graphics) Clamps](处于范围内) 处于包围盒边界范围内。<br />
- </p>
- <h3>[method:Box3 clone]()</h3>
- <p>返回一个与该包围盒子有相同下边界[page:.min min] 和上边界 [page:.max max]的新包围盒。</p>
- <h3>[method:Boolean containsBox]( [param:Box3 box] )</h3>
- <p>
- [page:Box3 box] - 需要检测是否在当前包围盒内的 [page:Box3 Box3]。<br /><br />
- 传入的 [page:Box3 box] 整体都被包含在该对象中则返回true。如果他们两个包围盒是一样的也返回true。
- </p>
- <h3>[method:Boolean containsPoint]( [param:Vector3 point] )</h3>
- <p>
- [page:Vector3 point] - 需要检测是否在当前包围盒内的 [page:Vector3]。<br /><br />
- 当传入的值 [page:Vector3 point] 在包围盒内部或者边界都会返回true。
- </p>
- <h3>[method:this copy]( [param:Box3 box] )</h3>
- <p>
- [page:Box3 box] - 需要复制的包围盒 [page:Box3] 。<br /><br />
- 将传入的值 [page:Box3 box] 中的 [page:.min min] 和 [page:.max max] 拷贝到当前对象。
- </p>
- <h3>[method:Float distanceToPoint]( [param:Vector3 point] )</h3>
- <p>
- [page:Vector3 point] - 用来测试距离的点 [page:Vector3]。<br /><br />
- 返回这个box的任何边缘到指定点的距离。如果这个点位于这个盒子里,距离将是0。
- </p>
- <h3>[method:Boolean equals]( [param:Box3 box] )</h3>
- <p>
- [page:Box3 box] - 将box与当前对象做比较。<br /><br />
- 返回true如果传入的值与当前的对象 [page:Box3 box] 有相同的上下边界。
- </p>
- <h3>[method:this expandByObject]( [param:Object3D object] )</h3>
- <p>
- [page:Object3D object] - 包裹在包围盒中的3d对象 [page:Object3D]。<br /><br />
- 扩展此包围盒的边界,使得对象及其子对象在包围盒内,包括对象和子对象的世界坐标的变换。
- 该方法可能会导致一个比严格需要的更大的框。
- </p>
- <h3>[method:this expandByPoint]( [param:Vector3 point] )</h3>
- <p>
- [page:Vector3 point] - 需要在包围盒中的点 [page:Vector3]。<br /><br />
- 扩展这个包围盒的边界使得该点([page:Vector3 point])在包围盒内。
- </p>
- <h3>[method:this expandByScalar]( [param:Float scalar] )</h3>
- <p>
- [page:Float scalar] - 扩展包围盒的比例。<br /><br />
- 按 [page:Float scalar] 的值展开盒子的每个维度。如果是负数,盒子的尺寸会缩小。
- </p>
- <h3>[method:this expandByVector]( [param:Vector3 vector] )</h3>
- <p>
- [page:Vector3 vector] - 扩展包围盒的数值 [page:Vector3] 。<br /><br />
- 按 [page:Vector3 vector] 每个纬度的值展开这个箱子。
- 这个盒子的宽度将由 [page:Vector3 vector] 的x分量在两个方向上展开。
- 这个盒子的高度将由 [page:Vector3 vector] 两个方向上的y分量展开。
- 这个盒子的深度将由 [page:Vector3 vector] z分量在两个方向上展开。
- </p>
- <h3>[method:Sphere getBoundingSphere]( [param:Sphere target] )</h3>
- <p>
- [page:Sphere target] — 如果指定了target ,结果将会被拷贝到target。<br /><br />
- 获取一个包围球 [page:Sphere]。
- </p>
- <h3>[method:Vector3 getCenter]( [param:Vector3 target] )</h3>
- <p>
- [page:Vector3 target] — 如果指定了target ,结果将会被拷贝到target。<br /><br />
- 返回包围盒的中心点 [page:Vector3]。
- </p>
- <h3>[method:Vector3 getParameter]( [param:Vector3 point], [param:Vector3 target] ) </h3>
- <p>
- [page:Vector3 point] - [page:Vector3].<br/>
- [page:Vector3 target] — 如果指定了target ,结果将会被拷贝到target。<br /><br />
- 返回一个点为这个盒子的宽度、高度和深度的比例。
- </p>
- <h3>[method:Vector3 getSize]( [param:Vector3 target] )</h3>
- <p>
- [page:Vector3 target] — 如果指定了target ,结果将会被拷贝到target。<br /><br />
- 返回包围盒的宽度,高度,和深度。
- </p>
- <h3>[method:this intersect]( [param:Box3 box] )</h3>
- <p>
- [page:Box3 box] - 与包围盒的交集<br /><br />
- 计算此包围盒和 [page:Box3 box] 的交集,将此框的上界设置为两个框的max的较小部分,
- 将此包围盒的下界设置为两个包围盒的min的较大部分。如果两个包围盒不相交,则清空此包围盒。
- </p>
- <h3>[method:Boolean intersectsBox]( [param:Box3 box] )</h3>
- <p>
- [page:Box3 box] - 用来检测是否相交的包围盒<br /><br />
- 确定当前包围盒是否与传入包围盒[page:Box3 box] 相交。
- </p>
- <h3>[method:Boolean intersectsPlane]( [param:Plane plane] )</h3>
- <p>
- [page:Plane plane] - 用来检测是否相交的 [page:Plane]。<br /><br />
- 确定当前包围盒是否与平面 [page:Plane plane] 相交。
- </p>
- <h3>[method:Boolean intersectsSphere]( [param:Sphere sphere] )</h3>
- <p>
- [page:Sphere sphere] - 用来检测是否相交的球体 [page:Sphere]。<br /><br />
- 确定当前包围盒是否与球体 [page:Sphere sphere] 相交。
- </p>
- <h3>[method:Boolean intersectsTriangle]( [param:Triangle triangle] )</h3>
- <p>
- [page:Triangle triangle] - 用来检测是否相交的三角形 [page:Triangle]。<br /><br />
- 确定当前包围盒是否与三角形 [page:Triangle triangle] 相交。
- </p>
- <h3>[method:Boolean isEmpty]()</h3>
- <p>
- 如果这个盒子包含0个顶点,则返回true。<br>
- 注意,下界和上界相等的方框仍然包含一个点,即两个边界共享的那个点。
- </p>
- <h3>[method:this makeEmpty]()</h3>
- <p>清空包围盒。</p>
- <h3>[method:this set]( [param:Vector3 min], [param:Vector3 max] )</h3>
- <p>
- [page:Vector3 min] - [page:Vector3] 表示下边界每个纬度(x,y,z)的值。<br />
- [page:Vector3 max] - [page:Vector3] 表示上边界每个纬度(x,y,z)的值。<br /><br />
- 设置包围盒上下边界每个纬度(x,y,z)的值。<br>
- 请注意,此方法仅复制给定对象的值。
- </p>
- <h3>[method:this setFromArray]( [param:Array array] )</h3>
- <p>
- array - 数组当中的所有的点都将被包围盒包裹。<br /><br />
- 设置包围盒的上下边界使得数组 *array* 中的所有点的点都被包含在内。
- </p>
- <h3>[method:this setFromBufferAttribute]( [param:BufferAttribute attribute] )</h3>
- <p>
- [page:BufferAttribute attribute] - 位置的缓冲数据,包含在返回的包围盒内。<br /><br />
- 设置此包围盒的上边界和下边界,以包含 [page:BufferAttribute attribute] 中的所有位置数据。
- </p>
- <h3>[method:this setFromCenterAndSize]( [param:Vector3 center], [param:Vector3 size] )</h3>
- <p>
- [page:Vector3 center], - 包围盒所要设置的中心位置。 <br>
- [page:Vector3 size] - 包围盒所要设置的x、y和z尺寸(宽/高/长)。<br /><br />
- 将当前包围盒的中心点设置为 [page:Vector3 center] ,并将此包围盒的宽度,高度和深度设置为大小指定 [page:Vector3 size] 的值。
- </p>
- <h3>[method:this setFromObject]( [param:Object3D object] )</h3>
- <p>
- [page:Object3D object] - 用来计算包围盒的3D对象 [page:Object3D]。<br /><br />
- 计算和世界轴对齐的一个对象 [page:Object3D] (含其子对象)的包围盒,计算对象和子对象的世界坐标变换。
- 该方法可能会导致一个比严格需要的更大的框。
- </p>
- <h3>[method:this setFromPoints]( [param:Array points] )</h3>
- <p>
- [page:Array points] - 计算出的包围盒将包含数组中所有的点 [page:Vector3 Vector3s]<br /><br />
- 设置此包围盒的上边界和下边界,以包含数组 [page:Array points] 中的所有点。
- </p>
- <h3>[method:this translate]( [param:Vector3 offset] )</h3>
- <p>
- [page:Vector3 offset] - 偏移方向和距离。<br /><br />
- 给包围盒的上下边界添加偏移量 [page:Vector3 offset],这样可以有效的在3D空间中移动包围盒。
- 偏移量为 [page:Vector3 offset] 大小。
- </p>
- <h3>[method:this union]( [param:Box3 box] )</h3>
- <p>
- [page:Box3 box] - 将被用于与该盒子计算并集的盒子。<br /><br />
- 在 [page:Box3 box] 参数的上边界和已有box对象的上边界之间取较大者,而对两者的下边界取较小者,这样获得一个新的较大的联合盒子。
- </p>
- <h2>源码(Source)</h2>
- <p>
- [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
- </p>
- </body>
- </html>
|