@@ -144,6 +144,7 @@ module.exports.Component = registerComponent('oculus-touch-controls', {
144144 this . onThumbstickMoved = this . onThumbstickMoved . bind ( this ) ;
145145 this . onModelLoaded = this . onModelLoaded . bind ( this ) ;
146146 this . onControllersUpdate = this . onControllersUpdate . bind ( this ) ;
147+ this . onControllerDisconnected = this . onControllerDisconnected . bind ( this ) ;
147148 this . checkIfControllerPresent = this . checkIfControllerPresent . bind ( this ) ;
148149 this . onAxisMoved = this . onAxisMoved . bind ( this ) ;
149150 } ,
@@ -155,7 +156,6 @@ module.exports.Component = registerComponent('oculus-touch-controls', {
155156 this . onButtonTouchStart = function ( evt ) { onButtonEvent ( evt . detail . id , 'touchstart' , self , self . data . hand ) ; } ;
156157 this . onButtonTouchEnd = function ( evt ) { onButtonEvent ( evt . detail . id , 'touchend' , self , self . data . hand ) ; } ;
157158 this . controllerPresent = false ;
158- this . lastControllerCheck = 0 ;
159159 this . previousButtonValues = { } ;
160160 this . bindMethods ( ) ;
161161 this . triggerEuler = new THREE . Euler ( ) ;
@@ -207,11 +207,11 @@ module.exports.Component = registerComponent('oculus-touch-controls', {
207207 loadModel : function ( controller ) {
208208 var data = this . data ;
209209 var controllerId ;
210-
211210 if ( ! data . model ) { return ; }
212211 // If model has been already loaded
213212 if ( this . controllerObject3D ) {
214213 this . el . setObject3D ( 'mesh' , this . controllerObject3D ) ;
214+ this . controllerObject3D . visible = true ;
215215 return ;
216216 }
217217
@@ -252,10 +252,17 @@ module.exports.Component = registerComponent('oculus-touch-controls', {
252252
253253 addControllersUpdateListener : function ( ) {
254254 this . el . sceneEl . addEventListener ( 'controllersupdated' , this . onControllersUpdate , false ) ;
255+ this . el . addEventListener ( 'controllerdisconnected' , this . onControllerDisconnected ) ;
255256 } ,
256257
257258 removeControllersUpdateListener : function ( ) {
258259 this . el . sceneEl . removeEventListener ( 'controllersupdated' , this . onControllersUpdate , false ) ;
260+ this . el . removeEventListener ( 'controllerdisconnected' , this . onControllerDisconnected ) ;
261+ } ,
262+
263+ onControllerDisconnected : function ( ) {
264+ if ( ! this . controllerObject3D ) { return ; }
265+ this . controllerObject3D . visible = false ;
259266 } ,
260267
261268 onControllersUpdate : function ( ) {
0 commit comments