diff --git a/yanzhu-bigscreen/src/views/bim/bimTools.js b/yanzhu-bigscreen/src/views/bim/bimTools.js index 3a8c116c..69e1a060 100644 --- a/yanzhu-bigscreen/src/views/bim/bimTools.js +++ b/yanzhu-bigscreen/src/views/bim/bimTools.js @@ -112,6 +112,67 @@ function initSAPIEngine(apiID, elId, bimCfg, cb) { ); } +function loadClipModel(api, bimCfg, modelList, cb) { + let allHideParts = []; + let cnt = 0; + if (modelList && modelList.length > 0) { + modelList.forEach((it) => { + addClipModel( + api, + bimCfg, + it.modelId, + (hideParts) => { + allHideParts.push(...hideParts); + cnt++; + if (cnt == modelList.length) { + cb && cb(allHideParts); + } + }, + modelList + ); + }); + } +} +function addClipModel(api, bimCfg, modelId, cb, models) { + let url = `${window.config.modelUrl}/Tools/output/model/${modelId}/root.glt`; + let direction = null; + let modelInfo = null; + if (models) { + modelInfo = models.find((m) => m.modelId == modelId); + } + if (bimCfg.clientApi) { + url = `/bimdata/Tools/output/model/${modelId}/root.glt`; + if (modelInfo) { + //direction = modelInfo.bimCfg.direction; + } + } + console.log("加载模型:" + url); + api.Model.add( + url, + "clip"+modelId, + () => { + console.log("加载模型成功2"); + }, + () => { + console.log("加载模型成功"); + let hideParts = []; + if (modelInfo) { + let cfg = modelInfo.bimCfg; + if (cfg && cfg.hideParts) { + cfg.hideParts.forEach((it) => { + hideParts.push({ + featureId:"clip"+it.featureId + }); + }); + } + } + api.Model.setVisible("clip"+modelId, false); + cb && cb(hideParts); + }, + direction + ); +} + function addModelList(api, bimCfg, modelList, cb) { let allHideParts = []; let cnt = 0; @@ -325,7 +386,7 @@ function resetScene(that, api) { api.Camera.stopViewPortRoam(); api.Camera.stopImmersiveRoam(); } - } catch (e) {} + } catch (e) { } api.Model.location(api.m_model.keys().toArray()[0]); if (!that.bimCfg.clientApi) { api.Plugin.deleteMiniMap(); @@ -344,10 +405,10 @@ function resetScene(that, api) { } } // 添加无操作检测相关方法 -function initIdleDetection(that, apiName,timeOut) { +function initIdleDetection(that, apiName, timeOut) { that.idleTimer = null; that.idleTime = 0; - that.maxIdleTime = timeOut||60*5; + that.maxIdleTime = timeOut || 60 * 5; that.isAutoRotate = false; // 清除已有的定时器 @@ -360,10 +421,10 @@ function initIdleDetection(that, apiName,timeOut) { // 设置定时器,每秒检查一次 that.idleTimer = setInterval(() => { - if(!that.isAutoRotate){ - that.idleTime++; + if (!that.isAutoRotate) { + that.idleTime++; } - console.log("--->",that.idleTime,that.maxIdleTime) + console.log("--->", that.idleTime, that.maxIdleTime) // 如果达到最大空闲时间,执行自动旋转 if (that.idleTime >= that.maxIdleTime && !that.isAutoRotate) { autoRotate(that, apiName); @@ -371,7 +432,7 @@ function initIdleDetection(that, apiName,timeOut) { }, 1000); // 监听用户操作事件,重置空闲时间 - resetIdleEvents(that,apiName); + resetIdleEvents(that, apiName); } function destroyRouter(that) { @@ -451,5 +512,6 @@ export default { hideParts, addModelList, initIdleDetection, - destroyRouter + destroyRouter, + loadClipModel }; diff --git a/yanzhu-bigscreen/src/views/bim/briefingTools.js b/yanzhu-bigscreen/src/views/bim/briefingTools.js index 87ff8538..88fa7c6a 100644 --- a/yanzhu-bigscreen/src/views/bim/briefingTools.js +++ b/yanzhu-bigscreen/src/views/bim/briefingTools.js @@ -223,7 +223,7 @@ function measurementArea(that) { } //构件体积 -function measuringVolume(that) {} +function measuringVolume(that) { } //构件距离--客户端渲染 function distanceClient(that) { let api = bimBriefingApi; @@ -301,15 +301,35 @@ function getModels(that) { function closeClientClipping(that) { let api = bimBriefingApi; if (that.clipState && that.clip) { + that.models.forEach(it => { + api.Model.setVisible(it.modelId, true); + api.Model.setVisible("clip" + it.modelId, false); + }); + if (that.bimCfg.showGis) { + api.Public.setGisState(true); + api.viewer.terrainProvider = Cesium.createWorldTerrain({ + requestVertexNormals: true, //开启地形光照 + requestWaterMask: true, // 开启水面波纹 + }); + } that.clipState = false; that.clip.remove(123456); - that.clip=null; + that.clip = null; + that.resetScene(); } } //剖切 -- 客户端渲染 function initClientClipping(that) { let api = bimBriefingApi; - let models = that.models.map((it) => it.modelId); + that.models.forEach(it => { + api.Model.setVisible(it.modelId, false); + api.Model.setVisible("clip" + it.modelId, true); + }); + if (that.bimCfg.showGis) { + api.Public.setGisState(false) + } + let models = that.models.map((it) => "clip" + it.modelId); + api.Model.location(models[0]); closeClientClipping(that); that.$message.info("鼠标左键点击轴线进行操作!"); that.clipState = true; @@ -325,19 +345,21 @@ function initClientClipping(that) { outline: !0, outlineColor: Cesium.Color.WHITE, planeColor: Cesium.Color.WHITE.withAlpha(0.1), - scalar: [1, 1, 1] - + scalar: [1, 1, 1] + }, HelperLineWidth: 10, }); } //剖切 -- 服务端渲染 function initClipping(that) { + console.log("---->initClipping") let api = bimBriefingApi; api.Public.clearHandler(); api.Measurement.clearAllTrace(); if (that.isClient) { initClientClipping(that); + //that.clipShow(); return; } api.Model.clipByBox(getModels(that)); diff --git a/yanzhu-bigscreen/src/views/bimBriefing.vue b/yanzhu-bigscreen/src/views/bimBriefing.vue index 4540732c..0e6c7332 100644 --- a/yanzhu-bigscreen/src/views/bimBriefing.vue +++ b/yanzhu-bigscreen/src/views/bimBriefing.vue @@ -12,30 +12,15 @@ 模型结构树
+ | ||
---|---|---|
{{ item2.name }} | -+ |
{{ item2.value }}
米
米2
@@ -139,31 +108,16 @@
-
-
+
+
+
+
+
+
+
+ |