xushiting 3 年之前
父節點
當前提交
a18ba35dd4
共有 14 個文件被更改,包括 474 次插入425 次删除
  1. 11 11
      src/ActionsHandler.js
  2. 119 100
      src/BaseTable.js
  3. 24 18
      src/BreathPoint.js
  4. 19 19
      src/Broadcast.js
  5. 86 59
      src/Camera.js
  6. 28 19
      src/CircularArray.js
  7. 0 24
      src/Constant.js
  8. 3 2
      src/DataStorage.js
  9. 1 0
      src/Debug.js
  10. 158 149
      src/EngineProxy.js
  11. 2 1
      src/Stats.js
  12. 15 15
      src/XStats.js
  13. 3 4
      src/Xverse_Room.js
  14. 5 4
      src/开发笔记.txt

+ 11 - 11
src/ActionsHandler.js

@@ -127,20 +127,20 @@ export default class ActionsHandler {
             tag: "changeToRotationVideo"
         })
     }
-    requestPanorama(e, t, r) {
-        const {camera: n, player: o, areaName: a, attitude: s, pathName: l, tag: u} = e;
+    requestPanorama(e, noMedia, timeout) {
+        const {camera: camera, player: player, areaName: areaName, attitude: attitude, pathName: pathName, tag: tag} = e;
         return this.transfer({
             renderType: RenderType.ClientRotationPano,
-            player: o,
-            camera: n,
+            player: player,
+            camera: camera,
             person: Person.First,
-            areaName: a,
-            attitude: s,
-            pathName: l,
-            noMedia: t,
-            timeout: r,
-            tag: u || "requestPanorama",
-            special: !t
+            areaName: areaName,
+            attitude: attitude,
+            pathName: pathName,
+            noMedia: noMedia,
+            timeout: timeout,
+            tag: tag || "requestPanorama",
+            special: !noMedia
         })
     }
     setMotionType(e) {

+ 119 - 100
src/BaseTable.js

@@ -2,24 +2,29 @@ import Logger from "./Logger.js"
 
 const logger = new Logger('db')
 export default class BaseTable {
-    constructor(e, t) {
+    constructor(dbName, dbVersion) {
         this.db = null
         this.isCreatingTable = !1
         this.hasCleared = !1
-        this.dbName = e,
-        this.dbVersion = t
+        this.dbName = dbName,
+        this.dbVersion = dbVersion
     }
     async clearDataBase(e) {
-        return this.hasCleared || (e && (this.hasCleared = !0),
-        !window.indexedDB.databases) ? Promise.resolve() : new Promise((t,r)=>{
-            const n = window.indexedDB.deleteDatabase(this.dbName);
-            n.onsuccess = ()=>{
-                t()
+        if(!this.hasCleared){
+            e && (this.hasCleared = !0)
+            if(!window.indexedDB.databases){
+                return Promise.resolve()
+            }   
+            else{
+                return new Promise((resolve,reject)=>{
+                    const dBDeleteRequest = window.indexedDB.deleteDatabase(this.dbName);
+                    dBDeleteRequest.onsuccess = ()=>{
+                        resolve()
+                    },
+                    dBDeleteRequest.onerror = reject
+                })
             }
-            ,
-            n.onerror = r
         }
-        )
     }
     tableName() {
         throw new Error("Derived class have to override 'tableName', and set a proper table name!")
@@ -31,152 +36,166 @@ export default class BaseTable {
         throw new Error("Derived class have to override 'index', and set a proper index name!")
     }
     async checkAndOpenDatabase() {
-        return this.db ? Promise.resolve(this.db) : new Promise((e,t)=>{
-            const n = setTimeout(()=>{
-                logger.info("wait db to open for", 200),
-                this.db ? e(this.db) : e(this.checkAndOpenDatabase()),
-                clearTimeout(n)
-            }
-            , 200);
-            this.openDatabase(this.dbName, this.dbVersion || 1, ()=>{
-                this.db && !this.isCreatingTable && e(this.db),
-                logger.info(`successCallback called, this.db: ${!!this.db}, this.isCreatingStore: ${this.isCreatingTable}`),
-                clearTimeout(n)
-            }
-            , ()=>{
-                t(new Error("Failed to open database!")),
-                clearTimeout(n)
-            }
-            , ()=>{
-                this.db && e(this.db),
-                clearTimeout(n),
-                logger.info(`successCallback called, this.db: ${!!this.db}, this.isCreatingStore: ${this.isCreatingTable}`)
+        if(this.db){
+            return Promise.resolve(this.db)
+        }
+        else{
+            return new Promise((resolve,reject)=>{
+                const timeoutId = setTimeout(()=>{
+                    logger.info("wait db to open for", 200);
+                    if(this.db){
+                        resolve(this.db);
+                    }
+                    else{
+                        resolve(this.checkAndOpenDatabase());
+                    }
+                    clearTimeout(timeoutId)
+                }
+                , 200);
+                this.openDatabase(this.dbName, this.dbVersion || 1, ()=>{
+                    this.db && !this.isCreatingTable && resolve(this.db);
+                    logger.info(`successCallback called, this.db: ${!!this.db}, this.isCreatingStore: ${this.isCreatingTable}`);
+                    clearTimeout(timeoutId);
+                }
+                , ()=>{
+                    reject(new Error("Failed to open database!"));
+                    clearTimeout(timeoutId);
+                }
+                , ()=>{
+                    this.db && resolve(this.db);
+                    clearTimeout(timeoutId);
+                    logger.info(`successCallback called, this.db: ${!!this.db}, this.isCreatingStore: ${this.isCreatingTable}`);
+                }
+                )
             }
             )
         }
-        )
     }
-    openDatabase(e, t, r, n, o) {
+
+    openDatabase(dbName, version, resolve, reject, complete) {
         if (this.isCreatingTable)
+        {
             return;
-        this.isCreatingTable = !0,
-        logger.info(e, t);
-        const a = window.indexedDB.open(e, t)
-          , s = this.tableName();
-        a.onsuccess = l=>{
-            this.db = a.result,
-            logger.info(`IndexedDb ${e} is opened.`),
-            this.db.objectStoreNames.contains(s) && (this.isCreatingTable = !1),
-            r && r(l)
         }
-        ,
-        a.onerror = l=>{
+        this.isCreatingTable = !0;
+        logger.info(dbName, version);
+        const dBOpenRequest = window.indexedDB.open(dbName, version);
+        const tableName = this.tableName();
+        dBOpenRequest.onsuccess = _event=>{
+            this.db = dBOpenRequest.result;
+            logger.info(`IndexedDb ${dbName} is opened.`);
+            this.db.objectStoreNames.contains(tableName) && (this.isCreatingTable = !1);
+            resolve && resolve(_event)
+        };
+        
+        dBOpenRequest.onerror = _event=>{
             var u;
-            logger.error("Failed to open database", (u = l == null ? void 0 : l.srcElement) == null ? void 0 : u.error),
-            this.isCreatingTable = !1,
-            n && n(l),
-            this.clearDataBase(!0)
-        }
-        ,
-        a.onupgradeneeded = l=>{
-            const u = l.target.result
-              , c = this.index();
-            logger.info(`Creating table ${s}.`);
-            let h = u.objectStoreNames.contains(s);
+            logger.error("Failed to open database", (u = _event == null ? void 0 : _event.srcElement) == null ? void 0 : u.error);
+            this.isCreatingTable = !1;
+            reject && reject(_event);
+            this.clearDataBase(!0);
+        };
+        
+        dBOpenRequest.onupgradeneeded = _event=>{
+            const u = _event.target.result;
+            const _index = this.index();
+            logger.info(`Creating table ${tableName}.`);
+            let h = u.objectStoreNames.contains(tableName);
             if (h)
-                h = u.transaction([s], "readwrite").objectStore(s);
+                h = u.transaction([tableName], "readwrite").objectStore(tableName);
             else {
-                const f = this.keyPath();
-                h = u.createObjectStore(s, {
-                    keyPath: f
+                const keyPath = this.keyPath();
+                h = u.createObjectStore(tableName, {
+                    keyPath: keyPath
                 })
             }
-            c.map(f=>{
+
+            _index.map(f=>{
                 h.createIndex(f, f, {
                     unique: !1
                 })
-            }
-            ),
-            this.isCreatingTable = !1,
-            logger.info(`Table ${s} opened`),
-            o && o(l)
-        }
+            });
+
+            this.isCreatingTable = !1;
+            logger.info(`Table ${tableName} opened`);
+            complete && complete(_event);
+        };
     }
     async add(e) {
-        const t = this.tableName()
-          , o = (await this.checkAndOpenDatabase()).transaction([t], "readwrite").objectStore(t).add(e);
-        return new Promise(function(a, s) {
-            o.onsuccess = l=>{
-                a(l)
+        const tableName = this.tableName();
+        const promise = (await this.checkAndOpenDatabase()).transaction([tableName], "readwrite").objectStore(tableName).add(e);
+        return new Promise(function(resolve, reject) {
+            promise.onsuccess = l=>{
+                resolve(l)
             }
             ,
-            o.onerror = l=>{
+            promise.onerror = l=>{
                 var u;
                 logger.error((u = l.srcElement) == null ? void 0 : u.error),
-                s(l)
+                reject(l)
             }
         }
         )
     }
     async put(e) {
-        const t = this.tableName()
-          , o = (await this.checkAndOpenDatabase()).transaction([t], "readwrite").objectStore(t).put(e);
-        return new Promise(function(a, s) {
-            o.onsuccess = l=>{
-                a(l)
+        const tableName = this.tableName();
+        const promise = (await this.checkAndOpenDatabase()).transaction([tableName], "readwrite").objectStore(tableName).put(e);
+        return new Promise(function(resolve, reject) {
+            promise.onsuccess = l=>{
+                resolve(l)
             }
             ,
-            o.onerror = l=>{
+            promise.onerror = l=>{
                 var u;
                 logger.error("db put error", (u = l.srcElement) == null ? void 0 : u.error),
-                s(l)
+                reject(l)
             }
         }
         )
     }
-    delete(e, t, r) {
-        const n = this.tableName();
-        this.checkAndOpenDatabase().then(o=>{
-            const s = o.transaction([n], "readwrite").objectStore(n).delete(e);
-            s.onsuccess = t,
-            s.onerror = r
+    delete(e, resolve, reject) {
+        const tableName = this.tableName();
+        this.checkAndOpenDatabase().then(promise=>{
+            const s = promise.transaction([tableName], "readwrite").objectStore(tableName).delete(e);
+            s.onsuccess = resolve,
+            s.onerror = reject
         }
         )
     }
     update() {
-        this.checkAndOpenDatabase().then(e=>{}
+        this.checkAndOpenDatabase().then(promise=>{}
         )
     }
     async getAllKeys() {
-        const e = this.tableName()
-          , t = await this.checkAndOpenDatabase();
-        return new Promise((r,n)=>{
-            const a = t.transaction([e], "readonly").objectStore(e).getAllKeys();
+        const tableName = this.tableName()
+        const promise = await this.checkAndOpenDatabase();
+        return new Promise((resolve, reject)=>{
+            const a = promise.transaction([tableName], "readonly").objectStore(tableName).getAllKeys();
             a.onsuccess = s=>{
-                r(s.target.result)
+                resolve(s.target.result)
             }
             ,
             a.onerror = s=>{
                 logger.error("db getAllKeys error", s),
-                n(s)
+                reject(s)
             }
         }
         )
     }
-    async query(e, t) {
-        const r = this.tableName()
-          , n = await this.checkAndOpenDatabase();
-        return new Promise((o,a)=>{
-            const u = n.transaction([r], "readonly").objectStore(r).index(e).get(t);
+    async query(keyName, filesrc) {
+        const tableName = this.tableName()
+        const promise = await this.checkAndOpenDatabase();
+        return new Promise((resolve, reject)=>{
+            const u = promise.transaction([tableName], "readonly").objectStore(tableName).index(keyName).get(filesrc);
             u.onsuccess = function(c) {
                 var f;
                 const h = (f = c == null ? void 0 : c.target) == null ? void 0 : f.result;
-                o && o(h)
+                resolve && resolve(h)
             }
             ,
             u.onerror = c=>{
                 logger.error("db query error", c),
-                a(c)
+                reject(c)
             }
         }
         )

+ 24 - 18
src/BreathPoint.js

@@ -1,5 +1,5 @@
 export default class BreathPoint {
-    constructor(e) {
+    constructor(panoInfo) {
         E(this, "_staticmesh");
         E(this, "_id");
         E(this, "_mat");
@@ -8,17 +8,17 @@ export default class BreathPoint {
         E(this, "_skinInfo");
         E(this, "_scene");
         E(this, "_isInScene");
-        const {mesh: t, id: r, position: n, rotation: o, mat: a, type: s="default", maxVisibleRegion: l=-1, scene: u, skinInfo: c="default"} = e;
-        this._id = r,
-        t.mesh.position = ue4Position2Xverse(n),
-        t.mesh.rotation = ue4Rotation2Xverse(o),
-        this._staticmesh = t,
-        this._mat = a,
-        this._type = s,
-        this._maxVisibleRegion = l,
-        this._scene = u,
-        this._skinInfo = c,
-        this._isInScene = !0
+        const {mesh: xStaticMesh, id: id, position: position, rotation: rotation, mat: material, type: type="default", maxVisibleRegion: maxVisibleRegion=-1, scene: scene, skinInfo: skinInfo="default"} = panoInfo;
+        this._id = id;
+        xStaticMesh.mesh.position = ue4Position2Xverse(position);
+        xStaticMesh.mesh.rotation = ue4Rotation2Xverse(rotation);
+        this._staticmesh = xStaticMesh;
+        this._mat = material;
+        this._type = type;
+        this._maxVisibleRegion = maxVisibleRegion;
+        this._scene = scene;
+        this._skinInfo = skinInfo;
+        this._isInScene = !0;
     }
     get isInScene() {
         return this._isInScene
@@ -42,16 +42,22 @@ export default class BreathPoint {
         this._staticmesh.mesh.isPickable = e
     }
     removeFromScene() {
-        this._isInScene && (this._staticmesh.mesh != null && this._scene.removeMesh(this._staticmesh.mesh),
-        this._isInScene = !1)
+        if(this._isInScene){
+            this._staticmesh.mesh != null && this._scene.removeMesh(this._staticmesh.mesh)
+            this._isInScene = !1
+        }
     }
     addToScene() {
-        this._isInScene == !1 && (this._staticmesh.mesh != null && this._scene.addMesh(this._staticmesh.mesh),
-        this._isInScene = !0)
+        if(this._isInScene == !1){
+            this._staticmesh.mesh != null && this._scene.addMesh(this._staticmesh.mesh);
+            this._isInScene = !0
+        }
     }
     dispose() {
-        var e;
-        (e = this._staticmesh.mesh) == null || e.dispose(!1, !1)
+        let mesh = this._staticmesh.mesh
+        if(mesh != null){
+            mesh.dispose(!1, !1)
+        }
     }
     set position(e) {
         this._staticmesh.mesh.position = ue4Position2Xverse(e)

+ 19 - 19
src/Broadcast.js

@@ -4,8 +4,8 @@ import Logger from "./Logger.js"
 const logger = new Logger('xverse-broadcast')
 
 export default class Broadcast{
-    constructor(e, t) {
-        this.room = e;
+    constructor(xverseRoom, t) {
+        this.room = xverseRoom;
         this.handlers = []
         this.init(t)
     }
@@ -14,22 +14,22 @@ export default class Broadcast{
         this.handlers.push(t)
     }
 
-    async handleBroadcast(e) {
-        let t = null;
-        try {
-            t = JSON.parse(e.broadcastAction.data)
-        } catch (r) {
-            logger.error(r);
-            return
-        }
-    }
-    broadcast(e) {
-        const {data: t, msgType: r=MessageHandleType.MHT_FollowListMulticast, targetUserIds: n} = e;
-        return this.room.actionsHandler.broadcast({
-            data: t,
-            msgType: r,
-            targetUserIds: n
-        })
-    }
+    // async handleBroadcast(e) {
+    //     let t = null;
+    //     try {
+    //         t = JSON.parse(e.broadcastAction.data)
+    //     } catch (r) {
+    //         logger.error(r);
+    //         return
+    //     }
+    // }
+    // broadcast(e) {
+    //     const {data: t, msgType: r=MessageHandleType.MHT_FollowListMulticast, targetUserIds: n} = e;
+    //     return this.room.actionsHandler.broadcast({
+    //         data: t,
+    //         msgType: r,
+    //         targetUserIds: n
+    //     })
+    // }
 }
 ;

+ 86 - 59
src/Camera.js

@@ -15,15 +15,20 @@ export default class Camera extends EventEmitter {
         this._room = e
     }
 
+    /*
     checkPointOnLeftOrRight(e){
         const t = ue4Position2Xverse(e);
         if (!t || this.checkPointInView(e))
+        {
             return;
-        const o = this._room.scene.activeCamera;
-        if (!o)
+        }
+        const activeCamera = this._room.scene.activeCamera;
+        if (!activeCamera)
+        {
             return;
-        const a = [o.target.x, o.target.y, o.target.z]
-          , s = [o.position.x, o.position.y, o.position.z]
+        }
+        const a = [activeCamera.target.x, activeCamera.target.y, activeCamera.target.z]
+          , s = [activeCamera.position.x, activeCamera.position.y, activeCamera.position.z]
           , {x: l, y: u, z: c} = t
           , h = calNormVector(s, a)
           , f = calNormVector(s, [l, u, c]);
@@ -62,32 +67,51 @@ export default class Camera extends EventEmitter {
     get cameraFollowing() {
         return this._cameraFollowing
     }
+
     setCameraFollowing({isFollowHost: e}) {}
+    */
+
     handleRenderInfo(e) {
-        const {cameraStateType: t} = e.renderInfo
-          , r = this._room.sceneManager;
-        if (t !== this._state && (this._state = t,
-        logger.debug("camera._state changed to", CameraStates[t]),
-        t === CameraStates.CGView ? (r.cameraComponent.switchToCgCamera(),
-        r.staticmeshComponent.getCgMesh().show()) : (r.cameraComponent.switchToMainCamera(),
-        r.staticmeshComponent.getCgMesh().hide()),
-        this.emit("stateChanged", {
-            state: t
-        })),
-        this._room.isHost)
+        const {cameraStateType: cameraStateType} = e.renderInfo;
+        const sceneManager = this._room.sceneManager;
+
+        if(cameraStateType !== this._state){
+            this._state = cameraStateType;
+            logger.debug("camera._state changed to", CameraStates[cameraStateType]);
+            if(cameraStateType === CameraStates.CGView){
+                sceneManager.cameraComponent.switchToCgCamera();
+                sceneManager.staticmeshComponent.getCgMesh().show();
+            }
+            else{
+                sceneManager.cameraComponent.switchToMainCamera();
+                sceneManager.staticmeshComponent.getCgMesh().hide();
+            }
+
+            this.emit("stateChanged", {
+                state: cameraStateType
+            })
+        }
+        
+        if(this._room.isHost)
+        {
             return;
-        const {isFollowHost: n} = e.playerState;
-        !!n !== this._cameraFollowing && (this._cameraFollowing = !!n,
-        this.emit("cameraFollowingChanged", {
-            cameraFollowing: !!n
-        }))
-    }
-    setCameraState({state: e}) {
-        if (this._state === e) {
-            logger.warn(`You are already in ${CameraStates[e]} camera state`);
+        }
+
+        const {isFollowHost: isFollowHost} = e.playerState;
+        if(!!isFollowHost !== this._cameraFollowing){
+            this._cameraFollowing = !!isFollowHost;
+            this.emit("cameraFollowingChanged", {
+                cameraFollowing: !!isFollowHost
+            })
+        }
+    }
+    /*
+    setCameraState({state: state}) {
+        if (this._state === state) {
+            logger.warn(`You are already in ${CameraStates[state]} camera state`);
             return
         }
-        e === CameraStates.Normal || this._state === CameraStates.ItemView && logger.warn("CloseUp camera state can only be triggerd by room internally")
+        state === CameraStates.Normal || this._state === CameraStates.ItemView && logger.warn("CloseUp camera state can only be triggerd by room internally")
     }
     turnToFace({extra: e="", offset: t=0}) {
         const r = {
@@ -109,38 +133,41 @@ export default class Camera extends EventEmitter {
             return
         }
         if (!this._room._currentClickingState)
-            return logger.error("CurrentState should not be empty"),
-            !1;
-        const {camera: e, player: t} = this._room._currentClickingState;
-        return Math.abs(t.angle.yaw - 180 - e.angle.yaw) % 360 <= 4
-    }
-    async screenShot({name: e, autoSave: t=!1}) {
-        const r = this._room.scene.getEngine()
-          , n = this._room.scene.activeCamera;
+        {
+            logger.error("CurrentState should not be empty");
+            return !1;
+        }
+        const {camera: camera, player: player} = this._room._currentClickingState;
+        return Math.abs(player.angle.yaw - 180 - camera.angle.yaw) % 360 <= 4
+    }
+    
+    async screenShot({name: name, autoSave: autoSave=!1}) {
+        const engine = this._room.scene.getEngine()
+        const activeCamera = this._room.scene.activeCamera;
         try {
             this._room.sceneManager.setImageQuality(EImageQuality.high);
-            const o = await CreateScreenshotAsync(r, n, {
+            const promise = await CreateScreenshotAsync(engine, activeCamera, {
                 precision: 1
             });
-            return this._room.sceneManager.setImageQuality(EImageQuality.low),
-            t === !0 && downloadFileByBase64(o, e),
-            Promise.resolve(o)
-        } catch (o) {
-            return this._room.sceneManager.setImageQuality(EImageQuality.low),
-            Promise.reject(o)
+            this._room.sceneManager.setImageQuality(EImageQuality.low);
+            autoSave === !0 && downloadFileByBase64(promise, name);
+            return Promise.resolve(promise)
+        } catch (error) {
+            this._room.sceneManager.setImageQuality(EImageQuality.low)
+            return Promise.reject(error)
         }
     }
     changeToFirstPerson(e, t, r) {
-        const {camera: n, player: o, attitude: a, areaName: s, pathName: l} = e;
+        const {camera: camera, player: player, attitude: attitude, areaName: areaName, pathName: pathName} = e;
         return this._room.actionsHandler.requestPanorama({
-            camera: n,
-            player: o,
-            attitude: a,
-            areaName: s,
-            pathName: l
+            camera: camera,
+            player: player,
+            attitude: attitude,
+            areaName: areaName,
+            pathName: pathName
         }, t, r).then(()=>{
             this._room.networkController.rtcp.workers.changePanoMode(!0);
-            const {position: u, angle: c} = o || {};
+            const {position: u, angle: c} = player || {};
             this._room.sceneManager.cameraComponent.changeToFirstPersonView({
                 position: u,
                 rotation: c
@@ -152,15 +179,14 @@ export default class Camera extends EventEmitter {
         camera: this._room._currentClickingState.camera,
         player: this._room._currentClickingState.player
     }) {
-        const r = Date.now();
+        const startTime = Date.now();
         return this._setPerson(e, t).then(n=>(logger.infoAndReportMeasurement({
             tag: Person[e],
-            startTime: r,
+            startTime: startTime,
             metric: "setPerson"
-        }),
-        n)).catch(n=>(logger.infoAndReportMeasurement({
+        }),n)).catch(n=>(logger.infoAndReportMeasurement({
             tag: Person[e],
-            startTime: r,
+            startTime: startTime,
             metric: "setPerson",
             error: n
         }),
@@ -194,14 +220,15 @@ export default class Camera extends EventEmitter {
         }
         )
     }
-    setCameraPose(e) {
+    */
+    setCameraPose(cameraPose) {
         this._room.sceneManager.cameraComponent.setCameraPose({
-            position: e.position,
-            rotation: e.angle
+            position: cameraPose.position,
+            rotation: cameraPose.angle
         })
     }
-    setMainCameraRotationLimit(e) {
-        const {limitAxis: t, limitRotation: r} = e;
-        this._room.sceneManager.cameraComponent.setMainCameraRotationLimit(t, r)
-    }
+    // setMainCameraRotationLimit(e) {
+    //     const {limitAxis: t, limitRotation: r} = e;
+    //     this._room.sceneManager.cameraComponent.setMainCameraRotationLimit(t, r)
+    // }
 }

+ 28 - 19
src/CircularArray.js

@@ -32,7 +32,7 @@ function count_less(i, e) {
 }
 
 export default class CircularArray {
-    constructor(e, t, r) {
+    constructor(circularLength, t, lessThreshes) {
         this.sum = 0,
         this.incomingSum = 0,
         this.count = 0,
@@ -46,27 +46,36 @@ export default class CircularArray {
         this.countLess = !1,
         this.lessThreshes = [],
         this.incomingData = [],
-        this.circularData = Array(e).fill(-1),
+        this.circularData = Array(circularLength).fill(-1),
         this.circularPtr = 0,
-        this.circularLength = e,
-        t && (this.countLess = !0,
-        this.lessThreshes = r)
+        this.circularLength = circularLength,
+        t && (this.countLess = !0,this.lessThreshes = lessThreshes)
     }
     add(e) {
-        this.circularData[this.circularPtr] != -1 ? (this.sum -= this.circularData[this.circularPtr],
-        Math.abs(this.circularData[this.circularPtr] - this.max) < .01 && (this.circularData[this.circularPtr] = -1,
-        this.max = this.getMax(!1))) : this.count += 1,
-        this.sum += e,
-        this.incomingSum += e,
-        this.incomingCount += 1,
-        this.max < e && (this.max = e),
-        this.incomingMax < e && (this.incomingMax = e),
-        this.circularData[this.circularPtr] = e,
-        this.circularPtr = (this.circularPtr + 1) % this.circularLength,
-        this.incomingData.push(e),
-        this.incomingData.length > this.circularLength && (this.clearIncoming(),
-        this.incomingCount = 0,
-        this.incomingSum = 0)
+        if(this.circularData[this.circularPtr] != -1){
+            this.sum -= this.circularData[this.circularPtr]
+            if(Math.abs(this.circularData[this.circularPtr] - this.max) < .01) {
+                this.circularData[this.circularPtr] = -1
+                this.max = this.getMax(!1)
+            }
+        }
+        else{
+            this.count += 1
+        }
+
+        this.sum += e;
+        this.incomingSum += e;
+        this.incomingCount += 1;
+        this.max < e && (this.max = e);
+        this.incomingMax < e && (this.incomingMax = e);
+        this.circularData[this.circularPtr] = e;
+        this.circularPtr = (this.circularPtr + 1) % this.circularLength;
+        this.incomingData.push(e);
+        if(this.incomingData.length > this.circularLength){
+            this.clearIncoming();
+            this.incomingCount = 0;
+            this.incomingSum = 0;
+        }
     }
     computeAvg(e) {
         return e.reduce(add, 0) / e.reduce(count_valid, 0) || 0

+ 0 - 24
src/Constant.js

@@ -1,24 +0,0 @@
-const SERVER_URLS = {
-    DEV: "wss://sit-eks.xverse.cn/ws",
-    PROD: "wss://eks.xverse.cn/ws"
-}
-  , REPORT_URL = {
-    DEV: "https://xa.xverse.cn:6680/collect",
-    PROD: "https://xa.xverse.cn/collect"
-}
-  , MAX_RECONNECT_COUNT = 3
-  , DEFAULT_JOINROOM_TIMEOUT = 15e3
-  , DEFAULT_MAIN_CAMERA_FOV = 50
-  , DEFAULT_AVATAR_SCALE = 1
-  , REPORT_NUM_PER_REQUEST = 20
-  , DEFAULT_OPEN_TIMEOUT_MS = 6e3
-  , WS_CLOSE_NORMAL = 1e3
-  , WS_CLOSE_RECONNECT = 3008
-  , PING_INTERVAL_MS = 1e3
-  , TEXTURE_URL = "https://static.xverse.cn/qqktv/texture.png"
-  , REPORT_MODULE_TYPE = "xverse-js"
-  , authenticationErrorCodes = [3001, 3002, 3003, 3005]
-  , RTT_MAX_VALUE = 200
-  , HB_MAX_VALUE = 500
-  , DURATION = 10
-  , NET_INTERVAL = 1;

+ 3 - 2
src/DataStorage.js

@@ -1,3 +1,4 @@
+/*
 class DataStorage{
     static _GetStorage() {
         try {
@@ -39,5 +40,5 @@ class DataStorage{
     static WriteNumber(e, t) {
         this._Storage.setItem(e, t.toString())
     }
-}
-;
+};
+*/

+ 1 - 0
src/Debug.js

@@ -1,6 +1,7 @@
 const BREATH_POINT_TYPE = "debugBreathPoint"
   , TAP_BREATH_POINT_TYPE = "debugTapBreathPoint"
   , DEFAULT_SEARCH_RANGE = 1e3;
+  
 export default class Debug {
     constructor(e) {
         E(this, "isShowNearbyBreathPoints", !1);

+ 158 - 149
src/EngineProxy.js

@@ -13,16 +13,16 @@ import Logger from "./Logger.js"
 
 const logger = new Logger('xverse-bus')
 const http = new Http
-  , blobToDataURI = async i=>new Promise((e,t)=>{
-    const r = new FileReader;
-    r.readAsDataURL(i),
-    r.onload = function(n) {
+const blobToDataURI = async i=>new Promise((resolve,reject)=>{
+    const fileReader = new FileReader;
+    fileReader.readAsDataURL(i),
+    fileReader.onload = function(n) {
         var o;
-        e((o = n.target) == null ? void 0 : o.result)
+        resolve((o = n.target) == null ? void 0 : o.result)
     }
     ,
-    r.onerror = function(n) {
-        t(n)
+    fileReader.onerror = function(n) {
+        reject(n)
     }
 }
 )
@@ -48,7 +48,7 @@ function getSceneManager(i, e) {
 }
 
 export default class EngineProxy{
-    constructor(e) {
+    constructor(xverseRoom) {
         E(this, "_tvs", []);
         E(this, "isRenderFirstFrame", !1);
         E(this, "_idleTime", 0);
@@ -74,10 +74,10 @@ export default class EngineProxy{
         E(this, "engineSloppyCnt", 0);
         E(this, "systemStuckCnt", 0);
         E(this, "frameRenderNumber", 0);
-        E(this, "_setFPS", (e,t=25)=>{
+        E(this, "_setFPS", (sceneManager,t=25)=>{
             logger.info("Set fps to", t);
             const r = t > 60 ? 60 : t < 24 ? 24 : t;
-            e.Engine.stopRenderLoop();
+            sceneManager.Engine.stopRenderLoop();
             const n = 1e3 / r;
             let o = Date.now()
               , a = Date.now()
@@ -97,8 +97,9 @@ export default class EngineProxy{
                 let g = 0
                   , m = 0;
                 if (this.room.isUpdatedRawYUVData || this.room.isPano) {
-                    if (this.isRenderFirstFrame = !0,
-                    this._checkSceneDurationFrameNum > 0)
+                    this.isRenderFirstFrame = !0
+                    if (this._checkSceneDurationFrameNum > 0)
+                    {
                         this._checkSceneFrameCount++,
                         this.room.sceneManager.isReadyToRender({}) && this._checkSceneDurationFrameNum--,
                         this._checkSceneFrameCount > EngineProxy._CHECK_DURATION && (this._checkSceneDurationFrameNum = EngineProxy._CHECK_DURATION,
@@ -121,10 +122,13 @@ export default class EngineProxy{
                                 sampleRate: .1
                             }
                         }));
+                    }
                     else
+                    {
                         try {
-                            e.render()
-                        } catch (C) {
+                            sceneManager.render()
+                        } 
+                        catch (C) {
                             this.renderErrorCount++,
                             this.renderErrorCount > 10 && this.room.proxyEvents("renderError", {
                                 error: C
@@ -142,6 +146,7 @@ export default class EngineProxy{
                                 }
                             })
                         }
+                    }
                     g = Date.now() - _,
                     this.frameRenderNumber < 1e3 && this.frameRenderNumber++,
                     this.room.networkController.rtcp.workers.UpdateYUV(),
@@ -174,8 +179,8 @@ export default class EngineProxy{
             }
             ;
             this.renderTimer = window.setTimeout(u, n / l)
-        }
-        );
+        });
+
         E(this, "updateStats", ()=>{
             var e;
             (e = this.room.stats) == null || e.assign({
@@ -206,13 +211,12 @@ export default class EngineProxy{
             })
         }
         );
-        this.room = e
+        this.room = xverseRoom
     }
     async initEngine(e) {
-        await this.updateBillboard(),
+        await this.updateBillboard();
         logger.info("engine version:", VERSION$1);
-        const t = logger;
-        t.setLevel(LoggerLevels.Warn);
+        logger.setLevel(LoggerLevels.Warn);
         const r = {
             videoResOriArray: [{
                 width: 720,
@@ -252,23 +256,23 @@ export default class EngineProxy{
                 maxZ: 1e4
             },
             urlTransformer,
-            logger: t,
+            logger: logger,
             disableWebGL2: this.room.options.disableWebGL2 || !1
-        }
-          , n = this.room.options.resolution;
-        n && (r.videoResOriArray.some(l=>l.width === n.width && l.height === n.height) || r.videoResOriArray.push(n));
-        const o = this.room.sceneManager = getSceneManager(this.room.canvas, r);
-        this.room.setPictureQualityLevel(this.room.options.pictureQualityLevel || "high"),
-        this.room.sceneManager.staticmeshComponent.setRegionLodRule([2, 2, -1, -1, -1]),
-        this.room.scene = o.Scene,
-        this.room.breathPointManager = o.breathPointComponent,
-        this.lightManager = o.lightComponent,
-        this.registerStats(),
-        this.setEnv(e),
+        };
+        const resolution = this.room.options.resolution;
+        resolution && (r.videoResOriArray.some(l=>l.width === resolution.width && l.height === resolution.height) || r.videoResOriArray.push(resolution));
+        const sceneManager = this.room.sceneManager = getSceneManager(this.room.canvas, r);
+        this.room.setPictureQualityLevel(this.room.options.pictureQualityLevel || "high");
+        this.room.sceneManager.staticmeshComponent.setRegionLodRule([2, 2, -1, -1, -1]);
+        this.room.scene = sceneManager.Scene;
+        this.room.breathPointManager = sceneManager.breathPointComponent;
+        this.lightManager = sceneManager.lightComponent;
+        this.registerStats();
+        this.setEnv(e);
         await this.room.avatarManager.init();
         const a = this._createAssetList(e);
-        await this.loadAssets(a, ""),
-        this._setFPS(o)
+        await this.loadAssets(a, "");
+        this._setFPS(sceneManager);
     }
     pause() {
         clearTimeout(this.renderTimer),
@@ -362,44 +366,44 @@ export default class EngineProxy{
         return this.loadAssets(e, this.room.skinId).catch(()=>this.loadAssets(e, this.room.skinId))
     }
     async loadAssets(e, t="", r=8e3) {
-        const n = Date.now();
+        const startTime = Date.now();
         return this._loadAssets(e, t)._timeout(r, new InitEngineTimeoutError(`loadAssets timeout(${r}ms)`)).then(o=>(logger.infoAndReportMeasurement({
             tag: "loadAssets",
-            startTime: n,
+            startTime: startTime,
             metric: "loadAssets"
-        }),
-        o)).catch(o=>(logger.infoAndReportMeasurement({
+        }),o)).catch(err=>(logger.infoAndReportMeasurement({
             tag: "loadAssets",
-            startTime: n,
+            startTime: startTime,
             metric: "loadAssets",
-            error: o
+            error: err
         }),
-        Promise.reject(o)))
+        Promise.reject(err)))
     }
     async _loadAssets(e, t="") {
         try {
             const r = [];
-            r.push(this._loadAssetsLowpolyModel(e, t)),
-            await Promise.all(r),
-            await this.setEnv(),
-            this._checkSceneDurationFrameNum = EngineProxy._CHECK_DURATION,
-            this._checkSceneNotReadyCount = 0,
-            this._checkSceneFrameCount = 0,
-            this.updateAnimationList(),
-            this.room.loadAssetsHook()
+            r.push(this._loadAssetsLowpolyModel(e, t));
+            await Promise.all(r);
+            await this.setEnv();
+            this._checkSceneDurationFrameNum = EngineProxy._CHECK_DURATION;
+            this._checkSceneNotReadyCount = 0;
+            this._checkSceneFrameCount = 0;
+            this.updateAnimationList();
+            this.room.loadAssetsHook();
         } catch (r) {
             return Promise.reject(r)
         }
     }
     updateAnimationList() {
         if (this.room.avatarManager && this.room.avatarManager.xAvatarManager) {
-            const e = this.room.skin.animationList;
-            if (!e)
+            const animationList = this.room.skin.animationList;
+            if (!animationList)
+            {
                 return;
-            e.forEach(t=>{
-                this.room.avatarManager.xAvatarManager.updateAnimationLists(t.animations, t.avatarId)
             }
-            )
+            animationList.forEach(t=>{
+                this.room.avatarManager.xAvatarManager.updateAnimationLists(t.animations, t.avatarId)
+            })
         }
     }
     async _loadAssetsLowpolyModel(e, t="") {
@@ -429,46 +433,46 @@ export default class EngineProxy{
                 className: AssetClassName.Lpm,
                 modelUrl: f.url
             })
-        }
-        ),
+        });
+
         t != "" && t != null && this._deleteAssetsLowpolyModel(t);
-        const a = e.skinId;
-        logger.info("====> from ", t, "  to  ", a),
+        const skinId = e.skinId;
+        logger.info("====> from ", t, "  to  ", skinId),
         this._tvs.forEach(f=>f.clean()),
         this._tvs = [];
         let s = EFitMode.cover;
-        a == "10048" && (s = EFitMode.contain),
+        skinId == "10048" && (s = EFitMode.contain)
         Array.isArray(n) && n.forEach((f,d)=>{
             this._tvs.push(new TV("squareTv" + d,f.modelUrl,this.room,{
                 fitMode: s
             }))
         }
         ),
-        e.breathPointsConfig.forEach(async f=>{
+        e.breathPointsConfig.forEach(async breathPoint=>{
             let d;
             try {
-                d = await urlTransformer(f.imageUrl)
+                d = await urlTransformer(breathPoint.imageUrl)
             } catch (_) {
-                d = f.imageUrl,
+                d = breathPoint.imageUrl,
                 logger.error("urlTransformer error", _)
             }
             this.room.breathPointManager.addBreathPoint({
-                id: f.id,
-                position: f.position,
+                id: breathPoint.id,
+                position: breathPoint.position,
                 spriteSheet: d,
-                rotation: f.rotation || {
+                rotation: breathPoint.rotation || {
                     pitch: 0,
                     yaw: 270,
                     roll: 0
                 },
                 billboardMode: !0,
-                type: f.type || "no_type",
-                spriteWidthNumber: f.spriteWidthNum || 1,
-                spriteHeightNumber: f.spriteHeightNum || 1,
-                maxVisibleRegion: f.maxVisibleRegion || 150,
-                width: f.width,
-                height: f.height,
-                skinInfo: f.skinId
+                type: breathPoint.type || "no_type",
+                spriteWidthNumber: breathPoint.spriteWidthNum || 1,
+                spriteHeightNumber: breathPoint.spriteHeightNum || 1,
+                maxVisibleRegion: breathPoint.maxVisibleRegion || 150,
+                width: breathPoint.width,
+                height: breathPoint.height,
+                skinInfo: breathPoint.skinId
             })
         }
         ),
@@ -476,7 +480,7 @@ export default class EngineProxy{
             this.room.sceneManager.decalComponent.addDecal({
                 id: f.id || "gbq",
                 meshPath: f.modelUrl,
-                skinInfo: a
+                skinInfo: skinId
             })
         }
         );
@@ -484,7 +488,7 @@ export default class EngineProxy{
           , c = Array.from(u.keys()).filter(f=>!f.startsWith("region_"))
           , h = ["airship", "balloon", "ground_feiting", "ground_reqiqiu", "default"];
         return new Promise((f,d)=>{
-            Promise.all(h.map(_=>this._parseModelsAndLoad(r, _, a))).then(()=>{
+            Promise.all(h.map(_=>this._parseModelsAndLoad(r, _, skinId))).then(()=>{
                 let _ = !1;
                 r.forEach(v=>{
                     v.modelUrl.endsWith("zip") && (_ = !0)
@@ -577,87 +581,92 @@ export default class EngineProxy{
             skinId: e.id
         }
     }
+    //sceneManager.statisticComponent是XStats对象
     registerStats() {
-        const e = this.room.sceneManager;
+        const sceneManager = this.room.sceneManager;
         this.room.scene.registerAfterRender(()=>{
-            var I;
-            const t = e.statisticComponent.getInterFrameTimeCounter()
-              , r = e.statisticComponent.getDrawCall()
-              , n = e.statisticComponent.getActiveFaces()
-              , o = e.statisticComponent.getFrameTimeCounter()
-              , a = e.statisticComponent.getDrawCallTime()
-              , s = e.statisticComponent.getAnimationTime()
-              , l = e.statisticComponent.getActiveMeshEvaluationTime()
-              , u = e.statisticComponent.getRenderTargetRenderTime()
-              , c = e.statisticComponent.getRegisterBeforeRenderTime()
-              , h = e.statisticComponent.getRegisterAfterRenderTime()
-              , f = e.statisticComponent.getActiveParticles()
-              , d = e.statisticComponent.getActiveBones()
-              , _ = e.Scene._activeAnimatables.length
-              , g = e.statisticComponent.getTotalRootNodes()
-              , m = e.Scene.geometries.length
-              , v = e.Scene.onBeforeRenderObservable.observers.length
-              , y = e.Scene.onAfterRenderObservable.observers.length
-              , b = e.statisticComponent.getTotalMeshes()
-              , T = e.statisticComponent.getTotalTextures()
-              , C = e.statisticComponent.getTotalMaterials()
-              , A = e.statisticComponent.getSystemInfo()
-              , S = A.resolution
-              , P = A.driver;
-            A.vender;
-            const R = A.version
-              , M = A.hardwareScalingLevel
-              , x = S + "_" + P + "_" + R + "_" + M;
-            this.interFrameCircularArray.add(t),
-            this.renderTimeCircularArray.add(o),
-            this.animationCircularArray.add(s),
-            this.meshSelectCircularArray.add(l),
-            this.drawCallTimeCircularArray.add(a),
-            this.regAfterRenderCircularArray.add(h),
-            this.regBeforeRenderCircularArray.add(c),
-            this.renderTargetCircularArray.add(u),
-            this.drawCallCntCircularArray.add(r),
-            this.renderCnt += 1,
-            this.renderCnt % 25 == 0 && ((I = this.room.stats) == null || I.assign({
-                renderFrameTime: this.renderTimeCircularArray.getAvg(),
-                maxRenderFrameTime: this.renderTimeCircularArray.getMax(),
-                interFrameTime: this.interFrameCircularArray.getAvg(),
-                animationTime: this.animationCircularArray.getAvg(),
-                meshSelectTime: this.meshSelectCircularArray.getAvg(),
-                drawcallTime: this.drawCallTimeCircularArray.getAvg(),
-                idleTime: this._idleTime,
-                registerBeforeRenderTime: this.regBeforeRenderCircularArray.getAvg(),
-                registerAfterRenderTime: this.regAfterRenderCircularArray.getAvg(),
-                renderTargetRenderTime: this.renderTargetCircularArray.getAvg(),
-                fps: (1e3 / (this.renderTimeCircularArray.getAvg() + this.interFrameCircularArray.getAvg())).toFixed(2),
-                drawcall: this.drawCallCntCircularArray.getAvg(),
-                triangle: n.toString(),
-                engineSloppyCnt: this.engineSloppyCnt,
-                maxInterFrameTime: this.interFrameCircularArray.getMax(),
-                maxDrawcallTime: this.drawCallTimeCircularArray.getMax(),
-                maxMeshSelectTime: this.meshSelectCircularArray.getMax(),
-                maxAnimationTime: this.animationCircularArray.getMax(),
-                maxRegisterBeforeRenderTime: this.regBeforeRenderCircularArray.getMax(),
-                maxRegisterAfterRenderTime: this.regAfterRenderCircularArray.getMax(),
-                maxRenderTargetRenderTime: this.renderTargetCircularArray.getMax(),
-                activeParticles: f,
-                activeBones: d,
-                activeAnimation: _,
-                totalMeshes: b,
-                totalRootNodes: g,
-                totalGeometries: m,
-                totalTextures: T,
-                totalMaterials: C,
-                registerBeforeCount: v,
-                registerAfterCount: y,
-                hardwareInfo: x
-            }))
+            const interFrameTimeCounterCurrent = sceneManager.statisticComponent.getInterFrameTimeCounter()
+            const drawCallsCounterCurrent = sceneManager.statisticComponent.getDrawCall()
+            const activeTriangle = sceneManager.statisticComponent.getActiveFaces()
+            const frameTimeCounterCurrent = sceneManager.statisticComponent.getFrameTimeCounter()
+            const renderTimeCounterCurrent = sceneManager.statisticComponent.getDrawCallTime()
+            const animationsTimeCounterCurrent = sceneManager.statisticComponent.getAnimationTime()
+            const activeMeshesEvaluationTimeCounterCurrent = sceneManager.statisticComponent.getActiveMeshEvaluationTime()
+            const renderTargetRenderTime = sceneManager.statisticComponent.getRenderTargetRenderTime()
+            const registerBeforeTimeCounterCurrent = sceneManager.statisticComponent.getRegisterBeforeRenderTime()
+            const registerAfterTimeCounterCurrent = sceneManager.statisticComponent.getRegisterAfterRenderTime()
+            const _activeParticlesCurrent = sceneManager.statisticComponent.getActiveParticles()
+            const _activeBonesCurrent = sceneManager.statisticComponent.getActiveBones()
+            const activeAnimatablesLength = sceneManager.Scene._activeAnimatables.length
+            const rootNodesLength = sceneManager.statisticComponent.getTotalRootNodes()
+            const geometriesLength = sceneManager.Scene.geometries.length
+            const beforeRenderObservableLength = sceneManager.Scene.onBeforeRenderObservable.observers.length
+            const afterRenderObservableLength = sceneManager.Scene.onAfterRenderObservable.observers.length
+            const meshesLength = sceneManager.statisticComponent.getTotalMeshes()
+            const texturesLength = sceneManager.statisticComponent.getTotalTextures()
+            const materialsLength = sceneManager.statisticComponent.getTotalMaterials()
+            const systemInfo = sceneManager.statisticComponent.getSystemInfo()
+            const resolution = systemInfo.resolution
+            const driver = systemInfo.driver;
+            systemInfo.vender;
+            const version = systemInfo.version
+            const hardwareScalingLevel = systemInfo.hardwareScalingLevel
+            const hardwareInfo = resolution + "_" + driver + "_" + version + "_" + hardwareScalingLevel;
+            this.interFrameCircularArray.add(interFrameTimeCounterCurrent);
+            this.renderTimeCircularArray.add(frameTimeCounterCurrent);
+            this.animationCircularArray.add(animationsTimeCounterCurrent);
+            this.meshSelectCircularArray.add(activeMeshesEvaluationTimeCounterCurrent);
+            this.drawCallTimeCircularArray.add(renderTimeCounterCurrent);
+            this.regAfterRenderCircularArray.add(registerAfterTimeCounterCurrent);
+            this.regBeforeRenderCircularArray.add(registerBeforeTimeCounterCurrent);
+            this.renderTargetCircularArray.add(renderTargetRenderTime);
+            this.drawCallCntCircularArray.add(drawCallsCounterCurrent);
+            this.renderCnt += 1;
+            if(this.renderCnt % 25 == 0){
+                let stats = this.room.stats
+                if(stats != null){
+                    stats.assign({
+                        renderFrameTime: this.renderTimeCircularArray.getAvg(),
+                        maxRenderFrameTime: this.renderTimeCircularArray.getMax(),
+                        interFrameTime: this.interFrameCircularArray.getAvg(),
+                        animationTime: this.animationCircularArray.getAvg(),
+                        meshSelectTime: this.meshSelectCircularArray.getAvg(),
+                        drawcallTime: this.drawCallTimeCircularArray.getAvg(),
+                        idleTime: this._idleTime,
+                        registerBeforeRenderTime: this.regBeforeRenderCircularArray.getAvg(),
+                        registerAfterRenderTime: this.regAfterRenderCircularArray.getAvg(),
+                        renderTargetRenderTime: this.renderTargetCircularArray.getAvg(),
+                        fps: (1e3 / (this.renderTimeCircularArray.getAvg() + this.interFrameCircularArray.getAvg())).toFixed(2),
+                        drawcall: this.drawCallCntCircularArray.getAvg(),
+                        triangle: activeTriangle.toString(),
+                        engineSloppyCnt: this.engineSloppyCnt,
+                        maxInterFrameTime: this.interFrameCircularArray.getMax(),
+                        maxDrawcallTime: this.drawCallTimeCircularArray.getMax(),
+                        maxMeshSelectTime: this.meshSelectCircularArray.getMax(),
+                        maxAnimationTime: this.animationCircularArray.getMax(),
+                        maxRegisterBeforeRenderTime: this.regBeforeRenderCircularArray.getMax(),
+                        maxRegisterAfterRenderTime: this.regAfterRenderCircularArray.getMax(),
+                        maxRenderTargetRenderTime: this.renderTargetCircularArray.getMax(),
+                        activeParticles: _activeParticlesCurrent,
+                        activeBones: _activeBonesCurrent,
+                        activeAnimation: activeAnimatablesLength,
+                        totalMeshes: meshesLength,
+                        totalRootNodes: rootNodesLength,
+                        totalGeometries: geometriesLength,
+                        totalTextures: texturesLength,
+                        totalMaterials: materialsLength,
+                        registerBeforeCount: beforeRenderObservableLength,
+                        registerAfterCount: afterRenderObservableLength,
+                        hardwareInfo: hardwareInfo
+                    })
+                }
+            }
         }
         )
     }
     async updateBillboard() {
-        const {options: {skinId: e}} = this.room
-          , r = (await this.room.modelManager.findAssetList(e)).filter(a=>a.typeName === AssetTypeName.Textures && a.className === AssetClassName.SayBubble)
+        const {options: {skinId: skinId}} = this.room
+          , r = (await this.room.modelManager.findAssetList(skinId)).filter(a=>a.typeName === AssetTypeName.Textures && a.className === AssetClassName.SayBubble)
           , n = ["bubble01", "bubble02", "bubble03"]
           , o = ["bubble01_npc", "bubble02_npc", "bubble03_npc"];
         if (r.length) {

+ 2 - 1
src/Stats.js

@@ -1,5 +1,6 @@
 
 import Logger from "./Logger.js"
+import Xverse from "./Xverse.js"
 
 const logger = new Logger('stats')
 const numberFormat = new Intl.NumberFormat(window.navigator.language,{
@@ -167,7 +168,7 @@ export default class Stats extends EventEmitter {
             value: "FPS: " + this._extraStats.fps + " avatar: " + ((c = this.room._userAvatar) == null ? void 0 : c.state)
         }),
         e.push({
-            key: "SDK: " + Xverse$1.SUB_PACKAGE_VERSION,
+            key: "SDK: " + Xverse.SUB_PACKAGE_VERSION,
             value: "ENGINE:" + VERSION$1 + " uid:" + this._extraStats.userId
         }),
         e.push({

+ 15 - 15
src/XStats.js

@@ -14,21 +14,21 @@ export default class XStats {
         this.initSceneInstrument()
     }
     initSceneInstrument() {
-        this.sceneInstrumentation = new BABYLON.SceneInstrumentation(this.scene),
-        this.sceneInstrumentation.captureCameraRenderTime = !0,
-        this.sceneInstrumentation.captureActiveMeshesEvaluationTime = !0,
-        this.sceneInstrumentation.captureRenderTargetsRenderTime = !0,
-        this.sceneInstrumentation.captureFrameTime = !0,
-        this.sceneInstrumentation.captureRenderTime = !0,
-        this.sceneInstrumentation.captureInterFrameTime = !0,
-        this.sceneInstrumentation.captureParticlesRenderTime = !0,
-        this.sceneInstrumentation.captureSpritesRenderTime = !0,
-        this.sceneInstrumentation.capturePhysicsTime = !0,
-        this.sceneInstrumentation.captureAnimationsTime = !0,
-        this.engineInstrumentation = new BABYLON.EngineInstrumentation(this.scene.getEngine()),
-        this.caps = this.scene.getEngine().getCaps(),
-        this.engine = this.scene.getEngine(),
-        this._osversion = this.osVersion()
+        this.sceneInstrumentation = new BABYLON.SceneInstrumentation(this.scene);
+        this.sceneInstrumentation.captureCameraRenderTime = !0;
+        this.sceneInstrumentation.captureActiveMeshesEvaluationTime = !0;
+        this.sceneInstrumentation.captureRenderTargetsRenderTime = !0;
+        this.sceneInstrumentation.captureFrameTime = !0;
+        this.sceneInstrumentation.captureRenderTime = !0;
+        this.sceneInstrumentation.captureInterFrameTime = !0;
+        this.sceneInstrumentation.captureParticlesRenderTime = !0;
+        this.sceneInstrumentation.captureSpritesRenderTime = !0;
+        this.sceneInstrumentation.capturePhysicsTime = !0;
+        this.sceneInstrumentation.captureAnimationsTime = !0;
+        this.engineInstrumentation = new BABYLON.EngineInstrumentation(this.scene.getEngine());
+        this.caps = this.scene.getEngine().getCaps();
+        this.engine = this.scene.getEngine();
+        this._osversion = this.osVersion();
     }
     getFrameTimeCounter() {
         return this.sceneInstrumentation.frameTimeCounter.current

+ 3 - 4
src/Xverse_Room.js

@@ -520,13 +520,12 @@ export default class Xverse_Room extends EventEmitter {
         }),
         this.sceneManager.setImageQuality(t[e])
     }
-    async getSkin(e) {
-        let t = null;
-        t = (this.skinList = await this.modelManager.getSkinsList()).find(n=>n.id === e || n.id === e)
+    async getSkin(skinId) {
+        let t = (this.skinList = await this.modelManager.getSkinsList()).find(skin=>skin.id === skinId || skin.id === skinId)
         if (t)
             return t;
         {
-            const n = `skin is invalid: skinId: ${e}`;
+            const n = `skin is invalid: skinId: ${skinId}`;
             return Promise.reject(new ParamError(n))
         }
     }

+ 5 - 4
src/开发笔记.txt

@@ -1,5 +1,5 @@
-1. Logger不能用单例模式,里面的module对应的是类的名称
-2. BABYLON源码修改:
+1. Logger涓嶈兘鐢ㄥ崟渚嬫ā寮忥紝閲岄潰鐨刴odule瀵瑰簲鐨勬槸绫荤殑鍚嶇О
+2. BABYLON源码修改:
 
           this._onBeforeRegisterBeforeRenderObserver = null,
                 this._onAfterRegisterBeforeRenderObserver = null,
@@ -119,8 +119,9 @@
 		
 		
 /***************************************************************************************************************************************************************************************/
-
-
+3. Broadcast绫伙紝 constructor(xverseRoom, t) 涓�弬鏁皌鐨勬剰鎬濓紵
+4. 瀵规柟缃戦〉绔�彲浠ュ綍鍒惰�棰戯紝鐩存帴閲囩敤浜嗚吘璁�簯oss鐨剆dk锛岀洿鎺ヤ笂浼犮€備唬鐮佸湪杩欎竴鍧楋細COS$1 = function(i)
+5. EngineProxy里,skinId如果是10048