Shape.html 3.0 KB

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