MMDLoader.html 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. [page:Loader] &rarr;
  11. <h1>[name]</h1>
  12. <p class="desc"> A loader for <a href="https://sites.google.com/view/evpvp/">`MMD`</a> resources. <br /><br />
  13. [name] creates Three.js Objects from MMD resources as PMD, PMX, VMD, and VPD files.
  14. See [page:MMDAnimationHelper] for MMD animation handling as IK, Grant, and Physics.<br /><br />
  15. If you want raw content of MMD resources, use .loadPMD/PMX/VMD/VPD methods.</p>
  16. <h2>Import</h2>
  17. <p>
  18. [name] is an add-on, and must be imported explicitly.
  19. See [link:#manual/introduction/Installation Installation / Addons].
  20. </p>
  21. <code>
  22. import { MMDLoader } from 'three/addons/loaders/MMDLoader.js';
  23. </code>
  24. <h2>Code Example</h2>
  25. <code>
  26. // Instantiate a loader
  27. const loader = new MMDLoader();
  28. // Load a MMD model
  29. loader.load(
  30. // path to PMD/PMX file
  31. 'models/mmd/miku.pmd',
  32. // called when the resource is loaded
  33. function ( mesh ) {
  34. scene.add( mesh );
  35. },
  36. // called when loading is in progresses
  37. function ( xhr ) {
  38. console.log( ( xhr.loaded / xhr.total * 100 ) + '% loaded' );
  39. },
  40. // called when loading has errors
  41. function ( error ) {
  42. console.log( 'An error happened' );
  43. }
  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:LoadingManager manager] )</h3>
  54. <p>
  55. [page:LoadingManager manager] — The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].
  56. </p>
  57. <p>
  58. Creates a new [name].
  59. </p>
  60. <h2>Properties</h2>
  61. <p>See the base [page:Loader] class for common properties.</p>
  62. <h2>Methods</h2>
  63. <p>See the base [page:Loader] class for common methods.</p>
  64. <h3>[method:undefined load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
  65. <p>
  66. [page:String url] — A string containing the path/URL of the `.pmd` or `.pmx` file.<br />
  67. [page:Function onLoad] — A function to be called after the loading is successfully completed.<br />
  68. [page:Function onProgress] — (optional) A function to be called while the loading is in progress. The argument will be the XMLHttpRequest instance, that contains .[page:Integer total] and .[page:Integer loaded] bytes. If the server does not set the Content-Length header; .[page:Integer total] will be 0.<br />
  69. [page:Function onError] — (optional) A function to be called if an error occurs during loading. The function receives error as an argument.<br />
  70. </p>
  71. <p>
  72. Begin loading PMD/PMX model file from url and fire the callback function with the parsed [page:SkinnedMesh] containing [page:BufferGeometry] and an array of [page:MeshToonMaterial].
  73. </p>
  74. <h3>[method:undefined loadAnimation]( [param:String url], [param:Object3D object], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
  75. <p>
  76. [page:String url] — A string or an array of string containing the path/URL of the `.vmd` file(s).If two or more files are specified, they'll be merged.<br />
  77. [page:Object3D object] — [page:SkinnedMesh] or [page:Camera]. Clip and its tracks will be fitting to this object.<br />
  78. [page:Function onLoad] — A function to be called after the loading is successfully completed.<br />
  79. [page:Function onProgress] — (optional) A function to be called while the loading is in progress. The argument will be the XMLHttpRequest instance, that contains .[page:Integer total] and .[page:Integer loaded] bytes.<br />
  80. [page:Function onError] — (optional) A function to be called if an error occurs during loading. The function receives error as an argument.<br />
  81. </p>
  82. <p>
  83. Begin loading VMD motion file(s) from url(s) and fire the callback function with the parsed [page:AnimationClip].
  84. </p>
  85. <h3>[method:undefined loadWithAnimation]( [param:String modelUrl], [param:String vmdUrl], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
  86. <p>
  87. [page:String modelUrl] — A string containing the path/URL of the `.pmd` or `.pmx` file.<br />
  88. [page:String vmdUrl] — A string or an array of string containing the path/URL of the `.vmd` file(s).<br />
  89. [page:Function onLoad] — A function to be called after the loading is successfully completed.<br />
  90. [page:Function onProgress] — (optional) A function to be called while the loading is in progress. The argument will be the XMLHttpRequest instance, that contains .[page:Integer total] and .[page:Integer loaded] bytes.<br />
  91. [page:Function onError] — (optional) A function to be called if an error occurs during loading. The function receives error as an argument.<br />
  92. </p>
  93. <p>
  94. Begin loading PMD/PMX model file and VMD motion file(s) from urls and fire the callback function with an [page:Object] containing parsed [page:SkinnedMesh] and [page:AnimationClip] fitting to the [page:SkinnedMesh].
  95. </p>
  96. <h3>[method:this setAnimationPath]( [param:String animationPath] )</h3>
  97. <p>
  98. [page:String animationPath] — Base path for loading animation data (VMD/VPD files).
  99. </p>
  100. <p>
  101. Set the base path for additional resources like textures.
  102. </p>
  103. <h2>Source</h2>
  104. <p>
  105. [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/MMDLoader.js examples/jsm/loaders/MMDLoader.js]
  106. </p>
  107. </body>
  108. </html>