internal constructor new Cesium.ModelAnimationCollection()

Access a model's animations Model#activeAnimations. Do not call the constructor directly
活跃模式动画集.
See:

Members

animateWhilePaused : boolean

当真实时,动画即使在场景时间暂停时也会播放. 不过, 动画是否发生取决于动画 分配的时间职能 到模型的动画。 默认,这是基于场景时间,所以模型使用 默认将不会动起来,无论设置如何.
Default Value: false

animationAdded : Event

当动画被添加到收藏中时,事件就开火了. 这个可以用来,用于 例如,保持用户界面同步.
Default Value: new Event()
Example:
model.activeAnimations.animationAdded.addEventListener(function(model, animation) {
  console.log(`Animation added: ${animation.name}`);
});

animationRemoved : Event

动画被从收藏中移除后,事件即告发. 这个可以用来,用于 例如,保持用户界面同步.
Default Value: new Event()
Example:
model.activeAnimations.animationRemoved.addEventListener(function(model, animation) {
  console.log(`Animation removed: ${animation.name}`);
});

readonly length : number

收藏中的动画数量.

readonly model : Model

拥有这本动画集的模型.

Methods

add(options)ModelAnimation

创建并添加带有指定初始属性的动画到收藏中.

这提升了 ModelAnimationCollection#animationAdded 事件,以例如UI可以保持同步.

Name Type Description
options object 下列属性的对象 :
Name Type Default Description
name string optional 识别动画的glTF动画名称. 必须定义如果 NT Q4 是 NT Q2 未定义 NT Q 3 .
index number optional 识别动画的glTF动画索引. 必须定义如果 NT Q4 是 NT Q2 未定义 NT Q 3 .
startTime JulianDate optional 开始播放动画的场景时间. 当此为 NT 0 未定义 NT 1 时,动画从下一个帧开始.
delay number 0.0 optional The delay, in seconds, from startTime to start playing. This will only affect the animation if options.loop is ModelAnimationLoop.NONE.
stopTime JulianDate optional 现场时间停止播放动画. 当此为 NT 0 undefine NT 1 时,该动画全程播放.
removeOnStop boolean false optional When true, the animation is removed after it stops playing. This will only affect the animation if options.loop is ModelAnimationLoop.NONE.
multiplier number 1.0 optional 数值大于 NT 0 1.0 NT 1 ============================================================================================================================================================================================================================================.
reverse boolean false optional When true, the animation is played in reverse.
loop ModelAnimationLoop ModelAnimationLoop.NONE optional Determines if and how the animation is looped.
animationTime ModelAnimation.AnimationTimeCallback 未定义 optional 如果定义,则计算此动画的本地动画时间.
Returns:
收藏中加入的动画.
Throws:
Examples:
// Example 1. Add an animation by name
model.activeAnimations.add({
  name : 'animation name'
});
// Example 2. Add an animation by index
model.activeAnimations.add({
  index : 0
});
// Example 3. Add an animation and provide all properties and events
const startTime = Cesium.JulianDate.now();

const animation = model.activeAnimations.add({
  name : 'another animation name',
  startTime : startTime,
  delay : 0.0,                                 // Play at startTime (default)
  stopTime : Cesium.JulianDate.addSeconds(startTime, 4.0, new Cesium.JulianDate()),
  removeOnStop : false,                        // Do not remove when animation stops (default)
  multiplier : 2.0,                            // Play at double speed
  reverse : true,                              // Play in reverse
  loop : Cesium.ModelAnimationLoop.REPEAT      // Loop the animation
});

animation.start.addEventListener(function(model, animation) {
  console.log(`Animation started: ${animation.name}`);
});
animation.update.addEventListener(function(model, animation, time) {
  console.log(`Animation updated: ${animation.name}. glTF animation time: ${time}`);
});
animation.stop.addEventListener(function(model, animation) {
  console.log(`Animation stopped: ${animation.name}`);
});

addAll(options)Array.<ModelAnimation>

创建并添加带有指定初始属性的动画到收藏中 用于模型中的所有动画.

This raises the ModelAnimationCollection#animationAdded event for each model so, for example, a UI can stay in sync.

Name Type Description
options object optional 下列属性的对象 :
Name Type Default Description
startTime JulianDate optional 开始播放动画的场景时间. 当这是 NT 0 未定义 NT 1 ,动画开始于下一个帧.
delay number 0.0 optional The delay, in seconds, from startTime to start playing. This will only affect the animation if options.loop is ModelAnimationLoop.NONE.
stopTime JulianDate optional 场景时间停止播放动画. 当此为 NT 0 未定义 NT 1 时,动画全程播放.
removeOnStop boolean false optional When true, the animations are removed after they stop playing. This will only affect the animation if options.loop is ModelAnimationLoop.NONE.
multiplier number 1.0 optional 值大于 NT 0 1.0 NT 1 ============================================================================================================================================================================================================================================.
reverse boolean false optional When true, the animations are played in reverse.
loop ModelAnimationLoop ModelAnimationLoop.NONE optional Determines if and how the animations are looped.
animationTime ModelAnimation.AnimationTimeCallback 未定义 optional 如果定义,则计算所有动画的本地动画时间.
Returns:
An array of ModelAnimation objects, one for each animation added to the collection. If there are no glTF animations, the array is empty.
Throws:
Example:
model.activeAnimations.addAll({
  multiplier : 0.5,                            // Play at half-speed
  loop : Cesium.ModelAnimationLoop.REPEAT      // Loop the animations
});

contains(runtimeAnimation)boolean

确定此收藏是否包含给定的动画 .
Name Type Description
runtimeAnimation ModelAnimation 要检查的运行时间动画 .
Returns:
如果本集包含该动画,则#NT#0 真 NT 1 ,#NT#2 假 NT 3 否则.

get(index)ModelAnimation

在指定的索引中返回收藏中的动画。 指数为零 并随着动画的添加而增加. 删除动画后的所有动画 在左边,改变他们的指数。 此函数通常用于斜拉 收藏中的所有动画.
Name Type Description
index number 动画的零基指数.
Returns:
指定索引的运行时间动画 .
Example:
// Output the names of all the animations in the collection.
const animations = model.activeAnimations;
const length = animations.length;
for (let i = 0; i < length; ++i) {
  console.log(animations.get(i).name);
}

remove(runtimeAnimation)boolean

从收藏中删除动画.

这提升了 ModelAnimationCollection#animationRemoved 事件,以例如UI可以保持同步.

动画也可以通过设置 ModelAnimationCollection#removeOnStop 至 来隐含地从收藏中删除 true. The ModelAnimationCollection#animationRemoved event is still fired when the animation is removed.

Name Type Description
runtimeAnimation ModelAnimation 要删除的运行时间动画 .
Returns:
如果动画被移除,则使用 NT##0 真 NT 1 ;如果在收藏中找不到动画,则使用 NT 2 假 NT 3 .
Example:
const a = model.activeAnimations.add({
  name : 'animation name'
});
model.activeAnimations.remove(a); // Returns true

removeAll()

从收藏中删除所有动画.

This raises the ModelAnimationCollection#animationRemoved event for each 例如,动画可以保持同步.

Need help? The fastest way to get answers is from the community and team on the Cesium Forum.