1
0

MaterialLoader.html 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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 materials. 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"><a href="LoadingManager.html">LoadingManager</a></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">
  36. <strong>manager</strong>
  37. </td>
  38. <td class="description last">
  39. <p>The loading manager.</p>
  40. </td>
  41. </tr>
  42. </tbody>
  43. </table>
  44. </div>
  45. </div>
  46. <h2 class="subsection-title">Properties</h2>
  47. <div class="member">
  48. <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>
  49. <div class="description">
  50. <p>A dictionary holding textures used by the material.</p>
  51. </div>
  52. </div>
  53. <h2 class="subsection-title">Methods</h2>
  54. <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>
  55. <div class="method">
  56. <div class="description">
  57. <p>Creates a material for the given type.</p>
  58. </div>
  59. <table class="params">
  60. <tbody>
  61. <tr>
  62. <td class="name">
  63. <strong>type</strong>
  64. </td>
  65. <td class="description last">
  66. <p>The material type.</p>
  67. </td>
  68. </tr>
  69. </tbody>
  70. </table>
  71. <dl class="details">
  72. <dt class="tag-returns"><strong>Returns:</strong> The new material.</dt>
  73. </dl>
  74. </div>
  75. <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"><a href="global.html#onProgressCallback">onProgressCallback</a></span>, onError : <span class="param-type"><a href="global.html#onErrorCallback">onErrorCallback</a></span> )</span> </h3>
  76. <div class="method">
  77. <div class="description">
  78. <p>Starts loading from the given URL and pass the loaded material to the <code>onLoad()</code> callback.</p>
  79. </div>
  80. <table class="params">
  81. <tbody>
  82. <tr>
  83. <td class="name">
  84. <strong>url</strong>
  85. </td>
  86. <td class="description last">
  87. <p>The path/URL of the file to be loaded. This can also be a data URI.</p>
  88. </td>
  89. </tr>
  90. <tr>
  91. <td class="name">
  92. <strong>onLoad</strong>
  93. </td>
  94. <td class="description last">
  95. <p>Executed when the loading process has been finished.</p>
  96. </td>
  97. </tr>
  98. <tr>
  99. <td class="name">
  100. <strong>onProgress</strong>
  101. </td>
  102. <td class="description last">
  103. <p>Executed while the loading is in progress.</p>
  104. </td>
  105. </tr>
  106. <tr>
  107. <td class="name">
  108. <strong>onError</strong>
  109. </td>
  110. <td class="description last">
  111. <p>Executed when errors occur.</p>
  112. </td>
  113. </tr>
  114. </tbody>
  115. </table>
  116. <dl class="details">
  117. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Loader.html#load">Loader#load</a></dt>
  118. </dl>
  119. </div>
  120. <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>
  121. <div class="method">
  122. <div class="description">
  123. <p>Parses the given JSON object and returns a material.</p>
  124. </div>
  125. <table class="params">
  126. <tbody>
  127. <tr>
  128. <td class="name">
  129. <strong>json</strong>
  130. </td>
  131. <td class="description last">
  132. <p>The serialized material.</p>
  133. </td>
  134. </tr>
  135. </tbody>
  136. </table>
  137. <dl class="details">
  138. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Loader.html#parse">Loader#parse</a></dt>
  139. </dl>
  140. <dl class="details">
  141. <dt class="tag-returns"><strong>Returns:</strong> The parsed material.</dt>
  142. </dl>
  143. </div>
  144. <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>
  145. <div class="method">
  146. <div class="description">
  147. <p>Textures are not embedded in the material JSON so they have
  148. to be injected before the loading process starts.</p>
  149. </div>
  150. <table class="params">
  151. <tbody>
  152. <tr>
  153. <td class="name">
  154. <strong>value</strong>
  155. </td>
  156. <td class="description last">
  157. <p>A dictionary holding textures for material properties.</p>
  158. </td>
  159. </tr>
  160. </tbody>
  161. </table>
  162. <dl class="details">
  163. <dt class="tag-returns"><strong>Returns:</strong> A reference to this material loader.</dt>
  164. </dl>
  165. </div>
  166. <h2 class="subsection-title">Static Methods</h2>
  167. <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>
  168. <div class="method">
  169. <div class="description">
  170. <p>Creates a material for the given type.</p>
  171. </div>
  172. <table class="params">
  173. <tbody>
  174. <tr>
  175. <td class="name">
  176. <strong>type</strong>
  177. </td>
  178. <td class="description last">
  179. <p>The material type.</p>
  180. </td>
  181. </tr>
  182. </tbody>
  183. </table>
  184. <dl class="details">
  185. <dt class="tag-returns"><strong>Returns:</strong> The new material.</dt>
  186. </dl>
  187. </div>
  188. <h2 class="subsection-title">Source</h2>
  189. <p>
  190. <a href="https://github.com/mrdoob/three.js/blob/master/src/loaders/MaterialLoader.js" translate="no" target="_blank" rel="noopener">src/loaders/MaterialLoader.js</a>
  191. </p>
  192. </article>
  193. </section>
  194. <script src="../scripts/linenumber.js"></script>
  195. <script src="../scripts/page.js"></script>
  196. </body>
  197. </html>
粤ICP备19079148号