@@ -112,8 +112,28 @@ module.exports.Component = registerComponent('hand-controls', {
112112 mesh . mixer . update ( delta / 1000 ) ;
113113 } ,
114114
115- onControllerConnected : function ( ) {
116- this . el . object3D . visible = true ;
115+ onControllerConnected : function ( evt ) {
116+ var el = this . el ;
117+ var hand = this . data . hand ;
118+ var mesh = this . el . getObject3D ( 'mesh' ) ;
119+
120+ el . object3D . visible = true ;
121+
122+ var handModelOrientationZ = hand === 'left' ? Math . PI / 2 : - Math . PI / 2 ;
123+ // The WebXR standard defines the grip space such that a cylinder held in a closed hand points
124+ // along the Z axis. The models currently have such a cylinder point along the X-Axis.
125+ var handModelOrientationX = el . sceneEl . hasWebXR ? - Math . PI / 2 : 0 ;
126+
127+ // Pico4, at least on Wolvic, needs a different rotation offset
128+ // for the hand model. Pico Browser claims to use oculus
129+ // controllers instead; will load oculus-touch-controls and does
130+ // not require this adjustment.
131+ if ( evt . detail . name === 'pico-controls' ) {
132+ handModelOrientationX += Math . PI / 4 ;
133+ }
134+
135+ mesh . position . set ( 0 , 0 , 0 ) ;
136+ mesh . rotation . set ( handModelOrientationX , 0 , handModelOrientationZ ) ;
117137 } ,
118138
119139 onControllerDisconnected : function ( ) {
@@ -199,35 +219,19 @@ module.exports.Component = registerComponent('hand-controls', {
199219 var handmodelUrl = MODEL_URLS [ handModelStyle + hand . charAt ( 0 ) . toUpperCase ( ) + hand . slice ( 1 ) ] ;
200220 this . loader . load ( handmodelUrl , function ( gltf ) {
201221 var mesh = gltf . scene . children [ 0 ] ;
202- var handModelOrientationZ = hand === 'left' ? Math . PI / 2 : - Math . PI / 2 ;
203- // The WebXR standard defines the grip space such that a cylinder held in a closed hand points
204- // along the Z axis. The models currently have such a cylinder point along the X-Axis.
205- var handModelOrientationX = el . sceneEl . hasWebXR ? - Math . PI / 2 : 0 ;
206222 mesh . mixer = new THREE . AnimationMixer ( mesh ) ;
207223 self . clips = gltf . animations ;
208224 el . setObject3D ( 'mesh' , mesh ) ;
209225 mesh . traverse ( function ( object ) {
210226 if ( ! object . isMesh ) { return ; }
211227 object . material . color = new THREE . Color ( handColor ) ;
212228 } ) ;
213- mesh . position . set ( 0 , 0 , 0 ) ;
214- mesh . rotation . set ( handModelOrientationX , 0 , handModelOrientationZ ) ;
215229 el . setAttribute ( 'magicleap-controls' , controlConfiguration ) ;
216230 el . setAttribute ( 'vive-controls' , controlConfiguration ) ;
217231 el . setAttribute ( 'oculus-touch-controls' , controlConfiguration ) ;
218232 el . setAttribute ( 'pico-controls' , controlConfiguration ) ;
219233 el . setAttribute ( 'windows-motion-controls' , controlConfiguration ) ;
220234 el . setAttribute ( 'hp-mixed-reality-controls' , controlConfiguration ) ;
221-
222- // Pico4, at least on Wolvic, needs a different rotation
223- // offset for the hand model. Pico Browser claims to use
224- // oculus controllers instead; will load oculus-touch-controls
225- // and does not require this adjustment.
226- el . addEventListener ( 'controllerconnected' , function ( evt ) {
227- if ( evt . detail . name === 'pico-controls' ) {
228- mesh . rotation . x += Math . PI / 4 ;
229- }
230- } , { once : true } ) ;
231235 } ) ;
232236 }
233237 } ,
0 commit comments