@spiffcommerce/preview 4.0.2-alpha.4 → 4.0.2-alpha.5

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
@@ -1,34 +1,34 @@
1
- import { ArcRotateCamera as he } from "@babylonjs/core/Cameras/arcRotateCamera";
2
- import { Engine as de } from "@babylonjs/core/Engines/engine";
3
- import { NullEngine as pe } from "@babylonjs/core/Engines/nullEngine";
4
- import { HighlightLayer as fe } from "@babylonjs/core/Layers/highlightLayer";
5
- import { SceneLoader as ce } from "@babylonjs/core/Loading/sceneLoader";
6
- import { CubeTexture as be } from "@babylonjs/core/Materials/Textures/cubeTexture";
1
+ import { ArcRotateCamera as de } from "@babylonjs/core/Cameras/arcRotateCamera";
2
+ import { Engine as ue } from "@babylonjs/core/Engines/engine";
3
+ import { NullEngine as be } from "@babylonjs/core/Engines/nullEngine";
4
+ import { HighlightLayer as ve } from "@babylonjs/core/Layers/highlightLayer";
5
+ import { SceneLoader as ge } from "@babylonjs/core/Loading/sceneLoader";
6
+ import { CubeTexture as we } from "@babylonjs/core/Materials/Textures/cubeTexture";
7
7
  import { Color4 as f, Color3 as w } from "@babylonjs/core/Maths/math.color";
8
- import { Vector3 as g, Vector2 as J } from "@babylonjs/core/Maths/math.vector";
9
- import { DracoCompression as ve } from "@babylonjs/core/Meshes/Compression/dracoCompression";
8
+ import { Vector3 as g, Quaternion as J, Vector2 as ee } from "@babylonjs/core/Maths/math.vector";
9
+ import { DracoCompression as Ce } from "@babylonjs/core/Meshes/Compression/dracoCompression";
10
10
  import { Observable as b } from "@babylonjs/core/Misc/observable";
11
- import { Tools as we } from "@babylonjs/core/Misc/tools";
12
- import { Scene as Ce } from "@babylonjs/core/scene";
13
- import { GLTF2 as Pe } from "@babylonjs/loaders/glTF";
11
+ import { Tools as Pe } from "@babylonjs/core/Misc/tools";
12
+ import { Scene as Me } from "@babylonjs/core/scene";
13
+ import { GLTF2 as ye } from "@babylonjs/loaders/glTF";
14
14
  import { PBRMaterial as T } from "@babylonjs/core/Materials/PBR/pbrMaterial";
15
- import { MirrorTexture as Me } from "@babylonjs/core/Materials/Textures/mirrorTexture";
16
- import { Color3 as ye, Vector3 as ee, Plane as xe } from "@babylonjs/core/Maths/math";
17
- import { ReflectionProbe as Le } from "@babylonjs/core/Probes/reflectionProbe";
18
- import { GlowLayer as Ae } from "@babylonjs/core/Layers/glowLayer";
15
+ import { MirrorTexture as xe } from "@babylonjs/core/Materials/Textures/mirrorTexture";
16
+ import { Color3 as Le, Vector3 as te, Plane as Re } from "@babylonjs/core/Maths/math";
17
+ import { ReflectionProbe as Ae } from "@babylonjs/core/Probes/reflectionProbe";
18
+ import { GlowLayer as Ee } from "@babylonjs/core/Layers/glowLayer";
19
19
  import { ActionManager as L } from "@babylonjs/core/Actions/actionManager";
20
- import { ExecuteCodeAction as te } from "@babylonjs/core/Actions/directActions";
21
- import { Mesh as Re } from "@babylonjs/core/Meshes/mesh";
22
- import { TransformNode as Ee } from "@babylonjs/core/Meshes/transformNode";
23
- import { DynamicTexture as Oe } from "@babylonjs/core/Materials/Textures/dynamicTexture";
24
- import { Texture as Te } from "@babylonjs/core/Materials/Textures/texture";
20
+ import { ExecuteCodeAction as ie } from "@babylonjs/core/Actions/directActions";
21
+ import { Mesh as Oe } from "@babylonjs/core/Meshes/mesh";
22
+ import { TransformNode as se } from "@babylonjs/core/Meshes/transformNode";
23
+ import { DynamicTexture as Te } from "@babylonjs/core/Materials/Textures/dynamicTexture";
24
+ import { Texture as Ie } from "@babylonjs/core/Materials/Textures/texture";
25
25
  import { Animation as v } from "@babylonjs/core/Animations/animation";
26
- import { QuadraticEase as Ie, EasingFunction as Se } from "@babylonjs/core/Animations/easing";
27
- import { AssetsManager as Fe } from "@babylonjs/core/Misc/assetsManager";
28
- import { ColorCurves as ie } from "@babylonjs/core/Materials/colorCurves";
26
+ import { QuadraticEase as Se, EasingFunction as Fe } from "@babylonjs/core/Animations/easing";
27
+ import { AssetsManager as Be } from "@babylonjs/core/Misc/assetsManager";
28
+ import { ColorCurves as ne } from "@babylonjs/core/Materials/colorCurves";
29
29
  import { ImageProcessingConfiguration as M } from "@babylonjs/core/Materials/imageProcessingConfiguration";
30
- import { DefaultRenderingPipeline as Be } from "@babylonjs/core/PostProcesses/RenderPipeline";
31
- import { DepthOfFieldEffectBlurLevel as A } from "@babylonjs/core/PostProcesses/depthOfFieldEffect";
30
+ import { DefaultRenderingPipeline as De } from "@babylonjs/core/PostProcesses/RenderPipeline";
31
+ import { DepthOfFieldEffectBlurLevel as R } from "@babylonjs/core/PostProcesses/depthOfFieldEffect";
32
32
  import "@babylonjs/core/Rendering/depthRendererSceneComponent";
33
33
  import "@babylonjs/core/Engines/Extensions/engine.views";
34
34
  import "@babylonjs/core/Meshes/instancedMesh";
@@ -40,7 +40,7 @@ import "@babylonjs/core/Misc/screenshotTools";
40
40
  import "@babylonjs/core/Rendering/boundingBoxRenderer";
41
41
  import "@babylonjs/loaders/glTF/2.0/Extensions";
42
42
  var E = /* @__PURE__ */ ((a) => (a[a.Orbit = 0] = "Orbit", a[a.Pan = 1] = "Pan", a))(E || {}), O = /* @__PURE__ */ ((a) => (a.None = "None", a.RemoveWhenSelected = "RemoveWhenSelected", a.ApplyWhenSelected = "ApplyWhenSelected", a))(O || {});
