lixuliang
2024-04-18 b5c4921d0828500379502a916a2ccf2d9d4acc96
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
<template>
  <div>
    <Popup
      ref="pop"
      :title="form.title"
      width="420px"
      left="calc(100% - 450px)"
      @close="close"
    >
      <el-container class="container" style="height: 100%">
        <el-form class="form" ref="form" :model="form" label-width="100px">
          <el-form-item label="路线名称">
            <el-input v-model="tData.name"></el-input>
          </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"
              @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"
              @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"
              @input="getCameraProperty('pitch')"
              controls-position="right"
            ></el-input-number>
          </el-form-item>
          <el-form-item label="漫游模型">
            <el-input v-model="url" class="input-with-btn">
              <el-button
                slot="append"
                icon="el-icon-folder-opened"
                @click="changeModel"
              ></el-button>
            </el-input>
          </el-form-item>
          <el-form-item label="是否显示模型">
            <el-switch
              v-model="tData.showModel"
              active-color="#13ce66"
              inactive-color="#ff4949"
            >
            </el-switch>
          </el-form-item>
          <el-form-item label="是否显示路线">
            <el-switch
              v-model="tData.showLine"
              active-color="#13ce66"
              inactive-color="#ff4949"
            >
            </el-switch>
          </el-form-item>
          <el-form-item label="速度(km/h)">
            <el-input-number
              v-model="tData.speed"
              :placeholder="'50'"
            ></el-input-number>
          </el-form-item>
          <el-form-item label="路线高程">
            <el-input-number v-model="tData.lineHeight"></el-input-number>
          </el-form-item>
          <el-form-item label="是否循环漫游">
            <el-switch
              v-model="tData.isLoop"
              active-color="#13ce66"
              inactive-color="#ff4949"
            >
            </el-switch>
          </el-form-item>
        </el-form>
      </el-container>
    </Popup>
    <ModelLibrary ref="ModelLibrary" />
  </div>
</template>
 
<script>
import Popup from "@tools/Popup.vue";
import Bus from "@tools/Bus";
import ModelLibrary from "@tools/ModelLibrary";
export default {
  name: "PathAnimationEdit",
  components: { Popup, Bus, ModelLibrary },
  data() {
    return {
      form: {
        title: "路线编辑",
      },
      url: window.SmartEarthRootUrl + "Workers/Model/xiaoche.glb",
      isFly: false,
      notGod: false,
      tData: {},
      viewModel: "0",
      cameraHeight: "50",
      cameraDistance: "10",
      pitch: "-20",
      lineitem: {},
    };
  },
  methods: {
    // 关闭弹窗,初始化所有数据
    close() {
      window.Viewer.entities.remove(this.lineitem);
      Object.assign(this.$data, this.$options.data());
      Bus.$emit("exit");
    },
    // 打开弹窗
    open() {
      this.$refs.pop.open();
      this.loadData();
    },
    // 初始化数据
    loadData() {
      let geometry = this.tData.geojson.geometry.coordinates;
      let line = sgworld.Creator.createPolyline(
        geometry,
        "#ffff00",
        1,
        0,
        "线"
      );
      this.lineitem = line.item;
      sgworld.Navigate.flyToObj(this.lineitem);
    },
    // 控制视角模式变化
    viewmodeChange(value) {
      if (value === "0") {
        this.isFly = false;
        this.notGod = false;
      } else if (value === "1") {
        this.isFly = true;
        this.notGod = true;
      } else if (value === "2") {
        this.isFly = true;
        this.notGod = false;
      }
    },
    // 选择模型
    changeModel() {
      this.$refs.ModelLibrary.open(true);
    },
    // 获取当前视口属性
    getCameraProperty(type) {
      switch (type) {
        case "cameraDistance":
          this.tData &&
            (this.tData.cameraDistance = parseFloat(this.cameraDistance));
          break;
        case "cameraHeight":
          this.tData &&
            (this.tData.cameraHeight = parseFloat(this.cameraHeight));
          break;
        case "pitch":
          this.tData && (this.tData.pitch = parseFloat(this.pitch));
          break;
      }
    },
  },
  mounted() {
    Bus.$off("getModel");
    Bus.$on("getModel", (url) => {
      this.tData && (this.tData.url = url);
      this.url = url;
    });
  },
};
</script>
 
<style scoped lang="less">
@input_width: 280px;
.container {
  margin: 5px;
  height: 400px;
  width: 400px;
  overflow: scroll;
  overflow-x: hidden;
 
  .form {
    width: 100%;
 
    .el-form-item {
      margin-bottom: 5px;
      .el-input {
        width: @input_width;
      }
      .el-input-number {
        width: @input_width;
        /deep/ .el-input-number__increase,
        /deep/.el-input-number__decrease {
          width: 56px;
        }
      }
      /deep/ .el-form-item__label {
        color: white;
        font-size: 14px;
      }
 
      .el-select {
        width: @input_width;
      }
      // /deep/ .el-input__inner{
      //   width: 140px;
      //   display: inline-block;
      // }
    }
  }
  &::-webkit-scrollbar {
    display: none;
    /*滚动条整体样式*/
    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);
  // }
}
</style>