TubeGeometry.html 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <base href="../../" />
  6. <script src="list.js"></script>
  7. <script src="page.js"></script>
  8. <link type="text/css" rel="stylesheet" href="page.css" />
  9. </head>
  10. <body>
  11. [page:Geometry] &rarr;
  12. <h1>[name]</h1>
  13. <div class="desc">Creates a tube that extrudes along a 3d curve.</div>
  14. <iframe id="scene" src="scenes/geometry-browser.html#TubeGeometry"></iframe>
  15. <script>
  16. // iOS iframe auto-resize workaround
  17. if ( /(iPad|iPhone|iPod)/g.test( navigator.userAgent ) ) {
  18. var scene = document.getElementById( 'scene' );
  19. scene.style.width = getComputedStyle( scene ).width;
  20. scene.style.height = getComputedStyle( scene ).height;
  21. scene.setAttribute( 'scrolling', 'no' );
  22. }
  23. </script>
  24. <h2>Example</h2>
  25. <code>
  26. var CustomSinCurve = THREE.Curve.create(
  27. function ( scale ) { //custom curve constructor
  28. this.scale = ( scale === undefined ) ? 1 : scale;
  29. },
  30. function ( t ) { //getPoint: t is between 0-1
  31. var tx = t * 3 - 1.5,
  32. ty = Math.sin( 2 * Math.PI * t ),
  33. tz = 0;
  34. return new THREE.Vector3( tx, ty, tz ).multiplyScalar( this.scale );
  35. }
  36. );
  37. var path = new CustomSinCurve( 10 );
  38. var geometry = new THREE.TubeGeometry( path, 20, 2, 8, false );
  39. var material = new THREE.MeshBasicMaterial( { color: 0x00ff00 } );
  40. var mesh = new THREE.Mesh( geometry, material );
  41. scene.add( mesh );
  42. </code>
  43. <h2>Constructor</h2>
  44. <h3>[name]([page:Curve path], [page:Integer segments], [page:Float radius], [page:Integer radiusSegments], [page:Boolean closed])</h3>
  45. <div>
  46. path — [page:Curve] - A path that inherits from the [page:Curve] base class<br />
  47. segments — [page:Integer] - The number of segments that make up the tube, default is 64<br />
  48. radius — [page:Float] - The radius of the tube, default is 1<br />
  49. radiusSegments — [page:Integer] - The number of segments that make up the cross-section, default is 8 <br />
  50. closed — [page:Boolean] Is the tube open or closed, default is false <br />
  51. </div>
  52. <h2>Properties</h2>
  53. <h3>[property:Object parameters]</h3>
  54. <div>
  55. An object with all of the parameters that were used to generate the geometry.
  56. </div>
  57. <h3>[property:Array tangents]</h3>
  58. <div>
  59. An array of [page:Vector3] tangents
  60. </div>
  61. <h3>[property:Array normals]</h3>
  62. <div>
  63. An array of [page:Vector3] normals
  64. </div>
  65. <h3>[property:Array binormals]</h3>
  66. <div>
  67. An array of [page:Vector3] binormals
  68. </div>
  69. <h2>Methods</h2>
  70. <h3>THREE.TubeGeometry.FrenetFrames([page:Curve path], [page:Integer segments], [page:Boolean closed])</h3>
  71. <div>
  72. path — A path that inherits from the [page:Curve] base class <br />
  73. segments — The number of segments that make up the tube <br />
  74. closed — Is the tube open or closed
  75. </div>
  76. <div>
  77. A static method that generates the Frenet Frames. This is internally run on any new TubeGeometry and then the
  78. generated tangents, normals, and binormals are exposed as properties on the TubeGeometry object.
  79. </div>
  80. <h2>Source</h2>
  81. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  82. </body>
  83. </html>