From 8b6f89bf8f551d47a3e39b6bcce7daa7af4faaa9 Mon Sep 17 00:00:00 2001 From: "lj7788@126.com" Date: Tue, 29 Jul 2025 17:42:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BE=E7=89=8C=E9=AA=8C=E6=94=B6+BIM=20WebG?= =?UTF-8?q?L=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yanzhu-bigscreen/public/index.html | 9 +- yanzhu-bigscreen/src/views/bim/apiTools.js | 43 +++++++ yanzhu-bigscreen/src/views/bim/bim4DTools.js | 35 +++++- yanzhu-bigscreen/src/views/bim/bimTools.js | 20 ++- .../src/views/bim/briefingTools.js | 26 ++-- yanzhu-bigscreen/src/views/bim/sapiTools.js | 65 ++++++++++ .../src/views/bim4DSimulation.vue | 24 ++-- yanzhu-bigscreen/src/views/bimBriefing.vue | 41 ++++-- yanzhu-bigscreen/src/views/bimManage.vue | 119 ++++-------------- yanzhu-bigscreen/src/views/bimRoaming.vue | 96 +++++--------- yanzhu-bigscreen/vue.config.js | 12 +- .../src/main/resources/logback.xml | 2 +- yanzhu-ui-vue3/index.html | 13 +- .../views/bim/bimSetting/ModelFloorTree.vue | 13 +- .../src/views/bim/bimSetting/MoveModel.vue | 11 +- .../src/views/bim/bimSetting/apiTools.js | 5 +- .../src/views/bim/bimSetting/index.vue | 35 ++++-- .../src/views/bim/bimSetting/sapiTools.js | 55 ++++---- .../src/views/manage/projectChecked/index.vue | 2 +- yanzhu-ui-vue3/vite.config.js | 4 +- 20 files changed, 359 insertions(+), 271 deletions(-) create mode 100644 yanzhu-bigscreen/src/views/bim/apiTools.js create mode 100644 yanzhu-bigscreen/src/views/bim/sapiTools.js diff --git a/yanzhu-bigscreen/public/index.html b/yanzhu-bigscreen/public/index.html index 7f78b80e..5d912ad3 100644 --- a/yanzhu-bigscreen/public/index.html +++ b/yanzhu-bigscreen/public/index.html @@ -27,11 +27,12 @@ - + - - - + + + + diff --git a/yanzhu-bigscreen/src/views/bim/apiTools.js b/yanzhu-bigscreen/src/views/bim/apiTools.js new file mode 100644 index 00000000..5b8ec871 --- /dev/null +++ b/yanzhu-bigscreen/src/views/bim/apiTools.js @@ -0,0 +1,43 @@ + function loadEngine(that,elId,apiName,cb) { + let opt = { + container: elId, //[必须]容器id + showfps: false, //[可选]显示fps + openearth: true, //[可选]开启gis场景 + // imageryprovider: "tianditu_image", //[可选]gis底图 + openterrain: false, //[可选]开启gis地形 + maxspaceerror: 5000, //[可选]模型可视距离; 建议设置:常规BIM时3000或更大、BIM启用LOD时100~1000、倾斜摄影,点云数据时0.1~0.5 + loading: false, //[可选]gis模式加载动画 + bgcolor: "#87CEFA", //[可选]bim模式场景背景色 + selectedcolor: "#FFFF00", //[可选]选中构件颜色 + throughwall: true, //[可选]相机是否穿墙 + sitepath: "/cdn/Cesium/",//[可选]设置天空盒路径,指向Cesium文件夹 + editmode: true, //[可选]是否开启编辑模式 + searchbox: true, //[可选]gis模型是否显示搜索框 + mapbox: true, //[可选]gis模型是否显示地图选择 + isRequestWebgl2: true, //[可选]是否使用webgl2进行渲染 + colorBlendMode: 1, //0:HIGHLIGHT 1:REPLACE 2:MIX ,构件选中后的着色模式 + secretkey: window.config.secretKey, + language: "zh-CN", // 语言国际化 中文简体(zh-CN)、中文繁体(zh-TW)、英文(en), 默认中文简体 + targetFrameRate: 20, //目标渲染帧率 默认20 + }; + window[apiName] = new API(opt); + console.log("初始化成功(client)"); + let api = window[apiName] + setTimeout(() => { + if (that.bimCfg.showGis) { + that.showGis = true; + api.Public.setGisState(true); + api.viewer.terrainProvider = Cesium.createWorldTerrain({ + requestVertexNormals: true, //开启地形光照 + requestWaterMask: true, // 开启水面波纹 + }) + } else if (that.bimCfg.background) { + api.Public.setGisState(false, that.bimCfg.background); + } + cb && cb(); + }, 10); + } + +export default { + loadEngine +} \ No newline at end of file diff --git a/yanzhu-bigscreen/src/views/bim/bim4DTools.js b/yanzhu-bigscreen/src/views/bim/bim4DTools.js index a4d73db6..d9935ebc 100644 --- a/yanzhu-bigscreen/src/views/bim/bim4DTools.js +++ b/yanzhu-bigscreen/src/views/bim/bim4DTools.js @@ -1,4 +1,6 @@ import bimTools from "./bimTools"; +import apiTools from './apiTools.js' +import sapiTools from './sapiTools.js' const options = { taskMapping: { @@ -143,8 +145,20 @@ const ganttStyle = { stroke: "#000000A0", }, }; - function initEngine(that) { + if (that.isClient()) { + apiTools.loadEngine(that, "bim4DContainer", 'bim4DApi', + () => { + initLoadModel(that); + } + ) + } else { + sapiTools.loadEngine(that, "bim4DContainer", 'bim4DApi', () => { + initLoadModel(that); + }) + } +} +function initEngine2(that) { console.log("开始初始化引擎"); window.bim4DApi = new SAPI( { @@ -221,6 +235,7 @@ function initLoadModel(that) { .then((d) => { that.models = (d.rows || []).map((it) => { it.modelId = it.lightweightName; + it.bimCfg = that.$tryToJson(it.bimConfig || "{}", {}); it.visible = false; it.checked = true; it.gis = that.$tryToJson(it.gisJson || "{}", {}); @@ -242,6 +257,15 @@ function initLoadModel(that) { 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.isClient()) { + url = `/bimdata/Tools/output/model/${modelId}/root.glt`; + if (modelInfo) { + direction = modelInfo.bimCfg.direction; + } + } + console.log(modelId, url); api.Model.add( url, @@ -252,7 +276,11 @@ function addModel(that, modelId, cb) { console.log("加载模型成功"); setTimeout(() => { if (that.viewPoint) { - api.Camera.setViewPort(that.viewPoint); + if (that.viewPoint.world) { + if (!that.isClient()) { + api.Camera.setViewPort(that.viewPoint); + } + } } else { api.Camera.getViewPort((p) => { that.viewPoint = p; @@ -268,7 +296,8 @@ function addModel(that, modelId, cb) { }; fnInit(); }, 1000); - } + }, + direction ); } diff --git a/yanzhu-bigscreen/src/views/bim/bimTools.js b/yanzhu-bigscreen/src/views/bim/bimTools.js index e911b42d..d8c995f7 100644 --- a/yanzhu-bigscreen/src/views/bim/bimTools.js +++ b/yanzhu-bigscreen/src/views/bim/bimTools.js @@ -85,10 +85,28 @@ function initHideParts(that, api) { hideFn(); } +function resetScene(that, api) { + that.selectedViewpoint = null; + that.selectedRoam = null; + api.Camera.stopImmersiveRoam(); + api.Model.location(api.m_model.keys().toArray()[0]); + if (!that.isClient()) { + api.Plugin.deleteMiniMap(); + } + if (that.viewPoint) { + if (that.viewPoint.world) { + if (!that.isClient()) { + api.Camera.setViewPort(that.viewPoint); + } + } + } +} + export default { initBimCfg, initBimGis, initLoadModel, initModelPosition, - initHideParts + initHideParts, + resetScene } \ No newline at end of file diff --git a/yanzhu-bigscreen/src/views/bim/briefingTools.js b/yanzhu-bigscreen/src/views/bim/briefingTools.js index d6b90f85..ec7463ae 100644 --- a/yanzhu-bigscreen/src/views/bim/briefingTools.js +++ b/yanzhu-bigscreen/src/views/bim/briefingTools.js @@ -132,7 +132,7 @@ function measurementArea(that) { } //构件体积 -function measuringVolume(that) {} +function measuringVolume(that) { } //构件距离 function distance(that) { let api = bimBriefingApi; @@ -189,10 +189,10 @@ function actorVisible(that) { let modelId = featureId.split("^")[0]; api.Feature.setVisible(featureId, false); that.hideFeatureIds.push({ - show:false, - id:featureId.split("^")[1], - modelId:modelId, - featureId:featureId + show: false, + id: featureId.split("^")[1], + modelId: modelId, + featureId: featureId }); } }); @@ -202,13 +202,17 @@ function clearEvent(that) { let api = bimBriefingApi; if (api) { actorShow(that); - api.Feature.getByEvent(false); + if (!that.isClient()) { + api.Feature.getByEvent(false); + api.Model.clearBoundsBox(); + + api.Measurement.setFaceToFaceState(!1); + + api.Measurement.setPointToFaceVerticalDistanceState(!1); + + api.Public.clearAllDrawObject(); + } api.Model.closeClip(); - api.Model.clearBoundsBox(); - api.Measurement.setFaceToFaceState(!1); - api.Measurement.setPointToFaceVerticalDistanceState(!1); - api.Public.clearAllDrawObject(); - api.Feature.getByEvent(!1); api.Measurement.angle(!1); api.Measurement.distance(!1); api.Measurement.clearAllTrace(); diff --git a/yanzhu-bigscreen/src/views/bim/sapiTools.js b/yanzhu-bigscreen/src/views/bim/sapiTools.js new file mode 100644 index 00000000..73012436 --- /dev/null +++ b/yanzhu-bigscreen/src/views/bim/sapiTools.js @@ -0,0 +1,65 @@ +function loadEngine(that, elId, apiName, cb) { + console.log("开始初始化..."); + window[apiName] = new SAPI( + { + serverIP: window.config.serverIP, //服务ip地址 + port: window.config.port, //HTTP端口 + useHttps: window.config.useHttps, //使用Https + container: elId, //[必须]容器id + secretKey: window.config.secretKey, + openEarth: window.config.openEarth, //[可选]开启Gis场景 + bgColor: window.config.bgColor, //[可选]bim场景背景色, 传值即为纯色天空盒 + tintColor: window.config.tintColor, //[可选]osgb单体化颜色 + sceneTime: window.config.sceneTime, //[可选]分别为当前时间、日出时间、日落时间 + cadMode: window.config.cadMode, // 是否是Cad图纸预览模式 + }, + () => { + that.initSuccess = true; + console.log("初始化成功"); + setTimeout(() => { + cb && cb(); + }, 1000); + let mapOptions = { + imgs: { + // 六面图片 + top: "/cdn/bim/sapi/img/top.png", + bottom: "/cdn/bim/sapi/img/under.png", + east: "/cdn/bim/sapi/img/east.png", + south: "/cdn/bim/sapi/img/south.png", + west: "/cdn/bim/sapi/img/west.png", + north: "/cdn/bim/sapi/img/north.png", + }, + offset: { + // 屏幕坐标偏移 + corner: GLENavigationCube.RightTop, + x: 25, + y: 20, + }, + cube: { + hoverColor: "#7193dc", // 立方导航快鼠标移过显示颜色 + size: 32, // 导航立方尺寸 + hotPointSize: 7, // 导航立方棱角热点区域尺寸 + cubeTextColor: "#4c4c4ccc", // cube 各个面文字颜色 + cubeStrokeColor: "#374769cc", // cube 各个面边框颜色 + cubeFillColor: "#374769cc", // cube 各个面填充颜色 + }, + zoomRatios: 1, // 缩放倍率 + show: true, // 是否显示 + showAxes: true, // 是否显示XYZ轴线 + }; + let api = window[apiName] + api.Plugin.initNavCube(mapOptions); + if (that.bimCfg.showGis) { + api.Public.setGisState(true); + api.Public.setTerrainState(false, "/cdn/Cesium/layer.json", false) + api.Public.setGisState(true); + } else if (that.bimCfg.background) { + api.Public.setGisState(false, that.bimCfg.background); + } + } + ); +} + +export default { + loadEngine +} \ No newline at end of file diff --git a/yanzhu-bigscreen/src/views/bim4DSimulation.vue b/yanzhu-bigscreen/src/views/bim4DSimulation.vue index baa56f3a..e9396c9e 100644 --- a/yanzhu-bigscreen/src/views/bim4DSimulation.vue +++ b/yanzhu-bigscreen/src/views/bim4DSimulation.vue @@ -5,10 +5,7 @@
-
- - -
+
@@ -18,6 +15,10 @@
+
+ + +