new Cesium.Animation(container, viewModal)
动画组件提供了播放、暂停和反转按钮,以及当前时间和日期,周围环绕着一个“梭子环”,用于控制动画的速度。
“梭子环”的概念是借用了视频编辑,梭子环来控制回放的方向和速度。Cesium通常将时间视为连续的(而不是分解成预定义的动画帧),所以这个组件不提供“慢跑轮” (典型的“慢跑轮”可以非常缓慢地移动单个动画帧)。相反,梭子环支持快速和慢速的回放。点击并拖动梭子环指针本身(如上绿色所示),或点击环区域的其余部分,将指针微调到该方向的下一个预设速度。
动画组件还提供了一个“realtime”按钮(在左上角),使动画时间与最终用户的系统时钟同步,通常显示“今天”或“现在”。如果当前时间在时钟的起始时间和结束时间之外,则此模式在ClockRange.CLAMPED和ClockRange.LOOP_STOP模式中不可用。
参数
名称 | 类型 | 描述 |
---|---|---|
container | Element | String | The DOM element or ID that will contain the widget. |
viewModel | AnimationViewModel | The view model used by this widget. |
抛出错误:
DeveloperError : Element with id “container” does not exist in the document.
使用示例
// 在 HTML 头部引入 Animation.css 样式,
// 在 body 添加: <div id="animationContainer"></div>
var clock = new Cesium.Clock();
var clockViewModel = new Cesium.ClockViewModel(clock);
var viewModel = new Cesium.AnimationViewModel(clockViewModel);
var widget = new Cesium.Animation('animationContainer', viewModel);
function tick() {
clock.tick();
Cesium.requestAnimationFrame(tick);
}
Cesium.requestAnimationFrame(tick);
成员变量
- container : Element
只读 获取父容器- viewModel : AnimationViewModel
只读 获取view modal
方法
applyThemeChanges()
更新css
//切换成 cesium-lighter 主题.
document.body.className = 'cesium-lighter';
animation.applyThemeChanges();
destroy()
从布局中永久删除组件
isDestroyed() → Boolean
返回值:如果对象已销毁,则为true,否则为false。
resize()
调整组件的大小以匹配容器大小。当容器大小发生变化时,应该调用这个函数。