-
Notifications
You must be signed in to change notification settings - Fork 160
/
Animation2.html
54 lines (45 loc) · 2.2 KB
/
Animation2.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<!DOCTYPE html>
<head>
<title>Animation</title>
<link href="../Build/Cesium/Widgets/widgets.css" rel="stylesheet">
<link href="../Build/Cesium/Widgets/Animation/Animation.css" rel="stylesheet">
<link href="../Build/Cesium/Widgets/Animation/lighter.css" rel="stylesheet">
<script type="text/javascript" src="./js/require.min.js" data-main="./js/main"></script>
<script type="text/javascript" src="./js/require.min.js" data-main="./js/main"></script>
</head>
<body>
<div id="animationContainer" class="cesium-viewer-animationContainer" style="z-index:100">
</div>
<div id="cesiumContainer"></div>
<script>
function onload(Cesium) {
var viewer = new Cesium.Viewer('cesiumContainer',{animation:true,timeline:true});
var d = new Date();
var hour = 0 - d.getTimezoneOffset();
viewer.animation.viewModel.timeFormatter = function(date, viewModel) {
var dateZone8 = Cesium.JulianDate.addMinutes(date,hour,new Cesium.JulianDate());
var gregorianDate = Cesium.JulianDate.toGregorianDate(dateZone8);
var millisecond = Math.round(gregorianDate.millisecond);
if (Math.abs(viewModel._clockViewModel.multiplier) < 1) {
return Cesium.sprintf("%02d:%02d:%02d.%03d", gregorianDate.hour, gregorianDate.minute, gregorianDate.second, millisecond);
}
return Cesium.sprintf("%02d:%02d:%02d GMT+8", gregorianDate.hour, gregorianDate.minute, gregorianDate.second);
};
var clock = viewer.cesiumWidget.clock;
var timeline = viewer.timeline;
var startTime = clock.startTime;
var stopTime = clock.stopTime;
function tick() {
var currentTime = Cesium.JulianDate.clone(clock.currentTime);
if(Cesium.JulianDate.greaterThan(currentTime, stopTime))
{
startTime = Cesium.JulianDate.addDays(startTime,1.0,startTime);
stopTime = Cesium.JulianDate.addDays(stopTime,1.0,stopTime);
timeline.zoomTo(startTime,stopTime);
}
}
var helper = new Cesium.EventHelper();
helper.add(clock.onTick,tick);
}
</script>
</body>