LoopNode.html 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>LoopNode - 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="EventDispatcher.html">EventDispatcher</a> → <a href="Node.html">Node</a> → </p>
  13. <h1 translate="no">LoopNode</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>This module offers a variety of ways to implement loops in TSL. In it's basic form it's:</p>
  17. <p>However, it is also possible to define a start and end ranges, data types and loop conditions:</p>
  18. <pre><code class="language-js">Loop( { start: int( 0 ), end: int( 10 ), type: 'int', condition: '&lt;' }, ( { i } ) => {
  19. } );
  20. </code></pre>
  21. <p>Nested loops can be defined in a compacted form:</p>
  22. <pre><code class="language-js">Loop( 10, 5, ( { i, j } ) => {
  23. } );
  24. </code></pre>
  25. <p>Loops that should run backwards can be defined like so:</p>
  26. <pre><code class="language-js">Loop( { start: 10 }, () => {} );
  27. </code></pre>
  28. <p>It is possible to execute with boolean values, similar to the <code>while</code> syntax.</p>
  29. <pre><code class="language-js">const value = float( 0 ).toVar();
  30. Loop( value.lessThan( 10 ), () => {
  31. value.addAssign( 1 );
  32. } );
  33. </code></pre>
  34. <p>The module also provides <code>Break()</code> and <code>Continue()</code> TSL expression for loop control.</p></div>
  35. <h2>Code Example</h2>
  36. <div translate="no"><pre><code class="language-js">Loop( count, ( { i } ) => {
  37. } );
  38. </code></pre></div>
  39. </header>
  40. <article>
  41. <div class="container-overview">
  42. <h2>Constructor</h2>
  43. <h3 class="name name-method" id="LoopNode" translate="no">new <a href="#LoopNode">LoopNode</a><span class="signature">( params : <span class="param-type">Array.&lt;any></span> )</span> </h3>
  44. <div class="method">
  45. <div class="description">
  46. <p>Constructs a new loop node.</p>
  47. </div>
  48. <table class="params">
  49. <tbody>
  50. <tr>
  51. <td class="name"><code>params</code></td>
  52. <td class="description last"><p>Depending on the loop type, array holds different parameterization values for the loop.</p></td>
  53. </tr>
  54. </tbody>
  55. </table>
  56. </div>
  57. </div>
  58. <h2 class="subsection-title">Methods</h2>
  59. <h3 class="name name-method" id="getProperties" translate="no">.<a href="#getProperties">getProperties</a><span class="signature">( builder : <span class="param-type">NodeBuilder</span> )</span><span class="type-signature"> : Object</span> </h3>
  60. <div class="method">
  61. <div class="description">
  62. <p>Returns properties about this node.</p>
  63. </div>
  64. <table class="params">
  65. <tbody>
  66. <tr>
  67. <td class="name"><code>builder</code></td>
  68. <td class="description last"><p>The current node builder.</p></td>
  69. </tr>
  70. </tbody>
  71. </table>
  72. <dl class="details">
  73. <dt class="tag-returns"><strong>Returns:</strong> The node properties.</dt>
  74. </dl>
  75. </div>
  76. <h3 class="name name-method" id="getVarName" translate="no">.<a href="#getVarName">getVarName</a><span class="signature">( index : <span class="param-type">number</span> )</span><span class="type-signature"> : string</span> </h3>
  77. <div class="method">
  78. <div class="description">
  79. <p>Returns a loop variable name based on an index. The pattern is
  80. <code>0</code> = <code>i</code>, <code>1</code>= <code>j</code>, <code>2</code>= <code>k</code> and so on.</p>
  81. </div>
  82. <table class="params">
  83. <tbody>
  84. <tr>
  85. <td class="name"><code>index</code></td>
  86. <td class="description last"><p>The index.</p></td>
  87. </tr>
  88. </tbody>
  89. </table>
  90. <dl class="details">
  91. <dt class="tag-returns"><strong>Returns:</strong> The loop variable name.</dt>
  92. </dl>
  93. </div>
  94. <h2 class="subsection-title">Source</h2>
  95. <p>
  96. <a href="https://github.com/mrdoob/three.js/blob/master/src/nodes/utils/LoopNode.js" target="_blank" rel="noopener" translate="no">src/nodes/utils/LoopNode.js</a>
  97. </p>
  98. </article>
  99. </section>
  100. <script src="../scripts/linenumber.js"></script>
  101. <script src="../scripts/page.js"></script>
  102. </body>
  103. </html>
粤ICP备19079148号