TreeGenerator.html 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>TreeGenerator - 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">TreeGenerator</h1>
  13. <section>
  14. <header>
  15. <div class="class-description"><p>Grows a procedural tree skeleton — trunk, branches and twigs, each swept as a tapered
  16. tube — and bakes it into one non-indexed <a href="BufferGeometry.html">BufferGeometry</a> (position and normal
  17. only), ready to instance into a forest. It produces <em>branches only</em>; add foliage as a
  18. separate layer.</p>
  19. <p>The branching is deterministic for a given <code>seed</code>: a recursive sweep lays down gently
  20. curved tubes with a parallel-transport frame (so they never twist), forking by the
  21. pipe model (each child much thinner than its parent), spreading children along the
  22. upper part of each branch with a golden-angle roll, and pulling them back up toward
  23. the light. A flared root, non-linear taper and gravity droop fill in the character.</p>
  24. <p>Parameters are set with a fluent builder: a <code>set&lt;Param&gt;()</code> exists for every default
  25. ( <code>setSeed</code>, <code>setLevels</code>, <code>setChildren</code>, … ), each returning <code>this</code> for chaining.</p>
  26. <p>Each <code>build()</code> returns a fresh, independent mesh that the caller owns, so one
  27. generator can be re-parametrized and built repeatedly to grow a varied stand:</p></div>
  28. <h2>Code Example</h2>
  29. <div translate="no"><pre><code class="language-js">const generator = new TreeGenerator( material );
  30. const oak = generator.setSeed( 1 ).setLevels( 4 ).build();
  31. const pine = generator.setSeed( 2 ).setLevels( 5 ).build();
  32. </code></pre></div>
  33. </header>
  34. <article>
  35. <div class="container-overview">
  36. <h2>Constructor</h2>
  37. <h3 class="name name-method" id="TreeGenerator" translate="no">new <a href="#TreeGenerator">TreeGenerator</a><span class="signature">()</span> </h3>
  38. <div class="method">
  39. </div>
  40. </div>
  41. <h2 class="subsection-title">Source</h2>
  42. <p>
  43. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/generators/TreeGenerator.js" translate="no" target="_blank" rel="noopener">examples/jsm/generators/TreeGenerator.js</a>
  44. </p>
  45. </article>
  46. </section>
  47. <script src="../scripts/linenumber.js"></script>
  48. <script src="../scripts/page.js"></script>
  49. </body>
  50. </html>
粤ICP备19079148号