曲线路径(CurvePath)

优质
小牛编辑
125浏览
2023-12-01

一个扩展了Curve的抽象基类。CurvePath仅仅是一个已连接的曲线的数组,但保留了曲线的API。

构造函数

CurvePath()

构造函数中不传入参数。

属性

共有属性请参见其基类Curve

.curves : Array

Curves数组。

.autoClose : Boolean

是否自动闭合路径。

方法

共有方法请参见其基类Curve

.add ( curve : Curve ) : null

添加一条曲线到.curves数组中。

.closePath () : null

添加一条lineCurve用于闭合路径。

.getCurveLengths () : Array

Get list of cumulative curve lengths of the curves in the .curves array.

.getPoint ( t : Float ) : Vector

t - A position on the curve. Must be in the range [ 0, 1 ].

Returns a vector for a given position on the curve path.

.getPoints ( divisions : Integer ) : Array

divisions -- 曲线分段数量。默认值为12

返回一组使用getPoint( t )获得的divisions + 1个点。

.getSpacedPoints ( divisions : Integer ) : Array

divisions -- 曲线分段数量。默认值为40

返回一组使用getPointAt( u )获得的divisions + 1个均分点。

源代码

src/extras/core/CurvePath.js