English中文

ModelAnimation

internal constructor new Cesium.ModelAnimation()

通过调用创建动画 Create animations by calling ModelAnimationCollection#add。不要直接调用构造函数。 . Do not call the constructor directly.
从 glTF 资源派生的活动动画。活动动画是当前正在播放或由于添加到模型而计划播放的动画 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。活动动画是动画的一个实例;例如,同一个 glTF 动画可以有多个活动动画,每个动画都有不同的开始时间。 . 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

如果定义了此值,它将用于计算本地动画时间而不是场景时间。 If this is defined, it will be used to compute the local animation time instead of the scene's time.
默认值: Default Value: undefined
延迟(以秒为单位) The delay, in seconds, from ModelAnimation#startTime 开始播放。 to start playing.
默认值: Default Value: undefined
确定动画是否循环以及如何循环。 Determines if and how the animation is looped.
默认值: Default Value: ModelAnimationLoop.NONE
值大于 Values greater than 1.0 提高动画相对于场景时钟速度的播放速度;值小于 increase the speed that the animation is played relative to the scene clock speed; values less than 1.0 降低速度。值为 decrease the speed. A value of 1.0 以映射到场景时钟速度的 glTF 动画中的速度播放动画。例如,如果场景以 2 倍实时速度播放,则两秒的 glTF 动画将在一秒内播放,即使 plays the animation at the speed in the glTF animation mapped to the scene clock speed. For example, if the scene is played at 2x real-time, a two-second glTF animation will play in one second even if multiplier is 1.0.
默认值: Default Value: 1.0
模型中标识此动画的名称(如果存在)。 The name that identifies this animation in the model, if it exists.
When true,动画在停止播放后被删除。这比不删除它稍微更有效,但是如果例如时间倒转,则不会再次播放动画。 , the animation is removed after it stops playing. This is slightly more efficient that not removing it, but if, for example, time is reversed, the animation is not played again.
默认值: Default Value: false
When true,动画反向播放。 , the animation is played in reverse.
默认值: Default Value: false
该事件在动画开始时触发。例如,这可以用于在动画开始时播放声音或启动粒子系统。 The event fired when this animation is started. This can be used, for example, to play a sound or start a particle system, when the animation starts.

该事件在场景渲染后的帧末尾触发。 This event is fired at the end of the frame after the scene is rendered.

默认值: Default Value: new Event()
示例: Example:
animation.start.addEventListener(function(model, animation) {
  console.log(`Animation started: ${animation.name}`);
});
开始播放该动画的场景时间。当这是 The scene time to start playing this animation. When this is undefined,动画从下一帧开始。 , the animation starts at the next frame.
默认值: Default Value: undefined
当动画停止时触发该事件。例如,这可用于在动画停止时播放声音或启动粒子系统。 The event fired when this animation is stopped. This can be used, for example, to play a sound or start a particle system, when the animation stops.

该事件在场景渲染后的帧末尾触发。 This event is fired at the end of the frame after the scene is rendered.

默认值: Default Value: new Event()
示例: Example:
animation.stop.addEventListener(function(model, animation) {
  console.log(`Animation stopped: ${animation.name}`);
});
停止播放该动画的场景时间。当这是 The scene time to stop playing this animation. When this is undefined,动画会在整个持续时间内播放,并且可能会重复播放,具体取决于 , the animation is played for its full duration and perhaps repeated depending on ModelAnimation#loop.
默认值: Default Value: undefined
当动画更新时,该事件在每一帧上触发。动画的当前时间(相对于 glTF 动画时间跨度)被传递给事件,这允许例如在相对于正在播放的动画的特定时间开始新动画。 The event fired when on each frame when this animation is updated. The current time of the animation, relative to the glTF animation time span, is passed to the event, which allows, for example, starting new animations at a specific time relative to a playing animation.

该事件在场景渲染后的帧末尾触发。 This event is fired at the end of the frame after the scene is rendered.

默认值: 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 的本地动画时间的函数。 A function used to compute the local animation time for a ModelAnimation.
名称 Name 类型 Type 说明 Description
duration number 动画的原始持续时间(以秒为单位)。 The animation's original duration in seconds.
seconds number 自动画开始以来的秒数(以场景时间计)。 The seconds since the animation started, in scene time.
返回: Returns:
返回本地动画时间。 Returns the local animation time.
示例: 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;
}
需要帮助吗?获得答案的最快方法是从社区和团队那里获得答案 Need help? The fastest way to get answers is from the community and team on the Cesium Forum.