@lumiscaphe/viewer 4.1.16 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/index.cjs +2 -2
- package/dist/lib/index.d.ts +52 -12
- package/dist/lib/index.js +204 -203
- package/package.json +5 -4
package/dist/lib/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".ls-viewer-container{display:block;position:relative;overflow:hidden;-webkit-user-select:none;user-select:none;width:100%;height:100%}.ls-viewer-container-image,.ls-viewer-container-video{cursor:default;pointer-events:none}.ls-viewer-container-vrcube{cursor:pointer;cursor:grab}.ls-viewer-container-vrcube-grabbing{cursor:move;cursor:grabbing}.ls-viewer-container-vrobject{cursor:move;cursor:grab}.ls-viewer-container-vrobject-grabbing{cursor:move;cursor:grabbing}.ls-viewer-container-loading{cursor:progress}.ls-viewer-canvas{position:absolute;opacity:0;transition:opacity .5s}.ls-viewer-video{position:absolute}")),document.head.appendChild(e)}}catch(r){console.error("vite-plugin-css-injected-by-js",r)}})();
|
|
2
|
-
import
|
|
2
|
+
import C from "debounce-promise";
|
|
3
3
|
import * as P from "twgl.js";
|
|
4
4
|
import { v3 as h, m4 as c } from "twgl.js";
|
|
5
5
|
import $ from "regression";
|
|
@@ -20,34 +20,34 @@ class p {
|
|
|
20
20
|
}
|
|
21
21
|
static fit(t, e, i) {
|
|
22
22
|
const s = t.aspect, r = e.aspect;
|
|
23
|
-
let
|
|
23
|
+
let a = 0, n = 0;
|
|
24
24
|
switch (i) {
|
|
25
25
|
case "contain":
|
|
26
|
-
|
|
26
|
+
a = r < s ? e.width : e.height * s, n = r < s ? e.width / s : e.height;
|
|
27
27
|
break;
|
|
28
28
|
case "cover":
|
|
29
29
|
default:
|
|
30
|
-
|
|
30
|
+
a = r < s ? e.height * s : e.width, n = r < s ? e.height : e.width / s;
|
|
31
31
|
break;
|
|
32
32
|
case "fill":
|
|
33
|
-
|
|
33
|
+
a = e.width, n = e.height;
|
|
34
34
|
break;
|
|
35
35
|
}
|
|
36
|
-
const o = (e.height -
|
|
37
|
-
return new p(o,
|
|
36
|
+
const o = (e.height - n) / 2, u = (e.width - a) / 2;
|
|
37
|
+
return new p(o, u, a, n);
|
|
38
38
|
}
|
|
39
39
|
static project(t, e, i, s) {
|
|
40
|
-
const r = p.fit(t, e, i),
|
|
40
|
+
const r = p.fit(t, e, i), a = r.width / t.width, n = r.height / t.height;
|
|
41
41
|
return {
|
|
42
|
-
x: Math.round(r.left + s.x *
|
|
43
|
-
y: Math.round(r.top + s.y *
|
|
42
|
+
x: Math.round(r.left + s.x * a),
|
|
43
|
+
y: Math.round(r.top + s.y * n)
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
46
|
static unproject(t, e, i, s) {
|
|
47
|
-
const r = p.fit(t, e, i),
|
|
47
|
+
const r = p.fit(t, e, i), a = r.width / t.width, n = r.height / t.height;
|
|
48
48
|
return {
|
|
49
|
-
x: Math.round((s.x - r.left) /
|
|
50
|
-
y: Math.round((s.y - r.top) /
|
|
49
|
+
x: Math.round((s.x - r.left) / a),
|
|
50
|
+
y: Math.round((s.y - r.top) / n)
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
53
|
static getStandardAspectRatio(t, e) {
|
|
@@ -55,8 +55,8 @@ class p {
|
|
|
55
55
|
return 0;
|
|
56
56
|
const i = t / e;
|
|
57
57
|
if (t < e) {
|
|
58
|
-
const
|
|
59
|
-
return
|
|
58
|
+
const a = Math.abs(0.75 - i), n = Math.abs(9 / 16 - i);
|
|
59
|
+
return a < n ? 3 / 4 : 9 / 16;
|
|
60
60
|
}
|
|
61
61
|
const s = Math.abs(4 / 3 - i), r = Math.abs(16 / 9 - i);
|
|
62
62
|
return s < r ? 4 / 3 : 16 / 9;
|
|
@@ -73,7 +73,7 @@ class p {
|
|
|
73
73
|
return new b(Math.round(s * i), Math.round(s));
|
|
74
74
|
}
|
|
75
75
|
static getStandardQuality(t) {
|
|
76
|
-
return t <=
|
|
76
|
+
return t <= 720 ? 720 : 1080;
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
class U {
|
|
@@ -145,41 +145,41 @@ class w {
|
|
|
145
145
|
return t - e * Math.floor(t / e);
|
|
146
146
|
}
|
|
147
147
|
static perspectiveWithFovX(t, e, i, s, r) {
|
|
148
|
-
const
|
|
149
|
-
return this.perspectiveWithLeft(-
|
|
148
|
+
const a = Math.tan(t / 2), n = a / e;
|
|
149
|
+
return this.perspectiveWithLeft(-a, a, -n, n, i, s, r);
|
|
150
150
|
}
|
|
151
151
|
static perspectiveWithFovY(t, e, i, s, r) {
|
|
152
|
-
const
|
|
153
|
-
return this.perspectiveWithLeft(-
|
|
152
|
+
const a = i * Math.tan(t / 2), n = a * e;
|
|
153
|
+
return this.perspectiveWithLeft(-n, n, -a, a, i, s, r);
|
|
154
154
|
}
|
|
155
|
-
static perspectiveWithLeft(t, e, i, s, r,
|
|
156
|
-
|
|
157
|
-
const o = e + t,
|
|
158
|
-
return
|
|
155
|
+
static perspectiveWithLeft(t, e, i, s, r, a, n) {
|
|
156
|
+
n = n || new Float32Array(16);
|
|
157
|
+
const o = e + t, u = e - t, m = s + i, f = s - i, d = a - r;
|
|
158
|
+
return n[0] = 2 * r / u, n[1] = 0, n[2] = 0, n[3] = 0, n[4] = 0, n[5] = 2 * r / f, n[6] = 0, n[7] = 0, n[8] = o / u, n[9] = m / f, n[10] = -a / d, n[11] = -1, n[12] = 0, n[13] = 0, n[14] = -a * r / d, n[15] = 0, n;
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
161
|
const A = class A {
|
|
162
162
|
static initCubeFace(t, e, i) {
|
|
163
163
|
let s = [0, 0, 0];
|
|
164
|
-
const r = h.subtract(e, t),
|
|
164
|
+
const r = h.subtract(e, t), a = h.mulScalar([0, 1, 0], h.length(r)), n = h.mulScalar(h.normalize(h.cross(r, a)), h.length(r)), o = h.mulScalar(h.normalize(h.cross(a, n)), h.length(r));
|
|
165
165
|
switch (i) {
|
|
166
166
|
case "front":
|
|
167
|
-
e = h.add(t, o), s = h.normalize(
|
|
167
|
+
e = h.add(t, o), s = h.normalize(a);
|
|
168
168
|
break;
|
|
169
169
|
case "right":
|
|
170
|
-
e = h.add(t,
|
|
170
|
+
e = h.add(t, n), s = h.normalize(a);
|
|
171
171
|
break;
|
|
172
172
|
case "back":
|
|
173
|
-
e = h.subtract(t, o), s = h.normalize(
|
|
173
|
+
e = h.subtract(t, o), s = h.normalize(a);
|
|
174
174
|
break;
|
|
175
175
|
case "left":
|
|
176
|
-
e = h.subtract(t,
|
|
176
|
+
e = h.subtract(t, n), s = h.normalize(a);
|
|
177
177
|
break;
|
|
178
178
|
case "up":
|
|
179
|
-
e = h.add(t,
|
|
179
|
+
e = h.add(t, a), s = h.normalize(h.mulScalar(o, -1));
|
|
180
180
|
break;
|
|
181
181
|
case "down":
|
|
182
|
-
e = h.subtract(t,
|
|
182
|
+
e = h.subtract(t, a), s = h.normalize(o);
|
|
183
183
|
break;
|
|
184
184
|
}
|
|
185
185
|
return new A(e, t, s);
|
|
@@ -214,12 +214,12 @@ class B {
|
|
|
214
214
|
}
|
|
215
215
|
pointOfView(t) {
|
|
216
216
|
const e = c.rotationY(this.longitude), i = c.rotationX(-this.latitude), s = c.rotationZ(0), r = c.multiply(e, c.multiply(i, s));
|
|
217
|
-
let
|
|
218
|
-
n = c.transformPoint(r, n);
|
|
219
|
-
let a = [0, 1, 0];
|
|
217
|
+
let a = [0, 0, -1];
|
|
220
218
|
a = c.transformPoint(r, a);
|
|
221
|
-
|
|
222
|
-
|
|
219
|
+
let n = [0, 1, 0];
|
|
220
|
+
n = c.transformPoint(r, n);
|
|
221
|
+
const o = h.subtract(t, h.mulScalar(a, this.distance));
|
|
222
|
+
return new L(t, o, n);
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
225
|
class X {
|
|
@@ -315,7 +315,7 @@ const g = class g {
|
|
|
315
315
|
return Object.entries(t).filter(([e, i]) => i != null).map(([e, i]) => `${e}=${i}`).join("&");
|
|
316
316
|
}
|
|
317
317
|
static sceneParameters(t) {
|
|
318
|
-
const e = t.scene, i = e.length > 1 ? e.find((
|
|
318
|
+
const e = t.scene, i = e.length > 1 ? e.find((a) => a.accessory) : null, s = e.length > 1 ? e.find((a) => a.decor) : null, r = e.find((a) => a !== i && a !== s);
|
|
319
319
|
return {
|
|
320
320
|
databaseId: r.database,
|
|
321
321
|
configuration: r?.configuration,
|
|
@@ -416,7 +416,7 @@ const g = class g {
|
|
|
416
416
|
};
|
|
417
417
|
g.xmlRegex = /directUrl="([^"]*)"/g;
|
|
418
418
|
let S = g;
|
|
419
|
-
class
|
|
419
|
+
class l {
|
|
420
420
|
constructor(t) {
|
|
421
421
|
this.server = t;
|
|
422
422
|
}
|
|
@@ -482,29 +482,29 @@ class m {
|
|
|
482
482
|
}
|
|
483
483
|
async image(t) {
|
|
484
484
|
const e = {
|
|
485
|
-
scene:
|
|
485
|
+
scene: l.scene(t),
|
|
486
486
|
mode: {
|
|
487
487
|
image: {
|
|
488
488
|
camera: t.view.camera
|
|
489
489
|
}
|
|
490
490
|
},
|
|
491
|
-
renderParameters:
|
|
492
|
-
encoder:
|
|
491
|
+
renderParameters: l.renderParameters(t),
|
|
492
|
+
encoder: l.encoder(t)
|
|
493
493
|
};
|
|
494
|
-
return
|
|
494
|
+
return l.fetchFrame(`${this.server}/Snapshot`, e);
|
|
495
495
|
}
|
|
496
496
|
async vrCube(t) {
|
|
497
497
|
const e = {
|
|
498
|
-
scene:
|
|
498
|
+
scene: l.scene(t),
|
|
499
499
|
mode: {
|
|
500
500
|
vrCube: {
|
|
501
501
|
camera: t.view.camera
|
|
502
502
|
}
|
|
503
503
|
},
|
|
504
|
-
renderParameters:
|
|
505
|
-
encoder:
|
|
504
|
+
renderParameters: l.renderParameters(t),
|
|
505
|
+
encoder: l.encoder(t)
|
|
506
506
|
};
|
|
507
|
-
return e.renderParameters.width = Math.max(e.renderParameters.width, e.renderParameters.height), e.renderParameters.height = Math.max(e.renderParameters.width, e.renderParameters.height),
|
|
507
|
+
return e.renderParameters.width = Math.max(e.renderParameters.width, e.renderParameters.height), e.renderParameters.height = Math.max(e.renderParameters.width, e.renderParameters.height), l.fetchFrameArray(`${this.server}/Snapshot`, e);
|
|
508
508
|
}
|
|
509
509
|
async vrObject(t) {
|
|
510
510
|
let e;
|
|
@@ -531,16 +531,16 @@ class m {
|
|
|
531
531
|
}
|
|
532
532
|
};
|
|
533
533
|
const i = {
|
|
534
|
-
scene:
|
|
534
|
+
scene: l.scene(t),
|
|
535
535
|
mode: e,
|
|
536
|
-
renderParameters:
|
|
537
|
-
encoder:
|
|
536
|
+
renderParameters: l.renderParameters(t),
|
|
537
|
+
encoder: l.encoder(t)
|
|
538
538
|
};
|
|
539
|
-
return
|
|
539
|
+
return l.fetchFrameArray(`${this.server}/Snapshot`, i);
|
|
540
540
|
}
|
|
541
541
|
async animation(t) {
|
|
542
542
|
const e = {
|
|
543
|
-
scene:
|
|
543
|
+
scene: l.scene(t),
|
|
544
544
|
mode: {
|
|
545
545
|
animation: {
|
|
546
546
|
id: t.view.animation,
|
|
@@ -548,45 +548,45 @@ class m {
|
|
|
548
548
|
fps: t.view.fps
|
|
549
549
|
}
|
|
550
550
|
},
|
|
551
|
-
renderParameters:
|
|
552
|
-
encoder:
|
|
551
|
+
renderParameters: l.renderParameters(t),
|
|
552
|
+
encoder: l.encoder(t)
|
|
553
553
|
};
|
|
554
|
-
return
|
|
554
|
+
return l.fetchFrameArray(`${this.server}/Snapshot`, e);
|
|
555
555
|
}
|
|
556
556
|
async imageHotspots(t, e) {
|
|
557
557
|
const i = {
|
|
558
|
-
scene:
|
|
558
|
+
scene: l.scene(t),
|
|
559
559
|
mode: {
|
|
560
560
|
image: {
|
|
561
561
|
camera: t.view.camera
|
|
562
562
|
}
|
|
563
563
|
},
|
|
564
|
-
renderParameters:
|
|
564
|
+
renderParameters: l.renderParameters(t),
|
|
565
565
|
...this.hotspotsBody(e)
|
|
566
566
|
};
|
|
567
|
-
return await
|
|
567
|
+
return await l.fetchHotspots(`${this.server}/Hotspot`, i);
|
|
568
568
|
}
|
|
569
569
|
async imagePick(t, e) {
|
|
570
570
|
const i = {
|
|
571
|
-
scene:
|
|
571
|
+
scene: l.scene(t),
|
|
572
572
|
camera: t.view.camera,
|
|
573
|
-
renderParameters:
|
|
573
|
+
renderParameters: l.renderParameters(t),
|
|
574
574
|
positions: [e]
|
|
575
575
|
};
|
|
576
|
-
return await
|
|
576
|
+
return await l.fetchPick(`${this.server}/Pick`, i);
|
|
577
577
|
}
|
|
578
578
|
async vrCubeHotspots(t, e) {
|
|
579
579
|
const i = {
|
|
580
|
-
scene:
|
|
580
|
+
scene: l.scene(t),
|
|
581
581
|
mode: {
|
|
582
582
|
vrCube: {
|
|
583
583
|
camera: t.view.camera
|
|
584
584
|
}
|
|
585
585
|
},
|
|
586
|
-
renderParameters:
|
|
586
|
+
renderParameters: l.renderParameters(t),
|
|
587
587
|
...this.hotspotsBody(e)
|
|
588
588
|
};
|
|
589
|
-
return i.renderParameters.width = Math.max(i.renderParameters.width, i.renderParameters.height), i.renderParameters.height = Math.max(i.renderParameters.width, i.renderParameters.height), await
|
|
589
|
+
return i.renderParameters.width = Math.max(i.renderParameters.width, i.renderParameters.height), i.renderParameters.height = Math.max(i.renderParameters.width, i.renderParameters.height), await l.fetchHotspotsArray(`${this.server}/Hotspot`, i);
|
|
590
590
|
}
|
|
591
591
|
async vrObjectHotspots(t, e) {
|
|
592
592
|
let i;
|
|
@@ -613,12 +613,12 @@ class m {
|
|
|
613
613
|
}
|
|
614
614
|
};
|
|
615
615
|
const s = {
|
|
616
|
-
scene:
|
|
616
|
+
scene: l.scene(t),
|
|
617
617
|
mode: i,
|
|
618
|
-
renderParameters:
|
|
618
|
+
renderParameters: l.renderParameters(t),
|
|
619
619
|
...this.hotspotsBody(e)
|
|
620
620
|
};
|
|
621
|
-
return await
|
|
621
|
+
return await l.fetchHotspotsArray(`${this.server}/Hotspot`, s);
|
|
622
622
|
}
|
|
623
623
|
hotspotsBody(t) {
|
|
624
624
|
return {
|
|
@@ -634,13 +634,13 @@ class D {
|
|
|
634
634
|
this.webrender = new X();
|
|
635
635
|
break;
|
|
636
636
|
case "v1":
|
|
637
|
-
this.webrender = new S(t), this.webrenderV2 = new
|
|
637
|
+
this.webrender = new S(t), this.webrenderV2 = new l(t);
|
|
638
638
|
break;
|
|
639
639
|
case "v2":
|
|
640
|
-
this.webrender = new
|
|
640
|
+
this.webrender = new l(t), this.webrenderV2 = new l(t);
|
|
641
641
|
break;
|
|
642
642
|
default:
|
|
643
|
-
this.webrender = new S(t), this.webrenderV2 = new
|
|
643
|
+
this.webrender = new S(t), this.webrenderV2 = new l(t);
|
|
644
644
|
break;
|
|
645
645
|
}
|
|
646
646
|
this.delegate = i, this.loadingId = 0, this.loaded = 0, this.total = 0, this.databases = [], this.onLoadStart = i && i.onLoadStart ? i.onLoadStart : () => {
|
|
@@ -678,7 +678,7 @@ class D {
|
|
|
678
678
|
async loadImage(t, e) {
|
|
679
679
|
const i = new Image();
|
|
680
680
|
i.crossOrigin = location.protocol === "file:" && !D.isValidHttpUrl(t) ? null : "anonymous";
|
|
681
|
-
const s = new Promise((r,
|
|
681
|
+
const s = new Promise((r, a) => {
|
|
682
682
|
i.addEventListener(
|
|
683
683
|
"load",
|
|
684
684
|
() => {
|
|
@@ -687,8 +687,8 @@ class D {
|
|
|
687
687
|
{ once: !0 }
|
|
688
688
|
), i.addEventListener(
|
|
689
689
|
"error",
|
|
690
|
-
(
|
|
691
|
-
e === this.loadingId &&
|
|
690
|
+
(n) => {
|
|
691
|
+
e === this.loadingId && a(`${n.type} : ${t}`);
|
|
692
692
|
},
|
|
693
693
|
{ once: !0 }
|
|
694
694
|
);
|
|
@@ -697,27 +697,27 @@ class D {
|
|
|
697
697
|
}
|
|
698
698
|
loadImageFrames(t, e, i, s) {
|
|
699
699
|
this.total = t.length;
|
|
700
|
-
const r = new Array(t.length),
|
|
701
|
-
for (let
|
|
702
|
-
const
|
|
703
|
-
r[
|
|
700
|
+
const r = new Array(t.length), a = i || 0;
|
|
701
|
+
for (let n = 0, o = t.length; n < o; n += 1) {
|
|
702
|
+
const u = Math.ceil(n / 2) * (n % 2 === 0 ? 1 : -1), m = e ? w.mod(a + u, o) : n;
|
|
703
|
+
r[m] = this.loadImage(t[m], s);
|
|
704
704
|
}
|
|
705
705
|
return Promise.all(r).then(() => this.onLoadEnd(this.progress)).catch(() => {
|
|
706
706
|
}), r;
|
|
707
707
|
}
|
|
708
708
|
async loadVideo(t, e, i, s) {
|
|
709
709
|
t.loop = i;
|
|
710
|
-
const r = new Promise((
|
|
710
|
+
const r = new Promise((a, n) => {
|
|
711
711
|
t.addEventListener(
|
|
712
712
|
"canplaythrough",
|
|
713
713
|
() => {
|
|
714
|
-
s === this.loadingId && (this.loaded += 1, this.onLoadProgress(this.progress),
|
|
714
|
+
s === this.loadingId && (this.loaded += 1, this.onLoadProgress(this.progress), a());
|
|
715
715
|
},
|
|
716
716
|
{ once: !0 }
|
|
717
717
|
), t.addEventListener(
|
|
718
718
|
"error",
|
|
719
719
|
(o) => {
|
|
720
|
-
s === this.loadingId &&
|
|
720
|
+
s === this.loadingId && n(`${o.type} : ${e}`);
|
|
721
721
|
},
|
|
722
722
|
{ once: !0 }
|
|
723
723
|
);
|
|
@@ -725,24 +725,24 @@ class D {
|
|
|
725
725
|
return t.src = e, t.load(), r;
|
|
726
726
|
}
|
|
727
727
|
async loadVideoFrame(t, e, i, s, r) {
|
|
728
|
-
let
|
|
729
|
-
return new Promise((
|
|
730
|
-
const
|
|
728
|
+
let a = 0;
|
|
729
|
+
return new Promise((n, o) => {
|
|
730
|
+
const u = () => {
|
|
731
731
|
if (r !== this.loadingId) return;
|
|
732
|
-
if (
|
|
733
|
-
|
|
732
|
+
if (a !== s) {
|
|
733
|
+
a += 1;
|
|
734
734
|
return;
|
|
735
735
|
}
|
|
736
|
-
t.removeEventListener("seeked",
|
|
737
|
-
const
|
|
738
|
-
|
|
736
|
+
t.removeEventListener("seeked", u);
|
|
737
|
+
const m = document.createElement("canvas");
|
|
738
|
+
m.width = t.videoWidth, m.height = t.videoHeight, m.getContext("2d").drawImage(t, 0, 0);
|
|
739
739
|
const d = new Image();
|
|
740
|
-
d.src =
|
|
740
|
+
d.src = m.toDataURL(), n(d), this.loaded += 1, this.onLoadProgress(this.progress), s !== i - 1 && (t.currentTime += 1 / e);
|
|
741
741
|
};
|
|
742
|
-
t.addEventListener("seeked",
|
|
742
|
+
t.addEventListener("seeked", u), t.addEventListener(
|
|
743
743
|
"error",
|
|
744
|
-
(
|
|
745
|
-
r === this.loadingId && o(
|
|
744
|
+
(m) => {
|
|
745
|
+
r === this.loadingId && o(m);
|
|
746
746
|
},
|
|
747
747
|
{ once: !0 }
|
|
748
748
|
);
|
|
@@ -750,16 +750,16 @@ class D {
|
|
|
750
750
|
}
|
|
751
751
|
loadVideoFrames(t, e, i, s) {
|
|
752
752
|
this.total = e;
|
|
753
|
-
const r = new Array(e),
|
|
754
|
-
for (let
|
|
755
|
-
r[
|
|
756
|
-
return
|
|
753
|
+
const r = new Array(e), a = document.createElement("video");
|
|
754
|
+
for (let n = 0, o = e; n < o; n += 1)
|
|
755
|
+
r[n] = this.loadVideoFrame(a, i, e, n, s);
|
|
756
|
+
return a.addEventListener(
|
|
757
757
|
"canplaythrough",
|
|
758
758
|
() => {
|
|
759
|
-
s === this.loadingId && (
|
|
759
|
+
s === this.loadingId && (a.currentTime = 1 / i / 2);
|
|
760
760
|
},
|
|
761
761
|
{ once: !0 }
|
|
762
|
-
),
|
|
762
|
+
), a.src = t, a.load(), Promise.all(r).then(() => this.onLoadEnd(this.progress)).catch(() => {
|
|
763
763
|
}), r;
|
|
764
764
|
}
|
|
765
765
|
async loadImageHotspots(t, e) {
|
|
@@ -781,47 +781,48 @@ class D {
|
|
|
781
781
|
return this.webrenderV2 ? await this.webrenderV2.imagePick(await this.vrCubeFrameSnapshot(t, i), e) : Promise.reject(new Error("Picking only available with api V2"));
|
|
782
782
|
}
|
|
783
783
|
async convert(t) {
|
|
784
|
-
if (!this.webrenderV2 || this.webrender instanceof
|
|
784
|
+
if (!this.webrenderV2 || this.webrender instanceof l || !t.view.camera)
|
|
785
785
|
return t;
|
|
786
786
|
const e = t.scene.find((o) => !o.decor && !o.accessory);
|
|
787
787
|
if (!e)
|
|
788
788
|
return t;
|
|
789
789
|
let i = this.databases.find((o) => o.id === e.database);
|
|
790
790
|
(!i || !i.xmlDoc) && (i = await this.webrender.database(e.database), this.databases.push(i));
|
|
791
|
-
const s = t.view.camera
|
|
792
|
-
if (
|
|
793
|
-
return { ...t, view: { ...t.view, camera:
|
|
791
|
+
const s = t.view.camera.split("/"), r = s.length === 2 ? s[0] : void 0, a = s.length === 2 ? s[1] : s[0], n = i.getCameraId(a, r);
|
|
792
|
+
if (n)
|
|
793
|
+
return { ...t, view: { ...t.view, camera: n } };
|
|
794
794
|
{
|
|
795
|
-
const o = i.getCameraGroupId(
|
|
795
|
+
const o = i.getCameraGroupId(a);
|
|
796
796
|
return o ? { ...t, view: { ...t.view, cameraGroup: o } } : t;
|
|
797
797
|
}
|
|
798
798
|
}
|
|
799
799
|
async vrObjectFrameSnapshot(t, e, i) {
|
|
800
800
|
if (!this.webrenderV2)
|
|
801
801
|
return t;
|
|
802
|
-
const s = t.scene.find((
|
|
802
|
+
const s = t.scene.find((a) => !a.decor && !a.accessory);
|
|
803
803
|
if (!s)
|
|
804
804
|
return t;
|
|
805
|
-
let r = this.databases.find((
|
|
805
|
+
let r = this.databases.find((a) => a.id === s.database);
|
|
806
806
|
if (r || (r = await this.webrender.database(s.database), this.databases.push(r)), this.webrender instanceof S) {
|
|
807
807
|
if (!t.view.camera)
|
|
808
808
|
return t;
|
|
809
|
-
const
|
|
810
|
-
if (!n)
|
|
811
|
-
return t;
|
|
812
|
-
const a = r.getCameraGroupById(n);
|
|
809
|
+
const a = r.getCameraGroupId(t.view.camera);
|
|
813
810
|
if (!a)
|
|
814
811
|
return t;
|
|
815
|
-
const
|
|
812
|
+
const n = r.getCameraGroupById(a);
|
|
813
|
+
if (!n)
|
|
814
|
+
return t;
|
|
815
|
+
const o = n.cameras[e];
|
|
816
816
|
return o ? { ...t, view: { ...t.view, camera: o.id } } : t;
|
|
817
|
-
} else if (this.webrender instanceof
|
|
818
|
-
|
|
819
|
-
|
|
817
|
+
} else if (this.webrender instanceof l) {
|
|
818
|
+
const a = typeof t.view.camera == "string" ? t.view.camera : t.view.camera?.id;
|
|
819
|
+
if (a) {
|
|
820
|
+
const n = r.getCameraById(a);
|
|
820
821
|
if (!n)
|
|
821
822
|
return t;
|
|
822
|
-
const
|
|
823
|
-
|
|
824
|
-
const
|
|
823
|
+
const o = new B(n.pointOfView), u = 2 * Math.PI / i;
|
|
824
|
+
o.longitude += e * u % (2 * Math.PI);
|
|
825
|
+
const m = o.pointOfView(n.pointOfView.target);
|
|
825
826
|
return {
|
|
826
827
|
...t,
|
|
827
828
|
view: {
|
|
@@ -830,19 +831,19 @@ class D {
|
|
|
830
831
|
id: n.id,
|
|
831
832
|
pov: {
|
|
832
833
|
target: {
|
|
833
|
-
x:
|
|
834
|
-
y:
|
|
835
|
-
z:
|
|
834
|
+
x: m.target[0],
|
|
835
|
+
y: m.target[1],
|
|
836
|
+
z: m.target[2]
|
|
836
837
|
},
|
|
837
838
|
eye: {
|
|
838
|
-
x:
|
|
839
|
-
y:
|
|
840
|
-
z:
|
|
839
|
+
x: m.eye[0],
|
|
840
|
+
y: m.eye[1],
|
|
841
|
+
z: m.eye[2]
|
|
841
842
|
},
|
|
842
843
|
up: {
|
|
843
|
-
x:
|
|
844
|
-
y:
|
|
845
|
-
z:
|
|
844
|
+
x: m.up[0],
|
|
845
|
+
y: m.up[1],
|
|
846
|
+
z: m.up[2]
|
|
846
847
|
}
|
|
847
848
|
}
|
|
848
849
|
}
|
|
@@ -852,11 +853,11 @@ class D {
|
|
|
852
853
|
const n = r.getCameraGroupById(t.view.cameraGroup);
|
|
853
854
|
if (!n)
|
|
854
855
|
return t;
|
|
855
|
-
const
|
|
856
|
-
return
|
|
856
|
+
const o = n.cameras[e];
|
|
857
|
+
return o ? { ...t, view: { ...t.view, camera: o.id } } : t;
|
|
857
858
|
} else
|
|
858
859
|
return t;
|
|
859
|
-
else
|
|
860
|
+
} else
|
|
860
861
|
return t;
|
|
861
862
|
}
|
|
862
863
|
async vrCubeFrameSnapshot(t, e) {
|
|
@@ -868,36 +869,36 @@ class D {
|
|
|
868
869
|
return t;
|
|
869
870
|
let r;
|
|
870
871
|
if (this.webrender instanceof S) {
|
|
871
|
-
const o = t.view.camera.split("/"),
|
|
872
|
-
r = s.getCameraId(
|
|
873
|
-
} else this.webrender instanceof
|
|
872
|
+
const o = t.view.camera.split("/"), u = o.length === 2 ? o[0] : void 0, m = o.length === 2 ? o[1] : o[0];
|
|
873
|
+
r = s.getCameraId(m, u);
|
|
874
|
+
} else this.webrender instanceof l && (r = typeof t.view.camera == "string" ? t.view.camera : t.view.camera.id);
|
|
874
875
|
if (!r)
|
|
875
876
|
return t;
|
|
876
|
-
const
|
|
877
|
-
if (!
|
|
877
|
+
const a = s.getCameraById(r);
|
|
878
|
+
if (!a)
|
|
878
879
|
return t;
|
|
879
|
-
const
|
|
880
|
+
const n = L.initCubeFace(a.pointOfView.eye, a.pointOfView.target, e);
|
|
880
881
|
return {
|
|
881
882
|
...t,
|
|
882
883
|
view: {
|
|
883
884
|
...t.view,
|
|
884
885
|
camera: {
|
|
885
|
-
id:
|
|
886
|
+
id: a.id,
|
|
886
887
|
pov: {
|
|
887
888
|
target: {
|
|
888
|
-
x:
|
|
889
|
-
y:
|
|
890
|
-
z:
|
|
889
|
+
x: n.target[0],
|
|
890
|
+
y: n.target[1],
|
|
891
|
+
z: n.target[2]
|
|
891
892
|
},
|
|
892
893
|
eye: {
|
|
893
|
-
x:
|
|
894
|
-
y:
|
|
895
|
-
z:
|
|
894
|
+
x: n.eye[0],
|
|
895
|
+
y: n.eye[1],
|
|
896
|
+
z: n.eye[2]
|
|
896
897
|
},
|
|
897
898
|
up: {
|
|
898
|
-
x:
|
|
899
|
-
y:
|
|
900
|
-
z:
|
|
899
|
+
x: n.up[0],
|
|
900
|
+
y: n.up[1],
|
|
901
|
+
z: n.up[2]
|
|
901
902
|
}
|
|
902
903
|
},
|
|
903
904
|
lens: {
|
|
@@ -960,18 +961,18 @@ class J {
|
|
|
960
961
|
}
|
|
961
962
|
async load(t, e, i, s) {
|
|
962
963
|
let r = Promise.resolve();
|
|
963
|
-
const
|
|
964
|
-
|
|
964
|
+
const a = JSON.stringify(t);
|
|
965
|
+
a === this.snapshotHash && this.image ? r = r.then(() => this.canvas.draw(this.image, s, 0.05)) : r = r.then(
|
|
965
966
|
() => this.loader.loadImageSnapshot(t).then((o) => {
|
|
966
967
|
this.canvas.draw(o, s, 0.05), this.image = o;
|
|
967
968
|
})
|
|
968
969
|
);
|
|
969
|
-
const
|
|
970
|
-
return (
|
|
970
|
+
const n = JSON.stringify(e);
|
|
971
|
+
return (a !== this.snapshotHash || n !== this.hotspotsHash) && (e.length ? r = r.then(
|
|
971
972
|
() => this.loader.loadImageHotspots(t, e).then((o) => {
|
|
972
973
|
this.hotspotList = o;
|
|
973
974
|
})
|
|
974
|
-
) : this.hotspotList = []), this.hotspotsHash =
|
|
975
|
+
) : this.hotspotList = []), this.hotspotsHash = n, this.snapshotHash = a, r;
|
|
975
976
|
}
|
|
976
977
|
async pick(t, e) {
|
|
977
978
|
const i = new b(t.parameters.width, t.parameters.height), s = p.unproject(i, this.canvas.resolution, this.canvas.fit, e);
|
|
@@ -1072,8 +1073,8 @@ class Q {
|
|
|
1072
1073
|
get orientedPov() {
|
|
1073
1074
|
const t = h.normalize(h.cross(this.pov.up, this.pov.target)), e = new V(t, [0, 1, 0], this.pov.eye), i = c.identity();
|
|
1074
1075
|
c.multiply(i, e.localToGlobalMatrix, i), c.multiply(i, this.orientationMatrix, i), c.multiply(i, e.globalToLocalMatrix, i);
|
|
1075
|
-
const s = c.transformDirection(i, this.pov.target), r = this.pov.eye,
|
|
1076
|
-
return new L(s, r,
|
|
1076
|
+
const s = c.transformDirection(i, this.pov.target), r = this.pov.eye, a = c.transformDirection(i, this.pov.up);
|
|
1077
|
+
return new L(s, r, a);
|
|
1077
1078
|
}
|
|
1078
1079
|
reset() {
|
|
1079
1080
|
this.pov = this.initPov.clone(), this.fov = this.initFov;
|
|
@@ -1086,17 +1087,17 @@ class Q {
|
|
|
1086
1087
|
const e = {
|
|
1087
1088
|
x: t.x - this.previousPoint.x,
|
|
1088
1089
|
y: t.y - this.previousPoint.y
|
|
1089
|
-
}, i = w.accelerate(e.x, 1.3) / this.startSize.width * 0.2 * Math.PI * 1.5, s = w.accelerate(e.y, 1.3) / this.startSize.height * 0.2 * Math.PI, r = c.multiply(c.rotationY(i), c.rotationX(-s)),
|
|
1090
|
-
c.multiply(o,
|
|
1091
|
-
const
|
|
1092
|
-
h.cross(
|
|
1090
|
+
}, i = w.accelerate(e.x, 1.3) / this.startSize.width * 0.2 * Math.PI * 1.5, s = w.accelerate(e.y, 1.3) / this.startSize.height * 0.2 * Math.PI, r = c.multiply(c.rotationY(i), c.rotationX(-s)), a = h.normalize(h.cross(this.pov.up, this.pov.target)), n = new V(a, [0, 1, 0], this.pov.eye), o = c.identity();
|
|
1091
|
+
c.multiply(o, n.localToGlobalMatrix, o), c.multiply(o, r, o), c.multiply(o, n.globalToLocalMatrix, o);
|
|
1092
|
+
const u = c.transformPoint(o, this.pov.target), m = c.transformDirection(o, this.pov.up);
|
|
1093
|
+
h.cross(m, [0, 0, 1])[0] >= 0 && (this.pov.target = u, this.pov.up = m), this.previousPoint = t, this.onMotion();
|
|
1093
1094
|
}
|
|
1094
1095
|
end(t, e) {
|
|
1095
1096
|
this.isStarted = !1, e && (this.inertia.track(t), this.inertia.start());
|
|
1096
1097
|
}
|
|
1097
1098
|
orientation(t, e, i) {
|
|
1098
|
-
const s = w.degreesToRadians(window.orientation) || 0, r = w.degreesToRadians(t),
|
|
1099
|
-
c.rotateZ(o, this.initOrientation, o), c.rotateZ(o, r, o), c.rotateX(o,
|
|
1099
|
+
const s = w.degreesToRadians(window.orientation) || 0, r = w.degreesToRadians(t), a = w.degreesToRadians(-e), n = w.degreesToRadians(-i), o = c.rotationX(w.degreesToRadians(90));
|
|
1100
|
+
c.rotateZ(o, this.initOrientation, o), c.rotateZ(o, r, o), c.rotateX(o, a, o), c.rotateY(o, n, o), c.rotateZ(o, -s, o), this.orientationMatrix = o, this.onMotion();
|
|
1100
1101
|
}
|
|
1101
1102
|
}
|
|
1102
1103
|
var W = `precision mediump float;
|
|
@@ -1124,8 +1125,8 @@ void main() {
|
|
|
1124
1125
|
class K {
|
|
1125
1126
|
constructor(t, e, i, s) {
|
|
1126
1127
|
this.container = t, this.canvas = e, this.loader = i, this.images = [], this.hotspotsList = [[]];
|
|
1127
|
-
const r = new L([0, 0, 1], [0, 0, 0], [0, 1, 0]),
|
|
1128
|
-
c.transformDirection(
|
|
1128
|
+
const r = new L([0, 0, 1], [0, 0, 0], [0, 1, 0]), a = 60, n = c.rotationX(w.degreesToRadians(15));
|
|
1129
|
+
c.transformDirection(n, r.target, r.target), c.transformDirection(n, r.up, r.up), this.interaction = new Q(r, a, () => {
|
|
1129
1130
|
this.animationFrameId = requestAnimationFrame(this.render), this.onInteraction({
|
|
1130
1131
|
pov: this.interaction.pov.clone(),
|
|
1131
1132
|
fov: this.interaction.fov
|
|
@@ -1176,8 +1177,8 @@ class K {
|
|
|
1176
1177
|
const o = this.gl.getExtension("WEBGL_debug_renderer_info");
|
|
1177
1178
|
o && navigator.platform === "MacIntel" && navigator.userAgent.includes("Chrome") && this.gl.getParameter(o.UNMASKED_RENDERER_WEBGL).includes("OpenGL") && (t.parameters.width = Math.min(t.parameters.width, 1812), t.parameters.height = Math.min(t.parameters.height, 1812));
|
|
1178
1179
|
}
|
|
1179
|
-
const
|
|
1180
|
-
|
|
1180
|
+
const a = JSON.stringify(t);
|
|
1181
|
+
a === this.snapshotHash ? r = r.then(() => (this.animationFrameId = requestAnimationFrame(this.render), Promise.resolve())) : (this.images = [], this.animationFrameId = requestAnimationFrame(this.render), r = r.then(
|
|
1181
1182
|
() => this.loader.loadVRCubeSnapshot(t).then((o) => {
|
|
1182
1183
|
this.images = o, P.createTexture(
|
|
1183
1184
|
this.gl,
|
|
@@ -1196,21 +1197,21 @@ class K {
|
|
|
1196
1197
|
],
|
|
1197
1198
|
src: o
|
|
1198
1199
|
},
|
|
1199
|
-
(
|
|
1200
|
-
|
|
1200
|
+
(u, m) => {
|
|
1201
|
+
u || (i && this.interaction.reset(), this.uniforms.u_mix = s ? 0 : 1, this.uniforms.u_texture_back = this.uniforms.u_texture, this.uniforms.u_texture = m, this.animationFrameId = requestAnimationFrame(this.render));
|
|
1201
1202
|
}
|
|
1202
1203
|
);
|
|
1203
1204
|
})
|
|
1204
1205
|
));
|
|
1205
|
-
const
|
|
1206
|
-
return (
|
|
1206
|
+
const n = JSON.stringify(e);
|
|
1207
|
+
return (a !== this.snapshotHash || n !== this.hotspotsHash) && (e.length ? r = r.then(
|
|
1207
1208
|
() => this.loader.loadVRCubeHotspots(t, e).then((o) => {
|
|
1208
1209
|
this.hotspotsList = o;
|
|
1209
1210
|
})
|
|
1210
|
-
) : this.hotspotsList = [[]]), this.hotspotsHash =
|
|
1211
|
+
) : this.hotspotsList = [[]]), this.hotspotsHash = n, this.snapshotHash = a, r;
|
|
1211
1212
|
}
|
|
1212
1213
|
async pick(t, e) {
|
|
1213
|
-
const i = this.canvas.element.clientWidth, s = this.canvas.element.clientHeight, r = e.x,
|
|
1214
|
+
const i = this.canvas.element.clientWidth, s = this.canvas.element.clientHeight, r = e.x, a = s - e.y, n = 2 * r / i - 1, o = 2 * a / s - 1, u = [n, o, 0], m = this.modelViewProjectionMatrix, f = c.inverse(m), d = h.normalize(c.transformPoint(f, u)), T = Math.max(Math.abs(d[0]), Math.abs(d[1]), Math.abs(d[2]));
|
|
1214
1215
|
let F = "";
|
|
1215
1216
|
Math.abs(d[0]) === T ? F = d[0] > 0 ? "XPOS" : "XNEG" : Math.abs(d[1]) === T ? F = d[1] > 0 ? "YPOS" : "YNEG" : F = d[2] > 0 ? "ZPOS" : "ZNEG";
|
|
1216
1217
|
let x = 0, M = 0, E = "";
|
|
@@ -1234,11 +1235,11 @@ class K {
|
|
|
1234
1235
|
x = (-d[0] / Math.abs(d[2]) + 1) / 2, M = (-d[1] / Math.abs(d[2]) + 1) / 2, E = "back";
|
|
1235
1236
|
break;
|
|
1236
1237
|
}
|
|
1237
|
-
const
|
|
1238
|
+
const O = {
|
|
1238
1239
|
x: Math.round(x * Math.max(t.parameters.width, t.parameters.height)),
|
|
1239
1240
|
y: Math.round(M * Math.max(t.parameters.width, t.parameters.height))
|
|
1240
1241
|
};
|
|
1241
|
-
return this.loader.loadVRCubePick(t,
|
|
1242
|
+
return this.loader.loadVRCubePick(t, O, E);
|
|
1242
1243
|
}
|
|
1243
1244
|
hotspots() {
|
|
1244
1245
|
const t = [];
|
|
@@ -1249,33 +1250,33 @@ class K {
|
|
|
1249
1250
|
const r = this.hotspotsList.findIndex((R) => R[s].visibility !== "OutOfFrustum");
|
|
1250
1251
|
if (r === -1)
|
|
1251
1252
|
continue;
|
|
1252
|
-
const
|
|
1253
|
-
let
|
|
1253
|
+
const a = { ...this.hotspotsList[r][s] }, n = a.position2D.x / this.images[0].width, o = a.position2D.y / this.images[0].height;
|
|
1254
|
+
let u = 0, m = 0, f = 0;
|
|
1254
1255
|
switch (r) {
|
|
1255
1256
|
case 0:
|
|
1256
|
-
this.pov.target[2] < 0 && (
|
|
1257
|
+
this.pov.target[2] < 0 && (a.visibility = "OutOfFrustum"), u = 2 * n - 1, m = 1 - 2 * o, f = 1;
|
|
1257
1258
|
break;
|
|
1258
1259
|
case 1:
|
|
1259
|
-
this.pov.target[0] > 0 && (
|
|
1260
|
+
this.pov.target[0] > 0 && (a.visibility = "OutOfFrustum"), u = 1, m = 1 - 2 * o, f = 1 - 2 * n;
|
|
1260
1261
|
break;
|
|
1261
1262
|
case 2:
|
|
1262
|
-
this.pov.target[2] > 0 && (
|
|
1263
|
+
this.pov.target[2] > 0 && (a.visibility = "OutOfFrustum"), u = 1 - 2 * n, m = 1 - 2 * o, f = -1;
|
|
1263
1264
|
break;
|
|
1264
1265
|
case 3:
|
|
1265
|
-
this.pov.target[0] < 0 && (
|
|
1266
|
+
this.pov.target[0] < 0 && (a.visibility = "OutOfFrustum"), u = -1, m = 1 - 2 * o, f = 2 * n - 1;
|
|
1266
1267
|
break;
|
|
1267
1268
|
case 4:
|
|
1268
|
-
this.pov.target[1] < 0 && (
|
|
1269
|
+
this.pov.target[1] < 0 && (a.visibility = "OutOfFrustum"), u = 2 * n - 1, m = 1, f = 2 * o - 1;
|
|
1269
1270
|
break;
|
|
1270
1271
|
case 5:
|
|
1271
|
-
this.pov.target[1] > 0 && (
|
|
1272
|
+
this.pov.target[1] > 0 && (a.visibility = "OutOfFrustum"), u = 2 * n - 1, m = -1, f = 1 - 2 * o;
|
|
1272
1273
|
break;
|
|
1273
1274
|
}
|
|
1274
|
-
const d = h.normalize([
|
|
1275
|
+
const d = h.normalize([u, m, f]), T = c.transformPoint(i, d), F = this.canvas.element.clientWidth, x = this.canvas.element.clientHeight, M = 0.5 * F * (T[0] + 1), E = 0.5 * x * (T[1] + 1), O = {
|
|
1275
1276
|
x: Math.round(M),
|
|
1276
1277
|
y: Math.round(x - E)
|
|
1277
|
-
}, G = new b(F, x), z = p.contains(G,
|
|
1278
|
-
t.push({ ...
|
|
1278
|
+
}, G = new b(F, x), z = p.contains(G, O) ? a.visibility : "OutOfFrustum";
|
|
1279
|
+
t.push({ ...a, position2D: O, visibility: z });
|
|
1279
1280
|
}
|
|
1280
1281
|
return t;
|
|
1281
1282
|
}
|
|
@@ -1283,8 +1284,8 @@ class K {
|
|
|
1283
1284
|
return this.canvas.element.toDataURL(t, e);
|
|
1284
1285
|
}
|
|
1285
1286
|
get modelViewProjectionMatrix() {
|
|
1286
|
-
const t = this.canvas.element.clientWidth, e = this.canvas.element.clientHeight, i = t > e ? t / e : e / t, s = p.getStandardAspectRatio(t, e), r = this.interaction.fov * (s / i),
|
|
1287
|
-
return c.multiply(c.multiply(
|
|
1287
|
+
const t = this.canvas.element.clientWidth, e = this.canvas.element.clientHeight, i = t > e ? t / e : e / t, s = p.getStandardAspectRatio(t, e), r = this.interaction.fov * (s / i), a = c.setAxis(c.identity(), [-1, 0, 0], 0), n = t > e ? w.perspectiveWithFovY(r, t / e, 0.5, 100) : w.perspectiveWithFovX(r, t / e, 0.5, 100), o = this.interaction.orientedPov, u = c.inverse(c.lookAt(o.eye, o.target, o.up));
|
|
1288
|
+
return c.multiply(c.multiply(n, u), a);
|
|
1288
1289
|
}
|
|
1289
1290
|
render() {
|
|
1290
1291
|
this.gl.viewport(0, 0, this.gl.canvas.width, this.gl.canvas.height), this.uniforms.u_mvpi = c.inverse(this.modelViewProjectionMatrix), this.gl.useProgram(this.programInfo.program), P.setBuffersAndAttributes(this.gl, this.programInfo, this.quad), P.setUniforms(this.programInfo, this.uniforms), P.drawBufferInfo(this.gl, this.quad), this.uniforms.u_mix < 1 && (this.uniforms.u_mix = Math.min(this.uniforms.u_mix + 0.05, 1), this.animationFrameId = requestAnimationFrame(this.render));
|
|
@@ -1349,21 +1350,21 @@ class tt {
|
|
|
1349
1350
|
const s = w.accelerate(t.x - this.startPoint.x, 1.3) / this.startSize.width * (this.frames / 4);
|
|
1350
1351
|
let r = this.startPosition.x - Math.round(s);
|
|
1351
1352
|
r = this.loop ? w.mod(r, this.frames) : Math.max(0, Math.min(r, this.frames - 1)), r !== this.position.x && (this.position.x = r, this.onMotion());
|
|
1352
|
-
const
|
|
1353
|
-
Math.max(...this.lastPoints.map((o) => o.x)) -
|
|
1353
|
+
const a = Math.min(...this.lastPoints.map((o) => o.x));
|
|
1354
|
+
Math.max(...this.lastPoints.map((o) => o.x)) - a > i && (this.startPoint.y = t.y, this.startPosition.y = this.position.y);
|
|
1354
1355
|
} else {
|
|
1355
1356
|
const s = w.accelerate(t.y - this.startPoint.y, 1.7) / this.startSize.height * (this.rows / 4);
|
|
1356
1357
|
let r = this.startPosition.y + Math.round(s);
|
|
1357
1358
|
r = Math.max(0, Math.min(r, this.rows - 1)), r !== this.position.y && (this.position.y = r, this.onMotion());
|
|
1358
|
-
const
|
|
1359
|
-
Math.max(...this.lastPoints.map((o) => o.y)) -
|
|
1359
|
+
const a = Math.min(...this.lastPoints.map((o) => o.y));
|
|
1360
|
+
Math.max(...this.lastPoints.map((o) => o.y)) - a > i && (this.startPoint.x = t.x, this.startPosition.x = this.position.x);
|
|
1360
1361
|
}
|
|
1361
1362
|
}
|
|
1362
1363
|
end(t, e) {
|
|
1363
1364
|
this.isStarted = !1, e && (this.inertia.track(t), this.inertia.start());
|
|
1364
1365
|
}
|
|
1365
1366
|
}
|
|
1366
|
-
class
|
|
1367
|
+
class k {
|
|
1367
1368
|
constructor(t, e, i, s) {
|
|
1368
1369
|
this.container = t, this.canvas = e, this.loader = i, this.images = [], this.frames = 24, this.hotspotsList = [[]], this.interaction = new tt({ x: 0, y: 0 }, 1, 1, !1, () => {
|
|
1369
1370
|
this.canvas.draw(this.image, !0, 0.5), this.onInteraction({
|
|
@@ -1406,24 +1407,24 @@ class O {
|
|
|
1406
1407
|
async load(t, e, i, s) {
|
|
1407
1408
|
let r = Promise.resolve();
|
|
1408
1409
|
i && this.interaction.reset();
|
|
1409
|
-
const
|
|
1410
|
-
|
|
1410
|
+
const a = JSON.stringify(t);
|
|
1411
|
+
a === this.snapshotHash && this.image ? r = r.then(() => this.canvas.draw(this.image, s, 0.05)) : (this.images = [], r = r.then(
|
|
1411
1412
|
() => this.loader.loadVRObjectSnapshot(t, this.interaction.positionIndex).then((o) => {
|
|
1412
|
-
const
|
|
1413
|
-
return this.images = new Array(
|
|
1414
|
-
|
|
1413
|
+
const u = o.length;
|
|
1414
|
+
return this.images = new Array(u), this.interaction.frames = t.view.frames ?? t.view.panFrames ?? this.frames, this.interaction.rows = u / this.interaction.frames, this.interaction.loop = !!t.view.loop, i && this.interaction.reset(), o.forEach((m, f) => {
|
|
1415
|
+
m.then((d) => {
|
|
1415
1416
|
this.images[f] = d, d === this.image && this.canvas.draw(this.image, s, 0.05);
|
|
1416
1417
|
}).catch(() => {
|
|
1417
1418
|
});
|
|
1418
1419
|
}), o[this.interaction.positionIndex].then(() => Promise.resolve());
|
|
1419
1420
|
})
|
|
1420
1421
|
));
|
|
1421
|
-
const
|
|
1422
|
-
return (
|
|
1422
|
+
const n = JSON.stringify(e);
|
|
1423
|
+
return (a !== this.snapshotHash || n !== this.hotspotsHash) && (e.length ? r = r.then(
|
|
1423
1424
|
() => this.loader.loadVRObjectHotspots(t, e).then((o) => {
|
|
1424
1425
|
this.hotspotsList = o;
|
|
1425
1426
|
})
|
|
1426
|
-
) : this.hotspotsList = [[]]), this.hotspotsHash =
|
|
1427
|
+
) : this.hotspotsList = [[]]), this.hotspotsHash = n, this.snapshotHash = a, r;
|
|
1427
1428
|
}
|
|
1428
1429
|
async pick(t, e) {
|
|
1429
1430
|
const i = new b(t.parameters.width, t.parameters.height), s = p.unproject(i, this.canvas.resolution, this.canvas.fit, e);
|
|
@@ -1518,7 +1519,7 @@ class et {
|
|
|
1518
1519
|
onDeviceOrientation(t) {
|
|
1519
1520
|
}
|
|
1520
1521
|
}
|
|
1521
|
-
class
|
|
1522
|
+
class at {
|
|
1522
1523
|
constructor(t, e) {
|
|
1523
1524
|
this.checkResize = this.checkResize.bind(this), this.onDeviceOrientation = this.onDeviceOrientation.bind(this), this.onResize = this.onResize.bind(this), this.onMouseDown = this.onMouseDown.bind(this), this.onMouseMove = this.onMouseMove.bind(this), this.onMouseUp = this.onMouseUp.bind(this), this.onMouseEnter = this.onMouseEnter.bind(this), this.onTouchStart = this.onTouchStart.bind(this), this.onTouchMove = this.onTouchMove.bind(this), this.onTouchEnd = this.onTouchEnd.bind(this), this.onLoadStart = this.onLoadStart.bind(this), this.onLoadProgress = this.onLoadProgress.bind(this), this.onLoadEnd = this.onLoadEnd.bind(this), this.onLoadError = this.onLoadError.bind(this), this.onHotspotsChange = this.onHotspotsChange.bind(this), this.onVrcubeInteraction = this.onVrcubeInteraction.bind(this), this.onVrobjectInteraction = this.onVrobjectInteraction.bind(this), this.options = {
|
|
1524
1525
|
server: "localhost",
|
|
@@ -1549,7 +1550,7 @@ class nt {
|
|
|
1549
1550
|
onHotspotsChange: () => {
|
|
1550
1551
|
},
|
|
1551
1552
|
...e.events
|
|
1552
|
-
}, this.options.events.onLoadError =
|
|
1553
|
+
}, this.options.events.onLoadError = C(this.options.events.onLoadError, 10), this.container = t, this.container.classList.add("ls-viewer-container"), this.containerWidth = 0, this.containerHeight = 0, this.canvas2D = new U(this.options.fit), this.container.prepend(this.canvas2D.element), this.canvas3D = new N(), this.container.prepend(this.canvas3D.element), this.video = new Y(), this.container.prepend(this.video.element), this.loader = new D(this.options.server, this.options.api, this), this.resolution = new b(0, 0), this.parameters = {
|
|
1553
1554
|
width: 0,
|
|
1554
1555
|
height: 0,
|
|
1555
1556
|
antialiasing: !1,
|
|
@@ -1557,14 +1558,14 @@ class nt {
|
|
|
1557
1558
|
}, this.encoder = {
|
|
1558
1559
|
format: "jpeg",
|
|
1559
1560
|
quality: 80
|
|
1560
|
-
}, this.hotspots = [], this.widgetImage = new J(t, this.canvas2D, this.loader), this.widgetVideo = new et(t, this.video, this.loader), this.widgetVRObject = new
|
|
1561
|
+
}, this.hotspots = [], this.widgetImage = new J(t, this.canvas2D, this.loader), this.widgetVideo = new et(t, this.video, this.loader), this.widgetVRObject = new k(t, this.canvas2D, this.loader, this.onVrobjectInteraction), this.canvas3D.context && (this.widgetVRCube = new K(t, this.canvas3D, this.loader, this.onVrcubeInteraction)), this.widget = this.widgetImage, this.isDestroyed = !1, this.container.addEventListener("mousedown", this.onMouseDown), this.container.addEventListener("mouseenter", this.onMouseEnter), this.container.addEventListener("touchstart", this.onTouchStart), document.addEventListener("mousemove", this.onMouseMove, { passive: !1 }), document.addEventListener("mouseup", this.onMouseUp), document.addEventListener("touchmove", this.onTouchMove, { passive: !1 }), document.addEventListener("touchend", this.onTouchEnd), this.loadWidget = C(this.loadWidget, 10), this.onResize = C(this.onResize, 250), requestAnimationFrame(this.checkResize);
|
|
1561
1562
|
}
|
|
1562
1563
|
destroy() {
|
|
1563
1564
|
this.canvas2D.destroy(), this.container.removeEventListener("mousedown", this.onMouseDown), this.container.removeEventListener("mouseenter", this.onMouseEnter), this.container.removeEventListener("touchstart", this.onTouchStart), document.removeEventListener("mousemove", this.onMouseMove), document.removeEventListener("mouseup", this.onMouseUp), document.removeEventListener("touchmove", this.onTouchMove), document.removeEventListener("touchend", this.onTouchEnd), this.isDestroyed = !0;
|
|
1564
1565
|
}
|
|
1565
1566
|
async load(t, e) {
|
|
1566
1567
|
let i = Promise.resolve();
|
|
1567
|
-
return e?.animation && (i = i.then(() => this.loadAnimation(e.animation))), this.view && e?.fromPosition !== void 0 && this.viewWidget instanceof
|
|
1568
|
+
return e?.animation && (i = i.then(() => this.loadAnimation(e.animation))), this.view && e?.fromPosition !== void 0 && this.viewWidget instanceof k && (this.view.mode, i = i.then(() => this.viewWidget.goto(e.fromPosition))), e?.animation && (i = i.then(() => this.widgetVideo.play())), i = i.then(() => (this.scene = Array.isArray(t) ? [...t] : [t], this.loadWidget(!1, !(e && e.animation)))), i.catch((s) => {
|
|
1568
1569
|
this.onLoadError(s);
|
|
1569
1570
|
}), i;
|
|
1570
1571
|
}
|
|
@@ -1587,9 +1588,9 @@ class nt {
|
|
|
1587
1588
|
}
|
|
1588
1589
|
async setView(t, e) {
|
|
1589
1590
|
let i = Promise.resolve();
|
|
1590
|
-
return e?.animation && (i = i.then(() => this.loadAnimation(e.animation))), this.view && e?.fromPosition !== void 0 && this.viewWidget instanceof
|
|
1591
|
+
return e?.animation && (i = i.then(() => this.loadAnimation(e.animation))), this.view && e?.fromPosition !== void 0 && this.viewWidget instanceof k && (i = i.then(() => this.viewWidget.goto(e.fromPosition))), e?.animation && (i = i.then(() => this.widgetVideo.play())), i = i.then(() => {
|
|
1591
1592
|
let s = !0;
|
|
1592
|
-
return this.view = { ...t }, this.view && this.viewWidget instanceof
|
|
1593
|
+
return this.view = { ...t }, this.view && this.viewWidget instanceof k && e?.toPosition !== void 0 && (s = !1, this.viewWidget.position = e.toPosition), this.loadWidget(s, !(e && e.animation));
|
|
1593
1594
|
}), i.catch((s) => {
|
|
1594
1595
|
this.onLoadError(s);
|
|
1595
1596
|
}), i;
|
|
@@ -1747,16 +1748,16 @@ var j;
|
|
|
1747
1748
|
})(v.SunShadowQualityMode || (v.SunShadowQualityMode = {})), ((t) => {
|
|
1748
1749
|
t.None = "none", t.Weak = "weak", t.Normal = "normal", t.Fine = "fine", t.UltraFine = "ultraFine", t.Max = "max";
|
|
1749
1750
|
})(v.SunShadowSmoothnessMode || (v.SunShadowSmoothnessMode = {})), ((t) => {
|
|
1750
|
-
t.Manual = "manual", t.ExtractedFromEnv = "extractedFromEnv";
|
|
1751
|
+
t.Manual = "manual", t.TimeAndLoc = "timeAndLoc", t.ExtractedFromEnv = "extractedFromEnv";
|
|
1751
1752
|
})(v.SunUseCaseMode || (v.SunUseCaseMode = {})), ((t) => {
|
|
1752
1753
|
t.ShowOnly = "showOnly", t.HideOnly = "hideOnly";
|
|
1753
1754
|
})(v.SurfacesFilterMode || (v.SurfacesFilterMode = {}));
|
|
1754
1755
|
})(j || (j = {}));
|
|
1755
1756
|
export {
|
|
1756
|
-
|
|
1757
|
+
at as Viewer,
|
|
1757
1758
|
j as WRAPIv2,
|
|
1758
1759
|
J as WidgetImage,
|
|
1759
1760
|
K as WidgetVRCube,
|
|
1760
|
-
|
|
1761
|
+
k as WidgetVRObject,
|
|
1761
1762
|
et as WidgetVideo
|
|
1762
1763
|
};
|