xushiting 3 years ago
parent
commit
a5f2ac7b45
5 changed files with 84 additions and 84 deletions
  1. 2 2
      src/Signal.js
  2. 1 1
      src/Socket.js
  3. 52 52
      src/Workers.js
  4. 25 25
      src/XAvatarManager.js
  5. 4 4
      src/main.js

+ 2 - 2
src/Signal.js

@@ -35,9 +35,9 @@ export default class Signal {
             return
         }
 
-        if(t.actionType == 1009){
+        //if(t.actionType == 1009){
             console.log('执行signal:'+JSON.stringify(t))
-        }
+        //}
 
         this.isUpdatedYUV = r;
         const n = t;

+ 1 - 1
src/Socket.js

@@ -60,7 +60,7 @@ export default class Socket extends EventEmitter {
                     room_type_id: C,
                     syncToOthers: A,
                     hasAvatar: S,
-                    avatarSize: 1,
+                    avatarSize: h,
                     prioritySync: P,
                     extra: JSON.stringify(R)
                 })

+ 52 - 52
src/Workers.js

@@ -383,26 +383,26 @@ export default class Workers {
             if(this.cachedStreams[this.setPtr] != null && this.cachedStreams[this.setPtr].byteLength != 0)
             {
                 if(e.data.data == null){
-                    // this.executeFunction("stream", {
-                    //     stream: this.cachedStreams[this.setPtr],
-                    //     width: this.cachedResolution[this.setPtr].width,
-                    //     height: this.cachedResolution[this.setPtr].height,
-                    //     pts: this.cachedPtss[this.setPtr]
-                    // }),
-                    // this.executeFunction("signal", {
-                    //     signal: this.cachedMetas[this.setPtr],
-                    //     pts: this.cachedPtss[this.setPtr],
-                    //     alreadyUpdateYUV: !0
-                    // })
+                    this.executeFunction("stream", {
+                        stream: this.cachedStreams[this.setPtr],
+                        width: this.cachedResolution[this.setPtr].width,
+                        height: this.cachedResolution[this.setPtr].height,
+                        pts: this.cachedPtss[this.setPtr]
+                    }),
+                    this.executeFunction("signal", {
+                        signal: this.cachedMetas[this.setPtr],
+                        pts: this.cachedPtss[this.setPtr],
+                        alreadyUpdateYUV: !0
+                    })
                 }
                 else{
                     this.updateDropFrame += 1
                 }
-                // this.decoderWorker.postMessage({
-                //     t: 2,
-                //     frameCnt: this.cachedPtss[this.setPtr],
-                //     buffer: this.cachedStreams[this.setPtr]
-                // }, [this.cachedStreams[this.setPtr].buffer])
+                this.decoderWorker.postMessage({
+                    t: 2,
+                    frameCnt: this.cachedPtss[this.setPtr],
+                    buffer: this.cachedStreams[this.setPtr]
+                }, [this.cachedStreams[this.setPtr].buffer])
             }
             this.getPtr = (this.getPtr + 1) % this.cachedLength
         }
@@ -650,42 +650,42 @@ export default class Workers {
                 frameCnt: this.cachedPtss[e],
                 buffer: this.cachedStreams[e]
             }, [this.cachedStreams[e].buffer]);
