TubeGeometry.html 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <base href="../../../" />
  6. <script src="page.js"></script>
  7. <link type="text/css" rel="stylesheet" href="page.css" />
  8. </head>
  9. <body>
  10. [page:BufferGeometry] &rarr;
  11. <h1>[name]</h1>
  12. <p class="desc">Creates a tube that extrudes along a 3d curve.</p>
  13. <iframe id="scene" src="scenes/geometry-browser.html#TubeGeometry"></iframe>
  14. <script>
  15. // iOS iframe auto-resize workaround
  16. if ( /(iPad|iPhone|iPod)/g.test( navigator.userAgent ) ) {
  17. const scene = document.getElementById( 'scene' );
  18. scene.style.width = getComputedStyle( scene ).width;
  19. scene.style.height = getComputedStyle( scene ).height;
  20. scene.setAttribute( 'scrolling', 'no' );
  21. }
  22. </script>
  23. <h2>Code Example</h2>
  24. <code>
  25. class CustomSinCurve extends THREE.Curve {
  26. constructor( scale = 1 ) {
  27. super();
  28. this.scale = scale;
  29. }
  30. getPoint( t, optionalTarget = new THREE.Vector3() ) {
  31. const tx = t * 3 - 1.5;
  32. const ty = Math.sin( 2 * Math.PI * t );
  33. const tz = 0;
  34. return optionalTarget.set( tx, ty, tz ).multiplyScalar( this.scale );
  35. }
  36. }
  37. const path = new CustomSinCurve( 10 );
  38. const geometry = new THREE.TubeGeometry( path, 20, 2, 8, false );
  39. const material = new THREE.MeshBasicMaterial( { color: 0x00ff00 } );
  40. const mesh = new THREE.Mesh( geometry, material );
  41. scene.add( mesh );
  42. </code>
  43. <h2>Constructor</h2>
  44. <h3>
  45. [name]([param:Curve path], [param:Integer tubularSegments], [param:Float radius], [param:Integer radialSegments], [param:Boolean closed])
  46. </h3>
  47. <p>
  48. path — [page:Curve] - A 3D path that inherits from the [page:Curve] base
  49. class. Default is a quadratic bezier curve.<br />
  50. tubularSegments — [page:Integer] - The number of segments that make up the
  51. tube. Default is `64`.<br />
  52. radius — [page:Float] - The radius of the tube. Default is `1`.<br />
  53. radialSegments — [page:Integer] - The number of segments that make up the
  54. cross-section. Default is `8`.<br />
  55. closed — [page:Boolean] Is the tube open or closed. Default is `false`.<br />
  56. </p>
  57. <h2>Properties</h2>
  58. <p>See the base [page:BufferGeometry] class for common properties.</p>
  59. <h3>[property:Object parameters]</h3>
  60. <p>
  61. An object with a property for each of the constructor parameters. Any
  62. modification after instantiation does not change the geometry.
  63. </p>
  64. <h3>[property:Array tangents]</h3>
  65. <p>An array of [page:Vector3] tangents</p>
  66. <h3>[property:Array normals]</h3>
  67. <p>An array of [page:Vector3] normals</p>
  68. <h3>[property:Array binormals]</h3>
  69. <p>An array of [page:Vector3] binormals</p>
  70. <h2>Methods</h2>
  71. <p>See the base [page:BufferGeometry] class for common methods.</p>
  72. <h2>Source</h2>
  73. <p>
  74. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  75. </p>
  76. </body>
  77. </html>