@spiffcommerce/preview 5.3.5-3 → 5.3.5-4

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.esm.js CHANGED
@@ -3,21 +3,21 @@ import { Engine as pe } from "@babylonjs/core/Engines/engine";
3
3
  import { NullEngine as Ce } from "@babylonjs/core/Engines/nullEngine";
4
4
  import { HighlightLayer as ye } from "@babylonjs/core/Layers/highlightLayer";
5
5
  import { SceneLoader as fe } from "@babylonjs/core/Loading/sceneLoader";
6
- import { CubeTexture as te } from "@babylonjs/core/Materials/Textures/cubeTexture";
6
+ import { CubeTexture as ie } from "@babylonjs/core/Materials/Textures/cubeTexture";
7
7
  import { Color4 as f, Color3 as w } from "@babylonjs/core/Maths/math.color";
8
- import { Vector3 as m, Quaternion as y, Vector2 as ie, Matrix as se } from "@babylonjs/core/Maths/math.vector";
8
+ import { Vector3 as m, Quaternion as y, Vector2 as se, Matrix as ne } from "@babylonjs/core/Maths/math.vector";
9
9
  import { DracoCompression as Me } from "@babylonjs/core/Meshes/Compression/dracoCompression";
10
10
  import { Observable as C } from "@babylonjs/core/Misc/observable";
11
11
  import { Tools as xe } from "@babylonjs/core/Misc/tools";
12
12
  import { Scene as Pe } from "@babylonjs/core/scene";
13
- import { GLTF2 as Ae } from "@babylonjs/loaders/glTF";
14
- import { PBRMaterial as F } from "@babylonjs/core/Materials/PBR/pbrMaterial";
13
+ import { GLTF2 as Ee } from "@babylonjs/loaders/glTF";
14
+ import { PBRMaterial as B } from "@babylonjs/core/Materials/PBR/pbrMaterial";
15
15
  import { MirrorTexture as Te } from "@babylonjs/core/Materials/Textures/mirrorTexture";
16
- import { Color3 as Ee, Vector3 as ne, Plane as Re } from "@babylonjs/core/Maths/math";
17
- import { ReflectionProbe as Oe } from "@babylonjs/core/Probes/reflectionProbe";
18
- import { GlowLayer as Ie } from "@babylonjs/core/Layers/glowLayer";
19
- import { ActionManager as T } from "@babylonjs/core/Actions/actionManager";
20
- import { ExecuteCodeAction as re } from "@babylonjs/core/Actions/directActions";
16
+ import { Color3 as Ae, Vector3 as re, Plane as Re } from "@babylonjs/core/Maths/math";
17
+ import { ReflectionProbe as Ie } from "@babylonjs/core/Probes/reflectionProbe";
18
+ import { GlowLayer as Oe } from "@babylonjs/core/Layers/glowLayer";
19
+ import { ActionManager as A } from "@babylonjs/core/Actions/actionManager";
20
+ import { ExecuteCodeAction as ae } from "@babylonjs/core/Actions/directActions";
21
21
  import { Mesh as Le } from "@babylonjs/core/Meshes/mesh";
22
22
  import { TransformNode as Se } from "@babylonjs/core/Meshes/transformNode";
23
23
  import { DynamicTexture as Fe } from "@babylonjs/core/Materials/Textures/dynamicTexture";
@@ -25,10 +25,10 @@ import { Texture as Be } from "@babylonjs/core/Materials/Textures/texture";
25
25
  import { Animation as v } from "@babylonjs/core/Animations/animation";
26
26
  import { QuadraticEase as De, EasingFunction as Ge } from "@babylonjs/core/Animations/easing";
27
27
  import { AssetsManager as Ne } from "@babylonjs/core/Misc/assetsManager";
28
- import { ColorCurves as ae } from "@babylonjs/core/Materials/colorCurves";
28
+ import { ColorCurves as oe } from "@babylonjs/core/Materials/colorCurves";
29
29
  import { ImageProcessingConfiguration as P } from "@babylonjs/core/Materials/imageProcessingConfiguration";
30
30
  import { DefaultRenderingPipeline as ke } from "@babylonjs/core/PostProcesses/RenderPipeline";
31
- import { DepthOfFieldEffectBlurLevel as E } from "@babylonjs/core/PostProcesses/depthOfFieldEffect";
31
+ import { DepthOfFieldEffectBlurLevel as R } from "@babylonjs/core/PostProcesses/depthOfFieldEffect";
32
32
  import "@babylonjs/core/Rendering/depthRendererSceneComponent";
33
33
  import "@babylonjs/core/Engines/Extensions/engine.views";
34
34
  import "@babylonjs/core/Meshes/instancedMesh";
@@ -39,8 +39,8 @@ import "@babylonjs/core/Animations/animatable";
39
39
  import "@babylonjs/core/Misc/screenshotTools";
40
40
  import "@babylonjs/core/Rendering/boundingBoxRenderer";
41
41
  import "@babylonjs/loaders/glTF/2.0/Extensions";
