-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
96 lines (85 loc) · 2.87 KB
/
index.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<script src="js/polyfills/browser-polyfill.min.js"></script>
<script src="js/polyfills/ie.js"></script>
<script src="js/three.js"></script>
<script src="js/SkyShader.js"></script>
<script src="js/renderers/Projector.js"></script>
<script src="js/renderers/CanvasRenderer.js"></script>
<script src="js/controls/SightControls.js"></script>
<script src="js/controls/DeviceOrientationControls.js"></script>
<script src="js/planetarium.js"></script>
<script src="js/data/star_names.js"></script>
<script src="js/data/stars_mag_8.js"></script>
<script src="js/data/constellations.js"></script>
<script src="js/data/planets.js"></script>
<style>
#container {
width: 90vw;
height: 90vh;
background-color: green;
}
#container:fullscreen {
width: 100vw;
height: 100vh;
}
#container:-webkit-full-screen {
width: 100vw;
height: 100vh;
}
#container:-moz-full-screen {
width: 100vw;
height: 100vh;
}
#container:-ms-fullscreen {
width: 100vw;
height: 100vh;
}
</style>
</head>
<body>
<div id="container"></div>
<div id="date"></div>
<input type="button" value="Full Screen" onclick="fullScreen()">
<input id="time_speed" type="number" value="1" step="100">
<script>
var el = document.getElementById('container');
var date = document.getElementById('date');
var time_speed = document.getElementById('time_speed');
var planetarium;
getLocation(function(location) {
planetarium = new Planetarium(el, {location: location, use_sensors: true});
});
el.addEventListener('onrender', function(e) {
date.textContent = e.detail.planetarium.date;
});
time_speed.addEventListener('input', function() {
planetarium.setTimeSpeed(+time_speed.value);
});
function fullScreen() {
planetarium.requestFullScreen();
}
function getLocation(callback, defaultLocation) {
defaultLocation = defaultLocation || {
latitude: 0,
longitude: 0
};
function setDefault() {
callback(defaultLocation);
}
if(navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
callback({
latitude: position.coords.latitude,
longitude: position.coords.longitude
});
}, setDefault);
} else {
setDefault();
}
}
</script>
</body>
</html>