ModelAnimation

internal constructor new Cesium.ModelAnimation()

通过调用 ModelAnimationCollection#add 创建动画。不要直接调用构造函数。
An active animation derived from a glTF asset. An active animation is an animation that is either currently playing or scheduled to be played due to being added to a model's ModelAnimationCollection. An active animation is an instance of an animation; for example, there can be multiple active animations for the same glTF animation, each with a different start time.
See:

Members

如果定义了该项,它将用于计算局部动画时间, 而非使用场景的时间。
Default Value: undefined
ModelAnimation#startTime 到开始播放之间的延迟(秒)。
Default Value: undefined
决定动画是否循环以及循环方式。
Default Value: ModelAnimationLoop.NONE
大于 1.0 的值会相对于场景时钟速度加快动画的播放速度; 小于 1.0 的值会减慢播放速度。值为 1.0 时, 动画将以映射到场景时钟速度的 glTF 动画速度播放。例如,如果场景以 2 倍实时速度播放, 即使 multiplier1.0,一段两秒的 glTF 动画也会在一秒内播放完毕。
Default Value: 1.0
在模型中标识此动画的名称(如果存在)。
当为 true 时,动画在停止播放后被移除。 这比不移除它稍微更高效,但如果例如 时间被倒退,动画将不会再次播放。
Default Value: false
当为 true 时,动画将反向播放。
Default Value: false
当此动画开始播放时触发的事件。例如,可在动画开始时 用于播放声音或启动粒子系统。

该事件在场景渲染完成后的帧末尾触发。

Default Value: new Event()
Example:
animation.start.addEventListener(function(model, animation) {
  console.log(`Animation started: ${animation.name}`);
});
开始播放此动画的场景时间。当其为 undefined 时, 动画在下一帧开始播放。
Default Value: undefined
当此动画停止时触发的事件。例如,可在动画停止时 用于播放声音或启动粒子系统。

该事件在场景渲染完成后的帧末尾触发。

Default Value: new Event()
Example:
animation.stop.addEventListener(function(model, animation) {
  console.log(`Animation stopped: ${animation.name}`);
});
停止播放此动画的场景时间。当其为 undefined 时, 动画将播放其完整时长,并可能根据 ModelAnimation#loop 重复播放。
Default Value: undefined
每次更新此动画的帧上触发的事件。动画的当前时间(相对于 glTF 动画时间跨度) 会传递给该事件,从而允许例如相对于正在播放的动画 在特定的时间启动新的动画。

该事件在场景渲染完成后的帧末尾触发。

Default Value: new Event()
Example:
animation.update.addEventListener(function(model, animation, time) {
  console.log(`Animation updated: ${animation.name}. glTF animation time: ${time}`);
});

Type Definitions

Cesium.ModelAnimation.AnimationTimeCallback(duration, seconds)number

用于计算 ModelAnimation 局部动画时间的函数。
Name Type Description
duration number 动画的原始时长(秒)。
seconds number 自动画开始以来经过的秒数(以场景时间为准)。
Returns:
返回局部动画时间。
Examples:
// Use real time for model animation (assuming animateWhilePaused was set to true)
function animationTime(duration) {
    return Date.now() / 1000 / duration;
}
// Offset the phase of the animation, so it starts halfway through its cycle.
function animationTime(duration, seconds) {
    return seconds / duration + 0.5;
}
需要帮助?获取答案的最快方式是在 Cesium 论坛 上向社区和团队提问。