vesium 1.0.1-beta.50 → 1.0.1-beta.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1420 -1318
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1323 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +1323 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.iife.js +1624 -1519
- package/dist/index.iife.js.map +1 -1
- package/dist/index.iife.min.js +2 -2
- package/dist/index.iife.min.js.map +1 -1
- package/dist/index.min.cjs +2 -2
- package/dist/index.min.cjs.map +1 -1
- package/dist/index.min.mjs +2 -2
- package/dist/index.min.mjs.map +1 -1
- package/dist/index.mjs +1398 -1380
- package/dist/index.mjs.map +1 -1
- package/package.json +18 -16
- package/dist/index.d.ts +0 -1329
package/dist/index.iife.js
CHANGED
|
@@ -1,1519 +1,1624 @@
|
|
|
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
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
}
|
|
1519
|
-
|
|
1
|
+
(function(exports, __vueuse_core, cesium, vue) {
|
|
2
|
+
|
|
3
|
+
//#region rolldown:runtime
|
|
4
|
+
var __create = Object.create;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
12
|
+
key = keys[i];
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
21
|
+
value: mod,
|
|
22
|
+
enumerable: true
|
|
23
|
+
}) : target, mod));
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
__vueuse_core = __toESM(__vueuse_core);
|
|
27
|
+
cesium = __toESM(cesium);
|
|
28
|
+
vue = __toESM(vue);
|
|
29
|
+
|
|
30
|
+
//#region createViewer/index.ts
|
|
31
|
+
/**
|
|
32
|
+
* @internal
|
|
33
|
+
*/
|
|
34
|
+
const CREATE_VIEWER_INJECTION_KEY = Symbol("CREATE_VIEWER_INJECTION_KEY");
|
|
35
|
+
/**
|
|
36
|
+
* @internal
|
|
37
|
+
*/
|
|
38
|
+
const CREATE_VIEWER_COLLECTION = /* @__PURE__ */ new WeakMap();
|
|
39
|
+
/**
|
|
40
|
+
*/
|
|
41
|
+
function createViewer(...args) {
|
|
42
|
+
const viewer = (0, vue.shallowRef)();
|
|
43
|
+
const readonlyViewer = (0, vue.shallowReadonly)(viewer);
|
|
44
|
+
(0, vue.provide)(CREATE_VIEWER_INJECTION_KEY, readonlyViewer);
|
|
45
|
+
const scope = (0, vue.getCurrentScope)();
|
|
46
|
+
if (scope) CREATE_VIEWER_COLLECTION.set(scope, readonlyViewer);
|
|
47
|
+
const canvas = (0, vue.computed)(() => viewer.value?.canvas);
|
|
48
|
+
(0, __vueuse_core.useMutationObserver)(document?.body, () => {
|
|
49
|
+
if (canvas.value && !document?.body.contains(canvas.value)) viewer.value = void 0;
|
|
50
|
+
}, {
|
|
51
|
+
childList: true,
|
|
52
|
+
subtree: true
|
|
53
|
+
});
|
|
54
|
+
(0, vue.watchEffect)((onCleanup) => {
|
|
55
|
+
const [arg1, arg2] = args;
|
|
56
|
+
const value = (0, vue.toRaw)((0, vue.toValue)(arg1));
|
|
57
|
+
if (value instanceof cesium.Viewer) viewer.value = (0, vue.markRaw)(value);
|
|
58
|
+
else if (value) {
|
|
59
|
+
const element = value;
|
|
60
|
+
const options = arg2;
|
|
61
|
+
viewer.value = new cesium.Viewer(element, options);
|
|
62
|
+
onCleanup(() => !viewer.value?.isDestroyed() && viewer.value?.destroy());
|
|
63
|
+
} else viewer.value = void 0;
|
|
64
|
+
});
|
|
65
|
+
(0, __vueuse_core.tryOnScopeDispose)(() => {
|
|
66
|
+
viewer.value = void 0;
|
|
67
|
+
});
|
|
68
|
+
return (0, vue.computed)(() => {
|
|
69
|
+
return viewer.value?.isDestroyed() ? void 0 : viewer.value;
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region utils/arrayDiff.ts
|
|
75
|
+
/**
|
|
76
|
+
* 计算两个数组的差异,返回新增和删除的元素
|
|
77
|
+
*/
|
|
78
|
+
function arrayDiff(list, oldList) {
|
|
79
|
+
const oldListSet = new Set(oldList);
|
|
80
|
+
const added = list.filter((obj) => !oldListSet.has(obj));
|
|
81
|
+
const newListSet = new Set(list);
|
|
82
|
+
const removed = oldList?.filter((obj) => !newListSet.has(obj)) ?? [];
|
|
83
|
+
return {
|
|
84
|
+
added,
|
|
85
|
+
removed
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region utils/canvasCoordToCartesian.ts
|
|
91
|
+
/**
|
|
92
|
+
* Convert canvas coordinates to Cartesian coordinates
|
|
93
|
+
*
|
|
94
|
+
* @param canvasCoord Canvas coordinates
|
|
95
|
+
* @param scene Cesium.Scene instance
|
|
96
|
+
* @param mode optional values are 'pickPosition' | 'globePick' | 'auto' | 'noHeight' @default 'auto'
|
|
97
|
+
*
|
|
98
|
+
* `pickPosition`: Use scene.pickPosition for conversion, which can be used for picking models, oblique photography, etc.
|
|
99
|
+
* However, if depth detection is not enabled (globe.depthTestAgainstTerrain=false), picking terrain or inaccurate issues may occur
|
|
100
|
+
*
|
|
101
|
+
* `globePick`: Use camera.getPickRay for conversion, which cannot be used for picking models or oblique photography,
|
|
102
|
+
* but can be used for picking terrain. If terrain does not exist, the picked elevation is 0
|
|
103
|
+
*
|
|
104
|
+
* `auto`: Automatically determine which picking content to return
|
|
105
|
+
*
|
|
106
|
+
* Calculation speed comparison: globePick > auto >= pickPosition
|
|
107
|
+
*/
|
|
108
|
+
function canvasCoordToCartesian(canvasCoord, scene, mode = "auto") {
|
|
109
|
+
if (mode === "pickPosition") return scene.pickPosition(canvasCoord);
|
|
110
|
+
else if (mode === "globePick") {
|
|
111
|
+
const ray = scene.camera.getPickRay(canvasCoord);
|
|
112
|
+
return ray && scene.globe.pick(ray, scene);
|
|
113
|
+
} else {
|
|
114
|
+
if (scene.globe.depthTestAgainstTerrain) return scene.pickPosition(canvasCoord);
|
|
115
|
+
const position1 = scene.pickPosition(canvasCoord);
|
|
116
|
+
const ray = scene.camera.getPickRay(canvasCoord);
|
|
117
|
+
const position2 = ray && scene.globe.pick(ray, scene);
|
|
118
|
+
if (!position1) return position2;
|
|
119
|
+
const height1 = (position1 && cesium.Ellipsoid.WGS84.cartesianToCartographic(position1).height) ?? 0;
|
|
120
|
+
const height2 = (position2 && cesium.Ellipsoid.WGS84.cartesianToCartographic(position2).height) ?? 0;
|
|
121
|
+
return height1 < height2 ? position1 : position2;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
//#endregion
|
|
126
|
+
//#region utils/cartesianToCanvasCoord.ts
|
|
127
|
+
/**
|
|
128
|
+
* Convert Cartesian coordinates to canvas coordinates
|
|
129
|
+
*
|
|
130
|
+
* @param position Cartesian coordinates
|
|
131
|
+
* @param scene Cesium.Scene instance
|
|
132
|
+
*/
|
|
133
|
+
function cartesianToCanvasCoord(position, scene) {
|
|
134
|
+
return scene.cartesianToCanvasCoordinates(position);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
//#endregion
|
|
138
|
+
//#region utils/is.ts
|
|
139
|
+
const toString = Object.prototype.toString;
|
|
140
|
+
function isDef(val) {
|
|
141
|
+
return typeof val !== "undefined";
|
|
142
|
+
}
|
|
143
|
+
function isBoolean(val) {
|
|
144
|
+
return typeof val === "boolean";
|
|
145
|
+
}
|
|
146
|
+
function isFunction(val) {
|
|
147
|
+
return typeof val === "function";
|
|
148
|
+
}
|
|
149
|
+
function isNumber(val) {
|
|
150
|
+
return typeof val === "number";
|
|
151
|
+
}
|
|
152
|
+
function isString(val) {
|
|
153
|
+
return typeof val === "string";
|
|
154
|
+
}
|
|
155
|
+
function isObject(val) {
|
|
156
|
+
return toString.call(val) === "[object Object]";
|
|
157
|
+
}
|
|
158
|
+
function isWindow(val) {
|
|
159
|
+
return typeof window !== "undefined" && toString.call(val) === "[object Window]";
|
|
160
|
+
}
|
|
161
|
+
function isPromise(val) {
|
|
162
|
+
return !!val && (typeof val === "object" || typeof val === "function") && typeof val.then === "function";
|
|
163
|
+
}
|
|
164
|
+
function isElement(val) {
|
|
165
|
+
return !!(val && val.nodeName && val.nodeType === 1);
|
|
166
|
+
}
|
|
167
|
+
const isArray = Array.isArray;
|
|
168
|
+
function isBase64(val) {
|
|
169
|
+
const reg = /^\s*data:([a-z]+\/[\d+.a-z-]+(;[a-z-]+=[\da-z-]+)?)?(;base64)?,([\s\w!$%&'()*+,./:;=?@~-]*?)\s*$/i;
|
|
170
|
+
return reg.test(val);
|
|
171
|
+
}
|
|
172
|
+
function assertError(condition, error) {
|
|
173
|
+
if (condition) throw new Error(error);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
//#endregion
|
|
177
|
+
//#region utils/cesiumEquals.ts
|
|
178
|
+
/**
|
|
179
|
+
* Determines if two Cesium objects are equal.
|
|
180
|
+
*
|
|
181
|
+
* This function not only judges whether the instances are equal,
|
|
182
|
+
* but also judges the equals method in the example.
|
|
183
|
+
*
|
|
184
|
+
* @param left The first Cesium object
|
|
185
|
+
* @param right The second Cesium object
|
|
186
|
+
* @returns Returns true if the two Cesium objects are equal, otherwise false
|
|
187
|
+
*/
|
|
188
|
+
function cesiumEquals(left, right) {
|
|
189
|
+
return left === right || isFunction(left?.equals) && left.equals(right) || isFunction(right?.equals) && right.equals(left);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
//#endregion
|
|
193
|
+
//#region utils/toCoord.ts
|
|
194
|
+
/**
|
|
195
|
+
* Converts coordinates to an array or object in the specified format.
|
|
196
|
+
*
|
|
197
|
+
* @param position The coordinate to be converted, which can be a Cartesian3, Cartographic, array, or object.
|
|
198
|
+
* @param options Conversion options, including conversion type and whether to include altitude information.
|
|
199
|
+
* @returns The converted coordinate, which may be an array or object. If the input position is empty, undefined is returned.
|
|
200
|
+
*
|
|
201
|
+
* @template T Conversion type, optional values are 'Array' or 'Object', @default 'Array'.
|
|
202
|
+
* @template Alt Whether to include altitude information, default is false
|
|
203
|
+
*/
|
|
204
|
+
function toCoord(position, options = {}) {
|
|
205
|
+
if (!position) return void 0;
|
|
206
|
+
const { type = "Array", alt = false } = options;
|
|
207
|
+
let longitude, latitude, height;
|
|
208
|
+
if (position instanceof cesium.Cartesian3) {
|
|
209
|
+
const cartographic = cesium.Ellipsoid.WGS84.cartesianToCartographic(position);
|
|
210
|
+
longitude = cesium.Math.toDegrees(cartographic.longitude);
|
|
211
|
+
latitude = cesium.Math.toDegrees(cartographic.latitude);
|
|
212
|
+
height = cartographic.height;
|
|
213
|
+
} else if (position instanceof cesium.Cartographic) {
|
|
214
|
+
const cartographic = position;
|
|
215
|
+
longitude = cesium.Math.toDegrees(cartographic.longitude);
|
|
216
|
+
latitude = cesium.Math.toDegrees(cartographic.latitude);
|
|
217
|
+
height = cartographic.height;
|
|
218
|
+
} else if (Array.isArray(position)) {
|
|
219
|
+
longitude = cesium.Math.toDegrees(position[0]);
|
|
220
|
+
latitude = cesium.Math.toDegrees(position[1]);
|
|
221
|
+
height = position[2];
|
|
222
|
+
} else {
|
|
223
|
+
longitude = position.longitude;
|
|
224
|
+
latitude = position.latitude;
|
|
225
|
+
height = position.height;
|
|
226
|
+
}
|
|
227
|
+
if (type === "Array") return alt ? [
|
|
228
|
+
longitude,
|
|
229
|
+
latitude,
|
|
230
|
+
height
|
|
231
|
+
] : [longitude, latitude];
|
|
232
|
+
else return alt ? {
|
|
233
|
+
longitude,
|
|
234
|
+
latitude,
|
|
235
|
+
height
|
|
236
|
+
} : {
|
|
237
|
+
longitude,
|
|
238
|
+
latitude
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
//#endregion
|
|
243
|
+
//#region utils/convertDMS.ts
|
|
244
|
+
/**
|
|
245
|
+
* Convert degrees to DMS (Degrees Minutes Seconds) format string
|
|
246
|
+
*
|
|
247
|
+
* @param degrees The angle value
|
|
248
|
+
* @param precision The number of decimal places to retain for the seconds, defaults to 3
|
|
249
|
+
* @returns A DMS formatted string in the format: degrees° minutes′ seconds″
|
|
250
|
+
*/
|
|
251
|
+
function dmsEncode(degrees, precision = 3) {
|
|
252
|
+
const str = `${degrees}`;
|
|
253
|
+
let i = str.indexOf(".");
|
|
254
|
+
const d = i < 0 ? str : str.slice(0, Math.max(0, i));
|
|
255
|
+
let m = "0";
|
|
256
|
+
let s = "0";
|
|
257
|
+
if (i > 0) {
|
|
258
|
+
m = `0${str.slice(Math.max(0, i))}`;
|
|
259
|
+
m = `${+m * 60}`;
|
|
260
|
+
i = m.indexOf(".");
|
|
261
|
+
if (i > 0) {
|
|
262
|
+
s = `0${m.slice(Math.max(0, i))}`;
|
|
263
|
+
m = m.slice(0, Math.max(0, i));
|
|
264
|
+
s = `${+s * 60}`;
|
|
265
|
+
i = s.indexOf(".");
|
|
266
|
+
s = s.slice(0, Math.max(0, i + 4));
|
|
267
|
+
s = (+s).toFixed(precision);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
return `${Math.abs(+d)}°${+m}′${+s}″`;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Decode a DMS (Degrees Minutes Seconds) formatted string to a decimal angle value
|
|
274
|
+
*
|
|
275
|
+
* @param dmsCode DMS formatted string, e.g. "120°30′45″N"
|
|
276
|
+
* @returns The decoded decimal angle value, or 0 if decoding fails
|
|
277
|
+
*/
|
|
278
|
+
function dmsDecode(dmsCode) {
|
|
279
|
+
const [dd, msStr] = dmsCode.split("°") ?? [];
|
|
280
|
+
const [mm, sStr] = msStr?.split("′") ?? [];
|
|
281
|
+
const ss = sStr?.split("″")[0];
|
|
282
|
+
const d = Number(dd) || 0;
|
|
283
|
+
const m = (Number(mm) || 0) / 60;
|
|
284
|
+
const s = (Number(ss) || 0) / 60 / 60;
|
|
285
|
+
const degrees = d + m + s;
|
|
286
|
+
if (degrees === 0) return 0;
|
|
287
|
+
else {
|
|
288
|
+
let res = degrees;
|
|
289
|
+
if ([
|
|
290
|
+
"W",
|
|
291
|
+
"w",
|
|
292
|
+
"S",
|
|
293
|
+
"s"
|
|
294
|
+
].includes(dmsCode[dmsCode.length - 1])) res = -res;
|
|
295
|
+
return res;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Convert latitude and longitude coordinates to degrees-minutes-seconds format
|
|
300
|
+
*
|
|
301
|
+
* @param position The latitude and longitude coordinates
|
|
302
|
+
* @param precision The number of decimal places to retain for 'seconds', default is 3
|
|
303
|
+
* @returns Returns the coordinates in degrees-minutes-seconds format, or undefined if the conversion fails
|
|
304
|
+
*/
|
|
305
|
+
function degreesToDms(position, precision = 3) {
|
|
306
|
+
const coord = toCoord(position, { alt: true });
|
|
307
|
+
if (!coord) return;
|
|
308
|
+
const [longitude, latitude, height] = coord;
|
|
309
|
+
const x = dmsEncode(longitude, precision);
|
|
310
|
+
const y = dmsEncode(latitude, precision);
|
|
311
|
+
return [
|
|
312
|
+
`${x}${longitude > 0 ? "E" : "W"}`,
|
|
313
|
+
`${y}${latitude > 0 ? "N" : "S"}`,
|
|
314
|
+
height
|
|
315
|
+
];
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Convert DMS (Degrees Minutes Seconds) format to decimal degrees for latitude and longitude coordinates
|
|
319
|
+
*
|
|
320
|
+
* @param dms The latitude or longitude coordinate in DMS format
|
|
321
|
+
* @returns Returns the coordinate in decimal degrees format, or undefined if the conversion fails
|
|
322
|
+
*/
|
|
323
|
+
function dmsToDegrees(dms) {
|
|
324
|
+
const [x, y, height] = dms;
|
|
325
|
+
const longitude = dmsDecode(x);
|
|
326
|
+
const latitude = dmsDecode(y);
|
|
327
|
+
return [
|
|
328
|
+
longitude,
|
|
329
|
+
latitude,
|
|
330
|
+
Number(height) || 0
|
|
331
|
+
];
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
//#endregion
|
|
335
|
+
//#region utils/isCesiumConstant.ts
|
|
336
|
+
/**
|
|
337
|
+
* Determines if the Cesium property is a constant.
|
|
338
|
+
*
|
|
339
|
+
* @param value Cesium property
|
|
340
|
+
*/
|
|
341
|
+
function isCesiumConstant(value) {
|
|
342
|
+
return !(0, cesium.defined)(value) || !!value.isConstant;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
//#endregion
|
|
346
|
+
//#region utils/material.ts
|
|
347
|
+
/**
|
|
348
|
+
* Only as a type fix for `Cesium.Material`
|
|
349
|
+
*/
|
|
350
|
+
var CesiumMaterial = class extends cesium.Material {
|
|
351
|
+
constructor(options) {
|
|
352
|
+
super(options);
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
/**
|
|
356
|
+
* Get material from cache, alias of `Material._materialCache.getMaterial`
|
|
357
|
+
*/
|
|
358
|
+
function getMaterialCache(type) {
|
|
359
|
+
return cesium.Material._materialCache.getMaterial(type);
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Add material to Cesium's material cache, alias of `Material._materialCache.addMaterial`
|
|
363
|
+
*/
|
|
364
|
+
function addMaterialCache(type, material) {
|
|
365
|
+
return cesium.Material._materialCache.addMaterial(type, material);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
//#endregion
|
|
369
|
+
//#region utils/pick.ts
|
|
370
|
+
/**
|
|
371
|
+
* Analyze the result of Cesium's `scene.pick` and convert it to an array format
|
|
372
|
+
*/
|
|
373
|
+
function resolvePick(pick = {}) {
|
|
374
|
+
const { primitive, id, primitiveCollection, collection } = pick;
|
|
375
|
+
const entityCollection = id && id.entityCollection || null;
|
|
376
|
+
const dataSource = entityCollection && entityCollection.owner || null;
|
|
377
|
+
const ids = Array.isArray(id) ? id : [id].filter(Boolean);
|
|
378
|
+
return [
|
|
379
|
+
...ids,
|
|
380
|
+
primitive,
|
|
381
|
+
primitiveCollection,
|
|
382
|
+
collection,
|
|
383
|
+
entityCollection,
|
|
384
|
+
dataSource
|
|
385
|
+
].filter((e) => !!e);
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Determine if the given array of graphics is hit by Cesium's `scene.pick`
|
|
389
|
+
*
|
|
390
|
+
* @param pick The `scene.pick` object used for matching
|
|
391
|
+
* @param graphic An array of graphics to check for hits
|
|
392
|
+
*/
|
|
393
|
+
function pickHitGraphic(pick, graphic) {
|
|
394
|
+
if (!Array.isArray(graphic) || !graphic.length) return false;
|
|
395
|
+
const elements = resolvePick(pick);
|
|
396
|
+
if (!elements.length) return false;
|
|
397
|
+
return elements.some((element) => graphic.includes(element));
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
//#endregion
|
|
401
|
+
//#region utils/property.ts
|
|
402
|
+
/**
|
|
403
|
+
* Is Cesium.Property
|
|
404
|
+
* @param value - The target object
|
|
405
|
+
*/
|
|
406
|
+
function isProperty(value) {
|
|
407
|
+
return value && isFunction(value.getValue);
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Converts a value that may be a Property into its target value, @see {toProperty} for the reverse operation
|
|
411
|
+
* ```typescript
|
|
412
|
+
* toPropertyValue('val') //=> 'val'
|
|
413
|
+
* toPropertyValue(new ConstantProperty('val')) //=> 'val'
|
|
414
|
+
* toPropertyValue(new CallbackProperty(()=>'val')) //=> 'val'
|
|
415
|
+
* ```
|
|
416
|
+
*
|
|
417
|
+
* @param value - The value to convert
|
|
418
|
+
*/
|
|
419
|
+
function toPropertyValue(value, time) {
|
|
420
|
+
return isProperty(value) ? value.getValue(time) : value;
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* Converts a value that may be a Property into a Property object, @see {toPropertyValue} for the reverse operation
|
|
424
|
+
*
|
|
425
|
+
* @param value - The property value or getter to convert, can be undefined or null
|
|
426
|
+
* @param isConstant - The second parameter for converting to CallbackProperty
|
|
427
|
+
* @returns Returns the converted Property object, if value is undefined or null, returns undefined
|
|
428
|
+
*/
|
|
429
|
+
function toProperty(value, isConstant = false) {
|
|
430
|
+
return isProperty(value) ? value : isFunction(value) ? new cesium.CallbackProperty(value, isConstant) : new cesium.ConstantProperty(value);
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* Create a Cesium property key
|
|
434
|
+
*
|
|
435
|
+
* @param scope The host object
|
|
436
|
+
* @param field The property name
|
|
437
|
+
* @param maybeProperty Optional property or getter
|
|
438
|
+
* @param readonly Whether the property is read-only
|
|
439
|
+
*/
|
|
440
|
+
function createPropertyField(scope, field, maybeProperty, readonly$2) {
|
|
441
|
+
let removeOwnerListener;
|
|
442
|
+
const ownerBinding = (value) => {
|
|
443
|
+
removeOwnerListener?.();
|
|
444
|
+
if ((0, cesium.defined)(value?.definitionChanged)) removeOwnerListener = value?.definitionChanged?.addEventListener(() => {
|
|
445
|
+
scope.definitionChanged.raiseEvent(scope, field, value, value);
|
|
446
|
+
});
|
|
447
|
+
};
|
|
448
|
+
const privateField = `_${field}`;
|
|
449
|
+
const property = toProperty(maybeProperty);
|
|
450
|
+
scope[privateField] = property;
|
|
451
|
+
ownerBinding(property);
|
|
452
|
+
if (readonly$2) Object.defineProperty(scope, field, { get() {
|
|
453
|
+
return scope[privateField];
|
|
454
|
+
} });
|
|
455
|
+
else Object.defineProperty(scope, field, {
|
|
456
|
+
get() {
|
|
457
|
+
return scope[privateField];
|
|
458
|
+
},
|
|
459
|
+
set(value) {
|
|
460
|
+
const previous = scope[privateField];
|
|
461
|
+
if (scope[privateField] !== value) {
|
|
462
|
+
scope[privateField] = value;
|
|
463
|
+
ownerBinding(value);
|
|
464
|
+
if ((0, cesium.defined)(scope.definitionChanged)) scope.definitionChanged.raiseEvent(scope, field, value, previous);
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
function createCesiumAttribute(scope, key, value, options = {}) {
|
|
470
|
+
const allowToProperty = !!options.toProperty;
|
|
471
|
+
const shallowClone = !!options.shallowClone;
|
|
472
|
+
const changedEventKey = options.changedEventKey || "definitionChanged";
|
|
473
|
+
const changedEvent = Reflect.get(scope, changedEventKey);
|
|
474
|
+
const privateKey = `_${String(key)}`;
|
|
475
|
+
const attribute = allowToProperty ? toProperty(value) : value;
|
|
476
|
+
Reflect.set(scope, privateKey, attribute);
|
|
477
|
+
const obj = { get() {
|
|
478
|
+
const value$1 = Reflect.get(scope, privateKey);
|
|
479
|
+
if (shallowClone) return Array.isArray(value$1) ? [...value$1] : { ...value$1 };
|
|
480
|
+
else return value$1;
|
|
481
|
+
} };
|
|
482
|
+
let previousListener;
|
|
483
|
+
const serial = (property, previous) => {
|
|
484
|
+
previousListener?.();
|
|
485
|
+
previousListener = property?.definitionChanged?.addEventListener(() => {
|
|
486
|
+
changedEvent?.raiseEvent.bind(changedEvent)(scope, key, property, previous);
|
|
487
|
+
});
|
|
488
|
+
};
|
|
489
|
+
if (!options.readonly) {
|
|
490
|
+
if (allowToProperty && isProperty(value)) serial(value);
|
|
491
|
+
obj.set = (value$1) => {
|
|
492
|
+
if (allowToProperty && !isProperty(value$1)) throw new Error(`The value of ${String(key)} must be a Cesium.Property object`);
|
|
493
|
+
const previous = Reflect.get(scope, privateKey);
|
|
494
|
+
if (previous !== value$1) {
|
|
495
|
+
Reflect.set(scope, privateKey, value$1);
|
|
496
|
+
changedEvent?.raiseEvent.bind(changedEvent)(scope, key, value$1, previous);
|
|
497
|
+
if (allowToProperty) serial(value$1);
|
|
498
|
+
}
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
Object.defineProperty(scope, key, obj);
|
|
502
|
+
}
|
|
503
|
+
function createCesiumProperty(scope, key, value, options = {}) {
|
|
504
|
+
return createCesiumAttribute(scope, key, value, {
|
|
505
|
+
...options,
|
|
506
|
+
toProperty: true
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
//#endregion
|
|
511
|
+
//#region utils/throttle.ts
|
|
512
|
+
/**
|
|
513
|
+
* Throttle function, which limits the frequency of execution of the function
|
|
514
|
+
*
|
|
515
|
+
* @param callback raw function
|
|
516
|
+
* @param delay Throttled delay duration (ms)
|
|
517
|
+
* @param trailing Trigger callback function after last call @default true
|
|
518
|
+
* @param leading Trigger the callback function immediately on the first call @default false
|
|
519
|
+
* @returns Throttle function
|
|
520
|
+
*/
|
|
521
|
+
function throttle(callback, delay = 100, trailing = true, leading = false) {
|
|
522
|
+
const restList = [];
|
|
523
|
+
let tracked = false;
|
|
524
|
+
const trigger = async () => {
|
|
525
|
+
await (0, __vueuse_core.promiseTimeout)(delay);
|
|
526
|
+
tracked = false;
|
|
527
|
+
if (leading) try {
|
|
528
|
+
callback(...restList[0]);
|
|
529
|
+
} catch (error) {
|
|
530
|
+
console.error(error);
|
|
531
|
+
}
|
|
532
|
+
if (trailing && (!leading || restList.length > 1)) try {
|
|
533
|
+
callback(...restList[restList.length - 1]);
|
|
534
|
+
} catch (error) {
|
|
535
|
+
console.error(error);
|
|
536
|
+
}
|
|
537
|
+
restList.length = 0;
|
|
538
|
+
};
|
|
539
|
+
return (...rest) => {
|
|
540
|
+
if (restList.length < 2) restList.push(rest);
|
|
541
|
+
else restList[1] = rest;
|
|
542
|
+
if (!tracked) {
|
|
543
|
+
tracked = true;
|
|
544
|
+
trigger();
|
|
545
|
+
}
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
//#endregion
|
|
550
|
+
//#region utils/toCartesian3.ts
|
|
551
|
+
/**
|
|
552
|
+
* Converts position to a coordinate point in the Cartesian coordinate system
|
|
553
|
+
*
|
|
554
|
+
* @param position Position information, which can be a Cartesian coordinate point (Cartesian3), a geographic coordinate point (Cartographic), an array, or an object containing WGS84 latitude, longitude, and height information
|
|
555
|
+
* @returns The converted Cartesian coordinate point. If the input parameter is invalid, undefined is returned
|
|
556
|
+
*/
|
|
557
|
+
function toCartesian3(position) {
|
|
558
|
+
if (!position) return void 0;
|
|
559
|
+
if (position instanceof cesium.Cartesian3) return position.clone();
|
|
560
|
+
else if (position instanceof cesium.Cartographic) return cesium.Ellipsoid.WGS84.cartographicToCartesian(position);
|
|
561
|
+
else if (Array.isArray(position)) return cesium.Cartesian3.fromDegrees(position[0], position[1], position[2]);
|
|
562
|
+
else return cesium.Cartesian3.fromDegrees(position.longitude, position.latitude, position.height);
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
//#endregion
|
|
566
|
+
//#region utils/toCartographic.ts
|
|
567
|
+
/**
|
|
568
|
+
* Converts a position to a Cartographic coordinate point
|
|
569
|
+
*
|
|
570
|
+
* @param position Position information, which can be a Cartesian3 coordinate point, a Cartographic coordinate point, an array, or an object containing WGS84 longitude, latitude, and height information
|
|
571
|
+
* @returns The converted Cartographic coordinate point, or undefined if the input parameter is invalid
|
|
572
|
+
*/
|
|
573
|
+
function toCartographic(position) {
|
|
574
|
+
if (!position) return void 0;
|
|
575
|
+
if (position instanceof cesium.Cartesian3) return cesium.Ellipsoid.WGS84.cartesianToCartographic(position);
|
|
576
|
+
else if (position instanceof cesium.Cartographic) return position.clone();
|
|
577
|
+
else if (Array.isArray(position)) return cesium.Cartographic.fromDegrees(position[0], position[1], position[2]);
|
|
578
|
+
else return cesium.Cartographic.fromDegrees(position.longitude, position.latitude, position.height);
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
//#endregion
|
|
582
|
+
//#region utils/tryRun.ts
|
|
583
|
+
/**
|
|
584
|
+
* Safely execute the provided function without throwing errors,
|
|
585
|
+
* essentially a simple wrapper around a `try...catch...` block
|
|
586
|
+
*/
|
|
587
|
+
function tryRun(fn) {
|
|
588
|
+
return (...args) => {
|
|
589
|
+
try {
|
|
590
|
+
return fn?.(...args);
|
|
591
|
+
} catch (error) {
|
|
592
|
+
console.error(error);
|
|
593
|
+
}
|
|
594
|
+
};
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
//#endregion
|
|
598
|
+
//#region toPromiseValue/index.ts
|
|
599
|
+
/**
|
|
600
|
+
* Similar to Vue's built-in `toValue`, but capable of handling asynchronous functions, thus returning a `await value`.
|
|
601
|
+
*
|
|
602
|
+
* Used in conjunction with VueUse's `computedAsync`.
|
|
603
|
+
*
|
|
604
|
+
* @param source The source value, which can be a reactive reference or an asynchronous getter.
|
|
605
|
+
* @param options Conversion options
|
|
606
|
+
* @returns The converted value.
|
|
607
|
+
*
|
|
608
|
+
* @example
|
|
609
|
+
* ```ts
|
|
610
|
+
*
|
|
611
|
+
* const data = computedAsync(async ()=> {
|
|
612
|
+
* return await toPromiseValue(promiseRef)
|
|
613
|
+
* })
|
|
614
|
+
*
|
|
615
|
+
* ```
|
|
616
|
+
*/
|
|
617
|
+
async function toPromiseValue(source, options = {}) {
|
|
618
|
+
try {
|
|
619
|
+
const { raw = true } = options;
|
|
620
|
+
let value;
|
|
621
|
+
if (isFunction(source)) value = await source();
|
|
622
|
+
else {
|
|
623
|
+
const result = (0, vue.toValue)(source);
|
|
624
|
+
value = isPromise(result) ? await result : result;
|
|
625
|
+
}
|
|
626
|
+
return raw ? (0, vue.toRaw)(value) : value;
|
|
627
|
+
} catch (error) {
|
|
628
|
+
console.error(error);
|
|
629
|
+
throw error;
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
//#endregion
|
|
634
|
+
//#region useCesiumEventListener/index.ts
|
|
635
|
+
/**
|
|
636
|
+
* Easily use the `addEventListener` in `Cesium.Event` instances,
|
|
637
|
+
* when the dependent data changes or the component is unmounted,
|
|
638
|
+
* the listener function will automatically reload or destroy.
|
|
639
|
+
*
|
|
640
|
+
* @param event The Cesium.Event instance
|
|
641
|
+
* @param listener The listener function
|
|
642
|
+
* @param options additional options
|
|
643
|
+
* @returns A function that can be called to remove the event listener
|
|
644
|
+
*/
|
|
645
|
+
function useCesiumEventListener(event, listener, options = {}) {
|
|
646
|
+
const isActive = (0, vue.toRef)(options.isActive ?? true);
|
|
647
|
+
const cleanup = (0, vue.watchEffect)((onCleanup) => {
|
|
648
|
+
const _event = (0, vue.toValue)(event);
|
|
649
|
+
const events = Array.isArray(_event) ? _event : [_event];
|
|
650
|
+
if (events) {
|
|
651
|
+
if (events.length && isActive.value) {
|
|
652
|
+
const stopFns = events.map((event$1) => {
|
|
653
|
+
const e = (0, vue.toValue)(event$1);
|
|
654
|
+
return e?.addEventListener(listener, e);
|
|
655
|
+
});
|
|
656
|
+
onCleanup(() => stopFns.forEach((stop) => stop?.()));
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
});
|
|
660
|
+
(0, __vueuse_core.tryOnScopeDispose)(cleanup.stop);
|
|
661
|
+
return cleanup.stop;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
//#endregion
|
|
665
|
+
//#region useViewer/index.ts
|
|
666
|
+
/**
|
|
667
|
+
* Obtain the `Viewer` instance injected through `createViewer` in the current component or its ancestor components.
|
|
668
|
+
*
|
|
669
|
+
* note:
|
|
670
|
+
* - If `createViewer` and `useViewer` are called in the same component, the `Viewer` instance injected by `createViewer` will be used preferentially.
|
|
671
|
+
* - When calling `createViewer` and `useViewer` in the same component, `createViewer` should be called before `useViewer`.
|
|
672
|
+
*/
|
|
673
|
+
function useViewer() {
|
|
674
|
+
const scope = (0, vue.getCurrentScope)();
|
|
675
|
+
const instanceViewer = scope ? CREATE_VIEWER_COLLECTION.get(scope) : void 0;
|
|
676
|
+
if (instanceViewer) return instanceViewer;
|
|
677
|
+
else {
|
|
678
|
+
const injectViewer = (0, vue.inject)(CREATE_VIEWER_INJECTION_KEY);
|
|
679
|
+
if (!injectViewer) throw new Error("The `Viewer` instance injected by `createViewer` was not found in the current component or its ancestor components. Have you called `createViewer`?");
|
|
680
|
+
return injectViewer;
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
//#endregion
|
|
685
|
+
//#region useCameraState/index.ts
|
|
686
|
+
/**
|
|
687
|
+
* Reactive Cesium Camera state
|
|
688
|
+
* @param options options
|
|
689
|
+
* @returns Reactive camera states
|
|
690
|
+
*/
|
|
691
|
+
function useCameraState(options = {}) {
|
|
692
|
+
let getCamera = options.camera;
|
|
693
|
+
if (!getCamera) {
|
|
694
|
+
const viewer = useViewer();
|
|
695
|
+
getCamera = () => viewer.value?.scene.camera;
|
|
696
|
+
}
|
|
697
|
+
const camera = (0, vue.computed)(() => (0, vue.toValue)(getCamera));
|
|
698
|
+
const event = (0, vue.computed)(() => {
|
|
699
|
+
const eventField = (0, vue.toValue)(options.event) || "changed";
|
|
700
|
+
return camera.value?.[eventField];
|
|
701
|
+
});
|
|
702
|
+
const changedSymbol = (0, __vueuse_core.refThrottled)((0, vue.shallowRef)(Symbol("camera change")), options.delay ?? 8, true, false);
|
|
703
|
+
const setChangedSymbol = () => {
|
|
704
|
+
changedSymbol.value = Symbol("camera change");
|
|
705
|
+
};
|
|
706
|
+
(0, vue.watch)(camera, () => setChangedSymbol());
|
|
707
|
+
useCesiumEventListener(event, () => setChangedSymbol());
|
|
708
|
+
return {
|
|
709
|
+
camera,
|
|
710
|
+
position: (0, vue.computed)(() => changedSymbol.value ? camera.value?.position?.clone() : void 0),
|
|
711
|
+
direction: (0, vue.computed)(() => changedSymbol.value ? camera.value?.direction?.clone() : void 0),
|
|
712
|
+
up: (0, vue.computed)(() => changedSymbol.value ? camera.value?.up?.clone() : void 0),
|
|
713
|
+
right: (0, vue.computed)(() => changedSymbol.value ? camera.value?.right?.clone() : void 0),
|
|
714
|
+
positionCartographic: (0, vue.computed)(() => changedSymbol.value ? camera.value?.positionCartographic?.clone() : void 0),
|
|
715
|
+
positionWC: (0, vue.computed)(() => changedSymbol.value ? camera.value?.positionWC?.clone() : void 0),
|
|
716
|
+
directionWC: (0, vue.computed)(() => changedSymbol.value ? camera.value?.directionWC?.clone() : void 0),
|
|
717
|
+
upWC: (0, vue.computed)(() => changedSymbol.value ? camera.value?.directionWC?.clone() : void 0),
|
|
718
|
+
rightWC: (0, vue.computed)(() => changedSymbol.value ? camera.value?.directionWC?.clone() : void 0),
|
|
719
|
+
viewRectangle: (0, vue.computed)(() => changedSymbol.value ? camera.value?.computeViewRectangle() : void 0),
|
|
720
|
+
heading: (0, vue.computed)(() => changedSymbol.value ? camera.value?.heading : void 0),
|
|
721
|
+
pitch: (0, vue.computed)(() => changedSymbol.value ? camera.value?.pitch : void 0),
|
|
722
|
+
roll: (0, vue.computed)(() => changedSymbol.value ? camera.value?.roll : void 0),
|
|
723
|
+
level: (0, vue.computed)(() => changedSymbol.value && camera.value?.positionCartographic?.height ? computeLevel(camera.value.positionCartographic.height) : void 0)
|
|
724
|
+
};
|
|
725
|
+
}
|
|
726
|
+
const A = 40487.57;
|
|
727
|
+
const B = 7096758e-11;
|
|
728
|
+
const C = 91610.74;
|
|
729
|
+
const D = -40467.74;
|
|
730
|
+
/**
|
|
731
|
+
* Compute the camera level at a given height.
|
|
732
|
+
*/
|
|
733
|
+
function computeLevel(height) {
|
|
734
|
+
return D + (A - D) / (1 + (height / C) ** B);
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
//#endregion
|
|
738
|
+
//#region useCesiumFps/index.ts
|
|
739
|
+
/**
|
|
740
|
+
* Reactive get the frame rate of Cesium
|
|
741
|
+
* @param options options
|
|
742
|
+
* @returns Reactive fps states
|
|
743
|
+
*/
|
|
744
|
+
function useCesiumFps(options = {}) {
|
|
745
|
+
const { delay = 100 } = options;
|
|
746
|
+
const viewer = useViewer();
|
|
747
|
+
const p = (0, vue.shallowRef)(performance.now());
|
|
748
|
+
useCesiumEventListener(() => viewer.value?.scene.postRender, () => p.value = performance.now());
|
|
749
|
+
const interval = (0, vue.ref)(0);
|
|
750
|
+
(0, __vueuse_core.watchThrottled)(p, (value, oldValue) => {
|
|
751
|
+
interval.value = value - oldValue;
|
|
752
|
+
}, { throttle: delay });
|
|
753
|
+
const fps = (0, vue.computed)(() => {
|
|
754
|
+
return 1e3 / interval.value;
|
|
755
|
+
});
|
|
756
|
+
return {
|
|
757
|
+
interval: (0, vue.readonly)(interval),
|
|
758
|
+
fps
|
|
759
|
+
};
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
//#endregion
|
|
763
|
+
//#region useCollectionScope/index.ts
|
|
764
|
+
/**
|
|
765
|
+
* Scope the SideEffects of Cesium-related `Collection` and automatically remove them when unmounted.
|
|
766
|
+
* - note: This is a basic function that is intended to be called by other lower-level function
|
|
767
|
+
* @param addFn - add SideEffect function. eg.`entites.add`
|
|
768
|
+
* @param removeFn - Clean SideEffect function. eg.`entities.remove`
|
|
769
|
+
* @param removeScopeArgs - The parameters to pass for `removeScope` triggered when the component is unmounted
|
|
770
|
+
*
|
|
771
|
+
* @returns Contains side effect addition and removal functions
|
|
772
|
+
*/
|
|
773
|
+
function useCollectionScope(addFn, removeFn, removeScopeArgs) {
|
|
774
|
+
const scope = (0, vue.shallowReactive)(/* @__PURE__ */ new Set());
|
|
775
|
+
const add = (instance, ...args) => {
|
|
776
|
+
const result = addFn(instance, ...args);
|
|
777
|
+
if (isPromise(result)) return new Promise((resolve, reject) => {
|
|
778
|
+
result.then((i) => {
|
|
779
|
+
scope.add(i);
|
|
780
|
+
resolve(i);
|
|
781
|
+
}).catch((error) => reject(error));
|
|
782
|
+
});
|
|
783
|
+
else {
|
|
784
|
+
scope.add(result);
|
|
785
|
+
return result;
|
|
786
|
+
}
|
|
787
|
+
};
|
|
788
|
+
const remove = (instance, ...args) => {
|
|
789
|
+
scope.delete(instance);
|
|
790
|
+
return removeFn(instance, ...args);
|
|
791
|
+
};
|
|
792
|
+
const removeWhere = (predicate, ...args) => {
|
|
793
|
+
scope.forEach((instance) => {
|
|
794
|
+
if (predicate(instance)) remove(instance, ...args);
|
|
795
|
+
});
|
|
796
|
+
};
|
|
797
|
+
const removeScope = (...args) => {
|
|
798
|
+
scope.forEach((instance) => {
|
|
799
|
+
remove(instance, ...args);
|
|
800
|
+
});
|
|
801
|
+
};
|
|
802
|
+
(0, __vueuse_core.tryOnScopeDispose)(() => removeScope(...removeScopeArgs));
|
|
803
|
+
return {
|
|
804
|
+
scope: (0, vue.shallowReadonly)(scope),
|
|
805
|
+
add,
|
|
806
|
+
remove,
|
|
807
|
+
removeWhere,
|
|
808
|
+
removeScope
|
|
809
|
+
};
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
//#endregion
|
|
813
|
+
//#region useDataSource/index.ts
|
|
814
|
+
function useDataSource(dataSources, options = {}) {
|
|
815
|
+
const { destroyOnRemove, collection, isActive = true, evaluating } = options;
|
|
816
|
+
const result = (0, __vueuse_core.computedAsync)(() => toPromiseValue(dataSources), void 0, { evaluating });
|
|
817
|
+
const viewer = useViewer();
|
|
818
|
+
(0, vue.watchEffect)((onCleanup) => {
|
|
819
|
+
const _isActive = (0, vue.toValue)(isActive);
|
|
820
|
+
if (_isActive) {
|
|
821
|
+
const list = Array.isArray(result.value) ? [...result.value] : [result.value];
|
|
822
|
+
const _collection = collection ?? viewer.value?.dataSources;
|
|
823
|
+
list.forEach((item) => item && _collection?.add(item));
|
|
824
|
+
onCleanup(() => {
|
|
825
|
+
const destroy = (0, vue.toValue)(destroyOnRemove);
|
|
826
|
+
!_collection?.isDestroyed() && list.forEach((dataSource) => dataSource && _collection?.remove(dataSource, destroy));
|
|
827
|
+
});
|
|
828
|
+
}
|
|
829
|
+
});
|
|
830
|
+
return result;
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
//#endregion
|
|
834
|
+
//#region useDataSourceScope/index.ts
|
|
835
|
+
/**
|
|
836
|
+
* // Scope the SideEffects of `DataSourceCollection` operations and automatically remove them when unmounted
|
|
837
|
+
*/
|
|
838
|
+
function useDataSourceScope(options = {}) {
|
|
839
|
+
const { collection: _collection, destroyOnRemove } = options;
|
|
840
|
+
const viewer = useViewer();
|
|
841
|
+
const collection = (0, vue.computed)(() => {
|
|
842
|
+
return (0, vue.toValue)(_collection) ?? viewer.value?.dataSources;
|
|
843
|
+
});
|
|
844
|
+
const addFn = (dataSource) => {
|
|
845
|
+
if (!collection.value) throw new Error("collection is not defined");
|
|
846
|
+
return collection.value.add(dataSource);
|
|
847
|
+
};
|
|
848
|
+
const removeFn = (dataSource, destroy) => {
|
|
849
|
+
return !!collection.value?.remove(dataSource, destroy);
|
|
850
|
+
};
|
|
851
|
+
const { scope, add, remove, removeWhere, removeScope } = useCollectionScope(addFn, removeFn, [destroyOnRemove]);
|
|
852
|
+
return {
|
|
853
|
+
scope,
|
|
854
|
+
add,
|
|
855
|
+
remove,
|
|
856
|
+
removeWhere,
|
|
857
|
+
removeScope
|
|
858
|
+
};
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
//#endregion
|
|
862
|
+
//#region useElementOverlay/index.ts
|
|
863
|
+
/**
|
|
864
|
+
* Cesium HtmlElement Overlay
|
|
865
|
+
*/
|
|
866
|
+
function useElementOverlay(target, position, options = {}) {
|
|
867
|
+
const { referenceWindow, horizontal = "center", vertical = "bottom", offset = {
|
|
868
|
+
x: 0,
|
|
869
|
+
y: 0
|
|
870
|
+
} } = options;
|
|
871
|
+
const cartesian3 = (0, vue.computed)(() => toCartesian3((0, vue.toValue)(position)));
|
|
872
|
+
const viewer = useViewer();
|
|
873
|
+
const coord = (0, vue.shallowRef)();
|
|
874
|
+
useCesiumEventListener(() => viewer.value?.scene.postRender, () => {
|
|
875
|
+
if (!viewer.value?.scene) return;
|
|
876
|
+
if (!cartesian3.value) coord.value = void 0;
|
|
877
|
+
else {
|
|
878
|
+
const reslut = cartesianToCanvasCoord(cartesian3.value, viewer.value.scene);
|
|
879
|
+
coord.value = !cesium.Cartesian2.equals(reslut, coord.value) ? reslut : coord.value;
|
|
880
|
+
}
|
|
881
|
+
});
|
|
882
|
+
const canvasBounding = (0, __vueuse_core.useElementBounding)(() => viewer.value?.canvas.parentElement);
|
|
883
|
+
const targetBounding = (0, __vueuse_core.useElementBounding)(target);
|
|
884
|
+
const finalOffset = (0, vue.computed)(() => {
|
|
885
|
+
const _offset = (0, vue.toValue)(offset);
|
|
886
|
+
let x$1 = _offset?.x ?? 0;
|
|
887
|
+
const _horizontal = (0, vue.toValue)(horizontal);
|
|
888
|
+
if (_horizontal === "center") x$1 -= targetBounding.width.value / 2;
|
|
889
|
+
else if (_horizontal === "right") x$1 -= targetBounding.width.value;
|
|
890
|
+
let y$1 = _offset?.y ?? 0;
|
|
891
|
+
const _vertical = (0, vue.toValue)(vertical);
|
|
892
|
+
if (_vertical === "center") y$1 -= targetBounding.height.value / 2;
|
|
893
|
+
else if (_vertical === "bottom") y$1 -= targetBounding.height.value;
|
|
894
|
+
return {
|
|
895
|
+
x: x$1,
|
|
896
|
+
y: y$1
|
|
897
|
+
};
|
|
898
|
+
});
|
|
899
|
+
const location = (0, vue.computed)(() => {
|
|
900
|
+
const data = {
|
|
901
|
+
x: coord.value?.x ?? 0,
|
|
902
|
+
y: coord.value?.y ?? 0
|
|
903
|
+
};
|
|
904
|
+
if ((0, vue.toValue)(referenceWindow)) {
|
|
905
|
+
data.x += canvasBounding.x.value;
|
|
906
|
+
data.y += canvasBounding.y.value;
|
|
907
|
+
}
|
|
908
|
+
return {
|
|
909
|
+
x: finalOffset.value.x + data.x,
|
|
910
|
+
y: finalOffset.value.y + data.y
|
|
911
|
+
};
|
|
912
|
+
});
|
|
913
|
+
const x = (0, vue.computed)(() => location.value.x);
|
|
914
|
+
const y = (0, vue.computed)(() => location.value.y);
|
|
915
|
+
const style = (0, vue.computed)(() => ({
|
|
916
|
+
left: `${x.value?.toFixed(2)}px`,
|
|
917
|
+
top: `${y.value?.toFixed(2)}px`
|
|
918
|
+
}));
|
|
919
|
+
(0, vue.watchEffect)(() => {
|
|
920
|
+
const element = (0, vue.toValue)(target);
|
|
921
|
+
if (element && (0, vue.toValue)(options.applyStyle ?? true)) {
|
|
922
|
+
element.style?.setProperty?.("left", style.value.left);
|
|
923
|
+
element.style?.setProperty?.("top", style.value.top);
|
|
924
|
+
}
|
|
925
|
+
});
|
|
926
|
+
return {
|
|
927
|
+
x,
|
|
928
|
+
y,
|
|
929
|
+
style
|
|
930
|
+
};
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
//#endregion
|
|
934
|
+
//#region useEntity/index.ts
|
|
935
|
+
function useEntity(data, options = {}) {
|
|
936
|
+
const { collection, isActive = true, evaluating } = options;
|
|
937
|
+
const result = (0, __vueuse_core.computedAsync)(() => toPromiseValue(data), [], { evaluating });
|
|
938
|
+
const viewer = useViewer();
|
|
939
|
+
(0, vue.watchEffect)((onCleanup) => {
|
|
940
|
+
const _isActive = (0, vue.toValue)(isActive);
|
|
941
|
+
if (_isActive) {
|
|
942
|
+
const list = Array.isArray(result.value) ? [...result.value] : [result.value];
|
|
943
|
+
const _collection = collection ?? viewer.value?.entities;
|
|
944
|
+
list.forEach((item) => item && _collection?.add(item));
|
|
945
|
+
onCleanup(() => {
|
|
946
|
+
list.forEach((item) => item && _collection?.remove(item));
|
|
947
|
+
});
|
|
948
|
+
}
|
|
949
|
+
});
|
|
950
|
+
return result;
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
//#endregion
|
|
954
|
+
//#region useEntityScope/index.ts
|
|
955
|
+
/**
|
|
956
|
+
* Make `add` and `remove` operations of `EntityCollection` scoped,
|
|
957
|
+
* automatically remove `Entity` instance when component is unmounted.
|
|
958
|
+
*/
|
|
959
|
+
function useEntityScope(options = {}) {
|
|
960
|
+
const { collection: _collection } = options;
|
|
961
|
+
const viewer = useViewer();
|
|
962
|
+
const collection = (0, vue.computed)(() => {
|
|
963
|
+
return (0, vue.toValue)(_collection) ?? viewer.value?.entities;
|
|
964
|
+
});
|
|
965
|
+
const addFn = (entity) => {
|
|
966
|
+
if (!collection.value) throw new Error("collection is not defined");
|
|
967
|
+
if (!collection.value.contains(entity)) collection.value.add(entity);
|
|
968
|
+
return entity;
|
|
969
|
+
};
|
|
970
|
+
const removeFn = (entity) => {
|
|
971
|
+
return !!collection.value?.remove(entity);
|
|
972
|
+
};
|
|
973
|
+
const { scope, add, remove, removeWhere, removeScope } = useCollectionScope(addFn, removeFn, []);
|
|
974
|
+
return {
|
|
975
|
+
scope,
|
|
976
|
+
add,
|
|
977
|
+
remove,
|
|
978
|
+
removeWhere,
|
|
979
|
+
removeScope
|
|
980
|
+
};
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
//#endregion
|
|
984
|
+
//#region useScenePick/index.ts
|
|
985
|
+
const pickCache = /* @__PURE__ */ new WeakMap();
|
|
986
|
+
/**
|
|
987
|
+
* Uses the `scene.pick` function in Cesium's Scene object to perform screen point picking,
|
|
988
|
+
* return a computed property containing the pick result, or undefined if no object is picked.
|
|
989
|
+
*
|
|
990
|
+
* @param windowPosition The screen coordinates of the pick point.
|
|
991
|
+
*/
|
|
992
|
+
function useScenePick(windowPosition, options = {}) {
|
|
993
|
+
const { width = 3, height = 3, throttled = 8 } = options;
|
|
994
|
+
const isActive = (0, vue.toRef)(options.isActive ?? true);
|
|
995
|
+
const viewer = useViewer();
|
|
996
|
+
const position = (0, __vueuse_core.refThrottled)((0, vue.computed)(() => (0, vue.toValue)(windowPosition)?.clone()), throttled, false, true);
|
|
997
|
+
const pick = (0, vue.shallowRef)();
|
|
998
|
+
(0, vue.watchEffect)(() => {
|
|
999
|
+
if (viewer.value && position.value && isActive.value) {
|
|
1000
|
+
const cache = pickCache.get(viewer.value);
|
|
1001
|
+
if (cache && cache[0].equals(position.value)) pick.value = cache[1];
|
|
1002
|
+
else {
|
|
1003
|
+
pickCache.set(viewer.value, [position.value.clone(), pick.value]);
|
|
1004
|
+
pick.value = viewer.value?.scene.pick(position.value, (0, vue.toValue)(width), (0, vue.toValue)(height));
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
});
|
|
1008
|
+
return pick;
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
//#endregion
|
|
1012
|
+
//#region useScreenSpaceEventHandler/index.ts
|
|
1013
|
+
/**
|
|
1014
|
+
* Easily use the `ScreenSpaceEventHandler`,
|
|
1015
|
+
* when the dependent data changes or the component is unmounted,
|
|
1016
|
+
* the listener function will automatically reload or destroy.
|
|
1017
|
+
*
|
|
1018
|
+
* @param type Types of mouse event
|
|
1019
|
+
* @param inputAction Callback function for listening
|
|
1020
|
+
*/
|
|
1021
|
+
function useScreenSpaceEventHandler(type, inputAction, options = {}) {
|
|
1022
|
+
const { modifier } = options;
|
|
1023
|
+
const viewer = useViewer();
|
|
1024
|
+
const isActive = (0, vue.toRef)(options.isActive ?? true);
|
|
1025
|
+
const handler = (0, vue.computed)(() => {
|
|
1026
|
+
if (viewer.value?.cesiumWidget?.canvas) return new cesium.ScreenSpaceEventHandler(viewer.value.cesiumWidget.canvas);
|
|
1027
|
+
});
|
|
1028
|
+
const cleanup1 = (0, vue.watch)(handler, (_value, previous) => {
|
|
1029
|
+
viewer.value?.cesiumWidget && previous?.destroy();
|
|
1030
|
+
});
|
|
1031
|
+
const cleanup2 = (0, vue.watchEffect)((onCleanup) => {
|
|
1032
|
+
const typeValue = (0, vue.toValue)(type);
|
|
1033
|
+
const modifierValue = (0, vue.toValue)(modifier);
|
|
1034
|
+
const handlerValue = (0, vue.toValue)(handler);
|
|
1035
|
+
if (!handlerValue || !isActive.value || !inputAction) return;
|
|
1036
|
+
if (isDef(typeValue)) {
|
|
1037
|
+
handlerValue.setInputAction(inputAction, typeValue, modifierValue);
|
|
1038
|
+
onCleanup(() => handlerValue.removeInputAction(typeValue, modifierValue));
|
|
1039
|
+
}
|
|
1040
|
+
});
|
|
1041
|
+
const stop = () => {
|
|
1042
|
+
cleanup1();
|
|
1043
|
+
cleanup2();
|
|
1044
|
+
};
|
|
1045
|
+
(0, __vueuse_core.tryOnScopeDispose)(stop);
|
|
1046
|
+
return stop;
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
//#endregion
|
|
1050
|
+
//#region useGraphicEvent/useDrag.ts
|
|
1051
|
+
/**
|
|
1052
|
+
* Use graphic drag events with ease, and remove listener automatically on unmounted.
|
|
1053
|
+
*/
|
|
1054
|
+
function useDrag(listener) {
|
|
1055
|
+
const position = (0, vue.shallowRef)();
|
|
1056
|
+
const pick = useScenePick(position);
|
|
1057
|
+
const motionEvent = (0, vue.shallowRef)();
|
|
1058
|
+
const dragging = (0, vue.ref)(false);
|
|
1059
|
+
const viewer = useViewer();
|
|
1060
|
+
const cameraLocked = (0, vue.ref)(false);
|
|
1061
|
+
(0, vue.watch)(cameraLocked, (cameraLocked$1) => {
|
|
1062
|
+
viewer.value && (viewer.value.scene.screenSpaceCameraController.enableRotate = !cameraLocked$1);
|
|
1063
|
+
});
|
|
1064
|
+
const lockCamera = () => {
|
|
1065
|
+
cameraLocked.value = true;
|
|
1066
|
+
};
|
|
1067
|
+
const execute = (pick$1, startPosition, endPosition) => {
|
|
1068
|
+
listener({
|
|
1069
|
+
event: {
|
|
1070
|
+
startPosition: startPosition.clone(),
|
|
1071
|
+
endPosition: endPosition.clone()
|
|
1072
|
+
},
|
|
1073
|
+
pick: pick$1,
|
|
1074
|
+
dragging: dragging.value,
|
|
1075
|
+
lockCamera
|
|
1076
|
+
});
|
|
1077
|
+
(0, vue.nextTick)(() => {
|
|
1078
|
+
if (!dragging.value && cameraLocked.value) cameraLocked.value = false;
|
|
1079
|
+
});
|
|
1080
|
+
};
|
|
1081
|
+
const stopLeftDownWatch = useScreenSpaceEventHandler(cesium.ScreenSpaceEventType.LEFT_DOWN, (event) => {
|
|
1082
|
+
dragging.value = true;
|
|
1083
|
+
position.value = event.position.clone();
|
|
1084
|
+
});
|
|
1085
|
+
const stopMouseMoveWatch = useScreenSpaceEventHandler(cesium.ScreenSpaceEventType.MOUSE_MOVE, throttle(({ startPosition, endPosition }) => {
|
|
1086
|
+
motionEvent.value = {
|
|
1087
|
+
startPosition: motionEvent.value?.endPosition.clone() || startPosition.clone(),
|
|
1088
|
+
endPosition: endPosition.clone()
|
|
1089
|
+
};
|
|
1090
|
+
}, 8, false, true));
|
|
1091
|
+
(0, vue.watch)([pick, motionEvent], ([pick$1, motionEvent$1]) => {
|
|
1092
|
+
if (pick$1 && motionEvent$1) {
|
|
1093
|
+
const { startPosition, endPosition } = motionEvent$1;
|
|
1094
|
+
dragging.value && execute(pick$1, startPosition, endPosition);
|
|
1095
|
+
}
|
|
1096
|
+
});
|
|
1097
|
+
const stopLeftUpWatch = useScreenSpaceEventHandler(cesium.ScreenSpaceEventType.LEFT_UP, (event) => {
|
|
1098
|
+
dragging.value = false;
|
|
1099
|
+
if (pick.value && motionEvent.value) execute(pick.value, motionEvent.value.endPosition, event.position);
|
|
1100
|
+
position.value = void 0;
|
|
1101
|
+
motionEvent.value = void 0;
|
|
1102
|
+
});
|
|
1103
|
+
const stop = () => {
|
|
1104
|
+
stopLeftDownWatch();
|
|
1105
|
+
stopMouseMoveWatch();
|
|
1106
|
+
stopLeftUpWatch();
|
|
1107
|
+
};
|
|
1108
|
+
(0, __vueuse_core.tryOnScopeDispose)(stop);
|
|
1109
|
+
return stop;
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1112
|
+
//#endregion
|
|
1113
|
+
//#region useGraphicEvent/useHover.ts
|
|
1114
|
+
/**
|
|
1115
|
+
* Use graphic hover events with ease, and remove listener automatically on unmounted.
|
|
1116
|
+
*/
|
|
1117
|
+
function useHover(listener) {
|
|
1118
|
+
const motionEvent = (0, vue.shallowRef)();
|
|
1119
|
+
const pick = useScenePick(() => motionEvent.value?.endPosition);
|
|
1120
|
+
const execute = (pick$1, startPosition, endPosition, hovering) => {
|
|
1121
|
+
listener({
|
|
1122
|
+
event: {
|
|
1123
|
+
startPosition: startPosition.clone(),
|
|
1124
|
+
endPosition: endPosition.clone()
|
|
1125
|
+
},
|
|
1126
|
+
pick: pick$1,
|
|
1127
|
+
hovering
|
|
1128
|
+
});
|
|
1129
|
+
};
|
|
1130
|
+
useScreenSpaceEventHandler(cesium.ScreenSpaceEventType.MOUSE_MOVE, ({ startPosition, endPosition }) => {
|
|
1131
|
+
if (!startPosition.equals(motionEvent.value?.startPosition) || !endPosition.equals(motionEvent.value?.endPosition)) motionEvent.value = {
|
|
1132
|
+
startPosition: startPosition.clone(),
|
|
1133
|
+
endPosition: endPosition.clone()
|
|
1134
|
+
};
|
|
1135
|
+
});
|
|
1136
|
+
(0, vue.watch)([pick, motionEvent], ([pick$1, motionEvent$1]) => {
|
|
1137
|
+
if (pick$1 && motionEvent$1) {
|
|
1138
|
+
const { startPosition, endPosition } = motionEvent$1;
|
|
1139
|
+
execute(pick$1, startPosition, endPosition, true);
|
|
1140
|
+
}
|
|
1141
|
+
});
|
|
1142
|
+
(0, vue.watch)(pick, (pick$1, prevPick) => {
|
|
1143
|
+
if (prevPick && motionEvent.value) {
|
|
1144
|
+
const { startPosition, endPosition } = motionEvent.value;
|
|
1145
|
+
execute(prevPick, startPosition, endPosition, false);
|
|
1146
|
+
}
|
|
1147
|
+
});
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
//#endregion
|
|
1151
|
+
//#region useGraphicEvent/usePositioned.ts
|
|
1152
|
+
/**
|
|
1153
|
+
* @internal
|
|
1154
|
+
*/
|
|
1155
|
+
const EVENT_TYPE_RECORD = {
|
|
1156
|
+
LEFT_DOWN: cesium.ScreenSpaceEventType.LEFT_DOWN,
|
|
1157
|
+
LEFT_UP: cesium.ScreenSpaceEventType.LEFT_UP,
|
|
1158
|
+
LEFT_CLICK: cesium.ScreenSpaceEventType.LEFT_CLICK,
|
|
1159
|
+
LEFT_DOUBLE_CLICK: cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK,
|
|
1160
|
+
RIGHT_DOWN: cesium.ScreenSpaceEventType.RIGHT_DOWN,
|
|
1161
|
+
RIGHT_UP: cesium.ScreenSpaceEventType.RIGHT_UP,
|
|
1162
|
+
RIGHT_CLICK: cesium.ScreenSpaceEventType.RIGHT_CLICK,
|
|
1163
|
+
MIDDLE_DOWN: cesium.ScreenSpaceEventType.MIDDLE_DOWN,
|
|
1164
|
+
MIDDLE_UP: cesium.ScreenSpaceEventType.MIDDLE_UP,
|
|
1165
|
+
MIDDLE_CLICK: cesium.ScreenSpaceEventType.MIDDLE_CLICK
|
|
1166
|
+
};
|
|
1167
|
+
function usePositioned(type, listener) {
|
|
1168
|
+
const screenEvent = EVENT_TYPE_RECORD[type];
|
|
1169
|
+
const viewer = useViewer();
|
|
1170
|
+
useScreenSpaceEventHandler(screenEvent, (event) => {
|
|
1171
|
+
const position = event.position;
|
|
1172
|
+
const pick = viewer.value?.scene.pick(position);
|
|
1173
|
+
pick && position && listener({
|
|
1174
|
+
event: { position },
|
|
1175
|
+
pick
|
|
1176
|
+
});
|
|
1177
|
+
});
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
//#endregion
|
|
1181
|
+
//#region useGraphicEvent/index.ts
|
|
1182
|
+
const GLOBAL_GRAPHIC_SYMBOL = Symbol("GLOBAL_GRAPHIC_SYMBOL");
|
|
1183
|
+
const POSITIONED_EVENT_TYPES = [
|
|
1184
|
+
"LEFT_DOWN",
|
|
1185
|
+
"LEFT_UP",
|
|
1186
|
+
"LEFT_CLICK",
|
|
1187
|
+
"LEFT_DOUBLE_CLICK",
|
|
1188
|
+
"RIGHT_DOWN",
|
|
1189
|
+
"RIGHT_UP",
|
|
1190
|
+
"RIGHT_CLICK",
|
|
1191
|
+
"MIDDLE_DOWN",
|
|
1192
|
+
"MIDDLE_UP",
|
|
1193
|
+
"MIDDLE_CLICK"
|
|
1194
|
+
];
|
|
1195
|
+
/**
|
|
1196
|
+
* Handle graphic event listeners and cursor styles for Cesium graphics.
|
|
1197
|
+
* You don't need to overly worry about memory leaks from the function, as it automatically cleans up internally.
|
|
1198
|
+
*/
|
|
1199
|
+
function useGraphicEvent() {
|
|
1200
|
+
const collection = /* @__PURE__ */ new WeakMap();
|
|
1201
|
+
const cursorCollection = /* @__PURE__ */ new WeakMap();
|
|
1202
|
+
const dragCursorCollection = /* @__PURE__ */ new WeakMap();
|
|
1203
|
+
const removeGraphicEvent = (graphic, type, listener) => {
|
|
1204
|
+
const _graphic = graphic === "global" ? GLOBAL_GRAPHIC_SYMBOL : graphic;
|
|
1205
|
+
collection?.get(_graphic)?.get(type)?.delete(listener);
|
|
1206
|
+
cursorCollection?.get(_graphic)?.get(type)?.delete(listener);
|
|
1207
|
+
if (collection?.get(_graphic)?.get(type)?.size === 0) collection.get(_graphic).delete(type);
|
|
1208
|
+
if (collection.get(_graphic)?.size === 0) collection.delete(_graphic);
|
|
1209
|
+
cursorCollection?.get(_graphic)?.get(type)?.delete(listener);
|
|
1210
|
+
if (cursorCollection?.get(_graphic)?.get(type)?.size === 0) cursorCollection?.get(_graphic)?.delete(type);
|
|
1211
|
+
if (cursorCollection?.get(_graphic)?.size === 0) cursorCollection?.delete(_graphic);
|
|
1212
|
+
dragCursorCollection?.get(_graphic)?.get(type)?.delete(listener);
|
|
1213
|
+
if (dragCursorCollection?.get(_graphic)?.get(type)?.size === 0) dragCursorCollection?.get(_graphic)?.delete(type);
|
|
1214
|
+
if (dragCursorCollection?.get(_graphic)?.size === 0) dragCursorCollection?.delete(_graphic);
|
|
1215
|
+
};
|
|
1216
|
+
const addGraphicEvent = (graphic, type, listener, options = {}) => {
|
|
1217
|
+
const _graphic = graphic === "global" ? GLOBAL_GRAPHIC_SYMBOL : graphic;
|
|
1218
|
+
collection.get(_graphic) ?? collection.set(_graphic, /* @__PURE__ */ new Map());
|
|
1219
|
+
const eventTypeMap = collection.get(_graphic);
|
|
1220
|
+
eventTypeMap.get(type) ?? eventTypeMap.set(type, /* @__PURE__ */ new Set());
|
|
1221
|
+
const listeners = eventTypeMap.get(type);
|
|
1222
|
+
listeners.add(listener);
|
|
1223
|
+
let { cursor = "pointer", dragCursor } = options;
|
|
1224
|
+
if (isDef(cursor)) {
|
|
1225
|
+
const _cursor = isFunction(cursor) ? cursor : () => cursor;
|
|
1226
|
+
cursorCollection.get(_graphic) ?? cursorCollection.set(_graphic, /* @__PURE__ */ new Map());
|
|
1227
|
+
cursorCollection.get(_graphic).get(type) ?? cursorCollection.get(_graphic).set(type, /* @__PURE__ */ new Map());
|
|
1228
|
+
cursorCollection.get(_graphic).get(type).set(listener, _cursor);
|
|
1229
|
+
}
|
|
1230
|
+
if (type === "DRAG") dragCursor ??= (event) => event?.dragging ? "crosshair" : void 0;
|
|
1231
|
+
if (isDef(dragCursor)) {
|
|
1232
|
+
const _dragCursor = isFunction(dragCursor) ? dragCursor : () => dragCursor;
|
|
1233
|
+
dragCursorCollection.get(_graphic) ?? dragCursorCollection.set(_graphic, /* @__PURE__ */ new Map());
|
|
1234
|
+
dragCursorCollection.get(_graphic).get(type) ?? dragCursorCollection.get(_graphic).set(type, /* @__PURE__ */ new Map());
|
|
1235
|
+
dragCursorCollection.get(_graphic).get(type).set(listener, _dragCursor);
|
|
1236
|
+
}
|
|
1237
|
+
return () => removeGraphicEvent(graphic, type, listener);
|
|
1238
|
+
};
|
|
1239
|
+
const clearGraphicEvent = (graphic, type) => {
|
|
1240
|
+
const _graphic = graphic === "global" ? GLOBAL_GRAPHIC_SYMBOL : graphic;
|
|
1241
|
+
if (type === "all") {
|
|
1242
|
+
collection.delete(_graphic);
|
|
1243
|
+
cursorCollection.delete(_graphic);
|
|
1244
|
+
dragCursorCollection.delete(_graphic);
|
|
1245
|
+
return;
|
|
1246
|
+
}
|
|
1247
|
+
collection.get(_graphic)?.delete(type);
|
|
1248
|
+
if (collection.get(_graphic)?.size === 0) collection.delete(_graphic);
|
|
1249
|
+
cursorCollection?.get(_graphic)?.delete(type);
|
|
1250
|
+
dragCursorCollection?.get(_graphic)?.delete(type);
|
|
1251
|
+
if (cursorCollection?.get(_graphic)?.size === 0) cursorCollection?.delete(_graphic);
|
|
1252
|
+
if (dragCursorCollection?.get(_graphic)?.size === 0) dragCursorCollection?.delete(_graphic);
|
|
1253
|
+
};
|
|
1254
|
+
for (const type of POSITIONED_EVENT_TYPES) usePositioned(type, (event) => {
|
|
1255
|
+
const graphics = resolvePick(event.pick);
|
|
1256
|
+
graphics.concat(GLOBAL_GRAPHIC_SYMBOL).forEach((graphic) => {
|
|
1257
|
+
collection.get(graphic)?.get(type)?.forEach((fn) => tryRun(fn)?.(event));
|
|
1258
|
+
});
|
|
1259
|
+
});
|
|
1260
|
+
const dragging = (0, vue.ref)(false);
|
|
1261
|
+
const viewer = useViewer();
|
|
1262
|
+
useHover((event) => {
|
|
1263
|
+
const graphics = resolvePick(event.pick).concat(GLOBAL_GRAPHIC_SYMBOL);
|
|
1264
|
+
graphics.forEach((graphic) => {
|
|
1265
|
+
collection.get(graphic)?.get("HOVER")?.forEach((fn) => tryRun(fn)?.(event));
|
|
1266
|
+
if (!dragging.value) cursorCollection.get(graphic)?.forEach((map) => {
|
|
1267
|
+
map.forEach((fn) => {
|
|
1268
|
+
const cursor = event.hovering ? tryRun(fn)(event) : "";
|
|
1269
|
+
viewer.value?.canvas.style?.setProperty("cursor", cursor);
|
|
1270
|
+
});
|
|
1271
|
+
});
|
|
1272
|
+
});
|
|
1273
|
+
});
|
|
1274
|
+
useDrag((event) => {
|
|
1275
|
+
const graphics = resolvePick(event.pick).concat(GLOBAL_GRAPHIC_SYMBOL);
|
|
1276
|
+
dragging.value = event.dragging;
|
|
1277
|
+
graphics.forEach((graphic) => {
|
|
1278
|
+
collection.get(graphic)?.get("DRAG")?.forEach((fn) => tryRun(fn)(event));
|
|
1279
|
+
dragCursorCollection.get(graphic)?.forEach((map) => {
|
|
1280
|
+
map.forEach((fn) => {
|
|
1281
|
+
const cursor = event.dragging ? tryRun(fn)(event) : "";
|
|
1282
|
+
viewer.value?.canvas.style?.setProperty("cursor", cursor);
|
|
1283
|
+
});
|
|
1284
|
+
});
|
|
1285
|
+
});
|
|
1286
|
+
});
|
|
1287
|
+
return {
|
|
1288
|
+
addGraphicEvent,
|
|
1289
|
+
removeGraphicEvent,
|
|
1290
|
+
clearGraphicEvent
|
|
1291
|
+
};
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1294
|
+
//#endregion
|
|
1295
|
+
//#region useImageryLayer/index.ts
|
|
1296
|
+
function useImageryLayer(data, options = {}) {
|
|
1297
|
+
const { destroyOnRemove, collection, isActive = true, evaluating } = options;
|
|
1298
|
+
const result = (0, __vueuse_core.computedAsync)(() => toPromiseValue(data), [], { evaluating });
|
|
1299
|
+
const viewer = useViewer();
|
|
1300
|
+
(0, vue.watchEffect)((onCleanup) => {
|
|
1301
|
+
const _isActive = (0, vue.toValue)(isActive);
|
|
1302
|
+
if (_isActive) {
|
|
1303
|
+
const list = Array.isArray(result.value) ? [...result.value] : [result.value];
|
|
1304
|
+
const _collection = collection ?? viewer.value?.imageryLayers;
|
|
1305
|
+
if (collection?.isDestroyed()) return;
|
|
1306
|
+
list.forEach((item) => {
|
|
1307
|
+
if (!item) {
|
|
1308
|
+
console.warn("ImageryLayer is undefined");
|
|
1309
|
+
return;
|
|
1310
|
+
}
|
|
1311
|
+
if (item?.isDestroyed()) {
|
|
1312
|
+
console.warn("ImageryLayer is destroyed");
|
|
1313
|
+
return;
|
|
1314
|
+
}
|
|
1315
|
+
_collection?.add(item);
|
|
1316
|
+
});
|
|
1317
|
+
onCleanup(() => {
|
|
1318
|
+
const destroy = (0, vue.toValue)(destroyOnRemove);
|
|
1319
|
+
list.forEach((item) => item && _collection?.remove(item, destroy));
|
|
1320
|
+
});
|
|
1321
|
+
}
|
|
1322
|
+
});
|
|
1323
|
+
return result;
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1326
|
+
//#endregion
|
|
1327
|
+
//#region useImageryLayerScope/index.ts
|
|
1328
|
+
/**
|
|
1329
|
+
* Make `add` and `remove` operations of `ImageryLayerCollection` scoped,
|
|
1330
|
+
* automatically remove `ImageryLayer` instance when component is unmounted.
|
|
1331
|
+
*/
|
|
1332
|
+
function useImageryLayerScope(options = {}) {
|
|
1333
|
+
const { collection: _collection, destroyOnRemove } = options;
|
|
1334
|
+
const viewer = useViewer();
|
|
1335
|
+
const collection = (0, vue.computed)(() => {
|
|
1336
|
+
return (0, vue.toValue)(_collection) ?? viewer.value?.imageryLayers;
|
|
1337
|
+
});
|
|
1338
|
+
const addFn = (imageryLayer, index) => {
|
|
1339
|
+
if (!collection.value) throw new Error("collection is not defined");
|
|
1340
|
+
collection.value.add(imageryLayer, index);
|
|
1341
|
+
return imageryLayer;
|
|
1342
|
+
};
|
|
1343
|
+
const removeFn = (imageryLayer, destroy) => {
|
|
1344
|
+
return !!collection.value?.remove(imageryLayer, destroy);
|
|
1345
|
+
};
|
|
1346
|
+
const { scope, add, remove, removeWhere, removeScope } = useCollectionScope(addFn, removeFn, [destroyOnRemove]);
|
|
1347
|
+
return {
|
|
1348
|
+
scope,
|
|
1349
|
+
add,
|
|
1350
|
+
remove,
|
|
1351
|
+
removeWhere,
|
|
1352
|
+
removeScope
|
|
1353
|
+
};
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1356
|
+
//#endregion
|
|
1357
|
+
//#region usePostProcessStage/index.ts
|
|
1358
|
+
function usePostProcessStage(data, options = {}) {
|
|
1359
|
+
const { collection, isActive = true, evaluating } = options;
|
|
1360
|
+
const result = (0, __vueuse_core.computedAsync)(() => toPromiseValue(data), void 0, { evaluating });
|
|
1361
|
+
const viewer = useViewer();
|
|
1362
|
+
(0, vue.watchEffect)((onCleanup) => {
|
|
1363
|
+
if (!viewer.value) return;
|
|
1364
|
+
const _isActive = (0, vue.toValue)(isActive);
|
|
1365
|
+
if (_isActive) {
|
|
1366
|
+
const list = Array.isArray(result.value) ? [...result.value] : [result.value];
|
|
1367
|
+
const _collection = collection ?? viewer.value.scene.postProcessStages;
|
|
1368
|
+
list.forEach((item) => item && _collection.add(item));
|
|
1369
|
+
onCleanup(() => {
|
|
1370
|
+
list.forEach((item) => item && _collection.remove(item));
|
|
1371
|
+
});
|
|
1372
|
+
}
|
|
1373
|
+
});
|
|
1374
|
+
return result;
|
|
1375
|
+
}
|
|
1376
|
+
|
|
1377
|
+
//#endregion
|
|
1378
|
+
//#region usePostProcessStageScope/index.ts
|
|
1379
|
+
/**
|
|
1380
|
+
* Make `add` and `remove` operations of `PostProcessStageCollection` scoped,
|
|
1381
|
+
* automatically remove `PostProcessStage` instance when component is unmounted.
|
|
1382
|
+
*/
|
|
1383
|
+
function usePostProcessStageScope(options = {}) {
|
|
1384
|
+
const { collection: _collection } = options;
|
|
1385
|
+
const viewer = useViewer();
|
|
1386
|
+
const collection = (0, vue.computed)(() => {
|
|
1387
|
+
return (0, vue.toValue)(_collection) ?? viewer.value?.postProcessStages;
|
|
1388
|
+
});
|
|
1389
|
+
const addFn = (postProcessStage) => {
|
|
1390
|
+
if (!collection.value) throw new Error("collection is not defined");
|
|
1391
|
+
return collection.value.add(postProcessStage);
|
|
1392
|
+
};
|
|
1393
|
+
const removeFn = (postProcessStage) => {
|
|
1394
|
+
return !!collection.value?.remove(postProcessStage);
|
|
1395
|
+
};
|
|
1396
|
+
const { scope, add, remove, removeWhere, removeScope } = useCollectionScope(addFn, removeFn, []);
|
|
1397
|
+
return {
|
|
1398
|
+
scope,
|
|
1399
|
+
add,
|
|
1400
|
+
remove,
|
|
1401
|
+
removeWhere,
|
|
1402
|
+
removeScope
|
|
1403
|
+
};
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1406
|
+
//#endregion
|
|
1407
|
+
//#region usePrimitive/index.ts
|
|
1408
|
+
function usePrimitive(data, options = {}) {
|
|
1409
|
+
const { collection, isActive = true, evaluating } = options;
|
|
1410
|
+
const result = (0, __vueuse_core.computedAsync)(() => toPromiseValue(data), void 0, { evaluating });
|
|
1411
|
+
const viewer = useViewer();
|
|
1412
|
+
(0, vue.watchEffect)((onCleanup) => {
|
|
1413
|
+
const _isActive = (0, vue.toValue)(isActive);
|
|
1414
|
+
if (_isActive) {
|
|
1415
|
+
const list = Array.isArray(result.value) ? [...result.value] : [result.value];
|
|
1416
|
+
const _collection = collection === "ground" ? viewer.value?.scene.groundPrimitives : collection ?? viewer.value?.scene.primitives;
|
|
1417
|
+
list.forEach((item) => item && _collection?.add(item));
|
|
1418
|
+
onCleanup(() => {
|
|
1419
|
+
!_collection?.isDestroyed() && list.forEach((item) => item && _collection?.remove(item));
|
|
1420
|
+
});
|
|
1421
|
+
}
|
|
1422
|
+
});
|
|
1423
|
+
return result;
|
|
1424
|
+
}
|
|
1425
|
+
|
|
1426
|
+
//#endregion
|
|
1427
|
+
//#region usePrimitiveScope/index.ts
|
|
1428
|
+
/**
|
|
1429
|
+
* Make `add` and `remove` operations of `PrimitiveCollection` scoped,
|
|
1430
|
+
* automatically remove `Primitive` instance when component is unmounted.
|
|
1431
|
+
*/
|
|
1432
|
+
function usePrimitiveScope(options = {}) {
|
|
1433
|
+
const { collection: _collection } = options;
|
|
1434
|
+
const viewer = useViewer();
|
|
1435
|
+
const collection = (0, vue.computed)(() => {
|
|
1436
|
+
return (0, vue.toValue)(_collection) ?? viewer.value?.scene.primitives;
|
|
1437
|
+
});
|
|
1438
|
+
const addFn = (primitive) => {
|
|
1439
|
+
if (!collection.value) throw new Error("collection is not defined");
|
|
1440
|
+
return collection.value.add(primitive);
|
|
1441
|
+
};
|
|
1442
|
+
const removeFn = (primitive) => {
|
|
1443
|
+
return !!collection.value?.remove(primitive);
|
|
1444
|
+
};
|
|
1445
|
+
const { scope, add, remove, removeWhere, removeScope } = useCollectionScope(addFn, removeFn, []);
|
|
1446
|
+
return {
|
|
1447
|
+
scope,
|
|
1448
|
+
add,
|
|
1449
|
+
remove,
|
|
1450
|
+
removeWhere,
|
|
1451
|
+
removeScope
|
|
1452
|
+
};
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1455
|
+
//#endregion
|
|
1456
|
+
//#region useScaleBar/index.ts
|
|
1457
|
+
const distances = [
|
|
1458
|
+
.01,
|
|
1459
|
+
.05,
|
|
1460
|
+
.1,
|
|
1461
|
+
.5,
|
|
1462
|
+
1,
|
|
1463
|
+
2,
|
|
1464
|
+
3,
|
|
1465
|
+
5,
|
|
1466
|
+
10,
|
|
1467
|
+
20,
|
|
1468
|
+
30,
|
|
1469
|
+
50,
|
|
1470
|
+
100,
|
|
1471
|
+
200,
|
|
1472
|
+
300,
|
|
1473
|
+
500,
|
|
1474
|
+
1e3,
|
|
1475
|
+
2e3,
|
|
1476
|
+
3e3,
|
|
1477
|
+
5e3,
|
|
1478
|
+
1e4,
|
|
1479
|
+
2e4,
|
|
1480
|
+
3e4,
|
|
1481
|
+
5e4,
|
|
1482
|
+
1e5,
|
|
1483
|
+
2e5,
|
|
1484
|
+
3e5,
|
|
1485
|
+
5e5,
|
|
1486
|
+
1e6,
|
|
1487
|
+
2e6,
|
|
1488
|
+
3e6,
|
|
1489
|
+
5e6,
|
|
1490
|
+
1e7,
|
|
1491
|
+
2e7,
|
|
1492
|
+
3e7,
|
|
1493
|
+
5e7
|
|
1494
|
+
].reverse();
|
|
1495
|
+
/**
|
|
1496
|
+
* Reactive generation of scale bars
|
|
1497
|
+
*/
|
|
1498
|
+
function useScaleBar(options = {}) {
|
|
1499
|
+
const { maxPixel = 80, delay = 8 } = options;
|
|
1500
|
+
const maxPixelRef = (0, vue.computed)(() => (0, vue.toValue)(maxPixel));
|
|
1501
|
+
const viewer = useViewer();
|
|
1502
|
+
const canvasSize = (0, __vueuse_core.useElementSize)(() => viewer.value?.canvas);
|
|
1503
|
+
const pixelDistance = (0, vue.ref)();
|
|
1504
|
+
const setPixelDistance = async () => {
|
|
1505
|
+
await (0, vue.nextTick)();
|
|
1506
|
+
const scene = viewer.value?.scene;
|
|
1507
|
+
if (!scene) return;
|
|
1508
|
+
const left = scene.camera.getPickRay(new cesium.Cartesian2(Math.floor(canvasSize.width.value / 2), canvasSize.height.value - 1));
|
|
1509
|
+
const right = scene.camera.getPickRay(new cesium.Cartesian2(Math.floor(1 + canvasSize.width.value / 2), canvasSize.height.value - 1));
|
|
1510
|
+
if (!left || !right) return;
|
|
1511
|
+
const leftPosition = scene.globe.pick(left, scene);
|
|
1512
|
+
const rightPosition = scene.globe.pick(right, scene);
|
|
1513
|
+
if (!leftPosition || !rightPosition) return;
|
|
1514
|
+
const leftCartographic = scene.globe.ellipsoid.cartesianToCartographic(leftPosition);
|
|
1515
|
+
const rightCartographic = scene.globe.ellipsoid.cartesianToCartographic(rightPosition);
|
|
1516
|
+
const geodesic = new cesium.EllipsoidGeodesic(leftCartographic, rightCartographic);
|
|
1517
|
+
pixelDistance.value = geodesic.surfaceDistance;
|
|
1518
|
+
};
|
|
1519
|
+
(0, __vueuse_core.watchImmediate)(viewer, () => setPixelDistance());
|
|
1520
|
+
useCesiumEventListener(() => viewer.value?.camera.changed, throttle(setPixelDistance, delay));
|
|
1521
|
+
const distance = (0, vue.computed)(() => {
|
|
1522
|
+
if (pixelDistance.value) return distances.find((item) => pixelDistance.value * maxPixelRef.value > item);
|
|
1523
|
+
});
|
|
1524
|
+
const width = (0, vue.computed)(() => {
|
|
1525
|
+
if (distance.value && pixelDistance.value) {
|
|
1526
|
+
const value = distance.value / pixelDistance.value;
|
|
1527
|
+
return value;
|
|
1528
|
+
}
|
|
1529
|
+
return 0;
|
|
1530
|
+
});
|
|
1531
|
+
const distanceText = (0, vue.computed)(() => {
|
|
1532
|
+
if (distance.value) return distance.value > 1e3 ? `${distance.value / 1e3 || 0}km` : `${distance.value || 0}m`;
|
|
1533
|
+
});
|
|
1534
|
+
return {
|
|
1535
|
+
pixelDistance: (0, vue.readonly)(pixelDistance),
|
|
1536
|
+
width,
|
|
1537
|
+
distance,
|
|
1538
|
+
distanceText
|
|
1539
|
+
};
|
|
1540
|
+
}
|
|
1541
|
+
|
|
1542
|
+
//#endregion
|
|
1543
|
+
//#region useSceneDrillPick/index.ts
|
|
1544
|
+
/**
|
|
1545
|
+
* Uses the `scene.drillPick` function to perform screen point picking,
|
|
1546
|
+
* return a computed property containing the pick result, or undefined if no object is picked.
|
|
1547
|
+
*
|
|
1548
|
+
* @param windowPosition The screen coordinates of the pick point.
|
|
1549
|
+
*/
|
|
1550
|
+
function useSceneDrillPick(windowPosition, options = {}) {
|
|
1551
|
+
const { width = 3, height = 3, limit, throttled = 8, isActive = true } = options;
|
|
1552
|
+
const viewer = useViewer();
|
|
1553
|
+
const position = (0, __vueuse_core.refThrottled)((0, vue.computed)(() => (0, vue.toValue)(windowPosition)), throttled, false, true);
|
|
1554
|
+
const pick = (0, vue.computed)(() => {
|
|
1555
|
+
if (position.value && (0, vue.toValue)(isActive)) return viewer.value?.scene.drillPick(position.value, (0, vue.toValue)(limit), (0, vue.toValue)(width), (0, vue.toValue)(height));
|
|
1556
|
+
});
|
|
1557
|
+
return pick;
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1560
|
+
//#endregion
|
|
1561
|
+
exports.CREATE_VIEWER_COLLECTION = CREATE_VIEWER_COLLECTION;
|
|
1562
|
+
exports.CREATE_VIEWER_INJECTION_KEY = CREATE_VIEWER_INJECTION_KEY;
|
|
1563
|
+
exports.CesiumMaterial = CesiumMaterial;
|
|
1564
|
+
exports.addMaterialCache = addMaterialCache;
|
|
1565
|
+
exports.arrayDiff = arrayDiff;
|
|
1566
|
+
exports.assertError = assertError;
|
|
1567
|
+
exports.canvasCoordToCartesian = canvasCoordToCartesian;
|
|
1568
|
+
exports.cartesianToCanvasCoord = cartesianToCanvasCoord;
|
|
1569
|
+
exports.cesiumEquals = cesiumEquals;
|
|
1570
|
+
exports.createCesiumAttribute = createCesiumAttribute;
|
|
1571
|
+
exports.createCesiumProperty = createCesiumProperty;
|
|
1572
|
+
exports.createPropertyField = createPropertyField;
|
|
1573
|
+
exports.createViewer = createViewer;
|
|
1574
|
+
exports.degreesToDms = degreesToDms;
|
|
1575
|
+
exports.dmsDecode = dmsDecode;
|
|
1576
|
+
exports.dmsEncode = dmsEncode;
|
|
1577
|
+
exports.dmsToDegrees = dmsToDegrees;
|
|
1578
|
+
exports.getMaterialCache = getMaterialCache;
|
|
1579
|
+
exports.isArray = isArray;
|
|
1580
|
+
exports.isBase64 = isBase64;
|
|
1581
|
+
exports.isBoolean = isBoolean;
|
|
1582
|
+
exports.isCesiumConstant = isCesiumConstant;
|
|
1583
|
+
exports.isDef = isDef;
|
|
1584
|
+
exports.isElement = isElement;
|
|
1585
|
+
exports.isFunction = isFunction;
|
|
1586
|
+
exports.isNumber = isNumber;
|
|
1587
|
+
exports.isObject = isObject;
|
|
1588
|
+
exports.isPromise = isPromise;
|
|
1589
|
+
exports.isProperty = isProperty;
|
|
1590
|
+
exports.isString = isString;
|
|
1591
|
+
exports.isWindow = isWindow;
|
|
1592
|
+
exports.pickHitGraphic = pickHitGraphic;
|
|
1593
|
+
exports.resolvePick = resolvePick;
|
|
1594
|
+
exports.throttle = throttle;
|
|
1595
|
+
exports.toCartesian3 = toCartesian3;
|
|
1596
|
+
exports.toCartographic = toCartographic;
|
|
1597
|
+
exports.toCoord = toCoord;
|
|
1598
|
+
exports.toPromiseValue = toPromiseValue;
|
|
1599
|
+
exports.toProperty = toProperty;
|
|
1600
|
+
exports.toPropertyValue = toPropertyValue;
|
|
1601
|
+
exports.tryRun = tryRun;
|
|
1602
|
+
exports.useCameraState = useCameraState;
|
|
1603
|
+
exports.useCesiumEventListener = useCesiumEventListener;
|
|
1604
|
+
exports.useCesiumFps = useCesiumFps;
|
|
1605
|
+
exports.useCollectionScope = useCollectionScope;
|
|
1606
|
+
exports.useDataSource = useDataSource;
|
|
1607
|
+
exports.useDataSourceScope = useDataSourceScope;
|
|
1608
|
+
exports.useElementOverlay = useElementOverlay;
|
|
1609
|
+
exports.useEntity = useEntity;
|
|
1610
|
+
exports.useEntityScope = useEntityScope;
|
|
1611
|
+
exports.useGraphicEvent = useGraphicEvent;
|
|
1612
|
+
exports.useImageryLayer = useImageryLayer;
|
|
1613
|
+
exports.useImageryLayerScope = useImageryLayerScope;
|
|
1614
|
+
exports.usePostProcessStage = usePostProcessStage;
|
|
1615
|
+
exports.usePostProcessStageScope = usePostProcessStageScope;
|
|
1616
|
+
exports.usePrimitive = usePrimitive;
|
|
1617
|
+
exports.usePrimitiveScope = usePrimitiveScope;
|
|
1618
|
+
exports.useScaleBar = useScaleBar;
|
|
1619
|
+
exports.useSceneDrillPick = useSceneDrillPick;
|
|
1620
|
+
exports.useScenePick = useScenePick;
|
|
1621
|
+
exports.useScreenSpaceEventHandler = useScreenSpaceEventHandler;
|
|
1622
|
+
exports.useViewer = useViewer;
|
|
1623
|
+
})(this.Vesium = this.Vesium || {}, VueUse, Cesium, Vue);
|
|
1624
|
+
//# sourceMappingURL=index.iife.js.map
|