Shape.html 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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 ]
  42. </p>
  43. <h2>Constructor</h2>
  44. <h3>[name]( [param:Array points] )</h3>
  45. <p>
  46. points -- (optional) array of [page:Vector2 Vector2s].<br /><br />
  47. Creates a Shape from the points. The first point defines the offset, then
  48. successive points are added to the [page:CurvePath.curves curves] array as
  49. [page:LineCurve LineCurves].<br /><br />
  50. If no points are specified, an empty shape is created and the
  51. [page:.currentPoint] is set to the origin.
  52. </p>
  53. <h2>Properties</h2>
  54. <p>See the base [page:Path] class for common properties.</p>
  55. <h3>[property:String uuid]</h3>
  56. <p>
  57. [link:http://en.wikipedia.org/wiki/Universally_unique_identifier UUID] of
  58. this instance. This gets automatically assigned, so this shouldn't be
  59. edited.
  60. </p>
  61. <h3>[property:Array holes]</h3>
  62. <p>An array of [page:Path paths] that define the holes in the shape.</p>
  63. <h2>Methods</h2>
  64. <p>See the base [page:Path] class for common methods.</p>
  65. <h3>[method:Array extractPoints]( [param:Integer divisions] )</h3>
  66. <p>
  67. divisions -- The fineness of the result.<br /><br />
  68. Call [page:Curve.getPoints getPoints] on the shape and the [page:.holes]
  69. array, and return an object of the form:
  70. <code> { shape holes } </code>
  71. where shape and holes are arrays of [page:Vector2 Vector2s].
  72. </p>
  73. <h3>[method:Array getPointsHoles]( [param:Integer divisions] )</h3>
  74. <p>
  75. divisions -- The fineness of the result.<br /><br />
  76. Get an array of [page:Vector2 Vector2s] that represent the holes in the
  77. shape.
  78. </p>
  79. <h2>Source</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>