operationModel.vue 28 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043
  1. <template>
  2. <div id="distribution" class="distribution-index">
  3. <div class="left-button" v-if="!isWalk">
  4. <div :class="'menu-item pangmenzhengdao' + (node.id == pathNode.id ? ' active' :'')"
  5. v-for="(node,index) in titleList" :key="node.id" @click="selectItem(node)">
  6. {{node.name}}
  7. </div>
  8. <!-- <div class="menu-item pangmenzhengdao" @click="getWalk">记录</div> -->
  9. <!-- <div class="menu-item pangmenzhengdao" @click="getCamera">视角</div> -->
  10. </div>
  11. <div class="walk-box" v-else>
  12. <div class="walk-box-item">
  13. <i :class="'iconfont '+ (stop ? 'huifont-bofang':'huifont-bofangzanting')" @click="startWalk"></i>
  14. </div>
  15. <div>
  16. <el-button type="primary" size="medium" @click="stopWalkFunc">退出</el-button>
  17. </div>
  18. </div>
  19. <div :id="'previewBim'+_uid" class="previewBim"></div>
  20. <div id="distribution-drap" class="distribution-drap" v-show="drapShow" @mousedown="dragStart"
  21. @touchstart="dragStart">
  22. <div class="distribution-drap-title">
  23. <div id="title" class="distribution-drap-title-content">{{detail.title}}</div>
  24. <i id="close" class="el-icon-circle-close" @click="drapShow = false"></i>
  25. </div>
  26. <div class="distribution-drap-content">
  27. <div class="user-list">
  28. <div class="user-item" v-for="(item,index) in detail.list">
  29. <div class="user-key">{{item.name}}</div>
  30. <div class="user-value" v-if="item.value === 'operation'">
  31. <el-switch v-model="value" active-color="#13ce66">
  32. </el-switch>
  33. </div>
  34. <div class="user-value" :title="item.value" v-else>
  35. <span v-if="item.value === '元重构人工智能科技(上海)有限公司'" class="color-blue"
  36. @click="open('1')">{{item.value}}</span>
  37. <span v-else-if="item.name === '设备名称'" class="color-blue"
  38. @click="open('2')">{{item.value}}</span>
  39. <span v-else>{{item.value}}</span>
  40. </div>
  41. </div>
  42. </div>
  43. </div>
  44. <div class="image-box" v-if="detail.imageUrl">
  45. <img :src="detail.imageUrl" alt="aa.png" />
  46. <div class="video-mask" v-if="detail.title === '监控信息'" @click="isVideo = true">
  47. <i class="iconfont huifont-shuzhuangcaidanxiala"></i>
  48. </div>
  49. </div>
  50. <div style="padding: 5px;" v-else></div>
  51. </div>
  52. <el-dialog :close-on-click-modal="false" :title="type === '1' ? '企业看板':'设备看板'" :visible.sync="modelVisible"
  53. width="1100px" :append-to-body="true">
  54. <notice-board v-if="modelVisible" :type="type"></notice-board>
  55. </el-dialog>
  56. <div class="video-toggle" v-if="isVideo">
  57. <div class="chart-title">
  58. <div>监控</div>
  59. <i class="el-icon-close" @click="isVideo = false"></i>
  60. </div>
  61. <div class="video-toggle-box">
  62. <img style="width: 100%;height: 100%;"
  63. src="https://file-node.oss-cn-shanghai.aliyuncs.com/youji/d8f0a8b4bd2043dfb8058d92763e57b0"
  64. alt="" />
  65. </div>
  66. </div>
  67. </div>
  68. </template>
  69. <script>
  70. import {
  71. getBimViewToken,
  72. } from '@/httpApi/bim'
  73. import bimView from '@/uitls/controls'
  74. // import bimData from '@/config/demo'//新华医院
  75. // import bimData from '@/config/demo2'
  76. import bimData from '@/config/demo1'
  77. import noticeBoard from '@/components/work/common/noticeBoard'
  78. export default {
  79. data() {
  80. return {
  81. roomId: 100,
  82. bimViewer: null,
  83. positionData: [],
  84. titleList: [{
  85. id: 1,
  86. name: '企业'
  87. }, {
  88. id: 2,
  89. name: '监控'
  90. }, {
  91. id: 3,
  92. name: '空调'
  93. }, {
  94. id: 4,
  95. name: '灯光'
  96. }, {
  97. id: 5,
  98. name: '漫游'
  99. }],
  100. pathNode: {
  101. id: 1,
  102. name: '企业'
  103. },
  104. renderSuccess: false,
  105. isWalk: false,
  106. walk: [{
  107. "id": "45989e46-5279-4256-b956-4134968f229f",
  108. "position": {
  109. "x": 28807.993915330604,
  110. "y": 27399.352876051573,
  111. "z": 16738.5117384898
  112. },
  113. "target": {
  114. "x": -65426.025574263804,
  115. "y": 30224.66289488717,
  116. "z": 16738.522116432978
  117. },
  118. "coordinateSystem": "world",
  119. "stayTime": 0,
  120. "timeBetweenFrames": 4
  121. }, {
  122. "id": "932ba4e5-8e61-47a9-9e95-106eb68b6179",
  123. "position": {
  124. "x": 23429.310851444443,
  125. "y": 27560.61573240541,
  126. "z": 16738.51233084135
  127. },
  128. "target": {
  129. "x": -70804.70863814997,
  130. "y": 30385.92575124101,
  131. "z": 16738.522708784523
  132. },
  133. "coordinateSystem": "world",
  134. "stayTime": 0,
  135. "timeBetweenFrames": 2
  136. }, {
  137. "id": "d6a69146-0fa4-4b96-8823-5a6acb93df10",
  138. "position": {
  139. "x": 21270.373381191373,
  140. "y": 27944.435752543206,
  141. "z": 16738.513740691003
  142. },
  143. "target": {
  144. "x": 11449.311926122491,
  145. "y": -64824.15181454667,
  146. "z": 16738.152764310379
  147. },
  148. "coordinateSystem": "world",
  149. "stayTime": 1,
  150. "timeBetweenFrames": 6
  151. }, {
  152. "id": "6f76a823-5b9a-478b-88d1-8cc701f48d91",
  153. "position": {
  154. "x": 20792.50087657239,
  155. "y": 13841.412598430225,
  156. "z": 16738.461937394382
  157. },
  158. "target": {
  159. "x": 18038.03011945137,
  160. "y": -79397.87720835117,
  161. "z": 16738.0364486589156
  162. },
  163. "coordinateSystem": "world",
  164. "stayTime": 0,
  165. "timeBetweenFrames": 2
  166. }, {
  167. "id": "9afa7778-a500-4707-8576-a25cec8710b3",
  168. "position": {
  169. "x": 20653.4160327832,
  170. "y": 13408.877024051308,
  171. "z": 16738.460348602504
  172. },
  173. "target": {
  174. "x": 112398.1176970292,
  175. "y": 2548.198234651193,
  176. "z": 16738.5192830622163
  177. },
  178. "coordinateSystem": "world",
  179. "stayTime": 1,
  180. "timeBetweenFrames": 4
  181. }, {
  182. "id": "bd51d05f-287d-45b9-addc-9da32d0e79f8",
  183. "position": {
  184. "x": 30968.639340308415,
  185. "y": 13085.285430882526,
  186. "z": 16738.459159984213
  187. },
  188. "target": {
  189. "x": 122900.33170996535,
  190. "y": 19518.523647883958,
  191. "z": 16738.434953464723
  192. },
  193. "coordinateSystem": "world",
  194. "stayTime": 0,
  195. "timeBetweenFrames": 2
  196. }, {
  197. "id": "bf6e4d38-74e2-4f51-83d3-20a7f16cdf56",
  198. "position": {
  199. "x": 32211.266434023968,
  200. "y": 13275.842610296175,
  201. "z": 16738.459859939816
  202. },
  203. "target": {
  204. "x": 30902.284349220965,
  205. "y": 105501.28094759125,
  206. "z": 16738.3274521968156
  207. },
  208. "coordinateSystem": "world",
  209. "stayTime": 1,
  210. "timeBetweenFrames": 12
  211. }, {
  212. "id": "6b309ba7-6044-41fb-815e-e878692fc437",
  213. "position": {
  214. "x": 32401.761864596003,
  215. "y": 44931.81365916862,
  216. "z": 16738.57613881422
  217. },
  218. "target": {
  219. "x": 33065.36397610181,
  220. "y": 137450.0034069327,
  221. "z": 16738.5592527883905
  222. },
  223. "coordinateSystem": "world",
  224. "stayTime": 1,
  225. "timeBetweenFrames": 2
  226. }],
  227. wt: null,
  228. stop: true,
  229. drapShow: false,
  230. detail: {
  231. title: '',
  232. list: [],
  233. imageUrl: ''
  234. },
  235. value: true,
  236. type: '1',
  237. modelVisible: false,
  238. isVideo: false,
  239. }
  240. },
  241. mounted() {
  242. let width = document.getElementById('distribution').clientWidth;
  243. document.getElementById('distribution-drap').style.left = (width - 330) + 'px';
  244. document.getElementById('distribution-drap').style.top = '30px';
  245. this.init();
  246. },
  247. beforeDestroy() {
  248. if (this.bimViewer) this.bimViewer.destroy();
  249. },
  250. components: {
  251. noticeBoard
  252. },
  253. methods: {
  254. dragStart(evt) {
  255. let oEvent = evt || event; //获取事件对象,这个是兼容写法
  256. if (oEvent.target.id !== 'title') return;
  257. let div = document.getElementById('distribution-drap');
  258. let disX = oEvent.clientX - parseInt(div.style.left || 0);
  259. let disY = oEvent.clientY - parseInt(div.style.top || 0);
  260. div.style.left = oEvent.clientX - disX + 'px';
  261. div.style.top = oEvent.clientY - disY + 'px';
  262. document.onmousemove = function(evt) { //实时改变目标元素obox的位置
  263. let oEvent = evt || event;
  264. div.style.left = oEvent.clientX - disX + 'px';
  265. div.style.top = oEvent.clientY - disY + 'px';
  266. }
  267. //停止拖动
  268. document.onmouseup = function() {
  269. document.onmousemove = null;
  270. document.onmouseup = null;
  271. }
  272. },
  273. showDrap(type) {
  274. this.detail = bimData[type];
  275. this.drapShow = true;
  276. },
  277. getWalk() {
  278. let walk = this.bimViewer.getWalkthroughData();
  279. this.walk.push(walk);
  280. },
  281. startWalk() {
  282. if (!this.bimViewer) return;
  283. if (!this.stop) return this.pauseWalk();
  284. if (this.wt) {
  285. this.stop = false;
  286. this.wt.play();
  287. return;
  288. }
  289. this.wt = this.bimViewer.walkthrough();
  290. this.wt.setKeyFrames(this.walk);
  291. this.wt.setKeyFrameCallback(this.keyFrameCallback);
  292. this.wt.stopCallback(() => {
  293. this.wt = null;
  294. this.stop = true;
  295. this.bimViewer.clearDrawable();
  296. });
  297. this.wt.play();
  298. this.stop = false;
  299. },
  300. pauseWalk() { //暂停漫游
  301. if (!this.wt) return;
  302. this.wt.pause();
  303. this.stop = true;
  304. },
  305. stopWalk() {
  306. if (!this.wt) return;
  307. this.wt.stop();
  308. },
  309. keyFrameCallback(idx) {
  310. this.bimViewer.clearDrawable();
  311. switch (idx) {
  312. case 0:
  313. this.setWalkTip([{
  314. "x": 24050.411537689757,
  315. "y": 29350.017590535575,
  316. "z": 17302.099026757893
  317. }, {
  318. "x": 23995.61377426047,
  319. "y": 25650.002239992325,
  320. "z": 17335.244453548836
  321. }],
  322. `<div class="tips-11">
  323. <div class="title">
  324. <img src="https://file-node.oss-cn-shanghai.aliyuncs.com/youji/34e112ef844245d79d500d120d256fbf" alt="">
  325. <div class="name">电梯</div>
  326. </div>
  327. <div class="content">
  328. <div class="item">
  329. <div class="label">状态:</div>
  330. <div class="value">运行中</div>
  331. </div>
  332. <div class="item">
  333. <div class="label">维护:</div>
  334. <div class="value">今日已检修</div>
  335. </div>
  336. </div>
  337. </div>`,
  338. -220, -40, 3
  339. );
  340. break;
  341. case 2:
  342. this.setWalkTip([{
  343. "x": 22000.02194219269,
  344. "y": 18556.11888764512,
  345. "z": 16860.98452689552
  346. }],
  347. `<div class="tips-9">
  348. <div class="line" style="width:48px;"><img src="https://static.bimface.com/attach/24ce9654e88a4218908f46279e5c4b04_line.png" height="35" width="49"/></div>
  349. <div class="article">
  350. <div class="title">
  351. <i class="iconfont huifont-shuzhuangcaidanxiala"></i>
  352. 1202
  353. </div>
  354. <div class="content">
  355. <div class="item">
  356. <div class="label">温度</div>
  357. <div class="value">16°C</div>
  358. </div>
  359. <div class="item">
  360. <div class="label">湿度</div>
  361. <div class="value">30%</div>
  362. </div>
  363. <div class="item">
  364. <div class="label">CO2</div>
  365. <div class="value">15ppm</div>
  366. </div>
  367. <div class="item">
  368. <div class="label">Tvoc</div>
  369. <div class="value">1.5ppm</div>
  370. </div>
  371. <div class="item">
  372. <div class="label">PM2.5</div>
  373. <div class="value">2.3ug/m3</div>
  374. </div>
  375. </div>
  376. </div>`,
  377. 0, -40, 2
  378. );
  379. this.setWalkTip([{
  380. "x": 22000.02194219269,
  381. "y": 21593.121086217907,
  382. "z": 16482.919997783156
  383. }],
  384. `<div class="tips-5" style="width:180px;">
  385. <div class="title"><i class="iconfont huifont-shuzhuangcaidanxiala"></i>照明设备</div>
  386. <div class="content">
  387. <div class="tips-6">
  388. <div class="item">
  389. <div class="label">灯光名称</div>
  390. <div class="value">1号照明</div>
  391. </div>
  392. <div class="item">
  393. <div class="label">灯光位置</div>
  394. <div class="value">走廊</div>
  395. </div>
  396. <div class="item">
  397. <div class="label">灯光操作</div>
  398. <div class="value">
  399. <label class="hui-switch">
  400. <input type="checkbox" id="myCheckbox">
  401. <span class="slider round"></span>
  402. </label>
  403. </div>
  404. </div>
  405. </div>
  406. </div>
  407. </div>
  408. `,
  409. 0, -40, 1
  410. );
  411. break;
  412. case 4:
  413. this.setWalkTip([{
  414. "x": 24409.083286761037,
  415. "y": 14149.986899588841,
  416. "z": 16842.24504298319
  417. }, {
  418. "x": 28737.64383719606,
  419. "y": 14149.986899588841,
  420. "z": 16881.492220074306
  421. }],
  422. `<div class="tips-9">
  423. <div class="line" style="width:48px;"><img src="https://static.bimface.com/attach/24ce9654e88a4218908f46279e5c4b04_line.png" height="35" width="49"/></div>
  424. <div class="article">
  425. <div class="title">
  426. <i class="iconfont huifont-shuzhuangcaidanxiala"></i>
  427. 1202
  428. </div>
  429. <div class="content">
  430. <div class="item">
  431. <div class="label">温度</div>
  432. <div class="value">16°C</div>
  433. </div>
  434. <div class="item">
  435. <div class="label">湿度</div>
  436. <div class="value">30%</div>
  437. </div>
  438. <div class="item">
  439. <div class="label">CO2</div>
  440. <div class="value">15ppm</div>
  441. </div>
  442. <div class="item">
  443. <div class="label">Tvoc</div>
  444. <div class="value">1.5ppm</div>
  445. </div>
  446. <div class="item">
  447. <div class="label">PM2.5</div>
  448. <div class="value">2.3ug/m3</div>
  449. </div>
  450. </div>
  451. </div>`,
  452. 0, -40, 2
  453. );
  454. break;
  455. case 6:
  456. this.setWalkTip([{
  457. "x": 31000.028548922273,
  458. "y": 19920.593446388877,
  459. "z": 16869.840184958644
  460. }, {
  461. "x": 31000.024545155615,
  462. "y": 24661.86466740186,
  463. "z": 16875.88203316609
  464. }],
  465. `<div class="tips-9">
  466. <div class="line" style="width:48px;"><img src="https://static.bimface.com/attach/24ce9654e88a4218908f46279e5c4b04_line.png" height="35" width="49"/></div>
  467. <div class="article">
  468. <div class="title">
  469. <i class="iconfont huifont-shuzhuangcaidanxiala"></i>
  470. 1202
  471. </div>
  472. <div class="content">
  473. <div class="item">
  474. <div class="label">温度</div>
  475. <div class="value">16°C</div>
  476. </div>
  477. <div class="item">
  478. <div class="label">湿度</div>
  479. <div class="value">30%</div>
  480. </div>
  481. <div class="item">
  482. <div class="label">CO2</div>
  483. <div class="value">15ppm</div>
  484. </div>
  485. <div class="item">
  486. <div class="label">Tvoc</div>
  487. <div class="value">1.5ppm</div>
  488. </div>
  489. <div class="item">
  490. <div class="label">PM2.5</div>
  491. <div class="value">2.3ug/m3</div>
  492. </div>
  493. </div>
  494. </div>`,
  495. 0, -40, 2
  496. );
  497. break;
  498. default:
  499. break;
  500. }
  501. },
  502. init() {
  503. getBimViewToken(bimData.fileId).then(this.successFunc);
  504. },
  505. selectItem(item) {
  506. this.drapShow = false;
  507. this.clearAll();
  508. if (item.id === 5) return this.setWalk();
  509. this.bimViewer.setStatus(bimData.cameraState);
  510. if (this.pathNode.id == item.id) return this.pathNode = {};
  511. this.pathNode = item;
  512. if (item.id === 1) this.setFloor();
  513. if (item.id === 2) this.setMonitor();
  514. if (item.id === 3) this.setDevice();
  515. if (item.id === 4) this.setLight();
  516. },
  517. clearAll() {
  518. if (!this.bimViewer) return;
  519. this.clearFloor();
  520. this.bimViewer.clear3DMaker();
  521. },
  522. setFloor() { //设置房间
  523. for (var i = 0; i < bimData.roomList.length; i++) {
  524. let boundary = bimData.roomList[i].boundary;
  525. let arrX = boundary.map(node => node.x);
  526. let arrY = boundary.map(node => node.y);
  527. let maxX = Math.max(...arrX);
  528. let minX = Math.min(...arrX);
  529. let maxY = Math.max(...arrY);
  530. let minY = Math.min(...arrY);
  531. let x = (maxX - minX) / 2 + minX;
  532. let y = (maxY - minY) / 2 + minY;
  533. if (bimData.roomList[i].name) {
  534. this.bimViewer.addDrawable({
  535. position: {
  536. x: x,
  537. y: y,
  538. z: boundary[0].z + bimData.roomList[i].height
  539. },
  540. offsetX: -75,
  541. offsetY: -40,
  542. html: ` <div class="tips-4">${bimData.roomList[i].name}<i class="iconfont huifont-sanjiaojiantou-xia"></i></div>`,
  543. id: 'room' + bimData.roomList[i].roomId
  544. }, data => {
  545. this.showDrap('organizationDetail');
  546. })
  547. }
  548. if (bimData.roomList[i].floorName) {
  549. this.bimViewer.addDrawable({
  550. position: {
  551. x: x,
  552. y: y,
  553. z: boundary[0].z + bimData.roomList[i].height
  554. },
  555. offsetX: -30,
  556. offsetY: 5,
  557. html: ` <div class="floor-name">${bimData.roomList[i].floorName}</div>`,
  558. id: 'floor' + bimData.roomList[i].roomId
  559. }, data => {
  560. let floor = data.id.split('floor');
  561. let item = bimData.roomList.find(node => node.roomId == floor[floor.length - 1]);
  562. if (item.floorName === '卫生间' || item.floorName === '公共区域' || item.floorName ===
  563. '楼梯间' || item.floorName === '电梯间' || item.floorName === '设备间') return;
  564. this.showDrap('roomDetail');
  565. })
  566. }
  567. }
  568. },
  569. clearFloor() { //清除房间
  570. let ids = bimData.roomList.filter(node => node.name).map(node => node.roomId);
  571. let arr = ids.map(id => 'room' + id);
  572. this.bimViewer.clearDrawable(arr);
  573. },
  574. setMonitor() { //设置摄像头
  575. for (var i = 0; i < bimData.monitorList.length; i++) {
  576. this.bimViewer.add3DMaker('image', bimData.monitorList[i],
  577. './assets/shexiangtou.png', (data) => {
  578. this.showDrap('monitorDetail');
  579. }, 'monitor' + i);
  580. }
  581. },
  582. setDevice() {
  583. for (var i = 0; i < bimData.deviceList.length; i++) {
  584. this.bimViewer.add3DMaker('image', bimData.deviceList[i],
  585. './assets/kongtiao.png', (data) => {
  586. this.showDrap('deviceDetail');
  587. }, 'device' + i);
  588. }
  589. },
  590. setLight() {
  591. for (var i = 0; i < bimData.deviceList.length; i++) {
  592. this.bimViewer.add3DMaker('image', bimData.deviceList[i],
  593. './assets/zhaoming.png', (data) => {
  594. this.showDrap('lightDetail');
  595. }, 'light' + i);
  596. }
  597. },
  598. open(type) {
  599. this.type = type;
  600. this.modelVisible = true;
  601. },
  602. setWalk() {
  603. this.isWalk = true;
  604. if (!this.bimViewer) return;
  605. this.bimViewer.setCamera({
  606. isPan: false,
  607. isRotate: false,
  608. isZoom: false
  609. })
  610. this.bimViewer.clearAllRooms();
  611. this.bimViewer.clearDrawable();
  612. this.bimViewer.setStatus({
  613. "name": "persp",
  614. "position": {
  615. "x": 28807.993915330604,
  616. "y": 27399.352876051566,
  617. "z": 16738.511738489797
  618. },
  619. "target": {
  620. "x": -65426.025574263804,
  621. "y": 30224.662894887166,
  622. "z": 16738.522116432974
  623. },
  624. "up": {
  625. "x": 0,
  626. "y": -0.0000036732051114073575,
  627. "z": 0.9999999999932537
  628. },
  629. "near": 9.86184145967756,
  630. "far": 26059.687483045527,
  631. "zoom": 3.075280565913524,
  632. "version": 1,
  633. "fov": 45,
  634. "aspect": 1.6274768824306474,
  635. "coordinateSystem": "world"
  636. });
  637. },
  638. stopWalkFunc() {
  639. this.bimViewer.setCamera({
  640. isPan: true,
  641. isRotate: true,
  642. isZoom: true
  643. })
  644. this.bimViewer.clearDrawable();
  645. this.isWalk = false;
  646. this.stopWalk();
  647. this.bimViewer.setStatus(bimData.cameraState);
  648. this.initFloor();
  649. if (this.pathNode.id === 1) this.setFloor();
  650. if (this.pathNode.id === 2) this.setMonitor();
  651. if (this.pathNode.id === 3) this.setDevice();
  652. if (this.pathNode.id === 4) this.setLight();
  653. },
  654. setWalkTip(data, html, x, y, type) {
  655. for (let i = 0; i < data.length; i++) {
  656. this.bimViewer.addDrawable({
  657. position: data[i],
  658. offsetX: x,
  659. offsetY: y,
  660. html: html,
  661. id: 'walktip' + type + i
  662. }, data => {
  663. if (type === 1) {
  664. this.showDrap('lightDetail');
  665. } else if (type === 2) {
  666. this.showDrap('roomDetail');
  667. } else if (type === 3) {
  668. this.showDrap('deviceDetail');
  669. }
  670. })
  671. }
  672. },
  673. returnRGBA(color) {
  674. let [r, g, b, a] = color.match(/\d+(\.\d+)?/g).map(Number);
  675. return {
  676. r,
  677. g,
  678. b,
  679. a
  680. }
  681. },
  682. getCamera() {
  683. if (!this.bimViewer) return;
  684. console.log(this.bimViewer.getCameraState());
  685. },
  686. setRoom(data) {
  687. let point = data.worldPosition;
  688. if (!point) return this.$message.warning('请点击模型范围内的点');
  689. this.positionData.push(point);
  690. this.bimViewer.add3DMaker('image', point);
  691. if (this.positionData.length == 3) {
  692. this.bimViewer.insertRooms({
  693. id: this.roomId,
  694. boundary: {
  695. "outer": this.positionData
  696. },
  697. height: 500,
  698. roomColor: this.returnRGBA('rgba(19, 206, 102, 0.6)')
  699. })
  700. this.bimViewer.clear3DMaker();
  701. this.positionData = [];
  702. this.bimViewer.editRoom({
  703. roomId: this.roomId
  704. })
  705. this.roomId++;
  706. }
  707. },
  708. successFunc(res) {
  709. if (res.state) {
  710. this.bimViewer = new bimView({
  711. dom: document.getElementById('previewBim' + this._uid),
  712. viewToken: res.data,
  713. roamAngle: bimData.roamAngle,
  714. initHomeViewer: bimData.cameraState,
  715. renderSuccess: () => {
  716. this.renderSuccess = true;
  717. this.bimViewer.setStatus(bimData.cameraState);
  718. // this.bimViewer.setToolbars(true);
  719. if (bimData.fileId == '10000892771892') this.modelRenderSuccess();
  720. if (bimData.fileId == '10000903243565') this.modelRenderSuccess2();
  721. },
  722. roomSaved: data => {
  723. console.log(data);
  724. },
  725. click: data => {
  726. console.log(data);
  727. // this.setRoom(data);
  728. }
  729. })
  730. }
  731. },
  732. modelRenderSuccess() {
  733. this.bimViewer.HideOthers();
  734. this.bimViewer.hideComponentsByObjectData([{
  735. "family": "TJ双扇平开门",
  736. "levelName": "A_4F(14.500)"
  737. }, {
  738. "family": "单扇推拉门",
  739. "levelName": "A_4F(14.500)"
  740. }, {
  741. "family": "TJ单扇平开门",
  742. "levelName": "A_4F(14.500)"
  743. }, {
  744. "family": "TJ子母门",
  745. "levelName": "A_4F(14.500)"
  746. }])
  747. this.bimViewer.overrideComponentsColorByObjectData([{
  748. "family": "楼板",
  749. "levelName": "A_4F(14.500)"
  750. }, {
  751. "family": "幕墙",
  752. "levelName": "A_4F(14.500)"
  753. }, {
  754. "family": "基本墙",
  755. "levelName": "A_4F(14.500)"
  756. }, {
  757. "family": "常规模型 39",
  758. "levelName": "A_4F(14.500)"
  759. }], "#cecece")
  760. this.initFloor();
  761. this.setFloor();
  762. },
  763. modelRenderSuccess2() {
  764. this.bimViewer.hideComponentsByObjectData([{
  765. categoryId: "-2000038",
  766. levelName: "标高 1"
  767. }])
  768. this.bimViewer.overrideComponentsColorByObjectData([{
  769. family: "楼板",
  770. levelName: "标高 1"
  771. }], "#cecece")
  772. this.bimViewer.overrideComponentsColorByObjectData([{
  773. family: "基本墙",
  774. levelName: "标高 1"
  775. }], "#afa6ab")
  776. this.initFloor();
  777. this.setFloor();
  778. },
  779. initFloor() {
  780. for (var i = 0; i < bimData.roomList.length; i++) {
  781. this.bimViewer.insertRooms({
  782. id: bimData.roomList[i].roomId,
  783. boundary: {
  784. "outer": bimData.roomList[i].boundary
  785. },
  786. height: bimData.roomList[i].height,
  787. roomColor: this.returnRGBA(bimData.roomList[i].color)
  788. })
  789. }
  790. }
  791. }
  792. }
  793. </script>
  794. <style lang="scss">
  795. .distribution-index {
  796. width: 100%;
  797. height: 100%;
  798. display: flex;
  799. flex-direction: column;
  800. position: relative;
  801. overflow: hidden;
  802. background: $--box-background;
  803. .video-toggle {
  804. position: fixed;
  805. width: 700px;
  806. height: 500px;
  807. background: #000;
  808. left: 50%;
  809. top: 50%;
  810. transform: translate(-50%, -50%);
  811. display: flex;
  812. flex-direction: column;
  813. z-index: 999;
  814. .chart-title {
  815. display: flex;
  816. justify-content: space-between;
  817. width: 100%;
  818. background-size: contain;
  819. position: relative;
  820. background-color: $--background;
  821. padding-left: 15px;
  822. align-items: center;
  823. .el-icon-close {
  824. padding: 8px;
  825. font-size: 24px;
  826. cursor: pointer;
  827. }
  828. }
  829. .chart-title:before {
  830. content: "";
  831. position: absolute;
  832. height: 2px;
  833. left: 0px;
  834. right: 0;
  835. border-bottom: 2px solid;
  836. -o-border-image: linear-gradient(315deg, rgba(167, 208, 255, 0), rgba(110, 163, 255, .3)) 2 2;
  837. border-image: linear-gradient(315deg, rgba(167, 208, 255, 0), rgba(110, 163, 255, .3)) 2 2;
  838. bottom: .5px;
  839. }
  840. .video-toggle-box {
  841. flex: 1;
  842. height: 0;
  843. display: flex;
  844. align-items: center;
  845. padding: 20px;
  846. box-sizing: border-box;
  847. }
  848. video {
  849. max-height: 100%;
  850. }
  851. }
  852. .tips-4 {
  853. cursor: pointer;
  854. }
  855. .floor-name {
  856. cursor: pointer;
  857. width: 60px;
  858. text-align: center;
  859. color: #fff;
  860. }
  861. .left-button {
  862. position: absolute;
  863. z-index: 998;
  864. display: flex;
  865. justify-content: center;
  866. left: 0;
  867. bottom: 30px;
  868. width: 100%;
  869. }
  870. .menu-item {
  871. width: 100px;
  872. height: 32px;
  873. font-size: 16px;
  874. color: #AAB5C7;
  875. line-height: 30px;
  876. letter-spacing: 2px;
  877. text-align: center;
  878. background-image: url(../../../assets/image/common/tab.png);
  879. background-size: 100% 100%;
  880. margin: 0 15px;
  881. cursor: pointer;
  882. }
  883. .menu-item.active,
  884. .menu-item:hover {
  885. color: #fff;
  886. background-image: url(../../../assets/image/common/tab_active.png);
  887. }
  888. .previewBim {
  889. flex: 1;
  890. height: 0;
  891. }
  892. .distribution-drap {
  893. position: absolute;
  894. top: 30px;
  895. right: 30px;
  896. background: $--color-background;
  897. width: 300px;
  898. border-radius: 8px;
  899. z-index: 998;
  900. right: 30px;
  901. top: 30px;
  902. .distribution-drap-title {
  903. height: 40px;
  904. display: flex;
  905. align-items: center;
  906. .distribution-drap-title-content {
  907. flex: 1;
  908. width: 0;
  909. font-weight: 500;
  910. cursor: move;
  911. padding-left: 10px;
  912. }
  913. .el-icon-circle-close {
  914. font-size: 20px;
  915. cursor: pointer;
  916. padding-right: 10px;
  917. }
  918. }
  919. .user-list {
  920. padding: 0 10px 0px 10px;
  921. font-size: 13px;
  922. .user-item {
  923. display: flex;
  924. margin-bottom: 2px;
  925. .user-value {
  926. flex: 1;
  927. width: 0;
  928. margin-left: 2px;
  929. overflow: hidden;
  930. white-space: nowrap;
  931. text-overflow: ellipsis;
  932. }
  933. }
  934. .user-item>div {
  935. background: #232A37;
  936. line-height: 34px;
  937. padding: 0 16px;
  938. }
  939. .user-item:last-child {
  940. margin-bottom: 0;
  941. }
  942. }
  943. .image-box {
  944. width: 100%;
  945. height: 150px;
  946. padding: 10px;
  947. box-sizing: border-box;
  948. position: relative;
  949. img {
  950. width: 100%;
  951. height: 100%;
  952. object-fit: cover;
  953. }
  954. .video-mask {
  955. position: absolute;
  956. top: 0;
  957. left: 0;
  958. right: 0;
  959. bottom: 0;
  960. background: rgba(0, 0, 0, 0.5);
  961. z-index: 2;
  962. display: flex;
  963. justify-content: center;
  964. align-items: center;
  965. opacity: 0;
  966. transition: 300ms;
  967. cursor: pointer;
  968. i {
  969. font-size: 24px;
  970. }
  971. }
  972. }
  973. .image-box:hover {
  974. .video-mask {
  975. opacity: 1;
  976. }
  977. }
  978. }
  979. .walk-box {
  980. position: absolute;
  981. bottom: 30px;
  982. left: 50%;
  983. margin-left: -80px;
  984. display: flex;
  985. align-items: center;
  986. z-index: 998;
  987. .walk-box-item {
  988. width: 80px;
  989. height: 80px;
  990. border-radius: 80px;
  991. background: #232A37;
  992. text-align: center;
  993. line-height: 80px;
  994. cursor: pointer;
  995. margin-right: 20px;
  996. &:hover {
  997. opacity: 0.7;
  998. }
  999. }
  1000. .iconfont {
  1001. font-size: 36px;
  1002. }
  1003. }
  1004. // .bf-house,
  1005. // .bf-tree-toolbar {
  1006. // display: none;
  1007. // }
  1008. }
  1009. </style>