TubeGeometry.html 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <!DOCTYPE html>
  2. <html lang="zh">
  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">创建一个沿着三维曲线延伸的管道。</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>代码示例</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>构造器</h2>
  44. <h3>[name]([param:Curve path], [param:Integer tubularSegments], [param:Float radius], [param:Integer radialSegments], [param:Boolean closed])</h3>
  45. <p>
  46. path — [page:Curve] - 一个由基类[page:Curve]继承而来的3D路径。 Default is a quadratic bezier curve.<br />
  47. tubularSegments — [page:Integer] - 组成这一管道的分段数,默认值为64。<br />
  48. radius — [page:Float] - 管道的半径,默认值为1。<br />
  49. radialSegments — [page:Integer] - 管道横截面的分段数目,默认值为8。<br />
  50. closed — [page:Boolean] 管道的两端是否闭合,默认值为false。<br />
  51. </p>
  52. <h2>属性</h2>
  53. <p>共有属性请参见其基类[page:BufferGeometry]。</p>
  54. <h3>[property:Object parameters]</h3>
  55. <p>
  56. 一个包含着构造函数中每个参数的对象。在对象实例化之后,对该属性的任何修改都不会改变这个几何体。
  57. </p>
  58. <h3>[property:Array tangents]</h3>
  59. <p>
  60. 一个[page:Vector3]切线数组。
  61. </p>
  62. <h3>[property:Array normals]</h3>
  63. <p>
  64. 一个[page:Vector3]法线数组。
  65. </p>
  66. <h3>[property:Array binormals]</h3>
  67. <p>
  68. 一个[page:Vector3]次法线数组。
  69. </p>
  70. <h2>方法(Methods)</h2>
  71. <p>共有方法请参见其基类[page:BufferGeometry]。</p>
  72. <h2>源代码</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>