@spiffcommerce/preview 5.3.8-rc.7 → 5.3.9-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -979,6 +979,7 @@ 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
983
  private panDenominator;
983
984
  /**
984
985
  * Returns the framing behavior of this camera.
package/dist/index.esm.js CHANGED
@@ -1,31 +1,32 @@
1
1
  import { ArcRotateCamera as pe } from "@babylonjs/core/Cameras/arcRotateCamera";
2
2
  import { Engine as fe } from "@babylonjs/core/Engines/engine";
3
- import { NullEngine as Ce } from "@babylonjs/core/Engines/nullEngine";
4
- import { HighlightLayer as ye } from "@babylonjs/core/Layers/highlightLayer";
5
- import { SceneLoader as be } from "@babylonjs/core/Loading/sceneLoader";
6
- import { CubeTexture as te } from "@babylonjs/core/Materials/Textures/cubeTexture";
3
+ import { NullEngine as we } from "@babylonjs/core/Engines/nullEngine";
4
+ import { HighlightLayer as Ce } from "@babylonjs/core/Layers/highlightLayer";
5
+ import { SceneLoader as S } from "@babylonjs/core/Loading/sceneLoader";
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 ie, Matrix as se } from "@babylonjs/core/Maths/math.vector";
9
- import { DracoCompression as Me } from "@babylonjs/core/Meshes/Compression/dracoCompression";
8
+ import { Vector3 as g, Quaternion as y, Vector2 as se, Matrix as ne } from "@babylonjs/core/Maths/math.vector";
9
+ import { DracoCompression as ye } from "@babylonjs/core/Meshes/Compression/dracoCompression";
10
10
  import { Observable as C } from "@babylonjs/core/Misc/observable";
11
- import { Tools as xe } from "@babylonjs/core/Misc/tools";
12
- import { Scene as Pe } from "@babylonjs/core/scene";
13
- import { GLTF2 as Ae } from "@babylonjs/loaders/glTF";
14
- import { PBRMaterial as F } from "@babylonjs/core/Materials/PBR/pbrMaterial";
15
- import { MirrorTexture as Re } from "@babylonjs/core/Materials/Textures/mirrorTexture";
16
- import { Color3 as Te, Vector3 as ne, Plane as Ee } from "@babylonjs/core/Maths/math";
17
- import { ReflectionProbe as Oe } from "@babylonjs/core/Probes/reflectionProbe";
18
- import { GlowLayer as Le } from "@babylonjs/core/Layers/glowLayer";
11
+ import { Tools as Me } from "@babylonjs/core/Misc/tools";
12
+ import { Scene as xe } from "@babylonjs/core/scene";
13
+ import { GLTF2 as Pe } from "@babylonjs/loaders/glTF";
14
+ import { PBRMaterial as B } from "@babylonjs/core/Materials/PBR/pbrMaterial";
15
+ import { MirrorTexture as Ae } from "@babylonjs/core/Materials/Textures/mirrorTexture";
16
+ import { Color3 as Re, Vector3 as re, Plane as Te } from "@babylonjs/core/Maths/math";
17
+ import { ReflectionProbe as Ee } from "@babylonjs/core/Probes/reflectionProbe";
18
+ import { GlowLayer as Oe } from "@babylonjs/core/Layers/glowLayer";
19
19
  import { ActionManager as R } from "@babylonjs/core/Actions/actionManager";
20
- import { ExecuteCodeAction as re } from "@babylonjs/core/Actions/directActions";
21
- import { Mesh as Ie } from "@babylonjs/core/Meshes/mesh";
22
- import { TransformNode as Se } from "@babylonjs/core/Meshes/transformNode";
23
- import { DynamicTexture as Fe } from "@babylonjs/core/Materials/Textures/dynamicTexture";
20
+ import { ExecuteCodeAction as ae } from "@babylonjs/core/Actions/directActions";
21
+ import { Mesh as Le } from "@babylonjs/core/Meshes/mesh";
22
+ import { TransformNode as Ie } from "@babylonjs/core/Meshes/transformNode";
23
+ import { GLTFLoaderAnimationStartMode as Fe } from "@babylonjs/loaders/glTF/glTFFileLoader";
24
+ import { DynamicTexture as Se } from "@babylonjs/core/Materials/Textures/dynamicTexture";
24
25
  import { Texture as Be } from "@babylonjs/core/Materials/Textures/texture";
25
26
  import { Animation as v } from "@babylonjs/core/Animations/animation";
26
27
  import { QuadraticEase as De, EasingFunction as ke } from "@babylonjs/core/Animations/easing";
27
28
  import { AssetsManager as ze } from "@babylonjs/core/Misc/assetsManager";
28
- import { ColorCurves as ae } from "@babylonjs/core/Materials/colorCurves";
29
+ import { ColorCurves as oe } from "@babylonjs/core/Materials/colorCurves";
29
30
  import { ImageProcessingConfiguration as P } from "@babylonjs/core/Materials/imageProcessingConfiguration";
30
31
  import { DefaultRenderingPipeline as Ve } from "@babylonjs/core/PostProcesses/RenderPipeline";
31
32
  import { DepthOfFieldEffectBlurLevel as T } from "@babylonjs/core/PostProcesses/depthOfFieldEffect";
@@ -39,8 +40,8 @@ import "@babylonjs/core/Animations/animatable";
39
40
  import "@babylonjs/core/Misc/screenshotTools";
40
41
  import "@babylonjs/core/Rendering/boundingBoxRenderer";
41
42
  import "@babylonjs/loaders/glTF/2.0/Extensions";
42
- var I = /* @__PURE__ */ ((s) => (s[s.Orbit = 0] = "Orbit", s[s.Pan = 1] = "Pan", s))(I || {}), S = /* @__PURE__ */ ((s) => (s.None = "None", s.RemoveWhenSelected = "RemoveWhenSelected", s.ApplyWhenSelected = "ApplyWhenSelected", s))(S || {});
43
- class oe {
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 || {});
44
+ class le {
44
45
  constructor(e) {
45
46
  this.getSceneClearColor = () => {
46
47
  var i, n, a, o;
@@ -282,14 +283,14 @@ class Ne {
282
283
  * @param babylonMaterial An instance of a material representation in babylon.
283
284
  */
284
285
  enableMaterialExtrasIfRequired(e, t) {
285
- if (!(!e.extras || !(t instanceof F))) {
286
+ if (!(!e.extras || !(t instanceof B))) {
286
287
  if (e.extras.sheen) {
287
288
  const i = t;
288
289
  i.sheen.isEnabled = !0, i.sheen.intensity = e.extras.sheen;
289
290
  }
290
291
  if (e.extras.translucency) {
291
292
  const i = t;
292
- i.subSurface.isTranslucencyEnabled = !0, i.subSurface.translucencyIntensity = e.extras.translucency, e.extras.translucencyR && e.extras.translucencyG && e.extras.translucencyB && (i.subSurface.tintColor = new Te(
293
+ i.subSurface.isTranslucencyEnabled = !0, i.subSurface.translucencyIntensity = e.extras.translucency, e.extras.translucencyR && e.extras.translucencyG && e.extras.translucencyB && (i.subSurface.tintColor = new Re(
293
294
  e.extras.translucencyR,
294
295
  e.extras.translucencyG,
295
296
  e.extras.translucencyB
@@ -327,7 +328,7 @@ class Ne {
327
328
  const r = a.material;
328
329
  if (!r)
329
330
  return;
330
- const l = new Re(
331
+ const l = new Ae(
331
332
  "mirror",
332
333
  x.getMirrorTextureResolution(),
333
334
  e,
@@ -340,17 +341,17 @@ class Ne {
340
341
  "Mirror attribute specified on: " + a.name + "But no normals exist to generate a mirror from!"
341
342
  );
342
343
  a.computeWorldMatrix(!0);
343
- const h = a.getWorldMatrix(), u = ne.TransformNormal(
344
- new ne(d[0], d[1], d[2]),
344
+ const h = a.getWorldMatrix(), u = re.TransformNormal(
345
+ new re(d[0], d[1], d[2]),
345
346
  h
346
- ).normalize(), m = Ee.FromPositionAndNormal(
347
+ ).normalize(), m = Te.FromPositionAndNormal(
347
348
  a.position,
348
349
  u.scale(-1)
349
350
  );
350
351
  l.mirrorPlane = m, l.level = o, r.reflectionTexture = l;
351
352
  }
352
353
  function n(a) {
353
- const o = a.material, r = new Oe(
354
+ const o = a.material, r = new Ee(
354
355
  "probe-" + o.name,
355
356
  qe,
356
357
  e
@@ -372,7 +373,7 @@ class Ge {
372
373
  }
373
374
  includeMeshes(e) {
374
375
  if (e) {
375
- this.glowLayer || (this.glowLayer = new Le("glow", this.scene), this.glowLayer.intensity = this.intensity);
376
+ this.glowLayer || (this.glowLayer = new Oe("glow", this.scene), this.glowLayer.intensity = this.intensity);
376
377
  for (const t of e)
377
378
  this.glowLayer.hasMesh(t) || (this.glowLayer.addIncludedOnlyMesh(t), this.meshCount++);
378
379
  }
@@ -385,28 +386,31 @@ class Ge {
385
386
  }
386
387
  }
387
388
  }
388
- const le = /* @__PURE__ */ new Map();
389
- async function ve(s, e, t) {
390
- const i = le.get(s);
389
+ const he = /* @__PURE__ */ new Map();
390
+ async function be(s, e, t) {
391
+ const i = he.get(s);
391
392
  if (i && i.scene.uid === e.uid)
392
393
  return i;
393
394
  {
394
- const n = await be.LoadAssetContainerAsync(
395
+ const n = await S.LoadAssetContainerAsync(
395
396
  s,
396
397
  void 0,
397
398
  e,
398
399
  t
399
400
  );
400
- return le.set(s, n), n;
401
+ return he.set(s, n), n;
401
402
  }
402
403
  }
404
+ S.OnPluginActivatedObservable.add((s) => {
405
+ s.name === "gltf" && (s.animationStartMode = Fe.NONE);
406
+ });
403
407
  function He(s, e, t, i, n = "") {
404
408
  t.forEach((a) => {
405
409
  const o = a.getID(), r = a.getName(), l = x.getDynamicTextureResolution();
406
410
  s.filter((h) => h.name === n + r).forEach((h) => {
407
411
  const u = i.get(o), m = !1;
408
412
  if (u)
409
- he(h, u), u.update(m);
413
+ ce(h, u), u.update(m);
410
414
  else {
411
415
  const p = _e(
412
416
  r,
@@ -416,7 +420,7 @@ function He(s, e, t, i, n = "") {
416
420
  );
417
421
  i.set(o, p), a.setStaticContext(
418
422
  p.getContext()
419
- ), he(h, p), p.onLoadObservable.addOnce(() => {
423
+ ), ce(h, p), p.onLoadObservable.addOnce(() => {
420
424
  p.update(m);
421
425
  });
422
426
  }
@@ -424,7 +428,7 @@ function He(s, e, t, i, n = "") {
424
428
  });
425
429
  }
426
430
  function _e(s, e, t, i) {
427
- const n = new Fe(
431
+ const n = new Se(
428
432
  s,
429
433
  { width: t, height: i },
430
434
  e,
@@ -434,8 +438,8 @@ function _e(s, e, t, i) {
434
438
  ), a = n.getContext();
435
439
  return a && (a.fillStyle = "#f5f5f5", a.fillRect(0, 0, t, i), n.update()), n;
436
440
  }
437
- function he(s, e) {
438
- if (s instanceof F) {
441
+ function ce(s, e) {
442
+ if (s instanceof B) {
439
443
  const t = s, i = t.albedoTexture;
440
444
  i ? (e.wrapU = i.wrapU, e.wrapV = i.wrapV) : (e.wrapU = 1, e.wrapV = 1), t.albedoTexture = e;
441
445
  } else {
@@ -447,8 +451,8 @@ function Ke() {
447
451
  const s = () => Math.floor((1 + Math.random()) * 65536).toString(16).substring(1);
448
452
  return s() + s() + "-" + s() + "-" + s() + "-" + s() + "-" + s() + s() + s();
449
453
  }
450
- const M = 60, ce = 1;
451
- function de(s) {
454
+ const M = 60, de = 1;
455
+ function ue(s) {
452
456
  return s.targetedAnimations.map((t) => t.animation.framePerSecond).reduce((t, i) => t + i, 0) / s.targetedAnimations.length || 0;
453
457
  }
454
458
  function We(s, e, t, i, n, a) {
@@ -469,24 +473,24 @@ function We(s, e, t, i, n, a) {
469
473
  };
470
474
  if (i !== void 0 && t !== void 0 && i === t) {
471
475
  o.forEach((h) => {
472
- const u = de(h), m = i * u;
473
- d(h, !1, ce, m, m);
476
+ const u = ue(h), m = i * u;
477
+ d(h, !1, de, m, m);
474
478
  });
475
479
  return;
476
480
  }
477
481
  o.forEach((h) => {
478
- const u = de(h), m = i !== void 0 ? i * u : void 0, p = t !== void 0 ? t * u : void 0;
479
- d(h, e, ce, m, p);
482
+ const u = ue(h), m = i !== void 0 ? i * u : void 0, p = t !== void 0 ? t * u : void 0;
483
+ d(h, e, de, m, p);
480
484
  });
481
485
  }
482
- function ue(s) {
486
+ function Ue(s) {
483
487
  s.forEach((e) => {
484
- e.stop();
488
+ e.reset(), e.stop();
485
489
  });
486
490
  }
487
- function Ue(s, e, t) {
491
+ function Ye(s, e, t) {
488
492
  return new Promise((i) => {
489
- s.stopAnimation(e), e.animations = [], Math.abs(e.alpha) > 2 * Math.PI && (e.alpha = Ye(e.alpha, 0, 2 * Math.PI));
493
+ s.stopAnimation(e), e.animations = [], Math.abs(e.alpha) > 2 * Math.PI && (e.alpha = Qe(e.alpha, 0, 2 * Math.PI));
490
494
  const n = [], a = t.target, o = 0, r = a ? 1 : 0;
491
495
  if (t.target && Object.keys(t.target).length > 0 && n.push(
492
496
  A(
@@ -564,10 +568,10 @@ function A(s, e, t, i, n, a = 0, o = v.ANIMATIONLOOPMODE_CONSTANT) {
564
568
  value: i
565
569
  }), l.setKeys(d), l.setEasingFunction(r), l;
566
570
  }
567
- function Ye(s, e, t) {
571
+ function Qe(s, e, t) {
568
572
  return s < e ? s = t - (e - s) % (t - e) : s = e + (s - e) % (t - e);
569
573
  }
570
- const Qe = {
574
+ const Ze = {
571
575
  albedoTexture: "albedoMap",
572
576
  bumpTexture: "normalMap",
573
577
  ambientTexture: "ambientMap",
@@ -577,7 +581,7 @@ const Qe = {
577
581
  refractionTexture: "refractionMap",
578
582
  reflectionTexture: "reflectionMap"
579
583
  };
580
- function Ze(s, e, t, i) {
584
+ function $e(s, e, t, i) {
581
585
  [
582
586
  "albedoTexture",
583
587
  "bumpTexture",
@@ -588,17 +592,17 @@ function Ze(s, e, t, i) {
588
592
  "refractionTexture",
589
593
  "reflectionTexture"
590
594
  ].forEach((a) => {
591
- $e(
595
+ je(
592
596
  a,
593
597
  s,
594
598
  e,
595
599
  t,
596
600
  i
597
601
  );
598
- }), Je(s, e);
602
+ }), et(s, e);
599
603
  }
600
- function $e(s, e, t, i, n) {
601
- const a = Qe[s];
604
+ function je(s, e, t, i, n) {
605
+ const a = Ze[s];
602
606
  if (!a)
603
607
  throw new Error("Unexpected texture name encountered.");
604
608
  const o = e[a], r = o == null ? void 0 : o.fileLink;
@@ -616,22 +620,22 @@ function $e(s, e, t, i, n) {
616
620
  !1,
617
621
  !0,
618
622
  !1
619
- ) : i.addTextureTask(s, r, !1, !1) : i.addTextureTask(s, r, !1, !1) : n && t[s] && (t[s] && t[s].dispose(), t[s] = null, je(s, t));
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));
620
624
  }
621
- function je(s, e) {
625
+ function Xe(s, e) {
622
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);
623
627
  }
624
- function Xe(s, e, t, i) {
628
+ function Je(s, e, t, i) {
625
629
  if (!e) {
626
630
  console.error("Failed to apply texture to material: material is null.");
627
631
  return;
628
632
  }
629
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);
630
634
  }
631
- function Je(s, e) {
632
- s.clearCoat && (s.clearCoat === S.RemoveWhenSelected ? (e.clearCoat.isEnabled = !1, e.clearCoat.indexOfRefraction = 1.5) : s.clearCoat === S.ApplyWhenSelected && (e.clearCoat.isEnabled = !0, e.clearCoat.indexOfRefraction = s.clearCoatIOR || e.clearCoat.indexOfRefraction));
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));
633
637
  }
634
- class et {
638
+ class tt {
635
639
  constructor(e, t, i) {
636
640
  this.materialVariantMap = /* @__PURE__ */ new Map(), this.keysThatRemovedBaseModel = [], this.loadedContainerForKey = /* @__PURE__ */ new Map(), this.loadedMaterialsForKey = /* @__PURE__ */ new Map(), this.scene = e, this.renameClonedAsset = t, this.setBaseModelEnabled = i;
637
641
  }
@@ -660,7 +664,7 @@ class et {
660
664
  }
661
665
  const d = new ze(this.scene);
662
666
  d.useDefaultLoadingScreen = !1, l.forEach(
663
- (h) => Ze(
667
+ (h) => $e(
664
668
  t,
665
669
  h,
666
670
  d,
@@ -674,7 +678,7 @@ class et {
674
678
  i && i(100, 100, u.name), this.scene.materials.filter(
675
679
  (f) => f.name === r
676
680
  ).forEach(
677
- (f) => Xe(
681
+ (f) => Je(
678
682
  u.name,
679
683
  f,
680
684
  t,
@@ -698,11 +702,11 @@ class et {
698
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(
699
703
  (h) => h !== e
700
704
  ), Promise.resolve(void 0);
701
- const o = (await ve(i, this.scene, n)).instantiateModelsToScene(
705
+ const o = (await be(i, this.scene, n)).instantiateModelsToScene(
702
706
  this.renameClonedAsset,
703
707
  !0
704
708
  );
705
- this.loadedContainerForKey.has(e) && ((d = this.loadedContainerForKey.get(e)) == null || d.dispose(), this.loadedContainerForKey.delete(e), this.loadedMaterialsForKey.delete(e)), t && await this.setBaseModelEnabled(!1), this.loadedContainerForKey.set(e, o), this.loadedMaterialsForKey.set(e, we(o));
709
+ this.loadedContainerForKey.has(e) && ((d = this.loadedContainerForKey.get(e)) == null || d.dispose(), this.loadedContainerForKey.delete(e), this.loadedMaterialsForKey.delete(e)), t && await this.setBaseModelEnabled(!1), this.loadedContainerForKey.set(e, o), this.loadedMaterialsForKey.set(e, ve(o));
706
710
  const r = [];
707
711
  return this.materialVariantMap.forEach(async (h, u) => {
708
712
  r.push(this.applyMaterial(u, h));
@@ -728,7 +732,7 @@ class et {
728
732
  }), e;
729
733
  }
730
734
  }
731
- function we(s) {
735
+ function ve(s) {
732
736
  const e = [];
733
737
  return s.rootNodes.forEach((t) => {
734
738
  t.getChildMeshes().forEach((i) => {
@@ -747,7 +751,7 @@ function ge(s, e = "") {
747
751
  from: t.from
748
752
  }));
749
753
  }
750
- class tt {
754
+ class it {
751
755
  constructor(e) {
752
756
  this.metadata = /* @__PURE__ */ new Map(), this.materialSelectedObservable = new C(), this.materialDeselectedObservable = new C(), this.materialVariantObservable = new C(), this.modelVariantObservable = new C(), this.materialReadyToLoadCallbacks = /* @__PURE__ */ new Map(), this.modelReadyToLoadCallbacks = /* @__PURE__ */ new Map(), this.dynamicTextures = /* @__PURE__ */ new Map(), this.queuedMaterialChanges = /* @__PURE__ */ new Map(), this.materialChangesInProgress = [], this.queuedModelChanges = /* @__PURE__ */ new Map(), this.modelChangesInProgress = [], this.isExecutingAnimation = !1, this.animations = [], this.initialized = !1, this.materials = [];
753
757
  const {
@@ -757,17 +761,17 @@ class tt {
757
761
  progressHandler: a,
758
762
  scene: o
759
763
  } = e;
760
- this.enablePicking = t, this.contextService = i.contextService, this.id = Ke(), this.previewService = n, this.scene = o, this.variantManager = new et(
764
+ this.enablePicking = t, this.contextService = i.contextService, this.id = Ke(), this.previewService = n, this.scene = o, this.variantManager = new tt(
761
765
  o,
762
766
  this.renameClonedAsset.bind(this),
763
767
  this.setBaseModelEnabled.bind(this)
764
- ), this.transformRoot = new Se("root", this.scene);
768
+ ), this.transformRoot = new Ie("root", this.scene);
765
769
  const r = async () => {
766
770
  if (!i.model)
767
771
  throw new Error(
768
772
  "Model container constructed with no URL. This is currently unsupported."
769
773
  );
770
- return this.assetContainer = await ve(
774
+ return this.assetContainer = await be(
771
775
  i.model,
772
776
  o,
773
777
  a
@@ -892,7 +896,7 @@ class tt {
892
896
  1
893
897
  ), r;
894
898
  })();
895
- 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 && Ue(this.modelInstance.animationGroups), this.contextService || (this.contextService = t == null ? void 0 : t.contextService), o ? this.configureModelInstance(o) : this.configureGlowLayer();
896
900
  }
897
901
  dispose() {
898
902
  var e;
@@ -999,14 +1003,14 @@ class tt {
999
1003
  e.rootNodes.forEach((t) => {
1000
1004
  t.getChildMeshes(!1).forEach((i) => {
1001
1005
  i.name === "targetcube_t" || i.name === "backgroundShell" || (i.actionManager || (i.actionManager = new R(this.scene)), i.actionManager.registerAction(
1002
- new re(R.OnPointerOverTrigger, (n) => {
1006
+ new ae(R.OnPointerOverTrigger, (n) => {
1003
1007
  n.meshUnderPointer && i.material && this.materialSelectedObservable.notifyObservers({
1004
1008
  id: i.material.id,
1005
1009
  name: this.stripIdFromName(i.material.name)
1006
1010
  });
1007
1011
  })
1008
1012
  ), i.actionManager.registerAction(
1009
- new re(R.OnPointerOutTrigger, () => {
1013
+ new ae(R.OnPointerOutTrigger, () => {
1010
1014
  i.material && this.materialDeselectedObservable.notifyObservers({
1011
1015
  id: i.material.id,
1012
1016
  name: this.stripIdFromName(i.material.name)
@@ -1035,7 +1039,7 @@ class tt {
1035
1039
  return this.modelReadyToLoadCallbacks.size;
1036
1040
  }
1037
1041
  configureGlowLayer() {
1038
- const e = (i) => i instanceof F && i.emissiveTexture !== null;
1042
+ const e = (i) => i instanceof B && i.emissiveTexture !== null;
1039
1043
  this.materials.some(e) || this.variantManager.getAllMaterials().some(e) ? this.previewService.getGlowLayerManager().includeMeshes(this.getAllMeshes()) : this.previewService.getGlowLayerManager().removeMeshes(this.getAllMeshes());
1040
1044
  }
1041
1045
  configureModelInstance(e) {
@@ -1066,7 +1070,7 @@ class tt {
1066
1070
  getAllMeshes() {
1067
1071
  var e;
1068
1072
  return (e = this.modelInstance) == null ? void 0 : e.rootNodes.map(
1069
- (t) => t.getChildMeshes(!1).filter((i) => i instanceof Ie)
1073
+ (t) => t.getChildMeshes(!1).filter((i) => i instanceof Le)
1070
1074
  ).flat();
1071
1075
  }
1072
1076
  async instantiate() {
@@ -1077,10 +1081,10 @@ class tt {
1077
1081
  this.modelInstance = this.assetContainer.instantiateModelsToScene(
1078
1082
  this.renameClonedAsset.bind(this),
1079
1083
  !0
1080
- ), this.materials = we(this.modelInstance), this.configureModelInstance(this.modelInstance), this.animations = ge(
1084
+ ), this.materials = ve(this.modelInstance), this.configureModelInstance(this.modelInstance), this.animations = ge(
1081
1085
  this.modelInstance.animationGroups,
1082
1086
  this.renameClonedAsset("")
1083
- ), ue(this.modelInstance.animationGroups), this.initialized = !0, await this.processQueuedEvents();
1087
+ ), this.initialized = !0, await this.processQueuedEvents();
1084
1088
  }
1085
1089
  renameClonedAsset(e) {
1086
1090
  return `${this.id}_${e}`;
@@ -1129,7 +1133,7 @@ class tt {
1129
1133
  }
1130
1134
  //#endregion
1131
1135
  }
1132
- class B extends pe {
1136
+ class D extends pe {
1133
1137
  constructor(e, t, i, n, a, o, r, l) {
1134
1138
  super(
1135
1139
  e,
@@ -1139,7 +1143,7 @@ class B extends pe {
1139
1143
  a,
1140
1144
  o,
1141
1145
  l
1142
- ), this.lastFocus = new g(0, 0, 0), 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(
1143
1147
  r.camera.autoRotation.idleTimeMs
1144
1148
  ));
1145
1149
  }
@@ -1175,12 +1179,13 @@ class B extends pe {
1175
1179
  * @param time The time in milliseconds the animation should take.
1176
1180
  */
1177
1181
  rerunFramingBehavior(e, t) {
1182
+ this.isRunningFramingBehavior = !0;
1178
1183
  const i = this.getFramingBehavior();
1179
1184
  i.framingTime = t || 800;
1180
1185
  const n = () => {
1181
- e && e();
1186
+ this.isRunningFramingBehavior = !1, e && e();
1182
1187
  }, a = E(this._scene), o = a.max.subtract(a.min), r = a.min.add(o.scale(0.5));
1183
- this.updateRadiusBounds(o.length() * 1.5), this.wheelPrecision = 100 / this.radius, this.panningInertia = 0, this.panningOriginTarget.copyFrom(r), this.panDenominator = o.length(), i.zoomOnBoundingInfo(
1188
+ 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(
1184
1189
  a.min,
1185
1190
  a.max,
1186
1191
  void 0,
@@ -1214,7 +1219,7 @@ class B extends pe {
1214
1219
  * @param assignActive If true the camera will be assigned as the active camera on the scene.
1215
1220
  */
1216
1221
  static create(e, t, i) {
1217
- const n = E(e), a = n.max.subtract(n.min), o = n.min.add(a.scale(0.5)), r = new B(
1222
+ const n = E(e), a = n.max.subtract(n.min), o = n.min.add(a.scale(0.5)), r = new D(
1218
1223
  "ProductCamera",
1219
1224
  -(Math.PI / 2),
1220
1225
  Math.PI / 2,
@@ -1237,7 +1242,7 @@ function E(s) {
1237
1242
  const e = s.meshes.filter((t) => t.name.toLowerCase().endsWith("_t") || t.name.toLowerCase().includes("_t_"));
1238
1243
  return s.getWorldExtends((t) => t.isVisible && t.isEnabled() && (e.length === 0 || e.includes(t)));
1239
1244
  }
1240
- class it {
1245
+ class st {
1241
1246
  constructor(e, t = !1, i = void 0) {
1242
1247
  this.renderingPipeline = new Ve(
1243
1248
  "default",
@@ -1255,15 +1260,15 @@ class it {
1255
1260
  return this.currentConfiguration;
1256
1261
  }
1257
1262
  setConfiguration(e) {
1258
- var t, i, n, a, o, r, l, d, h, u, m, p, f, D, k, z, V, q, N, G, H, _, K, W, U, Y, Q, Z, $, j, X, J, ee;
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;
1259
1264
  if (this.renderingPipeline.isSupported) {
1260
- 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 ie(
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(
1261
1266
  e.chromaticAberration.direction.x,
1262
1267
  e.chromaticAberration.direction.y
1263
- ) : new ie(
1268
+ ) : new se(
1264
1269
  c.chromaticAberration.direction.x,
1265
1270
  c.chromaticAberration.direction.y
1266
- ), 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 ae(), this.renderingPipeline.depthOfFieldEnabled = ((f = e.depthOfField) == null ? void 0 : f.enabled) ?? c.depthOfField.enabled, e.depthOfField)
1271
+ ), 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)
1267
1272
  switch (e.depthOfField.blurLevel ?? c.depthOfField.blurLevel) {
1268
1273
  case "Low":
1269
1274
  this.renderingPipeline.depthOfFieldBlurLevel = T.Low;
@@ -1275,7 +1280,7 @@ class it {
1275
1280
  this.renderingPipeline.depthOfFieldBlurLevel = T.High;
1276
1281
  break;
1277
1282
  }
1278
- if (this.renderingPipeline.depthOfField.focalLength = ((D = e.depthOfField) == null ? void 0 : D.focalLength) ?? c.depthOfField.focalLength, this.renderingPipeline.depthOfField.fStop = ((k = e.depthOfField) == null ? void 0 : k.fStop) ?? c.depthOfField.fStop, this.renderingPipeline.depthOfField.focusDistance = ((z = e.depthOfField) == null ? void 0 : z.focusDistance) ?? c.depthOfField.focusDistance, this.renderingPipeline.depthOfField.lensSize = ((V = e.depthOfField) == null ? void 0 : V.lensSize) ?? c.depthOfField.lensSize, this.renderingPipeline.grainEnabled = ((q = e.grain) == null ? void 0 : q.enabled) ?? c.grain.enabled, this.renderingPipeline.grain.animated = ((N = e.grain) == null ? void 0 : N.animated) ?? c.grain.animated, this.renderingPipeline.grain.intensity = ((G = e.grain) == null ? void 0 : G.intensity) ?? c.grain.intensity, this.renderingPipeline.imageProcessing.contrast = ((H = e.misc) == null ? void 0 : H.contrast) ?? c.misc.contrast, this.renderingPipeline.imageProcessing.exposure = ((_ = e.misc) == null ? void 0 : _.exposure) ?? c.misc.exposure, this.renderingPipeline.imageProcessing.toneMappingEnabled = ((K = e.misc) == null ? void 0 : K.toneMappingEnabled) ?? c.misc.toneMappingEnabled, this.renderingPipeline.imageProcessing.toneMappingEnabled)
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)
1279
1284
  switch (e.misc.toneMappingType ?? c.misc.toneMappingType) {
1280
1285
  case "Standard":
1281
1286
  this.renderingPipeline.imageProcessing.toneMappingType = P.TONEMAPPING_STANDARD;
@@ -1284,8 +1289,8 @@ class it {
1284
1289
  this.renderingPipeline.imageProcessing.toneMappingType = P.TONEMAPPING_ACES;
1285
1290
  break;
1286
1291
  }
1287
- if (this.renderingPipeline.sharpenEnabled = ((W = e.sharpen) == null ? void 0 : W.enabled) ?? c.sharpen.enabled, this.renderingPipeline.sharpen.colorAmount = ((U = e.sharpen) == null ? void 0 : U.colorAmount) ?? c.sharpen.colorAmount, this.renderingPipeline.sharpen.edgeAmount = ((Y = e.sharpen) == null ? void 0 : Y.edgeAmount) ?? c.sharpen.edgeAmount, this.renderingPipeline.imageProcessing.vignetteEnabled = ((Q = e.vignette) == null ? void 0 : Q.enabled) ?? c.vignette.enabled, (Z = e.vignette) != null && Z.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)
1288
- switch ((($ = e.vignette) == null ? void 0 : $.blendMode) ?? c.vignette.blendMode) {
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)
1293
+ switch (((j = e.vignette) == null ? void 0 : j.blendMode) ?? c.vignette.blendMode) {
1289
1294
  case "Multiply":
1290
1295
  this.renderingPipeline.imageProcessing.vignetteBlendMode = P.VIGNETTEMODE_MULTIPLY;
1291
1296
  break;
@@ -1293,28 +1298,28 @@ class it {
1293
1298
  this.renderingPipeline.imageProcessing.vignetteBlendMode = P.VIGNETTEMODE_OPAQUE;
1294
1299
  break;
1295
1300
  }
1296
- (j = e.vignette) != null && j.colorRgba ? this.renderingPipeline.imageProcessing.vignetteColor = new b(
1301
+ (X = e.vignette) != null && X.colorRgba ? this.renderingPipeline.imageProcessing.vignetteColor = new b(
1297
1302
  e.vignette.colorRgba.r,
1298
1303
  e.vignette.colorRgba.g,
1299
1304
  e.vignette.colorRgba.b,
1300
1305
  e.vignette.colorRgba.a
1301
- ) : (X = e.vignette) != null && X.colorHex ? this.renderingPipeline.imageProcessing.vignetteColor = b.FromHexString(e.vignette.colorHex) : this.renderingPipeline.imageProcessing.vignetteColor = new b(
1306
+ ) : (J = e.vignette) != null && J.colorHex ? this.renderingPipeline.imageProcessing.vignetteColor = b.FromHexString(e.vignette.colorHex) : this.renderingPipeline.imageProcessing.vignetteColor = new b(
1302
1307
  c.vignette.colorRgba.r,
1303
1308
  c.vignette.colorRgba.g,
1304
1309
  c.vignette.colorRgba.b,
1305
1310
  c.vignette.colorRgba.a
1306
- ), this.renderingPipeline.imageProcessing.vignetteStretch = ((J = e.vignette) == null ? void 0 : J.stretch) ?? c.vignette.stretch, this.renderingPipeline.imageProcessing.vignetteWeight = ((ee = e.vignette) == null ? void 0 : ee.weight) ?? c.vignette.weight, this.renderingPipeline.prepare(), this.currentConfiguration = e;
1311
+ ), this.renderingPipeline.imageProcessing.vignetteStretch = ((ee = e.vignette) == null ? void 0 : ee.stretch) ?? c.vignette.stretch, this.renderingPipeline.imageProcessing.vignetteWeight = ((te = e.vignette) == null ? void 0 : te.weight) ?? c.vignette.weight, this.renderingPipeline.prepare(), this.currentConfiguration = e;
1307
1312
  }
1308
1313
  }
1309
1314
  updateColorCurve(e) {
1310
- const t = new ae();
1315
+ const t = new oe();
1311
1316
  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;
1312
1317
  }
1313
1318
  }
1314
- Ae.GLTFLoader.RegisterExtension("glbPostProcessor", function(s) {
1319
+ Pe.GLTFLoader.RegisterExtension("glbPostProcessor", function(s) {
1315
1320
  return new Ne(s);
1316
1321
  });
1317
- be.OnPluginActivatedObservable.add((s) => {
1322
+ S.OnPluginActivatedObservable.add((s) => {
1318
1323
  if (s.name === "gltf") {
1319
1324
  const e = s;
1320
1325
  e.transparencyAsCoverage = !0;
@@ -1326,19 +1331,22 @@ function O(s) {
1326
1331
  function L(s) {
1327
1332
  return { x: s.x, y: s.y, z: s.z };
1328
1333
  }
1329
- class Kt {
1334
+ class Ut {
1330
1335
  constructor(e) {
1331
1336
  var l;
1332
1337
  this.focusLostNotified = !1, this.focusLostObservable = new C(), this.modelLoadEventCallbacks = [], this.modelContainers = /* @__PURE__ */ new Map(), this.plugins = [], this.initComplete = !1, this.isAnimatingCamera = !1, this.renderLoop = () => {
1333
1338
  this.engine.views && (this.modelContainers.forEach((d) => {
1334
1339
  d.updateDynamicTextures();
1335
- }), this.scene.render(), !this.camera.target.equalsWithEpsilon(this.camera.lastFocus, 0.1) && !this.focusLostNotified && (this.focusLostObservable.notifyObservers(void 0), this.focusLostNotified = !0), this.screenshotPrepareResolve && (this.screenshotPrepareResolve(), this.screenshotPrepareResolve = void 0));
1336
- }, this.configuration = new oe(e);
1340
+ }), this.scene.render(), !this.camera.isRunningFramingBehavior && !this.camera.target.equalsWithEpsilon(
1341
+ this.camera.lastFocus,
1342
+ (this.camera.lowerRadiusLimit ?? 1) * 0.01
1343
+ ) && !this.focusLostNotified && (this.focusLostObservable.notifyObservers(void 0), this.focusLostNotified = !0), this.screenshotPrepareResolve && (this.screenshotPrepareResolve(), this.screenshotPrepareResolve = void 0));
1344
+ }, this.configuration = new le(e);
1337
1345
  const i = (() => {
1338
1346
  if (!(e != null && e.noRender))
1339
1347
  return this.configuration.createCanvas();
1340
1348
  })(), n = "1.5.6";
1341
- Me.Configuration = {
1349
+ ye.Configuration = {
1342
1350
  decoder: {
1343
1351
  wasmUrl: `https://www.gstatic.com/draco/versioned/decoders/${n}/draco_wasm_wrapper_gltf.js`,
1344
1352
  wasmBinaryUrl: `https://www.gstatic.com/draco/versioned/decoders/${n}/draco_decoder_gltf.wasm`,
@@ -1356,13 +1364,13 @@ class Kt {
1356
1364
  audioEngine: !1,
1357
1365
  stencil: this.configuration.highlights.enabled,
1358
1366
  forceSRGBBufferSupportState: !0
1359
- }) : new Ce();
1360
- console.log = a, o.hideLoadingUI(), window.addEventListener("resize", this.fireResizeEvent.bind(this)), this.engine = o, this.scene = new Pe(o), this.scene.autoClear = !0, this.scene.autoClearDepthAndStencil = !0, this.camera = B.create(this.scene, this.configuration), this.scene.activeCamera = this.camera, this.renderingPipeline = new it(
1367
+ }) : new we();
1368
+ 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(
1361
1369
  this.scene,
1362
1370
  !1,
1363
1371
  this.camera
1364
1372
  ), this.scene.clearColor = this.configuration.scene.clearColor;
1365
- const r = te.CreateFromPrefilteredData(
1373
+ const r = ie.CreateFromPrefilteredData(
1366
1374
  this.configuration.scene.environment.file,
1367
1375
  this.scene
1368
1376
  );
@@ -1423,7 +1431,7 @@ class Kt {
1423
1431
  let t = () => {
1424
1432
  };
1425
1433
  const i = async () => {
1426
- this.isAnimatingCamera = !0, await Ue(
1434
+ this.isAnimatingCamera = !0, await Ye(
1427
1435
  this.scene,
1428
1436
  this.scene.activeCamera,
1429
1437
  e
@@ -1501,7 +1509,7 @@ class Kt {
1501
1509
  try {
1502
1510
  const n = t.latDeg * Math.PI / 180, a = t.lonDeg * Math.PI / 180;
1503
1511
  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();
1504
- const o = await xe.CreateScreenshotUsingRenderTargetAsync(
1512
+ const o = await Me.CreateScreenshotUsingRenderTargetAsync(
1505
1513
  this.engine,
1506
1514
  i,
1507
1515
  e,
@@ -1529,7 +1537,7 @@ class Kt {
1529
1537
  }
1530
1538
  setHighlights(e, t) {
1531
1539
  var n;
1532
- e.length === 0 && ((n = this.highlightLayer) == null || n.dispose(), this.highlightLayer = void 0), this.highlightLayer || (this.highlightLayer = new ye("highlights", this.scene, {
1540
+ e.length === 0 && ((n = this.highlightLayer) == null || n.dispose(), this.highlightLayer = void 0), this.highlightLayer || (this.highlightLayer = new Ce("highlights", this.scene, {
1533
1541
  isStroke: !0,
1534
1542
  blurVerticalSize: 0.85,
1535
1543
  blurHorizontalSize: 0.85
@@ -1554,7 +1562,7 @@ class Kt {
1554
1562
  this.renderingPipeline && this.renderingPipeline.setConfiguration(e);
1555
1563
  }
1556
1564
  loadModel(e, t) {
1557
- const i = new tt({
1565
+ const i = new it({
1558
1566
  enablePicking: this.configuration.highlights.enabled,
1559
1567
  modelDetails: e,
1560
1568
  scene: this.scene,
@@ -1609,13 +1617,13 @@ class Kt {
1609
1617
  * Flips a transform around the origin.
1610
1618
  */
1611
1619
  flipTransform(e, t, i) {
1612
- const n = se.Compose(
1620
+ const n = ne.Compose(
1613
1621
  O(i || { x: 1, y: 1, z: 1 }),
1614
1622
  y.FromEulerVector(
1615
1623
  O(t || { x: 0, y: 0, z: 0 })
1616
1624
  ),
1617
1625
  O(e || { x: 0, y: 0, z: 0 })
1618
- ), a = se.RotationAxis(g.Up(), Math.PI), o = n.multiply(a), r = g.Zero(), l = y.Identity(), d = g.Zero();
1626
+ ), a = ne.RotationAxis(g.Up(), Math.PI), o = n.multiply(a), r = g.Zero(), l = y.Identity(), d = g.Zero();
1619
1627
  return o.decompose(d, l, r), l.multiplyInPlace(y.FromEulerAngles(0, Math.PI, 0)), {
1620
1628
  position: L(r),
1621
1629
  rotation: L(l.toEulerAngles()),
@@ -1624,10 +1632,10 @@ class Kt {
1624
1632
  }
1625
1633
  updatePreviewOptions(e) {
1626
1634
  var n;
1627
- const t = new oe(e);
1635
+ const t = new le(e);
1628
1636
  this.configuration.highlights.enabled !== t.highlights.enabled && this.engine.setStencilBuffer(t.highlights.enabled), this.scene.clearColor = t.scene.clearColor;
1629
1637
  let i = this.scene.environmentTexture;
1630
- this.configuration.scene.environment.file !== t.scene.environment.file && (i = te.CreateFromPrefilteredData(
1638
+ this.configuration.scene.environment.file !== t.scene.environment.file && (i = ie.CreateFromPrefilteredData(
1631
1639
  t.scene.environment.file,
1632
1640
  this.scene
1633
1641
  ), 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,10 +1657,10 @@ class Kt {
1649
1657
  }
1650
1658
  }
1651
1659
  export {
1652
- S as MaterialEffectMode,
1660
+ F as MaterialEffectMode,
1653
1661
  I as ProductCameraRig,
1654
1662
  qe as REFLECTION_PROBE_RESOLUTION,
1655
1663
  x as RenderingConfiguration,
1656
- Kt as SpiffCommerce3DPreviewService,
1664
+ Ut as SpiffCommerce3DPreviewService,
1657
1665
  c as renderingPipelineDefaults
1658
1666
  };
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/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/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.dynamicTexture,c.texture,c.animation,c.easing,c.assetsManager,c.colorCurves,c.imageProcessingConfiguration,c.RenderPipeline,c.depthOfFieldEffect))})(this,function(c,v,q,ve,we,D,V,b,m,Ce,M,Me,xe,Pe,L,Ae,P,Te,Re,O,k,Ee,Le,Oe,Ie,w,z,Se,N,A,Fe,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 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 L.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 Ae.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 Te.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 Re.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 D.SceneLoader.LoadAssetContainerAsync(s,void 0,e,t);return K.set(s,n),n}}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,q.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 L.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 Z(s){s.forEach(e=>{e.stop()})}function ze(s,e,t){return new Promise(i=>{s.stopAnimation(e),e.animations=[],Math.abs(e.alpha)>2*Math.PI&&(e.alpha=Ne(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,$(t.lonDeg),w.Animation.ANIMATIONTYPE_FLOAT,r)),n.push(E("cameraBetaLerp","beta",e.beta,$(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 $(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 Ne(s,e,t){return s<e?s=t-(e-s)%(t-e):s=e+(s-e)%(t-e)}const Ge={albedoTexture:"albedoMap",bumpTexture:"normalMap",ambientTexture:"ambientMap",emissiveTexture:"emissionMap",opacityTexture:"alphaMap",metallicTexture:"metallicMap",refractionTexture:"refractionMap",reflectionTexture:"reflectionMap"};function He(s,e,t,i){["albedoTexture","bumpTexture","ambientTexture","emissiveTexture","opacityTexture","metallicTexture","refractionTexture","reflectionTexture"].forEach(a=>{Ke(a,s,e,t,i)}),Qe(s,e)}function Ke(s,e,t,i,n){const a=Ge[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,Ue(s,t))}function Ue(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 We(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 Qe(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 Ye{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 Se.AssetsManager(this.scene);u.useDefaultLoadingScreen=!1,l.forEach(h=>He(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=>We(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,X(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 X(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 J(s,e=""){return s.map(t=>({name:t.name.substring(e.length),loop:t.loopAnimation,to:t.to,from:t.from}))}class Ze{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 Ye(o,this.renameClonedAsset.bind(this),this.setBaseModelEnabled.bind(this)),this.transformRoot=new Le.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&&Z(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?J(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 O.ActionManager(this.scene)),i.actionManager.registerAction(new k.ExecuteCodeAction(O.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(O.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 L.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 Ee.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=X(this.modelInstance),this.configureModelInstance(this.modelInstance),this.animations=J(this.modelInstance.animationGroups,this.renameClonedAsset("")),Z(this.modelInstance.animationGroups),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.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=F(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){const i=this.getFramingBehavior();i.framingTime=t||800;const n=()=>{e&&e()},a=F(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(),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=F(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 F(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 $e{constructor(e,t=!1,i=void 0){this.renderingPipeline=new Fe.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,_,ee,te,ie,se,ne,re,ae,oe,le,he,ce,de,ue,ge,me,pe,fe,be,ye;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=((ee=e.depthOfField)==null?void 0:ee.fStop)??d.depthOfField.fStop,this.renderingPipeline.depthOfField.focusDistance=((te=e.depthOfField)==null?void 0:te.focusDistance)??d.depthOfField.focusDistance,this.renderingPipeline.depthOfField.lensSize=((ie=e.depthOfField)==null?void 0:ie.lensSize)??d.depthOfField.lensSize,this.renderingPipeline.grainEnabled=((se=e.grain)==null?void 0:se.enabled)??d.grain.enabled,this.renderingPipeline.grain.animated=((ne=e.grain)==null?void 0:ne.animated)??d.grain.animated,this.renderingPipeline.grain.intensity=((re=e.grain)==null?void 0:re.intensity)??d.grain.intensity,this.renderingPipeline.imageProcessing.contrast=((ae=e.misc)==null?void 0:ae.contrast)??d.misc.contrast,this.renderingPipeline.imageProcessing.exposure=((oe=e.misc)==null?void 0:oe.exposure)??d.misc.exposure,this.renderingPipeline.imageProcessing.toneMappingEnabled=((le=e.misc)==null?void 0:le.toneMappingEnabled)??d.misc.toneMappingEnabled,this.renderingPipeline.imageProcessing.toneMappingEnabled)switch(e.misc.toneMappingType??d.misc.toneMappingType){case"Standard":this.renderingPipeline.imageProcessing.toneMappingType=A.ImageProcessingConfiguration.TONEMAPPING_STANDARD;break;case"ACES":this.renderingPipeline.imageProcessing.toneMappingType=A.ImageProcessingConfiguration.TONEMAPPING_ACES;break}if(this.renderingPipeline.sharpenEnabled=((he=e.sharpen)==null?void 0:he.enabled)??d.sharpen.enabled,this.renderingPipeline.sharpen.colorAmount=((ce=e.sharpen)==null?void 0:ce.colorAmount)??d.sharpen.colorAmount,this.renderingPipeline.sharpen.edgeAmount=((de=e.sharpen)==null?void 0:de.edgeAmount)??d.sharpen.edgeAmount,this.renderingPipeline.imageProcessing.vignetteEnabled=((ue=e.vignette)==null?void 0:ue.enabled)??d.vignette.enabled,(ge=e.vignette)!=null&&ge.center?(this.renderingPipeline.imageProcessing.vignetteCenterX=e.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=e.vignette.center.y):(this.renderingPipeline.imageProcessing.vignetteCenterX=d.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=d.vignette.center.y),e.vignette)switch(((me=e.vignette)==null?void 0:me.blendMode)??d.vignette.blendMode){case"Multiply":this.renderingPipeline.imageProcessing.vignetteBlendMode=A.ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY;break;case"Opaque":this.renderingPipeline.imageProcessing.vignetteBlendMode=A.ImageProcessingConfiguration.VIGNETTEMODE_OPAQUE;break}(pe=e.vignette)!=null&&pe.colorRgba?this.renderingPipeline.imageProcessing.vignetteColor=new b.Color4(e.vignette.colorRgba.r,e.vignette.colorRgba.g,e.vignette.colorRgba.b,e.vignette.colorRgba.a):(fe=e.vignette)!=null&&fe.colorHex?this.renderingPipeline.imageProcessing.vignetteColor=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=((be=e.vignette)==null?void 0:be.stretch)??d.vignette.stretch,this.renderingPipeline.imageProcessing.vignetteWeight=((ye=e.vignette)==null?void 0:ye.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}}Pe.GLTF2.GLTFLoader.RegisterExtension("glbPostProcessor",function(s){return new Be(s)}),D.SceneLoader.OnPluginActivatedObservable.add(s=>{if(s.name==="gltf"){const e=s;e.transparencyAsCoverage=!0}});function B(s){return new m.Vector3(s.x,s.y,s.z)}function j(s){return{x:s.x,y:s.y,z:s.z}}class Xe{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=()=>{this.engine.views&&(this.modelContainers.forEach(u=>{u.updateDynamicTextures()}),this.scene.render(),!this.camera.target.equalsWithEpsilon(this.camera.lastFocus,.1)&&!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 q.Engine(i,!0,{adaptToDeviceRatio:!0,limitDeviceRatio:2,premultipliedAlpha:!1,preserveDrawingBuffer:!!(e!=null&&e.backgroundImage),audioEngine:!1,stencil:this.configuration.highlights.enabled,forceSRGBBufferSupportState:!0}):new ve.NullEngine;console.log=a,o.hideLoadingUI(),window.addEventListener("resize",this.fireResizeEvent.bind(this)),this.engine=o,this.scene=new xe.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 $e(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 ze(this.scene,this.scene.activeCamera,e),this.isAnimatingCamera=!1,this.queuedAnimationFunction&&this.queuedAnimationFunction(),this.queuedAnimationFunction=void 0,t()};return this.isAnimatingCamera?(this.queuedAnimationFunction=i,new Promise(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 Me.Tools.CreateScreenshotUsingRenderTargetAsync(this.engine,i,e,"image/png",2,!0);return i.dispose(),o}catch{throw i.isDisposed()||i.dispose(),new Error("Failed to render screenshot")}}orbitEnabled(){const e=this.configuration;if(!e)return!0;const t=e.camera.limits.min.alpha,i=e.camera.limits.max.alpha,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 we.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 Ze({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(B(i||{x:1,y:1,z:1}),m.Quaternion.FromEulerVector(B(t||{x:0,y:0,z:0})),B(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:j(r),rotation:j(l.toEulerAngles()),scale:j(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=Xe,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,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=()=>{this.engine.views&&(this.modelContainers.forEach(u=>{u.updateDynamicTextures()}),this.scene.render(),!this.camera.isRunningFramingBehavior&&!this.camera.target.equalsWithEpsilon(this.camera.lastFocus,(this.camera.lowerRadiusLimit??1)*.01)&&!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"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spiffcommerce/preview",
3
- "version": "5.3.8-rc.7",
3
+ "version": "5.3.9-rc.0",
4
4
  "description": "An internal implementation of the ThreeDPreviewService interface used by Spiff Commerce",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/index.umd.js",