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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -266,7 +266,7 @@ type ModelLoadEventData = {
266
266
  /**
267
267
  * The type of event that has occurred.
268
268
  */
269
- readonly eventType: "load" | "unload";
269
+ readonly eventType: 'load' | 'unload';
270
270
  /**
271
271
  * The model that has been loaded or unloaded.
272
272
  */
@@ -528,7 +528,6 @@ type CameraAnimation = {
528
528
  readonly latDeg: number;
529
529
  /**
530
530
  * An optional target for the camera to focus on in the scene.
531
- * This should be provided as left handed coordinates. They will be converted internally.
532
531
  */
533
532
  readonly target?: {
534
533
  readonly x: number;
@@ -640,7 +639,7 @@ interface DepthOfFieldPipelineConfiguration {
640
639
  /**
641
640
  * The quality of the blur. Higher values will provide better quality but will be slower.
642
641
  */
643
- blurLevel?: "Low" | "Medium" | "High";
642
+ blurLevel?: 'Low' | 'Medium' | 'High';
644
643
  /**
645
644
  * The distance from the camera to the focus point.
646
645
  */
@@ -692,7 +691,7 @@ interface MiscPipelineConfiguration {
692
691
  * The type of tone mapping to use. "Standard" or "ACES". "ACES" applies a tone that is similar to Unity and Unreal.
693
692
  * @default "standard"
694
693
  */
695
- toneMappingType?: "Standard" | "ACES";
694
+ toneMappingType?: 'Standard' | 'ACES';
696
695
  }
697
696
  /**
698
697
  * Sharpening is a post processing effect that increases the contrast between pixels.
@@ -713,7 +712,7 @@ interface VignettePipelineConfiguration {
713
712
  /**
714
713
  * "Multiply" or "Opaque". "Multiply" will mix the vignette color with the scene color. "Opaque" will replace the scene color with the vignette color.
715
714
  */
716
- blendMode?: "Multiply" | "Opaque";
715
+ blendMode?: 'Multiply' | 'Opaque';
717
716
  /**
718
717
  * The FOV of the camera. This is used to calculate the vignette size.
719
718
  */
@@ -1153,4 +1152,20 @@ declare const REFLECTION_PROBE_RESOLUTION = 128;
1153
1152
  type PowerOfTwoNumber = 128 | 256 | 512 | 1024 | 2048 | 4096 | 8192;
1154
1153
  declare const renderingPipelineDefaults: RenderingPipelineConfiguration;
1155
1154
 
1156
- export { AntiAliasingPipelineConfiguration, Asset, BloomPipelineConfiguration, CameraAnimation, CameraPose, ChromaticAberrationPipelineConfiguration, Color4Configuration, ColorCurvesConfiguration, DepthOfFieldPipelineConfiguration, EngineContext, GrainPipelineConfiguration, LoadProgressEventData, MaterialEffectMode, MaterialHandle, MaterialResource, MiscPipelineConfiguration, ModelAnimation, ModelContainer, ModelDetails, ModelLoadEventData, PowerOfTwoNumber, PreviewOptions, PreviewServicePlugin, ProductCameraRig, REFLECTION_PROBE_RESOLUTION, RenderableContext, RenderableContextService, RenderingConfiguration, RenderingPipelineConfiguration, SharpenPipelineConfiguration, SpiffCommerce3DPreviewService, ThreeDPreviewService, Vector, VignettePipelineConfiguration, renderingPipelineDefaults };
1155
+ /**
1156
+ * Rotates a transform around the origin.
1157
+ * @param transform The transform to rotate. All values are optional and default to standard identity values.
1158
+ * @param axis The axis to rotate around. Defaults to the Y axis.
1159
+ * @param angle The angle to rotate by. Defaults to PI (180 degrees);
1160
+ */
1161
+ declare function rotateAroundOrigin(transform: {
1162
+ position?: Vector3;
1163
+ rotation?: Vector3;
1164
+ scale?: Vector3;
1165
+ }, axis?: Vector3, angle?: number): {
1166
+ position: Vector3;
1167
+ rotation: Vector3;
1168
+ scale: Vector3;
1169
+ };
1170
+
1171
+ export { AntiAliasingPipelineConfiguration, Asset, BloomPipelineConfiguration, CameraAnimation, CameraPose, ChromaticAberrationPipelineConfiguration, Color4Configuration, ColorCurvesConfiguration, DepthOfFieldPipelineConfiguration, EngineContext, GrainPipelineConfiguration, LoadProgressEventData, MaterialEffectMode, MaterialHandle, MaterialResource, MiscPipelineConfiguration, ModelAnimation, ModelContainer, ModelDetails, ModelLoadEventData, PowerOfTwoNumber, PreviewOptions, PreviewServicePlugin, ProductCameraRig, REFLECTION_PROBE_RESOLUTION, RenderableContext, RenderableContextService, RenderingConfiguration, RenderingPipelineConfiguration, SharpenPipelineConfiguration, SpiffCommerce3DPreviewService, ThreeDPreviewService, Vector, VignettePipelineConfiguration, renderingPipelineDefaults, rotateAroundOrigin };
package/dist/index.esm.js CHANGED
@@ -1,33 +1,33 @@
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, Vector2 as J, Matrix as ee, Quaternion as te } 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 Me } from "@babylonjs/core/Misc/tools";
12
+ import { Scene as Pe } 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 ie, Plane as Ae } from "@babylonjs/core/Maths/math";
17
+ import { ReflectionProbe as Oe } from "@babylonjs/core/Probes/reflectionProbe";
18
+ import { GlowLayer as Re } 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 Oe } from "@babylonjs/core/Meshes/transformNode";
23
- import { DynamicTexture as Ee } from "@babylonjs/core/Materials/Textures/dynamicTexture";
24
- import { Texture as Te } from "@babylonjs/core/Materials/Textures/texture";
20
+ import { ExecuteCodeAction as se } from "@babylonjs/core/Actions/directActions";
21
+ import { Mesh as Ee } from "@babylonjs/core/Meshes/mesh";
22
+ import { TransformNode as Te } from "@babylonjs/core/Meshes/transformNode";
23
+ import { DynamicTexture as Ie } from "@babylonjs/core/Materials/Textures/dynamicTexture";
24
+ import { Texture as Se } 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";
29
- import { ImageProcessingConfiguration as M } from "@babylonjs/core/Materials/imageProcessingConfiguration";
30
- import { DefaultRenderingPipeline as Be } from "@babylonjs/core/PostProcesses/RenderPipeline";
26
+ import { QuadraticEase as Fe, EasingFunction as Be } from "@babylonjs/core/Animations/easing";
27
+ import { AssetsManager as De } from "@babylonjs/core/Misc/assetsManager";
28
+ import { ColorCurves as ne } from "@babylonjs/core/Materials/colorCurves";
29
+ import { ImageProcessingConfiguration as P } from "@babylonjs/core/Materials/imageProcessingConfiguration";
30
+ import { DefaultRenderingPipeline as ze } from "@babylonjs/core/PostProcesses/RenderPipeline";
31
31
  import { DepthOfFieldEffectBlurLevel as A } from "@babylonjs/core/PostProcesses/depthOfFieldEffect";
