Shape.html 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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:Curve] &rarr; [page:CurvePath] &rarr; [page:Path] &rarr;
  11. <h1>[name]</h1>
  12. <p class="desc">
  13. Defines an arbitrary 2d shape plane using paths with optional holes. It
  14. can be used with [page:ExtrudeGeometry], [page:ShapeGeometry], to get
  15. points, or to get triangulated faces.
  16. </p>
  17. <h2>Code Example</h2>
  18. <code>
  19. const heartShape = new THREE.Shape();
  20. heartShape.moveTo( 25, 25 );
  21. heartShape.bezierCurveTo( 25, 25, 20, 0, 0, 0 );
  22. heartShape.bezierCurveTo( - 30, 0, - 30, 35, - 30, 35 );
  23. heartShape.bezierCurveTo( - 30, 55, - 10, 77, 25, 95 );
  24. heartShape.bezierCurveTo( 60, 77, 80, 55, 80, 35 );
  25. heartShape.bezierCurveTo( 80, 35, 80, 0, 50, 0 );
  26. heartShape.bezierCurveTo( 35, 0, 25, 25, 25, 25 );
  27. const extrudeSettings = {
  28. depth: 8,
  29. bevelEnabled: true,
  30. bevelSegments: 2,
  31. steps: 2,
  32. bevelSize: 1,
  33. bevelThickness: 1
  34. };
  35. const geometry = new THREE.ExtrudeGeometry( heartShape, extrudeSettings );
  36. const mesh = new THREE.Mesh( geometry, new THREE.MeshPhongMaterial() );
  37. </code>
  38. <h2>Examples</h2>
  39. <p>
  40. [example:webgl_geometry_shapes geometry / shapes ]<br />
  41. [example:webgl_geometry_extrude_shapes geometry / extrude / shapes ]<br />
  42. [example:webgl_geometry_extrude_shapes2 geometry / extrude / shapes2 ]<br />
  43. </p>
  44. <h2>Constructor</h2>
  45. <h3>[name]( [param:Array points] )</h3>
  46. <p>
  47. points -- (optional) array of [page:Vector2 Vector2s].<br /><br />
  48. Creates a Shape from the points. The first point defines the offset, then
  49. successive points are added to the [page:CurvePath.curves curves] array as
  50. [page:LineCurve LineCurves].<br /><br />
  51. If no points are specified, an empty shape is created and the
  52. [page:.currentPoint] is set to the origin.
  53. </p>
  54. <h2>Properties</h2>
  55. <p>See the base [page:Path] class for common properties.</p>
  56. <h3>[property:String uuid]</h3>
  57. <p>
  58. [link:http://en.wikipedia.org/wiki/Universally_unique_identifier UUID] of
  59. this instance. This gets automatically assigned, so this shouldn't be
  60. edited.
  61. </p>
  62. <h3>[property:Array holes]</h3>
  63. <p>An array of [page:Path paths] that define the holes in the shape.</p>
  64. <h2>Methods</h2>
  65. <p>See the base [page:Path] class for common methods.</p>
  66. <h3>[method:Array extractPoints]( [param:Integer divisions] )</h3>
  67. <p>
  68. divisions -- The fineness of the result.<br /><br />
  69. Call [page:Curve.getPoints getPoints] on the shape and the [page:.holes]
  70. array, and return an object of the form:
  71. <code> { shape holes } </code>
  72. where shape and holes are arrays of [page:Vector2 Vector2s].
  73. </p>
  74. <h3>[method:Array getPointsHoles]( [param:Integer divisions] )</h3>
  75. <p>
  76. divisions -- The fineness of the result.<br /><br />
  77. Get an array of [page:Vector2 Vector2s] that represent the holes in the
  78. shape.
  79. </p>
  80. <h2>Source</h2>
  81. <p>
  82. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  83. </p>
  84. </body>
  85. </html>