2
0

MMDAnimationHelper.html 5.6 KB

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