43
- class De {
43
+ class ze {
44
44
  constructor(e) {
45
45
  this.getSceneClearColor = () => {
46
46
  var i, r, n, s;
@@ -91,7 +91,7 @@ class De {
91
91
  * Configuration related to the camera used to view and interact with the scene.
92
92
  */
93
93
  get camera() {
94
- var e, t, i, r, n, s, o, l, d, c, u, m, p;
94
+ var e, t, i, r, n, s, o, l, c, d, u, m, p;
95
95
  return {
96
96
  autoOrientation: ((e = this.customOptions) == null ? void 0 : e.disableAutomaticOrientation) ?? !0,
97
97
  autoRotation: {
@@ -105,7 +105,7 @@ class De {
105
105
  radius: (l = this.customOptions) == null ? void 0 : l.minZoomOverride
106
106
  },
107
107
  max: {
108
- alpha: (d = this.customOptions) != null && d.upperAlphaLimitDeg ? ((c = this.customOptions) == null ? void 0 : c.upperAlphaLimitDeg) * Math.PI / 180 : void 0,
108
+ alpha: (c = this.customOptions) != null && c.upperAlphaLimitDeg ? ((d = this.customOptions) == null ? void 0 : d.upperAlphaLimitDeg) * Math.PI / 180 : void 0,
109
109
  beta: (u = this.customOptions) != null && u.upperBetaLimitDeg ? ((m = this.customOptions) == null ? void 0 : m.upperBetaLimitDeg) * Math.PI / 180 : void 0,
110
110
  radius: (p = this.customOptions) == null ? void 0 : p.maxZoomOverride
111
111
  }
@@ -176,7 +176,7 @@ class P {
176
176
  }
177
177
  }
178
178
  }
179
- const ze = 128, h = {
179
+ const ke = 128, h = {
180
180
  antiAliasing: {
181
181
  samples: 4,
182
182
  fxaaEnabled: !1
@@ -233,7 +233,7 @@ const ze = 128, h = {
233
233
  weight: 1
234
234
  }
235
235
  };
236
- class ke {
236
+ class Ne {
237
237
  constructor(e) {
238
238
  this.name = "glbPostProcessor", this.enabled = !0, this.loader = e;
239
239
  }
@@ -284,7 +284,7 @@ class ke {
284
284
  }
285
285
  if (e.extras.translucency) {
286
286
  const i = t;
287
- i.subSurface.isTranslucencyEnabled = !0, i.subSurface.translucencyIntensity = e.extras.translucency, e.extras.translucencyR && e.extras.translucencyG && e.extras.translucencyB && (i.subSurface.tintColor = new ye(
287
+ i.subSurface.isTranslucencyEnabled = !0, i.subSurface.translucencyIntensity = e.extras.translucency, e.extras.translucencyR && e.extras.translucencyG && e.extras.translucencyB && (i.subSurface.tintColor = new Le(
288
288
  e.extras.translucencyR,
289
289
  e.extras.translucencyG,
290
290
  e.extras.translucencyB
@@ -322,32 +322,32 @@ class ke {
322
322
  const o = n.material;
323
323
  if (!o)
324
324
  return;
325
- const l = new Me(
325
+ const l = new xe(
326
326
  "mirror",
327
327
  P.getMirrorTextureResolution(),
328
328
  e,
329
329
  !0
330
330
  );
331
331
  l.renderList = t(e);
332
- const d = n.getVerticesData("normal");
333
- if (!d)
332
+ const c = n.getVerticesData("normal");
333
+ if (!c)
334
334
  throw new Error(
335
335
  "Mirror attribute specified on: " + n.name + "But no normals exist to generate a mirror from!"
336
336
  );
337
337
  n.computeWorldMatrix(!0);
338
- const c = n.getWorldMatrix(), u = ee.TransformNormal(
339
- new ee(d[0], d[1], d[2]),
340
- c
341
- ).normalize(), m = xe.FromPositionAndNormal(
338
+ const d = n.getWorldMatrix(), u = te.TransformNormal(
339
+ new te(c[0], c[1], c[2]),
340
+ d
341
+ ).normalize(), m = Re.FromPositionAndNormal(
342
342
  n.position,
343
343
  u.scale(-1)
344
344
  );
345
345
  l.mirrorPlane = m, l.level = s, o.reflectionTexture = l;
346
346
  }
347
347
  function r(n) {
348
- const s = n.material, o = new Le(
348
+ const s = n.material, o = new Ae(
349
349
  "probe-" + s.name,
350
- ze,
350
+ ke,
351
351
  e
352
352
  );
353
353
  o.attachToMesh(n), o.renderList && o.renderList.push(...t(e)), s.reflectionTexture = o.cubeTexture;
@@ -358,12 +358,12 @@ class ke {
358
358
  });
359
359
  }
360
360
  }
361
- class Ne {
361
+ class Ve {
362
362
  constructor(e, t) {
363
363
  this.scene = e, this.intensity = t, this.meshCount = 0;
364
364
  }
365
365
  includeMeshes(e) {
366
- this.glowLayer || (this.glowLayer = new Ae("glow", this.scene), this.glowLayer.intensity = this.intensity), e.forEach((t) => {
366
+ this.glowLayer || (this.glowLayer = new Ee("glow", this.scene), this.glowLayer.intensity = this.intensity), e.forEach((t) => {
367
367
  this.glowLayer.hasMesh(t) || (this.glowLayer.addIncludedOnlyMesh(t), this.meshCount++);
368
368
  });
369
369
  }
@@ -373,31 +373,31 @@ class Ne {
373
373
  }), this.meshCount === 0 && (this.glowLayer.dispose(), this.glowLayer = void 0));
374
374
  }
375
375
  }
376
- const se = /* @__PURE__ */ new Map();
377
- async function ue(a, e, t) {
376
+ const re = /* @__PURE__ */ new Map();
377
+ async function me(a, e, t) {
378
378
  return new Promise((i, r) => {
379
- const n = se.get(a);
379
+ const n = re.get(a);
380
380
  if (n && n.scene.uid === e.uid)
381
381
  return i(n);
382
- ce.LoadAssetContainerAsync(
382
+ ge.LoadAssetContainerAsync(
383
383
  a,
384
384
  void 0,
385
385
  e,
386
386
  t
387
387
  ).then((s) => {
388
- se.set(a, s), i(s);
388
+ re.set(a, s), i(s);
389
389
  }).catch(r);
390
390
  });
391
391
  }
392
- function Ve(a, e, t, i, r = "") {
392
+ function Ge(a, e, t, i, r = "") {
393
393
  t.forEach((n) => {
394
394
  const s = n.getID(), o = n.getName(), l = P.getDynamicTextureResolution();
395
- a.filter((c) => c.name === r + o).forEach((c) => {
395
+ a.filter((d) => d.name === r + o).forEach((d) => {
396
396
  const u = i.get(s), m = !1;
397
397
  if (u)
398
- ne(c, u), u.update(m);
398
+ ae(d, u), u.update(m);
399
399
  else {
400
- const p = Ge(
400
+ const p = He(
401
401
  o,
402
402
  e,
403
403
  l.width,
@@ -405,25 +405,25 @@ function Ve(a, e, t, i, r = "") {
405
405
  );
406
406
  i.set(s, p), n.setStaticContext(
407
407
  p.getContext()
408
- ), ne(c, p), p.onLoadObservable.addOnce(() => {
408
+ ), ae(d, p), p.onLoadObservable.addOnce(() => {
409
409
  p.update(m);
410
410
  });
411
411
  }
412
412
  });
413
413
  });
414
414
  }
415
- function Ge(a, e, t, i) {
416
- const r = new Oe(
415
+ function He(a, e, t, i) {
416
+ const r = new Te(
417
417
  a,
418
418
  { width: t, height: i },
419
419
  e,
420
420
  P.shouldMipMap(),
421
- Te.TRILINEAR_SAMPLINGMODE,
422
- de.TEXTUREFORMAT_RGBA
421
+ Ie.TRILINEAR_SAMPLINGMODE,
422
+ ue.TEXTUREFORMAT_RGBA
423
423
  ), n = r.getContext();
424
424
  return n && (n.fillStyle = "#f5f5f5", n.fillRect(0, 0, t, i), r.update()), r;
425
425
  }
426
- function ne(a, e) {
426
+ function ae(a, e) {
427
427
  if (a instanceof T) {
428
428
  const t = a, i = t.albedoTexture;
429
429
  i ? (e.wrapU = i.wrapU, e.wrapV = i.wrapV) : (e.wrapU = 1, e.wrapV = 1), t.albedoTexture = e;
@@ -432,15 +432,15 @@ function ne(a, e) {
432
432
  i && (e.wrapU = i.wrapU, e.wrapV = i.wrapV), t.diffuseTexture = e;
433
433
  }
434
434
  }
435
- function He() {
435
+ function _e() {
436
436
  const a = () => Math.floor((1 + Math.random()) * 65536).toString(16).substring(1);
437
437
  return a() + a() + "-" + a() + "-" + a() + "-" + a() + "-" + a() + a() + a();
438
438
  }
439
- const C = 60, re = 1;
440
- function ae(a) {
439
+ const C = 60, oe = 1;
440
+ function le(a) {
441
441
  return a.targetedAnimations.map((t) => t.animation.framePerSecond).reduce((t, i) => t + i, 0) / a.targetedAnimations.length || 0;
442
442
  }
443
- function _e(a, e, t, i, r) {
443
+ function qe(a, e, t, i, r) {
444
444
  const n = r ? a.filter((s) => s.name === r) : a;
445
445
  if (n.length === 0) {
446
446
  console.warn(`No animations found for name: ${r}`);
@@ -449,28 +449,28 @@ function _e(a, e, t, i, r) {
449
449
  if (i !== void 0 && t !== void 0 && i === t) {
450
450
  n.forEach((s) => {
451
451
  s.stop();
452
- const o = ae(s), l = i * o;
453
- s.start(e, re, l, l);
452
+ const o = le(s), l = i * o;
453
+ s.start(e, oe, l, l);
454
454
  });
455
455
  return;
456
456
  }
457
457
  n.forEach((s) => {
458
458
  s.stop();
459
- const o = ae(s), l = i !== void 0 ? i * o : void 0, d = t !== void 0 ? t * o : void 0;
460
- s.start(e, re, l, d);
459
+ const o = le(s), l = i !== void 0 ? i * o : void 0, c = t !== void 0 ? t * o : void 0;
460
+ s.start(e, oe, l, c);
461
461
  });
462
462
  }
463
- function ge(a) {
463
+ function pe(a) {
464
464
  a.forEach((e) => {
465
465
  e.stop();
466
466
  });
467
467
  }
468
- function qe(a) {
468
+ function Ke(a) {
469
469
  const e = a.animationGroups;
470
- ge(e);
470
+ pe(e);
471
471
  }
472
- function Ke(a, e, t) {
473
- a.stopAnimation(e), e.animations = [], Math.abs(e.alpha) > 2 * Math.PI && (e.alpha = Ue(e.alpha, 0, 2 * Math.PI));
472
+ function Ue(a, e, t) {
473
+ a.stopAnimation(e), e.animations = [], Math.abs(e.alpha) > 2 * Math.PI && (e.alpha = We(e.alpha, 0, 2 * Math.PI));
474
474
  const i = [], r = t.target, n = 0, s = r ? 1 : 0;
475
475
  if (t.target && Object.keys(t.target).length > 0 && i.push(
476
476
  y(
@@ -490,7 +490,7 @@ function Ke(a, e, t) {
490
490
  "cameraAlphaLerp",
491
491
  "alpha",
492
492
  e.alpha,
493
- oe(t.lonDeg),
493
+ he(t.lonDeg),
494
494
  v.ANIMATIONTYPE_FLOAT,
495
495
  s
496
496
  )
@@ -499,18 +499,18 @@ function Ke(a, e, t) {
499
499
  "cameraBetaLerp",
500
500
  "beta",
501
501
  e.beta,
502
- oe(t.latDeg),
502
+ he(t.latDeg),
503
503
  v.ANIMATIONTYPE_FLOAT,
504
504
  s
505
505
  )
506
506
  ), t.radius !== void 0) {
507
- const d = Math.max(0.01, t.radius);
507
+ const c = Math.max(0.01, t.radius);
508
508
  i.push(
509
509
  y(
510
510
  "cameraRadiusLerp",
511
511
  "radius",
512
512
  e.radius,
513
- d,
513
+ c,
514
514
  v.ANIMATIONTYPE_FLOAT,
515
515
  s
516
516
  )
@@ -529,28 +529,28 @@ function Ke(a, e, t) {
529
529
  }
530
530
  );
531
531
  }
532
- function oe(a) {
532
+ function he(a) {
533
533
  return a * Math.PI / 180;
534
534
  }
535
535
  function y(a, e, t, i, r, n = 0, s = v.ANIMATIONLOOPMODE_CONSTANT) {
536
- const o = new Ie();
537
- o.setEasingMode(Se.EASINGMODE_EASEINOUT);
536
+ const o = new Se();
537
+ o.setEasingMode(Fe.EASINGMODE_EASEINOUT);
538
538
  const l = new v(
539
539
  a,
540
540
  e,
541
541
  C,
542
542
  r,
543
543
  s
544
- ), d = [];
545
- return n > 0 && d.push({ frame: 0, value: t }), d.push({ frame: C * n, value: t }), d.push({
544
+ ), c = [];
545
+ return n > 0 && c.push({ frame: 0, value: t }), c.push({ frame: C * n, value: t }), c.push({
546
546
  frame: C * (n + 1),
547
547
  value: i
548
- }), l.setKeys(d), l.setEasingFunction(o), l;
548
+ }), l.setKeys(c), l.setEasingFunction(o), l;
549
549
  }
550
- function Ue(a, e, t) {
550
+ function We(a, e, t) {
551
551
  return a < e ? a = t - (e - a) % (t - e) : a = e + (a - e) % (t - e);
552
552
  }
553
- const We = {
553
+ const Qe = {
554
554
  albedoTexture: "albedoMap",
555
555
  bumpTexture: "normalMap",
556
556
  ambientTexture: "ambientMap",
@@ -576,10 +576,10 @@ function Ze(a, e, t, i) {
576
576
  t,
577
577
  i
578
578
  );
579
- }), je(a, e);
579
+ }), Xe(a, e);
580
580
  }
581
581
  function $e(a, e, t, i, r) {
582
- const n = We[a];
582
+ const n = Qe[a];
583
583
  if (!n)
584
584
  throw new Error("Unexpected texture name encountered.");
585
585
  const s = e[n], o = s == null ? void 0 : s.fileLink;
@@ -588,13 +588,13 @@ function $e(a, e, t, i, r) {
588
588
  function Ye(a, e) {
589
589
  a === "opacityTexture" && (e.useAlphaFromAlbedoTexture = !0), a === "metallicTexture" && (e.useRoughnessFromMetallicTextureAlpha = !1, e.useRoughnessFromMetallicTextureGreen = !1, e.useMetallnessFromMetallicTextureBlue = !1), a === "refractionTexture" && (e.subSurface.isRefractionEnabled = !1, e.subSurface.refractionIntensity = 1), a === "emissiveTexture" && (e.emissiveIntensity = 0, e.emissiveColor = new w(0, 0, 0));
590
590
  }
591
- function Qe(a, e, t, i) {
591
+ function je(a, e, t, i) {
592
592
  a === "opacityTexture" && (e.useAlphaFromAlbedoTexture = !1), a === "metallicTexture" && (e.useRoughnessFromMetallicTextureAlpha = !1, e.useRoughnessFromMetallicTextureGreen = !0, e.useMetallnessFromMetallicTextureBlue = !0), a === "refractionTexture" && (e.subSurface.isRefractionEnabled = !0, e.subSurface.refractionIntensity = t.refractionIntensity || 1), e[a] = i, a === "emissiveTexture" && (e.emissiveColor = new w(1, 1, 1), e.emissiveIntensity = 1);
593
593
  }
594
- function je(a, e) {
594
+ function Xe(a, e) {
595
595
  a.clearCoat && (a.clearCoat === O.RemoveWhenSelected ? (e.clearCoat.isEnabled = !1, e.clearCoat.indexOfRefraction = 1.5) : a.clearCoat === O.ApplyWhenSelected && (e.clearCoat.isEnabled = !0, e.clearCoat.indexOfRefraction = a.clearCoatIOR || e.clearCoat.indexOfRefraction));
596
596
  }
597
- class Xe {
597
+ class Je {
598
598
  constructor(e, t, i) {
599
599
  this.materialVariantMap = /* @__PURE__ */ new Map(), this.keysThatRemovedBaseModel = [], this.loadedContainerForKey = /* @__PURE__ */ new Map(), this.loadedMaterialsForKey = /* @__PURE__ */ new Map(), this.scene = e, this.renameClonedAsset = t, this.setBaseModelEnabled = i;
600
600
  }
@@ -615,27 +615,27 @@ class Xe {
615
615
  ...t
616
616
  });
617
617
  const o = this.renameClonedAsset(e), l = this.scene.materials.filter(
618
- (c) => c.name === o
618
+ (d) => d.name === o
619
619
  );
620
620
  if (l.length === 0) {
621
621
  n();
622
622
  return;
623
623
  }
624
- const d = new Fe(this.scene);
625
- d.useDefaultLoadingScreen = !1, l.forEach(
626
- (c) => Ze(
624
+ const c = new Be(this.scene);
625
+ c.useDefaultLoadingScreen = !1, l.forEach(
626
+ (d) => Ze(
627
627
  t,
628
- c,
629
628
  d,
629
+ c,
630
630
  r
631
631
  )
632
- ), d.onProgress = (c, u, m) => {
633
- i && i(c / u * 100, 100, m.name);
634
- }, d.onFinish = (c) => {
635
- c.forEach((u) => {
632
+ ), c.onProgress = (d, u, m) => {
633
+ i && i(d / u * 100, 100, m.name);
634
+ }, c.onFinish = (d) => {
635
+ d.forEach((u) => {
636
636
  const m = u;
637
637
  i && i(100, 100, u.name), l.forEach(
638
- (p) => Qe(
638
+ (p) => je(
639
639
  u.name,
640
640
  p,
641
641
  t,
@@ -643,7 +643,7 @@ class Xe {
643
643
  )
644
644
  );
645
645
  }), n();
646
- }, d.loadAsync();
646
+ }, c.loadAsync();
647
647
  });
648
648
  }
649
649
  /**
@@ -654,18 +654,18 @@ class Xe {
654
654
  * @param onProgress A load progress callback that can be used for loading bars and event timing.
655
655
  */
656
656
  async applyModel(e, t, i, r) {
657
- var l, d;
657
+ var l, c;
658
658
  if (i && t && !this.keysThatRemovedBaseModel.includes(e) && this.keysThatRemovedBaseModel.push(e), !i)
659
659
  return this.keysThatRemovedBaseModel.includes(e) && this.setBaseModelEnabled(!0), (l = this.loadedContainerForKey.get(e)) == null || l.dispose(), this.loadedContainerForKey.delete(e), this.loadedMaterialsForKey.delete(e), Promise.resolve(void 0);
660
- this.loadedContainerForKey.has(e) && ((d = this.loadedContainerForKey.get(e)) == null || d.dispose(), this.loadedContainerForKey.delete(e), this.loadedMaterialsForKey.delete(e)), t && this.setBaseModelEnabled(!1);
661
- const s = (await ue(i, this.scene, r)).instantiateModelsToScene(
660
+ this.loadedContainerForKey.has(e) && ((c = this.loadedContainerForKey.get(e)) == null || c.dispose(), this.loadedContainerForKey.delete(e), this.loadedMaterialsForKey.delete(e)), t && this.setBaseModelEnabled(!1);
661
+ const s = (await me(i, this.scene, r)).instantiateModelsToScene(
662
662
  this.renameClonedAsset,
663
663
  !0
664
664
  );
665
- this.loadedContainerForKey.set(e, s), this.loadedMaterialsForKey.set(e, me(s));
665
+ this.loadedContainerForKey.set(e, s), this.loadedMaterialsForKey.set(e, fe(s));
666
666
  const o = [];
667
- return this.materialVariantMap.forEach(async (c, u) => {
668
- o.push(this.applyMaterial(u, c));
667
+ return this.materialVariantMap.forEach(async (d, u) => {
668
+ o.push(this.applyMaterial(u, d));
669
669
  }), await Promise.all(o), s;
670
670
  }
671
671
  dispose() {
@@ -688,7 +688,7 @@ class Xe {
688
688
  }), e;
689
689
  }
690
690
  }
691
- function me(a) {
691
+ function fe(a) {
692
692
  const e = [];
693
693
  return a.rootNodes.forEach((t) => {
694
694
  t.getChildMeshes().forEach((i) => {
@@ -699,7 +699,7 @@ function me(a) {
699
699
  });
700
700
  }), e;
701
701
  }
702
- function le(a, e = "") {
702
+ function ce(a, e = "") {
703
703
  return a.map((t) => ({
704
704
  name: t.name.substring(e.length),
705
705
  loop: t.loopAnimation,
@@ -707,7 +707,7 @@ function le(a, e = "") {
707
707
  from: t.from
708
708
  }));
709
709
  }
710
- class Je {
710
+ class et {
711
711
  constructor(e) {
712
712
  this.metadata = /* @__PURE__ */ new Map(), this.materialSelectedObservable = new b(), this.materialDeselectedObservable = new b(), this.materialVariantObservable = new b(), this.modelVariantObservable = new b(), this.materialReadyToLoadCallbacks = /* @__PURE__ */ new Map(), this.modelReadyToLoadCallbacks = /* @__PURE__ */ new Map(), this.dynamicTextures = /* @__PURE__ */ new Map(), this.queuedMaterialChanges = /* @__PURE__ */ new Map(), this.materialChangesInProgress = [], this.queuedModelChanges = /* @__PURE__ */ new Map(), this.modelChangesInProgress = [], this.animations = [], this.initialized = !1, this.materials = [];
713
713
  const {
@@ -717,14 +717,14 @@ class Je {
717
717
  progressHandler: n,
718
718
  scene: s
719
719
  } = e;
720
- this.enablePicking = t, this.contextService = i.contextService, this.id = He(), this.previewService = r, this.scene = s, this.variantManager = new Xe(
720
+ this.enablePicking = t, this.contextService = i.contextService, this.id = _e(), this.previewService = r, this.scene = s, this.variantManager = new Je(
721
721
  s,
722
722
  this.renameClonedAsset.bind(this),
723
723
  this.setEnabled.bind(this)
724
724
  ), this.previewService.registerInitializedListener(
725
725
  async () => await this.processQueuedEvents()
726
- ), this.transformRoot = new Ee("root", this.scene);
727
- const o = async () => (this.assetContainer = await ue(
726
+ ), this.transformRoot = new se("root", this.scene), this.rotationRoot = new se("rotationRoot", this.scene), this.rotationRoot.setParent(this.transformRoot, !0, !1), this.rotationRoot.rotation = new g(0, Math.PI, 0);
727
+ const o = async () => (this.assetContainer = await me(
728
728
  i.model,
729
729
  s,
730
730
  n
@@ -836,7 +836,7 @@ class Je {
836
836
  1
837
837
  ), o;
838
838
  })();
839
- this.modelInstance && ge(this.modelInstance.animationGroups), this.contextService || (this.contextService = t == null ? void 0 : t.contextService), s ? this.configureModelInstance(s) : this.configureGlowLayer();
839
+ this.modelInstance && pe(this.modelInstance.animationGroups), this.contextService || (this.contextService = t == null ? void 0 : t.contextService), s ? this.configureModelInstance(s) : this.configureGlowLayer();
840
840
  }
841
841
  dispose() {
842
842
  var e;
@@ -847,7 +847,7 @@ class Je {
847
847
  this.queuedModelAnimation = e;
848
848
  return;
849
849
  }
850
- this.modelInstance && _e(
850
+ this.modelInstance && qe(
851
851
  [
852
852
  ...this.modelInstance.animationGroups,
853
853
  ...this.variantManager.getAnimationGroups()
@@ -861,7 +861,7 @@ class Je {
861
861
  getAnimations(e) {
862
862
  return [
863
863
  ...this.animations,
864
- ...e ? le(
864
+ ...e ? ce(
865
865
  this.variantManager.getAnimationGroups(),
866
866
  this.renameClonedAsset("")
867
867
  ) : []
@@ -916,14 +916,14 @@ class Je {
916
916
  e.rootNodes.forEach((t) => {
917
917
  t.getChildMeshes(!1).forEach((i) => {
918
918
  i.name === "targetcube_t" || i.name === "backgroundShell" || (i.actionManager || (i.actionManager = new L(this.scene)), i.actionManager.registerAction(
919
- new te(L.OnPointerOverTrigger, (r) => {
919
+ new ie(L.OnPointerOverTrigger, (r) => {
920
920
  r.meshUnderPointer && i.material && this.materialSelectedObservable.notifyObservers({
921
921
  id: i.material.id,
922
922
  name: this.stripIdFromName(i.material.name)
923
923
  });
924
924
  })
925
925
  ), i.actionManager.registerAction(
926
- new te(L.OnPointerOutTrigger, () => {
926
+ new ie(L.OnPointerOutTrigger, () => {
927
927
  i.material && this.materialDeselectedObservable.notifyObservers({
928
928
  id: i.material.id,
929
929
  name: this.stripIdFromName(i.material.name)
@@ -958,11 +958,11 @@ class Je {
958
958
  configureModelInstance(e) {
959
959
  var n;
960
960
  const t = this.transformRoot.position, i = this.transformRoot.rotation, r = this.transformRoot.scaling;
961
- this.transformRoot.position = g.Zero(), this.transformRoot.rotation = g.Zero(), this.transformRoot.scaling = g.One(), e.rootNodes.forEach((s) => {
962
- s.getChildTransformNodes(!0).forEach((o) => {
963
- o.rotation.subtractInPlace(new g(0, Math.PI, 0));
964
- }), s.rotation.addInPlace(new g(0, Math.PI, 0)), s.setParent(this.transformRoot, !0, !1);
965
- }), this.transformRoot.position = t, this.transformRoot.rotation = i, this.transformRoot.scaling = r, this.canvasPanels = ((n = this.contextService) == null ? void 0 : n.getAll()) || /* @__PURE__ */ new Map(), Ve(
961
+ this.transformRoot.position = g.Zero(), this.transformRoot.rotation = g.Zero(), this.transformRoot.scaling = g.One(), this.rotationRoot.rotation = new g(0, 0, 0), e.rootNodes.forEach((s) => {
962
+ s.rotationQuaternion || (s.rotationQuaternion = J.FromEulerVector(s.rotation)), s.rotationQuaternion.subtractInPlace(
963
+ J.FromEulerAngles(0, Math.PI, 0)
964
+ ), s.setParent(this.rotationRoot, !0, !1);
965
+ }), this.rotationRoot.rotation = new g(0, Math.PI, 0), this.transformRoot.position = t, this.transformRoot.rotation = i, this.transformRoot.scaling = r, this.canvasPanels = ((n = this.contextService) == null ? void 0 : n.getAll()) || /* @__PURE__ */ new Map(), Ge(
966
966
  this.materials.concat(this.variantManager.getAllMaterials()),
967
967
  this.scene,
968
968
  this.canvasPanels,
@@ -980,14 +980,14 @@ class Je {
980
980
  getAllMeshes() {
981
981
  var e;
982
982
  return (e = this.modelInstance) == null ? void 0 : e.rootNodes.map(
983
- (t) => t.getChildMeshes(!1).filter((i) => i instanceof Re)
983
+ (t) => t.getChildMeshes(!1).filter((i) => i instanceof Oe)
984
984
  ).flat();
985
985
  }
986
986
  instantiate() {
987
987
  this.modelInstance = this.assetContainer.instantiateModelsToScene(
988
988
  this.renameClonedAsset.bind(this),
989
989
  !0
990
- ), this.materials = me(this.modelInstance), this.configureModelInstance(this.modelInstance), this.animations = le(
990
+ ), this.materials = fe(this.modelInstance), this.configureModelInstance(this.modelInstance), this.animations = ce(
991
991
  this.modelInstance.animationGroups,
992
992
  this.renameClonedAsset("")
993
993
  ), this.processQueuedEvents();
@@ -1037,7 +1037,7 @@ class Je {
1037
1037
  }
1038
1038
  //#endregion
1039
1039
  }
1040
- class I extends he {
1040
+ class I extends de {
1041
1041
  constructor(e, t, i, r, n, s, o, l) {
1042
1042
  super(
1043
1043
  e,
@@ -1074,7 +1074,7 @@ class I extends he {
1074
1074
  this.useFramingBehavior = !0;
1075
1075
  const e = this.getFramingBehavior();
1076
1076
  e.attach(this), e.framingTime = 0, e.elevationReturnTime = -1, e.zoomStopsAnimation = !1, this.lowerRadiusLimit = null;
1077
- const t = R(this._scene);
1077
+ const t = A(this._scene);
1078
1078
  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;
1079
1079
  }
1080
1080
  /**
@@ -1087,7 +1087,7 @@ class I extends he {
1087
1087
  i.framingTime = t || 800;
1088
1088
  const r = () => {
1089
1089
  e && e();
1090
- }, n = R(this._scene), s = n.max.subtract(n.min), o = n.min.add(s.scale(0.5));
1090
+ }, n = A(this._scene), s = n.max.subtract(n.min), o = n.min.add(s.scale(0.5));
1091
1091
  this.setRadius(s.length() * 1.5), this.wheelPrecision = 100 / this.radius, this.panningInertia = 0, this.panningOriginTarget.copyFrom(o), this.panDenominator = s.length(), i.zoomOnBoundingInfo(
1092
1092
  n.min,
1093
1093
  n.max,
@@ -1122,7 +1122,7 @@ class I extends he {
1122
1122
  * @param assignActive If true the camera will be assigned as the active camera on the scene.
1123
1123
  */
1124
1124
  static create(e, t, i) {
1125
- const r = R(e), n = r.max.subtract(r.min), s = r.min.add(n.scale(0.5)), o = new I(
1125
+ const r = A(e), n = r.max.subtract(r.min), s = r.min.add(n.scale(0.5)), o = new I(
1126
1126
  "ProductCamera",
1127
1127
  -(Math.PI / 2),
1128
1128
  Math.PI / 2,
@@ -1136,7 +1136,7 @@ class I extends he {
1136
1136
  }), i && (e.activeCamera = o), o;
1137
1137
  }
1138
1138
  }
1139
- function R(a) {
1139
+ function A(a) {
1140
1140
  if (a.meshes.length === 0)
1141
1141
  return {
1142
1142
  min: new g(-1, -1, -1),
@@ -1145,9 +1145,9 @@ function R(a) {
1145
1145
  const e = a.meshes.filter((t) => t.name.toLowerCase().endsWith("_t") || t.name.toLowerCase().includes("_t_"));
1146
1146
  return a.getWorldExtends((t) => t.isVisible && t.isEnabled() && (e.length === 0 || e.includes(t)));
1147
1147
  }
1148
- class et {
1148
+ class tt {
1149
1149
  constructor(e, t = !1, i = void 0) {
1150
- this.renderingPipeline = new Be(
1150
+ this.renderingPipeline = new De(
1151
1151
  "default",
1152
1152
  t,
1153
1153
  e,
@@ -1163,24 +1163,24 @@ class et {
1163
1163
  return this.currentConfiguration;
1164
1164
  }
1165
1165
  setConfiguration(e) {
1166
- var t, i, r, n, s, o, l, d, c, u, m, p, S, F, B, D, z, k, N, V, G, H, _, q, K, U, W, Z, $, Y, Q, j, X;
1166
+ var t, i, r, n, s, o, l, c, d, u, m, p, S, F, B, D, z, k, N, V, G, H, _, q, K, U, W, Q, Z, $, Y, j, X;
1167
1167
  if (this.renderingPipeline.isSupported) {
1168
- 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 = ((r = e.bloom) == null ? void 0 : r.enabled) ?? h.bloom.enabled, this.renderingPipeline.bloomKernel = ((n = e.bloom) == null ? void 0 : n.kernel) ?? h.bloom.kernel, this.renderingPipeline.bloomScale = ((s = e.bloom) == null ? void 0 : s.scale) ?? h.bloom.scale, this.renderingPipeline.bloomThreshold = ((o = e.bloom) == null ? void 0 : o.threshold) ?? h.bloom.threshold, this.renderingPipeline.bloomWeight = ((l = e.bloom) == null ? void 0 : l.weight) ?? h.bloom.weight, this.renderingPipeline.chromaticAberrationEnabled = ((d = e.chromaticAberration) == null ? void 0 : d.enabled) ?? h.chromaticAberration.enabled, this.renderingPipeline.chromaticAberration.aberrationAmount = ((c = e.chromaticAberration) == null ? void 0 : c.aberrationAmount) ?? h.chromaticAberration.aberrationAmount, this.renderingPipeline.chromaticAberration.radialIntensity = ((u = e.chromaticAberration) == null ? void 0 : u.radialIntensity) ?? h.chromaticAberration.radialIntensity, this.renderingPipeline.chromaticAberration.direction = (m = e.chromaticAberration) != null && m.direction ? new J(
1168
+ 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 = ((r = e.bloom) == null ? void 0 : r.enabled) ?? h.bloom.enabled, this.renderingPipeline.bloomKernel = ((n = e.bloom) == null ? void 0 : n.kernel) ?? h.bloom.kernel, this.renderingPipeline.bloomScale = ((s = e.bloom) == null ? void 0 : s.scale) ?? h.bloom.scale, this.renderingPipeline.bloomThreshold = ((o = e.bloom) == null ? void 0 : o.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 = (m = e.chromaticAberration) != null && m.direction ? new ee(
1169
1169
  e.chromaticAberration.direction.x,
1170
1170
  e.chromaticAberration.direction.y
1171
- ) : new J(
1171
+ ) : new ee(
1172
1172
  h.chromaticAberration.direction.x,
1173
1173
  h.chromaticAberration.direction.y
1174
- ), 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 ie(), this.renderingPipeline.depthOfFieldEnabled = ((S = e.depthOfField) == null ? void 0 : S.enabled) ?? h.depthOfField.enabled, e.depthOfField)
1174
+ ), this.renderingPipeline.imageProcessing.colorCurvesEnabled = ((p = e.colorCurves) == null ? void 0 : p.enabled) ?? h.colorCurves.enabled, this.renderingPipeline.imageProcessing.colorCurves = e.colorCurves ? this.updateColorCurve(e.colorCurves) : new ne(), this.renderingPipeline.depthOfFieldEnabled = ((S = e.depthOfField) == null ? void 0 : S.enabled) ?? h.depthOfField.enabled, e.depthOfField)
1175
1175
  switch (e.depthOfField.blurLevel ?? h.depthOfField.blurLevel) {
1176
1176
  case "Low":
1177
- this.renderingPipeline.depthOfFieldBlurLevel = A.Low;
1177
+ this.renderingPipeline.depthOfFieldBlurLevel = R.Low;
1178
1178
  break;
1179
1179
  case "Medium":
1180
- this.renderingPipeline.depthOfFieldBlurLevel = A.Medium;
1180
+ this.renderingPipeline.depthOfFieldBlurLevel = R.Medium;
1181
1181
  break;
1182
1182
  case "High":
1183
- this.renderingPipeline.depthOfFieldBlurLevel = A.High;
1183
+ this.renderingPipeline.depthOfFieldBlurLevel = R.High;
1184
1184
  break;
1185
1185
  }
1186
1186
  if (this.renderingPipeline.depthOfField.focalLength = ((F = e.depthOfField) == null ? void 0 : F.focalLength) ?? h.depthOfField.focalLength, this.renderingPipeline.depthOfField.fStop = ((B = e.depthOfField) == null ? void 0 : B.fStop) ?? h.depthOfField.fStop, this.renderingPipeline.depthOfField.focusDistance = ((D = e.depthOfField) == null ? void 0 : D.focusDistance) ?? h.depthOfField.focusDistance, this.renderingPipeline.depthOfField.lensSize = ((z = e.depthOfField) == null ? void 0 : z.lensSize) ?? h.depthOfField.lensSize, this.renderingPipeline.grainEnabled = ((k = e.grain) == null ? void 0 : k.enabled) ?? h.grain.enabled, this.renderingPipeline.grain.animated = ((N = e.grain) == null ? void 0 : N.animated) ?? h.grain.animated, this.renderingPipeline.grain.intensity = ((V = e.grain) == null ? void 0 : V.intensity) ?? h.grain.intensity, this.renderingPipeline.imageProcessing.contrast = ((G = e.misc) == null ? void 0 : G.contrast) ?? h.misc.contrast, this.renderingPipeline.imageProcessing.exposure = ((H = e.misc) == null ? void 0 : H.exposure) ?? h.misc.exposure, this.renderingPipeline.imageProcessing.toneMappingEnabled = ((_ = e.misc) == null ? void 0 : _.toneMappingEnabled) ?? h.misc.toneMappingEnabled, this.renderingPipeline.imageProcessing.toneMappingEnabled)
@@ -1192,8 +1192,8 @@ class et {
1192
1192
  this.renderingPipeline.imageProcessing.toneMappingType = M.TONEMAPPING_ACES;
1193
1193
  break;
1194
1194
  }
1195
- if (this.renderingPipeline.sharpenEnabled = ((q = e.sharpen) == null ? void 0 : q.enabled) ?? h.sharpen.enabled, this.renderingPipeline.sharpen.colorAmount = ((K = e.sharpen) == null ? void 0 : K.colorAmount) ?? h.sharpen.colorAmount, this.renderingPipeline.sharpen.edgeAmount = ((U = e.sharpen) == null ? void 0 : U.edgeAmount) ?? h.sharpen.edgeAmount, this.renderingPipeline.imageProcessing.vignetteEnabled = ((W = e.vignette) == null ? void 0 : W.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)
1196
- switch ((($ = e.vignette) == null ? void 0 : $.blendMode) ?? h.vignette.blendMode) {
1195
+ if (this.renderingPipeline.sharpenEnabled = ((q = e.sharpen) == null ? void 0 : q.enabled) ?? h.sharpen.enabled, this.renderingPipeline.sharpen.colorAmount = ((K = e.sharpen) == null ? void 0 : K.colorAmount) ?? h.sharpen.colorAmount, this.renderingPipeline.sharpen.edgeAmount = ((U = e.sharpen) == null ? void 0 : U.edgeAmount) ?? h.sharpen.edgeAmount, this.renderingPipeline.imageProcessing.vignetteEnabled = ((W = e.vignette) == null ? void 0 : W.enabled) ?? h.vignette.enabled, (Q = e.vignette) != null && Q.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)
1196
+ switch (((Z = e.vignette) == null ? void 0 : Z.blendMode) ?? h.vignette.blendMode) {
1197
1197
  case "Multiply":
1198
1198
  this.renderingPipeline.imageProcessing.vignetteBlendMode = M.VIGNETTEMODE_MULTIPLY;
1199
1199
  break;
@@ -1201,12 +1201,12 @@ class et {
1201
1201
  this.renderingPipeline.imageProcessing.vignetteBlendMode = M.VIGNETTEMODE_OPAQUE;
1202
1202
  break;
1203
1203
  }
1204
- (Y = e.vignette) != null && Y.colorRgba ? this.renderingPipeline.imageProcessing.vignetteColor = new f(
1204
+ ($ = e.vignette) != null && $.colorRgba ? this.renderingPipeline.imageProcessing.vignetteColor = new f(
1205
1205
  e.vignette.colorRgba.r,
1206
1206
  e.vignette.colorRgba.g,
1207
1207
  e.vignette.colorRgba.b,
1208
1208
  e.vignette.colorRgba.a
1209
- ) : (Q = e.vignette) != null && Q.colorHex ? this.renderingPipeline.imageProcessing.vignetteColor = f.FromHexString(e.vignette.colorHex) : this.renderingPipeline.imageProcessing.vignetteColor = new f(
1209
+ ) : (Y = e.vignette) != null && Y.colorHex ? this.renderingPipeline.imageProcessing.vignetteColor = f.FromHexString(e.vignette.colorHex) : this.renderingPipeline.imageProcessing.vignetteColor = new f(
1210
1210
  h.vignette.colorRgba.r,
1211
1211
  h.vignette.colorRgba.g,
1212
1212
  h.vignette.colorRgba.b,
@@ -1215,30 +1215,30 @@ class et {
1215
1215
  }
1216
1216
  }
1217
1217
  updateColorCurve(e) {
1218
- const t = new ie();
1218
+ const t = new ne();
1219
1219
  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;
1220
1220
  }
1221
1221
  }
1222
- Pe.GLTFLoader.RegisterExtension("glbPostProcessor", function(a) {
1223
- return new ke(a);
1222
+ ye.GLTFLoader.RegisterExtension("glbPostProcessor", function(a) {
1223
+ return new Ne(a);
1224
1224
  });
1225
- ce.OnPluginActivatedObservable.add((a) => {
1225
+ ge.OnPluginActivatedObservable.add((a) => {
1226
1226
  if (a.name === "gltf") {
1227
1227
  const e = a;
1228
1228
  e.transparencyAsCoverage = !0;
1229
1229
  }
1230
1230
  });
1231
1231
  const x = "initialScene";
1232
- class _t {
1232
+ class qt {
1233
1233
  constructor(e) {
1234
1234
  this.loadProgress = /* @__PURE__ */ new Map([
1235
1235
  [x, 0]
1236
- ]), this.focusLostNotified = !1, this.loadObservable = new b(), this.focusLostObservable = new b(), this.initializedCallbacks = [], this.isInitialized = !1, this.modelLoadEventCallbacks = [], this.modelContainers = /* @__PURE__ */ new Map(), this.plugins = [], this.configuration = new De(e);
1236
+ ]), this.focusLostNotified = !1, this.loadObservable = new b(), this.focusLostObservable = new b(), this.initializedCallbacks = [], this.isInitialized = !1, this.modelLoadEventCallbacks = [], this.modelContainers = /* @__PURE__ */ new Map(), this.plugins = [], this.configuration = new ze(e);
1237
1237
  const i = (() => {
1238
1238
  if (!(e != null && e.noRender))
1239
1239
  return this.configuration.createCanvas();
1240
1240
  })(), r = "1.5.6";
1241
- ve.Configuration = {
1241
+ Ce.Configuration = {
1242
1242
  decoder: {
1243
1243
  wasmUrl: `https://www.gstatic.com/draco/versioned/decoders/${r}/draco_wasm_wrapper_gltf.js`,
1244
1244
  wasmBinaryUrl: `https://www.gstatic.com/draco/versioned/decoders/${r}/draco_decoder_gltf.wasm`,
@@ -1248,7 +1248,7 @@ class _t {
1248
1248
  const n = console.log;
1249
1249
  console.log = () => {
1250
1250
  };
1251
- const s = i ? new de(i, !0, {
1251
+ const s = i ? new ue(i, !0, {
1252
1252
  adaptToDeviceRatio: !0,
1253
1253
  limitDeviceRatio: 2,
1254
1254
  premultipliedAlpha: !1,
@@ -1256,12 +1256,12 @@ class _t {
1256
1256
  audioEngine: !1,
1257
1257
  stencil: this.configuration.highlights.enabled,
1258
1258
  forceSRGBBufferSupportState: !0
1259
- }) : new pe();
1260
- console.log = n, s.hideLoadingUI(), window.addEventListener("resize", this.fireResizeEvent.bind(this)), this.engine = s, this.scene = new Ce(s), this.camera = I.create(this.scene, this.configuration), this.renderingPipeline = new et(
1259
+ }) : new be();
1260
+ console.log = n, s.hideLoadingUI(), window.addEventListener("resize", this.fireResizeEvent.bind(this)), this.engine = s, this.scene = new Me(s), this.camera = I.create(this.scene, this.configuration), this.renderingPipeline = new tt(
1261
1261
  this.scene,
1262
1262
  !1,
1263
1263
  this.camera
1264
- ), this.scene.imageProcessingConfiguration.exposure = this.configuration.lighting.exposure, this.scene.imageProcessingConfiguration.contrast = this.configuration.lighting.contrast, this.glowLayerManager = new Ne(
1264
+ ), this.scene.imageProcessingConfiguration.exposure = this.configuration.lighting.exposure, this.scene.imageProcessingConfiguration.contrast = this.configuration.lighting.contrast, this.glowLayerManager = new Ve(
1265
1265
  this.scene,
1266
1266
  this.configuration.emissiveGlowIntensity
1267
1267
  );
@@ -1323,7 +1323,7 @@ class _t {
1323
1323
  }
1324
1324
  async initialize(e) {
1325
1325
  var i, r;
1326
- this.scene.clearColor = this.configuration.scene.clearColor, this.scene.environmentTexture = be.CreateFromPrefilteredData(
1326
+ this.scene.clearColor = this.configuration.scene.clearColor, this.scene.environmentTexture = we.CreateFromPrefilteredData(
1327
1327
  this.configuration.scene.environmentFile,
1328
1328
  this.scene
1329
1329
  );
@@ -1336,7 +1336,7 @@ class _t {
1336
1336
  s.loaded * 100 / s.total
1337
1337
  ), this.notifyLoadHandlers();
1338
1338
  }
1339
- ).getInitializationPromise()), this.loadProgress.set(x, 100), this.notifyLoadHandlers(), this.scene.activeCamera = this.camera, this.camera.rerunFramingBehavior(void 0, 1), qe(this.scene), ((i = this.engine.views) == null ? void 0 : i.length) >= 1 && this.reattachControls(
1339
+ ).getInitializationPromise()), this.loadProgress.set(x, 100), this.notifyLoadHandlers(), this.scene.activeCamera = this.camera, this.camera.rerunFramingBehavior(void 0, 1), Ke(this.scene), ((i = this.engine.views) == null ? void 0 : i.length) >= 1 && this.reattachControls(
1340
1340
  this.engine.views[this.engine.views.length - 1].target
1341
1341
  ), this.queuedCameraAnimation && (this.executeCameraAnimation(this.queuedCameraAnimation), this.queuedCameraAnimation = void 0), this.isInitialized = !0, await Promise.all(this.initializedCallbacks.map((n) => n())), this.initializedCallbacks = [], (r = this.configuration.options) != null && r.renderingPipelineConfiguration && this.renderingPipeline.setConfiguration(
1342
1342
  this.configuration.options.renderingPipelineConfiguration
@@ -1359,7 +1359,7 @@ class _t {
1359
1359
  this.queuedCameraAnimation = e;
1360
1360
  return;
1361
1361
  }
1362
- Ke(
1362
+ Ue(
1363
1363
  this.scene,
1364
1364
  this.scene.activeCamera,
1365
1365
  e
@@ -1415,7 +1415,7 @@ class _t {
1415
1415
  async renderSceneScreenshot(e, t) {
1416
1416
  if (!this.camera)
1417
1417
  throw new Error("Missing product camera, cannot render screenshot!");
1418
- const i = new he(
1418
+ const i = new de(
1419
1419
  "screenshotCamera",
1420
1420
  0,
1421
1421
  0,
@@ -1426,7 +1426,7 @@ class _t {
1426
1426
  try {
1427
1427
  const r = t.latDeg * Math.PI / 180, n = t.lonDeg * Math.PI / 180;
1428
1428
  i.target = t.target ? new g(t.target.x, t.target.y, t.target.z) : g.Zero(), i.alpha = n, i.beta = r, i.radius = t.radius || this.camera.radius, i.minZ = 0.01, this.scene.render();
1429
- const s = await we.CreateScreenshotUsingRenderTargetAsync(
1429
+ const s = await Pe.CreateScreenshotUsingRenderTargetAsync(
1430
1430
  this.engine,
1431
1431
  i,
1432
1432
  e,
@@ -1446,15 +1446,15 @@ class _t {
1446
1446
  const t = e.camera.limits.min.alpha, i = e.camera.limits.max.alpha, r = e.camera.limits.min.beta, n = e.camera.limits.max.beta;
1447
1447
  if (t === void 0 || i === void 0 || r === void 0 || n === void 0)
1448
1448
  return !0;
1449
- const s = [t, i], o = [r, n], l = s.every((c) => c === t), d = o.every((c) => c === r);
1450
- return !l && !d;
1449
+ const s = [t, i], o = [r, n], l = s.every((d) => d === t), c = o.every((d) => d === r);
1450
+ return !l && !c;
1451
1451
  }
1452
1452
  fireResizeEvent() {
1453
1453
  this.getNumViewports() > 0 && this.engine.resize();
1454
1454
  }
1455
1455
  setHighlights(e, t) {
1456
1456
  var r;
1457
- e.length === 0 && ((r = this.highlightLayer) == null || r.dispose(), this.highlightLayer = void 0), this.highlightLayer || (this.highlightLayer = new fe("highlights", this.scene, {
1457
+ e.length === 0 && ((r = this.highlightLayer) == null || r.dispose(), this.highlightLayer = void 0), this.highlightLayer || (this.highlightLayer = new ve("highlights", this.scene, {
1458
1458
  isStroke: !0,
1459
1459
  blurVerticalSize: 0.85,
1460
1460
  blurHorizontalSize: 0.85
@@ -1479,7 +1479,7 @@ class _t {
1479
1479
  this.renderingPipeline && this.renderingPipeline.setConfiguration(e);
1480
1480
  }
1481
1481
  loadModel(e, t) {
1482
- const i = new Je({
1482
+ const i = new et({
1483
1483
  enablePicking: this.configuration.highlights.enabled,
1484
1484
  modelDetails: e,
1485
1485
  scene: this.scene,
@@ -1574,8 +1574,8 @@ class _t {
1574
1574
  export {
1575
1575
  O as MaterialEffectMode,
1576
1576
  E as ProductCameraRig,
1577
- ze as REFLECTION_PROBE_RESOLUTION,
1577
+ ke as REFLECTION_PROBE_RESOLUTION,
1578
1578
  P as RenderingConfiguration,
1579
- _t as SpiffCommerce3DPreviewService,
1579
+ qt as SpiffCommerce3DPreviewService,
1580
1580
  h as renderingPipelineDefaults
1581
1581
  };
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- (function(l,v){typeof exports=="object"&&typeof module<"u"?v(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"],v):(l=typeof globalThis<"u"?globalThis:l||self,v(l.Preview={},l.arcRotateCamera,l.engine,l.nullEngine,l.highlightLayer,l.sceneLoader,l.cubeTexture,l.math_color,l.math_vector,l.dracoCompression,l.observable,l.tools,l.scene,l.glTF,l.pbrMaterial,l.mirrorTexture,l.math,l.reflectionProbe,l.glowLayer,l.actionManager,l.directActions,l.mesh,l.transformNode,l.dynamicTexture,l.texture,l.animation,l.easing,l.assetsManager,l.colorCurves,l.imageProcessingConfiguration,l.RenderPipeline,l.depthOfFieldEffect))})(this,function(l,v,j,be,fe,B,ve,p,g,ye,y,Ce,we,Me,E,Pe,P,xe,Le,O,D,Te,Ae,Re,Ee,C,q,Oe,z,x,Ie,I){"use strict";var L=(a=>(a[a.Orbit=0]="Orbit",a[a.Pan=1]="Pan",a))(L||{}),T=(a=>(a.None="None",a.RemoveWhenSelected="RemoveWhenSelected",a.ApplyWhenSelected="ApplyWhenSelected",a))(T||{});class Se{constructor(e){this.getSceneClearColor=()=>{var i,n,r,s;const t=(i=this.customOptions)!=null&&i.transparentBackground||(n=this.customOptions)!=null&&n.backgroundImage?0:1;if(this.customOptions&&((r=this.customOptions)!=null&&r.transparentBackground)||(s=this.customOptions)!=null&&s.backgroundImage)return new p.Color4(0,0,0,t).toLinearSpace();if(this.customOptions&&this.customOptions.backgroundColor){const o=p.Color3.FromHexString(this.customOptions.backgroundColor);return new p.Color4(o.r,o.g,o.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 n=p.Color3.FromHexString(t);return new p.Color4(n.r,n.g,n.b,i).toLinearSpace()},this.customOptions=e}createCanvas(){var e;return(e=this.customOptions)!=null&&e.createCanvas?this.customOptions.createCanvas():document.createElement("canvas")}get options(){return this.customOptions}get scene(){var e,t,i;return{clearColor:this.getSceneClearColor(),transparentBackground:((e=this.customOptions)==null?void 0:e.transparentBackground)||((t=this.customOptions)==null?void 0:t.backgroundImage),environmentFile:((i=this.customOptions)==null?void 0:i.environmentFile)??"assets/model-viewer/default.env"}}get camera(){var e,t,i,n,r,s,o,c,d,u,m,b,f;return{autoOrientation:((e=this.customOptions)==null?void 0:e.disableAutomaticOrientation)??!0,autoRotation:{enabled:((t=this.customOptions)==null?void 0:t.autoRotation)??!1,idleTimeMs:((i=this.customOptions)==null?void 0:i.idleTimeBeforeRotation)??5e3},limits:{min:{alpha:(n=this.customOptions)!=null&&n.lowerAlphaLimitDeg?((r=this.customOptions)==null?void 0:r.lowerAlphaLimitDeg)*Math.PI/180:void 0,beta:(s=this.customOptions)!=null&&s.lowerBetaLimitDeg?((o=this.customOptions)==null?void 0:o.lowerBetaLimitDeg)*Math.PI/180:void 0,radius:(c=this.customOptions)==null?void 0:c.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?((b=this.customOptions)==null?void 0:b.upperBetaLimitDeg)*Math.PI/180:void 0,radius:(f=this.customOptions)==null?void 0:f.maxZoomOverride}}}}get highlights(){var e;return{enabled:((e=this.customOptions)==null?void 0:e.highlightOnMaterialHover)??!1,color:this.highlightColorFromConfig()}}get lighting(){var e,t,i,n;return{exposure:((t=(e=this.customOptions)==null?void 0:e.lighting)==null?void 0:t.exposure)??.9,contrast:((n=(i=this.customOptions)==null?void 0:i.lighting)==null?void 0:n.contrast)??1.6}}get emissiveGlowIntensity(){var e;return((e=this.customOptions)==null?void 0:e.emissiveGlowIntensity)??.5}}class w{static getDynamicTextureResolution(){return this.getIsMobile()||!w.offscreenRenderingSupported()?{width:1024,height:1024}:{width:2048,height:2048}}static shouldMipMap(){return!0}static offscreenRenderingSupported(){return navigator.userAgent.includes("SamsungBrowser")?!1:!!window.Worker&&!!window.OffscreenCanvas}static getMirrorTextureResolution(){return this.getIsMobile()?512:1024}static getIsMobile(){try{return typeof window>"u"||!window.navigator?!1:/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(window.navigator.userAgent)||window.innerWidth<=480}catch{return!1}}}const V=128,h={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 Fe{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(n){t.extras&&Object.keys(t.extras).forEach(r=>{const s=t.extras[r];n.metadata[r]=s}),i(n)})}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 E.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(r){const s=[];return r.transformNodes.forEach(o=>{o.metadata&&o.metadata.reflective&&s.push(...o.getChildMeshes())}),r.meshes.forEach(o=>{o.metadata&&o.metadata.reflective&&!s.includes(o)&&s.push(o)}),s}function i(r,s=1){const o=r.material;if(!o)return;const c=new Pe.MirrorTexture("mirror",w.getMirrorTextureResolution(),e,!0);c.renderList=t(e);const d=r.getVerticesData("normal");if(!d)throw new Error("Mirror attribute specified on: "+r.name+"But no normals exist to generate a mirror from!");r.computeWorldMatrix(!0);const u=r.getWorldMatrix(),m=P.Vector3.TransformNormal(new P.Vector3(d[0],d[1],d[2]),u).normalize(),b=P.Plane.FromPositionAndNormal(r.position,m.scale(-1));c.mirrorPlane=b,c.level=s,o.reflectionTexture=c}function n(r){const s=r.material,o=new xe.ReflectionProbe("probe-"+s.name,V,e);o.attachToMesh(r),o.renderList&&o.renderList.push(...t(e)),s.reflectionTexture=o.cubeTexture}e.meshes.forEach(r=>{const s=r.metadata;s&&(s.mirrorTexture&&i(r,s.mirrorTexture),s.reflectionProbe&&n(r))})}}class je{constructor(e,t){this.scene=e,this.intensity=t,this.meshCount=0}includeMeshes(e){this.glowLayer||(this.glowLayer=new Le.GlowLayer("glow",this.scene),this.glowLayer.intensity=this.intensity),e.forEach(t=>{this.glowLayer.hasMesh(t)||(this.glowLayer.addIncludedOnlyMesh(t),this.meshCount++)})}removeMeshes(e){this.glowLayer&&(e.forEach(t=>{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 N(a,e,t){return new Promise((i,n)=>{const r=k.get(a);if(r&&r.scene.uid===e.uid)return i(r);B.SceneLoader.LoadAssetContainerAsync(a,void 0,e,t).then(s=>{k.set(a,s),i(s)}).catch(n)})}function Be(a,e,t,i,n=""){t.forEach(r=>{const s=r.getID(),o=r.getName(),c=w.getDynamicTextureResolution();a.filter(u=>u.name===n+o).forEach(u=>{const m=i.get(s),b=!1;if(m)G(u,m),m.update(b);else{const f=De(o,e,c.width,c.height);i.set(s,f),r.setStaticContext(f.getContext()),G(u,f),f.onLoadObservable.addOnce(()=>{f.update(b)})}})})}function De(a,e,t,i){const n=new Re.DynamicTexture(a,{width:t,height:i},e,w.shouldMipMap(),Ee.Texture.TRILINEAR_SAMPLINGMODE,j.Engine.TEXTUREFORMAT_RGBA),r=n.getContext();return r&&(r.fillStyle="#f5f5f5",r.fillRect(0,0,t,i),n.update()),n}function G(a,e){if(a instanceof E.PBRMaterial){const t=a,i=t.albedoTexture;i?(e.wrapU=i.wrapU,e.wrapV=i.wrapV):(e.wrapU=1,e.wrapV=1),t.albedoTexture=e}else{const t=a,i=t.diffuseTexture;i&&(e.wrapU=i.wrapU,e.wrapV=i.wrapV),t.diffuseTexture=e}}function qe(){const a=()=>Math.floor((1+Math.random())*65536).toString(16).substring(1);return a()+a()+"-"+a()+"-"+a()+"-"+a()+"-"+a()+a()+a()}const M=60,H=1;function K(a){return a.targetedAnimations.map(t=>t.animation.framePerSecond).reduce((t,i)=>t+i,0)/a.targetedAnimations.length||0}function ze(a,e,t,i,n){const r=n?a.filter(s=>s.name===n):a;if(r.length===0){console.warn(`No animations found for name: ${n}`);return}if(i!==void 0&&t!==void 0&&i===t){r.forEach(s=>{s.stop();const o=K(s),c=i*o;s.start(e,H,c,c)});return}r.forEach(s=>{s.stop();const o=K(s),c=i!==void 0?i*o:void 0,d=t!==void 0?t*o:void 0;s.start(e,H,c,d)})}function U(a){a.forEach(e=>{e.stop()})}function Ve(a){const e=a.animationGroups;U(e)}function ke(a,e,t){a.stopAnimation(e),e.animations=[],Math.abs(e.alpha)>2*Math.PI&&(e.alpha=Ne(e.alpha,0,2*Math.PI));const i=[],n=t.target,r=0,s=n?1:0;if(t.target&&Object.keys(t.target).length>0&&i.push(A("cameraTargetLerp","target",new g.Vector3().copyFrom(e.target),new g.Vector3(t.target.x,t.target.y,t.target.z),C.Animation.ANIMATIONTYPE_VECTOR3,r)),i.push(A("cameraAlphaLerp","alpha",e.alpha,W(t.lonDeg),C.Animation.ANIMATIONTYPE_FLOAT,s)),i.push(A("cameraBetaLerp","beta",e.beta,W(t.latDeg),C.Animation.ANIMATIONTYPE_FLOAT,s)),t.radius!==void 0){const d=Math.max(.01,t.radius);i.push(A("cameraRadiusLerp","radius",e.radius,d,C.Animation.ANIMATIONTYPE_FLOAT,s))}e.animations.push(...i);const c=e.useAutoRotationBehavior;e.disableAutoRotationBehavior(),a.beginAnimation(e,0,n?M*2:M,!1,1,()=>{e.animations=[],c&&e.enableAutoRotationBehavior()})}function W(a){return a*Math.PI/180}function A(a,e,t,i,n,r=0,s=C.Animation.ANIMATIONLOOPMODE_CONSTANT){const o=new q.QuadraticEase;o.setEasingMode(q.EasingFunction.EASINGMODE_EASEINOUT);const c=new C.Animation(a,e,M,n,s),d=[];return r>0&&d.push({frame:0,value:t}),d.push({frame:M*r,value:t}),d.push({frame:M*(r+1),value:i}),c.setKeys(d),c.setEasingFunction(o),c}function Ne(a,e,t){return a<e?a=t-(e-a)%(t-e):a=e+(a-e)%(t-e)}const Ge={albedoTexture:"albedoMap",bumpTexture:"normalMap",ambientTexture:"ambientMap",emissiveTexture:"emissionMap",opacityTexture:"alphaMap",metallicTexture:"metallicMap",refractionTexture:"refractionMap"};function He(a,e,t,i){["albedoTexture","bumpTexture","ambientTexture","emissiveTexture","opacityTexture","metallicTexture","refractionTexture"].forEach(r=>{Ke(r,a,e,t,i)}),Ze(a,e)}function Ke(a,e,t,i,n){const r=Ge[a];if(!r)throw new Error("Unexpected texture name encountered.");const s=e[r],o=s==null?void 0:s.fileLink;o?i.addTextureTask(a,o,!1,!1):n&&t[a]&&(t[a]&&t[a].dispose(),t[a]=null,Ue(a,t))}function Ue(a,e){a==="opacityTexture"&&(e.useAlphaFromAlbedoTexture=!0),a==="metallicTexture"&&(e.useRoughnessFromMetallicTextureAlpha=!1,e.useRoughnessFromMetallicTextureGreen=!1,e.useMetallnessFromMetallicTextureBlue=!1),a==="refractionTexture"&&(e.subSurface.isRefractionEnabled=!1,e.subSurface.refractionIntensity=1),a==="emissiveTexture"&&(e.emissiveIntensity=0,e.emissiveColor=new p.Color3(0,0,0))}function We(a,e,t,i){a==="opacityTexture"&&(e.useAlphaFromAlbedoTexture=!1),a==="metallicTexture"&&(e.useRoughnessFromMetallicTextureAlpha=!1,e.useRoughnessFromMetallicTextureGreen=!0,e.useMetallnessFromMetallicTextureBlue=!0),a==="refractionTexture"&&(e.subSurface.isRefractionEnabled=!0,e.subSurface.refractionIntensity=t.refractionIntensity||1),e[a]=i,a==="emissiveTexture"&&(e.emissiveColor=new p.Color3(1,1,1),e.emissiveIntensity=1)}function Ze(a,e){a.clearCoat&&(a.clearCoat===T.RemoveWhenSelected?(e.clearCoat.isEnabled=!1,e.clearCoat.indexOfRefraction=1.5):a.clearCoat===T.ApplyWhenSelected&&(e.clearCoat.isEnabled=!0,e.clearCoat.indexOfRefraction=a.clearCoatIOR||e.clearCoat.indexOfRefraction))}class $e{constructor(e,t,i){this.materialVariantMap=new Map,this.keysThatRemovedBaseModel=[],this.loadedContainerForKey=new Map,this.loadedMaterialsForKey=new Map,this.scene=e,this.renameClonedAsset=t,this.setBaseModelEnabled=i}async applyMaterial(e,t,i,n){return new Promise(r=>{const s=this.materialVariantMap.get(e);this.materialVariantMap.set(e,{...s,...t});const o=this.renameClonedAsset(e),c=this.scene.materials.filter(u=>u.name===o);if(c.length===0){r();return}const d=new Oe.AssetsManager(this.scene);d.useDefaultLoadingScreen=!1,c.forEach(u=>He(t,u,d,n)),d.onProgress=(u,m,b)=>{i&&i(u/m*100,100,b.name)},d.onFinish=u=>{u.forEach(m=>{const b=m;i&&i(100,100,m.name),c.forEach(f=>We(m.name,f,t,b.texture))}),r()},d.loadAsync()})}async applyModel(e,t,i,n){var c,d;if(i&&t&&!this.keysThatRemovedBaseModel.includes(e)&&this.keysThatRemovedBaseModel.push(e),!i)return this.keysThatRemovedBaseModel.includes(e)&&this.setBaseModelEnabled(!0),(c=this.loadedContainerForKey.get(e))==null||c.dispose(),this.loadedContainerForKey.delete(e),this.loadedMaterialsForKey.delete(e),Promise.resolve(void 0);this.loadedContainerForKey.has(e)&&((d=this.loadedContainerForKey.get(e))==null||d.dispose(),this.loadedContainerForKey.delete(e),this.loadedMaterialsForKey.delete(e)),t&&this.setBaseModelEnabled(!1);const s=(await N(i,this.scene,n)).instantiateModelsToScene(this.renameClonedAsset,!0);this.loadedContainerForKey.set(e,s),this.loadedMaterialsForKey.set(e,Z(s));const o=[];return this.materialVariantMap.forEach(async(u,m)=>{o.push(this.applyMaterial(m,u))}),await Promise.all(o),s}dispose(){this.loadedContainerForKey.forEach(e=>e==null?void 0:e.dispose()),this.loadedContainerForKey.clear(),this.loadedMaterialsForKey.forEach(e=>e.forEach(t=>t==null?void 0:t.dispose())),this.loadedMaterialsForKey.clear(),this.materialVariantMap.clear(),this.keysThatRemovedBaseModel=[]}getAllMaterials(){const e=[];return this.loadedMaterialsForKey.forEach(t=>{t.forEach(i=>{e.includes(i)||e.push(i)})}),e}getAnimationGroups(){const e=[];return this.loadedContainerForKey.forEach(t=>{e.push(...t.animationGroups)}),e}}function Z(a){const e=[];return a.rootNodes.forEach(t=>{t.getChildMeshes().forEach(i=>{i.material&&!e.includes(i.material)&&e.push(i.material),i.subMeshes&&i.subMeshes.forEach(n=>{const r=n.getMaterial(!1);r&&!e.includes(r)&&e.push(r)})})}),e}function $(a,e=""){return a.map(t=>({name:t.name.substring(e.length),loop:t.loopAnimation,to:t.to,from:t.from}))}class Ye{constructor(e){this.metadata=new Map,this.materialSelectedObservable=new y.Observable,this.materialDeselectedObservable=new y.Observable,this.materialVariantObservable=new y.Observable,this.modelVariantObservable=new y.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:n,progressHandler:r,scene:s}=e;this.enablePicking=t,this.contextService=i.contextService,this.id=qe(),this.previewService=n,this.scene=s,this.variantManager=new $e(s,this.renameClonedAsset.bind(this),this.setEnabled.bind(this)),this.previewService.registerInitializedListener(async()=>await this.processQueuedEvents()),this.transformRoot=new Ae.TransformNode("root",this.scene);const o=async()=>(this.assetContainer=await N(i.model,s,r),this.initialized=!0,this.instantiate(),this);this.importPromise=o()}async applyMaterialVariant(e,t,i,n){if(this.previewService.getSceneInitializationProgress()!==100||!this.initialized){if(this.materialReadyToLoadCallbacks.has(e)){const s=this.materialReadyToLoadCallbacks.get(e);s==null||s.set(t,this.applyMaterialVariant.bind(this,e,t,i,n))}else{this.materialReadyToLoadCallbacks.set(e,new Map);const s=this.materialReadyToLoadCallbacks.get(e);s==null||s.set(t,this.applyMaterialVariant.bind(this,e,t,i,n))}return}const r=async()=>{await this.variantManager.applyMaterial(e,i,(s,o,c)=>{this.materialVariantObservable.notifyObservers({remainingCount:s,totalCount:o,taskName:c})},n)};if(this.materialChangesInProgress.includes(e)){if(this.queuedMaterialChanges.has(e)){const s=this.queuedMaterialChanges.get(e);s==null||s.set(t,r)}else{this.queuedMaterialChanges.set(e,new Map);const s=this.queuedMaterialChanges.get(e);s==null||s.set(t,r)}return}this.materialChangesInProgress.push(e),await r(),this.queuedMaterialChanges.has(e)&&(this.queuedMaterialChanges.get(e).forEach(async o=>{await o()}),this.queuedMaterialChanges.delete(e)),this.materialChangesInProgress.splice(this.materialChangesInProgress.indexOf(e),1),this.configureGlowLayer()}async applyModelVariant(e,t,i){if(!this.previewService.getIsInitialized()||!this.initialized){this.modelReadyToLoadCallbacks.set(e,this.applyModelVariant.bind(this,e,t,i));return}const n=()=>this.variantManager.applyModel(e,i,t==null?void 0:t.model,o=>{this.modelVariantObservable.notifyObservers({...o,key:e})});if(this.modelChangesInProgress.includes(e)){this.queuedModelChanges.set(e,n);return}const s=await(async()=>{this.modelChangesInProgress.push(e);let o=await n();return this.queuedModelChanges.has(e)&&(o=await this.queuedModelChanges.get(e)(),this.queuedModelChanges.delete(e)),this.modelChangesInProgress.splice(this.modelChangesInProgress.indexOf(e),1),o})();this.modelInstance&&U(this.modelInstance.animationGroups),this.contextService||(this.contextService=t==null?void 0:t.contextService),s?this.configureModelInstance(s):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.getIsInitialized()){this.queuedModelAnimation=e;return}this.modelInstance&&ze([...this.modelInstance.animationGroups,...this.variantManager.getAnimationGroups()],e.loop,e.to,e.from,e.name?this.renameClonedAsset(e.name):void 0)}getAnimations(e){return[...this.animations,...e?$(this.variantManager.getAnimationGroups(),this.renameClonedAsset("")):[]]}getId(){return this.id}listMaterials(){var t;const e=(t=this.scene)==null?void 0:t.materials.filter(i=>i.name.startsWith(this.id));return e?e.map(i=>({id:i.id,name:this.stripIdFromName(i.name)})):[]}registerMaterialSelectedCallback(e){this.materialSelectedObservable.add(e)}unregisterMaterialSelectedCallback(e){this.materialSelectedObservable.removeCallback(e)}registerMaterialDeselectedCallback(e){this.materialDeselectedObservable.add(e)}unregisterMaterialDeselectedCallback(e){this.materialDeselectedObservable.removeCallback(e)}get position(){return this.transformRoot.position}set position(e){this.transformRoot.position=new g.Vector3(e.x,e.y,e.z)}get rotation(){return this.transformRoot.rotation}set rotation(e){this.transformRoot.rotation=new g.Vector3(e.x,e.y,e.z)}get scale(){return this.transformRoot.scaling}set scale(e){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 D.ExecuteCodeAction(O.ActionManager.OnPointerOverTrigger,n=>{n.meshUnderPointer&&i.material&&this.materialSelectedObservable.notifyObservers({id:i.material.id,name:this.stripIdFromName(i.material.name)})})),i.actionManager.registerAction(new D.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 E.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 r;const t=this.transformRoot.position,i=this.transformRoot.rotation,n=this.transformRoot.scaling;this.transformRoot.position=g.Vector3.Zero(),this.transformRoot.rotation=g.Vector3.Zero(),this.transformRoot.scaling=g.Vector3.One(),e.rootNodes.forEach(s=>{s.getChildTransformNodes(!0).forEach(o=>{o.rotation.subtractInPlace(new g.Vector3(0,Math.PI,0))}),s.rotation.addInPlace(new g.Vector3(0,Math.PI,0)),s.setParent(this.transformRoot,!0,!1)}),this.transformRoot.position=t,this.transformRoot.rotation=i,this.transformRoot.scaling=n,this.canvasPanels=((r=this.contextService)==null?void 0:r.getAll())||new Map,Be(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 Te.Mesh)).flat()}instantiate(){this.modelInstance=this.assetContainer.instantiateModelsToScene(this.renameClonedAsset.bind(this),!0),this.materials=Z(this.modelInstance),this.configureModelInstance(this.modelInstance),this.animations=$(this.modelInstance.animationGroups,this.renameClonedAsset("")),this.processQueuedEvents()}renameClonedAsset(e){return`${this.id}_${e}`}setEnabled(e){e&&!this.modelInstance?this.instantiate():!e&&this.modelInstance&&this.destroyInstance()}updateDynamicTextures(){var e;(e=this.canvasPanels)==null||e.forEach((t,i)=>{const n=this.dynamicTextures.get(i);n&&t.getStaticContextDirty()&&n.isReady()&&(n.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(){this.previewService.getIsInitialized()&&(await Promise.all(Array.from(this.materialReadyToLoadCallbacks.values()).map(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 v.ArcRotateCamera{constructor(e,t,i,n,r,s,o,c){super(e,t,i,n,r,s,c),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,o.camera.autoOrientation&&(this.alpha+=Math.PI),o&&(o.camera.limits.min.beta&&(this.lowerBetaLimit=o.camera.limits.min.beta),o.camera.limits.max.beta&&(this.upperBetaLimit=o.camera.limits.max.beta),o.camera.limits.min.alpha&&(this.lowerAlphaLimit=o.camera.limits.min.alpha),o.camera.limits.max.alpha&&(this.upperAlphaLimit=o.camera.limits.max.alpha),o.camera.limits.min.radius&&(this.lowerRadiusLimit=o.camera.limits.min.radius),o.camera.limits.max.radius&&(this.upperRadiusLimit=o.camera.limits.max.radius),o.camera.autoRotation.enabled&&this.enableAutoRotationBehavior(o.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 n=()=>{e&&e()},r=F(this._scene),s=r.max.subtract(r.min),o=r.min.add(s.scale(.5));this.setRadius(s.length()*1.5),this.wheelPrecision=100/this.radius,this.panningInertia=0,this.panningOriginTarget.copyFrom(o),this.panDenominator=s.length(),i.zoomOnBoundingInfo(r.min,r.max,void 0,n),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 n=F(e),r=n.max.subtract(n.min),s=n.min.add(r.scale(.5)),o=new S("ProductCamera",-(Math.PI/2),Math.PI/2,r.length()*1.5,s,e,t);return o.panningInertia=0,o.panningOriginTarget.copyFrom(s),o.panDenominator=r.length(),o.onAfterCheckInputsObservable.add(()=>{o.panningSensibility=1e3/o.panDenominator}),i&&(e.activeCamera=o),o}}function F(a){if(a.meshes.length===0)return{min:new g.Vector3(-1,-1,-1),max:new g.Vector3(1,1,1)};const e=a.meshes.filter(t=>t.name.toLowerCase().endsWith("_t")||t.name.toLowerCase().includes("_t_"));return a.getWorldExtends(t=>t.isVisible&&t.isEnabled()&&(e.length===0||e.includes(t)))}class Qe{constructor(e,t=!1,i=void 0){this.renderingPipeline=new Ie.DefaultRenderingPipeline("default",t,e,i?[i]:void 0,!1),this.renderingPipeline.isSupported&&(this.renderingPipeline.prepare(),this.setConfiguration(h))}dispose(){this.renderingPipeline.dispose()}getConfiguration(){return this.currentConfiguration}setConfiguration(e){var t,i,n,r,s,o,c,d,u,m,b,f,Y,Q,_,X,J,ee,te,ie,se,re,ne,ae,oe,le,he,ce,de,ue,ge,me,pe;if(this.renderingPipeline.isSupported){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=((n=e.bloom)==null?void 0:n.enabled)??h.bloom.enabled,this.renderingPipeline.bloomKernel=((r=e.bloom)==null?void 0:r.kernel)??h.bloom.kernel,this.renderingPipeline.bloomScale=((s=e.bloom)==null?void 0:s.scale)??h.bloom.scale,this.renderingPipeline.bloomThreshold=((o=e.bloom)==null?void 0:o.threshold)??h.bloom.threshold,this.renderingPipeline.bloomWeight=((c=e.bloom)==null?void 0:c.weight)??h.bloom.weight,this.renderingPipeline.chromaticAberrationEnabled=((d=e.chromaticAberration)==null?void 0:d.enabled)??h.chromaticAberration.enabled,this.renderingPipeline.chromaticAberration.aberrationAmount=((u=e.chromaticAberration)==null?void 0:u.aberrationAmount)??h.chromaticAberration.aberrationAmount,this.renderingPipeline.chromaticAberration.radialIntensity=((m=e.chromaticAberration)==null?void 0:m.radialIntensity)??h.chromaticAberration.radialIntensity,this.renderingPipeline.chromaticAberration.direction=(b=e.chromaticAberration)!=null&&b.direction?new g.Vector2(e.chromaticAberration.direction.x,e.chromaticAberration.direction.y):new g.Vector2(h.chromaticAberration.direction.x,h.chromaticAberration.direction.y),this.renderingPipeline.imageProcessing.colorCurvesEnabled=((f=e.colorCurves)==null?void 0:f.enabled)??h.colorCurves.enabled,this.renderingPipeline.imageProcessing.colorCurves=e.colorCurves?this.updateColorCurve(e.colorCurves):new z.ColorCurves,this.renderingPipeline.depthOfFieldEnabled=((Y=e.depthOfField)==null?void 0:Y.enabled)??h.depthOfField.enabled,e.depthOfField)switch(e.depthOfField.blurLevel??h.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=((Q=e.depthOfField)==null?void 0:Q.focalLength)??h.depthOfField.focalLength,this.renderingPipeline.depthOfField.fStop=((_=e.depthOfField)==null?void 0:_.fStop)??h.depthOfField.fStop,this.renderingPipeline.depthOfField.focusDistance=((X=e.depthOfField)==null?void 0:X.focusDistance)??h.depthOfField.focusDistance,this.renderingPipeline.depthOfField.lensSize=((J=e.depthOfField)==null?void 0:J.lensSize)??h.depthOfField.lensSize,this.renderingPipeline.grainEnabled=((ee=e.grain)==null?void 0:ee.enabled)??h.grain.enabled,this.renderingPipeline.grain.animated=((te=e.grain)==null?void 0:te.animated)??h.grain.animated,this.renderingPipeline.grain.intensity=((ie=e.grain)==null?void 0:ie.intensity)??h.grain.intensity,this.renderingPipeline.imageProcessing.contrast=((se=e.misc)==null?void 0:se.contrast)??h.misc.contrast,this.renderingPipeline.imageProcessing.exposure=((re=e.misc)==null?void 0:re.exposure)??h.misc.exposure,this.renderingPipeline.imageProcessing.toneMappingEnabled=((ne=e.misc)==null?void 0:ne.toneMappingEnabled)??h.misc.toneMappingEnabled,this.renderingPipeline.imageProcessing.toneMappingEnabled)switch(e.misc.toneMappingType??h.misc.toneMappingType){case"Standard":this.renderingPipeline.imageProcessing.toneMappingType=x.ImageProcessingConfiguration.TONEMAPPING_STANDARD;break;case"ACES":this.renderingPipeline.imageProcessing.toneMappingType=x.ImageProcessingConfiguration.TONEMAPPING_ACES;break}if(this.renderingPipeline.sharpenEnabled=((ae=e.sharpen)==null?void 0:ae.enabled)??h.sharpen.enabled,this.renderingPipeline.sharpen.colorAmount=((oe=e.sharpen)==null?void 0:oe.colorAmount)??h.sharpen.colorAmount,this.renderingPipeline.sharpen.edgeAmount=((le=e.sharpen)==null?void 0:le.edgeAmount)??h.sharpen.edgeAmount,this.renderingPipeline.imageProcessing.vignetteEnabled=((he=e.vignette)==null?void 0:he.enabled)??h.vignette.enabled,(ce=e.vignette)!=null&&ce.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)switch(((de=e.vignette)==null?void 0:de.blendMode)??h.vignette.blendMode){case"Multiply":this.renderingPipeline.imageProcessing.vignetteBlendMode=x.ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY;break;case"Opaque":this.renderingPipeline.imageProcessing.vignetteBlendMode=x.ImageProcessingConfiguration.VIGNETTEMODE_OPAQUE;break}(ue=e.vignette)!=null&&ue.colorRgba?this.renderingPipeline.imageProcessing.vignetteColor=new p.Color4(e.vignette.colorRgba.r,e.vignette.colorRgba.g,e.vignette.colorRgba.b,e.vignette.colorRgba.a):(ge=e.vignette)!=null&&ge.colorHex?this.renderingPipeline.imageProcessing.vignetteColor=p.Color4.FromHexString(e.vignette.colorHex):this.renderingPipeline.imageProcessing.vignetteColor=new p.Color4(h.vignette.colorRgba.r,h.vignette.colorRgba.g,h.vignette.colorRgba.b,h.vignette.colorRgba.a),this.renderingPipeline.imageProcessing.vignetteStretch=((me=e.vignette)==null?void 0:me.stretch)??h.vignette.stretch,this.renderingPipeline.imageProcessing.vignetteWeight=((pe=e.vignette)==null?void 0:pe.weight)??h.vignette.weight,this.renderingPipeline.prepare(),this.currentConfiguration=e}}updateColorCurve(e){const t=new z.ColorCurves;return t.globalDensity=e.globalDensity??t.globalDensity,t.globalExposure=e.globalExposure??t.globalExposure,t.globalHue=e.globalHue??t.globalHue,t.globalSaturation=e.globalSaturation??t.globalSaturation,t.highlightsDensity=e.highlightsDensity??t.highlightsDensity,t.highlightsExposure=e.highlightsExposure??t.highlightsExposure,t.highlightsHue=e.highlightsHue??t.highlightsHue,t.highlightsSaturation=e.highlightsSaturation??t.highlightsSaturation,t.midtonesDensity=e.midtonesDensity??t.midtonesDensity,t.midtonesExposure=e.midtonesExposure??t.midtonesExposure,t.midtonesHue=e.midtonesHue??t.midtonesHue,t.midtonesSaturation=e.midtonesSaturation??t.midtonesSaturation,t.shadowsDensity=e.shadowsDensity??t.shadowsDensity,t.shadowsExposure=e.shadowsExposure??t.shadowsExposure,t.shadowsHue=e.shadowsHue??t.shadowsHue,t.shadowsSaturation=e.shadowsSaturation??t.shadowsSaturation,t}}Me.GLTF2.GLTFLoader.RegisterExtension("glbPostProcessor",function(a){return new Fe(a)}),B.SceneLoader.OnPluginActivatedObservable.add(a=>{if(a.name==="gltf"){const e=a;e.transparencyAsCoverage=!0}});const R="initialScene";class _e{constructor(e){this.loadProgress=new Map([[R,0]]),this.focusLostNotified=!1,this.loadObservable=new y.Observable,this.focusLostObservable=new y.Observable,this.initializedCallbacks=[],this.isInitialized=!1,this.modelLoadEventCallbacks=[],this.modelContainers=new Map,this.plugins=[],this.configuration=new Se(e);const i=(()=>{if(!(e!=null&&e.noRender))return this.configuration.createCanvas()})(),n="1.5.6";ye.DracoCompression.Configuration={decoder:{wasmUrl:`https://www.gstatic.com/draco/versioned/decoders/${n}/draco_wasm_wrapper_gltf.js`,wasmBinaryUrl:`https://www.gstatic.com/draco/versioned/decoders/${n}/draco_decoder_gltf.wasm`,fallbackUrl:`https://www.gstatic.com/draco/versioned/decoders/${n}/draco_decoder_gltf.js`}},i&&(i.getContext("webgl2")||i.getContext("webgl"));const r=console.log;console.log=()=>{};const s=i?new j.Engine(i,!0,{adaptToDeviceRatio:!0,limitDeviceRatio:2,premultipliedAlpha:!1,preserveDrawingBuffer:!!(e!=null&&e.backgroundImage),audioEngine:!1,stencil:this.configuration.highlights.enabled,forceSRGBBufferSupportState:!0}):new be.NullEngine;console.log=r,s.hideLoadingUI(),window.addEventListener("resize",this.fireResizeEvent.bind(this)),this.engine=s,this.scene=new we.Scene(s),this.camera=S.create(this.scene,this.configuration),this.renderingPipeline=new Qe(this.scene,!1,this.camera),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)}getEngineContext(){return{engine:this.engine,scene:this.scene,camera:this.camera}}registerFocusLostListener(e){this.focusLostObservable.add(e)}unregisterFocusLostListener(e){this.focusLostObservable.removeCallback(e)}registerLoadProgressListener(e){this.loadObservable.add(e),e(this.getLoadListenerEvent())}unregisterLoadProgressListener(e){this.loadObservable.removeCallback(e)}registerInitializedListener(e){this.isInitialized||!this.isInitialized&&this.initializedCallbacks.push(e)}unregisterInitializedListener(e){if(this.isInitialized)return;const t=this.initializedCallbacks.indexOf(e);t>-1&&this.initializedCallbacks.splice(t,1)}getIsInitialized(){return this.isInitialized}registerModelLoadEventListener(e){this.modelLoadEventCallbacks.push(e)}unregisterModelLoadEventListener(e){const t=this.modelLoadEventCallbacks.indexOf(e);t>-1&&this.modelLoadEventCallbacks.splice(t,1)}registerView(e){const t=e.height,i=e.width;this.engine.registerView(e),e.setAttribute("height",t.toString()),e.setAttribute("width",i.toString()),this.orbitEnabled()||this.setCameraState(L.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)}getSceneInitializationProgress(){return this.loadProgress.get(R)}async initialize(e){var i,n;this.scene.clearColor=this.configuration.scene.clearColor,this.scene.environmentTexture=ve.CubeTexture.CreateFromPrefilteredData(this.configuration.scene.environmentFile,this.scene);let t;return e&&(t=await this.loadModel(e,s=>{this.loadProgress.set(R,s.loaded*100/s.total),this.notifyLoadHandlers()}).getInitializationPromise()),this.loadProgress.set(R,100),this.notifyLoadHandlers(),this.scene.activeCamera=this.camera,this.camera.rerunFramingBehavior(void 0,1),Ve(this.scene),((i=this.engine.views)==null?void 0:i.length)>=1&&this.reattachControls(this.engine.views[this.engine.views.length-1].target),this.queuedCameraAnimation&&(this.executeCameraAnimation(this.queuedCameraAnimation),this.queuedCameraAnimation=void 0),this.isInitialized=!0,await Promise.all(this.initializedCallbacks.map(r=>r())),this.initializedCallbacks=[],(n=this.configuration.options)!=null&&n.renderingPipelineConfiguration&&this.renderingPipeline.setConfiguration(this.configuration.options.renderingPipelineConfiguration),this.engine.runRenderLoop(()=>{this.engine.views&&(this.modelContainers.forEach(r=>{r.updateDynamicTextures()}),this.configuration.scene.transparentBackground&&this.engine.views.forEach(r=>{const s=this.engine.getRenderingCanvas();r.target.getContext("2d").clearRect(0,0,s.width,s.height)}),this.scene.render(),!this.camera.target.equalsWithEpsilon(this.camera.lastFocus,.1)&&!this.focusLostNotified&&(this.focusLostObservable.notifyObservers(void 0),this.focusLostNotified=!0),this.screenshotPrepareResolve&&(this.screenshotPrepareResolve(),this.screenshotPrepareResolve=void 0))}),t}executeCameraAnimation(e){if(this.getSceneInitializationProgress()!==100||!this.camera||this.scene.activeCamera!==this.camera){this.queuedCameraAnimation=e;return}ke(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===L.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 v.ArcRotateCamera("screenshotCamera",0,0,0,g.Vector3.Zero(),this.scene);try{const n=t.latDeg*Math.PI/180,r=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=r,i.beta=n,i.radius=t.radius||this.camera.radius,i.minZ=.01,this.scene.render();const s=await Ce.Tools.CreateScreenshotUsingRenderTargetAsync(this.engine,i,e,"image/png",2,!0);return i.dispose(),s}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,n=e.camera.limits.min.beta,r=e.camera.limits.max.beta;if(t===void 0||i===void 0||n===void 0||r===void 0)return!0;const s=[t,i],o=[n,r],c=s.every(u=>u===t),d=o.every(u=>u===n);return!c&&!d}fireResizeEvent(){this.getNumViewports()>0&&this.engine.resize()}setHighlights(e,t){var n;e.length===0&&((n=this.highlightLayer)==null||n.dispose(),this.highlightLayer=void 0),this.highlightLayer||(this.highlightLayer=new fe.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(r=>{const s=this.scene.materials.find(o=>o.name===r.name&&o.id===r.id);s&&s.getBindedMeshes().forEach(o=>{var c;return(c=this.highlightLayer)==null?void 0:c.addMesh(o,i||p.Color3.FromHexString("#fcba03"))})})}setRenderingPipelineConfiguration(e){this.renderingPipeline&&this.renderingPipeline.setConfiguration(e)}loadModel(e,t){const i=new Ye({enablePicking:this.configuration.highlights.enabled,modelDetails:e,scene:this.scene,previewService:this,progressHandler:t});return i.registerMaterialVariantListener(n=>this.handleMaterialProgressCallback(n.remainingCount,n.totalCount,n.taskName)),i.registerModelVariantListener(n=>this.handleModelProgressCallback(n,n.key)),this.configuration.highlights.enabled&&(i.registerMaterialSelectedCallback(n=>{this.setHighlights([n])}),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(n=>n.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))}handleMaterialProgressCallback(e,t,i){this.loadProgress.set(`key_${i}`,e/t*100),this.notifyLoadHandlers()}handleModelProgressCallback(e,t){this.loadProgress.set(t,e.loaded*100/e.total),this.notifyLoadHandlers()}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)}getLoadListenerEvent(){const e=Array.from(this.loadProgress.values()).filter(n=>n<100),i=e.reduce((n,r)=>n+r,0)/e.length||0;return{loadValue:e.length===0?100:i,sceneInitialized:this.getSceneInitializationProgress()===100}}notifyLoadHandlers(){this.loadObservable.notifyObservers(this.getLoadListenerEvent())}}l.MaterialEffectMode=T,l.ProductCameraRig=L,l.REFLECTION_PROBE_RESOLUTION=V,l.RenderingConfiguration=w,l.SpiffCommerce3DPreviewService=_e,l.renderingPipelineDefaults=h,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
1
+ (function(l,v){typeof exports=="object"&&typeof module<"u"?v(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"],v):(l=typeof globalThis<"u"?globalThis:l||self,v(l.Preview={},l.arcRotateCamera,l.engine,l.nullEngine,l.highlightLayer,l.sceneLoader,l.cubeTexture,l.math_color,l.math_vector,l.dracoCompression,l.observable,l.tools,l.scene,l.glTF,l.pbrMaterial,l.mirrorTexture,l.math,l.reflectionProbe,l.glowLayer,l.actionManager,l.directActions,l.mesh,l.transformNode,l.dynamicTexture,l.texture,l.animation,l.easing,l.assetsManager,l.colorCurves,l.imageProcessingConfiguration,l.RenderPipeline,l.depthOfFieldEffect))})(this,function(l,v,j,fe,ve,B,ye,p,g,Ce,y,we,Me,Pe,E,xe,P,Le,Te,O,D,Re,q,Ae,Ee,C,V,Oe,z,x,Ie,I){"use strict";var L=(a=>(a[a.Orbit=0]="Orbit",a[a.Pan=1]="Pan",a))(L||{}),T=(a=>(a.None="None",a.RemoveWhenSelected="RemoveWhenSelected",a.ApplyWhenSelected="ApplyWhenSelected",a))(T||{});class Se{constructor(e){this.getSceneClearColor=()=>{var i,n,r,s;const t=(i=this.customOptions)!=null&&i.transparentBackground||(n=this.customOptions)!=null&&n.backgroundImage?0:1;if(this.customOptions&&((r=this.customOptions)!=null&&r.transparentBackground)||(s=this.customOptions)!=null&&s.backgroundImage)return new p.Color4(0,0,0,t).toLinearSpace();if(this.customOptions&&this.customOptions.backgroundColor){const o=p.Color3.FromHexString(this.customOptions.backgroundColor);return new p.Color4(o.r,o.g,o.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 n=p.Color3.FromHexString(t);return new p.Color4(n.r,n.g,n.b,i).toLinearSpace()},this.customOptions=e}createCanvas(){var e;return(e=this.customOptions)!=null&&e.createCanvas?this.customOptions.createCanvas():document.createElement("canvas")}get options(){return this.customOptions}get scene(){var e,t,i;return{clearColor:this.getSceneClearColor(),transparentBackground:((e=this.customOptions)==null?void 0:e.transparentBackground)||((t=this.customOptions)==null?void 0:t.backgroundImage),environmentFile:((i=this.customOptions)==null?void 0:i.environmentFile)??"assets/model-viewer/default.env"}}get camera(){var e,t,i,n,r,s,o,c,d,u,m,b,f;return{autoOrientation:((e=this.customOptions)==null?void 0:e.disableAutomaticOrientation)??!0,autoRotation:{enabled:((t=this.customOptions)==null?void 0:t.autoRotation)??!1,idleTimeMs:((i=this.customOptions)==null?void 0:i.idleTimeBeforeRotation)??5e3},limits:{min:{alpha:(n=this.customOptions)!=null&&n.lowerAlphaLimitDeg?((r=this.customOptions)==null?void 0:r.lowerAlphaLimitDeg)*Math.PI/180:void 0,beta:(s=this.customOptions)!=null&&s.lowerBetaLimitDeg?((o=this.customOptions)==null?void 0:o.lowerBetaLimitDeg)*Math.PI/180:void 0,radius:(c=this.customOptions)==null?void 0:c.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?((b=this.customOptions)==null?void 0:b.upperBetaLimitDeg)*Math.PI/180:void 0,radius:(f=this.customOptions)==null?void 0:f.maxZoomOverride}}}}get highlights(){var e;return{enabled:((e=this.customOptions)==null?void 0:e.highlightOnMaterialHover)??!1,color:this.highlightColorFromConfig()}}get lighting(){var e,t,i,n;return{exposure:((t=(e=this.customOptions)==null?void 0:e.lighting)==null?void 0:t.exposure)??.9,contrast:((n=(i=this.customOptions)==null?void 0:i.lighting)==null?void 0:n.contrast)??1.6}}get emissiveGlowIntensity(){var e;return((e=this.customOptions)==null?void 0:e.emissiveGlowIntensity)??.5}}class w{static getDynamicTextureResolution(){return this.getIsMobile()||!w.offscreenRenderingSupported()?{width:1024,height:1024}:{width:2048,height:2048}}static shouldMipMap(){return!0}static offscreenRenderingSupported(){return navigator.userAgent.includes("SamsungBrowser")?!1:!!window.Worker&&!!window.OffscreenCanvas}static getMirrorTextureResolution(){return this.getIsMobile()?512:1024}static getIsMobile(){try{return typeof window>"u"||!window.navigator?!1:/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(window.navigator.userAgent)||window.innerWidth<=480}catch{return!1}}}const k=128,h={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 Fe{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(n){t.extras&&Object.keys(t.extras).forEach(r=>{const s=t.extras[r];n.metadata[r]=s}),i(n)})}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 E.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(r){const s=[];return r.transformNodes.forEach(o=>{o.metadata&&o.metadata.reflective&&s.push(...o.getChildMeshes())}),r.meshes.forEach(o=>{o.metadata&&o.metadata.reflective&&!s.includes(o)&&s.push(o)}),s}function i(r,s=1){const o=r.material;if(!o)return;const c=new xe.MirrorTexture("mirror",w.getMirrorTextureResolution(),e,!0);c.renderList=t(e);const d=r.getVerticesData("normal");if(!d)throw new Error("Mirror attribute specified on: "+r.name+"But no normals exist to generate a mirror from!");r.computeWorldMatrix(!0);const u=r.getWorldMatrix(),m=P.Vector3.TransformNormal(new P.Vector3(d[0],d[1],d[2]),u).normalize(),b=P.Plane.FromPositionAndNormal(r.position,m.scale(-1));c.mirrorPlane=b,c.level=s,o.reflectionTexture=c}function n(r){const s=r.material,o=new Le.ReflectionProbe("probe-"+s.name,k,e);o.attachToMesh(r),o.renderList&&o.renderList.push(...t(e)),s.reflectionTexture=o.cubeTexture}e.meshes.forEach(r=>{const s=r.metadata;s&&(s.mirrorTexture&&i(r,s.mirrorTexture),s.reflectionProbe&&n(r))})}}class je{constructor(e,t){this.scene=e,this.intensity=t,this.meshCount=0}includeMeshes(e){this.glowLayer||(this.glowLayer=new Te.GlowLayer("glow",this.scene),this.glowLayer.intensity=this.intensity),e.forEach(t=>{this.glowLayer.hasMesh(t)||(this.glowLayer.addIncludedOnlyMesh(t),this.meshCount++)})}removeMeshes(e){this.glowLayer&&(e.forEach(t=>{this.glowLayer.hasMesh(t)&&(this.glowLayer.removeIncludedOnlyMesh(t),this.meshCount--)}),this.meshCount===0&&(this.glowLayer.dispose(),this.glowLayer=void 0))}}const N=new Map;async function G(a,e,t){return new Promise((i,n)=>{const r=N.get(a);if(r&&r.scene.uid===e.uid)return i(r);B.SceneLoader.LoadAssetContainerAsync(a,void 0,e,t).then(s=>{N.set(a,s),i(s)}).catch(n)})}function Be(a,e,t,i,n=""){t.forEach(r=>{const s=r.getID(),o=r.getName(),c=w.getDynamicTextureResolution();a.filter(u=>u.name===n+o).forEach(u=>{const m=i.get(s),b=!1;if(m)H(u,m),m.update(b);else{const f=De(o,e,c.width,c.height);i.set(s,f),r.setStaticContext(f.getContext()),H(u,f),f.onLoadObservable.addOnce(()=>{f.update(b)})}})})}function De(a,e,t,i){const n=new Ae.DynamicTexture(a,{width:t,height:i},e,w.shouldMipMap(),Ee.Texture.TRILINEAR_SAMPLINGMODE,j.Engine.TEXTUREFORMAT_RGBA),r=n.getContext();return r&&(r.fillStyle="#f5f5f5",r.fillRect(0,0,t,i),n.update()),n}function H(a,e){if(a instanceof E.PBRMaterial){const t=a,i=t.albedoTexture;i?(e.wrapU=i.wrapU,e.wrapV=i.wrapV):(e.wrapU=1,e.wrapV=1),t.albedoTexture=e}else{const t=a,i=t.diffuseTexture;i&&(e.wrapU=i.wrapU,e.wrapV=i.wrapV),t.diffuseTexture=e}}function qe(){const a=()=>Math.floor((1+Math.random())*65536).toString(16).substring(1);return a()+a()+"-"+a()+"-"+a()+"-"+a()+"-"+a()+a()+a()}const M=60,K=1;function U(a){return a.targetedAnimations.map(t=>t.animation.framePerSecond).reduce((t,i)=>t+i,0)/a.targetedAnimations.length||0}function Ve(a,e,t,i,n){const r=n?a.filter(s=>s.name===n):a;if(r.length===0){console.warn(`No animations found for name: ${n}`);return}if(i!==void 0&&t!==void 0&&i===t){r.forEach(s=>{s.stop();const o=U(s),c=i*o;s.start(e,K,c,c)});return}r.forEach(s=>{s.stop();const o=U(s),c=i!==void 0?i*o:void 0,d=t!==void 0?t*o:void 0;s.start(e,K,c,d)})}function W(a){a.forEach(e=>{e.stop()})}function ze(a){const e=a.animationGroups;W(e)}function ke(a,e,t){a.stopAnimation(e),e.animations=[],Math.abs(e.alpha)>2*Math.PI&&(e.alpha=Ne(e.alpha,0,2*Math.PI));const i=[],n=t.target,r=0,s=n?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),C.Animation.ANIMATIONTYPE_VECTOR3,r)),i.push(R("cameraAlphaLerp","alpha",e.alpha,Q(t.lonDeg),C.Animation.ANIMATIONTYPE_FLOAT,s)),i.push(R("cameraBetaLerp","beta",e.beta,Q(t.latDeg),C.Animation.ANIMATIONTYPE_FLOAT,s)),t.radius!==void 0){const d=Math.max(.01,t.radius);i.push(R("cameraRadiusLerp","radius",e.radius,d,C.Animation.ANIMATIONTYPE_FLOAT,s))}e.animations.push(...i);const c=e.useAutoRotationBehavior;e.disableAutoRotationBehavior(),a.beginAnimation(e,0,n?M*2:M,!1,1,()=>{e.animations=[],c&&e.enableAutoRotationBehavior()})}function Q(a){return a*Math.PI/180}function R(a,e,t,i,n,r=0,s=C.Animation.ANIMATIONLOOPMODE_CONSTANT){const o=new V.QuadraticEase;o.setEasingMode(V.EasingFunction.EASINGMODE_EASEINOUT);const c=new C.Animation(a,e,M,n,s),d=[];return r>0&&d.push({frame:0,value:t}),d.push({frame:M*r,value:t}),d.push({frame:M*(r+1),value:i}),c.setKeys(d),c.setEasingFunction(o),c}function Ne(a,e,t){return a<e?a=t-(e-a)%(t-e):a=e+(a-e)%(t-e)}const Ge={albedoTexture:"albedoMap",bumpTexture:"normalMap",ambientTexture:"ambientMap",emissiveTexture:"emissionMap",opacityTexture:"alphaMap",metallicTexture:"metallicMap",refractionTexture:"refractionMap"};function He(a,e,t,i){["albedoTexture","bumpTexture","ambientTexture","emissiveTexture","opacityTexture","metallicTexture","refractionTexture"].forEach(r=>{Ke(r,a,e,t,i)}),Qe(a,e)}function Ke(a,e,t,i,n){const r=Ge[a];if(!r)throw new Error("Unexpected texture name encountered.");const s=e[r],o=s==null?void 0:s.fileLink;o?i.addTextureTask(a,o,!1,!1):n&&t[a]&&(t[a]&&t[a].dispose(),t[a]=null,Ue(a,t))}function Ue(a,e){a==="opacityTexture"&&(e.useAlphaFromAlbedoTexture=!0),a==="metallicTexture"&&(e.useRoughnessFromMetallicTextureAlpha=!1,e.useRoughnessFromMetallicTextureGreen=!1,e.useMetallnessFromMetallicTextureBlue=!1),a==="refractionTexture"&&(e.subSurface.isRefractionEnabled=!1,e.subSurface.refractionIntensity=1),a==="emissiveTexture"&&(e.emissiveIntensity=0,e.emissiveColor=new p.Color3(0,0,0))}function We(a,e,t,i){a==="opacityTexture"&&(e.useAlphaFromAlbedoTexture=!1),a==="metallicTexture"&&(e.useRoughnessFromMetallicTextureAlpha=!1,e.useRoughnessFromMetallicTextureGreen=!0,e.useMetallnessFromMetallicTextureBlue=!0),a==="refractionTexture"&&(e.subSurface.isRefractionEnabled=!0,e.subSurface.refractionIntensity=t.refractionIntensity||1),e[a]=i,a==="emissiveTexture"&&(e.emissiveColor=new p.Color3(1,1,1),e.emissiveIntensity=1)}function Qe(a,e){a.clearCoat&&(a.clearCoat===T.RemoveWhenSelected?(e.clearCoat.isEnabled=!1,e.clearCoat.indexOfRefraction=1.5):a.clearCoat===T.ApplyWhenSelected&&(e.clearCoat.isEnabled=!0,e.clearCoat.indexOfRefraction=a.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,n){return new Promise(r=>{const s=this.materialVariantMap.get(e);this.materialVariantMap.set(e,{...s,...t});const o=this.renameClonedAsset(e),c=this.scene.materials.filter(u=>u.name===o);if(c.length===0){r();return}const d=new Oe.AssetsManager(this.scene);d.useDefaultLoadingScreen=!1,c.forEach(u=>He(t,u,d,n)),d.onProgress=(u,m,b)=>{i&&i(u/m*100,100,b.name)},d.onFinish=u=>{u.forEach(m=>{const b=m;i&&i(100,100,m.name),c.forEach(f=>We(m.name,f,t,b.texture))}),r()},d.loadAsync()})}async applyModel(e,t,i,n){var c,d;if(i&&t&&!this.keysThatRemovedBaseModel.includes(e)&&this.keysThatRemovedBaseModel.push(e),!i)return this.keysThatRemovedBaseModel.includes(e)&&this.setBaseModelEnabled(!0),(c=this.loadedContainerForKey.get(e))==null||c.dispose(),this.loadedContainerForKey.delete(e),this.loadedMaterialsForKey.delete(e),Promise.resolve(void 0);this.loadedContainerForKey.has(e)&&((d=this.loadedContainerForKey.get(e))==null||d.dispose(),this.loadedContainerForKey.delete(e),this.loadedMaterialsForKey.delete(e)),t&&this.setBaseModelEnabled(!1);const s=(await G(i,this.scene,n)).instantiateModelsToScene(this.renameClonedAsset,!0);this.loadedContainerForKey.set(e,s),this.loadedMaterialsForKey.set(e,Z(s));const o=[];return this.materialVariantMap.forEach(async(u,m)=>{o.push(this.applyMaterial(m,u))}),await Promise.all(o),s}dispose(){this.loadedContainerForKey.forEach(e=>e==null?void 0:e.dispose()),this.loadedContainerForKey.clear(),this.loadedMaterialsForKey.forEach(e=>e.forEach(t=>t==null?void 0:t.dispose())),this.loadedMaterialsForKey.clear(),this.materialVariantMap.clear(),this.keysThatRemovedBaseModel=[]}getAllMaterials(){const e=[];return this.loadedMaterialsForKey.forEach(t=>{t.forEach(i=>{e.includes(i)||e.push(i)})}),e}getAnimationGroups(){const e=[];return this.loadedContainerForKey.forEach(t=>{e.push(...t.animationGroups)}),e}}function Z(a){const e=[];return a.rootNodes.forEach(t=>{t.getChildMeshes().forEach(i=>{i.material&&!e.includes(i.material)&&e.push(i.material),i.subMeshes&&i.subMeshes.forEach(n=>{const r=n.getMaterial(!1);r&&!e.includes(r)&&e.push(r)})})}),e}function $(a,e=""){return a.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 y.Observable,this.materialDeselectedObservable=new y.Observable,this.materialVariantObservable=new y.Observable,this.modelVariantObservable=new y.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:n,progressHandler:r,scene:s}=e;this.enablePicking=t,this.contextService=i.contextService,this.id=qe(),this.previewService=n,this.scene=s,this.variantManager=new Ze(s,this.renameClonedAsset.bind(this),this.setEnabled.bind(this)),this.previewService.registerInitializedListener(async()=>await this.processQueuedEvents()),this.transformRoot=new q.TransformNode("root",this.scene),this.rotationRoot=new q.TransformNode("rotationRoot",this.scene),this.rotationRoot.setParent(this.transformRoot,!0,!1),this.rotationRoot.rotation=new g.Vector3(0,Math.PI,0);const o=async()=>(this.assetContainer=await G(i.model,s,r),this.initialized=!0,this.instantiate(),this);this.importPromise=o()}async applyMaterialVariant(e,t,i,n){if(this.previewService.getSceneInitializationProgress()!==100||!this.initialized){if(this.materialReadyToLoadCallbacks.has(e)){const s=this.materialReadyToLoadCallbacks.get(e);s==null||s.set(t,this.applyMaterialVariant.bind(this,e,t,i,n))}else{this.materialReadyToLoadCallbacks.set(e,new Map);const s=this.materialReadyToLoadCallbacks.get(e);s==null||s.set(t,this.applyMaterialVariant.bind(this,e,t,i,n))}return}const r=async()=>{await this.variantManager.applyMaterial(e,i,(s,o,c)=>{this.materialVariantObservable.notifyObservers({remainingCount:s,totalCount:o,taskName:c})},n)};if(this.materialChangesInProgress.includes(e)){if(this.queuedMaterialChanges.has(e)){const s=this.queuedMaterialChanges.get(e);s==null||s.set(t,r)}else{this.queuedMaterialChanges.set(e,new Map);const s=this.queuedMaterialChanges.get(e);s==null||s.set(t,r)}return}this.materialChangesInProgress.push(e),await r(),this.queuedMaterialChanges.has(e)&&(this.queuedMaterialChanges.get(e).forEach(async o=>{await o()}),this.queuedMaterialChanges.delete(e)),this.materialChangesInProgress.splice(this.materialChangesInProgress.indexOf(e),1),this.configureGlowLayer()}async applyModelVariant(e,t,i){if(!this.previewService.getIsInitialized()||!this.initialized){this.modelReadyToLoadCallbacks.set(e,this.applyModelVariant.bind(this,e,t,i));return}const n=()=>this.variantManager.applyModel(e,i,t==null?void 0:t.model,o=>{this.modelVariantObservable.notifyObservers({...o,key:e})});if(this.modelChangesInProgress.includes(e)){this.queuedModelChanges.set(e,n);return}const s=await(async()=>{this.modelChangesInProgress.push(e);let o=await n();return this.queuedModelChanges.has(e)&&(o=await this.queuedModelChanges.get(e)(),this.queuedModelChanges.delete(e)),this.modelChangesInProgress.splice(this.modelChangesInProgress.indexOf(e),1),o})();this.modelInstance&&W(this.modelInstance.animationGroups),this.contextService||(this.contextService=t==null?void 0:t.contextService),s?this.configureModelInstance(s):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.getIsInitialized()){this.queuedModelAnimation=e;return}this.modelInstance&&Ve([...this.modelInstance.animationGroups,...this.variantManager.getAnimationGroups()],e.loop,e.to,e.from,e.name?this.renameClonedAsset(e.name):void 0)}getAnimations(e){return[...this.animations,...e?$(this.variantManager.getAnimationGroups(),this.renameClonedAsset("")):[]]}getId(){return this.id}listMaterials(){var t;const e=(t=this.scene)==null?void 0:t.materials.filter(i=>i.name.startsWith(this.id));return e?e.map(i=>({id:i.id,name:this.stripIdFromName(i.name)})):[]}registerMaterialSelectedCallback(e){this.materialSelectedObservable.add(e)}unregisterMaterialSelectedCallback(e){this.materialSelectedObservable.removeCallback(e)}registerMaterialDeselectedCallback(e){this.materialDeselectedObservable.add(e)}unregisterMaterialDeselectedCallback(e){this.materialDeselectedObservable.removeCallback(e)}get position(){return this.transformRoot.position}set position(e){this.transformRoot.position=new g.Vector3(e.x,e.y,e.z)}get rotation(){return this.transformRoot.rotation}set rotation(e){this.transformRoot.rotation=new g.Vector3(e.x,e.y,e.z)}get scale(){return this.transformRoot.scaling}set scale(e){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 D.ExecuteCodeAction(O.ActionManager.OnPointerOverTrigger,n=>{n.meshUnderPointer&&i.material&&this.materialSelectedObservable.notifyObservers({id:i.material.id,name:this.stripIdFromName(i.material.name)})})),i.actionManager.registerAction(new D.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 E.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 r;const t=this.transformRoot.position,i=this.transformRoot.rotation,n=this.transformRoot.scaling;this.transformRoot.position=g.Vector3.Zero(),this.transformRoot.rotation=g.Vector3.Zero(),this.transformRoot.scaling=g.Vector3.One(),this.rotationRoot.rotation=new g.Vector3(0,0,0),e.rootNodes.forEach(s=>{s.rotationQuaternion||(s.rotationQuaternion=g.Quaternion.FromEulerVector(s.rotation)),s.rotationQuaternion.subtractInPlace(g.Quaternion.FromEulerAngles(0,Math.PI,0)),s.setParent(this.rotationRoot,!0,!1)}),this.rotationRoot.rotation=new g.Vector3(0,Math.PI,0),this.transformRoot.position=t,this.transformRoot.rotation=i,this.transformRoot.scaling=n,this.canvasPanels=((r=this.contextService)==null?void 0:r.getAll())||new Map,Be(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()}instantiate(){this.modelInstance=this.assetContainer.instantiateModelsToScene(this.renameClonedAsset.bind(this),!0),this.materials=Z(this.modelInstance),this.configureModelInstance(this.modelInstance),this.animations=$(this.modelInstance.animationGroups,this.renameClonedAsset("")),this.processQueuedEvents()}renameClonedAsset(e){return`${this.id}_${e}`}setEnabled(e){e&&!this.modelInstance?this.instantiate():!e&&this.modelInstance&&this.destroyInstance()}updateDynamicTextures(){var e;(e=this.canvasPanels)==null||e.forEach((t,i)=>{const n=this.dynamicTextures.get(i);n&&t.getStaticContextDirty()&&n.isReady()&&(n.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(){this.previewService.getIsInitialized()&&(await Promise.all(Array.from(this.materialReadyToLoadCallbacks.values()).map(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 v.ArcRotateCamera{constructor(e,t,i,n,r,s,o,c){super(e,t,i,n,r,s,c),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,o.camera.autoOrientation&&(this.alpha+=Math.PI),o&&(o.camera.limits.min.beta&&(this.lowerBetaLimit=o.camera.limits.min.beta),o.camera.limits.max.beta&&(this.upperBetaLimit=o.camera.limits.max.beta),o.camera.limits.min.alpha&&(this.lowerAlphaLimit=o.camera.limits.min.alpha),o.camera.limits.max.alpha&&(this.upperAlphaLimit=o.camera.limits.max.alpha),o.camera.limits.min.radius&&(this.lowerRadiusLimit=o.camera.limits.min.radius),o.camera.limits.max.radius&&(this.upperRadiusLimit=o.camera.limits.max.radius),o.camera.autoRotation.enabled&&this.enableAutoRotationBehavior(o.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 n=()=>{e&&e()},r=F(this._scene),s=r.max.subtract(r.min),o=r.min.add(s.scale(.5));this.setRadius(s.length()*1.5),this.wheelPrecision=100/this.radius,this.panningInertia=0,this.panningOriginTarget.copyFrom(o),this.panDenominator=s.length(),i.zoomOnBoundingInfo(r.min,r.max,void 0,n),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 n=F(e),r=n.max.subtract(n.min),s=n.min.add(r.scale(.5)),o=new S("ProductCamera",-(Math.PI/2),Math.PI/2,r.length()*1.5,s,e,t);return o.panningInertia=0,o.panningOriginTarget.copyFrom(s),o.panDenominator=r.length(),o.onAfterCheckInputsObservable.add(()=>{o.panningSensibility=1e3/o.panDenominator}),i&&(e.activeCamera=o),o}}function F(a){if(a.meshes.length===0)return{min:new g.Vector3(-1,-1,-1),max:new g.Vector3(1,1,1)};const e=a.meshes.filter(t=>t.name.toLowerCase().endsWith("_t")||t.name.toLowerCase().includes("_t_"));return a.getWorldExtends(t=>t.isVisible&&t.isEnabled()&&(e.length===0||e.includes(t)))}class Ye{constructor(e,t=!1,i=void 0){this.renderingPipeline=new Ie.DefaultRenderingPipeline("default",t,e,i?[i]:void 0,!1),this.renderingPipeline.isSupported&&(this.renderingPipeline.prepare(),this.setConfiguration(h))}dispose(){this.renderingPipeline.dispose()}getConfiguration(){return this.currentConfiguration}setConfiguration(e){var t,i,n,r,s,o,c,d,u,m,b,f,Y,X,_,J,ee,te,ie,se,re,ne,ae,oe,le,he,ce,de,ue,ge,me,pe,be;if(this.renderingPipeline.isSupported){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=((n=e.bloom)==null?void 0:n.enabled)??h.bloom.enabled,this.renderingPipeline.bloomKernel=((r=e.bloom)==null?void 0:r.kernel)??h.bloom.kernel,this.renderingPipeline.bloomScale=((s=e.bloom)==null?void 0:s.scale)??h.bloom.scale,this.renderingPipeline.bloomThreshold=((o=e.bloom)==null?void 0:o.threshold)??h.bloom.threshold,this.renderingPipeline.bloomWeight=((c=e.bloom)==null?void 0:c.weight)??h.bloom.weight,this.renderingPipeline.chromaticAberrationEnabled=((d=e.chromaticAberration)==null?void 0:d.enabled)??h.chromaticAberration.enabled,this.renderingPipeline.chromaticAberration.aberrationAmount=((u=e.chromaticAberration)==null?void 0:u.aberrationAmount)??h.chromaticAberration.aberrationAmount,this.renderingPipeline.chromaticAberration.radialIntensity=((m=e.chromaticAberration)==null?void 0:m.radialIntensity)??h.chromaticAberration.radialIntensity,this.renderingPipeline.chromaticAberration.direction=(b=e.chromaticAberration)!=null&&b.direction?new g.Vector2(e.chromaticAberration.direction.x,e.chromaticAberration.direction.y):new g.Vector2(h.chromaticAberration.direction.x,h.chromaticAberration.direction.y),this.renderingPipeline.imageProcessing.colorCurvesEnabled=((f=e.colorCurves)==null?void 0:f.enabled)??h.colorCurves.enabled,this.renderingPipeline.imageProcessing.colorCurves=e.colorCurves?this.updateColorCurve(e.colorCurves):new z.ColorCurves,this.renderingPipeline.depthOfFieldEnabled=((Y=e.depthOfField)==null?void 0:Y.enabled)??h.depthOfField.enabled,e.depthOfField)switch(e.depthOfField.blurLevel??h.depthOfField.blurLevel){case"Low":this.renderingPipeline.depthOfFieldBlurLevel=I.DepthOfFieldEffectBlurLevel.Low;break;case"Medium":this.renderingPipeline.depthOfFieldBlurLevel=I.DepthOfFieldEffectBlurLevel.Medium;break;case"High":this.renderingPipeline.depthOfFieldBlurLevel=I.DepthOfFieldEffectBlurLevel.High;break}if(this.renderingPipeline.depthOfField.focalLength=((X=e.depthOfField)==null?void 0:X.focalLength)??h.depthOfField.focalLength,this.renderingPipeline.depthOfField.fStop=((_=e.depthOfField)==null?void 0:_.fStop)??h.depthOfField.fStop,this.renderingPipeline.depthOfField.focusDistance=((J=e.depthOfField)==null?void 0:J.focusDistance)??h.depthOfField.focusDistance,this.renderingPipeline.depthOfField.lensSize=((ee=e.depthOfField)==null?void 0:ee.lensSize)??h.depthOfField.lensSize,this.renderingPipeline.grainEnabled=((te=e.grain)==null?void 0:te.enabled)??h.grain.enabled,this.renderingPipeline.grain.animated=((ie=e.grain)==null?void 0:ie.animated)??h.grain.animated,this.renderingPipeline.grain.intensity=((se=e.grain)==null?void 0:se.intensity)??h.grain.intensity,this.renderingPipeline.imageProcessing.contrast=((re=e.misc)==null?void 0:re.contrast)??h.misc.contrast,this.renderingPipeline.imageProcessing.exposure=((ne=e.misc)==null?void 0:ne.exposure)??h.misc.exposure,this.renderingPipeline.imageProcessing.toneMappingEnabled=((ae=e.misc)==null?void 0:ae.toneMappingEnabled)??h.misc.toneMappingEnabled,this.renderingPipeline.imageProcessing.toneMappingEnabled)switch(e.misc.toneMappingType??h.misc.toneMappingType){case"Standard":this.renderingPipeline.imageProcessing.toneMappingType=x.ImageProcessingConfiguration.TONEMAPPING_STANDARD;break;case"ACES":this.renderingPipeline.imageProcessing.toneMappingType=x.ImageProcessingConfiguration.TONEMAPPING_ACES;break}if(this.renderingPipeline.sharpenEnabled=((oe=e.sharpen)==null?void 0:oe.enabled)??h.sharpen.enabled,this.renderingPipeline.sharpen.colorAmount=((le=e.sharpen)==null?void 0:le.colorAmount)??h.sharpen.colorAmount,this.renderingPipeline.sharpen.edgeAmount=((he=e.sharpen)==null?void 0:he.edgeAmount)??h.sharpen.edgeAmount,this.renderingPipeline.imageProcessing.vignetteEnabled=((ce=e.vignette)==null?void 0:ce.enabled)??h.vignette.enabled,(de=e.vignette)!=null&&de.center?(this.renderingPipeline.imageProcessing.vignetteCenterX=e.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=e.vignette.center.y):(this.renderingPipeline.imageProcessing.vignetteCenterX=h.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=h.vignette.center.y),e.vignette)switch(((ue=e.vignette)==null?void 0:ue.blendMode)??h.vignette.blendMode){case"Multiply":this.renderingPipeline.imageProcessing.vignetteBlendMode=x.ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY;break;case"Opaque":this.renderingPipeline.imageProcessing.vignetteBlendMode=x.ImageProcessingConfiguration.VIGNETTEMODE_OPAQUE;break}(ge=e.vignette)!=null&&ge.colorRgba?this.renderingPipeline.imageProcessing.vignetteColor=new p.Color4(e.vignette.colorRgba.r,e.vignette.colorRgba.g,e.vignette.colorRgba.b,e.vignette.colorRgba.a):(me=e.vignette)!=null&&me.colorHex?this.renderingPipeline.imageProcessing.vignetteColor=p.Color4.FromHexString(e.vignette.colorHex):this.renderingPipeline.imageProcessing.vignetteColor=new p.Color4(h.vignette.colorRgba.r,h.vignette.colorRgba.g,h.vignette.colorRgba.b,h.vignette.colorRgba.a),this.renderingPipeline.imageProcessing.vignetteStretch=((pe=e.vignette)==null?void 0:pe.stretch)??h.vignette.stretch,this.renderingPipeline.imageProcessing.vignetteWeight=((be=e.vignette)==null?void 0:be.weight)??h.vignette.weight,this.renderingPipeline.prepare(),this.currentConfiguration=e}}updateColorCurve(e){const t=new z.ColorCurves;return t.globalDensity=e.globalDensity??t.globalDensity,t.globalExposure=e.globalExposure??t.globalExposure,t.globalHue=e.globalHue??t.globalHue,t.globalSaturation=e.globalSaturation??t.globalSaturation,t.highlightsDensity=e.highlightsDensity??t.highlightsDensity,t.highlightsExposure=e.highlightsExposure??t.highlightsExposure,t.highlightsHue=e.highlightsHue??t.highlightsHue,t.highlightsSaturation=e.highlightsSaturation??t.highlightsSaturation,t.midtonesDensity=e.midtonesDensity??t.midtonesDensity,t.midtonesExposure=e.midtonesExposure??t.midtonesExposure,t.midtonesHue=e.midtonesHue??t.midtonesHue,t.midtonesSaturation=e.midtonesSaturation??t.midtonesSaturation,t.shadowsDensity=e.shadowsDensity??t.shadowsDensity,t.shadowsExposure=e.shadowsExposure??t.shadowsExposure,t.shadowsHue=e.shadowsHue??t.shadowsHue,t.shadowsSaturation=e.shadowsSaturation??t.shadowsSaturation,t}}Pe.GLTF2.GLTFLoader.RegisterExtension("glbPostProcessor",function(a){return new Fe(a)}),B.SceneLoader.OnPluginActivatedObservable.add(a=>{if(a.name==="gltf"){const e=a;e.transparencyAsCoverage=!0}});const A="initialScene";class Xe{constructor(e){this.loadProgress=new Map([[A,0]]),this.focusLostNotified=!1,this.loadObservable=new y.Observable,this.focusLostObservable=new y.Observable,this.initializedCallbacks=[],this.isInitialized=!1,this.modelLoadEventCallbacks=[],this.modelContainers=new Map,this.plugins=[],this.configuration=new Se(e);const i=(()=>{if(!(e!=null&&e.noRender))return this.configuration.createCanvas()})(),n="1.5.6";Ce.DracoCompression.Configuration={decoder:{wasmUrl:`https://www.gstatic.com/draco/versioned/decoders/${n}/draco_wasm_wrapper_gltf.js`,wasmBinaryUrl:`https://www.gstatic.com/draco/versioned/decoders/${n}/draco_decoder_gltf.wasm`,fallbackUrl:`https://www.gstatic.com/draco/versioned/decoders/${n}/draco_decoder_gltf.js`}},i&&(i.getContext("webgl2")||i.getContext("webgl"));const r=console.log;console.log=()=>{};const s=i?new j.Engine(i,!0,{adaptToDeviceRatio:!0,limitDeviceRatio:2,premultipliedAlpha:!1,preserveDrawingBuffer:!!(e!=null&&e.backgroundImage),audioEngine:!1,stencil:this.configuration.highlights.enabled,forceSRGBBufferSupportState:!0}):new fe.NullEngine;console.log=r,s.hideLoadingUI(),window.addEventListener("resize",this.fireResizeEvent.bind(this)),this.engine=s,this.scene=new Me.Scene(s),this.camera=S.create(this.scene,this.configuration),this.renderingPipeline=new Ye(this.scene,!1,this.camera),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)}getEngineContext(){return{engine:this.engine,scene:this.scene,camera:this.camera}}registerFocusLostListener(e){this.focusLostObservable.add(e)}unregisterFocusLostListener(e){this.focusLostObservable.removeCallback(e)}registerLoadProgressListener(e){this.loadObservable.add(e),e(this.getLoadListenerEvent())}unregisterLoadProgressListener(e){this.loadObservable.removeCallback(e)}registerInitializedListener(e){this.isInitialized||!this.isInitialized&&this.initializedCallbacks.push(e)}unregisterInitializedListener(e){if(this.isInitialized)return;const t=this.initializedCallbacks.indexOf(e);t>-1&&this.initializedCallbacks.splice(t,1)}getIsInitialized(){return this.isInitialized}registerModelLoadEventListener(e){this.modelLoadEventCallbacks.push(e)}unregisterModelLoadEventListener(e){const t=this.modelLoadEventCallbacks.indexOf(e);t>-1&&this.modelLoadEventCallbacks.splice(t,1)}registerView(e){const t=e.height,i=e.width;this.engine.registerView(e),e.setAttribute("height",t.toString()),e.setAttribute("width",i.toString()),this.orbitEnabled()||this.setCameraState(L.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)}getSceneInitializationProgress(){return this.loadProgress.get(A)}async initialize(e){var i,n;this.scene.clearColor=this.configuration.scene.clearColor,this.scene.environmentTexture=ye.CubeTexture.CreateFromPrefilteredData(this.configuration.scene.environmentFile,this.scene);let t;return e&&(t=await this.loadModel(e,s=>{this.loadProgress.set(A,s.loaded*100/s.total),this.notifyLoadHandlers()}).getInitializationPromise()),this.loadProgress.set(A,100),this.notifyLoadHandlers(),this.scene.activeCamera=this.camera,this.camera.rerunFramingBehavior(void 0,1),ze(this.scene),((i=this.engine.views)==null?void 0:i.length)>=1&&this.reattachControls(this.engine.views[this.engine.views.length-1].target),this.queuedCameraAnimation&&(this.executeCameraAnimation(this.queuedCameraAnimation),this.queuedCameraAnimation=void 0),this.isInitialized=!0,await Promise.all(this.initializedCallbacks.map(r=>r())),this.initializedCallbacks=[],(n=this.configuration.options)!=null&&n.renderingPipelineConfiguration&&this.renderingPipeline.setConfiguration(this.configuration.options.renderingPipelineConfiguration),this.engine.runRenderLoop(()=>{this.engine.views&&(this.modelContainers.forEach(r=>{r.updateDynamicTextures()}),this.configuration.scene.transparentBackground&&this.engine.views.forEach(r=>{const s=this.engine.getRenderingCanvas();r.target.getContext("2d").clearRect(0,0,s.width,s.height)}),this.scene.render(),!this.camera.target.equalsWithEpsilon(this.camera.lastFocus,.1)&&!this.focusLostNotified&&(this.focusLostObservable.notifyObservers(void 0),this.focusLostNotified=!0),this.screenshotPrepareResolve&&(this.screenshotPrepareResolve(),this.screenshotPrepareResolve=void 0))}),t}executeCameraAnimation(e){if(this.getSceneInitializationProgress()!==100||!this.camera||this.scene.activeCamera!==this.camera){this.queuedCameraAnimation=e;return}ke(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===L.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 v.ArcRotateCamera("screenshotCamera",0,0,0,g.Vector3.Zero(),this.scene);try{const n=t.latDeg*Math.PI/180,r=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=r,i.beta=n,i.radius=t.radius||this.camera.radius,i.minZ=.01,this.scene.render();const s=await we.Tools.CreateScreenshotUsingRenderTargetAsync(this.engine,i,e,"image/png",2,!0);return i.dispose(),s}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,n=e.camera.limits.min.beta,r=e.camera.limits.max.beta;if(t===void 0||i===void 0||n===void 0||r===void 0)return!0;const s=[t,i],o=[n,r],c=s.every(u=>u===t),d=o.every(u=>u===n);return!c&&!d}fireResizeEvent(){this.getNumViewports()>0&&this.engine.resize()}setHighlights(e,t){var n;e.length===0&&((n=this.highlightLayer)==null||n.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(r=>{const s=this.scene.materials.find(o=>o.name===r.name&&o.id===r.id);s&&s.getBindedMeshes().forEach(o=>{var c;return(c=this.highlightLayer)==null?void 0:c.addMesh(o,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.registerMaterialVariantListener(n=>this.handleMaterialProgressCallback(n.remainingCount,n.totalCount,n.taskName)),i.registerModelVariantListener(n=>this.handleModelProgressCallback(n,n.key)),this.configuration.highlights.enabled&&(i.registerMaterialSelectedCallback(n=>{this.setHighlights([n])}),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(n=>n.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))}handleMaterialProgressCallback(e,t,i){this.loadProgress.set(`key_${i}`,e/t*100),this.notifyLoadHandlers()}handleModelProgressCallback(e,t){this.loadProgress.set(t,e.loaded*100/e.total),this.notifyLoadHandlers()}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)}getLoadListenerEvent(){const e=Array.from(this.loadProgress.values()).filter(n=>n<100),i=e.reduce((n,r)=>n+r,0)/e.length||0;return{loadValue:e.length===0?100:i,sceneInitialized:this.getSceneInitializationProgress()===100}}notifyLoadHandlers(){this.loadObservable.notifyObservers(this.getLoadListenerEvent())}}l.MaterialEffectMode=T,l.ProductCameraRig=L,l.REFLECTION_PROBE_RESOLUTION=k,l.RenderingConfiguration=w,l.SpiffCommerce3DPreviewService=Xe,l.renderingPipelineDefaults=h,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spiffcommerce/preview",
3
- "version": "4.0.2-alpha.4",
3
+ "version": "4.0.2-alpha.5",
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",