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