three.js CatmullRomCurve3

2023-02-16 17:33 更新

使用Catmull-Rom算法, 从一系列的点创建一条平滑的三维样条曲线。

代码示例

//Create a closed wavey loop
const curve = new THREE.CatmullRomCurve3( [
	new THREE.Vector3( -10, 0, 10 ),
	new THREE.Vector3( -5, 5, 5 ),
	new THREE.Vector3( 0, 0, 0 ),
	new THREE.Vector3( 5, -5, 5 ),
	new THREE.Vector3( 10, 0, 10 )
] );

const points = curve.getPoints( 50 );
const geometry = new THREE.BufferGeometry().setFromPoints( points );

const material = new THREE.LineBasicMaterial( { color: 0xff0000 } );

// Create the final object to add to the scene
const curveObject = new THREE.Line( geometry, material );

例子

WebGL / geometry / extrude / splines

构造函数

CatmullRomCurve3( points : Array, closed : Boolean, curveType : String, tension : Float )

points – Vector3点数组
closed – 该曲线是否闭合,默认值为false。
curveType – 曲线的类型,默认值为centripetal
tension – 曲线的张力,默认为0.5

属性

共有属性请参见其基类Curve。

.points : Array

定义了这一曲线的Vector3点数组,数组中至少需要两个点。

.closed : Boolean

当该值为true时,曲线将会闭合(环回自身)。

.curveType : String

可能的值为centripetal、chordal和catmullrom。

.tension : Float

当.curveType为catmullrom时,定义catmullrom的张力。

方法

共有方法请参见其基类Curve。

源代码

src/extras/curves/CatmullRomCurve3.js


以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号