-
Notifications
You must be signed in to change notification settings - Fork 27
/
example.html
72 lines (59 loc) · 1.82 KB
/
example.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
<!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='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();
// - create a random block (somewhere on earth)
// - center the globe to that position
// - spawn the block on that position (after 300ms)
var drawRandomLevitatingBlock = function() {
var data = {
color: '#'+Math.floor(Math.random()*16777215).toString(16),
size: Math.random() * 100,
lat: Math.random() * 160 - 80,
lon: Math.random() * 360 - 180,
size: 20
};
// center the globe to the position
globe.center(data);
setTimeout(function() {
// offset the lat/long so you can actually
// see the block levitating
data.lat += 10;
data.lon += 10;
globe.addLevitatingBlock(data);
}, 300);
}
setInterval(drawRandomLevitatingBlock, 2000);
</script>
</body>
</html>