@spiffcommerce/preview 5.0.2 → 5.1.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
@@ -397,6 +397,14 @@ type PreviewOptions = {
397
397
  * The environment file used to calculate product lighting.
398
398
  */
399
399
  readonly environmentFile?: string;
400
+ /**
401
+ * The intensity of the environment lighting.
402
+ */
403
+ readonly environmentIntensity?: number;
404
+ /**
405
+ * The rotation (around the y axis) of the environment lighting, in degrees.
406
+ */
407
+ readonly environmentRotationY?: number;
400
408
  /**
401
409
  * The lowest point, vertically, that the camera can rotate to.
402
410
  * https://doc.babylonjs.com/divingDeeper/cameras/camera_introduction
@@ -890,7 +898,11 @@ declare class Configuration {
890
898
  get scene(): {
891
899
  clearColor: Color4;
892
900
  transparentBackground: string | true | undefined;
893
- environmentFile: string;
901
+ environment: {
902
+ file: string;
903
+ intensity: number;
904
+ rotationY: number;
905
+ };
894
906
  };
895
907
  /**
896
908
  * Configuration related to the camera used to view and interact with the scene.
package/dist/index.esm.js CHANGED
@@ -17,7 +17,7 @@ import { Color3 as Ee, Vector3 as se, Plane as Ae } from "@babylonjs/core/Maths/
17
17
  import { ReflectionProbe as Te } from "@babylonjs/core/Probes/reflectionProbe";
18
18
  import { GlowLayer as Oe } from "@babylonjs/core/Layers/glowLayer";
19
19
  import { ActionManager as E } from "@babylonjs/core/Actions/actionManager";
20
- import { ExecuteCodeAction as re } from "@babylonjs/core/Actions/directActions";
20
+ import { ExecuteCodeAction as ne } from "@babylonjs/core/Actions/directActions";
21
21
  import { Mesh as Le } from "@babylonjs/core/Meshes/mesh";
22
22
  import { TransformNode as Ie } from "@babylonjs/core/Meshes/transformNode";
23
23
  import { DynamicTexture as Se } from "@babylonjs/core/Materials/Textures/dynamicTexture";
@@ -25,7 +25,7 @@ import { Texture as Fe } from "@babylonjs/core/Materials/Textures/texture";
25
25
  import { Animation as w } from "@babylonjs/core/Animations/animation";
26
26
  import { QuadraticEase as Be, EasingFunction as De } from "@babylonjs/core/Animations/easing";
27
27
  import { AssetsManager as ke } from "@babylonjs/core/Misc/assetsManager";
28
- import { ColorCurves as ne } from "@babylonjs/core/Materials/colorCurves";
28
+ import { ColorCurves as re } from "@babylonjs/core/Materials/colorCurves";
29
29
  import { ImageProcessingConfiguration as P } from "@babylonjs/core/Materials/imageProcessingConfiguration";
30
30
  import { DefaultRenderingPipeline as ze } from "@babylonjs/core/PostProcesses/RenderPipeline";
31
31
  import { DepthOfFieldEffectBlurLevel as A } from "@babylonjs/core/PostProcesses/depthOfFieldEffect";
@@ -43,18 +43,18 @@ var I = /* @__PURE__ */ ((s) => (s[s.Orbit = 0] = "Orbit", s[s.Pan = 1] = "Pan",
43
43
  class Ne {
44
44
  constructor(e) {
45
45
  this.getSceneClearColor = () => {
46
- var i, o, a, r;
46
+ var i, o, a, n;
47
47
  const t = (i = this.customOptions) != null && i.transparentBackground || (o = this.customOptions) != null && o.backgroundImage ? 0 : 1;
48
- if (this.customOptions && ((a = this.customOptions) != null && a.transparentBackground) || (r = this.customOptions) != null && r.backgroundImage)
48
+ if (this.customOptions && ((a = this.customOptions) != null && a.transparentBackground) || (n = this.customOptions) != null && n.backgroundImage)
49
49
  return new f(0, 0, 0, t).toLinearSpace();
50
50
  if (this.customOptions && this.customOptions.backgroundColor) {
51
- const n = v.FromHexString(
51
+ const r = v.FromHexString(
52
52
  this.customOptions.backgroundColor
53
53
  );
54
54
  return new f(
55
- n.r,
56
- n.g,
57
- n.b,
55
+ r.r,
56
+ r.g,
57
+ r.b,
58
58
  t
59
59
  ).toLinearSpace();
60
60
  }
@@ -80,18 +80,23 @@ class Ne {
80
80
  * Configuration related to the scene
81
81
  */
82
82
  get scene() {
83
- var e, t, i;
83
+ var e, t, i, o, a;
84
84
  return {
85
85
  clearColor: this.getSceneClearColor(),
86
86
  transparentBackground: ((e = this.customOptions) == null ? void 0 : e.transparentBackground) || ((t = this.customOptions) == null ? void 0 : t.backgroundImage),
87
- environmentFile: ((i = this.customOptions) == null ? void 0 : i.environmentFile) ?? "assets/model-viewer/default.env"
87
+ environment: {
88
+ file: ((i = this.customOptions) == null ? void 0 : i.environmentFile) ?? "assets/model-viewer/default.env",
89
+ intensity: ((o = this.customOptions) == null ? void 0 : o.environmentIntensity) ?? 1,
90
+ rotationY: (((a = this.customOptions) == null ? void 0 : a.environmentRotationY) ?? 0) * (Math.PI / 180)
91
+ // Convert to radians
92
+ }
88
93
  };
89
94
  }
90
95
  /**
91
96
  * Configuration related to the camera used to view and interact with the scene.
92
97
  */
93
98
  get camera() {
94
- var e, t, i, o, a, r, n, l, c, d, u, g, p;
99
+ var e, t, i, o, a, n, r, l, h, d, u, g, p;
95
100
  return {
96
101
  autoOrientation: ((e = this.customOptions) == null ? void 0 : e.disableAutomaticOrientation) ?? !0,
97
102
  autoRotation: {
@@ -101,11 +106,11 @@ class Ne {
101
106
  limits: {
102
107
  min: {
103
108
  alpha: (o = this.customOptions) != null && o.lowerAlphaLimitDeg ? ((a = this.customOptions) == null ? void 0 : a.lowerAlphaLimitDeg) * Math.PI / 180 : void 0,
104
- beta: (r = this.customOptions) != null && r.lowerBetaLimitDeg ? ((n = this.customOptions) == null ? void 0 : n.lowerBetaLimitDeg) * Math.PI / 180 : void 0,
109
+ beta: (n = this.customOptions) != null && n.lowerBetaLimitDeg ? ((r = this.customOptions) == null ? void 0 : r.lowerBetaLimitDeg) * Math.PI / 180 : void 0,
105
110
  radius: (l = this.customOptions) == null ? void 0 : l.minZoomOverride
106
111
  },
107
112
  max: {
108
- alpha: (c = this.customOptions) != null && c.upperAlphaLimitDeg ? ((d = this.customOptions) == null ? void 0 : d.upperAlphaLimitDeg) * Math.PI / 180 : void 0,
113
+ alpha: (h = this.customOptions) != null && h.upperAlphaLimitDeg ? ((d = this.customOptions) == null ? void 0 : d.upperAlphaLimitDeg) * Math.PI / 180 : void 0,
109
114
  beta: (u = this.customOptions) != null && u.upperBetaLimitDeg ? ((g = this.customOptions) == null ? void 0 : g.upperBetaLimitDeg) * Math.PI / 180 : void 0,
110
115
  radius: (p = this.customOptions) == null ? void 0 : p.maxZoomOverride
111
116
  }
@@ -176,7 +181,7 @@ class x {
176
181
  }
177
182
  }
178
183
  }
179
- const Ve = 128, h = {
184
+ const Ve = 128, c = {
180
185
  antiAliasing: {
181
186
  samples: 4,
182
187
  fxaaEnabled: !1
@@ -250,8 +255,8 @@ class Ge {
250
255
  t,
251
256
  function(o) {
252
257
  t.extras && Object.keys(t.extras).forEach((a) => {
253
- const r = t.extras[a];
254
- o.metadata[a] = r;
258
+ const n = t.extras[a];
259
+ o.metadata[a] = n;
255
260
  }), i(o);
256
261
  }
257
262
  );
@@ -311,16 +316,16 @@ class Ge {
311
316
  */
312
317
  applyReflections(e) {
313
318
  function t(a) {
314
- const r = [];
315
- return a.transformNodes.forEach((n) => {
316
- n.metadata && n.metadata.reflective && r.push(...n.getChildMeshes());
317
- }), a.meshes.forEach((n) => {
318
- n.metadata && n.metadata.reflective && !r.includes(n) && r.push(n);
319
- }), r;
319
+ const n = [];
320
+ return a.transformNodes.forEach((r) => {
321
+ r.metadata && r.metadata.reflective && n.push(...r.getChildMeshes());
322
+ }), a.meshes.forEach((r) => {
323
+ r.metadata && r.metadata.reflective && !n.includes(r) && n.push(r);
324
+ }), n;
320
325
  }
321
- function i(a, r = 1) {
322
- const n = a.material;
323
- if (!n)
326
+ function i(a, n = 1) {
327
+ const r = a.material;
328
+ if (!r)
324
329
  return;
325
330
  const l = new Re(
326
331
  "mirror",
@@ -329,32 +334,32 @@ class Ge {
329
334
  !0
330
335
  );
331
336
  l.renderList = t(e);
332
- const c = a.getVerticesData("normal");
333
- if (!c)
337
+ const h = a.getVerticesData("normal");
338
+ if (!h)
334
339
  throw new Error(
335
340
  "Mirror attribute specified on: " + a.name + "But no normals exist to generate a mirror from!"
336
341
  );
337
342
  a.computeWorldMatrix(!0);
338
343
  const d = a.getWorldMatrix(), u = se.TransformNormal(
339
- new se(c[0], c[1], c[2]),
344
+ new se(h[0], h[1], h[2]),
340
345
  d
341
346
  ).normalize(), g = Ae.FromPositionAndNormal(
342
347
  a.position,
343
348
  u.scale(-1)
344
349
  );
345
- l.mirrorPlane = g, l.level = r, n.reflectionTexture = l;
350
+ l.mirrorPlane = g, l.level = n, r.reflectionTexture = l;
346
351
  }
347
352
  function o(a) {
348
- const r = a.material, n = new Te(
349
- "probe-" + r.name,
353
+ const n = a.material, r = new Te(
354
+ "probe-" + n.name,
350
355
  Ve,
351
356
  e
352
357
  );
353
- n.attachToMesh(a), n.renderList && n.renderList.push(...t(e)), r.reflectionTexture = n.cubeTexture;
358
+ r.attachToMesh(a), r.renderList && r.renderList.push(...t(e)), n.reflectionTexture = r.cubeTexture;
354
359
  }
355
360
  e.meshes.forEach((a) => {
356
- const r = a.metadata;
357
- r && (r.mirrorTexture && i(a, r.mirrorTexture), r.reflectionProbe && o(a));
361
+ const n = a.metadata;
362
+ n && (n.mirrorTexture && i(a, n.mirrorTexture), n.reflectionProbe && o(a));
358
363
  });
359
364
  }
360
365
  }
@@ -394,19 +399,19 @@ async function pe(s, e, t) {
394
399
  }
395
400
  function He(s, e, t, i, o = "") {
396
401
  t.forEach((a) => {
397
- const r = a.getID(), n = a.getName(), l = x.getDynamicTextureResolution();
398
- s.filter((d) => d.name === o + n).forEach((d) => {
399
- const u = i.get(r), g = !1;
402
+ const n = a.getID(), r = a.getName(), l = x.getDynamicTextureResolution();
403
+ s.filter((d) => d.name === o + r).forEach((d) => {
404
+ const u = i.get(n), g = !1;
400
405
  if (u)
401
406
  oe(d, u), u.update(g);
402
407
  else {
403
408
  const p = _e(
404
- n,
409
+ r,
405
410
  e,
406
411
  l.width,
407
412
  l.height
408
413
  );
409
- i.set(r, p), a.setStaticContext(
414
+ i.set(n, p), a.setStaticContext(
410
415
  p.getContext()
411
416
  ), oe(d, p), p.onLoadObservable.addOnce(() => {
412
417
  p.update(g);
@@ -444,23 +449,23 @@ function he(s) {
444
449
  return s.targetedAnimations.map((t) => t.animation.framePerSecond).reduce((t, i) => t + i, 0) / s.targetedAnimations.length || 0;
445
450
  }
446
451
  function Ue(s, e, t, i, o) {
447
- const a = o ? s.filter((r) => r.name === o) : s;
452
+ const a = o ? s.filter((n) => n.name === o) : s;
448
453
  if (a.length === 0) {
449
454
  console.warn(`No animations found for name: ${o}`);
450
455
  return;
451
456
  }
452
457
  if (i !== void 0 && t !== void 0 && i === t) {
453
- a.forEach((r) => {
454
- r.stop();
455
- const n = he(r), l = i * n;
456
- r.start(e, le, l, l);
458
+ a.forEach((n) => {
459
+ n.stop();
460
+ const r = he(n), l = i * r;
461
+ n.start(e, le, l, l);
457
462
  });
458
463
  return;
459
464
  }
460
- a.forEach((r) => {
461
- r.stop();
462
- const n = he(r), l = i !== void 0 ? i * n : void 0, c = t !== void 0 ? t * n : void 0;
463
- r.start(e, le, l, c);
465
+ a.forEach((n) => {
466
+ n.stop();
467
+ const r = he(n), l = i !== void 0 ? i * r : void 0, h = t !== void 0 ? t * r : void 0;
468
+ n.start(e, le, l, h);
464
469
  });
465
470
  }
466
471
  function fe(s) {
@@ -473,8 +478,8 @@ function We(s) {
473
478
  fe(e);
474
479
  }
475
480
  function Qe(s, e, t) {
476
- s.stopAnimation(e), e.animations = [], Math.abs(e.alpha) > 2 * Math.PI && (e.alpha = Ze(e.alpha, 0, 2 * Math.PI));
477
- const i = [], o = t.target, a = 0, r = o ? 1 : 0;
481
+ s.stopAnimation(e), e.animations = [], Math.abs(e.alpha) > 2 * Math.PI && (e.alpha = Ye(e.alpha, 0, 2 * Math.PI));
482
+ const i = [], o = t.target, a = 0, n = o ? 1 : 0;
478
483
  if (t.target && Object.keys(t.target).length > 0 && i.push(
479
484
  R(
480
485
  "cameraTargetLerp",
@@ -495,7 +500,7 @@ function Qe(s, e, t) {
495
500
  e.alpha,
496
501
  ce(t.lonDeg),
497
502
  w.ANIMATIONTYPE_FLOAT,
498
- r
503
+ n
499
504
  )
500
505
  ), i.push(
501
506
  R(
@@ -504,18 +509,18 @@ function Qe(s, e, t) {
504
509
  e.beta,
505
510
  ce(t.latDeg),
506
511
  w.ANIMATIONTYPE_FLOAT,
507
- r
512
+ n
508
513
  )
509
514
  ), t.radius !== void 0) {
510
- const c = Math.max(0.01, t.radius);
515
+ const h = Math.max(0.01, t.radius);
511
516
  i.push(
512
517
  R(
513
518
  "cameraRadiusLerp",
514
519
  "radius",
515
520
  e.radius,
516
- c,
521
+ h,
517
522
  w.ANIMATIONTYPE_FLOAT,
518
- r
523
+ n
519
524
  )
520
525
  );
521
526
  }
@@ -535,25 +540,25 @@ function Qe(s, e, t) {
535
540
  function ce(s) {
536
541
  return s * Math.PI / 180;
537
542
  }
538
- function R(s, e, t, i, o, a = 0, r = w.ANIMATIONLOOPMODE_CONSTANT) {
539
- const n = new Be();
540
- n.setEasingMode(De.EASINGMODE_EASEINOUT);
543
+ function R(s, e, t, i, o, a = 0, n = w.ANIMATIONLOOPMODE_CONSTANT) {
544
+ const r = new Be();
545
+ r.setEasingMode(De.EASINGMODE_EASEINOUT);
541
546
  const l = new w(
542
547
  s,
543
548
  e,
544
549
  y,
545
550
  o,
546
- r
547
- ), c = [];
548
- return a > 0 && c.push({ frame: 0, value: t }), c.push({ frame: y * a, value: t }), c.push({
551
+ n
552
+ ), h = [];
553
+ return a > 0 && h.push({ frame: 0, value: t }), h.push({ frame: y * a, value: t }), h.push({
549
554
  frame: y * (a + 1),
550
555
  value: i
551
- }), l.setKeys(c), l.setEasingFunction(n), l;
556
+ }), l.setKeys(h), l.setEasingFunction(r), l;
552
557
  }
553
- function Ze(s, e, t) {
558
+ function Ye(s, e, t) {
554
559
  return s < e ? s = t - (e - s) % (t - e) : s = e + (s - e) % (t - e);
555
560
  }
556
- const $e = {
561
+ const Ze = {
557
562
  albedoTexture: "albedoMap",
558
563
  bumpTexture: "normalMap",
559
564
  ambientTexture: "ambientMap",
@@ -562,7 +567,7 @@ const $e = {
562
567
  metallicTexture: "metallicMap",
563
568
  refractionTexture: "refractionMap"
564
569
  };
565
- function Ye(s, e, t, i) {
570
+ function $e(s, e, t, i) {
566
571
  [
567
572
  "albedoTexture",
568
573
  "bumpTexture",
@@ -582,11 +587,11 @@ function Ye(s, e, t, i) {
582
587
  }), et(s, e);
583
588
  }
584
589
  function je(s, e, t, i, o) {
585
- const a = $e[s];
590
+ const a = Ze[s];
586
591
  if (!a)
587
592
  throw new Error("Unexpected texture name encountered.");
588
- const r = e[a], n = r == null ? void 0 : r.fileLink;
589
- n ? i.addTextureTask(s, n, !1, !1) : o && t[s] && (t[s] && t[s].dispose(), t[s] = null, Xe(s, t));
593
+ const n = e[a], r = n == null ? void 0 : n.fileLink;
594
+ r ? i.addTextureTask(s, r, !1, !1) : o && t[s] && (t[s] && t[s].dispose(), t[s] = null, Xe(s, t));
590
595
  }
591
596
  function Xe(s, e) {
592
597
  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 === "emissiveTexture" && (e.emissiveIntensity = 0, e.emissiveColor = new v(0, 0, 0));
@@ -616,33 +621,33 @@ class tt {
616
621
  */
617
622
  async applyMaterial(e, t, i, o) {
618
623
  return new Promise((a) => {
619
- const r = this.materialVariantMap.get(e);
624
+ const n = this.materialVariantMap.get(e);
620
625
  this.materialVariantMap.set(e, {
621
- ...r,
626
+ ...n,
622
627
  ...t
623
628
  });
624
- const n = this.renameClonedAsset(e), l = this.scene.materials.filter(
625
- (d) => d.name === n
629
+ const r = this.renameClonedAsset(e), l = this.scene.materials.filter(
630
+ (d) => d.name === r
626
631
  );
627
632
  if (l.length === 0) {
628
633
  a();
629
634
  return;
630
635
  }
631
- const c = new ke(this.scene);
632
- c.useDefaultLoadingScreen = !1, l.forEach(
633
- (d) => Ye(
636
+ const h = new ke(this.scene);
637
+ h.useDefaultLoadingScreen = !1, l.forEach(
638
+ (d) => $e(
634
639
  t,
635
640
  d,
636
- c,
641
+ h,
637
642
  o
638
643
  )
639
- ), c.onProgress = (d, u, g) => {
644
+ ), h.onProgress = (d, u, g) => {
640
645
  i && i(d / u * 100, 100, g.name);
641
- }, c.onFinish = (d) => {
646
+ }, h.onFinish = (d) => {
642
647
  d.forEach((u) => {
643
648
  const g = u;
644
649
  i && i(100, 100, u.name), this.scene.materials.filter(
645
- (b) => b.name === n
650
+ (b) => b.name === r
646
651
  ).forEach(
647
652
  (b) => Je(
648
653
  u.name,
@@ -652,7 +657,7 @@ class tt {
652
657
  )
653
658
  );
654
659
  }), a();
655
- }, c.loadAsync();
660
+ }, h.loadAsync();
656
661
  });
657
662
  }
658
663
  /**
@@ -663,20 +668,20 @@ class tt {
663
668
  * @param onProgress A load progress callback that can be used for loading bars and event timing.
664
669
  */
665
670
  async applyModel(e, t, i, o) {
666
- var l, c;
671
+ var l, h;
667
672
  if (i && t && !this.keysThatRemovedBaseModel.includes(e) && this.keysThatRemovedBaseModel.push(e), !i)
668
673
  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(
669
674
  (d) => d !== e
670
675
  ), Promise.resolve(void 0);
671
- const r = (await pe(i, this.scene, o)).instantiateModelsToScene(
676
+ const n = (await pe(i, this.scene, o)).instantiateModelsToScene(
672
677
  this.renameClonedAsset,
673
678
  !0
674
679
  );
675
- this.loadedContainerForKey.has(e) && ((c = this.loadedContainerForKey.get(e)) == null || c.dispose(), this.loadedContainerForKey.delete(e), this.loadedMaterialsForKey.delete(e)), t && await this.setBaseModelEnabled(!1), this.loadedContainerForKey.set(e, r), this.loadedMaterialsForKey.set(e, be(r));
676
- const n = [];
680
+ this.loadedContainerForKey.has(e) && ((h = this.loadedContainerForKey.get(e)) == null || h.dispose(), this.loadedContainerForKey.delete(e), this.loadedMaterialsForKey.delete(e)), t && await this.setBaseModelEnabled(!1), this.loadedContainerForKey.set(e, n), this.loadedMaterialsForKey.set(e, be(n));
681
+ const r = [];
677
682
  return this.materialVariantMap.forEach(async (d, u) => {
678
- n.push(this.applyMaterial(u, d));
679
- }), await Promise.all(n), r;
683
+ r.push(this.applyMaterial(u, d));
684
+ }), await Promise.all(r), n;
680
685
  }
681
686
  dispose() {
682
687
  this.loadedContainerForKey.forEach((e) => e == null ? void 0 : e.dispose()), this.loadedContainerForKey.clear(), this.loadedMaterialsForKey.forEach(
@@ -725,32 +730,32 @@ class it {
725
730
  modelDetails: i,
726
731
  previewService: o,
727
732
  progressHandler: a,
728
- scene: r
733
+ scene: n
729
734
  } = e;
730
- this.enablePicking = t, this.contextService = i.contextService, this.id = Ke(), this.previewService = o, this.scene = r, this.variantManager = new tt(
731
- r,
735
+ this.enablePicking = t, this.contextService = i.contextService, this.id = Ke(), this.previewService = o, this.scene = n, this.variantManager = new tt(
736
+ n,
732
737
  this.renameClonedAsset.bind(this),
733
738
  this.setBaseModelEnabled.bind(this)
734
739
  ), this.transformRoot = new Ie("root", this.scene);
735
- const n = async () => {
740
+ const r = async () => {
736
741
  if (!i.model)
737
742
  throw new Error(
738
743
  "Model container constructed with no URL. This is currently unsupported."
739
744
  );
740
745
  return this.assetContainer = await pe(
741
746
  i.model,
742
- r,
747
+ n,
743
748
  a
744
749
  ), this.initialized = !0, await this.instantiate(), this;
745
750
  };
746
- this.importPromise = n();
751
+ this.importPromise = r();
747
752
  }
748
753
  //#region Interface implementation
749
754
  async applyMaterialVariant(e, t, i, o) {
750
755
  if (!this.initialized) {
751
756
  if (this.materialReadyToLoadCallbacks.has(e)) {
752
- const r = this.materialReadyToLoadCallbacks.get(e);
753
- r == null || r.set(
757
+ const n = this.materialReadyToLoadCallbacks.get(e);
758
+ n == null || n.set(
754
759
  t,
755
760
  this.applyMaterialVariant.bind(
756
761
  this,
@@ -765,8 +770,8 @@ class it {
765
770
  e,
766
771
  /* @__PURE__ */ new Map()
767
772
  );
768
- const r = this.materialReadyToLoadCallbacks.get(e);
769
- r == null || r.set(
773
+ const n = this.materialReadyToLoadCallbacks.get(e);
774
+ n == null || n.set(
770
775
  t,
771
776
  this.applyMaterialVariant.bind(
772
777
  this,
@@ -783,10 +788,10 @@ class it {
783
788
  await this.variantManager.applyMaterial(
784
789
  e,
785
790
  i,
786
- (r, n, l) => {
791
+ (n, r, l) => {
787
792
  this.materialVariantObservable.notifyObservers({
788
- remainingCount: r,
789
- totalCount: n,
793
+ remainingCount: n,
794
+ totalCount: r,
790
795
  taskName: l
791
796
  });
792
797
  },
@@ -795,24 +800,24 @@ class it {
795
800
  };
796
801
  if (this.materialChangesInProgress.includes(e)) {
797
802
  if (this.queuedMaterialChanges.has(e)) {
798
- const r = this.queuedMaterialChanges.get(e);
799
- r == null || r.set(t, a);
803
+ const n = this.queuedMaterialChanges.get(e);
804
+ n == null || n.set(t, a);
800
805
  } else {
801
806
  this.queuedMaterialChanges.set(
802
807
  e,
803
808
  /* @__PURE__ */ new Map()
804
809
  );
805
- const r = this.queuedMaterialChanges.get(e);
806
- r == null || r.set(t, a);
810
+ const n = this.queuedMaterialChanges.get(e);
811
+ n == null || n.set(t, a);
807
812
  }
808
813
  return;
809
814
  }
810
815
  if (this.materialChangesInProgress.push(e), await a(), this.queuedMaterialChanges.has(e)) {
811
- const r = this.queuedMaterialChanges.get(e);
812
- if (!r)
816
+ const n = this.queuedMaterialChanges.get(e);
817
+ if (!n)
813
818
  throw new Error("Target material is undefined");
814
- r.forEach(async (n) => {
815
- await n();
819
+ n.forEach(async (r) => {
820
+ await r();
816
821
  }), this.queuedMaterialChanges.delete(e);
817
822
  }
818
823
  this.materialChangesInProgress.splice(
@@ -837,9 +842,9 @@ class it {
837
842
  e,
838
843
  i,
839
844
  t == null ? void 0 : t.model,
840
- (n) => {
845
+ (r) => {
841
846
  this.modelVariantObservable.notifyObservers({
842
- ...n,
847
+ ...r,
843
848
  key: e
844
849
  });
845
850
  }
@@ -848,21 +853,21 @@ class it {
848
853
  this.queuedModelChanges.set(e, o);
849
854
  return;
850
855
  }
851
- const r = await (async () => {
856
+ const n = await (async () => {
852
857
  this.modelChangesInProgress.push(e);
853
- let n = await o();
858
+ let r = await o();
854
859
  if (this.queuedModelChanges.has(e)) {
855
860
  const l = this.queuedModelChanges.get(e);
856
861
  if (!l)
857
862
  throw new Error("Queued change resolved undefined");
858
- n = await l(), this.queuedModelChanges.delete(e);
863
+ r = await l(), this.queuedModelChanges.delete(e);
859
864
  }
860
865
  return this.modelChangesInProgress.splice(
861
866
  this.modelChangesInProgress.indexOf(e),
862
867
  1
863
- ), n;
868
+ ), r;
864
869
  })();
865
- this.modelInstance && fe(this.modelInstance.animationGroups), this.contextService || (this.contextService = t == null ? void 0 : t.contextService), r ? this.configureModelInstance(r) : this.configureGlowLayer();
870
+ this.modelInstance && fe(this.modelInstance.animationGroups), this.contextService || (this.contextService = t == null ? void 0 : t.contextService), n ? this.configureModelInstance(n) : this.configureGlowLayer();
866
871
  }
867
872
  dispose() {
868
873
  var e;
@@ -959,14 +964,14 @@ class it {
959
964
  e.rootNodes.forEach((t) => {
960
965
  t.getChildMeshes(!1).forEach((i) => {
961
966
  i.name === "targetcube_t" || i.name === "backgroundShell" || (i.actionManager || (i.actionManager = new E(this.scene)), i.actionManager.registerAction(
962
- new re(E.OnPointerOverTrigger, (o) => {
967
+ new ne(E.OnPointerOverTrigger, (o) => {
963
968
  o.meshUnderPointer && i.material && this.materialSelectedObservable.notifyObservers({
964
969
  id: i.material.id,
965
970
  name: this.stripIdFromName(i.material.name)
966
971
  });
967
972
  })
968
973
  ), i.actionManager.registerAction(
969
- new re(E.OnPointerOutTrigger, () => {
974
+ new ne(E.OnPointerOutTrigger, () => {
970
975
  i.material && this.materialDeselectedObservable.notifyObservers({
971
976
  id: i.material.id,
972
977
  name: this.stripIdFromName(i.material.name)
@@ -1006,8 +1011,8 @@ class it {
1006
1011
  );
1007
1012
  const t = this.transformRoot.position, i = this.transformRoot.rotationQuaternion, o = this.transformRoot.scaling;
1008
1013
  this.transformRoot.position = m.Zero(), this.transformRoot.rotationQuaternion = M.Identity(), this.transformRoot.scaling = m.One();
1009
- for (const r of e.rootNodes)
1010
- r.parent = this.transformRoot;
1014
+ for (const n of e.rootNodes)
1015
+ n.parent = this.transformRoot;
1011
1016
  this.transformRoot.position = t, this.transformRoot.rotationQuaternion = i, this.transformRoot.scaling = o, this.canvasPanels = ((a = this.contextService) == null ? void 0 : a.getAll()) || /* @__PURE__ */ new Map(), He(
1012
1017
  this.materials.concat(this.variantManager.getAllMaterials()),
1013
1018
  this.scene,
@@ -1088,17 +1093,17 @@ class it {
1088
1093
  //#endregion
1089
1094
  }
1090
1095
  class B extends ue {
1091
- constructor(e, t, i, o, a, r, n, l) {
1096
+ constructor(e, t, i, o, a, n, r, l) {
1092
1097
  super(
1093
1098
  e,
1094
1099
  t,
1095
1100
  i,
1096
1101
  o,
1097
1102
  a,
1098
- r,
1103
+ n,
1099
1104
  l
1100
- ), this.lastFocus = new m(0, 0, 0), this.panDenominator = 1, this.minZ = 0.01, this.setRadius(this.radius), this.enableFramingBehavior(), this.wheelDeltaPercentage = 0.01, this.pinchDeltaPercentage = 5e-3, this.useNaturalPinchZoom = !0, n.camera.autoOrientation && (this.alpha += Math.PI), n && (n.camera.limits.min.beta && (this.lowerBetaLimit = n.camera.limits.min.beta), n.camera.limits.max.beta && (this.upperBetaLimit = n.camera.limits.max.beta), n.camera.limits.min.alpha && (this.lowerAlphaLimit = n.camera.limits.min.alpha), n.camera.limits.max.alpha && (this.upperAlphaLimit = n.camera.limits.max.alpha), n.camera.limits.min.radius && (this.lowerRadiusLimit = n.camera.limits.min.radius), n.camera.limits.max.radius && (this.upperRadiusLimit = n.camera.limits.max.radius), n.camera.autoRotation.enabled && this.enableAutoRotationBehavior(
1101
- n.camera.autoRotation.idleTimeMs
1105
+ ), this.lastFocus = new m(0, 0, 0), this.panDenominator = 1, this.minZ = 0.01, this.setRadius(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(
1106
+ r.camera.autoRotation.idleTimeMs
1102
1107
  ));
1103
1108
  }
1104
1109
  /**
@@ -1137,8 +1142,8 @@ class B extends ue {
1137
1142
  i.framingTime = t || 800;
1138
1143
  const o = () => {
1139
1144
  e && e();
1140
- }, a = T(this._scene), r = a.max.subtract(a.min), n = a.min.add(r.scale(0.5));
1141
- this.setRadius(r.length() * 1.5), this.wheelPrecision = 100 / this.radius, this.panningInertia = 0, this.panningOriginTarget.copyFrom(n), this.panDenominator = r.length(), i.zoomOnBoundingInfo(
1145
+ }, a = T(this._scene), n = a.max.subtract(a.min), r = a.min.add(n.scale(0.5));
1146
+ this.setRadius(n.length() * 1.5), this.wheelPrecision = 100 / this.radius, this.panningInertia = 0, this.panningOriginTarget.copyFrom(r), this.panDenominator = n.length(), i.zoomOnBoundingInfo(
1142
1147
  a.min,
1143
1148
  a.max,
1144
1149
  void 0,
@@ -1172,18 +1177,18 @@ class B extends ue {
1172
1177
  * @param assignActive If true the camera will be assigned as the active camera on the scene.
1173
1178
  */
1174
1179
  static create(e, t, i) {
1175
- const o = T(e), a = o.max.subtract(o.min), r = o.min.add(a.scale(0.5)), n = new B(
1180
+ const o = T(e), a = o.max.subtract(o.min), n = o.min.add(a.scale(0.5)), r = new B(
1176
1181
  "ProductCamera",
1177
1182
  -(Math.PI / 2),
1178
1183
  Math.PI / 2,
1179
1184
  a.length() * 1.5,
1180
- r,
1185
+ n,
1181
1186
  e,
1182
1187
  t
1183
1188
  );
1184
- return n.panningInertia = 0, n.panningOriginTarget.copyFrom(r), n.panDenominator = a.length(), n.onAfterCheckInputsObservable.add(() => {
1185
- n.panningSensibility = 1e3 / n.panDenominator;
1186
- }), i && (e.activeCamera = n), n;
1189
+ return r.panningInertia = 0, r.panningOriginTarget.copyFrom(n), r.panDenominator = a.length(), r.onAfterCheckInputsObservable.add(() => {
1190
+ r.panningSensibility = 1e3 / r.panDenominator;
1191
+ }), i && (e.activeCamera = r), r;
1187
1192
  }
1188
1193
  }
1189
1194
  function T(s) {
@@ -1204,7 +1209,7 @@ class st {
1204
1209
  i ? [i] : void 0,
1205
1210
  !1
1206
1211
  // Disable automatic build
1207
- ), this.renderingPipeline.isSupported && (this.renderingPipeline.prepare(), this.setConfiguration(h));
1212
+ ), this.renderingPipeline.isSupported && (this.renderingPipeline.prepare(), this.setConfiguration(c));
1208
1213
  }
1209
1214
  dispose() {
1210
1215
  this.renderingPipeline.dispose();
@@ -1213,16 +1218,16 @@ class st {
1213
1218
  return this.currentConfiguration;
1214
1219
  }
1215
1220
  setConfiguration(e) {
1216
- var t, i, o, a, r, n, l, c, d, u, g, p, b, D, k, z, N, V, G, q, H, _, K, U, W, Q, Z, $, Y, j, X, J, ee;
1221
+ var t, i, o, a, n, r, l, h, d, u, g, p, b, D, k, z, N, V, G, q, H, _, K, U, W, Q, Y, Z, $, j, X, J, ee;
1217
1222
  if (this.renderingPipeline.isSupported) {
1218
- if (this.renderingPipeline.samples = ((t = e.antiAliasing) == null ? void 0 : t.samples) ?? h.antiAliasing.samples, this.renderingPipeline.fxaaEnabled = ((i = e.antiAliasing) == null ? void 0 : i.fxaaEnabled) ?? h.antiAliasing.fxaaEnabled, this.renderingPipeline.bloomEnabled = ((o = e.bloom) == null ? void 0 : o.enabled) ?? h.bloom.enabled, this.renderingPipeline.bloomKernel = ((a = e.bloom) == null ? void 0 : a.kernel) ?? h.bloom.kernel, this.renderingPipeline.bloomScale = ((r = e.bloom) == null ? void 0 : r.scale) ?? h.bloom.scale, this.renderingPipeline.bloomThreshold = ((n = e.bloom) == null ? void 0 : n.threshold) ?? h.bloom.threshold, this.renderingPipeline.bloomWeight = ((l = e.bloom) == null ? void 0 : l.weight) ?? h.bloom.weight, this.renderingPipeline.chromaticAberrationEnabled = ((c = e.chromaticAberration) == null ? void 0 : c.enabled) ?? h.chromaticAberration.enabled, this.renderingPipeline.chromaticAberration.aberrationAmount = ((d = e.chromaticAberration) == null ? void 0 : d.aberrationAmount) ?? h.chromaticAberration.aberrationAmount, this.renderingPipeline.chromaticAberration.radialIntensity = ((u = e.chromaticAberration) == null ? void 0 : u.radialIntensity) ?? h.chromaticAberration.radialIntensity, this.renderingPipeline.chromaticAberration.direction = (g = e.chromaticAberration) != null && g.direction ? new te(
1223
+ 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 = ((o = e.bloom) == null ? void 0 : o.enabled) ?? c.bloom.enabled, this.renderingPipeline.bloomKernel = ((a = e.bloom) == null ? void 0 : a.kernel) ?? c.bloom.kernel, this.renderingPipeline.bloomScale = ((n = e.bloom) == null ? void 0 : n.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 = ((h = e.chromaticAberration) == null ? void 0 : h.enabled) ?? c.chromaticAberration.enabled, this.renderingPipeline.chromaticAberration.aberrationAmount = ((d = e.chromaticAberration) == null ? void 0 : d.aberrationAmount) ?? c.chromaticAberration.aberrationAmount, this.renderingPipeline.chromaticAberration.radialIntensity = ((u = e.chromaticAberration) == null ? void 0 : u.radialIntensity) ?? c.chromaticAberration.radialIntensity, this.renderingPipeline.chromaticAberration.direction = (g = e.chromaticAberration) != null && g.direction ? new te(
1219
1224
  e.chromaticAberration.direction.x,
1220
1225
  e.chromaticAberration.direction.y
1221
1226
  ) : new te(
1222
- h.chromaticAberration.direction.x,
1223
- h.chromaticAberration.direction.y
1224
- ), this.renderingPipeline.imageProcessing.colorCurvesEnabled = ((p = e.colorCurves) == null ? void 0 : p.enabled) ?? h.colorCurves.enabled, this.renderingPipeline.imageProcessing.colorCurves = e.colorCurves ? this.updateColorCurve(e.colorCurves) : new ne(), this.renderingPipeline.depthOfFieldEnabled = ((b = e.depthOfField) == null ? void 0 : b.enabled) ?? h.depthOfField.enabled, e.depthOfField)
1225
- switch (e.depthOfField.blurLevel ?? h.depthOfField.blurLevel) {
1227
+ c.chromaticAberration.direction.x,
1228
+ c.chromaticAberration.direction.y
1229
+ ), 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 re(), this.renderingPipeline.depthOfFieldEnabled = ((b = e.depthOfField) == null ? void 0 : b.enabled) ?? c.depthOfField.enabled, e.depthOfField)
1230
+ switch (e.depthOfField.blurLevel ?? c.depthOfField.blurLevel) {
1226
1231
  case "Low":
1227
1232
  this.renderingPipeline.depthOfFieldBlurLevel = A.Low;
1228
1233
  break;
@@ -1233,8 +1238,8 @@ class st {
1233
1238
  this.renderingPipeline.depthOfFieldBlurLevel = A.High;
1234
1239
  break;
1235
1240
  }
1236
- if (this.renderingPipeline.depthOfField.focalLength = ((D = e.depthOfField) == null ? void 0 : D.focalLength) ?? h.depthOfField.focalLength, this.renderingPipeline.depthOfField.fStop = ((k = e.depthOfField) == null ? void 0 : k.fStop) ?? h.depthOfField.fStop, this.renderingPipeline.depthOfField.focusDistance = ((z = e.depthOfField) == null ? void 0 : z.focusDistance) ?? h.depthOfField.focusDistance, this.renderingPipeline.depthOfField.lensSize = ((N = e.depthOfField) == null ? void 0 : N.lensSize) ?? h.depthOfField.lensSize, this.renderingPipeline.grainEnabled = ((V = e.grain) == null ? void 0 : V.enabled) ?? h.grain.enabled, this.renderingPipeline.grain.animated = ((G = e.grain) == null ? void 0 : G.animated) ?? h.grain.animated, this.renderingPipeline.grain.intensity = ((q = e.grain) == null ? void 0 : q.intensity) ?? h.grain.intensity, this.renderingPipeline.imageProcessing.contrast = ((H = e.misc) == null ? void 0 : H.contrast) ?? h.misc.contrast, this.renderingPipeline.imageProcessing.exposure = ((_ = e.misc) == null ? void 0 : _.exposure) ?? h.misc.exposure, this.renderingPipeline.imageProcessing.toneMappingEnabled = ((K = e.misc) == null ? void 0 : K.toneMappingEnabled) ?? h.misc.toneMappingEnabled, this.renderingPipeline.imageProcessing.toneMappingEnabled)
1237
- switch (e.misc.toneMappingType ?? h.misc.toneMappingType) {
1241
+ 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 = ((N = e.depthOfField) == null ? void 0 : N.lensSize) ?? c.depthOfField.lensSize, this.renderingPipeline.grainEnabled = ((V = e.grain) == null ? void 0 : V.enabled) ?? c.grain.enabled, this.renderingPipeline.grain.animated = ((G = e.grain) == null ? void 0 : G.animated) ?? c.grain.animated, this.renderingPipeline.grain.intensity = ((q = e.grain) == null ? void 0 : q.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)
1242
+ switch (e.misc.toneMappingType ?? c.misc.toneMappingType) {
1238
1243
  case "Standard":
1239
1244
  this.renderingPipeline.imageProcessing.toneMappingType = P.TONEMAPPING_STANDARD;
1240
1245
  break;
@@ -1242,8 +1247,8 @@ class st {
1242
1247
  this.renderingPipeline.imageProcessing.toneMappingType = P.TONEMAPPING_ACES;
1243
1248
  break;
1244
1249
  }
1245
- if (this.renderingPipeline.sharpenEnabled = ((U = e.sharpen) == null ? void 0 : U.enabled) ?? h.sharpen.enabled, this.renderingPipeline.sharpen.colorAmount = ((W = e.sharpen) == null ? void 0 : W.colorAmount) ?? h.sharpen.colorAmount, this.renderingPipeline.sharpen.edgeAmount = ((Q = e.sharpen) == null ? void 0 : Q.edgeAmount) ?? h.sharpen.edgeAmount, this.renderingPipeline.imageProcessing.vignetteEnabled = ((Z = e.vignette) == null ? void 0 : Z.enabled) ?? h.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 = h.vignette.center.x, this.renderingPipeline.imageProcessing.vignetteCenterY = h.vignette.center.y), e.vignette)
1246
- switch (((Y = e.vignette) == null ? void 0 : Y.blendMode) ?? h.vignette.blendMode) {
1250
+ if (this.renderingPipeline.sharpenEnabled = ((U = e.sharpen) == null ? void 0 : U.enabled) ?? c.sharpen.enabled, this.renderingPipeline.sharpen.colorAmount = ((W = e.sharpen) == null ? void 0 : W.colorAmount) ?? c.sharpen.colorAmount, this.renderingPipeline.sharpen.edgeAmount = ((Q = e.sharpen) == null ? void 0 : Q.edgeAmount) ?? c.sharpen.edgeAmount, this.renderingPipeline.imageProcessing.vignetteEnabled = ((Y = e.vignette) == null ? void 0 : Y.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)
1251
+ switch ((($ = e.vignette) == null ? void 0 : $.blendMode) ?? c.vignette.blendMode) {
1247
1252
  case "Multiply":
1248
1253
  this.renderingPipeline.imageProcessing.vignetteBlendMode = P.VIGNETTEMODE_MULTIPLY;
1249
1254
  break;
@@ -1257,15 +1262,15 @@ class st {
1257
1262
  e.vignette.colorRgba.b,
1258
1263
  e.vignette.colorRgba.a
1259
1264
  ) : (X = e.vignette) != null && X.colorHex ? this.renderingPipeline.imageProcessing.vignetteColor = f.FromHexString(e.vignette.colorHex) : this.renderingPipeline.imageProcessing.vignetteColor = new f(
1260
- h.vignette.colorRgba.r,
1261
- h.vignette.colorRgba.g,
1262
- h.vignette.colorRgba.b,
1263
- h.vignette.colorRgba.a
1264
- ), this.renderingPipeline.imageProcessing.vignetteStretch = ((J = e.vignette) == null ? void 0 : J.stretch) ?? h.vignette.stretch, this.renderingPipeline.imageProcessing.vignetteWeight = ((ee = e.vignette) == null ? void 0 : ee.weight) ?? h.vignette.weight, this.renderingPipeline.prepare(), this.currentConfiguration = e;
1265
+ c.vignette.colorRgba.r,
1266
+ c.vignette.colorRgba.g,
1267
+ c.vignette.colorRgba.b,
1268
+ c.vignette.colorRgba.a
1269
+ ), 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;
1265
1270
  }
1266
1271
  }
1267
1272
  updateColorCurve(e) {
1268
- const t = new ne();
1273
+ const t = new re();
1269
1274
  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;
1270
1275
  }
1271
1276
  }
@@ -1286,17 +1291,17 @@ function L(s) {
1286
1291
  }
1287
1292
  class Ut {
1288
1293
  constructor(e) {
1289
- var n;
1294
+ var l;
1290
1295
  this.focusLostNotified = !1, this.focusLostObservable = new C(), this.modelLoadEventCallbacks = [], this.modelContainers = /* @__PURE__ */ new Map(), this.plugins = [], this.initComplete = !1, this.renderLoop = () => {
1291
- this.engine.views && (this.modelContainers.forEach((l) => {
1292
- l.updateDynamicTextures();
1293
- }), this.configuration.scene.transparentBackground && this.engine.views.forEach((l) => {
1294
- const c = this.engine.getRenderingCanvas(), d = l.target.getContext("2d");
1295
- if (!c)
1296
- throw new Error("Could not access rendering canvas");
1296
+ this.engine.views && (this.modelContainers.forEach((h) => {
1297
+ h.updateDynamicTextures();
1298
+ }), this.configuration.scene.transparentBackground && this.engine.views.forEach((h) => {
1299
+ const d = this.engine.getRenderingCanvas(), u = h.target.getContext("2d");
1297
1300
  if (!d)
1301
+ throw new Error("Could not access rendering canvas");
1302
+ if (!u)
1298
1303
  throw new Error("Could not access 2D context for view target");
1299
- d.clearRect(0, 0, c.width, c.height);
1304
+ u.clearRect(0, 0, d.width, d.height);
1300
1305
  }), 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));
1301
1306
  }, this.configuration = new Ne(e);
1302
1307
  const i = (() => {
@@ -1313,7 +1318,7 @@ class Ut {
1313
1318
  const a = console.log;
1314
1319
  console.log = () => {
1315
1320
  };
1316
- const r = i ? new me(i, !0, {
1321
+ const n = i ? new me(i, !0, {
1317
1322
  adaptToDeviceRatio: !0,
1318
1323
  limitDeviceRatio: 2,
1319
1324
  premultipliedAlpha: !1,
@@ -1322,21 +1327,23 @@ class Ut {
1322
1327
  stencil: this.configuration.highlights.enabled,
1323
1328
  forceSRGBBufferSupportState: !0
1324
1329
  }) : new we();
1325
- console.log = a, r.hideLoadingUI(), window.addEventListener("resize", this.fireResizeEvent.bind(this)), this.engine = r, this.scene = new xe(r), this.camera = B.create(this.scene, this.configuration), this.scene.activeCamera = this.camera, this.renderingPipeline = new st(
1330
+ console.log = a, n.hideLoadingUI(), window.addEventListener("resize", this.fireResizeEvent.bind(this)), this.engine = n, this.scene = new xe(n), this.camera = B.create(this.scene, this.configuration), this.scene.activeCamera = this.camera, this.renderingPipeline = new st(
1326
1331
  this.scene,
1327
1332
  !1,
1328
1333
  this.camera
1329
- ), this.scene.clearColor = this.configuration.scene.clearColor, this.scene.environmentTexture = Ce.CreateFromPrefilteredData(
1330
- this.configuration.scene.environmentFile,
1334
+ ), this.scene.clearColor = this.configuration.scene.clearColor;
1335
+ const r = Ce.CreateFromPrefilteredData(
1336
+ this.configuration.scene.environment.file,
1331
1337
  this.scene
1332
- ), (n = this.configuration.options) != null && n.renderingPipelineConfiguration && this.renderingPipeline.setConfiguration(
1338
+ );
1339
+ 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(
1333
1340
  this.configuration.options.renderingPipelineConfiguration
1334
- ), this.glowLayerManager = new qe(
1341
+ ) : (this.scene.imageProcessingConfiguration.exposure = this.configuration.lighting.exposure, this.scene.imageProcessingConfiguration.contrast = this.configuration.lighting.contrast), this.glowLayerManager = new qe(
1335
1342
  this.scene,
1336
1343
  this.configuration.emissiveGlowIntensity
1337
- ), this.initPromise = new Promise((l) => {
1344
+ ), this.initPromise = new Promise((h) => {
1338
1345
  this.scene.onReadyObservable.addOnce(() => {
1339
- this.initComplete = !0, l();
1346
+ this.initComplete = !0, h();
1340
1347
  });
1341
1348
  }), this.engine.runRenderLoop(this.renderLoop);
1342
1349
  }
@@ -1452,7 +1459,7 @@ class Ut {
1452
1459
  try {
1453
1460
  const o = t.latDeg * Math.PI / 180, a = t.lonDeg * Math.PI / 180;
1454
1461
  i.target = t.target ? new m(t.target.x, t.target.y, t.target.z) : m.Zero(), i.alpha = a, i.beta = o, i.radius = t.radius || this.camera.radius, i.minZ = 0.01, this.scene.render();
1455
- const r = await ye.CreateScreenshotUsingRenderTargetAsync(
1462
+ const n = await ye.CreateScreenshotUsingRenderTargetAsync(
1456
1463
  this.engine,
1457
1464
  i,
1458
1465
  e,
@@ -1460,7 +1467,7 @@ class Ut {
1460
1467
  2,
1461
1468
  !0
1462
1469
  );
1463
- return i.dispose(), r;
1470
+ return i.dispose(), n;
1464
1471
  } catch {
1465
1472
  throw i.isDisposed() || i.dispose(), new Error("Failed to render screenshot");
1466
1473
  }
@@ -1472,8 +1479,8 @@ class Ut {
1472
1479
  const t = e.camera.limits.min.alpha, i = e.camera.limits.max.alpha, o = e.camera.limits.min.beta, a = e.camera.limits.max.beta;
1473
1480
  if (t === void 0 || i === void 0 || o === void 0 || a === void 0)
1474
1481
  return !0;
1475
- const r = [t, i], n = [o, a], l = r.every((d) => d === t), c = n.every((d) => d === o);
1476
- return !l && !c;
1482
+ const n = [t, i], r = [o, a], l = n.every((d) => d === t), h = r.every((d) => d === o);
1483
+ return !l && !h;
1477
1484
  }
1478
1485
  fireResizeEvent() {
1479
1486
  this.getNumViewports() > 0 && this.engine.resize();
@@ -1487,14 +1494,14 @@ class Ut {
1487
1494
  }), this.highlightLayer.innerGlow = !0, this.highlightLayer.outerGlow = !1), this.highlightLayer.removeAllMeshes();
1488
1495
  const i = t ? new v(t[0], t[1], t[2]).toLinearSpace() : void 0;
1489
1496
  e.forEach((a) => {
1490
- const r = this.scene.materials.find(
1491
- (n) => n.name === a.name && n.id === a.id
1497
+ const n = this.scene.materials.find(
1498
+ (r) => r.name === a.name && r.id === a.id
1492
1499
  );
1493
- r && r.getBindedMeshes().forEach(
1494
- (n) => {
1500
+ n && n.getBindedMeshes().forEach(
1501
+ (r) => {
1495
1502
  var l;
1496
1503
  return (l = this.highlightLayer) == null ? void 0 : l.addMesh(
1497
- n,
1504
+ r,
1498
1505
  i || v.FromHexString("#fcba03")
1499
1506
  );
1500
1507
  }
@@ -1562,11 +1569,11 @@ class Ut {
1562
1569
  O(t || { x: 0, y: 0, z: 0 })
1563
1570
  ),
1564
1571
  O(e || { x: 0, y: 0, z: 0 })
1565
- ), a = ie.RotationAxis(m.Up(), Math.PI), r = o.multiply(a), n = m.Zero(), l = M.Identity(), c = m.Zero();
1566
- return r.decompose(c, l, n), l.multiplyInPlace(M.FromEulerAngles(0, Math.PI, 0)), {
1567
- position: L(n),
1572
+ ), a = ie.RotationAxis(m.Up(), Math.PI), n = o.multiply(a), r = m.Zero(), l = M.Identity(), h = m.Zero();
1573
+ return n.decompose(h, l, r), l.multiplyInPlace(M.FromEulerAngles(0, Math.PI, 0)), {
1574
+ position: L(r),
1568
1575
  rotation: L(l.toEulerAngles()),
1569
- scale: L(c)
1576
+ scale: L(h)
1570
1577
  };
1571
1578
  }
1572
1579
  /**
@@ -1589,5 +1596,5 @@ export {
1589
1596
  Ve as REFLECTION_PROBE_RESOLUTION,
1590
1597
  x as RenderingConfiguration,
1591
1598
  Ut as SpiffCommerce3DPreviewService,
1592
- h as renderingPipelineDefaults
1599
+ c as renderingPipelineDefaults
1593
1600
  };
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- (function(h,y){typeof exports=="object"&&typeof module<"u"?y(exports,require("@babylonjs/core/Cameras/arcRotateCamera"),require("@babylonjs/core/Engines/engine"),require("@babylonjs/core/Engines/nullEngine"),require("@babylonjs/core/Layers/highlightLayer"),require("@babylonjs/core/Loading/sceneLoader"),require("@babylonjs/core/Materials/Textures/cubeTexture"),require("@babylonjs/core/Maths/math.color"),require("@babylonjs/core/Maths/math.vector"),require("@babylonjs/core/Meshes/Compression/dracoCompression"),require("@babylonjs/core/Misc/observable"),require("@babylonjs/core/Misc/tools"),require("@babylonjs/core/scene"),require("@babylonjs/loaders/glTF"),require("@babylonjs/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"],y):(h=typeof globalThis<"u"?globalThis:h||self,y(h.Preview={},h.arcRotateCamera,h.engine,h.nullEngine,h.highlightLayer,h.sceneLoader,h.cubeTexture,h.math_color,h.math_vector,h.dracoCompression,h.observable,h.tools,h.scene,h.glTF,h.pbrMaterial,h.mirrorTexture,h.math,h.reflectionProbe,h.glowLayer,h.actionManager,h.directActions,h.mesh,h.transformNode,h.dynamicTexture,h.texture,h.animation,h.easing,h.assetsManager,h.colorCurves,h.imageProcessingConfiguration,h.RenderPipeline,h.depthOfFieldEffect))})(this,function(h,y,D,be,ye,q,we,p,g,Ce,M,ve,Me,xe,L,Pe,P,Te,Re,O,V,Ee,Ae,Le,Oe,w,N,Ie,k,T,Se,I){"use strict";var R=(s=>(s[s.Orbit=0]="Orbit",s[s.Pan=1]="Pan",s))(R||{}),E=(s=>(s.None="None",s.RemoveWhenSelected="RemoveWhenSelected",s.ApplyWhenSelected="ApplyWhenSelected",s))(E||{});class Fe{constructor(e){this.getSceneClearColor=()=>{var i,o,a,r;const t=(i=this.customOptions)!=null&&i.transparentBackground||(o=this.customOptions)!=null&&o.backgroundImage?0:1;if(this.customOptions&&((a=this.customOptions)!=null&&a.transparentBackground)||(r=this.customOptions)!=null&&r.backgroundImage)return new p.Color4(0,0,0,t).toLinearSpace();if(this.customOptions&&this.customOptions.backgroundColor){const n=p.Color3.FromHexString(this.customOptions.backgroundColor);return new p.Color4(n.r,n.g,n.b,t).toLinearSpace()}return new p.Color4(.98,.98,.98,t).toLinearSpace()},this.highlightColorFromConfig=()=>this.customOptions&&this.customOptions.highlightColor?this.hexToColor4(this.customOptions.highlightColor):new p.Color4(.98,.98,.98,1).toLinearSpace(),this.hexToColor4=(t,i=1)=>{const o=p.Color3.FromHexString(t);return new p.Color4(o.r,o.g,o.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;return{clearColor:this.getSceneClearColor(),transparentBackground:((e=this.customOptions)==null?void 0:e.transparentBackground)||((t=this.customOptions)==null?void 0:t.backgroundImage),environmentFile:((i=this.customOptions)==null?void 0:i.environmentFile)??"assets/model-viewer/default.env"}}get camera(){var e,t,i,o,a,r,n,l,d,u,m,f,b;return{autoOrientation:((e=this.customOptions)==null?void 0:e.disableAutomaticOrientation)??!0,autoRotation:{enabled:((t=this.customOptions)==null?void 0:t.autoRotation)??!1,idleTimeMs:((i=this.customOptions)==null?void 0:i.idleTimeBeforeRotation)??5e3},limits:{min:{alpha:(o=this.customOptions)!=null&&o.lowerAlphaLimitDeg?((a=this.customOptions)==null?void 0:a.lowerAlphaLimitDeg)*Math.PI/180:void 0,beta:(r=this.customOptions)!=null&&r.lowerBetaLimitDeg?((n=this.customOptions)==null?void 0:n.lowerBetaLimitDeg)*Math.PI/180:void 0,radius:(l=this.customOptions)==null?void 0:l.minZoomOverride},max:{alpha:(d=this.customOptions)!=null&&d.upperAlphaLimitDeg?((u=this.customOptions)==null?void 0:u.upperAlphaLimitDeg)*Math.PI/180:void 0,beta:(m=this.customOptions)!=null&&m.upperBetaLimitDeg?((f=this.customOptions)==null?void 0:f.upperBetaLimitDeg)*Math.PI/180:void 0,radius:(b=this.customOptions)==null?void 0:b.maxZoomOverride}}}}get highlights(){var e;return{enabled:((e=this.customOptions)==null?void 0:e.highlightOnMaterialHover)??!1,color:this.highlightColorFromConfig()}}get lighting(){var e,t,i,o;return{exposure:((t=(e=this.customOptions)==null?void 0:e.lighting)==null?void 0:t.exposure)??.9,contrast:((o=(i=this.customOptions)==null?void 0:i.lighting)==null?void 0:o.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<=480}catch{return!1}}}const z=128,c={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(o){t.extras&&Object.keys(t.extras).forEach(a=>{const r=t.extras[a];o.metadata[a]=r}),i(o)})}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 r=[];return a.transformNodes.forEach(n=>{n.metadata&&n.metadata.reflective&&r.push(...n.getChildMeshes())}),a.meshes.forEach(n=>{n.metadata&&n.metadata.reflective&&!r.includes(n)&&r.push(n)}),r}function i(a,r=1){const n=a.material;if(!n)return;const l=new Pe.MirrorTexture("mirror",C.getMirrorTextureResolution(),e,!0);l.renderList=t(e);const d=a.getVerticesData("normal");if(!d)throw new Error("Mirror attribute specified on: "+a.name+"But no normals exist to generate a mirror from!");a.computeWorldMatrix(!0);const u=a.getWorldMatrix(),m=P.Vector3.TransformNormal(new P.Vector3(d[0],d[1],d[2]),u).normalize(),f=P.Plane.FromPositionAndNormal(a.position,m.scale(-1));l.mirrorPlane=f,l.level=r,n.reflectionTexture=l}function o(a){const r=a.material,n=new Te.ReflectionProbe("probe-"+r.name,z,e);n.attachToMesh(a),n.renderList&&n.renderList.push(...t(e)),r.reflectionTexture=n.cubeTexture}e.meshes.forEach(a=>{const r=a.metadata;r&&(r.mirrorTexture&&i(a,r.mirrorTexture),r.reflectionProbe&&o(a))})}}class je{constructor(e,t){this.scene=e,this.intensity=t,this.meshCount=0}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 G=new Map;async function H(s,e,t){const i=G.get(s);if(i&&i.scene.uid===e.uid)return i;{const o=await q.SceneLoader.LoadAssetContainerAsync(s,void 0,e,t);return G.set(s,o),o}}function De(s,e,t,i,o=""){t.forEach(a=>{const r=a.getID(),n=a.getName(),l=C.getDynamicTextureResolution();s.filter(u=>u.name===o+n).forEach(u=>{const m=i.get(r),f=!1;if(m)K(u,m),m.update(f);else{const b=qe(n,e,l.width,l.height);i.set(r,b),a.setStaticContext(b.getContext()),K(u,b),b.onLoadObservable.addOnce(()=>{b.update(f)})}})})}function qe(s,e,t,i){const o=new Le.DynamicTexture(s,{width:t,height:i},e,C.shouldMipMap(),Oe.Texture.TRILINEAR_SAMPLINGMODE,D.Engine.TEXTUREFORMAT_RGBA),a=o.getContext();return a&&(a.fillStyle="#f5f5f5",a.fillRect(0,0,t,i),o.update()),o}function K(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,U=1;function Q(s){return s.targetedAnimations.map(t=>t.animation.framePerSecond).reduce((t,i)=>t+i,0)/s.targetedAnimations.length||0}function Ne(s,e,t,i,o){const a=o?s.filter(r=>r.name===o):s;if(a.length===0){console.warn(`No animations found for name: ${o}`);return}if(i!==void 0&&t!==void 0&&i===t){a.forEach(r=>{r.stop();const n=Q(r),l=i*n;r.start(e,U,l,l)});return}a.forEach(r=>{r.stop();const n=Q(r),l=i!==void 0?i*n:void 0,d=t!==void 0?t*n:void 0;r.start(e,U,l,d)})}function W(s){s.forEach(e=>{e.stop()})}function ke(s){const e=s.animationGroups;W(e)}function ze(s,e,t){s.stopAnimation(e),e.animations=[],Math.abs(e.alpha)>2*Math.PI&&(e.alpha=Ge(e.alpha,0,2*Math.PI));const i=[],o=t.target,a=0,r=o?1:0;if(t.target&&Object.keys(t.target).length>0&&i.push(A("cameraTargetLerp","target",new g.Vector3().copyFrom(e.target),new g.Vector3(t.target.x,t.target.y,t.target.z),w.Animation.ANIMATIONTYPE_VECTOR3,a)),i.push(A("cameraAlphaLerp","alpha",e.alpha,Z(t.lonDeg),w.Animation.ANIMATIONTYPE_FLOAT,r)),i.push(A("cameraBetaLerp","beta",e.beta,Z(t.latDeg),w.Animation.ANIMATIONTYPE_FLOAT,r)),t.radius!==void 0){const d=Math.max(.01,t.radius);i.push(A("cameraRadiusLerp","radius",e.radius,d,w.Animation.ANIMATIONTYPE_FLOAT,r))}e.animations.push(...i);const l=e.useAutoRotationBehavior;e.disableAutoRotationBehavior(),s.beginAnimation(e,0,o?x*2:x,!1,1,()=>{e.animations=[],l&&e.enableAutoRotationBehavior()})}function Z(s){return s*Math.PI/180}function A(s,e,t,i,o,a=0,r=w.Animation.ANIMATIONLOOPMODE_CONSTANT){const n=new N.QuadraticEase;n.setEasingMode(N.EasingFunction.EASINGMODE_EASEINOUT);const l=new w.Animation(s,e,x,o,r),d=[];return a>0&&d.push({frame:0,value:t}),d.push({frame:x*a,value:t}),d.push({frame:x*(a+1),value:i}),l.setKeys(d),l.setEasingFunction(n),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"};function Ke(s,e,t,i){["albedoTexture","bumpTexture","ambientTexture","emissiveTexture","opacityTexture","metallicTexture","refractionTexture"].forEach(a=>{Ue(a,s,e,t,i)}),Ze(s,e)}function Ue(s,e,t,i,o){const a=He[s];if(!a)throw new Error("Unexpected texture name encountered.");const r=e[a],n=r==null?void 0:r.fileLink;n?i.addTextureTask(s,n,!1,!1):o&&t[s]&&(t[s]&&t[s].dispose(),t[s]=null,Qe(s,t))}function Qe(s,e){s==="opacityTexture"&&(e.useAlphaFromAlbedoTexture=!0),s==="metallicTexture"&&(e.useRoughnessFromMetallicTextureAlpha=!1,e.useRoughnessFromMetallicTextureGreen=!1,e.useMetallnessFromMetallicTextureBlue=!1),s==="refractionTexture"&&(e.subSurface.isRefractionEnabled=!1,e.subSurface.refractionIntensity=1),s==="emissiveTexture"&&(e.emissiveIntensity=0,e.emissiveColor=new p.Color3(0,0,0))}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),e[s]=i,s==="emissiveTexture"&&(e.emissiveColor=new p.Color3(1,1,1),e.emissiveIntensity=1)}function Ze(s,e){s.clearCoat&&(s.clearCoat===E.RemoveWhenSelected?(e.clearCoat.isEnabled=!1,e.clearCoat.indexOfRefraction=1.5):s.clearCoat===E.ApplyWhenSelected&&(e.clearCoat.isEnabled=!0,e.clearCoat.indexOfRefraction=s.clearCoatIOR||e.clearCoat.indexOfRefraction))}class $e{constructor(e,t,i){this.materialVariantMap=new Map,this.keysThatRemovedBaseModel=[],this.loadedContainerForKey=new Map,this.loadedMaterialsForKey=new Map,this.scene=e,this.renameClonedAsset=t,this.setBaseModelEnabled=i}async applyMaterial(e,t,i,o){return new Promise(a=>{const r=this.materialVariantMap.get(e);this.materialVariantMap.set(e,{...r,...t});const n=this.renameClonedAsset(e),l=this.scene.materials.filter(u=>u.name===n);if(l.length===0){a();return}const d=new Ie.AssetsManager(this.scene);d.useDefaultLoadingScreen=!1,l.forEach(u=>Ke(t,u,d,o)),d.onProgress=(u,m,f)=>{i&&i(u/m*100,100,f.name)},d.onFinish=u=>{u.forEach(m=>{const f=m;i&&i(100,100,m.name),this.scene.materials.filter(v=>v.name===n).forEach(v=>We(m.name,v,t,f.texture))}),a()},d.loadAsync()})}async applyModel(e,t,i,o){var l,d;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(u=>u!==e),Promise.resolve(void 0);const r=(await H(i,this.scene,o)).instantiateModelsToScene(this.renameClonedAsset,!0);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,r),this.loadedMaterialsForKey.set(e,$(r));const n=[];return this.materialVariantMap.forEach(async(u,m)=>{n.push(this.applyMaterial(m,u))}),await Promise.all(n),r}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(o=>{const a=o.getMaterial(!1);a&&!e.includes(a)&&e.push(a)})})}),e}function Y(s,e=""){return s.map(t=>({name:t.name.substring(e.length),loop:t.loopAnimation,to:t.to,from:t.from}))}class Ye{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.animations=[],this.initialized=!1,this.materials=[];const{enablePicking:t,modelDetails:i,previewService:o,progressHandler:a,scene:r}=e;this.enablePicking=t,this.contextService=i.contextService,this.id=Ve(),this.previewService=o,this.scene=r,this.variantManager=new $e(r,this.renameClonedAsset.bind(this),this.setBaseModelEnabled.bind(this)),this.transformRoot=new Ae.TransformNode("root",this.scene);const n=async()=>{if(!i.model)throw new Error("Model container constructed with no URL. This is currently unsupported.");return this.assetContainer=await H(i.model,r,a),this.initialized=!0,await this.instantiate(),this};this.importPromise=n()}async applyMaterialVariant(e,t,i,o){if(!this.initialized){if(this.materialReadyToLoadCallbacks.has(e)){const r=this.materialReadyToLoadCallbacks.get(e);r==null||r.set(t,this.applyMaterialVariant.bind(this,e,t,i,o))}else{this.materialReadyToLoadCallbacks.set(e,new Map);const r=this.materialReadyToLoadCallbacks.get(e);r==null||r.set(t,this.applyMaterialVariant.bind(this,e,t,i,o))}return}const a=async()=>{await this.variantManager.applyMaterial(e,i,(r,n,l)=>{this.materialVariantObservable.notifyObservers({remainingCount:r,totalCount:n,taskName:l})},o)};if(this.materialChangesInProgress.includes(e)){if(this.queuedMaterialChanges.has(e)){const r=this.queuedMaterialChanges.get(e);r==null||r.set(t,a)}else{this.queuedMaterialChanges.set(e,new Map);const r=this.queuedMaterialChanges.get(e);r==null||r.set(t,a)}return}if(this.materialChangesInProgress.push(e),await a(),this.queuedMaterialChanges.has(e)){const r=this.queuedMaterialChanges.get(e);if(!r)throw new Error("Target material is undefined");r.forEach(async n=>{await n()}),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 o=()=>this.variantManager.applyModel(e,i,t==null?void 0:t.model,n=>{this.modelVariantObservable.notifyObservers({...n,key:e})});if(this.modelChangesInProgress.includes(e)){this.queuedModelChanges.set(e,o);return}const r=await(async()=>{this.modelChangesInProgress.push(e);let n=await o();if(this.queuedModelChanges.has(e)){const l=this.queuedModelChanges.get(e);if(!l)throw new Error("Queued change resolved undefined");n=await l(),this.queuedModelChanges.delete(e)}return this.modelChangesInProgress.splice(this.modelChangesInProgress.indexOf(e),1),n})();this.modelInstance&&W(this.modelInstance.animationGroups),this.contextService||(this.contextService=t==null?void 0:t.contextService),r?this.configureModelInstance(r):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.previewService.getInitializationComplete()){this.queuedModelAnimation=e;return}this.modelInstance&&Ne([...this.modelInstance.animationGroups,...this.variantManager.getAnimationGroups()],e.loop,e.to,e.from,e.name?this.renameClonedAsset(e.name):void 0)}getAnimations(e){return[...this.animations,...e?Y(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 g.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=g.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 g.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 V.ExecuteCodeAction(O.ActionManager.OnPointerOverTrigger,o=>{o.meshUnderPointer&&i.material&&this.materialSelectedObservable.notifyObservers({id:i.material.id,name:this.stripIdFromName(i.material.name)})})),i.actionManager.registerAction(new V.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,o=this.transformRoot.scaling;this.transformRoot.position=g.Vector3.Zero(),this.transformRoot.rotationQuaternion=g.Quaternion.Identity(),this.transformRoot.scaling=g.Vector3.One();for(const r of e.rootNodes)r.parent=this.transformRoot;this.transformRoot.position=t,this.transformRoot.rotationQuaternion=i,this.transformRoot.scaling=o,this.canvasPanels=((a=this.contextService)==null?void 0:a.getAll())||new Map,De(this.materials.concat(this.variantManager.getAllMaterials()),this.scene,this.canvasPanels,this.dynamicTextures,`${this.id}_`),this.enablePicking&&this.attachPickingHandler(e),this.configureGlowLayer()}destroyInstance(){var e;(e=this.modelInstance)==null||e.dispose(),this.modelInstance=void 0}getAllMeshes(){var e;return(e=this.modelInstance)==null?void 0:e.rootNodes.map(t=>t.getChildMeshes(!1).filter(i=>i instanceof 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=$(this.modelInstance),this.configureModelInstance(this.modelInstance),this.animations=Y(this.modelInstance.animationGroups,this.renameClonedAsset("")),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 o=this.dynamicTextures.get(i);o&&t.getStaticContextDirty()&&o.isReady()&&(o.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.queuedModelAnimation&&(this.executeAnimation(this.queuedModelAnimation),this.queuedModelAnimation=void 0)}}class S extends y.ArcRotateCamera{constructor(e,t,i,o,a,r,n,l){super(e,t,i,o,a,r,l),this.lastFocus=new g.Vector3(0,0,0),this.panDenominator=1,this.minZ=.01,this.setRadius(this.radius),this.enableFramingBehavior(),this.wheelDeltaPercentage=.01,this.pinchDeltaPercentage=.005,this.useNaturalPinchZoom=!0,n.camera.autoOrientation&&(this.alpha+=Math.PI),n&&(n.camera.limits.min.beta&&(this.lowerBetaLimit=n.camera.limits.min.beta),n.camera.limits.max.beta&&(this.upperBetaLimit=n.camera.limits.max.beta),n.camera.limits.min.alpha&&(this.lowerAlphaLimit=n.camera.limits.min.alpha),n.camera.limits.max.alpha&&(this.upperAlphaLimit=n.camera.limits.max.alpha),n.camera.limits.min.radius&&(this.lowerRadiusLimit=n.camera.limits.min.radius),n.camera.limits.max.radius&&(this.upperRadiusLimit=n.camera.limits.max.radius),n.camera.autoRotation.enabled&&this.enableAutoRotationBehavior(n.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 o=()=>{e&&e()},a=F(this._scene),r=a.max.subtract(a.min),n=a.min.add(r.scale(.5));this.setRadius(r.length()*1.5),this.wheelPrecision=100/this.radius,this.panningInertia=0,this.panningOriginTarget.copyFrom(n),this.panDenominator=r.length(),i.zoomOnBoundingInfo(a.min,a.max,void 0,o),i.framingTime=0}enableAutoRotationBehavior(e=5e3){this.useAutoRotationBehavior=!0;const t=this.getAutoRotationBehavior();t&&(t.idleRotationWaitTime=e)}disableAutoRotationBehavior(){this.useAutoRotationBehavior=!1}setRadius(e){this.radius=e,this.maxZ=this.radius*1e3,this.lowerRadiusLimit=this.radius*.01,this.upperRadiusLimit=1.5*this.radius,this.wheelPrecision=100/this.radius,this.pinchPrecision=300/this.radius}static create(e,t,i){const o=F(e),a=o.max.subtract(o.min),r=o.min.add(a.scale(.5)),n=new S("ProductCamera",-(Math.PI/2),Math.PI/2,a.length()*1.5,r,e,t);return n.panningInertia=0,n.panningOriginTarget.copyFrom(r),n.panDenominator=a.length(),n.onAfterCheckInputsObservable.add(()=>{n.panningSensibility=1e3/n.panDenominator}),i&&(e.activeCamera=n),n}}function F(s){if(s.meshes.length===0)return{min:new g.Vector3(-1,-1,-1),max:new g.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(c))}dispose(){this.renderingPipeline.dispose()}getConfiguration(){return this.currentConfiguration}setConfiguration(e){var t,i,o,a,r,n,l,d,u,m,f,b,v,X,J,_,ee,te,ie,se,re,ne,ae,oe,le,he,ce,de,ue,ge,me,pe,fe;if(this.renderingPipeline.isSupported){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=((o=e.bloom)==null?void 0:o.enabled)??c.bloom.enabled,this.renderingPipeline.bloomKernel=((a=e.bloom)==null?void 0:a.kernel)??c.bloom.kernel,this.renderingPipeline.bloomScale=((r=e.bloom)==null?void 0:r.scale)??c.bloom.scale,this.renderingPipeline.bloomThreshold=((n=e.bloom)==null?void 0:n.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=((u=e.chromaticAberration)==null?void 0:u.aberrationAmount)??c.chromaticAberration.aberrationAmount,this.renderingPipeline.chromaticAberration.radialIntensity=((m=e.chromaticAberration)==null?void 0:m.radialIntensity)??c.chromaticAberration.radialIntensity,this.renderingPipeline.chromaticAberration.direction=(f=e.chromaticAberration)!=null&&f.direction?new g.Vector2(e.chromaticAberration.direction.x,e.chromaticAberration.direction.y):new g.Vector2(c.chromaticAberration.direction.x,c.chromaticAberration.direction.y),this.renderingPipeline.imageProcessing.colorCurvesEnabled=((b=e.colorCurves)==null?void 0:b.enabled)??c.colorCurves.enabled,this.renderingPipeline.imageProcessing.colorCurves=e.colorCurves?this.updateColorCurve(e.colorCurves):new k.ColorCurves,this.renderingPipeline.depthOfFieldEnabled=((v=e.depthOfField)==null?void 0:v.enabled)??c.depthOfField.enabled,e.depthOfField)switch(e.depthOfField.blurLevel??c.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=((X=e.depthOfField)==null?void 0:X.focalLength)??c.depthOfField.focalLength,this.renderingPipeline.depthOfField.fStop=((J=e.depthOfField)==null?void 0:J.fStop)??c.depthOfField.fStop,this.renderingPipeline.depthOfField.focusDistance=((_=e.depthOfField)==null?void 0:_.focusDistance)??c.depthOfField.focusDistance,this.renderingPipeline.depthOfField.lensSize=((ee=e.depthOfField)==null?void 0:ee.lensSize)??c.depthOfField.lensSize,this.renderingPipeline.grainEnabled=((te=e.grain)==null?void 0:te.enabled)??c.grain.enabled,this.renderingPipeline.grain.animated=((ie=e.grain)==null?void 0:ie.animated)??c.grain.animated,this.renderingPipeline.grain.intensity=((se=e.grain)==null?void 0:se.intensity)??c.grain.intensity,this.renderingPipeline.imageProcessing.contrast=((re=e.misc)==null?void 0:re.contrast)??c.misc.contrast,this.renderingPipeline.imageProcessing.exposure=((ne=e.misc)==null?void 0:ne.exposure)??c.misc.exposure,this.renderingPipeline.imageProcessing.toneMappingEnabled=((ae=e.misc)==null?void 0:ae.toneMappingEnabled)??c.misc.toneMappingEnabled,this.renderingPipeline.imageProcessing.toneMappingEnabled)switch(e.misc.toneMappingType??c.misc.toneMappingType){case"Standard":this.renderingPipeline.imageProcessing.toneMappingType=T.ImageProcessingConfiguration.TONEMAPPING_STANDARD;break;case"ACES":this.renderingPipeline.imageProcessing.toneMappingType=T.ImageProcessingConfiguration.TONEMAPPING_ACES;break}if(this.renderingPipeline.sharpenEnabled=((oe=e.sharpen)==null?void 0:oe.enabled)??c.sharpen.enabled,this.renderingPipeline.sharpen.colorAmount=((le=e.sharpen)==null?void 0:le.colorAmount)??c.sharpen.colorAmount,this.renderingPipeline.sharpen.edgeAmount=((he=e.sharpen)==null?void 0:he.edgeAmount)??c.sharpen.edgeAmount,this.renderingPipeline.imageProcessing.vignetteEnabled=((ce=e.vignette)==null?void 0:ce.enabled)??c.vignette.enabled,(de=e.vignette)!=null&&de.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)switch(((ue=e.vignette)==null?void 0:ue.blendMode)??c.vignette.blendMode){case"Multiply":this.renderingPipeline.imageProcessing.vignetteBlendMode=T.ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY;break;case"Opaque":this.renderingPipeline.imageProcessing.vignetteBlendMode=T.ImageProcessingConfiguration.VIGNETTEMODE_OPAQUE;break}(ge=e.vignette)!=null&&ge.colorRgba?this.renderingPipeline.imageProcessing.vignetteColor=new p.Color4(e.vignette.colorRgba.r,e.vignette.colorRgba.g,e.vignette.colorRgba.b,e.vignette.colorRgba.a):(me=e.vignette)!=null&&me.colorHex?this.renderingPipeline.imageProcessing.vignetteColor=p.Color4.FromHexString(e.vignette.colorHex):this.renderingPipeline.imageProcessing.vignetteColor=new p.Color4(c.vignette.colorRgba.r,c.vignette.colorRgba.g,c.vignette.colorRgba.b,c.vignette.colorRgba.a),this.renderingPipeline.imageProcessing.vignetteStretch=((pe=e.vignette)==null?void 0:pe.stretch)??c.vignette.stretch,this.renderingPipeline.imageProcessing.vignetteWeight=((fe=e.vignette)==null?void 0:fe.weight)??c.vignette.weight,this.renderingPipeline.prepare(),this.currentConfiguration=e}}updateColorCurve(e){const t=new k.ColorCurves;return t.globalDensity=e.globalDensity??t.globalDensity,t.globalExposure=e.globalExposure??t.globalExposure,t.globalHue=e.globalHue??t.globalHue,t.globalSaturation=e.globalSaturation??t.globalSaturation,t.highlightsDensity=e.highlightsDensity??t.highlightsDensity,t.highlightsExposure=e.highlightsExposure??t.highlightsExposure,t.highlightsHue=e.highlightsHue??t.highlightsHue,t.highlightsSaturation=e.highlightsSaturation??t.highlightsSaturation,t.midtonesDensity=e.midtonesDensity??t.midtonesDensity,t.midtonesExposure=e.midtonesExposure??t.midtonesExposure,t.midtonesHue=e.midtonesHue??t.midtonesHue,t.midtonesSaturation=e.midtonesSaturation??t.midtonesSaturation,t.shadowsDensity=e.shadowsDensity??t.shadowsDensity,t.shadowsExposure=e.shadowsExposure??t.shadowsExposure,t.shadowsHue=e.shadowsHue??t.shadowsHue,t.shadowsSaturation=e.shadowsSaturation??t.shadowsSaturation,t}}xe.GLTF2.GLTFLoader.RegisterExtension("glbPostProcessor",function(s){return new Be(s)}),q.SceneLoader.OnPluginActivatedObservable.add(s=>{if(s.name==="gltf"){const e=s;e.transparencyAsCoverage=!0}});function B(s){return new g.Vector3(s.x,s.y,s.z)}function j(s){return{x:s.x,y:s.y,z:s.z}}class Je{constructor(e){var n;this.focusLostNotified=!1,this.focusLostObservable=new M.Observable,this.modelLoadEventCallbacks=[],this.modelContainers=new Map,this.plugins=[],this.initComplete=!1,this.renderLoop=()=>{this.engine.views&&(this.modelContainers.forEach(l=>{l.updateDynamicTextures()}),this.configuration.scene.transparentBackground&&this.engine.views.forEach(l=>{const d=this.engine.getRenderingCanvas(),u=l.target.getContext("2d");if(!d)throw new Error("Could not access rendering canvas");if(!u)throw new Error("Could not access 2D context for view target");u.clearRect(0,0,d.width,d.height)}),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 Fe(e);const i=(()=>{if(!(e!=null&&e.noRender))return this.configuration.createCanvas()})(),o="1.5.6";Ce.DracoCompression.Configuration={decoder:{wasmUrl:`https://www.gstatic.com/draco/versioned/decoders/${o}/draco_wasm_wrapper_gltf.js`,wasmBinaryUrl:`https://www.gstatic.com/draco/versioned/decoders/${o}/draco_decoder_gltf.wasm`,fallbackUrl:`https://www.gstatic.com/draco/versioned/decoders/${o}/draco_decoder_gltf.js`}},i&&(i.getContext("webgl2")||i.getContext("webgl"));const a=console.log;console.log=()=>{};const r=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 be.NullEngine;console.log=a,r.hideLoadingUI(),window.addEventListener("resize",this.fireResizeEvent.bind(this)),this.engine=r,this.scene=new Me.Scene(r),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,this.scene.environmentTexture=we.CubeTexture.CreateFromPrefilteredData(this.configuration.scene.environmentFile,this.scene),(n=this.configuration.options)!=null&&n.renderingPipelineConfiguration&&this.renderingPipeline.setConfiguration(this.configuration.options.renderingPipelineConfiguration),this.glowLayerManager=new je(this.scene,this.configuration.emissiveGlowIntensity),this.initPromise=new Promise(l=>{this.scene.onReadyObservable.addOnce(()=>{this.initComplete=!0,l()})}),this.engine.runRenderLoop(this.renderLoop)}getInitializationPromise(){return this.initPromise}getInitializationComplete(){return this.initComplete}getEngineContext(){return{engine:this.engine,scene:this.scene,camera:this.camera}}registerFocusLostListener(e){this.focusLostObservable.add(e)}unregisterFocusLostListener(e){this.focusLostObservable.removeCallback(e)}registerModelLoadEventListener(e){this.modelLoadEventCallbacks.push(e)}unregisterModelLoadEventListener(e){const t=this.modelLoadEventCallbacks.indexOf(e);t>-1&&this.modelLoadEventCallbacks.splice(t,1)}registerView(e){const t=e.height,i=e.width;this.engine.registerView(e),e.setAttribute("height",t.toString()),e.setAttribute("width",i.toString()),this.orbitEnabled()||this.setCameraState(R.Pan),this.reattachControls(e)}getNumViewports(){var e;return((e=this.engine.views)==null?void 0:e.length)||0}unregisterView(e){this.engine.unRegisterView(e)}shutdown(){this.plugins.forEach(e=>e.dispose(!0)),this.renderingPipeline.dispose(),this.engine&&this.engine.dispose(),window.removeEventListener("resize",this.fireResizeEvent)}executeCameraAnimation(e){if(!this.camera||this.scene.activeCamera!==this.camera){this.queuedCameraAnimation=e;return}ze(this.scene,this.scene.activeCamera,e)}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 g.Vector3(e.target.x,e.target.y,e.target.z),this.camera.radius=e.radius,this.camera.alpha=e.latDeg,this.camera.beta=e.lonDeg)}setCameraState(e){var t,i;if(!((t=this.engine)!=null&&t.views)||!((i=this.engine)!=null&&i.views[0]))throw new Error("No views attached, camera state requires a view to attach controls onto.");e===R.Orbit?this.reattachControls(this.engine.views[0].target,2):this.reattachControls(this.engine.views[0].target,0)}animateToLastCameraFocus(){return new Promise(e=>{const t=()=>{const i=this.configuration;this.camera.rerunFramingBehavior(()=>{this.focusLostNotified=!1,i.camera.limits.min.radius&&(this.camera.lowerRadiusLimit=i.camera.limits.min.radius),i.camera.limits.max.radius&&(this.camera.upperRadiusLimit=i.camera.limits.max.radius),e()})};this.scene.onAfterRenderObservable.addOnce(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 y.ArcRotateCamera("screenshotCamera",0,0,0,g.Vector3.Zero(),this.scene);try{const o=t.latDeg*Math.PI/180,a=t.lonDeg*Math.PI/180;i.target=t.target?new g.Vector3(t.target.x,t.target.y,t.target.z):g.Vector3.Zero(),i.alpha=a,i.beta=o,i.radius=t.radius||this.camera.radius,i.minZ=.01,this.scene.render();const r=await ve.Tools.CreateScreenshotUsingRenderTargetAsync(this.engine,i,e,"image/png",2,!0);return i.dispose(),r}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,o=e.camera.limits.min.beta,a=e.camera.limits.max.beta;if(t===void 0||i===void 0||o===void 0||a===void 0)return!0;const r=[t,i],n=[o,a],l=r.every(u=>u===t),d=n.every(u=>u===o);return!l&&!d}fireResizeEvent(){this.getNumViewports()>0&&this.engine.resize()}setHighlights(e,t){var o;e.length===0&&((o=this.highlightLayer)==null||o.dispose(),this.highlightLayer=void 0),this.highlightLayer||(this.highlightLayer=new ye.HighlightLayer("highlights",this.scene,{isStroke:!0,blurVerticalSize:.85,blurHorizontalSize:.85}),this.highlightLayer.innerGlow=!0,this.highlightLayer.outerGlow=!1),this.highlightLayer.removeAllMeshes();const i=t?new p.Color3(t[0],t[1],t[2]).toLinearSpace():void 0;e.forEach(a=>{const r=this.scene.materials.find(n=>n.name===a.name&&n.id===a.id);r&&r.getBindedMeshes().forEach(n=>{var l;return(l=this.highlightLayer)==null?void 0:l.addMesh(n,i||p.Color3.FromHexString("#fcba03"))})})}setRenderingPipelineConfiguration(e){this.renderingPipeline&&this.renderingPipeline.setConfiguration(e)}loadModel(e,t){const i=new Ye({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(void 0,1),ke(this.scene),this.queuedCameraAnimation&&(this.executeCameraAnimation(this.queuedCameraAnimation),this.queuedCameraAnimation=void 0)}),this.configuration.highlights.enabled&&(i.registerMaterialSelectedCallback(o=>{this.setHighlights([o])}),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(o=>o.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 o=g.Matrix.Compose(B(i||{x:1,y:1,z:1}),g.Quaternion.FromEulerVector(B(t||{x:0,y:0,z:0})),B(e||{x:0,y:0,z:0})),a=g.Matrix.RotationAxis(g.Vector3.Up(),Math.PI),r=o.multiply(a),n=g.Vector3.Zero(),l=g.Quaternion.Identity(),d=g.Vector3.Zero();return r.decompose(d,l,n),l.multiplyInPlace(g.Quaternion.FromEulerAngles(0,Math.PI,0)),{position:j(n),rotation:j(l.toEulerAngles()),scale:j(d)}}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)}}h.MaterialEffectMode=E,h.ProductCameraRig=R,h.REFLECTION_PROBE_RESOLUTION=z,h.RenderingConfiguration=C,h.SpiffCommerce3DPreviewService=Je,h.renderingPipelineDefaults=c,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
1
+ (function(h,y){typeof exports=="object"&&typeof module<"u"?y(exports,require("@babylonjs/core/Cameras/arcRotateCamera"),require("@babylonjs/core/Engines/engine"),require("@babylonjs/core/Engines/nullEngine"),require("@babylonjs/core/Layers/highlightLayer"),require("@babylonjs/core/Loading/sceneLoader"),require("@babylonjs/core/Materials/Textures/cubeTexture"),require("@babylonjs/core/Maths/math.color"),require("@babylonjs/core/Maths/math.vector"),require("@babylonjs/core/Meshes/Compression/dracoCompression"),require("@babylonjs/core/Misc/observable"),require("@babylonjs/core/Misc/tools"),require("@babylonjs/core/scene"),require("@babylonjs/loaders/glTF"),require("@babylonjs/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"],y):(h=typeof globalThis<"u"?globalThis:h||self,y(h.Preview={},h.arcRotateCamera,h.engine,h.nullEngine,h.highlightLayer,h.sceneLoader,h.cubeTexture,h.math_color,h.math_vector,h.dracoCompression,h.observable,h.tools,h.scene,h.glTF,h.pbrMaterial,h.mirrorTexture,h.math,h.reflectionProbe,h.glowLayer,h.actionManager,h.directActions,h.mesh,h.transformNode,h.dynamicTexture,h.texture,h.animation,h.easing,h.assetsManager,h.colorCurves,h.imageProcessingConfiguration,h.RenderPipeline,h.depthOfFieldEffect))})(this,function(h,y,D,be,ye,q,we,p,g,Ce,M,ve,Me,xe,L,Pe,P,Te,Re,O,V,Ee,Ae,Le,Oe,w,N,Ie,k,T,Se,I){"use strict";var R=(s=>(s[s.Orbit=0]="Orbit",s[s.Pan=1]="Pan",s))(R||{}),E=(s=>(s.None="None",s.RemoveWhenSelected="RemoveWhenSelected",s.ApplyWhenSelected="ApplyWhenSelected",s))(E||{});class Fe{constructor(e){this.getSceneClearColor=()=>{var i,o,a,n;const t=(i=this.customOptions)!=null&&i.transparentBackground||(o=this.customOptions)!=null&&o.backgroundImage?0:1;if(this.customOptions&&((a=this.customOptions)!=null&&a.transparentBackground)||(n=this.customOptions)!=null&&n.backgroundImage)return new p.Color4(0,0,0,t).toLinearSpace();if(this.customOptions&&this.customOptions.backgroundColor){const r=p.Color3.FromHexString(this.customOptions.backgroundColor);return new p.Color4(r.r,r.g,r.b,t).toLinearSpace()}return new p.Color4(.98,.98,.98,t).toLinearSpace()},this.highlightColorFromConfig=()=>this.customOptions&&this.customOptions.highlightColor?this.hexToColor4(this.customOptions.highlightColor):new p.Color4(.98,.98,.98,1).toLinearSpace(),this.hexToColor4=(t,i=1)=>{const o=p.Color3.FromHexString(t);return new p.Color4(o.r,o.g,o.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,o,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:((o=this.customOptions)==null?void 0:o.environmentIntensity)??1,rotationY:(((a=this.customOptions)==null?void 0:a.environmentRotationY)??0)*(Math.PI/180)}}}get camera(){var e,t,i,o,a,n,r,l,d,u,m,f,b;return{autoOrientation:((e=this.customOptions)==null?void 0:e.disableAutomaticOrientation)??!0,autoRotation:{enabled:((t=this.customOptions)==null?void 0:t.autoRotation)??!1,idleTimeMs:((i=this.customOptions)==null?void 0:i.idleTimeBeforeRotation)??5e3},limits:{min:{alpha:(o=this.customOptions)!=null&&o.lowerAlphaLimitDeg?((a=this.customOptions)==null?void 0:a.lowerAlphaLimitDeg)*Math.PI/180:void 0,beta:(n=this.customOptions)!=null&&n.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:(d=this.customOptions)!=null&&d.upperAlphaLimitDeg?((u=this.customOptions)==null?void 0:u.upperAlphaLimitDeg)*Math.PI/180:void 0,beta:(m=this.customOptions)!=null&&m.upperBetaLimitDeg?((f=this.customOptions)==null?void 0:f.upperBetaLimitDeg)*Math.PI/180:void 0,radius:(b=this.customOptions)==null?void 0:b.maxZoomOverride}}}}get highlights(){var e;return{enabled:((e=this.customOptions)==null?void 0:e.highlightOnMaterialHover)??!1,color:this.highlightColorFromConfig()}}get lighting(){var e,t,i,o;return{exposure:((t=(e=this.customOptions)==null?void 0:e.lighting)==null?void 0:t.exposure)??.9,contrast:((o=(i=this.customOptions)==null?void 0:i.lighting)==null?void 0:o.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<=480}catch{return!1}}}const z=128,c={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(o){t.extras&&Object.keys(t.extras).forEach(a=>{const n=t.extras[a];o.metadata[a]=n}),i(o)})}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 n=[];return a.transformNodes.forEach(r=>{r.metadata&&r.metadata.reflective&&n.push(...r.getChildMeshes())}),a.meshes.forEach(r=>{r.metadata&&r.metadata.reflective&&!n.includes(r)&&n.push(r)}),n}function i(a,n=1){const r=a.material;if(!r)return;const l=new Pe.MirrorTexture("mirror",C.getMirrorTextureResolution(),e,!0);l.renderList=t(e);const d=a.getVerticesData("normal");if(!d)throw new Error("Mirror attribute specified on: "+a.name+"But no normals exist to generate a mirror from!");a.computeWorldMatrix(!0);const u=a.getWorldMatrix(),m=P.Vector3.TransformNormal(new P.Vector3(d[0],d[1],d[2]),u).normalize(),f=P.Plane.FromPositionAndNormal(a.position,m.scale(-1));l.mirrorPlane=f,l.level=n,r.reflectionTexture=l}function o(a){const n=a.material,r=new Te.ReflectionProbe("probe-"+n.name,z,e);r.attachToMesh(a),r.renderList&&r.renderList.push(...t(e)),n.reflectionTexture=r.cubeTexture}e.meshes.forEach(a=>{const n=a.metadata;n&&(n.mirrorTexture&&i(a,n.mirrorTexture),n.reflectionProbe&&o(a))})}}class je{constructor(e,t){this.scene=e,this.intensity=t,this.meshCount=0}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 G=new Map;async function H(s,e,t){const i=G.get(s);if(i&&i.scene.uid===e.uid)return i;{const o=await q.SceneLoader.LoadAssetContainerAsync(s,void 0,e,t);return G.set(s,o),o}}function De(s,e,t,i,o=""){t.forEach(a=>{const n=a.getID(),r=a.getName(),l=C.getDynamicTextureResolution();s.filter(u=>u.name===o+r).forEach(u=>{const m=i.get(n),f=!1;if(m)K(u,m),m.update(f);else{const b=qe(r,e,l.width,l.height);i.set(n,b),a.setStaticContext(b.getContext()),K(u,b),b.onLoadObservable.addOnce(()=>{b.update(f)})}})})}function qe(s,e,t,i){const o=new Le.DynamicTexture(s,{width:t,height:i},e,C.shouldMipMap(),Oe.Texture.TRILINEAR_SAMPLINGMODE,D.Engine.TEXTUREFORMAT_RGBA),a=o.getContext();return a&&(a.fillStyle="#f5f5f5",a.fillRect(0,0,t,i),o.update()),o}function K(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,U=1;function Q(s){return s.targetedAnimations.map(t=>t.animation.framePerSecond).reduce((t,i)=>t+i,0)/s.targetedAnimations.length||0}function Ne(s,e,t,i,o){const a=o?s.filter(n=>n.name===o):s;if(a.length===0){console.warn(`No animations found for name: ${o}`);return}if(i!==void 0&&t!==void 0&&i===t){a.forEach(n=>{n.stop();const r=Q(n),l=i*r;n.start(e,U,l,l)});return}a.forEach(n=>{n.stop();const r=Q(n),l=i!==void 0?i*r:void 0,d=t!==void 0?t*r:void 0;n.start(e,U,l,d)})}function W(s){s.forEach(e=>{e.stop()})}function ke(s){const e=s.animationGroups;W(e)}function ze(s,e,t){s.stopAnimation(e),e.animations=[],Math.abs(e.alpha)>2*Math.PI&&(e.alpha=Ge(e.alpha,0,2*Math.PI));const i=[],o=t.target,a=0,n=o?1:0;if(t.target&&Object.keys(t.target).length>0&&i.push(A("cameraTargetLerp","target",new g.Vector3().copyFrom(e.target),new g.Vector3(t.target.x,t.target.y,t.target.z),w.Animation.ANIMATIONTYPE_VECTOR3,a)),i.push(A("cameraAlphaLerp","alpha",e.alpha,Y(t.lonDeg),w.Animation.ANIMATIONTYPE_FLOAT,n)),i.push(A("cameraBetaLerp","beta",e.beta,Y(t.latDeg),w.Animation.ANIMATIONTYPE_FLOAT,n)),t.radius!==void 0){const d=Math.max(.01,t.radius);i.push(A("cameraRadiusLerp","radius",e.radius,d,w.Animation.ANIMATIONTYPE_FLOAT,n))}e.animations.push(...i);const l=e.useAutoRotationBehavior;e.disableAutoRotationBehavior(),s.beginAnimation(e,0,o?x*2:x,!1,1,()=>{e.animations=[],l&&e.enableAutoRotationBehavior()})}function Y(s){return s*Math.PI/180}function A(s,e,t,i,o,a=0,n=w.Animation.ANIMATIONLOOPMODE_CONSTANT){const r=new N.QuadraticEase;r.setEasingMode(N.EasingFunction.EASINGMODE_EASEINOUT);const l=new w.Animation(s,e,x,o,n),d=[];return a>0&&d.push({frame:0,value:t}),d.push({frame:x*a,value:t}),d.push({frame:x*(a+1),value:i}),l.setKeys(d),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"};function Ke(s,e,t,i){["albedoTexture","bumpTexture","ambientTexture","emissiveTexture","opacityTexture","metallicTexture","refractionTexture"].forEach(a=>{Ue(a,s,e,t,i)}),Ye(s,e)}function Ue(s,e,t,i,o){const a=He[s];if(!a)throw new Error("Unexpected texture name encountered.");const n=e[a],r=n==null?void 0:n.fileLink;r?i.addTextureTask(s,r,!1,!1):o&&t[s]&&(t[s]&&t[s].dispose(),t[s]=null,Qe(s,t))}function Qe(s,e){s==="opacityTexture"&&(e.useAlphaFromAlbedoTexture=!0),s==="metallicTexture"&&(e.useRoughnessFromMetallicTextureAlpha=!1,e.useRoughnessFromMetallicTextureGreen=!1,e.useMetallnessFromMetallicTextureBlue=!1),s==="refractionTexture"&&(e.subSurface.isRefractionEnabled=!1,e.subSurface.refractionIntensity=1),s==="emissiveTexture"&&(e.emissiveIntensity=0,e.emissiveColor=new p.Color3(0,0,0))}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),e[s]=i,s==="emissiveTexture"&&(e.emissiveColor=new p.Color3(1,1,1),e.emissiveIntensity=1)}function Ye(s,e){s.clearCoat&&(s.clearCoat===E.RemoveWhenSelected?(e.clearCoat.isEnabled=!1,e.clearCoat.indexOfRefraction=1.5):s.clearCoat===E.ApplyWhenSelected&&(e.clearCoat.isEnabled=!0,e.clearCoat.indexOfRefraction=s.clearCoatIOR||e.clearCoat.indexOfRefraction))}class Ze{constructor(e,t,i){this.materialVariantMap=new Map,this.keysThatRemovedBaseModel=[],this.loadedContainerForKey=new Map,this.loadedMaterialsForKey=new Map,this.scene=e,this.renameClonedAsset=t,this.setBaseModelEnabled=i}async applyMaterial(e,t,i,o){return new Promise(a=>{const n=this.materialVariantMap.get(e);this.materialVariantMap.set(e,{...n,...t});const r=this.renameClonedAsset(e),l=this.scene.materials.filter(u=>u.name===r);if(l.length===0){a();return}const d=new Ie.AssetsManager(this.scene);d.useDefaultLoadingScreen=!1,l.forEach(u=>Ke(t,u,d,o)),d.onProgress=(u,m,f)=>{i&&i(u/m*100,100,f.name)},d.onFinish=u=>{u.forEach(m=>{const f=m;i&&i(100,100,m.name),this.scene.materials.filter(v=>v.name===r).forEach(v=>We(m.name,v,t,f.texture))}),a()},d.loadAsync()})}async applyModel(e,t,i,o){var l,d;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(u=>u!==e),Promise.resolve(void 0);const n=(await H(i,this.scene,o)).instantiateModelsToScene(this.renameClonedAsset,!0);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,n),this.loadedMaterialsForKey.set(e,Z(n));const r=[];return this.materialVariantMap.forEach(async(u,m)=>{r.push(this.applyMaterial(m,u))}),await Promise.all(r),n}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 Z(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(o=>{const a=o.getMaterial(!1);a&&!e.includes(a)&&e.push(a)})})}),e}function $(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.animations=[],this.initialized=!1,this.materials=[];const{enablePicking:t,modelDetails:i,previewService:o,progressHandler:a,scene:n}=e;this.enablePicking=t,this.contextService=i.contextService,this.id=Ve(),this.previewService=o,this.scene=n,this.variantManager=new Ze(n,this.renameClonedAsset.bind(this),this.setBaseModelEnabled.bind(this)),this.transformRoot=new Ae.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 H(i.model,n,a),this.initialized=!0,await this.instantiate(),this};this.importPromise=r()}async applyMaterialVariant(e,t,i,o){if(!this.initialized){if(this.materialReadyToLoadCallbacks.has(e)){const n=this.materialReadyToLoadCallbacks.get(e);n==null||n.set(t,this.applyMaterialVariant.bind(this,e,t,i,o))}else{this.materialReadyToLoadCallbacks.set(e,new Map);const n=this.materialReadyToLoadCallbacks.get(e);n==null||n.set(t,this.applyMaterialVariant.bind(this,e,t,i,o))}return}const a=async()=>{await this.variantManager.applyMaterial(e,i,(n,r,l)=>{this.materialVariantObservable.notifyObservers({remainingCount:n,totalCount:r,taskName:l})},o)};if(this.materialChangesInProgress.includes(e)){if(this.queuedMaterialChanges.has(e)){const n=this.queuedMaterialChanges.get(e);n==null||n.set(t,a)}else{this.queuedMaterialChanges.set(e,new Map);const n=this.queuedMaterialChanges.get(e);n==null||n.set(t,a)}return}if(this.materialChangesInProgress.push(e),await a(),this.queuedMaterialChanges.has(e)){const n=this.queuedMaterialChanges.get(e);if(!n)throw new Error("Target material is undefined");n.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 o=()=>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,o);return}const n=await(async()=>{this.modelChangesInProgress.push(e);let r=await o();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&&W(this.modelInstance.animationGroups),this.contextService||(this.contextService=t==null?void 0:t.contextService),n?this.configureModelInstance(n):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.previewService.getInitializationComplete()){this.queuedModelAnimation=e;return}this.modelInstance&&Ne([...this.modelInstance.animationGroups,...this.variantManager.getAnimationGroups()],e.loop,e.to,e.from,e.name?this.renameClonedAsset(e.name):void 0)}getAnimations(e){return[...this.animations,...e?$(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 g.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=g.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 g.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 V.ExecuteCodeAction(O.ActionManager.OnPointerOverTrigger,o=>{o.meshUnderPointer&&i.material&&this.materialSelectedObservable.notifyObservers({id:i.material.id,name:this.stripIdFromName(i.material.name)})})),i.actionManager.registerAction(new V.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,o=this.transformRoot.scaling;this.transformRoot.position=g.Vector3.Zero(),this.transformRoot.rotationQuaternion=g.Quaternion.Identity(),this.transformRoot.scaling=g.Vector3.One();for(const n of e.rootNodes)n.parent=this.transformRoot;this.transformRoot.position=t,this.transformRoot.rotationQuaternion=i,this.transformRoot.scaling=o,this.canvasPanels=((a=this.contextService)==null?void 0:a.getAll())||new Map,De(this.materials.concat(this.variantManager.getAllMaterials()),this.scene,this.canvasPanels,this.dynamicTextures,`${this.id}_`),this.enablePicking&&this.attachPickingHandler(e),this.configureGlowLayer()}destroyInstance(){var e;(e=this.modelInstance)==null||e.dispose(),this.modelInstance=void 0}getAllMeshes(){var e;return(e=this.modelInstance)==null?void 0:e.rootNodes.map(t=>t.getChildMeshes(!1).filter(i=>i instanceof 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=Z(this.modelInstance),this.configureModelInstance(this.modelInstance),this.animations=$(this.modelInstance.animationGroups,this.renameClonedAsset("")),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 o=this.dynamicTextures.get(i);o&&t.getStaticContextDirty()&&o.isReady()&&(o.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.queuedModelAnimation&&(this.executeAnimation(this.queuedModelAnimation),this.queuedModelAnimation=void 0)}}class S extends y.ArcRotateCamera{constructor(e,t,i,o,a,n,r,l){super(e,t,i,o,a,n,l),this.lastFocus=new g.Vector3(0,0,0),this.panDenominator=1,this.minZ=.01,this.setRadius(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 o=()=>{e&&e()},a=F(this._scene),n=a.max.subtract(a.min),r=a.min.add(n.scale(.5));this.setRadius(n.length()*1.5),this.wheelPrecision=100/this.radius,this.panningInertia=0,this.panningOriginTarget.copyFrom(r),this.panDenominator=n.length(),i.zoomOnBoundingInfo(a.min,a.max,void 0,o),i.framingTime=0}enableAutoRotationBehavior(e=5e3){this.useAutoRotationBehavior=!0;const t=this.getAutoRotationBehavior();t&&(t.idleRotationWaitTime=e)}disableAutoRotationBehavior(){this.useAutoRotationBehavior=!1}setRadius(e){this.radius=e,this.maxZ=this.radius*1e3,this.lowerRadiusLimit=this.radius*.01,this.upperRadiusLimit=1.5*this.radius,this.wheelPrecision=100/this.radius,this.pinchPrecision=300/this.radius}static create(e,t,i){const o=F(e),a=o.max.subtract(o.min),n=o.min.add(a.scale(.5)),r=new S("ProductCamera",-(Math.PI/2),Math.PI/2,a.length()*1.5,n,e,t);return r.panningInertia=0,r.panningOriginTarget.copyFrom(n),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 g.Vector3(-1,-1,-1),max:new g.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(c))}dispose(){this.renderingPipeline.dispose()}getConfiguration(){return this.currentConfiguration}setConfiguration(e){var t,i,o,a,n,r,l,d,u,m,f,b,v,X,J,_,ee,te,ie,se,ne,re,ae,oe,le,he,ce,de,ue,ge,me,pe,fe;if(this.renderingPipeline.isSupported){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=((o=e.bloom)==null?void 0:o.enabled)??c.bloom.enabled,this.renderingPipeline.bloomKernel=((a=e.bloom)==null?void 0:a.kernel)??c.bloom.kernel,this.renderingPipeline.bloomScale=((n=e.bloom)==null?void 0:n.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=((u=e.chromaticAberration)==null?void 0:u.aberrationAmount)??c.chromaticAberration.aberrationAmount,this.renderingPipeline.chromaticAberration.radialIntensity=((m=e.chromaticAberration)==null?void 0:m.radialIntensity)??c.chromaticAberration.radialIntensity,this.renderingPipeline.chromaticAberration.direction=(f=e.chromaticAberration)!=null&&f.direction?new g.Vector2(e.chromaticAberration.direction.x,e.chromaticAberration.direction.y):new g.Vector2(c.chromaticAberration.direction.x,c.chromaticAberration.direction.y),this.renderingPipeline.imageProcessing.colorCurvesEnabled=((b=e.colorCurves)==null?void 0:b.enabled)??c.colorCurves.enabled,this.renderingPipeline.imageProcessing.colorCurves=e.colorCurves?this.updateColorCurve(e.colorCurves):new k.ColorCurves,this.renderingPipeline.depthOfFieldEnabled=((v=e.depthOfField)==null?void 0:v.enabled)??c.depthOfField.enabled,e.depthOfField)switch(e.depthOfField.blurLevel??c.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=((X=e.depthOfField)==null?void 0:X.focalLength)??c.depthOfField.focalLength,this.renderingPipeline.depthOfField.fStop=((J=e.depthOfField)==null?void 0:J.fStop)??c.depthOfField.fStop,this.renderingPipeline.depthOfField.focusDistance=((_=e.depthOfField)==null?void 0:_.focusDistance)??c.depthOfField.focusDistance,this.renderingPipeline.depthOfField.lensSize=((ee=e.depthOfField)==null?void 0:ee.lensSize)??c.depthOfField.lensSize,this.renderingPipeline.grainEnabled=((te=e.grain)==null?void 0:te.enabled)??c.grain.enabled,this.renderingPipeline.grain.animated=((ie=e.grain)==null?void 0:ie.animated)??c.grain.animated,this.renderingPipeline.grain.intensity=((se=e.grain)==null?void 0:se.intensity)??c.grain.intensity,this.renderingPipeline.imageProcessing.contrast=((ne=e.misc)==null?void 0:ne.contrast)??c.misc.contrast,this.renderingPipeline.imageProcessing.exposure=((re=e.misc)==null?void 0:re.exposure)??c.misc.exposure,this.renderingPipeline.imageProcessing.toneMappingEnabled=((ae=e.misc)==null?void 0:ae.toneMappingEnabled)??c.misc.toneMappingEnabled,this.renderingPipeline.imageProcessing.toneMappingEnabled)switch(e.misc.toneMappingType??c.misc.toneMappingType){case"Standard":this.renderingPipeline.imageProcessing.toneMappingType=T.ImageProcessingConfiguration.TONEMAPPING_STANDARD;break;case"ACES":this.renderingPipeline.imageProcessing.toneMappingType=T.ImageProcessingConfiguration.TONEMAPPING_ACES;break}if(this.renderingPipeline.sharpenEnabled=((oe=e.sharpen)==null?void 0:oe.enabled)??c.sharpen.enabled,this.renderingPipeline.sharpen.colorAmount=((le=e.sharpen)==null?void 0:le.colorAmount)??c.sharpen.colorAmount,this.renderingPipeline.sharpen.edgeAmount=((he=e.sharpen)==null?void 0:he.edgeAmount)??c.sharpen.edgeAmount,this.renderingPipeline.imageProcessing.vignetteEnabled=((ce=e.vignette)==null?void 0:ce.enabled)??c.vignette.enabled,(de=e.vignette)!=null&&de.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)switch(((ue=e.vignette)==null?void 0:ue.blendMode)??c.vignette.blendMode){case"Multiply":this.renderingPipeline.imageProcessing.vignetteBlendMode=T.ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY;break;case"Opaque":this.renderingPipeline.imageProcessing.vignetteBlendMode=T.ImageProcessingConfiguration.VIGNETTEMODE_OPAQUE;break}(ge=e.vignette)!=null&&ge.colorRgba?this.renderingPipeline.imageProcessing.vignetteColor=new p.Color4(e.vignette.colorRgba.r,e.vignette.colorRgba.g,e.vignette.colorRgba.b,e.vignette.colorRgba.a):(me=e.vignette)!=null&&me.colorHex?this.renderingPipeline.imageProcessing.vignetteColor=p.Color4.FromHexString(e.vignette.colorHex):this.renderingPipeline.imageProcessing.vignetteColor=new p.Color4(c.vignette.colorRgba.r,c.vignette.colorRgba.g,c.vignette.colorRgba.b,c.vignette.colorRgba.a),this.renderingPipeline.imageProcessing.vignetteStretch=((pe=e.vignette)==null?void 0:pe.stretch)??c.vignette.stretch,this.renderingPipeline.imageProcessing.vignetteWeight=((fe=e.vignette)==null?void 0:fe.weight)??c.vignette.weight,this.renderingPipeline.prepare(),this.currentConfiguration=e}}updateColorCurve(e){const t=new k.ColorCurves;return t.globalDensity=e.globalDensity??t.globalDensity,t.globalExposure=e.globalExposure??t.globalExposure,t.globalHue=e.globalHue??t.globalHue,t.globalSaturation=e.globalSaturation??t.globalSaturation,t.highlightsDensity=e.highlightsDensity??t.highlightsDensity,t.highlightsExposure=e.highlightsExposure??t.highlightsExposure,t.highlightsHue=e.highlightsHue??t.highlightsHue,t.highlightsSaturation=e.highlightsSaturation??t.highlightsSaturation,t.midtonesDensity=e.midtonesDensity??t.midtonesDensity,t.midtonesExposure=e.midtonesExposure??t.midtonesExposure,t.midtonesHue=e.midtonesHue??t.midtonesHue,t.midtonesSaturation=e.midtonesSaturation??t.midtonesSaturation,t.shadowsDensity=e.shadowsDensity??t.shadowsDensity,t.shadowsExposure=e.shadowsExposure??t.shadowsExposure,t.shadowsHue=e.shadowsHue??t.shadowsHue,t.shadowsSaturation=e.shadowsSaturation??t.shadowsSaturation,t}}xe.GLTF2.GLTFLoader.RegisterExtension("glbPostProcessor",function(s){return new Be(s)}),q.SceneLoader.OnPluginActivatedObservable.add(s=>{if(s.name==="gltf"){const e=s;e.transparencyAsCoverage=!0}});function B(s){return new g.Vector3(s.x,s.y,s.z)}function j(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.renderLoop=()=>{this.engine.views&&(this.modelContainers.forEach(d=>{d.updateDynamicTextures()}),this.configuration.scene.transparentBackground&&this.engine.views.forEach(d=>{const u=this.engine.getRenderingCanvas(),m=d.target.getContext("2d");if(!u)throw new Error("Could not access rendering canvas");if(!m)throw new Error("Could not access 2D context for view target");m.clearRect(0,0,u.width,u.height)}),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 Fe(e);const i=(()=>{if(!(e!=null&&e.noRender))return this.configuration.createCanvas()})(),o="1.5.6";Ce.DracoCompression.Configuration={decoder:{wasmUrl:`https://www.gstatic.com/draco/versioned/decoders/${o}/draco_wasm_wrapper_gltf.js`,wasmBinaryUrl:`https://www.gstatic.com/draco/versioned/decoders/${o}/draco_decoder_gltf.wasm`,fallbackUrl:`https://www.gstatic.com/draco/versioned/decoders/${o}/draco_decoder_gltf.js`}},i&&(i.getContext("webgl2")||i.getContext("webgl"));const a=console.log;console.log=()=>{};const n=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 be.NullEngine;console.log=a,n.hideLoadingUI(),window.addEventListener("resize",this.fireResizeEvent.bind(this)),this.engine=n,this.scene=new Me.Scene(n),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=we.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(d=>{this.scene.onReadyObservable.addOnce(()=>{this.initComplete=!0,d()})}),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),e.setAttribute("height",t.toString()),e.setAttribute("width",i.toString()),this.orbitEnabled()||this.setCameraState(R.Pan),this.reattachControls(e)}getNumViewports(){var e;return((e=this.engine.views)==null?void 0:e.length)||0}unregisterView(e){this.engine.unRegisterView(e)}shutdown(){this.plugins.forEach(e=>e.dispose(!0)),this.renderingPipeline.dispose(),this.engine&&this.engine.dispose(),window.removeEventListener("resize",this.fireResizeEvent)}executeCameraAnimation(e){if(!this.camera||this.scene.activeCamera!==this.camera){this.queuedCameraAnimation=e;return}ze(this.scene,this.scene.activeCamera,e)}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 g.Vector3(e.target.x,e.target.y,e.target.z),this.camera.radius=e.radius,this.camera.alpha=e.latDeg,this.camera.beta=e.lonDeg)}setCameraState(e){var t,i;if(!((t=this.engine)!=null&&t.views)||!((i=this.engine)!=null&&i.views[0]))throw new Error("No views attached, camera state requires a view to attach controls onto.");e===R.Orbit?this.reattachControls(this.engine.views[0].target,2):this.reattachControls(this.engine.views[0].target,0)}animateToLastCameraFocus(){return new Promise(e=>{const t=()=>{const i=this.configuration;this.camera.rerunFramingBehavior(()=>{this.focusLostNotified=!1,i.camera.limits.min.radius&&(this.camera.lowerRadiusLimit=i.camera.limits.min.radius),i.camera.limits.max.radius&&(this.camera.upperRadiusLimit=i.camera.limits.max.radius),e()})};this.scene.onAfterRenderObservable.addOnce(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 y.ArcRotateCamera("screenshotCamera",0,0,0,g.Vector3.Zero(),this.scene);try{const o=t.latDeg*Math.PI/180,a=t.lonDeg*Math.PI/180;i.target=t.target?new g.Vector3(t.target.x,t.target.y,t.target.z):g.Vector3.Zero(),i.alpha=a,i.beta=o,i.radius=t.radius||this.camera.radius,i.minZ=.01,this.scene.render();const n=await ve.Tools.CreateScreenshotUsingRenderTargetAsync(this.engine,i,e,"image/png",2,!0);return i.dispose(),n}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,o=e.camera.limits.min.beta,a=e.camera.limits.max.beta;if(t===void 0||i===void 0||o===void 0||a===void 0)return!0;const n=[t,i],r=[o,a],l=n.every(u=>u===t),d=r.every(u=>u===o);return!l&&!d}fireResizeEvent(){this.getNumViewports()>0&&this.engine.resize()}setHighlights(e,t){var o;e.length===0&&((o=this.highlightLayer)==null||o.dispose(),this.highlightLayer=void 0),this.highlightLayer||(this.highlightLayer=new ye.HighlightLayer("highlights",this.scene,{isStroke:!0,blurVerticalSize:.85,blurHorizontalSize:.85}),this.highlightLayer.innerGlow=!0,this.highlightLayer.outerGlow=!1),this.highlightLayer.removeAllMeshes();const i=t?new p.Color3(t[0],t[1],t[2]).toLinearSpace():void 0;e.forEach(a=>{const n=this.scene.materials.find(r=>r.name===a.name&&r.id===a.id);n&&n.getBindedMeshes().forEach(r=>{var l;return(l=this.highlightLayer)==null?void 0:l.addMesh(r,i||p.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(void 0,1),ke(this.scene),this.queuedCameraAnimation&&(this.executeCameraAnimation(this.queuedCameraAnimation),this.queuedCameraAnimation=void 0)}),this.configuration.highlights.enabled&&(i.registerMaterialSelectedCallback(o=>{this.setHighlights([o])}),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(o=>o.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 o=g.Matrix.Compose(B(i||{x:1,y:1,z:1}),g.Quaternion.FromEulerVector(B(t||{x:0,y:0,z:0})),B(e||{x:0,y:0,z:0})),a=g.Matrix.RotationAxis(g.Vector3.Up(),Math.PI),n=o.multiply(a),r=g.Vector3.Zero(),l=g.Quaternion.Identity(),d=g.Vector3.Zero();return n.decompose(d,l,r),l.multiplyInPlace(g.Quaternion.FromEulerAngles(0,Math.PI,0)),{position:j(r),rotation:j(l.toEulerAngles()),scale:j(d)}}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)}}h.MaterialEffectMode=E,h.ProductCameraRig=R,h.REFLECTION_PROBE_RESOLUTION=z,h.RenderingConfiguration=C,h.SpiffCommerce3DPreviewService=Je,h.renderingPipelineDefaults=c,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spiffcommerce/preview",
3
- "version": "5.0.2",
3
+ "version": "5.1.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",