-
Notifications
You must be signed in to change notification settings - Fork 3
/
map.js
102 lines (80 loc) · 2.07 KB
/
map.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
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
// http://en.wikipedia.org/wiki/Server_(computing)#Types_of_servers
servers = [{
domain: "ftp.zi-xen.info",
ip: "139.28.60.34",
type: "files",
x: 500, y: 6250,
}, {
domain: "db.zi-xen.info",
ip: "139.28.60.34",
type: "database",
x: 1340, y: 4450,
}, {
domain: "pro.xyz",
ip: "133.46.26.85",
type: "proxy",
security: "hallpass required",
x: 50, y: 3550,
}, {
domain: "auth.faceboo.kr",
ip: "136.27.47.11",
type: "authentification",
x: 1350, y: 8350,
}];
function WorldMap() {
var m = new Modal()
.title("World Map")
.content("<div class='webgl'/>");
var webglEl = m.$(".webgl");
if (!Detector.webgl) {
Detector.addGetWebGLMessage(webglEl);
return;
}
// Earth params
var radius = 0.5;
var segments = 64;
var rotation = 6;
var scene = new THREE.Scene();
var width = 640;
var height = 480;
var camera = new THREE.PerspectiveCamera(45, width / height, 0.01, 1000);
camera.position.z = 1.5;
var renderer = new THREE.WebGLRenderer({ antialias: true, depth: false });
renderer.setSize(width, height);
webglEl.appendChild(renderer.domElement);
var controls = new THREE.TrackballControls(camera);
var earth = createEarth(radius, segments);
earth.rotation.y = rotation;
scene.add(earth);
var outlineMaterial = new THREE.MeshBasicMaterial({
color: 0x00ff00,
side: THREE.BackSide
});
var outline = new THREE.Mesh(
new THREE.SphereGeometry(radius + 0.001, segments, segments),
outlineMaterial
);
scene.add(outline);
render();
function render() {
controls.update();
requestAnimationFrame(render);
renderer.render(scene, camera);
}
function createEarth(radius, segments) {
var earthTexture = THREE.ImageUtils.loadTexture("images/future-earth.png");
earthTexture.anisotropy = renderer.getMaxAnisotropy();
var earthMaterial = new THREE.MeshBasicMaterial({
map: earthTexture,
color: 0x00ff00
});
return new THREE.Mesh(
new THREE.SphereGeometry(radius, segments, segments),
earthMaterial
);
}
// TODO: add back servers
// TODO: constrain zoom
// TODO: find a way of normalizing the line thickness (with a shader)
return m;
}