MMDPhysics.html 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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 Physics handler for <a href="https://sites.google.com/view/evpvp/">`MMD`</a> resources. <br /><br />
  12. [name] calculates Physics for model loaded by [page:MMDLoader] with [link:https://github.com/kripken/ammo.js/ ammo.js] (Bullet-based JavaScript Physics engine).
  13. </p>
  14. <h2>Import</h2>
  15. <p>
  16. [name] is an add-on, and must be imported explicitly.
  17. See [link:#manual/introduction/Installation Installation / Addons].
  18. </p>
  19. <code>
  20. import { MMDPhysics } from 'three/addons/animation/MMDPhysics.js';
  21. </code>
  22. <h2>Code Example</h2>
  23. <code>
  24. let physics;
  25. // Load MMD resources and instantiate MMDPhysics
  26. new MMDLoader().load(
  27. 'models/mmd/miku.pmd',
  28. function ( mesh ) {
  29. physics = new MMDPhysics( mesh )
  30. scene.add( mesh );
  31. }
  32. );
  33. function render() {
  34. const delta = clock.getDelta();
  35. animate( delta ); // update bones
  36. if ( physics !== undefined ) physics.update( delta );
  37. renderer.render( scene, camera );
  38. }
  39. </code>
  40. <h2>Examples</h2>
  41. <p>
  42. [example:webgl_loader_mmd]<br />
  43. [example:webgl_loader_mmd_audio]
  44. </p>
  45. <h2>Constructor</h2>
  46. <h3>[name]( [param:SkinnedMesh mesh], [param:Array rigidBodyParams], [param:Array constraintParams], [param:Object params] )</h3>
  47. <p>
  48. [page:SkinnedMesh mesh] — [page:SkinnedMesh] for which [name] calculates Physics.<br />
  49. [page:Array rigidBodyParams] — An array of [page:Object] specifying Rigid Body parameters.<br />
  50. [page:Array constraintParams] — (optional) An array of [page:Object] specifying Constraint parameters.<br />
  51. [page:Object params] — (optional)<br />
  52. </p>
  53. <ul>
  54. <li>[page:Number unitStep] - Default is 1 / 65.</li>
  55. <li>[page:Integer maxStepNum] - Default is 3.</li>
  56. <li>[page:Vector3 gravity] - Default is ( 0, - 9.8 * 10, 0 )</li>
  57. </ul>
  58. <p>
  59. Creates a new [name].
  60. </p>
  61. <h2>Properties</h2>
  62. <h3>[property:Array mesh]</h3>
  63. <p>[page:SkinnedMesh] passed to the constructor.</p>
  64. <h2>Methods</h2>
  65. <h3>[method:MMDPhysicsHelper createHelper]()</h3>
  66. <p>
  67. Return [page:MMDPhysicsHelper]. You can visualize Rigid bodies by adding the helper to scene.
  68. </p>
  69. <h3>[method:this reset]()</h3>
  70. <p>
  71. Resets Rigid bodies transform to current bone's.
  72. </p>
  73. <h3>[method:this setGravity]( [param:Vector3 gravity] )</h3>
  74. <p>
  75. [page:Vector3 gravity] — Direction and volume of gravity.
  76. </p>
  77. <p>
  78. Set gravity.
  79. </p>
  80. <h3>[method:this update]( [param:Number delta] )</h3>
  81. <p>
  82. [page:Number delta] — Time in second.
  83. </p>
  84. <p>
  85. Advance Physics calculation and updates bones.
  86. </p>
  87. <h3>[method:this warmup]( [param:Integer cycles] )</h3>
  88. <p>
  89. [page:Number delta] — Time in second.
  90. </p>
  91. <p>
  92. Warm up Rigid bodies. Calculates cycles steps.
  93. </p>
  94. <h2>Source</h2>
  95. <p>
  96. [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/animation/MMDPhysics.js examples/jsm/animation/MMDPhysics.js]
  97. </p>
  98. </body>
  99. </html>