@lumiscaphe/viewer 4.1.14 → 4.1.16
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/CLAUDE.md +174 -0
- package/dist/lib/index.cjs +5 -5
- package/dist/lib/index.d.ts +101 -63
- package/dist/lib/index.js +206 -211
- package/package.json +10 -13
package/dist/lib/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".ls-viewer-container{display:block;position:relative;overflow:hidden;-webkit-user-select:none;user-select:none;width:100%;height:100%}.ls-viewer-container-image,.ls-viewer-container-video{cursor:default;pointer-events:none}.ls-viewer-container-vrcube{cursor:pointer;cursor:grab}.ls-viewer-container-vrcube-grabbing{cursor:move;cursor:grabbing}.ls-viewer-container-vrobject{cursor:move;cursor:grab}.ls-viewer-container-vrobject-grabbing{cursor:move;cursor:grabbing}.ls-viewer-container-loading{cursor:progress}.ls-viewer-canvas{position:absolute;opacity:0;transition:opacity .5s}.ls-viewer-video{position:absolute}")),document.head.appendChild(e)}}catch(r){console.error("vite-plugin-css-injected-by-js",r)}})();
|
|
2
|
-
import
|
|
3
|
-
import * as
|
|
4
|
-
import { v3 as h, m4 as
|
|
5
|
-
import
|
|
2
|
+
import k from "debounce-promise";
|
|
3
|
+
import * as P from "twgl.js";
|
|
4
|
+
import { v3 as h, m4 as c } from "twgl.js";
|
|
5
|
+
import $ from "regression";
|
|
6
6
|
class b {
|
|
7
7
|
constructor(t, e) {
|
|
8
8
|
this.width = t, this.height = e;
|
|
@@ -33,8 +33,8 @@ class p {
|
|
|
33
33
|
n = e.width, a = e.height;
|
|
34
34
|
break;
|
|
35
35
|
}
|
|
36
|
-
const o = (e.height - a) / 2,
|
|
37
|
-
return new p(o,
|
|
36
|
+
const o = (e.height - a) / 2, l = (e.width - n) / 2;
|
|
37
|
+
return new p(o, l, n, a);
|
|
38
38
|
}
|
|
39
39
|
static project(t, e, i, s) {
|
|
40
40
|
const r = p.fit(t, e, i), n = r.width / t.width, a = r.height / t.height;
|
|
@@ -76,7 +76,7 @@ class p {
|
|
|
76
76
|
return t <= 240 ? 240 : t <= 360 ? 360 : t <= 480 ? 480 : t <= 720 ? 720 : 1080;
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
-
class
|
|
79
|
+
class U {
|
|
80
80
|
constructor(t) {
|
|
81
81
|
this.element = document.createElement("canvas"), this.element.classList.add("ls-viewer-canvas"), this.element.style.opacity = "0", this.element.width = 0, this.element.height = 0, this.context = this.element.getContext("2d"), this.backCanvas = document.createElement("canvas"), this.backContext = this.backCanvas.getContext("2d"), this.fit = t, this.pixelRatio = 1;
|
|
82
82
|
}
|
|
@@ -113,9 +113,9 @@ class N {
|
|
|
113
113
|
});
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
|
-
class
|
|
116
|
+
class N {
|
|
117
117
|
constructor() {
|
|
118
|
-
this.element = document.createElement("canvas"), this.element.classList.add("ls-viewer-canvas"), this.element.style.opacity = "0", this.element.width = 0, this.element.height = 0, this.context =
|
|
118
|
+
this.element = document.createElement("canvas"), this.element.classList.add("ls-viewer-canvas"), this.element.style.opacity = "0", this.element.width = 0, this.element.height = 0, this.context = P.getContext(this.element, { preserveDrawingBuffer: !0 }), this.context && this.context.isContextLost() && (this.context = void 0), P.setDefaults({ textureColor: [1, 1, 1, 1] });
|
|
119
119
|
}
|
|
120
120
|
show() {
|
|
121
121
|
this.element.style.opacity = "1";
|
|
@@ -154,8 +154,8 @@ class w {
|
|
|
154
154
|
}
|
|
155
155
|
static perspectiveWithLeft(t, e, i, s, r, n, a) {
|
|
156
156
|
a = a || new Float32Array(16);
|
|
157
|
-
const o = e + t,
|
|
158
|
-
return a[0] = 2 * r /
|
|
157
|
+
const o = e + t, l = e - t, u = s + i, f = s - i, d = n - r;
|
|
158
|
+
return a[0] = 2 * r / l, a[1] = 0, a[2] = 0, a[3] = 0, a[4] = 0, a[5] = 2 * r / f, a[6] = 0, a[7] = 0, a[8] = o / l, a[9] = u / f, a[10] = -n / d, a[11] = -1, a[12] = 0, a[13] = 0, a[14] = -n * r / d, a[15] = 0, a;
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
161
|
const A = class A {
|
|
@@ -194,7 +194,7 @@ const A = class A {
|
|
|
194
194
|
return h.normalize(h.cross(this.viewVector, this.up));
|
|
195
195
|
}
|
|
196
196
|
get viewMatrix() {
|
|
197
|
-
return
|
|
197
|
+
return c.inverse(c.lookAt(this.eye, this.target, this.up));
|
|
198
198
|
}
|
|
199
199
|
clone() {
|
|
200
200
|
return new A(h.copy(this.target), h.copy(this.eye), h.copy(this.up));
|
|
@@ -202,7 +202,7 @@ const A = class A {
|
|
|
202
202
|
};
|
|
203
203
|
A.default = new A([0, 0, 0], [2, 2, 2], [0, 1, 0]);
|
|
204
204
|
let L = A;
|
|
205
|
-
class
|
|
205
|
+
class B {
|
|
206
206
|
constructor(t) {
|
|
207
207
|
this.target = t.target;
|
|
208
208
|
const e = h.normalize(h.subtract(t.eye, t.target)), i = h.dot(e, [1, 0, 0]), s = h.dot(e, [0, 1, 0]), r = h.dot(e, [0, 0, 1]);
|
|
@@ -213,16 +213,16 @@ class X {
|
|
|
213
213
|
return [i, e, s];
|
|
214
214
|
}
|
|
215
215
|
pointOfView(t) {
|
|
216
|
-
const e =
|
|
216
|
+
const e = c.rotationY(this.longitude), i = c.rotationX(-this.latitude), s = c.rotationZ(0), r = c.multiply(e, c.multiply(i, s));
|
|
217
217
|
let n = [0, 0, -1];
|
|
218
|
-
n =
|
|
218
|
+
n = c.transformPoint(r, n);
|
|
219
219
|
let a = [0, 1, 0];
|
|
220
|
-
a =
|
|
220
|
+
a = c.transformPoint(r, a);
|
|
221
221
|
const o = h.subtract(t, h.mulScalar(n, this.distance));
|
|
222
222
|
return new L(t, o, a);
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
|
-
class
|
|
225
|
+
class X {
|
|
226
226
|
constructor() {
|
|
227
227
|
}
|
|
228
228
|
async animation(t) {
|
|
@@ -244,17 +244,15 @@ class Y {
|
|
|
244
244
|
return t.scene;
|
|
245
245
|
}
|
|
246
246
|
}
|
|
247
|
-
class
|
|
247
|
+
class H {
|
|
248
248
|
constructor(t) {
|
|
249
249
|
this.xmlDoc = t;
|
|
250
250
|
}
|
|
251
251
|
get id() {
|
|
252
|
-
|
|
253
|
-
return (t = this.xmlDoc.getElementsByTagName("Database")[0]) == null ? void 0 : t.getAttribute("id");
|
|
252
|
+
return this.xmlDoc.getElementsByTagName("Database")[0]?.getAttribute("id");
|
|
254
253
|
}
|
|
255
254
|
getCameraId(t, e) {
|
|
256
|
-
|
|
257
|
-
return e ? (i = this.xmlDoc.querySelector(`RootCameraGroup Group[name="${e}"] Camera[name="${t}"]`)) == null ? void 0 : i.getAttribute("id") : (s = this.xmlDoc.querySelector(`RootCameraGroup Camera[name="${t}"]`)) == null ? void 0 : s.getAttribute("id");
|
|
255
|
+
return e ? this.xmlDoc.querySelector(`RootCameraGroup Group[name="${e}"] Camera[name="${t}"]`)?.getAttribute("id") : this.xmlDoc.querySelector(`RootCameraGroup Camera[name="${t}"]`)?.getAttribute("id");
|
|
258
256
|
}
|
|
259
257
|
getCameraById(t, e) {
|
|
260
258
|
let i;
|
|
@@ -265,8 +263,7 @@ class q {
|
|
|
265
263
|
return e && t ? i = this.xmlDoc.querySelector(`RootCameraGroup Group[name="${e}"] Camera[name="${t}"]`) : i = this.xmlDoc.querySelector(`RootCameraGroup Camera[name="${t}"]`), i ? this.mapElementToCamera(i) : null;
|
|
266
264
|
}
|
|
267
265
|
getCameraGroupId(t) {
|
|
268
|
-
|
|
269
|
-
return (e = this.xmlDoc.querySelector(`RootCameraGroup Group[name="${t}"]`)) == null ? void 0 : e.getAttribute("id");
|
|
266
|
+
return this.xmlDoc.querySelector(`RootCameraGroup Group[name="${t}"]`)?.getAttribute("id");
|
|
270
267
|
}
|
|
271
268
|
getCameraGroupById(t) {
|
|
272
269
|
const e = this.xmlDoc.querySelector(`RootCameraGroup Group[id="${t}"]`);
|
|
@@ -310,7 +307,7 @@ class q {
|
|
|
310
307
|
};
|
|
311
308
|
}
|
|
312
309
|
}
|
|
313
|
-
const
|
|
310
|
+
const g = class g {
|
|
314
311
|
constructor(t) {
|
|
315
312
|
this.server = t;
|
|
316
313
|
}
|
|
@@ -318,15 +315,14 @@ const v = class v {
|
|
|
318
315
|
return Object.entries(t).filter(([e, i]) => i != null).map(([e, i]) => `${e}=${i}`).join("&");
|
|
319
316
|
}
|
|
320
317
|
static sceneParameters(t) {
|
|
321
|
-
|
|
322
|
-
const e = t.scene, i = e.length > 1 ? e.find((o) => o.accessory) : null, s = e.length > 1 ? e.find((o) => o.decor) : null, r = e.find((o) => o !== i && o !== s);
|
|
318
|
+
const e = t.scene, i = e.length > 1 ? e.find((n) => n.accessory) : null, s = e.length > 1 ? e.find((n) => n.decor) : null, r = e.find((n) => n !== i && n !== s);
|
|
323
319
|
return {
|
|
324
320
|
databaseId: r.database,
|
|
325
|
-
configuration: r
|
|
326
|
-
animations:
|
|
327
|
-
accessoryDatabaseId: i
|
|
328
|
-
decorDatabaseId: s
|
|
329
|
-
decorDeltaAltitude:
|
|
321
|
+
configuration: r?.configuration,
|
|
322
|
+
animations: r?.animations?.join("/"),
|
|
323
|
+
accessoryDatabaseId: i?.database,
|
|
324
|
+
decorDatabaseId: s?.database,
|
|
325
|
+
decorDeltaAltitude: s?.translation?.y
|
|
330
326
|
};
|
|
331
327
|
}
|
|
332
328
|
static renderParameters(t) {
|
|
@@ -354,36 +350,36 @@ const v = class v {
|
|
|
354
350
|
}
|
|
355
351
|
async animation(t) {
|
|
356
352
|
const e = {
|
|
357
|
-
...
|
|
353
|
+
...g.sceneParameters(t),
|
|
358
354
|
animation: t.view.animation,
|
|
359
355
|
bookmarkSet: t.view.camera.split("/")[0],
|
|
360
356
|
bookmark: t.view.camera.split("/")[1],
|
|
361
357
|
frames: t.view.frames,
|
|
362
358
|
loop: !!t.view.loop,
|
|
363
|
-
...
|
|
364
|
-
...
|
|
365
|
-
}, i =
|
|
366
|
-
return
|
|
359
|
+
...g.renderParameters(t),
|
|
360
|
+
...g.encoderParameters(t)
|
|
361
|
+
}, i = g.buildQuery(e);
|
|
362
|
+
return g.fetch(`${this.server}/ImagesFromAnimation?${i}`);
|
|
367
363
|
}
|
|
368
364
|
async database(t) {
|
|
369
365
|
return fetch(`${this.server}/Database?databaseId=${t}`).then((e) => e.text()).then((e) => {
|
|
370
366
|
const i = new DOMParser().parseFromString(e, "application/xml");
|
|
371
|
-
return new
|
|
367
|
+
return new H(i);
|
|
372
368
|
});
|
|
373
369
|
}
|
|
374
370
|
async image(t) {
|
|
375
371
|
const e = {
|
|
376
|
-
...
|
|
372
|
+
...g.sceneParameters(t),
|
|
377
373
|
bookmarkSet: t.view.camera.split("/")[0],
|
|
378
374
|
bookmark: t.view.camera.split("/")[1],
|
|
379
|
-
...
|
|
380
|
-
...
|
|
381
|
-
}, i =
|
|
375
|
+
...g.renderParameters(t),
|
|
376
|
+
...g.encoderParameters(t)
|
|
377
|
+
}, i = g.buildQuery(e);
|
|
382
378
|
return Promise.resolve(`${this.server}/ImageFromBookmark?${i}`);
|
|
383
379
|
}
|
|
384
380
|
async video(t) {
|
|
385
381
|
const e = {
|
|
386
|
-
...
|
|
382
|
+
...g.sceneParameters(t),
|
|
387
383
|
animation: t.view.animation,
|
|
388
384
|
bookmarkSet: t.view.camera.split("/")[0],
|
|
389
385
|
bookmark: t.view.camera.split("/")[1],
|
|
@@ -391,36 +387,36 @@ const v = class v {
|
|
|
391
387
|
frames: t.view.frames,
|
|
392
388
|
loop: !!t.view.loop,
|
|
393
389
|
reverse: !!t.view.reverse,
|
|
394
|
-
...
|
|
395
|
-
...
|
|
396
|
-
}, i =
|
|
390
|
+
...g.renderParameters(t),
|
|
391
|
+
...g.encoderParameters(t)
|
|
392
|
+
}, i = g.buildQuery(e);
|
|
397
393
|
return Promise.resolve(`${this.server}/ImagesFromAnimation?${i}`);
|
|
398
394
|
}
|
|
399
395
|
async vrCube(t) {
|
|
400
396
|
const e = {
|
|
401
|
-
...
|
|
397
|
+
...g.sceneParameters(t),
|
|
402
398
|
bookmarkSet: t.view.camera.split("/")[0],
|
|
403
399
|
bookmark: t.view.camera.split("/")[1],
|
|
404
|
-
...
|
|
405
|
-
...
|
|
400
|
+
...g.renderParameters(t),
|
|
401
|
+
...g.encoderParameters(t)
|
|
406
402
|
};
|
|
407
403
|
e.width = Math.max(e.width, e.height), e.height = Math.max(e.width, e.height);
|
|
408
|
-
const i =
|
|
409
|
-
return
|
|
404
|
+
const i = g.buildQuery(e);
|
|
405
|
+
return g.fetch(`${this.server}/CubeFromBookmark?${i}`);
|
|
410
406
|
}
|
|
411
407
|
async vrObject(t) {
|
|
412
408
|
const e = {
|
|
413
|
-
...
|
|
409
|
+
...g.sceneParameters(t),
|
|
414
410
|
bookmarkSet: t.view.camera,
|
|
415
|
-
...
|
|
416
|
-
...
|
|
417
|
-
}, i =
|
|
418
|
-
return
|
|
411
|
+
...g.renderParameters(t),
|
|
412
|
+
...g.encoderParameters(t)
|
|
413
|
+
}, i = g.buildQuery(e);
|
|
414
|
+
return g.fetch(`${this.server}/ImagesFromBookmarkSet?${i}`);
|
|
419
415
|
}
|
|
420
416
|
};
|
|
421
|
-
|
|
422
|
-
let S =
|
|
423
|
-
class
|
|
417
|
+
g.xmlRegex = /directUrl="([^"]*)"/g;
|
|
418
|
+
let S = g;
|
|
419
|
+
class m {
|
|
424
420
|
constructor(t) {
|
|
425
421
|
this.server = t;
|
|
426
422
|
}
|
|
@@ -481,34 +477,34 @@ class l {
|
|
|
481
477
|
async database(t) {
|
|
482
478
|
return fetch(`${this.server}/Database?databaseId=${t}`).then((e) => e.text()).then((e) => {
|
|
483
479
|
const i = new DOMParser().parseFromString(e, "application/xml");
|
|
484
|
-
return new
|
|
480
|
+
return new H(i);
|
|
485
481
|
});
|
|
486
482
|
}
|
|
487
483
|
async image(t) {
|
|
488
484
|
const e = {
|
|
489
|
-
scene:
|
|
485
|
+
scene: m.scene(t),
|
|
490
486
|
mode: {
|
|
491
487
|
image: {
|
|
492
488
|
camera: t.view.camera
|
|
493
489
|
}
|
|
494
490
|
},
|
|
495
|
-
renderParameters:
|
|
496
|
-
encoder:
|
|
491
|
+
renderParameters: m.renderParameters(t),
|
|
492
|
+
encoder: m.encoder(t)
|
|
497
493
|
};
|
|
498
|
-
return
|
|
494
|
+
return m.fetchFrame(`${this.server}/Snapshot`, e);
|
|
499
495
|
}
|
|
500
496
|
async vrCube(t) {
|
|
501
497
|
const e = {
|
|
502
|
-
scene:
|
|
498
|
+
scene: m.scene(t),
|
|
503
499
|
mode: {
|
|
504
500
|
vrCube: {
|
|
505
501
|
camera: t.view.camera
|
|
506
502
|
}
|
|
507
503
|
},
|
|
508
|
-
renderParameters:
|
|
509
|
-
encoder:
|
|
504
|
+
renderParameters: m.renderParameters(t),
|
|
505
|
+
encoder: m.encoder(t)
|
|
510
506
|
};
|
|
511
|
-
return e.renderParameters.width = Math.max(e.renderParameters.width, e.renderParameters.height), e.renderParameters.height = Math.max(e.renderParameters.width, e.renderParameters.height),
|
|
507
|
+
return e.renderParameters.width = Math.max(e.renderParameters.width, e.renderParameters.height), e.renderParameters.height = Math.max(e.renderParameters.width, e.renderParameters.height), m.fetchFrameArray(`${this.server}/Snapshot`, e);
|
|
512
508
|
}
|
|
513
509
|
async vrObject(t) {
|
|
514
510
|
let e;
|
|
@@ -535,16 +531,16 @@ class l {
|
|
|
535
531
|
}
|
|
536
532
|
};
|
|
537
533
|
const i = {
|
|
538
|
-
scene:
|
|
534
|
+
scene: m.scene(t),
|
|
539
535
|
mode: e,
|
|
540
|
-
renderParameters:
|
|
541
|
-
encoder:
|
|
536
|
+
renderParameters: m.renderParameters(t),
|
|
537
|
+
encoder: m.encoder(t)
|
|
542
538
|
};
|
|
543
|
-
return
|
|
539
|
+
return m.fetchFrameArray(`${this.server}/Snapshot`, i);
|
|
544
540
|
}
|
|
545
541
|
async animation(t) {
|
|
546
542
|
const e = {
|
|
547
|
-
scene:
|
|
543
|
+
scene: m.scene(t),
|
|
548
544
|
mode: {
|
|
549
545
|
animation: {
|
|
550
546
|
id: t.view.animation,
|
|
@@ -552,45 +548,45 @@ class l {
|
|
|
552
548
|
fps: t.view.fps
|
|
553
549
|
}
|
|
554
550
|
},
|
|
555
|
-
renderParameters:
|
|
556
|
-
encoder:
|
|
551
|
+
renderParameters: m.renderParameters(t),
|
|
552
|
+
encoder: m.encoder(t)
|
|
557
553
|
};
|
|
558
|
-
return
|
|
554
|
+
return m.fetchFrameArray(`${this.server}/Snapshot`, e);
|
|
559
555
|
}
|
|
560
556
|
async imageHotspots(t, e) {
|
|
561
557
|
const i = {
|
|
562
|
-
scene:
|
|
558
|
+
scene: m.scene(t),
|
|
563
559
|
mode: {
|
|
564
560
|
image: {
|
|
565
561
|
camera: t.view.camera
|
|
566
562
|
}
|
|
567
563
|
},
|
|
568
|
-
renderParameters:
|
|
564
|
+
renderParameters: m.renderParameters(t),
|
|
569
565
|
...this.hotspotsBody(e)
|
|
570
566
|
};
|
|
571
|
-
return await
|
|
567
|
+
return await m.fetchHotspots(`${this.server}/Hotspot`, i);
|
|
572
568
|
}
|
|
573
569
|
async imagePick(t, e) {
|
|
574
570
|
const i = {
|
|
575
|
-
scene:
|
|
571
|
+
scene: m.scene(t),
|
|
576
572
|
camera: t.view.camera,
|
|
577
|
-
renderParameters:
|
|
573
|
+
renderParameters: m.renderParameters(t),
|
|
578
574
|
positions: [e]
|
|
579
575
|
};
|
|
580
|
-
return await
|
|
576
|
+
return await m.fetchPick(`${this.server}/Pick`, i);
|
|
581
577
|
}
|
|
582
578
|
async vrCubeHotspots(t, e) {
|
|
583
579
|
const i = {
|
|
584
|
-
scene:
|
|
580
|
+
scene: m.scene(t),
|
|
585
581
|
mode: {
|
|
586
582
|
vrCube: {
|
|
587
583
|
camera: t.view.camera
|
|
588
584
|
}
|
|
589
585
|
},
|
|
590
|
-
renderParameters:
|
|
586
|
+
renderParameters: m.renderParameters(t),
|
|
591
587
|
...this.hotspotsBody(e)
|
|
592
588
|
};
|
|
593
|
-
return i.renderParameters.width = Math.max(i.renderParameters.width, i.renderParameters.height), i.renderParameters.height = Math.max(i.renderParameters.width, i.renderParameters.height), await
|
|
589
|
+
return i.renderParameters.width = Math.max(i.renderParameters.width, i.renderParameters.height), i.renderParameters.height = Math.max(i.renderParameters.width, i.renderParameters.height), await m.fetchHotspotsArray(`${this.server}/Hotspot`, i);
|
|
594
590
|
}
|
|
595
591
|
async vrObjectHotspots(t, e) {
|
|
596
592
|
let i;
|
|
@@ -617,12 +613,12 @@ class l {
|
|
|
617
613
|
}
|
|
618
614
|
};
|
|
619
615
|
const s = {
|
|
620
|
-
scene:
|
|
616
|
+
scene: m.scene(t),
|
|
621
617
|
mode: i,
|
|
622
|
-
renderParameters:
|
|
618
|
+
renderParameters: m.renderParameters(t),
|
|
623
619
|
...this.hotspotsBody(e)
|
|
624
620
|
};
|
|
625
|
-
return await
|
|
621
|
+
return await m.fetchHotspotsArray(`${this.server}/Hotspot`, s);
|
|
626
622
|
}
|
|
627
623
|
hotspotsBody(t) {
|
|
628
624
|
return {
|
|
@@ -635,16 +631,16 @@ class D {
|
|
|
635
631
|
constructor(t, e, i) {
|
|
636
632
|
switch (e) {
|
|
637
633
|
case "static":
|
|
638
|
-
this.webrender = new
|
|
634
|
+
this.webrender = new X();
|
|
639
635
|
break;
|
|
640
636
|
case "v1":
|
|
641
|
-
this.webrender = new S(t), this.webrenderV2 = new
|
|
637
|
+
this.webrender = new S(t), this.webrenderV2 = new m(t);
|
|
642
638
|
break;
|
|
643
639
|
case "v2":
|
|
644
|
-
this.webrender = new
|
|
640
|
+
this.webrender = new m(t), this.webrenderV2 = new m(t);
|
|
645
641
|
break;
|
|
646
642
|
default:
|
|
647
|
-
this.webrender = new S(t), this.webrenderV2 = new
|
|
643
|
+
this.webrender = new S(t), this.webrenderV2 = new m(t);
|
|
648
644
|
break;
|
|
649
645
|
}
|
|
650
646
|
this.delegate = i, this.loadingId = 0, this.loaded = 0, this.total = 0, this.databases = [], this.onLoadStart = i && i.onLoadStart ? i.onLoadStart : () => {
|
|
@@ -675,10 +671,9 @@ class D {
|
|
|
675
671
|
}).then((i) => (this.onLoadEnd(this.progress), i));
|
|
676
672
|
}
|
|
677
673
|
async loadVRObjectSnapshot(t, e) {
|
|
678
|
-
var s;
|
|
679
674
|
this.loadingId += 1, this.loaded = 0, this.total = 0, this.onLoadStart(this.progress);
|
|
680
675
|
const { loadingId: i } = this;
|
|
681
|
-
return t.view.animation ?
|
|
676
|
+
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));
|
|
682
677
|
}
|
|
683
678
|
async loadImage(t, e) {
|
|
684
679
|
const i = new Image();
|
|
@@ -704,7 +699,7 @@ class D {
|
|
|
704
699
|
this.total = t.length;
|
|
705
700
|
const r = new Array(t.length), n = i || 0;
|
|
706
701
|
for (let a = 0, o = t.length; a < o; a += 1) {
|
|
707
|
-
const
|
|
702
|
+
const l = Math.ceil(a / 2) * (a % 2 === 0 ? 1 : -1), u = e ? w.mod(n + l, o) : a;
|
|
708
703
|
r[u] = this.loadImage(t[u], s);
|
|
709
704
|
}
|
|
710
705
|
return Promise.all(r).then(() => this.onLoadEnd(this.progress)).catch(() => {
|
|
@@ -732,19 +727,19 @@ class D {
|
|
|
732
727
|
async loadVideoFrame(t, e, i, s, r) {
|
|
733
728
|
let n = 0;
|
|
734
729
|
return new Promise((a, o) => {
|
|
735
|
-
const
|
|
730
|
+
const l = () => {
|
|
736
731
|
if (r !== this.loadingId) return;
|
|
737
732
|
if (n !== s) {
|
|
738
733
|
n += 1;
|
|
739
734
|
return;
|
|
740
735
|
}
|
|
741
|
-
t.removeEventListener("seeked",
|
|
736
|
+
t.removeEventListener("seeked", l);
|
|
742
737
|
const u = document.createElement("canvas");
|
|
743
738
|
u.width = t.videoWidth, u.height = t.videoHeight, u.getContext("2d").drawImage(t, 0, 0);
|
|
744
|
-
const
|
|
745
|
-
|
|
739
|
+
const d = new Image();
|
|
740
|
+
d.src = u.toDataURL(), a(d), this.loaded += 1, this.onLoadProgress(this.progress), s !== i - 1 && (t.currentTime += 1 / e);
|
|
746
741
|
};
|
|
747
|
-
t.addEventListener("seeked",
|
|
742
|
+
t.addEventListener("seeked", l), t.addEventListener(
|
|
748
743
|
"error",
|
|
749
744
|
(u) => {
|
|
750
745
|
r === this.loadingId && o(u);
|
|
@@ -786,20 +781,19 @@ class D {
|
|
|
786
781
|
return this.webrenderV2 ? await this.webrenderV2.imagePick(await this.vrCubeFrameSnapshot(t, i), e) : Promise.reject(new Error("Picking only available with api V2"));
|
|
787
782
|
}
|
|
788
783
|
async convert(t) {
|
|
789
|
-
|
|
790
|
-
if (!this.webrenderV2 || this.webrender instanceof l || !t.view.camera)
|
|
784
|
+
if (!this.webrenderV2 || this.webrender instanceof m || !t.view.camera)
|
|
791
785
|
return t;
|
|
792
|
-
const e = t.scene.find((
|
|
786
|
+
const e = t.scene.find((o) => !o.decor && !o.accessory);
|
|
793
787
|
if (!e)
|
|
794
788
|
return t;
|
|
795
|
-
let i = this.databases.find((
|
|
789
|
+
let i = this.databases.find((o) => o.id === e.database);
|
|
796
790
|
(!i || !i.xmlDoc) && (i = await this.webrender.database(e.database), this.databases.push(i));
|
|
797
|
-
const s =
|
|
791
|
+
const s = t.view.camera?.split("/"), r = s.length === 2 ? s[0] : void 0, n = s.length === 2 ? s[1] : s[0], a = i.getCameraId(n, r);
|
|
798
792
|
if (a)
|
|
799
793
|
return { ...t, view: { ...t.view, camera: a } };
|
|
800
794
|
{
|
|
801
|
-
const
|
|
802
|
-
return
|
|
795
|
+
const o = i.getCameraGroupId(n);
|
|
796
|
+
return o ? { ...t, view: { ...t.view, cameraGroup: o } } : t;
|
|
803
797
|
}
|
|
804
798
|
}
|
|
805
799
|
async vrObjectFrameSnapshot(t, e, i) {
|
|
@@ -820,14 +814,14 @@ class D {
|
|
|
820
814
|
return t;
|
|
821
815
|
const o = a.cameras[e];
|
|
822
816
|
return o ? { ...t, view: { ...t.view, camera: o.id } } : t;
|
|
823
|
-
} else if (this.webrender instanceof
|
|
817
|
+
} else if (this.webrender instanceof m)
|
|
824
818
|
if (t.view.camera) {
|
|
825
819
|
const n = r.getCameraById(t.view.camera);
|
|
826
820
|
if (!n)
|
|
827
821
|
return t;
|
|
828
|
-
const a = new
|
|
822
|
+
const a = new B(n.pointOfView), o = 2 * Math.PI / i;
|
|
829
823
|
a.longitude += e * o % (2 * Math.PI);
|
|
830
|
-
const
|
|
824
|
+
const l = a.pointOfView(n.pointOfView.target);
|
|
831
825
|
return {
|
|
832
826
|
...t,
|
|
833
827
|
view: {
|
|
@@ -836,19 +830,19 @@ class D {
|
|
|
836
830
|
id: n.id,
|
|
837
831
|
pov: {
|
|
838
832
|
target: {
|
|
839
|
-
x:
|
|
840
|
-
y:
|
|
841
|
-
z:
|
|
833
|
+
x: l.target[0],
|
|
834
|
+
y: l.target[1],
|
|
835
|
+
z: l.target[2]
|
|
842
836
|
},
|
|
843
837
|
eye: {
|
|
844
|
-
x:
|
|
845
|
-
y:
|
|
846
|
-
z:
|
|
838
|
+
x: l.eye[0],
|
|
839
|
+
y: l.eye[1],
|
|
840
|
+
z: l.eye[2]
|
|
847
841
|
},
|
|
848
842
|
up: {
|
|
849
|
-
x:
|
|
850
|
-
y:
|
|
851
|
-
z:
|
|
843
|
+
x: l.up[0],
|
|
844
|
+
y: l.up[1],
|
|
845
|
+
z: l.up[2]
|
|
852
846
|
}
|
|
853
847
|
}
|
|
854
848
|
}
|
|
@@ -874,9 +868,9 @@ class D {
|
|
|
874
868
|
return t;
|
|
875
869
|
let r;
|
|
876
870
|
if (this.webrender instanceof S) {
|
|
877
|
-
const o = t.view.camera.split("/"),
|
|
878
|
-
r = s.getCameraId(u,
|
|
879
|
-
} else this.webrender instanceof
|
|
871
|
+
const o = t.view.camera.split("/"), l = o.length === 2 ? o[0] : void 0, u = o.length === 2 ? o[1] : o[0];
|
|
872
|
+
r = s.getCameraId(u, l);
|
|
873
|
+
} else this.webrender instanceof m && (r = t.view.camera);
|
|
880
874
|
if (!r)
|
|
881
875
|
return t;
|
|
882
876
|
const n = s.getCameraById(r);
|
|
@@ -937,7 +931,7 @@ class D {
|
|
|
937
931
|
return e.protocol === "http:" || e.protocol === "https:";
|
|
938
932
|
}
|
|
939
933
|
}
|
|
940
|
-
class
|
|
934
|
+
class Y {
|
|
941
935
|
constructor() {
|
|
942
936
|
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");
|
|
943
937
|
}
|
|
@@ -1023,7 +1017,7 @@ class y {
|
|
|
1023
1017
|
return new I(e.screenX, e.screenY);
|
|
1024
1018
|
}
|
|
1025
1019
|
}
|
|
1026
|
-
class
|
|
1020
|
+
class V {
|
|
1027
1021
|
constructor(...t) {
|
|
1028
1022
|
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]);
|
|
1029
1023
|
}
|
|
@@ -1032,7 +1026,7 @@ class j {
|
|
|
1032
1026
|
return [...t, ...e, ...i, ...s];
|
|
1033
1027
|
}
|
|
1034
1028
|
get globalToLocalMatrix() {
|
|
1035
|
-
return
|
|
1029
|
+
return c.inverse(this.localToGlobalMatrix);
|
|
1036
1030
|
}
|
|
1037
1031
|
}
|
|
1038
1032
|
class Z {
|
|
@@ -1040,7 +1034,7 @@ class Z {
|
|
|
1040
1034
|
this.x = t, this.y = e, this.time = i;
|
|
1041
1035
|
}
|
|
1042
1036
|
}
|
|
1043
|
-
class
|
|
1037
|
+
class q {
|
|
1044
1038
|
constructor(t) {
|
|
1045
1039
|
this.points = [], this.onMotion = t, this.lastPoint = new I(0, 0), this.velocity = new I(0, 0), this.loop = this.loop.bind(this);
|
|
1046
1040
|
}
|
|
@@ -1070,15 +1064,15 @@ class G {
|
|
|
1070
1064
|
}
|
|
1071
1065
|
class Q {
|
|
1072
1066
|
constructor(t, e, i) {
|
|
1073
|
-
this.isStarted = !1, this.pov = t, this.fov = w.degreesToRadians(e), this.orientationMatrix =
|
|
1067
|
+
this.isStarted = !1, this.pov = t, this.fov = w.degreesToRadians(e), this.orientationMatrix = c.identity(), this.inertia = new q(this.motion.bind(this)), this.onMotion = i, this.initPov = this.pov, this.initFov = this.fov, this.initOrientation = w.degreesToRadians(window.orientation) || 0, this.startPov = new L([0, 0, 1], [0, 0, 0], [0, 1, 0]), this.startSize = { width: 0, height: 0 }, this.previousPoint = new I(0, 0);
|
|
1074
1068
|
}
|
|
1075
1069
|
destroy() {
|
|
1076
1070
|
this.inertia.destroy();
|
|
1077
1071
|
}
|
|
1078
1072
|
get orientedPov() {
|
|
1079
|
-
const t = h.normalize(h.cross(this.pov.up, this.pov.target)), e = new
|
|
1080
|
-
|
|
1081
|
-
const s =
|
|
1073
|
+
const t = h.normalize(h.cross(this.pov.up, this.pov.target)), e = new V(t, [0, 1, 0], this.pov.eye), i = c.identity();
|
|
1074
|
+
c.multiply(i, e.localToGlobalMatrix, i), c.multiply(i, this.orientationMatrix, i), c.multiply(i, e.globalToLocalMatrix, i);
|
|
1075
|
+
const s = c.transformDirection(i, this.pov.target), r = this.pov.eye, n = c.transformDirection(i, this.pov.up);
|
|
1082
1076
|
return new L(s, r, n);
|
|
1083
1077
|
}
|
|
1084
1078
|
reset() {
|
|
@@ -1092,20 +1086,20 @@ class Q {
|
|
|
1092
1086
|
const e = {
|
|
1093
1087
|
x: t.x - this.previousPoint.x,
|
|
1094
1088
|
y: t.y - this.previousPoint.y
|
|
1095
|
-
}, 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 =
|
|
1096
|
-
|
|
1097
|
-
const
|
|
1098
|
-
h.cross(u, [0, 0, 1])[0] >= 0 && (this.pov.target =
|
|
1089
|
+
}, i = w.accelerate(e.x, 1.3) / this.startSize.width * 0.2 * Math.PI * 1.5, s = w.accelerate(e.y, 1.3) / this.startSize.height * 0.2 * Math.PI, r = c.multiply(c.rotationY(i), c.rotationX(-s)), n = h.normalize(h.cross(this.pov.up, this.pov.target)), a = new V(n, [0, 1, 0], this.pov.eye), o = c.identity();
|
|
1090
|
+
c.multiply(o, a.localToGlobalMatrix, o), c.multiply(o, r, o), c.multiply(o, a.globalToLocalMatrix, o);
|
|
1091
|
+
const l = c.transformPoint(o, this.pov.target), u = c.transformDirection(o, this.pov.up);
|
|
1092
|
+
h.cross(u, [0, 0, 1])[0] >= 0 && (this.pov.target = l, this.pov.up = u), this.previousPoint = t, this.onMotion();
|
|
1099
1093
|
}
|
|
1100
1094
|
end(t, e) {
|
|
1101
1095
|
this.isStarted = !1, e && (this.inertia.track(t), this.inertia.start());
|
|
1102
1096
|
}
|
|
1103
1097
|
orientation(t, e, i) {
|
|
1104
|
-
const s = w.degreesToRadians(window.orientation) || 0, r = w.degreesToRadians(t), n = w.degreesToRadians(-e), a = w.degreesToRadians(-i), o =
|
|
1105
|
-
|
|
1098
|
+
const s = w.degreesToRadians(window.orientation) || 0, r = w.degreesToRadians(t), n = w.degreesToRadians(-e), a = w.degreesToRadians(-i), o = c.rotationX(w.degreesToRadians(90));
|
|
1099
|
+
c.rotateZ(o, this.initOrientation, o), c.rotateZ(o, r, o), c.rotateX(o, n, o), c.rotateY(o, a, o), c.rotateZ(o, -s, o), this.orientationMatrix = o, this.onMotion();
|
|
1106
1100
|
}
|
|
1107
1101
|
}
|
|
1108
|
-
var
|
|
1102
|
+
var W = `precision mediump float;
|
|
1109
1103
|
|
|
1110
1104
|
uniform float u_mix;
|
|
1111
1105
|
uniform samplerCube u_texture;
|
|
@@ -1117,7 +1111,7 @@ void main() {
|
|
|
1117
1111
|
vec4 backColor = textureCube(u_texture_back, direction);
|
|
1118
1112
|
vec4 color = textureCube(u_texture, direction);
|
|
1119
1113
|
gl_FragColor = mix(backColor, color, u_mix);
|
|
1120
|
-
}`,
|
|
1114
|
+
}`, _ = `attribute vec4 position;
|
|
1121
1115
|
|
|
1122
1116
|
uniform mat4 u_mvpi;
|
|
1123
1117
|
|
|
@@ -1127,27 +1121,27 @@ void main() {
|
|
|
1127
1121
|
direction = (u_mvpi * position).xyz;
|
|
1128
1122
|
gl_Position = position;
|
|
1129
1123
|
}`;
|
|
1130
|
-
class
|
|
1124
|
+
class K {
|
|
1131
1125
|
constructor(t, e, i, s) {
|
|
1132
1126
|
this.container = t, this.canvas = e, this.loader = i, this.images = [], this.hotspotsList = [[]];
|
|
1133
|
-
const r = new L([0, 0, 1], [0, 0, 0], [0, 1, 0]), n = 60, a =
|
|
1134
|
-
|
|
1127
|
+
const r = new L([0, 0, 1], [0, 0, 0], [0, 1, 0]), n = 60, a = c.rotationX(w.degreesToRadians(15));
|
|
1128
|
+
c.transformDirection(a, r.target, r.target), c.transformDirection(a, r.up, r.up), this.interaction = new Q(r, n, () => {
|
|
1135
1129
|
this.animationFrameId = requestAnimationFrame(this.render), this.onInteraction({
|
|
1136
1130
|
pov: this.interaction.pov.clone(),
|
|
1137
1131
|
fov: this.interaction.fov
|
|
1138
1132
|
});
|
|
1139
|
-
}), this.onInteraction = s, this.gl = this.canvas.context, this.programInfo =
|
|
1140
|
-
`, `${
|
|
1141
|
-
`]), this.quad =
|
|
1142
|
-
u_mvpi:
|
|
1133
|
+
}), this.onInteraction = s, this.gl = this.canvas.context, this.programInfo = P.createProgramInfo(this.gl, [`${_}
|
|
1134
|
+
`, `${W}
|
|
1135
|
+
`]), this.quad = P.primitives.createXYQuadBufferInfo(this.gl), this.uniforms = {
|
|
1136
|
+
u_mvpi: c.identity(),
|
|
1143
1137
|
u_mix: 0,
|
|
1144
|
-
u_texture_back:
|
|
1138
|
+
u_texture_back: P.createTexture(this.gl, {
|
|
1145
1139
|
target: this.gl.TEXTURE_CUBE_MAP,
|
|
1146
1140
|
minMag: this.gl.LINEAR,
|
|
1147
1141
|
width: 1,
|
|
1148
1142
|
height: 1
|
|
1149
1143
|
}),
|
|
1150
|
-
u_texture:
|
|
1144
|
+
u_texture: P.createTexture(this.gl, {
|
|
1151
1145
|
target: this.gl.TEXTURE_CUBE_MAP,
|
|
1152
1146
|
minMag: this.gl.LINEAR,
|
|
1153
1147
|
width: 1,
|
|
@@ -1185,7 +1179,7 @@ class tt {
|
|
|
1185
1179
|
const n = JSON.stringify(t);
|
|
1186
1180
|
n === this.snapshotHash ? r = r.then(() => (this.animationFrameId = requestAnimationFrame(this.render), Promise.resolve())) : (this.images = [], this.animationFrameId = requestAnimationFrame(this.render), r = r.then(
|
|
1187
1181
|
() => this.loader.loadVRCubeSnapshot(t).then((o) => {
|
|
1188
|
-
this.images = o,
|
|
1182
|
+
this.images = o, P.createTexture(
|
|
1189
1183
|
this.gl,
|
|
1190
1184
|
{
|
|
1191
1185
|
target: this.gl.TEXTURE_CUBE_MAP,
|
|
@@ -1202,8 +1196,8 @@ class tt {
|
|
|
1202
1196
|
],
|
|
1203
1197
|
src: o
|
|
1204
1198
|
},
|
|
1205
|
-
(
|
|
1206
|
-
|
|
1199
|
+
(l, u) => {
|
|
1200
|
+
l || (i && this.interaction.reset(), this.uniforms.u_mix = s ? 0 : 1, this.uniforms.u_texture_back = this.uniforms.u_texture, this.uniforms.u_texture = u, this.animationFrameId = requestAnimationFrame(this.render));
|
|
1207
1201
|
}
|
|
1208
1202
|
);
|
|
1209
1203
|
})
|
|
@@ -1216,73 +1210,72 @@ class tt {
|
|
|
1216
1210
|
) : this.hotspotsList = [[]]), this.hotspotsHash = a, this.snapshotHash = n, r;
|
|
1217
1211
|
}
|
|
1218
1212
|
async pick(t, e) {
|
|
1219
|
-
const i = this.canvas.element.clientWidth, s = this.canvas.element.clientHeight, r = e.x, n = s - e.y, a = 2 * r / i - 1, o = 2 * n / s - 1,
|
|
1213
|
+
const i = this.canvas.element.clientWidth, s = this.canvas.element.clientHeight, r = e.x, n = s - e.y, a = 2 * r / i - 1, o = 2 * n / s - 1, l = [a, o, 0], u = this.modelViewProjectionMatrix, f = c.inverse(u), d = h.normalize(c.transformPoint(f, l)), T = Math.max(Math.abs(d[0]), Math.abs(d[1]), Math.abs(d[2]));
|
|
1220
1214
|
let F = "";
|
|
1221
|
-
Math.abs(
|
|
1222
|
-
let x = 0,
|
|
1215
|
+
Math.abs(d[0]) === T ? F = d[0] > 0 ? "XPOS" : "XNEG" : Math.abs(d[1]) === T ? F = d[1] > 0 ? "YPOS" : "YNEG" : F = d[2] > 0 ? "ZPOS" : "ZNEG";
|
|
1216
|
+
let x = 0, M = 0, E = "";
|
|
1223
1217
|
switch (F) {
|
|
1224
1218
|
case "XPOS":
|
|
1225
|
-
x = (-
|
|
1219
|
+
x = (-d[2] / Math.abs(d[0]) + 1) / 2, M = (-d[1] / Math.abs(d[0]) + 1) / 2, E = "right";
|
|
1226
1220
|
break;
|
|
1227
1221
|
case "XNEG":
|
|
1228
|
-
x = (
|
|
1222
|
+
x = (d[2] / Math.abs(d[0]) + 1) / 2, M = (-d[1] / Math.abs(d[0]) + 1) / 2, E = "left";
|
|
1229
1223
|
break;
|
|
1230
1224
|
case "YPOS":
|
|
1231
|
-
x = (
|
|
1225
|
+
x = (d[0] / Math.abs(d[1]) + 1) / 2, M = (d[2] / Math.abs(d[1]) + 1) / 2, E = "up";
|
|
1232
1226
|
break;
|
|
1233
1227
|
case "YNEG":
|
|
1234
|
-
x = (
|
|
1228
|
+
x = (d[0] / Math.abs(d[1]) + 1) / 2, M = (-d[2] / Math.abs(d[1]) + 1) / 2, E = "down";
|
|
1235
1229
|
break;
|
|
1236
1230
|
case "ZPOS":
|
|
1237
|
-
x = (
|
|
1231
|
+
x = (d[0] / Math.abs(d[2]) + 1) / 2, M = (-d[1] / Math.abs(d[2]) + 1) / 2, E = "front";
|
|
1238
1232
|
break;
|
|
1239
1233
|
case "ZNEG":
|
|
1240
|
-
x = (-
|
|
1234
|
+
x = (-d[0] / Math.abs(d[2]) + 1) / 2, M = (-d[1] / Math.abs(d[2]) + 1) / 2, E = "back";
|
|
1241
1235
|
break;
|
|
1242
1236
|
}
|
|
1243
1237
|
const C = {
|
|
1244
1238
|
x: Math.round(x * Math.max(t.parameters.width, t.parameters.height)),
|
|
1245
|
-
y: Math.round(
|
|
1239
|
+
y: Math.round(M * Math.max(t.parameters.width, t.parameters.height))
|
|
1246
1240
|
};
|
|
1247
1241
|
return this.loader.loadVRCubePick(t, C, E);
|
|
1248
1242
|
}
|
|
1249
1243
|
hotspots() {
|
|
1250
|
-
var s;
|
|
1251
1244
|
const t = [];
|
|
1252
1245
|
if (this.hotspotsList.length === 0)
|
|
1253
1246
|
return [];
|
|
1254
|
-
const e =
|
|
1255
|
-
for (let
|
|
1256
|
-
const
|
|
1257
|
-
if (
|
|
1247
|
+
const e = this.hotspotsList[0]?.length ?? 0, i = this.modelViewProjectionMatrix;
|
|
1248
|
+
for (let s = 0; s < e; s++) {
|
|
1249
|
+
const r = this.hotspotsList.findIndex((R) => R[s].visibility !== "OutOfFrustum");
|
|
1250
|
+
if (r === -1)
|
|
1258
1251
|
continue;
|
|
1259
|
-
const
|
|
1260
|
-
let
|
|
1261
|
-
switch (
|
|
1252
|
+
const n = { ...this.hotspotsList[r][s] }, a = n.position2D.x / this.images[0].width, o = n.position2D.y / this.images[0].height;
|
|
1253
|
+
let l = 0, u = 0, f = 0;
|
|
1254
|
+
switch (r) {
|
|
1262
1255
|
case 0:
|
|
1263
|
-
this.pov.target[2] < 0 && (
|
|
1256
|
+
this.pov.target[2] < 0 && (n.visibility = "OutOfFrustum"), l = 2 * a - 1, u = 1 - 2 * o, f = 1;
|
|
1264
1257
|
break;
|
|
1265
1258
|
case 1:
|
|
1266
|
-
this.pov.target[0] > 0 && (
|
|
1259
|
+
this.pov.target[0] > 0 && (n.visibility = "OutOfFrustum"), l = 1, u = 1 - 2 * o, f = 1 - 2 * a;
|
|
1267
1260
|
break;
|
|
1268
1261
|
case 2:
|
|
1269
|
-
this.pov.target[2] > 0 && (
|
|
1262
|
+
this.pov.target[2] > 0 && (n.visibility = "OutOfFrustum"), l = 1 - 2 * a, u = 1 - 2 * o, f = -1;
|
|
1270
1263
|
break;
|
|
1271
1264
|
case 3:
|
|
1272
|
-
this.pov.target[0] < 0 && (
|
|
1265
|
+
this.pov.target[0] < 0 && (n.visibility = "OutOfFrustum"), l = -1, u = 1 - 2 * o, f = 2 * a - 1;
|
|
1273
1266
|
break;
|
|
1274
1267
|
case 4:
|
|
1275
|
-
this.pov.target[1] < 0 && (
|
|
1268
|
+
this.pov.target[1] < 0 && (n.visibility = "OutOfFrustum"), l = 2 * a - 1, u = 1, f = 2 * o - 1;
|
|
1276
1269
|
break;
|
|
1277
1270
|
case 5:
|
|
1278
|
-
this.pov.target[1] > 0 && (
|
|
1271
|
+
this.pov.target[1] > 0 && (n.visibility = "OutOfFrustum"), l = 2 * a - 1, u = -1, f = 1 - 2 * o;
|
|
1279
1272
|
break;
|
|
1280
1273
|
}
|
|
1281
|
-
const
|
|
1282
|
-
x: Math.round(
|
|
1283
|
-
y: Math.round(
|
|
1284
|
-
},
|
|
1285
|
-
t.push({ ...
|
|
1274
|
+
const d = h.normalize([l, u, f]), T = c.transformPoint(i, d), F = this.canvas.element.clientWidth, x = this.canvas.element.clientHeight, M = 0.5 * F * (T[0] + 1), E = 0.5 * x * (T[1] + 1), C = {
|
|
1275
|
+
x: Math.round(M),
|
|
1276
|
+
y: Math.round(x - E)
|
|
1277
|
+
}, G = new b(F, x), z = p.contains(G, C) ? n.visibility : "OutOfFrustum";
|
|
1278
|
+
t.push({ ...n, position2D: C, visibility: z });
|
|
1286
1279
|
}
|
|
1287
1280
|
return t;
|
|
1288
1281
|
}
|
|
@@ -1290,11 +1283,11 @@ class tt {
|
|
|
1290
1283
|
return this.canvas.element.toDataURL(t, e);
|
|
1291
1284
|
}
|
|
1292
1285
|
get modelViewProjectionMatrix() {
|
|
1293
|
-
const t = this.canvas.element.clientWidth, e = this.canvas.element.clientHeight, i = t > e ? t / e : e / t, s = p.getStandardAspectRatio(t, e), r = this.interaction.fov * (s / i), n =
|
|
1294
|
-
return
|
|
1286
|
+
const t = this.canvas.element.clientWidth, e = this.canvas.element.clientHeight, i = t > e ? t / e : e / t, s = p.getStandardAspectRatio(t, e), r = this.interaction.fov * (s / i), n = c.setAxis(c.identity(), [-1, 0, 0], 0), a = t > e ? w.perspectiveWithFovY(r, t / e, 0.5, 100) : w.perspectiveWithFovX(r, t / e, 0.5, 100), o = this.interaction.orientedPov, l = c.inverse(c.lookAt(o.eye, o.target, o.up));
|
|
1287
|
+
return c.multiply(c.multiply(a, l), n);
|
|
1295
1288
|
}
|
|
1296
1289
|
render() {
|
|
1297
|
-
this.gl.viewport(0, 0, this.gl.canvas.width, this.gl.canvas.height), this.uniforms.u_mvpi =
|
|
1290
|
+
this.gl.viewport(0, 0, this.gl.canvas.width, this.gl.canvas.height), this.uniforms.u_mvpi = c.inverse(this.modelViewProjectionMatrix), this.gl.useProgram(this.programInfo.program), P.setBuffersAndAttributes(this.gl, this.programInfo, this.quad), P.setUniforms(this.programInfo, this.uniforms), P.drawBufferInfo(this.gl, this.quad), this.uniforms.u_mix < 1 && (this.uniforms.u_mix = Math.min(this.uniforms.u_mix + 0.05, 1), this.animationFrameId = requestAnimationFrame(this.render));
|
|
1298
1291
|
}
|
|
1299
1292
|
onMouseDown(t) {
|
|
1300
1293
|
this.container.classList.add("ls-viewer-container-vrcube-grabbing"), this.interaction.start(y.pointFromMouseEvent(t), {
|
|
@@ -1327,9 +1320,9 @@ class tt {
|
|
|
1327
1320
|
this.interaction.orientation(t.alpha, t.beta, t.gamma);
|
|
1328
1321
|
}
|
|
1329
1322
|
}
|
|
1330
|
-
class
|
|
1323
|
+
class tt {
|
|
1331
1324
|
constructor(t, e, i, s, r) {
|
|
1332
|
-
this.isStarted = !1, this.position = t, this.frames = e, this.rows = i, this.loop = s, this.onMotion = r, this.inertia = new
|
|
1325
|
+
this.isStarted = !1, this.position = t, this.frames = e, this.rows = i, this.loop = s, this.onMotion = r, this.inertia = new q(this.motion.bind(this)), this.initPosition = { ...this.position }, this.startPosition = { x: 0, y: 0 }, this.startPoint = new I(0, 0), this.startSize = { width: 0, height: 0 }, this.lastPoints = [], this.lastPointsNumber = 20;
|
|
1333
1326
|
}
|
|
1334
1327
|
destroy() {
|
|
1335
1328
|
this.inertia.destroy();
|
|
@@ -1351,7 +1344,7 @@ class et {
|
|
|
1351
1344
|
}
|
|
1352
1345
|
motion(t) {
|
|
1353
1346
|
this.isStarted && this.inertia.track(t), this.lastPoints.push({ x: t.x, y: t.y }), this.lastPoints.splice(0, this.lastPoints.length - this.lastPointsNumber);
|
|
1354
|
-
const e =
|
|
1347
|
+
const e = $.linear(this.lastPoints.map((s) => [s.x, s.y])), i = 25;
|
|
1355
1348
|
if (Math.abs(e.equation[0]) < 1) {
|
|
1356
1349
|
const s = w.accelerate(t.x - this.startPoint.x, 1.3) / this.startSize.width * (this.frames / 4);
|
|
1357
1350
|
let r = this.startPosition.x - Math.round(s);
|
|
@@ -1370,9 +1363,9 @@ class et {
|
|
|
1370
1363
|
this.isStarted = !1, e && (this.inertia.track(t), this.inertia.start());
|
|
1371
1364
|
}
|
|
1372
1365
|
}
|
|
1373
|
-
class
|
|
1366
|
+
class O {
|
|
1374
1367
|
constructor(t, e, i, s) {
|
|
1375
|
-
this.container = t, this.canvas = e, this.loader = i, this.images = [], this.frames = 24, this.hotspotsList = [[]], this.interaction = new
|
|
1368
|
+
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, () => {
|
|
1376
1369
|
this.canvas.draw(this.image, !0, 0.5), this.onInteraction({
|
|
1377
1370
|
position: this.interaction.positionIndex
|
|
1378
1371
|
});
|
|
@@ -1416,10 +1409,10 @@ class k {
|
|
|
1416
1409
|
const n = JSON.stringify(t);
|
|
1417
1410
|
n === this.snapshotHash && this.image ? r = r.then(() => this.canvas.draw(this.image, s, 0.05)) : (this.images = [], r = r.then(
|
|
1418
1411
|
() => this.loader.loadVRObjectSnapshot(t, this.interaction.positionIndex).then((o) => {
|
|
1419
|
-
const
|
|
1420
|
-
return this.images = new Array(
|
|
1421
|
-
u.then((
|
|
1422
|
-
this.images[f] =
|
|
1412
|
+
const l = o.length;
|
|
1413
|
+
return this.images = new Array(l), this.interaction.frames = t.view.frames ?? t.view.panFrames ?? this.frames, this.interaction.rows = l / this.interaction.frames, this.interaction.loop = !!t.view.loop, i && this.interaction.reset(), o.forEach((u, f) => {
|
|
1414
|
+
u.then((d) => {
|
|
1415
|
+
this.images[f] = d, d === this.image && this.canvas.draw(this.image, s, 0.05);
|
|
1423
1416
|
}).catch(() => {
|
|
1424
1417
|
});
|
|
1425
1418
|
}), o[this.interaction.positionIndex].then(() => Promise.resolve());
|
|
@@ -1472,7 +1465,7 @@ class k {
|
|
|
1472
1465
|
onDeviceOrientation(t) {
|
|
1473
1466
|
}
|
|
1474
1467
|
}
|
|
1475
|
-
class
|
|
1468
|
+
class et {
|
|
1476
1469
|
constructor(t, e, i) {
|
|
1477
1470
|
this.container = t, this.loader = i, this.video = e;
|
|
1478
1471
|
}
|
|
@@ -1556,7 +1549,7 @@ class nt {
|
|
|
1556
1549
|
onHotspotsChange: () => {
|
|
1557
1550
|
},
|
|
1558
1551
|
...e.events
|
|
1559
|
-
}, this.options.events.onLoadError =
|
|
1552
|
+
}, this.options.events.onLoadError = k(this.options.events.onLoadError, 10), this.container = t, this.container.classList.add("ls-viewer-container"), this.containerWidth = 0, this.containerHeight = 0, this.canvas2D = new U(this.options.fit), this.container.prepend(this.canvas2D.element), this.canvas3D = new N(), this.container.prepend(this.canvas3D.element), this.video = new Y(), this.container.prepend(this.video.element), this.loader = new D(this.options.server, this.options.api, this), this.resolution = new b(0, 0), this.parameters = {
|
|
1560
1553
|
width: 0,
|
|
1561
1554
|
height: 0,
|
|
1562
1555
|
antialiasing: !1,
|
|
@@ -1564,14 +1557,14 @@ class nt {
|
|
|
1564
1557
|
}, this.encoder = {
|
|
1565
1558
|
format: "jpeg",
|
|
1566
1559
|
quality: 80
|
|
1567
|
-
}, this.hotspots = [], this.widgetImage = new J(t, this.canvas2D, this.loader), this.widgetVideo = new
|
|
1560
|
+
}, this.hotspots = [], this.widgetImage = new J(t, this.canvas2D, this.loader), this.widgetVideo = new et(t, this.video, this.loader), this.widgetVRObject = new O(t, this.canvas2D, this.loader, this.onVrobjectInteraction), this.canvas3D.context && (this.widgetVRCube = new K(t, this.canvas3D, this.loader, this.onVrcubeInteraction)), this.widget = this.widgetImage, this.isDestroyed = !1, this.container.addEventListener("mousedown", this.onMouseDown), this.container.addEventListener("mouseenter", this.onMouseEnter), this.container.addEventListener("touchstart", this.onTouchStart), document.addEventListener("mousemove", this.onMouseMove, { passive: !1 }), document.addEventListener("mouseup", this.onMouseUp), document.addEventListener("touchmove", this.onTouchMove, { passive: !1 }), document.addEventListener("touchend", this.onTouchEnd), this.loadWidget = k(this.loadWidget, 10), this.onResize = k(this.onResize, 250), requestAnimationFrame(this.checkResize);
|
|
1568
1561
|
}
|
|
1569
1562
|
destroy() {
|
|
1570
1563
|
this.canvas2D.destroy(), this.container.removeEventListener("mousedown", this.onMouseDown), this.container.removeEventListener("mouseenter", this.onMouseEnter), this.container.removeEventListener("touchstart", this.onTouchStart), document.removeEventListener("mousemove", this.onMouseMove), document.removeEventListener("mouseup", this.onMouseUp), document.removeEventListener("touchmove", this.onTouchMove), document.removeEventListener("touchend", this.onTouchEnd), this.isDestroyed = !0;
|
|
1571
1564
|
}
|
|
1572
1565
|
async load(t, e) {
|
|
1573
1566
|
let i = Promise.resolve();
|
|
1574
|
-
return e
|
|
1567
|
+
return e?.animation && (i = i.then(() => this.loadAnimation(e.animation))), this.view && e?.fromPosition !== void 0 && this.viewWidget instanceof O && (this.view.mode, i = i.then(() => this.viewWidget.goto(e.fromPosition))), e?.animation && (i = i.then(() => this.widgetVideo.play())), i = i.then(() => (this.scene = Array.isArray(t) ? [...t] : [t], this.loadWidget(!1, !(e && e.animation)))), i.catch((s) => {
|
|
1575
1568
|
this.onLoadError(s);
|
|
1576
1569
|
}), i;
|
|
1577
1570
|
}
|
|
@@ -1594,9 +1587,9 @@ class nt {
|
|
|
1594
1587
|
}
|
|
1595
1588
|
async setView(t, e) {
|
|
1596
1589
|
let i = Promise.resolve();
|
|
1597
|
-
return e
|
|
1590
|
+
return e?.animation && (i = i.then(() => this.loadAnimation(e.animation))), this.view && e?.fromPosition !== void 0 && this.viewWidget instanceof O && (i = i.then(() => this.viewWidget.goto(e.fromPosition))), e?.animation && (i = i.then(() => this.widgetVideo.play())), i = i.then(() => {
|
|
1598
1591
|
let s = !0;
|
|
1599
|
-
return this.view = { ...t }, this.view && this.viewWidget instanceof
|
|
1592
|
+
return this.view = { ...t }, this.view && this.viewWidget instanceof O && e?.toPosition !== void 0 && (s = !1, this.viewWidget.position = e.toPosition), this.loadWidget(s, !(e && e.animation));
|
|
1600
1593
|
}), i.catch((s) => {
|
|
1601
1594
|
this.onLoadError(s);
|
|
1602
1595
|
}), i;
|
|
@@ -1608,7 +1601,6 @@ class nt {
|
|
|
1608
1601
|
Object.assign(this.widgetVRObject, t);
|
|
1609
1602
|
}
|
|
1610
1603
|
async loadAnimation(t) {
|
|
1611
|
-
var i;
|
|
1612
1604
|
const e = {
|
|
1613
1605
|
scene: this.scene,
|
|
1614
1606
|
view: {
|
|
@@ -1623,7 +1615,7 @@ class nt {
|
|
|
1623
1615
|
format: "mp4"
|
|
1624
1616
|
}
|
|
1625
1617
|
};
|
|
1626
|
-
return
|
|
1618
|
+
return e.view?.background || (e.view.background = "product"), this.widgetVideo.load(e).then(() => Promise.resolve());
|
|
1627
1619
|
}
|
|
1628
1620
|
async playAnimation(t) {
|
|
1629
1621
|
return this.loadAnimation(t).then(() => this.widgetVideo.play()).catch((e) => {
|
|
@@ -1672,8 +1664,7 @@ class nt {
|
|
|
1672
1664
|
});
|
|
1673
1665
|
}
|
|
1674
1666
|
get viewWidget() {
|
|
1675
|
-
|
|
1676
|
-
switch ((t = this.view) == null ? void 0 : t.mode) {
|
|
1667
|
+
switch (this.view?.mode) {
|
|
1677
1668
|
case "image":
|
|
1678
1669
|
return this.widgetImage;
|
|
1679
1670
|
case "video":
|
|
@@ -1747,21 +1738,25 @@ class nt {
|
|
|
1747
1738
|
this.container.classList.remove("ls-viewer-container-loading"), this.options.events.onLoadError(...t);
|
|
1748
1739
|
}
|
|
1749
1740
|
}
|
|
1750
|
-
var
|
|
1751
|
-
((
|
|
1741
|
+
var j;
|
|
1742
|
+
((v) => {
|
|
1752
1743
|
((t) => {
|
|
1744
|
+
t.Visible = "Visible", t.Occluded = "Occluded", t.Clipped = "Clipped", t.OutOfFrustum = "OutOfFrustum";
|
|
1745
|
+
})(v.HotspotVisibility || (v.HotspotVisibility = {})), ((t) => {
|
|
1753
1746
|
t.VeryLow = "veryLow", t.Low = "low", t.Medium = "medium", t.Fine = "fine", t.Ultra = "ultra";
|
|
1754
|
-
})(
|
|
1747
|
+
})(v.SunShadowQualityMode || (v.SunShadowQualityMode = {})), ((t) => {
|
|
1755
1748
|
t.None = "none", t.Weak = "weak", t.Normal = "normal", t.Fine = "fine", t.UltraFine = "ultraFine", t.Max = "max";
|
|
1756
|
-
})(
|
|
1749
|
+
})(v.SunShadowSmoothnessMode || (v.SunShadowSmoothnessMode = {})), ((t) => {
|
|
1757
1750
|
t.Manual = "manual", t.ExtractedFromEnv = "extractedFromEnv";
|
|
1758
|
-
})(
|
|
1759
|
-
|
|
1751
|
+
})(v.SunUseCaseMode || (v.SunUseCaseMode = {})), ((t) => {
|
|
1752
|
+
t.ShowOnly = "showOnly", t.HideOnly = "hideOnly";
|
|
1753
|
+
})(v.SurfacesFilterMode || (v.SurfacesFilterMode = {}));
|
|
1754
|
+
})(j || (j = {}));
|
|
1760
1755
|
export {
|
|
1761
1756
|
nt as Viewer,
|
|
1762
|
-
|
|
1757
|
+
j as WRAPIv2,
|
|
1763
1758
|
J as WidgetImage,
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1759
|
+
K as WidgetVRCube,
|
|
1760
|
+
O as WidgetVRObject,
|
|
1761
|
+
et as WidgetVideo
|
|
1767
1762
|
};
|