| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586 |
- <!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.<<a href="Vector2.html">Vector2</a>></span> )</span> </h3>
- <div class="method">
- <div class="description">
- <p>Constructs a new path.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name">
- <strong>points</strong>
- </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">
- <strong>aX</strong>
- </td>
- <td class="description last">
- <p>The x coordinate of the center of the arc.</p>
- <p>Default is <code>0</code>.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>aY</strong>
- </td>
- <td class="description last">
- <p>The y coordinate of the center of the arc.</p>
- <p>Default is <code>0</code>.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>aRadius</strong>
- </td>
- <td class="description last">
- <p>The radius of the arc.</p>
- <p>Default is <code>1</code>.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>aStartAngle</strong>
- </td>
- <td class="description last">
- <p>The start angle in radians.</p>
- <p>Default is <code>0</code>.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>aEndAngle</strong>
- </td>
- <td class="description last">
- <p>The end angle in radians.</p>
- <p>Default is <code>Math.PI*2</code>.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>aClockwise</strong>
- </td>
- <td class="description last">
- <p>Whether to sweep the arc clockwise or not.</p>
- <p>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">
- <strong>aX</strong>
- </td>
- <td class="description last">
- <p>The x coordinate of the absolute center of the ellipse.</p>
- <p>Default is <code>0</code>.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>aY</strong>
- </td>
- <td class="description last">
- <p>The y coordinate of the absolute center of the ellipse.</p>
- <p>Default is <code>0</code>.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>xRadius</strong>
- </td>
- <td class="description last">
- <p>The radius of the ellipse in the x axis.</p>
- <p>Default is <code>1</code>.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>yRadius</strong>
- </td>
- <td class="description last">
- <p>The radius of the ellipse in the y axis.</p>
- <p>Default is <code>1</code>.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>aStartAngle</strong>
- </td>
- <td class="description last">
- <p>The start angle in radians.</p>
- <p>Default is <code>0</code>.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>aEndAngle</strong>
- </td>
- <td class="description last">
- <p>The end angle in radians.</p>
- <p>Default is <code>Math.PI*2</code>.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>aClockwise</strong>
- </td>
- <td class="description last">
- <p>Whether to sweep the ellipse clockwise or not.</p>
- <p>Default is <code>false</code>.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>aRotation</strong>
- </td>
- <td class="description last">
- <p>The rotation angle of the ellipse in radians, counterclockwise from the positive X axis.</p>
- <p>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">
- <strong>aX</strong>
- </td>
- <td class="description last">
- <p>The x coordinate of the center of the arc offsetted from the previous curve.</p>
- <p>Default is <code>0</code>.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>aY</strong>
- </td>
- <td class="description last">
- <p>The y coordinate of the center of the arc offsetted from the previous curve.</p>
- <p>Default is <code>0</code>.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>aRadius</strong>
- </td>
- <td class="description last">
- <p>The radius of the arc.</p>
- <p>Default is <code>1</code>.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>aStartAngle</strong>
- </td>
- <td class="description last">
- <p>The start angle in radians.</p>
- <p>Default is <code>0</code>.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>aEndAngle</strong>
- </td>
- <td class="description last">
- <p>The end angle in radians.</p>
- <p>Default is <code>Math.PI*2</code>.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>aClockwise</strong>
- </td>
- <td class="description last">
- <p>Whether to sweep the arc clockwise or not.</p>
- <p>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">
- <strong>aCP1x</strong>
- </td>
- <td class="description last">
- <p>The x coordinate of the first control point.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>aCP1y</strong>
- </td>
- <td class="description last">
- <p>The y coordinate of the first control point.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>aCP2x</strong>
- </td>
- <td class="description last">
- <p>The x coordinate of the second control point.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>aCP2y</strong>
- </td>
- <td class="description last">
- <p>The y coordinate of the second control point.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>aX</strong>
- </td>
- <td class="description last">
- <p>The x coordinate of the end point.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>aY</strong>
- </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">
- <strong>aX</strong>
- </td>
- <td class="description last">
- <p>The x coordinate of the center of the ellipse offsetted from the previous curve.</p>
- <p>Default is <code>0</code>.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>aY</strong>
- </td>
- <td class="description last">
- <p>The y coordinate of the center of the ellipse offsetted from the previous curve.</p>
- <p>Default is <code>0</code>.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>xRadius</strong>
- </td>
- <td class="description last">
- <p>The radius of the ellipse in the x axis.</p>
- <p>Default is <code>1</code>.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>yRadius</strong>
- </td>
- <td class="description last">
- <p>The radius of the ellipse in the y axis.</p>
- <p>Default is <code>1</code>.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>aStartAngle</strong>
- </td>
- <td class="description last">
- <p>The start angle in radians.</p>
- <p>Default is <code>0</code>.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>aEndAngle</strong>
- </td>
- <td class="description last">
- <p>The end angle in radians.</p>
- <p>Default is <code>Math.PI*2</code>.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>aClockwise</strong>
- </td>
- <td class="description last">
- <p>Whether to sweep the ellipse clockwise or not.</p>
- <p>Default is <code>false</code>.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>aRotation</strong>
- </td>
- <td class="description last">
- <p>The rotation angle of the ellipse in radians, counterclockwise from the positive X axis.</p>
- <p>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">
- <strong>x</strong>
- </td>
- <td class="description last">
- <p>The x coordinate of the end point.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>y</strong>
- </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">
- <strong>x</strong>
- </td>
- <td class="description last">
- <p>The x coordinate.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>y</strong>
- </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">
- <strong>aCPx</strong>
- </td>
- <td class="description last">
- <p>The x coordinate of the control point.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>aCPy</strong>
- </td>
- <td class="description last">
- <p>The y coordinate of the control point.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>aX</strong>
- </td>
- <td class="description last">
- <p>The x coordinate of the end point.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>aY</strong>
- </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.<<a href="Vector2.html">Vector2</a>></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">
- <strong>points</strong>
- </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.<<a href="Vector2.html">Vector2</a>></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">
- <strong>pts</strong>
- </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" translate="no" target="_blank" rel="noopener">src/extras/core/Path.js</a>
- </p>
- </article>
- </section>
- <script src="../scripts/linenumber.js"></script>
- <script src="../scripts/page.js"></script>
- </body>
- </html>
|