CatmullRomCurve3.html 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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;
  11. <h1>[name]</h1>
  12. <p class="desc">
  13. Create a smooth 3d spline curve from a series of points using the
  14. [link:https://en.wikipedia.org/wiki/Centripetal_Catmull-Rom_spline Catmull-Rom] algorithm.
  15. </p>
  16. <h2>Code Example</h2>
  17. <code>
  18. //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>
  32. <h2>Examples</h2>
  33. <p>
  34. [example:webgl_geometry_extrude_splines WebGL / geometry / extrude / splines]
  35. </p>
  36. <h2>Constructor</h2>
  37. <h3>
  38. [name]( [param:Array points], [param:Boolean closed], [param:String curveType], [param:Float tension] )
  39. </h3>
  40. <p>
  41. points – An array of [page:Vector3] points<br />
  42. closed – Whether the curve is closed. Default is `false`.<br />
  43. curveType – Type of the curve. Default is `centripetal`.<br />
  44. tension – Tension of the curve. Default is `0.5`.
  45. </p>
  46. <h2>Properties</h2>
  47. <p>See the base [page:Curve] class for common properties.</p>
  48. <h3>[property:Array points]</h3>
  49. <p>
  50. The array of [page:Vector3] points that define the curve. It needs at
  51. least two entries.
  52. </p>
  53. <h3>[property:Boolean closed]</h3>
  54. <p>The curve will loop back onto itself when this is true.</p>
  55. <h3>[property:String curveType]</h3>
  56. <p>Possible values are `centripetal`, `chordal` and `catmullrom`.</p>
  57. <h3>[property:Float tension]</h3>
  58. <p>When [page:.curveType] is `catmullrom`, defines catmullrom's tension.</p>
  59. <h2>Methods</h2>
  60. <p>See the base [page:Curve] class for common methods.</p>
  61. <h2>Source</h2>
  62. <p>
  63. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  64. </p>
  65. </body>
  66. </html>