@spiffcommerce/preview 5.8.8 → 5.8.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +0 -1
- package/dist/index.esm.js +174 -168
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1099,7 +1099,6 @@ declare class SpiffCommerce3DPreviewService implements ThreeDPreviewService {
|
|
|
1099
1099
|
private renderingPipeline;
|
|
1100
1100
|
private modelContainers;
|
|
1101
1101
|
private plugins;
|
|
1102
|
-
private screenshotPrepareResolve;
|
|
1103
1102
|
private readonly initPromise;
|
|
1104
1103
|
private initComplete;
|
|
1105
1104
|
private isAnimatingCamera;
|
package/dist/index.esm.js
CHANGED
|
@@ -33,6 +33,7 @@ import { DepthOfFieldEffectBlurLevel as L } from "@babylonjs/core/PostProcesses/
|
|
|
33
33
|
import "@babylonjs/core/Rendering/depthRendererSceneComponent";
|
|
34
34
|
import "@babylonjs/core/Engines/Extensions/engine.views";
|
|
35
35
|
import "@babylonjs/core/Meshes/instancedMesh";
|
|
36
|
+
import "@babylonjs/core/Culling/ray";
|
|
36
37
|
import "@babylonjs/core/Materials/Textures/Loaders/ddsTextureLoader";
|
|
37
38
|
import "@babylonjs/core/Materials/Textures/Loaders/envTextureLoader";
|
|
38
39
|
import "@babylonjs/core/Materials/Textures/Loaders/ktxTextureLoader";
|
|
@@ -50,13 +51,13 @@ async function N(s, e, t) {
|
|
|
50
51
|
const i = await he.get(s);
|
|
51
52
|
if (i && i.scene.uid === e.uid)
|
|
52
53
|
return i;
|
|
53
|
-
const
|
|
54
|
+
const a = q.LoadAssetContainerAsync(
|
|
54
55
|
s,
|
|
55
56
|
void 0,
|
|
56
57
|
e,
|
|
57
58
|
t
|
|
58
59
|
);
|
|
59
|
-
return !Ve() && he.set(s,
|
|
60
|
+
return !Ve() && he.set(s, a), a;
|
|
60
61
|
}
|
|
61
62
|
q.OnPluginActivatedObservable.add((s) => {
|
|
62
63
|
s.name === "gltf" && (s.animationStartMode = Re.NONE);
|
|
@@ -64,28 +65,28 @@ q.OnPluginActivatedObservable.add((s) => {
|
|
|
64
65
|
class ce {
|
|
65
66
|
constructor(e) {
|
|
66
67
|
this.getSceneClearColor = () => {
|
|
67
|
-
var i,
|
|
68
|
-
const t = (i = this.customOptions) != null && i.transparentBackground || (
|
|
68
|
+
var i, a, n, o;
|
|
69
|
+
const t = (i = this.customOptions) != null && i.transparentBackground || (a = this.customOptions) != null && a.backgroundImage ? 0 : 1;
|
|
69
70
|
if (this.customOptions && ((n = this.customOptions) != null && n.transparentBackground) || (o = this.customOptions) != null && o.backgroundImage)
|
|
70
71
|
return new v(0, 0, 0, t).toLinearSpace();
|
|
71
72
|
if (this.customOptions && this.customOptions.backgroundColor) {
|
|
72
|
-
const
|
|
73
|
+
const r = A.FromHexString(
|
|
73
74
|
this.customOptions.backgroundColor
|
|
74
75
|
);
|
|
75
76
|
return new v(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
r.r,
|
|
78
|
+
r.g,
|
|
79
|
+
r.b,
|
|
79
80
|
t
|
|
80
81
|
).toLinearSpace();
|
|
81
82
|
}
|
|
82
83
|
return new v(0.98, 0.98, 0.98, t).toLinearSpace();
|
|
83
84
|
}, this.highlightColorFromConfig = () => this.customOptions && this.customOptions.highlightColor ? this.hexToColor4(this.customOptions.highlightColor) : new v(0.98, 0.98, 0.98, 1).toLinearSpace(), this.hexToColor4 = (t, i = 1) => {
|
|
84
|
-
const
|
|
85
|
+
const a = A.FromHexString(t);
|
|
85
86
|
return new v(
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
a.r,
|
|
88
|
+
a.g,
|
|
89
|
+
a.b,
|
|
89
90
|
i
|
|
90
91
|
).toLinearSpace();
|
|
91
92
|
}, this.customOptions = e;
|
|
@@ -101,13 +102,13 @@ class ce {
|
|
|
101
102
|
* Configuration related to the scene
|
|
102
103
|
*/
|
|
103
104
|
get scene() {
|
|
104
|
-
var e, t, i,
|
|
105
|
+
var e, t, i, a, n;
|
|
105
106
|
return {
|
|
106
107
|
clearColor: this.getSceneClearColor(),
|
|
107
108
|
transparentBackground: ((e = this.customOptions) == null ? void 0 : e.transparentBackground) || ((t = this.customOptions) == null ? void 0 : t.backgroundImage),
|
|
108
109
|
environment: {
|
|
109
110
|
file: ((i = this.customOptions) == null ? void 0 : i.environmentFile) ?? "assets/model-viewer/default.env",
|
|
110
|
-
intensity: ((
|
|
111
|
+
intensity: ((a = this.customOptions) == null ? void 0 : a.environmentIntensity) ?? 1,
|
|
111
112
|
rotationY: (((n = this.customOptions) == null ? void 0 : n.environmentRotationY) ?? 0) * (Math.PI / 180)
|
|
112
113
|
// Convert to radians
|
|
113
114
|
}
|
|
@@ -117,7 +118,7 @@ class ce {
|
|
|
117
118
|
* Configuration related to the camera used to view and interact with the scene.
|
|
118
119
|
*/
|
|
119
120
|
get camera() {
|
|
120
|
-
var e, t, i,
|
|
121
|
+
var e, t, i, a, n, o, r, l, h, c, u, m, f;
|
|
121
122
|
return {
|
|
122
123
|
autoOrientation: ((e = this.customOptions) == null ? void 0 : e.disableAutomaticOrientation) ?? !0,
|
|
123
124
|
autoRotation: {
|
|
@@ -126,8 +127,8 @@ class ce {
|
|
|
126
127
|
},
|
|
127
128
|
limits: {
|
|
128
129
|
min: {
|
|
129
|
-
alpha: (
|
|
130
|
-
beta: (o = this.customOptions) != null && o.lowerBetaLimitDeg ? ((
|
|
130
|
+
alpha: (a = this.customOptions) != null && a.lowerAlphaLimitDeg ? ((n = this.customOptions) == null ? void 0 : n.lowerAlphaLimitDeg) * Math.PI / 180 : void 0,
|
|
131
|
+
beta: (o = this.customOptions) != null && o.lowerBetaLimitDeg ? ((r = this.customOptions) == null ? void 0 : r.lowerBetaLimitDeg) * Math.PI / 180 : void 0,
|
|
131
132
|
radius: (l = this.customOptions) == null ? void 0 : l.minZoomOverride
|
|
132
133
|
},
|
|
133
134
|
max: {
|
|
@@ -150,10 +151,10 @@ class ce {
|
|
|
150
151
|
};
|
|
151
152
|
}
|
|
152
153
|
get lighting() {
|
|
153
|
-
var e, t, i,
|
|
154
|
+
var e, t, i, a;
|
|
154
155
|
return {
|
|
155
156
|
exposure: ((t = (e = this.customOptions) == null ? void 0 : e.lighting) == null ? void 0 : t.exposure) ?? 0.9,
|
|
156
|
-
contrast: ((
|
|
157
|
+
contrast: ((a = (i = this.customOptions) == null ? void 0 : i.lighting) == null ? void 0 : a.contrast) ?? 1.6
|
|
157
158
|
};
|
|
158
159
|
}
|
|
159
160
|
get emissiveGlowIntensity() {
|
|
@@ -274,11 +275,11 @@ class _e {
|
|
|
274
275
|
return this.loader.loadNodeAsync(
|
|
275
276
|
e,
|
|
276
277
|
t,
|
|
277
|
-
function(
|
|
278
|
+
function(a) {
|
|
278
279
|
t.extras && Object.keys(t.extras).forEach((n) => {
|
|
279
280
|
const o = t.extras[n];
|
|
280
|
-
|
|
281
|
-
}), i(
|
|
281
|
+
a.metadata[n] = o;
|
|
282
|
+
}), i(a);
|
|
282
283
|
}
|
|
283
284
|
);
|
|
284
285
|
}
|
|
@@ -338,15 +339,15 @@ class _e {
|
|
|
338
339
|
applyReflections(e) {
|
|
339
340
|
function t(n) {
|
|
340
341
|
const o = [];
|
|
341
|
-
return n.transformNodes.forEach((
|
|
342
|
-
|
|
343
|
-
}), n.meshes.forEach((
|
|
344
|
-
|
|
342
|
+
return n.transformNodes.forEach((r) => {
|
|
343
|
+
r.metadata && r.metadata.reflective && o.push(...r.getChildMeshes());
|
|
344
|
+
}), n.meshes.forEach((r) => {
|
|
345
|
+
r.metadata && r.metadata.reflective && !o.includes(r) && o.push(r);
|
|
345
346
|
}), o;
|
|
346
347
|
}
|
|
347
348
|
function i(n, o = 1) {
|
|
348
|
-
const
|
|
349
|
-
if (!
|
|
349
|
+
const r = n.material;
|
|
350
|
+
if (!r)
|
|
350
351
|
return;
|
|
351
352
|
const l = new Ee(
|
|
352
353
|
"mirror",
|
|
@@ -368,19 +369,19 @@ class _e {
|
|
|
368
369
|
n.position,
|
|
369
370
|
u.scale(-1)
|
|
370
371
|
);
|
|
371
|
-
l.mirrorPlane = m, l.level = o,
|
|
372
|
+
l.mirrorPlane = m, l.level = o, r.reflectionTexture = l;
|
|
372
373
|
}
|
|
373
|
-
function
|
|
374
|
-
const o = n.material,
|
|
374
|
+
function a(n) {
|
|
375
|
+
const o = n.material, r = new Le(
|
|
375
376
|
"probe-" + o.name,
|
|
376
377
|
Ge,
|
|
377
378
|
e
|
|
378
379
|
);
|
|
379
|
-
|
|
380
|
+
r.cubeTexture.name = "reflection-probe-cube-texture", r.attachToMesh(n), r.renderList && r.renderList.push(...t(e)), o.reflectionTexture = r.cubeTexture;
|
|
380
381
|
}
|
|
381
382
|
e.meshes.forEach((n) => {
|
|
382
383
|
const o = n.metadata;
|
|
383
|
-
o && (o.mirrorTexture && i(n, o.mirrorTexture), o.reflectionProbe &&
|
|
384
|
+
o && (o.mirrorTexture && i(n, o.mirrorTexture), o.reflectionProbe && a(n));
|
|
384
385
|
});
|
|
385
386
|
}
|
|
386
387
|
}
|
|
@@ -406,18 +407,18 @@ class He {
|
|
|
406
407
|
}
|
|
407
408
|
}
|
|
408
409
|
}
|
|
409
|
-
function Ue(s, e, t, i,
|
|
410
|
+
function Ue(s, e, t, i, a = "") {
|
|
410
411
|
t.forEach((n) => {
|
|
411
|
-
const o = n.getID(),
|
|
412
|
+
const o = n.getID(), r = n.getName(), l = n.getPanelSize && n.getPanelSize(), h = P.getDynamicTextureResolution(
|
|
412
413
|
(l == null ? void 0 : l.width) === 1 || (l == null ? void 0 : l.height) === 1
|
|
413
414
|
);
|
|
414
|
-
s.filter((u) => u.name ===
|
|
415
|
+
s.filter((u) => u.name === a + r).forEach((u) => {
|
|
415
416
|
const m = i.get(o), f = !1;
|
|
416
417
|
if (m)
|
|
417
418
|
de(u, m), m.update(f);
|
|
418
419
|
else {
|
|
419
420
|
const p = Ke(
|
|
420
|
-
|
|
421
|
+
r,
|
|
421
422
|
e,
|
|
422
423
|
h.width,
|
|
423
424
|
h.height
|
|
@@ -432,15 +433,15 @@ function Ue(s, e, t, i, r = "") {
|
|
|
432
433
|
});
|
|
433
434
|
}
|
|
434
435
|
function Ke(s, e, t, i) {
|
|
435
|
-
const
|
|
436
|
+
const a = new Be(
|
|
436
437
|
s,
|
|
437
438
|
{ width: t, height: i },
|
|
438
439
|
e,
|
|
439
440
|
P.shouldMipMap(),
|
|
440
441
|
De.TRILINEAR_SAMPLINGMODE,
|
|
441
442
|
be.TEXTUREFORMAT_RGBA
|
|
442
|
-
), n =
|
|
443
|
-
return n && (n.fillStyle = "#f5f5f5", n.fillRect(0, 0, t, i),
|
|
443
|
+
), n = a.getContext();
|
|
444
|
+
return n && (n.fillStyle = "#f5f5f5", n.fillRect(0, 0, t, i), a.update()), a;
|
|
444
445
|
}
|
|
445
446
|
function de(s, e) {
|
|
446
447
|
if (s instanceof k) {
|
|
@@ -459,15 +460,15 @@ const y = 60, ue = 1;
|
|
|
459
460
|
function me(s) {
|
|
460
461
|
return s.targetedAnimations.map((t) => t.animation.framePerSecond).reduce((t, i) => t + i, 0) / s.targetedAnimations.length || 0;
|
|
461
462
|
}
|
|
462
|
-
function ve(s, e, t, i,
|
|
463
|
-
const o =
|
|
463
|
+
function ve(s, e, t, i, a, n) {
|
|
464
|
+
const o = a ? s.filter((c) => c.name === a) : s;
|
|
464
465
|
if (o.length === 0) {
|
|
465
|
-
console.warn(`No animations found for name: ${
|
|
466
|
+
console.warn(`No animations found for name: ${a}`);
|
|
466
467
|
return;
|
|
467
468
|
}
|
|
468
|
-
let
|
|
469
|
+
let r = 0;
|
|
469
470
|
const l = () => {
|
|
470
|
-
|
|
471
|
+
r++, r === o.length && n && n();
|
|
471
472
|
}, h = (c, u, m, f, p) => {
|
|
472
473
|
c.stop(), c.start(u, m, f, p), n && (u == !1 || u === void 0 && !c.loopAnimation ? c.onAnimationGroupEndObservable.addOnce(() => {
|
|
473
474
|
l();
|
|
@@ -490,8 +491,8 @@ function ve(s, e, t, i, r, n) {
|
|
|
490
491
|
function Ye(s, e, t) {
|
|
491
492
|
return new Promise((i) => {
|
|
492
493
|
s.stopAnimation(e), e.animations = [], Math.abs(e.alpha) > 2 * Math.PI && (e.alpha = Qe(e.alpha, 0, 2 * Math.PI));
|
|
493
|
-
const
|
|
494
|
-
if (t.target && Object.keys(t.target).length > 0 &&
|
|
494
|
+
const a = [], n = t.target, o = 0, r = n ? 1 : 0;
|
|
495
|
+
if (t.target && Object.keys(t.target).length > 0 && a.push(
|
|
495
496
|
T(
|
|
496
497
|
"cameraTargetLerp",
|
|
497
498
|
"target",
|
|
@@ -504,38 +505,38 @@ function Ye(s, e, t) {
|
|
|
504
505
|
C.ANIMATIONTYPE_VECTOR3,
|
|
505
506
|
o
|
|
506
507
|
)
|
|
507
|
-
),
|
|
508
|
+
), a.push(
|
|
508
509
|
T(
|
|
509
510
|
"cameraAlphaLerp",
|
|
510
511
|
"alpha",
|
|
511
512
|
e.alpha,
|
|
512
513
|
ge(t.lonDeg),
|
|
513
514
|
C.ANIMATIONTYPE_FLOAT,
|
|
514
|
-
|
|
515
|
+
r
|
|
515
516
|
)
|
|
516
|
-
),
|
|
517
|
+
), a.push(
|
|
517
518
|
T(
|
|
518
519
|
"cameraBetaLerp",
|
|
519
520
|
"beta",
|
|
520
521
|
e.beta,
|
|
521
522
|
ge(t.latDeg),
|
|
522
523
|
C.ANIMATIONTYPE_FLOAT,
|
|
523
|
-
|
|
524
|
+
r
|
|
524
525
|
)
|
|
525
526
|
), t.radius !== void 0) {
|
|
526
527
|
const c = Math.max(0.01, t.radius);
|
|
527
|
-
|
|
528
|
+
a.push(
|
|
528
529
|
T(
|
|
529
530
|
"cameraRadiusLerp",
|
|
530
531
|
"radius",
|
|
531
532
|
e.radius,
|
|
532
533
|
c,
|
|
533
534
|
C.ANIMATIONTYPE_FLOAT,
|
|
534
|
-
|
|
535
|
+
r
|
|
535
536
|
)
|
|
536
537
|
);
|
|
537
538
|
}
|
|
538
|
-
e.animations.push(...
|
|
539
|
+
e.animations.push(...a);
|
|
539
540
|
const h = e.useAutoRotationBehavior;
|
|
540
541
|
e.disableAutoRotationBehavior(), s.beginAnimation(
|
|
541
542
|
e,
|
|
@@ -552,20 +553,20 @@ function Ye(s, e, t) {
|
|
|
552
553
|
function ge(s) {
|
|
553
554
|
return s * Math.PI / 180;
|
|
554
555
|
}
|
|
555
|
-
function T(s, e, t, i,
|
|
556
|
-
const
|
|
557
|
-
|
|
556
|
+
function T(s, e, t, i, a, n = 0, o = C.ANIMATIONLOOPMODE_CONSTANT) {
|
|
557
|
+
const r = new qe();
|
|
558
|
+
r.setEasingMode(ke.EASINGMODE_EASEINOUT);
|
|
558
559
|
const l = new C(
|
|
559
560
|
s,
|
|
560
561
|
e,
|
|
561
562
|
y,
|
|
562
|
-
|
|
563
|
+
a,
|
|
563
564
|
o
|
|
564
565
|
), h = [];
|
|
565
566
|
return n > 0 && h.push({ frame: 0, value: t }), h.push({ frame: y * n, value: t }), h.push({
|
|
566
567
|
frame: y * (n + 1),
|
|
567
568
|
value: i
|
|
568
|
-
}), l.setKeys(h), l.setEasingFunction(
|
|
569
|
+
}), l.setKeys(h), l.setEasingFunction(r), l;
|
|
569
570
|
}
|
|
570
571
|
function Qe(s, e, t) {
|
|
571
572
|
return s < e ? s = t - (e - s) % (t - e) : s = e + (s - e) % (t - e);
|
|
@@ -605,26 +606,26 @@ function je(s, e, t, i) {
|
|
|
605
606
|
);
|
|
606
607
|
}), tt(s, e);
|
|
607
608
|
}
|
|
608
|
-
function Xe(s, e, t, i,
|
|
609
|
+
function Xe(s, e, t, i, a) {
|
|
609
610
|
const n = $e[s];
|
|
610
611
|
if (!n)
|
|
611
612
|
throw new Error("Unexpected texture name encountered.");
|
|
612
|
-
const o = e[n],
|
|
613
|
-
|
|
613
|
+
const o = e[n], r = o == null ? void 0 : o.fileLink;
|
|
614
|
+
r ? s === "reflectionTexture" ? r.endsWith(".env") || r.endsWith(".dds") ? i.addCubeTextureTask(
|
|
614
615
|
s,
|
|
615
|
-
|
|
616
|
+
r,
|
|
616
617
|
void 0,
|
|
617
618
|
!1,
|
|
618
619
|
void 0,
|
|
619
620
|
!0
|
|
620
|
-
) :
|
|
621
|
+
) : r.endsWith(".hdr") ? i.addHDRCubeTextureTask(
|
|
621
622
|
s,
|
|
622
|
-
|
|
623
|
+
r,
|
|
623
624
|
128,
|
|
624
625
|
!1,
|
|
625
626
|
!0,
|
|
626
627
|
!1
|
|
627
|
-
) : i.addTextureTask(s,
|
|
628
|
+
) : i.addTextureTask(s, r, !1, !1) : i.addTextureTask(s, r, !1, !1) : a && t[s] && (t[s] && t[s].dispose(), t[s] = null, Je(s, t));
|
|
628
629
|
}
|
|
629
630
|
function Je(s, e) {
|
|
630
631
|
s === "opacityTexture" && (e.useAlphaFromAlbedoTexture = !0), s === "metallicTexture" && (e.useRoughnessFromMetallicTextureAlpha = !1, e.useRoughnessFromMetallicTextureGreen = !1, e.useMetallnessFromMetallicTextureBlue = !1), s === "refractionTexture" && (e.subSurface.isRefractionEnabled = !1, e.subSurface.refractionIntensity = 1), s === "reflectionTexture" && (e.environmentIntensity = 1), s === "emissiveTexture" && (e.emissiveIntensity = 0, e.emissiveColor = new A(0, 0, 0), e.reflectionTexture);
|
|
@@ -652,15 +653,15 @@ class it {
|
|
|
652
653
|
* instead remove material textures when they aren't defined. this is useful for material editor applications
|
|
653
654
|
* where we want to undo changes are remove effects from display.
|
|
654
655
|
*/
|
|
655
|
-
async applyMaterial(e, t, i,
|
|
656
|
+
async applyMaterial(e, t, i, a) {
|
|
656
657
|
return new Promise((n) => {
|
|
657
658
|
const o = this.materialVariantMap.get(e);
|
|
658
659
|
this.materialVariantMap.set(e, {
|
|
659
660
|
...o,
|
|
660
661
|
...t
|
|
661
662
|
});
|
|
662
|
-
const
|
|
663
|
-
(c) => c.name ===
|
|
663
|
+
const r = this.renameClonedAsset(e), l = this.scene.materials.filter(
|
|
664
|
+
(c) => c.name === r
|
|
664
665
|
);
|
|
665
666
|
if (l.length === 0) {
|
|
666
667
|
n();
|
|
@@ -672,7 +673,7 @@ class it {
|
|
|
672
673
|
t,
|
|
673
674
|
c,
|
|
674
675
|
h,
|
|
675
|
-
|
|
676
|
+
a
|
|
676
677
|
)
|
|
677
678
|
), h.onProgress = (c, u, m) => {
|
|
678
679
|
i && i(c / u * 100, 100, m.name);
|
|
@@ -680,7 +681,7 @@ class it {
|
|
|
680
681
|
c.forEach((u) => {
|
|
681
682
|
const m = u;
|
|
682
683
|
i && i(100, 100, u.name), this.scene.materials.filter(
|
|
683
|
-
(p) => p.name ===
|
|
684
|
+
(p) => p.name === r
|
|
684
685
|
).forEach((p) => {
|
|
685
686
|
et(
|
|
686
687
|
u.name,
|
|
@@ -703,13 +704,13 @@ class it {
|
|
|
703
704
|
* @param getCurrentFrame A function that returns the current frame of the animation.
|
|
704
705
|
* @param getAnimationIsPlaying A function that returns whether the animation is currently playing.
|
|
705
706
|
*/
|
|
706
|
-
async applyModel(e, t, i,
|
|
707
|
+
async applyModel(e, t, i, a, n, o, r) {
|
|
707
708
|
var m, f, p;
|
|
708
709
|
if (i && t && !this.keysThatRemovedBaseModel.includes(e) && this.keysThatRemovedBaseModel.push(e), !i)
|
|
709
710
|
return this.keysThatRemovedBaseModel.includes(e) && this.keysThatRemovedBaseModel.length === 1 && await this.setBaseModelEnabled(!0), (m = this.loadedContainerForKey.get(e)) == null || m.dispose(), this.loadedContainerForKey.delete(e), (f = this.loadedMaterialsForKey.get(e)) == null || f.forEach((b) => b.dispose()), this.loadedMaterialsForKey.delete(e), this.keysThatRemovedBaseModel = this.keysThatRemovedBaseModel.filter(
|
|
710
711
|
(b) => b !== e
|
|
711
712
|
), Promise.resolve(void 0);
|
|
712
|
-
const h = (await N(i, this.scene,
|
|
713
|
+
const h = (await N(i, this.scene, a)).instantiateModelsToScene(
|
|
713
714
|
this.renameClonedAsset,
|
|
714
715
|
!0
|
|
715
716
|
);
|
|
@@ -724,7 +725,7 @@ class it {
|
|
|
724
725
|
c.from,
|
|
725
726
|
w
|
|
726
727
|
), b != null) {
|
|
727
|
-
const R =
|
|
728
|
+
const R = r && r() || !0;
|
|
728
729
|
Ze(
|
|
729
730
|
h.animationGroups,
|
|
730
731
|
b + (R ? 2 : 0),
|
|
@@ -762,8 +763,8 @@ function we(s) {
|
|
|
762
763
|
const e = [];
|
|
763
764
|
return s.rootNodes.forEach((t) => {
|
|
764
765
|
t.getChildMeshes().forEach((i) => {
|
|
765
|
-
i.material && !e.includes(i.material) && e.push(i.material), i.subMeshes && i.subMeshes.forEach((
|
|
766
|
-
const n =
|
|
766
|
+
i.material && !e.includes(i.material) && e.push(i.material), i.subMeshes && i.subMeshes.forEach((a) => {
|
|
767
|
+
const n = a.getMaterial(!1);
|
|
767
768
|
n && !e.includes(n) && e.push(n);
|
|
768
769
|
});
|
|
769
770
|
});
|
|
@@ -783,16 +784,16 @@ class nt {
|
|
|
783
784
|
const {
|
|
784
785
|
enablePicking: t,
|
|
785
786
|
modelDetails: i,
|
|
786
|
-
previewService:
|
|
787
|
+
previewService: a,
|
|
787
788
|
progressHandler: n,
|
|
788
789
|
scene: o
|
|
789
790
|
} = e;
|
|
790
|
-
this.enablePicking = t, this.contextService = i.contextService, this.id = We(), this.previewService =
|
|
791
|
+
this.enablePicking = t, this.contextService = i.contextService, this.id = We(), this.previewService = a, this.scene = o, this.variantManager = new it(
|
|
791
792
|
o,
|
|
792
793
|
this.renameClonedAsset.bind(this),
|
|
793
794
|
this.setBaseModelEnabled.bind(this)
|
|
794
795
|
), this.transformRoot = new Se("root", this.scene);
|
|
795
|
-
const
|
|
796
|
+
const r = async () => {
|
|
796
797
|
if (!i.model)
|
|
797
798
|
throw new Error(
|
|
798
799
|
"Model container constructed with no URL. This is currently unsupported."
|
|
@@ -803,10 +804,10 @@ class nt {
|
|
|
803
804
|
n
|
|
804
805
|
), await this.instantiate(), this;
|
|
805
806
|
};
|
|
806
|
-
this.importPromise =
|
|
807
|
+
this.importPromise = r();
|
|
807
808
|
}
|
|
808
809
|
//#region Interface implementation
|
|
809
|
-
async applyMaterialVariant(e, t, i,
|
|
810
|
+
async applyMaterialVariant(e, t, i, a) {
|
|
810
811
|
if (!this.initialized) {
|
|
811
812
|
if (this.materialReadyToLoadCallbacks.has(e)) {
|
|
812
813
|
const o = this.materialReadyToLoadCallbacks.get(e);
|
|
@@ -817,7 +818,7 @@ class nt {
|
|
|
817
818
|
e,
|
|
818
819
|
t,
|
|
819
820
|
i,
|
|
820
|
-
|
|
821
|
+
a
|
|
821
822
|
)
|
|
822
823
|
);
|
|
823
824
|
} else {
|
|
@@ -833,7 +834,7 @@ class nt {
|
|
|
833
834
|
e,
|
|
834
835
|
t,
|
|
835
836
|
i,
|
|
836
|
-
|
|
837
|
+
a
|
|
837
838
|
)
|
|
838
839
|
);
|
|
839
840
|
}
|
|
@@ -843,14 +844,14 @@ class nt {
|
|
|
843
844
|
await this.variantManager.applyMaterial(
|
|
844
845
|
e,
|
|
845
846
|
i,
|
|
846
|
-
(o,
|
|
847
|
+
(o, r, l) => {
|
|
847
848
|
this.materialVariantObservable.notifyObservers({
|
|
848
849
|
remainingCount: o,
|
|
849
|
-
totalCount:
|
|
850
|
+
totalCount: r,
|
|
850
851
|
taskName: l
|
|
851
852
|
});
|
|
852
853
|
},
|
|
853
|
-
|
|
854
|
+
a
|
|
854
855
|
);
|
|
855
856
|
};
|
|
856
857
|
if (this.materialChangesInProgress.includes(e)) {
|
|
@@ -871,8 +872,8 @@ class nt {
|
|
|
871
872
|
const o = this.queuedMaterialChanges.get(e);
|
|
872
873
|
if (!o)
|
|
873
874
|
throw new Error("Target material is undefined");
|
|
874
|
-
o.forEach(async (
|
|
875
|
-
await
|
|
875
|
+
o.forEach(async (r) => {
|
|
876
|
+
await r();
|
|
876
877
|
}), this.queuedMaterialChanges.delete(e);
|
|
877
878
|
}
|
|
878
879
|
this.materialChangesInProgress.splice(
|
|
@@ -881,13 +882,13 @@ class nt {
|
|
|
881
882
|
), this.configureGlowLayer(), this.scene.cleanCachedTextureBuffer();
|
|
882
883
|
}
|
|
883
884
|
async applyModelVariant(e, t, i) {
|
|
884
|
-
const
|
|
885
|
+
const a = () => this.variantManager.applyModel(
|
|
885
886
|
e,
|
|
886
887
|
i,
|
|
887
888
|
t == null ? void 0 : t.model,
|
|
888
|
-
(
|
|
889
|
+
(r) => {
|
|
889
890
|
this.modelVariantObservable.notifyObservers({
|
|
890
|
-
...
|
|
891
|
+
...r,
|
|
891
892
|
key: e
|
|
892
893
|
});
|
|
893
894
|
},
|
|
@@ -896,24 +897,24 @@ class nt {
|
|
|
896
897
|
this.getAnimationIsPlaying.bind(this)
|
|
897
898
|
), n = async () => {
|
|
898
899
|
this.modelChangesInProgress.push(e);
|
|
899
|
-
let
|
|
900
|
+
let r = await a();
|
|
900
901
|
if (this.queuedModelChanges.has(e)) {
|
|
901
902
|
const l = this.queuedModelChanges.get(e);
|
|
902
903
|
if (!l)
|
|
903
904
|
throw new Error("Queued change resolved undefined");
|
|
904
|
-
|
|
905
|
+
r = await l(), this.queuedModelChanges.delete(e);
|
|
905
906
|
}
|
|
906
907
|
return this.modelChangesInProgress.splice(
|
|
907
908
|
this.modelChangesInProgress.indexOf(e),
|
|
908
909
|
1
|
|
909
|
-
),
|
|
910
|
+
), r;
|
|
910
911
|
};
|
|
911
912
|
if (!this.initialized || this.modelChangesInProgress.includes(e)) {
|
|
912
|
-
const
|
|
913
|
-
const l = await
|
|
913
|
+
const r = async () => {
|
|
914
|
+
const l = await a();
|
|
914
915
|
return l ? this.configureModelInstance(l) : this.configureGlowLayer(), l;
|
|
915
916
|
};
|
|
916
|
-
this.queuedModelChanges.set(e,
|
|
917
|
+
this.queuedModelChanges.set(e, r);
|
|
917
918
|
return;
|
|
918
919
|
}
|
|
919
920
|
const o = await n();
|
|
@@ -929,7 +930,7 @@ class nt {
|
|
|
929
930
|
let t = () => {
|
|
930
931
|
};
|
|
931
932
|
const i = async () => {
|
|
932
|
-
this.isExecutingAnimation = !0, await new Promise((
|
|
933
|
+
this.isExecutingAnimation = !0, await new Promise((a) => {
|
|
933
934
|
var o;
|
|
934
935
|
const n = [
|
|
935
936
|
...((o = this.modelInstance) == null ? void 0 : o.animationGroups) || [],
|
|
@@ -941,12 +942,12 @@ class nt {
|
|
|
941
942
|
e.to,
|
|
942
943
|
e.from,
|
|
943
944
|
e.name ? this.renameClonedAsset(e.name) : void 0,
|
|
944
|
-
|
|
945
|
+
a
|
|
945
946
|
);
|
|
946
947
|
}), this.isExecutingAnimation = !1, this.queuedAnimationFunction && this.queuedAnimationFunction(), this.queuedAnimationFunction = void 0, t();
|
|
947
948
|
};
|
|
948
|
-
return this.isExecutingAnimation ? (this.queuedAnimationFunction = i, new Promise((
|
|
949
|
-
t =
|
|
949
|
+
return this.isExecutingAnimation ? (this.queuedAnimationFunction = i, new Promise((a) => {
|
|
950
|
+
t = a;
|
|
950
951
|
})) : i();
|
|
951
952
|
}
|
|
952
953
|
getAnimations(e) {
|
|
@@ -956,7 +957,7 @@ class nt {
|
|
|
956
957
|
this.variantManager.getAnimationGroups(),
|
|
957
958
|
this.renameClonedAsset("")
|
|
958
959
|
) : []
|
|
959
|
-
].map((t, i) => ({ ...t, name: t.name || `UNNAMED_ANIMATION_${i}` })).filter((t, i,
|
|
960
|
+
].map((t, i) => ({ ...t, name: t.name || `UNNAMED_ANIMATION_${i}` })).filter((t, i, a) => a.indexOf(a.find((n) => n.name === t.name)) == i);
|
|
960
961
|
}
|
|
961
962
|
getId() {
|
|
962
963
|
return this.id;
|
|
@@ -1024,8 +1025,8 @@ class nt {
|
|
|
1024
1025
|
e.rootNodes.forEach((t) => {
|
|
1025
1026
|
t.getChildMeshes(!1).forEach((i) => {
|
|
1026
1027
|
i.name === "targetcube_t" || i.name === "backgroundShell" || (i.actionManager || (i.actionManager = new O(this.scene)), i.actionManager.registerAction(
|
|
1027
|
-
new oe(O.OnPointerOverTrigger, (
|
|
1028
|
-
|
|
1028
|
+
new oe(O.OnPointerOverTrigger, (a) => {
|
|
1029
|
+
a.meshUnderPointer && i.material && this.materialSelectedObservable.notifyObservers({
|
|
1029
1030
|
id: i.material.id,
|
|
1030
1031
|
name: this.stripIdFromName(i.material.name)
|
|
1031
1032
|
});
|
|
@@ -1069,14 +1070,14 @@ class nt {
|
|
|
1069
1070
|
throw new Error(
|
|
1070
1071
|
"Transform disposed! This should never happen unless there is a race condition present!"
|
|
1071
1072
|
);
|
|
1072
|
-
const t = this.transformRoot.position, i = this.transformRoot.rotationQuaternion,
|
|
1073
|
+
const t = this.transformRoot.position, i = this.transformRoot.rotationQuaternion, a = this.transformRoot.scaling;
|
|
1073
1074
|
this.transformRoot.position = g.Zero(), this.transformRoot.rotationQuaternion = x.Identity(), this.transformRoot.scaling = g.One();
|
|
1074
1075
|
for (const o of e.rootNodes) {
|
|
1075
1076
|
o.parent = this.transformRoot;
|
|
1076
|
-
for (const
|
|
1077
|
-
|
|
1077
|
+
for (const r of o.getChildMeshes(!1))
|
|
1078
|
+
r.alwaysSelectAsActiveMesh = !0;
|
|
1078
1079
|
}
|
|
1079
|
-
this.transformRoot.position = t, this.transformRoot.rotationQuaternion = i, this.transformRoot.scaling =
|
|
1080
|
+
this.transformRoot.position = t, this.transformRoot.rotationQuaternion = i, this.transformRoot.scaling = a, this.canvasPanels = ((n = this.contextService) == null ? void 0 : n.getAll()) || /* @__PURE__ */ new Map(), Ue(
|
|
1080
1081
|
this.materials.concat(this.variantManager.getAllMaterials()),
|
|
1081
1082
|
this.scene,
|
|
1082
1083
|
this.canvasPanels,
|
|
@@ -1120,8 +1121,8 @@ class nt {
|
|
|
1120
1121
|
var e;
|
|
1121
1122
|
(e = this.canvasPanels) == null || e.forEach(
|
|
1122
1123
|
(t, i) => {
|
|
1123
|
-
const
|
|
1124
|
-
|
|
1124
|
+
const a = this.dynamicTextures.get(i);
|
|
1125
|
+
a && t.getStaticContextDirty() && a.isReady() && (a.update(!1), t.setStaticContextDirty(!1));
|
|
1125
1126
|
}
|
|
1126
1127
|
);
|
|
1127
1128
|
}
|
|
@@ -1183,17 +1184,17 @@ class nt {
|
|
|
1183
1184
|
//#endregion
|
|
1184
1185
|
}
|
|
1185
1186
|
class z extends fe {
|
|
1186
|
-
constructor(e, t, i,
|
|
1187
|
+
constructor(e, t, i, a, n, o, r, l) {
|
|
1187
1188
|
super(
|
|
1188
1189
|
e,
|
|
1189
1190
|
t,
|
|
1190
1191
|
i,
|
|
1191
|
-
|
|
1192
|
+
a,
|
|
1192
1193
|
n,
|
|
1193
1194
|
o,
|
|
1194
1195
|
l
|
|
1195
|
-
), this.lastFocus = new g(0, 0, 0), this._isRunningFramingBehavior = !1, this.panDenominator = 1, this.panEnabled = !0, this.minZ = 0.01, this.updateRadiusBounds(this.radius), this.enableFramingBehavior(), this.wheelDeltaPercentage = 0.01, this.pinchDeltaPercentage = 5e-3, this.useNaturalPinchZoom = !0,
|
|
1196
|
-
|
|
1196
|
+
), this.lastFocus = new g(0, 0, 0), this._isRunningFramingBehavior = !1, this.panDenominator = 1, this.panEnabled = !0, this.minZ = 0.01, this.updateRadiusBounds(this.radius), this.enableFramingBehavior(), this.wheelDeltaPercentage = 0.01, this.pinchDeltaPercentage = 5e-3, this.useNaturalPinchZoom = !0, r.camera.autoOrientation && (this.alpha += Math.PI), r && (r.camera.limits.min.beta && (this.lowerBetaLimit = r.camera.limits.min.beta), r.camera.limits.max.beta && (this.upperBetaLimit = r.camera.limits.max.beta), r.camera.limits.min.alpha && (this.lowerAlphaLimit = r.camera.limits.min.alpha), r.camera.limits.max.alpha && (this.upperAlphaLimit = r.camera.limits.max.alpha), r.camera.limits.min.radius && (this.lowerRadiusLimit = r.camera.limits.min.radius), r.camera.limits.max.radius && (this.upperRadiusLimit = r.camera.limits.max.radius), r.camera.autoRotation.enabled && this.enableAutoRotationBehavior(
|
|
1197
|
+
r.camera.autoRotation.idleTimeMs
|
|
1197
1198
|
));
|
|
1198
1199
|
}
|
|
1199
1200
|
updateConfiguration(e) {
|
|
@@ -1245,14 +1246,14 @@ class z extends fe {
|
|
|
1245
1246
|
this._isRunningFramingBehavior = !0, this.framingBehaviourCallback = e;
|
|
1246
1247
|
const i = this.getFramingBehavior();
|
|
1247
1248
|
i.framingTime = t || 800;
|
|
1248
|
-
const
|
|
1249
|
+
const a = () => {
|
|
1249
1250
|
this.isRunningFramingBehavior = !1;
|
|
1250
|
-
}, n = I(this._scene), o = n.max.subtract(n.min),
|
|
1251
|
-
this.updateRadiusBounds(o.length() * 1.5), this.wheelPrecision = 100 / this.radius, this.panningInertia = 0, this.panningOriginTarget.copyFrom(
|
|
1251
|
+
}, n = I(this._scene), o = n.max.subtract(n.min), r = n.min.add(o.scale(0.5));
|
|
1252
|
+
this.updateRadiusBounds(o.length() * 1.5), this.wheelPrecision = 100 / this.radius, this.panningInertia = 0, this.panningOriginTarget.copyFrom(r), this.panDenominator = o.length(), this.lastFocus.copyFrom(r), i.zoomOnBoundingInfo(
|
|
1252
1253
|
n.min,
|
|
1253
1254
|
n.max,
|
|
1254
1255
|
void 0,
|
|
1255
|
-
|
|
1256
|
+
a
|
|
1256
1257
|
), i.framingTime = 0;
|
|
1257
1258
|
}
|
|
1258
1259
|
/**
|
|
@@ -1284,7 +1285,7 @@ class z extends fe {
|
|
|
1284
1285
|
*/
|
|
1285
1286
|
static create(e, t, i) {
|
|
1286
1287
|
var l;
|
|
1287
|
-
const
|
|
1288
|
+
const a = I(e), n = a.max.subtract(a.min), o = a.min.add(n.scale(0.5)), r = new z(
|
|
1288
1289
|
"ProductCamera",
|
|
1289
1290
|
-(Math.PI / 2),
|
|
1290
1291
|
Math.PI / 2,
|
|
@@ -1293,11 +1294,11 @@ class z extends fe {
|
|
|
1293
1294
|
e,
|
|
1294
1295
|
t
|
|
1295
1296
|
);
|
|
1296
|
-
return
|
|
1297
|
+
return r.setPanEnabled(
|
|
1297
1298
|
((l = t.options) == null ? void 0 : l.noPan) !== void 0 ? !t.options.noPan : !0
|
|
1298
|
-
),
|
|
1299
|
-
|
|
1300
|
-
}), i && (e.activeCamera =
|
|
1299
|
+
), r.panningInertia = 0, r.panningOriginTarget.copyFrom(o), r.panDenominator = n.length(), r.onAfterCheckInputsObservable.addOnce(() => {
|
|
1300
|
+
r.setPanEnabled(r.panEnabled);
|
|
1301
|
+
}), i && (e.activeCamera = r), r;
|
|
1301
1302
|
}
|
|
1302
1303
|
}
|
|
1303
1304
|
function I(s) {
|
|
@@ -1327,9 +1328,9 @@ class st {
|
|
|
1327
1328
|
return this.currentConfiguration;
|
|
1328
1329
|
}
|
|
1329
1330
|
setConfiguration(e) {
|
|
1330
|
-
var t, i,
|
|
1331
|
+
var t, i, a, n, o, r, l, h, c, u, m, f, p, b, w, R, V, G, _, H, U, K, W, Y, Q, Z, $, j, X, J, ee, te, ie;
|
|
1331
1332
|
if (this.renderingPipeline.isSupported) {
|
|
1332
|
-
if (this.renderingPipeline.samples = ((t = e.antiAliasing) == null ? void 0 : t.samples) ?? d.antiAliasing.samples, this.renderingPipeline.fxaaEnabled = ((i = e.antiAliasing) == null ? void 0 : i.fxaaEnabled) ?? d.antiAliasing.fxaaEnabled, this.renderingPipeline.bloomEnabled = ((
|
|
1333
|
+
if (this.renderingPipeline.samples = ((t = e.antiAliasing) == null ? void 0 : t.samples) ?? d.antiAliasing.samples, this.renderingPipeline.fxaaEnabled = ((i = e.antiAliasing) == null ? void 0 : i.fxaaEnabled) ?? d.antiAliasing.fxaaEnabled, this.renderingPipeline.bloomEnabled = ((a = e.bloom) == null ? void 0 : a.enabled) ?? d.bloom.enabled, this.renderingPipeline.bloomKernel = ((n = e.bloom) == null ? void 0 : n.kernel) ?? d.bloom.kernel, this.renderingPipeline.bloomScale = ((o = e.bloom) == null ? void 0 : o.scale) ?? d.bloom.scale, this.renderingPipeline.bloomThreshold = ((r = e.bloom) == null ? void 0 : r.threshold) ?? d.bloom.threshold, this.renderingPipeline.bloomWeight = ((l = e.bloom) == null ? void 0 : l.weight) ?? d.bloom.weight, this.renderingPipeline.chromaticAberrationEnabled = ((h = e.chromaticAberration) == null ? void 0 : h.enabled) ?? d.chromaticAberration.enabled, this.renderingPipeline.chromaticAberration.aberrationAmount = ((c = e.chromaticAberration) == null ? void 0 : c.aberrationAmount) ?? d.chromaticAberration.aberrationAmount, this.renderingPipeline.chromaticAberration.radialIntensity = ((u = e.chromaticAberration) == null ? void 0 : u.radialIntensity) ?? d.chromaticAberration.radialIntensity, this.renderingPipeline.chromaticAberration.direction = (m = e.chromaticAberration) != null && m.direction ? new se(
|
|
1333
1334
|
e.chromaticAberration.direction.x,
|
|
1334
1335
|
e.chromaticAberration.direction.y
|
|
1335
1336
|
) : new se(
|
|
@@ -1398,7 +1399,7 @@ function F(s) {
|
|
|
1398
1399
|
function S(s) {
|
|
1399
1400
|
return { x: s.x, y: s.y, z: s.z };
|
|
1400
1401
|
}
|
|
1401
|
-
class
|
|
1402
|
+
class Qt {
|
|
1402
1403
|
constructor(e) {
|
|
1403
1404
|
var l;
|
|
1404
1405
|
this.focusLostNotified = !1, this.focusLostObservable = new M(), this.modelLoadEventCallbacks = [], this.modelContainers = /* @__PURE__ */ new Map(), this.plugins = [], this.initComplete = !1, this.isAnimatingCamera = !1, this.renderLoop = () => {
|
|
@@ -1420,17 +1421,17 @@ class Yt {
|
|
|
1420
1421
|
);
|
|
1421
1422
|
this.scene.render(), this.camera.isRunningFramingBehavior && this.camera.getFramingBehavior().isUserIsMoving && (this.camera.isRunningFramingBehavior = !1);
|
|
1422
1423
|
const c = Math.max((this.camera.lowerRadiusLimit ?? 1) * 0.01, 1e-3);
|
|
1423
|
-
!this.camera.isRunningFramingBehavior && !this.camera.target.equalsWithEpsilon(this.camera.lastFocus, c) && !this.focusLostNotified && (this.focusLostObservable.notifyObservers(void 0), this.focusLostNotified = !0)
|
|
1424
|
+
!this.camera.isRunningFramingBehavior && !this.camera.target.equalsWithEpsilon(this.camera.lastFocus, c) && !this.focusLostNotified && (this.focusLostObservable.notifyObservers(void 0), this.focusLostNotified = !0);
|
|
1424
1425
|
}, this.configuration = new ce(e);
|
|
1425
1426
|
const i = (() => {
|
|
1426
1427
|
if (!(e != null && e.noRender))
|
|
1427
1428
|
return this.configuration.createCanvas();
|
|
1428
|
-
})(),
|
|
1429
|
+
})(), a = "1.5.7";
|
|
1429
1430
|
Me.Configuration = {
|
|
1430
1431
|
decoder: {
|
|
1431
|
-
wasmUrl: `https://www.gstatic.com/draco/versioned/decoders/${
|
|
1432
|
-
wasmBinaryUrl: `https://www.gstatic.com/draco/versioned/decoders/${
|
|
1433
|
-
fallbackUrl: `https://www.gstatic.com/draco/versioned/decoders/${
|
|
1432
|
+
wasmUrl: `https://www.gstatic.com/draco/versioned/decoders/${a}/draco_wasm_wrapper_gltf.js`,
|
|
1433
|
+
wasmBinaryUrl: `https://www.gstatic.com/draco/versioned/decoders/${a}/draco_decoder_gltf.wasm`,
|
|
1434
|
+
fallbackUrl: `https://www.gstatic.com/draco/versioned/decoders/${a}/draco_decoder_gltf.js`
|
|
1434
1435
|
}
|
|
1435
1436
|
}, i && (i.getContext("webgl2") || i.getContext("webgl"));
|
|
1436
1437
|
const n = console.log;
|
|
@@ -1450,11 +1451,11 @@ class Yt {
|
|
|
1450
1451
|
!1,
|
|
1451
1452
|
this.camera
|
|
1452
1453
|
), this.scene.clearColor = this.configuration.scene.clearColor;
|
|
1453
|
-
const
|
|
1454
|
+
const r = ne.CreateFromPrefilteredData(
|
|
1454
1455
|
this.configuration.scene.environment.file,
|
|
1455
1456
|
this.scene
|
|
1456
1457
|
);
|
|
1457
|
-
|
|
1458
|
+
r.name = "initial-environment-cube", r.rotationY = this.configuration.scene.environment.rotationY, this.scene.environmentTexture = r, this.scene.environmentIntensity = this.configuration.scene.environment.intensity, (l = this.configuration.options) != null && l.renderingPipelineConfiguration ? this.renderingPipeline.setConfiguration(
|
|
1458
1459
|
this.configuration.options.renderingPipelineConfiguration
|
|
1459
1460
|
) : (this.scene.imageProcessingConfiguration.exposure = this.configuration.lighting.exposure, this.scene.imageProcessingConfiguration.contrast = this.configuration.lighting.contrast), this.glowLayerManager = new He(
|
|
1460
1461
|
this.scene,
|
|
@@ -1506,7 +1507,7 @@ class Yt {
|
|
|
1506
1507
|
this.plugins.forEach((e) => e.dispose(!0)), this.renderingPipeline.dispose(), this.engine && this.engine.dispose(), window.removeEventListener("resize", this.fireResizeEvent);
|
|
1507
1508
|
}
|
|
1508
1509
|
executeCameraAnimation(e) {
|
|
1509
|
-
if (!this.camera || this.scene.activeCamera !== this.camera || this.getAllModels().length === 0 || !this.getAllModels().some((
|
|
1510
|
+
if (!this.camera || this.scene.activeCamera !== this.camera || this.getAllModels().length === 0 || !this.getAllModels().some((a) => a.getIsInitialized()))
|
|
1510
1511
|
return this.queuedCameraAnimation = e, Promise.resolve();
|
|
1511
1512
|
let t = () => {
|
|
1512
1513
|
};
|
|
@@ -1517,8 +1518,8 @@ class Yt {
|
|
|
1517
1518
|
e
|
|
1518
1519
|
), this.isAnimatingCamera = !1, this.queuedAnimationFunction && this.queuedAnimationFunction(), this.queuedAnimationFunction = void 0, t();
|
|
1519
1520
|
};
|
|
1520
|
-
return this.isAnimatingCamera ? (this.queuedAnimationFunction = i, new Promise((
|
|
1521
|
-
t =
|
|
1521
|
+
return this.isAnimatingCamera ? (this.queuedAnimationFunction = i, new Promise((a) => {
|
|
1522
|
+
t = a;
|
|
1522
1523
|
})) : i();
|
|
1523
1524
|
}
|
|
1524
1525
|
getCameraPose() {
|
|
@@ -1555,13 +1556,13 @@ class Yt {
|
|
|
1555
1556
|
const t = async () => {
|
|
1556
1557
|
this.isAnimatingCamera = !0, await new Promise((i) => {
|
|
1557
1558
|
this.focusLostNotified = !1;
|
|
1558
|
-
const
|
|
1559
|
+
const a = () => {
|
|
1559
1560
|
const n = this.configuration;
|
|
1560
1561
|
this.camera.rerunFramingBehavior(() => {
|
|
1561
1562
|
n.camera.limits.min.radius && (this.camera.lowerRadiusLimit = n.camera.limits.min.radius), n.camera.limits.max.radius && (this.camera.upperRadiusLimit = n.camera.limits.max.radius), i();
|
|
1562
1563
|
});
|
|
1563
1564
|
};
|
|
1564
|
-
this.scene.onAfterRenderObservable.addOnce(
|
|
1565
|
+
this.scene.onAfterRenderObservable.addOnce(a);
|
|
1565
1566
|
}), this.isAnimatingCamera = !1, this.queuedAnimationFunction && this.queuedAnimationFunction(), this.queuedAnimationFunction = void 0, e();
|
|
1566
1567
|
};
|
|
1567
1568
|
return this.isAnimatingCamera ? (this.queuedAnimationFunction = t, new Promise((i) => {
|
|
@@ -1590,19 +1591,24 @@ class Yt {
|
|
|
1590
1591
|
0,
|
|
1591
1592
|
g.Zero(),
|
|
1592
1593
|
this.scene
|
|
1593
|
-
);
|
|
1594
|
+
), a = t.latDeg * Math.PI / 180, n = t.lonDeg * Math.PI / 180;
|
|
1595
|
+
i.target = t.target ? new g(t.target.x, t.target.y, t.target.z) : g.Zero(), i.alpha = n, i.beta = a, i.radius = t.radius || this.camera.radius, i.minZ = 0.01;
|
|
1594
1596
|
try {
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1597
|
+
return await new Promise((o) => {
|
|
1598
|
+
const r = this.scene.onBeforeRenderObservable.add(async () => {
|
|
1599
|
+
this.scene.onBeforeRenderObservable.remove(r);
|
|
1600
|
+
const l = await xe.CreateScreenshotUsingRenderTargetAsync(
|
|
1601
|
+
this.engine,
|
|
1602
|
+
i,
|
|
1603
|
+
e,
|
|
1604
|
+
"image/png",
|
|
1605
|
+
2,
|
|
1606
|
+
!0
|
|
1607
|
+
);
|
|
1608
|
+
return i.dispose(), o(l);
|
|
1609
|
+
});
|
|
1610
|
+
this.scene.render(), this.engine.endFrame();
|
|
1611
|
+
});
|
|
1606
1612
|
} catch {
|
|
1607
1613
|
throw i.isDisposed() || i.dispose(), new Error("Failed to render screenshot");
|
|
1608
1614
|
}
|
|
@@ -1611,18 +1617,18 @@ class Yt {
|
|
|
1611
1617
|
const e = this.configuration;
|
|
1612
1618
|
if (!e)
|
|
1613
1619
|
return !0;
|
|
1614
|
-
const t = e.camera.limits.min.alpha, i = e.camera.limits.max.alpha,
|
|
1615
|
-
if (t === void 0 || i === void 0 ||
|
|
1620
|
+
const t = e.camera.limits.min.alpha, i = e.camera.limits.max.alpha, a = e.camera.limits.min.beta, n = e.camera.limits.max.beta;
|
|
1621
|
+
if (t === void 0 || i === void 0 || a === void 0 || n === void 0)
|
|
1616
1622
|
return !0;
|
|
1617
|
-
const o = [t, i],
|
|
1623
|
+
const o = [t, i], r = [a, n], l = o.every((c) => c === t), h = r.every((c) => c === a);
|
|
1618
1624
|
return !l && !h;
|
|
1619
1625
|
}
|
|
1620
1626
|
fireResizeEvent() {
|
|
1621
1627
|
this.getNumViewports() > 0 && this.engine.resize();
|
|
1622
1628
|
}
|
|
1623
1629
|
setHighlights(e, t) {
|
|
1624
|
-
var
|
|
1625
|
-
e.length === 0 && ((
|
|
1630
|
+
var a;
|
|
1631
|
+
e.length === 0 && ((a = this.highlightLayer) == null || a.dispose(), this.highlightLayer = void 0), this.highlightLayer || (this.highlightLayer = new Ae("highlights", this.scene, {
|
|
1626
1632
|
isStroke: !0,
|
|
1627
1633
|
blurVerticalSize: 0.85,
|
|
1628
1634
|
blurHorizontalSize: 0.85
|
|
@@ -1630,13 +1636,13 @@ class Yt {
|
|
|
1630
1636
|
const i = t ? new A(t[0], t[1], t[2]).toLinearSpace() : void 0;
|
|
1631
1637
|
e.forEach((n) => {
|
|
1632
1638
|
const o = this.scene.materials.find(
|
|
1633
|
-
(
|
|
1639
|
+
(r) => r.name === n.name && r.id === n.id
|
|
1634
1640
|
);
|
|
1635
1641
|
o && o.getBindedMeshes().forEach(
|
|
1636
|
-
(
|
|
1642
|
+
(r) => {
|
|
1637
1643
|
var l;
|
|
1638
1644
|
return (l = this.highlightLayer) == null ? void 0 : l.addMesh(
|
|
1639
|
-
|
|
1645
|
+
r,
|
|
1640
1646
|
i || A.FromHexString("#fcba03")
|
|
1641
1647
|
);
|
|
1642
1648
|
}
|
|
@@ -1647,12 +1653,12 @@ class Yt {
|
|
|
1647
1653
|
this.renderingPipeline && this.renderingPipeline.setConfiguration(e);
|
|
1648
1654
|
}
|
|
1649
1655
|
loadModel(e, t) {
|
|
1650
|
-
const { refocusCamera: i = !0, progressHandler:
|
|
1656
|
+
const { refocusCamera: i = !0, progressHandler: a } = t ?? {}, n = new nt({
|
|
1651
1657
|
enablePicking: this.configuration.highlights.enabled,
|
|
1652
1658
|
modelDetails: e,
|
|
1653
1659
|
scene: this.scene,
|
|
1654
1660
|
previewService: this,
|
|
1655
|
-
progressHandler:
|
|
1661
|
+
progressHandler: a
|
|
1656
1662
|
});
|
|
1657
1663
|
return n.getInitializationPromise().then(() => {
|
|
1658
1664
|
if (this.modelContainers.size <= 1 && i) {
|
|
@@ -1690,7 +1696,7 @@ class Yt {
|
|
|
1690
1696
|
}
|
|
1691
1697
|
unregisterPlugin(e) {
|
|
1692
1698
|
const t = this.plugins.indexOf(e);
|
|
1693
|
-
t > -1 && this.plugins.splice(t, 1).forEach((
|
|
1699
|
+
t > -1 && this.plugins.splice(t, 1).forEach((a) => a.dispose(!1));
|
|
1694
1700
|
}
|
|
1695
1701
|
getGlowLayerManager() {
|
|
1696
1702
|
return this.glowLayerManager;
|
|
@@ -1708,28 +1714,28 @@ class Yt {
|
|
|
1708
1714
|
* Flips a transform around the origin.
|
|
1709
1715
|
*/
|
|
1710
1716
|
flipTransform(e, t, i) {
|
|
1711
|
-
const
|
|
1717
|
+
const a = re.Compose(
|
|
1712
1718
|
F(i || { x: 1, y: 1, z: 1 }),
|
|
1713
1719
|
x.FromEulerVector(
|
|
1714
1720
|
F(t || { x: 0, y: 0, z: 0 })
|
|
1715
1721
|
),
|
|
1716
1722
|
F(e || { x: 0, y: 0, z: 0 })
|
|
1717
|
-
), n = re.RotationAxis(g.Up(), Math.PI), o =
|
|
1718
|
-
return o.decompose(h, l,
|
|
1719
|
-
position: S(
|
|
1723
|
+
), n = re.RotationAxis(g.Up(), Math.PI), o = a.multiply(n), r = g.Zero(), l = x.Identity(), h = g.Zero();
|
|
1724
|
+
return o.decompose(h, l, r), l.multiplyInPlace(x.FromEulerAngles(0, Math.PI, 0)), {
|
|
1725
|
+
position: S(r),
|
|
1720
1726
|
rotation: S(l.toEulerAngles()),
|
|
1721
1727
|
scale: S(h)
|
|
1722
1728
|
};
|
|
1723
1729
|
}
|
|
1724
1730
|
updatePreviewOptions(e) {
|
|
1725
|
-
var
|
|
1731
|
+
var a, n;
|
|
1726
1732
|
const t = new ce(e);
|
|
1727
1733
|
this.configuration.highlights.enabled !== t.highlights.enabled && this.engine.setStencilBuffer(t.highlights.enabled), this.scene.clearColor = t.scene.clearColor;
|
|
1728
1734
|
let i = this.scene.environmentTexture;
|
|
1729
1735
|
this.configuration.scene.environment.file !== t.scene.environment.file && (i = ne.CreateFromPrefilteredData(
|
|
1730
1736
|
t.scene.environment.file,
|
|
1731
1737
|
this.scene
|
|
1732
|
-
), i.name = "updated-environment-cube", i.rotationY = this.configuration.scene.environment.rotationY, this.scene.environmentTexture = i), i.rotationY = t.scene.environment.rotationY, this.scene.environmentIntensity = t.scene.environment.intensity, (
|
|
1738
|
+
), i.name = "updated-environment-cube", i.rotationY = this.configuration.scene.environment.rotationY, this.scene.environmentTexture = i), i.rotationY = t.scene.environment.rotationY, this.scene.environmentIntensity = t.scene.environment.intensity, (a = t.options) != null && a.renderingPipelineConfiguration ? this.renderingPipeline.setConfiguration(
|
|
1733
1739
|
t.options.renderingPipelineConfiguration
|
|
1734
1740
|
) : (this.scene.imageProcessingConfiguration.exposure = t.lighting.exposure, this.scene.imageProcessingConfiguration.contrast = t.lighting.contrast), this.glowLayerManager.setIntensity(t.emissiveGlowIntensity), this.camera.updateConfiguration(t), this.camera.setPanEnabled(
|
|
1735
1741
|
((n = t.options) == null ? void 0 : n.noPan) !== void 0 ? !t.options.noPan : !0
|
|
@@ -1754,6 +1760,6 @@ export {
|
|
|
1754
1760
|
B as ProductCameraRig,
|
|
1755
1761
|
Ge as REFLECTION_PROBE_RESOLUTION,
|
|
1756
1762
|
P as RenderingConfiguration,
|
|
1757
|
-
|
|
1763
|
+
Qt as SpiffCommerce3DPreviewService,
|
|
1758
1764
|
d as renderingPipelineDefaults
|
|
1759
1765
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(d,w){typeof exports=="object"&&typeof module<"u"?w(exports,require("@babylonjs/core/Cameras/arcRotateCamera"),require("@babylonjs/core/Engines/engine"),require("@babylonjs/core/Engines/nullEngine"),require("@babylonjs/core/Layers/highlightLayer"),require("@babylonjs/core/Loading/sceneLoader"),require("@babylonjs/core/Materials/Textures/cubeTexture"),require("@babylonjs/core/Maths/math.color"),require("@babylonjs/core/Maths/math.vector"),require("@babylonjs/core/Meshes/Compression/dracoCompression"),require("@babylonjs/core/Misc/observable"),require("@babylonjs/core/Misc/tools"),require("@babylonjs/core/scene"),require("@babylonjs/loaders/glTF"),require("@babylonjs/loaders/glTF/glTFFileLoader"),require("@babylonjs/core/Materials/PBR/pbrMaterial"),require("@babylonjs/core/Materials/Textures/mirrorTexture"),require("@babylonjs/core/Maths/math"),require("@babylonjs/core/Probes/reflectionProbe"),require("@babylonjs/core/Layers/glowLayer"),require("@babylonjs/core/Actions/actionManager"),require("@babylonjs/core/Actions/directActions"),require("@babylonjs/core/Meshes/mesh"),require("@babylonjs/core/Meshes/transformNode"),require("@babylonjs/core/Materials/Textures/dynamicTexture"),require("@babylonjs/core/Materials/Textures/texture"),require("@babylonjs/core/Animations/animation"),require("@babylonjs/core/Animations/easing"),require("@babylonjs/core/Misc/assetsManager"),require("@babylonjs/core/Materials/colorCurves"),require("@babylonjs/core/Materials/imageProcessingConfiguration"),require("@babylonjs/core/PostProcesses/RenderPipeline"),require("@babylonjs/core/PostProcesses/depthOfFieldEffect"),require("@babylonjs/core/Rendering/depthRendererSceneComponent"),require("@babylonjs/core/Engines/Extensions/engine.views"),require("@babylonjs/core/Meshes/instancedMesh"),require("@babylonjs/core/Materials/Textures/Loaders/ddsTextureLoader"),require("@babylonjs/core/Materials/Textures/Loaders/envTextureLoader"),require("@babylonjs/core/Materials/Textures/Loaders/ktxTextureLoader"),require("@babylonjs/core/Animations/animatable"),require("@babylonjs/core/Misc/screenshotTools"),require("@babylonjs/core/Rendering/boundingBoxRenderer"),require("@babylonjs/loaders/glTF/2.0/Extensions")):typeof define=="function"&&define.amd?define(["exports","@babylonjs/core/Cameras/arcRotateCamera","@babylonjs/core/Engines/engine","@babylonjs/core/Engines/nullEngine","@babylonjs/core/Layers/highlightLayer","@babylonjs/core/Loading/sceneLoader","@babylonjs/core/Materials/Textures/cubeTexture","@babylonjs/core/Maths/math.color","@babylonjs/core/Maths/math.vector","@babylonjs/core/Meshes/Compression/dracoCompression","@babylonjs/core/Misc/observable","@babylonjs/core/Misc/tools","@babylonjs/core/scene","@babylonjs/loaders/glTF","@babylonjs/loaders/glTF/glTFFileLoader","@babylonjs/core/Materials/PBR/pbrMaterial","@babylonjs/core/Materials/Textures/mirrorTexture","@babylonjs/core/Maths/math","@babylonjs/core/Probes/reflectionProbe","@babylonjs/core/Layers/glowLayer","@babylonjs/core/Actions/actionManager","@babylonjs/core/Actions/directActions","@babylonjs/core/Meshes/mesh","@babylonjs/core/Meshes/transformNode","@babylonjs/core/Materials/Textures/dynamicTexture","@babylonjs/core/Materials/Textures/texture","@babylonjs/core/Animations/animation","@babylonjs/core/Animations/easing","@babylonjs/core/Misc/assetsManager","@babylonjs/core/Materials/colorCurves","@babylonjs/core/Materials/imageProcessingConfiguration","@babylonjs/core/PostProcesses/RenderPipeline","@babylonjs/core/PostProcesses/depthOfFieldEffect","@babylonjs/core/Rendering/depthRendererSceneComponent","@babylonjs/core/Engines/Extensions/engine.views","@babylonjs/core/Meshes/instancedMesh","@babylonjs/core/Materials/Textures/Loaders/ddsTextureLoader","@babylonjs/core/Materials/Textures/Loaders/envTextureLoader","@babylonjs/core/Materials/Textures/Loaders/ktxTextureLoader","@babylonjs/core/Animations/animatable","@babylonjs/core/Misc/screenshotTools","@babylonjs/core/Rendering/boundingBoxRenderer","@babylonjs/loaders/glTF/2.0/Extensions"],w):(d=typeof globalThis<"u"?globalThis:d||self,w(d.Preview={},d.arcRotateCamera,d.engine,d.nullEngine,d.highlightLayer,d.sceneLoader,d.cubeTexture,d.math_color,d.math_vector,d.dracoCompression,d.observable,d.tools,d.scene,d.glTF,d.glTFFileLoader,d.pbrMaterial,d.mirrorTexture,d.math,d.reflectionProbe,d.glowLayer,d.actionManager,d.directActions,d.mesh,d.transformNode,d.dynamicTexture,d.texture,d.animation,d.easing,d.assetsManager,d.colorCurves,d.imageProcessingConfiguration,d.RenderPipeline,d.depthOfFieldEffect))})(this,function(d,w,z,Ce,ye,I,G,v,p,we,A,Me,xe,Ae,Pe,S,Te,T,Re,Ee,B,H,Le,Oe,Fe,Ie,M,U,Se,K,R,Be,q){"use strict";var E=(s=>(s[s.Orbit=0]="Orbit",s[s.Pan=1]="Pan",s))(E||{}),L=(s=>(s.None="None",s.RemoveWhenSelected="RemoveWhenSelected",s.ApplyWhenSelected="ApplyWhenSelected",s))(L||{});function qe(){const s=navigator.vendor.toLowerCase().includes("apple"),e=navigator.maxTouchPoints>0,t=!navigator.userAgent.toLowerCase().includes("crios");return s&&e&&t}const W=new Map;async function j(s,e,t){const i=await W.get(s);if(i&&i.scene.uid===e.uid)return i;const r=I.SceneLoader.LoadAssetContainerAsync(s,void 0,e,t);return!qe()&&W.set(s,r),r}I.SceneLoader.OnPluginActivatedObservable.add(s=>{s.name==="gltf"&&(s.animationStartMode=Pe.GLTFLoaderAnimationStartMode.NONE)});class Q{constructor(e){this.getSceneClearColor=()=>{var i,r,n,o;const t=(i=this.customOptions)!=null&&i.transparentBackground||(r=this.customOptions)!=null&&r.backgroundImage?0:1;if(this.customOptions&&((n=this.customOptions)!=null&&n.transparentBackground)||(o=this.customOptions)!=null&&o.backgroundImage)return new v.Color4(0,0,0,t).toLinearSpace();if(this.customOptions&&this.customOptions.backgroundColor){const a=v.Color3.FromHexString(this.customOptions.backgroundColor);return new v.Color4(a.r,a.g,a.b,t).toLinearSpace()}return new v.Color4(.98,.98,.98,t).toLinearSpace()},this.highlightColorFromConfig=()=>this.customOptions&&this.customOptions.highlightColor?this.hexToColor4(this.customOptions.highlightColor):new v.Color4(.98,.98,.98,1).toLinearSpace(),this.hexToColor4=(t,i=1)=>{const r=v.Color3.FromHexString(t);return new v.Color4(r.r,r.g,r.b,i).toLinearSpace()},this.customOptions=e}createCanvas(){var e;return(e=this.customOptions)!=null&&e.createCanvas?this.customOptions.createCanvas():document.createElement("canvas")}get options(){return this.customOptions}get scene(){var e,t,i,r,n;return{clearColor:this.getSceneClearColor(),transparentBackground:((e=this.customOptions)==null?void 0:e.transparentBackground)||((t=this.customOptions)==null?void 0:t.backgroundImage),environment:{file:((i=this.customOptions)==null?void 0:i.environmentFile)??"assets/model-viewer/default.env",intensity:((r=this.customOptions)==null?void 0:r.environmentIntensity)??1,rotationY:(((n=this.customOptions)==null?void 0:n.environmentRotationY)??0)*(Math.PI/180)}}}get camera(){var e,t,i,r,n,o,a,l,h,c,g,m,b;return{autoOrientation:((e=this.customOptions)==null?void 0:e.disableAutomaticOrientation)??!0,autoRotation:{enabled:((t=this.customOptions)==null?void 0:t.autoRotation)??!1,idleTimeMs:((i=this.customOptions)==null?void 0:i.idleTimeBeforeRotation)??5e3},limits:{min:{alpha:(r=this.customOptions)!=null&&r.lowerAlphaLimitDeg?((n=this.customOptions)==null?void 0:n.lowerAlphaLimitDeg)*Math.PI/180:void 0,beta:(o=this.customOptions)!=null&&o.lowerBetaLimitDeg?((a=this.customOptions)==null?void 0:a.lowerBetaLimitDeg)*Math.PI/180:void 0,radius:(l=this.customOptions)==null?void 0:l.minZoomOverride},max:{alpha:(h=this.customOptions)!=null&&h.upperAlphaLimitDeg?((c=this.customOptions)==null?void 0:c.upperAlphaLimitDeg)*Math.PI/180:void 0,beta:(g=this.customOptions)!=null&&g.upperBetaLimitDeg?((m=this.customOptions)==null?void 0:m.upperBetaLimitDeg)*Math.PI/180:void 0,radius:(b=this.customOptions)==null?void 0:b.maxZoomOverride}}}}get highlights(){var e;return{enabled:((e=this.customOptions)==null?void 0:e.highlightOnMaterialHover)??!1,color:this.highlightColorFromConfig()}}get lighting(){var e,t,i,r;return{exposure:((t=(e=this.customOptions)==null?void 0:e.lighting)==null?void 0:t.exposure)??.9,contrast:((r=(i=this.customOptions)==null?void 0:i.lighting)==null?void 0:r.contrast)??1.6}}get emissiveGlowIntensity(){var e;return((e=this.customOptions)==null?void 0:e.emissiveGlowIntensity)??.5}}class x{static getDynamicTextureResolution(e=!1){return e?{width:1,height:1}:this.getIsMobile()||!x.offscreenRenderingSupported()?{width:1024,height:1024}:{width:2048,height:2048}}static shouldMipMap(){return!0}static offscreenRenderingSupported(){return navigator.userAgent.includes("SamsungBrowser")?!1:!!window.Worker&&!!window.OffscreenCanvas}static getMirrorTextureResolution(){return this.getIsMobile()?512:1024}static getIsMobile(){try{return typeof window>"u"||!window.navigator?!1:/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(window.navigator.userAgent)||window.innerWidth/window.devicePixelRatio<=480}catch{return!1}}}const Y=128,u={antiAliasing:{samples:4,fxaaEnabled:!1},bloom:{enabled:!1,kernel:64,scale:.5,threshold:.9,weight:.15},chromaticAberration:{enabled:!1,aberrationAmount:30,direction:{x:0,y:0},radialIntensity:0},colorCurves:{enabled:!1},depthOfField:{enabled:!1,blurLevel:"Low",focalLength:50,focusDistance:2e3,fStop:1.4,lensSize:50},grain:{enabled:!1,animated:!1,intensity:30},misc:{contrast:1,exposure:1,toneMappingEnabled:!1,toneMappingType:"Standard"},sharpen:{enabled:!1,colorAmount:1,edgeAmount:.3},vignette:{enabled:!1,blendMode:"Multiply",cameraFov:.5,center:{x:0,y:0},colorHex:"#000000ff",colorRgba:{r:0,g:0,b:0,a:1},stretch:0,weight:1}};class je{constructor(e){this.name="glbPostProcessor",this.enabled=!0,this.loader=e}onReady(){this.applyReflections(this.loader.babylonScene)}loadNodeAsync(e,t,i){return this.loader.loadNodeAsync(e,t,function(r){t.extras&&Object.keys(t.extras).forEach(n=>{const o=t.extras[n];r.metadata[n]=o}),i(r)})}async loadMaterialPropertiesAsync(e,t,i){await this.loader.loadMaterialPropertiesAsync(e,t,i),this.enableMaterialExtrasIfRequired(t,i),i.needDepthPrePass=!0}dispose(){}enableMaterialExtrasIfRequired(e,t){if(!(!e.extras||!(t instanceof S.PBRMaterial))){if(e.extras.sheen){const i=t;i.sheen.isEnabled=!0,i.sheen.intensity=e.extras.sheen}if(e.extras.translucency){const i=t;i.subSurface.isTranslucencyEnabled=!0,i.subSurface.translucencyIntensity=e.extras.translucency,e.extras.translucencyR&&e.extras.translucencyG&&e.extras.translucencyB&&(i.subSurface.tintColor=new T.Color3(e.extras.translucencyR,e.extras.translucencyG,e.extras.translucencyB))}if(e.extras.refractionIOR){const i=t;i.subSurface.isRefractionEnabled=!0,i.subSurface.volumeIndexOfRefraction=e.extras.refractionIOR}if(e.extras.useDepthPrePass){const i=t;i.needDepthPrePass=!0,i.forceIrradianceInFragment=!0}if(e.extras.useParallax){const i=t;i.useParallax=!0,i.useParallaxOcclusion=!0,i.parallaxScaleBias=e.extras.useParallax}}}applyReflections(e){function t(n){const o=[];return n.transformNodes.forEach(a=>{a.metadata&&a.metadata.reflective&&o.push(...a.getChildMeshes())}),n.meshes.forEach(a=>{a.metadata&&a.metadata.reflective&&!o.includes(a)&&o.push(a)}),o}function i(n,o=1){const a=n.material;if(!a)return;const l=new Te.MirrorTexture("mirror",x.getMirrorTextureResolution(),e,!0);l.renderList=t(e);const h=n.getVerticesData("normal");if(!h)throw new Error("Mirror attribute specified on: "+n.name+"But no normals exist to generate a mirror from!");n.computeWorldMatrix(!0);const c=n.getWorldMatrix(),g=T.Vector3.TransformNormal(new T.Vector3(h[0],h[1],h[2]),c).normalize(),m=T.Plane.FromPositionAndNormal(n.position,g.scale(-1));l.mirrorPlane=m,l.level=o,a.reflectionTexture=l}function r(n){const o=n.material,a=new Re.ReflectionProbe("probe-"+o.name,Y,e);a.cubeTexture.name="reflection-probe-cube-texture",a.attachToMesh(n),a.renderList&&a.renderList.push(...t(e)),o.reflectionTexture=a.cubeTexture}e.meshes.forEach(n=>{const o=n.metadata;o&&(o.mirrorTexture&&i(n,o.mirrorTexture),o.reflectionProbe&&r(n))})}}class De{constructor(e,t){this.scene=e,this.intensity=t,this.meshCount=0}setIntensity(e){this.intensity=e,this.glowLayer&&(this.glowLayer.intensity=e)}includeMeshes(e){if(e){this.glowLayer||(this.glowLayer=new Ee.GlowLayer("glow",this.scene),this.glowLayer.intensity=this.intensity);for(const t of e)this.glowLayer.hasMesh(t)||(this.glowLayer.addIncludedOnlyMesh(t),this.meshCount++)}}removeMeshes(e){if(!(!this.glowLayer||!e)){for(const t of e)this.glowLayer.hasMesh(t)&&(this.glowLayer.removeIncludedOnlyMesh(t),this.meshCount--);this.meshCount===0&&(this.glowLayer.dispose(),this.glowLayer=void 0)}}}function Ve(s,e,t,i,r=""){t.forEach(n=>{const o=n.getID(),a=n.getName(),l=n.getPanelSize&&n.getPanelSize(),h=x.getDynamicTextureResolution((l==null?void 0:l.width)===1||(l==null?void 0:l.height)===1);s.filter(g=>g.name===r+a).forEach(g=>{const m=i.get(o),b=!1;if(m)Z(g,m),m.update(b);else{const f=Ne(a,e,h.width,h.height);i.set(o,f),n.setStaticContext(f.getContext()),Z(g,f),f.onLoadObservable.addOnce(()=>{f.update(b)})}})})}function Ne(s,e,t,i){const r=new Fe.DynamicTexture(s,{width:t,height:i},e,x.shouldMipMap(),Ie.Texture.TRILINEAR_SAMPLINGMODE,z.Engine.TEXTUREFORMAT_RGBA),n=r.getContext();return n&&(n.fillStyle="#f5f5f5",n.fillRect(0,0,t,i),r.update()),r}function Z(s,e){if(s instanceof S.PBRMaterial){const t=s,i=t.albedoTexture;i?(e.wrapU=i.wrapU,e.wrapV=i.wrapV):(e.wrapU=1,e.wrapV=1),t.albedoTexture=e}else{const t=s,i=t.diffuseTexture;i&&(e.wrapU=i.wrapU,e.wrapV=i.wrapV),t.diffuseTexture=e}}function ke(){const s=()=>Math.floor((1+Math.random())*65536).toString(16).substring(1);return s()+s()+"-"+s()+"-"+s()+"-"+s()+"-"+s()+s()+s()}const P=60,$=1;function _(s){return s.targetedAnimations.map(t=>t.animation.framePerSecond).reduce((t,i)=>t+i,0)/s.targetedAnimations.length||0}function X(s,e,t,i,r,n){const o=r?s.filter(c=>c.name===r):s;if(o.length===0){console.warn(`No animations found for name: ${r}`);return}let a=0;const l=()=>{a++,a===o.length&&n&&n()},h=(c,g,m,b,f)=>{c.stop(),c.start(g,m,b,f),n&&(g==!1||g===void 0&&!c.loopAnimation?c.onAnimationGroupEndObservable.addOnce(()=>{l()}):c.onAnimationLoopObservable.addOnce(()=>{l()}))};if(i!==void 0&&t!==void 0&&i===t){o.forEach(c=>{const g=_(c),m=i*g;h(c,!1,$,m,m)});return}o.forEach(c=>{const g=_(c),m=i!==void 0?i*g:void 0,b=t!==void 0?t*g:void 0;h(c,e,$,m,b)})}function ze(s,e,t){return new Promise(i=>{s.stopAnimation(e),e.animations=[],Math.abs(e.alpha)>2*Math.PI&&(e.alpha=Ge(e.alpha,0,2*Math.PI));const r=[],n=t.target,o=0,a=n?1:0;if(t.target&&Object.keys(t.target).length>0&&r.push(O("cameraTargetLerp","target",new p.Vector3().copyFrom(e.target),new p.Vector3(t.target.x,t.target.y,t.target.z),M.Animation.ANIMATIONTYPE_VECTOR3,o)),r.push(O("cameraAlphaLerp","alpha",e.alpha,J(t.lonDeg),M.Animation.ANIMATIONTYPE_FLOAT,a)),r.push(O("cameraBetaLerp","beta",e.beta,J(t.latDeg),M.Animation.ANIMATIONTYPE_FLOAT,a)),t.radius!==void 0){const c=Math.max(.01,t.radius);r.push(O("cameraRadiusLerp","radius",e.radius,c,M.Animation.ANIMATIONTYPE_FLOAT,a))}e.animations.push(...r);const h=e.useAutoRotationBehavior;e.disableAutoRotationBehavior(),s.beginAnimation(e,0,n?P*2:P,!1,1,()=>{e.animations=[],h&&e.enableAutoRotationBehavior(),i()})})}function J(s){return s*Math.PI/180}function O(s,e,t,i,r,n=0,o=M.Animation.ANIMATIONLOOPMODE_CONSTANT){const a=new U.QuadraticEase;a.setEasingMode(U.EasingFunction.EASINGMODE_EASEINOUT);const l=new M.Animation(s,e,P,r,o),h=[];return n>0&&h.push({frame:0,value:t}),h.push({frame:P*n,value:t}),h.push({frame:P*(n+1),value:i}),l.setKeys(h),l.setEasingFunction(a),l}function Ge(s,e,t){return s<e?s=t-(e-s)%(t-e):s=e+(s-e)%(t-e)}function He(s,e,t){s.forEach(i=>{t&&i.name!==t||i.goToFrame(e)})}const Ue={albedoTexture:"albedoMap",bumpTexture:"normalMap",ambientTexture:"ambientMap",emissiveTexture:"emissionMap",opacityTexture:"alphaMap",metallicTexture:"metallicMap",refractionTexture:"refractionMap",reflectionTexture:"reflectionMap"};function Ke(s,e,t,i){["albedoTexture","bumpTexture","ambientTexture","emissiveTexture","opacityTexture","metallicTexture","refractionTexture","reflectionTexture"].forEach(n=>{We(n,s,e,t,i)}),Ze(s,e)}function We(s,e,t,i,r){const n=Ue[s];if(!n)throw new Error("Unexpected texture name encountered.");const o=e[n],a=o==null?void 0:o.fileLink;a?s==="reflectionTexture"?a.endsWith(".env")||a.endsWith(".dds")?i.addCubeTextureTask(s,a,void 0,!1,void 0,!0):a.endsWith(".hdr")?i.addHDRCubeTextureTask(s,a,128,!1,!0,!1):i.addTextureTask(s,a,!1,!1):i.addTextureTask(s,a,!1,!1):r&&t[s]&&(t[s]&&t[s].dispose(),t[s]=null,Qe(s,t))}function Qe(s,e){s==="opacityTexture"&&(e.useAlphaFromAlbedoTexture=!0),s==="metallicTexture"&&(e.useRoughnessFromMetallicTextureAlpha=!1,e.useRoughnessFromMetallicTextureGreen=!1,e.useMetallnessFromMetallicTextureBlue=!1),s==="refractionTexture"&&(e.subSurface.isRefractionEnabled=!1,e.subSurface.refractionIntensity=1),s==="reflectionTexture"&&(e.environmentIntensity=1),s==="emissiveTexture"&&(e.emissiveIntensity=0,e.emissiveColor=new v.Color3(0,0,0),e.reflectionTexture)}function Ye(s,e,t,i){if(!e){console.error("Failed to apply texture to material: material is null.");return}s==="opacityTexture"&&(e.useAlphaFromAlbedoTexture=!1),s==="metallicTexture"&&(e.useRoughnessFromMetallicTextureAlpha=!1,e.useRoughnessFromMetallicTextureGreen=!0,e.useMetallnessFromMetallicTextureBlue=!0),s==="refractionTexture"&&(e.subSurface.isRefractionEnabled=!0,e.subSurface.refractionIntensity=t.refractionIntensity||1),s==="reflectionTexture"&&(e.environmentIntensity=t.reflectionIntensity||1,i.isCube&&(i.rotationY=t.reflectionRotation?t.reflectionRotation*Math.PI/180:0)),e[s]=i,s==="emissiveTexture"&&(e.emissiveColor=new v.Color3(1,1,1),e.emissiveIntensity=1)}function Ze(s,e){s.clearCoat&&(s.clearCoat===L.RemoveWhenSelected?(e.clearCoat.isEnabled=!1,e.clearCoat.indexOfRefraction=1.5):s.clearCoat===L.ApplyWhenSelected&&(e.clearCoat.isEnabled=!0,e.clearCoat.indexOfRefraction=s.clearCoatIOR||e.clearCoat.indexOfRefraction))}class $e{constructor(e,t,i){this.materialVariantMap=new Map,this.keysThatRemovedBaseModel=[],this.loadedContainerForKey=new Map,this.loadedMaterialsForKey=new Map,this.scene=e,this.renameClonedAsset=t,this.setBaseModelEnabled=i}async applyMaterial(e,t,i,r){return new Promise(n=>{const o=this.materialVariantMap.get(e);this.materialVariantMap.set(e,{...o,...t});const a=this.renameClonedAsset(e),l=this.scene.materials.filter(c=>c.name===a);if(l.length===0){n();return}const h=new Se.AssetsManager(this.scene);h.useDefaultLoadingScreen=!1,l.forEach(c=>Ke(t,c,h,r)),h.onProgress=(c,g,m)=>{i&&i(c/g*100,100,m.name)},h.onFinish=c=>{c.forEach(g=>{const m=g;i&&i(100,100,g.name),this.scene.materials.filter(f=>f.name===a).forEach(f=>{Ye(g.name,f,t,m.texture)})}),n()},h.loadAsync()})}async applyModel(e,t,i,r,n,o,a){var m,b,f;if(i&&t&&!this.keysThatRemovedBaseModel.includes(e)&&this.keysThatRemovedBaseModel.push(e),!i)return this.keysThatRemovedBaseModel.includes(e)&&this.keysThatRemovedBaseModel.length===1&&await this.setBaseModelEnabled(!0),(m=this.loadedContainerForKey.get(e))==null||m.dispose(),this.loadedContainerForKey.delete(e),(b=this.loadedMaterialsForKey.get(e))==null||b.forEach(C=>C.dispose()),this.loadedMaterialsForKey.delete(e),this.keysThatRemovedBaseModel=this.keysThatRemovedBaseModel.filter(C=>C!==e),Promise.resolve(void 0);const h=(await j(i,this.scene,r)).instantiateModelsToScene(this.renameClonedAsset,!0);this.loadedContainerForKey.has(e)&&(this.loadedContainerForKey.get(e).dispose(),this.loadedContainerForKey.delete(e),(f=this.loadedMaterialsForKey.get(e))==null||f.forEach(C=>C.dispose()),this.loadedMaterialsForKey.delete(e));const c=n&&n();if(c){const C=o&&o(),y=c.name?this.renameClonedAsset(c.name):void 0;if(X(h.animationGroups,c.loop,c.to,c.from,y),C!=null){const F=a&&a()||!0;He(h.animationGroups,C+(F?2:0),y)}}t&&await this.setBaseModelEnabled(!1),this.loadedContainerForKey.set(e,h),this.loadedMaterialsForKey.set(e,ee(h));const g=[];return this.materialVariantMap.forEach(async(C,y)=>{g.push(this.applyMaterial(y,C))}),await Promise.all(g),h}dispose(){this.loadedContainerForKey.forEach(e=>e==null?void 0:e.dispose()),this.loadedContainerForKey.clear(),this.loadedMaterialsForKey.forEach(e=>e.forEach(t=>t==null?void 0:t.dispose())),this.loadedMaterialsForKey.clear(),this.materialVariantMap.clear(),this.keysThatRemovedBaseModel=[]}getAllMaterials(){const e=[];return this.loadedMaterialsForKey.forEach(t=>{t.forEach(i=>{e.includes(i)||e.push(i)})}),e}getAnimationGroups(){const e=[];return this.loadedContainerForKey.forEach(t=>{e.push(...t.animationGroups)}),e}}function ee(s){const e=[];return s.rootNodes.forEach(t=>{t.getChildMeshes().forEach(i=>{i.material&&!e.includes(i.material)&&e.push(i.material),i.subMeshes&&i.subMeshes.forEach(r=>{const n=r.getMaterial(!1);n&&!e.includes(n)&&e.push(n)})})}),e}function te(s,e=""){return s.map(t=>({name:t.name.substring(e.length),loop:t.loopAnimation,to:t.to,from:t.from}))}class _e{constructor(e){this.metadata=new Map,this.materialSelectedObservable=new A.Observable,this.materialDeselectedObservable=new A.Observable,this.materialVariantObservable=new A.Observable,this.modelVariantObservable=new A.Observable,this.materialReadyToLoadCallbacks=new Map,this.dynamicTextures=new Map,this.queuedMaterialChanges=new Map,this.materialChangesInProgress=[],this.queuedModelChanges=new Map,this.modelChangesInProgress=[],this.isExecutingAnimation=!1,this.animations=[],this.initialized=!1,this.materials=[];const{enablePicking:t,modelDetails:i,previewService:r,progressHandler:n,scene:o}=e;this.enablePicking=t,this.contextService=i.contextService,this.id=ke(),this.previewService=r,this.scene=o,this.variantManager=new $e(o,this.renameClonedAsset.bind(this),this.setBaseModelEnabled.bind(this)),this.transformRoot=new Oe.TransformNode("root",this.scene);const a=async()=>{if(!i.model)throw new Error("Model container constructed with no URL. This is currently unsupported.");return this.assetContainer=await j(i.model,o,n),await this.instantiate(),this};this.importPromise=a()}async applyMaterialVariant(e,t,i,r){if(!this.initialized){if(this.materialReadyToLoadCallbacks.has(e)){const o=this.materialReadyToLoadCallbacks.get(e);o==null||o.set(t,this.applyMaterialVariant.bind(this,e,t,i,r))}else{this.materialReadyToLoadCallbacks.set(e,new Map);const o=this.materialReadyToLoadCallbacks.get(e);o==null||o.set(t,this.applyMaterialVariant.bind(this,e,t,i,r))}return}const n=async()=>{await this.variantManager.applyMaterial(e,i,(o,a,l)=>{this.materialVariantObservable.notifyObservers({remainingCount:o,totalCount:a,taskName:l})},r)};if(this.materialChangesInProgress.includes(e)){if(this.queuedMaterialChanges.has(e)){const o=this.queuedMaterialChanges.get(e);o==null||o.set(t,n)}else{this.queuedMaterialChanges.set(e,new Map);const o=this.queuedMaterialChanges.get(e);o==null||o.set(t,n)}return}if(this.materialChangesInProgress.push(e),await n(),this.queuedMaterialChanges.has(e)){const o=this.queuedMaterialChanges.get(e);if(!o)throw new Error("Target material is undefined");o.forEach(async a=>{await a()}),this.queuedMaterialChanges.delete(e)}this.materialChangesInProgress.splice(this.materialChangesInProgress.indexOf(e),1),this.configureGlowLayer(),this.scene.cleanCachedTextureBuffer()}async applyModelVariant(e,t,i){const r=()=>this.variantManager.applyModel(e,i,t==null?void 0:t.model,a=>{this.modelVariantObservable.notifyObservers({...a,key:e})},this.getLastRequestedAnimation.bind(this),this.getCurrentAnimationFrame.bind(this),this.getAnimationIsPlaying.bind(this)),n=async()=>{this.modelChangesInProgress.push(e);let a=await r();if(this.queuedModelChanges.has(e)){const l=this.queuedModelChanges.get(e);if(!l)throw new Error("Queued change resolved undefined");a=await l(),this.queuedModelChanges.delete(e)}return this.modelChangesInProgress.splice(this.modelChangesInProgress.indexOf(e),1),a};if(!this.initialized||this.modelChangesInProgress.includes(e)){const a=async()=>{const l=await r();return l?this.configureModelInstance(l):this.configureGlowLayer(),l};this.queuedModelChanges.set(e,a);return}const o=await n();this.contextService||(this.contextService=t==null?void 0:t.contextService),o?this.configureModelInstance(o):this.configureGlowLayer()}dispose(){var e;this.destroyInstance(),this.variantManager.dispose(),this.dynamicTextures.forEach(t=>t==null?void 0:t.dispose()),this.dynamicTextures.clear(),this.materials.forEach(t=>t&&(t==null?void 0:t.dispose())),this.materials=[],(e=this.transformRoot)==null||e.dispose(),this.transformRoot=void 0,this.previewService.modelUnloaded(this)}executeAnimation(e){if(this.lastRequestedAnimation=e,!this.initialized)return this.queuedModelAnimation=e,Promise.resolve();let t=()=>{};const i=async()=>{this.isExecutingAnimation=!0,await new Promise(r=>{var o;const n=[...((o=this.modelInstance)==null?void 0:o.animationGroups)||[],...this.variantManager.getAnimationGroups()];X(n,e.loop,e.to,e.from,e.name?this.renameClonedAsset(e.name):void 0,r)}),this.isExecutingAnimation=!1,this.queuedAnimationFunction&&this.queuedAnimationFunction(),this.queuedAnimationFunction=void 0,t()};return this.isExecutingAnimation?(this.queuedAnimationFunction=i,new Promise(r=>{t=r})):i()}getAnimations(e){return[...this.animations,...e?te(this.variantManager.getAnimationGroups(),this.renameClonedAsset("")):[]].map((t,i)=>({...t,name:t.name||`UNNAMED_ANIMATION_${i}`})).filter((t,i,r)=>r.indexOf(r.find(n=>n.name===t.name))==i)}getId(){return this.id}listMaterials(){var t;const e=(t=this.scene)==null?void 0:t.materials.filter(i=>i.name.startsWith(this.id));return e?e.map(i=>({id:i.id,name:this.stripIdFromName(i.name)})):[]}registerMaterialSelectedCallback(e){this.materialSelectedObservable.add(e)}unregisterMaterialSelectedCallback(e){this.materialSelectedObservable.removeCallback(e)}registerMaterialDeselectedCallback(e){this.materialDeselectedObservable.add(e)}unregisterMaterialDeselectedCallback(e){this.materialDeselectedObservable.removeCallback(e)}get position(){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to requesting position!");return this.transformRoot.position}set position(e){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to setting position!");this.transformRoot.position=new p.Vector3(e.x,e.y,e.z)}get rotation(){var e;if(!((e=this.transformRoot)!=null&&e.rotationQuaternion))throw new Error("ModelContainer disposed prior to requesting rotation!");return this.transformRoot.rotationQuaternion.toEulerAngles()}set rotation(e){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to setting rotation!");this.transformRoot.rotationQuaternion=p.Quaternion.FromEulerAngles(e.x,e.y,e.z)}get scale(){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to requesting scale!");return this.transformRoot.scaling}set scale(e){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to setting scale!");this.transformRoot.scaling=new p.Vector3(e.x,e.y,e.z)}attachPickingHandler(e){e.rootNodes.forEach(t=>{t.getChildMeshes(!1).forEach(i=>{i.name==="targetcube_t"||i.name==="backgroundShell"||(i.actionManager||(i.actionManager=new B.ActionManager(this.scene)),i.actionManager.registerAction(new H.ExecuteCodeAction(B.ActionManager.OnPointerOverTrigger,r=>{r.meshUnderPointer&&i.material&&this.materialSelectedObservable.notifyObservers({id:i.material.id,name:this.stripIdFromName(i.material.name)})})),i.actionManager.registerAction(new H.ExecuteCodeAction(B.ActionManager.OnPointerOutTrigger,()=>{i.material&&this.materialDeselectedObservable.notifyObservers({id:i.material.id,name:this.stripIdFromName(i.material.name)})})))})})}getInitializationPromise(){return this.importPromise}getIsInitialized(){return this.initialized}getQueuedMaterialVariantCount(){return this.materialReadyToLoadCallbacks.size}getQueuedModelVariantCount(){return this.queuedModelChanges.size}configureGlowLayer(){const e=i=>i instanceof S.PBRMaterial&&i.emissiveTexture!==null;this.materials.some(e)||this.variantManager.getAllMaterials().some(e)?this.previewService.getGlowLayerManager().includeMeshes(this.getAllMeshes()):this.previewService.getGlowLayerManager().removeMeshes(this.getAllMeshes())}configureModelInstance(e){var n;if(!this.transformRoot)throw new Error("Transform disposed! This should never happen unless there is a race condition present!");const t=this.transformRoot.position,i=this.transformRoot.rotationQuaternion,r=this.transformRoot.scaling;this.transformRoot.position=p.Vector3.Zero(),this.transformRoot.rotationQuaternion=p.Quaternion.Identity(),this.transformRoot.scaling=p.Vector3.One();for(const o of e.rootNodes){o.parent=this.transformRoot;for(const a of o.getChildMeshes(!1))a.alwaysSelectAsActiveMesh=!0}this.transformRoot.position=t,this.transformRoot.rotationQuaternion=i,this.transformRoot.scaling=r,this.canvasPanels=((n=this.contextService)==null?void 0:n.getAll())||new Map,Ve(this.materials.concat(this.variantManager.getAllMaterials()),this.scene,this.canvasPanels,this.dynamicTextures,`${this.id}_`),this.enablePicking&&this.attachPickingHandler(e),this.configureGlowLayer()}destroyInstance(){var e;(e=this.modelInstance)==null||e.dispose(),this.modelInstance=void 0}getAllMeshes(){var e;return(e=this.modelInstance)==null?void 0:e.rootNodes.map(t=>t.getChildMeshes(!1).filter(i=>i instanceof Le.Mesh)).flat()}async instantiate(){if(!this.assetContainer)throw new Error("Attempted to instantiate ModelContainer without an AssetContainer");this.modelInstance=this.assetContainer.instantiateModelsToScene(this.renameClonedAsset.bind(this),!0),this.materials=ee(this.modelInstance),this.configureModelInstance(this.modelInstance),this.animations=te(this.modelInstance.animationGroups,this.renameClonedAsset("")),this.initialized=!0,await this.processQueuedEvents()}renameClonedAsset(e){return`${this.id}_${e}`}async setBaseModelEnabled(e){e&&!this.modelInstance?await this.instantiate():!e&&this.modelInstance&&this.destroyInstance()}updateDynamicTextures(){var e;(e=this.canvasPanels)==null||e.forEach((t,i)=>{const r=this.dynamicTextures.get(i);r&&t.getStaticContextDirty()&&r.isReady()&&(r.update(!1),t.setStaticContextDirty(!1))})}registerMaterialVariantListener(e){this.materialVariantObservable.add(e)}unregisterMaterialVariantListener(e){this.materialVariantObservable.removeCallback(e)}registerModelVariantListener(e){this.modelVariantObservable.add(e)}unregisterModelVariantListener(e){this.modelVariantObservable.removeCallback(e)}getLastRequestedAnimation(){return this.lastRequestedAnimation}getCurrentAnimationFrame(){var t;const e=[...((t=this.modelInstance)==null?void 0:t.animationGroups)||[],...this.variantManager.getAnimationGroups()];for(const i of e)if(i.animatables.length>0&&i.animatables[0].masterFrame!==void 0&&i.animatables[0].masterFrame!==null)return i.animatables[0].masterFrame;return 0}getAnimationIsPlaying(){var t;const e=[...((t=this.modelInstance)==null?void 0:t.animationGroups)||[],...this.variantManager.getAnimationGroups()];for(const i of e)if(i.isPlaying)return!0;return!1}stripIdFromName(e){return e.substring(this.id.length+1)}async processQueuedEvents(){await Promise.all(Array.from(this.materialReadyToLoadCallbacks.values()).flatMap(e=>Array.from(e.values()).map(t=>t()))),this.materialReadyToLoadCallbacks.clear(),await Promise.all(Array.from(this.queuedModelChanges.values()).map(e=>e())),this.queuedModelChanges.clear(),this.scene.onAfterRenderObservable.addOnce(()=>{this.queuedModelAnimation&&(this.executeAnimation(this.queuedModelAnimation),this.queuedModelAnimation=void 0)})}}class D extends w.ArcRotateCamera{constructor(e,t,i,r,n,o,a,l){super(e,t,i,r,n,o,l),this.lastFocus=new p.Vector3(0,0,0),this._isRunningFramingBehavior=!1,this.panDenominator=1,this.panEnabled=!0,this.minZ=.01,this.updateRadiusBounds(this.radius),this.enableFramingBehavior(),this.wheelDeltaPercentage=.01,this.pinchDeltaPercentage=.005,this.useNaturalPinchZoom=!0,a.camera.autoOrientation&&(this.alpha+=Math.PI),a&&(a.camera.limits.min.beta&&(this.lowerBetaLimit=a.camera.limits.min.beta),a.camera.limits.max.beta&&(this.upperBetaLimit=a.camera.limits.max.beta),a.camera.limits.min.alpha&&(this.lowerAlphaLimit=a.camera.limits.min.alpha),a.camera.limits.max.alpha&&(this.upperAlphaLimit=a.camera.limits.max.alpha),a.camera.limits.min.radius&&(this.lowerRadiusLimit=a.camera.limits.min.radius),a.camera.limits.max.radius&&(this.upperRadiusLimit=a.camera.limits.max.radius),a.camera.autoRotation.enabled&&this.enableAutoRotationBehavior(a.camera.autoRotation.idleTimeMs))}updateConfiguration(e){e&&(this.lowerBetaLimit=e.camera.limits.min.beta??null,this.upperBetaLimit=e.camera.limits.max.beta??null,this.lowerAlphaLimit=e.camera.limits.min.alpha??null,this.upperAlphaLimit=e.camera.limits.max.alpha??null,e.camera.autoRotation.enabled?this.enableAutoRotationBehavior(e.camera.autoRotation.idleTimeMs):this.disableAutoRotationBehavior())}get isRunningFramingBehavior(){return this._isRunningFramingBehavior}set isRunningFramingBehavior(e){this._isRunningFramingBehavior=e,!e&&this.framingBehaviourCallback&&(this.framingBehaviourCallback(),this.framingBehaviourCallback=void 0)}setPanEnabled(e){this.panEnabled=e,this.panningSensibility=1e3/this.panDenominator,this.panningAxis=e?new p.Vector3(1,1,0):new p.Vector3(0,0,0)}getFramingBehavior(){return this.getBehaviorByName("Framing")}getAutoRotationBehavior(){const e=this.getBehaviorByName("AutoRotation");if(e)return e}enableFramingBehavior(){this.useFramingBehavior=!0;const e=this.getFramingBehavior();e.attach(this),e.framingTime=0,e.elevationReturnTime=-1,e.zoomStopsAnimation=!1,this.lowerRadiusLimit=null;const t=V(this._scene);return e.zoomOnBoundingInfo(t.min,t.max),this.wheelPrecision=100/this.radius,this.lowerRadiusLimit===null&&(this.lowerRadiusLimit=.1),this.lastFocus.copyFrom(this.target),e}rerunFramingBehavior(e,t){this._isRunningFramingBehavior=!0,this.framingBehaviourCallback=e;const i=this.getFramingBehavior();i.framingTime=t||800;const r=()=>{this.isRunningFramingBehavior=!1},n=V(this._scene),o=n.max.subtract(n.min),a=n.min.add(o.scale(.5));this.updateRadiusBounds(o.length()*1.5),this.wheelPrecision=100/this.radius,this.panningInertia=0,this.panningOriginTarget.copyFrom(a),this.panDenominator=o.length(),this.lastFocus.copyFrom(a),i.zoomOnBoundingInfo(n.min,n.max,void 0,r),i.framingTime=0}enableAutoRotationBehavior(e=5e3){this.useAutoRotationBehavior=!0;const t=this.getAutoRotationBehavior();t&&(t.idleRotationWaitTime=e)}disableAutoRotationBehavior(){this.useAutoRotationBehavior=!1}updateRadiusBounds(e){this.maxZ=e*1e3,this.lowerRadiusLimit=e*.01,this.upperRadiusLimit=1.5*e,this.wheelPrecision=100/e,this.pinchPrecision=300/e}static create(e,t,i){var l;const r=V(e),n=r.max.subtract(r.min),o=r.min.add(n.scale(.5)),a=new D("ProductCamera",-(Math.PI/2),Math.PI/2,n.length()*1.5,o,e,t);return a.setPanEnabled(((l=t.options)==null?void 0:l.noPan)!==void 0?!t.options.noPan:!0),a.panningInertia=0,a.panningOriginTarget.copyFrom(o),a.panDenominator=n.length(),a.onAfterCheckInputsObservable.addOnce(()=>{a.setPanEnabled(a.panEnabled)}),i&&(e.activeCamera=a),a}}function V(s){if(s.meshes.length===0)return{min:new p.Vector3(-1,-1,-1),max:new p.Vector3(1,1,1)};const e=s.meshes.filter(t=>t.name.toLowerCase().endsWith("_t")||t.name.toLowerCase().includes("_t_"));return s.getWorldExtends(t=>t.isVisible&&t.isEnabled()&&(e.length===0||e.includes(t)))}class Xe{constructor(e,t=!1,i=void 0){this.renderingPipeline=new Be.DefaultRenderingPipeline("default",t,e,i?[i]:void 0,!1),this.renderingPipeline.isSupported&&(this.renderingPipeline.prepare(),this.setConfiguration(u))}dispose(){this.renderingPipeline.dispose()}getConfiguration(){return this.currentConfiguration}setConfiguration(e){var t,i,r,n,o,a,l,h,c,g,m,b,f,C,y,F,ie,ne,se,re,ae,oe,le,he,ce,de,ue,ge,me,pe,fe,be,ve;if(this.renderingPipeline.isSupported){if(this.renderingPipeline.samples=((t=e.antiAliasing)==null?void 0:t.samples)??u.antiAliasing.samples,this.renderingPipeline.fxaaEnabled=((i=e.antiAliasing)==null?void 0:i.fxaaEnabled)??u.antiAliasing.fxaaEnabled,this.renderingPipeline.bloomEnabled=((r=e.bloom)==null?void 0:r.enabled)??u.bloom.enabled,this.renderingPipeline.bloomKernel=((n=e.bloom)==null?void 0:n.kernel)??u.bloom.kernel,this.renderingPipeline.bloomScale=((o=e.bloom)==null?void 0:o.scale)??u.bloom.scale,this.renderingPipeline.bloomThreshold=((a=e.bloom)==null?void 0:a.threshold)??u.bloom.threshold,this.renderingPipeline.bloomWeight=((l=e.bloom)==null?void 0:l.weight)??u.bloom.weight,this.renderingPipeline.chromaticAberrationEnabled=((h=e.chromaticAberration)==null?void 0:h.enabled)??u.chromaticAberration.enabled,this.renderingPipeline.chromaticAberration.aberrationAmount=((c=e.chromaticAberration)==null?void 0:c.aberrationAmount)??u.chromaticAberration.aberrationAmount,this.renderingPipeline.chromaticAberration.radialIntensity=((g=e.chromaticAberration)==null?void 0:g.radialIntensity)??u.chromaticAberration.radialIntensity,this.renderingPipeline.chromaticAberration.direction=(m=e.chromaticAberration)!=null&&m.direction?new p.Vector2(e.chromaticAberration.direction.x,e.chromaticAberration.direction.y):new p.Vector2(u.chromaticAberration.direction.x,u.chromaticAberration.direction.y),this.renderingPipeline.imageProcessing.colorCurvesEnabled=((b=e.colorCurves)==null?void 0:b.enabled)??u.colorCurves.enabled,this.renderingPipeline.imageProcessing.colorCurves=e.colorCurves?this.updateColorCurve(e.colorCurves):new K.ColorCurves,this.renderingPipeline.depthOfFieldEnabled=((f=e.depthOfField)==null?void 0:f.enabled)??u.depthOfField.enabled,e.depthOfField)switch(e.depthOfField.blurLevel??u.depthOfField.blurLevel){case"Low":this.renderingPipeline.depthOfFieldBlurLevel=q.DepthOfFieldEffectBlurLevel.Low;break;case"Medium":this.renderingPipeline.depthOfFieldBlurLevel=q.DepthOfFieldEffectBlurLevel.Medium;break;case"High":this.renderingPipeline.depthOfFieldBlurLevel=q.DepthOfFieldEffectBlurLevel.High;break}if(this.renderingPipeline.depthOfField.focalLength=((C=e.depthOfField)==null?void 0:C.focalLength)??u.depthOfField.focalLength,this.renderingPipeline.depthOfField.fStop=((y=e.depthOfField)==null?void 0:y.fStop)??u.depthOfField.fStop,this.renderingPipeline.depthOfField.focusDistance=((F=e.depthOfField)==null?void 0:F.focusDistance)??u.depthOfField.focusDistance,this.renderingPipeline.depthOfField.lensSize=((ie=e.depthOfField)==null?void 0:ie.lensSize)??u.depthOfField.lensSize,this.renderingPipeline.grainEnabled=((ne=e.grain)==null?void 0:ne.enabled)??u.grain.enabled,this.renderingPipeline.grain.animated=((se=e.grain)==null?void 0:se.animated)??u.grain.animated,this.renderingPipeline.grain.intensity=((re=e.grain)==null?void 0:re.intensity)??u.grain.intensity,this.renderingPipeline.imageProcessing.contrast=((ae=e.misc)==null?void 0:ae.contrast)??u.misc.contrast,this.renderingPipeline.imageProcessing.exposure=((oe=e.misc)==null?void 0:oe.exposure)??u.misc.exposure,this.renderingPipeline.imageProcessing.toneMappingEnabled=((le=e.misc)==null?void 0:le.toneMappingEnabled)??u.misc.toneMappingEnabled,this.renderingPipeline.imageProcessing.toneMappingEnabled)switch(e.misc.toneMappingType??u.misc.toneMappingType){case"Standard":this.renderingPipeline.imageProcessing.toneMappingType=R.ImageProcessingConfiguration.TONEMAPPING_STANDARD;break;case"ACES":this.renderingPipeline.imageProcessing.toneMappingType=R.ImageProcessingConfiguration.TONEMAPPING_ACES;break}if(this.renderingPipeline.sharpenEnabled=((he=e.sharpen)==null?void 0:he.enabled)??u.sharpen.enabled,this.renderingPipeline.sharpen.colorAmount=((ce=e.sharpen)==null?void 0:ce.colorAmount)??u.sharpen.colorAmount,this.renderingPipeline.sharpen.edgeAmount=((de=e.sharpen)==null?void 0:de.edgeAmount)??u.sharpen.edgeAmount,this.renderingPipeline.imageProcessing.vignetteEnabled=((ue=e.vignette)==null?void 0:ue.enabled)??u.vignette.enabled,(ge=e.vignette)!=null&&ge.center?(this.renderingPipeline.imageProcessing.vignetteCenterX=e.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=e.vignette.center.y):(this.renderingPipeline.imageProcessing.vignetteCenterX=u.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=u.vignette.center.y),e.vignette)switch(((me=e.vignette)==null?void 0:me.blendMode)??u.vignette.blendMode){case"Multiply":this.renderingPipeline.imageProcessing.vignetteBlendMode=R.ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY;break;case"Opaque":this.renderingPipeline.imageProcessing.vignetteBlendMode=R.ImageProcessingConfiguration.VIGNETTEMODE_OPAQUE;break}(pe=e.vignette)!=null&&pe.colorRgba?this.renderingPipeline.imageProcessing.vignetteColor=new v.Color4(e.vignette.colorRgba.r,e.vignette.colorRgba.g,e.vignette.colorRgba.b,e.vignette.colorRgba.a):(fe=e.vignette)!=null&&fe.colorHex?this.renderingPipeline.imageProcessing.vignetteColor=v.Color4.FromHexString(e.vignette.colorHex):this.renderingPipeline.imageProcessing.vignetteColor=new v.Color4(u.vignette.colorRgba.r,u.vignette.colorRgba.g,u.vignette.colorRgba.b,u.vignette.colorRgba.a),this.renderingPipeline.imageProcessing.vignetteStretch=((be=e.vignette)==null?void 0:be.stretch)??u.vignette.stretch,this.renderingPipeline.imageProcessing.vignetteWeight=((ve=e.vignette)==null?void 0:ve.weight)??u.vignette.weight,this.renderingPipeline.prepare(),this.currentConfiguration=e}}updateColorCurve(e){const t=new K.ColorCurves;return t.globalDensity=e.globalDensity??t.globalDensity,t.globalExposure=e.globalExposure??t.globalExposure,t.globalHue=e.globalHue??t.globalHue,t.globalSaturation=e.globalSaturation??t.globalSaturation,t.highlightsDensity=e.highlightsDensity??t.highlightsDensity,t.highlightsExposure=e.highlightsExposure??t.highlightsExposure,t.highlightsHue=e.highlightsHue??t.highlightsHue,t.highlightsSaturation=e.highlightsSaturation??t.highlightsSaturation,t.midtonesDensity=e.midtonesDensity??t.midtonesDensity,t.midtonesExposure=e.midtonesExposure??t.midtonesExposure,t.midtonesHue=e.midtonesHue??t.midtonesHue,t.midtonesSaturation=e.midtonesSaturation??t.midtonesSaturation,t.shadowsDensity=e.shadowsDensity??t.shadowsDensity,t.shadowsExposure=e.shadowsExposure??t.shadowsExposure,t.shadowsHue=e.shadowsHue??t.shadowsHue,t.shadowsSaturation=e.shadowsSaturation??t.shadowsSaturation,t}}Ae.GLTF2.GLTFLoader.RegisterExtension("glbPostProcessor",function(s){return new je(s)}),I.SceneLoader.OnPluginActivatedObservable.add(s=>{if(s.name==="gltf"){const e=s;e.transparencyAsCoverage=!0}});function N(s){return new p.Vector3(s.x,s.y,s.z)}function k(s){return{x:s.x,y:s.y,z:s.z}}class Je{constructor(e){var l;this.focusLostNotified=!1,this.focusLostObservable=new A.Observable,this.modelLoadEventCallbacks=[],this.modelContainers=new Map,this.plugins=[],this.initComplete=!1,this.isAnimatingCamera=!1,this.renderLoop=()=>{if(!this.engine.views)return;this.modelContainers.forEach(g=>{g.updateDynamicTextures()}),this.scene.autoClear=!0,this.scene.autoClearDepthAndStencil=!0;const h=this.engine.getRenderingCanvas();if(h)if(h.getContext("webgl2")??h.getContext("webgl")){const g=this.configuration.scene.clearColor,m=h.getContext("webgl2")??h.getContext("webgl");m.clearDepth(1),m.depthFunc(m.LEQUAL),m.clearStencil(0),m.clearColor(g.r,g.g,g.b,g.a),m.clear(m.COLOR_BUFFER_BIT|m.DEPTH_BUFFER_BIT|m.STENCIL_BUFFER_BIT)}else h.getContext("2d")?h.getContext("2d").clearRect(0,0,h.width,h.height):console.error("SpiffCommerce: Failed to get any context on the rendering canvas.");this.scene.render(),this.camera.isRunningFramingBehavior&&this.camera.getFramingBehavior().isUserIsMoving&&(this.camera.isRunningFramingBehavior=!1);const c=Math.max((this.camera.lowerRadiusLimit??1)*.01,.001);!this.camera.isRunningFramingBehavior&&!this.camera.target.equalsWithEpsilon(this.camera.lastFocus,c)&&!this.focusLostNotified&&(this.focusLostObservable.notifyObservers(void 0),this.focusLostNotified=!0),this.screenshotPrepareResolve&&(this.screenshotPrepareResolve(),this.screenshotPrepareResolve=void 0)},this.configuration=new Q(e);const i=(()=>{if(!(e!=null&&e.noRender))return this.configuration.createCanvas()})(),r="1.5.6";we.DracoCompression.Configuration={decoder:{wasmUrl:`https://www.gstatic.com/draco/versioned/decoders/${r}/draco_wasm_wrapper_gltf.js`,wasmBinaryUrl:`https://www.gstatic.com/draco/versioned/decoders/${r}/draco_decoder_gltf.wasm`,fallbackUrl:`https://www.gstatic.com/draco/versioned/decoders/${r}/draco_decoder_gltf.js`}},i&&(i.getContext("webgl2")||i.getContext("webgl"));const n=console.log;console.log=()=>{};const o=i?new z.Engine(i,!0,{adaptToDeviceRatio:!0,limitDeviceRatio:2,premultipliedAlpha:!1,preserveDrawingBuffer:!!(e!=null&&e.backgroundImage),audioEngine:!1,stencil:this.configuration.highlights.enabled,forceSRGBBufferSupportState:!0}):new Ce.NullEngine;o.enableOfflineSupport=!1,o.doNotHandleContextLost=!0,console.log=n,o.hideLoadingUI(),window.addEventListener("resize",this.fireResizeEvent.bind(this)),this.engine=o,this.scene=new xe.Scene(o),this.camera=D.create(this.scene,this.configuration),this.scene.activeCamera=this.camera,this.renderingPipeline=new Xe(this.scene,!1,this.camera),this.scene.clearColor=this.configuration.scene.clearColor;const a=G.CubeTexture.CreateFromPrefilteredData(this.configuration.scene.environment.file,this.scene);a.name="initial-environment-cube",a.rotationY=this.configuration.scene.environment.rotationY,this.scene.environmentTexture=a,this.scene.environmentIntensity=this.configuration.scene.environment.intensity,(l=this.configuration.options)!=null&&l.renderingPipelineConfiguration?this.renderingPipeline.setConfiguration(this.configuration.options.renderingPipelineConfiguration):(this.scene.imageProcessingConfiguration.exposure=this.configuration.lighting.exposure,this.scene.imageProcessingConfiguration.contrast=this.configuration.lighting.contrast),this.glowLayerManager=new De(this.scene,this.configuration.emissiveGlowIntensity),this.initPromise=new Promise(h=>{this.scene.onReadyObservable.addOnce(()=>{this.initComplete=!0,h()})}),this.engine.runRenderLoop(this.renderLoop)}getInitializationPromise(){return this.initPromise}getInitializationComplete(){return this.initComplete}getEngineContext(){return{engine:this.engine,scene:this.scene,camera:this.camera}}registerFocusLostListener(e){this.focusLostObservable.add(e)}unregisterFocusLostListener(e){this.focusLostObservable.removeCallback(e)}registerModelLoadEventListener(e){this.modelLoadEventCallbacks.push(e)}unregisterModelLoadEventListener(e){const t=this.modelLoadEventCallbacks.indexOf(e);t>-1&&this.modelLoadEventCallbacks.splice(t,1)}registerView(e){const t=e.height,i=e.width;this.engine.registerView(e,void 0,!0),e.setAttribute("height",t.toString()),e.setAttribute("width",i.toString()),this.orbitEnabled()||this.setCameraState(E.Pan),this.reattachControls(e)}getNumViewports(){var e;return((e=this.engine.views)==null?void 0:e.length)||0}unregisterView(e){this.engine.unRegisterView(e)}shutdown(){this.plugins.forEach(e=>e.dispose(!0)),this.renderingPipeline.dispose(),this.engine&&this.engine.dispose(),window.removeEventListener("resize",this.fireResizeEvent)}executeCameraAnimation(e){if(!this.camera||this.scene.activeCamera!==this.camera||this.getAllModels().length===0||!this.getAllModels().some(r=>r.getIsInitialized()))return this.queuedCameraAnimation=e,Promise.resolve();let t=()=>{};const i=async()=>{this.isAnimatingCamera=!0,await ze(this.scene,this.scene.activeCamera,e),this.isAnimatingCamera=!1,this.queuedAnimationFunction&&this.queuedAnimationFunction(),this.queuedAnimationFunction=void 0,t()};return this.isAnimatingCamera?(this.queuedAnimationFunction=i,new Promise(r=>{t=r})):i()}getCameraPose(){if(this.scene&&this.camera)return{lonDeg:Math.round(this.camera.alpha*180/Math.PI),latDeg:Math.round(this.camera.beta*180/Math.PI),radius:Math.round((this.camera.radius+Number.EPSILON)*1e4)/1e4,target:{x:this.camera.target.x,y:this.camera.target.y,z:this.camera.target.z}}}setCameraPose(e){this.scene&&this.camera&&(this.camera.target=new p.Vector3(e.target.x,e.target.y,e.target.z),this.camera.radius=e.radius,this.camera.alpha=e.latDeg,this.camera.beta=e.lonDeg)}setCameraState(e){var t,i;if(!((t=this.engine)!=null&&t.views)||!((i=this.engine)!=null&&i.views[0]))throw new Error("No views attached, camera state requires a view to attach controls onto.");e===E.Orbit?this.reattachControls(this.engine.views[0].target,2):this.reattachControls(this.engine.views[0].target,0)}animateToLastCameraFocus(){let e=()=>{};const t=async()=>{this.isAnimatingCamera=!0,await new Promise(i=>{this.focusLostNotified=!1;const r=()=>{const n=this.configuration;this.camera.rerunFramingBehavior(()=>{n.camera.limits.min.radius&&(this.camera.lowerRadiusLimit=n.camera.limits.min.radius),n.camera.limits.max.radius&&(this.camera.upperRadiusLimit=n.camera.limits.max.radius),i()})};this.scene.onAfterRenderObservable.addOnce(r)}),this.isAnimatingCamera=!1,this.queuedAnimationFunction&&this.queuedAnimationFunction(),this.queuedAnimationFunction=void 0,e()};return this.isAnimatingCamera?(this.queuedAnimationFunction=t,new Promise(i=>{e=i})):t()}forceStopCameraAnimations(){var e;this.queuedAnimationFunction=void 0,this.queuedCameraAnimation=void 0,this.isAnimatingCamera=!1,(e=this.camera.framingBehavior)==null||e.stopAllAnimations(),this.scene.stopAnimation(this.camera)}setAutoRotation(e){!this.configuration.camera.autoRotation.enabled||!this.camera||(e?this.camera.enableAutoRotationBehavior(this.configuration.camera.autoRotation.idleTimeMs):this.camera.disableAutoRotationBehavior())}getCurrentConfiguration(){return this.configuration.options}async renderSceneScreenshot(e,t){if(!this.camera)throw new Error("Missing product camera, cannot render screenshot!");const i=new w.ArcRotateCamera("screenshotCamera",0,0,0,p.Vector3.Zero(),this.scene);try{const r=t.latDeg*Math.PI/180,n=t.lonDeg*Math.PI/180;i.target=t.target?new p.Vector3(t.target.x,t.target.y,t.target.z):p.Vector3.Zero(),i.alpha=n,i.beta=r,i.radius=t.radius||this.camera.radius,i.minZ=.01,this.scene.render();const o=await Me.Tools.CreateScreenshotUsingRenderTargetAsync(this.engine,i,e,"image/png",2,!0);return i.dispose(),o}catch{throw i.isDisposed()||i.dispose(),new Error("Failed to render screenshot")}}orbitEnabled(){const e=this.configuration;if(!e)return!0;const t=e.camera.limits.min.alpha,i=e.camera.limits.max.alpha,r=e.camera.limits.min.beta,n=e.camera.limits.max.beta;if(t===void 0||i===void 0||r===void 0||n===void 0)return!0;const o=[t,i],a=[r,n],l=o.every(c=>c===t),h=a.every(c=>c===r);return!l&&!h}fireResizeEvent(){this.getNumViewports()>0&&this.engine.resize()}setHighlights(e,t){var r;e.length===0&&((r=this.highlightLayer)==null||r.dispose(),this.highlightLayer=void 0),this.highlightLayer||(this.highlightLayer=new ye.HighlightLayer("highlights",this.scene,{isStroke:!0,blurVerticalSize:.85,blurHorizontalSize:.85}),this.highlightLayer.innerGlow=!0,this.highlightLayer.outerGlow=!1),this.highlightLayer.removeAllMeshes();const i=t?new v.Color3(t[0],t[1],t[2]).toLinearSpace():void 0;e.forEach(n=>{const o=this.scene.materials.find(a=>a.name===n.name&&a.id===n.id);o&&o.getBindedMeshes().forEach(a=>{var l;return(l=this.highlightLayer)==null?void 0:l.addMesh(a,i||v.Color3.FromHexString("#fcba03"))})})}setRenderingPipelineConfiguration(e){this.renderingPipeline&&this.renderingPipeline.setConfiguration(e)}loadModel(e,t){const{refocusCamera:i=!0,progressHandler:r}=t??{},n=new _e({enablePicking:this.configuration.highlights.enabled,modelDetails:e,scene:this.scene,previewService:this,progressHandler:r});return n.getInitializationPromise().then(()=>{if(this.modelContainers.size<=1&&i){const o=this.queuedCameraAnimation;this.forceStopCameraAnimations(),this.camera.rerunFramingBehavior(()=>{this.scene.onAfterRenderObservable.addOnce(()=>{o&&(this.executeCameraAnimation(o),this.queuedCameraAnimation=void 0)})},1)}}),this.configuration.highlights.enabled&&(n.registerMaterialSelectedCallback(o=>{this.setHighlights([o])}),n.registerMaterialDeselectedCallback(()=>{this.setHighlights([])})),this.modelContainers.set(n.getId(),n),this.triggerModelLoadEvent({eventType:"load",modelContainer:n}),n}async preloadModel(e){await j(e,this.scene)}getAllModels(){return Array.from(this.modelContainers.values())}getModelById(e){return this.modelContainers.get(e)}registerPlugin(e){this.plugins.push(e),e.initialize(this,{camera:this.camera,engine:this.engine,scene:this.scene})}unregisterPlugin(e){const t=this.plugins.indexOf(e);t>-1&&this.plugins.splice(t,1).forEach(r=>r.dispose(!1))}getGlowLayerManager(){return this.glowLayerManager}modelUnloaded(e){this.modelContainers.delete(e.getId()),this.triggerModelLoadEvent({eventType:"unload",modelContainer:e})}triggerModelLoadEvent(e){this.modelLoadEventCallbacks.forEach(t=>t(e))}flipTransform(e,t,i){const r=p.Matrix.Compose(N(i||{x:1,y:1,z:1}),p.Quaternion.FromEulerVector(N(t||{x:0,y:0,z:0})),N(e||{x:0,y:0,z:0})),n=p.Matrix.RotationAxis(p.Vector3.Up(),Math.PI),o=r.multiply(n),a=p.Vector3.Zero(),l=p.Quaternion.Identity(),h=p.Vector3.Zero();return o.decompose(h,l,a),l.multiplyInPlace(p.Quaternion.FromEulerAngles(0,Math.PI,0)),{position:k(a),rotation:k(l.toEulerAngles()),scale:k(h)}}updatePreviewOptions(e){var r,n;const t=new Q(e);this.configuration.highlights.enabled!==t.highlights.enabled&&this.engine.setStencilBuffer(t.highlights.enabled),this.scene.clearColor=t.scene.clearColor;let i=this.scene.environmentTexture;this.configuration.scene.environment.file!==t.scene.environment.file&&(i=G.CubeTexture.CreateFromPrefilteredData(t.scene.environment.file,this.scene),i.name="updated-environment-cube",i.rotationY=this.configuration.scene.environment.rotationY,this.scene.environmentTexture=i),i.rotationY=t.scene.environment.rotationY,this.scene.environmentIntensity=t.scene.environment.intensity,(r=t.options)!=null&&r.renderingPipelineConfiguration?this.renderingPipeline.setConfiguration(t.options.renderingPipelineConfiguration):(this.scene.imageProcessingConfiguration.exposure=t.lighting.exposure,this.scene.imageProcessingConfiguration.contrast=t.lighting.contrast),this.glowLayerManager.setIntensity(t.emissiveGlowIntensity),this.camera.updateConfiguration(t),this.camera.setPanEnabled(((n=t.options)==null?void 0:n.noPan)!==void 0?!t.options.noPan:!0),this.configuration=t}reattachControls(e,t=2){if(this.scene.detachControl(),this.engine.inputElement=e,this.camera){this.camera.attachControl(!0,!1,t);const i=this.camera.inputs.attached.pointers;i.multiTouchPanning=!1}this.scene.attachControl(!0,!0,!0)}}d.MaterialEffectMode=L,d.ProductCameraRig=E,d.REFLECTION_PROBE_RESOLUTION=Y,d.RenderingConfiguration=x,d.SpiffCommerce3DPreviewService=Je,d.renderingPipelineDefaults=u,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(d,w){typeof exports=="object"&&typeof module<"u"?w(exports,require("@babylonjs/core/Cameras/arcRotateCamera"),require("@babylonjs/core/Engines/engine"),require("@babylonjs/core/Engines/nullEngine"),require("@babylonjs/core/Layers/highlightLayer"),require("@babylonjs/core/Loading/sceneLoader"),require("@babylonjs/core/Materials/Textures/cubeTexture"),require("@babylonjs/core/Maths/math.color"),require("@babylonjs/core/Maths/math.vector"),require("@babylonjs/core/Meshes/Compression/dracoCompression"),require("@babylonjs/core/Misc/observable"),require("@babylonjs/core/Misc/tools"),require("@babylonjs/core/scene"),require("@babylonjs/loaders/glTF"),require("@babylonjs/loaders/glTF/glTFFileLoader"),require("@babylonjs/core/Materials/PBR/pbrMaterial"),require("@babylonjs/core/Materials/Textures/mirrorTexture"),require("@babylonjs/core/Maths/math"),require("@babylonjs/core/Probes/reflectionProbe"),require("@babylonjs/core/Layers/glowLayer"),require("@babylonjs/core/Actions/actionManager"),require("@babylonjs/core/Actions/directActions"),require("@babylonjs/core/Meshes/mesh"),require("@babylonjs/core/Meshes/transformNode"),require("@babylonjs/core/Materials/Textures/dynamicTexture"),require("@babylonjs/core/Materials/Textures/texture"),require("@babylonjs/core/Animations/animation"),require("@babylonjs/core/Animations/easing"),require("@babylonjs/core/Misc/assetsManager"),require("@babylonjs/core/Materials/colorCurves"),require("@babylonjs/core/Materials/imageProcessingConfiguration"),require("@babylonjs/core/PostProcesses/RenderPipeline"),require("@babylonjs/core/PostProcesses/depthOfFieldEffect"),require("@babylonjs/core/Rendering/depthRendererSceneComponent"),require("@babylonjs/core/Engines/Extensions/engine.views"),require("@babylonjs/core/Meshes/instancedMesh"),require("@babylonjs/core/Culling/ray"),require("@babylonjs/core/Materials/Textures/Loaders/ddsTextureLoader"),require("@babylonjs/core/Materials/Textures/Loaders/envTextureLoader"),require("@babylonjs/core/Materials/Textures/Loaders/ktxTextureLoader"),require("@babylonjs/core/Animations/animatable"),require("@babylonjs/core/Misc/screenshotTools"),require("@babylonjs/core/Rendering/boundingBoxRenderer"),require("@babylonjs/loaders/glTF/2.0/Extensions")):typeof define=="function"&&define.amd?define(["exports","@babylonjs/core/Cameras/arcRotateCamera","@babylonjs/core/Engines/engine","@babylonjs/core/Engines/nullEngine","@babylonjs/core/Layers/highlightLayer","@babylonjs/core/Loading/sceneLoader","@babylonjs/core/Materials/Textures/cubeTexture","@babylonjs/core/Maths/math.color","@babylonjs/core/Maths/math.vector","@babylonjs/core/Meshes/Compression/dracoCompression","@babylonjs/core/Misc/observable","@babylonjs/core/Misc/tools","@babylonjs/core/scene","@babylonjs/loaders/glTF","@babylonjs/loaders/glTF/glTFFileLoader","@babylonjs/core/Materials/PBR/pbrMaterial","@babylonjs/core/Materials/Textures/mirrorTexture","@babylonjs/core/Maths/math","@babylonjs/core/Probes/reflectionProbe","@babylonjs/core/Layers/glowLayer","@babylonjs/core/Actions/actionManager","@babylonjs/core/Actions/directActions","@babylonjs/core/Meshes/mesh","@babylonjs/core/Meshes/transformNode","@babylonjs/core/Materials/Textures/dynamicTexture","@babylonjs/core/Materials/Textures/texture","@babylonjs/core/Animations/animation","@babylonjs/core/Animations/easing","@babylonjs/core/Misc/assetsManager","@babylonjs/core/Materials/colorCurves","@babylonjs/core/Materials/imageProcessingConfiguration","@babylonjs/core/PostProcesses/RenderPipeline","@babylonjs/core/PostProcesses/depthOfFieldEffect","@babylonjs/core/Rendering/depthRendererSceneComponent","@babylonjs/core/Engines/Extensions/engine.views","@babylonjs/core/Meshes/instancedMesh","@babylonjs/core/Culling/ray","@babylonjs/core/Materials/Textures/Loaders/ddsTextureLoader","@babylonjs/core/Materials/Textures/Loaders/envTextureLoader","@babylonjs/core/Materials/Textures/Loaders/ktxTextureLoader","@babylonjs/core/Animations/animatable","@babylonjs/core/Misc/screenshotTools","@babylonjs/core/Rendering/boundingBoxRenderer","@babylonjs/loaders/glTF/2.0/Extensions"],w):(d=typeof globalThis<"u"?globalThis:d||self,w(d.Preview={},d.arcRotateCamera,d.engine,d.nullEngine,d.highlightLayer,d.sceneLoader,d.cubeTexture,d.math_color,d.math_vector,d.dracoCompression,d.observable,d.tools,d.scene,d.glTF,d.glTFFileLoader,d.pbrMaterial,d.mirrorTexture,d.math,d.reflectionProbe,d.glowLayer,d.actionManager,d.directActions,d.mesh,d.transformNode,d.dynamicTexture,d.texture,d.animation,d.easing,d.assetsManager,d.colorCurves,d.imageProcessingConfiguration,d.RenderPipeline,d.depthOfFieldEffect))})(this,function(d,w,z,ye,Ce,I,G,v,p,we,A,Me,xe,Ae,Pe,S,Te,T,Re,Ee,B,H,Le,Oe,Fe,Ie,M,U,Se,K,R,Be,q){"use strict";var E=(s=>(s[s.Orbit=0]="Orbit",s[s.Pan=1]="Pan",s))(E||{}),L=(s=>(s.None="None",s.RemoveWhenSelected="RemoveWhenSelected",s.ApplyWhenSelected="ApplyWhenSelected",s))(L||{});function qe(){const s=navigator.vendor.toLowerCase().includes("apple"),e=navigator.maxTouchPoints>0,t=!navigator.userAgent.toLowerCase().includes("crios");return s&&e&&t}const W=new Map;async function j(s,e,t){const i=await W.get(s);if(i&&i.scene.uid===e.uid)return i;const a=I.SceneLoader.LoadAssetContainerAsync(s,void 0,e,t);return!qe()&&W.set(s,a),a}I.SceneLoader.OnPluginActivatedObservable.add(s=>{s.name==="gltf"&&(s.animationStartMode=Pe.GLTFLoaderAnimationStartMode.NONE)});class Q{constructor(e){this.getSceneClearColor=()=>{var i,a,n,o;const t=(i=this.customOptions)!=null&&i.transparentBackground||(a=this.customOptions)!=null&&a.backgroundImage?0:1;if(this.customOptions&&((n=this.customOptions)!=null&&n.transparentBackground)||(o=this.customOptions)!=null&&o.backgroundImage)return new v.Color4(0,0,0,t).toLinearSpace();if(this.customOptions&&this.customOptions.backgroundColor){const r=v.Color3.FromHexString(this.customOptions.backgroundColor);return new v.Color4(r.r,r.g,r.b,t).toLinearSpace()}return new v.Color4(.98,.98,.98,t).toLinearSpace()},this.highlightColorFromConfig=()=>this.customOptions&&this.customOptions.highlightColor?this.hexToColor4(this.customOptions.highlightColor):new v.Color4(.98,.98,.98,1).toLinearSpace(),this.hexToColor4=(t,i=1)=>{const a=v.Color3.FromHexString(t);return new v.Color4(a.r,a.g,a.b,i).toLinearSpace()},this.customOptions=e}createCanvas(){var e;return(e=this.customOptions)!=null&&e.createCanvas?this.customOptions.createCanvas():document.createElement("canvas")}get options(){return this.customOptions}get scene(){var e,t,i,a,n;return{clearColor:this.getSceneClearColor(),transparentBackground:((e=this.customOptions)==null?void 0:e.transparentBackground)||((t=this.customOptions)==null?void 0:t.backgroundImage),environment:{file:((i=this.customOptions)==null?void 0:i.environmentFile)??"assets/model-viewer/default.env",intensity:((a=this.customOptions)==null?void 0:a.environmentIntensity)??1,rotationY:(((n=this.customOptions)==null?void 0:n.environmentRotationY)??0)*(Math.PI/180)}}}get camera(){var e,t,i,a,n,o,r,l,h,c,g,m,b;return{autoOrientation:((e=this.customOptions)==null?void 0:e.disableAutomaticOrientation)??!0,autoRotation:{enabled:((t=this.customOptions)==null?void 0:t.autoRotation)??!1,idleTimeMs:((i=this.customOptions)==null?void 0:i.idleTimeBeforeRotation)??5e3},limits:{min:{alpha:(a=this.customOptions)!=null&&a.lowerAlphaLimitDeg?((n=this.customOptions)==null?void 0:n.lowerAlphaLimitDeg)*Math.PI/180:void 0,beta:(o=this.customOptions)!=null&&o.lowerBetaLimitDeg?((r=this.customOptions)==null?void 0:r.lowerBetaLimitDeg)*Math.PI/180:void 0,radius:(l=this.customOptions)==null?void 0:l.minZoomOverride},max:{alpha:(h=this.customOptions)!=null&&h.upperAlphaLimitDeg?((c=this.customOptions)==null?void 0:c.upperAlphaLimitDeg)*Math.PI/180:void 0,beta:(g=this.customOptions)!=null&&g.upperBetaLimitDeg?((m=this.customOptions)==null?void 0:m.upperBetaLimitDeg)*Math.PI/180:void 0,radius:(b=this.customOptions)==null?void 0:b.maxZoomOverride}}}}get highlights(){var e;return{enabled:((e=this.customOptions)==null?void 0:e.highlightOnMaterialHover)??!1,color:this.highlightColorFromConfig()}}get lighting(){var e,t,i,a;return{exposure:((t=(e=this.customOptions)==null?void 0:e.lighting)==null?void 0:t.exposure)??.9,contrast:((a=(i=this.customOptions)==null?void 0:i.lighting)==null?void 0:a.contrast)??1.6}}get emissiveGlowIntensity(){var e;return((e=this.customOptions)==null?void 0:e.emissiveGlowIntensity)??.5}}class x{static getDynamicTextureResolution(e=!1){return e?{width:1,height:1}:this.getIsMobile()||!x.offscreenRenderingSupported()?{width:1024,height:1024}:{width:2048,height:2048}}static shouldMipMap(){return!0}static offscreenRenderingSupported(){return navigator.userAgent.includes("SamsungBrowser")?!1:!!window.Worker&&!!window.OffscreenCanvas}static getMirrorTextureResolution(){return this.getIsMobile()?512:1024}static getIsMobile(){try{return typeof window>"u"||!window.navigator?!1:/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(window.navigator.userAgent)||window.innerWidth/window.devicePixelRatio<=480}catch{return!1}}}const Y=128,u={antiAliasing:{samples:4,fxaaEnabled:!1},bloom:{enabled:!1,kernel:64,scale:.5,threshold:.9,weight:.15},chromaticAberration:{enabled:!1,aberrationAmount:30,direction:{x:0,y:0},radialIntensity:0},colorCurves:{enabled:!1},depthOfField:{enabled:!1,blurLevel:"Low",focalLength:50,focusDistance:2e3,fStop:1.4,lensSize:50},grain:{enabled:!1,animated:!1,intensity:30},misc:{contrast:1,exposure:1,toneMappingEnabled:!1,toneMappingType:"Standard"},sharpen:{enabled:!1,colorAmount:1,edgeAmount:.3},vignette:{enabled:!1,blendMode:"Multiply",cameraFov:.5,center:{x:0,y:0},colorHex:"#000000ff",colorRgba:{r:0,g:0,b:0,a:1},stretch:0,weight:1}};class je{constructor(e){this.name="glbPostProcessor",this.enabled=!0,this.loader=e}onReady(){this.applyReflections(this.loader.babylonScene)}loadNodeAsync(e,t,i){return this.loader.loadNodeAsync(e,t,function(a){t.extras&&Object.keys(t.extras).forEach(n=>{const o=t.extras[n];a.metadata[n]=o}),i(a)})}async loadMaterialPropertiesAsync(e,t,i){await this.loader.loadMaterialPropertiesAsync(e,t,i),this.enableMaterialExtrasIfRequired(t,i),i.needDepthPrePass=!0}dispose(){}enableMaterialExtrasIfRequired(e,t){if(!(!e.extras||!(t instanceof S.PBRMaterial))){if(e.extras.sheen){const i=t;i.sheen.isEnabled=!0,i.sheen.intensity=e.extras.sheen}if(e.extras.translucency){const i=t;i.subSurface.isTranslucencyEnabled=!0,i.subSurface.translucencyIntensity=e.extras.translucency,e.extras.translucencyR&&e.extras.translucencyG&&e.extras.translucencyB&&(i.subSurface.tintColor=new T.Color3(e.extras.translucencyR,e.extras.translucencyG,e.extras.translucencyB))}if(e.extras.refractionIOR){const i=t;i.subSurface.isRefractionEnabled=!0,i.subSurface.volumeIndexOfRefraction=e.extras.refractionIOR}if(e.extras.useDepthPrePass){const i=t;i.needDepthPrePass=!0,i.forceIrradianceInFragment=!0}if(e.extras.useParallax){const i=t;i.useParallax=!0,i.useParallaxOcclusion=!0,i.parallaxScaleBias=e.extras.useParallax}}}applyReflections(e){function t(n){const o=[];return n.transformNodes.forEach(r=>{r.metadata&&r.metadata.reflective&&o.push(...r.getChildMeshes())}),n.meshes.forEach(r=>{r.metadata&&r.metadata.reflective&&!o.includes(r)&&o.push(r)}),o}function i(n,o=1){const r=n.material;if(!r)return;const l=new Te.MirrorTexture("mirror",x.getMirrorTextureResolution(),e,!0);l.renderList=t(e);const h=n.getVerticesData("normal");if(!h)throw new Error("Mirror attribute specified on: "+n.name+"But no normals exist to generate a mirror from!");n.computeWorldMatrix(!0);const c=n.getWorldMatrix(),g=T.Vector3.TransformNormal(new T.Vector3(h[0],h[1],h[2]),c).normalize(),m=T.Plane.FromPositionAndNormal(n.position,g.scale(-1));l.mirrorPlane=m,l.level=o,r.reflectionTexture=l}function a(n){const o=n.material,r=new Re.ReflectionProbe("probe-"+o.name,Y,e);r.cubeTexture.name="reflection-probe-cube-texture",r.attachToMesh(n),r.renderList&&r.renderList.push(...t(e)),o.reflectionTexture=r.cubeTexture}e.meshes.forEach(n=>{const o=n.metadata;o&&(o.mirrorTexture&&i(n,o.mirrorTexture),o.reflectionProbe&&a(n))})}}class De{constructor(e,t){this.scene=e,this.intensity=t,this.meshCount=0}setIntensity(e){this.intensity=e,this.glowLayer&&(this.glowLayer.intensity=e)}includeMeshes(e){if(e){this.glowLayer||(this.glowLayer=new Ee.GlowLayer("glow",this.scene),this.glowLayer.intensity=this.intensity);for(const t of e)this.glowLayer.hasMesh(t)||(this.glowLayer.addIncludedOnlyMesh(t),this.meshCount++)}}removeMeshes(e){if(!(!this.glowLayer||!e)){for(const t of e)this.glowLayer.hasMesh(t)&&(this.glowLayer.removeIncludedOnlyMesh(t),this.meshCount--);this.meshCount===0&&(this.glowLayer.dispose(),this.glowLayer=void 0)}}}function Ve(s,e,t,i,a=""){t.forEach(n=>{const o=n.getID(),r=n.getName(),l=n.getPanelSize&&n.getPanelSize(),h=x.getDynamicTextureResolution((l==null?void 0:l.width)===1||(l==null?void 0:l.height)===1);s.filter(g=>g.name===a+r).forEach(g=>{const m=i.get(o),b=!1;if(m)Z(g,m),m.update(b);else{const f=Ne(r,e,h.width,h.height);i.set(o,f),n.setStaticContext(f.getContext()),Z(g,f),f.onLoadObservable.addOnce(()=>{f.update(b)})}})})}function Ne(s,e,t,i){const a=new Fe.DynamicTexture(s,{width:t,height:i},e,x.shouldMipMap(),Ie.Texture.TRILINEAR_SAMPLINGMODE,z.Engine.TEXTUREFORMAT_RGBA),n=a.getContext();return n&&(n.fillStyle="#f5f5f5",n.fillRect(0,0,t,i),a.update()),a}function Z(s,e){if(s instanceof S.PBRMaterial){const t=s,i=t.albedoTexture;i?(e.wrapU=i.wrapU,e.wrapV=i.wrapV):(e.wrapU=1,e.wrapV=1),t.albedoTexture=e}else{const t=s,i=t.diffuseTexture;i&&(e.wrapU=i.wrapU,e.wrapV=i.wrapV),t.diffuseTexture=e}}function ke(){const s=()=>Math.floor((1+Math.random())*65536).toString(16).substring(1);return s()+s()+"-"+s()+"-"+s()+"-"+s()+"-"+s()+s()+s()}const P=60,$=1;function _(s){return s.targetedAnimations.map(t=>t.animation.framePerSecond).reduce((t,i)=>t+i,0)/s.targetedAnimations.length||0}function X(s,e,t,i,a,n){const o=a?s.filter(c=>c.name===a):s;if(o.length===0){console.warn(`No animations found for name: ${a}`);return}let r=0;const l=()=>{r++,r===o.length&&n&&n()},h=(c,g,m,b,f)=>{c.stop(),c.start(g,m,b,f),n&&(g==!1||g===void 0&&!c.loopAnimation?c.onAnimationGroupEndObservable.addOnce(()=>{l()}):c.onAnimationLoopObservable.addOnce(()=>{l()}))};if(i!==void 0&&t!==void 0&&i===t){o.forEach(c=>{const g=_(c),m=i*g;h(c,!1,$,m,m)});return}o.forEach(c=>{const g=_(c),m=i!==void 0?i*g:void 0,b=t!==void 0?t*g:void 0;h(c,e,$,m,b)})}function ze(s,e,t){return new Promise(i=>{s.stopAnimation(e),e.animations=[],Math.abs(e.alpha)>2*Math.PI&&(e.alpha=Ge(e.alpha,0,2*Math.PI));const a=[],n=t.target,o=0,r=n?1:0;if(t.target&&Object.keys(t.target).length>0&&a.push(O("cameraTargetLerp","target",new p.Vector3().copyFrom(e.target),new p.Vector3(t.target.x,t.target.y,t.target.z),M.Animation.ANIMATIONTYPE_VECTOR3,o)),a.push(O("cameraAlphaLerp","alpha",e.alpha,J(t.lonDeg),M.Animation.ANIMATIONTYPE_FLOAT,r)),a.push(O("cameraBetaLerp","beta",e.beta,J(t.latDeg),M.Animation.ANIMATIONTYPE_FLOAT,r)),t.radius!==void 0){const c=Math.max(.01,t.radius);a.push(O("cameraRadiusLerp","radius",e.radius,c,M.Animation.ANIMATIONTYPE_FLOAT,r))}e.animations.push(...a);const h=e.useAutoRotationBehavior;e.disableAutoRotationBehavior(),s.beginAnimation(e,0,n?P*2:P,!1,1,()=>{e.animations=[],h&&e.enableAutoRotationBehavior(),i()})})}function J(s){return s*Math.PI/180}function O(s,e,t,i,a,n=0,o=M.Animation.ANIMATIONLOOPMODE_CONSTANT){const r=new U.QuadraticEase;r.setEasingMode(U.EasingFunction.EASINGMODE_EASEINOUT);const l=new M.Animation(s,e,P,a,o),h=[];return n>0&&h.push({frame:0,value:t}),h.push({frame:P*n,value:t}),h.push({frame:P*(n+1),value:i}),l.setKeys(h),l.setEasingFunction(r),l}function Ge(s,e,t){return s<e?s=t-(e-s)%(t-e):s=e+(s-e)%(t-e)}function He(s,e,t){s.forEach(i=>{t&&i.name!==t||i.goToFrame(e)})}const Ue={albedoTexture:"albedoMap",bumpTexture:"normalMap",ambientTexture:"ambientMap",emissiveTexture:"emissionMap",opacityTexture:"alphaMap",metallicTexture:"metallicMap",refractionTexture:"refractionMap",reflectionTexture:"reflectionMap"};function Ke(s,e,t,i){["albedoTexture","bumpTexture","ambientTexture","emissiveTexture","opacityTexture","metallicTexture","refractionTexture","reflectionTexture"].forEach(n=>{We(n,s,e,t,i)}),Ze(s,e)}function We(s,e,t,i,a){const n=Ue[s];if(!n)throw new Error("Unexpected texture name encountered.");const o=e[n],r=o==null?void 0:o.fileLink;r?s==="reflectionTexture"?r.endsWith(".env")||r.endsWith(".dds")?i.addCubeTextureTask(s,r,void 0,!1,void 0,!0):r.endsWith(".hdr")?i.addHDRCubeTextureTask(s,r,128,!1,!0,!1):i.addTextureTask(s,r,!1,!1):i.addTextureTask(s,r,!1,!1):a&&t[s]&&(t[s]&&t[s].dispose(),t[s]=null,Qe(s,t))}function Qe(s,e){s==="opacityTexture"&&(e.useAlphaFromAlbedoTexture=!0),s==="metallicTexture"&&(e.useRoughnessFromMetallicTextureAlpha=!1,e.useRoughnessFromMetallicTextureGreen=!1,e.useMetallnessFromMetallicTextureBlue=!1),s==="refractionTexture"&&(e.subSurface.isRefractionEnabled=!1,e.subSurface.refractionIntensity=1),s==="reflectionTexture"&&(e.environmentIntensity=1),s==="emissiveTexture"&&(e.emissiveIntensity=0,e.emissiveColor=new v.Color3(0,0,0),e.reflectionTexture)}function Ye(s,e,t,i){if(!e){console.error("Failed to apply texture to material: material is null.");return}s==="opacityTexture"&&(e.useAlphaFromAlbedoTexture=!1),s==="metallicTexture"&&(e.useRoughnessFromMetallicTextureAlpha=!1,e.useRoughnessFromMetallicTextureGreen=!0,e.useMetallnessFromMetallicTextureBlue=!0),s==="refractionTexture"&&(e.subSurface.isRefractionEnabled=!0,e.subSurface.refractionIntensity=t.refractionIntensity||1),s==="reflectionTexture"&&(e.environmentIntensity=t.reflectionIntensity||1,i.isCube&&(i.rotationY=t.reflectionRotation?t.reflectionRotation*Math.PI/180:0)),e[s]=i,s==="emissiveTexture"&&(e.emissiveColor=new v.Color3(1,1,1),e.emissiveIntensity=1)}function Ze(s,e){s.clearCoat&&(s.clearCoat===L.RemoveWhenSelected?(e.clearCoat.isEnabled=!1,e.clearCoat.indexOfRefraction=1.5):s.clearCoat===L.ApplyWhenSelected&&(e.clearCoat.isEnabled=!0,e.clearCoat.indexOfRefraction=s.clearCoatIOR||e.clearCoat.indexOfRefraction))}class $e{constructor(e,t,i){this.materialVariantMap=new Map,this.keysThatRemovedBaseModel=[],this.loadedContainerForKey=new Map,this.loadedMaterialsForKey=new Map,this.scene=e,this.renameClonedAsset=t,this.setBaseModelEnabled=i}async applyMaterial(e,t,i,a){return new Promise(n=>{const o=this.materialVariantMap.get(e);this.materialVariantMap.set(e,{...o,...t});const r=this.renameClonedAsset(e),l=this.scene.materials.filter(c=>c.name===r);if(l.length===0){n();return}const h=new Se.AssetsManager(this.scene);h.useDefaultLoadingScreen=!1,l.forEach(c=>Ke(t,c,h,a)),h.onProgress=(c,g,m)=>{i&&i(c/g*100,100,m.name)},h.onFinish=c=>{c.forEach(g=>{const m=g;i&&i(100,100,g.name),this.scene.materials.filter(f=>f.name===r).forEach(f=>{Ye(g.name,f,t,m.texture)})}),n()},h.loadAsync()})}async applyModel(e,t,i,a,n,o,r){var m,b,f;if(i&&t&&!this.keysThatRemovedBaseModel.includes(e)&&this.keysThatRemovedBaseModel.push(e),!i)return this.keysThatRemovedBaseModel.includes(e)&&this.keysThatRemovedBaseModel.length===1&&await this.setBaseModelEnabled(!0),(m=this.loadedContainerForKey.get(e))==null||m.dispose(),this.loadedContainerForKey.delete(e),(b=this.loadedMaterialsForKey.get(e))==null||b.forEach(y=>y.dispose()),this.loadedMaterialsForKey.delete(e),this.keysThatRemovedBaseModel=this.keysThatRemovedBaseModel.filter(y=>y!==e),Promise.resolve(void 0);const h=(await j(i,this.scene,a)).instantiateModelsToScene(this.renameClonedAsset,!0);this.loadedContainerForKey.has(e)&&(this.loadedContainerForKey.get(e).dispose(),this.loadedContainerForKey.delete(e),(f=this.loadedMaterialsForKey.get(e))==null||f.forEach(y=>y.dispose()),this.loadedMaterialsForKey.delete(e));const c=n&&n();if(c){const y=o&&o(),C=c.name?this.renameClonedAsset(c.name):void 0;if(X(h.animationGroups,c.loop,c.to,c.from,C),y!=null){const F=r&&r()||!0;He(h.animationGroups,y+(F?2:0),C)}}t&&await this.setBaseModelEnabled(!1),this.loadedContainerForKey.set(e,h),this.loadedMaterialsForKey.set(e,ee(h));const g=[];return this.materialVariantMap.forEach(async(y,C)=>{g.push(this.applyMaterial(C,y))}),await Promise.all(g),h}dispose(){this.loadedContainerForKey.forEach(e=>e==null?void 0:e.dispose()),this.loadedContainerForKey.clear(),this.loadedMaterialsForKey.forEach(e=>e.forEach(t=>t==null?void 0:t.dispose())),this.loadedMaterialsForKey.clear(),this.materialVariantMap.clear(),this.keysThatRemovedBaseModel=[]}getAllMaterials(){const e=[];return this.loadedMaterialsForKey.forEach(t=>{t.forEach(i=>{e.includes(i)||e.push(i)})}),e}getAnimationGroups(){const e=[];return this.loadedContainerForKey.forEach(t=>{e.push(...t.animationGroups)}),e}}function ee(s){const e=[];return s.rootNodes.forEach(t=>{t.getChildMeshes().forEach(i=>{i.material&&!e.includes(i.material)&&e.push(i.material),i.subMeshes&&i.subMeshes.forEach(a=>{const n=a.getMaterial(!1);n&&!e.includes(n)&&e.push(n)})})}),e}function te(s,e=""){return s.map(t=>({name:t.name.substring(e.length),loop:t.loopAnimation,to:t.to,from:t.from}))}class _e{constructor(e){this.metadata=new Map,this.materialSelectedObservable=new A.Observable,this.materialDeselectedObservable=new A.Observable,this.materialVariantObservable=new A.Observable,this.modelVariantObservable=new A.Observable,this.materialReadyToLoadCallbacks=new Map,this.dynamicTextures=new Map,this.queuedMaterialChanges=new Map,this.materialChangesInProgress=[],this.queuedModelChanges=new Map,this.modelChangesInProgress=[],this.isExecutingAnimation=!1,this.animations=[],this.initialized=!1,this.materials=[];const{enablePicking:t,modelDetails:i,previewService:a,progressHandler:n,scene:o}=e;this.enablePicking=t,this.contextService=i.contextService,this.id=ke(),this.previewService=a,this.scene=o,this.variantManager=new $e(o,this.renameClonedAsset.bind(this),this.setBaseModelEnabled.bind(this)),this.transformRoot=new Oe.TransformNode("root",this.scene);const r=async()=>{if(!i.model)throw new Error("Model container constructed with no URL. This is currently unsupported.");return this.assetContainer=await j(i.model,o,n),await this.instantiate(),this};this.importPromise=r()}async applyMaterialVariant(e,t,i,a){if(!this.initialized){if(this.materialReadyToLoadCallbacks.has(e)){const o=this.materialReadyToLoadCallbacks.get(e);o==null||o.set(t,this.applyMaterialVariant.bind(this,e,t,i,a))}else{this.materialReadyToLoadCallbacks.set(e,new Map);const o=this.materialReadyToLoadCallbacks.get(e);o==null||o.set(t,this.applyMaterialVariant.bind(this,e,t,i,a))}return}const n=async()=>{await this.variantManager.applyMaterial(e,i,(o,r,l)=>{this.materialVariantObservable.notifyObservers({remainingCount:o,totalCount:r,taskName:l})},a)};if(this.materialChangesInProgress.includes(e)){if(this.queuedMaterialChanges.has(e)){const o=this.queuedMaterialChanges.get(e);o==null||o.set(t,n)}else{this.queuedMaterialChanges.set(e,new Map);const o=this.queuedMaterialChanges.get(e);o==null||o.set(t,n)}return}if(this.materialChangesInProgress.push(e),await n(),this.queuedMaterialChanges.has(e)){const o=this.queuedMaterialChanges.get(e);if(!o)throw new Error("Target material is undefined");o.forEach(async r=>{await r()}),this.queuedMaterialChanges.delete(e)}this.materialChangesInProgress.splice(this.materialChangesInProgress.indexOf(e),1),this.configureGlowLayer(),this.scene.cleanCachedTextureBuffer()}async applyModelVariant(e,t,i){const a=()=>this.variantManager.applyModel(e,i,t==null?void 0:t.model,r=>{this.modelVariantObservable.notifyObservers({...r,key:e})},this.getLastRequestedAnimation.bind(this),this.getCurrentAnimationFrame.bind(this),this.getAnimationIsPlaying.bind(this)),n=async()=>{this.modelChangesInProgress.push(e);let r=await a();if(this.queuedModelChanges.has(e)){const l=this.queuedModelChanges.get(e);if(!l)throw new Error("Queued change resolved undefined");r=await l(),this.queuedModelChanges.delete(e)}return this.modelChangesInProgress.splice(this.modelChangesInProgress.indexOf(e),1),r};if(!this.initialized||this.modelChangesInProgress.includes(e)){const r=async()=>{const l=await a();return l?this.configureModelInstance(l):this.configureGlowLayer(),l};this.queuedModelChanges.set(e,r);return}const o=await n();this.contextService||(this.contextService=t==null?void 0:t.contextService),o?this.configureModelInstance(o):this.configureGlowLayer()}dispose(){var e;this.destroyInstance(),this.variantManager.dispose(),this.dynamicTextures.forEach(t=>t==null?void 0:t.dispose()),this.dynamicTextures.clear(),this.materials.forEach(t=>t&&(t==null?void 0:t.dispose())),this.materials=[],(e=this.transformRoot)==null||e.dispose(),this.transformRoot=void 0,this.previewService.modelUnloaded(this)}executeAnimation(e){if(this.lastRequestedAnimation=e,!this.initialized)return this.queuedModelAnimation=e,Promise.resolve();let t=()=>{};const i=async()=>{this.isExecutingAnimation=!0,await new Promise(a=>{var o;const n=[...((o=this.modelInstance)==null?void 0:o.animationGroups)||[],...this.variantManager.getAnimationGroups()];X(n,e.loop,e.to,e.from,e.name?this.renameClonedAsset(e.name):void 0,a)}),this.isExecutingAnimation=!1,this.queuedAnimationFunction&&this.queuedAnimationFunction(),this.queuedAnimationFunction=void 0,t()};return this.isExecutingAnimation?(this.queuedAnimationFunction=i,new Promise(a=>{t=a})):i()}getAnimations(e){return[...this.animations,...e?te(this.variantManager.getAnimationGroups(),this.renameClonedAsset("")):[]].map((t,i)=>({...t,name:t.name||`UNNAMED_ANIMATION_${i}`})).filter((t,i,a)=>a.indexOf(a.find(n=>n.name===t.name))==i)}getId(){return this.id}listMaterials(){var t;const e=(t=this.scene)==null?void 0:t.materials.filter(i=>i.name.startsWith(this.id));return e?e.map(i=>({id:i.id,name:this.stripIdFromName(i.name)})):[]}registerMaterialSelectedCallback(e){this.materialSelectedObservable.add(e)}unregisterMaterialSelectedCallback(e){this.materialSelectedObservable.removeCallback(e)}registerMaterialDeselectedCallback(e){this.materialDeselectedObservable.add(e)}unregisterMaterialDeselectedCallback(e){this.materialDeselectedObservable.removeCallback(e)}get position(){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to requesting position!");return this.transformRoot.position}set position(e){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to setting position!");this.transformRoot.position=new p.Vector3(e.x,e.y,e.z)}get rotation(){var e;if(!((e=this.transformRoot)!=null&&e.rotationQuaternion))throw new Error("ModelContainer disposed prior to requesting rotation!");return this.transformRoot.rotationQuaternion.toEulerAngles()}set rotation(e){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to setting rotation!");this.transformRoot.rotationQuaternion=p.Quaternion.FromEulerAngles(e.x,e.y,e.z)}get scale(){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to requesting scale!");return this.transformRoot.scaling}set scale(e){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to setting scale!");this.transformRoot.scaling=new p.Vector3(e.x,e.y,e.z)}attachPickingHandler(e){e.rootNodes.forEach(t=>{t.getChildMeshes(!1).forEach(i=>{i.name==="targetcube_t"||i.name==="backgroundShell"||(i.actionManager||(i.actionManager=new B.ActionManager(this.scene)),i.actionManager.registerAction(new H.ExecuteCodeAction(B.ActionManager.OnPointerOverTrigger,a=>{a.meshUnderPointer&&i.material&&this.materialSelectedObservable.notifyObservers({id:i.material.id,name:this.stripIdFromName(i.material.name)})})),i.actionManager.registerAction(new H.ExecuteCodeAction(B.ActionManager.OnPointerOutTrigger,()=>{i.material&&this.materialDeselectedObservable.notifyObservers({id:i.material.id,name:this.stripIdFromName(i.material.name)})})))})})}getInitializationPromise(){return this.importPromise}getIsInitialized(){return this.initialized}getQueuedMaterialVariantCount(){return this.materialReadyToLoadCallbacks.size}getQueuedModelVariantCount(){return this.queuedModelChanges.size}configureGlowLayer(){const e=i=>i instanceof S.PBRMaterial&&i.emissiveTexture!==null;this.materials.some(e)||this.variantManager.getAllMaterials().some(e)?this.previewService.getGlowLayerManager().includeMeshes(this.getAllMeshes()):this.previewService.getGlowLayerManager().removeMeshes(this.getAllMeshes())}configureModelInstance(e){var n;if(!this.transformRoot)throw new Error("Transform disposed! This should never happen unless there is a race condition present!");const t=this.transformRoot.position,i=this.transformRoot.rotationQuaternion,a=this.transformRoot.scaling;this.transformRoot.position=p.Vector3.Zero(),this.transformRoot.rotationQuaternion=p.Quaternion.Identity(),this.transformRoot.scaling=p.Vector3.One();for(const o of e.rootNodes){o.parent=this.transformRoot;for(const r of o.getChildMeshes(!1))r.alwaysSelectAsActiveMesh=!0}this.transformRoot.position=t,this.transformRoot.rotationQuaternion=i,this.transformRoot.scaling=a,this.canvasPanels=((n=this.contextService)==null?void 0:n.getAll())||new Map,Ve(this.materials.concat(this.variantManager.getAllMaterials()),this.scene,this.canvasPanels,this.dynamicTextures,`${this.id}_`),this.enablePicking&&this.attachPickingHandler(e),this.configureGlowLayer()}destroyInstance(){var e;(e=this.modelInstance)==null||e.dispose(),this.modelInstance=void 0}getAllMeshes(){var e;return(e=this.modelInstance)==null?void 0:e.rootNodes.map(t=>t.getChildMeshes(!1).filter(i=>i instanceof Le.Mesh)).flat()}async instantiate(){if(!this.assetContainer)throw new Error("Attempted to instantiate ModelContainer without an AssetContainer");this.modelInstance=this.assetContainer.instantiateModelsToScene(this.renameClonedAsset.bind(this),!0),this.materials=ee(this.modelInstance),this.configureModelInstance(this.modelInstance),this.animations=te(this.modelInstance.animationGroups,this.renameClonedAsset("")),this.initialized=!0,await this.processQueuedEvents()}renameClonedAsset(e){return`${this.id}_${e}`}async setBaseModelEnabled(e){e&&!this.modelInstance?await this.instantiate():!e&&this.modelInstance&&this.destroyInstance()}updateDynamicTextures(){var e;(e=this.canvasPanels)==null||e.forEach((t,i)=>{const a=this.dynamicTextures.get(i);a&&t.getStaticContextDirty()&&a.isReady()&&(a.update(!1),t.setStaticContextDirty(!1))})}registerMaterialVariantListener(e){this.materialVariantObservable.add(e)}unregisterMaterialVariantListener(e){this.materialVariantObservable.removeCallback(e)}registerModelVariantListener(e){this.modelVariantObservable.add(e)}unregisterModelVariantListener(e){this.modelVariantObservable.removeCallback(e)}getLastRequestedAnimation(){return this.lastRequestedAnimation}getCurrentAnimationFrame(){var t;const e=[...((t=this.modelInstance)==null?void 0:t.animationGroups)||[],...this.variantManager.getAnimationGroups()];for(const i of e)if(i.animatables.length>0&&i.animatables[0].masterFrame!==void 0&&i.animatables[0].masterFrame!==null)return i.animatables[0].masterFrame;return 0}getAnimationIsPlaying(){var t;const e=[...((t=this.modelInstance)==null?void 0:t.animationGroups)||[],...this.variantManager.getAnimationGroups()];for(const i of e)if(i.isPlaying)return!0;return!1}stripIdFromName(e){return e.substring(this.id.length+1)}async processQueuedEvents(){await Promise.all(Array.from(this.materialReadyToLoadCallbacks.values()).flatMap(e=>Array.from(e.values()).map(t=>t()))),this.materialReadyToLoadCallbacks.clear(),await Promise.all(Array.from(this.queuedModelChanges.values()).map(e=>e())),this.queuedModelChanges.clear(),this.scene.onAfterRenderObservable.addOnce(()=>{this.queuedModelAnimation&&(this.executeAnimation(this.queuedModelAnimation),this.queuedModelAnimation=void 0)})}}class D extends w.ArcRotateCamera{constructor(e,t,i,a,n,o,r,l){super(e,t,i,a,n,o,l),this.lastFocus=new p.Vector3(0,0,0),this._isRunningFramingBehavior=!1,this.panDenominator=1,this.panEnabled=!0,this.minZ=.01,this.updateRadiusBounds(this.radius),this.enableFramingBehavior(),this.wheelDeltaPercentage=.01,this.pinchDeltaPercentage=.005,this.useNaturalPinchZoom=!0,r.camera.autoOrientation&&(this.alpha+=Math.PI),r&&(r.camera.limits.min.beta&&(this.lowerBetaLimit=r.camera.limits.min.beta),r.camera.limits.max.beta&&(this.upperBetaLimit=r.camera.limits.max.beta),r.camera.limits.min.alpha&&(this.lowerAlphaLimit=r.camera.limits.min.alpha),r.camera.limits.max.alpha&&(this.upperAlphaLimit=r.camera.limits.max.alpha),r.camera.limits.min.radius&&(this.lowerRadiusLimit=r.camera.limits.min.radius),r.camera.limits.max.radius&&(this.upperRadiusLimit=r.camera.limits.max.radius),r.camera.autoRotation.enabled&&this.enableAutoRotationBehavior(r.camera.autoRotation.idleTimeMs))}updateConfiguration(e){e&&(this.lowerBetaLimit=e.camera.limits.min.beta??null,this.upperBetaLimit=e.camera.limits.max.beta??null,this.lowerAlphaLimit=e.camera.limits.min.alpha??null,this.upperAlphaLimit=e.camera.limits.max.alpha??null,e.camera.autoRotation.enabled?this.enableAutoRotationBehavior(e.camera.autoRotation.idleTimeMs):this.disableAutoRotationBehavior())}get isRunningFramingBehavior(){return this._isRunningFramingBehavior}set isRunningFramingBehavior(e){this._isRunningFramingBehavior=e,!e&&this.framingBehaviourCallback&&(this.framingBehaviourCallback(),this.framingBehaviourCallback=void 0)}setPanEnabled(e){this.panEnabled=e,this.panningSensibility=1e3/this.panDenominator,this.panningAxis=e?new p.Vector3(1,1,0):new p.Vector3(0,0,0)}getFramingBehavior(){return this.getBehaviorByName("Framing")}getAutoRotationBehavior(){const e=this.getBehaviorByName("AutoRotation");if(e)return e}enableFramingBehavior(){this.useFramingBehavior=!0;const e=this.getFramingBehavior();e.attach(this),e.framingTime=0,e.elevationReturnTime=-1,e.zoomStopsAnimation=!1,this.lowerRadiusLimit=null;const t=V(this._scene);return e.zoomOnBoundingInfo(t.min,t.max),this.wheelPrecision=100/this.radius,this.lowerRadiusLimit===null&&(this.lowerRadiusLimit=.1),this.lastFocus.copyFrom(this.target),e}rerunFramingBehavior(e,t){this._isRunningFramingBehavior=!0,this.framingBehaviourCallback=e;const i=this.getFramingBehavior();i.framingTime=t||800;const a=()=>{this.isRunningFramingBehavior=!1},n=V(this._scene),o=n.max.subtract(n.min),r=n.min.add(o.scale(.5));this.updateRadiusBounds(o.length()*1.5),this.wheelPrecision=100/this.radius,this.panningInertia=0,this.panningOriginTarget.copyFrom(r),this.panDenominator=o.length(),this.lastFocus.copyFrom(r),i.zoomOnBoundingInfo(n.min,n.max,void 0,a),i.framingTime=0}enableAutoRotationBehavior(e=5e3){this.useAutoRotationBehavior=!0;const t=this.getAutoRotationBehavior();t&&(t.idleRotationWaitTime=e)}disableAutoRotationBehavior(){this.useAutoRotationBehavior=!1}updateRadiusBounds(e){this.maxZ=e*1e3,this.lowerRadiusLimit=e*.01,this.upperRadiusLimit=1.5*e,this.wheelPrecision=100/e,this.pinchPrecision=300/e}static create(e,t,i){var l;const a=V(e),n=a.max.subtract(a.min),o=a.min.add(n.scale(.5)),r=new D("ProductCamera",-(Math.PI/2),Math.PI/2,n.length()*1.5,o,e,t);return r.setPanEnabled(((l=t.options)==null?void 0:l.noPan)!==void 0?!t.options.noPan:!0),r.panningInertia=0,r.panningOriginTarget.copyFrom(o),r.panDenominator=n.length(),r.onAfterCheckInputsObservable.addOnce(()=>{r.setPanEnabled(r.panEnabled)}),i&&(e.activeCamera=r),r}}function V(s){if(s.meshes.length===0)return{min:new p.Vector3(-1,-1,-1),max:new p.Vector3(1,1,1)};const e=s.meshes.filter(t=>t.name.toLowerCase().endsWith("_t")||t.name.toLowerCase().includes("_t_"));return s.getWorldExtends(t=>t.isVisible&&t.isEnabled()&&(e.length===0||e.includes(t)))}class Xe{constructor(e,t=!1,i=void 0){this.renderingPipeline=new Be.DefaultRenderingPipeline("default",t,e,i?[i]:void 0,!1),this.renderingPipeline.isSupported&&(this.renderingPipeline.prepare(),this.setConfiguration(u))}dispose(){this.renderingPipeline.dispose()}getConfiguration(){return this.currentConfiguration}setConfiguration(e){var t,i,a,n,o,r,l,h,c,g,m,b,f,y,C,F,ie,ne,se,re,ae,oe,le,he,ce,de,ue,ge,me,pe,fe,be,ve;if(this.renderingPipeline.isSupported){if(this.renderingPipeline.samples=((t=e.antiAliasing)==null?void 0:t.samples)??u.antiAliasing.samples,this.renderingPipeline.fxaaEnabled=((i=e.antiAliasing)==null?void 0:i.fxaaEnabled)??u.antiAliasing.fxaaEnabled,this.renderingPipeline.bloomEnabled=((a=e.bloom)==null?void 0:a.enabled)??u.bloom.enabled,this.renderingPipeline.bloomKernel=((n=e.bloom)==null?void 0:n.kernel)??u.bloom.kernel,this.renderingPipeline.bloomScale=((o=e.bloom)==null?void 0:o.scale)??u.bloom.scale,this.renderingPipeline.bloomThreshold=((r=e.bloom)==null?void 0:r.threshold)??u.bloom.threshold,this.renderingPipeline.bloomWeight=((l=e.bloom)==null?void 0:l.weight)??u.bloom.weight,this.renderingPipeline.chromaticAberrationEnabled=((h=e.chromaticAberration)==null?void 0:h.enabled)??u.chromaticAberration.enabled,this.renderingPipeline.chromaticAberration.aberrationAmount=((c=e.chromaticAberration)==null?void 0:c.aberrationAmount)??u.chromaticAberration.aberrationAmount,this.renderingPipeline.chromaticAberration.radialIntensity=((g=e.chromaticAberration)==null?void 0:g.radialIntensity)??u.chromaticAberration.radialIntensity,this.renderingPipeline.chromaticAberration.direction=(m=e.chromaticAberration)!=null&&m.direction?new p.Vector2(e.chromaticAberration.direction.x,e.chromaticAberration.direction.y):new p.Vector2(u.chromaticAberration.direction.x,u.chromaticAberration.direction.y),this.renderingPipeline.imageProcessing.colorCurvesEnabled=((b=e.colorCurves)==null?void 0:b.enabled)??u.colorCurves.enabled,this.renderingPipeline.imageProcessing.colorCurves=e.colorCurves?this.updateColorCurve(e.colorCurves):new K.ColorCurves,this.renderingPipeline.depthOfFieldEnabled=((f=e.depthOfField)==null?void 0:f.enabled)??u.depthOfField.enabled,e.depthOfField)switch(e.depthOfField.blurLevel??u.depthOfField.blurLevel){case"Low":this.renderingPipeline.depthOfFieldBlurLevel=q.DepthOfFieldEffectBlurLevel.Low;break;case"Medium":this.renderingPipeline.depthOfFieldBlurLevel=q.DepthOfFieldEffectBlurLevel.Medium;break;case"High":this.renderingPipeline.depthOfFieldBlurLevel=q.DepthOfFieldEffectBlurLevel.High;break}if(this.renderingPipeline.depthOfField.focalLength=((y=e.depthOfField)==null?void 0:y.focalLength)??u.depthOfField.focalLength,this.renderingPipeline.depthOfField.fStop=((C=e.depthOfField)==null?void 0:C.fStop)??u.depthOfField.fStop,this.renderingPipeline.depthOfField.focusDistance=((F=e.depthOfField)==null?void 0:F.focusDistance)??u.depthOfField.focusDistance,this.renderingPipeline.depthOfField.lensSize=((ie=e.depthOfField)==null?void 0:ie.lensSize)??u.depthOfField.lensSize,this.renderingPipeline.grainEnabled=((ne=e.grain)==null?void 0:ne.enabled)??u.grain.enabled,this.renderingPipeline.grain.animated=((se=e.grain)==null?void 0:se.animated)??u.grain.animated,this.renderingPipeline.grain.intensity=((re=e.grain)==null?void 0:re.intensity)??u.grain.intensity,this.renderingPipeline.imageProcessing.contrast=((ae=e.misc)==null?void 0:ae.contrast)??u.misc.contrast,this.renderingPipeline.imageProcessing.exposure=((oe=e.misc)==null?void 0:oe.exposure)??u.misc.exposure,this.renderingPipeline.imageProcessing.toneMappingEnabled=((le=e.misc)==null?void 0:le.toneMappingEnabled)??u.misc.toneMappingEnabled,this.renderingPipeline.imageProcessing.toneMappingEnabled)switch(e.misc.toneMappingType??u.misc.toneMappingType){case"Standard":this.renderingPipeline.imageProcessing.toneMappingType=R.ImageProcessingConfiguration.TONEMAPPING_STANDARD;break;case"ACES":this.renderingPipeline.imageProcessing.toneMappingType=R.ImageProcessingConfiguration.TONEMAPPING_ACES;break}if(this.renderingPipeline.sharpenEnabled=((he=e.sharpen)==null?void 0:he.enabled)??u.sharpen.enabled,this.renderingPipeline.sharpen.colorAmount=((ce=e.sharpen)==null?void 0:ce.colorAmount)??u.sharpen.colorAmount,this.renderingPipeline.sharpen.edgeAmount=((de=e.sharpen)==null?void 0:de.edgeAmount)??u.sharpen.edgeAmount,this.renderingPipeline.imageProcessing.vignetteEnabled=((ue=e.vignette)==null?void 0:ue.enabled)??u.vignette.enabled,(ge=e.vignette)!=null&&ge.center?(this.renderingPipeline.imageProcessing.vignetteCenterX=e.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=e.vignette.center.y):(this.renderingPipeline.imageProcessing.vignetteCenterX=u.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=u.vignette.center.y),e.vignette)switch(((me=e.vignette)==null?void 0:me.blendMode)??u.vignette.blendMode){case"Multiply":this.renderingPipeline.imageProcessing.vignetteBlendMode=R.ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY;break;case"Opaque":this.renderingPipeline.imageProcessing.vignetteBlendMode=R.ImageProcessingConfiguration.VIGNETTEMODE_OPAQUE;break}(pe=e.vignette)!=null&&pe.colorRgba?this.renderingPipeline.imageProcessing.vignetteColor=new v.Color4(e.vignette.colorRgba.r,e.vignette.colorRgba.g,e.vignette.colorRgba.b,e.vignette.colorRgba.a):(fe=e.vignette)!=null&&fe.colorHex?this.renderingPipeline.imageProcessing.vignetteColor=v.Color4.FromHexString(e.vignette.colorHex):this.renderingPipeline.imageProcessing.vignetteColor=new v.Color4(u.vignette.colorRgba.r,u.vignette.colorRgba.g,u.vignette.colorRgba.b,u.vignette.colorRgba.a),this.renderingPipeline.imageProcessing.vignetteStretch=((be=e.vignette)==null?void 0:be.stretch)??u.vignette.stretch,this.renderingPipeline.imageProcessing.vignetteWeight=((ve=e.vignette)==null?void 0:ve.weight)??u.vignette.weight,this.renderingPipeline.prepare(),this.currentConfiguration=e}}updateColorCurve(e){const t=new K.ColorCurves;return t.globalDensity=e.globalDensity??t.globalDensity,t.globalExposure=e.globalExposure??t.globalExposure,t.globalHue=e.globalHue??t.globalHue,t.globalSaturation=e.globalSaturation??t.globalSaturation,t.highlightsDensity=e.highlightsDensity??t.highlightsDensity,t.highlightsExposure=e.highlightsExposure??t.highlightsExposure,t.highlightsHue=e.highlightsHue??t.highlightsHue,t.highlightsSaturation=e.highlightsSaturation??t.highlightsSaturation,t.midtonesDensity=e.midtonesDensity??t.midtonesDensity,t.midtonesExposure=e.midtonesExposure??t.midtonesExposure,t.midtonesHue=e.midtonesHue??t.midtonesHue,t.midtonesSaturation=e.midtonesSaturation??t.midtonesSaturation,t.shadowsDensity=e.shadowsDensity??t.shadowsDensity,t.shadowsExposure=e.shadowsExposure??t.shadowsExposure,t.shadowsHue=e.shadowsHue??t.shadowsHue,t.shadowsSaturation=e.shadowsSaturation??t.shadowsSaturation,t}}Ae.GLTF2.GLTFLoader.RegisterExtension("glbPostProcessor",function(s){return new je(s)}),I.SceneLoader.OnPluginActivatedObservable.add(s=>{if(s.name==="gltf"){const e=s;e.transparencyAsCoverage=!0}});function N(s){return new p.Vector3(s.x,s.y,s.z)}function k(s){return{x:s.x,y:s.y,z:s.z}}class Je{constructor(e){var l;this.focusLostNotified=!1,this.focusLostObservable=new A.Observable,this.modelLoadEventCallbacks=[],this.modelContainers=new Map,this.plugins=[],this.initComplete=!1,this.isAnimatingCamera=!1,this.renderLoop=()=>{if(!this.engine.views)return;this.modelContainers.forEach(g=>{g.updateDynamicTextures()}),this.scene.autoClear=!0,this.scene.autoClearDepthAndStencil=!0;const h=this.engine.getRenderingCanvas();if(h)if(h.getContext("webgl2")??h.getContext("webgl")){const g=this.configuration.scene.clearColor,m=h.getContext("webgl2")??h.getContext("webgl");m.clearDepth(1),m.depthFunc(m.LEQUAL),m.clearStencil(0),m.clearColor(g.r,g.g,g.b,g.a),m.clear(m.COLOR_BUFFER_BIT|m.DEPTH_BUFFER_BIT|m.STENCIL_BUFFER_BIT)}else h.getContext("2d")?h.getContext("2d").clearRect(0,0,h.width,h.height):console.error("SpiffCommerce: Failed to get any context on the rendering canvas.");this.scene.render(),this.camera.isRunningFramingBehavior&&this.camera.getFramingBehavior().isUserIsMoving&&(this.camera.isRunningFramingBehavior=!1);const c=Math.max((this.camera.lowerRadiusLimit??1)*.01,.001);!this.camera.isRunningFramingBehavior&&!this.camera.target.equalsWithEpsilon(this.camera.lastFocus,c)&&!this.focusLostNotified&&(this.focusLostObservable.notifyObservers(void 0),this.focusLostNotified=!0)},this.configuration=new Q(e);const i=(()=>{if(!(e!=null&&e.noRender))return this.configuration.createCanvas()})(),a="1.5.7";we.DracoCompression.Configuration={decoder:{wasmUrl:`https://www.gstatic.com/draco/versioned/decoders/${a}/draco_wasm_wrapper_gltf.js`,wasmBinaryUrl:`https://www.gstatic.com/draco/versioned/decoders/${a}/draco_decoder_gltf.wasm`,fallbackUrl:`https://www.gstatic.com/draco/versioned/decoders/${a}/draco_decoder_gltf.js`}},i&&(i.getContext("webgl2")||i.getContext("webgl"));const n=console.log;console.log=()=>{};const o=i?new z.Engine(i,!0,{adaptToDeviceRatio:!0,limitDeviceRatio:2,premultipliedAlpha:!1,preserveDrawingBuffer:!!(e!=null&&e.backgroundImage),audioEngine:!1,stencil:this.configuration.highlights.enabled,forceSRGBBufferSupportState:!0}):new ye.NullEngine;o.enableOfflineSupport=!1,o.doNotHandleContextLost=!0,console.log=n,o.hideLoadingUI(),window.addEventListener("resize",this.fireResizeEvent.bind(this)),this.engine=o,this.scene=new xe.Scene(o),this.camera=D.create(this.scene,this.configuration),this.scene.activeCamera=this.camera,this.renderingPipeline=new Xe(this.scene,!1,this.camera),this.scene.clearColor=this.configuration.scene.clearColor;const r=G.CubeTexture.CreateFromPrefilteredData(this.configuration.scene.environment.file,this.scene);r.name="initial-environment-cube",r.rotationY=this.configuration.scene.environment.rotationY,this.scene.environmentTexture=r,this.scene.environmentIntensity=this.configuration.scene.environment.intensity,(l=this.configuration.options)!=null&&l.renderingPipelineConfiguration?this.renderingPipeline.setConfiguration(this.configuration.options.renderingPipelineConfiguration):(this.scene.imageProcessingConfiguration.exposure=this.configuration.lighting.exposure,this.scene.imageProcessingConfiguration.contrast=this.configuration.lighting.contrast),this.glowLayerManager=new De(this.scene,this.configuration.emissiveGlowIntensity),this.initPromise=new Promise(h=>{this.scene.onReadyObservable.addOnce(()=>{this.initComplete=!0,h()})}),this.engine.runRenderLoop(this.renderLoop)}getInitializationPromise(){return this.initPromise}getInitializationComplete(){return this.initComplete}getEngineContext(){return{engine:this.engine,scene:this.scene,camera:this.camera}}registerFocusLostListener(e){this.focusLostObservable.add(e)}unregisterFocusLostListener(e){this.focusLostObservable.removeCallback(e)}registerModelLoadEventListener(e){this.modelLoadEventCallbacks.push(e)}unregisterModelLoadEventListener(e){const t=this.modelLoadEventCallbacks.indexOf(e);t>-1&&this.modelLoadEventCallbacks.splice(t,1)}registerView(e){const t=e.height,i=e.width;this.engine.registerView(e,void 0,!0),e.setAttribute("height",t.toString()),e.setAttribute("width",i.toString()),this.orbitEnabled()||this.setCameraState(E.Pan),this.reattachControls(e)}getNumViewports(){var e;return((e=this.engine.views)==null?void 0:e.length)||0}unregisterView(e){this.engine.unRegisterView(e)}shutdown(){this.plugins.forEach(e=>e.dispose(!0)),this.renderingPipeline.dispose(),this.engine&&this.engine.dispose(),window.removeEventListener("resize",this.fireResizeEvent)}executeCameraAnimation(e){if(!this.camera||this.scene.activeCamera!==this.camera||this.getAllModels().length===0||!this.getAllModels().some(a=>a.getIsInitialized()))return this.queuedCameraAnimation=e,Promise.resolve();let t=()=>{};const i=async()=>{this.isAnimatingCamera=!0,await ze(this.scene,this.scene.activeCamera,e),this.isAnimatingCamera=!1,this.queuedAnimationFunction&&this.queuedAnimationFunction(),this.queuedAnimationFunction=void 0,t()};return this.isAnimatingCamera?(this.queuedAnimationFunction=i,new Promise(a=>{t=a})):i()}getCameraPose(){if(this.scene&&this.camera)return{lonDeg:Math.round(this.camera.alpha*180/Math.PI),latDeg:Math.round(this.camera.beta*180/Math.PI),radius:Math.round((this.camera.radius+Number.EPSILON)*1e4)/1e4,target:{x:this.camera.target.x,y:this.camera.target.y,z:this.camera.target.z}}}setCameraPose(e){this.scene&&this.camera&&(this.camera.target=new p.Vector3(e.target.x,e.target.y,e.target.z),this.camera.radius=e.radius,this.camera.alpha=e.latDeg,this.camera.beta=e.lonDeg)}setCameraState(e){var t,i;if(!((t=this.engine)!=null&&t.views)||!((i=this.engine)!=null&&i.views[0]))throw new Error("No views attached, camera state requires a view to attach controls onto.");e===E.Orbit?this.reattachControls(this.engine.views[0].target,2):this.reattachControls(this.engine.views[0].target,0)}animateToLastCameraFocus(){let e=()=>{};const t=async()=>{this.isAnimatingCamera=!0,await new Promise(i=>{this.focusLostNotified=!1;const a=()=>{const n=this.configuration;this.camera.rerunFramingBehavior(()=>{n.camera.limits.min.radius&&(this.camera.lowerRadiusLimit=n.camera.limits.min.radius),n.camera.limits.max.radius&&(this.camera.upperRadiusLimit=n.camera.limits.max.radius),i()})};this.scene.onAfterRenderObservable.addOnce(a)}),this.isAnimatingCamera=!1,this.queuedAnimationFunction&&this.queuedAnimationFunction(),this.queuedAnimationFunction=void 0,e()};return this.isAnimatingCamera?(this.queuedAnimationFunction=t,new Promise(i=>{e=i})):t()}forceStopCameraAnimations(){var e;this.queuedAnimationFunction=void 0,this.queuedCameraAnimation=void 0,this.isAnimatingCamera=!1,(e=this.camera.framingBehavior)==null||e.stopAllAnimations(),this.scene.stopAnimation(this.camera)}setAutoRotation(e){!this.configuration.camera.autoRotation.enabled||!this.camera||(e?this.camera.enableAutoRotationBehavior(this.configuration.camera.autoRotation.idleTimeMs):this.camera.disableAutoRotationBehavior())}getCurrentConfiguration(){return this.configuration.options}async renderSceneScreenshot(e,t){if(!this.camera)throw new Error("Missing product camera, cannot render screenshot!");const i=new w.ArcRotateCamera("screenshotCamera",0,0,0,p.Vector3.Zero(),this.scene),a=t.latDeg*Math.PI/180,n=t.lonDeg*Math.PI/180;i.target=t.target?new p.Vector3(t.target.x,t.target.y,t.target.z):p.Vector3.Zero(),i.alpha=n,i.beta=a,i.radius=t.radius||this.camera.radius,i.minZ=.01;try{return await new Promise(o=>{const r=this.scene.onBeforeRenderObservable.add(async()=>{this.scene.onBeforeRenderObservable.remove(r);const l=await Me.Tools.CreateScreenshotUsingRenderTargetAsync(this.engine,i,e,"image/png",2,!0);return i.dispose(),o(l)});this.scene.render(),this.engine.endFrame()})}catch{throw i.isDisposed()||i.dispose(),new Error("Failed to render screenshot")}}orbitEnabled(){const e=this.configuration;if(!e)return!0;const t=e.camera.limits.min.alpha,i=e.camera.limits.max.alpha,a=e.camera.limits.min.beta,n=e.camera.limits.max.beta;if(t===void 0||i===void 0||a===void 0||n===void 0)return!0;const o=[t,i],r=[a,n],l=o.every(c=>c===t),h=r.every(c=>c===a);return!l&&!h}fireResizeEvent(){this.getNumViewports()>0&&this.engine.resize()}setHighlights(e,t){var a;e.length===0&&((a=this.highlightLayer)==null||a.dispose(),this.highlightLayer=void 0),this.highlightLayer||(this.highlightLayer=new Ce.HighlightLayer("highlights",this.scene,{isStroke:!0,blurVerticalSize:.85,blurHorizontalSize:.85}),this.highlightLayer.innerGlow=!0,this.highlightLayer.outerGlow=!1),this.highlightLayer.removeAllMeshes();const i=t?new v.Color3(t[0],t[1],t[2]).toLinearSpace():void 0;e.forEach(n=>{const o=this.scene.materials.find(r=>r.name===n.name&&r.id===n.id);o&&o.getBindedMeshes().forEach(r=>{var l;return(l=this.highlightLayer)==null?void 0:l.addMesh(r,i||v.Color3.FromHexString("#fcba03"))})})}setRenderingPipelineConfiguration(e){this.renderingPipeline&&this.renderingPipeline.setConfiguration(e)}loadModel(e,t){const{refocusCamera:i=!0,progressHandler:a}=t??{},n=new _e({enablePicking:this.configuration.highlights.enabled,modelDetails:e,scene:this.scene,previewService:this,progressHandler:a});return n.getInitializationPromise().then(()=>{if(this.modelContainers.size<=1&&i){const o=this.queuedCameraAnimation;this.forceStopCameraAnimations(),this.camera.rerunFramingBehavior(()=>{this.scene.onAfterRenderObservable.addOnce(()=>{o&&(this.executeCameraAnimation(o),this.queuedCameraAnimation=void 0)})},1)}}),this.configuration.highlights.enabled&&(n.registerMaterialSelectedCallback(o=>{this.setHighlights([o])}),n.registerMaterialDeselectedCallback(()=>{this.setHighlights([])})),this.modelContainers.set(n.getId(),n),this.triggerModelLoadEvent({eventType:"load",modelContainer:n}),n}async preloadModel(e){await j(e,this.scene)}getAllModels(){return Array.from(this.modelContainers.values())}getModelById(e){return this.modelContainers.get(e)}registerPlugin(e){this.plugins.push(e),e.initialize(this,{camera:this.camera,engine:this.engine,scene:this.scene})}unregisterPlugin(e){const t=this.plugins.indexOf(e);t>-1&&this.plugins.splice(t,1).forEach(a=>a.dispose(!1))}getGlowLayerManager(){return this.glowLayerManager}modelUnloaded(e){this.modelContainers.delete(e.getId()),this.triggerModelLoadEvent({eventType:"unload",modelContainer:e})}triggerModelLoadEvent(e){this.modelLoadEventCallbacks.forEach(t=>t(e))}flipTransform(e,t,i){const a=p.Matrix.Compose(N(i||{x:1,y:1,z:1}),p.Quaternion.FromEulerVector(N(t||{x:0,y:0,z:0})),N(e||{x:0,y:0,z:0})),n=p.Matrix.RotationAxis(p.Vector3.Up(),Math.PI),o=a.multiply(n),r=p.Vector3.Zero(),l=p.Quaternion.Identity(),h=p.Vector3.Zero();return o.decompose(h,l,r),l.multiplyInPlace(p.Quaternion.FromEulerAngles(0,Math.PI,0)),{position:k(r),rotation:k(l.toEulerAngles()),scale:k(h)}}updatePreviewOptions(e){var a,n;const t=new Q(e);this.configuration.highlights.enabled!==t.highlights.enabled&&this.engine.setStencilBuffer(t.highlights.enabled),this.scene.clearColor=t.scene.clearColor;let i=this.scene.environmentTexture;this.configuration.scene.environment.file!==t.scene.environment.file&&(i=G.CubeTexture.CreateFromPrefilteredData(t.scene.environment.file,this.scene),i.name="updated-environment-cube",i.rotationY=this.configuration.scene.environment.rotationY,this.scene.environmentTexture=i),i.rotationY=t.scene.environment.rotationY,this.scene.environmentIntensity=t.scene.environment.intensity,(a=t.options)!=null&&a.renderingPipelineConfiguration?this.renderingPipeline.setConfiguration(t.options.renderingPipelineConfiguration):(this.scene.imageProcessingConfiguration.exposure=t.lighting.exposure,this.scene.imageProcessingConfiguration.contrast=t.lighting.contrast),this.glowLayerManager.setIntensity(t.emissiveGlowIntensity),this.camera.updateConfiguration(t),this.camera.setPanEnabled(((n=t.options)==null?void 0:n.noPan)!==void 0?!t.options.noPan:!0),this.configuration=t}reattachControls(e,t=2){if(this.scene.detachControl(),this.engine.inputElement=e,this.camera){this.camera.attachControl(!0,!1,t);const i=this.camera.inputs.attached.pointers;i.multiTouchPanning=!1}this.scene.attachControl(!0,!0,!0)}}d.MaterialEffectMode=L,d.ProductCameraRig=E,d.REFLECTION_PROBE_RESOLUTION=Y,d.RenderingConfiguration=x,d.SpiffCommerce3DPreviewService=Je,d.renderingPipelineDefaults=u,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED