@spiffcommerce/preview 5.3.5-1 → 5.3.5-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -10,25 +10,25 @@ import { DracoCompression as Me } from "@babylonjs/core/Meshes/Compression/draco
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 Te } from "@babylonjs/loaders/glTF";
13
+ import { GLTF2 as Ae } from "@babylonjs/loaders/glTF";
14
14
  import { PBRMaterial as F } from "@babylonjs/core/Materials/PBR/pbrMaterial";
15
- import { MirrorTexture as Re } from "@babylonjs/core/Materials/Textures/mirrorTexture";
16
- import { Color3 as Ae, Vector3 as ne, Plane as Ee } from "@babylonjs/core/Maths/math";
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
17
  import { ReflectionProbe as Oe } from "@babylonjs/core/Probes/reflectionProbe";
18
- import { GlowLayer as Le } from "@babylonjs/core/Layers/glowLayer";
19
- import { ActionManager as R } from "@babylonjs/core/Actions/actionManager";
18
+ import { GlowLayer as Ie } from "@babylonjs/core/Layers/glowLayer";
19
+ import { ActionManager as T } from "@babylonjs/core/Actions/actionManager";
20
20
  import { ExecuteCodeAction as re } from "@babylonjs/core/Actions/directActions";
21
- import { Mesh as Ie } from "@babylonjs/core/Meshes/mesh";
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";
24
24
  import { Texture as Be } from "@babylonjs/core/Materials/Textures/texture";
25
25
  import { Animation as v } from "@babylonjs/core/Animations/animation";
26
- import { QuadraticEase as De, EasingFunction as ke } from "@babylonjs/core/Animations/easing";
27
- import { AssetsManager as ze } from "@babylonjs/core/Misc/assetsManager";
26
+ import { QuadraticEase as De, EasingFunction as Ge } from "@babylonjs/core/Animations/easing";
27
+ import { AssetsManager as Ne } from "@babylonjs/core/Misc/assetsManager";
28
28
  import { ColorCurves as ae } from "@babylonjs/core/Materials/colorCurves";
29
29
  import { ImageProcessingConfiguration as P } from "@babylonjs/core/Materials/imageProcessingConfiguration";
