@spiffcommerce/preview 5.8.3-0 → 5.8.4-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +95 -97
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { ArcRotateCamera as fe } from "@babylonjs/core/Cameras/arcRotateCamera";
|
|
2
2
|
import { Engine as be } from "@babylonjs/core/Engines/engine";
|
|
3
3
|
import { NullEngine as Ce } from "@babylonjs/core/Engines/nullEngine";
|
|
4
|
-
import { HighlightLayer as
|
|
4
|
+
import { HighlightLayer as Ae } from "@babylonjs/core/Layers/highlightLayer";
|
|
5
5
|
import { SceneLoader as D } from "@babylonjs/core/Loading/sceneLoader";
|
|
6
6
|
import { CubeTexture as ne } from "@babylonjs/core/Materials/Textures/cubeTexture";
|
|
7
|
-
import { Color4 as
|
|
8
|
-
import { Vector3 as p, Quaternion as
|
|
9
|
-
import { DracoCompression as
|
|
10
|
-
import { Observable as
|
|
11
|
-
import { Tools as
|
|
12
|
-
import { Scene as
|
|
7
|
+
import { Color4 as b, Color3 as C } from "@babylonjs/core/Maths/math.color";
|
|
8
|
+
import { Vector3 as p, Quaternion as x, Vector2 as se, Matrix as re } from "@babylonjs/core/Maths/math.vector";
|
|
9
|
+
import { DracoCompression as xe } from "@babylonjs/core/Meshes/Compression/dracoCompression";
|
|
10
|
+
import { Observable as A } from "@babylonjs/core/Misc/observable";
|
|
11
|
+
import { Tools as Me } from "@babylonjs/core/Misc/tools";
|
|
12
|
+
import { Scene as ye } from "@babylonjs/core/scene";
|
|
13
13
|
import { GLTF2 as Pe } from "@babylonjs/loaders/glTF";
|
|
14
14
|
import { GLTFLoaderAnimationStartMode as Re } from "@babylonjs/loaders/glTF/glTFFileLoader";
|
|
15
15
|
import { PBRMaterial as k } from "@babylonjs/core/Materials/PBR/pbrMaterial";
|
|
@@ -25,10 +25,10 @@ import { DynamicTexture as Be } from "@babylonjs/core/Materials/Textures/dynamic
|
|
|
25
25
|
import { Texture as De } from "@babylonjs/core/Materials/Textures/texture";
|
|
26
26
|
import { Animation as w } from "@babylonjs/core/Animations/animation";
|
|
27
27
|
import { QuadraticEase as ke, EasingFunction as Ne } from "@babylonjs/core/Animations/easing";
|
|
28
|
-
import { AssetsManager as
|
|
28
|
+
import { AssetsManager as qe } from "@babylonjs/core/Misc/assetsManager";
|
|
29
29
|
import { ColorCurves as le } from "@babylonjs/core/Materials/colorCurves";
|
|
30
30
|
import { ImageProcessingConfiguration as R } from "@babylonjs/core/Materials/imageProcessingConfiguration";
|
|
31
|
-
import { DefaultRenderingPipeline as
|
|
31
|
+
import { DefaultRenderingPipeline as ze } from "@babylonjs/core/PostProcesses/RenderPipeline";
|
|
32
32
|
import { DepthOfFieldEffectBlurLevel as O } from "@babylonjs/core/PostProcesses/depthOfFieldEffect";
|
|
33
33
|
import "@babylonjs/core/Rendering/depthRendererSceneComponent";
|
|
34
34
|
import "@babylonjs/core/Engines/Extensions/engine.views";
|
|
@@ -41,6 +41,10 @@ import "@babylonjs/core/Misc/screenshotTools";
|
|
|
41
41
|
import "@babylonjs/core/Rendering/boundingBoxRenderer";
|
|
42
42
|
import "@babylonjs/loaders/glTF/2.0/Extensions";
|
|
43
43
|
var S = /* @__PURE__ */ ((s) => (s[s.Orbit = 0] = "Orbit", s[s.Pan = 1] = "Pan", s))(S || {}), B = /* @__PURE__ */ ((s) => (s.None = "None", s.RemoveWhenSelected = "RemoveWhenSelected", s.ApplyWhenSelected = "ApplyWhenSelected", s))(B || {});
|
|
44
|
+
function Ve() {
|
|
45
|
+
const s = navigator.vendor.toLowerCase().includes("apple"), e = navigator.maxTouchPoints > 0, t = !navigator.userAgent.toLowerCase().includes("crios");
|
|
46
|
+
return s && e && t;
|
|
47
|
+
}
|
|
44
48
|
const he = /* @__PURE__ */ new Map();
|
|
45
49
|
async function N(s, e, t) {
|
|
46
50
|
const i = await he.get(s);
|
|
@@ -52,7 +56,7 @@ async function N(s, e, t) {
|
|
|
52
56
|
e,
|
|
53
57
|
t
|
|
54
58
|
);
|
|
55
|
-
return he.set(s, r), r;
|
|
59
|
+
return !Ve() && he.set(s, r), r;
|
|
56
60
|
}
|
|
57
61
|
D.OnPluginActivatedObservable.add((s) => {
|
|
58
62
|
s.name === "gltf" && (s.animationStartMode = Re.NONE);
|
|
@@ -63,22 +67,22 @@ class ce {
|
|
|
63
67
|
var i, r, n, o;
|
|
64
68
|
const t = (i = this.customOptions) != null && i.transparentBackground || (r = this.customOptions) != null && r.backgroundImage ? 0 : 1;
|
|
65
69
|
if (this.customOptions && ((n = this.customOptions) != null && n.transparentBackground) || (o = this.customOptions) != null && o.backgroundImage)
|
|
66
|
-
return new
|
|
70
|
+
return new b(0, 0, 0, t).toLinearSpace();
|
|
67
71
|
if (this.customOptions && this.customOptions.backgroundColor) {
|
|
68
72
|
const a = C.FromHexString(
|
|
69
73
|
this.customOptions.backgroundColor
|
|
70
74
|
);
|
|
71
|
-
return new
|
|
75
|
+
return new b(
|
|
72
76
|
a.r,
|
|
73
77
|
a.g,
|
|
74
78
|
a.b,
|
|
75
79
|
t
|
|
76
80
|
).toLinearSpace();
|
|
77
81
|
}
|
|
78
|
-
return new
|
|
79
|
-
}, this.highlightColorFromConfig = () => this.customOptions && this.customOptions.highlightColor ? this.hexToColor4(this.customOptions.highlightColor) : new
|
|
82
|
+
return new b(0.98, 0.98, 0.98, t).toLinearSpace();
|
|
83
|
+
}, this.highlightColorFromConfig = () => this.customOptions && this.customOptions.highlightColor ? this.hexToColor4(this.customOptions.highlightColor) : new b(0.98, 0.98, 0.98, 1).toLinearSpace(), this.hexToColor4 = (t, i = 1) => {
|
|
80
84
|
const r = C.FromHexString(t);
|
|
81
|
-
return new
|
|
85
|
+
return new b(
|
|
82
86
|
r.r,
|
|
83
87
|
r.g,
|
|
84
88
|
r.b,
|
|
@@ -157,12 +161,12 @@ class ce {
|
|
|
157
161
|
return ((e = this.customOptions) == null ? void 0 : e.emissiveGlowIntensity) ?? 0.5;
|
|
158
162
|
}
|
|
159
163
|
}
|
|
160
|
-
class
|
|
164
|
+
class y {
|
|
161
165
|
/**
|
|
162
166
|
* Returns the resolution expected for generated textures.
|
|
163
167
|
*/
|
|
164
168
|
static getDynamicTextureResolution(e = !1) {
|
|
165
|
-
return e ? { width: 1, height: 1 } : this.getIsMobile() || !
|
|
169
|
+
return e ? { width: 1, height: 1 } : this.getIsMobile() || !y.offscreenRenderingSupported() ? {
|
|
166
170
|
width: 1024,
|
|
167
171
|
height: 1024
|
|
168
172
|
} : {
|
|
@@ -198,7 +202,7 @@ class M {
|
|
|
198
202
|
}
|
|
199
203
|
}
|
|
200
204
|
}
|
|
201
|
-
const
|
|
205
|
+
const _e = 128, d = {
|
|
202
206
|
antiAliasing: {
|
|
203
207
|
samples: 4,
|
|
204
208
|
fxaaEnabled: !1
|
|
@@ -255,7 +259,7 @@ const Ve = 128, d = {
|
|
|
255
259
|
weight: 1
|
|
256
260
|
}
|
|
257
261
|
};
|
|
258
|
-
class
|
|
262
|
+
class Ge {
|
|
259
263
|
constructor(e) {
|
|
260
264
|
this.name = "glbPostProcessor", this.enabled = !0, this.loader = e;
|
|
261
265
|
}
|
|
@@ -346,7 +350,7 @@ class _e {
|
|
|
346
350
|
return;
|
|
347
351
|
const h = new Ee(
|
|
348
352
|
"mirror",
|
|
349
|
-
|
|
353
|
+
y.getMirrorTextureResolution(),
|
|
350
354
|
e,
|
|
351
355
|
!0
|
|
352
356
|
);
|
|
@@ -369,7 +373,7 @@ class _e {
|
|
|
369
373
|
function r(n) {
|
|
370
374
|
const o = n.material, a = new Le(
|
|
371
375
|
"probe-" + o.name,
|
|
372
|
-
|
|
376
|
+
_e,
|
|
373
377
|
e
|
|
374
378
|
);
|
|
375
379
|
a.cubeTexture.name = "reflection-probe-cube-texture", a.attachToMesh(n), a.renderList && a.renderList.push(...t(e)), o.reflectionTexture = a.cubeTexture;
|
|
@@ -380,7 +384,7 @@ class _e {
|
|
|
380
384
|
});
|
|
381
385
|
}
|
|
382
386
|
}
|
|
383
|
-
class
|
|
387
|
+
class He {
|
|
384
388
|
constructor(e, t) {
|
|
385
389
|
this.scene = e, this.intensity = t, this.meshCount = 0;
|
|
386
390
|
}
|
|
@@ -402,9 +406,9 @@ class Ge {
|
|
|
402
406
|
}
|
|
403
407
|
}
|
|
404
408
|
}
|
|
405
|
-
function
|
|
409
|
+
function Ue(s, e, t, i, r = "") {
|
|
406
410
|
t.forEach((n) => {
|
|
407
|
-
const o = n.getID(), a = n.getName(), h = n.getPanelSize && n.getPanelSize(), l =
|
|
411
|
+
const o = n.getID(), a = n.getName(), h = n.getPanelSize && n.getPanelSize(), l = y.getDynamicTextureResolution(
|
|
408
412
|
(h == null ? void 0 : h.width) === 1 || (h == null ? void 0 : h.height) === 1
|
|
409
413
|
);
|
|
410
414
|
s.filter((u) => u.name === r + a).forEach((u) => {
|
|
@@ -412,7 +416,7 @@ function He(s, e, t, i, r = "") {
|
|
|
412
416
|
if (m)
|
|
413
417
|
de(u, m), m.update(f);
|
|
414
418
|
else {
|
|
415
|
-
const g =
|
|
419
|
+
const g = Ke(
|
|
416
420
|
a,
|
|
417
421
|
e,
|
|
418
422
|
l.width,
|
|
@@ -427,12 +431,12 @@ function He(s, e, t, i, r = "") {
|
|
|
427
431
|
});
|
|
428
432
|
});
|
|
429
433
|
}
|
|
430
|
-
function
|
|
434
|
+
function Ke(s, e, t, i) {
|
|
431
435
|
const r = new Be(
|
|
432
436
|
s,
|
|
433
437
|
{ width: t, height: i },
|
|
434
438
|
e,
|
|
435
|
-
|
|
439
|
+
y.shouldMipMap(),
|
|
436
440
|
De.TRILINEAR_SAMPLINGMODE,
|
|
437
441
|
be.TEXTUREFORMAT_RGBA
|
|
438
442
|
), n = r.getContext();
|
|
@@ -447,11 +451,11 @@ function de(s, e) {
|
|
|
447
451
|
i && (e.wrapU = i.wrapU, e.wrapV = i.wrapV), t.diffuseTexture = e;
|
|
448
452
|
}
|
|
449
453
|
}
|
|
450
|
-
function
|
|
454
|
+
function We() {
|
|
451
455
|
const s = () => Math.floor((1 + Math.random()) * 65536).toString(16).substring(1);
|
|
452
456
|
return s() + s() + "-" + s() + "-" + s() + "-" + s() + "-" + s() + s() + s();
|
|
453
457
|
}
|
|
454
|
-
const
|
|
458
|
+
const M = 60, ue = 1;
|
|
455
459
|
function me(s) {
|
|
456
460
|
return s.targetedAnimations.map((t) => t.animation.framePerSecond).reduce((t, i) => t + i, 0) / s.targetedAnimations.length || 0;
|
|
457
461
|
}
|
|
@@ -483,9 +487,9 @@ function ve(s, e, t, i, r, n) {
|
|
|
483
487
|
l(c, e, ue, m, f);
|
|
484
488
|
});
|
|
485
489
|
}
|
|
486
|
-
function
|
|
490
|
+
function Ye(s, e, t) {
|
|
487
491
|
return new Promise((i) => {
|
|
488
|
-
s.stopAnimation(e), e.animations = [], Math.abs(e.alpha) > 2 * Math.PI && (e.alpha =
|
|
492
|
+
s.stopAnimation(e), e.animations = [], Math.abs(e.alpha) > 2 * Math.PI && (e.alpha = Qe(e.alpha, 0, 2 * Math.PI));
|
|
489
493
|
const r = [], n = t.target, o = 0, a = n ? 1 : 0;
|
|
490
494
|
if (t.target && Object.keys(t.target).length > 0 && r.push(
|
|
491
495
|
E(
|
|
@@ -536,7 +540,7 @@ function We(s, e, t) {
|
|
|
536
540
|
e.disableAutoRotationBehavior(), s.beginAnimation(
|
|
537
541
|
e,
|
|
538
542
|
0,
|
|
539
|
-
n ?
|
|
543
|
+
n ? M * 2 : M,
|
|
540
544
|
!1,
|
|
541
545
|
1,
|
|
542
546
|
() => {
|
|
@@ -554,24 +558,24 @@ function E(s, e, t, i, r, n = 0, o = w.ANIMATIONLOOPMODE_CONSTANT) {
|
|
|
554
558
|
const h = new w(
|
|
555
559
|
s,
|
|
556
560
|
e,
|
|
557
|
-
|
|
561
|
+
M,
|
|
558
562
|
r,
|
|
559
563
|
o
|
|
560
564
|
), l = [];
|
|
561
|
-
return n > 0 && l.push({ frame: 0, value: t }), l.push({ frame:
|
|
562
|
-
frame:
|
|
565
|
+
return n > 0 && l.push({ frame: 0, value: t }), l.push({ frame: M * n, value: t }), l.push({
|
|
566
|
+
frame: M * (n + 1),
|
|
563
567
|
value: i
|
|
564
568
|
}), h.setKeys(l), h.setEasingFunction(a), h;
|
|
565
569
|
}
|
|
566
|
-
function
|
|
570
|
+
function Qe(s, e, t) {
|
|
567
571
|
return s < e ? s = t - (e - s) % (t - e) : s = e + (s - e) % (t - e);
|
|
568
572
|
}
|
|
569
|
-
function
|
|
573
|
+
function Ze(s, e, t) {
|
|
570
574
|
s.forEach((i) => {
|
|
571
575
|
t && i.name !== t || i.goToFrame(e);
|
|
572
576
|
});
|
|
573
577
|
}
|
|
574
|
-
const
|
|
578
|
+
const $e = {
|
|
575
579
|
albedoTexture: "albedoMap",
|
|
576
580
|
bumpTexture: "normalMap",
|
|
577
581
|
ambientTexture: "ambientMap",
|
|
@@ -581,7 +585,7 @@ const Ze = {
|
|
|
581
585
|
refractionTexture: "refractionMap",
|
|
582
586
|
reflectionTexture: "reflectionMap"
|
|
583
587
|
};
|
|
584
|
-
function
|
|
588
|
+
function je(s, e, t, i) {
|
|
585
589
|
[
|
|
586
590
|
"albedoTexture",
|
|
587
591
|
"bumpTexture",
|
|
@@ -592,17 +596,17 @@ function $e(s, e, t, i) {
|
|
|
592
596
|
"refractionTexture",
|
|
593
597
|
"reflectionTexture"
|
|
594
598
|
].forEach((n) => {
|
|
595
|
-
|
|
599
|
+
Xe(
|
|
596
600
|
n,
|
|
597
601
|
s,
|
|
598
602
|
e,
|
|
599
603
|
t,
|
|
600
604
|
i
|
|
601
605
|
);
|
|
602
|
-
}),
|
|
606
|
+
}), tt(s, e);
|
|
603
607
|
}
|
|
604
|
-
function
|
|
605
|
-
const n =
|
|
608
|
+
function Xe(s, e, t, i, r) {
|
|
609
|
+
const n = $e[s];
|
|
606
610
|
if (!n)
|
|
607
611
|
throw new Error("Unexpected texture name encountered.");
|
|
608
612
|
const o = e[n], a = o == null ? void 0 : o.fileLink;
|
|
@@ -620,22 +624,22 @@ function je(s, e, t, i, r) {
|
|
|
620
624
|
!1,
|
|
621
625
|
!0,
|
|
622
626
|
!1
|
|
623
|
-
) : i.addTextureTask(s, a, !1, !1) : i.addTextureTask(s, a, !1, !1) : r && t[s] && (t[s] && t[s].dispose(), t[s] = null,
|
|
627
|
+
) : i.addTextureTask(s, a, !1, !1) : i.addTextureTask(s, a, !1, !1) : r && t[s] && (t[s] && t[s].dispose(), t[s] = null, Je(s, t));
|
|
624
628
|
}
|
|
625
|
-
function
|
|
629
|
+
function Je(s, e) {
|
|
626
630
|
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 C(0, 0, 0), e.reflectionTexture);
|
|
627
631
|
}
|
|
628
|
-
function
|
|
632
|
+
function et(s, e, t, i) {
|
|
629
633
|
if (!e) {
|
|
630
634
|
console.error("Failed to apply texture to material: material is null.");
|
|
631
635
|
return;
|
|
632
636
|
}
|
|
633
637
|
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 C(1, 1, 1), e.emissiveIntensity = 1);
|
|
634
638
|
}
|
|
635
|
-
function
|
|
639
|
+
function tt(s, e) {
|
|
636
640
|
s.clearCoat && (s.clearCoat === B.RemoveWhenSelected ? (e.clearCoat.isEnabled = !1, e.clearCoat.indexOfRefraction = 1.5) : s.clearCoat === B.ApplyWhenSelected && (e.clearCoat.isEnabled = !0, e.clearCoat.indexOfRefraction = s.clearCoatIOR || e.clearCoat.indexOfRefraction));
|
|
637
641
|
}
|
|
638
|
-
class
|
|
642
|
+
class it {
|
|
639
643
|
constructor(e, t, i) {
|
|
640
644
|
this.materialVariantMap = /* @__PURE__ */ new Map(), this.keysThatRemovedBaseModel = [], this.loadedContainerForKey = /* @__PURE__ */ new Map(), this.loadedMaterialsForKey = /* @__PURE__ */ new Map(), this.scene = e, this.renameClonedAsset = t, this.setBaseModelEnabled = i;
|
|
641
645
|
}
|
|
@@ -662,9 +666,9 @@ class tt {
|
|
|
662
666
|
n();
|
|
663
667
|
return;
|
|
664
668
|
}
|
|
665
|
-
const l = new
|
|
669
|
+
const l = new qe(this.scene);
|
|
666
670
|
l.useDefaultLoadingScreen = !1, h.forEach(
|
|
667
|
-
(c) =>
|
|
671
|
+
(c) => je(
|
|
668
672
|
t,
|
|
669
673
|
c,
|
|
670
674
|
l,
|
|
@@ -678,7 +682,7 @@ class tt {
|
|
|
678
682
|
i && i(100, 100, u.name), this.scene.materials.filter(
|
|
679
683
|
(g) => g.name === a
|
|
680
684
|
).forEach((g) => {
|
|
681
|
-
|
|
685
|
+
et(
|
|
682
686
|
u.name,
|
|
683
687
|
g,
|
|
684
688
|
t,
|
|
@@ -709,33 +713,27 @@ class tt {
|
|
|
709
713
|
this.renameClonedAsset,
|
|
710
714
|
!0
|
|
711
715
|
);
|
|
712
|
-
if (this.loadedContainerForKey.has(e)) {
|
|
713
|
-
const g = this.
|
|
714
|
-
g.rootNodes.slice(0).forEach((b) => {
|
|
715
|
-
b.dispose(!1, !0);
|
|
716
|
-
}), g.dispose(), this.loadedContainerForKey.delete(e), (f = this.loadedMaterialsForKey.get(e)) == null || f.forEach((b) => b.dispose()), this.loadedMaterialsForKey.delete(e);
|
|
717
|
-
}
|
|
718
|
-
if (n) {
|
|
719
|
-
const g = o && o(), b = n.name ? this.renameClonedAsset(n.name) : void 0;
|
|
716
|
+
if (this.loadedContainerForKey.has(e) && (this.loadedContainerForKey.get(e).dispose(), this.loadedContainerForKey.delete(e), (f = this.loadedMaterialsForKey.get(e)) == null || f.forEach((g) => g.dispose()), this.loadedMaterialsForKey.delete(e)), n) {
|
|
717
|
+
const g = o && o(), v = n.name ? this.renameClonedAsset(n.name) : void 0;
|
|
720
718
|
if (ve(
|
|
721
719
|
l.animationGroups,
|
|
722
720
|
n.loop,
|
|
723
721
|
n.to,
|
|
724
722
|
n.from,
|
|
725
|
-
|
|
723
|
+
v
|
|
726
724
|
), g != null) {
|
|
727
725
|
const P = a && a() || !0;
|
|
728
|
-
|
|
726
|
+
Ze(
|
|
729
727
|
l.animationGroups,
|
|
730
728
|
g + (P ? 2 : 0),
|
|
731
|
-
|
|
729
|
+
v
|
|
732
730
|
);
|
|
733
731
|
}
|
|
734
732
|
}
|
|
735
733
|
t && await this.setBaseModelEnabled(!1), this.loadedContainerForKey.set(e, l), this.loadedMaterialsForKey.set(e, we(l));
|
|
736
734
|
const c = [];
|
|
737
|
-
return this.materialVariantMap.forEach(async (g,
|
|
738
|
-
c.push(this.applyMaterial(
|
|
735
|
+
return this.materialVariantMap.forEach(async (g, v) => {
|
|
736
|
+
c.push(this.applyMaterial(v, g));
|
|
739
737
|
}), await Promise.all(c), l;
|
|
740
738
|
}
|
|
741
739
|
dispose() {
|
|
@@ -777,9 +775,9 @@ function pe(s, e = "") {
|
|
|
777
775
|
from: t.from
|
|
778
776
|
}));
|
|
779
777
|
}
|
|
780
|
-
class
|
|
778
|
+
class nt {
|
|
781
779
|
constructor(e) {
|
|
782
|
-
this.metadata = /* @__PURE__ */ new Map(), this.materialSelectedObservable = new
|
|
780
|
+
this.metadata = /* @__PURE__ */ new Map(), this.materialSelectedObservable = new A(), this.materialDeselectedObservable = new A(), this.materialVariantObservable = new A(), this.modelVariantObservable = new A(), this.materialReadyToLoadCallbacks = /* @__PURE__ */ new Map(), this.modelReadyToLoadCallbacks = /* @__PURE__ */ new Map(), this.dynamicTextures = /* @__PURE__ */ new Map(), this.queuedMaterialChanges = /* @__PURE__ */ new Map(), this.materialChangesInProgress = [], this.queuedModelChanges = /* @__PURE__ */ new Map(), this.modelChangesInProgress = [], this.isExecutingAnimation = !1, this.animations = [], this.initialized = !1, this.materials = [];
|
|
783
781
|
const {
|
|
784
782
|
enablePicking: t,
|
|
785
783
|
modelDetails: i,
|
|
@@ -787,7 +785,7 @@ class it {
|
|
|
787
785
|
progressHandler: n,
|
|
788
786
|
scene: o
|
|
789
787
|
} = e;
|
|
790
|
-
this.enablePicking = t, this.contextService = i.contextService, this.id =
|
|
788
|
+
this.enablePicking = t, this.contextService = i.contextService, this.id = We(), this.previewService = r, this.scene = o, this.variantManager = new it(
|
|
791
789
|
o,
|
|
792
790
|
this.renameClonedAsset.bind(this),
|
|
793
791
|
this.setBaseModelEnabled.bind(this)
|
|
@@ -903,7 +901,7 @@ class it {
|
|
|
903
901
|
key: e
|
|
904
902
|
});
|
|
905
903
|
},
|
|
906
|
-
this.
|
|
904
|
+
this.lastRequestedAnimation,
|
|
907
905
|
this.getCurrentAnimationFrame.bind(this),
|
|
908
906
|
this.getAnimationIsPlaying.bind(this)
|
|
909
907
|
);
|
|
@@ -932,12 +930,12 @@ class it {
|
|
|
932
930
|
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);
|
|
933
931
|
}
|
|
934
932
|
executeAnimation(e) {
|
|
935
|
-
if (!this.initialized)
|
|
933
|
+
if (this.lastRequestedAnimation = e, !this.initialized)
|
|
936
934
|
return this.queuedModelAnimation = e, Promise.resolve();
|
|
937
935
|
let t = () => {
|
|
938
936
|
};
|
|
939
937
|
const i = async () => {
|
|
940
|
-
this.
|
|
938
|
+
this.isExecutingAnimation = !0, await new Promise((r) => {
|
|
941
939
|
var o;
|
|
942
940
|
const n = [
|
|
943
941
|
...((o = this.modelInstance) == null ? void 0 : o.animationGroups) || [],
|
|
@@ -1010,7 +1008,7 @@ class it {
|
|
|
1010
1008
|
set rotation(e) {
|
|
1011
1009
|
if (!this.transformRoot)
|
|
1012
1010
|
throw new Error("ModelContainer disposed prior to setting rotation!");
|
|
1013
|
-
this.transformRoot.rotationQuaternion =
|
|
1011
|
+
this.transformRoot.rotationQuaternion = x.FromEulerAngles(
|
|
1014
1012
|
e.x,
|
|
1015
1013
|
e.y,
|
|
1016
1014
|
e.z
|
|
@@ -1078,13 +1076,13 @@ class it {
|
|
|
1078
1076
|
"Transform disposed! This should never happen unless there is a race condition present!"
|
|
1079
1077
|
);
|
|
1080
1078
|
const t = this.transformRoot.position, i = this.transformRoot.rotationQuaternion, r = this.transformRoot.scaling;
|
|
1081
|
-
this.transformRoot.position = p.Zero(), this.transformRoot.rotationQuaternion =
|
|
1079
|
+
this.transformRoot.position = p.Zero(), this.transformRoot.rotationQuaternion = x.Identity(), this.transformRoot.scaling = p.One();
|
|
1082
1080
|
for (const o of e.rootNodes) {
|
|
1083
1081
|
o.parent = this.transformRoot;
|
|
1084
1082
|
for (const a of o.getChildMeshes(!1))
|
|
1085
1083
|
a.alwaysSelectAsActiveMesh = !0;
|
|
1086
1084
|
}
|
|
1087
|
-
this.transformRoot.position = t, this.transformRoot.rotationQuaternion = i, this.transformRoot.scaling = r, this.canvasPanels = ((n = this.contextService) == null ? void 0 : n.getAll()) || /* @__PURE__ */ new Map(),
|
|
1085
|
+
this.transformRoot.position = t, this.transformRoot.rotationQuaternion = i, this.transformRoot.scaling = r, this.canvasPanels = ((n = this.contextService) == null ? void 0 : n.getAll()) || /* @__PURE__ */ new Map(), Ue(
|
|
1088
1086
|
this.materials.concat(this.variantManager.getAllMaterials()),
|
|
1089
1087
|
this.scene,
|
|
1090
1088
|
this.canvasPanels,
|
|
@@ -1187,7 +1185,7 @@ class it {
|
|
|
1187
1185
|
}
|
|
1188
1186
|
//#endregion
|
|
1189
1187
|
}
|
|
1190
|
-
class
|
|
1188
|
+
class q extends fe {
|
|
1191
1189
|
constructor(e, t, i, r, n, o, a, h) {
|
|
1192
1190
|
super(
|
|
1193
1191
|
e,
|
|
@@ -1289,7 +1287,7 @@ class z extends fe {
|
|
|
1289
1287
|
*/
|
|
1290
1288
|
static create(e, t, i) {
|
|
1291
1289
|
var h;
|
|
1292
|
-
const r = L(e), n = r.max.subtract(r.min), o = r.min.add(n.scale(0.5)), a = new
|
|
1290
|
+
const r = L(e), n = r.max.subtract(r.min), o = r.min.add(n.scale(0.5)), a = new q(
|
|
1293
1291
|
"ProductCamera",
|
|
1294
1292
|
-(Math.PI / 2),
|
|
1295
1293
|
Math.PI / 2,
|
|
@@ -1314,9 +1312,9 @@ function L(s) {
|
|
|
1314
1312
|
const e = s.meshes.filter((t) => t.name.toLowerCase().endsWith("_t") || t.name.toLowerCase().includes("_t_"));
|
|
1315
1313
|
return s.getWorldExtends((t) => t.isVisible && t.isEnabled() && (e.length === 0 || e.includes(t)));
|
|
1316
1314
|
}
|
|
1317
|
-
class
|
|
1315
|
+
class st {
|
|
1318
1316
|
constructor(e, t = !1, i = void 0) {
|
|
1319
|
-
this.renderingPipeline = new
|
|
1317
|
+
this.renderingPipeline = new ze(
|
|
1320
1318
|
"default",
|
|
1321
1319
|
t,
|
|
1322
1320
|
e,
|
|
@@ -1332,7 +1330,7 @@ class nt {
|
|
|
1332
1330
|
return this.currentConfiguration;
|
|
1333
1331
|
}
|
|
1334
1332
|
setConfiguration(e) {
|
|
1335
|
-
var t, i, r, n, o, a, h, l, c, u, m, f, g,
|
|
1333
|
+
var t, i, r, n, o, a, h, l, c, u, m, f, g, v, P, z, V, _, G, H, U, K, W, Y, Q, Z, $, j, X, J, ee, te, ie;
|
|
1336
1334
|
if (this.renderingPipeline.isSupported) {
|
|
1337
1335
|
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 = ((r = e.bloom) == null ? void 0 : r.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 = ((a = e.bloom) == null ? void 0 : a.threshold) ?? d.bloom.threshold, this.renderingPipeline.bloomWeight = ((h = e.bloom) == null ? void 0 : h.weight) ?? d.bloom.weight, this.renderingPipeline.chromaticAberrationEnabled = ((l = e.chromaticAberration) == null ? void 0 : l.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(
|
|
1338
1336
|
e.chromaticAberration.direction.x,
|
|
@@ -1352,7 +1350,7 @@ class nt {
|
|
|
1352
1350
|
this.renderingPipeline.depthOfFieldBlurLevel = O.High;
|
|
1353
1351
|
break;
|
|
1354
1352
|
}
|
|
1355
|
-
if (this.renderingPipeline.depthOfField.focalLength = ((
|
|
1353
|
+
if (this.renderingPipeline.depthOfField.focalLength = ((v = e.depthOfField) == null ? void 0 : v.focalLength) ?? d.depthOfField.focalLength, this.renderingPipeline.depthOfField.fStop = ((P = e.depthOfField) == null ? void 0 : P.fStop) ?? d.depthOfField.fStop, this.renderingPipeline.depthOfField.focusDistance = ((z = e.depthOfField) == null ? void 0 : z.focusDistance) ?? d.depthOfField.focusDistance, this.renderingPipeline.depthOfField.lensSize = ((V = e.depthOfField) == null ? void 0 : V.lensSize) ?? d.depthOfField.lensSize, this.renderingPipeline.grainEnabled = ((_ = e.grain) == null ? void 0 : _.enabled) ?? d.grain.enabled, this.renderingPipeline.grain.animated = ((G = e.grain) == null ? void 0 : G.animated) ?? d.grain.animated, this.renderingPipeline.grain.intensity = ((H = e.grain) == null ? void 0 : H.intensity) ?? d.grain.intensity, this.renderingPipeline.imageProcessing.contrast = ((U = e.misc) == null ? void 0 : U.contrast) ?? d.misc.contrast, this.renderingPipeline.imageProcessing.exposure = ((K = e.misc) == null ? void 0 : K.exposure) ?? d.misc.exposure, this.renderingPipeline.imageProcessing.toneMappingEnabled = ((W = e.misc) == null ? void 0 : W.toneMappingEnabled) ?? d.misc.toneMappingEnabled, this.renderingPipeline.imageProcessing.toneMappingEnabled)
|
|
1356
1354
|
switch (e.misc.toneMappingType ?? d.misc.toneMappingType) {
|
|
1357
1355
|
case "Standard":
|
|
1358
1356
|
this.renderingPipeline.imageProcessing.toneMappingType = R.TONEMAPPING_STANDARD;
|
|
@@ -1370,12 +1368,12 @@ class nt {
|
|
|
1370
1368
|
this.renderingPipeline.imageProcessing.vignetteBlendMode = R.VIGNETTEMODE_OPAQUE;
|
|
1371
1369
|
break;
|
|
1372
1370
|
}
|
|
1373
|
-
(J = e.vignette) != null && J.colorRgba ? this.renderingPipeline.imageProcessing.vignetteColor = new
|
|
1371
|
+
(J = e.vignette) != null && J.colorRgba ? this.renderingPipeline.imageProcessing.vignetteColor = new b(
|
|
1374
1372
|
e.vignette.colorRgba.r,
|
|
1375
1373
|
e.vignette.colorRgba.g,
|
|
1376
1374
|
e.vignette.colorRgba.b,
|
|
1377
1375
|
e.vignette.colorRgba.a
|
|
1378
|
-
) : (ee = e.vignette) != null && ee.colorHex ? this.renderingPipeline.imageProcessing.vignetteColor =
|
|
1376
|
+
) : (ee = e.vignette) != null && ee.colorHex ? this.renderingPipeline.imageProcessing.vignetteColor = b.FromHexString(e.vignette.colorHex) : this.renderingPipeline.imageProcessing.vignetteColor = new b(
|
|
1379
1377
|
d.vignette.colorRgba.r,
|
|
1380
1378
|
d.vignette.colorRgba.g,
|
|
1381
1379
|
d.vignette.colorRgba.b,
|
|
@@ -1389,7 +1387,7 @@ class nt {
|
|
|
1389
1387
|
}
|
|
1390
1388
|
}
|
|
1391
1389
|
Pe.GLTFLoader.RegisterExtension("glbPostProcessor", function(s) {
|
|
1392
|
-
return new
|
|
1390
|
+
return new Ge(s);
|
|
1393
1391
|
});
|
|
1394
1392
|
D.OnPluginActivatedObservable.add((s) => {
|
|
1395
1393
|
if (s.name === "gltf") {
|
|
@@ -1403,10 +1401,10 @@ function I(s) {
|
|
|
1403
1401
|
function F(s) {
|
|
1404
1402
|
return { x: s.x, y: s.y, z: s.z };
|
|
1405
1403
|
}
|
|
1406
|
-
class
|
|
1404
|
+
class Yt {
|
|
1407
1405
|
constructor(e) {
|
|
1408
1406
|
var h;
|
|
1409
|
-
this.focusLostNotified = !1, this.focusLostObservable = new
|
|
1407
|
+
this.focusLostNotified = !1, this.focusLostObservable = new A(), this.modelLoadEventCallbacks = [], this.modelContainers = /* @__PURE__ */ new Map(), this.plugins = [], this.initComplete = !1, this.isAnimatingCamera = !1, this.renderLoop = () => {
|
|
1410
1408
|
if (!this.engine.views)
|
|
1411
1409
|
return;
|
|
1412
1410
|
this.modelContainers.forEach((u) => {
|
|
@@ -1431,7 +1429,7 @@ class Wt {
|
|
|
1431
1429
|
if (!(e != null && e.noRender))
|
|
1432
1430
|
return this.configuration.createCanvas();
|
|
1433
1431
|
})(), r = "1.5.6";
|
|
1434
|
-
|
|
1432
|
+
xe.Configuration = {
|
|
1435
1433
|
decoder: {
|
|
1436
1434
|
wasmUrl: `https://www.gstatic.com/draco/versioned/decoders/${r}/draco_wasm_wrapper_gltf.js`,
|
|
1437
1435
|
wasmBinaryUrl: `https://www.gstatic.com/draco/versioned/decoders/${r}/draco_decoder_gltf.wasm`,
|
|
@@ -1450,7 +1448,7 @@ class Wt {
|
|
|
1450
1448
|
stencil: this.configuration.highlights.enabled,
|
|
1451
1449
|
forceSRGBBufferSupportState: !0
|
|
1452
1450
|
}) : new Ce();
|
|
1453
|
-
o.enableOfflineSupport = !1, o.doNotHandleContextLost = !0, console.log = n, o.hideLoadingUI(), window.addEventListener("resize", this.fireResizeEvent.bind(this)), this.engine = o, this.scene = new
|
|
1451
|
+
o.enableOfflineSupport = !1, o.doNotHandleContextLost = !0, console.log = n, o.hideLoadingUI(), window.addEventListener("resize", this.fireResizeEvent.bind(this)), this.engine = o, this.scene = new ye(o), this.camera = q.create(this.scene, this.configuration), this.scene.activeCamera = this.camera, this.renderingPipeline = new st(
|
|
1454
1452
|
this.scene,
|
|
1455
1453
|
!1,
|
|
1456
1454
|
this.camera
|
|
@@ -1461,7 +1459,7 @@ class Wt {
|
|
|
1461
1459
|
);
|
|
1462
1460
|
a.name = "initial-environment-cube", a.rotationY = this.configuration.scene.environment.rotationY, this.scene.environmentTexture = a, this.scene.environmentIntensity = this.configuration.scene.environment.intensity, (h = this.configuration.options) != null && h.renderingPipelineConfiguration ? this.renderingPipeline.setConfiguration(
|
|
1463
1461
|
this.configuration.options.renderingPipelineConfiguration
|
|
1464
|
-
) : (this.scene.imageProcessingConfiguration.exposure = this.configuration.lighting.exposure, this.scene.imageProcessingConfiguration.contrast = this.configuration.lighting.contrast), this.glowLayerManager = new
|
|
1462
|
+
) : (this.scene.imageProcessingConfiguration.exposure = this.configuration.lighting.exposure, this.scene.imageProcessingConfiguration.contrast = this.configuration.lighting.contrast), this.glowLayerManager = new He(
|
|
1465
1463
|
this.scene,
|
|
1466
1464
|
this.configuration.emissiveGlowIntensity
|
|
1467
1465
|
), this.initPromise = new Promise((l) => {
|
|
@@ -1516,7 +1514,7 @@ class Wt {
|
|
|
1516
1514
|
let t = () => {
|
|
1517
1515
|
};
|
|
1518
1516
|
const i = async () => {
|
|
1519
|
-
this.isAnimatingCamera = !0, await
|
|
1517
|
+
this.isAnimatingCamera = !0, await Ye(
|
|
1520
1518
|
this.scene,
|
|
1521
1519
|
this.scene.activeCamera,
|
|
1522
1520
|
e
|
|
@@ -1599,7 +1597,7 @@ class Wt {
|
|
|
1599
1597
|
try {
|
|
1600
1598
|
const r = t.latDeg * Math.PI / 180, n = t.lonDeg * Math.PI / 180;
|
|
1601
1599
|
i.target = t.target ? new p(t.target.x, t.target.y, t.target.z) : p.Zero(), i.alpha = n, i.beta = r, i.radius = t.radius || this.camera.radius, i.minZ = 0.01, this.scene.render();
|
|
1602
|
-
const o = await
|
|
1600
|
+
const o = await Me.CreateScreenshotUsingRenderTargetAsync(
|
|
1603
1601
|
this.engine,
|
|
1604
1602
|
i,
|
|
1605
1603
|
e,
|
|
@@ -1627,7 +1625,7 @@ class Wt {
|
|
|
1627
1625
|
}
|
|
1628
1626
|
setHighlights(e, t) {
|
|
1629
1627
|
var r;
|
|
1630
|
-
e.length === 0 && ((r = this.highlightLayer) == null || r.dispose(), this.highlightLayer = void 0), this.highlightLayer || (this.highlightLayer = new
|
|
1628
|
+
e.length === 0 && ((r = this.highlightLayer) == null || r.dispose(), this.highlightLayer = void 0), this.highlightLayer || (this.highlightLayer = new Ae("highlights", this.scene, {
|
|
1631
1629
|
isStroke: !0,
|
|
1632
1630
|
blurVerticalSize: 0.85,
|
|
1633
1631
|
blurHorizontalSize: 0.85
|
|
@@ -1652,7 +1650,7 @@ class Wt {
|
|
|
1652
1650
|
this.renderingPipeline && this.renderingPipeline.setConfiguration(e);
|
|
1653
1651
|
}
|
|
1654
1652
|
loadModel(e, t) {
|
|
1655
|
-
const { refocusCamera: i = !0, progressHandler: r } = t ?? {}, n = new
|
|
1653
|
+
const { refocusCamera: i = !0, progressHandler: r } = t ?? {}, n = new nt({
|
|
1656
1654
|
enablePicking: this.configuration.highlights.enabled,
|
|
1657
1655
|
modelDetails: e,
|
|
1658
1656
|
scene: this.scene,
|
|
@@ -1715,12 +1713,12 @@ class Wt {
|
|
|
1715
1713
|
flipTransform(e, t, i) {
|
|
1716
1714
|
const r = re.Compose(
|
|
1717
1715
|
I(i || { x: 1, y: 1, z: 1 }),
|
|
1718
|
-
|
|
1716
|
+
x.FromEulerVector(
|
|
1719
1717
|
I(t || { x: 0, y: 0, z: 0 })
|
|
1720
1718
|
),
|
|
1721
1719
|
I(e || { x: 0, y: 0, z: 0 })
|
|
1722
|
-
), n = re.RotationAxis(p.Up(), Math.PI), o = r.multiply(n), a = p.Zero(), h =
|
|
1723
|
-
return o.decompose(l, h, a), h.multiplyInPlace(
|
|
1720
|
+
), n = re.RotationAxis(p.Up(), Math.PI), o = r.multiply(n), a = p.Zero(), h = x.Identity(), l = p.Zero();
|
|
1721
|
+
return o.decompose(l, h, a), h.multiplyInPlace(x.FromEulerAngles(0, Math.PI, 0)), {
|
|
1724
1722
|
position: F(a),
|
|
1725
1723
|
rotation: F(h.toEulerAngles()),
|
|
1726
1724
|
scale: F(l)
|
|
@@ -1757,8 +1755,8 @@ class Wt {
|
|
|
1757
1755
|
export {
|
|
1758
1756
|
B as MaterialEffectMode,
|
|
1759
1757
|
S as ProductCameraRig,
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1758
|
+
_e as REFLECTION_PROBE_RESOLUTION,
|
|
1759
|
+
y as RenderingConfiguration,
|
|
1760
|
+
Yt as SpiffCommerce3DPreviewService,
|
|
1763
1761
|
d as renderingPipelineDefaults
|
|
1764
1762
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(c,y){typeof exports=="object"&&typeof module<"u"?y(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"],y):(c=typeof globalThis<"u"?globalThis:c||self,y(c.Preview={},c.arcRotateCamera,c.engine,c.nullEngine,c.highlightLayer,c.sceneLoader,c.cubeTexture,c.math_color,c.math_vector,c.dracoCompression,c.observable,c.tools,c.scene,c.glTF,c.glTFFileLoader,c.pbrMaterial,c.mirrorTexture,c.math,c.reflectionProbe,c.glowLayer,c.actionManager,c.directActions,c.mesh,c.transformNode,c.dynamicTexture,c.texture,c.animation,c.easing,c.assetsManager,c.colorCurves,c.imageProcessingConfiguration,c.RenderPipeline,c.depthOfFieldEffect))})(this,function(c,y,k,Ce,ye,F,z,v,p,we,x,Me,xe,Pe,Ae,I,Te,A,Re,Ee,S,G,Le,Oe,Fe,Ie,w,H,Se,U,T,Be,B){"use strict";var R=(s=>(s[s.Orbit=0]="Orbit",s[s.Pan=1]="Pan",s))(R||{}),E=(s=>(s.None="None",s.RemoveWhenSelected="RemoveWhenSelected",s.ApplyWhenSelected="ApplyWhenSelected",s))(E||{});const K=new Map;async function j(s,e,t){const i=await K.get(s);if(i&&i.scene.uid===e.uid)return i;const r=F.SceneLoader.LoadAssetContainerAsync(s,void 0,e,t);return K.set(s,r),r}F.SceneLoader.OnPluginActivatedObservable.add(s=>{s.name==="gltf"&&(s.animationStartMode=Ae.GLTFLoaderAnimationStartMode.NONE)});class W{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,h,l,u,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:(h=this.customOptions)==null?void 0:h.minZoomOverride},max:{alpha:(l=this.customOptions)!=null&&l.upperAlphaLimitDeg?((u=this.customOptions)==null?void 0:u.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 M{static getDynamicTextureResolution(e=!1){return e?{width:1,height:1}:this.getIsMobile()||!M.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 Q=128,d={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 I.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 A.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 h=new Te.MirrorTexture("mirror",M.getMirrorTextureResolution(),e,!0);h.renderList=t(e);const l=n.getVerticesData("normal");if(!l)throw new Error("Mirror attribute specified on: "+n.name+"But no normals exist to generate a mirror from!");n.computeWorldMatrix(!0);const u=n.getWorldMatrix(),g=A.Vector3.TransformNormal(new A.Vector3(l[0],l[1],l[2]),u).normalize(),m=A.Plane.FromPositionAndNormal(n.position,g.scale(-1));h.mirrorPlane=m,h.level=o,a.reflectionTexture=h}function r(n){const o=n.material,a=new Re.ReflectionProbe("probe-"+o.name,Q,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 qe{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 De(s,e,t,i,r=""){t.forEach(n=>{const o=n.getID(),a=n.getName(),h=n.getPanelSize&&n.getPanelSize(),l=M.getDynamicTextureResolution((h==null?void 0:h.width)===1||(h==null?void 0:h.height)===1);s.filter(g=>g.name===r+a).forEach(g=>{const m=i.get(o),b=!1;if(m)Y(g,m),m.update(b);else{const f=Ve(a,e,l.width,l.height);i.set(o,f),n.setStaticContext(f.getContext()),Y(g,f),f.onLoadObservable.addOnce(()=>{f.update(b)})}})})}function Ve(s,e,t,i){const r=new Fe.DynamicTexture(s,{width:t,height:i},e,M.shouldMipMap(),Ie.Texture.TRILINEAR_SAMPLINGMODE,k.Engine.TEXTUREFORMAT_RGBA),n=r.getContext();return n&&(n.fillStyle="#f5f5f5",n.fillRect(0,0,t,i),r.update()),r}function Y(s,e){if(s instanceof I.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 Ne(){const s=()=>Math.floor((1+Math.random())*65536).toString(16).substring(1);return s()+s()+"-"+s()+"-"+s()+"-"+s()+"-"+s()+s()+s()}const P=60,Z=1;function $(s){return s.targetedAnimations.map(t=>t.animation.framePerSecond).reduce((t,i)=>t+i,0)/s.targetedAnimations.length||0}function _(s,e,t,i,r,n){const o=r?s.filter(u=>u.name===r):s;if(o.length===0){console.warn(`No animations found for name: ${r}`);return}let a=0;const h=()=>{a++,a===o.length&&n&&n()},l=(u,g,m,b,f)=>{u.stop(),u.start(g,m,b,f),n&&(g==!1||g===void 0&&!u.loopAnimation?u.onAnimationGroupEndObservable.addOnce(()=>{h()}):u.onAnimationLoopObservable.addOnce(()=>{h()}))};if(i!==void 0&&t!==void 0&&i===t){o.forEach(u=>{const g=$(u),m=i*g;l(u,!1,Z,m,m)});return}o.forEach(u=>{const g=$(u),m=i!==void 0?i*g:void 0,b=t!==void 0?t*g:void 0;l(u,e,Z,m,b)})}function ke(s,e,t){return new Promise(i=>{s.stopAnimation(e),e.animations=[],Math.abs(e.alpha)>2*Math.PI&&(e.alpha=ze(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(L("cameraTargetLerp","target",new p.Vector3().copyFrom(e.target),new p.Vector3(t.target.x,t.target.y,t.target.z),w.Animation.ANIMATIONTYPE_VECTOR3,o)),r.push(L("cameraAlphaLerp","alpha",e.alpha,X(t.lonDeg),w.Animation.ANIMATIONTYPE_FLOAT,a)),r.push(L("cameraBetaLerp","beta",e.beta,X(t.latDeg),w.Animation.ANIMATIONTYPE_FLOAT,a)),t.radius!==void 0){const u=Math.max(.01,t.radius);r.push(L("cameraRadiusLerp","radius",e.radius,u,w.Animation.ANIMATIONTYPE_FLOAT,a))}e.animations.push(...r);const l=e.useAutoRotationBehavior;e.disableAutoRotationBehavior(),s.beginAnimation(e,0,n?P*2:P,!1,1,()=>{e.animations=[],l&&e.enableAutoRotationBehavior(),i()})})}function X(s){return s*Math.PI/180}function L(s,e,t,i,r,n=0,o=w.Animation.ANIMATIONLOOPMODE_CONSTANT){const a=new H.QuadraticEase;a.setEasingMode(H.EasingFunction.EASINGMODE_EASEINOUT);const h=new w.Animation(s,e,P,r,o),l=[];return n>0&&l.push({frame:0,value:t}),l.push({frame:P*n,value:t}),l.push({frame:P*(n+1),value:i}),h.setKeys(l),h.setEasingFunction(a),h}function ze(s,e,t){return s<e?s=t-(e-s)%(t-e):s=e+(s-e)%(t-e)}function Ge(s,e,t){s.forEach(i=>{t&&i.name!==t||i.goToFrame(e)})}const He={albedoTexture:"albedoMap",bumpTexture:"normalMap",ambientTexture:"ambientMap",emissiveTexture:"emissionMap",opacityTexture:"alphaMap",metallicTexture:"metallicMap",refractionTexture:"refractionMap",reflectionTexture:"reflectionMap"};function Ue(s,e,t,i){["albedoTexture","bumpTexture","ambientTexture","emissiveTexture","opacityTexture","metallicTexture","refractionTexture","reflectionTexture"].forEach(n=>{Ke(n,s,e,t,i)}),Ye(s,e)}function Ke(s,e,t,i,r){const n=He[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,We(s,t))}function We(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 Qe(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 Ye(s,e){s.clearCoat&&(s.clearCoat===E.RemoveWhenSelected?(e.clearCoat.isEnabled=!1,e.clearCoat.indexOfRefraction=1.5):s.clearCoat===E.ApplyWhenSelected&&(e.clearCoat.isEnabled=!0,e.clearCoat.indexOfRefraction=s.clearCoatIOR||e.clearCoat.indexOfRefraction))}class Ze{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),h=this.scene.materials.filter(u=>u.name===a);if(h.length===0){n();return}const l=new Se.AssetsManager(this.scene);l.useDefaultLoadingScreen=!1,h.forEach(u=>Ue(t,u,l,r)),l.onProgress=(u,g,m)=>{i&&i(u/g*100,100,m.name)},l.onFinish=u=>{u.forEach(g=>{const m=g;i&&i(100,100,g.name),this.scene.materials.filter(f=>f.name===a).forEach(f=>{Qe(g.name,f,t,m.texture)})}),n()},l.loadAsync()})}async applyModel(e,t,i,r,n,o,a){var g,m,b;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),(g=this.loadedContainerForKey.get(e))==null||g.dispose(),this.loadedContainerForKey.delete(e),(m=this.loadedMaterialsForKey.get(e))==null||m.forEach(f=>f.dispose()),this.loadedMaterialsForKey.delete(e),this.keysThatRemovedBaseModel=this.keysThatRemovedBaseModel.filter(f=>f!==e),Promise.resolve(void 0);const l=(await j(i,this.scene,r)).instantiateModelsToScene(this.renameClonedAsset,!0);if(this.loadedContainerForKey.has(e)){const f=this.loadedContainerForKey.get(e);f.rootNodes.slice(0).forEach(C=>{C.dispose(!1,!0)}),f.dispose(),this.loadedContainerForKey.delete(e),(b=this.loadedMaterialsForKey.get(e))==null||b.forEach(C=>C.dispose()),this.loadedMaterialsForKey.delete(e)}if(n){const f=o&&o(),C=n.name?this.renameClonedAsset(n.name):void 0;if(_(l.animationGroups,n.loop,n.to,n.from,C),f!=null){const O=a&&a()||!0;Ge(l.animationGroups,f+(O?2:0),C)}}t&&await this.setBaseModelEnabled(!1),this.loadedContainerForKey.set(e,l),this.loadedMaterialsForKey.set(e,J(l));const u=[];return this.materialVariantMap.forEach(async(f,C)=>{u.push(this.applyMaterial(C,f))}),await Promise.all(u),l}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 J(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 ee(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 x.Observable,this.materialDeselectedObservable=new x.Observable,this.materialVariantObservable=new x.Observable,this.modelVariantObservable=new x.Observable,this.materialReadyToLoadCallbacks=new Map,this.modelReadyToLoadCallbacks=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=Ne(),this.previewService=r,this.scene=o,this.variantManager=new Ze(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,h)=>{this.materialVariantObservable.notifyObservers({remainingCount:o,totalCount:a,taskName:h})},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){if(!this.initialized){this.modelReadyToLoadCallbacks.set(e,this.applyModelVariant.bind(this,e,t,i));return}const r=()=>this.variantManager.applyModel(e,i,t==null?void 0:t.model,a=>{this.modelVariantObservable.notifyObservers({...a,key:e})},this.lastPlayedAnimation,this.getCurrentAnimationFrame.bind(this),this.getAnimationIsPlaying.bind(this));if(this.modelChangesInProgress.includes(e)){this.queuedModelChanges.set(e,r);return}const o=await(async()=>{this.modelChangesInProgress.push(e);let a=await r();if(this.queuedModelChanges.has(e)){const h=this.queuedModelChanges.get(e);if(!h)throw new Error("Queued change resolved undefined");a=await h(),this.queuedModelChanges.delete(e)}return this.modelChangesInProgress.splice(this.modelChangesInProgress.indexOf(e),1),a})();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.initialized)return this.queuedModelAnimation=e,Promise.resolve();let t=()=>{};const i=async()=>{this.lastPlayedAnimation=e,this.isExecutingAnimation=!0,await new Promise(r=>{var o;const n=[...((o=this.modelInstance)==null?void 0:o.animationGroups)||[],...this.variantManager.getAnimationGroups()];_(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?ee(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 S.ActionManager(this.scene)),i.actionManager.registerAction(new G.ExecuteCodeAction(S.ActionManager.OnPointerOverTrigger,r=>{r.meshUnderPointer&&i.material&&this.materialSelectedObservable.notifyObservers({id:i.material.id,name:this.stripIdFromName(i.material.name)})})),i.actionManager.registerAction(new G.ExecuteCodeAction(S.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.modelReadyToLoadCallbacks.size}configureGlowLayer(){const e=i=>i instanceof I.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,De(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=J(this.modelInstance),this.configureModelInstance(this.modelInstance),this.animations=ee(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)}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.modelReadyToLoadCallbacks.values()).map(e=>e())),this.modelReadyToLoadCallbacks.clear(),this.scene.onAfterRenderObservable.addOnce(()=>{this.queuedModelAnimation&&(this.executeAnimation(this.queuedModelAnimation),this.queuedModelAnimation=void 0)})}}class q extends y.ArcRotateCamera{constructor(e,t,i,r,n,o,a,h){super(e,t,i,r,n,o,h),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=D(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=D(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 h;const r=D(e),n=r.max.subtract(r.min),o=r.min.add(n.scale(.5)),a=new q("ProductCamera",-(Math.PI/2),Math.PI/2,n.length()*1.5,o,e,t);return a.setPanEnabled(((h=t.options)==null?void 0:h.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 D(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 _e{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(d))}dispose(){this.renderingPipeline.dispose()}getConfiguration(){return this.currentConfiguration}setConfiguration(e){var t,i,r,n,o,a,h,l,u,g,m,b,f,C,O,te,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)??d.antiAliasing.samples,this.renderingPipeline.fxaaEnabled=((i=e.antiAliasing)==null?void 0:i.fxaaEnabled)??d.antiAliasing.fxaaEnabled,this.renderingPipeline.bloomEnabled=((r=e.bloom)==null?void 0:r.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=((a=e.bloom)==null?void 0:a.threshold)??d.bloom.threshold,this.renderingPipeline.bloomWeight=((h=e.bloom)==null?void 0:h.weight)??d.bloom.weight,this.renderingPipeline.chromaticAberrationEnabled=((l=e.chromaticAberration)==null?void 0:l.enabled)??d.chromaticAberration.enabled,this.renderingPipeline.chromaticAberration.aberrationAmount=((u=e.chromaticAberration)==null?void 0:u.aberrationAmount)??d.chromaticAberration.aberrationAmount,this.renderingPipeline.chromaticAberration.radialIntensity=((g=e.chromaticAberration)==null?void 0:g.radialIntensity)??d.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(d.chromaticAberration.direction.x,d.chromaticAberration.direction.y),this.renderingPipeline.imageProcessing.colorCurvesEnabled=((b=e.colorCurves)==null?void 0:b.enabled)??d.colorCurves.enabled,this.renderingPipeline.imageProcessing.colorCurves=e.colorCurves?this.updateColorCurve(e.colorCurves):new U.ColorCurves,this.renderingPipeline.depthOfFieldEnabled=((f=e.depthOfField)==null?void 0:f.enabled)??d.depthOfField.enabled,e.depthOfField)switch(e.depthOfField.blurLevel??d.depthOfField.blurLevel){case"Low":this.renderingPipeline.depthOfFieldBlurLevel=B.DepthOfFieldEffectBlurLevel.Low;break;case"Medium":this.renderingPipeline.depthOfFieldBlurLevel=B.DepthOfFieldEffectBlurLevel.Medium;break;case"High":this.renderingPipeline.depthOfFieldBlurLevel=B.DepthOfFieldEffectBlurLevel.High;break}if(this.renderingPipeline.depthOfField.focalLength=((C=e.depthOfField)==null?void 0:C.focalLength)??d.depthOfField.focalLength,this.renderingPipeline.depthOfField.fStop=((O=e.depthOfField)==null?void 0:O.fStop)??d.depthOfField.fStop,this.renderingPipeline.depthOfField.focusDistance=((te=e.depthOfField)==null?void 0:te.focusDistance)??d.depthOfField.focusDistance,this.renderingPipeline.depthOfField.lensSize=((ie=e.depthOfField)==null?void 0:ie.lensSize)??d.depthOfField.lensSize,this.renderingPipeline.grainEnabled=((ne=e.grain)==null?void 0:ne.enabled)??d.grain.enabled,this.renderingPipeline.grain.animated=((se=e.grain)==null?void 0:se.animated)??d.grain.animated,this.renderingPipeline.grain.intensity=((re=e.grain)==null?void 0:re.intensity)??d.grain.intensity,this.renderingPipeline.imageProcessing.contrast=((ae=e.misc)==null?void 0:ae.contrast)??d.misc.contrast,this.renderingPipeline.imageProcessing.exposure=((oe=e.misc)==null?void 0:oe.exposure)??d.misc.exposure,this.renderingPipeline.imageProcessing.toneMappingEnabled=((le=e.misc)==null?void 0:le.toneMappingEnabled)??d.misc.toneMappingEnabled,this.renderingPipeline.imageProcessing.toneMappingEnabled)switch(e.misc.toneMappingType??d.misc.toneMappingType){case"Standard":this.renderingPipeline.imageProcessing.toneMappingType=T.ImageProcessingConfiguration.TONEMAPPING_STANDARD;break;case"ACES":this.renderingPipeline.imageProcessing.toneMappingType=T.ImageProcessingConfiguration.TONEMAPPING_ACES;break}if(this.renderingPipeline.sharpenEnabled=((he=e.sharpen)==null?void 0:he.enabled)??d.sharpen.enabled,this.renderingPipeline.sharpen.colorAmount=((ce=e.sharpen)==null?void 0:ce.colorAmount)??d.sharpen.colorAmount,this.renderingPipeline.sharpen.edgeAmount=((de=e.sharpen)==null?void 0:de.edgeAmount)??d.sharpen.edgeAmount,this.renderingPipeline.imageProcessing.vignetteEnabled=((ue=e.vignette)==null?void 0:ue.enabled)??d.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=d.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=d.vignette.center.y),e.vignette)switch(((me=e.vignette)==null?void 0:me.blendMode)??d.vignette.blendMode){case"Multiply":this.renderingPipeline.imageProcessing.vignetteBlendMode=T.ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY;break;case"Opaque":this.renderingPipeline.imageProcessing.vignetteBlendMode=T.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(d.vignette.colorRgba.r,d.vignette.colorRgba.g,d.vignette.colorRgba.b,d.vignette.colorRgba.a),this.renderingPipeline.imageProcessing.vignetteStretch=((be=e.vignette)==null?void 0:be.stretch)??d.vignette.stretch,this.renderingPipeline.imageProcessing.vignetteWeight=((ve=e.vignette)==null?void 0:ve.weight)??d.vignette.weight,this.renderingPipeline.prepare(),this.currentConfiguration=e}}updateColorCurve(e){const t=new U.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}}Pe.GLTF2.GLTFLoader.RegisterExtension("glbPostProcessor",function(s){return new je(s)}),F.SceneLoader.OnPluginActivatedObservable.add(s=>{if(s.name==="gltf"){const e=s;e.transparencyAsCoverage=!0}});function V(s){return new p.Vector3(s.x,s.y,s.z)}function N(s){return{x:s.x,y:s.y,z:s.z}}class Xe{constructor(e){var h;this.focusLostNotified=!1,this.focusLostObservable=new x.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 l=this.engine.getRenderingCanvas();if(l)if(l.getContext("webgl2")??l.getContext("webgl")){const g=this.configuration.scene.clearColor,m=l.getContext("webgl2")??l.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 l.getContext("2d")?l.getContext("2d").clearRect(0,0,l.width,l.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 u=Math.max((this.camera.lowerRadiusLimit??1)*.01,.001);!this.camera.isRunningFramingBehavior&&!this.camera.target.equalsWithEpsilon(this.camera.lastFocus,u)&&!this.focusLostNotified&&(this.focusLostObservable.notifyObservers(void 0),this.focusLostNotified=!0),this.screenshotPrepareResolve&&(this.screenshotPrepareResolve(),this.screenshotPrepareResolve=void 0)},this.configuration=new W(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 k.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=q.create(this.scene,this.configuration),this.scene.activeCamera=this.camera,this.renderingPipeline=new _e(this.scene,!1,this.camera),this.scene.clearColor=this.configuration.scene.clearColor;const a=z.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,(h=this.configuration.options)!=null&&h.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 qe(this.scene,this.configuration.emissiveGlowIntensity),this.initPromise=new Promise(l=>{this.scene.onReadyObservable.addOnce(()=>{this.initComplete=!0,l()})}),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(R.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 ke(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===R.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 y.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],h=o.every(u=>u===t),l=a.every(u=>u===r);return!h&&!l}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 h;return(h=this.highlightLayer)==null?void 0:h.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(V(i||{x:1,y:1,z:1}),p.Quaternion.FromEulerVector(V(t||{x:0,y:0,z:0})),V(e||{x:0,y:0,z:0})),n=p.Matrix.RotationAxis(p.Vector3.Up(),Math.PI),o=r.multiply(n),a=p.Vector3.Zero(),h=p.Quaternion.Identity(),l=p.Vector3.Zero();return o.decompose(l,h,a),h.multiplyInPlace(p.Quaternion.FromEulerAngles(0,Math.PI,0)),{position:N(a),rotation:N(h.toEulerAngles()),scale:N(l)}}updatePreviewOptions(e){var r,n;const t=new W(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=z.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)}}c.MaterialEffectMode=E,c.ProductCameraRig=R,c.REFLECTION_PROBE_RESOLUTION=Q,c.RenderingConfiguration=M,c.SpiffCommerce3DPreviewService=Xe,c.renderingPipelineDefaults=d,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(c,y){typeof exports=="object"&&typeof module<"u"?y(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"],y):(c=typeof globalThis<"u"?globalThis:c||self,y(c.Preview={},c.arcRotateCamera,c.engine,c.nullEngine,c.highlightLayer,c.sceneLoader,c.cubeTexture,c.math_color,c.math_vector,c.dracoCompression,c.observable,c.tools,c.scene,c.glTF,c.glTFFileLoader,c.pbrMaterial,c.mirrorTexture,c.math,c.reflectionProbe,c.glowLayer,c.actionManager,c.directActions,c.mesh,c.transformNode,c.dynamicTexture,c.texture,c.animation,c.easing,c.assetsManager,c.colorCurves,c.imageProcessingConfiguration,c.RenderPipeline,c.depthOfFieldEffect))})(this,function(c,y,N,Ce,ye,F,z,v,p,we,x,Me,xe,Ae,Pe,I,Te,P,Re,Ee,S,G,Le,Oe,Fe,Ie,w,H,Se,U,T,Be,B){"use strict";var R=(s=>(s[s.Orbit=0]="Orbit",s[s.Pan=1]="Pan",s))(R||{}),E=(s=>(s.None="None",s.RemoveWhenSelected="RemoveWhenSelected",s.ApplyWhenSelected="ApplyWhenSelected",s))(E||{});function je(){const s=navigator.vendor.toLowerCase().includes("apple"),e=navigator.maxTouchPoints>0,t=!navigator.userAgent.toLowerCase().includes("crios");return s&&e&&t}const K=new Map;async function j(s,e,t){const i=await K.get(s);if(i&&i.scene.uid===e.uid)return i;const r=F.SceneLoader.LoadAssetContainerAsync(s,void 0,e,t);return!je()&&K.set(s,r),r}F.SceneLoader.OnPluginActivatedObservable.add(s=>{s.name==="gltf"&&(s.animationStartMode=Pe.GLTFLoaderAnimationStartMode.NONE)});class W{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,h,l,u,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:(h=this.customOptions)==null?void 0:h.minZoomOverride},max:{alpha:(l=this.customOptions)!=null&&l.upperAlphaLimitDeg?((u=this.customOptions)==null?void 0:u.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 M{static getDynamicTextureResolution(e=!1){return e?{width:1,height:1}:this.getIsMobile()||!M.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 Q=128,d={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 qe{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 I.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 P.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 h=new Te.MirrorTexture("mirror",M.getMirrorTextureResolution(),e,!0);h.renderList=t(e);const l=n.getVerticesData("normal");if(!l)throw new Error("Mirror attribute specified on: "+n.name+"But no normals exist to generate a mirror from!");n.computeWorldMatrix(!0);const u=n.getWorldMatrix(),g=P.Vector3.TransformNormal(new P.Vector3(l[0],l[1],l[2]),u).normalize(),m=P.Plane.FromPositionAndNormal(n.position,g.scale(-1));h.mirrorPlane=m,h.level=o,a.reflectionTexture=h}function r(n){const o=n.material,a=new Re.ReflectionProbe("probe-"+o.name,Q,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(),h=n.getPanelSize&&n.getPanelSize(),l=M.getDynamicTextureResolution((h==null?void 0:h.width)===1||(h==null?void 0:h.height)===1);s.filter(g=>g.name===r+a).forEach(g=>{const m=i.get(o),b=!1;if(m)Y(g,m),m.update(b);else{const f=ke(a,e,l.width,l.height);i.set(o,f),n.setStaticContext(f.getContext()),Y(g,f),f.onLoadObservable.addOnce(()=>{f.update(b)})}})})}function ke(s,e,t,i){const r=new Fe.DynamicTexture(s,{width:t,height:i},e,M.shouldMipMap(),Ie.Texture.TRILINEAR_SAMPLINGMODE,N.Engine.TEXTUREFORMAT_RGBA),n=r.getContext();return n&&(n.fillStyle="#f5f5f5",n.fillRect(0,0,t,i),r.update()),r}function Y(s,e){if(s instanceof I.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 Ne(){const s=()=>Math.floor((1+Math.random())*65536).toString(16).substring(1);return s()+s()+"-"+s()+"-"+s()+"-"+s()+"-"+s()+s()+s()}const A=60,Z=1;function $(s){return s.targetedAnimations.map(t=>t.animation.framePerSecond).reduce((t,i)=>t+i,0)/s.targetedAnimations.length||0}function _(s,e,t,i,r,n){const o=r?s.filter(u=>u.name===r):s;if(o.length===0){console.warn(`No animations found for name: ${r}`);return}let a=0;const h=()=>{a++,a===o.length&&n&&n()},l=(u,g,m,b,f)=>{u.stop(),u.start(g,m,b,f),n&&(g==!1||g===void 0&&!u.loopAnimation?u.onAnimationGroupEndObservable.addOnce(()=>{h()}):u.onAnimationLoopObservable.addOnce(()=>{h()}))};if(i!==void 0&&t!==void 0&&i===t){o.forEach(u=>{const g=$(u),m=i*g;l(u,!1,Z,m,m)});return}o.forEach(u=>{const g=$(u),m=i!==void 0?i*g:void 0,b=t!==void 0?t*g:void 0;l(u,e,Z,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(L("cameraTargetLerp","target",new p.Vector3().copyFrom(e.target),new p.Vector3(t.target.x,t.target.y,t.target.z),w.Animation.ANIMATIONTYPE_VECTOR3,o)),r.push(L("cameraAlphaLerp","alpha",e.alpha,X(t.lonDeg),w.Animation.ANIMATIONTYPE_FLOAT,a)),r.push(L("cameraBetaLerp","beta",e.beta,X(t.latDeg),w.Animation.ANIMATIONTYPE_FLOAT,a)),t.radius!==void 0){const u=Math.max(.01,t.radius);r.push(L("cameraRadiusLerp","radius",e.radius,u,w.Animation.ANIMATIONTYPE_FLOAT,a))}e.animations.push(...r);const l=e.useAutoRotationBehavior;e.disableAutoRotationBehavior(),s.beginAnimation(e,0,n?A*2:A,!1,1,()=>{e.animations=[],l&&e.enableAutoRotationBehavior(),i()})})}function X(s){return s*Math.PI/180}function L(s,e,t,i,r,n=0,o=w.Animation.ANIMATIONLOOPMODE_CONSTANT){const a=new H.QuadraticEase;a.setEasingMode(H.EasingFunction.EASINGMODE_EASEINOUT);const h=new w.Animation(s,e,A,r,o),l=[];return n>0&&l.push({frame:0,value:t}),l.push({frame:A*n,value:t}),l.push({frame:A*(n+1),value:i}),h.setKeys(l),h.setEasingFunction(a),h}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===E.RemoveWhenSelected?(e.clearCoat.isEnabled=!1,e.clearCoat.indexOfRefraction=1.5):s.clearCoat===E.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),h=this.scene.materials.filter(u=>u.name===a);if(h.length===0){n();return}const l=new Se.AssetsManager(this.scene);l.useDefaultLoadingScreen=!1,h.forEach(u=>Ke(t,u,l,r)),l.onProgress=(u,g,m)=>{i&&i(u/g*100,100,m.name)},l.onFinish=u=>{u.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()},l.loadAsync()})}async applyModel(e,t,i,r,n,o,a){var g,m,b;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),(g=this.loadedContainerForKey.get(e))==null||g.dispose(),this.loadedContainerForKey.delete(e),(m=this.loadedMaterialsForKey.get(e))==null||m.forEach(f=>f.dispose()),this.loadedMaterialsForKey.delete(e),this.keysThatRemovedBaseModel=this.keysThatRemovedBaseModel.filter(f=>f!==e),Promise.resolve(void 0);const l=(await j(i,this.scene,r)).instantiateModelsToScene(this.renameClonedAsset,!0);if(this.loadedContainerForKey.has(e)&&(this.loadedContainerForKey.get(e).dispose(),this.loadedContainerForKey.delete(e),(b=this.loadedMaterialsForKey.get(e))==null||b.forEach(f=>f.dispose()),this.loadedMaterialsForKey.delete(e)),n){const f=o&&o(),C=n.name?this.renameClonedAsset(n.name):void 0;if(_(l.animationGroups,n.loop,n.to,n.from,C),f!=null){const O=a&&a()||!0;He(l.animationGroups,f+(O?2:0),C)}}t&&await this.setBaseModelEnabled(!1),this.loadedContainerForKey.set(e,l),this.loadedMaterialsForKey.set(e,J(l));const u=[];return this.materialVariantMap.forEach(async(f,C)=>{u.push(this.applyMaterial(C,f))}),await Promise.all(u),l}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 J(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 ee(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 x.Observable,this.materialDeselectedObservable=new x.Observable,this.materialVariantObservable=new x.Observable,this.modelVariantObservable=new x.Observable,this.materialReadyToLoadCallbacks=new Map,this.modelReadyToLoadCallbacks=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=Ne(),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,h)=>{this.materialVariantObservable.notifyObservers({remainingCount:o,totalCount:a,taskName:h})},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){if(!this.initialized){this.modelReadyToLoadCallbacks.set(e,this.applyModelVariant.bind(this,e,t,i));return}const r=()=>this.variantManager.applyModel(e,i,t==null?void 0:t.model,a=>{this.modelVariantObservable.notifyObservers({...a,key:e})},this.lastRequestedAnimation,this.getCurrentAnimationFrame.bind(this),this.getAnimationIsPlaying.bind(this));if(this.modelChangesInProgress.includes(e)){this.queuedModelChanges.set(e,r);return}const o=await(async()=>{this.modelChangesInProgress.push(e);let a=await r();if(this.queuedModelChanges.has(e)){const h=this.queuedModelChanges.get(e);if(!h)throw new Error("Queued change resolved undefined");a=await h(),this.queuedModelChanges.delete(e)}return this.modelChangesInProgress.splice(this.modelChangesInProgress.indexOf(e),1),a})();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()];_(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?ee(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 S.ActionManager(this.scene)),i.actionManager.registerAction(new G.ExecuteCodeAction(S.ActionManager.OnPointerOverTrigger,r=>{r.meshUnderPointer&&i.material&&this.materialSelectedObservable.notifyObservers({id:i.material.id,name:this.stripIdFromName(i.material.name)})})),i.actionManager.registerAction(new G.ExecuteCodeAction(S.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.modelReadyToLoadCallbacks.size}configureGlowLayer(){const e=i=>i instanceof I.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=J(this.modelInstance),this.configureModelInstance(this.modelInstance),this.animations=ee(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)}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.modelReadyToLoadCallbacks.values()).map(e=>e())),this.modelReadyToLoadCallbacks.clear(),this.scene.onAfterRenderObservable.addOnce(()=>{this.queuedModelAnimation&&(this.executeAnimation(this.queuedModelAnimation),this.queuedModelAnimation=void 0)})}}class q extends y.ArcRotateCamera{constructor(e,t,i,r,n,o,a,h){super(e,t,i,r,n,o,h),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=D(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=D(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 h;const r=D(e),n=r.max.subtract(r.min),o=r.min.add(n.scale(.5)),a=new q("ProductCamera",-(Math.PI/2),Math.PI/2,n.length()*1.5,o,e,t);return a.setPanEnabled(((h=t.options)==null?void 0:h.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 D(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(d))}dispose(){this.renderingPipeline.dispose()}getConfiguration(){return this.currentConfiguration}setConfiguration(e){var t,i,r,n,o,a,h,l,u,g,m,b,f,C,O,te,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)??d.antiAliasing.samples,this.renderingPipeline.fxaaEnabled=((i=e.antiAliasing)==null?void 0:i.fxaaEnabled)??d.antiAliasing.fxaaEnabled,this.renderingPipeline.bloomEnabled=((r=e.bloom)==null?void 0:r.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=((a=e.bloom)==null?void 0:a.threshold)??d.bloom.threshold,this.renderingPipeline.bloomWeight=((h=e.bloom)==null?void 0:h.weight)??d.bloom.weight,this.renderingPipeline.chromaticAberrationEnabled=((l=e.chromaticAberration)==null?void 0:l.enabled)??d.chromaticAberration.enabled,this.renderingPipeline.chromaticAberration.aberrationAmount=((u=e.chromaticAberration)==null?void 0:u.aberrationAmount)??d.chromaticAberration.aberrationAmount,this.renderingPipeline.chromaticAberration.radialIntensity=((g=e.chromaticAberration)==null?void 0:g.radialIntensity)??d.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(d.chromaticAberration.direction.x,d.chromaticAberration.direction.y),this.renderingPipeline.imageProcessing.colorCurvesEnabled=((b=e.colorCurves)==null?void 0:b.enabled)??d.colorCurves.enabled,this.renderingPipeline.imageProcessing.colorCurves=e.colorCurves?this.updateColorCurve(e.colorCurves):new U.ColorCurves,this.renderingPipeline.depthOfFieldEnabled=((f=e.depthOfField)==null?void 0:f.enabled)??d.depthOfField.enabled,e.depthOfField)switch(e.depthOfField.blurLevel??d.depthOfField.blurLevel){case"Low":this.renderingPipeline.depthOfFieldBlurLevel=B.DepthOfFieldEffectBlurLevel.Low;break;case"Medium":this.renderingPipeline.depthOfFieldBlurLevel=B.DepthOfFieldEffectBlurLevel.Medium;break;case"High":this.renderingPipeline.depthOfFieldBlurLevel=B.DepthOfFieldEffectBlurLevel.High;break}if(this.renderingPipeline.depthOfField.focalLength=((C=e.depthOfField)==null?void 0:C.focalLength)??d.depthOfField.focalLength,this.renderingPipeline.depthOfField.fStop=((O=e.depthOfField)==null?void 0:O.fStop)??d.depthOfField.fStop,this.renderingPipeline.depthOfField.focusDistance=((te=e.depthOfField)==null?void 0:te.focusDistance)??d.depthOfField.focusDistance,this.renderingPipeline.depthOfField.lensSize=((ie=e.depthOfField)==null?void 0:ie.lensSize)??d.depthOfField.lensSize,this.renderingPipeline.grainEnabled=((ne=e.grain)==null?void 0:ne.enabled)??d.grain.enabled,this.renderingPipeline.grain.animated=((se=e.grain)==null?void 0:se.animated)??d.grain.animated,this.renderingPipeline.grain.intensity=((re=e.grain)==null?void 0:re.intensity)??d.grain.intensity,this.renderingPipeline.imageProcessing.contrast=((ae=e.misc)==null?void 0:ae.contrast)??d.misc.contrast,this.renderingPipeline.imageProcessing.exposure=((oe=e.misc)==null?void 0:oe.exposure)??d.misc.exposure,this.renderingPipeline.imageProcessing.toneMappingEnabled=((le=e.misc)==null?void 0:le.toneMappingEnabled)??d.misc.toneMappingEnabled,this.renderingPipeline.imageProcessing.toneMappingEnabled)switch(e.misc.toneMappingType??d.misc.toneMappingType){case"Standard":this.renderingPipeline.imageProcessing.toneMappingType=T.ImageProcessingConfiguration.TONEMAPPING_STANDARD;break;case"ACES":this.renderingPipeline.imageProcessing.toneMappingType=T.ImageProcessingConfiguration.TONEMAPPING_ACES;break}if(this.renderingPipeline.sharpenEnabled=((he=e.sharpen)==null?void 0:he.enabled)??d.sharpen.enabled,this.renderingPipeline.sharpen.colorAmount=((ce=e.sharpen)==null?void 0:ce.colorAmount)??d.sharpen.colorAmount,this.renderingPipeline.sharpen.edgeAmount=((de=e.sharpen)==null?void 0:de.edgeAmount)??d.sharpen.edgeAmount,this.renderingPipeline.imageProcessing.vignetteEnabled=((ue=e.vignette)==null?void 0:ue.enabled)??d.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=d.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=d.vignette.center.y),e.vignette)switch(((me=e.vignette)==null?void 0:me.blendMode)??d.vignette.blendMode){case"Multiply":this.renderingPipeline.imageProcessing.vignetteBlendMode=T.ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY;break;case"Opaque":this.renderingPipeline.imageProcessing.vignetteBlendMode=T.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(d.vignette.colorRgba.r,d.vignette.colorRgba.g,d.vignette.colorRgba.b,d.vignette.colorRgba.a),this.renderingPipeline.imageProcessing.vignetteStretch=((be=e.vignette)==null?void 0:be.stretch)??d.vignette.stretch,this.renderingPipeline.imageProcessing.vignetteWeight=((ve=e.vignette)==null?void 0:ve.weight)??d.vignette.weight,this.renderingPipeline.prepare(),this.currentConfiguration=e}}updateColorCurve(e){const t=new U.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 qe(s)}),F.SceneLoader.OnPluginActivatedObservable.add(s=>{if(s.name==="gltf"){const e=s;e.transparencyAsCoverage=!0}});function V(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 h;this.focusLostNotified=!1,this.focusLostObservable=new x.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 l=this.engine.getRenderingCanvas();if(l)if(l.getContext("webgl2")??l.getContext("webgl")){const g=this.configuration.scene.clearColor,m=l.getContext("webgl2")??l.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 l.getContext("2d")?l.getContext("2d").clearRect(0,0,l.width,l.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 u=Math.max((this.camera.lowerRadiusLimit??1)*.01,.001);!this.camera.isRunningFramingBehavior&&!this.camera.target.equalsWithEpsilon(this.camera.lastFocus,u)&&!this.focusLostNotified&&(this.focusLostObservable.notifyObservers(void 0),this.focusLostNotified=!0),this.screenshotPrepareResolve&&(this.screenshotPrepareResolve(),this.screenshotPrepareResolve=void 0)},this.configuration=new W(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 N.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=q.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=z.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,(h=this.configuration.options)!=null&&h.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(l=>{this.scene.onReadyObservable.addOnce(()=>{this.initComplete=!0,l()})}),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(R.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===R.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 y.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],h=o.every(u=>u===t),l=a.every(u=>u===r);return!h&&!l}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 h;return(h=this.highlightLayer)==null?void 0:h.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(V(i||{x:1,y:1,z:1}),p.Quaternion.FromEulerVector(V(t||{x:0,y:0,z:0})),V(e||{x:0,y:0,z:0})),n=p.Matrix.RotationAxis(p.Vector3.Up(),Math.PI),o=r.multiply(n),a=p.Vector3.Zero(),h=p.Quaternion.Identity(),l=p.Vector3.Zero();return o.decompose(l,h,a),h.multiplyInPlace(p.Quaternion.FromEulerAngles(0,Math.PI,0)),{position:k(a),rotation:k(h.toEulerAngles()),scale:k(l)}}updatePreviewOptions(e){var r,n;const t=new W(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=z.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)}}c.MaterialEffectMode=E,c.ProductCameraRig=R,c.REFLECTION_PROBE_RESOLUTION=Q,c.RenderingConfiguration=M,c.SpiffCommerce3DPreviewService=Je,c.renderingPipelineDefaults=d,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED