AnimationMixer.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>AnimationMixer - 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">AnimationMixer</h1>
  13. <section>
  14. <header>
  15. <div class="class-description"><p><code>AnimationMixer</code> is a player for animations on a particular object in
  16. the scene. When multiple objects in the scene are animated independently,
  17. one <code>AnimationMixer</code> may be used for each object.</p></div>
  18. </header>
  19. <article>
  20. <div class="container-overview">
  21. <h2>Constructor</h2>
  22. <h3 class="name name-method" id="AnimationMixer" translate="no">new <a href="#AnimationMixer">AnimationMixer</a><span class="signature">( root : <span class="param-type"><a href="Object3D.html">Object3D</a></span> )</span> </h3>
  23. <div class="method">
  24. <div class="description">
  25. <p>Constructs a new animation mixer.</p>
  26. </div>
  27. <table class="params">
  28. <tbody>
  29. <tr>
  30. <td class="name">
  31. <strong>root</strong>
  32. </td>
  33. <td class="description last">
  34. <p>The object whose animations shall be played by this mixer.</p>
  35. </td>
  36. </tr>
  37. </tbody>
  38. </table>
  39. </div>
  40. </div>
  41. <h2 class="subsection-title">Properties</h2>
  42. <div class="member">
  43. <h3 class="name" id="time" translate="no">.<a href="#time">time</a><span class="type-signature"> : number</span> </h3>
  44. <div class="description">
  45. <p>The global mixer time (in seconds; starting with <code>0</code> on the mixer's creation).</p>
  46. <p>Default is <code>0</code>.</p>
  47. </div>
  48. </div>
  49. <div class="member">
  50. <h3 class="name" id="timeScale" translate="no">.<a href="#timeScale">timeScale</a><span class="type-signature"> : number</span> </h3>
  51. <div class="description">
  52. <p>A scaling factor for the global time.</p>
  53. <p>Note: Setting this member to <code>0</code> and later back to <code>1</code> is a
  54. possibility to pause/unpause all actions that are controlled by this
  55. mixer.</p>
  56. <p>Default is <code>1</code>.</p>
  57. </div>
  58. </div>
  59. <h2 class="subsection-title">Methods</h2>
  60. <h3 class="name name-method" id="clipAction" translate="no">.<a href="#clipAction">clipAction</a><span class="signature">( clip : <span class="param-type"><a href="AnimationClip.html">AnimationClip</a> | string</span>, optionalRoot : <span class="param-type"><a href="Object3D.html">Object3D</a></span>, blendMode : <span class="param-type"><a href="global.html#NormalAnimationBlendMode">NormalAnimationBlendMode</a> | <a href="global.html#AdditiveAnimationBlendMode">AdditiveAnimationBlendMode</a></span> )</span><span class="type-signature"> : <a href="AnimationAction.html">AnimationAction</a></span> </h3>
  61. <div class="method">
  62. <div class="description">
  63. <p>Returns an instance of <a href="AnimationAction.html">AnimationAction</a> for the passed clip.</p>
  64. <p>If an action fitting the clip and root parameters doesn't yet exist, it
  65. will be created by this method. Calling this method several times with the
  66. same clip and root parameters always returns the same action.</p>
  67. </div>
  68. <table class="params">
  69. <tbody>
  70. <tr>
  71. <td class="name">
  72. <strong>clip</strong>
  73. </td>
  74. <td class="description last">
  75. <p>An animation clip or alternatively the name of the animation clip.</p>
  76. </td>
  77. </tr>
  78. <tr>
  79. <td class="name">
  80. <strong>optionalRoot</strong>
  81. </td>
  82. <td class="description last">
  83. <p>An alternative root object.</p>
  84. </td>
  85. </tr>
  86. <tr>
  87. <td class="name">
  88. <strong>blendMode</strong>
  89. </td>
  90. <td class="description last">
  91. <p>The blend mode.</p>
  92. </td>
  93. </tr>
  94. </tbody>
  95. </table>
  96. <dl class="details">
  97. <dt class="tag-returns"><strong>Returns:</strong> The animation action.</dt>
  98. </dl>
  99. </div>
  100. <h3 class="name name-method" id="existingAction" translate="no">.<a href="#existingAction">existingAction</a><span class="signature">( clip : <span class="param-type"><a href="AnimationClip.html">AnimationClip</a> | string</span>, optionalRoot : <span class="param-type"><a href="Object3D.html">Object3D</a></span> )</span><span class="type-signature"> : <a href="AnimationAction.html">AnimationAction</a></span> </h3>
  101. <div class="method">
  102. <div class="description">
  103. <p>Returns an existing animation action for the passed clip.</p>
  104. </div>
  105. <table class="params">
  106. <tbody>
  107. <tr>
  108. <td class="name">
  109. <strong>clip</strong>
  110. </td>
  111. <td class="description last">
  112. <p>An animation clip or alternatively the name of the animation clip.</p>
  113. </td>
  114. </tr>
  115. <tr>
  116. <td class="name">
  117. <strong>optionalRoot</strong>
  118. </td>
  119. <td class="description last">
  120. <p>An alternative root object.</p>
  121. </td>
  122. </tr>
  123. </tbody>
  124. </table>
  125. <dl class="details">
  126. <dt class="tag-returns"><strong>Returns:</strong> The animation action. Returns <code>null</code> if no action was found.</dt>
  127. </dl>
  128. </div>
  129. <h3 class="name name-method" id="getRoot" translate="no">.<a href="#getRoot">getRoot</a><span class="signature">()</span><span class="type-signature"> : <a href="Object3D.html">Object3D</a></span> </h3>
  130. <div class="method">
  131. <div class="description">
  132. <p>Returns this mixer's root object.</p>
  133. </div>
  134. <dl class="details">
  135. <dt class="tag-returns"><strong>Returns:</strong> The mixer's root object.</dt>
  136. </dl>
  137. </div>
  138. <h3 class="name name-method" id="setTime" translate="no">.<a href="#setTime">setTime</a><span class="signature">( time : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="AnimationMixer.html">AnimationMixer</a></span> </h3>
  139. <div class="method">
  140. <div class="description">
  141. <p>Sets the global mixer to a specific time and updates the animation accordingly.</p>
  142. <p>This is useful when you need to jump to an exact time in an animation. The
  143. input parameter will be scaled by <a href="AnimationMixer.html#timeScale">AnimationMixer#timeScale</a></p>
  144. </div>
  145. <table class="params">
  146. <tbody>
  147. <tr>
  148. <td class="name">
  149. <strong>time</strong>
  150. </td>
  151. <td class="description last">
  152. <p>The time to set in seconds.</p>
  153. </td>
  154. </tr>
  155. </tbody>
  156. </table>
  157. <dl class="details">
  158. <dt class="tag-returns"><strong>Returns:</strong> A reference to this animation mixer.</dt>
  159. </dl>
  160. </div>
  161. <h3 class="name name-method" id="stopAllAction" translate="no">.<a href="#stopAllAction">stopAllAction</a><span class="signature">()</span><span class="type-signature"> : <a href="AnimationMixer.html">AnimationMixer</a></span> </h3>
  162. <div class="method">
  163. <div class="description">
  164. <p>Deactivates all previously scheduled actions on this mixer.</p>
  165. </div>
  166. <dl class="details">
  167. <dt class="tag-returns"><strong>Returns:</strong> A reference to this animation mixer.</dt>
  168. </dl>
  169. </div>
  170. <h3 class="name name-method" id="uncacheAction" translate="no">.<a href="#uncacheAction">uncacheAction</a><span class="signature">( clip : <span class="param-type"><a href="AnimationClip.html">AnimationClip</a> | string</span>, optionalRoot : <span class="param-type"><a href="Object3D.html">Object3D</a></span> )</span> </h3>
  171. <div class="method">
  172. <div class="description">
  173. <p>Deallocates all memory resources for an action. The action is identified by the
  174. given clip and an optional root object. Before using this method make
  175. sure to call <a href="AnimationAction.html#stop">AnimationAction#stop</a> to deactivate the action.</p>
  176. </div>
  177. <table class="params">
  178. <tbody>
  179. <tr>
  180. <td class="name">
  181. <strong>clip</strong>
  182. </td>
  183. <td class="description last">
  184. <p>An animation clip or alternatively the name of the animation clip.</p>
  185. </td>
  186. </tr>
  187. <tr>
  188. <td class="name">
  189. <strong>optionalRoot</strong>
  190. </td>
  191. <td class="description last">
  192. <p>An alternative root object.</p>
  193. </td>
  194. </tr>
  195. </tbody>
  196. </table>
  197. </div>
  198. <h3 class="name name-method" id="uncacheClip" translate="no">.<a href="#uncacheClip">uncacheClip</a><span class="signature">( clip : <span class="param-type"><a href="AnimationClip.html">AnimationClip</a></span> )</span> </h3>
  199. <div class="method">
  200. <div class="description">
  201. <p>Deallocates all memory resources for a clip. Before using this method make
  202. sure to call <a href="AnimationAction.html#stop">AnimationAction#stop</a> for all related actions.</p>
  203. </div>
  204. <table class="params">
  205. <tbody>
  206. <tr>
  207. <td class="name">
  208. <strong>clip</strong>
  209. </td>
  210. <td class="description last">
  211. <p>The clip to uncache.</p>
  212. </td>
  213. </tr>
  214. </tbody>
  215. </table>
  216. </div>
  217. <h3 class="name name-method" id="uncacheRoot" translate="no">.<a href="#uncacheRoot">uncacheRoot</a><span class="signature">( root : <span class="param-type"><a href="Object3D.html">Object3D</a></span> )</span> </h3>
  218. <div class="method">
  219. <div class="description">
  220. <p>Deallocates all memory resources for a root object. Before using this
  221. method make sure to call <a href="AnimationAction.html#stop">AnimationAction#stop</a> for all related
  222. actions or alternatively <a href="AnimationMixer.html#stopAllAction">AnimationMixer#stopAllAction</a> when the
  223. mixer operates on a single root.</p>
  224. </div>
  225. <table class="params">
  226. <tbody>
  227. <tr>
  228. <td class="name">
  229. <strong>root</strong>
  230. </td>
  231. <td class="description last">
  232. <p>The root object to uncache.</p>
  233. </td>
  234. </tr>
  235. </tbody>
  236. </table>
  237. </div>
  238. <h3 class="name name-method" id="update" translate="no">.<a href="#update">update</a><span class="signature">( deltaTime : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="AnimationMixer.html">AnimationMixer</a></span> </h3>
  239. <div class="method">
  240. <div class="description">
  241. <p>Advances the global mixer time and updates the animation.</p>
  242. <p>This is usually done in the render loop by passing the delta
  243. time from <a href="Clock.html">Clock</a> or <a href="Timer.html">Timer</a>.</p>
  244. </div>
  245. <table class="params">
  246. <tbody>
  247. <tr>
  248. <td class="name">
  249. <strong>deltaTime</strong>
  250. </td>
  251. <td class="description last">
  252. <p>The delta time in seconds.</p>
  253. </td>
  254. </tr>
  255. </tbody>
  256. </table>
  257. <dl class="details">
  258. <dt class="tag-returns"><strong>Returns:</strong> A reference to this animation mixer.</dt>
  259. </dl>
  260. </div>
  261. <h2 class="subsection-title">Source</h2>
  262. <p>
  263. <a href="https://github.com/mrdoob/three.js/blob/master/src/animation/AnimationMixer.js" translate="no" target="_blank" rel="noopener">src/animation/AnimationMixer.js</a>
  264. </p>
  265. </article>
  266. </section>
  267. <script src="../scripts/linenumber.js"></script>
  268. <script src="../scripts/page.js"></script>
  269. </body>
  270. </html>
粤ICP备19079148号