活动模型动画的集合。使用
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
创建具有指定初始属性的动画并将其添加到集合中。
这会引发
ModelAnimationCollection#animationAdded
事件,例如,UI可以保持同步。
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options
|
Object |
具有以下属性的对象:
|
Returns:
添加到集合中的动画。
Throws:
-
DeveloperError :未加载动画。等待
型号#readyPromise
解决。 -
DeveloperError :options.name必须是有效的动画名称。
-
DeveloperError :options.index必须是有效的动画索引。
-
DeveloperError :必须定义options.name或options.index。
-
DeveloperError :options.multiplier必须大于零。
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 = LSGlobe.JulianDate.now();
var animation = model.activeAnimations.add({
name : 'another animation name',
startTime : startTime,
delay : 0.0, // Play at startTime (default)
stopTime : LSGlobe.JulianDate.addSeconds(startTime, 4.0, new LSGlobe.JulianDate()),
removeOnStop : false, // Do not remove when animation stops (default)
multiplier : 2.0, // Play at double speed
reverse : true, // Play in reverse
loop : LSGlobe.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 >
创建具有指定初始属性的动画并将其添加到集合中模型中的每个动画。
这会为每个模型引发
ModelAnimationCollection#animationAdded
事件,例如,UI可以保持同步。
Name | Type | Description | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options
|
Object |
可选
具有以下属性的对象:
|
Returns:
一组
模型动画
对象,每个动画添加到集合中。如果没有glTF动画,则数组为空。
Throws:
-
DeveloperError :未加载动画。等待
型号#readyPromise
解决。 -
DeveloperError :options.multiplier必须大于零。
Example:
model.activeAnimations.addAll({
multiplier : 0.5, // Play at half-speed
loop : LSGlobe.ModelAnimationLoop.REPEAT // Loop the animations
});
确定此集合是否包含给定的动画。
Name | Type | Description |
---|---|---|
animation
|
ModelAnimation | 要检查的动画。 |
Returns:
真正
如果此集合包含动画,
假
除此以外。
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);
}
从集合中删除动画。
这会引发
ModelAnimationCollection#animationRemoved
事件,例如,UI可以保持同步。
通过将
ModelAnimation#removeOnStop
设置为,也可以从集合中隐式删除动画。
true
。删除动画时,仍会触发
ModelAnimationCollection#animationRemoved
事件。
Name | Type | Description |
---|---|---|
animation
|
ModelAnimation | 要删除的动画。 |
Returns:
真正
如果动画被删除;
假
如果在集合中找不到动画。
Example:
var a = model.activeAnimations.add({
name : 'animation name'
});
model.activeAnimations.remove(a); // Returns true
从集合中删除所有动画。
这会为每个事件引发
ModelAnimationCollection#animationRemoved
事件动画,例如,UI可以保持同步。