@spiffcommerce/preview 5.3.8-rc.1 → 5.3.8-rc.3
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 +166 -170
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -5,7 +5,7 @@ import { HighlightLayer as ye } from "@babylonjs/core/Layers/highlightLayer";
|
|
|
5
5
|
import { SceneLoader as fe } from "@babylonjs/core/Loading/sceneLoader";
|
|
6
6
|
import { CubeTexture as te } from "@babylonjs/core/Materials/Textures/cubeTexture";
|
|
7
7
|
import { Color4 as b, Color3 as w } from "@babylonjs/core/Maths/math.color";
|
|
8
|
-
import { Vector3 as g, Quaternion as y, Vector2 as ie, Matrix as
|
|
8
|
+
import { Vector3 as g, Quaternion as y, Vector2 as ie, Matrix as se } from "@babylonjs/core/Maths/math.vector";
|
|
9
9
|
import { DracoCompression as Me } from "@babylonjs/core/Meshes/Compression/dracoCompression";
|
|
10
10
|
import { Observable as C } from "@babylonjs/core/Misc/observable";
|
|
11
11
|
import { Tools as xe } from "@babylonjs/core/Misc/tools";
|
|
@@ -13,7 +13,7 @@ import { Scene as Pe } from "@babylonjs/core/scene";
|
|
|
13
13
|
import { GLTF2 as Ae } from "@babylonjs/loaders/glTF";
|
|
14
14
|
import { PBRMaterial as F } from "@babylonjs/core/Materials/PBR/pbrMaterial";
|
|
15
15
|
import { MirrorTexture as Re } from "@babylonjs/core/Materials/Textures/mirrorTexture";
|
|
16
|
-
import { Color3 as Te, Vector3 as
|
|
16
|
+
import { Color3 as Te, Vector3 as ne, Plane as Ee } from "@babylonjs/core/Maths/math";
|
|
17
17
|
import { ReflectionProbe as Oe } from "@babylonjs/core/Probes/reflectionProbe";
|
|
18
18
|
import { GlowLayer as Le } from "@babylonjs/core/Layers/glowLayer";
|
|
19
19
|
import { ActionManager as R } from "@babylonjs/core/Actions/actionManager";
|
|
@@ -24,10 +24,10 @@ import { DynamicTexture as Fe } from "@babylonjs/core/Materials/Textures/dynamic
|
|
|
24
24
|
import { Texture as Be } from "@babylonjs/core/Materials/Textures/texture";
|
|
25
25
|
import { Animation as v } from "@babylonjs/core/Animations/animation";
|
|
26
26
|
import { QuadraticEase as De, EasingFunction as ke } from "@babylonjs/core/Animations/easing";
|
|
27
|
-
import { AssetsManager as
|
|
27
|
+
import { AssetsManager as ze } from "@babylonjs/core/Misc/assetsManager";
|
|
28
28
|
import { ColorCurves as ae } from "@babylonjs/core/Materials/colorCurves";
|
|
29
29
|
import { ImageProcessingConfiguration as P } from "@babylonjs/core/Materials/imageProcessingConfiguration";
|
|
30
|
-
import { DefaultRenderingPipeline as
|
|
30
|
+
import { DefaultRenderingPipeline as Ve } from "@babylonjs/core/PostProcesses/RenderPipeline";
|
|
31
31
|
import { DepthOfFieldEffectBlurLevel as T } from "@babylonjs/core/PostProcesses/depthOfFieldEffect";
|
|
32
32
|
import "@babylonjs/core/Rendering/depthRendererSceneComponent";
|
|
33
33
|
import "@babylonjs/core/Engines/Extensions/engine.views";
|
|
@@ -39,12 +39,12 @@ import "@babylonjs/core/Animations/animatable";
|
|
|
39
39
|
import "@babylonjs/core/Misc/screenshotTools";
|
|
40
40
|
import "@babylonjs/core/Rendering/boundingBoxRenderer";
|
|
41
41
|
import "@babylonjs/loaders/glTF/2.0/Extensions";
|
|
42
|
-
var I = /* @__PURE__ */ ((
|
|
42
|
+
var I = /* @__PURE__ */ ((s) => (s[s.Orbit = 0] = "Orbit", s[s.Pan = 1] = "Pan", s))(I || {}), S = /* @__PURE__ */ ((s) => (s.None = "None", s.RemoveWhenSelected = "RemoveWhenSelected", s.ApplyWhenSelected = "ApplyWhenSelected", s))(S || {});
|
|
43
43
|
class oe {
|
|
44
44
|
constructor(e) {
|
|
45
45
|
this.getSceneClearColor = () => {
|
|
46
|
-
var i,
|
|
47
|
-
const t = (i = this.customOptions) != null && i.transparentBackground || (
|
|
46
|
+
var i, n, a, o;
|
|
47
|
+
const t = (i = this.customOptions) != null && i.transparentBackground || (n = this.customOptions) != null && n.backgroundImage ? 0 : 1;
|
|
48
48
|
if (this.customOptions && ((a = this.customOptions) != null && a.transparentBackground) || (o = this.customOptions) != null && o.backgroundImage)
|
|
49
49
|
return new b(0, 0, 0, t).toLinearSpace();
|
|
50
50
|
if (this.customOptions && this.customOptions.backgroundColor) {
|
|
@@ -60,11 +60,11 @@ class oe {
|
|
|
60
60
|
}
|
|
61
61
|
return new b(0.98, 0.98, 0.98, t).toLinearSpace();
|
|
62
62
|
}, this.highlightColorFromConfig = () => this.customOptions && this.customOptions.highlightColor ? this.hexToColor4(this.customOptions.highlightColor) : new b(0.98, 0.98, 0.98, 1).toLinearSpace(), this.hexToColor4 = (t, i = 1) => {
|
|
63
|
-
const
|
|
63
|
+
const n = w.FromHexString(t);
|
|
64
64
|
return new b(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
n.r,
|
|
66
|
+
n.g,
|
|
67
|
+
n.b,
|
|
68
68
|
i
|
|
69
69
|
).toLinearSpace();
|
|
70
70
|
}, this.customOptions = e;
|
|
@@ -80,13 +80,13 @@ class oe {
|
|
|
80
80
|
* Configuration related to the scene
|
|
81
81
|
*/
|
|
82
82
|
get scene() {
|
|
83
|
-
var e, t, i,
|
|
83
|
+
var e, t, i, n, a;
|
|
84
84
|
return {
|
|
85
85
|
clearColor: this.getSceneClearColor(),
|
|
86
86
|
transparentBackground: ((e = this.customOptions) == null ? void 0 : e.transparentBackground) || ((t = this.customOptions) == null ? void 0 : t.backgroundImage),
|
|
87
87
|
environment: {
|
|
88
88
|
file: ((i = this.customOptions) == null ? void 0 : i.environmentFile) ?? "assets/model-viewer/default.env",
|
|
89
|
-
intensity: ((
|
|
89
|
+
intensity: ((n = this.customOptions) == null ? void 0 : n.environmentIntensity) ?? 1,
|
|
90
90
|
rotationY: (((a = this.customOptions) == null ? void 0 : a.environmentRotationY) ?? 0) * (Math.PI / 180)
|
|
91
91
|
// Convert to radians
|
|
92
92
|
}
|
|
@@ -96,7 +96,7 @@ class oe {
|
|
|
96
96
|
* Configuration related to the camera used to view and interact with the scene.
|
|
97
97
|
*/
|
|
98
98
|
get camera() {
|
|
99
|
-
var e, t, i,
|
|
99
|
+
var e, t, i, n, a, o, r, l, d, h, u, m, p;
|
|
100
100
|
return {
|
|
101
101
|
autoOrientation: ((e = this.customOptions) == null ? void 0 : e.disableAutomaticOrientation) ?? !0,
|
|
102
102
|
autoRotation: {
|
|
@@ -105,7 +105,7 @@ class oe {
|
|
|
105
105
|
},
|
|
106
106
|
limits: {
|
|
107
107
|
min: {
|
|
108
|
-
alpha: (
|
|
108
|
+
alpha: (n = this.customOptions) != null && n.lowerAlphaLimitDeg ? ((a = this.customOptions) == null ? void 0 : a.lowerAlphaLimitDeg) * Math.PI / 180 : void 0,
|
|
109
109
|
beta: (o = this.customOptions) != null && o.lowerBetaLimitDeg ? ((r = this.customOptions) == null ? void 0 : r.lowerBetaLimitDeg) * Math.PI / 180 : void 0,
|
|
110
110
|
radius: (l = this.customOptions) == null ? void 0 : l.minZoomOverride
|
|
111
111
|
},
|
|
@@ -129,10 +129,10 @@ class oe {
|
|
|
129
129
|
};
|
|
130
130
|
}
|
|
131
131
|
get lighting() {
|
|
132
|
-
var e, t, i,
|
|
132
|
+
var e, t, i, n;
|
|
133
133
|
return {
|
|
134
134
|
exposure: ((t = (e = this.customOptions) == null ? void 0 : e.lighting) == null ? void 0 : t.exposure) ?? 0.9,
|
|
135
|
-
contrast: ((
|
|
135
|
+
contrast: ((n = (i = this.customOptions) == null ? void 0 : i.lighting) == null ? void 0 : n.contrast) ?? 1.6
|
|
136
136
|
};
|
|
137
137
|
}
|
|
138
138
|
get emissiveGlowIntensity() {
|
|
@@ -181,7 +181,7 @@ class x {
|
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
|
-
const
|
|
184
|
+
const qe = 128, c = {
|
|
185
185
|
antiAliasing: {
|
|
186
186
|
samples: 4,
|
|
187
187
|
fxaaEnabled: !1
|
|
@@ -253,11 +253,11 @@ class Ne {
|
|
|
253
253
|
return this.loader.loadNodeAsync(
|
|
254
254
|
e,
|
|
255
255
|
t,
|
|
256
|
-
function(
|
|
256
|
+
function(n) {
|
|
257
257
|
t.extras && Object.keys(t.extras).forEach((a) => {
|
|
258
258
|
const o = t.extras[a];
|
|
259
|
-
|
|
260
|
-
}), i(
|
|
259
|
+
n.metadata[a] = o;
|
|
260
|
+
}), i(n);
|
|
261
261
|
}
|
|
262
262
|
);
|
|
263
263
|
}
|
|
@@ -340,8 +340,8 @@ class Ne {
|
|
|
340
340
|
"Mirror attribute specified on: " + a.name + "But no normals exist to generate a mirror from!"
|
|
341
341
|
);
|
|
342
342
|
a.computeWorldMatrix(!0);
|
|
343
|
-
const h = a.getWorldMatrix(), u =
|
|
344
|
-
new
|
|
343
|
+
const h = a.getWorldMatrix(), u = ne.TransformNormal(
|
|
344
|
+
new ne(d[0], d[1], d[2]),
|
|
345
345
|
h
|
|
346
346
|
).normalize(), m = Ee.FromPositionAndNormal(
|
|
347
347
|
a.position,
|
|
@@ -349,17 +349,17 @@ class Ne {
|
|
|
349
349
|
);
|
|
350
350
|
l.mirrorPlane = m, l.level = o, r.reflectionTexture = l;
|
|
351
351
|
}
|
|
352
|
-
function
|
|
352
|
+
function n(a) {
|
|
353
353
|
const o = a.material, r = new Oe(
|
|
354
354
|
"probe-" + o.name,
|
|
355
|
-
|
|
355
|
+
qe,
|
|
356
356
|
e
|
|
357
357
|
);
|
|
358
358
|
r.attachToMesh(a), r.renderList && r.renderList.push(...t(e)), o.reflectionTexture = r.cubeTexture;
|
|
359
359
|
}
|
|
360
360
|
e.meshes.forEach((a) => {
|
|
361
361
|
const o = a.metadata;
|
|
362
|
-
o && (o.mirrorTexture && i(a, o.mirrorTexture), o.reflectionProbe &&
|
|
362
|
+
o && (o.mirrorTexture && i(a, o.mirrorTexture), o.reflectionProbe && n(a));
|
|
363
363
|
});
|
|
364
364
|
}
|
|
365
365
|
}
|
|
@@ -386,24 +386,24 @@ class Ge {
|
|
|
386
386
|
}
|
|
387
387
|
}
|
|
388
388
|
const le = /* @__PURE__ */ new Map();
|
|
389
|
-
async function be(
|
|
390
|
-
const i = le.get(
|
|
389
|
+
async function be(s, e, t) {
|
|
390
|
+
const i = le.get(s);
|
|
391
391
|
if (i && i.scene.uid === e.uid)
|
|
392
392
|
return i;
|
|
393
393
|
{
|
|
394
|
-
const
|
|
395
|
-
|
|
394
|
+
const n = await fe.LoadAssetContainerAsync(
|
|
395
|
+
s,
|
|
396
396
|
void 0,
|
|
397
397
|
e,
|
|
398
398
|
t
|
|
399
399
|
);
|
|
400
|
-
return le.set(
|
|
400
|
+
return le.set(s, n), n;
|
|
401
401
|
}
|
|
402
402
|
}
|
|
403
|
-
function He(
|
|
403
|
+
function He(s, e, t, i, n = "") {
|
|
404
404
|
t.forEach((a) => {
|
|
405
405
|
const o = a.getID(), r = a.getName(), l = x.getDynamicTextureResolution();
|
|
406
|
-
|
|
406
|
+
s.filter((h) => h.name === n + r).forEach((h) => {
|
|
407
407
|
const u = i.get(o), m = !1;
|
|
408
408
|
if (u)
|
|
409
409
|
he(h, u), u.update(m);
|
|
@@ -423,38 +423,38 @@ function He(n, e, t, i, s = "") {
|
|
|
423
423
|
});
|
|
424
424
|
});
|
|
425
425
|
}
|
|
426
|
-
function _e(
|
|
427
|
-
const
|
|
428
|
-
|
|
426
|
+
function _e(s, e, t, i) {
|
|
427
|
+
const n = new Fe(
|
|
428
|
+
s,
|
|
429
429
|
{ width: t, height: i },
|
|
430
430
|
e,
|
|
431
431
|
x.shouldMipMap(),
|
|
432
432
|
Be.TRILINEAR_SAMPLINGMODE,
|
|
433
433
|
pe.TEXTUREFORMAT_RGBA
|
|
434
|
-
), a =
|
|
435
|
-
return a && (a.fillStyle = "#f5f5f5", a.fillRect(0, 0, t, i),
|
|
434
|
+
), a = n.getContext();
|
|
435
|
+
return a && (a.fillStyle = "#f5f5f5", a.fillRect(0, 0, t, i), n.update()), n;
|
|
436
436
|
}
|
|
437
|
-
function he(
|
|
438
|
-
if (
|
|
439
|
-
const t =
|
|
437
|
+
function he(s, e) {
|
|
438
|
+
if (s instanceof F) {
|
|
439
|
+
const t = s, i = t.albedoTexture;
|
|
440
440
|
i ? (e.wrapU = i.wrapU, e.wrapV = i.wrapV) : (e.wrapU = 1, e.wrapV = 1), t.albedoTexture = e;
|
|
441
441
|
} else {
|
|
442
|
-
const t =
|
|
442
|
+
const t = s, i = t.diffuseTexture;
|
|
443
443
|
i && (e.wrapU = i.wrapU, e.wrapV = i.wrapV), t.diffuseTexture = e;
|
|
444
444
|
}
|
|
445
445
|
}
|
|
446
446
|
function Ke() {
|
|
447
|
-
const
|
|
448
|
-
return
|
|
447
|
+
const s = () => Math.floor((1 + Math.random()) * 65536).toString(16).substring(1);
|
|
448
|
+
return s() + s() + "-" + s() + "-" + s() + "-" + s() + "-" + s() + s() + s();
|
|
449
449
|
}
|
|
450
450
|
const M = 60, ce = 1;
|
|
451
|
-
function de(
|
|
452
|
-
return
|
|
451
|
+
function de(s) {
|
|
452
|
+
return s.targetedAnimations.map((t) => t.animation.framePerSecond).reduce((t, i) => t + i, 0) / s.targetedAnimations.length || 0;
|
|
453
453
|
}
|
|
454
|
-
function We(
|
|
455
|
-
const o =
|
|
454
|
+
function We(s, e, t, i, n, a) {
|
|
455
|
+
const o = n ? s.filter((h) => h.name === n) : s;
|
|
456
456
|
if (o.length === 0) {
|
|
457
|
-
console.warn(`No animations found for name: ${
|
|
457
|
+
console.warn(`No animations found for name: ${n}`);
|
|
458
458
|
return;
|
|
459
459
|
}
|
|
460
460
|
let r = 0;
|
|
@@ -479,20 +479,20 @@ function We(n, e, t, i, s, a) {
|
|
|
479
479
|
d(h, e, ce, m, p);
|
|
480
480
|
});
|
|
481
481
|
}
|
|
482
|
-
function ve(
|
|
483
|
-
|
|
482
|
+
function ve(s) {
|
|
483
|
+
s.forEach((e) => {
|
|
484
484
|
e.stop();
|
|
485
485
|
});
|
|
486
486
|
}
|
|
487
|
-
function Ue(
|
|
488
|
-
const e =
|
|
487
|
+
function Ue(s) {
|
|
488
|
+
const e = s.animationGroups;
|
|
489
489
|
ve(e);
|
|
490
490
|
}
|
|
491
|
-
function Ye(
|
|
491
|
+
function Ye(s, e, t) {
|
|
492
492
|
return new Promise((i) => {
|
|
493
|
-
|
|
494
|
-
const
|
|
495
|
-
if (t.target && Object.keys(t.target).length > 0 &&
|
|
493
|
+
s.stopAnimation(e), e.animations = [], Math.abs(e.alpha) > 2 * Math.PI && (e.alpha = Qe(e.alpha, 0, 2 * Math.PI));
|
|
494
|
+
const n = [], a = t.target, o = 0, r = a ? 1 : 0;
|
|
495
|
+
if (t.target && Object.keys(t.target).length > 0 && n.push(
|
|
496
496
|
A(
|
|
497
497
|
"cameraTargetLerp",
|
|
498
498
|
"target",
|
|
@@ -505,7 +505,7 @@ function Ye(n, e, t) {
|
|
|
505
505
|
v.ANIMATIONTYPE_VECTOR3,
|
|
506
506
|
o
|
|
507
507
|
)
|
|
508
|
-
),
|
|
508
|
+
), n.push(
|
|
509
509
|
A(
|
|
510
510
|
"cameraAlphaLerp",
|
|
511
511
|
"alpha",
|
|
@@ -514,7 +514,7 @@ function Ye(n, e, t) {
|
|
|
514
514
|
v.ANIMATIONTYPE_FLOAT,
|
|
515
515
|
r
|
|
516
516
|
)
|
|
517
|
-
),
|
|
517
|
+
), n.push(
|
|
518
518
|
A(
|
|
519
519
|
"cameraBetaLerp",
|
|
520
520
|
"beta",
|
|
@@ -525,7 +525,7 @@ function Ye(n, e, t) {
|
|
|
525
525
|
)
|
|
526
526
|
), t.radius !== void 0) {
|
|
527
527
|
const h = Math.max(0.01, t.radius);
|
|
528
|
-
|
|
528
|
+
n.push(
|
|
529
529
|
A(
|
|
530
530
|
"cameraRadiusLerp",
|
|
531
531
|
"radius",
|
|
@@ -536,9 +536,9 @@ function Ye(n, e, t) {
|
|
|
536
536
|
)
|
|
537
537
|
);
|
|
538
538
|
}
|
|
539
|
-
e.animations.push(...
|
|
539
|
+
e.animations.push(...n);
|
|
540
540
|
const d = e.useAutoRotationBehavior;
|
|
541
|
-
e.disableAutoRotationBehavior(),
|
|
541
|
+
e.disableAutoRotationBehavior(), s.beginAnimation(
|
|
542
542
|
e,
|
|
543
543
|
0,
|
|
544
544
|
a ? M * 2 : M,
|
|
@@ -550,17 +550,17 @@ function Ye(n, e, t) {
|
|
|
550
550
|
);
|
|
551
551
|
});
|
|
552
552
|
}
|
|
553
|
-
function ue(
|
|
554
|
-
return
|
|
553
|
+
function ue(s) {
|
|
554
|
+
return s * Math.PI / 180;
|
|
555
555
|
}
|
|
556
|
-
function A(
|
|
556
|
+
function A(s, e, t, i, n, a = 0, o = v.ANIMATIONLOOPMODE_CONSTANT) {
|
|
557
557
|
const r = new De();
|
|
558
558
|
r.setEasingMode(ke.EASINGMODE_EASEINOUT);
|
|
559
559
|
const l = new v(
|
|
560
|
-
|
|
560
|
+
s,
|
|
561
561
|
e,
|
|
562
562
|
M,
|
|
563
|
-
|
|
563
|
+
n,
|
|
564
564
|
o
|
|
565
565
|
), d = [];
|
|
566
566
|
return a > 0 && d.push({ frame: 0, value: t }), d.push({ frame: M * a, value: t }), d.push({
|
|
@@ -568,8 +568,8 @@ function A(n, e, t, i, s, a = 0, o = v.ANIMATIONLOOPMODE_CONSTANT) {
|
|
|
568
568
|
value: i
|
|
569
569
|
}), l.setKeys(d), l.setEasingFunction(r), l;
|
|
570
570
|
}
|
|
571
|
-
function Qe(
|
|
572
|
-
return
|
|
571
|
+
function Qe(s, e, t) {
|
|
572
|
+
return s < e ? s = t - (e - s) % (t - e) : s = e + (s - e) % (t - e);
|
|
573
573
|
}
|
|
574
574
|
const Ze = {
|
|
575
575
|
albedoTexture: "albedoMap",
|
|
@@ -581,7 +581,7 @@ const Ze = {
|
|
|
581
581
|
refractionTexture: "refractionMap",
|
|
582
582
|
reflectionTexture: "reflectionMap"
|
|
583
583
|
};
|
|
584
|
-
function $e(
|
|
584
|
+
function $e(s, e, t, i) {
|
|
585
585
|
[
|
|
586
586
|
"albedoTexture",
|
|
587
587
|
"bumpTexture",
|
|
@@ -594,46 +594,46 @@ function $e(n, e, t, i) {
|
|
|
594
594
|
].forEach((a) => {
|
|
595
595
|
je(
|
|
596
596
|
a,
|
|
597
|
-
|
|
597
|
+
s,
|
|
598
598
|
e,
|
|
599
599
|
t,
|
|
600
600
|
i
|
|
601
601
|
);
|
|
602
|
-
}), et(
|
|
602
|
+
}), et(s, e);
|
|
603
603
|
}
|
|
604
|
-
function je(
|
|
605
|
-
const a = Ze[
|
|
604
|
+
function je(s, e, t, i, n) {
|
|
605
|
+
const a = Ze[s];
|
|
606
606
|
if (!a)
|
|
607
607
|
throw new Error("Unexpected texture name encountered.");
|
|
608
608
|
const o = e[a], r = o == null ? void 0 : o.fileLink;
|
|
609
|
-
r ?
|
|
610
|
-
|
|
609
|
+
r ? s === "reflectionTexture" ? r.endsWith(".env") || r.endsWith(".dds") ? i.addCubeTextureTask(
|
|
610
|
+
s,
|
|
611
611
|
r,
|
|
612
612
|
void 0,
|
|
613
613
|
!1,
|
|
614
614
|
void 0,
|
|
615
615
|
!0
|
|
616
616
|
) : r.endsWith(".hdr") ? i.addHDRCubeTextureTask(
|
|
617
|
-
|
|
617
|
+
s,
|
|
618
618
|
r,
|
|
619
619
|
128,
|
|
620
620
|
!1,
|
|
621
621
|
!0,
|
|
622
622
|
!1
|
|
623
|
-
) : i.addTextureTask(
|
|
623
|
+
) : i.addTextureTask(s, r, !1, !1) : i.addTextureTask(s, r, !1, !1) : n && t[s] && (t[s] && t[s].dispose(), t[s] = null, Xe(s, t));
|
|
624
624
|
}
|
|
625
|
-
function Xe(
|
|
626
|
-
|
|
625
|
+
function Xe(s, e) {
|
|
626
|
+
s === "opacityTexture" && (e.useAlphaFromAlbedoTexture = !0), s === "metallicTexture" && (e.useRoughnessFromMetallicTextureAlpha = !1, e.useRoughnessFromMetallicTextureGreen = !1, e.useMetallnessFromMetallicTextureBlue = !1), s === "refractionTexture" && (e.subSurface.isRefractionEnabled = !1, e.subSurface.refractionIntensity = 1), s === "reflectionTexture" && (e.environmentIntensity = 1), s === "emissiveTexture" && (e.emissiveIntensity = 0, e.emissiveColor = new w(0, 0, 0), e.reflectionTexture);
|
|
627
627
|
}
|
|
628
|
-
function Je(
|
|
628
|
+
function Je(s, e, t, i) {
|
|
629
629
|
if (!e) {
|
|
630
630
|
console.error("Failed to apply texture to material: material is null.");
|
|
631
631
|
return;
|
|
632
632
|
}
|
|
633
|
-
|
|
633
|
+
s === "opacityTexture" && (e.useAlphaFromAlbedoTexture = !1), s === "metallicTexture" && (e.useRoughnessFromMetallicTextureAlpha = !1, e.useRoughnessFromMetallicTextureGreen = !0, e.useMetallnessFromMetallicTextureBlue = !0), s === "refractionTexture" && (e.subSurface.isRefractionEnabled = !0, e.subSurface.refractionIntensity = t.refractionIntensity || 1), s === "reflectionTexture" && (e.environmentIntensity = t.reflectionIntensity || 1, i.isCube && (i.rotationY = t.reflectionRotation ? t.reflectionRotation * Math.PI / 180 : 0)), e[s] = i, s === "emissiveTexture" && (e.emissiveColor = new w(1, 1, 1), e.emissiveIntensity = 1);
|
|
634
634
|
}
|
|
635
|
-
function et(
|
|
636
|
-
|
|
635
|
+
function et(s, e) {
|
|
636
|
+
s.clearCoat && (s.clearCoat === S.RemoveWhenSelected ? (e.clearCoat.isEnabled = !1, e.clearCoat.indexOfRefraction = 1.5) : s.clearCoat === S.ApplyWhenSelected && (e.clearCoat.isEnabled = !0, e.clearCoat.indexOfRefraction = s.clearCoatIOR || e.clearCoat.indexOfRefraction));
|
|
637
637
|
}
|
|
638
638
|
class tt {
|
|
639
639
|
constructor(e, t, i) {
|
|
@@ -648,7 +648,7 @@ class tt {
|
|
|
648
648
|
* instead remove material textures when they aren't defined. this is useful for material editor applications
|
|
649
649
|
* where we want to undo changes are remove effects from display.
|
|
650
650
|
*/
|
|
651
|
-
async applyMaterial(e, t, i,
|
|
651
|
+
async applyMaterial(e, t, i, n) {
|
|
652
652
|
return new Promise((a) => {
|
|
653
653
|
const o = this.materialVariantMap.get(e);
|
|
654
654
|
this.materialVariantMap.set(e, {
|
|
@@ -662,13 +662,13 @@ class tt {
|
|
|
662
662
|
a();
|
|
663
663
|
return;
|
|
664
664
|
}
|
|
665
|
-
const d = new
|
|
665
|
+
const d = new ze(this.scene);
|
|
666
666
|
d.useDefaultLoadingScreen = !1, l.forEach(
|
|
667
667
|
(h) => $e(
|
|
668
668
|
t,
|
|
669
669
|
h,
|
|
670
670
|
d,
|
|
671
|
-
|
|
671
|
+
n
|
|
672
672
|
)
|
|
673
673
|
), d.onProgress = (h, u, m) => {
|
|
674
674
|
i && i(h / u * 100, 100, m.name);
|
|
@@ -696,13 +696,13 @@ class tt {
|
|
|
696
696
|
* @param model The details for the new model, when undefined we should remove the variant associated to the given key.
|
|
697
697
|
* @param onProgress A load progress callback that can be used for loading bars and event timing.
|
|
698
698
|
*/
|
|
699
|
-
async applyModel(e, t, i,
|
|
699
|
+
async applyModel(e, t, i, n) {
|
|
700
700
|
var l, d;
|
|
701
701
|
if (i && t && !this.keysThatRemovedBaseModel.includes(e) && this.keysThatRemovedBaseModel.push(e), !i)
|
|
702
702
|
return this.keysThatRemovedBaseModel.includes(e) && this.keysThatRemovedBaseModel.length === 1 && await this.setBaseModelEnabled(!0), (l = this.loadedContainerForKey.get(e)) == null || l.dispose(), this.loadedContainerForKey.delete(e), this.loadedMaterialsForKey.delete(e), this.keysThatRemovedBaseModel = this.keysThatRemovedBaseModel.filter(
|
|
703
703
|
(h) => h !== e
|
|
704
704
|
), Promise.resolve(void 0);
|
|
705
|
-
const o = (await be(i, this.scene,
|
|
705
|
+
const o = (await be(i, this.scene, n)).instantiateModelsToScene(
|
|
706
706
|
this.renameClonedAsset,
|
|
707
707
|
!0
|
|
708
708
|
);
|
|
@@ -732,19 +732,19 @@ class tt {
|
|
|
732
732
|
}), e;
|
|
733
733
|
}
|
|
734
734
|
}
|
|
735
|
-
function we(
|
|
735
|
+
function we(s) {
|
|
736
736
|
const e = [];
|
|
737
|
-
return
|
|
737
|
+
return s.rootNodes.forEach((t) => {
|
|
738
738
|
t.getChildMeshes().forEach((i) => {
|
|
739
|
-
i.material && !e.includes(i.material) && e.push(i.material), i.subMeshes && i.subMeshes.forEach((
|
|
740
|
-
const a =
|
|
739
|
+
i.material && !e.includes(i.material) && e.push(i.material), i.subMeshes && i.subMeshes.forEach((n) => {
|
|
740
|
+
const a = n.getMaterial(!1);
|
|
741
741
|
a && !e.includes(a) && e.push(a);
|
|
742
742
|
});
|
|
743
743
|
});
|
|
744
744
|
}), e;
|
|
745
745
|
}
|
|
746
|
-
function me(
|
|
747
|
-
return
|
|
746
|
+
function me(s, e = "") {
|
|
747
|
+
return s.map((t) => ({
|
|
748
748
|
name: t.name.substring(e.length),
|
|
749
749
|
loop: t.loopAnimation,
|
|
750
750
|
to: t.to,
|
|
@@ -757,11 +757,11 @@ class it {
|
|
|
757
757
|
const {
|
|
758
758
|
enablePicking: t,
|
|
759
759
|
modelDetails: i,
|
|
760
|
-
previewService:
|
|
760
|
+
previewService: n,
|
|
761
761
|
progressHandler: a,
|
|
762
762
|
scene: o
|
|
763
763
|
} = e;
|
|
764
|
-
this.enablePicking = t, this.contextService = i.contextService, this.id = Ke(), this.previewService =
|
|
764
|
+
this.enablePicking = t, this.contextService = i.contextService, this.id = Ke(), this.previewService = n, this.scene = o, this.variantManager = new tt(
|
|
765
765
|
o,
|
|
766
766
|
this.renameClonedAsset.bind(this),
|
|
767
767
|
this.setBaseModelEnabled.bind(this)
|
|
@@ -780,7 +780,7 @@ class it {
|
|
|
780
780
|
this.importPromise = r();
|
|
781
781
|
}
|
|
782
782
|
//#region Interface implementation
|
|
783
|
-
async applyMaterialVariant(e, t, i,
|
|
783
|
+
async applyMaterialVariant(e, t, i, n) {
|
|
784
784
|
if (!this.initialized) {
|
|
785
785
|
if (this.materialReadyToLoadCallbacks.has(e)) {
|
|
786
786
|
const o = this.materialReadyToLoadCallbacks.get(e);
|
|
@@ -791,7 +791,7 @@ class it {
|
|
|
791
791
|
e,
|
|
792
792
|
t,
|
|
793
793
|
i,
|
|
794
|
-
|
|
794
|
+
n
|
|
795
795
|
)
|
|
796
796
|
);
|
|
797
797
|
} else {
|
|
@@ -807,7 +807,7 @@ class it {
|
|
|
807
807
|
e,
|
|
808
808
|
t,
|
|
809
809
|
i,
|
|
810
|
-
|
|
810
|
+
n
|
|
811
811
|
)
|
|
812
812
|
);
|
|
813
813
|
}
|
|
@@ -824,7 +824,7 @@ class it {
|
|
|
824
824
|
taskName: l
|
|
825
825
|
});
|
|
826
826
|
},
|
|
827
|
-
|
|
827
|
+
n
|
|
828
828
|
);
|
|
829
829
|
};
|
|
830
830
|
if (this.materialChangesInProgress.includes(e)) {
|
|
@@ -867,7 +867,7 @@ class it {
|
|
|
867
867
|
);
|
|
868
868
|
return;
|
|
869
869
|
}
|
|
870
|
-
const
|
|
870
|
+
const n = () => this.variantManager.applyModel(
|
|
871
871
|
e,
|
|
872
872
|
i,
|
|
873
873
|
t == null ? void 0 : t.model,
|
|
@@ -879,12 +879,12 @@ class it {
|
|
|
879
879
|
}
|
|
880
880
|
);
|
|
881
881
|
if (this.modelChangesInProgress.includes(e)) {
|
|
882
|
-
this.queuedModelChanges.set(e,
|
|
882
|
+
this.queuedModelChanges.set(e, n);
|
|
883
883
|
return;
|
|
884
884
|
}
|
|
885
885
|
const o = await (async () => {
|
|
886
886
|
this.modelChangesInProgress.push(e);
|
|
887
|
-
let r = await
|
|
887
|
+
let r = await n();
|
|
888
888
|
if (this.queuedModelChanges.has(e)) {
|
|
889
889
|
const l = this.queuedModelChanges.get(e);
|
|
890
890
|
if (!l)
|
|
@@ -910,7 +910,7 @@ class it {
|
|
|
910
910
|
let t = () => {
|
|
911
911
|
};
|
|
912
912
|
const i = async () => {
|
|
913
|
-
this.isExecutingAnimation = !0, await new Promise((
|
|
913
|
+
this.isExecutingAnimation = !0, await new Promise((n) => {
|
|
914
914
|
We(
|
|
915
915
|
[
|
|
916
916
|
...this.modelInstance.animationGroups,
|
|
@@ -920,12 +920,12 @@ class it {
|
|
|
920
920
|
e.to,
|
|
921
921
|
e.from,
|
|
922
922
|
e.name ? this.renameClonedAsset(e.name) : void 0,
|
|
923
|
-
|
|
923
|
+
n
|
|
924
924
|
);
|
|
925
925
|
}), this.isExecutingAnimation = !1, this.queuedAnimationFunction && this.queuedAnimationFunction(), this.queuedAnimationFunction = void 0, t();
|
|
926
926
|
};
|
|
927
|
-
return this.isExecutingAnimation ? (this.queuedAnimationFunction = i, new Promise((
|
|
928
|
-
t =
|
|
927
|
+
return this.isExecutingAnimation ? (this.queuedAnimationFunction = i, new Promise((n) => {
|
|
928
|
+
t = n;
|
|
929
929
|
})) : i();
|
|
930
930
|
}
|
|
931
931
|
getAnimations(e) {
|
|
@@ -1003,8 +1003,8 @@ class it {
|
|
|
1003
1003
|
e.rootNodes.forEach((t) => {
|
|
1004
1004
|
t.getChildMeshes(!1).forEach((i) => {
|
|
1005
1005
|
i.name === "targetcube_t" || i.name === "backgroundShell" || (i.actionManager || (i.actionManager = new R(this.scene)), i.actionManager.registerAction(
|
|
1006
|
-
new re(R.OnPointerOverTrigger, (
|
|
1007
|
-
|
|
1006
|
+
new re(R.OnPointerOverTrigger, (n) => {
|
|
1007
|
+
n.meshUnderPointer && i.material && this.materialSelectedObservable.notifyObservers({
|
|
1008
1008
|
id: i.material.id,
|
|
1009
1009
|
name: this.stripIdFromName(i.material.name)
|
|
1010
1010
|
});
|
|
@@ -1048,11 +1048,11 @@ class it {
|
|
|
1048
1048
|
throw new Error(
|
|
1049
1049
|
"Transform disposed! This should never happen unless there is a race condition present!"
|
|
1050
1050
|
);
|
|
1051
|
-
const t = this.transformRoot.position, i = this.transformRoot.rotationQuaternion,
|
|
1051
|
+
const t = this.transformRoot.position, i = this.transformRoot.rotationQuaternion, n = this.transformRoot.scaling;
|
|
1052
1052
|
this.transformRoot.position = g.Zero(), this.transformRoot.rotationQuaternion = y.Identity(), this.transformRoot.scaling = g.One();
|
|
1053
1053
|
for (const o of e.rootNodes)
|
|
1054
1054
|
o.parent = this.transformRoot;
|
|
1055
|
-
this.transformRoot.position = t, this.transformRoot.rotationQuaternion = i, this.transformRoot.scaling =
|
|
1055
|
+
this.transformRoot.position = t, this.transformRoot.rotationQuaternion = i, this.transformRoot.scaling = n, this.canvasPanels = ((a = this.contextService) == null ? void 0 : a.getAll()) || /* @__PURE__ */ new Map(), He(
|
|
1056
1056
|
this.materials.concat(this.variantManager.getAllMaterials()),
|
|
1057
1057
|
this.scene,
|
|
1058
1058
|
this.canvasPanels,
|
|
@@ -1096,8 +1096,8 @@ class it {
|
|
|
1096
1096
|
var e;
|
|
1097
1097
|
(e = this.canvasPanels) == null || e.forEach(
|
|
1098
1098
|
(t, i) => {
|
|
1099
|
-
const
|
|
1100
|
-
|
|
1099
|
+
const n = this.dynamicTextures.get(i);
|
|
1100
|
+
n && t.getStaticContextDirty() && n.isReady() && (n.update(!1), t.setStaticContextDirty(!1));
|
|
1101
1101
|
}
|
|
1102
1102
|
);
|
|
1103
1103
|
}
|
|
@@ -1127,20 +1127,17 @@ class it {
|
|
|
1127
1127
|
Array.from(this.modelReadyToLoadCallbacks.values()).map(
|
|
1128
1128
|
(e) => e()
|
|
1129
1129
|
)
|
|
1130
|
-
), this.modelReadyToLoadCallbacks.clear(),
|
|
1131
|
-
"ModelContainer ready, executing queued animation",
|
|
1132
|
-
this.queuedModelAnimation
|
|
1133
|
-
), this.queuedModelAnimation && (this.executeAnimation(this.queuedModelAnimation), this.queuedModelAnimation = void 0);
|
|
1130
|
+
), this.modelReadyToLoadCallbacks.clear(), this.queuedModelAnimation && (this.executeAnimation(this.queuedModelAnimation), this.queuedModelAnimation = void 0);
|
|
1134
1131
|
}
|
|
1135
1132
|
//#endregion
|
|
1136
1133
|
}
|
|
1137
1134
|
class B extends ge {
|
|
1138
|
-
constructor(e, t, i,
|
|
1135
|
+
constructor(e, t, i, n, a, o, r, l) {
|
|
1139
1136
|
super(
|
|
1140
1137
|
e,
|
|
1141
1138
|
t,
|
|
1142
1139
|
i,
|
|
1143
|
-
|
|
1140
|
+
n,
|
|
1144
1141
|
a,
|
|
1145
1142
|
o,
|
|
1146
1143
|
l
|
|
@@ -1182,14 +1179,14 @@ class B extends ge {
|
|
|
1182
1179
|
rerunFramingBehavior(e, t) {
|
|
1183
1180
|
const i = this.getFramingBehavior();
|
|
1184
1181
|
i.framingTime = t || 800;
|
|
1185
|
-
const
|
|
1182
|
+
const n = () => {
|
|
1186
1183
|
e && e();
|
|
1187
1184
|
}, a = E(this._scene), o = a.max.subtract(a.min), r = a.min.add(o.scale(0.5));
|
|
1188
1185
|
this.updateRadiusBounds(o.length() * 1.5), this.wheelPrecision = 100 / this.radius, this.panningInertia = 0, this.panningOriginTarget.copyFrom(r), this.panDenominator = o.length(), i.zoomOnBoundingInfo(
|
|
1189
1186
|
a.min,
|
|
1190
1187
|
a.max,
|
|
1191
1188
|
void 0,
|
|
1192
|
-
|
|
1189
|
+
n
|
|
1193
1190
|
), i.framingTime = 0;
|
|
1194
1191
|
}
|
|
1195
1192
|
/**
|
|
@@ -1219,7 +1216,7 @@ class B extends ge {
|
|
|
1219
1216
|
* @param assignActive If true the camera will be assigned as the active camera on the scene.
|
|
1220
1217
|
*/
|
|
1221
1218
|
static create(e, t, i) {
|
|
1222
|
-
const
|
|
1219
|
+
const n = E(e), a = n.max.subtract(n.min), o = n.min.add(a.scale(0.5)), r = new B(
|
|
1223
1220
|
"ProductCamera",
|
|
1224
1221
|
-(Math.PI / 2),
|
|
1225
1222
|
Math.PI / 2,
|
|
@@ -1233,18 +1230,18 @@ class B extends ge {
|
|
|
1233
1230
|
}), i && (e.activeCamera = r), r;
|
|
1234
1231
|
}
|
|
1235
1232
|
}
|
|
1236
|
-
function E(
|
|
1237
|
-
if (
|
|
1233
|
+
function E(s) {
|
|
1234
|
+
if (s.meshes.length === 0)
|
|
1238
1235
|
return {
|
|
1239
1236
|
min: new g(-1, -1, -1),
|
|
1240
1237
|
max: new g(1, 1, 1)
|
|
1241
1238
|
};
|
|
1242
|
-
const e =
|
|
1243
|
-
return
|
|
1239
|
+
const e = s.meshes.filter((t) => t.name.toLowerCase().endsWith("_t") || t.name.toLowerCase().includes("_t_"));
|
|
1240
|
+
return s.getWorldExtends((t) => t.isVisible && t.isEnabled() && (e.length === 0 || e.includes(t)));
|
|
1244
1241
|
}
|
|
1245
|
-
class
|
|
1242
|
+
class st {
|
|
1246
1243
|
constructor(e, t = !1, i = void 0) {
|
|
1247
|
-
this.renderingPipeline = new
|
|
1244
|
+
this.renderingPipeline = new Ve(
|
|
1248
1245
|
"default",
|
|
1249
1246
|
t,
|
|
1250
1247
|
e,
|
|
@@ -1260,9 +1257,9 @@ class nt {
|
|
|
1260
1257
|
return this.currentConfiguration;
|
|
1261
1258
|
}
|
|
1262
1259
|
setConfiguration(e) {
|
|
1263
|
-
var t, i,
|
|
1260
|
+
var t, i, n, a, o, r, l, d, h, u, m, p, f, D, k, z, V, q, N, G, H, _, K, W, U, Y, Q, Z, $, j, X, J, ee;
|
|
1264
1261
|
if (this.renderingPipeline.isSupported) {
|
|
1265
|
-
if (this.renderingPipeline.samples = ((t = e.antiAliasing) == null ? void 0 : t.samples) ?? c.antiAliasing.samples, this.renderingPipeline.fxaaEnabled = ((i = e.antiAliasing) == null ? void 0 : i.fxaaEnabled) ?? c.antiAliasing.fxaaEnabled, this.renderingPipeline.bloomEnabled = ((
|
|
1262
|
+
if (this.renderingPipeline.samples = ((t = e.antiAliasing) == null ? void 0 : t.samples) ?? c.antiAliasing.samples, this.renderingPipeline.fxaaEnabled = ((i = e.antiAliasing) == null ? void 0 : i.fxaaEnabled) ?? c.antiAliasing.fxaaEnabled, this.renderingPipeline.bloomEnabled = ((n = e.bloom) == null ? void 0 : n.enabled) ?? c.bloom.enabled, this.renderingPipeline.bloomKernel = ((a = e.bloom) == null ? void 0 : a.kernel) ?? c.bloom.kernel, this.renderingPipeline.bloomScale = ((o = e.bloom) == null ? void 0 : o.scale) ?? c.bloom.scale, this.renderingPipeline.bloomThreshold = ((r = e.bloom) == null ? void 0 : r.threshold) ?? c.bloom.threshold, this.renderingPipeline.bloomWeight = ((l = e.bloom) == null ? void 0 : l.weight) ?? c.bloom.weight, this.renderingPipeline.chromaticAberrationEnabled = ((d = e.chromaticAberration) == null ? void 0 : d.enabled) ?? c.chromaticAberration.enabled, this.renderingPipeline.chromaticAberration.aberrationAmount = ((h = e.chromaticAberration) == null ? void 0 : h.aberrationAmount) ?? c.chromaticAberration.aberrationAmount, this.renderingPipeline.chromaticAberration.radialIntensity = ((u = e.chromaticAberration) == null ? void 0 : u.radialIntensity) ?? c.chromaticAberration.radialIntensity, this.renderingPipeline.chromaticAberration.direction = (m = e.chromaticAberration) != null && m.direction ? new ie(
|
|
1266
1263
|
e.chromaticAberration.direction.x,
|
|
1267
1264
|
e.chromaticAberration.direction.y
|
|
1268
1265
|
) : new ie(
|
|
@@ -1280,7 +1277,7 @@ class nt {
|
|
|
1280
1277
|
this.renderingPipeline.depthOfFieldBlurLevel = T.High;
|
|
1281
1278
|
break;
|
|
1282
1279
|
}
|
|
1283
|
-
if (this.renderingPipeline.depthOfField.focalLength = ((D = e.depthOfField) == null ? void 0 : D.focalLength) ?? c.depthOfField.focalLength, this.renderingPipeline.depthOfField.fStop = ((k = e.depthOfField) == null ? void 0 : k.fStop) ?? c.depthOfField.fStop, this.renderingPipeline.depthOfField.focusDistance = ((
|
|
1280
|
+
if (this.renderingPipeline.depthOfField.focalLength = ((D = e.depthOfField) == null ? void 0 : D.focalLength) ?? c.depthOfField.focalLength, this.renderingPipeline.depthOfField.fStop = ((k = e.depthOfField) == null ? void 0 : k.fStop) ?? c.depthOfField.fStop, this.renderingPipeline.depthOfField.focusDistance = ((z = e.depthOfField) == null ? void 0 : z.focusDistance) ?? c.depthOfField.focusDistance, this.renderingPipeline.depthOfField.lensSize = ((V = e.depthOfField) == null ? void 0 : V.lensSize) ?? c.depthOfField.lensSize, this.renderingPipeline.grainEnabled = ((q = e.grain) == null ? void 0 : q.enabled) ?? c.grain.enabled, this.renderingPipeline.grain.animated = ((N = e.grain) == null ? void 0 : N.animated) ?? c.grain.animated, this.renderingPipeline.grain.intensity = ((G = e.grain) == null ? void 0 : G.intensity) ?? c.grain.intensity, this.renderingPipeline.imageProcessing.contrast = ((H = e.misc) == null ? void 0 : H.contrast) ?? c.misc.contrast, this.renderingPipeline.imageProcessing.exposure = ((_ = e.misc) == null ? void 0 : _.exposure) ?? c.misc.exposure, this.renderingPipeline.imageProcessing.toneMappingEnabled = ((K = e.misc) == null ? void 0 : K.toneMappingEnabled) ?? c.misc.toneMappingEnabled, this.renderingPipeline.imageProcessing.toneMappingEnabled)
|
|
1284
1281
|
switch (e.misc.toneMappingType ?? c.misc.toneMappingType) {
|
|
1285
1282
|
case "Standard":
|
|
1286
1283
|
this.renderingPipeline.imageProcessing.toneMappingType = P.TONEMAPPING_STANDARD;
|
|
@@ -1316,20 +1313,20 @@ class nt {
|
|
|
1316
1313
|
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;
|
|
1317
1314
|
}
|
|
1318
1315
|
}
|
|
1319
|
-
Ae.GLTFLoader.RegisterExtension("glbPostProcessor", function(
|
|
1320
|
-
return new Ne(
|
|
1316
|
+
Ae.GLTFLoader.RegisterExtension("glbPostProcessor", function(s) {
|
|
1317
|
+
return new Ne(s);
|
|
1321
1318
|
});
|
|
1322
|
-
fe.OnPluginActivatedObservable.add((
|
|
1323
|
-
if (
|
|
1324
|
-
const e =
|
|
1319
|
+
fe.OnPluginActivatedObservable.add((s) => {
|
|
1320
|
+
if (s.name === "gltf") {
|
|
1321
|
+
const e = s;
|
|
1325
1322
|
e.transparencyAsCoverage = !0;
|
|
1326
1323
|
}
|
|
1327
1324
|
});
|
|
1328
|
-
function O(
|
|
1329
|
-
return new g(
|
|
1325
|
+
function O(s) {
|
|
1326
|
+
return new g(s.x, s.y, s.z);
|
|
1330
1327
|
}
|
|
1331
|
-
function L(
|
|
1332
|
-
return { x:
|
|
1328
|
+
function L(s) {
|
|
1329
|
+
return { x: s.x, y: s.y, z: s.z };
|
|
1333
1330
|
}
|
|
1334
1331
|
class Wt {
|
|
1335
1332
|
constructor(e) {
|
|
@@ -1342,12 +1339,12 @@ class Wt {
|
|
|
1342
1339
|
const i = (() => {
|
|
1343
1340
|
if (!(e != null && e.noRender))
|
|
1344
1341
|
return this.configuration.createCanvas();
|
|
1345
|
-
})(),
|
|
1342
|
+
})(), n = "1.5.6";
|
|
1346
1343
|
Me.Configuration = {
|
|
1347
1344
|
decoder: {
|
|
1348
|
-
wasmUrl: `https://www.gstatic.com/draco/versioned/decoders/${
|
|
1349
|
-
wasmBinaryUrl: `https://www.gstatic.com/draco/versioned/decoders/${
|
|
1350
|
-
fallbackUrl: `https://www.gstatic.com/draco/versioned/decoders/${
|
|
1345
|
+
wasmUrl: `https://www.gstatic.com/draco/versioned/decoders/${n}/draco_wasm_wrapper_gltf.js`,
|
|
1346
|
+
wasmBinaryUrl: `https://www.gstatic.com/draco/versioned/decoders/${n}/draco_decoder_gltf.wasm`,
|
|
1347
|
+
fallbackUrl: `https://www.gstatic.com/draco/versioned/decoders/${n}/draco_decoder_gltf.js`
|
|
1351
1348
|
}
|
|
1352
1349
|
}, i && (i.getContext("webgl2") || i.getContext("webgl"));
|
|
1353
1350
|
const a = console.log;
|
|
@@ -1362,7 +1359,7 @@ class Wt {
|
|
|
1362
1359
|
stencil: this.configuration.highlights.enabled,
|
|
1363
1360
|
forceSRGBBufferSupportState: !0
|
|
1364
1361
|
}) : new Ce();
|
|
1365
|
-
console.log = a, o.hideLoadingUI(), window.addEventListener("resize", this.fireResizeEvent.bind(this)), this.engine = o, this.scene = new Pe(o), this.scene.autoClear = !0, this.scene.autoClearDepthAndStencil = !0, this.camera = B.create(this.scene, this.configuration), this.scene.activeCamera = this.camera, this.renderingPipeline = new
|
|
1362
|
+
console.log = a, o.hideLoadingUI(), window.addEventListener("resize", this.fireResizeEvent.bind(this)), this.engine = o, this.scene = new Pe(o), this.scene.autoClear = !0, this.scene.autoClearDepthAndStencil = !0, this.camera = B.create(this.scene, this.configuration), this.scene.activeCamera = this.camera, this.renderingPipeline = new st(
|
|
1366
1363
|
this.scene,
|
|
1367
1364
|
!1,
|
|
1368
1365
|
this.camera
|
|
@@ -1423,7 +1420,7 @@ class Wt {
|
|
|
1423
1420
|
this.plugins.forEach((e) => e.dispose(!0)), this.renderingPipeline.dispose(), this.engine && this.engine.dispose(), window.removeEventListener("resize", this.fireResizeEvent);
|
|
1424
1421
|
}
|
|
1425
1422
|
executeCameraAnimation(e) {
|
|
1426
|
-
if (!this.camera || this.scene.activeCamera !== this.camera)
|
|
1423
|
+
if (!this.camera || this.scene.activeCamera !== this.camera || this.getAllModels().length === 0 || !this.getAllModels().some((n) => n.getIsInitialized()))
|
|
1427
1424
|
return this.queuedCameraAnimation = e, Promise.resolve();
|
|
1428
1425
|
let t = () => {
|
|
1429
1426
|
};
|
|
@@ -1434,8 +1431,8 @@ class Wt {
|
|
|
1434
1431
|
e
|
|
1435
1432
|
), this.isAnimatingCamera = !1, this.queuedAnimationFunction && this.queuedAnimationFunction(), this.queuedAnimationFunction = void 0, t();
|
|
1436
1433
|
};
|
|
1437
|
-
return this.isAnimatingCamera ? (this.queuedAnimationFunction = i, new Promise((
|
|
1438
|
-
t =
|
|
1434
|
+
return this.isAnimatingCamera ? (this.queuedAnimationFunction = i, new Promise((n) => {
|
|
1435
|
+
t = n;
|
|
1439
1436
|
})) : i();
|
|
1440
1437
|
}
|
|
1441
1438
|
getCameraPose() {
|
|
@@ -1471,13 +1468,13 @@ class Wt {
|
|
|
1471
1468
|
};
|
|
1472
1469
|
const t = async () => {
|
|
1473
1470
|
this.isAnimatingCamera = !0, await new Promise((i) => {
|
|
1474
|
-
const
|
|
1471
|
+
const n = () => {
|
|
1475
1472
|
const a = this.configuration;
|
|
1476
1473
|
this.camera.rerunFramingBehavior(() => {
|
|
1477
1474
|
this.focusLostNotified = !1, a.camera.limits.min.radius && (this.camera.lowerRadiusLimit = a.camera.limits.min.radius), a.camera.limits.max.radius && (this.camera.upperRadiusLimit = a.camera.limits.max.radius), i();
|
|
1478
1475
|
});
|
|
1479
1476
|
};
|
|
1480
|
-
this.scene.onAfterRenderObservable.addOnce(
|
|
1477
|
+
this.scene.onAfterRenderObservable.addOnce(n);
|
|
1481
1478
|
}), this.isAnimatingCamera = !1, this.queuedAnimationFunction && this.queuedAnimationFunction(), this.queuedAnimationFunction = void 0, e();
|
|
1482
1479
|
};
|
|
1483
1480
|
return this.isAnimatingCamera ? (this.queuedAnimationFunction = t, new Promise((i) => {
|
|
@@ -1504,8 +1501,8 @@ class Wt {
|
|
|
1504
1501
|
this.scene
|
|
1505
1502
|
);
|
|
1506
1503
|
try {
|
|
1507
|
-
const
|
|
1508
|
-
i.target = t.target ? new g(t.target.x, t.target.y, t.target.z) : g.Zero(), i.alpha = a, i.beta =
|
|
1504
|
+
const n = t.latDeg * Math.PI / 180, a = t.lonDeg * Math.PI / 180;
|
|
1505
|
+
i.target = t.target ? new g(t.target.x, t.target.y, t.target.z) : g.Zero(), i.alpha = a, i.beta = n, i.radius = t.radius || this.camera.radius, i.minZ = 0.01, this.scene.render();
|
|
1509
1506
|
const o = await xe.CreateScreenshotUsingRenderTargetAsync(
|
|
1510
1507
|
this.engine,
|
|
1511
1508
|
i,
|
|
@@ -1523,18 +1520,18 @@ class Wt {
|
|
|
1523
1520
|
const e = this.configuration;
|
|
1524
1521
|
if (!e)
|
|
1525
1522
|
return !0;
|
|
1526
|
-
const t = e.camera.limits.min.alpha, i = e.camera.limits.max.alpha,
|
|
1527
|
-
if (t === void 0 || i === void 0 ||
|
|
1523
|
+
const t = e.camera.limits.min.alpha, i = e.camera.limits.max.alpha, n = e.camera.limits.min.beta, a = e.camera.limits.max.beta;
|
|
1524
|
+
if (t === void 0 || i === void 0 || n === void 0 || a === void 0)
|
|
1528
1525
|
return !0;
|
|
1529
|
-
const o = [t, i], r = [
|
|
1526
|
+
const o = [t, i], r = [n, a], l = o.every((h) => h === t), d = r.every((h) => h === n);
|
|
1530
1527
|
return !l && !d;
|
|
1531
1528
|
}
|
|
1532
1529
|
fireResizeEvent() {
|
|
1533
1530
|
this.getNumViewports() > 0 && this.engine.resize();
|
|
1534
1531
|
}
|
|
1535
1532
|
setHighlights(e, t) {
|
|
1536
|
-
var
|
|
1537
|
-
e.length === 0 && ((
|
|
1533
|
+
var n;
|
|
1534
|
+
e.length === 0 && ((n = this.highlightLayer) == null || n.dispose(), this.highlightLayer = void 0), this.highlightLayer || (this.highlightLayer = new ye("highlights", this.scene, {
|
|
1538
1535
|
isStroke: !0,
|
|
1539
1536
|
blurVerticalSize: 0.85,
|
|
1540
1537
|
blurHorizontalSize: 0.85
|
|
@@ -1567,12 +1564,11 @@ class Wt {
|
|
|
1567
1564
|
progressHandler: t
|
|
1568
1565
|
});
|
|
1569
1566
|
return i.getInitializationPromise().then(() => {
|
|
1570
|
-
this.modelContainers.size <= 1 && this.camera.rerunFramingBehavior(
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
this.setHighlights([s]);
|
|
1567
|
+
this.modelContainers.size <= 1 && this.camera.rerunFramingBehavior(() => {
|
|
1568
|
+
Ue(this.scene), this.queuedCameraAnimation && (this.executeCameraAnimation(this.queuedCameraAnimation), this.queuedCameraAnimation = void 0);
|
|
1569
|
+
}, 1);
|
|
1570
|
+
}), this.configuration.highlights.enabled && (i.registerMaterialSelectedCallback((n) => {
|
|
1571
|
+
this.setHighlights([n]);
|
|
1576
1572
|
}), i.registerMaterialDeselectedCallback(() => {
|
|
1577
1573
|
this.setHighlights([]);
|
|
1578
1574
|
})), this.modelContainers.set(i.getId(), i), this.triggerModelLoadEvent({
|
|
@@ -1595,7 +1591,7 @@ class Wt {
|
|
|
1595
1591
|
}
|
|
1596
1592
|
unregisterPlugin(e) {
|
|
1597
1593
|
const t = this.plugins.indexOf(e);
|
|
1598
|
-
t > -1 && this.plugins.splice(t, 1).forEach((
|
|
1594
|
+
t > -1 && this.plugins.splice(t, 1).forEach((n) => n.dispose(!1));
|
|
1599
1595
|
}
|
|
1600
1596
|
getGlowLayerManager() {
|
|
1601
1597
|
return this.glowLayerManager;
|
|
@@ -1613,13 +1609,13 @@ class Wt {
|
|
|
1613
1609
|
* Flips a transform around the origin.
|
|
1614
1610
|
*/
|
|
1615
1611
|
flipTransform(e, t, i) {
|
|
1616
|
-
const
|
|
1612
|
+
const n = se.Compose(
|
|
1617
1613
|
O(i || { x: 1, y: 1, z: 1 }),
|
|
1618
1614
|
y.FromEulerVector(
|
|
1619
1615
|
O(t || { x: 0, y: 0, z: 0 })
|
|
1620
1616
|
),
|
|
1621
1617
|
O(e || { x: 0, y: 0, z: 0 })
|
|
1622
|
-
), a =
|
|
1618
|
+
), a = se.RotationAxis(g.Up(), Math.PI), o = n.multiply(a), r = g.Zero(), l = y.Identity(), d = g.Zero();
|
|
1623
1619
|
return o.decompose(d, l, r), l.multiplyInPlace(y.FromEulerAngles(0, Math.PI, 0)), {
|
|
1624
1620
|
position: L(r),
|
|
1625
1621
|
rotation: L(l.toEulerAngles()),
|
|
@@ -1627,14 +1623,14 @@ class Wt {
|
|
|
1627
1623
|
};
|
|
1628
1624
|
}
|
|
1629
1625
|
updatePreviewOptions(e) {
|
|
1630
|
-
var
|
|
1626
|
+
var n;
|
|
1631
1627
|
const t = new oe(e);
|
|
1632
1628
|
this.configuration.highlights.enabled !== t.highlights.enabled && this.engine.setStencilBuffer(t.highlights.enabled), this.scene.clearColor = t.scene.clearColor;
|
|
1633
1629
|
let i = this.scene.environmentTexture;
|
|
1634
1630
|
this.configuration.scene.environment.file !== t.scene.environment.file && (i = te.CreateFromPrefilteredData(
|
|
1635
1631
|
t.scene.environment.file,
|
|
1636
1632
|
this.scene
|
|
1637
|
-
), i.rotationY = this.configuration.scene.environment.rotationY, this.scene.environmentTexture = i), i.rotationY = t.scene.environment.rotationY, this.scene.environmentIntensity = t.scene.environment.intensity, (
|
|
1633
|
+
), i.rotationY = this.configuration.scene.environment.rotationY, this.scene.environmentTexture = i), i.rotationY = t.scene.environment.rotationY, this.scene.environmentIntensity = t.scene.environment.intensity, (n = t.options) != null && n.renderingPipelineConfiguration ? this.renderingPipeline.setConfiguration(
|
|
1638
1634
|
t.options.renderingPipelineConfiguration
|
|
1639
1635
|
) : (this.scene.imageProcessingConfiguration.exposure = t.lighting.exposure, this.scene.imageProcessingConfiguration.contrast = t.lighting.contrast), this.glowLayerManager.setIntensity(t.emissiveGlowIntensity), this.configuration = t;
|
|
1640
1636
|
}
|
|
@@ -1655,7 +1651,7 @@ class Wt {
|
|
|
1655
1651
|
export {
|
|
1656
1652
|
S as MaterialEffectMode,
|
|
1657
1653
|
I as ProductCameraRig,
|
|
1658
|
-
|
|
1654
|
+
qe as REFLECTION_PROBE_RESOLUTION,
|
|
1659
1655
|
x as RenderingConfiguration,
|
|
1660
1656
|
Wt as SpiffCommerce3DPreviewService,
|
|
1661
1657
|
c as renderingPipelineDefaults
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(c,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):(c=typeof globalThis<"u"?globalThis:c||self,v(c.Preview={},c.arcRotateCamera,c.engine,c.nullEngine,c.highlightLayer,c.sceneLoader,c.cubeTexture,c.math_color,c.math_vector,c.dracoCompression,c.observable,c.tools,c.scene,c.glTF,c.pbrMaterial,c.mirrorTexture,c.math,c.reflectionProbe,c.glowLayer,c.actionManager,c.directActions,c.mesh,c.transformNode,c.dynamicTexture,c.texture,c.animation,c.easing,c.assetsManager,c.colorCurves,c.imageProcessingConfiguration,c.RenderPipeline,c.depthOfFieldEffect))})(this,function(c,v,j,ve,we,D,V,b,m,Ce,M,Me,xe,Pe,L,Ae,P,Te,Re,O,k,Ee,Le,Oe,Ie,w,z,Se,N,A,Fe,I){"use strict";var T=(s=>(s[s.Orbit=0]="Orbit",s[s.Pan=1]="Pan",s))(T||{}),R=(s=>(s.None="None",s.RemoveWhenSelected="RemoveWhenSelected",s.ApplyWhenSelected="ApplyWhenSelected",s))(R||{});class G{constructor(e){this.getSceneClearColor=()=>{var i,n,a,o;const t=(i=this.customOptions)!=null&&i.transparentBackground||(n=this.customOptions)!=null&&n.backgroundImage?0:1;if(this.customOptions&&((a=this.customOptions)!=null&&a.transparentBackground)||(o=this.customOptions)!=null&&o.backgroundImage)return new b.Color4(0,0,0,t).toLinearSpace();if(this.customOptions&&this.customOptions.backgroundColor){const r=b.Color3.FromHexString(this.customOptions.backgroundColor);return new b.Color4(r.r,r.g,r.b,t).toLinearSpace()}return new b.Color4(.98,.98,.98,t).toLinearSpace()},this.highlightColorFromConfig=()=>this.customOptions&&this.customOptions.highlightColor?this.hexToColor4(this.customOptions.highlightColor):new b.Color4(.98,.98,.98,1).toLinearSpace(),this.hexToColor4=(t,i=1)=>{const n=b.Color3.FromHexString(t);return new b.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,n,a;return{clearColor:this.getSceneClearColor(),transparentBackground:((e=this.customOptions)==null?void 0:e.transparentBackground)||((t=this.customOptions)==null?void 0:t.backgroundImage),environment:{file:((i=this.customOptions)==null?void 0:i.environmentFile)??"assets/model-viewer/default.env",intensity:((n=this.customOptions)==null?void 0:n.environmentIntensity)??1,rotationY:(((a=this.customOptions)==null?void 0:a.environmentRotationY)??0)*(Math.PI/180)}}}get camera(){var e,t,i,n,a,o,r,l,u,h,g,p,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?((a=this.customOptions)==null?void 0:a.lowerAlphaLimitDeg)*Math.PI/180:void 0,beta:(o=this.customOptions)!=null&&o.lowerBetaLimitDeg?((r=this.customOptions)==null?void 0:r.lowerBetaLimitDeg)*Math.PI/180:void 0,radius:(l=this.customOptions)==null?void 0:l.minZoomOverride},max:{alpha:(u=this.customOptions)!=null&&u.upperAlphaLimitDeg?((h=this.customOptions)==null?void 0:h.upperAlphaLimitDeg)*Math.PI/180:void 0,beta:(g=this.customOptions)!=null&&g.upperBetaLimitDeg?((p=this.customOptions)==null?void 0:p.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 C{static getDynamicTextureResolution(){return this.getIsMobile()||!C.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/window.devicePixelRatio<=480}catch{return!1}}}const H=128,d={antiAliasing:{samples:4,fxaaEnabled:!1},bloom:{enabled:!1,kernel:64,scale:.5,threshold:.9,weight:.15},chromaticAberration:{enabled:!1,aberrationAmount:30,direction:{x:0,y:0},radialIntensity:0},colorCurves:{enabled:!1},depthOfField:{enabled:!1,blurLevel:"Low",focalLength:50,focusDistance:2e3,fStop:1.4,lensSize:50},grain:{enabled:!1,animated:!1,intensity:30},misc:{contrast:1,exposure:1,toneMappingEnabled:!1,toneMappingType:"Standard"},sharpen:{enabled:!1,colorAmount:1,edgeAmount:.3},vignette:{enabled:!1,blendMode:"Multiply",cameraFov:.5,center:{x:0,y:0},colorHex:"#000000ff",colorRgba:{r:0,g:0,b:0,a:1},stretch:0,weight:1}};class Be{constructor(e){this.name="glbPostProcessor",this.enabled=!0,this.loader=e}onReady(){this.applyReflections(this.loader.babylonScene)}loadNodeAsync(e,t,i){return this.loader.loadNodeAsync(e,t,function(n){t.extras&&Object.keys(t.extras).forEach(a=>{const o=t.extras[a];n.metadata[a]=o}),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 L.PBRMaterial))){if(e.extras.sheen){const i=t;i.sheen.isEnabled=!0,i.sheen.intensity=e.extras.sheen}if(e.extras.translucency){const i=t;i.subSurface.isTranslucencyEnabled=!0,i.subSurface.translucencyIntensity=e.extras.translucency,e.extras.translucencyR&&e.extras.translucencyG&&e.extras.translucencyB&&(i.subSurface.tintColor=new P.Color3(e.extras.translucencyR,e.extras.translucencyG,e.extras.translucencyB))}if(e.extras.refractionIOR){const i=t;i.subSurface.isRefractionEnabled=!0,i.subSurface.volumeIndexOfRefraction=e.extras.refractionIOR}if(e.extras.useDepthPrePass){const i=t;i.needDepthPrePass=!0,i.forceIrradianceInFragment=!0}if(e.extras.useParallax){const i=t;i.useParallax=!0,i.useParallaxOcclusion=!0,i.parallaxScaleBias=e.extras.useParallax}}}applyReflections(e){function t(a){const o=[];return a.transformNodes.forEach(r=>{r.metadata&&r.metadata.reflective&&o.push(...r.getChildMeshes())}),a.meshes.forEach(r=>{r.metadata&&r.metadata.reflective&&!o.includes(r)&&o.push(r)}),o}function i(a,o=1){const r=a.material;if(!r)return;const l=new Ae.MirrorTexture("mirror",C.getMirrorTextureResolution(),e,!0);l.renderList=t(e);const u=a.getVerticesData("normal");if(!u)throw new Error("Mirror attribute specified on: "+a.name+"But no normals exist to generate a mirror from!");a.computeWorldMatrix(!0);const h=a.getWorldMatrix(),g=P.Vector3.TransformNormal(new P.Vector3(u[0],u[1],u[2]),h).normalize(),p=P.Plane.FromPositionAndNormal(a.position,g.scale(-1));l.mirrorPlane=p,l.level=o,r.reflectionTexture=l}function n(a){const o=a.material,r=new Te.ReflectionProbe("probe-"+o.name,H,e);r.attachToMesh(a),r.renderList&&r.renderList.push(...t(e)),o.reflectionTexture=r.cubeTexture}e.meshes.forEach(a=>{const o=a.metadata;o&&(o.mirrorTexture&&i(a,o.mirrorTexture),o.reflectionProbe&&n(a))})}}class qe{constructor(e,t){this.scene=e,this.intensity=t,this.meshCount=0}setIntensity(e){this.intensity=e,this.glowLayer&&(this.glowLayer.intensity=e)}includeMeshes(e){if(e){this.glowLayer||(this.glowLayer=new Re.GlowLayer("glow",this.scene),this.glowLayer.intensity=this.intensity);for(const t of e)this.glowLayer.hasMesh(t)||(this.glowLayer.addIncludedOnlyMesh(t),this.meshCount++)}}removeMeshes(e){if(!(!this.glowLayer||!e)){for(const t of e)this.glowLayer.hasMesh(t)&&(this.glowLayer.removeIncludedOnlyMesh(t),this.meshCount--);this.meshCount===0&&(this.glowLayer.dispose(),this.glowLayer=void 0)}}}const K=new Map;async function U(s,e,t){const i=K.get(s);if(i&&i.scene.uid===e.uid)return i;{const n=await D.SceneLoader.LoadAssetContainerAsync(s,void 0,e,t);return K.set(s,n),n}}function je(s,e,t,i,n=""){t.forEach(a=>{const o=a.getID(),r=a.getName(),l=C.getDynamicTextureResolution();s.filter(h=>h.name===n+r).forEach(h=>{const g=i.get(o),p=!1;if(g)W(h,g),g.update(p);else{const f=De(r,e,l.width,l.height);i.set(o,f),a.setStaticContext(f.getContext()),W(h,f),f.onLoadObservable.addOnce(()=>{f.update(p)})}})})}function De(s,e,t,i){const n=new Oe.DynamicTexture(s,{width:t,height:i},e,C.shouldMipMap(),Ie.Texture.TRILINEAR_SAMPLINGMODE,j.Engine.TEXTUREFORMAT_RGBA),a=n.getContext();return a&&(a.fillStyle="#f5f5f5",a.fillRect(0,0,t,i),n.update()),n}function W(s,e){if(s instanceof L.PBRMaterial){const t=s,i=t.albedoTexture;i?(e.wrapU=i.wrapU,e.wrapV=i.wrapV):(e.wrapU=1,e.wrapV=1),t.albedoTexture=e}else{const t=s,i=t.diffuseTexture;i&&(e.wrapU=i.wrapU,e.wrapV=i.wrapV),t.diffuseTexture=e}}function Ve(){const s=()=>Math.floor((1+Math.random())*65536).toString(16).substring(1);return s()+s()+"-"+s()+"-"+s()+"-"+s()+"-"+s()+s()+s()}const x=60,Q=1;function Y(s){return s.targetedAnimations.map(t=>t.animation.framePerSecond).reduce((t,i)=>t+i,0)/s.targetedAnimations.length||0}function ke(s,e,t,i,n,a){const o=n?s.filter(h=>h.name===n):s;if(o.length===0){console.warn(`No animations found for name: ${n}`);return}let r=0;const l=()=>{r++,r===o.length&&a&&a()},u=(h,g,p,f,y)=>{h.stop(),h.start(g,p,f,y),a&&(g==!1||g===void 0&&!h.loopAnimation?h.onAnimationGroupEndObservable.addOnce(()=>{l()}):h.onAnimationLoopObservable.addOnce(()=>{l()}))};if(i!==void 0&&t!==void 0&&i===t){o.forEach(h=>{const g=Y(h),p=i*g;u(h,!1,Q,p,p)});return}o.forEach(h=>{const g=Y(h),p=i!==void 0?i*g:void 0,f=t!==void 0?t*g:void 0;u(h,e,Q,p,f)})}function Z(s){s.forEach(e=>{e.stop()})}function ze(s){const e=s.animationGroups;Z(e)}function Ne(s,e,t){return new Promise(i=>{s.stopAnimation(e),e.animations=[],Math.abs(e.alpha)>2*Math.PI&&(e.alpha=Ge(e.alpha,0,2*Math.PI));const n=[],a=t.target,o=0,r=a?1:0;if(t.target&&Object.keys(t.target).length>0&&n.push(E("cameraTargetLerp","target",new m.Vector3().copyFrom(e.target),new m.Vector3(t.target.x,t.target.y,t.target.z),w.Animation.ANIMATIONTYPE_VECTOR3,o)),n.push(E("cameraAlphaLerp","alpha",e.alpha,$(t.lonDeg),w.Animation.ANIMATIONTYPE_FLOAT,r)),n.push(E("cameraBetaLerp","beta",e.beta,$(t.latDeg),w.Animation.ANIMATIONTYPE_FLOAT,r)),t.radius!==void 0){const h=Math.max(.01,t.radius);n.push(E("cameraRadiusLerp","radius",e.radius,h,w.Animation.ANIMATIONTYPE_FLOAT,r))}e.animations.push(...n);const u=e.useAutoRotationBehavior;e.disableAutoRotationBehavior(),s.beginAnimation(e,0,a?x*2:x,!1,1,()=>{e.animations=[],u&&e.enableAutoRotationBehavior(),i()})})}function $(s){return s*Math.PI/180}function E(s,e,t,i,n,a=0,o=w.Animation.ANIMATIONLOOPMODE_CONSTANT){const r=new z.QuadraticEase;r.setEasingMode(z.EasingFunction.EASINGMODE_EASEINOUT);const l=new w.Animation(s,e,x,n,o),u=[];return a>0&&u.push({frame:0,value:t}),u.push({frame:x*a,value:t}),u.push({frame:x*(a+1),value:i}),l.setKeys(u),l.setEasingFunction(r),l}function Ge(s,e,t){return s<e?s=t-(e-s)%(t-e):s=e+(s-e)%(t-e)}const He={albedoTexture:"albedoMap",bumpTexture:"normalMap",ambientTexture:"ambientMap",emissiveTexture:"emissionMap",opacityTexture:"alphaMap",metallicTexture:"metallicMap",refractionTexture:"refractionMap",reflectionTexture:"reflectionMap"};function Ke(s,e,t,i){["albedoTexture","bumpTexture","ambientTexture","emissiveTexture","opacityTexture","metallicTexture","refractionTexture","reflectionTexture"].forEach(a=>{Ue(a,s,e,t,i)}),Ye(s,e)}function Ue(s,e,t,i,n){const a=He[s];if(!a)throw new Error("Unexpected texture name encountered.");const o=e[a],r=o==null?void 0:o.fileLink;r?s==="reflectionTexture"?r.endsWith(".env")||r.endsWith(".dds")?i.addCubeTextureTask(s,r,void 0,!1,void 0,!0):r.endsWith(".hdr")?i.addHDRCubeTextureTask(s,r,128,!1,!0,!1):i.addTextureTask(s,r,!1,!1):i.addTextureTask(s,r,!1,!1):n&&t[s]&&(t[s]&&t[s].dispose(),t[s]=null,We(s,t))}function We(s,e){s==="opacityTexture"&&(e.useAlphaFromAlbedoTexture=!0),s==="metallicTexture"&&(e.useRoughnessFromMetallicTextureAlpha=!1,e.useRoughnessFromMetallicTextureGreen=!1,e.useMetallnessFromMetallicTextureBlue=!1),s==="refractionTexture"&&(e.subSurface.isRefractionEnabled=!1,e.subSurface.refractionIntensity=1),s==="reflectionTexture"&&(e.environmentIntensity=1),s==="emissiveTexture"&&(e.emissiveIntensity=0,e.emissiveColor=new b.Color3(0,0,0),e.reflectionTexture)}function Qe(s,e,t,i){if(!e){console.error("Failed to apply texture to material: material is null.");return}s==="opacityTexture"&&(e.useAlphaFromAlbedoTexture=!1),s==="metallicTexture"&&(e.useRoughnessFromMetallicTextureAlpha=!1,e.useRoughnessFromMetallicTextureGreen=!0,e.useMetallnessFromMetallicTextureBlue=!0),s==="refractionTexture"&&(e.subSurface.isRefractionEnabled=!0,e.subSurface.refractionIntensity=t.refractionIntensity||1),s==="reflectionTexture"&&(e.environmentIntensity=t.reflectionIntensity||1,i.isCube&&(i.rotationY=t.reflectionRotation?t.reflectionRotation*Math.PI/180:0)),e[s]=i,s==="emissiveTexture"&&(e.emissiveColor=new b.Color3(1,1,1),e.emissiveIntensity=1)}function Ye(s,e){s.clearCoat&&(s.clearCoat===R.RemoveWhenSelected?(e.clearCoat.isEnabled=!1,e.clearCoat.indexOfRefraction=1.5):s.clearCoat===R.ApplyWhenSelected&&(e.clearCoat.isEnabled=!0,e.clearCoat.indexOfRefraction=s.clearCoatIOR||e.clearCoat.indexOfRefraction))}class Ze{constructor(e,t,i){this.materialVariantMap=new Map,this.keysThatRemovedBaseModel=[],this.loadedContainerForKey=new Map,this.loadedMaterialsForKey=new Map,this.scene=e,this.renameClonedAsset=t,this.setBaseModelEnabled=i}async applyMaterial(e,t,i,n){return new Promise(a=>{const o=this.materialVariantMap.get(e);this.materialVariantMap.set(e,{...o,...t});const r=this.renameClonedAsset(e),l=this.scene.materials.filter(h=>h.name===r);if(l.length===0){a();return}const u=new Se.AssetsManager(this.scene);u.useDefaultLoadingScreen=!1,l.forEach(h=>Ke(t,h,u,n)),u.onProgress=(h,g,p)=>{i&&i(h/g*100,100,p.name)},u.onFinish=h=>{h.forEach(g=>{const p=g;i&&i(100,100,g.name),this.scene.materials.filter(y=>y.name===r).forEach(y=>Qe(g.name,y,t,p.texture))}),a()},u.loadAsync()})}async applyModel(e,t,i,n){var l,u;if(i&&t&&!this.keysThatRemovedBaseModel.includes(e)&&this.keysThatRemovedBaseModel.push(e),!i)return this.keysThatRemovedBaseModel.includes(e)&&this.keysThatRemovedBaseModel.length===1&&await this.setBaseModelEnabled(!0),(l=this.loadedContainerForKey.get(e))==null||l.dispose(),this.loadedContainerForKey.delete(e),this.loadedMaterialsForKey.delete(e),this.keysThatRemovedBaseModel=this.keysThatRemovedBaseModel.filter(h=>h!==e),Promise.resolve(void 0);const o=(await U(i,this.scene,n)).instantiateModelsToScene(this.renameClonedAsset,!0);this.loadedContainerForKey.has(e)&&((u=this.loadedContainerForKey.get(e))==null||u.dispose(),this.loadedContainerForKey.delete(e),this.loadedMaterialsForKey.delete(e)),t&&await this.setBaseModelEnabled(!1),this.loadedContainerForKey.set(e,o),this.loadedMaterialsForKey.set(e,X(o));const r=[];return this.materialVariantMap.forEach(async(h,g)=>{r.push(this.applyMaterial(g,h))}),await Promise.all(r),o}dispose(){this.loadedContainerForKey.forEach(e=>e==null?void 0:e.dispose()),this.loadedContainerForKey.clear(),this.loadedMaterialsForKey.forEach(e=>e.forEach(t=>t==null?void 0:t.dispose())),this.loadedMaterialsForKey.clear(),this.materialVariantMap.clear(),this.keysThatRemovedBaseModel=[]}getAllMaterials(){const e=[];return this.loadedMaterialsForKey.forEach(t=>{t.forEach(i=>{e.includes(i)||e.push(i)})}),e}getAnimationGroups(){const e=[];return this.loadedContainerForKey.forEach(t=>{e.push(...t.animationGroups)}),e}}function X(s){const e=[];return s.rootNodes.forEach(t=>{t.getChildMeshes().forEach(i=>{i.material&&!e.includes(i.material)&&e.push(i.material),i.subMeshes&&i.subMeshes.forEach(n=>{const a=n.getMaterial(!1);a&&!e.includes(a)&&e.push(a)})})}),e}function J(s,e=""){return s.map(t=>({name:t.name.substring(e.length),loop:t.loopAnimation,to:t.to,from:t.from}))}class $e{constructor(e){this.metadata=new Map,this.materialSelectedObservable=new M.Observable,this.materialDeselectedObservable=new M.Observable,this.materialVariantObservable=new M.Observable,this.modelVariantObservable=new M.Observable,this.materialReadyToLoadCallbacks=new Map,this.modelReadyToLoadCallbacks=new Map,this.dynamicTextures=new Map,this.queuedMaterialChanges=new Map,this.materialChangesInProgress=[],this.queuedModelChanges=new Map,this.modelChangesInProgress=[],this.isExecutingAnimation=!1,this.animations=[],this.initialized=!1,this.materials=[];const{enablePicking:t,modelDetails:i,previewService:n,progressHandler:a,scene:o}=e;this.enablePicking=t,this.contextService=i.contextService,this.id=Ve(),this.previewService=n,this.scene=o,this.variantManager=new Ze(o,this.renameClonedAsset.bind(this),this.setBaseModelEnabled.bind(this)),this.transformRoot=new Le.TransformNode("root",this.scene);const r=async()=>{if(!i.model)throw new Error("Model container constructed with no URL. This is currently unsupported.");return this.assetContainer=await U(i.model,o,a),this.initialized=!0,await this.instantiate(),this};this.importPromise=r()}async applyMaterialVariant(e,t,i,n){if(!this.initialized){if(this.materialReadyToLoadCallbacks.has(e)){const o=this.materialReadyToLoadCallbacks.get(e);o==null||o.set(t,this.applyMaterialVariant.bind(this,e,t,i,n))}else{this.materialReadyToLoadCallbacks.set(e,new Map);const o=this.materialReadyToLoadCallbacks.get(e);o==null||o.set(t,this.applyMaterialVariant.bind(this,e,t,i,n))}return}const a=async()=>{await this.variantManager.applyMaterial(e,i,(o,r,l)=>{this.materialVariantObservable.notifyObservers({remainingCount:o,totalCount:r,taskName:l})},n)};if(this.materialChangesInProgress.includes(e)){if(this.queuedMaterialChanges.has(e)){const o=this.queuedMaterialChanges.get(e);o==null||o.set(t,a)}else{this.queuedMaterialChanges.set(e,new Map);const o=this.queuedMaterialChanges.get(e);o==null||o.set(t,a)}return}if(this.materialChangesInProgress.push(e),await a(),this.queuedMaterialChanges.has(e)){const o=this.queuedMaterialChanges.get(e);if(!o)throw new Error("Target material is undefined");o.forEach(async r=>{await r()}),this.queuedMaterialChanges.delete(e)}this.materialChangesInProgress.splice(this.materialChangesInProgress.indexOf(e),1),this.configureGlowLayer()}async applyModelVariant(e,t,i){if(!this.initialized){this.modelReadyToLoadCallbacks.set(e,this.applyModelVariant.bind(this,e,t,i));return}const n=()=>this.variantManager.applyModel(e,i,t==null?void 0:t.model,r=>{this.modelVariantObservable.notifyObservers({...r,key:e})});if(this.modelChangesInProgress.includes(e)){this.queuedModelChanges.set(e,n);return}const o=await(async()=>{this.modelChangesInProgress.push(e);let r=await n();if(this.queuedModelChanges.has(e)){const l=this.queuedModelChanges.get(e);if(!l)throw new Error("Queued change resolved undefined");r=await l(),this.queuedModelChanges.delete(e)}return this.modelChangesInProgress.splice(this.modelChangesInProgress.indexOf(e),1),r})();this.modelInstance&&Z(this.modelInstance.animationGroups),this.contextService||(this.contextService=t==null?void 0:t.contextService),o?this.configureModelInstance(o):this.configureGlowLayer()}dispose(){var e;this.destroyInstance(),this.variantManager.dispose(),this.dynamicTextures.forEach(t=>t==null?void 0:t.dispose()),this.dynamicTextures.clear(),this.materials.forEach(t=>t&&(t==null?void 0:t.dispose())),this.materials=[],(e=this.transformRoot)==null||e.dispose(),this.transformRoot=void 0,this.previewService.modelUnloaded(this)}executeAnimation(e){if(!this.previewService.getInitializationComplete())return this.queuedModelAnimation=e,Promise.resolve();if(!this.modelInstance)return Promise.resolve();let t=()=>{};const i=async()=>{this.isExecutingAnimation=!0,await new Promise(n=>{ke([...this.modelInstance.animationGroups,...this.variantManager.getAnimationGroups()],e.loop,e.to,e.from,e.name?this.renameClonedAsset(e.name):void 0,n)}),this.isExecutingAnimation=!1,this.queuedAnimationFunction&&this.queuedAnimationFunction(),this.queuedAnimationFunction=void 0,t()};return this.isExecutingAnimation?(this.queuedAnimationFunction=i,new Promise(n=>{t=n})):i()}getAnimations(e){return[...this.animations,...e?J(this.variantManager.getAnimationGroups(),this.renameClonedAsset("")):[]]}getId(){return this.id}listMaterials(){var t;const e=(t=this.scene)==null?void 0:t.materials.filter(i=>i.name.startsWith(this.id));return e?e.map(i=>({id:i.id,name:this.stripIdFromName(i.name)})):[]}registerMaterialSelectedCallback(e){this.materialSelectedObservable.add(e)}unregisterMaterialSelectedCallback(e){this.materialSelectedObservable.removeCallback(e)}registerMaterialDeselectedCallback(e){this.materialDeselectedObservable.add(e)}unregisterMaterialDeselectedCallback(e){this.materialDeselectedObservable.removeCallback(e)}get position(){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to requesting position!");return this.transformRoot.position}set position(e){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to setting position!");this.transformRoot.position=new m.Vector3(e.x,e.y,e.z)}get rotation(){var e;if(!((e=this.transformRoot)!=null&&e.rotationQuaternion))throw new Error("ModelContainer disposed prior to requesting rotation!");return this.transformRoot.rotationQuaternion.toEulerAngles()}set rotation(e){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to setting rotation!");this.transformRoot.rotationQuaternion=m.Quaternion.FromEulerAngles(e.x,e.y,e.z)}get scale(){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to requesting scale!");return this.transformRoot.scaling}set scale(e){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to setting scale!");this.transformRoot.scaling=new 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 k.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 k.ExecuteCodeAction(O.ActionManager.OnPointerOutTrigger,()=>{i.material&&this.materialDeselectedObservable.notifyObservers({id:i.material.id,name:this.stripIdFromName(i.material.name)})})))})})}getInitializationPromise(){return this.importPromise}getIsInitialized(){return this.initialized}getQueuedMaterialVariantCount(){return this.materialReadyToLoadCallbacks.size}getQueuedModelVariantCount(){return this.modelReadyToLoadCallbacks.size}configureGlowLayer(){const e=i=>i instanceof L.PBRMaterial&&i.emissiveTexture!==null;this.materials.some(e)||this.variantManager.getAllMaterials().some(e)?this.previewService.getGlowLayerManager().includeMeshes(this.getAllMeshes()):this.previewService.getGlowLayerManager().removeMeshes(this.getAllMeshes())}configureModelInstance(e){var a;if(!this.transformRoot)throw new Error("Transform disposed! This should never happen unless there is a race condition present!");const t=this.transformRoot.position,i=this.transformRoot.rotationQuaternion,n=this.transformRoot.scaling;this.transformRoot.position=m.Vector3.Zero(),this.transformRoot.rotationQuaternion=m.Quaternion.Identity(),this.transformRoot.scaling=m.Vector3.One();for(const o of e.rootNodes)o.parent=this.transformRoot;this.transformRoot.position=t,this.transformRoot.rotationQuaternion=i,this.transformRoot.scaling=n,this.canvasPanels=((a=this.contextService)==null?void 0:a.getAll())||new Map,je(this.materials.concat(this.variantManager.getAllMaterials()),this.scene,this.canvasPanels,this.dynamicTextures,`${this.id}_`),this.enablePicking&&this.attachPickingHandler(e),this.configureGlowLayer()}destroyInstance(){var e;(e=this.modelInstance)==null||e.dispose(),this.modelInstance=void 0}getAllMeshes(){var e;return(e=this.modelInstance)==null?void 0:e.rootNodes.map(t=>t.getChildMeshes(!1).filter(i=>i instanceof Ee.Mesh)).flat()}async instantiate(){if(!this.assetContainer)throw new Error("Attempted to instantiate ModelContainer without an AssetContainer");this.modelInstance=this.assetContainer.instantiateModelsToScene(this.renameClonedAsset.bind(this),!0),this.materials=X(this.modelInstance),this.configureModelInstance(this.modelInstance),this.animations=J(this.modelInstance.animationGroups,this.renameClonedAsset("")),await this.processQueuedEvents()}renameClonedAsset(e){return`${this.id}_${e}`}async setBaseModelEnabled(e){e&&!this.modelInstance?await this.instantiate():!e&&this.modelInstance&&this.destroyInstance()}updateDynamicTextures(){var e;(e=this.canvasPanels)==null||e.forEach((t,i)=>{const 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(){await Promise.all(Array.from(this.materialReadyToLoadCallbacks.values()).flatMap(e=>Array.from(e.values()).map(t=>t()))),this.materialReadyToLoadCallbacks.clear(),await Promise.all(Array.from(this.modelReadyToLoadCallbacks.values()).map(e=>e())),this.modelReadyToLoadCallbacks.clear(),console.log("ModelContainer ready, executing queued animation",this.queuedModelAnimation),this.queuedModelAnimation&&(this.executeAnimation(this.queuedModelAnimation),this.queuedModelAnimation=void 0)}}class S extends v.ArcRotateCamera{constructor(e,t,i,n,a,o,r,l){super(e,t,i,n,a,o,l),this.lastFocus=new m.Vector3(0,0,0),this.panDenominator=1,this.minZ=.01,this.updateRadiusBounds(this.radius),this.enableFramingBehavior(),this.wheelDeltaPercentage=.01,this.pinchDeltaPercentage=.005,this.useNaturalPinchZoom=!0,r.camera.autoOrientation&&(this.alpha+=Math.PI),r&&(r.camera.limits.min.beta&&(this.lowerBetaLimit=r.camera.limits.min.beta),r.camera.limits.max.beta&&(this.upperBetaLimit=r.camera.limits.max.beta),r.camera.limits.min.alpha&&(this.lowerAlphaLimit=r.camera.limits.min.alpha),r.camera.limits.max.alpha&&(this.upperAlphaLimit=r.camera.limits.max.alpha),r.camera.limits.min.radius&&(this.lowerRadiusLimit=r.camera.limits.min.radius),r.camera.limits.max.radius&&(this.upperRadiusLimit=r.camera.limits.max.radius),r.camera.autoRotation.enabled&&this.enableAutoRotationBehavior(r.camera.autoRotation.idleTimeMs))}getFramingBehavior(){return this.getBehaviorByName("Framing")}getAutoRotationBehavior(){const e=this.getBehaviorByName("AutoRotation");if(e)return e}enableFramingBehavior(){this.useFramingBehavior=!0;const e=this.getFramingBehavior();e.attach(this),e.framingTime=0,e.elevationReturnTime=-1,e.zoomStopsAnimation=!1,this.lowerRadiusLimit=null;const t=F(this._scene);return e.zoomOnBoundingInfo(t.min,t.max),this.wheelPrecision=100/this.radius,this.lowerRadiusLimit===null&&(this.lowerRadiusLimit=.1),this.lastFocus.copyFrom(this.target),e}rerunFramingBehavior(e,t){const i=this.getFramingBehavior();i.framingTime=t||800;const n=()=>{e&&e()},a=F(this._scene),o=a.max.subtract(a.min),r=a.min.add(o.scale(.5));this.updateRadiusBounds(o.length()*1.5),this.wheelPrecision=100/this.radius,this.panningInertia=0,this.panningOriginTarget.copyFrom(r),this.panDenominator=o.length(),i.zoomOnBoundingInfo(a.min,a.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}updateRadiusBounds(e){this.maxZ=e*1e3,this.lowerRadiusLimit=e*.01,this.upperRadiusLimit=1.5*e,this.wheelPrecision=100/e,this.pinchPrecision=300/e}static create(e,t,i){const n=F(e),a=n.max.subtract(n.min),o=n.min.add(a.scale(.5)),r=new S("ProductCamera",-(Math.PI/2),Math.PI/2,a.length()*1.5,o,e,t);return r.panningInertia=0,r.panningOriginTarget.copyFrom(o),r.panDenominator=a.length(),r.onAfterCheckInputsObservable.add(()=>{r.panningSensibility=1e3/r.panDenominator}),i&&(e.activeCamera=r),r}}function F(s){if(s.meshes.length===0)return{min:new m.Vector3(-1,-1,-1),max:new m.Vector3(1,1,1)};const e=s.meshes.filter(t=>t.name.toLowerCase().endsWith("_t")||t.name.toLowerCase().includes("_t_"));return s.getWorldExtends(t=>t.isVisible&&t.isEnabled()&&(e.length===0||e.includes(t)))}class Xe{constructor(e,t=!1,i=void 0){this.renderingPipeline=new Fe.DefaultRenderingPipeline("default",t,e,i?[i]:void 0,!1),this.renderingPipeline.isSupported&&(this.renderingPipeline.prepare(),this.setConfiguration(d))}dispose(){this.renderingPipeline.dispose()}getConfiguration(){return this.currentConfiguration}setConfiguration(e){var t,i,n,a,o,r,l,u,h,g,p,f,y,_,ee,te,ie,se,ne,re,ae,oe,le,he,ce,de,ue,ge,me,pe,fe,be,ye;if(this.renderingPipeline.isSupported){if(this.renderingPipeline.samples=((t=e.antiAliasing)==null?void 0:t.samples)??d.antiAliasing.samples,this.renderingPipeline.fxaaEnabled=((i=e.antiAliasing)==null?void 0:i.fxaaEnabled)??d.antiAliasing.fxaaEnabled,this.renderingPipeline.bloomEnabled=((n=e.bloom)==null?void 0:n.enabled)??d.bloom.enabled,this.renderingPipeline.bloomKernel=((a=e.bloom)==null?void 0:a.kernel)??d.bloom.kernel,this.renderingPipeline.bloomScale=((o=e.bloom)==null?void 0:o.scale)??d.bloom.scale,this.renderingPipeline.bloomThreshold=((r=e.bloom)==null?void 0:r.threshold)??d.bloom.threshold,this.renderingPipeline.bloomWeight=((l=e.bloom)==null?void 0:l.weight)??d.bloom.weight,this.renderingPipeline.chromaticAberrationEnabled=((u=e.chromaticAberration)==null?void 0:u.enabled)??d.chromaticAberration.enabled,this.renderingPipeline.chromaticAberration.aberrationAmount=((h=e.chromaticAberration)==null?void 0:h.aberrationAmount)??d.chromaticAberration.aberrationAmount,this.renderingPipeline.chromaticAberration.radialIntensity=((g=e.chromaticAberration)==null?void 0:g.radialIntensity)??d.chromaticAberration.radialIntensity,this.renderingPipeline.chromaticAberration.direction=(p=e.chromaticAberration)!=null&&p.direction?new m.Vector2(e.chromaticAberration.direction.x,e.chromaticAberration.direction.y):new m.Vector2(d.chromaticAberration.direction.x,d.chromaticAberration.direction.y),this.renderingPipeline.imageProcessing.colorCurvesEnabled=((f=e.colorCurves)==null?void 0:f.enabled)??d.colorCurves.enabled,this.renderingPipeline.imageProcessing.colorCurves=e.colorCurves?this.updateColorCurve(e.colorCurves):new N.ColorCurves,this.renderingPipeline.depthOfFieldEnabled=((y=e.depthOfField)==null?void 0:y.enabled)??d.depthOfField.enabled,e.depthOfField)switch(e.depthOfField.blurLevel??d.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)??d.depthOfField.focalLength,this.renderingPipeline.depthOfField.fStop=((ee=e.depthOfField)==null?void 0:ee.fStop)??d.depthOfField.fStop,this.renderingPipeline.depthOfField.focusDistance=((te=e.depthOfField)==null?void 0:te.focusDistance)??d.depthOfField.focusDistance,this.renderingPipeline.depthOfField.lensSize=((ie=e.depthOfField)==null?void 0:ie.lensSize)??d.depthOfField.lensSize,this.renderingPipeline.grainEnabled=((se=e.grain)==null?void 0:se.enabled)??d.grain.enabled,this.renderingPipeline.grain.animated=((ne=e.grain)==null?void 0:ne.animated)??d.grain.animated,this.renderingPipeline.grain.intensity=((re=e.grain)==null?void 0:re.intensity)??d.grain.intensity,this.renderingPipeline.imageProcessing.contrast=((ae=e.misc)==null?void 0:ae.contrast)??d.misc.contrast,this.renderingPipeline.imageProcessing.exposure=((oe=e.misc)==null?void 0:oe.exposure)??d.misc.exposure,this.renderingPipeline.imageProcessing.toneMappingEnabled=((le=e.misc)==null?void 0:le.toneMappingEnabled)??d.misc.toneMappingEnabled,this.renderingPipeline.imageProcessing.toneMappingEnabled)switch(e.misc.toneMappingType??d.misc.toneMappingType){case"Standard":this.renderingPipeline.imageProcessing.toneMappingType=A.ImageProcessingConfiguration.TONEMAPPING_STANDARD;break;case"ACES":this.renderingPipeline.imageProcessing.toneMappingType=A.ImageProcessingConfiguration.TONEMAPPING_ACES;break}if(this.renderingPipeline.sharpenEnabled=((he=e.sharpen)==null?void 0:he.enabled)??d.sharpen.enabled,this.renderingPipeline.sharpen.colorAmount=((ce=e.sharpen)==null?void 0:ce.colorAmount)??d.sharpen.colorAmount,this.renderingPipeline.sharpen.edgeAmount=((de=e.sharpen)==null?void 0:de.edgeAmount)??d.sharpen.edgeAmount,this.renderingPipeline.imageProcessing.vignetteEnabled=((ue=e.vignette)==null?void 0:ue.enabled)??d.vignette.enabled,(ge=e.vignette)!=null&&ge.center?(this.renderingPipeline.imageProcessing.vignetteCenterX=e.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=e.vignette.center.y):(this.renderingPipeline.imageProcessing.vignetteCenterX=d.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=d.vignette.center.y),e.vignette)switch(((me=e.vignette)==null?void 0:me.blendMode)??d.vignette.blendMode){case"Multiply":this.renderingPipeline.imageProcessing.vignetteBlendMode=A.ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY;break;case"Opaque":this.renderingPipeline.imageProcessing.vignetteBlendMode=A.ImageProcessingConfiguration.VIGNETTEMODE_OPAQUE;break}(pe=e.vignette)!=null&&pe.colorRgba?this.renderingPipeline.imageProcessing.vignetteColor=new b.Color4(e.vignette.colorRgba.r,e.vignette.colorRgba.g,e.vignette.colorRgba.b,e.vignette.colorRgba.a):(fe=e.vignette)!=null&&fe.colorHex?this.renderingPipeline.imageProcessing.vignetteColor=b.Color4.FromHexString(e.vignette.colorHex):this.renderingPipeline.imageProcessing.vignetteColor=new b.Color4(d.vignette.colorRgba.r,d.vignette.colorRgba.g,d.vignette.colorRgba.b,d.vignette.colorRgba.a),this.renderingPipeline.imageProcessing.vignetteStretch=((be=e.vignette)==null?void 0:be.stretch)??d.vignette.stretch,this.renderingPipeline.imageProcessing.vignetteWeight=((ye=e.vignette)==null?void 0:ye.weight)??d.vignette.weight,this.renderingPipeline.prepare(),this.currentConfiguration=e}}updateColorCurve(e){const t=new N.ColorCurves;return t.globalDensity=e.globalDensity??t.globalDensity,t.globalExposure=e.globalExposure??t.globalExposure,t.globalHue=e.globalHue??t.globalHue,t.globalSaturation=e.globalSaturation??t.globalSaturation,t.highlightsDensity=e.highlightsDensity??t.highlightsDensity,t.highlightsExposure=e.highlightsExposure??t.highlightsExposure,t.highlightsHue=e.highlightsHue??t.highlightsHue,t.highlightsSaturation=e.highlightsSaturation??t.highlightsSaturation,t.midtonesDensity=e.midtonesDensity??t.midtonesDensity,t.midtonesExposure=e.midtonesExposure??t.midtonesExposure,t.midtonesHue=e.midtonesHue??t.midtonesHue,t.midtonesSaturation=e.midtonesSaturation??t.midtonesSaturation,t.shadowsDensity=e.shadowsDensity??t.shadowsDensity,t.shadowsExposure=e.shadowsExposure??t.shadowsExposure,t.shadowsHue=e.shadowsHue??t.shadowsHue,t.shadowsSaturation=e.shadowsSaturation??t.shadowsSaturation,t}}Pe.GLTF2.GLTFLoader.RegisterExtension("glbPostProcessor",function(s){return new Be(s)}),D.SceneLoader.OnPluginActivatedObservable.add(s=>{if(s.name==="gltf"){const e=s;e.transparencyAsCoverage=!0}});function B(s){return new m.Vector3(s.x,s.y,s.z)}function q(s){return{x:s.x,y:s.y,z:s.z}}class Je{constructor(e){var l;this.focusLostNotified=!1,this.focusLostObservable=new M.Observable,this.modelLoadEventCallbacks=[],this.modelContainers=new Map,this.plugins=[],this.initComplete=!1,this.isAnimatingCamera=!1,this.renderLoop=()=>{this.engine.views&&(this.modelContainers.forEach(u=>{u.updateDynamicTextures()}),this.scene.render(),!this.camera.target.equalsWithEpsilon(this.camera.lastFocus,.1)&&!this.focusLostNotified&&(this.focusLostObservable.notifyObservers(void 0),this.focusLostNotified=!0),this.screenshotPrepareResolve&&(this.screenshotPrepareResolve(),this.screenshotPrepareResolve=void 0))},this.configuration=new G(e);const i=(()=>{if(!(e!=null&&e.noRender))return this.configuration.createCanvas()})(),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 a=console.log;console.log=()=>{};const o=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 ve.NullEngine;console.log=a,o.hideLoadingUI(),window.addEventListener("resize",this.fireResizeEvent.bind(this)),this.engine=o,this.scene=new xe.Scene(o),this.scene.autoClear=!0,this.scene.autoClearDepthAndStencil=!0,this.camera=S.create(this.scene,this.configuration),this.scene.activeCamera=this.camera,this.renderingPipeline=new Xe(this.scene,!1,this.camera),this.scene.clearColor=this.configuration.scene.clearColor;const r=V.CubeTexture.CreateFromPrefilteredData(this.configuration.scene.environment.file,this.scene);r.rotationY=this.configuration.scene.environment.rotationY,this.scene.environmentTexture=r,this.scene.environmentIntensity=this.configuration.scene.environment.intensity,(l=this.configuration.options)!=null&&l.renderingPipelineConfiguration?this.renderingPipeline.setConfiguration(this.configuration.options.renderingPipelineConfiguration):(this.scene.imageProcessingConfiguration.exposure=this.configuration.lighting.exposure,this.scene.imageProcessingConfiguration.contrast=this.configuration.lighting.contrast),this.glowLayerManager=new qe(this.scene,this.configuration.emissiveGlowIntensity),this.initPromise=new Promise(u=>{this.scene.onReadyObservable.addOnce(()=>{this.initComplete=!0,u()})}),this.engine.runRenderLoop(this.renderLoop)}getInitializationPromise(){return this.initPromise}getInitializationComplete(){return this.initComplete}getEngineContext(){return{engine:this.engine,scene:this.scene,camera:this.camera}}registerFocusLostListener(e){this.focusLostObservable.add(e)}unregisterFocusLostListener(e){this.focusLostObservable.removeCallback(e)}registerModelLoadEventListener(e){this.modelLoadEventCallbacks.push(e)}unregisterModelLoadEventListener(e){const t=this.modelLoadEventCallbacks.indexOf(e);t>-1&&this.modelLoadEventCallbacks.splice(t,1)}registerView(e){const t=e.height,i=e.width;this.engine.registerView(e,void 0,!0),e.setAttribute("height",t.toString()),e.setAttribute("width",i.toString()),this.orbitEnabled()||this.setCameraState(T.Pan),this.reattachControls(e)}getNumViewports(){var e;return((e=this.engine.views)==null?void 0:e.length)||0}unregisterView(e){this.engine.unRegisterView(e)}shutdown(){this.plugins.forEach(e=>e.dispose(!0)),this.renderingPipeline.dispose(),this.engine&&this.engine.dispose(),window.removeEventListener("resize",this.fireResizeEvent)}executeCameraAnimation(e){if(!this.camera||this.scene.activeCamera!==this.camera)return this.queuedCameraAnimation=e,Promise.resolve();let t=()=>{};const i=async()=>{this.isAnimatingCamera=!0,await Ne(this.scene,this.scene.activeCamera,e),this.isAnimatingCamera=!1,this.queuedAnimationFunction&&this.queuedAnimationFunction(),this.queuedAnimationFunction=void 0,t()};return this.isAnimatingCamera?(this.queuedAnimationFunction=i,new Promise(n=>{t=n})):i()}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===T.Orbit?this.reattachControls(this.engine.views[0].target,2):this.reattachControls(this.engine.views[0].target,0)}animateToLastCameraFocus(){let e=()=>{};const t=async()=>{this.isAnimatingCamera=!0,await new Promise(i=>{const n=()=>{const a=this.configuration;this.camera.rerunFramingBehavior(()=>{this.focusLostNotified=!1,a.camera.limits.min.radius&&(this.camera.lowerRadiusLimit=a.camera.limits.min.radius),a.camera.limits.max.radius&&(this.camera.upperRadiusLimit=a.camera.limits.max.radius),i()})};this.scene.onAfterRenderObservable.addOnce(n)}),this.isAnimatingCamera=!1,this.queuedAnimationFunction&&this.queuedAnimationFunction(),this.queuedAnimationFunction=void 0,e()};return this.isAnimatingCamera?(this.queuedAnimationFunction=t,new Promise(i=>{e=i})):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,a=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=a,i.beta=n,i.radius=t.radius||this.camera.radius,i.minZ=.01,this.scene.render();const o=await Me.Tools.CreateScreenshotUsingRenderTargetAsync(this.engine,i,e,"image/png",2,!0);return i.dispose(),o}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,a=e.camera.limits.max.beta;if(t===void 0||i===void 0||n===void 0||a===void 0)return!0;const o=[t,i],r=[n,a],l=o.every(h=>h===t),u=r.every(h=>h===n);return!l&&!u}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 we.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 b.Color3(t[0],t[1],t[2]).toLinearSpace():void 0;e.forEach(a=>{const o=this.scene.materials.find(r=>r.name===a.name&&r.id===a.id);o&&o.getBindedMeshes().forEach(r=>{var l;return(l=this.highlightLayer)==null?void 0:l.addMesh(r,i||b.Color3.FromHexString("#fcba03"))})})}setRenderingPipelineConfiguration(e){this.renderingPipeline&&this.renderingPipeline.setConfiguration(e)}loadModel(e,t){const i=new $e({enablePicking:this.configuration.highlights.enabled,modelDetails:e,scene:this.scene,previewService:this,progressHandler:t});return i.getInitializationPromise().then(()=>{this.modelContainers.size<=1&&this.camera.rerunFramingBehavior(void 0,1),ze(this.scene),console.log("Model loaded, executing queued camera animation",this.queuedCameraAnimation),this.queuedCameraAnimation&&(this.executeCameraAnimation(this.queuedCameraAnimation),this.queuedCameraAnimation=void 0)}),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))}flipTransform(e,t,i){const n=m.Matrix.Compose(B(i||{x:1,y:1,z:1}),m.Quaternion.FromEulerVector(B(t||{x:0,y:0,z:0})),B(e||{x:0,y:0,z:0})),a=m.Matrix.RotationAxis(m.Vector3.Up(),Math.PI),o=n.multiply(a),r=m.Vector3.Zero(),l=m.Quaternion.Identity(),u=m.Vector3.Zero();return o.decompose(u,l,r),l.multiplyInPlace(m.Quaternion.FromEulerAngles(0,Math.PI,0)),{position:q(r),rotation:q(l.toEulerAngles()),scale:q(u)}}updatePreviewOptions(e){var n;const t=new G(e);this.configuration.highlights.enabled!==t.highlights.enabled&&this.engine.setStencilBuffer(t.highlights.enabled),this.scene.clearColor=t.scene.clearColor;let i=this.scene.environmentTexture;this.configuration.scene.environment.file!==t.scene.environment.file&&(i=V.CubeTexture.CreateFromPrefilteredData(t.scene.environment.file,this.scene),i.rotationY=this.configuration.scene.environment.rotationY,this.scene.environmentTexture=i),i.rotationY=t.scene.environment.rotationY,this.scene.environmentIntensity=t.scene.environment.intensity,(n=t.options)!=null&&n.renderingPipelineConfiguration?this.renderingPipeline.setConfiguration(t.options.renderingPipelineConfiguration):(this.scene.imageProcessingConfiguration.exposure=t.lighting.exposure,this.scene.imageProcessingConfiguration.contrast=t.lighting.contrast),this.glowLayerManager.setIntensity(t.emissiveGlowIntensity),this.configuration=t}reattachControls(e,t=2){if(this.scene.detachControl(),this.engine.inputElement=e,this.camera){this.camera.attachControl(!0,!1,t);const i=this.camera.inputs.attached.pointers;i.multiTouchPanning=!1}this.scene.attachControl(!0,!0,!0)}}c.MaterialEffectMode=R,c.ProductCameraRig=T,c.REFLECTION_PROBE_RESOLUTION=H,c.RenderingConfiguration=C,c.SpiffCommerce3DPreviewService=Je,c.renderingPipelineDefaults=d,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(c,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):(c=typeof globalThis<"u"?globalThis:c||self,v(c.Preview={},c.arcRotateCamera,c.engine,c.nullEngine,c.highlightLayer,c.sceneLoader,c.cubeTexture,c.math_color,c.math_vector,c.dracoCompression,c.observable,c.tools,c.scene,c.glTF,c.pbrMaterial,c.mirrorTexture,c.math,c.reflectionProbe,c.glowLayer,c.actionManager,c.directActions,c.mesh,c.transformNode,c.dynamicTexture,c.texture,c.animation,c.easing,c.assetsManager,c.colorCurves,c.imageProcessingConfiguration,c.RenderPipeline,c.depthOfFieldEffect))})(this,function(c,v,q,ve,we,D,V,b,m,Ce,M,Me,xe,Pe,L,Ae,P,Te,Re,O,k,Ee,Le,Oe,Ie,w,z,Se,N,A,Fe,I){"use strict";var T=(s=>(s[s.Orbit=0]="Orbit",s[s.Pan=1]="Pan",s))(T||{}),R=(s=>(s.None="None",s.RemoveWhenSelected="RemoveWhenSelected",s.ApplyWhenSelected="ApplyWhenSelected",s))(R||{});class G{constructor(e){this.getSceneClearColor=()=>{var i,n,a,o;const t=(i=this.customOptions)!=null&&i.transparentBackground||(n=this.customOptions)!=null&&n.backgroundImage?0:1;if(this.customOptions&&((a=this.customOptions)!=null&&a.transparentBackground)||(o=this.customOptions)!=null&&o.backgroundImage)return new b.Color4(0,0,0,t).toLinearSpace();if(this.customOptions&&this.customOptions.backgroundColor){const r=b.Color3.FromHexString(this.customOptions.backgroundColor);return new b.Color4(r.r,r.g,r.b,t).toLinearSpace()}return new b.Color4(.98,.98,.98,t).toLinearSpace()},this.highlightColorFromConfig=()=>this.customOptions&&this.customOptions.highlightColor?this.hexToColor4(this.customOptions.highlightColor):new b.Color4(.98,.98,.98,1).toLinearSpace(),this.hexToColor4=(t,i=1)=>{const n=b.Color3.FromHexString(t);return new b.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,n,a;return{clearColor:this.getSceneClearColor(),transparentBackground:((e=this.customOptions)==null?void 0:e.transparentBackground)||((t=this.customOptions)==null?void 0:t.backgroundImage),environment:{file:((i=this.customOptions)==null?void 0:i.environmentFile)??"assets/model-viewer/default.env",intensity:((n=this.customOptions)==null?void 0:n.environmentIntensity)??1,rotationY:(((a=this.customOptions)==null?void 0:a.environmentRotationY)??0)*(Math.PI/180)}}}get camera(){var e,t,i,n,a,o,r,l,u,h,g,p,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?((a=this.customOptions)==null?void 0:a.lowerAlphaLimitDeg)*Math.PI/180:void 0,beta:(o=this.customOptions)!=null&&o.lowerBetaLimitDeg?((r=this.customOptions)==null?void 0:r.lowerBetaLimitDeg)*Math.PI/180:void 0,radius:(l=this.customOptions)==null?void 0:l.minZoomOverride},max:{alpha:(u=this.customOptions)!=null&&u.upperAlphaLimitDeg?((h=this.customOptions)==null?void 0:h.upperAlphaLimitDeg)*Math.PI/180:void 0,beta:(g=this.customOptions)!=null&&g.upperBetaLimitDeg?((p=this.customOptions)==null?void 0:p.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 C{static getDynamicTextureResolution(){return this.getIsMobile()||!C.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/window.devicePixelRatio<=480}catch{return!1}}}const H=128,d={antiAliasing:{samples:4,fxaaEnabled:!1},bloom:{enabled:!1,kernel:64,scale:.5,threshold:.9,weight:.15},chromaticAberration:{enabled:!1,aberrationAmount:30,direction:{x:0,y:0},radialIntensity:0},colorCurves:{enabled:!1},depthOfField:{enabled:!1,blurLevel:"Low",focalLength:50,focusDistance:2e3,fStop:1.4,lensSize:50},grain:{enabled:!1,animated:!1,intensity:30},misc:{contrast:1,exposure:1,toneMappingEnabled:!1,toneMappingType:"Standard"},sharpen:{enabled:!1,colorAmount:1,edgeAmount:.3},vignette:{enabled:!1,blendMode:"Multiply",cameraFov:.5,center:{x:0,y:0},colorHex:"#000000ff",colorRgba:{r:0,g:0,b:0,a:1},stretch:0,weight:1}};class Be{constructor(e){this.name="glbPostProcessor",this.enabled=!0,this.loader=e}onReady(){this.applyReflections(this.loader.babylonScene)}loadNodeAsync(e,t,i){return this.loader.loadNodeAsync(e,t,function(n){t.extras&&Object.keys(t.extras).forEach(a=>{const o=t.extras[a];n.metadata[a]=o}),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 L.PBRMaterial))){if(e.extras.sheen){const i=t;i.sheen.isEnabled=!0,i.sheen.intensity=e.extras.sheen}if(e.extras.translucency){const i=t;i.subSurface.isTranslucencyEnabled=!0,i.subSurface.translucencyIntensity=e.extras.translucency,e.extras.translucencyR&&e.extras.translucencyG&&e.extras.translucencyB&&(i.subSurface.tintColor=new P.Color3(e.extras.translucencyR,e.extras.translucencyG,e.extras.translucencyB))}if(e.extras.refractionIOR){const i=t;i.subSurface.isRefractionEnabled=!0,i.subSurface.volumeIndexOfRefraction=e.extras.refractionIOR}if(e.extras.useDepthPrePass){const i=t;i.needDepthPrePass=!0,i.forceIrradianceInFragment=!0}if(e.extras.useParallax){const i=t;i.useParallax=!0,i.useParallaxOcclusion=!0,i.parallaxScaleBias=e.extras.useParallax}}}applyReflections(e){function t(a){const o=[];return a.transformNodes.forEach(r=>{r.metadata&&r.metadata.reflective&&o.push(...r.getChildMeshes())}),a.meshes.forEach(r=>{r.metadata&&r.metadata.reflective&&!o.includes(r)&&o.push(r)}),o}function i(a,o=1){const r=a.material;if(!r)return;const l=new Ae.MirrorTexture("mirror",C.getMirrorTextureResolution(),e,!0);l.renderList=t(e);const u=a.getVerticesData("normal");if(!u)throw new Error("Mirror attribute specified on: "+a.name+"But no normals exist to generate a mirror from!");a.computeWorldMatrix(!0);const h=a.getWorldMatrix(),g=P.Vector3.TransformNormal(new P.Vector3(u[0],u[1],u[2]),h).normalize(),p=P.Plane.FromPositionAndNormal(a.position,g.scale(-1));l.mirrorPlane=p,l.level=o,r.reflectionTexture=l}function n(a){const o=a.material,r=new Te.ReflectionProbe("probe-"+o.name,H,e);r.attachToMesh(a),r.renderList&&r.renderList.push(...t(e)),o.reflectionTexture=r.cubeTexture}e.meshes.forEach(a=>{const o=a.metadata;o&&(o.mirrorTexture&&i(a,o.mirrorTexture),o.reflectionProbe&&n(a))})}}class je{constructor(e,t){this.scene=e,this.intensity=t,this.meshCount=0}setIntensity(e){this.intensity=e,this.glowLayer&&(this.glowLayer.intensity=e)}includeMeshes(e){if(e){this.glowLayer||(this.glowLayer=new Re.GlowLayer("glow",this.scene),this.glowLayer.intensity=this.intensity);for(const t of e)this.glowLayer.hasMesh(t)||(this.glowLayer.addIncludedOnlyMesh(t),this.meshCount++)}}removeMeshes(e){if(!(!this.glowLayer||!e)){for(const t of e)this.glowLayer.hasMesh(t)&&(this.glowLayer.removeIncludedOnlyMesh(t),this.meshCount--);this.meshCount===0&&(this.glowLayer.dispose(),this.glowLayer=void 0)}}}const K=new Map;async function U(s,e,t){const i=K.get(s);if(i&&i.scene.uid===e.uid)return i;{const n=await D.SceneLoader.LoadAssetContainerAsync(s,void 0,e,t);return K.set(s,n),n}}function qe(s,e,t,i,n=""){t.forEach(a=>{const o=a.getID(),r=a.getName(),l=C.getDynamicTextureResolution();s.filter(h=>h.name===n+r).forEach(h=>{const g=i.get(o),p=!1;if(g)W(h,g),g.update(p);else{const f=De(r,e,l.width,l.height);i.set(o,f),a.setStaticContext(f.getContext()),W(h,f),f.onLoadObservable.addOnce(()=>{f.update(p)})}})})}function De(s,e,t,i){const n=new Oe.DynamicTexture(s,{width:t,height:i},e,C.shouldMipMap(),Ie.Texture.TRILINEAR_SAMPLINGMODE,q.Engine.TEXTUREFORMAT_RGBA),a=n.getContext();return a&&(a.fillStyle="#f5f5f5",a.fillRect(0,0,t,i),n.update()),n}function W(s,e){if(s instanceof L.PBRMaterial){const t=s,i=t.albedoTexture;i?(e.wrapU=i.wrapU,e.wrapV=i.wrapV):(e.wrapU=1,e.wrapV=1),t.albedoTexture=e}else{const t=s,i=t.diffuseTexture;i&&(e.wrapU=i.wrapU,e.wrapV=i.wrapV),t.diffuseTexture=e}}function Ve(){const s=()=>Math.floor((1+Math.random())*65536).toString(16).substring(1);return s()+s()+"-"+s()+"-"+s()+"-"+s()+"-"+s()+s()+s()}const x=60,Q=1;function Y(s){return s.targetedAnimations.map(t=>t.animation.framePerSecond).reduce((t,i)=>t+i,0)/s.targetedAnimations.length||0}function ke(s,e,t,i,n,a){const o=n?s.filter(h=>h.name===n):s;if(o.length===0){console.warn(`No animations found for name: ${n}`);return}let r=0;const l=()=>{r++,r===o.length&&a&&a()},u=(h,g,p,f,y)=>{h.stop(),h.start(g,p,f,y),a&&(g==!1||g===void 0&&!h.loopAnimation?h.onAnimationGroupEndObservable.addOnce(()=>{l()}):h.onAnimationLoopObservable.addOnce(()=>{l()}))};if(i!==void 0&&t!==void 0&&i===t){o.forEach(h=>{const g=Y(h),p=i*g;u(h,!1,Q,p,p)});return}o.forEach(h=>{const g=Y(h),p=i!==void 0?i*g:void 0,f=t!==void 0?t*g:void 0;u(h,e,Q,p,f)})}function Z(s){s.forEach(e=>{e.stop()})}function ze(s){const e=s.animationGroups;Z(e)}function Ne(s,e,t){return new Promise(i=>{s.stopAnimation(e),e.animations=[],Math.abs(e.alpha)>2*Math.PI&&(e.alpha=Ge(e.alpha,0,2*Math.PI));const n=[],a=t.target,o=0,r=a?1:0;if(t.target&&Object.keys(t.target).length>0&&n.push(E("cameraTargetLerp","target",new m.Vector3().copyFrom(e.target),new m.Vector3(t.target.x,t.target.y,t.target.z),w.Animation.ANIMATIONTYPE_VECTOR3,o)),n.push(E("cameraAlphaLerp","alpha",e.alpha,$(t.lonDeg),w.Animation.ANIMATIONTYPE_FLOAT,r)),n.push(E("cameraBetaLerp","beta",e.beta,$(t.latDeg),w.Animation.ANIMATIONTYPE_FLOAT,r)),t.radius!==void 0){const h=Math.max(.01,t.radius);n.push(E("cameraRadiusLerp","radius",e.radius,h,w.Animation.ANIMATIONTYPE_FLOAT,r))}e.animations.push(...n);const u=e.useAutoRotationBehavior;e.disableAutoRotationBehavior(),s.beginAnimation(e,0,a?x*2:x,!1,1,()=>{e.animations=[],u&&e.enableAutoRotationBehavior(),i()})})}function $(s){return s*Math.PI/180}function E(s,e,t,i,n,a=0,o=w.Animation.ANIMATIONLOOPMODE_CONSTANT){const r=new z.QuadraticEase;r.setEasingMode(z.EasingFunction.EASINGMODE_EASEINOUT);const l=new w.Animation(s,e,x,n,o),u=[];return a>0&&u.push({frame:0,value:t}),u.push({frame:x*a,value:t}),u.push({frame:x*(a+1),value:i}),l.setKeys(u),l.setEasingFunction(r),l}function Ge(s,e,t){return s<e?s=t-(e-s)%(t-e):s=e+(s-e)%(t-e)}const He={albedoTexture:"albedoMap",bumpTexture:"normalMap",ambientTexture:"ambientMap",emissiveTexture:"emissionMap",opacityTexture:"alphaMap",metallicTexture:"metallicMap",refractionTexture:"refractionMap",reflectionTexture:"reflectionMap"};function Ke(s,e,t,i){["albedoTexture","bumpTexture","ambientTexture","emissiveTexture","opacityTexture","metallicTexture","refractionTexture","reflectionTexture"].forEach(a=>{Ue(a,s,e,t,i)}),Ye(s,e)}function Ue(s,e,t,i,n){const a=He[s];if(!a)throw new Error("Unexpected texture name encountered.");const o=e[a],r=o==null?void 0:o.fileLink;r?s==="reflectionTexture"?r.endsWith(".env")||r.endsWith(".dds")?i.addCubeTextureTask(s,r,void 0,!1,void 0,!0):r.endsWith(".hdr")?i.addHDRCubeTextureTask(s,r,128,!1,!0,!1):i.addTextureTask(s,r,!1,!1):i.addTextureTask(s,r,!1,!1):n&&t[s]&&(t[s]&&t[s].dispose(),t[s]=null,We(s,t))}function We(s,e){s==="opacityTexture"&&(e.useAlphaFromAlbedoTexture=!0),s==="metallicTexture"&&(e.useRoughnessFromMetallicTextureAlpha=!1,e.useRoughnessFromMetallicTextureGreen=!1,e.useMetallnessFromMetallicTextureBlue=!1),s==="refractionTexture"&&(e.subSurface.isRefractionEnabled=!1,e.subSurface.refractionIntensity=1),s==="reflectionTexture"&&(e.environmentIntensity=1),s==="emissiveTexture"&&(e.emissiveIntensity=0,e.emissiveColor=new b.Color3(0,0,0),e.reflectionTexture)}function Qe(s,e,t,i){if(!e){console.error("Failed to apply texture to material: material is null.");return}s==="opacityTexture"&&(e.useAlphaFromAlbedoTexture=!1),s==="metallicTexture"&&(e.useRoughnessFromMetallicTextureAlpha=!1,e.useRoughnessFromMetallicTextureGreen=!0,e.useMetallnessFromMetallicTextureBlue=!0),s==="refractionTexture"&&(e.subSurface.isRefractionEnabled=!0,e.subSurface.refractionIntensity=t.refractionIntensity||1),s==="reflectionTexture"&&(e.environmentIntensity=t.reflectionIntensity||1,i.isCube&&(i.rotationY=t.reflectionRotation?t.reflectionRotation*Math.PI/180:0)),e[s]=i,s==="emissiveTexture"&&(e.emissiveColor=new b.Color3(1,1,1),e.emissiveIntensity=1)}function Ye(s,e){s.clearCoat&&(s.clearCoat===R.RemoveWhenSelected?(e.clearCoat.isEnabled=!1,e.clearCoat.indexOfRefraction=1.5):s.clearCoat===R.ApplyWhenSelected&&(e.clearCoat.isEnabled=!0,e.clearCoat.indexOfRefraction=s.clearCoatIOR||e.clearCoat.indexOfRefraction))}class Ze{constructor(e,t,i){this.materialVariantMap=new Map,this.keysThatRemovedBaseModel=[],this.loadedContainerForKey=new Map,this.loadedMaterialsForKey=new Map,this.scene=e,this.renameClonedAsset=t,this.setBaseModelEnabled=i}async applyMaterial(e,t,i,n){return new Promise(a=>{const o=this.materialVariantMap.get(e);this.materialVariantMap.set(e,{...o,...t});const r=this.renameClonedAsset(e),l=this.scene.materials.filter(h=>h.name===r);if(l.length===0){a();return}const u=new Se.AssetsManager(this.scene);u.useDefaultLoadingScreen=!1,l.forEach(h=>Ke(t,h,u,n)),u.onProgress=(h,g,p)=>{i&&i(h/g*100,100,p.name)},u.onFinish=h=>{h.forEach(g=>{const p=g;i&&i(100,100,g.name),this.scene.materials.filter(y=>y.name===r).forEach(y=>Qe(g.name,y,t,p.texture))}),a()},u.loadAsync()})}async applyModel(e,t,i,n){var l,u;if(i&&t&&!this.keysThatRemovedBaseModel.includes(e)&&this.keysThatRemovedBaseModel.push(e),!i)return this.keysThatRemovedBaseModel.includes(e)&&this.keysThatRemovedBaseModel.length===1&&await this.setBaseModelEnabled(!0),(l=this.loadedContainerForKey.get(e))==null||l.dispose(),this.loadedContainerForKey.delete(e),this.loadedMaterialsForKey.delete(e),this.keysThatRemovedBaseModel=this.keysThatRemovedBaseModel.filter(h=>h!==e),Promise.resolve(void 0);const o=(await U(i,this.scene,n)).instantiateModelsToScene(this.renameClonedAsset,!0);this.loadedContainerForKey.has(e)&&((u=this.loadedContainerForKey.get(e))==null||u.dispose(),this.loadedContainerForKey.delete(e),this.loadedMaterialsForKey.delete(e)),t&&await this.setBaseModelEnabled(!1),this.loadedContainerForKey.set(e,o),this.loadedMaterialsForKey.set(e,X(o));const r=[];return this.materialVariantMap.forEach(async(h,g)=>{r.push(this.applyMaterial(g,h))}),await Promise.all(r),o}dispose(){this.loadedContainerForKey.forEach(e=>e==null?void 0:e.dispose()),this.loadedContainerForKey.clear(),this.loadedMaterialsForKey.forEach(e=>e.forEach(t=>t==null?void 0:t.dispose())),this.loadedMaterialsForKey.clear(),this.materialVariantMap.clear(),this.keysThatRemovedBaseModel=[]}getAllMaterials(){const e=[];return this.loadedMaterialsForKey.forEach(t=>{t.forEach(i=>{e.includes(i)||e.push(i)})}),e}getAnimationGroups(){const e=[];return this.loadedContainerForKey.forEach(t=>{e.push(...t.animationGroups)}),e}}function X(s){const e=[];return s.rootNodes.forEach(t=>{t.getChildMeshes().forEach(i=>{i.material&&!e.includes(i.material)&&e.push(i.material),i.subMeshes&&i.subMeshes.forEach(n=>{const a=n.getMaterial(!1);a&&!e.includes(a)&&e.push(a)})})}),e}function J(s,e=""){return s.map(t=>({name:t.name.substring(e.length),loop:t.loopAnimation,to:t.to,from:t.from}))}class $e{constructor(e){this.metadata=new Map,this.materialSelectedObservable=new M.Observable,this.materialDeselectedObservable=new M.Observable,this.materialVariantObservable=new M.Observable,this.modelVariantObservable=new M.Observable,this.materialReadyToLoadCallbacks=new Map,this.modelReadyToLoadCallbacks=new Map,this.dynamicTextures=new Map,this.queuedMaterialChanges=new Map,this.materialChangesInProgress=[],this.queuedModelChanges=new Map,this.modelChangesInProgress=[],this.isExecutingAnimation=!1,this.animations=[],this.initialized=!1,this.materials=[];const{enablePicking:t,modelDetails:i,previewService:n,progressHandler:a,scene:o}=e;this.enablePicking=t,this.contextService=i.contextService,this.id=Ve(),this.previewService=n,this.scene=o,this.variantManager=new Ze(o,this.renameClonedAsset.bind(this),this.setBaseModelEnabled.bind(this)),this.transformRoot=new Le.TransformNode("root",this.scene);const r=async()=>{if(!i.model)throw new Error("Model container constructed with no URL. This is currently unsupported.");return this.assetContainer=await U(i.model,o,a),this.initialized=!0,await this.instantiate(),this};this.importPromise=r()}async applyMaterialVariant(e,t,i,n){if(!this.initialized){if(this.materialReadyToLoadCallbacks.has(e)){const o=this.materialReadyToLoadCallbacks.get(e);o==null||o.set(t,this.applyMaterialVariant.bind(this,e,t,i,n))}else{this.materialReadyToLoadCallbacks.set(e,new Map);const o=this.materialReadyToLoadCallbacks.get(e);o==null||o.set(t,this.applyMaterialVariant.bind(this,e,t,i,n))}return}const a=async()=>{await this.variantManager.applyMaterial(e,i,(o,r,l)=>{this.materialVariantObservable.notifyObservers({remainingCount:o,totalCount:r,taskName:l})},n)};if(this.materialChangesInProgress.includes(e)){if(this.queuedMaterialChanges.has(e)){const o=this.queuedMaterialChanges.get(e);o==null||o.set(t,a)}else{this.queuedMaterialChanges.set(e,new Map);const o=this.queuedMaterialChanges.get(e);o==null||o.set(t,a)}return}if(this.materialChangesInProgress.push(e),await a(),this.queuedMaterialChanges.has(e)){const o=this.queuedMaterialChanges.get(e);if(!o)throw new Error("Target material is undefined");o.forEach(async r=>{await r()}),this.queuedMaterialChanges.delete(e)}this.materialChangesInProgress.splice(this.materialChangesInProgress.indexOf(e),1),this.configureGlowLayer()}async applyModelVariant(e,t,i){if(!this.initialized){this.modelReadyToLoadCallbacks.set(e,this.applyModelVariant.bind(this,e,t,i));return}const n=()=>this.variantManager.applyModel(e,i,t==null?void 0:t.model,r=>{this.modelVariantObservable.notifyObservers({...r,key:e})});if(this.modelChangesInProgress.includes(e)){this.queuedModelChanges.set(e,n);return}const o=await(async()=>{this.modelChangesInProgress.push(e);let r=await n();if(this.queuedModelChanges.has(e)){const l=this.queuedModelChanges.get(e);if(!l)throw new Error("Queued change resolved undefined");r=await l(),this.queuedModelChanges.delete(e)}return this.modelChangesInProgress.splice(this.modelChangesInProgress.indexOf(e),1),r})();this.modelInstance&&Z(this.modelInstance.animationGroups),this.contextService||(this.contextService=t==null?void 0:t.contextService),o?this.configureModelInstance(o):this.configureGlowLayer()}dispose(){var e;this.destroyInstance(),this.variantManager.dispose(),this.dynamicTextures.forEach(t=>t==null?void 0:t.dispose()),this.dynamicTextures.clear(),this.materials.forEach(t=>t&&(t==null?void 0:t.dispose())),this.materials=[],(e=this.transformRoot)==null||e.dispose(),this.transformRoot=void 0,this.previewService.modelUnloaded(this)}executeAnimation(e){if(!this.previewService.getInitializationComplete())return this.queuedModelAnimation=e,Promise.resolve();if(!this.modelInstance)return Promise.resolve();let t=()=>{};const i=async()=>{this.isExecutingAnimation=!0,await new Promise(n=>{ke([...this.modelInstance.animationGroups,...this.variantManager.getAnimationGroups()],e.loop,e.to,e.from,e.name?this.renameClonedAsset(e.name):void 0,n)}),this.isExecutingAnimation=!1,this.queuedAnimationFunction&&this.queuedAnimationFunction(),this.queuedAnimationFunction=void 0,t()};return this.isExecutingAnimation?(this.queuedAnimationFunction=i,new Promise(n=>{t=n})):i()}getAnimations(e){return[...this.animations,...e?J(this.variantManager.getAnimationGroups(),this.renameClonedAsset("")):[]]}getId(){return this.id}listMaterials(){var t;const e=(t=this.scene)==null?void 0:t.materials.filter(i=>i.name.startsWith(this.id));return e?e.map(i=>({id:i.id,name:this.stripIdFromName(i.name)})):[]}registerMaterialSelectedCallback(e){this.materialSelectedObservable.add(e)}unregisterMaterialSelectedCallback(e){this.materialSelectedObservable.removeCallback(e)}registerMaterialDeselectedCallback(e){this.materialDeselectedObservable.add(e)}unregisterMaterialDeselectedCallback(e){this.materialDeselectedObservable.removeCallback(e)}get position(){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to requesting position!");return this.transformRoot.position}set position(e){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to setting position!");this.transformRoot.position=new m.Vector3(e.x,e.y,e.z)}get rotation(){var e;if(!((e=this.transformRoot)!=null&&e.rotationQuaternion))throw new Error("ModelContainer disposed prior to requesting rotation!");return this.transformRoot.rotationQuaternion.toEulerAngles()}set rotation(e){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to setting rotation!");this.transformRoot.rotationQuaternion=m.Quaternion.FromEulerAngles(e.x,e.y,e.z)}get scale(){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to requesting scale!");return this.transformRoot.scaling}set scale(e){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to setting scale!");this.transformRoot.scaling=new 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 k.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 k.ExecuteCodeAction(O.ActionManager.OnPointerOutTrigger,()=>{i.material&&this.materialDeselectedObservable.notifyObservers({id:i.material.id,name:this.stripIdFromName(i.material.name)})})))})})}getInitializationPromise(){return this.importPromise}getIsInitialized(){return this.initialized}getQueuedMaterialVariantCount(){return this.materialReadyToLoadCallbacks.size}getQueuedModelVariantCount(){return this.modelReadyToLoadCallbacks.size}configureGlowLayer(){const e=i=>i instanceof L.PBRMaterial&&i.emissiveTexture!==null;this.materials.some(e)||this.variantManager.getAllMaterials().some(e)?this.previewService.getGlowLayerManager().includeMeshes(this.getAllMeshes()):this.previewService.getGlowLayerManager().removeMeshes(this.getAllMeshes())}configureModelInstance(e){var a;if(!this.transformRoot)throw new Error("Transform disposed! This should never happen unless there is a race condition present!");const t=this.transformRoot.position,i=this.transformRoot.rotationQuaternion,n=this.transformRoot.scaling;this.transformRoot.position=m.Vector3.Zero(),this.transformRoot.rotationQuaternion=m.Quaternion.Identity(),this.transformRoot.scaling=m.Vector3.One();for(const o of e.rootNodes)o.parent=this.transformRoot;this.transformRoot.position=t,this.transformRoot.rotationQuaternion=i,this.transformRoot.scaling=n,this.canvasPanels=((a=this.contextService)==null?void 0:a.getAll())||new Map,qe(this.materials.concat(this.variantManager.getAllMaterials()),this.scene,this.canvasPanels,this.dynamicTextures,`${this.id}_`),this.enablePicking&&this.attachPickingHandler(e),this.configureGlowLayer()}destroyInstance(){var e;(e=this.modelInstance)==null||e.dispose(),this.modelInstance=void 0}getAllMeshes(){var e;return(e=this.modelInstance)==null?void 0:e.rootNodes.map(t=>t.getChildMeshes(!1).filter(i=>i instanceof Ee.Mesh)).flat()}async instantiate(){if(!this.assetContainer)throw new Error("Attempted to instantiate ModelContainer without an AssetContainer");this.modelInstance=this.assetContainer.instantiateModelsToScene(this.renameClonedAsset.bind(this),!0),this.materials=X(this.modelInstance),this.configureModelInstance(this.modelInstance),this.animations=J(this.modelInstance.animationGroups,this.renameClonedAsset("")),await this.processQueuedEvents()}renameClonedAsset(e){return`${this.id}_${e}`}async setBaseModelEnabled(e){e&&!this.modelInstance?await this.instantiate():!e&&this.modelInstance&&this.destroyInstance()}updateDynamicTextures(){var e;(e=this.canvasPanels)==null||e.forEach((t,i)=>{const 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(){await Promise.all(Array.from(this.materialReadyToLoadCallbacks.values()).flatMap(e=>Array.from(e.values()).map(t=>t()))),this.materialReadyToLoadCallbacks.clear(),await Promise.all(Array.from(this.modelReadyToLoadCallbacks.values()).map(e=>e())),this.modelReadyToLoadCallbacks.clear(),this.queuedModelAnimation&&(this.executeAnimation(this.queuedModelAnimation),this.queuedModelAnimation=void 0)}}class S extends v.ArcRotateCamera{constructor(e,t,i,n,a,o,r,l){super(e,t,i,n,a,o,l),this.lastFocus=new m.Vector3(0,0,0),this.panDenominator=1,this.minZ=.01,this.updateRadiusBounds(this.radius),this.enableFramingBehavior(),this.wheelDeltaPercentage=.01,this.pinchDeltaPercentage=.005,this.useNaturalPinchZoom=!0,r.camera.autoOrientation&&(this.alpha+=Math.PI),r&&(r.camera.limits.min.beta&&(this.lowerBetaLimit=r.camera.limits.min.beta),r.camera.limits.max.beta&&(this.upperBetaLimit=r.camera.limits.max.beta),r.camera.limits.min.alpha&&(this.lowerAlphaLimit=r.camera.limits.min.alpha),r.camera.limits.max.alpha&&(this.upperAlphaLimit=r.camera.limits.max.alpha),r.camera.limits.min.radius&&(this.lowerRadiusLimit=r.camera.limits.min.radius),r.camera.limits.max.radius&&(this.upperRadiusLimit=r.camera.limits.max.radius),r.camera.autoRotation.enabled&&this.enableAutoRotationBehavior(r.camera.autoRotation.idleTimeMs))}getFramingBehavior(){return this.getBehaviorByName("Framing")}getAutoRotationBehavior(){const e=this.getBehaviorByName("AutoRotation");if(e)return e}enableFramingBehavior(){this.useFramingBehavior=!0;const e=this.getFramingBehavior();e.attach(this),e.framingTime=0,e.elevationReturnTime=-1,e.zoomStopsAnimation=!1,this.lowerRadiusLimit=null;const t=F(this._scene);return e.zoomOnBoundingInfo(t.min,t.max),this.wheelPrecision=100/this.radius,this.lowerRadiusLimit===null&&(this.lowerRadiusLimit=.1),this.lastFocus.copyFrom(this.target),e}rerunFramingBehavior(e,t){const i=this.getFramingBehavior();i.framingTime=t||800;const n=()=>{e&&e()},a=F(this._scene),o=a.max.subtract(a.min),r=a.min.add(o.scale(.5));this.updateRadiusBounds(o.length()*1.5),this.wheelPrecision=100/this.radius,this.panningInertia=0,this.panningOriginTarget.copyFrom(r),this.panDenominator=o.length(),i.zoomOnBoundingInfo(a.min,a.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}updateRadiusBounds(e){this.maxZ=e*1e3,this.lowerRadiusLimit=e*.01,this.upperRadiusLimit=1.5*e,this.wheelPrecision=100/e,this.pinchPrecision=300/e}static create(e,t,i){const n=F(e),a=n.max.subtract(n.min),o=n.min.add(a.scale(.5)),r=new S("ProductCamera",-(Math.PI/2),Math.PI/2,a.length()*1.5,o,e,t);return r.panningInertia=0,r.panningOriginTarget.copyFrom(o),r.panDenominator=a.length(),r.onAfterCheckInputsObservable.add(()=>{r.panningSensibility=1e3/r.panDenominator}),i&&(e.activeCamera=r),r}}function F(s){if(s.meshes.length===0)return{min:new m.Vector3(-1,-1,-1),max:new m.Vector3(1,1,1)};const e=s.meshes.filter(t=>t.name.toLowerCase().endsWith("_t")||t.name.toLowerCase().includes("_t_"));return s.getWorldExtends(t=>t.isVisible&&t.isEnabled()&&(e.length===0||e.includes(t)))}class Xe{constructor(e,t=!1,i=void 0){this.renderingPipeline=new Fe.DefaultRenderingPipeline("default",t,e,i?[i]:void 0,!1),this.renderingPipeline.isSupported&&(this.renderingPipeline.prepare(),this.setConfiguration(d))}dispose(){this.renderingPipeline.dispose()}getConfiguration(){return this.currentConfiguration}setConfiguration(e){var t,i,n,a,o,r,l,u,h,g,p,f,y,_,ee,te,ie,se,ne,re,ae,oe,le,he,ce,de,ue,ge,me,pe,fe,be,ye;if(this.renderingPipeline.isSupported){if(this.renderingPipeline.samples=((t=e.antiAliasing)==null?void 0:t.samples)??d.antiAliasing.samples,this.renderingPipeline.fxaaEnabled=((i=e.antiAliasing)==null?void 0:i.fxaaEnabled)??d.antiAliasing.fxaaEnabled,this.renderingPipeline.bloomEnabled=((n=e.bloom)==null?void 0:n.enabled)??d.bloom.enabled,this.renderingPipeline.bloomKernel=((a=e.bloom)==null?void 0:a.kernel)??d.bloom.kernel,this.renderingPipeline.bloomScale=((o=e.bloom)==null?void 0:o.scale)??d.bloom.scale,this.renderingPipeline.bloomThreshold=((r=e.bloom)==null?void 0:r.threshold)??d.bloom.threshold,this.renderingPipeline.bloomWeight=((l=e.bloom)==null?void 0:l.weight)??d.bloom.weight,this.renderingPipeline.chromaticAberrationEnabled=((u=e.chromaticAberration)==null?void 0:u.enabled)??d.chromaticAberration.enabled,this.renderingPipeline.chromaticAberration.aberrationAmount=((h=e.chromaticAberration)==null?void 0:h.aberrationAmount)??d.chromaticAberration.aberrationAmount,this.renderingPipeline.chromaticAberration.radialIntensity=((g=e.chromaticAberration)==null?void 0:g.radialIntensity)??d.chromaticAberration.radialIntensity,this.renderingPipeline.chromaticAberration.direction=(p=e.chromaticAberration)!=null&&p.direction?new m.Vector2(e.chromaticAberration.direction.x,e.chromaticAberration.direction.y):new m.Vector2(d.chromaticAberration.direction.x,d.chromaticAberration.direction.y),this.renderingPipeline.imageProcessing.colorCurvesEnabled=((f=e.colorCurves)==null?void 0:f.enabled)??d.colorCurves.enabled,this.renderingPipeline.imageProcessing.colorCurves=e.colorCurves?this.updateColorCurve(e.colorCurves):new N.ColorCurves,this.renderingPipeline.depthOfFieldEnabled=((y=e.depthOfField)==null?void 0:y.enabled)??d.depthOfField.enabled,e.depthOfField)switch(e.depthOfField.blurLevel??d.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)??d.depthOfField.focalLength,this.renderingPipeline.depthOfField.fStop=((ee=e.depthOfField)==null?void 0:ee.fStop)??d.depthOfField.fStop,this.renderingPipeline.depthOfField.focusDistance=((te=e.depthOfField)==null?void 0:te.focusDistance)??d.depthOfField.focusDistance,this.renderingPipeline.depthOfField.lensSize=((ie=e.depthOfField)==null?void 0:ie.lensSize)??d.depthOfField.lensSize,this.renderingPipeline.grainEnabled=((se=e.grain)==null?void 0:se.enabled)??d.grain.enabled,this.renderingPipeline.grain.animated=((ne=e.grain)==null?void 0:ne.animated)??d.grain.animated,this.renderingPipeline.grain.intensity=((re=e.grain)==null?void 0:re.intensity)??d.grain.intensity,this.renderingPipeline.imageProcessing.contrast=((ae=e.misc)==null?void 0:ae.contrast)??d.misc.contrast,this.renderingPipeline.imageProcessing.exposure=((oe=e.misc)==null?void 0:oe.exposure)??d.misc.exposure,this.renderingPipeline.imageProcessing.toneMappingEnabled=((le=e.misc)==null?void 0:le.toneMappingEnabled)??d.misc.toneMappingEnabled,this.renderingPipeline.imageProcessing.toneMappingEnabled)switch(e.misc.toneMappingType??d.misc.toneMappingType){case"Standard":this.renderingPipeline.imageProcessing.toneMappingType=A.ImageProcessingConfiguration.TONEMAPPING_STANDARD;break;case"ACES":this.renderingPipeline.imageProcessing.toneMappingType=A.ImageProcessingConfiguration.TONEMAPPING_ACES;break}if(this.renderingPipeline.sharpenEnabled=((he=e.sharpen)==null?void 0:he.enabled)??d.sharpen.enabled,this.renderingPipeline.sharpen.colorAmount=((ce=e.sharpen)==null?void 0:ce.colorAmount)??d.sharpen.colorAmount,this.renderingPipeline.sharpen.edgeAmount=((de=e.sharpen)==null?void 0:de.edgeAmount)??d.sharpen.edgeAmount,this.renderingPipeline.imageProcessing.vignetteEnabled=((ue=e.vignette)==null?void 0:ue.enabled)??d.vignette.enabled,(ge=e.vignette)!=null&&ge.center?(this.renderingPipeline.imageProcessing.vignetteCenterX=e.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=e.vignette.center.y):(this.renderingPipeline.imageProcessing.vignetteCenterX=d.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=d.vignette.center.y),e.vignette)switch(((me=e.vignette)==null?void 0:me.blendMode)??d.vignette.blendMode){case"Multiply":this.renderingPipeline.imageProcessing.vignetteBlendMode=A.ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY;break;case"Opaque":this.renderingPipeline.imageProcessing.vignetteBlendMode=A.ImageProcessingConfiguration.VIGNETTEMODE_OPAQUE;break}(pe=e.vignette)!=null&&pe.colorRgba?this.renderingPipeline.imageProcessing.vignetteColor=new b.Color4(e.vignette.colorRgba.r,e.vignette.colorRgba.g,e.vignette.colorRgba.b,e.vignette.colorRgba.a):(fe=e.vignette)!=null&&fe.colorHex?this.renderingPipeline.imageProcessing.vignetteColor=b.Color4.FromHexString(e.vignette.colorHex):this.renderingPipeline.imageProcessing.vignetteColor=new b.Color4(d.vignette.colorRgba.r,d.vignette.colorRgba.g,d.vignette.colorRgba.b,d.vignette.colorRgba.a),this.renderingPipeline.imageProcessing.vignetteStretch=((be=e.vignette)==null?void 0:be.stretch)??d.vignette.stretch,this.renderingPipeline.imageProcessing.vignetteWeight=((ye=e.vignette)==null?void 0:ye.weight)??d.vignette.weight,this.renderingPipeline.prepare(),this.currentConfiguration=e}}updateColorCurve(e){const t=new N.ColorCurves;return t.globalDensity=e.globalDensity??t.globalDensity,t.globalExposure=e.globalExposure??t.globalExposure,t.globalHue=e.globalHue??t.globalHue,t.globalSaturation=e.globalSaturation??t.globalSaturation,t.highlightsDensity=e.highlightsDensity??t.highlightsDensity,t.highlightsExposure=e.highlightsExposure??t.highlightsExposure,t.highlightsHue=e.highlightsHue??t.highlightsHue,t.highlightsSaturation=e.highlightsSaturation??t.highlightsSaturation,t.midtonesDensity=e.midtonesDensity??t.midtonesDensity,t.midtonesExposure=e.midtonesExposure??t.midtonesExposure,t.midtonesHue=e.midtonesHue??t.midtonesHue,t.midtonesSaturation=e.midtonesSaturation??t.midtonesSaturation,t.shadowsDensity=e.shadowsDensity??t.shadowsDensity,t.shadowsExposure=e.shadowsExposure??t.shadowsExposure,t.shadowsHue=e.shadowsHue??t.shadowsHue,t.shadowsSaturation=e.shadowsSaturation??t.shadowsSaturation,t}}Pe.GLTF2.GLTFLoader.RegisterExtension("glbPostProcessor",function(s){return new Be(s)}),D.SceneLoader.OnPluginActivatedObservable.add(s=>{if(s.name==="gltf"){const e=s;e.transparencyAsCoverage=!0}});function B(s){return new m.Vector3(s.x,s.y,s.z)}function j(s){return{x:s.x,y:s.y,z:s.z}}class Je{constructor(e){var l;this.focusLostNotified=!1,this.focusLostObservable=new M.Observable,this.modelLoadEventCallbacks=[],this.modelContainers=new Map,this.plugins=[],this.initComplete=!1,this.isAnimatingCamera=!1,this.renderLoop=()=>{this.engine.views&&(this.modelContainers.forEach(u=>{u.updateDynamicTextures()}),this.scene.render(),!this.camera.target.equalsWithEpsilon(this.camera.lastFocus,.1)&&!this.focusLostNotified&&(this.focusLostObservable.notifyObservers(void 0),this.focusLostNotified=!0),this.screenshotPrepareResolve&&(this.screenshotPrepareResolve(),this.screenshotPrepareResolve=void 0))},this.configuration=new G(e);const i=(()=>{if(!(e!=null&&e.noRender))return this.configuration.createCanvas()})(),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 a=console.log;console.log=()=>{};const o=i?new q.Engine(i,!0,{adaptToDeviceRatio:!0,limitDeviceRatio:2,premultipliedAlpha:!1,preserveDrawingBuffer:!!(e!=null&&e.backgroundImage),audioEngine:!1,stencil:this.configuration.highlights.enabled,forceSRGBBufferSupportState:!0}):new ve.NullEngine;console.log=a,o.hideLoadingUI(),window.addEventListener("resize",this.fireResizeEvent.bind(this)),this.engine=o,this.scene=new xe.Scene(o),this.scene.autoClear=!0,this.scene.autoClearDepthAndStencil=!0,this.camera=S.create(this.scene,this.configuration),this.scene.activeCamera=this.camera,this.renderingPipeline=new Xe(this.scene,!1,this.camera),this.scene.clearColor=this.configuration.scene.clearColor;const r=V.CubeTexture.CreateFromPrefilteredData(this.configuration.scene.environment.file,this.scene);r.rotationY=this.configuration.scene.environment.rotationY,this.scene.environmentTexture=r,this.scene.environmentIntensity=this.configuration.scene.environment.intensity,(l=this.configuration.options)!=null&&l.renderingPipelineConfiguration?this.renderingPipeline.setConfiguration(this.configuration.options.renderingPipelineConfiguration):(this.scene.imageProcessingConfiguration.exposure=this.configuration.lighting.exposure,this.scene.imageProcessingConfiguration.contrast=this.configuration.lighting.contrast),this.glowLayerManager=new je(this.scene,this.configuration.emissiveGlowIntensity),this.initPromise=new Promise(u=>{this.scene.onReadyObservable.addOnce(()=>{this.initComplete=!0,u()})}),this.engine.runRenderLoop(this.renderLoop)}getInitializationPromise(){return this.initPromise}getInitializationComplete(){return this.initComplete}getEngineContext(){return{engine:this.engine,scene:this.scene,camera:this.camera}}registerFocusLostListener(e){this.focusLostObservable.add(e)}unregisterFocusLostListener(e){this.focusLostObservable.removeCallback(e)}registerModelLoadEventListener(e){this.modelLoadEventCallbacks.push(e)}unregisterModelLoadEventListener(e){const t=this.modelLoadEventCallbacks.indexOf(e);t>-1&&this.modelLoadEventCallbacks.splice(t,1)}registerView(e){const t=e.height,i=e.width;this.engine.registerView(e,void 0,!0),e.setAttribute("height",t.toString()),e.setAttribute("width",i.toString()),this.orbitEnabled()||this.setCameraState(T.Pan),this.reattachControls(e)}getNumViewports(){var e;return((e=this.engine.views)==null?void 0:e.length)||0}unregisterView(e){this.engine.unRegisterView(e)}shutdown(){this.plugins.forEach(e=>e.dispose(!0)),this.renderingPipeline.dispose(),this.engine&&this.engine.dispose(),window.removeEventListener("resize",this.fireResizeEvent)}executeCameraAnimation(e){if(!this.camera||this.scene.activeCamera!==this.camera||this.getAllModels().length===0||!this.getAllModels().some(n=>n.getIsInitialized()))return this.queuedCameraAnimation=e,Promise.resolve();let t=()=>{};const i=async()=>{this.isAnimatingCamera=!0,await Ne(this.scene,this.scene.activeCamera,e),this.isAnimatingCamera=!1,this.queuedAnimationFunction&&this.queuedAnimationFunction(),this.queuedAnimationFunction=void 0,t()};return this.isAnimatingCamera?(this.queuedAnimationFunction=i,new Promise(n=>{t=n})):i()}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===T.Orbit?this.reattachControls(this.engine.views[0].target,2):this.reattachControls(this.engine.views[0].target,0)}animateToLastCameraFocus(){let e=()=>{};const t=async()=>{this.isAnimatingCamera=!0,await new Promise(i=>{const n=()=>{const a=this.configuration;this.camera.rerunFramingBehavior(()=>{this.focusLostNotified=!1,a.camera.limits.min.radius&&(this.camera.lowerRadiusLimit=a.camera.limits.min.radius),a.camera.limits.max.radius&&(this.camera.upperRadiusLimit=a.camera.limits.max.radius),i()})};this.scene.onAfterRenderObservable.addOnce(n)}),this.isAnimatingCamera=!1,this.queuedAnimationFunction&&this.queuedAnimationFunction(),this.queuedAnimationFunction=void 0,e()};return this.isAnimatingCamera?(this.queuedAnimationFunction=t,new Promise(i=>{e=i})):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,a=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=a,i.beta=n,i.radius=t.radius||this.camera.radius,i.minZ=.01,this.scene.render();const o=await Me.Tools.CreateScreenshotUsingRenderTargetAsync(this.engine,i,e,"image/png",2,!0);return i.dispose(),o}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,a=e.camera.limits.max.beta;if(t===void 0||i===void 0||n===void 0||a===void 0)return!0;const o=[t,i],r=[n,a],l=o.every(h=>h===t),u=r.every(h=>h===n);return!l&&!u}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 we.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 b.Color3(t[0],t[1],t[2]).toLinearSpace():void 0;e.forEach(a=>{const o=this.scene.materials.find(r=>r.name===a.name&&r.id===a.id);o&&o.getBindedMeshes().forEach(r=>{var l;return(l=this.highlightLayer)==null?void 0:l.addMesh(r,i||b.Color3.FromHexString("#fcba03"))})})}setRenderingPipelineConfiguration(e){this.renderingPipeline&&this.renderingPipeline.setConfiguration(e)}loadModel(e,t){const i=new $e({enablePicking:this.configuration.highlights.enabled,modelDetails:e,scene:this.scene,previewService:this,progressHandler:t});return i.getInitializationPromise().then(()=>{this.modelContainers.size<=1&&this.camera.rerunFramingBehavior(()=>{ze(this.scene),this.queuedCameraAnimation&&(this.executeCameraAnimation(this.queuedCameraAnimation),this.queuedCameraAnimation=void 0)},1)}),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))}flipTransform(e,t,i){const n=m.Matrix.Compose(B(i||{x:1,y:1,z:1}),m.Quaternion.FromEulerVector(B(t||{x:0,y:0,z:0})),B(e||{x:0,y:0,z:0})),a=m.Matrix.RotationAxis(m.Vector3.Up(),Math.PI),o=n.multiply(a),r=m.Vector3.Zero(),l=m.Quaternion.Identity(),u=m.Vector3.Zero();return o.decompose(u,l,r),l.multiplyInPlace(m.Quaternion.FromEulerAngles(0,Math.PI,0)),{position:j(r),rotation:j(l.toEulerAngles()),scale:j(u)}}updatePreviewOptions(e){var n;const t=new G(e);this.configuration.highlights.enabled!==t.highlights.enabled&&this.engine.setStencilBuffer(t.highlights.enabled),this.scene.clearColor=t.scene.clearColor;let i=this.scene.environmentTexture;this.configuration.scene.environment.file!==t.scene.environment.file&&(i=V.CubeTexture.CreateFromPrefilteredData(t.scene.environment.file,this.scene),i.rotationY=this.configuration.scene.environment.rotationY,this.scene.environmentTexture=i),i.rotationY=t.scene.environment.rotationY,this.scene.environmentIntensity=t.scene.environment.intensity,(n=t.options)!=null&&n.renderingPipelineConfiguration?this.renderingPipeline.setConfiguration(t.options.renderingPipelineConfiguration):(this.scene.imageProcessingConfiguration.exposure=t.lighting.exposure,this.scene.imageProcessingConfiguration.contrast=t.lighting.contrast),this.glowLayerManager.setIntensity(t.emissiveGlowIntensity),this.configuration=t}reattachControls(e,t=2){if(this.scene.detachControl(),this.engine.inputElement=e,this.camera){this.camera.attachControl(!0,!1,t);const i=this.camera.inputs.attached.pointers;i.multiTouchPanning=!1}this.scene.attachControl(!0,!0,!0)}}c.MaterialEffectMode=R,c.ProductCameraRig=T,c.REFLECTION_PROBE_RESOLUTION=H,c.RenderingConfiguration=C,c.SpiffCommerce3DPreviewService=Je,c.renderingPipelineDefaults=d,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED