Appearance
KBE3D / KBCore / Cesium / CatmullRomSpline
类: CatmullRomSpline
A Catmull-Rom spline is a cubic spline where the tangent at control points, except the first and last, are computed using the previous and next control points. Catmull-Rom splines are in the class C<sup>1</sup>.
示例
ts
// spline above the earth from Philadelphia to Los Angeles
const spline = new Cesium.CatmullRomSpline({
times : [ 0.0, 1.5, 3.0, 4.5, 6.0 ],
points : [
new Cesium.Cartesian3(1235398.0, -4810983.0, 4146266.0),
new Cesium.Cartesian3(1372574.0, -5345182.0, 4606657.0),
new Cesium.Cartesian3(-757983.0, -5542796.0, 4514323.0),
new Cesium.Cartesian3(-2821260.0, -5248423.0, 4021290.0),
new Cesium.Cartesian3(-2539788.0, -4724797.0, 3620093.0)
]
});
const p0 = spline.evaluate(times[i]); // equal to positions[i]
const p1 = spline.evaluate(times[i] + delta); // interpolated value when delta < times[i + 1] - times[i]参数
Object with the following properties:
参数
An array of strictly increasing, unit-less, floating-point times at each point. The values are in no way connected to the clock time. They are the parameterization for the curve.
参数
The array of Cartesian3 control points.
参数
The tangent of the curve at the first control point. If the tangent is not given, it will be estimated.
参数
The tangent of the curve at the last control point. If the tangent is not given, it will be estimated.
属性
times
readonlytimes:number[]
An array of times for the control points.
points
readonlypoints:Cartesian3[]
An array of Cartesian3 control points.
firstTangent
readonlyfirstTangent:Cartesian3
The tangent at the first control point.
lastTangent
readonlylastTangent:Cartesian3
The tangent at the last control point.
方法
findTimeInterval()
findTimeInterval(
time:number):number
Finds an index <code>i</code> in <code>times</code> such that the parameter <code>time</code> is in the interval <code>[times[i], times[i + 1]]</code>.
参数
time
number
The time.
返回
number
The index for the element at the start of the interval.
wrapTime()
wrapTime(
time:number):number
Wraps the given time to the period covered by the spline.
参数
time
number
The time.
返回
number
The time, wrapped around to the updated animation.
clampTime()
clampTime(
time:number):number
Clamps the given time to the period covered by the spline.
参数
time
number
The time.
返回
number
The time, clamped to the animation period.
evaluate()
evaluate(
time:number,result?:Cartesian3):Cartesian3
Evaluates the curve at a given time.
参数
time
number
The time at which to evaluate the curve.
result?
The object onto which to store the result.
返回
The modified result parameter or a new instance of the point on the curve at the given time.
构造函数
构造函数
new CatmullRomSpline(
options: {times:number[];points:Cartesian3[];firstTangent?:Cartesian3;lastTangent?:Cartesian3; }):CatmullRomSpline
参数
options
times
number[]
points
firstTangent?
lastTangent?
返回
CatmullRomSpline
