zhouenguang il y a 3 ans
Parent
commit
7cc58be8bd
2 fichiers modifiés avec 22 ajouts et 9 suppressions
  1. 19 8
      src/RotationEvent.js
  2. 3 1
      src/Xverse_Room.js

+ 19 - 8
src/RotationEvent.js

@@ -48,22 +48,33 @@ export default class RotationEvent {
             const canvasHeight = this._room.options.canvas.offsetHeight
             const canvasWidth = this._room.options.canvas.offsetWidth
 
+
+            // 旋转中
+            if(this.rotating) return
+
+
             // offset累计
             if(!this.offset) this.offset = 0
             this.offset += offsetX
 
             // 累计超过6度
-            let angle = Math.round(this.offset / (canvasWidth*10) * 2 * Math.PI / (Math.PI/30)) * (Math.PI/30)
+            let angle = this.offset / (canvasWidth*2) * (2*Math.PI)
+            angle = Math.round(angle / (Math.PI/30)) * (Math.PI/30)
             if(Math.abs(angle) < Math.PI/30) return
 
-            // 开始旋转
-            this._room.actionsHandler.rotate({
-                type: 'rotate',
-                angle: angle
-            });
+            this.rotating = true
+
+            setTimeout(() => {
+                // 开始旋转
+                this._room.actionsHandler.rotate({
+                    type: 'rotate',
+                    angle: Math.PI/30 * Math.sign(angle)    // angle
+                });
 
-            // 重置累计
-            this.offset = 0
+                // 重置累计
+                this.offset = 0
+                this.rotating = false
+            }, 1000/32)
 
             this.touchStartX = pageX;
             this.touchStartY = pageY;

+ 3 - 1
src/Xverse_Room.js

@@ -200,7 +200,9 @@ export default class Xverse_Room extends EventEmitter {
         response.signal.newUserStates[0].playerState.cameraCenter.z = this.avatarManager.avatars.get(nickname).position.z
         
         console.log('更新相机角度')
-        this.signal.handleSignal(response)
+        // setTimeout(() => {
+            this.signal.handleSignal(response)
+        // }, 50);
     }
 
     get currentNetworkOptions() {