@spiffcommerce/preview 4.0.1 → 4.0.2-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +94 -94
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import { ArcRotateCamera as
|
|
1
|
+
import { ArcRotateCamera as ce } from "@babylonjs/core/Cameras/arcRotateCamera";
|
|
2
2
|
import { Engine as de } from "@babylonjs/core/Engines/engine";
|
|
3
|
-
import { NullEngine as
|
|
4
|
-
import { HighlightLayer as
|
|
5
|
-
import { SceneLoader as
|
|
6
|
-
import { CubeTexture as
|
|
3
|
+
import { NullEngine as fe } from "@babylonjs/core/Engines/nullEngine";
|
|
4
|
+
import { HighlightLayer as be } from "@babylonjs/core/Layers/highlightLayer";
|
|
5
|
+
import { SceneLoader as ue } from "@babylonjs/core/Loading/sceneLoader";
|
|
6
|
+
import { CubeTexture as ve } from "@babylonjs/core/Materials/Textures/cubeTexture";
|
|
7
7
|
import { Color4 as f, Color3 as w } from "@babylonjs/core/Maths/math.color";
|
|
8
8
|
import { Vector3 as g, Vector2 as J } from "@babylonjs/core/Maths/math.vector";
|
|
9
|
-
import { DracoCompression as
|
|
9
|
+
import { DracoCompression as we } from "@babylonjs/core/Meshes/Compression/dracoCompression";
|
|
10
10
|
import { Observable as b } from "@babylonjs/core/Misc/observable";
|
|
11
|
-
import { Tools as
|
|
12
|
-
import { Scene as
|
|
13
|
-
import { GLTF2 as
|
|
11
|
+
import { Tools as Ce } from "@babylonjs/core/Misc/tools";
|
|
12
|
+
import { Scene as Pe } from "@babylonjs/core/scene";
|
|
13
|
+
import { GLTF2 as Me } from "@babylonjs/loaders/glTF";
|
|
14
14
|
import { PBRMaterial as T } from "@babylonjs/core/Materials/PBR/pbrMaterial";
|
|
15
|
-
import { MirrorTexture as
|
|
16
|
-
import { Color3 as
|
|
17
|
-
import { ReflectionProbe as
|
|
18
|
-
import { GlowLayer as
|
|
15
|
+
import { MirrorTexture as ye } from "@babylonjs/core/Materials/Textures/mirrorTexture";
|
|
16
|
+
import { Color3 as xe, Vector3 as ee, Plane as Le } from "@babylonjs/core/Maths/math";
|
|
17
|
+
import { ReflectionProbe as Ae } 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
20
|
import { ExecuteCodeAction as te } from "@babylonjs/core/Actions/directActions";
|
|
21
|
-
import { Mesh as
|
|
22
|
-
import { TransformNode as
|
|
21
|
+
import { Mesh as Oe } from "@babylonjs/core/Meshes/mesh";
|
|
22
|
+
import { TransformNode as ie } from "@babylonjs/core/Meshes/transformNode";
|
|
23
23
|
import { DynamicTexture as Ee } from "@babylonjs/core/Materials/Textures/dynamicTexture";
|
|
24
24
|
import { Texture as Te } from "@babylonjs/core/Materials/Textures/texture";
|
|
25
25
|
import { Animation as v } from "@babylonjs/core/Animations/animation";
|
|
26
26
|
import { QuadraticEase as Ie, EasingFunction as Se } from "@babylonjs/core/Animations/easing";
|
|
27
27
|
import { AssetsManager as Fe } from "@babylonjs/core/Misc/assetsManager";
|
|
28
|
-
import { ColorCurves as
|
|
28
|
+
import { ColorCurves as se } from "@babylonjs/core/Materials/colorCurves";
|
|
29
29
|
import { ImageProcessingConfiguration as M } from "@babylonjs/core/Materials/imageProcessingConfiguration";
|
|
30
30
|
import { DefaultRenderingPipeline as Be } from "@babylonjs/core/PostProcesses/RenderPipeline";
|
|
31
31
|
import { DepthOfFieldEffectBlurLevel as A } from "@babylonjs/core/PostProcesses/depthOfFieldEffect";
|
|
@@ -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,
|
|
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: (
|
|
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
|
}
|
|
@@ -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
|
|
287
|
+
i.subSurface.isTranslucencyEnabled = !0, i.subSurface.translucencyIntensity = e.extras.translucency, e.extras.translucencyR && e.extras.translucencyG && e.extras.translucencyB && (i.subSurface.tintColor = new xe(
|
|
288
288
|
e.extras.translucencyR,
|
|
289
289
|
e.extras.translucencyG,
|
|
290
290
|
e.extras.translucencyB
|
|
@@ -322,30 +322,30 @@ class ke {
|
|
|
322
322
|
const o = n.material;
|
|
323
323
|
if (!o)
|
|
324
324
|
return;
|
|
325
|
-
const l = new
|
|
325
|
+
const l = new ye(
|
|
326
326
|
"mirror",
|
|
327
327
|
P.getMirrorTextureResolution(),
|
|
328
328
|
e,
|
|
329
329
|
!0
|
|
330
330
|
);
|
|
331
331
|
l.renderList = t(e);
|
|
332
|
-
const
|
|
333
|
-
if (!
|
|
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
|
|
339
|
-
new ee(
|
|
340
|
-
|
|
341
|
-
).normalize(), m =
|
|
338
|
+
const d = n.getWorldMatrix(), u = ee.TransformNormal(
|
|
339
|
+
new ee(c[0], c[1], c[2]),
|
|
340
|
+
d
|
|
341
|
+
).normalize(), m = Le.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
|
|
348
|
+
const s = n.material, o = new Ae(
|
|
349
349
|
"probe-" + s.name,
|
|
350
350
|
ze,
|
|
351
351
|
e
|
|
@@ -363,7 +363,7 @@ class Ne {
|
|
|
363
363
|
this.scene = e, this.intensity = t, this.meshCount = 0;
|
|
364
364
|
}
|
|
365
365
|
includeMeshes(e) {
|
|
366
|
-
this.glowLayer || (this.glowLayer = new
|
|
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,29 +373,29 @@ class Ne {
|
|
|
373
373
|
}), this.meshCount === 0 && (this.glowLayer.dispose(), this.glowLayer = void 0));
|
|
374
374
|
}
|
|
375
375
|
}
|
|
376
|
-
const
|
|
377
|
-
async function
|
|
376
|
+
const ne = /* @__PURE__ */ new Map();
|
|
377
|
+
async function ge(a, e, t) {
|
|
378
378
|
return new Promise((i, r) => {
|
|
379
|
-
const n =
|
|
379
|
+
const n = ne.get(a);
|
|
380
380
|
if (n && n.scene.uid === e.uid)
|
|
381
381
|
return i(n);
|
|
382
|
-
|
|
382
|
+
ue.LoadAssetContainerAsync(
|
|
383
383
|
a,
|
|
384
384
|
void 0,
|
|
385
385
|
e,
|
|
386
386
|
t
|
|
387
387
|
).then((s) => {
|
|
388
|
-
|
|
388
|
+
ne.set(a, s), i(s);
|
|
389
389
|
}).catch(r);
|
|
390
390
|
});
|
|
391
391
|
}
|
|
392
392
|
function Ve(a, e, t, i, r = "") {
|
|
393
393
|
t.forEach((n) => {
|
|
394
394
|
const s = n.getID(), o = n.getName(), l = P.getDynamicTextureResolution();
|
|
395
|
-
a.filter((
|
|
395
|
+
a.filter((d) => d.name === r + o).forEach((d) => {
|
|
396
396
|
const u = i.get(s), m = !1;
|
|
397
397
|
if (u)
|
|
398
|
-
|
|
398
|
+
re(d, u), u.update(m);
|
|
399
399
|
else {
|
|
400
400
|
const p = Ge(
|
|
401
401
|
o,
|
|
@@ -405,7 +405,7 @@ function Ve(a, e, t, i, r = "") {
|
|
|
405
405
|
);
|
|
406
406
|
i.set(s, p), n.setStaticContext(
|
|
407
407
|
p.getContext()
|
|
408
|
-
),
|
|
408
|
+
), re(d, p), p.onLoadObservable.addOnce(() => {
|
|
409
409
|
p.update(m);
|
|
410
410
|
});
|
|
411
411
|
}
|
|
@@ -423,7 +423,7 @@ function Ge(a, e, t, i) {
|
|
|
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
|
|
426
|
+
function re(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;
|
|
@@ -436,8 +436,8 @@ function He() {
|
|
|
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,
|
|
440
|
-
function
|
|
439
|
+
const C = 60, ae = 1;
|
|
440
|
+
function oe(a) {
|
|
441
441
|
return a.targetedAnimations.map((t) => t.animation.framePerSecond).reduce((t, i) => t + i, 0) / a.targetedAnimations.length || 0;
|
|
442
442
|
}
|
|
443
443
|
function _e(a, e, t, i, r) {
|
|
@@ -449,25 +449,25 @@ 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 =
|
|
453
|
-
s.start(e,
|
|
452
|
+
const o = oe(s), l = i * o;
|
|
453
|
+
s.start(e, ae, l, l);
|
|
454
454
|
});
|
|
455
455
|
return;
|
|
456
456
|
}
|
|
457
457
|
n.forEach((s) => {
|
|
458
458
|
s.stop();
|
|
459
|
-
const o =
|
|
460
|
-
s.start(e,
|
|
459
|
+
const o = oe(s), l = i !== void 0 ? i * o : void 0, c = t !== void 0 ? t * o : void 0;
|
|
460
|
+
s.start(e, ae, l, c);
|
|
461
461
|
});
|
|
462
462
|
}
|
|
463
|
-
function
|
|
463
|
+
function me(a) {
|
|
464
464
|
a.forEach((e) => {
|
|
465
465
|
e.stop();
|
|
466
466
|
});
|
|
467
467
|
}
|
|
468
468
|
function qe(a) {
|
|
469
469
|
const e = a.animationGroups;
|
|
470
|
-
|
|
470
|
+
me(e);
|
|
471
471
|
}
|
|
472
472
|
function Ke(a, e, t) {
|
|
473
473
|
a.stopAnimation(e), e.animations = [], Math.abs(e.alpha) > 2 * Math.PI && (e.alpha = Ue(e.alpha, 0, 2 * Math.PI));
|
|
@@ -490,7 +490,7 @@ function Ke(a, e, t) {
|
|
|
490
490
|
"cameraAlphaLerp",
|
|
491
491
|
"alpha",
|
|
492
492
|
e.alpha,
|
|
493
|
-
|
|
493
|
+
le(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
|
-
|
|
502
|
+
le(t.latDeg),
|
|
503
503
|
v.ANIMATIONTYPE_FLOAT,
|
|
504
504
|
s
|
|
505
505
|
)
|
|
506
506
|
), t.radius !== void 0) {
|
|
507
|
-
const
|
|
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
|
-
|
|
513
|
+
c,
|
|
514
514
|
v.ANIMATIONTYPE_FLOAT,
|
|
515
515
|
s
|
|
516
516
|
)
|
|
@@ -529,7 +529,7 @@ function Ke(a, e, t) {
|
|
|
529
529
|
}
|
|
530
530
|
);
|
|
531
531
|
}
|
|
532
|
-
function
|
|
532
|
+
function le(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) {
|
|
@@ -541,11 +541,11 @@ function y(a, e, t, i, r, n = 0, s = v.ANIMATIONLOOPMODE_CONSTANT) {
|
|
|
541
541
|
C,
|
|
542
542
|
r,
|
|
543
543
|
s
|
|
544
|
-
),
|
|
545
|
-
return n > 0 &&
|
|
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(
|
|
548
|
+
}), l.setKeys(c), l.setEasingFunction(o), l;
|
|
549
549
|
}
|
|
550
550
|
function Ue(a, e, t) {
|
|
551
551
|
return a < e ? a = t - (e - a) % (t - e) : a = e + (a - e) % (t - e);
|
|
@@ -615,24 +615,24 @@ class Xe {
|
|
|
615
615
|
...t
|
|
616
616
|
});
|
|
617
617
|
const o = this.renameClonedAsset(e), l = this.scene.materials.filter(
|
|
618
|
-
(
|
|
618
|
+
(d) => d.name === o
|
|
619
619
|
);
|
|
620
620
|
if (l.length === 0) {
|
|
621
621
|
n();
|
|
622
622
|
return;
|
|
623
623
|
}
|
|
624
|
-
const
|
|
625
|
-
|
|
626
|
-
(
|
|
624
|
+
const c = new Fe(this.scene);
|
|
625
|
+
c.useDefaultLoadingScreen = !1, l.forEach(
|
|
626
|
+
(d) => Ze(
|
|
627
627
|
t,
|
|
628
|
-
c,
|
|
629
628
|
d,
|
|
629
|
+
c,
|
|
630
630
|
r
|
|
631
631
|
)
|
|
632
|
-
),
|
|
633
|
-
i && i(
|
|
634
|
-
},
|
|
635
|
-
|
|
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
638
|
(p) => Qe(
|
|
@@ -643,7 +643,7 @@ class Xe {
|
|
|
643
643
|
)
|
|
644
644
|
);
|
|
645
645
|
}), n();
|
|
646
|
-
},
|
|
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,
|
|
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) && ((
|
|
661
|
-
const s = (await
|
|
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 ge(i, this.scene, r)).instantiateModelsToScene(
|
|
662
662
|
this.renameClonedAsset,
|
|
663
663
|
!0
|
|
664
664
|
);
|
|
665
|
-
this.loadedContainerForKey.set(e, s), this.loadedMaterialsForKey.set(e,
|
|
665
|
+
this.loadedContainerForKey.set(e, s), this.loadedMaterialsForKey.set(e, pe(s));
|
|
666
666
|
const o = [];
|
|
667
|
-
return this.materialVariantMap.forEach(async (
|
|
668
|
-
o.push(this.applyMaterial(u,
|
|
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
|
|
691
|
+
function pe(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
|
|
702
|
+
function he(a, e = "") {
|
|
703
703
|
return a.map((t) => ({
|
|
704
704
|
name: t.name.substring(e.length),
|
|
705
705
|
loop: t.loopAnimation,
|
|
@@ -723,8 +723,8 @@ class Je {
|
|
|
723
723
|
this.setEnabled.bind(this)
|
|
724
724
|
), this.previewService.registerInitializedListener(
|
|
725
725
|
async () => await this.processQueuedEvents()
|
|
726
|
-
), this.transformRoot = new
|
|
727
|
-
const o = async () => (this.assetContainer = await
|
|
726
|
+
), this.transformRoot = new ie("root", this.scene), this.rotationTransform = new ie("rotation", this.scene), this.rotationTransform.parent = this.transformRoot, this.rotationTransform.rotation = new g(0, Math.PI, 0);
|
|
727
|
+
const o = async () => (this.assetContainer = await ge(
|
|
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 &&
|
|
839
|
+
this.modelInstance && me(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;
|
|
@@ -861,7 +861,7 @@ class Je {
|
|
|
861
861
|
getAnimations(e) {
|
|
862
862
|
return [
|
|
863
863
|
...this.animations,
|
|
864
|
-
...e ?
|
|
864
|
+
...e ? he(
|
|
865
865
|
this.variantManager.getAnimationGroups(),
|
|
866
866
|
this.renameClonedAsset("")
|
|
867
867
|
) : []
|
|
@@ -959,7 +959,7 @@ class Je {
|
|
|
959
959
|
var n;
|
|
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
|
-
s.parent = this.
|
|
962
|
+
s.rotation.subtractInPlace(new g(0, Math.PI, 0)), s.parent = this.rotationTransform;
|
|
963
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(
|
|
964
964
|
this.materials.concat(this.variantManager.getAllMaterials()),
|
|
965
965
|
this.scene,
|
|
@@ -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
|
|
981
|
+
(t) => t.getChildMeshes(!1).filter((i) => i instanceof Oe)
|
|
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 =
|
|
988
|
+
), this.materials = pe(this.modelInstance), this.configureModelInstance(this.modelInstance), this.animations = he(
|
|
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
|
|
1038
|
+
class I extends ce {
|
|
1039
1039
|
constructor(e, t, i, r, n, s, o, l) {
|
|
1040
1040
|
super(
|
|
1041
1041
|
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,
|
|
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, $, Y, Q, 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 = ((
|
|
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
|
|
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 se(), 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;
|
|
@@ -1213,14 +1213,14 @@ class et {
|
|
|
1213
1213
|
}
|
|
1214
1214
|
}
|
|
1215
1215
|
updateColorCurve(e) {
|
|
1216
|
-
const t = new
|
|
1216
|
+
const t = new se();
|
|
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
|
-
|
|
1220
|
+
Me.GLTFLoader.RegisterExtension("glbPostProcessor", function(a) {
|
|
1221
1221
|
return new ke(a);
|
|
1222
1222
|
});
|
|
1223
|
-
|
|
1223
|
+
ue.OnPluginActivatedObservable.add((a) => {
|
|
1224
1224
|
if (a.name === "gltf") {
|
|
1225
1225
|
const e = a;
|
|
1226
1226
|
e.transparencyAsCoverage = !0;
|
|
@@ -1236,7 +1236,7 @@ class _t {
|
|
|
1236
1236
|
if (!(e != null && e.noRender))
|
|
1237
1237
|
return this.configuration.createCanvas();
|
|
1238
1238
|
})(), r = "1.5.6";
|
|
1239
|
-
|
|
1239
|
+
we.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`,
|
|
@@ -1254,8 +1254,8 @@ class _t {
|
|
|
1254
1254
|
audioEngine: !1,
|
|
1255
1255
|
stencil: this.configuration.highlights.enabled,
|
|
1256
1256
|
forceSRGBBufferSupportState: !0
|
|
1257
|
-
}) : new
|
|
1258
|
-
console.log = n, s.hideLoadingUI(), window.addEventListener("resize", this.fireResizeEvent.bind(this)), this.engine = s, this.scene = new
|
|
1257
|
+
}) : new fe();
|
|
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 et(
|
|
1259
1259
|
this.scene,
|
|
1260
1260
|
!1,
|
|
1261
1261
|
this.camera
|
|
@@ -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 =
|
|
1324
|
+
this.scene.clearColor = this.configuration.scene.clearColor, this.scene.environmentTexture = ve.CreateFromPrefilteredData(
|
|
1325
1325
|
this.configuration.scene.environmentFile,
|
|
1326
1326
|
this.scene
|
|
1327
1327
|
);
|
|
@@ -1413,7 +1413,7 @@ class _t {
|
|
|
1413
1413
|
async renderSceneScreenshot(e, t) {
|
|
1414
1414
|
if (!this.camera)
|
|
1415
1415
|
throw new Error("Missing product camera, cannot render screenshot!");
|
|
1416
|
-
const i = new
|
|
1416
|
+
const i = new ce(
|
|
1417
1417
|
"screenshotCamera",
|
|
1418
1418
|
0,
|
|
1419
1419
|
0,
|
|
@@ -1424,7 +1424,7 @@ class _t {
|
|
|
1424
1424
|
try {
|
|
1425
1425
|
const r = t.latDeg * Math.PI / 180, n = t.lonDeg * Math.PI / 180;
|
|
1426
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
|
|
1427
|
+
const s = await Ce.CreateScreenshotUsingRenderTargetAsync(
|
|
1428
1428
|
this.engine,
|
|
1429
1429
|
i,
|
|
1430
1430
|
e,
|
|
@@ -1444,15 +1444,15 @@ class _t {
|
|
|
1444
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;
|
|
1445
1445
|
if (t === void 0 || i === void 0 || r === void 0 || n === void 0)
|
|
1446
1446
|
return !0;
|
|
1447
|
-
const s = [t, i], o = [r, n], l = s.every((
|
|
1448
|
-
return !l && !
|
|
1447
|
+
const s = [t, i], o = [r, n], l = s.every((d) => d === t), c = o.every((d) => d === r);
|
|
1448
|
+
return !l && !c;
|
|
1449
1449
|
}
|
|
1450
1450
|
fireResizeEvent() {
|
|
1451
1451
|
this.getNumViewports() > 0 && this.engine.resize();
|
|
1452
1452
|
}
|
|
1453
1453
|
setHighlights(e, t) {
|
|
1454
1454
|
var r;
|
|
1455
|
-
e.length === 0 && ((r = this.highlightLayer) == null || r.dispose(), this.highlightLayer = void 0), this.highlightLayer || (this.highlightLayer = new
|
|
1455
|
+
e.length === 0 && ((r = this.highlightLayer) == null || r.dispose(), this.highlightLayer = void 0), this.highlightLayer || (this.highlightLayer = new be("highlights", this.scene, {
|
|
1456
1456
|
isStroke: !0,
|
|
1457
1457
|
blurVerticalSize: 0.85,
|
|
1458
1458
|
blurHorizontalSize: 0.85
|
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,Ae,Re,Ee,C,q,Oe,z,x,Ie,I){"use strict";var L=(a=>(a[a.Orbit=0]="Orbit",a[a.Pan=1]="Pan",a))(L||{}),T=(a=>(a.None="None",a.RemoveWhenSelected="RemoveWhenSelected",a.ApplyWhenSelected="ApplyWhenSelected",a))(T||{});class Se{constructor(e){this.getSceneClearColor=()=>{var i,n,r,s;const t=(i=this.customOptions)!=null&&i.transparentBackground||(n=this.customOptions)!=null&&n.backgroundImage?0:1;if(this.customOptions&&((r=this.customOptions)!=null&&r.transparentBackground)||(s=this.customOptions)!=null&&s.backgroundImage)return new p.Color4(0,0,0,t).toLinearSpace();if(this.customOptions&&this.customOptions.backgroundColor){const o=p.Color3.FromHexString(this.customOptions.backgroundColor);return new p.Color4(o.r,o.g,o.b,t).toLinearSpace()}return new p.Color4(.98,.98,.98,t).toLinearSpace()},this.highlightColorFromConfig=()=>this.customOptions&&this.customOptions.highlightColor?this.hexToColor4(this.customOptions.highlightColor):new p.Color4(.98,.98,.98,1).toLinearSpace(),this.hexToColor4=(t,i=1)=>{const n=p.Color3.FromHexString(t);return new p.Color4(n.r,n.g,n.b,i).toLinearSpace()},this.customOptions=e}createCanvas(){var e;return(e=this.customOptions)!=null&&e.createCanvas?this.customOptions.createCanvas():document.createElement("canvas")}get options(){return this.customOptions}get scene(){var e,t,i;return{clearColor:this.getSceneClearColor(),transparentBackground:((e=this.customOptions)==null?void 0:e.transparentBackground)||((t=this.customOptions)==null?void 0:t.backgroundImage),environmentFile:((i=this.customOptions)==null?void 0:i.environmentFile)??"assets/model-viewer/default.env"}}get camera(){var e,t,i,n,r,s,o,c,d,u,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 Re.DynamicTexture(a,{width:t,height:i},e,w.shouldMipMap(),Ee.Texture.TRILINEAR_SAMPLINGMODE,j.Engine.TEXTUREFORMAT_RGBA),r=n.getContext();return r&&(r.fillStyle="#f5f5f5",r.fillRect(0,0,t,i),n.update()),n}function G(a,e){if(a instanceof E.PBRMaterial){const t=a,i=t.albedoTexture;i?(e.wrapU=i.wrapU,e.wrapV=i.wrapV):(e.wrapU=1,e.wrapV=1),t.albedoTexture=e}else{const t=a,i=t.diffuseTexture;i&&(e.wrapU=i.wrapU,e.wrapV=i.wrapV),t.diffuseTexture=e}}function qe(){const a=()=>Math.floor((1+Math.random())*65536).toString(16).substring(1);return a()+a()+"-"+a()+"-"+a()+"-"+a()+"-"+a()+a()+a()}const M=60,H=1;function K(a){return a.targetedAnimations.map(t=>t.animation.framePerSecond).reduce((t,i)=>t+i,0)/a.targetedAnimations.length||0}function ze(a,e,t,i,n){const r=n?a.filter(s=>s.name===n):a;if(r.length===0){console.warn(`No animations found for name: ${n}`);return}if(i!==void 0&&t!==void 0&&i===t){r.forEach(s=>{s.stop();const o=K(s),c=i*o;s.start(e,H,c,c)});return}r.forEach(s=>{s.stop();const o=K(s),c=i!==void 0?i*o:void 0,d=t!==void 0?t*o:void 0;s.start(e,H,c,d)})}function U(a){a.forEach(e=>{e.stop()})}function 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(A("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(A("cameraAlphaLerp","alpha",e.alpha,W(t.lonDeg),C.Animation.ANIMATIONTYPE_FLOAT,s)),i.push(A("cameraBetaLerp","beta",e.beta,W(t.latDeg),C.Animation.ANIMATIONTYPE_FLOAT,s)),t.radius!==void 0){const d=Math.max(.01,t.radius);i.push(A("cameraRadiusLerp","radius",e.radius,d,C.Animation.ANIMATIONTYPE_FLOAT,s))}e.animations.push(...i);const c=e.useAutoRotationBehavior;e.disableAutoRotationBehavior(),a.beginAnimation(e,0,n?M*2:M,!1,1,()=>{e.animations=[],c&&e.enableAutoRotationBehavior()})}function W(a){return a*Math.PI/180}function A(a,e,t,i,n,r=0,s=C.Animation.ANIMATIONLOOPMODE_CONSTANT){const o=new q.QuadraticEase;o.setEasingMode(q.EasingFunction.EASINGMODE_EASEINOUT);const c=new C.Animation(a,e,M,n,s),d=[];return r>0&&d.push({frame:0,value:t}),d.push({frame:M*r,value:t}),d.push({frame:M*(r+1),value:i}),c.setKeys(d),c.setEasingFunction(o),c}function Ne(a,e,t){return a<e?a=t-(e-a)%(t-e):a=e+(a-e)%(t-e)}const Ge={albedoTexture:"albedoMap",bumpTexture:"normalMap",ambientTexture:"ambientMap",emissiveTexture:"emissionMap",opacityTexture:"alphaMap",metallicTexture:"metallicMap",refractionTexture:"refractionMap"};function He(a,e,t,i){["albedoTexture","bumpTexture","ambientTexture","emissiveTexture","opacityTexture","metallicTexture","refractionTexture"].forEach(r=>{Ke(r,a,e,t,i)}),Ze(a,e)}function Ke(a,e,t,i,n){const r=Ge[a];if(!r)throw new Error("Unexpected texture name encountered.");const s=e[r],o=s==null?void 0:s.fileLink;o?i.addTextureTask(a,o,!1,!1):n&&t[a]&&(t[a]&&t[a].dispose(),t[a]=null,Ue(a,t))}function Ue(a,e){a==="opacityTexture"&&(e.useAlphaFromAlbedoTexture=!0),a==="metallicTexture"&&(e.useRoughnessFromMetallicTextureAlpha=!1,e.useRoughnessFromMetallicTextureGreen=!1,e.useMetallnessFromMetallicTextureBlue=!1),a==="refractionTexture"&&(e.subSurface.isRefractionEnabled=!1,e.subSurface.refractionIntensity=1),a==="emissiveTexture"&&(e.emissiveIntensity=0,e.emissiveColor=new p.Color3(0,0,0))}function We(a,e,t,i){a==="opacityTexture"&&(e.useAlphaFromAlbedoTexture=!1),a==="metallicTexture"&&(e.useRoughnessFromMetallicTextureAlpha=!1,e.useRoughnessFromMetallicTextureGreen=!0,e.useMetallnessFromMetallicTextureBlue=!0),a==="refractionTexture"&&(e.subSurface.isRefractionEnabled=!0,e.subSurface.refractionIntensity=t.refractionIntensity||1),e[a]=i,a==="emissiveTexture"&&(e.emissiveColor=new p.Color3(1,1,1),e.emissiveIntensity=1)}function Ze(a,e){a.clearCoat&&(a.clearCoat===T.RemoveWhenSelected?(e.clearCoat.isEnabled=!1,e.clearCoat.indexOfRefraction=1.5):a.clearCoat===T.ApplyWhenSelected&&(e.clearCoat.isEnabled=!0,e.clearCoat.indexOfRefraction=a.clearCoatIOR||e.clearCoat.indexOfRefraction))}class $e{constructor(e,t,i){this.materialVariantMap=new Map,this.keysThatRemovedBaseModel=[],this.loadedContainerForKey=new Map,this.loadedMaterialsForKey=new Map,this.scene=e,this.renameClonedAsset=t,this.setBaseModelEnabled=i}async applyMaterial(e,t,i,n){return new Promise(r=>{const s=this.materialVariantMap.get(e);this.materialVariantMap.set(e,{...s,...t});const o=this.renameClonedAsset(e),c=this.scene.materials.filter(u=>u.name===o);if(c.length===0){r();return}const d=new Oe.AssetsManager(this.scene);d.useDefaultLoadingScreen=!1,c.forEach(u=>He(t,u,d,n)),d.onProgress=(u,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 Ae.TransformNode("root",this.scene);const o=async()=>(this.assetContainer=await N(i.model,s,r),this.initialized=!0,this.instantiate(),this);this.importPromise=o()}async applyMaterialVariant(e,t,i,n){if(this.previewService.getSceneInitializationProgress()!==100||!this.initialized){if(this.materialReadyToLoadCallbacks.has(e)){const s=this.materialReadyToLoadCallbacks.get(e);s==null||s.set(t,this.applyMaterialVariant.bind(this,e,t,i,n))}else{this.materialReadyToLoadCallbacks.set(e,new Map);const s=this.materialReadyToLoadCallbacks.get(e);s==null||s.set(t,this.applyMaterialVariant.bind(this,e,t,i,n))}return}const r=async()=>{await this.variantManager.applyMaterial(e,i,(s,o,c)=>{this.materialVariantObservable.notifyObservers({remainingCount:s,totalCount:o,taskName:c})},n)};if(this.materialChangesInProgress.includes(e)){if(this.queuedMaterialChanges.has(e)){const s=this.queuedMaterialChanges.get(e);s==null||s.set(t,r)}else{this.queuedMaterialChanges.set(e,new Map);const s=this.queuedMaterialChanges.get(e);s==null||s.set(t,r)}return}this.materialChangesInProgress.push(e),await r(),this.queuedMaterialChanges.has(e)&&(this.queuedMaterialChanges.get(e).forEach(async o=>{await o()}),this.queuedMaterialChanges.delete(e)),this.materialChangesInProgress.splice(this.materialChangesInProgress.indexOf(e),1),this.configureGlowLayer()}async applyModelVariant(e,t,i){if(!this.previewService.getIsInitialized()||!this.initialized){this.modelReadyToLoadCallbacks.set(e,this.applyModelVariant.bind(this,e,t,i));return}const n=()=>this.variantManager.applyModel(e,i,t==null?void 0:t.model,o=>{this.modelVariantObservable.notifyObservers({...o,key:e})});if(this.modelChangesInProgress.includes(e)){this.queuedModelChanges.set(e,n);return}const s=await(async()=>{this.modelChangesInProgress.push(e);let o=await n();return this.queuedModelChanges.has(e)&&(o=await this.queuedModelChanges.get(e)(),this.queuedModelChanges.delete(e)),this.modelChangesInProgress.splice(this.modelChangesInProgress.indexOf(e),1),o})();this.modelInstance&&U(this.modelInstance.animationGroups),this.contextService||(this.contextService=t==null?void 0:t.contextService),s?this.configureModelInstance(s):this.configureGlowLayer()}dispose(){var e;this.destroyInstance(),this.variantManager.dispose(),this.dynamicTextures.forEach(t=>t==null?void 0:t.dispose()),this.dynamicTextures.clear(),this.materials.forEach(t=>t&&(t==null?void 0:t.dispose())),this.materials=[],(e=this.transformRoot)==null||e.dispose(),this.transformRoot=void 0,this.previewService.modelUnloaded(this)}executeAnimation(e){if(!this.previewService.getIsInitialized()){this.queuedModelAnimation=e;return}this.modelInstance&&ze([...this.modelInstance.animationGroups,...this.variantManager.getAnimationGroups()],e.loop,e.to,e.from,e.name?this.renameClonedAsset(e.name):void 0)}getAnimations(e){return[...this.animations,...e?$(this.variantManager.getAnimationGroups(),this.renameClonedAsset("")):[]]}getId(){return this.id}listMaterials(){var t;const e=(t=this.scene)==null?void 0:t.materials.filter(i=>i.name.startsWith(this.id));return e?e.map(i=>({id:i.id,name:this.stripIdFromName(i.name)})):[]}registerMaterialSelectedCallback(e){this.materialSelectedObservable.add(e)}unregisterMaterialSelectedCallback(e){this.materialSelectedObservable.removeCallback(e)}registerMaterialDeselectedCallback(e){this.materialDeselectedObservable.add(e)}unregisterMaterialDeselectedCallback(e){this.materialDeselectedObservable.removeCallback(e)}get position(){return this.transformRoot.position}set position(e){this.transformRoot.position=new 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 R="initialScene";class _e{constructor(e){this.loadProgress=new Map([[R,0]]),this.focusLostNotified=!1,this.loadObservable=new y.Observable,this.focusLostObservable=new y.Observable,this.initializedCallbacks=[],this.isInitialized=!1,this.modelLoadEventCallbacks=[],this.modelContainers=new Map,this.plugins=[],this.configuration=new Se(e);const i=(()=>{if(!(e!=null&&e.noRender))return this.configuration.createCanvas()})(),n="1.5.6";ye.DracoCompression.Configuration={decoder:{wasmUrl:`https://www.gstatic.com/draco/versioned/decoders/${n}/draco_wasm_wrapper_gltf.js`,wasmBinaryUrl:`https://www.gstatic.com/draco/versioned/decoders/${n}/draco_decoder_gltf.wasm`,fallbackUrl:`https://www.gstatic.com/draco/versioned/decoders/${n}/draco_decoder_gltf.js`}},i&&(i.getContext("webgl2")||i.getContext("webgl"));const r=console.log;console.log=()=>{};const s=i?new j.Engine(i,!0,{adaptToDeviceRatio:!0,limitDeviceRatio:2,premultipliedAlpha:!1,preserveDrawingBuffer:!!(e!=null&&e.backgroundImage),audioEngine:!1,stencil:this.configuration.highlights.enabled,forceSRGBBufferSupportState:!0}):new be.NullEngine;console.log=r,s.hideLoadingUI(),window.addEventListener("resize",this.fireResizeEvent.bind(this)),this.engine=s,this.scene=new we.Scene(s),this.camera=S.create(this.scene,this.configuration),this.renderingPipeline=new Qe(this.scene,!1,this.camera),this.scene.imageProcessingConfiguration.exposure=this.configuration.lighting.exposure,this.scene.imageProcessingConfiguration.contrast=this.configuration.lighting.contrast,this.glowLayerManager=new je(this.scene,this.configuration.emissiveGlowIntensity)}getEngineContext(){return{engine:this.engine,scene:this.scene,camera:this.camera}}registerFocusLostListener(e){this.focusLostObservable.add(e)}unregisterFocusLostListener(e){this.focusLostObservable.removeCallback(e)}registerLoadProgressListener(e){this.loadObservable.add(e),e(this.getLoadListenerEvent())}unregisterLoadProgressListener(e){this.loadObservable.removeCallback(e)}registerInitializedListener(e){this.isInitialized||!this.isInitialized&&this.initializedCallbacks.push(e)}unregisterInitializedListener(e){if(this.isInitialized)return;const t=this.initializedCallbacks.indexOf(e);t>-1&&this.initializedCallbacks.splice(t,1)}getIsInitialized(){return this.isInitialized}registerModelLoadEventListener(e){this.modelLoadEventCallbacks.push(e)}unregisterModelLoadEventListener(e){const t=this.modelLoadEventCallbacks.indexOf(e);t>-1&&this.modelLoadEventCallbacks.splice(t,1)}registerView(e){const t=e.height,i=e.width;this.engine.registerView(e),e.setAttribute("height",t.toString()),e.setAttribute("width",i.toString()),this.orbitEnabled()||this.setCameraState(L.Pan),this.reattachControls(e)}getNumViewports(){var e;return((e=this.engine.views)==null?void 0:e.length)||0}unregisterView(e){this.engine.unRegisterView(e)}shutdown(){this.plugins.forEach(e=>e.dispose(!0)),this.renderingPipeline.dispose(),this.engine&&this.engine.dispose(),window.removeEventListener("resize",this.fireResizeEvent)}getSceneInitializationProgress(){return this.loadProgress.get(R)}async initialize(e){var i,n;this.scene.clearColor=this.configuration.scene.clearColor,this.scene.environmentTexture=ve.CubeTexture.CreateFromPrefilteredData(this.configuration.scene.environmentFile,this.scene);let t;return e&&(t=await this.loadModel(e,s=>{this.loadProgress.set(R,s.loaded*100/s.total),this.notifyLoadHandlers()}).getInitializationPromise()),this.loadProgress.set(R,100),this.notifyLoadHandlers(),this.scene.activeCamera=this.camera,this.camera.rerunFramingBehavior(void 0,1),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,v){typeof exports=="object"&&typeof module<"u"?v(exports,require("@babylonjs/core/Cameras/arcRotateCamera"),require("@babylonjs/core/Engines/engine"),require("@babylonjs/core/Engines/nullEngine"),require("@babylonjs/core/Layers/highlightLayer"),require("@babylonjs/core/Loading/sceneLoader"),require("@babylonjs/core/Materials/Textures/cubeTexture"),require("@babylonjs/core/Maths/math.color"),require("@babylonjs/core/Maths/math.vector"),require("@babylonjs/core/Meshes/Compression/dracoCompression"),require("@babylonjs/core/Misc/observable"),require("@babylonjs/core/Misc/tools"),require("@babylonjs/core/scene"),require("@babylonjs/loaders/glTF"),require("@babylonjs/core/Materials/PBR/pbrMaterial"),require("@babylonjs/core/Materials/Textures/mirrorTexture"),require("@babylonjs/core/Maths/math"),require("@babylonjs/core/Probes/reflectionProbe"),require("@babylonjs/core/Layers/glowLayer"),require("@babylonjs/core/Actions/actionManager"),require("@babylonjs/core/Actions/directActions"),require("@babylonjs/core/Meshes/mesh"),require("@babylonjs/core/Meshes/transformNode"),require("@babylonjs/core/Materials/Textures/dynamicTexture"),require("@babylonjs/core/Materials/Textures/texture"),require("@babylonjs/core/Animations/animation"),require("@babylonjs/core/Animations/easing"),require("@babylonjs/core/Misc/assetsManager"),require("@babylonjs/core/Materials/colorCurves"),require("@babylonjs/core/Materials/imageProcessingConfiguration"),require("@babylonjs/core/PostProcesses/RenderPipeline"),require("@babylonjs/core/PostProcesses/depthOfFieldEffect"),require("@babylonjs/core/Rendering/depthRendererSceneComponent"),require("@babylonjs/core/Engines/Extensions/engine.views"),require("@babylonjs/core/Meshes/instancedMesh"),require("@babylonjs/core/Materials/Textures/Loaders/ddsTextureLoader"),require("@babylonjs/core/Materials/Textures/Loaders/envTextureLoader"),require("@babylonjs/core/Materials/Textures/Loaders/ktxTextureLoader"),require("@babylonjs/core/Animations/animatable"),require("@babylonjs/core/Misc/screenshotTools"),require("@babylonjs/core/Rendering/boundingBoxRenderer"),require("@babylonjs/loaders/glTF/2.0/Extensions")):typeof define=="function"&&define.amd?define(["exports","@babylonjs/core/Cameras/arcRotateCamera","@babylonjs/core/Engines/engine","@babylonjs/core/Engines/nullEngine","@babylonjs/core/Layers/highlightLayer","@babylonjs/core/Loading/sceneLoader","@babylonjs/core/Materials/Textures/cubeTexture","@babylonjs/core/Maths/math.color","@babylonjs/core/Maths/math.vector","@babylonjs/core/Meshes/Compression/dracoCompression","@babylonjs/core/Misc/observable","@babylonjs/core/Misc/tools","@babylonjs/core/scene","@babylonjs/loaders/glTF","@babylonjs/core/Materials/PBR/pbrMaterial","@babylonjs/core/Materials/Textures/mirrorTexture","@babylonjs/core/Maths/math","@babylonjs/core/Probes/reflectionProbe","@babylonjs/core/Layers/glowLayer","@babylonjs/core/Actions/actionManager","@babylonjs/core/Actions/directActions","@babylonjs/core/Meshes/mesh","@babylonjs/core/Meshes/transformNode","@babylonjs/core/Materials/Textures/dynamicTexture","@babylonjs/core/Materials/Textures/texture","@babylonjs/core/Animations/animation","@babylonjs/core/Animations/easing","@babylonjs/core/Misc/assetsManager","@babylonjs/core/Materials/colorCurves","@babylonjs/core/Materials/imageProcessingConfiguration","@babylonjs/core/PostProcesses/RenderPipeline","@babylonjs/core/PostProcesses/depthOfFieldEffect","@babylonjs/core/Rendering/depthRendererSceneComponent","@babylonjs/core/Engines/Extensions/engine.views","@babylonjs/core/Meshes/instancedMesh","@babylonjs/core/Materials/Textures/Loaders/ddsTextureLoader","@babylonjs/core/Materials/Textures/Loaders/envTextureLoader","@babylonjs/core/Materials/Textures/Loaders/ktxTextureLoader","@babylonjs/core/Animations/animatable","@babylonjs/core/Misc/screenshotTools","@babylonjs/core/Rendering/boundingBoxRenderer","@babylonjs/loaders/glTF/2.0/Extensions"],v):(l=typeof globalThis<"u"?globalThis:l||self,v(l.Preview={},l.arcRotateCamera,l.engine,l.nullEngine,l.highlightLayer,l.sceneLoader,l.cubeTexture,l.math_color,l.math_vector,l.dracoCompression,l.observable,l.tools,l.scene,l.glTF,l.pbrMaterial,l.mirrorTexture,l.math,l.reflectionProbe,l.glowLayer,l.actionManager,l.directActions,l.mesh,l.transformNode,l.dynamicTexture,l.texture,l.animation,l.easing,l.assetsManager,l.colorCurves,l.imageProcessingConfiguration,l.RenderPipeline,l.depthOfFieldEffect))})(this,function(l,v,j,fe,ve,B,ye,p,g,Ce,y,we,Me,Pe,E,xe,P,Le,Te,O,D,Ae,q,Re,Ee,C,z,Oe,V,x,Ie,I){"use strict";var L=(a=>(a[a.Orbit=0]="Orbit",a[a.Pan=1]="Pan",a))(L||{}),T=(a=>(a.None="None",a.RemoveWhenSelected="RemoveWhenSelected",a.ApplyWhenSelected="ApplyWhenSelected",a))(T||{});class Se{constructor(e){this.getSceneClearColor=()=>{var i,n,r,s;const t=(i=this.customOptions)!=null&&i.transparentBackground||(n=this.customOptions)!=null&&n.backgroundImage?0:1;if(this.customOptions&&((r=this.customOptions)!=null&&r.transparentBackground)||(s=this.customOptions)!=null&&s.backgroundImage)return new p.Color4(0,0,0,t).toLinearSpace();if(this.customOptions&&this.customOptions.backgroundColor){const o=p.Color3.FromHexString(this.customOptions.backgroundColor);return new p.Color4(o.r,o.g,o.b,t).toLinearSpace()}return new p.Color4(.98,.98,.98,t).toLinearSpace()},this.highlightColorFromConfig=()=>this.customOptions&&this.customOptions.highlightColor?this.hexToColor4(this.customOptions.highlightColor):new p.Color4(.98,.98,.98,1).toLinearSpace(),this.hexToColor4=(t,i=1)=>{const n=p.Color3.FromHexString(t);return new p.Color4(n.r,n.g,n.b,i).toLinearSpace()},this.customOptions=e}createCanvas(){var e;return(e=this.customOptions)!=null&&e.createCanvas?this.customOptions.createCanvas():document.createElement("canvas")}get options(){return this.customOptions}get scene(){var e,t,i;return{clearColor:this.getSceneClearColor(),transparentBackground:((e=this.customOptions)==null?void 0:e.transparentBackground)||((t=this.customOptions)==null?void 0:t.backgroundImage),environmentFile:((i=this.customOptions)==null?void 0:i.environmentFile)??"assets/model-viewer/default.env"}}get camera(){var e,t,i,n,r,s,o,c,d,u,m,b,f;return{autoOrientation:((e=this.customOptions)==null?void 0:e.disableAutomaticOrientation)??!0,autoRotation:{enabled:((t=this.customOptions)==null?void 0:t.autoRotation)??!1,idleTimeMs:((i=this.customOptions)==null?void 0:i.idleTimeBeforeRotation)??5e3},limits:{min:{alpha:(n=this.customOptions)!=null&&n.lowerAlphaLimitDeg?((r=this.customOptions)==null?void 0:r.lowerAlphaLimitDeg)*Math.PI/180:void 0,beta:(s=this.customOptions)!=null&&s.lowerBetaLimitDeg?((o=this.customOptions)==null?void 0:o.lowerBetaLimitDeg)*Math.PI/180:void 0,radius:(c=this.customOptions)==null?void 0:c.minZoomOverride},max:{alpha:(d=this.customOptions)!=null&&d.upperAlphaLimitDeg?((u=this.customOptions)==null?void 0:u.upperAlphaLimitDeg)*Math.PI/180:void 0,beta:(m=this.customOptions)!=null&&m.upperBetaLimitDeg?((b=this.customOptions)==null?void 0:b.upperBetaLimitDeg)*Math.PI/180:void 0,radius:(f=this.customOptions)==null?void 0:f.maxZoomOverride}}}}get highlights(){var e;return{enabled:((e=this.customOptions)==null?void 0:e.highlightOnMaterialHover)??!1,color:this.highlightColorFromConfig()}}get lighting(){var e,t,i,n;return{exposure:((t=(e=this.customOptions)==null?void 0:e.lighting)==null?void 0:t.exposure)??.9,contrast:((n=(i=this.customOptions)==null?void 0:i.lighting)==null?void 0:n.contrast)??1.6}}get emissiveGlowIntensity(){var e;return((e=this.customOptions)==null?void 0:e.emissiveGlowIntensity)??.5}}class w{static getDynamicTextureResolution(){return this.getIsMobile()||!w.offscreenRenderingSupported()?{width:1024,height:1024}:{width:2048,height:2048}}static shouldMipMap(){return!0}static offscreenRenderingSupported(){return navigator.userAgent.includes("SamsungBrowser")?!1:!!window.Worker&&!!window.OffscreenCanvas}static getMirrorTextureResolution(){return this.getIsMobile()?512:1024}static getIsMobile(){try{return typeof window>"u"||!window.navigator?!1:/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(window.navigator.userAgent)||window.innerWidth<=480}catch{return!1}}}const k=128,h={antiAliasing:{samples:4,fxaaEnabled:!1},bloom:{enabled:!1,kernel:64,scale:.5,threshold:.9,weight:.15},chromaticAberration:{enabled:!1,aberrationAmount:30,direction:{x:0,y:0},radialIntensity:0},colorCurves:{enabled:!1},depthOfField:{enabled:!1,blurLevel:"Low",focalLength:50,focusDistance:2e3,fStop:1.4,lensSize:50},grain:{enabled:!1,animated:!1,intensity:30},misc:{contrast:1,exposure:1,toneMappingEnabled:!1,toneMappingType:"Standard"},sharpen:{enabled:!1,colorAmount:1,edgeAmount:.3},vignette:{enabled:!1,blendMode:"Multiply",cameraFov:.5,center:{x:0,y:0},colorHex:"#000000ff",colorRgba:{r:0,g:0,b:0,a:1},stretch:0,weight:1}};class Fe{constructor(e){this.name="glbPostProcessor",this.enabled=!0,this.loader=e}onReady(){this.applyReflections(this.loader.babylonScene)}loadNodeAsync(e,t,i){return this.loader.loadNodeAsync(e,t,function(n){t.extras&&Object.keys(t.extras).forEach(r=>{const s=t.extras[r];n.metadata[r]=s}),i(n)})}async loadMaterialPropertiesAsync(e,t,i){await this.loader.loadMaterialPropertiesAsync(e,t,i),this.enableMaterialExtrasIfRequired(t,i),i.needDepthPrePass=!0}dispose(){}enableMaterialExtrasIfRequired(e,t){if(!(!e.extras||!(t instanceof E.PBRMaterial))){if(e.extras.sheen){const i=t;i.sheen.isEnabled=!0,i.sheen.intensity=e.extras.sheen}if(e.extras.translucency){const i=t;i.subSurface.isTranslucencyEnabled=!0,i.subSurface.translucencyIntensity=e.extras.translucency,e.extras.translucencyR&&e.extras.translucencyG&&e.extras.translucencyB&&(i.subSurface.tintColor=new P.Color3(e.extras.translucencyR,e.extras.translucencyG,e.extras.translucencyB))}if(e.extras.refractionIOR){const i=t;i.subSurface.isRefractionEnabled=!0,i.subSurface.volumeIndexOfRefraction=e.extras.refractionIOR}if(e.extras.useDepthPrePass){const i=t;i.needDepthPrePass=!0,i.forceIrradianceInFragment=!0}if(e.extras.useParallax){const i=t;i.useParallax=!0,i.useParallaxOcclusion=!0,i.parallaxScaleBias=e.extras.useParallax}}}applyReflections(e){function t(r){const s=[];return r.transformNodes.forEach(o=>{o.metadata&&o.metadata.reflective&&s.push(...o.getChildMeshes())}),r.meshes.forEach(o=>{o.metadata&&o.metadata.reflective&&!s.includes(o)&&s.push(o)}),s}function i(r,s=1){const o=r.material;if(!o)return;const c=new xe.MirrorTexture("mirror",w.getMirrorTextureResolution(),e,!0);c.renderList=t(e);const d=r.getVerticesData("normal");if(!d)throw new Error("Mirror attribute specified on: "+r.name+"But no normals exist to generate a mirror from!");r.computeWorldMatrix(!0);const u=r.getWorldMatrix(),m=P.Vector3.TransformNormal(new P.Vector3(d[0],d[1],d[2]),u).normalize(),b=P.Plane.FromPositionAndNormal(r.position,m.scale(-1));c.mirrorPlane=b,c.level=s,o.reflectionTexture=c}function n(r){const s=r.material,o=new Le.ReflectionProbe("probe-"+s.name,k,e);o.attachToMesh(r),o.renderList&&o.renderList.push(...t(e)),s.reflectionTexture=o.cubeTexture}e.meshes.forEach(r=>{const s=r.metadata;s&&(s.mirrorTexture&&i(r,s.mirrorTexture),s.reflectionProbe&&n(r))})}}class je{constructor(e,t){this.scene=e,this.intensity=t,this.meshCount=0}includeMeshes(e){this.glowLayer||(this.glowLayer=new Te.GlowLayer("glow",this.scene),this.glowLayer.intensity=this.intensity),e.forEach(t=>{this.glowLayer.hasMesh(t)||(this.glowLayer.addIncludedOnlyMesh(t),this.meshCount++)})}removeMeshes(e){this.glowLayer&&(e.forEach(t=>{this.glowLayer.hasMesh(t)&&(this.glowLayer.removeIncludedOnlyMesh(t),this.meshCount--)}),this.meshCount===0&&(this.glowLayer.dispose(),this.glowLayer=void 0))}}const N=new Map;async function G(a,e,t){return new Promise((i,n)=>{const r=N.get(a);if(r&&r.scene.uid===e.uid)return i(r);B.SceneLoader.LoadAssetContainerAsync(a,void 0,e,t).then(s=>{N.set(a,s),i(s)}).catch(n)})}function Be(a,e,t,i,n=""){t.forEach(r=>{const s=r.getID(),o=r.getName(),c=w.getDynamicTextureResolution();a.filter(u=>u.name===n+o).forEach(u=>{const m=i.get(s),b=!1;if(m)H(u,m),m.update(b);else{const f=De(o,e,c.width,c.height);i.set(s,f),r.setStaticContext(f.getContext()),H(u,f),f.onLoadObservable.addOnce(()=>{f.update(b)})}})})}function De(a,e,t,i){const n=new 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 H(a,e){if(a instanceof E.PBRMaterial){const t=a,i=t.albedoTexture;i?(e.wrapU=i.wrapU,e.wrapV=i.wrapV):(e.wrapU=1,e.wrapV=1),t.albedoTexture=e}else{const t=a,i=t.diffuseTexture;i&&(e.wrapU=i.wrapU,e.wrapV=i.wrapV),t.diffuseTexture=e}}function qe(){const a=()=>Math.floor((1+Math.random())*65536).toString(16).substring(1);return a()+a()+"-"+a()+"-"+a()+"-"+a()+"-"+a()+a()+a()}const M=60,K=1;function U(a){return a.targetedAnimations.map(t=>t.animation.framePerSecond).reduce((t,i)=>t+i,0)/a.targetedAnimations.length||0}function 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=U(s),c=i*o;s.start(e,K,c,c)});return}r.forEach(s=>{s.stop();const o=U(s),c=i!==void 0?i*o:void 0,d=t!==void 0?t*o:void 0;s.start(e,K,c,d)})}function W(a){a.forEach(e=>{e.stop()})}function Ve(a){const e=a.animationGroups;W(e)}function ke(a,e,t){a.stopAnimation(e),e.animations=[],Math.abs(e.alpha)>2*Math.PI&&(e.alpha=Ne(e.alpha,0,2*Math.PI));const i=[],n=t.target,r=0,s=n?1:0;if(t.target&&Object.keys(t.target).length>0&&i.push(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,Z(t.lonDeg),C.Animation.ANIMATIONTYPE_FLOAT,s)),i.push(A("cameraBetaLerp","beta",e.beta,Z(t.latDeg),C.Animation.ANIMATIONTYPE_FLOAT,s)),t.radius!==void 0){const d=Math.max(.01,t.radius);i.push(A("cameraRadiusLerp","radius",e.radius,d,C.Animation.ANIMATIONTYPE_FLOAT,s))}e.animations.push(...i);const c=e.useAutoRotationBehavior;e.disableAutoRotationBehavior(),a.beginAnimation(e,0,n?M*2:M,!1,1,()=>{e.animations=[],c&&e.enableAutoRotationBehavior()})}function Z(a){return a*Math.PI/180}function A(a,e,t,i,n,r=0,s=C.Animation.ANIMATIONLOOPMODE_CONSTANT){const o=new z.QuadraticEase;o.setEasingMode(z.EasingFunction.EASINGMODE_EASEINOUT);const c=new C.Animation(a,e,M,n,s),d=[];return r>0&&d.push({frame:0,value:t}),d.push({frame:M*r,value:t}),d.push({frame:M*(r+1),value:i}),c.setKeys(d),c.setEasingFunction(o),c}function Ne(a,e,t){return a<e?a=t-(e-a)%(t-e):a=e+(a-e)%(t-e)}const Ge={albedoTexture:"albedoMap",bumpTexture:"normalMap",ambientTexture:"ambientMap",emissiveTexture:"emissionMap",opacityTexture:"alphaMap",metallicTexture:"metallicMap",refractionTexture:"refractionMap"};function He(a,e,t,i){["albedoTexture","bumpTexture","ambientTexture","emissiveTexture","opacityTexture","metallicTexture","refractionTexture"].forEach(r=>{Ke(r,a,e,t,i)}),Ze(a,e)}function Ke(a,e,t,i,n){const r=Ge[a];if(!r)throw new Error("Unexpected texture name encountered.");const s=e[r],o=s==null?void 0:s.fileLink;o?i.addTextureTask(a,o,!1,!1):n&&t[a]&&(t[a]&&t[a].dispose(),t[a]=null,Ue(a,t))}function Ue(a,e){a==="opacityTexture"&&(e.useAlphaFromAlbedoTexture=!0),a==="metallicTexture"&&(e.useRoughnessFromMetallicTextureAlpha=!1,e.useRoughnessFromMetallicTextureGreen=!1,e.useMetallnessFromMetallicTextureBlue=!1),a==="refractionTexture"&&(e.subSurface.isRefractionEnabled=!1,e.subSurface.refractionIntensity=1),a==="emissiveTexture"&&(e.emissiveIntensity=0,e.emissiveColor=new p.Color3(0,0,0))}function We(a,e,t,i){a==="opacityTexture"&&(e.useAlphaFromAlbedoTexture=!1),a==="metallicTexture"&&(e.useRoughnessFromMetallicTextureAlpha=!1,e.useRoughnessFromMetallicTextureGreen=!0,e.useMetallnessFromMetallicTextureBlue=!0),a==="refractionTexture"&&(e.subSurface.isRefractionEnabled=!0,e.subSurface.refractionIntensity=t.refractionIntensity||1),e[a]=i,a==="emissiveTexture"&&(e.emissiveColor=new p.Color3(1,1,1),e.emissiveIntensity=1)}function Ze(a,e){a.clearCoat&&(a.clearCoat===T.RemoveWhenSelected?(e.clearCoat.isEnabled=!1,e.clearCoat.indexOfRefraction=1.5):a.clearCoat===T.ApplyWhenSelected&&(e.clearCoat.isEnabled=!0,e.clearCoat.indexOfRefraction=a.clearCoatIOR||e.clearCoat.indexOfRefraction))}class $e{constructor(e,t,i){this.materialVariantMap=new Map,this.keysThatRemovedBaseModel=[],this.loadedContainerForKey=new Map,this.loadedMaterialsForKey=new Map,this.scene=e,this.renameClonedAsset=t,this.setBaseModelEnabled=i}async applyMaterial(e,t,i,n){return new Promise(r=>{const s=this.materialVariantMap.get(e);this.materialVariantMap.set(e,{...s,...t});const o=this.renameClonedAsset(e),c=this.scene.materials.filter(u=>u.name===o);if(c.length===0){r();return}const d=new Oe.AssetsManager(this.scene);d.useDefaultLoadingScreen=!1,c.forEach(u=>He(t,u,d,n)),d.onProgress=(u,m,b)=>{i&&i(u/m*100,100,b.name)},d.onFinish=u=>{u.forEach(m=>{const b=m;i&&i(100,100,m.name),c.forEach(f=>We(m.name,f,t,b.texture))}),r()},d.loadAsync()})}async applyModel(e,t,i,n){var c,d;if(i&&t&&!this.keysThatRemovedBaseModel.includes(e)&&this.keysThatRemovedBaseModel.push(e),!i)return this.keysThatRemovedBaseModel.includes(e)&&this.setBaseModelEnabled(!0),(c=this.loadedContainerForKey.get(e))==null||c.dispose(),this.loadedContainerForKey.delete(e),this.loadedMaterialsForKey.delete(e),Promise.resolve(void 0);this.loadedContainerForKey.has(e)&&((d=this.loadedContainerForKey.get(e))==null||d.dispose(),this.loadedContainerForKey.delete(e),this.loadedMaterialsForKey.delete(e)),t&&this.setBaseModelEnabled(!1);const s=(await G(i,this.scene,n)).instantiateModelsToScene(this.renameClonedAsset,!0);this.loadedContainerForKey.set(e,s),this.loadedMaterialsForKey.set(e,$(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 $(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 Y(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 q.TransformNode("root",this.scene),this.rotationTransform=new q.TransformNode("rotation",this.scene),this.rotationTransform.parent=this.transformRoot,this.rotationTransform.rotation=new g.Vector3(0,Math.PI,0);const o=async()=>(this.assetContainer=await G(i.model,s,r),this.initialized=!0,this.instantiate(),this);this.importPromise=o()}async applyMaterialVariant(e,t,i,n){if(this.previewService.getSceneInitializationProgress()!==100||!this.initialized){if(this.materialReadyToLoadCallbacks.has(e)){const s=this.materialReadyToLoadCallbacks.get(e);s==null||s.set(t,this.applyMaterialVariant.bind(this,e,t,i,n))}else{this.materialReadyToLoadCallbacks.set(e,new Map);const s=this.materialReadyToLoadCallbacks.get(e);s==null||s.set(t,this.applyMaterialVariant.bind(this,e,t,i,n))}return}const r=async()=>{await this.variantManager.applyMaterial(e,i,(s,o,c)=>{this.materialVariantObservable.notifyObservers({remainingCount:s,totalCount:o,taskName:c})},n)};if(this.materialChangesInProgress.includes(e)){if(this.queuedMaterialChanges.has(e)){const s=this.queuedMaterialChanges.get(e);s==null||s.set(t,r)}else{this.queuedMaterialChanges.set(e,new Map);const s=this.queuedMaterialChanges.get(e);s==null||s.set(t,r)}return}this.materialChangesInProgress.push(e),await r(),this.queuedMaterialChanges.has(e)&&(this.queuedMaterialChanges.get(e).forEach(async o=>{await o()}),this.queuedMaterialChanges.delete(e)),this.materialChangesInProgress.splice(this.materialChangesInProgress.indexOf(e),1),this.configureGlowLayer()}async applyModelVariant(e,t,i){if(!this.previewService.getIsInitialized()||!this.initialized){this.modelReadyToLoadCallbacks.set(e,this.applyModelVariant.bind(this,e,t,i));return}const n=()=>this.variantManager.applyModel(e,i,t==null?void 0:t.model,o=>{this.modelVariantObservable.notifyObservers({...o,key:e})});if(this.modelChangesInProgress.includes(e)){this.queuedModelChanges.set(e,n);return}const s=await(async()=>{this.modelChangesInProgress.push(e);let o=await n();return this.queuedModelChanges.has(e)&&(o=await this.queuedModelChanges.get(e)(),this.queuedModelChanges.delete(e)),this.modelChangesInProgress.splice(this.modelChangesInProgress.indexOf(e),1),o})();this.modelInstance&&W(this.modelInstance.animationGroups),this.contextService||(this.contextService=t==null?void 0:t.contextService),s?this.configureModelInstance(s):this.configureGlowLayer()}dispose(){var e;this.destroyInstance(),this.variantManager.dispose(),this.dynamicTextures.forEach(t=>t==null?void 0:t.dispose()),this.dynamicTextures.clear(),this.materials.forEach(t=>t&&(t==null?void 0:t.dispose())),this.materials=[],(e=this.transformRoot)==null||e.dispose(),this.transformRoot=void 0,this.previewService.modelUnloaded(this)}executeAnimation(e){if(!this.previewService.getIsInitialized()){this.queuedModelAnimation=e;return}this.modelInstance&&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?Y(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.rotation.subtractInPlace(new g.Vector3(0,Math.PI,0)),s.parent=this.rotationTransform}),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 Ae.Mesh)).flat()}instantiate(){this.modelInstance=this.assetContainer.instantiateModelsToScene(this.renameClonedAsset.bind(this),!0),this.materials=$(this.modelInstance),this.configureModelInstance(this.modelInstance),this.animations=Y(this.modelInstance.animationGroups,this.renameClonedAsset("")),this.processQueuedEvents()}renameClonedAsset(e){return`${this.id}_${e}`}setEnabled(e){e&&!this.modelInstance?this.instantiate():!e&&this.modelInstance&&this.destroyInstance()}updateDynamicTextures(){var e;(e=this.canvasPanels)==null||e.forEach((t,i)=>{const n=this.dynamicTextures.get(i);n&&t.getStaticContextDirty()&&n.isReady()&&(n.update(!1),t.setStaticContextDirty(!1))})}registerMaterialVariantListener(e){this.materialVariantObservable.add(e)}unregisterMaterialVariantListener(e){this.materialVariantObservable.removeCallback(e)}registerModelVariantListener(e){this.modelVariantObservable.add(e)}unregisterModelVariantListener(e){this.modelVariantObservable.removeCallback(e)}stripIdFromName(e){return e.substring(this.id.length+1)}async processQueuedEvents(){this.previewService.getIsInitialized()&&(await Promise.all(Array.from(this.materialReadyToLoadCallbacks.values()).map(e=>Array.from(e.values()).map(t=>t()))),this.materialReadyToLoadCallbacks.clear(),await Promise.all(Array.from(this.modelReadyToLoadCallbacks.values()).map(e=>e())),this.modelReadyToLoadCallbacks.clear(),this.queuedModelAnimation&&(this.executeAnimation(this.queuedModelAnimation),this.queuedModelAnimation=void 0))}}class S extends v.ArcRotateCamera{constructor(e,t,i,n,r,s,o,c){super(e,t,i,n,r,s,c),this.lastFocus=new g.Vector3(0,0,0),this.panDenominator=1,this.minZ=.01,this.setRadius(this.radius),this.enableFramingBehavior(),this.wheelDeltaPercentage=.01,this.pinchDeltaPercentage=.005,this.useNaturalPinchZoom=!0,o.camera.autoOrientation&&(this.alpha+=Math.PI),o&&(o.camera.limits.min.beta&&(this.lowerBetaLimit=o.camera.limits.min.beta),o.camera.limits.max.beta&&(this.upperBetaLimit=o.camera.limits.max.beta),o.camera.limits.min.alpha&&(this.lowerAlphaLimit=o.camera.limits.min.alpha),o.camera.limits.max.alpha&&(this.upperAlphaLimit=o.camera.limits.max.alpha),o.camera.limits.min.radius&&(this.lowerRadiusLimit=o.camera.limits.min.radius),o.camera.limits.max.radius&&(this.upperRadiusLimit=o.camera.limits.max.radius),o.camera.autoRotation.enabled&&this.enableAutoRotationBehavior(o.camera.autoRotation.idleTimeMs))}getFramingBehavior(){return this.getBehaviorByName("Framing")}getAutoRotationBehavior(){const e=this.getBehaviorByName("AutoRotation");if(e)return e}enableFramingBehavior(){this.useFramingBehavior=!0;const e=this.getFramingBehavior();e.attach(this),e.framingTime=0,e.elevationReturnTime=-1,e.zoomStopsAnimation=!1,this.lowerRadiusLimit=null;const t=F(this._scene);return e.zoomOnBoundingInfo(t.min,t.max),this.wheelPrecision=100/this.radius,this.lowerRadiusLimit===null&&(this.lowerRadiusLimit=.1),this.lastFocus.copyFrom(this.target),e}rerunFramingBehavior(e,t){const i=this.getFramingBehavior();i.framingTime=t||800;const n=()=>{e&&e()},r=F(this._scene),s=r.max.subtract(r.min),o=r.min.add(s.scale(.5));this.setRadius(s.length()*1.5),this.wheelPrecision=100/this.radius,this.panningInertia=0,this.panningOriginTarget.copyFrom(o),this.panDenominator=s.length(),i.zoomOnBoundingInfo(r.min,r.max,void 0,n),i.framingTime=0}enableAutoRotationBehavior(e=5e3){this.useAutoRotationBehavior=!0;const t=this.getAutoRotationBehavior();t&&(t.idleRotationWaitTime=e)}disableAutoRotationBehavior(){this.useAutoRotationBehavior=!1}setRadius(e){this.radius=e,this.maxZ=this.radius*1e3,this.lowerRadiusLimit=this.radius*.01,this.upperRadiusLimit=1.5*this.radius,this.wheelPrecision=100/this.radius,this.pinchPrecision=300/this.radius}static create(e,t,i){const n=F(e),r=n.max.subtract(n.min),s=n.min.add(r.scale(.5)),o=new S("ProductCamera",-(Math.PI/2),Math.PI/2,r.length()*1.5,s,e,t);return o.panningInertia=0,o.panningOriginTarget.copyFrom(s),o.panDenominator=r.length(),o.onAfterCheckInputsObservable.add(()=>{o.panningSensibility=1e3/o.panDenominator}),i&&(e.activeCamera=o),o}}function F(a){if(a.meshes.length===0)return{min:new g.Vector3(-1,-1,-1),max:new g.Vector3(1,1,1)};const e=a.meshes.filter(t=>t.name.toLowerCase().endsWith("_t")||t.name.toLowerCase().includes("_t_"));return a.getWorldExtends(t=>t.isVisible&&t.isEnabled()&&(e.length===0||e.includes(t)))}class Qe{constructor(e,t=!1,i=void 0){this.renderingPipeline=new Ie.DefaultRenderingPipeline("default",t,e,i?[i]:void 0,!1),this.renderingPipeline.isSupported&&(this.renderingPipeline.prepare(),this.setConfiguration(h))}dispose(){this.renderingPipeline.dispose()}getConfiguration(){return this.currentConfiguration}setConfiguration(e){var t,i,n,r,s,o,c,d,u,m,b,f,Q,_,X,J,ee,te,ie,se,re,ne,ae,oe,le,he,ce,de,ue,ge,me,pe,be;if(this.renderingPipeline.isSupported){if(this.renderingPipeline.samples=((t=e.antiAliasing)==null?void 0:t.samples)??h.antiAliasing.samples,this.renderingPipeline.fxaaEnabled=((i=e.antiAliasing)==null?void 0:i.fxaaEnabled)??h.antiAliasing.fxaaEnabled,this.renderingPipeline.bloomEnabled=((n=e.bloom)==null?void 0:n.enabled)??h.bloom.enabled,this.renderingPipeline.bloomKernel=((r=e.bloom)==null?void 0:r.kernel)??h.bloom.kernel,this.renderingPipeline.bloomScale=((s=e.bloom)==null?void 0:s.scale)??h.bloom.scale,this.renderingPipeline.bloomThreshold=((o=e.bloom)==null?void 0:o.threshold)??h.bloom.threshold,this.renderingPipeline.bloomWeight=((c=e.bloom)==null?void 0:c.weight)??h.bloom.weight,this.renderingPipeline.chromaticAberrationEnabled=((d=e.chromaticAberration)==null?void 0:d.enabled)??h.chromaticAberration.enabled,this.renderingPipeline.chromaticAberration.aberrationAmount=((u=e.chromaticAberration)==null?void 0:u.aberrationAmount)??h.chromaticAberration.aberrationAmount,this.renderingPipeline.chromaticAberration.radialIntensity=((m=e.chromaticAberration)==null?void 0:m.radialIntensity)??h.chromaticAberration.radialIntensity,this.renderingPipeline.chromaticAberration.direction=(b=e.chromaticAberration)!=null&&b.direction?new g.Vector2(e.chromaticAberration.direction.x,e.chromaticAberration.direction.y):new g.Vector2(h.chromaticAberration.direction.x,h.chromaticAberration.direction.y),this.renderingPipeline.imageProcessing.colorCurvesEnabled=((f=e.colorCurves)==null?void 0:f.enabled)??h.colorCurves.enabled,this.renderingPipeline.imageProcessing.colorCurves=e.colorCurves?this.updateColorCurve(e.colorCurves):new V.ColorCurves,this.renderingPipeline.depthOfFieldEnabled=((Q=e.depthOfField)==null?void 0:Q.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=((_=e.depthOfField)==null?void 0:_.focalLength)??h.depthOfField.focalLength,this.renderingPipeline.depthOfField.fStop=((X=e.depthOfField)==null?void 0:X.fStop)??h.depthOfField.fStop,this.renderingPipeline.depthOfField.focusDistance=((J=e.depthOfField)==null?void 0:J.focusDistance)??h.depthOfField.focusDistance,this.renderingPipeline.depthOfField.lensSize=((ee=e.depthOfField)==null?void 0:ee.lensSize)??h.depthOfField.lensSize,this.renderingPipeline.grainEnabled=((te=e.grain)==null?void 0:te.enabled)??h.grain.enabled,this.renderingPipeline.grain.animated=((ie=e.grain)==null?void 0:ie.animated)??h.grain.animated,this.renderingPipeline.grain.intensity=((se=e.grain)==null?void 0:se.intensity)??h.grain.intensity,this.renderingPipeline.imageProcessing.contrast=((re=e.misc)==null?void 0:re.contrast)??h.misc.contrast,this.renderingPipeline.imageProcessing.exposure=((ne=e.misc)==null?void 0:ne.exposure)??h.misc.exposure,this.renderingPipeline.imageProcessing.toneMappingEnabled=((ae=e.misc)==null?void 0:ae.toneMappingEnabled)??h.misc.toneMappingEnabled,this.renderingPipeline.imageProcessing.toneMappingEnabled)switch(e.misc.toneMappingType??h.misc.toneMappingType){case"Standard":this.renderingPipeline.imageProcessing.toneMappingType=x.ImageProcessingConfiguration.TONEMAPPING_STANDARD;break;case"ACES":this.renderingPipeline.imageProcessing.toneMappingType=x.ImageProcessingConfiguration.TONEMAPPING_ACES;break}if(this.renderingPipeline.sharpenEnabled=((oe=e.sharpen)==null?void 0:oe.enabled)??h.sharpen.enabled,this.renderingPipeline.sharpen.colorAmount=((le=e.sharpen)==null?void 0:le.colorAmount)??h.sharpen.colorAmount,this.renderingPipeline.sharpen.edgeAmount=((he=e.sharpen)==null?void 0:he.edgeAmount)??h.sharpen.edgeAmount,this.renderingPipeline.imageProcessing.vignetteEnabled=((ce=e.vignette)==null?void 0:ce.enabled)??h.vignette.enabled,(de=e.vignette)!=null&&de.center?(this.renderingPipeline.imageProcessing.vignetteCenterX=e.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=e.vignette.center.y):(this.renderingPipeline.imageProcessing.vignetteCenterX=h.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=h.vignette.center.y),e.vignette)switch(((ue=e.vignette)==null?void 0:ue.blendMode)??h.vignette.blendMode){case"Multiply":this.renderingPipeline.imageProcessing.vignetteBlendMode=x.ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY;break;case"Opaque":this.renderingPipeline.imageProcessing.vignetteBlendMode=x.ImageProcessingConfiguration.VIGNETTEMODE_OPAQUE;break}(ge=e.vignette)!=null&&ge.colorRgba?this.renderingPipeline.imageProcessing.vignetteColor=new p.Color4(e.vignette.colorRgba.r,e.vignette.colorRgba.g,e.vignette.colorRgba.b,e.vignette.colorRgba.a):(me=e.vignette)!=null&&me.colorHex?this.renderingPipeline.imageProcessing.vignetteColor=p.Color4.FromHexString(e.vignette.colorHex):this.renderingPipeline.imageProcessing.vignetteColor=new p.Color4(h.vignette.colorRgba.r,h.vignette.colorRgba.g,h.vignette.colorRgba.b,h.vignette.colorRgba.a),this.renderingPipeline.imageProcessing.vignetteStretch=((pe=e.vignette)==null?void 0:pe.stretch)??h.vignette.stretch,this.renderingPipeline.imageProcessing.vignetteWeight=((be=e.vignette)==null?void 0:be.weight)??h.vignette.weight,this.renderingPipeline.prepare(),this.currentConfiguration=e}}updateColorCurve(e){const t=new 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}}Pe.GLTF2.GLTFLoader.RegisterExtension("glbPostProcessor",function(a){return new Fe(a)}),B.SceneLoader.OnPluginActivatedObservable.add(a=>{if(a.name==="gltf"){const e=a;e.transparencyAsCoverage=!0}});const R="initialScene";class _e{constructor(e){this.loadProgress=new Map([[R,0]]),this.focusLostNotified=!1,this.loadObservable=new y.Observable,this.focusLostObservable=new y.Observable,this.initializedCallbacks=[],this.isInitialized=!1,this.modelLoadEventCallbacks=[],this.modelContainers=new Map,this.plugins=[],this.configuration=new Se(e);const i=(()=>{if(!(e!=null&&e.noRender))return this.configuration.createCanvas()})(),n="1.5.6";Ce.DracoCompression.Configuration={decoder:{wasmUrl:`https://www.gstatic.com/draco/versioned/decoders/${n}/draco_wasm_wrapper_gltf.js`,wasmBinaryUrl:`https://www.gstatic.com/draco/versioned/decoders/${n}/draco_decoder_gltf.wasm`,fallbackUrl:`https://www.gstatic.com/draco/versioned/decoders/${n}/draco_decoder_gltf.js`}},i&&(i.getContext("webgl2")||i.getContext("webgl"));const r=console.log;console.log=()=>{};const s=i?new j.Engine(i,!0,{adaptToDeviceRatio:!0,limitDeviceRatio:2,premultipliedAlpha:!1,preserveDrawingBuffer:!!(e!=null&&e.backgroundImage),audioEngine:!1,stencil:this.configuration.highlights.enabled,forceSRGBBufferSupportState:!0}):new fe.NullEngine;console.log=r,s.hideLoadingUI(),window.addEventListener("resize",this.fireResizeEvent.bind(this)),this.engine=s,this.scene=new Me.Scene(s),this.camera=S.create(this.scene,this.configuration),this.renderingPipeline=new Qe(this.scene,!1,this.camera),this.scene.imageProcessingConfiguration.exposure=this.configuration.lighting.exposure,this.scene.imageProcessingConfiguration.contrast=this.configuration.lighting.contrast,this.glowLayerManager=new je(this.scene,this.configuration.emissiveGlowIntensity)}getEngineContext(){return{engine:this.engine,scene:this.scene,camera:this.camera}}registerFocusLostListener(e){this.focusLostObservable.add(e)}unregisterFocusLostListener(e){this.focusLostObservable.removeCallback(e)}registerLoadProgressListener(e){this.loadObservable.add(e),e(this.getLoadListenerEvent())}unregisterLoadProgressListener(e){this.loadObservable.removeCallback(e)}registerInitializedListener(e){this.isInitialized||!this.isInitialized&&this.initializedCallbacks.push(e)}unregisterInitializedListener(e){if(this.isInitialized)return;const t=this.initializedCallbacks.indexOf(e);t>-1&&this.initializedCallbacks.splice(t,1)}getIsInitialized(){return this.isInitialized}registerModelLoadEventListener(e){this.modelLoadEventCallbacks.push(e)}unregisterModelLoadEventListener(e){const t=this.modelLoadEventCallbacks.indexOf(e);t>-1&&this.modelLoadEventCallbacks.splice(t,1)}registerView(e){const t=e.height,i=e.width;this.engine.registerView(e),e.setAttribute("height",t.toString()),e.setAttribute("width",i.toString()),this.orbitEnabled()||this.setCameraState(L.Pan),this.reattachControls(e)}getNumViewports(){var e;return((e=this.engine.views)==null?void 0:e.length)||0}unregisterView(e){this.engine.unRegisterView(e)}shutdown(){this.plugins.forEach(e=>e.dispose(!0)),this.renderingPipeline.dispose(),this.engine&&this.engine.dispose(),window.removeEventListener("resize",this.fireResizeEvent)}getSceneInitializationProgress(){return this.loadProgress.get(R)}async initialize(e){var i,n;this.scene.clearColor=this.configuration.scene.clearColor,this.scene.environmentTexture=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),Ve(this.scene),((i=this.engine.views)==null?void 0:i.length)>=1&&this.reattachControls(this.engine.views[this.engine.views.length-1].target),this.queuedCameraAnimation&&(this.executeCameraAnimation(this.queuedCameraAnimation),this.queuedCameraAnimation=void 0),this.isInitialized=!0,await Promise.all(this.initializedCallbacks.map(r=>r())),this.initializedCallbacks=[],(n=this.configuration.options)!=null&&n.renderingPipelineConfiguration&&this.renderingPipeline.setConfiguration(this.configuration.options.renderingPipelineConfiguration),this.engine.runRenderLoop(()=>{this.engine.views&&(this.modelContainers.forEach(r=>{r.updateDynamicTextures()}),this.configuration.scene.transparentBackground&&this.engine.views.forEach(r=>{const s=this.engine.getRenderingCanvas();r.target.getContext("2d").clearRect(0,0,s.width,s.height)}),this.scene.render(),!this.camera.target.equalsWithEpsilon(this.camera.lastFocus,.1)&&!this.focusLostNotified&&(this.focusLostObservable.notifyObservers(void 0),this.focusLostNotified=!0),this.screenshotPrepareResolve&&(this.screenshotPrepareResolve(),this.screenshotPrepareResolve=void 0))}),t}executeCameraAnimation(e){if(this.getSceneInitializationProgress()!==100||!this.camera||this.scene.activeCamera!==this.camera){this.queuedCameraAnimation=e;return}ke(this.scene,this.scene.activeCamera,e)}getCameraPose(){if(this.scene&&this.camera)return{lonDeg:Math.round(this.camera.alpha*180/Math.PI),latDeg:Math.round(this.camera.beta*180/Math.PI),radius:Math.round((this.camera.radius+Number.EPSILON)*1e4)/1e4,target:{x:this.camera.target.x,y:this.camera.target.y,z:this.camera.target.z}}}setCameraPose(e){this.scene&&this.camera&&(this.camera.target=new g.Vector3(e.target.x,e.target.y,e.target.z),this.camera.radius=e.radius,this.camera.alpha=e.latDeg,this.camera.beta=e.lonDeg)}setCameraState(e){var t,i;if(!((t=this.engine)!=null&&t.views)||!((i=this.engine)!=null&&i.views[0]))throw new Error("No views attached, camera state requires a view to attach controls onto.");e===L.Orbit?this.reattachControls(this.engine.views[0].target,2):this.reattachControls(this.engine.views[0].target,0)}animateToLastCameraFocus(){return new Promise(e=>{const t=()=>{const i=this.configuration;this.camera.rerunFramingBehavior(()=>{this.focusLostNotified=!1,i.camera.limits.min.radius&&(this.camera.lowerRadiusLimit=i.camera.limits.min.radius),i.camera.limits.max.radius&&(this.camera.upperRadiusLimit=i.camera.limits.max.radius),e()})};this.scene.onAfterRenderObservable.addOnce(t)})}setAutoRotation(e){!this.configuration.camera.autoRotation.enabled||!this.camera||(e?this.camera.enableAutoRotationBehavior(this.configuration.camera.autoRotation.idleTimeMs):this.camera.disableAutoRotationBehavior())}getCurrentConfiguration(){return this.configuration.options}async renderSceneScreenshot(e,t){if(!this.camera)throw new Error("Missing product camera, cannot render screenshot!");const i=new v.ArcRotateCamera("screenshotCamera",0,0,0,g.Vector3.Zero(),this.scene);try{const n=t.latDeg*Math.PI/180,r=t.lonDeg*Math.PI/180;i.target=t.target?new g.Vector3(t.target.x,t.target.y,t.target.z):g.Vector3.Zero(),i.alpha=r,i.beta=n,i.radius=t.radius||this.camera.radius,i.minZ=.01,this.scene.render();const s=await we.Tools.CreateScreenshotUsingRenderTargetAsync(this.engine,i,e,"image/png",2,!0);return i.dispose(),s}catch{throw i.isDisposed()||i.dispose(),new Error("Failed to render screenshot")}}orbitEnabled(){const e=this.configuration;if(!e)return!0;const t=e.camera.limits.min.alpha,i=e.camera.limits.max.alpha,n=e.camera.limits.min.beta,r=e.camera.limits.max.beta;if(t===void 0||i===void 0||n===void 0||r===void 0)return!0;const s=[t,i],o=[n,r],c=s.every(u=>u===t),d=o.every(u=>u===n);return!c&&!d}fireResizeEvent(){this.getNumViewports()>0&&this.engine.resize()}setHighlights(e,t){var n;e.length===0&&((n=this.highlightLayer)==null||n.dispose(),this.highlightLayer=void 0),this.highlightLayer||(this.highlightLayer=new ve.HighlightLayer("highlights",this.scene,{isStroke:!0,blurVerticalSize:.85,blurHorizontalSize:.85}),this.highlightLayer.innerGlow=!0,this.highlightLayer.outerGlow=!1),this.highlightLayer.removeAllMeshes();const i=t?new p.Color3(t[0],t[1],t[2]).toLinearSpace():void 0;e.forEach(r=>{const s=this.scene.materials.find(o=>o.name===r.name&&o.id===r.id);s&&s.getBindedMeshes().forEach(o=>{var c;return(c=this.highlightLayer)==null?void 0:c.addMesh(o,i||p.Color3.FromHexString("#fcba03"))})})}setRenderingPipelineConfiguration(e){this.renderingPipeline&&this.renderingPipeline.setConfiguration(e)}loadModel(e,t){const i=new 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"})});
|
package/package.json
CHANGED