CatmullRomCurve3.html 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>CatmullRomCurve3 - Three.js Docs</title>
  6. <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
  7. <script src="../scripts/highlight.min.js"></script>
  8. <link type="text/css" rel="stylesheet" href="../styles/highlight-three.css">
  9. <link type="text/css" rel="stylesheet" href="../styles/page.css">
  10. </head>
  11. <body>
  12. <p class="inheritance" translate="no"><a href="Curve.html">Curve</a> → </p>
  13. <h1 translate="no">CatmullRomCurve3</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>A curve representing a Catmull-Rom spline.</p></div>
  17. <h2>Code Example</h2>
  18. <div translate="no"><pre><code class="language-js">//Create a closed wavey loop
  19. const curve = new THREE.CatmullRomCurve3( [
  20. new THREE.Vector3( -10, 0, 10 ),
  21. new THREE.Vector3( -5, 5, 5 ),
  22. new THREE.Vector3( 0, 0, 0 ),
  23. new THREE.Vector3( 5, -5, 5 ),
  24. new THREE.Vector3( 10, 0, 10 )
  25. ] );
  26. const points = curve.getPoints( 50 );
  27. const geometry = new THREE.BufferGeometry().setFromPoints( points );
  28. const material = new THREE.LineBasicMaterial( { color: 0xff0000 } );
  29. // Create the final object to add to the scene
  30. const curveObject = new THREE.Line( geometry, material );
  31. </code></pre></div>
  32. </header>
  33. <article>
  34. <div class="container-overview">
  35. <h2>Constructor</h2>
  36. <h3 class="name name-method" id="CatmullRomCurve3" translate="no">new <a href="#CatmullRomCurve3">CatmullRomCurve3</a><span class="signature">( points : <span class="param-type">Array.&lt;Vector3></span>, closed : <span class="param-type">boolean</span>, curveType : <span class="param-type">'centripetal' | 'chordal' | 'catmullrom'</span>, tension : <span class="param-type">number</span> )</span> </h3>
  37. <div class="method">
  38. <div class="description">
  39. <p>Constructs a new Catmull-Rom curve.</p>
  40. </div>
  41. <table class="params">
  42. <tbody>
  43. <tr>
  44. <td class="name"><code>points</code></td>
  45. <td class="description last"><p>An array of 3D points defining the curve.</p></td>
  46. </tr>
  47. <tr>
  48. <td class="name"><code>closed</code></td>
  49. <td class="description last"><p>Whether the curve is closed or not.<br/>Default is <code>false</code>.</p></td>
  50. </tr>
  51. <tr>
  52. <td class="name"><code>curveType</code></td>
  53. <td class="description last"><p>The curve type.<br/>Default is <code>'centripetal'</code>.</p></td>
  54. </tr>
  55. <tr>
  56. <td class="name"><code>tension</code></td>
  57. <td class="description last"><p>Tension of the curve.<br/>Default is <code>0.5</code>.</p></td>
  58. </tr>
  59. </tbody>
  60. </table>
  61. </div>
  62. </div>
  63. <h2 class="subsection-title">Properties</h2>
  64. <div class="member">
  65. <h3 class="name" id="closed" translate="no">.<a href="#closed">closed</a><span class="type-signature"> : boolean</span> </h3>
  66. <div class="description">
  67. <p>Whether the curve is closed or not.<br/>Default is <code>false</code>.</p>
  68. </div>
  69. </div>
  70. <div class="member">
  71. <h3 class="name" id="curveType" translate="no">.<a href="#curveType">curveType</a><span class="type-signature"> : 'centripetal' | 'chordal' | 'catmullrom'</span> </h3>
  72. <div class="description">
  73. <p>The curve type.<br/>Default is <code>'centripetal'</code>.</p>
  74. </div>
  75. </div>
  76. <div class="member">
  77. <h3 class="name" id="isCatmullRomCurve3" translate="no">.<a href="#isCatmullRomCurve3">isCatmullRomCurve3</a><span class="type-signature"> : boolean</span> <span class="type-signature">(readonly) </span></h3>
  78. <div class="description">
  79. <p>This flag can be used for type testing.<br/>Default is <code>true</code>.</p>
  80. </div>
  81. </div>
  82. <div class="member">
  83. <h3 class="name" id="points" translate="no">.<a href="#points">points</a><span class="type-signature"> : Array.&lt;<a href="Vector3.html">Vector3</a>></span> </h3>
  84. <div class="description">
  85. <p>An array of 3D points defining the curve.</p>
  86. </div>
  87. </div>
  88. <div class="member">
  89. <h3 class="name" id="tension" translate="no">.<a href="#tension">tension</a><span class="type-signature"> : number</span> </h3>
  90. <div class="description">
  91. <p>Tension of the curve.<br/>Default is <code>0.5</code>.</p>
  92. </div>
  93. </div>
  94. <h2 class="subsection-title">Methods</h2>
  95. <h3 class="name name-method" id="getPoint" translate="no">.<a href="#getPoint">getPoint</a><span class="signature">( t : <span class="param-type">number</span>, optionalTarget : <span class="param-type">Vector3</span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  96. <div class="method">
  97. <div class="description">
  98. <p>Returns a point on the curve.</p>
  99. </div>
  100. <table class="params">
  101. <tbody>
  102. <tr>
  103. <td class="name"><code>t</code></td>
  104. <td class="description last"><p>A interpolation factor representing a position on the curve. Must be in the range <code>[0,1]</code>.</p></td>
  105. </tr>
  106. <tr>
  107. <td class="name"><code>optionalTarget</code></td>
  108. <td class="description last"><p>The optional target vector the result is written to.</p></td>
  109. </tr>
  110. </tbody>
  111. </table>
  112. <dl class="details">
  113. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Curve.html#getPoint">Curve#getPoint</a></dt>
  114. </dl>
  115. <dl class="details">
  116. <dt class="tag-returns"><strong>Returns:</strong> The position on the curve.</dt>
  117. </dl>
  118. </div>
  119. <h2 class="subsection-title">Source</h2>
  120. <p>
  121. <a href="https://github.com/mrdoob/three.js/blob/master/src/extras/curves/CatmullRomCurve3.js" target="_blank" rel="noopener" translate="no">src/extras/curves/CatmullRomCurve3.js</a>
  122. </p>
  123. </article>
  124. </section>
  125. <script src="../scripts/linenumber.js"></script>
  126. <script src="../scripts/page.js"></script>
  127. </body>
  128. </html>
粤ICP备19079148号