@spiffcommerce/preview 5.8.7 → 5.8.8-alpha.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 CHANGED
@@ -12,7 +12,7 @@ import { Tools as xe } from "@babylonjs/core/Misc/tools";
12
12
  import { Scene as Me } 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
- import { PBRMaterial as q } from "@babylonjs/core/Materials/PBR/pbrMaterial";
15
+ import { PBRMaterial as N } from "@babylonjs/core/Materials/PBR/pbrMaterial";
16
16
  import { MirrorTexture as Ee } from "@babylonjs/core/Materials/Textures/mirrorTexture";
17
17
  import { Color3 as Te, Vector3 as ae, Plane as Oe } from "@babylonjs/core/Maths/math";
18
18
  import { ReflectionProbe as Le } from "@babylonjs/core/Probes/reflectionProbe";
@@ -24,8 +24,8 @@ import { TransformNode as Se } from "@babylonjs/core/Meshes/transformNode";
24
24
  import { DynamicTexture as Be } from "@babylonjs/core/Materials/Textures/dynamicTexture";
25
25
  import { Texture as De } from "@babylonjs/core/Materials/Textures/texture";
26
26
  import { Animation as C } from "@babylonjs/core/Animations/animation";
27
- import { QuadraticEase as ke, EasingFunction as qe } from "@babylonjs/core/Animations/easing";
28
- import { AssetsManager as Ne } from "@babylonjs/core/Misc/assetsManager";
27
+ import { QuadraticEase as ke, EasingFunction as Ne } from "@babylonjs/core/Animations/easing";
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 E } from "@babylonjs/core/Materials/imageProcessingConfiguration";
31
31
  import { DefaultRenderingPipeline as ze } from "@babylonjs/core/PostProcesses/RenderPipeline";
@@ -40,32 +40,32 @@ import "@babylonjs/core/Animations/animatable";
40
40
  import "@babylonjs/core/Misc/screenshotTools";
41
41
  import "@babylonjs/core/Rendering/boundingBoxRenderer";
42
42
  import "@babylonjs/loaders/glTF/2.0/Extensions";
43
- var B = /* @__PURE__ */ ((s) => (s[s.Orbit = 0] = "Orbit", s[s.Pan = 1] = "Pan", s))(B || {}), D = /* @__PURE__ */ ((s) => (s.None = "None", s.RemoveWhenSelected = "RemoveWhenSelected", s.ApplyWhenSelected = "ApplyWhenSelected", s))(D || {});
43
+ var B = /* @__PURE__ */ ((r) => (r[r.Orbit = 0] = "Orbit", r[r.Pan = 1] = "Pan", r))(B || {}), D = /* @__PURE__ */ ((r) => (r.None = "None", r.RemoveWhenSelected = "RemoveWhenSelected", r.ApplyWhenSelected = "ApplyWhenSelected", r))(D || {});
44
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;
45
+ const r = navigator.vendor.toLowerCase().includes("apple"), e = navigator.maxTouchPoints > 0, t = !navigator.userAgent.toLowerCase().includes("crios");
46
+ return r && e && t;
47
47
  }
48
48
  const he = /* @__PURE__ */ new Map();
