| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <title>Skeleton - 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">Skeleton</h1>
- <section>
- <header>
- <div class="class-description"><p>Class for representing the armatures in <code>three.js</code>. The skeleton
- is defined by a hierarchy of bones.</p></div>
- <h2>Code Example</h2>
- <div translate="no"><pre><code class="language-js">const bones = [];
- const shoulder = new THREE.Bone();
- const elbow = new THREE.Bone();
- const hand = new THREE.Bone();
- shoulder.add( elbow );
- elbow.add( hand );
- bones.push( shoulder , elbow, hand);
- shoulder.position.y = -5;
- elbow.position.y = 0;
- hand.position.y = 5;
- const armSkeleton = new THREE.Skeleton( bones );
- </code></pre></div>
- </header>
- <article>
- <div class="container-overview">
- <h2>Constructor</h2>
- <h3 class="name name-method" id="Skeleton" translate="no">new <a href="#Skeleton">Skeleton</a><span class="signature">( bones : <span class="param-type">Array.<<a href="Bone.html">Bone</a>></span>, boneInverses : <span class="param-type">Array.<<a href="Matrix4.html">Matrix4</a>></span> )</span> </h3>
- <div class="method">
- <div class="description">
- <p>Constructs a new skeleton.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name">
- <strong>bones</strong>
- </td>
- <td class="description last">
- <p>An array of bones.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>boneInverses</strong>
- </td>
- <td class="description last">
- <p>An array of bone inverse matrices.
- If not provided, these matrices will be computed automatically via <a href="Skeleton.html#calculateInverses">Skeleton#calculateInverses</a>.</p>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- </div>
- <h2 class="subsection-title">Properties</h2>
- <div class="member">
- <h3 class="name" id="boneInverses" translate="no">.<a href="#boneInverses">boneInverses</a><span class="type-signature"> : Array.<<a href="Matrix4.html">Matrix4</a>></span> </h3>
- <div class="description">
- <p>An array of bone inverse matrices.</p>
- </div>
- </div>
- <div class="member">
- <h3 class="name" id="boneMatrices" translate="no">.<a href="#boneMatrices">boneMatrices</a><span class="type-signature"> : Float32Array</span> </h3>
- <div class="description">
- <p>An array buffer holding the bone data.
- Input data for <a href="Skeleton.html#boneTexture">Skeleton#boneTexture</a>.</p>
- <p>Default is <code>null</code>.</p>
- </div>
- </div>
- <div class="member">
- <h3 class="name" id="boneTexture" translate="no">.<a href="#boneTexture">boneTexture</a><span class="type-signature"> : <a href="DataTexture.html">DataTexture</a></span> </h3>
- <div class="description">
- <p>A texture holding the bone data for use
- in the vertex shader.</p>
- <p>Default is <code>null</code>.</p>
- </div>
- </div>
- <div class="member">
- <h3 class="name" id="bones" translate="no">.<a href="#bones">bones</a><span class="type-signature"> : Array.<<a href="Bone.html">Bone</a>></span> </h3>
- <div class="description">
- <p>An array of bones defining the skeleton.</p>
- </div>
- </div>
- <h2 class="subsection-title">Methods</h2>
- <h3 class="name name-method" id="calculateInverses" translate="no">.<a href="#calculateInverses">calculateInverses</a><span class="signature">()</span> </h3>
- <div class="method">
- <div class="description">
- <p>Computes the bone inverse matrices. This method resets <a href="Skeleton.html#boneInverses">Skeleton#boneInverses</a>
- and fills it with new matrices.</p>
- </div>
- </div>
- <h3 class="name name-method" id="clone" translate="no">.<a href="#clone">clone</a><span class="signature">()</span><span class="type-signature"> : <a href="Skeleton.html">Skeleton</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Returns a new skeleton 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="computeBoneTexture" translate="no">.<a href="#computeBoneTexture">computeBoneTexture</a><span class="signature">()</span><span class="type-signature"> : <a href="Skeleton.html">Skeleton</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Computes a data texture for passing bone data to the vertex shader.</p>
- </div>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference of this instance.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="dispose" translate="no">.<a href="#dispose">dispose</a><span class="signature">()</span> </h3>
- <div class="method">
- <div class="description">
- <p>Frees the GPU-related resources allocated by this instance. Call this
- method whenever this instance is no longer used in your app.</p>
- </div>
- </div>
- <h3 class="name name-method" id="fromJSON" translate="no">.<a href="#fromJSON">fromJSON</a><span class="signature">( json : <span class="param-type">Object</span>, bones : <span class="param-type">Object.<string, <a href="Bone.html">Bone</a>></span> )</span><span class="type-signature"> : <a href="Skeleton.html">Skeleton</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Setups the skeleton by the given JSON and bones.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name">
- <strong>json</strong>
- </td>
- <td class="description last">
- <p>The skeleton as serialized JSON.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>bones</strong>
- </td>
- <td class="description last">
- <p>An array of bones.</p>
- </td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference of this instance.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="getBoneByName" translate="no">.<a href="#getBoneByName">getBoneByName</a><span class="signature">( name : <span class="param-type">string</span> )</span><span class="type-signature"> : <a href="Bone.html">Bone</a> | undefined</span> </h3>
- <div class="method">
- <div class="description">
- <p>Searches through the skeleton's bone array and returns the first with a
- matching name.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name">
- <strong>name</strong>
- </td>
- <td class="description last">
- <p>The name of the bone.</p>
- </td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> The found bone. <code>undefined</code> if no bone has been found.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="init" translate="no">.<a href="#init">init</a><span class="signature">()</span> </h3>
- <div class="method">
- <div class="description">
- <p>Initializes the skeleton. This method gets automatically called by the constructor
- but depending on how the skeleton is created it might be necessary to call this method
- manually.</p>
- </div>
- </div>
- <h3 class="name name-method" id="pose" translate="no">.<a href="#pose">pose</a><span class="signature">()</span> </h3>
- <div class="method">
- <div class="description">
- <p>Resets the skeleton to the base pose.</p>
- </div>
- </div>
- <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>
- <div class="method">
- <div class="description">
- <p>Serializes the skeleton into JSON.</p>
- </div>
- <dl class="details">
- <dt class="tag-see">See:</dt>
- <dd class="tag-see">
- <ul>
- <li><a href="ObjectLoader.html#parse">ObjectLoader#parse</a></li>
- </ul>
- </dd>
- </dl>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A JSON object representing the serialized skeleton.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="update" translate="no">.<a href="#update">update</a><span class="signature">()</span> </h3>
- <div class="method">
- <div class="description">
- <p>Resets the skeleton to the base pose.</p>
- </div>
- </div>
- <h2 class="subsection-title">Source</h2>
- <p>
- <a href="https://github.com/mrdoob/three.js/blob/master/src/objects/Skeleton.js" translate="no" target="_blank" rel="noopener">src/objects/Skeleton.js</a>
- </p>
- </article>
- </section>
- <script src="../scripts/linenumber.js"></script>
- <script src="../scripts/page.js"></script>
- </body>
- </html>
|