import { ElMessage, ElTooltip } from 'element-plus'; //初始化 function initEngine(that) { window.api = new SAPI( { serverIP: window.config.serverIP, //服务ip地址 port: window.config.port, //HTTP端口 useHttps: window.config.useHttps, //使用Https container: "bimSettingContainer", //[必须]容器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("初始化成功"); 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轴线 }; api.Plugin.initNavCube(mapOptions); if (that.bimCfg.showGis) { that.showGis = true; that.doChangeGis(); } else if (that.bimCfg.background) { api.Public.setGisState(false, that.bimCfg.background); } } ); } //模型偏移管理 function doModelMove(that) { api.Public.pickupCoordinate(false); api.Public.event("LEFT_CLICK", (e) => { api.Feature.getByPosition([e.x, e.y], (n) => { if (n && n["id"]) { let modelId = n.id.split("^")[0]; that.showMove = true; that.modelId = modelId; that.$refs.moveModel.initData(modelId) } else { ElMessage.warning("请在模型上选点!"); } }); }); } //在地图上移动模型 function moveToPosition(that) { api.Public.event("LEFT_CLICK", ((n) => { api.Public.pickupCoordinate(true, ((n) => { console.log(n); api.Public.convertWorldToCartographicLocation(n, m => { api.Model.moveToPosition(m, 0, that.modelId) if (that.saveData.rotateZ != 0) { api.Model.rotate(that.saveData.x, that.saveData.y, that.saveData.rotateZ, that.modelId) } that.movePoint = m; }); } )) } )), api.Public.event("RIGHT_CLICK", ((n) => { api.Public.clearHandler(), api.Public.pickupCoordinate(false); ElMessage.info("已结束模型移动!"), that.activeMenu = -1; let pt = that.movePoint; that.form.x = pt[0] that.form.y = pt[1] that.form.z = pt[2] that.saveData.x = that.form.x; that.saveData.y = that.form.y; that.saveData.z = that.form.z; })); } export default { initEngine, doModelMove, moveToPosition }