Capsule.html 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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">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">Vector3</span>, end : <span class="param-type">Vector3</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"><code>start</code></td>
  34. <td class="description last"><p>The start vector.</p></td>
  35. </tr>
  36. <tr>
  37. <td class="name"><code>end</code></td>
  38. <td class="description last"><p>The end vector.</p></td>
  39. </tr>
  40. <tr>
  41. <td class="name"><code>radius</code></td>
  42. <td class="description last"><p>The capsule's radius.<br/>Default is <code>1</code>.</p></td>
  43. </tr>
  44. </tbody>
  45. </table>
  46. </div>
  47. </div>
  48. <h2 class="subsection-title">Properties</h2>
  49. <div class="member">
  50. <h3 class="name" id="end" translate="no">.<a href="#end">end</a><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  51. <div class="description">
  52. <p>The end vector.</p>
  53. </div>
  54. </div>
  55. <div class="member">
  56. <h3 class="name" id="radius" translate="no">.<a href="#radius">radius</a><span class="type-signature"> : number</span> </h3>
  57. <div class="description">
  58. <p>The capsule's radius.<br/>Default is <code>1</code>.</p>
  59. </div>
  60. </div>
  61. <div class="member">
  62. <h3 class="name" id="start" translate="no">.<a href="#start">start</a><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  63. <div class="description">
  64. <p>The start vector.</p>
  65. </div>
  66. </div>
  67. <h2 class="subsection-title">Methods</h2>
  68. <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>
  69. <div class="method">
  70. <div class="description">
  71. <p>Returns a new capsule with copied values from this instance.</p>
  72. </div>
  73. <dl class="details">
  74. <dt class="tag-returns"><strong>Returns:</strong> A clone of this instance.</dt>
  75. </dl>
  76. </div>
  77. <h3 class="name name-method" id="copy" translate="no">.<a href="#copy">copy</a><span class="signature">( capsule : <span class="param-type">Capsule</span> )</span><span class="type-signature"> : <a href="Capsule.html">Capsule</a></span> </h3>
  78. <div class="method">
  79. <div class="description">
  80. <p>Copies the values of the given capsule to this instance.</p>
  81. </div>
  82. <table class="params">
  83. <tbody>
  84. <tr>
  85. <td class="name"><code>capsule</code></td>
  86. <td class="description last"><p>The capsule to copy.</p></td>
  87. </tr>
  88. </tbody>
  89. </table>
  90. <dl class="details">
  91. <dt class="tag-returns"><strong>Returns:</strong> A reference to this capsule.</dt>
  92. </dl>
  93. </div>
  94. <h3 class="name name-method" id="getCenter" translate="no">.<a href="#getCenter">getCenter</a><span class="signature">( target : <span class="param-type">Vector3</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  95. <div class="method">
  96. <div class="description">
  97. <p>Returns the center point of this capsule.</p>
  98. </div>
  99. <table class="params">
  100. <tbody>
  101. <tr>
  102. <td class="name"><code>target</code></td>
  103. <td class="description last"><p>The target vector that is used to store the method's result.</p></td>
  104. </tr>
  105. </tbody>
  106. </table>
  107. <dl class="details">
  108. <dt class="tag-returns"><strong>Returns:</strong> The center point.</dt>
  109. </dl>
  110. </div>
  111. <h3 class="name name-method" id="intersectsBox" translate="no">.<a href="#intersectsBox">intersectsBox</a><span class="signature">( box : <span class="param-type">Box3</span> )</span><span class="type-signature"> : boolean</span> </h3>
  112. <div class="method">
  113. <div class="description">
  114. <p>Returns <code>true</code> if the given bounding box intersects with this capsule.</p>
  115. </div>
  116. <table class="params">
  117. <tbody>
  118. <tr>
  119. <td class="name"><code>box</code></td>
  120. <td class="description last"><p>The bounding box to test.</p></td>
  121. </tr>
  122. </tbody>
  123. </table>
  124. <dl class="details">
  125. <dt class="tag-returns"><strong>Returns:</strong> Whether the given bounding box intersects with this capsule.</dt>
  126. </dl>
  127. </div>
  128. <h3 class="name name-method" id="set" translate="no">.<a href="#set">set</a><span class="signature">( start : <span class="param-type">Vector3</span>, end : <span class="param-type">Vector3</span>, radius : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Capsule.html">Capsule</a></span> </h3>
  129. <div class="method">
  130. <div class="description">
  131. <p>Sets the capsule components to the given values.
  132. Please note that this method only copies the values from the given objects.</p>
  133. </div>
  134. <table class="params">
  135. <tbody>
  136. <tr>
  137. <td class="name"><code>start</code></td>
  138. <td class="description last"><p>The start vector.</p></td>
  139. </tr>
  140. <tr>
  141. <td class="name"><code>end</code></td>
  142. <td class="description last"><p>The end vector</p></td>
  143. </tr>
  144. <tr>
  145. <td class="name"><code>radius</code></td>
  146. <td class="description last"><p>The capsule's radius.</p></td>
  147. </tr>
  148. </tbody>
  149. </table>
  150. <dl class="details">
  151. <dt class="tag-returns"><strong>Returns:</strong> A reference to this capsule.</dt>
  152. </dl>
  153. </div>
  154. <h3 class="name name-method" id="translate" translate="no">.<a href="#translate">translate</a><span class="signature">( v : <span class="param-type">Vector3</span> )</span><span class="type-signature"> : <a href="Capsule.html">Capsule</a></span> </h3>
  155. <div class="method">
  156. <div class="description">
  157. <p>Adds the given offset to this capsule, effectively moving it in 3D space.</p>
  158. </div>
  159. <table class="params">
  160. <tbody>
  161. <tr>
  162. <td class="name"><code>v</code></td>
  163. <td class="description last"><p>The offset that should be used to translate the capsule.</p></td>
  164. </tr>
  165. </tbody>
  166. </table>
  167. <dl class="details">
  168. <dt class="tag-returns"><strong>Returns:</strong> A reference to this capsule.</dt>
  169. </dl>
  170. </div>
  171. <h2 class="subsection-title">Source</h2>
  172. <p>
  173. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/math/Capsule.js" target="_blank" rel="noopener" translate="no">examples/jsm/math/Capsule.js</a>
  174. </p>
  175. </article>
  176. </section>
  177. <script src="../scripts/linenumber.js"></script>
  178. <script src="../scripts/page.js"></script>
  179. </body>
  180. </html>
粤ICP备19079148号