ShapeGeometry.html 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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">
  13. Creates an one-sided polygonal geometry from one or more path shapes.
  14. </p>
  15. <iframe
  16. id="scene"
  17. src="scenes/geometry-browser.html#ShapeGeometry"
  18. ></iframe>
  19. <script>
  20. // iOS iframe auto-resize workaround
  21. if ( /(iPad|iPhone|iPod)/g.test( navigator.userAgent ) ) {
  22. const scene = document.getElementById( 'scene' );
  23. scene.style.width = getComputedStyle( scene ).width;
  24. scene.style.height = getComputedStyle( scene ).height;
  25. scene.setAttribute( 'scrolling', 'no' );
  26. }
  27. </script>
  28. <h2>Code Example</h2>
  29. <code>
  30. const x = 0, y = 0;
  31. const heartShape = new THREE.Shape();
  32. heartShape.moveTo( x + 5, y + 5 );
  33. heartShape.bezierCurveTo( x + 5, y + 5, x + 4, y, x, y );
  34. heartShape.bezierCurveTo( x - 6, y, x - 6, y + 7,x - 6, y + 7 );
  35. heartShape.bezierCurveTo( x - 6, y + 11, x - 3, y + 15.4, x + 5, y + 19 );
  36. heartShape.bezierCurveTo( x + 12, y + 15.4, x + 16, y + 11, x + 16, y + 7 );
  37. heartShape.bezierCurveTo( x + 16, y + 7, x + 16, y, x + 10, y );
  38. heartShape.bezierCurveTo( x + 7, y, x + 5, y + 5, x + 5, y + 5 );
  39. const geometry = new THREE.ShapeGeometry( heartShape );
  40. const material = new THREE.MeshBasicMaterial( { color: 0x00ff00 } );
  41. const mesh = new THREE.Mesh( geometry, material ) ;
  42. scene.add( mesh );
  43. </code>
  44. <h2>Constructor</h2>
  45. <h3>[name]([param:Array shapes], [param:Integer curveSegments])</h3>
  46. <p>
  47. shapes — [page:Array] of shapes or a single [page:Shape shape]. Default is
  48. a single triangle shape.<br />
  49. curveSegments - [page:Integer] - Number of segments per shape. Default is
  50. 12.
  51. </p>
  52. <h2>Properties</h2>
  53. <p>See the base [page:BufferGeometry] class for common properties.</p>
  54. <h3>[property:Object parameters]</h3>
  55. <p>
  56. An object with a property for each of the constructor parameters. Any
  57. modification after instantiation does not change the geometry.
  58. </p>
  59. <h2>Methods</h2>
  60. <p>See the base [page:BufferGeometry] class for common methods.</p>
  61. <h2>Source</h2>
  62. <p>
  63. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  64. </p>
  65. </body>
  66. </html>