TubeBufferGeometry.html 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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:BufferGeometry] &rarr;
  12. <h1>[name]</h1>
  13. <p class="desc">Creates a tube that extrudes along a 3d curve.</p>
  14. <iframe id="scene" src="scenes/geometry-browser.html#TubeBufferGeometry"></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. function CustomSinCurve( scale ) {
  27. THREE.Curve.call( this );
  28. this.scale = ( scale === undefined ) ? 1 : scale;
  29. }
  30. CustomSinCurve.prototype = Object.create( THREE.Curve.prototype );
  31. CustomSinCurve.prototype.constructor = CustomSinCurve;
  32. CustomSinCurve.prototype.getPoint = function ( t ) {
  33. var tx = t * 3 - 1.5;
  34. var ty = Math.sin( 2 * Math.PI * t );
  35. var tz = 0;
  36. return new THREE.Vector3( tx, ty, tz ).multiplyScalar( this.scale );
  37. };
  38. var path = new CustomSinCurve( 10 );
  39. var geometry = new THREE.TubeBufferGeometry( path, 20, 2, 8, false );
  40. var material = new THREE.MeshBasicMaterial( { color: 0x00ff00 } );
  41. var mesh = new THREE.Mesh( geometry, material );
  42. scene.add( mesh );
  43. </code>
  44. <h2>Constructor</h2>
  45. <h3>[name]([param:Curve path], [param:Integer tubularSegments], [param:Float radius], [param:Integer radialSegments], [param:Boolean closed])</h3>
  46. <p>
  47. path — [page:Curve] - A path that inherits from the [page:Curve] base class<br />
  48. tubularSegments — [page:Integer] - The number of segments that make up the tube, default is 64<br />
  49. radius — [page:Float] - The radius of the tube, default is 1<br />
  50. radialSegments — [page:Integer] - The number of segments that make up the cross-section, default is 8 <br />
  51. closed — [page:Boolean] Is the tube open or closed, default is false <br />
  52. </p>
  53. <h2>Properties</h2>
  54. <h3>[property:Object parameters]</h3>
  55. <p>
  56. An object with a property for each of the constructor parameters. Any modification after instantiation does not change the geometry.
  57. </p>
  58. <h3>[property:Array tangents]</h3>
  59. <p>
  60. An array of [page:Vector3] tangents
  61. </p>
  62. <h3>[property:Array normals]</h3>
  63. <p>
  64. An array of [page:Vector3] normals
  65. </p>
  66. <h3>[property:Array binormals]</h3>
  67. <p>
  68. An array of [page:Vector3] binormals
  69. </p>
  70. <h2>Source</h2>
  71. [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/TubeGeometry.js src/geometries/TubeGeometry.js]
  72. </body>
  73. </html>