@spiffcommerce/preview 5.3.9-rc.4 → 5.3.9-rc.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -979,7 +979,10 @@ declare class ProductCamera extends ArcRotateCamera {
979
979
  * via panning we can notify ui about the fact to help users reset the camera.
980
980
  */
981
981
  readonly lastFocus: Vector3;
982
- isRunningFramingBehavior: boolean;
982
+ get isRunningFramingBehavior(): boolean;
983
+ set isRunningFramingBehavior(value: boolean);
984
+ private _isRunningFramingBehavior;
985
+ private framingBehaviourCallback?;
983
986
  private panDenominator;
984
987
  /**
985
988
  * Returns the framing behavior of this camera.
package/dist/index.esm.js CHANGED
@@ -5,7 +5,7 @@ import { HighlightLayer as Ce } from "@babylonjs/core/Layers/highlightLayer";
5
5
  import { SceneLoader as S } from "@babylonjs/core/Loading/sceneLoader";
6
6
  import { CubeTexture as ie } from "@babylonjs/core/Materials/Textures/cubeTexture";
7
7
  import { Color4 as b, Color3 as w } from "@babylonjs/core/Maths/math.color";
8
- import { Vector3 as g, Quaternion as y, Vector2 as se, Matrix as ne } from "@babylonjs/core/Maths/math.vector";
8
+ import { Vector3 as g, Quaternion as y, Vector2 as ne, Matrix as se } from "@babylonjs/core/Maths/math.vector";
9
9
  import { DracoCompression as ye } from "@babylonjs/core/Meshes/Compression/dracoCompression";
10
10
  import { Observable as C } from "@babylonjs/core/Misc/observable";
11
11
  import { Tools as Me } from "@babylonjs/core/Misc/tools";
@@ -40,12 +40,12 @@ 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 I = /* @__PURE__ */ ((s) => (s[s.Orbit = 0] = "Orbit", s[s.Pan = 1] = "Pan", s))(I || {}), F = /* @__PURE__ */ ((s) => (s.None = "None", s.RemoveWhenSelected = "RemoveWhenSelected", s.ApplyWhenSelected = "ApplyWhenSelected", s))(F || {});
43
+ var I = /* @__PURE__ */ ((n) => (n[n.Orbit = 0] = "Orbit", n[n.Pan = 1] = "Pan", n))(I || {}), F = /* @__PURE__ */ ((n) => (n.None = "None", n.RemoveWhenSelected = "RemoveWhenSelected", n.ApplyWhenSelected = "ApplyWhenSelected", n))(F || {});
44
44
  class le {
45
45
  constructor(e) {
46
46
  this.getSceneClearColor = () => {
47
- var i, n, a, o;
48
- const t = (i = this.customOptions) != null && i.transparentBackground || (n = this.customOptions) != null && n.backgroundImage ? 0 : 1;
47
+ var i, s, a, o;
48
+ const t = (i = this.customOptions) != null && i.transparentBackground || (s = this.customOptions) != null && s.backgroundImage ? 0 : 1;
49
49
  if (this.customOptions && ((a = this.customOptions) != null && a.transparentBackground) || (o = this.customOptions) != null && o.backgroundImage)
50
50
  return new b(0, 0, 0, t).toLinearSpace();
51
51
  if (this.customOptions && this.customOptions.backgroundColor) {
@@ -61,11 +61,11 @@ class le {
61
61
  }
62
62
  return new b(0.98, 0.98, 0.98, t).toLinearSpace();
63
63
  }, this.highlightColorFromConfig = () => this.customOptions && this.customOptions.highlightColor ? this.hexToColor4(this.customOptions.highlightColor) : new b(0.98, 0.98, 0.98, 1).toLinearSpace(), this.hexToColor4 = (t, i = 1) => {
64
- const n = w.FromHexString(t);
64
+ const s = w.FromHexString(t);
65
65
  return new b(
66
- n.r,
67
- n.g,
68
- n.b,
66
+ s.r,
67
+ s.g,
68
+ s.b,
69
69
  i
70
70
  ).toLinearSpace();
71
71
  }, this.customOptions = e;
@@ -81,13 +81,13 @@ class le {
81
81
  * Configuration related to the scene
82
82
  */
83
83
  get scene() {
84
- var e, t, i, n, a;
84
+ var e, t, i, s, a;
85
85
  return {
86
86
  clearColor: this.getSceneClearColor(),
87
87
  transparentBackground: ((e = this.customOptions) == null ? void 0 : e.transparentBackground) || ((t = this.customOptions) == null ? void 0 : t.backgroundImage),
88
88
  environment: {
89
89
  file: ((i = this.customOptions) == null ? void 0 : i.environmentFile) ?? "assets/model-viewer/default.env",
90
- intensity: ((n = this.customOptions) == null ? void 0 : n.environmentIntensity) ?? 1,
90
+ intensity: ((s = this.customOptions) == null ? void 0 : s.environmentIntensity) ?? 1,
91
91
  rotationY: (((a = this.customOptions) == null ? void 0 : a.environmentRotationY) ?? 0) * (Math.PI / 180)
92
92
  // Convert to radians
93
93
  }
@@ -97,7 +97,7 @@ class le {
97
97
  * Configuration related to the camera used to view and interact with the scene.
98
98
  */
99
99
  get camera() {
100
- var e, t, i, n, a, o, r, l, d, h, u, m, p;
100
+ var e, t, i, s, a, o, r, l, d, h, u, m, p;
101
101
  return {
102
102
  autoOrientation: ((e = this.customOptions) == null ? void 0 : e.disableAutomaticOrientation) ?? !0,
103
103
  autoRotation: {
@@ -106,7 +106,7 @@ class le {
106
106
  },
107
107
  limits: {
108
108
  min: {
109
- alpha: (n = this.customOptions) != null && n.lowerAlphaLimitDeg ? ((a = this.customOptions) == null ? void 0 : a.lowerAlphaLimitDeg) * Math.PI / 180 : void 0,
109
+ alpha: (s = this.customOptions) != null && s.lowerAlphaLimitDeg ? ((a = this.customOptions) == null ? void 0 : a.lowerAlphaLimitDeg) * Math.PI / 180 : void 0,
110
110
  beta: (o = this.customOptions) != null && o.lowerBetaLimitDeg ? ((r = this.customOptions) == null ? void 0 : r.lowerBetaLimitDeg) * Math.PI / 180 : void 0,
111
111
  radius: (l = this.customOptions) == null ? void 0 : l.minZoomOverride
112
112
  },
@@ -130,10 +130,10 @@ class le {
130
130
  };
131
131
  }
132
132
  get lighting() {
133
- var e, t, i, n;
133
+ var e, t, i, s;
134
134
  return {
135
135
  exposure: ((t = (e = this.customOptions) == null ? void 0 : e.lighting) == null ? void 0 : t.exposure) ?? 0.9,
136
- contrast: ((n = (i = this.customOptions) == null ? void 0 : i.lighting) == null ? void 0 : n.contrast) ?? 1.6
136
+ contrast: ((s = (i = this.customOptions) == null ? void 0 : i.lighting) == null ? void 0 : s.contrast) ?? 1.6
137
137
  };
138
138
  }
139
139
  get emissiveGlowIntensity() {
@@ -254,11 +254,11 @@ class Ne {
254
254
  return this.loader.loadNodeAsync(
255
255
  e,
256
256
  t,
257
- function(n) {
257
+ function(s) {
258
258
  t.extras && Object.keys(t.extras).forEach((a) => {
259
259
  const o = t.extras[a];
260
- n.metadata[a] = o;
261
- }), i(n);
260
+ s.metadata[a] = o;
261
+ }), i(s);
262
262
  }
263
263
  );
264
264
  }
@@ -350,7 +350,7 @@ class Ne {
350
350
  );
351
351
  l.mirrorPlane = m, l.level = o, r.reflectionTexture = l;
352
352
  }
353
- function n(a) {
353
+ function s(a) {
354
354
  const o = a.material, r = new Ee(
355
355
  "probe-" + o.name,
356
356
  qe,
@@ -360,7 +360,7 @@ class Ne {
360
360
  }
361
361
  e.meshes.forEach((a) => {
362
362
  const o = a.metadata;
363
- o && (o.mirrorTexture && i(a, o.mirrorTexture), o.reflectionProbe && n(a));
363
+ o && (o.mirrorTexture && i(a, o.mirrorTexture), o.reflectionProbe && s(a));
364
364
  });
365
365
  }
366
366
  }
@@ -387,32 +387,32 @@ class Ge {
387
387
  }
388
388
  }
389
389
  const he = /* @__PURE__ */ new Map();
390
- async function be(s, e, t) {
391
- const i = he.get(s);
390
+ async function be(n, e, t) {
391
+ const i = he.get(n);
392
392
  if (i && i.scene.uid === e.uid)
393
393
  return i;
394
394
  {
395
- const n = await S.LoadAssetContainerAsync(
396
- s,
395
+ const s = await S.LoadAssetContainerAsync(
396
+ n,
397
397
  void 0,
398
398
  e,
399
399
  t
400
400
  );
401
- return he.set(s, n), n;
401
+ return he.set(n, s), s;
402
402
  }
403
403
  }
404
- S.OnPluginActivatedObservable.add((s) => {
405
- s.name === "gltf" && (s.animationStartMode = Fe.NONE);
404
+ S.OnPluginActivatedObservable.add((n) => {
405
+ n.name === "gltf" && (n.animationStartMode = Fe.NONE);
406
406
  });
407
- function He(s, e, t, i, n = "") {
407
+ function _e(n, e, t, i, s = "") {
408
408
  t.forEach((a) => {
409
409
  const o = a.getID(), r = a.getName(), l = x.getDynamicTextureResolution();
410
- s.filter((h) => h.name === n + r).forEach((h) => {
410
+ n.filter((h) => h.name === s + r).forEach((h) => {
411
411
  const u = i.get(o), m = !1;
412
412
  if (u)
413
413
  ce(h, u), u.update(m);
414
414
  else {
415
- const p = _e(
415
+ const p = He(
416
416
  r,
417
417
  e,
418
418
  l.width,
@@ -427,38 +427,38 @@ function He(s, e, t, i, n = "") {
427
427
  });
428
428
  });
429
429
  }
430
- function _e(s, e, t, i) {
431
- const n = new Se(
432
- s,
430
+ function He(n, e, t, i) {
431
+ const s = new Se(
432
+ n,
433
433
  { width: t, height: i },
434
434
  e,
435
435
  x.shouldMipMap(),
436
436
  Be.TRILINEAR_SAMPLINGMODE,
437
437
  fe.TEXTUREFORMAT_RGBA
438
- ), a = n.getContext();
439
- return a && (a.fillStyle = "#f5f5f5", a.fillRect(0, 0, t, i), n.update()), n;
438
+ ), a = s.getContext();
439
+ return a && (a.fillStyle = "#f5f5f5", a.fillRect(0, 0, t, i), s.update()), s;
440
440
  }
441
- function ce(s, e) {
442
- if (s instanceof B) {
443
- const t = s, i = t.albedoTexture;
441
+ function ce(n, e) {
442
+ if (n instanceof B) {
443
+ const t = n, i = t.albedoTexture;
444
444
  i ? (e.wrapU = i.wrapU, e.wrapV = i.wrapV) : (e.wrapU = 1, e.wrapV = 1), t.albedoTexture = e;
445
445
  } else {
446
- const t = s, i = t.diffuseTexture;
446
+ const t = n, i = t.diffuseTexture;
447
447
  i && (e.wrapU = i.wrapU, e.wrapV = i.wrapV), t.diffuseTexture = e;
448
448
  }
449
449
  }
450
450
  function Ke() {
451
- const s = () => Math.floor((1 + Math.random()) * 65536).toString(16).substring(1);
452
- return s() + s() + "-" + s() + "-" + s() + "-" + s() + "-" + s() + s() + s();
451
+ const n = () => Math.floor((1 + Math.random()) * 65536).toString(16).substring(1);
452
+ return n() + n() + "-" + n() + "-" + n() + "-" + n() + "-" + n() + n() + n();
453
453
  }
454
454
  const M = 60, de = 1;
455
- function ue(s) {
456
- return s.targetedAnimations.map((t) => t.animation.framePerSecond).reduce((t, i) => t + i, 0) / s.targetedAnimations.length || 0;
455
+ function ue(n) {
456
+ return n.targetedAnimations.map((t) => t.animation.framePerSecond).reduce((t, i) => t + i, 0) / n.targetedAnimations.length || 0;
457
457
  }
458
- function We(s, e, t, i, n, a) {
459
- const o = n ? s.filter((h) => h.name === n) : s;
458
+ function Ue(n, e, t, i, s, a) {
459
+ const o = s ? n.filter((h) => h.name === s) : n;
460
460
  if (o.length === 0) {
461
- console.warn(`No animations found for name: ${n}`);
461
+ console.warn(`No animations found for name: ${s}`);
462
462
  return;
463
463
  }
464
464
  let r = 0;
@@ -483,16 +483,16 @@ function We(s, e, t, i, n, a) {
483
483
  d(h, e, de, m, p);
484
484
  });
485
485
  }
486
- function Ue(s) {
487
- s.forEach((e) => {
486
+ function We(n) {
487
+ n.forEach((e) => {
488
488
  e.reset(), e.stop();
489
489
  });
490
490
  }
491
- function Ye(s, e, t) {
491
+ function Ye(n, e, t) {
492
492
  return new Promise((i) => {
493
- s.stopAnimation(e), e.animations = [], Math.abs(e.alpha) > 2 * Math.PI && (e.alpha = Qe(e.alpha, 0, 2 * Math.PI));
494
- const n = [], a = t.target, o = 0, r = a ? 1 : 0;
495
- if (t.target && Object.keys(t.target).length > 0 && n.push(
493
+ n.stopAnimation(e), e.animations = [], Math.abs(e.alpha) > 2 * Math.PI && (e.alpha = Qe(e.alpha, 0, 2 * Math.PI));
494
+ const s = [], a = t.target, o = 0, r = a ? 1 : 0;
495
+ if (t.target && Object.keys(t.target).length > 0 && s.push(
496
496
  A(
497
497
  "cameraTargetLerp",
498
498
  "target",
@@ -505,7 +505,7 @@ function Ye(s, e, t) {
505
505
  v.ANIMATIONTYPE_VECTOR3,
506
506
  o
507
507
  )
508
- ), n.push(
508
+ ), s.push(
509
509
  A(
510
510
  "cameraAlphaLerp",
511
511
  "alpha",
@@ -514,7 +514,7 @@ function Ye(s, e, t) {
514
514
  v.ANIMATIONTYPE_FLOAT,
515
515
  r
516
516
  )
517
- ), n.push(
517
+ ), s.push(
518
518
  A(
519
519
  "cameraBetaLerp",
520
520
  "beta",
@@ -525,7 +525,7 @@ function Ye(s, e, t) {
525
525
  )
526
526
  ), t.radius !== void 0) {
527
527
  const h = Math.max(0.01, t.radius);
528
- n.push(
528
+ s.push(
529
529
  A(
530
530
  "cameraRadiusLerp",
531
531
  "radius",
@@ -536,9 +536,9 @@ function Ye(s, e, t) {
536
536
  )
537
537
  );
538
538
  }
539
- e.animations.push(...n);
539
+ e.animations.push(...s);
540
540
  const d = e.useAutoRotationBehavior;
541
- e.disableAutoRotationBehavior(), s.beginAnimation(
541
+ e.disableAutoRotationBehavior(), n.beginAnimation(
542
542
  e,
543
543
  0,
544
544
  a ? M * 2 : M,
@@ -550,17 +550,17 @@ function Ye(s, e, t) {
550
550
  );
551
551
  });
552
552
  }
553
- function me(s) {
554
- return s * Math.PI / 180;
553
+ function me(n) {
554
+ return n * Math.PI / 180;
555
555
  }
556
- function A(s, e, t, i, n, a = 0, o = v.ANIMATIONLOOPMODE_CONSTANT) {
556
+ function A(n, e, t, i, s, a = 0, o = v.ANIMATIONLOOPMODE_CONSTANT) {
557
557
  const r = new De();
558
558
  r.setEasingMode(ke.EASINGMODE_EASEINOUT);
559
559
  const l = new v(
560
- s,
560
+ n,
561
561
  e,
562
562
  M,
563
- n,
563
+ s,
564
564
  o
565
565
  ), d = [];
566
566
  return a > 0 && d.push({ frame: 0, value: t }), d.push({ frame: M * a, value: t }), d.push({
@@ -568,8 +568,8 @@ function A(s, e, t, i, n, a = 0, o = v.ANIMATIONLOOPMODE_CONSTANT) {
568
568
  value: i
569
569
  }), l.setKeys(d), l.setEasingFunction(r), l;
570
570
  }
571
- function Qe(s, e, t) {
572
- return s < e ? s = t - (e - s) % (t - e) : s = e + (s - e) % (t - e);
571
+ function Qe(n, e, t) {
572
+ return n < e ? n = t - (e - n) % (t - e) : n = e + (n - e) % (t - e);
573
573
  }
574
574
  const Ze = {
575
575
  albedoTexture: "albedoMap",
@@ -581,7 +581,7 @@ const Ze = {
581
581
  refractionTexture: "refractionMap",
582
582
  reflectionTexture: "reflectionMap"
583
583
  };
584
- function $e(s, e, t, i) {
584
+ function $e(n, e, t, i) {
585
585
  [
586
586
  "albedoTexture",
587
587
  "bumpTexture",
@@ -594,46 +594,46 @@ function $e(s, e, t, i) {
594
594
  ].forEach((a) => {
595
595
  je(
596
596
  a,
597
- s,
597
+ n,
598
598
  e,
599
599
  t,
600
600
  i
601
601
  );
602
- }), et(s, e);
602
+ }), et(n, e);
603
603
  }
604
- function je(s, e, t, i, n) {
605
- const a = Ze[s];
604
+ function je(n, e, t, i, s) {
605
+ const a = Ze[n];
606
606
  if (!a)
607
607
  throw new Error("Unexpected texture name encountered.");
608
608
  const o = e[a], r = o == null ? void 0 : o.fileLink;
609
- r ? s === "reflectionTexture" ? r.endsWith(".env") || r.endsWith(".dds") ? i.addCubeTextureTask(
610
- s,
609
+ r ? n === "reflectionTexture" ? r.endsWith(".env") || r.endsWith(".dds") ? i.addCubeTextureTask(
610
+ n,
611
611
  r,
612
612
  void 0,
613
613
  !1,
614
614
  void 0,
615
615
  !0
616
616
  ) : r.endsWith(".hdr") ? i.addHDRCubeTextureTask(
617
- s,
617
+ n,
618
618
  r,
619
619
  128,
620
620
  !1,
621
621
  !0,
622
622
  !1
623
- ) : i.addTextureTask(s, r, !1, !1) : i.addTextureTask(s, r, !1, !1) : n && t[s] && (t[s] && t[s].dispose(), t[s] = null, Xe(s, t));
623
+ ) : i.addTextureTask(n, r, !1, !1) : i.addTextureTask(n, r, !1, !1) : s && t[n] && (t[n] && t[n].dispose(), t[n] = null, Xe(n, t));
624
624
  }
625
- function Xe(s, e) {
626
- 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 w(0, 0, 0), e.reflectionTexture);
625
+ function Xe(n, e) {
626
+ n === "opacityTexture" && (e.useAlphaFromAlbedoTexture = !0), n === "metallicTexture" && (e.useRoughnessFromMetallicTextureAlpha = !1, e.useRoughnessFromMetallicTextureGreen = !1, e.useMetallnessFromMetallicTextureBlue = !1), n === "refractionTexture" && (e.subSurface.isRefractionEnabled = !1, e.subSurface.refractionIntensity = 1), n === "reflectionTexture" && (e.environmentIntensity = 1), n === "emissiveTexture" && (e.emissiveIntensity = 0, e.emissiveColor = new w(0, 0, 0), e.reflectionTexture);
627
627
  }
628
- function Je(s, e, t, i) {
628
+ function Je(n, e, t, i) {
629
629
  if (!e) {
630
630
  console.error("Failed to apply texture to material: material is null.");
631
631
  return;
632
632
  }
633
- 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 w(1, 1, 1), e.emissiveIntensity = 1);
633
+ n === "opacityTexture" && (e.useAlphaFromAlbedoTexture = !1), n === "metallicTexture" && (e.useRoughnessFromMetallicTextureAlpha = !1, e.useRoughnessFromMetallicTextureGreen = !0, e.useMetallnessFromMetallicTextureBlue = !0), n === "refractionTexture" && (e.subSurface.isRefractionEnabled = !0, e.subSurface.refractionIntensity = t.refractionIntensity || 1), n === "reflectionTexture" && (e.environmentIntensity = t.reflectionIntensity || 1, i.isCube && (i.rotationY = t.reflectionRotation ? t.reflectionRotation * Math.PI / 180 : 0)), e[n] = i, n === "emissiveTexture" && (e.emissiveColor = new w(1, 1, 1), e.emissiveIntensity = 1);
634
634
  }
635
- function et(s, e) {
636
- s.clearCoat && (s.clearCoat === F.RemoveWhenSelected ? (e.clearCoat.isEnabled = !1, e.clearCoat.indexOfRefraction = 1.5) : s.clearCoat === F.ApplyWhenSelected && (e.clearCoat.isEnabled = !0, e.clearCoat.indexOfRefraction = s.clearCoatIOR || e.clearCoat.indexOfRefraction));
635
+ function et(n, e) {
636
+ n.clearCoat && (n.clearCoat === F.RemoveWhenSelected ? (e.clearCoat.isEnabled = !1, e.clearCoat.indexOfRefraction = 1.5) : n.clearCoat === F.ApplyWhenSelected && (e.clearCoat.isEnabled = !0, e.clearCoat.indexOfRefraction = n.clearCoatIOR || e.clearCoat.indexOfRefraction));
637
637
  }
638
638
  class tt {
639
639
  constructor(e, t, i) {
@@ -648,7 +648,7 @@ class tt {
648
648
  * instead remove material textures when they aren't defined. this is useful for material editor applications
649
649
  * where we want to undo changes are remove effects from display.
650
650
  */
651
- async applyMaterial(e, t, i, n) {
651
+ async applyMaterial(e, t, i, s) {
652
652
  return new Promise((a) => {
653
653
  const o = this.materialVariantMap.get(e);
654
654
  this.materialVariantMap.set(e, {
@@ -668,7 +668,7 @@ class tt {
668
668
  t,
669
669
  h,
670
670
  d,
671
- n
671
+ s
672
672
  )
673
673
  ), d.onProgress = (h, u, m) => {
674
674
  i && i(h / u * 100, 100, m.name);
@@ -696,13 +696,13 @@ class tt {
696
696
  * @param model The details for the new model, when undefined we should remove the variant associated to the given key.
697
697
  * @param onProgress A load progress callback that can be used for loading bars and event timing.
698
698
  */
699
- async applyModel(e, t, i, n) {
699
+ async applyModel(e, t, i, s) {
700
700
  var l, d;
701
701
  if (i && t && !this.keysThatRemovedBaseModel.includes(e) && this.keysThatRemovedBaseModel.push(e), !i)
702
702
  return this.keysThatRemovedBaseModel.includes(e) && this.keysThatRemovedBaseModel.length === 1 && await this.setBaseModelEnabled(!0), (l = this.loadedContainerForKey.get(e)) == null || l.dispose(), this.loadedContainerForKey.delete(e), this.loadedMaterialsForKey.delete(e), this.keysThatRemovedBaseModel = this.keysThatRemovedBaseModel.filter(
703
703
  (h) => h !== e
704
704
  ), Promise.resolve(void 0);
705
- const o = (await be(i, this.scene, n)).instantiateModelsToScene(
705
+ const o = (await be(i, this.scene, s)).instantiateModelsToScene(
706
706
  this.renameClonedAsset,
707
707
  !0
708
708
  );
@@ -732,19 +732,19 @@ class tt {
732
732
  }), e;
733
733
  }
734
734
  }
735
- function ve(s) {
735
+ function ve(n) {
736
736
  const e = [];
737
- return s.rootNodes.forEach((t) => {
737
+ return n.rootNodes.forEach((t) => {
738
738
  t.getChildMeshes().forEach((i) => {
739
- i.material && !e.includes(i.material) && e.push(i.material), i.subMeshes && i.subMeshes.forEach((n) => {
740
- const a = n.getMaterial(!1);
739
+ i.material && !e.includes(i.material) && e.push(i.material), i.subMeshes && i.subMeshes.forEach((s) => {
740
+ const a = s.getMaterial(!1);
741
741
  a && !e.includes(a) && e.push(a);
742
742
  });
743
743
  });
744
744
  }), e;
745
745
  }
746
- function ge(s, e = "") {
747
- return s.map((t) => ({
746
+ function ge(n, e = "") {
747
+ return n.map((t) => ({
748
748
  name: t.name.substring(e.length),
749
749
  loop: t.loopAnimation,
750
750
  to: t.to,
@@ -757,11 +757,11 @@ class it {
757
757
  const {
758
758
  enablePicking: t,
759
759
  modelDetails: i,
760
- previewService: n,
760
+ previewService: s,
761
761
  progressHandler: a,
762
762
  scene: o
763
763
  } = e;
764
- this.enablePicking = t, this.contextService = i.contextService, this.id = Ke(), this.previewService = n, this.scene = o, this.variantManager = new tt(
764
+ this.enablePicking = t, this.contextService = i.contextService, this.id = Ke(), this.previewService = s, this.scene = o, this.variantManager = new tt(
765
765
  o,
766
766
  this.renameClonedAsset.bind(this),
767
767
  this.setBaseModelEnabled.bind(this)
@@ -780,7 +780,7 @@ class it {
780
780
  this.importPromise = r();
781
781
  }
782
782
  //#region Interface implementation
783
- async applyMaterialVariant(e, t, i, n) {
783
+ async applyMaterialVariant(e, t, i, s) {
784
784
  if (!this.initialized) {
785
785
  if (this.materialReadyToLoadCallbacks.has(e)) {
786
786
  const o = this.materialReadyToLoadCallbacks.get(e);
@@ -791,7 +791,7 @@ class it {
791
791
  e,
792
792
  t,
793
793
  i,
794
- n
794
+ s
795
795
  )
796
796
  );
797
797
  } else {
@@ -807,7 +807,7 @@ class it {
807
807
  e,
808
808
  t,
809
809
  i,
810
- n
810
+ s
811
811
  )
812
812
  );
813
813
  }
@@ -824,7 +824,7 @@ class it {
824
824
  taskName: l
825
825
  });
826
826
  },
827
- n
827
+ s
828
828
  );
829
829
  };
830
830
  if (this.materialChangesInProgress.includes(e)) {
@@ -867,7 +867,7 @@ class it {
867
867
  );
868
868
  return;
869
869
  }
870
- const n = () => this.variantManager.applyModel(
870
+ const s = () => this.variantManager.applyModel(
871
871
  e,
872
872
  i,
873
873
  t == null ? void 0 : t.model,
@@ -879,12 +879,12 @@ class it {
879
879
  }
880
880
  );
881
881
  if (this.modelChangesInProgress.includes(e)) {
882
- this.queuedModelChanges.set(e, n);
882
+ this.queuedModelChanges.set(e, s);
883
883
  return;
884
884
  }
885
885
  const o = await (async () => {
886
886
  this.modelChangesInProgress.push(e);
887
- let r = await n();
887
+ let r = await s();
888
888
  if (this.queuedModelChanges.has(e)) {
889
889
  const l = this.queuedModelChanges.get(e);
890
890
  if (!l)
@@ -896,7 +896,7 @@ class it {
896
896
  1
897
897
  ), r;
898
898
  })();
899
- this.modelInstance && Ue(this.modelInstance.animationGroups), this.contextService || (this.contextService = t == null ? void 0 : t.contextService), o ? this.configureModelInstance(o) : this.configureGlowLayer();
899
+ this.modelInstance && We(this.modelInstance.animationGroups), this.contextService || (this.contextService = t == null ? void 0 : t.contextService), o ? this.configureModelInstance(o) : this.configureGlowLayer();
900
900
  }
901
901
  dispose() {
902
902
  var e;
@@ -910,8 +910,8 @@ class it {
910
910
  let t = () => {
911
911
  };
912
912
  const i = async () => {
913
- this.isExecutingAnimation = !0, await new Promise((n) => {
914
- We(
913
+ this.isExecutingAnimation = !0, await new Promise((s) => {
914
+ Ue(
915
915
  [
916
916
  ...this.modelInstance.animationGroups,
917
917
  ...this.variantManager.getAnimationGroups()
@@ -920,12 +920,12 @@ class it {
920
920
  e.to,
921
921
  e.from,
922
922
  e.name ? this.renameClonedAsset(e.name) : void 0,
923
- n
923
+ s
924
924
  );
925
925
  }), this.isExecutingAnimation = !1, this.queuedAnimationFunction && this.queuedAnimationFunction(), this.queuedAnimationFunction = void 0, t();
926
926
  };
927
- return this.isExecutingAnimation ? (this.queuedAnimationFunction = i, new Promise((n) => {
928
- t = n;
927
+ return this.isExecutingAnimation ? (this.queuedAnimationFunction = i, new Promise((s) => {
928
+ t = s;
929
929
  })) : i();
930
930
  }
931
931
  getAnimations(e) {
@@ -1003,8 +1003,8 @@ class it {
1003
1003
  e.rootNodes.forEach((t) => {
1004
1004
  t.getChildMeshes(!1).forEach((i) => {
1005
1005
  i.name === "targetcube_t" || i.name === "backgroundShell" || (i.actionManager || (i.actionManager = new R(this.scene)), i.actionManager.registerAction(
1006
- new ae(R.OnPointerOverTrigger, (n) => {
1007
- n.meshUnderPointer && i.material && this.materialSelectedObservable.notifyObservers({
1006
+ new ae(R.OnPointerOverTrigger, (s) => {
1007
+ s.meshUnderPointer && i.material && this.materialSelectedObservable.notifyObservers({
1008
1008
  id: i.material.id,
1009
1009
  name: this.stripIdFromName(i.material.name)
1010
1010
  });
@@ -1048,11 +1048,11 @@ class it {
1048
1048
  throw new Error(
1049
1049
  "Transform disposed! This should never happen unless there is a race condition present!"
1050
1050
  );
1051
- const t = this.transformRoot.position, i = this.transformRoot.rotationQuaternion, n = this.transformRoot.scaling;
1051
+ const t = this.transformRoot.position, i = this.transformRoot.rotationQuaternion, s = this.transformRoot.scaling;
1052
1052
  this.transformRoot.position = g.Zero(), this.transformRoot.rotationQuaternion = y.Identity(), this.transformRoot.scaling = g.One();
1053
1053
  for (const o of e.rootNodes)
1054
1054
  o.parent = this.transformRoot;
1055
- this.transformRoot.position = t, this.transformRoot.rotationQuaternion = i, this.transformRoot.scaling = n, this.canvasPanels = ((a = this.contextService) == null ? void 0 : a.getAll()) || /* @__PURE__ */ new Map(), He(
1055
+ this.transformRoot.position = t, this.transformRoot.rotationQuaternion = i, this.transformRoot.scaling = s, this.canvasPanels = ((a = this.contextService) == null ? void 0 : a.getAll()) || /* @__PURE__ */ new Map(), _e(
1056
1056
  this.materials.concat(this.variantManager.getAllMaterials()),
1057
1057
  this.scene,
1058
1058
  this.canvasPanels,
@@ -1096,8 +1096,8 @@ class it {
1096
1096
  var e;
1097
1097
  (e = this.canvasPanels) == null || e.forEach(
1098
1098
  (t, i) => {
1099
- const n = this.dynamicTextures.get(i);
1100
- n && t.getStaticContextDirty() && n.isReady() && (n.update(!1), t.setStaticContextDirty(!1));
1099
+ const s = this.dynamicTextures.get(i);
1100
+ s && t.getStaticContextDirty() && s.isReady() && (s.update(!1), t.setStaticContextDirty(!1));
1101
1101
  }
1102
1102
  );
1103
1103
  }
@@ -1134,19 +1134,25 @@ class it {
1134
1134
  //#endregion
1135
1135
  }
1136
1136
  class D extends pe {
1137
- constructor(e, t, i, n, a, o, r, l) {
1137
+ constructor(e, t, i, s, a, o, r, l) {
1138
1138
  super(
1139
1139
  e,
1140
1140
  t,
1141
1141
  i,
1142
- n,
1142
+ s,
1143
1143
  a,
1144
1144
  o,
1145
1145
  l
1146
- ), this.lastFocus = new g(0, 0, 0), this.isRunningFramingBehavior = !1, this.panDenominator = 1, this.minZ = 0.01, this.updateRadiusBounds(this.radius), this.enableFramingBehavior(), this.wheelDeltaPercentage = 0.01, this.pinchDeltaPercentage = 5e-3, this.useNaturalPinchZoom = !0, r.camera.autoOrientation && (this.alpha += Math.PI), r && (r.camera.limits.min.beta && (this.lowerBetaLimit = r.camera.limits.min.beta), r.camera.limits.max.beta && (this.upperBetaLimit = r.camera.limits.max.beta), r.camera.limits.min.alpha && (this.lowerAlphaLimit = r.camera.limits.min.alpha), r.camera.limits.max.alpha && (this.upperAlphaLimit = r.camera.limits.max.alpha), r.camera.limits.min.radius && (this.lowerRadiusLimit = r.camera.limits.min.radius), r.camera.limits.max.radius && (this.upperRadiusLimit = r.camera.limits.max.radius), r.camera.autoRotation.enabled && this.enableAutoRotationBehavior(
1146
+ ), this.lastFocus = new g(0, 0, 0), this._isRunningFramingBehavior = !1, this.panDenominator = 1, this.minZ = 0.01, this.updateRadiusBounds(this.radius), this.enableFramingBehavior(), this.wheelDeltaPercentage = 0.01, this.pinchDeltaPercentage = 5e-3, this.useNaturalPinchZoom = !0, r.camera.autoOrientation && (this.alpha += Math.PI), r && (r.camera.limits.min.beta && (this.lowerBetaLimit = r.camera.limits.min.beta), r.camera.limits.max.beta && (this.upperBetaLimit = r.camera.limits.max.beta), r.camera.limits.min.alpha && (this.lowerAlphaLimit = r.camera.limits.min.alpha), r.camera.limits.max.alpha && (this.upperAlphaLimit = r.camera.limits.max.alpha), r.camera.limits.min.radius && (this.lowerRadiusLimit = r.camera.limits.min.radius), r.camera.limits.max.radius && (this.upperRadiusLimit = r.camera.limits.max.radius), r.camera.autoRotation.enabled && this.enableAutoRotationBehavior(
1147
1147
  r.camera.autoRotation.idleTimeMs
1148
1148
  ));
1149
1149
  }
1150
+ get isRunningFramingBehavior() {
1151
+ return this._isRunningFramingBehavior;
1152
+ }
1153
+ set isRunningFramingBehavior(e) {
1154
+ this._isRunningFramingBehavior = e, !e && this.framingBehaviourCallback && (this.framingBehaviourCallback(), this.framingBehaviourCallback = void 0);
1155
+ }
1150
1156
  /**
1151
1157
  * Returns the framing behavior of this camera.
1152
1158
  */
@@ -1179,17 +1185,17 @@ class D extends pe {
1179
1185
  * @param time The time in milliseconds the animation should take.
1180
1186
  */
1181
1187
  rerunFramingBehavior(e, t) {
1182
- this.isRunningFramingBehavior = !0;
1188
+ this._isRunningFramingBehavior = !0, this.framingBehaviourCallback = e;
1183
1189
  const i = this.getFramingBehavior();
1184
1190
  i.framingTime = t || 800;
1185
- const n = () => {
1186
- this.isRunningFramingBehavior = !1, e && e();
1191
+ const s = () => {
1192
+ this.isRunningFramingBehavior = !1;
1187
1193
  }, a = E(this._scene), o = a.max.subtract(a.min), r = a.min.add(o.scale(0.5));
1188
1194
  this.updateRadiusBounds(o.length() * 1.5), this.wheelPrecision = 100 / this.radius, this.panningInertia = 0, this.panningOriginTarget.copyFrom(r), this.panDenominator = o.length(), this.lastFocus.copyFrom(r), i.zoomOnBoundingInfo(
1189
1195
  a.min,
1190
1196
  a.max,
1191
1197
  void 0,
1192
- n
1198
+ s
1193
1199
  ), i.framingTime = 0;
1194
1200
  }
1195
1201
  /**
@@ -1219,7 +1225,7 @@ class D extends pe {
1219
1225
  * @param assignActive If true the camera will be assigned as the active camera on the scene.
1220
1226
  */
1221
1227
  static create(e, t, i) {
1222
- const n = E(e), a = n.max.subtract(n.min), o = n.min.add(a.scale(0.5)), r = new D(
1228
+ const s = E(e), a = s.max.subtract(s.min), o = s.min.add(a.scale(0.5)), r = new D(
1223
1229
  "ProductCamera",
1224
1230
  -(Math.PI / 2),
1225
1231
  Math.PI / 2,
@@ -1233,16 +1239,16 @@ class D extends pe {
1233
1239
  }), i && (e.activeCamera = r), r;
1234
1240
  }
1235
1241
  }
1236
- function E(s) {
1237
- if (s.meshes.length === 0)
1242
+ function E(n) {
1243
+ if (n.meshes.length === 0)
1238
1244
  return {
1239
1245
  min: new g(-1, -1, -1),
1240
1246
  max: new g(1, 1, 1)
1241
1247
  };
1242
- const e = s.meshes.filter((t) => t.name.toLowerCase().endsWith("_t") || t.name.toLowerCase().includes("_t_"));
1243
- return s.getWorldExtends((t) => t.isVisible && t.isEnabled() && (e.length === 0 || e.includes(t)));
1248
+ const e = n.meshes.filter((t) => t.name.toLowerCase().endsWith("_t") || t.name.toLowerCase().includes("_t_"));
1249
+ return n.getWorldExtends((t) => t.isVisible && t.isEnabled() && (e.length === 0 || e.includes(t)));
1244
1250
  }
1245
- class st {
1251
+ class nt {
1246
1252
  constructor(e, t = !1, i = void 0) {
1247
1253
  this.renderingPipeline = new Ve(
1248
1254
  "default",
@@ -1260,12 +1266,12 @@ class st {
1260
1266
  return this.currentConfiguration;
1261
1267
  }
1262
1268
  setConfiguration(e) {
1263
- var t, i, n, a, o, r, l, d, h, u, m, p, f, k, z, V, q, N, G, H, _, K, W, U, Y, Q, Z, $, j, X, J, ee, te;
1269
+ var t, i, s, a, o, r, l, d, h, u, m, p, f, k, z, V, q, N, G, _, H, K, U, W, Y, Q, Z, $, j, X, J, ee, te;
1264
1270
  if (this.renderingPipeline.isSupported) {
1265
- if (this.renderingPipeline.samples = ((t = e.antiAliasing) == null ? void 0 : t.samples) ?? c.antiAliasing.samples, this.renderingPipeline.fxaaEnabled = ((i = e.antiAliasing) == null ? void 0 : i.fxaaEnabled) ?? c.antiAliasing.fxaaEnabled, this.renderingPipeline.bloomEnabled = ((n = e.bloom) == null ? void 0 : n.enabled) ?? c.bloom.enabled, this.renderingPipeline.bloomKernel = ((a = e.bloom) == null ? void 0 : a.kernel) ?? c.bloom.kernel, this.renderingPipeline.bloomScale = ((o = e.bloom) == null ? void 0 : o.scale) ?? c.bloom.scale, this.renderingPipeline.bloomThreshold = ((r = e.bloom) == null ? void 0 : r.threshold) ?? c.bloom.threshold, this.renderingPipeline.bloomWeight = ((l = e.bloom) == null ? void 0 : l.weight) ?? c.bloom.weight, this.renderingPipeline.chromaticAberrationEnabled = ((d = e.chromaticAberration) == null ? void 0 : d.enabled) ?? c.chromaticAberration.enabled, this.renderingPipeline.chromaticAberration.aberrationAmount = ((h = e.chromaticAberration) == null ? void 0 : h.aberrationAmount) ?? c.chromaticAberration.aberrationAmount, this.renderingPipeline.chromaticAberration.radialIntensity = ((u = e.chromaticAberration) == null ? void 0 : u.radialIntensity) ?? c.chromaticAberration.radialIntensity, this.renderingPipeline.chromaticAberration.direction = (m = e.chromaticAberration) != null && m.direction ? new se(
1271
+ if (this.renderingPipeline.samples = ((t = e.antiAliasing) == null ? void 0 : t.samples) ?? c.antiAliasing.samples, this.renderingPipeline.fxaaEnabled = ((i = e.antiAliasing) == null ? void 0 : i.fxaaEnabled) ?? c.antiAliasing.fxaaEnabled, this.renderingPipeline.bloomEnabled = ((s = e.bloom) == null ? void 0 : s.enabled) ?? c.bloom.enabled, this.renderingPipeline.bloomKernel = ((a = e.bloom) == null ? void 0 : a.kernel) ?? c.bloom.kernel, this.renderingPipeline.bloomScale = ((o = e.bloom) == null ? void 0 : o.scale) ?? c.bloom.scale, this.renderingPipeline.bloomThreshold = ((r = e.bloom) == null ? void 0 : r.threshold) ?? c.bloom.threshold, this.renderingPipeline.bloomWeight = ((l = e.bloom) == null ? void 0 : l.weight) ?? c.bloom.weight, this.renderingPipeline.chromaticAberrationEnabled = ((d = e.chromaticAberration) == null ? void 0 : d.enabled) ?? c.chromaticAberration.enabled, this.renderingPipeline.chromaticAberration.aberrationAmount = ((h = e.chromaticAberration) == null ? void 0 : h.aberrationAmount) ?? c.chromaticAberration.aberrationAmount, this.renderingPipeline.chromaticAberration.radialIntensity = ((u = e.chromaticAberration) == null ? void 0 : u.radialIntensity) ?? c.chromaticAberration.radialIntensity, this.renderingPipeline.chromaticAberration.direction = (m = e.chromaticAberration) != null && m.direction ? new ne(
1266
1272
  e.chromaticAberration.direction.x,
1267
1273
  e.chromaticAberration.direction.y
1268
- ) : new se(
1274
+ ) : new ne(
1269
1275
  c.chromaticAberration.direction.x,
1270
1276
  c.chromaticAberration.direction.y
1271
1277
  ), this.renderingPipeline.imageProcessing.colorCurvesEnabled = ((p = e.colorCurves) == null ? void 0 : p.enabled) ?? c.colorCurves.enabled, this.renderingPipeline.imageProcessing.colorCurves = e.colorCurves ? this.updateColorCurve(e.colorCurves) : new oe(), this.renderingPipeline.depthOfFieldEnabled = ((f = e.depthOfField) == null ? void 0 : f.enabled) ?? c.depthOfField.enabled, e.depthOfField)
@@ -1280,7 +1286,7 @@ class st {
1280
1286
  this.renderingPipeline.depthOfFieldBlurLevel = T.High;
1281
1287
  break;
1282
1288
  }
1283
- if (this.renderingPipeline.depthOfField.focalLength = ((k = e.depthOfField) == null ? void 0 : k.focalLength) ?? c.depthOfField.focalLength, this.renderingPipeline.depthOfField.fStop = ((z = e.depthOfField) == null ? void 0 : z.fStop) ?? c.depthOfField.fStop, this.renderingPipeline.depthOfField.focusDistance = ((V = e.depthOfField) == null ? void 0 : V.focusDistance) ?? c.depthOfField.focusDistance, this.renderingPipeline.depthOfField.lensSize = ((q = e.depthOfField) == null ? void 0 : q.lensSize) ?? c.depthOfField.lensSize, this.renderingPipeline.grainEnabled = ((N = e.grain) == null ? void 0 : N.enabled) ?? c.grain.enabled, this.renderingPipeline.grain.animated = ((G = e.grain) == null ? void 0 : G.animated) ?? c.grain.animated, this.renderingPipeline.grain.intensity = ((H = e.grain) == null ? void 0 : H.intensity) ?? c.grain.intensity, this.renderingPipeline.imageProcessing.contrast = ((_ = e.misc) == null ? void 0 : _.contrast) ?? c.misc.contrast, this.renderingPipeline.imageProcessing.exposure = ((K = e.misc) == null ? void 0 : K.exposure) ?? c.misc.exposure, this.renderingPipeline.imageProcessing.toneMappingEnabled = ((W = e.misc) == null ? void 0 : W.toneMappingEnabled) ?? c.misc.toneMappingEnabled, this.renderingPipeline.imageProcessing.toneMappingEnabled)
1289
+ if (this.renderingPipeline.depthOfField.focalLength = ((k = e.depthOfField) == null ? void 0 : k.focalLength) ?? c.depthOfField.focalLength, this.renderingPipeline.depthOfField.fStop = ((z = e.depthOfField) == null ? void 0 : z.fStop) ?? c.depthOfField.fStop, this.renderingPipeline.depthOfField.focusDistance = ((V = e.depthOfField) == null ? void 0 : V.focusDistance) ?? c.depthOfField.focusDistance, this.renderingPipeline.depthOfField.lensSize = ((q = e.depthOfField) == null ? void 0 : q.lensSize) ?? c.depthOfField.lensSize, this.renderingPipeline.grainEnabled = ((N = e.grain) == null ? void 0 : N.enabled) ?? c.grain.enabled, this.renderingPipeline.grain.animated = ((G = e.grain) == null ? void 0 : G.animated) ?? c.grain.animated, this.renderingPipeline.grain.intensity = ((_ = e.grain) == null ? void 0 : _.intensity) ?? c.grain.intensity, this.renderingPipeline.imageProcessing.contrast = ((H = e.misc) == null ? void 0 : H.contrast) ?? c.misc.contrast, this.renderingPipeline.imageProcessing.exposure = ((K = e.misc) == null ? void 0 : K.exposure) ?? c.misc.exposure, this.renderingPipeline.imageProcessing.toneMappingEnabled = ((U = e.misc) == null ? void 0 : U.toneMappingEnabled) ?? c.misc.toneMappingEnabled, this.renderingPipeline.imageProcessing.toneMappingEnabled)
1284
1290
  switch (e.misc.toneMappingType ?? c.misc.toneMappingType) {
1285
1291
  case "Standard":
1286
1292
  this.renderingPipeline.imageProcessing.toneMappingType = P.TONEMAPPING_STANDARD;
@@ -1289,7 +1295,7 @@ class st {
1289
1295
  this.renderingPipeline.imageProcessing.toneMappingType = P.TONEMAPPING_ACES;
1290
1296
  break;
1291
1297
  }
1292
- if (this.renderingPipeline.sharpenEnabled = ((U = e.sharpen) == null ? void 0 : U.enabled) ?? c.sharpen.enabled, this.renderingPipeline.sharpen.colorAmount = ((Y = e.sharpen) == null ? void 0 : Y.colorAmount) ?? c.sharpen.colorAmount, this.renderingPipeline.sharpen.edgeAmount = ((Q = e.sharpen) == null ? void 0 : Q.edgeAmount) ?? c.sharpen.edgeAmount, this.renderingPipeline.imageProcessing.vignetteEnabled = ((Z = e.vignette) == null ? void 0 : Z.enabled) ?? c.vignette.enabled, ($ = e.vignette) != null && $.center ? (this.renderingPipeline.imageProcessing.vignetteCenterX = e.vignette.center.x, this.renderingPipeline.imageProcessing.vignetteCenterY = e.vignette.center.y) : (this.renderingPipeline.imageProcessing.vignetteCenterX = c.vignette.center.x, this.renderingPipeline.imageProcessing.vignetteCenterY = c.vignette.center.y), e.vignette)
1298
+ if (this.renderingPipeline.sharpenEnabled = ((W = e.sharpen) == null ? void 0 : W.enabled) ?? c.sharpen.enabled, this.renderingPipeline.sharpen.colorAmount = ((Y = e.sharpen) == null ? void 0 : Y.colorAmount) ?? c.sharpen.colorAmount, this.renderingPipeline.sharpen.edgeAmount = ((Q = e.sharpen) == null ? void 0 : Q.edgeAmount) ?? c.sharpen.edgeAmount, this.renderingPipeline.imageProcessing.vignetteEnabled = ((Z = e.vignette) == null ? void 0 : Z.enabled) ?? c.vignette.enabled, ($ = e.vignette) != null && $.center ? (this.renderingPipeline.imageProcessing.vignetteCenterX = e.vignette.center.x, this.renderingPipeline.imageProcessing.vignetteCenterY = e.vignette.center.y) : (this.renderingPipeline.imageProcessing.vignetteCenterX = c.vignette.center.x, this.renderingPipeline.imageProcessing.vignetteCenterY = c.vignette.center.y), e.vignette)
1293
1299
  switch (((j = e.vignette) == null ? void 0 : j.blendMode) ?? c.vignette.blendMode) {
1294
1300
  case "Multiply":
1295
1301
  this.renderingPipeline.imageProcessing.vignetteBlendMode = P.VIGNETTEMODE_MULTIPLY;
@@ -1316,22 +1322,22 @@ class st {
1316
1322
  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;
1317
1323
  }
1318
1324
  }
1319
- Pe.GLTFLoader.RegisterExtension("glbPostProcessor", function(s) {
1320
- return new Ne(s);
1325
+ Pe.GLTFLoader.RegisterExtension("glbPostProcessor", function(n) {
1326
+ return new Ne(n);
1321
1327
  });
1322
- S.OnPluginActivatedObservable.add((s) => {
1323
- if (s.name === "gltf") {
1324
- const e = s;
1328
+ S.OnPluginActivatedObservable.add((n) => {
1329
+ if (n.name === "gltf") {
1330
+ const e = n;
1325
1331
  e.transparencyAsCoverage = !0;
1326
1332
  }
1327
1333
  });
1328
- function O(s) {
1329
- return new g(s.x, s.y, s.z);
1334
+ function O(n) {
1335
+ return new g(n.x, n.y, n.z);
1330
1336
  }
1331
- function L(s) {
1332
- return { x: s.x, y: s.y, z: s.z };
1337
+ function L(n) {
1338
+ return { x: n.x, y: n.y, z: n.z };
1333
1339
  }
1334
- class Ut {
1340
+ class Wt {
1335
1341
  constructor(e) {
1336
1342
  var l;
1337
1343
  this.focusLostNotified = !1, this.focusLostObservable = new C(), this.modelLoadEventCallbacks = [], this.modelContainers = /* @__PURE__ */ new Map(), this.plugins = [], this.initComplete = !1, this.isAnimatingCamera = !1, this.renderLoop = () => {
@@ -1339,19 +1345,19 @@ class Ut {
1339
1345
  return;
1340
1346
  this.modelContainers.forEach((h) => {
1341
1347
  h.updateDynamicTextures();
1342
- }), this.scene.render();
1348
+ }), this.scene.render(), this.camera.isRunningFramingBehavior && this.camera.getFramingBehavior().isUserIsMoving && (this.camera.isRunningFramingBehavior = !1);
1343
1349
  const d = Math.max((this.camera.lowerRadiusLimit ?? 1) * 0.01, 1e-3);
1344
1350
  !this.camera.isRunningFramingBehavior && !this.camera.target.equalsWithEpsilon(this.camera.lastFocus, d) && !this.focusLostNotified && (this.focusLostObservable.notifyObservers(void 0), this.focusLostNotified = !0), this.screenshotPrepareResolve && (this.screenshotPrepareResolve(), this.screenshotPrepareResolve = void 0);
1345
1351
  }, this.configuration = new le(e);
1346
1352
  const i = (() => {
1347
1353
  if (!(e != null && e.noRender))
1348
1354
  return this.configuration.createCanvas();
1349
- })(), n = "1.5.6";
1355
+ })(), s = "1.5.6";
1350
1356
  ye.Configuration = {
1351
1357
  decoder: {
1352
- wasmUrl: `https://www.gstatic.com/draco/versioned/decoders/${n}/draco_wasm_wrapper_gltf.js`,
1353
- wasmBinaryUrl: `https://www.gstatic.com/draco/versioned/decoders/${n}/draco_decoder_gltf.wasm`,
1354
- fallbackUrl: `https://www.gstatic.com/draco/versioned/decoders/${n}/draco_decoder_gltf.js`
1358
+ wasmUrl: `https://www.gstatic.com/draco/versioned/decoders/${s}/draco_wasm_wrapper_gltf.js`,
1359
+ wasmBinaryUrl: `https://www.gstatic.com/draco/versioned/decoders/${s}/draco_decoder_gltf.wasm`,
1360
+ fallbackUrl: `https://www.gstatic.com/draco/versioned/decoders/${s}/draco_decoder_gltf.js`
1355
1361
  }
1356
1362
  }, i && (i.getContext("webgl2") || i.getContext("webgl"));
1357
1363
  const a = console.log;
@@ -1366,7 +1372,7 @@ class Ut {
1366
1372
  stencil: this.configuration.highlights.enabled,
1367
1373
  forceSRGBBufferSupportState: !0
1368
1374
  }) : new we();
1369
- console.log = a, o.hideLoadingUI(), window.addEventListener("resize", this.fireResizeEvent.bind(this)), this.engine = o, this.scene = new xe(o), this.scene.autoClear = !0, this.scene.autoClearDepthAndStencil = !0, this.camera = D.create(this.scene, this.configuration), this.scene.activeCamera = this.camera, this.renderingPipeline = new st(
1375
+ console.log = a, o.hideLoadingUI(), window.addEventListener("resize", this.fireResizeEvent.bind(this)), this.engine = o, this.scene = new xe(o), this.scene.autoClear = !0, this.scene.autoClearDepthAndStencil = !0, this.camera = D.create(this.scene, this.configuration), this.scene.activeCamera = this.camera, this.renderingPipeline = new nt(
1370
1376
  this.scene,
1371
1377
  !1,
1372
1378
  this.camera
@@ -1427,7 +1433,7 @@ class Ut {
1427
1433
  this.plugins.forEach((e) => e.dispose(!0)), this.renderingPipeline.dispose(), this.engine && this.engine.dispose(), window.removeEventListener("resize", this.fireResizeEvent);
1428
1434
  }
1429
1435
  executeCameraAnimation(e) {
1430
- if (!this.camera || this.scene.activeCamera !== this.camera || this.getAllModels().length === 0 || !this.getAllModels().some((n) => n.getIsInitialized()))
1436
+ if (!this.camera || this.scene.activeCamera !== this.camera || this.getAllModels().length === 0 || !this.getAllModels().some((s) => s.getIsInitialized()))
1431
1437
  return this.queuedCameraAnimation = e, Promise.resolve();
1432
1438
  let t = () => {
1433
1439
  };
@@ -1438,8 +1444,8 @@ class Ut {
1438
1444
  e
1439
1445
  ), this.isAnimatingCamera = !1, this.queuedAnimationFunction && this.queuedAnimationFunction(), this.queuedAnimationFunction = void 0, t();
1440
1446
  };
1441
- return this.isAnimatingCamera ? (this.queuedAnimationFunction = i, new Promise((n) => {
1442
- t = n;
1447
+ return this.isAnimatingCamera ? (this.queuedAnimationFunction = i, new Promise((s) => {
1448
+ t = s;
1443
1449
  })) : i();
1444
1450
  }
1445
1451
  getCameraPose() {
@@ -1475,13 +1481,14 @@ class Ut {
1475
1481
  };
1476
1482
  const t = async () => {
1477
1483
  this.isAnimatingCamera = !0, await new Promise((i) => {
1478
- const n = () => {
1484
+ this.focusLostNotified = !1;
1485
+ const s = () => {
1479
1486
  const a = this.configuration;
1480
1487
  this.camera.rerunFramingBehavior(() => {
1481
- this.focusLostNotified = !1, a.camera.limits.min.radius && (this.camera.lowerRadiusLimit = a.camera.limits.min.radius), a.camera.limits.max.radius && (this.camera.upperRadiusLimit = a.camera.limits.max.radius), i();
1488
+ a.camera.limits.min.radius && (this.camera.lowerRadiusLimit = a.camera.limits.min.radius), a.camera.limits.max.radius && (this.camera.upperRadiusLimit = a.camera.limits.max.radius), i();
1482
1489
  });
1483
1490
  };
1484
- this.scene.onAfterRenderObservable.addOnce(n);
1491
+ this.scene.onAfterRenderObservable.addOnce(s);
1485
1492
  }), this.isAnimatingCamera = !1, this.queuedAnimationFunction && this.queuedAnimationFunction(), this.queuedAnimationFunction = void 0, e();
1486
1493
  };
1487
1494
  return this.isAnimatingCamera ? (this.queuedAnimationFunction = t, new Promise((i) => {
@@ -1508,8 +1515,8 @@ class Ut {
1508
1515
  this.scene
1509
1516
  );
1510
1517
  try {
1511
- const n = t.latDeg * Math.PI / 180, a = t.lonDeg * Math.PI / 180;
1512
- i.target = t.target ? new g(t.target.x, t.target.y, t.target.z) : g.Zero(), i.alpha = a, i.beta = n, i.radius = t.radius || this.camera.radius, i.minZ = 0.01, this.scene.render();
1518
+ const s = t.latDeg * Math.PI / 180, a = t.lonDeg * Math.PI / 180;
1519
+ i.target = t.target ? new g(t.target.x, t.target.y, t.target.z) : g.Zero(), i.alpha = a, i.beta = s, i.radius = t.radius || this.camera.radius, i.minZ = 0.01, this.scene.render();
1513
1520
  const o = await Me.CreateScreenshotUsingRenderTargetAsync(
1514
1521
  this.engine,
1515
1522
  i,
@@ -1527,18 +1534,18 @@ class Ut {
1527
1534
  const e = this.configuration;
1528
1535
  if (!e)
1529
1536
  return !0;
1530
- const t = e.camera.limits.min.alpha, i = e.camera.limits.max.alpha, n = e.camera.limits.min.beta, a = e.camera.limits.max.beta;
1531
- if (t === void 0 || i === void 0 || n === void 0 || a === void 0)
1537
+ const t = e.camera.limits.min.alpha, i = e.camera.limits.max.alpha, s = e.camera.limits.min.beta, a = e.camera.limits.max.beta;
1538
+ if (t === void 0 || i === void 0 || s === void 0 || a === void 0)
1532
1539
  return !0;
1533
- const o = [t, i], r = [n, a], l = o.every((h) => h === t), d = r.every((h) => h === n);
1540
+ const o = [t, i], r = [s, a], l = o.every((h) => h === t), d = r.every((h) => h === s);
1534
1541
  return !l && !d;
1535
1542
  }
1536
1543
  fireResizeEvent() {
1537
1544
  this.getNumViewports() > 0 && this.engine.resize();
1538
1545
  }
1539
1546
  setHighlights(e, t) {
1540
- var n;
1541
- e.length === 0 && ((n = this.highlightLayer) == null || n.dispose(), this.highlightLayer = void 0), this.highlightLayer || (this.highlightLayer = new Ce("highlights", this.scene, {
1547
+ var s;
1548
+ e.length === 0 && ((s = this.highlightLayer) == null || s.dispose(), this.highlightLayer = void 0), this.highlightLayer || (this.highlightLayer = new Ce("highlights", this.scene, {
1542
1549
  isStroke: !0,
1543
1550
  blurVerticalSize: 0.85,
1544
1551
  blurHorizontalSize: 0.85
@@ -1576,8 +1583,8 @@ class Ut {
1576
1583
  this.queuedCameraAnimation && (this.executeCameraAnimation(this.queuedCameraAnimation), this.queuedCameraAnimation = void 0);
1577
1584
  });
1578
1585
  }, 1);
1579
- }), this.configuration.highlights.enabled && (i.registerMaterialSelectedCallback((n) => {
1580
- this.setHighlights([n]);
1586
+ }), this.configuration.highlights.enabled && (i.registerMaterialSelectedCallback((s) => {
1587
+ this.setHighlights([s]);
1581
1588
  }), i.registerMaterialDeselectedCallback(() => {
1582
1589
  this.setHighlights([]);
1583
1590
  })), this.modelContainers.set(i.getId(), i), this.triggerModelLoadEvent({
@@ -1600,7 +1607,7 @@ class Ut {
1600
1607
  }
1601
1608
  unregisterPlugin(e) {
1602
1609
  const t = this.plugins.indexOf(e);
1603
- t > -1 && this.plugins.splice(t, 1).forEach((n) => n.dispose(!1));
1610
+ t > -1 && this.plugins.splice(t, 1).forEach((s) => s.dispose(!1));
1604
1611
  }
1605
1612
  getGlowLayerManager() {
1606
1613
  return this.glowLayerManager;
@@ -1618,13 +1625,13 @@ class Ut {
1618
1625
  * Flips a transform around the origin.
1619
1626
  */
1620
1627
  flipTransform(e, t, i) {
1621
- const n = ne.Compose(
1628
+ const s = se.Compose(
1622
1629
  O(i || { x: 1, y: 1, z: 1 }),
1623
1630
  y.FromEulerVector(
1624
1631
  O(t || { x: 0, y: 0, z: 0 })
1625
1632
  ),
1626
1633
  O(e || { x: 0, y: 0, z: 0 })
1627
- ), a = ne.RotationAxis(g.Up(), Math.PI), o = n.multiply(a), r = g.Zero(), l = y.Identity(), d = g.Zero();
1634
+ ), a = se.RotationAxis(g.Up(), Math.PI), o = s.multiply(a), r = g.Zero(), l = y.Identity(), d = g.Zero();
1628
1635
  return o.decompose(d, l, r), l.multiplyInPlace(y.FromEulerAngles(0, Math.PI, 0)), {
1629
1636
  position: L(r),
1630
1637
  rotation: L(l.toEulerAngles()),
@@ -1632,14 +1639,14 @@ class Ut {
1632
1639
  };
1633
1640
  }
1634
1641
  updatePreviewOptions(e) {
1635
- var n;
1642
+ var s;
1636
1643
  const t = new le(e);
1637
1644
  this.configuration.highlights.enabled !== t.highlights.enabled && this.engine.setStencilBuffer(t.highlights.enabled), this.scene.clearColor = t.scene.clearColor;
1638
1645
  let i = this.scene.environmentTexture;
1639
1646
  this.configuration.scene.environment.file !== t.scene.environment.file && (i = ie.CreateFromPrefilteredData(
1640
1647
  t.scene.environment.file,
1641
1648
  this.scene
1642
- ), i.rotationY = this.configuration.scene.environment.rotationY, this.scene.environmentTexture = i), i.rotationY = t.scene.environment.rotationY, this.scene.environmentIntensity = t.scene.environment.intensity, (n = t.options) != null && n.renderingPipelineConfiguration ? this.renderingPipeline.setConfiguration(
1649
+ ), 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(
1643
1650
  t.options.renderingPipelineConfiguration
1644
1651
  ) : (this.scene.imageProcessingConfiguration.exposure = t.lighting.exposure, this.scene.imageProcessingConfiguration.contrast = t.lighting.contrast), this.glowLayerManager.setIntensity(t.emissiveGlowIntensity), this.configuration = t;
1645
1652
  }
@@ -1662,6 +1669,6 @@ export {
1662
1669
  I as ProductCameraRig,
1663
1670
  qe as REFLECTION_PROBE_RESOLUTION,
1664
1671
  x as RenderingConfiguration,
1665
- Ut as SpiffCommerce3DPreviewService,
1672
+ Wt as SpiffCommerce3DPreviewService,
1666
1673
  c as renderingPipelineDefaults
1667
1674
  };
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- (function(c,v){typeof exports=="object"&&typeof module<"u"?v(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/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/loaders/glTF/glTFFileLoader"),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/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/loaders/glTF/glTFFileLoader","@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"],v):(c=typeof globalThis<"u"?globalThis:c||self,v(c.Preview={},c.arcRotateCamera,c.engine,c.nullEngine,c.highlightLayer,c.sceneLoader,c.cubeTexture,c.math_color,c.math_vector,c.dracoCompression,c.observable,c.tools,c.scene,c.glTF,c.pbrMaterial,c.mirrorTexture,c.math,c.reflectionProbe,c.glowLayer,c.actionManager,c.directActions,c.mesh,c.transformNode,c.glTFFileLoader,c.dynamicTexture,c.texture,c.animation,c.easing,c.assetsManager,c.colorCurves,c.imageProcessingConfiguration,c.RenderPipeline,c.depthOfFieldEffect))})(this,function(c,v,D,ye,ve,L,V,b,m,we,M,Ce,Me,xe,O,Pe,P,Ae,Te,I,k,Re,Ee,Le,Oe,Ie,w,z,Fe,N,A,Se,F){"use strict";var T=(s=>(s[s.Orbit=0]="Orbit",s[s.Pan=1]="Pan",s))(T||{}),R=(s=>(s.None="None",s.RemoveWhenSelected="RemoveWhenSelected",s.ApplyWhenSelected="ApplyWhenSelected",s))(R||{});class G{constructor(e){this.getSceneClearColor=()=>{var i,n,a,o;const t=(i=this.customOptions)!=null&&i.transparentBackground||(n=this.customOptions)!=null&&n.backgroundImage?0:1;if(this.customOptions&&((a=this.customOptions)!=null&&a.transparentBackground)||(o=this.customOptions)!=null&&o.backgroundImage)return new b.Color4(0,0,0,t).toLinearSpace();if(this.customOptions&&this.customOptions.backgroundColor){const r=b.Color3.FromHexString(this.customOptions.backgroundColor);return new b.Color4(r.r,r.g,r.b,t).toLinearSpace()}return new b.Color4(.98,.98,.98,t).toLinearSpace()},this.highlightColorFromConfig=()=>this.customOptions&&this.customOptions.highlightColor?this.hexToColor4(this.customOptions.highlightColor):new b.Color4(.98,.98,.98,1).toLinearSpace(),this.hexToColor4=(t,i=1)=>{const n=b.Color3.FromHexString(t);return new b.Color4(n.r,n.g,n.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,n,a;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:((n=this.customOptions)==null?void 0:n.environmentIntensity)??1,rotationY:(((a=this.customOptions)==null?void 0:a.environmentRotationY)??0)*(Math.PI/180)}}}get camera(){var e,t,i,n,a,o,r,l,u,h,g,p,f;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:(n=this.customOptions)!=null&&n.lowerAlphaLimitDeg?((a=this.customOptions)==null?void 0:a.lowerAlphaLimitDeg)*Math.PI/180:void 0,beta:(o=this.customOptions)!=null&&o.lowerBetaLimitDeg?((r=this.customOptions)==null?void 0:r.lowerBetaLimitDeg)*Math.PI/180:void 0,radius:(l=this.customOptions)==null?void 0:l.minZoomOverride},max:{alpha:(u=this.customOptions)!=null&&u.upperAlphaLimitDeg?((h=this.customOptions)==null?void 0:h.upperAlphaLimitDeg)*Math.PI/180:void 0,beta:(g=this.customOptions)!=null&&g.upperBetaLimitDeg?((p=this.customOptions)==null?void 0:p.upperBetaLimitDeg)*Math.PI/180:void 0,radius:(f=this.customOptions)==null?void 0:f.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,n;return{exposure:((t=(e=this.customOptions)==null?void 0:e.lighting)==null?void 0:t.exposure)??.9,contrast:((n=(i=this.customOptions)==null?void 0:i.lighting)==null?void 0:n.contrast)??1.6}}get emissiveGlowIntensity(){var e;return((e=this.customOptions)==null?void 0:e.emissiveGlowIntensity)??.5}}class C{static getDynamicTextureResolution(){return this.getIsMobile()||!C.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 H=128,d={antiAliasing:{samples:4,fxaaEnabled:!1},bloom:{enabled:!1,kernel:64,scale:.5,threshold:.9,weight:.15},chromaticAberration:{enabled:!1,aberrationAmount:30,direction:{x:0,y:0},radialIntensity:0},colorCurves:{enabled:!1},depthOfField:{enabled:!1,blurLevel:"Low",focalLength:50,focusDistance:2e3,fStop:1.4,lensSize:50},grain:{enabled:!1,animated:!1,intensity:30},misc:{contrast:1,exposure:1,toneMappingEnabled:!1,toneMappingType:"Standard"},sharpen:{enabled:!1,colorAmount:1,edgeAmount:.3},vignette:{enabled:!1,blendMode:"Multiply",cameraFov:.5,center:{x:0,y:0},colorHex:"#000000ff",colorRgba:{r:0,g:0,b:0,a:1},stretch:0,weight:1}};class Be{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(n){t.extras&&Object.keys(t.extras).forEach(a=>{const o=t.extras[a];n.metadata[a]=o}),i(n)})}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 O.PBRMaterial))){if(e.extras.sheen){const i=t;i.sheen.isEnabled=!0,i.sheen.intensity=e.extras.sheen}if(e.extras.translucency){const i=t;i.subSurface.isTranslucencyEnabled=!0,i.subSurface.translucencyIntensity=e.extras.translucency,e.extras.translucencyR&&e.extras.translucencyG&&e.extras.translucencyB&&(i.subSurface.tintColor=new P.Color3(e.extras.translucencyR,e.extras.translucencyG,e.extras.translucencyB))}if(e.extras.refractionIOR){const i=t;i.subSurface.isRefractionEnabled=!0,i.subSurface.volumeIndexOfRefraction=e.extras.refractionIOR}if(e.extras.useDepthPrePass){const i=t;i.needDepthPrePass=!0,i.forceIrradianceInFragment=!0}if(e.extras.useParallax){const i=t;i.useParallax=!0,i.useParallaxOcclusion=!0,i.parallaxScaleBias=e.extras.useParallax}}}applyReflections(e){function t(a){const o=[];return a.transformNodes.forEach(r=>{r.metadata&&r.metadata.reflective&&o.push(...r.getChildMeshes())}),a.meshes.forEach(r=>{r.metadata&&r.metadata.reflective&&!o.includes(r)&&o.push(r)}),o}function i(a,o=1){const r=a.material;if(!r)return;const l=new Pe.MirrorTexture("mirror",C.getMirrorTextureResolution(),e,!0);l.renderList=t(e);const u=a.getVerticesData("normal");if(!u)throw new Error("Mirror attribute specified on: "+a.name+"But no normals exist to generate a mirror from!");a.computeWorldMatrix(!0);const h=a.getWorldMatrix(),g=P.Vector3.TransformNormal(new P.Vector3(u[0],u[1],u[2]),h).normalize(),p=P.Plane.FromPositionAndNormal(a.position,g.scale(-1));l.mirrorPlane=p,l.level=o,r.reflectionTexture=l}function n(a){const o=a.material,r=new Ae.ReflectionProbe("probe-"+o.name,H,e);r.attachToMesh(a),r.renderList&&r.renderList.push(...t(e)),o.reflectionTexture=r.cubeTexture}e.meshes.forEach(a=>{const o=a.metadata;o&&(o.mirrorTexture&&i(a,o.mirrorTexture),o.reflectionProbe&&n(a))})}}class je{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 Te.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)}}}const K=new Map;async function U(s,e,t){const i=K.get(s);if(i&&i.scene.uid===e.uid)return i;{const n=await L.SceneLoader.LoadAssetContainerAsync(s,void 0,e,t);return K.set(s,n),n}}L.SceneLoader.OnPluginActivatedObservable.add(s=>{s.name==="gltf"&&(s.animationStartMode=Le.GLTFLoaderAnimationStartMode.NONE)});function qe(s,e,t,i,n=""){t.forEach(a=>{const o=a.getID(),r=a.getName(),l=C.getDynamicTextureResolution();s.filter(h=>h.name===n+r).forEach(h=>{const g=i.get(o),p=!1;if(g)W(h,g),g.update(p);else{const f=De(r,e,l.width,l.height);i.set(o,f),a.setStaticContext(f.getContext()),W(h,f),f.onLoadObservable.addOnce(()=>{f.update(p)})}})})}function De(s,e,t,i){const n=new Oe.DynamicTexture(s,{width:t,height:i},e,C.shouldMipMap(),Ie.Texture.TRILINEAR_SAMPLINGMODE,D.Engine.TEXTUREFORMAT_RGBA),a=n.getContext();return a&&(a.fillStyle="#f5f5f5",a.fillRect(0,0,t,i),n.update()),n}function W(s,e){if(s instanceof O.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 Ve(){const s=()=>Math.floor((1+Math.random())*65536).toString(16).substring(1);return s()+s()+"-"+s()+"-"+s()+"-"+s()+"-"+s()+s()+s()}const x=60,Q=1;function Y(s){return s.targetedAnimations.map(t=>t.animation.framePerSecond).reduce((t,i)=>t+i,0)/s.targetedAnimations.length||0}function ke(s,e,t,i,n,a){const o=n?s.filter(h=>h.name===n):s;if(o.length===0){console.warn(`No animations found for name: ${n}`);return}let r=0;const l=()=>{r++,r===o.length&&a&&a()},u=(h,g,p,f,y)=>{h.stop(),h.start(g,p,f,y),a&&(g==!1||g===void 0&&!h.loopAnimation?h.onAnimationGroupEndObservable.addOnce(()=>{l()}):h.onAnimationLoopObservable.addOnce(()=>{l()}))};if(i!==void 0&&t!==void 0&&i===t){o.forEach(h=>{const g=Y(h),p=i*g;u(h,!1,Q,p,p)});return}o.forEach(h=>{const g=Y(h),p=i!==void 0?i*g:void 0,f=t!==void 0?t*g:void 0;u(h,e,Q,p,f)})}function ze(s){s.forEach(e=>{e.reset(),e.stop()})}function Ne(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 n=[],a=t.target,o=0,r=a?1:0;if(t.target&&Object.keys(t.target).length>0&&n.push(E("cameraTargetLerp","target",new m.Vector3().copyFrom(e.target),new m.Vector3(t.target.x,t.target.y,t.target.z),w.Animation.ANIMATIONTYPE_VECTOR3,o)),n.push(E("cameraAlphaLerp","alpha",e.alpha,Z(t.lonDeg),w.Animation.ANIMATIONTYPE_FLOAT,r)),n.push(E("cameraBetaLerp","beta",e.beta,Z(t.latDeg),w.Animation.ANIMATIONTYPE_FLOAT,r)),t.radius!==void 0){const h=Math.max(.01,t.radius);n.push(E("cameraRadiusLerp","radius",e.radius,h,w.Animation.ANIMATIONTYPE_FLOAT,r))}e.animations.push(...n);const u=e.useAutoRotationBehavior;e.disableAutoRotationBehavior(),s.beginAnimation(e,0,a?x*2:x,!1,1,()=>{e.animations=[],u&&e.enableAutoRotationBehavior(),i()})})}function Z(s){return s*Math.PI/180}function E(s,e,t,i,n,a=0,o=w.Animation.ANIMATIONLOOPMODE_CONSTANT){const r=new z.QuadraticEase;r.setEasingMode(z.EasingFunction.EASINGMODE_EASEINOUT);const l=new w.Animation(s,e,x,n,o),u=[];return a>0&&u.push({frame:0,value:t}),u.push({frame:x*a,value:t}),u.push({frame:x*(a+1),value:i}),l.setKeys(u),l.setEasingFunction(r),l}function Ge(s,e,t){return s<e?s=t-(e-s)%(t-e):s=e+(s-e)%(t-e)}const He={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(a=>{Ue(a,s,e,t,i)}),Ye(s,e)}function Ue(s,e,t,i,n){const a=He[s];if(!a)throw new Error("Unexpected texture name encountered.");const o=e[a],r=o==null?void 0:o.fileLink;r?s==="reflectionTexture"?r.endsWith(".env")||r.endsWith(".dds")?i.addCubeTextureTask(s,r,void 0,!1,void 0,!0):r.endsWith(".hdr")?i.addHDRCubeTextureTask(s,r,128,!1,!0,!1):i.addTextureTask(s,r,!1,!1):i.addTextureTask(s,r,!1,!1):n&&t[s]&&(t[s]&&t[s].dispose(),t[s]=null,We(s,t))}function We(s,e){s==="opacityTexture"&&(e.useAlphaFromAlbedoTexture=!0),s==="metallicTexture"&&(e.useRoughnessFromMetallicTextureAlpha=!1,e.useRoughnessFromMetallicTextureGreen=!1,e.useMetallnessFromMetallicTextureBlue=!1),s==="refractionTexture"&&(e.subSurface.isRefractionEnabled=!1,e.subSurface.refractionIntensity=1),s==="reflectionTexture"&&(e.environmentIntensity=1),s==="emissiveTexture"&&(e.emissiveIntensity=0,e.emissiveColor=new b.Color3(0,0,0),e.reflectionTexture)}function Qe(s,e,t,i){if(!e){console.error("Failed to apply texture to material: material is null.");return}s==="opacityTexture"&&(e.useAlphaFromAlbedoTexture=!1),s==="metallicTexture"&&(e.useRoughnessFromMetallicTextureAlpha=!1,e.useRoughnessFromMetallicTextureGreen=!0,e.useMetallnessFromMetallicTextureBlue=!0),s==="refractionTexture"&&(e.subSurface.isRefractionEnabled=!0,e.subSurface.refractionIntensity=t.refractionIntensity||1),s==="reflectionTexture"&&(e.environmentIntensity=t.reflectionIntensity||1,i.isCube&&(i.rotationY=t.reflectionRotation?t.reflectionRotation*Math.PI/180:0)),e[s]=i,s==="emissiveTexture"&&(e.emissiveColor=new b.Color3(1,1,1),e.emissiveIntensity=1)}function Ye(s,e){s.clearCoat&&(s.clearCoat===R.RemoveWhenSelected?(e.clearCoat.isEnabled=!1,e.clearCoat.indexOfRefraction=1.5):s.clearCoat===R.ApplyWhenSelected&&(e.clearCoat.isEnabled=!0,e.clearCoat.indexOfRefraction=s.clearCoatIOR||e.clearCoat.indexOfRefraction))}class Ze{constructor(e,t,i){this.materialVariantMap=new Map,this.keysThatRemovedBaseModel=[],this.loadedContainerForKey=new Map,this.loadedMaterialsForKey=new Map,this.scene=e,this.renameClonedAsset=t,this.setBaseModelEnabled=i}async applyMaterial(e,t,i,n){return new Promise(a=>{const o=this.materialVariantMap.get(e);this.materialVariantMap.set(e,{...o,...t});const r=this.renameClonedAsset(e),l=this.scene.materials.filter(h=>h.name===r);if(l.length===0){a();return}const u=new Fe.AssetsManager(this.scene);u.useDefaultLoadingScreen=!1,l.forEach(h=>Ke(t,h,u,n)),u.onProgress=(h,g,p)=>{i&&i(h/g*100,100,p.name)},u.onFinish=h=>{h.forEach(g=>{const p=g;i&&i(100,100,g.name),this.scene.materials.filter(y=>y.name===r).forEach(y=>Qe(g.name,y,t,p.texture))}),a()},u.loadAsync()})}async applyModel(e,t,i,n){var l,u;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),(l=this.loadedContainerForKey.get(e))==null||l.dispose(),this.loadedContainerForKey.delete(e),this.loadedMaterialsForKey.delete(e),this.keysThatRemovedBaseModel=this.keysThatRemovedBaseModel.filter(h=>h!==e),Promise.resolve(void 0);const o=(await U(i,this.scene,n)).instantiateModelsToScene(this.renameClonedAsset,!0);this.loadedContainerForKey.has(e)&&((u=this.loadedContainerForKey.get(e))==null||u.dispose(),this.loadedContainerForKey.delete(e),this.loadedMaterialsForKey.delete(e)),t&&await this.setBaseModelEnabled(!1),this.loadedContainerForKey.set(e,o),this.loadedMaterialsForKey.set(e,$(o));const r=[];return this.materialVariantMap.forEach(async(h,g)=>{r.push(this.applyMaterial(g,h))}),await Promise.all(r),o}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 $(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(n=>{const a=n.getMaterial(!1);a&&!e.includes(a)&&e.push(a)})})}),e}function X(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 M.Observable,this.materialDeselectedObservable=new M.Observable,this.materialVariantObservable=new M.Observable,this.modelVariantObservable=new M.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:n,progressHandler:a,scene:o}=e;this.enablePicking=t,this.contextService=i.contextService,this.id=Ve(),this.previewService=n,this.scene=o,this.variantManager=new Ze(o,this.renameClonedAsset.bind(this),this.setBaseModelEnabled.bind(this)),this.transformRoot=new Ee.TransformNode("root",this.scene);const r=async()=>{if(!i.model)throw new Error("Model container constructed with no URL. This is currently unsupported.");return this.assetContainer=await U(i.model,o,a),await this.instantiate(),this};this.importPromise=r()}async applyMaterialVariant(e,t,i,n){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,n))}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,n))}return}const a=async()=>{await this.variantManager.applyMaterial(e,i,(o,r,l)=>{this.materialVariantObservable.notifyObservers({remainingCount:o,totalCount:r,taskName:l})},n)};if(this.materialChangesInProgress.includes(e)){if(this.queuedMaterialChanges.has(e)){const o=this.queuedMaterialChanges.get(e);o==null||o.set(t,a)}else{this.queuedMaterialChanges.set(e,new Map);const o=this.queuedMaterialChanges.get(e);o==null||o.set(t,a)}return}if(this.materialChangesInProgress.push(e),await a(),this.queuedMaterialChanges.has(e)){const o=this.queuedMaterialChanges.get(e);if(!o)throw new Error("Target material is undefined");o.forEach(async r=>{await r()}),this.queuedMaterialChanges.delete(e)}this.materialChangesInProgress.splice(this.materialChangesInProgress.indexOf(e),1),this.configureGlowLayer()}async applyModelVariant(e,t,i){if(!this.initialized){this.modelReadyToLoadCallbacks.set(e,this.applyModelVariant.bind(this,e,t,i));return}const n=()=>this.variantManager.applyModel(e,i,t==null?void 0:t.model,r=>{this.modelVariantObservable.notifyObservers({...r,key:e})});if(this.modelChangesInProgress.includes(e)){this.queuedModelChanges.set(e,n);return}const o=await(async()=>{this.modelChangesInProgress.push(e);let r=await n();if(this.queuedModelChanges.has(e)){const l=this.queuedModelChanges.get(e);if(!l)throw new Error("Queued change resolved undefined");r=await l(),this.queuedModelChanges.delete(e)}return this.modelChangesInProgress.splice(this.modelChangesInProgress.indexOf(e),1),r})();this.modelInstance&&ze(this.modelInstance.animationGroups),this.contextService||(this.contextService=t==null?void 0:t.contextService),o?this.configureModelInstance(o):this.configureGlowLayer()}dispose(){var e;this.destroyInstance(),this.variantManager.dispose(),this.dynamicTextures.forEach(t=>t==null?void 0:t.dispose()),this.dynamicTextures.clear(),this.materials.forEach(t=>t&&(t==null?void 0:t.dispose())),this.materials=[],(e=this.transformRoot)==null||e.dispose(),this.transformRoot=void 0,this.previewService.modelUnloaded(this)}executeAnimation(e){if(!this.initialized)return this.queuedModelAnimation=e,Promise.resolve();if(!this.modelInstance)return Promise.resolve();let t=()=>{};const i=async()=>{this.isExecutingAnimation=!0,await new Promise(n=>{ke([...this.modelInstance.animationGroups,...this.variantManager.getAnimationGroups()],e.loop,e.to,e.from,e.name?this.renameClonedAsset(e.name):void 0,n)}),this.isExecutingAnimation=!1,this.queuedAnimationFunction&&this.queuedAnimationFunction(),this.queuedAnimationFunction=void 0,t()};return this.isExecutingAnimation?(this.queuedAnimationFunction=i,new Promise(n=>{t=n})):i()}getAnimations(e){return[...this.animations,...e?X(this.variantManager.getAnimationGroups(),this.renameClonedAsset("")):[]]}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 m.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=m.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 m.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 I.ActionManager(this.scene)),i.actionManager.registerAction(new k.ExecuteCodeAction(I.ActionManager.OnPointerOverTrigger,n=>{n.meshUnderPointer&&i.material&&this.materialSelectedObservable.notifyObservers({id:i.material.id,name:this.stripIdFromName(i.material.name)})})),i.actionManager.registerAction(new k.ExecuteCodeAction(I.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 O.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 a;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,n=this.transformRoot.scaling;this.transformRoot.position=m.Vector3.Zero(),this.transformRoot.rotationQuaternion=m.Quaternion.Identity(),this.transformRoot.scaling=m.Vector3.One();for(const o of e.rootNodes)o.parent=this.transformRoot;this.transformRoot.position=t,this.transformRoot.rotationQuaternion=i,this.transformRoot.scaling=n,this.canvasPanels=((a=this.contextService)==null?void 0:a.getAll())||new Map,qe(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 Re.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=$(this.modelInstance),this.configureModelInstance(this.modelInstance),this.animations=X(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 n=this.dynamicTextures.get(i);n&&t.getStaticContextDirty()&&n.isReady()&&(n.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)}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 S extends v.ArcRotateCamera{constructor(e,t,i,n,a,o,r,l){super(e,t,i,n,a,o,l),this.lastFocus=new m.Vector3(0,0,0),this.isRunningFramingBehavior=!1,this.panDenominator=1,this.minZ=.01,this.updateRadiusBounds(this.radius),this.enableFramingBehavior(),this.wheelDeltaPercentage=.01,this.pinchDeltaPercentage=.005,this.useNaturalPinchZoom=!0,r.camera.autoOrientation&&(this.alpha+=Math.PI),r&&(r.camera.limits.min.beta&&(this.lowerBetaLimit=r.camera.limits.min.beta),r.camera.limits.max.beta&&(this.upperBetaLimit=r.camera.limits.max.beta),r.camera.limits.min.alpha&&(this.lowerAlphaLimit=r.camera.limits.min.alpha),r.camera.limits.max.alpha&&(this.upperAlphaLimit=r.camera.limits.max.alpha),r.camera.limits.min.radius&&(this.lowerRadiusLimit=r.camera.limits.min.radius),r.camera.limits.max.radius&&(this.upperRadiusLimit=r.camera.limits.max.radius),r.camera.autoRotation.enabled&&this.enableAutoRotationBehavior(r.camera.autoRotation.idleTimeMs))}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=B(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;const i=this.getFramingBehavior();i.framingTime=t||800;const n=()=>{this.isRunningFramingBehavior=!1,e&&e()},a=B(this._scene),o=a.max.subtract(a.min),r=a.min.add(o.scale(.5));this.updateRadiusBounds(o.length()*1.5),this.wheelPrecision=100/this.radius,this.panningInertia=0,this.panningOriginTarget.copyFrom(r),this.panDenominator=o.length(),this.lastFocus.copyFrom(r),i.zoomOnBoundingInfo(a.min,a.max,void 0,n),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){const n=B(e),a=n.max.subtract(n.min),o=n.min.add(a.scale(.5)),r=new S("ProductCamera",-(Math.PI/2),Math.PI/2,a.length()*1.5,o,e,t);return r.panningInertia=0,r.panningOriginTarget.copyFrom(o),r.panDenominator=a.length(),r.onAfterCheckInputsObservable.add(()=>{r.panningSensibility=1e3/r.panDenominator}),i&&(e.activeCamera=r),r}}function B(s){if(s.meshes.length===0)return{min:new m.Vector3(-1,-1,-1),max:new m.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 Se.DefaultRenderingPipeline("default",t,e,i?[i]:void 0,!1),this.renderingPipeline.isSupported&&(this.renderingPipeline.prepare(),this.setConfiguration(d))}dispose(){this.renderingPipeline.dispose()}getConfiguration(){return this.currentConfiguration}setConfiguration(e){var t,i,n,a,o,r,l,u,h,g,p,f,y,J,_,ee,te,ie,se,ne,re,ae,oe,le,he,ce,de,ue,ge,me,pe,fe,be;if(this.renderingPipeline.isSupported){if(this.renderingPipeline.samples=((t=e.antiAliasing)==null?void 0:t.samples)??d.antiAliasing.samples,this.renderingPipeline.fxaaEnabled=((i=e.antiAliasing)==null?void 0:i.fxaaEnabled)??d.antiAliasing.fxaaEnabled,this.renderingPipeline.bloomEnabled=((n=e.bloom)==null?void 0:n.enabled)??d.bloom.enabled,this.renderingPipeline.bloomKernel=((a=e.bloom)==null?void 0:a.kernel)??d.bloom.kernel,this.renderingPipeline.bloomScale=((o=e.bloom)==null?void 0:o.scale)??d.bloom.scale,this.renderingPipeline.bloomThreshold=((r=e.bloom)==null?void 0:r.threshold)??d.bloom.threshold,this.renderingPipeline.bloomWeight=((l=e.bloom)==null?void 0:l.weight)??d.bloom.weight,this.renderingPipeline.chromaticAberrationEnabled=((u=e.chromaticAberration)==null?void 0:u.enabled)??d.chromaticAberration.enabled,this.renderingPipeline.chromaticAberration.aberrationAmount=((h=e.chromaticAberration)==null?void 0:h.aberrationAmount)??d.chromaticAberration.aberrationAmount,this.renderingPipeline.chromaticAberration.radialIntensity=((g=e.chromaticAberration)==null?void 0:g.radialIntensity)??d.chromaticAberration.radialIntensity,this.renderingPipeline.chromaticAberration.direction=(p=e.chromaticAberration)!=null&&p.direction?new m.Vector2(e.chromaticAberration.direction.x,e.chromaticAberration.direction.y):new m.Vector2(d.chromaticAberration.direction.x,d.chromaticAberration.direction.y),this.renderingPipeline.imageProcessing.colorCurvesEnabled=((f=e.colorCurves)==null?void 0:f.enabled)??d.colorCurves.enabled,this.renderingPipeline.imageProcessing.colorCurves=e.colorCurves?this.updateColorCurve(e.colorCurves):new N.ColorCurves,this.renderingPipeline.depthOfFieldEnabled=((y=e.depthOfField)==null?void 0:y.enabled)??d.depthOfField.enabled,e.depthOfField)switch(e.depthOfField.blurLevel??d.depthOfField.blurLevel){case"Low":this.renderingPipeline.depthOfFieldBlurLevel=F.DepthOfFieldEffectBlurLevel.Low;break;case"Medium":this.renderingPipeline.depthOfFieldBlurLevel=F.DepthOfFieldEffectBlurLevel.Medium;break;case"High":this.renderingPipeline.depthOfFieldBlurLevel=F.DepthOfFieldEffectBlurLevel.High;break}if(this.renderingPipeline.depthOfField.focalLength=((J=e.depthOfField)==null?void 0:J.focalLength)??d.depthOfField.focalLength,this.renderingPipeline.depthOfField.fStop=((_=e.depthOfField)==null?void 0:_.fStop)??d.depthOfField.fStop,this.renderingPipeline.depthOfField.focusDistance=((ee=e.depthOfField)==null?void 0:ee.focusDistance)??d.depthOfField.focusDistance,this.renderingPipeline.depthOfField.lensSize=((te=e.depthOfField)==null?void 0:te.lensSize)??d.depthOfField.lensSize,this.renderingPipeline.grainEnabled=((ie=e.grain)==null?void 0:ie.enabled)??d.grain.enabled,this.renderingPipeline.grain.animated=((se=e.grain)==null?void 0:se.animated)??d.grain.animated,this.renderingPipeline.grain.intensity=((ne=e.grain)==null?void 0:ne.intensity)??d.grain.intensity,this.renderingPipeline.imageProcessing.contrast=((re=e.misc)==null?void 0:re.contrast)??d.misc.contrast,this.renderingPipeline.imageProcessing.exposure=((ae=e.misc)==null?void 0:ae.exposure)??d.misc.exposure,this.renderingPipeline.imageProcessing.toneMappingEnabled=((oe=e.misc)==null?void 0:oe.toneMappingEnabled)??d.misc.toneMappingEnabled,this.renderingPipeline.imageProcessing.toneMappingEnabled)switch(e.misc.toneMappingType??d.misc.toneMappingType){case"Standard":this.renderingPipeline.imageProcessing.toneMappingType=A.ImageProcessingConfiguration.TONEMAPPING_STANDARD;break;case"ACES":this.renderingPipeline.imageProcessing.toneMappingType=A.ImageProcessingConfiguration.TONEMAPPING_ACES;break}if(this.renderingPipeline.sharpenEnabled=((le=e.sharpen)==null?void 0:le.enabled)??d.sharpen.enabled,this.renderingPipeline.sharpen.colorAmount=((he=e.sharpen)==null?void 0:he.colorAmount)??d.sharpen.colorAmount,this.renderingPipeline.sharpen.edgeAmount=((ce=e.sharpen)==null?void 0:ce.edgeAmount)??d.sharpen.edgeAmount,this.renderingPipeline.imageProcessing.vignetteEnabled=((de=e.vignette)==null?void 0:de.enabled)??d.vignette.enabled,(ue=e.vignette)!=null&&ue.center?(this.renderingPipeline.imageProcessing.vignetteCenterX=e.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=e.vignette.center.y):(this.renderingPipeline.imageProcessing.vignetteCenterX=d.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=d.vignette.center.y),e.vignette)switch(((ge=e.vignette)==null?void 0:ge.blendMode)??d.vignette.blendMode){case"Multiply":this.renderingPipeline.imageProcessing.vignetteBlendMode=A.ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY;break;case"Opaque":this.renderingPipeline.imageProcessing.vignetteBlendMode=A.ImageProcessingConfiguration.VIGNETTEMODE_OPAQUE;break}(me=e.vignette)!=null&&me.colorRgba?this.renderingPipeline.imageProcessing.vignetteColor=new b.Color4(e.vignette.colorRgba.r,e.vignette.colorRgba.g,e.vignette.colorRgba.b,e.vignette.colorRgba.a):(pe=e.vignette)!=null&&pe.colorHex?this.renderingPipeline.imageProcessing.vignetteColor=b.Color4.FromHexString(e.vignette.colorHex):this.renderingPipeline.imageProcessing.vignetteColor=new b.Color4(d.vignette.colorRgba.r,d.vignette.colorRgba.g,d.vignette.colorRgba.b,d.vignette.colorRgba.a),this.renderingPipeline.imageProcessing.vignetteStretch=((fe=e.vignette)==null?void 0:fe.stretch)??d.vignette.stretch,this.renderingPipeline.imageProcessing.vignetteWeight=((be=e.vignette)==null?void 0:be.weight)??d.vignette.weight,this.renderingPipeline.prepare(),this.currentConfiguration=e}}updateColorCurve(e){const t=new N.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}}xe.GLTF2.GLTFLoader.RegisterExtension("glbPostProcessor",function(s){return new Be(s)}),L.SceneLoader.OnPluginActivatedObservable.add(s=>{if(s.name==="gltf"){const e=s;e.transparencyAsCoverage=!0}});function j(s){return new m.Vector3(s.x,s.y,s.z)}function q(s){return{x:s.x,y:s.y,z:s.z}}class Je{constructor(e){var l;this.focusLostNotified=!1,this.focusLostObservable=new M.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(h=>{h.updateDynamicTextures()}),this.scene.render();const u=Math.max((this.camera.lowerRadiusLimit??1)*.01,.001);!this.camera.isRunningFramingBehavior&&!this.camera.target.equalsWithEpsilon(this.camera.lastFocus,u)&&!this.focusLostNotified&&(this.focusLostObservable.notifyObservers(void 0),this.focusLostNotified=!0),this.screenshotPrepareResolve&&(this.screenshotPrepareResolve(),this.screenshotPrepareResolve=void 0)},this.configuration=new G(e);const i=(()=>{if(!(e!=null&&e.noRender))return this.configuration.createCanvas()})(),n="1.5.6";we.DracoCompression.Configuration={decoder:{wasmUrl:`https://www.gstatic.com/draco/versioned/decoders/${n}/draco_wasm_wrapper_gltf.js`,wasmBinaryUrl:`https://www.gstatic.com/draco/versioned/decoders/${n}/draco_decoder_gltf.wasm`,fallbackUrl:`https://www.gstatic.com/draco/versioned/decoders/${n}/draco_decoder_gltf.js`}},i&&(i.getContext("webgl2")||i.getContext("webgl"));const a=console.log;console.log=()=>{};const o=i?new D.Engine(i,!0,{adaptToDeviceRatio:!0,limitDeviceRatio:2,premultipliedAlpha:!1,preserveDrawingBuffer:!!(e!=null&&e.backgroundImage),audioEngine:!1,stencil:this.configuration.highlights.enabled,forceSRGBBufferSupportState:!0}):new ye.NullEngine;console.log=a,o.hideLoadingUI(),window.addEventListener("resize",this.fireResizeEvent.bind(this)),this.engine=o,this.scene=new Me.Scene(o),this.scene.autoClear=!0,this.scene.autoClearDepthAndStencil=!0,this.camera=S.create(this.scene,this.configuration),this.scene.activeCamera=this.camera,this.renderingPipeline=new Xe(this.scene,!1,this.camera),this.scene.clearColor=this.configuration.scene.clearColor;const r=V.CubeTexture.CreateFromPrefilteredData(this.configuration.scene.environment.file,this.scene);r.rotationY=this.configuration.scene.environment.rotationY,this.scene.environmentTexture=r,this.scene.environmentIntensity=this.configuration.scene.environment.intensity,(l=this.configuration.options)!=null&&l.renderingPipelineConfiguration?this.renderingPipeline.setConfiguration(this.configuration.options.renderingPipelineConfiguration):(this.scene.imageProcessingConfiguration.exposure=this.configuration.lighting.exposure,this.scene.imageProcessingConfiguration.contrast=this.configuration.lighting.contrast),this.glowLayerManager=new je(this.scene,this.configuration.emissiveGlowIntensity),this.initPromise=new Promise(u=>{this.scene.onReadyObservable.addOnce(()=>{this.initComplete=!0,u()})}),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(T.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(n=>n.getIsInitialized()))return this.queuedCameraAnimation=e,Promise.resolve();let t=()=>{};const i=async()=>{this.isAnimatingCamera=!0,await Ne(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(n=>{t=n})):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 m.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===T.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=>{const n=()=>{const a=this.configuration;this.camera.rerunFramingBehavior(()=>{this.focusLostNotified=!1,a.camera.limits.min.radius&&(this.camera.lowerRadiusLimit=a.camera.limits.min.radius),a.camera.limits.max.radius&&(this.camera.upperRadiusLimit=a.camera.limits.max.radius),i()})};this.scene.onAfterRenderObservable.addOnce(n)}),this.isAnimatingCamera=!1,this.queuedAnimationFunction&&this.queuedAnimationFunction(),this.queuedAnimationFunction=void 0,e()};return this.isAnimatingCamera?(this.queuedAnimationFunction=t,new Promise(i=>{e=i})):t()}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 v.ArcRotateCamera("screenshotCamera",0,0,0,m.Vector3.Zero(),this.scene);try{const n=t.latDeg*Math.PI/180,a=t.lonDeg*Math.PI/180;i.target=t.target?new m.Vector3(t.target.x,t.target.y,t.target.z):m.Vector3.Zero(),i.alpha=a,i.beta=n,i.radius=t.radius||this.camera.radius,i.minZ=.01,this.scene.render();const o=await Ce.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,n=e.camera.limits.min.beta,a=e.camera.limits.max.beta;if(t===void 0||i===void 0||n===void 0||a===void 0)return!0;const o=[t,i],r=[n,a],l=o.every(h=>h===t),u=r.every(h=>h===n);return!l&&!u}fireResizeEvent(){this.getNumViewports()>0&&this.engine.resize()}setHighlights(e,t){var n;e.length===0&&((n=this.highlightLayer)==null||n.dispose(),this.highlightLayer=void 0),this.highlightLayer||(this.highlightLayer=new ve.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 b.Color3(t[0],t[1],t[2]).toLinearSpace():void 0;e.forEach(a=>{const o=this.scene.materials.find(r=>r.name===a.name&&r.id===a.id);o&&o.getBindedMeshes().forEach(r=>{var l;return(l=this.highlightLayer)==null?void 0:l.addMesh(r,i||b.Color3.FromHexString("#fcba03"))})})}setRenderingPipelineConfiguration(e){this.renderingPipeline&&this.renderingPipeline.setConfiguration(e)}loadModel(e,t){const i=new $e({enablePicking:this.configuration.highlights.enabled,modelDetails:e,scene:this.scene,previewService:this,progressHandler:t});return i.getInitializationPromise().then(()=>{this.modelContainers.size<=1&&this.camera.rerunFramingBehavior(()=>{this.scene.onAfterRenderObservable.addOnce(()=>{this.queuedCameraAnimation&&(this.executeCameraAnimation(this.queuedCameraAnimation),this.queuedCameraAnimation=void 0)})},1)}),this.configuration.highlights.enabled&&(i.registerMaterialSelectedCallback(n=>{this.setHighlights([n])}),i.registerMaterialDeselectedCallback(()=>{this.setHighlights([])})),this.modelContainers.set(i.getId(),i),this.triggerModelLoadEvent({eventType:"load",modelContainer:i}),i}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(n=>n.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 n=m.Matrix.Compose(j(i||{x:1,y:1,z:1}),m.Quaternion.FromEulerVector(j(t||{x:0,y:0,z:0})),j(e||{x:0,y:0,z:0})),a=m.Matrix.RotationAxis(m.Vector3.Up(),Math.PI),o=n.multiply(a),r=m.Vector3.Zero(),l=m.Quaternion.Identity(),u=m.Vector3.Zero();return o.decompose(u,l,r),l.multiplyInPlace(m.Quaternion.FromEulerAngles(0,Math.PI,0)),{position:q(r),rotation:q(l.toEulerAngles()),scale:q(u)}}updatePreviewOptions(e){var n;const t=new G(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=V.CubeTexture.CreateFromPrefilteredData(t.scene.environment.file,this.scene),i.rotationY=this.configuration.scene.environment.rotationY,this.scene.environmentTexture=i),i.rotationY=t.scene.environment.rotationY,this.scene.environmentIntensity=t.scene.environment.intensity,(n=t.options)!=null&&n.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.configuration=t}reattachControls(e,t=2){if(this.scene.detachControl(),this.engine.inputElement=e,this.camera){this.camera.attachControl(!0,!1,t);const i=this.camera.inputs.attached.pointers;i.multiTouchPanning=!1}this.scene.attachControl(!0,!0,!0)}}c.MaterialEffectMode=R,c.ProductCameraRig=T,c.REFLECTION_PROBE_RESOLUTION=H,c.RenderingConfiguration=C,c.SpiffCommerce3DPreviewService=Je,c.renderingPipelineDefaults=d,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
1
+ (function(c,v){typeof exports=="object"&&typeof module<"u"?v(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/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/loaders/glTF/glTFFileLoader"),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/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/loaders/glTF/glTFFileLoader","@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"],v):(c=typeof globalThis<"u"?globalThis:c||self,v(c.Preview={},c.arcRotateCamera,c.engine,c.nullEngine,c.highlightLayer,c.sceneLoader,c.cubeTexture,c.math_color,c.math_vector,c.dracoCompression,c.observable,c.tools,c.scene,c.glTF,c.pbrMaterial,c.mirrorTexture,c.math,c.reflectionProbe,c.glowLayer,c.actionManager,c.directActions,c.mesh,c.transformNode,c.glTFFileLoader,c.dynamicTexture,c.texture,c.animation,c.easing,c.assetsManager,c.colorCurves,c.imageProcessingConfiguration,c.RenderPipeline,c.depthOfFieldEffect))})(this,function(c,v,D,ye,ve,L,V,b,m,Ce,M,we,Me,xe,O,Pe,P,Ae,Te,F,k,Re,Ee,Le,Oe,Fe,C,z,Ie,N,A,Se,I){"use strict";var T=(s=>(s[s.Orbit=0]="Orbit",s[s.Pan=1]="Pan",s))(T||{}),R=(s=>(s.None="None",s.RemoveWhenSelected="RemoveWhenSelected",s.ApplyWhenSelected="ApplyWhenSelected",s))(R||{});class G{constructor(e){this.getSceneClearColor=()=>{var i,n,a,o;const t=(i=this.customOptions)!=null&&i.transparentBackground||(n=this.customOptions)!=null&&n.backgroundImage?0:1;if(this.customOptions&&((a=this.customOptions)!=null&&a.transparentBackground)||(o=this.customOptions)!=null&&o.backgroundImage)return new b.Color4(0,0,0,t).toLinearSpace();if(this.customOptions&&this.customOptions.backgroundColor){const r=b.Color3.FromHexString(this.customOptions.backgroundColor);return new b.Color4(r.r,r.g,r.b,t).toLinearSpace()}return new b.Color4(.98,.98,.98,t).toLinearSpace()},this.highlightColorFromConfig=()=>this.customOptions&&this.customOptions.highlightColor?this.hexToColor4(this.customOptions.highlightColor):new b.Color4(.98,.98,.98,1).toLinearSpace(),this.hexToColor4=(t,i=1)=>{const n=b.Color3.FromHexString(t);return new b.Color4(n.r,n.g,n.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,n,a;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:((n=this.customOptions)==null?void 0:n.environmentIntensity)??1,rotationY:(((a=this.customOptions)==null?void 0:a.environmentRotationY)??0)*(Math.PI/180)}}}get camera(){var e,t,i,n,a,o,r,l,u,h,g,p,f;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:(n=this.customOptions)!=null&&n.lowerAlphaLimitDeg?((a=this.customOptions)==null?void 0:a.lowerAlphaLimitDeg)*Math.PI/180:void 0,beta:(o=this.customOptions)!=null&&o.lowerBetaLimitDeg?((r=this.customOptions)==null?void 0:r.lowerBetaLimitDeg)*Math.PI/180:void 0,radius:(l=this.customOptions)==null?void 0:l.minZoomOverride},max:{alpha:(u=this.customOptions)!=null&&u.upperAlphaLimitDeg?((h=this.customOptions)==null?void 0:h.upperAlphaLimitDeg)*Math.PI/180:void 0,beta:(g=this.customOptions)!=null&&g.upperBetaLimitDeg?((p=this.customOptions)==null?void 0:p.upperBetaLimitDeg)*Math.PI/180:void 0,radius:(f=this.customOptions)==null?void 0:f.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,n;return{exposure:((t=(e=this.customOptions)==null?void 0:e.lighting)==null?void 0:t.exposure)??.9,contrast:((n=(i=this.customOptions)==null?void 0:i.lighting)==null?void 0:n.contrast)??1.6}}get emissiveGlowIntensity(){var e;return((e=this.customOptions)==null?void 0:e.emissiveGlowIntensity)??.5}}class w{static getDynamicTextureResolution(){return this.getIsMobile()||!w.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 H=128,d={antiAliasing:{samples:4,fxaaEnabled:!1},bloom:{enabled:!1,kernel:64,scale:.5,threshold:.9,weight:.15},chromaticAberration:{enabled:!1,aberrationAmount:30,direction:{x:0,y:0},radialIntensity:0},colorCurves:{enabled:!1},depthOfField:{enabled:!1,blurLevel:"Low",focalLength:50,focusDistance:2e3,fStop:1.4,lensSize:50},grain:{enabled:!1,animated:!1,intensity:30},misc:{contrast:1,exposure:1,toneMappingEnabled:!1,toneMappingType:"Standard"},sharpen:{enabled:!1,colorAmount:1,edgeAmount:.3},vignette:{enabled:!1,blendMode:"Multiply",cameraFov:.5,center:{x:0,y:0},colorHex:"#000000ff",colorRgba:{r:0,g:0,b:0,a:1},stretch:0,weight:1}};class Be{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(n){t.extras&&Object.keys(t.extras).forEach(a=>{const o=t.extras[a];n.metadata[a]=o}),i(n)})}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 O.PBRMaterial))){if(e.extras.sheen){const i=t;i.sheen.isEnabled=!0,i.sheen.intensity=e.extras.sheen}if(e.extras.translucency){const i=t;i.subSurface.isTranslucencyEnabled=!0,i.subSurface.translucencyIntensity=e.extras.translucency,e.extras.translucencyR&&e.extras.translucencyG&&e.extras.translucencyB&&(i.subSurface.tintColor=new P.Color3(e.extras.translucencyR,e.extras.translucencyG,e.extras.translucencyB))}if(e.extras.refractionIOR){const i=t;i.subSurface.isRefractionEnabled=!0,i.subSurface.volumeIndexOfRefraction=e.extras.refractionIOR}if(e.extras.useDepthPrePass){const i=t;i.needDepthPrePass=!0,i.forceIrradianceInFragment=!0}if(e.extras.useParallax){const i=t;i.useParallax=!0,i.useParallaxOcclusion=!0,i.parallaxScaleBias=e.extras.useParallax}}}applyReflections(e){function t(a){const o=[];return a.transformNodes.forEach(r=>{r.metadata&&r.metadata.reflective&&o.push(...r.getChildMeshes())}),a.meshes.forEach(r=>{r.metadata&&r.metadata.reflective&&!o.includes(r)&&o.push(r)}),o}function i(a,o=1){const r=a.material;if(!r)return;const l=new Pe.MirrorTexture("mirror",w.getMirrorTextureResolution(),e,!0);l.renderList=t(e);const u=a.getVerticesData("normal");if(!u)throw new Error("Mirror attribute specified on: "+a.name+"But no normals exist to generate a mirror from!");a.computeWorldMatrix(!0);const h=a.getWorldMatrix(),g=P.Vector3.TransformNormal(new P.Vector3(u[0],u[1],u[2]),h).normalize(),p=P.Plane.FromPositionAndNormal(a.position,g.scale(-1));l.mirrorPlane=p,l.level=o,r.reflectionTexture=l}function n(a){const o=a.material,r=new Ae.ReflectionProbe("probe-"+o.name,H,e);r.attachToMesh(a),r.renderList&&r.renderList.push(...t(e)),o.reflectionTexture=r.cubeTexture}e.meshes.forEach(a=>{const o=a.metadata;o&&(o.mirrorTexture&&i(a,o.mirrorTexture),o.reflectionProbe&&n(a))})}}class je{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 Te.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)}}}const K=new Map;async function U(s,e,t){const i=K.get(s);if(i&&i.scene.uid===e.uid)return i;{const n=await L.SceneLoader.LoadAssetContainerAsync(s,void 0,e,t);return K.set(s,n),n}}L.SceneLoader.OnPluginActivatedObservable.add(s=>{s.name==="gltf"&&(s.animationStartMode=Le.GLTFLoaderAnimationStartMode.NONE)});function qe(s,e,t,i,n=""){t.forEach(a=>{const o=a.getID(),r=a.getName(),l=w.getDynamicTextureResolution();s.filter(h=>h.name===n+r).forEach(h=>{const g=i.get(o),p=!1;if(g)W(h,g),g.update(p);else{const f=De(r,e,l.width,l.height);i.set(o,f),a.setStaticContext(f.getContext()),W(h,f),f.onLoadObservable.addOnce(()=>{f.update(p)})}})})}function De(s,e,t,i){const n=new Oe.DynamicTexture(s,{width:t,height:i},e,w.shouldMipMap(),Fe.Texture.TRILINEAR_SAMPLINGMODE,D.Engine.TEXTUREFORMAT_RGBA),a=n.getContext();return a&&(a.fillStyle="#f5f5f5",a.fillRect(0,0,t,i),n.update()),n}function W(s,e){if(s instanceof O.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 Ve(){const s=()=>Math.floor((1+Math.random())*65536).toString(16).substring(1);return s()+s()+"-"+s()+"-"+s()+"-"+s()+"-"+s()+s()+s()}const x=60,Q=1;function Y(s){return s.targetedAnimations.map(t=>t.animation.framePerSecond).reduce((t,i)=>t+i,0)/s.targetedAnimations.length||0}function ke(s,e,t,i,n,a){const o=n?s.filter(h=>h.name===n):s;if(o.length===0){console.warn(`No animations found for name: ${n}`);return}let r=0;const l=()=>{r++,r===o.length&&a&&a()},u=(h,g,p,f,y)=>{h.stop(),h.start(g,p,f,y),a&&(g==!1||g===void 0&&!h.loopAnimation?h.onAnimationGroupEndObservable.addOnce(()=>{l()}):h.onAnimationLoopObservable.addOnce(()=>{l()}))};if(i!==void 0&&t!==void 0&&i===t){o.forEach(h=>{const g=Y(h),p=i*g;u(h,!1,Q,p,p)});return}o.forEach(h=>{const g=Y(h),p=i!==void 0?i*g:void 0,f=t!==void 0?t*g:void 0;u(h,e,Q,p,f)})}function ze(s){s.forEach(e=>{e.reset(),e.stop()})}function Ne(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 n=[],a=t.target,o=0,r=a?1:0;if(t.target&&Object.keys(t.target).length>0&&n.push(E("cameraTargetLerp","target",new m.Vector3().copyFrom(e.target),new m.Vector3(t.target.x,t.target.y,t.target.z),C.Animation.ANIMATIONTYPE_VECTOR3,o)),n.push(E("cameraAlphaLerp","alpha",e.alpha,Z(t.lonDeg),C.Animation.ANIMATIONTYPE_FLOAT,r)),n.push(E("cameraBetaLerp","beta",e.beta,Z(t.latDeg),C.Animation.ANIMATIONTYPE_FLOAT,r)),t.radius!==void 0){const h=Math.max(.01,t.radius);n.push(E("cameraRadiusLerp","radius",e.radius,h,C.Animation.ANIMATIONTYPE_FLOAT,r))}e.animations.push(...n);const u=e.useAutoRotationBehavior;e.disableAutoRotationBehavior(),s.beginAnimation(e,0,a?x*2:x,!1,1,()=>{e.animations=[],u&&e.enableAutoRotationBehavior(),i()})})}function Z(s){return s*Math.PI/180}function E(s,e,t,i,n,a=0,o=C.Animation.ANIMATIONLOOPMODE_CONSTANT){const r=new z.QuadraticEase;r.setEasingMode(z.EasingFunction.EASINGMODE_EASEINOUT);const l=new C.Animation(s,e,x,n,o),u=[];return a>0&&u.push({frame:0,value:t}),u.push({frame:x*a,value:t}),u.push({frame:x*(a+1),value:i}),l.setKeys(u),l.setEasingFunction(r),l}function Ge(s,e,t){return s<e?s=t-(e-s)%(t-e):s=e+(s-e)%(t-e)}const He={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(a=>{Ue(a,s,e,t,i)}),Ye(s,e)}function Ue(s,e,t,i,n){const a=He[s];if(!a)throw new Error("Unexpected texture name encountered.");const o=e[a],r=o==null?void 0:o.fileLink;r?s==="reflectionTexture"?r.endsWith(".env")||r.endsWith(".dds")?i.addCubeTextureTask(s,r,void 0,!1,void 0,!0):r.endsWith(".hdr")?i.addHDRCubeTextureTask(s,r,128,!1,!0,!1):i.addTextureTask(s,r,!1,!1):i.addTextureTask(s,r,!1,!1):n&&t[s]&&(t[s]&&t[s].dispose(),t[s]=null,We(s,t))}function We(s,e){s==="opacityTexture"&&(e.useAlphaFromAlbedoTexture=!0),s==="metallicTexture"&&(e.useRoughnessFromMetallicTextureAlpha=!1,e.useRoughnessFromMetallicTextureGreen=!1,e.useMetallnessFromMetallicTextureBlue=!1),s==="refractionTexture"&&(e.subSurface.isRefractionEnabled=!1,e.subSurface.refractionIntensity=1),s==="reflectionTexture"&&(e.environmentIntensity=1),s==="emissiveTexture"&&(e.emissiveIntensity=0,e.emissiveColor=new b.Color3(0,0,0),e.reflectionTexture)}function Qe(s,e,t,i){if(!e){console.error("Failed to apply texture to material: material is null.");return}s==="opacityTexture"&&(e.useAlphaFromAlbedoTexture=!1),s==="metallicTexture"&&(e.useRoughnessFromMetallicTextureAlpha=!1,e.useRoughnessFromMetallicTextureGreen=!0,e.useMetallnessFromMetallicTextureBlue=!0),s==="refractionTexture"&&(e.subSurface.isRefractionEnabled=!0,e.subSurface.refractionIntensity=t.refractionIntensity||1),s==="reflectionTexture"&&(e.environmentIntensity=t.reflectionIntensity||1,i.isCube&&(i.rotationY=t.reflectionRotation?t.reflectionRotation*Math.PI/180:0)),e[s]=i,s==="emissiveTexture"&&(e.emissiveColor=new b.Color3(1,1,1),e.emissiveIntensity=1)}function Ye(s,e){s.clearCoat&&(s.clearCoat===R.RemoveWhenSelected?(e.clearCoat.isEnabled=!1,e.clearCoat.indexOfRefraction=1.5):s.clearCoat===R.ApplyWhenSelected&&(e.clearCoat.isEnabled=!0,e.clearCoat.indexOfRefraction=s.clearCoatIOR||e.clearCoat.indexOfRefraction))}class Ze{constructor(e,t,i){this.materialVariantMap=new Map,this.keysThatRemovedBaseModel=[],this.loadedContainerForKey=new Map,this.loadedMaterialsForKey=new Map,this.scene=e,this.renameClonedAsset=t,this.setBaseModelEnabled=i}async applyMaterial(e,t,i,n){return new Promise(a=>{const o=this.materialVariantMap.get(e);this.materialVariantMap.set(e,{...o,...t});const r=this.renameClonedAsset(e),l=this.scene.materials.filter(h=>h.name===r);if(l.length===0){a();return}const u=new Ie.AssetsManager(this.scene);u.useDefaultLoadingScreen=!1,l.forEach(h=>Ke(t,h,u,n)),u.onProgress=(h,g,p)=>{i&&i(h/g*100,100,p.name)},u.onFinish=h=>{h.forEach(g=>{const p=g;i&&i(100,100,g.name),this.scene.materials.filter(y=>y.name===r).forEach(y=>Qe(g.name,y,t,p.texture))}),a()},u.loadAsync()})}async applyModel(e,t,i,n){var l,u;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),(l=this.loadedContainerForKey.get(e))==null||l.dispose(),this.loadedContainerForKey.delete(e),this.loadedMaterialsForKey.delete(e),this.keysThatRemovedBaseModel=this.keysThatRemovedBaseModel.filter(h=>h!==e),Promise.resolve(void 0);const o=(await U(i,this.scene,n)).instantiateModelsToScene(this.renameClonedAsset,!0);this.loadedContainerForKey.has(e)&&((u=this.loadedContainerForKey.get(e))==null||u.dispose(),this.loadedContainerForKey.delete(e),this.loadedMaterialsForKey.delete(e)),t&&await this.setBaseModelEnabled(!1),this.loadedContainerForKey.set(e,o),this.loadedMaterialsForKey.set(e,$(o));const r=[];return this.materialVariantMap.forEach(async(h,g)=>{r.push(this.applyMaterial(g,h))}),await Promise.all(r),o}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 $(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(n=>{const a=n.getMaterial(!1);a&&!e.includes(a)&&e.push(a)})})}),e}function X(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 M.Observable,this.materialDeselectedObservable=new M.Observable,this.materialVariantObservable=new M.Observable,this.modelVariantObservable=new M.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:n,progressHandler:a,scene:o}=e;this.enablePicking=t,this.contextService=i.contextService,this.id=Ve(),this.previewService=n,this.scene=o,this.variantManager=new Ze(o,this.renameClonedAsset.bind(this),this.setBaseModelEnabled.bind(this)),this.transformRoot=new Ee.TransformNode("root",this.scene);const r=async()=>{if(!i.model)throw new Error("Model container constructed with no URL. This is currently unsupported.");return this.assetContainer=await U(i.model,o,a),await this.instantiate(),this};this.importPromise=r()}async applyMaterialVariant(e,t,i,n){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,n))}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,n))}return}const a=async()=>{await this.variantManager.applyMaterial(e,i,(o,r,l)=>{this.materialVariantObservable.notifyObservers({remainingCount:o,totalCount:r,taskName:l})},n)};if(this.materialChangesInProgress.includes(e)){if(this.queuedMaterialChanges.has(e)){const o=this.queuedMaterialChanges.get(e);o==null||o.set(t,a)}else{this.queuedMaterialChanges.set(e,new Map);const o=this.queuedMaterialChanges.get(e);o==null||o.set(t,a)}return}if(this.materialChangesInProgress.push(e),await a(),this.queuedMaterialChanges.has(e)){const o=this.queuedMaterialChanges.get(e);if(!o)throw new Error("Target material is undefined");o.forEach(async r=>{await r()}),this.queuedMaterialChanges.delete(e)}this.materialChangesInProgress.splice(this.materialChangesInProgress.indexOf(e),1),this.configureGlowLayer()}async applyModelVariant(e,t,i){if(!this.initialized){this.modelReadyToLoadCallbacks.set(e,this.applyModelVariant.bind(this,e,t,i));return}const n=()=>this.variantManager.applyModel(e,i,t==null?void 0:t.model,r=>{this.modelVariantObservable.notifyObservers({...r,key:e})});if(this.modelChangesInProgress.includes(e)){this.queuedModelChanges.set(e,n);return}const o=await(async()=>{this.modelChangesInProgress.push(e);let r=await n();if(this.queuedModelChanges.has(e)){const l=this.queuedModelChanges.get(e);if(!l)throw new Error("Queued change resolved undefined");r=await l(),this.queuedModelChanges.delete(e)}return this.modelChangesInProgress.splice(this.modelChangesInProgress.indexOf(e),1),r})();this.modelInstance&&ze(this.modelInstance.animationGroups),this.contextService||(this.contextService=t==null?void 0:t.contextService),o?this.configureModelInstance(o):this.configureGlowLayer()}dispose(){var e;this.destroyInstance(),this.variantManager.dispose(),this.dynamicTextures.forEach(t=>t==null?void 0:t.dispose()),this.dynamicTextures.clear(),this.materials.forEach(t=>t&&(t==null?void 0:t.dispose())),this.materials=[],(e=this.transformRoot)==null||e.dispose(),this.transformRoot=void 0,this.previewService.modelUnloaded(this)}executeAnimation(e){if(!this.initialized)return this.queuedModelAnimation=e,Promise.resolve();if(!this.modelInstance)return Promise.resolve();let t=()=>{};const i=async()=>{this.isExecutingAnimation=!0,await new Promise(n=>{ke([...this.modelInstance.animationGroups,...this.variantManager.getAnimationGroups()],e.loop,e.to,e.from,e.name?this.renameClonedAsset(e.name):void 0,n)}),this.isExecutingAnimation=!1,this.queuedAnimationFunction&&this.queuedAnimationFunction(),this.queuedAnimationFunction=void 0,t()};return this.isExecutingAnimation?(this.queuedAnimationFunction=i,new Promise(n=>{t=n})):i()}getAnimations(e){return[...this.animations,...e?X(this.variantManager.getAnimationGroups(),this.renameClonedAsset("")):[]]}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 m.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=m.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 m.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 F.ActionManager(this.scene)),i.actionManager.registerAction(new k.ExecuteCodeAction(F.ActionManager.OnPointerOverTrigger,n=>{n.meshUnderPointer&&i.material&&this.materialSelectedObservable.notifyObservers({id:i.material.id,name:this.stripIdFromName(i.material.name)})})),i.actionManager.registerAction(new k.ExecuteCodeAction(F.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 O.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 a;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,n=this.transformRoot.scaling;this.transformRoot.position=m.Vector3.Zero(),this.transformRoot.rotationQuaternion=m.Quaternion.Identity(),this.transformRoot.scaling=m.Vector3.One();for(const o of e.rootNodes)o.parent=this.transformRoot;this.transformRoot.position=t,this.transformRoot.rotationQuaternion=i,this.transformRoot.scaling=n,this.canvasPanels=((a=this.contextService)==null?void 0:a.getAll())||new Map,qe(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 Re.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=$(this.modelInstance),this.configureModelInstance(this.modelInstance),this.animations=X(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 n=this.dynamicTextures.get(i);n&&t.getStaticContextDirty()&&n.isReady()&&(n.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)}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 S extends v.ArcRotateCamera{constructor(e,t,i,n,a,o,r,l){super(e,t,i,n,a,o,l),this.lastFocus=new m.Vector3(0,0,0),this._isRunningFramingBehavior=!1,this.panDenominator=1,this.minZ=.01,this.updateRadiusBounds(this.radius),this.enableFramingBehavior(),this.wheelDeltaPercentage=.01,this.pinchDeltaPercentage=.005,this.useNaturalPinchZoom=!0,r.camera.autoOrientation&&(this.alpha+=Math.PI),r&&(r.camera.limits.min.beta&&(this.lowerBetaLimit=r.camera.limits.min.beta),r.camera.limits.max.beta&&(this.upperBetaLimit=r.camera.limits.max.beta),r.camera.limits.min.alpha&&(this.lowerAlphaLimit=r.camera.limits.min.alpha),r.camera.limits.max.alpha&&(this.upperAlphaLimit=r.camera.limits.max.alpha),r.camera.limits.min.radius&&(this.lowerRadiusLimit=r.camera.limits.min.radius),r.camera.limits.max.radius&&(this.upperRadiusLimit=r.camera.limits.max.radius),r.camera.autoRotation.enabled&&this.enableAutoRotationBehavior(r.camera.autoRotation.idleTimeMs))}get isRunningFramingBehavior(){return this._isRunningFramingBehavior}set isRunningFramingBehavior(e){this._isRunningFramingBehavior=e,!e&&this.framingBehaviourCallback&&(this.framingBehaviourCallback(),this.framingBehaviourCallback=void 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=B(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 n=()=>{this.isRunningFramingBehavior=!1},a=B(this._scene),o=a.max.subtract(a.min),r=a.min.add(o.scale(.5));this.updateRadiusBounds(o.length()*1.5),this.wheelPrecision=100/this.radius,this.panningInertia=0,this.panningOriginTarget.copyFrom(r),this.panDenominator=o.length(),this.lastFocus.copyFrom(r),i.zoomOnBoundingInfo(a.min,a.max,void 0,n),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){const n=B(e),a=n.max.subtract(n.min),o=n.min.add(a.scale(.5)),r=new S("ProductCamera",-(Math.PI/2),Math.PI/2,a.length()*1.5,o,e,t);return r.panningInertia=0,r.panningOriginTarget.copyFrom(o),r.panDenominator=a.length(),r.onAfterCheckInputsObservable.add(()=>{r.panningSensibility=1e3/r.panDenominator}),i&&(e.activeCamera=r),r}}function B(s){if(s.meshes.length===0)return{min:new m.Vector3(-1,-1,-1),max:new m.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 Se.DefaultRenderingPipeline("default",t,e,i?[i]:void 0,!1),this.renderingPipeline.isSupported&&(this.renderingPipeline.prepare(),this.setConfiguration(d))}dispose(){this.renderingPipeline.dispose()}getConfiguration(){return this.currentConfiguration}setConfiguration(e){var t,i,n,a,o,r,l,u,h,g,p,f,y,_,J,ee,te,ie,se,ne,re,ae,oe,le,he,ce,de,ue,ge,me,pe,fe,be;if(this.renderingPipeline.isSupported){if(this.renderingPipeline.samples=((t=e.antiAliasing)==null?void 0:t.samples)??d.antiAliasing.samples,this.renderingPipeline.fxaaEnabled=((i=e.antiAliasing)==null?void 0:i.fxaaEnabled)??d.antiAliasing.fxaaEnabled,this.renderingPipeline.bloomEnabled=((n=e.bloom)==null?void 0:n.enabled)??d.bloom.enabled,this.renderingPipeline.bloomKernel=((a=e.bloom)==null?void 0:a.kernel)??d.bloom.kernel,this.renderingPipeline.bloomScale=((o=e.bloom)==null?void 0:o.scale)??d.bloom.scale,this.renderingPipeline.bloomThreshold=((r=e.bloom)==null?void 0:r.threshold)??d.bloom.threshold,this.renderingPipeline.bloomWeight=((l=e.bloom)==null?void 0:l.weight)??d.bloom.weight,this.renderingPipeline.chromaticAberrationEnabled=((u=e.chromaticAberration)==null?void 0:u.enabled)??d.chromaticAberration.enabled,this.renderingPipeline.chromaticAberration.aberrationAmount=((h=e.chromaticAberration)==null?void 0:h.aberrationAmount)??d.chromaticAberration.aberrationAmount,this.renderingPipeline.chromaticAberration.radialIntensity=((g=e.chromaticAberration)==null?void 0:g.radialIntensity)??d.chromaticAberration.radialIntensity,this.renderingPipeline.chromaticAberration.direction=(p=e.chromaticAberration)!=null&&p.direction?new m.Vector2(e.chromaticAberration.direction.x,e.chromaticAberration.direction.y):new m.Vector2(d.chromaticAberration.direction.x,d.chromaticAberration.direction.y),this.renderingPipeline.imageProcessing.colorCurvesEnabled=((f=e.colorCurves)==null?void 0:f.enabled)??d.colorCurves.enabled,this.renderingPipeline.imageProcessing.colorCurves=e.colorCurves?this.updateColorCurve(e.colorCurves):new N.ColorCurves,this.renderingPipeline.depthOfFieldEnabled=((y=e.depthOfField)==null?void 0:y.enabled)??d.depthOfField.enabled,e.depthOfField)switch(e.depthOfField.blurLevel??d.depthOfField.blurLevel){case"Low":this.renderingPipeline.depthOfFieldBlurLevel=I.DepthOfFieldEffectBlurLevel.Low;break;case"Medium":this.renderingPipeline.depthOfFieldBlurLevel=I.DepthOfFieldEffectBlurLevel.Medium;break;case"High":this.renderingPipeline.depthOfFieldBlurLevel=I.DepthOfFieldEffectBlurLevel.High;break}if(this.renderingPipeline.depthOfField.focalLength=((_=e.depthOfField)==null?void 0:_.focalLength)??d.depthOfField.focalLength,this.renderingPipeline.depthOfField.fStop=((J=e.depthOfField)==null?void 0:J.fStop)??d.depthOfField.fStop,this.renderingPipeline.depthOfField.focusDistance=((ee=e.depthOfField)==null?void 0:ee.focusDistance)??d.depthOfField.focusDistance,this.renderingPipeline.depthOfField.lensSize=((te=e.depthOfField)==null?void 0:te.lensSize)??d.depthOfField.lensSize,this.renderingPipeline.grainEnabled=((ie=e.grain)==null?void 0:ie.enabled)??d.grain.enabled,this.renderingPipeline.grain.animated=((se=e.grain)==null?void 0:se.animated)??d.grain.animated,this.renderingPipeline.grain.intensity=((ne=e.grain)==null?void 0:ne.intensity)??d.grain.intensity,this.renderingPipeline.imageProcessing.contrast=((re=e.misc)==null?void 0:re.contrast)??d.misc.contrast,this.renderingPipeline.imageProcessing.exposure=((ae=e.misc)==null?void 0:ae.exposure)??d.misc.exposure,this.renderingPipeline.imageProcessing.toneMappingEnabled=((oe=e.misc)==null?void 0:oe.toneMappingEnabled)??d.misc.toneMappingEnabled,this.renderingPipeline.imageProcessing.toneMappingEnabled)switch(e.misc.toneMappingType??d.misc.toneMappingType){case"Standard":this.renderingPipeline.imageProcessing.toneMappingType=A.ImageProcessingConfiguration.TONEMAPPING_STANDARD;break;case"ACES":this.renderingPipeline.imageProcessing.toneMappingType=A.ImageProcessingConfiguration.TONEMAPPING_ACES;break}if(this.renderingPipeline.sharpenEnabled=((le=e.sharpen)==null?void 0:le.enabled)??d.sharpen.enabled,this.renderingPipeline.sharpen.colorAmount=((he=e.sharpen)==null?void 0:he.colorAmount)??d.sharpen.colorAmount,this.renderingPipeline.sharpen.edgeAmount=((ce=e.sharpen)==null?void 0:ce.edgeAmount)??d.sharpen.edgeAmount,this.renderingPipeline.imageProcessing.vignetteEnabled=((de=e.vignette)==null?void 0:de.enabled)??d.vignette.enabled,(ue=e.vignette)!=null&&ue.center?(this.renderingPipeline.imageProcessing.vignetteCenterX=e.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=e.vignette.center.y):(this.renderingPipeline.imageProcessing.vignetteCenterX=d.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=d.vignette.center.y),e.vignette)switch(((ge=e.vignette)==null?void 0:ge.blendMode)??d.vignette.blendMode){case"Multiply":this.renderingPipeline.imageProcessing.vignetteBlendMode=A.ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY;break;case"Opaque":this.renderingPipeline.imageProcessing.vignetteBlendMode=A.ImageProcessingConfiguration.VIGNETTEMODE_OPAQUE;break}(me=e.vignette)!=null&&me.colorRgba?this.renderingPipeline.imageProcessing.vignetteColor=new b.Color4(e.vignette.colorRgba.r,e.vignette.colorRgba.g,e.vignette.colorRgba.b,e.vignette.colorRgba.a):(pe=e.vignette)!=null&&pe.colorHex?this.renderingPipeline.imageProcessing.vignetteColor=b.Color4.FromHexString(e.vignette.colorHex):this.renderingPipeline.imageProcessing.vignetteColor=new b.Color4(d.vignette.colorRgba.r,d.vignette.colorRgba.g,d.vignette.colorRgba.b,d.vignette.colorRgba.a),this.renderingPipeline.imageProcessing.vignetteStretch=((fe=e.vignette)==null?void 0:fe.stretch)??d.vignette.stretch,this.renderingPipeline.imageProcessing.vignetteWeight=((be=e.vignette)==null?void 0:be.weight)??d.vignette.weight,this.renderingPipeline.prepare(),this.currentConfiguration=e}}updateColorCurve(e){const t=new N.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}}xe.GLTF2.GLTFLoader.RegisterExtension("glbPostProcessor",function(s){return new Be(s)}),L.SceneLoader.OnPluginActivatedObservable.add(s=>{if(s.name==="gltf"){const e=s;e.transparencyAsCoverage=!0}});function j(s){return new m.Vector3(s.x,s.y,s.z)}function q(s){return{x:s.x,y:s.y,z:s.z}}class _e{constructor(e){var l;this.focusLostNotified=!1,this.focusLostObservable=new M.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(h=>{h.updateDynamicTextures()}),this.scene.render(),this.camera.isRunningFramingBehavior&&this.camera.getFramingBehavior().isUserIsMoving&&(this.camera.isRunningFramingBehavior=!1);const u=Math.max((this.camera.lowerRadiusLimit??1)*.01,.001);!this.camera.isRunningFramingBehavior&&!this.camera.target.equalsWithEpsilon(this.camera.lastFocus,u)&&!this.focusLostNotified&&(this.focusLostObservable.notifyObservers(void 0),this.focusLostNotified=!0),this.screenshotPrepareResolve&&(this.screenshotPrepareResolve(),this.screenshotPrepareResolve=void 0)},this.configuration=new G(e);const i=(()=>{if(!(e!=null&&e.noRender))return this.configuration.createCanvas()})(),n="1.5.6";Ce.DracoCompression.Configuration={decoder:{wasmUrl:`https://www.gstatic.com/draco/versioned/decoders/${n}/draco_wasm_wrapper_gltf.js`,wasmBinaryUrl:`https://www.gstatic.com/draco/versioned/decoders/${n}/draco_decoder_gltf.wasm`,fallbackUrl:`https://www.gstatic.com/draco/versioned/decoders/${n}/draco_decoder_gltf.js`}},i&&(i.getContext("webgl2")||i.getContext("webgl"));const a=console.log;console.log=()=>{};const o=i?new D.Engine(i,!0,{adaptToDeviceRatio:!0,limitDeviceRatio:2,premultipliedAlpha:!1,preserveDrawingBuffer:!!(e!=null&&e.backgroundImage),audioEngine:!1,stencil:this.configuration.highlights.enabled,forceSRGBBufferSupportState:!0}):new ye.NullEngine;console.log=a,o.hideLoadingUI(),window.addEventListener("resize",this.fireResizeEvent.bind(this)),this.engine=o,this.scene=new Me.Scene(o),this.scene.autoClear=!0,this.scene.autoClearDepthAndStencil=!0,this.camera=S.create(this.scene,this.configuration),this.scene.activeCamera=this.camera,this.renderingPipeline=new Xe(this.scene,!1,this.camera),this.scene.clearColor=this.configuration.scene.clearColor;const r=V.CubeTexture.CreateFromPrefilteredData(this.configuration.scene.environment.file,this.scene);r.rotationY=this.configuration.scene.environment.rotationY,this.scene.environmentTexture=r,this.scene.environmentIntensity=this.configuration.scene.environment.intensity,(l=this.configuration.options)!=null&&l.renderingPipelineConfiguration?this.renderingPipeline.setConfiguration(this.configuration.options.renderingPipelineConfiguration):(this.scene.imageProcessingConfiguration.exposure=this.configuration.lighting.exposure,this.scene.imageProcessingConfiguration.contrast=this.configuration.lighting.contrast),this.glowLayerManager=new je(this.scene,this.configuration.emissiveGlowIntensity),this.initPromise=new Promise(u=>{this.scene.onReadyObservable.addOnce(()=>{this.initComplete=!0,u()})}),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(T.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(n=>n.getIsInitialized()))return this.queuedCameraAnimation=e,Promise.resolve();let t=()=>{};const i=async()=>{this.isAnimatingCamera=!0,await Ne(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(n=>{t=n})):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 m.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===T.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 n=()=>{const a=this.configuration;this.camera.rerunFramingBehavior(()=>{a.camera.limits.min.radius&&(this.camera.lowerRadiusLimit=a.camera.limits.min.radius),a.camera.limits.max.radius&&(this.camera.upperRadiusLimit=a.camera.limits.max.radius),i()})};this.scene.onAfterRenderObservable.addOnce(n)}),this.isAnimatingCamera=!1,this.queuedAnimationFunction&&this.queuedAnimationFunction(),this.queuedAnimationFunction=void 0,e()};return this.isAnimatingCamera?(this.queuedAnimationFunction=t,new Promise(i=>{e=i})):t()}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 v.ArcRotateCamera("screenshotCamera",0,0,0,m.Vector3.Zero(),this.scene);try{const n=t.latDeg*Math.PI/180,a=t.lonDeg*Math.PI/180;i.target=t.target?new m.Vector3(t.target.x,t.target.y,t.target.z):m.Vector3.Zero(),i.alpha=a,i.beta=n,i.radius=t.radius||this.camera.radius,i.minZ=.01,this.scene.render();const o=await we.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,n=e.camera.limits.min.beta,a=e.camera.limits.max.beta;if(t===void 0||i===void 0||n===void 0||a===void 0)return!0;const o=[t,i],r=[n,a],l=o.every(h=>h===t),u=r.every(h=>h===n);return!l&&!u}fireResizeEvent(){this.getNumViewports()>0&&this.engine.resize()}setHighlights(e,t){var n;e.length===0&&((n=this.highlightLayer)==null||n.dispose(),this.highlightLayer=void 0),this.highlightLayer||(this.highlightLayer=new ve.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 b.Color3(t[0],t[1],t[2]).toLinearSpace():void 0;e.forEach(a=>{const o=this.scene.materials.find(r=>r.name===a.name&&r.id===a.id);o&&o.getBindedMeshes().forEach(r=>{var l;return(l=this.highlightLayer)==null?void 0:l.addMesh(r,i||b.Color3.FromHexString("#fcba03"))})})}setRenderingPipelineConfiguration(e){this.renderingPipeline&&this.renderingPipeline.setConfiguration(e)}loadModel(e,t){const i=new $e({enablePicking:this.configuration.highlights.enabled,modelDetails:e,scene:this.scene,previewService:this,progressHandler:t});return i.getInitializationPromise().then(()=>{this.modelContainers.size<=1&&this.camera.rerunFramingBehavior(()=>{this.scene.onAfterRenderObservable.addOnce(()=>{this.queuedCameraAnimation&&(this.executeCameraAnimation(this.queuedCameraAnimation),this.queuedCameraAnimation=void 0)})},1)}),this.configuration.highlights.enabled&&(i.registerMaterialSelectedCallback(n=>{this.setHighlights([n])}),i.registerMaterialDeselectedCallback(()=>{this.setHighlights([])})),this.modelContainers.set(i.getId(),i),this.triggerModelLoadEvent({eventType:"load",modelContainer:i}),i}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(n=>n.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 n=m.Matrix.Compose(j(i||{x:1,y:1,z:1}),m.Quaternion.FromEulerVector(j(t||{x:0,y:0,z:0})),j(e||{x:0,y:0,z:0})),a=m.Matrix.RotationAxis(m.Vector3.Up(),Math.PI),o=n.multiply(a),r=m.Vector3.Zero(),l=m.Quaternion.Identity(),u=m.Vector3.Zero();return o.decompose(u,l,r),l.multiplyInPlace(m.Quaternion.FromEulerAngles(0,Math.PI,0)),{position:q(r),rotation:q(l.toEulerAngles()),scale:q(u)}}updatePreviewOptions(e){var n;const t=new G(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=V.CubeTexture.CreateFromPrefilteredData(t.scene.environment.file,this.scene),i.rotationY=this.configuration.scene.environment.rotationY,this.scene.environmentTexture=i),i.rotationY=t.scene.environment.rotationY,this.scene.environmentIntensity=t.scene.environment.intensity,(n=t.options)!=null&&n.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.configuration=t}reattachControls(e,t=2){if(this.scene.detachControl(),this.engine.inputElement=e,this.camera){this.camera.attachControl(!0,!1,t);const i=this.camera.inputs.attached.pointers;i.multiTouchPanning=!1}this.scene.attachControl(!0,!0,!0)}}c.MaterialEffectMode=R,c.ProductCameraRig=T,c.REFLECTION_PROBE_RESOLUTION=H,c.RenderingConfiguration=w,c.SpiffCommerce3DPreviewService=_e,c.renderingPipelineDefaults=d,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spiffcommerce/preview",
3
- "version": "5.3.9-rc.4",
3
+ "version": "5.3.9-rc.5",
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",