| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <title>Path - Three.js Docs</title>
- <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
- <script src="../scripts/highlight.min.js"></script>
- <link type="text/css" rel="stylesheet" href="../styles/highlight-three.css">
- <link type="text/css" rel="stylesheet" href="../styles/page.css">
- </head>
- <body>
- <p class="inheritance" translate="no"><a href="Curve.html">Curve</a> → <a href="CurvePath.html">CurvePath</a> → </p>
- <h1 translate="no">Path</h1>
- <section>
- <header>
- <div class="class-description"><p>A 2D path representation. The class provides methods for creating paths
- and contours of 2D shapes similar to the 2D Canvas API.</p></div>
- <h2>Code Example</h2>
- <div translate="no"><pre><code class="language-js">const path = new THREE.Path();
- path.lineTo( 0, 0.8 );
- path.quadraticCurveTo( 0, 1, 0.2, 1 );
- path.lineTo( 1, 1 );
- const points = path.getPoints();
- const geometry = new THREE.BufferGeometry().setFromPoints( points );
- const material = new THREE.LineBasicMaterial( { color: 0xffffff } );
- const line = new THREE.Line( geometry, material );
- scene.add( line );
- </code></pre></div>
- </header>
- <article>
- <div class="container-overview">
- <h2>Constructor</h2>
- <h3 class="name name-method" id="Path" translate="no">new <a href="#Path">Path</a><span class="signature">( points : <span class="param-type">Array.<Vector2></span> )</span> </h3>
- <div class="method">
- <div class="description">
- <p>Constructs a new path.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>points</code></td>
- <td class="description last"><p>An array of 2D points defining the path.</p></td>
- </tr>
- </tbody>
- </table>
- </div>
- </div>
- <h2 class="subsection-title">Properties</h2>
- <div class="member">
- <h3 class="name" id="currentPoint" translate="no">.<a href="#currentPoint">currentPoint</a><span class="type-signature"> : <a href="Vector2.html">Vector2</a></span> </h3>
- <div class="description">
- <p>The current offset of the path. Any new curve added will start here.</p>
- </div>
- </div>
- <h2 class="subsection-title">Methods</h2>
- <h3 class="name name-method" id="absarc" translate="no">.<a href="#absarc">absarc</a><span class="signature">( aX : <span class="param-type">number</span>, aY : <span class="param-type">number</span>, aRadius : <span class="param-type">number</span>, aStartAngle : <span class="param-type">number</span>, aEndAngle : <span class="param-type">number</span>, aClockwise : <span class="param-type">boolean</span> )</span><span class="type-signature"> : <a href="Path.html">Path</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Adds an absolutely positioned arc as an instance of <a href="EllipseCurve.html">EllipseCurve</a> to the path.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>aX</code></td>
- <td class="description last"><p>The x coordinate of the center of the arc.<br/>Default is <code>0</code>.</p></td>
- </tr>
- <tr>
- <td class="name"><code>aY</code></td>
- <td class="description last"><p>The y coordinate of the center of the arc.<br/>Default is <code>0</code>.</p></td>
- </tr>
- <tr>
- <td class="name"><code>aRadius</code></td>
- <td class="description last"><p>The radius of the arc.<br/>Default is <code>1</code>.</p></td>
- </tr>
- <tr>
- <td class="name"><code>aStartAngle</code></td>
- <td class="description last"><p>The start angle in radians.<br/>Default is <code>0</code>.</p></td>
- </tr>
- <tr>
- <td class="name"><code>aEndAngle</code></td>
- <td class="description last"><p>The end angle in radians.<br/>Default is <code>Math.PI*2</code>.</p></td>
- </tr>
- <tr>
- <td class="name"><code>aClockwise</code></td>
- <td class="description last"><p>Whether to sweep the arc clockwise or not.<br/>Default is <code>false</code>.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this path.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="absellipse" translate="no">.<a href="#absellipse">absellipse</a><span class="signature">( aX : <span class="param-type">number</span>, aY : <span class="param-type">number</span>, xRadius : <span class="param-type">number</span>, yRadius : <span class="param-type">number</span>, aStartAngle : <span class="param-type">number</span>, aEndAngle : <span class="param-type">number</span>, aClockwise : <span class="param-type">boolean</span>, aRotation : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Path.html">Path</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Adds an absolutely positioned ellipse as an instance of <a href="EllipseCurve.html">EllipseCurve</a> to the path.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>aX</code></td>
- <td class="description last"><p>The x coordinate of the absolute center of the ellipse.<br/>Default is <code>0</code>.</p></td>
- </tr>
- <tr>
- <td class="name"><code>aY</code></td>
- <td class="description last"><p>The y coordinate of the absolute center of the ellipse.<br/>Default is <code>0</code>.</p></td>
- </tr>
- <tr>
- <td class="name"><code>xRadius</code></td>
- <td class="description last"><p>The radius of the ellipse in the x axis.<br/>Default is <code>1</code>.</p></td>
- </tr>
- <tr>
- <td class="name"><code>yRadius</code></td>
- <td class="description last"><p>The radius of the ellipse in the y axis.<br/>Default is <code>1</code>.</p></td>
- </tr>
- <tr>
- <td class="name"><code>aStartAngle</code></td>
- <td class="description last"><p>The start angle in radians.<br/>Default is <code>0</code>.</p></td>
- </tr>
- <tr>
- <td class="name"><code>aEndAngle</code></td>
- <td class="description last"><p>The end angle in radians.<br/>Default is <code>Math.PI*2</code>.</p></td>
- </tr>
- <tr>
- <td class="name"><code>aClockwise</code></td>
- <td class="description last"><p>Whether to sweep the ellipse clockwise or not.<br/>Default is <code>false</code>.</p></td>
- </tr>
- <tr>
- <td class="name"><code>aRotation</code></td>
- <td class="description last"><p>The rotation angle of the ellipse in radians, counterclockwise from the positive X axis.<br/>Default is <code>0</code>.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this path.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="arc" translate="no">.<a href="#arc">arc</a><span class="signature">( aX : <span class="param-type">number</span>, aY : <span class="param-type">number</span>, aRadius : <span class="param-type">number</span>, aStartAngle : <span class="param-type">number</span>, aEndAngle : <span class="param-type">number</span>, aClockwise : <span class="param-type">boolean</span> )</span><span class="type-signature"> : <a href="Path.html">Path</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Adds an arc as an instance of <a href="EllipseCurve.html">EllipseCurve</a> to the path, positioned relative
- to the current point.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>aX</code></td>
- <td class="description last"><p>The x coordinate of the center of the arc offsetted from the previous curve.<br/>Default is <code>0</code>.</p></td>
- </tr>
- <tr>
- <td class="name"><code>aY</code></td>
- <td class="description last"><p>The y coordinate of the center of the arc offsetted from the previous curve.<br/>Default is <code>0</code>.</p></td>
- </tr>
- <tr>
- <td class="name"><code>aRadius</code></td>
- <td class="description last"><p>The radius of the arc.<br/>Default is <code>1</code>.</p></td>
- </tr>
- <tr>
- <td class="name"><code>aStartAngle</code></td>
- <td class="description last"><p>The start angle in radians.<br/>Default is <code>0</code>.</p></td>
- </tr>
- <tr>
- <td class="name"><code>aEndAngle</code></td>
- <td class="description last"><p>The end angle in radians.<br/>Default is <code>Math.PI*2</code>.</p></td>
- </tr>
- <tr>
- <td class="name"><code>aClockwise</code></td>
- <td class="description last"><p>Whether to sweep the arc clockwise or not.<br/>Default is <code>false</code>.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this path.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="bezierCurveTo" translate="no">.<a href="#bezierCurveTo">bezierCurveTo</a><span class="signature">( aCP1x : <span class="param-type">number</span>, aCP1y : <span class="param-type">number</span>, aCP2x : <span class="param-type">number</span>, aCP2y : <span class="param-type">number</span>, aX : <span class="param-type">number</span>, aY : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Path.html">Path</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Adds an instance of <a href="CubicBezierCurve.html">CubicBezierCurve</a> to the path by connecting
- the current point with the given one.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>aCP1x</code></td>
- <td class="description last"><p>The x coordinate of the first control point.</p></td>
- </tr>
- <tr>
- <td class="name"><code>aCP1y</code></td>
- <td class="description last"><p>The y coordinate of the first control point.</p></td>
- </tr>
- <tr>
- <td class="name"><code>aCP2x</code></td>
- <td class="description last"><p>The x coordinate of the second control point.</p></td>
- </tr>
- <tr>
- <td class="name"><code>aCP2y</code></td>
- <td class="description last"><p>The y coordinate of the second control point.</p></td>
- </tr>
- <tr>
- <td class="name"><code>aX</code></td>
- <td class="description last"><p>The x coordinate of the end point.</p></td>
- </tr>
- <tr>
- <td class="name"><code>aY</code></td>
- <td class="description last"><p>The y coordinate of the end point.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this path.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="ellipse" translate="no">.<a href="#ellipse">ellipse</a><span class="signature">( aX : <span class="param-type">number</span>, aY : <span class="param-type">number</span>, xRadius : <span class="param-type">number</span>, yRadius : <span class="param-type">number</span>, aStartAngle : <span class="param-type">number</span>, aEndAngle : <span class="param-type">number</span>, aClockwise : <span class="param-type">boolean</span>, aRotation : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Path.html">Path</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Adds an ellipse as an instance of <a href="EllipseCurve.html">EllipseCurve</a> to the path, positioned relative
- to the current point</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>aX</code></td>
- <td class="description last"><p>The x coordinate of the center of the ellipse offsetted from the previous curve.<br/>Default is <code>0</code>.</p></td>
- </tr>
- <tr>
- <td class="name"><code>aY</code></td>
- <td class="description last"><p>The y coordinate of the center of the ellipse offsetted from the previous curve.<br/>Default is <code>0</code>.</p></td>
- </tr>
- <tr>
- <td class="name"><code>xRadius</code></td>
- <td class="description last"><p>The radius of the ellipse in the x axis.<br/>Default is <code>1</code>.</p></td>
- </tr>
- <tr>
- <td class="name"><code>yRadius</code></td>
- <td class="description last"><p>The radius of the ellipse in the y axis.<br/>Default is <code>1</code>.</p></td>
- </tr>
- <tr>
- <td class="name"><code>aStartAngle</code></td>
- <td class="description last"><p>The start angle in radians.<br/>Default is <code>0</code>.</p></td>
- </tr>
- <tr>
- <td class="name"><code>aEndAngle</code></td>
- <td class="description last"><p>The end angle in radians.<br/>Default is <code>Math.PI*2</code>.</p></td>
- </tr>
- <tr>
- <td class="name"><code>aClockwise</code></td>
- <td class="description last"><p>Whether to sweep the ellipse clockwise or not.<br/>Default is <code>false</code>.</p></td>
- </tr>
- <tr>
- <td class="name"><code>aRotation</code></td>
- <td class="description last"><p>The rotation angle of the ellipse in radians, counterclockwise from the positive X axis.<br/>Default is <code>0</code>.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this path.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="lineTo" translate="no">.<a href="#lineTo">lineTo</a><span class="signature">( x : <span class="param-type">number</span>, y : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Path.html">Path</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Adds an instance of <a href="LineCurve.html">LineCurve</a> to the path by connecting
- the current point with the given one.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>x</code></td>
- <td class="description last"><p>The x coordinate of the end point.</p></td>
- </tr>
- <tr>
- <td class="name"><code>y</code></td>
- <td class="description last"><p>The y coordinate of the end point.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this path.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="moveTo" translate="no">.<a href="#moveTo">moveTo</a><span class="signature">( x : <span class="param-type">number</span>, y : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Path.html">Path</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Moves <a href="Path.html#currentPoint">Path#currentPoint</a> to the given point.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>x</code></td>
- <td class="description last"><p>The x coordinate.</p></td>
- </tr>
- <tr>
- <td class="name"><code>y</code></td>
- <td class="description last"><p>The y coordinate.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this path.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="quadraticCurveTo" translate="no">.<a href="#quadraticCurveTo">quadraticCurveTo</a><span class="signature">( aCPx : <span class="param-type">number</span>, aCPy : <span class="param-type">number</span>, aX : <span class="param-type">number</span>, aY : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Path.html">Path</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Adds an instance of <a href="QuadraticBezierCurve.html">QuadraticBezierCurve</a> to the path by connecting
- the current point with the given one.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>aCPx</code></td>
- <td class="description last"><p>The x coordinate of the control point.</p></td>
- </tr>
- <tr>
- <td class="name"><code>aCPy</code></td>
- <td class="description last"><p>The y coordinate of the control point.</p></td>
- </tr>
- <tr>
- <td class="name"><code>aX</code></td>
- <td class="description last"><p>The x coordinate of the end point.</p></td>
- </tr>
- <tr>
- <td class="name"><code>aY</code></td>
- <td class="description last"><p>The y coordinate of the end point.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this path.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="setFromPoints" translate="no">.<a href="#setFromPoints">setFromPoints</a><span class="signature">( points : <span class="param-type">Array.<Vector2></span> )</span><span class="type-signature"> : <a href="Path.html">Path</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Creates a path from the given list of points. The points are added
- to the path as instances of <a href="LineCurve.html">LineCurve</a>.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>points</code></td>
- <td class="description last"><p>An array of 2D points.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this path.</dt>
- </dl>
- </div>
- <h3 class="name name-method" id="splineThru" translate="no">.<a href="#splineThru">splineThru</a><span class="signature">( pts : <span class="param-type">Array.<Vector2></span> )</span><span class="type-signature"> : <a href="Path.html">Path</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Adds an instance of <a href="SplineCurve.html">SplineCurve</a> to the path by connecting
- the current point with the given list of points.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>pts</code></td>
- <td class="description last"><p>An array of points in 2D space.</p></td>
- </tr>
- </tbody>
- </table>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> A reference to this path.</dt>
- </dl>
- </div>
- <h2 class="subsection-title">Source</h2>
- <p>
- <a href="https://github.com/mrdoob/three.js/blob/master/src/extras/core/Path.js" target="_blank" rel="noopener" translate="no">src/extras/core/Path.js</a>
- </p>
- </article>
- </section>
- <script src="../scripts/linenumber.js"></script>
- <script src="../scripts/page.js"></script>
- </body>
- </html>
|