-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathworker.js
37 lines (36 loc) · 1.09 KB
/
worker.js
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
importScripts('js/satellite.min.js');
addEventListener('message', function (e) {
while (true) {
var vertex = [];
var date = new Date();
e.data.satellites.forEach(function (sat, i) {
var position_and_velocity = satellite.propagate(
sat.satrec,
date.getUTCFullYear(),
date.getUTCMonth() + 1,
date.getUTCDate(),
date.getUTCHours(),
date.getUTCMinutes(),
date.getUTCSeconds()
);
var eci = position_and_velocity.position;
if (eci === null || eci === undefined || isNaN(eci.x) || isNaN(eci.y) || isNaN(eci.z)) {
vertex.push(
0,
0,
0
);
}
else {
vertex.push(
eci.x * 1000,
eci.y * 1000,
eci.z * 1000
);
}
});
postMessage({
vertex: new Float32Array(vertex)
});
}
}, false);