ShapeGeometry.html 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <!DOCTYPE html>
  2. <html lang="zh">
  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">从一个或多个路径形状中创建一个单面多边形几何体。</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>代码示例</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>构造器</h2>
  40. <h3>[name]([param:Array shapes], [param:Integer curveSegments])</h3>
  41. <p>
  42. shapes — 一个单独的[page:Shape shape],或者一个包含形状的[page:Array]。Default is a single triangle shape.<br />
  43. curveSegments - [page:Integer] - 每一个形状的分段数,默认值为12。
  44. </p>
  45. <h2>属性</h2>
  46. <p>共有属性请参见其基类[page:BufferGeometry]。</p>
  47. <h3>[property:Object parameters]</h3>
  48. <p>
  49. 一个包含着构造函数中每个参数的对象。在对象实例化之后,对该属性的任何修改都不会改变这个几何体。
  50. </p>
  51. <h2>方法(Methods)</h2>
  52. <p>共有方法请参见其基类[page:BufferGeometry]。</p>
  53. <h2>源代码</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>