lixuliang
2024-04-19 1fef6dcc04ffe09336e4983c2b05962ad901e545
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
<template>
  <Popup
    ref="pop"
    :title="form.title"
    maxHeight="500px"
    left="calc(100% - 450px)"
    @close="close"
  >
    <div class="btnContainer">
      <el-button
        type="primary"
        align="center"
        v-if="!isstart"
        @click="stop(false)"
        >继续漫游</el-button
      >
      <el-button
        type="primary"
        align="center"
        v-if="isstart"
        @click="stop(true)"
        >暂停漫游</el-button
      >
      <el-button type="primary" align="center" @click="quitRoam"
        >退出漫游</el-button
      >
    </div>
    <el-container class="container">
      <el-form
        class="form"
        ref="form"
        :model="form"
        label-width="100px"
        label-position="left"
      >
        <el-form-item label="路线名称">
          <div>{{ tData.name }}</div>
        </el-form-item>
        <el-form-item label="视角模式">
          <el-select v-model="viewModel" @change="viewmodeChange">
            <el-option label="跟随模型" value="0"></el-option>
            <el-option label="第一人称视角" value="1"></el-option>
            <el-option label="上帝视角" value="2"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="飞行高度" v-if="isFly">
          <el-input-number
            v-model="cameraHeight"
            style="width: 140px"
            @input="getCameraProperty('cameraHeight')"
            controls-position="right"
          ></el-input-number>
        </el-form-item>
        <el-form-item label="飞行距离" v-if="isFly && notGod">
          <el-input-number
            v-model="cameraDistance"
            style="width: 140px"
            @input="getCameraProperty('cameraDistance')"
            controls-position="right"
          ></el-input-number>
        </el-form-item>
        <el-form-item label="俯仰角" v-if="isFly && notGod">
          <el-input-number
            v-model="pitch"
            style="width: 140px"
            @input="getCameraProperty('pitch')"
            controls-position="right"
          ></el-input-number>
        </el-form-item>
        <el-form-item label="总长度">
          <div>{{ getDistance(tData.distance) }}</div>
        </el-form-item>
        <el-form-item label="已漫游长度">
          <div>{{ distanceTraveled }}</div>
        </el-form-item>
        <el-form-item label="总时长">
          <div>{{ getTime(tData.Totaltime) }}</div>
        </el-form-item>
        <el-form-item label="已漫游时间">
          <div>{{ timeTraveled }}</div>
        </el-form-item>
        <el-form-item label="是否显示模型">
          <el-switch
            v-model="tData.showModel"
            active-color="#13ce66"
            inactive-color="#ff4949"
            @change="showModel"
          >
          </el-switch>
        </el-form-item>
        <el-form-item label="是否显示路线">
          <el-switch
            v-model="tData.showLine"
            active-color="#13ce66"
            inactive-color="#ff4949"
            @change="showLine"
          >
          </el-switch>
        </el-form-item>
        <el-form-item label="速度">
          <div>{{ speed }}</div>
        </el-form-item>
        <el-form-item label="播放倍速">
          <el-slider
            @input="setMultiplier"
            :min="0.1"
            :max="10"
            :step="0.1"
            v-model="multiplier"
          ></el-slider>
        </el-form-item>
        <el-form-item label="经度">
          <div>{{ longitude }}</div>
        </el-form-item>
        <el-form-item label="纬度">
          <div>{{ latitude }}</div>
        </el-form-item>
        <el-form-item label="漫游高程">
          <div>{{ getDistance(height) }}</div>
        </el-form-item>
        <el-form-item label="地面高程">
          <div>{{ getDistance(globeHeight) }}</div>
        </el-form-item>
      </el-form>
    </el-container>
    <el-progress
      :text-inside="true"
      :stroke-width="26"
      :percentage="ratio"
    ></el-progress>
  </Popup>
</template>
 
