@@ -106,7 +106,12 @@ class ShoulderPoser extends MonoBehavior
106106
107107 updateHips ( ) {
108108 const hmdPosition = this . vrTrackingReferences . head . position ;
109- const hmdRotation = this . vrTrackingReferences . head . rotation . multiply ( z180Quaternion ) ;
109+ const hmdRotation = this . vrTrackingReferences . head . rotation ;
110+ if ( PoseManager . Instance . flipZ ) {
111+ hmdRotation . premultiply ( z180Quaternion ) ;
112+ } else {
113+ hmdRotation . multiply ( z180Quaternion ) ;
114+ }
110115 const hmdEuler = new THREE . Euler ( ) . setFromQuaternion ( hmdRotation , 'YXZ' ) ;
111116 hmdEuler . x = 0 ;
112117 hmdEuler . z = 0 ;
@@ -126,7 +131,12 @@ class ShoulderPoser extends MonoBehavior
126131
127132 updateNeck ( ) {
128133 // const hmdPosition = this.vrTrackingReferences.head.position;
129- const hmdRotation = this . vrTrackingReferences . head . rotation . multiply ( z180Quaternion ) ;
134+ const hmdRotation = this . vrTrackingReferences . head . rotation ;
135+ if ( PoseManager . Instance . flipZ ) {
136+ hmdRotation . premultiply ( z180Quaternion ) ;
137+ } else {
138+ hmdRotation . multiply ( z180Quaternion ) ;
139+ }
130140 const hmdEuler = new THREE . Euler ( ) . setFromQuaternion ( hmdRotation , 'YXZ' ) ;
131141 hmdEuler . x = 0 ;
132142 hmdEuler . z = 0 ;
@@ -211,8 +221,14 @@ class ShoulderPoser extends MonoBehavior
211221 const heightDiff = this . vrTrackingReferences . head . position . y - PoseManager . Instance . vrSystemOffsetHeight ;
212222 const relativeHeightDiff = - heightDiff / PoseManager . Instance . playerHeightHmd ;
213223
224+ const hmdRotation = this . vrTrackingReferences . head . rotation ;
225+ if ( PoseManager . Instance . flipZ ) {
226+ hmdRotation . premultiply ( z180Quaternion ) ;
227+ } else {
228+ hmdRotation . multiply ( z180Quaternion ) ;
229+ }
214230 const headRightRotation = VectorHelpers . getAngleBetween ( this . shoulder . transform . forward ,
215- new Vector3 ( 0 , 0 , 1 ) . applyQuaternion ( this . avatarTrackingReferences . head . transform . rotation . multiply ( z180Quaternion ) ) ,
231+ new Vector3 ( 0 , 0 , 1 ) . applyQuaternion ( hmdRotation ) ,
216232 Vector3 . up , this . shoulder . transform . right ) + this . rightRotationHeadRotationOffset ;
217233 const heightFactor = Mathf . Clamp ( relativeHeightDiff - this . rightRotationStartHeight , 0 , 1 ) ;
218234 this . shoulderRightRotation = heightFactor * this . rightRotationHeightFactor ;
@@ -276,7 +292,13 @@ class ShoulderPoser extends MonoBehavior
276292
277293 clampHeadRotationDeltaUp ( targetRotation )
278294 {
279- const headUpRotation = ( Transform . eulerAngles ( this . avatarTrackingReferences . head . transform . rotation . multiply ( z180Quaternion ) ) . y + 360 ) % 360 ;
295+ const hmdRotation = this . vrTrackingReferences . head . rotation ;
296+ if ( PoseManager . Instance . flipZ ) {
297+ hmdRotation . premultiply ( z180Quaternion ) ;
298+ } else {
299+ hmdRotation . multiply ( z180Quaternion ) ;
300+ }
301+ const headUpRotation = ( Transform . eulerAngles ( hmdRotation ) . y + 360 ) % 360 ;
280302 const targetUpRotation = ( targetRotation . y + 360 ) % 360 ;
281303
282304 const delta = headUpRotation - targetUpRotation ;
0 commit comments