MaterialXLoader.html 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>MaterialXLoader - 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">MaterialXLoader</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>A loader for the MaterialX format.</p>
  17. <p>The node materials loaded with this loader can only be used with <a href="WebGPURenderer.html">WebGPURenderer</a>.</p></div>
  18. <h2>Code Example</h2>
  19. <div translate="no"><pre><code class="language-js">const loader = new MaterialXLoader().setPath( SAMPLE_PATH );
  20. const materials = await loader.loadAsync( 'standard_surface_brass_tiled.mtlx' );
  21. </code></pre></div>
  22. </header>
  23. <article>
  24. <h2 class="subsection-title">Import</h2>
  25. <p><span translate="no">MaterialXLoader</span> is an addon, and must be imported explicitly, see <a href="https://threejs.org/manual/#en/installation" target="_blank" rel="noopener">Installation#Addons</a>.</p>
  26. <pre><code class="language-js">import { MaterialXLoader } from 'three/addons/loaders/MaterialXLoader.js';</code></pre>
  27. <div class="container-overview">
  28. <h2>Constructor</h2>
  29. <h3 class="name name-method" id="MaterialXLoader" translate="no">new <a href="#MaterialXLoader">MaterialXLoader</a><span class="signature">( manager : <span class="param-type"><a href="LoadingManager.html">LoadingManager</a></span> )</span> </h3>
  30. <div class="method">
  31. <div class="description">
  32. <p>Constructs a new MaterialX loader.</p>
  33. </div>
  34. <table class="params">
  35. <tbody>
  36. <tr>
  37. <td class="name">
  38. <strong>manager</strong>
  39. </td>
  40. <td class="description last">
  41. <p>The loading manager.</p>
  42. </td>
  43. </tr>
  44. </tbody>
  45. </table>
  46. </div>
  47. </div>
  48. <h2 class="subsection-title">Methods</h2>
  49. <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><span class="type-signature"> : <a href="MaterialXLoader.html">MaterialXLoader</a></span> </h3>
  50. <div class="method">
  51. <div class="description">
  52. <p>Starts loading from the given URL and passes the loaded MaterialX asset
  53. to the <code>onLoad()</code> callback.</p>
  54. </div>
  55. <table class="params">
  56. <tbody>
  57. <tr>
  58. <td class="name">
  59. <strong>url</strong>
  60. </td>
  61. <td class="description last">
  62. <p>The path/URL of the file to be loaded. This can also be a data URI.</p>
  63. </td>
  64. </tr>
  65. <tr>
  66. <td class="name">
  67. <strong>onLoad</strong>
  68. </td>
  69. <td class="description last">
  70. <p>Executed when the loading process has been finished.</p>
  71. </td>
  72. </tr>
  73. <tr>
  74. <td class="name">
  75. <strong>onProgress</strong>
  76. </td>
  77. <td class="description last">
  78. <p>Executed while the loading is in progress.</p>
  79. </td>
  80. </tr>
  81. <tr>
  82. <td class="name">
  83. <strong>onError</strong>
  84. </td>
  85. <td class="description last">
  86. <p>Executed when errors occur.</p>
  87. </td>
  88. </tr>
  89. </tbody>
  90. </table>
  91. <dl class="details">
  92. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Loader.html#load">Loader#load</a></dt>
  93. </dl>
  94. <dl class="details">
  95. <dt class="tag-returns"><strong>Returns:</strong> A reference to this loader.</dt>
  96. </dl>
  97. </div>
  98. <h3 class="name name-method" id="parse" translate="no">.<a href="#parse">parse</a><span class="signature">( text : <span class="param-type">string</span> )</span><span class="type-signature"> : Object.&lt;string, <a href="NodeMaterial.html">NodeMaterial</a>></span> </h3>
  99. <div class="method">
  100. <div class="description">
  101. <p>Parses the given MaterialX data and returns the resulting materials.</p>
  102. <p>Supported standard_surface inputs:</p>
  103. <ul>
  104. <li>base, base_color: Base color/albedo</li>
  105. <li>opacity: Alpha/transparency</li>
  106. <li>specular_roughness: Surface roughness</li>
  107. <li>metalness: Metallic property</li>
  108. <li>specular: Specular reflection intensity</li>
  109. <li>specular_color: Specular reflection color</li>
  110. <li>ior: Index of refraction</li>
  111. <li>specular_anisotropy, specular_rotation: Anisotropic reflection</li>
  112. <li>transmission, transmission_color: Transmission properties</li>
  113. <li>thin_film_thickness, thin_film_ior: Thin film interference</li>
  114. <li>sheen, sheen_color, sheen_roughness: Sheen properties</li>
  115. <li>normal: Normal map</li>
  116. <li>coat, coat_roughness, coat_color: Clearcoat properties</li>
  117. <li>emission, emissionColor: Emission properties</li>
  118. </ul>
  119. </div>
  120. <table class="params">
  121. <tbody>
  122. <tr>
  123. <td class="name">
  124. <strong>text</strong>
  125. </td>
  126. <td class="description last">
  127. <p>The raw MaterialX data as a string.</p>
  128. </td>
  129. </tr>
  130. </tbody>
  131. </table>
  132. <dl class="details">
  133. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Loader.html#parse">Loader#parse</a></dt>
  134. </dl>
  135. <dl class="details">
  136. <dt class="tag-returns"><strong>Returns:</strong> A dictionary holding the parse node materials.</dt>
  137. </dl>
  138. </div>
  139. <h2 class="subsection-title">Source</h2>
  140. <p>
  141. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/MaterialXLoader.js" translate="no" target="_blank" rel="noopener">examples/jsm/loaders/MaterialXLoader.js</a>
  142. </p>
  143. </article>
  144. </section>
  145. <script src="../scripts/linenumber.js"></script>
  146. <script src="../scripts/page.js"></script>
  147. </body>
  148. </html>
粤ICP备19079148号