-
Notifications
You must be signed in to change notification settings - Fork 15
/
disco-globe.html
70 lines (54 loc) · 1.81 KB
/
disco-globe.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Disco globe</title>
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
<link href="https://api.mapbox.com/mapbox-gl-js/v2.9.0-beta.1/mapbox-gl.css" rel="stylesheet">
<script src="https://api.mapbox.com/mapbox-gl-js/v2.9.0-beta.1/mapbox-gl.js"></script>
<style>
body { margin: 0; padding: 0; }
#map { position: absolute; top: 0; bottom: 0; width: 100%; }
</style>
</head>
<body>
<div id="map"></div>
<script>
let initLoad = true;
function random_rgba() {
var o = Math.round, s = 255;
return 'rgba(' + o((Date.now()/1000)% 3*s) + ',' + o((Date.now()/1500)% 5*s) + ',' + o((Date.now()/2000)% 10 *s) + ',' + 1 + ')';
}
function adjustAtmosphere() {
map.setFog({
color: random_rgba(),
'horizon-blend': (Math.sin((Date.now()/1000)) % 60) / 10,
'high-color': '#9BBBA0',
'star-intensity': (Math.sin((Date.now()/1000)) % 60) / 100,
'space-color': '#384426'
});
}
setInterval(adjustAtmosphere, 10); // Milliseconds
mapboxgl.accessToken = 'pk.eyJ1IjoidGp1a2Fub3Z0IiwiYSI6ImNrNTdxempkZTBmeTczZmxqdmxmNHlqczAifQ.a_BL5RTprJKXwaTzbsPeyw';
const map = new mapboxgl.Map({
container: 'map',
projection: 'globe',
style: 'mapbox://styles/tjukanovt/cl46yduq5002316opf823qy10',
zoom: 3,
center: [120,-10]
});
map.on('load', () => {
if (initLoad) {
initLoad = false;
map.setFog({
color: random_rgba(),
'horizon-blend': (Math.sin((Date.now()/1000)) % 60) / 10,
'high-color': '#9BBBA0',
'star-intensity': (Math.sin((Date.now()/1000)) % 60) / 100,
'space-color': '#384426'
});
}
});
</script>
</body>
</html>