@lumiscaphe/viewer 4.2.2 → 4.3.1
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/CHANGELOG.md +11 -0
- package/dist/lib/index.cjs +4 -6
- package/dist/lib/index.d.ts +48 -52
- package/dist/lib/index.js +1688 -1778
- package/package.json +16 -9
- package/CLAUDE.md +0 -174
package/dist/lib/index.js
CHANGED
|
@@ -1,1778 +1,1688 @@
|
|
|
1
|
-
(function(){
|
|
2
|
-
import
|
|
3
|
-
import * as
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
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
|
-
class
|
|
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
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
case "vrcube":
|
|
1690
|
-
return this.widgetVRCube ?? this.widgetImage;
|
|
1691
|
-
case "vrobject":
|
|
1692
|
-
return this.widgetVRObject;
|
|
1693
|
-
default:
|
|
1694
|
-
return this.widgetImage;
|
|
1695
|
-
}
|
|
1696
|
-
}
|
|
1697
|
-
onMouseDown(t) {
|
|
1698
|
-
this.widget.onMouseDown(t);
|
|
1699
|
-
}
|
|
1700
|
-
onMouseEnter(t) {
|
|
1701
|
-
this.widget.onMouseEnter(t);
|
|
1702
|
-
}
|
|
1703
|
-
onMouseMove(t) {
|
|
1704
|
-
this.widget.onMouseMove(t);
|
|
1705
|
-
}
|
|
1706
|
-
onMouseUp(t) {
|
|
1707
|
-
this.widget.onMouseUp(t);
|
|
1708
|
-
}
|
|
1709
|
-
onTouchStart(t) {
|
|
1710
|
-
this.widget.onTouchStart(t);
|
|
1711
|
-
}
|
|
1712
|
-
onTouchMove(t) {
|
|
1713
|
-
this.widget.onTouchMove(t);
|
|
1714
|
-
}
|
|
1715
|
-
onTouchEnd(t) {
|
|
1716
|
-
this.widget.onTouchEnd(t);
|
|
1717
|
-
}
|
|
1718
|
-
onDeviceOrientation(t) {
|
|
1719
|
-
this.widget.onDeviceOrientation(t);
|
|
1720
|
-
}
|
|
1721
|
-
// Cap per-axis so the canvas backing never exceeds the source resolution; otherwise
|
|
1722
|
-
// drawImage upscales the JPEG and looks blurry on iOS / MacOS.
|
|
1723
|
-
getCanvas2DPixelRatio(t, e) {
|
|
1724
|
-
return t <= 0 || e <= 0 || this.resolution.width <= 0 || this.resolution.height <= 0 ? window.devicePixelRatio : Math.min(window.devicePixelRatio, this.resolution.width / t, this.resolution.height / e);
|
|
1725
|
-
}
|
|
1726
|
-
onResize() {
|
|
1727
|
-
const t = this.container.clientWidth, e = this.container.clientHeight;
|
|
1728
|
-
this.options.autores && (this.resolution = b.getStandardResolution(t * window.devicePixelRatio, e * window.devicePixelRatio, this.aspectRatioOverride), this.parameters.width = this.resolution.width, this.parameters.height = this.resolution.height), this.canvas2D.resize(t, e, this.getCanvas2DPixelRatio(t, e)), this.canvas3D.resize(t, e, window.devicePixelRatio), this.video.resize(t, e, this.resolution, this.options.fit), this.loadWidget(!1, !1).then(() => {
|
|
1729
|
-
this.onHotspotsChange();
|
|
1730
|
-
}).catch((i) => {
|
|
1731
|
-
this.onLoadError(i);
|
|
1732
|
-
});
|
|
1733
|
-
}
|
|
1734
|
-
onVrcubeInteraction(...t) {
|
|
1735
|
-
this.onHotspotsChange(), this.options.events.onInteraction(...t), this.options.events.onVrcubeInteraction(...t);
|
|
1736
|
-
}
|
|
1737
|
-
onVrobjectInteraction(t) {
|
|
1738
|
-
this.onHotspotsChange(), this.options.events.onInteraction(t.position), this.options.events.onVrobjectInteraction(t.position);
|
|
1739
|
-
}
|
|
1740
|
-
onHotspotsChange() {
|
|
1741
|
-
const t = this.widget.hotspots(this.resolution);
|
|
1742
|
-
t.length && this.options.events.onHotspotsChange(t);
|
|
1743
|
-
}
|
|
1744
|
-
onLoadStart(...t) {
|
|
1745
|
-
this.container.classList.add("ls-viewer-container-loading"), this.options.events.onLoadStart(...t);
|
|
1746
|
-
}
|
|
1747
|
-
onLoadProgress(...t) {
|
|
1748
|
-
this.options.events.onLoadProgress(...t);
|
|
1749
|
-
}
|
|
1750
|
-
onLoadEnd(...t) {
|
|
1751
|
-
this.container.classList.remove("ls-viewer-container-loading"), this.options.events.onLoadEnd(...t);
|
|
1752
|
-
}
|
|
1753
|
-
onLoadError(...t) {
|
|
1754
|
-
this.container.classList.remove("ls-viewer-container-loading"), this.options.events.onLoadError(...t);
|
|
1755
|
-
}
|
|
1756
|
-
}
|
|
1757
|
-
var q;
|
|
1758
|
-
((v) => {
|
|
1759
|
-
((t) => {
|
|
1760
|
-
t.Visible = "Visible", t.Occluded = "Occluded", t.Clipped = "Clipped", t.OutOfFrustum = "OutOfFrustum";
|
|
1761
|
-
})(v.HotspotVisibility || (v.HotspotVisibility = {})), ((t) => {
|
|
1762
|
-
t.VeryLow = "veryLow", t.Low = "low", t.Medium = "medium", t.Fine = "fine", t.Ultra = "ultra";
|
|
1763
|
-
})(v.SunShadowQualityMode || (v.SunShadowQualityMode = {})), ((t) => {
|
|
1764
|
-
t.None = "none", t.Weak = "weak", t.Normal = "normal", t.Fine = "fine", t.UltraFine = "ultraFine", t.Max = "max";
|
|
1765
|
-
})(v.SunShadowSmoothnessMode || (v.SunShadowSmoothnessMode = {})), ((t) => {
|
|
1766
|
-
t.Manual = "manual", t.TimeAndLoc = "timeAndLoc", t.ExtractedFromEnv = "extractedFromEnv";
|
|
1767
|
-
})(v.SunUseCaseMode || (v.SunUseCaseMode = {})), ((t) => {
|
|
1768
|
-
t.ShowOnly = "showOnly", t.HideOnly = "hideOnly";
|
|
1769
|
-
})(v.SurfacesFilterMode || (v.SurfacesFilterMode = {}));
|
|
1770
|
-
})(q || (q = {}));
|
|
1771
|
-
export {
|
|
1772
|
-
nt as Viewer,
|
|
1773
|
-
q as WRAPIv2,
|
|
1774
|
-
J as WidgetImage,
|
|
1775
|
-
tt as WidgetVRCube,
|
|
1776
|
-
k as WidgetVRObject,
|
|
1777
|
-
it as WidgetVideo
|
|
1778
|
-
};
|
|
1
|
+
(function(){try{if(typeof document<`u`){var e=document.createElement(`style`);e.appendChild(document.createTextNode(`.ls-viewer-container{-webkit-user-select:none;user-select:none;width:100%;height:100%;display:block;position:relative;overflow:hidden}.ls-viewer-container-image,.ls-viewer-container-video{cursor:default;pointer-events:none}.ls-viewer-container-vrcube{cursor:pointer;cursor:grab;touch-action:none}.ls-viewer-container-vrcube-grabbing{cursor:move;cursor:grabbing}.ls-viewer-container-vrobject{cursor:move;cursor:grab;touch-action:none}.ls-viewer-container-vrobject-grabbing{cursor:move;cursor:grabbing}.ls-viewer-container-loading{cursor:progress}.ls-viewer-canvas{opacity:0;transition:opacity .5s;position:absolute}.ls-viewer-video{position:absolute}/*$vite$:1*/`)),document.head.appendChild(e)}}catch(e){console.error(`vite-plugin-css-injected-by-js`,e)}})();
|
|
2
|
+
import e from "debounce-promise";
|
|
3
|
+
import * as t from "twgl.js";
|
|
4
|
+
import { m4 as n, v3 as r } from "twgl.js";
|
|
5
|
+
import i from "regression";
|
|
6
|
+
//#region src/lib/Resolution.ts
|
|
7
|
+
var a = class {
|
|
8
|
+
constructor(e, t) {
|
|
9
|
+
this.width = e, this.height = t;
|
|
10
|
+
}
|
|
11
|
+
get aspect() {
|
|
12
|
+
return this.width / this.height;
|
|
13
|
+
}
|
|
14
|
+
}, o = class e {
|
|
15
|
+
static {
|
|
16
|
+
this.LANDSCAPE_ASPECT_BOUNDARY = Math.sqrt(4 / 3 * (16 / 9));
|
|
17
|
+
}
|
|
18
|
+
static {
|
|
19
|
+
this.PORTRAIT_ASPECT_BOUNDARY = Math.sqrt(.421875);
|
|
20
|
+
}
|
|
21
|
+
constructor(e, t, n, r) {
|
|
22
|
+
this.top = e, this.left = t, this.width = n, this.height = r;
|
|
23
|
+
}
|
|
24
|
+
static contains(e, t) {
|
|
25
|
+
return t.x >= 0 && t.x < e.width && t.y >= 0 && t.y < e.height;
|
|
26
|
+
}
|
|
27
|
+
static fit(t, n, r) {
|
|
28
|
+
let i = t.aspect, a = n.aspect, o, s;
|
|
29
|
+
switch (r) {
|
|
30
|
+
case "contain":
|
|
31
|
+
o = a < i ? n.width : n.height * i, s = a < i ? n.width / i : n.height;
|
|
32
|
+
break;
|
|
33
|
+
case "cover":
|
|
34
|
+
default:
|
|
35
|
+
o = a < i ? n.height * i : n.width, s = a < i ? n.height : n.width / i;
|
|
36
|
+
break;
|
|
37
|
+
case "fill": o = n.width, s = n.height;
|
|
38
|
+
}
|
|
39
|
+
let c = (n.height - s) / 2, l = (n.width - o) / 2;
|
|
40
|
+
return new e(c, l, o, s);
|
|
41
|
+
}
|
|
42
|
+
static project(t, n, r, i) {
|
|
43
|
+
let a = e.fit(t, n, r), o = a.width / t.width, s = a.height / t.height;
|
|
44
|
+
return {
|
|
45
|
+
x: Math.round(a.left + i.x * o),
|
|
46
|
+
y: Math.round(a.top + i.y * s)
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
static unproject(t, n, r, i) {
|
|
50
|
+
let a = e.fit(t, n, r), o = a.width / t.width, s = a.height / t.height;
|
|
51
|
+
return {
|
|
52
|
+
x: Math.round((i.x - a.left) / o),
|
|
53
|
+
y: Math.round((i.y - a.top) / s)
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
static getStandardAspectRatio(t, n, r) {
|
|
57
|
+
if (t === 0 || n === 0) return 0;
|
|
58
|
+
if (r) return r;
|
|
59
|
+
let i = t / n;
|
|
60
|
+
return t < n ? i < e.PORTRAIT_ASPECT_BOUNDARY ? 9 / 16 : 3 / 4 : i < e.LANDSCAPE_ASPECT_BOUNDARY ? 4 / 3 : 16 / 9;
|
|
61
|
+
}
|
|
62
|
+
static getStandardResolution(t, n, r) {
|
|
63
|
+
if (t === 0 || n === 0) return new a(0, 0);
|
|
64
|
+
let i = e.getStandardAspectRatio(t, n, r);
|
|
65
|
+
if (r) {
|
|
66
|
+
let r = e.getStandardQuality(Math.min(t, n));
|
|
67
|
+
return new a(Math.round(r * i), Math.round(r));
|
|
68
|
+
}
|
|
69
|
+
if (t < n) {
|
|
70
|
+
let r = e.getStandardQuality(Math.max(n * i, t));
|
|
71
|
+
return new a(Math.round(r), Math.round(r / i));
|
|
72
|
+
}
|
|
73
|
+
let o = e.getStandardQuality(Math.max(t / i, n));
|
|
74
|
+
return new a(Math.round(o * i), Math.round(o));
|
|
75
|
+
}
|
|
76
|
+
static getStandardQuality(e) {
|
|
77
|
+
return e <= 720 ? 720 : 1080;
|
|
78
|
+
}
|
|
79
|
+
}, s = class {
|
|
80
|
+
constructor(e) {
|
|
81
|
+
this.element = document.createElement("canvas"), this.element.classList.add("ls-viewer-canvas"), this.element.style.opacity = "0", this.element.width = 0, this.element.height = 0, this.context = this.element.getContext("2d"), this.context.imageSmoothingQuality = "high", this.backCanvas = document.createElement("canvas"), this.backContext = this.backCanvas.getContext("2d"), this.backContext.imageSmoothingQuality = "high", this.fit = e;
|
|
82
|
+
}
|
|
83
|
+
destroy() {
|
|
84
|
+
this.requestAnimationId &&= (cancelAnimationFrame(this.requestAnimationId), void 0);
|
|
85
|
+
}
|
|
86
|
+
show(e) {
|
|
87
|
+
e ? this.element.style.display = "block" : this.element.style.opacity = "1";
|
|
88
|
+
}
|
|
89
|
+
hide(e) {
|
|
90
|
+
e ? this.element.style.display = "none" : this.element.style.opacity = "0";
|
|
91
|
+
}
|
|
92
|
+
get resolution() {
|
|
93
|
+
return new a(this.element.clientWidth, this.element.clientHeight);
|
|
94
|
+
}
|
|
95
|
+
resize(e, t, n) {
|
|
96
|
+
let r = Math.floor(e * n), i = Math.floor(t * n);
|
|
97
|
+
this.element.style.width = `${e}px`, this.element.style.height = `${t}px`, (this.element.width !== r || this.element.height !== i) && (this.element.width = r, this.element.height = i, this.context.imageSmoothingQuality = "high", this.backCanvas.width = r, this.backCanvas.height = i, this.backContext.imageSmoothingQuality = "high", this.image && this.draw(this.image, !1));
|
|
98
|
+
}
|
|
99
|
+
draw(e, t, n) {
|
|
100
|
+
if (!e) return;
|
|
101
|
+
this.requestAnimationId &&= (cancelAnimationFrame(this.requestAnimationId), void 0);
|
|
102
|
+
let r = o.fit(new a(e.width, e.height), new a(this.element.width, this.element.height), this.fit);
|
|
103
|
+
t ? (this.backContext.drawImage(this.element, 0, 0), this.context.globalAlpha = 0, this.fadeLoop(e, n || 0)) : (this.context.globalAlpha = 1, this.context.drawImage(e, r.left, r.top, r.width, r.height)), this.image = e;
|
|
104
|
+
}
|
|
105
|
+
fadeLoop(e, t) {
|
|
106
|
+
if (this.context.globalAlpha >= 1) {
|
|
107
|
+
cancelAnimationFrame(this.requestAnimationId), this.requestAnimationId = void 0;
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
let n = Math.min(this.context.globalAlpha + t, 1), r = o.fit(new a(e.width, e.height), new a(this.element.width, this.element.height), this.fit);
|
|
111
|
+
this.context.clearRect(0, 0, this.element.width, this.element.height), this.context.globalAlpha = 1, this.context.drawImage(this.backCanvas, 0, 0), this.context.globalAlpha = n, this.context.drawImage(e, r.left, r.top, r.width, r.height), this.requestAnimationId = requestAnimationFrame(() => {
|
|
112
|
+
this.fadeLoop(e, t);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}, c = class {
|
|
116
|
+
constructor() {
|
|
117
|
+
this.element = document.createElement("canvas"), this.element.classList.add("ls-viewer-canvas"), this.element.style.opacity = "0", this.element.width = 0, this.element.height = 0, this.context = t.getContext(this.element, { preserveDrawingBuffer: !0 }), this.context && this.context.isContextLost() && (this.context = void 0), t.setDefaults({ textureColor: [
|
|
118
|
+
1,
|
|
119
|
+
1,
|
|
120
|
+
1,
|
|
121
|
+
1
|
|
122
|
+
] });
|
|
123
|
+
}
|
|
124
|
+
show() {
|
|
125
|
+
this.element.style.opacity = "1";
|
|
126
|
+
}
|
|
127
|
+
hide() {
|
|
128
|
+
this.element.style.opacity = "0";
|
|
129
|
+
}
|
|
130
|
+
resize(e, t, n) {
|
|
131
|
+
this.element.width = e * n, this.element.height = t * n, this.element.style.width = `${e}px`, this.element.style.height = `${t}px`;
|
|
132
|
+
}
|
|
133
|
+
}, l = class {
|
|
134
|
+
static accelerate(e, t) {
|
|
135
|
+
return Math.abs(e) ** (t || 1.5) * (e > 0 ? 1 : -1);
|
|
136
|
+
}
|
|
137
|
+
static clamp(e, t, n) {
|
|
138
|
+
return Math.max(Math.min(e, n), t);
|
|
139
|
+
}
|
|
140
|
+
static degreesToRadians(e) {
|
|
141
|
+
return Math.PI / 180 * e;
|
|
142
|
+
}
|
|
143
|
+
static radiansToDegrees(e) {
|
|
144
|
+
return 180 / Math.PI * e;
|
|
145
|
+
}
|
|
146
|
+
static mod(e, t) {
|
|
147
|
+
return e - t * Math.floor(e / t);
|
|
148
|
+
}
|
|
149
|
+
static perspectiveWithFovX(e, t, n, r, i) {
|
|
150
|
+
let a = Math.tan(e / 2), o = a / t;
|
|
151
|
+
return this.perspectiveWithLeft(-a, a, -o, o, n, r, i);
|
|
152
|
+
}
|
|
153
|
+
static perspectiveWithFovY(e, t, n, r, i) {
|
|
154
|
+
let a = n * Math.tan(e / 2), o = a * t;
|
|
155
|
+
return this.perspectiveWithLeft(-o, o, -a, a, n, r, i);
|
|
156
|
+
}
|
|
157
|
+
static perspectiveWithLeft(e, t, n, r, i, a, o) {
|
|
158
|
+
o ||= /* @__PURE__ */ new Float32Array(16);
|
|
159
|
+
let s = t + e, c = t - e, l = r + n, u = r - n, d = a - i;
|
|
160
|
+
return o[0] = 2 * i / c, o[1] = 0, o[2] = 0, o[3] = 0, o[4] = 0, o[5] = 2 * i / u, o[6] = 0, o[7] = 0, o[8] = s / c, o[9] = l / u, o[10] = -a / d, o[11] = -1, o[12] = 0, o[13] = 0, o[14] = -a * i / d, o[15] = 0, o;
|
|
161
|
+
}
|
|
162
|
+
}, u = class e {
|
|
163
|
+
static {
|
|
164
|
+
this.default = new e([
|
|
165
|
+
0,
|
|
166
|
+
0,
|
|
167
|
+
0
|
|
168
|
+
], [
|
|
169
|
+
2,
|
|
170
|
+
2,
|
|
171
|
+
2
|
|
172
|
+
], [
|
|
173
|
+
0,
|
|
174
|
+
1,
|
|
175
|
+
0
|
|
176
|
+
]);
|
|
177
|
+
}
|
|
178
|
+
static initCubeFace(t, n, i) {
|
|
179
|
+
let a = [
|
|
180
|
+
0,
|
|
181
|
+
0,
|
|
182
|
+
0
|
|
183
|
+
], o = r.subtract(n, t), s = r.mulScalar([
|
|
184
|
+
0,
|
|
185
|
+
1,
|
|
186
|
+
0
|
|
187
|
+
], r.length(o)), c = r.mulScalar(r.normalize(r.cross(o, s)), r.length(o)), l = r.mulScalar(r.normalize(r.cross(s, c)), r.length(o));
|
|
188
|
+
switch (i) {
|
|
189
|
+
case "front":
|
|
190
|
+
n = r.add(t, l), a = r.normalize(s);
|
|
191
|
+
break;
|
|
192
|
+
case "right":
|
|
193
|
+
n = r.add(t, c), a = r.normalize(s);
|
|
194
|
+
break;
|
|
195
|
+
case "back":
|
|
196
|
+
n = r.subtract(t, l), a = r.normalize(s);
|
|
197
|
+
break;
|
|
198
|
+
case "left":
|
|
199
|
+
n = r.subtract(t, c), a = r.normalize(s);
|
|
200
|
+
break;
|
|
201
|
+
case "up":
|
|
202
|
+
n = r.add(t, s), a = r.normalize(r.mulScalar(l, -1));
|
|
203
|
+
break;
|
|
204
|
+
case "down": n = r.subtract(t, s), a = r.normalize(l);
|
|
205
|
+
}
|
|
206
|
+
return new e(n, t, a);
|
|
207
|
+
}
|
|
208
|
+
constructor(e, t, n) {
|
|
209
|
+
this.target = r.copy(e), this.eye = r.copy(t), this.up = r.copy(n);
|
|
210
|
+
}
|
|
211
|
+
get viewVector() {
|
|
212
|
+
return r.subtract(this.target, this.eye);
|
|
213
|
+
}
|
|
214
|
+
get rightVector() {
|
|
215
|
+
return r.normalize(r.cross(this.viewVector, this.up));
|
|
216
|
+
}
|
|
217
|
+
get viewMatrix() {
|
|
218
|
+
return n.inverse(n.lookAt(this.eye, this.target, this.up));
|
|
219
|
+
}
|
|
220
|
+
clone() {
|
|
221
|
+
return new e(r.copy(this.target), r.copy(this.eye), r.copy(this.up));
|
|
222
|
+
}
|
|
223
|
+
}, d = class {
|
|
224
|
+
constructor(e) {
|
|
225
|
+
this.target = e.target;
|
|
226
|
+
let t = r.normalize(r.subtract(e.eye, e.target)), n = r.dot(t, [
|
|
227
|
+
1,
|
|
228
|
+
0,
|
|
229
|
+
0
|
|
230
|
+
]), i = r.dot(t, [
|
|
231
|
+
0,
|
|
232
|
+
1,
|
|
233
|
+
0
|
|
234
|
+
]), a = r.dot(t, [
|
|
235
|
+
0,
|
|
236
|
+
0,
|
|
237
|
+
1
|
|
238
|
+
]);
|
|
239
|
+
this.longitude = Math.atan2(n, a), this.latitude = Math.atan2(i, Math.sqrt(n * n + a * a)), r.dot(e.up, [
|
|
240
|
+
0,
|
|
241
|
+
1,
|
|
242
|
+
0
|
|
243
|
+
]) < 0 && (this.longitude = Math.PI + this.longitude, this.latitude = Math.PI - this.latitude), this.distance = r.length(r.subtract(e.target, e.eye));
|
|
244
|
+
}
|
|
245
|
+
get vector() {
|
|
246
|
+
let e = Math.cos(this.latitude) * this.distance, t = Math.sin(this.latitude) * this.distance;
|
|
247
|
+
return [
|
|
248
|
+
Math.cos(this.longitude) * e,
|
|
249
|
+
t,
|
|
250
|
+
Math.sin(this.longitude) * e
|
|
251
|
+
];
|
|
252
|
+
}
|
|
253
|
+
pointOfView(e) {
|
|
254
|
+
let t = n.rotationY(this.longitude), i = n.rotationX(-this.latitude), a = n.rotationZ(0), o = n.multiply(t, n.multiply(i, a)), s = [
|
|
255
|
+
0,
|
|
256
|
+
0,
|
|
257
|
+
-1
|
|
258
|
+
];
|
|
259
|
+
s = n.transformPoint(o, s);
|
|
260
|
+
let c = [
|
|
261
|
+
0,
|
|
262
|
+
1,
|
|
263
|
+
0
|
|
264
|
+
];
|
|
265
|
+
return c = n.transformPoint(o, c), new u(e, r.subtract(e, r.mulScalar(s, this.distance)), c);
|
|
266
|
+
}
|
|
267
|
+
}, f = class {
|
|
268
|
+
constructor() {}
|
|
269
|
+
async animation(e, t) {
|
|
270
|
+
return e.scene;
|
|
271
|
+
}
|
|
272
|
+
async database(e) {
|
|
273
|
+
throw Error("Unavailable");
|
|
274
|
+
}
|
|
275
|
+
async image(e, t) {
|
|
276
|
+
return e.scene;
|
|
277
|
+
}
|
|
278
|
+
async video(e) {
|
|
279
|
+
return e.scene;
|
|
280
|
+
}
|
|
281
|
+
async vrCube(e, t) {
|
|
282
|
+
return e.scene;
|
|
283
|
+
}
|
|
284
|
+
async vrObject(e, t) {
|
|
285
|
+
return e.scene;
|
|
286
|
+
}
|
|
287
|
+
}, p = class {
|
|
288
|
+
constructor(e) {
|
|
289
|
+
this.xmlDoc = e;
|
|
290
|
+
}
|
|
291
|
+
get id() {
|
|
292
|
+
return this.xmlDoc.getElementsByTagName("Database")[0]?.getAttribute("id");
|
|
293
|
+
}
|
|
294
|
+
getCameraId(e, t) {
|
|
295
|
+
return t ? this.xmlDoc.querySelector(`RootCameraGroup Group[name="${t}"] Camera[name="${e}"]`)?.getAttribute("id") : this.xmlDoc.querySelector(`RootCameraGroup Camera[name="${e}"]`)?.getAttribute("id");
|
|
296
|
+
}
|
|
297
|
+
getCameraById(e, t) {
|
|
298
|
+
let n;
|
|
299
|
+
return n = e && t ? this.xmlDoc.querySelector(`RootCameraGroup Group[id="${t}"] Camera[id="${e}"]`) : this.xmlDoc.querySelector(`RootCameraGroup Camera[id="${e}"]`), n ? this.mapElementToCamera(n) : null;
|
|
300
|
+
}
|
|
301
|
+
getCameraByName(e, t) {
|
|
302
|
+
let n;
|
|
303
|
+
return n = t && e ? this.xmlDoc.querySelector(`RootCameraGroup Group[name="${t}"] Camera[name="${e}"]`) : this.xmlDoc.querySelector(`RootCameraGroup Camera[name="${e}"]`), n ? this.mapElementToCamera(n) : null;
|
|
304
|
+
}
|
|
305
|
+
getCameraGroupId(e) {
|
|
306
|
+
return this.xmlDoc.querySelector(`RootCameraGroup Group[name="${e}"]`)?.getAttribute("id");
|
|
307
|
+
}
|
|
308
|
+
getCameraGroupById(e) {
|
|
309
|
+
let t = this.xmlDoc.querySelector(`RootCameraGroup Group[id="${e}"]`);
|
|
310
|
+
return t ? this.mapElementToCameraGroup(t) : null;
|
|
311
|
+
}
|
|
312
|
+
getCameraGroupByName(e) {
|
|
313
|
+
let t = this.xmlDoc.querySelector(`RootCameraGroup Group[name="${e}"]`);
|
|
314
|
+
return t ? this.mapElementToCameraGroup(t) : null;
|
|
315
|
+
}
|
|
316
|
+
mapElementToCamera(e) {
|
|
317
|
+
return {
|
|
318
|
+
id: e.getAttribute("id"),
|
|
319
|
+
name: e.getAttribute("name"),
|
|
320
|
+
pointOfView: new u([
|
|
321
|
+
parseFloat(e.querySelector("PointOfView Target").getAttribute("x")),
|
|
322
|
+
parseFloat(e.querySelector("PointOfView Target").getAttribute("y")),
|
|
323
|
+
parseFloat(e.querySelector("PointOfView Target").getAttribute("z"))
|
|
324
|
+
], [
|
|
325
|
+
parseFloat(e.querySelector("PointOfView Eye").getAttribute("x")),
|
|
326
|
+
parseFloat(e.querySelector("PointOfView Eye").getAttribute("y")),
|
|
327
|
+
parseFloat(e.querySelector("PointOfView Eye").getAttribute("z"))
|
|
328
|
+
], [
|
|
329
|
+
parseFloat(e.querySelector("PointOfView Up").getAttribute("x")),
|
|
330
|
+
parseFloat(e.querySelector("PointOfView Up").getAttribute("y")),
|
|
331
|
+
parseFloat(e.querySelector("PointOfView Up").getAttribute("z"))
|
|
332
|
+
])
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
mapElementToCameraGroup(e) {
|
|
336
|
+
return {
|
|
337
|
+
id: e.getAttribute("id"),
|
|
338
|
+
name: e.getAttribute("name"),
|
|
339
|
+
cameras: [...e.querySelectorAll("Camera")].map((e) => this.mapElementToCamera(e))
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
}, m = class e {
|
|
343
|
+
static {
|
|
344
|
+
this.xmlRegex = /directUrl="([^"]*)"/g;
|
|
345
|
+
}
|
|
346
|
+
constructor(e) {
|
|
347
|
+
this.server = e;
|
|
348
|
+
}
|
|
349
|
+
static buildQuery(e) {
|
|
350
|
+
return Object.entries(e).filter(([e, t]) => t != null).map(([e, t]) => `${e}=${t}`).join("&");
|
|
351
|
+
}
|
|
352
|
+
static sceneParameters(e) {
|
|
353
|
+
let t = e.scene, n = t.length > 1 ? t.find((e) => e.accessory) : null, r = t.length > 1 ? t.find((e) => e.decor) : null, i = t.find((e) => e !== n && e !== r);
|
|
354
|
+
return {
|
|
355
|
+
databaseId: i.database,
|
|
356
|
+
configuration: i?.configuration,
|
|
357
|
+
animations: i?.animations?.join("/"),
|
|
358
|
+
accessoryDatabaseId: n?.database,
|
|
359
|
+
decorDatabaseId: r?.database,
|
|
360
|
+
decorDeltaAltitude: r?.translation?.y
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
static renderParameters(e) {
|
|
364
|
+
let { parameters: t, view: n } = e;
|
|
365
|
+
return {
|
|
366
|
+
background: n.background,
|
|
367
|
+
width: t.width,
|
|
368
|
+
height: t.height,
|
|
369
|
+
softwareAntialiasing: t.antialiasing,
|
|
370
|
+
superSampling: t.superSampling
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
static encoderParameters(e) {
|
|
374
|
+
let { encoder: t } = e;
|
|
375
|
+
return {
|
|
376
|
+
imageFormat: t.format,
|
|
377
|
+
imageQuality: t.quality
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
static async fetch(e, t) {
|
|
381
|
+
return fetch(e, { signal: t }).then((e) => e.text()).then((e) => {
|
|
382
|
+
let t = e.replace(/&/g, "&").match(this.xmlRegex);
|
|
383
|
+
return t ? t.map((e) => e.replace(this.xmlRegex, "$1")) : Promise.reject();
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
async animation(t, n) {
|
|
387
|
+
let r = {
|
|
388
|
+
...e.sceneParameters(t),
|
|
389
|
+
animation: t.view.animation,
|
|
390
|
+
bookmarkSet: t.view.camera.split("/")[0],
|
|
391
|
+
bookmark: t.view.camera.split("/")[1],
|
|
392
|
+
frames: t.view.frames,
|
|
393
|
+
loop: !!t.view.loop,
|
|
394
|
+
...e.renderParameters(t),
|
|
395
|
+
...e.encoderParameters(t)
|
|
396
|
+
}, i = e.buildQuery(r);
|
|
397
|
+
return e.fetch(`${this.server}/ImagesFromAnimation?${i}`, n);
|
|
398
|
+
}
|
|
399
|
+
async database(e) {
|
|
400
|
+
return fetch(`${this.server}/Database?databaseId=${e}`).then((e) => e.text()).then((e) => new p(new DOMParser().parseFromString(e, "application/xml")));
|
|
401
|
+
}
|
|
402
|
+
async image(t, n) {
|
|
403
|
+
let r = {
|
|
404
|
+
...e.sceneParameters(t),
|
|
405
|
+
bookmarkSet: t.view.camera.split("/")[0],
|
|
406
|
+
bookmark: t.view.camera.split("/")[1],
|
|
407
|
+
...e.renderParameters(t),
|
|
408
|
+
...e.encoderParameters(t)
|
|
409
|
+
}, i = e.buildQuery(r);
|
|
410
|
+
return Promise.resolve(`${this.server}/ImageFromBookmark?${i}`);
|
|
411
|
+
}
|
|
412
|
+
async video(t) {
|
|
413
|
+
let n = {
|
|
414
|
+
...e.sceneParameters(t),
|
|
415
|
+
animation: t.view.animation,
|
|
416
|
+
bookmarkSet: t.view.camera.split("/")[0],
|
|
417
|
+
bookmark: t.view.camera.split("/")[1],
|
|
418
|
+
duration: t.view.duration,
|
|
419
|
+
frames: t.view.frames,
|
|
420
|
+
loop: !!t.view.loop,
|
|
421
|
+
reverse: !!t.view.reverse,
|
|
422
|
+
...e.renderParameters(t),
|
|
423
|
+
...e.encoderParameters(t)
|
|
424
|
+
}, r = e.buildQuery(n);
|
|
425
|
+
return Promise.resolve(`${this.server}/ImagesFromAnimation?${r}`);
|
|
426
|
+
}
|
|
427
|
+
async vrCube(t, n) {
|
|
428
|
+
let r = {
|
|
429
|
+
...e.sceneParameters(t),
|
|
430
|
+
bookmarkSet: t.view.camera.split("/")[0],
|
|
431
|
+
bookmark: t.view.camera.split("/")[1],
|
|
432
|
+
...e.renderParameters(t),
|
|
433
|
+
...e.encoderParameters(t)
|
|
434
|
+
};
|
|
435
|
+
r.width = Math.max(r.width, r.height), r.height = Math.max(r.width, r.height);
|
|
436
|
+
let i = e.buildQuery(r);
|
|
437
|
+
return e.fetch(`${this.server}/CubeFromBookmark?${i}`, n);
|
|
438
|
+
}
|
|
439
|
+
async vrObject(t, n) {
|
|
440
|
+
let r = {
|
|
441
|
+
...e.sceneParameters(t),
|
|
442
|
+
bookmarkSet: t.view.camera,
|
|
443
|
+
...e.renderParameters(t),
|
|
444
|
+
...e.encoderParameters(t)
|
|
445
|
+
}, i = e.buildQuery(r);
|
|
446
|
+
return e.fetch(`${this.server}/ImagesFromBookmarkSet?${i}`, n);
|
|
447
|
+
}
|
|
448
|
+
}, h = class e {
|
|
449
|
+
constructor(e) {
|
|
450
|
+
this.server = e;
|
|
451
|
+
}
|
|
452
|
+
static scene(e) {
|
|
453
|
+
return e.scene.map((e) => {
|
|
454
|
+
let { accessory: t, decor: n, ...r } = e;
|
|
455
|
+
return r;
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
static renderParameters(e) {
|
|
459
|
+
return {
|
|
460
|
+
...e.parameters,
|
|
461
|
+
superSampling: e.parameters.superSampling.toString()
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
static encoder(e) {
|
|
465
|
+
switch (e.encoder.format) {
|
|
466
|
+
case "jpeg": return { jpeg: { quality: e.encoder.quality } };
|
|
467
|
+
case "png": return { png: { compression: e.encoder.compression } };
|
|
468
|
+
case "webp": return { webp: { quality: e.encoder.quality } };
|
|
469
|
+
}
|
|
470
|
+
return { jpeg: { quality: 80 } };
|
|
471
|
+
}
|
|
472
|
+
static async fetchFrame(e, t, n) {
|
|
473
|
+
return fetch(e, {
|
|
474
|
+
method: "POST",
|
|
475
|
+
body: JSON.stringify(t),
|
|
476
|
+
signal: n
|
|
477
|
+
}).then((e) => e.json()).then((e) => e.url);
|
|
478
|
+
}
|
|
479
|
+
static async fetchFrameArray(e, t, n) {
|
|
480
|
+
return fetch(e, {
|
|
481
|
+
method: "POST",
|
|
482
|
+
body: JSON.stringify(t),
|
|
483
|
+
signal: n
|
|
484
|
+
}).then((e) => e.json()).then((e) => e.map((e) => e.url));
|
|
485
|
+
}
|
|
486
|
+
static async fetchHotspots(e, t) {
|
|
487
|
+
return fetch(e, {
|
|
488
|
+
method: "POST",
|
|
489
|
+
body: JSON.stringify(t)
|
|
490
|
+
}).then((e) => e.json());
|
|
491
|
+
}
|
|
492
|
+
static async fetchHotspotsArray(e, t) {
|
|
493
|
+
return fetch(e, {
|
|
494
|
+
method: "POST",
|
|
495
|
+
body: JSON.stringify(t)
|
|
496
|
+
}).then((e) => e.json());
|
|
497
|
+
}
|
|
498
|
+
static async fetchPick(e, t) {
|
|
499
|
+
return fetch(e, {
|
|
500
|
+
method: "POST",
|
|
501
|
+
body: JSON.stringify(t)
|
|
502
|
+
}).then((e) => e.json()).then((e) => e[0]);
|
|
503
|
+
}
|
|
504
|
+
async database(e) {
|
|
505
|
+
return fetch(`${this.server}/Database?databaseId=${e}`).then((e) => e.text()).then((e) => new p(new DOMParser().parseFromString(e, "application/xml")));
|
|
506
|
+
}
|
|
507
|
+
async image(t, n) {
|
|
508
|
+
let r = {
|
|
509
|
+
scene: e.scene(t),
|
|
510
|
+
mode: { image: { camera: t.view.camera } },
|
|
511
|
+
renderParameters: e.renderParameters(t),
|
|
512
|
+
encoder: e.encoder(t)
|
|
513
|
+
};
|
|
514
|
+
return e.fetchFrame(`${this.server}/Snapshot`, r, n);
|
|
515
|
+
}
|
|
516
|
+
async vrCube(t, n) {
|
|
517
|
+
let r = {
|
|
518
|
+
scene: e.scene(t),
|
|
519
|
+
mode: { vrCube: { camera: t.view.camera } },
|
|
520
|
+
renderParameters: e.renderParameters(t),
|
|
521
|
+
encoder: e.encoder(t)
|
|
522
|
+
};
|
|
523
|
+
return r.renderParameters.width = Math.max(r.renderParameters.width, r.renderParameters.height), r.renderParameters.height = Math.max(r.renderParameters.width, r.renderParameters.height), e.fetchFrameArray(`${this.server}/Snapshot`, r, n);
|
|
524
|
+
}
|
|
525
|
+
async vrObject(t, n) {
|
|
526
|
+
let r;
|
|
527
|
+
r = t.view.cameraGroup ? { images: { cameraGroup: t.view.cameraGroup } } : t.view.frames ? { vrObject: {
|
|
528
|
+
camera: t.view.camera,
|
|
529
|
+
frames: t.view.frames
|
|
530
|
+
} } : { vrObject: {
|
|
531
|
+
camera: t.view.camera,
|
|
532
|
+
panFrames: t.view.panFrames || 1,
|
|
533
|
+
panFrom: t.view.panFrom || 0,
|
|
534
|
+
panTo: t.view.panTo || 0,
|
|
535
|
+
panLoop: t.view.panLoop || !1,
|
|
536
|
+
tiltFrames: t.view.tiltFrames || 1,
|
|
537
|
+
tiltFrom: t.view.tiltFrom || 0,
|
|
538
|
+
tiltTo: t.view.tiltTo || 0,
|
|
539
|
+
tiltLoop: t.view.tiltLoop || !1
|
|
540
|
+
} };
|
|
541
|
+
let i = {
|
|
542
|
+
scene: e.scene(t),
|
|
543
|
+
mode: r,
|
|
544
|
+
renderParameters: e.renderParameters(t),
|
|
545
|
+
encoder: e.encoder(t)
|
|
546
|
+
};
|
|
547
|
+
return e.fetchFrameArray(`${this.server}/Snapshot`, i, n);
|
|
548
|
+
}
|
|
549
|
+
async animation(t, n) {
|
|
550
|
+
let r = {
|
|
551
|
+
scene: e.scene(t),
|
|
552
|
+
mode: { animation: {
|
|
553
|
+
id: t.view.animation,
|
|
554
|
+
camera: t.view.camera,
|
|
555
|
+
fps: t.view.fps
|
|
556
|
+
} },
|
|
557
|
+
renderParameters: e.renderParameters(t),
|
|
558
|
+
encoder: e.encoder(t)
|
|
559
|
+
};
|
|
560
|
+
return e.fetchFrameArray(`${this.server}/Snapshot`, r, n);
|
|
561
|
+
}
|
|
562
|
+
async imageHotspots(t, n) {
|
|
563
|
+
let r = {
|
|
564
|
+
scene: e.scene(t),
|
|
565
|
+
mode: { image: { camera: t.view.camera } },
|
|
566
|
+
renderParameters: e.renderParameters(t),
|
|
567
|
+
...this.hotspotsBody(n)
|
|
568
|
+
};
|
|
569
|
+
return await e.fetchHotspots(`${this.server}/Hotspot`, r);
|
|
570
|
+
}
|
|
571
|
+
async imagePick(t, n) {
|
|
572
|
+
let r = {
|
|
573
|
+
scene: e.scene(t),
|
|
574
|
+
camera: t.view.camera,
|
|
575
|
+
renderParameters: e.renderParameters(t),
|
|
576
|
+
positions: [n]
|
|
577
|
+
};
|
|
578
|
+
return await e.fetchPick(`${this.server}/Pick`, r);
|
|
579
|
+
}
|
|
580
|
+
async vrCubeHotspots(t, n) {
|
|
581
|
+
let r = {
|
|
582
|
+
scene: e.scene(t),
|
|
583
|
+
mode: { vrCube: { camera: t.view.camera } },
|
|
584
|
+
renderParameters: e.renderParameters(t),
|
|
585
|
+
...this.hotspotsBody(n)
|
|
586
|
+
};
|
|
587
|
+
return r.renderParameters.width = Math.max(r.renderParameters.width, r.renderParameters.height), r.renderParameters.height = Math.max(r.renderParameters.width, r.renderParameters.height), await e.fetchHotspotsArray(`${this.server}/Hotspot`, r);
|
|
588
|
+
}
|
|
589
|
+
async vrObjectHotspots(t, n) {
|
|
590
|
+
let r;
|
|
591
|
+
r = t.view.cameraGroup ? { images: { cameraGroup: t.view.cameraGroup } } : t.view.frames ? { vrObject: {
|
|
592
|
+
camera: t.view.camera,
|
|
593
|
+
frames: t.view.frames
|
|
594
|
+
} } : { vrObject: {
|
|
595
|
+
camera: t.view.camera,
|
|
596
|
+
panFrames: t.view.panFrames || 1,
|
|
597
|
+
panFrom: t.view.panFrom || 0,
|
|
598
|
+
panTo: t.view.panTo || 0,
|
|
599
|
+
panLoop: t.view.panLoop || !1,
|
|
600
|
+
tiltFrames: t.view.tiltFrames || 1,
|
|
601
|
+
tiltFrom: t.view.tiltFrom || 0,
|
|
602
|
+
tiltTo: t.view.tiltTo || 0,
|
|
603
|
+
tiltLoop: t.view.tiltLoop || !1
|
|
604
|
+
} };
|
|
605
|
+
let i = {
|
|
606
|
+
scene: e.scene(t),
|
|
607
|
+
mode: r,
|
|
608
|
+
renderParameters: e.renderParameters(t),
|
|
609
|
+
...this.hotspotsBody(n)
|
|
610
|
+
};
|
|
611
|
+
return await e.fetchHotspotsArray(`${this.server}/Hotspot`, i);
|
|
612
|
+
}
|
|
613
|
+
hotspotsBody(e) {
|
|
614
|
+
return {
|
|
615
|
+
positions: e.every((e) => typeof e != "string") ? e : void 0,
|
|
616
|
+
tags: e.every((e) => typeof e == "string") ? e : void 0
|
|
617
|
+
};
|
|
618
|
+
}
|
|
619
|
+
}, g = class e {
|
|
620
|
+
constructor(e, t, n) {
|
|
621
|
+
switch (t) {
|
|
622
|
+
case "static":
|
|
623
|
+
this.webrender = new f();
|
|
624
|
+
break;
|
|
625
|
+
case "v1":
|
|
626
|
+
this.webrender = new m(e), this.webrenderV2 = new h(e);
|
|
627
|
+
break;
|
|
628
|
+
case "v2":
|
|
629
|
+
this.webrender = new h(e), this.webrenderV2 = new h(e);
|
|
630
|
+
break;
|
|
631
|
+
default: this.webrender = new m(e), this.webrenderV2 = new h(e);
|
|
632
|
+
}
|
|
633
|
+
this.delegate = n, this.controller = new AbortController(), this.loaded = 0, this.total = 0, this.databases = [], this.onLoadStart = n && n.onLoadStart ? n.onLoadStart : () => {}, this.onLoadProgress = n && n.onLoadProgress ? n.onLoadProgress : () => {}, this.onLoadEnd = n && n.onLoadEnd ? n.onLoadEnd : () => {};
|
|
634
|
+
}
|
|
635
|
+
get progress() {
|
|
636
|
+
return this.total ? this.loaded / this.total : 0;
|
|
637
|
+
}
|
|
638
|
+
renew() {
|
|
639
|
+
return this.controller.abort(), this.controller = new AbortController(), this.controller.signal;
|
|
640
|
+
}
|
|
641
|
+
async loadImageSnapshot(e) {
|
|
642
|
+
let t = this.renew();
|
|
643
|
+
return this.loaded = 0, this.total = 1, this.onLoadStart(this.progress), this.webrender.image(e, t).then((e) => this.loadImage(e, t)).then((e) => (this.onLoadEnd(this.progress), e));
|
|
644
|
+
}
|
|
645
|
+
async loadVideoSnapshot(e, t) {
|
|
646
|
+
let n = this.renew();
|
|
647
|
+
return this.loaded = 0, this.total = 1, this.onLoadStart(this.progress), this.webrender.video(t).then((r) => this.loadVideo(e, r, !!t.view.loop, n)).then(() => (this.onLoadEnd(this.progress), e));
|
|
648
|
+
}
|
|
649
|
+
async loadVRCubeSnapshot(e) {
|
|
650
|
+
let t = this.renew();
|
|
651
|
+
return this.loaded = 0, this.total = 0, this.onLoadStart(this.progress), this.webrender.vrCube(e, t).then((e) => {
|
|
652
|
+
this.total = e.length;
|
|
653
|
+
let n = e.map((e) => this.loadImage(e, t));
|
|
654
|
+
return Promise.all(n);
|
|
655
|
+
}).then((e) => (this.onLoadEnd(this.progress), e));
|
|
656
|
+
}
|
|
657
|
+
async loadVRObjectSnapshot(e, t) {
|
|
658
|
+
let n = this.renew();
|
|
659
|
+
return this.loaded = 0, this.total = 0, this.onLoadStart(this.progress), e.view.animation ? e.encoder?.format === "mp4" ? this.webrender.video(e).then((t) => this.loadVideoFrames(t, e.view.frames, 30, n)) : this.webrender.animation(e, n).then((r) => this.loadImageFrames(r, e.view.loop, t, n)) : this.webrender.vrObject(e, n).then((r) => this.loadImageFrames(r, e.view.loop, t, n));
|
|
660
|
+
}
|
|
661
|
+
async loadImage(t, n) {
|
|
662
|
+
let r = new Image();
|
|
663
|
+
r.crossOrigin = location.protocol === "file:" && !e.isValidHttpUrl(t) ? null : "anonymous";
|
|
664
|
+
let i = new Promise((e, i) => {
|
|
665
|
+
let a = () => {
|
|
666
|
+
r.src = "", i(new DOMException("Image load aborted", "AbortError"));
|
|
667
|
+
};
|
|
668
|
+
if (n.aborted) {
|
|
669
|
+
a();
|
|
670
|
+
return;
|
|
671
|
+
}
|
|
672
|
+
r.addEventListener("load", () => {
|
|
673
|
+
n.removeEventListener("abort", a), this.loaded += 1, this.onLoadProgress(this.progress), e(r);
|
|
674
|
+
}, { once: !0 }), r.addEventListener("error", (e) => {
|
|
675
|
+
n.removeEventListener("abort", a), i(`${e.type} : ${t}`);
|
|
676
|
+
}, { once: !0 }), n.addEventListener("abort", a, { once: !0 });
|
|
677
|
+
});
|
|
678
|
+
return r.src = t, i;
|
|
679
|
+
}
|
|
680
|
+
loadImageFrames(e, t, n, r) {
|
|
681
|
+
this.total = e.length;
|
|
682
|
+
let i = Array(e.length), a = n || 0;
|
|
683
|
+
for (let n = 0, o = e.length; n < o; n += 1) {
|
|
684
|
+
let s = Math.ceil(n / 2) * (n % 2 == 0 ? 1 : -1), c = t ? l.mod(a + s, o) : n;
|
|
685
|
+
i[c] = this.loadImage(e[c], r);
|
|
686
|
+
}
|
|
687
|
+
return Promise.all(i).then(() => this.onLoadEnd(this.progress)).catch((e) => {
|
|
688
|
+
e instanceof DOMException && e.name === "AbortError" || this.onLoadEnd(this.progress);
|
|
689
|
+
}), i;
|
|
690
|
+
}
|
|
691
|
+
async loadVideo(e, t, n, r) {
|
|
692
|
+
e.loop = n;
|
|
693
|
+
let i = new Promise((n, i) => {
|
|
694
|
+
let a = () => {
|
|
695
|
+
e.removeAttribute("src"), e.load(), i(new DOMException("Video load aborted", "AbortError"));
|
|
696
|
+
};
|
|
697
|
+
if (r.aborted) {
|
|
698
|
+
a();
|
|
699
|
+
return;
|
|
700
|
+
}
|
|
701
|
+
e.addEventListener("canplaythrough", () => {
|
|
702
|
+
r.removeEventListener("abort", a), this.loaded += 1, this.onLoadProgress(this.progress), n();
|
|
703
|
+
}, { once: !0 }), e.addEventListener("error", (e) => {
|
|
704
|
+
r.removeEventListener("abort", a), i(`${e.type} : ${t}`);
|
|
705
|
+
}, { once: !0 }), r.addEventListener("abort", a, { once: !0 });
|
|
706
|
+
});
|
|
707
|
+
return e.src = t, e.load(), i;
|
|
708
|
+
}
|
|
709
|
+
async loadVideoFrame(e, t, n, r, i) {
|
|
710
|
+
let a = 0;
|
|
711
|
+
return new Promise((o, s) => {
|
|
712
|
+
let c = () => {
|
|
713
|
+
if (i.aborted) return;
|
|
714
|
+
if (a !== r) {
|
|
715
|
+
a += 1;
|
|
716
|
+
return;
|
|
717
|
+
}
|
|
718
|
+
e.removeEventListener("seeked", c), e.removeEventListener("error", l), i.removeEventListener("abort", u);
|
|
719
|
+
let s = document.createElement("canvas");
|
|
720
|
+
s.width = e.videoWidth, s.height = e.videoHeight, s.getContext("2d").drawImage(e, 0, 0);
|
|
721
|
+
let d = new Image();
|
|
722
|
+
d.src = s.toDataURL(), o(d), this.loaded += 1, this.onLoadProgress(this.progress), r !== n - 1 && (e.currentTime += 1 / t);
|
|
723
|
+
}, l = (e) => {
|
|
724
|
+
i.removeEventListener("abort", u), s(e);
|
|
725
|
+
}, u = () => {
|
|
726
|
+
e.removeEventListener("seeked", c), e.removeEventListener("error", l), s(new DOMException("Video frame load aborted", "AbortError"));
|
|
727
|
+
};
|
|
728
|
+
if (i.aborted) {
|
|
729
|
+
u();
|
|
730
|
+
return;
|
|
731
|
+
}
|
|
732
|
+
e.addEventListener("seeked", c), e.addEventListener("error", l, { once: !0 }), i.addEventListener("abort", u, { once: !0 });
|
|
733
|
+
});
|
|
734
|
+
}
|
|
735
|
+
loadVideoFrames(e, t, n, r) {
|
|
736
|
+
this.total = t;
|
|
737
|
+
let i = Array(t), a = document.createElement("video");
|
|
738
|
+
for (let e = 0, o = t; e < o; e += 1) i[e] = this.loadVideoFrame(a, n, t, e, r);
|
|
739
|
+
return a.addEventListener("canplaythrough", () => {
|
|
740
|
+
r.aborted || (a.currentTime = 1 / n / 2);
|
|
741
|
+
}, { once: !0 }), r.addEventListener("abort", () => {
|
|
742
|
+
a.removeAttribute("src"), a.load();
|
|
743
|
+
}, { once: !0 }), a.src = e, a.load(), Promise.all(i).then(() => this.onLoadEnd(this.progress)).catch((e) => {
|
|
744
|
+
e instanceof DOMException && e.name === "AbortError" || this.onLoadEnd(this.progress);
|
|
745
|
+
}), i;
|
|
746
|
+
}
|
|
747
|
+
async loadImageHotspots(e, t) {
|
|
748
|
+
return this.webrenderV2 ? await this.webrenderV2.imageHotspots(await this.convert(e), t) : Promise.reject(/* @__PURE__ */ Error("Hotspots only available with api V2"));
|
|
749
|
+
}
|
|
750
|
+
async loadVRCubeHotspots(e, t) {
|
|
751
|
+
return this.webrenderV2 ? await this.webrenderV2.vrCubeHotspots(await this.convert(e), t) : Promise.reject(/* @__PURE__ */ Error("Hotspots only available with api V2"));
|
|
752
|
+
}
|
|
753
|
+
async loadVRObjectHotspots(e, t) {
|
|
754
|
+
return this.webrenderV2 ? await this.webrenderV2.vrObjectHotspots(await this.convert(e), t) : Promise.reject(/* @__PURE__ */ Error("Hotspots only available with api V2"));
|
|
755
|
+
}
|
|
756
|
+
async loadImagePick(e, t) {
|
|
757
|
+
return this.webrenderV2 ? await this.webrenderV2.imagePick(await this.convert(e), t) : Promise.reject(/* @__PURE__ */ Error("Picking only available with api V2"));
|
|
758
|
+
}
|
|
759
|
+
async loadVRObjectPick(e, t, n, r) {
|
|
760
|
+
return this.webrenderV2 ? await this.webrenderV2.imagePick(await this.vrObjectFrameSnapshot(e, n, r), t) : Promise.reject(/* @__PURE__ */ Error("Picking only available with api V2"));
|
|
761
|
+
}
|
|
762
|
+
async loadVRCubePick(e, t, n) {
|
|
763
|
+
return this.webrenderV2 ? await this.webrenderV2.imagePick(await this.vrCubeFrameSnapshot(e, n), t) : Promise.reject(/* @__PURE__ */ Error("Picking only available with api V2"));
|
|
764
|
+
}
|
|
765
|
+
async convert(e) {
|
|
766
|
+
if (!this.webrenderV2 || this.webrender instanceof h || !e.view.camera) return e;
|
|
767
|
+
let t = e.scene.find((e) => !e.decor && !e.accessory);
|
|
768
|
+
if (!t) return e;
|
|
769
|
+
let n = this.databases.find((e) => e.id === t.database);
|
|
770
|
+
(!n || !n.xmlDoc) && (n = await this.webrender.database(t.database), this.databases.push(n));
|
|
771
|
+
let r = e.view.camera.split("/"), i = r.length === 2 ? r[0] : void 0, a = r.length === 2 ? r[1] : r[0], o = n.getCameraId(a, i);
|
|
772
|
+
if (o) return {
|
|
773
|
+
...e,
|
|
774
|
+
view: {
|
|
775
|
+
...e.view,
|
|
776
|
+
camera: o
|
|
777
|
+
}
|
|
778
|
+
};
|
|
779
|
+
{
|
|
780
|
+
let t = n.getCameraGroupId(a);
|
|
781
|
+
return t ? {
|
|
782
|
+
...e,
|
|
783
|
+
view: {
|
|
784
|
+
...e.view,
|
|
785
|
+
cameraGroup: t
|
|
786
|
+
}
|
|
787
|
+
} : e;
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
async vrObjectFrameSnapshot(e, t, n) {
|
|
791
|
+
if (!this.webrenderV2) return e;
|
|
792
|
+
let r = e.scene.find((e) => !e.decor && !e.accessory);
|
|
793
|
+
if (!r) return e;
|
|
794
|
+
let i = this.databases.find((e) => e.id === r.database);
|
|
795
|
+
if (i || (i = await this.webrender.database(r.database), this.databases.push(i)), this.webrender instanceof m) {
|
|
796
|
+
if (!e.view.camera) return e;
|
|
797
|
+
let n = i.getCameraGroupId(e.view.camera);
|
|
798
|
+
if (!n) return e;
|
|
799
|
+
let r = i.getCameraGroupById(n);
|
|
800
|
+
if (!r) return e;
|
|
801
|
+
let a = r.cameras[t];
|
|
802
|
+
return a ? {
|
|
803
|
+
...e,
|
|
804
|
+
view: {
|
|
805
|
+
...e.view,
|
|
806
|
+
camera: a.id
|
|
807
|
+
}
|
|
808
|
+
} : e;
|
|
809
|
+
}
|
|
810
|
+
if (this.webrender instanceof h) {
|
|
811
|
+
let r = typeof e.view.camera == "string" ? e.view.camera : e.view.camera?.id;
|
|
812
|
+
if (r) {
|
|
813
|
+
let a = i.getCameraById(r);
|
|
814
|
+
if (!a) return e;
|
|
815
|
+
let o = new d(a.pointOfView), s = 2 * Math.PI / n;
|
|
816
|
+
o.longitude += t * s % (2 * Math.PI);
|
|
817
|
+
let c = o.pointOfView(a.pointOfView.target);
|
|
818
|
+
return {
|
|
819
|
+
...e,
|
|
820
|
+
view: {
|
|
821
|
+
...e.view,
|
|
822
|
+
camera: {
|
|
823
|
+
id: a.id,
|
|
824
|
+
pov: {
|
|
825
|
+
target: {
|
|
826
|
+
x: c.target[0],
|
|
827
|
+
y: c.target[1],
|
|
828
|
+
z: c.target[2]
|
|
829
|
+
},
|
|
830
|
+
eye: {
|
|
831
|
+
x: c.eye[0],
|
|
832
|
+
y: c.eye[1],
|
|
833
|
+
z: c.eye[2]
|
|
834
|
+
},
|
|
835
|
+
up: {
|
|
836
|
+
x: c.up[0],
|
|
837
|
+
y: c.up[1],
|
|
838
|
+
z: c.up[2]
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
};
|
|
844
|
+
}
|
|
845
|
+
if (e.view.cameraGroup) {
|
|
846
|
+
let n = i.getCameraGroupById(e.view.cameraGroup);
|
|
847
|
+
if (!n) return e;
|
|
848
|
+
let r = n.cameras[t];
|
|
849
|
+
return r ? {
|
|
850
|
+
...e,
|
|
851
|
+
view: {
|
|
852
|
+
...e.view,
|
|
853
|
+
camera: r.id
|
|
854
|
+
}
|
|
855
|
+
} : e;
|
|
856
|
+
}
|
|
857
|
+
return e;
|
|
858
|
+
}
|
|
859
|
+
return e;
|
|
860
|
+
}
|
|
861
|
+
async vrCubeFrameSnapshot(e, t) {
|
|
862
|
+
let n = e.scene.find((e) => !e.decor && !e.accessory);
|
|
863
|
+
if (!n) return e;
|
|
864
|
+
let r = this.databases.find((e) => e.id === n.database);
|
|
865
|
+
if (r || (r = await this.webrender.database(n.database), this.databases.push(r)), !e.view.camera) return e;
|
|
866
|
+
let i;
|
|
867
|
+
if (this.webrender instanceof m) {
|
|
868
|
+
let t = e.view.camera.split("/"), n = t.length === 2 ? t[0] : void 0, a = t.length === 2 ? t[1] : t[0];
|
|
869
|
+
i = r.getCameraId(a, n);
|
|
870
|
+
} else this.webrender instanceof h && (i = typeof e.view.camera == "string" ? e.view.camera : e.view.camera.id);
|
|
871
|
+
if (!i) return e;
|
|
872
|
+
let a = r.getCameraById(i);
|
|
873
|
+
if (!a) return e;
|
|
874
|
+
let o = u.initCubeFace(a.pointOfView.eye, a.pointOfView.target, t);
|
|
875
|
+
return {
|
|
876
|
+
...e,
|
|
877
|
+
view: {
|
|
878
|
+
...e.view,
|
|
879
|
+
camera: {
|
|
880
|
+
id: a.id,
|
|
881
|
+
pov: {
|
|
882
|
+
target: {
|
|
883
|
+
x: o.target[0],
|
|
884
|
+
y: o.target[1],
|
|
885
|
+
z: o.target[2]
|
|
886
|
+
},
|
|
887
|
+
eye: {
|
|
888
|
+
x: o.eye[0],
|
|
889
|
+
y: o.eye[1],
|
|
890
|
+
z: o.eye[2]
|
|
891
|
+
},
|
|
892
|
+
up: {
|
|
893
|
+
x: o.up[0],
|
|
894
|
+
y: o.up[1],
|
|
895
|
+
z: o.up[2]
|
|
896
|
+
}
|
|
897
|
+
},
|
|
898
|
+
lens: { fov: 90 }
|
|
899
|
+
}
|
|
900
|
+
},
|
|
901
|
+
parameters: {
|
|
902
|
+
...e.parameters,
|
|
903
|
+
width: Math.max(e.parameters.width, e.parameters.height),
|
|
904
|
+
height: Math.max(e.parameters.width, e.parameters.height)
|
|
905
|
+
}
|
|
906
|
+
};
|
|
907
|
+
}
|
|
908
|
+
onLoadStart(e) {
|
|
909
|
+
this.delegate && this.delegate.onLoadStart(e);
|
|
910
|
+
}
|
|
911
|
+
onLoadProgress(e) {
|
|
912
|
+
this.delegate && this.delegate.onLoadProgress(e);
|
|
913
|
+
}
|
|
914
|
+
onLoadEnd(e) {
|
|
915
|
+
this.delegate && this.delegate.onLoadEnd(e);
|
|
916
|
+
}
|
|
917
|
+
static isValidHttpUrl(e) {
|
|
918
|
+
let t;
|
|
919
|
+
try {
|
|
920
|
+
t = new URL(e);
|
|
921
|
+
} catch {
|
|
922
|
+
return !1;
|
|
923
|
+
}
|
|
924
|
+
return t.protocol === "http:" || t.protocol === "https:";
|
|
925
|
+
}
|
|
926
|
+
}, _ = class {
|
|
927
|
+
constructor() {
|
|
928
|
+
this.element = document.createElement("video"), this.element.classList.add("ls-viewer-video"), this.element.style.opacity = "0", this.element.width = 0, this.element.height = 0, this.element.setAttribute("muted", ""), this.element.setAttribute("playsinline", ""), this.element.setAttribute("preload", "auto");
|
|
929
|
+
}
|
|
930
|
+
show() {
|
|
931
|
+
this.element.style.opacity = "1";
|
|
932
|
+
}
|
|
933
|
+
hide() {
|
|
934
|
+
this.element.style.opacity = "0";
|
|
935
|
+
}
|
|
936
|
+
resize(e, t, n, r) {
|
|
937
|
+
let i = o.fit(n, new a(e, t), r);
|
|
938
|
+
this.element.style.top = `${i.top}px`, this.element.style.left = `${i.left}px`, this.element.style.width = `${i.width}px`, this.element.style.height = `${i.height}px`, (n.width !== this.element.width || n.height !== this.element.height) && (this.element.width = n.width, this.element.height = n.height);
|
|
939
|
+
}
|
|
940
|
+
}, v = class {
|
|
941
|
+
constructor(e, t, n) {
|
|
942
|
+
this.container = e, this.canvas = t, this.loader = n, this.hotspotList = [];
|
|
943
|
+
}
|
|
944
|
+
destroy() {}
|
|
945
|
+
show() {
|
|
946
|
+
this.canvas.show(!1), this.container.classList.add("ls-viewer-container-image");
|
|
947
|
+
}
|
|
948
|
+
hide() {
|
|
949
|
+
this.canvas.hide(!1), this.container.classList.remove("ls-viewer-container-image");
|
|
950
|
+
}
|
|
951
|
+
async load(e, t, n, r) {
|
|
952
|
+
let i = Promise.resolve(), a = JSON.stringify(e);
|
|
953
|
+
i = a === this.snapshotHash && this.image ? i.then(() => this.canvas.draw(this.image, r, .05)) : i.then(() => this.loader.loadImageSnapshot(e).then((e) => {
|
|
954
|
+
this.canvas.draw(e, r, .05), this.image = e;
|
|
955
|
+
}));
|
|
956
|
+
let o = JSON.stringify(t);
|
|
957
|
+
return (a !== this.snapshotHash || o !== this.hotspotsHash) && (t.length ? i = i.then(() => this.loader.loadImageHotspots(e, t).then((e) => {
|
|
958
|
+
this.hotspotList = e;
|
|
959
|
+
})) : this.hotspotList = []), this.hotspotsHash = o, this.snapshotHash = a, i;
|
|
960
|
+
}
|
|
961
|
+
async pick(e, t) {
|
|
962
|
+
let n = new a(e.parameters.width, e.parameters.height), r = o.unproject(n, this.canvas.resolution, this.canvas.fit, t);
|
|
963
|
+
return this.loader.loadImagePick(e, r);
|
|
964
|
+
}
|
|
965
|
+
hotspots(e) {
|
|
966
|
+
return this.hotspotList.map((t) => ({
|
|
967
|
+
...t,
|
|
968
|
+
position2D: o.project(e, this.canvas.resolution, this.canvas.fit, t.position2D)
|
|
969
|
+
})).map((e) => ({
|
|
970
|
+
...e,
|
|
971
|
+
visibility: o.contains(this.canvas.resolution, e.position2D) ? e.visibility : "OutOfFrustum"
|
|
972
|
+
}));
|
|
973
|
+
}
|
|
974
|
+
snapshot(e, t) {
|
|
975
|
+
return this.canvas.element.toDataURL(e, t);
|
|
976
|
+
}
|
|
977
|
+
onPointerDown(e) {}
|
|
978
|
+
onPointerMove(e) {}
|
|
979
|
+
onPointerUp(e) {}
|
|
980
|
+
onPointerCancel(e) {}
|
|
981
|
+
onDeviceOrientation(e) {}
|
|
982
|
+
}, y = class {
|
|
983
|
+
constructor(...e) {
|
|
984
|
+
e.length === 3 ? ({0: this.u, 1: this.v, 2: this.o} = e, this.w = r.cross(this.u, this.v)) : e.length === 4 ? {0: this.u, 1: this.v, 2: this.w, 3: this.o} = e : (this.u = [
|
|
985
|
+
1,
|
|
986
|
+
0,
|
|
987
|
+
0
|
|
988
|
+
], this.v = [
|
|
989
|
+
0,
|
|
990
|
+
1,
|
|
991
|
+
0
|
|
992
|
+
], this.w = [
|
|
993
|
+
0,
|
|
994
|
+
0,
|
|
995
|
+
1
|
|
996
|
+
], this.o = [
|
|
997
|
+
0,
|
|
998
|
+
0,
|
|
999
|
+
0
|
|
1000
|
+
]);
|
|
1001
|
+
}
|
|
1002
|
+
get localToGlobalMatrix() {
|
|
1003
|
+
let e = [
|
|
1004
|
+
this.u[0],
|
|
1005
|
+
this.u[1],
|
|
1006
|
+
this.u[2],
|
|
1007
|
+
0
|
|
1008
|
+
], t = [
|
|
1009
|
+
this.v[0],
|
|
1010
|
+
this.v[1],
|
|
1011
|
+
this.v[2],
|
|
1012
|
+
0
|
|
1013
|
+
], n = [
|
|
1014
|
+
this.w[0],
|
|
1015
|
+
this.w[1],
|
|
1016
|
+
this.w[2],
|
|
1017
|
+
0
|
|
1018
|
+
], r = [
|
|
1019
|
+
this.o[0],
|
|
1020
|
+
this.o[1],
|
|
1021
|
+
this.o[2],
|
|
1022
|
+
1
|
|
1023
|
+
];
|
|
1024
|
+
return [
|
|
1025
|
+
...e,
|
|
1026
|
+
...t,
|
|
1027
|
+
...n,
|
|
1028
|
+
...r
|
|
1029
|
+
];
|
|
1030
|
+
}
|
|
1031
|
+
get globalToLocalMatrix() {
|
|
1032
|
+
return n.inverse(this.localToGlobalMatrix);
|
|
1033
|
+
}
|
|
1034
|
+
}, b = class {
|
|
1035
|
+
constructor(e, t, n) {
|
|
1036
|
+
this.x = e, this.y = t, this.time = n;
|
|
1037
|
+
}
|
|
1038
|
+
}, x = class e {
|
|
1039
|
+
constructor(e, t) {
|
|
1040
|
+
this.x = e, this.y = t;
|
|
1041
|
+
}
|
|
1042
|
+
clone() {
|
|
1043
|
+
return new e(this.x, this.y);
|
|
1044
|
+
}
|
|
1045
|
+
}, S = class {
|
|
1046
|
+
constructor(e) {
|
|
1047
|
+
this.loop = () => {
|
|
1048
|
+
if (Math.abs(this.velocity.x) < 1 && Math.abs(this.velocity.y) < 1) {
|
|
1049
|
+
this.animationFrameId = void 0, this.points = [];
|
|
1050
|
+
return;
|
|
1051
|
+
}
|
|
1052
|
+
this.lastPoint.x += this.velocity.x, this.lastPoint.y += this.velocity.y, this.velocity.x *= .9, this.velocity.y *= .9, this.onMotion(this.lastPoint.clone()), this.animationFrameId = requestAnimationFrame(this.loop);
|
|
1053
|
+
}, this.points = [], this.onMotion = e, this.lastPoint = new x(0, 0), this.velocity = new x(0, 0);
|
|
1054
|
+
}
|
|
1055
|
+
destroy() {
|
|
1056
|
+
this.animationFrameId &&= (cancelAnimationFrame(this.animationFrameId), void 0);
|
|
1057
|
+
}
|
|
1058
|
+
track(e) {
|
|
1059
|
+
let t = Date.now();
|
|
1060
|
+
this.points = this.points.filter((e) => t - e.time <= 100), this.points.push(new b(e.x, e.y, t)), this.lastPoint = e;
|
|
1061
|
+
}
|
|
1062
|
+
start() {
|
|
1063
|
+
if (this.points.length === 0) return;
|
|
1064
|
+
let e = this.points[0], t = this.points[this.points.length - 1], n = t.x - e.x, r = t.y - e.y, i = t.time - e.time;
|
|
1065
|
+
this.velocity = new x(i === 0 ? 0 : n / (i / 15), i === 0 ? 0 : r / (i / 15)), this.animationFrameId &&= (cancelAnimationFrame(this.animationFrameId), void 0), this.animationFrameId = requestAnimationFrame(this.loop);
|
|
1066
|
+
}
|
|
1067
|
+
stop() {
|
|
1068
|
+
this.animationFrameId &&= (cancelAnimationFrame(this.animationFrameId), void 0), this.points = [];
|
|
1069
|
+
}
|
|
1070
|
+
}, C = class {
|
|
1071
|
+
constructor(e, t, i) {
|
|
1072
|
+
this.motion = (e) => {
|
|
1073
|
+
this.isStarted && this.inertia.track(e);
|
|
1074
|
+
let t = {
|
|
1075
|
+
x: e.x - this.previousPoint.x,
|
|
1076
|
+
y: e.y - this.previousPoint.y
|
|
1077
|
+
}, i = l.accelerate(t.x, 1.3) / this.startSize.width * .2 * Math.PI * 1.5, a = l.accelerate(t.y, 1.3) / this.startSize.height * .2 * Math.PI, o = n.multiply(n.rotationY(i), n.rotationX(-a)), s = new y(r.normalize(r.cross(this.pov.up, this.pov.target)), [
|
|
1078
|
+
0,
|
|
1079
|
+
1,
|
|
1080
|
+
0
|
|
1081
|
+
], this.pov.eye), c = n.identity();
|
|
1082
|
+
n.multiply(c, s.localToGlobalMatrix, c), n.multiply(c, o, c), n.multiply(c, s.globalToLocalMatrix, c);
|
|
1083
|
+
let u = n.transformPoint(c, this.pov.target), d = n.transformDirection(c, this.pov.up);
|
|
1084
|
+
r.cross(d, [
|
|
1085
|
+
0,
|
|
1086
|
+
0,
|
|
1087
|
+
1
|
|
1088
|
+
])[0] >= 0 && (this.pov.target = u, this.pov.up = d), this.previousPoint = e, this.onMotion();
|
|
1089
|
+
}, this.isStarted = !1, this.pov = e, this.fov = l.degreesToRadians(t), this.orientationMatrix = n.identity(), this.inertia = new S(this.motion), this.onMotion = i, this.initPov = this.pov, this.initFov = this.fov, this.initOrientation = l.degreesToRadians(window.orientation) || 0, this.startPov = new u([
|
|
1090
|
+
0,
|
|
1091
|
+
0,
|
|
1092
|
+
1
|
|
1093
|
+
], [
|
|
1094
|
+
0,
|
|
1095
|
+
0,
|
|
1096
|
+
0
|
|
1097
|
+
], [
|
|
1098
|
+
0,
|
|
1099
|
+
1,
|
|
1100
|
+
0
|
|
1101
|
+
]), this.startSize = {
|
|
1102
|
+
width: 0,
|
|
1103
|
+
height: 0
|
|
1104
|
+
}, this.previousPoint = new x(0, 0);
|
|
1105
|
+
}
|
|
1106
|
+
destroy() {
|
|
1107
|
+
this.inertia.destroy();
|
|
1108
|
+
}
|
|
1109
|
+
get orientedPov() {
|
|
1110
|
+
let e = new y(r.normalize(r.cross(this.pov.up, this.pov.target)), [
|
|
1111
|
+
0,
|
|
1112
|
+
1,
|
|
1113
|
+
0
|
|
1114
|
+
], this.pov.eye), t = n.identity();
|
|
1115
|
+
n.multiply(t, e.localToGlobalMatrix, t), n.multiply(t, this.orientationMatrix, t), n.multiply(t, e.globalToLocalMatrix, t);
|
|
1116
|
+
let i = n.transformDirection(t, this.pov.target), a = this.pov.eye;
|
|
1117
|
+
return new u(i, a, n.transformDirection(t, this.pov.up));
|
|
1118
|
+
}
|
|
1119
|
+
reset() {
|
|
1120
|
+
this.pov = this.initPov.clone(), this.fov = this.initFov;
|
|
1121
|
+
}
|
|
1122
|
+
start(e, t) {
|
|
1123
|
+
this.isStarted = !0, this.startPov = this.pov, this.startSize = t, this.previousPoint = e, this.inertia.stop();
|
|
1124
|
+
}
|
|
1125
|
+
end(e, t) {
|
|
1126
|
+
this.isStarted = !1, t && (this.inertia.track(e), this.inertia.start());
|
|
1127
|
+
}
|
|
1128
|
+
orientation(e, t, r) {
|
|
1129
|
+
let i = l.degreesToRadians(window.orientation) || 0, a = l.degreesToRadians(e), o = l.degreesToRadians(-t), s = l.degreesToRadians(-r), c = n.rotationX(l.degreesToRadians(90));
|
|
1130
|
+
n.rotateZ(c, this.initOrientation, c), n.rotateZ(c, a, c), n.rotateX(c, o, c), n.rotateY(c, s, c), n.rotateZ(c, -i, c), this.orientationMatrix = c, this.onMotion();
|
|
1131
|
+
}
|
|
1132
|
+
}, w = "precision mediump float;\n\nuniform float u_mix;\nuniform samplerCube u_texture;\nuniform samplerCube u_texture_back;\n\nvarying vec3 direction;\n\nvoid main() {\n vec4 backColor = textureCube(u_texture_back, direction);\n vec4 color = textureCube(u_texture, direction);\n gl_FragColor = mix(backColor, color, u_mix);\n}", T = "attribute vec4 position;\n\nuniform mat4 u_mvpi;\n\nvarying vec3 direction;\n\nvoid main() {\n direction = (u_mvpi * position).xyz;\n gl_Position = position;\n}", E = class {
|
|
1133
|
+
constructor(e, r, i, a, o) {
|
|
1134
|
+
this.render = () => {
|
|
1135
|
+
this.gl.viewport(0, 0, this.gl.canvas.width, this.gl.canvas.height), this.uniforms.u_mvpi = n.inverse(this.modelViewProjectionMatrix), this.gl.useProgram(this.programInfo.program), t.setBuffersAndAttributes(this.gl, this.programInfo, this.quad), t.setUniforms(this.programInfo, this.uniforms), t.drawBufferInfo(this.gl, this.quad), this.uniforms.u_mix < 1 && (this.uniforms.u_mix = Math.min(this.uniforms.u_mix + .05, 1), this.animationFrameId = requestAnimationFrame(this.render));
|
|
1136
|
+
}, this.container = e, this.canvas = r, this.loader = i, this.aspectRatioOverride = o, this.images = [], this.hotspotsList = [[]];
|
|
1137
|
+
let s = new u([
|
|
1138
|
+
0,
|
|
1139
|
+
0,
|
|
1140
|
+
1
|
|
1141
|
+
], [
|
|
1142
|
+
0,
|
|
1143
|
+
0,
|
|
1144
|
+
0
|
|
1145
|
+
], [
|
|
1146
|
+
0,
|
|
1147
|
+
1,
|
|
1148
|
+
0
|
|
1149
|
+
]), c = n.rotationX(l.degreesToRadians(15));
|
|
1150
|
+
n.transformDirection(c, s.target, s.target), n.transformDirection(c, s.up, s.up), this.interaction = new C(s, 60, () => {
|
|
1151
|
+
this.animationFrameId = requestAnimationFrame(this.render), this.onInteraction({
|
|
1152
|
+
pov: this.interaction.pov.clone(),
|
|
1153
|
+
fov: this.interaction.fov
|
|
1154
|
+
});
|
|
1155
|
+
}), this.onInteraction = a, this.gl = this.canvas.context, this.programInfo = t.createProgramInfo(this.gl, [`${T}\n`, `${w}\n`]), this.quad = t.primitives.createXYQuadBufferInfo(this.gl), this.uniforms = {
|
|
1156
|
+
u_mvpi: n.identity(),
|
|
1157
|
+
u_mix: 0,
|
|
1158
|
+
u_texture_back: t.createTexture(this.gl, {
|
|
1159
|
+
target: this.gl.TEXTURE_CUBE_MAP,
|
|
1160
|
+
minMag: this.gl.LINEAR,
|
|
1161
|
+
width: 1,
|
|
1162
|
+
height: 1
|
|
1163
|
+
}),
|
|
1164
|
+
u_texture: t.createTexture(this.gl, {
|
|
1165
|
+
target: this.gl.TEXTURE_CUBE_MAP,
|
|
1166
|
+
minMag: this.gl.LINEAR,
|
|
1167
|
+
width: 1,
|
|
1168
|
+
height: 1
|
|
1169
|
+
})
|
|
1170
|
+
};
|
|
1171
|
+
}
|
|
1172
|
+
destroy() {
|
|
1173
|
+
this.interaction.destroy(), this.animationFrameId &&= (cancelAnimationFrame(this.animationFrameId), void 0);
|
|
1174
|
+
}
|
|
1175
|
+
show() {
|
|
1176
|
+
this.canvas.show(), this.container.classList.add("ls-viewer-container-vrcube");
|
|
1177
|
+
}
|
|
1178
|
+
hide() {
|
|
1179
|
+
this.canvas.hide(), this.container.classList.remove("ls-viewer-container-vrcube");
|
|
1180
|
+
}
|
|
1181
|
+
get pov() {
|
|
1182
|
+
return this.interaction.pov;
|
|
1183
|
+
}
|
|
1184
|
+
set pov(e) {
|
|
1185
|
+
this.interaction.pov.eye.every((t, n) => t === e.eye[n]) && this.interaction.pov.target.every((t, n) => t === e.target[n]) && this.interaction.pov.up.every((t, n) => t === e.up[n]) || (this.interaction.pov = e.clone(), this.animationFrameId = requestAnimationFrame(this.render));
|
|
1186
|
+
}
|
|
1187
|
+
get fov() {
|
|
1188
|
+
return l.radiansToDegrees(this.interaction.fov);
|
|
1189
|
+
}
|
|
1190
|
+
set fov(e) {
|
|
1191
|
+
this.interaction.fov !== e && (this.interaction.fov = l.degreesToRadians(e), this.animationFrameId = requestAnimationFrame(this.render));
|
|
1192
|
+
}
|
|
1193
|
+
async load(e, n, r, i) {
|
|
1194
|
+
let a = Promise.resolve();
|
|
1195
|
+
{
|
|
1196
|
+
let t = this.gl.getExtension("WEBGL_debug_renderer_info");
|
|
1197
|
+
t && navigator.platform === "MacIntel" && navigator.userAgent.includes("Chrome") && this.gl.getParameter(t.UNMASKED_RENDERER_WEBGL).includes("OpenGL") && (e.parameters.width = Math.min(e.parameters.width, 1812), e.parameters.height = Math.min(e.parameters.height, 1812));
|
|
1198
|
+
}
|
|
1199
|
+
let o = JSON.stringify(e);
|
|
1200
|
+
o === this.snapshotHash ? a = a.then(() => (this.animationFrameId = requestAnimationFrame(this.render), Promise.resolve())) : (this.images = [], this.animationFrameId = requestAnimationFrame(this.render), a = a.then(() => this.loader.loadVRCubeSnapshot(e).then((e) => {
|
|
1201
|
+
this.images = e, t.createTexture(this.gl, {
|
|
1202
|
+
target: this.gl.TEXTURE_CUBE_MAP,
|
|
1203
|
+
min: this.gl.LINEAR_MIPMAP_LINEAR,
|
|
1204
|
+
minMag: this.gl.LINEAR,
|
|
1205
|
+
cubeFaceOrder: [
|
|
1206
|
+
this.gl.TEXTURE_CUBE_MAP_POSITIVE_Z,
|
|
1207
|
+
this.gl.TEXTURE_CUBE_MAP_POSITIVE_X,
|
|
1208
|
+
this.gl.TEXTURE_CUBE_MAP_NEGATIVE_Z,
|
|
1209
|
+
this.gl.TEXTURE_CUBE_MAP_NEGATIVE_X,
|
|
1210
|
+
this.gl.TEXTURE_CUBE_MAP_POSITIVE_Y,
|
|
1211
|
+
this.gl.TEXTURE_CUBE_MAP_NEGATIVE_Y
|
|
1212
|
+
],
|
|
1213
|
+
src: e
|
|
1214
|
+
}, (e, t) => {
|
|
1215
|
+
e || (r && this.interaction.reset(), this.uniforms.u_mix = +!i, this.uniforms.u_texture_back = this.uniforms.u_texture, this.uniforms.u_texture = t, this.animationFrameId = requestAnimationFrame(this.render));
|
|
1216
|
+
});
|
|
1217
|
+
})));
|
|
1218
|
+
let s = JSON.stringify(n);
|
|
1219
|
+
return (o !== this.snapshotHash || s !== this.hotspotsHash) && (n.length ? a = a.then(() => this.loader.loadVRCubeHotspots(e, n).then((e) => {
|
|
1220
|
+
this.hotspotsList = e;
|
|
1221
|
+
})) : this.hotspotsList = [[]]), this.hotspotsHash = s, this.snapshotHash = o, a;
|
|
1222
|
+
}
|
|
1223
|
+
async pick(e, t) {
|
|
1224
|
+
let i = this.canvas.element.clientWidth, a = this.canvas.element.clientHeight, o = t.x, s = a - t.y, c = [
|
|
1225
|
+
2 * o / i - 1,
|
|
1226
|
+
2 * s / a - 1,
|
|
1227
|
+
0
|
|
1228
|
+
], l = this.modelViewProjectionMatrix, u = n.inverse(l), d = r.normalize(n.transformPoint(u, c)), f = Math.max(Math.abs(d[0]), Math.abs(d[1]), Math.abs(d[2])), p;
|
|
1229
|
+
p = Math.abs(d[0]) === f ? d[0] > 0 ? "XPOS" : "XNEG" : Math.abs(d[1]) === f ? d[1] > 0 ? "YPOS" : "YNEG" : d[2] > 0 ? "ZPOS" : "ZNEG";
|
|
1230
|
+
let m = 0, h = 0, g = "";
|
|
1231
|
+
switch (p) {
|
|
1232
|
+
case "XPOS":
|
|
1233
|
+
m = (-d[2] / Math.abs(d[0]) + 1) / 2, h = (-d[1] / Math.abs(d[0]) + 1) / 2, g = "right";
|
|
1234
|
+
break;
|
|
1235
|
+
case "XNEG":
|
|
1236
|
+
m = (d[2] / Math.abs(d[0]) + 1) / 2, h = (-d[1] / Math.abs(d[0]) + 1) / 2, g = "left";
|
|
1237
|
+
break;
|
|
1238
|
+
case "YPOS":
|
|
1239
|
+
m = (d[0] / Math.abs(d[1]) + 1) / 2, h = (d[2] / Math.abs(d[1]) + 1) / 2, g = "up";
|
|
1240
|
+
break;
|
|
1241
|
+
case "YNEG":
|
|
1242
|
+
m = (d[0] / Math.abs(d[1]) + 1) / 2, h = (-d[2] / Math.abs(d[1]) + 1) / 2, g = "down";
|
|
1243
|
+
break;
|
|
1244
|
+
case "ZPOS":
|
|
1245
|
+
m = (d[0] / Math.abs(d[2]) + 1) / 2, h = (-d[1] / Math.abs(d[2]) + 1) / 2, g = "front";
|
|
1246
|
+
break;
|
|
1247
|
+
case "ZNEG": m = (-d[0] / Math.abs(d[2]) + 1) / 2, h = (-d[1] / Math.abs(d[2]) + 1) / 2, g = "back";
|
|
1248
|
+
}
|
|
1249
|
+
let _ = {
|
|
1250
|
+
x: Math.round(m * Math.max(e.parameters.width, e.parameters.height)),
|
|
1251
|
+
y: Math.round(h * Math.max(e.parameters.width, e.parameters.height))
|
|
1252
|
+
};
|
|
1253
|
+
return this.loader.loadVRCubePick(e, _, g);
|
|
1254
|
+
}
|
|
1255
|
+
hotspots() {
|
|
1256
|
+
let e = [];
|
|
1257
|
+
if (this.hotspotsList.length === 0) return [];
|
|
1258
|
+
let t = this.hotspotsList[0]?.length ?? 0, i = this.modelViewProjectionMatrix;
|
|
1259
|
+
for (let s = 0; s < t; s++) {
|
|
1260
|
+
let t = this.hotspotsList.findIndex((e) => e[s].visibility !== "OutOfFrustum");
|
|
1261
|
+
if (t === -1) continue;
|
|
1262
|
+
let c = { ...this.hotspotsList[t][s] }, l = c.position2D.x / this.images[0].width, u = c.position2D.y / this.images[0].height, d = 0, f = 0, p = 0;
|
|
1263
|
+
switch (t) {
|
|
1264
|
+
case 0:
|
|
1265
|
+
this.pov.target[2] < 0 && (c.visibility = "OutOfFrustum"), d = 2 * l - 1, f = 1 - 2 * u, p = 1;
|
|
1266
|
+
break;
|
|
1267
|
+
case 1:
|
|
1268
|
+
this.pov.target[0] > 0 && (c.visibility = "OutOfFrustum"), d = 1, f = 1 - 2 * u, p = 1 - 2 * l;
|
|
1269
|
+
break;
|
|
1270
|
+
case 2:
|
|
1271
|
+
this.pov.target[2] > 0 && (c.visibility = "OutOfFrustum"), d = 1 - 2 * l, f = 1 - 2 * u, p = -1;
|
|
1272
|
+
break;
|
|
1273
|
+
case 3:
|
|
1274
|
+
this.pov.target[0] < 0 && (c.visibility = "OutOfFrustum"), d = -1, f = 1 - 2 * u, p = 2 * l - 1;
|
|
1275
|
+
break;
|
|
1276
|
+
case 4:
|
|
1277
|
+
this.pov.target[1] < 0 && (c.visibility = "OutOfFrustum"), d = 2 * l - 1, f = 1, p = 2 * u - 1;
|
|
1278
|
+
break;
|
|
1279
|
+
case 5: this.pov.target[1] > 0 && (c.visibility = "OutOfFrustum"), d = 2 * l - 1, f = -1, p = 1 - 2 * u;
|
|
1280
|
+
}
|
|
1281
|
+
let m = r.normalize([
|
|
1282
|
+
d,
|
|
1283
|
+
f,
|
|
1284
|
+
p
|
|
1285
|
+
]), h = n.transformPoint(i, m), g = this.canvas.element.clientWidth, _ = this.canvas.element.clientHeight, v = .5 * g * (h[0] + 1), y = .5 * _ * (h[1] + 1), b = {
|
|
1286
|
+
x: Math.round(v),
|
|
1287
|
+
y: Math.round(_ - y)
|
|
1288
|
+
}, x = new a(g, _), S = o.contains(x, b) ? c.visibility : "OutOfFrustum";
|
|
1289
|
+
e.push({
|
|
1290
|
+
...c,
|
|
1291
|
+
position2D: b,
|
|
1292
|
+
visibility: S
|
|
1293
|
+
});
|
|
1294
|
+
}
|
|
1295
|
+
return e;
|
|
1296
|
+
}
|
|
1297
|
+
snapshot(e, t) {
|
|
1298
|
+
return this.canvas.element.toDataURL(e, t);
|
|
1299
|
+
}
|
|
1300
|
+
get modelViewProjectionMatrix() {
|
|
1301
|
+
let e = this.canvas.element.clientWidth, t = this.canvas.element.clientHeight, r = e > t ? e / t : t / e, i = o.getStandardAspectRatio(e, t, this.aspectRatioOverride), a = this.interaction.fov * (i / r), s = n.setAxis(n.identity(), [
|
|
1302
|
+
-1,
|
|
1303
|
+
0,
|
|
1304
|
+
0
|
|
1305
|
+
], 0), c = e > t ? l.perspectiveWithFovY(a, e / t, .5, 100) : l.perspectiveWithFovX(a, e / t, .5, 100), u = this.interaction.orientedPov, d = n.inverse(n.lookAt(u.eye, u.target, u.up));
|
|
1306
|
+
return n.multiply(n.multiply(c, d), s);
|
|
1307
|
+
}
|
|
1308
|
+
onPointerDown(e) {
|
|
1309
|
+
this.container.setPointerCapture(e.pointerId), this.container.classList.add("ls-viewer-container-vrcube-grabbing"), this.interaction.start(new x(e.screenX, e.screenY), {
|
|
1310
|
+
width: this.gl.canvas.width,
|
|
1311
|
+
height: this.gl.canvas.height
|
|
1312
|
+
});
|
|
1313
|
+
}
|
|
1314
|
+
onPointerMove(e) {
|
|
1315
|
+
this.interaction.isStarted && (this.interaction.motion(new x(e.screenX, e.screenY)), e.preventDefault());
|
|
1316
|
+
}
|
|
1317
|
+
onPointerUp(e) {
|
|
1318
|
+
this.interaction.isStarted && (this.container.classList.remove("ls-viewer-container-vrcube-grabbing"), this.interaction.end(new x(e.screenX, e.screenY), !0));
|
|
1319
|
+
}
|
|
1320
|
+
onPointerCancel(e) {
|
|
1321
|
+
this.interaction.isStarted && (this.container.classList.remove("ls-viewer-container-vrcube-grabbing"), this.interaction.end(new x(e.screenX, e.screenY), !1));
|
|
1322
|
+
}
|
|
1323
|
+
onDeviceOrientation(e) {
|
|
1324
|
+
this.interaction.orientation(e.alpha, e.beta, e.gamma);
|
|
1325
|
+
}
|
|
1326
|
+
}, D = class {
|
|
1327
|
+
constructor(e, t, n, r, a) {
|
|
1328
|
+
this.motion = (e) => {
|
|
1329
|
+
this.isStarted && this.inertia.track(e), this.lastPoints.push({
|
|
1330
|
+
x: e.x,
|
|
1331
|
+
y: e.y
|
|
1332
|
+
}), this.lastPoints.splice(0, this.lastPoints.length - this.lastPointsNumber);
|
|
1333
|
+
let t = i.linear(this.lastPoints.map((e) => [e.x, e.y]));
|
|
1334
|
+
if (Math.abs(t.equation[0]) < 1) {
|
|
1335
|
+
let t = l.accelerate(e.x - this.startPoint.x, 1.3) / this.startSize.width * (this.frames / 4), n = this.startPosition.x - Math.round(t);
|
|
1336
|
+
n = this.loop ? l.mod(n, this.frames) : Math.max(0, Math.min(n, this.frames - 1)), n !== this.position.x && (this.position.x = n, this.onMotion());
|
|
1337
|
+
let r = Math.min(...this.lastPoints.map((e) => e.x));
|
|
1338
|
+
Math.max(...this.lastPoints.map((e) => e.x)) - r > 25 && (this.startPoint.y = e.y, this.startPosition.y = this.position.y);
|
|
1339
|
+
} else {
|
|
1340
|
+
let t = l.accelerate(e.y - this.startPoint.y, 1.7) / this.startSize.height * (this.rows / 4), n = this.startPosition.y + Math.round(t);
|
|
1341
|
+
n = Math.max(0, Math.min(n, this.rows - 1)), n !== this.position.y && (this.position.y = n, this.onMotion());
|
|
1342
|
+
let r = Math.min(...this.lastPoints.map((e) => e.y));
|
|
1343
|
+
Math.max(...this.lastPoints.map((e) => e.y)) - r > 25 && (this.startPoint.x = e.x, this.startPosition.x = this.position.x);
|
|
1344
|
+
}
|
|
1345
|
+
}, this.isStarted = !1, this.position = e, this.frames = t, this.rows = n, this.loop = r, this.onMotion = a, this.inertia = new S(this.motion), this.initPosition = { ...this.position }, this.startPosition = {
|
|
1346
|
+
x: 0,
|
|
1347
|
+
y: 0
|
|
1348
|
+
}, this.startPoint = new x(0, 0), this.startSize = {
|
|
1349
|
+
width: 0,
|
|
1350
|
+
height: 0
|
|
1351
|
+
}, this.lastPoints = [], this.lastPointsNumber = 20;
|
|
1352
|
+
}
|
|
1353
|
+
destroy() {
|
|
1354
|
+
this.inertia.destroy();
|
|
1355
|
+
}
|
|
1356
|
+
reset() {
|
|
1357
|
+
this.position = { ...this.initPosition };
|
|
1358
|
+
}
|
|
1359
|
+
get positionIndex() {
|
|
1360
|
+
return this.frames * this.position.y + this.position.x;
|
|
1361
|
+
}
|
|
1362
|
+
set positionIndex(e) {
|
|
1363
|
+
if (this.positionIndex === e) return;
|
|
1364
|
+
let t = this.loop ? l.mod(e, this.frames * this.rows) : Math.max(0, Math.min(e, this.frames * this.rows));
|
|
1365
|
+
this.position.x = l.mod(t, this.frames), this.position.y = Math.floor(t / this.frames);
|
|
1366
|
+
}
|
|
1367
|
+
start(e, t) {
|
|
1368
|
+
this.isStarted = !0, this.startPosition = { ...this.position }, this.startPoint = e, this.startSize = t, this.lastPoints = [], this.inertia.stop();
|
|
1369
|
+
}
|
|
1370
|
+
end(e, t) {
|
|
1371
|
+
this.isStarted = !1, t && (this.inertia.track(e), this.inertia.start());
|
|
1372
|
+
}
|
|
1373
|
+
}, O = class {
|
|
1374
|
+
constructor(e, t, n, r) {
|
|
1375
|
+
this.container = e, this.canvas = t, this.loader = n, this.images = [], this.frames = 24, this.hotspotsList = [[]], this.interaction = new D({
|
|
1376
|
+
x: 0,
|
|
1377
|
+
y: 0
|
|
1378
|
+
}, 1, 1, !1, () => {
|
|
1379
|
+
this.canvas.draw(this.image, !0, .5), this.onInteraction({ position: this.interaction.positionIndex });
|
|
1380
|
+
}), this.onInteraction = r;
|
|
1381
|
+
}
|
|
1382
|
+
destroy() {
|
|
1383
|
+
this.animationFrameId &&= (cancelAnimationFrame(this.animationFrameId), void 0);
|
|
1384
|
+
}
|
|
1385
|
+
show() {
|
|
1386
|
+
this.canvas.show(!1), this.container.classList.add("ls-viewer-container-vrobject");
|
|
1387
|
+
}
|
|
1388
|
+
hide() {
|
|
1389
|
+
this.canvas.hide(!1), this.container.classList.remove("ls-viewer-container-vrobject");
|
|
1390
|
+
}
|
|
1391
|
+
async goto(e) {
|
|
1392
|
+
return new Promise((t) => {
|
|
1393
|
+
let n = this.interaction.positionIndex, r = () => {
|
|
1394
|
+
if (this.interaction.positionIndex === e) t();
|
|
1395
|
+
else {
|
|
1396
|
+
let t = n > e ? -1 : 1;
|
|
1397
|
+
this.interaction.loop && this.interaction.frames - n + e < Math.abs(e - n) && (t *= -1), n += .5 * t, this.position = Math.floor(n), this.animationFrameId = requestAnimationFrame(r);
|
|
1398
|
+
}
|
|
1399
|
+
};
|
|
1400
|
+
this.animationFrameId = requestAnimationFrame(r);
|
|
1401
|
+
});
|
|
1402
|
+
}
|
|
1403
|
+
get position() {
|
|
1404
|
+
return this.interaction.positionIndex;
|
|
1405
|
+
}
|
|
1406
|
+
set position(e) {
|
|
1407
|
+
this.interaction.positionIndex = e, this.canvas.draw(this.image, !0, .5);
|
|
1408
|
+
}
|
|
1409
|
+
get image() {
|
|
1410
|
+
return this.images[this.interaction.positionIndex];
|
|
1411
|
+
}
|
|
1412
|
+
async load(e, t, n, r) {
|
|
1413
|
+
let i = Promise.resolve();
|
|
1414
|
+
n && this.interaction.reset();
|
|
1415
|
+
let a = JSON.stringify(e);
|
|
1416
|
+
a === this.snapshotHash && this.image ? i = i.then(() => this.canvas.draw(this.image, r, .05)) : (this.images = [], i = i.then(() => this.loader.loadVRObjectSnapshot(e, this.interaction.positionIndex).then((t) => {
|
|
1417
|
+
let i = t.length;
|
|
1418
|
+
return this.images = Array(i), this.interaction.frames = e.view.frames ?? e.view.panFrames ?? this.frames, this.interaction.rows = i / this.interaction.frames, this.interaction.loop = !!e.view.loop, n && this.interaction.reset(), t.forEach((e, t) => {
|
|
1419
|
+
e.then((e) => {
|
|
1420
|
+
this.images[t] = e, e === this.image && this.canvas.draw(this.image, r, .05);
|
|
1421
|
+
}).catch(() => {});
|
|
1422
|
+
}), t[this.interaction.positionIndex].then(() => Promise.resolve());
|
|
1423
|
+
})));
|
|
1424
|
+
let o = JSON.stringify(t);
|
|
1425
|
+
return (a !== this.snapshotHash || o !== this.hotspotsHash) && (t.length ? i = i.then(() => this.loader.loadVRObjectHotspots(e, t).then((e) => {
|
|
1426
|
+
this.hotspotsList = e;
|
|
1427
|
+
})) : this.hotspotsList = [[]]), this.hotspotsHash = o, this.snapshotHash = a, i;
|
|
1428
|
+
}
|
|
1429
|
+
async pick(e, t) {
|
|
1430
|
+
let n = new a(e.parameters.width, e.parameters.height), r = o.unproject(n, this.canvas.resolution, this.canvas.fit, t);
|
|
1431
|
+
return this.loader.loadVRObjectPick(e, r, this.position, this.frames);
|
|
1432
|
+
}
|
|
1433
|
+
hotspots(e) {
|
|
1434
|
+
return (this.hotspotsList[this.interaction.positionIndex] || []).map((t) => ({
|
|
1435
|
+
...t,
|
|
1436
|
+
position2D: o.project(e, this.canvas.resolution, this.canvas.fit, t.position2D)
|
|
1437
|
+
})).map((e) => ({
|
|
1438
|
+
...e,
|
|
1439
|
+
visibility: o.contains(this.canvas.resolution, e.position2D) ? e.visibility : "OutOfFrustum"
|
|
1440
|
+
}));
|
|
1441
|
+
}
|
|
1442
|
+
snapshot(e, t) {
|
|
1443
|
+
return this.canvas.element.toDataURL(e, t);
|
|
1444
|
+
}
|
|
1445
|
+
onPointerDown(e) {
|
|
1446
|
+
this.container.setPointerCapture(e.pointerId), this.container.classList.add("ls-viewer-container-vrobject-grabbing"), this.interaction.start(new x(e.screenX, e.screenY), {
|
|
1447
|
+
width: this.canvas.element.width,
|
|
1448
|
+
height: this.canvas.element.height
|
|
1449
|
+
});
|
|
1450
|
+
}
|
|
1451
|
+
onPointerMove(e) {
|
|
1452
|
+
this.interaction.isStarted && (this.interaction.motion(new x(e.screenX, e.screenY)), e.preventDefault());
|
|
1453
|
+
}
|
|
1454
|
+
onPointerUp(e) {
|
|
1455
|
+
this.interaction.isStarted && (this.container.classList.remove("ls-viewer-container-vrobject-grabbing"), this.interaction.end(new x(e.screenX, e.screenY), !0));
|
|
1456
|
+
}
|
|
1457
|
+
onPointerCancel(e) {
|
|
1458
|
+
this.interaction.isStarted && (this.container.classList.remove("ls-viewer-container-vrobject-grabbing"), this.interaction.end(new x(e.screenX, e.screenY), !1));
|
|
1459
|
+
}
|
|
1460
|
+
onDeviceOrientation(e) {}
|
|
1461
|
+
}, k = class {
|
|
1462
|
+
constructor(e, t, n) {
|
|
1463
|
+
this.container = e, this.loader = n, this.video = t;
|
|
1464
|
+
}
|
|
1465
|
+
destroy() {}
|
|
1466
|
+
show() {
|
|
1467
|
+
this.video.show(), this.container.classList.add("ls-viewer-container-video");
|
|
1468
|
+
}
|
|
1469
|
+
hide() {
|
|
1470
|
+
this.video.hide(), this.container.classList.remove("ls-viewer-container-video");
|
|
1471
|
+
}
|
|
1472
|
+
async load(e) {
|
|
1473
|
+
let t = JSON.stringify(e);
|
|
1474
|
+
return t === this.hash ? (this.video.element.load(), Promise.resolve()) : (this.hash = t, this.loader.loadVideoSnapshot(this.video.element, e));
|
|
1475
|
+
}
|
|
1476
|
+
async pick(e, t) {
|
|
1477
|
+
return Promise.reject();
|
|
1478
|
+
}
|
|
1479
|
+
hotspots(e) {
|
|
1480
|
+
return [];
|
|
1481
|
+
}
|
|
1482
|
+
snapshot(e, t) {
|
|
1483
|
+
return "data:image/gif;base64,R0lGODlhAQABAIAAAP7//wAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==";
|
|
1484
|
+
}
|
|
1485
|
+
async play() {
|
|
1486
|
+
return new Promise((e, t) => {
|
|
1487
|
+
this.video.element.addEventListener("ended", () => {
|
|
1488
|
+
e();
|
|
1489
|
+
}, { once: !0 }), this.video.element.play().catch(t), this.show();
|
|
1490
|
+
});
|
|
1491
|
+
}
|
|
1492
|
+
onPointerDown(e) {}
|
|
1493
|
+
onPointerMove(e) {}
|
|
1494
|
+
onPointerUp(e) {}
|
|
1495
|
+
onPointerCancel(e) {}
|
|
1496
|
+
onDeviceOrientation(e) {}
|
|
1497
|
+
}, A = class {
|
|
1498
|
+
constructor(t, n) {
|
|
1499
|
+
this.onPointerDown = (e) => {
|
|
1500
|
+
this.container.addEventListener("pointermove", this.onPointerMove, { passive: !1 }), this.widget.onPointerDown(e);
|
|
1501
|
+
}, this.onPointerMove = (e) => {
|
|
1502
|
+
this.widget.onPointerMove(e);
|
|
1503
|
+
}, this.onPointerUp = (e) => {
|
|
1504
|
+
this.container.removeEventListener("pointermove", this.onPointerMove), this.widget.onPointerUp(e);
|
|
1505
|
+
}, this.onPointerCancel = (e) => {
|
|
1506
|
+
this.container.removeEventListener("pointermove", this.onPointerMove), this.widget.onPointerCancel(e);
|
|
1507
|
+
}, this.onDeviceOrientation = (e) => {
|
|
1508
|
+
this.widget.onDeviceOrientation(e);
|
|
1509
|
+
}, this.onResize = () => {
|
|
1510
|
+
let e = this.container.clientWidth, t = this.container.clientHeight;
|
|
1511
|
+
this.options.autores && (this.resolution = o.getStandardResolution(e * window.devicePixelRatio, t * window.devicePixelRatio, this.aspectRatioOverride), this.parameters.width = this.resolution.width, this.parameters.height = this.resolution.height), this.canvas2D.resize(e, t, this.getCanvas2DPixelRatio(e, t)), this.canvas3D.resize(e, t, window.devicePixelRatio), this.video.resize(e, t, this.resolution, this.options.fit), this.loadWidget(!1, !1).then(() => {
|
|
1512
|
+
this.onHotspotsChange();
|
|
1513
|
+
}).catch((e) => {
|
|
1514
|
+
this.onLoadError(e);
|
|
1515
|
+
});
|
|
1516
|
+
}, this.onVrcubeInteraction = (e) => {
|
|
1517
|
+
this.onHotspotsChange(), this.options.events.onInteraction?.(e), this.options.events.onVrcubeInteraction?.(e);
|
|
1518
|
+
}, this.onVrobjectInteraction = (e) => {
|
|
1519
|
+
this.onHotspotsChange(), this.options.events.onInteraction?.(e.position), this.options.events.onVrobjectInteraction?.(e.position);
|
|
1520
|
+
}, this.onHotspotsChange = () => {
|
|
1521
|
+
let e = this.widget.hotspots(this.resolution);
|
|
1522
|
+
e.length && this.options.events.onHotspotsChange?.(e);
|
|
1523
|
+
}, this.onLoadStart = (e) => {
|
|
1524
|
+
this.container.classList.add("ls-viewer-container-loading"), this.options.events.onLoadStart?.(e);
|
|
1525
|
+
}, this.onLoadProgress = (e) => {
|
|
1526
|
+
this.options.events.onLoadProgress?.(e);
|
|
1527
|
+
}, this.onLoadEnd = (e) => {
|
|
1528
|
+
this.container.classList.remove("ls-viewer-container-loading"), this.options.events.onLoadEnd?.(e);
|
|
1529
|
+
}, this.onLoadError = (e) => {
|
|
1530
|
+
e instanceof DOMException && e.name === "AbortError" || (this.container.classList.remove("ls-viewer-container-loading"), this.options.events.onLoadError?.(e));
|
|
1531
|
+
}, this.options = {
|
|
1532
|
+
server: "localhost",
|
|
1533
|
+
api: "v1",
|
|
1534
|
+
autores: !0,
|
|
1535
|
+
fit: "cover",
|
|
1536
|
+
...n,
|
|
1537
|
+
events: { ...n.events }
|
|
1538
|
+
}, this.options.events.onLoadError && (this.options.events.onLoadError = e(this.options.events.onLoadError, 10)), this.container = t, this.container.classList.add("ls-viewer-container"), this.canvas2D = new s(this.options.fit), this.container.prepend(this.canvas2D.element), this.canvas3D = new c(), this.container.prepend(this.canvas3D.element), this.video = new _(), this.container.prepend(this.video.element), this.loader = new g(this.options.server, this.options.api, this), this.resolution = new a(0, 0), this.parameters = {
|
|
1539
|
+
width: 0,
|
|
1540
|
+
height: 0,
|
|
1541
|
+
antialiasing: !1,
|
|
1542
|
+
superSampling: 2
|
|
1543
|
+
}, this.encoder = {
|
|
1544
|
+
format: "jpeg",
|
|
1545
|
+
quality: 80
|
|
1546
|
+
}, this.hotspots = [], this.widgetImage = new v(t, this.canvas2D, this.loader), this.widgetVideo = new k(t, this.video, this.loader), this.widgetVRObject = new O(t, this.canvas2D, this.loader, this.onVrobjectInteraction), this.canvas3D.context && (this.widgetVRCube = new E(t, this.canvas3D, this.loader, this.onVrcubeInteraction, this.aspectRatioOverride)), this.widget = this.widgetImage, this.container.addEventListener("pointerdown", this.onPointerDown), this.container.addEventListener("pointerup", this.onPointerUp), this.container.addEventListener("pointercancel", this.onPointerCancel), this.loadWidget = e(this.loadWidget, 10), this.resizeObserver = new ResizeObserver(this.onResize), this.resizeObserver.observe(this.container);
|
|
1547
|
+
}
|
|
1548
|
+
destroy() {
|
|
1549
|
+
this.resizeObserver.disconnect(), this.canvas2D.destroy(), this.container.removeEventListener("pointerdown", this.onPointerDown), this.container.removeEventListener("pointerup", this.onPointerUp), this.container.removeEventListener("pointercancel", this.onPointerCancel), this.container.removeEventListener("pointermove", this.onPointerMove);
|
|
1550
|
+
}
|
|
1551
|
+
async load(e, t) {
|
|
1552
|
+
let n = Promise.resolve();
|
|
1553
|
+
return t?.animation && (n = n.then(() => this.loadAnimation(t.animation))), this.view && t?.fromPosition !== void 0 && this.viewWidget instanceof O && (this.view.mode, n = n.then(() => this.viewWidget.goto(t.fromPosition))), t?.animation && (n = n.then(() => this.widgetVideo.play())), n = n.then(() => (this.scene = Array.isArray(e) ? [...e] : [e], this.loadWidget(!1, !(t && t.animation)))), n.catch((e) => {
|
|
1554
|
+
this.onLoadError(e);
|
|
1555
|
+
}), n;
|
|
1556
|
+
}
|
|
1557
|
+
async setEncoder(e) {
|
|
1558
|
+
this.encoder = { ...e };
|
|
1559
|
+
let t = Promise.resolve();
|
|
1560
|
+
return t = t.then(() => this.loadWidget(!1, !0)), t.catch((e) => {
|
|
1561
|
+
this.onLoadError(e);
|
|
1562
|
+
}), t;
|
|
1563
|
+
}
|
|
1564
|
+
setParameters(e) {
|
|
1565
|
+
if (e.width && e.height) {
|
|
1566
|
+
this.resolution = new a(e.width, e.height);
|
|
1567
|
+
let t = this.container.clientWidth, n = this.container.clientHeight;
|
|
1568
|
+
this.canvas2D.resize(t, n, this.getCanvas2DPixelRatio(t, n));
|
|
1569
|
+
}
|
|
1570
|
+
this.parameters = { ...e }, this.parameters.width = this.resolution.width, this.parameters.height = this.resolution.height;
|
|
1571
|
+
let t = Promise.resolve();
|
|
1572
|
+
return t = t.then(() => this.loadWidget(!1, !0)), t.catch((e) => {
|
|
1573
|
+
this.onLoadError(e);
|
|
1574
|
+
}), t;
|
|
1575
|
+
}
|
|
1576
|
+
setHotspots(e) {
|
|
1577
|
+
this.hotspots = e, this.loadWidget(!1, !1);
|
|
1578
|
+
}
|
|
1579
|
+
async setView(e, t) {
|
|
1580
|
+
let n = Promise.resolve();
|
|
1581
|
+
return t?.animation && (n = n.then(() => this.loadAnimation(t.animation))), this.view && t?.fromPosition !== void 0 && this.viewWidget instanceof O && (n = n.then(() => this.viewWidget.goto(t.fromPosition))), t?.animation && (n = n.then(() => this.widgetVideo.play())), n = n.then(() => {
|
|
1582
|
+
let n = !0;
|
|
1583
|
+
return this.view = { ...e }, this.view && this.viewWidget instanceof O && t?.toPosition !== void 0 && (n = !1, this.viewWidget.position = t.toPosition), this.loadWidget(n, !(t && t.animation));
|
|
1584
|
+
}), n.catch((e) => {
|
|
1585
|
+
this.onLoadError(e);
|
|
1586
|
+
}), n;
|
|
1587
|
+
}
|
|
1588
|
+
setVrcube(e) {
|
|
1589
|
+
this.widgetVRCube && Object.assign(this.widgetVRCube, e);
|
|
1590
|
+
}
|
|
1591
|
+
setVrobject(e) {
|
|
1592
|
+
Object.assign(this.widgetVRObject, e);
|
|
1593
|
+
}
|
|
1594
|
+
async loadAnimation(e) {
|
|
1595
|
+
let t = {
|
|
1596
|
+
scene: this.scene,
|
|
1597
|
+
view: {
|
|
1598
|
+
animation: e.name,
|
|
1599
|
+
camera: e.camera,
|
|
1600
|
+
duration: e.duration,
|
|
1601
|
+
loop: e.loop,
|
|
1602
|
+
reverse: e.reverse
|
|
1603
|
+
},
|
|
1604
|
+
parameters: this.parameters,
|
|
1605
|
+
encoder: { format: "mp4" }
|
|
1606
|
+
};
|
|
1607
|
+
return t.view?.background || (t.view.background = "product"), this.widgetVideo.load(t).then(() => Promise.resolve());
|
|
1608
|
+
}
|
|
1609
|
+
async playAnimation(e) {
|
|
1610
|
+
return this.loadAnimation(e).then(() => this.widgetVideo.play()).catch((e) => {
|
|
1611
|
+
this.onLoadError(e);
|
|
1612
|
+
});
|
|
1613
|
+
}
|
|
1614
|
+
stopAnimation() {
|
|
1615
|
+
this.widgetVideo.hide();
|
|
1616
|
+
}
|
|
1617
|
+
async pick(e) {
|
|
1618
|
+
if (!this.scene) throw Error("No scene set");
|
|
1619
|
+
if (!this.view) throw Error("No view set");
|
|
1620
|
+
if (!this.view.camera && !this.view.cameraGroup) throw Error("No camera set");
|
|
1621
|
+
let t = {
|
|
1622
|
+
scene: this.scene,
|
|
1623
|
+
view: this.view,
|
|
1624
|
+
parameters: this.parameters,
|
|
1625
|
+
encoder: this.encoder
|
|
1626
|
+
};
|
|
1627
|
+
return await this.viewWidget.pick(t, e);
|
|
1628
|
+
}
|
|
1629
|
+
async pickHotspot(e) {
|
|
1630
|
+
let t = await this.pick(e), n = Object.values(t.point), i = r.normalize(Object.values(t.normal)), a = r.add(n, r.mulScalar(i, .01));
|
|
1631
|
+
return t.point = {
|
|
1632
|
+
x: a[0],
|
|
1633
|
+
y: a[1],
|
|
1634
|
+
z: a[2]
|
|
1635
|
+
}, t;
|
|
1636
|
+
}
|
|
1637
|
+
snapshot(e, t) {
|
|
1638
|
+
return this.viewWidget.snapshot(e, t);
|
|
1639
|
+
}
|
|
1640
|
+
async loadWidget(e, t) {
|
|
1641
|
+
if (!this.scene || !this.view || !this.parameters.width || !this.parameters.height) return Promise.resolve();
|
|
1642
|
+
let n = this.viewWidget;
|
|
1643
|
+
if (!n) return Promise.reject(/* @__PURE__ */ Error("Unknown view mode"));
|
|
1644
|
+
let r = {
|
|
1645
|
+
scene: this.scene,
|
|
1646
|
+
view: this.view,
|
|
1647
|
+
parameters: this.parameters,
|
|
1648
|
+
encoder: this.encoder
|
|
1649
|
+
};
|
|
1650
|
+
return r.view.background || (r.view.background = "product"), n.load(r, this.hotspots, e, t).then(() => {
|
|
1651
|
+
this.widget.hide(), this.widget = n, this.widget.show(), this.widgetVideo.hide(), this.onHotspotsChange();
|
|
1652
|
+
});
|
|
1653
|
+
}
|
|
1654
|
+
get aspectRatioOverride() {
|
|
1655
|
+
switch (this.options.aspectRatio) {
|
|
1656
|
+
case "4:3": return 4 / 3;
|
|
1657
|
+
case "16:9": return 16 / 9;
|
|
1658
|
+
default: return;
|
|
1659
|
+
}
|
|
1660
|
+
}
|
|
1661
|
+
get viewWidget() {
|
|
1662
|
+
switch (this.view?.mode) {
|
|
1663
|
+
case "image": return this.widgetImage;
|
|
1664
|
+
case "video": return this.widgetVideo;
|
|
1665
|
+
case "vrcube": return this.widgetVRCube ?? this.widgetImage;
|
|
1666
|
+
case "vrobject": return this.widgetVRObject;
|
|
1667
|
+
default: return this.widgetImage;
|
|
1668
|
+
}
|
|
1669
|
+
}
|
|
1670
|
+
getCanvas2DPixelRatio(e, t) {
|
|
1671
|
+
return e <= 0 || t <= 0 || this.resolution.width <= 0 || this.resolution.height <= 0 ? window.devicePixelRatio : Math.min(window.devicePixelRatio, this.resolution.width / e, this.resolution.height / t);
|
|
1672
|
+
}
|
|
1673
|
+
}, j;
|
|
1674
|
+
(function(e) {
|
|
1675
|
+
e.HotspotVisibility = /* @__PURE__ */ function(e) {
|
|
1676
|
+
return e.Visible = "Visible", e.Occluded = "Occluded", e.Clipped = "Clipped", e.OutOfFrustum = "OutOfFrustum", e;
|
|
1677
|
+
}({}), e.SunShadowQualityMode = /* @__PURE__ */ function(e) {
|
|
1678
|
+
return e.VeryLow = "veryLow", e.Low = "low", e.Medium = "medium", e.Fine = "fine", e.Ultra = "ultra", e;
|
|
1679
|
+
}({}), e.SunShadowSmoothnessMode = /* @__PURE__ */ function(e) {
|
|
1680
|
+
return e.None = "none", e.Weak = "weak", e.Normal = "normal", e.Fine = "fine", e.UltraFine = "ultraFine", e.Max = "max", e;
|
|
1681
|
+
}({}), e.SunUseCaseMode = /* @__PURE__ */ function(e) {
|
|
1682
|
+
return e.Manual = "manual", e.TimeAndLoc = "timeAndLoc", e.ExtractedFromEnv = "extractedFromEnv", e;
|
|
1683
|
+
}({}), e.SurfacesFilterMode = /* @__PURE__ */ function(e) {
|
|
1684
|
+
return e.ShowOnly = "showOnly", e.HideOnly = "hideOnly", e;
|
|
1685
|
+
}({});
|
|
1686
|
+
})(j ||= {});
|
|
1687
|
+
//#endregion
|
|
1688
|
+
export { A as Viewer, j as WRAPIv2, v as WidgetImage, E as WidgetVRCube, O as WidgetVRObject, k as WidgetVideo };
|