30
- import { DefaultRenderingPipeline as Ve } from "@babylonjs/core/PostProcesses/RenderPipeline";
31
- import { DepthOfFieldEffectBlurLevel as A } from "@babylonjs/core/PostProcesses/depthOfFieldEffect";
30
+ import { DefaultRenderingPipeline as ke } from "@babylonjs/core/PostProcesses/RenderPipeline";
31
+ import { DepthOfFieldEffectBlurLevel as E } 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,7 +39,7 @@ 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 I = /* @__PURE__ */ ((s) => (s[s.Orbit = 0] = "Orbit", s[s.Pan = 1] = "Pan", s))(I || {}), S = /* @__PURE__ */ ((s) => (s.None = "None", s.RemoveWhenSelected = "RemoveWhenSelected", s.ApplyWhenSelected = "ApplyWhenSelected", s))(S || {});
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
43
  class oe {
44
44
  constructor(e) {
45
45
  this.getSceneClearColor = () => {
@@ -181,7 +181,7 @@ class x {
181
181
  }
182
182
  }
183
183
  }
184
- const Ge = 128, h = {
184
+ const ze = 128, h = {
185
185
  antiAliasing: {
186
186
  samples: 4,
187
187
  fxaaEnabled: !1
@@ -238,7 +238,7 @@ const Ge = 128, h = {
238
238
  weight: 1
239
239
  }
240
240
  };
241
- class Ne {
241
+ class Ve {
242
242
  constructor(e) {
243
243
  this.name = "glbPostProcessor", this.enabled = !0, this.loader = e;
244
244
  }
@@ -289,7 +289,7 @@ class Ne {
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 Ae(
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(
293
293
  e.extras.translucencyR,
294
294
  e.extras.translucencyG,
295
295
  e.extras.translucencyB
@@ -327,7 +327,7 @@ class Ne {
327
327
  const r = o.material;
328
328
  if (!r)
329
329
  return;
330
- const l = new Re(
330
+ const l = new Te(
331
331
  "mirror",
332
332
  x.getMirrorTextureResolution(),
333
333
  e,
@@ -343,7 +343,7 @@ class Ne {
343
343
  const d = o.getWorldMatrix(), u = ne.TransformNormal(
344
344
  new ne(c[0], c[1], c[2]),
345
345
  d
346
- ).normalize(), g = Ee.FromPositionAndNormal(
346
+ ).normalize(), g = Re.FromPositionAndNormal(
347
347
  o.position,
348
348
  u.scale(-1)
349
349
  );
@@ -352,7 +352,7 @@ class Ne {
352
352
  function a(o) {
353
353
  const n = o.material, r = new Oe(
354
354
  "probe-" + n.name,
355
- Ge,
355
+ ze,
356
356
  e
357
357
  );
358
358
  r.attachToMesh(o), r.renderList && r.renderList.push(...t(e)), n.reflectionTexture = r.cubeTexture;
@@ -363,7 +363,7 @@ class Ne {
363
363
  });
364
364
  }
365
365
  }
366
- class He {
366
+ class qe {
367
367
  constructor(e, t) {
368
368
  this.scene = e, this.intensity = t, this.meshCount = 0;
369
369
  }
@@ -372,7 +372,7 @@ class He {
372
372
  }
373
373
  includeMeshes(e) {
374
374
  if (e) {
375
- this.glowLayer || (this.glowLayer = new Le("glow", this.scene), this.glowLayer.intensity = this.intensity);
375
+ this.glowLayer || (this.glowLayer = new Ie("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
  }
@@ -400,7 +400,7 @@ async function be(s, e, t) {
400
400
  return le.set(s, a), a;
401
401
  }
402
402
  }
403
- function qe(s, e, t, i, a = "") {
403
+ function He(s, e, t, i, a = "") {
404
404
  t.forEach((o) => {
405
405
  const n = o.getID(), r = o.getName(), l = x.getDynamicTextureResolution();
406
406
  s.filter((d) => d.name === a + r).forEach((d) => {
@@ -443,7 +443,7 @@ function he(s, e) {
443
443
  i && (e.wrapU = i.wrapU, e.wrapV = i.wrapV), t.diffuseTexture = e;
444
444
  }
445
445
  }
446
- function Ke() {
446
+ 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
  }
@@ -451,7 +451,7 @@ const M = 60, ce = 1;
451
451
  function de(s) {
452
452
  return s.targetedAnimations.map((t) => t.animation.framePerSecond).reduce((t, i) => t + i, 0) / s.targetedAnimations.length || 0;
453
453
  }
454
- function We(s, e, t, i, a) {
454
+ function Ke(s, e, t, i, a) {
455
455
  const o = a ? s.filter((n) => n.name === a) : s;
456
456
  if (o.length === 0) {
457
457
  console.warn(`No animations found for name: ${a}`);
@@ -476,15 +476,15 @@ function ve(s) {
476
476
  e.stop();
477
477
  });
478
478
  }
479
- function Ue(s) {
479
+ function We(s) {
480
480
  const e = s.animationGroups;
481
481
  ve(e);
482
482
  }
483
483
  function Ye(s, e, t) {
484
- 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 = Qe(e.alpha, 0, 2 * Math.PI));
485
485
  const i = [], a = t.target, o = 0, n = a ? 1 : 0;
486
486
  if (t.target && Object.keys(t.target).length > 0 && i.push(
487
- T(
487
+ A(
488
488
  "cameraTargetLerp",
489
489
  "target",
490
490
  new m().copyFrom(e.target),
@@ -497,7 +497,7 @@ function Ye(s, e, t) {
497
497
  o
498
498
  )
499
499
  ), i.push(
500
- T(
500
+ A(
501
501
  "cameraAlphaLerp",
502
502
  "alpha",
503
503
  e.alpha,
@@ -506,7 +506,7 @@ function Ye(s, e, t) {
506
506
  n
507
507
  )
508
508
  ), i.push(
509
- T(
509
+ A(
510
510
  "cameraBetaLerp",
511
511
  "beta",
512
512
  e.beta,
@@ -517,7 +517,7 @@ function Ye(s, e, t) {
517
517
  ), t.radius !== void 0) {
518
518
  const c = Math.max(0.01, t.radius);
519
519
  i.push(
520
- T(
520
+ A(
521
521
  "cameraRadiusLerp",
522
522
  "radius",
523
523
  e.radius,
@@ -529,7 +529,7 @@ function Ye(s, e, t) {
529
529
  }
530
530
  e.animations.push(...i);
531
531
  const l = e.useAutoRotationBehavior;
532
- e.disableAutoRotationBehavior(), s.beginAnimation(
532
+ e.disableAutoRotationBehavior(), console.log("ANIM DEBUGGING: beginning animation"), s.beginAnimation(
533
533
  e,
534
534
  0,
535
535
  a ? M * 2 : M,
@@ -543,9 +543,9 @@ function Ye(s, e, t) {
543
543
  function ue(s) {
544
544
  return s * Math.PI / 180;
545
545
  }
546
- function T(s, e, t, i, a, o = 0, n = v.ANIMATIONLOOPMODE_CONSTANT) {
546
+ function A(s, e, t, i, a, o = 0, n = v.ANIMATIONLOOPMODE_CONSTANT) {
547
547
  const r = new De();
548
- r.setEasingMode(ke.EASINGMODE_EASEINOUT);
548
+ r.setEasingMode(Ge.EASINGMODE_EASEINOUT);
549
549
  const l = new v(
550
550
  s,
551
551
  e,
@@ -652,7 +652,7 @@ class tt {
652
652
  o();
653
653
  return;
654
654
  }
655
- const c = new ze(this.scene);
655
+ const c = new Ne(this.scene);
656
656
  c.useDefaultLoadingScreen = !1, l.forEach(
657
657
  (d) => $e(
658
658
  t,
@@ -751,7 +751,7 @@ class it {
751
751
  progressHandler: o,
752
752
  scene: n
753
753
  } = e;
754
- this.enablePicking = t, this.contextService = i.contextService, this.id = Ke(), this.previewService = a, this.scene = n, this.variantManager = new tt(
754
+ this.enablePicking = t, this.contextService = i.contextService, this.id = Ue(), this.previewService = a, this.scene = n, this.variantManager = new tt(
755
755
  n,
756
756
  this.renameClonedAsset.bind(this),
757
757
  this.setBaseModelEnabled.bind(this)
@@ -897,7 +897,7 @@ class it {
897
897
  this.queuedModelAnimation = e;
898
898
  return;
899
899
  }
900
- this.modelInstance && We(
900
+ this.modelInstance && Ke(
901
901
  [
902
902
  ...this.modelInstance.animationGroups,
903
903
  ...this.variantManager.getAnimationGroups()
@@ -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 R(this.scene)), i.actionManager.registerAction(
986
- new re(R.OnPointerOverTrigger, (a) => {
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) => {
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(R.OnPointerOutTrigger, () => {
993
+ new re(T.OnPointerOutTrigger, () => {
994
994
  i.material && this.materialDeselectedObservable.notifyObservers({
995
995
  id: i.material.id,
996
996
  name: this.stripIdFromName(i.material.name)
@@ -1032,7 +1032,7 @@ class it {
1032
1032
  this.transformRoot.position = m.Zero(), this.transformRoot.rotationQuaternion = y.Identity(), this.transformRoot.scaling = m.One();
1033
1033
  for (const n of e.rootNodes)
1034
1034
  n.parent = this.transformRoot;
1035
- this.transformRoot.position = t, this.transformRoot.rotationQuaternion = i, this.transformRoot.scaling = a, this.canvasPanels = ((o = this.contextService) == null ? void 0 : o.getAll()) || /* @__PURE__ */ new Map(), qe(
1035
+ this.transformRoot.position = t, this.transformRoot.rotationQuaternion = i, this.transformRoot.scaling = a, this.canvasPanels = ((o = this.contextService) == null ? void 0 : o.getAll()) || /* @__PURE__ */ new Map(), He(
1036
1036
  this.materials.concat(this.variantManager.getAllMaterials()),
1037
1037
  this.scene,
1038
1038
  this.canvasPanels,
@@ -1050,7 +1050,7 @@ class it {
1050
1050
  getAllMeshes() {
1051
1051
  var e;
1052
1052
  return (e = this.modelInstance) == null ? void 0 : e.rootNodes.map(
1053
- (t) => t.getChildMeshes(!1).filter((i) => i instanceof Ie)
1053
+ (t) => t.getChildMeshes(!1).filter((i) => i instanceof Le)
1054
1054
  ).flat();
1055
1055
  }
1056
1056
  async instantiate() {
@@ -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 = E(this._scene);
1151
+ const t = R(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 = E(this._scene), n = o.max.subtract(o.min), r = o.min.add(n.scale(0.5));
1164
+ }, o = R(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 = E(e), o = a.max.subtract(a.min), n = a.min.add(o.scale(0.5)), r = new B(
1199
+ const a = R(e), o = a.max.subtract(a.min), n = a.min.add(o.scale(0.5)), r = new B(
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 E(s) {
1213
+ function R(s) {
1214
1214
  if (s.meshes.length === 0)
1215
1215
  return {
1216
1216
  min: new m(-1, -1, -1),
@@ -1221,7 +1221,7 @@ function E(s) {
1221
1221
  }
1222
1222
  class st {
1223
1223
  constructor(e, t = !1, i = void 0) {
1224
- this.renderingPipeline = new Ve(
1224
+ this.renderingPipeline = new ke(
1225
1225
  "default",
1226
1226
  t,
1227
1227
  e,
@@ -1237,7 +1237,7 @@ 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, k, z, V, G, N, H, q, _, K, W, U, Y, Q, Z, $, j, X, J, ee;
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;
1241
1241
  if (this.renderingPipeline.isSupported) {
1242
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(
1243
1243
  e.chromaticAberration.direction.x,
@@ -1248,16 +1248,16 @@ class st {
1248
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)
1249
1249
  switch (e.depthOfField.blurLevel ?? h.depthOfField.blurLevel) {
1250
1250
  case "Low":
1251
- this.renderingPipeline.depthOfFieldBlurLevel = A.Low;
1251
+ this.renderingPipeline.depthOfFieldBlurLevel = E.Low;
1252
1252
  break;
1253
1253
  case "Medium":
1254
- this.renderingPipeline.depthOfFieldBlurLevel = A.Medium;
1254
+ this.renderingPipeline.depthOfFieldBlurLevel = E.Medium;
1255
1255
  break;
1256
1256
  case "High":
1257
- this.renderingPipeline.depthOfFieldBlurLevel = A.High;
1257
+ this.renderingPipeline.depthOfFieldBlurLevel = E.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 = ((k = e.depthOfField) == null ? void 0 : k.fStop) ?? h.depthOfField.fStop, this.renderingPipeline.depthOfField.focusDistance = ((z = e.depthOfField) == null ? void 0 : z.focusDistance) ?? h.depthOfField.focusDistance, this.renderingPipeline.depthOfField.lensSize = ((V = e.depthOfField) == null ? void 0 : V.lensSize) ?? h.depthOfField.lensSize, this.renderingPipeline.grainEnabled = ((G = e.grain) == null ? void 0 : G.enabled) ?? h.grain.enabled, this.renderingPipeline.grain.animated = ((N = e.grain) == null ? void 0 : N.animated) ?? h.grain.animated, this.renderingPipeline.grain.intensity = ((H = e.grain) == null ? void 0 : H.intensity) ?? h.grain.intensity, this.renderingPipeline.imageProcessing.contrast = ((q = e.misc) == null ? void 0 : q.contrast) ?? h.misc.contrast, this.renderingPipeline.imageProcessing.exposure = ((_ = e.misc) == null ? void 0 : _.exposure) ?? h.misc.exposure, this.renderingPipeline.imageProcessing.toneMappingEnabled = ((K = e.misc) == null ? void 0 : K.toneMappingEnabled) ?? h.misc.toneMappingEnabled, this.renderingPipeline.imageProcessing.toneMappingEnabled)
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)
1261
1261
  switch (e.misc.toneMappingType ?? h.misc.toneMappingType) {
1262
1262
  case "Standard":
1263
1263
  this.renderingPipeline.imageProcessing.toneMappingType = P.TONEMAPPING_STANDARD;
@@ -1266,7 +1266,7 @@ class st {
1266
1266
  this.renderingPipeline.imageProcessing.toneMappingType = P.TONEMAPPING_ACES;
1267
1267
  break;
1268
1268
  }
1269
- if (this.renderingPipeline.sharpenEnabled = ((W = e.sharpen) == null ? void 0 : W.enabled) ?? h.sharpen.enabled, this.renderingPipeline.sharpen.colorAmount = ((U = e.sharpen) == null ? void 0 : U.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)
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
1270
  switch ((($ = e.vignette) == null ? void 0 : $.blendMode) ?? h.vignette.blendMode) {
1271
1271
  case "Multiply":
1272
1272
  this.renderingPipeline.imageProcessing.vignetteBlendMode = P.VIGNETTEMODE_MULTIPLY;
@@ -1293,8 +1293,8 @@ class st {
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
- Te.GLTFLoader.RegisterExtension("glbPostProcessor", function(s) {
1297
- return new Ne(s);
1296
+ Ae.GLTFLoader.RegisterExtension("glbPostProcessor", function(s) {
1297
+ return new Ve(s);
1298
1298
  });
1299
1299
  fe.OnPluginActivatedObservable.add((s) => {
1300
1300
  if (s.name === "gltf") {
@@ -1305,10 +1305,10 @@ fe.OnPluginActivatedObservable.add((s) => {
1305
1305
  function O(s) {
1306
1306
  return new m(s.x, s.y, s.z);
1307
1307
  }
1308
- function L(s) {
1308
+ function I(s) {
1309
1309
  return { x: s.x, y: s.y, z: s.z };
1310
1310
  }
1311
- class Wt {
1311
+ class Kt {
1312
1312
  constructor(e) {
1313
1313
  var l;
1314
1314
  this.focusLostNotified = !1, this.focusLostObservable = new C(), this.modelLoadEventCallbacks = [], this.modelContainers = /* @__PURE__ */ new Map(), this.plugins = [], this.initComplete = !1, this.renderLoop = () => {
@@ -1327,10 +1327,7 @@ class Wt {
1327
1327
  fallbackUrl: `https://www.gstatic.com/draco/versioned/decoders/${a}/draco_decoder_gltf.js`
1328
1328
  }
1329
1329
  }, i && (i.getContext("webgl2") || i.getContext("webgl"));
1330
- const o = console.log;
1331
- console.log = () => {
1332
- };
1333
- const n = i ? new pe(i, !0, {
1330
+ const o = console.log, n = i ? new pe(i, !0, {
1334
1331
  adaptToDeviceRatio: !0,
1335
1332
  limitDeviceRatio: 2,
1336
1333
  premultipliedAlpha: !1,
@@ -1350,7 +1347,7 @@ class Wt {
1350
1347
  );
1351
1348
  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(
1352
1349
  this.configuration.options.renderingPipelineConfiguration
1353
- ) : (this.scene.imageProcessingConfiguration.exposure = this.configuration.lighting.exposure, this.scene.imageProcessingConfiguration.contrast = this.configuration.lighting.contrast), this.glowLayerManager = new He(
1350
+ ) : (this.scene.imageProcessingConfiguration.exposure = this.configuration.lighting.exposure, this.scene.imageProcessingConfiguration.contrast = this.configuration.lighting.contrast), this.glowLayerManager = new qe(
1354
1351
  this.scene,
1355
1352
  this.configuration.emissiveGlowIntensity
1356
1353
  ), this.initPromise = new Promise((c) => {
@@ -1387,7 +1384,7 @@ class Wt {
1387
1384
  }
1388
1385
  registerView(e) {
1389
1386
  const t = e.height, i = e.width;
1390
- this.engine.registerView(e, void 0, !0), e.setAttribute("height", t.toString()), e.setAttribute("width", i.toString()), this.orbitEnabled() || this.setCameraState(I.Pan), this.reattachControls(e);
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);
1391
1388
  }
1392
1389
  getNumViewports() {
1393
1390
  var e;
@@ -1401,14 +1398,14 @@ class Wt {
1401
1398
  }
1402
1399
  executeCameraAnimation(e) {
1403
1400
  if (!this.camera || this.scene.activeCamera !== this.camera) {
1404
- this.queuedCameraAnimation = e;
1401
+ this.camera ? console.log("ANIM: DEBUGGING: queueing animation bc wrong camera") : console.log("ANIM: DEBUGGING: queueing animation bc no camera"), this.queuedCameraAnimation = e;
1405
1402
  return;
1406
1403
  }
1407
- Ye(
1404
+ console.log("ANIM: DEBUGGING: animating camera in scene"), Ye(
1408
1405
  this.scene,
1409
1406
  this.scene.activeCamera,
1410
1407
  e
1411
- );
1408
+ ), console.log("ANIM: DEBUGGING: animated camera in scene");
1412
1409
  }
1413
1410
  getCameraPose() {
1414
1411
  if (this.scene && this.camera)
@@ -1436,7 +1433,7 @@ class Wt {
1436
1433
  throw new Error(
1437
1434
  "No views attached, camera state requires a view to attach controls onto."
1438
1435
  );
1439
- e === I.Orbit ? this.reattachControls(this.engine.views[0].target, 2) : this.reattachControls(this.engine.views[0].target, 0);
1436
+ e === L.Orbit ? this.reattachControls(this.engine.views[0].target, 2) : this.reattachControls(this.engine.views[0].target, 0);
1440
1437
  }
1441
1438
  animateToLastCameraFocus() {
1442
1439
  return new Promise((e) => {
@@ -1532,7 +1529,7 @@ class Wt {
1532
1529
  progressHandler: t
1533
1530
  });
1534
1531
  return i.getInitializationPromise().then(() => {
1535
- this.modelContainers.size <= 1 && this.camera.rerunFramingBehavior(void 0, 1), Ue(this.scene), this.queuedCameraAnimation && (this.executeCameraAnimation(this.queuedCameraAnimation), this.queuedCameraAnimation = void 0);
1532
+ this.modelContainers.size <= 1 && this.camera.rerunFramingBehavior(void 0, 1), We(this.scene), this.queuedCameraAnimation && (this.executeCameraAnimation(this.queuedCameraAnimation), this.queuedCameraAnimation = void 0);
1536
1533
  }), this.configuration.highlights.enabled && (i.registerMaterialSelectedCallback((a) => {
1537
1534
  this.setHighlights([a]);
1538
1535
  }), i.registerMaterialDeselectedCallback(() => {
@@ -1583,9 +1580,9 @@ class Wt {
1583
1580
  O(e || { x: 0, y: 0, z: 0 })
1584
1581
  ), o = se.RotationAxis(m.Up(), Math.PI), n = a.multiply(o), r = m.Zero(), l = y.Identity(), c = m.Zero();
1585
1582
  return n.decompose(c, l, r), l.multiplyInPlace(y.FromEulerAngles(0, Math.PI, 0)), {
1586
- position: L(r),
1587
- rotation: L(l.toEulerAngles()),
1588
- scale: L(c)
1583
+ position: I(r),
1584
+ rotation: I(l.toEulerAngles()),
1585
+ scale: I(c)
1589
1586
  };
1590
1587
  }
1591
1588
  updatePreviewOptions(e) {
@@ -1616,9 +1613,9 @@ class Wt {
1616
1613
  }
1617
1614
  export {
1618
1615
  S as MaterialEffectMode,
1619
- I as ProductCameraRig,
1620
- Ge as REFLECTION_PROBE_RESOLUTION,
1616
+ L as ProductCameraRig,
1617
+ ze as REFLECTION_PROBE_RESOLUTION,
1621
1618
  x as RenderingConfiguration,
1622
- Wt as SpiffCommerce3DPreviewService,
1619
+ Kt as SpiffCommerce3DPreviewService,
1623
1620
  h as renderingPipelineDefaults
1624
1621
  };
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,Re,Ae,O,k,Ee,Le,Oe,Ie,w,z,Se,N,T,Fe,I){"use strict";var R=(s=>(s[s.Orbit=0]="Orbit",s[s.Pan=1]="Pan",s))(R||{}),A=(s=>(s.None="None",s.RemoveWhenSelected="RemoveWhenSelected",s.ApplyWhenSelected="ApplyWhenSelected",s))(A||{});class G{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 Re.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 Ae.GlowLayer("glow",this.scene),this.glowLayer.intensity=this.intensity);for(const t of e)this.glowLayer.hasMesh(t)||(this.glowLayer.addIncludedOnlyMesh(t),this.meshCount++)}}removeMeshes(e){if(!(!this.glowLayer||!e)){for(const t of e)this.glowLayer.hasMesh(t)&&(this.glowLayer.removeIncludedOnlyMesh(t),this.meshCount--);this.meshCount===0&&(this.glowLayer.dispose(),this.glowLayer=void 0)}}}const K=new Map;async function U(s,e,t){const i=K.get(s);if(i&&i.scene.uid===e.uid)return i;{const a=await q.SceneLoader.LoadAssetContainerAsync(s,void 0,e,t);return K.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 ke(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 ze(s){const e=s.animationGroups;Z(e)}function Ne(s,e,t){s.stopAnimation(e),e.animations=[],Math.abs(e.alpha)>2*Math.PI&&(e.alpha=Ge(e.alpha,0,2*Math.PI));const i=[],a=t.target,o=0,n=a?1:0;if(t.target&&Object.keys(t.target).length>0&&i.push(E("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(E("cameraAlphaLerp","alpha",e.alpha,$(t.lonDeg),w.Animation.ANIMATIONTYPE_FLOAT,n)),i.push(E("cameraBetaLerp","beta",e.beta,$(t.latDeg),w.Animation.ANIMATIONTYPE_FLOAT,n)),t.radius!==void 0){const d=Math.max(.01,t.radius);i.push(E("cameraRadiusLerp","radius",e.radius,d,w.Animation.ANIMATIONTYPE_FLOAT,n))}e.animations.push(...i);const l=e.useAutoRotationBehavior;e.disableAutoRotationBehavior(),s.beginAnimation(e,0,a?x*2:x,!1,1,()=>{e.animations=[],l&&e.enableAutoRotationBehavior()})}function $(s){return s*Math.PI/180}function E(s,e,t,i,a,o=0,n=w.Animation.ANIMATIONLOOPMODE_CONSTANT){const r=new z.QuadraticEase;r.setEasingMode(z.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 Ge(s,e,t){return s<e?s=t-(e-s)%(t-e):s=e+(s-e)%(t-e)}const He={albedoTexture:"albedoMap",bumpTexture:"normalMap",ambientTexture:"ambientMap",emissiveTexture:"emissionMap",opacityTexture:"alphaMap",metallicTexture:"metallicMap",refractionTexture:"refractionMap",reflectionTexture:"reflectionMap"};function Ke(s,e,t,i){["albedoTexture","bumpTexture","ambientTexture","emissiveTexture","opacityTexture","metallicTexture","refractionTexture","reflectionTexture"].forEach(o=>{Ue(o,s,e,t,i)}),Ye(s,e)}function Ue(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===A.RemoveWhenSelected?(e.clearCoat.isEnabled=!1,e.clearCoat.indexOfRefraction=1.5):s.clearCoat===A.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=>Ke(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 U(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 U(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&&ke([...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 k.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 k.ExecuteCodeAction(O.ActionManager.OnPointerOutTrigger,()=>{i.material&&this.materialDeselectedObservable.notifyObservers({id:i.material.id,name:this.stripIdFromName(i.material.name)})})))})})}getInitializationPromise(){return this.importPromise}getIsInitialized(){return this.initialized}getQueuedMaterialVariantCount(){return this.materialReadyToLoadCallbacks.size}getQueuedModelVariantCount(){return this.modelReadyToLoadCallbacks.size}configureGlowLayer(){const e=i=>i instanceof L.PBRMaterial&&i.emissiveTexture!==null;this.materials.some(e)||this.variantManager.getAllMaterials().some(e)?this.previewService.getGlowLayerManager().includeMeshes(this.getAllMeshes()):this.previewService.getGlowLayerManager().removeMeshes(this.getAllMeshes())}configureModelInstance(e){var 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 Ee.Mesh)).flat()}async instantiate(){if(!this.assetContainer)throw new Error("Attempted to instantiate ModelContainer without an AssetContainer");this.modelInstance=this.assetContainer.instantiateModelsToScene(this.renameClonedAsset.bind(this),!0),this.materials=X(this.modelInstance),this.configureModelInstance(this.modelInstance),this.animations=J(this.modelInstance.animationGroups,this.renameClonedAsset("")),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 N.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 N.ColorCurves;return t.globalDensity=e.globalDensity??t.globalDensity,t.globalExposure=e.globalExposure??t.globalExposure,t.globalHue=e.globalHue??t.globalHue,t.globalSaturation=e.globalSaturation??t.globalSaturation,t.highlightsDensity=e.highlightsDensity??t.highlightsDensity,t.highlightsExposure=e.highlightsExposure??t.highlightsExposure,t.highlightsHue=e.highlightsHue??t.highlightsHue,t.highlightsSaturation=e.highlightsSaturation??t.highlightsSaturation,t.midtonesDensity=e.midtonesDensity??t.midtonesDensity,t.midtonesExposure=e.midtonesExposure??t.midtonesExposure,t.midtonesHue=e.midtonesHue??t.midtonesHue,t.midtonesSaturation=e.midtonesSaturation??t.midtonesSaturation,t.shadowsDensity=e.shadowsDensity??t.shadowsDensity,t.shadowsExposure=e.shadowsExposure??t.shadowsExposure,t.shadowsHue=e.shadowsHue??t.shadowsHue,t.shadowsSaturation=e.shadowsSaturation??t.shadowsSaturation,t}}Pe.GLTF2.GLTFLoader.RegisterExtension("glbPostProcessor",function(s){return new Be(s)}),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 G(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;console.log=()=>{};const n=i?new D.Engine(i,!0,{adaptToDeviceRatio:!0,limitDeviceRatio:2,premultipliedAlpha:!1,preserveDrawingBuffer:!!(e!=null&&e.backgroundImage),audioEngine:!1,stencil:this.configuration.highlights.enabled,forceSRGBBufferSupportState:!0}):new 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(R.Pan),this.reattachControls(e)}getNumViewports(){var e;return((e=this.engine.views)==null?void 0:e.length)||0}unregisterView(e){this.engine.unRegisterView(e)}shutdown(){this.plugins.forEach(e=>e.dispose(!0)),this.renderingPipeline.dispose(),this.engine&&this.engine.dispose(),window.removeEventListener("resize",this.fireResizeEvent)}executeCameraAnimation(e){if(!this.camera||this.scene.activeCamera!==this.camera){this.queuedCameraAnimation=e;return}Ne(this.scene,this.scene.activeCamera,e)}getCameraPose(){if(this.scene&&this.camera)return{lonDeg:Math.round(this.camera.alpha*180/Math.PI),latDeg:Math.round(this.camera.beta*180/Math.PI),radius:Math.round((this.camera.radius+Number.EPSILON)*1e4)/1e4,target:{x:this.camera.target.x,y:this.camera.target.y,z:this.camera.target.z}}}setCameraPose(e){this.scene&&this.camera&&(this.camera.target=new g.Vector3(e.target.x,e.target.y,e.target.z),this.camera.radius=e.radius,this.camera.alpha=e.latDeg,this.camera.beta=e.lonDeg)}setCameraState(e){var t,i;if(!((t=this.engine)!=null&&t.views)||!((i=this.engine)!=null&&i.views[0]))throw new Error("No views attached, camera state requires a view to attach controls onto.");e===R.Orbit?this.reattachControls(this.engine.views[0].target,2):this.reattachControls(this.engine.views[0].target,0)}animateToLastCameraFocus(){return new Promise(e=>{const t=()=>{const i=this.configuration;this.camera.rerunFramingBehavior(()=>{this.focusLostNotified=!1,i.camera.limits.min.radius&&(this.camera.lowerRadiusLimit=i.camera.limits.min.radius),i.camera.limits.max.radius&&(this.camera.upperRadiusLimit=i.camera.limits.max.radius),e()})};this.scene.onAfterRenderObservable.addOnce(t)})}setAutoRotation(e){!this.configuration.camera.autoRotation.enabled||!this.camera||(e?this.camera.enableAutoRotationBehavior(this.configuration.camera.autoRotation.idleTimeMs):this.camera.disableAutoRotationBehavior())}getCurrentConfiguration(){return this.configuration.options}async renderSceneScreenshot(e,t){if(!this.camera)throw new Error("Missing product camera, cannot render screenshot!");const i=new y.ArcRotateCamera("screenshotCamera",0,0,0,g.Vector3.Zero(),this.scene);try{const 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),ze(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 G(e);this.configuration.highlights.enabled!==t.highlights.enabled&&this.engine.setStencilBuffer(t.highlights.enabled),this.scene.clearColor=t.scene.clearColor;let i=this.scene.environmentTexture;this.configuration.scene.environment.file!==t.scene.environment.file&&(i=V.CubeTexture.CreateFromPrefilteredData(t.scene.environment.file,this.scene),i.rotationY=this.configuration.scene.environment.rotationY,this.scene.environmentTexture=i),i.rotationY=t.scene.environment.rotationY,this.scene.environmentIntensity=t.scene.environment.intensity,(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=A,h.ProductCameraRig=R,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,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: beginning animation"),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"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spiffcommerce/preview",
3
- "version": "5.3.5-1",
3
+ "version": "5.3.5-2",
4
4
  "description": "An internal implementation of the ThreeDPreviewService interface used by Spiff Commerce",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/index.umd.js",