@@ -3,7 +3,7 @@ var THREE = require('../lib/three');
33var utils = require ( '../utils/' ) ;
44var bind = utils . bind ;
55
6- var checkHeadsetConnected = utils . checkHeadsetConnected ;
6+ var checkHasPositionalTracking = utils . device . checkHasPositionalTracking ;
77
88/**
99 * Camera component.
@@ -121,20 +121,18 @@ module.exports.Component = registerComponent('camera', {
121121 /**
122122 * Remove the height offset (called when entering VR) since WebVR API gives absolute
123123 * position.
124- * Does not apply for mobile.
125124 */
126125 removeHeightOffset : function ( ) {
127126 var currentPosition ;
128127 var el = this . el ;
129- var headsetConnected ;
130- var sceneEl = el . sceneEl ;
128+ var hasPositionalTracking ;
131129 var userHeightOffset = this . data . userHeight ;
132130
133- // If there's not a headset connected we keep the offset .
131+ // Remove the offset if there is positional tracking when entering VR .
134132 // Necessary for fullscreen mode with no headset.
135- // Checking this.headsetConnected to make the value injectable for unit tests.
136- headsetConnected = this . headsetConnected || checkHeadsetConnected ( ) ;
137- if ( sceneEl . isMobile || ! userHeightOffset || ! headsetConnected ) { return ; }
133+ // Checking this.hasPositionalTracking to make the value injectable for unit tests.
134+ hasPositionalTracking = this . hasPositionalTracking || checkHasPositionalTracking ( ) ;
135+ if ( ! userHeightOffset || ! hasPositionalTracking ) { return ; }
138136
139137 currentPosition = el . getAttribute ( 'position' ) || { x : 0 , y : 0 , z : 0 } ;
140138 el . setAttribute ( 'position' , {
@@ -149,9 +147,9 @@ module.exports.Component = registerComponent('camera', {
149147 */
150148 saveCameraPose : function ( ) {
151149 var el = this . el ;
152- var headsetConnected = this . headsetConnected || checkHeadsetConnected ( ) ;
150+ var hasPositionalTracking = this . hasPositionalTracking || checkHasPositionalTracking ( ) ;
153151
154- if ( this . savedPose || ! headsetConnected ) { return ; }
152+ if ( this . savedPose || ! hasPositionalTracking ) { return ; }
155153
156154 this . savedPose = {
157155 position : el . getAttribute ( 'position' ) ,
@@ -165,9 +163,9 @@ module.exports.Component = registerComponent('camera', {
165163 restoreCameraPose : function ( ) {
166164 var el = this . el ;
167165 var savedPose = this . savedPose ;
168- var headsetConnected = this . headsetConnected || checkHeadsetConnected ( ) ;
166+ var hasPositionalTracking = this . hasPositionalTracking || checkHasPositionalTracking ( ) ;
169167
170- if ( ! savedPose || ! headsetConnected ) { return ; }
168+ if ( ! savedPose || ! hasPositionalTracking ) { return ; }
171169
172170 // Reset camera orientation.
173171 el . setAttribute ( 'position' , savedPose . position ) ;
0 commit comments