活动模型动画的集合。使用
Model#activeAnimations
访问。Members
animationAdded : Event
将动画添加到集合时激发的事件。这可以用来
例如,保持UI同步。
-
Default Value:
new Event()
Example:
model.activeAnimations.animationAdded.addEventListener(function(model, animation) {
console.log('Animation added: ' + animation.name);
});
animationRemoved : Event
从集合中移除动画时激发的事件。这可以用来
例如,保持UI同步。
-
Default Value:
new Event()
Example:
model.activeAnimations.animationRemoved.addEventListener(function(model, animation) {
console.log('Animation removed: ' + animation.name);
});
集合中的动画数。
Methods
add(options) → ModelAnimation
创建具有指定初始属性的动画并将其添加到集合中。
This raises the ModelAnimationCollection#animationAdded
event so, for example, a UI can stay in sync.
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | 具有以下属性的对象:
|
Returns:
添加到集合中的动画。
Throws:
-
DeveloperError :未加载动画。等待
Model#readyPromise
解决。 -
DeveloperError : 选项.name必须是有效的动画名称。
-
DeveloperError : 选项.索引必须是有效的动画索引。
-
DeveloperError :任意一个选项.名称或者选项.索引必须定义。
-
DeveloperError : 选项.乘数必须大于零。
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
var startTime = Cesium.JulianDate.now();
var 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
具有以下属性的对象:
|
Returns:
ModelAnimation
个对象的数组,每个添加到集合中的动画对应一个对象。如果没有glTF动画,则数组为空。Throws:
-
DeveloperError :未加载动画。等待
Model#readyPromise
解决。 -
DeveloperError : 选项.乘数必须大于零。
Example:
model.activeAnimations.addAll({
multiplier : 0.5, // Play at half-speed
loop : Cesium.ModelAnimationLoop.REPEAT // Loop the animations
});
确定此集合是否包含给定动画。
Name | Type | Description |
---|---|---|
animation |
ModelAnimation | 要检查的动画。 |
Returns:
如果此集合包含动画,则为
true
,否则为false
。get(index) → ModelAnimation
返回集合中指定索引处的动画。指数以零为基础
随着动画的增加而增加。移除动画会在之后移动所有动画
它在左边,改变他们的指数。此函数通常用于迭代
集合中的所有动画。
Name | Type | Description |
---|---|---|
index |
Number | 从零开始的动画索引。 |
Returns:
指定索引处的动画。
Example:
// Output the names of all the animations in the collection.
var animations = model.activeAnimations;
var length = animations.length;
for (var i = 0; i < length; ++i) {
console.log(animations.get(i).name);
}
从集合中移除动画。
This raises the ModelAnimationCollection#animationRemoved
event so, for example, a UI can stay in sync.
An animation can also be implicitly removed from the collection by setting ModelAnimation#removeOnStop
to
true
. The ModelAnimationCollection#animationRemoved
event is still fired when the animation is removed.
Name | Type | Description |
---|---|---|
animation |
ModelAnimation | 要移除的动画。 |
Returns:
如果动画已移除,则为
true
;如果在集合中未找到动画,则为false
。Example:
var a = model.activeAnimations.add({
name : 'animation name'
});
model.activeAnimations.remove(a); // Returns true
从集合中移除所有动画。
This raises the ModelAnimationCollection#animationRemoved
event for each
animation so, for example, a UI can stay in sync.