Transpiler.html 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Transpiler - 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. <h1 translate="no">Transpiler</h1>
  13. <section>
  14. <header>
  15. <div class="class-description"><p>A class that transpiles shader code from one language into another.</p>
  16. <p><code>Transpiler</code> can only be used to convert GLSL into TSL right now. It is intended
  17. to support developers when they want to migrate their custom materials from the
  18. current to the new node-based material system.</p></div>
  19. </header>
  20. <article>
  21. <h2 class="subsection-title">Import</h2>
  22. <p><span translate="no">Transpiler</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>
  23. <pre><code class="language-js">import Transpiler from 'three/addons/transpiler/Transpiler.js';</code></pre>
  24. <div class="container-overview">
  25. <h2>Constructor</h2>
  26. <h3 class="name name-method" id="Transpiler" translate="no">new <a href="#Transpiler">Transpiler</a><span class="signature">( decoder : <span class="param-type">GLSLDecoder</span>, encoder : <span class="param-type">TSLEncoder</span> )</span> </h3>
  27. <div class="method">
  28. <div class="description">
  29. <p>Constructs a new transpiler.</p>
  30. </div>
  31. <table class="params">
  32. <tbody>
  33. <tr>
  34. <td class="name">
  35. <strong>decoder</strong>
  36. </td>
  37. <td class="description last">
  38. <p>The GLSL decoder.</p>
  39. </td>
  40. </tr>
  41. <tr>
  42. <td class="name">
  43. <strong>encoder</strong>
  44. </td>
  45. <td class="description last">
  46. <p>The TSL encoder.</p>
  47. </td>
  48. </tr>
  49. </tbody>
  50. </table>
  51. </div>
  52. </div>
  53. <h2 class="subsection-title">Properties</h2>
  54. <div class="member">
  55. <h3 class="name" id="decoder" translate="no">.<a href="#decoder">decoder</a><span class="type-signature"> : GLSLDecoder</span> </h3>
  56. <div class="description">
  57. <p>The GLSL decoder. This component parse GLSL and produces
  58. a language-independent AST for further processing.</p>
  59. </div>
  60. </div>
  61. <div class="member">
  62. <h3 class="name" id="encoder" translate="no">.<a href="#encoder">encoder</a><span class="type-signature"> : TSLEncoder</span> </h3>
  63. <div class="description">
  64. <p>The TSL encoder. It takes the AST and emits TSL code.</p>
  65. </div>
  66. </div>
  67. <div class="member">
  68. <h3 class="name" id="linker" translate="no">.<a href="#linker">linker</a><span class="type-signature"> : Linker</span> </h3>
  69. <div class="description">
  70. <p>The linker. It processes the AST and resolves
  71. variable and function references, ensuring that all
  72. dependencies are properly linked.</p>
  73. </div>
  74. </div>
  75. <h2 class="subsection-title">Methods</h2>
  76. <h3 class="name name-method" id="parse" translate="no">.<a href="#parse">parse</a><span class="signature">( source : <span class="param-type">string</span> )</span><span class="type-signature"> : string</span> </h3>
  77. <div class="method">
  78. <div class="description">
  79. <p>Parses the given GLSL source and returns TSL syntax.</p>
  80. </div>
  81. <table class="params">
  82. <tbody>
  83. <tr>
  84. <td class="name">
  85. <strong>source</strong>
  86. </td>
  87. <td class="description last">
  88. <p>The GLSL source.</p>
  89. </td>
  90. </tr>
  91. </tbody>
  92. </table>
  93. <dl class="details">
  94. <dt class="tag-returns"><strong>Returns:</strong> The TSL code.</dt>
  95. </dl>
  96. </div>
  97. <h2 class="subsection-title">Source</h2>
  98. <p>
  99. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/transpiler/Transpiler.js" translate="no" target="_blank" rel="noopener">examples/jsm/transpiler/Transpiler.js</a>
  100. </p>
  101. </article>
  102. </section>
  103. <script src="../scripts/linenumber.js"></script>
  104. <script src="../scripts/page.js"></script>
  105. </body>
  106. </html>
粤ICP备19079148号