TrackRoam.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <script setup>
  2. /**
  3. * element-plus组件
  4. */
  5. import {
  6. ElMessage
  7. } from 'element-plus';
  8. import {
  9. inject
  10. } from "vue";
  11. const getMapInstance = inject("getMapInstance");
  12. jt3d = getMapInstance();
  13. </script>
  14. <template>
  15. <div class="jt-TrackRoam">
  16. <el-row style="margin-bottom: 5px;">
  17. <el-button type="danger" v-if="isNew" @click="drawLine()">
  18. <el-icon>
  19. <Plus />
  20. </el-icon>新增漫游
  21. </el-button>
  22. <el-button type="danger" v-if="!isNew" @click="flightRoaming('remove')">
  23. <el-icon>
  24. <Delete />
  25. </el-icon>
  26. 退出漫游
  27. </el-button>
  28. </el-row>
  29. <el-row style="margin-bottom: 5px;" v-if="!isNew">
  30. <el-button type="danger" v-if="isBackward" @click="flightRoaming('playReverse')">
  31. <el-icon>
  32. <Back />
  33. </el-icon>向后飞行
  34. </el-button>
  35. <el-button type="danger" v-if="!isBackward" @click="flightRoaming('playForward')">
  36. <el-icon>
  37. <Right />
  38. </el-icon>向前飞行
  39. </el-button>
  40. <el-button type="danger" v-if="isPause" @click="flightRoaming('pause')">
  41. <el-icon>
  42. <VideoPause />
  43. </el-icon>暂停漫游
  44. </el-button>
  45. <el-button type="danger" v-if="!isPause" @click="flightRoaming('pause')">
  46. <el-icon>
  47. <VideoPlay />
  48. </el-icon>继续漫游
  49. </el-button>
  50. </el-row>
  51. <el-row style="margin-bottom: 5px;" v-if="!isNew">
  52. <el-button type="danger" @click="flightRoaming(0)">
  53. 自由漫游
  54. </el-button>
  55. <el-button type="danger" @click="flightRoaming(1)">
  56. 相机跟随
  57. </el-button>
  58. </el-row>
  59. <el-row style="margin-bottom: 5px;" v-if="!isNew">
  60. <el-button type="danger" @click="flightRoaming(2)">
  61. 第一视角
  62. </el-button>
  63. <el-button type="danger" @click="flightRoaming(3)">
  64. 上帝视角
  65. </el-button>
  66. </el-row>
  67. <el-form label-width="130rem">
  68. <el-form-item label="飞行速度:" v-if="!isNew">
  69. <el-slider v-model="roam.speed" @input="handleSpeedChange" :max="100" :min="1" :step="1" />
  70. </el-form-item>
  71. <el-form-item label="距离运动点的距离(后方):" v-if="roam.role===2">
  72. <el-slider v-model="roam.followedX" @input="handleFollowedXChange" :max="10000" :min="1" :step="1" />
  73. </el-form-item>
  74. <el-form-item label="距离运动点的距离(上方):" v-if="roam.role===2">
  75. <el-slider v-model="roam.followedZ" @input="handleFollowedZChange" :max="10000" :min="1" :step="1" />
  76. </el-form-item>
  77. </el-form>
  78. </div>
  79. </template>
  80. <script>
  81. let jt3d = undefined;
  82. export default {
  83. data() {
  84. return {
  85. isNew: true,
  86. isPause: true,
  87. isBackward: true,
  88. Roaming: undefined,
  89. roam: {
  90. role: 0,
  91. speed: 10,
  92. followedX: 50,
  93. followedZ: 10
  94. }
  95. }
  96. },
  97. /* 方法 */
  98. methods: {
  99. handleFollowedXChange(followedX) {
  100. this.Roaming.followedX = followedX;
  101. },
  102. handleFollowedZChange(followedZ) {
  103. this.Roaming.followedZ = followedZ;
  104. },
  105. handleSpeedChange(speed) {
  106. this.Roaming.ChangeRoamingSpeed(speed);
  107. },
  108. /**
  109. * 绘制飞行路线
  110. */
  111. drawLine() {
  112. let _self = this;
  113. jt3d.DrawTools.draw('polyline', {
  114. isEdit: false,
  115. onComplete(cartesian3d, points) {
  116. //清除绘制
  117. jt3d.DrawTools.Clear();
  118. _self.Roaming = new _self.jt3dSDK.Roaming(jt3d._viewer, cartesian3d, {
  119. time: 360,
  120. role: 2,
  121. // label: {
  122. // text: "lineName",
  123. // }
  124. });
  125. _self.isPause = true;
  126. _self.isNew = false;
  127. _self.roam.role = 2;
  128. _self.Roaming.PauseOrContinue(_self.isPause);
  129. }
  130. });
  131. },
  132. /**
  133. * 飞行漫游
  134. * @param {Object} type
  135. */
  136. flightRoaming(type) {
  137. let _self = this;
  138. switch (type) {
  139. case "pause": //暂停飞行
  140. this.isPause = !this.isPause;
  141. this.Roaming.PauseOrContinue(this.isPause);
  142. break;
  143. case "playForward": //向前飞行
  144. this.isPause = true;
  145. this.isBackward = !this.isBackward;
  146. this.Roaming.forwardFly();
  147. break;
  148. case "playReverse": //向后飞行
  149. this.isPause = true;
  150. this.isBackward = !this.isBackward;
  151. this.Roaming.backwardsFly();
  152. break;
  153. case "remove": //向后飞行
  154. this.isNew = true;
  155. this.roam.role = Number(type);
  156. this.Roaming.EndRoaming();
  157. // //获取被clock监听的全部事件数量
  158. // let len = jt3d._viewer.clock.onTick.numberOfListeners;
  159. // for (let i = 0; i < len; i++) {
  160. // //将被监听的方法移除来停止方法
  161. // jt3d._viewer.clock.onTick.removeEventListener(jt3d._viewer.clock.onTick._listeners[i]);
  162. // }
  163. break;
  164. case 0:
  165. this.roam.role = Number(type);
  166. this.Roaming.initRole(0);
  167. break;
  168. case 1:
  169. this.roam.role = Number(type);
  170. this.Roaming.initRole(1);
  171. break;
  172. case 2:
  173. this.roam.role = Number(type);
  174. this.Roaming.followedX = -100;
  175. this.Roaming.followedZ = 50;
  176. this.Roaming.initRole(2);
  177. break;
  178. case 3:
  179. this.roam.role = Number(type);
  180. this.Roaming.followedX = -50;
  181. this.Roaming.followedZ = 250;
  182. this.Roaming.initRole(3);
  183. break;
  184. }
  185. },
  186. },
  187. mounted() {
  188. }
  189. };
  190. </script>
  191. <style lang="scss" scoped>
  192. ::v-deep .el-table .cell {
  193. line-height: 23rem !important;
  194. padding: 0 12rem !important;
  195. font-size: 14rem;
  196. }
  197. //整体样式
  198. .jt-TrackRoam {
  199. width: 90%;
  200. margin-top: 16rem;
  201. margin-left: 5%;
  202. text-align: left;
  203. --el-bg-color: rgb(0 44 126 / 60%);
  204. --el-fill-color-blank: rgb(0 44 126 / 60%);
  205. --el-text-color-secondary: rgb(216 240 255); //title
  206. --el-text-color-regular: rgb(216 240 255); //内容
  207. --el-fill-color-light: rgb(30 130 255);
  208. .el-icon {
  209. margin-right: 5rem;
  210. color: #fff;
  211. }
  212. }
  213. </style>