MMDAnimationHelper.html 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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. <p class="desc"> A animation helper for <a href="http://www.geocities.jp/higuchuu4/index_e.htm"><em>MMD</em></a> resources. <br /><br />
  13. [name] handles animation of MMD assets loaded by [page:MMDLoader] with MMD special features as IK, Grant, and Physics.
  14. It uses [page:CCDIKSolver] and [page:MMDPhysics] inside.
  15. </p>
  16. <h2>Example</h2>
  17. <code>
  18. // Instantiate a helper
  19. var helper = new THREE.MMDAnimationHelper();
  20. // Load MMD resources and add to helper
  21. new THREE.MMDLoader().loadWithAnimation(
  22. 'models/mmd/miku.pmd',
  23. 'models/mmd/dance.vmd',
  24. function ( mmd ) {
  25. helper.add( mmd.mesh, {
  26. animation: mmd.animation,
  27. physics: true
  28. } );
  29. scene.add( mmd.mesh );
  30. new THREE.AudioLoader().load(
  31. 'audios/mmd/song.mp3',
  32. function ( buffer ) {
  33. var listener = new THREE.AudioListener();
  34. var audio = new THREE.Audio( listener )
  35. .setBuffer( buffer );
  36. listener.position.z = 1;
  37. scene.add( audio );
  38. scene.add( listener );
  39. }
  40. );
  41. }
  42. );
  43. function render() {
  44. helper.update( clock.getDelta() );
  45. renderer.render( scene, camera );
  46. }
  47. </code>
  48. [example:webgl_loader_mmd]<br />
  49. [example:webgl_loader_mmd_pose]<br />
  50. [example:webgl_loader_mmd_audio]<br />
  51. <br />
  52. <hr>
  53. <h2>Constructor</h2>
  54. <h3>[name]( [param:Object params] )</h3>
  55. <p>
  56. [page:Object params] — (optional)<br />
  57. <ul>
  58. <li> [page:Boolean sync] - Whether animation durations of added objects are synched. Default is true.</li>
  59. <li> [page:Number afterglow] - Default is 0.0.</li>
  60. <li> [page:Boolean resetPhysicsOnLoop] - Default is true.</li>
  61. </ul>
  62. </p>
  63. <p>
  64. Creates a new [name].
  65. </p>
  66. <h2>Properties</h2>
  67. <h3>[property:Audio audio]</h3>
  68. <p>An [page:Audio] added to helper.</p>
  69. <h3>[property:Camera camera]</h3>
  70. <p>An [page:Camera] added to helper.</p>
  71. <h3>[property:Array meshes]</h3>
  72. <p>An array of [page:SkinnedMesh] added to helper.</p>
  73. <h3>[property:WeakMap objects]</h3>
  74. <p>A [page:WeakMap] which holds animation stuffs used in helper for objects added to helper. For example, you can access [page:AnimationMixer] for an added [page:SkinnedMesh] with "helper.objects.get( mesh ).mixer"</p>
  75. <h3>[property:function onBeforePhysics]</h3>
  76. <p>An optional callback that is executed immediately before the physicis calculation for an [page:SkinnedMesh]. This function is called with the [page:SkinnedMesh].</p>
  77. <h2>Methods</h2>
  78. <h3>[method:MMDAnimationHelper add]( [param:Object3D object], [param:Object params] )</h3>
  79. <p>
  80. [page:Object3D object] — [page:SkinnedMesh], [page:Camera], or [page:Audio]<br />
  81. [page:Object params] — (optional)<br />
  82. <ul>
  83. <li>[page:AnimationClip animation] - an [page:AnimationClip] or an array of [page:AnimationClip] set to object. Only for [page:SkinnedMesh] and [page:Camera]. Default is undefined.</li>
  84. <li>[page:Boolean physics] - Only for [page:SkinnedMesh]. A flag whether turn on physics. Default is true.</li>
  85. <li>[page:Integer warmup] - Only for [page:SkinnedMesh] and physics is true. Physics parameter. Default is 60.</li>
  86. <li>[page:Number unitStep] - Only for [page:SkinnedMesh] and physics is true. Physics parameter. Default is 1 / 65.</li>
  87. <li>[page:Integer maxStepNum] - Only for [page:SkinnedMesh] and physics is true. Physics parameter. Default is 3.</li>
  88. <li>[page:Vector3 gravity] - Only for [page:SkinnedMesh] and physics is true. Physics parameter. Default is ( 0, - 9.8 * 10, 0 ).</li>
  89. <li>[page:Number delayTime] - Only for [page:Audio]. Default is 0.0.</li>
  90. </ul>
  91. </p>
  92. <p>
  93. Add an [page:SkinnedMesh], [page:Camera], or [page:Audio] to helper and setup animation. The anmation durations of added objects are synched.
  94. If camera/audio has already been added, it'll be replaced with a new one.
  95. </p>
  96. <h3>[method:MMDAnimationHelper enable]( [param:string key], [param:Boolean enabled] )</h3>
  97. <p>
  98. [page:string key] — Allowed strings are 'animation', 'ik', 'grant', 'physics', and 'cameraAnimation'.<br />
  99. [page:Boolean enabled] — true is enable, false is disable<br />
  100. </p>
  101. <p>
  102. Enable/Disable an animation feature
  103. </p>
  104. <h3>[method:MMDAnimationHelper pose]( [param:SkinnedMesh mesh], [param:Object vpd], [param:Object params] )</h3>
  105. <p>
  106. [page:SkinnedMesh mesh] — [page:SkinnedMesh] which changes the posing. It doesn't need to be added to helper.<br />
  107. [page:Object vpd] — VPD content obtained by [page:MMDLoader].loadVPD<br />
  108. [page:Object params] — (optional)<br />
  109. <ul>
  110. <li>[page:Boolean resetPose] - Default is true.</li>
  111. <li>[page:Boolean ik] - Default is true.</li>
  112. <li>[page:Boolean grant] - Default is true.</li>
  113. </ul>
  114. </p>
  115. <p>
  116. Changes the posing of [page:SkinnedMesh] as VPD content specifies.
  117. </p>
  118. <h3>[method:MMDAnimationHelper remove]( [param:Object3D object] )</h3>
  119. <p>
  120. [page:Object3D object] — [page:SkinnedMesh], [page:Camera], or [page:Audio]<br />
  121. </p>
  122. <p>
  123. Remove an [page:SkinnedMesh], [page:Camera], or [page:Audio] from helper.
  124. </p>
  125. <h3>[method:MMDAnimationHelper update]( [param:Nummber delta] )</h3>
  126. <p>
  127. [page:Number delta] — number in second<br />
  128. </p>
  129. <p>
  130. Advance mixer time and update the animations of objects added to helper
  131. </p>
  132. <h2>Source</h2>
  133. <p>
  134. [link:https://github.com/mrdoob/three.js/blob/master/examples/js/animation/MMDAnimationHelper.js examples/js/animation/MMDAnimationHelper.js]
  135. </p>
  136. </body>
  137. </html>