49
- async function N(s, e, t) {
50
- const i = await he.get(s);
49
+ async function q(r, e, t) {
50
+ const i = await he.get(r);
51
51
  if (i && i.scene.uid === e.uid)
52
52
  return i;
53
- const r = k.LoadAssetContainerAsync(
54
- s,
53
+ const s = k.LoadAssetContainerAsync(
54
+ r,
55
55
  void 0,
56
56
  e,
57
57
  t
58
58
  );
59
- return !Ve() && he.set(s, r), r;
59
+ return !Ve() && he.set(r, s), s;
60
60
  }
61
- k.OnPluginActivatedObservable.add((s) => {
62
- s.name === "gltf" && (s.animationStartMode = Re.NONE);
61
+ k.OnPluginActivatedObservable.add((r) => {
62
+ r.name === "gltf" && (r.animationStartMode = Re.NONE);
63
63
  });
64
64
  class ce {
65
65
  constructor(e) {
66
66
  this.getSceneClearColor = () => {
67
- var i, r, n, o;
68
- const t = (i = this.customOptions) != null && i.transparentBackground || (r = this.customOptions) != null && r.backgroundImage ? 0 : 1;
67
+ var i, s, n, o;
68
+ const t = (i = this.customOptions) != null && i.transparentBackground || (s = this.customOptions) != null && s.backgroundImage ? 0 : 1;
69
69
  if (this.customOptions && ((n = this.customOptions) != null && n.transparentBackground) || (o = this.customOptions) != null && o.backgroundImage)
70
70
  return new v(0, 0, 0, t).toLinearSpace();
71
71
  if (this.customOptions && this.customOptions.backgroundColor) {
@@ -81,11 +81,11 @@ class ce {
81
81
  }
82
82
  return new v(0.98, 0.98, 0.98, t).toLinearSpace();
83
83
  }, this.highlightColorFromConfig = () => this.customOptions && this.customOptions.highlightColor ? this.hexToColor4(this.customOptions.highlightColor) : new v(0.98, 0.98, 0.98, 1).toLinearSpace(), this.hexToColor4 = (t, i = 1) => {
84
- const r = A.FromHexString(t);
84
+ const s = A.FromHexString(t);
85
85
  return new v(
86
- r.r,
87
- r.g,
88
- r.b,
86
+ s.r,
87
+ s.g,
88
+ s.b,
89
89
  i
90
90
  ).toLinearSpace();
91
91
  }, this.customOptions = e;
@@ -101,13 +101,13 @@ class ce {
101
101
  * Configuration related to the scene
102
102
  */
103
103
  get scene() {
104
- var e, t, i, r, n;
104
+ var e, t, i, s, n;
105
105
  return {
106
106
  clearColor: this.getSceneClearColor(),
107
107
  transparentBackground: ((e = this.customOptions) == null ? void 0 : e.transparentBackground) || ((t = this.customOptions) == null ? void 0 : t.backgroundImage),
108
108
  environment: {
109
109
  file: ((i = this.customOptions) == null ? void 0 : i.environmentFile) ?? "assets/model-viewer/default.env",
110
- intensity: ((r = this.customOptions) == null ? void 0 : r.environmentIntensity) ?? 1,
110
+ intensity: ((s = this.customOptions) == null ? void 0 : s.environmentIntensity) ?? 1,
111
111
  rotationY: (((n = this.customOptions) == null ? void 0 : n.environmentRotationY) ?? 0) * (Math.PI / 180)
112
112
  // Convert to radians
113
113
  }
@@ -117,7 +117,7 @@ class ce {
117
117
  * Configuration related to the camera used to view and interact with the scene.
118
118
  */
119
119
  get camera() {
120
- var e, t, i, r, n, o, a, h, l, c, u, m, f;
120
+ var e, t, i, s, n, o, a, h, l, c, u, m, f;
121
121
  return {
122
122
  autoOrientation: ((e = this.customOptions) == null ? void 0 : e.disableAutomaticOrientation) ?? !0,
123
123
  autoRotation: {
@@ -126,7 +126,7 @@ class ce {
126
126
  },
127
127
  limits: {
128
128
  min: {
129
- alpha: (r = this.customOptions) != null && r.lowerAlphaLimitDeg ? ((n = this.customOptions) == null ? void 0 : n.lowerAlphaLimitDeg) * Math.PI / 180 : void 0,
129
+ alpha: (s = this.customOptions) != null && s.lowerAlphaLimitDeg ? ((n = this.customOptions) == null ? void 0 : n.lowerAlphaLimitDeg) * Math.PI / 180 : void 0,
130
130
  beta: (o = this.customOptions) != null && o.lowerBetaLimitDeg ? ((a = this.customOptions) == null ? void 0 : a.lowerBetaLimitDeg) * Math.PI / 180 : void 0,
131
131
  radius: (h = this.customOptions) == null ? void 0 : h.minZoomOverride
132
132
  },
@@ -150,10 +150,10 @@ class ce {
150
150
  };
151
151
  }
152
152
  get lighting() {
153
- var e, t, i, r;
153
+ var e, t, i, s;
154
154
  return {
155
155
  exposure: ((t = (e = this.customOptions) == null ? void 0 : e.lighting) == null ? void 0 : t.exposure) ?? 0.9,
156
- contrast: ((r = (i = this.customOptions) == null ? void 0 : i.lighting) == null ? void 0 : r.contrast) ?? 1.6
156
+ contrast: ((s = (i = this.customOptions) == null ? void 0 : i.lighting) == null ? void 0 : s.contrast) ?? 1.6
157
157
  };
158
158
  }
159
159
  get emissiveGlowIntensity() {
@@ -274,11 +274,11 @@ class Ge {
274
274
  return this.loader.loadNodeAsync(
275
275
  e,
276
276
  t,
277
- function(r) {
277
+ function(s) {
278
278
  t.extras && Object.keys(t.extras).forEach((n) => {
279
279
  const o = t.extras[n];
280
- r.metadata[n] = o;
281
- }), i(r);
280
+ s.metadata[n] = o;
281
+ }), i(s);
282
282
  }
283
283
  );
284
284
  }
@@ -303,7 +303,7 @@ class Ge {
303
303
  * @param babylonMaterial An instance of a material representation in babylon.
304
304
  */
305
305
  enableMaterialExtrasIfRequired(e, t) {
306
- if (!(!e.extras || !(t instanceof q))) {
306
+ if (!(!e.extras || !(t instanceof N))) {
307
307
  if (e.extras.sheen) {
308
308
  const i = t;
309
309
  i.sheen.isEnabled = !0, i.sheen.intensity = e.extras.sheen;
@@ -370,7 +370,7 @@ class Ge {
370
370
  );
371
371
  h.mirrorPlane = m, h.level = o, a.reflectionTexture = h;
372
372
  }
373
- function r(n) {
373
+ function s(n) {
374
374
  const o = n.material, a = new Le(
375
375
  "probe-" + o.name,
376
376
  _e,
@@ -380,7 +380,7 @@ class Ge {
380
380
  }
381
381
  e.meshes.forEach((n) => {
382
382
  const o = n.metadata;
383
- o && (o.mirrorTexture && i(n, o.mirrorTexture), o.reflectionProbe && r(n));
383
+ o && (o.mirrorTexture && i(n, o.mirrorTexture), o.reflectionProbe && s(n));
384
384
  });
385
385
  }
386
386
  }
@@ -406,12 +406,12 @@ class He {
406
406
  }
407
407
  }
408
408
  }
409
- function Ue(s, e, t, i, r = "") {
409
+ function Ue(r, e, t, i, s = "") {
410
410
  t.forEach((n) => {
411
411
  const o = n.getID(), a = n.getName(), h = n.getPanelSize && n.getPanelSize(), l = P.getDynamicTextureResolution(
412
412
  (h == null ? void 0 : h.width) === 1 || (h == null ? void 0 : h.height) === 1
413
413
  );
414
- s.filter((u) => u.name === r + a).forEach((u) => {
414
+ r.filter((u) => u.name === s + a).forEach((u) => {
415
415
  const m = i.get(o), f = !1;
416
416
  if (m)
417
417
  de(u, m), m.update(f);
@@ -431,38 +431,38 @@ function Ue(s, e, t, i, r = "") {
431
431
  });
432
432
  });
433
433
  }
434
- function Ke(s, e, t, i) {
435
- const r = new Be(
436
- s,
434
+ function Ke(r, e, t, i) {
435
+ const s = new Be(
436
+ r,
437
437
  { width: t, height: i },
438
438
  e,
439
439
  P.shouldMipMap(),
440
440
  De.TRILINEAR_SAMPLINGMODE,
441
441
  be.TEXTUREFORMAT_RGBA
442
- ), n = r.getContext();
443
- return n && (n.fillStyle = "#f5f5f5", n.fillRect(0, 0, t, i), r.update()), r;
442
+ ), n = s.getContext();
443
+ return n && (n.fillStyle = "#f5f5f5", n.fillRect(0, 0, t, i), s.update()), s;
444
444
  }
445
- function de(s, e) {
446
- if (s instanceof q) {
447
- const t = s, i = t.albedoTexture;
445
+ function de(r, e) {
446
+ if (r instanceof N) {
447
+ const t = r, i = t.albedoTexture;
448
448
  i ? (e.wrapU = i.wrapU, e.wrapV = i.wrapV) : (e.wrapU = 1, e.wrapV = 1), t.albedoTexture = e;
449
449
  } else {
450
- const t = s, i = t.diffuseTexture;
450
+ const t = r, i = t.diffuseTexture;
451
451
  i && (e.wrapU = i.wrapU, e.wrapV = i.wrapV), t.diffuseTexture = e;
452
452
  }
453
453
  }
454
454
  function We() {
455
- const s = () => Math.floor((1 + Math.random()) * 65536).toString(16).substring(1);
456
- return s() + s() + "-" + s() + "-" + s() + "-" + s() + "-" + s() + s() + s();
455
+ const r = () => Math.floor((1 + Math.random()) * 65536).toString(16).substring(1);
456
+ return r() + r() + "-" + r() + "-" + r() + "-" + r() + "-" + r() + r() + r();
457
457
  }
458
458
  const M = 60, ue = 1;
459
- function me(s) {
460
- return s.targetedAnimations.map((t) => t.animation.framePerSecond).reduce((t, i) => t + i, 0) / s.targetedAnimations.length || 0;
459
+ function me(r) {
460
+ return r.targetedAnimations.map((t) => t.animation.framePerSecond).reduce((t, i) => t + i, 0) / r.targetedAnimations.length || 0;
461
461
  }
462
- function ve(s, e, t, i, r, n) {
463
- const o = r ? s.filter((c) => c.name === r) : s;
462
+ function ve(r, e, t, i, s, n) {
463
+ const o = s ? r.filter((c) => c.name === s) : r;
464
464
  if (o.length === 0) {
465
- console.warn(`No animations found for name: ${r}`);
465
+ console.warn(`No animations found for name: ${s}`);
466
466
  return;
467
467
  }
468
468
  let a = 0;
@@ -487,11 +487,11 @@ function ve(s, e, t, i, r, n) {
487
487
  l(c, e, ue, m, f);
488
488
  });
489
489
  }
490
- function Ye(s, e, t) {
490
+ function Ye(r, e, t) {
491
491
  return new Promise((i) => {
492
- s.stopAnimation(e), e.animations = [], Math.abs(e.alpha) > 2 * Math.PI && (e.alpha = Qe(e.alpha, 0, 2 * Math.PI));
493
- const r = [], n = t.target, o = 0, a = n ? 1 : 0;
494
- if (t.target && Object.keys(t.target).length > 0 && r.push(
492
+ r.stopAnimation(e), e.animations = [], Math.abs(e.alpha) > 2 * Math.PI && (e.alpha = Qe(e.alpha, 0, 2 * Math.PI));
493
+ const s = [], n = t.target, o = 0, a = n ? 1 : 0;
494
+ if (t.target && Object.keys(t.target).length > 0 && s.push(
495
495
  T(
496
496
  "cameraTargetLerp",
497
497
  "target",
@@ -504,7 +504,7 @@ function Ye(s, e, t) {
504
504
  C.ANIMATIONTYPE_VECTOR3,
505
505
  o
506
506
  )
507
- ), r.push(
507
+ ), s.push(
508
508
  T(
509
509
  "cameraAlphaLerp",
510
510
  "alpha",
@@ -513,7 +513,7 @@ function Ye(s, e, t) {
513
513
  C.ANIMATIONTYPE_FLOAT,
514
514
  a
515
515
  )
516
- ), r.push(
516
+ ), s.push(
517
517
  T(
518
518
  "cameraBetaLerp",
519
519
  "beta",
@@ -524,7 +524,7 @@ function Ye(s, e, t) {
524
524
  )
525
525
  ), t.radius !== void 0) {
526
526
  const c = Math.max(0.01, t.radius);
527
- r.push(
527
+ s.push(
528
528
  T(
529
529
  "cameraRadiusLerp",
530
530
  "radius",
@@ -535,9 +535,9 @@ function Ye(s, e, t) {
535
535
  )
536
536
  );
537
537
  }
538
- e.animations.push(...r);
538
+ e.animations.push(...s);
539
539
  const l = e.useAutoRotationBehavior;
540
- e.disableAutoRotationBehavior(), s.beginAnimation(
540
+ e.disableAutoRotationBehavior(), r.beginAnimation(
541
541
  e,
542
542
  0,
543
543
  n ? M * 2 : M,
@@ -549,17 +549,17 @@ function Ye(s, e, t) {
549
549
  );
550
550
  });
551
551
  }
552
- function ge(s) {
553
- return s * Math.PI / 180;
552
+ function ge(r) {
553
+ return r * Math.PI / 180;
554
554
  }
555
- function T(s, e, t, i, r, n = 0, o = C.ANIMATIONLOOPMODE_CONSTANT) {
555
+ function T(r, e, t, i, s, n = 0, o = C.ANIMATIONLOOPMODE_CONSTANT) {
556
556
  const a = new ke();
557
- a.setEasingMode(qe.EASINGMODE_EASEINOUT);
557
+ a.setEasingMode(Ne.EASINGMODE_EASEINOUT);
558
558
  const h = new C(
559
- s,
559
+ r,
560
560
  e,
561
561
  M,
562
- r,
562
+ s,
563
563
  o
564
564
  ), l = [];
565
565
  return n > 0 && l.push({ frame: 0, value: t }), l.push({ frame: M * n, value: t }), l.push({
@@ -567,11 +567,11 @@ function T(s, e, t, i, r, n = 0, o = C.ANIMATIONLOOPMODE_CONSTANT) {
567
567
  value: i
568
568
  }), h.setKeys(l), h.setEasingFunction(a), h;
569
569
  }
570
- function Qe(s, e, t) {
571
- return s < e ? s = t - (e - s) % (t - e) : s = e + (s - e) % (t - e);
570
+ function Qe(r, e, t) {
571
+ return r < e ? r = t - (e - r) % (t - e) : r = e + (r - e) % (t - e);
572
572
  }
573
- function Ze(s, e, t) {
574
- s.forEach((i) => {
573
+ function Ze(r, e, t) {
574
+ r.forEach((i) => {
575
575
  t && i.name !== t || i.goToFrame(e);
576
576
  });
577
577
  }
@@ -585,7 +585,7 @@ const $e = {
585
585
  refractionTexture: "refractionMap",
586
586
  reflectionTexture: "reflectionMap"
587
587
  };
588
- function je(s, e, t, i) {
588
+ function je(r, e, t, i) {
589
589
  [
590
590
  "albedoTexture",
591
591
  "bumpTexture",
@@ -598,46 +598,46 @@ function je(s, e, t, i) {
598
598
  ].forEach((n) => {
599
599
  Xe(
600
600
  n,
601
- s,
601
+ r,
602
602
  e,
603
603
  t,
604
604
  i
605
605
  );
606
- }), tt(s, e);
606
+ }), tt(r, e);
607
607
  }
608
- function Xe(s, e, t, i, r) {
609
- const n = $e[s];
608
+ function Xe(r, e, t, i, s) {
609
+ const n = $e[r];
610
610
  if (!n)
611
611
  throw new Error("Unexpected texture name encountered.");
612
612
  const o = e[n], a = o == null ? void 0 : o.fileLink;
613
- a ? s === "reflectionTexture" ? a.endsWith(".env") || a.endsWith(".dds") ? i.addCubeTextureTask(
614
- s,
613
+ a ? r === "reflectionTexture" ? a.endsWith(".env") || a.endsWith(".dds") ? i.addCubeTextureTask(
614
+ r,
615
615
  a,
616
616
  void 0,
617
617
  !1,
618
618
  void 0,
619
619
  !0
620
620
  ) : a.endsWith(".hdr") ? i.addHDRCubeTextureTask(
621
- s,
621
+ r,
622
622
  a,
623
623
  128,
624
624
  !1,
625
625
  !0,
626
626
  !1
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));
627
+ ) : i.addTextureTask(r, a, !1, !1) : i.addTextureTask(r, a, !1, !1) : s && t[r] && (t[r] && t[r].dispose(), t[r] = null, Je(r, t));
628
628
  }
629
- function Je(s, e) {
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 A(0, 0, 0), e.reflectionTexture);
629
+ function Je(r, e) {
630
+ r === "opacityTexture" && (e.useAlphaFromAlbedoTexture = !0), r === "metallicTexture" && (e.useRoughnessFromMetallicTextureAlpha = !1, e.useRoughnessFromMetallicTextureGreen = !1, e.useMetallnessFromMetallicTextureBlue = !1), r === "refractionTexture" && (e.subSurface.isRefractionEnabled = !1, e.subSurface.refractionIntensity = 1), r === "reflectionTexture" && (e.environmentIntensity = 1), r === "emissiveTexture" && (e.emissiveIntensity = 0, e.emissiveColor = new A(0, 0, 0), e.reflectionTexture);
631
631
  }
632
- function et(s, e, t, i) {
632
+ function et(r, e, t, i) {
633
633
  if (!e) {
634
634
  console.error("Failed to apply texture to material: material is null.");
635
635
  return;
636
636
  }
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 A(1, 1, 1), e.emissiveIntensity = 1);
637
+ r === "opacityTexture" && (e.useAlphaFromAlbedoTexture = !1), r === "metallicTexture" && (e.useRoughnessFromMetallicTextureAlpha = !1, e.useRoughnessFromMetallicTextureGreen = !0, e.useMetallnessFromMetallicTextureBlue = !0), r === "refractionTexture" && (e.subSurface.isRefractionEnabled = !0, e.subSurface.refractionIntensity = t.refractionIntensity || 1), r === "reflectionTexture" && (e.environmentIntensity = t.reflectionIntensity || 1, i.isCube && (i.rotationY = t.reflectionRotation ? t.reflectionRotation * Math.PI / 180 : 0)), e[r] = i, r === "emissiveTexture" && (e.emissiveColor = new A(1, 1, 1), e.emissiveIntensity = 1);
638
638
  }
639
- function tt(s, e) {
640
- s.clearCoat && (s.clearCoat === D.RemoveWhenSelected ? (e.clearCoat.isEnabled = !1, e.clearCoat.indexOfRefraction = 1.5) : s.clearCoat === D.ApplyWhenSelected && (e.clearCoat.isEnabled = !0, e.clearCoat.indexOfRefraction = s.clearCoatIOR || e.clearCoat.indexOfRefraction));
639
+ function tt(r, e) {
640
+ r.clearCoat && (r.clearCoat === D.RemoveWhenSelected ? (e.clearCoat.isEnabled = !1, e.clearCoat.indexOfRefraction = 1.5) : r.clearCoat === D.ApplyWhenSelected && (e.clearCoat.isEnabled = !0, e.clearCoat.indexOfRefraction = r.clearCoatIOR || e.clearCoat.indexOfRefraction));
641
641
  }
642
642
  class it {
643
643
  constructor(e, t, i) {
@@ -652,7 +652,7 @@ class it {
652
652
  * instead remove material textures when they aren't defined. this is useful for material editor applications
653
653
  * where we want to undo changes are remove effects from display.
654
654
  */
655
- async applyMaterial(e, t, i, r) {
655
+ async applyMaterial(e, t, i, s) {
656
656
  return new Promise((n) => {
657
657
  const o = this.materialVariantMap.get(e);
658
658
  this.materialVariantMap.set(e, {
@@ -666,13 +666,13 @@ class it {
666
666
  n();
667
667
  return;
668
668
  }
669
- const l = new Ne(this.scene);
669
+ const l = new qe(this.scene);
670
670
  l.useDefaultLoadingScreen = !1, h.forEach(
671
671
  (c) => je(
672
672
  t,
673
673
  c,
674
674
  l,
675
- r
675
+ s
676
676
  )
677
677
  ), l.onProgress = (c, u, m) => {
678
678
  i && i(c / u * 100, 100, m.name);
@@ -703,13 +703,13 @@ class it {
703
703
  * @param getCurrentFrame A function that returns the current frame of the animation.
704
704
  * @param getAnimationIsPlaying A function that returns whether the animation is currently playing.
705
705
  */
706
- async applyModel(e, t, i, r, n, o, a) {
706
+ async applyModel(e, t, i, s, n, o, a) {
707
707
  var m, f, p;
708
708
  if (i && t && !this.keysThatRemovedBaseModel.includes(e) && this.keysThatRemovedBaseModel.push(e), !i)
709
709
  return this.keysThatRemovedBaseModel.includes(e) && this.keysThatRemovedBaseModel.length === 1 && await this.setBaseModelEnabled(!0), (m = this.loadedContainerForKey.get(e)) == null || m.dispose(), this.loadedContainerForKey.delete(e), (f = this.loadedMaterialsForKey.get(e)) == null || f.forEach((b) => b.dispose()), this.loadedMaterialsForKey.delete(e), this.keysThatRemovedBaseModel = this.keysThatRemovedBaseModel.filter(
710
710
  (b) => b !== e
711
711
  ), Promise.resolve(void 0);
712
- const l = (await N(i, this.scene, r)).instantiateModelsToScene(
712
+ const l = (await q(i, this.scene, s)).instantiateModelsToScene(
713
713
  this.renameClonedAsset,
714
714
  !0
715
715
  );
@@ -758,19 +758,19 @@ class it {
758
758
  }), e;
759
759
  }
760
760
  }
761
- function we(s) {
761
+ function we(r) {
762
762
  const e = [];
763
- return s.rootNodes.forEach((t) => {
763
+ return r.rootNodes.forEach((t) => {
764
764
  t.getChildMeshes().forEach((i) => {
765
- i.material && !e.includes(i.material) && e.push(i.material), i.subMeshes && i.subMeshes.forEach((r) => {
766
- const n = r.getMaterial(!1);
765
+ i.material && !e.includes(i.material) && e.push(i.material), i.subMeshes && i.subMeshes.forEach((s) => {
766
+ const n = s.getMaterial(!1);
767
767
  n && !e.includes(n) && e.push(n);
768
768
  });
769
769
  });
770
770
  }), e;
771
771
  }
772
- function pe(s, e = "") {
773
- return s.map((t) => ({
772
+ function pe(r, e = "") {
773
+ return r.map((t) => ({
774
774
  name: t.name.substring(e.length),
775
775
  loop: t.loopAnimation,
776
776
  to: t.to,
@@ -783,11 +783,11 @@ class nt {
783
783
  const {
784
784
  enablePicking: t,
785
785
  modelDetails: i,
786
- previewService: r,
786
+ previewService: s,
787
787
  progressHandler: n,
788
788
  scene: o
789
789
  } = e;
790
- this.enablePicking = t, this.contextService = i.contextService, this.id = We(), this.previewService = r, this.scene = o, this.variantManager = new it(
790
+ this.enablePicking = t, this.contextService = i.contextService, this.id = We(), this.previewService = s, this.scene = o, this.variantManager = new it(
791
791
  o,
792
792
  this.renameClonedAsset.bind(this),
793
793
  this.setBaseModelEnabled.bind(this)
@@ -797,7 +797,7 @@ class nt {
797
797
  throw new Error(
798
798
  "Model container constructed with no URL. This is currently unsupported."
799
799
  );
800
- return this.assetContainer = await N(
800
+ return this.assetContainer = await q(
801
801
  i.model,
802
802
  o,
803
803
  n
@@ -806,7 +806,7 @@ class nt {
806
806
  this.importPromise = a();
807
807
  }
808
808
  //#region Interface implementation
809
- async applyMaterialVariant(e, t, i, r) {
809
+ async applyMaterialVariant(e, t, i, s) {
810
810
  if (!this.initialized) {
811
811
  if (this.materialReadyToLoadCallbacks.has(e)) {
812
812
  const o = this.materialReadyToLoadCallbacks.get(e);
@@ -817,7 +817,7 @@ class nt {
817
817
  e,
818
818
  t,
819
819
  i,
820
- r
820
+ s
821
821
  )
822
822
  );
823
823
  } else {
@@ -833,7 +833,7 @@ class nt {
833
833
  e,
834
834
  t,
835
835
  i,
836
- r
836
+ s
837
837
  )
838
838
  );
839
839
  }
@@ -850,7 +850,7 @@ class nt {
850
850
  taskName: h
851
851
  });
852
852
  },
853
- r
853
+ s
854
854
  );
855
855
  };
856
856
  if (this.materialChangesInProgress.includes(e)) {
@@ -881,7 +881,7 @@ class nt {
881
881
  ), this.configureGlowLayer(), this.scene.cleanCachedTextureBuffer();
882
882
  }
883
883
  async applyModelVariant(e, t, i) {
884
- const r = () => this.variantManager.applyModel(
884
+ const s = () => this.variantManager.applyModel(
885
885
  e,
886
886
  i,
887
887
  t == null ? void 0 : t.model,
@@ -896,16 +896,16 @@ class nt {
896
896
  this.getAnimationIsPlaying.bind(this)
897
897
  );
898
898
  if (!this.initialized) {
899
- this.modelReadyToLoadCallbacks.set(e, r);
899
+ this.modelReadyToLoadCallbacks.set(e, s);
900
900
  return;
901
901
  }
902
902
  if (this.modelChangesInProgress.includes(e)) {
903
- this.queuedModelChanges.set(e, r);
903
+ this.queuedModelChanges.set(e, s);
904
904
  return;
905
905
  }
906
906
  const o = await (async () => {
907
907
  this.modelChangesInProgress.push(e);
908
- let a = await r();
908
+ let a = await s();
909
909
  if (this.queuedModelChanges.has(e)) {
910
910
  const h = this.queuedModelChanges.get(e);
911
911
  if (!h)
@@ -929,7 +929,7 @@ class nt {
929
929
  let t = () => {
930
930
  };
931
931
  const i = async () => {
932
- this.isExecutingAnimation = !0, await new Promise((r) => {
932
+ this.isExecutingAnimation = !0, await new Promise((s) => {
933
933
  var o;
934
934
  const n = [
935
935
  ...((o = this.modelInstance) == null ? void 0 : o.animationGroups) || [],
@@ -941,12 +941,12 @@ class nt {
941
941
  e.to,
942
942
  e.from,
943
943
  e.name ? this.renameClonedAsset(e.name) : void 0,
944
- r
944
+ s
945
945
  );
946
946
  }), this.isExecutingAnimation = !1, this.queuedAnimationFunction && this.queuedAnimationFunction(), this.queuedAnimationFunction = void 0, t();
947
947
  };
948
- return this.isExecutingAnimation ? (this.queuedAnimationFunction = i, new Promise((r) => {
949
- t = r;
948
+ return this.isExecutingAnimation ? (this.queuedAnimationFunction = i, new Promise((s) => {
949
+ t = s;
950
950
  })) : i();
951
951
  }
952
952
  getAnimations(e) {
@@ -956,7 +956,7 @@ class nt {
956
956
  this.variantManager.getAnimationGroups(),
957
957
  this.renameClonedAsset("")
958
958
  ) : []
959
- ].map((t, i) => ({ ...t, name: t.name || `UNNAMED_ANIMATION_${i}` })).filter((t, i, r) => r.indexOf(r.find((n) => n.name === t.name)) == i);
959
+ ].map((t, i) => ({ ...t, name: t.name || `UNNAMED_ANIMATION_${i}` })).filter((t, i, s) => s.indexOf(s.find((n) => n.name === t.name)) == i);
960
960
  }
961
961
  getId() {
962
962
  return this.id;
@@ -1024,8 +1024,8 @@ class nt {
1024
1024
  e.rootNodes.forEach((t) => {
1025
1025
  t.getChildMeshes(!1).forEach((i) => {
1026
1026
  i.name === "targetcube_t" || i.name === "backgroundShell" || (i.actionManager || (i.actionManager = new O(this.scene)), i.actionManager.registerAction(
1027
- new oe(O.OnPointerOverTrigger, (r) => {
1028
- r.meshUnderPointer && i.material && this.materialSelectedObservable.notifyObservers({
1027
+ new oe(O.OnPointerOverTrigger, (s) => {
1028
+ s.meshUnderPointer && i.material && this.materialSelectedObservable.notifyObservers({
1029
1029
  id: i.material.id,
1030
1030
  name: this.stripIdFromName(i.material.name)
1031
1031
  });
@@ -1060,7 +1060,7 @@ class nt {
1060
1060
  return this.modelReadyToLoadCallbacks.size;
1061
1061
  }
1062
1062
  configureGlowLayer() {
1063
- const e = (i) => i instanceof q && i.emissiveTexture !== null;
1063
+ const e = (i) => i instanceof N && i.emissiveTexture !== null;
1064
1064
  this.materials.some(e) || this.variantManager.getAllMaterials().some(e) ? this.previewService.getGlowLayerManager().includeMeshes(this.getAllMeshes()) : this.previewService.getGlowLayerManager().removeMeshes(this.getAllMeshes());
1065
1065
  }
1066
1066
  configureModelInstance(e) {
@@ -1069,14 +1069,14 @@ class nt {
1069
1069
  throw new Error(
1070
1070
  "Transform disposed! This should never happen unless there is a race condition present!"
1071
1071
  );
1072
- const t = this.transformRoot.position, i = this.transformRoot.rotationQuaternion, r = this.transformRoot.scaling;
1072
+ const t = this.transformRoot.position, i = this.transformRoot.rotationQuaternion, s = this.transformRoot.scaling;
1073
1073
  this.transformRoot.position = g.Zero(), this.transformRoot.rotationQuaternion = x.Identity(), this.transformRoot.scaling = g.One();
1074
1074
  for (const o of e.rootNodes) {
1075
1075
  o.parent = this.transformRoot;
1076
1076
  for (const a of o.getChildMeshes(!1))
1077
1077
  a.alwaysSelectAsActiveMesh = !0;
1078
1078
  }
1079
- 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(
1079
+ this.transformRoot.position = t, this.transformRoot.rotationQuaternion = i, this.transformRoot.scaling = s, this.canvasPanels = ((n = this.contextService) == null ? void 0 : n.getAll()) || /* @__PURE__ */ new Map(), Ue(
1080
1080
  this.materials.concat(this.variantManager.getAllMaterials()),
1081
1081
  this.scene,
1082
1082
  this.canvasPanels,
@@ -1120,8 +1120,13 @@ class nt {
1120
1120
  var e;
1121
1121
  (e = this.canvasPanels) == null || e.forEach(
1122
1122
  (t, i) => {
1123
- const r = this.dynamicTextures.get(i);
1124
- r && t.getStaticContextDirty() && r.isReady() && (r.update(!1), t.setStaticContextDirty(!1));
1123
+ const s = this.dynamicTextures.get(i);
1124
+ t.getName().toLowerCase() === "crown" && console.log(
1125
+ t.getName(),
1126
+ s,
1127
+ t.getStaticContextDirty(),
1128
+ s == null ? void 0 : s.isReady()
1129
+ ), s && t.getStaticContextDirty() && s.isReady() && (s.update(!1), t.setStaticContextDirty(!1));
1125
1130
  }
1126
1131
  );
1127
1132
  }
@@ -1183,12 +1188,12 @@ class nt {
1183
1188
  //#endregion
1184
1189
  }
1185
1190
  class z extends fe {
1186
- constructor(e, t, i, r, n, o, a, h) {
1191
+ constructor(e, t, i, s, n, o, a, h) {
1187
1192
  super(
1188
1193
  e,
1189
1194
  t,
1190
1195
  i,
1191
- r,
1196
+ s,
1192
1197
  n,
1193
1198
  o,
1194
1199
  h
@@ -1245,14 +1250,14 @@ class z extends fe {
1245
1250
  this._isRunningFramingBehavior = !0, this.framingBehaviourCallback = e;
1246
1251
  const i = this.getFramingBehavior();
1247
1252
  i.framingTime = t || 800;
1248
- const r = () => {
1253
+ const s = () => {
1249
1254
  this.isRunningFramingBehavior = !1;
1250
1255
  }, n = I(this._scene), o = n.max.subtract(n.min), a = n.min.add(o.scale(0.5));
1251
1256
  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(
1252
1257
  n.min,
1253
1258
  n.max,
1254
1259
  void 0,
1255
- r
1260
+ s
1256
1261
  ), i.framingTime = 0;
1257
1262
  }
1258
1263
  /**
@@ -1284,7 +1289,7 @@ class z extends fe {
1284
1289
  */
1285
1290
  static create(e, t, i) {
1286
1291
  var h;
1287
- const r = I(e), n = r.max.subtract(r.min), o = r.min.add(n.scale(0.5)), a = new z(
1292
+ const s = I(e), n = s.max.subtract(s.min), o = s.min.add(n.scale(0.5)), a = new z(
1288
1293
  "ProductCamera",
1289
1294
  -(Math.PI / 2),
1290
1295
  Math.PI / 2,
@@ -1300,14 +1305,14 @@ class z extends fe {
1300
1305
  }), i && (e.activeCamera = a), a;
1301
1306
  }
1302
1307
  }
1303
- function I(s) {
1304
- if (s.meshes.length === 0)
1308
+ function I(r) {
1309
+ if (r.meshes.length === 0)
1305
1310
  return {
1306
1311
  min: new g(-1, -1, -1),
1307
1312
  max: new g(1, 1, 1)
1308
1313
  };
1309
- const e = s.meshes.filter((t) => t.name.toLowerCase().endsWith("_t") || t.name.toLowerCase().includes("_t_"));
1310
- return s.getWorldExtends((t) => t.isVisible && t.isEnabled() && (e.length === 0 || e.includes(t)));
1314
+ const e = r.meshes.filter((t) => t.name.toLowerCase().endsWith("_t") || t.name.toLowerCase().includes("_t_"));
1315
+ return r.getWorldExtends((t) => t.isVisible && t.isEnabled() && (e.length === 0 || e.includes(t)));
1311
1316
  }
1312
1317
  class st {
1313
1318
  constructor(e, t = !1, i = void 0) {
@@ -1327,9 +1332,9 @@ class st {
1327
1332
  return this.currentConfiguration;
1328
1333
  }
1329
1334
  setConfiguration(e) {
1330
- var t, i, r, n, o, a, h, l, c, u, m, f, p, b, w, R, V, _, G, H, U, K, W, Y, Q, Z, $, j, X, J, ee, te, ie;
1335
+ var t, i, s, n, o, a, h, l, c, u, m, f, p, b, w, R, V, _, G, H, U, K, W, Y, Q, Z, $, j, X, J, ee, te, ie;
1331
1336
  if (this.renderingPipeline.isSupported) {
1332
- if (this.renderingPipeline.samples = ((t = e.antiAliasing) == null ? void 0 : t.samples) ?? d.antiAliasing.samples, this.renderingPipeline.fxaaEnabled = ((i = e.antiAliasing) == null ? void 0 : i.fxaaEnabled) ?? d.antiAliasing.fxaaEnabled, this.renderingPipeline.bloomEnabled = ((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(
1337
+ 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 = ((s = e.bloom) == null ? void 0 : s.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(
1333
1338
  e.chromaticAberration.direction.x,
1334
1339
  e.chromaticAberration.direction.y
1335
1340
  ) : new se(
@@ -1383,20 +1388,20 @@ class st {
1383
1388
  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;
1384
1389
  }
1385
1390
  }
1386
- Pe.GLTFLoader.RegisterExtension("glbPostProcessor", function(s) {
1387
- return new Ge(s);
1391
+ Pe.GLTFLoader.RegisterExtension("glbPostProcessor", function(r) {
1392
+ return new Ge(r);
1388
1393
  });
1389
- k.OnPluginActivatedObservable.add((s) => {
1390
- if (s.name === "gltf") {
1391
- const e = s;
1394
+ k.OnPluginActivatedObservable.add((r) => {
1395
+ if (r.name === "gltf") {
1396
+ const e = r;
1392
1397
  e.transparencyAsCoverage = !0;
1393
1398
  }
1394
1399
  });
1395
- function F(s) {
1396
- return new g(s.x, s.y, s.z);
1400
+ function F(r) {
1401
+ return new g(r.x, r.y, r.z);
1397
1402
  }
1398
- function S(s) {
1399
- return { x: s.x, y: s.y, z: s.z };
1403
+ function S(r) {
1404
+ return { x: r.x, y: r.y, z: r.z };
1400
1405
  }
1401
1406
  class Yt {
1402
1407
  constructor(e) {
@@ -1425,12 +1430,12 @@ class Yt {
1425
1430
  const i = (() => {
1426
1431
  if (!(e != null && e.noRender))
1427
1432
  return this.configuration.createCanvas();
1428
- })(), r = "1.5.6";
1433
+ })(), s = "1.5.6";
1429
1434
  ye.Configuration = {
1430
1435
  decoder: {
1431
- wasmUrl: `https://www.gstatic.com/draco/versioned/decoders/${r}/draco_wasm_wrapper_gltf.js`,
1432
- wasmBinaryUrl: `https://www.gstatic.com/draco/versioned/decoders/${r}/draco_decoder_gltf.wasm`,
1433
- fallbackUrl: `https://www.gstatic.com/draco/versioned/decoders/${r}/draco_decoder_gltf.js`
1436
+ wasmUrl: `https://www.gstatic.com/draco/versioned/decoders/${s}/draco_wasm_wrapper_gltf.js`,
1437
+ wasmBinaryUrl: `https://www.gstatic.com/draco/versioned/decoders/${s}/draco_decoder_gltf.wasm`,
1438
+ fallbackUrl: `https://www.gstatic.com/draco/versioned/decoders/${s}/draco_decoder_gltf.js`
1434
1439
  }
1435
1440
  }, i && (i.getContext("webgl2") || i.getContext("webgl"));
1436
1441
  const n = console.log;
@@ -1506,7 +1511,7 @@ class Yt {
1506
1511
  this.plugins.forEach((e) => e.dispose(!0)), this.renderingPipeline.dispose(), this.engine && this.engine.dispose(), window.removeEventListener("resize", this.fireResizeEvent);
1507
1512
  }
1508
1513
  executeCameraAnimation(e) {
1509
- if (!this.camera || this.scene.activeCamera !== this.camera || this.getAllModels().length === 0 || !this.getAllModels().some((r) => r.getIsInitialized()))
1514
+ if (!this.camera || this.scene.activeCamera !== this.camera || this.getAllModels().length === 0 || !this.getAllModels().some((s) => s.getIsInitialized()))
1510
1515
  return this.queuedCameraAnimation = e, Promise.resolve();
1511
1516
  let t = () => {
1512
1517
  };
@@ -1517,8 +1522,8 @@ class Yt {
1517
1522
  e
1518
1523
  ), this.isAnimatingCamera = !1, this.queuedAnimationFunction && this.queuedAnimationFunction(), this.queuedAnimationFunction = void 0, t();
1519
1524
  };
1520
- return this.isAnimatingCamera ? (this.queuedAnimationFunction = i, new Promise((r) => {
1521
- t = r;
1525
+ return this.isAnimatingCamera ? (this.queuedAnimationFunction = i, new Promise((s) => {
1526
+ t = s;
1522
1527
  })) : i();
1523
1528
  }
1524
1529
  getCameraPose() {
@@ -1555,13 +1560,13 @@ class Yt {
1555
1560
  const t = async () => {
1556
1561
  this.isAnimatingCamera = !0, await new Promise((i) => {
1557
1562
  this.focusLostNotified = !1;
1558
- const r = () => {
1563
+ const s = () => {
1559
1564
  const n = this.configuration;
1560
1565
  this.camera.rerunFramingBehavior(() => {
1561
1566
  n.camera.limits.min.radius && (this.camera.lowerRadiusLimit = n.camera.limits.min.radius), n.camera.limits.max.radius && (this.camera.upperRadiusLimit = n.camera.limits.max.radius), i();
1562
1567
  });
1563
1568
  };
1564
- this.scene.onAfterRenderObservable.addOnce(r);
1569
+ this.scene.onAfterRenderObservable.addOnce(s);
1565
1570
  }), this.isAnimatingCamera = !1, this.queuedAnimationFunction && this.queuedAnimationFunction(), this.queuedAnimationFunction = void 0, e();
1566
1571
  };
1567
1572
  return this.isAnimatingCamera ? (this.queuedAnimationFunction = t, new Promise((i) => {
@@ -1592,8 +1597,8 @@ class Yt {
1592
1597
  this.scene
1593
1598
  );
1594
1599
  try {
1595
- const r = t.latDeg * Math.PI / 180, n = t.lonDeg * Math.PI / 180;
1596
- i.target = t.target ? new g(t.target.x, t.target.y, t.target.z) : g.Zero(), i.alpha = n, i.beta = r, i.radius = t.radius || this.camera.radius, i.minZ = 0.01, this.scene.render();
1600
+ const s = t.latDeg * Math.PI / 180, n = t.lonDeg * Math.PI / 180;
1601
+ i.target = t.target ? new g(t.target.x, t.target.y, t.target.z) : g.Zero(), i.alpha = n, i.beta = s, i.radius = t.radius || this.camera.radius, i.minZ = 0.01, this.scene.render();
1597
1602
  const o = await xe.CreateScreenshotUsingRenderTargetAsync(
1598
1603
  this.engine,
1599
1604
  i,
@@ -1611,18 +1616,18 @@ class Yt {
1611
1616
  const e = this.configuration;
1612
1617
  if (!e)
1613
1618
  return !0;
1614
- 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;
1615
- if (t === void 0 || i === void 0 || r === void 0 || n === void 0)
1619
+ const t = e.camera.limits.min.alpha, i = e.camera.limits.max.alpha, s = e.camera.limits.min.beta, n = e.camera.limits.max.beta;
1620
+ if (t === void 0 || i === void 0 || s === void 0 || n === void 0)
1616
1621
  return !0;
1617
- const o = [t, i], a = [r, n], h = o.every((c) => c === t), l = a.every((c) => c === r);
1622
+ const o = [t, i], a = [s, n], h = o.every((c) => c === t), l = a.every((c) => c === s);
1618
1623
  return !h && !l;
1619
1624
  }
1620
1625
  fireResizeEvent() {
1621
1626
  this.getNumViewports() > 0 && this.engine.resize();
1622
1627
  }
1623
1628
  setHighlights(e, t) {
1624
- var r;
1625
- e.length === 0 && ((r = this.highlightLayer) == null || r.dispose(), this.highlightLayer = void 0), this.highlightLayer || (this.highlightLayer = new Ae("highlights", this.scene, {
1629
+ var s;
1630
+ e.length === 0 && ((s = this.highlightLayer) == null || s.dispose(), this.highlightLayer = void 0), this.highlightLayer || (this.highlightLayer = new Ae("highlights", this.scene, {
1626
1631
  isStroke: !0,
1627
1632
  blurVerticalSize: 0.85,
1628
1633
  blurHorizontalSize: 0.85
@@ -1647,12 +1652,12 @@ class Yt {
1647
1652
  this.renderingPipeline && this.renderingPipeline.setConfiguration(e);
1648
1653
  }
1649
1654
  loadModel(e, t) {
1650
- const { refocusCamera: i = !0, progressHandler: r } = t ?? {}, n = new nt({
1655
+ const { refocusCamera: i = !0, progressHandler: s } = t ?? {}, n = new nt({
1651
1656
  enablePicking: this.configuration.highlights.enabled,
1652
1657
  modelDetails: e,
1653
1658
  scene: this.scene,
1654
1659
  previewService: this,
1655
- progressHandler: r
1660
+ progressHandler: s
1656
1661
  });
1657
1662
  return n.getInitializationPromise().then(() => {
1658
1663
  if (this.modelContainers.size <= 1 && i) {
@@ -1673,7 +1678,7 @@ class Yt {
1673
1678
  }), n;
1674
1679
  }
1675
1680
  async preloadModel(e) {
1676
- await N(e, this.scene);
1681
+ await q(e, this.scene);
1677
1682
  }
1678
1683
  getAllModels() {
1679
1684
  return Array.from(this.modelContainers.values());
@@ -1690,7 +1695,7 @@ class Yt {
1690
1695
  }
1691
1696
  unregisterPlugin(e) {
1692
1697
  const t = this.plugins.indexOf(e);
1693
- t > -1 && this.plugins.splice(t, 1).forEach((r) => r.dispose(!1));
1698
+ t > -1 && this.plugins.splice(t, 1).forEach((s) => s.dispose(!1));
1694
1699
  }
1695
1700
  getGlowLayerManager() {
1696
1701
  return this.glowLayerManager;
@@ -1708,13 +1713,13 @@ class Yt {
1708
1713
  * Flips a transform around the origin.
1709
1714
  */
1710
1715
  flipTransform(e, t, i) {
1711
- const r = re.Compose(
1716
+ const s = re.Compose(
1712
1717
  F(i || { x: 1, y: 1, z: 1 }),
1713
1718
  x.FromEulerVector(
1714
1719
  F(t || { x: 0, y: 0, z: 0 })
1715
1720
  ),
1716
1721
  F(e || { x: 0, y: 0, z: 0 })
1717
- ), n = re.RotationAxis(g.Up(), Math.PI), o = r.multiply(n), a = g.Zero(), h = x.Identity(), l = g.Zero();
1722
+ ), n = re.RotationAxis(g.Up(), Math.PI), o = s.multiply(n), a = g.Zero(), h = x.Identity(), l = g.Zero();
1718
1723
  return o.decompose(l, h, a), h.multiplyInPlace(x.FromEulerAngles(0, Math.PI, 0)), {
1719
1724
  position: S(a),
1720
1725
  rotation: S(h.toEulerAngles()),
@@ -1722,14 +1727,14 @@ class Yt {
1722
1727
  };
1723
1728
  }
1724
1729
  updatePreviewOptions(e) {
1725
- var r, n;
1730
+ var s, n;
1726
1731
  const t = new ce(e);
1727
1732
  this.configuration.highlights.enabled !== t.highlights.enabled && this.engine.setStencilBuffer(t.highlights.enabled), this.scene.clearColor = t.scene.clearColor;
1728
1733
  let i = this.scene.environmentTexture;
1729
1734
  this.configuration.scene.environment.file !== t.scene.environment.file && (i = ne.CreateFromPrefilteredData(
1730
1735
  t.scene.environment.file,
1731
1736
  this.scene
1732
- ), i.name = "updated-environment-cube", i.rotationY = this.configuration.scene.environment.rotationY, this.scene.environmentTexture = i), i.rotationY = t.scene.environment.rotationY, this.scene.environmentIntensity = t.scene.environment.intensity, (r = t.options) != null && r.renderingPipelineConfiguration ? this.renderingPipeline.setConfiguration(
1737
+ ), 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, (s = t.options) != null && s.renderingPipelineConfiguration ? this.renderingPipeline.setConfiguration(
1733
1738
  t.options.renderingPipelineConfiguration
1734
1739
  ) : (this.scene.imageProcessingConfiguration.exposure = t.lighting.exposure, this.scene.imageProcessingConfiguration.contrast = t.lighting.contrast), this.glowLayerManager.setIntensity(t.emissiveGlowIntensity), this.camera.updateConfiguration(t), this.camera.setPanEnabled(
1735
1740
  ((n = t.options) == null ? void 0 : n.noPan) !== void 0 ? !t.options.noPan : !0
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- (function(d,w){typeof exports=="object"&&typeof module<"u"?w(exports,require("@babylonjs/core/Cameras/arcRotateCamera"),require("@babylonjs/core/Engines/engine"),require("@babylonjs/core/Engines/nullEngine"),require("@babylonjs/core/Layers/highlightLayer"),require("@babylonjs/core/Loading/sceneLoader"),require("@babylonjs/core/Materials/Textures/cubeTexture"),require("@babylonjs/core/Maths/math.color"),require("@babylonjs/core/Maths/math.vector"),require("@babylonjs/core/Meshes/Compression/dracoCompression"),require("@babylonjs/core/Misc/observable"),require("@babylonjs/core/Misc/tools"),require("@babylonjs/core/scene"),require("@babylonjs/loaders/glTF"),require("@babylonjs/loaders/glTF/glTFFileLoader"),require("@babylonjs/core/Materials/PBR/pbrMaterial"),require("@babylonjs/core/Materials/Textures/mirrorTexture"),require("@babylonjs/core/Maths/math"),require("@babylonjs/core/Probes/reflectionProbe"),require("@babylonjs/core/Layers/glowLayer"),require("@babylonjs/core/Actions/actionManager"),require("@babylonjs/core/Actions/directActions"),require("@babylonjs/core/Meshes/mesh"),require("@babylonjs/core/Meshes/transformNode"),require("@babylonjs/core/Materials/Textures/dynamicTexture"),require("@babylonjs/core/Materials/Textures/texture"),require("@babylonjs/core/Animations/animation"),require("@babylonjs/core/Animations/easing"),require("@babylonjs/core/Misc/assetsManager"),require("@babylonjs/core/Materials/colorCurves"),require("@babylonjs/core/Materials/imageProcessingConfiguration"),require("@babylonjs/core/PostProcesses/RenderPipeline"),require("@babylonjs/core/PostProcesses/depthOfFieldEffect"),require("@babylonjs/core/Rendering/depthRendererSceneComponent"),require("@babylonjs/core/Engines/Extensions/engine.views"),require("@babylonjs/core/Meshes/instancedMesh"),require("@babylonjs/core/Materials/Textures/Loaders/ddsTextureLoader"),require("@babylonjs/core/Materials/Textures/Loaders/envTextureLoader"),require("@babylonjs/core/Materials/Textures/Loaders/ktxTextureLoader"),require("@babylonjs/core/Animations/animatable"),require("@babylonjs/core/Misc/screenshotTools"),require("@babylonjs/core/Rendering/boundingBoxRenderer"),require("@babylonjs/loaders/glTF/2.0/Extensions")):typeof define=="function"&&define.amd?define(["exports","@babylonjs/core/Cameras/arcRotateCamera","@babylonjs/core/Engines/engine","@babylonjs/core/Engines/nullEngine","@babylonjs/core/Layers/highlightLayer","@babylonjs/core/Loading/sceneLoader","@babylonjs/core/Materials/Textures/cubeTexture","@babylonjs/core/Maths/math.color","@babylonjs/core/Maths/math.vector","@babylonjs/core/Meshes/Compression/dracoCompression","@babylonjs/core/Misc/observable","@babylonjs/core/Misc/tools","@babylonjs/core/scene","@babylonjs/loaders/glTF","@babylonjs/loaders/glTF/glTFFileLoader","@babylonjs/core/Materials/PBR/pbrMaterial","@babylonjs/core/Materials/Textures/mirrorTexture","@babylonjs/core/Maths/math","@babylonjs/core/Probes/reflectionProbe","@babylonjs/core/Layers/glowLayer","@babylonjs/core/Actions/actionManager","@babylonjs/core/Actions/directActions","@babylonjs/core/Meshes/mesh","@babylonjs/core/Meshes/transformNode","@babylonjs/core/Materials/Textures/dynamicTexture","@babylonjs/core/Materials/Textures/texture","@babylonjs/core/Animations/animation","@babylonjs/core/Animations/easing","@babylonjs/core/Misc/assetsManager","@babylonjs/core/Materials/colorCurves","@babylonjs/core/Materials/imageProcessingConfiguration","@babylonjs/core/PostProcesses/RenderPipeline","@babylonjs/core/PostProcesses/depthOfFieldEffect","@babylonjs/core/Rendering/depthRendererSceneComponent","@babylonjs/core/Engines/Extensions/engine.views","@babylonjs/core/Meshes/instancedMesh","@babylonjs/core/Materials/Textures/Loaders/ddsTextureLoader","@babylonjs/core/Materials/Textures/Loaders/envTextureLoader","@babylonjs/core/Materials/Textures/Loaders/ktxTextureLoader","@babylonjs/core/Animations/animatable","@babylonjs/core/Misc/screenshotTools","@babylonjs/core/Rendering/boundingBoxRenderer","@babylonjs/loaders/glTF/2.0/Extensions"],w):(d=typeof globalThis<"u"?globalThis:d||self,w(d.Preview={},d.arcRotateCamera,d.engine,d.nullEngine,d.highlightLayer,d.sceneLoader,d.cubeTexture,d.math_color,d.math_vector,d.dracoCompression,d.observable,d.tools,d.scene,d.glTF,d.glTFFileLoader,d.pbrMaterial,d.mirrorTexture,d.math,d.reflectionProbe,d.glowLayer,d.actionManager,d.directActions,d.mesh,d.transformNode,d.dynamicTexture,d.texture,d.animation,d.easing,d.assetsManager,d.colorCurves,d.imageProcessingConfiguration,d.RenderPipeline,d.depthOfFieldEffect))})(this,function(d,w,z,Ce,ye,I,G,v,p,we,A,Me,xe,Ae,Pe,S,Te,T,Re,Ee,B,H,Le,Oe,Fe,Ie,M,U,Se,K,R,Be,q){"use strict";var E=(s=>(s[s.Orbit=0]="Orbit",s[s.Pan=1]="Pan",s))(E||{}),L=(s=>(s.None="None",s.RemoveWhenSelected="RemoveWhenSelected",s.ApplyWhenSelected="ApplyWhenSelected",s))(L||{});function qe(){const s=navigator.vendor.toLowerCase().includes("apple"),e=navigator.maxTouchPoints>0,t=!navigator.userAgent.toLowerCase().includes("crios");return s&&e&&t}const W=new Map;async function j(s,e,t){const i=await W.get(s);if(i&&i.scene.uid===e.uid)return i;const r=I.SceneLoader.LoadAssetContainerAsync(s,void 0,e,t);return!qe()&&W.set(s,r),r}I.SceneLoader.OnPluginActivatedObservable.add(s=>{s.name==="gltf"&&(s.animationStartMode=Pe.GLTFLoaderAnimationStartMode.NONE)});class Q{constructor(e){this.getSceneClearColor=()=>{var i,r,n,o;const t=(i=this.customOptions)!=null&&i.transparentBackground||(r=this.customOptions)!=null&&r.backgroundImage?0:1;if(this.customOptions&&((n=this.customOptions)!=null&&n.transparentBackground)||(o=this.customOptions)!=null&&o.backgroundImage)return new v.Color4(0,0,0,t).toLinearSpace();if(this.customOptions&&this.customOptions.backgroundColor){const a=v.Color3.FromHexString(this.customOptions.backgroundColor);return new v.Color4(a.r,a.g,a.b,t).toLinearSpace()}return new v.Color4(.98,.98,.98,t).toLinearSpace()},this.highlightColorFromConfig=()=>this.customOptions&&this.customOptions.highlightColor?this.hexToColor4(this.customOptions.highlightColor):new v.Color4(.98,.98,.98,1).toLinearSpace(),this.hexToColor4=(t,i=1)=>{const r=v.Color3.FromHexString(t);return new v.Color4(r.r,r.g,r.b,i).toLinearSpace()},this.customOptions=e}createCanvas(){var e;return(e=this.customOptions)!=null&&e.createCanvas?this.customOptions.createCanvas():document.createElement("canvas")}get options(){return this.customOptions}get scene(){var e,t,i,r,n;return{clearColor:this.getSceneClearColor(),transparentBackground:((e=this.customOptions)==null?void 0:e.transparentBackground)||((t=this.customOptions)==null?void 0:t.backgroundImage),environment:{file:((i=this.customOptions)==null?void 0:i.environmentFile)??"assets/model-viewer/default.env",intensity:((r=this.customOptions)==null?void 0:r.environmentIntensity)??1,rotationY:(((n=this.customOptions)==null?void 0:n.environmentRotationY)??0)*(Math.PI/180)}}}get camera(){var e,t,i,r,n,o,a,h,l,c,g,m,b;return{autoOrientation:((e=this.customOptions)==null?void 0:e.disableAutomaticOrientation)??!0,autoRotation:{enabled:((t=this.customOptions)==null?void 0:t.autoRotation)??!1,idleTimeMs:((i=this.customOptions)==null?void 0:i.idleTimeBeforeRotation)??5e3},limits:{min:{alpha:(r=this.customOptions)!=null&&r.lowerAlphaLimitDeg?((n=this.customOptions)==null?void 0:n.lowerAlphaLimitDeg)*Math.PI/180:void 0,beta:(o=this.customOptions)!=null&&o.lowerBetaLimitDeg?((a=this.customOptions)==null?void 0:a.lowerBetaLimitDeg)*Math.PI/180:void 0,radius:(h=this.customOptions)==null?void 0:h.minZoomOverride},max:{alpha:(l=this.customOptions)!=null&&l.upperAlphaLimitDeg?((c=this.customOptions)==null?void 0:c.upperAlphaLimitDeg)*Math.PI/180:void 0,beta:(g=this.customOptions)!=null&&g.upperBetaLimitDeg?((m=this.customOptions)==null?void 0:m.upperBetaLimitDeg)*Math.PI/180:void 0,radius:(b=this.customOptions)==null?void 0:b.maxZoomOverride}}}}get highlights(){var e;return{enabled:((e=this.customOptions)==null?void 0:e.highlightOnMaterialHover)??!1,color:this.highlightColorFromConfig()}}get lighting(){var e,t,i,r;return{exposure:((t=(e=this.customOptions)==null?void 0:e.lighting)==null?void 0:t.exposure)??.9,contrast:((r=(i=this.customOptions)==null?void 0:i.lighting)==null?void 0:r.contrast)??1.6}}get emissiveGlowIntensity(){var e;return((e=this.customOptions)==null?void 0:e.emissiveGlowIntensity)??.5}}class x{static getDynamicTextureResolution(e=!1){return e?{width:1,height:1}:this.getIsMobile()||!x.offscreenRenderingSupported()?{width:1024,height:1024}:{width:2048,height:2048}}static shouldMipMap(){return!0}static offscreenRenderingSupported(){return navigator.userAgent.includes("SamsungBrowser")?!1:!!window.Worker&&!!window.OffscreenCanvas}static getMirrorTextureResolution(){return this.getIsMobile()?512:1024}static getIsMobile(){try{return typeof window>"u"||!window.navigator?!1:/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(window.navigator.userAgent)||window.innerWidth/window.devicePixelRatio<=480}catch{return!1}}}const Y=128,u={antiAliasing:{samples:4,fxaaEnabled:!1},bloom:{enabled:!1,kernel:64,scale:.5,threshold:.9,weight:.15},chromaticAberration:{enabled:!1,aberrationAmount:30,direction:{x:0,y:0},radialIntensity:0},colorCurves:{enabled:!1},depthOfField:{enabled:!1,blurLevel:"Low",focalLength:50,focusDistance:2e3,fStop:1.4,lensSize:50},grain:{enabled:!1,animated:!1,intensity:30},misc:{contrast:1,exposure:1,toneMappingEnabled:!1,toneMappingType:"Standard"},sharpen:{enabled:!1,colorAmount:1,edgeAmount:.3},vignette:{enabled:!1,blendMode:"Multiply",cameraFov:.5,center:{x:0,y:0},colorHex:"#000000ff",colorRgba:{r:0,g:0,b:0,a:1},stretch:0,weight:1}};class je{constructor(e){this.name="glbPostProcessor",this.enabled=!0,this.loader=e}onReady(){this.applyReflections(this.loader.babylonScene)}loadNodeAsync(e,t,i){return this.loader.loadNodeAsync(e,t,function(r){t.extras&&Object.keys(t.extras).forEach(n=>{const o=t.extras[n];r.metadata[n]=o}),i(r)})}async loadMaterialPropertiesAsync(e,t,i){await this.loader.loadMaterialPropertiesAsync(e,t,i),this.enableMaterialExtrasIfRequired(t,i),i.needDepthPrePass=!0}dispose(){}enableMaterialExtrasIfRequired(e,t){if(!(!e.extras||!(t instanceof S.PBRMaterial))){if(e.extras.sheen){const i=t;i.sheen.isEnabled=!0,i.sheen.intensity=e.extras.sheen}if(e.extras.translucency){const i=t;i.subSurface.isTranslucencyEnabled=!0,i.subSurface.translucencyIntensity=e.extras.translucency,e.extras.translucencyR&&e.extras.translucencyG&&e.extras.translucencyB&&(i.subSurface.tintColor=new T.Color3(e.extras.translucencyR,e.extras.translucencyG,e.extras.translucencyB))}if(e.extras.refractionIOR){const i=t;i.subSurface.isRefractionEnabled=!0,i.subSurface.volumeIndexOfRefraction=e.extras.refractionIOR}if(e.extras.useDepthPrePass){const i=t;i.needDepthPrePass=!0,i.forceIrradianceInFragment=!0}if(e.extras.useParallax){const i=t;i.useParallax=!0,i.useParallaxOcclusion=!0,i.parallaxScaleBias=e.extras.useParallax}}}applyReflections(e){function t(n){const o=[];return n.transformNodes.forEach(a=>{a.metadata&&a.metadata.reflective&&o.push(...a.getChildMeshes())}),n.meshes.forEach(a=>{a.metadata&&a.metadata.reflective&&!o.includes(a)&&o.push(a)}),o}function i(n,o=1){const a=n.material;if(!a)return;const h=new Te.MirrorTexture("mirror",x.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 c=n.getWorldMatrix(),g=T.Vector3.TransformNormal(new T.Vector3(l[0],l[1],l[2]),c).normalize(),m=T.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,Y,e);a.cubeTexture.name="reflection-probe-cube-texture",a.attachToMesh(n),a.renderList&&a.renderList.push(...t(e)),o.reflectionTexture=a.cubeTexture}e.meshes.forEach(n=>{const o=n.metadata;o&&(o.mirrorTexture&&i(n,o.mirrorTexture),o.reflectionProbe&&r(n))})}}class De{constructor(e,t){this.scene=e,this.intensity=t,this.meshCount=0}setIntensity(e){this.intensity=e,this.glowLayer&&(this.glowLayer.intensity=e)}includeMeshes(e){if(e){this.glowLayer||(this.glowLayer=new Ee.GlowLayer("glow",this.scene),this.glowLayer.intensity=this.intensity);for(const t of e)this.glowLayer.hasMesh(t)||(this.glowLayer.addIncludedOnlyMesh(t),this.meshCount++)}}removeMeshes(e){if(!(!this.glowLayer||!e)){for(const t of e)this.glowLayer.hasMesh(t)&&(this.glowLayer.removeIncludedOnlyMesh(t),this.meshCount--);this.meshCount===0&&(this.glowLayer.dispose(),this.glowLayer=void 0)}}}function Ve(s,e,t,i,r=""){t.forEach(n=>{const o=n.getID(),a=n.getName(),h=n.getPanelSize&&n.getPanelSize(),l=x.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)Z(g,m),m.update(b);else{const f=ke(a,e,l.width,l.height);i.set(o,f),n.setStaticContext(f.getContext()),Z(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,x.shouldMipMap(),Ie.Texture.TRILINEAR_SAMPLINGMODE,z.Engine.TEXTUREFORMAT_RGBA),n=r.getContext();return n&&(n.fillStyle="#f5f5f5",n.fillRect(0,0,t,i),r.update()),r}function Z(s,e){if(s instanceof S.PBRMaterial){const t=s,i=t.albedoTexture;i?(e.wrapU=i.wrapU,e.wrapV=i.wrapV):(e.wrapU=1,e.wrapV=1),t.albedoTexture=e}else{const t=s,i=t.diffuseTexture;i&&(e.wrapU=i.wrapU,e.wrapV=i.wrapV),t.diffuseTexture=e}}function 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,$=1;function _(s){return s.targetedAnimations.map(t=>t.animation.framePerSecond).reduce((t,i)=>t+i,0)/s.targetedAnimations.length||0}function X(s,e,t,i,r,n){const o=r?s.filter(c=>c.name===r):s;if(o.length===0){console.warn(`No animations found for name: ${r}`);return}let a=0;const h=()=>{a++,a===o.length&&n&&n()},l=(c,g,m,b,f)=>{c.stop(),c.start(g,m,b,f),n&&(g==!1||g===void 0&&!c.loopAnimation?c.onAnimationGroupEndObservable.addOnce(()=>{h()}):c.onAnimationLoopObservable.addOnce(()=>{h()}))};if(i!==void 0&&t!==void 0&&i===t){o.forEach(c=>{const g=_(c),m=i*g;l(c,!1,$,m,m)});return}o.forEach(c=>{const g=_(c),m=i!==void 0?i*g:void 0,b=t!==void 0?t*g:void 0;l(c,e,$,m,b)})}function ze(s,e,t){return new Promise(i=>{s.stopAnimation(e),e.animations=[],Math.abs(e.alpha)>2*Math.PI&&(e.alpha=Ge(e.alpha,0,2*Math.PI));const r=[],n=t.target,o=0,a=n?1:0;if(t.target&&Object.keys(t.target).length>0&&r.push(O("cameraTargetLerp","target",new p.Vector3().copyFrom(e.target),new p.Vector3(t.target.x,t.target.y,t.target.z),M.Animation.ANIMATIONTYPE_VECTOR3,o)),r.push(O("cameraAlphaLerp","alpha",e.alpha,J(t.lonDeg),M.Animation.ANIMATIONTYPE_FLOAT,a)),r.push(O("cameraBetaLerp","beta",e.beta,J(t.latDeg),M.Animation.ANIMATIONTYPE_FLOAT,a)),t.radius!==void 0){const c=Math.max(.01,t.radius);r.push(O("cameraRadiusLerp","radius",e.radius,c,M.Animation.ANIMATIONTYPE_FLOAT,a))}e.animations.push(...r);const l=e.useAutoRotationBehavior;e.disableAutoRotationBehavior(),s.beginAnimation(e,0,n?P*2:P,!1,1,()=>{e.animations=[],l&&e.enableAutoRotationBehavior(),i()})})}function J(s){return s*Math.PI/180}function O(s,e,t,i,r,n=0,o=M.Animation.ANIMATIONLOOPMODE_CONSTANT){const a=new U.QuadraticEase;a.setEasingMode(U.EasingFunction.EASINGMODE_EASEINOUT);const h=new M.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 Ge(s,e,t){return s<e?s=t-(e-s)%(t-e):s=e+(s-e)%(t-e)}function He(s,e,t){s.forEach(i=>{t&&i.name!==t||i.goToFrame(e)})}const Ue={albedoTexture:"albedoMap",bumpTexture:"normalMap",ambientTexture:"ambientMap",emissiveTexture:"emissionMap",opacityTexture:"alphaMap",metallicTexture:"metallicMap",refractionTexture:"refractionMap",reflectionTexture:"reflectionMap"};function Ke(s,e,t,i){["albedoTexture","bumpTexture","ambientTexture","emissiveTexture","opacityTexture","metallicTexture","refractionTexture","reflectionTexture"].forEach(n=>{We(n,s,e,t,i)}),Ze(s,e)}function We(s,e,t,i,r){const n=Ue[s];if(!n)throw new Error("Unexpected texture name encountered.");const o=e[n],a=o==null?void 0:o.fileLink;a?s==="reflectionTexture"?a.endsWith(".env")||a.endsWith(".dds")?i.addCubeTextureTask(s,a,void 0,!1,void 0,!0):a.endsWith(".hdr")?i.addHDRCubeTextureTask(s,a,128,!1,!0,!1):i.addTextureTask(s,a,!1,!1):i.addTextureTask(s,a,!1,!1):r&&t[s]&&(t[s]&&t[s].dispose(),t[s]=null,Qe(s,t))}function Qe(s,e){s==="opacityTexture"&&(e.useAlphaFromAlbedoTexture=!0),s==="metallicTexture"&&(e.useRoughnessFromMetallicTextureAlpha=!1,e.useRoughnessFromMetallicTextureGreen=!1,e.useMetallnessFromMetallicTextureBlue=!1),s==="refractionTexture"&&(e.subSurface.isRefractionEnabled=!1,e.subSurface.refractionIntensity=1),s==="reflectionTexture"&&(e.environmentIntensity=1),s==="emissiveTexture"&&(e.emissiveIntensity=0,e.emissiveColor=new v.Color3(0,0,0),e.reflectionTexture)}function Ye(s,e,t,i){if(!e){console.error("Failed to apply texture to material: material is null.");return}s==="opacityTexture"&&(e.useAlphaFromAlbedoTexture=!1),s==="metallicTexture"&&(e.useRoughnessFromMetallicTextureAlpha=!1,e.useRoughnessFromMetallicTextureGreen=!0,e.useMetallnessFromMetallicTextureBlue=!0),s==="refractionTexture"&&(e.subSurface.isRefractionEnabled=!0,e.subSurface.refractionIntensity=t.refractionIntensity||1),s==="reflectionTexture"&&(e.environmentIntensity=t.reflectionIntensity||1,i.isCube&&(i.rotationY=t.reflectionRotation?t.reflectionRotation*Math.PI/180:0)),e[s]=i,s==="emissiveTexture"&&(e.emissiveColor=new v.Color3(1,1,1),e.emissiveIntensity=1)}function Ze(s,e){s.clearCoat&&(s.clearCoat===L.RemoveWhenSelected?(e.clearCoat.isEnabled=!1,e.clearCoat.indexOfRefraction=1.5):s.clearCoat===L.ApplyWhenSelected&&(e.clearCoat.isEnabled=!0,e.clearCoat.indexOfRefraction=s.clearCoatIOR||e.clearCoat.indexOfRefraction))}class $e{constructor(e,t,i){this.materialVariantMap=new Map,this.keysThatRemovedBaseModel=[],this.loadedContainerForKey=new Map,this.loadedMaterialsForKey=new Map,this.scene=e,this.renameClonedAsset=t,this.setBaseModelEnabled=i}async applyMaterial(e,t,i,r){return new Promise(n=>{const o=this.materialVariantMap.get(e);this.materialVariantMap.set(e,{...o,...t});const a=this.renameClonedAsset(e),h=this.scene.materials.filter(c=>c.name===a);if(h.length===0){n();return}const l=new Se.AssetsManager(this.scene);l.useDefaultLoadingScreen=!1,h.forEach(c=>Ke(t,c,l,r)),l.onProgress=(c,g,m)=>{i&&i(c/g*100,100,m.name)},l.onFinish=c=>{c.forEach(g=>{const m=g;i&&i(100,100,g.name),this.scene.materials.filter(f=>f.name===a).forEach(f=>{Ye(g.name,f,t,m.texture)})}),n()},l.loadAsync()})}async applyModel(e,t,i,r,n,o,a){var m,b,f;if(i&&t&&!this.keysThatRemovedBaseModel.includes(e)&&this.keysThatRemovedBaseModel.push(e),!i)return this.keysThatRemovedBaseModel.includes(e)&&this.keysThatRemovedBaseModel.length===1&&await this.setBaseModelEnabled(!0),(m=this.loadedContainerForKey.get(e))==null||m.dispose(),this.loadedContainerForKey.delete(e),(b=this.loadedMaterialsForKey.get(e))==null||b.forEach(C=>C.dispose()),this.loadedMaterialsForKey.delete(e),this.keysThatRemovedBaseModel=this.keysThatRemovedBaseModel.filter(C=>C!==e),Promise.resolve(void 0);const l=(await j(i,this.scene,r)).instantiateModelsToScene(this.renameClonedAsset,!0);this.loadedContainerForKey.has(e)&&(this.loadedContainerForKey.get(e).dispose(),this.loadedContainerForKey.delete(e),(f=this.loadedMaterialsForKey.get(e))==null||f.forEach(C=>C.dispose()),this.loadedMaterialsForKey.delete(e));const c=n&&n();if(c){const C=o&&o(),y=c.name?this.renameClonedAsset(c.name):void 0;if(X(l.animationGroups,c.loop,c.to,c.from,y),C!=null){const F=a&&a()||!0;He(l.animationGroups,C+(F?2:0),y)}}t&&await this.setBaseModelEnabled(!1),this.loadedContainerForKey.set(e,l),this.loadedMaterialsForKey.set(e,ee(l));const g=[];return this.materialVariantMap.forEach(async(C,y)=>{g.push(this.applyMaterial(y,C))}),await Promise.all(g),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 ee(s){const e=[];return s.rootNodes.forEach(t=>{t.getChildMeshes().forEach(i=>{i.material&&!e.includes(i.material)&&e.push(i.material),i.subMeshes&&i.subMeshes.forEach(r=>{const n=r.getMaterial(!1);n&&!e.includes(n)&&e.push(n)})})}),e}function te(s,e=""){return s.map(t=>({name:t.name.substring(e.length),loop:t.loopAnimation,to:t.to,from:t.from}))}class _e{constructor(e){this.metadata=new Map,this.materialSelectedObservable=new A.Observable,this.materialDeselectedObservable=new A.Observable,this.materialVariantObservable=new A.Observable,this.modelVariantObservable=new A.Observable,this.materialReadyToLoadCallbacks=new Map,this.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){const r=()=>this.variantManager.applyModel(e,i,t==null?void 0:t.model,a=>{this.modelVariantObservable.notifyObservers({...a,key:e})},this.getLastRequestedAnimation.bind(this),this.getCurrentAnimationFrame.bind(this),this.getAnimationIsPlaying.bind(this));if(!this.initialized){this.modelReadyToLoadCallbacks.set(e,r);return}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()];X(n,e.loop,e.to,e.from,e.name?this.renameClonedAsset(e.name):void 0,r)}),this.isExecutingAnimation=!1,this.queuedAnimationFunction&&this.queuedAnimationFunction(),this.queuedAnimationFunction=void 0,t()};return this.isExecutingAnimation?(this.queuedAnimationFunction=i,new Promise(r=>{t=r})):i()}getAnimations(e){return[...this.animations,...e?te(this.variantManager.getAnimationGroups(),this.renameClonedAsset("")):[]].map((t,i)=>({...t,name:t.name||`UNNAMED_ANIMATION_${i}`})).filter((t,i,r)=>r.indexOf(r.find(n=>n.name===t.name))==i)}getId(){return this.id}listMaterials(){var t;const e=(t=this.scene)==null?void 0:t.materials.filter(i=>i.name.startsWith(this.id));return e?e.map(i=>({id:i.id,name:this.stripIdFromName(i.name)})):[]}registerMaterialSelectedCallback(e){this.materialSelectedObservable.add(e)}unregisterMaterialSelectedCallback(e){this.materialSelectedObservable.removeCallback(e)}registerMaterialDeselectedCallback(e){this.materialDeselectedObservable.add(e)}unregisterMaterialDeselectedCallback(e){this.materialDeselectedObservable.removeCallback(e)}get position(){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to requesting position!");return this.transformRoot.position}set position(e){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to setting position!");this.transformRoot.position=new p.Vector3(e.x,e.y,e.z)}get rotation(){var e;if(!((e=this.transformRoot)!=null&&e.rotationQuaternion))throw new Error("ModelContainer disposed prior to requesting rotation!");return this.transformRoot.rotationQuaternion.toEulerAngles()}set rotation(e){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to setting rotation!");this.transformRoot.rotationQuaternion=p.Quaternion.FromEulerAngles(e.x,e.y,e.z)}get scale(){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to requesting scale!");return this.transformRoot.scaling}set scale(e){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to setting scale!");this.transformRoot.scaling=new p.Vector3(e.x,e.y,e.z)}attachPickingHandler(e){e.rootNodes.forEach(t=>{t.getChildMeshes(!1).forEach(i=>{i.name==="targetcube_t"||i.name==="backgroundShell"||(i.actionManager||(i.actionManager=new B.ActionManager(this.scene)),i.actionManager.registerAction(new H.ExecuteCodeAction(B.ActionManager.OnPointerOverTrigger,r=>{r.meshUnderPointer&&i.material&&this.materialSelectedObservable.notifyObservers({id:i.material.id,name:this.stripIdFromName(i.material.name)})})),i.actionManager.registerAction(new H.ExecuteCodeAction(B.ActionManager.OnPointerOutTrigger,()=>{i.material&&this.materialDeselectedObservable.notifyObservers({id:i.material.id,name:this.stripIdFromName(i.material.name)})})))})})}getInitializationPromise(){return this.importPromise}getIsInitialized(){return this.initialized}getQueuedMaterialVariantCount(){return this.materialReadyToLoadCallbacks.size}getQueuedModelVariantCount(){return this.modelReadyToLoadCallbacks.size}configureGlowLayer(){const e=i=>i instanceof S.PBRMaterial&&i.emissiveTexture!==null;this.materials.some(e)||this.variantManager.getAllMaterials().some(e)?this.previewService.getGlowLayerManager().includeMeshes(this.getAllMeshes()):this.previewService.getGlowLayerManager().removeMeshes(this.getAllMeshes())}configureModelInstance(e){var n;if(!this.transformRoot)throw new Error("Transform disposed! This should never happen unless there is a race condition present!");const t=this.transformRoot.position,i=this.transformRoot.rotationQuaternion,r=this.transformRoot.scaling;this.transformRoot.position=p.Vector3.Zero(),this.transformRoot.rotationQuaternion=p.Quaternion.Identity(),this.transformRoot.scaling=p.Vector3.One();for(const o of e.rootNodes){o.parent=this.transformRoot;for(const a of o.getChildMeshes(!1))a.alwaysSelectAsActiveMesh=!0}this.transformRoot.position=t,this.transformRoot.rotationQuaternion=i,this.transformRoot.scaling=r,this.canvasPanels=((n=this.contextService)==null?void 0:n.getAll())||new Map,Ve(this.materials.concat(this.variantManager.getAllMaterials()),this.scene,this.canvasPanels,this.dynamicTextures,`${this.id}_`),this.enablePicking&&this.attachPickingHandler(e),this.configureGlowLayer()}destroyInstance(){var e;(e=this.modelInstance)==null||e.dispose(),this.modelInstance=void 0}getAllMeshes(){var e;return(e=this.modelInstance)==null?void 0:e.rootNodes.map(t=>t.getChildMeshes(!1).filter(i=>i instanceof Le.Mesh)).flat()}async instantiate(){if(!this.assetContainer)throw new Error("Attempted to instantiate ModelContainer without an AssetContainer");this.modelInstance=this.assetContainer.instantiateModelsToScene(this.renameClonedAsset.bind(this),!0),this.materials=ee(this.modelInstance),this.configureModelInstance(this.modelInstance),this.animations=te(this.modelInstance.animationGroups,this.renameClonedAsset("")),this.initialized=!0,await this.processQueuedEvents()}renameClonedAsset(e){return`${this.id}_${e}`}async setBaseModelEnabled(e){e&&!this.modelInstance?await this.instantiate():!e&&this.modelInstance&&this.destroyInstance()}updateDynamicTextures(){var e;(e=this.canvasPanels)==null||e.forEach((t,i)=>{const r=this.dynamicTextures.get(i);r&&t.getStaticContextDirty()&&r.isReady()&&(r.update(!1),t.setStaticContextDirty(!1))})}registerMaterialVariantListener(e){this.materialVariantObservable.add(e)}unregisterMaterialVariantListener(e){this.materialVariantObservable.removeCallback(e)}registerModelVariantListener(e){this.modelVariantObservable.add(e)}unregisterModelVariantListener(e){this.modelVariantObservable.removeCallback(e)}getLastRequestedAnimation(){return this.lastRequestedAnimation}getCurrentAnimationFrame(){var t;const e=[...((t=this.modelInstance)==null?void 0:t.animationGroups)||[],...this.variantManager.getAnimationGroups()];for(const i of e)if(i.animatables.length>0&&i.animatables[0].masterFrame!==void 0&&i.animatables[0].masterFrame!==null)return i.animatables[0].masterFrame;return 0}getAnimationIsPlaying(){var t;const e=[...((t=this.modelInstance)==null?void 0:t.animationGroups)||[],...this.variantManager.getAnimationGroups()];for(const i of e)if(i.isPlaying)return!0;return!1}stripIdFromName(e){return e.substring(this.id.length+1)}async processQueuedEvents(){await Promise.all(Array.from(this.materialReadyToLoadCallbacks.values()).flatMap(e=>Array.from(e.values()).map(t=>t()))),this.materialReadyToLoadCallbacks.clear(),await Promise.all(Array.from(this.modelReadyToLoadCallbacks.values()).map(e=>e())),this.modelReadyToLoadCallbacks.clear(),this.scene.onAfterRenderObservable.addOnce(()=>{this.queuedModelAnimation&&(this.executeAnimation(this.queuedModelAnimation),this.queuedModelAnimation=void 0)})}}class D extends w.ArcRotateCamera{constructor(e,t,i,r,n,o,a,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=V(this._scene);return e.zoomOnBoundingInfo(t.min,t.max),this.wheelPrecision=100/this.radius,this.lowerRadiusLimit===null&&(this.lowerRadiusLimit=.1),this.lastFocus.copyFrom(this.target),e}rerunFramingBehavior(e,t){this._isRunningFramingBehavior=!0,this.framingBehaviourCallback=e;const i=this.getFramingBehavior();i.framingTime=t||800;const r=()=>{this.isRunningFramingBehavior=!1},n=V(this._scene),o=n.max.subtract(n.min),a=n.min.add(o.scale(.5));this.updateRadiusBounds(o.length()*1.5),this.wheelPrecision=100/this.radius,this.panningInertia=0,this.panningOriginTarget.copyFrom(a),this.panDenominator=o.length(),this.lastFocus.copyFrom(a),i.zoomOnBoundingInfo(n.min,n.max,void 0,r),i.framingTime=0}enableAutoRotationBehavior(e=5e3){this.useAutoRotationBehavior=!0;const t=this.getAutoRotationBehavior();t&&(t.idleRotationWaitTime=e)}disableAutoRotationBehavior(){this.useAutoRotationBehavior=!1}updateRadiusBounds(e){this.maxZ=e*1e3,this.lowerRadiusLimit=e*.01,this.upperRadiusLimit=1.5*e,this.wheelPrecision=100/e,this.pinchPrecision=300/e}static create(e,t,i){var h;const r=V(e),n=r.max.subtract(r.min),o=r.min.add(n.scale(.5)),a=new D("ProductCamera",-(Math.PI/2),Math.PI/2,n.length()*1.5,o,e,t);return a.setPanEnabled(((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 V(s){if(s.meshes.length===0)return{min:new p.Vector3(-1,-1,-1),max:new p.Vector3(1,1,1)};const e=s.meshes.filter(t=>t.name.toLowerCase().endsWith("_t")||t.name.toLowerCase().includes("_t_"));return s.getWorldExtends(t=>t.isVisible&&t.isEnabled()&&(e.length===0||e.includes(t)))}class Xe{constructor(e,t=!1,i=void 0){this.renderingPipeline=new Be.DefaultRenderingPipeline("default",t,e,i?[i]:void 0,!1),this.renderingPipeline.isSupported&&(this.renderingPipeline.prepare(),this.setConfiguration(u))}dispose(){this.renderingPipeline.dispose()}getConfiguration(){return this.currentConfiguration}setConfiguration(e){var t,i,r,n,o,a,h,l,c,g,m,b,f,C,y,F,ie,ne,se,re,ae,oe,le,he,ce,de,ue,ge,me,pe,fe,be,ve;if(this.renderingPipeline.isSupported){if(this.renderingPipeline.samples=((t=e.antiAliasing)==null?void 0:t.samples)??u.antiAliasing.samples,this.renderingPipeline.fxaaEnabled=((i=e.antiAliasing)==null?void 0:i.fxaaEnabled)??u.antiAliasing.fxaaEnabled,this.renderingPipeline.bloomEnabled=((r=e.bloom)==null?void 0:r.enabled)??u.bloom.enabled,this.renderingPipeline.bloomKernel=((n=e.bloom)==null?void 0:n.kernel)??u.bloom.kernel,this.renderingPipeline.bloomScale=((o=e.bloom)==null?void 0:o.scale)??u.bloom.scale,this.renderingPipeline.bloomThreshold=((a=e.bloom)==null?void 0:a.threshold)??u.bloom.threshold,this.renderingPipeline.bloomWeight=((h=e.bloom)==null?void 0:h.weight)??u.bloom.weight,this.renderingPipeline.chromaticAberrationEnabled=((l=e.chromaticAberration)==null?void 0:l.enabled)??u.chromaticAberration.enabled,this.renderingPipeline.chromaticAberration.aberrationAmount=((c=e.chromaticAberration)==null?void 0:c.aberrationAmount)??u.chromaticAberration.aberrationAmount,this.renderingPipeline.chromaticAberration.radialIntensity=((g=e.chromaticAberration)==null?void 0:g.radialIntensity)??u.chromaticAberration.radialIntensity,this.renderingPipeline.chromaticAberration.direction=(m=e.chromaticAberration)!=null&&m.direction?new p.Vector2(e.chromaticAberration.direction.x,e.chromaticAberration.direction.y):new p.Vector2(u.chromaticAberration.direction.x,u.chromaticAberration.direction.y),this.renderingPipeline.imageProcessing.colorCurvesEnabled=((b=e.colorCurves)==null?void 0:b.enabled)??u.colorCurves.enabled,this.renderingPipeline.imageProcessing.colorCurves=e.colorCurves?this.updateColorCurve(e.colorCurves):new K.ColorCurves,this.renderingPipeline.depthOfFieldEnabled=((f=e.depthOfField)==null?void 0:f.enabled)??u.depthOfField.enabled,e.depthOfField)switch(e.depthOfField.blurLevel??u.depthOfField.blurLevel){case"Low":this.renderingPipeline.depthOfFieldBlurLevel=q.DepthOfFieldEffectBlurLevel.Low;break;case"Medium":this.renderingPipeline.depthOfFieldBlurLevel=q.DepthOfFieldEffectBlurLevel.Medium;break;case"High":this.renderingPipeline.depthOfFieldBlurLevel=q.DepthOfFieldEffectBlurLevel.High;break}if(this.renderingPipeline.depthOfField.focalLength=((C=e.depthOfField)==null?void 0:C.focalLength)??u.depthOfField.focalLength,this.renderingPipeline.depthOfField.fStop=((y=e.depthOfField)==null?void 0:y.fStop)??u.depthOfField.fStop,this.renderingPipeline.depthOfField.focusDistance=((F=e.depthOfField)==null?void 0:F.focusDistance)??u.depthOfField.focusDistance,this.renderingPipeline.depthOfField.lensSize=((ie=e.depthOfField)==null?void 0:ie.lensSize)??u.depthOfField.lensSize,this.renderingPipeline.grainEnabled=((ne=e.grain)==null?void 0:ne.enabled)??u.grain.enabled,this.renderingPipeline.grain.animated=((se=e.grain)==null?void 0:se.animated)??u.grain.animated,this.renderingPipeline.grain.intensity=((re=e.grain)==null?void 0:re.intensity)??u.grain.intensity,this.renderingPipeline.imageProcessing.contrast=((ae=e.misc)==null?void 0:ae.contrast)??u.misc.contrast,this.renderingPipeline.imageProcessing.exposure=((oe=e.misc)==null?void 0:oe.exposure)??u.misc.exposure,this.renderingPipeline.imageProcessing.toneMappingEnabled=((le=e.misc)==null?void 0:le.toneMappingEnabled)??u.misc.toneMappingEnabled,this.renderingPipeline.imageProcessing.toneMappingEnabled)switch(e.misc.toneMappingType??u.misc.toneMappingType){case"Standard":this.renderingPipeline.imageProcessing.toneMappingType=R.ImageProcessingConfiguration.TONEMAPPING_STANDARD;break;case"ACES":this.renderingPipeline.imageProcessing.toneMappingType=R.ImageProcessingConfiguration.TONEMAPPING_ACES;break}if(this.renderingPipeline.sharpenEnabled=((he=e.sharpen)==null?void 0:he.enabled)??u.sharpen.enabled,this.renderingPipeline.sharpen.colorAmount=((ce=e.sharpen)==null?void 0:ce.colorAmount)??u.sharpen.colorAmount,this.renderingPipeline.sharpen.edgeAmount=((de=e.sharpen)==null?void 0:de.edgeAmount)??u.sharpen.edgeAmount,this.renderingPipeline.imageProcessing.vignetteEnabled=((ue=e.vignette)==null?void 0:ue.enabled)??u.vignette.enabled,(ge=e.vignette)!=null&&ge.center?(this.renderingPipeline.imageProcessing.vignetteCenterX=e.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=e.vignette.center.y):(this.renderingPipeline.imageProcessing.vignetteCenterX=u.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=u.vignette.center.y),e.vignette)switch(((me=e.vignette)==null?void 0:me.blendMode)??u.vignette.blendMode){case"Multiply":this.renderingPipeline.imageProcessing.vignetteBlendMode=R.ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY;break;case"Opaque":this.renderingPipeline.imageProcessing.vignetteBlendMode=R.ImageProcessingConfiguration.VIGNETTEMODE_OPAQUE;break}(pe=e.vignette)!=null&&pe.colorRgba?this.renderingPipeline.imageProcessing.vignetteColor=new v.Color4(e.vignette.colorRgba.r,e.vignette.colorRgba.g,e.vignette.colorRgba.b,e.vignette.colorRgba.a):(fe=e.vignette)!=null&&fe.colorHex?this.renderingPipeline.imageProcessing.vignetteColor=v.Color4.FromHexString(e.vignette.colorHex):this.renderingPipeline.imageProcessing.vignetteColor=new v.Color4(u.vignette.colorRgba.r,u.vignette.colorRgba.g,u.vignette.colorRgba.b,u.vignette.colorRgba.a),this.renderingPipeline.imageProcessing.vignetteStretch=((be=e.vignette)==null?void 0:be.stretch)??u.vignette.stretch,this.renderingPipeline.imageProcessing.vignetteWeight=((ve=e.vignette)==null?void 0:ve.weight)??u.vignette.weight,this.renderingPipeline.prepare(),this.currentConfiguration=e}}updateColorCurve(e){const t=new K.ColorCurves;return t.globalDensity=e.globalDensity??t.globalDensity,t.globalExposure=e.globalExposure??t.globalExposure,t.globalHue=e.globalHue??t.globalHue,t.globalSaturation=e.globalSaturation??t.globalSaturation,t.highlightsDensity=e.highlightsDensity??t.highlightsDensity,t.highlightsExposure=e.highlightsExposure??t.highlightsExposure,t.highlightsHue=e.highlightsHue??t.highlightsHue,t.highlightsSaturation=e.highlightsSaturation??t.highlightsSaturation,t.midtonesDensity=e.midtonesDensity??t.midtonesDensity,t.midtonesExposure=e.midtonesExposure??t.midtonesExposure,t.midtonesHue=e.midtonesHue??t.midtonesHue,t.midtonesSaturation=e.midtonesSaturation??t.midtonesSaturation,t.shadowsDensity=e.shadowsDensity??t.shadowsDensity,t.shadowsExposure=e.shadowsExposure??t.shadowsExposure,t.shadowsHue=e.shadowsHue??t.shadowsHue,t.shadowsSaturation=e.shadowsSaturation??t.shadowsSaturation,t}}Ae.GLTF2.GLTFLoader.RegisterExtension("glbPostProcessor",function(s){return new je(s)}),I.SceneLoader.OnPluginActivatedObservable.add(s=>{if(s.name==="gltf"){const e=s;e.transparencyAsCoverage=!0}});function k(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 Je{constructor(e){var h;this.focusLostNotified=!1,this.focusLostObservable=new A.Observable,this.modelLoadEventCallbacks=[],this.modelContainers=new Map,this.plugins=[],this.initComplete=!1,this.isAnimatingCamera=!1,this.renderLoop=()=>{if(!this.engine.views)return;this.modelContainers.forEach(g=>{g.updateDynamicTextures()}),this.scene.autoClear=!0,this.scene.autoClearDepthAndStencil=!0;const 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 c=Math.max((this.camera.lowerRadiusLimit??1)*.01,.001);!this.camera.isRunningFramingBehavior&&!this.camera.target.equalsWithEpsilon(this.camera.lastFocus,c)&&!this.focusLostNotified&&(this.focusLostObservable.notifyObservers(void 0),this.focusLostNotified=!0),this.screenshotPrepareResolve&&(this.screenshotPrepareResolve(),this.screenshotPrepareResolve=void 0)},this.configuration=new Q(e);const i=(()=>{if(!(e!=null&&e.noRender))return this.configuration.createCanvas()})(),r="1.5.6";we.DracoCompression.Configuration={decoder:{wasmUrl:`https://www.gstatic.com/draco/versioned/decoders/${r}/draco_wasm_wrapper_gltf.js`,wasmBinaryUrl:`https://www.gstatic.com/draco/versioned/decoders/${r}/draco_decoder_gltf.wasm`,fallbackUrl:`https://www.gstatic.com/draco/versioned/decoders/${r}/draco_decoder_gltf.js`}},i&&(i.getContext("webgl2")||i.getContext("webgl"));const n=console.log;console.log=()=>{};const o=i?new z.Engine(i,!0,{adaptToDeviceRatio:!0,limitDeviceRatio:2,premultipliedAlpha:!1,preserveDrawingBuffer:!!(e!=null&&e.backgroundImage),audioEngine:!1,stencil:this.configuration.highlights.enabled,forceSRGBBufferSupportState:!0}):new Ce.NullEngine;o.enableOfflineSupport=!1,o.doNotHandleContextLost=!0,console.log=n,o.hideLoadingUI(),window.addEventListener("resize",this.fireResizeEvent.bind(this)),this.engine=o,this.scene=new xe.Scene(o),this.camera=D.create(this.scene,this.configuration),this.scene.activeCamera=this.camera,this.renderingPipeline=new Xe(this.scene,!1,this.camera),this.scene.clearColor=this.configuration.scene.clearColor;const a=G.CubeTexture.CreateFromPrefilteredData(this.configuration.scene.environment.file,this.scene);a.name="initial-environment-cube",a.rotationY=this.configuration.scene.environment.rotationY,this.scene.environmentTexture=a,this.scene.environmentIntensity=this.configuration.scene.environment.intensity,(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(E.Pan),this.reattachControls(e)}getNumViewports(){var e;return((e=this.engine.views)==null?void 0:e.length)||0}unregisterView(e){this.engine.unRegisterView(e)}shutdown(){this.plugins.forEach(e=>e.dispose(!0)),this.renderingPipeline.dispose(),this.engine&&this.engine.dispose(),window.removeEventListener("resize",this.fireResizeEvent)}executeCameraAnimation(e){if(!this.camera||this.scene.activeCamera!==this.camera||this.getAllModels().length===0||!this.getAllModels().some(r=>r.getIsInitialized()))return this.queuedCameraAnimation=e,Promise.resolve();let t=()=>{};const i=async()=>{this.isAnimatingCamera=!0,await ze(this.scene,this.scene.activeCamera,e),this.isAnimatingCamera=!1,this.queuedAnimationFunction&&this.queuedAnimationFunction(),this.queuedAnimationFunction=void 0,t()};return this.isAnimatingCamera?(this.queuedAnimationFunction=i,new Promise(r=>{t=r})):i()}getCameraPose(){if(this.scene&&this.camera)return{lonDeg:Math.round(this.camera.alpha*180/Math.PI),latDeg:Math.round(this.camera.beta*180/Math.PI),radius:Math.round((this.camera.radius+Number.EPSILON)*1e4)/1e4,target:{x:this.camera.target.x,y:this.camera.target.y,z:this.camera.target.z}}}setCameraPose(e){this.scene&&this.camera&&(this.camera.target=new p.Vector3(e.target.x,e.target.y,e.target.z),this.camera.radius=e.radius,this.camera.alpha=e.latDeg,this.camera.beta=e.lonDeg)}setCameraState(e){var t,i;if(!((t=this.engine)!=null&&t.views)||!((i=this.engine)!=null&&i.views[0]))throw new Error("No views attached, camera state requires a view to attach controls onto.");e===E.Orbit?this.reattachControls(this.engine.views[0].target,2):this.reattachControls(this.engine.views[0].target,0)}animateToLastCameraFocus(){let e=()=>{};const t=async()=>{this.isAnimatingCamera=!0,await new Promise(i=>{this.focusLostNotified=!1;const r=()=>{const n=this.configuration;this.camera.rerunFramingBehavior(()=>{n.camera.limits.min.radius&&(this.camera.lowerRadiusLimit=n.camera.limits.min.radius),n.camera.limits.max.radius&&(this.camera.upperRadiusLimit=n.camera.limits.max.radius),i()})};this.scene.onAfterRenderObservable.addOnce(r)}),this.isAnimatingCamera=!1,this.queuedAnimationFunction&&this.queuedAnimationFunction(),this.queuedAnimationFunction=void 0,e()};return this.isAnimatingCamera?(this.queuedAnimationFunction=t,new Promise(i=>{e=i})):t()}forceStopCameraAnimations(){var e;this.queuedAnimationFunction=void 0,this.queuedCameraAnimation=void 0,this.isAnimatingCamera=!1,(e=this.camera.framingBehavior)==null||e.stopAllAnimations(),this.scene.stopAnimation(this.camera)}setAutoRotation(e){!this.configuration.camera.autoRotation.enabled||!this.camera||(e?this.camera.enableAutoRotationBehavior(this.configuration.camera.autoRotation.idleTimeMs):this.camera.disableAutoRotationBehavior())}getCurrentConfiguration(){return this.configuration.options}async renderSceneScreenshot(e,t){if(!this.camera)throw new Error("Missing product camera, cannot render screenshot!");const i=new w.ArcRotateCamera("screenshotCamera",0,0,0,p.Vector3.Zero(),this.scene);try{const r=t.latDeg*Math.PI/180,n=t.lonDeg*Math.PI/180;i.target=t.target?new p.Vector3(t.target.x,t.target.y,t.target.z):p.Vector3.Zero(),i.alpha=n,i.beta=r,i.radius=t.radius||this.camera.radius,i.minZ=.01,this.scene.render();const o=await Me.Tools.CreateScreenshotUsingRenderTargetAsync(this.engine,i,e,"image/png",2,!0);return i.dispose(),o}catch{throw i.isDisposed()||i.dispose(),new Error("Failed to render screenshot")}}orbitEnabled(){const e=this.configuration;if(!e)return!0;const t=e.camera.limits.min.alpha,i=e.camera.limits.max.alpha,r=e.camera.limits.min.beta,n=e.camera.limits.max.beta;if(t===void 0||i===void 0||r===void 0||n===void 0)return!0;const o=[t,i],a=[r,n],h=o.every(c=>c===t),l=a.every(c=>c===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(k(i||{x:1,y:1,z:1}),p.Quaternion.FromEulerVector(k(t||{x:0,y:0,z:0})),k(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 Q(e);this.configuration.highlights.enabled!==t.highlights.enabled&&this.engine.setStencilBuffer(t.highlights.enabled),this.scene.clearColor=t.scene.clearColor;let i=this.scene.environmentTexture;this.configuration.scene.environment.file!==t.scene.environment.file&&(i=G.CubeTexture.CreateFromPrefilteredData(t.scene.environment.file,this.scene),i.name="updated-environment-cube",i.rotationY=this.configuration.scene.environment.rotationY,this.scene.environmentTexture=i),i.rotationY=t.scene.environment.rotationY,this.scene.environmentIntensity=t.scene.environment.intensity,(r=t.options)!=null&&r.renderingPipelineConfiguration?this.renderingPipeline.setConfiguration(t.options.renderingPipelineConfiguration):(this.scene.imageProcessingConfiguration.exposure=t.lighting.exposure,this.scene.imageProcessingConfiguration.contrast=t.lighting.contrast),this.glowLayerManager.setIntensity(t.emissiveGlowIntensity),this.camera.updateConfiguration(t),this.camera.setPanEnabled(((n=t.options)==null?void 0:n.noPan)!==void 0?!t.options.noPan:!0),this.configuration=t}reattachControls(e,t=2){if(this.scene.detachControl(),this.engine.inputElement=e,this.camera){this.camera.attachControl(!0,!1,t);const i=this.camera.inputs.attached.pointers;i.multiTouchPanning=!1}this.scene.attachControl(!0,!0,!0)}}d.MaterialEffectMode=L,d.ProductCameraRig=E,d.REFLECTION_PROBE_RESOLUTION=Y,d.RenderingConfiguration=x,d.SpiffCommerce3DPreviewService=Je,d.renderingPipelineDefaults=u,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
1
+ (function(d,w){typeof exports=="object"&&typeof module<"u"?w(exports,require("@babylonjs/core/Cameras/arcRotateCamera"),require("@babylonjs/core/Engines/engine"),require("@babylonjs/core/Engines/nullEngine"),require("@babylonjs/core/Layers/highlightLayer"),require("@babylonjs/core/Loading/sceneLoader"),require("@babylonjs/core/Materials/Textures/cubeTexture"),require("@babylonjs/core/Maths/math.color"),require("@babylonjs/core/Maths/math.vector"),require("@babylonjs/core/Meshes/Compression/dracoCompression"),require("@babylonjs/core/Misc/observable"),require("@babylonjs/core/Misc/tools"),require("@babylonjs/core/scene"),require("@babylonjs/loaders/glTF"),require("@babylonjs/loaders/glTF/glTFFileLoader"),require("@babylonjs/core/Materials/PBR/pbrMaterial"),require("@babylonjs/core/Materials/Textures/mirrorTexture"),require("@babylonjs/core/Maths/math"),require("@babylonjs/core/Probes/reflectionProbe"),require("@babylonjs/core/Layers/glowLayer"),require("@babylonjs/core/Actions/actionManager"),require("@babylonjs/core/Actions/directActions"),require("@babylonjs/core/Meshes/mesh"),require("@babylonjs/core/Meshes/transformNode"),require("@babylonjs/core/Materials/Textures/dynamicTexture"),require("@babylonjs/core/Materials/Textures/texture"),require("@babylonjs/core/Animations/animation"),require("@babylonjs/core/Animations/easing"),require("@babylonjs/core/Misc/assetsManager"),require("@babylonjs/core/Materials/colorCurves"),require("@babylonjs/core/Materials/imageProcessingConfiguration"),require("@babylonjs/core/PostProcesses/RenderPipeline"),require("@babylonjs/core/PostProcesses/depthOfFieldEffect"),require("@babylonjs/core/Rendering/depthRendererSceneComponent"),require("@babylonjs/core/Engines/Extensions/engine.views"),require("@babylonjs/core/Meshes/instancedMesh"),require("@babylonjs/core/Materials/Textures/Loaders/ddsTextureLoader"),require("@babylonjs/core/Materials/Textures/Loaders/envTextureLoader"),require("@babylonjs/core/Materials/Textures/Loaders/ktxTextureLoader"),require("@babylonjs/core/Animations/animatable"),require("@babylonjs/core/Misc/screenshotTools"),require("@babylonjs/core/Rendering/boundingBoxRenderer"),require("@babylonjs/loaders/glTF/2.0/Extensions")):typeof define=="function"&&define.amd?define(["exports","@babylonjs/core/Cameras/arcRotateCamera","@babylonjs/core/Engines/engine","@babylonjs/core/Engines/nullEngine","@babylonjs/core/Layers/highlightLayer","@babylonjs/core/Loading/sceneLoader","@babylonjs/core/Materials/Textures/cubeTexture","@babylonjs/core/Maths/math.color","@babylonjs/core/Maths/math.vector","@babylonjs/core/Meshes/Compression/dracoCompression","@babylonjs/core/Misc/observable","@babylonjs/core/Misc/tools","@babylonjs/core/scene","@babylonjs/loaders/glTF","@babylonjs/loaders/glTF/glTFFileLoader","@babylonjs/core/Materials/PBR/pbrMaterial","@babylonjs/core/Materials/Textures/mirrorTexture","@babylonjs/core/Maths/math","@babylonjs/core/Probes/reflectionProbe","@babylonjs/core/Layers/glowLayer","@babylonjs/core/Actions/actionManager","@babylonjs/core/Actions/directActions","@babylonjs/core/Meshes/mesh","@babylonjs/core/Meshes/transformNode","@babylonjs/core/Materials/Textures/dynamicTexture","@babylonjs/core/Materials/Textures/texture","@babylonjs/core/Animations/animation","@babylonjs/core/Animations/easing","@babylonjs/core/Misc/assetsManager","@babylonjs/core/Materials/colorCurves","@babylonjs/core/Materials/imageProcessingConfiguration","@babylonjs/core/PostProcesses/RenderPipeline","@babylonjs/core/PostProcesses/depthOfFieldEffect","@babylonjs/core/Rendering/depthRendererSceneComponent","@babylonjs/core/Engines/Extensions/engine.views","@babylonjs/core/Meshes/instancedMesh","@babylonjs/core/Materials/Textures/Loaders/ddsTextureLoader","@babylonjs/core/Materials/Textures/Loaders/envTextureLoader","@babylonjs/core/Materials/Textures/Loaders/ktxTextureLoader","@babylonjs/core/Animations/animatable","@babylonjs/core/Misc/screenshotTools","@babylonjs/core/Rendering/boundingBoxRenderer","@babylonjs/loaders/glTF/2.0/Extensions"],w):(d=typeof globalThis<"u"?globalThis:d||self,w(d.Preview={},d.arcRotateCamera,d.engine,d.nullEngine,d.highlightLayer,d.sceneLoader,d.cubeTexture,d.math_color,d.math_vector,d.dracoCompression,d.observable,d.tools,d.scene,d.glTF,d.glTFFileLoader,d.pbrMaterial,d.mirrorTexture,d.math,d.reflectionProbe,d.glowLayer,d.actionManager,d.directActions,d.mesh,d.transformNode,d.dynamicTexture,d.texture,d.animation,d.easing,d.assetsManager,d.colorCurves,d.imageProcessingConfiguration,d.RenderPipeline,d.depthOfFieldEffect))})(this,function(d,w,z,Ce,ye,I,G,v,p,we,A,Me,xe,Ae,Pe,S,Te,T,Re,Ee,B,H,Le,Oe,Fe,Ie,M,U,Se,K,R,Be,q){"use strict";var E=(r=>(r[r.Orbit=0]="Orbit",r[r.Pan=1]="Pan",r))(E||{}),L=(r=>(r.None="None",r.RemoveWhenSelected="RemoveWhenSelected",r.ApplyWhenSelected="ApplyWhenSelected",r))(L||{});function qe(){const r=navigator.vendor.toLowerCase().includes("apple"),e=navigator.maxTouchPoints>0,t=!navigator.userAgent.toLowerCase().includes("crios");return r&&e&&t}const W=new Map;async function j(r,e,t){const i=await W.get(r);if(i&&i.scene.uid===e.uid)return i;const s=I.SceneLoader.LoadAssetContainerAsync(r,void 0,e,t);return!qe()&&W.set(r,s),s}I.SceneLoader.OnPluginActivatedObservable.add(r=>{r.name==="gltf"&&(r.animationStartMode=Pe.GLTFLoaderAnimationStartMode.NONE)});class Q{constructor(e){this.getSceneClearColor=()=>{var i,s,n,o;const t=(i=this.customOptions)!=null&&i.transparentBackground||(s=this.customOptions)!=null&&s.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 s=v.Color3.FromHexString(t);return new v.Color4(s.r,s.g,s.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,s,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:((s=this.customOptions)==null?void 0:s.environmentIntensity)??1,rotationY:(((n=this.customOptions)==null?void 0:n.environmentRotationY)??0)*(Math.PI/180)}}}get camera(){var e,t,i,s,n,o,a,h,l,c,g,m,b;return{autoOrientation:((e=this.customOptions)==null?void 0:e.disableAutomaticOrientation)??!0,autoRotation:{enabled:((t=this.customOptions)==null?void 0:t.autoRotation)??!1,idleTimeMs:((i=this.customOptions)==null?void 0:i.idleTimeBeforeRotation)??5e3},limits:{min:{alpha:(s=this.customOptions)!=null&&s.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?((c=this.customOptions)==null?void 0:c.upperAlphaLimitDeg)*Math.PI/180:void 0,beta:(g=this.customOptions)!=null&&g.upperBetaLimitDeg?((m=this.customOptions)==null?void 0:m.upperBetaLimitDeg)*Math.PI/180:void 0,radius:(b=this.customOptions)==null?void 0:b.maxZoomOverride}}}}get highlights(){var e;return{enabled:((e=this.customOptions)==null?void 0:e.highlightOnMaterialHover)??!1,color:this.highlightColorFromConfig()}}get lighting(){var e,t,i,s;return{exposure:((t=(e=this.customOptions)==null?void 0:e.lighting)==null?void 0:t.exposure)??.9,contrast:((s=(i=this.customOptions)==null?void 0:i.lighting)==null?void 0:s.contrast)??1.6}}get emissiveGlowIntensity(){var e;return((e=this.customOptions)==null?void 0:e.emissiveGlowIntensity)??.5}}class x{static getDynamicTextureResolution(e=!1){return e?{width:1,height:1}:this.getIsMobile()||!x.offscreenRenderingSupported()?{width:1024,height:1024}:{width:2048,height:2048}}static shouldMipMap(){return!0}static offscreenRenderingSupported(){return navigator.userAgent.includes("SamsungBrowser")?!1:!!window.Worker&&!!window.OffscreenCanvas}static getMirrorTextureResolution(){return this.getIsMobile()?512:1024}static getIsMobile(){try{return typeof window>"u"||!window.navigator?!1:/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(window.navigator.userAgent)||window.innerWidth/window.devicePixelRatio<=480}catch{return!1}}}const Y=128,u={antiAliasing:{samples:4,fxaaEnabled:!1},bloom:{enabled:!1,kernel:64,scale:.5,threshold:.9,weight:.15},chromaticAberration:{enabled:!1,aberrationAmount:30,direction:{x:0,y:0},radialIntensity:0},colorCurves:{enabled:!1},depthOfField:{enabled:!1,blurLevel:"Low",focalLength:50,focusDistance:2e3,fStop:1.4,lensSize:50},grain:{enabled:!1,animated:!1,intensity:30},misc:{contrast:1,exposure:1,toneMappingEnabled:!1,toneMappingType:"Standard"},sharpen:{enabled:!1,colorAmount:1,edgeAmount:.3},vignette:{enabled:!1,blendMode:"Multiply",cameraFov:.5,center:{x:0,y:0},colorHex:"#000000ff",colorRgba:{r:0,g:0,b:0,a:1},stretch:0,weight:1}};class je{constructor(e){this.name="glbPostProcessor",this.enabled=!0,this.loader=e}onReady(){this.applyReflections(this.loader.babylonScene)}loadNodeAsync(e,t,i){return this.loader.loadNodeAsync(e,t,function(s){t.extras&&Object.keys(t.extras).forEach(n=>{const o=t.extras[n];s.metadata[n]=o}),i(s)})}async loadMaterialPropertiesAsync(e,t,i){await this.loader.loadMaterialPropertiesAsync(e,t,i),this.enableMaterialExtrasIfRequired(t,i),i.needDepthPrePass=!0}dispose(){}enableMaterialExtrasIfRequired(e,t){if(!(!e.extras||!(t instanceof S.PBRMaterial))){if(e.extras.sheen){const i=t;i.sheen.isEnabled=!0,i.sheen.intensity=e.extras.sheen}if(e.extras.translucency){const i=t;i.subSurface.isTranslucencyEnabled=!0,i.subSurface.translucencyIntensity=e.extras.translucency,e.extras.translucencyR&&e.extras.translucencyG&&e.extras.translucencyB&&(i.subSurface.tintColor=new T.Color3(e.extras.translucencyR,e.extras.translucencyG,e.extras.translucencyB))}if(e.extras.refractionIOR){const i=t;i.subSurface.isRefractionEnabled=!0,i.subSurface.volumeIndexOfRefraction=e.extras.refractionIOR}if(e.extras.useDepthPrePass){const i=t;i.needDepthPrePass=!0,i.forceIrradianceInFragment=!0}if(e.extras.useParallax){const i=t;i.useParallax=!0,i.useParallaxOcclusion=!0,i.parallaxScaleBias=e.extras.useParallax}}}applyReflections(e){function t(n){const o=[];return n.transformNodes.forEach(a=>{a.metadata&&a.metadata.reflective&&o.push(...a.getChildMeshes())}),n.meshes.forEach(a=>{a.metadata&&a.metadata.reflective&&!o.includes(a)&&o.push(a)}),o}function i(n,o=1){const a=n.material;if(!a)return;const h=new Te.MirrorTexture("mirror",x.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 c=n.getWorldMatrix(),g=T.Vector3.TransformNormal(new T.Vector3(l[0],l[1],l[2]),c).normalize(),m=T.Plane.FromPositionAndNormal(n.position,g.scale(-1));h.mirrorPlane=m,h.level=o,a.reflectionTexture=h}function s(n){const o=n.material,a=new Re.ReflectionProbe("probe-"+o.name,Y,e);a.cubeTexture.name="reflection-probe-cube-texture",a.attachToMesh(n),a.renderList&&a.renderList.push(...t(e)),o.reflectionTexture=a.cubeTexture}e.meshes.forEach(n=>{const o=n.metadata;o&&(o.mirrorTexture&&i(n,o.mirrorTexture),o.reflectionProbe&&s(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(r,e,t,i,s=""){t.forEach(n=>{const o=n.getID(),a=n.getName(),h=n.getPanelSize&&n.getPanelSize(),l=x.getDynamicTextureResolution((h==null?void 0:h.width)===1||(h==null?void 0:h.height)===1);r.filter(g=>g.name===s+a).forEach(g=>{const m=i.get(o),b=!1;if(m)Z(g,m),m.update(b);else{const f=Ne(a,e,l.width,l.height);i.set(o,f),n.setStaticContext(f.getContext()),Z(g,f),f.onLoadObservable.addOnce(()=>{f.update(b)})}})})}function Ne(r,e,t,i){const s=new Fe.DynamicTexture(r,{width:t,height:i},e,x.shouldMipMap(),Ie.Texture.TRILINEAR_SAMPLINGMODE,z.Engine.TEXTUREFORMAT_RGBA),n=s.getContext();return n&&(n.fillStyle="#f5f5f5",n.fillRect(0,0,t,i),s.update()),s}function Z(r,e){if(r instanceof S.PBRMaterial){const t=r,i=t.albedoTexture;i?(e.wrapU=i.wrapU,e.wrapV=i.wrapV):(e.wrapU=1,e.wrapV=1),t.albedoTexture=e}else{const t=r,i=t.diffuseTexture;i&&(e.wrapU=i.wrapU,e.wrapV=i.wrapV),t.diffuseTexture=e}}function ke(){const r=()=>Math.floor((1+Math.random())*65536).toString(16).substring(1);return r()+r()+"-"+r()+"-"+r()+"-"+r()+"-"+r()+r()+r()}const P=60,$=1;function _(r){return r.targetedAnimations.map(t=>t.animation.framePerSecond).reduce((t,i)=>t+i,0)/r.targetedAnimations.length||0}function X(r,e,t,i,s,n){const o=s?r.filter(c=>c.name===s):r;if(o.length===0){console.warn(`No animations found for name: ${s}`);return}let a=0;const h=()=>{a++,a===o.length&&n&&n()},l=(c,g,m,b,f)=>{c.stop(),c.start(g,m,b,f),n&&(g==!1||g===void 0&&!c.loopAnimation?c.onAnimationGroupEndObservable.addOnce(()=>{h()}):c.onAnimationLoopObservable.addOnce(()=>{h()}))};if(i!==void 0&&t!==void 0&&i===t){o.forEach(c=>{const g=_(c),m=i*g;l(c,!1,$,m,m)});return}o.forEach(c=>{const g=_(c),m=i!==void 0?i*g:void 0,b=t!==void 0?t*g:void 0;l(c,e,$,m,b)})}function ze(r,e,t){return new Promise(i=>{r.stopAnimation(e),e.animations=[],Math.abs(e.alpha)>2*Math.PI&&(e.alpha=Ge(e.alpha,0,2*Math.PI));const s=[],n=t.target,o=0,a=n?1:0;if(t.target&&Object.keys(t.target).length>0&&s.push(O("cameraTargetLerp","target",new p.Vector3().copyFrom(e.target),new p.Vector3(t.target.x,t.target.y,t.target.z),M.Animation.ANIMATIONTYPE_VECTOR3,o)),s.push(O("cameraAlphaLerp","alpha",e.alpha,J(t.lonDeg),M.Animation.ANIMATIONTYPE_FLOAT,a)),s.push(O("cameraBetaLerp","beta",e.beta,J(t.latDeg),M.Animation.ANIMATIONTYPE_FLOAT,a)),t.radius!==void 0){const c=Math.max(.01,t.radius);s.push(O("cameraRadiusLerp","radius",e.radius,c,M.Animation.ANIMATIONTYPE_FLOAT,a))}e.animations.push(...s);const l=e.useAutoRotationBehavior;e.disableAutoRotationBehavior(),r.beginAnimation(e,0,n?P*2:P,!1,1,()=>{e.animations=[],l&&e.enableAutoRotationBehavior(),i()})})}function J(r){return r*Math.PI/180}function O(r,e,t,i,s,n=0,o=M.Animation.ANIMATIONLOOPMODE_CONSTANT){const a=new U.QuadraticEase;a.setEasingMode(U.EasingFunction.EASINGMODE_EASEINOUT);const h=new M.Animation(r,e,P,s,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 Ge(r,e,t){return r<e?r=t-(e-r)%(t-e):r=e+(r-e)%(t-e)}function He(r,e,t){r.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(r,e,t,i){["albedoTexture","bumpTexture","ambientTexture","emissiveTexture","opacityTexture","metallicTexture","refractionTexture","reflectionTexture"].forEach(n=>{We(n,r,e,t,i)}),Ze(r,e)}function We(r,e,t,i,s){const n=Ue[r];if(!n)throw new Error("Unexpected texture name encountered.");const o=e[n],a=o==null?void 0:o.fileLink;a?r==="reflectionTexture"?a.endsWith(".env")||a.endsWith(".dds")?i.addCubeTextureTask(r,a,void 0,!1,void 0,!0):a.endsWith(".hdr")?i.addHDRCubeTextureTask(r,a,128,!1,!0,!1):i.addTextureTask(r,a,!1,!1):i.addTextureTask(r,a,!1,!1):s&&t[r]&&(t[r]&&t[r].dispose(),t[r]=null,Qe(r,t))}function Qe(r,e){r==="opacityTexture"&&(e.useAlphaFromAlbedoTexture=!0),r==="metallicTexture"&&(e.useRoughnessFromMetallicTextureAlpha=!1,e.useRoughnessFromMetallicTextureGreen=!1,e.useMetallnessFromMetallicTextureBlue=!1),r==="refractionTexture"&&(e.subSurface.isRefractionEnabled=!1,e.subSurface.refractionIntensity=1),r==="reflectionTexture"&&(e.environmentIntensity=1),r==="emissiveTexture"&&(e.emissiveIntensity=0,e.emissiveColor=new v.Color3(0,0,0),e.reflectionTexture)}function Ye(r,e,t,i){if(!e){console.error("Failed to apply texture to material: material is null.");return}r==="opacityTexture"&&(e.useAlphaFromAlbedoTexture=!1),r==="metallicTexture"&&(e.useRoughnessFromMetallicTextureAlpha=!1,e.useRoughnessFromMetallicTextureGreen=!0,e.useMetallnessFromMetallicTextureBlue=!0),r==="refractionTexture"&&(e.subSurface.isRefractionEnabled=!0,e.subSurface.refractionIntensity=t.refractionIntensity||1),r==="reflectionTexture"&&(e.environmentIntensity=t.reflectionIntensity||1,i.isCube&&(i.rotationY=t.reflectionRotation?t.reflectionRotation*Math.PI/180:0)),e[r]=i,r==="emissiveTexture"&&(e.emissiveColor=new v.Color3(1,1,1),e.emissiveIntensity=1)}function Ze(r,e){r.clearCoat&&(r.clearCoat===L.RemoveWhenSelected?(e.clearCoat.isEnabled=!1,e.clearCoat.indexOfRefraction=1.5):r.clearCoat===L.ApplyWhenSelected&&(e.clearCoat.isEnabled=!0,e.clearCoat.indexOfRefraction=r.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,s){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(c=>c.name===a);if(h.length===0){n();return}const l=new Se.AssetsManager(this.scene);l.useDefaultLoadingScreen=!1,h.forEach(c=>Ke(t,c,l,s)),l.onProgress=(c,g,m)=>{i&&i(c/g*100,100,m.name)},l.onFinish=c=>{c.forEach(g=>{const m=g;i&&i(100,100,g.name),this.scene.materials.filter(f=>f.name===a).forEach(f=>{Ye(g.name,f,t,m.texture)})}),n()},l.loadAsync()})}async applyModel(e,t,i,s,n,o,a){var m,b,f;if(i&&t&&!this.keysThatRemovedBaseModel.includes(e)&&this.keysThatRemovedBaseModel.push(e),!i)return this.keysThatRemovedBaseModel.includes(e)&&this.keysThatRemovedBaseModel.length===1&&await this.setBaseModelEnabled(!0),(m=this.loadedContainerForKey.get(e))==null||m.dispose(),this.loadedContainerForKey.delete(e),(b=this.loadedMaterialsForKey.get(e))==null||b.forEach(C=>C.dispose()),this.loadedMaterialsForKey.delete(e),this.keysThatRemovedBaseModel=this.keysThatRemovedBaseModel.filter(C=>C!==e),Promise.resolve(void 0);const l=(await j(i,this.scene,s)).instantiateModelsToScene(this.renameClonedAsset,!0);this.loadedContainerForKey.has(e)&&(this.loadedContainerForKey.get(e).dispose(),this.loadedContainerForKey.delete(e),(f=this.loadedMaterialsForKey.get(e))==null||f.forEach(C=>C.dispose()),this.loadedMaterialsForKey.delete(e));const c=n&&n();if(c){const C=o&&o(),y=c.name?this.renameClonedAsset(c.name):void 0;if(X(l.animationGroups,c.loop,c.to,c.from,y),C!=null){const F=a&&a()||!0;He(l.animationGroups,C+(F?2:0),y)}}t&&await this.setBaseModelEnabled(!1),this.loadedContainerForKey.set(e,l),this.loadedMaterialsForKey.set(e,ee(l));const g=[];return this.materialVariantMap.forEach(async(C,y)=>{g.push(this.applyMaterial(y,C))}),await Promise.all(g),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 ee(r){const e=[];return r.rootNodes.forEach(t=>{t.getChildMeshes().forEach(i=>{i.material&&!e.includes(i.material)&&e.push(i.material),i.subMeshes&&i.subMeshes.forEach(s=>{const n=s.getMaterial(!1);n&&!e.includes(n)&&e.push(n)})})}),e}function te(r,e=""){return r.map(t=>({name:t.name.substring(e.length),loop:t.loopAnimation,to:t.to,from:t.from}))}class _e{constructor(e){this.metadata=new Map,this.materialSelectedObservable=new A.Observable,this.materialDeselectedObservable=new A.Observable,this.materialVariantObservable=new A.Observable,this.modelVariantObservable=new A.Observable,this.materialReadyToLoadCallbacks=new Map,this.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:s,progressHandler:n,scene:o}=e;this.enablePicking=t,this.contextService=i.contextService,this.id=ke(),this.previewService=s,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,s){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,s))}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,s))}return}const n=async()=>{await this.variantManager.applyMaterial(e,i,(o,a,h)=>{this.materialVariantObservable.notifyObservers({remainingCount:o,totalCount:a,taskName:h})},s)};if(this.materialChangesInProgress.includes(e)){if(this.queuedMaterialChanges.has(e)){const o=this.queuedMaterialChanges.get(e);o==null||o.set(t,n)}else{this.queuedMaterialChanges.set(e,new Map);const o=this.queuedMaterialChanges.get(e);o==null||o.set(t,n)}return}if(this.materialChangesInProgress.push(e),await n(),this.queuedMaterialChanges.has(e)){const o=this.queuedMaterialChanges.get(e);if(!o)throw new Error("Target material is undefined");o.forEach(async a=>{await a()}),this.queuedMaterialChanges.delete(e)}this.materialChangesInProgress.splice(this.materialChangesInProgress.indexOf(e),1),this.configureGlowLayer(),this.scene.cleanCachedTextureBuffer()}async applyModelVariant(e,t,i){const s=()=>this.variantManager.applyModel(e,i,t==null?void 0:t.model,a=>{this.modelVariantObservable.notifyObservers({...a,key:e})},this.getLastRequestedAnimation.bind(this),this.getCurrentAnimationFrame.bind(this),this.getAnimationIsPlaying.bind(this));if(!this.initialized){this.modelReadyToLoadCallbacks.set(e,s);return}if(this.modelChangesInProgress.includes(e)){this.queuedModelChanges.set(e,s);return}const o=await(async()=>{this.modelChangesInProgress.push(e);let a=await s();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(s=>{var o;const n=[...((o=this.modelInstance)==null?void 0:o.animationGroups)||[],...this.variantManager.getAnimationGroups()];X(n,e.loop,e.to,e.from,e.name?this.renameClonedAsset(e.name):void 0,s)}),this.isExecutingAnimation=!1,this.queuedAnimationFunction&&this.queuedAnimationFunction(),this.queuedAnimationFunction=void 0,t()};return this.isExecutingAnimation?(this.queuedAnimationFunction=i,new Promise(s=>{t=s})):i()}getAnimations(e){return[...this.animations,...e?te(this.variantManager.getAnimationGroups(),this.renameClonedAsset("")):[]].map((t,i)=>({...t,name:t.name||`UNNAMED_ANIMATION_${i}`})).filter((t,i,s)=>s.indexOf(s.find(n=>n.name===t.name))==i)}getId(){return this.id}listMaterials(){var t;const e=(t=this.scene)==null?void 0:t.materials.filter(i=>i.name.startsWith(this.id));return e?e.map(i=>({id:i.id,name:this.stripIdFromName(i.name)})):[]}registerMaterialSelectedCallback(e){this.materialSelectedObservable.add(e)}unregisterMaterialSelectedCallback(e){this.materialSelectedObservable.removeCallback(e)}registerMaterialDeselectedCallback(e){this.materialDeselectedObservable.add(e)}unregisterMaterialDeselectedCallback(e){this.materialDeselectedObservable.removeCallback(e)}get position(){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to requesting position!");return this.transformRoot.position}set position(e){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to setting position!");this.transformRoot.position=new p.Vector3(e.x,e.y,e.z)}get rotation(){var e;if(!((e=this.transformRoot)!=null&&e.rotationQuaternion))throw new Error("ModelContainer disposed prior to requesting rotation!");return this.transformRoot.rotationQuaternion.toEulerAngles()}set rotation(e){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to setting rotation!");this.transformRoot.rotationQuaternion=p.Quaternion.FromEulerAngles(e.x,e.y,e.z)}get scale(){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to requesting scale!");return this.transformRoot.scaling}set scale(e){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to setting scale!");this.transformRoot.scaling=new p.Vector3(e.x,e.y,e.z)}attachPickingHandler(e){e.rootNodes.forEach(t=>{t.getChildMeshes(!1).forEach(i=>{i.name==="targetcube_t"||i.name==="backgroundShell"||(i.actionManager||(i.actionManager=new B.ActionManager(this.scene)),i.actionManager.registerAction(new H.ExecuteCodeAction(B.ActionManager.OnPointerOverTrigger,s=>{s.meshUnderPointer&&i.material&&this.materialSelectedObservable.notifyObservers({id:i.material.id,name:this.stripIdFromName(i.material.name)})})),i.actionManager.registerAction(new H.ExecuteCodeAction(B.ActionManager.OnPointerOutTrigger,()=>{i.material&&this.materialDeselectedObservable.notifyObservers({id:i.material.id,name:this.stripIdFromName(i.material.name)})})))})})}getInitializationPromise(){return this.importPromise}getIsInitialized(){return this.initialized}getQueuedMaterialVariantCount(){return this.materialReadyToLoadCallbacks.size}getQueuedModelVariantCount(){return this.modelReadyToLoadCallbacks.size}configureGlowLayer(){const e=i=>i instanceof S.PBRMaterial&&i.emissiveTexture!==null;this.materials.some(e)||this.variantManager.getAllMaterials().some(e)?this.previewService.getGlowLayerManager().includeMeshes(this.getAllMeshes()):this.previewService.getGlowLayerManager().removeMeshes(this.getAllMeshes())}configureModelInstance(e){var n;if(!this.transformRoot)throw new Error("Transform disposed! This should never happen unless there is a race condition present!");const t=this.transformRoot.position,i=this.transformRoot.rotationQuaternion,s=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=s,this.canvasPanels=((n=this.contextService)==null?void 0:n.getAll())||new Map,Ve(this.materials.concat(this.variantManager.getAllMaterials()),this.scene,this.canvasPanels,this.dynamicTextures,`${this.id}_`),this.enablePicking&&this.attachPickingHandler(e),this.configureGlowLayer()}destroyInstance(){var e;(e=this.modelInstance)==null||e.dispose(),this.modelInstance=void 0}getAllMeshes(){var e;return(e=this.modelInstance)==null?void 0:e.rootNodes.map(t=>t.getChildMeshes(!1).filter(i=>i instanceof Le.Mesh)).flat()}async instantiate(){if(!this.assetContainer)throw new Error("Attempted to instantiate ModelContainer without an AssetContainer");this.modelInstance=this.assetContainer.instantiateModelsToScene(this.renameClonedAsset.bind(this),!0),this.materials=ee(this.modelInstance),this.configureModelInstance(this.modelInstance),this.animations=te(this.modelInstance.animationGroups,this.renameClonedAsset("")),this.initialized=!0,await this.processQueuedEvents()}renameClonedAsset(e){return`${this.id}_${e}`}async setBaseModelEnabled(e){e&&!this.modelInstance?await this.instantiate():!e&&this.modelInstance&&this.destroyInstance()}updateDynamicTextures(){var e;(e=this.canvasPanels)==null||e.forEach((t,i)=>{const s=this.dynamicTextures.get(i);t.getName().toLowerCase()==="crown"&&console.log(t.getName(),s,t.getStaticContextDirty(),s==null?void 0:s.isReady()),s&&t.getStaticContextDirty()&&s.isReady()&&(s.update(!1),t.setStaticContextDirty(!1))})}registerMaterialVariantListener(e){this.materialVariantObservable.add(e)}unregisterMaterialVariantListener(e){this.materialVariantObservable.removeCallback(e)}registerModelVariantListener(e){this.modelVariantObservable.add(e)}unregisterModelVariantListener(e){this.modelVariantObservable.removeCallback(e)}getLastRequestedAnimation(){return this.lastRequestedAnimation}getCurrentAnimationFrame(){var t;const e=[...((t=this.modelInstance)==null?void 0:t.animationGroups)||[],...this.variantManager.getAnimationGroups()];for(const i of e)if(i.animatables.length>0&&i.animatables[0].masterFrame!==void 0&&i.animatables[0].masterFrame!==null)return i.animatables[0].masterFrame;return 0}getAnimationIsPlaying(){var t;const e=[...((t=this.modelInstance)==null?void 0:t.animationGroups)||[],...this.variantManager.getAnimationGroups()];for(const i of e)if(i.isPlaying)return!0;return!1}stripIdFromName(e){return e.substring(this.id.length+1)}async processQueuedEvents(){await Promise.all(Array.from(this.materialReadyToLoadCallbacks.values()).flatMap(e=>Array.from(e.values()).map(t=>t()))),this.materialReadyToLoadCallbacks.clear(),await Promise.all(Array.from(this.modelReadyToLoadCallbacks.values()).map(e=>e())),this.modelReadyToLoadCallbacks.clear(),this.scene.onAfterRenderObservable.addOnce(()=>{this.queuedModelAnimation&&(this.executeAnimation(this.queuedModelAnimation),this.queuedModelAnimation=void 0)})}}class D extends w.ArcRotateCamera{constructor(e,t,i,s,n,o,a,h){super(e,t,i,s,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=V(this._scene);return e.zoomOnBoundingInfo(t.min,t.max),this.wheelPrecision=100/this.radius,this.lowerRadiusLimit===null&&(this.lowerRadiusLimit=.1),this.lastFocus.copyFrom(this.target),e}rerunFramingBehavior(e,t){this._isRunningFramingBehavior=!0,this.framingBehaviourCallback=e;const i=this.getFramingBehavior();i.framingTime=t||800;const s=()=>{this.isRunningFramingBehavior=!1},n=V(this._scene),o=n.max.subtract(n.min),a=n.min.add(o.scale(.5));this.updateRadiusBounds(o.length()*1.5),this.wheelPrecision=100/this.radius,this.panningInertia=0,this.panningOriginTarget.copyFrom(a),this.panDenominator=o.length(),this.lastFocus.copyFrom(a),i.zoomOnBoundingInfo(n.min,n.max,void 0,s),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 s=V(e),n=s.max.subtract(s.min),o=s.min.add(n.scale(.5)),a=new D("ProductCamera",-(Math.PI/2),Math.PI/2,n.length()*1.5,o,e,t);return a.setPanEnabled(((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 V(r){if(r.meshes.length===0)return{min:new p.Vector3(-1,-1,-1),max:new p.Vector3(1,1,1)};const e=r.meshes.filter(t=>t.name.toLowerCase().endsWith("_t")||t.name.toLowerCase().includes("_t_"));return r.getWorldExtends(t=>t.isVisible&&t.isEnabled()&&(e.length===0||e.includes(t)))}class Xe{constructor(e,t=!1,i=void 0){this.renderingPipeline=new Be.DefaultRenderingPipeline("default",t,e,i?[i]:void 0,!1),this.renderingPipeline.isSupported&&(this.renderingPipeline.prepare(),this.setConfiguration(u))}dispose(){this.renderingPipeline.dispose()}getConfiguration(){return this.currentConfiguration}setConfiguration(e){var t,i,s,n,o,a,h,l,c,g,m,b,f,C,y,F,ie,ne,se,re,ae,oe,le,he,ce,de,ue,ge,me,pe,fe,be,ve;if(this.renderingPipeline.isSupported){if(this.renderingPipeline.samples=((t=e.antiAliasing)==null?void 0:t.samples)??u.antiAliasing.samples,this.renderingPipeline.fxaaEnabled=((i=e.antiAliasing)==null?void 0:i.fxaaEnabled)??u.antiAliasing.fxaaEnabled,this.renderingPipeline.bloomEnabled=((s=e.bloom)==null?void 0:s.enabled)??u.bloom.enabled,this.renderingPipeline.bloomKernel=((n=e.bloom)==null?void 0:n.kernel)??u.bloom.kernel,this.renderingPipeline.bloomScale=((o=e.bloom)==null?void 0:o.scale)??u.bloom.scale,this.renderingPipeline.bloomThreshold=((a=e.bloom)==null?void 0:a.threshold)??u.bloom.threshold,this.renderingPipeline.bloomWeight=((h=e.bloom)==null?void 0:h.weight)??u.bloom.weight,this.renderingPipeline.chromaticAberrationEnabled=((l=e.chromaticAberration)==null?void 0:l.enabled)??u.chromaticAberration.enabled,this.renderingPipeline.chromaticAberration.aberrationAmount=((c=e.chromaticAberration)==null?void 0:c.aberrationAmount)??u.chromaticAberration.aberrationAmount,this.renderingPipeline.chromaticAberration.radialIntensity=((g=e.chromaticAberration)==null?void 0:g.radialIntensity)??u.chromaticAberration.radialIntensity,this.renderingPipeline.chromaticAberration.direction=(m=e.chromaticAberration)!=null&&m.direction?new p.Vector2(e.chromaticAberration.direction.x,e.chromaticAberration.direction.y):new p.Vector2(u.chromaticAberration.direction.x,u.chromaticAberration.direction.y),this.renderingPipeline.imageProcessing.colorCurvesEnabled=((b=e.colorCurves)==null?void 0:b.enabled)??u.colorCurves.enabled,this.renderingPipeline.imageProcessing.colorCurves=e.colorCurves?this.updateColorCurve(e.colorCurves):new K.ColorCurves,this.renderingPipeline.depthOfFieldEnabled=((f=e.depthOfField)==null?void 0:f.enabled)??u.depthOfField.enabled,e.depthOfField)switch(e.depthOfField.blurLevel??u.depthOfField.blurLevel){case"Low":this.renderingPipeline.depthOfFieldBlurLevel=q.DepthOfFieldEffectBlurLevel.Low;break;case"Medium":this.renderingPipeline.depthOfFieldBlurLevel=q.DepthOfFieldEffectBlurLevel.Medium;break;case"High":this.renderingPipeline.depthOfFieldBlurLevel=q.DepthOfFieldEffectBlurLevel.High;break}if(this.renderingPipeline.depthOfField.focalLength=((C=e.depthOfField)==null?void 0:C.focalLength)??u.depthOfField.focalLength,this.renderingPipeline.depthOfField.fStop=((y=e.depthOfField)==null?void 0:y.fStop)??u.depthOfField.fStop,this.renderingPipeline.depthOfField.focusDistance=((F=e.depthOfField)==null?void 0:F.focusDistance)??u.depthOfField.focusDistance,this.renderingPipeline.depthOfField.lensSize=((ie=e.depthOfField)==null?void 0:ie.lensSize)??u.depthOfField.lensSize,this.renderingPipeline.grainEnabled=((ne=e.grain)==null?void 0:ne.enabled)??u.grain.enabled,this.renderingPipeline.grain.animated=((se=e.grain)==null?void 0:se.animated)??u.grain.animated,this.renderingPipeline.grain.intensity=((re=e.grain)==null?void 0:re.intensity)??u.grain.intensity,this.renderingPipeline.imageProcessing.contrast=((ae=e.misc)==null?void 0:ae.contrast)??u.misc.contrast,this.renderingPipeline.imageProcessing.exposure=((oe=e.misc)==null?void 0:oe.exposure)??u.misc.exposure,this.renderingPipeline.imageProcessing.toneMappingEnabled=((le=e.misc)==null?void 0:le.toneMappingEnabled)??u.misc.toneMappingEnabled,this.renderingPipeline.imageProcessing.toneMappingEnabled)switch(e.misc.toneMappingType??u.misc.toneMappingType){case"Standard":this.renderingPipeline.imageProcessing.toneMappingType=R.ImageProcessingConfiguration.TONEMAPPING_STANDARD;break;case"ACES":this.renderingPipeline.imageProcessing.toneMappingType=R.ImageProcessingConfiguration.TONEMAPPING_ACES;break}if(this.renderingPipeline.sharpenEnabled=((he=e.sharpen)==null?void 0:he.enabled)??u.sharpen.enabled,this.renderingPipeline.sharpen.colorAmount=((ce=e.sharpen)==null?void 0:ce.colorAmount)??u.sharpen.colorAmount,this.renderingPipeline.sharpen.edgeAmount=((de=e.sharpen)==null?void 0:de.edgeAmount)??u.sharpen.edgeAmount,this.renderingPipeline.imageProcessing.vignetteEnabled=((ue=e.vignette)==null?void 0:ue.enabled)??u.vignette.enabled,(ge=e.vignette)!=null&&ge.center?(this.renderingPipeline.imageProcessing.vignetteCenterX=e.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=e.vignette.center.y):(this.renderingPipeline.imageProcessing.vignetteCenterX=u.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=u.vignette.center.y),e.vignette)switch(((me=e.vignette)==null?void 0:me.blendMode)??u.vignette.blendMode){case"Multiply":this.renderingPipeline.imageProcessing.vignetteBlendMode=R.ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY;break;case"Opaque":this.renderingPipeline.imageProcessing.vignetteBlendMode=R.ImageProcessingConfiguration.VIGNETTEMODE_OPAQUE;break}(pe=e.vignette)!=null&&pe.colorRgba?this.renderingPipeline.imageProcessing.vignetteColor=new v.Color4(e.vignette.colorRgba.r,e.vignette.colorRgba.g,e.vignette.colorRgba.b,e.vignette.colorRgba.a):(fe=e.vignette)!=null&&fe.colorHex?this.renderingPipeline.imageProcessing.vignetteColor=v.Color4.FromHexString(e.vignette.colorHex):this.renderingPipeline.imageProcessing.vignetteColor=new v.Color4(u.vignette.colorRgba.r,u.vignette.colorRgba.g,u.vignette.colorRgba.b,u.vignette.colorRgba.a),this.renderingPipeline.imageProcessing.vignetteStretch=((be=e.vignette)==null?void 0:be.stretch)??u.vignette.stretch,this.renderingPipeline.imageProcessing.vignetteWeight=((ve=e.vignette)==null?void 0:ve.weight)??u.vignette.weight,this.renderingPipeline.prepare(),this.currentConfiguration=e}}updateColorCurve(e){const t=new K.ColorCurves;return t.globalDensity=e.globalDensity??t.globalDensity,t.globalExposure=e.globalExposure??t.globalExposure,t.globalHue=e.globalHue??t.globalHue,t.globalSaturation=e.globalSaturation??t.globalSaturation,t.highlightsDensity=e.highlightsDensity??t.highlightsDensity,t.highlightsExposure=e.highlightsExposure??t.highlightsExposure,t.highlightsHue=e.highlightsHue??t.highlightsHue,t.highlightsSaturation=e.highlightsSaturation??t.highlightsSaturation,t.midtonesDensity=e.midtonesDensity??t.midtonesDensity,t.midtonesExposure=e.midtonesExposure??t.midtonesExposure,t.midtonesHue=e.midtonesHue??t.midtonesHue,t.midtonesSaturation=e.midtonesSaturation??t.midtonesSaturation,t.shadowsDensity=e.shadowsDensity??t.shadowsDensity,t.shadowsExposure=e.shadowsExposure??t.shadowsExposure,t.shadowsHue=e.shadowsHue??t.shadowsHue,t.shadowsSaturation=e.shadowsSaturation??t.shadowsSaturation,t}}Ae.GLTF2.GLTFLoader.RegisterExtension("glbPostProcessor",function(r){return new je(r)}),I.SceneLoader.OnPluginActivatedObservable.add(r=>{if(r.name==="gltf"){const e=r;e.transparencyAsCoverage=!0}});function N(r){return new p.Vector3(r.x,r.y,r.z)}function k(r){return{x:r.x,y:r.y,z:r.z}}class Je{constructor(e){var h;this.focusLostNotified=!1,this.focusLostObservable=new A.Observable,this.modelLoadEventCallbacks=[],this.modelContainers=new Map,this.plugins=[],this.initComplete=!1,this.isAnimatingCamera=!1,this.renderLoop=()=>{if(!this.engine.views)return;this.modelContainers.forEach(g=>{g.updateDynamicTextures()}),this.scene.autoClear=!0,this.scene.autoClearDepthAndStencil=!0;const 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 c=Math.max((this.camera.lowerRadiusLimit??1)*.01,.001);!this.camera.isRunningFramingBehavior&&!this.camera.target.equalsWithEpsilon(this.camera.lastFocus,c)&&!this.focusLostNotified&&(this.focusLostObservable.notifyObservers(void 0),this.focusLostNotified=!0),this.screenshotPrepareResolve&&(this.screenshotPrepareResolve(),this.screenshotPrepareResolve=void 0)},this.configuration=new Q(e);const i=(()=>{if(!(e!=null&&e.noRender))return this.configuration.createCanvas()})(),s="1.5.6";we.DracoCompression.Configuration={decoder:{wasmUrl:`https://www.gstatic.com/draco/versioned/decoders/${s}/draco_wasm_wrapper_gltf.js`,wasmBinaryUrl:`https://www.gstatic.com/draco/versioned/decoders/${s}/draco_decoder_gltf.wasm`,fallbackUrl:`https://www.gstatic.com/draco/versioned/decoders/${s}/draco_decoder_gltf.js`}},i&&(i.getContext("webgl2")||i.getContext("webgl"));const n=console.log;console.log=()=>{};const o=i?new z.Engine(i,!0,{adaptToDeviceRatio:!0,limitDeviceRatio:2,premultipliedAlpha:!1,preserveDrawingBuffer:!!(e!=null&&e.backgroundImage),audioEngine:!1,stencil:this.configuration.highlights.enabled,forceSRGBBufferSupportState:!0}):new Ce.NullEngine;o.enableOfflineSupport=!1,o.doNotHandleContextLost=!0,console.log=n,o.hideLoadingUI(),window.addEventListener("resize",this.fireResizeEvent.bind(this)),this.engine=o,this.scene=new xe.Scene(o),this.camera=D.create(this.scene,this.configuration),this.scene.activeCamera=this.camera,this.renderingPipeline=new Xe(this.scene,!1,this.camera),this.scene.clearColor=this.configuration.scene.clearColor;const a=G.CubeTexture.CreateFromPrefilteredData(this.configuration.scene.environment.file,this.scene);a.name="initial-environment-cube",a.rotationY=this.configuration.scene.environment.rotationY,this.scene.environmentTexture=a,this.scene.environmentIntensity=this.configuration.scene.environment.intensity,(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(E.Pan),this.reattachControls(e)}getNumViewports(){var e;return((e=this.engine.views)==null?void 0:e.length)||0}unregisterView(e){this.engine.unRegisterView(e)}shutdown(){this.plugins.forEach(e=>e.dispose(!0)),this.renderingPipeline.dispose(),this.engine&&this.engine.dispose(),window.removeEventListener("resize",this.fireResizeEvent)}executeCameraAnimation(e){if(!this.camera||this.scene.activeCamera!==this.camera||this.getAllModels().length===0||!this.getAllModels().some(s=>s.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(s=>{t=s})):i()}getCameraPose(){if(this.scene&&this.camera)return{lonDeg:Math.round(this.camera.alpha*180/Math.PI),latDeg:Math.round(this.camera.beta*180/Math.PI),radius:Math.round((this.camera.radius+Number.EPSILON)*1e4)/1e4,target:{x:this.camera.target.x,y:this.camera.target.y,z:this.camera.target.z}}}setCameraPose(e){this.scene&&this.camera&&(this.camera.target=new p.Vector3(e.target.x,e.target.y,e.target.z),this.camera.radius=e.radius,this.camera.alpha=e.latDeg,this.camera.beta=e.lonDeg)}setCameraState(e){var t,i;if(!((t=this.engine)!=null&&t.views)||!((i=this.engine)!=null&&i.views[0]))throw new Error("No views attached, camera state requires a view to attach controls onto.");e===E.Orbit?this.reattachControls(this.engine.views[0].target,2):this.reattachControls(this.engine.views[0].target,0)}animateToLastCameraFocus(){let e=()=>{};const t=async()=>{this.isAnimatingCamera=!0,await new Promise(i=>{this.focusLostNotified=!1;const s=()=>{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(s)}),this.isAnimatingCamera=!1,this.queuedAnimationFunction&&this.queuedAnimationFunction(),this.queuedAnimationFunction=void 0,e()};return this.isAnimatingCamera?(this.queuedAnimationFunction=t,new Promise(i=>{e=i})):t()}forceStopCameraAnimations(){var e;this.queuedAnimationFunction=void 0,this.queuedCameraAnimation=void 0,this.isAnimatingCamera=!1,(e=this.camera.framingBehavior)==null||e.stopAllAnimations(),this.scene.stopAnimation(this.camera)}setAutoRotation(e){!this.configuration.camera.autoRotation.enabled||!this.camera||(e?this.camera.enableAutoRotationBehavior(this.configuration.camera.autoRotation.idleTimeMs):this.camera.disableAutoRotationBehavior())}getCurrentConfiguration(){return this.configuration.options}async renderSceneScreenshot(e,t){if(!this.camera)throw new Error("Missing product camera, cannot render screenshot!");const i=new w.ArcRotateCamera("screenshotCamera",0,0,0,p.Vector3.Zero(),this.scene);try{const s=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=s,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,s=e.camera.limits.min.beta,n=e.camera.limits.max.beta;if(t===void 0||i===void 0||s===void 0||n===void 0)return!0;const o=[t,i],a=[s,n],h=o.every(c=>c===t),l=a.every(c=>c===s);return!h&&!l}fireResizeEvent(){this.getNumViewports()>0&&this.engine.resize()}setHighlights(e,t){var s;e.length===0&&((s=this.highlightLayer)==null||s.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:s}=t??{},n=new _e({enablePicking:this.configuration.highlights.enabled,modelDetails:e,scene:this.scene,previewService:this,progressHandler:s});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(s=>s.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 s=p.Matrix.Compose(N(i||{x:1,y:1,z:1}),p.Quaternion.FromEulerVector(N(t||{x:0,y:0,z:0})),N(e||{x:0,y:0,z:0})),n=p.Matrix.RotationAxis(p.Vector3.Up(),Math.PI),o=s.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 s,n;const t=new Q(e);this.configuration.highlights.enabled!==t.highlights.enabled&&this.engine.setStencilBuffer(t.highlights.enabled),this.scene.clearColor=t.scene.clearColor;let i=this.scene.environmentTexture;this.configuration.scene.environment.file!==t.scene.environment.file&&(i=G.CubeTexture.CreateFromPrefilteredData(t.scene.environment.file,this.scene),i.name="updated-environment-cube",i.rotationY=this.configuration.scene.environment.rotationY,this.scene.environmentTexture=i),i.rotationY=t.scene.environment.rotationY,this.scene.environmentIntensity=t.scene.environment.intensity,(s=t.options)!=null&&s.renderingPipelineConfiguration?this.renderingPipeline.setConfiguration(t.options.renderingPipelineConfiguration):(this.scene.imageProcessingConfiguration.exposure=t.lighting.exposure,this.scene.imageProcessingConfiguration.contrast=t.lighting.contrast),this.glowLayerManager.setIntensity(t.emissiveGlowIntensity),this.camera.updateConfiguration(t),this.camera.setPanEnabled(((n=t.options)==null?void 0:n.noPan)!==void 0?!t.options.noPan:!0),this.configuration=t}reattachControls(e,t=2){if(this.scene.detachControl(),this.engine.inputElement=e,this.camera){this.camera.attachControl(!0,!1,t);const i=this.camera.inputs.attached.pointers;i.multiTouchPanning=!1}this.scene.attachControl(!0,!0,!0)}}d.MaterialEffectMode=L,d.ProductCameraRig=E,d.REFLECTION_PROBE_RESOLUTION=Y,d.RenderingConfiguration=x,d.SpiffCommerce3DPreviewService=Je,d.renderingPipelineDefaults=u,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spiffcommerce/preview",
3
- "version": "5.8.7",
3
+ "version": "5.8.8-alpha.0",
4
4
  "description": "An internal implementation of the ThreeDPreviewService interface used by Spiff Commerce",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/index.umd.js",