ExtrudeGeometry.html 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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 extruded geometry from a path shape.</p>
  13. <iframe
  14. id="scene"
  15. src="scenes/geometry-browser.html#ExtrudeGeometry"
  16. ></iframe>
  17. <script>
  18. // iOS iframe auto-resize workaround
  19. if ( /(iPad|iPhone|iPod)/g.test( navigator.userAgent ) ) {
  20. const scene = document.getElementById( 'scene' );
  21. scene.style.width = getComputedStyle( scene ).width;
  22. scene.style.height = getComputedStyle( scene ).height;
  23. scene.setAttribute( 'scrolling', 'no' );
  24. }
  25. </script>
  26. <h2>Code Example</h2>
  27. <code>
  28. const length = 12, width = 8;
  29. const shape = new THREE.Shape();
  30. shape.moveTo( 0,0 );
  31. shape.lineTo( 0, width );
  32. shape.lineTo( length, width );
  33. shape.lineTo( length, 0 );
  34. shape.lineTo( 0, 0 );
  35. const extrudeSettings = {
  36. steps: 2,
  37. depth: 16,
  38. bevelEnabled: true,
  39. bevelThickness: 1,
  40. bevelSize: 1,
  41. bevelOffset: 0,
  42. bevelSegments: 1
  43. };
  44. const geometry = new THREE.ExtrudeGeometry( shape, extrudeSettings );
  45. const material = new THREE.MeshBasicMaterial( { color: 0x00ff00 } );
  46. const mesh = new THREE.Mesh( geometry, material ) ;
  47. scene.add( mesh );
  48. </code>
  49. <h2>Constructor</h2>
  50. <h3>[name]([param:Array shapes], [param:Object options])</h3>
  51. <p>
  52. shapes — Shape or an array of shapes. <br />
  53. options — Object that can contain the following parameters.
  54. </p>
  55. <ul>
  56. <li>
  57. curveSegments — int. Number of points on the curves. Default is `12`.
  58. </li>
  59. <li>
  60. steps — int. Number of points used for subdividing segments along the
  61. depth of the extruded spline. Default is `1`.
  62. </li>
  63. <li>depth — float. Depth to extrude the shape. Default is `1`.</li>
  64. <li>
  65. bevelEnabled — bool. Apply beveling to the shape. Default is true.
  66. </li>
  67. <li>
  68. bevelThickness — float. How deep into the original shape the bevel goes.
  69. Default is `0.2`.
  70. </li>
  71. <li>
  72. bevelSize — float. Distance from the shape outline that the bevel
  73. extends. Default is bevelThickness - 0.1.
  74. </li>
  75. <li>
  76. bevelOffset — float. Distance from the shape outline that the bevel
  77. starts. Default is `0`.
  78. </li>
  79. <li>bevelSegments — int. Number of bevel layers. Default is `3`.</li>
  80. <li>
  81. extrudePath — THREE.Curve. A 3D spline path along which the shape should
  82. be extruded. Bevels not supported for path extrusion.
  83. </li>
  84. <li>UVGenerator — Object. object that provides UV generator functions</li>
  85. </ul>
  86. <p>This object extrudes a 2D shape to a 3D geometry.</p>
  87. <p>
  88. When creating a Mesh with this geometry, if you'd like to have a separate
  89. material used for its face and its extruded sides, you can use an array of
  90. materials. The first material will be applied to the face; the second
  91. material will be applied to the sides.
  92. </p>
  93. <h2>Properties</h2>
  94. <p>See the base [page:BufferGeometry] class for common properties.</p>
  95. <h3>[property:Object parameters]</h3>
  96. <p>
  97. An object with a property for each of the constructor parameters. Any
  98. modification after instantiation does not change the geometry.
  99. </p>
  100. <h2>Methods</h2>
  101. <p>See the base [page:BufferGeometry] class for common methods.</p>
  102. <h2>Source</h2>
  103. <p>
  104. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  105. </p>
  106. </body>
  107. </html>