| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <title>LoopNode - Three.js Docs</title>
- <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
- <script src="../scripts/highlight.min.js"></script>
- <link type="text/css" rel="stylesheet" href="../styles/highlight-three.css">
- <link type="text/css" rel="stylesheet" href="../styles/page.css">
- </head>
- <body>
- <p class="inheritance" translate="no"><a href="EventDispatcher.html">EventDispatcher</a> → <a href="Node.html">Node</a> → </p>
- <h1 translate="no">LoopNode</h1>
- <section>
- <header>
- <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>
- <p>However, it is also possible to define a start and end ranges, data types and loop conditions:</p>
- <pre><code class="language-js">Loop( { start: int( 0 ), end: int( 10 ), type: 'int', condition: '<' }, ( { i } ) => {
- } );
- </code></pre>
- <p>Nested loops can be defined in a compacted form:</p>
- <pre><code class="language-js">Loop( 10, 5, ( { i, j } ) => {
- } );
- </code></pre>
- <p>Loops that should run backwards can be defined like so:</p>
- <pre><code class="language-js">Loop( { start: 10 }, () => {} );
- </code></pre>
- <p>It is possible to execute with boolean values, similar to the <code>while</code> syntax.</p>
- <pre><code class="language-js">const value = float( 0 ).toVar();
- Loop( value.lessThan( 10 ), () => {
- value.addAssign( 1 );
- } );
- </code></pre>
- <p>The module also provides <code>Break()</code> and <code>Continue()</code> TSL expression for loop control.</p></div>
- <h2>Code Example</h2>
- <div translate="no"><pre><code class="language-js">Loop( count, ( { i } ) => {
- } );
- </code></pre></div>
- </header>
- <article>
- <div class="container-overview">
- <h2>Constructor</h2>
- <h3 class="name name-method" id="LoopNode" translate="no">new <a href="#LoopNode">LoopNode</a><span class="signature">( params : <span class="param-type">Array.<<a href="global.html#any">any</a>></span> )</span> </h3>
- <div class="method">
- <div class="description">
- <p>Constructs a new loop node.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name">
- <strong>params</strong>
- </td>
- <td class="description last">
- <p>Depending on the loop type, array holds different parameterization values for the loop.</p>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- </div>
- <h2 class="subsection-title">Methods</h2>
- <h3 class="name name-method" id="getProperties" translate="no">.<a href="#getProperties">getProperties</a><span class="signature">( builder : <span class="param-type"><a href="NodeBuilder.html">NodeBuilder</a></span> )</span><span class="type-signature"> : Object</span> </h3>
- <div class="method">
- <div class="description">
- <p>Returns properties about this node.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name">
- <strong>builder</strong>
- </td>
- <td class="description last">
- <p>The current node builder.</p>
- </td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> The node properties.</dt>
- </dl>
- </div>
- <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>
- <div class="method">
- <div class="description">
- <p>Returns a loop variable name based on an index. The pattern is
- <code>0</code> = <code>i</code>, <code>1</code>= <code>j</code>, <code>2</code>= <code>k</code> and so on.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name">
- <strong>index</strong>
- </td>
- <td class="description last">
- <p>The index.</p>
- </td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> The loop variable name.</dt>
- </dl>
- </div>
- <h2 class="subsection-title">Source</h2>
- <p>
- <a href="https://github.com/mrdoob/three.js/blob/master/src/nodes/utils/LoopNode.js" translate="no" target="_blank" rel="noopener">src/nodes/utils/LoopNode.js</a>
- </p>
- </article>
- </section>
- <script src="../scripts/linenumber.js"></script>
- <script src="../scripts/page.js"></script>
- </body>
- </html>
|