代码如下
自己创建的时钟效果var clock = new Cesium.Clock({
startTime: Cesium.JulianDate.fromIso8601("2013-12-25"),
currentTime: Cesium.JulianDate.fromIso8601("2013-12-25"),
stopTime: Cesium.JulianDate.fromIso8601("2013-12-26"),
clockRange: Cesium.ClockRange.LOOP_STOP, // loop when we hit the end time
clockStep: Cesium.ClockStep.SYSTEM_CLOCK_MULTIPLIER,
multiplier: 4000, // how much time to advance each tick
shouldAnimate: true, // Animation on by default
});
var viewer = new Cesium.Viewer("cesiumContainer", {
//clockViewModel: new Cesium.ClockViewModel(clock),
});
//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);
通过clockViewModel来控制时钟的状态
clockViewModel.shouldAnimate设置是否可以进行时钟动画
clockViewModel.shouldAnimate 来暂停和播放动画
clockViewModel.currentTime 来重置当前时间
网友评论