-
Notifications
You must be signed in to change notification settings - Fork 27
/
example-iss.html
69 lines (61 loc) · 2.03 KB
/
example-iss.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
<!DOCTYPE html>
<html lang="en_US">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Realtime WebGL Globe Example</title>
<meta name="description" content="A webgl earth making it easy to add shapes at coordinates in realtime.">
<style>
body {
padding: 0;
margin: 0;
background: black;
}
</style>
</head>
<body>
<main>
<div id='globe'></div>
</main>
</script>
<script src='//cdnjs.cloudflare.com/ajax/libs/three.js/r70/three.min.js'></script>
<script src="https://code.jquery.com/jquery-3.1.0.min.js" integrity="sha256-cCueBR6CsyA4/9szpPfrX3s49M9vUU5BgtiJj06wt/s=" crossorigin="anonymous"></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/three.js/r79/three.min.js'></script>
<script src='globe.js'></script>
<script>
var div = document.getElementById('globe');
var urls = {
earth: 'img/world.jpg',
bump: 'img/bump.jpg',
specular: 'img/specular.jpg',
}
// create a globe
var globe = new Globe(div, urls);
// start it
globe.init();
var trackIss = function() {
//get data from ISS tracking api
$.getJSON("http://api.open-notify.org/iss-now.json?callback=?", function(coords) {
var latitude = coords.iss_position.latitude;
var longitude = coords.iss_position.longitude;
//create & render ISS object on globe
var data = {
color: '#FF0000',
size: 5,
lat: latitude,
lon: longitude,
};
// center the globe to the position
globe.center(data);
setTimeout(function() {
globe.addBlock(data);
}, 300);
//Create animation moving ISS(its not a very fliud animation for now)
globe.removeAllBlocks();
});
}
setInterval(trackIss, 2000);
</script>
</body>
</html>