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