32
32
  import "@babylonjs/core/Rendering/depthRendererSceneComponent";
33
33
  import "@babylonjs/core/Engines/Extensions/engine.views";
@@ -39,8 +39,8 @@ import "@babylonjs/core/Animations/animatable";
39
39
  import "@babylonjs/core/Misc/screenshotTools";
40
40
  import "@babylonjs/core/Rendering/boundingBoxRenderer";
41
41
  import "@babylonjs/loaders/glTF/2.0/Extensions";
42
- var O = /* @__PURE__ */ ((a) => (a[a.Orbit = 0] = "Orbit", a[a.Pan = 1] = "Pan", a))(O || {}), E = /* @__PURE__ */ ((a) => (a.None = "None", a.RemoveWhenSelected = "RemoveWhenSelected", a.ApplyWhenSelected = "ApplyWhenSelected", a))(E || {});
43
- class De {
42
+ var R = /* @__PURE__ */ ((a) => (a[a.Orbit = 0] = "Orbit", a[a.Pan = 1] = "Pan", a))(R || {}), E = /* @__PURE__ */ ((a) => (a.None = "None", a.RemoveWhenSelected = "RemoveWhenSelected", a.ApplyWhenSelected = "ApplyWhenSelected", a))(E || {});
43
+ class ke {
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
  }
@@ -135,12 +135,12 @@ class De {
135
135
  return ((e = this.customOptions) == null ? void 0 : e.emissiveGlowIntensity) ?? 0.5;
136
136
  }
137
137
  }
