@spiffcommerce/preview 5.9.5-1 → 5.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1171,6 +1171,7 @@ declare class SpiffCommerce3DPreviewService implements ThreeDPreviewService {
1171
1171
  * to either 0 (left mouse) or 2 (right mouse).
1172
1172
  */
1173
1173
  private reattachControls;
1174
+ static isSupported(): boolean;
1174
1175
  }
1175
1176
 
1176
1177
  /**
package/dist/index.esm.js CHANGED
@@ -1,23 +1,23 @@
1
- import { ArcRotateCamera as fe } from "@babylonjs/core/Cameras/arcRotateCamera";
2
- import { Engine as be } from "@babylonjs/core/Engines/engine";
1
+ import { ArcRotateCamera as be } from "@babylonjs/core/Cameras/arcRotateCamera";
2
+ import { Engine as B } from "@babylonjs/core/Engines/engine";
3
3
  import { NullEngine as Ce } from "@babylonjs/core/Engines/nullEngine";
4
- import { SceneLoader as q } from "@babylonjs/core/Loading/sceneLoader";
5
- import { CubeTexture as ne } from "@babylonjs/core/Materials/Textures/cubeTexture";
4
+ import { SceneLoader as k } from "@babylonjs/core/Loading/sceneLoader";
5
+ import { CubeTexture as se } from "@babylonjs/core/Materials/Textures/cubeTexture";
6
6
  import { Color4 as v, Color3 as C } from "@babylonjs/core/Maths/math.color";
7
- import { Vector3 as g, Quaternion as P, Vector2 as se, Matrix as re } from "@babylonjs/core/Maths/math.vector";
7
+ import { Vector3 as g, Quaternion as x, Vector2 as re, Matrix as ae } from "@babylonjs/core/Maths/math.vector";
8
8
  import { DracoCompression as Ae } from "@babylonjs/core/Meshes/Compression/dracoCompression";
9
9
  import { Observable as M } from "@babylonjs/core/Misc/observable";
10
10
  import { Tools as Me } from "@babylonjs/core/Misc/tools";
11
- import { Scene as Pe } from "@babylonjs/core/scene";
12
- import { GLTF2 as xe } from "@babylonjs/loaders/glTF";
13
- import { GLTFLoaderAnimationStartMode as ye } from "@babylonjs/loaders/glTF/glTFFileLoader";
14
- import { PBRMaterial as k } from "@babylonjs/core/Materials/PBR/pbrMaterial";
11
+ import { Scene as xe } from "@babylonjs/core/scene";
12
+ import { GLTF2 as ye } from "@babylonjs/loaders/glTF";
13
+ import { GLTFLoaderAnimationStartMode as Pe } from "@babylonjs/loaders/glTF/glTFFileLoader";
14
+ import { PBRMaterial as N } from "@babylonjs/core/Materials/PBR/pbrMaterial";
15
15
  import { MirrorTexture as Re } from "@babylonjs/core/Materials/Textures/mirrorTexture";
16
- import { Color3 as Ee, Vector3 as ae, Plane as Te } from "@babylonjs/core/Maths/math";
16
+ import { Color3 as Ee, Vector3 as oe, Plane as Te } from "@babylonjs/core/Maths/math";
17
17
  import { ReflectionProbe as Oe } from "@babylonjs/core/Probes/reflectionProbe";
18
18
  import { GlowLayer as Ie } from "@babylonjs/core/Layers/glowLayer";
19
19
  import { ActionManager as O } from "@babylonjs/core/Actions/actionManager";
20
- import { ExecuteCodeAction as oe } from "@babylonjs/core/Actions/directActions";
20
+ import { ExecuteCodeAction as le } from "@babylonjs/core/Actions/directActions";
21
21
  import { Mesh as Le } from "@babylonjs/core/Meshes/mesh";
22
22
  import { TransformNode as Fe } from "@babylonjs/core/Meshes/transformNode";
23
23
  import { DynamicTexture as Se } from "@babylonjs/core/Materials/Textures/dynamicTexture";
@@ -25,7 +25,7 @@ import { Texture as Be } from "@babylonjs/core/Materials/Textures/texture";
25
25
  import { Animation as A } from "@babylonjs/core/Animations/animation";
26
26
  import { QuadraticEase as De, EasingFunction as qe } from "@babylonjs/core/Animations/easing";
27
27
  import { AssetsManager as ke } from "@babylonjs/core/Misc/assetsManager";
28
- import { ColorCurves as le } from "@babylonjs/core/Materials/colorCurves";
28
+ import { ColorCurves as he } from "@babylonjs/core/Materials/colorCurves";
29
29
  import { ImageProcessingConfiguration as E } from "@babylonjs/core/Materials/imageProcessingConfiguration";
30
30
  import { DefaultRenderingPipeline as Ne } from "@babylonjs/core/PostProcesses/RenderPipeline";
31
31
  import { DepthOfFieldEffectBlurLevel as I } from "@babylonjs/core/PostProcesses/depthOfFieldEffect";
@@ -40,28 +40,28 @@ import "@babylonjs/core/Animations/animatable";
40
40
  import "@babylonjs/core/Misc/screenshotTools";
41
41
  import "@babylonjs/core/Rendering/boundingBoxRenderer";
42
42
  import "@babylonjs/loaders/glTF/2.0/Extensions";
43
- var B = /* @__PURE__ */ ((s) => (s[s.Orbit = 0] = "Orbit", s[s.Pan = 1] = "Pan", s))(B || {}), D = /* @__PURE__ */ ((s) => (s.None = "None", s.RemoveWhenSelected = "RemoveWhenSelected", s.ApplyWhenSelected = "ApplyWhenSelected", s))(D || {});
43
+ var D = /* @__PURE__ */ ((s) => (s[s.Orbit = 0] = "Orbit", s[s.Pan = 1] = "Pan", s))(D || {}), q = /* @__PURE__ */ ((s) => (s.None = "None", s.RemoveWhenSelected = "RemoveWhenSelected", s.ApplyWhenSelected = "ApplyWhenSelected", s))(q || {});
44
44
  function ze() {
45
45
  const s = navigator.vendor.toLowerCase().includes("apple"), e = navigator.maxTouchPoints > 0, t = !navigator.userAgent.toLowerCase().includes("crios");
46
46
  return s && e && t;
47
47
  }
