import * as Cesium from 'cesium';

const 默认场景的时间跨度 = 2 * 60 * 60; // 2小时

export function configureTimeLine(viewer: Cesium.Viewer, totalSeconds = 默认场景的时间跨度) {
  const start = Cesium.JulianDate.fromIso8601(new Date().toISOString());
  const stop = Cesium.JulianDate.addSeconds(start, totalSeconds, new Cesium.JulianDate());

  // 设置时钟范围
  viewer.clock.startTime = start.clone();
  viewer.clock.stopTime = stop.clone();
  viewer.clock.currentTime = start.clone();
  viewer.clock.clockRange = Cesium.ClockRange.LOOP_STOP;
  viewer.clock.multiplier = 30; // 30倍速播放

  // 设置时间轴范围
  viewer.timeline.zoomTo(start, stop);

  viewer.clock.shouldAnimate = true;
}
