LoftGeometry.html 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>LoftGeometry - 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="BufferGeometry.html">BufferGeometry</a> → </p>
  13. <h1 translate="no">LoftGeometry</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>This class can be used to generate a geometry by lofting (skinning) a surface
  17. through a series of cross sections. Each section is an array of points in 3D
  18. space and all sections must have the same number of points.</p>
  19. <p><code>LoftGeometry</code> is the general case of geometries like <a href="LatheGeometry.html">LatheGeometry</a>
  20. (which revolves a fixed profile around an axis) or <a href="TubeGeometry.html">TubeGeometry</a>
  21. (which sweeps a circular section along a path): the sections can have any
  22. shape, and can change shape, size, position and orientation from one
  23. section to the next.</p>
  24. <p>Sections wind around the loft so the resulting face normals point outwards
  25. when each section is ordered counterclockwise as seen from the end of the
  26. loft, looking back towards the start. If the surface appears inside out,
  27. reverse the point order of each section.</p></div>
  28. <h2>Code Example</h2>
  29. <div translate="no"><pre><code class="language-js">const sections = [];
  30. for ( let i = 0; i &lt;= 10; i ++ ) {
  31. const points = [];
  32. const radius = 2 + Math.sin( i * 0.8 );
  33. for ( let j = 0; j &lt; 32; j ++ ) {
  34. const angle = j / 32 * Math.PI * 2;
  35. points.push( new THREE.Vector3( Math.sin( angle ) * radius, i, Math.cos( angle ) * radius ) );
  36. }
  37. sections.push( points );
  38. }
  39. const geometry = new LoftGeometry( sections, { capStart: true, capEnd: true } );
  40. const material = new THREE.MeshStandardMaterial( { color: 0x00ff00 } );
  41. const mesh = new THREE.Mesh( geometry, material );
  42. scene.add( mesh );
  43. </code></pre></div>
  44. </header>
  45. <article>
  46. <h2 class="subsection-title">Import</h2>
  47. <p><span translate="no">LoftGeometry</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>
  48. <pre><code class="language-js">import { LoftGeometry } from 'three/addons/geometries/LoftGeometry.js';</code></pre>
  49. <div class="container-overview">
  50. <h2>Constructor</h2>
  51. <h3 class="name name-method" id="LoftGeometry" translate="no">new <a href="#LoftGeometry">LoftGeometry</a><span class="signature">( sections : <span class="param-type">Array.&lt;Array.&lt;<a href="Vector3.html">Vector3</a>>></span>, options : <span class="param-type">Object</span> )</span> </h3>
  52. <div class="method">
  53. <div class="description">
  54. <p>Constructs a new loft geometry.</p>
  55. </div>
  56. <table class="params">
  57. <tbody>
  58. <tr>
  59. <td class="name">
  60. <strong translate="no">sections</strong>
  61. </td>
  62. <td class="description last">
  63. <p>The cross sections to skin. At least
  64. two sections are required and all sections must have the same number of points.</p>
  65. </td>
  66. </tr>
  67. <tr>
  68. <td class="name">
  69. <strong translate="no">options</strong>
  70. </td>
  71. <td class="description last">
  72. <p>The loft options.</p>
  73. <p>Default is <code>{}</code>.</p>
  74. <table class="params">
  75. <tbody>
  76. <tr>
  77. <td class="name">
  78. <strong translate="no">closed</strong>
  79. </td>
  80. <td class="description last">
  81. <p>Whether each section is treated as a
  82. closed ring (e.g. a fuselage) or an open strip (e.g. a ribbon).</p>
  83. <p>Default is <code>true</code>.</p>
  84. </td>
  85. </tr>
  86. <tr>
  87. <td class="name">
  88. <strong translate="no">capStart</strong>
  89. </td>
  90. <td class="description last">
  91. <p>Whether the first section is closed
  92. with a cap or not.</p>
  93. <p>Default is <code>false</code>.</p>
  94. </td>
  95. </tr>
  96. <tr>
  97. <td class="name">
  98. <strong translate="no">capEnd</strong>
  99. </td>
  100. <td class="description last">
  101. <p>Whether the last section is closed
  102. with a cap or not.</p>
  103. <p>Default is <code>false</code>.</p>
  104. </td>
  105. </tr>
  106. </tbody>
  107. </table>
  108. </td>
  109. </tr>
  110. </tbody>
  111. </table>
  112. </div>
  113. </div>
  114. <h2 class="subsection-title">Properties</h2>
  115. <div class="member">
  116. <h3 class="name" id="parameters" translate="no">.<a href="#parameters">parameters</a><span class="type-signature"> : Object</span> </h3>
  117. <div class="description">
  118. <p>Holds the constructor parameters that have been
  119. used to generate the geometry. Any modification
  120. after instantiation does not change the geometry.</p>
  121. </div>
  122. </div>
  123. <h2 class="subsection-title">Source</h2>
  124. <p>
  125. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/geometries/LoftGeometry.js" translate="no" target="_blank" rel="noopener">examples/jsm/geometries/LoftGeometry.js</a>
  126. </p>
  127. </article>
  128. </section>
  129. <script src="../scripts/linenumber.js"></script>
  130. <script src="../scripts/page.js"></script>
  131. </body>
  132. </html>
粤ICP备19079148号