ExtrudeGeometry.html 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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">从一个形状路径中,挤压出一个BufferGeometry。</p>
  13. <iframe id="scene" src="scenes/geometry-browser.html#ExtrudeGeometry"></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. const length = 12, width = 8;
  26. const shape = new THREE.Shape();
  27. shape.moveTo( 0,0 );
  28. shape.lineTo( 0, width );
  29. shape.lineTo( length, width );
  30. shape.lineTo( length, 0 );
  31. shape.lineTo( 0, 0 );
  32. const extrudeSettings = {
  33. steps: 2,
  34. depth: 16,
  35. bevelEnabled: true,
  36. bevelThickness: 1,
  37. bevelSize: 1,
  38. bevelOffset: 0,
  39. bevelSegments: 1
  40. };
  41. const geometry = new THREE.ExtrudeGeometry( shape, extrudeSettings );
  42. const material = new THREE.MeshBasicMaterial( { color: 0x00ff00 } );
  43. const mesh = new THREE.Mesh( geometry, material ) ;
  44. scene.add( mesh );
  45. </code>
  46. <h2>构造器</h2>
  47. <h3>[name]([param:Array shapes], [param:Object options])</h3>
  48. <p>
  49. shapes — 形状或者一个包含形状的数组。<br />
  50. options — 一个包含有下列参数的对象:
  51. <ul>
  52. <li>curveSegments — int,曲线上点的数量,默认值是12。</li>
  53. <li>steps — int,用于沿着挤出样条的深度细分的点的数量,默认值为1。</li>
  54. <li>depth — float,挤出的形状的深度,默认值为1。</li>
  55. <li>bevelEnabled — bool,对挤出的形状应用是否斜角,默认值为true。</li>
  56. <li>bevelThickness — float,设置原始形状上斜角的厚度。默认值为0.2。</li>
  57. <li>bevelSize — float。斜角与原始形状轮廓之间的延伸距离,默认值为bevelThickness-0.1。</li>
  58. <li>bevelOffset — float. Distance from the shape outline that the bevel starts. Default is 0.</li>
  59. <li>bevelSegments — int。斜角的分段层数,默认值为3。</li>
  60. <li>extrudePath — THREE.Curve对象。一条沿着被挤出形状的三维样条线。Bevels not supported for path extrusion.</li>
  61. <li>UVGenerator — Object。提供了UV生成器函数的对象。</li>
  62. </ul>
  63. </p>
  64. <p>
  65. 该对象将一个二维形状挤出为一个三维几何体。
  66. </p>
  67. <p>
  68. 当使用这个几何体创建Mesh的时候,如果你希望分别对它的表面和它挤出的侧面使用单独的材质,你可以使用一个材质数组。
  69. 第一个材质将用于其表面;第二个材质则将用于其挤压出的侧面。
  70. </p>
  71. <h2>属性</h2>
  72. <p>共有属性请参见其基类[page:BufferGeometry]。</p>
  73. <h3>[property:Object parameters]</h3>
  74. <p>
  75. 一个包含着构造函数中每个参数的对象。在对象实例化之后,对该属性的任何修改都不会改变这个几何体。
  76. </p>
  77. <h2>方法(Methods)</h2>
  78. <p>共有方法请参见其基类[page:BufferGeometry]。</p>
  79. <h2>源代码</h2>
  80. <p>
  81. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  82. </p>
  83. </body>
  84. </html>