diff --git a/yanzhu-bigscreen/public/index.html b/yanzhu-bigscreen/public/index.html index 83e09a54..7f78b80e 100644 --- a/yanzhu-bigscreen/public/index.html +++ b/yanzhu-bigscreen/public/index.html @@ -30,7 +30,7 @@ - + diff --git a/yanzhu-bigscreen/src/views/bim/bim4DTools.js b/yanzhu-bigscreen/src/views/bim/bim4DTools.js index 83cd0ded..b7b7d02a 100644 --- a/yanzhu-bigscreen/src/views/bim/bim4DTools.js +++ b/yanzhu-bigscreen/src/views/bim/bim4DTools.js @@ -143,7 +143,7 @@ const ganttStyle = { }; function initEngine(that) { - console.log("开始初始化引擎") + console.log("开始初始化引擎"); window.bim4DApi = new SAPI( { serverIP: window.config.serverIP, //服务ip地址 @@ -240,6 +240,7 @@ function addModel(that, modelId, cb) { that.viewPoint = p; that.modelLoaded = true; }); + that.initPlay(); }, 1000); } ); @@ -251,9 +252,8 @@ function showBim(that, index) { if (index <= 0) { index = getCurrentTaskIndex(that); } - console.log(index); let showFeatureIds = []; - let currFeatureId = []; + let currFeatureIds = []; for (let i = 0; i <= that.taskList.length; i++) { if (i <= index) { that.taskList[i].gis.forEach((item) => { @@ -265,13 +265,20 @@ function showBim(that, index) { } } if (showFeatureIds.length > 0) { - let featureId = showFeatureIds[0]; - let modelId = featureId.split("_")[0]; - let tmpsIds2 = showFeatureIds.splice(0, maxLen); - api.Model.original(modelId); - api.Feature.showFeatures(tmpsIds2.join("#")); setFeatueVisible(showFeatureIds, true); } + setTimeout(() => { + that.lastFeatureIds.forEach((it) => { + api.Feature.setColor(it, "rgba(255,255,255,1)"); + }); + 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)"); + }); + } + that.lastFeatureIds = currFeatureIds; + }, 0); } function setFeatueVisible(featureIds, show) { @@ -299,10 +306,73 @@ function getCurrentTaskIndex(that) { return index; } +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); + } +} + +function original() { + let api = bim4DApi; + for (let modelId in api.m_model) { + api.Model.original(modelId); + } +} + +function getFirstFeatureId(that) { + for (let i = 0; i < that.taskList.length; i++) { + let task = that.taskList[i]; + if (task.gis.length > 0) { + return task.gis[0].featureId; + } + } + return ""; +} + +function preparePlay(that) { + let featureId = getFirstFeatureId(that); + if (!featureId) { + return; + } + let api = bim4DApi; + api.Feature.showFeatures(featureId); + api.Feature.setColor(featureId, "rgba(255,255,255,0)"); +} + +function playStop(that) { + let api = bim4DApi; + that.lastFeatureIds.forEach((it) => { + api.Feature.setColor(it, "rgba(255,255,255,1)"); + }); +} + +function doPLay(that) { + that.playTimer = setInterval(() => { + that.playValue++; + if (that.playValue >= that.taskList.length) { + playStop(that); + that.doStop(); + } else { + that.doPlayPan(that.playValue); + } + }, that.playTime); +} + export default { options, ganttStyle, initEngine, initLoadModel, showBim, + resetScene, + original, + getFirstFeatureId, + preparePlay, + playStop, + getCurrentTaskIndex, + doPLay, }; diff --git a/yanzhu-bigscreen/src/views/bim4DSimulation.vue b/yanzhu-bigscreen/src/views/bim4DSimulation.vue index ed47f018..37ae2572 100644 --- a/yanzhu-bigscreen/src/views/bim4DSimulation.vue +++ b/yanzhu-bigscreen/src/views/bim4DSimulation.vue @@ -11,7 +11,20 @@