Shape.html 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Shape - Three.js Docs</title>
  6. <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
  7. <script src="../scripts/highlight.min.js"></script>
  8. <link type="text/css" rel="stylesheet" href="../styles/highlight-three.css">
  9. <link type="text/css" rel="stylesheet" href="../styles/page.css">
  10. </head>
  11. <body>
  12. <p class="inheritance" translate="no"><a href="Curve.html">Curve</a> → <a href="CurvePath.html">CurvePath</a> → <a href="Path.html">Path</a> → </p>
  13. <h1 translate="no">Shape</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>Defines an arbitrary 2d shape plane using paths with optional holes. It
  17. can be used with <a href="ExtrudeGeometry.html">ExtrudeGeometry</a>, <a href="ShapeGeometry.html">ShapeGeometry</a>, to get
  18. points, or to get triangulated faces.</p></div>
  19. <h2>Code Example</h2>
  20. <div translate="no"><pre><code class="language-js">const heartShape = new THREE.Shape();
  21. heartShape.moveTo( 25, 25 );
  22. heartShape.bezierCurveTo( 25, 25, 20, 0, 0, 0 );
  23. heartShape.bezierCurveTo( - 30, 0, - 30, 35, - 30, 35 );
  24. heartShape.bezierCurveTo( - 30, 55, - 10, 77, 25, 95 );
  25. heartShape.bezierCurveTo( 60, 77, 80, 55, 80, 35 );
  26. heartShape.bezierCurveTo( 80, 35, 80, 0, 50, 0 );
  27. heartShape.bezierCurveTo( 35, 0, 25, 25, 25, 25 );
  28. const extrudeSettings = {
  29. depth: 8,
  30. bevelEnabled: true,
  31. bevelSegments: 2,
  32. steps: 2,
  33. bevelSize: 1,
  34. bevelThickness: 1
  35. };
  36. const geometry = new THREE.ExtrudeGeometry( heartShape, extrudeSettings );
  37. const mesh = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial() );
  38. </code></pre></div>
  39. </header>
  40. <article>
  41. <div class="container-overview">
  42. <h2>Constructor</h2>
  43. <h3 class="name name-method" id="Shape" translate="no">new <a href="#Shape">Shape</a><span class="signature">( points : <span class="param-type">Array.&lt;<a href="Vector2.html">Vector2</a>></span> )</span> </h3>
  44. <div class="method">
  45. <div class="description">
  46. <p>Constructs a new shape.</p>
  47. </div>
  48. <table class="params">
  49. <tbody>
  50. <tr>
  51. <td class="name">
  52. <strong>points</strong>
  53. </td>
  54. <td class="description last">
  55. <p>An array of 2D points defining the shape.</p>
  56. </td>
  57. </tr>
  58. </tbody>
  59. </table>
  60. </div>
  61. </div>
  62. <h2 class="subsection-title">Properties</h2>
  63. <div class="member">
  64. <h3 class="name" id="holes" translate="no">.<a href="#holes">holes</a><span class="type-signature"> : Array.&lt;<a href="Path.html">Path</a>></span> <span class="type-signature">(readonly) </span></h3>
  65. <div class="description">
  66. <p>Defines the holes in the shape. Hole definitions must use the
  67. opposite winding order (CW/CCW) than the outer shape.</p>
  68. </div>
  69. </div>
  70. <div class="member">
  71. <h3 class="name" id="uuid" translate="no">.<a href="#uuid">uuid</a><span class="type-signature"> : string</span> <span class="type-signature">(readonly) </span></h3>
  72. <div class="description">
  73. <p>The UUID of the shape.</p>
  74. </div>
  75. </div>
  76. <h2 class="subsection-title">Methods</h2>
  77. <h3 class="name name-method" id="extractPoints" translate="no">.<a href="#extractPoints">extractPoints</a><span class="signature">( divisions : <span class="param-type">number</span> )</span><span class="type-signature"> : Object</span> </h3>
  78. <div class="method">
  79. <div class="description">
  80. <p>Returns an object that holds contour data for the shape and its holes as
  81. arrays of 2D points.</p>
  82. </div>
  83. <table class="params">
  84. <tbody>
  85. <tr>
  86. <td class="name">
  87. <strong>divisions</strong>
  88. </td>
  89. <td class="description last">
  90. <p>The fineness of the result.</p>
  91. </td>
  92. </tr>
  93. </tbody>
  94. </table>
  95. <dl class="details">
  96. <dt class="tag-returns"><strong>Returns:</strong> An object with contour data.</dt>
  97. </dl>
  98. </div>
  99. <h3 class="name name-method" id="getPointsHoles" translate="no">.<a href="#getPointsHoles">getPointsHoles</a><span class="signature">( divisions : <span class="param-type">number</span> )</span><span class="type-signature"> : Array.&lt;Array.&lt;<a href="Vector2.html">Vector2</a>>></span> </h3>
  100. <div class="method">
  101. <div class="description">
  102. <p>Returns an array representing each contour of the holes
  103. as a list of 2D points.</p>
  104. </div>
  105. <table class="params">
  106. <tbody>
  107. <tr>
  108. <td class="name">
  109. <strong>divisions</strong>
  110. </td>
  111. <td class="description last">
  112. <p>The fineness of the result.</p>
  113. </td>
  114. </tr>
  115. </tbody>
  116. </table>
  117. <dl class="details">
  118. <dt class="tag-returns"><strong>Returns:</strong> The holes as a series of 2D points.</dt>
  119. </dl>
  120. </div>
  121. <h2 class="subsection-title">Source</h2>
  122. <p>
  123. <a href="https://github.com/mrdoob/three.js/blob/master/src/extras/core/Shape.js" translate="no" target="_blank" rel="noopener">src/extras/core/Shape.js</a>
  124. </p>
  125. </article>
  126. </section>
  127. <script src="../scripts/linenumber.js"></script>
  128. <script src="../scripts/page.js"></script>
  129. </body>
  130. </html>
粤ICP备19079148号