diff --git a/yanzhu-bigscreen/src/views/bim/bim4DTools.js b/yanzhu-bigscreen/src/views/bim/bim4DTools.js index 5452090c..ece2538c 100644 --- a/yanzhu-bigscreen/src/views/bim/bim4DTools.js +++ b/yanzhu-bigscreen/src/views/bim/bim4DTools.js @@ -1,6 +1,6 @@ import bimTools from "./bimTools"; -import apiTools from './apiTools.js' -import sapiTools from './sapiTools.js' +// import apiTools from './apiTools.js' +// import sapiTools from './sapiTools.js' const options = { taskMapping: { @@ -146,17 +146,20 @@ const ganttStyle = { }, }; function initEngine(that) { - if (that.clientShow()) { - apiTools.loadEngine(that, "bim4DContainer", 'bim4DApi', - () => { - initLoadModel(that); - } - ) - } else { - sapiTools.loadEngine(that, "bim4DContainer", 'bim4DApi', () => { - initLoadModel(that); - }) - } + bimTools.initEngine("bim4DApi", "bim4DContainer", that.bimCfg, () => { + initLoadModel(that); + }); + // if (that.isClient) { + // apiTools.loadEngine(that, "bim4DContainer", 'bim4DApi', + // () => { + // initLoadModel(that); + // } + // ) + // } else { + // sapiTools.loadEngine(that, "bim4DContainer", 'bim4DApi', () => { + // initLoadModel(that); + // }) + // } } @@ -194,59 +197,29 @@ function initLoadModel(that) { that.models.forEach((item) => { item.modelId = item.lightweightName; item.gis = JSON.parse(item.gisJson); - addModel(that, item.lightweightName); }); - bimTools.initLoadModel(that, bim4DApi) + bimTools.addModelList(window.bim4DApi, that.bimCfg, that.models, (hideParts) => { + setTimeout(() => { + bimTools.setDefaultViewPoint(window.bim4DApi, that.bimCfg, that.viewPoint) + that.hideParts = hideParts; + bimTools.hideParts(window.bim4DApi, hideParts); + that.modelLoadSuccess = true; + that.resetScene(); + let fnInit = () => { + if (that.planLoaded) { + that.initPlay(); + } else { + setTimeout(fnInit, 100); + } + }; + fnInit(); + + }, 1000); + }); } }); } -function addModel(that, modelId, cb) { - let api = window.bim4DApi; - let url = `${window.config.modelUrl}/Tools/output/model/${modelId}/root.glt`; - let direction = null; - let modelInfo = that.models.find(m => m.modelId == modelId); - if (that.clientShow()) { - url = `/bimdata/Tools/output/model/${modelId}/root.glt`; - if (modelInfo) { - direction = modelInfo.bimCfg.direction; - } - } - - console.log(modelId, url); - api.Model.add( - url, - modelId, - () => { }, - () => { - cb && cb(); - console.log("加载模型成功"); - setTimeout(() => { - if (that.viewPoint) { - if (that.viewPoint.world) { - if (!that.clientShow()) { - api.Camera.setViewPort(that.viewPoint); - } - } - } else { - api.Camera.getViewPort((p) => { - that.viewPoint = p; - }); - } - that.modelLoaded = true; - let fnInit = () => { - if (that.planLoaded) { - that.initPlay(); - } else { - setTimeout(fnInit, 100); - } - }; - fnInit(); - }, 1000); - }, - direction - ); -} const maxLen = 500; function showBim(that, index) { @@ -261,23 +234,39 @@ function showBim(that, index) { that.taskList[i].gis.forEach((item) => { let featureId = item.featureId; if (!showFeatureIds.includes(featureId)) { - showFeatureIds.push(featureId); + if (!that.hideParts.find(d => d.featureId == featureId)) { + showFeatureIds.push(featureId); + } + } }); } } - console.log(index, showFeatureIds, currFeatureIds) if (showFeatureIds.length > 0) { + let tmp = showFeatureIds.splice(0, maxLen); + if (tmp.length > 0) { + api.Feature.showFeatures(tmp.join("#")); + } setFeatueVisible(showFeatureIds, true); } setTimeout(() => { that.lastFeatureIds.forEach((it) => { - api.Feature.setColor(it, "rgba(255,255,255,1)"); + if (that.isClient) { + api.Feature.setColor(it, 255, 255, 255, 1); + } else { + api.Feature.setColor(it, "rgba(255,255,255,0)"); + } + }); currFeatureIds = that.taskList[index].gis.map((item) => item.featureId); if (currFeatureIds.length > 0) { currFeatureIds.forEach((it) => { - api.Feature.setColor(it, "rgba(255,0,255,1)"); + if (that.isClient) { + api.Feature.setColor(it, 255, 0, 255, 1); + } else { + api.Feature.setColor(it, "rgba(255,0,255,1)"); + } + }); } that.lastFeatureIds = currFeatureIds; @@ -291,6 +280,7 @@ function setFeatueVisible(featureIds, show) { if (cnt == 0) { return; } + for (let i = 0; i < cnt; i += len) { api.Feature.setVisible(featureIds.slice(i, i + len).join("#"), show); } @@ -313,17 +303,22 @@ function resetScene(that) { let api = bim4DApi; api.Camera.stopImmersiveRoam(); api.Model.location(api.m_model.keys().toArray()[0]); - api.Plugin.deleteMiniMap(); - if (that.viewPoint) { - api.Camera.setViewPort(that.viewPoint); + if (!that.isClient) { + api.Plugin.deleteMiniMap(); + if (that.viewPoint) { + api.Camera.setViewPort(that.viewPoint); + } } + } -function original() { +function original(that) { let api = bim4DApi; for (let modelId in api.m_model) { api.Model.original(modelId); } + console.log("---hideParts---", that.hideParts) + bimTools.hideParts(window.bim4DApi, that.hideParts); } function getFirstFeatureId(that) { diff --git a/yanzhu-bigscreen/src/views/bim4DSimulation.vue b/yanzhu-bigscreen/src/views/bim4DSimulation.vue index ed0e5b88..60dd252f 100644 --- a/yanzhu-bigscreen/src/views/bim4DSimulation.vue +++ b/yanzhu-bigscreen/src/views/bim4DSimulation.vue @@ -3,23 +3,21 @@