TubeGeometry.html 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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">Curve</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"><code>path</code></td>
  46. <td class="description last"><p>A 3D curve defining the path of the tube.<br/>Default is <code>QuadraticBezierCurve3</code>.</p></td>
  47. </tr>
  48. <tr>
  49. <td class="name"><code>tubularSegments</code></td>
  50. <td class="description last"><p>The number of segments that make up the tube.<br/>Default is <code>64</code>.</p></td>
  51. </tr>
  52. <tr>
  53. <td class="name"><code>radius</code></td>
  54. <td class="description last"><p>The radius of the tube.<br/>Default is <code>1</code>.</p></td>
  55. </tr>
  56. <tr>
  57. <td class="name"><code>radialSegments</code></td>
  58. <td class="description last"><p>The number of segments that make up the cross-section.<br/>Default is <code>8</code>.</p></td>
  59. </tr>
  60. <tr>
  61. <td class="name"><code>closed</code></td>
  62. <td class="description last"><p>Whether the tube is closed or not.<br/>Default is <code>false</code>.</p></td>
  63. </tr>
  64. </tbody>
  65. </table>
  66. </div>
  67. </div>
  68. <h2 class="subsection-title">Properties</h2>
  69. <div class="member">
  70. <h3 class="name" id="parameters" translate="no">.<a href="#parameters">parameters</a><span class="type-signature"> : Object</span> </h3>
  71. <div class="description">
  72. <p>Holds the constructor parameters that have been
  73. used to generate the geometry. Any modification
  74. after instantiation does not change the geometry.</p>
  75. </div>
  76. </div>
  77. <h2 class="subsection-title">Static Methods</h2>
  78. <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>
  79. <div class="method">
  80. <div class="description">
  81. <p>Factory method for creating an instance of this class from the given
  82. JSON object.</p>
  83. </div>
  84. <table class="params">
  85. <tbody>
  86. <tr>
  87. <td class="name"><code>data</code></td>
  88. <td class="description last"><p>A JSON object representing the serialized geometry.</p></td>
  89. </tr>
  90. </tbody>
  91. </table>
  92. <dl class="details">
  93. <dt class="tag-returns"><strong>Returns:</strong> A new instance.</dt>
  94. </dl>
  95. </div>
  96. <h2 class="subsection-title">Source</h2>
  97. <p>
  98. <a href="https://github.com/mrdoob/three.js/blob/master/src/geometries/TubeGeometry.js" target="_blank" rel="noopener" translate="no">src/geometries/TubeGeometry.js</a>
  99. </p>
  100. </article>
  101. </section>
  102. <script src="../scripts/linenumber.js"></script>
  103. <script src="../scripts/page.js"></script>
  104. </body>
  105. </html>
粤ICP备19079148号