1
0

Capsule.html 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Capsule - 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">Capsule</h1>
  13. <section>
  14. <header>
  15. <div class="class-description"><p>A capsule is essentially a cylinder with hemispherical caps at both ends.
  16. It can be thought of as a swept sphere, where a sphere is moved along a line segment.</p>
  17. <p>Capsules are often used as bounding volumes (next to AABBs and bounding spheres).</p></div>
  18. </header>
  19. <article>
  20. <h2 class="subsection-title">Import</h2>
  21. <p><span translate="no">Capsule</span> is an addon, and must be imported explicitly, see <a href="https://threejs.org/manual/#en/installation" target="_blank" rel="noopener">Installation#Addons</a>.</p>
  22. <pre><code class="language-js">import { Capsule } from 'three/addons/math/Capsule.js';</code></pre>
  23. <div class="container-overview">
  24. <h2>Constructor</h2>
  25. <h3 class="name name-method" id="Capsule" translate="no">new <a href="#Capsule">Capsule</a><span class="signature">( start : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, end : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, radius : <span class="param-type">number</span> )</span> </h3>
  26. <div class="method">
  27. <div class="description">
  28. <p>Constructs a new capsule.</p>
  29. </div>
  30. <table class="params">
  31. <tbody>
  32. <tr>
  33. <td class="name">
  34. <strong>start</strong>
  35. </td>
  36. <td class="description last">
  37. <p>The start vector.</p>
  38. </td>
  39. </tr>
  40. <tr>
  41. <td class="name">
  42. <strong>end</strong>
  43. </td>
  44. <td class="description last">
  45. <p>The end vector.</p>
  46. </td>
  47. </tr>
  48. <tr>
  49. <td class="name">
  50. <strong>radius</strong>
  51. </td>
  52. <td class="description last">
  53. <p>The capsule's radius.</p>
  54. <p>Default is <code>1</code>.</p>
  55. </td>
  56. </tr>
  57. </tbody>
  58. </table>
  59. </div>
  60. </div>
  61. <h2 class="subsection-title">Properties</h2>
  62. <div class="member">
  63. <h3 class="name" id="end" translate="no">.<a href="#end">end</a><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  64. <div class="description">
  65. <p>The end vector.</p>
  66. </div>
  67. </div>
  68. <div class="member">
  69. <h3 class="name" id="radius" translate="no">.<a href="#radius">radius</a><span class="type-signature"> : number</span> </h3>
  70. <div class="description">
  71. <p>The capsule's radius.</p>
  72. <p>Default is <code>1</code>.</p>
  73. </div>
  74. </div>
  75. <div class="member">
  76. <h3 class="name" id="start" translate="no">.<a href="#start">start</a><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  77. <div class="description">
  78. <p>The start vector.</p>
  79. </div>
  80. </div>
  81. <h2 class="subsection-title">Methods</h2>
  82. <h3 class="name name-method" id="clone" translate="no">.<a href="#clone">clone</a><span class="signature">()</span><span class="type-signature"> : <a href="Capsule.html">Capsule</a></span> </h3>
  83. <div class="method">
  84. <div class="description">
  85. <p>Returns a new capsule with copied values from this instance.</p>
  86. </div>
  87. <dl class="details">
  88. <dt class="tag-returns"><strong>Returns:</strong> A clone of this instance.</dt>
  89. </dl>
  90. </div>
  91. <h3 class="name name-method" id="copy" translate="no">.<a href="#copy">copy</a><span class="signature">( capsule : <span class="param-type"><a href="Capsule.html">Capsule</a></span> )</span><span class="type-signature"> : <a href="Capsule.html">Capsule</a></span> </h3>
  92. <div class="method">
  93. <div class="description">
  94. <p>Copies the values of the given capsule to this instance.</p>
  95. </div>
  96. <table class="params">
  97. <tbody>
  98. <tr>
  99. <td class="name">
  100. <strong>capsule</strong>
  101. </td>
  102. <td class="description last">
  103. <p>The capsule to copy.</p>
  104. </td>
  105. </tr>
  106. </tbody>
  107. </table>
  108. <dl class="details">
  109. <dt class="tag-returns"><strong>Returns:</strong> A reference to this capsule.</dt>
  110. </dl>
  111. </div>
  112. <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>
  113. <div class="method">
  114. <div class="description">
  115. <p>Returns the center point of this capsule.</p>
  116. </div>
  117. <table class="params">
  118. <tbody>
  119. <tr>
  120. <td class="name">
  121. <strong>target</strong>
  122. </td>
  123. <td class="description last">
  124. <p>The target vector that is used to store the method's result.</p>
  125. </td>
  126. </tr>
  127. </tbody>
  128. </table>
  129. <dl class="details">
  130. <dt class="tag-returns"><strong>Returns:</strong> The center point.</dt>
  131. </dl>
  132. </div>
  133. <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>
  134. <div class="method">
  135. <div class="description">
  136. <p>Returns <code>true</code> if the given bounding box intersects with this capsule.</p>
  137. </div>
  138. <table class="params">
  139. <tbody>
  140. <tr>
  141. <td class="name">
  142. <strong>box</strong>
  143. </td>
  144. <td class="description last">
  145. <p>The bounding box to test.</p>
  146. </td>
  147. </tr>
  148. </tbody>
  149. </table>
  150. <dl class="details">
  151. <dt class="tag-returns"><strong>Returns:</strong> Whether the given bounding box intersects with this capsule.</dt>
  152. </dl>
  153. </div>
  154. <h3 class="name name-method" id="set" translate="no">.<a href="#set">set</a><span class="signature">( start : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, end : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, radius : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Capsule.html">Capsule</a></span> </h3>
  155. <div class="method">
  156. <div class="description">
  157. <p>Sets the capsule components to the given values.
  158. Please note that this method only copies the values from the given objects.</p>
  159. </div>
  160. <table class="params">
  161. <tbody>
  162. <tr>
  163. <td class="name">
  164. <strong>start</strong>
  165. </td>
  166. <td class="description last">
  167. <p>The start vector.</p>
  168. </td>
  169. </tr>
  170. <tr>
  171. <td class="name">
  172. <strong>end</strong>
  173. </td>
  174. <td class="description last">
  175. <p>The end vector</p>
  176. </td>
  177. </tr>
  178. <tr>
  179. <td class="name">
  180. <strong>radius</strong>
  181. </td>
  182. <td class="description last">
  183. <p>The capsule's radius.</p>
  184. </td>
  185. </tr>
  186. </tbody>
  187. </table>
  188. <dl class="details">
  189. <dt class="tag-returns"><strong>Returns:</strong> A reference to this capsule.</dt>
  190. </dl>
  191. </div>
  192. <h3 class="name name-method" id="translate" translate="no">.<a href="#translate">translate</a><span class="signature">( v : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Capsule.html">Capsule</a></span> </h3>
  193. <div class="method">
  194. <div class="description">
  195. <p>Adds the given offset to this capsule, effectively moving it in 3D space.</p>
  196. </div>
  197. <table class="params">
  198. <tbody>
  199. <tr>
  200. <td class="name">
  201. <strong>v</strong>
  202. </td>
  203. <td class="description last">
  204. <p>The offset that should be used to translate the capsule.</p>
  205. </td>
  206. </tr>
  207. </tbody>
  208. </table>
  209. <dl class="details">
  210. <dt class="tag-returns"><strong>Returns:</strong> A reference to this capsule.</dt>
  211. </dl>
  212. </div>
  213. <h2 class="subsection-title">Source</h2>
  214. <p>
  215. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/math/Capsule.js" translate="no" target="_blank" rel="noopener">examples/jsm/math/Capsule.js</a>
  216. </p>
  217. </article>
  218. </section>
  219. <script src="../scripts/linenumber.js"></script>
  220. <script src="../scripts/page.js"></script>
  221. </body>
  222. </html>
粤ICP备19079148号