2
0

Path.html 5.7 KB

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