forked from arscan/encom-globe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
519 lines (422 loc) · 20.9 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
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta property="og:image" content="resources/fp_icon.jpg" />
<meta property="og:description" content="A WebGL implementation of the Encom Boardroom visualization in Tron: Legacy" />
<title>Encom Globe</title>
<!-- these are just for the demo page / options -->
<script src="//code.jquery.com/jquery-2.0.3.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js"></script>
<script src="include/spectrum.js"></script>
<link href="include/spectrum.css" rel="stylesheet" type="text/css" />
<script src="include/jquery.switchButton.js"></script>
<link href="include/jquery.switchButton.css" rel="stylesheet" type="text/css" />
<script src="include/simple-slider.js"></script>
<script src="include/Detector.js"></script>
<link href="styles.css" rel="stylesheet" type="text/css" />
<!-- required for the application -->
<script src="data.js"></script>
<script src="grid.js"></script>
<!-- ref:js build/encom-globe.min.js -->
<script src="build/encom-globe.js"></script>
<!-- endref -->
<script>
var globe,
globeCount = 0;
function createGlobe(){
var newData = [];
globeCount++;
$("#globe canvas").remove();
if($("#globe-dd:checked").length){
newData = data.slice();
}
globe = new ENCOM.Globe(window.innerWidth, window.innerHeight, {
font: "Inconsolata",
data: newData, // copy the data array
tiles: grid.tiles,
baseColor: $("#globe-color").val(),
markerColor: $("#marker-color").val(),
pinColor: $("#pin-color").val(),
satelliteColor: $("#satellite-color").val(),
scale: parseFloat($("#globe-scale").val()),
dayLength: 1000 * parseFloat($("#globe-spr").val()),
introLinesDuration: parseFloat($("#globe-id").val()),
maxPins: parseFloat($("#globe-mp").val()),
maxMarkers: parseFloat($("#globe-mm").val()),
viewAngle: parseFloat($("#globe-va").val())
});
$("#globe").append(globe.domElement);
globe.init(start);
}
function onWindowResize(){
globe.camera.aspect = window.innerWidth / window.innerHeight;
globe.camera.updateProjectionMatrix();
globe.renderer.setSize(window.innerWidth, window.innerHeight);
}
function roundNumber(num){
return Math.round(num * 100)/100;
}
function projectionToLatLng(width, height, x,y){
return {
lat: 90 - 180*(y/height),
lon: 360*(x/width)- 180,
};
}
function animate(){
if(globe){
globe.tick();
}
lastTickTime = Date.now();
requestAnimationFrame(animate);
}
function start(){
if(globeCount == 1){ // only do this for the first globe that's created. very messy
$("#apply-button").click(function(e){
globe.destroy(function(){
createGlobe();
});
});
$(".projection").click(function(e){
var offset = $(this).offset();
var latLon = projectionToLatLng($(".projection").width(), $(".projection").height(), e.clientX - offset.left, e.clientY - offset.top);
var selectedId = $("#add-element .selected").attr("id");
if(selectedId == "add-pin"){
globe.addPin(latLon.lat, latLon.lon, "User Dropped Pin");
} else if(selectedId == "add-marker"){
globe.addMarker(latLon.lat, latLon.lon, "User Marker", true);
} else if(selectedId == "add-satellite"){
var opts = {
coreColor: $("#satellite-color").val(),
numWaves: parseInt($("#globe-si").val())
};
globe.addSatellite(latLon.lat, latLon.lon, parseFloat($("#globe-sa").val()), opts);
}
});
$("#add-element li").click(function(e){
$("#add-element li").removeClass("selected");
$(e.currentTarget).addClass("selected");
});
animate();
/* add pins at random locations */
setInterval(function(){
if(!globe || !$("#globe-dd:checked").length){
return;
}
var lat = Math.random() * 180 - 90,
lon = Math.random() * 360 - 180,
name = "Test " + Math.floor(Math.random() * 100);
globe.addPin(lat,lon, name);
}, 5000);
}
/* add 6 satellites in random locations */
if($("#globe-dd:checked").length){
setTimeout(function(){
var constellation = [];
var opts = {
coreColor: $("#satellite-color").val(),
numWaves: parseInt($("#globe-si").val())
};
var alt = parseFloat($("#globe-sa").val());
for(var i = 0; i< 2; i++){
for(var j = 0; j< 3; j++){
constellation.push({
lat: 50 * i - 30 + 15 * Math.random(),
lon: 120 * j - 120 + 30 * i,
altitude: alt
});
}
}
globe.addConstellation(constellation, opts);
}, 4000);
/* add the connected points that are in the movie */
setTimeout(function(){
globe.addMarker(49.25, -123.1, "Vancouver");
globe.addMarker(35.6895, 129.69171, "Tokyo", true);
}, 2000);
}
}
function openOptions(){
var headerTopPosition = $("#header-top").position().top;
var headerBottomPosition = $("#header-bottom").position().top;
var headerHeight = $("#header-top").outerHeight(); /* margins or something, whatever */
$(".header-animator").offset({top: $(document).height()/2, left: 25});
$(".header-animator").height(0);
$("#options").data("left", $("#options").css("left"));
$("#thumbprint").data("left", $("#thumbprint").css("left"));
$("#options").animate({left: 0}, 500);
$("#thumbprint").animate({left: 265}, 500);
$("#options-content").delay(1500).animate({opacity: 1}, 500);
setTimeout(function(){
$(".header-animator").css("visibility", "visible");
$("#header-animator-outside").animate({
top: headerTopPosition,
height: headerBottomPosition - headerTopPosition + headerHeight
}, 500);
$("#header-animator-inside").animate({
top: headerTopPosition + headerHeight,
height: headerBottomPosition - headerTopPosition - headerHeight
}, 500);
}, 500);
setTimeout(function(){
$(".header-animator").css("visibility", "hidden");
$(".header").css("visibility", "visible");
}, 1000);
}
function closeOptions(){
$("#options").animate({left: $("#options").data("left")}, 500);
$("#thumbprint").animate({left: $("#thumbprint").data("left")}, 500);
$("#options-content").animate({opacity: 0}, 500);
$(".header").css("visibility", "hidden");
}
$(function() {
var open = false;
if(!Detector.webgl)
{
Detector.addGetWebGLMessage({parent: document.getElementById("container")});
return;
}
window.addEventListener( 'resize', onWindowResize, false );
$("#globe-color").spectrum({
color: "#ffcc00",
showButtons: false,
showInput: false,
change: function(color){
if(globe){
globe.setBaseColor(color.toHexString());
}
}
});
$("#pin-color").spectrum({
color: "#8FD8D8",
showButtons: false,
showInput: false,
change: function(color){
if(globe){
globe.setPinColor(color.toHexString());
}
}
});
$("#marker-color").spectrum({
color: "#ffcc00",
showButtons: false,
showInput: false,
change: function(color){
if(globe){
globe.setMarkerColor(color.toHexString());
}
}
});
$("#satellite-color").spectrum({
color: "#ff0000",
showButtons: false,
showInput: false,
change: function(color){
if(globe){
for(var x in globe.satellites){
globe.satellites[x].changeCanvas(null, null, color.toHexString());
}
}
}
});
$("[data-slider]")
.each(function () {
var input = $(this);
$("<span>")
.addClass("slider-output")
.insertAfter($(this))
.html(input.val());
})
.bind("slider:ready slider:changed", function (event, data) {
$(this)
.nextAll(".slider-output:first")
.html(data.value.toFixed(3));
});
$(":checkbox").switchButton();
$("#globe-scale").bind("slider:changed", function (event, data) {
if(globe){
globe.setScale(data.value);
}
});
$("#globe-va").bind("slider:changed", function (event, data) {
if(globe){
globe.viewAngle = data.value;
}
});
$("#globe-spr").bind("slider:changed", function (event, data) {
if(globe){
globe.dayLength = data.value * 1000;
}
});
$("#globe-mp").bind("slider:changed", function (event, data) {
if(globe){
globe.setMaxPins(data.value);
}
});
$("#globe-mm").bind("slider:changed", function (event, data) {
if(globe){
globe.setMaxMarkers(data.value);
}
});
$("#globe-sa").bind("slider:changed", function (event, data) {
if(globe){
for(var x in globe.satellites){
globe.satellites[x].changeAltitude(data.value);
}
}
});
$("#globe-si").bind("slider:changed", function (event, data) {
if(globe){
for(var x in globe.satellites){
globe.satellites[x].changeCanvas(data.value);
}
}
});
var docHeight = $(document).height();
WebFontConfig = {
google: {
families: ['Inconsolata']
},
active: function(){
/* don't start the globe until the font has been loaded */
$("#options").css({
"visibility": "visible",
"top": docHeight/2,
"bottom": docHeight/2
}).animate({
"top": 0,
"bottom": 0,
"padding-top": 46
},800,function complete(){
$("#thumbprint").animate({opacity: 1});
$("#thumbprint").click(function(){
if(!open){
open = true;
openOptions();
} else {
open = false;
closeOptions();
}
});
setTimeout(function(){
open = true;
openOptions();
}, 3000);
createGlobe();
});
}
};
/* Webgl stuff */
/* web font stuff*/
var wf = document.createElement('script');
wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +
'://ajax.googleapis.com/ajax/libs/webfont/1.4.7/webfont.js';
wf.type = 'text/javascript';
wf.async = 'true';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(wf, s);
});
</script>
</head>
<body>
<div id="container">
<div id="banner">
Encom Globe
<small>by <a href="http://twitter.com/arscan">@arscan</a></small>
</div>
<div id="globe">
</div>
<div id="info-box">
A tribute to the <a href="http://work.gmunk.com/TRON-Board-Room">boardroom scene</a> in Disney's <a href="http://www.imdb.com/title/tt1104001/">Tron: Legacy</a>. Built for reuse. Source on <a href="http://github.com/arscan/encom-globe/" class="github-link">Github</a>.
</div>
<div id="options">
<div id="options-content">
<h3>Add element by clicking map below</h3>
<img class="projection" src="resources/point_picker.png" width= "280px"/>
<ul id = "add-element">
<li id="add-pin" class="button selected">Drop Pin</li>
<li id="add-marker" class="button">Marker</li>
<li id="add-satellite" class="button">Satellite</li>
</ul>
<h3>Configure Globe</h3>
<div>
<label>
Color Palette
</label>
<ul id="color-options">
<li title="Globe Color"><input type="text" id="globe-color" value="#ffcc00"></li>
<li title="Pin Color"><input type="text" id="pin-color" value="#8FD8D8"></li>
<li title="Marker Color"><input type="text" id="marker-color" value="#ffcc00"></li>
<li title="Satellite Core Color"><input type="text" id="satellite-color" value="#ff0000"></li>
</ul>
<label>
Globe Scale
</label>
<input type="text" id="globe-scale" data-slider="true" data-slider-range=".1, 3.0" data-slider-step=".01" data-slider-highlight="true" value="1.0"/>
<label>
View Angle
</label>
<input type="text" id="globe-va" data-slider="true" data-slider-range="-1.57, 1.57" data-slider-step=".01" data-slider-highlight="true" value=".1"/>
<label>
Seconds per Rotation
</label>
<input type="text" id="globe-spr" data-slider="true" data-slider-range="1, 120" data-slider-step="1" data-slider-highlight="true" value="28"/>
<!--
<label>
Points per Degree
</label>
<input type="text" id="globe-ppd" data-slider="true" data-slider-range=".5,4" data-slider-step=".1" data-slider-highlight="true" value="1.1"/>
<label>
Point Size
</label>
<input type="text" id="globe-ps" data-slider="true" data-slider-range=".1,1.0" data-slider-step=".1" data-slider-highlight="true" value=".6"/>
-->
<label>
Intro Duration (ms)
</label>
<input type="text" id="globe-id" data-slider="true" data-slider-range="500,5000" data-slider-step="100" data-slider-highlight="true" value="2000"/>
<label>
Max Pins
</label>
<input type="text" id="globe-mp" data-slider="true" data-slider-range="10,1000" data-slider-step="10" data-slider-highlight="true" value="500"/>
<label>
Max Markers
</label>
<input type="text" id="globe-mm" data-slider="true" data-slider-range="1,10" data-slider-step="1" data-slider-highlight="true" value="4"/>
<label>
Satellite Altitude
</label>
<input type="text" id="globe-sa" data-slider="true" data-slider-range="1.0,3.0" data-slider-step=".01" data-slider-highlight="true" value="1.3"/>
<label>
Satellite Intensity
</label>
<input type="text" id="globe-si" data-slider="true" data-slider-range="3,12" data-slider-step="1" data-slider-highlight="true" value="8"/>
<label>
Load Dummy Data
</label>
<div class="switch">
<input type="checkbox" id="globe-dd" value="1" checked>
</div>
</div>
<div id="apply-button" class="button">Reload</div>
</div>
</div>
<div class="header" id="header-top">
<div class="header-left-section">CENTRAL SYSTEM DATA ... <span class="alt-1">LAUNCH ENCOM GLOBALIZATION</span></div>
<div class="header-right-section">OIA | 012</div>
</div>
<div class="header" id="header-bottom">
<div class="header-left-section">TOUCHPOINT KEYBOARD ... <span class="alt-1">INTERACTION SEQUENCING</span></div>
<div class="header-right-section">SYS | O12</div>
</div>
<div id="thumbprint">
<img src="resources/thumbprint.png" />
</div>
<!-- probably should remove these and have them created in the script-->
<div class="header-animator" id="header-animator-inside"></div>
<div class="header-animator" id="header-animator-outside"></div>
</div>
<!-- ref:include analytics -->
<!-- endref -->
</body>
</html>