MaterialLoader.html 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>MaterialLoader - Three.js Docs</title>
  6. <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
  7. <script src="../scripts/highlight.min.js"></script>
  8. <link type="text/css" rel="stylesheet" href="../styles/highlight-three.css">
  9. <link type="text/css" rel="stylesheet" href="../styles/page.css">
  10. </head>
  11. <body>
  12. <p class="inheritance" translate="no"><a href="Loader.html">Loader</a> → </p>
  13. <h1 translate="no">MaterialLoader</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>Class for loading geometries. The files are internally
  17. loaded via <a href="FileLoader.html">FileLoader</a>.</p>
  18. <p>This loader does not support node materials. Use <a href="NodeMaterialLoader.html">NodeMaterialLoader</a> instead.</p></div>
  19. <h2>Code Example</h2>
  20. <div translate="no"><pre><code class="language-js">const loader = new THREE.MaterialLoader();
  21. const material = await loader.loadAsync( 'material.json' );
  22. </code></pre></div>
  23. </header>
  24. <article>
  25. <div class="container-overview">
  26. <h2>Constructor</h2>
  27. <h3 class="name name-method" id="MaterialLoader" translate="no">new <a href="#MaterialLoader">MaterialLoader</a><span class="signature">( manager : <span class="param-type">LoadingManager</span> )</span> </h3>
  28. <div class="method">
  29. <div class="description">
  30. <p>Constructs a new material loader.</p>
  31. </div>
  32. <table class="params">
  33. <tbody>
  34. <tr>
  35. <td class="name"><code>manager</code></td>
  36. <td class="description last"><p>The loading manager.</p></td>
  37. </tr>
  38. </tbody>
  39. </table>
  40. </div>
  41. </div>
  42. <h2 class="subsection-title">Properties</h2>
  43. <div class="member">
  44. <h3 class="name" id="textures" translate="no">.<a href="#textures">textures</a><span class="type-signature"> : Object.&lt;string, <a href="Texture.html">Texture</a>></span> </h3>
  45. <div class="description">
  46. <p>A dictionary holding textures used by the material.</p>
  47. </div>
  48. </div>
  49. <h2 class="subsection-title">Methods</h2>
  50. <h3 class="name name-method" id="createMaterialFromType" translate="no">.<a href="#createMaterialFromType">createMaterialFromType</a><span class="signature">( type : <span class="param-type">string</span> )</span><span class="type-signature"> : <a href="Material.html">Material</a></span> </h3>
  51. <div class="method">
  52. <div class="description">
  53. <p>Creates a material for the given type.</p>
  54. </div>
  55. <table class="params">
  56. <tbody>
  57. <tr>
  58. <td class="name"><code>type</code></td>
  59. <td class="description last"><p>The material type.</p></td>
  60. </tr>
  61. </tbody>
  62. </table>
  63. <dl class="details">
  64. <dt class="tag-returns"><strong>Returns:</strong> The new material.</dt>
  65. </dl>
  66. </div>
  67. <h3 class="name name-method" id="load" translate="no">.<a href="#load">load</a><span class="signature">( url : <span class="param-type">string</span>, onLoad : <span class="param-type">function</span>, onProgress : <span class="param-type">onProgressCallback</span>, onError : <span class="param-type">onErrorCallback</span> )</span> </h3>
  68. <div class="method">
  69. <div class="description">
  70. <p>Starts loading from the given URL and pass the loaded material to the <code>onLoad()</code> callback.</p>
  71. </div>
  72. <table class="params">
  73. <tbody>
  74. <tr>
  75. <td class="name"><code>url</code></td>
  76. <td class="description last"><p>The path/URL of the file to be loaded. This can also be a data URI.</p></td>
  77. </tr>
  78. <tr>
  79. <td class="name"><code>onLoad</code></td>
  80. <td class="description last"><p>Executed when the loading process has been finished.</p></td>
  81. </tr>
  82. <tr>
  83. <td class="name"><code>onProgress</code></td>
  84. <td class="description last"><p>Executed while the loading is in progress.</p></td>
  85. </tr>
  86. <tr>
  87. <td class="name"><code>onError</code></td>
  88. <td class="description last"><p>Executed when errors occur.</p></td>
  89. </tr>
  90. </tbody>
  91. </table>
  92. <dl class="details">
  93. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Loader.html#load">Loader#load</a></dt>
  94. </dl>
  95. </div>
  96. <h3 class="name name-method" id="parse" translate="no">.<a href="#parse">parse</a><span class="signature">( json : <span class="param-type">Object</span> )</span><span class="type-signature"> : <a href="Material.html">Material</a></span> </h3>
  97. <div class="method">
  98. <div class="description">
  99. <p>Parses the given JSON object and returns a material.</p>
  100. </div>
  101. <table class="params">
  102. <tbody>
  103. <tr>
  104. <td class="name"><code>json</code></td>
  105. <td class="description last"><p>The serialized material.</p></td>
  106. </tr>
  107. </tbody>
  108. </table>
  109. <dl class="details">
  110. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Loader.html#parse">Loader#parse</a></dt>
  111. </dl>
  112. <dl class="details">
  113. <dt class="tag-returns"><strong>Returns:</strong> The parsed material.</dt>
  114. </dl>
  115. </div>
  116. <h3 class="name name-method" id="setTextures" translate="no">.<a href="#setTextures">setTextures</a><span class="signature">( value : <span class="param-type">Object</span> )</span><span class="type-signature"> : <a href="MaterialLoader.html">MaterialLoader</a></span> </h3>
  117. <div class="method">
  118. <div class="description">
  119. <p>Textures are not embedded in the material JSON so they have
  120. to be injected before the loading process starts.</p>
  121. </div>
  122. <table class="params">
  123. <tbody>
  124. <tr>
  125. <td class="name"><code>value</code></td>
  126. <td class="description last"><p>A dictionary holding textures for material properties.</p></td>
  127. </tr>
  128. </tbody>
  129. </table>
  130. <dl class="details">
  131. <dt class="tag-returns"><strong>Returns:</strong> A reference to this material loader.</dt>
  132. </dl>
  133. </div>
  134. <h2 class="subsection-title">Static Methods</h2>
  135. <h3 class="name name-method" id=".createMaterialFromType" translate="no">.<a href="#.createMaterialFromType">createMaterialFromType</a><span class="signature">( type : <span class="param-type">string</span> )</span><span class="type-signature"> : <a href="Material.html">Material</a></span> </h3>
  136. <div class="method">
  137. <div class="description">
  138. <p>Creates a material for the given type.</p>
  139. </div>
  140. <table class="params">
  141. <tbody>
  142. <tr>
  143. <td class="name"><code>type</code></td>
  144. <td class="description last"><p>The material type.</p></td>
  145. </tr>
  146. </tbody>
  147. </table>
  148. <dl class="details">
  149. <dt class="tag-returns"><strong>Returns:</strong> The new material.</dt>
  150. </dl>
  151. </div>
  152. <h2 class="subsection-title">Source</h2>
  153. <p>
  154. <a href="https://github.com/mrdoob/three.js/blob/master/src/loaders/MaterialLoader.js" target="_blank" rel="noopener" translate="no">src/loaders/MaterialLoader.js</a>
  155. </p>
  156. </article>
  157. </section>
  158. <script src="../scripts/linenumber.js"></script>
  159. <script src="../scripts/page.js"></script>
  160. </body>
  161. </html>
粤ICP备19079148号