浏览代码

Target Camera constraints applied before quaterion

sebavan 5 年之前
父节点
当前提交
7dcd1696a4
共有 1 个文件被更改,包括 9 次插入8 次删除
  1. 9 8
      src/Cameras/targetCamera.ts

+ 9 - 8
src/Cameras/targetCamera.ts

@@ -324,14 +324,7 @@ export class TargetCamera extends Camera {
             this.rotation.x += this.cameraRotation.x * directionMultiplier;
             this.rotation.y += this.cameraRotation.y * directionMultiplier;
 
-            //rotate, if quaternion is set and rotation was used
-            if (this.rotationQuaternion) {
-                var len = this.rotation.lengthSquared();
-                if (len) {
-                    Quaternion.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion);
-                }
-            }
-
+            // Apply constraints
             if (!this.noRotationConstraint) {
                 var limit = 1.570796;
 
@@ -342,6 +335,14 @@ export class TargetCamera extends Camera {
                     this.rotation.x = -limit;
                 }
             }
+
+            //rotate, if quaternion is set and rotation was used
+            if (this.rotationQuaternion) {
+                var len = this.rotation.lengthSquared();
+                if (len) {
+                    Quaternion.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion);
+                }
+            }
         }
 
         // Inertia