Browse Source

Fix linting, and edit comments

thscott 6 năm trước cách đây
mục cha
commit
a2de5e1870
2 tập tin đã thay đổi với 14 bổ sung10 xóa
  1. 10 6
      src/Cameras/arcRotateCamera.ts
  2. 4 4
      src/Maths/math.ts

+ 10 - 6
src/Cameras/arcRotateCamera.ts

@@ -80,8 +80,9 @@ export class ArcRotateCamera extends TargetCamera {
     protected _upToYMatrix: Matrix;
     protected _YToUpMatrix: Matrix;
 
-    /**The vector the camera should consider as up. (default is Vector3(0, 1, 0) aka Vector3.Up())
-     * Setting this will copy the given vec to the camera's upVector, and set rotation matrices to and from the Y up.  
+    /**
+     * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
+     * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
      * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
      */
     set upVector(vec: Vector3) {
@@ -94,18 +95,21 @@ export class ArcRotateCamera extends TargetCamera {
 
         vec.normalize();
         this._upVector.copyFrom(vec);
-        this.setMatUp(); // still more efficient to calculate this once
+        this.setMatUp();
     }
 
     get upVector() {
         return this._upVector;
     }
 
-    setMatUp() {
+    /**
+     * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
+     */
+    public setMatUp() {
         // from y-up to custom-up (used in _getViewMatrix)
         Matrix.RotationAlignToRef(Vector3.UpReadOnly, this._upVector, this._YToUpMatrix);
 
-        // from custom-up to y-up (used in rebuildAnglesAndRadians)
+        // from custom-up to y-up (used in rebuildAnglesAndRadius)
         Matrix.RotationAlignToRef(this._upVector, Vector3.UpReadOnly, this._upToYMatrix);
     }
 
@@ -906,7 +910,7 @@ export class ArcRotateCamera extends TargetCamera {
 
         // Alpha
         if (this._computationVector.x === 0 && this._computationVector.z === 0) {
-            this.alpha = Math.PI / 2; // avoid division by zero, and set to acos(0)
+            this.alpha = Math.PI / 2; // avoid division by zero when looking along up axis, and set to acos(0)
         } else {
             this.alpha = Math.acos(this._computationVector.x / Math.sqrt(Math.pow(this._computationVector.x, 2) + Math.pow(this._computationVector.z, 2)));
         }

+ 4 - 4
src/Maths/math.ts

@@ -5477,7 +5477,7 @@ export class Matrix {
     }
 
     /**
-     * Takes normalised vectors and returns a rotation matrix to align "from" with "to".  
+     * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
      * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
      * @param from defines the vector to align
      * @param to defines the vector to align to
@@ -5489,9 +5489,9 @@ export class Matrix {
         const k = 1 / (1 + c);
 
         const m = result._m;
-        m[0]  = v.x*v.x*k + c;   m[1]  = v.y*v.x*k - v.z; m[2]  = v.z*v.x*k + v.y; m[3]  = 0;
-        m[4]  = v.x*v.y*k + v.z; m[5]  = v.y*v.y*k + c;   m[6]  = v.z*v.y*k - v.x; m[7]  = 0;
-        m[8]  = v.x*v.z*k - v.y; m[9]  = v.y*v.z*k + v.x; m[10] = v.z*v.z*k + c;   m[11] = 0;
+        m[0]  = v.x * v.x * k + c;   m[1]  = v.y * v.x * k - v.z; m[2]  = v.z * v.x * k + v.y; m[3]  = 0;
+        m[4]  = v.x * v.y * k + v.z; m[5]  = v.y * v.y * k + c;   m[6]  = v.z * v.y * k - v.x; m[7]  = 0;
+        m[8]  = v.x * v.z * k - v.y; m[9]  = v.y * v.z * k + v.x; m[10] = v.z * v.z * k + c;   m[11] = 0;
         m[12] = 0;               m[13] = 0;               m[14] = 0;               m[15] = 1;
 
         result._markAsUpdated();