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
|
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 })
$.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
data.rooms && Rooms.deserialize(data.rooms)
data.walls && Walls.deserialize(data.walls)
data.media && Scenery.deserialize(data.media)
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])
})
editor.permissions.clear()
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){
this.mediaPlayer.pick(scenery)
app.tube("pick-scenery", { scenery: scenery })
},
pickWall: function(wall, pos){
this.hideExtras()
},
hideExtras: function(){
this.mediaPlayer.hide()
app.tube("close-scenery")
}
})
|