Path.html 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <base href="../../../../" />
  6. <script src="list.js"></script>
  7. <script src="page.js"></script>
  8. <link type="text/css" rel="stylesheet" href="page.css" />
  9. </head>
  10. <body>
  11. [page:Curve] &rarr; [page:CurvePath] &rarr;
  12. <h1>[name]</h1>
  13. <p class="desc">
  14. A 2D path representation. The class provides methods for creating paths and contours of 2D shapes similar to the 2D Canvas API.
  15. </p>
  16. <h2>Example</h2>
  17. <code>
  18. var path = new THREE.Path();
  19. path.lineTo( 0, 0.8 );
  20. path.quadraticCurveTo( 0, 1, 0.2, 1 );
  21. path.lineTo( 1, 1 );
  22. var points = path.getPoints();
  23. var geometry = new THREE.BufferGeometry().setFromPoints( points );
  24. var material = new THREE.LineBasicMaterial( { color: 0xffffff } );
  25. var line = new THREE.Line( geometry, material );
  26. scene.add( line );
  27. </code>
  28. <h2>Constructor</h2>
  29. <h3>[name]( [param:Array points] )</h3>
  30. <p>
  31. points -- (optional) array of [page:Vector2 Vector2s].<br /><br />
  32. Creates a Path from the points. The first point defines the offset, then successive points
  33. are added to the [page:CurvePath.curves curves] array as [page:LineCurve LineCurves].<br /><br />
  34. If no points are specified, an empty path is created and the [page:.currentPoint] is set to
  35. the origin.
  36. </p>
  37. <h2>Properties</h2>
  38. <p>See the base [page:CurvePath] class for common properties.</p>
  39. <h3>[property:array currentPoint]</h3>
  40. <p>The current offset of the path. Any new [page:Curve] added will start here.</p>
  41. <h2>Methods</h2>
  42. <p>See the base [page:CurvePath] class for common methods.</p>
  43. <h3>[method:null absarc]( [param:Float x], [param:Float y], [param:Float radius], [param:Float startAngle], [param:Float endAngle], [param:Float clockwise] )</h3>
  44. <p>
  45. x, y -- The absolute center of the arc.<br />
  46. radius -- The radius of the arc.<br />
  47. startAngle -- The start angle in radians.<br />
  48. endAngle -- The end angle in radians.<br />
  49. clockwise -- Sweep the arc clockwise. Defaults to *false*.<br /><br />
  50. Adds an absolutely positioned [page:EllipseCurve EllipseCurve] to the path.
  51. </p>
  52. <h3>[method:null absellipse]( [param:Float x], [param:Float y], [param:Float xRadius], [param:Float yRadius], [param:Float startAngle], [param:Float endAngle], [param:Float clockwise], [param:Float rotation] )</h3>
  53. <p>
  54. x, y -- The absolute center of the ellipse.<br />
  55. xRadius -- The radius of the ellipse in the x axis.<br />
  56. yRadius -- The radius of the ellipse in the y axis.<br />
  57. startAngle -- The start angle in radians.<br />
  58. endAngle -- The end angle in radians.<br />
  59. clockwise -- Sweep the ellipse clockwise. Defaults to false.<br />
  60. rotation -- The rotation angle of the ellipse in radians, counterclockwise from the positive X axis. Optional, defaults to 0.<br /><br />
  61. Adds an absolutely positioned [page:EllipseCurve EllipseCurve] to the path.
  62. </p>
  63. <h3>[method:null arc]( [param:Float x], [param:Float y], [param:Float radius], [param:Float startAngle], [param:Float endAngle], [param:Float clockwise] )</h3>
  64. <p>
  65. x, y -- The center of the arc offset from the last call.<br />
  66. radius -- The radius of the arc.<br />
  67. startAngle -- The start angle in radians.<br />
  68. endAngle -- The end angle in radians.<br />
  69. clockwise -- Sweep the arc clockwise. Defaults to *false*.<br /><br />
  70. Adds an [page:EllipseCurve EllipseCurve] to the path, positioned relative to [page:.currentPoint].
  71. </p>
  72. <h3>[method:null bezierCurveTo]( [param:Float cp1X], [param:Float cp1Y], [param:Float cp2X], [param:Float cp2Y], [param:Float x], [param:Float y] )</h3>
  73. <p>This creates a bezier curve from [page:.currentPoint] with (cp1X, cp1Y) and (cp2X, cp2Y) as control points and updates [page:.currentPoint] to x and y.</p>
  74. <h3>[method:null ellipse]( [param:Float x], [param:Float y], [param:Float xRadius], [param:Float yRadius], [param:Float startAngle], [param:Float endAngle], [param:Float clockwise], [param:Float rotation] )</h3>
  75. <p>
  76. x, y -- The center of the ellipse offset from the last call.<br />
  77. xRadius -- The radius of the ellipse in the x axis.<br />
  78. yRadius -- The radius of the ellipse in the y axis.<br />
  79. startAngle -- The start angle in radians.<br />
  80. endAngle -- The end angle in radians.<br />
  81. clockwise -- Sweep the ellipse clockwise. Defaults to *false*.<br />
  82. rotation -- The rotation angle of the ellipse in radians, counterclockwise from the positive X axis. Optional, defaults to *0*.<br /><br />
  83. Adds an [page:EllipseCurve EllipseCurve] to the path, positioned relative to [page:.currentPoint].
  84. </p>
  85. <h3>[method:null lineTo]( [param:Float x], [param:Float y] )</h3>
  86. <p>Connects a [page:LineCurve] from [page:.currentPoint] to x, y onto the path.</p>
  87. <h3>[method:null moveTo]( [param:Float x], [param:Float y] )</h3>
  88. <p>Move the [page:.currentPoint] to x, y.</p>
  89. <h3>[method:null quadraticCurveTo]( [param:Float cpX], [param:Float cpY], [param:Float x], [param:Float y] )</h3>
  90. <p>Creates a quadratic curve from [page:.currentPoint] with cpX and cpY as control point and updates [page:.currentPoint] to x and y.</p>
  91. <h3>[method:null setFromPoints]( [param:Array vector2s] )</h3>
  92. <p>
  93. points -- array of [page:Vector2 Vector2s].<br /><br />
  94. Points are added to the [page:CurvePath.curves curves]
  95. array as [page:LineCurve LineCurves].
  96. </p>
  97. <h3>[method:null splineThru] ( [param:Array points] ) </h3>
  98. <p>
  99. points - An array of [page:Vector2 Vector2s]<br /><br />
  100. Connects a new [page:SplineCurve] onto the path.
  101. </p>
  102. <h2>Source</h2>
  103. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  104. </body>
  105. </html>