@spiffcommerce/preview 5.7.1-alpha.0 → 5.7.1-alpha.2

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
@@ -1095,7 +1095,6 @@ declare class SpiffCommerce3DPreviewService implements ThreeDPreviewService {
1095
1095
  private initComplete;
1096
1096
  private isAnimatingCamera;
1097
1097
  private queuedAnimationFunction?;
1098
- private registeredCanvases;
1099
1098
  constructor(options?: PreviewOptions);
1100
1099
  getInitializationPromise(): Promise<void>;
1101
1100
  getInitializationComplete(): boolean;
package/dist/index.esm.js CHANGED
@@ -3,9 +3,9 @@ import { Engine as be } from "@babylonjs/core/Engines/engine";
3
3
  import { NullEngine as Ce } from "@babylonjs/core/Engines/nullEngine";
4
4
  import { HighlightLayer as ye } from "@babylonjs/core/Layers/highlightLayer";
5
5
  import { SceneLoader as S } from "@babylonjs/core/Loading/sceneLoader";
6
- import { CubeTexture as se } from "@babylonjs/core/Materials/Textures/cubeTexture";
6
+ import { CubeTexture as ne } from "@babylonjs/core/Materials/Textures/cubeTexture";
7
7
  import { Color4 as b, Color3 as w } from "@babylonjs/core/Maths/math.color";
8
- import { Vector3 as p, Quaternion as y, Vector2 as ne, Matrix as re } from "@babylonjs/core/Maths/math.vector";
8
+ import { Vector3 as p, Quaternion as y, Vector2 as se, Matrix as re } from "@babylonjs/core/Maths/math.vector";
9
9
  import { DracoCompression as Ae } from "@babylonjs/core/Meshes/Compression/dracoCompression";
10
10
  import { Observable as C } from "@babylonjs/core/Misc/observable";
11
11
  import { Tools as Me } from "@babylonjs/core/Misc/tools";
@@ -25,10 +25,10 @@ import { DynamicTexture as Be } from "@babylonjs/core/Materials/Textures/dynamic
25
25
  import { Texture as De } from "@babylonjs/core/Materials/Textures/texture";
26
26
  import { Animation as v } from "@babylonjs/core/Animations/animation";
27
27
  import { QuadraticEase as ke, EasingFunction as ze } from "@babylonjs/core/Animations/easing";
28
- import { AssetsManager as Ve } from "@babylonjs/core/Misc/assetsManager";
28
+ import { AssetsManager as qe } from "@babylonjs/core/Misc/assetsManager";
29
29
  import { ColorCurves as le } from "@babylonjs/core/Materials/colorCurves";
30
30
  import { ImageProcessingConfiguration as P } from "@babylonjs/core/Materials/imageProcessingConfiguration";
31
- import { DefaultRenderingPipeline as qe } from "@babylonjs/core/PostProcesses/RenderPipeline";
31
+ import { DefaultRenderingPipeline as Ve } from "@babylonjs/core/PostProcesses/RenderPipeline";
32
32
  import { DepthOfFieldEffectBlurLevel as E } from "@babylonjs/core/PostProcesses/depthOfFieldEffect";
33
33
  import "@babylonjs/core/Rendering/depthRendererSceneComponent";
34
34
  import "@babylonjs/core/Engines/Extensions/engine.views";
@@ -40,31 +40,31 @@ import "@babylonjs/core/Animations/animatable";
40
40
  import "@babylonjs/core/Misc/screenshotTools";
41
41
  import "@babylonjs/core/Rendering/boundingBoxRenderer";
42
42
  import "@babylonjs/loaders/glTF/2.0/Extensions";
43
- var I = /* @__PURE__ */ ((n) => (n[n.Orbit = 0] = "Orbit", n[n.Pan = 1] = "Pan", n))(I || {}), F = /* @__PURE__ */ ((n) => (n.None = "None", n.RemoveWhenSelected = "RemoveWhenSelected", n.ApplyWhenSelected = "ApplyWhenSelected", n))(F || {});
43
+ var I = /* @__PURE__ */ ((s) => (s[s.Orbit = 0] = "Orbit", s[s.Pan = 1] = "Pan", s))(I || {}), F = /* @__PURE__ */ ((s) => (s.None = "None", s.RemoveWhenSelected = "RemoveWhenSelected", s.ApplyWhenSelected = "ApplyWhenSelected", s))(F || {});
44
44
  const he = /* @__PURE__ */ new Map();
45
- async function D(n, e, t) {
46
- const i = he.get(n);
45
+ async function D(s, e, t) {
46
+ const i = he.get(s);
47
47
  if (i)
48
48
  return i;
49
49
  {
50
50
  const r = S.LoadAssetContainerAsync(
51
- n,
51
+ s,
52
52
  void 0,
53
53
  e,
54
54
  t
55
55
  );
56
- return he.set(n, r), r;
56
+ return he.set(s, r), r;
57
57
  }
58
58
  }
59
- S.OnPluginActivatedObservable.add((n) => {
60
- n.name === "gltf" && (n.animationStartMode = Re.NONE);
59
+ S.OnPluginActivatedObservable.add((s) => {
60
+ s.name === "gltf" && (s.animationStartMode = Re.NONE);
61
61
  });
62
62
  class ce {
63
63
  constructor(e) {
64
64
  this.getSceneClearColor = () => {
65
- var i, r, s, o;
65
+ var i, r, n, o;
66
66
  const t = (i = this.customOptions) != null && i.transparentBackground || (r = this.customOptions) != null && r.backgroundImage ? 0 : 1;
67
- if (this.customOptions && ((s = this.customOptions) != null && s.transparentBackground) || (o = this.customOptions) != null && o.backgroundImage)
67
+ if (this.customOptions && ((n = this.customOptions) != null && n.transparentBackground) || (o = this.customOptions) != null && o.backgroundImage)
68
68
  return new b(0, 0, 0, t).toLinearSpace();
69
69
  if (this.customOptions && this.customOptions.backgroundColor) {
70
70
  const a = w.FromHexString(
@@ -99,14 +99,14 @@ class ce {
99
99
  * Configuration related to the scene
100
100
  */
101
101
  get scene() {
102
- var e, t, i, r, s;
102
+ var e, t, i, r, n;
103
103
  return {
104
104
  clearColor: this.getSceneClearColor(),
105
105
  transparentBackground: ((e = this.customOptions) == null ? void 0 : e.transparentBackground) || ((t = this.customOptions) == null ? void 0 : t.backgroundImage),
106
106
  environment: {
107
107
  file: ((i = this.customOptions) == null ? void 0 : i.environmentFile) ?? "assets/model-viewer/default.env",
108
108
  intensity: ((r = this.customOptions) == null ? void 0 : r.environmentIntensity) ?? 1,
109
- rotationY: (((s = this.customOptions) == null ? void 0 : s.environmentRotationY) ?? 0) * (Math.PI / 180)
109
+ rotationY: (((n = this.customOptions) == null ? void 0 : n.environmentRotationY) ?? 0) * (Math.PI / 180)
110
110
  // Convert to radians
111
111
  }
112
112
  };
@@ -115,7 +115,7 @@ class ce {
115
115
  * Configuration related to the camera used to view and interact with the scene.
116
116
  */
117
117
  get camera() {
118
- var e, t, i, r, s, o, a, l, c, h, u, m, g;
118
+ var e, t, i, r, n, o, a, l, c, h, u, m, g;
119
119
  return {
120
120
  autoOrientation: ((e = this.customOptions) == null ? void 0 : e.disableAutomaticOrientation) ?? !0,
121
121
  autoRotation: {
@@ -124,7 +124,7 @@ class ce {
124
124
  },
125
125
  limits: {
126
126
  min: {
127
- alpha: (r = this.customOptions) != null && r.lowerAlphaLimitDeg ? ((s = this.customOptions) == null ? void 0 : s.lowerAlphaLimitDeg) * Math.PI / 180 : void 0,
127
+ alpha: (r = this.customOptions) != null && r.lowerAlphaLimitDeg ? ((n = this.customOptions) == null ? void 0 : n.lowerAlphaLimitDeg) * Math.PI / 180 : void 0,
128
128
  beta: (o = this.customOptions) != null && o.lowerBetaLimitDeg ? ((a = this.customOptions) == null ? void 0 : a.lowerBetaLimitDeg) * Math.PI / 180 : void 0,
129
129
  radius: (l = this.customOptions) == null ? void 0 : l.minZoomOverride
130
130
  },
@@ -273,9 +273,9 @@ class Ge {
273
273
  e,
274
274
  t,
275
275
  function(r) {
276
- t.extras && Object.keys(t.extras).forEach((s) => {
277
- const o = t.extras[s];
278
- r.metadata[s] = o;
276
+ t.extras && Object.keys(t.extras).forEach((n) => {
277
+ const o = t.extras[n];
278
+ r.metadata[n] = o;
279
279
  }), i(r);
280
280
  }
281
281
  );
@@ -334,16 +334,16 @@ class Ge {
334
334
  * @param scene The scene to parse.
335
335
  */
336
336
  applyReflections(e) {
337
- function t(s) {
337
+ function t(n) {
338
338
  const o = [];
339
- return s.transformNodes.forEach((a) => {
339
+ return n.transformNodes.forEach((a) => {
340
340
  a.metadata && a.metadata.reflective && o.push(...a.getChildMeshes());
341
- }), s.meshes.forEach((a) => {
341
+ }), n.meshes.forEach((a) => {
342
342
  a.metadata && a.metadata.reflective && !o.includes(a) && o.push(a);
343
343
  }), o;
344
344
  }
345
- function i(s, o = 1) {
346
- const a = s.material;
345
+ function i(n, o = 1) {
346
+ const a = n.material;
347
347
  if (!a)
348
348
  return;
349
349
  const l = new Ee(
@@ -353,32 +353,32 @@ class Ge {
353
353
  !0
354
354
  );
355
355
  l.renderList = t(e);
356
- const c = s.getVerticesData("normal");
356
+ const c = n.getVerticesData("normal");
357
357
  if (!c)
358
358
  throw new Error(
359
- "Mirror attribute specified on: " + s.name + "But no normals exist to generate a mirror from!"
359
+ "Mirror attribute specified on: " + n.name + "But no normals exist to generate a mirror from!"
360
360
  );
361
- s.computeWorldMatrix(!0);
362
- const h = s.getWorldMatrix(), u = ae.TransformNormal(
361
+ n.computeWorldMatrix(!0);
362
+ const h = n.getWorldMatrix(), u = ae.TransformNormal(
363
363
  new ae(c[0], c[1], c[2]),
364
364
  h
365
365
  ).normalize(), m = Oe.FromPositionAndNormal(
366
- s.position,
366
+ n.position,
367
367
  u.scale(-1)
368
368
  );
369
369
  l.mirrorPlane = m, l.level = o, a.reflectionTexture = l;
370
370
  }
371
- function r(s) {
372
- const o = s.material, a = new Le(
371
+ function r(n) {
372
+ const o = n.material, a = new Le(
373
373
  "probe-" + o.name,
374
374
  Ne,
375
375
  e
376
376
  );
377
- a.attachToMesh(s), a.renderList && a.renderList.push(...t(e)), o.reflectionTexture = a.cubeTexture;
377
+ a.attachToMesh(n), a.renderList && a.renderList.push(...t(e)), o.reflectionTexture = a.cubeTexture;
378
378
  }
379
- e.meshes.forEach((s) => {
380
- const o = s.metadata;
381
- o && (o.mirrorTexture && i(s, o.mirrorTexture), o.reflectionProbe && r(s));
379
+ e.meshes.forEach((n) => {
380
+ const o = n.metadata;
381
+ o && (o.mirrorTexture && i(n, o.mirrorTexture), o.reflectionProbe && r(n));
382
382
  });
383
383
  }
384
384
  }
@@ -404,10 +404,10 @@ class _e {
404
404
  }
405
405
  }
406
406
  }
407
- function He(n, e, t, i, r = "") {
408
- t.forEach((s) => {
409
- const o = s.getID(), a = s.getName(), l = M.getDynamicTextureResolution();
410
- n.filter((h) => h.name === r + a).forEach((h) => {
407
+ function He(s, e, t, i, r = "") {
408
+ t.forEach((n) => {
409
+ const o = n.getID(), a = n.getName(), l = M.getDynamicTextureResolution();
410
+ s.filter((h) => h.name === r + a).forEach((h) => {
411
411
  const u = i.get(o), m = !1;
412
412
  if (u)
413
413
  de(h, u), u.update(m);
@@ -418,7 +418,7 @@ function He(n, e, t, i, r = "") {
418
418
  l.width,
419
419
  l.height
420
420
  );
421
- i.set(o, g), s.setStaticContext(
421
+ i.set(o, g), n.setStaticContext(
422
422
  g.getContext()
423
423
  ), de(h, g), g.onLoadObservable.addOnce(() => {
424
424
  g.update(m);
@@ -427,45 +427,45 @@ function He(n, e, t, i, r = "") {
427
427
  });
428
428
  });
429
429
  }
430
- function Ke(n, e, t, i) {
430
+ function Ke(s, e, t, i) {
431
431
  const r = new Be(
432
- n,
432
+ s,
433
433
  { width: t, height: i },
434
434
  e,
435
435
  M.shouldMipMap(),
436
436
  De.TRILINEAR_SAMPLINGMODE,
437
437
  be.TEXTUREFORMAT_RGBA
438
- ), s = r.getContext();
439
- return s && (s.fillStyle = "#f5f5f5", s.fillRect(0, 0, t, i), r.update()), r;
438
+ ), n = r.getContext();
439
+ return n && (n.fillStyle = "#f5f5f5", n.fillRect(0, 0, t, i), r.update()), r;
440
440
  }
441
- function de(n, e) {
442
- if (n instanceof B) {
443
- const t = n, i = t.albedoTexture;
441
+ function de(s, e) {
442
+ if (s instanceof B) {
443
+ const t = s, i = t.albedoTexture;
444
444
  i ? (e.wrapU = i.wrapU, e.wrapV = i.wrapV) : (e.wrapU = 1, e.wrapV = 1), t.albedoTexture = e;
445
445
  } else {
446
- const t = n, i = t.diffuseTexture;
446
+ const t = s, i = t.diffuseTexture;
447
447
  i && (e.wrapU = i.wrapU, e.wrapV = i.wrapV), t.diffuseTexture = e;
448
448
  }
449
449
  }
450
450
  function Ue() {
451
- const n = () => Math.floor((1 + Math.random()) * 65536).toString(16).substring(1);
452
- return n() + n() + "-" + n() + "-" + n() + "-" + n() + "-" + n() + n() + n();
451
+ const s = () => Math.floor((1 + Math.random()) * 65536).toString(16).substring(1);
452
+ return s() + s() + "-" + s() + "-" + s() + "-" + s() + "-" + s() + s() + s();
453
453
  }
454
454
  const A = 60, ue = 1;
455
- function me(n) {
456
- return n.targetedAnimations.map((t) => t.animation.framePerSecond).reduce((t, i) => t + i, 0) / n.targetedAnimations.length || 0;
455
+ function me(s) {
456
+ return s.targetedAnimations.map((t) => t.animation.framePerSecond).reduce((t, i) => t + i, 0) / s.targetedAnimations.length || 0;
457
457
  }
458
- function ve(n, e, t, i, r, s) {
459
- const o = r ? n.filter((h) => h.name === r) : n;
458
+ function ve(s, e, t, i, r, n) {
459
+ const o = r ? s.filter((h) => h.name === r) : s;
460
460
  if (o.length === 0) {
461
461
  console.warn(`No animations found for name: ${r}`);
462
462
  return;
463
463
  }
464
464
  let a = 0;
465
465
  const l = () => {
466
- a++, a === o.length && s && s();
466
+ a++, a === o.length && n && n();
467
467
  }, c = (h, u, m, g, f) => {
468
- h.stop(), h.start(u, m, g, f), s && (u == !1 || u === void 0 && !h.loopAnimation ? h.onAnimationGroupEndObservable.addOnce(() => {
468
+ h.stop(), h.start(u, m, g, f), n && (u == !1 || u === void 0 && !h.loopAnimation ? h.onAnimationGroupEndObservable.addOnce(() => {
469
469
  l();
470
470
  }) : h.onAnimationLoopObservable.addOnce(() => {
471
471
  l();
@@ -483,10 +483,10 @@ function ve(n, e, t, i, r, s) {
483
483
  c(h, e, ue, m, g);
484
484
  });
485
485
  }
486
- function We(n, e, t) {
486
+ function We(s, e, t) {
487
487
  return new Promise((i) => {
488
- n.stopAnimation(e), e.animations = [], Math.abs(e.alpha) > 2 * Math.PI && (e.alpha = Ye(e.alpha, 0, 2 * Math.PI));
489
- const r = [], s = t.target, o = 0, a = s ? 1 : 0;
488
+ s.stopAnimation(e), e.animations = [], Math.abs(e.alpha) > 2 * Math.PI && (e.alpha = Ye(e.alpha, 0, 2 * Math.PI));
489
+ const r = [], n = t.target, o = 0, a = n ? 1 : 0;
490
490
  if (t.target && Object.keys(t.target).length > 0 && r.push(
491
491
  x(
492
492
  "cameraTargetLerp",
@@ -533,10 +533,10 @@ function We(n, e, t) {
533
533
  }
534
534
  e.animations.push(...r);
535
535
  const c = e.useAutoRotationBehavior;
536
- e.disableAutoRotationBehavior(), n.beginAnimation(
536
+ e.disableAutoRotationBehavior(), s.beginAnimation(
537
537
  e,
538
538
  0,
539
- s ? A * 2 : A,
539
+ n ? A * 2 : A,
540
540
  !1,
541
541
  1,
542
542
  () => {
@@ -545,29 +545,29 @@ function We(n, e, t) {
545
545
  );
546
546
  });
547
547
  }
548
- function ge(n) {
549
- return n * Math.PI / 180;
548
+ function ge(s) {
549
+ return s * Math.PI / 180;
550
550
  }
551
- function x(n, e, t, i, r, s = 0, o = v.ANIMATIONLOOPMODE_CONSTANT) {
551
+ function x(s, e, t, i, r, n = 0, o = v.ANIMATIONLOOPMODE_CONSTANT) {
552
552
  const a = new ke();
553
553
  a.setEasingMode(ze.EASINGMODE_EASEINOUT);
554
554
  const l = new v(
555
- n,
555
+ s,
556
556
  e,
557
557
  A,
558
558
  r,
559
559
  o
560
560
  ), c = [];
561
- return s > 0 && c.push({ frame: 0, value: t }), c.push({ frame: A * s, value: t }), c.push({
562
- frame: A * (s + 1),
561
+ return n > 0 && c.push({ frame: 0, value: t }), c.push({ frame: A * n, value: t }), c.push({
562
+ frame: A * (n + 1),
563
563
  value: i
564
564
  }), l.setKeys(c), l.setEasingFunction(a), l;
565
565
  }
566
- function Ye(n, e, t) {
567
- return n < e ? n = t - (e - n) % (t - e) : n = e + (n - e) % (t - e);
566
+ function Ye(s, e, t) {
567
+ return s < e ? s = t - (e - s) % (t - e) : s = e + (s - e) % (t - e);
568
568
  }
569
- function Qe(n, e, t) {
570
- n.forEach((i) => {
569
+ function Qe(s, e, t) {
570
+ s.forEach((i) => {
571
571
  t && i.name !== t || i.goToFrame(e);
572
572
  });
573
573
  }
@@ -581,7 +581,7 @@ const Ze = {
581
581
  refractionTexture: "refractionMap",
582
582
  reflectionTexture: "reflectionMap"
583
583
  };
584
- function $e(n, e, t, i) {
584
+ function $e(s, e, t, i) {
585
585
  [
586
586
  "albedoTexture",
587
587
  "bumpTexture",
@@ -591,49 +591,49 @@ function $e(n, e, t, i) {
591
591
  "metallicTexture",
592
592
  "refractionTexture",
593
593
  "reflectionTexture"
594
- ].forEach((s) => {
594
+ ].forEach((n) => {
595
595
  je(
596
- s,
597
596
  n,
597
+ s,
598
598
  e,
599
599
  t,
600
600
  i
601
601
  );
602
- }), et(n, e);
602
+ }), et(s, e);
603
603
  }
604
- function je(n, e, t, i, r) {
605
- const s = Ze[n];
606
- if (!s)
604
+ function je(s, e, t, i, r) {
605
+ const n = Ze[s];
606
+ if (!n)
607
607
  throw new Error("Unexpected texture name encountered.");
608
- const o = e[s], a = o == null ? void 0 : o.fileLink;
609
- a ? n === "reflectionTexture" ? a.endsWith(".env") || a.endsWith(".dds") ? i.addCubeTextureTask(
610
- n,
608
+ const o = e[n], a = o == null ? void 0 : o.fileLink;
609
+ a ? s === "reflectionTexture" ? a.endsWith(".env") || a.endsWith(".dds") ? i.addCubeTextureTask(
610
+ s,
611
611
  a,
612
612
  void 0,
613
613
  !1,
614
614
  void 0,
615
615
  !0
616
616
  ) : a.endsWith(".hdr") ? i.addHDRCubeTextureTask(
617
- n,
617
+ s,
618
618
  a,
619
619
  128,
620
620
  !1,
621
621
  !0,
622
622
  !1
623
- ) : i.addTextureTask(n, a, !1, !1) : i.addTextureTask(n, a, !1, !1) : r && t[n] && (t[n] && t[n].dispose(), t[n] = null, Xe(n, t));
623
+ ) : i.addTextureTask(s, a, !1, !1) : i.addTextureTask(s, a, !1, !1) : r && t[s] && (t[s] && t[s].dispose(), t[s] = null, Xe(s, t));
624
624
  }
625
- function Xe(n, e) {
626
- n === "opacityTexture" && (e.useAlphaFromAlbedoTexture = !0), n === "metallicTexture" && (e.useRoughnessFromMetallicTextureAlpha = !1, e.useRoughnessFromMetallicTextureGreen = !1, e.useMetallnessFromMetallicTextureBlue = !1), n === "refractionTexture" && (e.subSurface.isRefractionEnabled = !1, e.subSurface.refractionIntensity = 1), n === "reflectionTexture" && (e.environmentIntensity = 1), n === "emissiveTexture" && (e.emissiveIntensity = 0, e.emissiveColor = new w(0, 0, 0), e.reflectionTexture);
625
+ function Xe(s, e) {
626
+ s === "opacityTexture" && (e.useAlphaFromAlbedoTexture = !0), s === "metallicTexture" && (e.useRoughnessFromMetallicTextureAlpha = !1, e.useRoughnessFromMetallicTextureGreen = !1, e.useMetallnessFromMetallicTextureBlue = !1), s === "refractionTexture" && (e.subSurface.isRefractionEnabled = !1, e.subSurface.refractionIntensity = 1), s === "reflectionTexture" && (e.environmentIntensity = 1), s === "emissiveTexture" && (e.emissiveIntensity = 0, e.emissiveColor = new w(0, 0, 0), e.reflectionTexture);
627
627
  }
628
- function Je(n, e, t, i) {
628
+ function Je(s, e, t, i) {
629
629
  if (!e) {
630
630
  console.error("Failed to apply texture to material: material is null.");
631
631
  return;
632
632
  }
633
- n === "opacityTexture" && (e.useAlphaFromAlbedoTexture = !1), n === "metallicTexture" && (e.useRoughnessFromMetallicTextureAlpha = !1, e.useRoughnessFromMetallicTextureGreen = !0, e.useMetallnessFromMetallicTextureBlue = !0), n === "refractionTexture" && (e.subSurface.isRefractionEnabled = !0, e.subSurface.refractionIntensity = t.refractionIntensity || 1), n === "reflectionTexture" && (e.environmentIntensity = t.reflectionIntensity || 1, i.isCube && (i.rotationY = t.reflectionRotation ? t.reflectionRotation * Math.PI / 180 : 0)), e[n] = i, n === "emissiveTexture" && (e.emissiveColor = new w(1, 1, 1), e.emissiveIntensity = 1);
633
+ s === "opacityTexture" && (e.useAlphaFromAlbedoTexture = !1), s === "metallicTexture" && (e.useRoughnessFromMetallicTextureAlpha = !1, e.useRoughnessFromMetallicTextureGreen = !0, e.useMetallnessFromMetallicTextureBlue = !0), s === "refractionTexture" && (e.subSurface.isRefractionEnabled = !0, e.subSurface.refractionIntensity = t.refractionIntensity || 1), s === "reflectionTexture" && (e.environmentIntensity = t.reflectionIntensity || 1, i.isCube && (i.rotationY = t.reflectionRotation ? t.reflectionRotation * Math.PI / 180 : 0)), e[s] = i, s === "emissiveTexture" && (e.emissiveColor = new w(1, 1, 1), e.emissiveIntensity = 1);
634
634
  }
635
- function et(n, e) {
636
- n.clearCoat && (n.clearCoat === F.RemoveWhenSelected ? (e.clearCoat.isEnabled = !1, e.clearCoat.indexOfRefraction = 1.5) : n.clearCoat === F.ApplyWhenSelected && (e.clearCoat.isEnabled = !0, e.clearCoat.indexOfRefraction = n.clearCoatIOR || e.clearCoat.indexOfRefraction));
635
+ function et(s, e) {
636
+ s.clearCoat && (s.clearCoat === F.RemoveWhenSelected ? (e.clearCoat.isEnabled = !1, e.clearCoat.indexOfRefraction = 1.5) : s.clearCoat === F.ApplyWhenSelected && (e.clearCoat.isEnabled = !0, e.clearCoat.indexOfRefraction = s.clearCoatIOR || e.clearCoat.indexOfRefraction));
637
637
  }
638
638
  class tt {
639
639
  constructor(e, t, i) {
@@ -649,7 +649,7 @@ class tt {
649
649
  * where we want to undo changes are remove effects from display.
650
650
  */
651
651
  async applyMaterial(e, t, i, r) {
652
- return new Promise((s) => {
652
+ return new Promise((n) => {
653
653
  const o = this.materialVariantMap.get(e);
654
654
  this.materialVariantMap.set(e, {
655
655
  ...o,
@@ -659,10 +659,10 @@ class tt {
659
659
  (h) => h.name === a
660
660
  );
661
661
  if (l.length === 0) {
662
- s();
662
+ n();
663
663
  return;
664
664
  }
665
- const c = new Ve(this.scene);
665
+ const c = new qe(this.scene);
666
666
  c.useDefaultLoadingScreen = !1, l.forEach(
667
667
  (h) => $e(
668
668
  t,
@@ -685,7 +685,7 @@ class tt {
685
685
  m.texture
686
686
  )
687
687
  );
688
- }), s();
688
+ }), n();
689
689
  }, c.loadAsync();
690
690
  });
691
691
  }
@@ -699,7 +699,7 @@ class tt {
699
699
  * @param getCurrentFrame A function that returns the current frame of the animation.
700
700
  * @param getAnimationIsPlaying A function that returns whether the animation is currently playing.
701
701
  */
702
- async applyModel(e, t, i, r, s, o, a) {
702
+ async applyModel(e, t, i, r, n, o, a) {
703
703
  var u;
704
704
  if (i && t && !this.keysThatRemovedBaseModel.includes(e) && this.keysThatRemovedBaseModel.push(e), !i)
705
705
  return this.keysThatRemovedBaseModel.includes(e) && this.keysThatRemovedBaseModel.length === 1 && await this.setBaseModelEnabled(!0), (u = this.loadedContainerForKey.get(e)) == null || u.dispose(), this.loadedContainerForKey.delete(e), this.loadedMaterialsForKey.delete(e), this.keysThatRemovedBaseModel = this.keysThatRemovedBaseModel.filter(
@@ -709,13 +709,13 @@ class tt {
709
709
  this.renameClonedAsset,
710
710
  !0
711
711
  );
712
- if (this.loadedContainerForKey.has(e) && (this.loadedContainerForKey.get(e).dispose(), this.loadedContainerForKey.delete(e), this.loadedMaterialsForKey.delete(e)), s) {
713
- const m = o && o(), g = s.name ? this.renameClonedAsset(s.name) : void 0;
712
+ if (this.loadedContainerForKey.has(e) && (this.loadedContainerForKey.get(e).dispose(), this.loadedContainerForKey.delete(e), this.loadedMaterialsForKey.delete(e)), n) {
713
+ const m = o && o(), g = n.name ? this.renameClonedAsset(n.name) : void 0;
714
714
  if (ve(
715
715
  c.animationGroups,
716
- s.loop,
717
- s.to,
718
- s.from,
716
+ n.loop,
717
+ n.to,
718
+ n.from,
719
719
  g
720
720
  ), m != null) {
721
721
  const f = a && a() || !0;
@@ -752,19 +752,19 @@ class tt {
752
752
  }), e;
753
753
  }
754
754
  }
755
- function we(n) {
755
+ function we(s) {
756
756
  const e = [];
757
- return n.rootNodes.forEach((t) => {
757
+ return s.rootNodes.forEach((t) => {
758
758
  t.getChildMeshes().forEach((i) => {
759
759
  i.material && !e.includes(i.material) && e.push(i.material), i.subMeshes && i.subMeshes.forEach((r) => {
760
- const s = r.getMaterial(!1);
761
- s && !e.includes(s) && e.push(s);
760
+ const n = r.getMaterial(!1);
761
+ n && !e.includes(n) && e.push(n);
762
762
  });
763
763
  });
764
764
  }), e;
765
765
  }
766
- function pe(n, e = "") {
767
- return n.map((t) => ({
766
+ function pe(s, e = "") {
767
+ return s.map((t) => ({
768
768
  name: t.name.substring(e.length),
769
769
  loop: t.loopAnimation,
770
770
  to: t.to,
@@ -778,7 +778,7 @@ class it {
778
778
  enablePicking: t,
779
779
  modelDetails: i,
780
780
  previewService: r,
781
- progressHandler: s,
781
+ progressHandler: n,
782
782
  scene: o
783
783
  } = e;
784
784
  this.enablePicking = t, this.contextService = i.contextService, this.id = Ue(), this.previewService = r, this.scene = o, this.variantManager = new tt(
@@ -794,7 +794,7 @@ class it {
794
794
  return this.assetContainer = await D(
795
795
  i.model,
796
796
  o,
797
- s
797
+ n
798
798
  ), await this.instantiate(), this;
799
799
  };
800
800
  this.importPromise = a();
@@ -833,7 +833,7 @@ class it {
833
833
  }
834
834
  return;
835
835
  }
836
- const s = async () => {
836
+ const n = async () => {
837
837
  await this.variantManager.applyMaterial(
838
838
  e,
839
839
  i,
@@ -850,18 +850,18 @@ class it {
850
850
  if (this.materialChangesInProgress.includes(e)) {
851
851
  if (this.queuedMaterialChanges.has(e)) {
852
852
  const o = this.queuedMaterialChanges.get(e);
853
- o == null || o.set(t, s);
853
+ o == null || o.set(t, n);
854
854
  } else {
855
855
  this.queuedMaterialChanges.set(
856
856
  e,
857
857
  /* @__PURE__ */ new Map()
858
858
  );
859
859
  const o = this.queuedMaterialChanges.get(e);
860
- o == null || o.set(t, s);
860
+ o == null || o.set(t, n);
861
861
  }
862
862
  return;
863
863
  }
864
- if (this.materialChangesInProgress.push(e), await s(), this.queuedMaterialChanges.has(e)) {
864
+ if (this.materialChangesInProgress.push(e), await n(), this.queuedMaterialChanges.has(e)) {
865
865
  const o = this.queuedMaterialChanges.get(e);
866
866
  if (!o)
867
867
  throw new Error("Target material is undefined");
@@ -933,12 +933,12 @@ class it {
933
933
  const i = async () => {
934
934
  this.lastPlayedAnimation = e, this.isExecutingAnimation = !0, await new Promise((r) => {
935
935
  var o;
936
- const s = [
936
+ const n = [
937
937
  ...((o = this.modelInstance) == null ? void 0 : o.animationGroups) || [],
938
938
  ...this.variantManager.getAnimationGroups()
939
939
  ];
940
940
  ve(
941
- s,
941
+ n,
942
942
  e.loop,
943
943
  e.to,
944
944
  e.from,
@@ -1066,7 +1066,7 @@ class it {
1066
1066
  this.materials.some(e) || this.variantManager.getAllMaterials().some(e) ? this.previewService.getGlowLayerManager().includeMeshes(this.getAllMeshes()) : this.previewService.getGlowLayerManager().removeMeshes(this.getAllMeshes());
1067
1067
  }
1068
1068
  configureModelInstance(e) {
1069
- var s;
1069
+ var n;
1070
1070
  if (!this.transformRoot)
1071
1071
  throw new Error(
1072
1072
  "Transform disposed! This should never happen unless there is a race condition present!"
@@ -1078,7 +1078,7 @@ class it {
1078
1078
  for (const a of o.getChildMeshes(!1))
1079
1079
  a.alwaysSelectAsActiveMesh = !0;
1080
1080
  }
1081
- this.transformRoot.position = t, this.transformRoot.rotationQuaternion = i, this.transformRoot.scaling = r, this.canvasPanels = ((s = this.contextService) == null ? void 0 : s.getAll()) || /* @__PURE__ */ new Map(), He(
1081
+ this.transformRoot.position = t, this.transformRoot.rotationQuaternion = i, this.transformRoot.scaling = r, this.canvasPanels = ((n = this.contextService) == null ? void 0 : n.getAll()) || /* @__PURE__ */ new Map(), He(
1082
1082
  this.materials.concat(this.variantManager.getAllMaterials()),
1083
1083
  this.scene,
1084
1084
  this.canvasPanels,
@@ -1182,13 +1182,13 @@ class it {
1182
1182
  //#endregion
1183
1183
  }
1184
1184
  class k extends fe {
1185
- constructor(e, t, i, r, s, o, a, l) {
1185
+ constructor(e, t, i, r, n, o, a, l) {
1186
1186
  super(
1187
1187
  e,
1188
1188
  t,
1189
1189
  i,
1190
1190
  r,
1191
- s,
1191
+ n,
1192
1192
  o,
1193
1193
  l
1194
1194
  ), this.lastFocus = new p(0, 0, 0), this._isRunningFramingBehavior = !1, this.panDenominator = 1, this.panEnabled = !0, this.minZ = 0.01, this.updateRadiusBounds(this.radius), this.enableFramingBehavior(), this.wheelDeltaPercentage = 0.01, this.pinchDeltaPercentage = 5e-3, this.useNaturalPinchZoom = !0, a.camera.autoOrientation && (this.alpha += Math.PI), a && (a.camera.limits.min.beta && (this.lowerBetaLimit = a.camera.limits.min.beta), a.camera.limits.max.beta && (this.upperBetaLimit = a.camera.limits.max.beta), a.camera.limits.min.alpha && (this.lowerAlphaLimit = a.camera.limits.min.alpha), a.camera.limits.max.alpha && (this.upperAlphaLimit = a.camera.limits.max.alpha), a.camera.limits.min.radius && (this.lowerRadiusLimit = a.camera.limits.min.radius), a.camera.limits.max.radius && (this.upperRadiusLimit = a.camera.limits.max.radius), a.camera.autoRotation.enabled && this.enableAutoRotationBehavior(
@@ -1246,10 +1246,10 @@ class k extends fe {
1246
1246
  i.framingTime = t || 800;
1247
1247
  const r = () => {
1248
1248
  this.isRunningFramingBehavior = !1;
1249
- }, s = T(this._scene), o = s.max.subtract(s.min), a = s.min.add(o.scale(0.5));
1249
+ }, n = T(this._scene), o = n.max.subtract(n.min), a = n.min.add(o.scale(0.5));
1250
1250
  this.updateRadiusBounds(o.length() * 1.5), this.wheelPrecision = 100 / this.radius, this.panningInertia = 0, this.panningOriginTarget.copyFrom(a), this.panDenominator = o.length(), this.lastFocus.copyFrom(a), i.zoomOnBoundingInfo(
1251
- s.min,
1252
- s.max,
1251
+ n.min,
1252
+ n.max,
1253
1253
  void 0,
1254
1254
  r
1255
1255
  ), i.framingTime = 0;
@@ -1283,34 +1283,34 @@ class k extends fe {
1283
1283
  */
1284
1284
  static create(e, t, i) {
1285
1285
  var l;
1286
- const r = T(e), s = r.max.subtract(r.min), o = r.min.add(s.scale(0.5)), a = new k(
1286
+ const r = T(e), n = r.max.subtract(r.min), o = r.min.add(n.scale(0.5)), a = new k(
1287
1287
  "ProductCamera",
1288
1288
  -(Math.PI / 2),
1289
1289
  Math.PI / 2,
1290
- s.length() * 1.5,
1290
+ n.length() * 1.5,
1291
1291
  o,
1292
1292
  e,
1293
1293
  t
1294
1294
  );
1295
1295
  return a.setPanEnabled(
1296
1296
  ((l = t.options) == null ? void 0 : l.noPan) !== void 0 ? !t.options.noPan : !0
1297
- ), a.panningInertia = 0, a.panningOriginTarget.copyFrom(o), a.panDenominator = s.length(), a.onAfterCheckInputsObservable.addOnce(() => {
1297
+ ), a.panningInertia = 0, a.panningOriginTarget.copyFrom(o), a.panDenominator = n.length(), a.onAfterCheckInputsObservable.addOnce(() => {
1298
1298
  a.setPanEnabled(a.panEnabled);
1299
1299
  }), i && (e.activeCamera = a), a;
1300
1300
  }
1301
1301
  }
1302
- function T(n) {
1303
- if (n.meshes.length === 0)
1302
+ function T(s) {
1303
+ if (s.meshes.length === 0)
1304
1304
  return {
1305
1305
  min: new p(-1, -1, -1),
1306
1306
  max: new p(1, 1, 1)
1307
1307
  };
1308
- const e = n.meshes.filter((t) => t.name.toLowerCase().endsWith("_t") || t.name.toLowerCase().includes("_t_"));
1309
- return n.getWorldExtends((t) => t.isVisible && t.isEnabled() && (e.length === 0 || e.includes(t)));
1308
+ const e = s.meshes.filter((t) => t.name.toLowerCase().endsWith("_t") || t.name.toLowerCase().includes("_t_"));
1309
+ return s.getWorldExtends((t) => t.isVisible && t.isEnabled() && (e.length === 0 || e.includes(t)));
1310
1310
  }
1311
- class st {
1311
+ class nt {
1312
1312
  constructor(e, t = !1, i = void 0) {
1313
- this.renderingPipeline = new qe(
1313
+ this.renderingPipeline = new Ve(
1314
1314
  "default",
1315
1315
  t,
1316
1316
  e,
@@ -1326,12 +1326,12 @@ class st {
1326
1326
  return this.currentConfiguration;
1327
1327
  }
1328
1328
  setConfiguration(e) {
1329
- var t, i, r, s, o, a, l, c, h, u, m, g, f, z, V, q, N, G, _, H, K, U, W, Y, Q, Z, $, j, X, J, ee, te, ie;
1329
+ var t, i, r, n, o, a, l, c, h, u, m, g, f, z, q, V, N, G, _, H, K, U, W, Y, Q, Z, $, j, X, J, ee, te, ie;
1330
1330
  if (this.renderingPipeline.isSupported) {
1331
- if (this.renderingPipeline.samples = ((t = e.antiAliasing) == null ? void 0 : t.samples) ?? d.antiAliasing.samples, this.renderingPipeline.fxaaEnabled = ((i = e.antiAliasing) == null ? void 0 : i.fxaaEnabled) ?? d.antiAliasing.fxaaEnabled, this.renderingPipeline.bloomEnabled = ((r = e.bloom) == null ? void 0 : r.enabled) ?? d.bloom.enabled, this.renderingPipeline.bloomKernel = ((s = e.bloom) == null ? void 0 : s.kernel) ?? d.bloom.kernel, this.renderingPipeline.bloomScale = ((o = e.bloom) == null ? void 0 : o.scale) ?? d.bloom.scale, this.renderingPipeline.bloomThreshold = ((a = e.bloom) == null ? void 0 : a.threshold) ?? d.bloom.threshold, this.renderingPipeline.bloomWeight = ((l = e.bloom) == null ? void 0 : l.weight) ?? d.bloom.weight, this.renderingPipeline.chromaticAberrationEnabled = ((c = e.chromaticAberration) == null ? void 0 : c.enabled) ?? d.chromaticAberration.enabled, this.renderingPipeline.chromaticAberration.aberrationAmount = ((h = e.chromaticAberration) == null ? void 0 : h.aberrationAmount) ?? d.chromaticAberration.aberrationAmount, this.renderingPipeline.chromaticAberration.radialIntensity = ((u = e.chromaticAberration) == null ? void 0 : u.radialIntensity) ?? d.chromaticAberration.radialIntensity, this.renderingPipeline.chromaticAberration.direction = (m = e.chromaticAberration) != null && m.direction ? new ne(
1331
+ if (this.renderingPipeline.samples = ((t = e.antiAliasing) == null ? void 0 : t.samples) ?? d.antiAliasing.samples, this.renderingPipeline.fxaaEnabled = ((i = e.antiAliasing) == null ? void 0 : i.fxaaEnabled) ?? d.antiAliasing.fxaaEnabled, this.renderingPipeline.bloomEnabled = ((r = e.bloom) == null ? void 0 : r.enabled) ?? d.bloom.enabled, this.renderingPipeline.bloomKernel = ((n = e.bloom) == null ? void 0 : n.kernel) ?? d.bloom.kernel, this.renderingPipeline.bloomScale = ((o = e.bloom) == null ? void 0 : o.scale) ?? d.bloom.scale, this.renderingPipeline.bloomThreshold = ((a = e.bloom) == null ? void 0 : a.threshold) ?? d.bloom.threshold, this.renderingPipeline.bloomWeight = ((l = e.bloom) == null ? void 0 : l.weight) ?? d.bloom.weight, this.renderingPipeline.chromaticAberrationEnabled = ((c = e.chromaticAberration) == null ? void 0 : c.enabled) ?? d.chromaticAberration.enabled, this.renderingPipeline.chromaticAberration.aberrationAmount = ((h = e.chromaticAberration) == null ? void 0 : h.aberrationAmount) ?? d.chromaticAberration.aberrationAmount, this.renderingPipeline.chromaticAberration.radialIntensity = ((u = e.chromaticAberration) == null ? void 0 : u.radialIntensity) ?? d.chromaticAberration.radialIntensity, this.renderingPipeline.chromaticAberration.direction = (m = e.chromaticAberration) != null && m.direction ? new se(
1332
1332
  e.chromaticAberration.direction.x,
1333
1333
  e.chromaticAberration.direction.y
1334
- ) : new ne(
1334
+ ) : new se(
1335
1335
  d.chromaticAberration.direction.x,
1336
1336
  d.chromaticAberration.direction.y
1337
1337
  ), this.renderingPipeline.imageProcessing.colorCurvesEnabled = ((g = e.colorCurves) == null ? void 0 : g.enabled) ?? d.colorCurves.enabled, this.renderingPipeline.imageProcessing.colorCurves = e.colorCurves ? this.updateColorCurve(e.colorCurves) : new le(), this.renderingPipeline.depthOfFieldEnabled = ((f = e.depthOfField) == null ? void 0 : f.enabled) ?? d.depthOfField.enabled, e.depthOfField)
@@ -1346,7 +1346,7 @@ class st {
1346
1346
  this.renderingPipeline.depthOfFieldBlurLevel = E.High;
1347
1347
  break;
1348
1348
  }
1349
- if (this.renderingPipeline.depthOfField.focalLength = ((z = e.depthOfField) == null ? void 0 : z.focalLength) ?? d.depthOfField.focalLength, this.renderingPipeline.depthOfField.fStop = ((V = e.depthOfField) == null ? void 0 : V.fStop) ?? d.depthOfField.fStop, this.renderingPipeline.depthOfField.focusDistance = ((q = e.depthOfField) == null ? void 0 : q.focusDistance) ?? d.depthOfField.focusDistance, this.renderingPipeline.depthOfField.lensSize = ((N = e.depthOfField) == null ? void 0 : N.lensSize) ?? d.depthOfField.lensSize, this.renderingPipeline.grainEnabled = ((G = e.grain) == null ? void 0 : G.enabled) ?? d.grain.enabled, this.renderingPipeline.grain.animated = ((_ = e.grain) == null ? void 0 : _.animated) ?? d.grain.animated, this.renderingPipeline.grain.intensity = ((H = e.grain) == null ? void 0 : H.intensity) ?? d.grain.intensity, this.renderingPipeline.imageProcessing.contrast = ((K = e.misc) == null ? void 0 : K.contrast) ?? d.misc.contrast, this.renderingPipeline.imageProcessing.exposure = ((U = e.misc) == null ? void 0 : U.exposure) ?? d.misc.exposure, this.renderingPipeline.imageProcessing.toneMappingEnabled = ((W = e.misc) == null ? void 0 : W.toneMappingEnabled) ?? d.misc.toneMappingEnabled, this.renderingPipeline.imageProcessing.toneMappingEnabled)
1349
+ if (this.renderingPipeline.depthOfField.focalLength = ((z = e.depthOfField) == null ? void 0 : z.focalLength) ?? d.depthOfField.focalLength, this.renderingPipeline.depthOfField.fStop = ((q = e.depthOfField) == null ? void 0 : q.fStop) ?? d.depthOfField.fStop, this.renderingPipeline.depthOfField.focusDistance = ((V = e.depthOfField) == null ? void 0 : V.focusDistance) ?? d.depthOfField.focusDistance, this.renderingPipeline.depthOfField.lensSize = ((N = e.depthOfField) == null ? void 0 : N.lensSize) ?? d.depthOfField.lensSize, this.renderingPipeline.grainEnabled = ((G = e.grain) == null ? void 0 : G.enabled) ?? d.grain.enabled, this.renderingPipeline.grain.animated = ((_ = e.grain) == null ? void 0 : _.animated) ?? d.grain.animated, this.renderingPipeline.grain.intensity = ((H = e.grain) == null ? void 0 : H.intensity) ?? d.grain.intensity, this.renderingPipeline.imageProcessing.contrast = ((K = e.misc) == null ? void 0 : K.contrast) ?? d.misc.contrast, this.renderingPipeline.imageProcessing.exposure = ((U = e.misc) == null ? void 0 : U.exposure) ?? d.misc.exposure, this.renderingPipeline.imageProcessing.toneMappingEnabled = ((W = e.misc) == null ? void 0 : W.toneMappingEnabled) ?? d.misc.toneMappingEnabled, this.renderingPipeline.imageProcessing.toneMappingEnabled)
1350
1350
  switch (e.misc.toneMappingType ?? d.misc.toneMappingType) {
1351
1351
  case "Standard":
1352
1352
  this.renderingPipeline.imageProcessing.toneMappingType = P.TONEMAPPING_STANDARD;
@@ -1382,30 +1382,30 @@ class st {
1382
1382
  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;
1383
1383
  }
1384
1384
  }
1385
- xe.GLTFLoader.RegisterExtension("glbPostProcessor", function(n) {
1386
- return new Ge(n);
1385
+ xe.GLTFLoader.RegisterExtension("glbPostProcessor", function(s) {
1386
+ return new Ge(s);
1387
1387
  });
1388
- S.OnPluginActivatedObservable.add((n) => {
1389
- if (n.name === "gltf") {
1390
- const e = n;
1388
+ S.OnPluginActivatedObservable.add((s) => {
1389
+ if (s.name === "gltf") {
1390
+ const e = s;
1391
1391
  e.transparencyAsCoverage = !0;
1392
1392
  }
1393
1393
  });
1394
- function O(n) {
1395
- return new p(n.x, n.y, n.z);
1394
+ function O(s) {
1395
+ return new p(s.x, s.y, s.z);
1396
1396
  }
1397
- function L(n) {
1398
- return { x: n.x, y: n.y, z: n.z };
1397
+ function L(s) {
1398
+ return { x: s.x, y: s.y, z: s.z };
1399
1399
  }
1400
1400
  class Wt {
1401
1401
  constructor(e) {
1402
1402
  var l;
1403
- this.focusLostNotified = !1, this.focusLostObservable = new C(), this.modelLoadEventCallbacks = [], this.modelContainers = /* @__PURE__ */ new Map(), this.plugins = [], this.initComplete = !1, this.isAnimatingCamera = !1, this.registeredCanvases = [], this.renderLoop = () => {
1403
+ this.focusLostNotified = !1, this.focusLostObservable = new C(), this.modelLoadEventCallbacks = [], this.modelContainers = /* @__PURE__ */ new Map(), this.plugins = [], this.initComplete = !1, this.isAnimatingCamera = !1, this.renderLoop = () => {
1404
1404
  if (!this.engine.views)
1405
1405
  return;
1406
1406
  this.modelContainers.forEach((h) => {
1407
1407
  h.updateDynamicTextures();
1408
- }), this.scene.autoClear = !0, this.scene.autoClearDepthAndStencil = !0, this.scene.render(), this.camera.isRunningFramingBehavior && this.camera.getFramingBehavior().isUserIsMoving && (this.camera.isRunningFramingBehavior = !1);
1408
+ }), this.scene.autoClear = !1, this.scene.autoClearDepthAndStencil = !1, this.scene.render(), this.camera.isRunningFramingBehavior && this.camera.getFramingBehavior().isUserIsMoving && (this.camera.isRunningFramingBehavior = !1);
1409
1409
  const c = Math.max((this.camera.lowerRadiusLimit ?? 1) * 0.01, 1e-3);
1410
1410
  !this.camera.isRunningFramingBehavior && !this.camera.target.equalsWithEpsilon(this.camera.lastFocus, c) && !this.focusLostNotified && (this.focusLostObservable.notifyObservers(void 0), this.focusLostNotified = !0), this.screenshotPrepareResolve && (this.screenshotPrepareResolve(), this.screenshotPrepareResolve = void 0);
1411
1411
  }, this.configuration = new ce(e);
@@ -1420,7 +1420,7 @@ class Wt {
1420
1420
  fallbackUrl: `https://www.gstatic.com/draco/versioned/decoders/${r}/draco_decoder_gltf.js`
1421
1421
  }
1422
1422
  }, i && (i.getContext("webgl2") || i.getContext("webgl"));
1423
- const s = console.log;
1423
+ const n = console.log;
1424
1424
  console.log = () => {
1425
1425
  };
1426
1426
  const o = i ? new be(i, !0, {
@@ -1432,12 +1432,12 @@ class Wt {
1432
1432
  stencil: this.configuration.highlights.enabled,
1433
1433
  forceSRGBBufferSupportState: !0
1434
1434
  }) : new Ce();
1435
- console.log = s, o.hideLoadingUI(), window.addEventListener("resize", this.fireResizeEvent.bind(this)), this.engine = o, this.scene = new Pe(o), this.camera = k.create(this.scene, this.configuration), this.scene.activeCamera = this.camera, this.renderingPipeline = new st(
1435
+ console.log = n, o.hideLoadingUI(), window.addEventListener("resize", this.fireResizeEvent.bind(this)), this.engine = o, this.scene = new Pe(o), this.camera = k.create(this.scene, this.configuration), this.scene.activeCamera = this.camera, this.renderingPipeline = new nt(
1436
1436
  this.scene,
1437
1437
  !1,
1438
1438
  this.camera
1439
1439
  ), this.scene.clearColor = this.configuration.scene.clearColor;
1440
- const a = se.CreateFromPrefilteredData(
1440
+ const a = ne.CreateFromPrefilteredData(
1441
1441
  this.configuration.scene.environment.file,
1442
1442
  this.scene
1443
1443
  );
@@ -1450,7 +1450,7 @@ class Wt {
1450
1450
  this.scene.onReadyObservable.addOnce(() => {
1451
1451
  this.initComplete = !0, c();
1452
1452
  });
1453
- }), this.engine.runRenderLoop(this.renderLoop);
1453
+ }), console.log(this.renderLoop);
1454
1454
  }
1455
1455
  getInitializationPromise() {
1456
1456
  return this.initPromise;
@@ -1479,13 +1479,6 @@ class Wt {
1479
1479
  t > -1 && this.modelLoadEventCallbacks.splice(t, 1);
1480
1480
  }
1481
1481
  registerView(e) {
1482
- if (this.registeredCanvases.includes(e)) {
1483
- console.warn(
1484
- "registerView has been called with a canvas that is already registered. You should call unregisterView first."
1485
- );
1486
- return;
1487
- }
1488
- this.registeredCanvases.push(e);
1489
1482
  const t = e.height, i = e.width;
1490
1483
  this.engine.registerView(e, void 0, !0), e.setAttribute("height", t.toString()), e.setAttribute("width", i.toString()), this.orbitEnabled() || this.setCameraState(I.Pan), this.reattachControls(e);
1491
1484
  }
@@ -1494,11 +1487,7 @@ class Wt {
1494
1487
  return ((e = this.engine.views) == null ? void 0 : e.length) || 0;
1495
1488
  }
1496
1489
  unregisterView(e) {
1497
- this.registeredCanvases.includes(e) || console.warn(
1498
- "unregisterView has been called with a canvas that has not been registered."
1499
- ), this.registeredCanvases = this.registeredCanvases.filter(
1500
- (t) => t !== e
1501
- ), this.engine.unRegisterView(e);
1490
+ this.engine.unRegisterView(e);
1502
1491
  }
1503
1492
  shutdown() {
1504
1493
  this.plugins.forEach((e) => e.dispose(!0)), this.renderingPipeline.dispose(), this.engine && this.engine.dispose(), window.removeEventListener("resize", this.fireResizeEvent);
@@ -1554,9 +1543,9 @@ class Wt {
1554
1543
  this.isAnimatingCamera = !0, await new Promise((i) => {
1555
1544
  this.focusLostNotified = !1;
1556
1545
  const r = () => {
1557
- const s = this.configuration;
1546
+ const n = this.configuration;
1558
1547
  this.camera.rerunFramingBehavior(() => {
1559
- s.camera.limits.min.radius && (this.camera.lowerRadiusLimit = s.camera.limits.min.radius), s.camera.limits.max.radius && (this.camera.upperRadiusLimit = s.camera.limits.max.radius), i();
1548
+ n.camera.limits.min.radius && (this.camera.lowerRadiusLimit = n.camera.limits.min.radius), n.camera.limits.max.radius && (this.camera.upperRadiusLimit = n.camera.limits.max.radius), i();
1560
1549
  });
1561
1550
  };
1562
1551
  this.scene.onAfterRenderObservable.addOnce(r);
@@ -1590,8 +1579,8 @@ class Wt {
1590
1579
  this.scene
1591
1580
  );
1592
1581
  try {
1593
- const r = t.latDeg * Math.PI / 180, s = t.lonDeg * Math.PI / 180;
1594
- i.target = t.target ? new p(t.target.x, t.target.y, t.target.z) : p.Zero(), i.alpha = s, i.beta = r, i.radius = t.radius || this.camera.radius, i.minZ = 0.01, this.scene.render();
1582
+ const r = t.latDeg * Math.PI / 180, n = t.lonDeg * Math.PI / 180;
1583
+ i.target = t.target ? new p(t.target.x, t.target.y, t.target.z) : p.Zero(), i.alpha = n, i.beta = r, i.radius = t.radius || this.camera.radius, i.minZ = 0.01, this.scene.render();
1595
1584
  const o = await Me.CreateScreenshotUsingRenderTargetAsync(
1596
1585
  this.engine,
1597
1586
  i,
@@ -1609,10 +1598,10 @@ class Wt {
1609
1598
  const e = this.configuration;
1610
1599
  if (!e)
1611
1600
  return !0;
1612
- const t = e.camera.limits.min.alpha, i = e.camera.limits.max.alpha, r = e.camera.limits.min.beta, s = e.camera.limits.max.beta;
1613
- if (t === void 0 || i === void 0 || r === void 0 || s === void 0)
1601
+ const t = e.camera.limits.min.alpha, i = e.camera.limits.max.alpha, r = e.camera.limits.min.beta, n = e.camera.limits.max.beta;
1602
+ if (t === void 0 || i === void 0 || r === void 0 || n === void 0)
1614
1603
  return !0;
1615
- const o = [t, i], a = [r, s], l = o.every((h) => h === t), c = a.every((h) => h === r);
1604
+ const o = [t, i], a = [r, n], l = o.every((h) => h === t), c = a.every((h) => h === r);
1616
1605
  return !l && !c;
1617
1606
  }
1618
1607
  fireResizeEvent() {
@@ -1626,9 +1615,9 @@ class Wt {
1626
1615
  blurHorizontalSize: 0.85
1627
1616
  }), this.highlightLayer.innerGlow = !0, this.highlightLayer.outerGlow = !1), this.highlightLayer.removeAllMeshes();
1628
1617
  const i = t ? new w(t[0], t[1], t[2]).toLinearSpace() : void 0;
1629
- e.forEach((s) => {
1618
+ e.forEach((n) => {
1630
1619
  const o = this.scene.materials.find(
1631
- (a) => a.name === s.name && a.id === s.id
1620
+ (a) => a.name === n.name && a.id === n.id
1632
1621
  );
1633
1622
  o && o.getBindedMeshes().forEach(
1634
1623
  (a) => {
@@ -1645,27 +1634,27 @@ class Wt {
1645
1634
  this.renderingPipeline && this.renderingPipeline.setConfiguration(e);
1646
1635
  }
1647
1636
  loadModel(e, t) {
1648
- const { refocusCamera: i = !0, progressHandler: r } = t ?? {}, s = new it({
1637
+ const { refocusCamera: i = !0, progressHandler: r } = t ?? {}, n = new it({
1649
1638
  enablePicking: this.configuration.highlights.enabled,
1650
1639
  modelDetails: e,
1651
1640
  scene: this.scene,
1652
1641
  previewService: this,
1653
1642
  progressHandler: r
1654
1643
  });
1655
- return s.getInitializationPromise().then(() => {
1644
+ return n.getInitializationPromise().then(() => {
1656
1645
  this.modelContainers.size <= 1 && i && (this.forceStopCameraAnimations(), this.camera.rerunFramingBehavior(() => {
1657
1646
  this.scene.onAfterRenderObservable.addOnce(() => {
1658
1647
  this.queuedCameraAnimation && (this.executeCameraAnimation(this.queuedCameraAnimation), this.queuedCameraAnimation = void 0);
1659
1648
  });
1660
1649
  }, 1));
1661
- }), this.configuration.highlights.enabled && (s.registerMaterialSelectedCallback((o) => {
1650
+ }), this.configuration.highlights.enabled && (n.registerMaterialSelectedCallback((o) => {
1662
1651
  this.setHighlights([o]);
1663
- }), s.registerMaterialDeselectedCallback(() => {
1652
+ }), n.registerMaterialDeselectedCallback(() => {
1664
1653
  this.setHighlights([]);
1665
- })), this.modelContainers.set(s.getId(), s), this.triggerModelLoadEvent({
1654
+ })), this.modelContainers.set(n.getId(), n), this.triggerModelLoadEvent({
1666
1655
  eventType: "load",
1667
- modelContainer: s
1668
- }), s;
1656
+ modelContainer: n
1657
+ }), n;
1669
1658
  }
1670
1659
  async preloadModel(e) {
1671
1660
  await D(e, this.scene);
@@ -1709,7 +1698,7 @@ class Wt {
1709
1698
  O(t || { x: 0, y: 0, z: 0 })
1710
1699
  ),
1711
1700
  O(e || { x: 0, y: 0, z: 0 })
1712
- ), s = re.RotationAxis(p.Up(), Math.PI), o = r.multiply(s), a = p.Zero(), l = y.Identity(), c = p.Zero();
1701
+ ), n = re.RotationAxis(p.Up(), Math.PI), o = r.multiply(n), a = p.Zero(), l = y.Identity(), c = p.Zero();
1713
1702
  return o.decompose(c, l, a), l.multiplyInPlace(y.FromEulerAngles(0, Math.PI, 0)), {
1714
1703
  position: L(a),
1715
1704
  rotation: L(l.toEulerAngles()),
@@ -1717,17 +1706,17 @@ class Wt {
1717
1706
  };
1718
1707
  }
1719
1708
  updatePreviewOptions(e) {
1720
- var r, s;
1709
+ var r, n;
1721
1710
  const t = new ce(e);
1722
1711
  this.configuration.highlights.enabled !== t.highlights.enabled && this.engine.setStencilBuffer(t.highlights.enabled), this.scene.clearColor = t.scene.clearColor;
1723
1712
  let i = this.scene.environmentTexture;
1724
- this.configuration.scene.environment.file !== t.scene.environment.file && (i = se.CreateFromPrefilteredData(
1713
+ this.configuration.scene.environment.file !== t.scene.environment.file && (i = ne.CreateFromPrefilteredData(
1725
1714
  t.scene.environment.file,
1726
1715
  this.scene
1727
1716
  ), i.rotationY = this.configuration.scene.environment.rotationY, this.scene.environmentTexture = i), i.rotationY = t.scene.environment.rotationY, this.scene.environmentIntensity = t.scene.environment.intensity, (r = t.options) != null && r.renderingPipelineConfiguration ? this.renderingPipeline.setConfiguration(
1728
1717
  t.options.renderingPipelineConfiguration
1729
1718
  ) : (this.scene.imageProcessingConfiguration.exposure = t.lighting.exposure, this.scene.imageProcessingConfiguration.contrast = t.lighting.contrast), this.glowLayerManager.setIntensity(t.emissiveGlowIntensity), this.camera.updateConfiguration(t), this.camera.setPanEnabled(
1730
- ((s = t.options) == null ? void 0 : s.noPan) !== void 0 ? !t.options.noPan : !0
1719
+ ((n = t.options) == null ? void 0 : n.noPan) !== void 0 ? !t.options.noPan : !0
1731
1720
  ), this.scene.autoClear = !0, this.scene.autoClearDepthAndStencil = !0, this.configuration = t;
1732
1721
  }
1733
1722
  /**
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- (function(c,y){typeof exports=="object"&&typeof module<"u"?y(exports,require("@babylonjs/core/Cameras/arcRotateCamera"),require("@babylonjs/core/Engines/engine"),require("@babylonjs/core/Engines/nullEngine"),require("@babylonjs/core/Layers/highlightLayer"),require("@babylonjs/core/Loading/sceneLoader"),require("@babylonjs/core/Materials/Textures/cubeTexture"),require("@babylonjs/core/Maths/math.color"),require("@babylonjs/core/Maths/math.vector"),require("@babylonjs/core/Meshes/Compression/dracoCompression"),require("@babylonjs/core/Misc/observable"),require("@babylonjs/core/Misc/tools"),require("@babylonjs/core/scene"),require("@babylonjs/loaders/glTF"),require("@babylonjs/loaders/glTF/glTFFileLoader"),require("@babylonjs/core/Materials/PBR/pbrMaterial"),require("@babylonjs/core/Materials/Textures/mirrorTexture"),require("@babylonjs/core/Maths/math"),require("@babylonjs/core/Probes/reflectionProbe"),require("@babylonjs/core/Layers/glowLayer"),require("@babylonjs/core/Actions/actionManager"),require("@babylonjs/core/Actions/directActions"),require("@babylonjs/core/Meshes/mesh"),require("@babylonjs/core/Meshes/transformNode"),require("@babylonjs/core/Materials/Textures/dynamicTexture"),require("@babylonjs/core/Materials/Textures/texture"),require("@babylonjs/core/Animations/animation"),require("@babylonjs/core/Animations/easing"),require("@babylonjs/core/Misc/assetsManager"),require("@babylonjs/core/Materials/colorCurves"),require("@babylonjs/core/Materials/imageProcessingConfiguration"),require("@babylonjs/core/PostProcesses/RenderPipeline"),require("@babylonjs/core/PostProcesses/depthOfFieldEffect"),require("@babylonjs/core/Rendering/depthRendererSceneComponent"),require("@babylonjs/core/Engines/Extensions/engine.views"),require("@babylonjs/core/Meshes/instancedMesh"),require("@babylonjs/core/Materials/Textures/Loaders/ddsTextureLoader"),require("@babylonjs/core/Materials/Textures/Loaders/envTextureLoader"),require("@babylonjs/core/Materials/Textures/Loaders/ktxTextureLoader"),require("@babylonjs/core/Animations/animatable"),require("@babylonjs/core/Misc/screenshotTools"),require("@babylonjs/core/Rendering/boundingBoxRenderer"),require("@babylonjs/loaders/glTF/2.0/Extensions")):typeof define=="function"&&define.amd?define(["exports","@babylonjs/core/Cameras/arcRotateCamera","@babylonjs/core/Engines/engine","@babylonjs/core/Engines/nullEngine","@babylonjs/core/Layers/highlightLayer","@babylonjs/core/Loading/sceneLoader","@babylonjs/core/Materials/Textures/cubeTexture","@babylonjs/core/Maths/math.color","@babylonjs/core/Maths/math.vector","@babylonjs/core/Meshes/Compression/dracoCompression","@babylonjs/core/Misc/observable","@babylonjs/core/Misc/tools","@babylonjs/core/scene","@babylonjs/loaders/glTF","@babylonjs/loaders/glTF/glTFFileLoader","@babylonjs/core/Materials/PBR/pbrMaterial","@babylonjs/core/Materials/Textures/mirrorTexture","@babylonjs/core/Maths/math","@babylonjs/core/Probes/reflectionProbe","@babylonjs/core/Layers/glowLayer","@babylonjs/core/Actions/actionManager","@babylonjs/core/Actions/directActions","@babylonjs/core/Meshes/mesh","@babylonjs/core/Meshes/transformNode","@babylonjs/core/Materials/Textures/dynamicTexture","@babylonjs/core/Materials/Textures/texture","@babylonjs/core/Animations/animation","@babylonjs/core/Animations/easing","@babylonjs/core/Misc/assetsManager","@babylonjs/core/Materials/colorCurves","@babylonjs/core/Materials/imageProcessingConfiguration","@babylonjs/core/PostProcesses/RenderPipeline","@babylonjs/core/PostProcesses/depthOfFieldEffect","@babylonjs/core/Rendering/depthRendererSceneComponent","@babylonjs/core/Engines/Extensions/engine.views","@babylonjs/core/Meshes/instancedMesh","@babylonjs/core/Materials/Textures/Loaders/ddsTextureLoader","@babylonjs/core/Materials/Textures/Loaders/envTextureLoader","@babylonjs/core/Materials/Textures/Loaders/ktxTextureLoader","@babylonjs/core/Animations/animatable","@babylonjs/core/Misc/screenshotTools","@babylonjs/core/Rendering/boundingBoxRenderer","@babylonjs/loaders/glTF/2.0/Extensions"],y):(c=typeof globalThis<"u"?globalThis:c||self,y(c.Preview={},c.arcRotateCamera,c.engine,c.nullEngine,c.highlightLayer,c.sceneLoader,c.cubeTexture,c.math_color,c.math_vector,c.dracoCompression,c.observable,c.tools,c.scene,c.glTF,c.glTFFileLoader,c.pbrMaterial,c.mirrorTexture,c.math,c.reflectionProbe,c.glowLayer,c.actionManager,c.directActions,c.mesh,c.transformNode,c.dynamicTexture,c.texture,c.animation,c.easing,c.assetsManager,c.colorCurves,c.imageProcessingConfiguration,c.RenderPipeline,c.depthOfFieldEffect))})(this,function(c,y,V,ye,Ce,L,k,b,p,we,M,Me,xe,Ae,Pe,O,Te,A,Re,Ee,F,z,Le,Oe,Fe,Ie,C,N,Se,G,P,Be,I){"use strict";var T=(n=>(n[n.Orbit=0]="Orbit",n[n.Pan=1]="Pan",n))(T||{}),R=(n=>(n.None="None",n.RemoveWhenSelected="RemoveWhenSelected",n.ApplyWhenSelected="ApplyWhenSelected",n))(R||{});const H=new Map;async function S(n,e,t){const i=H.get(n);if(i)return i;{const r=L.SceneLoader.LoadAssetContainerAsync(n,void 0,e,t);return H.set(n,r),r}}L.SceneLoader.OnPluginActivatedObservable.add(n=>{n.name==="gltf"&&(n.animationStartMode=Pe.GLTFLoaderAnimationStartMode.NONE)});class K{constructor(e){this.getSceneClearColor=()=>{var i,r,s,o;const t=(i=this.customOptions)!=null&&i.transparentBackground||(r=this.customOptions)!=null&&r.backgroundImage?0:1;if(this.customOptions&&((s=this.customOptions)!=null&&s.transparentBackground)||(o=this.customOptions)!=null&&o.backgroundImage)return new b.Color4(0,0,0,t).toLinearSpace();if(this.customOptions&&this.customOptions.backgroundColor){const a=b.Color3.FromHexString(this.customOptions.backgroundColor);return new b.Color4(a.r,a.g,a.b,t).toLinearSpace()}return new b.Color4(.98,.98,.98,t).toLinearSpace()},this.highlightColorFromConfig=()=>this.customOptions&&this.customOptions.highlightColor?this.hexToColor4(this.customOptions.highlightColor):new b.Color4(.98,.98,.98,1).toLinearSpace(),this.hexToColor4=(t,i=1)=>{const r=b.Color3.FromHexString(t);return new b.Color4(r.r,r.g,r.b,i).toLinearSpace()},this.customOptions=e}createCanvas(){var e;return(e=this.customOptions)!=null&&e.createCanvas?this.customOptions.createCanvas():document.createElement("canvas")}get options(){return this.customOptions}get scene(){var e,t,i,r,s;return{clearColor:this.getSceneClearColor(),transparentBackground:((e=this.customOptions)==null?void 0:e.transparentBackground)||((t=this.customOptions)==null?void 0:t.backgroundImage),environment:{file:((i=this.customOptions)==null?void 0:i.environmentFile)??"assets/model-viewer/default.env",intensity:((r=this.customOptions)==null?void 0:r.environmentIntensity)??1,rotationY:(((s=this.customOptions)==null?void 0:s.environmentRotationY)??0)*(Math.PI/180)}}}get camera(){var e,t,i,r,s,o,a,l,d,h,g,m,f;return{autoOrientation:((e=this.customOptions)==null?void 0:e.disableAutomaticOrientation)??!0,autoRotation:{enabled:((t=this.customOptions)==null?void 0:t.autoRotation)??!1,idleTimeMs:((i=this.customOptions)==null?void 0:i.idleTimeBeforeRotation)??5e3},limits:{min:{alpha:(r=this.customOptions)!=null&&r.lowerAlphaLimitDeg?((s=this.customOptions)==null?void 0:s.lowerAlphaLimitDeg)*Math.PI/180:void 0,beta:(o=this.customOptions)!=null&&o.lowerBetaLimitDeg?((a=this.customOptions)==null?void 0:a.lowerBetaLimitDeg)*Math.PI/180:void 0,radius:(l=this.customOptions)==null?void 0:l.minZoomOverride},max:{alpha:(d=this.customOptions)!=null&&d.upperAlphaLimitDeg?((h=this.customOptions)==null?void 0:h.upperAlphaLimitDeg)*Math.PI/180:void 0,beta:(g=this.customOptions)!=null&&g.upperBetaLimitDeg?((m=this.customOptions)==null?void 0:m.upperBetaLimitDeg)*Math.PI/180:void 0,radius:(f=this.customOptions)==null?void 0:f.maxZoomOverride}}}}get highlights(){var e;return{enabled:((e=this.customOptions)==null?void 0:e.highlightOnMaterialHover)??!1,color:this.highlightColorFromConfig()}}get lighting(){var e,t,i,r;return{exposure:((t=(e=this.customOptions)==null?void 0:e.lighting)==null?void 0:t.exposure)??.9,contrast:((r=(i=this.customOptions)==null?void 0:i.lighting)==null?void 0:r.contrast)??1.6}}get emissiveGlowIntensity(){var e;return((e=this.customOptions)==null?void 0:e.emissiveGlowIntensity)??.5}}class w{static getDynamicTextureResolution(){return this.getIsMobile()||!w.offscreenRenderingSupported()?{width:1024,height:1024}:{width:2048,height:2048}}static shouldMipMap(){return!0}static offscreenRenderingSupported(){return navigator.userAgent.includes("SamsungBrowser")?!1:!!window.Worker&&!!window.OffscreenCanvas}static getMirrorTextureResolution(){return this.getIsMobile()?512:1024}static getIsMobile(){try{return typeof window>"u"||!window.navigator?!1:/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(window.navigator.userAgent)||window.innerWidth/window.devicePixelRatio<=480}catch{return!1}}}const U=128,u={antiAliasing:{samples:4,fxaaEnabled:!1},bloom:{enabled:!1,kernel:64,scale:.5,threshold:.9,weight:.15},chromaticAberration:{enabled:!1,aberrationAmount:30,direction:{x:0,y:0},radialIntensity:0},colorCurves:{enabled:!1},depthOfField:{enabled:!1,blurLevel:"Low",focalLength:50,focusDistance:2e3,fStop:1.4,lensSize:50},grain:{enabled:!1,animated:!1,intensity:30},misc:{contrast:1,exposure:1,toneMappingEnabled:!1,toneMappingType:"Standard"},sharpen:{enabled:!1,colorAmount:1,edgeAmount:.3},vignette:{enabled:!1,blendMode:"Multiply",cameraFov:.5,center:{x:0,y:0},colorHex:"#000000ff",colorRgba:{r:0,g:0,b:0,a:1},stretch:0,weight:1}};class je{constructor(e){this.name="glbPostProcessor",this.enabled=!0,this.loader=e}onReady(){this.applyReflections(this.loader.babylonScene)}loadNodeAsync(e,t,i){return this.loader.loadNodeAsync(e,t,function(r){t.extras&&Object.keys(t.extras).forEach(s=>{const o=t.extras[s];r.metadata[s]=o}),i(r)})}async loadMaterialPropertiesAsync(e,t,i){await this.loader.loadMaterialPropertiesAsync(e,t,i),this.enableMaterialExtrasIfRequired(t,i),i.needDepthPrePass=!0}dispose(){}enableMaterialExtrasIfRequired(e,t){if(!(!e.extras||!(t instanceof O.PBRMaterial))){if(e.extras.sheen){const i=t;i.sheen.isEnabled=!0,i.sheen.intensity=e.extras.sheen}if(e.extras.translucency){const i=t;i.subSurface.isTranslucencyEnabled=!0,i.subSurface.translucencyIntensity=e.extras.translucency,e.extras.translucencyR&&e.extras.translucencyG&&e.extras.translucencyB&&(i.subSurface.tintColor=new A.Color3(e.extras.translucencyR,e.extras.translucencyG,e.extras.translucencyB))}if(e.extras.refractionIOR){const i=t;i.subSurface.isRefractionEnabled=!0,i.subSurface.volumeIndexOfRefraction=e.extras.refractionIOR}if(e.extras.useDepthPrePass){const i=t;i.needDepthPrePass=!0,i.forceIrradianceInFragment=!0}if(e.extras.useParallax){const i=t;i.useParallax=!0,i.useParallaxOcclusion=!0,i.parallaxScaleBias=e.extras.useParallax}}}applyReflections(e){function t(s){const o=[];return s.transformNodes.forEach(a=>{a.metadata&&a.metadata.reflective&&o.push(...a.getChildMeshes())}),s.meshes.forEach(a=>{a.metadata&&a.metadata.reflective&&!o.includes(a)&&o.push(a)}),o}function i(s,o=1){const a=s.material;if(!a)return;const l=new Te.MirrorTexture("mirror",w.getMirrorTextureResolution(),e,!0);l.renderList=t(e);const d=s.getVerticesData("normal");if(!d)throw new Error("Mirror attribute specified on: "+s.name+"But no normals exist to generate a mirror from!");s.computeWorldMatrix(!0);const h=s.getWorldMatrix(),g=A.Vector3.TransformNormal(new A.Vector3(d[0],d[1],d[2]),h).normalize(),m=A.Plane.FromPositionAndNormal(s.position,g.scale(-1));l.mirrorPlane=m,l.level=o,a.reflectionTexture=l}function r(s){const o=s.material,a=new Re.ReflectionProbe("probe-"+o.name,U,e);a.attachToMesh(s),a.renderList&&a.renderList.push(...t(e)),o.reflectionTexture=a.cubeTexture}e.meshes.forEach(s=>{const o=s.metadata;o&&(o.mirrorTexture&&i(s,o.mirrorTexture),o.reflectionProbe&&r(s))})}}class qe{constructor(e,t){this.scene=e,this.intensity=t,this.meshCount=0}setIntensity(e){this.intensity=e,this.glowLayer&&(this.glowLayer.intensity=e)}includeMeshes(e){if(e){this.glowLayer||(this.glowLayer=new Ee.GlowLayer("glow",this.scene),this.glowLayer.intensity=this.intensity);for(const t of e)this.glowLayer.hasMesh(t)||(this.glowLayer.addIncludedOnlyMesh(t),this.meshCount++)}}removeMeshes(e){if(!(!this.glowLayer||!e)){for(const t of e)this.glowLayer.hasMesh(t)&&(this.glowLayer.removeIncludedOnlyMesh(t),this.meshCount--);this.meshCount===0&&(this.glowLayer.dispose(),this.glowLayer=void 0)}}}function De(n,e,t,i,r=""){t.forEach(s=>{const o=s.getID(),a=s.getName(),l=w.getDynamicTextureResolution();n.filter(h=>h.name===r+a).forEach(h=>{const g=i.get(o),m=!1;if(g)W(h,g),g.update(m);else{const f=Ve(a,e,l.width,l.height);i.set(o,f),s.setStaticContext(f.getContext()),W(h,f),f.onLoadObservable.addOnce(()=>{f.update(m)})}})})}function Ve(n,e,t,i){const r=new Fe.DynamicTexture(n,{width:t,height:i},e,w.shouldMipMap(),Ie.Texture.TRILINEAR_SAMPLINGMODE,V.Engine.TEXTUREFORMAT_RGBA),s=r.getContext();return s&&(s.fillStyle="#f5f5f5",s.fillRect(0,0,t,i),r.update()),r}function W(n,e){if(n instanceof O.PBRMaterial){const t=n,i=t.albedoTexture;i?(e.wrapU=i.wrapU,e.wrapV=i.wrapV):(e.wrapU=1,e.wrapV=1),t.albedoTexture=e}else{const t=n,i=t.diffuseTexture;i&&(e.wrapU=i.wrapU,e.wrapV=i.wrapV),t.diffuseTexture=e}}function ke(){const n=()=>Math.floor((1+Math.random())*65536).toString(16).substring(1);return n()+n()+"-"+n()+"-"+n()+"-"+n()+"-"+n()+n()+n()}const x=60,Q=1;function Y(n){return n.targetedAnimations.map(t=>t.animation.framePerSecond).reduce((t,i)=>t+i,0)/n.targetedAnimations.length||0}function Z(n,e,t,i,r,s){const o=r?n.filter(h=>h.name===r):n;if(o.length===0){console.warn(`No animations found for name: ${r}`);return}let a=0;const l=()=>{a++,a===o.length&&s&&s()},d=(h,g,m,f,v)=>{h.stop(),h.start(g,m,f,v),s&&(g==!1||g===void 0&&!h.loopAnimation?h.onAnimationGroupEndObservable.addOnce(()=>{l()}):h.onAnimationLoopObservable.addOnce(()=>{l()}))};if(i!==void 0&&t!==void 0&&i===t){o.forEach(h=>{const g=Y(h),m=i*g;d(h,!1,Q,m,m)});return}o.forEach(h=>{const g=Y(h),m=i!==void 0?i*g:void 0,f=t!==void 0?t*g:void 0;d(h,e,Q,m,f)})}function ze(n,e,t){return new Promise(i=>{n.stopAnimation(e),e.animations=[],Math.abs(e.alpha)>2*Math.PI&&(e.alpha=Ne(e.alpha,0,2*Math.PI));const r=[],s=t.target,o=0,a=s?1:0;if(t.target&&Object.keys(t.target).length>0&&r.push(E("cameraTargetLerp","target",new p.Vector3().copyFrom(e.target),new p.Vector3(t.target.x,t.target.y,t.target.z),C.Animation.ANIMATIONTYPE_VECTOR3,o)),r.push(E("cameraAlphaLerp","alpha",e.alpha,$(t.lonDeg),C.Animation.ANIMATIONTYPE_FLOAT,a)),r.push(E("cameraBetaLerp","beta",e.beta,$(t.latDeg),C.Animation.ANIMATIONTYPE_FLOAT,a)),t.radius!==void 0){const h=Math.max(.01,t.radius);r.push(E("cameraRadiusLerp","radius",e.radius,h,C.Animation.ANIMATIONTYPE_FLOAT,a))}e.animations.push(...r);const d=e.useAutoRotationBehavior;e.disableAutoRotationBehavior(),n.beginAnimation(e,0,s?x*2:x,!1,1,()=>{e.animations=[],d&&e.enableAutoRotationBehavior(),i()})})}function $(n){return n*Math.PI/180}function E(n,e,t,i,r,s=0,o=C.Animation.ANIMATIONLOOPMODE_CONSTANT){const a=new N.QuadraticEase;a.setEasingMode(N.EasingFunction.EASINGMODE_EASEINOUT);const l=new C.Animation(n,e,x,r,o),d=[];return s>0&&d.push({frame:0,value:t}),d.push({frame:x*s,value:t}),d.push({frame:x*(s+1),value:i}),l.setKeys(d),l.setEasingFunction(a),l}function Ne(n,e,t){return n<e?n=t-(e-n)%(t-e):n=e+(n-e)%(t-e)}function Ge(n,e,t){n.forEach(i=>{t&&i.name!==t||i.goToFrame(e)})}const He={albedoTexture:"albedoMap",bumpTexture:"normalMap",ambientTexture:"ambientMap",emissiveTexture:"emissionMap",opacityTexture:"alphaMap",metallicTexture:"metallicMap",refractionTexture:"refractionMap",reflectionTexture:"reflectionMap"};function Ke(n,e,t,i){["albedoTexture","bumpTexture","ambientTexture","emissiveTexture","opacityTexture","metallicTexture","refractionTexture","reflectionTexture"].forEach(s=>{Ue(s,n,e,t,i)}),Ye(n,e)}function Ue(n,e,t,i,r){const s=He[n];if(!s)throw new Error("Unexpected texture name encountered.");const o=e[s],a=o==null?void 0:o.fileLink;a?n==="reflectionTexture"?a.endsWith(".env")||a.endsWith(".dds")?i.addCubeTextureTask(n,a,void 0,!1,void 0,!0):a.endsWith(".hdr")?i.addHDRCubeTextureTask(n,a,128,!1,!0,!1):i.addTextureTask(n,a,!1,!1):i.addTextureTask(n,a,!1,!1):r&&t[n]&&(t[n]&&t[n].dispose(),t[n]=null,We(n,t))}function We(n,e){n==="opacityTexture"&&(e.useAlphaFromAlbedoTexture=!0),n==="metallicTexture"&&(e.useRoughnessFromMetallicTextureAlpha=!1,e.useRoughnessFromMetallicTextureGreen=!1,e.useMetallnessFromMetallicTextureBlue=!1),n==="refractionTexture"&&(e.subSurface.isRefractionEnabled=!1,e.subSurface.refractionIntensity=1),n==="reflectionTexture"&&(e.environmentIntensity=1),n==="emissiveTexture"&&(e.emissiveIntensity=0,e.emissiveColor=new b.Color3(0,0,0),e.reflectionTexture)}function Qe(n,e,t,i){if(!e){console.error("Failed to apply texture to material: material is null.");return}n==="opacityTexture"&&(e.useAlphaFromAlbedoTexture=!1),n==="metallicTexture"&&(e.useRoughnessFromMetallicTextureAlpha=!1,e.useRoughnessFromMetallicTextureGreen=!0,e.useMetallnessFromMetallicTextureBlue=!0),n==="refractionTexture"&&(e.subSurface.isRefractionEnabled=!0,e.subSurface.refractionIntensity=t.refractionIntensity||1),n==="reflectionTexture"&&(e.environmentIntensity=t.reflectionIntensity||1,i.isCube&&(i.rotationY=t.reflectionRotation?t.reflectionRotation*Math.PI/180:0)),e[n]=i,n==="emissiveTexture"&&(e.emissiveColor=new b.Color3(1,1,1),e.emissiveIntensity=1)}function Ye(n,e){n.clearCoat&&(n.clearCoat===R.RemoveWhenSelected?(e.clearCoat.isEnabled=!1,e.clearCoat.indexOfRefraction=1.5):n.clearCoat===R.ApplyWhenSelected&&(e.clearCoat.isEnabled=!0,e.clearCoat.indexOfRefraction=n.clearCoatIOR||e.clearCoat.indexOfRefraction))}class Ze{constructor(e,t,i){this.materialVariantMap=new Map,this.keysThatRemovedBaseModel=[],this.loadedContainerForKey=new Map,this.loadedMaterialsForKey=new Map,this.scene=e,this.renameClonedAsset=t,this.setBaseModelEnabled=i}async applyMaterial(e,t,i,r){return new Promise(s=>{const o=this.materialVariantMap.get(e);this.materialVariantMap.set(e,{...o,...t});const a=this.renameClonedAsset(e),l=this.scene.materials.filter(h=>h.name===a);if(l.length===0){s();return}const d=new Se.AssetsManager(this.scene);d.useDefaultLoadingScreen=!1,l.forEach(h=>Ke(t,h,d,r)),d.onProgress=(h,g,m)=>{i&&i(h/g*100,100,m.name)},d.onFinish=h=>{h.forEach(g=>{const m=g;i&&i(100,100,g.name),this.scene.materials.filter(v=>v.name===a).forEach(v=>Qe(g.name,v,t,m.texture))}),s()},d.loadAsync()})}async applyModel(e,t,i,r,s,o,a){var g;if(i&&t&&!this.keysThatRemovedBaseModel.includes(e)&&this.keysThatRemovedBaseModel.push(e),!i)return this.keysThatRemovedBaseModel.includes(e)&&this.keysThatRemovedBaseModel.length===1&&await this.setBaseModelEnabled(!0),(g=this.loadedContainerForKey.get(e))==null||g.dispose(),this.loadedContainerForKey.delete(e),this.loadedMaterialsForKey.delete(e),this.keysThatRemovedBaseModel=this.keysThatRemovedBaseModel.filter(m=>m!==e),Promise.resolve(void 0);const d=(await S(i,this.scene,r)).instantiateModelsToScene(this.renameClonedAsset,!0);if(this.loadedContainerForKey.has(e)&&(this.loadedContainerForKey.get(e).dispose(),this.loadedContainerForKey.delete(e),this.loadedMaterialsForKey.delete(e)),s){const m=o&&o(),f=s.name?this.renameClonedAsset(s.name):void 0;if(Z(d.animationGroups,s.loop,s.to,s.from,f),m!=null){const v=a&&a()||!0;Ge(d.animationGroups,m+(v?2:0),f)}}t&&await this.setBaseModelEnabled(!1),this.loadedContainerForKey.set(e,d),this.loadedMaterialsForKey.set(e,X(d));const h=[];return this.materialVariantMap.forEach(async(m,f)=>{h.push(this.applyMaterial(f,m))}),await Promise.all(h),d}dispose(){this.loadedContainerForKey.forEach(e=>e==null?void 0:e.dispose()),this.loadedContainerForKey.clear(),this.loadedMaterialsForKey.forEach(e=>e.forEach(t=>t==null?void 0:t.dispose())),this.loadedMaterialsForKey.clear(),this.materialVariantMap.clear(),this.keysThatRemovedBaseModel=[]}getAllMaterials(){const e=[];return this.loadedMaterialsForKey.forEach(t=>{t.forEach(i=>{e.includes(i)||e.push(i)})}),e}getAnimationGroups(){const e=[];return this.loadedContainerForKey.forEach(t=>{e.push(...t.animationGroups)}),e}}function X(n){const e=[];return n.rootNodes.forEach(t=>{t.getChildMeshes().forEach(i=>{i.material&&!e.includes(i.material)&&e.push(i.material),i.subMeshes&&i.subMeshes.forEach(r=>{const s=r.getMaterial(!1);s&&!e.includes(s)&&e.push(s)})})}),e}function J(n,e=""){return n.map(t=>({name:t.name.substring(e.length),loop:t.loopAnimation,to:t.to,from:t.from}))}class $e{constructor(e){this.metadata=new Map,this.materialSelectedObservable=new M.Observable,this.materialDeselectedObservable=new M.Observable,this.materialVariantObservable=new M.Observable,this.modelVariantObservable=new M.Observable,this.materialReadyToLoadCallbacks=new Map,this.modelReadyToLoadCallbacks=new Map,this.dynamicTextures=new Map,this.queuedMaterialChanges=new Map,this.materialChangesInProgress=[],this.queuedModelChanges=new Map,this.modelChangesInProgress=[],this.isExecutingAnimation=!1,this.animations=[],this.initialized=!1,this.materials=[];const{enablePicking:t,modelDetails:i,previewService:r,progressHandler:s,scene:o}=e;this.enablePicking=t,this.contextService=i.contextService,this.id=ke(),this.previewService=r,this.scene=o,this.variantManager=new Ze(o,this.renameClonedAsset.bind(this),this.setBaseModelEnabled.bind(this)),this.transformRoot=new Oe.TransformNode("root",this.scene);const a=async()=>{if(!i.model)throw new Error("Model container constructed with no URL. This is currently unsupported.");return this.assetContainer=await S(i.model,o,s),await this.instantiate(),this};this.importPromise=a()}async applyMaterialVariant(e,t,i,r){if(!this.initialized){if(this.materialReadyToLoadCallbacks.has(e)){const o=this.materialReadyToLoadCallbacks.get(e);o==null||o.set(t,this.applyMaterialVariant.bind(this,e,t,i,r))}else{this.materialReadyToLoadCallbacks.set(e,new Map);const o=this.materialReadyToLoadCallbacks.get(e);o==null||o.set(t,this.applyMaterialVariant.bind(this,e,t,i,r))}return}const s=async()=>{await this.variantManager.applyMaterial(e,i,(o,a,l)=>{this.materialVariantObservable.notifyObservers({remainingCount:o,totalCount:a,taskName:l})},r)};if(this.materialChangesInProgress.includes(e)){if(this.queuedMaterialChanges.has(e)){const o=this.queuedMaterialChanges.get(e);o==null||o.set(t,s)}else{this.queuedMaterialChanges.set(e,new Map);const o=this.queuedMaterialChanges.get(e);o==null||o.set(t,s)}return}if(this.materialChangesInProgress.push(e),await s(),this.queuedMaterialChanges.has(e)){const o=this.queuedMaterialChanges.get(e);if(!o)throw new Error("Target material is undefined");o.forEach(async a=>{await a()}),this.queuedMaterialChanges.delete(e)}this.materialChangesInProgress.splice(this.materialChangesInProgress.indexOf(e),1),this.configureGlowLayer()}async applyModelVariant(e,t,i){if(!this.initialized){this.modelReadyToLoadCallbacks.set(e,this.applyModelVariant.bind(this,e,t,i));return}const r=()=>this.variantManager.applyModel(e,i,t==null?void 0:t.model,a=>{this.modelVariantObservable.notifyObservers({...a,key:e})},this.lastPlayedAnimation,this.getCurrentAnimationFrame.bind(this),this.getAnimationIsPlaying.bind(this));if(this.modelChangesInProgress.includes(e)){this.queuedModelChanges.set(e,r);return}const o=await(async()=>{this.modelChangesInProgress.push(e);let a=await r();if(this.queuedModelChanges.has(e)){const l=this.queuedModelChanges.get(e);if(!l)throw new Error("Queued change resolved undefined");a=await l(),this.queuedModelChanges.delete(e)}return this.modelChangesInProgress.splice(this.modelChangesInProgress.indexOf(e),1),a})();this.contextService||(this.contextService=t==null?void 0:t.contextService),o?this.configureModelInstance(o):this.configureGlowLayer()}dispose(){var e;this.destroyInstance(),this.variantManager.dispose(),this.dynamicTextures.forEach(t=>t==null?void 0:t.dispose()),this.dynamicTextures.clear(),this.materials.forEach(t=>t&&(t==null?void 0:t.dispose())),this.materials=[],(e=this.transformRoot)==null||e.dispose(),this.transformRoot=void 0,this.previewService.modelUnloaded(this)}executeAnimation(e){if(!this.initialized)return this.queuedModelAnimation=e,Promise.resolve();let t=()=>{};const i=async()=>{this.lastPlayedAnimation=e,this.isExecutingAnimation=!0,await new Promise(r=>{var o;const s=[...((o=this.modelInstance)==null?void 0:o.animationGroups)||[],...this.variantManager.getAnimationGroups()];Z(s,e.loop,e.to,e.from,e.name?this.renameClonedAsset(e.name):void 0,r)}),this.isExecutingAnimation=!1,this.queuedAnimationFunction&&this.queuedAnimationFunction(),this.queuedAnimationFunction=void 0,t()};return this.isExecutingAnimation?(this.queuedAnimationFunction=i,new Promise(r=>{t=r})):i()}getAnimations(e){return[...this.animations,...e?J(this.variantManager.getAnimationGroups(),this.renameClonedAsset("")):[]]}getId(){return this.id}listMaterials(){var t;const e=(t=this.scene)==null?void 0:t.materials.filter(i=>i.name.startsWith(this.id));return e?e.map(i=>({id:i.id,name:this.stripIdFromName(i.name)})):[]}registerMaterialSelectedCallback(e){this.materialSelectedObservable.add(e)}unregisterMaterialSelectedCallback(e){this.materialSelectedObservable.removeCallback(e)}registerMaterialDeselectedCallback(e){this.materialDeselectedObservable.add(e)}unregisterMaterialDeselectedCallback(e){this.materialDeselectedObservable.removeCallback(e)}get position(){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to requesting position!");return this.transformRoot.position}set position(e){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to setting position!");this.transformRoot.position=new p.Vector3(e.x,e.y,e.z)}get rotation(){var e;if(!((e=this.transformRoot)!=null&&e.rotationQuaternion))throw new Error("ModelContainer disposed prior to requesting rotation!");return this.transformRoot.rotationQuaternion.toEulerAngles()}set rotation(e){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to setting rotation!");this.transformRoot.rotationQuaternion=p.Quaternion.FromEulerAngles(e.x,e.y,e.z)}get scale(){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to requesting scale!");return this.transformRoot.scaling}set scale(e){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to setting scale!");this.transformRoot.scaling=new p.Vector3(e.x,e.y,e.z)}attachPickingHandler(e){e.rootNodes.forEach(t=>{t.getChildMeshes(!1).forEach(i=>{i.name==="targetcube_t"||i.name==="backgroundShell"||(i.actionManager||(i.actionManager=new F.ActionManager(this.scene)),i.actionManager.registerAction(new z.ExecuteCodeAction(F.ActionManager.OnPointerOverTrigger,r=>{r.meshUnderPointer&&i.material&&this.materialSelectedObservable.notifyObservers({id:i.material.id,name:this.stripIdFromName(i.material.name)})})),i.actionManager.registerAction(new z.ExecuteCodeAction(F.ActionManager.OnPointerOutTrigger,()=>{i.material&&this.materialDeselectedObservable.notifyObservers({id:i.material.id,name:this.stripIdFromName(i.material.name)})})))})})}getInitializationPromise(){return this.importPromise}getIsInitialized(){return this.initialized}getQueuedMaterialVariantCount(){return this.materialReadyToLoadCallbacks.size}getQueuedModelVariantCount(){return this.modelReadyToLoadCallbacks.size}configureGlowLayer(){const e=i=>i instanceof O.PBRMaterial&&i.emissiveTexture!==null;this.materials.some(e)||this.variantManager.getAllMaterials().some(e)?this.previewService.getGlowLayerManager().includeMeshes(this.getAllMeshes()):this.previewService.getGlowLayerManager().removeMeshes(this.getAllMeshes())}configureModelInstance(e){var s;if(!this.transformRoot)throw new Error("Transform disposed! This should never happen unless there is a race condition present!");const t=this.transformRoot.position,i=this.transformRoot.rotationQuaternion,r=this.transformRoot.scaling;this.transformRoot.position=p.Vector3.Zero(),this.transformRoot.rotationQuaternion=p.Quaternion.Identity(),this.transformRoot.scaling=p.Vector3.One();for(const o of e.rootNodes){o.parent=this.transformRoot;for(const a of o.getChildMeshes(!1))a.alwaysSelectAsActiveMesh=!0}this.transformRoot.position=t,this.transformRoot.rotationQuaternion=i,this.transformRoot.scaling=r,this.canvasPanels=((s=this.contextService)==null?void 0:s.getAll())||new Map,De(this.materials.concat(this.variantManager.getAllMaterials()),this.scene,this.canvasPanels,this.dynamicTextures,`${this.id}_`),this.enablePicking&&this.attachPickingHandler(e),this.configureGlowLayer()}destroyInstance(){var e;(e=this.modelInstance)==null||e.dispose(),this.modelInstance=void 0}getAllMeshes(){var e;return(e=this.modelInstance)==null?void 0:e.rootNodes.map(t=>t.getChildMeshes(!1).filter(i=>i instanceof Le.Mesh)).flat()}async instantiate(){if(!this.assetContainer)throw new Error("Attempted to instantiate ModelContainer without an AssetContainer");this.modelInstance=this.assetContainer.instantiateModelsToScene(this.renameClonedAsset.bind(this),!0),this.materials=X(this.modelInstance),this.configureModelInstance(this.modelInstance),this.animations=J(this.modelInstance.animationGroups,this.renameClonedAsset("")),this.initialized=!0,await this.processQueuedEvents()}renameClonedAsset(e){return`${this.id}_${e}`}async setBaseModelEnabled(e){e&&!this.modelInstance?await this.instantiate():!e&&this.modelInstance&&this.destroyInstance()}updateDynamicTextures(){var e;(e=this.canvasPanels)==null||e.forEach((t,i)=>{const r=this.dynamicTextures.get(i);r&&t.getStaticContextDirty()&&r.isReady()&&(r.update(!1),t.setStaticContextDirty(!1))})}registerMaterialVariantListener(e){this.materialVariantObservable.add(e)}unregisterMaterialVariantListener(e){this.materialVariantObservable.removeCallback(e)}registerModelVariantListener(e){this.modelVariantObservable.add(e)}unregisterModelVariantListener(e){this.modelVariantObservable.removeCallback(e)}getCurrentAnimationFrame(){var t;const e=[...((t=this.modelInstance)==null?void 0:t.animationGroups)||[],...this.variantManager.getAnimationGroups()];for(const i of e)if(i.animatables.length>0&&i.animatables[0].masterFrame!==void 0&&i.animatables[0].masterFrame!==null)return i.animatables[0].masterFrame;return 0}getAnimationIsPlaying(){var t;const e=[...((t=this.modelInstance)==null?void 0:t.animationGroups)||[],...this.variantManager.getAnimationGroups()];for(const i of e)if(i.isPlaying)return!0;return!1}stripIdFromName(e){return e.substring(this.id.length+1)}async processQueuedEvents(){await Promise.all(Array.from(this.materialReadyToLoadCallbacks.values()).flatMap(e=>Array.from(e.values()).map(t=>t()))),this.materialReadyToLoadCallbacks.clear(),await Promise.all(Array.from(this.modelReadyToLoadCallbacks.values()).map(e=>e())),this.modelReadyToLoadCallbacks.clear(),this.scene.onAfterRenderObservable.addOnce(()=>{this.queuedModelAnimation&&(this.executeAnimation(this.queuedModelAnimation),this.queuedModelAnimation=void 0)})}}class B extends y.ArcRotateCamera{constructor(e,t,i,r,s,o,a,l){super(e,t,i,r,s,o,l),this.lastFocus=new p.Vector3(0,0,0),this._isRunningFramingBehavior=!1,this.panDenominator=1,this.panEnabled=!0,this.minZ=.01,this.updateRadiusBounds(this.radius),this.enableFramingBehavior(),this.wheelDeltaPercentage=.01,this.pinchDeltaPercentage=.005,this.useNaturalPinchZoom=!0,a.camera.autoOrientation&&(this.alpha+=Math.PI),a&&(a.camera.limits.min.beta&&(this.lowerBetaLimit=a.camera.limits.min.beta),a.camera.limits.max.beta&&(this.upperBetaLimit=a.camera.limits.max.beta),a.camera.limits.min.alpha&&(this.lowerAlphaLimit=a.camera.limits.min.alpha),a.camera.limits.max.alpha&&(this.upperAlphaLimit=a.camera.limits.max.alpha),a.camera.limits.min.radius&&(this.lowerRadiusLimit=a.camera.limits.min.radius),a.camera.limits.max.radius&&(this.upperRadiusLimit=a.camera.limits.max.radius),a.camera.autoRotation.enabled&&this.enableAutoRotationBehavior(a.camera.autoRotation.idleTimeMs))}updateConfiguration(e){e&&(this.lowerBetaLimit=e.camera.limits.min.beta??null,this.upperBetaLimit=e.camera.limits.max.beta??null,this.lowerAlphaLimit=e.camera.limits.min.alpha??null,this.upperAlphaLimit=e.camera.limits.max.alpha??null,e.camera.autoRotation.enabled?this.enableAutoRotationBehavior(e.camera.autoRotation.idleTimeMs):this.disableAutoRotationBehavior())}get isRunningFramingBehavior(){return this._isRunningFramingBehavior}set isRunningFramingBehavior(e){this._isRunningFramingBehavior=e,!e&&this.framingBehaviourCallback&&(this.framingBehaviourCallback(),this.framingBehaviourCallback=void 0)}setPanEnabled(e){this.panEnabled=e,this.panningSensibility=1e3/this.panDenominator,this.panningAxis=e?new p.Vector3(1,1,0):new p.Vector3(0,0,0)}getFramingBehavior(){return this.getBehaviorByName("Framing")}getAutoRotationBehavior(){const e=this.getBehaviorByName("AutoRotation");if(e)return e}enableFramingBehavior(){this.useFramingBehavior=!0;const e=this.getFramingBehavior();e.attach(this),e.framingTime=0,e.elevationReturnTime=-1,e.zoomStopsAnimation=!1,this.lowerRadiusLimit=null;const t=j(this._scene);return e.zoomOnBoundingInfo(t.min,t.max),this.wheelPrecision=100/this.radius,this.lowerRadiusLimit===null&&(this.lowerRadiusLimit=.1),this.lastFocus.copyFrom(this.target),e}rerunFramingBehavior(e,t){this._isRunningFramingBehavior=!0,this.framingBehaviourCallback=e;const i=this.getFramingBehavior();i.framingTime=t||800;const r=()=>{this.isRunningFramingBehavior=!1},s=j(this._scene),o=s.max.subtract(s.min),a=s.min.add(o.scale(.5));this.updateRadiusBounds(o.length()*1.5),this.wheelPrecision=100/this.radius,this.panningInertia=0,this.panningOriginTarget.copyFrom(a),this.panDenominator=o.length(),this.lastFocus.copyFrom(a),i.zoomOnBoundingInfo(s.min,s.max,void 0,r),i.framingTime=0}enableAutoRotationBehavior(e=5e3){this.useAutoRotationBehavior=!0;const t=this.getAutoRotationBehavior();t&&(t.idleRotationWaitTime=e)}disableAutoRotationBehavior(){this.useAutoRotationBehavior=!1}updateRadiusBounds(e){this.maxZ=e*1e3,this.lowerRadiusLimit=e*.01,this.upperRadiusLimit=1.5*e,this.wheelPrecision=100/e,this.pinchPrecision=300/e}static create(e,t,i){var l;const r=j(e),s=r.max.subtract(r.min),o=r.min.add(s.scale(.5)),a=new B("ProductCamera",-(Math.PI/2),Math.PI/2,s.length()*1.5,o,e,t);return a.setPanEnabled(((l=t.options)==null?void 0:l.noPan)!==void 0?!t.options.noPan:!0),a.panningInertia=0,a.panningOriginTarget.copyFrom(o),a.panDenominator=s.length(),a.onAfterCheckInputsObservable.addOnce(()=>{a.setPanEnabled(a.panEnabled)}),i&&(e.activeCamera=a),a}}function j(n){if(n.meshes.length===0)return{min:new p.Vector3(-1,-1,-1),max:new p.Vector3(1,1,1)};const e=n.meshes.filter(t=>t.name.toLowerCase().endsWith("_t")||t.name.toLowerCase().includes("_t_"));return n.getWorldExtends(t=>t.isVisible&&t.isEnabled()&&(e.length===0||e.includes(t)))}class Xe{constructor(e,t=!1,i=void 0){this.renderingPipeline=new Be.DefaultRenderingPipeline("default",t,e,i?[i]:void 0,!1),this.renderingPipeline.isSupported&&(this.renderingPipeline.prepare(),this.setConfiguration(u))}dispose(){this.renderingPipeline.dispose()}getConfiguration(){return this.currentConfiguration}setConfiguration(e){var t,i,r,s,o,a,l,d,h,g,m,f,v,_,ee,te,ie,se,ne,re,ae,oe,le,he,ce,de,ue,ge,me,pe,fe,be,ve;if(this.renderingPipeline.isSupported){if(this.renderingPipeline.samples=((t=e.antiAliasing)==null?void 0:t.samples)??u.antiAliasing.samples,this.renderingPipeline.fxaaEnabled=((i=e.antiAliasing)==null?void 0:i.fxaaEnabled)??u.antiAliasing.fxaaEnabled,this.renderingPipeline.bloomEnabled=((r=e.bloom)==null?void 0:r.enabled)??u.bloom.enabled,this.renderingPipeline.bloomKernel=((s=e.bloom)==null?void 0:s.kernel)??u.bloom.kernel,this.renderingPipeline.bloomScale=((o=e.bloom)==null?void 0:o.scale)??u.bloom.scale,this.renderingPipeline.bloomThreshold=((a=e.bloom)==null?void 0:a.threshold)??u.bloom.threshold,this.renderingPipeline.bloomWeight=((l=e.bloom)==null?void 0:l.weight)??u.bloom.weight,this.renderingPipeline.chromaticAberrationEnabled=((d=e.chromaticAberration)==null?void 0:d.enabled)??u.chromaticAberration.enabled,this.renderingPipeline.chromaticAberration.aberrationAmount=((h=e.chromaticAberration)==null?void 0:h.aberrationAmount)??u.chromaticAberration.aberrationAmount,this.renderingPipeline.chromaticAberration.radialIntensity=((g=e.chromaticAberration)==null?void 0:g.radialIntensity)??u.chromaticAberration.radialIntensity,this.renderingPipeline.chromaticAberration.direction=(m=e.chromaticAberration)!=null&&m.direction?new p.Vector2(e.chromaticAberration.direction.x,e.chromaticAberration.direction.y):new p.Vector2(u.chromaticAberration.direction.x,u.chromaticAberration.direction.y),this.renderingPipeline.imageProcessing.colorCurvesEnabled=((f=e.colorCurves)==null?void 0:f.enabled)??u.colorCurves.enabled,this.renderingPipeline.imageProcessing.colorCurves=e.colorCurves?this.updateColorCurve(e.colorCurves):new G.ColorCurves,this.renderingPipeline.depthOfFieldEnabled=((v=e.depthOfField)==null?void 0:v.enabled)??u.depthOfField.enabled,e.depthOfField)switch(e.depthOfField.blurLevel??u.depthOfField.blurLevel){case"Low":this.renderingPipeline.depthOfFieldBlurLevel=I.DepthOfFieldEffectBlurLevel.Low;break;case"Medium":this.renderingPipeline.depthOfFieldBlurLevel=I.DepthOfFieldEffectBlurLevel.Medium;break;case"High":this.renderingPipeline.depthOfFieldBlurLevel=I.DepthOfFieldEffectBlurLevel.High;break}if(this.renderingPipeline.depthOfField.focalLength=((_=e.depthOfField)==null?void 0:_.focalLength)??u.depthOfField.focalLength,this.renderingPipeline.depthOfField.fStop=((ee=e.depthOfField)==null?void 0:ee.fStop)??u.depthOfField.fStop,this.renderingPipeline.depthOfField.focusDistance=((te=e.depthOfField)==null?void 0:te.focusDistance)??u.depthOfField.focusDistance,this.renderingPipeline.depthOfField.lensSize=((ie=e.depthOfField)==null?void 0:ie.lensSize)??u.depthOfField.lensSize,this.renderingPipeline.grainEnabled=((se=e.grain)==null?void 0:se.enabled)??u.grain.enabled,this.renderingPipeline.grain.animated=((ne=e.grain)==null?void 0:ne.animated)??u.grain.animated,this.renderingPipeline.grain.intensity=((re=e.grain)==null?void 0:re.intensity)??u.grain.intensity,this.renderingPipeline.imageProcessing.contrast=((ae=e.misc)==null?void 0:ae.contrast)??u.misc.contrast,this.renderingPipeline.imageProcessing.exposure=((oe=e.misc)==null?void 0:oe.exposure)??u.misc.exposure,this.renderingPipeline.imageProcessing.toneMappingEnabled=((le=e.misc)==null?void 0:le.toneMappingEnabled)??u.misc.toneMappingEnabled,this.renderingPipeline.imageProcessing.toneMappingEnabled)switch(e.misc.toneMappingType??u.misc.toneMappingType){case"Standard":this.renderingPipeline.imageProcessing.toneMappingType=P.ImageProcessingConfiguration.TONEMAPPING_STANDARD;break;case"ACES":this.renderingPipeline.imageProcessing.toneMappingType=P.ImageProcessingConfiguration.TONEMAPPING_ACES;break}if(this.renderingPipeline.sharpenEnabled=((he=e.sharpen)==null?void 0:he.enabled)??u.sharpen.enabled,this.renderingPipeline.sharpen.colorAmount=((ce=e.sharpen)==null?void 0:ce.colorAmount)??u.sharpen.colorAmount,this.renderingPipeline.sharpen.edgeAmount=((de=e.sharpen)==null?void 0:de.edgeAmount)??u.sharpen.edgeAmount,this.renderingPipeline.imageProcessing.vignetteEnabled=((ue=e.vignette)==null?void 0:ue.enabled)??u.vignette.enabled,(ge=e.vignette)!=null&&ge.center?(this.renderingPipeline.imageProcessing.vignetteCenterX=e.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=e.vignette.center.y):(this.renderingPipeline.imageProcessing.vignetteCenterX=u.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=u.vignette.center.y),e.vignette)switch(((me=e.vignette)==null?void 0:me.blendMode)??u.vignette.blendMode){case"Multiply":this.renderingPipeline.imageProcessing.vignetteBlendMode=P.ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY;break;case"Opaque":this.renderingPipeline.imageProcessing.vignetteBlendMode=P.ImageProcessingConfiguration.VIGNETTEMODE_OPAQUE;break}(pe=e.vignette)!=null&&pe.colorRgba?this.renderingPipeline.imageProcessing.vignetteColor=new b.Color4(e.vignette.colorRgba.r,e.vignette.colorRgba.g,e.vignette.colorRgba.b,e.vignette.colorRgba.a):(fe=e.vignette)!=null&&fe.colorHex?this.renderingPipeline.imageProcessing.vignetteColor=b.Color4.FromHexString(e.vignette.colorHex):this.renderingPipeline.imageProcessing.vignetteColor=new b.Color4(u.vignette.colorRgba.r,u.vignette.colorRgba.g,u.vignette.colorRgba.b,u.vignette.colorRgba.a),this.renderingPipeline.imageProcessing.vignetteStretch=((be=e.vignette)==null?void 0:be.stretch)??u.vignette.stretch,this.renderingPipeline.imageProcessing.vignetteWeight=((ve=e.vignette)==null?void 0:ve.weight)??u.vignette.weight,this.renderingPipeline.prepare(),this.currentConfiguration=e}}updateColorCurve(e){const t=new G.ColorCurves;return t.globalDensity=e.globalDensity??t.globalDensity,t.globalExposure=e.globalExposure??t.globalExposure,t.globalHue=e.globalHue??t.globalHue,t.globalSaturation=e.globalSaturation??t.globalSaturation,t.highlightsDensity=e.highlightsDensity??t.highlightsDensity,t.highlightsExposure=e.highlightsExposure??t.highlightsExposure,t.highlightsHue=e.highlightsHue??t.highlightsHue,t.highlightsSaturation=e.highlightsSaturation??t.highlightsSaturation,t.midtonesDensity=e.midtonesDensity??t.midtonesDensity,t.midtonesExposure=e.midtonesExposure??t.midtonesExposure,t.midtonesHue=e.midtonesHue??t.midtonesHue,t.midtonesSaturation=e.midtonesSaturation??t.midtonesSaturation,t.shadowsDensity=e.shadowsDensity??t.shadowsDensity,t.shadowsExposure=e.shadowsExposure??t.shadowsExposure,t.shadowsHue=e.shadowsHue??t.shadowsHue,t.shadowsSaturation=e.shadowsSaturation??t.shadowsSaturation,t}}Ae.GLTF2.GLTFLoader.RegisterExtension("glbPostProcessor",function(n){return new je(n)}),L.SceneLoader.OnPluginActivatedObservable.add(n=>{if(n.name==="gltf"){const e=n;e.transparencyAsCoverage=!0}});function q(n){return new p.Vector3(n.x,n.y,n.z)}function D(n){return{x:n.x,y:n.y,z:n.z}}class Je{constructor(e){var l;this.focusLostNotified=!1,this.focusLostObservable=new M.Observable,this.modelLoadEventCallbacks=[],this.modelContainers=new Map,this.plugins=[],this.initComplete=!1,this.isAnimatingCamera=!1,this.registeredCanvases=[],this.renderLoop=()=>{if(!this.engine.views)return;this.modelContainers.forEach(h=>{h.updateDynamicTextures()}),this.scene.autoClear=!0,this.scene.autoClearDepthAndStencil=!0,this.scene.render(),this.camera.isRunningFramingBehavior&&this.camera.getFramingBehavior().isUserIsMoving&&(this.camera.isRunningFramingBehavior=!1);const d=Math.max((this.camera.lowerRadiusLimit??1)*.01,.001);!this.camera.isRunningFramingBehavior&&!this.camera.target.equalsWithEpsilon(this.camera.lastFocus,d)&&!this.focusLostNotified&&(this.focusLostObservable.notifyObservers(void 0),this.focusLostNotified=!0),this.screenshotPrepareResolve&&(this.screenshotPrepareResolve(),this.screenshotPrepareResolve=void 0)},this.configuration=new K(e);const i=(()=>{if(!(e!=null&&e.noRender))return this.configuration.createCanvas()})(),r="1.5.6";we.DracoCompression.Configuration={decoder:{wasmUrl:`https://www.gstatic.com/draco/versioned/decoders/${r}/draco_wasm_wrapper_gltf.js`,wasmBinaryUrl:`https://www.gstatic.com/draco/versioned/decoders/${r}/draco_decoder_gltf.wasm`,fallbackUrl:`https://www.gstatic.com/draco/versioned/decoders/${r}/draco_decoder_gltf.js`}},i&&(i.getContext("webgl2")||i.getContext("webgl"));const s=console.log;console.log=()=>{};const o=i?new V.Engine(i,!0,{adaptToDeviceRatio:!0,limitDeviceRatio:2,premultipliedAlpha:!1,preserveDrawingBuffer:!!(e!=null&&e.backgroundImage),audioEngine:!1,stencil:this.configuration.highlights.enabled,forceSRGBBufferSupportState:!0}):new ye.NullEngine;console.log=s,o.hideLoadingUI(),window.addEventListener("resize",this.fireResizeEvent.bind(this)),this.engine=o,this.scene=new xe.Scene(o),this.camera=B.create(this.scene,this.configuration),this.scene.activeCamera=this.camera,this.renderingPipeline=new Xe(this.scene,!1,this.camera),this.scene.clearColor=this.configuration.scene.clearColor;const a=k.CubeTexture.CreateFromPrefilteredData(this.configuration.scene.environment.file,this.scene);a.rotationY=this.configuration.scene.environment.rotationY,this.scene.environmentTexture=a,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 qe(this.scene,this.configuration.emissiveGlowIntensity),this.scene.autoClear=!0,this.scene.autoClearDepthAndStencil=!0,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){if(this.registeredCanvases.includes(e)){console.warn("registerView has been called with a canvas that is already registered. You should call unregisterView first.");return}this.registeredCanvases.push(e);const t=e.height,i=e.width;this.engine.registerView(e,void 0,!0),e.setAttribute("height",t.toString()),e.setAttribute("width",i.toString()),this.orbitEnabled()||this.setCameraState(T.Pan),this.reattachControls(e)}getNumViewports(){var e;return((e=this.engine.views)==null?void 0:e.length)||0}unregisterView(e){this.registeredCanvases.includes(e)||console.warn("unregisterView has been called with a canvas that has not been registered."),this.registeredCanvases=this.registeredCanvases.filter(t=>t!==e),this.engine.unRegisterView(e)}shutdown(){this.plugins.forEach(e=>e.dispose(!0)),this.renderingPipeline.dispose(),this.engine&&this.engine.dispose(),window.removeEventListener("resize",this.fireResizeEvent)}executeCameraAnimation(e){if(!this.camera||this.scene.activeCamera!==this.camera||this.getAllModels().length===0||!this.getAllModels().some(r=>r.getIsInitialized()))return this.queuedCameraAnimation=e,Promise.resolve();let t=()=>{};const i=async()=>{this.isAnimatingCamera=!0,await ze(this.scene,this.scene.activeCamera,e),this.isAnimatingCamera=!1,this.queuedAnimationFunction&&this.queuedAnimationFunction(),this.queuedAnimationFunction=void 0,t()};return this.isAnimatingCamera?(this.queuedAnimationFunction=i,new Promise(r=>{t=r})):i()}getCameraPose(){if(this.scene&&this.camera)return{lonDeg:Math.round(this.camera.alpha*180/Math.PI),latDeg:Math.round(this.camera.beta*180/Math.PI),radius:Math.round((this.camera.radius+Number.EPSILON)*1e4)/1e4,target:{x:this.camera.target.x,y:this.camera.target.y,z:this.camera.target.z}}}setCameraPose(e){this.scene&&this.camera&&(this.camera.target=new p.Vector3(e.target.x,e.target.y,e.target.z),this.camera.radius=e.radius,this.camera.alpha=e.latDeg,this.camera.beta=e.lonDeg)}setCameraState(e){var t,i;if(!((t=this.engine)!=null&&t.views)||!((i=this.engine)!=null&&i.views[0]))throw new Error("No views attached, camera state requires a view to attach controls onto.");e===T.Orbit?this.reattachControls(this.engine.views[0].target,2):this.reattachControls(this.engine.views[0].target,0)}animateToLastCameraFocus(){let e=()=>{};const t=async()=>{this.isAnimatingCamera=!0,await new Promise(i=>{this.focusLostNotified=!1;const r=()=>{const s=this.configuration;this.camera.rerunFramingBehavior(()=>{s.camera.limits.min.radius&&(this.camera.lowerRadiusLimit=s.camera.limits.min.radius),s.camera.limits.max.radius&&(this.camera.upperRadiusLimit=s.camera.limits.max.radius),i()})};this.scene.onAfterRenderObservable.addOnce(r)}),this.isAnimatingCamera=!1,this.queuedAnimationFunction&&this.queuedAnimationFunction(),this.queuedAnimationFunction=void 0,e()};return this.isAnimatingCamera?(this.queuedAnimationFunction=t,new Promise(i=>{e=i})):t()}forceStopCameraAnimations(){var e;this.queuedAnimationFunction=void 0,this.queuedCameraAnimation=void 0,this.isAnimatingCamera=!1,(e=this.camera.framingBehavior)==null||e.stopAllAnimations(),this.scene.stopAnimation(this.camera)}setAutoRotation(e){!this.configuration.camera.autoRotation.enabled||!this.camera||(e?this.camera.enableAutoRotationBehavior(this.configuration.camera.autoRotation.idleTimeMs):this.camera.disableAutoRotationBehavior())}getCurrentConfiguration(){return this.configuration.options}async renderSceneScreenshot(e,t){if(!this.camera)throw new Error("Missing product camera, cannot render screenshot!");const i=new y.ArcRotateCamera("screenshotCamera",0,0,0,p.Vector3.Zero(),this.scene);try{const r=t.latDeg*Math.PI/180,s=t.lonDeg*Math.PI/180;i.target=t.target?new p.Vector3(t.target.x,t.target.y,t.target.z):p.Vector3.Zero(),i.alpha=s,i.beta=r,i.radius=t.radius||this.camera.radius,i.minZ=.01,this.scene.render();const o=await Me.Tools.CreateScreenshotUsingRenderTargetAsync(this.engine,i,e,"image/png",2,!0);return i.dispose(),o}catch{throw i.isDisposed()||i.dispose(),new Error("Failed to render screenshot")}}orbitEnabled(){const e=this.configuration;if(!e)return!0;const t=e.camera.limits.min.alpha,i=e.camera.limits.max.alpha,r=e.camera.limits.min.beta,s=e.camera.limits.max.beta;if(t===void 0||i===void 0||r===void 0||s===void 0)return!0;const o=[t,i],a=[r,s],l=o.every(h=>h===t),d=a.every(h=>h===r);return!l&&!d}fireResizeEvent(){this.getNumViewports()>0&&this.engine.resize()}setHighlights(e,t){var r;e.length===0&&((r=this.highlightLayer)==null||r.dispose(),this.highlightLayer=void 0),this.highlightLayer||(this.highlightLayer=new Ce.HighlightLayer("highlights",this.scene,{isStroke:!0,blurVerticalSize:.85,blurHorizontalSize:.85}),this.highlightLayer.innerGlow=!0,this.highlightLayer.outerGlow=!1),this.highlightLayer.removeAllMeshes();const i=t?new b.Color3(t[0],t[1],t[2]).toLinearSpace():void 0;e.forEach(s=>{const o=this.scene.materials.find(a=>a.name===s.name&&a.id===s.id);o&&o.getBindedMeshes().forEach(a=>{var l;return(l=this.highlightLayer)==null?void 0:l.addMesh(a,i||b.Color3.FromHexString("#fcba03"))})})}setRenderingPipelineConfiguration(e){this.renderingPipeline&&this.renderingPipeline.setConfiguration(e)}loadModel(e,t){const{refocusCamera:i=!0,progressHandler:r}=t??{},s=new $e({enablePicking:this.configuration.highlights.enabled,modelDetails:e,scene:this.scene,previewService:this,progressHandler:r});return s.getInitializationPromise().then(()=>{this.modelContainers.size<=1&&i&&(this.forceStopCameraAnimations(),this.camera.rerunFramingBehavior(()=>{this.scene.onAfterRenderObservable.addOnce(()=>{this.queuedCameraAnimation&&(this.executeCameraAnimation(this.queuedCameraAnimation),this.queuedCameraAnimation=void 0)})},1))}),this.configuration.highlights.enabled&&(s.registerMaterialSelectedCallback(o=>{this.setHighlights([o])}),s.registerMaterialDeselectedCallback(()=>{this.setHighlights([])})),this.modelContainers.set(s.getId(),s),this.triggerModelLoadEvent({eventType:"load",modelContainer:s}),s}async preloadModel(e){await S(e,this.scene)}getAllModels(){return Array.from(this.modelContainers.values())}getModelById(e){return this.modelContainers.get(e)}registerPlugin(e){this.plugins.push(e),e.initialize(this,{camera:this.camera,engine:this.engine,scene:this.scene})}unregisterPlugin(e){const t=this.plugins.indexOf(e);t>-1&&this.plugins.splice(t,1).forEach(r=>r.dispose(!1))}getGlowLayerManager(){return this.glowLayerManager}modelUnloaded(e){this.modelContainers.delete(e.getId()),this.triggerModelLoadEvent({eventType:"unload",modelContainer:e})}triggerModelLoadEvent(e){this.modelLoadEventCallbacks.forEach(t=>t(e))}flipTransform(e,t,i){const r=p.Matrix.Compose(q(i||{x:1,y:1,z:1}),p.Quaternion.FromEulerVector(q(t||{x:0,y:0,z:0})),q(e||{x:0,y:0,z:0})),s=p.Matrix.RotationAxis(p.Vector3.Up(),Math.PI),o=r.multiply(s),a=p.Vector3.Zero(),l=p.Quaternion.Identity(),d=p.Vector3.Zero();return o.decompose(d,l,a),l.multiplyInPlace(p.Quaternion.FromEulerAngles(0,Math.PI,0)),{position:D(a),rotation:D(l.toEulerAngles()),scale:D(d)}}updatePreviewOptions(e){var r,s;const t=new K(e);this.configuration.highlights.enabled!==t.highlights.enabled&&this.engine.setStencilBuffer(t.highlights.enabled),this.scene.clearColor=t.scene.clearColor;let i=this.scene.environmentTexture;this.configuration.scene.environment.file!==t.scene.environment.file&&(i=k.CubeTexture.CreateFromPrefilteredData(t.scene.environment.file,this.scene),i.rotationY=this.configuration.scene.environment.rotationY,this.scene.environmentTexture=i),i.rotationY=t.scene.environment.rotationY,this.scene.environmentIntensity=t.scene.environment.intensity,(r=t.options)!=null&&r.renderingPipelineConfiguration?this.renderingPipeline.setConfiguration(t.options.renderingPipelineConfiguration):(this.scene.imageProcessingConfiguration.exposure=t.lighting.exposure,this.scene.imageProcessingConfiguration.contrast=t.lighting.contrast),this.glowLayerManager.setIntensity(t.emissiveGlowIntensity),this.camera.updateConfiguration(t),this.camera.setPanEnabled(((s=t.options)==null?void 0:s.noPan)!==void 0?!t.options.noPan:!0),this.scene.autoClear=!0,this.scene.autoClearDepthAndStencil=!0,this.configuration=t}reattachControls(e,t=2){if(this.scene.detachControl(),this.engine.inputElement=e,this.camera){this.camera.attachControl(!0,!1,t);const i=this.camera.inputs.attached.pointers;i.multiTouchPanning=!1}this.scene.attachControl(!0,!0,!0)}}c.MaterialEffectMode=R,c.ProductCameraRig=T,c.REFLECTION_PROBE_RESOLUTION=U,c.RenderingConfiguration=w,c.SpiffCommerce3DPreviewService=Je,c.renderingPipelineDefaults=u,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
1
+ (function(c,y){typeof exports=="object"&&typeof module<"u"?y(exports,require("@babylonjs/core/Cameras/arcRotateCamera"),require("@babylonjs/core/Engines/engine"),require("@babylonjs/core/Engines/nullEngine"),require("@babylonjs/core/Layers/highlightLayer"),require("@babylonjs/core/Loading/sceneLoader"),require("@babylonjs/core/Materials/Textures/cubeTexture"),require("@babylonjs/core/Maths/math.color"),require("@babylonjs/core/Maths/math.vector"),require("@babylonjs/core/Meshes/Compression/dracoCompression"),require("@babylonjs/core/Misc/observable"),require("@babylonjs/core/Misc/tools"),require("@babylonjs/core/scene"),require("@babylonjs/loaders/glTF"),require("@babylonjs/loaders/glTF/glTFFileLoader"),require("@babylonjs/core/Materials/PBR/pbrMaterial"),require("@babylonjs/core/Materials/Textures/mirrorTexture"),require("@babylonjs/core/Maths/math"),require("@babylonjs/core/Probes/reflectionProbe"),require("@babylonjs/core/Layers/glowLayer"),require("@babylonjs/core/Actions/actionManager"),require("@babylonjs/core/Actions/directActions"),require("@babylonjs/core/Meshes/mesh"),require("@babylonjs/core/Meshes/transformNode"),require("@babylonjs/core/Materials/Textures/dynamicTexture"),require("@babylonjs/core/Materials/Textures/texture"),require("@babylonjs/core/Animations/animation"),require("@babylonjs/core/Animations/easing"),require("@babylonjs/core/Misc/assetsManager"),require("@babylonjs/core/Materials/colorCurves"),require("@babylonjs/core/Materials/imageProcessingConfiguration"),require("@babylonjs/core/PostProcesses/RenderPipeline"),require("@babylonjs/core/PostProcesses/depthOfFieldEffect"),require("@babylonjs/core/Rendering/depthRendererSceneComponent"),require("@babylonjs/core/Engines/Extensions/engine.views"),require("@babylonjs/core/Meshes/instancedMesh"),require("@babylonjs/core/Materials/Textures/Loaders/ddsTextureLoader"),require("@babylonjs/core/Materials/Textures/Loaders/envTextureLoader"),require("@babylonjs/core/Materials/Textures/Loaders/ktxTextureLoader"),require("@babylonjs/core/Animations/animatable"),require("@babylonjs/core/Misc/screenshotTools"),require("@babylonjs/core/Rendering/boundingBoxRenderer"),require("@babylonjs/loaders/glTF/2.0/Extensions")):typeof define=="function"&&define.amd?define(["exports","@babylonjs/core/Cameras/arcRotateCamera","@babylonjs/core/Engines/engine","@babylonjs/core/Engines/nullEngine","@babylonjs/core/Layers/highlightLayer","@babylonjs/core/Loading/sceneLoader","@babylonjs/core/Materials/Textures/cubeTexture","@babylonjs/core/Maths/math.color","@babylonjs/core/Maths/math.vector","@babylonjs/core/Meshes/Compression/dracoCompression","@babylonjs/core/Misc/observable","@babylonjs/core/Misc/tools","@babylonjs/core/scene","@babylonjs/loaders/glTF","@babylonjs/loaders/glTF/glTFFileLoader","@babylonjs/core/Materials/PBR/pbrMaterial","@babylonjs/core/Materials/Textures/mirrorTexture","@babylonjs/core/Maths/math","@babylonjs/core/Probes/reflectionProbe","@babylonjs/core/Layers/glowLayer","@babylonjs/core/Actions/actionManager","@babylonjs/core/Actions/directActions","@babylonjs/core/Meshes/mesh","@babylonjs/core/Meshes/transformNode","@babylonjs/core/Materials/Textures/dynamicTexture","@babylonjs/core/Materials/Textures/texture","@babylonjs/core/Animations/animation","@babylonjs/core/Animations/easing","@babylonjs/core/Misc/assetsManager","@babylonjs/core/Materials/colorCurves","@babylonjs/core/Materials/imageProcessingConfiguration","@babylonjs/core/PostProcesses/RenderPipeline","@babylonjs/core/PostProcesses/depthOfFieldEffect","@babylonjs/core/Rendering/depthRendererSceneComponent","@babylonjs/core/Engines/Extensions/engine.views","@babylonjs/core/Meshes/instancedMesh","@babylonjs/core/Materials/Textures/Loaders/ddsTextureLoader","@babylonjs/core/Materials/Textures/Loaders/envTextureLoader","@babylonjs/core/Materials/Textures/Loaders/ktxTextureLoader","@babylonjs/core/Animations/animatable","@babylonjs/core/Misc/screenshotTools","@babylonjs/core/Rendering/boundingBoxRenderer","@babylonjs/loaders/glTF/2.0/Extensions"],y):(c=typeof globalThis<"u"?globalThis:c||self,y(c.Preview={},c.arcRotateCamera,c.engine,c.nullEngine,c.highlightLayer,c.sceneLoader,c.cubeTexture,c.math_color,c.math_vector,c.dracoCompression,c.observable,c.tools,c.scene,c.glTF,c.glTFFileLoader,c.pbrMaterial,c.mirrorTexture,c.math,c.reflectionProbe,c.glowLayer,c.actionManager,c.directActions,c.mesh,c.transformNode,c.dynamicTexture,c.texture,c.animation,c.easing,c.assetsManager,c.colorCurves,c.imageProcessingConfiguration,c.RenderPipeline,c.depthOfFieldEffect))})(this,function(c,y,V,ye,Ce,L,k,b,p,we,M,Me,xe,Ae,Pe,O,Te,A,Re,Ee,F,z,Le,Oe,Fe,Ie,C,N,Se,G,P,Be,I){"use strict";var T=(s=>(s[s.Orbit=0]="Orbit",s[s.Pan=1]="Pan",s))(T||{}),R=(s=>(s.None="None",s.RemoveWhenSelected="RemoveWhenSelected",s.ApplyWhenSelected="ApplyWhenSelected",s))(R||{});const H=new Map;async function S(s,e,t){const i=H.get(s);if(i)return i;{const r=L.SceneLoader.LoadAssetContainerAsync(s,void 0,e,t);return H.set(s,r),r}}L.SceneLoader.OnPluginActivatedObservable.add(s=>{s.name==="gltf"&&(s.animationStartMode=Pe.GLTFLoaderAnimationStartMode.NONE)});class K{constructor(e){this.getSceneClearColor=()=>{var i,r,n,o;const t=(i=this.customOptions)!=null&&i.transparentBackground||(r=this.customOptions)!=null&&r.backgroundImage?0:1;if(this.customOptions&&((n=this.customOptions)!=null&&n.transparentBackground)||(o=this.customOptions)!=null&&o.backgroundImage)return new b.Color4(0,0,0,t).toLinearSpace();if(this.customOptions&&this.customOptions.backgroundColor){const a=b.Color3.FromHexString(this.customOptions.backgroundColor);return new b.Color4(a.r,a.g,a.b,t).toLinearSpace()}return new b.Color4(.98,.98,.98,t).toLinearSpace()},this.highlightColorFromConfig=()=>this.customOptions&&this.customOptions.highlightColor?this.hexToColor4(this.customOptions.highlightColor):new b.Color4(.98,.98,.98,1).toLinearSpace(),this.hexToColor4=(t,i=1)=>{const r=b.Color3.FromHexString(t);return new b.Color4(r.r,r.g,r.b,i).toLinearSpace()},this.customOptions=e}createCanvas(){var e;return(e=this.customOptions)!=null&&e.createCanvas?this.customOptions.createCanvas():document.createElement("canvas")}get options(){return this.customOptions}get scene(){var e,t,i,r,n;return{clearColor:this.getSceneClearColor(),transparentBackground:((e=this.customOptions)==null?void 0:e.transparentBackground)||((t=this.customOptions)==null?void 0:t.backgroundImage),environment:{file:((i=this.customOptions)==null?void 0:i.environmentFile)??"assets/model-viewer/default.env",intensity:((r=this.customOptions)==null?void 0:r.environmentIntensity)??1,rotationY:(((n=this.customOptions)==null?void 0:n.environmentRotationY)??0)*(Math.PI/180)}}}get camera(){var e,t,i,r,n,o,a,l,d,h,g,m,f;return{autoOrientation:((e=this.customOptions)==null?void 0:e.disableAutomaticOrientation)??!0,autoRotation:{enabled:((t=this.customOptions)==null?void 0:t.autoRotation)??!1,idleTimeMs:((i=this.customOptions)==null?void 0:i.idleTimeBeforeRotation)??5e3},limits:{min:{alpha:(r=this.customOptions)!=null&&r.lowerAlphaLimitDeg?((n=this.customOptions)==null?void 0:n.lowerAlphaLimitDeg)*Math.PI/180:void 0,beta:(o=this.customOptions)!=null&&o.lowerBetaLimitDeg?((a=this.customOptions)==null?void 0:a.lowerBetaLimitDeg)*Math.PI/180:void 0,radius:(l=this.customOptions)==null?void 0:l.minZoomOverride},max:{alpha:(d=this.customOptions)!=null&&d.upperAlphaLimitDeg?((h=this.customOptions)==null?void 0:h.upperAlphaLimitDeg)*Math.PI/180:void 0,beta:(g=this.customOptions)!=null&&g.upperBetaLimitDeg?((m=this.customOptions)==null?void 0:m.upperBetaLimitDeg)*Math.PI/180:void 0,radius:(f=this.customOptions)==null?void 0:f.maxZoomOverride}}}}get highlights(){var e;return{enabled:((e=this.customOptions)==null?void 0:e.highlightOnMaterialHover)??!1,color:this.highlightColorFromConfig()}}get lighting(){var e,t,i,r;return{exposure:((t=(e=this.customOptions)==null?void 0:e.lighting)==null?void 0:t.exposure)??.9,contrast:((r=(i=this.customOptions)==null?void 0:i.lighting)==null?void 0:r.contrast)??1.6}}get emissiveGlowIntensity(){var e;return((e=this.customOptions)==null?void 0:e.emissiveGlowIntensity)??.5}}class w{static getDynamicTextureResolution(){return this.getIsMobile()||!w.offscreenRenderingSupported()?{width:1024,height:1024}:{width:2048,height:2048}}static shouldMipMap(){return!0}static offscreenRenderingSupported(){return navigator.userAgent.includes("SamsungBrowser")?!1:!!window.Worker&&!!window.OffscreenCanvas}static getMirrorTextureResolution(){return this.getIsMobile()?512:1024}static getIsMobile(){try{return typeof window>"u"||!window.navigator?!1:/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(window.navigator.userAgent)||window.innerWidth/window.devicePixelRatio<=480}catch{return!1}}}const U=128,u={antiAliasing:{samples:4,fxaaEnabled:!1},bloom:{enabled:!1,kernel:64,scale:.5,threshold:.9,weight:.15},chromaticAberration:{enabled:!1,aberrationAmount:30,direction:{x:0,y:0},radialIntensity:0},colorCurves:{enabled:!1},depthOfField:{enabled:!1,blurLevel:"Low",focalLength:50,focusDistance:2e3,fStop:1.4,lensSize:50},grain:{enabled:!1,animated:!1,intensity:30},misc:{contrast:1,exposure:1,toneMappingEnabled:!1,toneMappingType:"Standard"},sharpen:{enabled:!1,colorAmount:1,edgeAmount:.3},vignette:{enabled:!1,blendMode:"Multiply",cameraFov:.5,center:{x:0,y:0},colorHex:"#000000ff",colorRgba:{r:0,g:0,b:0,a:1},stretch:0,weight:1}};class je{constructor(e){this.name="glbPostProcessor",this.enabled=!0,this.loader=e}onReady(){this.applyReflections(this.loader.babylonScene)}loadNodeAsync(e,t,i){return this.loader.loadNodeAsync(e,t,function(r){t.extras&&Object.keys(t.extras).forEach(n=>{const o=t.extras[n];r.metadata[n]=o}),i(r)})}async loadMaterialPropertiesAsync(e,t,i){await this.loader.loadMaterialPropertiesAsync(e,t,i),this.enableMaterialExtrasIfRequired(t,i),i.needDepthPrePass=!0}dispose(){}enableMaterialExtrasIfRequired(e,t){if(!(!e.extras||!(t instanceof O.PBRMaterial))){if(e.extras.sheen){const i=t;i.sheen.isEnabled=!0,i.sheen.intensity=e.extras.sheen}if(e.extras.translucency){const i=t;i.subSurface.isTranslucencyEnabled=!0,i.subSurface.translucencyIntensity=e.extras.translucency,e.extras.translucencyR&&e.extras.translucencyG&&e.extras.translucencyB&&(i.subSurface.tintColor=new A.Color3(e.extras.translucencyR,e.extras.translucencyG,e.extras.translucencyB))}if(e.extras.refractionIOR){const i=t;i.subSurface.isRefractionEnabled=!0,i.subSurface.volumeIndexOfRefraction=e.extras.refractionIOR}if(e.extras.useDepthPrePass){const i=t;i.needDepthPrePass=!0,i.forceIrradianceInFragment=!0}if(e.extras.useParallax){const i=t;i.useParallax=!0,i.useParallaxOcclusion=!0,i.parallaxScaleBias=e.extras.useParallax}}}applyReflections(e){function t(n){const o=[];return n.transformNodes.forEach(a=>{a.metadata&&a.metadata.reflective&&o.push(...a.getChildMeshes())}),n.meshes.forEach(a=>{a.metadata&&a.metadata.reflective&&!o.includes(a)&&o.push(a)}),o}function i(n,o=1){const a=n.material;if(!a)return;const l=new Te.MirrorTexture("mirror",w.getMirrorTextureResolution(),e,!0);l.renderList=t(e);const d=n.getVerticesData("normal");if(!d)throw new Error("Mirror attribute specified on: "+n.name+"But no normals exist to generate a mirror from!");n.computeWorldMatrix(!0);const h=n.getWorldMatrix(),g=A.Vector3.TransformNormal(new A.Vector3(d[0],d[1],d[2]),h).normalize(),m=A.Plane.FromPositionAndNormal(n.position,g.scale(-1));l.mirrorPlane=m,l.level=o,a.reflectionTexture=l}function r(n){const o=n.material,a=new Re.ReflectionProbe("probe-"+o.name,U,e);a.attachToMesh(n),a.renderList&&a.renderList.push(...t(e)),o.reflectionTexture=a.cubeTexture}e.meshes.forEach(n=>{const o=n.metadata;o&&(o.mirrorTexture&&i(n,o.mirrorTexture),o.reflectionProbe&&r(n))})}}class qe{constructor(e,t){this.scene=e,this.intensity=t,this.meshCount=0}setIntensity(e){this.intensity=e,this.glowLayer&&(this.glowLayer.intensity=e)}includeMeshes(e){if(e){this.glowLayer||(this.glowLayer=new Ee.GlowLayer("glow",this.scene),this.glowLayer.intensity=this.intensity);for(const t of e)this.glowLayer.hasMesh(t)||(this.glowLayer.addIncludedOnlyMesh(t),this.meshCount++)}}removeMeshes(e){if(!(!this.glowLayer||!e)){for(const t of e)this.glowLayer.hasMesh(t)&&(this.glowLayer.removeIncludedOnlyMesh(t),this.meshCount--);this.meshCount===0&&(this.glowLayer.dispose(),this.glowLayer=void 0)}}}function De(s,e,t,i,r=""){t.forEach(n=>{const o=n.getID(),a=n.getName(),l=w.getDynamicTextureResolution();s.filter(h=>h.name===r+a).forEach(h=>{const g=i.get(o),m=!1;if(g)W(h,g),g.update(m);else{const f=Ve(a,e,l.width,l.height);i.set(o,f),n.setStaticContext(f.getContext()),W(h,f),f.onLoadObservable.addOnce(()=>{f.update(m)})}})})}function Ve(s,e,t,i){const r=new Fe.DynamicTexture(s,{width:t,height:i},e,w.shouldMipMap(),Ie.Texture.TRILINEAR_SAMPLINGMODE,V.Engine.TEXTUREFORMAT_RGBA),n=r.getContext();return n&&(n.fillStyle="#f5f5f5",n.fillRect(0,0,t,i),r.update()),r}function W(s,e){if(s instanceof O.PBRMaterial){const t=s,i=t.albedoTexture;i?(e.wrapU=i.wrapU,e.wrapV=i.wrapV):(e.wrapU=1,e.wrapV=1),t.albedoTexture=e}else{const t=s,i=t.diffuseTexture;i&&(e.wrapU=i.wrapU,e.wrapV=i.wrapV),t.diffuseTexture=e}}function ke(){const s=()=>Math.floor((1+Math.random())*65536).toString(16).substring(1);return s()+s()+"-"+s()+"-"+s()+"-"+s()+"-"+s()+s()+s()}const x=60,Q=1;function Y(s){return s.targetedAnimations.map(t=>t.animation.framePerSecond).reduce((t,i)=>t+i,0)/s.targetedAnimations.length||0}function Z(s,e,t,i,r,n){const o=r?s.filter(h=>h.name===r):s;if(o.length===0){console.warn(`No animations found for name: ${r}`);return}let a=0;const l=()=>{a++,a===o.length&&n&&n()},d=(h,g,m,f,v)=>{h.stop(),h.start(g,m,f,v),n&&(g==!1||g===void 0&&!h.loopAnimation?h.onAnimationGroupEndObservable.addOnce(()=>{l()}):h.onAnimationLoopObservable.addOnce(()=>{l()}))};if(i!==void 0&&t!==void 0&&i===t){o.forEach(h=>{const g=Y(h),m=i*g;d(h,!1,Q,m,m)});return}o.forEach(h=>{const g=Y(h),m=i!==void 0?i*g:void 0,f=t!==void 0?t*g:void 0;d(h,e,Q,m,f)})}function ze(s,e,t){return new Promise(i=>{s.stopAnimation(e),e.animations=[],Math.abs(e.alpha)>2*Math.PI&&(e.alpha=Ne(e.alpha,0,2*Math.PI));const r=[],n=t.target,o=0,a=n?1:0;if(t.target&&Object.keys(t.target).length>0&&r.push(E("cameraTargetLerp","target",new p.Vector3().copyFrom(e.target),new p.Vector3(t.target.x,t.target.y,t.target.z),C.Animation.ANIMATIONTYPE_VECTOR3,o)),r.push(E("cameraAlphaLerp","alpha",e.alpha,$(t.lonDeg),C.Animation.ANIMATIONTYPE_FLOAT,a)),r.push(E("cameraBetaLerp","beta",e.beta,$(t.latDeg),C.Animation.ANIMATIONTYPE_FLOAT,a)),t.radius!==void 0){const h=Math.max(.01,t.radius);r.push(E("cameraRadiusLerp","radius",e.radius,h,C.Animation.ANIMATIONTYPE_FLOAT,a))}e.animations.push(...r);const d=e.useAutoRotationBehavior;e.disableAutoRotationBehavior(),s.beginAnimation(e,0,n?x*2:x,!1,1,()=>{e.animations=[],d&&e.enableAutoRotationBehavior(),i()})})}function $(s){return s*Math.PI/180}function E(s,e,t,i,r,n=0,o=C.Animation.ANIMATIONLOOPMODE_CONSTANT){const a=new N.QuadraticEase;a.setEasingMode(N.EasingFunction.EASINGMODE_EASEINOUT);const l=new C.Animation(s,e,x,r,o),d=[];return n>0&&d.push({frame:0,value:t}),d.push({frame:x*n,value:t}),d.push({frame:x*(n+1),value:i}),l.setKeys(d),l.setEasingFunction(a),l}function Ne(s,e,t){return s<e?s=t-(e-s)%(t-e):s=e+(s-e)%(t-e)}function Ge(s,e,t){s.forEach(i=>{t&&i.name!==t||i.goToFrame(e)})}const He={albedoTexture:"albedoMap",bumpTexture:"normalMap",ambientTexture:"ambientMap",emissiveTexture:"emissionMap",opacityTexture:"alphaMap",metallicTexture:"metallicMap",refractionTexture:"refractionMap",reflectionTexture:"reflectionMap"};function Ke(s,e,t,i){["albedoTexture","bumpTexture","ambientTexture","emissiveTexture","opacityTexture","metallicTexture","refractionTexture","reflectionTexture"].forEach(n=>{Ue(n,s,e,t,i)}),Ye(s,e)}function Ue(s,e,t,i,r){const n=He[s];if(!n)throw new Error("Unexpected texture name encountered.");const o=e[n],a=o==null?void 0:o.fileLink;a?s==="reflectionTexture"?a.endsWith(".env")||a.endsWith(".dds")?i.addCubeTextureTask(s,a,void 0,!1,void 0,!0):a.endsWith(".hdr")?i.addHDRCubeTextureTask(s,a,128,!1,!0,!1):i.addTextureTask(s,a,!1,!1):i.addTextureTask(s,a,!1,!1):r&&t[s]&&(t[s]&&t[s].dispose(),t[s]=null,We(s,t))}function We(s,e){s==="opacityTexture"&&(e.useAlphaFromAlbedoTexture=!0),s==="metallicTexture"&&(e.useRoughnessFromMetallicTextureAlpha=!1,e.useRoughnessFromMetallicTextureGreen=!1,e.useMetallnessFromMetallicTextureBlue=!1),s==="refractionTexture"&&(e.subSurface.isRefractionEnabled=!1,e.subSurface.refractionIntensity=1),s==="reflectionTexture"&&(e.environmentIntensity=1),s==="emissiveTexture"&&(e.emissiveIntensity=0,e.emissiveColor=new b.Color3(0,0,0),e.reflectionTexture)}function Qe(s,e,t,i){if(!e){console.error("Failed to apply texture to material: material is null.");return}s==="opacityTexture"&&(e.useAlphaFromAlbedoTexture=!1),s==="metallicTexture"&&(e.useRoughnessFromMetallicTextureAlpha=!1,e.useRoughnessFromMetallicTextureGreen=!0,e.useMetallnessFromMetallicTextureBlue=!0),s==="refractionTexture"&&(e.subSurface.isRefractionEnabled=!0,e.subSurface.refractionIntensity=t.refractionIntensity||1),s==="reflectionTexture"&&(e.environmentIntensity=t.reflectionIntensity||1,i.isCube&&(i.rotationY=t.reflectionRotation?t.reflectionRotation*Math.PI/180:0)),e[s]=i,s==="emissiveTexture"&&(e.emissiveColor=new b.Color3(1,1,1),e.emissiveIntensity=1)}function Ye(s,e){s.clearCoat&&(s.clearCoat===R.RemoveWhenSelected?(e.clearCoat.isEnabled=!1,e.clearCoat.indexOfRefraction=1.5):s.clearCoat===R.ApplyWhenSelected&&(e.clearCoat.isEnabled=!0,e.clearCoat.indexOfRefraction=s.clearCoatIOR||e.clearCoat.indexOfRefraction))}class Ze{constructor(e,t,i){this.materialVariantMap=new Map,this.keysThatRemovedBaseModel=[],this.loadedContainerForKey=new Map,this.loadedMaterialsForKey=new Map,this.scene=e,this.renameClonedAsset=t,this.setBaseModelEnabled=i}async applyMaterial(e,t,i,r){return new Promise(n=>{const o=this.materialVariantMap.get(e);this.materialVariantMap.set(e,{...o,...t});const a=this.renameClonedAsset(e),l=this.scene.materials.filter(h=>h.name===a);if(l.length===0){n();return}const d=new Se.AssetsManager(this.scene);d.useDefaultLoadingScreen=!1,l.forEach(h=>Ke(t,h,d,r)),d.onProgress=(h,g,m)=>{i&&i(h/g*100,100,m.name)},d.onFinish=h=>{h.forEach(g=>{const m=g;i&&i(100,100,g.name),this.scene.materials.filter(v=>v.name===a).forEach(v=>Qe(g.name,v,t,m.texture))}),n()},d.loadAsync()})}async applyModel(e,t,i,r,n,o,a){var g;if(i&&t&&!this.keysThatRemovedBaseModel.includes(e)&&this.keysThatRemovedBaseModel.push(e),!i)return this.keysThatRemovedBaseModel.includes(e)&&this.keysThatRemovedBaseModel.length===1&&await this.setBaseModelEnabled(!0),(g=this.loadedContainerForKey.get(e))==null||g.dispose(),this.loadedContainerForKey.delete(e),this.loadedMaterialsForKey.delete(e),this.keysThatRemovedBaseModel=this.keysThatRemovedBaseModel.filter(m=>m!==e),Promise.resolve(void 0);const d=(await S(i,this.scene,r)).instantiateModelsToScene(this.renameClonedAsset,!0);if(this.loadedContainerForKey.has(e)&&(this.loadedContainerForKey.get(e).dispose(),this.loadedContainerForKey.delete(e),this.loadedMaterialsForKey.delete(e)),n){const m=o&&o(),f=n.name?this.renameClonedAsset(n.name):void 0;if(Z(d.animationGroups,n.loop,n.to,n.from,f),m!=null){const v=a&&a()||!0;Ge(d.animationGroups,m+(v?2:0),f)}}t&&await this.setBaseModelEnabled(!1),this.loadedContainerForKey.set(e,d),this.loadedMaterialsForKey.set(e,X(d));const h=[];return this.materialVariantMap.forEach(async(m,f)=>{h.push(this.applyMaterial(f,m))}),await Promise.all(h),d}dispose(){this.loadedContainerForKey.forEach(e=>e==null?void 0:e.dispose()),this.loadedContainerForKey.clear(),this.loadedMaterialsForKey.forEach(e=>e.forEach(t=>t==null?void 0:t.dispose())),this.loadedMaterialsForKey.clear(),this.materialVariantMap.clear(),this.keysThatRemovedBaseModel=[]}getAllMaterials(){const e=[];return this.loadedMaterialsForKey.forEach(t=>{t.forEach(i=>{e.includes(i)||e.push(i)})}),e}getAnimationGroups(){const e=[];return this.loadedContainerForKey.forEach(t=>{e.push(...t.animationGroups)}),e}}function X(s){const e=[];return s.rootNodes.forEach(t=>{t.getChildMeshes().forEach(i=>{i.material&&!e.includes(i.material)&&e.push(i.material),i.subMeshes&&i.subMeshes.forEach(r=>{const n=r.getMaterial(!1);n&&!e.includes(n)&&e.push(n)})})}),e}function J(s,e=""){return s.map(t=>({name:t.name.substring(e.length),loop:t.loopAnimation,to:t.to,from:t.from}))}class $e{constructor(e){this.metadata=new Map,this.materialSelectedObservable=new M.Observable,this.materialDeselectedObservable=new M.Observable,this.materialVariantObservable=new M.Observable,this.modelVariantObservable=new M.Observable,this.materialReadyToLoadCallbacks=new Map,this.modelReadyToLoadCallbacks=new Map,this.dynamicTextures=new Map,this.queuedMaterialChanges=new Map,this.materialChangesInProgress=[],this.queuedModelChanges=new Map,this.modelChangesInProgress=[],this.isExecutingAnimation=!1,this.animations=[],this.initialized=!1,this.materials=[];const{enablePicking:t,modelDetails:i,previewService:r,progressHandler:n,scene:o}=e;this.enablePicking=t,this.contextService=i.contextService,this.id=ke(),this.previewService=r,this.scene=o,this.variantManager=new Ze(o,this.renameClonedAsset.bind(this),this.setBaseModelEnabled.bind(this)),this.transformRoot=new Oe.TransformNode("root",this.scene);const a=async()=>{if(!i.model)throw new Error("Model container constructed with no URL. This is currently unsupported.");return this.assetContainer=await S(i.model,o,n),await this.instantiate(),this};this.importPromise=a()}async applyMaterialVariant(e,t,i,r){if(!this.initialized){if(this.materialReadyToLoadCallbacks.has(e)){const o=this.materialReadyToLoadCallbacks.get(e);o==null||o.set(t,this.applyMaterialVariant.bind(this,e,t,i,r))}else{this.materialReadyToLoadCallbacks.set(e,new Map);const o=this.materialReadyToLoadCallbacks.get(e);o==null||o.set(t,this.applyMaterialVariant.bind(this,e,t,i,r))}return}const n=async()=>{await this.variantManager.applyMaterial(e,i,(o,a,l)=>{this.materialVariantObservable.notifyObservers({remainingCount:o,totalCount:a,taskName:l})},r)};if(this.materialChangesInProgress.includes(e)){if(this.queuedMaterialChanges.has(e)){const o=this.queuedMaterialChanges.get(e);o==null||o.set(t,n)}else{this.queuedMaterialChanges.set(e,new Map);const o=this.queuedMaterialChanges.get(e);o==null||o.set(t,n)}return}if(this.materialChangesInProgress.push(e),await n(),this.queuedMaterialChanges.has(e)){const o=this.queuedMaterialChanges.get(e);if(!o)throw new Error("Target material is undefined");o.forEach(async a=>{await a()}),this.queuedMaterialChanges.delete(e)}this.materialChangesInProgress.splice(this.materialChangesInProgress.indexOf(e),1),this.configureGlowLayer()}async applyModelVariant(e,t,i){if(!this.initialized){this.modelReadyToLoadCallbacks.set(e,this.applyModelVariant.bind(this,e,t,i));return}const r=()=>this.variantManager.applyModel(e,i,t==null?void 0:t.model,a=>{this.modelVariantObservable.notifyObservers({...a,key:e})},this.lastPlayedAnimation,this.getCurrentAnimationFrame.bind(this),this.getAnimationIsPlaying.bind(this));if(this.modelChangesInProgress.includes(e)){this.queuedModelChanges.set(e,r);return}const o=await(async()=>{this.modelChangesInProgress.push(e);let a=await r();if(this.queuedModelChanges.has(e)){const l=this.queuedModelChanges.get(e);if(!l)throw new Error("Queued change resolved undefined");a=await l(),this.queuedModelChanges.delete(e)}return this.modelChangesInProgress.splice(this.modelChangesInProgress.indexOf(e),1),a})();this.contextService||(this.contextService=t==null?void 0:t.contextService),o?this.configureModelInstance(o):this.configureGlowLayer()}dispose(){var e;this.destroyInstance(),this.variantManager.dispose(),this.dynamicTextures.forEach(t=>t==null?void 0:t.dispose()),this.dynamicTextures.clear(),this.materials.forEach(t=>t&&(t==null?void 0:t.dispose())),this.materials=[],(e=this.transformRoot)==null||e.dispose(),this.transformRoot=void 0,this.previewService.modelUnloaded(this)}executeAnimation(e){if(!this.initialized)return this.queuedModelAnimation=e,Promise.resolve();let t=()=>{};const i=async()=>{this.lastPlayedAnimation=e,this.isExecutingAnimation=!0,await new Promise(r=>{var o;const n=[...((o=this.modelInstance)==null?void 0:o.animationGroups)||[],...this.variantManager.getAnimationGroups()];Z(n,e.loop,e.to,e.from,e.name?this.renameClonedAsset(e.name):void 0,r)}),this.isExecutingAnimation=!1,this.queuedAnimationFunction&&this.queuedAnimationFunction(),this.queuedAnimationFunction=void 0,t()};return this.isExecutingAnimation?(this.queuedAnimationFunction=i,new Promise(r=>{t=r})):i()}getAnimations(e){return[...this.animations,...e?J(this.variantManager.getAnimationGroups(),this.renameClonedAsset("")):[]]}getId(){return this.id}listMaterials(){var t;const e=(t=this.scene)==null?void 0:t.materials.filter(i=>i.name.startsWith(this.id));return e?e.map(i=>({id:i.id,name:this.stripIdFromName(i.name)})):[]}registerMaterialSelectedCallback(e){this.materialSelectedObservable.add(e)}unregisterMaterialSelectedCallback(e){this.materialSelectedObservable.removeCallback(e)}registerMaterialDeselectedCallback(e){this.materialDeselectedObservable.add(e)}unregisterMaterialDeselectedCallback(e){this.materialDeselectedObservable.removeCallback(e)}get position(){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to requesting position!");return this.transformRoot.position}set position(e){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to setting position!");this.transformRoot.position=new p.Vector3(e.x,e.y,e.z)}get rotation(){var e;if(!((e=this.transformRoot)!=null&&e.rotationQuaternion))throw new Error("ModelContainer disposed prior to requesting rotation!");return this.transformRoot.rotationQuaternion.toEulerAngles()}set rotation(e){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to setting rotation!");this.transformRoot.rotationQuaternion=p.Quaternion.FromEulerAngles(e.x,e.y,e.z)}get scale(){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to requesting scale!");return this.transformRoot.scaling}set scale(e){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to setting scale!");this.transformRoot.scaling=new p.Vector3(e.x,e.y,e.z)}attachPickingHandler(e){e.rootNodes.forEach(t=>{t.getChildMeshes(!1).forEach(i=>{i.name==="targetcube_t"||i.name==="backgroundShell"||(i.actionManager||(i.actionManager=new F.ActionManager(this.scene)),i.actionManager.registerAction(new z.ExecuteCodeAction(F.ActionManager.OnPointerOverTrigger,r=>{r.meshUnderPointer&&i.material&&this.materialSelectedObservable.notifyObservers({id:i.material.id,name:this.stripIdFromName(i.material.name)})})),i.actionManager.registerAction(new z.ExecuteCodeAction(F.ActionManager.OnPointerOutTrigger,()=>{i.material&&this.materialDeselectedObservable.notifyObservers({id:i.material.id,name:this.stripIdFromName(i.material.name)})})))})})}getInitializationPromise(){return this.importPromise}getIsInitialized(){return this.initialized}getQueuedMaterialVariantCount(){return this.materialReadyToLoadCallbacks.size}getQueuedModelVariantCount(){return this.modelReadyToLoadCallbacks.size}configureGlowLayer(){const e=i=>i instanceof O.PBRMaterial&&i.emissiveTexture!==null;this.materials.some(e)||this.variantManager.getAllMaterials().some(e)?this.previewService.getGlowLayerManager().includeMeshes(this.getAllMeshes()):this.previewService.getGlowLayerManager().removeMeshes(this.getAllMeshes())}configureModelInstance(e){var n;if(!this.transformRoot)throw new Error("Transform disposed! This should never happen unless there is a race condition present!");const t=this.transformRoot.position,i=this.transformRoot.rotationQuaternion,r=this.transformRoot.scaling;this.transformRoot.position=p.Vector3.Zero(),this.transformRoot.rotationQuaternion=p.Quaternion.Identity(),this.transformRoot.scaling=p.Vector3.One();for(const o of e.rootNodes){o.parent=this.transformRoot;for(const a of o.getChildMeshes(!1))a.alwaysSelectAsActiveMesh=!0}this.transformRoot.position=t,this.transformRoot.rotationQuaternion=i,this.transformRoot.scaling=r,this.canvasPanels=((n=this.contextService)==null?void 0:n.getAll())||new Map,De(this.materials.concat(this.variantManager.getAllMaterials()),this.scene,this.canvasPanels,this.dynamicTextures,`${this.id}_`),this.enablePicking&&this.attachPickingHandler(e),this.configureGlowLayer()}destroyInstance(){var e;(e=this.modelInstance)==null||e.dispose(),this.modelInstance=void 0}getAllMeshes(){var e;return(e=this.modelInstance)==null?void 0:e.rootNodes.map(t=>t.getChildMeshes(!1).filter(i=>i instanceof Le.Mesh)).flat()}async instantiate(){if(!this.assetContainer)throw new Error("Attempted to instantiate ModelContainer without an AssetContainer");this.modelInstance=this.assetContainer.instantiateModelsToScene(this.renameClonedAsset.bind(this),!0),this.materials=X(this.modelInstance),this.configureModelInstance(this.modelInstance),this.animations=J(this.modelInstance.animationGroups,this.renameClonedAsset("")),this.initialized=!0,await this.processQueuedEvents()}renameClonedAsset(e){return`${this.id}_${e}`}async setBaseModelEnabled(e){e&&!this.modelInstance?await this.instantiate():!e&&this.modelInstance&&this.destroyInstance()}updateDynamicTextures(){var e;(e=this.canvasPanels)==null||e.forEach((t,i)=>{const r=this.dynamicTextures.get(i);r&&t.getStaticContextDirty()&&r.isReady()&&(r.update(!1),t.setStaticContextDirty(!1))})}registerMaterialVariantListener(e){this.materialVariantObservable.add(e)}unregisterMaterialVariantListener(e){this.materialVariantObservable.removeCallback(e)}registerModelVariantListener(e){this.modelVariantObservable.add(e)}unregisterModelVariantListener(e){this.modelVariantObservable.removeCallback(e)}getCurrentAnimationFrame(){var t;const e=[...((t=this.modelInstance)==null?void 0:t.animationGroups)||[],...this.variantManager.getAnimationGroups()];for(const i of e)if(i.animatables.length>0&&i.animatables[0].masterFrame!==void 0&&i.animatables[0].masterFrame!==null)return i.animatables[0].masterFrame;return 0}getAnimationIsPlaying(){var t;const e=[...((t=this.modelInstance)==null?void 0:t.animationGroups)||[],...this.variantManager.getAnimationGroups()];for(const i of e)if(i.isPlaying)return!0;return!1}stripIdFromName(e){return e.substring(this.id.length+1)}async processQueuedEvents(){await Promise.all(Array.from(this.materialReadyToLoadCallbacks.values()).flatMap(e=>Array.from(e.values()).map(t=>t()))),this.materialReadyToLoadCallbacks.clear(),await Promise.all(Array.from(this.modelReadyToLoadCallbacks.values()).map(e=>e())),this.modelReadyToLoadCallbacks.clear(),this.scene.onAfterRenderObservable.addOnce(()=>{this.queuedModelAnimation&&(this.executeAnimation(this.queuedModelAnimation),this.queuedModelAnimation=void 0)})}}class B extends y.ArcRotateCamera{constructor(e,t,i,r,n,o,a,l){super(e,t,i,r,n,o,l),this.lastFocus=new p.Vector3(0,0,0),this._isRunningFramingBehavior=!1,this.panDenominator=1,this.panEnabled=!0,this.minZ=.01,this.updateRadiusBounds(this.radius),this.enableFramingBehavior(),this.wheelDeltaPercentage=.01,this.pinchDeltaPercentage=.005,this.useNaturalPinchZoom=!0,a.camera.autoOrientation&&(this.alpha+=Math.PI),a&&(a.camera.limits.min.beta&&(this.lowerBetaLimit=a.camera.limits.min.beta),a.camera.limits.max.beta&&(this.upperBetaLimit=a.camera.limits.max.beta),a.camera.limits.min.alpha&&(this.lowerAlphaLimit=a.camera.limits.min.alpha),a.camera.limits.max.alpha&&(this.upperAlphaLimit=a.camera.limits.max.alpha),a.camera.limits.min.radius&&(this.lowerRadiusLimit=a.camera.limits.min.radius),a.camera.limits.max.radius&&(this.upperRadiusLimit=a.camera.limits.max.radius),a.camera.autoRotation.enabled&&this.enableAutoRotationBehavior(a.camera.autoRotation.idleTimeMs))}updateConfiguration(e){e&&(this.lowerBetaLimit=e.camera.limits.min.beta??null,this.upperBetaLimit=e.camera.limits.max.beta??null,this.lowerAlphaLimit=e.camera.limits.min.alpha??null,this.upperAlphaLimit=e.camera.limits.max.alpha??null,e.camera.autoRotation.enabled?this.enableAutoRotationBehavior(e.camera.autoRotation.idleTimeMs):this.disableAutoRotationBehavior())}get isRunningFramingBehavior(){return this._isRunningFramingBehavior}set isRunningFramingBehavior(e){this._isRunningFramingBehavior=e,!e&&this.framingBehaviourCallback&&(this.framingBehaviourCallback(),this.framingBehaviourCallback=void 0)}setPanEnabled(e){this.panEnabled=e,this.panningSensibility=1e3/this.panDenominator,this.panningAxis=e?new p.Vector3(1,1,0):new p.Vector3(0,0,0)}getFramingBehavior(){return this.getBehaviorByName("Framing")}getAutoRotationBehavior(){const e=this.getBehaviorByName("AutoRotation");if(e)return e}enableFramingBehavior(){this.useFramingBehavior=!0;const e=this.getFramingBehavior();e.attach(this),e.framingTime=0,e.elevationReturnTime=-1,e.zoomStopsAnimation=!1,this.lowerRadiusLimit=null;const t=j(this._scene);return e.zoomOnBoundingInfo(t.min,t.max),this.wheelPrecision=100/this.radius,this.lowerRadiusLimit===null&&(this.lowerRadiusLimit=.1),this.lastFocus.copyFrom(this.target),e}rerunFramingBehavior(e,t){this._isRunningFramingBehavior=!0,this.framingBehaviourCallback=e;const i=this.getFramingBehavior();i.framingTime=t||800;const r=()=>{this.isRunningFramingBehavior=!1},n=j(this._scene),o=n.max.subtract(n.min),a=n.min.add(o.scale(.5));this.updateRadiusBounds(o.length()*1.5),this.wheelPrecision=100/this.radius,this.panningInertia=0,this.panningOriginTarget.copyFrom(a),this.panDenominator=o.length(),this.lastFocus.copyFrom(a),i.zoomOnBoundingInfo(n.min,n.max,void 0,r),i.framingTime=0}enableAutoRotationBehavior(e=5e3){this.useAutoRotationBehavior=!0;const t=this.getAutoRotationBehavior();t&&(t.idleRotationWaitTime=e)}disableAutoRotationBehavior(){this.useAutoRotationBehavior=!1}updateRadiusBounds(e){this.maxZ=e*1e3,this.lowerRadiusLimit=e*.01,this.upperRadiusLimit=1.5*e,this.wheelPrecision=100/e,this.pinchPrecision=300/e}static create(e,t,i){var l;const r=j(e),n=r.max.subtract(r.min),o=r.min.add(n.scale(.5)),a=new B("ProductCamera",-(Math.PI/2),Math.PI/2,n.length()*1.5,o,e,t);return a.setPanEnabled(((l=t.options)==null?void 0:l.noPan)!==void 0?!t.options.noPan:!0),a.panningInertia=0,a.panningOriginTarget.copyFrom(o),a.panDenominator=n.length(),a.onAfterCheckInputsObservable.addOnce(()=>{a.setPanEnabled(a.panEnabled)}),i&&(e.activeCamera=a),a}}function j(s){if(s.meshes.length===0)return{min:new p.Vector3(-1,-1,-1),max:new p.Vector3(1,1,1)};const e=s.meshes.filter(t=>t.name.toLowerCase().endsWith("_t")||t.name.toLowerCase().includes("_t_"));return s.getWorldExtends(t=>t.isVisible&&t.isEnabled()&&(e.length===0||e.includes(t)))}class Xe{constructor(e,t=!1,i=void 0){this.renderingPipeline=new Be.DefaultRenderingPipeline("default",t,e,i?[i]:void 0,!1),this.renderingPipeline.isSupported&&(this.renderingPipeline.prepare(),this.setConfiguration(u))}dispose(){this.renderingPipeline.dispose()}getConfiguration(){return this.currentConfiguration}setConfiguration(e){var t,i,r,n,o,a,l,d,h,g,m,f,v,_,ee,te,ie,ne,se,re,ae,oe,le,he,ce,de,ue,ge,me,pe,fe,be,ve;if(this.renderingPipeline.isSupported){if(this.renderingPipeline.samples=((t=e.antiAliasing)==null?void 0:t.samples)??u.antiAliasing.samples,this.renderingPipeline.fxaaEnabled=((i=e.antiAliasing)==null?void 0:i.fxaaEnabled)??u.antiAliasing.fxaaEnabled,this.renderingPipeline.bloomEnabled=((r=e.bloom)==null?void 0:r.enabled)??u.bloom.enabled,this.renderingPipeline.bloomKernel=((n=e.bloom)==null?void 0:n.kernel)??u.bloom.kernel,this.renderingPipeline.bloomScale=((o=e.bloom)==null?void 0:o.scale)??u.bloom.scale,this.renderingPipeline.bloomThreshold=((a=e.bloom)==null?void 0:a.threshold)??u.bloom.threshold,this.renderingPipeline.bloomWeight=((l=e.bloom)==null?void 0:l.weight)??u.bloom.weight,this.renderingPipeline.chromaticAberrationEnabled=((d=e.chromaticAberration)==null?void 0:d.enabled)??u.chromaticAberration.enabled,this.renderingPipeline.chromaticAberration.aberrationAmount=((h=e.chromaticAberration)==null?void 0:h.aberrationAmount)??u.chromaticAberration.aberrationAmount,this.renderingPipeline.chromaticAberration.radialIntensity=((g=e.chromaticAberration)==null?void 0:g.radialIntensity)??u.chromaticAberration.radialIntensity,this.renderingPipeline.chromaticAberration.direction=(m=e.chromaticAberration)!=null&&m.direction?new p.Vector2(e.chromaticAberration.direction.x,e.chromaticAberration.direction.y):new p.Vector2(u.chromaticAberration.direction.x,u.chromaticAberration.direction.y),this.renderingPipeline.imageProcessing.colorCurvesEnabled=((f=e.colorCurves)==null?void 0:f.enabled)??u.colorCurves.enabled,this.renderingPipeline.imageProcessing.colorCurves=e.colorCurves?this.updateColorCurve(e.colorCurves):new G.ColorCurves,this.renderingPipeline.depthOfFieldEnabled=((v=e.depthOfField)==null?void 0:v.enabled)??u.depthOfField.enabled,e.depthOfField)switch(e.depthOfField.blurLevel??u.depthOfField.blurLevel){case"Low":this.renderingPipeline.depthOfFieldBlurLevel=I.DepthOfFieldEffectBlurLevel.Low;break;case"Medium":this.renderingPipeline.depthOfFieldBlurLevel=I.DepthOfFieldEffectBlurLevel.Medium;break;case"High":this.renderingPipeline.depthOfFieldBlurLevel=I.DepthOfFieldEffectBlurLevel.High;break}if(this.renderingPipeline.depthOfField.focalLength=((_=e.depthOfField)==null?void 0:_.focalLength)??u.depthOfField.focalLength,this.renderingPipeline.depthOfField.fStop=((ee=e.depthOfField)==null?void 0:ee.fStop)??u.depthOfField.fStop,this.renderingPipeline.depthOfField.focusDistance=((te=e.depthOfField)==null?void 0:te.focusDistance)??u.depthOfField.focusDistance,this.renderingPipeline.depthOfField.lensSize=((ie=e.depthOfField)==null?void 0:ie.lensSize)??u.depthOfField.lensSize,this.renderingPipeline.grainEnabled=((ne=e.grain)==null?void 0:ne.enabled)??u.grain.enabled,this.renderingPipeline.grain.animated=((se=e.grain)==null?void 0:se.animated)??u.grain.animated,this.renderingPipeline.grain.intensity=((re=e.grain)==null?void 0:re.intensity)??u.grain.intensity,this.renderingPipeline.imageProcessing.contrast=((ae=e.misc)==null?void 0:ae.contrast)??u.misc.contrast,this.renderingPipeline.imageProcessing.exposure=((oe=e.misc)==null?void 0:oe.exposure)??u.misc.exposure,this.renderingPipeline.imageProcessing.toneMappingEnabled=((le=e.misc)==null?void 0:le.toneMappingEnabled)??u.misc.toneMappingEnabled,this.renderingPipeline.imageProcessing.toneMappingEnabled)switch(e.misc.toneMappingType??u.misc.toneMappingType){case"Standard":this.renderingPipeline.imageProcessing.toneMappingType=P.ImageProcessingConfiguration.TONEMAPPING_STANDARD;break;case"ACES":this.renderingPipeline.imageProcessing.toneMappingType=P.ImageProcessingConfiguration.TONEMAPPING_ACES;break}if(this.renderingPipeline.sharpenEnabled=((he=e.sharpen)==null?void 0:he.enabled)??u.sharpen.enabled,this.renderingPipeline.sharpen.colorAmount=((ce=e.sharpen)==null?void 0:ce.colorAmount)??u.sharpen.colorAmount,this.renderingPipeline.sharpen.edgeAmount=((de=e.sharpen)==null?void 0:de.edgeAmount)??u.sharpen.edgeAmount,this.renderingPipeline.imageProcessing.vignetteEnabled=((ue=e.vignette)==null?void 0:ue.enabled)??u.vignette.enabled,(ge=e.vignette)!=null&&ge.center?(this.renderingPipeline.imageProcessing.vignetteCenterX=e.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=e.vignette.center.y):(this.renderingPipeline.imageProcessing.vignetteCenterX=u.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=u.vignette.center.y),e.vignette)switch(((me=e.vignette)==null?void 0:me.blendMode)??u.vignette.blendMode){case"Multiply":this.renderingPipeline.imageProcessing.vignetteBlendMode=P.ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY;break;case"Opaque":this.renderingPipeline.imageProcessing.vignetteBlendMode=P.ImageProcessingConfiguration.VIGNETTEMODE_OPAQUE;break}(pe=e.vignette)!=null&&pe.colorRgba?this.renderingPipeline.imageProcessing.vignetteColor=new b.Color4(e.vignette.colorRgba.r,e.vignette.colorRgba.g,e.vignette.colorRgba.b,e.vignette.colorRgba.a):(fe=e.vignette)!=null&&fe.colorHex?this.renderingPipeline.imageProcessing.vignetteColor=b.Color4.FromHexString(e.vignette.colorHex):this.renderingPipeline.imageProcessing.vignetteColor=new b.Color4(u.vignette.colorRgba.r,u.vignette.colorRgba.g,u.vignette.colorRgba.b,u.vignette.colorRgba.a),this.renderingPipeline.imageProcessing.vignetteStretch=((be=e.vignette)==null?void 0:be.stretch)??u.vignette.stretch,this.renderingPipeline.imageProcessing.vignetteWeight=((ve=e.vignette)==null?void 0:ve.weight)??u.vignette.weight,this.renderingPipeline.prepare(),this.currentConfiguration=e}}updateColorCurve(e){const t=new G.ColorCurves;return t.globalDensity=e.globalDensity??t.globalDensity,t.globalExposure=e.globalExposure??t.globalExposure,t.globalHue=e.globalHue??t.globalHue,t.globalSaturation=e.globalSaturation??t.globalSaturation,t.highlightsDensity=e.highlightsDensity??t.highlightsDensity,t.highlightsExposure=e.highlightsExposure??t.highlightsExposure,t.highlightsHue=e.highlightsHue??t.highlightsHue,t.highlightsSaturation=e.highlightsSaturation??t.highlightsSaturation,t.midtonesDensity=e.midtonesDensity??t.midtonesDensity,t.midtonesExposure=e.midtonesExposure??t.midtonesExposure,t.midtonesHue=e.midtonesHue??t.midtonesHue,t.midtonesSaturation=e.midtonesSaturation??t.midtonesSaturation,t.shadowsDensity=e.shadowsDensity??t.shadowsDensity,t.shadowsExposure=e.shadowsExposure??t.shadowsExposure,t.shadowsHue=e.shadowsHue??t.shadowsHue,t.shadowsSaturation=e.shadowsSaturation??t.shadowsSaturation,t}}Ae.GLTF2.GLTFLoader.RegisterExtension("glbPostProcessor",function(s){return new je(s)}),L.SceneLoader.OnPluginActivatedObservable.add(s=>{if(s.name==="gltf"){const e=s;e.transparencyAsCoverage=!0}});function q(s){return new p.Vector3(s.x,s.y,s.z)}function D(s){return{x:s.x,y:s.y,z:s.z}}class Je{constructor(e){var l;this.focusLostNotified=!1,this.focusLostObservable=new M.Observable,this.modelLoadEventCallbacks=[],this.modelContainers=new Map,this.plugins=[],this.initComplete=!1,this.isAnimatingCamera=!1,this.renderLoop=()=>{if(!this.engine.views)return;this.modelContainers.forEach(h=>{h.updateDynamicTextures()}),this.scene.autoClear=!1,this.scene.autoClearDepthAndStencil=!1,this.scene.render(),this.camera.isRunningFramingBehavior&&this.camera.getFramingBehavior().isUserIsMoving&&(this.camera.isRunningFramingBehavior=!1);const d=Math.max((this.camera.lowerRadiusLimit??1)*.01,.001);!this.camera.isRunningFramingBehavior&&!this.camera.target.equalsWithEpsilon(this.camera.lastFocus,d)&&!this.focusLostNotified&&(this.focusLostObservable.notifyObservers(void 0),this.focusLostNotified=!0),this.screenshotPrepareResolve&&(this.screenshotPrepareResolve(),this.screenshotPrepareResolve=void 0)},this.configuration=new K(e);const i=(()=>{if(!(e!=null&&e.noRender))return this.configuration.createCanvas()})(),r="1.5.6";we.DracoCompression.Configuration={decoder:{wasmUrl:`https://www.gstatic.com/draco/versioned/decoders/${r}/draco_wasm_wrapper_gltf.js`,wasmBinaryUrl:`https://www.gstatic.com/draco/versioned/decoders/${r}/draco_decoder_gltf.wasm`,fallbackUrl:`https://www.gstatic.com/draco/versioned/decoders/${r}/draco_decoder_gltf.js`}},i&&(i.getContext("webgl2")||i.getContext("webgl"));const n=console.log;console.log=()=>{};const o=i?new V.Engine(i,!0,{adaptToDeviceRatio:!0,limitDeviceRatio:2,premultipliedAlpha:!1,preserveDrawingBuffer:!!(e!=null&&e.backgroundImage),audioEngine:!1,stencil:this.configuration.highlights.enabled,forceSRGBBufferSupportState:!0}):new ye.NullEngine;console.log=n,o.hideLoadingUI(),window.addEventListener("resize",this.fireResizeEvent.bind(this)),this.engine=o,this.scene=new xe.Scene(o),this.camera=B.create(this.scene,this.configuration),this.scene.activeCamera=this.camera,this.renderingPipeline=new Xe(this.scene,!1,this.camera),this.scene.clearColor=this.configuration.scene.clearColor;const a=k.CubeTexture.CreateFromPrefilteredData(this.configuration.scene.environment.file,this.scene);a.rotationY=this.configuration.scene.environment.rotationY,this.scene.environmentTexture=a,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 qe(this.scene,this.configuration.emissiveGlowIntensity),this.scene.autoClear=!0,this.scene.autoClearDepthAndStencil=!0,this.initPromise=new Promise(d=>{this.scene.onReadyObservable.addOnce(()=>{this.initComplete=!0,d()})}),console.log(this.renderLoop)}getInitializationPromise(){return this.initPromise}getInitializationComplete(){return this.initComplete}getEngineContext(){return{engine:this.engine,scene:this.scene,camera:this.camera}}registerFocusLostListener(e){this.focusLostObservable.add(e)}unregisterFocusLostListener(e){this.focusLostObservable.removeCallback(e)}registerModelLoadEventListener(e){this.modelLoadEventCallbacks.push(e)}unregisterModelLoadEventListener(e){const t=this.modelLoadEventCallbacks.indexOf(e);t>-1&&this.modelLoadEventCallbacks.splice(t,1)}registerView(e){const t=e.height,i=e.width;this.engine.registerView(e,void 0,!0),e.setAttribute("height",t.toString()),e.setAttribute("width",i.toString()),this.orbitEnabled()||this.setCameraState(T.Pan),this.reattachControls(e)}getNumViewports(){var e;return((e=this.engine.views)==null?void 0:e.length)||0}unregisterView(e){this.engine.unRegisterView(e)}shutdown(){this.plugins.forEach(e=>e.dispose(!0)),this.renderingPipeline.dispose(),this.engine&&this.engine.dispose(),window.removeEventListener("resize",this.fireResizeEvent)}executeCameraAnimation(e){if(!this.camera||this.scene.activeCamera!==this.camera||this.getAllModels().length===0||!this.getAllModels().some(r=>r.getIsInitialized()))return this.queuedCameraAnimation=e,Promise.resolve();let t=()=>{};const i=async()=>{this.isAnimatingCamera=!0,await ze(this.scene,this.scene.activeCamera,e),this.isAnimatingCamera=!1,this.queuedAnimationFunction&&this.queuedAnimationFunction(),this.queuedAnimationFunction=void 0,t()};return this.isAnimatingCamera?(this.queuedAnimationFunction=i,new Promise(r=>{t=r})):i()}getCameraPose(){if(this.scene&&this.camera)return{lonDeg:Math.round(this.camera.alpha*180/Math.PI),latDeg:Math.round(this.camera.beta*180/Math.PI),radius:Math.round((this.camera.radius+Number.EPSILON)*1e4)/1e4,target:{x:this.camera.target.x,y:this.camera.target.y,z:this.camera.target.z}}}setCameraPose(e){this.scene&&this.camera&&(this.camera.target=new p.Vector3(e.target.x,e.target.y,e.target.z),this.camera.radius=e.radius,this.camera.alpha=e.latDeg,this.camera.beta=e.lonDeg)}setCameraState(e){var t,i;if(!((t=this.engine)!=null&&t.views)||!((i=this.engine)!=null&&i.views[0]))throw new Error("No views attached, camera state requires a view to attach controls onto.");e===T.Orbit?this.reattachControls(this.engine.views[0].target,2):this.reattachControls(this.engine.views[0].target,0)}animateToLastCameraFocus(){let e=()=>{};const t=async()=>{this.isAnimatingCamera=!0,await new Promise(i=>{this.focusLostNotified=!1;const r=()=>{const n=this.configuration;this.camera.rerunFramingBehavior(()=>{n.camera.limits.min.radius&&(this.camera.lowerRadiusLimit=n.camera.limits.min.radius),n.camera.limits.max.radius&&(this.camera.upperRadiusLimit=n.camera.limits.max.radius),i()})};this.scene.onAfterRenderObservable.addOnce(r)}),this.isAnimatingCamera=!1,this.queuedAnimationFunction&&this.queuedAnimationFunction(),this.queuedAnimationFunction=void 0,e()};return this.isAnimatingCamera?(this.queuedAnimationFunction=t,new Promise(i=>{e=i})):t()}forceStopCameraAnimations(){var e;this.queuedAnimationFunction=void 0,this.queuedCameraAnimation=void 0,this.isAnimatingCamera=!1,(e=this.camera.framingBehavior)==null||e.stopAllAnimations(),this.scene.stopAnimation(this.camera)}setAutoRotation(e){!this.configuration.camera.autoRotation.enabled||!this.camera||(e?this.camera.enableAutoRotationBehavior(this.configuration.camera.autoRotation.idleTimeMs):this.camera.disableAutoRotationBehavior())}getCurrentConfiguration(){return this.configuration.options}async renderSceneScreenshot(e,t){if(!this.camera)throw new Error("Missing product camera, cannot render screenshot!");const i=new y.ArcRotateCamera("screenshotCamera",0,0,0,p.Vector3.Zero(),this.scene);try{const r=t.latDeg*Math.PI/180,n=t.lonDeg*Math.PI/180;i.target=t.target?new p.Vector3(t.target.x,t.target.y,t.target.z):p.Vector3.Zero(),i.alpha=n,i.beta=r,i.radius=t.radius||this.camera.radius,i.minZ=.01,this.scene.render();const o=await Me.Tools.CreateScreenshotUsingRenderTargetAsync(this.engine,i,e,"image/png",2,!0);return i.dispose(),o}catch{throw i.isDisposed()||i.dispose(),new Error("Failed to render screenshot")}}orbitEnabled(){const e=this.configuration;if(!e)return!0;const t=e.camera.limits.min.alpha,i=e.camera.limits.max.alpha,r=e.camera.limits.min.beta,n=e.camera.limits.max.beta;if(t===void 0||i===void 0||r===void 0||n===void 0)return!0;const o=[t,i],a=[r,n],l=o.every(h=>h===t),d=a.every(h=>h===r);return!l&&!d}fireResizeEvent(){this.getNumViewports()>0&&this.engine.resize()}setHighlights(e,t){var r;e.length===0&&((r=this.highlightLayer)==null||r.dispose(),this.highlightLayer=void 0),this.highlightLayer||(this.highlightLayer=new Ce.HighlightLayer("highlights",this.scene,{isStroke:!0,blurVerticalSize:.85,blurHorizontalSize:.85}),this.highlightLayer.innerGlow=!0,this.highlightLayer.outerGlow=!1),this.highlightLayer.removeAllMeshes();const i=t?new b.Color3(t[0],t[1],t[2]).toLinearSpace():void 0;e.forEach(n=>{const o=this.scene.materials.find(a=>a.name===n.name&&a.id===n.id);o&&o.getBindedMeshes().forEach(a=>{var l;return(l=this.highlightLayer)==null?void 0:l.addMesh(a,i||b.Color3.FromHexString("#fcba03"))})})}setRenderingPipelineConfiguration(e){this.renderingPipeline&&this.renderingPipeline.setConfiguration(e)}loadModel(e,t){const{refocusCamera:i=!0,progressHandler:r}=t??{},n=new $e({enablePicking:this.configuration.highlights.enabled,modelDetails:e,scene:this.scene,previewService:this,progressHandler:r});return n.getInitializationPromise().then(()=>{this.modelContainers.size<=1&&i&&(this.forceStopCameraAnimations(),this.camera.rerunFramingBehavior(()=>{this.scene.onAfterRenderObservable.addOnce(()=>{this.queuedCameraAnimation&&(this.executeCameraAnimation(this.queuedCameraAnimation),this.queuedCameraAnimation=void 0)})},1))}),this.configuration.highlights.enabled&&(n.registerMaterialSelectedCallback(o=>{this.setHighlights([o])}),n.registerMaterialDeselectedCallback(()=>{this.setHighlights([])})),this.modelContainers.set(n.getId(),n),this.triggerModelLoadEvent({eventType:"load",modelContainer:n}),n}async preloadModel(e){await S(e,this.scene)}getAllModels(){return Array.from(this.modelContainers.values())}getModelById(e){return this.modelContainers.get(e)}registerPlugin(e){this.plugins.push(e),e.initialize(this,{camera:this.camera,engine:this.engine,scene:this.scene})}unregisterPlugin(e){const t=this.plugins.indexOf(e);t>-1&&this.plugins.splice(t,1).forEach(r=>r.dispose(!1))}getGlowLayerManager(){return this.glowLayerManager}modelUnloaded(e){this.modelContainers.delete(e.getId()),this.triggerModelLoadEvent({eventType:"unload",modelContainer:e})}triggerModelLoadEvent(e){this.modelLoadEventCallbacks.forEach(t=>t(e))}flipTransform(e,t,i){const r=p.Matrix.Compose(q(i||{x:1,y:1,z:1}),p.Quaternion.FromEulerVector(q(t||{x:0,y:0,z:0})),q(e||{x:0,y:0,z:0})),n=p.Matrix.RotationAxis(p.Vector3.Up(),Math.PI),o=r.multiply(n),a=p.Vector3.Zero(),l=p.Quaternion.Identity(),d=p.Vector3.Zero();return o.decompose(d,l,a),l.multiplyInPlace(p.Quaternion.FromEulerAngles(0,Math.PI,0)),{position:D(a),rotation:D(l.toEulerAngles()),scale:D(d)}}updatePreviewOptions(e){var r,n;const t=new K(e);this.configuration.highlights.enabled!==t.highlights.enabled&&this.engine.setStencilBuffer(t.highlights.enabled),this.scene.clearColor=t.scene.clearColor;let i=this.scene.environmentTexture;this.configuration.scene.environment.file!==t.scene.environment.file&&(i=k.CubeTexture.CreateFromPrefilteredData(t.scene.environment.file,this.scene),i.rotationY=this.configuration.scene.environment.rotationY,this.scene.environmentTexture=i),i.rotationY=t.scene.environment.rotationY,this.scene.environmentIntensity=t.scene.environment.intensity,(r=t.options)!=null&&r.renderingPipelineConfiguration?this.renderingPipeline.setConfiguration(t.options.renderingPipelineConfiguration):(this.scene.imageProcessingConfiguration.exposure=t.lighting.exposure,this.scene.imageProcessingConfiguration.contrast=t.lighting.contrast),this.glowLayerManager.setIntensity(t.emissiveGlowIntensity),this.camera.updateConfiguration(t),this.camera.setPanEnabled(((n=t.options)==null?void 0:n.noPan)!==void 0?!t.options.noPan:!0),this.scene.autoClear=!0,this.scene.autoClearDepthAndStencil=!0,this.configuration=t}reattachControls(e,t=2){if(this.scene.detachControl(),this.engine.inputElement=e,this.camera){this.camera.attachControl(!0,!1,t);const i=this.camera.inputs.attached.pointers;i.multiTouchPanning=!1}this.scene.attachControl(!0,!0,!0)}}c.MaterialEffectMode=R,c.ProductCameraRig=T,c.REFLECTION_PROBE_RESOLUTION=U,c.RenderingConfiguration=w,c.SpiffCommerce3DPreviewService=Je,c.renderingPipelineDefaults=u,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spiffcommerce/preview",
3
- "version": "5.7.1-alpha.0",
3
+ "version": "5.7.1-alpha.2",
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",