@@ -29,14 +29,10 @@ module.exports.Component = registerComponent('daydream-controls', {
2929 // 1 - menu (never dispatched on this layer)
3030 // 2 - system (never dispatched on this layer)
3131 mapping : {
32- axes : { ' trackpad' : [ 0 , 1 ] } ,
32+ axes : { trackpad : [ 0 , 1 ] } ,
3333 buttons : [ 'trackpad' , 'menu' , 'system' ]
3434 } ,
3535
36- // Use these labels for detail on axis events such as thumbstickmoved.
37- // e.g. for thumbstickmoved detail, the first axis returned is labeled x, and the second is labeled y.
38- axisLabels : [ 'x' , 'y' , 'z' , 'w' ] ,
39-
4036 bindMethods : function ( ) {
4137 this . onModelLoaded = bind ( this . onModelLoaded , this ) ;
4238 this . onControllersUpdate = bind ( this . onControllersUpdate , this ) ;
@@ -50,17 +46,25 @@ module.exports.Component = registerComponent('daydream-controls', {
5046 var self = this ;
5147 this . animationActive = 'pointing' ;
5248 this . onButtonChanged = bind ( this . onButtonChanged , this ) ;
53- this . onButtonDown = function ( evt ) { self . onButtonEvent ( evt . detail . id , 'down' ) ; } ;
54- this . onButtonUp = function ( evt ) { self . onButtonEvent ( evt . detail . id , 'up' ) ; } ;
55- this . onButtonTouchStart = function ( evt ) { self . onButtonEvent ( evt . detail . id , 'touchstart' ) ; } ;
56- this . onButtonTouchEnd = function ( evt ) { self . onButtonEvent ( evt . detail . id , 'touchend' ) ; } ;
49+ this . onButtonDown = function ( evt ) {
50+ self . onButtonEvent ( evt . detail . id , 'down' ) ;
51+ } ;
52+ this . onButtonUp = function ( evt ) {
53+ self . onButtonEvent ( evt . detail . id , 'up' ) ;
54+ } ;
55+ this . onButtonTouchStart = function ( evt ) {
56+ self . onButtonEvent ( evt . detail . id , 'touchstart' ) ;
57+ } ;
58+ this . onButtonTouchEnd = function ( evt ) {
59+ self . onButtonEvent ( evt . detail . id , 'touchend' ) ;
60+ } ;
5761 this . onAxisMoved = bind ( this . onAxisMoved , this ) ;
5862 this . controllerPresent = false ;
5963 this . everGotGamepadEvent = false ;
6064 this . lastControllerCheck = 0 ;
6165 this . bindMethods ( ) ;
62- this . checkControllerPresentAndSetup = checkControllerPresentAndSetup ; // to allow mock
63- this . emitIfAxesChanged = emitIfAxesChanged ; // to allow mock
66+ this . checkControllerPresentAndSetup = checkControllerPresentAndSetup ; // To allow mock.
67+ this . emitIfAxesChanged = emitIfAxesChanged ; // To allow mock.
6468 } ,
6569
6670 addEventListeners : function ( ) {
@@ -117,7 +121,12 @@ module.exports.Component = registerComponent('daydream-controls', {
117121 injectTrackedControls : function ( ) {
118122 var el = this . el ;
119123 var data = this . data ;
120- el . setAttribute ( 'tracked-controls' , { idPrefix : GAMEPAD_ID_PREFIX , hand : data . hand , rotationOffset : data . rotationOffset , armModel : data . armModel } ) ;
124+ el . setAttribute ( 'tracked-controls' , {
125+ armModel : data . armModel ,
126+ hand : data . hand ,
127+ idPrefix : GAMEPAD_ID_PREFIX ,
128+ rotationOffset : data . rotationOffset
129+ } ) ;
121130 if ( ! this . data . model ) { return ; }
122131 this . el . setAttribute ( 'obj-model' , {
123132 obj : DAYDREAM_CONTROLLER_MODEL_OBJ_URL ,
@@ -137,21 +146,24 @@ module.exports.Component = registerComponent('daydream-controls', {
137146 if ( ! this . everGotGamepadEvent ) { this . checkIfControllerPresent ( ) ; }
138147 } ,
139148
140- // No need for onButtonChanged, since Daydream controller has no analog buttons.
141-
142149 onModelLoaded : function ( evt ) {
143150 var controllerObject3D = evt . detail . model ;
144151 var buttonMeshes ;
145152 if ( ! this . data . model ) { return ; }
146153 buttonMeshes = this . buttonMeshes = { } ;
147- buttonMeshes . menu = controllerObject3D . getObjectByName ( 'AppButton_AppButton_Cylinder.004' ) ;
148- buttonMeshes . system = controllerObject3D . getObjectByName ( 'HomeButton_HomeButton_Cylinder.005' ) ;
149- buttonMeshes . trackpad = controllerObject3D . getObjectByName ( 'TouchPad_TouchPad_Cylinder.003' ) ;
150- // Offset pivot point
154+ buttonMeshes . menu = controllerObject3D . getObjectByName (
155+ 'AppButton_AppButton_Cylinder.004' ) ;
156+ buttonMeshes . system = controllerObject3D . getObjectByName (
157+ 'HomeButton_HomeButton_Cylinder.005' ) ;
158+ buttonMeshes . trackpad = controllerObject3D . getObjectByName (
159+ 'TouchPad_TouchPad_Cylinder.003' ) ;
160+ // Offset pivot point.
151161 controllerObject3D . position . set ( 0 , 0 , - 0.04 ) ;
152162 } ,
153163
154- onAxisMoved : function ( evt ) { this . emitIfAxesChanged ( this , this . mapping . axes , evt ) ; } ,
164+ onAxisMoved : function ( evt ) {
165+ this . emitIfAxesChanged ( this , this . mapping . axes , evt ) ;
166+ } ,
155167
156168 onButtonChanged : function ( evt ) {
157169 var button = this . mapping . buttons [ evt . detail . id ] ;
0 commit comments