ModelAnimation

internal constructor new Cesium.ModelAnimation()

通过调用 ModelAnimationCollection#add 创建动画。请勿直接调用构造函数。
一个源自 glTF 资产的活跃动画。活跃动画是指当前正在播放或由于被添加到模型的 ModelAnimationCollection 中而计划播放的动画。活跃动画是动画的一个实例;例如,对于同一个 glTF 动画,可以有多个活跃动画,每个动画具有不同的开始时间。
See:

Members

如果定义了此值,它将用于计算本地动画时间, 而不是场景时间。
Default Value: undefined
ModelAnimation#startTime 开始播放的延迟(以秒为单位)。
Default Value: undefined
决定动画是否以及如何循环播放。
Default Value: ModelAnimationLoop.NONE
大于 1.0 的值会相对于场景时钟速度加快动画播放速度;小于 1.0 的值会减慢速度。值为 1.0 时,动画以映射到场景时钟速度的 glTF 动画速度播放。例如,如果场景以真实时间的 2 倍播放,两秒的 glTF 动画 将在一秒内播放,即使 multiplier1.0
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 Forum.