2
0

CatmullRomCurve3.html 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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">Create a smooth 3d spline curve from a series of points using the
  13. [link:https://en.wikipedia.org/wiki/Centripetal_Catmull-Rom_spline Catmull-Rom] algorithm.</p>
  14. <h2>Code Example</h2>
  15. <code>
  16. //Create a closed wavey loop
  17. const curve = new THREE.CatmullRomCurve3( [
  18. new THREE.Vector3( -10, 0, 10 ),
  19. new THREE.Vector3( -5, 5, 5 ),
  20. new THREE.Vector3( 0, 0, 0 ),
  21. new THREE.Vector3( 5, -5, 5 ),
  22. new THREE.Vector3( 10, 0, 10 )
  23. ] );
  24. const points = curve.getPoints( 50 );
  25. const geometry = new THREE.BufferGeometry().setFromPoints( points );
  26. const material = new THREE.LineBasicMaterial( { color : 0xff0000 } );
  27. // Create the final object to add to the scene
  28. const curveObject = new THREE.Line( geometry, material );
  29. </code>
  30. <h2>Examples</h2>
  31. <p>
  32. [example:webgl_geometry_extrude_splines WebGL / geometry / extrude / splines]
  33. </p>
  34. <h2>Constructor</h2>
  35. <h3>[name]( [param:Array points], [param:Boolean closed], [param:String curveType], [param:Float tension] )</h3>
  36. <p>
  37. points – An array of [page:Vector3] points<br/>
  38. closed – Whether the curve is closed. Default is *false*.<br/>
  39. curveType – Type of the curve. Default is *centripetal*.<br/>
  40. tension – Tension of the curve. Default is *0.5*.
  41. </p>
  42. <h2>Properties</h2>
  43. <p>See the base [page:Curve] class for common properties.</p>
  44. <h3>[property:Array points]</h3>
  45. <p>The array of [page:Vector3] points that define the curve. It needs at least two entries.</p>
  46. <h3>[property:Boolean closed]</h3>
  47. <p>The curve will loop back onto itself when this is true.</p>
  48. <h3>[property:String curveType]</h3>
  49. <p>Possible values are *centripetal*, *chordal* and *catmullrom*.</p>
  50. <h3>[property:Float tension]</h3>
  51. <p>When [page:.curveType] is *catmullrom*, defines catmullrom's tension.</p>
  52. <h2>Methods</h2>
  53. <p>See the base [page:Curve] class for common methods.</p>
  54. <h2>Source</h2>
  55. <p>
  56. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  57. </p>
  58. </body>
  59. </html>