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
|
var ReaderView = View.extend({
el: "#readerView",
projectAction: "/api/project/",
events: {
},
initialize: function(){
this.mediaPlayer = new MediaPlayer ({ parent: this })
this.shareView = new ShareView ({ parent: this })
},
load: function(name){
var opt = this.getQS()
var mode = "default"
var name = sanitize(name)
if (opt.noui) {
$(".logo, .topLinks, #editorView, #keyhint").hide()
mode = "noui"
}
if (opt.embed) {
$(".topLinks, .share, #edit-room-link, #keyhint").hide()
mode = "embed"
}
if (opt.mute) {
app.muted = true
}
this.tracker = new Tracker ({ mode: mode })
if ('vvalls_data' in window) {
this.ready(window.vvalls_data)
}
else {
$.get(this.projectAction + name, this.ready.bind(this))
}
},
getQS: function(){
var qs = {}
window.location.search.replace(/^\?/,"").split("&").forEach(function(s){
var pair = s.split("=")
if (pair.length < 2) {
qs[pair[0]] = true
}
else {
qs[pair[0]] = pair[1]
}
})
return qs
},
ready: function(data){
$("#map").hide()
this.data = data
var is_landscape = window.innerWidth > window.innerHeight
if (is_desktop || (is_mobile && is_landscape)) {
this.build(data)
return
}
// don't build anything until we're in landscape mode, otherwise ios might crash!!
var orientationFn = orientationchange.bind(this)
window.addEventListener('orientationchange', orientationFn)
function orientationchange (e) {
var is_landscape = window.innerWidth > window.innerHeight
if (is_landscape) {
window.removeEventListener('orientationchange', orientationFn)
this.build(data)
}
}
},
build: function(data){
data.rooms && Rooms.deserialize(data.rooms)
data.walls && Walls.deserialize(data.walls)
data.media && Scenery.deserialize(data.media)
data.sculpture && Sculpture.deserialize(data.sculpture)
data.startPosition && scene.camera.move(data.startPosition)
cam.y = window.viewHeight = data.viewHeight || app.defaults.viewHeight
var colors = data.colors || app.defaults.colors
var modes = [ "wall", "outline", "floor", "ceiling" ]
modes.forEach(function(mode){
Walls.setColor[mode](colors[mode])
})
window.editor && editor.permissions.clear()
// disable until we start using spinning again
// this.listen()
},
listen: function(){
var base = this
$(window).on('message', function(event){
if (event.originalEvent.origin !== window.location.origin) {
return
}
var message = event.originalEvent.data
switch (message) {
case "spin-on":
base.spinning = true
break
case "spin-off":
base.spinning = false
break
}
})
requestAnimationFrame(this.spin.bind(this))
},
spinning: false,
spin: function(){
requestAnimationFrame(this.spin.bind(this))
if (this.spinning) {
scene.camera.rotationY -= 1/180
}
},
pick: function(scenery){
var has_info = this.mediaPlayer.pick(scenery)
$("#minimap").toggleClass('active', ! has_info)
app.tube("pick-scenery", { scenery: scenery })
},
pickWall: function(wall, pos){
this.hideExtras()
},
hideExtras: function(){
$("#minimap").addClass('active')
this.mediaPlayer.hide()
app.tube("close-scenery")
}
})
|