|
@@ -34,9 +34,11 @@ export default class XStaticMeshComponent{
|
|
|
E(this, "_visCheckDurationFrameNumber");
|
|
|
E(this, "_regionLodRule");
|
|
|
E(this, "reg_staticmesh_partupdate", ()=>{
|
|
|
- if (this._allowRegionUpdate && (this.scene.getFrameId(),
|
|
|
- this._meshUpdateFrame()),
|
|
|
- this._allowRegionForceLod) {
|
|
|
+ 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());
|
|
@@ -46,19 +48,18 @@ export default class XStaticMeshComponent{
|
|
|
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()
|
|
|
- }
|
|
|
- ))
|
|
|
- }
|
|
|
- );
|
|
|
+ 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];
|
|
@@ -167,61 +168,75 @@ export default class XStaticMeshComponent{
|
|
|
return !0
|
|
|
}
|
|
|
);
|
|
|
- E(this, "addNewLowPolyMesh", (e,t,r)=>{
|
|
|
- if (!e.url.endsWith("glb") && !e.url.startsWith("blob:"))
|
|
|
- return e.url.endsWith("zip") ? (this.setMeshInfo(e.url, e.skinInfo),
|
|
|
- Promise.resolve(!0)) : (logger.error("[Engine] input model path is error! ", e.url),
|
|
|
- Promise.reject(new XLowpolyModelError("[Engine] input model path is error! " + e.url)));
|
|
|
+ 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))
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
{
|
|
|
- const n = e.url;
|
|
|
- return new Promise((o,a)=>this._scenemanager.urlTransformer(e.url).then(s=>{
|
|
|
- e.url = s;
|
|
|
- const l = new XStaticMeshFromOneGltf(this.scene,e)
|
|
|
- , u = Date.now();
|
|
|
- return new Promise((c,h)=>{
|
|
|
- l.loadMesh(r, !0).then(f=>{
|
|
|
- const d = Date.now();
|
|
|
- if (this._scenemanager.engineRunTimeStats.timeArray_loadStaticMesh.add(d - u),
|
|
|
- f == !0) {
|
|
|
- const _ = this.getLowModelType(e);
|
|
|
+ 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;
|
|
|
- if (this._lowModel_group.has(_) && (g = this._lowModel_group.get(_).length),
|
|
|
- r != null && this._scenemanager.currentShader != null && this._scenemanager.currentShader.name != r.name && l.setMaterial(this._scenemanager.currentShader),
|
|
|
- this._allowRegionUpdate == !1 && _.startsWith("region_"))
|
|
|
+ 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(_, l),
|
|
|
- t != null && t.length > 0) {
|
|
|
+ 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], _, g)
|
|
|
+ this.updateLowModelGroup(t[v], modelType, g)
|
|
|
}
|
|
|
- this._scenemanager.engineRunTimeStats.timeArray_updateStaticMesh.add(Date.now() - d),
|
|
|
+ this._scenemanager.engineRunTimeStats.timeArray_updateStaticMesh.add(Date.now() - time1),
|
|
|
c(!0)
|
|
|
} else
|
|
|
h(new XLowpolyModelError("[Engine] after lowmodel error!"))
|
|
|
}
|
|
|
- ).catch(f=>{
|
|
|
- logger.error("[Engine] load Mesh [" + n + "] error! " + f),
|
|
|
- h(new XLowpolyModelError(`[Engine] load Mesh [${n}] error! ${f}`))
|
|
|
- }
|
|
|
- )
|
|
|
- }
|
|
|
- )
|
|
|
+ ).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 [${n}] successfully.`),
|
|
|
- o(!0)) : a(!1)
|
|
|
+ s == !0 ? (
|
|
|
+ logger.info(`[Engine] load Mesh [${fileUrl}] successfully.`),
|
|
|
+ o(!0)
|
|
|
+ ) : a(!1)
|
|
|
}
|
|
|
).catch(s=>{
|
|
|
- logger.error("[Engine] addNewLowPolyMesh [" + n + "] error! " + s),
|
|
|
- a(new XLowpolyModelError(`[Engine] addNewLowPolyMesh [${n}] error! ${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,
|