Box3.html 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Box3 - Three.js Docs</title>
  6. <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
  7. <script src="../scripts/highlight.min.js"></script>
  8. <link type="text/css" rel="stylesheet" href="../styles/highlight-three.css">
  9. <link type="text/css" rel="stylesheet" href="../styles/page.css">
  10. </head>
  11. <body>
  12. <h1 translate="no">Box3</h1>
  13. <section>
  14. <header>
  15. <div class="class-description"><p>Represents an axis-aligned bounding box (AABB) in 3D space.</p></div>
  16. </header>
  17. <article>
  18. <div class="container-overview">
  19. <h2>Constructor</h2>
  20. <h3 class="name name-method" id="Box3" translate="no">new <a href="#Box3">Box3</a><span class="signature">( min : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, max : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span> </h3>
  21. <div class="method">
  22. <div class="description">
  23. <p>Constructs a new bounding box.</p>
  24. </div>
  25. <table class="params">
  26. <tbody>
  27. <tr>
  28. <td class="name">
  29. <strong>min</strong>
  30. </td>
  31. <td class="description last">
  32. <p>A vector representing the lower boundary of the box.</p>
  33. <p>Default is <code>(Infinity,Infinity,Infinity)</code>.</p>
  34. </td>
  35. </tr>
  36. <tr>
  37. <td class="name">
  38. <strong>max</strong>
  39. </td>
  40. <td class="description last">
  41. <p>A vector representing the upper boundary of the box.</p>
  42. <p>Default is <code>(-Infinity,-Infinity,-Infinity)</code>.</p>
  43. </td>
  44. </tr>
  45. </tbody>
  46. </table>
  47. </div>
  48. </div>
  49. <h2 class="subsection-title">Properties</h2>
  50. <div class="member">
  51. <h3 class="name" id="isBox3" translate="no">.<a href="#isBox3">isBox3</a><span class="type-signature"> : boolean</span> <span class="type-signature">(readonly) </span></h3>
  52. <div class="description">
  53. <p>This flag can be used for type testing.</p>
  54. <p>Default is <code>true</code>.</p>
  55. </div>
  56. </div>
  57. <div class="member">
  58. <h3 class="name" id="max" translate="no">.<a href="#max">max</a><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  59. <div class="description">
  60. <p>The upper boundary of the box.</p>
  61. </div>
  62. </div>
  63. <div class="member">
  64. <h3 class="name" id="min" translate="no">.<a href="#min">min</a><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  65. <div class="description">
  66. <p>The lower boundary of the box.</p>
  67. </div>
  68. </div>
  69. <h2 class="subsection-title">Methods</h2>
  70. <h3 class="name name-method" id="applyMatrix4" translate="no">.<a href="#applyMatrix4">applyMatrix4</a><span class="signature">( matrix : <span class="param-type"><a href="Matrix4.html">Matrix4</a></span> )</span><span class="type-signature"> : <a href="Box3.html">Box3</a></span> </h3>
  71. <div class="method">
  72. <div class="description">
  73. <p>Transforms this bounding box by the given 4x4 transformation matrix.</p>
  74. </div>
  75. <table class="params">
  76. <tbody>
  77. <tr>
  78. <td class="name">
  79. <strong>matrix</strong>
  80. </td>
  81. <td class="description last">
  82. <p>The transformation matrix.</p>
  83. </td>
  84. </tr>
  85. </tbody>
  86. </table>
  87. <dl class="details">
  88. <dt class="tag-returns"><strong>Returns:</strong> A reference to this bounding box.</dt>
  89. </dl>
  90. </div>
  91. <h3 class="name name-method" id="clampPoint" translate="no">.<a href="#clampPoint">clampPoint</a><span class="signature">( point : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, target : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  92. <div class="method">
  93. <div class="description">
  94. <p>Clamps the given point within the bounds of this box.</p>
  95. </div>
  96. <table class="params">
  97. <tbody>
  98. <tr>
  99. <td class="name">
  100. <strong>point</strong>
  101. </td>
  102. <td class="description last">
  103. <p>The point to clamp.</p>
  104. </td>
  105. </tr>
  106. <tr>
  107. <td class="name">
  108. <strong>target</strong>
  109. </td>
  110. <td class="description last">
  111. <p>The target vector that is used to store the method's result.</p>
  112. </td>
  113. </tr>
  114. </tbody>
  115. </table>
  116. <dl class="details">
  117. <dt class="tag-returns"><strong>Returns:</strong> The clamped point.</dt>
  118. </dl>
  119. </div>
  120. <h3 class="name name-method" id="clone" translate="no">.<a href="#clone">clone</a><span class="signature">()</span><span class="type-signature"> : <a href="Box3.html">Box3</a></span> </h3>
  121. <div class="method">
  122. <div class="description">
  123. <p>Returns a new box with copied values from this instance.</p>
  124. </div>
  125. <dl class="details">
  126. <dt class="tag-returns"><strong>Returns:</strong> A clone of this instance.</dt>
  127. </dl>
  128. </div>
  129. <h3 class="name name-method" id="containsBox" translate="no">.<a href="#containsBox">containsBox</a><span class="signature">( box : <span class="param-type"><a href="Box3.html">Box3</a></span> )</span><span class="type-signature"> : boolean</span> </h3>
  130. <div class="method">
  131. <div class="description">
  132. <p>Returns <code>true</code> if this bounding box includes the entirety of the given bounding box.
  133. If this box and the given one are identical, this function also returns <code>true</code>.</p>
  134. </div>
  135. <table class="params">
  136. <tbody>
  137. <tr>
  138. <td class="name">
  139. <strong>box</strong>
  140. </td>
  141. <td class="description last">
  142. <p>The bounding box to test.</p>
  143. </td>
  144. </tr>
  145. </tbody>
  146. </table>
  147. <dl class="details">
  148. <dt class="tag-returns"><strong>Returns:</strong> Whether the bounding box contains the given bounding box or not.</dt>
  149. </dl>
  150. </div>
  151. <h3 class="name name-method" id="containsPoint" translate="no">.<a href="#containsPoint">containsPoint</a><span class="signature">( point : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : boolean</span> </h3>
  152. <div class="method">
  153. <div class="description">
  154. <p>Returns <code>true</code> if the given point lies within or on the boundaries of this box.</p>
  155. </div>
  156. <table class="params">
  157. <tbody>
  158. <tr>
  159. <td class="name">
  160. <strong>point</strong>
  161. </td>
  162. <td class="description last">
  163. <p>The point to test.</p>
  164. </td>
  165. </tr>
  166. </tbody>
  167. </table>
  168. <dl class="details">
  169. <dt class="tag-returns"><strong>Returns:</strong> Whether the bounding box contains the given point or not.</dt>
  170. </dl>
  171. </div>
  172. <h3 class="name name-method" id="copy" translate="no">.<a href="#copy">copy</a><span class="signature">( box : <span class="param-type"><a href="Box3.html">Box3</a></span> )</span><span class="type-signature"> : <a href="Box3.html">Box3</a></span> </h3>
  173. <div class="method">
  174. <div class="description">
  175. <p>Copies the values of the given box to this instance.</p>
  176. </div>
  177. <table class="params">
  178. <tbody>
  179. <tr>
  180. <td class="name">
  181. <strong>box</strong>
  182. </td>
  183. <td class="description last">
  184. <p>The box to copy.</p>
  185. </td>
  186. </tr>
  187. </tbody>
  188. </table>
  189. <dl class="details">
  190. <dt class="tag-returns"><strong>Returns:</strong> A reference to this bounding box.</dt>
  191. </dl>
  192. </div>
  193. <h3 class="name name-method" id="distanceToPoint" translate="no">.<a href="#distanceToPoint">distanceToPoint</a><span class="signature">( point : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : number</span> </h3>
  194. <div class="method">
  195. <div class="description">
  196. <p>Returns the euclidean distance from any edge of this box to the specified point. If
  197. the given point lies inside of this box, the distance will be <code>0</code>.</p>
  198. </div>
  199. <table class="params">
  200. <tbody>
  201. <tr>
  202. <td class="name">
  203. <strong>point</strong>
  204. </td>
  205. <td class="description last">
  206. <p>The point to compute the distance to.</p>
  207. </td>
  208. </tr>
  209. </tbody>
  210. </table>
  211. <dl class="details">
  212. <dt class="tag-returns"><strong>Returns:</strong> The euclidean distance.</dt>
  213. </dl>
  214. </div>
  215. <h3 class="name name-method" id="equals" translate="no">.<a href="#equals">equals</a><span class="signature">( box : <span class="param-type"><a href="Box3.html">Box3</a></span> )</span><span class="type-signature"> : boolean</span> </h3>
  216. <div class="method">
  217. <div class="description">
  218. <p>Returns <code>true</code> if this bounding box is equal with the given one.</p>
  219. </div>
  220. <table class="params">
  221. <tbody>
  222. <tr>
  223. <td class="name">
  224. <strong>box</strong>
  225. </td>
  226. <td class="description last">
  227. <p>The box to test for equality.</p>
  228. </td>
  229. </tr>
  230. </tbody>
  231. </table>
  232. <dl class="details">
  233. <dt class="tag-returns"><strong>Returns:</strong> Whether this bounding box is equal with the given one.</dt>
  234. </dl>
  235. </div>
  236. <h3 class="name name-method" id="expandByObject" translate="no">.<a href="#expandByObject">expandByObject</a><span class="signature">( object : <span class="param-type"><a href="Object3D.html">Object3D</a></span>, precise : <span class="param-type">boolean</span> )</span><span class="type-signature"> : <a href="Box3.html">Box3</a></span> </h3>
  237. <div class="method">
  238. <div class="description">
  239. <p>Expands the boundaries of this box to include the given 3D object and
  240. its children, accounting for the object's, and children's, world
  241. transforms. The function may result in a larger box than strictly
  242. necessary (unless the precise parameter is set to true).</p>
  243. </div>
  244. <table class="params">
  245. <tbody>
  246. <tr>
  247. <td class="name">
  248. <strong>object</strong>
  249. </td>
  250. <td class="description last">
  251. <p>The 3D object that should expand the bounding box.</p>
  252. </td>
  253. </tr>
  254. <tr>
  255. <td class="name">
  256. <strong>precise</strong>
  257. </td>
  258. <td class="description last">
  259. <p>If set to <code>true</code>, the method expands the bounding box
  260. as little as necessary at the expense of more computation.</p>
  261. <p>Default is <code>false</code>.</p>
  262. </td>
  263. </tr>
  264. </tbody>
  265. </table>
  266. <dl class="details">
  267. <dt class="tag-returns"><strong>Returns:</strong> A reference to this bounding box.</dt>
  268. </dl>
  269. </div>
  270. <h3 class="name name-method" id="expandByPoint" translate="no">.<a href="#expandByPoint">expandByPoint</a><span class="signature">( point : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Box3.html">Box3</a></span> </h3>
  271. <div class="method">
  272. <div class="description">
  273. <p>Expands the boundaries of this box to include the given point.</p>
  274. </div>
  275. <table class="params">
  276. <tbody>
  277. <tr>
  278. <td class="name">
  279. <strong>point</strong>
  280. </td>
  281. <td class="description last">
  282. <p>The point that should be included by the bounding box.</p>
  283. </td>
  284. </tr>
  285. </tbody>
  286. </table>
  287. <dl class="details">
  288. <dt class="tag-returns"><strong>Returns:</strong> A reference to this bounding box.</dt>
  289. </dl>
  290. </div>
  291. <h3 class="name name-method" id="expandByScalar" translate="no">.<a href="#expandByScalar">expandByScalar</a><span class="signature">( scalar : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Box3.html">Box3</a></span> </h3>
  292. <div class="method">
  293. <div class="description">
  294. <p>Expands each dimension of the box by the given scalar. If negative, the
  295. dimensions of the box will be contracted.</p>
  296. </div>
  297. <table class="params">
  298. <tbody>
  299. <tr>
  300. <td class="name">
  301. <strong>scalar</strong>
  302. </td>
  303. <td class="description last">
  304. <p>The scalar value that should expand the bounding box.</p>
  305. </td>
  306. </tr>
  307. </tbody>
  308. </table>
  309. <dl class="details">
  310. <dt class="tag-returns"><strong>Returns:</strong> A reference to this bounding box.</dt>
  311. </dl>
  312. </div>
  313. <h3 class="name name-method" id="expandByVector" translate="no">.<a href="#expandByVector">expandByVector</a><span class="signature">( vector : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Box3.html">Box3</a></span> </h3>
  314. <div class="method">
  315. <div class="description">
  316. <p>Expands this box equilaterally by the given vector. The width of this
  317. box will be expanded by the x component of the vector in both
  318. directions. The height of this box will be expanded by the y component of
  319. the vector in both directions. The depth of this box will be
  320. expanded by the z component of the vector in both directions.</p>
  321. </div>
  322. <table class="params">
  323. <tbody>
  324. <tr>
  325. <td class="name">
  326. <strong>vector</strong>
  327. </td>
  328. <td class="description last">
  329. <p>The vector that should expand the bounding box.</p>
  330. </td>
  331. </tr>
  332. </tbody>
  333. </table>
  334. <dl class="details">
  335. <dt class="tag-returns"><strong>Returns:</strong> A reference to this bounding box.</dt>
  336. </dl>
  337. </div>
  338. <h3 class="name name-method" id="fromJSON" translate="no">.<a href="#fromJSON">fromJSON</a><span class="signature">( json : <span class="param-type">Object</span> )</span><span class="type-signature"> : <a href="Box3.html">Box3</a></span> </h3>
  339. <div class="method">
  340. <div class="description">
  341. <p>Returns a serialized structure of the bounding box.</p>
  342. </div>
  343. <table class="params">
  344. <tbody>
  345. <tr>
  346. <td class="name">
  347. <strong>json</strong>
  348. </td>
  349. <td class="description last">
  350. <p>The serialized json to set the box from.</p>
  351. </td>
  352. </tr>
  353. </tbody>
  354. </table>
  355. <dl class="details">
  356. <dt class="tag-returns"><strong>Returns:</strong> A reference to this bounding box.</dt>
  357. </dl>
  358. </div>
  359. <h3 class="name name-method" id="getBoundingSphere" translate="no">.<a href="#getBoundingSphere">getBoundingSphere</a><span class="signature">( target : <span class="param-type"><a href="Sphere.html">Sphere</a></span> )</span><span class="type-signature"> : <a href="Sphere.html">Sphere</a></span> </h3>
  360. <div class="method">
  361. <div class="description">
  362. <p>Returns a bounding sphere that encloses this bounding box.</p>
  363. </div>
  364. <table class="params">
  365. <tbody>
  366. <tr>
  367. <td class="name">
  368. <strong>target</strong>
  369. </td>
  370. <td class="description last">
  371. <p>The target sphere that is used to store the method's result.</p>
  372. </td>
  373. </tr>
  374. </tbody>
  375. </table>
  376. <dl class="details">
  377. <dt class="tag-returns"><strong>Returns:</strong> The bounding sphere that encloses this bounding box.</dt>
  378. </dl>
  379. </div>
  380. <h3 class="name name-method" id="getCenter" translate="no">.<a href="#getCenter">getCenter</a><span class="signature">( target : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  381. <div class="method">
  382. <div class="description">
  383. <p>Returns the center point of this box.</p>
  384. </div>
  385. <table class="params">
  386. <tbody>
  387. <tr>
  388. <td class="name">
  389. <strong>target</strong>
  390. </td>
  391. <td class="description last">
  392. <p>The target vector that is used to store the method's result.</p>
  393. </td>
  394. </tr>
  395. </tbody>
  396. </table>
  397. <dl class="details">
  398. <dt class="tag-returns"><strong>Returns:</strong> The center point.</dt>
  399. </dl>
  400. </div>
  401. <h3 class="name name-method" id="getParameter" translate="no">.<a href="#getParameter">getParameter</a><span class="signature">( point : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, target : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  402. <div class="method">
  403. <div class="description">
  404. <p>Returns a point as a proportion of this box's width, height and depth.</p>
  405. </div>
  406. <table class="params">
  407. <tbody>
  408. <tr>
  409. <td class="name">
  410. <strong>point</strong>
  411. </td>
  412. <td class="description last">
  413. <p>A point in 3D space.</p>
  414. </td>
  415. </tr>
  416. <tr>
  417. <td class="name">
  418. <strong>target</strong>
  419. </td>
  420. <td class="description last">
  421. <p>The target vector that is used to store the method's result.</p>
  422. </td>
  423. </tr>
  424. </tbody>
  425. </table>
  426. <dl class="details">
  427. <dt class="tag-returns"><strong>Returns:</strong> A point as a proportion of this box's width, height and depth.</dt>
  428. </dl>
  429. </div>
  430. <h3 class="name name-method" id="getSize" translate="no">.<a href="#getSize">getSize</a><span class="signature">( target : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  431. <div class="method">
  432. <div class="description">
  433. <p>Returns the dimensions of this box.</p>
  434. </div>
  435. <table class="params">
  436. <tbody>
  437. <tr>
  438. <td class="name">
  439. <strong>target</strong>
  440. </td>
  441. <td class="description last">
  442. <p>The target vector that is used to store the method's result.</p>
  443. </td>
  444. </tr>
  445. </tbody>
  446. </table>
  447. <dl class="details">
  448. <dt class="tag-returns"><strong>Returns:</strong> The size.</dt>
  449. </dl>
  450. </div>
  451. <h3 class="name name-method" id="intersect" translate="no">.<a href="#intersect">intersect</a><span class="signature">( box : <span class="param-type"><a href="Box3.html">Box3</a></span> )</span><span class="type-signature"> : <a href="Box3.html">Box3</a></span> </h3>
  452. <div class="method">
  453. <div class="description">
  454. <p>Computes the intersection of this bounding box and the given one, setting the upper
  455. bound of this box to the lesser of the two boxes' upper bounds and the
  456. lower bound of this box to the greater of the two boxes' lower bounds. If
  457. there's no overlap, makes this box empty.</p>
  458. </div>
  459. <table class="params">
  460. <tbody>
  461. <tr>
  462. <td class="name">
  463. <strong>box</strong>
  464. </td>
  465. <td class="description last">
  466. <p>The bounding box to intersect with.</p>
  467. </td>
  468. </tr>
  469. </tbody>
  470. </table>
  471. <dl class="details">
  472. <dt class="tag-returns"><strong>Returns:</strong> A reference to this bounding box.</dt>
  473. </dl>
  474. </div>
  475. <h3 class="name name-method" id="intersectsBox" translate="no">.<a href="#intersectsBox">intersectsBox</a><span class="signature">( box : <span class="param-type"><a href="Box3.html">Box3</a></span> )</span><span class="type-signature"> : boolean</span> </h3>
  476. <div class="method">
  477. <div class="description">
  478. <p>Returns <code>true</code> if the given bounding box intersects with this bounding box.</p>
  479. </div>
  480. <table class="params">
  481. <tbody>
  482. <tr>
  483. <td class="name">
  484. <strong>box</strong>
  485. </td>
  486. <td class="description last">
  487. <p>The bounding box to test.</p>
  488. </td>
  489. </tr>
  490. </tbody>
  491. </table>
  492. <dl class="details">
  493. <dt class="tag-returns"><strong>Returns:</strong> Whether the given bounding box intersects with this bounding box.</dt>
  494. </dl>
  495. </div>
  496. <h3 class="name name-method" id="intersectsPlane" translate="no">.<a href="#intersectsPlane">intersectsPlane</a><span class="signature">( plane : <span class="param-type"><a href="Plane.html">Plane</a></span> )</span><span class="type-signature"> : boolean</span> </h3>
  497. <div class="method">
  498. <div class="description">
  499. <p>Returns <code>true</code> if the given plane intersects with this bounding box.</p>
  500. </div>
  501. <table class="params">
  502. <tbody>
  503. <tr>
  504. <td class="name">
  505. <strong>plane</strong>
  506. </td>
  507. <td class="description last">
  508. <p>The plane to test.</p>
  509. </td>
  510. </tr>
  511. </tbody>
  512. </table>
  513. <dl class="details">
  514. <dt class="tag-returns"><strong>Returns:</strong> Whether the given plane intersects with this bounding box.</dt>
  515. </dl>
  516. </div>
  517. <h3 class="name name-method" id="intersectsSphere" translate="no">.<a href="#intersectsSphere">intersectsSphere</a><span class="signature">( sphere : <span class="param-type"><a href="Sphere.html">Sphere</a></span> )</span><span class="type-signature"> : boolean</span> </h3>
  518. <div class="method">
  519. <div class="description">
  520. <p>Returns <code>true</code> if the given bounding sphere intersects with this bounding box.</p>
  521. </div>
  522. <table class="params">
  523. <tbody>
  524. <tr>
  525. <td class="name">
  526. <strong>sphere</strong>
  527. </td>
  528. <td class="description last">
  529. <p>The bounding sphere to test.</p>
  530. </td>
  531. </tr>
  532. </tbody>
  533. </table>
  534. <dl class="details">
  535. <dt class="tag-returns"><strong>Returns:</strong> Whether the given bounding sphere intersects with this bounding box.</dt>
  536. </dl>
  537. </div>
  538. <h3 class="name name-method" id="intersectsTriangle" translate="no">.<a href="#intersectsTriangle">intersectsTriangle</a><span class="signature">( triangle : <span class="param-type"><a href="Triangle.html">Triangle</a></span> )</span><span class="type-signature"> : boolean</span> </h3>
  539. <div class="method">
  540. <div class="description">
  541. <p>Returns <code>true</code> if the given triangle intersects with this bounding box.</p>
  542. </div>
  543. <table class="params">
  544. <tbody>
  545. <tr>
  546. <td class="name">
  547. <strong>triangle</strong>
  548. </td>
  549. <td class="description last">
  550. <p>The triangle to test.</p>
  551. </td>
  552. </tr>
  553. </tbody>
  554. </table>
  555. <dl class="details">
  556. <dt class="tag-returns"><strong>Returns:</strong> Whether the given triangle intersects with this bounding box.</dt>
  557. </dl>
  558. </div>
  559. <h3 class="name name-method" id="isEmpty" translate="no">.<a href="#isEmpty">isEmpty</a><span class="signature">()</span><span class="type-signature"> : boolean</span> </h3>
  560. <div class="method">
  561. <div class="description">
  562. <p>Returns true if this box includes zero points within its bounds.
  563. Note that a box with equal lower and upper bounds still includes one
  564. point, the one both bounds share.</p>
  565. </div>
  566. <dl class="details">
  567. <dt class="tag-returns"><strong>Returns:</strong> Whether this box is empty or not.</dt>
  568. </dl>
  569. </div>
  570. <h3 class="name name-method" id="makeEmpty" translate="no">.<a href="#makeEmpty">makeEmpty</a><span class="signature">()</span><span class="type-signature"> : <a href="Box3.html">Box3</a></span> </h3>
  571. <div class="method">
  572. <div class="description">
  573. <p>Makes this box empty which means in encloses a zero space in 3D.</p>
  574. </div>
  575. <dl class="details">
  576. <dt class="tag-returns"><strong>Returns:</strong> A reference to this bounding box.</dt>
  577. </dl>
  578. </div>
  579. <h3 class="name name-method" id="set" translate="no">.<a href="#set">set</a><span class="signature">( min : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, max : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Box3.html">Box3</a></span> </h3>
  580. <div class="method">
  581. <div class="description">
  582. <p>Sets the lower and upper boundaries of this box.
  583. Please note that this method only copies the values from the given objects.</p>
  584. </div>
  585. <table class="params">
  586. <tbody>
  587. <tr>
  588. <td class="name">
  589. <strong>min</strong>
  590. </td>
  591. <td class="description last">
  592. <p>The lower boundary of the box.</p>
  593. </td>
  594. </tr>
  595. <tr>
  596. <td class="name">
  597. <strong>max</strong>
  598. </td>
  599. <td class="description last">
  600. <p>The upper boundary of the box.</p>
  601. </td>
  602. </tr>
  603. </tbody>
  604. </table>
  605. <dl class="details">
  606. <dt class="tag-returns"><strong>Returns:</strong> A reference to this bounding box.</dt>
  607. </dl>
  608. </div>
  609. <h3 class="name name-method" id="setFromArray" translate="no">.<a href="#setFromArray">setFromArray</a><span class="signature">( array : <span class="param-type">Array.&lt;number></span> )</span><span class="type-signature"> : <a href="Box3.html">Box3</a></span> </h3>
  610. <div class="method">
  611. <div class="description">
  612. <p>Sets the upper and lower bounds of this box so it encloses the position data
  613. in the given array.</p>
  614. </div>
  615. <table class="params">
  616. <tbody>
  617. <tr>
  618. <td class="name">
  619. <strong>array</strong>
  620. </td>
  621. <td class="description last">
  622. <p>An array holding 3D position data.</p>
  623. </td>
  624. </tr>
  625. </tbody>
  626. </table>
  627. <dl class="details">
  628. <dt class="tag-returns"><strong>Returns:</strong> A reference to this bounding box.</dt>
  629. </dl>
  630. </div>
  631. <h3 class="name name-method" id="setFromBufferAttribute" translate="no">.<a href="#setFromBufferAttribute">setFromBufferAttribute</a><span class="signature">( attribute : <span class="param-type"><a href="BufferAttribute.html">BufferAttribute</a></span> )</span><span class="type-signature"> : <a href="Box3.html">Box3</a></span> </h3>
  632. <div class="method">
  633. <div class="description">
  634. <p>Sets the upper and lower bounds of this box so it encloses the position data
  635. in the given buffer attribute.</p>
  636. </div>
  637. <table class="params">
  638. <tbody>
  639. <tr>
  640. <td class="name">
  641. <strong>attribute</strong>
  642. </td>
  643. <td class="description last">
  644. <p>A buffer attribute holding 3D position data.</p>
  645. </td>
  646. </tr>
  647. </tbody>
  648. </table>
  649. <dl class="details">
  650. <dt class="tag-returns"><strong>Returns:</strong> A reference to this bounding box.</dt>
  651. </dl>
  652. </div>
  653. <h3 class="name name-method" id="setFromCenterAndSize" translate="no">.<a href="#setFromCenterAndSize">setFromCenterAndSize</a><span class="signature">( center : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, size : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Box3.html">Box3</a></span> </h3>
  654. <div class="method">
  655. <div class="description">
  656. <p>Centers this box on the given center vector and sets this box's width, height and
  657. depth to the given size values.</p>
  658. </div>
  659. <table class="params">
  660. <tbody>
  661. <tr>
  662. <td class="name">
  663. <strong>center</strong>
  664. </td>
  665. <td class="description last">
  666. <p>The center of the box.</p>
  667. </td>
  668. </tr>
  669. <tr>
  670. <td class="name">
  671. <strong>size</strong>
  672. </td>
  673. <td class="description last">
  674. <p>The x, y and z dimensions of the box.</p>
  675. </td>
  676. </tr>
  677. </tbody>
  678. </table>
  679. <dl class="details">
  680. <dt class="tag-returns"><strong>Returns:</strong> A reference to this bounding box.</dt>
  681. </dl>
  682. </div>
  683. <h3 class="name name-method" id="setFromObject" translate="no">.<a href="#setFromObject">setFromObject</a><span class="signature">( object : <span class="param-type"><a href="Object3D.html">Object3D</a></span>, precise : <span class="param-type">boolean</span> )</span><span class="type-signature"> : <a href="Box3.html">Box3</a></span> </h3>
  684. <div class="method">
  685. <div class="description">
  686. <p>Computes the world-axis-aligned bounding box for the given 3D object
  687. (including its children), accounting for the object's, and children's,
  688. world transforms. The function may result in a larger box than strictly necessary.</p>
  689. </div>
  690. <table class="params">
  691. <tbody>
  692. <tr>
  693. <td class="name">
  694. <strong>object</strong>
  695. </td>
  696. <td class="description last">
  697. <p>The 3D object to compute the bounding box for.</p>
  698. </td>
  699. </tr>
  700. <tr>
  701. <td class="name">
  702. <strong>precise</strong>
  703. </td>
  704. <td class="description last">
  705. <p>If set to <code>true</code>, the method computes the smallest
  706. world-axis-aligned bounding box at the expense of more computation.</p>
  707. <p>Default is <code>false</code>.</p>
  708. </td>
  709. </tr>
  710. </tbody>
  711. </table>
  712. <dl class="details">
  713. <dt class="tag-returns"><strong>Returns:</strong> A reference to this bounding box.</dt>
  714. </dl>
  715. </div>
  716. <h3 class="name name-method" id="setFromPoints" translate="no">.<a href="#setFromPoints">setFromPoints</a><span class="signature">( points : <span class="param-type">Array.&lt;<a href="Vector3.html">Vector3</a>></span> )</span><span class="type-signature"> : <a href="Box3.html">Box3</a></span> </h3>
  717. <div class="method">
  718. <div class="description">
  719. <p>Sets the upper and lower bounds of this box so it encloses the position data
  720. in the given array.</p>
  721. </div>
  722. <table class="params">
  723. <tbody>
  724. <tr>
  725. <td class="name">
  726. <strong>points</strong>
  727. </td>
  728. <td class="description last">
  729. <p>An array holding 3D position data as instances of <a href="Vector3.html">Vector3</a>.</p>
  730. </td>
  731. </tr>
  732. </tbody>
  733. </table>
  734. <dl class="details">
  735. <dt class="tag-returns"><strong>Returns:</strong> A reference to this bounding box.</dt>
  736. </dl>
  737. </div>
  738. <h3 class="name name-method" id="toJSON" translate="no">.<a href="#toJSON">toJSON</a><span class="signature">()</span><span class="type-signature"> : Object</span> </h3>
  739. <div class="method">
  740. <div class="description">
  741. <p>Returns a serialized structure of the bounding box.</p>
  742. </div>
  743. <dl class="details">
  744. <dt class="tag-returns"><strong>Returns:</strong> Serialized structure with fields representing the object state.</dt>
  745. </dl>
  746. </div>
  747. <h3 class="name name-method" id="translate" translate="no">.<a href="#translate">translate</a><span class="signature">( offset : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Box3.html">Box3</a></span> </h3>
  748. <div class="method">
  749. <div class="description">
  750. <p>Adds the given offset to both the upper and lower bounds of this bounding box,
  751. effectively moving it in 3D space.</p>
  752. </div>
  753. <table class="params">
  754. <tbody>
  755. <tr>
  756. <td class="name">
  757. <strong>offset</strong>
  758. </td>
  759. <td class="description last">
  760. <p>The offset that should be used to translate the bounding box.</p>
  761. </td>
  762. </tr>
  763. </tbody>
  764. </table>
  765. <dl class="details">
  766. <dt class="tag-returns"><strong>Returns:</strong> A reference to this bounding box.</dt>
  767. </dl>
  768. </div>
  769. <h3 class="name name-method" id="union" translate="no">.<a href="#union">union</a><span class="signature">( box : <span class="param-type"><a href="Box3.html">Box3</a></span> )</span><span class="type-signature"> : <a href="Box3.html">Box3</a></span> </h3>
  770. <div class="method">
  771. <div class="description">
  772. <p>Computes the union of this box and another and the given one, setting the upper
  773. bound of this box to the greater of the two boxes' upper bounds and the
  774. lower bound of this box to the lesser of the two boxes' lower bounds.</p>
  775. </div>
  776. <table class="params">
  777. <tbody>
  778. <tr>
  779. <td class="name">
  780. <strong>box</strong>
  781. </td>
  782. <td class="description last">
  783. <p>The bounding box that will be unioned with this instance.</p>
  784. </td>
  785. </tr>
  786. </tbody>
  787. </table>
  788. <dl class="details">
  789. <dt class="tag-returns"><strong>Returns:</strong> A reference to this bounding box.</dt>
  790. </dl>
  791. </div>
  792. <h2 class="subsection-title">Source</h2>
  793. <p>
  794. <a href="https://github.com/mrdoob/three.js/blob/master/src/math/Box3.js" translate="no" target="_blank" rel="noopener">src/math/Box3.js</a>
  795. </p>
  796. </article>
  797. </section>
  798. <script src="../scripts/linenumber.js"></script>
  799. <script src="../scripts/page.js"></script>
  800. </body>
  801. </html>
粤ICP备19079148号