42
- var L = /* @__PURE__ */ ((s) => (s[s.Orbit = 0] = "Orbit", s[s.Pan = 1] = "Pan", s))(L || {}), S = /* @__PURE__ */ ((s) => (s.None = "None", s.RemoveWhenSelected = "RemoveWhenSelected", s.ApplyWhenSelected = "ApplyWhenSelected", s))(S || {});
43
- class oe {
42
+ var S = /* @__PURE__ */ ((s) => (s[s.Orbit = 0] = "Orbit", s[s.Pan = 1] = "Pan", s))(S || {}), F = /* @__PURE__ */ ((s) => (s.None = "None", s.RemoveWhenSelected = "RemoveWhenSelected", s.ApplyWhenSelected = "ApplyWhenSelected", s))(F || {});
43
+ class le {
44
44
  constructor(e) {
45
45
  this.getSceneClearColor = () => {
46
46
  var i, a, o, n;
@@ -282,14 +282,14 @@ class Ve {
282
282
  * @param babylonMaterial An instance of a material representation in babylon.
283
283
  */
284
284
  enableMaterialExtrasIfRequired(e, t) {
285
- if (!(!e.extras || !(t instanceof F))) {
285
+ if (!(!e.extras || !(t instanceof B))) {
286
286
  if (e.extras.sheen) {
287
287
  const i = t;
288
288
  i.sheen.isEnabled = !0, i.sheen.intensity = e.extras.sheen;
289
289
  }
290
290
  if (e.extras.translucency) {
291
291
  const i = t;
292
- i.subSurface.isTranslucencyEnabled = !0, i.subSurface.translucencyIntensity = e.extras.translucency, e.extras.translucencyR && e.extras.translucencyG && e.extras.translucencyB && (i.subSurface.tintColor = new Ee(
292
+ i.subSurface.isTranslucencyEnabled = !0, i.subSurface.translucencyIntensity = e.extras.translucency, e.extras.translucencyR && e.extras.translucencyG && e.extras.translucencyB && (i.subSurface.tintColor = new Ae(
293
293
  e.extras.translucencyR,
294
294
  e.extras.translucencyG,
295
295
  e.extras.translucencyB
@@ -340,8 +340,8 @@ class Ve {
340
340
  "Mirror attribute specified on: " + o.name + "But no normals exist to generate a mirror from!"
341
341
  );
342
342
  o.computeWorldMatrix(!0);
343
- const d = o.getWorldMatrix(), u = ne.TransformNormal(
344
- new ne(c[0], c[1], c[2]),
343
+ const d = o.getWorldMatrix(), u = re.TransformNormal(
344
+ new re(c[0], c[1], c[2]),
345
345
  d
346
346
  ).normalize(), g = Re.FromPositionAndNormal(
347
347
  o.position,
@@ -350,7 +350,7 @@ class Ve {
350
350
  l.mirrorPlane = g, l.level = n, r.reflectionTexture = l;
351
351
  }
352
352
  function a(o) {
353
- const n = o.material, r = new Oe(
353
+ const n = o.material, r = new Ie(
354
354
  "probe-" + n.name,
355
355
  ze,
356
356
  e
@@ -372,7 +372,7 @@ class qe {
372
372
  }
373
373
  includeMeshes(e) {
374
374
  if (e) {
375
- this.glowLayer || (this.glowLayer = new Ie("glow", this.scene), this.glowLayer.intensity = this.intensity);
375
+ this.glowLayer || (this.glowLayer = new Oe("glow", this.scene), this.glowLayer.intensity = this.intensity);
376
376
  for (const t of e)
377
377
  this.glowLayer.hasMesh(t) || (this.glowLayer.addIncludedOnlyMesh(t), this.meshCount++);
378
378
  }
@@ -385,9 +385,9 @@ class qe {
385
385
  }
386
386
  }
387
387
  }
388
- const le = /* @__PURE__ */ new Map();
388
+ const he = /* @__PURE__ */ new Map();
389
389
  async function be(s, e, t) {
390
- const i = le.get(s);
390
+ const i = he.get(s);
391
391
  if (i && i.scene.uid === e.uid)
392
392
  return i;
393
393
  {
@@ -397,7 +397,7 @@ async function be(s, e, t) {
397
397
  e,
398
398
  t
399
399
  );
400
- return le.set(s, a), a;
400
+ return he.set(s, a), a;
401
401
  }
402
402
  }
403
403
  function He(s, e, t, i, a = "") {
@@ -406,7 +406,7 @@ function He(s, e, t, i, a = "") {
406
406
  s.filter((d) => d.name === a + r).forEach((d) => {
407
407
  const u = i.get(n), g = !1;
408
408
  if (u)
409
- he(d, u), u.update(g);
409
+ ce(d, u), u.update(g);
410
410
  else {
411
411
  const p = _e(
412
412
  r,
@@ -416,7 +416,7 @@ function He(s, e, t, i, a = "") {
416
416
  );
417
417
  i.set(n, p), o.setStaticContext(
418
418
  p.getContext()
419
- ), he(d, p), p.onLoadObservable.addOnce(() => {
419
+ ), ce(d, p), p.onLoadObservable.addOnce(() => {
420
420
  p.update(g);
421
421
  });
422
422
  }
@@ -434,8 +434,8 @@ function _e(s, e, t, i) {
434
434
  ), o = a.getContext();
435
435
  return o && (o.fillStyle = "#f5f5f5", o.fillRect(0, 0, t, i), a.update()), a;
436
436
  }
437
- function he(s, e) {
438
- if (s instanceof F) {
437
+ function ce(s, e) {
438
+ if (s instanceof B) {
439
439
  const t = s, i = t.albedoTexture;
440
440
  i ? (e.wrapU = i.wrapU, e.wrapV = i.wrapV) : (e.wrapU = 1, e.wrapV = 1), t.albedoTexture = e;
441
441
  } else {
@@ -447,8 +447,8 @@ function Ue() {
447
447
  const s = () => Math.floor((1 + Math.random()) * 65536).toString(16).substring(1);
448
448
  return s() + s() + "-" + s() + "-" + s() + "-" + s() + "-" + s() + s() + s();
449
449
  }
450
- const M = 60, ce = 1;
451
- function de(s) {
450
+ const M = 60, de = 1;
451
+ function ue(s) {
452
452
  return s.targetedAnimations.map((t) => t.animation.framePerSecond).reduce((t, i) => t + i, 0) / s.targetedAnimations.length || 0;
453
453
  }
454
454
  function Ke(s, e, t, i, a) {
@@ -460,15 +460,15 @@ function Ke(s, e, t, i, a) {
460
460
  if (i !== void 0 && t !== void 0 && i === t) {
461
461
  o.forEach((n) => {
462
462
  n.stop();
463
- const r = de(n), l = i * r;
464
- n.start(e, ce, l, l);
463
+ const r = ue(n), l = i * r;
464
+ n.start(e, de, l, l);
465
465
  });
466
466
  return;
467
467
  }
468
468
  o.forEach((n) => {
469
469
  n.stop();
470
- const r = de(n), l = i !== void 0 ? i * r : void 0, c = t !== void 0 ? t * r : void 0;
471
- n.start(e, ce, l, c);
470
+ const r = ue(n), l = i !== void 0 ? i * r : void 0, c = t !== void 0 ? t * r : void 0;
471
+ n.start(e, de, l, c);
472
472
  });
473
473
  }
474
474
  function ve(s) {
@@ -481,10 +481,10 @@ function We(s) {
481
481
  ve(e);
482
482
  }
483
483
  function Ye(s, e, t) {
484
- console.log("ANIM DEBUGGING: start of animate camera in scene"), s.stopAnimation(e), e.animations = [], Math.abs(e.alpha) > 2 * Math.PI && (e.alpha = Qe(e.alpha, 0, 2 * Math.PI));
484
+ console.log("ANIM DEBUGGING: start of animate camera in scene"), s.stopAnimation(e), e.animations = [], Math.abs(e.alpha) > 2 * Math.PI && (e.alpha = $e(e.alpha, 0, 2 * Math.PI));
485
485
  const i = [], a = t.target, o = 0, n = a ? 1 : 0;
486
- if (t.target && Object.keys(t.target).length > 0 && i.push(
487
- A(
486
+ if (t.target && Object.keys(t.target).length > 0 ? (i.push(
487
+ T(
488
488
  "cameraTargetLerp",
489
489
  "target",
490
490
  new m().copyFrom(e.target),
@@ -496,28 +496,28 @@ function Ye(s, e, t) {
496
496
  v.ANIMATIONTYPE_VECTOR3,
497
497
  o
498
498
  )
499
- ), i.push(
500
- A(
499
+ ), console.log(`ANIM DEBUGGING: target components (${t.target.x},${t.target.y},${t.target.z})`)) : console.log("ANIM DEBUGGING: target lacks components"), console.log(`ANIM DEBUGGING: alpha: ${E(t.lonDeg)}, beta: ${E(t.latDeg)}, r ${t.radius}`), i.push(
500
+ T(
501
501
  "cameraAlphaLerp",
502
502
  "alpha",
503
503
  e.alpha,
504
- ue(t.lonDeg),
504
+ E(t.lonDeg),
505
505
  v.ANIMATIONTYPE_FLOAT,
506
506
  n
507
507
  )
508
508
  ), i.push(
509
- A(
509
+ T(
510
510
  "cameraBetaLerp",
511
511
  "beta",
512
512
  e.beta,
513
- ue(t.latDeg),
513
+ E(t.latDeg),
514
514
  v.ANIMATIONTYPE_FLOAT,
515
515
  n
516
516
  )
517
517
  ), t.radius !== void 0) {
518
518
  const c = Math.max(0.01, t.radius);
519
519
  i.push(
520
- A(
520
+ T(
521
521
  "cameraRadiusLerp",
522
522
  "radius",
523
523
  e.radius,
@@ -540,10 +540,10 @@ function Ye(s, e, t) {
540
540
  }
541
541
  );
542
542
  }
543
- function ue(s) {
543
+ function E(s) {
544
544
  return s * Math.PI / 180;
545
545
  }
546
- function A(s, e, t, i, a, o = 0, n = v.ANIMATIONLOOPMODE_CONSTANT) {
546
+ function T(s, e, t, i, a, o = 0, n = v.ANIMATIONLOOPMODE_CONSTANT) {
547
547
  const r = new De();
548
548
  r.setEasingMode(Ge.EASINGMODE_EASEINOUT);
549
549
  const l = new v(
@@ -558,10 +558,10 @@ function A(s, e, t, i, a, o = 0, n = v.ANIMATIONLOOPMODE_CONSTANT) {
558
558
  value: i
559
559
  }), l.setKeys(c), l.setEasingFunction(r), l;
560
560
  }
561
- function Qe(s, e, t) {
561
+ function $e(s, e, t) {
562
562
  return s < e ? s = t - (e - s) % (t - e) : s = e + (s - e) % (t - e);
563
563
  }
564
- const Ze = {
564
+ const Qe = {
565
565
  albedoTexture: "albedoMap",
566
566
  bumpTexture: "normalMap",
567
567
  ambientTexture: "ambientMap",
@@ -571,7 +571,7 @@ const Ze = {
571
571
  refractionTexture: "refractionMap",
572
572
  reflectionTexture: "reflectionMap"
573
573
  };
574
- function $e(s, e, t, i) {
574
+ function Ze(s, e, t, i) {
575
575
  [
576
576
  "albedoTexture",
577
577
  "bumpTexture",
@@ -592,7 +592,7 @@ function $e(s, e, t, i) {
592
592
  }), et(s, e);
593
593
  }
594
594
  function je(s, e, t, i, a) {
595
- const o = Ze[s];
595
+ const o = Qe[s];
596
596
  if (!o)
597
597
  throw new Error("Unexpected texture name encountered.");
598
598
  const n = e[o], r = n == null ? void 0 : n.fileLink;
@@ -623,7 +623,7 @@ function Je(s, e, t, i) {
623
623
  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), e[s] = i, s === "emissiveTexture" && (e.emissiveColor = new w(1, 1, 1), e.emissiveIntensity = 1);
624
624
  }
625
625
  function et(s, e) {
626
- s.clearCoat && (s.clearCoat === S.RemoveWhenSelected ? (e.clearCoat.isEnabled = !1, e.clearCoat.indexOfRefraction = 1.5) : s.clearCoat === S.ApplyWhenSelected && (e.clearCoat.isEnabled = !0, e.clearCoat.indexOfRefraction = s.clearCoatIOR || e.clearCoat.indexOfRefraction));
626
+ s.clearCoat && (s.clearCoat === F.RemoveWhenSelected ? (e.clearCoat.isEnabled = !1, e.clearCoat.indexOfRefraction = 1.5) : s.clearCoat === F.ApplyWhenSelected && (e.clearCoat.isEnabled = !0, e.clearCoat.indexOfRefraction = s.clearCoatIOR || e.clearCoat.indexOfRefraction));
627
627
  }
628
628
  class tt {
629
629
  constructor(e, t, i) {
@@ -654,7 +654,7 @@ class tt {
654
654
  }
655
655
  const c = new Ne(this.scene);
656
656
  c.useDefaultLoadingScreen = !1, l.forEach(
657
- (d) => $e(
657
+ (d) => Ze(
658
658
  t,
659
659
  d,
660
660
  c,
@@ -982,15 +982,15 @@ class it {
982
982
  attachPickingHandler(e) {
983
983
  e.rootNodes.forEach((t) => {
984
984
  t.getChildMeshes(!1).forEach((i) => {
985
- i.name === "targetcube_t" || i.name === "backgroundShell" || (i.actionManager || (i.actionManager = new T(this.scene)), i.actionManager.registerAction(
986
- new re(T.OnPointerOverTrigger, (a) => {
985
+ i.name === "targetcube_t" || i.name === "backgroundShell" || (i.actionManager || (i.actionManager = new A(this.scene)), i.actionManager.registerAction(
986
+ new ae(A.OnPointerOverTrigger, (a) => {
987
987
  a.meshUnderPointer && i.material && this.materialSelectedObservable.notifyObservers({
988
988
  id: i.material.id,
989
989
  name: this.stripIdFromName(i.material.name)
990
990
  });
991
991
  })
992
992
  ), i.actionManager.registerAction(
993
- new re(T.OnPointerOutTrigger, () => {
993
+ new ae(A.OnPointerOutTrigger, () => {
994
994
  i.material && this.materialDeselectedObservable.notifyObservers({
995
995
  id: i.material.id,
996
996
  name: this.stripIdFromName(i.material.name)
@@ -1019,7 +1019,7 @@ class it {
1019
1019
  return this.modelReadyToLoadCallbacks.size;
1020
1020
  }
1021
1021
  configureGlowLayer() {
1022
- const e = (i) => i instanceof F && i.emissiveTexture !== null;
1022
+ const e = (i) => i instanceof B && i.emissiveTexture !== null;
1023
1023
  this.materials.some(e) || this.variantManager.getAllMaterials().some(e) ? this.previewService.getGlowLayerManager().includeMeshes(this.getAllMeshes()) : this.previewService.getGlowLayerManager().removeMeshes(this.getAllMeshes());
1024
1024
  }
1025
1025
  configureModelInstance(e) {
@@ -1111,7 +1111,7 @@ class it {
1111
1111
  }
1112
1112
  //#endregion
1113
1113
  }
1114
- class B extends ge {
1114
+ class D extends ge {
1115
1115
  constructor(e, t, i, a, o, n, r, l) {
1116
1116
  super(
1117
1117
  e,
@@ -1148,7 +1148,7 @@ class B extends ge {
1148
1148
  this.useFramingBehavior = !0;
1149
1149
  const e = this.getFramingBehavior();
1150
1150
  e.attach(this), e.framingTime = 0, e.elevationReturnTime = -1, e.zoomStopsAnimation = !1, this.lowerRadiusLimit = null;
1151
- const t = R(this._scene);
1151
+ const t = I(this._scene);
1152
1152
  return e.zoomOnBoundingInfo(t.min, t.max), this.wheelPrecision = 100 / this.radius, this.lowerRadiusLimit === null && (this.lowerRadiusLimit = 0.1), this.lastFocus.copyFrom(this.target), e;
1153
1153
  }
1154
1154
  /**
@@ -1161,7 +1161,7 @@ class B extends ge {
1161
1161
  i.framingTime = t || 800;
1162
1162
  const a = () => {
1163
1163
  e && e();
1164
- }, o = R(this._scene), n = o.max.subtract(o.min), r = o.min.add(n.scale(0.5));
1164
+ }, o = I(this._scene), n = o.max.subtract(o.min), r = o.min.add(n.scale(0.5));
1165
1165
  this.setRadius(n.length() * 1.5), this.wheelPrecision = 100 / this.radius, this.panningInertia = 0, this.panningOriginTarget.copyFrom(r), this.panDenominator = n.length(), i.zoomOnBoundingInfo(
1166
1166
  o.min,
1167
1167
  o.max,
@@ -1196,7 +1196,7 @@ class B extends ge {
1196
1196
  * @param assignActive If true the camera will be assigned as the active camera on the scene.
1197
1197
  */
1198
1198
  static create(e, t, i) {
1199
- const a = R(e), o = a.max.subtract(a.min), n = a.min.add(o.scale(0.5)), r = new B(
1199
+ const a = I(e), o = a.max.subtract(a.min), n = a.min.add(o.scale(0.5)), r = new D(
1200
1200
  "ProductCamera",
1201
1201
  -(Math.PI / 2),
1202
1202
  Math.PI / 2,
@@ -1210,7 +1210,7 @@ class B extends ge {
1210
1210
  }), i && (e.activeCamera = r), r;
1211
1211
  }
1212
1212
  }
1213
- function R(s) {
1213
+ function I(s) {
1214
1214
  if (s.meshes.length === 0)
1215
1215
  return {
1216
1216
  min: new m(-1, -1, -1),
@@ -1237,27 +1237,27 @@ class st {
1237
1237
  return this.currentConfiguration;
1238
1238
  }
1239
1239
  setConfiguration(e) {
1240
- var t, i, a, o, n, r, l, c, d, u, g, p, b, D, G, N, k, z, V, q, H, _, U, K, W, Y, Q, Z, $, j, X, J, ee;
1240
+ var t, i, a, o, n, r, l, c, d, u, g, p, b, G, N, k, z, V, q, H, _, U, K, W, Y, $, Q, Z, j, X, J, ee, te;
1241
1241
  if (this.renderingPipeline.isSupported) {
1242
- if (this.renderingPipeline.samples = ((t = e.antiAliasing) == null ? void 0 : t.samples) ?? h.antiAliasing.samples, this.renderingPipeline.fxaaEnabled = ((i = e.antiAliasing) == null ? void 0 : i.fxaaEnabled) ?? h.antiAliasing.fxaaEnabled, this.renderingPipeline.bloomEnabled = ((a = e.bloom) == null ? void 0 : a.enabled) ?? h.bloom.enabled, this.renderingPipeline.bloomKernel = ((o = e.bloom) == null ? void 0 : o.kernel) ?? h.bloom.kernel, this.renderingPipeline.bloomScale = ((n = e.bloom) == null ? void 0 : n.scale) ?? h.bloom.scale, this.renderingPipeline.bloomThreshold = ((r = e.bloom) == null ? void 0 : r.threshold) ?? h.bloom.threshold, this.renderingPipeline.bloomWeight = ((l = e.bloom) == null ? void 0 : l.weight) ?? h.bloom.weight, this.renderingPipeline.chromaticAberrationEnabled = ((c = e.chromaticAberration) == null ? void 0 : c.enabled) ?? h.chromaticAberration.enabled, this.renderingPipeline.chromaticAberration.aberrationAmount = ((d = e.chromaticAberration) == null ? void 0 : d.aberrationAmount) ?? h.chromaticAberration.aberrationAmount, this.renderingPipeline.chromaticAberration.radialIntensity = ((u = e.chromaticAberration) == null ? void 0 : u.radialIntensity) ?? h.chromaticAberration.radialIntensity, this.renderingPipeline.chromaticAberration.direction = (g = e.chromaticAberration) != null && g.direction ? new ie(
1242
+ if (this.renderingPipeline.samples = ((t = e.antiAliasing) == null ? void 0 : t.samples) ?? h.antiAliasing.samples, this.renderingPipeline.fxaaEnabled = ((i = e.antiAliasing) == null ? void 0 : i.fxaaEnabled) ?? h.antiAliasing.fxaaEnabled, this.renderingPipeline.bloomEnabled = ((a = e.bloom) == null ? void 0 : a.enabled) ?? h.bloom.enabled, this.renderingPipeline.bloomKernel = ((o = e.bloom) == null ? void 0 : o.kernel) ?? h.bloom.kernel, this.renderingPipeline.bloomScale = ((n = e.bloom) == null ? void 0 : n.scale) ?? h.bloom.scale, this.renderingPipeline.bloomThreshold = ((r = e.bloom) == null ? void 0 : r.threshold) ?? h.bloom.threshold, this.renderingPipeline.bloomWeight = ((l = e.bloom) == null ? void 0 : l.weight) ?? h.bloom.weight, this.renderingPipeline.chromaticAberrationEnabled = ((c = e.chromaticAberration) == null ? void 0 : c.enabled) ?? h.chromaticAberration.enabled, this.renderingPipeline.chromaticAberration.aberrationAmount = ((d = e.chromaticAberration) == null ? void 0 : d.aberrationAmount) ?? h.chromaticAberration.aberrationAmount, this.renderingPipeline.chromaticAberration.radialIntensity = ((u = e.chromaticAberration) == null ? void 0 : u.radialIntensity) ?? h.chromaticAberration.radialIntensity, this.renderingPipeline.chromaticAberration.direction = (g = e.chromaticAberration) != null && g.direction ? new se(
1243
1243
  e.chromaticAberration.direction.x,
1244
1244
  e.chromaticAberration.direction.y
1245
- ) : new ie(
1245
+ ) : new se(
1246
1246
  h.chromaticAberration.direction.x,
1247
1247
  h.chromaticAberration.direction.y
1248
- ), this.renderingPipeline.imageProcessing.colorCurvesEnabled = ((p = e.colorCurves) == null ? void 0 : p.enabled) ?? h.colorCurves.enabled, this.renderingPipeline.imageProcessing.colorCurves = e.colorCurves ? this.updateColorCurve(e.colorCurves) : new ae(), this.renderingPipeline.depthOfFieldEnabled = ((b = e.depthOfField) == null ? void 0 : b.enabled) ?? h.depthOfField.enabled, e.depthOfField)
1248
+ ), this.renderingPipeline.imageProcessing.colorCurvesEnabled = ((p = e.colorCurves) == null ? void 0 : p.enabled) ?? h.colorCurves.enabled, this.renderingPipeline.imageProcessing.colorCurves = e.colorCurves ? this.updateColorCurve(e.colorCurves) : new oe(), this.renderingPipeline.depthOfFieldEnabled = ((b = e.depthOfField) == null ? void 0 : b.enabled) ?? h.depthOfField.enabled, e.depthOfField)
1249
1249
  switch (e.depthOfField.blurLevel ?? h.depthOfField.blurLevel) {
1250
1250
  case "Low":
1251
- this.renderingPipeline.depthOfFieldBlurLevel = E.Low;
1251
+ this.renderingPipeline.depthOfFieldBlurLevel = R.Low;
1252
1252
  break;
1253
1253
  case "Medium":
1254
- this.renderingPipeline.depthOfFieldBlurLevel = E.Medium;
1254
+ this.renderingPipeline.depthOfFieldBlurLevel = R.Medium;
1255
1255
  break;
1256
1256
  case "High":
1257
- this.renderingPipeline.depthOfFieldBlurLevel = E.High;
1257
+ this.renderingPipeline.depthOfFieldBlurLevel = R.High;
1258
1258
  break;
1259
1259
  }
1260
- if (this.renderingPipeline.depthOfField.focalLength = ((D = e.depthOfField) == null ? void 0 : D.focalLength) ?? h.depthOfField.focalLength, this.renderingPipeline.depthOfField.fStop = ((G = e.depthOfField) == null ? void 0 : G.fStop) ?? h.depthOfField.fStop, this.renderingPipeline.depthOfField.focusDistance = ((N = e.depthOfField) == null ? void 0 : N.focusDistance) ?? h.depthOfField.focusDistance, this.renderingPipeline.depthOfField.lensSize = ((k = e.depthOfField) == null ? void 0 : k.lensSize) ?? h.depthOfField.lensSize, this.renderingPipeline.grainEnabled = ((z = e.grain) == null ? void 0 : z.enabled) ?? h.grain.enabled, this.renderingPipeline.grain.animated = ((V = e.grain) == null ? void 0 : V.animated) ?? h.grain.animated, this.renderingPipeline.grain.intensity = ((q = e.grain) == null ? void 0 : q.intensity) ?? h.grain.intensity, this.renderingPipeline.imageProcessing.contrast = ((H = e.misc) == null ? void 0 : H.contrast) ?? h.misc.contrast, this.renderingPipeline.imageProcessing.exposure = ((_ = e.misc) == null ? void 0 : _.exposure) ?? h.misc.exposure, this.renderingPipeline.imageProcessing.toneMappingEnabled = ((U = e.misc) == null ? void 0 : U.toneMappingEnabled) ?? h.misc.toneMappingEnabled, this.renderingPipeline.imageProcessing.toneMappingEnabled)
1260
+ if (this.renderingPipeline.depthOfField.focalLength = ((G = e.depthOfField) == null ? void 0 : G.focalLength) ?? h.depthOfField.focalLength, this.renderingPipeline.depthOfField.fStop = ((N = e.depthOfField) == null ? void 0 : N.fStop) ?? h.depthOfField.fStop, this.renderingPipeline.depthOfField.focusDistance = ((k = e.depthOfField) == null ? void 0 : k.focusDistance) ?? h.depthOfField.focusDistance, this.renderingPipeline.depthOfField.lensSize = ((z = e.depthOfField) == null ? void 0 : z.lensSize) ?? h.depthOfField.lensSize, this.renderingPipeline.grainEnabled = ((V = e.grain) == null ? void 0 : V.enabled) ?? h.grain.enabled, this.renderingPipeline.grain.animated = ((q = e.grain) == null ? void 0 : q.animated) ?? h.grain.animated, this.renderingPipeline.grain.intensity = ((H = e.grain) == null ? void 0 : H.intensity) ?? h.grain.intensity, this.renderingPipeline.imageProcessing.contrast = ((_ = e.misc) == null ? void 0 : _.contrast) ?? h.misc.contrast, this.renderingPipeline.imageProcessing.exposure = ((U = e.misc) == null ? void 0 : U.exposure) ?? h.misc.exposure, this.renderingPipeline.imageProcessing.toneMappingEnabled = ((K = e.misc) == null ? void 0 : K.toneMappingEnabled) ?? h.misc.toneMappingEnabled, this.renderingPipeline.imageProcessing.toneMappingEnabled)
1261
1261
  switch (e.misc.toneMappingType ?? h.misc.toneMappingType) {
1262
1262
  case "Standard":
1263
1263
  this.renderingPipeline.imageProcessing.toneMappingType = P.TONEMAPPING_STANDARD;
@@ -1266,8 +1266,8 @@ class st {
1266
1266
  this.renderingPipeline.imageProcessing.toneMappingType = P.TONEMAPPING_ACES;
1267
1267
  break;
1268
1268
  }
1269
- if (this.renderingPipeline.sharpenEnabled = ((K = e.sharpen) == null ? void 0 : K.enabled) ?? h.sharpen.enabled, this.renderingPipeline.sharpen.colorAmount = ((W = e.sharpen) == null ? void 0 : W.colorAmount) ?? h.sharpen.colorAmount, this.renderingPipeline.sharpen.edgeAmount = ((Y = e.sharpen) == null ? void 0 : Y.edgeAmount) ?? h.sharpen.edgeAmount, this.renderingPipeline.imageProcessing.vignetteEnabled = ((Q = e.vignette) == null ? void 0 : Q.enabled) ?? h.vignette.enabled, (Z = e.vignette) != null && Z.center ? (this.renderingPipeline.imageProcessing.vignetteCenterX = e.vignette.center.x, this.renderingPipeline.imageProcessing.vignetteCenterY = e.vignette.center.y) : (this.renderingPipeline.imageProcessing.vignetteCenterX = h.vignette.center.x, this.renderingPipeline.imageProcessing.vignetteCenterY = h.vignette.center.y), e.vignette)
1270
- switch ((($ = e.vignette) == null ? void 0 : $.blendMode) ?? h.vignette.blendMode) {
1269
+ if (this.renderingPipeline.sharpenEnabled = ((W = e.sharpen) == null ? void 0 : W.enabled) ?? h.sharpen.enabled, this.renderingPipeline.sharpen.colorAmount = ((Y = e.sharpen) == null ? void 0 : Y.colorAmount) ?? h.sharpen.colorAmount, this.renderingPipeline.sharpen.edgeAmount = (($ = e.sharpen) == null ? void 0 : $.edgeAmount) ?? h.sharpen.edgeAmount, this.renderingPipeline.imageProcessing.vignetteEnabled = ((Q = e.vignette) == null ? void 0 : Q.enabled) ?? h.vignette.enabled, (Z = e.vignette) != null && Z.center ? (this.renderingPipeline.imageProcessing.vignetteCenterX = e.vignette.center.x, this.renderingPipeline.imageProcessing.vignetteCenterY = e.vignette.center.y) : (this.renderingPipeline.imageProcessing.vignetteCenterX = h.vignette.center.x, this.renderingPipeline.imageProcessing.vignetteCenterY = h.vignette.center.y), e.vignette)
1270
+ switch (((j = e.vignette) == null ? void 0 : j.blendMode) ?? h.vignette.blendMode) {
1271
1271
  case "Multiply":
1272
1272
  this.renderingPipeline.imageProcessing.vignetteBlendMode = P.VIGNETTEMODE_MULTIPLY;
1273
1273
  break;
@@ -1275,25 +1275,25 @@ class st {
1275
1275
  this.renderingPipeline.imageProcessing.vignetteBlendMode = P.VIGNETTEMODE_OPAQUE;
1276
1276
  break;
1277
1277
  }
1278
- (j = e.vignette) != null && j.colorRgba ? this.renderingPipeline.imageProcessing.vignetteColor = new f(
1278
+ (X = e.vignette) != null && X.colorRgba ? this.renderingPipeline.imageProcessing.vignetteColor = new f(
1279
1279
  e.vignette.colorRgba.r,
1280
1280
  e.vignette.colorRgba.g,
1281
1281
  e.vignette.colorRgba.b,
1282
1282
  e.vignette.colorRgba.a
1283
- ) : (X = e.vignette) != null && X.colorHex ? this.renderingPipeline.imageProcessing.vignetteColor = f.FromHexString(e.vignette.colorHex) : this.renderingPipeline.imageProcessing.vignetteColor = new f(
1283
+ ) : (J = e.vignette) != null && J.colorHex ? this.renderingPipeline.imageProcessing.vignetteColor = f.FromHexString(e.vignette.colorHex) : this.renderingPipeline.imageProcessing.vignetteColor = new f(
1284
1284
  h.vignette.colorRgba.r,
1285
1285
  h.vignette.colorRgba.g,
1286
1286
  h.vignette.colorRgba.b,
1287
1287
  h.vignette.colorRgba.a
1288
- ), this.renderingPipeline.imageProcessing.vignetteStretch = ((J = e.vignette) == null ? void 0 : J.stretch) ?? h.vignette.stretch, this.renderingPipeline.imageProcessing.vignetteWeight = ((ee = e.vignette) == null ? void 0 : ee.weight) ?? h.vignette.weight, this.renderingPipeline.prepare(), this.currentConfiguration = e;
1288
+ ), this.renderingPipeline.imageProcessing.vignetteStretch = ((ee = e.vignette) == null ? void 0 : ee.stretch) ?? h.vignette.stretch, this.renderingPipeline.imageProcessing.vignetteWeight = ((te = e.vignette) == null ? void 0 : te.weight) ?? h.vignette.weight, this.renderingPipeline.prepare(), this.currentConfiguration = e;
1289
1289
  }
1290
1290
  }
1291
1291
  updateColorCurve(e) {
1292
- const t = new ae();
1292
+ const t = new oe();
1293
1293
  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;
1294
1294
  }
1295
1295
  }
1296
- Ae.GLTFLoader.RegisterExtension("glbPostProcessor", function(s) {
1296
+ Ee.GLTFLoader.RegisterExtension("glbPostProcessor", function(s) {
1297
1297
  return new Ve(s);
1298
1298
  });
1299
1299
  fe.OnPluginActivatedObservable.add((s) => {
@@ -1305,7 +1305,7 @@ fe.OnPluginActivatedObservable.add((s) => {
1305
1305
  function O(s) {
1306
1306
  return new m(s.x, s.y, s.z);
1307
1307
  }
1308
- function I(s) {
1308
+ function L(s) {
1309
1309
  return { x: s.x, y: s.y, z: s.z };
1310
1310
  }
1311
1311
  class Kt {
@@ -1315,7 +1315,7 @@ class Kt {
1315
1315
  this.engine.views && (this.modelContainers.forEach((c) => {
1316
1316
  c.updateDynamicTextures();
1317
1317
  }), this.scene.render(), !this.camera.target.equalsWithEpsilon(this.camera.lastFocus, 0.1) && !this.focusLostNotified && (this.focusLostObservable.notifyObservers(void 0), this.focusLostNotified = !0), this.screenshotPrepareResolve && (this.screenshotPrepareResolve(), this.screenshotPrepareResolve = void 0));
1318
- }, this.configuration = new oe(e);
1318
+ }, this.configuration = new le(e);
1319
1319
  const i = (() => {
1320
1320
  if (!(e != null && e.noRender))
1321
1321
  return this.configuration.createCanvas();
@@ -1336,12 +1336,12 @@ class Kt {
1336
1336
  stencil: this.configuration.highlights.enabled,
1337
1337
  forceSRGBBufferSupportState: !0
1338
1338
  }) : new Ce();
1339
- console.log = o, n.hideLoadingUI(), window.addEventListener("resize", this.fireResizeEvent.bind(this)), this.engine = n, this.scene = new Pe(n), this.scene.autoClear = !0, this.scene.autoClearDepthAndStencil = !0, this.camera = B.create(this.scene, this.configuration), this.scene.activeCamera = this.camera, this.renderingPipeline = new st(
1339
+ console.log = o, n.hideLoadingUI(), window.addEventListener("resize", this.fireResizeEvent.bind(this)), this.engine = n, this.scene = new Pe(n), this.scene.autoClear = !0, this.scene.autoClearDepthAndStencil = !0, this.camera = D.create(this.scene, this.configuration), this.scene.activeCamera = this.camera, this.renderingPipeline = new st(
1340
1340
  this.scene,
1341
1341
  !1,
1342
1342
  this.camera
1343
1343
  ), this.scene.clearColor = this.configuration.scene.clearColor;
1344
- const r = te.CreateFromPrefilteredData(
1344
+ const r = ie.CreateFromPrefilteredData(
1345
1345
  this.configuration.scene.environment.file,
1346
1346
  this.scene
1347
1347
  );
@@ -1384,7 +1384,7 @@ class Kt {
1384
1384
  }
1385
1385
  registerView(e) {
1386
1386
  const t = e.height, i = e.width;
1387
- this.engine.registerView(e, void 0, !0), e.setAttribute("height", t.toString()), e.setAttribute("width", i.toString()), this.orbitEnabled() || this.setCameraState(L.Pan), this.reattachControls(e);
1387
+ this.engine.registerView(e, void 0, !0), e.setAttribute("height", t.toString()), e.setAttribute("width", i.toString()), this.orbitEnabled() || this.setCameraState(S.Pan), this.reattachControls(e);
1388
1388
  }
1389
1389
  getNumViewports() {
1390
1390
  var e;
@@ -1433,7 +1433,7 @@ class Kt {
1433
1433
  throw new Error(
1434
1434
  "No views attached, camera state requires a view to attach controls onto."
1435
1435
  );
1436
- e === L.Orbit ? this.reattachControls(this.engine.views[0].target, 2) : this.reattachControls(this.engine.views[0].target, 0);
1436
+ e === S.Orbit ? this.reattachControls(this.engine.views[0].target, 2) : this.reattachControls(this.engine.views[0].target, 0);
1437
1437
  }
1438
1438
  animateToLastCameraFocus() {
1439
1439
  return new Promise((e) => {
@@ -1572,25 +1572,25 @@ class Kt {
1572
1572
  * Flips a transform around the origin.
1573
1573
  */
1574
1574
  flipTransform(e, t, i) {
1575
- const a = se.Compose(
1575
+ const a = ne.Compose(
1576
1576
  O(i || { x: 1, y: 1, z: 1 }),
1577
1577
  y.FromEulerVector(
1578
1578
  O(t || { x: 0, y: 0, z: 0 })
1579
1579
  ),
1580
1580
  O(e || { x: 0, y: 0, z: 0 })
1581
- ), o = se.RotationAxis(m.Up(), Math.PI), n = a.multiply(o), r = m.Zero(), l = y.Identity(), c = m.Zero();
1581
+ ), o = ne.RotationAxis(m.Up(), Math.PI), n = a.multiply(o), r = m.Zero(), l = y.Identity(), c = m.Zero();
1582
1582
  return n.decompose(c, l, r), l.multiplyInPlace(y.FromEulerAngles(0, Math.PI, 0)), {
1583
- position: I(r),
1584
- rotation: I(l.toEulerAngles()),
1585
- scale: I(c)
1583
+ position: L(r),
1584
+ rotation: L(l.toEulerAngles()),
1585
+ scale: L(c)
1586
1586
  };
1587
1587
  }
1588
1588
  updatePreviewOptions(e) {
1589
1589
  var a;
1590
- const t = new oe(e);
1590
+ const t = new le(e);
1591
1591
  this.configuration.highlights.enabled !== t.highlights.enabled && this.engine.setStencilBuffer(t.highlights.enabled), this.scene.clearColor = t.scene.clearColor;
1592
1592
  let i = this.scene.environmentTexture;
1593
- this.configuration.scene.environment.file !== t.scene.environment.file && (i = te.CreateFromPrefilteredData(
1593
+ this.configuration.scene.environment.file !== t.scene.environment.file && (i = ie.CreateFromPrefilteredData(
1594
1594
  t.scene.environment.file,
1595
1595
  this.scene
1596
1596
  ), i.rotationY = this.configuration.scene.environment.rotationY, this.scene.environmentTexture = i), i.rotationY = t.scene.environment.rotationY, this.scene.environmentIntensity = t.scene.environment.intensity, (a = t.options) != null && a.renderingPipelineConfiguration ? this.renderingPipeline.setConfiguration(
@@ -1612,8 +1612,8 @@ class Kt {
1612
1612
  }
1613
1613
  }
1614
1614
  export {
1615
- S as MaterialEffectMode,
1616
- L as ProductCameraRig,
1615
+ F as MaterialEffectMode,
1616
+ S as ProductCameraRig,
1617
1617
  ze as REFLECTION_PROBE_RESOLUTION,
1618
1618
  x as RenderingConfiguration,
1619
1619
  Kt as SpiffCommerce3DPreviewService,
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- (function(h,y){typeof exports=="object"&&typeof module<"u"?y(exports,require("@babylonjs/core/Cameras/arcRotateCamera"),require("@babylonjs/core/Engines/engine"),require("@babylonjs/core/Engines/nullEngine"),require("@babylonjs/core/Layers/highlightLayer"),require("@babylonjs/core/Loading/sceneLoader"),require("@babylonjs/core/Materials/Textures/cubeTexture"),require("@babylonjs/core/Maths/math.color"),require("@babylonjs/core/Maths/math.vector"),require("@babylonjs/core/Meshes/Compression/dracoCompression"),require("@babylonjs/core/Misc/observable"),require("@babylonjs/core/Misc/tools"),require("@babylonjs/core/scene"),require("@babylonjs/loaders/glTF"),require("@babylonjs/core/Materials/PBR/pbrMaterial"),require("@babylonjs/core/Materials/Textures/mirrorTexture"),require("@babylonjs/core/Maths/math"),require("@babylonjs/core/Probes/reflectionProbe"),require("@babylonjs/core/Layers/glowLayer"),require("@babylonjs/core/Actions/actionManager"),require("@babylonjs/core/Actions/directActions"),require("@babylonjs/core/Meshes/mesh"),require("@babylonjs/core/Meshes/transformNode"),require("@babylonjs/core/Materials/Textures/dynamicTexture"),require("@babylonjs/core/Materials/Textures/texture"),require("@babylonjs/core/Animations/animation"),require("@babylonjs/core/Animations/easing"),require("@babylonjs/core/Misc/assetsManager"),require("@babylonjs/core/Materials/colorCurves"),require("@babylonjs/core/Materials/imageProcessingConfiguration"),require("@babylonjs/core/PostProcesses/RenderPipeline"),require("@babylonjs/core/PostProcesses/depthOfFieldEffect"),require("@babylonjs/core/Rendering/depthRendererSceneComponent"),require("@babylonjs/core/Engines/Extensions/engine.views"),require("@babylonjs/core/Meshes/instancedMesh"),require("@babylonjs/core/Materials/Textures/Loaders/ddsTextureLoader"),require("@babylonjs/core/Materials/Textures/Loaders/envTextureLoader"),require("@babylonjs/core/Materials/Textures/Loaders/ktxTextureLoader"),require("@babylonjs/core/Animations/animatable"),require("@babylonjs/core/Misc/screenshotTools"),require("@babylonjs/core/Rendering/boundingBoxRenderer"),require("@babylonjs/loaders/glTF/2.0/Extensions")):typeof define=="function"&&define.amd?define(["exports","@babylonjs/core/Cameras/arcRotateCamera","@babylonjs/core/Engines/engine","@babylonjs/core/Engines/nullEngine","@babylonjs/core/Layers/highlightLayer","@babylonjs/core/Loading/sceneLoader","@babylonjs/core/Materials/Textures/cubeTexture","@babylonjs/core/Maths/math.color","@babylonjs/core/Maths/math.vector","@babylonjs/core/Meshes/Compression/dracoCompression","@babylonjs/core/Misc/observable","@babylonjs/core/Misc/tools","@babylonjs/core/scene","@babylonjs/loaders/glTF","@babylonjs/core/Materials/PBR/pbrMaterial","@babylonjs/core/Materials/Textures/mirrorTexture","@babylonjs/core/Maths/math","@babylonjs/core/Probes/reflectionProbe","@babylonjs/core/Layers/glowLayer","@babylonjs/core/Actions/actionManager","@babylonjs/core/Actions/directActions","@babylonjs/core/Meshes/mesh","@babylonjs/core/Meshes/transformNode","@babylonjs/core/Materials/Textures/dynamicTexture","@babylonjs/core/Materials/Textures/texture","@babylonjs/core/Animations/animation","@babylonjs/core/Animations/easing","@babylonjs/core/Misc/assetsManager","@babylonjs/core/Materials/colorCurves","@babylonjs/core/Materials/imageProcessingConfiguration","@babylonjs/core/PostProcesses/RenderPipeline","@babylonjs/core/PostProcesses/depthOfFieldEffect","@babylonjs/core/Rendering/depthRendererSceneComponent","@babylonjs/core/Engines/Extensions/engine.views","@babylonjs/core/Meshes/instancedMesh","@babylonjs/core/Materials/Textures/Loaders/ddsTextureLoader","@babylonjs/core/Materials/Textures/Loaders/envTextureLoader","@babylonjs/core/Materials/Textures/Loaders/ktxTextureLoader","@babylonjs/core/Animations/animatable","@babylonjs/core/Misc/screenshotTools","@babylonjs/core/Rendering/boundingBoxRenderer","@babylonjs/loaders/glTF/2.0/Extensions"],y):(h=typeof globalThis<"u"?globalThis:h||self,y(h.Preview={},h.arcRotateCamera,h.engine,h.nullEngine,h.highlightLayer,h.sceneLoader,h.cubeTexture,h.math_color,h.math_vector,h.dracoCompression,h.observable,h.tools,h.scene,h.glTF,h.pbrMaterial,h.mirrorTexture,h.math,h.reflectionProbe,h.glowLayer,h.actionManager,h.directActions,h.mesh,h.transformNode,h.dynamicTexture,h.texture,h.animation,h.easing,h.assetsManager,h.colorCurves,h.imageProcessingConfiguration,h.RenderPipeline,h.depthOfFieldEffect))})(this,function(h,y,D,we,ve,q,V,p,g,Ce,M,Me,xe,Pe,L,Te,P,Ae,Ee,O,G,Re,Le,Oe,Ie,w,N,Se,k,T,Fe,I){"use strict";var A=(s=>(s[s.Orbit=0]="Orbit",s[s.Pan=1]="Pan",s))(A||{}),E=(s=>(s.None="None",s.RemoveWhenSelected="RemoveWhenSelected",s.ApplyWhenSelected="ApplyWhenSelected",s))(E||{});class z{constructor(e){this.getSceneClearColor=()=>{var i,a,o,n;const t=(i=this.customOptions)!=null&&i.transparentBackground||(a=this.customOptions)!=null&&a.backgroundImage?0:1;if(this.customOptions&&((o=this.customOptions)!=null&&o.transparentBackground)||(n=this.customOptions)!=null&&n.backgroundImage)return new p.Color4(0,0,0,t).toLinearSpace();if(this.customOptions&&this.customOptions.backgroundColor){const r=p.Color3.FromHexString(this.customOptions.backgroundColor);return new p.Color4(r.r,r.g,r.b,t).toLinearSpace()}return new p.Color4(.98,.98,.98,t).toLinearSpace()},this.highlightColorFromConfig=()=>this.customOptions&&this.customOptions.highlightColor?this.hexToColor4(this.customOptions.highlightColor):new p.Color4(.98,.98,.98,1).toLinearSpace(),this.hexToColor4=(t,i=1)=>{const a=p.Color3.FromHexString(t);return new p.Color4(a.r,a.g,a.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,a,o;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:((a=this.customOptions)==null?void 0:a.environmentIntensity)??1,rotationY:(((o=this.customOptions)==null?void 0:o.environmentRotationY)??0)*(Math.PI/180)}}}get camera(){var e,t,i,a,o,n,r,l,d,u,m,f,b;return{autoOrientation:((e=this.customOptions)==null?void 0:e.disableAutomaticOrientation)??!0,autoRotation:{enabled:((t=this.customOptions)==null?void 0:t.autoRotation)??!1,idleTimeMs:((i=this.customOptions)==null?void 0:i.idleTimeBeforeRotation)??5e3},limits:{min:{alpha:(a=this.customOptions)!=null&&a.lowerAlphaLimitDeg?((o=this.customOptions)==null?void 0:o.lowerAlphaLimitDeg)*Math.PI/180:void 0,beta:(n=this.customOptions)!=null&&n.lowerBetaLimitDeg?((r=this.customOptions)==null?void 0:r.lowerBetaLimitDeg)*Math.PI/180:void 0,radius:(l=this.customOptions)==null?void 0:l.minZoomOverride},max:{alpha:(d=this.customOptions)!=null&&d.upperAlphaLimitDeg?((u=this.customOptions)==null?void 0:u.upperAlphaLimitDeg)*Math.PI/180:void 0,beta:(m=this.customOptions)!=null&&m.upperBetaLimitDeg?((f=this.customOptions)==null?void 0:f.upperBetaLimitDeg)*Math.PI/180:void 0,radius:(b=this.customOptions)==null?void 0:b.maxZoomOverride}}}}get highlights(){var e;return{enabled:((e=this.customOptions)==null?void 0:e.highlightOnMaterialHover)??!1,color:this.highlightColorFromConfig()}}get lighting(){var e,t,i,a;return{exposure:((t=(e=this.customOptions)==null?void 0:e.lighting)==null?void 0:t.exposure)??.9,contrast:((a=(i=this.customOptions)==null?void 0:i.lighting)==null?void 0:a.contrast)??1.6}}get emissiveGlowIntensity(){var e;return((e=this.customOptions)==null?void 0:e.emissiveGlowIntensity)??.5}}class v{static getDynamicTextureResolution(){return this.getIsMobile()||!v.offscreenRenderingSupported()?{width:1024,height:1024}:{width:2048,height:2048}}static shouldMipMap(){return!0}static offscreenRenderingSupported(){return navigator.userAgent.includes("SamsungBrowser")?!1:!!window.Worker&&!!window.OffscreenCanvas}static getMirrorTextureResolution(){return this.getIsMobile()?512:1024}static getIsMobile(){try{return typeof window>"u"||!window.navigator?!1:/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(window.navigator.userAgent)||window.innerWidth<=480}catch{return!1}}}const H=128,c={antiAliasing:{samples:4,fxaaEnabled:!1},bloom:{enabled:!1,kernel:64,scale:.5,threshold:.9,weight:.15},chromaticAberration:{enabled:!1,aberrationAmount:30,direction:{x:0,y:0},radialIntensity:0},colorCurves:{enabled:!1},depthOfField:{enabled:!1,blurLevel:"Low",focalLength:50,focusDistance:2e3,fStop:1.4,lensSize:50},grain:{enabled:!1,animated:!1,intensity:30},misc:{contrast:1,exposure:1,toneMappingEnabled:!1,toneMappingType:"Standard"},sharpen:{enabled:!1,colorAmount:1,edgeAmount:.3},vignette:{enabled:!1,blendMode:"Multiply",cameraFov:.5,center:{x:0,y:0},colorHex:"#000000ff",colorRgba:{r:0,g:0,b:0,a:1},stretch:0,weight:1}};class Be{constructor(e){this.name="glbPostProcessor",this.enabled=!0,this.loader=e}onReady(){this.applyReflections(this.loader.babylonScene)}loadNodeAsync(e,t,i){return this.loader.loadNodeAsync(e,t,function(a){t.extras&&Object.keys(t.extras).forEach(o=>{const n=t.extras[o];a.metadata[o]=n}),i(a)})}async loadMaterialPropertiesAsync(e,t,i){await this.loader.loadMaterialPropertiesAsync(e,t,i),this.enableMaterialExtrasIfRequired(t,i),i.needDepthPrePass=!0}dispose(){}enableMaterialExtrasIfRequired(e,t){if(!(!e.extras||!(t instanceof L.PBRMaterial))){if(e.extras.sheen){const i=t;i.sheen.isEnabled=!0,i.sheen.intensity=e.extras.sheen}if(e.extras.translucency){const i=t;i.subSurface.isTranslucencyEnabled=!0,i.subSurface.translucencyIntensity=e.extras.translucency,e.extras.translucencyR&&e.extras.translucencyG&&e.extras.translucencyB&&(i.subSurface.tintColor=new P.Color3(e.extras.translucencyR,e.extras.translucencyG,e.extras.translucencyB))}if(e.extras.refractionIOR){const i=t;i.subSurface.isRefractionEnabled=!0,i.subSurface.volumeIndexOfRefraction=e.extras.refractionIOR}if(e.extras.useDepthPrePass){const i=t;i.needDepthPrePass=!0,i.forceIrradianceInFragment=!0}if(e.extras.useParallax){const i=t;i.useParallax=!0,i.useParallaxOcclusion=!0,i.parallaxScaleBias=e.extras.useParallax}}}applyReflections(e){function t(o){const n=[];return o.transformNodes.forEach(r=>{r.metadata&&r.metadata.reflective&&n.push(...r.getChildMeshes())}),o.meshes.forEach(r=>{r.metadata&&r.metadata.reflective&&!n.includes(r)&&n.push(r)}),n}function i(o,n=1){const r=o.material;if(!r)return;const l=new Te.MirrorTexture("mirror",v.getMirrorTextureResolution(),e,!0);l.renderList=t(e);const d=o.getVerticesData("normal");if(!d)throw new Error("Mirror attribute specified on: "+o.name+"But no normals exist to generate a mirror from!");o.computeWorldMatrix(!0);const u=o.getWorldMatrix(),m=P.Vector3.TransformNormal(new P.Vector3(d[0],d[1],d[2]),u).normalize(),f=P.Plane.FromPositionAndNormal(o.position,m.scale(-1));l.mirrorPlane=f,l.level=n,r.reflectionTexture=l}function a(o){const n=o.material,r=new Ae.ReflectionProbe("probe-"+n.name,H,e);r.attachToMesh(o),r.renderList&&r.renderList.push(...t(e)),n.reflectionTexture=r.cubeTexture}e.meshes.forEach(o=>{const n=o.metadata;n&&(n.mirrorTexture&&i(o,n.mirrorTexture),n.reflectionProbe&&a(o))})}}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 Ee.GlowLayer("glow",this.scene),this.glowLayer.intensity=this.intensity);for(const t of e)this.glowLayer.hasMesh(t)||(this.glowLayer.addIncludedOnlyMesh(t),this.meshCount++)}}removeMeshes(e){if(!(!this.glowLayer||!e)){for(const t of e)this.glowLayer.hasMesh(t)&&(this.glowLayer.removeIncludedOnlyMesh(t),this.meshCount--);this.meshCount===0&&(this.glowLayer.dispose(),this.glowLayer=void 0)}}}const U=new Map;async function K(s,e,t){const i=U.get(s);if(i&&i.scene.uid===e.uid)return i;{const a=await q.SceneLoader.LoadAssetContainerAsync(s,void 0,e,t);return U.set(s,a),a}}function De(s,e,t,i,a=""){t.forEach(o=>{const n=o.getID(),r=o.getName(),l=v.getDynamicTextureResolution();s.filter(u=>u.name===a+r).forEach(u=>{const m=i.get(n),f=!1;if(m)W(u,m),m.update(f);else{const b=qe(r,e,l.width,l.height);i.set(n,b),o.setStaticContext(b.getContext()),W(u,b),b.onLoadObservable.addOnce(()=>{b.update(f)})}})})}function qe(s,e,t,i){const a=new Oe.DynamicTexture(s,{width:t,height:i},e,v.shouldMipMap(),Ie.Texture.TRILINEAR_SAMPLINGMODE,D.Engine.TEXTUREFORMAT_RGBA),o=a.getContext();return o&&(o.fillStyle="#f5f5f5",o.fillRect(0,0,t,i),a.update()),a}function W(s,e){if(s instanceof L.PBRMaterial){const t=s,i=t.albedoTexture;i?(e.wrapU=i.wrapU,e.wrapV=i.wrapV):(e.wrapU=1,e.wrapV=1),t.albedoTexture=e}else{const t=s,i=t.diffuseTexture;i&&(e.wrapU=i.wrapU,e.wrapV=i.wrapV),t.diffuseTexture=e}}function Ve(){const s=()=>Math.floor((1+Math.random())*65536).toString(16).substring(1);return s()+s()+"-"+s()+"-"+s()+"-"+s()+"-"+s()+s()+s()}const x=60,Q=1;function Y(s){return s.targetedAnimations.map(t=>t.animation.framePerSecond).reduce((t,i)=>t+i,0)/s.targetedAnimations.length||0}function Ge(s,e,t,i,a){const o=a?s.filter(n=>n.name===a):s;if(o.length===0){console.warn(`No animations found for name: ${a}`);return}if(i!==void 0&&t!==void 0&&i===t){o.forEach(n=>{n.stop();const r=Y(n),l=i*r;n.start(e,Q,l,l)});return}o.forEach(n=>{n.stop();const r=Y(n),l=i!==void 0?i*r:void 0,d=t!==void 0?t*r:void 0;n.start(e,Q,l,d)})}function Z(s){s.forEach(e=>{e.stop()})}function Ne(s){const e=s.animationGroups;Z(e)}function ke(s,e,t){console.log("ANIM DEBUGGING: start of animate camera in scene"),s.stopAnimation(e),e.animations=[],Math.abs(e.alpha)>2*Math.PI&&(e.alpha=ze(e.alpha,0,2*Math.PI));const i=[],a=t.target,o=0,n=a?1:0;if(t.target&&Object.keys(t.target).length>0&&i.push(R("cameraTargetLerp","target",new g.Vector3().copyFrom(e.target),new g.Vector3(t.target.x,t.target.y,t.target.z),w.Animation.ANIMATIONTYPE_VECTOR3,o)),i.push(R("cameraAlphaLerp","alpha",e.alpha,$(t.lonDeg),w.Animation.ANIMATIONTYPE_FLOAT,n)),i.push(R("cameraBetaLerp","beta",e.beta,$(t.latDeg),w.Animation.ANIMATIONTYPE_FLOAT,n)),t.radius!==void 0){const d=Math.max(.01,t.radius);i.push(R("cameraRadiusLerp","radius",e.radius,d,w.Animation.ANIMATIONTYPE_FLOAT,n))}e.animations.push(...i);const l=e.useAutoRotationBehavior;e.disableAutoRotationBehavior(),console.log(`ANIM DEBUGGING: animSet has ${i.length} animations`),s.beginAnimation(e,0,a?x*2:x,!1,1,()=>{e.animations=[],l&&e.enableAutoRotationBehavior()})}function $(s){return s*Math.PI/180}function R(s,e,t,i,a,o=0,n=w.Animation.ANIMATIONLOOPMODE_CONSTANT){const r=new N.QuadraticEase;r.setEasingMode(N.EasingFunction.EASINGMODE_EASEINOUT);const l=new w.Animation(s,e,x,a,n),d=[];return o>0&&d.push({frame:0,value:t}),d.push({frame:x*o,value:t}),d.push({frame:x*(o+1),value:i}),l.setKeys(d),l.setEasingFunction(r),l}function ze(s,e,t){return s<e?s=t-(e-s)%(t-e):s=e+(s-e)%(t-e)}const He={albedoTexture:"albedoMap",bumpTexture:"normalMap",ambientTexture:"ambientMap",emissiveTexture:"emissionMap",opacityTexture:"alphaMap",metallicTexture:"metallicMap",refractionTexture:"refractionMap",reflectionTexture:"reflectionMap"};function Ue(s,e,t,i){["albedoTexture","bumpTexture","ambientTexture","emissiveTexture","opacityTexture","metallicTexture","refractionTexture","reflectionTexture"].forEach(o=>{Ke(o,s,e,t,i)}),Ye(s,e)}function Ke(s,e,t,i,a){const o=He[s];if(!o)throw new Error("Unexpected texture name encountered.");const n=e[o],r=n==null?void 0:n.fileLink;r?s==="reflectionTexture"?r.endsWith(".env")||r.endsWith(".dds")?i.addCubeTextureTask(s,r,void 0,!1,void 0,!0):r.endsWith(".hdr")?i.addHDRCubeTextureTask(s,r,128,!1,!0,!1):i.addTextureTask(s,r,!1,!1):i.addTextureTask(s,r,!1,!1):a&&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 p.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),e[s]=i,s==="emissiveTexture"&&(e.emissiveColor=new p.Color3(1,1,1),e.emissiveIntensity=1)}function Ye(s,e){s.clearCoat&&(s.clearCoat===E.RemoveWhenSelected?(e.clearCoat.isEnabled=!1,e.clearCoat.indexOfRefraction=1.5):s.clearCoat===E.ApplyWhenSelected&&(e.clearCoat.isEnabled=!0,e.clearCoat.indexOfRefraction=s.clearCoatIOR||e.clearCoat.indexOfRefraction))}class Ze{constructor(e,t,i){this.materialVariantMap=new Map,this.keysThatRemovedBaseModel=[],this.loadedContainerForKey=new Map,this.loadedMaterialsForKey=new Map,this.scene=e,this.renameClonedAsset=t,this.setBaseModelEnabled=i}async applyMaterial(e,t,i,a){return new Promise(o=>{const n=this.materialVariantMap.get(e);this.materialVariantMap.set(e,{...n,...t});const r=this.renameClonedAsset(e),l=this.scene.materials.filter(u=>u.name===r);if(l.length===0){o();return}const d=new Se.AssetsManager(this.scene);d.useDefaultLoadingScreen=!1,l.forEach(u=>Ue(t,u,d,a)),d.onProgress=(u,m,f)=>{i&&i(u/m*100,100,f.name)},d.onFinish=u=>{u.forEach(m=>{const f=m;i&&i(100,100,m.name),this.scene.materials.filter(C=>C.name===r).forEach(C=>Qe(m.name,C,t,f.texture))}),o()},d.loadAsync()})}async applyModel(e,t,i,a){var l,d;if(i&&t&&!this.keysThatRemovedBaseModel.includes(e)&&this.keysThatRemovedBaseModel.push(e),!i)return this.keysThatRemovedBaseModel.includes(e)&&this.keysThatRemovedBaseModel.length===1&&await this.setBaseModelEnabled(!0),(l=this.loadedContainerForKey.get(e))==null||l.dispose(),this.loadedContainerForKey.delete(e),this.loadedMaterialsForKey.delete(e),this.keysThatRemovedBaseModel=this.keysThatRemovedBaseModel.filter(u=>u!==e),Promise.resolve(void 0);const n=(await K(i,this.scene,a)).instantiateModelsToScene(this.renameClonedAsset,!0);this.loadedContainerForKey.has(e)&&((d=this.loadedContainerForKey.get(e))==null||d.dispose(),this.loadedContainerForKey.delete(e),this.loadedMaterialsForKey.delete(e)),t&&await this.setBaseModelEnabled(!1),this.loadedContainerForKey.set(e,n),this.loadedMaterialsForKey.set(e,X(n));const r=[];return this.materialVariantMap.forEach(async(u,m)=>{r.push(this.applyMaterial(m,u))}),await Promise.all(r),n}dispose(){this.loadedContainerForKey.forEach(e=>e==null?void 0:e.dispose()),this.loadedContainerForKey.clear(),this.loadedMaterialsForKey.forEach(e=>e.forEach(t=>t==null?void 0:t.dispose())),this.loadedMaterialsForKey.clear(),this.materialVariantMap.clear(),this.keysThatRemovedBaseModel=[]}getAllMaterials(){const e=[];return this.loadedMaterialsForKey.forEach(t=>{t.forEach(i=>{e.includes(i)||e.push(i)})}),e}getAnimationGroups(){const e=[];return this.loadedContainerForKey.forEach(t=>{e.push(...t.animationGroups)}),e}}function X(s){const e=[];return s.rootNodes.forEach(t=>{t.getChildMeshes().forEach(i=>{i.material&&!e.includes(i.material)&&e.push(i.material),i.subMeshes&&i.subMeshes.forEach(a=>{const o=a.getMaterial(!1);o&&!e.includes(o)&&e.push(o)})})}),e}function J(s,e=""){return s.map(t=>({name:t.name.substring(e.length),loop:t.loopAnimation,to:t.to,from:t.from}))}class $e{constructor(e){this.metadata=new Map,this.materialSelectedObservable=new M.Observable,this.materialDeselectedObservable=new M.Observable,this.materialVariantObservable=new M.Observable,this.modelVariantObservable=new M.Observable,this.materialReadyToLoadCallbacks=new Map,this.modelReadyToLoadCallbacks=new Map,this.dynamicTextures=new Map,this.queuedMaterialChanges=new Map,this.materialChangesInProgress=[],this.queuedModelChanges=new Map,this.modelChangesInProgress=[],this.animations=[],this.initialized=!1,this.materials=[];const{enablePicking:t,modelDetails:i,previewService:a,progressHandler:o,scene:n}=e;this.enablePicking=t,this.contextService=i.contextService,this.id=Ve(),this.previewService=a,this.scene=n,this.variantManager=new Ze(n,this.renameClonedAsset.bind(this),this.setBaseModelEnabled.bind(this)),this.transformRoot=new Le.TransformNode("root",this.scene);const r=async()=>{if(!i.model)throw new Error("Model container constructed with no URL. This is currently unsupported.");return this.assetContainer=await K(i.model,n,o),this.initialized=!0,await this.instantiate(),this};this.importPromise=r()}async applyMaterialVariant(e,t,i,a){if(!this.initialized){if(this.materialReadyToLoadCallbacks.has(e)){const n=this.materialReadyToLoadCallbacks.get(e);n==null||n.set(t,this.applyMaterialVariant.bind(this,e,t,i,a))}else{this.materialReadyToLoadCallbacks.set(e,new Map);const n=this.materialReadyToLoadCallbacks.get(e);n==null||n.set(t,this.applyMaterialVariant.bind(this,e,t,i,a))}return}const o=async()=>{await this.variantManager.applyMaterial(e,i,(n,r,l)=>{this.materialVariantObservable.notifyObservers({remainingCount:n,totalCount:r,taskName:l})},a)};if(this.materialChangesInProgress.includes(e)){if(this.queuedMaterialChanges.has(e)){const n=this.queuedMaterialChanges.get(e);n==null||n.set(t,o)}else{this.queuedMaterialChanges.set(e,new Map);const n=this.queuedMaterialChanges.get(e);n==null||n.set(t,o)}return}if(this.materialChangesInProgress.push(e),await o(),this.queuedMaterialChanges.has(e)){const n=this.queuedMaterialChanges.get(e);if(!n)throw new Error("Target material is undefined");n.forEach(async r=>{await r()}),this.queuedMaterialChanges.delete(e)}this.materialChangesInProgress.splice(this.materialChangesInProgress.indexOf(e),1),this.configureGlowLayer()}async applyModelVariant(e,t,i){if(!this.initialized){this.modelReadyToLoadCallbacks.set(e,this.applyModelVariant.bind(this,e,t,i));return}const a=()=>this.variantManager.applyModel(e,i,t==null?void 0:t.model,r=>{this.modelVariantObservable.notifyObservers({...r,key:e})});if(this.modelChangesInProgress.includes(e)){this.queuedModelChanges.set(e,a);return}const n=await(async()=>{this.modelChangesInProgress.push(e);let r=await a();if(this.queuedModelChanges.has(e)){const l=this.queuedModelChanges.get(e);if(!l)throw new Error("Queued change resolved undefined");r=await l(),this.queuedModelChanges.delete(e)}return this.modelChangesInProgress.splice(this.modelChangesInProgress.indexOf(e),1),r})();this.modelInstance&&Z(this.modelInstance.animationGroups),this.contextService||(this.contextService=t==null?void 0:t.contextService),n?this.configureModelInstance(n):this.configureGlowLayer()}dispose(){var e;this.destroyInstance(),this.variantManager.dispose(),this.dynamicTextures.forEach(t=>t==null?void 0:t.dispose()),this.dynamicTextures.clear(),this.materials.forEach(t=>t&&(t==null?void 0:t.dispose())),this.materials=[],(e=this.transformRoot)==null||e.dispose(),this.transformRoot=void 0,this.previewService.modelUnloaded(this)}executeAnimation(e){if(!this.previewService.getInitializationComplete()){this.queuedModelAnimation=e;return}this.modelInstance&&Ge([...this.modelInstance.animationGroups,...this.variantManager.getAnimationGroups()],e.loop,e.to,e.from,e.name?this.renameClonedAsset(e.name):void 0)}getAnimations(e){return[...this.animations,...e?J(this.variantManager.getAnimationGroups(),this.renameClonedAsset("")):[]]}getId(){return this.id}listMaterials(){var t;const e=(t=this.scene)==null?void 0:t.materials.filter(i=>i.name.startsWith(this.id));return e?e.map(i=>({id:i.id,name:this.stripIdFromName(i.name)})):[]}registerMaterialSelectedCallback(e){this.materialSelectedObservable.add(e)}unregisterMaterialSelectedCallback(e){this.materialSelectedObservable.removeCallback(e)}registerMaterialDeselectedCallback(e){this.materialDeselectedObservable.add(e)}unregisterMaterialDeselectedCallback(e){this.materialDeselectedObservable.removeCallback(e)}get position(){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to requesting position!");return this.transformRoot.position}set position(e){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to setting position!");this.transformRoot.position=new g.Vector3(e.x,e.y,e.z)}get rotation(){var e;if(!((e=this.transformRoot)!=null&&e.rotationQuaternion))throw new Error("ModelContainer disposed prior to requesting rotation!");return this.transformRoot.rotationQuaternion.toEulerAngles()}set rotation(e){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to setting rotation!");this.transformRoot.rotationQuaternion=g.Quaternion.FromEulerAngles(e.x,e.y,e.z)}get scale(){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to requesting scale!");return this.transformRoot.scaling}set scale(e){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to setting scale!");this.transformRoot.scaling=new g.Vector3(e.x,e.y,e.z)}attachPickingHandler(e){e.rootNodes.forEach(t=>{t.getChildMeshes(!1).forEach(i=>{i.name==="targetcube_t"||i.name==="backgroundShell"||(i.actionManager||(i.actionManager=new O.ActionManager(this.scene)),i.actionManager.registerAction(new G.ExecuteCodeAction(O.ActionManager.OnPointerOverTrigger,a=>{a.meshUnderPointer&&i.material&&this.materialSelectedObservable.notifyObservers({id:i.material.id,name:this.stripIdFromName(i.material.name)})})),i.actionManager.registerAction(new G.ExecuteCodeAction(O.ActionManager.OnPointerOutTrigger,()=>{i.material&&this.materialDeselectedObservable.notifyObservers({id:i.material.id,name:this.stripIdFromName(i.material.name)})})))})})}getInitializationPromise(){return this.importPromise}getIsInitialized(){return this.initialized}getQueuedMaterialVariantCount(){return this.materialReadyToLoadCallbacks.size}getQueuedModelVariantCount(){return this.modelReadyToLoadCallbacks.size}configureGlowLayer(){const e=i=>i instanceof L.PBRMaterial&&i.emissiveTexture!==null;this.materials.some(e)||this.variantManager.getAllMaterials().some(e)?this.previewService.getGlowLayerManager().includeMeshes(this.getAllMeshes()):this.previewService.getGlowLayerManager().removeMeshes(this.getAllMeshes())}configureModelInstance(e){var o;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,a=this.transformRoot.scaling;this.transformRoot.position=g.Vector3.Zero(),this.transformRoot.rotationQuaternion=g.Quaternion.Identity(),this.transformRoot.scaling=g.Vector3.One();for(const n of e.rootNodes)n.parent=this.transformRoot;this.transformRoot.position=t,this.transformRoot.rotationQuaternion=i,this.transformRoot.scaling=a,this.canvasPanels=((o=this.contextService)==null?void 0:o.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 Re.Mesh)).flat()}async instantiate(){if(!this.assetContainer)throw new Error("Attempted to instantiate ModelContainer without an AssetContainer");this.modelInstance=this.assetContainer.instantiateModelsToScene(this.renameClonedAsset.bind(this),!0),this.materials=X(this.modelInstance),this.configureModelInstance(this.modelInstance),this.animations=J(this.modelInstance.animationGroups,this.renameClonedAsset("")),await this.processQueuedEvents()}renameClonedAsset(e){return`${this.id}_${e}`}async setBaseModelEnabled(e){e&&!this.modelInstance?await this.instantiate():!e&&this.modelInstance&&this.destroyInstance()}updateDynamicTextures(){var e;(e=this.canvasPanels)==null||e.forEach((t,i)=>{const a=this.dynamicTextures.get(i);a&&t.getStaticContextDirty()&&a.isReady()&&(a.update(!1),t.setStaticContextDirty(!1))})}registerMaterialVariantListener(e){this.materialVariantObservable.add(e)}unregisterMaterialVariantListener(e){this.materialVariantObservable.removeCallback(e)}registerModelVariantListener(e){this.modelVariantObservable.add(e)}unregisterModelVariantListener(e){this.modelVariantObservable.removeCallback(e)}stripIdFromName(e){return e.substring(this.id.length+1)}async processQueuedEvents(){await Promise.all(Array.from(this.materialReadyToLoadCallbacks.values()).flatMap(e=>Array.from(e.values()).map(t=>t()))),this.materialReadyToLoadCallbacks.clear(),await Promise.all(Array.from(this.modelReadyToLoadCallbacks.values()).map(e=>e())),this.modelReadyToLoadCallbacks.clear(),this.queuedModelAnimation&&(this.executeAnimation(this.queuedModelAnimation),this.queuedModelAnimation=void 0)}}class S extends y.ArcRotateCamera{constructor(e,t,i,a,o,n,r,l){super(e,t,i,a,o,n,l),this.lastFocus=new g.Vector3(0,0,0),this.panDenominator=1,this.minZ=.01,this.setRadius(this.radius),this.enableFramingBehavior(),this.wheelDeltaPercentage=.01,this.pinchDeltaPercentage=.005,this.useNaturalPinchZoom=!0,r.camera.autoOrientation&&(this.alpha+=Math.PI),r&&(r.camera.limits.min.beta&&(this.lowerBetaLimit=r.camera.limits.min.beta),r.camera.limits.max.beta&&(this.upperBetaLimit=r.camera.limits.max.beta),r.camera.limits.min.alpha&&(this.lowerAlphaLimit=r.camera.limits.min.alpha),r.camera.limits.max.alpha&&(this.upperAlphaLimit=r.camera.limits.max.alpha),r.camera.limits.min.radius&&(this.lowerRadiusLimit=r.camera.limits.min.radius),r.camera.limits.max.radius&&(this.upperRadiusLimit=r.camera.limits.max.radius),r.camera.autoRotation.enabled&&this.enableAutoRotationBehavior(r.camera.autoRotation.idleTimeMs))}getFramingBehavior(){return this.getBehaviorByName("Framing")}getAutoRotationBehavior(){const e=this.getBehaviorByName("AutoRotation");if(e)return e}enableFramingBehavior(){this.useFramingBehavior=!0;const e=this.getFramingBehavior();e.attach(this),e.framingTime=0,e.elevationReturnTime=-1,e.zoomStopsAnimation=!1,this.lowerRadiusLimit=null;const t=F(this._scene);return e.zoomOnBoundingInfo(t.min,t.max),this.wheelPrecision=100/this.radius,this.lowerRadiusLimit===null&&(this.lowerRadiusLimit=.1),this.lastFocus.copyFrom(this.target),e}rerunFramingBehavior(e,t){const i=this.getFramingBehavior();i.framingTime=t||800;const a=()=>{e&&e()},o=F(this._scene),n=o.max.subtract(o.min),r=o.min.add(n.scale(.5));this.setRadius(n.length()*1.5),this.wheelPrecision=100/this.radius,this.panningInertia=0,this.panningOriginTarget.copyFrom(r),this.panDenominator=n.length(),i.zoomOnBoundingInfo(o.min,o.max,void 0,a),i.framingTime=0}enableAutoRotationBehavior(e=5e3){this.useAutoRotationBehavior=!0;const t=this.getAutoRotationBehavior();t&&(t.idleRotationWaitTime=e)}disableAutoRotationBehavior(){this.useAutoRotationBehavior=!1}setRadius(e){this.radius=e,this.maxZ=this.radius*1e3,this.lowerRadiusLimit=this.radius*.01,this.upperRadiusLimit=1.5*this.radius,this.wheelPrecision=100/this.radius,this.pinchPrecision=300/this.radius}static create(e,t,i){const a=F(e),o=a.max.subtract(a.min),n=a.min.add(o.scale(.5)),r=new S("ProductCamera",-(Math.PI/2),Math.PI/2,o.length()*1.5,n,e,t);return r.panningInertia=0,r.panningOriginTarget.copyFrom(n),r.panDenominator=o.length(),r.onAfterCheckInputsObservable.add(()=>{r.panningSensibility=1e3/r.panDenominator}),i&&(e.activeCamera=r),r}}function F(s){if(s.meshes.length===0)return{min:new g.Vector3(-1,-1,-1),max:new g.Vector3(1,1,1)};const e=s.meshes.filter(t=>t.name.toLowerCase().endsWith("_t")||t.name.toLowerCase().includes("_t_"));return s.getWorldExtends(t=>t.isVisible&&t.isEnabled()&&(e.length===0||e.includes(t)))}class Xe{constructor(e,t=!1,i=void 0){this.renderingPipeline=new Fe.DefaultRenderingPipeline("default",t,e,i?[i]:void 0,!1),this.renderingPipeline.isSupported&&(this.renderingPipeline.prepare(),this.setConfiguration(c))}dispose(){this.renderingPipeline.dispose()}getConfiguration(){return this.currentConfiguration}setConfiguration(e){var t,i,a,o,n,r,l,d,u,m,f,b,C,_,ee,te,ie,se,ne,re,ae,oe,le,he,ce,de,ue,ge,me,pe,fe,be,ye;if(this.renderingPipeline.isSupported){if(this.renderingPipeline.samples=((t=e.antiAliasing)==null?void 0:t.samples)??c.antiAliasing.samples,this.renderingPipeline.fxaaEnabled=((i=e.antiAliasing)==null?void 0:i.fxaaEnabled)??c.antiAliasing.fxaaEnabled,this.renderingPipeline.bloomEnabled=((a=e.bloom)==null?void 0:a.enabled)??c.bloom.enabled,this.renderingPipeline.bloomKernel=((o=e.bloom)==null?void 0:o.kernel)??c.bloom.kernel,this.renderingPipeline.bloomScale=((n=e.bloom)==null?void 0:n.scale)??c.bloom.scale,this.renderingPipeline.bloomThreshold=((r=e.bloom)==null?void 0:r.threshold)??c.bloom.threshold,this.renderingPipeline.bloomWeight=((l=e.bloom)==null?void 0:l.weight)??c.bloom.weight,this.renderingPipeline.chromaticAberrationEnabled=((d=e.chromaticAberration)==null?void 0:d.enabled)??c.chromaticAberration.enabled,this.renderingPipeline.chromaticAberration.aberrationAmount=((u=e.chromaticAberration)==null?void 0:u.aberrationAmount)??c.chromaticAberration.aberrationAmount,this.renderingPipeline.chromaticAberration.radialIntensity=((m=e.chromaticAberration)==null?void 0:m.radialIntensity)??c.chromaticAberration.radialIntensity,this.renderingPipeline.chromaticAberration.direction=(f=e.chromaticAberration)!=null&&f.direction?new g.Vector2(e.chromaticAberration.direction.x,e.chromaticAberration.direction.y):new g.Vector2(c.chromaticAberration.direction.x,c.chromaticAberration.direction.y),this.renderingPipeline.imageProcessing.colorCurvesEnabled=((b=e.colorCurves)==null?void 0:b.enabled)??c.colorCurves.enabled,this.renderingPipeline.imageProcessing.colorCurves=e.colorCurves?this.updateColorCurve(e.colorCurves):new k.ColorCurves,this.renderingPipeline.depthOfFieldEnabled=((C=e.depthOfField)==null?void 0:C.enabled)??c.depthOfField.enabled,e.depthOfField)switch(e.depthOfField.blurLevel??c.depthOfField.blurLevel){case"Low":this.renderingPipeline.depthOfFieldBlurLevel=I.DepthOfFieldEffectBlurLevel.Low;break;case"Medium":this.renderingPipeline.depthOfFieldBlurLevel=I.DepthOfFieldEffectBlurLevel.Medium;break;case"High":this.renderingPipeline.depthOfFieldBlurLevel=I.DepthOfFieldEffectBlurLevel.High;break}if(this.renderingPipeline.depthOfField.focalLength=((_=e.depthOfField)==null?void 0:_.focalLength)??c.depthOfField.focalLength,this.renderingPipeline.depthOfField.fStop=((ee=e.depthOfField)==null?void 0:ee.fStop)??c.depthOfField.fStop,this.renderingPipeline.depthOfField.focusDistance=((te=e.depthOfField)==null?void 0:te.focusDistance)??c.depthOfField.focusDistance,this.renderingPipeline.depthOfField.lensSize=((ie=e.depthOfField)==null?void 0:ie.lensSize)??c.depthOfField.lensSize,this.renderingPipeline.grainEnabled=((se=e.grain)==null?void 0:se.enabled)??c.grain.enabled,this.renderingPipeline.grain.animated=((ne=e.grain)==null?void 0:ne.animated)??c.grain.animated,this.renderingPipeline.grain.intensity=((re=e.grain)==null?void 0:re.intensity)??c.grain.intensity,this.renderingPipeline.imageProcessing.contrast=((ae=e.misc)==null?void 0:ae.contrast)??c.misc.contrast,this.renderingPipeline.imageProcessing.exposure=((oe=e.misc)==null?void 0:oe.exposure)??c.misc.exposure,this.renderingPipeline.imageProcessing.toneMappingEnabled=((le=e.misc)==null?void 0:le.toneMappingEnabled)??c.misc.toneMappingEnabled,this.renderingPipeline.imageProcessing.toneMappingEnabled)switch(e.misc.toneMappingType??c.misc.toneMappingType){case"Standard":this.renderingPipeline.imageProcessing.toneMappingType=T.ImageProcessingConfiguration.TONEMAPPING_STANDARD;break;case"ACES":this.renderingPipeline.imageProcessing.toneMappingType=T.ImageProcessingConfiguration.TONEMAPPING_ACES;break}if(this.renderingPipeline.sharpenEnabled=((he=e.sharpen)==null?void 0:he.enabled)??c.sharpen.enabled,this.renderingPipeline.sharpen.colorAmount=((ce=e.sharpen)==null?void 0:ce.colorAmount)??c.sharpen.colorAmount,this.renderingPipeline.sharpen.edgeAmount=((de=e.sharpen)==null?void 0:de.edgeAmount)??c.sharpen.edgeAmount,this.renderingPipeline.imageProcessing.vignetteEnabled=((ue=e.vignette)==null?void 0:ue.enabled)??c.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=c.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=c.vignette.center.y),e.vignette)switch(((me=e.vignette)==null?void 0:me.blendMode)??c.vignette.blendMode){case"Multiply":this.renderingPipeline.imageProcessing.vignetteBlendMode=T.ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY;break;case"Opaque":this.renderingPipeline.imageProcessing.vignetteBlendMode=T.ImageProcessingConfiguration.VIGNETTEMODE_OPAQUE;break}(pe=e.vignette)!=null&&pe.colorRgba?this.renderingPipeline.imageProcessing.vignetteColor=new p.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=p.Color4.FromHexString(e.vignette.colorHex):this.renderingPipeline.imageProcessing.vignetteColor=new p.Color4(c.vignette.colorRgba.r,c.vignette.colorRgba.g,c.vignette.colorRgba.b,c.vignette.colorRgba.a),this.renderingPipeline.imageProcessing.vignetteStretch=((be=e.vignette)==null?void 0:be.stretch)??c.vignette.stretch,this.renderingPipeline.imageProcessing.vignetteWeight=((ye=e.vignette)==null?void 0:ye.weight)??c.vignette.weight,this.renderingPipeline.prepare(),this.currentConfiguration=e}}updateColorCurve(e){const t=new k.ColorCurves;return t.globalDensity=e.globalDensity??t.globalDensity,t.globalExposure=e.globalExposure??t.globalExposure,t.globalHue=e.globalHue??t.globalHue,t.globalSaturation=e.globalSaturation??t.globalSaturation,t.highlightsDensity=e.highlightsDensity??t.highlightsDensity,t.highlightsExposure=e.highlightsExposure??t.highlightsExposure,t.highlightsHue=e.highlightsHue??t.highlightsHue,t.highlightsSaturation=e.highlightsSaturation??t.highlightsSaturation,t.midtonesDensity=e.midtonesDensity??t.midtonesDensity,t.midtonesExposure=e.midtonesExposure??t.midtonesExposure,t.midtonesHue=e.midtonesHue??t.midtonesHue,t.midtonesSaturation=e.midtonesSaturation??t.midtonesSaturation,t.shadowsDensity=e.shadowsDensity??t.shadowsDensity,t.shadowsExposure=e.shadowsExposure??t.shadowsExposure,t.shadowsHue=e.shadowsHue??t.shadowsHue,t.shadowsSaturation=e.shadowsSaturation??t.shadowsSaturation,t}}Pe.GLTF2.GLTFLoader.RegisterExtension("glbPostProcessor",function(s){return new Be(s)}),q.SceneLoader.OnPluginActivatedObservable.add(s=>{if(s.name==="gltf"){const e=s;e.transparencyAsCoverage=!0}});function B(s){return new g.Vector3(s.x,s.y,s.z)}function j(s){return{x:s.x,y:s.y,z:s.z}}class Je{constructor(e){var l;this.focusLostNotified=!1,this.focusLostObservable=new M.Observable,this.modelLoadEventCallbacks=[],this.modelContainers=new Map,this.plugins=[],this.initComplete=!1,this.renderLoop=()=>{this.engine.views&&(this.modelContainers.forEach(d=>{d.updateDynamicTextures()}),this.scene.render(),!this.camera.target.equalsWithEpsilon(this.camera.lastFocus,.1)&&!this.focusLostNotified&&(this.focusLostObservable.notifyObservers(void 0),this.focusLostNotified=!0),this.screenshotPrepareResolve&&(this.screenshotPrepareResolve(),this.screenshotPrepareResolve=void 0))},this.configuration=new z(e);const i=(()=>{if(!(e!=null&&e.noRender))return this.configuration.createCanvas()})(),a="1.5.6";Ce.DracoCompression.Configuration={decoder:{wasmUrl:`https://www.gstatic.com/draco/versioned/decoders/${a}/draco_wasm_wrapper_gltf.js`,wasmBinaryUrl:`https://www.gstatic.com/draco/versioned/decoders/${a}/draco_decoder_gltf.wasm`,fallbackUrl:`https://www.gstatic.com/draco/versioned/decoders/${a}/draco_decoder_gltf.js`}},i&&(i.getContext("webgl2")||i.getContext("webgl"));const o=console.log,n=i?new D.Engine(i,!0,{adaptToDeviceRatio:!0,limitDeviceRatio:2,premultipliedAlpha:!1,preserveDrawingBuffer:!!(e!=null&&e.backgroundImage),audioEngine:!1,stencil:this.configuration.highlights.enabled,forceSRGBBufferSupportState:!0}):new we.NullEngine;console.log=o,n.hideLoadingUI(),window.addEventListener("resize",this.fireResizeEvent.bind(this)),this.engine=n,this.scene=new xe.Scene(n),this.scene.autoClear=!0,this.scene.autoClearDepthAndStencil=!0,this.camera=S.create(this.scene,this.configuration),this.scene.activeCamera=this.camera,this.renderingPipeline=new Xe(this.scene,!1,this.camera),this.scene.clearColor=this.configuration.scene.clearColor;const r=V.CubeTexture.CreateFromPrefilteredData(this.configuration.scene.environment.file,this.scene);r.rotationY=this.configuration.scene.environment.rotationY,this.scene.environmentTexture=r,this.scene.environmentIntensity=this.configuration.scene.environment.intensity,(l=this.configuration.options)!=null&&l.renderingPipelineConfiguration?this.renderingPipeline.setConfiguration(this.configuration.options.renderingPipelineConfiguration):(this.scene.imageProcessingConfiguration.exposure=this.configuration.lighting.exposure,this.scene.imageProcessingConfiguration.contrast=this.configuration.lighting.contrast),this.glowLayerManager=new je(this.scene,this.configuration.emissiveGlowIntensity),this.initPromise=new Promise(d=>{this.scene.onReadyObservable.addOnce(()=>{this.initComplete=!0,d()})}),this.engine.runRenderLoop(this.renderLoop)}getInitializationPromise(){return this.initPromise}getInitializationComplete(){return this.initComplete}getEngineContext(){return{engine:this.engine,scene:this.scene,camera:this.camera}}registerFocusLostListener(e){this.focusLostObservable.add(e)}unregisterFocusLostListener(e){this.focusLostObservable.removeCallback(e)}registerModelLoadEventListener(e){this.modelLoadEventCallbacks.push(e)}unregisterModelLoadEventListener(e){const t=this.modelLoadEventCallbacks.indexOf(e);t>-1&&this.modelLoadEventCallbacks.splice(t,1)}registerView(e){const t=e.height,i=e.width;this.engine.registerView(e,void 0,!0),e.setAttribute("height",t.toString()),e.setAttribute("width",i.toString()),this.orbitEnabled()||this.setCameraState(A.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.camera?console.log("ANIM: DEBUGGING: queueing animation bc wrong camera"):console.log("ANIM: DEBUGGING: queueing animation bc no camera"),this.queuedCameraAnimation=e;return}console.log("ANIM: DEBUGGING: animating camera in scene"),ke(this.scene,this.scene.activeCamera,e),console.log("ANIM: DEBUGGING: animated camera in scene")}getCameraPose(){if(this.scene&&this.camera)return{lonDeg:Math.round(this.camera.alpha*180/Math.PI),latDeg:Math.round(this.camera.beta*180/Math.PI),radius:Math.round((this.camera.radius+Number.EPSILON)*1e4)/1e4,target:{x:this.camera.target.x,y:this.camera.target.y,z:this.camera.target.z}}}setCameraPose(e){this.scene&&this.camera&&(this.camera.target=new g.Vector3(e.target.x,e.target.y,e.target.z),this.camera.radius=e.radius,this.camera.alpha=e.latDeg,this.camera.beta=e.lonDeg)}setCameraState(e){var t,i;if(!((t=this.engine)!=null&&t.views)||!((i=this.engine)!=null&&i.views[0]))throw new Error("No views attached, camera state requires a view to attach controls onto.");e===A.Orbit?this.reattachControls(this.engine.views[0].target,2):this.reattachControls(this.engine.views[0].target,0)}animateToLastCameraFocus(){return new Promise(e=>{const t=()=>{const i=this.configuration;this.camera.rerunFramingBehavior(()=>{this.focusLostNotified=!1,i.camera.limits.min.radius&&(this.camera.lowerRadiusLimit=i.camera.limits.min.radius),i.camera.limits.max.radius&&(this.camera.upperRadiusLimit=i.camera.limits.max.radius),e()})};this.scene.onAfterRenderObservable.addOnce(t)})}setAutoRotation(e){!this.configuration.camera.autoRotation.enabled||!this.camera||(e?this.camera.enableAutoRotationBehavior(this.configuration.camera.autoRotation.idleTimeMs):this.camera.disableAutoRotationBehavior())}getCurrentConfiguration(){return this.configuration.options}async renderSceneScreenshot(e,t){if(!this.camera)throw new Error("Missing product camera, cannot render screenshot!");const i=new y.ArcRotateCamera("screenshotCamera",0,0,0,g.Vector3.Zero(),this.scene);try{const a=t.latDeg*Math.PI/180,o=t.lonDeg*Math.PI/180;i.target=t.target?new g.Vector3(t.target.x,t.target.y,t.target.z):g.Vector3.Zero(),i.alpha=o,i.beta=a,i.radius=t.radius||this.camera.radius,i.minZ=.01,this.scene.render();const n=await Me.Tools.CreateScreenshotUsingRenderTargetAsync(this.engine,i,e,"image/png",2,!0);return i.dispose(),n}catch{throw i.isDisposed()||i.dispose(),new Error("Failed to render screenshot")}}orbitEnabled(){const e=this.configuration;if(!e)return!0;const t=e.camera.limits.min.alpha,i=e.camera.limits.max.alpha,a=e.camera.limits.min.beta,o=e.camera.limits.max.beta;if(t===void 0||i===void 0||a===void 0||o===void 0)return!0;const n=[t,i],r=[a,o],l=n.every(u=>u===t),d=r.every(u=>u===a);return!l&&!d}fireResizeEvent(){this.getNumViewports()>0&&this.engine.resize()}setHighlights(e,t){var a;e.length===0&&((a=this.highlightLayer)==null||a.dispose(),this.highlightLayer=void 0),this.highlightLayer||(this.highlightLayer=new ve.HighlightLayer("highlights",this.scene,{isStroke:!0,blurVerticalSize:.85,blurHorizontalSize:.85}),this.highlightLayer.innerGlow=!0,this.highlightLayer.outerGlow=!1),this.highlightLayer.removeAllMeshes();const i=t?new p.Color3(t[0],t[1],t[2]).toLinearSpace():void 0;e.forEach(o=>{const n=this.scene.materials.find(r=>r.name===o.name&&r.id===o.id);n&&n.getBindedMeshes().forEach(r=>{var l;return(l=this.highlightLayer)==null?void 0:l.addMesh(r,i||p.Color3.FromHexString("#fcba03"))})})}setRenderingPipelineConfiguration(e){this.renderingPipeline&&this.renderingPipeline.setConfiguration(e)}loadModel(e,t){const i=new $e({enablePicking:this.configuration.highlights.enabled,modelDetails:e,scene:this.scene,previewService:this,progressHandler:t});return i.getInitializationPromise().then(()=>{this.modelContainers.size<=1&&this.camera.rerunFramingBehavior(void 0,1),Ne(this.scene),this.queuedCameraAnimation&&(this.executeCameraAnimation(this.queuedCameraAnimation),this.queuedCameraAnimation=void 0)}),this.configuration.highlights.enabled&&(i.registerMaterialSelectedCallback(a=>{this.setHighlights([a])}),i.registerMaterialDeselectedCallback(()=>{this.setHighlights([])})),this.modelContainers.set(i.getId(),i),this.triggerModelLoadEvent({eventType:"load",modelContainer:i}),i}getAllModels(){return Array.from(this.modelContainers.values())}getModelById(e){return this.modelContainers.get(e)}registerPlugin(e){this.plugins.push(e),e.initialize(this,{camera:this.camera,engine:this.engine,scene:this.scene})}unregisterPlugin(e){const t=this.plugins.indexOf(e);t>-1&&this.plugins.splice(t,1).forEach(a=>a.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 a=g.Matrix.Compose(B(i||{x:1,y:1,z:1}),g.Quaternion.FromEulerVector(B(t||{x:0,y:0,z:0})),B(e||{x:0,y:0,z:0})),o=g.Matrix.RotationAxis(g.Vector3.Up(),Math.PI),n=a.multiply(o),r=g.Vector3.Zero(),l=g.Quaternion.Identity(),d=g.Vector3.Zero();return n.decompose(d,l,r),l.multiplyInPlace(g.Quaternion.FromEulerAngles(0,Math.PI,0)),{position:j(r),rotation:j(l.toEulerAngles()),scale:j(d)}}updatePreviewOptions(e){var a;const t=new z(e);this.configuration.highlights.enabled!==t.highlights.enabled&&this.engine.setStencilBuffer(t.highlights.enabled),this.scene.clearColor=t.scene.clearColor;let i=this.scene.environmentTexture;this.configuration.scene.environment.file!==t.scene.environment.file&&(i=V.CubeTexture.CreateFromPrefilteredData(t.scene.environment.file,this.scene),i.rotationY=this.configuration.scene.environment.rotationY,this.scene.environmentTexture=i),i.rotationY=t.scene.environment.rotationY,this.scene.environmentIntensity=t.scene.environment.intensity,(a=t.options)!=null&&a.renderingPipelineConfiguration?this.renderingPipeline.setConfiguration(t.options.renderingPipelineConfiguration):(this.scene.imageProcessingConfiguration.exposure=t.lighting.exposure,this.scene.imageProcessingConfiguration.contrast=t.lighting.contrast),this.glowLayerManager.setIntensity(t.emissiveGlowIntensity),this.configuration=t}reattachControls(e,t=2){if(this.scene.detachControl(),this.engine.inputElement=e,this.camera){this.camera.attachControl(!0,!1,t);const i=this.camera.inputs.attached.pointers;i.multiTouchPanning=!1}this.scene.attachControl(!0,!0,!0)}}h.MaterialEffectMode=E,h.ProductCameraRig=A,h.REFLECTION_PROBE_RESOLUTION=H,h.RenderingConfiguration=v,h.SpiffCommerce3DPreviewService=Je,h.renderingPipelineDefaults=c,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
1
+ (function(h,y){typeof exports=="object"&&typeof module<"u"?y(exports,require("@babylonjs/core/Cameras/arcRotateCamera"),require("@babylonjs/core/Engines/engine"),require("@babylonjs/core/Engines/nullEngine"),require("@babylonjs/core/Layers/highlightLayer"),require("@babylonjs/core/Loading/sceneLoader"),require("@babylonjs/core/Materials/Textures/cubeTexture"),require("@babylonjs/core/Maths/math.color"),require("@babylonjs/core/Maths/math.vector"),require("@babylonjs/core/Meshes/Compression/dracoCompression"),require("@babylonjs/core/Misc/observable"),require("@babylonjs/core/Misc/tools"),require("@babylonjs/core/scene"),require("@babylonjs/loaders/glTF"),require("@babylonjs/core/Materials/PBR/pbrMaterial"),require("@babylonjs/core/Materials/Textures/mirrorTexture"),require("@babylonjs/core/Maths/math"),require("@babylonjs/core/Probes/reflectionProbe"),require("@babylonjs/core/Layers/glowLayer"),require("@babylonjs/core/Actions/actionManager"),require("@babylonjs/core/Actions/directActions"),require("@babylonjs/core/Meshes/mesh"),require("@babylonjs/core/Meshes/transformNode"),require("@babylonjs/core/Materials/Textures/dynamicTexture"),require("@babylonjs/core/Materials/Textures/texture"),require("@babylonjs/core/Animations/animation"),require("@babylonjs/core/Animations/easing"),require("@babylonjs/core/Misc/assetsManager"),require("@babylonjs/core/Materials/colorCurves"),require("@babylonjs/core/Materials/imageProcessingConfiguration"),require("@babylonjs/core/PostProcesses/RenderPipeline"),require("@babylonjs/core/PostProcesses/depthOfFieldEffect"),require("@babylonjs/core/Rendering/depthRendererSceneComponent"),require("@babylonjs/core/Engines/Extensions/engine.views"),require("@babylonjs/core/Meshes/instancedMesh"),require("@babylonjs/core/Materials/Textures/Loaders/ddsTextureLoader"),require("@babylonjs/core/Materials/Textures/Loaders/envTextureLoader"),require("@babylonjs/core/Materials/Textures/Loaders/ktxTextureLoader"),require("@babylonjs/core/Animations/animatable"),require("@babylonjs/core/Misc/screenshotTools"),require("@babylonjs/core/Rendering/boundingBoxRenderer"),require("@babylonjs/loaders/glTF/2.0/Extensions")):typeof define=="function"&&define.amd?define(["exports","@babylonjs/core/Cameras/arcRotateCamera","@babylonjs/core/Engines/engine","@babylonjs/core/Engines/nullEngine","@babylonjs/core/Layers/highlightLayer","@babylonjs/core/Loading/sceneLoader","@babylonjs/core/Materials/Textures/cubeTexture","@babylonjs/core/Maths/math.color","@babylonjs/core/Maths/math.vector","@babylonjs/core/Meshes/Compression/dracoCompression","@babylonjs/core/Misc/observable","@babylonjs/core/Misc/tools","@babylonjs/core/scene","@babylonjs/loaders/glTF","@babylonjs/core/Materials/PBR/pbrMaterial","@babylonjs/core/Materials/Textures/mirrorTexture","@babylonjs/core/Maths/math","@babylonjs/core/Probes/reflectionProbe","@babylonjs/core/Layers/glowLayer","@babylonjs/core/Actions/actionManager","@babylonjs/core/Actions/directActions","@babylonjs/core/Meshes/mesh","@babylonjs/core/Meshes/transformNode","@babylonjs/core/Materials/Textures/dynamicTexture","@babylonjs/core/Materials/Textures/texture","@babylonjs/core/Animations/animation","@babylonjs/core/Animations/easing","@babylonjs/core/Misc/assetsManager","@babylonjs/core/Materials/colorCurves","@babylonjs/core/Materials/imageProcessingConfiguration","@babylonjs/core/PostProcesses/RenderPipeline","@babylonjs/core/PostProcesses/depthOfFieldEffect","@babylonjs/core/Rendering/depthRendererSceneComponent","@babylonjs/core/Engines/Extensions/engine.views","@babylonjs/core/Meshes/instancedMesh","@babylonjs/core/Materials/Textures/Loaders/ddsTextureLoader","@babylonjs/core/Materials/Textures/Loaders/envTextureLoader","@babylonjs/core/Materials/Textures/Loaders/ktxTextureLoader","@babylonjs/core/Animations/animatable","@babylonjs/core/Misc/screenshotTools","@babylonjs/core/Rendering/boundingBoxRenderer","@babylonjs/loaders/glTF/2.0/Extensions"],y):(h=typeof globalThis<"u"?globalThis:h||self,y(h.Preview={},h.arcRotateCamera,h.engine,h.nullEngine,h.highlightLayer,h.sceneLoader,h.cubeTexture,h.math_color,h.math_vector,h.dracoCompression,h.observable,h.tools,h.scene,h.glTF,h.pbrMaterial,h.mirrorTexture,h.math,h.reflectionProbe,h.glowLayer,h.actionManager,h.directActions,h.mesh,h.transformNode,h.dynamicTexture,h.texture,h.animation,h.easing,h.assetsManager,h.colorCurves,h.imageProcessingConfiguration,h.RenderPipeline,h.depthOfFieldEffect))})(this,function(h,y,q,we,ve,G,N,p,g,Ce,M,Me,xe,Pe,O,Te,P,Ee,Re,I,V,Ae,Le,Oe,Ie,w,k,Se,z,T,Fe,S){"use strict";var E=(s=>(s[s.Orbit=0]="Orbit",s[s.Pan=1]="Pan",s))(E||{}),R=(s=>(s.None="None",s.RemoveWhenSelected="RemoveWhenSelected",s.ApplyWhenSelected="ApplyWhenSelected",s))(R||{});class H{constructor(e){this.getSceneClearColor=()=>{var i,a,o,n;const t=(i=this.customOptions)!=null&&i.transparentBackground||(a=this.customOptions)!=null&&a.backgroundImage?0:1;if(this.customOptions&&((o=this.customOptions)!=null&&o.transparentBackground)||(n=this.customOptions)!=null&&n.backgroundImage)return new p.Color4(0,0,0,t).toLinearSpace();if(this.customOptions&&this.customOptions.backgroundColor){const r=p.Color3.FromHexString(this.customOptions.backgroundColor);return new p.Color4(r.r,r.g,r.b,t).toLinearSpace()}return new p.Color4(.98,.98,.98,t).toLinearSpace()},this.highlightColorFromConfig=()=>this.customOptions&&this.customOptions.highlightColor?this.hexToColor4(this.customOptions.highlightColor):new p.Color4(.98,.98,.98,1).toLinearSpace(),this.hexToColor4=(t,i=1)=>{const a=p.Color3.FromHexString(t);return new p.Color4(a.r,a.g,a.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,a,o;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:((a=this.customOptions)==null?void 0:a.environmentIntensity)??1,rotationY:(((o=this.customOptions)==null?void 0:o.environmentRotationY)??0)*(Math.PI/180)}}}get camera(){var e,t,i,a,o,n,r,l,d,u,m,f,b;return{autoOrientation:((e=this.customOptions)==null?void 0:e.disableAutomaticOrientation)??!0,autoRotation:{enabled:((t=this.customOptions)==null?void 0:t.autoRotation)??!1,idleTimeMs:((i=this.customOptions)==null?void 0:i.idleTimeBeforeRotation)??5e3},limits:{min:{alpha:(a=this.customOptions)!=null&&a.lowerAlphaLimitDeg?((o=this.customOptions)==null?void 0:o.lowerAlphaLimitDeg)*Math.PI/180:void 0,beta:(n=this.customOptions)!=null&&n.lowerBetaLimitDeg?((r=this.customOptions)==null?void 0:r.lowerBetaLimitDeg)*Math.PI/180:void 0,radius:(l=this.customOptions)==null?void 0:l.minZoomOverride},max:{alpha:(d=this.customOptions)!=null&&d.upperAlphaLimitDeg?((u=this.customOptions)==null?void 0:u.upperAlphaLimitDeg)*Math.PI/180:void 0,beta:(m=this.customOptions)!=null&&m.upperBetaLimitDeg?((f=this.customOptions)==null?void 0:f.upperBetaLimitDeg)*Math.PI/180:void 0,radius:(b=this.customOptions)==null?void 0:b.maxZoomOverride}}}}get highlights(){var e;return{enabled:((e=this.customOptions)==null?void 0:e.highlightOnMaterialHover)??!1,color:this.highlightColorFromConfig()}}get lighting(){var e,t,i,a;return{exposure:((t=(e=this.customOptions)==null?void 0:e.lighting)==null?void 0:t.exposure)??.9,contrast:((a=(i=this.customOptions)==null?void 0:i.lighting)==null?void 0:a.contrast)??1.6}}get emissiveGlowIntensity(){var e;return((e=this.customOptions)==null?void 0:e.emissiveGlowIntensity)??.5}}class v{static getDynamicTextureResolution(){return this.getIsMobile()||!v.offscreenRenderingSupported()?{width:1024,height:1024}:{width:2048,height:2048}}static shouldMipMap(){return!0}static offscreenRenderingSupported(){return navigator.userAgent.includes("SamsungBrowser")?!1:!!window.Worker&&!!window.OffscreenCanvas}static getMirrorTextureResolution(){return this.getIsMobile()?512:1024}static getIsMobile(){try{return typeof window>"u"||!window.navigator?!1:/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(window.navigator.userAgent)||window.innerWidth<=480}catch{return!1}}}const U=128,c={antiAliasing:{samples:4,fxaaEnabled:!1},bloom:{enabled:!1,kernel:64,scale:.5,threshold:.9,weight:.15},chromaticAberration:{enabled:!1,aberrationAmount:30,direction:{x:0,y:0},radialIntensity:0},colorCurves:{enabled:!1},depthOfField:{enabled:!1,blurLevel:"Low",focalLength:50,focusDistance:2e3,fStop:1.4,lensSize:50},grain:{enabled:!1,animated:!1,intensity:30},misc:{contrast:1,exposure:1,toneMappingEnabled:!1,toneMappingType:"Standard"},sharpen:{enabled:!1,colorAmount:1,edgeAmount:.3},vignette:{enabled:!1,blendMode:"Multiply",cameraFov:.5,center:{x:0,y:0},colorHex:"#000000ff",colorRgba:{r:0,g:0,b:0,a:1},stretch:0,weight:1}};class Be{constructor(e){this.name="glbPostProcessor",this.enabled=!0,this.loader=e}onReady(){this.applyReflections(this.loader.babylonScene)}loadNodeAsync(e,t,i){return this.loader.loadNodeAsync(e,t,function(a){t.extras&&Object.keys(t.extras).forEach(o=>{const n=t.extras[o];a.metadata[o]=n}),i(a)})}async loadMaterialPropertiesAsync(e,t,i){await this.loader.loadMaterialPropertiesAsync(e,t,i),this.enableMaterialExtrasIfRequired(t,i),i.needDepthPrePass=!0}dispose(){}enableMaterialExtrasIfRequired(e,t){if(!(!e.extras||!(t instanceof O.PBRMaterial))){if(e.extras.sheen){const i=t;i.sheen.isEnabled=!0,i.sheen.intensity=e.extras.sheen}if(e.extras.translucency){const i=t;i.subSurface.isTranslucencyEnabled=!0,i.subSurface.translucencyIntensity=e.extras.translucency,e.extras.translucencyR&&e.extras.translucencyG&&e.extras.translucencyB&&(i.subSurface.tintColor=new P.Color3(e.extras.translucencyR,e.extras.translucencyG,e.extras.translucencyB))}if(e.extras.refractionIOR){const i=t;i.subSurface.isRefractionEnabled=!0,i.subSurface.volumeIndexOfRefraction=e.extras.refractionIOR}if(e.extras.useDepthPrePass){const i=t;i.needDepthPrePass=!0,i.forceIrradianceInFragment=!0}if(e.extras.useParallax){const i=t;i.useParallax=!0,i.useParallaxOcclusion=!0,i.parallaxScaleBias=e.extras.useParallax}}}applyReflections(e){function t(o){const n=[];return o.transformNodes.forEach(r=>{r.metadata&&r.metadata.reflective&&n.push(...r.getChildMeshes())}),o.meshes.forEach(r=>{r.metadata&&r.metadata.reflective&&!n.includes(r)&&n.push(r)}),n}function i(o,n=1){const r=o.material;if(!r)return;const l=new Te.MirrorTexture("mirror",v.getMirrorTextureResolution(),e,!0);l.renderList=t(e);const d=o.getVerticesData("normal");if(!d)throw new Error("Mirror attribute specified on: "+o.name+"But no normals exist to generate a mirror from!");o.computeWorldMatrix(!0);const u=o.getWorldMatrix(),m=P.Vector3.TransformNormal(new P.Vector3(d[0],d[1],d[2]),u).normalize(),f=P.Plane.FromPositionAndNormal(o.position,m.scale(-1));l.mirrorPlane=f,l.level=n,r.reflectionTexture=l}function a(o){const n=o.material,r=new Ee.ReflectionProbe("probe-"+n.name,U,e);r.attachToMesh(o),r.renderList&&r.renderList.push(...t(e)),n.reflectionTexture=r.cubeTexture}e.meshes.forEach(o=>{const n=o.metadata;n&&(n.mirrorTexture&&i(o,n.mirrorTexture),n.reflectionProbe&&a(o))})}}class De{constructor(e,t){this.scene=e,this.intensity=t,this.meshCount=0}setIntensity(e){this.intensity=e,this.glowLayer&&(this.glowLayer.intensity=e)}includeMeshes(e){if(e){this.glowLayer||(this.glowLayer=new Re.GlowLayer("glow",this.scene),this.glowLayer.intensity=this.intensity);for(const t of e)this.glowLayer.hasMesh(t)||(this.glowLayer.addIncludedOnlyMesh(t),this.meshCount++)}}removeMeshes(e){if(!(!this.glowLayer||!e)){for(const t of e)this.glowLayer.hasMesh(t)&&(this.glowLayer.removeIncludedOnlyMesh(t),this.meshCount--);this.meshCount===0&&(this.glowLayer.dispose(),this.glowLayer=void 0)}}}const K=new Map;async function W(s,e,t){const i=K.get(s);if(i&&i.scene.uid===e.uid)return i;{const a=await G.SceneLoader.LoadAssetContainerAsync(s,void 0,e,t);return K.set(s,a),a}}function je(s,e,t,i,a=""){t.forEach(o=>{const n=o.getID(),r=o.getName(),l=v.getDynamicTextureResolution();s.filter(u=>u.name===a+r).forEach(u=>{const m=i.get(n),f=!1;if(m)Q(u,m),m.update(f);else{const b=qe(r,e,l.width,l.height);i.set(n,b),o.setStaticContext(b.getContext()),Q(u,b),b.onLoadObservable.addOnce(()=>{b.update(f)})}})})}function qe(s,e,t,i){const a=new Oe.DynamicTexture(s,{width:t,height:i},e,v.shouldMipMap(),Ie.Texture.TRILINEAR_SAMPLINGMODE,q.Engine.TEXTUREFORMAT_RGBA),o=a.getContext();return o&&(o.fillStyle="#f5f5f5",o.fillRect(0,0,t,i),a.update()),a}function Q(s,e){if(s instanceof O.PBRMaterial){const t=s,i=t.albedoTexture;i?(e.wrapU=i.wrapU,e.wrapV=i.wrapV):(e.wrapU=1,e.wrapV=1),t.albedoTexture=e}else{const t=s,i=t.diffuseTexture;i&&(e.wrapU=i.wrapU,e.wrapV=i.wrapV),t.diffuseTexture=e}}function Ge(){const s=()=>Math.floor((1+Math.random())*65536).toString(16).substring(1);return s()+s()+"-"+s()+"-"+s()+"-"+s()+"-"+s()+s()+s()}const x=60,Y=1;function $(s){return s.targetedAnimations.map(t=>t.animation.framePerSecond).reduce((t,i)=>t+i,0)/s.targetedAnimations.length||0}function Ne(s,e,t,i,a){const o=a?s.filter(n=>n.name===a):s;if(o.length===0){console.warn(`No animations found for name: ${a}`);return}if(i!==void 0&&t!==void 0&&i===t){o.forEach(n=>{n.stop();const r=$(n),l=i*r;n.start(e,Y,l,l)});return}o.forEach(n=>{n.stop();const r=$(n),l=i!==void 0?i*r:void 0,d=t!==void 0?t*r:void 0;n.start(e,Y,l,d)})}function Z(s){s.forEach(e=>{e.stop()})}function Ve(s){const e=s.animationGroups;Z(e)}function ke(s,e,t){console.log("ANIM DEBUGGING: start of animate camera in scene"),s.stopAnimation(e),e.animations=[],Math.abs(e.alpha)>2*Math.PI&&(e.alpha=ze(e.alpha,0,2*Math.PI));const i=[],a=t.target,o=0,n=a?1:0;if(t.target&&Object.keys(t.target).length>0?(i.push(L("cameraTargetLerp","target",new g.Vector3().copyFrom(e.target),new g.Vector3(t.target.x,t.target.y,t.target.z),w.Animation.ANIMATIONTYPE_VECTOR3,o)),console.log(`ANIM DEBUGGING: target components (${t.target.x},${t.target.y},${t.target.z})`)):console.log("ANIM DEBUGGING: target lacks components"),console.log(`ANIM DEBUGGING: alpha: ${A(t.lonDeg)}, beta: ${A(t.latDeg)}, r ${t.radius}`),i.push(L("cameraAlphaLerp","alpha",e.alpha,A(t.lonDeg),w.Animation.ANIMATIONTYPE_FLOAT,n)),i.push(L("cameraBetaLerp","beta",e.beta,A(t.latDeg),w.Animation.ANIMATIONTYPE_FLOAT,n)),t.radius!==void 0){const d=Math.max(.01,t.radius);i.push(L("cameraRadiusLerp","radius",e.radius,d,w.Animation.ANIMATIONTYPE_FLOAT,n))}e.animations.push(...i);const l=e.useAutoRotationBehavior;e.disableAutoRotationBehavior(),console.log(`ANIM DEBUGGING: animSet has ${i.length} animations`),s.beginAnimation(e,0,a?x*2:x,!1,1,()=>{e.animations=[],l&&e.enableAutoRotationBehavior()})}function A(s){return s*Math.PI/180}function L(s,e,t,i,a,o=0,n=w.Animation.ANIMATIONLOOPMODE_CONSTANT){const r=new k.QuadraticEase;r.setEasingMode(k.EasingFunction.EASINGMODE_EASEINOUT);const l=new w.Animation(s,e,x,a,n),d=[];return o>0&&d.push({frame:0,value:t}),d.push({frame:x*o,value:t}),d.push({frame:x*(o+1),value:i}),l.setKeys(d),l.setEasingFunction(r),l}function ze(s,e,t){return s<e?s=t-(e-s)%(t-e):s=e+(s-e)%(t-e)}const He={albedoTexture:"albedoMap",bumpTexture:"normalMap",ambientTexture:"ambientMap",emissiveTexture:"emissionMap",opacityTexture:"alphaMap",metallicTexture:"metallicMap",refractionTexture:"refractionMap",reflectionTexture:"reflectionMap"};function Ue(s,e,t,i){["albedoTexture","bumpTexture","ambientTexture","emissiveTexture","opacityTexture","metallicTexture","refractionTexture","reflectionTexture"].forEach(o=>{Ke(o,s,e,t,i)}),Ye(s,e)}function Ke(s,e,t,i,a){const o=He[s];if(!o)throw new Error("Unexpected texture name encountered.");const n=e[o],r=n==null?void 0:n.fileLink;r?s==="reflectionTexture"?r.endsWith(".env")||r.endsWith(".dds")?i.addCubeTextureTask(s,r,void 0,!1,void 0,!0):r.endsWith(".hdr")?i.addHDRCubeTextureTask(s,r,128,!1,!0,!1):i.addTextureTask(s,r,!1,!1):i.addTextureTask(s,r,!1,!1):a&&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 p.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),e[s]=i,s==="emissiveTexture"&&(e.emissiveColor=new p.Color3(1,1,1),e.emissiveIntensity=1)}function Ye(s,e){s.clearCoat&&(s.clearCoat===R.RemoveWhenSelected?(e.clearCoat.isEnabled=!1,e.clearCoat.indexOfRefraction=1.5):s.clearCoat===R.ApplyWhenSelected&&(e.clearCoat.isEnabled=!0,e.clearCoat.indexOfRefraction=s.clearCoatIOR||e.clearCoat.indexOfRefraction))}class $e{constructor(e,t,i){this.materialVariantMap=new Map,this.keysThatRemovedBaseModel=[],this.loadedContainerForKey=new Map,this.loadedMaterialsForKey=new Map,this.scene=e,this.renameClonedAsset=t,this.setBaseModelEnabled=i}async applyMaterial(e,t,i,a){return new Promise(o=>{const n=this.materialVariantMap.get(e);this.materialVariantMap.set(e,{...n,...t});const r=this.renameClonedAsset(e),l=this.scene.materials.filter(u=>u.name===r);if(l.length===0){o();return}const d=new Se.AssetsManager(this.scene);d.useDefaultLoadingScreen=!1,l.forEach(u=>Ue(t,u,d,a)),d.onProgress=(u,m,f)=>{i&&i(u/m*100,100,f.name)},d.onFinish=u=>{u.forEach(m=>{const f=m;i&&i(100,100,m.name),this.scene.materials.filter(C=>C.name===r).forEach(C=>Qe(m.name,C,t,f.texture))}),o()},d.loadAsync()})}async applyModel(e,t,i,a){var l,d;if(i&&t&&!this.keysThatRemovedBaseModel.includes(e)&&this.keysThatRemovedBaseModel.push(e),!i)return this.keysThatRemovedBaseModel.includes(e)&&this.keysThatRemovedBaseModel.length===1&&await this.setBaseModelEnabled(!0),(l=this.loadedContainerForKey.get(e))==null||l.dispose(),this.loadedContainerForKey.delete(e),this.loadedMaterialsForKey.delete(e),this.keysThatRemovedBaseModel=this.keysThatRemovedBaseModel.filter(u=>u!==e),Promise.resolve(void 0);const n=(await W(i,this.scene,a)).instantiateModelsToScene(this.renameClonedAsset,!0);this.loadedContainerForKey.has(e)&&((d=this.loadedContainerForKey.get(e))==null||d.dispose(),this.loadedContainerForKey.delete(e),this.loadedMaterialsForKey.delete(e)),t&&await this.setBaseModelEnabled(!1),this.loadedContainerForKey.set(e,n),this.loadedMaterialsForKey.set(e,X(n));const r=[];return this.materialVariantMap.forEach(async(u,m)=>{r.push(this.applyMaterial(m,u))}),await Promise.all(r),n}dispose(){this.loadedContainerForKey.forEach(e=>e==null?void 0:e.dispose()),this.loadedContainerForKey.clear(),this.loadedMaterialsForKey.forEach(e=>e.forEach(t=>t==null?void 0:t.dispose())),this.loadedMaterialsForKey.clear(),this.materialVariantMap.clear(),this.keysThatRemovedBaseModel=[]}getAllMaterials(){const e=[];return this.loadedMaterialsForKey.forEach(t=>{t.forEach(i=>{e.includes(i)||e.push(i)})}),e}getAnimationGroups(){const e=[];return this.loadedContainerForKey.forEach(t=>{e.push(...t.animationGroups)}),e}}function X(s){const e=[];return s.rootNodes.forEach(t=>{t.getChildMeshes().forEach(i=>{i.material&&!e.includes(i.material)&&e.push(i.material),i.subMeshes&&i.subMeshes.forEach(a=>{const o=a.getMaterial(!1);o&&!e.includes(o)&&e.push(o)})})}),e}function J(s,e=""){return s.map(t=>({name:t.name.substring(e.length),loop:t.loopAnimation,to:t.to,from:t.from}))}class Ze{constructor(e){this.metadata=new Map,this.materialSelectedObservable=new M.Observable,this.materialDeselectedObservable=new M.Observable,this.materialVariantObservable=new M.Observable,this.modelVariantObservable=new M.Observable,this.materialReadyToLoadCallbacks=new Map,this.modelReadyToLoadCallbacks=new Map,this.dynamicTextures=new Map,this.queuedMaterialChanges=new Map,this.materialChangesInProgress=[],this.queuedModelChanges=new Map,this.modelChangesInProgress=[],this.animations=[],this.initialized=!1,this.materials=[];const{enablePicking:t,modelDetails:i,previewService:a,progressHandler:o,scene:n}=e;this.enablePicking=t,this.contextService=i.contextService,this.id=Ge(),this.previewService=a,this.scene=n,this.variantManager=new $e(n,this.renameClonedAsset.bind(this),this.setBaseModelEnabled.bind(this)),this.transformRoot=new Le.TransformNode("root",this.scene);const r=async()=>{if(!i.model)throw new Error("Model container constructed with no URL. This is currently unsupported.");return this.assetContainer=await W(i.model,n,o),this.initialized=!0,await this.instantiate(),this};this.importPromise=r()}async applyMaterialVariant(e,t,i,a){if(!this.initialized){if(this.materialReadyToLoadCallbacks.has(e)){const n=this.materialReadyToLoadCallbacks.get(e);n==null||n.set(t,this.applyMaterialVariant.bind(this,e,t,i,a))}else{this.materialReadyToLoadCallbacks.set(e,new Map);const n=this.materialReadyToLoadCallbacks.get(e);n==null||n.set(t,this.applyMaterialVariant.bind(this,e,t,i,a))}return}const o=async()=>{await this.variantManager.applyMaterial(e,i,(n,r,l)=>{this.materialVariantObservable.notifyObservers({remainingCount:n,totalCount:r,taskName:l})},a)};if(this.materialChangesInProgress.includes(e)){if(this.queuedMaterialChanges.has(e)){const n=this.queuedMaterialChanges.get(e);n==null||n.set(t,o)}else{this.queuedMaterialChanges.set(e,new Map);const n=this.queuedMaterialChanges.get(e);n==null||n.set(t,o)}return}if(this.materialChangesInProgress.push(e),await o(),this.queuedMaterialChanges.has(e)){const n=this.queuedMaterialChanges.get(e);if(!n)throw new Error("Target material is undefined");n.forEach(async r=>{await r()}),this.queuedMaterialChanges.delete(e)}this.materialChangesInProgress.splice(this.materialChangesInProgress.indexOf(e),1),this.configureGlowLayer()}async applyModelVariant(e,t,i){if(!this.initialized){this.modelReadyToLoadCallbacks.set(e,this.applyModelVariant.bind(this,e,t,i));return}const a=()=>this.variantManager.applyModel(e,i,t==null?void 0:t.model,r=>{this.modelVariantObservable.notifyObservers({...r,key:e})});if(this.modelChangesInProgress.includes(e)){this.queuedModelChanges.set(e,a);return}const n=await(async()=>{this.modelChangesInProgress.push(e);let r=await a();if(this.queuedModelChanges.has(e)){const l=this.queuedModelChanges.get(e);if(!l)throw new Error("Queued change resolved undefined");r=await l(),this.queuedModelChanges.delete(e)}return this.modelChangesInProgress.splice(this.modelChangesInProgress.indexOf(e),1),r})();this.modelInstance&&Z(this.modelInstance.animationGroups),this.contextService||(this.contextService=t==null?void 0:t.contextService),n?this.configureModelInstance(n):this.configureGlowLayer()}dispose(){var e;this.destroyInstance(),this.variantManager.dispose(),this.dynamicTextures.forEach(t=>t==null?void 0:t.dispose()),this.dynamicTextures.clear(),this.materials.forEach(t=>t&&(t==null?void 0:t.dispose())),this.materials=[],(e=this.transformRoot)==null||e.dispose(),this.transformRoot=void 0,this.previewService.modelUnloaded(this)}executeAnimation(e){if(!this.previewService.getInitializationComplete()){this.queuedModelAnimation=e;return}this.modelInstance&&Ne([...this.modelInstance.animationGroups,...this.variantManager.getAnimationGroups()],e.loop,e.to,e.from,e.name?this.renameClonedAsset(e.name):void 0)}getAnimations(e){return[...this.animations,...e?J(this.variantManager.getAnimationGroups(),this.renameClonedAsset("")):[]]}getId(){return this.id}listMaterials(){var t;const e=(t=this.scene)==null?void 0:t.materials.filter(i=>i.name.startsWith(this.id));return e?e.map(i=>({id:i.id,name:this.stripIdFromName(i.name)})):[]}registerMaterialSelectedCallback(e){this.materialSelectedObservable.add(e)}unregisterMaterialSelectedCallback(e){this.materialSelectedObservable.removeCallback(e)}registerMaterialDeselectedCallback(e){this.materialDeselectedObservable.add(e)}unregisterMaterialDeselectedCallback(e){this.materialDeselectedObservable.removeCallback(e)}get position(){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to requesting position!");return this.transformRoot.position}set position(e){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to setting position!");this.transformRoot.position=new g.Vector3(e.x,e.y,e.z)}get rotation(){var e;if(!((e=this.transformRoot)!=null&&e.rotationQuaternion))throw new Error("ModelContainer disposed prior to requesting rotation!");return this.transformRoot.rotationQuaternion.toEulerAngles()}set rotation(e){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to setting rotation!");this.transformRoot.rotationQuaternion=g.Quaternion.FromEulerAngles(e.x,e.y,e.z)}get scale(){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to requesting scale!");return this.transformRoot.scaling}set scale(e){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to setting scale!");this.transformRoot.scaling=new g.Vector3(e.x,e.y,e.z)}attachPickingHandler(e){e.rootNodes.forEach(t=>{t.getChildMeshes(!1).forEach(i=>{i.name==="targetcube_t"||i.name==="backgroundShell"||(i.actionManager||(i.actionManager=new I.ActionManager(this.scene)),i.actionManager.registerAction(new V.ExecuteCodeAction(I.ActionManager.OnPointerOverTrigger,a=>{a.meshUnderPointer&&i.material&&this.materialSelectedObservable.notifyObservers({id:i.material.id,name:this.stripIdFromName(i.material.name)})})),i.actionManager.registerAction(new V.ExecuteCodeAction(I.ActionManager.OnPointerOutTrigger,()=>{i.material&&this.materialDeselectedObservable.notifyObservers({id:i.material.id,name:this.stripIdFromName(i.material.name)})})))})})}getInitializationPromise(){return this.importPromise}getIsInitialized(){return this.initialized}getQueuedMaterialVariantCount(){return this.materialReadyToLoadCallbacks.size}getQueuedModelVariantCount(){return this.modelReadyToLoadCallbacks.size}configureGlowLayer(){const e=i=>i instanceof O.PBRMaterial&&i.emissiveTexture!==null;this.materials.some(e)||this.variantManager.getAllMaterials().some(e)?this.previewService.getGlowLayerManager().includeMeshes(this.getAllMeshes()):this.previewService.getGlowLayerManager().removeMeshes(this.getAllMeshes())}configureModelInstance(e){var o;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,a=this.transformRoot.scaling;this.transformRoot.position=g.Vector3.Zero(),this.transformRoot.rotationQuaternion=g.Quaternion.Identity(),this.transformRoot.scaling=g.Vector3.One();for(const n of e.rootNodes)n.parent=this.transformRoot;this.transformRoot.position=t,this.transformRoot.rotationQuaternion=i,this.transformRoot.scaling=a,this.canvasPanels=((o=this.contextService)==null?void 0:o.getAll())||new Map,je(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 Ae.Mesh)).flat()}async instantiate(){if(!this.assetContainer)throw new Error("Attempted to instantiate ModelContainer without an AssetContainer");this.modelInstance=this.assetContainer.instantiateModelsToScene(this.renameClonedAsset.bind(this),!0),this.materials=X(this.modelInstance),this.configureModelInstance(this.modelInstance),this.animations=J(this.modelInstance.animationGroups,this.renameClonedAsset("")),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 a=this.dynamicTextures.get(i);a&&t.getStaticContextDirty()&&a.isReady()&&(a.update(!1),t.setStaticContextDirty(!1))})}registerMaterialVariantListener(e){this.materialVariantObservable.add(e)}unregisterMaterialVariantListener(e){this.materialVariantObservable.removeCallback(e)}registerModelVariantListener(e){this.modelVariantObservable.add(e)}unregisterModelVariantListener(e){this.modelVariantObservable.removeCallback(e)}stripIdFromName(e){return e.substring(this.id.length+1)}async processQueuedEvents(){await Promise.all(Array.from(this.materialReadyToLoadCallbacks.values()).flatMap(e=>Array.from(e.values()).map(t=>t()))),this.materialReadyToLoadCallbacks.clear(),await Promise.all(Array.from(this.modelReadyToLoadCallbacks.values()).map(e=>e())),this.modelReadyToLoadCallbacks.clear(),this.queuedModelAnimation&&(this.executeAnimation(this.queuedModelAnimation),this.queuedModelAnimation=void 0)}}class F extends y.ArcRotateCamera{constructor(e,t,i,a,o,n,r,l){super(e,t,i,a,o,n,l),this.lastFocus=new g.Vector3(0,0,0),this.panDenominator=1,this.minZ=.01,this.setRadius(this.radius),this.enableFramingBehavior(),this.wheelDeltaPercentage=.01,this.pinchDeltaPercentage=.005,this.useNaturalPinchZoom=!0,r.camera.autoOrientation&&(this.alpha+=Math.PI),r&&(r.camera.limits.min.beta&&(this.lowerBetaLimit=r.camera.limits.min.beta),r.camera.limits.max.beta&&(this.upperBetaLimit=r.camera.limits.max.beta),r.camera.limits.min.alpha&&(this.lowerAlphaLimit=r.camera.limits.min.alpha),r.camera.limits.max.alpha&&(this.upperAlphaLimit=r.camera.limits.max.alpha),r.camera.limits.min.radius&&(this.lowerRadiusLimit=r.camera.limits.min.radius),r.camera.limits.max.radius&&(this.upperRadiusLimit=r.camera.limits.max.radius),r.camera.autoRotation.enabled&&this.enableAutoRotationBehavior(r.camera.autoRotation.idleTimeMs))}getFramingBehavior(){return this.getBehaviorByName("Framing")}getAutoRotationBehavior(){const e=this.getBehaviorByName("AutoRotation");if(e)return e}enableFramingBehavior(){this.useFramingBehavior=!0;const e=this.getFramingBehavior();e.attach(this),e.framingTime=0,e.elevationReturnTime=-1,e.zoomStopsAnimation=!1,this.lowerRadiusLimit=null;const t=B(this._scene);return e.zoomOnBoundingInfo(t.min,t.max),this.wheelPrecision=100/this.radius,this.lowerRadiusLimit===null&&(this.lowerRadiusLimit=.1),this.lastFocus.copyFrom(this.target),e}rerunFramingBehavior(e,t){const i=this.getFramingBehavior();i.framingTime=t||800;const a=()=>{e&&e()},o=B(this._scene),n=o.max.subtract(o.min),r=o.min.add(n.scale(.5));this.setRadius(n.length()*1.5),this.wheelPrecision=100/this.radius,this.panningInertia=0,this.panningOriginTarget.copyFrom(r),this.panDenominator=n.length(),i.zoomOnBoundingInfo(o.min,o.max,void 0,a),i.framingTime=0}enableAutoRotationBehavior(e=5e3){this.useAutoRotationBehavior=!0;const t=this.getAutoRotationBehavior();t&&(t.idleRotationWaitTime=e)}disableAutoRotationBehavior(){this.useAutoRotationBehavior=!1}setRadius(e){this.radius=e,this.maxZ=this.radius*1e3,this.lowerRadiusLimit=this.radius*.01,this.upperRadiusLimit=1.5*this.radius,this.wheelPrecision=100/this.radius,this.pinchPrecision=300/this.radius}static create(e,t,i){const a=B(e),o=a.max.subtract(a.min),n=a.min.add(o.scale(.5)),r=new F("ProductCamera",-(Math.PI/2),Math.PI/2,o.length()*1.5,n,e,t);return r.panningInertia=0,r.panningOriginTarget.copyFrom(n),r.panDenominator=o.length(),r.onAfterCheckInputsObservable.add(()=>{r.panningSensibility=1e3/r.panDenominator}),i&&(e.activeCamera=r),r}}function B(s){if(s.meshes.length===0)return{min:new g.Vector3(-1,-1,-1),max:new g.Vector3(1,1,1)};const e=s.meshes.filter(t=>t.name.toLowerCase().endsWith("_t")||t.name.toLowerCase().includes("_t_"));return s.getWorldExtends(t=>t.isVisible&&t.isEnabled()&&(e.length===0||e.includes(t)))}class Xe{constructor(e,t=!1,i=void 0){this.renderingPipeline=new Fe.DefaultRenderingPipeline("default",t,e,i?[i]:void 0,!1),this.renderingPipeline.isSupported&&(this.renderingPipeline.prepare(),this.setConfiguration(c))}dispose(){this.renderingPipeline.dispose()}getConfiguration(){return this.currentConfiguration}setConfiguration(e){var t,i,a,o,n,r,l,d,u,m,f,b,C,_,ee,te,ie,se,ne,re,ae,oe,le,he,ce,de,ue,ge,me,pe,fe,be,ye;if(this.renderingPipeline.isSupported){if(this.renderingPipeline.samples=((t=e.antiAliasing)==null?void 0:t.samples)??c.antiAliasing.samples,this.renderingPipeline.fxaaEnabled=((i=e.antiAliasing)==null?void 0:i.fxaaEnabled)??c.antiAliasing.fxaaEnabled,this.renderingPipeline.bloomEnabled=((a=e.bloom)==null?void 0:a.enabled)??c.bloom.enabled,this.renderingPipeline.bloomKernel=((o=e.bloom)==null?void 0:o.kernel)??c.bloom.kernel,this.renderingPipeline.bloomScale=((n=e.bloom)==null?void 0:n.scale)??c.bloom.scale,this.renderingPipeline.bloomThreshold=((r=e.bloom)==null?void 0:r.threshold)??c.bloom.threshold,this.renderingPipeline.bloomWeight=((l=e.bloom)==null?void 0:l.weight)??c.bloom.weight,this.renderingPipeline.chromaticAberrationEnabled=((d=e.chromaticAberration)==null?void 0:d.enabled)??c.chromaticAberration.enabled,this.renderingPipeline.chromaticAberration.aberrationAmount=((u=e.chromaticAberration)==null?void 0:u.aberrationAmount)??c.chromaticAberration.aberrationAmount,this.renderingPipeline.chromaticAberration.radialIntensity=((m=e.chromaticAberration)==null?void 0:m.radialIntensity)??c.chromaticAberration.radialIntensity,this.renderingPipeline.chromaticAberration.direction=(f=e.chromaticAberration)!=null&&f.direction?new g.Vector2(e.chromaticAberration.direction.x,e.chromaticAberration.direction.y):new g.Vector2(c.chromaticAberration.direction.x,c.chromaticAberration.direction.y),this.renderingPipeline.imageProcessing.colorCurvesEnabled=((b=e.colorCurves)==null?void 0:b.enabled)??c.colorCurves.enabled,this.renderingPipeline.imageProcessing.colorCurves=e.colorCurves?this.updateColorCurve(e.colorCurves):new z.ColorCurves,this.renderingPipeline.depthOfFieldEnabled=((C=e.depthOfField)==null?void 0:C.enabled)??c.depthOfField.enabled,e.depthOfField)switch(e.depthOfField.blurLevel??c.depthOfField.blurLevel){case"Low":this.renderingPipeline.depthOfFieldBlurLevel=S.DepthOfFieldEffectBlurLevel.Low;break;case"Medium":this.renderingPipeline.depthOfFieldBlurLevel=S.DepthOfFieldEffectBlurLevel.Medium;break;case"High":this.renderingPipeline.depthOfFieldBlurLevel=S.DepthOfFieldEffectBlurLevel.High;break}if(this.renderingPipeline.depthOfField.focalLength=((_=e.depthOfField)==null?void 0:_.focalLength)??c.depthOfField.focalLength,this.renderingPipeline.depthOfField.fStop=((ee=e.depthOfField)==null?void 0:ee.fStop)??c.depthOfField.fStop,this.renderingPipeline.depthOfField.focusDistance=((te=e.depthOfField)==null?void 0:te.focusDistance)??c.depthOfField.focusDistance,this.renderingPipeline.depthOfField.lensSize=((ie=e.depthOfField)==null?void 0:ie.lensSize)??c.depthOfField.lensSize,this.renderingPipeline.grainEnabled=((se=e.grain)==null?void 0:se.enabled)??c.grain.enabled,this.renderingPipeline.grain.animated=((ne=e.grain)==null?void 0:ne.animated)??c.grain.animated,this.renderingPipeline.grain.intensity=((re=e.grain)==null?void 0:re.intensity)??c.grain.intensity,this.renderingPipeline.imageProcessing.contrast=((ae=e.misc)==null?void 0:ae.contrast)??c.misc.contrast,this.renderingPipeline.imageProcessing.exposure=((oe=e.misc)==null?void 0:oe.exposure)??c.misc.exposure,this.renderingPipeline.imageProcessing.toneMappingEnabled=((le=e.misc)==null?void 0:le.toneMappingEnabled)??c.misc.toneMappingEnabled,this.renderingPipeline.imageProcessing.toneMappingEnabled)switch(e.misc.toneMappingType??c.misc.toneMappingType){case"Standard":this.renderingPipeline.imageProcessing.toneMappingType=T.ImageProcessingConfiguration.TONEMAPPING_STANDARD;break;case"ACES":this.renderingPipeline.imageProcessing.toneMappingType=T.ImageProcessingConfiguration.TONEMAPPING_ACES;break}if(this.renderingPipeline.sharpenEnabled=((he=e.sharpen)==null?void 0:he.enabled)??c.sharpen.enabled,this.renderingPipeline.sharpen.colorAmount=((ce=e.sharpen)==null?void 0:ce.colorAmount)??c.sharpen.colorAmount,this.renderingPipeline.sharpen.edgeAmount=((de=e.sharpen)==null?void 0:de.edgeAmount)??c.sharpen.edgeAmount,this.renderingPipeline.imageProcessing.vignetteEnabled=((ue=e.vignette)==null?void 0:ue.enabled)??c.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=c.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=c.vignette.center.y),e.vignette)switch(((me=e.vignette)==null?void 0:me.blendMode)??c.vignette.blendMode){case"Multiply":this.renderingPipeline.imageProcessing.vignetteBlendMode=T.ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY;break;case"Opaque":this.renderingPipeline.imageProcessing.vignetteBlendMode=T.ImageProcessingConfiguration.VIGNETTEMODE_OPAQUE;break}(pe=e.vignette)!=null&&pe.colorRgba?this.renderingPipeline.imageProcessing.vignetteColor=new p.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=p.Color4.FromHexString(e.vignette.colorHex):this.renderingPipeline.imageProcessing.vignetteColor=new p.Color4(c.vignette.colorRgba.r,c.vignette.colorRgba.g,c.vignette.colorRgba.b,c.vignette.colorRgba.a),this.renderingPipeline.imageProcessing.vignetteStretch=((be=e.vignette)==null?void 0:be.stretch)??c.vignette.stretch,this.renderingPipeline.imageProcessing.vignetteWeight=((ye=e.vignette)==null?void 0:ye.weight)??c.vignette.weight,this.renderingPipeline.prepare(),this.currentConfiguration=e}}updateColorCurve(e){const t=new z.ColorCurves;return t.globalDensity=e.globalDensity??t.globalDensity,t.globalExposure=e.globalExposure??t.globalExposure,t.globalHue=e.globalHue??t.globalHue,t.globalSaturation=e.globalSaturation??t.globalSaturation,t.highlightsDensity=e.highlightsDensity??t.highlightsDensity,t.highlightsExposure=e.highlightsExposure??t.highlightsExposure,t.highlightsHue=e.highlightsHue??t.highlightsHue,t.highlightsSaturation=e.highlightsSaturation??t.highlightsSaturation,t.midtonesDensity=e.midtonesDensity??t.midtonesDensity,t.midtonesExposure=e.midtonesExposure??t.midtonesExposure,t.midtonesHue=e.midtonesHue??t.midtonesHue,t.midtonesSaturation=e.midtonesSaturation??t.midtonesSaturation,t.shadowsDensity=e.shadowsDensity??t.shadowsDensity,t.shadowsExposure=e.shadowsExposure??t.shadowsExposure,t.shadowsHue=e.shadowsHue??t.shadowsHue,t.shadowsSaturation=e.shadowsSaturation??t.shadowsSaturation,t}}Pe.GLTF2.GLTFLoader.RegisterExtension("glbPostProcessor",function(s){return new Be(s)}),G.SceneLoader.OnPluginActivatedObservable.add(s=>{if(s.name==="gltf"){const e=s;e.transparencyAsCoverage=!0}});function D(s){return new g.Vector3(s.x,s.y,s.z)}function j(s){return{x:s.x,y:s.y,z:s.z}}class Je{constructor(e){var l;this.focusLostNotified=!1,this.focusLostObservable=new M.Observable,this.modelLoadEventCallbacks=[],this.modelContainers=new Map,this.plugins=[],this.initComplete=!1,this.renderLoop=()=>{this.engine.views&&(this.modelContainers.forEach(d=>{d.updateDynamicTextures()}),this.scene.render(),!this.camera.target.equalsWithEpsilon(this.camera.lastFocus,.1)&&!this.focusLostNotified&&(this.focusLostObservable.notifyObservers(void 0),this.focusLostNotified=!0),this.screenshotPrepareResolve&&(this.screenshotPrepareResolve(),this.screenshotPrepareResolve=void 0))},this.configuration=new H(e);const i=(()=>{if(!(e!=null&&e.noRender))return this.configuration.createCanvas()})(),a="1.5.6";Ce.DracoCompression.Configuration={decoder:{wasmUrl:`https://www.gstatic.com/draco/versioned/decoders/${a}/draco_wasm_wrapper_gltf.js`,wasmBinaryUrl:`https://www.gstatic.com/draco/versioned/decoders/${a}/draco_decoder_gltf.wasm`,fallbackUrl:`https://www.gstatic.com/draco/versioned/decoders/${a}/draco_decoder_gltf.js`}},i&&(i.getContext("webgl2")||i.getContext("webgl"));const o=console.log,n=i?new q.Engine(i,!0,{adaptToDeviceRatio:!0,limitDeviceRatio:2,premultipliedAlpha:!1,preserveDrawingBuffer:!!(e!=null&&e.backgroundImage),audioEngine:!1,stencil:this.configuration.highlights.enabled,forceSRGBBufferSupportState:!0}):new we.NullEngine;console.log=o,n.hideLoadingUI(),window.addEventListener("resize",this.fireResizeEvent.bind(this)),this.engine=n,this.scene=new xe.Scene(n),this.scene.autoClear=!0,this.scene.autoClearDepthAndStencil=!0,this.camera=F.create(this.scene,this.configuration),this.scene.activeCamera=this.camera,this.renderingPipeline=new Xe(this.scene,!1,this.camera),this.scene.clearColor=this.configuration.scene.clearColor;const r=N.CubeTexture.CreateFromPrefilteredData(this.configuration.scene.environment.file,this.scene);r.rotationY=this.configuration.scene.environment.rotationY,this.scene.environmentTexture=r,this.scene.environmentIntensity=this.configuration.scene.environment.intensity,(l=this.configuration.options)!=null&&l.renderingPipelineConfiguration?this.renderingPipeline.setConfiguration(this.configuration.options.renderingPipelineConfiguration):(this.scene.imageProcessingConfiguration.exposure=this.configuration.lighting.exposure,this.scene.imageProcessingConfiguration.contrast=this.configuration.lighting.contrast),this.glowLayerManager=new De(this.scene,this.configuration.emissiveGlowIntensity),this.initPromise=new Promise(d=>{this.scene.onReadyObservable.addOnce(()=>{this.initComplete=!0,d()})}),this.engine.runRenderLoop(this.renderLoop)}getInitializationPromise(){return this.initPromise}getInitializationComplete(){return this.initComplete}getEngineContext(){return{engine:this.engine,scene:this.scene,camera:this.camera}}registerFocusLostListener(e){this.focusLostObservable.add(e)}unregisterFocusLostListener(e){this.focusLostObservable.removeCallback(e)}registerModelLoadEventListener(e){this.modelLoadEventCallbacks.push(e)}unregisterModelLoadEventListener(e){const t=this.modelLoadEventCallbacks.indexOf(e);t>-1&&this.modelLoadEventCallbacks.splice(t,1)}registerView(e){const t=e.height,i=e.width;this.engine.registerView(e,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.camera?console.log("ANIM: DEBUGGING: queueing animation bc wrong camera"):console.log("ANIM: DEBUGGING: queueing animation bc no camera"),this.queuedCameraAnimation=e;return}console.log("ANIM: DEBUGGING: animating camera in scene"),ke(this.scene,this.scene.activeCamera,e),console.log("ANIM: DEBUGGING: animated camera in scene")}getCameraPose(){if(this.scene&&this.camera)return{lonDeg:Math.round(this.camera.alpha*180/Math.PI),latDeg:Math.round(this.camera.beta*180/Math.PI),radius:Math.round((this.camera.radius+Number.EPSILON)*1e4)/1e4,target:{x:this.camera.target.x,y:this.camera.target.y,z:this.camera.target.z}}}setCameraPose(e){this.scene&&this.camera&&(this.camera.target=new g.Vector3(e.target.x,e.target.y,e.target.z),this.camera.radius=e.radius,this.camera.alpha=e.latDeg,this.camera.beta=e.lonDeg)}setCameraState(e){var t,i;if(!((t=this.engine)!=null&&t.views)||!((i=this.engine)!=null&&i.views[0]))throw new Error("No views attached, camera state requires a view to attach controls onto.");e===E.Orbit?this.reattachControls(this.engine.views[0].target,2):this.reattachControls(this.engine.views[0].target,0)}animateToLastCameraFocus(){return new Promise(e=>{const t=()=>{const i=this.configuration;this.camera.rerunFramingBehavior(()=>{this.focusLostNotified=!1,i.camera.limits.min.radius&&(this.camera.lowerRadiusLimit=i.camera.limits.min.radius),i.camera.limits.max.radius&&(this.camera.upperRadiusLimit=i.camera.limits.max.radius),e()})};this.scene.onAfterRenderObservable.addOnce(t)})}setAutoRotation(e){!this.configuration.camera.autoRotation.enabled||!this.camera||(e?this.camera.enableAutoRotationBehavior(this.configuration.camera.autoRotation.idleTimeMs):this.camera.disableAutoRotationBehavior())}getCurrentConfiguration(){return this.configuration.options}async renderSceneScreenshot(e,t){if(!this.camera)throw new Error("Missing product camera, cannot render screenshot!");const i=new y.ArcRotateCamera("screenshotCamera",0,0,0,g.Vector3.Zero(),this.scene);try{const a=t.latDeg*Math.PI/180,o=t.lonDeg*Math.PI/180;i.target=t.target?new g.Vector3(t.target.x,t.target.y,t.target.z):g.Vector3.Zero(),i.alpha=o,i.beta=a,i.radius=t.radius||this.camera.radius,i.minZ=.01,this.scene.render();const n=await Me.Tools.CreateScreenshotUsingRenderTargetAsync(this.engine,i,e,"image/png",2,!0);return i.dispose(),n}catch{throw i.isDisposed()||i.dispose(),new Error("Failed to render screenshot")}}orbitEnabled(){const e=this.configuration;if(!e)return!0;const t=e.camera.limits.min.alpha,i=e.camera.limits.max.alpha,a=e.camera.limits.min.beta,o=e.camera.limits.max.beta;if(t===void 0||i===void 0||a===void 0||o===void 0)return!0;const n=[t,i],r=[a,o],l=n.every(u=>u===t),d=r.every(u=>u===a);return!l&&!d}fireResizeEvent(){this.getNumViewports()>0&&this.engine.resize()}setHighlights(e,t){var a;e.length===0&&((a=this.highlightLayer)==null||a.dispose(),this.highlightLayer=void 0),this.highlightLayer||(this.highlightLayer=new ve.HighlightLayer("highlights",this.scene,{isStroke:!0,blurVerticalSize:.85,blurHorizontalSize:.85}),this.highlightLayer.innerGlow=!0,this.highlightLayer.outerGlow=!1),this.highlightLayer.removeAllMeshes();const i=t?new p.Color3(t[0],t[1],t[2]).toLinearSpace():void 0;e.forEach(o=>{const n=this.scene.materials.find(r=>r.name===o.name&&r.id===o.id);n&&n.getBindedMeshes().forEach(r=>{var l;return(l=this.highlightLayer)==null?void 0:l.addMesh(r,i||p.Color3.FromHexString("#fcba03"))})})}setRenderingPipelineConfiguration(e){this.renderingPipeline&&this.renderingPipeline.setConfiguration(e)}loadModel(e,t){const i=new Ze({enablePicking:this.configuration.highlights.enabled,modelDetails:e,scene:this.scene,previewService:this,progressHandler:t});return i.getInitializationPromise().then(()=>{this.modelContainers.size<=1&&this.camera.rerunFramingBehavior(void 0,1),Ve(this.scene),this.queuedCameraAnimation&&(this.executeCameraAnimation(this.queuedCameraAnimation),this.queuedCameraAnimation=void 0)}),this.configuration.highlights.enabled&&(i.registerMaterialSelectedCallback(a=>{this.setHighlights([a])}),i.registerMaterialDeselectedCallback(()=>{this.setHighlights([])})),this.modelContainers.set(i.getId(),i),this.triggerModelLoadEvent({eventType:"load",modelContainer:i}),i}getAllModels(){return Array.from(this.modelContainers.values())}getModelById(e){return this.modelContainers.get(e)}registerPlugin(e){this.plugins.push(e),e.initialize(this,{camera:this.camera,engine:this.engine,scene:this.scene})}unregisterPlugin(e){const t=this.plugins.indexOf(e);t>-1&&this.plugins.splice(t,1).forEach(a=>a.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 a=g.Matrix.Compose(D(i||{x:1,y:1,z:1}),g.Quaternion.FromEulerVector(D(t||{x:0,y:0,z:0})),D(e||{x:0,y:0,z:0})),o=g.Matrix.RotationAxis(g.Vector3.Up(),Math.PI),n=a.multiply(o),r=g.Vector3.Zero(),l=g.Quaternion.Identity(),d=g.Vector3.Zero();return n.decompose(d,l,r),l.multiplyInPlace(g.Quaternion.FromEulerAngles(0,Math.PI,0)),{position:j(r),rotation:j(l.toEulerAngles()),scale:j(d)}}updatePreviewOptions(e){var a;const t=new H(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=N.CubeTexture.CreateFromPrefilteredData(t.scene.environment.file,this.scene),i.rotationY=this.configuration.scene.environment.rotationY,this.scene.environmentTexture=i),i.rotationY=t.scene.environment.rotationY,this.scene.environmentIntensity=t.scene.environment.intensity,(a=t.options)!=null&&a.renderingPipelineConfiguration?this.renderingPipeline.setConfiguration(t.options.renderingPipelineConfiguration):(this.scene.imageProcessingConfiguration.exposure=t.lighting.exposure,this.scene.imageProcessingConfiguration.contrast=t.lighting.contrast),this.glowLayerManager.setIntensity(t.emissiveGlowIntensity),this.configuration=t}reattachControls(e,t=2){if(this.scene.detachControl(),this.engine.inputElement=e,this.camera){this.camera.attachControl(!0,!1,t);const i=this.camera.inputs.attached.pointers;i.multiTouchPanning=!1}this.scene.attachControl(!0,!0,!0)}}h.MaterialEffectMode=R,h.ProductCameraRig=E,h.REFLECTION_PROBE_RESOLUTION=U,h.RenderingConfiguration=v,h.SpiffCommerce3DPreviewService=Je,h.renderingPipelineDefaults=c,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spiffcommerce/preview",
3
- "version": "5.3.5-3",
3
+ "version": "5.3.5-4",
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",