-            // const a = Date.now()
-            //   , s = o - n
-            //   , l = a - o;
-            // (s > 33 || l > 10) && defaultLogger.debug("[wwwarning] updateYUV takes ", s, " ms, postMessage takes ", l, " ms for index ", this.cachedPtss[e]),
-            // o - this.lastRenderTs > 84 && this.JankTimes++,
-            // o - this.lastRenderTs > 125 && this.bigJankTimes++,
-            // this.lastRenderTs = o;
-            // const u = o - n;
-            // this.updateYUVCircular.add(u);
-            // const c = this.cachedMetas[e];
-            // if ((r = c == null ? void 0 : c.traceIds) != null && r.length) {
-            //     for (const h of c.traceIds)
-            //         if (this.traceIdMap.has(h)) {
-            //             const f = this.traceIdMap.get(h);
-            //             if (f != null) {
-            //                 f.displayTime = Date.now(),
-            //                 f.status = 3;
-            //                 const d = f.receiveTime - f.startTime
-            //                   , _ = f.readyTime - f.receiveTime
-            //                   , g = f.displayTime - f.readyTime
-            //                   , m = f.displayTime - f.startTime;
-            //                 this.responseTimeArray.push(d),
-            //                 this.processTimeArray.push(_),
-            //                 this.displayTimeArray.push(g),
-            //                 this.overallTimeArray.push(m),
-            //                 this.traceIdMap.delete(h)
-            //             }
-            //         }
-            // }
-            // this.cachedPtss[e] == this.moveStartPts && (this.MoveDisplayDelay = Date.now() - this.StartMovingTs)
-            // if (this.inMovingMode) {
-            //     const h = Date.now()
-            //       , f = h - this.lastMoveDisplayTime;
-            //     this.moveDisplayCircular.add(f),
-            //     this.lastMoveDisplayTime = h
-            // }
+            const a = Date.now()
+              , s = o - n
+              , l = a - o;
+            (s > 33 || l > 10) && defaultLogger.debug("[wwwarning] updateYUV takes ", s, " ms, postMessage takes ", l, " ms for index ", this.cachedPtss[e]),
+            o - this.lastRenderTs > 84 && this.JankTimes++,
+            o - this.lastRenderTs > 125 && this.bigJankTimes++,
+            this.lastRenderTs = o;
+            const u = o - n;
+            this.updateYUVCircular.add(u);
+            const c = this.cachedMetas[e];
+            if ((r = c == null ? void 0 : c.traceIds) != null && r.length) {
+                for (const h of c.traceIds)
+                    if (this.traceIdMap.has(h)) {
+                        const f = this.traceIdMap.get(h);
+                        if (f != null) {
+                            f.displayTime = Date.now(),
+                            f.status = 3;
+                            const d = f.receiveTime - f.startTime
+                              , _ = f.readyTime - f.receiveTime
+                              , g = f.displayTime - f.readyTime
+                              , m = f.displayTime - f.startTime;
+                            this.responseTimeArray.push(d),
+                            this.processTimeArray.push(_),
+                            this.displayTimeArray.push(g),
+                            this.overallTimeArray.push(m),
+                            this.traceIdMap.delete(h)
+                        }
+                    }
+            }
+            this.cachedPtss[e] == this.moveStartPts && (this.MoveDisplayDelay = Date.now() - this.StartMovingTs)
+            if (this.inMovingMode) {
+                const h = Date.now()
+                  , f = h - this.lastMoveDisplayTime;
+                this.moveDisplayCircular.add(f),
+                this.lastMoveDisplayTime = h
+            }
             this.executeFunction("signal", {
                 signal: this.cachedMetas[e],
                 pts: this.cachedPtss[e],

+ 25 - 25
src/XAvatarManager.js

@@ -179,30 +179,30 @@ export default class XAvatarManager {
                 status: a
             });
             this.registerAvatar(u);
-            // if (r == 0)
-            //     this.setMainAvatar(u.id),
-            //     this.addAvatarToScene(u, 0).then(c=>(logger.debug(`[Engine] avatar ${u.id} has been added to scene`),
-            //     c ? (this._updateBillboardStatus(c, BillboardStatus.SHOW),
-            //     setTimeout(()=>{
-            //         this.launchProcessLoadingLoop()
-            //     }
-            //     , this._delayTime),
-            //     s(c)) : (u.removeAvatarFromScene(),
-            //     l(new AvatarAssetLoadingError)))).catch(c=>(u.removeAvatarFromScene(),
-            //     l(new AvatarAssetLoadingError(c))));
-            // else
-            //     return s(u)
+            if (r == 0)
+                this.setMainAvatar(u.id),
+                this.addAvatarToScene(u, 0).then(c=>(logger.debug(`[Engine] avatar ${u.id} has been added to scene`),
+                c ? (this._updateBillboardStatus(c, BillboardStatus.SHOW),
+                setTimeout(()=>{
+                    this.launchProcessLoadingLoop()
+                }
+                , this._delayTime),
+                s(c)) : (u.removeAvatarFromScene(),
+                l(new AvatarAssetLoadingError)))).catch(c=>(u.removeAvatarFromScene(),
+                l(new AvatarAssetLoadingError(c))));
+            else
+                return s(u)
 
-            this.setMainAvatar(u.id),
-            this.addAvatarToScene(u, 0).then(c=>(logger.debug(`[Engine] avatar ${u.id} has been added to scene`),
-            c ? (this._updateBillboardStatus(c, BillboardStatus.SHOW),
-            setTimeout(()=>{
-                this.launchProcessLoadingLoop()
-            }
-            , this._delayTime),
-            s(c)) : (u.removeAvatarFromScene(),
-            l(new AvatarAssetLoadingError)))).catch(c=>(u.removeAvatarFromScene(),
-            l(new AvatarAssetLoadingError(c))));
+            // this.setMainAvatar(u.id),
+            // this.addAvatarToScene(u, 0).then(c=>(logger.debug(`[Engine] avatar ${u.id} has been added to scene`),
+            // c ? (this._updateBillboardStatus(c, BillboardStatus.SHOW),
+            // setTimeout(()=>{
+            //     this.launchProcessLoadingLoop()
+            // }
+            // , this._delayTime),
+            // s(c)) : (u.removeAvatarFromScene(),
+            // l(new AvatarAssetLoadingError)))).catch(c=>(u.removeAvatarFromScene(),
+            // l(new AvatarAssetLoadingError(c))));
         }
         )
     }
@@ -249,8 +249,8 @@ export default class XAvatarManager {
             }
             return calcDistance3D(t, r) * s
         } else
-            return logger.warn("user position or camera position is not correct!"),
-            1e11
+            logger.warn("user position or camera position is not correct!");
+            return 1e11
     }
     _distToCamera(e) {
         var n;

+ 4 - 4
src/main.js

@@ -4,7 +4,7 @@ import Codes from "./enum/Codes.js"
 const xverse = new Xverse({
     env: "DEV",
     appId:"10016",
-    releaseId:'2203120033_29769e'
+    releaseId:'2203181838_1375a0'
 });
 
 const l = async()=>{
@@ -25,7 +25,7 @@ const l = async()=>{
         toast("\u8FDB\u5165\u5931\u8D25, \u8BF7\u91CD\u8BD5");
         return
     }
-
+    let nickname = Math.random().toString(16).slice(2)
     try {
 
         let room = await xverse.joinRoom({
@@ -33,11 +33,11 @@ const l = async()=>{
             skinId: '10089',
             avatarId: 'KGe_Boy',
             roomId: 'e629ef3e-022d-4e64-8654-703bb96410eb',
-            userId: "2f60ea15cbd5a",
+            userId: nickname,
             wsServerUrl: 'wss://uat-eks.xverse.cn/ws',
             appId: "10016",
             token: " ",
-            nickname: "2f60ea15cbd5a",
+            nickname: nickname,
             firends: ["user1"],
             viewMode: "full",
             resolution: {