ForestGenerator.html 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>ForestGenerator - 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">ForestGenerator</h1>
  13. <section>
  14. <header>
  15. <div class="class-description"><p>Carpets a <a href="TerrainGenerator.html">TerrainGenerator</a> ( or anything exposing <code>sampleHeight</code>,
  16. <code>sampleSlope</code>, <code>minY</code>, <code>maxY</code> and <code>parameters.size</code> ) with a forest of hundreds
  17. of thousands of trees in a single draw call.</p>
  18. <p>Each tree is the cheapest thing that still reads as a tree: a ~20-face icosphere
  19. squashed into a tapered teardrop and lumped with a little noise, carrying a baked
  20. dark-base / bright-top gradient. Tens of triangles each, so a single
  21. THREE.InstancedMesh of half a million of them costs one draw call. Trees
  22. are placed by rejection sampling against ecological rules — a min/max altitude
  23. band ( above the mist floor, below the snowline ), a slope limit ( none on
  24. cliffs ) and a low-frequency density mask that opens clearings — then jittered in
  25. yaw, lean and ( squared-biased ) scale so the stand never reads as copies.</p></div>
  26. <h2>Code Example</h2>
  27. <div translate="no"><pre><code class="language-js">const forest = new ForestGenerator( { count: 500000 } );
  28. scene.add( forest.build( terrain ) );
  29. </code></pre></div>
  30. </header>
  31. <article>
  32. <div class="container-overview">
  33. <h2>Constructor</h2>
  34. <h3 class="name name-method" id="ForestGenerator" translate="no">new <a href="#ForestGenerator">ForestGenerator</a><span class="signature">()</span> </h3>
  35. <div class="method">
  36. </div>
  37. </div>
  38. <h2 class="subsection-title">Source</h2>
  39. <p>
  40. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/generators/ForestGenerator.js" translate="no" target="_blank" rel="noopener">examples/jsm/generators/ForestGenerator.js</a>
  41. </p>
  42. </article>
  43. </section>
  44. <script src="../scripts/linenumber.js"></script>
  45. <script src="../scripts/page.js"></script>
  46. </body>
  47. </html>
粤ICP备19079148号