Path.html 5.6 KB

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