AnimationMixer.html 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <base href="../../" />
  6. <script src="list.js"></script>
  7. <script src="page.js"></script>
  8. <link type="text/css" rel="stylesheet" href="page.css" />
  9. </head>
  10. <body>
  11. <h1>[name]</h1>
  12. <div class="desc">
  13. The AnimationMixer is a player for animations on a particular object in the scene.
  14. </div>
  15. <p>
  16. Each available animation sequence is stored as an [page:AnimationClip AnimationClip], and
  17. playback of that clip is controlled with an [page:AnimationClip AnimationAction]. When multiple
  18. objects in the scene are animated independently, one AnimationMixer may be used for each object.
  19. </p>
  20. <h2>Example</h2>
  21. <p>
  22. When loading a 3D model that includes animation, many loaders also return a list of
  23. [page:AnimationClip AnimationClip] instances. Each clip represents a specific animation
  24. sequence, and may be played or paused individually.
  25. </p>
  26. <code>
  27. var mesh;
  28. // Create an AnimationMixer, and get the list of AnimationClip instances
  29. var mixer = new THREE.AnimationMixer( mesh );
  30. var clips = mesh.animations;
  31. // Update the mixer on each frame
  32. function update () {
  33. mixer.update( deltaSeconds );
  34. }
  35. // Play a specific animation
  36. var clip = THREE.AnimationClip.findByName( clips, 'dance' );
  37. var action = mixer.clipAction(clip);
  38. action.play();
  39. // Play all animations
  40. clips.forEach( function (clip) {
  41. mixer.clipAction(clip).play();
  42. } );
  43. </code>
  44. <p>
  45. Note that not all model formats include animation (OBJ notably does not), and that only some
  46. THREE.js loaders support [page:AnimationClip AnimationClip] sequences. Several that <i>do</i>
  47. support this animation type:
  48. </p>
  49. <ul>
  50. <li>[page:ObjectLoader THREE.ObjectLoader]</li>
  51. <li>THREE.BVHLoader</li>
  52. <li>THREE.FBXLoader</li>
  53. <li>THREE.FBXLoader2</li>
  54. <li>[page:GLTFLoader THREE.GLTFLoader]</li>
  55. <li>THREE.MMDLoader</li>
  56. <li>THREE.SEA3DLoader</li>
  57. </ul>
  58. <h2>Constructor</h2>
  59. <h3>[name]( [page:Object3D root] )</h3>
  60. <h2>Properties</h2>
  61. <h3>[property:Number time]</h3>
  62. <h3>[property:Number timeScale]</h3>
  63. <h2>Methods</h2>
  64. <h3>[method:AnimationAction clipAction]([page:AnimationClip clip], [page:Object3D optionalRoot])</h3>
  65. <div>
  66. clip -- AnimationClip <br />
  67. optionalRoot -- Object3D
  68. </div>
  69. <div>
  70. Return an action for a clip, optionally using a custom root target object.
  71. </div>
  72. <h3>[method:AnimationAction existingAction]([page:AnimationClip clip], [page:Object3D optionalRoot])</h3>
  73. <div>
  74. clip -- AnimationClip <br />
  75. optionalRoot -- Object3D
  76. </div>
  77. <div>
  78. Return an existing action.
  79. </div>
  80. <h3>[method:AnimationMixer stopAllAction]()</h3>
  81. <div>
  82. Deactivates all scheduled actions.
  83. </div>
  84. <h3>[method:AnimationMixer update]([page:Number deltaTimeMS]) </h3>
  85. <div>
  86. deltaTimeMS -- Time elapsed since last update in milliseconds.
  87. </div>
  88. <div>
  89. Updates the animation with deltaTimeMS.
  90. </div>
  91. <h3>[method:Object3D getRoot]()</h3>
  92. <div>
  93. Return this mixer's root target object.
  94. </div>
  95. <h3>[method:null uncacheClip]([page:AnimationClip clip])</h3>
  96. <div>
  97. clip -- AnimationClip
  98. </div>
  99. <div>
  100. Free all resources for a clip.
  101. </div>
  102. <h3>[method:null uncacheRoot]([page:Object3D root]) </h3>
  103. <div>
  104. root -- Object3D
  105. </div>
  106. <div>
  107. Free all resources for a root target object.
  108. </div>
  109. <h3>[method:null uncacheAction]([page:AnimationClip clip], [page:Object3D optionalRoot])</h3>
  110. <div>
  111. clip -- AnimationClip <br />
  112. optionalRoot -- Object3D
  113. </div>
  114. <div>
  115. Free all resources for an action.
  116. </div>
  117. <h2>Source</h2>
  118. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  119. </body>
  120. </html>