| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <title>Capsule - Three.js Docs</title>
- <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
- <script src="../scripts/highlight.min.js"></script>
- <link type="text/css" rel="stylesheet" href="../styles/highlight-three.css">
- <link type="text/css" rel="stylesheet" href="../styles/page.css">
- </head>
- <body>
- <h1 translate="no">Capsule</h1>
- <section>
- <header>
- <div class="class-description"><p>A capsule is essentially a cylinder with hemispherical caps at both ends.
- It can be thought of as a swept sphere, where a sphere is moved along a line segment.</p>
- <p>Capsules are often used as bounding volumes (next to AABBs and bounding spheres).</p></div>
- </header>
- <article>
- <h2 class="subsection-title">Import</h2>
- <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>
- <pre><code class="language-js">import { Capsule } from 'three/addons/math/Capsule.js';</code></pre>
- <div class="container-overview">
- <h2>Constructor</h2>
- <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>
- <div class="method">
- <div class="description">
- <p>Constructs a new capsule.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name">
- <strong>start</strong>
- </td>
- <td class="description last">
- <p>The start vector.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>end</strong>
- </td>
- <td class="description last">
- <p>The end vector.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>radius</strong>
- </td>
- <td class="description last">
- <p>The capsule's radius.</p>
- <p>Default is <code>1</code>.</p>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- </div>
- <h2 class="subsection-title">Properties</h2>
- <div class="member">
- <h3 class="name" id="end" translate="no">.<a href="#end">end</a><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
- <div class="description">
- <p>The end vector.</p>
- </div>
- </div>
- <div class="member">
- <h3 class="name" id="radius" translate="no">.<a href="#radius">radius</a><span class="type-signature"> : number</span> </h3>
- <div class="description">
- <p>The capsule's radius.</p>
- <p>Default is <code>1</code>.</p>
- </div>
- </div>
- <div class="member">
- <h3 class="name" id="start" translate="no">.<a href="#start">start</a><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
- <div class="description">
- <p>The start vector.</p>
- </div>
- </div>
- <h2 class="subsection-title">Methods</h2>
- <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>
- <div class="method">
- <div class="description">
- <p>Returns a new capsule with copied values from this instance.</p>
- </div>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A clone of this instance.</dt>
- </dl>
- </div>
- <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>
- <div class="method">
- <div class="description">
- <p>Copies the values of the given capsule to this instance.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name">
- <strong>capsule</strong>
- </td>
- <td class="description last">
- <p>The capsule to copy.</p>
- </td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this capsule.</dt>
- </dl>
- </div>
- <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>
- <div class="method">
- <div class="description">
- <p>Returns the center point of this capsule.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name">
- <strong>target</strong>
- </td>
- <td class="description last">
- <p>The target vector that is used to store the method's result.</p>
- </td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> The center point.</dt>
- </dl>
- </div>
- <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>
- <div class="method">
- <div class="description">
- <p>Returns <code>true</code> if the given bounding box intersects with this capsule.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name">
- <strong>box</strong>
- </td>
- <td class="description last">
- <p>The bounding box to test.</p>
- </td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> Whether the given bounding box intersects with this capsule.</dt>
- </dl>
- </div>
- <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>
- <div class="method">
- <div class="description">
- <p>Sets the capsule components to the given values.
- Please note that this method only copies the values from the given objects.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name">
- <strong>start</strong>
- </td>
- <td class="description last">
- <p>The start vector.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>end</strong>
- </td>
- <td class="description last">
- <p>The end vector</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>radius</strong>
- </td>
- <td class="description last">
- <p>The capsule's radius.</p>
- </td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this capsule.</dt>
- </dl>
- </div>
- <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>
- <div class="method">
- <div class="description">
- <p>Adds the given offset to this capsule, effectively moving it in 3D space.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name">
- <strong>v</strong>
- </td>
- <td class="description last">
- <p>The offset that should be used to translate the capsule.</p>
- </td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this capsule.</dt>
- </dl>
- </div>
- <h2 class="subsection-title">Source</h2>
- <p>
- <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>
- </p>
- </article>
- </section>
- <script src="../scripts/linenumber.js"></script>
- <script src="../scripts/page.js"></script>
- </body>
- </html>
|