2
0

CatmullRomCurve3.html 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <!DOCTYPE html>
  2. <html lang="zh">
  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. 使用[link:https://en.wikipedia.org/wiki/Centripetal_Catmull-Rom_spline Catmull-Rom]算法,
  14. 从一系列的点创建一条平滑的三维样条曲线。</p>
  15. <h2>代码示例</h2>
  16. <code>
  17. //Create a closed wavey loop
  18. const curve = new THREE.CatmullRomCurve3( [
  19. new THREE.Vector3( -10, 0, 10 ),
  20. new THREE.Vector3( -5, 5, 5 ),
  21. new THREE.Vector3( 0, 0, 0 ),
  22. new THREE.Vector3( 5, -5, 5 ),
  23. new THREE.Vector3( 10, 0, 10 )
  24. ] );
  25. const points = curve.getPoints( 50 );
  26. const geometry = new THREE.BufferGeometry().setFromPoints( points );
  27. const material = new THREE.LineBasicMaterial( { color: 0xff0000 } );
  28. // Create the final object to add to the scene
  29. const curveObject = new THREE.Line( geometry, material );
  30. </code>
  31. <h2>例子</h2>
  32. <p>
  33. [example:webgl_geometry_extrude_splines WebGL / geometry / extrude / splines]
  34. </p>
  35. <h2>构造函数</h2>
  36. <h3>[name]( [param:Array points], [param:Boolean closed], [param:String curveType], [param:Float tension] )</h3>
  37. <p>
  38. points – [page:Vector3]点数组<br/>
  39. closed – 该曲线是否闭合,默认值为false。<br/>
  40. curveType – 曲线的类型,默认值为*centripetal*。<br/>
  41. tension – 曲线的张力,默认为*0.5*。
  42. </p>
  43. <h2>属性</h2>
  44. <p>共有属性请参见其基类[page:Curve]。</p>
  45. <h3>[property:Array points]</h3>
  46. <p>定义了这一曲线的[page:Vector3]点数组,数组中至少需要两个点。</p>
  47. <h3>[property:Boolean closed]</h3>
  48. <p>当该值为true时,曲线将会闭合(环回自身)。</p>
  49. <h3>[property:String curveType]</h3>
  50. <p>可能的值为*centripetal*、*chordal*和*catmullrom*。</p>
  51. <h3>[property:Float tension]</h3>
  52. <p>当[page:.curveType]为*catmullrom*时,定义catmullrom的张力。</p>
  53. <h2>方法</h2>
  54. <p>共有方法请参见其基类[page:Curve]。</p>
  55. <h2>源代码</h2>
  56. <p>
  57. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  58. </p>
  59. </body>
  60. </html>