File tree Expand file tree Collapse file tree 2 files changed +47
-4
lines changed Expand file tree Collapse file tree 2 files changed +47
-4
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ THREE.VRControls = function ( object, onError ) {
7
7
8
8
var scope = this ;
9
9
10
- var vrDisplay ;
10
+ var vrDisplay , vrDisplays ;
11
11
12
12
var standingMatrix = new THREE . Matrix4 ( ) ;
13
13
@@ -16,6 +16,28 @@ THREE.VRControls = function ( object, onError ) {
16
16
frameData = new VRFrameData ( ) ;
17
17
}
18
18
19
+ function gotVRDisplays ( displays ) {
20
+
21
+ vrDisplays = displays ;
22
+
23
+ if ( displays . length > 0 ) {
24
+
25
+ vrDisplay = displays [ 0 ] ;
26
+
27
+ } else {
28
+
29
+ if ( onError ) onError ( 'VR input not available.' ) ;
30
+
31
+ }
32
+
33
+ }
34
+
35
+ if ( navigator . getVRDisplays ) {
36
+
37
+ navigator . getVRDisplays ( ) . then ( gotVRDisplays ) ;
38
+
39
+ }
40
+
19
41
// the Rift SDK returns the position in meters
20
42
// this scale factor allows the user to define how meters
21
43
// are converted to scene units.
Original file line number Diff line number Diff line change 9
9
*
10
10
*/
11
11
12
- THREE . VREffect = function ( renderer ) {
13
-
14
- var vrDisplay ;
12
+ THREE . VREffect = function ( renderer , onError ) {
15
13
14
+ var vrDisplay , vrDisplays ;
16
15
var eyeTranslationL = new THREE . Vector3 ( ) ;
17
16
var eyeTranslationR = new THREE . Vector3 ( ) ;
18
17
var renderRectL , renderRectR ;
@@ -24,6 +23,28 @@ THREE.VREffect = function ( renderer ) {
24
23
25
24
}
26
25
26
+ function gotVRDisplays ( displays ) {
27
+
28
+ vrDisplays = displays ;
29
+
30
+ if ( displays . length > 0 ) {
31
+
32
+ vrDisplay = displays [ 0 ] ;
33
+
34
+ } else {
35
+
36
+ if ( onError ) onError ( 'HMD not available' ) ;
37
+
38
+ }
39
+
40
+ }
41
+
42
+ if ( navigator . getVRDisplays ) {
43
+
44
+ navigator . getVRDisplays ( ) . then ( gotVRDisplays ) ;
45
+
46
+ }
47
+
27
48
//
28
49
29
50
this . isPresenting = false ;
You can’t perform that action at this time.
0 commit comments