TubeGeometry.html 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>TubeGeometry - 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">TubeGeometry</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>Creates a tube that extrudes along a 3D curve.</p></div>
  17. <iframe id="viewer" src="../scenes/geometry-browser.html#TubeGeometry"></iframe>
  18. <h2>Code Example</h2>
  19. <div translate="no"><pre><code class="language-js">class CustomSinCurve extends THREE.Curve {
  20. getPoint( t, optionalTarget = new THREE.Vector3() ) {
  21. const tx = t * 3 - 1.5;
  22. const ty = Math.sin( 2 * Math.PI * t );
  23. const tz = 0;
  24. return optionalTarget.set( tx, ty, tz );
  25. }
  26. }
  27. const path = new CustomSinCurve( 10 );
  28. const geometry = new THREE.TubeGeometry( path, 20, 2, 8, false );
  29. const material = new THREE.MeshBasicMaterial( { color: 0x00ff00 } );
  30. const mesh = new THREE.Mesh( geometry, material );
  31. scene.add( mesh );
  32. </code></pre></div>
  33. </header>
  34. <article>
  35. <div class="container-overview">
  36. <h2>Constructor</h2>
  37. <h3 class="name name-method" id="TubeGeometry" translate="no">new <a href="#TubeGeometry">TubeGeometry</a><span class="signature">( path : <span class="param-type"><a href="Curve.html">Curve</a></span>, tubularSegments : <span class="param-type">number</span>, radius : <span class="param-type">number</span>, radialSegments : <span class="param-type">number</span>, closed : <span class="param-type">boolean</span> )</span> </h3>
  38. <div class="method">
  39. <div class="description">
  40. <p>Constructs a new tube geometry.</p>
  41. </div>
  42. <table class="params">
  43. <tbody>
  44. <tr>
  45. <td class="name">
  46. <strong>path</strong>
  47. </td>
  48. <td class="description last">
  49. <p>A 3D curve defining the path of the tube.</p>
  50. <p>Default is <code>QuadraticBezierCurve3</code>.</p>
  51. </td>
  52. </tr>
  53. <tr>
  54. <td class="name">
  55. <strong>tubularSegments</strong>
  56. </td>
  57. <td class="description last">
  58. <p>The number of segments that make up the tube.</p>
  59. <p>Default is <code>64</code>.</p>
  60. </td>
  61. </tr>
  62. <tr>
  63. <td class="name">
  64. <strong>radius</strong>
  65. </td>
  66. <td class="description last">
  67. <p>The radius of the tube.</p>
  68. <p>Default is <code>1</code>.</p>
  69. </td>
  70. </tr>
  71. <tr>
  72. <td class="name">
  73. <strong>radialSegments</strong>
  74. </td>
  75. <td class="description last">
  76. <p>The number of segments that make up the cross-section.</p>
  77. <p>Default is <code>8</code>.</p>
  78. </td>
  79. </tr>
  80. <tr>
  81. <td class="name">
  82. <strong>closed</strong>
  83. </td>
  84. <td class="description last">
  85. <p>Whether the tube is closed or not.</p>
  86. <p>Default is <code>false</code>.</p>
  87. </td>
  88. </tr>
  89. </tbody>
  90. </table>
  91. </div>
  92. </div>
  93. <h2 class="subsection-title">Properties</h2>
  94. <div class="member">
  95. <h3 class="name" id="parameters" translate="no">.<a href="#parameters">parameters</a><span class="type-signature"> : Object</span> </h3>
  96. <div class="description">
  97. <p>Holds the constructor parameters that have been
  98. used to generate the geometry. Any modification
  99. after instantiation does not change the geometry.</p>
  100. </div>
  101. </div>
  102. <h2 class="subsection-title">Static Methods</h2>
  103. <h3 class="name name-method" id=".fromJSON" translate="no">.<a href="#.fromJSON">fromJSON</a><span class="signature">( data : <span class="param-type">Object</span> )</span><span class="type-signature"> : <a href="TubeGeometry.html">TubeGeometry</a></span> </h3>
  104. <div class="method">
  105. <div class="description">
  106. <p>Factory method for creating an instance of this class from the given
  107. JSON object.</p>
  108. </div>
  109. <table class="params">
  110. <tbody>
  111. <tr>
  112. <td class="name">
  113. <strong>data</strong>
  114. </td>
  115. <td class="description last">
  116. <p>A JSON object representing the serialized geometry.</p>
  117. </td>
  118. </tr>
  119. </tbody>
  120. </table>
  121. <dl class="details">
  122. <dt class="tag-returns"><strong>Returns:</strong> A new instance.</dt>
  123. </dl>
  124. </div>
  125. <h2 class="subsection-title">Source</h2>
  126. <p>
  127. <a href="https://github.com/mrdoob/three.js/blob/master/src/geometries/TubeGeometry.js" translate="no" target="_blank" rel="noopener">src/geometries/TubeGeometry.js</a>
  128. </p>
  129. </article>
  130. </section>
  131. <script src="../scripts/linenumber.js"></script>
  132. <script src="../scripts/page.js"></script>
  133. </body>
  134. </html>
粤ICP备19079148号