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
|
if (is_mobile) {
$("html").addClass("mobile")
}
else {
$("html").addClass("desktop")
}
var scene, cam, map;
var app = new function(){}
app.mode = { editor: false, builder: false }
app.init = function () {
app.tube = new Tube ()
app.router = new SiteRouter ()
}
app.launch = function () {
if ($.browser.msie || ! has3d()) { return app.fallback() }
var movements
app.devicePixelRatio = is_mobile ? devicePixelRatio : 1
scene = new MX.Scene().addTo('#scene')
scene.width = window.innerWidth
scene.height = window.innerHeight
scene.perspective = window.innerHeight
window.onresize = function () {
scene.width = window.innerWidth
scene.height = window.innerHeight
scene.perspective = window.innerHeight
scene.update()
}
cam = scene.camera
cam.y = viewHeight
if (MX.Map) map = app.map = new MX.Map()
if (is_mobile) {
app.movements = new MX.MobileMovements(cam, viewHeight)
}
else {
app.movements = new MX.Movements(cam, viewHeight)
}
app.movements.init()
var last_t = 0
function animate (t) {
var dt = t - last_t
last_t = t
requestAnimationFrame(animate)
environment.update(t)
window.path && path.update(t)
app.movements.update(dt || 0)
scene.update()
}
var loader = new Loader(function(){
$("#loader").hide()
window.environment && window.environment.init()
// window.editor && window.editor.init()
// window.path && window.path.init()
animate()
})
// loader.preloadImages([])
loader.ready()
window.scrollTo(0,0)
}
app.fallback = function(){
app.unsupported = true
var msg = "Sorry, your browser is not supported.<br><br>" +
"Please use <a href='http://chrome.com/'>Chrome</a> or <a href='https://www.apple.com/safari/'>Safari</a> or <a href='http://getfirefox.com/'>Firefox</a>."
var $fallback = $("<div>")
$fallback.attr('id', 'fallback')
$fallback.html(msg)
$('body').append($fallback)
$("#keyhint").hide()
$("#editorView").hide()
}
app.on = function(){
app.tube.on.apply(app.tube, arguments)
}
app.off = function(){
app.tube.off.apply(app.tube, arguments)
}
app.position = function(obj){
var pos = {
x: obj.x,
y: obj.y,
z: obj.z,
rotationX: obj.rotationX,
rotationY: obj.rotationY
}
if (obj.scale !== 1) {
pos.scale = obj.scale
}
return pos
}
document.addEventListener('DOMContentLoaded', app.init)
|