NightscapeAnalysis.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723
  1. <template>
  2. <div
  3. class="ZTGlobal"
  4. style="width: 100%; padding: 1rem 1rem 0rem 1rem; color: white"
  5. >
  6. <el-row :gutter="10">
  7. <el-col :span="24">
  8. <div class="titleHeader">
  9. <el-switch
  10. v-model="isNightscaoe"
  11. active-text="开启夜景"
  12. inactive-text="关闭夜景"
  13. @change="handleChange"
  14. >
  15. </el-switch>
  16. <el-tooltip content="点击后可直接在光源参数中保存" placement="top">
  17. <el-button type="primary" size="mini" @click="openDgyAddVisibility"
  18. >添加光源</el-button
  19. >
  20. </el-tooltip>
  21. <el-button type="danger" size="mini" @click="dgyremove"
  22. >删除光源</el-button
  23. >
  24. </div>
  25. </el-col>
  26. </el-row>
  27. <el-row :gutter="10">
  28. <el-col :span="10">
  29. 光源列表:
  30. <el-row>
  31. <el-col :span="24" style="border: 1px solid #fff">
  32. <el-table
  33. ref="dgytable"
  34. :show-header="false"
  35. :data="gyTableData"
  36. :highlight-current-row="true"
  37. @current-change="handleCurrentChange"
  38. style="width: 100%"
  39. >
  40. <el-table-column
  41. prop="lightname"
  42. label="光源名称"
  43. ></el-table-column>
  44. </el-table>
  45. </el-col>
  46. </el-row>
  47. </el-col>
  48. <el-col :span="14">
  49. 光源参数:
  50. <el-row>
  51. <el-col :span="24" style="border: 1px solid #fff">
  52. <el-form
  53. ref="dgyform"
  54. :model="dgyform"
  55. label-width="80px"
  56. style="padding: 1rem 1rem 0rem 1rem"
  57. >
  58. <el-form-item label="光源名称">
  59. <el-input
  60. size="mini"
  61. v-model="dgyform.lightname"
  62. placeholder="请输入光源名称"
  63. ></el-input>
  64. </el-form-item>
  65. <el-form-item label="光源类型">
  66. <el-select
  67. size="mini"
  68. v-model="dgyform.lighttype"
  69. placeholder="请选择光源类型"
  70. >
  71. <el-option label="点光源" value="点光源"></el-option>
  72. <el-option label="聚光灯" value="聚光灯"></el-option>
  73. <el-option label="直射光" value="直射光"></el-option>
  74. </el-select>
  75. </el-form-item>
  76. <el-form-item label="光源颜色">
  77. <el-color-picker
  78. size="mini"
  79. v-model="dgyform.color"
  80. ></el-color-picker>
  81. <el-button size="mini" @click="addPoint"
  82. >添加光源位置</el-button
  83. >
  84. </el-form-item>
  85. <!-- <el-form-item label="X坐标(度)">
  86. <el-input-number
  87. size="mini"
  88. v-model="dgyform.location.x"
  89. ></el-input-number>
  90. </el-form-item>
  91. <el-form-item label="Y坐标(度)">
  92. <el-input-number
  93. size="mini"
  94. v-model="dgyform.location.y"
  95. ></el-input-number>
  96. </el-form-item>-->
  97. <!-- <el-form-item label="光源高度">
  98. <el-input-number
  99. size="mini"
  100. v-model="dgyform.location.z"
  101. ></el-input-number>
  102. </el-form-item> -->
  103. <el-form-item
  104. label="扩散距离"
  105. v-if="dgyform.lighttype != '直射光'"
  106. >
  107. <el-input-number
  108. size="mini"
  109. v-model="dgyform.cutoffdistance"
  110. :min="0"
  111. :max="10000"
  112. ></el-input-number>
  113. </el-form-item>
  114. <el-form-item
  115. label="衰减因子"
  116. v-if="dgyform.lighttype != '直射光'"
  117. >
  118. <el-input-number
  119. size="mini"
  120. v-model="dgyform.decay"
  121. :min="0"
  122. :max="10000"
  123. ></el-input-number>
  124. </el-form-item>
  125. <el-form-item label="光源强度">
  126. <el-input-number
  127. size="mini"
  128. v-model="dgyform.intensity"
  129. :min="0"
  130. :max="10000"
  131. ></el-input-number>
  132. </el-form-item>
  133. </el-form>
  134. <div class="SaveCenter">
  135. <el-button size="mini" type="primary" @click="onSubmit"
  136. >保存</el-button
  137. >
  138. <el-button size="mini" @click="resetForm">取消</el-button>
  139. </div>
  140. </el-col>
  141. </el-row>
  142. </el-col>
  143. </el-row>
  144. </div>
  145. </template>
  146. <script>
  147. import { v4 as uuidv4 } from "uuid";
  148. import Nightscape from "@/components/Combinations/NightscapeAnalysis/index.js";
  149. import {
  150. listZtLightList,
  151. addZtLightList,
  152. updateZtLightList,
  153. delZtLightList,
  154. } from "@/api/zt/ztApi.js";
  155. let entityPointLightPairs = new Map(),
  156. entitySpotLightPairs = new Map(),
  157. entityDirectionalLightPairs = new Map(),
  158. pointLightSourceDrawHandler = null,
  159. spotOrDirectionalLightSourceDrawHandler = null,
  160. spotOrDirectionalLightSourceCountHandler = null,
  161. spotOrDirectionalLightSourceAdding = false,
  162. spotOrDirectionalLightPositions = [];
  163. export default {
  164. data() {
  165. return {
  166. tooltip: createTooltip(document.body),
  167. sharedState: store.state,
  168. isNightscaoe: false,
  169. gyTableData: [],
  170. dgyform: {
  171. id: "",
  172. lightname: "",
  173. lighttype: "点光源",
  174. color: "#409EFF",
  175. cutoffdistance: 300,
  176. decay: 5,
  177. intensity: 5,
  178. // location: {
  179. // x: 0,
  180. // y: 0,
  181. // z: 0,
  182. // },
  183. },
  184. };
  185. },
  186. props: {
  187. info: {
  188. type: Object,
  189. default: () => {
  190. return {};
  191. },
  192. },
  193. layerid: {
  194. type: String,
  195. default: "",
  196. },
  197. lydata: {
  198. type: Object,
  199. default: () => {
  200. return {};
  201. },
  202. },
  203. lyoption: {
  204. type: Object,
  205. default: () => {
  206. return {};
  207. },
  208. },
  209. },
  210. computed: {},
  211. mounted() {
  212. this.init();
  213. },
  214. methods: {
  215. handleChange() {
  216. if (this.isNightscaoe) {
  217. this.startNight(true);
  218. } else {
  219. this.startNight(false);
  220. }
  221. },
  222. openDgyAddVisibility() {
  223. this.resetForm();
  224. },
  225. async init() {
  226. this.hyp = new Cesium.HypsometricSetting();
  227. this.startNight(false);
  228. debugger;
  229. await this.getModelLightData();
  230. },
  231. //获取模型灯光数据
  232. async getModelLightData() {
  233. let rData = await listZtLightList({
  234. isModelAssociated: true,
  235. modelId: this.info.id,
  236. });
  237. if (rData.code == 200) {
  238. rData.rows.forEach((element) => {
  239. element.location = JSON.parse(element.location);
  240. });
  241. this.gyTableData = rData.rows;
  242. if (this.isNightscaoe) {
  243. this.addModelLight();
  244. }
  245. }
  246. },
  247. //夜景开关
  248. startNight(isNight) {
  249. if (isNight) {
  250. Nightscape.openNightSwitch();
  251. this.addModelLight();
  252. } else {
  253. Nightscape.closNightSwitch();
  254. }
  255. },
  256. // 添加模型下的光源
  257. addModelLight() {
  258. this.clearLightSource();
  259. this.gyTableData.forEach((element) => {
  260. this.addLightSource(element);
  261. });
  262. },
  263. async onSubmit() {
  264. //更新
  265. if (this.dgyform.id) {
  266. // let gydata = this.gyTableData.find((c) => c.id == this.dgyform.id);
  267. // let data = JSON.parse(JSON.stringify(this.dgyform));
  268. // gydata.lightname = data.lightname;
  269. // gydata.color = data.color;
  270. // gydata.cutoffdistance = data.cutoffdistance;
  271. // gydata.decay = data.decay;
  272. // gydata.intensity = data.intensity;
  273. // gydata.location = data.location;
  274. // gydata.LightSource = this.dgyform.LightSource;
  275. this.dgyform.location = JSON.stringify(this.dgyform.location);
  276. var rownum = await updateZtLightList(this.dgyform);
  277. this.resetForm();
  278. if (rownum.code == 200) {
  279. this.$message({
  280. message: "修改成功",
  281. type: "success",
  282. });
  283. //更新列表及光源
  284. this.getModelLightData();
  285. }
  286. }
  287. //添加
  288. else {
  289. debugger;
  290. this.dgyform.id = uuidv4();
  291. // let data = JSON.parse(JSON.stringify(this.dgyform));
  292. // data.LightSource = this.dgyform.LightSource;
  293. // this.gyTableData.push(this.dgyform);
  294. this.dgyform.location = JSON.stringify(this.dgyform.location);
  295. this.dgyform.isModelAssociated = true;
  296. this.dgyform.modelId = this.info.id;
  297. var rownum = await addZtLightList(this.dgyform);
  298. this.resetForm();
  299. if (rownum.code == 200) {
  300. this.$message({
  301. message: "添加成功",
  302. type: "success",
  303. });
  304. //更新列表及光源
  305. this.getModelLightData();
  306. }
  307. }
  308. // this.clearLightSource(false);
  309. },
  310. //清空from
  311. resetForm() {
  312. this.dgyform = {
  313. id: "",
  314. lightname: "",
  315. lighttype: "点光源",
  316. color: "#409EFF",
  317. cutoffdistance: 300,
  318. decay: 5,
  319. intensity: 5,
  320. location: {},
  321. LightSource: null,
  322. };
  323. },
  324. //删除添加的光源
  325. async dgyremove() {
  326. let that = this;
  327. await delZtLightList(that.currentRow.id);
  328. scene.removeLightSource(that.currentRow.LightSource);
  329. that.resetForm();
  330. //更新列表及光源
  331. that.getModelLightData();
  332. },
  333. //点光源表选中
  334. handleCurrentChange(row) {
  335. this.currentRow = row;
  336. this.clearLightSource();
  337. if (row) {
  338. let data = JSON.parse(JSON.stringify(row));
  339. this.dgyform = data;
  340. this.dgyform.LightSource = row.LightSource;
  341. }
  342. },
  343. addPoint() {
  344. switch (this.dgyform.lighttype) {
  345. case "点光源":
  346. if (pointLightSourceDrawHandler) {
  347. pointLightSourceDrawHandler.clear();
  348. pointLightSourceDrawHandler = null;
  349. }
  350. this.initPointLightSourceDrawHandler();
  351. pointLightSourceDrawHandler.activate();
  352. break;
  353. case "聚光灯":
  354. case "直射光":
  355. if (spotOrDirectionalLightSourceDrawHandler) {
  356. spotOrDirectionalLightSourceDrawHandler.clear();
  357. spotOrDirectionalLightSourceDrawHandler = null;
  358. spotOrDirectionalLightPositions = [];
  359. spotOrDirectionalLightSourceDrawHandler.deactivate();
  360. }
  361. if (spotOrDirectionalLightSourceCountHandler) {
  362. spotOrDirectionalLightSourceCountHandler.destroy();
  363. spotOrDirectionalLightSourceCountHandler = undefined;
  364. }
  365. this.initSpotOrDirectionalLightSourceDrawHandler();
  366. spotOrDirectionalLightSourceAdding = true;
  367. spotOrDirectionalLightSourceDrawHandler.activate();
  368. break;
  369. default:
  370. break;
  371. }
  372. },
  373. initPointLightSourceDrawHandler() {
  374. let that = this;
  375. this.clearLightSource();
  376. pointLightSourceDrawHandler = new Cesium.DrawHandler(
  377. viewer,
  378. Cesium.DrawMode.Point
  379. );
  380. pointLightSourceDrawHandler.activeEvt.addEventListener(function (
  381. isActive
  382. ) {
  383. if (isActive == true) {
  384. viewer.enableCursorStyle = false;
  385. viewer._element.style.cursor = "";
  386. document.body.classList.add("drawCur");
  387. } else {
  388. viewer.enableCursorStyle = true;
  389. document.body.classList.remove("drawCur");
  390. }
  391. });
  392. pointLightSourceDrawHandler.movingEvt.addEventListener(
  393. (windowPosition) => {
  394. that.tooltip.showAt(
  395. windowPosition,
  396. `<p>${Resource.clickToConfirmThePositionOfTheLightSource}</p><p>${Resource.clickLightChangeAttributes}</p>`
  397. );
  398. }
  399. );
  400. pointLightSourceDrawHandler.drawEvt.addEventListener((result) => {
  401. let xyz = result.object.position;
  402. let location = this.cartesianToWgs84(xyz.x, xyz.y, xyz.z);
  403. this.dgyform.location = location;
  404. let option = {
  405. color: Cesium.Color.fromCssColorString(this.dgyform.color),
  406. cutoffDistance: Number(this.dgyform.cutoffdistance),
  407. decay: Number(this.dgyform.decay),
  408. intensity: Number(this.dgyform.intensity),
  409. };
  410. let pointLight = new Cesium.PointLight(
  411. new Cesium.Cartesian3.fromDegrees(location.x, location.y, location.z),
  412. option
  413. );
  414. scene.addLightSource(pointLight);
  415. if (this.dgyform.LightSource) {
  416. scene.removeLightSource(this.dgyform.LightSource);
  417. }
  418. this.dgyform.LightSource = pointLight;
  419. let entityAsKey = viewer.entities.add({
  420. id: "point-light-" + new Date().getTime(),
  421. position: location,
  422. billboard: {
  423. image: "@/../static/images/lightSource/pointLight.png",
  424. scaleByDistance: new Cesium.NearFarScalar(10, 1.0, 1000, 0.1),
  425. disableDepthTestDistance: Number.POSITIVE_INFINITY, // 关闭深度检测,使billboard不至于被裁剪
  426. },
  427. });
  428. console.log(entityPointLightPairs);
  429. entityPointLightPairs.set(entityAsKey, pointLight);
  430. pointLightSourceDrawHandler.clear();
  431. pointLightSourceDrawHandler = null;
  432. this.tooltip.setVisible(false);
  433. });
  434. },
  435. initSpotOrDirectionalLightSourceDrawHandler() {
  436. let that = this;
  437. that.clearLightSource();
  438. spotOrDirectionalLightSourceDrawHandler = new Cesium.DrawHandler(
  439. viewer,
  440. Cesium.DrawMode.Line
  441. );
  442. spotOrDirectionalLightSourceCountHandler =
  443. new Cesium.ScreenSpaceEventHandler(scene.canvas);
  444. spotOrDirectionalLightSourceDrawHandler.activeEvt.addEventListener(
  445. function (isActive) {
  446. if (isActive == true) {
  447. viewer.enableCursorStyle = false;
  448. viewer._element.style.cursor = "";
  449. document.body.classList.add("drawCur");
  450. } else {
  451. viewer.enableCursorStyle = true;
  452. document.body.classList.remove("drawCur");
  453. }
  454. }
  455. );
  456. spotOrDirectionalLightSourceDrawHandler.movingEvt.addEventListener(
  457. (windowPosition) => {
  458. this.tooltip.showAt(
  459. windowPosition,
  460. `<p>${Resource.ClickLineDirectionLightSource}</p><p>${Resource.clickLightChangeAttributes}</p>`
  461. );
  462. }
  463. );
  464. spotOrDirectionalLightSourceDrawHandler.drawEvt.addEventListener(
  465. (result) => {
  466. let positions = (result.object && result.object.positions) || result;
  467. if (positions.length !== 2) {
  468. return;
  469. }
  470. let locations = [];
  471. locations.push(
  472. this.cartesianToWgs84(
  473. positions[0].x,
  474. positions[0].y,
  475. positions[0].z
  476. )
  477. );
  478. locations.push(
  479. this.cartesianToWgs84(
  480. positions[1].x,
  481. positions[1].y,
  482. positions[1].z
  483. )
  484. );
  485. this.dgyform.location = locations;
  486. if (that.dgyform.lighttype === "聚光灯") {
  487. let spotLightOptions = {
  488. color: Cesium.Color.fromCssColorString(this.dgyform.color),
  489. distance: Number(this.dgyform.cutoffdistance),
  490. decay: Number(this.dgyform.decay),
  491. intensity: Number(this.dgyform.intensity),
  492. angle: Cesium.Math.toRadians(Number(30)),
  493. };
  494. let spotLight = new Cesium.SpotLight(
  495. positions[0],
  496. positions[1],
  497. spotLightOptions
  498. );
  499. scene.addLightSource(spotLight);
  500. if (this.dgyform.LightSource) {
  501. scene.removeLightSource(this.dgyform.LightSource);
  502. }
  503. this.dgyform.LightSource = spotLight;
  504. let entityAsKey = viewer.entities.add({
  505. id: "spot-light-" + new Date().getTime(),
  506. position: positions[0],
  507. billboard: {
  508. image: "@/../static/images/lightSource/spotLight.png",
  509. scaleByDistance: new Cesium.NearFarScalar(10, 1.0, 1000, 0.1), // 按照距离调整图片的大小
  510. disableDepthTestDistance: Number.POSITIVE_INFINITY, // 关闭深度检测,使billboard不至于被裁剪
  511. },
  512. });
  513. entitySpotLightPairs.set(entityAsKey, spotLight);
  514. } else if (that.dgyform.lighttype === "直射光") {
  515. let directionalLightOptions = {
  516. targetPosition: positions[1],
  517. color: Cesium.Color.fromCssColorString(this.dgyform.color),
  518. intensity: Number(this.dgyform.intensity),
  519. };
  520. let directionalLight = new Cesium.DirectionalLight(
  521. positions[0],
  522. directionalLightOptions
  523. );
  524. scene.addLightSource(directionalLight);
  525. if (this.dgyform.LightSource) {
  526. scene.removeLightSource(this.dgyform.LightSource);
  527. }
  528. this.dgyform.LightSource = directionalLight;
  529. let entityAsKey = viewer.entities.add({
  530. id: "directional-light-" + new Date().getTime(),
  531. position: positions[0],
  532. billboard: {
  533. image: "@/../static/images/lightSource/directionalLight.png",
  534. scaleByDistance: new Cesium.NearFarScalar(10, 1.0, 1000, 0.1),
  535. disableDepthTestDistance: Number.POSITIVE_INFINITY, // 关闭深度检测,使billboard不至于被裁剪
  536. },
  537. });
  538. entityDirectionalLightPairs.set(entityAsKey, directionalLight);
  539. }
  540. spotOrDirectionalLightPositions = [];
  541. spotOrDirectionalLightSourceDrawHandler.clear();
  542. spotOrDirectionalLightSourceDrawHandler = null;
  543. this.tooltip.setVisible(false);
  544. }
  545. );
  546. spotOrDirectionalLightSourceCountHandler.setInputAction(function (e) {
  547. if (spotOrDirectionalLightSourceAdding) {
  548. spotOrDirectionalLightPositions.push(scene.pickPosition(e.position));
  549. if (spotOrDirectionalLightPositions.length === 2) {
  550. if (spotOrDirectionalLightSourceCountHandler) {
  551. spotOrDirectionalLightSourceCountHandler.destroy();
  552. spotOrDirectionalLightSourceCountHandler = undefined;
  553. }
  554. spotOrDirectionalLightSourceDrawHandler.deactivate();
  555. spotOrDirectionalLightSourceAdding = false;
  556. spotOrDirectionalLightSourceDrawHandler.drawEvt.raiseEvent(
  557. spotOrDirectionalLightPositions
  558. );
  559. }
  560. }
  561. }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
  562. },
  563. addLightSource(gyData) {
  564. switch (gyData.lighttype) {
  565. case "点光源":
  566. let option = {
  567. color: Cesium.Color.fromCssColorString(gyData.color),
  568. cutoffDistance: Number(gyData.cutoffdistance),
  569. decay: Number(gyData.decay),
  570. intensity: Number(gyData.intensity),
  571. };
  572. let pointLight = new Cesium.PointLight(
  573. new Cesium.Cartesian3.fromDegrees(
  574. gyData.location.x,
  575. gyData.location.y,
  576. gyData.location.z
  577. ),
  578. option
  579. );
  580. scene.addLightSource(pointLight);
  581. gyData.LightSource = pointLight;
  582. break;
  583. case "聚光灯":
  584. let spotLightOptions = {
  585. color: Cesium.Color.fromCssColorString(gyData.color),
  586. distance: Number(gyData.cutoffdistance),
  587. decay: Number(gyData.decay),
  588. intensity: Number(gyData.intensity),
  589. angle: Cesium.Math.toRadians(Number(30)),
  590. };
  591. let spotLight = new Cesium.SpotLight(
  592. new Cesium.Cartesian3.fromDegrees(
  593. gyData.location[0].x,
  594. gyData.location[0].y,
  595. gyData.location[0].z
  596. ),
  597. new Cesium.Cartesian3.fromDegrees(
  598. gyData.location[1].x,
  599. gyData.location[1].y,
  600. gyData.location[1].z
  601. ),
  602. spotLightOptions
  603. );
  604. scene.addLightSource(spotLight);
  605. gyData.LightSource = spotLight;
  606. break;
  607. case "直射光":
  608. let directionalLightOptions = {
  609. targetPosition: new Cesium.Cartesian3.fromDegrees(
  610. gyData.location[1].x,
  611. gyData.location[1].y,
  612. gyData.location[1].z
  613. ),
  614. color: Cesium.Color.fromCssColorString(gyData.color),
  615. intensity: Number(gyData.intensity),
  616. };
  617. let directionalLight = new Cesium.DirectionalLight(
  618. new Cesium.Cartesian3.fromDegrees(
  619. gyData.location[0].x,
  620. gyData.location[0].y,
  621. gyData.location[0].z
  622. ),
  623. directionalLightOptions
  624. );
  625. scene.addLightSource(directionalLight);
  626. gyData.LightSource = directionalLight;
  627. break;
  628. default:
  629. break;
  630. }
  631. },
  632. /**
  633. * 删除灯光
  634. * @param isRemoveLightSource 是否删除临时灯光
  635. */
  636. clearLightSource(isRemoveLightSource = true) {
  637. for (let key of entityPointLightPairs.keys()) {
  638. viewer.entities.remove(key);
  639. if (isRemoveLightSource)
  640. scene.removeLightSource(entityPointLightPairs.get(key));
  641. }
  642. entityPointLightPairs.clear();
  643. for (let key of entitySpotLightPairs.keys()) {
  644. viewer.entities.remove(key);
  645. if (isRemoveLightSource)
  646. scene.removeLightSource(entitySpotLightPairs.get(key));
  647. }
  648. entitySpotLightPairs.clear();
  649. for (let key of entityDirectionalLightPairs.keys()) {
  650. viewer.entities.remove(key);
  651. if (isRemoveLightSource)
  652. scene.removeLightSource(entityDirectionalLightPairs.get(key));
  653. }
  654. entityDirectionalLightPairs.clear();
  655. },
  656. cartesianToWgs84(x, y, z) {
  657. var scene = viewer.scene;
  658. var positionCartesian = new Cesium.Cartesian3(x, y, z);
  659. var positionWGS84 =
  660. scene.globe.ellipsoid.cartesianToCartographic(positionCartesian);
  661. var longitude = Cesium.Math.toDegrees(positionWGS84.longitude);
  662. var latitude = Cesium.Math.toDegrees(positionWGS84.latitude);
  663. var height = positionWGS84.height;
  664. console.log(longitude + "," + latitude + "," + height);
  665. debugger;
  666. return { x: longitude, y: latitude, z: height };
  667. },
  668. },
  669. watch: {
  670. "dgyform.color": function (val, oldVal) {
  671. if (this.dgyform && this.dgyform.LightSource) {
  672. let color = Cesium.Color.fromCssColorString(val);
  673. this.dgyform.LightSource.color = color;
  674. }
  675. },
  676. "dgyform.cutoffdistance": function (val, oldVal) {
  677. if (this.dgyform && this.dgyform.LightSource) {
  678. this.dgyform.LightSource.cutoffDistance = Number(val);
  679. }
  680. },
  681. "dgyform.decay": function (val, oldVal) {
  682. if (this.dgyform && this.dgyform.LightSource) {
  683. this.dgyform.LightSource.decay = Number(val);
  684. }
  685. },
  686. "dgyform.intensity": function (val, oldVal) {
  687. if (this.dgyform && this.dgyform.LightSource) {
  688. this.dgyform.LightSource.intensity = Number(val);
  689. }
  690. },
  691. },
  692. beforeDestroy() {
  693. this.clearLightSource();
  694. this.startNight(false);
  695. },
  696. };
  697. </script>
  698. <style lang="scss">
  699. @import "@/../../zt.scss";
  700. </style>
  701. <style lang="scss" scoped>
  702. .el-card {
  703. border: 0px solid #02a7f0;
  704. }
  705. .el-form-item {
  706. margin-bottom: 0;
  707. }
  708. </style>