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
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
/**
 * 工具栏-特效
 */
//流场
var flowFieldValue = 40;
//风场
var WindFarmValue = 40;
//流动线,流动墙
var TrailLine = [];
//链路
var linkData = [];
//扩散
var KS = [];
//雷达
var LD = [];
//清除
import Bus from "@tools/Bus";
import { refreshStyles } from "less";
var particleHandel;
export default {
    methods: {
        addDiffusionTotree(entity, position, maxRadius, color, type) {
            let data = {
                id: window.sgworld.Core.getuid(),
                name: entity.treeobj.name,
                sourceType: type,
                item: entity,
                position,
                maxRadius,
                color,
            }
            Bus.$emit("addOtherData", '特效', data);
        },
        //添加特效
        addParticleEffectTotree(ParticleSystem, name, position) {
            let data = {
                id: window.sgworld.Core.getuid(),
                name: name,
                sourceType: 'ParticleEffect',
                item: ParticleSystem,
                position,
                flyTo: [position.x, position.y, 200],
            }
            Bus.$emit("addOtherData", '特效', data);
        },
        // 特效左键点击事件
        addEffectLeftClick(event, one = true) {
            this.destroyLeftEvent()
 
            particleHandel = sgworld.AttachEvent(
                "OnLButtonClk",
                (movement, degrees) => {
                    one && this.destroyLeftEvent()
                    event && typeof event === 'function' && event(movement, degrees)
                }
            );
            particleHandel.setInputAction(event => {
                tooltip.showAt(event.endPosition, '点击添加特效,右键取消')
            }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
            particleHandel.setInputAction(event => {
                this.destroyLeftEvent()
            }, Cesium.ScreenSpaceEventType.RIGHT_CLICK);
        },
        // 销毁特效事件
        destroyLeftEvent() {
            particleHandel && particleHandel.destroy()
            particleHandel = undefined
 
            tooltip.show(false)
        },
        //特效-烟
        cigarette() {
            let self = this;
            this.addEffectLeftClick(function (movement, degrees) {
                let smog = sgworld.Analysis.createParticleEffect(
                    "smog",
                    {
                        x: degrees.lon,
                        y: degrees.lat,
                        z: degrees.height,
                    },
                    {
                        translation: Cesium.Cartesian3.fromElements(0, 0, 0), //平移
                    },
                );
                self.addParticleEffectTotree(smog, "smog", {
                    x: degrees.lon,
                    y: degrees.lat,
                    z: degrees.height,
                })
            })
        },
        //特效-火
        fire() {
            let self = this;
            this.addEffectLeftClick(function (movement, degrees) {
                let fire = sgworld.Analysis.createParticleEffect(
                    "flame",
                    {
                        x: degrees.lon,
                        y: degrees.lat,
                        z: degrees.height,
                    },
                    {
                        translation: Cesium.Cartesian3.fromElements(0, 0, 0), //平移
                    }
                );
                self.addParticleEffectTotree(fire, "flame", {
                    x: degrees.lon,
                    y: degrees.lat,
                    z: degrees.height,
                })
            });
        },
        //特效-喷泉
        fountain() {
            let self = this;
            this.addEffectLeftClick(function (movement, degrees) {
                let fountain = sgworld.Analysis.createParticleEffect(
                    "fountain",
                    {
                        x: degrees.lon,
                        y: degrees.lat,
                        z: degrees.height,
                    },
                    {
                        translation: Cesium.Cartesian3.fromElements(0, 0, 0), //平移
                    }
                );
                self.addParticleEffectTotree(fountain, "fountain", {
                    x: degrees.lon,
                    y: degrees.lat,
                    z: degrees.height,
                })
            });
        },
        //特效-烟花
        fireworks() {
            let self = this;
            this.addEffectLeftClick(function (movement, degrees) {
                let fireworks = sgworld.Analysis.createParticleEffect(
                    "fireworks",
                    {
                        x: degrees.lon,
                        y: degrees.lat,
                        z: degrees.height,
                    },
                    {}
                );
                self.addParticleEffectTotree(fireworks, "fireworks", {
                    x: degrees.lon,
                    y: degrees.lat,
                    z: degrees.height,
                });
            });
        },
        //特效-流场
        flowField(btn) {
            btn.checked = !btn.checked;
            if (btn.checked) {
                sgworld.Navigate.Stop(); //取消飞行状态
                sgworld.Navigate.flyToPointsInterest({      //跳转视角
                    destination: new Cesium.Cartesian3.fromDegrees(110, 32, 8000000)
                });
                window.liuchang = sgworld.Creator.createField({
                    type: "ocean",
                    upath: SmartEarthRootUrl + "Workers/field/data/MIT.0000000001_UVEL_1.dat",
                    vpath: SmartEarthRootUrl + "Workers/field/data/MIT.0000000001_VVEL_1.dat",
                }, function () {
 
                });
            } else {
                window.liuchang && window.liuchang.destroy();
                window.liuchang = undefined;
            }
        },
        //特效-风场
        WindFarm(btn) {
            btn.checked = !btn.checked;
            if (btn.checked) {
                sgworld.Navigate.Stop(); //取消飞行状态
                sgworld.Navigate.flyToPointsInterest({      //跳转视角
                    destination: new Cesium.Cartesian3.fromDegrees(110, 32, 8000000)
                });
                window.fengchang = sgworld.Creator.createWindField(
                    window.SmartEarthRootUrl + "Workers/json/wind.json",
                    {
                        color: "random",
                        num: flowFieldValue * 15,
                    }
                );
                WindFarmValue = 0;
            } else {
                window.fengchang && window.fengchang.destroy();
                window.fengchang = undefined;
                WindFarmValue = 40;
            }
        },
        //特效-流动线
        FlowLine() {
            sgworld.Creator.createSimpleGraphic(
                "polyline",
                { clampToGround: true },
                (entity) => {
                    if (entity) {
                        let positions = entity.polyline.positions.getValue()
                        let _TrailLine = sgworld.Creator.createTrailLine(
                            positions,
                            {
                                //time: 3000,    //时间(可选)
                                width: 5, //线宽(可选)
                                color: "#0000ff", //线颜色(可选)
                                //url: 'http://183.162.245.49:82/05sdkdemo/src/static/image/TrailLine.png',     //渐变图片链接(可选)
                                clampToGround: true, //是否贴地(可选)
                            }
                        );
                        sgworld.Creator.SimpleGraphic.remove(entity.id);
                        TrailLine.push(_TrailLine);
 
                        let data = {
                            id: _TrailLine.treeobj.id,
                            name: _TrailLine.treeobj.name,
                            sourceType: 'FlowField',
                            style: {
                                width: 5, //线宽(可选)
                                color: "#0000ff", //线颜色(可选)
                                clampToGround: true, //是否贴地(可选)
                            },
                            positions,
                            item: _TrailLine,
                        }
                        data.item.boundingSphere = Cesium.BoundingSphere.fromPoints(positions);
                        Bus.$emit("addOtherData", '特效', data);
                    }
                }
            );
        },
        //特效-流动墙
        MobileWall() {
            sgworld.Creator.createSimpleGraphic(
                "polyline",
                { clampToGround: true },
                (entity) => {
                    if (entity) {
                        let positions = entity.polyline.positions.getValue();
                        addWall(positions, [entity]);
                        sgworld.Creator.SimpleGraphic.remove(entity.id);
                    }
                }
            );
            async function addWall(positions) {
                let LineInterpolation = sgworld.Core.LineInterpolation(Viewer, {
                    positions: positions,
                    num: 50,
                    getHeight: true,
                });
                let min = LineInterpolation.height;
                let max = min.map((item) => {
                    return item + 50;
                });
 
                let _TrailLine = sgworld.Creator.createTrailLineWall(
                    LineInterpolation.positions,
                    {
                        maximumHeights: max,
                        minimumHeights: Array(max.length).fill(0),
                        color: "#ffffff", //线颜色(可选)
                        // url: $('#sdkContainerifm')[0].contentWindow.SmartEarthRootUrl + "Workers/image/colors.png",
                        url: window.SmartEarthRootUrl + "Workers/image/colors.png",
                    }
                );
                TrailLine.push(_TrailLine);
                let data = {
                    id: _TrailLine.treeobj.id,
                    name: _TrailLine.treeobj.name,
                    sourceType: 'MobileWall',
                    style: {
                        maximumHeights: max,
                        minimumHeights: Array(max.length).fill(0),
                        color: "#ffffff", //线颜色(可选)
                        url: window.SmartEarthRootUrl + "Workers/image/colors.png",
                    },
                    LineInterpolation,
                    item: _TrailLine,
                }
                data.item.boundingSphere = Cesium.BoundingSphere.fromPoints(positions);
                Bus.$emit("addOtherData", '特效', data);
            }
 
        },
        //特效-链路 有bug
        link() {
            let _linkData = sgworld.Creator.createLinkPros(
                (entity) => {
                    let data = {
                        id: entity.id,
                        name: entity.name,
                        sourceType: 'link',
                        positions: entity.polyline.positions._value,
                        item: entity,
                    }
                    Bus.$emit("addOtherData", '特效', data);
                }
            );
            linkData.push(_linkData);
        },
        // 光锥体
        effectCone() {
            this.$refs.EffectCone.open();
        },
        //特效圆
        rotateEffectCircle() {
            this.$refs.RotateEffectCircle.open()
        },
        //扩散围墙
        effectCylinder() {
            this.$refs.EffectCylinder.open()
        },
        //垂直飞线
        flyingLine() {
            this.$refs.FlyingLine.open()
        },
        //四面体
        tetrahedron() {
            this.$refs.Tetrahedron.open()
        },
        //特效-圆形扩散
        CircularDiffusion() {
            sgworld.Creator.createSimpleGraphic(
                "circle",
                {},
                (entity) => {
                    let position = sgworld.Core.toDegrees(entity.position.getValue())
                    let maxRadius = entity.ellipse.semiMajorAxis.getValue()
                    sgworld.drawObj = undefined;
                    if (entity) {
                        let circle = sgworld.Analysis.createCircleScan(
                            position,
                            maxRadius,
                            "#00ff00",
                            3000,
                            true
                        );
                        sgworld.Creator.SimpleGraphic.remove(entity.id);
                        KS.push(circle);
                        this.addDiffusionTotree(circle, position, maxRadius, "#00ff00", "CircularDiffusion")
                    }
                }
            );
        },
        //特效-扇形扩散
        FanDiffusion() {
            sgworld.Command.execute(
                1,
                7,
                {
                    fillColor: Cesium.Color.RED.withAlpha(0.7),
                },
                (entity, data) => {
                    Viewer.entities.remove(entity);
 
                    if (entity) {
                        let sxksData = sgworld.Analysis.createSectorScan(
                            data.position,
                            data.distance,
                            "#ff0000",
                            60,
                            data.angle - 30,
                            true,
                            4000,
                            true
                        );
                        KS.push(sxksData);
                        let faninfo = {
                            id: sxksData.treeobj.id,
                            name: sxksData.treeobj.name,
                            sourceType: "FanDiffusion",
                            item: sxksData,
                            position: data.position,
                            distance: data.distance,
                            angle: data.angle - 30,
                        }
                        Bus.$emit("addOtherData", '特效', faninfo);
                    }
                }
            );
        },
        //特效-扩散源
        DiffusionSource() {
            sgworld.Creator.createSimpleGraphic(
                "circle",
                { color: "rgba(255,0,0,0.6)" },
                (entity) => {
                    if (entity) {
                        let position = sgworld.Core.toDegrees(entity.position.getValue())
                        let maxRadius = entity.ellipse.semiMajorAxis.getValue()
                        let circle = sgworld.Analysis.createMultiCircleScan(
                            position,
                            maxRadius,
                            "#ff0000",
                            3000,
                            true
                        );
                        sgworld.Creator.SimpleGraphic.remove(entity.id);
                        KS.push(circle);
                        this.addDiffusionTotree(circle, position, maxRadius, "#ff0000", "DiffusionSource")
                    }
                }
            );
        },
        //特效-风险扩散模拟
        RiskDiffusion() {
            sgworld.Creator.createSimpleGraphic(
                "circle",
                { color: "rgba(255,0,0,0.6)" },
                (entity) => {
                    if (entity) {
                        let position = sgworld.Core.toDegrees(entity.position.getValue())
                        let maxRadius = entity.ellipse.semiMajorAxis.getValue()
                        let circle = sgworld.Analysis.createCircleScan(
                            position,
                            maxRadius,
                            "#ff0000",
                            3000,
                            true
                        );
                        sgworld.Creator.SimpleGraphic.remove(entity.id);
                        KS.push(circle);
                        this.addDiffusionTotree(circle, position, maxRadius, "#ff0000", "RiskDiffusion");
                    }
                }
            );
        },
 
        //特效-雷达扩散模拟
        RadarMask() {
            sgworld.Creator.createSimpleGraphic(
                "circle",
                { color: "rgba(127,255,212,0.5)" },
                (entity) => {
                    if (entity) {
                        let degrees = sgworld.Core.toDegrees(entity.position.getValue());
                        let position = [degrees.lon, degrees.lat, degrees.height];
                        let cylinder = {
                            radius: entity.ellipse.semiMajorAxis.getValue(), //半径
                            angle: 30, //扫描角度(可选)
                            speed: 5, //倍速(可选)
                            stackPartitions: 80, //横向网格数(可选)
                            slicePartitions: 80, //纵向网格数(可选)
                            //color: 'rgba(255,255,255,0.5)',  //球颜色(可选)
                            //outlineColor: 'rgba(255,255,255,0.5)',  //球边框线颜色(可选)
                            wallColor: "rgba(255,255,255,0)", //扫描墙颜色(可选)
                            //wallOutlineColor: 'rgba(255,0,0,0.5)',   //扫描墙颜色(可选)
                            //surfaceColor: 'rgba(255,0,0,0.5)',   //扫描夹角颜色(可选)
                        };
                        let ldData = sgworld.Creator.createRectangularSensor(
                            position,
                            cylinder
                        );
                        sgworld.Creator.SimpleGraphic.remove(entity.id);
                        LD.push(ldData);
                        let data = {
                            id: entity.id,
                            name: "雷达扩散模拟",
                            sourceType: "RadarMask",
                            item: ldData,
                            position,
                            cylinder,
                        }
                        Bus.$emit("addOtherData", '特效', data);
                    }
                }
            );
        },
        //特效-动态卫星正射
        DynamicSatellite() {
            this.addEffectLeftClick(function (movement, degrees) {
                let position = [degrees.lon, degrees.lat, 700000];
                let dtwxzsData = sgworld.Creator.createConeRadar(position, {
                    color: "#7b9ef7",
                    radius: 200000,
                });
                let weixin = sgworld.Creator.createModel(
                    position,
                    window.SmartEarthRootUrl + "Workers/Model/weixin.gltf",
                    { scale: 15 },
                    "0",
                    "卫星"
                );
                LD.push(dtwxzsData, weixin);
                let data = {
                    id: window.sgworld.Core.getuid(),
                    name: dtwxzsData.treeobj.name,
                    sourceType: 'DynamicSatellite',
                    item: {
                        weixin,
                        dtwxzsData,
                    },
                    position,
                    flyTo: position,
                }
                Bus.$emit("addOtherData", '特效', data);
            });
        },
        //特效-清除
        clearTX() {
            // var type = ["fireworks", "fountain", "flame", "smog"];
            // type.forEach((item) => {
            //     sgworld.Analysis.removeParticleEffect(item);
            // });
            // this.destroyLeftEvent()
 
            // TrailLine.forEach((item) => {
            //     item.clear();
            // });
            // TrailLine = [];
 
            // KS.forEach((item) => {
            //     item.remove();
            // });
            // KS = [];
 
            // LD.forEach((item) => {
            //     item.deleteObject();
            // });
            // LD = [];
            // linkData.forEach((item) => {
            //     Viewer.entities.remove(item.item);
            // });
            Bus.$emit("clearFirstParentNode", '特效');
            this.$message.info("添加特效已全部清除");
        },
    }
}