zhouenguang 3 éve
szülő
commit
6b8c7ac8bb
6 módosított fájl, 412 hozzáadás és 431 törlés
  1. 1 1
      dist/index.html
  2. 25 22
      src/Stats.js
  3. 55 66
      src/XStaticMesh.js
  4. 261 281
      src/XStaticMeshComponent.js
  5. 62 61
      src/XStaticMeshFromOneGltf.js
  6. 8 0
      src/Xverse_Room.js

+ 1 - 1
dist/index.html

@@ -758,7 +758,7 @@
                     : (b = room.stats) == null || b.show();
         }
         document.querySelector('.debugger2').onclick = ()=>{
-            room.debug.toggleSceneshading(), r(room.debug.isSceneShading);
+            room.debug.toggleSceneshading() //, r(room.debug.isSceneShading);
         }
         document.querySelector('.debugger3').onclick = ()=>{
             let y = "average";

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 25 - 22
src/Stats.js


+ 55 - 66
src/XStaticMesh.js

@@ -12,72 +12,6 @@ export default class XStaticMesh {
         E(this, "_isRotating", !1);
         E(this, "_isVisible", !0);
         E(this, "_skinInfo");
-        E(this, "setVisibility", (e,t)=>{
-            Array.isArray(e) ? e.forEach(r=>{
-                this.setVisibility(r, t)
-            }
-            ) : e.isAnInstance || (e.visibility = t)
-        }
-        );
-        E(this, "setPickable", (e,t)=>{
-            Array.isArray(e) ? e.forEach(r=>{
-                this.setPickable(r, t)
-            }
-            ) : ("isPickable"in e && (e.isPickable = t),
-            e.setEnabled(t))
-        }
-        );
-        E(this, "hide", ()=>{
-            var e;
-            this._isVisible = !1,
-            this.mesh && this.setVisibility(this.mesh, 0),
-            this.mesh && this.setPickable(this.mesh, !1),
-            (e = this.mesh) == null || e.getChildMeshes().forEach(t=>{
-                this.setVisibility(t, 0),
-                this.setPickable(t, !1)
-            }
-            )
-        }
-        );
-        E(this, "show", ()=>{
-            var e;
-            this._isVisible = !0,
-            this.mesh && this.setVisibility(this.mesh, 1),
-            this.mesh && this.setPickable(this.mesh, !0),
-            (e = this.mesh) == null || e.getChildMeshes().forEach(t=>{
-                this.setVisibility(t, 1),
-                this.setPickable(t, !0)
-            }
-            )
-        }
-        );
-        E(this, "attachToAvatar", (e,t={
-            x: 0,
-            y: .5,
-            z: 0
-        },r={
-            yaw: 0,
-            pitch: 0,
-            roll: 0
-        },n={
-            x: .35,
-            y: .35,
-            z: .35
-        })=>{
-            const o = ue4Scaling2Xverse(n)
-              , a = ue4Rotation2Xverse(r)
-              , s = ue4Position2Xverse(t)
-              , l = this._mesh;
-            e && l ? (e.setParent(l),
-            e.position = s,
-            e.rotation = a,
-            e.scaling = o) : logger.error("[Engine] avatar or attachment not found!")
-        }
-        );
-        E(this, "detachFromAvatar", (e,t=!1)=>{
-            this._mesh && e ? this._mesh.removeChild(e) : logger.error("[Engine] avatar not found!")
-        }
-        );
         this._id = e,
         this._mesh = t,
         this._group = r,
@@ -91,6 +25,61 @@ export default class XStaticMesh {
         this._mesh.xskinInfo = this._skinInfo,
         this._mesh.xurl = s
     }
+    
+    setVisibility(e,t) {
+        Array.isArray(e) ? e.forEach(r=>{
+            this.setVisibility(r, t)
+        }
+        ) : e.isAnInstance || (e.visibility = t)
+    }
+    
+    setPickable(e,t) {
+        Array.isArray(e) ? e.forEach(r=>{
+            this.setPickable(r, t)
+        }
+        ) : ("isPickable"in e && (e.isPickable = t),
+        e.setEnabled(t))
+    }
+    
+    hide() {
+        var e;
+        this._isVisible = !1,
+        this.mesh && this.setVisibility(this.mesh, 0),
+        this.mesh && this.setPickable(this.mesh, !1),
+        (e = this.mesh) == null || e.getChildMeshes().forEach(t=>{
+            this.setVisibility(t, 0),
+            this.setPickable(t, !1)
+        }
+        )
+    }
+    
+    show() {
+        var e;
+        this._isVisible = !0,
+        this.mesh && this.setVisibility(this.mesh, 1),
+        this.mesh && this.setPickable(this.mesh, !0),
+        (e = this.mesh) == null || e.getChildMeshes().forEach(t=>{
+            this.setVisibility(t, 1),
+            this.setPickable(t, !0)
+        }
+        )
+    }
+    
+    attachToAvatar(e, t={x:0, y:.5, z:0}, r={yaw:0, pitch:0, roll:0}, n={x:.35, y:.35, z:.35}) {
+        const o = ue4Scaling2Xverse(n)
+          , a = ue4Rotation2Xverse(r)
+          , s = ue4Position2Xverse(t)
+          , l = this._mesh;
+        e && l ? (e.setParent(l),
+        e.position = s,
+        e.rotation = a,
+        e.scaling = o) : logger.error("[Engine] avatar or attachment not found!")
+    }
+    
+    detachFromAvatar(e,t=!1) {
+        this._mesh && e ? this._mesh.removeChild(e) : logger.error("[Engine] avatar not found!")
+    }
+    
     get mesh() {
         return this._mesh
     }

+ 261 - 281
src/XStaticMeshComponent.js

@@ -6,286 +6,11 @@ import Logger from "./Logger.js"
 
 const logger = new Logger('XStaticMeshComponent')
 export default class XStaticMeshComponent{
-    constructor(e) {
-        E(this, "scene");
-        E(this, "_staticmeshes");
-        E(this, "_lowModel_group");
-        E(this, "_CgPlane");
-        E(this, "_rootDir");
-        E(this, "_abosoluteUrl");
-        E(this, "_partMeshSkinInfo");
-        E(this, "_meshInfoJson");
-        E(this, "_orijson");
-        E(this, "_notUsedRegionLists");
-        E(this, "_meshInfoKeys");
-        E(this, "_currentUpdateRegionCount");
-        E(this, "_currentMeshUsedLod");
-        E(this, "_currentPartGroup");
-        E(this, "_allowRegionUpdate");
-        E(this, "_allowRegionForceLod");
-        E(this, "_forceLod");
-        E(this, "_scenemanager");
-        E(this, "regionIdInCamera");
-        E(this, "regionIdInCameraConst");
-        E(this, "_cameraInRegionId");
-        E(this, "_meshVis");
-        E(this, "_doMeshVisChangeNumber");
-        E(this, "_meshVisTypeName");
-        E(this, "_visCheckDurationFrameNumber");
-        E(this, "_regionLodRule");
-        E(this, "reg_staticmesh_partupdate", ()=>{
-            this._allowRegionUpdate && (
-                this.scene.getFrameId(),
-                this._meshUpdateFrame()
-            )
-            if (this._allowRegionForceLod) {
-                this.scene.getFrameId() % 2 == 0 && this.setOneRegionLod(this._meshInfoKeys[this._currentUpdateRegionCount % this._meshInfoKeys.length].toString(), this._forceLod);
-                let t = !0;
-                const r = Array.from(this._currentMeshUsedLod.keys());
-                if (r.length > 0) {
-                    for (let n = 0; n < r.length; ++n)
-                        this._currentMeshUsedLod.get(r[n]) != this._forceLod && (t = !1);
-                    t && (this._allowRegionForceLod = !1)
-                }
-            }
-        });
-        E(this, "setMeshInfo", (e,t="")=>{
-            this._abosoluteUrl != e && (
-                this._abosoluteUrl.length > 0 && this.deleteLastRegionMesh(),
-                this._partMeshSkinInfo = t,
-                this._abosoluteUrl = e,
-                this._rootDir = this._abosoluteUrl.slice(0, -4) + "/",
-                this.parseJson(this._rootDir + "meshInfo.json").then(()=>{
-                    this.startMeshUpdate()
-                })
-            )
-        });
-        E(this, "_meshUpdateFrame", ()=>{
-            {
-                let e = this._meshInfoKeys[this._currentUpdateRegionCount % this._meshInfoKeys.length];
-                const t = !0;
-                let r = 3;
-                if (this._scenemanager != null && this._scenemanager.cameraComponent != null) {
-                    const n = this._getMainPlayerPosition();
-                    if (n != null) {
-                        if (this._cameraInRegionId >= 0) {
-                            const a = this.getRegionIdWhichIncludeCamera(n);
-                            (this._cameraInRegionId != a || this.regionIdInCamera.length == 0) && (this._cameraInRegionId = a,
-                            this.regionIdInCamera = this._getNeighborId(this._cameraInRegionId.toString()),
-                            this.regionIdInCameraConst = this.regionIdInCamera.slice());
-                            let s = this.regionIdInCamera.pop();
-                            for (; s != null; )
-                                if (this._notUsedRegionLists.indexOf(s) >= 0)
-                                    s = this.regionIdInCamera.pop();
-                                else
-                                    break;
-                            s != null && (e = s.toString())
-                        } else
-                            this._cameraInRegionId = this.getRegionIdWhichIncludeCamera(n);
-                        if (this._currentMeshUsedLod.size == 0 || this._notUsedRegionLists.indexOf(parseInt(e)) >= 0) {
-                            e = this._cameraInRegionId.toString();
-                            const a = this._getNeighborId(e);
-                            for (; a.length == 0 && (e = this.getNearestRegionIdWithCamera(n).toString()),
-                            this._notUsedRegionLists.indexOf(parseInt(e)) >= 0; )
-                                e = a.pop().toString()
-                        }
-                        const o = this._meshInfoJson[this._cameraInRegionId.toString()].lod;
-                        r = 3,
-                        this._cameraInRegionId.toString() == e ? r = this._regionLodRule[0] : o[0].indexOf(parseInt(e)) >= 0 ? r = this._regionLodRule[1] : o[1].indexOf(parseInt(e)) >= 0 ? r = this._regionLodRule[2] : o[2].indexOf(parseInt(e)) >= 0 ? r = this._regionLodRule[3] : r = this._regionLodRule[4]
-                    }
-                }
-                this.setOneRegionLod(e, r, t),
-                this.updateRegionNotInLocalNeighbor(),
-                this.cleanRootNodes()
-            }
-        }
-        );
-        E(this, "updateRegionNotInLocalNeighbor", ()=>{
-            Array.from(this._currentMeshUsedLod.keys()).forEach(t=>{
-                this.regionIdInCameraConst.indexOf(parseInt(t)) < 0 && this.setOneRegionLod(t, -1)
-            }
-            )
-        }
-        );
-        E(this, "cleanRootNodes", ()=>{
-            if (this.scene.getFrameId() % 3 == 0) {
-                const e = [];
-                this.scene.rootNodes.forEach(t=>{
-                    (t.getClassName() == "TransformNode" && t.getChildren().length == 0 || t.getClassName() == "Mesh" && t.name == "__root__" && t.getChildren().length == 0) && e.push(t)
-                }
-                ),
-                e.forEach(t=>{
-                    t.dispose()
-                }
-                )
-            }
-        }
-        );
-        E(this, "setOneRegionLod", (e,t,r=!0)=>{
-            this._currentUpdateRegionCount++;
-            const n = this._calHashCode(this._rootDir)
-              , o = "region_" + n + "_" + e;
-            if (t < 0) {
-                this._currentMeshUsedLod.has(e) && (this._currentMeshUsedLod.delete(e),
-                this._currentPartGroup.delete(o),
-                this.deleteMeshesByCustomProperty("group", "region_" + n + "_" + e));
-                return
-            }
-            const a = this._rootDir + e + "_lod" + t + "_xverse.glb"
-              , s = this._currentMeshUsedLod.get(e);
-            this._currentPartGroup.add(o),
-            s != null ? s != t && (this._currentMeshUsedLod.set(e, t),
-            this._scenemanager.addNewLowPolyMesh({
-                url: a,
-                group: "region_" + n + "_" + e,
-                pick: !0,
-                lod: t,
-                skinInfo: this._partMeshSkinInfo
-            }, [{
-                group: "region_" + n + "_" + e,
-                mode: 0
-            }])) : (this._currentMeshUsedLod.set(e, t),
-            this._scenemanager.addNewLowPolyMesh({
-                url: a,
-                group: "region_" + n + "_" + e,
-                pick: !0,
-                lod: t,
-                skinInfo: this._partMeshSkinInfo
-            }))
-        }
-        );
-        E(this, "checkPointInView", ({x: e, y: t, z: r})=>{
-            const n = ue4Position2Xverse({
-                x: e,
-                y: t,
-                z: r
-            });
-            if (!n)
-                return !1;
-            for (let o = 0; o < 6; o++)
-                if (this.scene.frustumPlanes[o].dotCoordinate(n) < 0)
-                    return !1;
-            return !0
-        }
-        );
-        E(this, "addNewLowPolyMesh", (modelInfo, t, pureVideoShader)=>{
-            // 加载房间的glb模型
-
-            if (!modelInfo.url.endsWith("glb") && !modelInfo.url.startsWith("blob:")) {
-                return modelInfo.url.endsWith("zip") ? (
-                    this.setMeshInfo(modelInfo.url, modelInfo.skinInfo),
-                    Promise.resolve(!0)
-                ) : (
-                    logger.error("[Engine] input model path is error! ", modelInfo.url),
-                    Promise.reject(new XLowpolyModelError("[Engine] input model path is error! " + modelInfo.url))
-                );
-            }
+    constructor(scenemanager) {
+        this._CgPlane
+        this._orijson
+        this._notUsedRegionLists
 
-            {
-                const fileUrl = modelInfo.url;
-                return new Promise((o, a)=>this._scenemanager.urlTransformer(modelInfo.url).then(blobUrl=>{
-                    modelInfo.url = blobUrl;
-                    const l = new XStaticMeshFromOneGltf(this.scene, modelInfo)
-                      , time0 = Date.now();
-
-                    return new Promise((c, h)=>{
-                        l.loadMesh(pureVideoShader, !0).then(f => {
-                            const time1 = Date.now();
-                            this._scenemanager.engineRunTimeStats.timeArray_loadStaticMesh.add(time1 - time0)
-                            if (f == !0) {
-                                const modelType = this.getLowModelType(modelInfo);
-                                let g = 0;
-                                this._lowModel_group.has(modelType) && (g = this._lowModel_group.get(modelType).length)
-
-                                pureVideoShader && this._scenemanager.currentShader 
-                                && this._scenemanager.currentShader.name != pureVideoShader.name 
-                                && l.setMaterial(this._scenemanager.currentShader)
-
-                                if (this._allowRegionUpdate == !1 && modelType.startsWith("region_"))
-                                    l.dispose();
-                                else if (
-                                    this._staticmeshes.push(l),
-                                    this.lowmodelGroupMapAddValue(modelType, l),
-                                    t && t.length > 0
-                                ) {
-                                    const m = [];
-                                    for (let v = 0; v < t.length; ++v)
-                                        m.push(t[v].group),
-                                        this.updateLowModelGroup(t[v], modelType, g)
-                                }
-                                this._scenemanager.engineRunTimeStats.timeArray_updateStaticMesh.add(Date.now() - time1),
-                                c(!0)
-                            } else
-                                h(new XLowpolyModelError("[Engine] after lowmodel error!"))
-                        }
-                        ).catch(e=>{
-                            logger.error("[Engine] load Mesh [" + fileUrl + "] error! " + e),
-                            h(new XLowpolyModelError(`[Engine] load Mesh [${fileUrl}] error! ${e}`))
-                        })
-                    })
-                }
-                ).then(s=>{
-                    s == !0 ? (
-                        logger.info(`[Engine] load Mesh [${fileUrl}] successfully.`),
-                        o(!0)
-                    ) : a(!1)
-                }
-                ).catch(s=>{
-                    logger.error("[Engine] addNewLowPolyMesh [" + fileUrl + "] error! " + s),
-                    a(new XLowpolyModelError(`[Engine] addNewLowPolyMesh [${fileUrl}] error! ${s}`))
-                }))
-            }
-        });
-
-        E(this, "toggleLowModelVisibility", e=>{
-            const {vis: t, groupName: r="", skinInfo: n=""} = e;
-            this._meshVis = t,
-            this._meshVisTypeName = {
-                groupName: r,
-                skinInfo: n
-            },
-            this._doMeshVisChangeNumber = 0,
-            r == Te.ALL_MESHES || this._currentPartGroup.has(r) == !0 || this._partMeshSkinInfo == n ? t == !1 ? (this._visCheckDurationFrameNumber = 100,
-            this.stopMeshUpdate()) : (this._visCheckDurationFrameNumber = 1,
-            this.startMeshUpdate()) : this._visCheckDurationFrameNumber = 1
-        }
-        );
-        E(this, "reg_staticmesh_visibility", ()=>{
-            if (this._doMeshVisChangeNumber >= 0)
-                if (this._doMeshVisChangeNumber < this._visCheckDurationFrameNumber)
-                    if (this._doMeshVisChangeNumber = this._doMeshVisChangeNumber + 1,
-                    this._meshVisTypeName.groupName == Te.ALL_MESHES)
-                        this._lowModel_group.forEach((e,t)=>{
-                            for (let r = 0, n = e.length; r < n; ++r)
-                                e[r].toggleVisibility(this._meshVis)
-                        }
-                        );
-                    else {
-                        if (this._lowModel_group.has(this._meshVisTypeName.groupName))
-                            for (let e = 0; e < this._lowModel_group.get(this._meshVisTypeName.groupName).length; ++e)
-                                this._lowModel_group.get(this._meshVisTypeName.groupName)[e].toggleVisibility(this._meshVis);
-                        if (this._meshVisTypeName.skinInfo != "")
-                            for (let e = 0; e < this._staticmeshes.length; ++e)
-                                this._staticmeshes[e].skinInfo == this._meshVisTypeName.skinInfo && this._staticmeshes[e].toggleVisibility(this._meshVis)
-                    }
-                else
-                    this._meshVis = !0,
-                    this._meshVisTypeName = {
-                        groupName: "",
-                        skinInfo: ""
-                    },
-                    this._doMeshVisChangeNumber = -1
-        }
-        );
-        E(this, "_getMeshesByCustomProperty", (e,t)=>{
-            let r = [];
-            return this._staticmeshes.forEach(n=>{
-                n[e] != null && n[e] == t && (r = r.concat(n.meshes))
-            }
-            ),
-            r
-        }
-        );
         this._lowModel_group = new Map,
         this._staticmeshes = [],
         this._meshInfoJson = null,
@@ -298,8 +23,8 @@ export default class XStaticMeshComponent{
         this._allowRegionForceLod = !1,
         this._currentMeshUsedLod = new Map,
         this._currentPartGroup = new Set,
-        this._scenemanager = e,
-        this.scene = e.Scene,
+        this._scenemanager = scenemanager,
+        this.scene = scenemanager.Scene,
         this.regionIdInCamera = [],
         this.regionIdInCameraConst = [],
         this._cameraInRegionId = -1,
@@ -315,6 +40,261 @@ export default class XStaticMeshComponent{
         this.initCgLowModel(),
         this._regionPartLoop()
     }
+
+    reg_staticmesh_partupdate() {
+        this._allowRegionUpdate && (
+            this.scene.getFrameId(),
+            this._meshUpdateFrame()
+        )
+        if (this._allowRegionForceLod) {
+            this.scene.getFrameId() % 2 == 0 && this.setOneRegionLod(this._meshInfoKeys[this._currentUpdateRegionCount % this._meshInfoKeys.length].toString(), this._forceLod);
+            let t = !0;
+            const r = Array.from(this._currentMeshUsedLod.keys());
+            if (r.length > 0) {
+                for (let n = 0; n < r.length; ++n)
+                    this._currentMeshUsedLod.get(r[n]) != this._forceLod && (t = !1);
+                t && (this._allowRegionForceLod = !1)
+            }
+        }
+    }
+
+    setMeshInfo(e,t="") {
+        this._abosoluteUrl != e && (
+            this._abosoluteUrl.length > 0 && this.deleteLastRegionMesh(),
+            this._partMeshSkinInfo = t,
+            this._abosoluteUrl = e,
+            this._rootDir = this._abosoluteUrl.slice(0, -4) + "/",
+            this.parseJson(this._rootDir + "meshInfo.json").then(()=>{
+                this.startMeshUpdate()
+            })
+        )
+    }
+
+    _meshUpdateFrame() {
+        {
+            let e = this._meshInfoKeys[this._currentUpdateRegionCount % this._meshInfoKeys.length];
+            const t = !0;
+            let r = 3;
+            if (this._scenemanager != null && this._scenemanager.cameraComponent != null) {
+                const n = this._getMainPlayerPosition();
+                if (n != null) {
+                    if (this._cameraInRegionId >= 0) {
+                        const a = this.getRegionIdWhichIncludeCamera(n);
+                        (this._cameraInRegionId != a || this.regionIdInCamera.length == 0) && (this._cameraInRegionId = a,
+                        this.regionIdInCamera = this._getNeighborId(this._cameraInRegionId.toString()),
+                        this.regionIdInCameraConst = this.regionIdInCamera.slice());
+                        let s = this.regionIdInCamera.pop();
+                        for (; s != null; )
+                            if (this._notUsedRegionLists.indexOf(s) >= 0)
+                                s = this.regionIdInCamera.pop();
+                            else
+                                break;
+                        s != null && (e = s.toString())
+                    } else
+                        this._cameraInRegionId = this.getRegionIdWhichIncludeCamera(n);
+                    if (this._currentMeshUsedLod.size == 0 || this._notUsedRegionLists.indexOf(parseInt(e)) >= 0) {
+                        e = this._cameraInRegionId.toString();
+                        const a = this._getNeighborId(e);
+                        for (; a.length == 0 && (e = this.getNearestRegionIdWithCamera(n).toString()),
+                        this._notUsedRegionLists.indexOf(parseInt(e)) >= 0; )
+                            e = a.pop().toString()
+                    }
+                    const o = this._meshInfoJson[this._cameraInRegionId.toString()].lod;
+                    r = 3,
+                    this._cameraInRegionId.toString() == e ? r = this._regionLodRule[0] : o[0].indexOf(parseInt(e)) >= 0 ? r = this._regionLodRule[1] : o[1].indexOf(parseInt(e)) >= 0 ? r = this._regionLodRule[2] : o[2].indexOf(parseInt(e)) >= 0 ? r = this._regionLodRule[3] : r = this._regionLodRule[4]
+                }
+            }
+            this.setOneRegionLod(e, r, t),
+            this.updateRegionNotInLocalNeighbor(),
+            this.cleanRootNodes()
+        }
+    }
+
+    updateRegionNotInLocalNeighbor() {
+        Array.from(this._currentMeshUsedLod.keys()).forEach(t=>{
+            this.regionIdInCameraConst.indexOf(parseInt(t)) < 0 && this.setOneRegionLod(t, -1)
+        }
+        )
+    }
+
+    cleanRootNodes() {
+        if (this.scene.getFrameId() % 3 == 0) {
+            const e = [];
+            this.scene.rootNodes.forEach(t=>{
+                (t.getClassName() == "TransformNode" && t.getChildren().length == 0 || t.getClassName() == "Mesh" && t.name == "__root__" && t.getChildren().length == 0) && e.push(t)
+            }
+            ),
+            e.forEach(t=>{
+                t.dispose()
+            }
+            )
+        }
+    }
+
+    setOneRegionLod(e,t,r=!0) {
+        this._currentUpdateRegionCount++;
+        const n = this._calHashCode(this._rootDir)
+          , o = "region_" + n + "_" + e;
+        if (t < 0) {
+            this._currentMeshUsedLod.has(e) && (this._currentMeshUsedLod.delete(e),
+            this._currentPartGroup.delete(o),
+            this.deleteMeshesByCustomProperty("group", "region_" + n + "_" + e));
+            return
+        }
+        const a = this._rootDir + e + "_lod" + t + "_xverse.glb"
+          , s = this._currentMeshUsedLod.get(e);
+        this._currentPartGroup.add(o),
+        s != null ? s != t && (this._currentMeshUsedLod.set(e, t),
+        this._scenemanager.addNewLowPolyMesh({
+            url: a,
+            group: "region_" + n + "_" + e,
+            pick: !0,
+            lod: t,
+            skinInfo: this._partMeshSkinInfo
+        }, [{
+            group: "region_" + n + "_" + e,
+            mode: 0
+        }])) : (this._currentMeshUsedLod.set(e, t),
+        this._scenemanager.addNewLowPolyMesh({
+            url: a,
+            group: "region_" + n + "_" + e,
+            pick: !0,
+            lod: t,
+            skinInfo: this._partMeshSkinInfo
+        }))
+    }
+
+    checkPointInView({x: e, y: t, z: r}) {
+        const n = ue4Position2Xverse({
+            x: e,
+            y: t,
+            z: r
+        });
+        if (!n)
+            return !1;
+        for (let o = 0; o < 6; o++)
+            if (this.scene.frustumPlanes[o].dotCoordinate(n) < 0)
+                return !1;
+        return !0
+    }
+    
+    // 加载房间的glb模型
+    addNewLowPolyMesh(modelInfo, t, pureVideoShader) {
+
+        if (!modelInfo.url.endsWith("glb") && !modelInfo.url.startsWith("blob:")) {
+            return modelInfo.url.endsWith("zip") ? (
+                this.setMeshInfo(modelInfo.url, modelInfo.skinInfo),
+                Promise.resolve(!0)
+            ) : (
+                logger.error("[Engine] input model path is error! ", modelInfo.url),
+                Promise.reject(new XLowpolyModelError("[Engine] input model path is error! " + modelInfo.url))
+            );
+        }
+
+        const fileUrl = modelInfo.url;
+        return new Promise((o, a) => {
+            this._scenemanager.urlTransformer(modelInfo.url).then(blobUrl=>{
+                modelInfo.url = blobUrl;
+                const l = new XStaticMeshFromOneGltf(this.scene, modelInfo)
+                    , time0 = Date.now();
+
+                return new Promise((c, h)=>{
+                    l.loadMesh(pureVideoShader, !0).then(f => {
+                        const time1 = Date.now();
+                        this._scenemanager.engineRunTimeStats.timeArray_loadStaticMesh.add(time1 - time0)
+                        if (f == !0) {
+                            const modelType = this.getLowModelType(modelInfo);
+                            let g = 0;
+                            this._lowModel_group.has(modelType) && (g = this._lowModel_group.get(modelType).length)
+
+                            pureVideoShader && this._scenemanager.currentShader 
+                            && this._scenemanager.currentShader.name != pureVideoShader.name 
+                            && l.setMaterial(this._scenemanager.currentShader)
+
+                            if (this._allowRegionUpdate == !1 && modelType.startsWith("region_"))
+                                l.dispose();
+                            else if (
+                                this._staticmeshes.push(l),
+                                this.lowmodelGroupMapAddValue(modelType, l),
+                                t && t.length > 0
+                            ) {
+                                const m = [];
+                                for (let v = 0; v < t.length; ++v)
+                                    m.push(t[v].group),
+                                    this.updateLowModelGroup(t[v], modelType, g)
+                            }
+                            this._scenemanager.engineRunTimeStats.timeArray_updateStaticMesh.add(Date.now() - time1),
+                            c(!0)
+                        } else
+                            h(new XLowpolyModelError("[Engine] after lowmodel error!"))
+                    }
+                    ).catch(e=>{
+                        logger.error("[Engine] load Mesh [" + fileUrl + "] error! " + e),
+                        h(new XLowpolyModelError(`[Engine] load Mesh [${fileUrl}] error! ${e}`))
+                    })
+                })
+            }).then(s=>{
+                s == !0 ? (
+                    logger.info(`[Engine] load Mesh [${fileUrl}] successfully.`),
+                    o(!0)
+                ) : a(!1)
+            }
+            ).catch(s=>{
+                logger.error("[Engine] addNewLowPolyMesh [" + fileUrl + "] error! " + s),
+                a(new XLowpolyModelError(`[Engine] addNewLowPolyMesh [${fileUrl}] error! ${s}`))
+            })
+        })
+    }
+
+    toggleLowModelVisibility(e) {
+        const {vis: t, groupName: r="", skinInfo: n=""} = e;
+        this._meshVis = t,
+        this._meshVisTypeName = {
+            groupName: r,
+            skinInfo: n
+        },
+        this._doMeshVisChangeNumber = 0,
+        r == Te.ALL_MESHES || this._currentPartGroup.has(r) == !0 || this._partMeshSkinInfo == n ? t == !1 ? (this._visCheckDurationFrameNumber = 100,
+        this.stopMeshUpdate()) : (this._visCheckDurationFrameNumber = 1,
+        this.startMeshUpdate()) : this._visCheckDurationFrameNumber = 1
+    }
+    
+    reg_staticmesh_visibility() {
+        if (this._doMeshVisChangeNumber >= 0)
+            if (this._doMeshVisChangeNumber < this._visCheckDurationFrameNumber)
+                if (this._doMeshVisChangeNumber = this._doMeshVisChangeNumber + 1,
+                this._meshVisTypeName.groupName == Te.ALL_MESHES)
+                    this._lowModel_group.forEach((e,t)=>{
+                        for (let r = 0, n = e.length; r < n; ++r)
+                            e[r].toggleVisibility(this._meshVis)
+                    }
+                    );
+                else {
+                    if (this._lowModel_group.has(this._meshVisTypeName.groupName))
+                        for (let e = 0; e < this._lowModel_group.get(this._meshVisTypeName.groupName).length; ++e)
+                            this._lowModel_group.get(this._meshVisTypeName.groupName)[e].toggleVisibility(this._meshVis);
+                    if (this._meshVisTypeName.skinInfo != "")
+                        for (let e = 0; e < this._staticmeshes.length; ++e)
+                            this._staticmeshes[e].skinInfo == this._meshVisTypeName.skinInfo && this._staticmeshes[e].toggleVisibility(this._meshVis)
+                }
+            else
+                this._meshVis = !0,
+                this._meshVisTypeName = {
+                    groupName: "",
+                    skinInfo: ""
+                },
+                this._doMeshVisChangeNumber = -1
+    }
+
+    _getMeshesByCustomProperty(e,t) {
+        let r = [];
+        return this._staticmeshes.forEach(n=>{
+            n[e] != null && n[e] == t && (r = r.concat(n.meshes))
+        }
+        ),
+        r
+    }
+
     get cameraInRegionId() {
         return this._cameraInRegionId
     }

+ 62 - 61
src/XStaticMeshFromOneGltf.js

@@ -6,71 +6,72 @@ import Logger from "./Logger.js"
 
 const logger = new Logger('XStaticMeshComponent')
 export default class XStaticMeshFromOneGltf {
-    constructor(e, t) {
-        E(this, "_scene");
-        E(this, "_url");
-        E(this, "_group");
-        E(this, "_pickable");
-        E(this, "_meshes");
-        E(this, "_id");
-        E(this, "_lod");
-        E(this, "_groupUuid");
-        E(this, "_isInScene");
-        E(this, "_skinInfo");
-        E(this, "loadMesh", (pureVideoShader, t)=>{
-            const r = this._meshes.length
-              , n = t ? 1 : 0
-              , o = this._url;
-            return BABYLON.SceneLoader.LoadAssetContainerAsync("", o, this._scene, ()=>{
-                this._scene.blockMaterialDirtyMechanism = !0
-            }, ".glb").then(a=>{
-                for (let s = a.materials.length - 1; s >= 0; --s)
-                    a.materials[s].dispose();
-                this._scene.blockMaterialDirtyMechanism = !0;
-                for (let s = 0; s < a.meshes.length; ++s) {
-                    const mesh = a.meshes[s];
-                    if ("instances"in mesh) {
-                        "visibility"in mesh && (mesh.visibility = 0);
-                        "isPickable"in mesh && (mesh.isPickable = this._pickable);
-                        pureVideoShader && (mesh.material = pureVideoShader);
-                        "hasVertexAlpha"in mesh && (mesh.hasVertexAlpha = !1);
-                        const xMesh = new XStaticMesh({
-                            id: this._groupUuid + "-" + Math.random().toString(36).substr(2, 5),
-                            mesh,
-                            lod: this._lod,
-                            group: this._group,
-                            url: this._url,
-                            xtype: EMeshType.XStaticMesh,
-                            skinInfo: this._skinInfo
-                        });
-                        // 房间模型初始180度矫正
-                        xMesh.setRotation({pitch: 0, roll:0, yaw:180})
-                        this._meshes.push(xMesh);
-                    }
-                    this._scene.addMesh(mesh);
-                }
-                return !0
-            }).then(()=>{
-                this._isInScene = !0;
-                for (let a = r; a < this._meshes.length; ++a)
-                    this._meshes[a].mesh.visibility = n;
-                return Promise.resolve(!0)
-            }).catch(a=>{
-                logger.error("[Engine] input gltf mesh uri error! " + a),
-                Promise.reject(new XLowpolyModelError("[Engine] input gltf mesh uri error! " + a))
-            })
-        });
+    
+    constructor(scene, options) {
+
         this._meshes = [],
-        this._scene = e,
-        this._url = t.url,
-        t.group != null ? this._group = t.group : this._group = "default",
-        t.pick != null ? this._pickable = t.pick : this._pickable = !1,
-        t.id != null ? this._id = t.id : this._id = "default",
-        t.lod != null ? this._lod = t.lod : this._lod = -1,
-        t.skinInfo != null ? this._skinInfo = t.skinInfo : this._skinInfo = "default",
+        this._scene = scene,
+        this._url = options.url,
+
+        options.group != null ? this._group = options.group : this._group = "default",
+        options.pick != null ? this._pickable = options.pick : this._pickable = !1,
+        options.id != null ? this._id = options.id : this._id = "default",
+        options.lod != null ? this._lod = options.lod : this._lod = -1,
+        options.skinInfo != null ? this._skinInfo = options.skinInfo : this._skinInfo = "default",
+
         this._groupUuid = util.uuid(),
         this._isInScene = !1
     }
+    
+    loadMesh(pureVideoShader, t) {
+        const meshLength0 = this._meshes.length
+          , isVisi = t ? 1 : 0
+          , url = this._url;
+
+        return BABYLON.SceneLoader.LoadAssetContainerAsync("", url, this._scene, ()=>{
+            this._scene.blockMaterialDirtyMechanism = !0
+        }, ".glb").then(modelInfo => {
+
+            for (let s = modelInfo.materials.length - 1; s >= 0; --s)
+                modelInfo.materials[s].dispose();
+
+            this._scene.blockMaterialDirtyMechanism = !0;
+
+            for (let i = 0; i < modelInfo.meshes.length; ++i) {
+                const mesh = modelInfo.meshes[i];
+                if ("instances"in mesh) {
+                    "visibility"in mesh && (mesh.visibility = 0);
+                    "isPickable"in mesh && (mesh.isPickable = this._pickable);
+                    pureVideoShader && (mesh.material = pureVideoShader);
+                    "hasVertexAlpha"in mesh && (mesh.hasVertexAlpha = !1);
+
+                    const xMesh = new XStaticMesh({
+                        id: this._groupUuid + "-" + Math.random().toString(36).substr(2, 5),
+                        mesh,
+                        lod: this._lod,
+                        group: this._group,
+                        url: this._url,
+                        xtype: EMeshType.XStaticMesh,
+                        skinInfo: this._skinInfo
+                    });
+                    // 房间模型初始180度矫正
+                    xMesh.setRotation({pitch: 0, roll:0, yaw:180})
+                    this._meshes.push(xMesh);
+                }
+                this._scene.addMesh(mesh);
+            }
+            return !0
+        }).then(() => {
+            this._isInScene = !0;
+            for (let i = meshLength0; i < this._meshes.length; ++i)
+                this._meshes[i].mesh.visibility = isVisi;
+            return Promise.resolve(!0)
+        }).catch(e => {
+            logger.error("[Engine] input gltf mesh uri error! " + e),
+            Promise.reject(new XLowpolyModelError("[Engine] input gltf mesh uri error! " + e))
+        })
+    }
+
     get isinscene() {
         return this._isInScene
     }

+ 8 - 0
src/Xverse_Room.js

@@ -98,9 +98,17 @@ export default class Xverse_Room extends EventEmitter {
       const workers = this.networkController.rtcp.workers;
 
       workers.registerFunction("signal", data => {
+        // data.signal.newUserStates && data.signal.newUserStates[0].playerState.camera 
+        // && console.error(data.signal.actionResponses, data.signal.newUserStates[0].playerState.camera.position)
         // 更新坐标数据
         data.signal.newUserStates && data.signal.newUserStates[0] && (data.signal.newUserStates[0].userId = this.userId)  // todo 写死数据纠正
         this.signal.handleSignal(data, reject)
+        
+        // data.signal.newUserStates 
+        // && data.signal.newUserStates[0] 
+        // && data.signal.newUserStates[0].playerState 
+        // && data.signal.newUserStates[0].playerState.camera 
+        // && console.error(data.signal.newUserStates[0].playerState.camera.position, xversePosition2Ue4(this.sceneManager._cameraManager.mainCamera.position))
       }),
 
       workers.registerFunction("stream", data => {