Skeleton.html 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Skeleton - 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">Skeleton</h1>
  13. <section>
  14. <header>
  15. <div class="class-description"><p>Class for representing the armatures in <code>three.js</code>. The skeleton
  16. is defined by a hierarchy of bones.</p></div>
  17. <h2>Code Example</h2>
  18. <div translate="no"><pre><code class="language-js">const bones = [];
  19. const shoulder = new THREE.Bone();
  20. const elbow = new THREE.Bone();
  21. const hand = new THREE.Bone();
  22. shoulder.add( elbow );
  23. elbow.add( hand );
  24. bones.push( shoulder , elbow, hand);
  25. shoulder.position.y = -5;
  26. elbow.position.y = 0;
  27. hand.position.y = 5;
  28. const armSkeleton = new THREE.Skeleton( bones );
  29. </code></pre></div>
  30. </header>
  31. <article>
  32. <div class="container-overview">
  33. <h2>Constructor</h2>
  34. <h3 class="name name-method" id="Skeleton" translate="no">new <a href="#Skeleton">Skeleton</a><span class="signature">( bones : <span class="param-type">Array.&lt;<a href="Bone.html">Bone</a>></span>, boneInverses : <span class="param-type">Array.&lt;<a href="Matrix4.html">Matrix4</a>></span> )</span> </h3>
  35. <div class="method">
  36. <div class="description">
  37. <p>Constructs a new skeleton.</p>
  38. </div>
  39. <table class="params">
  40. <tbody>
  41. <tr>
  42. <td class="name">
  43. <strong>bones</strong>
  44. </td>
  45. <td class="description last">
  46. <p>An array of bones.</p>
  47. </td>
  48. </tr>
  49. <tr>
  50. <td class="name">
  51. <strong>boneInverses</strong>
  52. </td>
  53. <td class="description last">
  54. <p>An array of bone inverse matrices.
  55. If not provided, these matrices will be computed automatically via <a href="Skeleton.html#calculateInverses">Skeleton#calculateInverses</a>.</p>
  56. </td>
  57. </tr>
  58. </tbody>
  59. </table>
  60. </div>
  61. </div>
  62. <h2 class="subsection-title">Properties</h2>
  63. <div class="member">
  64. <h3 class="name" id="boneInverses" translate="no">.<a href="#boneInverses">boneInverses</a><span class="type-signature"> : Array.&lt;<a href="Matrix4.html">Matrix4</a>></span> </h3>
  65. <div class="description">
  66. <p>An array of bone inverse matrices.</p>
  67. </div>
  68. </div>
  69. <div class="member">
  70. <h3 class="name" id="boneMatrices" translate="no">.<a href="#boneMatrices">boneMatrices</a><span class="type-signature"> : Float32Array</span> </h3>
  71. <div class="description">
  72. <p>An array buffer holding the bone data.
  73. Input data for <a href="Skeleton.html#boneTexture">Skeleton#boneTexture</a>.</p>
  74. <p>Default is <code>null</code>.</p>
  75. </div>
  76. </div>
  77. <div class="member">
  78. <h3 class="name" id="boneTexture" translate="no">.<a href="#boneTexture">boneTexture</a><span class="type-signature"> : <a href="DataTexture.html">DataTexture</a></span> </h3>
  79. <div class="description">
  80. <p>A texture holding the bone data for use
  81. in the vertex shader.</p>
  82. <p>Default is <code>null</code>.</p>
  83. </div>
  84. </div>
  85. <div class="member">
  86. <h3 class="name" id="bones" translate="no">.<a href="#bones">bones</a><span class="type-signature"> : Array.&lt;<a href="Bone.html">Bone</a>></span> </h3>
  87. <div class="description">
  88. <p>An array of bones defining the skeleton.</p>
  89. </div>
  90. </div>
  91. <h2 class="subsection-title">Methods</h2>
  92. <h3 class="name name-method" id="calculateInverses" translate="no">.<a href="#calculateInverses">calculateInverses</a><span class="signature">()</span> </h3>
  93. <div class="method">
  94. <div class="description">
  95. <p>Computes the bone inverse matrices. This method resets <a href="Skeleton.html#boneInverses">Skeleton#boneInverses</a>
  96. and fills it with new matrices.</p>
  97. </div>
  98. </div>
  99. <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>
  100. <div class="method">
  101. <div class="description">
  102. <p>Returns a new skeleton with copied values from this instance.</p>
  103. </div>
  104. <dl class="details">
  105. <dt class="tag-returns"><strong>Returns:</strong> A clone of this instance.</dt>
  106. </dl>
  107. </div>
  108. <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>
  109. <div class="method">
  110. <div class="description">
  111. <p>Computes a data texture for passing bone data to the vertex shader.</p>
  112. </div>
  113. <dl class="details">
  114. <dt class="tag-returns"><strong>Returns:</strong> A reference of this instance.</dt>
  115. </dl>
  116. </div>
  117. <h3 class="name name-method" id="dispose" translate="no">.<a href="#dispose">dispose</a><span class="signature">()</span> </h3>
  118. <div class="method">
  119. <div class="description">
  120. <p>Frees the GPU-related resources allocated by this instance. Call this
  121. method whenever this instance is no longer used in your app.</p>
  122. </div>
  123. </div>
  124. <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.&lt;string, <a href="Bone.html">Bone</a>></span> )</span><span class="type-signature"> : <a href="Skeleton.html">Skeleton</a></span> </h3>
  125. <div class="method">
  126. <div class="description">
  127. <p>Setups the skeleton by the given JSON and bones.</p>
  128. </div>
  129. <table class="params">
  130. <tbody>
  131. <tr>
  132. <td class="name">
  133. <strong>json</strong>
  134. </td>
  135. <td class="description last">
  136. <p>The skeleton as serialized JSON.</p>
  137. </td>
  138. </tr>
  139. <tr>
  140. <td class="name">
  141. <strong>bones</strong>
  142. </td>
  143. <td class="description last">
  144. <p>An array of bones.</p>
  145. </td>
  146. </tr>
  147. </tbody>
  148. </table>
  149. <dl class="details">
  150. <dt class="tag-returns"><strong>Returns:</strong> A reference of this instance.</dt>
  151. </dl>
  152. </div>
  153. <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>
  154. <div class="method">
  155. <div class="description">
  156. <p>Searches through the skeleton's bone array and returns the first with a
  157. matching name.</p>
  158. </div>
  159. <table class="params">
  160. <tbody>
  161. <tr>
  162. <td class="name">
  163. <strong>name</strong>
  164. </td>
  165. <td class="description last">
  166. <p>The name of the bone.</p>
  167. </td>
  168. </tr>
  169. </tbody>
  170. </table>
  171. <dl class="details">
  172. <dt class="tag-returns"><strong>Returns:</strong> The found bone. <code>undefined</code> if no bone has been found.</dt>
  173. </dl>
  174. </div>
  175. <h3 class="name name-method" id="init" translate="no">.<a href="#init">init</a><span class="signature">()</span> </h3>
  176. <div class="method">
  177. <div class="description">
  178. <p>Initializes the skeleton. This method gets automatically called by the constructor
  179. but depending on how the skeleton is created it might be necessary to call this method
  180. manually.</p>
  181. </div>
  182. </div>
  183. <h3 class="name name-method" id="pose" translate="no">.<a href="#pose">pose</a><span class="signature">()</span> </h3>
  184. <div class="method">
  185. <div class="description">
  186. <p>Resets the skeleton to the base pose.</p>
  187. </div>
  188. </div>
  189. <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>
  190. <div class="method">
  191. <div class="description">
  192. <p>Serializes the skeleton into JSON.</p>
  193. </div>
  194. <dl class="details">
  195. <dt class="tag-see">See:</dt>
  196. <dd class="tag-see">
  197. <ul>
  198. <li><a href="ObjectLoader.html#parse">ObjectLoader#parse</a></li>
  199. </ul>
  200. </dd>
  201. </dl>
  202. <dl class="details">
  203. <dt class="tag-returns"><strong>Returns:</strong> A JSON object representing the serialized skeleton.</dt>
  204. </dl>
  205. </div>
  206. <h3 class="name name-method" id="update" translate="no">.<a href="#update">update</a><span class="signature">()</span> </h3>
  207. <div class="method">
  208. <div class="description">
  209. <p>Resets the skeleton to the base pose.</p>
  210. </div>
  211. </div>
  212. <h2 class="subsection-title">Source</h2>
  213. <p>
  214. <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>
  215. </p>
  216. </article>
  217. </section>
  218. <script src="../scripts/linenumber.js"></script>
  219. <script src="../scripts/page.js"></script>
  220. </body>
  221. </html>
粤ICP备19079148号