forked from dhvidding/miniature-earth
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
173 lines (144 loc) · 5.68 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Demo</title>
<script src="dist/miniature.earth.js"></script>
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<script>
let myearth;
const sprites = [];
const connections = [
[59.651901245117, 17.918600082397, 41.8002778, 12.2388889],
[59.651901245117, 17.918600082397, 51.4706, -0.461941],
[13.681099891662598, 100.74700164794922, -6.1255698204, 106.65599823],
[
13.681099891662598, 100.74700164794922, 28.566499710083008,
77.10310363769531,
],
[30.12190055847168, 31.40559959411621, -1.31923997402, 36.9277992249],
[30.12190055847168, 31.40559959411621, 25.2527999878, 55.3643989563],
[30.12190055847168, 31.40559959411621, 41.8002778, 12.2388889],
[
28.566499710083008, 77.10310363769531, 7.180759906768799,
79.88410186767578,
],
[
28.566499710083008, 77.10310363769531, 40.080101013183594,
116.58499908447266,
],
[28.566499710083008, 77.10310363769531, 25.2527999878, 55.3643989563],
[-33.9648017883, 18.6016998291, -1.31923997402, 36.9277992249],
[-1.31923997402, 36.9277992249, 25.2527999878, 55.3643989563],
[41.8002778, 12.2388889, 51.4706, -0.461941],
[41.8002778, 12.2388889, 40.471926, -3.56264],
[19.4363, -99.072098, 25.79319953918457, -80.29060363769531],
[19.4363, -99.072098, 33.94250107, -118.4079971],
[19.4363, -99.072098, -12.0219, -77.114304],
[-12.0219, -77.114304, -33.393001556396484, -70.78579711914062],
[-12.0219, -77.114304, -34.8222, -58.5358],
[-12.0219, -77.114304, -22.910499572799996, -43.1631011963],
[-34.8222, -58.5358, -33.393001556396484, -70.78579711914062],
[-34.8222, -58.5358, -22.910499572799996, -43.1631011963],
[22.3089008331, 113.915000916, 13.681099891662598, 100.74700164794922],
[22.3089008331, 113.915000916, 40.080101013183594, 116.58499908447266],
[22.3089008331, 113.915000916, 31.143400192260742, 121.80500030517578],
[35.552299, 139.779999, 40.080101013183594, 116.58499908447266],
[35.552299, 139.779999, 31.143400192260742, 121.80500030517578],
[33.94250107, -118.4079971, 40.63980103, -73.77890015],
[33.94250107, -118.4079971, 25.79319953918457, -80.29060363769531],
[33.94250107, -118.4079971, 49.193901062, -123.183998108],
[40.63980103, -73.77890015, 25.79319953918457, -80.29060363769531],
[40.63980103, -73.77890015, 51.4706, -0.461941],
[51.4706, -0.461941, 40.471926, -3.56264],
[
40.080101013183594, 116.58499908447266, 31.143400192260742,
121.80500030517578,
],
[-33.94609832763672, 151.177001953125, -41.3272018433, 174.804992676],
[-33.94609832763672, 151.177001953125, -6.1255698204, 106.65599823],
[55.5914993286, 37.2615013123, 59.651901245117, 17.918600082397],
[55.5914993286, 37.2615013123, 41.8002778, 12.2388889],
[55.5914993286, 37.2615013123, 40.080101013183594, 116.58499908447266],
[55.5914993286, 37.2615013123, 25.2527999878, 55.3643989563],
];
const getRandomInt = (min, max) => {
const rMin = Math.ceil(min);
const rMax = Math.floor(max);
return Math.floor(Math.random() * (rMax - rMin)) + min;
};
const pulse = (index) => {
const randomLocation =
connections[getRandomInt(0, connections.length - 1)];
sprites[index].location = {
lat: randomLocation[0],
lng: randomLocation[1],
};
sprites[index].animate("scale", 0.5, {
duration: 320,
complete() {
myearth.animate("scale", 0.01, {
duration: 320,
complete() {
setTimeout(() => {
pulse(index);
}, getRandomInt(100, 400));
},
});
},
});
};
window.addEventListener("load", () => {
myearth = new MiniatureEarth.Earth("myearth", {
location: { lat: 20, lng: 20 },
light: "none",
mapImage:
"https://cdn.jsdelivr.net/gh/dhvidding/miniature-earth/assets/hologram-map.svg",
transparent: true,
autoRotate: true,
autoRotateSpeed: 1.2,
autoRotateDelay: 100,
autoRotateStart: 2000,
});
myearth.addEventListener("ready", () => {
myearth.startAutoRotate();
// connections
const line = {
color: "#7500c0",
opacity: 0.35,
hairline: true,
offset: -0.5,
};
connections.forEach((connection) => {
line.locations = [
{ lat: connection[0], lng: connection[1] },
{ lat: connection[2], lng: connection[3] },
];
myearth.addLine(line);
});
// add 8 shine sprites
[...Array(8).keys()].forEach((el, i) => {
sprites[i] = myearth.addSprite({
image:
"https://cdn.jsdelivr.net/gh/dhvidding/miniature-earth/assets/hologram-shine.svg",
scale: 0.01,
offset: -0.5,
opacity: 0.5,
});
pulse(i);
});
});
});
</script>
<div class="intro-banner">
<div class="cop-text">
<h1>Modern Web Community of Practice</h1>
<p>Lorem Ipsum Dolor Sit Amet</p>
</div>
<div id="myearth"></div>
</div>
</body>
</html>