File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
Assets/MixedRealityToolkit.Services/InputSystem Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -191,8 +191,22 @@ protected MouseState GetMousePointerEventDataForMrtkPointer(PointerData pointerD
191191
192192 // Reset the RaycastCamera for projecting (used in calculating deltas)
193193 Debug . Assert ( pointer . Rays != null && pointer . Rays . Length > 0 ) ;
194- RaycastCamera . transform . position = pointer . Rays [ 0 ] . Origin ;
195- RaycastCamera . transform . rotation = Quaternion . LookRotation ( pointer . Rays [ 0 ] . Direction ) ;
194+
195+ if ( pointer . Controller != null && pointer . Controller . IsRotationAvailable )
196+ {
197+ RaycastCamera . transform . position = pointer . Rays [ 0 ] . Origin ;
198+ RaycastCamera . transform . rotation = Quaternion . LookRotation ( pointer . Rays [ 0 ] . Direction ) ;
199+ }
200+ else
201+ {
202+ // The pointer.Controller does not provide rotation, for example on HoloLens 1 hands.
203+ // In this case pointer.Rays[0].Origin will be the head position, but we want the
204+ // hand to do drag operations, not the head.
205+ // pointer.Position gives the position of the hand, use that to compute drag deltas.
206+ RaycastCamera . transform . position = pointer . Position ;
207+ RaycastCamera . transform . rotation = Quaternion . LookRotation ( pointer . Rays [ 0 ] . Direction ) ;
208+ }
209+
196210
197211 // Populate eventDataLeft
198212 pointerData . eventDataLeft . Reset ( ) ;
You can’t perform that action at this time.
0 commit comments