ソースを参照

Merge branch 'newWebRtc' of http://192.168.0.115:3000/xushiting/Metaverse into newWebRtc

xushiting 3 年 前
コミット
e49f689280
3 ファイル変更90 行追加73 行削除
  1. 18 18
      src/ActionsHandler.js
  2. 2 0
      src/RotationEvent.js
  3. 70 55
      src/Signal.js

+ 18 - 18
src/ActionsHandler.js

@@ -27,37 +27,37 @@ export default class ActionsHandler {
         })
     }
 
-    async sendData(e) {
+    async sendData(actionData) {
 
-        //console.log('发送数据:'+JSON.stringify(e))
+        console.log('发送数据:'+JSON.stringify(actionData))
 
-        await this.beforeSend(e);
-        const t = util.uuid();
-        this.room.networkController.sendRtcData(le(oe({}, e.data), {
-            trace_id: t,
+        await this.beforeSend(actionData);
+        const traceId = util.uuid();
+        this.room.networkController.sendRtcData(le(oe({}, actionData.data), {
+            trace_id: traceId,
             user_id: this.room.options.userId
         }));
 
-        if (e.track === !1)
+        if (actionData.track === !1)
         {
             return Promise.resolve(null);
         }
-        const {sampleRate: r=1, timeout: n=2e3, tag: o, data: a, special: s} = e;
+        const { sampleRate=1, timeout=2e3, tag, data, special } = actionData;
         return eventsManager.track({
-            timeout: n,
-            traceId: t,
-            event: a.action_type,
-            tag: o,
-            extra: a
+            timeout,
+            traceId,
+            event: data.action_type,
+            tag,
+            extra: data
         }, {
-            special: s,
-            sampleRate: r,
+            special,
+            sampleRate,
             noReport: this.room.viewMode === "serverless" || this.room.options.viewMode === "serverless"
         }).finally(()=>{
-            QueueActions.includes(e.data.action_type) && (this.currentActiveAction = void 0)
-        }
-        )
+            QueueActions.includes(actionData.data.action_type) && (this.currentActiveAction = void 0)
+        })
     }
+
     async beforeSend(e) {
         var o;
         const t = (o = this.room._userAvatar) == null ? void 0 : o.isMoving

+ 2 - 0
src/RotationEvent.js

@@ -28,8 +28,10 @@ export default class RotationEvent {
               , o = r - this.touchStartY
               , a = this._room.options.canvas.offsetHeight
               , s = this._room.options.canvas.offsetWidth;
+            // 后端定,鼠标移动一个canvas width转动90度。*2移动距离加倍,所以前端实际会转180度
             let l = 2 * o / a
               , u = 2 * n / s;
+            // 瞬时最大不超过90度
             l > 1 && (l = 1),
             u > 1 && (u = 1),
             this._room.actionsHandler.rotate({

ファイルの差分が大きいため隠しています
+ 70 - 55
src/Signal.js