ソースを参照

fix: 卡顿时旋转 加大摩擦力

xzw 3 年 前
コミット
a74da1f7fc
1 ファイル変更15 行追加11 行削除
  1. 15 11
      public/static/js/main_2020_show.js

+ 15 - 11
public/static/js/main_2020_show.js

@@ -4404,11 +4404,13 @@ window.Modernizr = function (n, e, t) {
             }
             ,
             n.prototype.update = function (e) {
-                e || (e = 1 / 60),
-                    this.rotationSpeed.multiplyScalar(1 - o.rotationFriction).addScaledVector(this.rotationAcceleration, o.rotationAccelerationOutside * e),
-                    this.rotateLeft(-this.rotationSpeed.x),
-                    this.noRotateUpDown || this.rotateUp(this.rotationSpeed.y),
-                    this.updatePan(e);
+                e || (e = 1 / 60);
+                 
+                var friction = Math.min(1, o.rotationFriction * e * 60) //add 如果deltaTime > 1/ 60 (比较卡),就增加rotationFriction, 以防止转动过久  
+                this.rotationSpeed.multiplyScalar(1 - friction).addScaledVector(this.rotationAcceleration, o.rotationAccelerationOutside * e) 
+                this.rotateLeft(-this.rotationSpeed.x),
+                this.noRotateUpDown || this.rotateUp(this.rotationSpeed.y),
+                this.updatePan(e);
                 var t = this.camera.position;
                 this.offset.copy(t).sub(this.target);
                 var i = Math.atan2(this.offset.x, this.offset.z)
@@ -4995,12 +4997,14 @@ window.Modernizr = function (n, e, t) {
                         this.rotationHistory.push(this.rotationDifference.clone()); this.rotationHistory.length > a.rotationAfterMoveHistoryCount;)
                         this.rotationHistory.shift();
                     this.lon += this.rotationDifference.x,
-                        this.lat += this.rotationDifference.y,
-                        this.rotationDifference.set(0, 0),
-                        this.rotationSpeed.x = this.rotationSpeed.x * (1 - a.rotationFriction) + this.rotationAcc.x * a.rotationAccelerationInside,
-                        this.rotationSpeed.y = this.rotationSpeed.y * (1 - a.rotationFriction) + this.rotationAcc.y * a.rotationAccelerationInside,
-                        this.lon += this.rotationSpeed.x * e,
-                        this.lat += this.rotationSpeed.y * e
+                    this.lat += this.rotationDifference.y,
+                    this.rotationDifference.set(0, 0);
+                    //改
+                    var friction = Math.min(1, a.rotationFriction * e * 60) //如果deltaTime > 1/ 60 (比较卡),就增加rotationFriction, 以防止转动过久  
+                    this.rotationSpeed.x = this.rotationSpeed.x * (1 - friction) + this.rotationAcc.x * a.rotationAccelerationInside,
+                    this.rotationSpeed.y = this.rotationSpeed.y * (1 - friction) + this.rotationAcc.y * a.rotationAccelerationInside,
+                    this.lon += this.rotationSpeed.x * e,
+                    this.lat += this.rotationSpeed.y * e
 
 
                     //this.lat = Math.max(a.insideLookLimitDown, Math.min(a.insideLookLimitUp, this.lat)),