Pim Schreurs commited on
Commit
aa14f68
·
1 Parent(s): 80d8f72

Fix orientation controls for iOS13

Browse files
index.html CHANGED
@@ -123,10 +123,28 @@
123
  }
124
  .no-ui #loading { display: none; }
125
 
 
 
 
 
 
 
 
 
 
126
  #keyboard-controls { display: block; }
127
  #mobile-device-controls { display: none; }
128
  .mobile-device #keyboard-controls { display: none; }
129
  .mobile-device #mobile-device-controls { display: block; }
 
 
 
 
 
 
 
 
 
130
 
131
  canvas { display: block; }
132
 
@@ -166,8 +184,12 @@
166
  Scroll to increase/decrease your field of view.
167
  </div>
168
  <div id="mobile-device-controls">
169
- <div class="no-pointer-events">Point your device around you to look around. Touch the screen to move forwards. Use two fingers to go faster.</div>
170
- <div id="teleport">Teleport to next object</div>
 
 
 
 
171
  </div>
172
  </div>
173
 
 
123
  }
124
  .no-ui #loading { display: none; }
125
 
126
+ button {
127
+ color: orange;
128
+ font: inherit;
129
+ text-shadow: inherit;
130
+ border: 1px solid;
131
+ background: rgba(0,0,0,0.5);
132
+ line-height: 1.5;
133
+ }
134
+
135
  #keyboard-controls { display: block; }
136
  #mobile-device-controls { display: none; }
137
  .mobile-device #keyboard-controls { display: none; }
138
  .mobile-device #mobile-device-controls { display: block; }
139
+ #permit-motion-controls {
140
+ display: none;
141
+ }
142
+ .no-motion-controls #permit-motion-controls {
143
+ display: inline-block;
144
+ }
145
+ .no-motion-controls .motion-description {
146
+ display: none;
147
+ }
148
 
149
  canvas { display: block; }
150
 
 
184
  Scroll to increase/decrease your field of view.
185
  </div>
186
  <div id="mobile-device-controls">
187
+ <div class="no-pointer-events">
188
+ <span class="motion-description">Point your device around you to look around.</span>
189
+ Touch the screen to move forwards. Use two fingers to go faster.
190
+ </div>
191
+ <button id="permit-motion-controls">Click here to enable looking around</button>
192
+ <button id="teleport">Teleport to next object</button>
193
  </div>
194
  </div>
195
 
src/Simulation.js CHANGED
@@ -140,6 +140,8 @@ class Simulation {
140
  })
141
  }
142
 
 
 
143
  this.player.addController(this.keyboardControls)
144
  this.player.addController(this.mobileDeviceControls)
145
  }
 
140
  })
141
  }
142
 
143
+ this.controlsManager.start()
144
+
145
  this.player.addController(this.keyboardControls)
146
  this.player.addController(this.mobileDeviceControls)
147
  }
src/controls/ControlsManager.js CHANGED
@@ -8,13 +8,27 @@ export default class ControlsManager {
8
 
9
  this.onKeyPress = this.onKeyPress.bind(this)
10
  this.onDeviceOrientation = this.onDeviceOrientation.bind(this)
11
-
12
- this.setDesktop()
13
  }
14
 
15
- setDesktop () {
16
  window.addEventListener('deviceorientation', this.onDeviceOrientation, false)
17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  this.keyboardControls.enable()
19
  this.mobileDeviceControls.disable()
20
 
@@ -27,7 +41,6 @@ export default class ControlsManager {
27
  this.controls = 'mobile'
28
 
29
  window.addEventListener('keypress', this.onKeyPress, false)
30
- window.removeEventListener('deviceorientation', this.onDeviceOrientation, false)
31
 
32
  this.keyboardControls.disable()
33
  this.mobileDeviceControls.enable()
@@ -47,6 +60,9 @@ export default class ControlsManager {
47
  }
48
 
49
  this.setMobile()
 
 
 
50
  }
51
 
52
  }
 
8
 
9
  this.onKeyPress = this.onKeyPress.bind(this)
10
  this.onDeviceOrientation = this.onDeviceOrientation.bind(this)
 
 
11
  }
12
 
13
+ start () {
14
  window.addEventListener('deviceorientation', this.onDeviceOrientation, false)
15
 
16
+ if (window.DeviceOrientationEvent && window.DeviceOrientationEvent.requestPermission) {
17
+ this.setMobile()
18
+
19
+ document.body.classList.add('no-motion-controls')
20
+ document.querySelector('#permit-motion-controls').addEventListener(
21
+ 'click',
22
+ () => window.DeviceOrientationEvent.requestPermission(),
23
+ false
24
+ )
25
+ }
26
+ else {
27
+ this.setDesktop()
28
+ }
29
+ }
30
+
31
+ setDesktop () {
32
  this.keyboardControls.enable()
33
  this.mobileDeviceControls.disable()
34
 
 
41
  this.controls = 'mobile'
42
 
43
  window.addEventListener('keypress', this.onKeyPress, false)
 
44
 
45
  this.keyboardControls.disable()
46
  this.mobileDeviceControls.enable()
 
60
  }
61
 
62
  this.setMobile()
63
+
64
+ document.body.classList.remove('no-motion-controls')
65
+ window.removeEventListener('deviceorientation', this.onDeviceOrientation, false)
66
  }
67
 
68
  }
src/postprocessing/EffectComposer.js CHANGED
@@ -48,9 +48,7 @@ export default class EffectComposer {
48
 
49
  render () {
50
  for (let i = 0; i < this.passes.length; i++) {
51
- let pass = this.passes[i]
52
-
53
- pass.render(this.renderer, this.writeBuffer, this.readBuffer)
54
  }
55
  }
56
 
 
48
 
49
  render () {
50
  for (let i = 0; i < this.passes.length; i++) {
51
+ this.passes[i].render(this.renderer, this.writeBuffer, this.readBuffer)
 
 
52
  }
53
  }
54