ShapeGeometry.html 2.3 KB

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