Box3.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <base href="../../" />
  6. <script src="list.js"></script>
  7. <script src="page.js"></script>
  8. <link type="text/css" rel="stylesheet" href="page.css" />
  9. </head>
  10. <body>
  11. <h1>[name]</h1>
  12. <div class="desc">
  13. Represents a box or cube in 3D space. The main purpose of this is to represent
  14. the [link:https://en.wikipedia.org/wiki/Minimum_bounding_box Minimum Bounding Boxes]
  15. for objects.
  16. </div>
  17. <h2>Constructor</h2>
  18. <h3>[name]( [page:Vector3 min], [page:Vector3 max] )</h3>
  19. [page:Vector3 min] - (optional) [page:Vector3] representing the lower (x, y, z) boundary of the box.
  20. Default is ( + Infinity, + Infinity, + Infinity ).<br>
  21. [page:Vector3 max] - (optional) [page:Vector3] representing the lower upper (x, y, z) boundary of the box.
  22. Default is ( - Infinity, - Infinity, - Infinity ).<br /><br />
  23. Creates a [name] bounded by min and max.
  24. </div>
  25. <h2>Properties</h2>
  26. <h3>[property:Boolean isBox3]</h3>
  27. <div>
  28. Used to check whether this or derived classes are Box3s. Default is *true*.<br /><br />
  29. You should not change this, as it used internally for optimisation.
  30. </div>
  31. <h3>[property:Vector3 min]</h3>
  32. <div>
  33. [page:Vector3] representing the lower (x, y, z) boundary of the box.<br />
  34. Default is ( + Infinity, + Infinity, + Infinity ).
  35. </div>
  36. <h3>[property:Vector3 max]</h3>
  37. <div>
  38. [page:Vector3] representing the lower upper (x, y, z) boundary of the box.<br />
  39. Default is ( - Infinity, - Infinity, - Infinity ).
  40. </div>
  41. <h2>Methods</h2>
  42. <h3>[method:Box3 applyMatrix4]( [page:Matrix4 matrix] )</h3>
  43. <div>
  44. [page:Matrix4 matrix] - The [page:Matrix4] to apply<br /><br />
  45. Transforms this Box3 with the supplied matrix.
  46. </div>
  47. <h3>[method:Vector3 clampPoint]( [page:Vector3 point], [page:Vector3 optionalTarget] )</h3>
  48. <div>
  49. [page:Vector3 point] - [page:Vector3] to clamp. <br>
  50. [page:Vector3 optionalTarget] — (optional) if specified, the result will be copied into this Vector3,
  51. otherwise a new Vector3 will be created. <br /><br />
  52. [link:https://en.wikipedia.org/wiki/Clamping_(graphics) Clamps] the [page:Vector3 point] within the bounds of this box.<br />
  53. </div>
  54. <h3>[method:Box3 clone]()</h3>
  55. <div>Returns a new [page:Box3] with the same [page:.min min] and [page:.max max] as this one.</div>
  56. <h3>[method:Boolean containsBox]( [page:Box3 box] )</h3>
  57. <div>
  58. [page:Box3 box] - [page:Box3 Box3] to test for inclusion.<br /><br />
  59. Returns true if this box includes the entirety of [page:Box3 box]. If this and [page:Box3 box] are identical, <br>
  60. this function also returns true.
  61. </div>
  62. <h3>[method:Boolean containsPoint]( [page:Vector3 point] )</h3>
  63. <div>
  64. [page:Vector3 point] - [page:Vector3] to check for inclusion.<br /><br />
  65. Returns true if the specified [page:Vector3 point] lies within or on the boundaries of this box.
  66. </div>
  67. <h3>[method:Box3 copy]( [page:Box3 box] )</h3>
  68. <div>
  69. [page:Box3 box] - [page:Box3] to copy.<br /><br />
  70. Copies the [page:.min min] and [page:.max max] from [page:Box3 box] to this box.
  71. </div>
  72. <h3>[method:Float distanceToPoint]( [page:Vector3 point] )</h3>
  73. <div>
  74. [page:Vector3 point] - [page:Vector3] to measure distance to.<br /><br />
  75. Returns the distance from any edge of this box to the specified point.
  76. If the [page:Vector3 point] lies inside of this box, the distance will be 0.
  77. </div>
  78. <h3>[method:Boolean equals]( [page:Box3 box] )</h3>
  79. <div>
  80. [page:Box3 box] - Box to compare with this one.<br /><br />
  81. Returns true if this box and [page:Box3 box] share the same lower and upper bounds.
  82. </div>
  83. <h3>[method:Box3 expandByPoint]( [page:Vector3 point] )</h3>
  84. <div>
  85. [page:Vector3 point] - [page:Vector3] that should be included in the box.<br /><br />
  86. Expands the boundaries of this box to include [page:Vector3 point].
  87. </div>
  88. <h3>[method:Box3 expandByScalar]( [page:float scalar] )</h3>
  89. <div>
  90. [page:float scalar] - Distance to expand the box by.<br /><br />
  91. Expands each dimension of the box by [page:float scalar]. If negative, the dimensions of the box
  92. will be contracted.
  93. </div>
  94. <h3>[method:Box3 expandByVector]( [page:Vector3 vector] )</h3>
  95. <div>
  96. [page:Vector3 vector] - [page:Vector3] to expand the box by.<br /><br />
  97. Expands this box equilaterally by [page:Vector3 vector]. The width of this box will be
  98. expanded by the x component of [page:Vector3 vector] in both directions. The height of
  99. this box will be expanded by the y component of [page:Vector3 vector] in both directions.
  100. The depth of this box will be expanded by the z component of *vector* in both directions.
  101. </div>
  102. <h3>[method:Sphere getBoundingSphere]( [page:Sphere optionalTarget] )</h3>
  103. <div>
  104. [page:Sphere optionalTarget] — (optional) if specified, the result will be copied into this Sphere,
  105. otherwise a new Sphere will be created. <br /><br />
  106. Gets a [page:Sphere] that bounds the box.
  107. </div>
  108. <h3>[method:Vector3 getCenter]( [page:Vector3 optionalTarget] )</h3>
  109. <div>
  110. [page:Vector3 optionalTarget] — (optional) if specified, the result will be copied into this Vector3,
  111. otherwise a new Vector3 will be created. <br /><br />
  112. Returns the center point of the box as a [page:Vector3].
  113. </div>
  114. <h3>[method:Vector3 getParameter]( [page:Vector3 point], [page:Vector3 optionalTarget] ) </h3>
  115. <div>
  116. [page:Vector3 point] - [page:Vector3].<br/>
  117. [page:Vector3 optionalTarget] — (optional) if specified, the result will be copied into this Vector3,
  118. otherwise a new Vector3 will be created. <br /><br />
  119. Returns a point as a proportion of this box's width and height.
  120. </div>
  121. <h3>[method:Vector3 getSize]( [page:Vector3 optionalTarget] )</h3>
  122. <div>
  123. [page:Vector3 optionalTarget] — (optional) if specified, the result will be copied into this Vector3,
  124. otherwise a new Vector3 will be created. <br /><br />
  125. Returns the width and height of this box.
  126. </div>
  127. <h3>[method:Box3 intersect]( [page:Box3 box] )</h3>
  128. <div>
  129. [page:Box3 box] - Box to intersect with.<br /><br />
  130. Returns the intersection of this and [page:Box3 box], setting the upper bound of this box to the lesser
  131. of the two boxes' upper bounds and the lower bound of this box to the greater of the two boxes'
  132. lower bounds.
  133. </div>
  134. <h3>[method:Boolean intersectsBox]( [page:Box3 box] )</h3>
  135. <div>
  136. [page:Box3 box] - Box to check for intersection against.<br /><br />
  137. Determines whether or not this box intersects [page:Box3 box].
  138. </div>
  139. <h3>[method:Boolean intersectsPlane]( [page:Plane plane] )</h3>
  140. <div>
  141. [page:Plane plane] - [page:Plane] to check for intersection against.<br /><br />
  142. Determines whether or not this box intersects [page:Plane plane].
  143. </div>
  144. <h3>[method:Boolean intersectsSphere]( [page:Sphere sphere] )</h3>
  145. <div>
  146. [page:Sphere sphere] - [page:Sphere] to check for intersection against.<br /><br />
  147. Determines whether or not this box intersects [page:Sphere sphere].
  148. </div>
  149. <h3>[method:Boolean isEmpty]()</h3>
  150. <div>
  151. Returns true if this box includes zero points within its bounds.<br>
  152. Note that a box with equal lower and upper bounds still includes one point,
  153. the one both bounds share.
  154. </div>
  155. <h3>[method:Box3 makeEmpty]()</h3>
  156. <div>Makes this box empty.</div>
  157. <h3>[method:Box3 set]( [page:Vector3 min], [page:Vector3 max] )</h3>
  158. <div>
  159. [page:Vector3 min] - [page:Vector3] representing the lower (x, y, z) boundary of the box.<br />
  160. [page:Vector3 max] - [page:Vector3] representing the lower upper (x, y, z) boundary of the box.<br /><br />
  161. Sets the lower and upper (x, y, z) boundaries of this box.
  162. </div>
  163. <h3>[method:Box3 setFromArray]( [page:Array array] ) [page:Box3 this]</h3>
  164. <div>
  165. array -- An array of position data that the resulting box will envelop.<br /><br />
  166. Sets the upper and lower bounds of this box to include all of the data in *array*.
  167. </div>
  168. <h3>[method:Box3 setFromBufferAttribute]( [page:BufferAttribute attribute] ) [page:Box3 this]</h3>
  169. <div>
  170. [page:BufferAttribute attribute] - A buffer attribute of position data that the resulting box will envelop.<br /><br />
  171. Sets the upper and lower bounds of this box to include all of the data in [page:BufferAttribute attribute].
  172. </div>
  173. <h3>[method:Box3 setFromCenterAndSize]( [page:Vector3 center], [page:Vector3 size] )</h3>
  174. <div>
  175. [page:Vector3 center] - Desired center position of the box ([page:Vector3]). <br>
  176. [page:Vector3 size] - Desired x and y dimensions of the box ([page:Vector3]).<br /><br />
  177. Centers this box on [page:Vector3 center] and sets this box's width and height to the values specified
  178. in [page:Vector3 size].
  179. </div>
  180. <h3>[method:Box3 setFromCenterAndSize]( [page:Vector3 center], [page:Vector3 size] ) [page:Box3 this]</h3>
  181. <div>
  182. [page:Vector3 center], - Desired center position of the box. <br>
  183. [page:Vector3 size] - Desired x, y and z dimensions of the box.<br /><br />
  184. Centers this box on [page:Vector3 center] and sets this box's width, height and depth to the values specified <br>
  185. in [page:Vector3 size]
  186. </div>
  187. <h3>[method:Box3 setFromObject]( [page:Object3D object] )</h3>
  188. <div>
  189. [page:Object3D object] - [page:Object3D] to compute the bounding box of.<br /><br />
  190. Computes the world-axis-aligned bounding box of an [page:Object3D] (including its children),
  191. accounting for the world transforms of both the object and its childrens.
  192. </div>
  193. <h3>[method:Box3 setFromPoints]( [page:Array points] )</h3>
  194. <div>
  195. [page:Array points] - Array of [page:Vector3 Vector3s] that the resulting box will contain.<br /><br />
  196. Sets the upper and lower bounds of this box to include all of the points in [page:Array points].
  197. </div>
  198. <h3>[method:Box3 translate]( [page:Vector3 offset] )</h3>
  199. <div>
  200. [page:Vector3 offset] - Direction and distance of offset.<br /><br />
  201. Adds [page:Vector3 offset] to both the upper and lower bounds of this box, effectively moving this box
  202. [page:Vector3 offset] units in 2D space.
  203. </div>
  204. <h3>[method:Box3 union]( [page:Box3 box] )</h3>
  205. <div>
  206. [page:Box3 box] - Box that will be unioned with this box.<br /><br />
  207. Unions this box with [page:Box3 box], setting the upper bound of this box to the greater of the
  208. two boxes' upper bounds and the lower bound of this box to the lesser of the two boxes'
  209. lower bounds.
  210. </div>
  211. <h2>Source</h2>
  212. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  213. </body>
  214. </html>