CatmullRomSpline

new Cesium.CatmullRomSpline(options)

Catmull-Rom样条是三次样条,其中控制点的切线, 除第一个和最后一个控制点外,使用前一个和下一个控制点计算。 Catmull-Rom样条在C1类中。
Name Type Description
options object 对象,具有以下属性:
Name Type Description
times Array.<number> 在每个点上严格递增的、无单位的浮点时间的数组。 这些值与时钟时间没有任何关系。它们是曲线的参数化。
points Array.<Cartesian3> Cartesian3 控制点数组。
firstTangent Cartesian3 optional 曲线在第一个控制点处的切线。 如果正切值没有给出,它将被估计。
lastTangent Cartesian3 optional 曲线在最后一个控制点的切线。 如果正切值没有给出,它将被估计。
Throws:
Example:
// 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]
See:

Members

在第一个控制点的切线。
最后一个控制点的切线。
Cartesian3 控制点数组。

readonly times : Array.<number>

控制点的时间数组。

Methods

clampTime(time)number

将给定的时间夹紧到样条所覆盖的周期。
Name Type Description
time number time.
Returns:
时间,被夹到了动画时期。
在给定时间对曲线求值。
Name Type Description
time number 计算曲线的时间。
result Cartesian3 optional 要在其上存储结果的对象。
Returns:
修改后的结果参数或给定时间曲线上该点的新实例。
Throws:
  • DeveloperError : 时间必须在范围内 [t0, tn], where t0 是数组中的第一个元素 timestn是最后一个元素 在数组中 times.

findTimeInterval(time)number

times中查找索引i,使得参数 time is in the interval [times[i], times[i + 1]].
Name Type Description
time number time.
Returns:
区间开始处元素的索引。
Throws:
  • DeveloperError : time must be in the range [t0, tn], where t0 is the first element in the array times and tn is the last element in the array times.

wrapTime(time)number

将给定的时间包裹到样条所覆盖的周期。
Name Type Description
time number time.
Returns:
时间,绕来绕去更新动画。
Need help? The fastest way to get answers is from the community and team on the Cesium Forum.