-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
289 lines (214 loc) · 9.92 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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
<html>
<head>
<title>TSuKBG</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<script src="js/three.min.js"></script>
<script>
// --allow-file-access-from-files should be added in Properties-> Target when starting chrome locally
// so local files can be loaded. This is because of security restrictions
var renderer, camera, scene, pointLight, worldPlane;
var mouseDown = false, mouseX = 0, mouseY = 0;
var minZoom = 120, maxZoom = 233;
init();
mainLoop();
function init()
{
/////////////////////////////////////////////////////////////////////////////////////////////////////////
//renderer
renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
/////////////////////////////////////////////////////////////////////////////////////////////////////////
//scene
scene = new THREE.Scene();
/////////////////////////////////////////////////////////////////////////////////////////////////////////
//camera
//vertical field of view, aspect ratio, near plane, far plane
camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 1, 1000);
camera.position.set(80, 100, 200);
scene.add(camera);
/////////////////////////////////////////////////////////////////////////////////////////////////////////
var worldTexture = THREE.ImageUtils.loadTexture('textures/NASA_world_reduced1.jpg');
var defaultWorldMaterial = new THREE.MeshPhongMaterial({ map: worldTexture });
var geometry = new THREE.PlaneGeometry(1000, 500, 1, 1);
worldPlane = new THREE.Mesh(geometry, defaultWorldMaterial);
scene.add(worldPlane);
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// ambient light
scene.add(new THREE.AmbientLight(0xffffff));
var light = new THREE.DirectionalLight(0xffffff, 0.2);
light.position.set(0, 50, 0);
scene.add(light);
/////////////////////////////////////////////////////////////////////////////////////////////////////////
//listeners for mouse move, mouse down, mouse up, mouse wheel
document.body.addEventListener('mousemove', function (e) { onMouseMove(e); }, false);
document.body.addEventListener('mousedown', function (e) { onMouseDown(e); }, false);
document.body.addEventListener('mouseup', function (e) { onMouseUp(e); }, false);
document.body.addEventListener('mousewheel', function (e) { onMouseWheel(e); }, false);
document.body.addEventListener('DOMMouseScroll', function (e) { onMouseWheel(e); }, false);//this is for Mozilla
}
function onMouseWheel(event)
{
var delta = 0;
if (event.wheelDelta) //Chrome
{
delta = -event.wheelDelta / 20;
}
else if (event.detail) //Mozilla
{
delta = event.detail*3;
}
if (camera.position.z + delta > minZoom && camera.position.z + delta < maxZoom)
{
camera.translateZ(delta);
}
}
function onMouseMove(event)
{
if (!mouseDown) {
return;
}
var deltaX = event.clientX - mouseX;
var deltaY = event.clientY - mouseY;
mouseX = event.clientX;
mouseY = event.clientY;
moveCamera(deltaX, deltaY);
}
function moveCamera(deltaX, deltaY)
{
deltaX = -(deltaX / 5);
deltaY = (deltaY / 5);
worldPlane.geometry.computeBoundingBox();
boundingBox = worldPlane.geometry.boundingBox;
var offsetX = 200;
var offsetY = 100;
//we want camera movement to be limited by the dimensions
//of the world plane. We dont want to go outside of the plane
//we achieve this by stopping the camera movement when we reach certain offsets of
//the dimensions of the plane
if (camera.position.x + deltaX + offsetX > boundingBox.max.x ||
camera.position.x + deltaX - offsetX < boundingBox.min.x)
{
deltaX = 0;
}
if (camera.position.y + deltaY + offsetY > boundingBox.max.y ||
camera.position.y + deltaY - offsetY < boundingBox.min.y)
{
deltaY = 0;
}
camera.translateX(deltaX);
camera.translateY(deltaY);
}
function onMouseDown(event)
{
mouseDown = true;
mouseX = event.clientX;
mouseY = event.clientY;
}
function onMouseUp(event)
{
mouseDown = false;
}
function mainLoop()
{
requestAnimationFrame(mainLoop);
update();
render();
}
function update()
{
}
function render()
{
renderer.render(scene, camera);
}
function setVisibility(id, visibility)
{
document.getElementById(id).style.visibility = visibility;
}
</script>
<!--search form-->
<div id="searchDiv" style="position: absolute; top: 0; left: 0; margin-top: 50px; margin-left: 50px; font-size: 15pt; font-family: 'Times New Roman';">
<form id="searchForm">
<input id="search" value="" style="font-size: 15pt; font-family: 'Times New Roman'" />
<input type="button" style="font-size: 15pt; font-family: 'Times New Roman';" value="Search" />
</form>
</div>
<!--Login button-->
<div style="position:absolute;top:0;right:0;margin-top:50px;margin-right:100px;">
<button name ="login" id ="login" style="font-size:15pt;font-family:'Times New Roman'" value ="Login" onclick="setVisibility('openLogin', 'visible');"> Login </button>
</div>
<!--Login dialog-->
<div id="openLogin" class="loginDialog">
<div>
<a href="#openLogin" onclick="setVisibility('openLogin', 'hidden');" class="closeButtonLogin">X</a>
<div style="position: relative; left: 10%;">
<form id="Form1">
<br /><br />
<label style="font-size: 25pt; font-family: 'Times New Roman'">Login </label> <br /><br />
Username <br />
<input name="username" id="username" value="" style="font-size: 15pt; font-family: 'Times New Roman'" /><br /> <br />
Password<br />
<input name="password" id="password" value="" style="font-size: 15pt; font-family: 'Times New Roman'" /><br /><br />
<input type="button" style="font-size: 15pt; font-family: 'Times New Roman'" value="Login" />
</form>
</div>
</div>
</div>
<!--Register button-->
<div style="position:absolute;top:0;right:0;margin-top:50px;margin-right:200px;">
<button name ="register" id ="Button2" style="font-size:15pt;font-family:'Times New Roman'" onclick="setVisibility('openRegister', 'visible');"> Register </button>
</div>
<!--Register dialog-->
<div id="openRegister" class="registerDialog">
<div>
<a href="#openRegister" onclick="setVisibility('openRegister', 'hidden');" title="Close" class="closeButtonRegister">X</a>
<div style="position: relative; left: 13%;">
<form id="Form2">
<br /><br />
<label style="font-size: 25pt; font-family: 'Times New Roman'">Register</label><br /><br />
Email <br />
<input name="email" id="Text3" value="" style="font-size: 15pt; font-family: 'Times New Roman'" /><br /><br />
Username<br />
<input name="username" id="Text1" value="" style="font-size: 15pt; font-family: 'Times New Roman'" /> <br /><br />
Password
<br />
<input name="password" id="Text2" value="" style="font-size: 15pt; font-family: 'Times New Roman'" /><br /><br />
Repeat password<br />
<input name="repeatPassword" id="Text4" value="" style="font-size: 15pt; font-family: 'Times New Roman'" /><br /><br />
<input type="button" style="font-size: 15pt; font-family: 'Times New Roman'" value="Register" />
</form>
</div>
</div>
</div>
<!--3d mode button-->
<div style="position:absolute;bottom:0;left:0;margin-bottom:10px;margin-left:50px;">
<form action="index3DMode.html">
<input type="submit" id ="Submit2" style="font-size:15pt;font-family:'Times New Roman'" value ="Go to 3D mode">
</form>
</div>
<!-- find route button -->
<div style="position:absolute;top:0;left:0;margin-top:50px;margin-left:400px;">
<button name ="openRoute" id ="Button1" style="font-size:15pt;font-family:'Times New Roman'" onclick="setVisibility('openRoute', 'visible');"> Find route </button>
</div>
<!-- find route dialog -->
<div id="openRoute" class="routeDialog">
<div>
<a href="#openRoute" onclick="setVisibility('openRoute', 'hidden');" title="Close" class="closeButtonRoute">X</a>
<div style="position: relative; left: 8%;">
<form id="Form3">
<br /><br />
<label style="font-size: 25pt; font-family: 'Times New Roman'">Find route between places</label><br /><br />
Starting place <br />
<input name="email" id="Text5" value="" style="font-size: 15pt; font-family: 'Times New Roman'" /><br /><br />
Target place<br />
<input name="username" id="Text6" value="" style="font-size: 15pt; font-family: 'Times New Roman'" /><br /> <br />
<input type="button" style="font-size: 15pt; font-family: 'Times New Roman'" value="Find route" />
</form>
</div>
</div>
</div>
</body>
</html>