48
- const he = /* @__PURE__ */ new Map();
49
- async function N(s, e, t) {
50
- const i = await he.get(s);
48
+ const ce = /* @__PURE__ */ new Map();
49
+ async function z(s, e, t) {
50
+ const i = await ce.get(s);
51
51
  if (i && i.scene.uid === e.uid)
52
52
  return i;
53
- const r = q.LoadAssetContainerAsync(
53
+ const r = k.LoadAssetContainerAsync(
54
54
  s,
55
55
  void 0,
56
56
  e,
57
57
  t
58
58
  );
59
- return !ze() && he.set(s, r), r;
59
+ return !ze() && ce.set(s, r), r;
60
60
  }
61
- q.OnPluginActivatedObservable.add((s) => {
62
- s.name === "gltf" && (s.animationStartMode = ye.NONE);
61
+ k.OnPluginActivatedObservable.add((s) => {
62
+ s.name === "gltf" && (s.animationStartMode = Pe.NONE);
63
63
  });
64
- class ce {
64
+ class de {
65
65
  constructor(e) {
66
66
  this.getSceneClearColor = () => {
67
67
  var i, r, n, o;
@@ -161,12 +161,12 @@ class ce {
161
161
  return ((e = this.customOptions) == null ? void 0 : e.emissiveGlowIntensity) ?? 0.5;
162
162
  }
163
163
  }
164
- class y {
164
+ class P {
165
165
  /**
166
166
  * Returns the resolution expected for generated textures.
167
167
  */
168
168
  static getDynamicTextureResolution(e = !1) {
169
- return e ? { width: 1, height: 1 } : this.getIsMobile() || !y.offscreenRenderingSupported() ? {
169
+ return e ? { width: 1, height: 1 } : this.getIsMobile() || !P.offscreenRenderingSupported() ? {
170
170
  width: 1024,
171
171
  height: 1024
172
172
  } : {
@@ -303,7 +303,7 @@ class _e {
303
303
  * @param babylonMaterial An instance of a material representation in babylon.
304
304
  */
305
305
  enableMaterialExtrasIfRequired(e, t) {
306
- if (!(!e.extras || !(t instanceof k))) {
306
+ if (!(!e.extras || !(t instanceof N))) {
307
307
  if (e.extras.sheen) {
308
308
  const i = t;
309
309
  i.sheen.isEnabled = !0, i.sheen.intensity = e.extras.sheen;
@@ -350,7 +350,7 @@ class _e {
350
350
  return;
351
351
  const l = new Re(
352
352
  "mirror",
353
- y.getMirrorTextureResolution(),
353
+ P.getMirrorTextureResolution(),
354
354
  e,
355
355
  !0
356
356
  );
@@ -361,8 +361,8 @@ class _e {
361
361
  "Mirror attribute specified on: " + n.name + "But no normals exist to generate a mirror from!"
362
362
  );
363
363
  n.computeWorldMatrix(!0);
364
- const c = n.getWorldMatrix(), u = ae.TransformNormal(
365
- new ae(h[0], h[1], h[2]),
364
+ const c = n.getWorldMatrix(), u = oe.TransformNormal(
365
+ new oe(h[0], h[1], h[2]),
366
366
  c
367
367
  ).normalize(), m = Te.FromPositionAndNormal(
368
368
  n.position,
@@ -408,13 +408,13 @@ class Ge {
408
408
  }
409
409
  function He(s, e, t, i, r = "") {
410
410
  t.forEach((n) => {
411
- const o = n.getID(), a = n.getName(), l = n.getPanelSize && n.getPanelSize(), h = y.getDynamicTextureResolution(
411
+ const o = n.getID(), a = n.getName(), l = n.getPanelSize && n.getPanelSize(), h = P.getDynamicTextureResolution(
412
412
  (l == null ? void 0 : l.width) === 1 || (l == null ? void 0 : l.height) === 1
413
413
  );
414
414
  s.filter((u) => u.name === r + a).forEach((u) => {
415
415
  const m = i.get(o), f = !1;
416
416
  if (m)
417
- de(u, m), m.update(f);
417
+ ue(u, m), m.update(f);
418
418
  else {
419
419
  const p = Ue(
420
420
  a,
@@ -424,7 +424,7 @@ function He(s, e, t, i, r = "") {
424
424
  );
425
425
  i.set(o, p), n.setStaticContext(
426
426
  p.getContext()
427
- ), de(u, p), p.onLoadObservable.addOnce(() => {
427
+ ), ue(u, p), p.onLoadObservable.addOnce(() => {
428
428
  p.update(f);
429
429
  });
430
430
  }
@@ -436,14 +436,14 @@ function Ue(s, e, t, i) {
436
436
  s,
437
437
  { width: t, height: i },
438
438
  e,
439
- y.shouldMipMap(),
439
+ P.shouldMipMap(),
440
440
  Be.TRILINEAR_SAMPLINGMODE,
441
- be.TEXTUREFORMAT_RGBA
441
+ B.TEXTUREFORMAT_RGBA
442
442
  ), n = r.getContext();
443
443
  return n && (n.fillStyle = "#f5f5f5", n.fillRect(0, 0, t, i), r.update()), r;
444
444
  }
445
- function de(s, e) {
446
- if (s instanceof k) {
445
+ function ue(s, e) {
446
+ if (s instanceof N) {
447
447
  const t = s, i = t.albedoTexture;
448
448
  i ? (e.wrapU = i.wrapU, e.wrapV = i.wrapV) : (e.wrapU = 1, e.wrapV = 1), t.albedoTexture = e;
449
449
  } else {
@@ -455,8 +455,8 @@ function Ke() {
455
455
  const s = () => Math.floor((1 + Math.random()) * 65536).toString(16).substring(1);
456
456
  return s() + s() + "-" + s() + "-" + s() + "-" + s() + "-" + s() + s() + s();
457
457
  }
458
- const x = 60, ue = 1;
459
- function me(s) {
458
+ const y = 60, me = 1;
459
+ function ge(s) {
460
460
  return s.targetedAnimations.map((t) => t.animation.framePerSecond).reduce((t, i) => t + i, 0) / s.targetedAnimations.length || 0;
461
461
  }
462
462
  function ve(s, e, t, i, r, n) {
@@ -477,14 +477,14 @@ function ve(s, e, t, i, r, n) {
477
477
  };
478
478
  if (i !== void 0 && t !== void 0 && i === t) {
479
479
  o.forEach((c) => {
480
- const u = me(c), m = i * u;
481
- h(c, !1, ue, m, m);
480
+ const u = ge(c), m = i * u;
481
+ h(c, !1, me, m, m);
482
482
  });
483
483
  return;
484
484
  }
485
485
  o.forEach((c) => {
486
- const u = me(c), m = i !== void 0 ? i * u : void 0, f = t !== void 0 ? t * u : void 0;
487
- h(c, e, ue, m, f);
486
+ const u = ge(c), m = i !== void 0 ? i * u : void 0, f = t !== void 0 ? t * u : void 0;
487
+ h(c, e, me, m, f);
488
488
  });
489
489
  }
490
490
  function We(s, e, t) {
@@ -508,7 +508,7 @@ function We(s, e, t) {
508
508
  "cameraAlphaLerp",
509
509
  "alpha",
510
510
  e.alpha,
511
- ge(t.lonDeg),
511
+ pe(t.lonDeg),
512
512
  A.ANIMATIONTYPE_FLOAT
513
513
  )
514
514
  ), r.push(
@@ -516,7 +516,7 @@ function We(s, e, t) {
516
516
  "cameraBetaLerp",
517
517
  "beta",
518
518
  e.beta,
519
- ge(t.latDeg),
519
+ pe(t.latDeg),
520
520
  A.ANIMATIONTYPE_FLOAT
521
521
  )
522
522
  ), t.radius !== void 0) {
@@ -536,7 +536,7 @@ function We(s, e, t) {
536
536
  e.disableAutoRotationBehavior(), s.beginAnimation(
537
537
  e,
538
538
  0,
539
- n ? x * 2 : x,
539
+ n ? y * 2 : y,
540
540
  !1,
541
541
  1,
542
542
  () => {
@@ -545,7 +545,7 @@ function We(s, e, t) {
545
545
  );
546
546
  });
547
547
  }
548
- function ge(s) {
548
+ function pe(s) {
549
549
  return s * Math.PI / 180;
550
550
  }
551
551
  function T(s, e, t, i, r, n = 0, o = A.ANIMATIONLOOPMODE_CONSTANT) {
@@ -554,12 +554,12 @@ function T(s, e, t, i, r, n = 0, o = A.ANIMATIONLOOPMODE_CONSTANT) {
554
554
  const l = new A(
555
555
  s,
556
556
  e,
557
- x,
557
+ y,
558
558
  r,
559
559
  o
560
560
  ), h = [];
561
- return n > 0 && h.push({ frame: 0, value: t }), h.push({ frame: x * n, value: t }), h.push({
562
- frame: x * (n + 1),
561
+ return n > 0 && h.push({ frame: 0, value: t }), h.push({ frame: y * n, value: t }), h.push({
562
+ frame: y * (n + 1),
563
563
  value: i
564
564
  }), l.setKeys(h), l.setEasingFunction(a), l;
565
565
  }
@@ -633,7 +633,7 @@ function Je(s, e, t, i) {
633
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 C(1, 1, 1), e.emissiveIntensity = 1);
634
634
  }
635
635
  function et(s, e) {
636
- s.clearCoat && (s.clearCoat === D.RemoveWhenSelected ? (e.clearCoat.isEnabled = !1, e.clearCoat.indexOfRefraction = 1.5) : s.clearCoat === D.ApplyWhenSelected && (e.clearCoat.isEnabled = !0, e.clearCoat.indexOfRefraction = s.clearCoatIOR || e.clearCoat.indexOfRefraction));
636
+ s.clearCoat && (s.clearCoat === q.RemoveWhenSelected ? (e.clearCoat.isEnabled = !1, e.clearCoat.indexOfRefraction = 1.5) : s.clearCoat === q.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) {
@@ -705,7 +705,7 @@ class tt {
705
705
  return this.keysThatRemovedBaseModel.includes(e) && this.keysThatRemovedBaseModel.length === 1 && await this.setBaseModelEnabled(!0), (m = this.loadedContainerForKey.get(e)) == null || m.dispose(), this.loadedContainerForKey.delete(e), (f = this.loadedMaterialsForKey.get(e)) == null || f.forEach((b) => b.dispose()), this.loadedMaterialsForKey.delete(e), this.keysThatRemovedBaseModel = this.keysThatRemovedBaseModel.filter(
706
706
  (b) => b !== e
707
707
  ), Promise.resolve(void 0);
708
- const h = (await N(i, this.scene, r)).instantiateModelsToScene(
708
+ const h = (await z(i, this.scene, r)).instantiateModelsToScene(
709
709
  this.renameClonedAsset,
710
710
  !0
711
711
  );
@@ -765,7 +765,7 @@ function we(s) {
765
765
  });
766
766
  }), e;
767
767
  }
768
- function pe(s, e = "") {
768
+ function fe(s, e = "") {
769
769
  return s.map((t) => ({
770
770
  name: t.name.substring(e.length),
771
771
  loop: t.loopAnimation,
@@ -793,7 +793,7 @@ class it {
793
793
  throw new Error(
794
794
  "Model container constructed with no URL. This is currently unsupported."
795
795
  );
796
- return this.assetContainer = await N(
796
+ return this.assetContainer = await z(
797
797
  i.model,
798
798
  o,
799
799
  n
@@ -948,7 +948,7 @@ class it {
948
948
  getAnimations(e) {
949
949
  return [
950
950
  ...this.animations,
951
- ...e ? pe(
951
+ ...e ? fe(
952
952
  this.variantManager.getAnimationGroups(),
953
953
  this.renameClonedAsset("")
954
954
  ) : []
@@ -998,7 +998,7 @@ class it {
998
998
  set rotation(e) {
999
999
  if (!this.transformRoot)
1000
1000
  throw new Error("ModelContainer disposed prior to setting rotation!");
1001
- this.transformRoot.rotationQuaternion = P.FromEulerAngles(
1001
+ this.transformRoot.rotationQuaternion = x.FromEulerAngles(
1002
1002
  e.x,
1003
1003
  e.y,
1004
1004
  e.z
@@ -1020,14 +1020,14 @@ class it {
1020
1020
  e.rootNodes.forEach((t) => {
1021
1021
  t.getChildMeshes(!1).forEach((i) => {
1022
1022
  i.name === "targetcube_t" || i.name === "backgroundShell" || (i.actionManager || (i.actionManager = new O(this.scene)), i.actionManager.registerAction(
1023
- new oe(O.OnPointerOverTrigger, (r) => {
1023
+ new le(O.OnPointerOverTrigger, (r) => {
1024
1024
  r.meshUnderPointer && i.material && this.materialSelectedObservable.notifyObservers({
1025
1025
  id: i.material.id,
1026
1026
  name: this.stripIdFromName(i.material.name)
1027
1027
  });
1028
1028
  })
1029
1029
  ), i.actionManager.registerAction(
1030
- new oe(O.OnPointerOutTrigger, () => {
1030
+ new le(O.OnPointerOutTrigger, () => {
1031
1031
  i.material && this.materialDeselectedObservable.notifyObservers({
1032
1032
  id: i.material.id,
1033
1033
  name: this.stripIdFromName(i.material.name)
@@ -1056,7 +1056,7 @@ class it {
1056
1056
  return this.queuedModelChanges.size;
1057
1057
  }
1058
1058
  configureGlowLayer() {
1059
- const e = (i) => i instanceof k && i.emissiveTexture !== null;
1059
+ const e = (i) => i instanceof N && i.emissiveTexture !== null;
1060
1060
  this.materials.some(e) || this.variantManager.getAllMaterials().some(e) ? this.previewService.getGlowLayerManager().includeMeshes(this.getAllMeshes()) : this.previewService.getGlowLayerManager().removeMeshes(this.getAllMeshes());
1061
1061
  }
1062
1062
  configureModelInstance(e) {
@@ -1066,7 +1066,7 @@ class it {
1066
1066
  "Transform disposed! This should never happen unless there is a race condition present!"
1067
1067
  );
1068
1068
  const t = this.transformRoot.position, i = this.transformRoot.rotationQuaternion, r = this.transformRoot.scaling;
1069
- this.transformRoot.position = g.Zero(), this.transformRoot.rotationQuaternion = P.Identity(), this.transformRoot.scaling = g.One();
1069
+ this.transformRoot.position = g.Zero(), this.transformRoot.rotationQuaternion = x.Identity(), this.transformRoot.scaling = g.One();
1070
1070
  for (const o of e.rootNodes) {
1071
1071
  o.parent = this.transformRoot;
1072
1072
  for (const a of o.getChildMeshes(!1))
@@ -1101,7 +1101,7 @@ class it {
1101
1101
  this.modelInstance = this.assetContainer.instantiateModelsToScene(
1102
1102
  this.renameClonedAsset.bind(this),
1103
1103
  !0
1104
- ), this.materials = we(this.modelInstance), this.configureModelInstance(this.modelInstance), this.animations = pe(
1104
+ ), this.materials = we(this.modelInstance), this.configureModelInstance(this.modelInstance), this.animations = fe(
1105
1105
  this.modelInstance.animationGroups,
1106
1106
  this.renameClonedAsset("")
1107
1107
  ), this.initialized = !0, await this.processQueuedEvents();
@@ -1178,7 +1178,7 @@ class it {
1178
1178
  }
1179
1179
  //#endregion
1180
1180
  }
1181
- class z extends fe {
1181
+ class V extends be {
1182
1182
  constructor(e, t, i, r, n, o, a, l) {
1183
1183
  super(
1184
1184
  e,
@@ -1280,7 +1280,7 @@ class z extends fe {
1280
1280
  */
1281
1281
  static create(e, t, i) {
1282
1282
  var l;
1283
- const r = L(e), n = r.max.subtract(r.min), o = r.min.add(n.scale(0.5)), a = new z(
1283
+ const r = L(e), n = r.max.subtract(r.min), o = r.min.add(n.scale(0.5)), a = new V(
1284
1284
  "ProductCamera",
1285
1285
  -(Math.PI / 2),
1286
1286
  Math.PI / 2,
@@ -1322,22 +1322,16 @@ class nt {
1322
1322
  getConfiguration() {
1323
1323
  return this.currentConfiguration;
1324
1324
  }
1325
- addCamera(e) {
1326
- this.renderingPipeline.addCamera(e), this.renderingPipeline.prepare();
1327
- }
1328
- removeCamera(e) {
1329
- this.renderingPipeline.cameras.includes(e) && this.renderingPipeline.removeCamera(e);
1330
- }
1331
1325
  setConfiguration(e) {
1332
- var t, i, r, n, o, a, l, h, c, u, m, f, p, b, w, R, V, _, G, H, U, K, W, Y, Q, Z, $, j, X, J, ee, te, ie;
1326
+ var t, i, r, n, o, a, l, h, c, u, m, f, p, b, w, R, _, G, H, U, K, W, Y, Q, Z, $, j, X, J, ee, te, ie, ne;
1333
1327
  if (this.renderingPipeline.isSupported) {
1334
- 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 = ((h = e.chromaticAberration) == null ? void 0 : h.enabled) ?? d.chromaticAberration.enabled, this.renderingPipeline.chromaticAberration.aberrationAmount = ((c = e.chromaticAberration) == null ? void 0 : c.aberrationAmount) ?? d.chromaticAberration.aberrationAmount, this.renderingPipeline.chromaticAberration.radialIntensity = ((u = e.chromaticAberration) == null ? void 0 : u.radialIntensity) ?? d.chromaticAberration.radialIntensity, this.renderingPipeline.chromaticAberration.direction = (m = e.chromaticAberration) != null && m.direction ? new se(
1328
+ 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 = ((h = e.chromaticAberration) == null ? void 0 : h.enabled) ?? d.chromaticAberration.enabled, this.renderingPipeline.chromaticAberration.aberrationAmount = ((c = e.chromaticAberration) == null ? void 0 : c.aberrationAmount) ?? d.chromaticAberration.aberrationAmount, this.renderingPipeline.chromaticAberration.radialIntensity = ((u = e.chromaticAberration) == null ? void 0 : u.radialIntensity) ?? d.chromaticAberration.radialIntensity, this.renderingPipeline.chromaticAberration.direction = (m = e.chromaticAberration) != null && m.direction ? new re(
1335
1329
  e.chromaticAberration.direction.x,
1336
1330
  e.chromaticAberration.direction.y
1337
- ) : new se(
1331
+ ) : new re(
1338
1332
  d.chromaticAberration.direction.x,
1339
1333
  d.chromaticAberration.direction.y
1340
- ), this.renderingPipeline.imageProcessing.colorCurvesEnabled = ((f = e.colorCurves) == null ? void 0 : f.enabled) ?? d.colorCurves.enabled, this.renderingPipeline.imageProcessing.colorCurves = e.colorCurves ? this.updateColorCurve(e.colorCurves) : new le(), this.renderingPipeline.depthOfFieldEnabled = ((p = e.depthOfField) == null ? void 0 : p.enabled) ?? d.depthOfField.enabled, e.depthOfField)
1334
+ ), this.renderingPipeline.imageProcessing.colorCurvesEnabled = ((f = e.colorCurves) == null ? void 0 : f.enabled) ?? d.colorCurves.enabled, this.renderingPipeline.imageProcessing.colorCurves = e.colorCurves ? this.updateColorCurve(e.colorCurves) : new he(), this.renderingPipeline.depthOfFieldEnabled = ((p = e.depthOfField) == null ? void 0 : p.enabled) ?? d.depthOfField.enabled, e.depthOfField)
1341
1335
  switch (e.depthOfField.blurLevel ?? d.depthOfField.blurLevel) {
1342
1336
  case "Low":
1343
1337
  this.renderingPipeline.depthOfFieldBlurLevel = I.Low;
@@ -1349,7 +1343,7 @@ class nt {
1349
1343
  this.renderingPipeline.depthOfFieldBlurLevel = I.High;
1350
1344
  break;
1351
1345
  }
1352
- if (this.renderingPipeline.depthOfField.focalLength = ((b = e.depthOfField) == null ? void 0 : b.focalLength) ?? d.depthOfField.focalLength, this.renderingPipeline.depthOfField.fStop = ((w = e.depthOfField) == null ? void 0 : w.fStop) ?? d.depthOfField.fStop, this.renderingPipeline.depthOfField.focusDistance = ((R = e.depthOfField) == null ? void 0 : R.focusDistance) ?? d.depthOfField.focusDistance, this.renderingPipeline.depthOfField.lensSize = ((V = e.depthOfField) == null ? void 0 : V.lensSize) ?? d.depthOfField.lensSize, this.renderingPipeline.grainEnabled = ((_ = e.grain) == null ? void 0 : _.enabled) ?? d.grain.enabled, this.renderingPipeline.grain.animated = ((G = e.grain) == null ? void 0 : G.animated) ?? d.grain.animated, this.renderingPipeline.grain.intensity = ((H = e.grain) == null ? void 0 : H.intensity) ?? d.grain.intensity, this.renderingPipeline.imageProcessing.contrast = ((U = e.misc) == null ? void 0 : U.contrast) ?? d.misc.contrast, this.renderingPipeline.imageProcessing.exposure = ((K = e.misc) == null ? void 0 : K.exposure) ?? d.misc.exposure, this.renderingPipeline.imageProcessing.toneMappingEnabled = ((W = e.misc) == null ? void 0 : W.toneMappingEnabled) ?? d.misc.toneMappingEnabled, this.renderingPipeline.imageProcessing.toneMappingEnabled)
1346
+ if (this.renderingPipeline.depthOfField.focalLength = ((b = e.depthOfField) == null ? void 0 : b.focalLength) ?? d.depthOfField.focalLength, this.renderingPipeline.depthOfField.fStop = ((w = e.depthOfField) == null ? void 0 : w.fStop) ?? d.depthOfField.fStop, this.renderingPipeline.depthOfField.focusDistance = ((R = e.depthOfField) == null ? void 0 : R.focusDistance) ?? d.depthOfField.focusDistance, this.renderingPipeline.depthOfField.lensSize = ((_ = e.depthOfField) == null ? void 0 : _.lensSize) ?? d.depthOfField.lensSize, this.renderingPipeline.grainEnabled = ((G = e.grain) == null ? void 0 : G.enabled) ?? d.grain.enabled, this.renderingPipeline.grain.animated = ((H = e.grain) == null ? void 0 : H.animated) ?? d.grain.animated, this.renderingPipeline.grain.intensity = ((U = e.grain) == null ? void 0 : U.intensity) ?? d.grain.intensity, this.renderingPipeline.imageProcessing.contrast = ((K = e.misc) == null ? void 0 : K.contrast) ?? d.misc.contrast, this.renderingPipeline.imageProcessing.exposure = ((W = e.misc) == null ? void 0 : W.exposure) ?? d.misc.exposure, this.renderingPipeline.imageProcessing.toneMappingEnabled = ((Y = e.misc) == null ? void 0 : Y.toneMappingEnabled) ?? d.misc.toneMappingEnabled, this.renderingPipeline.imageProcessing.toneMappingEnabled)
1353
1347
  switch (e.misc.toneMappingType ?? d.misc.toneMappingType) {
1354
1348
  case "Standard":
1355
1349
  this.renderingPipeline.imageProcessing.toneMappingType = E.TONEMAPPING_STANDARD;
@@ -1358,8 +1352,8 @@ class nt {
1358
1352
  this.renderingPipeline.imageProcessing.toneMappingType = E.TONEMAPPING_ACES;
1359
1353
  break;
1360
1354
  }
1361
- if (this.renderingPipeline.sharpenEnabled = ((Y = e.sharpen) == null ? void 0 : Y.enabled) ?? d.sharpen.enabled, this.renderingPipeline.sharpen.colorAmount = ((Q = e.sharpen) == null ? void 0 : Q.colorAmount) ?? d.sharpen.colorAmount, this.renderingPipeline.sharpen.edgeAmount = ((Z = e.sharpen) == null ? void 0 : Z.edgeAmount) ?? d.sharpen.edgeAmount, this.renderingPipeline.imageProcessing.vignetteEnabled = (($ = e.vignette) == null ? void 0 : $.enabled) ?? d.vignette.enabled, (j = e.vignette) != null && j.center ? (this.renderingPipeline.imageProcessing.vignetteCenterX = e.vignette.center.x, this.renderingPipeline.imageProcessing.vignetteCenterY = e.vignette.center.y) : (this.renderingPipeline.imageProcessing.vignetteCenterX = d.vignette.center.x, this.renderingPipeline.imageProcessing.vignetteCenterY = d.vignette.center.y), e.vignette)
1362
- switch (((X = e.vignette) == null ? void 0 : X.blendMode) ?? d.vignette.blendMode) {
1355
+ if (this.renderingPipeline.sharpenEnabled = ((Q = e.sharpen) == null ? void 0 : Q.enabled) ?? d.sharpen.enabled, this.renderingPipeline.sharpen.colorAmount = ((Z = e.sharpen) == null ? void 0 : Z.colorAmount) ?? d.sharpen.colorAmount, this.renderingPipeline.sharpen.edgeAmount = (($ = e.sharpen) == null ? void 0 : $.edgeAmount) ?? d.sharpen.edgeAmount, this.renderingPipeline.imageProcessing.vignetteEnabled = ((j = e.vignette) == null ? void 0 : j.enabled) ?? d.vignette.enabled, (X = e.vignette) != null && X.center ? (this.renderingPipeline.imageProcessing.vignetteCenterX = e.vignette.center.x, this.renderingPipeline.imageProcessing.vignetteCenterY = e.vignette.center.y) : (this.renderingPipeline.imageProcessing.vignetteCenterX = d.vignette.center.x, this.renderingPipeline.imageProcessing.vignetteCenterY = d.vignette.center.y), e.vignette)
1356
+ switch (((J = e.vignette) == null ? void 0 : J.blendMode) ?? d.vignette.blendMode) {
1363
1357
  case "Multiply":
1364
1358
  this.renderingPipeline.imageProcessing.vignetteBlendMode = E.VIGNETTEMODE_MULTIPLY;
1365
1359
  break;
@@ -1367,28 +1361,28 @@ class nt {
1367
1361
  this.renderingPipeline.imageProcessing.vignetteBlendMode = E.VIGNETTEMODE_OPAQUE;
1368
1362
  break;
1369
1363
  }
1370
- (J = e.vignette) != null && J.colorRgba ? this.renderingPipeline.imageProcessing.vignetteColor = new v(
1364
+ (ee = e.vignette) != null && ee.colorRgba ? this.renderingPipeline.imageProcessing.vignetteColor = new v(
1371
1365
  e.vignette.colorRgba.r,
1372
1366
  e.vignette.colorRgba.g,
1373
1367
  e.vignette.colorRgba.b,
1374
1368
  e.vignette.colorRgba.a
1375
- ) : (ee = e.vignette) != null && ee.colorHex ? this.renderingPipeline.imageProcessing.vignetteColor = v.FromHexString(e.vignette.colorHex) : this.renderingPipeline.imageProcessing.vignetteColor = new v(
1369
+ ) : (te = e.vignette) != null && te.colorHex ? this.renderingPipeline.imageProcessing.vignetteColor = v.FromHexString(e.vignette.colorHex) : this.renderingPipeline.imageProcessing.vignetteColor = new v(
1376
1370
  d.vignette.colorRgba.r,
1377
1371
  d.vignette.colorRgba.g,
1378
1372
  d.vignette.colorRgba.b,
1379
1373
  d.vignette.colorRgba.a
1380
- ), this.renderingPipeline.imageProcessing.vignetteStretch = ((te = e.vignette) == null ? void 0 : te.stretch) ?? d.vignette.stretch, this.renderingPipeline.imageProcessing.vignetteWeight = ((ie = e.vignette) == null ? void 0 : ie.weight) ?? d.vignette.weight, this.renderingPipeline.prepare(), this.currentConfiguration = e;
1374
+ ), this.renderingPipeline.imageProcessing.vignetteStretch = ((ie = e.vignette) == null ? void 0 : ie.stretch) ?? d.vignette.stretch, this.renderingPipeline.imageProcessing.vignetteWeight = ((ne = e.vignette) == null ? void 0 : ne.weight) ?? d.vignette.weight, this.renderingPipeline.prepare(), this.currentConfiguration = e;
1381
1375
  }
1382
1376
  }
1383
1377
  updateColorCurve(e) {
1384
- const t = new le();
1378
+ const t = new he();
1385
1379
  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;
1386
1380
  }
1387
1381
  }
1388
- xe.GLTFLoader.RegisterExtension("glbPostProcessor", function(s) {
1382
+ ye.GLTFLoader.RegisterExtension("glbPostProcessor", function(s) {
1389
1383
  return new _e(s);
1390
1384
  });
1391
- q.OnPluginActivatedObservable.add((s) => {
1385
+ k.OnPluginActivatedObservable.add((s) => {
1392
1386
  if (s.name === "gltf") {
1393
1387
  const e = s;
1394
1388
  e.transparencyAsCoverage = !0;
@@ -1423,7 +1417,7 @@ class Wt {
1423
1417
  this.scene.render(), this.camera.isRunningFramingBehavior && this.camera.getFramingBehavior().isUserIsMoving && (this.camera.isRunningFramingBehavior = !1);
1424
1418
  const c = Math.max((this.camera.lowerRadiusLimit ?? 1) * 0.01, 1e-3);
1425
1419
  !this.camera.isRunningFramingBehavior && !this.camera.target.equalsWithEpsilon(this.camera.lastFocus, c) && !this.focusLostNotified && (this.focusLostObservable.notifyObservers(void 0), this.focusLostNotified = !0);
1426
- }, this.configuration = new ce(e);
1420
+ }, this.configuration = new de(e);
1427
1421
  const i = (() => {
1428
1422
  if (!(e != null && e.noRender))
1429
1423
  return this.configuration.createCanvas();
@@ -1438,7 +1432,7 @@ class Wt {
1438
1432
  const n = console.log;
1439
1433
  console.log = () => {
1440
1434
  };
1441
- const o = i ? new be(i, !0, {
1435
+ const o = i ? new B(i, !0, {
1442
1436
  adaptToDeviceRatio: !0,
1443
1437
  limitDeviceRatio: 2,
1444
1438
  premultipliedAlpha: !1,
@@ -1447,12 +1441,12 @@ class Wt {
1447
1441
  stencil: this.configuration.highlights.enabled,
1448
1442
  forceSRGBBufferSupportState: !0
1449
1443
  }) : new Ce();
1450
- o.enableOfflineSupport = !1, o.doNotHandleContextLost = !0, console.log = n, o.hideLoadingUI(), window.addEventListener("resize", this.fireResizeEvent.bind(this)), this.engine = o, this.scene = new Pe(o), this.camera = z.create(this.scene, this.configuration), this.scene.activeCamera = this.camera, this.renderingPipeline = new nt(
1444
+ o.enableOfflineSupport = !1, o.doNotHandleContextLost = !0, console.log = n, o.hideLoadingUI(), window.addEventListener("resize", this.fireResizeEvent.bind(this)), this.engine = o, this.scene = new xe(o), this.camera = V.create(this.scene, this.configuration), this.scene.activeCamera = this.camera, this.renderingPipeline = new nt(
1451
1445
  this.scene,
1452
1446
  !1,
1453
1447
  this.camera
1454
1448
  ), this.scene.clearColor = this.configuration.scene.clearColor;
1455
- const a = ne.CreateFromPrefilteredData(
1449
+ const a = se.CreateFromPrefilteredData(
1456
1450
  this.configuration.scene.environment.file,
1457
1451
  this.scene
1458
1452
  );
@@ -1495,7 +1489,7 @@ class Wt {
1495
1489
  }
1496
1490
  registerView(e) {
1497
1491
  const t = e.height, i = e.width;
1498
- this.engine.registerView(e, void 0, !0), e.setAttribute("height", t.toString()), e.setAttribute("width", i.toString()), this.orbitEnabled() || this.setCameraState(B.Pan), this.reattachControls(e);
1492
+ this.engine.registerView(e, void 0, !0), e.setAttribute("height", t.toString()), e.setAttribute("width", i.toString()), this.orbitEnabled() || this.setCameraState(D.Pan), this.reattachControls(e);
1499
1493
  }
1500
1494
  getNumViewports() {
1501
1495
  var e;
@@ -1549,7 +1543,7 @@ class Wt {
1549
1543
  throw new Error(
1550
1544
  "No views attached, camera state requires a view to attach controls onto."
1551
1545
  );
1552
- e === B.Orbit ? this.reattachControls(this.engine.views[0].target, 2) : this.reattachControls(this.engine.views[0].target, 0);
1546
+ e === D.Orbit ? this.reattachControls(this.engine.views[0].target, 2) : this.reattachControls(this.engine.views[0].target, 0);
1553
1547
  }
1554
1548
  animateToLastCameraFocus() {
1555
1549
  let e = () => {
@@ -1585,16 +1579,14 @@ class Wt {
1585
1579
  async renderSceneScreenshot(e, t) {
1586
1580
  if (!this.camera)
1587
1581
  throw new Error("Missing product camera, cannot render screenshot!");
1588
- const i = new fe(
1582
+ const i = new be(
1589
1583
  "screenshotCamera",
1590
1584
  0,
1591
1585
  0,
1592
1586
  0,
1593
1587
  g.Zero(),
1594
1588
  this.scene
1595
- );
1596
- this.renderingPipeline.addCamera(i);
1597
- const r = t.latDeg * Math.PI / 180, n = t.lonDeg * Math.PI / 180;
1589
+ ), r = t.latDeg * Math.PI / 180, n = t.lonDeg * Math.PI / 180;
1598
1590
  i.target = t.target ? new g(t.target.x, t.target.y, t.target.z) : g.Zero(), i.alpha = n, i.beta = r, i.radius = t.radius || this.camera.radius, i.minZ = 0.01;
1599
1591
  try {
1600
1592
  return await new Promise((o) => {
@@ -1608,12 +1600,12 @@ class Wt {
1608
1600
  2,
1609
1601
  !0
1610
1602
  );
1611
- return this.renderingPipeline.removeCamera(i), i.dispose(), o(l);
1603
+ return i.dispose(), o(l);
1612
1604
  });
1613
1605
  this.scene.render(), this.engine.endFrame();
1614
1606
  });
1615
1607
  } catch {
1616
- throw this.renderingPipeline.removeCamera(i), i.isDisposed() || i.dispose(), new Error("Failed to render screenshot");
1608
+ throw i.isDisposed() || i.dispose(), new Error("Failed to render screenshot");
1617
1609
  }
1618
1610
  }
1619
1611
  orbitEnabled() {
@@ -1677,7 +1669,7 @@ class Wt {
1677
1669
  }), n;
1678
1670
  }
1679
1671
  async preloadModel(e) {
1680
- await N(e, this.scene);
1672
+ await z(e, this.scene);
1681
1673
  }
1682
1674
  getAllModels() {
1683
1675
  return Array.from(this.modelContainers.values());
@@ -1712,14 +1704,14 @@ class Wt {
1712
1704
  * Flips a transform around the origin.
1713
1705
  */
1714
1706
  flipTransform(e, t, i) {
1715
- const r = re.Compose(
1707
+ const r = ae.Compose(
1716
1708
  F(i || { x: 1, y: 1, z: 1 }),
1717
- P.FromEulerVector(
1709
+ x.FromEulerVector(
1718
1710
  F(t || { x: 0, y: 0, z: 0 })
1719
1711
  ),
1720
1712
  F(e || { x: 0, y: 0, z: 0 })
1721
- ), n = re.RotationAxis(g.Up(), Math.PI), o = r.multiply(n), a = g.Zero(), l = P.Identity(), h = g.Zero();
1722
- return o.decompose(h, l, a), l.multiplyInPlace(P.FromEulerAngles(0, Math.PI, 0)), {
1713
+ ), n = ae.RotationAxis(g.Up(), Math.PI), o = r.multiply(n), a = g.Zero(), l = x.Identity(), h = g.Zero();
1714
+ return o.decompose(h, l, a), l.multiplyInPlace(x.FromEulerAngles(0, Math.PI, 0)), {
1723
1715
  position: S(a),
1724
1716
  rotation: S(l.toEulerAngles()),
1725
1717
  scale: S(h)
@@ -1727,10 +1719,10 @@ class Wt {
1727
1719
  }
1728
1720
  updatePreviewOptions(e) {
1729
1721
  var r, n;
1730
- const t = new ce(e);
1722
+ const t = new de(e);
1731
1723
  this.configuration.highlights.enabled !== t.highlights.enabled && this.engine.setStencilBuffer(t.highlights.enabled), this.scene.clearColor = t.scene.clearColor;
1732
1724
  let i = this.scene.environmentTexture;
1733
- this.configuration.scene.environment.file !== t.scene.environment.file && (i = ne.CreateFromPrefilteredData(
1725
+ this.configuration.scene.environment.file !== t.scene.environment.file && (i = se.CreateFromPrefilteredData(
1734
1726
  t.scene.environment.file,
1735
1727
  this.scene
1736
1728
  ), i.name = "updated-environment-cube", i.rotationY = this.configuration.scene.environment.rotationY, this.scene.environmentTexture = i), i.rotationY = t.scene.environment.rotationY, this.scene.environmentIntensity = t.scene.environment.intensity, (r = t.options) != null && r.renderingPipelineConfiguration ? this.renderingPipeline.setConfiguration(
@@ -1755,12 +1747,15 @@ class Wt {
1755
1747
  }
1756
1748
  this.scene.attachControl(!0, !0, !0);
1757
1749
  }
1750
+ static isSupported() {
1751
+ return B.isSupported();
1752
+ }
1758
1753
  }
1759
1754
  export {
1760
- D as MaterialEffectMode,
1761
- B as ProductCameraRig,
1755
+ q as MaterialEffectMode,
1756
+ D as ProductCameraRig,
1762
1757
  Ve as REFLECTION_PROBE_RESOLUTION,
1763
- y as RenderingConfiguration,
1758
+ P as RenderingConfiguration,
1764
1759
  Wt as SpiffCommerce3DPreviewService,
1765
1760
  d as renderingPipelineDefaults
1766
1761
  };
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- (function(d,w){typeof exports=="object"&&typeof module<"u"?w(exports,require("@babylonjs/core/Cameras/arcRotateCamera"),require("@babylonjs/core/Engines/engine"),require("@babylonjs/core/Engines/nullEngine"),require("@babylonjs/core/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/Culling/ray"),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/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/Culling/ray","@babylonjs/core/Materials/Textures/Loaders/ddsTextureLoader","@babylonjs/core/Materials/Textures/Loaders/envTextureLoader","@babylonjs/core/Materials/Textures/Loaders/ktxTextureLoader","@babylonjs/core/Animations/animatable","@babylonjs/core/Misc/screenshotTools","@babylonjs/core/Rendering/boundingBoxRenderer","@babylonjs/loaders/glTF/2.0/Extensions"],w):(d=typeof globalThis<"u"?globalThis:d||self,w(d.Preview={},d.arcRotateCamera,d.engine,d.nullEngine,d.sceneLoader,d.cubeTexture,d.math_color,d.math_vector,d.dracoCompression,d.observable,d.tools,d.scene,d.glTF,d.glTFFileLoader,d.pbrMaterial,d.mirrorTexture,d.math,d.reflectionProbe,d.glowLayer,d.actionManager,d.directActions,d.mesh,d.transformNode,d.dynamicTexture,d.texture,d.animation,d.easing,d.assetsManager,d.colorCurves,d.imageProcessingConfiguration,d.RenderPipeline,d.depthOfFieldEffect))})(this,function(d,w,z,Ce,I,G,v,p,ye,P,we,Me,xe,Pe,S,Ae,T,Te,Re,B,H,Ee,Oe,Le,Fe,M,U,Ie,K,R,Se,q){"use strict";var E=(s=>(s[s.Orbit=0]="Orbit",s[s.Pan=1]="Pan",s))(E||{}),O=(s=>(s.None="None",s.RemoveWhenSelected="RemoveWhenSelected",s.ApplyWhenSelected="ApplyWhenSelected",s))(O||{});function Be(){const s=navigator.vendor.toLowerCase().includes("apple"),e=navigator.maxTouchPoints>0,t=!navigator.userAgent.toLowerCase().includes("crios");return s&&e&&t}const W=new Map;async function j(s,e,t){const i=await W.get(s);if(i&&i.scene.uid===e.uid)return i;const r=I.SceneLoader.LoadAssetContainerAsync(s,void 0,e,t);return!Be()&&W.set(s,r),r}I.SceneLoader.OnPluginActivatedObservable.add(s=>{s.name==="gltf"&&(s.animationStartMode=Pe.GLTFLoaderAnimationStartMode.NONE)});class Q{constructor(e){this.getSceneClearColor=()=>{var i,r,n,o;const t=(i=this.customOptions)!=null&&i.transparentBackground||(r=this.customOptions)!=null&&r.backgroundImage?0:1;if(this.customOptions&&((n=this.customOptions)!=null&&n.transparentBackground)||(o=this.customOptions)!=null&&o.backgroundImage)return new v.Color4(0,0,0,t).toLinearSpace();if(this.customOptions&&this.customOptions.backgroundColor){const a=v.Color3.FromHexString(this.customOptions.backgroundColor);return new v.Color4(a.r,a.g,a.b,t).toLinearSpace()}return new v.Color4(.98,.98,.98,t).toLinearSpace()},this.highlightColorFromConfig=()=>this.customOptions&&this.customOptions.highlightColor?this.hexToColor4(this.customOptions.highlightColor):v.Color4.FromColor3(v.Color3.Gray()),this.hexToColor4=(t,i=1)=>{const r=v.Color3.FromHexString(t);return new v.Color4(r.r,r.g,r.b,i).toLinearSpace()},this.customOptions=e}createCanvas(){var e;return(e=this.customOptions)!=null&&e.createCanvas?this.customOptions.createCanvas():document.createElement("canvas")}get options(){return this.customOptions}get scene(){var e,t,i,r,n;return{clearColor:this.getSceneClearColor(),transparentBackground:((e=this.customOptions)==null?void 0:e.transparentBackground)||((t=this.customOptions)==null?void 0:t.backgroundImage),environment:{file:((i=this.customOptions)==null?void 0:i.environmentFile)??"assets/model-viewer/default.env",intensity:((r=this.customOptions)==null?void 0:r.environmentIntensity)??1,rotationY:(((n=this.customOptions)==null?void 0:n.environmentRotationY)??0)*(Math.PI/180)}}}get camera(){var e,t,i,r,n,o,a,l,h,c,g,m,b;return{autoOrientation:((e=this.customOptions)==null?void 0:e.disableAutomaticOrientation)??!0,autoRotation:{enabled:((t=this.customOptions)==null?void 0:t.autoRotation)??!1,idleTimeMs:((i=this.customOptions)==null?void 0:i.idleTimeBeforeRotation)??5e3},limits:{min:{alpha:(r=this.customOptions)!=null&&r.lowerAlphaLimitDeg?((n=this.customOptions)==null?void 0:n.lowerAlphaLimitDeg)*Math.PI/180:void 0,beta:(o=this.customOptions)!=null&&o.lowerBetaLimitDeg?((a=this.customOptions)==null?void 0:a.lowerBetaLimitDeg)*Math.PI/180:void 0,radius:(l=this.customOptions)==null?void 0:l.minZoomOverride},max:{alpha:(h=this.customOptions)!=null&&h.upperAlphaLimitDeg?((c=this.customOptions)==null?void 0:c.upperAlphaLimitDeg)*Math.PI/180:void 0,beta:(g=this.customOptions)!=null&&g.upperBetaLimitDeg?((m=this.customOptions)==null?void 0:m.upperBetaLimitDeg)*Math.PI/180:void 0,radius:(b=this.customOptions)==null?void 0:b.maxZoomOverride}}}}get highlights(){var e;return{enabled:((e=this.customOptions)==null?void 0:e.highlightOnMaterialHover)??!1,color:this.highlightColorFromConfig()}}get lighting(){var e,t,i,r;return{exposure:((t=(e=this.customOptions)==null?void 0:e.lighting)==null?void 0:t.exposure)??.9,contrast:((r=(i=this.customOptions)==null?void 0:i.lighting)==null?void 0:r.contrast)??1.6}}get emissiveGlowIntensity(){var e;return((e=this.customOptions)==null?void 0:e.emissiveGlowIntensity)??.5}}class x{static getDynamicTextureResolution(e=!1){return e?{width:1,height:1}:this.getIsMobile()||!x.offscreenRenderingSupported()?{width:1024,height:1024}:{width:2048,height:2048}}static shouldMipMap(){return!0}static offscreenRenderingSupported(){return navigator.userAgent.includes("SamsungBrowser")?!1:!!window.Worker&&!!window.OffscreenCanvas}static getMirrorTextureResolution(){return this.getIsMobile()?512:1024}static getIsMobile(){try{return typeof window>"u"||!window.navigator?!1:/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(window.navigator.userAgent)||window.innerWidth/window.devicePixelRatio<=480}catch{return!1}}}const Y=128,u={antiAliasing:{samples:4,fxaaEnabled:!1},bloom:{enabled:!1,kernel:64,scale:.5,threshold:.9,weight:.15},chromaticAberration:{enabled:!1,aberrationAmount:30,direction:{x:0,y:0},radialIntensity:0},colorCurves:{enabled:!1},depthOfField:{enabled:!1,blurLevel:"Low",focalLength:50,focusDistance:2e3,fStop:1.4,lensSize:50},grain:{enabled:!1,animated:!1,intensity:30},misc:{contrast:1,exposure:1,toneMappingEnabled:!1,toneMappingType:"Standard"},sharpen:{enabled:!1,colorAmount:1,edgeAmount:.3},vignette:{enabled:!1,blendMode:"Multiply",cameraFov:.5,center:{x:0,y:0},colorHex:"#000000ff",colorRgba:{r:0,g:0,b:0,a:1},stretch:0,weight:1}};class qe{constructor(e){this.name="glbPostProcessor",this.enabled=!0,this.loader=e}onReady(){this.applyReflections(this.loader.babylonScene)}loadNodeAsync(e,t,i){return this.loader.loadNodeAsync(e,t,function(r){t.extras&&Object.keys(t.extras).forEach(n=>{const o=t.extras[n];r.metadata[n]=o}),i(r)})}async loadMaterialPropertiesAsync(e,t,i){await this.loader.loadMaterialPropertiesAsync(e,t,i),this.enableMaterialExtrasIfRequired(t,i),i.needDepthPrePass=!0}dispose(){}enableMaterialExtrasIfRequired(e,t){if(!(!e.extras||!(t instanceof S.PBRMaterial))){if(e.extras.sheen){const i=t;i.sheen.isEnabled=!0,i.sheen.intensity=e.extras.sheen}if(e.extras.translucency){const i=t;i.subSurface.isTranslucencyEnabled=!0,i.subSurface.translucencyIntensity=e.extras.translucency,e.extras.translucencyR&&e.extras.translucencyG&&e.extras.translucencyB&&(i.subSurface.tintColor=new T.Color3(e.extras.translucencyR,e.extras.translucencyG,e.extras.translucencyB))}if(e.extras.refractionIOR){const i=t;i.subSurface.isRefractionEnabled=!0,i.subSurface.volumeIndexOfRefraction=e.extras.refractionIOR}if(e.extras.useDepthPrePass){const i=t;i.needDepthPrePass=!0,i.forceIrradianceInFragment=!0}if(e.extras.useParallax){const i=t;i.useParallax=!0,i.useParallaxOcclusion=!0,i.parallaxScaleBias=e.extras.useParallax}}}applyReflections(e){function t(n){const o=[];return n.transformNodes.forEach(a=>{a.metadata&&a.metadata.reflective&&o.push(...a.getChildMeshes())}),n.meshes.forEach(a=>{a.metadata&&a.metadata.reflective&&!o.includes(a)&&o.push(a)}),o}function i(n,o=1){const a=n.material;if(!a)return;const l=new Ae.MirrorTexture("mirror",x.getMirrorTextureResolution(),e,!0);l.renderList=t(e);const h=n.getVerticesData("normal");if(!h)throw new Error("Mirror attribute specified on: "+n.name+"But no normals exist to generate a mirror from!");n.computeWorldMatrix(!0);const c=n.getWorldMatrix(),g=T.Vector3.TransformNormal(new T.Vector3(h[0],h[1],h[2]),c).normalize(),m=T.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 Te.ReflectionProbe("probe-"+o.name,Y,e);a.cubeTexture.name="reflection-probe-cube-texture",a.attachToMesh(n),a.renderList&&a.renderList.push(...t(e)),o.reflectionTexture=a.cubeTexture}e.meshes.forEach(n=>{const o=n.metadata;o&&(o.mirrorTexture&&i(n,o.mirrorTexture),o.reflectionProbe&&r(n))})}}class je{constructor(e,t){this.scene=e,this.intensity=t,this.meshCount=0}setIntensity(e){this.intensity=e,this.glowLayer&&(this.glowLayer.intensity=e)}includeMeshes(e){if(e){this.glowLayer||(this.glowLayer=new Re.GlowLayer("glow",this.scene),this.glowLayer.intensity=this.intensity);for(const t of e)this.glowLayer.hasMesh(t)||(this.glowLayer.addIncludedOnlyMesh(t),this.meshCount++)}}removeMeshes(e){if(!(!this.glowLayer||!e)){for(const t of e)this.glowLayer.hasMesh(t)&&(this.glowLayer.removeIncludedOnlyMesh(t),this.meshCount--);this.meshCount===0&&(this.glowLayer.dispose(),this.glowLayer=void 0)}}}function De(s,e,t,i,r=""){t.forEach(n=>{const o=n.getID(),a=n.getName(),l=n.getPanelSize&&n.getPanelSize(),h=x.getDynamicTextureResolution((l==null?void 0:l.width)===1||(l==null?void 0:l.height)===1);s.filter(g=>g.name===r+a).forEach(g=>{const m=i.get(o),b=!1;if(m)Z(g,m),m.update(b);else{const f=Ve(a,e,h.width,h.height);i.set(o,f),n.setStaticContext(f.getContext()),Z(g,f),f.onLoadObservable.addOnce(()=>{f.update(b)})}})})}function Ve(s,e,t,i){const r=new Le.DynamicTexture(s,{width:t,height:i},e,x.shouldMipMap(),Fe.Texture.TRILINEAR_SAMPLINGMODE,z.Engine.TEXTUREFORMAT_RGBA),n=r.getContext();return n&&(n.fillStyle="#f5f5f5",n.fillRect(0,0,t,i),r.update()),r}function Z(s,e){if(s instanceof S.PBRMaterial){const t=s,i=t.albedoTexture;i?(e.wrapU=i.wrapU,e.wrapV=i.wrapV):(e.wrapU=1,e.wrapV=1),t.albedoTexture=e}else{const t=s,i=t.diffuseTexture;i&&(e.wrapU=i.wrapU,e.wrapV=i.wrapV),t.diffuseTexture=e}}function Ne(){const s=()=>Math.floor((1+Math.random())*65536).toString(16).substring(1);return s()+s()+"-"+s()+"-"+s()+"-"+s()+"-"+s()+s()+s()}const A=60,$=1;function _(s){return s.targetedAnimations.map(t=>t.animation.framePerSecond).reduce((t,i)=>t+i,0)/s.targetedAnimations.length||0}function X(s,e,t,i,r,n){const o=r?s.filter(c=>c.name===r):s;if(o.length===0){console.warn(`No animations found for name: ${r}`);return}let a=0;const l=()=>{a++,a===o.length&&n&&n()},h=(c,g,m,b,f)=>{c.stop(),c.start(g,m,b,f),n&&(g==!1||g===void 0&&!c.loopAnimation?c.onAnimationGroupEndObservable.addOnce(()=>{l()}):c.onAnimationLoopObservable.addOnce(()=>{l()}))};if(i!==void 0&&t!==void 0&&i===t){o.forEach(c=>{const g=_(c),m=i*g;h(c,!1,$,m,m)});return}o.forEach(c=>{const g=_(c),m=i!==void 0?i*g:void 0,b=t!==void 0?t*g:void 0;h(c,e,$,m,b)})}function ke(s,e,t){return new Promise(i=>{s.stopAnimation(e),e.animations=[],Math.abs(e.alpha)>2*Math.PI&&(e.alpha=ze(e.alpha,0,2*Math.PI));const r=[],n=t.target;if(t.target&&Object.keys(t.target).length>0&&r.push(L("cameraTargetLerp","target",new p.Vector3().copyFrom(e.target),new p.Vector3(t.target.x,t.target.y,t.target.z),M.Animation.ANIMATIONTYPE_VECTOR3)),r.push(L("cameraAlphaLerp","alpha",e.alpha,J(t.lonDeg),M.Animation.ANIMATIONTYPE_FLOAT)),r.push(L("cameraBetaLerp","beta",e.beta,J(t.latDeg),M.Animation.ANIMATIONTYPE_FLOAT)),t.radius!==void 0){const l=Math.max(.01,t.radius);r.push(L("cameraRadiusLerp","radius",e.radius,l,M.Animation.ANIMATIONTYPE_FLOAT))}e.animations.push(...r);const a=e.useAutoRotationBehavior;e.disableAutoRotationBehavior(),s.beginAnimation(e,0,n?A*2:A,!1,1,()=>{e.animations=[],a&&e.enableAutoRotationBehavior(),i()})})}function J(s){return s*Math.PI/180}function L(s,e,t,i,r,n=0,o=M.Animation.ANIMATIONLOOPMODE_CONSTANT){const a=new U.QuadraticEase;a.setEasingMode(U.EasingFunction.EASINGMODE_EASEINOUT);const l=new M.Animation(s,e,A,r,o),h=[];return n>0&&h.push({frame:0,value:t}),h.push({frame:A*n,value:t}),h.push({frame:A*(n+1),value:i}),l.setKeys(h),l.setEasingFunction(a),l}function ze(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 Ue(s,e,t,i){["albedoTexture","bumpTexture","ambientTexture","emissiveTexture","opacityTexture","metallicTexture","refractionTexture","reflectionTexture"].forEach(n=>{Ke(n,s,e,t,i)}),Ye(s,e)}function Ke(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 v.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 v.Color3(1,1,1),e.emissiveIntensity=1)}function Ye(s,e){s.clearCoat&&(s.clearCoat===O.RemoveWhenSelected?(e.clearCoat.isEnabled=!1,e.clearCoat.indexOfRefraction=1.5):s.clearCoat===O.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(c=>c.name===a);if(l.length===0){n();return}const h=new Ie.AssetsManager(this.scene);h.useDefaultLoadingScreen=!1,l.forEach(c=>Ue(t,c,h,r)),h.onProgress=(c,g,m)=>{i&&i(c/g*100,100,m.name)},h.onFinish=c=>{c.forEach(g=>{const m=g;i&&i(100,100,g.name),this.scene.materials.filter(f=>f.name===a).forEach(f=>{Qe(g.name,f,t,m.texture)})}),n()},h.loadAsync()})}async applyModel(e,t,i,r,n,o,a){var m,b,f;if(i&&t&&!this.keysThatRemovedBaseModel.includes(e)&&this.keysThatRemovedBaseModel.push(e),!i)return this.keysThatRemovedBaseModel.includes(e)&&this.keysThatRemovedBaseModel.length===1&&await this.setBaseModelEnabled(!0),(m=this.loadedContainerForKey.get(e))==null||m.dispose(),this.loadedContainerForKey.delete(e),(b=this.loadedMaterialsForKey.get(e))==null||b.forEach(C=>C.dispose()),this.loadedMaterialsForKey.delete(e),this.keysThatRemovedBaseModel=this.keysThatRemovedBaseModel.filter(C=>C!==e),Promise.resolve(void 0);const h=(await j(i,this.scene,r)).instantiateModelsToScene(this.renameClonedAsset,!0);this.loadedContainerForKey.has(e)&&(this.loadedContainerForKey.get(e).dispose(),this.loadedContainerForKey.delete(e),(f=this.loadedMaterialsForKey.get(e))==null||f.forEach(C=>C.dispose()),this.loadedMaterialsForKey.delete(e));const c=n&&n();if(c){const C=o&&o(),y=c.name?this.renameClonedAsset(c.name):void 0;if(X(h.animationGroups,c.loop,c.to,c.from,y),C!=null){const F=a&&a()||!0;Ge(h.animationGroups,C+(F?2:0),y)}}t&&await this.setBaseModelEnabled(!1),this.loadedContainerForKey.set(e,h),this.loadedMaterialsForKey.set(e,ee(h));const g=[];return this.materialVariantMap.forEach(async(C,y)=>{g.push(this.applyMaterial(y,C))}),await Promise.all(g),h}dispose(){this.loadedContainerForKey.forEach(e=>e==null?void 0:e.dispose()),this.loadedContainerForKey.clear(),this.loadedMaterialsForKey.forEach(e=>e.forEach(t=>t==null?void 0:t.dispose())),this.loadedMaterialsForKey.clear(),this.materialVariantMap.clear(),this.keysThatRemovedBaseModel=[]}getAllMaterials(){const e=[];return this.loadedMaterialsForKey.forEach(t=>{t.forEach(i=>{e.includes(i)||e.push(i)})}),e}getAnimationGroups(){const e=[];return this.loadedContainerForKey.forEach(t=>{e.push(...t.animationGroups)}),e}}function ee(s){const e=[];return s.rootNodes.forEach(t=>{t.getChildMeshes().forEach(i=>{i.material&&!e.includes(i.material)&&e.push(i.material),i.subMeshes&&i.subMeshes.forEach(r=>{const n=r.getMaterial(!1);n&&!e.includes(n)&&e.push(n)})})}),e}function te(s,e=""){return s.map(t=>({name:t.name.substring(e.length),loop:t.loopAnimation,to:t.to,from:t.from}))}class $e{constructor(e){this.metadata=new Map,this.materialSelectedObservable=new P.Observable,this.materialDeselectedObservable=new P.Observable,this.materialVariantObservable=new P.Observable,this.modelVariantObservable=new P.Observable,this.materialReadyToLoadCallbacks=new Map,this.dynamicTextures=new Map,this.queuedMaterialChanges=new Map,this.materialChangesInProgress=[],this.queuedModelChanges=new Map,this.modelChangesInProgress=[],this.isExecutingAnimation=!1,this.animations=[],this.initialized=!1,this.materials=[];const{enablePicking:t,modelDetails:i,previewService:r,progressHandler:n,scene:o}=e;this.enablePicking=t,this.contextService=i.contextService,this.id=Ne(),this.previewService=r,this.scene=o,this.variantManager=new 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 j(i.model,o,n),await this.instantiate(),this};this.importPromise=a()}async applyMaterialVariant(e,t,i,r){if(!this.initialized){if(this.materialReadyToLoadCallbacks.has(e)){const o=this.materialReadyToLoadCallbacks.get(e);o==null||o.set(t,this.applyMaterialVariant.bind(this,e,t,i,r))}else{this.materialReadyToLoadCallbacks.set(e,new Map);const o=this.materialReadyToLoadCallbacks.get(e);o==null||o.set(t,this.applyMaterialVariant.bind(this,e,t,i,r))}return}const n=async()=>{await this.variantManager.applyMaterial(e,i,(o,a,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(),this.scene.cleanCachedTextureBuffer()}async applyModelVariant(e,t,i){const r=()=>this.variantManager.applyModel(e,i,t==null?void 0:t.model,a=>{this.modelVariantObservable.notifyObservers({...a,key:e})},this.getLastRequestedAnimation.bind(this),this.getCurrentAnimationFrame.bind(this),this.getAnimationIsPlaying.bind(this)),n=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};if(!this.initialized||this.modelChangesInProgress.includes(e)){const a=async()=>{const l=await r();return l?this.configureModelInstance(l):this.configureGlowLayer(),l};this.queuedModelChanges.set(e,a);return}const o=await n();this.contextService||(this.contextService=t==null?void 0:t.contextService),o?this.configureModelInstance(o):this.configureGlowLayer()}dispose(){var e;this.destroyInstance(),this.variantManager.dispose(),this.dynamicTextures.forEach(t=>t==null?void 0:t.dispose()),this.dynamicTextures.clear(),this.materials.forEach(t=>t&&(t==null?void 0:t.dispose())),this.materials=[],(e=this.transformRoot)==null||e.dispose(),this.transformRoot=void 0,this.previewService.modelUnloaded(this)}executeAnimation(e){if(this.lastRequestedAnimation=e,!this.initialized)return this.queuedModelAnimation=e,Promise.resolve();let t=()=>{};const i=async()=>{this.isExecutingAnimation=!0,await new Promise(r=>{var o;const n=[...((o=this.modelInstance)==null?void 0:o.animationGroups)||[],...this.variantManager.getAnimationGroups()];X(n,e.loop,e.to,e.from,e.name?this.renameClonedAsset(e.name):void 0,r)}),this.isExecutingAnimation=!1,this.queuedAnimationFunction&&this.queuedAnimationFunction(),this.queuedAnimationFunction=void 0,t()};return this.isExecutingAnimation?(this.queuedAnimationFunction=i,new Promise(r=>{t=r})):i()}getAnimations(e){return[...this.animations,...e?te(this.variantManager.getAnimationGroups(),this.renameClonedAsset("")):[]].map((t,i)=>({...t,name:t.name||`UNNAMED_ANIMATION_${i}`})).filter((t,i,r)=>r.indexOf(r.find(n=>n.name===t.name))==i)}getId(){return this.id}listMaterials(){var t;const e=(t=this.scene)==null?void 0:t.materials.filter(i=>i.name.startsWith(this.id));return e?e.map(i=>({id:i.id,name:this.stripIdFromName(i.name)})):[]}registerMaterialSelectedCallback(e){this.materialSelectedObservable.add(e)}unregisterMaterialSelectedCallback(e){this.materialSelectedObservable.removeCallback(e)}registerMaterialDeselectedCallback(e){this.materialDeselectedObservable.add(e)}unregisterMaterialDeselectedCallback(e){this.materialDeselectedObservable.removeCallback(e)}get position(){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to requesting position!");return this.transformRoot.position}set position(e){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to setting position!");this.transformRoot.position=new p.Vector3(e.x,e.y,e.z)}get rotation(){var e;if(!((e=this.transformRoot)!=null&&e.rotationQuaternion))throw new Error("ModelContainer disposed prior to requesting rotation!");return this.transformRoot.rotationQuaternion.toEulerAngles()}set rotation(e){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to setting rotation!");this.transformRoot.rotationQuaternion=p.Quaternion.FromEulerAngles(e.x,e.y,e.z)}get scale(){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to requesting scale!");return this.transformRoot.scaling}set scale(e){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to setting scale!");this.transformRoot.scaling=new p.Vector3(e.x,e.y,e.z)}attachPickingHandler(e){e.rootNodes.forEach(t=>{t.getChildMeshes(!1).forEach(i=>{i.name==="targetcube_t"||i.name==="backgroundShell"||(i.actionManager||(i.actionManager=new B.ActionManager(this.scene)),i.actionManager.registerAction(new H.ExecuteCodeAction(B.ActionManager.OnPointerOverTrigger,r=>{r.meshUnderPointer&&i.material&&this.materialSelectedObservable.notifyObservers({id:i.material.id,name:this.stripIdFromName(i.material.name)})})),i.actionManager.registerAction(new H.ExecuteCodeAction(B.ActionManager.OnPointerOutTrigger,()=>{i.material&&this.materialDeselectedObservable.notifyObservers({id:i.material.id,name:this.stripIdFromName(i.material.name)})})))})})}getInitializationPromise(){return this.importPromise}getIsInitialized(){return this.initialized}getQueuedMaterialVariantCount(){return this.materialReadyToLoadCallbacks.size}getQueuedModelVariantCount(){return this.queuedModelChanges.size}configureGlowLayer(){const e=i=>i instanceof S.PBRMaterial&&i.emissiveTexture!==null;this.materials.some(e)||this.variantManager.getAllMaterials().some(e)?this.previewService.getGlowLayerManager().includeMeshes(this.getAllMeshes()):this.previewService.getGlowLayerManager().removeMeshes(this.getAllMeshes())}configureModelInstance(e){var n;if(!this.transformRoot)throw new Error("Transform disposed! This should never happen unless there is a race condition present!");const t=this.transformRoot.position,i=this.transformRoot.rotationQuaternion,r=this.transformRoot.scaling;this.transformRoot.position=p.Vector3.Zero(),this.transformRoot.rotationQuaternion=p.Quaternion.Identity(),this.transformRoot.scaling=p.Vector3.One();for(const o of e.rootNodes){o.parent=this.transformRoot;for(const a of o.getChildMeshes(!1))a.alwaysSelectAsActiveMesh=!0}this.transformRoot.position=t,this.transformRoot.rotationQuaternion=i,this.transformRoot.scaling=r,this.canvasPanels=((n=this.contextService)==null?void 0:n.getAll())||new Map,De(this.materials.concat(this.variantManager.getAllMaterials()),this.scene,this.canvasPanels,this.dynamicTextures,`${this.id}_`),this.enablePicking&&this.attachPickingHandler(e),this.configureGlowLayer()}destroyInstance(){var e;(e=this.modelInstance)==null||e.dispose(),this.modelInstance=void 0}getAllMeshes(){var e;return(e=this.modelInstance)==null?void 0:e.rootNodes.map(t=>t.getChildMeshes(!1).filter(i=>i instanceof Ee.Mesh)).flat()}async instantiate(){if(!this.assetContainer)throw new Error("Attempted to instantiate ModelContainer without an AssetContainer");this.modelInstance=this.assetContainer.instantiateModelsToScene(this.renameClonedAsset.bind(this),!0),this.materials=ee(this.modelInstance),this.configureModelInstance(this.modelInstance),this.animations=te(this.modelInstance.animationGroups,this.renameClonedAsset("")),this.initialized=!0,await this.processQueuedEvents()}renameClonedAsset(e){return`${this.id}_${e}`}async setBaseModelEnabled(e){e&&!this.modelInstance?await this.instantiate():!e&&this.modelInstance&&this.destroyInstance()}updateDynamicTextures(){var e;(e=this.canvasPanels)==null||e.forEach((t,i)=>{const r=this.dynamicTextures.get(i);r&&t.getStaticContextDirty()&&r.isReady()&&(r.update(!1),t.setStaticContextDirty(!1))})}registerMaterialVariantListener(e){this.materialVariantObservable.add(e)}unregisterMaterialVariantListener(e){this.materialVariantObservable.removeCallback(e)}registerModelVariantListener(e){this.modelVariantObservable.add(e)}unregisterModelVariantListener(e){this.modelVariantObservable.removeCallback(e)}getLastRequestedAnimation(){return this.lastRequestedAnimation}getCurrentAnimationFrame(){var t;const e=[...((t=this.modelInstance)==null?void 0:t.animationGroups)||[],...this.variantManager.getAnimationGroups()];for(const i of e)if(i.animatables.length>0&&i.animatables[0].masterFrame!==void 0&&i.animatables[0].masterFrame!==null)return i.animatables[0].masterFrame;return 0}getAnimationIsPlaying(){var t;const e=[...((t=this.modelInstance)==null?void 0:t.animationGroups)||[],...this.variantManager.getAnimationGroups()];for(const i of e)if(i.isPlaying)return!0;return!1}stripIdFromName(e){return e.substring(this.id.length+1)}async processQueuedEvents(){await Promise.all(Array.from(this.materialReadyToLoadCallbacks.values()).flatMap(e=>Array.from(e.values()).map(t=>t()))),this.materialReadyToLoadCallbacks.clear(),await Promise.all(Array.from(this.queuedModelChanges.values()).map(e=>e())),this.queuedModelChanges.clear(),this.scene.onAfterRenderObservable.addOnce(()=>{this.queuedModelAnimation&&(this.executeAnimation(this.queuedModelAnimation),this.queuedModelAnimation=void 0)})}}class D extends w.ArcRotateCamera{constructor(e,t,i,r,n,o,a,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=V(this._scene);return e.zoomOnBoundingInfo(t.min,t.max),this.wheelPrecision=100/this.radius,this.lowerRadiusLimit===null&&(this.lowerRadiusLimit=.1),this.lastFocus.copyFrom(this.target),e}rerunFramingBehavior(e,t){this._isRunningFramingBehavior=!0,this.framingBehaviourCallback=e;const i=this.getFramingBehavior();i.framingTime=t||800;const r=()=>{this.isRunningFramingBehavior=!1},n=V(this._scene),o=n.max.subtract(n.min),a=n.min.add(o.scale(.5));this.updateRadiusBounds(o.length()*1.5),this.wheelPrecision=100/this.radius,this.panningInertia=0,this.panningOriginTarget.copyFrom(a),this.panDenominator=o.length(),this.lastFocus.copyFrom(a),i.zoomOnBoundingInfo(n.min,n.max,void 0,r),i.framingTime=0}enableAutoRotationBehavior(e=5e3){this.useAutoRotationBehavior=!0;const t=this.getAutoRotationBehavior();t&&(t.idleRotationWaitTime=e)}disableAutoRotationBehavior(){this.useAutoRotationBehavior=!1}updateRadiusBounds(e){this.maxZ=e*1e3,this.lowerRadiusLimit=e*.01,this.upperRadiusLimit=1.5*e,this.wheelPrecision=100/e,this.pinchPrecision=300/e}static create(e,t,i){var l;const r=V(e),n=r.max.subtract(r.min),o=r.min.add(n.scale(.5)),a=new D("ProductCamera",-(Math.PI/2),Math.PI/2,n.length()*1.5,o,e,t);return a.setPanEnabled(((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 V(s){if(s.meshes.length===0)return{min:new p.Vector3(-1,-1,-1),max:new p.Vector3(1,1,1)};const e=s.meshes.filter(t=>t.name.toLowerCase().endsWith("_t")||t.name.toLowerCase().includes("_t_"));return s.getWorldExtends(t=>t.isVisible&&t.isEnabled()&&(e.length===0||e.includes(t)))}class _e{constructor(e,t=!1,i=void 0){this.renderingPipeline=new Se.DefaultRenderingPipeline("default",t,e,i?[i]:void 0,!1),this.renderingPipeline.isSupported&&(this.renderingPipeline.prepare(),this.setConfiguration(u))}dispose(){this.renderingPipeline.dispose()}getConfiguration(){return this.currentConfiguration}addCamera(e){this.renderingPipeline.addCamera(e),this.renderingPipeline.prepare()}removeCamera(e){this.renderingPipeline.cameras.includes(e)&&this.renderingPipeline.removeCamera(e)}setConfiguration(e){var t,i,r,n,o,a,l,h,c,g,m,b,f,C,y,F,ie,ne,se,re,ae,oe,le,he,ce,de,ue,ge,me,pe,fe,be,ve;if(this.renderingPipeline.isSupported){if(this.renderingPipeline.samples=((t=e.antiAliasing)==null?void 0:t.samples)??u.antiAliasing.samples,this.renderingPipeline.fxaaEnabled=((i=e.antiAliasing)==null?void 0:i.fxaaEnabled)??u.antiAliasing.fxaaEnabled,this.renderingPipeline.bloomEnabled=((r=e.bloom)==null?void 0:r.enabled)??u.bloom.enabled,this.renderingPipeline.bloomKernel=((n=e.bloom)==null?void 0:n.kernel)??u.bloom.kernel,this.renderingPipeline.bloomScale=((o=e.bloom)==null?void 0:o.scale)??u.bloom.scale,this.renderingPipeline.bloomThreshold=((a=e.bloom)==null?void 0:a.threshold)??u.bloom.threshold,this.renderingPipeline.bloomWeight=((l=e.bloom)==null?void 0:l.weight)??u.bloom.weight,this.renderingPipeline.chromaticAberrationEnabled=((h=e.chromaticAberration)==null?void 0:h.enabled)??u.chromaticAberration.enabled,this.renderingPipeline.chromaticAberration.aberrationAmount=((c=e.chromaticAberration)==null?void 0:c.aberrationAmount)??u.chromaticAberration.aberrationAmount,this.renderingPipeline.chromaticAberration.radialIntensity=((g=e.chromaticAberration)==null?void 0:g.radialIntensity)??u.chromaticAberration.radialIntensity,this.renderingPipeline.chromaticAberration.direction=(m=e.chromaticAberration)!=null&&m.direction?new p.Vector2(e.chromaticAberration.direction.x,e.chromaticAberration.direction.y):new p.Vector2(u.chromaticAberration.direction.x,u.chromaticAberration.direction.y),this.renderingPipeline.imageProcessing.colorCurvesEnabled=((b=e.colorCurves)==null?void 0:b.enabled)??u.colorCurves.enabled,this.renderingPipeline.imageProcessing.colorCurves=e.colorCurves?this.updateColorCurve(e.colorCurves):new K.ColorCurves,this.renderingPipeline.depthOfFieldEnabled=((f=e.depthOfField)==null?void 0:f.enabled)??u.depthOfField.enabled,e.depthOfField)switch(e.depthOfField.blurLevel??u.depthOfField.blurLevel){case"Low":this.renderingPipeline.depthOfFieldBlurLevel=q.DepthOfFieldEffectBlurLevel.Low;break;case"Medium":this.renderingPipeline.depthOfFieldBlurLevel=q.DepthOfFieldEffectBlurLevel.Medium;break;case"High":this.renderingPipeline.depthOfFieldBlurLevel=q.DepthOfFieldEffectBlurLevel.High;break}if(this.renderingPipeline.depthOfField.focalLength=((C=e.depthOfField)==null?void 0:C.focalLength)??u.depthOfField.focalLength,this.renderingPipeline.depthOfField.fStop=((y=e.depthOfField)==null?void 0:y.fStop)??u.depthOfField.fStop,this.renderingPipeline.depthOfField.focusDistance=((F=e.depthOfField)==null?void 0:F.focusDistance)??u.depthOfField.focusDistance,this.renderingPipeline.depthOfField.lensSize=((ie=e.depthOfField)==null?void 0:ie.lensSize)??u.depthOfField.lensSize,this.renderingPipeline.grainEnabled=((ne=e.grain)==null?void 0:ne.enabled)??u.grain.enabled,this.renderingPipeline.grain.animated=((se=e.grain)==null?void 0:se.animated)??u.grain.animated,this.renderingPipeline.grain.intensity=((re=e.grain)==null?void 0:re.intensity)??u.grain.intensity,this.renderingPipeline.imageProcessing.contrast=((ae=e.misc)==null?void 0:ae.contrast)??u.misc.contrast,this.renderingPipeline.imageProcessing.exposure=((oe=e.misc)==null?void 0:oe.exposure)??u.misc.exposure,this.renderingPipeline.imageProcessing.toneMappingEnabled=((le=e.misc)==null?void 0:le.toneMappingEnabled)??u.misc.toneMappingEnabled,this.renderingPipeline.imageProcessing.toneMappingEnabled)switch(e.misc.toneMappingType??u.misc.toneMappingType){case"Standard":this.renderingPipeline.imageProcessing.toneMappingType=R.ImageProcessingConfiguration.TONEMAPPING_STANDARD;break;case"ACES":this.renderingPipeline.imageProcessing.toneMappingType=R.ImageProcessingConfiguration.TONEMAPPING_ACES;break}if(this.renderingPipeline.sharpenEnabled=((he=e.sharpen)==null?void 0:he.enabled)??u.sharpen.enabled,this.renderingPipeline.sharpen.colorAmount=((ce=e.sharpen)==null?void 0:ce.colorAmount)??u.sharpen.colorAmount,this.renderingPipeline.sharpen.edgeAmount=((de=e.sharpen)==null?void 0:de.edgeAmount)??u.sharpen.edgeAmount,this.renderingPipeline.imageProcessing.vignetteEnabled=((ue=e.vignette)==null?void 0:ue.enabled)??u.vignette.enabled,(ge=e.vignette)!=null&&ge.center?(this.renderingPipeline.imageProcessing.vignetteCenterX=e.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=e.vignette.center.y):(this.renderingPipeline.imageProcessing.vignetteCenterX=u.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=u.vignette.center.y),e.vignette)switch(((me=e.vignette)==null?void 0:me.blendMode)??u.vignette.blendMode){case"Multiply":this.renderingPipeline.imageProcessing.vignetteBlendMode=R.ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY;break;case"Opaque":this.renderingPipeline.imageProcessing.vignetteBlendMode=R.ImageProcessingConfiguration.VIGNETTEMODE_OPAQUE;break}(pe=e.vignette)!=null&&pe.colorRgba?this.renderingPipeline.imageProcessing.vignetteColor=new v.Color4(e.vignette.colorRgba.r,e.vignette.colorRgba.g,e.vignette.colorRgba.b,e.vignette.colorRgba.a):(fe=e.vignette)!=null&&fe.colorHex?this.renderingPipeline.imageProcessing.vignetteColor=v.Color4.FromHexString(e.vignette.colorHex):this.renderingPipeline.imageProcessing.vignetteColor=new v.Color4(u.vignette.colorRgba.r,u.vignette.colorRgba.g,u.vignette.colorRgba.b,u.vignette.colorRgba.a),this.renderingPipeline.imageProcessing.vignetteStretch=((be=e.vignette)==null?void 0:be.stretch)??u.vignette.stretch,this.renderingPipeline.imageProcessing.vignetteWeight=((ve=e.vignette)==null?void 0:ve.weight)??u.vignette.weight,this.renderingPipeline.prepare(),this.currentConfiguration=e}}updateColorCurve(e){const t=new K.ColorCurves;return t.globalDensity=e.globalDensity??t.globalDensity,t.globalExposure=e.globalExposure??t.globalExposure,t.globalHue=e.globalHue??t.globalHue,t.globalSaturation=e.globalSaturation??t.globalSaturation,t.highlightsDensity=e.highlightsDensity??t.highlightsDensity,t.highlightsExposure=e.highlightsExposure??t.highlightsExposure,t.highlightsHue=e.highlightsHue??t.highlightsHue,t.highlightsSaturation=e.highlightsSaturation??t.highlightsSaturation,t.midtonesDensity=e.midtonesDensity??t.midtonesDensity,t.midtonesExposure=e.midtonesExposure??t.midtonesExposure,t.midtonesHue=e.midtonesHue??t.midtonesHue,t.midtonesSaturation=e.midtonesSaturation??t.midtonesSaturation,t.shadowsDensity=e.shadowsDensity??t.shadowsDensity,t.shadowsExposure=e.shadowsExposure??t.shadowsExposure,t.shadowsHue=e.shadowsHue??t.shadowsHue,t.shadowsSaturation=e.shadowsSaturation??t.shadowsSaturation,t}}xe.GLTF2.GLTFLoader.RegisterExtension("glbPostProcessor",function(s){return new qe(s)}),I.SceneLoader.OnPluginActivatedObservable.add(s=>{if(s.name==="gltf"){const e=s;e.transparencyAsCoverage=!0}});function N(s){return new p.Vector3(s.x,s.y,s.z)}function k(s){return{x:s.x,y:s.y,z:s.z}}class Xe{constructor(e){var l;this.focusLostNotified=!1,this.focusLostObservable=new P.Observable,this.modelLoadEventCallbacks=[],this.validHighlightMaterials=[],this.modelContainers=new Map,this.plugins=[],this.initComplete=!1,this.isAnimatingCamera=!1,this.renderLoop=()=>{if(!this.engine.views)return;this.modelContainers.forEach(g=>{g.updateDynamicTextures()}),this.scene.autoClear=!0,this.scene.autoClearDepthAndStencil=!0;const h=this.engine.getRenderingCanvas();if(h)if(h.getContext("webgl2")??h.getContext("webgl")){const g=this.configuration.scene.clearColor,m=h.getContext("webgl2")??h.getContext("webgl");m.clearDepth(1),m.depthFunc(m.LEQUAL),m.clearStencil(0),m.clearColor(g.r,g.g,g.b,g.a),m.clear(m.COLOR_BUFFER_BIT|m.DEPTH_BUFFER_BIT|m.STENCIL_BUFFER_BIT)}else h.getContext("2d")?h.getContext("2d").clearRect(0,0,h.width,h.height):console.error("SpiffCommerce: Failed to get any context on the rendering canvas.");this.scene.render(),this.camera.isRunningFramingBehavior&&this.camera.getFramingBehavior().isUserIsMoving&&(this.camera.isRunningFramingBehavior=!1);const c=Math.max((this.camera.lowerRadiusLimit??1)*.01,.001);!this.camera.isRunningFramingBehavior&&!this.camera.target.equalsWithEpsilon(this.camera.lastFocus,c)&&!this.focusLostNotified&&(this.focusLostObservable.notifyObservers(void 0),this.focusLostNotified=!0)},this.configuration=new Q(e);const i=(()=>{if(!(e!=null&&e.noRender))return this.configuration.createCanvas()})(),r="1.5.7";ye.DracoCompression.Configuration={decoder:{wasmUrl:`https://www.gstatic.com/draco/versioned/decoders/${r}/draco_wasm_wrapper_gltf.js`,wasmBinaryUrl:`https://www.gstatic.com/draco/versioned/decoders/${r}/draco_decoder_gltf.wasm`,fallbackUrl:`https://www.gstatic.com/draco/versioned/decoders/${r}/draco_decoder_gltf.js`}},i&&(i.getContext("webgl2")||i.getContext("webgl"));const n=console.log;console.log=()=>{};const o=i?new z.Engine(i,!0,{adaptToDeviceRatio:!0,limitDeviceRatio:2,premultipliedAlpha:!1,preserveDrawingBuffer:!!(e!=null&&e.backgroundImage),audioEngine:!1,stencil:this.configuration.highlights.enabled,forceSRGBBufferSupportState:!0}):new Ce.NullEngine;o.enableOfflineSupport=!1,o.doNotHandleContextLost=!0,console.log=n,o.hideLoadingUI(),window.addEventListener("resize",this.fireResizeEvent.bind(this)),this.engine=o,this.scene=new Me.Scene(o),this.camera=D.create(this.scene,this.configuration),this.scene.activeCamera=this.camera,this.renderingPipeline=new _e(this.scene,!1,this.camera),this.scene.clearColor=this.configuration.scene.clearColor;const a=G.CubeTexture.CreateFromPrefilteredData(this.configuration.scene.environment.file,this.scene);a.name="initial-environment-cube",a.rotationY=this.configuration.scene.environment.rotationY,this.scene.environmentTexture=a,this.scene.environmentIntensity=this.configuration.scene.environment.intensity,(l=this.configuration.options)!=null&&l.renderingPipelineConfiguration?this.renderingPipeline.setConfiguration(this.configuration.options.renderingPipelineConfiguration):(this.scene.imageProcessingConfiguration.exposure=this.configuration.lighting.exposure,this.scene.imageProcessingConfiguration.contrast=this.configuration.lighting.contrast),this.glowLayerManager=new je(this.scene,this.configuration.emissiveGlowIntensity),this.initPromise=new Promise(h=>{this.scene.onReadyObservable.addOnce(()=>{this.initComplete=!0,h()})}),this.engine.runRenderLoop(this.renderLoop)}getInitializationPromise(){return this.initPromise}getInitializationComplete(){return this.initComplete}getEngineContext(){return{engine:this.engine,scene:this.scene,camera:this.camera}}registerFocusLostListener(e){this.focusLostObservable.add(e)}unregisterFocusLostListener(e){this.focusLostObservable.removeCallback(e)}registerModelLoadEventListener(e){this.modelLoadEventCallbacks.push(e)}unregisterModelLoadEventListener(e){const t=this.modelLoadEventCallbacks.indexOf(e);t>-1&&this.modelLoadEventCallbacks.splice(t,1)}registerView(e){const t=e.height,i=e.width;this.engine.registerView(e,void 0,!0),e.setAttribute("height",t.toString()),e.setAttribute("width",i.toString()),this.orbitEnabled()||this.setCameraState(E.Pan),this.reattachControls(e)}getNumViewports(){var e;return((e=this.engine.views)==null?void 0:e.length)||0}unregisterView(e){this.engine.unRegisterView(e)}shutdown(){this.plugins.forEach(e=>e.dispose(!0)),this.renderingPipeline.dispose(),this.engine&&this.engine.dispose(),window.removeEventListener("resize",this.fireResizeEvent)}executeCameraAnimation(e){if(!this.camera||this.scene.activeCamera!==this.camera||this.getAllModels().length===0||!this.getAllModels().some(r=>r.getIsInitialized()))return this.queuedCameraAnimation=e,Promise.resolve();let t=()=>{};const i=async()=>{this.isAnimatingCamera=!0,await ke(this.scene,this.scene.activeCamera,e),this.isAnimatingCamera=!1,this.queuedAnimationFunction&&this.queuedAnimationFunction(),this.queuedAnimationFunction=void 0,t()};return this.isAnimatingCamera?(this.queuedAnimationFunction=i,new Promise(r=>{t=r})):i()}getCameraPose(){if(this.scene&&this.camera)return{lonDeg:Math.round(this.camera.alpha*180/Math.PI),latDeg:Math.round(this.camera.beta*180/Math.PI),radius:Math.round((this.camera.radius+Number.EPSILON)*1e4)/1e4,target:{x:this.camera.target.x,y:this.camera.target.y,z:this.camera.target.z}}}setCameraPose(e){this.scene&&this.camera&&(this.camera.target=new p.Vector3(e.target.x,e.target.y,e.target.z),this.camera.radius=e.radius,this.camera.alpha=e.latDeg,this.camera.beta=e.lonDeg)}setCameraState(e){var t,i;if(!((t=this.engine)!=null&&t.views)||!((i=this.engine)!=null&&i.views[0]))throw new Error("No views attached, camera state requires a view to attach controls onto.");e===E.Orbit?this.reattachControls(this.engine.views[0].target,2):this.reattachControls(this.engine.views[0].target,0)}animateToLastCameraFocus(){let e=()=>{};const t=async()=>{this.isAnimatingCamera=!0,await new Promise(i=>{this.focusLostNotified=!1;const r=()=>{const n=this.configuration;this.camera.rerunFramingBehavior(()=>{n.camera.limits.min.radius&&(this.camera.lowerRadiusLimit=n.camera.limits.min.radius),n.camera.limits.max.radius&&(this.camera.upperRadiusLimit=n.camera.limits.max.radius),i()})};this.scene.onAfterRenderObservable.addOnce(r)}),this.isAnimatingCamera=!1,this.queuedAnimationFunction&&this.queuedAnimationFunction(),this.queuedAnimationFunction=void 0,e()};return this.isAnimatingCamera?(this.queuedAnimationFunction=t,new Promise(i=>{e=i})):t()}forceStopCameraAnimations(){var e;this.queuedAnimationFunction=void 0,this.queuedCameraAnimation=void 0,this.isAnimatingCamera=!1,(e=this.camera.framingBehavior)==null||e.stopAllAnimations(),this.scene.stopAnimation(this.camera)}setAutoRotation(e){!this.configuration.camera.autoRotation.enabled||!this.camera||(e?this.camera.enableAutoRotationBehavior(this.configuration.camera.autoRotation.idleTimeMs):this.camera.disableAutoRotationBehavior())}getCurrentConfiguration(){return this.configuration.options}async renderSceneScreenshot(e,t){if(!this.camera)throw new Error("Missing product camera, cannot render screenshot!");const i=new w.ArcRotateCamera("screenshotCamera",0,0,0,p.Vector3.Zero(),this.scene);this.renderingPipeline.addCamera(i);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;try{return await new Promise(o=>{const a=this.scene.onBeforeRenderObservable.add(async()=>{this.scene.onBeforeRenderObservable.remove(a);const l=await we.Tools.CreateScreenshotUsingRenderTargetAsync(this.engine,i,e,"image/png",2,!0);return this.renderingPipeline.removeCamera(i),i.dispose(),o(l)});this.scene.render(),this.engine.endFrame()})}catch{throw this.renderingPipeline.removeCamera(i),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(c=>c===t),h=a.every(c=>c===r);return!l&&!h}fireResizeEvent(){this.getNumViewports()>0&&this.engine.resize()}setHighlights(e){this.scene.materials.forEach(()=>{this.scene.materials.forEach(i=>{i.emissiveIntensity===.18&&(i.emissiveColor=v.Color3.Black(),i.emissiveIntensity=1)})}),e.filter(i=>this.validHighlightMaterials.includes(i.name)).forEach(i=>{const r=this.scene.materials.find(n=>n.id===i.id);r&&(r.emissiveColor=new v.Color3(this.configuration.highlights.color.r,this.configuration.highlights.color.g,this.configuration.highlights.color.b),r.emissiveIntensity=.18)})}setRenderingPipelineConfiguration(e){this.renderingPipeline&&this.renderingPipeline.setConfiguration(e)}loadModel(e,t){const{refocusCamera:i=!0,progressHandler:r}=t??{},n=new $e({enablePicking:this.configuration.highlights.enabled,modelDetails:e,scene:this.scene,previewService:this,progressHandler:r});return n.getInitializationPromise().then(()=>{if(this.modelContainers.size<=1&&i){const o=this.queuedCameraAnimation;this.forceStopCameraAnimations(),this.camera.rerunFramingBehavior(()=>{this.scene.onAfterRenderObservable.addOnce(()=>{o&&(this.executeCameraAnimation(o),this.queuedCameraAnimation=void 0)})},1)}}),this.configuration.highlights.enabled&&(n.registerMaterialSelectedCallback(o=>{this.setHighlights([o])}),n.registerMaterialDeselectedCallback(()=>{this.setHighlights([])})),this.modelContainers.set(n.getId(),n),this.triggerModelLoadEvent({eventType:"load",modelContainer:n}),n}async preloadModel(e){await j(e,this.scene)}getAllModels(){return Array.from(this.modelContainers.values())}getModelById(e){return this.modelContainers.get(e)}registerPlugin(e){this.plugins.push(e),e.initialize(this,{camera:this.camera,engine:this.engine,scene:this.scene})}unregisterPlugin(e){const t=this.plugins.indexOf(e);t>-1&&this.plugins.splice(t,1).forEach(r=>r.dispose(!1))}getGlowLayerManager(){return this.glowLayerManager}modelUnloaded(e){this.modelContainers.delete(e.getId()),this.triggerModelLoadEvent({eventType:"unload",modelContainer:e})}triggerModelLoadEvent(e){this.modelLoadEventCallbacks.forEach(t=>t(e))}flipTransform(e,t,i){const r=p.Matrix.Compose(N(i||{x:1,y:1,z:1}),p.Quaternion.FromEulerVector(N(t||{x:0,y:0,z:0})),N(e||{x:0,y:0,z:0})),n=p.Matrix.RotationAxis(p.Vector3.Up(),Math.PI),o=r.multiply(n),a=p.Vector3.Zero(),l=p.Quaternion.Identity(),h=p.Vector3.Zero();return o.decompose(h,l,a),l.multiplyInPlace(p.Quaternion.FromEulerAngles(0,Math.PI,0)),{position:k(a),rotation:k(l.toEulerAngles()),scale:k(h)}}updatePreviewOptions(e){var r,n;const t=new Q(e);this.configuration.highlights.enabled!==t.highlights.enabled&&this.engine.setStencilBuffer(t.highlights.enabled),this.scene.clearColor=t.scene.clearColor;let i=this.scene.environmentTexture;this.configuration.scene.environment.file!==t.scene.environment.file&&(i=G.CubeTexture.CreateFromPrefilteredData(t.scene.environment.file,this.scene),i.name="updated-environment-cube",i.rotationY=this.configuration.scene.environment.rotationY,this.scene.environmentTexture=i),i.rotationY=t.scene.environment.rotationY,this.scene.environmentIntensity=t.scene.environment.intensity,(r=t.options)!=null&&r.renderingPipelineConfiguration?this.renderingPipeline.setConfiguration(t.options.renderingPipelineConfiguration):(this.scene.imageProcessingConfiguration.exposure=t.lighting.exposure,this.scene.imageProcessingConfiguration.contrast=t.lighting.contrast),this.glowLayerManager.setIntensity(t.emissiveGlowIntensity),this.camera.updateConfiguration(t),this.camera.setPanEnabled(((n=t.options)==null?void 0:n.noPan)!==void 0?!t.options.noPan:!0),this.configuration=t}setHighlightMaterials(e){this.validHighlightMaterials=e}reattachControls(e,t=2){if(this.scene.detachControl(),this.engine.inputElement=e,this.camera){this.camera.attachControl(!0,!1,t);const i=this.camera.inputs.attached.pointers;i.multiTouchPanning=!1}this.scene.attachControl(!0,!0,!0)}}d.MaterialEffectMode=O,d.ProductCameraRig=E,d.REFLECTION_PROBE_RESOLUTION=Y,d.RenderingConfiguration=x,d.SpiffCommerce3DPreviewService=Xe,d.renderingPipelineDefaults=u,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
1
+ (function(d,w){typeof exports=="object"&&typeof module<"u"?w(exports,require("@babylonjs/core/Cameras/arcRotateCamera"),require("@babylonjs/core/Engines/engine"),require("@babylonjs/core/Engines/nullEngine"),require("@babylonjs/core/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/Culling/ray"),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/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/Culling/ray","@babylonjs/core/Materials/Textures/Loaders/ddsTextureLoader","@babylonjs/core/Materials/Textures/Loaders/envTextureLoader","@babylonjs/core/Materials/Textures/Loaders/ktxTextureLoader","@babylonjs/core/Animations/animatable","@babylonjs/core/Misc/screenshotTools","@babylonjs/core/Rendering/boundingBoxRenderer","@babylonjs/loaders/glTF/2.0/Extensions"],w):(d=typeof globalThis<"u"?globalThis:d||self,w(d.Preview={},d.arcRotateCamera,d.engine,d.nullEngine,d.sceneLoader,d.cubeTexture,d.math_color,d.math_vector,d.dracoCompression,d.observable,d.tools,d.scene,d.glTF,d.glTFFileLoader,d.pbrMaterial,d.mirrorTexture,d.math,d.reflectionProbe,d.glowLayer,d.actionManager,d.directActions,d.mesh,d.transformNode,d.dynamicTexture,d.texture,d.animation,d.easing,d.assetsManager,d.colorCurves,d.imageProcessingConfiguration,d.RenderPipeline,d.depthOfFieldEffect))})(this,function(d,w,I,Ce,S,G,v,p,ye,A,we,Me,xe,Ae,B,Pe,T,Te,Re,q,H,Ee,Oe,Le,Fe,M,U,Ie,K,R,Se,j){"use strict";var E=(s=>(s[s.Orbit=0]="Orbit",s[s.Pan=1]="Pan",s))(E||{}),O=(s=>(s.None="None",s.RemoveWhenSelected="RemoveWhenSelected",s.ApplyWhenSelected="ApplyWhenSelected",s))(O||{});function Be(){const s=navigator.vendor.toLowerCase().includes("apple"),e=navigator.maxTouchPoints>0,t=!navigator.userAgent.toLowerCase().includes("crios");return s&&e&&t}const W=new Map;async function D(s,e,t){const i=await W.get(s);if(i&&i.scene.uid===e.uid)return i;const r=S.SceneLoader.LoadAssetContainerAsync(s,void 0,e,t);return!Be()&&W.set(s,r),r}S.SceneLoader.OnPluginActivatedObservable.add(s=>{s.name==="gltf"&&(s.animationStartMode=Ae.GLTFLoaderAnimationStartMode.NONE)});class Q{constructor(e){this.getSceneClearColor=()=>{var i,r,n,o;const t=(i=this.customOptions)!=null&&i.transparentBackground||(r=this.customOptions)!=null&&r.backgroundImage?0:1;if(this.customOptions&&((n=this.customOptions)!=null&&n.transparentBackground)||(o=this.customOptions)!=null&&o.backgroundImage)return new v.Color4(0,0,0,t).toLinearSpace();if(this.customOptions&&this.customOptions.backgroundColor){const a=v.Color3.FromHexString(this.customOptions.backgroundColor);return new v.Color4(a.r,a.g,a.b,t).toLinearSpace()}return new v.Color4(.98,.98,.98,t).toLinearSpace()},this.highlightColorFromConfig=()=>this.customOptions&&this.customOptions.highlightColor?this.hexToColor4(this.customOptions.highlightColor):v.Color4.FromColor3(v.Color3.Gray()),this.hexToColor4=(t,i=1)=>{const r=v.Color3.FromHexString(t);return new v.Color4(r.r,r.g,r.b,i).toLinearSpace()},this.customOptions=e}createCanvas(){var e;return(e=this.customOptions)!=null&&e.createCanvas?this.customOptions.createCanvas():document.createElement("canvas")}get options(){return this.customOptions}get scene(){var e,t,i,r,n;return{clearColor:this.getSceneClearColor(),transparentBackground:((e=this.customOptions)==null?void 0:e.transparentBackground)||((t=this.customOptions)==null?void 0:t.backgroundImage),environment:{file:((i=this.customOptions)==null?void 0:i.environmentFile)??"assets/model-viewer/default.env",intensity:((r=this.customOptions)==null?void 0:r.environmentIntensity)??1,rotationY:(((n=this.customOptions)==null?void 0:n.environmentRotationY)??0)*(Math.PI/180)}}}get camera(){var e,t,i,r,n,o,a,l,h,c,g,m,b;return{autoOrientation:((e=this.customOptions)==null?void 0:e.disableAutomaticOrientation)??!0,autoRotation:{enabled:((t=this.customOptions)==null?void 0:t.autoRotation)??!1,idleTimeMs:((i=this.customOptions)==null?void 0:i.idleTimeBeforeRotation)??5e3},limits:{min:{alpha:(r=this.customOptions)!=null&&r.lowerAlphaLimitDeg?((n=this.customOptions)==null?void 0:n.lowerAlphaLimitDeg)*Math.PI/180:void 0,beta:(o=this.customOptions)!=null&&o.lowerBetaLimitDeg?((a=this.customOptions)==null?void 0:a.lowerBetaLimitDeg)*Math.PI/180:void 0,radius:(l=this.customOptions)==null?void 0:l.minZoomOverride},max:{alpha:(h=this.customOptions)!=null&&h.upperAlphaLimitDeg?((c=this.customOptions)==null?void 0:c.upperAlphaLimitDeg)*Math.PI/180:void 0,beta:(g=this.customOptions)!=null&&g.upperBetaLimitDeg?((m=this.customOptions)==null?void 0:m.upperBetaLimitDeg)*Math.PI/180:void 0,radius:(b=this.customOptions)==null?void 0:b.maxZoomOverride}}}}get highlights(){var e;return{enabled:((e=this.customOptions)==null?void 0:e.highlightOnMaterialHover)??!1,color:this.highlightColorFromConfig()}}get lighting(){var e,t,i,r;return{exposure:((t=(e=this.customOptions)==null?void 0:e.lighting)==null?void 0:t.exposure)??.9,contrast:((r=(i=this.customOptions)==null?void 0:i.lighting)==null?void 0:r.contrast)??1.6}}get emissiveGlowIntensity(){var e;return((e=this.customOptions)==null?void 0:e.emissiveGlowIntensity)??.5}}class x{static getDynamicTextureResolution(e=!1){return e?{width:1,height:1}:this.getIsMobile()||!x.offscreenRenderingSupported()?{width:1024,height:1024}:{width:2048,height:2048}}static shouldMipMap(){return!0}static offscreenRenderingSupported(){return navigator.userAgent.includes("SamsungBrowser")?!1:!!window.Worker&&!!window.OffscreenCanvas}static getMirrorTextureResolution(){return this.getIsMobile()?512:1024}static getIsMobile(){try{return typeof window>"u"||!window.navigator?!1:/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(window.navigator.userAgent)||window.innerWidth/window.devicePixelRatio<=480}catch{return!1}}}const Y=128,u={antiAliasing:{samples:4,fxaaEnabled:!1},bloom:{enabled:!1,kernel:64,scale:.5,threshold:.9,weight:.15},chromaticAberration:{enabled:!1,aberrationAmount:30,direction:{x:0,y:0},radialIntensity:0},colorCurves:{enabled:!1},depthOfField:{enabled:!1,blurLevel:"Low",focalLength:50,focusDistance:2e3,fStop:1.4,lensSize:50},grain:{enabled:!1,animated:!1,intensity:30},misc:{contrast:1,exposure:1,toneMappingEnabled:!1,toneMappingType:"Standard"},sharpen:{enabled:!1,colorAmount:1,edgeAmount:.3},vignette:{enabled:!1,blendMode:"Multiply",cameraFov:.5,center:{x:0,y:0},colorHex:"#000000ff",colorRgba:{r:0,g:0,b:0,a:1},stretch:0,weight:1}};class qe{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 B.PBRMaterial))){if(e.extras.sheen){const i=t;i.sheen.isEnabled=!0,i.sheen.intensity=e.extras.sheen}if(e.extras.translucency){const i=t;i.subSurface.isTranslucencyEnabled=!0,i.subSurface.translucencyIntensity=e.extras.translucency,e.extras.translucencyR&&e.extras.translucencyG&&e.extras.translucencyB&&(i.subSurface.tintColor=new T.Color3(e.extras.translucencyR,e.extras.translucencyG,e.extras.translucencyB))}if(e.extras.refractionIOR){const i=t;i.subSurface.isRefractionEnabled=!0,i.subSurface.volumeIndexOfRefraction=e.extras.refractionIOR}if(e.extras.useDepthPrePass){const i=t;i.needDepthPrePass=!0,i.forceIrradianceInFragment=!0}if(e.extras.useParallax){const i=t;i.useParallax=!0,i.useParallaxOcclusion=!0,i.parallaxScaleBias=e.extras.useParallax}}}applyReflections(e){function t(n){const o=[];return n.transformNodes.forEach(a=>{a.metadata&&a.metadata.reflective&&o.push(...a.getChildMeshes())}),n.meshes.forEach(a=>{a.metadata&&a.metadata.reflective&&!o.includes(a)&&o.push(a)}),o}function i(n,o=1){const a=n.material;if(!a)return;const l=new Pe.MirrorTexture("mirror",x.getMirrorTextureResolution(),e,!0);l.renderList=t(e);const h=n.getVerticesData("normal");if(!h)throw new Error("Mirror attribute specified on: "+n.name+"But no normals exist to generate a mirror from!");n.computeWorldMatrix(!0);const c=n.getWorldMatrix(),g=T.Vector3.TransformNormal(new T.Vector3(h[0],h[1],h[2]),c).normalize(),m=T.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 Te.ReflectionProbe("probe-"+o.name,Y,e);a.cubeTexture.name="reflection-probe-cube-texture",a.attachToMesh(n),a.renderList&&a.renderList.push(...t(e)),o.reflectionTexture=a.cubeTexture}e.meshes.forEach(n=>{const o=n.metadata;o&&(o.mirrorTexture&&i(n,o.mirrorTexture),o.reflectionProbe&&r(n))})}}class je{constructor(e,t){this.scene=e,this.intensity=t,this.meshCount=0}setIntensity(e){this.intensity=e,this.glowLayer&&(this.glowLayer.intensity=e)}includeMeshes(e){if(e){this.glowLayer||(this.glowLayer=new Re.GlowLayer("glow",this.scene),this.glowLayer.intensity=this.intensity);for(const t of e)this.glowLayer.hasMesh(t)||(this.glowLayer.addIncludedOnlyMesh(t),this.meshCount++)}}removeMeshes(e){if(!(!this.glowLayer||!e)){for(const t of e)this.glowLayer.hasMesh(t)&&(this.glowLayer.removeIncludedOnlyMesh(t),this.meshCount--);this.meshCount===0&&(this.glowLayer.dispose(),this.glowLayer=void 0)}}}function De(s,e,t,i,r=""){t.forEach(n=>{const o=n.getID(),a=n.getName(),l=n.getPanelSize&&n.getPanelSize(),h=x.getDynamicTextureResolution((l==null?void 0:l.width)===1||(l==null?void 0:l.height)===1);s.filter(g=>g.name===r+a).forEach(g=>{const m=i.get(o),b=!1;if(m)Z(g,m),m.update(b);else{const f=Ve(a,e,h.width,h.height);i.set(o,f),n.setStaticContext(f.getContext()),Z(g,f),f.onLoadObservable.addOnce(()=>{f.update(b)})}})})}function Ve(s,e,t,i){const r=new Le.DynamicTexture(s,{width:t,height:i},e,x.shouldMipMap(),Fe.Texture.TRILINEAR_SAMPLINGMODE,I.Engine.TEXTUREFORMAT_RGBA),n=r.getContext();return n&&(n.fillStyle="#f5f5f5",n.fillRect(0,0,t,i),r.update()),r}function Z(s,e){if(s instanceof B.PBRMaterial){const t=s,i=t.albedoTexture;i?(e.wrapU=i.wrapU,e.wrapV=i.wrapV):(e.wrapU=1,e.wrapV=1),t.albedoTexture=e}else{const t=s,i=t.diffuseTexture;i&&(e.wrapU=i.wrapU,e.wrapV=i.wrapV),t.diffuseTexture=e}}function Ne(){const s=()=>Math.floor((1+Math.random())*65536).toString(16).substring(1);return s()+s()+"-"+s()+"-"+s()+"-"+s()+"-"+s()+s()+s()}const P=60,$=1;function _(s){return s.targetedAnimations.map(t=>t.animation.framePerSecond).reduce((t,i)=>t+i,0)/s.targetedAnimations.length||0}function X(s,e,t,i,r,n){const o=r?s.filter(c=>c.name===r):s;if(o.length===0){console.warn(`No animations found for name: ${r}`);return}let a=0;const l=()=>{a++,a===o.length&&n&&n()},h=(c,g,m,b,f)=>{c.stop(),c.start(g,m,b,f),n&&(g==!1||g===void 0&&!c.loopAnimation?c.onAnimationGroupEndObservable.addOnce(()=>{l()}):c.onAnimationLoopObservable.addOnce(()=>{l()}))};if(i!==void 0&&t!==void 0&&i===t){o.forEach(c=>{const g=_(c),m=i*g;h(c,!1,$,m,m)});return}o.forEach(c=>{const g=_(c),m=i!==void 0?i*g:void 0,b=t!==void 0?t*g:void 0;h(c,e,$,m,b)})}function ke(s,e,t){return new Promise(i=>{s.stopAnimation(e),e.animations=[],Math.abs(e.alpha)>2*Math.PI&&(e.alpha=ze(e.alpha,0,2*Math.PI));const r=[],n=t.target;if(t.target&&Object.keys(t.target).length>0&&r.push(L("cameraTargetLerp","target",new p.Vector3().copyFrom(e.target),new p.Vector3(t.target.x,t.target.y,t.target.z),M.Animation.ANIMATIONTYPE_VECTOR3)),r.push(L("cameraAlphaLerp","alpha",e.alpha,J(t.lonDeg),M.Animation.ANIMATIONTYPE_FLOAT)),r.push(L("cameraBetaLerp","beta",e.beta,J(t.latDeg),M.Animation.ANIMATIONTYPE_FLOAT)),t.radius!==void 0){const l=Math.max(.01,t.radius);r.push(L("cameraRadiusLerp","radius",e.radius,l,M.Animation.ANIMATIONTYPE_FLOAT))}e.animations.push(...r);const a=e.useAutoRotationBehavior;e.disableAutoRotationBehavior(),s.beginAnimation(e,0,n?P*2:P,!1,1,()=>{e.animations=[],a&&e.enableAutoRotationBehavior(),i()})})}function J(s){return s*Math.PI/180}function L(s,e,t,i,r,n=0,o=M.Animation.ANIMATIONLOOPMODE_CONSTANT){const a=new U.QuadraticEase;a.setEasingMode(U.EasingFunction.EASINGMODE_EASEINOUT);const l=new M.Animation(s,e,P,r,o),h=[];return n>0&&h.push({frame:0,value:t}),h.push({frame:P*n,value:t}),h.push({frame:P*(n+1),value:i}),l.setKeys(h),l.setEasingFunction(a),l}function ze(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 Ue(s,e,t,i){["albedoTexture","bumpTexture","ambientTexture","emissiveTexture","opacityTexture","metallicTexture","refractionTexture","reflectionTexture"].forEach(n=>{Ke(n,s,e,t,i)}),Ye(s,e)}function Ke(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 v.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 v.Color3(1,1,1),e.emissiveIntensity=1)}function Ye(s,e){s.clearCoat&&(s.clearCoat===O.RemoveWhenSelected?(e.clearCoat.isEnabled=!1,e.clearCoat.indexOfRefraction=1.5):s.clearCoat===O.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(c=>c.name===a);if(l.length===0){n();return}const h=new Ie.AssetsManager(this.scene);h.useDefaultLoadingScreen=!1,l.forEach(c=>Ue(t,c,h,r)),h.onProgress=(c,g,m)=>{i&&i(c/g*100,100,m.name)},h.onFinish=c=>{c.forEach(g=>{const m=g;i&&i(100,100,g.name),this.scene.materials.filter(f=>f.name===a).forEach(f=>{Qe(g.name,f,t,m.texture)})}),n()},h.loadAsync()})}async applyModel(e,t,i,r,n,o,a){var m,b,f;if(i&&t&&!this.keysThatRemovedBaseModel.includes(e)&&this.keysThatRemovedBaseModel.push(e),!i)return this.keysThatRemovedBaseModel.includes(e)&&this.keysThatRemovedBaseModel.length===1&&await this.setBaseModelEnabled(!0),(m=this.loadedContainerForKey.get(e))==null||m.dispose(),this.loadedContainerForKey.delete(e),(b=this.loadedMaterialsForKey.get(e))==null||b.forEach(C=>C.dispose()),this.loadedMaterialsForKey.delete(e),this.keysThatRemovedBaseModel=this.keysThatRemovedBaseModel.filter(C=>C!==e),Promise.resolve(void 0);const h=(await D(i,this.scene,r)).instantiateModelsToScene(this.renameClonedAsset,!0);this.loadedContainerForKey.has(e)&&(this.loadedContainerForKey.get(e).dispose(),this.loadedContainerForKey.delete(e),(f=this.loadedMaterialsForKey.get(e))==null||f.forEach(C=>C.dispose()),this.loadedMaterialsForKey.delete(e));const c=n&&n();if(c){const C=o&&o(),y=c.name?this.renameClonedAsset(c.name):void 0;if(X(h.animationGroups,c.loop,c.to,c.from,y),C!=null){const F=a&&a()||!0;Ge(h.animationGroups,C+(F?2:0),y)}}t&&await this.setBaseModelEnabled(!1),this.loadedContainerForKey.set(e,h),this.loadedMaterialsForKey.set(e,ee(h));const g=[];return this.materialVariantMap.forEach(async(C,y)=>{g.push(this.applyMaterial(y,C))}),await Promise.all(g),h}dispose(){this.loadedContainerForKey.forEach(e=>e==null?void 0:e.dispose()),this.loadedContainerForKey.clear(),this.loadedMaterialsForKey.forEach(e=>e.forEach(t=>t==null?void 0:t.dispose())),this.loadedMaterialsForKey.clear(),this.materialVariantMap.clear(),this.keysThatRemovedBaseModel=[]}getAllMaterials(){const e=[];return this.loadedMaterialsForKey.forEach(t=>{t.forEach(i=>{e.includes(i)||e.push(i)})}),e}getAnimationGroups(){const e=[];return this.loadedContainerForKey.forEach(t=>{e.push(...t.animationGroups)}),e}}function ee(s){const e=[];return s.rootNodes.forEach(t=>{t.getChildMeshes().forEach(i=>{i.material&&!e.includes(i.material)&&e.push(i.material),i.subMeshes&&i.subMeshes.forEach(r=>{const n=r.getMaterial(!1);n&&!e.includes(n)&&e.push(n)})})}),e}function te(s,e=""){return s.map(t=>({name:t.name.substring(e.length),loop:t.loopAnimation,to:t.to,from:t.from}))}class $e{constructor(e){this.metadata=new Map,this.materialSelectedObservable=new A.Observable,this.materialDeselectedObservable=new A.Observable,this.materialVariantObservable=new A.Observable,this.modelVariantObservable=new A.Observable,this.materialReadyToLoadCallbacks=new Map,this.dynamicTextures=new Map,this.queuedMaterialChanges=new Map,this.materialChangesInProgress=[],this.queuedModelChanges=new Map,this.modelChangesInProgress=[],this.isExecutingAnimation=!1,this.animations=[],this.initialized=!1,this.materials=[];const{enablePicking:t,modelDetails:i,previewService:r,progressHandler:n,scene:o}=e;this.enablePicking=t,this.contextService=i.contextService,this.id=Ne(),this.previewService=r,this.scene=o,this.variantManager=new 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 D(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(),this.scene.cleanCachedTextureBuffer()}async applyModelVariant(e,t,i){const r=()=>this.variantManager.applyModel(e,i,t==null?void 0:t.model,a=>{this.modelVariantObservable.notifyObservers({...a,key:e})},this.getLastRequestedAnimation.bind(this),this.getCurrentAnimationFrame.bind(this),this.getAnimationIsPlaying.bind(this)),n=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};if(!this.initialized||this.modelChangesInProgress.includes(e)){const a=async()=>{const l=await r();return l?this.configureModelInstance(l):this.configureGlowLayer(),l};this.queuedModelChanges.set(e,a);return}const o=await n();this.contextService||(this.contextService=t==null?void 0:t.contextService),o?this.configureModelInstance(o):this.configureGlowLayer()}dispose(){var e;this.destroyInstance(),this.variantManager.dispose(),this.dynamicTextures.forEach(t=>t==null?void 0:t.dispose()),this.dynamicTextures.clear(),this.materials.forEach(t=>t&&(t==null?void 0:t.dispose())),this.materials=[],(e=this.transformRoot)==null||e.dispose(),this.transformRoot=void 0,this.previewService.modelUnloaded(this)}executeAnimation(e){if(this.lastRequestedAnimation=e,!this.initialized)return this.queuedModelAnimation=e,Promise.resolve();let t=()=>{};const i=async()=>{this.isExecutingAnimation=!0,await new Promise(r=>{var o;const n=[...((o=this.modelInstance)==null?void 0:o.animationGroups)||[],...this.variantManager.getAnimationGroups()];X(n,e.loop,e.to,e.from,e.name?this.renameClonedAsset(e.name):void 0,r)}),this.isExecutingAnimation=!1,this.queuedAnimationFunction&&this.queuedAnimationFunction(),this.queuedAnimationFunction=void 0,t()};return this.isExecutingAnimation?(this.queuedAnimationFunction=i,new Promise(r=>{t=r})):i()}getAnimations(e){return[...this.animations,...e?te(this.variantManager.getAnimationGroups(),this.renameClonedAsset("")):[]].map((t,i)=>({...t,name:t.name||`UNNAMED_ANIMATION_${i}`})).filter((t,i,r)=>r.indexOf(r.find(n=>n.name===t.name))==i)}getId(){return this.id}listMaterials(){var t;const e=(t=this.scene)==null?void 0:t.materials.filter(i=>i.name.startsWith(this.id));return e?e.map(i=>({id:i.id,name:this.stripIdFromName(i.name)})):[]}registerMaterialSelectedCallback(e){this.materialSelectedObservable.add(e)}unregisterMaterialSelectedCallback(e){this.materialSelectedObservable.removeCallback(e)}registerMaterialDeselectedCallback(e){this.materialDeselectedObservable.add(e)}unregisterMaterialDeselectedCallback(e){this.materialDeselectedObservable.removeCallback(e)}get position(){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to requesting position!");return this.transformRoot.position}set position(e){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to setting position!");this.transformRoot.position=new p.Vector3(e.x,e.y,e.z)}get rotation(){var e;if(!((e=this.transformRoot)!=null&&e.rotationQuaternion))throw new Error("ModelContainer disposed prior to requesting rotation!");return this.transformRoot.rotationQuaternion.toEulerAngles()}set rotation(e){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to setting rotation!");this.transformRoot.rotationQuaternion=p.Quaternion.FromEulerAngles(e.x,e.y,e.z)}get scale(){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to requesting scale!");return this.transformRoot.scaling}set scale(e){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to setting scale!");this.transformRoot.scaling=new p.Vector3(e.x,e.y,e.z)}attachPickingHandler(e){e.rootNodes.forEach(t=>{t.getChildMeshes(!1).forEach(i=>{i.name==="targetcube_t"||i.name==="backgroundShell"||(i.actionManager||(i.actionManager=new q.ActionManager(this.scene)),i.actionManager.registerAction(new H.ExecuteCodeAction(q.ActionManager.OnPointerOverTrigger,r=>{r.meshUnderPointer&&i.material&&this.materialSelectedObservable.notifyObservers({id:i.material.id,name:this.stripIdFromName(i.material.name)})})),i.actionManager.registerAction(new H.ExecuteCodeAction(q.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.queuedModelChanges.size}configureGlowLayer(){const e=i=>i instanceof B.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 Ee.Mesh)).flat()}async instantiate(){if(!this.assetContainer)throw new Error("Attempted to instantiate ModelContainer without an AssetContainer");this.modelInstance=this.assetContainer.instantiateModelsToScene(this.renameClonedAsset.bind(this),!0),this.materials=ee(this.modelInstance),this.configureModelInstance(this.modelInstance),this.animations=te(this.modelInstance.animationGroups,this.renameClonedAsset("")),this.initialized=!0,await this.processQueuedEvents()}renameClonedAsset(e){return`${this.id}_${e}`}async setBaseModelEnabled(e){e&&!this.modelInstance?await this.instantiate():!e&&this.modelInstance&&this.destroyInstance()}updateDynamicTextures(){var e;(e=this.canvasPanels)==null||e.forEach((t,i)=>{const r=this.dynamicTextures.get(i);r&&t.getStaticContextDirty()&&r.isReady()&&(r.update(!1),t.setStaticContextDirty(!1))})}registerMaterialVariantListener(e){this.materialVariantObservable.add(e)}unregisterMaterialVariantListener(e){this.materialVariantObservable.removeCallback(e)}registerModelVariantListener(e){this.modelVariantObservable.add(e)}unregisterModelVariantListener(e){this.modelVariantObservable.removeCallback(e)}getLastRequestedAnimation(){return this.lastRequestedAnimation}getCurrentAnimationFrame(){var t;const e=[...((t=this.modelInstance)==null?void 0:t.animationGroups)||[],...this.variantManager.getAnimationGroups()];for(const i of e)if(i.animatables.length>0&&i.animatables[0].masterFrame!==void 0&&i.animatables[0].masterFrame!==null)return i.animatables[0].masterFrame;return 0}getAnimationIsPlaying(){var t;const e=[...((t=this.modelInstance)==null?void 0:t.animationGroups)||[],...this.variantManager.getAnimationGroups()];for(const i of e)if(i.isPlaying)return!0;return!1}stripIdFromName(e){return e.substring(this.id.length+1)}async processQueuedEvents(){await Promise.all(Array.from(this.materialReadyToLoadCallbacks.values()).flatMap(e=>Array.from(e.values()).map(t=>t()))),this.materialReadyToLoadCallbacks.clear(),await Promise.all(Array.from(this.queuedModelChanges.values()).map(e=>e())),this.queuedModelChanges.clear(),this.scene.onAfterRenderObservable.addOnce(()=>{this.queuedModelAnimation&&(this.executeAnimation(this.queuedModelAnimation),this.queuedModelAnimation=void 0)})}}class V extends w.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=N(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=N(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=N(e),n=r.max.subtract(r.min),o=r.min.add(n.scale(.5)),a=new V("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 N(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 _e{constructor(e,t=!1,i=void 0){this.renderingPipeline=new Se.DefaultRenderingPipeline("default",t,e,i?[i]:void 0,!1),this.renderingPipeline.isSupported&&(this.renderingPipeline.prepare(),this.setConfiguration(u))}dispose(){this.renderingPipeline.dispose()}getConfiguration(){return this.currentConfiguration}setConfiguration(e){var t,i,r,n,o,a,l,h,c,g,m,b,f,C,y,F,ie,ne,se,re,ae,oe,le,he,ce,de,ue,ge,me,pe,fe,be,ve;if(this.renderingPipeline.isSupported){if(this.renderingPipeline.samples=((t=e.antiAliasing)==null?void 0:t.samples)??u.antiAliasing.samples,this.renderingPipeline.fxaaEnabled=((i=e.antiAliasing)==null?void 0:i.fxaaEnabled)??u.antiAliasing.fxaaEnabled,this.renderingPipeline.bloomEnabled=((r=e.bloom)==null?void 0:r.enabled)??u.bloom.enabled,this.renderingPipeline.bloomKernel=((n=e.bloom)==null?void 0:n.kernel)??u.bloom.kernel,this.renderingPipeline.bloomScale=((o=e.bloom)==null?void 0:o.scale)??u.bloom.scale,this.renderingPipeline.bloomThreshold=((a=e.bloom)==null?void 0:a.threshold)??u.bloom.threshold,this.renderingPipeline.bloomWeight=((l=e.bloom)==null?void 0:l.weight)??u.bloom.weight,this.renderingPipeline.chromaticAberrationEnabled=((h=e.chromaticAberration)==null?void 0:h.enabled)??u.chromaticAberration.enabled,this.renderingPipeline.chromaticAberration.aberrationAmount=((c=e.chromaticAberration)==null?void 0:c.aberrationAmount)??u.chromaticAberration.aberrationAmount,this.renderingPipeline.chromaticAberration.radialIntensity=((g=e.chromaticAberration)==null?void 0:g.radialIntensity)??u.chromaticAberration.radialIntensity,this.renderingPipeline.chromaticAberration.direction=(m=e.chromaticAberration)!=null&&m.direction?new p.Vector2(e.chromaticAberration.direction.x,e.chromaticAberration.direction.y):new p.Vector2(u.chromaticAberration.direction.x,u.chromaticAberration.direction.y),this.renderingPipeline.imageProcessing.colorCurvesEnabled=((b=e.colorCurves)==null?void 0:b.enabled)??u.colorCurves.enabled,this.renderingPipeline.imageProcessing.colorCurves=e.colorCurves?this.updateColorCurve(e.colorCurves):new K.ColorCurves,this.renderingPipeline.depthOfFieldEnabled=((f=e.depthOfField)==null?void 0:f.enabled)??u.depthOfField.enabled,e.depthOfField)switch(e.depthOfField.blurLevel??u.depthOfField.blurLevel){case"Low":this.renderingPipeline.depthOfFieldBlurLevel=j.DepthOfFieldEffectBlurLevel.Low;break;case"Medium":this.renderingPipeline.depthOfFieldBlurLevel=j.DepthOfFieldEffectBlurLevel.Medium;break;case"High":this.renderingPipeline.depthOfFieldBlurLevel=j.DepthOfFieldEffectBlurLevel.High;break}if(this.renderingPipeline.depthOfField.focalLength=((C=e.depthOfField)==null?void 0:C.focalLength)??u.depthOfField.focalLength,this.renderingPipeline.depthOfField.fStop=((y=e.depthOfField)==null?void 0:y.fStop)??u.depthOfField.fStop,this.renderingPipeline.depthOfField.focusDistance=((F=e.depthOfField)==null?void 0:F.focusDistance)??u.depthOfField.focusDistance,this.renderingPipeline.depthOfField.lensSize=((ie=e.depthOfField)==null?void 0:ie.lensSize)??u.depthOfField.lensSize,this.renderingPipeline.grainEnabled=((ne=e.grain)==null?void 0:ne.enabled)??u.grain.enabled,this.renderingPipeline.grain.animated=((se=e.grain)==null?void 0:se.animated)??u.grain.animated,this.renderingPipeline.grain.intensity=((re=e.grain)==null?void 0:re.intensity)??u.grain.intensity,this.renderingPipeline.imageProcessing.contrast=((ae=e.misc)==null?void 0:ae.contrast)??u.misc.contrast,this.renderingPipeline.imageProcessing.exposure=((oe=e.misc)==null?void 0:oe.exposure)??u.misc.exposure,this.renderingPipeline.imageProcessing.toneMappingEnabled=((le=e.misc)==null?void 0:le.toneMappingEnabled)??u.misc.toneMappingEnabled,this.renderingPipeline.imageProcessing.toneMappingEnabled)switch(e.misc.toneMappingType??u.misc.toneMappingType){case"Standard":this.renderingPipeline.imageProcessing.toneMappingType=R.ImageProcessingConfiguration.TONEMAPPING_STANDARD;break;case"ACES":this.renderingPipeline.imageProcessing.toneMappingType=R.ImageProcessingConfiguration.TONEMAPPING_ACES;break}if(this.renderingPipeline.sharpenEnabled=((he=e.sharpen)==null?void 0:he.enabled)??u.sharpen.enabled,this.renderingPipeline.sharpen.colorAmount=((ce=e.sharpen)==null?void 0:ce.colorAmount)??u.sharpen.colorAmount,this.renderingPipeline.sharpen.edgeAmount=((de=e.sharpen)==null?void 0:de.edgeAmount)??u.sharpen.edgeAmount,this.renderingPipeline.imageProcessing.vignetteEnabled=((ue=e.vignette)==null?void 0:ue.enabled)??u.vignette.enabled,(ge=e.vignette)!=null&&ge.center?(this.renderingPipeline.imageProcessing.vignetteCenterX=e.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=e.vignette.center.y):(this.renderingPipeline.imageProcessing.vignetteCenterX=u.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=u.vignette.center.y),e.vignette)switch(((me=e.vignette)==null?void 0:me.blendMode)??u.vignette.blendMode){case"Multiply":this.renderingPipeline.imageProcessing.vignetteBlendMode=R.ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY;break;case"Opaque":this.renderingPipeline.imageProcessing.vignetteBlendMode=R.ImageProcessingConfiguration.VIGNETTEMODE_OPAQUE;break}(pe=e.vignette)!=null&&pe.colorRgba?this.renderingPipeline.imageProcessing.vignetteColor=new v.Color4(e.vignette.colorRgba.r,e.vignette.colorRgba.g,e.vignette.colorRgba.b,e.vignette.colorRgba.a):(fe=e.vignette)!=null&&fe.colorHex?this.renderingPipeline.imageProcessing.vignetteColor=v.Color4.FromHexString(e.vignette.colorHex):this.renderingPipeline.imageProcessing.vignetteColor=new v.Color4(u.vignette.colorRgba.r,u.vignette.colorRgba.g,u.vignette.colorRgba.b,u.vignette.colorRgba.a),this.renderingPipeline.imageProcessing.vignetteStretch=((be=e.vignette)==null?void 0:be.stretch)??u.vignette.stretch,this.renderingPipeline.imageProcessing.vignetteWeight=((ve=e.vignette)==null?void 0:ve.weight)??u.vignette.weight,this.renderingPipeline.prepare(),this.currentConfiguration=e}}updateColorCurve(e){const t=new K.ColorCurves;return t.globalDensity=e.globalDensity??t.globalDensity,t.globalExposure=e.globalExposure??t.globalExposure,t.globalHue=e.globalHue??t.globalHue,t.globalSaturation=e.globalSaturation??t.globalSaturation,t.highlightsDensity=e.highlightsDensity??t.highlightsDensity,t.highlightsExposure=e.highlightsExposure??t.highlightsExposure,t.highlightsHue=e.highlightsHue??t.highlightsHue,t.highlightsSaturation=e.highlightsSaturation??t.highlightsSaturation,t.midtonesDensity=e.midtonesDensity??t.midtonesDensity,t.midtonesExposure=e.midtonesExposure??t.midtonesExposure,t.midtonesHue=e.midtonesHue??t.midtonesHue,t.midtonesSaturation=e.midtonesSaturation??t.midtonesSaturation,t.shadowsDensity=e.shadowsDensity??t.shadowsDensity,t.shadowsExposure=e.shadowsExposure??t.shadowsExposure,t.shadowsHue=e.shadowsHue??t.shadowsHue,t.shadowsSaturation=e.shadowsSaturation??t.shadowsSaturation,t}}xe.GLTF2.GLTFLoader.RegisterExtension("glbPostProcessor",function(s){return new qe(s)}),S.SceneLoader.OnPluginActivatedObservable.add(s=>{if(s.name==="gltf"){const e=s;e.transparencyAsCoverage=!0}});function k(s){return new p.Vector3(s.x,s.y,s.z)}function z(s){return{x:s.x,y:s.y,z:s.z}}class Xe{constructor(e){var l;this.focusLostNotified=!1,this.focusLostObservable=new A.Observable,this.modelLoadEventCallbacks=[],this.validHighlightMaterials=[],this.modelContainers=new Map,this.plugins=[],this.initComplete=!1,this.isAnimatingCamera=!1,this.renderLoop=()=>{if(!this.engine.views)return;this.modelContainers.forEach(g=>{g.updateDynamicTextures()}),this.scene.autoClear=!0,this.scene.autoClearDepthAndStencil=!0;const h=this.engine.getRenderingCanvas();if(h)if(h.getContext("webgl2")??h.getContext("webgl")){const g=this.configuration.scene.clearColor,m=h.getContext("webgl2")??h.getContext("webgl");m.clearDepth(1),m.depthFunc(m.LEQUAL),m.clearStencil(0),m.clearColor(g.r,g.g,g.b,g.a),m.clear(m.COLOR_BUFFER_BIT|m.DEPTH_BUFFER_BIT|m.STENCIL_BUFFER_BIT)}else h.getContext("2d")?h.getContext("2d").clearRect(0,0,h.width,h.height):console.error("SpiffCommerce: Failed to get any context on the rendering canvas.");this.scene.render(),this.camera.isRunningFramingBehavior&&this.camera.getFramingBehavior().isUserIsMoving&&(this.camera.isRunningFramingBehavior=!1);const c=Math.max((this.camera.lowerRadiusLimit??1)*.01,.001);!this.camera.isRunningFramingBehavior&&!this.camera.target.equalsWithEpsilon(this.camera.lastFocus,c)&&!this.focusLostNotified&&(this.focusLostObservable.notifyObservers(void 0),this.focusLostNotified=!0)},this.configuration=new Q(e);const i=(()=>{if(!(e!=null&&e.noRender))return this.configuration.createCanvas()})(),r="1.5.7";ye.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 I.Engine(i,!0,{adaptToDeviceRatio:!0,limitDeviceRatio:2,premultipliedAlpha:!1,preserveDrawingBuffer:!!(e!=null&&e.backgroundImage),audioEngine:!1,stencil:this.configuration.highlights.enabled,forceSRGBBufferSupportState:!0}):new Ce.NullEngine;o.enableOfflineSupport=!1,o.doNotHandleContextLost=!0,console.log=n,o.hideLoadingUI(),window.addEventListener("resize",this.fireResizeEvent.bind(this)),this.engine=o,this.scene=new Me.Scene(o),this.camera=V.create(this.scene,this.configuration),this.scene.activeCamera=this.camera,this.renderingPipeline=new _e(this.scene,!1,this.camera),this.scene.clearColor=this.configuration.scene.clearColor;const a=G.CubeTexture.CreateFromPrefilteredData(this.configuration.scene.environment.file,this.scene);a.name="initial-environment-cube",a.rotationY=this.configuration.scene.environment.rotationY,this.scene.environmentTexture=a,this.scene.environmentIntensity=this.configuration.scene.environment.intensity,(l=this.configuration.options)!=null&&l.renderingPipelineConfiguration?this.renderingPipeline.setConfiguration(this.configuration.options.renderingPipelineConfiguration):(this.scene.imageProcessingConfiguration.exposure=this.configuration.lighting.exposure,this.scene.imageProcessingConfiguration.contrast=this.configuration.lighting.contrast),this.glowLayerManager=new je(this.scene,this.configuration.emissiveGlowIntensity),this.initPromise=new Promise(h=>{this.scene.onReadyObservable.addOnce(()=>{this.initComplete=!0,h()})}),this.engine.runRenderLoop(this.renderLoop)}getInitializationPromise(){return this.initPromise}getInitializationComplete(){return this.initComplete}getEngineContext(){return{engine:this.engine,scene:this.scene,camera:this.camera}}registerFocusLostListener(e){this.focusLostObservable.add(e)}unregisterFocusLostListener(e){this.focusLostObservable.removeCallback(e)}registerModelLoadEventListener(e){this.modelLoadEventCallbacks.push(e)}unregisterModelLoadEventListener(e){const t=this.modelLoadEventCallbacks.indexOf(e);t>-1&&this.modelLoadEventCallbacks.splice(t,1)}registerView(e){const t=e.height,i=e.width;this.engine.registerView(e,void 0,!0),e.setAttribute("height",t.toString()),e.setAttribute("width",i.toString()),this.orbitEnabled()||this.setCameraState(E.Pan),this.reattachControls(e)}getNumViewports(){var e;return((e=this.engine.views)==null?void 0:e.length)||0}unregisterView(e){this.engine.unRegisterView(e)}shutdown(){this.plugins.forEach(e=>e.dispose(!0)),this.renderingPipeline.dispose(),this.engine&&this.engine.dispose(),window.removeEventListener("resize",this.fireResizeEvent)}executeCameraAnimation(e){if(!this.camera||this.scene.activeCamera!==this.camera||this.getAllModels().length===0||!this.getAllModels().some(r=>r.getIsInitialized()))return this.queuedCameraAnimation=e,Promise.resolve();let t=()=>{};const i=async()=>{this.isAnimatingCamera=!0,await ke(this.scene,this.scene.activeCamera,e),this.isAnimatingCamera=!1,this.queuedAnimationFunction&&this.queuedAnimationFunction(),this.queuedAnimationFunction=void 0,t()};return this.isAnimatingCamera?(this.queuedAnimationFunction=i,new Promise(r=>{t=r})):i()}getCameraPose(){if(this.scene&&this.camera)return{lonDeg:Math.round(this.camera.alpha*180/Math.PI),latDeg:Math.round(this.camera.beta*180/Math.PI),radius:Math.round((this.camera.radius+Number.EPSILON)*1e4)/1e4,target:{x:this.camera.target.x,y:this.camera.target.y,z:this.camera.target.z}}}setCameraPose(e){this.scene&&this.camera&&(this.camera.target=new p.Vector3(e.target.x,e.target.y,e.target.z),this.camera.radius=e.radius,this.camera.alpha=e.latDeg,this.camera.beta=e.lonDeg)}setCameraState(e){var t,i;if(!((t=this.engine)!=null&&t.views)||!((i=this.engine)!=null&&i.views[0]))throw new Error("No views attached, camera state requires a view to attach controls onto.");e===E.Orbit?this.reattachControls(this.engine.views[0].target,2):this.reattachControls(this.engine.views[0].target,0)}animateToLastCameraFocus(){let e=()=>{};const t=async()=>{this.isAnimatingCamera=!0,await new Promise(i=>{this.focusLostNotified=!1;const r=()=>{const n=this.configuration;this.camera.rerunFramingBehavior(()=>{n.camera.limits.min.radius&&(this.camera.lowerRadiusLimit=n.camera.limits.min.radius),n.camera.limits.max.radius&&(this.camera.upperRadiusLimit=n.camera.limits.max.radius),i()})};this.scene.onAfterRenderObservable.addOnce(r)}),this.isAnimatingCamera=!1,this.queuedAnimationFunction&&this.queuedAnimationFunction(),this.queuedAnimationFunction=void 0,e()};return this.isAnimatingCamera?(this.queuedAnimationFunction=t,new Promise(i=>{e=i})):t()}forceStopCameraAnimations(){var e;this.queuedAnimationFunction=void 0,this.queuedCameraAnimation=void 0,this.isAnimatingCamera=!1,(e=this.camera.framingBehavior)==null||e.stopAllAnimations(),this.scene.stopAnimation(this.camera)}setAutoRotation(e){!this.configuration.camera.autoRotation.enabled||!this.camera||(e?this.camera.enableAutoRotationBehavior(this.configuration.camera.autoRotation.idleTimeMs):this.camera.disableAutoRotationBehavior())}getCurrentConfiguration(){return this.configuration.options}async renderSceneScreenshot(e,t){if(!this.camera)throw new Error("Missing product camera, cannot render screenshot!");const i=new w.ArcRotateCamera("screenshotCamera",0,0,0,p.Vector3.Zero(),this.scene),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;try{return await new Promise(o=>{const a=this.scene.onBeforeRenderObservable.add(async()=>{this.scene.onBeforeRenderObservable.remove(a);const l=await we.Tools.CreateScreenshotUsingRenderTargetAsync(this.engine,i,e,"image/png",2,!0);return i.dispose(),o(l)});this.scene.render(),this.engine.endFrame()})}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(c=>c===t),h=a.every(c=>c===r);return!l&&!h}fireResizeEvent(){this.getNumViewports()>0&&this.engine.resize()}setHighlights(e){this.scene.materials.forEach(()=>{this.scene.materials.forEach(i=>{i.emissiveIntensity===.18&&(i.emissiveColor=v.Color3.Black(),i.emissiveIntensity=1)})}),e.filter(i=>this.validHighlightMaterials.includes(i.name)).forEach(i=>{const r=this.scene.materials.find(n=>n.id===i.id);r&&(r.emissiveColor=new v.Color3(this.configuration.highlights.color.r,this.configuration.highlights.color.g,this.configuration.highlights.color.b),r.emissiveIntensity=.18)})}setRenderingPipelineConfiguration(e){this.renderingPipeline&&this.renderingPipeline.setConfiguration(e)}loadModel(e,t){const{refocusCamera:i=!0,progressHandler:r}=t??{},n=new $e({enablePicking:this.configuration.highlights.enabled,modelDetails:e,scene:this.scene,previewService:this,progressHandler:r});return n.getInitializationPromise().then(()=>{if(this.modelContainers.size<=1&&i){const o=this.queuedCameraAnimation;this.forceStopCameraAnimations(),this.camera.rerunFramingBehavior(()=>{this.scene.onAfterRenderObservable.addOnce(()=>{o&&(this.executeCameraAnimation(o),this.queuedCameraAnimation=void 0)})},1)}}),this.configuration.highlights.enabled&&(n.registerMaterialSelectedCallback(o=>{this.setHighlights([o])}),n.registerMaterialDeselectedCallback(()=>{this.setHighlights([])})),this.modelContainers.set(n.getId(),n),this.triggerModelLoadEvent({eventType:"load",modelContainer:n}),n}async preloadModel(e){await D(e,this.scene)}getAllModels(){return Array.from(this.modelContainers.values())}getModelById(e){return this.modelContainers.get(e)}registerPlugin(e){this.plugins.push(e),e.initialize(this,{camera:this.camera,engine:this.engine,scene:this.scene})}unregisterPlugin(e){const t=this.plugins.indexOf(e);t>-1&&this.plugins.splice(t,1).forEach(r=>r.dispose(!1))}getGlowLayerManager(){return this.glowLayerManager}modelUnloaded(e){this.modelContainers.delete(e.getId()),this.triggerModelLoadEvent({eventType:"unload",modelContainer:e})}triggerModelLoadEvent(e){this.modelLoadEventCallbacks.forEach(t=>t(e))}flipTransform(e,t,i){const r=p.Matrix.Compose(k(i||{x:1,y:1,z:1}),p.Quaternion.FromEulerVector(k(t||{x:0,y:0,z:0})),k(e||{x:0,y:0,z:0})),n=p.Matrix.RotationAxis(p.Vector3.Up(),Math.PI),o=r.multiply(n),a=p.Vector3.Zero(),l=p.Quaternion.Identity(),h=p.Vector3.Zero();return o.decompose(h,l,a),l.multiplyInPlace(p.Quaternion.FromEulerAngles(0,Math.PI,0)),{position:z(a),rotation:z(l.toEulerAngles()),scale:z(h)}}updatePreviewOptions(e){var r,n;const t=new Q(e);this.configuration.highlights.enabled!==t.highlights.enabled&&this.engine.setStencilBuffer(t.highlights.enabled),this.scene.clearColor=t.scene.clearColor;let i=this.scene.environmentTexture;this.configuration.scene.environment.file!==t.scene.environment.file&&(i=G.CubeTexture.CreateFromPrefilteredData(t.scene.environment.file,this.scene),i.name="updated-environment-cube",i.rotationY=this.configuration.scene.environment.rotationY,this.scene.environmentTexture=i),i.rotationY=t.scene.environment.rotationY,this.scene.environmentIntensity=t.scene.environment.intensity,(r=t.options)!=null&&r.renderingPipelineConfiguration?this.renderingPipeline.setConfiguration(t.options.renderingPipelineConfiguration):(this.scene.imageProcessingConfiguration.exposure=t.lighting.exposure,this.scene.imageProcessingConfiguration.contrast=t.lighting.contrast),this.glowLayerManager.setIntensity(t.emissiveGlowIntensity),this.camera.updateConfiguration(t),this.camera.setPanEnabled(((n=t.options)==null?void 0:n.noPan)!==void 0?!t.options.noPan:!0),this.configuration=t}setHighlightMaterials(e){this.validHighlightMaterials=e}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)}static isSupported(){return I.Engine.isSupported()}}d.MaterialEffectMode=O,d.ProductCameraRig=E,d.REFLECTION_PROBE_RESOLUTION=Y,d.RenderingConfiguration=x,d.SpiffCommerce3DPreviewService=Xe,d.renderingPipelineDefaults=u,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spiffcommerce/preview",
3
- "version": "5.9.5-1",
3
+ "version": "5.10.0",
4
4
  "description": "An internal implementation of the ThreeDPreviewService interface used by Spiff Commerce",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/index.umd.js",