<script>
import Popup from "@tools/Popup.vue";
import Bus from "@tools/Bus";
let fly;
export default {
  name: "PathAnimationSec",
  components: { Popup, Bus },
  data() {
    return {
      form: {
        //窗体数据
        title: "漫游路线",
      },
      isFly: false,
      notGod: false,
      isstart: true, //是否开始漫游
      tData: {}, //当前数据
      viewModel: "0", //视角模式
      distanceTraveled: "0",
      timeTraveled: "0",
      longitude: "0",
      latitude: "0",
      speed: "0",
      height: "0",
      globeHeight: "0",
      ratio: 1,
      cameraHeight: "50",
      cameraDistance: "10",
      pitch: "-20",
      multiplier: 1,
    };
  },
  methods: {
    //退出漫游
    quitRoam() {
      this.close();
      this.$refs.pop.close();
    },
    // 关闭弹窗
    close() {
      fly && fly.exit && fly.exit();
      Object.assign(this.$data, this.$options.data());
      Bus.$emit("exit");
    },
    // 打开弹窗
    open() {
      this.$refs.pop.open();
      this.loadData();
    },
    // 暂停漫游
    stop(value) {
      this.isstart = !this.isstart;
      fly && fly.isPause(value);
    },
    // 控制视角模式变化
    viewmodeChange(value) {
      if (value === "0") {
        fly && fly.changeFlyMode(0);
        this.tData && (this.tData.mode = 0);
        this.isFly = false;
        this.notGod = false;
      } else if (value === "1") {
        fly && fly.changeFlyMode(1);
        this.tData && (this.tData.mode = 1);
        this.isFly = true;
        this.notGod = true;
      } else if (value === "2") {
        fly && fly.changeFlyMode(2);
        this.tData && (this.tData.mode = 2);
        this.isFly = true;
        this.notGod = false;
      }
      this.viewModel = value;
    },
    // 加载路径动画数据
    loadData() {
      let url = window.SmartEarthRootUrl + "Workers/Model/xiaoche.gltf";
      fly = sgworld.Creator.createDynamicObject(
        this.tData,
        this.tData.url || url,
        this.shuj
      );
      this.tData.showModel && this.showModel(this.tData.showModel);
      this.tData.showLine && this.showLine(this.tData.showLine);
      this.tData.cameraHeight && (this.cameraHeight = this.tData.cameraHeight);
      this.tData.cameraDistance &&
        (this.cameraDistance = this.tData.cameraDistance);
      this.tData.pitch && (this.pitch = this.tData.pitch);
      this.tData.mode && this.viewmodeChange(this.tData.mode);
      
    },
    getFly(){
      return fly;
    },
    // 是否展示模型
    showModel(isshow) {
      fly && fly.showModel(isshow);
    },
    // 是否展示模型
    setMultiplier(multiplier) {
      fly && fly.setMultiplier(multiplier);
    },
    //是否展示线路
    showLine(isshow) {
      fly && fly.showLine(isshow);
    },
    // 获取时间
    getTime(data) {
      let time;
      if (data < 60) {
        time = data + "秒";
      } else if (data >= 60 && data < 3600) {
        time = Math.floor(data / 60) + "分" + (data % 60) + "秒";
      } else {
        let h = Math.floor(data / 3600);
        data -= h * 3600;
        let m = Math.floor(data / 60);
        data -= m * 60;
        time = h + "小时" + m + "分" + data + "秒";
      }
      return time;
    },
    // 获取距离
    getDistance(data) {
      let dis;
      data = parseFloat(data).toFixed(2);
      data = parseFloat(data);
      if (data >= 1000) {
        dis = (data / 1000).toFixed(3) + "千米";
      } else {
        dis = data + "米";
      }
      return dis;
    },
    // 获取视角属性
    getCameraProperty(type) {
      switch (type) {
        case "cameraDistance":
          fly && fly.setFlyDistance(parseFloat(this.cameraDistance));
          break;
        case "cameraHeight":
          fly && fly.setFlyHeight(parseFloat(this.cameraHeight));
          break;
        case "pitch":
          fly && fly.setFlyPitch(parseFloat(this.pitch));
          break;
      }
    },
    // 刷新路径动画移动中数据
    shuj(data) {
      debugger
      if (data.distanceTraveled) {
        //已漫游长度
        this.distanceTraveled = this.getDistance(data.distanceTraveled);
      }
      if (data.time) {
        //已漫游时间
        this.timeTraveled = this.getTime(parseInt(data.time));
      }
      if (data.longitude) {
        //经度
        this.longitude = data.longitude.toFixed(7) + "°";
      }
      if (data.latitude) {
        //纬度
        this.latitude = data.latitude.toFixed(7) + "°";
      }
      if (data.speed) {
        //速度
        this.speed = data.speed;
      }
      if (data.height) {
        //高程
        this.height = this.getDistance(data.height);
      }
      if (data.globeHeight) {
        //高程
        this.globeHeight = this.getDistance(data.globeHeight);
      }
      if (data.ratio) {
        //进度
        this.ratio = parseInt(data.ratio * 100);
      }
    },
  },
};
</script>
 
<style scoped lang="less">
.container {
  margin: 5px;
  height: 400px;
  width: 300px;
  overflow: scroll;
  overflow-x: hidden;
  .form {
    width: 100%;
    .el-form-item {
      margin-bottom: 5px;
 
      /deep/ .el-form-item__label {
        color: white;
        font-size: 14px;
      }
      .el-select {
        width: 140px;
      }
      // /deep/ .el-input__inner{
      //   width: 140px;
      //   display: inline-block;
      // }
    }
    .el-slider {
      width: 150px;
    }
  }
 
  &::-webkit-scrollbar {
    /*滚动条整体样式*/
    width: 8px;
    /*高宽分别对应横竖滚动条的尺寸*/
    height: 8px;
    scrollbar-arrow-color: red;
  }
 
  &::-webkit-scrollbar-thumb {
    border-radius: 5px;
    -webkit-box-shadow: inset 0 0 5px rgba(218, 218, 218, 0.2);
    box-shadow: inset 0 0 5px rgba(218, 218, 218, 0.2);
    background: #797979;
    scrollbar-arrow-color: red;
  }
 
  &::-webkit-scrollbar-track {
    -webkit-box-shadow: inset 0 0 5px rgba(218, 218, 218, 0.2);
    box-shadow: inset 0 0 5px rgba(218, 218, 218, 0.2);
    border-radius: 0;
    background: rgba(218, 218, 218, 0.1);
  }
}
 
.btnContainer {
  margin: 5px 15px;
  display: flex;
  justify-content: center;
}
</style>