cesium 自定义时钟Clock

2021-01-23  本文已影响0人  panergongzi

代码如下

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 来重置当前时间

上一篇 下一篇

猜你喜欢

热点阅读