@spiffcommerce/preview 5.3.5-4 → 5.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +4 -0
- package/dist/index.esm.js +115 -112
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -349,6 +349,10 @@ type MaterialResource = {
|
|
|
349
349
|
* The intensity of reflection, when reflection is enabled via a texture.
|
|
350
350
|
*/
|
|
351
351
|
reflectionIntensity?: number;
|
|
352
|
+
/**
|
|
353
|
+
* The rotation of the reflection texture (along the up axis), in degrees.
|
|
354
|
+
*/
|
|
355
|
+
reflectionRotation?: number;
|
|
352
356
|
/**
|
|
353
357
|
* When enabled the material will be displayed with a clearcoat affect for simulating coated plastic surfaces.
|
|
354
358
|
*/
|
package/dist/index.esm.js
CHANGED
|
@@ -3,32 +3,32 @@ import { Engine as pe } from "@babylonjs/core/Engines/engine";
|
|
|
3
3
|
import { NullEngine as Ce } from "@babylonjs/core/Engines/nullEngine";
|
|
4
4
|
import { HighlightLayer as ye } from "@babylonjs/core/Layers/highlightLayer";
|
|
5
5
|
import { SceneLoader as fe } from "@babylonjs/core/Loading/sceneLoader";
|
|
6
|
-
import { CubeTexture as
|
|
6
|
+
import { CubeTexture as te } from "@babylonjs/core/Materials/Textures/cubeTexture";
|
|
7
7
|
import { Color4 as f, Color3 as w } from "@babylonjs/core/Maths/math.color";
|
|
8
|
-
import { Vector3 as m, Quaternion as y, Vector2 as
|
|
8
|
+
import { Vector3 as m, 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";
|
|
12
12
|
import { Scene as Pe } from "@babylonjs/core/scene";
|
|
13
|
-
import { GLTF2 as
|
|
14
|
-
import { PBRMaterial as
|
|
15
|
-
import { MirrorTexture as
|
|
16
|
-
import { Color3 as Ae, Vector3 as
|
|
17
|
-
import { ReflectionProbe as
|
|
18
|
-
import { GlowLayer as
|
|
19
|
-
import { ActionManager as
|
|
20
|
-
import { ExecuteCodeAction as
|
|
21
|
-
import { Mesh as
|
|
13
|
+
import { GLTF2 as Te } from "@babylonjs/loaders/glTF";
|
|
14
|
+
import { PBRMaterial as F } from "@babylonjs/core/Materials/PBR/pbrMaterial";
|
|
15
|
+
import { MirrorTexture as Re } from "@babylonjs/core/Materials/Textures/mirrorTexture";
|
|
16
|
+
import { Color3 as Ae, Vector3 as ne, Plane as Ee } from "@babylonjs/core/Maths/math";
|
|
17
|
+
import { ReflectionProbe as Oe } from "@babylonjs/core/Probes/reflectionProbe";
|
|
18
|
+
import { GlowLayer as Le } from "@babylonjs/core/Layers/glowLayer";
|
|
19
|
+
import { ActionManager as R } from "@babylonjs/core/Actions/actionManager";
|
|
20
|
+
import { ExecuteCodeAction as re } from "@babylonjs/core/Actions/directActions";
|
|
21
|
+
import { Mesh as Ie } from "@babylonjs/core/Meshes/mesh";
|
|
22
22
|
import { TransformNode as Se } from "@babylonjs/core/Meshes/transformNode";
|
|
23
23
|
import { DynamicTexture as Fe } from "@babylonjs/core/Materials/Textures/dynamicTexture";
|
|
24
24
|
import { Texture as Be } from "@babylonjs/core/Materials/Textures/texture";
|
|
25
25
|
import { Animation as v } from "@babylonjs/core/Animations/animation";
|
|
26
|
-
import { QuadraticEase as De, EasingFunction as
|
|
27
|
-
import { AssetsManager as
|
|
28
|
-
import { ColorCurves as
|
|
26
|
+
import { QuadraticEase as De, EasingFunction as ke } from "@babylonjs/core/Animations/easing";
|
|
27
|
+
import { AssetsManager as ze } from "@babylonjs/core/Misc/assetsManager";
|
|
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
|
|
31
|
-
import { DepthOfFieldEffectBlurLevel as
|
|
30
|
+
import { DefaultRenderingPipeline as Ve } from "@babylonjs/core/PostProcesses/RenderPipeline";
|
|
31
|
+
import { DepthOfFieldEffectBlurLevel as A } from "@babylonjs/core/PostProcesses/depthOfFieldEffect";
|
|
32
32
|
import "@babylonjs/core/Rendering/depthRendererSceneComponent";
|
|
33
33
|
import "@babylonjs/core/Engines/Extensions/engine.views";
|
|
34
34
|
import "@babylonjs/core/Meshes/instancedMesh";
|
|
@@ -39,8 +39,8 @@ import "@babylonjs/core/Animations/animatable";
|
|
|
39
39
|
import "@babylonjs/core/Misc/screenshotTools";
|
|
40
40
|
import "@babylonjs/core/Rendering/boundingBoxRenderer";
|
|
41
41
|
import "@babylonjs/loaders/glTF/2.0/Extensions";
|
|
42
|
-
var
|
|
43
|
-
class
|
|
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
|
+
class oe {
|
|
44
44
|
constructor(e) {
|
|
45
45
|
this.getSceneClearColor = () => {
|
|
46
46
|
var i, a, o, n;
|
|
@@ -181,7 +181,7 @@ class x {
|
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
|
-
const
|
|
184
|
+
const Ge = 128, h = {
|
|
185
185
|
antiAliasing: {
|
|
186
186
|
samples: 4,
|
|
187
187
|
fxaaEnabled: !1
|
|
@@ -238,7 +238,7 @@ const ze = 128, h = {
|
|
|
238
238
|
weight: 1
|
|
239
239
|
}
|
|
240
240
|
};
|
|
241
|
-
class
|
|
241
|
+
class Ne {
|
|
242
242
|
constructor(e) {
|
|
243
243
|
this.name = "glbPostProcessor", this.enabled = !0, this.loader = e;
|
|
244
244
|
}
|
|
@@ -282,7 +282,7 @@ class Ve {
|
|
|
282
282
|
* @param babylonMaterial An instance of a material representation in babylon.
|
|
283
283
|
*/
|
|
284
284
|
enableMaterialExtrasIfRequired(e, t) {
|
|
285
|
-
if (!(!e.extras || !(t instanceof
|
|
285
|
+
if (!(!e.extras || !(t instanceof F))) {
|
|
286
286
|
if (e.extras.sheen) {
|
|
287
287
|
const i = t;
|
|
288
288
|
i.sheen.isEnabled = !0, i.sheen.intensity = e.extras.sheen;
|
|
@@ -327,7 +327,7 @@ class Ve {
|
|
|
327
327
|
const r = o.material;
|
|
328
328
|
if (!r)
|
|
329
329
|
return;
|
|
330
|
-
const l = new
|
|
330
|
+
const l = new Re(
|
|
331
331
|
"mirror",
|
|
332
332
|
x.getMirrorTextureResolution(),
|
|
333
333
|
e,
|
|
@@ -340,19 +340,19 @@ class Ve {
|
|
|
340
340
|
"Mirror attribute specified on: " + o.name + "But no normals exist to generate a mirror from!"
|
|
341
341
|
);
|
|
342
342
|
o.computeWorldMatrix(!0);
|
|
343
|
-
const d = o.getWorldMatrix(), u =
|
|
344
|
-
new
|
|
343
|
+
const d = o.getWorldMatrix(), u = ne.TransformNormal(
|
|
344
|
+
new ne(c[0], c[1], c[2]),
|
|
345
345
|
d
|
|
346
|
-
).normalize(), g =
|
|
346
|
+
).normalize(), g = Ee.FromPositionAndNormal(
|
|
347
347
|
o.position,
|
|
348
348
|
u.scale(-1)
|
|
349
349
|
);
|
|
350
350
|
l.mirrorPlane = g, l.level = n, r.reflectionTexture = l;
|
|
351
351
|
}
|
|
352
352
|
function a(o) {
|
|
353
|
-
const n = o.material, r = new
|
|
353
|
+
const n = o.material, r = new Oe(
|
|
354
354
|
"probe-" + n.name,
|
|
355
|
-
|
|
355
|
+
Ge,
|
|
356
356
|
e
|
|
357
357
|
);
|
|
358
358
|
r.attachToMesh(o), r.renderList && r.renderList.push(...t(e)), n.reflectionTexture = r.cubeTexture;
|
|
@@ -363,7 +363,7 @@ class Ve {
|
|
|
363
363
|
});
|
|
364
364
|
}
|
|
365
365
|
}
|
|
366
|
-
class
|
|
366
|
+
class He {
|
|
367
367
|
constructor(e, t) {
|
|
368
368
|
this.scene = e, this.intensity = t, this.meshCount = 0;
|
|
369
369
|
}
|
|
@@ -372,7 +372,7 @@ class qe {
|
|
|
372
372
|
}
|
|
373
373
|
includeMeshes(e) {
|
|
374
374
|
if (e) {
|
|
375
|
-
this.glowLayer || (this.glowLayer = new
|
|
375
|
+
this.glowLayer || (this.glowLayer = new Le("glow", this.scene), this.glowLayer.intensity = this.intensity);
|
|
376
376
|
for (const t of e)
|
|
377
377
|
this.glowLayer.hasMesh(t) || (this.glowLayer.addIncludedOnlyMesh(t), this.meshCount++);
|
|
378
378
|
}
|
|
@@ -385,9 +385,9 @@ class qe {
|
|
|
385
385
|
}
|
|
386
386
|
}
|
|
387
387
|
}
|
|
388
|
-
const
|
|
388
|
+
const le = /* @__PURE__ */ new Map();
|
|
389
389
|
async function be(s, e, t) {
|
|
390
|
-
const i =
|
|
390
|
+
const i = le.get(s);
|
|
391
391
|
if (i && i.scene.uid === e.uid)
|
|
392
392
|
return i;
|
|
393
393
|
{
|
|
@@ -397,16 +397,16 @@ async function be(s, e, t) {
|
|
|
397
397
|
e,
|
|
398
398
|
t
|
|
399
399
|
);
|
|
400
|
-
return
|
|
400
|
+
return le.set(s, a), a;
|
|
401
401
|
}
|
|
402
402
|
}
|
|
403
|
-
function
|
|
403
|
+
function qe(s, e, t, i, a = "") {
|
|
404
404
|
t.forEach((o) => {
|
|
405
405
|
const n = o.getID(), r = o.getName(), l = x.getDynamicTextureResolution();
|
|
406
406
|
s.filter((d) => d.name === a + r).forEach((d) => {
|
|
407
407
|
const u = i.get(n), g = !1;
|
|
408
408
|
if (u)
|
|
409
|
-
|
|
409
|
+
he(d, u), u.update(g);
|
|
410
410
|
else {
|
|
411
411
|
const p = _e(
|
|
412
412
|
r,
|
|
@@ -416,7 +416,7 @@ function He(s, e, t, i, a = "") {
|
|
|
416
416
|
);
|
|
417
417
|
i.set(n, p), o.setStaticContext(
|
|
418
418
|
p.getContext()
|
|
419
|
-
),
|
|
419
|
+
), he(d, p), p.onLoadObservable.addOnce(() => {
|
|
420
420
|
p.update(g);
|
|
421
421
|
});
|
|
422
422
|
}
|
|
@@ -434,8 +434,8 @@ function _e(s, e, t, i) {
|
|
|
434
434
|
), o = a.getContext();
|
|
435
435
|
return o && (o.fillStyle = "#f5f5f5", o.fillRect(0, 0, t, i), a.update()), a;
|
|
436
436
|
}
|
|
437
|
-
function
|
|
438
|
-
if (s instanceof
|
|
437
|
+
function he(s, e) {
|
|
438
|
+
if (s instanceof F) {
|
|
439
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 {
|
|
@@ -443,15 +443,15 @@ function ce(s, e) {
|
|
|
443
443
|
i && (e.wrapU = i.wrapU, e.wrapV = i.wrapV), t.diffuseTexture = e;
|
|
444
444
|
}
|
|
445
445
|
}
|
|
446
|
-
function
|
|
446
|
+
function Ke() {
|
|
447
447
|
const s = () => Math.floor((1 + Math.random()) * 65536).toString(16).substring(1);
|
|
448
448
|
return s() + s() + "-" + s() + "-" + s() + "-" + s() + "-" + s() + s() + s();
|
|
449
449
|
}
|
|
450
|
-
const M = 60,
|
|
451
|
-
function
|
|
450
|
+
const M = 60, ce = 1;
|
|
451
|
+
function de(s) {
|
|
452
452
|
return s.targetedAnimations.map((t) => t.animation.framePerSecond).reduce((t, i) => t + i, 0) / s.targetedAnimations.length || 0;
|
|
453
453
|
}
|
|
454
|
-
function
|
|
454
|
+
function We(s, e, t, i, a) {
|
|
455
455
|
const o = a ? s.filter((n) => n.name === a) : s;
|
|
456
456
|
if (o.length === 0) {
|
|
457
457
|
console.warn(`No animations found for name: ${a}`);
|
|
@@ -460,15 +460,15 @@ function Ke(s, e, t, i, a) {
|
|
|
460
460
|
if (i !== void 0 && t !== void 0 && i === t) {
|
|
461
461
|
o.forEach((n) => {
|
|
462
462
|
n.stop();
|
|
463
|
-
const r =
|
|
464
|
-
n.start(e,
|
|
463
|
+
const r = de(n), l = i * r;
|
|
464
|
+
n.start(e, ce, l, l);
|
|
465
465
|
});
|
|
466
466
|
return;
|
|
467
467
|
}
|
|
468
468
|
o.forEach((n) => {
|
|
469
469
|
n.stop();
|
|
470
|
-
const r =
|
|
471
|
-
n.start(e,
|
|
470
|
+
const r = de(n), l = i !== void 0 ? i * r : void 0, c = t !== void 0 ? t * r : void 0;
|
|
471
|
+
n.start(e, ce, l, c);
|
|
472
472
|
});
|
|
473
473
|
}
|
|
474
474
|
function ve(s) {
|
|
@@ -476,14 +476,14 @@ function ve(s) {
|
|
|
476
476
|
e.stop();
|
|
477
477
|
});
|
|
478
478
|
}
|
|
479
|
-
function
|
|
479
|
+
function Ue(s) {
|
|
480
480
|
const e = s.animationGroups;
|
|
481
481
|
ve(e);
|
|
482
482
|
}
|
|
483
483
|
function Ye(s, e, t) {
|
|
484
|
-
|
|
484
|
+
s.stopAnimation(e), e.animations = [], Math.abs(e.alpha) > 2 * Math.PI && (e.alpha = Qe(e.alpha, 0, 2 * Math.PI));
|
|
485
485
|
const i = [], a = t.target, o = 0, n = a ? 1 : 0;
|
|
486
|
-
if (t.target && Object.keys(t.target).length > 0
|
|
486
|
+
if (t.target && Object.keys(t.target).length > 0 && i.push(
|
|
487
487
|
T(
|
|
488
488
|
"cameraTargetLerp",
|
|
489
489
|
"target",
|
|
@@ -496,12 +496,12 @@ function Ye(s, e, t) {
|
|
|
496
496
|
v.ANIMATIONTYPE_VECTOR3,
|
|
497
497
|
o
|
|
498
498
|
)
|
|
499
|
-
),
|
|
499
|
+
), i.push(
|
|
500
500
|
T(
|
|
501
501
|
"cameraAlphaLerp",
|
|
502
502
|
"alpha",
|
|
503
503
|
e.alpha,
|
|
504
|
-
|
|
504
|
+
ue(t.lonDeg),
|
|
505
505
|
v.ANIMATIONTYPE_FLOAT,
|
|
506
506
|
n
|
|
507
507
|
)
|
|
@@ -510,7 +510,7 @@ function Ye(s, e, t) {
|
|
|
510
510
|
"cameraBetaLerp",
|
|
511
511
|
"beta",
|
|
512
512
|
e.beta,
|
|
513
|
-
|
|
513
|
+
ue(t.latDeg),
|
|
514
514
|
v.ANIMATIONTYPE_FLOAT,
|
|
515
515
|
n
|
|
516
516
|
)
|
|
@@ -529,7 +529,7 @@ function Ye(s, e, t) {
|
|
|
529
529
|
}
|
|
530
530
|
e.animations.push(...i);
|
|
531
531
|
const l = e.useAutoRotationBehavior;
|
|
532
|
-
e.disableAutoRotationBehavior(),
|
|
532
|
+
e.disableAutoRotationBehavior(), s.beginAnimation(
|
|
533
533
|
e,
|
|
534
534
|
0,
|
|
535
535
|
a ? M * 2 : M,
|
|
@@ -540,12 +540,12 @@ function Ye(s, e, t) {
|
|
|
540
540
|
}
|
|
541
541
|
);
|
|
542
542
|
}
|
|
543
|
-
function
|
|
543
|
+
function ue(s) {
|
|
544
544
|
return s * Math.PI / 180;
|
|
545
545
|
}
|
|
546
546
|
function T(s, e, t, i, a, o = 0, n = v.ANIMATIONLOOPMODE_CONSTANT) {
|
|
547
547
|
const r = new De();
|
|
548
|
-
r.setEasingMode(
|
|
548
|
+
r.setEasingMode(ke.EASINGMODE_EASEINOUT);
|
|
549
549
|
const l = new v(
|
|
550
550
|
s,
|
|
551
551
|
e,
|
|
@@ -558,10 +558,10 @@ function T(s, e, t, i, a, o = 0, n = v.ANIMATIONLOOPMODE_CONSTANT) {
|
|
|
558
558
|
value: i
|
|
559
559
|
}), l.setKeys(c), l.setEasingFunction(r), l;
|
|
560
560
|
}
|
|
561
|
-
function
|
|
561
|
+
function Qe(s, e, t) {
|
|
562
562
|
return s < e ? s = t - (e - s) % (t - e) : s = e + (s - e) % (t - e);
|
|
563
563
|
}
|
|
564
|
-
const
|
|
564
|
+
const Ze = {
|
|
565
565
|
albedoTexture: "albedoMap",
|
|
566
566
|
bumpTexture: "normalMap",
|
|
567
567
|
ambientTexture: "ambientMap",
|
|
@@ -571,7 +571,7 @@ const Qe = {
|
|
|
571
571
|
refractionTexture: "refractionMap",
|
|
572
572
|
reflectionTexture: "reflectionMap"
|
|
573
573
|
};
|
|
574
|
-
function
|
|
574
|
+
function $e(s, e, t, i) {
|
|
575
575
|
[
|
|
576
576
|
"albedoTexture",
|
|
577
577
|
"bumpTexture",
|
|
@@ -592,7 +592,7 @@ function Ze(s, e, t, i) {
|
|
|
592
592
|
}), et(s, e);
|
|
593
593
|
}
|
|
594
594
|
function je(s, e, t, i, a) {
|
|
595
|
-
const o =
|
|
595
|
+
const o = Ze[s];
|
|
596
596
|
if (!o)
|
|
597
597
|
throw new Error("Unexpected texture name encountered.");
|
|
598
598
|
const n = e[o], r = n == null ? void 0 : n.fileLink;
|
|
@@ -620,10 +620,10 @@ function Je(s, e, t, i) {
|
|
|
620
620
|
console.error("Failed to apply texture to material: material is null.");
|
|
621
621
|
return;
|
|
622
622
|
}
|
|
623
|
-
s === "opacityTexture" && (e.useAlphaFromAlbedoTexture = !1), s === "metallicTexture" && (e.useRoughnessFromMetallicTextureAlpha = !1, e.useRoughnessFromMetallicTextureGreen = !0, e.useMetallnessFromMetallicTextureBlue = !0), s === "refractionTexture" && (e.subSurface.isRefractionEnabled = !0, e.subSurface.refractionIntensity = t.refractionIntensity || 1), s === "reflectionTexture" && (e.environmentIntensity = t.reflectionIntensity || 1), e[s] = i, s === "emissiveTexture" && (e.emissiveColor = new w(1, 1, 1), e.emissiveIntensity = 1);
|
|
623
|
+
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);
|
|
624
624
|
}
|
|
625
625
|
function et(s, e) {
|
|
626
|
-
s.clearCoat && (s.clearCoat ===
|
|
626
|
+
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));
|
|
627
627
|
}
|
|
628
628
|
class tt {
|
|
629
629
|
constructor(e, t, i) {
|
|
@@ -652,9 +652,9 @@ class tt {
|
|
|
652
652
|
o();
|
|
653
653
|
return;
|
|
654
654
|
}
|
|
655
|
-
const c = new
|
|
655
|
+
const c = new ze(this.scene);
|
|
656
656
|
c.useDefaultLoadingScreen = !1, l.forEach(
|
|
657
|
-
(d) =>
|
|
657
|
+
(d) => $e(
|
|
658
658
|
t,
|
|
659
659
|
d,
|
|
660
660
|
c,
|
|
@@ -751,7 +751,7 @@ class it {
|
|
|
751
751
|
progressHandler: o,
|
|
752
752
|
scene: n
|
|
753
753
|
} = e;
|
|
754
|
-
this.enablePicking = t, this.contextService = i.contextService, this.id =
|
|
754
|
+
this.enablePicking = t, this.contextService = i.contextService, this.id = Ke(), this.previewService = a, this.scene = n, this.variantManager = new tt(
|
|
755
755
|
n,
|
|
756
756
|
this.renameClonedAsset.bind(this),
|
|
757
757
|
this.setBaseModelEnabled.bind(this)
|
|
@@ -897,7 +897,7 @@ class it {
|
|
|
897
897
|
this.queuedModelAnimation = e;
|
|
898
898
|
return;
|
|
899
899
|
}
|
|
900
|
-
this.modelInstance &&
|
|
900
|
+
this.modelInstance && We(
|
|
901
901
|
[
|
|
902
902
|
...this.modelInstance.animationGroups,
|
|
903
903
|
...this.variantManager.getAnimationGroups()
|
|
@@ -982,15 +982,15 @@ class it {
|
|
|
982
982
|
attachPickingHandler(e) {
|
|
983
983
|
e.rootNodes.forEach((t) => {
|
|
984
984
|
t.getChildMeshes(!1).forEach((i) => {
|
|
985
|
-
i.name === "targetcube_t" || i.name === "backgroundShell" || (i.actionManager || (i.actionManager = new
|
|
986
|
-
new
|
|
985
|
+
i.name === "targetcube_t" || i.name === "backgroundShell" || (i.actionManager || (i.actionManager = new R(this.scene)), i.actionManager.registerAction(
|
|
986
|
+
new re(R.OnPointerOverTrigger, (a) => {
|
|
987
987
|
a.meshUnderPointer && i.material && this.materialSelectedObservable.notifyObservers({
|
|
988
988
|
id: i.material.id,
|
|
989
989
|
name: this.stripIdFromName(i.material.name)
|
|
990
990
|
});
|
|
991
991
|
})
|
|
992
992
|
), i.actionManager.registerAction(
|
|
993
|
-
new
|
|
993
|
+
new re(R.OnPointerOutTrigger, () => {
|
|
994
994
|
i.material && this.materialDeselectedObservable.notifyObservers({
|
|
995
995
|
id: i.material.id,
|
|
996
996
|
name: this.stripIdFromName(i.material.name)
|
|
@@ -1019,7 +1019,7 @@ class it {
|
|
|
1019
1019
|
return this.modelReadyToLoadCallbacks.size;
|
|
1020
1020
|
}
|
|
1021
1021
|
configureGlowLayer() {
|
|
1022
|
-
const e = (i) => i instanceof
|
|
1022
|
+
const e = (i) => i instanceof F && i.emissiveTexture !== null;
|
|
1023
1023
|
this.materials.some(e) || this.variantManager.getAllMaterials().some(e) ? this.previewService.getGlowLayerManager().includeMeshes(this.getAllMeshes()) : this.previewService.getGlowLayerManager().removeMeshes(this.getAllMeshes());
|
|
1024
1024
|
}
|
|
1025
1025
|
configureModelInstance(e) {
|
|
@@ -1032,7 +1032,7 @@ class it {
|
|
|
1032
1032
|
this.transformRoot.position = m.Zero(), this.transformRoot.rotationQuaternion = y.Identity(), this.transformRoot.scaling = m.One();
|
|
1033
1033
|
for (const n of e.rootNodes)
|
|
1034
1034
|
n.parent = this.transformRoot;
|
|
1035
|
-
this.transformRoot.position = t, this.transformRoot.rotationQuaternion = i, this.transformRoot.scaling = a, this.canvasPanels = ((o = this.contextService) == null ? void 0 : o.getAll()) || /* @__PURE__ */ new Map(),
|
|
1035
|
+
this.transformRoot.position = t, this.transformRoot.rotationQuaternion = i, this.transformRoot.scaling = a, this.canvasPanels = ((o = this.contextService) == null ? void 0 : o.getAll()) || /* @__PURE__ */ new Map(), qe(
|
|
1036
1036
|
this.materials.concat(this.variantManager.getAllMaterials()),
|
|
1037
1037
|
this.scene,
|
|
1038
1038
|
this.canvasPanels,
|
|
@@ -1050,7 +1050,7 @@ class it {
|
|
|
1050
1050
|
getAllMeshes() {
|
|
1051
1051
|
var e;
|
|
1052
1052
|
return (e = this.modelInstance) == null ? void 0 : e.rootNodes.map(
|
|
1053
|
-
(t) => t.getChildMeshes(!1).filter((i) => i instanceof
|
|
1053
|
+
(t) => t.getChildMeshes(!1).filter((i) => i instanceof Ie)
|
|
1054
1054
|
).flat();
|
|
1055
1055
|
}
|
|
1056
1056
|
async instantiate() {
|
|
@@ -1111,7 +1111,7 @@ class it {
|
|
|
1111
1111
|
}
|
|
1112
1112
|
//#endregion
|
|
1113
1113
|
}
|
|
1114
|
-
class
|
|
1114
|
+
class B extends ge {
|
|
1115
1115
|
constructor(e, t, i, a, o, n, r, l) {
|
|
1116
1116
|
super(
|
|
1117
1117
|
e,
|
|
@@ -1148,7 +1148,7 @@ class D extends ge {
|
|
|
1148
1148
|
this.useFramingBehavior = !0;
|
|
1149
1149
|
const e = this.getFramingBehavior();
|
|
1150
1150
|
e.attach(this), e.framingTime = 0, e.elevationReturnTime = -1, e.zoomStopsAnimation = !1, this.lowerRadiusLimit = null;
|
|
1151
|
-
const t =
|
|
1151
|
+
const t = E(this._scene);
|
|
1152
1152
|
return e.zoomOnBoundingInfo(t.min, t.max), this.wheelPrecision = 100 / this.radius, this.lowerRadiusLimit === null && (this.lowerRadiusLimit = 0.1), this.lastFocus.copyFrom(this.target), e;
|
|
1153
1153
|
}
|
|
1154
1154
|
/**
|
|
@@ -1161,7 +1161,7 @@ class D extends ge {
|
|
|
1161
1161
|
i.framingTime = t || 800;
|
|
1162
1162
|
const a = () => {
|
|
1163
1163
|
e && e();
|
|
1164
|
-
}, o =
|
|
1164
|
+
}, o = E(this._scene), n = o.max.subtract(o.min), r = o.min.add(n.scale(0.5));
|
|
1165
1165
|
this.setRadius(n.length() * 1.5), this.wheelPrecision = 100 / this.radius, this.panningInertia = 0, this.panningOriginTarget.copyFrom(r), this.panDenominator = n.length(), i.zoomOnBoundingInfo(
|
|
1166
1166
|
o.min,
|
|
1167
1167
|
o.max,
|
|
@@ -1196,7 +1196,7 @@ class D extends ge {
|
|
|
1196
1196
|
* @param assignActive If true the camera will be assigned as the active camera on the scene.
|
|
1197
1197
|
*/
|
|
1198
1198
|
static create(e, t, i) {
|
|
1199
|
-
const a =
|
|
1199
|
+
const a = E(e), o = a.max.subtract(a.min), n = a.min.add(o.scale(0.5)), r = new B(
|
|
1200
1200
|
"ProductCamera",
|
|
1201
1201
|
-(Math.PI / 2),
|
|
1202
1202
|
Math.PI / 2,
|
|
@@ -1210,7 +1210,7 @@ class D extends ge {
|
|
|
1210
1210
|
}), i && (e.activeCamera = r), r;
|
|
1211
1211
|
}
|
|
1212
1212
|
}
|
|
1213
|
-
function
|
|
1213
|
+
function E(s) {
|
|
1214
1214
|
if (s.meshes.length === 0)
|
|
1215
1215
|
return {
|
|
1216
1216
|
min: new m(-1, -1, -1),
|
|
@@ -1221,7 +1221,7 @@ function I(s) {
|
|
|
1221
1221
|
}
|
|
1222
1222
|
class st {
|
|
1223
1223
|
constructor(e, t = !1, i = void 0) {
|
|
1224
|
-
this.renderingPipeline = new
|
|
1224
|
+
this.renderingPipeline = new Ve(
|
|
1225
1225
|
"default",
|
|
1226
1226
|
t,
|
|
1227
1227
|
e,
|
|
@@ -1237,27 +1237,27 @@ class st {
|
|
|
1237
1237
|
return this.currentConfiguration;
|
|
1238
1238
|
}
|
|
1239
1239
|
setConfiguration(e) {
|
|
1240
|
-
var t, i, a, o, n, r, l, c, d, u, g, p, b,
|
|
1240
|
+
var t, i, a, o, n, r, l, c, d, u, g, p, b, D, k, z, V, G, N, H, q, _, K, W, U, Y, Q, Z, $, j, X, J, ee;
|
|
1241
1241
|
if (this.renderingPipeline.isSupported) {
|
|
1242
|
-
if (this.renderingPipeline.samples = ((t = e.antiAliasing) == null ? void 0 : t.samples) ?? h.antiAliasing.samples, this.renderingPipeline.fxaaEnabled = ((i = e.antiAliasing) == null ? void 0 : i.fxaaEnabled) ?? h.antiAliasing.fxaaEnabled, this.renderingPipeline.bloomEnabled = ((a = e.bloom) == null ? void 0 : a.enabled) ?? h.bloom.enabled, this.renderingPipeline.bloomKernel = ((o = e.bloom) == null ? void 0 : o.kernel) ?? h.bloom.kernel, this.renderingPipeline.bloomScale = ((n = e.bloom) == null ? void 0 : n.scale) ?? h.bloom.scale, this.renderingPipeline.bloomThreshold = ((r = e.bloom) == null ? void 0 : r.threshold) ?? h.bloom.threshold, this.renderingPipeline.bloomWeight = ((l = e.bloom) == null ? void 0 : l.weight) ?? h.bloom.weight, this.renderingPipeline.chromaticAberrationEnabled = ((c = e.chromaticAberration) == null ? void 0 : c.enabled) ?? h.chromaticAberration.enabled, this.renderingPipeline.chromaticAberration.aberrationAmount = ((d = e.chromaticAberration) == null ? void 0 : d.aberrationAmount) ?? h.chromaticAberration.aberrationAmount, this.renderingPipeline.chromaticAberration.radialIntensity = ((u = e.chromaticAberration) == null ? void 0 : u.radialIntensity) ?? h.chromaticAberration.radialIntensity, this.renderingPipeline.chromaticAberration.direction = (g = e.chromaticAberration) != null && g.direction ? new
|
|
1242
|
+
if (this.renderingPipeline.samples = ((t = e.antiAliasing) == null ? void 0 : t.samples) ?? h.antiAliasing.samples, this.renderingPipeline.fxaaEnabled = ((i = e.antiAliasing) == null ? void 0 : i.fxaaEnabled) ?? h.antiAliasing.fxaaEnabled, this.renderingPipeline.bloomEnabled = ((a = e.bloom) == null ? void 0 : a.enabled) ?? h.bloom.enabled, this.renderingPipeline.bloomKernel = ((o = e.bloom) == null ? void 0 : o.kernel) ?? h.bloom.kernel, this.renderingPipeline.bloomScale = ((n = e.bloom) == null ? void 0 : n.scale) ?? h.bloom.scale, this.renderingPipeline.bloomThreshold = ((r = e.bloom) == null ? void 0 : r.threshold) ?? h.bloom.threshold, this.renderingPipeline.bloomWeight = ((l = e.bloom) == null ? void 0 : l.weight) ?? h.bloom.weight, this.renderingPipeline.chromaticAberrationEnabled = ((c = e.chromaticAberration) == null ? void 0 : c.enabled) ?? h.chromaticAberration.enabled, this.renderingPipeline.chromaticAberration.aberrationAmount = ((d = e.chromaticAberration) == null ? void 0 : d.aberrationAmount) ?? h.chromaticAberration.aberrationAmount, this.renderingPipeline.chromaticAberration.radialIntensity = ((u = e.chromaticAberration) == null ? void 0 : u.radialIntensity) ?? h.chromaticAberration.radialIntensity, this.renderingPipeline.chromaticAberration.direction = (g = e.chromaticAberration) != null && g.direction ? new ie(
|
|
1243
1243
|
e.chromaticAberration.direction.x,
|
|
1244
1244
|
e.chromaticAberration.direction.y
|
|
1245
|
-
) : new
|
|
1245
|
+
) : new ie(
|
|
1246
1246
|
h.chromaticAberration.direction.x,
|
|
1247
1247
|
h.chromaticAberration.direction.y
|
|
1248
|
-
), this.renderingPipeline.imageProcessing.colorCurvesEnabled = ((p = e.colorCurves) == null ? void 0 : p.enabled) ?? h.colorCurves.enabled, this.renderingPipeline.imageProcessing.colorCurves = e.colorCurves ? this.updateColorCurve(e.colorCurves) : new
|
|
1248
|
+
), this.renderingPipeline.imageProcessing.colorCurvesEnabled = ((p = e.colorCurves) == null ? void 0 : p.enabled) ?? h.colorCurves.enabled, this.renderingPipeline.imageProcessing.colorCurves = e.colorCurves ? this.updateColorCurve(e.colorCurves) : new ae(), this.renderingPipeline.depthOfFieldEnabled = ((b = e.depthOfField) == null ? void 0 : b.enabled) ?? h.depthOfField.enabled, e.depthOfField)
|
|
1249
1249
|
switch (e.depthOfField.blurLevel ?? h.depthOfField.blurLevel) {
|
|
1250
1250
|
case "Low":
|
|
1251
|
-
this.renderingPipeline.depthOfFieldBlurLevel =
|
|
1251
|
+
this.renderingPipeline.depthOfFieldBlurLevel = A.Low;
|
|
1252
1252
|
break;
|
|
1253
1253
|
case "Medium":
|
|
1254
|
-
this.renderingPipeline.depthOfFieldBlurLevel =
|
|
1254
|
+
this.renderingPipeline.depthOfFieldBlurLevel = A.Medium;
|
|
1255
1255
|
break;
|
|
1256
1256
|
case "High":
|
|
1257
|
-
this.renderingPipeline.depthOfFieldBlurLevel =
|
|
1257
|
+
this.renderingPipeline.depthOfFieldBlurLevel = A.High;
|
|
1258
1258
|
break;
|
|
1259
1259
|
}
|
|
1260
|
-
if (this.renderingPipeline.depthOfField.focalLength = ((
|
|
1260
|
+
if (this.renderingPipeline.depthOfField.focalLength = ((D = e.depthOfField) == null ? void 0 : D.focalLength) ?? h.depthOfField.focalLength, this.renderingPipeline.depthOfField.fStop = ((k = e.depthOfField) == null ? void 0 : k.fStop) ?? h.depthOfField.fStop, this.renderingPipeline.depthOfField.focusDistance = ((z = e.depthOfField) == null ? void 0 : z.focusDistance) ?? h.depthOfField.focusDistance, this.renderingPipeline.depthOfField.lensSize = ((V = e.depthOfField) == null ? void 0 : V.lensSize) ?? h.depthOfField.lensSize, this.renderingPipeline.grainEnabled = ((G = e.grain) == null ? void 0 : G.enabled) ?? h.grain.enabled, this.renderingPipeline.grain.animated = ((N = e.grain) == null ? void 0 : N.animated) ?? h.grain.animated, this.renderingPipeline.grain.intensity = ((H = e.grain) == null ? void 0 : H.intensity) ?? h.grain.intensity, this.renderingPipeline.imageProcessing.contrast = ((q = e.misc) == null ? void 0 : q.contrast) ?? h.misc.contrast, this.renderingPipeline.imageProcessing.exposure = ((_ = e.misc) == null ? void 0 : _.exposure) ?? h.misc.exposure, this.renderingPipeline.imageProcessing.toneMappingEnabled = ((K = e.misc) == null ? void 0 : K.toneMappingEnabled) ?? h.misc.toneMappingEnabled, this.renderingPipeline.imageProcessing.toneMappingEnabled)
|
|
1261
1261
|
switch (e.misc.toneMappingType ?? h.misc.toneMappingType) {
|
|
1262
1262
|
case "Standard":
|
|
1263
1263
|
this.renderingPipeline.imageProcessing.toneMappingType = P.TONEMAPPING_STANDARD;
|
|
@@ -1266,8 +1266,8 @@ class st {
|
|
|
1266
1266
|
this.renderingPipeline.imageProcessing.toneMappingType = P.TONEMAPPING_ACES;
|
|
1267
1267
|
break;
|
|
1268
1268
|
}
|
|
1269
|
-
if (this.renderingPipeline.sharpenEnabled = ((W = e.sharpen) == null ? void 0 : W.enabled) ?? h.sharpen.enabled, this.renderingPipeline.sharpen.colorAmount = ((
|
|
1270
|
-
switch (((
|
|
1269
|
+
if (this.renderingPipeline.sharpenEnabled = ((W = e.sharpen) == null ? void 0 : W.enabled) ?? h.sharpen.enabled, this.renderingPipeline.sharpen.colorAmount = ((U = e.sharpen) == null ? void 0 : U.colorAmount) ?? h.sharpen.colorAmount, this.renderingPipeline.sharpen.edgeAmount = ((Y = e.sharpen) == null ? void 0 : Y.edgeAmount) ?? h.sharpen.edgeAmount, this.renderingPipeline.imageProcessing.vignetteEnabled = ((Q = e.vignette) == null ? void 0 : Q.enabled) ?? h.vignette.enabled, (Z = e.vignette) != null && Z.center ? (this.renderingPipeline.imageProcessing.vignetteCenterX = e.vignette.center.x, this.renderingPipeline.imageProcessing.vignetteCenterY = e.vignette.center.y) : (this.renderingPipeline.imageProcessing.vignetteCenterX = h.vignette.center.x, this.renderingPipeline.imageProcessing.vignetteCenterY = h.vignette.center.y), e.vignette)
|
|
1270
|
+
switch ((($ = e.vignette) == null ? void 0 : $.blendMode) ?? h.vignette.blendMode) {
|
|
1271
1271
|
case "Multiply":
|
|
1272
1272
|
this.renderingPipeline.imageProcessing.vignetteBlendMode = P.VIGNETTEMODE_MULTIPLY;
|
|
1273
1273
|
break;
|
|
@@ -1275,26 +1275,26 @@ class st {
|
|
|
1275
1275
|
this.renderingPipeline.imageProcessing.vignetteBlendMode = P.VIGNETTEMODE_OPAQUE;
|
|
1276
1276
|
break;
|
|
1277
1277
|
}
|
|
1278
|
-
(
|
|
1278
|
+
(j = e.vignette) != null && j.colorRgba ? this.renderingPipeline.imageProcessing.vignetteColor = new f(
|
|
1279
1279
|
e.vignette.colorRgba.r,
|
|
1280
1280
|
e.vignette.colorRgba.g,
|
|
1281
1281
|
e.vignette.colorRgba.b,
|
|
1282
1282
|
e.vignette.colorRgba.a
|
|
1283
|
-
) : (
|
|
1283
|
+
) : (X = e.vignette) != null && X.colorHex ? this.renderingPipeline.imageProcessing.vignetteColor = f.FromHexString(e.vignette.colorHex) : this.renderingPipeline.imageProcessing.vignetteColor = new f(
|
|
1284
1284
|
h.vignette.colorRgba.r,
|
|
1285
1285
|
h.vignette.colorRgba.g,
|
|
1286
1286
|
h.vignette.colorRgba.b,
|
|
1287
1287
|
h.vignette.colorRgba.a
|
|
1288
|
-
), this.renderingPipeline.imageProcessing.vignetteStretch = ((
|
|
1288
|
+
), this.renderingPipeline.imageProcessing.vignetteStretch = ((J = e.vignette) == null ? void 0 : J.stretch) ?? h.vignette.stretch, this.renderingPipeline.imageProcessing.vignetteWeight = ((ee = e.vignette) == null ? void 0 : ee.weight) ?? h.vignette.weight, this.renderingPipeline.prepare(), this.currentConfiguration = e;
|
|
1289
1289
|
}
|
|
1290
1290
|
}
|
|
1291
1291
|
updateColorCurve(e) {
|
|
1292
|
-
const t = new
|
|
1292
|
+
const t = new ae();
|
|
1293
1293
|
return t.globalDensity = e.globalDensity ?? t.globalDensity, t.globalExposure = e.globalExposure ?? t.globalExposure, t.globalHue = e.globalHue ?? t.globalHue, t.globalSaturation = e.globalSaturation ?? t.globalSaturation, t.highlightsDensity = e.highlightsDensity ?? t.highlightsDensity, t.highlightsExposure = e.highlightsExposure ?? t.highlightsExposure, t.highlightsHue = e.highlightsHue ?? t.highlightsHue, t.highlightsSaturation = e.highlightsSaturation ?? t.highlightsSaturation, t.midtonesDensity = e.midtonesDensity ?? t.midtonesDensity, t.midtonesExposure = e.midtonesExposure ?? t.midtonesExposure, t.midtonesHue = e.midtonesHue ?? t.midtonesHue, t.midtonesSaturation = e.midtonesSaturation ?? t.midtonesSaturation, t.shadowsDensity = e.shadowsDensity ?? t.shadowsDensity, t.shadowsExposure = e.shadowsExposure ?? t.shadowsExposure, t.shadowsHue = e.shadowsHue ?? t.shadowsHue, t.shadowsSaturation = e.shadowsSaturation ?? t.shadowsSaturation, t;
|
|
1294
1294
|
}
|
|
1295
1295
|
}
|
|
1296
|
-
|
|
1297
|
-
return new
|
|
1296
|
+
Te.GLTFLoader.RegisterExtension("glbPostProcessor", function(s) {
|
|
1297
|
+
return new Ne(s);
|
|
1298
1298
|
});
|
|
1299
1299
|
fe.OnPluginActivatedObservable.add((s) => {
|
|
1300
1300
|
if (s.name === "gltf") {
|
|
@@ -1308,14 +1308,14 @@ function O(s) {
|
|
|
1308
1308
|
function L(s) {
|
|
1309
1309
|
return { x: s.x, y: s.y, z: s.z };
|
|
1310
1310
|
}
|
|
1311
|
-
class
|
|
1311
|
+
class Wt {
|
|
1312
1312
|
constructor(e) {
|
|
1313
1313
|
var l;
|
|
1314
1314
|
this.focusLostNotified = !1, this.focusLostObservable = new C(), this.modelLoadEventCallbacks = [], this.modelContainers = /* @__PURE__ */ new Map(), this.plugins = [], this.initComplete = !1, this.renderLoop = () => {
|
|
1315
1315
|
this.engine.views && (this.modelContainers.forEach((c) => {
|
|
1316
1316
|
c.updateDynamicTextures();
|
|
1317
1317
|
}), this.scene.render(), !this.camera.target.equalsWithEpsilon(this.camera.lastFocus, 0.1) && !this.focusLostNotified && (this.focusLostObservable.notifyObservers(void 0), this.focusLostNotified = !0), this.screenshotPrepareResolve && (this.screenshotPrepareResolve(), this.screenshotPrepareResolve = void 0));
|
|
1318
|
-
}, this.configuration = new
|
|
1318
|
+
}, this.configuration = new oe(e);
|
|
1319
1319
|
const i = (() => {
|
|
1320
1320
|
if (!(e != null && e.noRender))
|
|
1321
1321
|
return this.configuration.createCanvas();
|
|
@@ -1327,7 +1327,10 @@ class Kt {
|
|
|
1327
1327
|
fallbackUrl: `https://www.gstatic.com/draco/versioned/decoders/${a}/draco_decoder_gltf.js`
|
|
1328
1328
|
}
|
|
1329
1329
|
}, i && (i.getContext("webgl2") || i.getContext("webgl"));
|
|
1330
|
-
const o = console.log
|
|
1330
|
+
const o = console.log;
|
|
1331
|
+
console.log = () => {
|
|
1332
|
+
};
|
|
1333
|
+
const n = i ? new pe(i, !0, {
|
|
1331
1334
|
adaptToDeviceRatio: !0,
|
|
1332
1335
|
limitDeviceRatio: 2,
|
|
1333
1336
|
premultipliedAlpha: !1,
|
|
@@ -1336,18 +1339,18 @@ class Kt {
|
|
|
1336
1339
|
stencil: this.configuration.highlights.enabled,
|
|
1337
1340
|
forceSRGBBufferSupportState: !0
|
|
1338
1341
|
}) : new Ce();
|
|
1339
|
-
console.log = o, n.hideLoadingUI(), window.addEventListener("resize", this.fireResizeEvent.bind(this)), this.engine = n, this.scene = new Pe(n), this.scene.autoClear = !0, this.scene.autoClearDepthAndStencil = !0, this.camera =
|
|
1342
|
+
console.log = o, n.hideLoadingUI(), window.addEventListener("resize", this.fireResizeEvent.bind(this)), this.engine = n, this.scene = new Pe(n), 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(
|
|
1340
1343
|
this.scene,
|
|
1341
1344
|
!1,
|
|
1342
1345
|
this.camera
|
|
1343
1346
|
), this.scene.clearColor = this.configuration.scene.clearColor;
|
|
1344
|
-
const r =
|
|
1347
|
+
const r = te.CreateFromPrefilteredData(
|
|
1345
1348
|
this.configuration.scene.environment.file,
|
|
1346
1349
|
this.scene
|
|
1347
1350
|
);
|
|
1348
1351
|
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(
|
|
1349
1352
|
this.configuration.options.renderingPipelineConfiguration
|
|
1350
|
-
) : (this.scene.imageProcessingConfiguration.exposure = this.configuration.lighting.exposure, this.scene.imageProcessingConfiguration.contrast = this.configuration.lighting.contrast), this.glowLayerManager = new
|
|
1353
|
+
) : (this.scene.imageProcessingConfiguration.exposure = this.configuration.lighting.exposure, this.scene.imageProcessingConfiguration.contrast = this.configuration.lighting.contrast), this.glowLayerManager = new He(
|
|
1351
1354
|
this.scene,
|
|
1352
1355
|
this.configuration.emissiveGlowIntensity
|
|
1353
1356
|
), this.initPromise = new Promise((c) => {
|
|
@@ -1384,7 +1387,7 @@ class Kt {
|
|
|
1384
1387
|
}
|
|
1385
1388
|
registerView(e) {
|
|
1386
1389
|
const t = e.height, i = e.width;
|
|
1387
|
-
this.engine.registerView(e, void 0, !0), e.setAttribute("height", t.toString()), e.setAttribute("width", i.toString()), this.orbitEnabled() || this.setCameraState(
|
|
1390
|
+
this.engine.registerView(e, void 0, !0), e.setAttribute("height", t.toString()), e.setAttribute("width", i.toString()), this.orbitEnabled() || this.setCameraState(I.Pan), this.reattachControls(e);
|
|
1388
1391
|
}
|
|
1389
1392
|
getNumViewports() {
|
|
1390
1393
|
var e;
|
|
@@ -1398,14 +1401,14 @@ class Kt {
|
|
|
1398
1401
|
}
|
|
1399
1402
|
executeCameraAnimation(e) {
|
|
1400
1403
|
if (!this.camera || this.scene.activeCamera !== this.camera) {
|
|
1401
|
-
this.
|
|
1404
|
+
this.queuedCameraAnimation = e;
|
|
1402
1405
|
return;
|
|
1403
1406
|
}
|
|
1404
|
-
|
|
1407
|
+
Ye(
|
|
1405
1408
|
this.scene,
|
|
1406
1409
|
this.scene.activeCamera,
|
|
1407
1410
|
e
|
|
1408
|
-
)
|
|
1411
|
+
);
|
|
1409
1412
|
}
|
|
1410
1413
|
getCameraPose() {
|
|
1411
1414
|
if (this.scene && this.camera)
|
|
@@ -1433,7 +1436,7 @@ class Kt {
|
|
|
1433
1436
|
throw new Error(
|
|
1434
1437
|
"No views attached, camera state requires a view to attach controls onto."
|
|
1435
1438
|
);
|
|
1436
|
-
e ===
|
|
1439
|
+
e === I.Orbit ? this.reattachControls(this.engine.views[0].target, 2) : this.reattachControls(this.engine.views[0].target, 0);
|
|
1437
1440
|
}
|
|
1438
1441
|
animateToLastCameraFocus() {
|
|
1439
1442
|
return new Promise((e) => {
|
|
@@ -1529,7 +1532,7 @@ class Kt {
|
|
|
1529
1532
|
progressHandler: t
|
|
1530
1533
|
});
|
|
1531
1534
|
return i.getInitializationPromise().then(() => {
|
|
1532
|
-
this.modelContainers.size <= 1 && this.camera.rerunFramingBehavior(void 0, 1),
|
|
1535
|
+
this.modelContainers.size <= 1 && this.camera.rerunFramingBehavior(void 0, 1), Ue(this.scene), this.queuedCameraAnimation && (this.executeCameraAnimation(this.queuedCameraAnimation), this.queuedCameraAnimation = void 0);
|
|
1533
1536
|
}), this.configuration.highlights.enabled && (i.registerMaterialSelectedCallback((a) => {
|
|
1534
1537
|
this.setHighlights([a]);
|
|
1535
1538
|
}), i.registerMaterialDeselectedCallback(() => {
|
|
@@ -1572,13 +1575,13 @@ class Kt {
|
|
|
1572
1575
|
* Flips a transform around the origin.
|
|
1573
1576
|
*/
|
|
1574
1577
|
flipTransform(e, t, i) {
|
|
1575
|
-
const a =
|
|
1578
|
+
const a = se.Compose(
|
|
1576
1579
|
O(i || { x: 1, y: 1, z: 1 }),
|
|
1577
1580
|
y.FromEulerVector(
|
|
1578
1581
|
O(t || { x: 0, y: 0, z: 0 })
|
|
1579
1582
|
),
|
|
1580
1583
|
O(e || { x: 0, y: 0, z: 0 })
|
|
1581
|
-
), o =
|
|
1584
|
+
), o = se.RotationAxis(m.Up(), Math.PI), n = a.multiply(o), r = m.Zero(), l = y.Identity(), c = m.Zero();
|
|
1582
1585
|
return n.decompose(c, l, r), l.multiplyInPlace(y.FromEulerAngles(0, Math.PI, 0)), {
|
|
1583
1586
|
position: L(r),
|
|
1584
1587
|
rotation: L(l.toEulerAngles()),
|
|
@@ -1587,10 +1590,10 @@ class Kt {
|
|
|
1587
1590
|
}
|
|
1588
1591
|
updatePreviewOptions(e) {
|
|
1589
1592
|
var a;
|
|
1590
|
-
const t = new
|
|
1593
|
+
const t = new oe(e);
|
|
1591
1594
|
this.configuration.highlights.enabled !== t.highlights.enabled && this.engine.setStencilBuffer(t.highlights.enabled), this.scene.clearColor = t.scene.clearColor;
|
|
1592
1595
|
let i = this.scene.environmentTexture;
|
|
1593
|
-
this.configuration.scene.environment.file !== t.scene.environment.file && (i =
|
|
1596
|
+
this.configuration.scene.environment.file !== t.scene.environment.file && (i = te.CreateFromPrefilteredData(
|
|
1594
1597
|
t.scene.environment.file,
|
|
1595
1598
|
this.scene
|
|
1596
1599
|
), i.rotationY = this.configuration.scene.environment.rotationY, this.scene.environmentTexture = i), i.rotationY = t.scene.environment.rotationY, this.scene.environmentIntensity = t.scene.environment.intensity, (a = t.options) != null && a.renderingPipelineConfiguration ? this.renderingPipeline.setConfiguration(
|
|
@@ -1612,10 +1615,10 @@ class Kt {
|
|
|
1612
1615
|
}
|
|
1613
1616
|
}
|
|
1614
1617
|
export {
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
+
S as MaterialEffectMode,
|
|
1619
|
+
I as ProductCameraRig,
|
|
1620
|
+
Ge as REFLECTION_PROBE_RESOLUTION,
|
|
1618
1621
|
x as RenderingConfiguration,
|
|
1619
|
-
|
|
1622
|
+
Wt as SpiffCommerce3DPreviewService,
|
|
1620
1623
|
h as renderingPipelineDefaults
|
|
1621
1624
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(h,y){typeof exports=="object"&&typeof module<"u"?y(exports,require("@babylonjs/core/Cameras/arcRotateCamera"),require("@babylonjs/core/Engines/engine"),require("@babylonjs/core/Engines/nullEngine"),require("@babylonjs/core/Layers/highlightLayer"),require("@babylonjs/core/Loading/sceneLoader"),require("@babylonjs/core/Materials/Textures/cubeTexture"),require("@babylonjs/core/Maths/math.color"),require("@babylonjs/core/Maths/math.vector"),require("@babylonjs/core/Meshes/Compression/dracoCompression"),require("@babylonjs/core/Misc/observable"),require("@babylonjs/core/Misc/tools"),require("@babylonjs/core/scene"),require("@babylonjs/loaders/glTF"),require("@babylonjs/core/Materials/PBR/pbrMaterial"),require("@babylonjs/core/Materials/Textures/mirrorTexture"),require("@babylonjs/core/Maths/math"),require("@babylonjs/core/Probes/reflectionProbe"),require("@babylonjs/core/Layers/glowLayer"),require("@babylonjs/core/Actions/actionManager"),require("@babylonjs/core/Actions/directActions"),require("@babylonjs/core/Meshes/mesh"),require("@babylonjs/core/Meshes/transformNode"),require("@babylonjs/core/Materials/Textures/dynamicTexture"),require("@babylonjs/core/Materials/Textures/texture"),require("@babylonjs/core/Animations/animation"),require("@babylonjs/core/Animations/easing"),require("@babylonjs/core/Misc/assetsManager"),require("@babylonjs/core/Materials/colorCurves"),require("@babylonjs/core/Materials/imageProcessingConfiguration"),require("@babylonjs/core/PostProcesses/RenderPipeline"),require("@babylonjs/core/PostProcesses/depthOfFieldEffect"),require("@babylonjs/core/Rendering/depthRendererSceneComponent"),require("@babylonjs/core/Engines/Extensions/engine.views"),require("@babylonjs/core/Meshes/instancedMesh"),require("@babylonjs/core/Materials/Textures/Loaders/ddsTextureLoader"),require("@babylonjs/core/Materials/Textures/Loaders/envTextureLoader"),require("@babylonjs/core/Materials/Textures/Loaders/ktxTextureLoader"),require("@babylonjs/core/Animations/animatable"),require("@babylonjs/core/Misc/screenshotTools"),require("@babylonjs/core/Rendering/boundingBoxRenderer"),require("@babylonjs/loaders/glTF/2.0/Extensions")):typeof define=="function"&&define.amd?define(["exports","@babylonjs/core/Cameras/arcRotateCamera","@babylonjs/core/Engines/engine","@babylonjs/core/Engines/nullEngine","@babylonjs/core/Layers/highlightLayer","@babylonjs/core/Loading/sceneLoader","@babylonjs/core/Materials/Textures/cubeTexture","@babylonjs/core/Maths/math.color","@babylonjs/core/Maths/math.vector","@babylonjs/core/Meshes/Compression/dracoCompression","@babylonjs/core/Misc/observable","@babylonjs/core/Misc/tools","@babylonjs/core/scene","@babylonjs/loaders/glTF","@babylonjs/core/Materials/PBR/pbrMaterial","@babylonjs/core/Materials/Textures/mirrorTexture","@babylonjs/core/Maths/math","@babylonjs/core/Probes/reflectionProbe","@babylonjs/core/Layers/glowLayer","@babylonjs/core/Actions/actionManager","@babylonjs/core/Actions/directActions","@babylonjs/core/Meshes/mesh","@babylonjs/core/Meshes/transformNode","@babylonjs/core/Materials/Textures/dynamicTexture","@babylonjs/core/Materials/Textures/texture","@babylonjs/core/Animations/animation","@babylonjs/core/Animations/easing","@babylonjs/core/Misc/assetsManager","@babylonjs/core/Materials/colorCurves","@babylonjs/core/Materials/imageProcessingConfiguration","@babylonjs/core/PostProcesses/RenderPipeline","@babylonjs/core/PostProcesses/depthOfFieldEffect","@babylonjs/core/Rendering/depthRendererSceneComponent","@babylonjs/core/Engines/Extensions/engine.views","@babylonjs/core/Meshes/instancedMesh","@babylonjs/core/Materials/Textures/Loaders/ddsTextureLoader","@babylonjs/core/Materials/Textures/Loaders/envTextureLoader","@babylonjs/core/Materials/Textures/Loaders/ktxTextureLoader","@babylonjs/core/Animations/animatable","@babylonjs/core/Misc/screenshotTools","@babylonjs/core/Rendering/boundingBoxRenderer","@babylonjs/loaders/glTF/2.0/Extensions"],y):(h=typeof globalThis<"u"?globalThis:h||self,y(h.Preview={},h.arcRotateCamera,h.engine,h.nullEngine,h.highlightLayer,h.sceneLoader,h.cubeTexture,h.math_color,h.math_vector,h.dracoCompression,h.observable,h.tools,h.scene,h.glTF,h.pbrMaterial,h.mirrorTexture,h.math,h.reflectionProbe,h.glowLayer,h.actionManager,h.directActions,h.mesh,h.transformNode,h.dynamicTexture,h.texture,h.animation,h.easing,h.assetsManager,h.colorCurves,h.imageProcessingConfiguration,h.RenderPipeline,h.depthOfFieldEffect))})(this,function(h,y,q,we,ve,G,N,p,g,Ce,M,Me,xe,Pe,O,Te,P,Ee,Re,I,V,Ae,Le,Oe,Ie,w,k,Se,z,T,Fe,S){"use strict";var E=(s=>(s[s.Orbit=0]="Orbit",s[s.Pan=1]="Pan",s))(E||{}),R=(s=>(s.None="None",s.RemoveWhenSelected="RemoveWhenSelected",s.ApplyWhenSelected="ApplyWhenSelected",s))(R||{});class H{constructor(e){this.getSceneClearColor=()=>{var i,a,o,n;const t=(i=this.customOptions)!=null&&i.transparentBackground||(a=this.customOptions)!=null&&a.backgroundImage?0:1;if(this.customOptions&&((o=this.customOptions)!=null&&o.transparentBackground)||(n=this.customOptions)!=null&&n.backgroundImage)return new p.Color4(0,0,0,t).toLinearSpace();if(this.customOptions&&this.customOptions.backgroundColor){const r=p.Color3.FromHexString(this.customOptions.backgroundColor);return new p.Color4(r.r,r.g,r.b,t).toLinearSpace()}return new p.Color4(.98,.98,.98,t).toLinearSpace()},this.highlightColorFromConfig=()=>this.customOptions&&this.customOptions.highlightColor?this.hexToColor4(this.customOptions.highlightColor):new p.Color4(.98,.98,.98,1).toLinearSpace(),this.hexToColor4=(t,i=1)=>{const a=p.Color3.FromHexString(t);return new p.Color4(a.r,a.g,a.b,i).toLinearSpace()},this.customOptions=e}createCanvas(){var e;return(e=this.customOptions)!=null&&e.createCanvas?this.customOptions.createCanvas():document.createElement("canvas")}get options(){return this.customOptions}get scene(){var e,t,i,a,o;return{clearColor:this.getSceneClearColor(),transparentBackground:((e=this.customOptions)==null?void 0:e.transparentBackground)||((t=this.customOptions)==null?void 0:t.backgroundImage),environment:{file:((i=this.customOptions)==null?void 0:i.environmentFile)??"assets/model-viewer/default.env",intensity:((a=this.customOptions)==null?void 0:a.environmentIntensity)??1,rotationY:(((o=this.customOptions)==null?void 0:o.environmentRotationY)??0)*(Math.PI/180)}}}get camera(){var e,t,i,a,o,n,r,l,d,u,m,f,b;return{autoOrientation:((e=this.customOptions)==null?void 0:e.disableAutomaticOrientation)??!0,autoRotation:{enabled:((t=this.customOptions)==null?void 0:t.autoRotation)??!1,idleTimeMs:((i=this.customOptions)==null?void 0:i.idleTimeBeforeRotation)??5e3},limits:{min:{alpha:(a=this.customOptions)!=null&&a.lowerAlphaLimitDeg?((o=this.customOptions)==null?void 0:o.lowerAlphaLimitDeg)*Math.PI/180:void 0,beta:(n=this.customOptions)!=null&&n.lowerBetaLimitDeg?((r=this.customOptions)==null?void 0:r.lowerBetaLimitDeg)*Math.PI/180:void 0,radius:(l=this.customOptions)==null?void 0:l.minZoomOverride},max:{alpha:(d=this.customOptions)!=null&&d.upperAlphaLimitDeg?((u=this.customOptions)==null?void 0:u.upperAlphaLimitDeg)*Math.PI/180:void 0,beta:(m=this.customOptions)!=null&&m.upperBetaLimitDeg?((f=this.customOptions)==null?void 0:f.upperBetaLimitDeg)*Math.PI/180:void 0,radius:(b=this.customOptions)==null?void 0:b.maxZoomOverride}}}}get highlights(){var e;return{enabled:((e=this.customOptions)==null?void 0:e.highlightOnMaterialHover)??!1,color:this.highlightColorFromConfig()}}get lighting(){var e,t,i,a;return{exposure:((t=(e=this.customOptions)==null?void 0:e.lighting)==null?void 0:t.exposure)??.9,contrast:((a=(i=this.customOptions)==null?void 0:i.lighting)==null?void 0:a.contrast)??1.6}}get emissiveGlowIntensity(){var e;return((e=this.customOptions)==null?void 0:e.emissiveGlowIntensity)??.5}}class v{static getDynamicTextureResolution(){return this.getIsMobile()||!v.offscreenRenderingSupported()?{width:1024,height:1024}:{width:2048,height:2048}}static shouldMipMap(){return!0}static offscreenRenderingSupported(){return navigator.userAgent.includes("SamsungBrowser")?!1:!!window.Worker&&!!window.OffscreenCanvas}static getMirrorTextureResolution(){return this.getIsMobile()?512:1024}static getIsMobile(){try{return typeof window>"u"||!window.navigator?!1:/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(window.navigator.userAgent)||window.innerWidth<=480}catch{return!1}}}const U=128,c={antiAliasing:{samples:4,fxaaEnabled:!1},bloom:{enabled:!1,kernel:64,scale:.5,threshold:.9,weight:.15},chromaticAberration:{enabled:!1,aberrationAmount:30,direction:{x:0,y:0},radialIntensity:0},colorCurves:{enabled:!1},depthOfField:{enabled:!1,blurLevel:"Low",focalLength:50,focusDistance:2e3,fStop:1.4,lensSize:50},grain:{enabled:!1,animated:!1,intensity:30},misc:{contrast:1,exposure:1,toneMappingEnabled:!1,toneMappingType:"Standard"},sharpen:{enabled:!1,colorAmount:1,edgeAmount:.3},vignette:{enabled:!1,blendMode:"Multiply",cameraFov:.5,center:{x:0,y:0},colorHex:"#000000ff",colorRgba:{r:0,g:0,b:0,a:1},stretch:0,weight:1}};class Be{constructor(e){this.name="glbPostProcessor",this.enabled=!0,this.loader=e}onReady(){this.applyReflections(this.loader.babylonScene)}loadNodeAsync(e,t,i){return this.loader.loadNodeAsync(e,t,function(a){t.extras&&Object.keys(t.extras).forEach(o=>{const n=t.extras[o];a.metadata[o]=n}),i(a)})}async loadMaterialPropertiesAsync(e,t,i){await this.loader.loadMaterialPropertiesAsync(e,t,i),this.enableMaterialExtrasIfRequired(t,i),i.needDepthPrePass=!0}dispose(){}enableMaterialExtrasIfRequired(e,t){if(!(!e.extras||!(t instanceof O.PBRMaterial))){if(e.extras.sheen){const i=t;i.sheen.isEnabled=!0,i.sheen.intensity=e.extras.sheen}if(e.extras.translucency){const i=t;i.subSurface.isTranslucencyEnabled=!0,i.subSurface.translucencyIntensity=e.extras.translucency,e.extras.translucencyR&&e.extras.translucencyG&&e.extras.translucencyB&&(i.subSurface.tintColor=new P.Color3(e.extras.translucencyR,e.extras.translucencyG,e.extras.translucencyB))}if(e.extras.refractionIOR){const i=t;i.subSurface.isRefractionEnabled=!0,i.subSurface.volumeIndexOfRefraction=e.extras.refractionIOR}if(e.extras.useDepthPrePass){const i=t;i.needDepthPrePass=!0,i.forceIrradianceInFragment=!0}if(e.extras.useParallax){const i=t;i.useParallax=!0,i.useParallaxOcclusion=!0,i.parallaxScaleBias=e.extras.useParallax}}}applyReflections(e){function t(o){const n=[];return o.transformNodes.forEach(r=>{r.metadata&&r.metadata.reflective&&n.push(...r.getChildMeshes())}),o.meshes.forEach(r=>{r.metadata&&r.metadata.reflective&&!n.includes(r)&&n.push(r)}),n}function i(o,n=1){const r=o.material;if(!r)return;const l=new Te.MirrorTexture("mirror",v.getMirrorTextureResolution(),e,!0);l.renderList=t(e);const d=o.getVerticesData("normal");if(!d)throw new Error("Mirror attribute specified on: "+o.name+"But no normals exist to generate a mirror from!");o.computeWorldMatrix(!0);const u=o.getWorldMatrix(),m=P.Vector3.TransformNormal(new P.Vector3(d[0],d[1],d[2]),u).normalize(),f=P.Plane.FromPositionAndNormal(o.position,m.scale(-1));l.mirrorPlane=f,l.level=n,r.reflectionTexture=l}function a(o){const n=o.material,r=new Ee.ReflectionProbe("probe-"+n.name,U,e);r.attachToMesh(o),r.renderList&&r.renderList.push(...t(e)),n.reflectionTexture=r.cubeTexture}e.meshes.forEach(o=>{const n=o.metadata;n&&(n.mirrorTexture&&i(o,n.mirrorTexture),n.reflectionProbe&&a(o))})}}class De{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 W(s,e,t){const i=K.get(s);if(i&&i.scene.uid===e.uid)return i;{const a=await G.SceneLoader.LoadAssetContainerAsync(s,void 0,e,t);return K.set(s,a),a}}function je(s,e,t,i,a=""){t.forEach(o=>{const n=o.getID(),r=o.getName(),l=v.getDynamicTextureResolution();s.filter(u=>u.name===a+r).forEach(u=>{const m=i.get(n),f=!1;if(m)Q(u,m),m.update(f);else{const b=qe(r,e,l.width,l.height);i.set(n,b),o.setStaticContext(b.getContext()),Q(u,b),b.onLoadObservable.addOnce(()=>{b.update(f)})}})})}function qe(s,e,t,i){const a=new Oe.DynamicTexture(s,{width:t,height:i},e,v.shouldMipMap(),Ie.Texture.TRILINEAR_SAMPLINGMODE,q.Engine.TEXTUREFORMAT_RGBA),o=a.getContext();return o&&(o.fillStyle="#f5f5f5",o.fillRect(0,0,t,i),a.update()),a}function Q(s,e){if(s instanceof O.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 Ge(){const s=()=>Math.floor((1+Math.random())*65536).toString(16).substring(1);return s()+s()+"-"+s()+"-"+s()+"-"+s()+"-"+s()+s()+s()}const x=60,Y=1;function $(s){return s.targetedAnimations.map(t=>t.animation.framePerSecond).reduce((t,i)=>t+i,0)/s.targetedAnimations.length||0}function Ne(s,e,t,i,a){const o=a?s.filter(n=>n.name===a):s;if(o.length===0){console.warn(`No animations found for name: ${a}`);return}if(i!==void 0&&t!==void 0&&i===t){o.forEach(n=>{n.stop();const r=$(n),l=i*r;n.start(e,Y,l,l)});return}o.forEach(n=>{n.stop();const r=$(n),l=i!==void 0?i*r:void 0,d=t!==void 0?t*r:void 0;n.start(e,Y,l,d)})}function Z(s){s.forEach(e=>{e.stop()})}function Ve(s){const e=s.animationGroups;Z(e)}function ke(s,e,t){console.log("ANIM DEBUGGING: start of animate camera in scene"),s.stopAnimation(e),e.animations=[],Math.abs(e.alpha)>2*Math.PI&&(e.alpha=ze(e.alpha,0,2*Math.PI));const i=[],a=t.target,o=0,n=a?1:0;if(t.target&&Object.keys(t.target).length>0?(i.push(L("cameraTargetLerp","target",new g.Vector3().copyFrom(e.target),new g.Vector3(t.target.x,t.target.y,t.target.z),w.Animation.ANIMATIONTYPE_VECTOR3,o)),console.log(`ANIM DEBUGGING: target components (${t.target.x},${t.target.y},${t.target.z})`)):console.log("ANIM DEBUGGING: target lacks components"),console.log(`ANIM DEBUGGING: alpha: ${A(t.lonDeg)}, beta: ${A(t.latDeg)}, r ${t.radius}`),i.push(L("cameraAlphaLerp","alpha",e.alpha,A(t.lonDeg),w.Animation.ANIMATIONTYPE_FLOAT,n)),i.push(L("cameraBetaLerp","beta",e.beta,A(t.latDeg),w.Animation.ANIMATIONTYPE_FLOAT,n)),t.radius!==void 0){const d=Math.max(.01,t.radius);i.push(L("cameraRadiusLerp","radius",e.radius,d,w.Animation.ANIMATIONTYPE_FLOAT,n))}e.animations.push(...i);const l=e.useAutoRotationBehavior;e.disableAutoRotationBehavior(),console.log(`ANIM DEBUGGING: animSet has ${i.length} animations`),s.beginAnimation(e,0,a?x*2:x,!1,1,()=>{e.animations=[],l&&e.enableAutoRotationBehavior()})}function A(s){return s*Math.PI/180}function L(s,e,t,i,a,o=0,n=w.Animation.ANIMATIONLOOPMODE_CONSTANT){const r=new k.QuadraticEase;r.setEasingMode(k.EasingFunction.EASINGMODE_EASEINOUT);const l=new w.Animation(s,e,x,a,n),d=[];return o>0&&d.push({frame:0,value:t}),d.push({frame:x*o,value:t}),d.push({frame:x*(o+1),value:i}),l.setKeys(d),l.setEasingFunction(r),l}function ze(s,e,t){return s<e?s=t-(e-s)%(t-e):s=e+(s-e)%(t-e)}const He={albedoTexture:"albedoMap",bumpTexture:"normalMap",ambientTexture:"ambientMap",emissiveTexture:"emissionMap",opacityTexture:"alphaMap",metallicTexture:"metallicMap",refractionTexture:"refractionMap",reflectionTexture:"reflectionMap"};function Ue(s,e,t,i){["albedoTexture","bumpTexture","ambientTexture","emissiveTexture","opacityTexture","metallicTexture","refractionTexture","reflectionTexture"].forEach(o=>{Ke(o,s,e,t,i)}),Ye(s,e)}function Ke(s,e,t,i,a){const o=He[s];if(!o)throw new Error("Unexpected texture name encountered.");const n=e[o],r=n==null?void 0:n.fileLink;r?s==="reflectionTexture"?r.endsWith(".env")||r.endsWith(".dds")?i.addCubeTextureTask(s,r,void 0,!1,void 0,!0):r.endsWith(".hdr")?i.addHDRCubeTextureTask(s,r,128,!1,!0,!1):i.addTextureTask(s,r,!1,!1):i.addTextureTask(s,r,!1,!1):a&&t[s]&&(t[s]&&t[s].dispose(),t[s]=null,We(s,t))}function We(s,e){s==="opacityTexture"&&(e.useAlphaFromAlbedoTexture=!0),s==="metallicTexture"&&(e.useRoughnessFromMetallicTextureAlpha=!1,e.useRoughnessFromMetallicTextureGreen=!1,e.useMetallnessFromMetallicTextureBlue=!1),s==="refractionTexture"&&(e.subSurface.isRefractionEnabled=!1,e.subSurface.refractionIntensity=1),s==="reflectionTexture"&&(e.environmentIntensity=1),s==="emissiveTexture"&&(e.emissiveIntensity=0,e.emissiveColor=new p.Color3(0,0,0),e.reflectionTexture)}function Qe(s,e,t,i){if(!e){console.error("Failed to apply texture to material: material is null.");return}s==="opacityTexture"&&(e.useAlphaFromAlbedoTexture=!1),s==="metallicTexture"&&(e.useRoughnessFromMetallicTextureAlpha=!1,e.useRoughnessFromMetallicTextureGreen=!0,e.useMetallnessFromMetallicTextureBlue=!0),s==="refractionTexture"&&(e.subSurface.isRefractionEnabled=!0,e.subSurface.refractionIntensity=t.refractionIntensity||1),s==="reflectionTexture"&&(e.environmentIntensity=t.reflectionIntensity||1),e[s]=i,s==="emissiveTexture"&&(e.emissiveColor=new p.Color3(1,1,1),e.emissiveIntensity=1)}function Ye(s,e){s.clearCoat&&(s.clearCoat===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 $e{constructor(e,t,i){this.materialVariantMap=new Map,this.keysThatRemovedBaseModel=[],this.loadedContainerForKey=new Map,this.loadedMaterialsForKey=new Map,this.scene=e,this.renameClonedAsset=t,this.setBaseModelEnabled=i}async applyMaterial(e,t,i,a){return new Promise(o=>{const n=this.materialVariantMap.get(e);this.materialVariantMap.set(e,{...n,...t});const r=this.renameClonedAsset(e),l=this.scene.materials.filter(u=>u.name===r);if(l.length===0){o();return}const d=new Se.AssetsManager(this.scene);d.useDefaultLoadingScreen=!1,l.forEach(u=>Ue(t,u,d,a)),d.onProgress=(u,m,f)=>{i&&i(u/m*100,100,f.name)},d.onFinish=u=>{u.forEach(m=>{const f=m;i&&i(100,100,m.name),this.scene.materials.filter(C=>C.name===r).forEach(C=>Qe(m.name,C,t,f.texture))}),o()},d.loadAsync()})}async applyModel(e,t,i,a){var l,d;if(i&&t&&!this.keysThatRemovedBaseModel.includes(e)&&this.keysThatRemovedBaseModel.push(e),!i)return this.keysThatRemovedBaseModel.includes(e)&&this.keysThatRemovedBaseModel.length===1&&await this.setBaseModelEnabled(!0),(l=this.loadedContainerForKey.get(e))==null||l.dispose(),this.loadedContainerForKey.delete(e),this.loadedMaterialsForKey.delete(e),this.keysThatRemovedBaseModel=this.keysThatRemovedBaseModel.filter(u=>u!==e),Promise.resolve(void 0);const n=(await W(i,this.scene,a)).instantiateModelsToScene(this.renameClonedAsset,!0);this.loadedContainerForKey.has(e)&&((d=this.loadedContainerForKey.get(e))==null||d.dispose(),this.loadedContainerForKey.delete(e),this.loadedMaterialsForKey.delete(e)),t&&await this.setBaseModelEnabled(!1),this.loadedContainerForKey.set(e,n),this.loadedMaterialsForKey.set(e,X(n));const r=[];return this.materialVariantMap.forEach(async(u,m)=>{r.push(this.applyMaterial(m,u))}),await Promise.all(r),n}dispose(){this.loadedContainerForKey.forEach(e=>e==null?void 0:e.dispose()),this.loadedContainerForKey.clear(),this.loadedMaterialsForKey.forEach(e=>e.forEach(t=>t==null?void 0:t.dispose())),this.loadedMaterialsForKey.clear(),this.materialVariantMap.clear(),this.keysThatRemovedBaseModel=[]}getAllMaterials(){const e=[];return this.loadedMaterialsForKey.forEach(t=>{t.forEach(i=>{e.includes(i)||e.push(i)})}),e}getAnimationGroups(){const e=[];return this.loadedContainerForKey.forEach(t=>{e.push(...t.animationGroups)}),e}}function X(s){const e=[];return s.rootNodes.forEach(t=>{t.getChildMeshes().forEach(i=>{i.material&&!e.includes(i.material)&&e.push(i.material),i.subMeshes&&i.subMeshes.forEach(a=>{const o=a.getMaterial(!1);o&&!e.includes(o)&&e.push(o)})})}),e}function J(s,e=""){return s.map(t=>({name:t.name.substring(e.length),loop:t.loopAnimation,to:t.to,from:t.from}))}class Ze{constructor(e){this.metadata=new Map,this.materialSelectedObservable=new M.Observable,this.materialDeselectedObservable=new M.Observable,this.materialVariantObservable=new M.Observable,this.modelVariantObservable=new M.Observable,this.materialReadyToLoadCallbacks=new Map,this.modelReadyToLoadCallbacks=new Map,this.dynamicTextures=new Map,this.queuedMaterialChanges=new Map,this.materialChangesInProgress=[],this.queuedModelChanges=new Map,this.modelChangesInProgress=[],this.animations=[],this.initialized=!1,this.materials=[];const{enablePicking:t,modelDetails:i,previewService:a,progressHandler:o,scene:n}=e;this.enablePicking=t,this.contextService=i.contextService,this.id=Ge(),this.previewService=a,this.scene=n,this.variantManager=new $e(n,this.renameClonedAsset.bind(this),this.setBaseModelEnabled.bind(this)),this.transformRoot=new Le.TransformNode("root",this.scene);const r=async()=>{if(!i.model)throw new Error("Model container constructed with no URL. This is currently unsupported.");return this.assetContainer=await W(i.model,n,o),this.initialized=!0,await this.instantiate(),this};this.importPromise=r()}async applyMaterialVariant(e,t,i,a){if(!this.initialized){if(this.materialReadyToLoadCallbacks.has(e)){const n=this.materialReadyToLoadCallbacks.get(e);n==null||n.set(t,this.applyMaterialVariant.bind(this,e,t,i,a))}else{this.materialReadyToLoadCallbacks.set(e,new Map);const n=this.materialReadyToLoadCallbacks.get(e);n==null||n.set(t,this.applyMaterialVariant.bind(this,e,t,i,a))}return}const o=async()=>{await this.variantManager.applyMaterial(e,i,(n,r,l)=>{this.materialVariantObservable.notifyObservers({remainingCount:n,totalCount:r,taskName:l})},a)};if(this.materialChangesInProgress.includes(e)){if(this.queuedMaterialChanges.has(e)){const n=this.queuedMaterialChanges.get(e);n==null||n.set(t,o)}else{this.queuedMaterialChanges.set(e,new Map);const n=this.queuedMaterialChanges.get(e);n==null||n.set(t,o)}return}if(this.materialChangesInProgress.push(e),await o(),this.queuedMaterialChanges.has(e)){const n=this.queuedMaterialChanges.get(e);if(!n)throw new Error("Target material is undefined");n.forEach(async r=>{await r()}),this.queuedMaterialChanges.delete(e)}this.materialChangesInProgress.splice(this.materialChangesInProgress.indexOf(e),1),this.configureGlowLayer()}async applyModelVariant(e,t,i){if(!this.initialized){this.modelReadyToLoadCallbacks.set(e,this.applyModelVariant.bind(this,e,t,i));return}const a=()=>this.variantManager.applyModel(e,i,t==null?void 0:t.model,r=>{this.modelVariantObservable.notifyObservers({...r,key:e})});if(this.modelChangesInProgress.includes(e)){this.queuedModelChanges.set(e,a);return}const n=await(async()=>{this.modelChangesInProgress.push(e);let r=await a();if(this.queuedModelChanges.has(e)){const l=this.queuedModelChanges.get(e);if(!l)throw new Error("Queued change resolved undefined");r=await l(),this.queuedModelChanges.delete(e)}return this.modelChangesInProgress.splice(this.modelChangesInProgress.indexOf(e),1),r})();this.modelInstance&&Z(this.modelInstance.animationGroups),this.contextService||(this.contextService=t==null?void 0:t.contextService),n?this.configureModelInstance(n):this.configureGlowLayer()}dispose(){var e;this.destroyInstance(),this.variantManager.dispose(),this.dynamicTextures.forEach(t=>t==null?void 0:t.dispose()),this.dynamicTextures.clear(),this.materials.forEach(t=>t&&(t==null?void 0:t.dispose())),this.materials=[],(e=this.transformRoot)==null||e.dispose(),this.transformRoot=void 0,this.previewService.modelUnloaded(this)}executeAnimation(e){if(!this.previewService.getInitializationComplete()){this.queuedModelAnimation=e;return}this.modelInstance&&Ne([...this.modelInstance.animationGroups,...this.variantManager.getAnimationGroups()],e.loop,e.to,e.from,e.name?this.renameClonedAsset(e.name):void 0)}getAnimations(e){return[...this.animations,...e?J(this.variantManager.getAnimationGroups(),this.renameClonedAsset("")):[]]}getId(){return this.id}listMaterials(){var t;const e=(t=this.scene)==null?void 0:t.materials.filter(i=>i.name.startsWith(this.id));return e?e.map(i=>({id:i.id,name:this.stripIdFromName(i.name)})):[]}registerMaterialSelectedCallback(e){this.materialSelectedObservable.add(e)}unregisterMaterialSelectedCallback(e){this.materialSelectedObservable.removeCallback(e)}registerMaterialDeselectedCallback(e){this.materialDeselectedObservable.add(e)}unregisterMaterialDeselectedCallback(e){this.materialDeselectedObservable.removeCallback(e)}get position(){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to requesting position!");return this.transformRoot.position}set position(e){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to setting position!");this.transformRoot.position=new g.Vector3(e.x,e.y,e.z)}get rotation(){var e;if(!((e=this.transformRoot)!=null&&e.rotationQuaternion))throw new Error("ModelContainer disposed prior to requesting rotation!");return this.transformRoot.rotationQuaternion.toEulerAngles()}set rotation(e){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to setting rotation!");this.transformRoot.rotationQuaternion=g.Quaternion.FromEulerAngles(e.x,e.y,e.z)}get scale(){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to requesting scale!");return this.transformRoot.scaling}set scale(e){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to setting scale!");this.transformRoot.scaling=new g.Vector3(e.x,e.y,e.z)}attachPickingHandler(e){e.rootNodes.forEach(t=>{t.getChildMeshes(!1).forEach(i=>{i.name==="targetcube_t"||i.name==="backgroundShell"||(i.actionManager||(i.actionManager=new I.ActionManager(this.scene)),i.actionManager.registerAction(new V.ExecuteCodeAction(I.ActionManager.OnPointerOverTrigger,a=>{a.meshUnderPointer&&i.material&&this.materialSelectedObservable.notifyObservers({id:i.material.id,name:this.stripIdFromName(i.material.name)})})),i.actionManager.registerAction(new V.ExecuteCodeAction(I.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 O.PBRMaterial&&i.emissiveTexture!==null;this.materials.some(e)||this.variantManager.getAllMaterials().some(e)?this.previewService.getGlowLayerManager().includeMeshes(this.getAllMeshes()):this.previewService.getGlowLayerManager().removeMeshes(this.getAllMeshes())}configureModelInstance(e){var o;if(!this.transformRoot)throw new Error("Transform disposed! This should never happen unless there is a race condition present!");const t=this.transformRoot.position,i=this.transformRoot.rotationQuaternion,a=this.transformRoot.scaling;this.transformRoot.position=g.Vector3.Zero(),this.transformRoot.rotationQuaternion=g.Quaternion.Identity(),this.transformRoot.scaling=g.Vector3.One();for(const n of e.rootNodes)n.parent=this.transformRoot;this.transformRoot.position=t,this.transformRoot.rotationQuaternion=i,this.transformRoot.scaling=a,this.canvasPanels=((o=this.contextService)==null?void 0:o.getAll())||new Map,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 Ae.Mesh)).flat()}async instantiate(){if(!this.assetContainer)throw new Error("Attempted to instantiate ModelContainer without an AssetContainer");this.modelInstance=this.assetContainer.instantiateModelsToScene(this.renameClonedAsset.bind(this),!0),this.materials=X(this.modelInstance),this.configureModelInstance(this.modelInstance),this.animations=J(this.modelInstance.animationGroups,this.renameClonedAsset("")),await this.processQueuedEvents()}renameClonedAsset(e){return`${this.id}_${e}`}async setBaseModelEnabled(e){e&&!this.modelInstance?await this.instantiate():!e&&this.modelInstance&&this.destroyInstance()}updateDynamicTextures(){var e;(e=this.canvasPanels)==null||e.forEach((t,i)=>{const a=this.dynamicTextures.get(i);a&&t.getStaticContextDirty()&&a.isReady()&&(a.update(!1),t.setStaticContextDirty(!1))})}registerMaterialVariantListener(e){this.materialVariantObservable.add(e)}unregisterMaterialVariantListener(e){this.materialVariantObservable.removeCallback(e)}registerModelVariantListener(e){this.modelVariantObservable.add(e)}unregisterModelVariantListener(e){this.modelVariantObservable.removeCallback(e)}stripIdFromName(e){return e.substring(this.id.length+1)}async processQueuedEvents(){await Promise.all(Array.from(this.materialReadyToLoadCallbacks.values()).flatMap(e=>Array.from(e.values()).map(t=>t()))),this.materialReadyToLoadCallbacks.clear(),await Promise.all(Array.from(this.modelReadyToLoadCallbacks.values()).map(e=>e())),this.modelReadyToLoadCallbacks.clear(),this.queuedModelAnimation&&(this.executeAnimation(this.queuedModelAnimation),this.queuedModelAnimation=void 0)}}class F extends y.ArcRotateCamera{constructor(e,t,i,a,o,n,r,l){super(e,t,i,a,o,n,l),this.lastFocus=new g.Vector3(0,0,0),this.panDenominator=1,this.minZ=.01,this.setRadius(this.radius),this.enableFramingBehavior(),this.wheelDeltaPercentage=.01,this.pinchDeltaPercentage=.005,this.useNaturalPinchZoom=!0,r.camera.autoOrientation&&(this.alpha+=Math.PI),r&&(r.camera.limits.min.beta&&(this.lowerBetaLimit=r.camera.limits.min.beta),r.camera.limits.max.beta&&(this.upperBetaLimit=r.camera.limits.max.beta),r.camera.limits.min.alpha&&(this.lowerAlphaLimit=r.camera.limits.min.alpha),r.camera.limits.max.alpha&&(this.upperAlphaLimit=r.camera.limits.max.alpha),r.camera.limits.min.radius&&(this.lowerRadiusLimit=r.camera.limits.min.radius),r.camera.limits.max.radius&&(this.upperRadiusLimit=r.camera.limits.max.radius),r.camera.autoRotation.enabled&&this.enableAutoRotationBehavior(r.camera.autoRotation.idleTimeMs))}getFramingBehavior(){return this.getBehaviorByName("Framing")}getAutoRotationBehavior(){const e=this.getBehaviorByName("AutoRotation");if(e)return e}enableFramingBehavior(){this.useFramingBehavior=!0;const e=this.getFramingBehavior();e.attach(this),e.framingTime=0,e.elevationReturnTime=-1,e.zoomStopsAnimation=!1,this.lowerRadiusLimit=null;const t=B(this._scene);return e.zoomOnBoundingInfo(t.min,t.max),this.wheelPrecision=100/this.radius,this.lowerRadiusLimit===null&&(this.lowerRadiusLimit=.1),this.lastFocus.copyFrom(this.target),e}rerunFramingBehavior(e,t){const i=this.getFramingBehavior();i.framingTime=t||800;const a=()=>{e&&e()},o=B(this._scene),n=o.max.subtract(o.min),r=o.min.add(n.scale(.5));this.setRadius(n.length()*1.5),this.wheelPrecision=100/this.radius,this.panningInertia=0,this.panningOriginTarget.copyFrom(r),this.panDenominator=n.length(),i.zoomOnBoundingInfo(o.min,o.max,void 0,a),i.framingTime=0}enableAutoRotationBehavior(e=5e3){this.useAutoRotationBehavior=!0;const t=this.getAutoRotationBehavior();t&&(t.idleRotationWaitTime=e)}disableAutoRotationBehavior(){this.useAutoRotationBehavior=!1}setRadius(e){this.radius=e,this.maxZ=this.radius*1e3,this.lowerRadiusLimit=this.radius*.01,this.upperRadiusLimit=1.5*this.radius,this.wheelPrecision=100/this.radius,this.pinchPrecision=300/this.radius}static create(e,t,i){const a=B(e),o=a.max.subtract(a.min),n=a.min.add(o.scale(.5)),r=new F("ProductCamera",-(Math.PI/2),Math.PI/2,o.length()*1.5,n,e,t);return r.panningInertia=0,r.panningOriginTarget.copyFrom(n),r.panDenominator=o.length(),r.onAfterCheckInputsObservable.add(()=>{r.panningSensibility=1e3/r.panDenominator}),i&&(e.activeCamera=r),r}}function B(s){if(s.meshes.length===0)return{min:new g.Vector3(-1,-1,-1),max:new g.Vector3(1,1,1)};const e=s.meshes.filter(t=>t.name.toLowerCase().endsWith("_t")||t.name.toLowerCase().includes("_t_"));return s.getWorldExtends(t=>t.isVisible&&t.isEnabled()&&(e.length===0||e.includes(t)))}class Xe{constructor(e,t=!1,i=void 0){this.renderingPipeline=new Fe.DefaultRenderingPipeline("default",t,e,i?[i]:void 0,!1),this.renderingPipeline.isSupported&&(this.renderingPipeline.prepare(),this.setConfiguration(c))}dispose(){this.renderingPipeline.dispose()}getConfiguration(){return this.currentConfiguration}setConfiguration(e){var t,i,a,o,n,r,l,d,u,m,f,b,C,_,ee,te,ie,se,ne,re,ae,oe,le,he,ce,de,ue,ge,me,pe,fe,be,ye;if(this.renderingPipeline.isSupported){if(this.renderingPipeline.samples=((t=e.antiAliasing)==null?void 0:t.samples)??c.antiAliasing.samples,this.renderingPipeline.fxaaEnabled=((i=e.antiAliasing)==null?void 0:i.fxaaEnabled)??c.antiAliasing.fxaaEnabled,this.renderingPipeline.bloomEnabled=((a=e.bloom)==null?void 0:a.enabled)??c.bloom.enabled,this.renderingPipeline.bloomKernel=((o=e.bloom)==null?void 0:o.kernel)??c.bloom.kernel,this.renderingPipeline.bloomScale=((n=e.bloom)==null?void 0:n.scale)??c.bloom.scale,this.renderingPipeline.bloomThreshold=((r=e.bloom)==null?void 0:r.threshold)??c.bloom.threshold,this.renderingPipeline.bloomWeight=((l=e.bloom)==null?void 0:l.weight)??c.bloom.weight,this.renderingPipeline.chromaticAberrationEnabled=((d=e.chromaticAberration)==null?void 0:d.enabled)??c.chromaticAberration.enabled,this.renderingPipeline.chromaticAberration.aberrationAmount=((u=e.chromaticAberration)==null?void 0:u.aberrationAmount)??c.chromaticAberration.aberrationAmount,this.renderingPipeline.chromaticAberration.radialIntensity=((m=e.chromaticAberration)==null?void 0:m.radialIntensity)??c.chromaticAberration.radialIntensity,this.renderingPipeline.chromaticAberration.direction=(f=e.chromaticAberration)!=null&&f.direction?new g.Vector2(e.chromaticAberration.direction.x,e.chromaticAberration.direction.y):new g.Vector2(c.chromaticAberration.direction.x,c.chromaticAberration.direction.y),this.renderingPipeline.imageProcessing.colorCurvesEnabled=((b=e.colorCurves)==null?void 0:b.enabled)??c.colorCurves.enabled,this.renderingPipeline.imageProcessing.colorCurves=e.colorCurves?this.updateColorCurve(e.colorCurves):new z.ColorCurves,this.renderingPipeline.depthOfFieldEnabled=((C=e.depthOfField)==null?void 0:C.enabled)??c.depthOfField.enabled,e.depthOfField)switch(e.depthOfField.blurLevel??c.depthOfField.blurLevel){case"Low":this.renderingPipeline.depthOfFieldBlurLevel=S.DepthOfFieldEffectBlurLevel.Low;break;case"Medium":this.renderingPipeline.depthOfFieldBlurLevel=S.DepthOfFieldEffectBlurLevel.Medium;break;case"High":this.renderingPipeline.depthOfFieldBlurLevel=S.DepthOfFieldEffectBlurLevel.High;break}if(this.renderingPipeline.depthOfField.focalLength=((_=e.depthOfField)==null?void 0:_.focalLength)??c.depthOfField.focalLength,this.renderingPipeline.depthOfField.fStop=((ee=e.depthOfField)==null?void 0:ee.fStop)??c.depthOfField.fStop,this.renderingPipeline.depthOfField.focusDistance=((te=e.depthOfField)==null?void 0:te.focusDistance)??c.depthOfField.focusDistance,this.renderingPipeline.depthOfField.lensSize=((ie=e.depthOfField)==null?void 0:ie.lensSize)??c.depthOfField.lensSize,this.renderingPipeline.grainEnabled=((se=e.grain)==null?void 0:se.enabled)??c.grain.enabled,this.renderingPipeline.grain.animated=((ne=e.grain)==null?void 0:ne.animated)??c.grain.animated,this.renderingPipeline.grain.intensity=((re=e.grain)==null?void 0:re.intensity)??c.grain.intensity,this.renderingPipeline.imageProcessing.contrast=((ae=e.misc)==null?void 0:ae.contrast)??c.misc.contrast,this.renderingPipeline.imageProcessing.exposure=((oe=e.misc)==null?void 0:oe.exposure)??c.misc.exposure,this.renderingPipeline.imageProcessing.toneMappingEnabled=((le=e.misc)==null?void 0:le.toneMappingEnabled)??c.misc.toneMappingEnabled,this.renderingPipeline.imageProcessing.toneMappingEnabled)switch(e.misc.toneMappingType??c.misc.toneMappingType){case"Standard":this.renderingPipeline.imageProcessing.toneMappingType=T.ImageProcessingConfiguration.TONEMAPPING_STANDARD;break;case"ACES":this.renderingPipeline.imageProcessing.toneMappingType=T.ImageProcessingConfiguration.TONEMAPPING_ACES;break}if(this.renderingPipeline.sharpenEnabled=((he=e.sharpen)==null?void 0:he.enabled)??c.sharpen.enabled,this.renderingPipeline.sharpen.colorAmount=((ce=e.sharpen)==null?void 0:ce.colorAmount)??c.sharpen.colorAmount,this.renderingPipeline.sharpen.edgeAmount=((de=e.sharpen)==null?void 0:de.edgeAmount)??c.sharpen.edgeAmount,this.renderingPipeline.imageProcessing.vignetteEnabled=((ue=e.vignette)==null?void 0:ue.enabled)??c.vignette.enabled,(ge=e.vignette)!=null&&ge.center?(this.renderingPipeline.imageProcessing.vignetteCenterX=e.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=e.vignette.center.y):(this.renderingPipeline.imageProcessing.vignetteCenterX=c.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=c.vignette.center.y),e.vignette)switch(((me=e.vignette)==null?void 0:me.blendMode)??c.vignette.blendMode){case"Multiply":this.renderingPipeline.imageProcessing.vignetteBlendMode=T.ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY;break;case"Opaque":this.renderingPipeline.imageProcessing.vignetteBlendMode=T.ImageProcessingConfiguration.VIGNETTEMODE_OPAQUE;break}(pe=e.vignette)!=null&&pe.colorRgba?this.renderingPipeline.imageProcessing.vignetteColor=new p.Color4(e.vignette.colorRgba.r,e.vignette.colorRgba.g,e.vignette.colorRgba.b,e.vignette.colorRgba.a):(fe=e.vignette)!=null&&fe.colorHex?this.renderingPipeline.imageProcessing.vignetteColor=p.Color4.FromHexString(e.vignette.colorHex):this.renderingPipeline.imageProcessing.vignetteColor=new p.Color4(c.vignette.colorRgba.r,c.vignette.colorRgba.g,c.vignette.colorRgba.b,c.vignette.colorRgba.a),this.renderingPipeline.imageProcessing.vignetteStretch=((be=e.vignette)==null?void 0:be.stretch)??c.vignette.stretch,this.renderingPipeline.imageProcessing.vignetteWeight=((ye=e.vignette)==null?void 0:ye.weight)??c.vignette.weight,this.renderingPipeline.prepare(),this.currentConfiguration=e}}updateColorCurve(e){const t=new z.ColorCurves;return t.globalDensity=e.globalDensity??t.globalDensity,t.globalExposure=e.globalExposure??t.globalExposure,t.globalHue=e.globalHue??t.globalHue,t.globalSaturation=e.globalSaturation??t.globalSaturation,t.highlightsDensity=e.highlightsDensity??t.highlightsDensity,t.highlightsExposure=e.highlightsExposure??t.highlightsExposure,t.highlightsHue=e.highlightsHue??t.highlightsHue,t.highlightsSaturation=e.highlightsSaturation??t.highlightsSaturation,t.midtonesDensity=e.midtonesDensity??t.midtonesDensity,t.midtonesExposure=e.midtonesExposure??t.midtonesExposure,t.midtonesHue=e.midtonesHue??t.midtonesHue,t.midtonesSaturation=e.midtonesSaturation??t.midtonesSaturation,t.shadowsDensity=e.shadowsDensity??t.shadowsDensity,t.shadowsExposure=e.shadowsExposure??t.shadowsExposure,t.shadowsHue=e.shadowsHue??t.shadowsHue,t.shadowsSaturation=e.shadowsSaturation??t.shadowsSaturation,t}}Pe.GLTF2.GLTFLoader.RegisterExtension("glbPostProcessor",function(s){return new Be(s)}),G.SceneLoader.OnPluginActivatedObservable.add(s=>{if(s.name==="gltf"){const e=s;e.transparencyAsCoverage=!0}});function D(s){return new g.Vector3(s.x,s.y,s.z)}function j(s){return{x:s.x,y:s.y,z:s.z}}class Je{constructor(e){var l;this.focusLostNotified=!1,this.focusLostObservable=new M.Observable,this.modelLoadEventCallbacks=[],this.modelContainers=new Map,this.plugins=[],this.initComplete=!1,this.renderLoop=()=>{this.engine.views&&(this.modelContainers.forEach(d=>{d.updateDynamicTextures()}),this.scene.render(),!this.camera.target.equalsWithEpsilon(this.camera.lastFocus,.1)&&!this.focusLostNotified&&(this.focusLostObservable.notifyObservers(void 0),this.focusLostNotified=!0),this.screenshotPrepareResolve&&(this.screenshotPrepareResolve(),this.screenshotPrepareResolve=void 0))},this.configuration=new H(e);const i=(()=>{if(!(e!=null&&e.noRender))return this.configuration.createCanvas()})(),a="1.5.6";Ce.DracoCompression.Configuration={decoder:{wasmUrl:`https://www.gstatic.com/draco/versioned/decoders/${a}/draco_wasm_wrapper_gltf.js`,wasmBinaryUrl:`https://www.gstatic.com/draco/versioned/decoders/${a}/draco_decoder_gltf.wasm`,fallbackUrl:`https://www.gstatic.com/draco/versioned/decoders/${a}/draco_decoder_gltf.js`}},i&&(i.getContext("webgl2")||i.getContext("webgl"));const o=console.log,n=i?new 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 we.NullEngine;console.log=o,n.hideLoadingUI(),window.addEventListener("resize",this.fireResizeEvent.bind(this)),this.engine=n,this.scene=new xe.Scene(n),this.scene.autoClear=!0,this.scene.autoClearDepthAndStencil=!0,this.camera=F.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=N.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 De(this.scene,this.configuration.emissiveGlowIntensity),this.initPromise=new Promise(d=>{this.scene.onReadyObservable.addOnce(()=>{this.initComplete=!0,d()})}),this.engine.runRenderLoop(this.renderLoop)}getInitializationPromise(){return this.initPromise}getInitializationComplete(){return this.initComplete}getEngineContext(){return{engine:this.engine,scene:this.scene,camera:this.camera}}registerFocusLostListener(e){this.focusLostObservable.add(e)}unregisterFocusLostListener(e){this.focusLostObservable.removeCallback(e)}registerModelLoadEventListener(e){this.modelLoadEventCallbacks.push(e)}unregisterModelLoadEventListener(e){const t=this.modelLoadEventCallbacks.indexOf(e);t>-1&&this.modelLoadEventCallbacks.splice(t,1)}registerView(e){const t=e.height,i=e.width;this.engine.registerView(e,void 0,!0),e.setAttribute("height",t.toString()),e.setAttribute("width",i.toString()),this.orbitEnabled()||this.setCameraState(E.Pan),this.reattachControls(e)}getNumViewports(){var e;return((e=this.engine.views)==null?void 0:e.length)||0}unregisterView(e){this.engine.unRegisterView(e)}shutdown(){this.plugins.forEach(e=>e.dispose(!0)),this.renderingPipeline.dispose(),this.engine&&this.engine.dispose(),window.removeEventListener("resize",this.fireResizeEvent)}executeCameraAnimation(e){if(!this.camera||this.scene.activeCamera!==this.camera){this.camera?console.log("ANIM: DEBUGGING: queueing animation bc wrong camera"):console.log("ANIM: DEBUGGING: queueing animation bc no camera"),this.queuedCameraAnimation=e;return}console.log("ANIM: DEBUGGING: animating camera in scene"),ke(this.scene,this.scene.activeCamera,e),console.log("ANIM: DEBUGGING: animated camera in scene")}getCameraPose(){if(this.scene&&this.camera)return{lonDeg:Math.round(this.camera.alpha*180/Math.PI),latDeg:Math.round(this.camera.beta*180/Math.PI),radius:Math.round((this.camera.radius+Number.EPSILON)*1e4)/1e4,target:{x:this.camera.target.x,y:this.camera.target.y,z:this.camera.target.z}}}setCameraPose(e){this.scene&&this.camera&&(this.camera.target=new g.Vector3(e.target.x,e.target.y,e.target.z),this.camera.radius=e.radius,this.camera.alpha=e.latDeg,this.camera.beta=e.lonDeg)}setCameraState(e){var t,i;if(!((t=this.engine)!=null&&t.views)||!((i=this.engine)!=null&&i.views[0]))throw new Error("No views attached, camera state requires a view to attach controls onto.");e===E.Orbit?this.reattachControls(this.engine.views[0].target,2):this.reattachControls(this.engine.views[0].target,0)}animateToLastCameraFocus(){return new Promise(e=>{const t=()=>{const i=this.configuration;this.camera.rerunFramingBehavior(()=>{this.focusLostNotified=!1,i.camera.limits.min.radius&&(this.camera.lowerRadiusLimit=i.camera.limits.min.radius),i.camera.limits.max.radius&&(this.camera.upperRadiusLimit=i.camera.limits.max.radius),e()})};this.scene.onAfterRenderObservable.addOnce(t)})}setAutoRotation(e){!this.configuration.camera.autoRotation.enabled||!this.camera||(e?this.camera.enableAutoRotationBehavior(this.configuration.camera.autoRotation.idleTimeMs):this.camera.disableAutoRotationBehavior())}getCurrentConfiguration(){return this.configuration.options}async renderSceneScreenshot(e,t){if(!this.camera)throw new Error("Missing product camera, cannot render screenshot!");const i=new y.ArcRotateCamera("screenshotCamera",0,0,0,g.Vector3.Zero(),this.scene);try{const a=t.latDeg*Math.PI/180,o=t.lonDeg*Math.PI/180;i.target=t.target?new g.Vector3(t.target.x,t.target.y,t.target.z):g.Vector3.Zero(),i.alpha=o,i.beta=a,i.radius=t.radius||this.camera.radius,i.minZ=.01,this.scene.render();const n=await Me.Tools.CreateScreenshotUsingRenderTargetAsync(this.engine,i,e,"image/png",2,!0);return i.dispose(),n}catch{throw i.isDisposed()||i.dispose(),new Error("Failed to render screenshot")}}orbitEnabled(){const e=this.configuration;if(!e)return!0;const t=e.camera.limits.min.alpha,i=e.camera.limits.max.alpha,a=e.camera.limits.min.beta,o=e.camera.limits.max.beta;if(t===void 0||i===void 0||a===void 0||o===void 0)return!0;const n=[t,i],r=[a,o],l=n.every(u=>u===t),d=r.every(u=>u===a);return!l&&!d}fireResizeEvent(){this.getNumViewports()>0&&this.engine.resize()}setHighlights(e,t){var a;e.length===0&&((a=this.highlightLayer)==null||a.dispose(),this.highlightLayer=void 0),this.highlightLayer||(this.highlightLayer=new ve.HighlightLayer("highlights",this.scene,{isStroke:!0,blurVerticalSize:.85,blurHorizontalSize:.85}),this.highlightLayer.innerGlow=!0,this.highlightLayer.outerGlow=!1),this.highlightLayer.removeAllMeshes();const i=t?new p.Color3(t[0],t[1],t[2]).toLinearSpace():void 0;e.forEach(o=>{const n=this.scene.materials.find(r=>r.name===o.name&&r.id===o.id);n&&n.getBindedMeshes().forEach(r=>{var l;return(l=this.highlightLayer)==null?void 0:l.addMesh(r,i||p.Color3.FromHexString("#fcba03"))})})}setRenderingPipelineConfiguration(e){this.renderingPipeline&&this.renderingPipeline.setConfiguration(e)}loadModel(e,t){const i=new Ze({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),Ve(this.scene),this.queuedCameraAnimation&&(this.executeCameraAnimation(this.queuedCameraAnimation),this.queuedCameraAnimation=void 0)}),this.configuration.highlights.enabled&&(i.registerMaterialSelectedCallback(a=>{this.setHighlights([a])}),i.registerMaterialDeselectedCallback(()=>{this.setHighlights([])})),this.modelContainers.set(i.getId(),i),this.triggerModelLoadEvent({eventType:"load",modelContainer:i}),i}getAllModels(){return Array.from(this.modelContainers.values())}getModelById(e){return this.modelContainers.get(e)}registerPlugin(e){this.plugins.push(e),e.initialize(this,{camera:this.camera,engine:this.engine,scene:this.scene})}unregisterPlugin(e){const t=this.plugins.indexOf(e);t>-1&&this.plugins.splice(t,1).forEach(a=>a.dispose(!1))}getGlowLayerManager(){return this.glowLayerManager}modelUnloaded(e){this.modelContainers.delete(e.getId()),this.triggerModelLoadEvent({eventType:"unload",modelContainer:e})}triggerModelLoadEvent(e){this.modelLoadEventCallbacks.forEach(t=>t(e))}flipTransform(e,t,i){const a=g.Matrix.Compose(D(i||{x:1,y:1,z:1}),g.Quaternion.FromEulerVector(D(t||{x:0,y:0,z:0})),D(e||{x:0,y:0,z:0})),o=g.Matrix.RotationAxis(g.Vector3.Up(),Math.PI),n=a.multiply(o),r=g.Vector3.Zero(),l=g.Quaternion.Identity(),d=g.Vector3.Zero();return n.decompose(d,l,r),l.multiplyInPlace(g.Quaternion.FromEulerAngles(0,Math.PI,0)),{position:j(r),rotation:j(l.toEulerAngles()),scale:j(d)}}updatePreviewOptions(e){var a;const t=new H(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=N.CubeTexture.CreateFromPrefilteredData(t.scene.environment.file,this.scene),i.rotationY=this.configuration.scene.environment.rotationY,this.scene.environmentTexture=i),i.rotationY=t.scene.environment.rotationY,this.scene.environmentIntensity=t.scene.environment.intensity,(a=t.options)!=null&&a.renderingPipelineConfiguration?this.renderingPipeline.setConfiguration(t.options.renderingPipelineConfiguration):(this.scene.imageProcessingConfiguration.exposure=t.lighting.exposure,this.scene.imageProcessingConfiguration.contrast=t.lighting.contrast),this.glowLayerManager.setIntensity(t.emissiveGlowIntensity),this.configuration=t}reattachControls(e,t=2){if(this.scene.detachControl(),this.engine.inputElement=e,this.camera){this.camera.attachControl(!0,!1,t);const i=this.camera.inputs.attached.pointers;i.multiTouchPanning=!1}this.scene.attachControl(!0,!0,!0)}}h.MaterialEffectMode=R,h.ProductCameraRig=E,h.REFLECTION_PROBE_RESOLUTION=U,h.RenderingConfiguration=v,h.SpiffCommerce3DPreviewService=Je,h.renderingPipelineDefaults=c,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(h,y){typeof exports=="object"&&typeof module<"u"?y(exports,require("@babylonjs/core/Cameras/arcRotateCamera"),require("@babylonjs/core/Engines/engine"),require("@babylonjs/core/Engines/nullEngine"),require("@babylonjs/core/Layers/highlightLayer"),require("@babylonjs/core/Loading/sceneLoader"),require("@babylonjs/core/Materials/Textures/cubeTexture"),require("@babylonjs/core/Maths/math.color"),require("@babylonjs/core/Maths/math.vector"),require("@babylonjs/core/Meshes/Compression/dracoCompression"),require("@babylonjs/core/Misc/observable"),require("@babylonjs/core/Misc/tools"),require("@babylonjs/core/scene"),require("@babylonjs/loaders/glTF"),require("@babylonjs/core/Materials/PBR/pbrMaterial"),require("@babylonjs/core/Materials/Textures/mirrorTexture"),require("@babylonjs/core/Maths/math"),require("@babylonjs/core/Probes/reflectionProbe"),require("@babylonjs/core/Layers/glowLayer"),require("@babylonjs/core/Actions/actionManager"),require("@babylonjs/core/Actions/directActions"),require("@babylonjs/core/Meshes/mesh"),require("@babylonjs/core/Meshes/transformNode"),require("@babylonjs/core/Materials/Textures/dynamicTexture"),require("@babylonjs/core/Materials/Textures/texture"),require("@babylonjs/core/Animations/animation"),require("@babylonjs/core/Animations/easing"),require("@babylonjs/core/Misc/assetsManager"),require("@babylonjs/core/Materials/colorCurves"),require("@babylonjs/core/Materials/imageProcessingConfiguration"),require("@babylonjs/core/PostProcesses/RenderPipeline"),require("@babylonjs/core/PostProcesses/depthOfFieldEffect"),require("@babylonjs/core/Rendering/depthRendererSceneComponent"),require("@babylonjs/core/Engines/Extensions/engine.views"),require("@babylonjs/core/Meshes/instancedMesh"),require("@babylonjs/core/Materials/Textures/Loaders/ddsTextureLoader"),require("@babylonjs/core/Materials/Textures/Loaders/envTextureLoader"),require("@babylonjs/core/Materials/Textures/Loaders/ktxTextureLoader"),require("@babylonjs/core/Animations/animatable"),require("@babylonjs/core/Misc/screenshotTools"),require("@babylonjs/core/Rendering/boundingBoxRenderer"),require("@babylonjs/loaders/glTF/2.0/Extensions")):typeof define=="function"&&define.amd?define(["exports","@babylonjs/core/Cameras/arcRotateCamera","@babylonjs/core/Engines/engine","@babylonjs/core/Engines/nullEngine","@babylonjs/core/Layers/highlightLayer","@babylonjs/core/Loading/sceneLoader","@babylonjs/core/Materials/Textures/cubeTexture","@babylonjs/core/Maths/math.color","@babylonjs/core/Maths/math.vector","@babylonjs/core/Meshes/Compression/dracoCompression","@babylonjs/core/Misc/observable","@babylonjs/core/Misc/tools","@babylonjs/core/scene","@babylonjs/loaders/glTF","@babylonjs/core/Materials/PBR/pbrMaterial","@babylonjs/core/Materials/Textures/mirrorTexture","@babylonjs/core/Maths/math","@babylonjs/core/Probes/reflectionProbe","@babylonjs/core/Layers/glowLayer","@babylonjs/core/Actions/actionManager","@babylonjs/core/Actions/directActions","@babylonjs/core/Meshes/mesh","@babylonjs/core/Meshes/transformNode","@babylonjs/core/Materials/Textures/dynamicTexture","@babylonjs/core/Materials/Textures/texture","@babylonjs/core/Animations/animation","@babylonjs/core/Animations/easing","@babylonjs/core/Misc/assetsManager","@babylonjs/core/Materials/colorCurves","@babylonjs/core/Materials/imageProcessingConfiguration","@babylonjs/core/PostProcesses/RenderPipeline","@babylonjs/core/PostProcesses/depthOfFieldEffect","@babylonjs/core/Rendering/depthRendererSceneComponent","@babylonjs/core/Engines/Extensions/engine.views","@babylonjs/core/Meshes/instancedMesh","@babylonjs/core/Materials/Textures/Loaders/ddsTextureLoader","@babylonjs/core/Materials/Textures/Loaders/envTextureLoader","@babylonjs/core/Materials/Textures/Loaders/ktxTextureLoader","@babylonjs/core/Animations/animatable","@babylonjs/core/Misc/screenshotTools","@babylonjs/core/Rendering/boundingBoxRenderer","@babylonjs/loaders/glTF/2.0/Extensions"],y):(h=typeof globalThis<"u"?globalThis:h||self,y(h.Preview={},h.arcRotateCamera,h.engine,h.nullEngine,h.highlightLayer,h.sceneLoader,h.cubeTexture,h.math_color,h.math_vector,h.dracoCompression,h.observable,h.tools,h.scene,h.glTF,h.pbrMaterial,h.mirrorTexture,h.math,h.reflectionProbe,h.glowLayer,h.actionManager,h.directActions,h.mesh,h.transformNode,h.dynamicTexture,h.texture,h.animation,h.easing,h.assetsManager,h.colorCurves,h.imageProcessingConfiguration,h.RenderPipeline,h.depthOfFieldEffect))})(this,function(h,y,D,Ce,ve,q,V,p,g,we,M,Me,xe,Pe,L,Te,P,Re,Ae,O,k,Ee,Le,Oe,Ie,C,z,Se,N,T,Fe,I){"use strict";var R=(s=>(s[s.Orbit=0]="Orbit",s[s.Pan=1]="Pan",s))(R||{}),A=(s=>(s.None="None",s.RemoveWhenSelected="RemoveWhenSelected",s.ApplyWhenSelected="ApplyWhenSelected",s))(A||{});class G{constructor(e){this.getSceneClearColor=()=>{var i,a,o,n;const t=(i=this.customOptions)!=null&&i.transparentBackground||(a=this.customOptions)!=null&&a.backgroundImage?0:1;if(this.customOptions&&((o=this.customOptions)!=null&&o.transparentBackground)||(n=this.customOptions)!=null&&n.backgroundImage)return new p.Color4(0,0,0,t).toLinearSpace();if(this.customOptions&&this.customOptions.backgroundColor){const r=p.Color3.FromHexString(this.customOptions.backgroundColor);return new p.Color4(r.r,r.g,r.b,t).toLinearSpace()}return new p.Color4(.98,.98,.98,t).toLinearSpace()},this.highlightColorFromConfig=()=>this.customOptions&&this.customOptions.highlightColor?this.hexToColor4(this.customOptions.highlightColor):new p.Color4(.98,.98,.98,1).toLinearSpace(),this.hexToColor4=(t,i=1)=>{const a=p.Color3.FromHexString(t);return new p.Color4(a.r,a.g,a.b,i).toLinearSpace()},this.customOptions=e}createCanvas(){var e;return(e=this.customOptions)!=null&&e.createCanvas?this.customOptions.createCanvas():document.createElement("canvas")}get options(){return this.customOptions}get scene(){var e,t,i,a,o;return{clearColor:this.getSceneClearColor(),transparentBackground:((e=this.customOptions)==null?void 0:e.transparentBackground)||((t=this.customOptions)==null?void 0:t.backgroundImage),environment:{file:((i=this.customOptions)==null?void 0:i.environmentFile)??"assets/model-viewer/default.env",intensity:((a=this.customOptions)==null?void 0:a.environmentIntensity)??1,rotationY:(((o=this.customOptions)==null?void 0:o.environmentRotationY)??0)*(Math.PI/180)}}}get camera(){var e,t,i,a,o,n,r,l,d,u,m,f,b;return{autoOrientation:((e=this.customOptions)==null?void 0:e.disableAutomaticOrientation)??!0,autoRotation:{enabled:((t=this.customOptions)==null?void 0:t.autoRotation)??!1,idleTimeMs:((i=this.customOptions)==null?void 0:i.idleTimeBeforeRotation)??5e3},limits:{min:{alpha:(a=this.customOptions)!=null&&a.lowerAlphaLimitDeg?((o=this.customOptions)==null?void 0:o.lowerAlphaLimitDeg)*Math.PI/180:void 0,beta:(n=this.customOptions)!=null&&n.lowerBetaLimitDeg?((r=this.customOptions)==null?void 0:r.lowerBetaLimitDeg)*Math.PI/180:void 0,radius:(l=this.customOptions)==null?void 0:l.minZoomOverride},max:{alpha:(d=this.customOptions)!=null&&d.upperAlphaLimitDeg?((u=this.customOptions)==null?void 0:u.upperAlphaLimitDeg)*Math.PI/180:void 0,beta:(m=this.customOptions)!=null&&m.upperBetaLimitDeg?((f=this.customOptions)==null?void 0:f.upperBetaLimitDeg)*Math.PI/180:void 0,radius:(b=this.customOptions)==null?void 0:b.maxZoomOverride}}}}get highlights(){var e;return{enabled:((e=this.customOptions)==null?void 0:e.highlightOnMaterialHover)??!1,color:this.highlightColorFromConfig()}}get lighting(){var e,t,i,a;return{exposure:((t=(e=this.customOptions)==null?void 0:e.lighting)==null?void 0:t.exposure)??.9,contrast:((a=(i=this.customOptions)==null?void 0:i.lighting)==null?void 0:a.contrast)??1.6}}get emissiveGlowIntensity(){var e;return((e=this.customOptions)==null?void 0:e.emissiveGlowIntensity)??.5}}class v{static getDynamicTextureResolution(){return this.getIsMobile()||!v.offscreenRenderingSupported()?{width:1024,height:1024}:{width:2048,height:2048}}static shouldMipMap(){return!0}static offscreenRenderingSupported(){return navigator.userAgent.includes("SamsungBrowser")?!1:!!window.Worker&&!!window.OffscreenCanvas}static getMirrorTextureResolution(){return this.getIsMobile()?512:1024}static getIsMobile(){try{return typeof window>"u"||!window.navigator?!1:/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(window.navigator.userAgent)||window.innerWidth<=480}catch{return!1}}}const H=128,c={antiAliasing:{samples:4,fxaaEnabled:!1},bloom:{enabled:!1,kernel:64,scale:.5,threshold:.9,weight:.15},chromaticAberration:{enabled:!1,aberrationAmount:30,direction:{x:0,y:0},radialIntensity:0},colorCurves:{enabled:!1},depthOfField:{enabled:!1,blurLevel:"Low",focalLength:50,focusDistance:2e3,fStop:1.4,lensSize:50},grain:{enabled:!1,animated:!1,intensity:30},misc:{contrast:1,exposure:1,toneMappingEnabled:!1,toneMappingType:"Standard"},sharpen:{enabled:!1,colorAmount:1,edgeAmount:.3},vignette:{enabled:!1,blendMode:"Multiply",cameraFov:.5,center:{x:0,y:0},colorHex:"#000000ff",colorRgba:{r:0,g:0,b:0,a:1},stretch:0,weight:1}};class Be{constructor(e){this.name="glbPostProcessor",this.enabled=!0,this.loader=e}onReady(){this.applyReflections(this.loader.babylonScene)}loadNodeAsync(e,t,i){return this.loader.loadNodeAsync(e,t,function(a){t.extras&&Object.keys(t.extras).forEach(o=>{const n=t.extras[o];a.metadata[o]=n}),i(a)})}async loadMaterialPropertiesAsync(e,t,i){await this.loader.loadMaterialPropertiesAsync(e,t,i),this.enableMaterialExtrasIfRequired(t,i),i.needDepthPrePass=!0}dispose(){}enableMaterialExtrasIfRequired(e,t){if(!(!e.extras||!(t instanceof L.PBRMaterial))){if(e.extras.sheen){const i=t;i.sheen.isEnabled=!0,i.sheen.intensity=e.extras.sheen}if(e.extras.translucency){const i=t;i.subSurface.isTranslucencyEnabled=!0,i.subSurface.translucencyIntensity=e.extras.translucency,e.extras.translucencyR&&e.extras.translucencyG&&e.extras.translucencyB&&(i.subSurface.tintColor=new P.Color3(e.extras.translucencyR,e.extras.translucencyG,e.extras.translucencyB))}if(e.extras.refractionIOR){const i=t;i.subSurface.isRefractionEnabled=!0,i.subSurface.volumeIndexOfRefraction=e.extras.refractionIOR}if(e.extras.useDepthPrePass){const i=t;i.needDepthPrePass=!0,i.forceIrradianceInFragment=!0}if(e.extras.useParallax){const i=t;i.useParallax=!0,i.useParallaxOcclusion=!0,i.parallaxScaleBias=e.extras.useParallax}}}applyReflections(e){function t(o){const n=[];return o.transformNodes.forEach(r=>{r.metadata&&r.metadata.reflective&&n.push(...r.getChildMeshes())}),o.meshes.forEach(r=>{r.metadata&&r.metadata.reflective&&!n.includes(r)&&n.push(r)}),n}function i(o,n=1){const r=o.material;if(!r)return;const l=new Te.MirrorTexture("mirror",v.getMirrorTextureResolution(),e,!0);l.renderList=t(e);const d=o.getVerticesData("normal");if(!d)throw new Error("Mirror attribute specified on: "+o.name+"But no normals exist to generate a mirror from!");o.computeWorldMatrix(!0);const u=o.getWorldMatrix(),m=P.Vector3.TransformNormal(new P.Vector3(d[0],d[1],d[2]),u).normalize(),f=P.Plane.FromPositionAndNormal(o.position,m.scale(-1));l.mirrorPlane=f,l.level=n,r.reflectionTexture=l}function a(o){const n=o.material,r=new Re.ReflectionProbe("probe-"+n.name,H,e);r.attachToMesh(o),r.renderList&&r.renderList.push(...t(e)),n.reflectionTexture=r.cubeTexture}e.meshes.forEach(o=>{const n=o.metadata;n&&(n.mirrorTexture&&i(o,n.mirrorTexture),n.reflectionProbe&&a(o))})}}class je{constructor(e,t){this.scene=e,this.intensity=t,this.meshCount=0}setIntensity(e){this.intensity=e,this.glowLayer&&(this.glowLayer.intensity=e)}includeMeshes(e){if(e){this.glowLayer||(this.glowLayer=new Ae.GlowLayer("glow",this.scene),this.glowLayer.intensity=this.intensity);for(const t of e)this.glowLayer.hasMesh(t)||(this.glowLayer.addIncludedOnlyMesh(t),this.meshCount++)}}removeMeshes(e){if(!(!this.glowLayer||!e)){for(const t of e)this.glowLayer.hasMesh(t)&&(this.glowLayer.removeIncludedOnlyMesh(t),this.meshCount--);this.meshCount===0&&(this.glowLayer.dispose(),this.glowLayer=void 0)}}}const K=new Map;async function U(s,e,t){const i=K.get(s);if(i&&i.scene.uid===e.uid)return i;{const a=await q.SceneLoader.LoadAssetContainerAsync(s,void 0,e,t);return K.set(s,a),a}}function De(s,e,t,i,a=""){t.forEach(o=>{const n=o.getID(),r=o.getName(),l=v.getDynamicTextureResolution();s.filter(u=>u.name===a+r).forEach(u=>{const m=i.get(n),f=!1;if(m)W(u,m),m.update(f);else{const b=qe(r,e,l.width,l.height);i.set(n,b),o.setStaticContext(b.getContext()),W(u,b),b.onLoadObservable.addOnce(()=>{b.update(f)})}})})}function qe(s,e,t,i){const a=new Oe.DynamicTexture(s,{width:t,height:i},e,v.shouldMipMap(),Ie.Texture.TRILINEAR_SAMPLINGMODE,D.Engine.TEXTUREFORMAT_RGBA),o=a.getContext();return o&&(o.fillStyle="#f5f5f5",o.fillRect(0,0,t,i),a.update()),a}function W(s,e){if(s instanceof L.PBRMaterial){const t=s,i=t.albedoTexture;i?(e.wrapU=i.wrapU,e.wrapV=i.wrapV):(e.wrapU=1,e.wrapV=1),t.albedoTexture=e}else{const t=s,i=t.diffuseTexture;i&&(e.wrapU=i.wrapU,e.wrapV=i.wrapV),t.diffuseTexture=e}}function Ve(){const s=()=>Math.floor((1+Math.random())*65536).toString(16).substring(1);return s()+s()+"-"+s()+"-"+s()+"-"+s()+"-"+s()+s()+s()}const x=60,Q=1;function Y(s){return s.targetedAnimations.map(t=>t.animation.framePerSecond).reduce((t,i)=>t+i,0)/s.targetedAnimations.length||0}function ke(s,e,t,i,a){const o=a?s.filter(n=>n.name===a):s;if(o.length===0){console.warn(`No animations found for name: ${a}`);return}if(i!==void 0&&t!==void 0&&i===t){o.forEach(n=>{n.stop();const r=Y(n),l=i*r;n.start(e,Q,l,l)});return}o.forEach(n=>{n.stop();const r=Y(n),l=i!==void 0?i*r:void 0,d=t!==void 0?t*r:void 0;n.start(e,Q,l,d)})}function Z(s){s.forEach(e=>{e.stop()})}function ze(s){const e=s.animationGroups;Z(e)}function Ne(s,e,t){s.stopAnimation(e),e.animations=[],Math.abs(e.alpha)>2*Math.PI&&(e.alpha=Ge(e.alpha,0,2*Math.PI));const i=[],a=t.target,o=0,n=a?1:0;if(t.target&&Object.keys(t.target).length>0&&i.push(E("cameraTargetLerp","target",new g.Vector3().copyFrom(e.target),new g.Vector3(t.target.x,t.target.y,t.target.z),C.Animation.ANIMATIONTYPE_VECTOR3,o)),i.push(E("cameraAlphaLerp","alpha",e.alpha,$(t.lonDeg),C.Animation.ANIMATIONTYPE_FLOAT,n)),i.push(E("cameraBetaLerp","beta",e.beta,$(t.latDeg),C.Animation.ANIMATIONTYPE_FLOAT,n)),t.radius!==void 0){const d=Math.max(.01,t.radius);i.push(E("cameraRadiusLerp","radius",e.radius,d,C.Animation.ANIMATIONTYPE_FLOAT,n))}e.animations.push(...i);const l=e.useAutoRotationBehavior;e.disableAutoRotationBehavior(),s.beginAnimation(e,0,a?x*2:x,!1,1,()=>{e.animations=[],l&&e.enableAutoRotationBehavior()})}function $(s){return s*Math.PI/180}function E(s,e,t,i,a,o=0,n=C.Animation.ANIMATIONLOOPMODE_CONSTANT){const r=new z.QuadraticEase;r.setEasingMode(z.EasingFunction.EASINGMODE_EASEINOUT);const l=new C.Animation(s,e,x,a,n),d=[];return o>0&&d.push({frame:0,value:t}),d.push({frame:x*o,value:t}),d.push({frame:x*(o+1),value:i}),l.setKeys(d),l.setEasingFunction(r),l}function Ge(s,e,t){return s<e?s=t-(e-s)%(t-e):s=e+(s-e)%(t-e)}const He={albedoTexture:"albedoMap",bumpTexture:"normalMap",ambientTexture:"ambientMap",emissiveTexture:"emissionMap",opacityTexture:"alphaMap",metallicTexture:"metallicMap",refractionTexture:"refractionMap",reflectionTexture:"reflectionMap"};function Ke(s,e,t,i){["albedoTexture","bumpTexture","ambientTexture","emissiveTexture","opacityTexture","metallicTexture","refractionTexture","reflectionTexture"].forEach(o=>{Ue(o,s,e,t,i)}),Ye(s,e)}function Ue(s,e,t,i,a){const o=He[s];if(!o)throw new Error("Unexpected texture name encountered.");const n=e[o],r=n==null?void 0:n.fileLink;r?s==="reflectionTexture"?r.endsWith(".env")||r.endsWith(".dds")?i.addCubeTextureTask(s,r,void 0,!1,void 0,!0):r.endsWith(".hdr")?i.addHDRCubeTextureTask(s,r,128,!1,!0,!1):i.addTextureTask(s,r,!1,!1):i.addTextureTask(s,r,!1,!1):a&&t[s]&&(t[s]&&t[s].dispose(),t[s]=null,We(s,t))}function We(s,e){s==="opacityTexture"&&(e.useAlphaFromAlbedoTexture=!0),s==="metallicTexture"&&(e.useRoughnessFromMetallicTextureAlpha=!1,e.useRoughnessFromMetallicTextureGreen=!1,e.useMetallnessFromMetallicTextureBlue=!1),s==="refractionTexture"&&(e.subSurface.isRefractionEnabled=!1,e.subSurface.refractionIntensity=1),s==="reflectionTexture"&&(e.environmentIntensity=1),s==="emissiveTexture"&&(e.emissiveIntensity=0,e.emissiveColor=new p.Color3(0,0,0),e.reflectionTexture)}function Qe(s,e,t,i){if(!e){console.error("Failed to apply texture to material: material is null.");return}s==="opacityTexture"&&(e.useAlphaFromAlbedoTexture=!1),s==="metallicTexture"&&(e.useRoughnessFromMetallicTextureAlpha=!1,e.useRoughnessFromMetallicTextureGreen=!0,e.useMetallnessFromMetallicTextureBlue=!0),s==="refractionTexture"&&(e.subSurface.isRefractionEnabled=!0,e.subSurface.refractionIntensity=t.refractionIntensity||1),s==="reflectionTexture"&&(e.environmentIntensity=t.reflectionIntensity||1,i.isCube&&(i.rotationY=t.reflectionRotation?t.reflectionRotation*Math.PI/180:0)),e[s]=i,s==="emissiveTexture"&&(e.emissiveColor=new p.Color3(1,1,1),e.emissiveIntensity=1)}function Ye(s,e){s.clearCoat&&(s.clearCoat===A.RemoveWhenSelected?(e.clearCoat.isEnabled=!1,e.clearCoat.indexOfRefraction=1.5):s.clearCoat===A.ApplyWhenSelected&&(e.clearCoat.isEnabled=!0,e.clearCoat.indexOfRefraction=s.clearCoatIOR||e.clearCoat.indexOfRefraction))}class Ze{constructor(e,t,i){this.materialVariantMap=new Map,this.keysThatRemovedBaseModel=[],this.loadedContainerForKey=new Map,this.loadedMaterialsForKey=new Map,this.scene=e,this.renameClonedAsset=t,this.setBaseModelEnabled=i}async applyMaterial(e,t,i,a){return new Promise(o=>{const n=this.materialVariantMap.get(e);this.materialVariantMap.set(e,{...n,...t});const r=this.renameClonedAsset(e),l=this.scene.materials.filter(u=>u.name===r);if(l.length===0){o();return}const d=new Se.AssetsManager(this.scene);d.useDefaultLoadingScreen=!1,l.forEach(u=>Ke(t,u,d,a)),d.onProgress=(u,m,f)=>{i&&i(u/m*100,100,f.name)},d.onFinish=u=>{u.forEach(m=>{const f=m;i&&i(100,100,m.name),this.scene.materials.filter(w=>w.name===r).forEach(w=>Qe(m.name,w,t,f.texture))}),o()},d.loadAsync()})}async applyModel(e,t,i,a){var l,d;if(i&&t&&!this.keysThatRemovedBaseModel.includes(e)&&this.keysThatRemovedBaseModel.push(e),!i)return this.keysThatRemovedBaseModel.includes(e)&&this.keysThatRemovedBaseModel.length===1&&await this.setBaseModelEnabled(!0),(l=this.loadedContainerForKey.get(e))==null||l.dispose(),this.loadedContainerForKey.delete(e),this.loadedMaterialsForKey.delete(e),this.keysThatRemovedBaseModel=this.keysThatRemovedBaseModel.filter(u=>u!==e),Promise.resolve(void 0);const n=(await U(i,this.scene,a)).instantiateModelsToScene(this.renameClonedAsset,!0);this.loadedContainerForKey.has(e)&&((d=this.loadedContainerForKey.get(e))==null||d.dispose(),this.loadedContainerForKey.delete(e),this.loadedMaterialsForKey.delete(e)),t&&await this.setBaseModelEnabled(!1),this.loadedContainerForKey.set(e,n),this.loadedMaterialsForKey.set(e,X(n));const r=[];return this.materialVariantMap.forEach(async(u,m)=>{r.push(this.applyMaterial(m,u))}),await Promise.all(r),n}dispose(){this.loadedContainerForKey.forEach(e=>e==null?void 0:e.dispose()),this.loadedContainerForKey.clear(),this.loadedMaterialsForKey.forEach(e=>e.forEach(t=>t==null?void 0:t.dispose())),this.loadedMaterialsForKey.clear(),this.materialVariantMap.clear(),this.keysThatRemovedBaseModel=[]}getAllMaterials(){const e=[];return this.loadedMaterialsForKey.forEach(t=>{t.forEach(i=>{e.includes(i)||e.push(i)})}),e}getAnimationGroups(){const e=[];return this.loadedContainerForKey.forEach(t=>{e.push(...t.animationGroups)}),e}}function X(s){const e=[];return s.rootNodes.forEach(t=>{t.getChildMeshes().forEach(i=>{i.material&&!e.includes(i.material)&&e.push(i.material),i.subMeshes&&i.subMeshes.forEach(a=>{const o=a.getMaterial(!1);o&&!e.includes(o)&&e.push(o)})})}),e}function J(s,e=""){return s.map(t=>({name:t.name.substring(e.length),loop:t.loopAnimation,to:t.to,from:t.from}))}class $e{constructor(e){this.metadata=new Map,this.materialSelectedObservable=new M.Observable,this.materialDeselectedObservable=new M.Observable,this.materialVariantObservable=new M.Observable,this.modelVariantObservable=new M.Observable,this.materialReadyToLoadCallbacks=new Map,this.modelReadyToLoadCallbacks=new Map,this.dynamicTextures=new Map,this.queuedMaterialChanges=new Map,this.materialChangesInProgress=[],this.queuedModelChanges=new Map,this.modelChangesInProgress=[],this.animations=[],this.initialized=!1,this.materials=[];const{enablePicking:t,modelDetails:i,previewService:a,progressHandler:o,scene:n}=e;this.enablePicking=t,this.contextService=i.contextService,this.id=Ve(),this.previewService=a,this.scene=n,this.variantManager=new Ze(n,this.renameClonedAsset.bind(this),this.setBaseModelEnabled.bind(this)),this.transformRoot=new Le.TransformNode("root",this.scene);const r=async()=>{if(!i.model)throw new Error("Model container constructed with no URL. This is currently unsupported.");return this.assetContainer=await U(i.model,n,o),this.initialized=!0,await this.instantiate(),this};this.importPromise=r()}async applyMaterialVariant(e,t,i,a){if(!this.initialized){if(this.materialReadyToLoadCallbacks.has(e)){const n=this.materialReadyToLoadCallbacks.get(e);n==null||n.set(t,this.applyMaterialVariant.bind(this,e,t,i,a))}else{this.materialReadyToLoadCallbacks.set(e,new Map);const n=this.materialReadyToLoadCallbacks.get(e);n==null||n.set(t,this.applyMaterialVariant.bind(this,e,t,i,a))}return}const o=async()=>{await this.variantManager.applyMaterial(e,i,(n,r,l)=>{this.materialVariantObservable.notifyObservers({remainingCount:n,totalCount:r,taskName:l})},a)};if(this.materialChangesInProgress.includes(e)){if(this.queuedMaterialChanges.has(e)){const n=this.queuedMaterialChanges.get(e);n==null||n.set(t,o)}else{this.queuedMaterialChanges.set(e,new Map);const n=this.queuedMaterialChanges.get(e);n==null||n.set(t,o)}return}if(this.materialChangesInProgress.push(e),await o(),this.queuedMaterialChanges.has(e)){const n=this.queuedMaterialChanges.get(e);if(!n)throw new Error("Target material is undefined");n.forEach(async r=>{await r()}),this.queuedMaterialChanges.delete(e)}this.materialChangesInProgress.splice(this.materialChangesInProgress.indexOf(e),1),this.configureGlowLayer()}async applyModelVariant(e,t,i){if(!this.initialized){this.modelReadyToLoadCallbacks.set(e,this.applyModelVariant.bind(this,e,t,i));return}const a=()=>this.variantManager.applyModel(e,i,t==null?void 0:t.model,r=>{this.modelVariantObservable.notifyObservers({...r,key:e})});if(this.modelChangesInProgress.includes(e)){this.queuedModelChanges.set(e,a);return}const n=await(async()=>{this.modelChangesInProgress.push(e);let r=await a();if(this.queuedModelChanges.has(e)){const l=this.queuedModelChanges.get(e);if(!l)throw new Error("Queued change resolved undefined");r=await l(),this.queuedModelChanges.delete(e)}return this.modelChangesInProgress.splice(this.modelChangesInProgress.indexOf(e),1),r})();this.modelInstance&&Z(this.modelInstance.animationGroups),this.contextService||(this.contextService=t==null?void 0:t.contextService),n?this.configureModelInstance(n):this.configureGlowLayer()}dispose(){var e;this.destroyInstance(),this.variantManager.dispose(),this.dynamicTextures.forEach(t=>t==null?void 0:t.dispose()),this.dynamicTextures.clear(),this.materials.forEach(t=>t&&(t==null?void 0:t.dispose())),this.materials=[],(e=this.transformRoot)==null||e.dispose(),this.transformRoot=void 0,this.previewService.modelUnloaded(this)}executeAnimation(e){if(!this.previewService.getInitializationComplete()){this.queuedModelAnimation=e;return}this.modelInstance&&ke([...this.modelInstance.animationGroups,...this.variantManager.getAnimationGroups()],e.loop,e.to,e.from,e.name?this.renameClonedAsset(e.name):void 0)}getAnimations(e){return[...this.animations,...e?J(this.variantManager.getAnimationGroups(),this.renameClonedAsset("")):[]]}getId(){return this.id}listMaterials(){var t;const e=(t=this.scene)==null?void 0:t.materials.filter(i=>i.name.startsWith(this.id));return e?e.map(i=>({id:i.id,name:this.stripIdFromName(i.name)})):[]}registerMaterialSelectedCallback(e){this.materialSelectedObservable.add(e)}unregisterMaterialSelectedCallback(e){this.materialSelectedObservable.removeCallback(e)}registerMaterialDeselectedCallback(e){this.materialDeselectedObservable.add(e)}unregisterMaterialDeselectedCallback(e){this.materialDeselectedObservable.removeCallback(e)}get position(){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to requesting position!");return this.transformRoot.position}set position(e){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to setting position!");this.transformRoot.position=new g.Vector3(e.x,e.y,e.z)}get rotation(){var e;if(!((e=this.transformRoot)!=null&&e.rotationQuaternion))throw new Error("ModelContainer disposed prior to requesting rotation!");return this.transformRoot.rotationQuaternion.toEulerAngles()}set rotation(e){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to setting rotation!");this.transformRoot.rotationQuaternion=g.Quaternion.FromEulerAngles(e.x,e.y,e.z)}get scale(){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to requesting scale!");return this.transformRoot.scaling}set scale(e){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to setting scale!");this.transformRoot.scaling=new g.Vector3(e.x,e.y,e.z)}attachPickingHandler(e){e.rootNodes.forEach(t=>{t.getChildMeshes(!1).forEach(i=>{i.name==="targetcube_t"||i.name==="backgroundShell"||(i.actionManager||(i.actionManager=new O.ActionManager(this.scene)),i.actionManager.registerAction(new k.ExecuteCodeAction(O.ActionManager.OnPointerOverTrigger,a=>{a.meshUnderPointer&&i.material&&this.materialSelectedObservable.notifyObservers({id:i.material.id,name:this.stripIdFromName(i.material.name)})})),i.actionManager.registerAction(new k.ExecuteCodeAction(O.ActionManager.OnPointerOutTrigger,()=>{i.material&&this.materialDeselectedObservable.notifyObservers({id:i.material.id,name:this.stripIdFromName(i.material.name)})})))})})}getInitializationPromise(){return this.importPromise}getIsInitialized(){return this.initialized}getQueuedMaterialVariantCount(){return this.materialReadyToLoadCallbacks.size}getQueuedModelVariantCount(){return this.modelReadyToLoadCallbacks.size}configureGlowLayer(){const e=i=>i instanceof L.PBRMaterial&&i.emissiveTexture!==null;this.materials.some(e)||this.variantManager.getAllMaterials().some(e)?this.previewService.getGlowLayerManager().includeMeshes(this.getAllMeshes()):this.previewService.getGlowLayerManager().removeMeshes(this.getAllMeshes())}configureModelInstance(e){var o;if(!this.transformRoot)throw new Error("Transform disposed! This should never happen unless there is a race condition present!");const t=this.transformRoot.position,i=this.transformRoot.rotationQuaternion,a=this.transformRoot.scaling;this.transformRoot.position=g.Vector3.Zero(),this.transformRoot.rotationQuaternion=g.Quaternion.Identity(),this.transformRoot.scaling=g.Vector3.One();for(const n of e.rootNodes)n.parent=this.transformRoot;this.transformRoot.position=t,this.transformRoot.rotationQuaternion=i,this.transformRoot.scaling=a,this.canvasPanels=((o=this.contextService)==null?void 0:o.getAll())||new Map,De(this.materials.concat(this.variantManager.getAllMaterials()),this.scene,this.canvasPanels,this.dynamicTextures,`${this.id}_`),this.enablePicking&&this.attachPickingHandler(e),this.configureGlowLayer()}destroyInstance(){var e;(e=this.modelInstance)==null||e.dispose(),this.modelInstance=void 0}getAllMeshes(){var e;return(e=this.modelInstance)==null?void 0:e.rootNodes.map(t=>t.getChildMeshes(!1).filter(i=>i instanceof Ee.Mesh)).flat()}async instantiate(){if(!this.assetContainer)throw new Error("Attempted to instantiate ModelContainer without an AssetContainer");this.modelInstance=this.assetContainer.instantiateModelsToScene(this.renameClonedAsset.bind(this),!0),this.materials=X(this.modelInstance),this.configureModelInstance(this.modelInstance),this.animations=J(this.modelInstance.animationGroups,this.renameClonedAsset("")),await this.processQueuedEvents()}renameClonedAsset(e){return`${this.id}_${e}`}async setBaseModelEnabled(e){e&&!this.modelInstance?await this.instantiate():!e&&this.modelInstance&&this.destroyInstance()}updateDynamicTextures(){var e;(e=this.canvasPanels)==null||e.forEach((t,i)=>{const a=this.dynamicTextures.get(i);a&&t.getStaticContextDirty()&&a.isReady()&&(a.update(!1),t.setStaticContextDirty(!1))})}registerMaterialVariantListener(e){this.materialVariantObservable.add(e)}unregisterMaterialVariantListener(e){this.materialVariantObservable.removeCallback(e)}registerModelVariantListener(e){this.modelVariantObservable.add(e)}unregisterModelVariantListener(e){this.modelVariantObservable.removeCallback(e)}stripIdFromName(e){return e.substring(this.id.length+1)}async processQueuedEvents(){await Promise.all(Array.from(this.materialReadyToLoadCallbacks.values()).flatMap(e=>Array.from(e.values()).map(t=>t()))),this.materialReadyToLoadCallbacks.clear(),await Promise.all(Array.from(this.modelReadyToLoadCallbacks.values()).map(e=>e())),this.modelReadyToLoadCallbacks.clear(),this.queuedModelAnimation&&(this.executeAnimation(this.queuedModelAnimation),this.queuedModelAnimation=void 0)}}class S extends y.ArcRotateCamera{constructor(e,t,i,a,o,n,r,l){super(e,t,i,a,o,n,l),this.lastFocus=new g.Vector3(0,0,0),this.panDenominator=1,this.minZ=.01,this.setRadius(this.radius),this.enableFramingBehavior(),this.wheelDeltaPercentage=.01,this.pinchDeltaPercentage=.005,this.useNaturalPinchZoom=!0,r.camera.autoOrientation&&(this.alpha+=Math.PI),r&&(r.camera.limits.min.beta&&(this.lowerBetaLimit=r.camera.limits.min.beta),r.camera.limits.max.beta&&(this.upperBetaLimit=r.camera.limits.max.beta),r.camera.limits.min.alpha&&(this.lowerAlphaLimit=r.camera.limits.min.alpha),r.camera.limits.max.alpha&&(this.upperAlphaLimit=r.camera.limits.max.alpha),r.camera.limits.min.radius&&(this.lowerRadiusLimit=r.camera.limits.min.radius),r.camera.limits.max.radius&&(this.upperRadiusLimit=r.camera.limits.max.radius),r.camera.autoRotation.enabled&&this.enableAutoRotationBehavior(r.camera.autoRotation.idleTimeMs))}getFramingBehavior(){return this.getBehaviorByName("Framing")}getAutoRotationBehavior(){const e=this.getBehaviorByName("AutoRotation");if(e)return e}enableFramingBehavior(){this.useFramingBehavior=!0;const e=this.getFramingBehavior();e.attach(this),e.framingTime=0,e.elevationReturnTime=-1,e.zoomStopsAnimation=!1,this.lowerRadiusLimit=null;const t=F(this._scene);return e.zoomOnBoundingInfo(t.min,t.max),this.wheelPrecision=100/this.radius,this.lowerRadiusLimit===null&&(this.lowerRadiusLimit=.1),this.lastFocus.copyFrom(this.target),e}rerunFramingBehavior(e,t){const i=this.getFramingBehavior();i.framingTime=t||800;const a=()=>{e&&e()},o=F(this._scene),n=o.max.subtract(o.min),r=o.min.add(n.scale(.5));this.setRadius(n.length()*1.5),this.wheelPrecision=100/this.radius,this.panningInertia=0,this.panningOriginTarget.copyFrom(r),this.panDenominator=n.length(),i.zoomOnBoundingInfo(o.min,o.max,void 0,a),i.framingTime=0}enableAutoRotationBehavior(e=5e3){this.useAutoRotationBehavior=!0;const t=this.getAutoRotationBehavior();t&&(t.idleRotationWaitTime=e)}disableAutoRotationBehavior(){this.useAutoRotationBehavior=!1}setRadius(e){this.radius=e,this.maxZ=this.radius*1e3,this.lowerRadiusLimit=this.radius*.01,this.upperRadiusLimit=1.5*this.radius,this.wheelPrecision=100/this.radius,this.pinchPrecision=300/this.radius}static create(e,t,i){const a=F(e),o=a.max.subtract(a.min),n=a.min.add(o.scale(.5)),r=new S("ProductCamera",-(Math.PI/2),Math.PI/2,o.length()*1.5,n,e,t);return r.panningInertia=0,r.panningOriginTarget.copyFrom(n),r.panDenominator=o.length(),r.onAfterCheckInputsObservable.add(()=>{r.panningSensibility=1e3/r.panDenominator}),i&&(e.activeCamera=r),r}}function F(s){if(s.meshes.length===0)return{min:new g.Vector3(-1,-1,-1),max:new g.Vector3(1,1,1)};const e=s.meshes.filter(t=>t.name.toLowerCase().endsWith("_t")||t.name.toLowerCase().includes("_t_"));return s.getWorldExtends(t=>t.isVisible&&t.isEnabled()&&(e.length===0||e.includes(t)))}class Xe{constructor(e,t=!1,i=void 0){this.renderingPipeline=new Fe.DefaultRenderingPipeline("default",t,e,i?[i]:void 0,!1),this.renderingPipeline.isSupported&&(this.renderingPipeline.prepare(),this.setConfiguration(c))}dispose(){this.renderingPipeline.dispose()}getConfiguration(){return this.currentConfiguration}setConfiguration(e){var t,i,a,o,n,r,l,d,u,m,f,b,w,_,ee,te,ie,se,ne,re,ae,oe,le,he,ce,de,ue,ge,me,pe,fe,be,ye;if(this.renderingPipeline.isSupported){if(this.renderingPipeline.samples=((t=e.antiAliasing)==null?void 0:t.samples)??c.antiAliasing.samples,this.renderingPipeline.fxaaEnabled=((i=e.antiAliasing)==null?void 0:i.fxaaEnabled)??c.antiAliasing.fxaaEnabled,this.renderingPipeline.bloomEnabled=((a=e.bloom)==null?void 0:a.enabled)??c.bloom.enabled,this.renderingPipeline.bloomKernel=((o=e.bloom)==null?void 0:o.kernel)??c.bloom.kernel,this.renderingPipeline.bloomScale=((n=e.bloom)==null?void 0:n.scale)??c.bloom.scale,this.renderingPipeline.bloomThreshold=((r=e.bloom)==null?void 0:r.threshold)??c.bloom.threshold,this.renderingPipeline.bloomWeight=((l=e.bloom)==null?void 0:l.weight)??c.bloom.weight,this.renderingPipeline.chromaticAberrationEnabled=((d=e.chromaticAberration)==null?void 0:d.enabled)??c.chromaticAberration.enabled,this.renderingPipeline.chromaticAberration.aberrationAmount=((u=e.chromaticAberration)==null?void 0:u.aberrationAmount)??c.chromaticAberration.aberrationAmount,this.renderingPipeline.chromaticAberration.radialIntensity=((m=e.chromaticAberration)==null?void 0:m.radialIntensity)??c.chromaticAberration.radialIntensity,this.renderingPipeline.chromaticAberration.direction=(f=e.chromaticAberration)!=null&&f.direction?new g.Vector2(e.chromaticAberration.direction.x,e.chromaticAberration.direction.y):new g.Vector2(c.chromaticAberration.direction.x,c.chromaticAberration.direction.y),this.renderingPipeline.imageProcessing.colorCurvesEnabled=((b=e.colorCurves)==null?void 0:b.enabled)??c.colorCurves.enabled,this.renderingPipeline.imageProcessing.colorCurves=e.colorCurves?this.updateColorCurve(e.colorCurves):new N.ColorCurves,this.renderingPipeline.depthOfFieldEnabled=((w=e.depthOfField)==null?void 0:w.enabled)??c.depthOfField.enabled,e.depthOfField)switch(e.depthOfField.blurLevel??c.depthOfField.blurLevel){case"Low":this.renderingPipeline.depthOfFieldBlurLevel=I.DepthOfFieldEffectBlurLevel.Low;break;case"Medium":this.renderingPipeline.depthOfFieldBlurLevel=I.DepthOfFieldEffectBlurLevel.Medium;break;case"High":this.renderingPipeline.depthOfFieldBlurLevel=I.DepthOfFieldEffectBlurLevel.High;break}if(this.renderingPipeline.depthOfField.focalLength=((_=e.depthOfField)==null?void 0:_.focalLength)??c.depthOfField.focalLength,this.renderingPipeline.depthOfField.fStop=((ee=e.depthOfField)==null?void 0:ee.fStop)??c.depthOfField.fStop,this.renderingPipeline.depthOfField.focusDistance=((te=e.depthOfField)==null?void 0:te.focusDistance)??c.depthOfField.focusDistance,this.renderingPipeline.depthOfField.lensSize=((ie=e.depthOfField)==null?void 0:ie.lensSize)??c.depthOfField.lensSize,this.renderingPipeline.grainEnabled=((se=e.grain)==null?void 0:se.enabled)??c.grain.enabled,this.renderingPipeline.grain.animated=((ne=e.grain)==null?void 0:ne.animated)??c.grain.animated,this.renderingPipeline.grain.intensity=((re=e.grain)==null?void 0:re.intensity)??c.grain.intensity,this.renderingPipeline.imageProcessing.contrast=((ae=e.misc)==null?void 0:ae.contrast)??c.misc.contrast,this.renderingPipeline.imageProcessing.exposure=((oe=e.misc)==null?void 0:oe.exposure)??c.misc.exposure,this.renderingPipeline.imageProcessing.toneMappingEnabled=((le=e.misc)==null?void 0:le.toneMappingEnabled)??c.misc.toneMappingEnabled,this.renderingPipeline.imageProcessing.toneMappingEnabled)switch(e.misc.toneMappingType??c.misc.toneMappingType){case"Standard":this.renderingPipeline.imageProcessing.toneMappingType=T.ImageProcessingConfiguration.TONEMAPPING_STANDARD;break;case"ACES":this.renderingPipeline.imageProcessing.toneMappingType=T.ImageProcessingConfiguration.TONEMAPPING_ACES;break}if(this.renderingPipeline.sharpenEnabled=((he=e.sharpen)==null?void 0:he.enabled)??c.sharpen.enabled,this.renderingPipeline.sharpen.colorAmount=((ce=e.sharpen)==null?void 0:ce.colorAmount)??c.sharpen.colorAmount,this.renderingPipeline.sharpen.edgeAmount=((de=e.sharpen)==null?void 0:de.edgeAmount)??c.sharpen.edgeAmount,this.renderingPipeline.imageProcessing.vignetteEnabled=((ue=e.vignette)==null?void 0:ue.enabled)??c.vignette.enabled,(ge=e.vignette)!=null&&ge.center?(this.renderingPipeline.imageProcessing.vignetteCenterX=e.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=e.vignette.center.y):(this.renderingPipeline.imageProcessing.vignetteCenterX=c.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=c.vignette.center.y),e.vignette)switch(((me=e.vignette)==null?void 0:me.blendMode)??c.vignette.blendMode){case"Multiply":this.renderingPipeline.imageProcessing.vignetteBlendMode=T.ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY;break;case"Opaque":this.renderingPipeline.imageProcessing.vignetteBlendMode=T.ImageProcessingConfiguration.VIGNETTEMODE_OPAQUE;break}(pe=e.vignette)!=null&&pe.colorRgba?this.renderingPipeline.imageProcessing.vignetteColor=new p.Color4(e.vignette.colorRgba.r,e.vignette.colorRgba.g,e.vignette.colorRgba.b,e.vignette.colorRgba.a):(fe=e.vignette)!=null&&fe.colorHex?this.renderingPipeline.imageProcessing.vignetteColor=p.Color4.FromHexString(e.vignette.colorHex):this.renderingPipeline.imageProcessing.vignetteColor=new p.Color4(c.vignette.colorRgba.r,c.vignette.colorRgba.g,c.vignette.colorRgba.b,c.vignette.colorRgba.a),this.renderingPipeline.imageProcessing.vignetteStretch=((be=e.vignette)==null?void 0:be.stretch)??c.vignette.stretch,this.renderingPipeline.imageProcessing.vignetteWeight=((ye=e.vignette)==null?void 0:ye.weight)??c.vignette.weight,this.renderingPipeline.prepare(),this.currentConfiguration=e}}updateColorCurve(e){const t=new N.ColorCurves;return t.globalDensity=e.globalDensity??t.globalDensity,t.globalExposure=e.globalExposure??t.globalExposure,t.globalHue=e.globalHue??t.globalHue,t.globalSaturation=e.globalSaturation??t.globalSaturation,t.highlightsDensity=e.highlightsDensity??t.highlightsDensity,t.highlightsExposure=e.highlightsExposure??t.highlightsExposure,t.highlightsHue=e.highlightsHue??t.highlightsHue,t.highlightsSaturation=e.highlightsSaturation??t.highlightsSaturation,t.midtonesDensity=e.midtonesDensity??t.midtonesDensity,t.midtonesExposure=e.midtonesExposure??t.midtonesExposure,t.midtonesHue=e.midtonesHue??t.midtonesHue,t.midtonesSaturation=e.midtonesSaturation??t.midtonesSaturation,t.shadowsDensity=e.shadowsDensity??t.shadowsDensity,t.shadowsExposure=e.shadowsExposure??t.shadowsExposure,t.shadowsHue=e.shadowsHue??t.shadowsHue,t.shadowsSaturation=e.shadowsSaturation??t.shadowsSaturation,t}}Pe.GLTF2.GLTFLoader.RegisterExtension("glbPostProcessor",function(s){return new Be(s)}),q.SceneLoader.OnPluginActivatedObservable.add(s=>{if(s.name==="gltf"){const e=s;e.transparencyAsCoverage=!0}});function B(s){return new g.Vector3(s.x,s.y,s.z)}function j(s){return{x:s.x,y:s.y,z:s.z}}class Je{constructor(e){var l;this.focusLostNotified=!1,this.focusLostObservable=new M.Observable,this.modelLoadEventCallbacks=[],this.modelContainers=new Map,this.plugins=[],this.initComplete=!1,this.renderLoop=()=>{this.engine.views&&(this.modelContainers.forEach(d=>{d.updateDynamicTextures()}),this.scene.render(),!this.camera.target.equalsWithEpsilon(this.camera.lastFocus,.1)&&!this.focusLostNotified&&(this.focusLostObservable.notifyObservers(void 0),this.focusLostNotified=!0),this.screenshotPrepareResolve&&(this.screenshotPrepareResolve(),this.screenshotPrepareResolve=void 0))},this.configuration=new G(e);const i=(()=>{if(!(e!=null&&e.noRender))return this.configuration.createCanvas()})(),a="1.5.6";we.DracoCompression.Configuration={decoder:{wasmUrl:`https://www.gstatic.com/draco/versioned/decoders/${a}/draco_wasm_wrapper_gltf.js`,wasmBinaryUrl:`https://www.gstatic.com/draco/versioned/decoders/${a}/draco_decoder_gltf.wasm`,fallbackUrl:`https://www.gstatic.com/draco/versioned/decoders/${a}/draco_decoder_gltf.js`}},i&&(i.getContext("webgl2")||i.getContext("webgl"));const o=console.log;console.log=()=>{};const n=i?new D.Engine(i,!0,{adaptToDeviceRatio:!0,limitDeviceRatio:2,premultipliedAlpha:!1,preserveDrawingBuffer:!!(e!=null&&e.backgroundImage),audioEngine:!1,stencil:this.configuration.highlights.enabled,forceSRGBBufferSupportState:!0}):new Ce.NullEngine;console.log=o,n.hideLoadingUI(),window.addEventListener("resize",this.fireResizeEvent.bind(this)),this.engine=n,this.scene=new xe.Scene(n),this.scene.autoClear=!0,this.scene.autoClearDepthAndStencil=!0,this.camera=S.create(this.scene,this.configuration),this.scene.activeCamera=this.camera,this.renderingPipeline=new Xe(this.scene,!1,this.camera),this.scene.clearColor=this.configuration.scene.clearColor;const r=V.CubeTexture.CreateFromPrefilteredData(this.configuration.scene.environment.file,this.scene);r.rotationY=this.configuration.scene.environment.rotationY,this.scene.environmentTexture=r,this.scene.environmentIntensity=this.configuration.scene.environment.intensity,(l=this.configuration.options)!=null&&l.renderingPipelineConfiguration?this.renderingPipeline.setConfiguration(this.configuration.options.renderingPipelineConfiguration):(this.scene.imageProcessingConfiguration.exposure=this.configuration.lighting.exposure,this.scene.imageProcessingConfiguration.contrast=this.configuration.lighting.contrast),this.glowLayerManager=new je(this.scene,this.configuration.emissiveGlowIntensity),this.initPromise=new Promise(d=>{this.scene.onReadyObservable.addOnce(()=>{this.initComplete=!0,d()})}),this.engine.runRenderLoop(this.renderLoop)}getInitializationPromise(){return this.initPromise}getInitializationComplete(){return this.initComplete}getEngineContext(){return{engine:this.engine,scene:this.scene,camera:this.camera}}registerFocusLostListener(e){this.focusLostObservable.add(e)}unregisterFocusLostListener(e){this.focusLostObservable.removeCallback(e)}registerModelLoadEventListener(e){this.modelLoadEventCallbacks.push(e)}unregisterModelLoadEventListener(e){const t=this.modelLoadEventCallbacks.indexOf(e);t>-1&&this.modelLoadEventCallbacks.splice(t,1)}registerView(e){const t=e.height,i=e.width;this.engine.registerView(e,void 0,!0),e.setAttribute("height",t.toString()),e.setAttribute("width",i.toString()),this.orbitEnabled()||this.setCameraState(R.Pan),this.reattachControls(e)}getNumViewports(){var e;return((e=this.engine.views)==null?void 0:e.length)||0}unregisterView(e){this.engine.unRegisterView(e)}shutdown(){this.plugins.forEach(e=>e.dispose(!0)),this.renderingPipeline.dispose(),this.engine&&this.engine.dispose(),window.removeEventListener("resize",this.fireResizeEvent)}executeCameraAnimation(e){if(!this.camera||this.scene.activeCamera!==this.camera){this.queuedCameraAnimation=e;return}Ne(this.scene,this.scene.activeCamera,e)}getCameraPose(){if(this.scene&&this.camera)return{lonDeg:Math.round(this.camera.alpha*180/Math.PI),latDeg:Math.round(this.camera.beta*180/Math.PI),radius:Math.round((this.camera.radius+Number.EPSILON)*1e4)/1e4,target:{x:this.camera.target.x,y:this.camera.target.y,z:this.camera.target.z}}}setCameraPose(e){this.scene&&this.camera&&(this.camera.target=new g.Vector3(e.target.x,e.target.y,e.target.z),this.camera.radius=e.radius,this.camera.alpha=e.latDeg,this.camera.beta=e.lonDeg)}setCameraState(e){var t,i;if(!((t=this.engine)!=null&&t.views)||!((i=this.engine)!=null&&i.views[0]))throw new Error("No views attached, camera state requires a view to attach controls onto.");e===R.Orbit?this.reattachControls(this.engine.views[0].target,2):this.reattachControls(this.engine.views[0].target,0)}animateToLastCameraFocus(){return new Promise(e=>{const t=()=>{const i=this.configuration;this.camera.rerunFramingBehavior(()=>{this.focusLostNotified=!1,i.camera.limits.min.radius&&(this.camera.lowerRadiusLimit=i.camera.limits.min.radius),i.camera.limits.max.radius&&(this.camera.upperRadiusLimit=i.camera.limits.max.radius),e()})};this.scene.onAfterRenderObservable.addOnce(t)})}setAutoRotation(e){!this.configuration.camera.autoRotation.enabled||!this.camera||(e?this.camera.enableAutoRotationBehavior(this.configuration.camera.autoRotation.idleTimeMs):this.camera.disableAutoRotationBehavior())}getCurrentConfiguration(){return this.configuration.options}async renderSceneScreenshot(e,t){if(!this.camera)throw new Error("Missing product camera, cannot render screenshot!");const i=new y.ArcRotateCamera("screenshotCamera",0,0,0,g.Vector3.Zero(),this.scene);try{const a=t.latDeg*Math.PI/180,o=t.lonDeg*Math.PI/180;i.target=t.target?new g.Vector3(t.target.x,t.target.y,t.target.z):g.Vector3.Zero(),i.alpha=o,i.beta=a,i.radius=t.radius||this.camera.radius,i.minZ=.01,this.scene.render();const n=await Me.Tools.CreateScreenshotUsingRenderTargetAsync(this.engine,i,e,"image/png",2,!0);return i.dispose(),n}catch{throw i.isDisposed()||i.dispose(),new Error("Failed to render screenshot")}}orbitEnabled(){const e=this.configuration;if(!e)return!0;const t=e.camera.limits.min.alpha,i=e.camera.limits.max.alpha,a=e.camera.limits.min.beta,o=e.camera.limits.max.beta;if(t===void 0||i===void 0||a===void 0||o===void 0)return!0;const n=[t,i],r=[a,o],l=n.every(u=>u===t),d=r.every(u=>u===a);return!l&&!d}fireResizeEvent(){this.getNumViewports()>0&&this.engine.resize()}setHighlights(e,t){var a;e.length===0&&((a=this.highlightLayer)==null||a.dispose(),this.highlightLayer=void 0),this.highlightLayer||(this.highlightLayer=new ve.HighlightLayer("highlights",this.scene,{isStroke:!0,blurVerticalSize:.85,blurHorizontalSize:.85}),this.highlightLayer.innerGlow=!0,this.highlightLayer.outerGlow=!1),this.highlightLayer.removeAllMeshes();const i=t?new p.Color3(t[0],t[1],t[2]).toLinearSpace():void 0;e.forEach(o=>{const n=this.scene.materials.find(r=>r.name===o.name&&r.id===o.id);n&&n.getBindedMeshes().forEach(r=>{var l;return(l=this.highlightLayer)==null?void 0:l.addMesh(r,i||p.Color3.FromHexString("#fcba03"))})})}setRenderingPipelineConfiguration(e){this.renderingPipeline&&this.renderingPipeline.setConfiguration(e)}loadModel(e,t){const i=new $e({enablePicking:this.configuration.highlights.enabled,modelDetails:e,scene:this.scene,previewService:this,progressHandler:t});return i.getInitializationPromise().then(()=>{this.modelContainers.size<=1&&this.camera.rerunFramingBehavior(void 0,1),ze(this.scene),this.queuedCameraAnimation&&(this.executeCameraAnimation(this.queuedCameraAnimation),this.queuedCameraAnimation=void 0)}),this.configuration.highlights.enabled&&(i.registerMaterialSelectedCallback(a=>{this.setHighlights([a])}),i.registerMaterialDeselectedCallback(()=>{this.setHighlights([])})),this.modelContainers.set(i.getId(),i),this.triggerModelLoadEvent({eventType:"load",modelContainer:i}),i}getAllModels(){return Array.from(this.modelContainers.values())}getModelById(e){return this.modelContainers.get(e)}registerPlugin(e){this.plugins.push(e),e.initialize(this,{camera:this.camera,engine:this.engine,scene:this.scene})}unregisterPlugin(e){const t=this.plugins.indexOf(e);t>-1&&this.plugins.splice(t,1).forEach(a=>a.dispose(!1))}getGlowLayerManager(){return this.glowLayerManager}modelUnloaded(e){this.modelContainers.delete(e.getId()),this.triggerModelLoadEvent({eventType:"unload",modelContainer:e})}triggerModelLoadEvent(e){this.modelLoadEventCallbacks.forEach(t=>t(e))}flipTransform(e,t,i){const a=g.Matrix.Compose(B(i||{x:1,y:1,z:1}),g.Quaternion.FromEulerVector(B(t||{x:0,y:0,z:0})),B(e||{x:0,y:0,z:0})),o=g.Matrix.RotationAxis(g.Vector3.Up(),Math.PI),n=a.multiply(o),r=g.Vector3.Zero(),l=g.Quaternion.Identity(),d=g.Vector3.Zero();return n.decompose(d,l,r),l.multiplyInPlace(g.Quaternion.FromEulerAngles(0,Math.PI,0)),{position:j(r),rotation:j(l.toEulerAngles()),scale:j(d)}}updatePreviewOptions(e){var a;const t=new G(e);this.configuration.highlights.enabled!==t.highlights.enabled&&this.engine.setStencilBuffer(t.highlights.enabled),this.scene.clearColor=t.scene.clearColor;let i=this.scene.environmentTexture;this.configuration.scene.environment.file!==t.scene.environment.file&&(i=V.CubeTexture.CreateFromPrefilteredData(t.scene.environment.file,this.scene),i.rotationY=this.configuration.scene.environment.rotationY,this.scene.environmentTexture=i),i.rotationY=t.scene.environment.rotationY,this.scene.environmentIntensity=t.scene.environment.intensity,(a=t.options)!=null&&a.renderingPipelineConfiguration?this.renderingPipeline.setConfiguration(t.options.renderingPipelineConfiguration):(this.scene.imageProcessingConfiguration.exposure=t.lighting.exposure,this.scene.imageProcessingConfiguration.contrast=t.lighting.contrast),this.glowLayerManager.setIntensity(t.emissiveGlowIntensity),this.configuration=t}reattachControls(e,t=2){if(this.scene.detachControl(),this.engine.inputElement=e,this.camera){this.camera.attachControl(!0,!1,t);const i=this.camera.inputs.attached.pointers;i.multiTouchPanning=!1}this.scene.attachControl(!0,!0,!0)}}h.MaterialEffectMode=A,h.ProductCameraRig=R,h.REFLECTION_PROBE_RESOLUTION=H,h.RenderingConfiguration=v,h.SpiffCommerce3DPreviewService=Je,h.renderingPipelineDefaults=c,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED