index.vue 51 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334
  1. <template>
  2. <div class="container">
  3. <el-row id="earth" style="height: 100%; width: 100%; display: flex; position: relative">
  4. <el-col style="height: 100%; position: relative" :span="this.leftwidth">
  5. <div class="main-layout" v-on:mouseover="changeActive('2D')" @mousemove="getMouseLocation">
  6. <div id="2DcesiumContainer" class="map"></div>
  7. </div>
  8. </el-col>
  9. <el-col style="height: 100%; position: relative" :span="24 - this.leftwidth">
  10. <div class="main-layout" v-on:mouseover="changeActive('3D')" @mousemove="getMouseLocation">
  11. <div id="3DcesiumContainer" class="map"></div>
  12. </div>
  13. </el-col>
  14. <el-tabs type="border-card" v-model="activeName" tab-position="left" class="menu" :stretch="true"
  15. @tab-click="legendClick">
  16. <el-tab-pane name="fouth">
  17. <el-tooltip placement="right" effect="light" slot="label">
  18. <span slot="content" class="item">想定</span>
  19. <span><i class="el-icon-house"></i></span>
  20. </el-tooltip>
  21. <el-table :data="situation">
  22. <el-table-column label="名称" prop="xdname" width="150px"></el-table-column>
  23. <el-table-column label="操作" align="center">
  24. <template slot-scope="scope">
  25. <el-button type="primary" @click="getJson(scope.row)">导入</el-button>
  26. <!-- <el-button type="primary" @click="saveJson()">保存</el-button> -->
  27. </template>
  28. </el-table-column>
  29. </el-table>
  30. </el-tab-pane>
  31. <el-tab-pane name="fifth">
  32. <el-tooltip placement="right" effect="light" slot="label">
  33. <span slot="content" class="item">消息</span>
  34. <span><i class="el-icon-chat-line-round"></i></span>
  35. </el-tooltip>
  36. <el-table :data="messageList">
  37. <el-table-column label="序号" prop="order" width="50px"></el-table-column>
  38. <el-table-column label="时间" align="center" prop="time"></el-table-column>
  39. <el-table-column label="消息" align="center" prop="context"></el-table-column>
  40. </el-table>
  41. </el-tab-pane>
  42. </el-tabs>
  43. <div class="buttons">
  44. <el-button icon="el-icon-full-screen" circle @click="ismax()"></el-button>
  45. <el-button icon="el-icon-house" circle @click="home()"></el-button>
  46. <el-button icon="el-icon-plus" circle @click="big()"></el-button>
  47. <el-button icon="el-icon-minus" circle @click="small()"></el-button>
  48. </div>
  49. </el-row>
  50. <!-- <TimeLine :showLayers="showLayers" :timeDataArray="timeDataArray" class="TimeLine"></TimeLine> -->
  51. <div>
  52. <el-dialog title="模拟消息列表" :visible.sync="dialogVisible" width="50%">
  53. <el-table :data="messageList">
  54. <el-table-column label="序号" prop="order" width="50px"></el-table-column>
  55. <el-table-column label="时间" align="center" prop="time"></el-table-column>
  56. <el-table-column label="消息" align="center" prop="context"></el-table-column>
  57. </el-table>
  58. <div slot="footer" class="dialog-footer">
  59. <el-button @click="exportReport()">导出报告</el-button>
  60. <el-button @click="dialogVisible = false">关闭</el-button>
  61. </div>
  62. </el-dialog>
  63. </div>
  64. </div>
  65. </template>
  66. <script>
  67. import screenfull from "screenfull";
  68. import fireController from "@/api/fireController.js";
  69. import { getToken } from "@/utils";
  70. import axios from "axios";
  71. import satelliteModel from 'public/static/model/satelite1.glb';
  72. import TimeLine from '@/components/TimeLine/index.vue';
  73. import missileModel from 'public/static/model/basic_missle.glb';
  74. import centerModel from 'public/static/model/the_white_house.glb';
  75. import radarModel from 'public/static/model/radar.glb'
  76. import { mapGetters } from "vuex";
  77. import CesiumNavigation from 'cesium-navigation-es6/viewerCesiumNavigationMixin';
  78. export default {
  79. components: {
  80. TimeLine
  81. },
  82. computed: {
  83. ...mapGetters([
  84. "dimension"
  85. ])
  86. },
  87. data() {
  88. return {
  89. save: false,
  90. messageList: [],
  91. situation: [],
  92. nameIdList: [],
  93. satelliteRange: [],
  94. missileList: {},
  95. thaadList: {},
  96. finish: false,
  97. websocket: null,
  98. centerPosition: null,
  99. leftwidth: 12,
  100. unit: [],
  101. dialogVisible: false,
  102. satellite: [],
  103. center: [],
  104. move_data: {},
  105. order: 1,
  106. _viewer2D: null,
  107. _viewer3D: null,
  108. mousevalue: null,
  109. // 选中的点
  110. selectedMarker: null,
  111. // 以前的标记点坐标
  112. oldPosition: null,
  113. activeName: 'fouth',
  114. currentLab: {
  115. index: -1,
  116. isActive: false
  117. },
  118. url: "https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
  119. isShow: false,
  120. handler3D: null,
  121. handler2D: null,
  122. image: null,
  123. modeltooltip: null,
  124. id: 1,
  125. showLayers: null,
  126. timeDataArray: ['Time 1', 'Time 2', 'Time 3', 'Time 4'],
  127. jsonData: null,
  128. mapNavOptions: {
  129. // 用于在使用重置导航重置地图视图时设置默认视图控制。接受的值是Cesium.Cartographic 和Cesium.Rectangle.
  130. defaultResetView: this.Cesium.Cartographic.fromDegrees(110, 30, 2000000),
  131. // 罗盘
  132. enableCompass: true,
  133. // 缩放控件
  134. enableZoomControls: false,
  135. // 距离图例
  136. enableDistanceLegend: true,
  137. // 指南针外环
  138. enableCompassOuterRing: true
  139. }
  140. };
  141. },
  142. watch: {
  143. dimension: {
  144. handler: function (val, oldVal) {
  145. console.log(val)
  146. if (val == 2) {
  147. this.leftwidth = 24;
  148. } else if (val == 3) {
  149. this.leftwidth = 0;
  150. } else if (val == 5) {
  151. this.leftwidth = 12;
  152. }
  153. },
  154. },
  155. },
  156. activated() {
  157. this.getData();
  158. },
  159. mounted() {
  160. this.cesiumInit();
  161. // this.pointMove();
  162. // this.startWebSocket();
  163. },
  164. methods: {
  165. async getJson(row) {
  166. this.order = 1;
  167. this.messageList = [];
  168. this.nameIdList = [];
  169. this.satelliteRange = [];
  170. this.missileList = {};
  171. this.thaadList = {};
  172. let redunit = [];
  173. let blueunit = [];
  174. let satellite = [];
  175. let center = [];
  176. let fileInfoStr = row.xdfile;
  177. let fileInfoArr = JSON.parse(fileInfoStr);
  178. this.$data._viewer2D.entities.removeAll();
  179. this.$data._viewer3D.entities.removeAll();
  180. await axios
  181. .get("http://127.0.0.1:8084/admin/online/onlineOperation/downloadDatasource/main", {
  182. params: {
  183. datasourceId: "1656243335922192384",
  184. fieldName: "xdfile",
  185. asImage: false,
  186. dataId: row.id,
  187. filename: fileInfoArr[0].filename,
  188. Authorization: getToken(),
  189. MenuId: "1656244747347431424"
  190. }
  191. })
  192. .then((response) => {
  193. console.log('response.data :>> ', response.data);
  194. // // 处理成功的响应
  195. // jsonData = response.data
  196. blueunit = response.data.blueunit
  197. redunit = response.data.redunit
  198. satellite = response.data.satellite
  199. center = response.data.center
  200. this.save = true
  201. this.jsonData = {
  202. id: row.id,
  203. xdname: response.data.xdname,
  204. type: response.data.type,
  205. // creator: row.creator,
  206. createtime: response.data.createtime,
  207. bluecnt: response.data.bluecnt,
  208. target: response.data.target,
  209. starttime: response.data.starttime,
  210. steptime: response.data.steptime,
  211. endtime: response.data.endtime,
  212. blueunit: blueunit,
  213. redunit: redunit,
  214. satellite: satellite,
  215. center: center
  216. }
  217. this.setTimeLine(response.data.starttime, response.data.endtime, response.data.steptime)//传入时间到时间轴
  218. })
  219. .catch((error) => {
  220. // 处理错误
  221. console.error(error);
  222. });
  223. for (let i = 0; i < blueunit.length; i++) {
  224. this.markLocationbyJson(parseFloat(blueunit[i].pos.lat), parseFloat(blueunit[i].pos.lon), parseFloat(blueunit[i].pos.height), blueunit[i].name, "blue")
  225. }
  226. for (let i = 0; i < center.length; i++) {
  227. let item = center[i]
  228. this.markLocationbyJson(parseFloat(item[center[i].name].properties.lat), parseFloat(item[center[i].name].properties.lon), parseFloat(item[center[i].name].properties.h), item.name, "center")
  229. }
  230. for (let i = 0; i < redunit.length; i++) {
  231. this.markLocationbyJson(parseFloat(redunit[i].component_movementjson.properties.launch_lat), parseFloat(redunit[i].component_movementjson.properties.launch_lon), parseFloat(redunit[i].component_movementjson.properties.launch_h), redunit[i].name, "red")
  232. let point1 = {
  233. longitude: parseFloat(redunit[i].component_movementjson.properties.launch_lon),
  234. latitude: parseFloat(redunit[i].component_movementjson.properties.launch_lat),
  235. height: parseFloat(redunit[i].component_movementjson.properties.launch_h)
  236. }
  237. let point2 = {
  238. longitude: parseFloat(redunit[i].component_movementjson.properties.target_lon),
  239. latitude: parseFloat(redunit[i].component_movementjson.properties.target_lat),
  240. height: parseFloat(redunit[i].component_movementjson.properties.target_h)
  241. }
  242. this.markLine(point1, point2, "red")
  243. }
  244. },
  245. //获取所有数据
  246. getData() {
  247. this.getCenter();
  248. this.getSatellite();
  249. this.getUnit();
  250. this.getSituation();
  251. },
  252. // 获取场景想定数据
  253. getSituation() {
  254. let params = {
  255. datasourceId: "1656243335922192384",
  256. filterDtoList: [],
  257. pageParam: {
  258. pageNum: 1,
  259. pageSize: 10
  260. }
  261. };
  262. fireController.situation(this, params).then((res) => {
  263. this.situation = res.data.dataList;
  264. });
  265. },
  266. // 获取作战单元数据
  267. getUnit() {
  268. let params = {
  269. datasourceId: "1657931215497334784",
  270. filterDtoList: [],
  271. pageParam: {
  272. pageNum: 1,
  273. pageSize: 10
  274. }
  275. };
  276. fireController.unit(this, params).then((res) => {
  277. this.unit = res.data.dataList;
  278. });
  279. },
  280. // 获取指挥中心数据
  281. getCenter() {
  282. let params = {
  283. datasourceId: "1654421731512684544",
  284. filterDtoList: [],
  285. pageParam: {
  286. pageNum: 1,
  287. pageSize: 10
  288. }
  289. };
  290. fireController.center(this, params).then((res) => {
  291. this.center = res.data.dataList;
  292. });
  293. },
  294. // 获取预警卫星数据
  295. getSatellite() {
  296. let params = {
  297. datasourceId: "1654424480958648320",
  298. filterDtoList: [],
  299. pageParam: {
  300. pageNum: 1,
  301. pageSize: 10
  302. }
  303. };
  304. fireController.satellite(this, params).then((res) => {
  305. this.satellite = res.data.dataList;
  306. });
  307. },
  308. cesiumInit() {
  309. this.$data._viewer2D = new this.Cesium.Viewer("2DcesiumContainer", {
  310. sceneMode: this.Cesium.SceneMode.SCENE2D,
  311. animation: true, // 是否显示时间轴动画
  312. baseLayerPicker: false,
  313. homeButton: false,
  314. geocoder: false,
  315. timeline: true, //是否显示时间线控件
  316. fullscreenButton: false,
  317. sceneModePicker: false,
  318. navigationHelpButton: false,
  319. selectionIndicator: false,
  320. imageryProvider: new this.Cesium.UrlTemplateImageryProvider({
  321. url: "https://webst02.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}",
  322. layer: "tdtVecBasicLayer",
  323. style: "default",
  324. format: "image/png",
  325. tileMatrixSetID: "GoogleMapsCompatible",
  326. show: false
  327. })
  328. });
  329. this.$data._viewer3D = new this.Cesium.Viewer("3DcesiumContainer", {
  330. animation: true, // 是否显示时间轴动画
  331. baseLayerPicker: false,
  332. homeButton: false,
  333. geocoder: false,
  334. timeline: true, //是否显示时间线控件
  335. fullscreenButton: false,
  336. sceneModePicker: false,
  337. navigationHelpButton: false,
  338. selectionIndicator: false,
  339. // imageryProvider: new this.Cesium.WebMapServiceImageryProvider({
  340. // url: '/geoserver/map/wms',
  341. // // 这里是自定义的图层名称
  342. // layers: 'map',
  343. // parameters: {
  344. // service: 'WMS',
  345. // format: 'image/png',
  346. // transparent: true
  347. // }
  348. // }),
  349. imageryProvider:
  350. // new this.Cesium.WebMapTileServiceImageryProvider({
  351. // url: "http://10.170.16.95:8080/geoserver/gwc/service/wmts/rest/map:map/{style}/{TileMatrixSet}/{TileMatrixSet}:{TileMatrix}/{TileRow}/{TileCol}?format=image/png",
  352. // layer: 'map:map',
  353. // style: 'raster',
  354. // format: 'image/png',
  355. // tileMatrixSetID: 'EPSG:900913', //一般使用EPSG:3857坐标系
  356. // }),
  357. new this.Cesium.UrlTemplateImageryProvider({
  358. url: "https://webst02.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}",
  359. layer: "tdtVecBasicLayer",
  360. style: "default",
  361. format: "image/png",
  362. tileMatrixSetID: "GoogleMapsCompatible",
  363. show: false
  364. })
  365. });
  366. this.$data._viewer3D._cesiumWidget._creditContainer.style.display = "none";
  367. this.$data._viewer2D._cesiumWidget._creditContainer.style.display = "none";
  368. this.$data._viewer3D.camera.setView({
  369. destination: new this.Cesium.Cartesian3.fromDegrees(117.918977, 25.0, 1500000)
  370. // 方向,俯视和仰视的视角
  371. // orientation:{
  372. // heading: this.Cesium.Math.toRadians(90),//坐标系旋转90度
  373. // pitch: this.Cesium.Math.toRadians(-45) ,//设置俯仰角度为-45度
  374. // }
  375. });
  376. this.$data._viewer2D.camera.setView({
  377. destination: new this.Cesium.Cartesian3.fromDegrees(117.918977, 25.0, 1500000)
  378. // 方向,俯视和仰视的视角
  379. // orientation:{
  380. // heading: this.Cesium.Math.toRadians(90),//坐标系旋转90度
  381. // pitch: this.Cesium.Math.toRadians(-45) ,//设置俯仰角度为-45度
  382. // }
  383. });
  384. // this.viewer.scene.screenSpaceCameraController.maximumZoomDistance = 1500000; //相机高度的最大值
  385. this.$data._viewer2D.camera.percentageChanged = 0.01;
  386. this.$data._viewer2D.camera.changed.addEventListener(this.sync); //地图移动事件
  387. this.$data._viewer3D.camera.percentageChanged = 0.01;
  388. this.$data._viewer3D.camera.changed.addEventListener(this.sync); //地图移动事件
  389. this.$data._viewer2D.camera.moveEnd.addEventListener(this.getCammeraHeightAndZoom) //地图缩放事件
  390. this.$data._viewer3D.camera.moveEnd.addEventListener(this.getCammeraHeightAndZoom) //地图缩放事件
  391. this.handler2D = new this.Cesium.ScreenSpaceEventHandler(this.$data._viewer2D.scene.canvas);
  392. this.handler3D = new this.Cesium.ScreenSpaceEventHandler(this.$data._viewer3D.scene.canvas);
  393. //设置导航组件
  394. new CesiumNavigation(this.$data._viewer2D, this.mapNavOptions);
  395. new CesiumNavigation(this.$data._viewer3D, this.mapNavOptions);
  396. },
  397. sync() {
  398. if (this.mousevalue == "3D") {
  399. // 三维地图中心点
  400. let center = new this.Cesium.Cartesian2(
  401. Math.floor(this.$data._viewer3D.canvas.clientWidth / 2),
  402. Math.floor(this.$data._viewer3D.canvas.clientHeight / 2)
  403. );
  404. // 转为世界坐标系
  405. let position = this.$data._viewer3D.scene.camera.pickEllipsoid(center);
  406. // 判断中心点是否在椭球体上
  407. if (this.Cesium.defined(position)) {
  408. // 获取三维地图中心点与相机之间的距离
  409. let distance = this.Cesium.Cartesian3.distance(position, this.$data._viewer3D.scene.camera.positionWC);
  410. position = this.convertWorldToCartographic(position);
  411. // 更新二维地图
  412. this.$data._viewer2D.scene.camera.setView({
  413. destination: new this.Cesium.Cartesian3.fromDegrees(position.longitude, position.latitude, distance)
  414. });
  415. }
  416. }
  417. if (this.mousevalue == "2D") {
  418. // 二维地图中心点
  419. let center = new this.Cesium.Cartesian2(
  420. Math.floor(this.$data._viewer2D.canvas.clientWidth / 2),
  421. Math.floor(this.$data._viewer2D.canvas.clientHeight / 2)
  422. );
  423. // 转为世界坐标系
  424. let position = this.$data._viewer2D.scene.camera.pickEllipsoid(center);
  425. // 判断中心点是否在椭球体上
  426. if (this.Cesium.defined(position)) {
  427. // 获取三维地图中心点与相机之间的距离
  428. let distance = this.$data._viewer2D.scene.camera.positionCartographic.height;
  429. position = this.convertWorldToCartographic(position);
  430. // 更新三维地图
  431. this.$data._viewer3D.scene.camera.setView({
  432. destination: new this.Cesium.Cartesian3.fromDegrees(position.longitude, position.latitude, distance)
  433. });
  434. }
  435. }
  436. },
  437. // 将世界坐标系转换为经纬度坐标系
  438. convertWorldToCartographic(worldPosition) {
  439. const ellipsoid = this.$data._viewer2D.scene.globe.ellipsoid;
  440. const cartographic = ellipsoid.cartesianToCartographic(worldPosition);
  441. const longitude = this.Cesium.Math.toDegrees(cartographic.longitude);
  442. const latitude = this.Cesium.Math.toDegrees(cartographic.latitude);
  443. const height = cartographic.height;
  444. return { longitude, latitude, height };
  445. },
  446. // 监听地图变化
  447. changeActive(value) {
  448. this.mousevalue = value;
  449. },
  450. dimensionswitch(value) {
  451. this.dimension = value;
  452. this.selectModel();
  453. },
  454. // 全屏缩小
  455. ismax() {
  456. if (screenfull.isEnabled && screenfull.isFullscreen) {
  457. screenfull.exit();
  458. } else {
  459. screenfull.request();
  460. }
  461. },
  462. /* 获取camera中心点坐标 */
  463. getCenterPosition(is3D = false) {
  464. let viewer = is3D ? this.$data._viewer3D : this.$data._viewer2D;
  465. let result = viewer.camera.pickEllipsoid(
  466. new this.Cesium.Cartesian2(viewer.canvas.clientWidth / 2, viewer.canvas.clientHeight / 2)
  467. );
  468. let curPosition = this.Cesium.Ellipsoid.WGS84.cartesianToCartographic(result);
  469. let lon = (curPosition.longitude * 180) / Math.PI;
  470. let lat = (curPosition.latitude * 180) / Math.PI;
  471. let height = viewer.camera.positionCartographic.height;
  472. return {
  473. lon: lon,
  474. lat: lat,
  475. height: height
  476. };
  477. },
  478. /* 地图放大 */
  479. big() {
  480. let { lon, lat, height } = this.getCenterPosition(this.dimension === 3);
  481. let viewer = (this.dimension === 3 || this.dimension === 5) ? this.$data._viewer3D : this.$data._viewer2D;
  482. // 镜头拉进
  483. viewer.camera.flyTo({
  484. destination: this.Cesium.Cartesian3.fromDegrees(lon, lat, height / 1.8),
  485. duration: 1.0
  486. });
  487. },
  488. /* 地图缩小 */
  489. small() {
  490. let { lon, lat, height } = this.getCenterPosition(this.dimension === 3);
  491. let viewer = (this.dimension === 3 || this.dimension === 5) ? this.$data._viewer3D : this.$data._viewer2D;
  492. // 镜头远离
  493. viewer.camera.flyTo({
  494. destination: this.Cesium.Cartesian3.fromDegrees(lon, lat, height * 1.2),
  495. duration: 1.0
  496. });
  497. },
  498. home() {
  499. let viewer = (this.dimension === 3 || this.dimension === 5) ? this.$data._viewer3D : this.$data._viewer2D;
  500. viewer.camera.flyTo({
  501. destination: this.Cesium.Cartesian3.fromDegrees(117.918977, 25.0, 1500000),
  502. duration: 2.0
  503. });
  504. },
  505. // tabs 切换点击
  506. legendClick({ index }) {
  507. this.selectModel();
  508. let tab_content = document.querySelectorAll(".menu .el-tabs__content");
  509. if (this.currentLab.index == index) {
  510. tab_content[0].style.display == "none" || ""
  511. ? (tab_content[0].style.display = "block")
  512. : (tab_content[0].style.display = "none");
  513. }
  514. if (this.currentLab.index != index) {
  515. this.currentLab.index = index;
  516. tab_content[0].style.display = "block";
  517. }
  518. },
  519. mouseMove(event) {
  520. if (this.$refs.modeltooltip) {
  521. this.$refs.modeltooltip.style.left = event.pageX - 240 + "px";
  522. this.$refs.modeltooltip.style.top = event.pageY - 115 + "px";
  523. }
  524. },
  525. //显示鼠标经纬度
  526. getMouseLocation(event) {
  527. let { longitude, latitude } = this.getCoordinatesFromEvent(event);
  528. this.$store.commit("app/setMouseLocation", { longitude, latitude });
  529. },
  530. /*根据camera高度近似计算当前层级*/
  531. heightToZoom(height) {
  532. var A = 40487.57;
  533. var B = 0.00007096758;
  534. var C = 91610.74;
  535. var D = -40467.74;
  536. return Math.round(D + (A - D) / (1 + Math.pow(height / C, B)));
  537. },
  538. getCammeraHeightAndZoom() {
  539. let viewer = (this.dimension === 3 || this.dimension === 5) ? this.$data._viewer3D : this.$data._viewer2D;
  540. //获取当前相机高度
  541. let height = viewer.camera.positionCartographic.height;
  542. let zoom = this.heightToZoom(height);
  543. this.$store.commit("app/setCameraHeightAndZoom", { height, zoom });
  544. },
  545. selectModel(cursorStyle, image, info) {
  546. console.log('image :>> ', image);
  547. let earthMap = document.getElementById("earth");
  548. earthMap.style.cursor = cursorStyle || "auto";
  549. if (cursorStyle) {
  550. document.addEventListener("mousemove", this.mouseMove);
  551. this.isShow = true;
  552. this.image = image;
  553. this.modeltooltip = info;
  554. } else {
  555. document.removeEventListener("mousemove", this.mouseMove);
  556. this.isShow = false;
  557. this.image = null;
  558. this.modeltooltip = null;
  559. }
  560. },
  561. markLocationbyJson(latitude, longitude, height, name, type) {
  562. const position = this.Cesium.Cartesian3.fromDegrees(longitude, latitude, height);
  563. console.log('position :>> ', position);
  564. let color = ''
  565. let modelUrl = ''
  566. let size = 64
  567. if (type == 'red') {
  568. color = 'Red'
  569. modelUrl = missileModel
  570. size = 100
  571. this.missileList[name] = {
  572. disturb: 20,
  573. id: this.id
  574. }
  575. }
  576. else if (type == 'blue') {
  577. color = 'Blue'
  578. modelUrl = radarModel
  579. this.thaadList[name] = {
  580. range: 700000.0,
  581. health: 100.0,
  582. id: this.id
  583. }
  584. }
  585. else if (type == 'center') {
  586. color = 'Blue'
  587. modelUrl = centerModel
  588. this.centerPosition = position
  589. }
  590. else if (type == 'satelite') {
  591. color = 'Blue'
  592. modelUrl = satelliteModel
  593. }
  594. if (type == 'blue') {
  595. console.log(' radar!!!');
  596. const range = 700000;
  597. this.$data._viewer2D.entities.add({
  598. id: this.id,
  599. position: position,
  600. ellipsoid: {
  601. radii: new this.Cesium.Cartesian3(range, range, range),
  602. material: this.Cesium.Color.GREEN.withAlpha(0.5), // 设置球体的颜色和透明度
  603. outline: true,
  604. outlineColor: this.Cesium.Color.GREEN,
  605. },
  606. point: {
  607. pixelSize: 12, // 调整点的大小,可以增大点的像素大小
  608. color: this.Cesium.Color.fromCssColorString(color)
  609. },
  610. model: {
  611. uri: modelUrl, // 替换为你的3D模型文件路径
  612. scale: 1.0, // 调整3D模型的缩放大小
  613. minimumPixelSize: size // 设置3D模型的最小像素大小,确保在视图中可见
  614. },
  615. label: {
  616. text: type + ' ' + name,
  617. show: true,
  618. font: "18px Helvetica", // 调整标签的字体样式和大小
  619. pixelOffset: new this.Cesium.Cartesian2(0, 20) // 调整标签的像素偏移,向下偏移20像素
  620. }
  621. });
  622. this.$data._viewer3D.entities.add({
  623. id: this.id,
  624. position: position,
  625. ellipsoid: {
  626. radii: new this.Cesium.Cartesian3(range, range, range),
  627. material: this.Cesium.Color.GREEN.withAlpha(0.5), // 设置球体的颜色和透明度
  628. outline: true,
  629. outlineColor: this.Cesium.Color.GREEN,
  630. },
  631. point: {
  632. pixelSize: 12, // 调整点的大小,可以增大点的像素大小
  633. color: this.Cesium.Color.fromCssColorString(color)
  634. },
  635. model: {
  636. uri: modelUrl, // 替换为你的3D模型文件路径
  637. scale: 1.0, // 调整3D模型的缩放大小
  638. minimumPixelSize: size // 设置3D模型的最小像素大小,确保在视图中可见
  639. },
  640. label: {
  641. text: type + ' ' + name,
  642. show: true,
  643. font: "18px Helvetica", // 调整标签的字体样式和大小
  644. pixelOffset: new this.Cesium.Cartesian2(0, 20) // 调整标签的像素偏移,向下偏移20像素
  645. }
  646. });
  647. this.nameIdList.push({
  648. id: this.id,
  649. name: name
  650. })
  651. this.id++;
  652. }
  653. else {
  654. this.$data._viewer2D.entities.add({
  655. id: this.id,
  656. position: position,
  657. point: {
  658. pixelSize: 12, // 调整点的大小,可以增大点的像素大小
  659. color: this.Cesium.Color.fromCssColorString(color)
  660. },
  661. model: {
  662. uri: modelUrl, // 替换为你的3D模型文件路径
  663. scale: 1.0, // 调整3D模型的缩放大小
  664. minimumPixelSize: size // 设置3D模型的最小像素大小,确保在视图中可见
  665. },
  666. label: {
  667. text: type + ' ' + name,
  668. show: true,
  669. font: "18px Helvetica", // 调整标签的字体样式和大小
  670. pixelOffset: new this.Cesium.Cartesian2(0, 20) // 调整标签的像素偏移,向下偏移20像素
  671. }
  672. });
  673. this.$data._viewer3D.entities.add({
  674. id: this.id,
  675. position: position,
  676. point: {
  677. pixelSize: 12, // 调整点的大小,可以增大点的像素大小
  678. color: this.Cesium.Color.fromCssColorString(color)
  679. },
  680. model: {
  681. uri: modelUrl, // 替换为你的3D模型文件路径
  682. scale: 1.0, // 调整3D模型的缩放大小
  683. minimumPixelSize: size // 设置3D模型的最小像素大小,确保在视图中可见
  684. },
  685. label: {
  686. text: type + ' ' + name,
  687. show: true,
  688. font: "18px Helvetica", // 调整标签的字体样式和大小
  689. pixelOffset: new this.Cesium.Cartesian2(0, 20) // 调整标签的像素偏移,向下偏移20像素
  690. }
  691. });
  692. this.nameIdList.push({
  693. id: this.id,
  694. name: name
  695. })
  696. this.id++;
  697. }
  698. },
  699. // 从鼠标点击事件获取坐标
  700. getCoordinatesFromEvent(event) {
  701. let viewer = this.mousevalue === "2D" ? this.$data._viewer2D : this.$data._viewer3D;
  702. let clickPosition;
  703. if (this.dimension === 5 && this.mousevalue === "3D") {
  704. clickPosition = new this.Cesium.Cartesian2(event.clientX - 1080, event.clientY - 160);
  705. } else {
  706. clickPosition = new this.Cesium.Cartesian2(event.clientX - 280, event.clientY - 160);
  707. }
  708. // 获取地图上的经纬度
  709. const viewerPosition = viewer.scene.camera.pickEllipsoid(clickPosition);
  710. const cartographic = viewer.scene.globe.ellipsoid.cartesianToCartographic(viewerPosition);
  711. const latitude = this.Cesium.Math.toDegrees(cartographic.latitude);
  712. const longitude = this.Cesium.Math.toDegrees(cartographic.longitude);
  713. return {
  714. latitude,
  715. longitude
  716. };
  717. },
  718. markLine(point1, point2, color) {
  719. // 从点1和点2的WGS84坐标创建Cartesian3对象
  720. const position1 = this.Cesium.Cartesian3.fromDegrees(point1.longitude, point1.latitude, point1.height || 0);
  721. const position2 = this.Cesium.Cartesian3.fromDegrees(point2.longitude, point2.latitude, point2.height || 0);
  722. // 创建一个带有箭头图标的PolylineMaterial
  723. const material = new this.Cesium.PolylineArrowMaterialProperty(
  724. this.Cesium.Color.fromCssColorString(color || "red")
  725. );
  726. // 将点1和点2之间的连线添加到Viewer中
  727. this.$data._viewer2D.entities.add({
  728. polyline: {
  729. positions: [position1, position2],
  730. width: 5, // 设置线的宽度
  731. material: material,
  732. followSurface: false // 设置为false,使连线保持在固定的高度,不会贴地显示
  733. }
  734. });
  735. this.$data._viewer3D.entities.add({
  736. polyline: {
  737. positions: [position1, position2],
  738. width: 5, // 设置线的宽度
  739. material: material,
  740. followSurface: false // 设置为false,使连线保持在固定的高度,不会贴地显示
  741. }
  742. });
  743. },
  744. markSatelliteLine(position1, position2, color, viewer) {
  745. // 创建一个带有箭头图标的PolylineMaterial
  746. const material = new this.Cesium.PolylineArrowMaterialProperty(
  747. this.Cesium.Color.fromCssColorString(color || "red")
  748. );
  749. // 将点1和点2之间的连线添加到Viewer中
  750. viewer.entities.add({
  751. polyline: {
  752. positions: [position1, position2],
  753. width: 5, // 设置线的宽度
  754. material: material,
  755. followSurface: false // 设置为false,使连线保持在固定的高度,不会贴地显示
  756. }
  757. });
  758. },
  759. setTimeLine(startTime, endtime, stepTime) {
  760. let start = this.Cesium.JulianDate.fromDate(new Date(startTime)); // 设置时间轴当前时间为开始时间
  761. let stop = this.Cesium.JulianDate.fromDate(new Date(endtime));
  762. // 添加8小时,使地图时间和北京时间相同
  763. start = this.Cesium.JulianDate.addHours(start, 8, new this.Cesium.JulianDate());
  764. stop = this.Cesium.JulianDate.addHours(stop, 8, new this.Cesium.JulianDate());
  765. // 设置时钟开始时间
  766. this.$data._viewer2D.clock.startTime = start.clone();
  767. this.$data._viewer3D.clock.startTime = start.clone();
  768. // 设置时钟当前时间
  769. this.$data._viewer2D.clock.currentTime = start.clone();
  770. this.$data._viewer3D.clock.currentTime = start.clone();
  771. // 设置时钟结束时间
  772. this.$data._viewer2D.clock.stopTime = stop.clone();
  773. this.$data._viewer3D.clock.stopTime = stop.clone();
  774. // 时间速率,数字越大时间过的越快,设置1好像是和实际时间一样
  775. this.$data._viewer2D.clock.multiplier = 10;
  776. this.$data._viewer3D.clock.multiplier = 10;
  777. // 时间轴绑定到viewer上去
  778. this.$data._viewer2D.timeline.zoomTo(start, stop);
  779. this.$data._viewer3D.timeline.zoomTo(start, stop);
  780. // 循环执行,到达终止时间,重新从起点时间开始
  781. this.$data._viewer2D.clock.clockRange = this.Cesium.ClockRange.LOOP_STOP;
  782. this.$data._viewer3D.clock.clockRange = this.Cesium.ClockRange.LOOP_STOP;
  783. this.messageList.push({
  784. order: this.order++,
  785. time: startTime,
  786. context: "开始模拟!!!"
  787. })
  788. // this.$data._viewer2D.clock.onTick.addEventListener(clock => {
  789. // const currentTime = clock.currentTime; // 获取当前时间轴的时间
  790. // const elapsedTime = this.Cesium.JulianDate.secondsDifference(
  791. // currentTime,
  792. // this.$data._viewer2D.clock.startTime
  793. // ); // 获取从起始时间到当前时间的秒数
  794. // if (parseInt(elapsedTime) % stepTime === 0 && parseInt(elapsedTime) !== 0 && this.$data._viewer2D.clock.shouldAnimate) {
  795. // // 当从起始时间到当前时间的秒数是 stepTime 的倍数时,发送请求
  796. // this.requestDataAndUpdateModel2D(startTime, elapsedTime);
  797. // }
  798. // });
  799. this.$data._viewer3D.clock.onTick.addEventListener(clock => {
  800. const currentTime = clock.currentTime; // 获取当前时间轴的时间
  801. const elapsedTime = this.Cesium.JulianDate.secondsDifference(
  802. currentTime,
  803. this.$data._viewer3D.clock.startTime
  804. ); // 获取从起始时间到当前时间的秒数
  805. if (parseInt(elapsedTime) % stepTime === 0 && parseInt(elapsedTime) !== 0) {
  806. // 当从起始时间到当前时间的秒数是 stepTime 的倍数时,发送请求
  807. this.requestDataAndUpdateModel3D(startTime, elapsedTime);
  808. }
  809. });
  810. this.initSTK()
  811. },
  812. // 初始化stk方法,生成轨迹文件
  813. async initSTK() {
  814. console.log('this.jsonData :>> ', this.jsonData);
  815. // await axios
  816. // .get("/api", this.jsonData).then(res=>{
  817. // console.log('res :>> ', res);
  818. // })
  819. const config = {
  820. timeout: 0 // 设置超时时间为0,表示忽略超时问题
  821. };
  822. await axios
  823. .post("/api/traj", this.jsonData, config).then(res => {
  824. console.log('res :>> ', res);
  825. let data = res.data[1].data[0]
  826. for (let key in data) {
  827. let isSatellite = true
  828. //判断是否为卫星
  829. for (let i = 0; i < this.nameIdList.length; i++) {
  830. if (key === this.nameIdList[i].name || key === 'dateTime') {
  831. isSatellite = false
  832. break
  833. }
  834. }
  835. // 新建卫星实体
  836. if (isSatellite) {
  837. let range = 1000000
  838. console.log('key :>> ', key);
  839. let x = parseFloat(data[key].x) * 1000
  840. let y = parseFloat(data[key].y) * 1000
  841. let z = parseFloat(data[key].z) * 1000
  842. //终点位置
  843. let position = new this.Cesium.Cartesian3(x, y, z);
  844. let cylinderposition = this.convertWorldToCartographic(position)
  845. cylinderposition.height = cylinderposition.height / 10.0
  846. cylinderposition = this.Cesium.Cartesian3.fromDegrees(cylinderposition.longitude, cylinderposition.latitude, cylinderposition.height);
  847. this.$data._viewer2D.entities.add({
  848. id: this.id,
  849. position: position,
  850. point: {
  851. pixelSize: 12, // 调整点的大小,可以增大点的像素大小
  852. color: this.Cesium.Color.fromCssColorString('Blue')
  853. },
  854. // cylinder: {
  855. // length: range, // 锥形的高度,可以根据需要调整
  856. // topRadius: 0,
  857. // bottomRadius: range / 2,
  858. // material: this.Cesium.Color.BLUE.withAlpha(0.5), // 设置锥形的颜色和透明度
  859. // outline: true,
  860. // outlineColor: this.Cesium.Color.BLUE,
  861. // },
  862. model: {
  863. uri: satelliteModel, // 替换为你的3D模型文件路径
  864. scale: 1.0, // 调整3D模型的缩放大小
  865. minimumPixelSize: 64 // 设置3D模型的最小像素大小,确保在视图中可见
  866. },
  867. label: {
  868. text: 'satellite ' + key,
  869. show: true,
  870. font: "18px Helvetica", // 调整标签的字体样式和大小
  871. pixelOffset: new this.Cesium.Cartesian2(0, 20) // 调整标签的像素偏移,向下偏移20像素
  872. }
  873. });
  874. this.$data._viewer2D.entities.add({
  875. id: this.id + 1,
  876. position: cylinderposition,
  877. cylinder: {
  878. length: range, // 锥形的高度,可以根据需要调整
  879. topRadius: 0,
  880. bottomRadius: range / 2,
  881. material: this.Cesium.Color.BLUE.withAlpha(0.5), // 设置锥形的颜色和透明度
  882. outline: true,
  883. outlineColor: this.Cesium.Color.BLUE,
  884. },
  885. });
  886. this.$data._viewer3D.entities.add({
  887. id: this.id,
  888. position: position,
  889. point: {
  890. pixelSize: 12, // 调整点的大小,可以增大点的像素大小
  891. color: this.Cesium.Color.fromCssColorString('Blue')
  892. },
  893. // cylinder: {
  894. // length: range, // 锥形的高度,可以根据需要调整
  895. // topRadius: 0,
  896. // bottomRadius: range / 2,
  897. // material: this.Cesium.Color.BLUE.withAlpha(0.5), // 设置锥形的颜色和透明度
  898. // outline: true,
  899. // outlineColor: this.Cesium.Color.BLUE,
  900. // },
  901. model: {
  902. uri: satelliteModel, // 替换为你的3D模型文件路径
  903. scale: 1.0, // 调整3D模型的缩放大小
  904. minimumPixelSize: 64 // 设置3D模型的最小像素大小,确保在视图中可见
  905. },
  906. label: {
  907. text: 'satellite ' + key,
  908. show: true,
  909. font: "18px Helvetica", // 调整标签的字体样式和大小
  910. pixelOffset: new this.Cesium.Cartesian2(0, 20) // 调整标签的像素偏移,向下偏移20像素
  911. },
  912. });
  913. this.$data._viewer3D.entities.add({
  914. id: this.id + 1,
  915. position: cylinderposition,
  916. cylinder: {
  917. length: range, // 锥形的高度,可以根据需要调整
  918. topRadius: 0,
  919. bottomRadius: range / 2,
  920. material: this.Cesium.Color.BLUE.withAlpha(0.5), // 设置锥形的颜色和透明度
  921. outline: true,
  922. outlineColor: this.Cesium.Color.BLUE,
  923. },
  924. });
  925. this.nameIdList.push({
  926. id: this.id,
  927. name: key
  928. })
  929. this.satelliteRange.push({
  930. satelliteId: this.id,
  931. rangeId: this.id + 1
  932. })
  933. this.id++;
  934. this.id++;
  935. }
  936. }
  937. })
  938. // this.$data._viewer2D.clock.shouldAnimate = true;
  939. // this.$data._viewer3D.clock.shouldAnimate = true;
  940. },
  941. // 根据时间参数请求模型位置并更新 2D
  942. async requestDataAndUpdateModel2D(startTime, elapsedTime) {
  943. const jsDate = new Date(startTime);
  944. // 增加 elapsedTime 秒
  945. jsDate.setSeconds(jsDate.getSeconds() + elapsedTime);
  946. // 转换为需求字符串格式
  947. const newTimeString = `${jsDate.getFullYear()}-${(jsDate.getMonth() + 1).toString().padStart(2, '0')}-${jsDate.getDate().toString().padStart(2, '0')} ${jsDate.getHours().toString().padStart(2, '0')}:${jsDate.getMinutes().toString().padStart(2, '0')}:${jsDate.getSeconds().toString().padStart(2, '0')}`;
  948. await axios
  949. .post("/api/pos", { simulation_time: newTimeString + '.000' }).then(res => {
  950. console.log('res :>> ', res);
  951. let data = res.data[1].data
  952. //依次更新每个模型位置
  953. for (let i = 0; i < this.nameIdList.length; i++) {
  954. if (data[this.nameIdList[i].name] != null && data[this.nameIdList[i].name] != undefined) {
  955. this.modelEntityMoveByIDAndLocation(this.$data._viewer2D, this.nameIdList[i].id, data[this.nameIdList[i].name].x, data[this.nameIdList[i].name].y, data[this.nameIdList[i].name].z)
  956. }
  957. }
  958. for (let i = 0; i < this.nameIdList.length; i++) {
  959. if (this.thaadList[this.nameIdList[i].name] != null || this.thaadList[this.nameIdList[i].name] != undefined) {
  960. //查看在雷达原侦察范围内有几颗导弹
  961. let missileNum = this.howManyMissile(this.$data._viewer2D, this.thaadList[this.nameIdList[i].name].id, this.nameIdList[i].name)
  962. let health = 100.0
  963. for (let j = 0; j < missileNum; j++) {
  964. health = health * 0.8
  965. }
  966. if (this.thaadList[this.nameIdList[i].name].health != health) {
  967. //修改健康值并修改范围
  968. let mark = true
  969. if (health > this.thaadList[this.nameIdList[i].name].health) {
  970. mark = false
  971. }
  972. this.thaadList[this.nameIdList[i].name].health = health
  973. this.changeRange(this.$data._viewer2D, this.thaadList[this.nameIdList[i].name].id, this.thaadList[this.nameIdList[i].name].range, this.thaadList[this.nameIdList[i].name].health, newTimeString, this.nameIdList[i].name, mark)
  974. }
  975. }
  976. }
  977. this.judgeMissile(this.$data._viewer2D, newTimeString);
  978. //判断攻防是否结束
  979. if (this.ifFinish(this.$data._viewer3D, newTimeString) && !this.finish) {
  980. // 停止时间轴动画
  981. this.$data._viewer2D.clock.shouldAnimate = false;
  982. this.dialogVisible = true
  983. this.finish = true
  984. }
  985. //更新模型位置
  986. // this.modelEntityMoveByIDAndLocation(this.$data._viewer2D,"1654426964397658112",res.data[1].data.W1.x,res.data[1].data.W1.y,res.data[1].data.W1.z)
  987. })
  988. },
  989. // 根据时间参数请求模型位置并更新 3D
  990. async requestDataAndUpdateModel3D(startTime, elapsedTime) {
  991. const jsDate = new Date(startTime);
  992. // 增加 elapsedTime 秒
  993. jsDate.setSeconds(jsDate.getSeconds() + elapsedTime);
  994. // 转换为需求字符串格式
  995. const newTimeString = `${jsDate.getFullYear()}-${(jsDate.getMonth() + 1).toString().padStart(2, '0')}-${jsDate.getDate().toString().padStart(2, '0')} ${jsDate.getHours().toString().padStart(2, '0')}:${jsDate.getMinutes().toString().padStart(2, '0')}:${jsDate.getSeconds().toString().padStart(2, '0')}`;
  996. await axios
  997. .post("/api/pos", { simulation_time: newTimeString + '.000' }).then(res => {
  998. let data = res.data[1].data
  999. //依次更新每个模型位置
  1000. for (let i = 0; i < this.nameIdList.length; i++) {
  1001. if (this.nameIdList[i].name in data) {
  1002. console.log(' 开始移动' + this.nameIdList[i].name);
  1003. this.modelEntityMoveByIDAndLocation(this.$data._viewer3D, this.nameIdList[i].id, data[this.nameIdList[i].name].x, data[this.nameIdList[i].name].y, data[this.nameIdList[i].name].z)
  1004. }
  1005. }
  1006. for (let i = 0; i < this.nameIdList.length; i++) {
  1007. if (this.thaadList[this.nameIdList[i].name] != null || this.thaadList[this.nameIdList[i].name] != undefined) {
  1008. //查看在雷达原侦察范围内有几颗导弹
  1009. let missileNum = this.howManyMissile(this.$data._viewer3D, this.thaadList[this.nameIdList[i].name].id, this.nameIdList[i].name)
  1010. let health = 100.0
  1011. //变化健康值
  1012. for (let j = 0; j < missileNum; j++) {
  1013. health = health * 0.8
  1014. }
  1015. if (this.thaadList[this.nameIdList[i].name].health != health) {
  1016. //修改健康值并修改范围
  1017. let mark = true
  1018. if (health > this.thaadList[this.nameIdList[i].name].health) {
  1019. mark = false
  1020. }
  1021. this.thaadList[this.nameIdList[i].name].health = health
  1022. this.changeRange(this.$data._viewer3D, this.thaadList[this.nameIdList[i].name].id, this.thaadList[this.nameIdList[i].name].range, this.thaadList[this.nameIdList[i].name].health, newTimeString, this.nameIdList[i].name, mark)
  1023. }
  1024. }
  1025. }
  1026. //判断是否有导弹被拦截
  1027. this.judgeMissile(this.$data._viewer3D, newTimeString);
  1028. //判断攻防是否结束
  1029. if (this.ifFinish(this.$data._viewer3D, newTimeString) && !this.finish) {
  1030. // 停止时间轴动画
  1031. this.$data._viewer3D.clock.shouldAnimate = false;
  1032. this.dialogVisible = true
  1033. this.finish = true
  1034. }
  1035. //更新模型位置
  1036. // this.modelEntityMoveByIDAndLocation(this.$data._viewer3D,viewer,"1654426964397658112",res.data[1].data.W1.x,res.data[1].data.W1.y,res.data[1].data.W1.z)
  1037. })
  1038. },
  1039. // 根据模型实体Id和终点位置进行移动
  1040. modelEntityMoveByIDAndLocation(viewer, id, x, y, z) {
  1041. x = parseFloat(x) * 1000
  1042. y = parseFloat(y) * 1000
  1043. z = parseFloat(z) * 1000
  1044. let entity = viewer.entities.getById(id)
  1045. for (let i = 0; i < this.satelliteRange.length; i++) {
  1046. if (id == this.satelliteRange[i].satelliteId) {
  1047. //是卫星
  1048. let rangeEntity = viewer.entities.getById(this.satelliteRange[i].rangeId)
  1049. let position = new this.Cesium.Cartesian3(x, y, z);
  1050. let cylinderposition = this.convertWorldToCartographic(position)
  1051. cylinderposition = this.Cesium.Cartesian3.fromDegrees(cylinderposition.longitude, cylinderposition.latitude, cylinderposition.height / 10.0);
  1052. let oldPosition = viewer.entities.getById(id).position._value
  1053. //设置方向,根据实体的位置来配置方向
  1054. entity.orientation = new this.Cesium.VelocityOrientationProperty(entity.position);
  1055. //设置实体位置
  1056. entity.position.setValue(position)
  1057. //设置方向,根据实体的位置来配置方向
  1058. rangeEntity.orientation = new this.Cesium.VelocityOrientationProperty(rangeEntity.position);
  1059. //设置实体位置getValue
  1060. rangeEntity.position.setValue(cylinderposition)
  1061. this.markSatelliteLine(oldPosition, position, 'Blue', viewer)
  1062. }
  1063. }
  1064. //终点位置
  1065. let position = new this.Cesium.Cartesian3(x, y, z);
  1066. let oldPosition = viewer.entities.getById(id).position._value
  1067. //设置方向,根据实体的位置来配置方向
  1068. entity.orientation = new this.Cesium.VelocityOrientationProperty(entity.position);
  1069. //设置实体位置
  1070. entity.position.setValue(position)
  1071. this.markSatelliteLine(oldPosition, position, 'Blue', viewer)
  1072. },
  1073. //计算有多少个导弹进入了雷达的原始范围
  1074. howManyMissile(viewer, id, name) {
  1075. let radar = viewer.entities.getById(id)
  1076. let radarPos = radar.position._value
  1077. let num = 0
  1078. for (let key in this.missileList) {
  1079. let missilePos = viewer.entities.getById(this.missileList[key].id).position._value
  1080. if (this.Cesium.Cartesian3.distance(radarPos, missilePos) <= this.thaadList[name].range) {//距离小于range
  1081. num++
  1082. }
  1083. }
  1084. return num;
  1085. },
  1086. //判断导弹是否被拦截
  1087. judgeMissile(viewer, time) {
  1088. for (let key in this.missileList) {
  1089. let missile = viewer.entities.getById(this.missileList[key].id)
  1090. let missilePos = viewer.entities.getById(this.missileList[key].id).position._value
  1091. for (let item in this.thaadList) {
  1092. let radarPos = viewer.entities.getById(this.thaadList[item].id).position._value
  1093. if (this.Cesium.Cartesian3.distance(radarPos, missilePos) <= this.thaadList[item].range * this.thaadList[item].health * 0.01) {
  1094. // 导弹进入了被干扰后的雷达探测范围,判断被拦截 移除实体,删除信息
  1095. this.messageList.push({
  1096. order: this.order++,
  1097. time: time,
  1098. context: '导弹' + key + '被雷达' + item + '拦截!!!'
  1099. })
  1100. viewer.entities.remove(missile)
  1101. this.nameIdList = this.nameIdList.filter(item => item.id !== this.missileList[key].id);
  1102. delete this.missileList[key]
  1103. break
  1104. }
  1105. }
  1106. }
  1107. },
  1108. //修改雷达的显示范围
  1109. changeRange(viewer, id, range, health, time, name, mark) {
  1110. let context = '雷达' + name + '受到干扰!健康值变化为: ' + health
  1111. if (!mark) {
  1112. context = '雷达' + name + '恢复健康值,健康值变化为: ' + health
  1113. }
  1114. this.messageList.push({
  1115. order: this.order++,
  1116. time: time,
  1117. context: context
  1118. })
  1119. let radar = viewer.entities.getById(id)
  1120. let newRange = range * health * 0.01
  1121. radar.ellipsoid.radii = new this.Cesium.Cartesian3(newRange, newRange, newRange);
  1122. },
  1123. isObjectEmpty(obj) {
  1124. for (let key in obj) {
  1125. if (obj.hasOwnProperty(key)) {
  1126. return false; // 如果对象有任何属性,返回 false
  1127. }
  1128. }
  1129. return true; // 如果对象没有任何属性,返回 true
  1130. },
  1131. //判断攻防是否完成
  1132. ifFinish(viewer, time) {
  1133. if (this.isObjectEmpty(this.missileList)) {
  1134. this.messageList.push({
  1135. order: this.order,
  1136. time: time,
  1137. context: '全部导弹被拦截,红方进攻失败,蓝方防守成功!!!'
  1138. })
  1139. return true
  1140. }
  1141. else {
  1142. for (let key in this.missileList) {
  1143. let missilePos = viewer.entities.getById(this.missileList[key].id).position._value
  1144. if (this.Cesium.Cartesian3.distance(this.centerPosition, missilePos) <= 100) {
  1145. this.messageList.push({
  1146. order: this.order,
  1147. time: time,
  1148. context: '导弹' + key + '成功摧毁蓝方指挥中心!!!'
  1149. })
  1150. return true
  1151. }
  1152. }
  1153. }
  1154. return false
  1155. },
  1156. exportReport() {
  1157. }
  1158. }
  1159. };
  1160. </script>
  1161. <style scoped>
  1162. ::v-deep .cesium-infoBox {
  1163. display: none !important;
  1164. }
  1165. ::v-deep .cesium-infoBox-bodyless {
  1166. display: none !important;
  1167. }
  1168. ::v-deep .cesium-infoBox-visible {
  1169. display: none !important;
  1170. }
  1171. .container {
  1172. height: 100%;
  1173. position: relative;
  1174. }
  1175. .modeltooltip {
  1176. position: absolute;
  1177. padding: 5px;
  1178. color: #fff;
  1179. font-size: 20px;
  1180. pointer-events: none;
  1181. z-index: 999;
  1182. }
  1183. .myHeader {
  1184. background-color: #1c222b !important;
  1185. color: #fff;
  1186. height: 100%;
  1187. display: flex;
  1188. flex-direction: row;
  1189. align-items: center;
  1190. /*由于flex-direction: column,因此align-items代表的是水平方向*/
  1191. justify-content: center;
  1192. /*由于flex-direction: column,因此justify-content代表的是垂直方向*/
  1193. }
  1194. .myHeader .el-button {
  1195. width: 100px;
  1196. height: 20px;
  1197. padding: 1px 23px;
  1198. }
  1199. .box-card {
  1200. min-height: 100%;
  1201. height: 100%;
  1202. }
  1203. ::v-deep .el-card__body {
  1204. height: 100% !important;
  1205. padding: 0px !important;
  1206. }
  1207. .main-layout {
  1208. height: 100%;
  1209. width: 100%;
  1210. }
  1211. .map {
  1212. width: 100%;
  1213. height: 100%;
  1214. }
  1215. .menu {
  1216. position: absolute;
  1217. height: 400px;
  1218. z-index: 999;
  1219. left: 20px;
  1220. top: 20px;
  1221. }
  1222. ::v-deep .el-tabs--left .el-tabs__header.is-left {
  1223. margin-right: 0px !important;
  1224. }
  1225. .buttons {
  1226. display: flex;
  1227. flex-direction: column;
  1228. align-items: center;
  1229. justify-items: center;
  1230. position: absolute;
  1231. z-index: 999;
  1232. right: 20px;
  1233. top: 20px;
  1234. }
  1235. .el-button {
  1236. margin: 5px !important;
  1237. }
  1238. ::v-deep .el-tabs--border-card>.el-tabs__content {
  1239. width: 300px;
  1240. height: 100%;
  1241. overflow-y: visible;
  1242. }
  1243. .model {
  1244. display: flex;
  1245. width: 100%;
  1246. flex-wrap: wrap;
  1247. }
  1248. .model>div {
  1249. width: 50%;
  1250. height: 120px;
  1251. padding: 5px;
  1252. }
  1253. .model>div:hover {
  1254. border: 2px solid blue;
  1255. }
  1256. .model>div:active {
  1257. border: 2px solid red;
  1258. }
  1259. .active {
  1260. border: 2px solid red !important;
  1261. }
  1262. .model .el-image {
  1263. display: block !important;
  1264. }
  1265. ::v-deep .el-image .el-image__inner {
  1266. border: 1px solid #ddd;
  1267. border-radius: 5px;
  1268. }
  1269. .item {
  1270. font-size: 14px;
  1271. /* right: 20px; */
  1272. }
  1273. .TimeLine {
  1274. position: absolute;
  1275. left: 21%;
  1276. bottom: 15px;
  1277. transform: translateX(-50%);
  1278. }
  1279. /* 罗盘样式 */
  1280. /deep/.compass {
  1281. pointer-events: auto;
  1282. position: absolute;
  1283. right: 0px;
  1284. top: 280px;
  1285. width: 95px;
  1286. height: 95px;
  1287. overflow: hidden;
  1288. }
  1289. </style>