@lumiscaphe/viewer 4.2.0 → 4.2.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/dist/lib/index.cjs +5 -5
- package/dist/lib/index.d.ts +4 -1
- package/dist/lib/index.js +202 -189
- package/package.json +1 -1
package/dist/lib/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
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
|
|
3
|
-
import * as
|
|
2
|
+
import D from "debounce-promise";
|
|
3
|
+
import * as M from "twgl.js";
|
|
4
4
|
import { v3 as h, m4 as c } from "twgl.js";
|
|
5
|
-
import
|
|
6
|
-
class
|
|
5
|
+
import U from "regression";
|
|
6
|
+
class f {
|
|
7
7
|
constructor(t, e) {
|
|
8
8
|
this.width = t, this.height = e;
|
|
9
9
|
}
|
|
@@ -11,7 +11,7 @@ class b {
|
|
|
11
11
|
return this.width / this.height;
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
class
|
|
14
|
+
const P = class P {
|
|
15
15
|
constructor(t, e, i, s) {
|
|
16
16
|
this.top = t, this.left = e, this.width = i, this.height = s;
|
|
17
17
|
}
|
|
@@ -34,49 +34,52 @@ class p {
|
|
|
34
34
|
break;
|
|
35
35
|
}
|
|
36
36
|
const o = (e.height - n) / 2, u = (e.width - a) / 2;
|
|
37
|
-
return new
|
|
37
|
+
return new P(o, u, a, n);
|
|
38
38
|
}
|
|
39
39
|
static project(t, e, i, s) {
|
|
40
|
-
const r =
|
|
40
|
+
const r = P.fit(t, e, i), a = r.width / t.width, n = r.height / t.height;
|
|
41
41
|
return {
|
|
42
42
|
x: Math.round(r.left + s.x * a),
|
|
43
43
|
y: Math.round(r.top + s.y * n)
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
46
|
static unproject(t, e, i, s) {
|
|
47
|
-
const r =
|
|
47
|
+
const r = P.fit(t, e, i), a = r.width / t.width, n = r.height / t.height;
|
|
48
48
|
return {
|
|
49
49
|
x: Math.round((s.x - r.left) / a),
|
|
50
50
|
y: Math.round((s.y - r.top) / n)
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
|
-
static getStandardAspectRatio(t, e) {
|
|
53
|
+
static getStandardAspectRatio(t, e, i) {
|
|
54
54
|
if (t === 0 || e === 0)
|
|
55
55
|
return 0;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
const s = Math.abs(4 / 3 - i), r = Math.abs(16 / 9 - i);
|
|
62
|
-
return s < r ? 4 / 3 : 16 / 9;
|
|
56
|
+
if (i)
|
|
57
|
+
return i;
|
|
58
|
+
const s = t / e;
|
|
59
|
+
return t < e ? s < P.PORTRAIT_ASPECT_BOUNDARY ? 9 / 16 : 3 / 4 : s < P.LANDSCAPE_ASPECT_BOUNDARY ? 4 / 3 : 16 / 9;
|
|
63
60
|
}
|
|
64
|
-
static getStandardResolution(t, e) {
|
|
61
|
+
static getStandardResolution(t, e, i) {
|
|
65
62
|
if (t === 0 || e === 0)
|
|
66
|
-
return new
|
|
67
|
-
const
|
|
63
|
+
return new f(0, 0);
|
|
64
|
+
const s = P.getStandardAspectRatio(t, e, i);
|
|
65
|
+
if (i) {
|
|
66
|
+
const a = P.getStandardQuality(Math.min(t, e));
|
|
67
|
+
return new f(Math.round(a * s), Math.round(a));
|
|
68
|
+
}
|
|
68
69
|
if (t < e) {
|
|
69
|
-
const
|
|
70
|
-
return new
|
|
70
|
+
const a = P.getStandardQuality(Math.max(e * s, t));
|
|
71
|
+
return new f(Math.round(a), Math.round(a / s));
|
|
71
72
|
}
|
|
72
|
-
const
|
|
73
|
-
return new
|
|
73
|
+
const r = P.getStandardQuality(Math.max(t / s, e));
|
|
74
|
+
return new f(Math.round(r * s), Math.round(r));
|
|
74
75
|
}
|
|
75
76
|
static getStandardQuality(t) {
|
|
76
77
|
return t <= 720 ? 720 : 1080;
|
|
77
78
|
}
|
|
78
|
-
}
|
|
79
|
-
|
|
79
|
+
};
|
|
80
|
+
P.LANDSCAPE_ASPECT_BOUNDARY = Math.sqrt(4 / 3 * (16 / 9)), P.PORTRAIT_ASPECT_BOUNDARY = Math.sqrt(3 / 4 * (9 / 16));
|
|
81
|
+
let b = P;
|
|
82
|
+
class N {
|
|
80
83
|
constructor(t) {
|
|
81
84
|
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.backCanvas = document.createElement("canvas"), this.backContext = this.backCanvas.getContext("2d"), this.fit = t, this.pixelRatio = 1;
|
|
82
85
|
}
|
|
@@ -90,7 +93,7 @@ class U {
|
|
|
90
93
|
t ? this.element.style.display = "none" : this.element.style.opacity = "0";
|
|
91
94
|
}
|
|
92
95
|
get resolution() {
|
|
93
|
-
return new
|
|
96
|
+
return new f(this.element.width / this.pixelRatio, this.element.height / this.pixelRatio);
|
|
94
97
|
}
|
|
95
98
|
resize(t, e, i) {
|
|
96
99
|
this.element.width = t * i, this.element.height = e * i, this.element.style.width = `${t}px`, this.element.style.height = `${e}px`, this.backCanvas.width = t * i, this.backCanvas.height = e * i, this.pixelRatio = i;
|
|
@@ -99,7 +102,7 @@ class U {
|
|
|
99
102
|
if (!t)
|
|
100
103
|
return;
|
|
101
104
|
this.requestAnimationId && (cancelAnimationFrame(this.requestAnimationId), this.requestAnimationId = void 0);
|
|
102
|
-
const s =
|
|
105
|
+
const s = b.fit(new f(t.width, t.height), new f(this.element.width, this.element.height), this.fit);
|
|
103
106
|
e ? (this.backContext.drawImage(this.element, 0, 0), this.context.globalAlpha = 0, this.fadeLoop(t, i || 0)) : (this.context.globalAlpha = 1, this.context.drawImage(t, s.left, s.top, s.width, s.height)), this.image = t;
|
|
104
107
|
}
|
|
105
108
|
fadeLoop(t, e) {
|
|
@@ -107,15 +110,15 @@ class U {
|
|
|
107
110
|
cancelAnimationFrame(this.requestAnimationId), this.requestAnimationId = void 0;
|
|
108
111
|
return;
|
|
109
112
|
}
|
|
110
|
-
const i = Math.min(this.context.globalAlpha + e, 1), s =
|
|
113
|
+
const i = Math.min(this.context.globalAlpha + e, 1), s = b.fit(new f(t.width, t.height), new f(this.element.width, this.element.height), this.fit);
|
|
111
114
|
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 = i, this.context.drawImage(t, s.left, s.top, s.width, s.height), this.requestAnimationId = requestAnimationFrame(() => {
|
|
112
115
|
this.fadeLoop(t, e);
|
|
113
116
|
});
|
|
114
117
|
}
|
|
115
118
|
}
|
|
116
|
-
class
|
|
119
|
+
class B {
|
|
117
120
|
constructor() {
|
|
118
|
-
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 =
|
|
121
|
+
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 = M.getContext(this.element, { preserveDrawingBuffer: !0 }), this.context && this.context.isContextLost() && (this.context = void 0), M.setDefaults({ textureColor: [1, 1, 1, 1] });
|
|
119
122
|
}
|
|
120
123
|
show() {
|
|
121
124
|
this.element.style.opacity = "1";
|
|
@@ -154,11 +157,11 @@ class w {
|
|
|
154
157
|
}
|
|
155
158
|
static perspectiveWithLeft(t, e, i, s, r, a, n) {
|
|
156
159
|
n = n || new Float32Array(16);
|
|
157
|
-
const o = e + t, u = e - t,
|
|
158
|
-
return n[0] = 2 * r / u, n[1] = 0, n[2] = 0, n[3] = 0, n[4] = 0, n[5] = 2 * r /
|
|
160
|
+
const o = e + t, u = e - t, l = s + i, p = s - i, d = a - r;
|
|
161
|
+
return n[0] = 2 * r / u, n[1] = 0, n[2] = 0, n[3] = 0, n[4] = 0, n[5] = 2 * r / p, n[6] = 0, n[7] = 0, n[8] = o / u, n[9] = l / p, n[10] = -a / d, n[11] = -1, n[12] = 0, n[13] = 0, n[14] = -a * r / d, n[15] = 0, n;
|
|
159
162
|
}
|
|
160
163
|
}
|
|
161
|
-
const
|
|
164
|
+
const O = class O {
|
|
162
165
|
static initCubeFace(t, e, i) {
|
|
163
166
|
let s = [0, 0, 0];
|
|
164
167
|
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));
|
|
@@ -182,7 +185,7 @@ const A = class A {
|
|
|
182
185
|
e = h.subtract(t, a), s = h.normalize(o);
|
|
183
186
|
break;
|
|
184
187
|
}
|
|
185
|
-
return new
|
|
188
|
+
return new O(e, t, s);
|
|
186
189
|
}
|
|
187
190
|
constructor(t, e, i) {
|
|
188
191
|
this.target = h.copy(t), this.eye = h.copy(e), this.up = h.copy(i);
|
|
@@ -197,12 +200,12 @@ const A = class A {
|
|
|
197
200
|
return c.inverse(c.lookAt(this.eye, this.target, this.up));
|
|
198
201
|
}
|
|
199
202
|
clone() {
|
|
200
|
-
return new
|
|
203
|
+
return new O(h.copy(this.target), h.copy(this.eye), h.copy(this.up));
|
|
201
204
|
}
|
|
202
205
|
};
|
|
203
|
-
|
|
204
|
-
let
|
|
205
|
-
class
|
|
206
|
+
O.default = new O([0, 0, 0], [2, 2, 2], [0, 1, 0]);
|
|
207
|
+
let S = O;
|
|
208
|
+
class X {
|
|
206
209
|
constructor(t) {
|
|
207
210
|
this.target = t.target;
|
|
208
211
|
const e = h.normalize(h.subtract(t.eye, t.target)), i = h.dot(e, [1, 0, 0]), s = h.dot(e, [0, 1, 0]), r = h.dot(e, [0, 0, 1]);
|
|
@@ -219,10 +222,10 @@ class B {
|
|
|
219
222
|
let n = [0, 1, 0];
|
|
220
223
|
n = c.transformPoint(r, n);
|
|
221
224
|
const o = h.subtract(t, h.mulScalar(a, this.distance));
|
|
222
|
-
return new
|
|
225
|
+
return new S(t, o, n);
|
|
223
226
|
}
|
|
224
227
|
}
|
|
225
|
-
class
|
|
228
|
+
class Y {
|
|
226
229
|
constructor() {
|
|
227
230
|
}
|
|
228
231
|
async animation(t) {
|
|
@@ -277,7 +280,7 @@ class H {
|
|
|
277
280
|
return {
|
|
278
281
|
id: t.getAttribute("id"),
|
|
279
282
|
name: t.getAttribute("name"),
|
|
280
|
-
pointOfView: new
|
|
283
|
+
pointOfView: new S(
|
|
281
284
|
[
|
|
282
285
|
parseFloat(t.querySelector("PointOfView Target").getAttribute("x")),
|
|
283
286
|
//
|
|
@@ -415,8 +418,8 @@ const g = class g {
|
|
|
415
418
|
}
|
|
416
419
|
};
|
|
417
420
|
g.xmlRegex = /directUrl="([^"]*)"/g;
|
|
418
|
-
let
|
|
419
|
-
class
|
|
421
|
+
let F = g;
|
|
422
|
+
class m {
|
|
420
423
|
constructor(t) {
|
|
421
424
|
this.server = t;
|
|
422
425
|
}
|
|
@@ -482,29 +485,29 @@ class l {
|
|
|
482
485
|
}
|
|
483
486
|
async image(t) {
|
|
484
487
|
const e = {
|
|
485
|
-
scene:
|
|
488
|
+
scene: m.scene(t),
|
|
486
489
|
mode: {
|
|
487
490
|
image: {
|
|
488
491
|
camera: t.view.camera
|
|
489
492
|
}
|
|
490
493
|
},
|
|
491
|
-
renderParameters:
|
|
492
|
-
encoder:
|
|
494
|
+
renderParameters: m.renderParameters(t),
|
|
495
|
+
encoder: m.encoder(t)
|
|
493
496
|
};
|
|
494
|
-
return
|
|
497
|
+
return m.fetchFrame(`${this.server}/Snapshot`, e);
|
|
495
498
|
}
|
|
496
499
|
async vrCube(t) {
|
|
497
500
|
const e = {
|
|
498
|
-
scene:
|
|
501
|
+
scene: m.scene(t),
|
|
499
502
|
mode: {
|
|
500
503
|
vrCube: {
|
|
501
504
|
camera: t.view.camera
|
|
502
505
|
}
|
|
503
506
|
},
|
|
504
|
-
renderParameters:
|
|
505
|
-
encoder:
|
|
507
|
+
renderParameters: m.renderParameters(t),
|
|
508
|
+
encoder: m.encoder(t)
|
|
506
509
|
};
|
|
507
|
-
return e.renderParameters.width = Math.max(e.renderParameters.width, e.renderParameters.height), e.renderParameters.height = Math.max(e.renderParameters.width, e.renderParameters.height),
|
|
510
|
+
return e.renderParameters.width = Math.max(e.renderParameters.width, e.renderParameters.height), e.renderParameters.height = Math.max(e.renderParameters.width, e.renderParameters.height), m.fetchFrameArray(`${this.server}/Snapshot`, e);
|
|
508
511
|
}
|
|
509
512
|
async vrObject(t) {
|
|
510
513
|
let e;
|
|
@@ -531,16 +534,16 @@ class l {
|
|
|
531
534
|
}
|
|
532
535
|
};
|
|
533
536
|
const i = {
|
|
534
|
-
scene:
|
|
537
|
+
scene: m.scene(t),
|
|
535
538
|
mode: e,
|
|
536
|
-
renderParameters:
|
|
537
|
-
encoder:
|
|
539
|
+
renderParameters: m.renderParameters(t),
|
|
540
|
+
encoder: m.encoder(t)
|
|
538
541
|
};
|
|
539
|
-
return
|
|
542
|
+
return m.fetchFrameArray(`${this.server}/Snapshot`, i);
|
|
540
543
|
}
|
|
541
544
|
async animation(t) {
|
|
542
545
|
const e = {
|
|
543
|
-
scene:
|
|
546
|
+
scene: m.scene(t),
|
|
544
547
|
mode: {
|
|
545
548
|
animation: {
|
|
546
549
|
id: t.view.animation,
|
|
@@ -548,45 +551,45 @@ class l {
|
|
|
548
551
|
fps: t.view.fps
|
|
549
552
|
}
|
|
550
553
|
},
|
|
551
|
-
renderParameters:
|
|
552
|
-
encoder:
|
|
554
|
+
renderParameters: m.renderParameters(t),
|
|
555
|
+
encoder: m.encoder(t)
|
|
553
556
|
};
|
|
554
|
-
return
|
|
557
|
+
return m.fetchFrameArray(`${this.server}/Snapshot`, e);
|
|
555
558
|
}
|
|
556
559
|
async imageHotspots(t, e) {
|
|
557
560
|
const i = {
|
|
558
|
-
scene:
|
|
561
|
+
scene: m.scene(t),
|
|
559
562
|
mode: {
|
|
560
563
|
image: {
|
|
561
564
|
camera: t.view.camera
|
|
562
565
|
}
|
|
563
566
|
},
|
|
564
|
-
renderParameters:
|
|
567
|
+
renderParameters: m.renderParameters(t),
|
|
565
568
|
...this.hotspotsBody(e)
|
|
566
569
|
};
|
|
567
|
-
return await
|
|
570
|
+
return await m.fetchHotspots(`${this.server}/Hotspot`, i);
|
|
568
571
|
}
|
|
569
572
|
async imagePick(t, e) {
|
|
570
573
|
const i = {
|
|
571
|
-
scene:
|
|
574
|
+
scene: m.scene(t),
|
|
572
575
|
camera: t.view.camera,
|
|
573
|
-
renderParameters:
|
|
576
|
+
renderParameters: m.renderParameters(t),
|
|
574
577
|
positions: [e]
|
|
575
578
|
};
|
|
576
|
-
return await
|
|
579
|
+
return await m.fetchPick(`${this.server}/Pick`, i);
|
|
577
580
|
}
|
|
578
581
|
async vrCubeHotspots(t, e) {
|
|
579
582
|
const i = {
|
|
580
|
-
scene:
|
|
583
|
+
scene: m.scene(t),
|
|
581
584
|
mode: {
|
|
582
585
|
vrCube: {
|
|
583
586
|
camera: t.view.camera
|
|
584
587
|
}
|
|
585
588
|
},
|
|
586
|
-
renderParameters:
|
|
589
|
+
renderParameters: m.renderParameters(t),
|
|
587
590
|
...this.hotspotsBody(e)
|
|
588
591
|
};
|
|
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
|
|
592
|
+
return i.renderParameters.width = Math.max(i.renderParameters.width, i.renderParameters.height), i.renderParameters.height = Math.max(i.renderParameters.width, i.renderParameters.height), await m.fetchHotspotsArray(`${this.server}/Hotspot`, i);
|
|
590
593
|
}
|
|
591
594
|
async vrObjectHotspots(t, e) {
|
|
592
595
|
let i;
|
|
@@ -613,12 +616,12 @@ class l {
|
|
|
613
616
|
}
|
|
614
617
|
};
|
|
615
618
|
const s = {
|
|
616
|
-
scene:
|
|
619
|
+
scene: m.scene(t),
|
|
617
620
|
mode: i,
|
|
618
|
-
renderParameters:
|
|
621
|
+
renderParameters: m.renderParameters(t),
|
|
619
622
|
...this.hotspotsBody(e)
|
|
620
623
|
};
|
|
621
|
-
return await
|
|
624
|
+
return await m.fetchHotspotsArray(`${this.server}/Hotspot`, s);
|
|
622
625
|
}
|
|
623
626
|
hotspotsBody(t) {
|
|
624
627
|
return {
|
|
@@ -627,20 +630,20 @@ class l {
|
|
|
627
630
|
};
|
|
628
631
|
}
|
|
629
632
|
}
|
|
630
|
-
class
|
|
633
|
+
class V {
|
|
631
634
|
constructor(t, e, i) {
|
|
632
635
|
switch (e) {
|
|
633
636
|
case "static":
|
|
634
|
-
this.webrender = new
|
|
637
|
+
this.webrender = new Y();
|
|
635
638
|
break;
|
|
636
639
|
case "v1":
|
|
637
|
-
this.webrender = new
|
|
640
|
+
this.webrender = new F(t), this.webrenderV2 = new m(t);
|
|
638
641
|
break;
|
|
639
642
|
case "v2":
|
|
640
|
-
this.webrender = new
|
|
643
|
+
this.webrender = new m(t), this.webrenderV2 = new m(t);
|
|
641
644
|
break;
|
|
642
645
|
default:
|
|
643
|
-
this.webrender = new
|
|
646
|
+
this.webrender = new F(t), this.webrenderV2 = new m(t);
|
|
644
647
|
break;
|
|
645
648
|
}
|
|
646
649
|
this.delegate = i, this.loadingId = 0, this.loaded = 0, this.total = 0, this.databases = [], this.onLoadStart = i && i.onLoadStart ? i.onLoadStart : () => {
|
|
@@ -677,7 +680,7 @@ class D {
|
|
|
677
680
|
}
|
|
678
681
|
async loadImage(t, e) {
|
|
679
682
|
const i = new Image();
|
|
680
|
-
i.crossOrigin = location.protocol === "file:" && !
|
|
683
|
+
i.crossOrigin = location.protocol === "file:" && !V.isValidHttpUrl(t) ? null : "anonymous";
|
|
681
684
|
const s = new Promise((r, a) => {
|
|
682
685
|
i.addEventListener(
|
|
683
686
|
"load",
|
|
@@ -699,8 +702,8 @@ class D {
|
|
|
699
702
|
this.total = t.length;
|
|
700
703
|
const r = new Array(t.length), a = i || 0;
|
|
701
704
|
for (let n = 0, o = t.length; n < o; n += 1) {
|
|
702
|
-
const u = Math.ceil(n / 2) * (n % 2 === 0 ? 1 : -1),
|
|
703
|
-
r[
|
|
705
|
+
const u = Math.ceil(n / 2) * (n % 2 === 0 ? 1 : -1), l = e ? w.mod(a + u, o) : n;
|
|
706
|
+
r[l] = this.loadImage(t[l], s);
|
|
704
707
|
}
|
|
705
708
|
return Promise.all(r).then(() => this.onLoadEnd(this.progress)).catch(() => {
|
|
706
709
|
}), r;
|
|
@@ -734,15 +737,15 @@ class D {
|
|
|
734
737
|
return;
|
|
735
738
|
}
|
|
736
739
|
t.removeEventListener("seeked", u);
|
|
737
|
-
const
|
|
738
|
-
|
|
740
|
+
const l = document.createElement("canvas");
|
|
741
|
+
l.width = t.videoWidth, l.height = t.videoHeight, l.getContext("2d").drawImage(t, 0, 0);
|
|
739
742
|
const d = new Image();
|
|
740
|
-
d.src =
|
|
743
|
+
d.src = l.toDataURL(), n(d), this.loaded += 1, this.onLoadProgress(this.progress), s !== i - 1 && (t.currentTime += 1 / e);
|
|
741
744
|
};
|
|
742
745
|
t.addEventListener("seeked", u), t.addEventListener(
|
|
743
746
|
"error",
|
|
744
|
-
(
|
|
745
|
-
r === this.loadingId && o(
|
|
747
|
+
(l) => {
|
|
748
|
+
r === this.loadingId && o(l);
|
|
746
749
|
},
|
|
747
750
|
{ once: !0 }
|
|
748
751
|
);
|
|
@@ -781,7 +784,7 @@ class D {
|
|
|
781
784
|
return this.webrenderV2 ? await this.webrenderV2.imagePick(await this.vrCubeFrameSnapshot(t, i), e) : Promise.reject(new Error("Picking only available with api V2"));
|
|
782
785
|
}
|
|
783
786
|
async convert(t) {
|
|
784
|
-
if (!this.webrenderV2 || this.webrender instanceof
|
|
787
|
+
if (!this.webrenderV2 || this.webrender instanceof m || !t.view.camera)
|
|
785
788
|
return t;
|
|
786
789
|
const e = t.scene.find((o) => !o.decor && !o.accessory);
|
|
787
790
|
if (!e)
|
|
@@ -803,7 +806,7 @@ class D {
|
|
|
803
806
|
if (!s)
|
|
804
807
|
return t;
|
|
805
808
|
let r = this.databases.find((a) => a.id === s.database);
|
|
806
|
-
if (r || (r = await this.webrender.database(s.database), this.databases.push(r)), this.webrender instanceof
|
|
809
|
+
if (r || (r = await this.webrender.database(s.database), this.databases.push(r)), this.webrender instanceof F) {
|
|
807
810
|
if (!t.view.camera)
|
|
808
811
|
return t;
|
|
809
812
|
const a = r.getCameraGroupId(t.view.camera);
|
|
@@ -814,15 +817,15 @@ class D {
|
|
|
814
817
|
return t;
|
|
815
818
|
const o = n.cameras[e];
|
|
816
819
|
return o ? { ...t, view: { ...t.view, camera: o.id } } : t;
|
|
817
|
-
} else if (this.webrender instanceof
|
|
820
|
+
} else if (this.webrender instanceof m) {
|
|
818
821
|
const a = typeof t.view.camera == "string" ? t.view.camera : t.view.camera?.id;
|
|
819
822
|
if (a) {
|
|
820
823
|
const n = r.getCameraById(a);
|
|
821
824
|
if (!n)
|
|
822
825
|
return t;
|
|
823
|
-
const o = new
|
|
826
|
+
const o = new X(n.pointOfView), u = 2 * Math.PI / i;
|
|
824
827
|
o.longitude += e * u % (2 * Math.PI);
|
|
825
|
-
const
|
|
828
|
+
const l = o.pointOfView(n.pointOfView.target);
|
|
826
829
|
return {
|
|
827
830
|
...t,
|
|
828
831
|
view: {
|
|
@@ -831,19 +834,19 @@ class D {
|
|
|
831
834
|
id: n.id,
|
|
832
835
|
pov: {
|
|
833
836
|
target: {
|
|
834
|
-
x:
|
|
835
|
-
y:
|
|
836
|
-
z:
|
|
837
|
+
x: l.target[0],
|
|
838
|
+
y: l.target[1],
|
|
839
|
+
z: l.target[2]
|
|
837
840
|
},
|
|
838
841
|
eye: {
|
|
839
|
-
x:
|
|
840
|
-
y:
|
|
841
|
-
z:
|
|
842
|
+
x: l.eye[0],
|
|
843
|
+
y: l.eye[1],
|
|
844
|
+
z: l.eye[2]
|
|
842
845
|
},
|
|
843
846
|
up: {
|
|
844
|
-
x:
|
|
845
|
-
y:
|
|
846
|
-
z:
|
|
847
|
+
x: l.up[0],
|
|
848
|
+
y: l.up[1],
|
|
849
|
+
z: l.up[2]
|
|
847
850
|
}
|
|
848
851
|
}
|
|
849
852
|
}
|
|
@@ -868,16 +871,16 @@ class D {
|
|
|
868
871
|
if (s || (s = await this.webrender.database(i.database), this.databases.push(s)), !t.view.camera)
|
|
869
872
|
return t;
|
|
870
873
|
let r;
|
|
871
|
-
if (this.webrender instanceof
|
|
872
|
-
const o = t.view.camera.split("/"), u = o.length === 2 ? o[0] : void 0,
|
|
873
|
-
r = s.getCameraId(
|
|
874
|
-
} else this.webrender instanceof
|
|
874
|
+
if (this.webrender instanceof F) {
|
|
875
|
+
const o = t.view.camera.split("/"), u = o.length === 2 ? o[0] : void 0, l = o.length === 2 ? o[1] : o[0];
|
|
876
|
+
r = s.getCameraId(l, u);
|
|
877
|
+
} else this.webrender instanceof m && (r = typeof t.view.camera == "string" ? t.view.camera : t.view.camera.id);
|
|
875
878
|
if (!r)
|
|
876
879
|
return t;
|
|
877
880
|
const a = s.getCameraById(r);
|
|
878
881
|
if (!a)
|
|
879
882
|
return t;
|
|
880
|
-
const n =
|
|
883
|
+
const n = S.initCubeFace(a.pointOfView.eye, a.pointOfView.target, e);
|
|
881
884
|
return {
|
|
882
885
|
...t,
|
|
883
886
|
view: {
|
|
@@ -932,7 +935,7 @@ class D {
|
|
|
932
935
|
return e.protocol === "http:" || e.protocol === "https:";
|
|
933
936
|
}
|
|
934
937
|
}
|
|
935
|
-
class
|
|
938
|
+
class J {
|
|
936
939
|
constructor() {
|
|
937
940
|
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");
|
|
938
941
|
}
|
|
@@ -943,11 +946,11 @@ class Y {
|
|
|
943
946
|
this.element.style.opacity = "0";
|
|
944
947
|
}
|
|
945
948
|
resize(t, e, i, s) {
|
|
946
|
-
const r =
|
|
949
|
+
const r = b.fit(i, new f(t, e), s);
|
|
947
950
|
this.element.style.top = `${r.top}px`, this.element.style.left = `${r.left}px`, this.element.style.width = `${r.width}px`, this.element.style.height = `${r.height}px`, (i.width !== this.element.width || i.height !== this.element.height) && (this.element.width = i.width, this.element.height = i.height);
|
|
948
951
|
}
|
|
949
952
|
}
|
|
950
|
-
class
|
|
953
|
+
class Q {
|
|
951
954
|
constructor(t, e, i) {
|
|
952
955
|
this.container = t, this.canvas = e, this.loader = i, this.hotspotList = [];
|
|
953
956
|
}
|
|
@@ -975,11 +978,11 @@ class J {
|
|
|
975
978
|
) : this.hotspotList = []), this.hotspotsHash = n, this.snapshotHash = a, r;
|
|
976
979
|
}
|
|
977
980
|
async pick(t, e) {
|
|
978
|
-
const i = new
|
|
981
|
+
const i = new f(t.parameters.width, t.parameters.height), s = b.unproject(i, this.canvas.resolution, this.canvas.fit, e);
|
|
979
982
|
return this.loader.loadImagePick(t, s);
|
|
980
983
|
}
|
|
981
984
|
hotspots(t) {
|
|
982
|
-
return this.hotspotList.map((e) => ({ ...e, position2D:
|
|
985
|
+
return this.hotspotList.map((e) => ({ ...e, position2D: b.project(t, this.canvas.resolution, this.canvas.fit, e.position2D) })).map((e) => ({ ...e, visibility: b.contains(this.canvas.resolution, e.position2D) ? e.visibility : "OutOfFrustum" }));
|
|
983
986
|
}
|
|
984
987
|
snapshot(t, e) {
|
|
985
988
|
return this.canvas.element.toDataURL(t, e);
|
|
@@ -1001,24 +1004,24 @@ class J {
|
|
|
1001
1004
|
onDeviceOrientation(t) {
|
|
1002
1005
|
}
|
|
1003
1006
|
}
|
|
1004
|
-
class
|
|
1007
|
+
class L {
|
|
1005
1008
|
constructor(t, e) {
|
|
1006
1009
|
this.x = t, this.y = e;
|
|
1007
1010
|
}
|
|
1008
1011
|
clone() {
|
|
1009
|
-
return new
|
|
1012
|
+
return new L(this.x, this.y);
|
|
1010
1013
|
}
|
|
1011
1014
|
}
|
|
1012
1015
|
class y {
|
|
1013
1016
|
static pointFromMouseEvent(t) {
|
|
1014
|
-
return new
|
|
1017
|
+
return new L(t.screenX, t.screenY);
|
|
1015
1018
|
}
|
|
1016
1019
|
static pointFromTouchEvent(t) {
|
|
1017
1020
|
const e = t.targetTouches[0] || t.changedTouches[0];
|
|
1018
|
-
return new
|
|
1021
|
+
return new L(e.screenX, e.screenY);
|
|
1019
1022
|
}
|
|
1020
1023
|
}
|
|
1021
|
-
class
|
|
1024
|
+
class j {
|
|
1022
1025
|
constructor(...t) {
|
|
1023
1026
|
t.length === 3 ? ({ 0: this.u, 1: this.v, 2: this.o } = t, this.w = h.cross(this.u, this.v)) : t.length === 4 ? { 0: this.u, 1: this.v, 2: this.w, 3: this.o } = t : (this.u = [1, 0, 0], this.v = [0, 1, 0], this.w = [0, 0, 1], this.o = [0, 0, 0]);
|
|
1024
1027
|
}
|
|
@@ -1035,9 +1038,9 @@ class Z {
|
|
|
1035
1038
|
this.x = t, this.y = e, this.time = i;
|
|
1036
1039
|
}
|
|
1037
1040
|
}
|
|
1038
|
-
class
|
|
1041
|
+
class R {
|
|
1039
1042
|
constructor(t) {
|
|
1040
|
-
this.points = [], this.onMotion = t, this.lastPoint = new
|
|
1043
|
+
this.points = [], this.onMotion = t, this.lastPoint = new L(0, 0), this.velocity = new L(0, 0), this.loop = this.loop.bind(this);
|
|
1041
1044
|
}
|
|
1042
1045
|
destroy() {
|
|
1043
1046
|
this.animationFrameId && (cancelAnimationFrame(this.animationFrameId), this.animationFrameId = void 0);
|
|
@@ -1050,7 +1053,7 @@ class q {
|
|
|
1050
1053
|
if (this.points.length === 0)
|
|
1051
1054
|
return;
|
|
1052
1055
|
const t = this.points[0], e = this.points[this.points.length - 1], i = e.x - t.x, s = e.y - t.y, r = e.time - t.time;
|
|
1053
|
-
this.velocity = new
|
|
1056
|
+
this.velocity = new L(r === 0 ? 0 : i / (r / 15), r === 0 ? 0 : s / (r / 15)), this.animationFrameId && (cancelAnimationFrame(this.animationFrameId), this.animationFrameId = void 0), this.animationFrameId = requestAnimationFrame(this.loop);
|
|
1054
1057
|
}
|
|
1055
1058
|
stop() {
|
|
1056
1059
|
this.animationFrameId && (cancelAnimationFrame(this.animationFrameId), this.animationFrameId = void 0), this.points = [];
|
|
@@ -1063,18 +1066,18 @@ class q {
|
|
|
1063
1066
|
this.lastPoint.x += this.velocity.x, this.lastPoint.y += this.velocity.y, this.velocity.x *= 0.9, this.velocity.y *= 0.9, this.onMotion(this.lastPoint.clone()), this.animationFrameId = requestAnimationFrame(this.loop);
|
|
1064
1067
|
}
|
|
1065
1068
|
}
|
|
1066
|
-
class
|
|
1069
|
+
class W {
|
|
1067
1070
|
constructor(t, e, i) {
|
|
1068
|
-
this.isStarted = !1, this.pov = t, this.fov = w.degreesToRadians(e), this.orientationMatrix = c.identity(), this.inertia = new
|
|
1071
|
+
this.isStarted = !1, this.pov = t, this.fov = w.degreesToRadians(e), this.orientationMatrix = c.identity(), this.inertia = new R(this.motion.bind(this)), this.onMotion = i, this.initPov = this.pov, this.initFov = this.fov, this.initOrientation = w.degreesToRadians(window.orientation) || 0, this.startPov = new S([0, 0, 1], [0, 0, 0], [0, 1, 0]), this.startSize = { width: 0, height: 0 }, this.previousPoint = new L(0, 0);
|
|
1069
1072
|
}
|
|
1070
1073
|
destroy() {
|
|
1071
1074
|
this.inertia.destroy();
|
|
1072
1075
|
}
|
|
1073
1076
|
get orientedPov() {
|
|
1074
|
-
const t = h.normalize(h.cross(this.pov.up, this.pov.target)), e = new
|
|
1077
|
+
const t = h.normalize(h.cross(this.pov.up, this.pov.target)), e = new j(t, [0, 1, 0], this.pov.eye), i = c.identity();
|
|
1075
1078
|
c.multiply(i, e.localToGlobalMatrix, i), c.multiply(i, this.orientationMatrix, i), c.multiply(i, e.globalToLocalMatrix, i);
|
|
1076
1079
|
const s = c.transformDirection(i, this.pov.target), r = this.pov.eye, a = c.transformDirection(i, this.pov.up);
|
|
1077
|
-
return new
|
|
1080
|
+
return new S(s, r, a);
|
|
1078
1081
|
}
|
|
1079
1082
|
reset() {
|
|
1080
1083
|
this.pov = this.initPov.clone(), this.fov = this.initFov;
|
|
@@ -1087,10 +1090,10 @@ class Q {
|
|
|
1087
1090
|
const e = {
|
|
1088
1091
|
x: t.x - this.previousPoint.x,
|
|
1089
1092
|
y: t.y - this.previousPoint.y
|
|
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
|
|
1093
|
+
}, 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 j(a, [0, 1, 0], this.pov.eye), o = c.identity();
|
|
1091
1094
|
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),
|
|
1093
|
-
h.cross(
|
|
1095
|
+
const u = c.transformPoint(o, this.pov.target), l = c.transformDirection(o, this.pov.up);
|
|
1096
|
+
h.cross(l, [0, 0, 1])[0] >= 0 && (this.pov.target = u, this.pov.up = l), this.previousPoint = t, this.onMotion();
|
|
1094
1097
|
}
|
|
1095
1098
|
end(t, e) {
|
|
1096
1099
|
this.isStarted = !1, e && (this.inertia.track(t), this.inertia.start());
|
|
@@ -1100,7 +1103,7 @@ class Q {
|
|
|
1100
1103
|
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();
|
|
1101
1104
|
}
|
|
1102
1105
|
}
|
|
1103
|
-
var
|
|
1106
|
+
var _ = `precision mediump float;
|
|
1104
1107
|
|
|
1105
1108
|
uniform float u_mix;
|
|
1106
1109
|
uniform samplerCube u_texture;
|
|
@@ -1112,7 +1115,7 @@ void main() {
|
|
|
1112
1115
|
vec4 backColor = textureCube(u_texture_back, direction);
|
|
1113
1116
|
vec4 color = textureCube(u_texture, direction);
|
|
1114
1117
|
gl_FragColor = mix(backColor, color, u_mix);
|
|
1115
|
-
}`,
|
|
1118
|
+
}`, K = `attribute vec4 position;
|
|
1116
1119
|
|
|
1117
1120
|
uniform mat4 u_mvpi;
|
|
1118
1121
|
|
|
@@ -1122,27 +1125,27 @@ void main() {
|
|
|
1122
1125
|
direction = (u_mvpi * position).xyz;
|
|
1123
1126
|
gl_Position = position;
|
|
1124
1127
|
}`;
|
|
1125
|
-
class
|
|
1126
|
-
constructor(t, e, i, s) {
|
|
1127
|
-
this.container = t, this.canvas = e, this.loader = i, this.images = [], this.hotspotsList = [[]];
|
|
1128
|
-
const
|
|
1129
|
-
c.transformDirection(
|
|
1128
|
+
class tt {
|
|
1129
|
+
constructor(t, e, i, s, r) {
|
|
1130
|
+
this.container = t, this.canvas = e, this.loader = i, this.aspectRatioOverride = r, this.images = [], this.hotspotsList = [[]];
|
|
1131
|
+
const a = new S([0, 0, 1], [0, 0, 0], [0, 1, 0]), n = 60, o = c.rotationX(w.degreesToRadians(15));
|
|
1132
|
+
c.transformDirection(o, a.target, a.target), c.transformDirection(o, a.up, a.up), this.interaction = new W(a, n, () => {
|
|
1130
1133
|
this.animationFrameId = requestAnimationFrame(this.render), this.onInteraction({
|
|
1131
1134
|
pov: this.interaction.pov.clone(),
|
|
1132
1135
|
fov: this.interaction.fov
|
|
1133
1136
|
});
|
|
1134
|
-
}), this.onInteraction = s, this.gl = this.canvas.context, this.programInfo =
|
|
1135
|
-
`, `${
|
|
1136
|
-
`]), this.quad =
|
|
1137
|
+
}), this.onInteraction = s, this.gl = this.canvas.context, this.programInfo = M.createProgramInfo(this.gl, [`${K}
|
|
1138
|
+
`, `${_}
|
|
1139
|
+
`]), this.quad = M.primitives.createXYQuadBufferInfo(this.gl), this.uniforms = {
|
|
1137
1140
|
u_mvpi: c.identity(),
|
|
1138
1141
|
u_mix: 0,
|
|
1139
|
-
u_texture_back:
|
|
1142
|
+
u_texture_back: M.createTexture(this.gl, {
|
|
1140
1143
|
target: this.gl.TEXTURE_CUBE_MAP,
|
|
1141
1144
|
minMag: this.gl.LINEAR,
|
|
1142
1145
|
width: 1,
|
|
1143
1146
|
height: 1
|
|
1144
1147
|
}),
|
|
1145
|
-
u_texture:
|
|
1148
|
+
u_texture: M.createTexture(this.gl, {
|
|
1146
1149
|
target: this.gl.TEXTURE_CUBE_MAP,
|
|
1147
1150
|
minMag: this.gl.LINEAR,
|
|
1148
1151
|
width: 1,
|
|
@@ -1180,7 +1183,7 @@ class K {
|
|
|
1180
1183
|
const a = JSON.stringify(t);
|
|
1181
1184
|
a === this.snapshotHash ? r = r.then(() => (this.animationFrameId = requestAnimationFrame(this.render), Promise.resolve())) : (this.images = [], this.animationFrameId = requestAnimationFrame(this.render), r = r.then(
|
|
1182
1185
|
() => this.loader.loadVRCubeSnapshot(t).then((o) => {
|
|
1183
|
-
this.images = o,
|
|
1186
|
+
this.images = o, M.createTexture(
|
|
1184
1187
|
this.gl,
|
|
1185
1188
|
{
|
|
1186
1189
|
target: this.gl.TEXTURE_CUBE_MAP,
|
|
@@ -1197,8 +1200,8 @@ class K {
|
|
|
1197
1200
|
],
|
|
1198
1201
|
src: o
|
|
1199
1202
|
},
|
|
1200
|
-
(u,
|
|
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 =
|
|
1203
|
+
(u, l) => {
|
|
1204
|
+
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 = l, this.animationFrameId = requestAnimationFrame(this.render));
|
|
1202
1205
|
}
|
|
1203
1206
|
);
|
|
1204
1207
|
})
|
|
@@ -1211,35 +1214,35 @@ class K {
|
|
|
1211
1214
|
) : this.hotspotsList = [[]]), this.hotspotsHash = n, this.snapshotHash = a, r;
|
|
1212
1215
|
}
|
|
1213
1216
|
async pick(t, e) {
|
|
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],
|
|
1215
|
-
let
|
|
1216
|
-
Math.abs(d[0]) === T ?
|
|
1217
|
-
let x = 0,
|
|
1218
|
-
switch (
|
|
1217
|
+
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], l = this.modelViewProjectionMatrix, p = c.inverse(l), d = h.normalize(c.transformPoint(p, u)), T = Math.max(Math.abs(d[0]), Math.abs(d[1]), Math.abs(d[2]));
|
|
1218
|
+
let A = "";
|
|
1219
|
+
Math.abs(d[0]) === T ? A = d[0] > 0 ? "XPOS" : "XNEG" : Math.abs(d[1]) === T ? A = d[1] > 0 ? "YPOS" : "YNEG" : A = d[2] > 0 ? "ZPOS" : "ZNEG";
|
|
1220
|
+
let x = 0, E = 0, I = "";
|
|
1221
|
+
switch (A) {
|
|
1219
1222
|
case "XPOS":
|
|
1220
|
-
x = (-d[2] / Math.abs(d[0]) + 1) / 2,
|
|
1223
|
+
x = (-d[2] / Math.abs(d[0]) + 1) / 2, E = (-d[1] / Math.abs(d[0]) + 1) / 2, I = "right";
|
|
1221
1224
|
break;
|
|
1222
1225
|
case "XNEG":
|
|
1223
|
-
x = (d[2] / Math.abs(d[0]) + 1) / 2,
|
|
1226
|
+
x = (d[2] / Math.abs(d[0]) + 1) / 2, E = (-d[1] / Math.abs(d[0]) + 1) / 2, I = "left";
|
|
1224
1227
|
break;
|
|
1225
1228
|
case "YPOS":
|
|
1226
|
-
x = (d[0] / Math.abs(d[1]) + 1) / 2,
|
|
1229
|
+
x = (d[0] / Math.abs(d[1]) + 1) / 2, E = (d[2] / Math.abs(d[1]) + 1) / 2, I = "up";
|
|
1227
1230
|
break;
|
|
1228
1231
|
case "YNEG":
|
|
1229
|
-
x = (d[0] / Math.abs(d[1]) + 1) / 2,
|
|
1232
|
+
x = (d[0] / Math.abs(d[1]) + 1) / 2, E = (-d[2] / Math.abs(d[1]) + 1) / 2, I = "down";
|
|
1230
1233
|
break;
|
|
1231
1234
|
case "ZPOS":
|
|
1232
|
-
x = (d[0] / Math.abs(d[2]) + 1) / 2,
|
|
1235
|
+
x = (d[0] / Math.abs(d[2]) + 1) / 2, E = (-d[1] / Math.abs(d[2]) + 1) / 2, I = "front";
|
|
1233
1236
|
break;
|
|
1234
1237
|
case "ZNEG":
|
|
1235
|
-
x = (-d[0] / Math.abs(d[2]) + 1) / 2,
|
|
1238
|
+
x = (-d[0] / Math.abs(d[2]) + 1) / 2, E = (-d[1] / Math.abs(d[2]) + 1) / 2, I = "back";
|
|
1236
1239
|
break;
|
|
1237
1240
|
}
|
|
1238
|
-
const
|
|
1241
|
+
const C = {
|
|
1239
1242
|
x: Math.round(x * Math.max(t.parameters.width, t.parameters.height)),
|
|
1240
|
-
y: Math.round(
|
|
1243
|
+
y: Math.round(E * Math.max(t.parameters.width, t.parameters.height))
|
|
1241
1244
|
};
|
|
1242
|
-
return this.loader.loadVRCubePick(t,
|
|
1245
|
+
return this.loader.loadVRCubePick(t, C, I);
|
|
1243
1246
|
}
|
|
1244
1247
|
hotspots() {
|
|
1245
1248
|
const t = [];
|
|
@@ -1247,36 +1250,36 @@ class K {
|
|
|
1247
1250
|
return [];
|
|
1248
1251
|
const e = this.hotspotsList[0]?.length ?? 0, i = this.modelViewProjectionMatrix;
|
|
1249
1252
|
for (let s = 0; s < e; s++) {
|
|
1250
|
-
const r = this.hotspotsList.findIndex((
|
|
1253
|
+
const r = this.hotspotsList.findIndex(($) => $[s].visibility !== "OutOfFrustum");
|
|
1251
1254
|
if (r === -1)
|
|
1252
1255
|
continue;
|
|
1253
1256
|
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,
|
|
1257
|
+
let u = 0, l = 0, p = 0;
|
|
1255
1258
|
switch (r) {
|
|
1256
1259
|
case 0:
|
|
1257
|
-
this.pov.target[2] < 0 && (a.visibility = "OutOfFrustum"), u = 2 * n - 1,
|
|
1260
|
+
this.pov.target[2] < 0 && (a.visibility = "OutOfFrustum"), u = 2 * n - 1, l = 1 - 2 * o, p = 1;
|
|
1258
1261
|
break;
|
|
1259
1262
|
case 1:
|
|
1260
|
-
this.pov.target[0] > 0 && (a.visibility = "OutOfFrustum"), u = 1,
|
|
1263
|
+
this.pov.target[0] > 0 && (a.visibility = "OutOfFrustum"), u = 1, l = 1 - 2 * o, p = 1 - 2 * n;
|
|
1261
1264
|
break;
|
|
1262
1265
|
case 2:
|
|
1263
|
-
this.pov.target[2] > 0 && (a.visibility = "OutOfFrustum"), u = 1 - 2 * n,
|
|
1266
|
+
this.pov.target[2] > 0 && (a.visibility = "OutOfFrustum"), u = 1 - 2 * n, l = 1 - 2 * o, p = -1;
|
|
1264
1267
|
break;
|
|
1265
1268
|
case 3:
|
|
1266
|
-
this.pov.target[0] < 0 && (a.visibility = "OutOfFrustum"), u = -1,
|
|
1269
|
+
this.pov.target[0] < 0 && (a.visibility = "OutOfFrustum"), u = -1, l = 1 - 2 * o, p = 2 * n - 1;
|
|
1267
1270
|
break;
|
|
1268
1271
|
case 4:
|
|
1269
|
-
this.pov.target[1] < 0 && (a.visibility = "OutOfFrustum"), u = 2 * n - 1,
|
|
1272
|
+
this.pov.target[1] < 0 && (a.visibility = "OutOfFrustum"), u = 2 * n - 1, l = 1, p = 2 * o - 1;
|
|
1270
1273
|
break;
|
|
1271
1274
|
case 5:
|
|
1272
|
-
this.pov.target[1] > 0 && (a.visibility = "OutOfFrustum"), u = 2 * n - 1,
|
|
1275
|
+
this.pov.target[1] > 0 && (a.visibility = "OutOfFrustum"), u = 2 * n - 1, l = -1, p = 1 - 2 * o;
|
|
1273
1276
|
break;
|
|
1274
1277
|
}
|
|
1275
|
-
const d = h.normalize([u,
|
|
1276
|
-
x: Math.round(
|
|
1277
|
-
y: Math.round(x -
|
|
1278
|
-
}, G = new
|
|
1279
|
-
t.push({ ...a, position2D:
|
|
1278
|
+
const d = h.normalize([u, l, p]), T = c.transformPoint(i, d), A = this.canvas.element.clientWidth, x = this.canvas.element.clientHeight, E = 0.5 * A * (T[0] + 1), I = 0.5 * x * (T[1] + 1), C = {
|
|
1279
|
+
x: Math.round(E),
|
|
1280
|
+
y: Math.round(x - I)
|
|
1281
|
+
}, G = new f(A, x), z = b.contains(G, C) ? a.visibility : "OutOfFrustum";
|
|
1282
|
+
t.push({ ...a, position2D: C, visibility: z });
|
|
1280
1283
|
}
|
|
1281
1284
|
return t;
|
|
1282
1285
|
}
|
|
@@ -1284,11 +1287,11 @@ class K {
|
|
|
1284
1287
|
return this.canvas.element.toDataURL(t, e);
|
|
1285
1288
|
}
|
|
1286
1289
|
get modelViewProjectionMatrix() {
|
|
1287
|
-
const t = this.canvas.element.clientWidth, e = this.canvas.element.clientHeight, i = t > e ? t / e : e / t, s =
|
|
1290
|
+
const t = this.canvas.element.clientWidth, e = this.canvas.element.clientHeight, i = t > e ? t / e : e / t, s = b.getStandardAspectRatio(t, e, this.aspectRatioOverride), 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
1291
|
return c.multiply(c.multiply(n, u), a);
|
|
1289
1292
|
}
|
|
1290
1293
|
render() {
|
|
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),
|
|
1294
|
+
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), M.setBuffersAndAttributes(this.gl, this.programInfo, this.quad), M.setUniforms(this.programInfo, this.uniforms), M.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));
|
|
1292
1295
|
}
|
|
1293
1296
|
onMouseDown(t) {
|
|
1294
1297
|
this.container.classList.add("ls-viewer-container-vrcube-grabbing"), this.interaction.start(y.pointFromMouseEvent(t), {
|
|
@@ -1321,9 +1324,9 @@ class K {
|
|
|
1321
1324
|
this.interaction.orientation(t.alpha, t.beta, t.gamma);
|
|
1322
1325
|
}
|
|
1323
1326
|
}
|
|
1324
|
-
class
|
|
1327
|
+
class et {
|
|
1325
1328
|
constructor(t, e, i, s, r) {
|
|
1326
|
-
this.isStarted = !1, this.position = t, this.frames = e, this.rows = i, this.loop = s, this.onMotion = r, this.inertia = new
|
|
1329
|
+
this.isStarted = !1, this.position = t, this.frames = e, this.rows = i, this.loop = s, this.onMotion = r, this.inertia = new R(this.motion.bind(this)), this.initPosition = { ...this.position }, this.startPosition = { x: 0, y: 0 }, this.startPoint = new L(0, 0), this.startSize = { width: 0, height: 0 }, this.lastPoints = [], this.lastPointsNumber = 20;
|
|
1327
1330
|
}
|
|
1328
1331
|
destroy() {
|
|
1329
1332
|
this.inertia.destroy();
|
|
@@ -1345,7 +1348,7 @@ class tt {
|
|
|
1345
1348
|
}
|
|
1346
1349
|
motion(t) {
|
|
1347
1350
|
this.isStarted && this.inertia.track(t), this.lastPoints.push({ x: t.x, y: t.y }), this.lastPoints.splice(0, this.lastPoints.length - this.lastPointsNumber);
|
|
1348
|
-
const e =
|
|
1351
|
+
const e = U.linear(this.lastPoints.map((s) => [s.x, s.y])), i = 25;
|
|
1349
1352
|
if (Math.abs(e.equation[0]) < 1) {
|
|
1350
1353
|
const s = w.accelerate(t.x - this.startPoint.x, 1.3) / this.startSize.width * (this.frames / 4);
|
|
1351
1354
|
let r = this.startPosition.x - Math.round(s);
|
|
@@ -1366,7 +1369,7 @@ class tt {
|
|
|
1366
1369
|
}
|
|
1367
1370
|
class k {
|
|
1368
1371
|
constructor(t, e, i, s) {
|
|
1369
|
-
this.container = t, this.canvas = e, this.loader = i, this.images = [], this.frames = 24, this.hotspotsList = [[]], this.interaction = new
|
|
1372
|
+
this.container = t, this.canvas = e, this.loader = i, this.images = [], this.frames = 24, this.hotspotsList = [[]], this.interaction = new et({ x: 0, y: 0 }, 1, 1, !1, () => {
|
|
1370
1373
|
this.canvas.draw(this.image, !0, 0.5), this.onInteraction({
|
|
1371
1374
|
position: this.interaction.positionIndex
|
|
1372
1375
|
});
|
|
@@ -1411,9 +1414,9 @@ class k {
|
|
|
1411
1414
|
a === this.snapshotHash && this.image ? r = r.then(() => this.canvas.draw(this.image, s, 0.05)) : (this.images = [], r = r.then(
|
|
1412
1415
|
() => this.loader.loadVRObjectSnapshot(t, this.interaction.positionIndex).then((o) => {
|
|
1413
1416
|
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((
|
|
1415
|
-
|
|
1416
|
-
this.images[
|
|
1417
|
+
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((l, p) => {
|
|
1418
|
+
l.then((d) => {
|
|
1419
|
+
this.images[p] = d, d === this.image && this.canvas.draw(this.image, s, 0.05);
|
|
1417
1420
|
}).catch(() => {
|
|
1418
1421
|
});
|
|
1419
1422
|
}), o[this.interaction.positionIndex].then(() => Promise.resolve());
|
|
@@ -1427,11 +1430,11 @@ class k {
|
|
|
1427
1430
|
) : this.hotspotsList = [[]]), this.hotspotsHash = n, this.snapshotHash = a, r;
|
|
1428
1431
|
}
|
|
1429
1432
|
async pick(t, e) {
|
|
1430
|
-
const i = new
|
|
1433
|
+
const i = new f(t.parameters.width, t.parameters.height), s = b.unproject(i, this.canvas.resolution, this.canvas.fit, e);
|
|
1431
1434
|
return this.loader.loadVRObjectPick(t, s, this.position, this.frames);
|
|
1432
1435
|
}
|
|
1433
1436
|
hotspots(t) {
|
|
1434
|
-
return (this.hotspotsList[this.interaction.positionIndex] || []).map((i) => ({ ...i, position2D:
|
|
1437
|
+
return (this.hotspotsList[this.interaction.positionIndex] || []).map((i) => ({ ...i, position2D: b.project(t, this.canvas.resolution, this.canvas.fit, i.position2D) })).map((i) => ({ ...i, visibility: b.contains(this.canvas.resolution, i.position2D) ? i.visibility : "OutOfFrustum" }));
|
|
1435
1438
|
}
|
|
1436
1439
|
snapshot(t, e) {
|
|
1437
1440
|
return this.canvas.element.toDataURL(t, e);
|
|
@@ -1466,7 +1469,7 @@ class k {
|
|
|
1466
1469
|
onDeviceOrientation(t) {
|
|
1467
1470
|
}
|
|
1468
1471
|
}
|
|
1469
|
-
class
|
|
1472
|
+
class it {
|
|
1470
1473
|
constructor(t, e, i) {
|
|
1471
1474
|
this.container = t, this.loader = i, this.video = e;
|
|
1472
1475
|
}
|
|
@@ -1519,7 +1522,7 @@ class et {
|
|
|
1519
1522
|
onDeviceOrientation(t) {
|
|
1520
1523
|
}
|
|
1521
1524
|
}
|
|
1522
|
-
class
|
|
1525
|
+
class nt {
|
|
1523
1526
|
constructor(t, e) {
|
|
1524
1527
|
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 = {
|
|
1525
1528
|
server: "localhost",
|
|
@@ -1550,7 +1553,7 @@ class at {
|
|
|
1550
1553
|
onHotspotsChange: () => {
|
|
1551
1554
|
},
|
|
1552
1555
|
...e.events
|
|
1553
|
-
}, this.options.events.onLoadError =
|
|
1556
|
+
}, this.options.events.onLoadError = D(this.options.events.onLoadError, 10), this.container = t, this.container.classList.add("ls-viewer-container"), this.containerWidth = 0, this.containerHeight = 0, this.canvas2D = new N(this.options.fit), this.container.prepend(this.canvas2D.element), this.canvas3D = new B(), this.container.prepend(this.canvas3D.element), this.video = new J(), this.container.prepend(this.video.element), this.loader = new V(this.options.server, this.options.api, this), this.resolution = new f(0, 0), this.parameters = {
|
|
1554
1557
|
width: 0,
|
|
1555
1558
|
height: 0,
|
|
1556
1559
|
antialiasing: !1,
|
|
@@ -1558,7 +1561,7 @@ class at {
|
|
|
1558
1561
|
}, this.encoder = {
|
|
1559
1562
|
format: "jpeg",
|
|
1560
1563
|
quality: 80
|
|
1561
|
-
}, this.hotspots = [], this.widgetImage = new
|
|
1564
|
+
}, this.hotspots = [], this.widgetImage = new Q(t, this.canvas2D, this.loader), this.widgetVideo = new it(t, this.video, this.loader), this.widgetVRObject = new k(t, this.canvas2D, this.loader, this.onVrobjectInteraction), this.canvas3D.context && (this.widgetVRCube = new tt(t, this.canvas3D, this.loader, this.onVrcubeInteraction, this.aspectRatioOverride)), 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 = D(this.loadWidget, 10), this.onResize = D(this.onResize, 250), requestAnimationFrame(this.checkResize);
|
|
1562
1565
|
}
|
|
1563
1566
|
destroy() {
|
|
1564
1567
|
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;
|
|
@@ -1577,7 +1580,7 @@ class at {
|
|
|
1577
1580
|
}), e;
|
|
1578
1581
|
}
|
|
1579
1582
|
setParameters(t) {
|
|
1580
|
-
t.width && t.height && (this.resolution = new
|
|
1583
|
+
t.width && t.height && (this.resolution = new f(t.width, t.height)), this.parameters = { ...t }, this.parameters.width = this.resolution.width, this.parameters.height = this.resolution.height;
|
|
1581
1584
|
let e = Promise.resolve();
|
|
1582
1585
|
return e = e.then(() => this.loadWidget(!1, !0)), e.catch((i) => {
|
|
1583
1586
|
this.onLoadError(i);
|
|
@@ -1664,6 +1667,16 @@ class at {
|
|
|
1664
1667
|
this.widget.hide(), this.widget = i, this.widget.show(), this.widgetVideo.hide(), this.onHotspotsChange();
|
|
1665
1668
|
});
|
|
1666
1669
|
}
|
|
1670
|
+
get aspectRatioOverride() {
|
|
1671
|
+
switch (this.options.aspectRatio) {
|
|
1672
|
+
case "4:3":
|
|
1673
|
+
return 4 / 3;
|
|
1674
|
+
case "16:9":
|
|
1675
|
+
return 16 / 9;
|
|
1676
|
+
default:
|
|
1677
|
+
return;
|
|
1678
|
+
}
|
|
1679
|
+
}
|
|
1667
1680
|
get viewWidget() {
|
|
1668
1681
|
switch (this.view?.mode) {
|
|
1669
1682
|
case "image":
|
|
@@ -1710,7 +1723,7 @@ class at {
|
|
|
1710
1723
|
}
|
|
1711
1724
|
onResize() {
|
|
1712
1725
|
const t = this.container.clientWidth, e = this.container.clientHeight;
|
|
1713
|
-
this.options.autores && (this.resolution =
|
|
1726
|
+
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, window.devicePixelRatio), this.canvas3D.resize(t, e, window.devicePixelRatio), this.video.resize(t, e, this.resolution, this.options.fit), this.loadWidget(!1, !1).then(() => {
|
|
1714
1727
|
this.onHotspotsChange();
|
|
1715
1728
|
}).catch((i) => {
|
|
1716
1729
|
this.onLoadError(i);
|
|
@@ -1739,7 +1752,7 @@ class at {
|
|
|
1739
1752
|
this.container.classList.remove("ls-viewer-container-loading"), this.options.events.onLoadError(...t);
|
|
1740
1753
|
}
|
|
1741
1754
|
}
|
|
1742
|
-
var
|
|
1755
|
+
var q;
|
|
1743
1756
|
((v) => {
|
|
1744
1757
|
((t) => {
|
|
1745
1758
|
t.Visible = "Visible", t.Occluded = "Occluded", t.Clipped = "Clipped", t.OutOfFrustum = "OutOfFrustum";
|
|
@@ -1752,12 +1765,12 @@ var j;
|
|
|
1752
1765
|
})(v.SunUseCaseMode || (v.SunUseCaseMode = {})), ((t) => {
|
|
1753
1766
|
t.ShowOnly = "showOnly", t.HideOnly = "hideOnly";
|
|
1754
1767
|
})(v.SurfacesFilterMode || (v.SurfacesFilterMode = {}));
|
|
1755
|
-
})(
|
|
1768
|
+
})(q || (q = {}));
|
|
1756
1769
|
export {
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1770
|
+
nt as Viewer,
|
|
1771
|
+
q as WRAPIv2,
|
|
1772
|
+
Q as WidgetImage,
|
|
1773
|
+
tt as WidgetVRCube,
|
|
1761
1774
|
k as WidgetVRObject,
|
|
1762
|
-
|
|
1775
|
+
it as WidgetVideo
|
|
1763
1776
|
};
|