138
- class P {
138
+ class M {
139
139
  /**
140
140
  * Returns the resolution expected for generated textures.
141
141
  */
142
142
  static getDynamicTextureResolution() {
143
- return this.getIsMobile() || !P.offscreenRenderingSupported() ? {
143
+ return this.getIsMobile() || !M.offscreenRenderingSupported() ? {
144
144
  width: 1024,
145
145
  height: 1024
146
146
  } : {
@@ -176,7 +176,7 @@ class P {
176
176
  }
177
177
  }
178
178
  }
179
- const ze = 128, h = {
179
+ const Ne = 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 Ve {
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
- P.getMirrorTextureResolution(),
327
+ M.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 = ie.TransformNormal(
339
+ new ie(c[0], c[1], c[2]),
340
+ d
341
+ ).normalize(), m = Ae.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 Oe(
349
349
  "probe-" + s.name,
350
- ze,
350
+ Ne,
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 Ge {
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 Re("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 He(a, e, t, i, r = "") {
393
393
  t.forEach((n) => {
394
- const s = n.getID(), o = n.getName(), l = P.getDynamicTextureResolution();
395
- a.filter((c) => c.name === r + o).forEach((c) => {
394
+ const s = n.getID(), o = n.getName(), l = M.getDynamicTextureResolution();
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 = _e(
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 Ee(
415
+ function _e(a, e, t, i) {
416
+ const r = new Ie(
417
417
  a,
418
418
  { width: t, height: i },
419
419
  e,
420
- P.shouldMipMap(),
421
- Te.TRILINEAR_SAMPLINGMODE,
422
- de.TEXTUREFORMAT_RGBA
420
+ M.shouldMipMap(),
421
+ Se.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 qe() {
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 Ke(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 Ue(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 We(a, e, t) {
473
+ a.stopAnimation(e), e.animations = [], Math.abs(e.alpha) > 2 * Math.PI && (e.alpha = Ze(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(
@@ -478,7 +478,7 @@ function Ke(a, e, t) {
478
478
  "target",
479
479
  new g().copyFrom(e.target),
480
480
  new g(
481
- -t.target.x,
481
+ t.target.x,
482
482
  t.target.y,
483
483
  t.target.z
484
484
  ),
@@ -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 Fe();
537
+ o.setEasingMode(Be.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 Ze(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 $e = {
554
554
  albedoTexture: "albedoMap",
555
555
  bumpTexture: "normalMap",
556
556
  ambientTexture: "ambientMap",
@@ -559,7 +559,7 @@ const We = {
559
559
  metallicTexture: "metallicMap",
560
560
  refractionTexture: "refractionMap"
561
561
  };
562
- function Ze(a, e, t, i) {
562
+ function Qe(a, e, t, i) {
563
563
  [
564
564
  "albedoTexture",
565
565
  "bumpTexture",
@@ -569,32 +569,32 @@ function Ze(a, e, t, i) {
569
569
  "metallicTexture",
570
570
  "refractionTexture"
571
571
  ].forEach((n) => {
572
- $e(
572
+ Ye(
573
573
  n,
574
574
  a,
575
575
  e,
576
576
  t,
577
577
  i
578
578
  );
579
- }), je(a, e);
579
+ }), Je(a, e);
580
580
  }
581
- function $e(a, e, t, i, r) {
582
- const n = We[a];
581
+ function Ye(a, e, t, i, r) {
582
+ const n = $e[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;
586
- o ? i.addTextureTask(a, o, !1, !1) : r && t[a] && (t[a] && t[a].dispose(), t[a] = null, Ye(a, t));
586
+ o ? i.addTextureTask(a, o, !1, !1) : r && t[a] && (t[a] && t[a].dispose(), t[a] = null, je(a, t));
587
587
  }
588
- function Ye(a, e) {
588
+ function je(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 Xe(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 Je(a, e) {
595
595
  a.clearCoat && (a.clearCoat === E.RemoveWhenSelected ? (e.clearCoat.isEnabled = !1, e.clearCoat.indexOfRefraction = 1.5) : a.clearCoat === E.ApplyWhenSelected && (e.clearCoat.isEnabled = !0, e.clearCoat.indexOfRefraction = a.clearCoatIOR || e.clearCoat.indexOfRefraction));
596
596
  }
597
- class Xe {
597
+ class et {
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 De(this.scene);
625
+ c.useDefaultLoadingScreen = !1, l.forEach(
626
+ (d) => Qe(
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) => Xe(
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 tt {
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 = qe(), this.previewService = r, this.scene = s, this.variantManager = new et(
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 Oe("root", this.scene);
727
- const o = async () => (this.assetContainer = await ue(
726
+ ), this.transformRoot = new Te("root", this.scene);
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 && Ke(
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 se(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 se(L.OnPointerOutTrigger, () => {
927
927
  i.material && this.materialDeselectedObservable.notifyObservers({
928
928
  id: i.material.id,
929
929
  name: this.stripIdFromName(i.material.name)
@@ -960,7 +960,7 @@ class Je {
960
960
  const t = this.transformRoot.position, i = this.transformRoot.rotation, r = this.transformRoot.scaling;
961
961
  this.transformRoot.position = g.Zero(), this.transformRoot.rotation = g.Zero(), this.transformRoot.scaling = g.One(), e.rootNodes.forEach((s) => {
962
962
  s.parent = this.transformRoot;
963
- }), 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(
963
+ }), 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(), He(
964
964
  this.materials.concat(this.variantManager.getAllMaterials()),
965
965
  this.scene,
966
966
  this.canvasPanels,
@@ -978,14 +978,14 @@ class Je {
978
978
  getAllMeshes() {
979
979
  var e;
980
980
  return (e = this.modelInstance) == null ? void 0 : e.rootNodes.map(
981
- (t) => t.getChildMeshes(!1).filter((i) => i instanceof Re)
981
+ (t) => t.getChildMeshes(!1).filter((i) => i instanceof Ee)
982
982
  ).flat();
983
983
  }
984
984
  instantiate() {
985
985
  this.modelInstance = this.assetContainer.instantiateModelsToScene(
986
986
  this.renameClonedAsset.bind(this),
987
987
  !0
988
- ), this.materials = me(this.modelInstance), this.configureModelInstance(this.modelInstance), this.animations = le(
988
+ ), this.materials = fe(this.modelInstance), this.configureModelInstance(this.modelInstance), this.animations = ce(
989
989
  this.modelInstance.animationGroups,
990
990
  this.renameClonedAsset("")
991
991
  ), this.processQueuedEvents();
@@ -1035,7 +1035,7 @@ class Je {
1035
1035
  }
1036
1036
  //#endregion
1037
1037
  }
1038
- class I extends he {
1038
+ class I extends de {
1039
1039
  constructor(e, t, i, r, n, s, o, l) {
1040
1040
  super(
1041
1041
  e,
@@ -1072,7 +1072,7 @@ class I extends he {
1072
1072
  this.useFramingBehavior = !0;
1073
1073
  const e = this.getFramingBehavior();
1074
1074
  e.attach(this), e.framingTime = 0, e.elevationReturnTime = -1, e.zoomStopsAnimation = !1, this.lowerRadiusLimit = null;
1075
- const t = R(this._scene);
1075
+ const t = O(this._scene);
1076
1076
  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;
1077
1077
  }
1078
1078
  /**
@@ -1085,7 +1085,7 @@ class I extends he {
1085
1085
  i.framingTime = t || 800;
1086
1086
  const r = () => {
1087
1087
  e && e();
1088
- }, n = R(this._scene), s = n.max.subtract(n.min), o = n.min.add(s.scale(0.5));
1088
+ }, n = O(this._scene), s = n.max.subtract(n.min), o = n.min.add(s.scale(0.5));
1089
1089
  this.setRadius(s.length() * 1.5), this.wheelPrecision = 100 / this.radius, this.panningInertia = 0, this.panningOriginTarget.copyFrom(o), this.panDenominator = s.length(), i.zoomOnBoundingInfo(
1090
1090
  n.min,
1091
1091
  n.max,
@@ -1120,7 +1120,7 @@ class I extends he {
1120
1120
  * @param assignActive If true the camera will be assigned as the active camera on the scene.
1121
1121
  */
1122
1122
  static create(e, t, i) {
1123
- const r = R(e), n = r.max.subtract(r.min), s = r.min.add(n.scale(0.5)), o = new I(
1123
+ const r = O(e), n = r.max.subtract(r.min), s = r.min.add(n.scale(0.5)), o = new I(
1124
1124
  "ProductCamera",
1125
1125
  -(Math.PI / 2),
1126
1126
  Math.PI / 2,
@@ -1134,7 +1134,7 @@ class I extends he {
1134
1134
  }), i && (e.activeCamera = o), o;
1135
1135
  }
1136
1136
  }
1137
- function R(a) {
1137
+ function O(a) {
1138
1138
  if (a.meshes.length === 0)
1139
1139
  return {
1140
1140
  min: new g(-1, -1, -1),
@@ -1143,9 +1143,9 @@ function R(a) {
1143
1143
  const e = a.meshes.filter((t) => t.name.toLowerCase().endsWith("_t") || t.name.toLowerCase().includes("_t_"));
1144
1144
  return a.getWorldExtends((t) => t.isVisible && t.isEnabled() && (e.length === 0 || e.includes(t)));
1145
1145
  }
1146
- class et {
1146
+ class it {
1147
1147
  constructor(e, t = !1, i = void 0) {
1148
- this.renderingPipeline = new Be(
1148
+ this.renderingPipeline = new ze(
1149
1149
  "default",
1150
1150
  t,
1151
1151
  e,
@@ -1161,15 +1161,15 @@ class et {
1161
1161
  return this.currentConfiguration;
1162
1162
  }
1163
1163
  setConfiguration(e) {
1164
- 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;
1164
+ 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, Z, $, Q, Y, j, X;
1165
1165
  if (this.renderingPipeline.isSupported) {
1166
- 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(
1166
+ 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 J(
1167
1167
  e.chromaticAberration.direction.x,
1168
1168
  e.chromaticAberration.direction.y
1169
1169
  ) : new J(
1170
1170
  h.chromaticAberration.direction.x,
1171
1171
  h.chromaticAberration.direction.y
1172
- ), 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)
1172
+ ), 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)
1173
1173
  switch (e.depthOfField.blurLevel ?? h.depthOfField.blurLevel) {
1174
1174
  case "Low":
1175
1175
  this.renderingPipeline.depthOfFieldBlurLevel = A.Low;
@@ -1184,27 +1184,27 @@ class et {
1184
1184
  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)
1185
1185
  switch (e.misc.toneMappingType ?? h.misc.toneMappingType) {
1186
1186
  case "Standard":
1187
- this.renderingPipeline.imageProcessing.toneMappingType = M.TONEMAPPING_STANDARD;
1187
+ this.renderingPipeline.imageProcessing.toneMappingType = P.TONEMAPPING_STANDARD;
1188
1188
  break;
1189
1189
  case "ACES":
1190
- this.renderingPipeline.imageProcessing.toneMappingType = M.TONEMAPPING_ACES;
1190
+ this.renderingPipeline.imageProcessing.toneMappingType = P.TONEMAPPING_ACES;
1191
1191
  break;
1192
1192
  }
1193
1193
  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)
1194
1194
  switch ((($ = e.vignette) == null ? void 0 : $.blendMode) ?? h.vignette.blendMode) {
1195
1195
  case "Multiply":
1196
- this.renderingPipeline.imageProcessing.vignetteBlendMode = M.VIGNETTEMODE_MULTIPLY;
1196
+ this.renderingPipeline.imageProcessing.vignetteBlendMode = P.VIGNETTEMODE_MULTIPLY;
1197
1197
  break;
1198
1198
  case "Opaque":
1199
- this.renderingPipeline.imageProcessing.vignetteBlendMode = M.VIGNETTEMODE_OPAQUE;
1199
+ this.renderingPipeline.imageProcessing.vignetteBlendMode = P.VIGNETTEMODE_OPAQUE;
1200
1200
  break;
1201
1201
  }
1202
- (Y = e.vignette) != null && Y.colorRgba ? this.renderingPipeline.imageProcessing.vignetteColor = new f(
1202
+ (Q = e.vignette) != null && Q.colorRgba ? this.renderingPipeline.imageProcessing.vignetteColor = new f(
1203
1203
  e.vignette.colorRgba.r,
1204
1204
  e.vignette.colorRgba.g,
1205
1205
  e.vignette.colorRgba.b,
1206
1206
  e.vignette.colorRgba.a
1207
- ) : (Q = e.vignette) != null && Q.colorHex ? this.renderingPipeline.imageProcessing.vignetteColor = f.FromHexString(e.vignette.colorHex) : this.renderingPipeline.imageProcessing.vignetteColor = new f(
1207
+ ) : (Y = e.vignette) != null && Y.colorHex ? this.renderingPipeline.imageProcessing.vignetteColor = f.FromHexString(e.vignette.colorHex) : this.renderingPipeline.imageProcessing.vignetteColor = new f(
1208
1208
  h.vignette.colorRgba.r,
1209
1209
  h.vignette.colorRgba.g,
1210
1210
  h.vignette.colorRgba.b,
@@ -1213,30 +1213,30 @@ class et {
1213
1213
  }
1214
1214
  }
1215
1215
  updateColorCurve(e) {
1216
- const t = new ie();
1216
+ const t = new ne();
1217
1217
  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;
1218
1218
  }
1219
1219
  }
1220
- Pe.GLTFLoader.RegisterExtension("glbPostProcessor", function(a) {
1221
- return new ke(a);
1220
+ ye.GLTFLoader.RegisterExtension("glbPostProcessor", function(a) {
1221
+ return new Ve(a);
1222
1222
  });
1223
- ce.OnPluginActivatedObservable.add((a) => {
1223
+ ge.OnPluginActivatedObservable.add((a) => {
1224
1224
  if (a.name === "gltf") {
1225
1225
  const e = a;
1226
1226
  e.transparencyAsCoverage = !0;
1227
1227
  }
1228
1228
  });
1229
1229
  const x = "initialScene";
1230
- class _t {
1230
+ class Kt {
1231
1231
  constructor(e) {
1232
1232
  this.loadProgress = /* @__PURE__ */ new Map([
1233
1233
  [x, 0]
1234
- ]), 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);
1234
+ ]), 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 ke(e);
1235
1235
  const i = (() => {
1236
1236
  if (!(e != null && e.noRender))
1237
1237
  return this.configuration.createCanvas();
1238
1238
  })(), r = "1.5.6";
1239
- ve.Configuration = {
1239
+ Ce.Configuration = {
1240
1240
  decoder: {
1241
1241
  wasmUrl: `https://www.gstatic.com/draco/versioned/decoders/${r}/draco_wasm_wrapper_gltf.js`,
1242
1242
  wasmBinaryUrl: `https://www.gstatic.com/draco/versioned/decoders/${r}/draco_decoder_gltf.wasm`,
@@ -1246,7 +1246,7 @@ class _t {
1246
1246
  const n = console.log;
1247
1247
  console.log = () => {
1248
1248
  };
1249
- const s = i ? new de(i, !0, {
1249
+ const s = i ? new ue(i, !0, {
1250
1250
  adaptToDeviceRatio: !0,
1251
1251
  limitDeviceRatio: 2,
1252
1252
  premultipliedAlpha: !1,
@@ -1254,12 +1254,12 @@ class _t {
1254
1254
  audioEngine: !1,
1255
1255
  stencil: this.configuration.highlights.enabled,
1256
1256
  forceSRGBBufferSupportState: !0
1257
- }) : new pe();
1258
- console.log = n, s.hideLoadingUI(), window.addEventListener("resize", this.fireResizeEvent.bind(this)), this.engine = s, this.scene = new Ce(s), this.scene.useRightHandedSystem = !0, this.camera = I.create(this.scene, this.configuration), this.renderingPipeline = new et(
1257
+ }) : new be();
1258
+ console.log = n, s.hideLoadingUI(), window.addEventListener("resize", this.fireResizeEvent.bind(this)), this.engine = s, this.scene = new Pe(s), this.camera = I.create(this.scene, this.configuration), this.renderingPipeline = new it(
1259
1259
  this.scene,
1260
1260
  !1,
1261
1261
  this.camera
1262
- ), this.scene.imageProcessingConfiguration.exposure = this.configuration.lighting.exposure, this.scene.imageProcessingConfiguration.contrast = this.configuration.lighting.contrast, this.glowLayerManager = new Ne(
1262
+ ), this.scene.imageProcessingConfiguration.exposure = this.configuration.lighting.exposure, this.scene.imageProcessingConfiguration.contrast = this.configuration.lighting.contrast, this.glowLayerManager = new Ge(
1263
1263
  this.scene,
1264
1264
  this.configuration.emissiveGlowIntensity
1265
1265
  );
@@ -1304,7 +1304,7 @@ class _t {
1304
1304
  }
1305
1305
  registerView(e) {
1306
1306
  const t = e.height, i = e.width;
1307
- this.engine.registerView(e), e.setAttribute("height", t.toString()), e.setAttribute("width", i.toString()), this.orbitEnabled() || this.setCameraState(O.Pan), this.reattachControls(e);
1307
+ this.engine.registerView(e), e.setAttribute("height", t.toString()), e.setAttribute("width", i.toString()), this.orbitEnabled() || this.setCameraState(R.Pan), this.reattachControls(e);
1308
1308
  }
1309
1309
  getNumViewports() {
1310
1310
  var e;
@@ -1321,7 +1321,7 @@ class _t {
1321
1321
  }
1322
1322
  async initialize(e) {
1323
1323
  var i, r;
1324
- this.scene.clearColor = this.configuration.scene.clearColor, this.scene.environmentTexture = be.CreateFromPrefilteredData(
1324
+ this.scene.clearColor = this.configuration.scene.clearColor, this.scene.environmentTexture = we.CreateFromPrefilteredData(
1325
1325
  this.configuration.scene.environmentFile,
1326
1326
  this.scene
1327
1327
  );
@@ -1334,7 +1334,7 @@ class _t {
1334
1334
  s.loaded * 100 / s.total
1335
1335
  ), this.notifyLoadHandlers();
1336
1336
  }
1337
- ).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(
1337
+ ).getInitializationPromise()), this.loadProgress.set(x, 100), this.notifyLoadHandlers(), this.scene.activeCamera = this.camera, this.camera.rerunFramingBehavior(void 0, 1), Ue(this.scene), ((i = this.engine.views) == null ? void 0 : i.length) >= 1 && this.reattachControls(
1338
1338
  this.engine.views[this.engine.views.length - 1].target
1339
1339
  ), 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(
1340
1340
  this.configuration.options.renderingPipelineConfiguration
@@ -1357,7 +1357,7 @@ class _t {
1357
1357
  this.queuedCameraAnimation = e;
1358
1358
  return;
1359
1359
  }
1360
- Ke(
1360
+ We(
1361
1361
  this.scene,
1362
1362
  this.scene.activeCamera,
1363
1363
  e
@@ -1370,8 +1370,7 @@ class _t {
1370
1370
  latDeg: Math.round(this.camera.beta * 180 / Math.PI),
1371
1371
  radius: Math.round((this.camera.radius + Number.EPSILON) * 1e4) / 1e4,
1372
1372
  target: {
1373
- x: -this.camera.target.x,
1374
- // Negate x to match legacy behavior
1373
+ x: this.camera.target.x,
1375
1374
  y: this.camera.target.y,
1376
1375
  z: this.camera.target.z
1377
1376
  }
@@ -1390,7 +1389,7 @@ class _t {
1390
1389
  throw new Error(
1391
1390
  "No views attached, camera state requires a view to attach controls onto."
1392
1391
  );
1393
- e === O.Orbit ? this.reattachControls(this.engine.views[0].target, 2) : this.reattachControls(this.engine.views[0].target, 0);
1392
+ e === R.Orbit ? this.reattachControls(this.engine.views[0].target, 2) : this.reattachControls(this.engine.views[0].target, 0);
1394
1393
  }
1395
1394
  animateToLastCameraFocus() {
1396
1395
  return new Promise((e) => {
@@ -1414,7 +1413,7 @@ class _t {
1414
1413
  async renderSceneScreenshot(e, t) {
1415
1414
  if (!this.camera)
1416
1415
  throw new Error("Missing product camera, cannot render screenshot!");
1417
- const i = new he(
1416
+ const i = new de(
1418
1417
  "screenshotCamera",
1419
1418
  0,
1420
1419
  0,
@@ -1424,8 +1423,8 @@ class _t {
1424
1423
  );
1425
1424
  try {
1426
1425
  const r = t.latDeg * Math.PI / 180, n = t.lonDeg * Math.PI / 180;
1427
- 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();
1428
- const s = await we.CreateScreenshotUsingRenderTargetAsync(
1426
+ 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();
1427
+ const s = await Me.CreateScreenshotUsingRenderTargetAsync(
1429
1428
  this.engine,
1430
1429
  i,
1431
1430
  e,
@@ -1445,15 +1444,15 @@ class _t {
1445
1444
  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;
1446
1445
  if (t === void 0 || i === void 0 || r === void 0 || n === void 0)
1447
1446
  return !0;
1448
- const s = [t, i], o = [r, n], l = s.every((c) => c === t), d = o.every((c) => c === r);
1449
- return !l && !d;
1447
+ const s = [t, i], o = [r, n], l = s.every((d) => d === t), c = o.every((d) => d === r);
1448
+ return !l && !c;
1450
1449
  }
1451
1450
  fireResizeEvent() {
1452
1451
  this.getNumViewports() > 0 && this.engine.resize();
1453
1452
  }
1454
1453
  setHighlights(e, t) {
1455
1454
  var r;
1456
- e.length === 0 && ((r = this.highlightLayer) == null || r.dispose(), this.highlightLayer = void 0), this.highlightLayer || (this.highlightLayer = new fe("highlights", this.scene, {
1455
+ e.length === 0 && ((r = this.highlightLayer) == null || r.dispose(), this.highlightLayer = void 0), this.highlightLayer || (this.highlightLayer = new ve("highlights", this.scene, {
1457
1456
  isStroke: !0,
1458
1457
  blurVerticalSize: 0.85,
1459
1458
  blurHorizontalSize: 0.85
@@ -1478,7 +1477,7 @@ class _t {
1478
1477
  this.renderingPipeline && this.renderingPipeline.setConfiguration(e);
1479
1478
  }
1480
1479
  loadModel(e, t) {
1481
- const i = new Je({
1480
+ const i = new tt({
1482
1481
  enablePicking: this.configuration.highlights.enabled,
1483
1482
  modelDetails: e,
1484
1483
  scene: this.scene,
@@ -1570,11 +1569,28 @@ class _t {
1570
1569
  this.loadObservable.notifyObservers(this.getLoadListenerEvent());
1571
1570
  }
1572
1571
  }
1572
+ function Ut(a, e = new g(0, 1, 0), t = Math.PI) {
1573
+ const {
1574
+ position: i = g.Zero(),
1575
+ rotation: r = g.Zero(),
1576
+ scale: n = g.One()
1577
+ } = a, s = ee.Compose(
1578
+ n,
1579
+ te.FromEulerVector(r),
1580
+ i
1581
+ ), o = ee.RotationAxis(e, t), l = s.multiply(o), c = g.Zero(), d = te.Identity(), u = g.Zero();
1582
+ return l.decompose(u, d, c), {
1583
+ position: c,
1584
+ rotation: d.toEulerAngles(),
1585
+ scale: u
1586
+ };
1587
+ }
1573
1588
  export {
1574
1589
  E as MaterialEffectMode,
1575
- O as ProductCameraRig,
1576
- ze as REFLECTION_PROBE_RESOLUTION,
1577
- P as RenderingConfiguration,
1578
- _t as SpiffCommerce3DPreviewService,
1579
- h as renderingPipelineDefaults
1590
+ R as ProductCameraRig,
1591
+ Ne as REFLECTION_PROBE_RESOLUTION,
1592
+ M as RenderingConfiguration,
1593
+ Kt as SpiffCommerce3DPreviewService,
1594
+ h as renderingPipelineDefaults,
1595
+ Ut as rotateAroundOrigin
1580
1596
  };
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,m,ye,y,Ce,we,Me,E,Pe,P,xe,Le,O,D,Te,Re,Ae,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,g,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:(g=this.customOptions)!=null&&g.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 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(),g=P.Vector3.TransformNormal(new P.Vector3(d[0],d[1],d[2]),u).normalize(),b=P.Plane.FromPositionAndNormal(r.position,g.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,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 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 V=new Map;async function N(a,e,t){return new Promise((i,n)=>{const r=V.get(a);if(r&&r.scene.uid===e.uid)return i(r);B.SceneLoader.LoadAssetContainerAsync(a,void 0,e,t).then(s=>{V.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 g=i.get(s),b=!1;if(g)G(u,g),g.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 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 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 ke(a){const e=a.animationGroups;U(e)}function Ve(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 m.Vector3().copyFrom(e.target),new m.Vector3(-t.target.x,t.target.y,t.target.z),C.Animation.ANIMATIONTYPE_VECTOR3,r)),i.push(R("cameraAlphaLerp","alpha",e.alpha,W(t.lonDeg),C.Animation.ANIMATIONTYPE_FLOAT,s)),i.push(R("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(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 W(a){return a*Math.PI/180}function R(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,g,b)=>{i&&i(u/g*100,100,b.name)},d.onFinish=u=>{u.forEach(g=>{const b=g;i&&i(100,100,g.name),c.forEach(f=>We(g.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,g)=>{o.push(this.applyMaterial(g,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 Re.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 m.Vector3(e.x,e.y,e.z)}get rotation(){return this.transformRoot.rotation}set rotation(e){this.transformRoot.rotation=new m.Vector3(e.x,e.y,e.z)}get scale(){return this.transformRoot.scaling}set scale(e){this.transformRoot.scaling=new m.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=m.Vector3.Zero(),this.transformRoot.rotation=m.Vector3.Zero(),this.transformRoot.scaling=m.Vector3.One(),e.rootNodes.forEach(s=>{s.parent=this.transformRoot}),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 m.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 m.Vector3(-1,-1,-1),max:new m.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,g,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=((g=e.chromaticAberration)==null?void 0:g.radialIntensity)??h.chromaticAberration.radialIntensity,this.renderingPipeline.chromaticAberration.direction=(b=e.chromaticAberration)!=null&&b.direction?new m.Vector2(e.chromaticAberration.direction.x,e.chromaticAberration.direction.y):new m.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 A="initialScene";class _e{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";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.scene.useRightHandedSystem=!0,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(A)}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(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),ke(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}Ve(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 m.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,m.Vector3.Zero(),this.scene);try{const n=t.latDeg*Math.PI/180,r=t.lonDeg*Math.PI/180;i.target=t.target?new m.Vector3(-t.target.x,t.target.y,t.target.z):m.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=k,l.RenderingConfiguration=w,l.SpiffCommerce3DPreviewService=_e,l.renderingPipelineDefaults=h,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
1
+ (function(l,y){typeof exports=="object"&&typeof module<"u"?y(exports,require("@babylonjs/core/Cameras/arcRotateCamera"),require("@babylonjs/core/Engines/engine"),require("@babylonjs/core/Engines/nullEngine"),require("@babylonjs/core/Layers/highlightLayer"),require("@babylonjs/core/Loading/sceneLoader"),require("@babylonjs/core/Materials/Textures/cubeTexture"),require("@babylonjs/core/Maths/math.color"),require("@babylonjs/core/Maths/math.vector"),require("@babylonjs/core/Meshes/Compression/dracoCompression"),require("@babylonjs/core/Misc/observable"),require("@babylonjs/core/Misc/tools"),require("@babylonjs/core/scene"),require("@babylonjs/loaders/glTF"),require("@babylonjs/core/Materials/PBR/pbrMaterial"),require("@babylonjs/core/Materials/Textures/mirrorTexture"),require("@babylonjs/core/Maths/math"),require("@babylonjs/core/Probes/reflectionProbe"),require("@babylonjs/core/Layers/glowLayer"),require("@babylonjs/core/Actions/actionManager"),require("@babylonjs/core/Actions/directActions"),require("@babylonjs/core/Meshes/mesh"),require("@babylonjs/core/Meshes/transformNode"),require("@babylonjs/core/Materials/Textures/dynamicTexture"),require("@babylonjs/core/Materials/Textures/texture"),require("@babylonjs/core/Animations/animation"),require("@babylonjs/core/Animations/easing"),require("@babylonjs/core/Misc/assetsManager"),require("@babylonjs/core/Materials/colorCurves"),require("@babylonjs/core/Materials/imageProcessingConfiguration"),require("@babylonjs/core/PostProcesses/RenderPipeline"),require("@babylonjs/core/PostProcesses/depthOfFieldEffect"),require("@babylonjs/core/Rendering/depthRendererSceneComponent"),require("@babylonjs/core/Engines/Extensions/engine.views"),require("@babylonjs/core/Meshes/instancedMesh"),require("@babylonjs/core/Materials/Textures/Loaders/ddsTextureLoader"),require("@babylonjs/core/Materials/Textures/Loaders/envTextureLoader"),require("@babylonjs/core/Materials/Textures/Loaders/ktxTextureLoader"),require("@babylonjs/core/Animations/animatable"),require("@babylonjs/core/Misc/screenshotTools"),require("@babylonjs/core/Rendering/boundingBoxRenderer"),require("@babylonjs/loaders/glTF/2.0/Extensions")):typeof define=="function"&&define.amd?define(["exports","@babylonjs/core/Cameras/arcRotateCamera","@babylonjs/core/Engines/engine","@babylonjs/core/Engines/nullEngine","@babylonjs/core/Layers/highlightLayer","@babylonjs/core/Loading/sceneLoader","@babylonjs/core/Materials/Textures/cubeTexture","@babylonjs/core/Maths/math.color","@babylonjs/core/Maths/math.vector","@babylonjs/core/Meshes/Compression/dracoCompression","@babylonjs/core/Misc/observable","@babylonjs/core/Misc/tools","@babylonjs/core/scene","@babylonjs/loaders/glTF","@babylonjs/core/Materials/PBR/pbrMaterial","@babylonjs/core/Materials/Textures/mirrorTexture","@babylonjs/core/Maths/math","@babylonjs/core/Probes/reflectionProbe","@babylonjs/core/Layers/glowLayer","@babylonjs/core/Actions/actionManager","@babylonjs/core/Actions/directActions","@babylonjs/core/Meshes/mesh","@babylonjs/core/Meshes/transformNode","@babylonjs/core/Materials/Textures/dynamicTexture","@babylonjs/core/Materials/Textures/texture","@babylonjs/core/Animations/animation","@babylonjs/core/Animations/easing","@babylonjs/core/Misc/assetsManager","@babylonjs/core/Materials/colorCurves","@babylonjs/core/Materials/imageProcessingConfiguration","@babylonjs/core/PostProcesses/RenderPipeline","@babylonjs/core/PostProcesses/depthOfFieldEffect","@babylonjs/core/Rendering/depthRendererSceneComponent","@babylonjs/core/Engines/Extensions/engine.views","@babylonjs/core/Meshes/instancedMesh","@babylonjs/core/Materials/Textures/Loaders/ddsTextureLoader","@babylonjs/core/Materials/Textures/Loaders/envTextureLoader","@babylonjs/core/Materials/Textures/Loaders/ktxTextureLoader","@babylonjs/core/Animations/animatable","@babylonjs/core/Misc/screenshotTools","@babylonjs/core/Rendering/boundingBoxRenderer","@babylonjs/loaders/glTF/2.0/Extensions"],y):(l=typeof globalThis<"u"?globalThis:l||self,y(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,y,j,be,fe,B,ye,p,g,ve,v,Ce,we,Me,E,xe,x,Pe,Le,O,D,Te,Ae,Re,Ee,C,q,Oe,V,P,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,h,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:(h=this.customOptions)==null?void 0:h.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 z=128,c={antiAliasing:{samples:4,fxaaEnabled:!1},bloom:{enabled:!1,kernel:64,scale:.5,threshold:.9,weight:.15},chromaticAberration:{enabled:!1,aberrationAmount:30,direction:{x:0,y:0},radialIntensity:0},colorCurves:{enabled:!1},depthOfField:{enabled:!1,blurLevel:"Low",focalLength:50,focusDistance:2e3,fStop:1.4,lensSize:50},grain:{enabled:!1,animated:!1,intensity:30},misc:{contrast:1,exposure:1,toneMappingEnabled:!1,toneMappingType:"Standard"},sharpen:{enabled:!1,colorAmount:1,edgeAmount:.3},vignette:{enabled:!1,blendMode:"Multiply",cameraFov:.5,center:{x:0,y:0},colorHex:"#000000ff",colorRgba:{r:0,g:0,b:0,a:1},stretch:0,weight:1}};class 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 x.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 h=new xe.MirrorTexture("mirror",w.getMirrorTextureResolution(),e,!0);h.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=x.Vector3.TransformNormal(new x.Vector3(d[0],d[1],d[2]),u).normalize(),b=x.Plane.FromPositionAndNormal(r.position,m.scale(-1));h.mirrorPlane=b,h.level=s,o.reflectionTexture=h}function n(r){const s=r.material,o=new Pe.ReflectionProbe("probe-"+s.name,z,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(),h=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,h.width,h.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 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=K(s),h=i*o;s.start(e,H,h,h)});return}r.forEach(s=>{s.stop();const o=K(s),h=i!==void 0?i*o:void 0,d=t!==void 0?t*o:void 0;s.start(e,H,h,d)})}function U(a){a.forEach(e=>{e.stop()})}function ze(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 h=e.useAutoRotationBehavior;e.disableAutoRotationBehavior(),a.beginAnimation(e,0,n?M*2:M,!1,1,()=>{e.animations=[],h&&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 h=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}),h.setKeys(d),h.setEasingFunction(o),h}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),h=this.scene.materials.filter(u=>u.name===o);if(h.length===0){r();return}const d=new Oe.AssetsManager(this.scene);d.useDefaultLoadingScreen=!1,h.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),h.forEach(f=>We(m.name,f,t,b.texture))}),r()},d.loadAsync()})}async applyModel(e,t,i,n){var h,d;if(i&&t&&!this.keysThatRemovedBaseModel.includes(e)&&this.keysThatRemovedBaseModel.push(e),!i)return this.keysThatRemovedBaseModel.includes(e)&&this.setBaseModelEnabled(!0),(h=this.loadedContainerForKey.get(e))==null||h.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 Qe{constructor(e){this.metadata=new Map,this.materialSelectedObservable=new v.Observable,this.materialDeselectedObservable=new v.Observable,this.materialVariantObservable=new v.Observable,this.modelVariantObservable=new v.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,h)=>{this.materialVariantObservable.notifyObservers({remainingCount:s,totalCount:o,taskName:h})},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&&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(),e.rootNodes.forEach(s=>{s.parent=this.transformRoot}),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 y.ArcRotateCamera{constructor(e,t,i,n,r,s,o,h){super(e,t,i,n,r,s,h),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(c))}dispose(){this.renderingPipeline.dispose()}getConfiguration(){return this.currentConfiguration}setConfiguration(e){var t,i,n,r,s,o,h,d,u,m,b,f,Q,Y,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)??c.antiAliasing.samples,this.renderingPipeline.fxaaEnabled=((i=e.antiAliasing)==null?void 0:i.fxaaEnabled)??c.antiAliasing.fxaaEnabled,this.renderingPipeline.bloomEnabled=((n=e.bloom)==null?void 0:n.enabled)??c.bloom.enabled,this.renderingPipeline.bloomKernel=((r=e.bloom)==null?void 0:r.kernel)??c.bloom.kernel,this.renderingPipeline.bloomScale=((s=e.bloom)==null?void 0:s.scale)??c.bloom.scale,this.renderingPipeline.bloomThreshold=((o=e.bloom)==null?void 0:o.threshold)??c.bloom.threshold,this.renderingPipeline.bloomWeight=((h=e.bloom)==null?void 0:h.weight)??c.bloom.weight,this.renderingPipeline.chromaticAberrationEnabled=((d=e.chromaticAberration)==null?void 0:d.enabled)??c.chromaticAberration.enabled,this.renderingPipeline.chromaticAberration.aberrationAmount=((u=e.chromaticAberration)==null?void 0:u.aberrationAmount)??c.chromaticAberration.aberrationAmount,this.renderingPipeline.chromaticAberration.radialIntensity=((m=e.chromaticAberration)==null?void 0:m.radialIntensity)??c.chromaticAberration.radialIntensity,this.renderingPipeline.chromaticAberration.direction=(b=e.chromaticAberration)!=null&&b.direction?new g.Vector2(e.chromaticAberration.direction.x,e.chromaticAberration.direction.y):new g.Vector2(c.chromaticAberration.direction.x,c.chromaticAberration.direction.y),this.renderingPipeline.imageProcessing.colorCurvesEnabled=((f=e.colorCurves)==null?void 0:f.enabled)??c.colorCurves.enabled,this.renderingPipeline.imageProcessing.colorCurves=e.colorCurves?this.updateColorCurve(e.colorCurves):new V.ColorCurves,this.renderingPipeline.depthOfFieldEnabled=((Q=e.depthOfField)==null?void 0:Q.enabled)??c.depthOfField.enabled,e.depthOfField)switch(e.depthOfField.blurLevel??c.depthOfField.blurLevel){case"Low":this.renderingPipeline.depthOfFieldBlurLevel=I.DepthOfFieldEffectBlurLevel.Low;break;case"Medium":this.renderingPipeline.depthOfFieldBlurLevel=I.DepthOfFieldEffectBlurLevel.Medium;break;case"High":this.renderingPipeline.depthOfFieldBlurLevel=I.DepthOfFieldEffectBlurLevel.High;break}if(this.renderingPipeline.depthOfField.focalLength=((Y=e.depthOfField)==null?void 0:Y.focalLength)??c.depthOfField.focalLength,this.renderingPipeline.depthOfField.fStop=((X=e.depthOfField)==null?void 0:X.fStop)??c.depthOfField.fStop,this.renderingPipeline.depthOfField.focusDistance=((J=e.depthOfField)==null?void 0:J.focusDistance)??c.depthOfField.focusDistance,this.renderingPipeline.depthOfField.lensSize=((_=e.depthOfField)==null?void 0:_.lensSize)??c.depthOfField.lensSize,this.renderingPipeline.grainEnabled=((ee=e.grain)==null?void 0:ee.enabled)??c.grain.enabled,this.renderingPipeline.grain.animated=((te=e.grain)==null?void 0:te.animated)??c.grain.animated,this.renderingPipeline.grain.intensity=((ie=e.grain)==null?void 0:ie.intensity)??c.grain.intensity,this.renderingPipeline.imageProcessing.contrast=((se=e.misc)==null?void 0:se.contrast)??c.misc.contrast,this.renderingPipeline.imageProcessing.exposure=((re=e.misc)==null?void 0:re.exposure)??c.misc.exposure,this.renderingPipeline.imageProcessing.toneMappingEnabled=((ne=e.misc)==null?void 0:ne.toneMappingEnabled)??c.misc.toneMappingEnabled,this.renderingPipeline.imageProcessing.toneMappingEnabled)switch(e.misc.toneMappingType??c.misc.toneMappingType){case"Standard":this.renderingPipeline.imageProcessing.toneMappingType=P.ImageProcessingConfiguration.TONEMAPPING_STANDARD;break;case"ACES":this.renderingPipeline.imageProcessing.toneMappingType=P.ImageProcessingConfiguration.TONEMAPPING_ACES;break}if(this.renderingPipeline.sharpenEnabled=((ae=e.sharpen)==null?void 0:ae.enabled)??c.sharpen.enabled,this.renderingPipeline.sharpen.colorAmount=((oe=e.sharpen)==null?void 0:oe.colorAmount)??c.sharpen.colorAmount,this.renderingPipeline.sharpen.edgeAmount=((le=e.sharpen)==null?void 0:le.edgeAmount)??c.sharpen.edgeAmount,this.renderingPipeline.imageProcessing.vignetteEnabled=((he=e.vignette)==null?void 0:he.enabled)??c.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=c.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=c.vignette.center.y),e.vignette)switch(((de=e.vignette)==null?void 0:de.blendMode)??c.vignette.blendMode){case"Multiply":this.renderingPipeline.imageProcessing.vignetteBlendMode=P.ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY;break;case"Opaque":this.renderingPipeline.imageProcessing.vignetteBlendMode=P.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(c.vignette.colorRgba.r,c.vignette.colorRgba.g,c.vignette.colorRgba.b,c.vignette.colorRgba.a),this.renderingPipeline.imageProcessing.vignetteStretch=((me=e.vignette)==null?void 0:me.stretch)??c.vignette.stretch,this.renderingPipeline.imageProcessing.vignetteWeight=((pe=e.vignette)==null?void 0:pe.weight)??c.vignette.weight,this.renderingPipeline.prepare(),this.currentConfiguration=e}}updateColorCurve(e){const t=new V.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 Xe{constructor(e){this.loadProgress=new Map([[R,0]]),this.focusLostNotified=!1,this.loadObservable=new v.Observable,this.focusLostObservable=new v.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";ve.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 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(R)}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(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),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 y.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],h=s.every(u=>u===t),d=o.every(u=>u===n);return!h&&!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 h;return(h=this.highlightLayer)==null?void 0:h.addMesh(o,i||p.Color3.FromHexString("#fcba03"))})})}setRenderingPipelineConfiguration(e){this.renderingPipeline&&this.renderingPipeline.setConfiguration(e)}loadModel(e,t){const i=new Qe({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())}}function Je(a,e=new g.Vector3(0,1,0),t=Math.PI){const{position:i=g.Vector3.Zero(),rotation:n=g.Vector3.Zero(),scale:r=g.Vector3.One()}=a,s=g.Matrix.Compose(r,g.Quaternion.FromEulerVector(n),i),o=g.Matrix.RotationAxis(e,t),h=s.multiply(o),d=g.Vector3.Zero(),u=g.Quaternion.Identity(),m=g.Vector3.Zero();return h.decompose(m,u,d),{position:d,rotation:u.toEulerAngles(),scale:m}}l.MaterialEffectMode=T,l.ProductCameraRig=L,l.REFLECTION_PROBE_RESOLUTION=z,l.RenderingConfiguration=w,l.SpiffCommerce3DPreviewService=Xe,l.renderingPipelineDefaults=c,l.rotateAroundOrigin=Je,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.1.0-alpha.0",
3
+ "version": "4.1.0-alpha.2",
4
4
  "description": "An internal implementation of the ThreeDPreviewService interface used by Spiff Commerce",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/index.umd.js",