Sfoglia il codice sorgente

store RH to LH matrix in gizmo

Cedric Guillemet 5 anni fa
parent
commit
e99bdcc1c8
1 ha cambiato i file con 3 aggiunte e 2 eliminazioni
  1. 3 2
      src/Gizmos/gizmo.ts

+ 3 - 2
src/Gizmos/gizmo.ts

@@ -114,7 +114,8 @@ export class Gizmo implements IDisposable {
     private _tempVector2 = new Vector3();
     private _tempMatrix1 = new Matrix();
     private _tempMatrix2 = new Matrix();
-
+    private _rightHandtoLeftHandMatrix = Matrix.RotationY(Math.PI);
+    
     /**
      * Creates a gizmo
      * @param gizmoLayer The utility layer the gizmo will be added to
@@ -202,7 +203,7 @@ export class Gizmo implements IDisposable {
 
             if (camera.getScene().useRightHandedSystem) {
                 // avoid desync with RH matrix computation. Otherwise, rotation of PI around Y axis happens each frame resulting in axis flipped because worldMatrix is computed as inverse of viewMatrix.
-                Matrix.RotationY(Math.PI).multiplyToRef(worldMatrix, this._tempMatrix2);
+                this._rightHandtoLeftHandMatrix.multiplyToRef(worldMatrix, this._tempMatrix2);
                 worldMatrixUC = this._tempMatrix2;
             } else {
                 worldMatrixUC = worldMatrix;