@spiffcommerce/preview 4.0.2-alpha.5 → 4.1.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +17 -1
- package/dist/index.esm.js +123 -108
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1152,4 +1152,20 @@ declare const REFLECTION_PROBE_RESOLUTION = 128;
|
|
|
1152
1152
|
type PowerOfTwoNumber = 128 | 256 | 512 | 1024 | 2048 | 4096 | 8192;
|
|
1153
1153
|
declare const renderingPipelineDefaults: RenderingPipelineConfiguration;
|
|
1154
1154
|
|
|
1155
|
-
|
|
1155
|
+
/**
|
|
1156
|
+
* Rotates a transform around the origin.
|
|
1157
|
+
* @param transform The transform to rotate. All values are optional and default to standard identity values.
|
|
1158
|
+
* @param axis The axis to rotate around. Defaults to the Y axis.
|
|
1159
|
+
* @param angle The angle to rotate by. Defaults to PI (180 degrees);
|
|
1160
|
+
*/
|
|
1161
|
+
declare function rotateAroundOrigin(transform: {
|
|
1162
|
+
position?: Vector3;
|
|
1163
|
+
rotation?: Vector3;
|
|
1164
|
+
scale?: Vector3;
|
|
1165
|
+
}, axis?: Vector3, angle?: number): {
|
|
1166
|
+
position: Vector3;
|
|
1167
|
+
rotation: Vector3;
|
|
1168
|
+
scale: Vector3;
|
|
1169
|
+
};
|
|
1170
|
+
|
|
1171
|
+
export { AntiAliasingPipelineConfiguration, Asset, BloomPipelineConfiguration, CameraAnimation, CameraPose, ChromaticAberrationPipelineConfiguration, Color4Configuration, ColorCurvesConfiguration, DepthOfFieldPipelineConfiguration, EngineContext, GrainPipelineConfiguration, LoadProgressEventData, MaterialEffectMode, MaterialHandle, MaterialResource, MiscPipelineConfiguration, ModelAnimation, ModelContainer, ModelDetails, ModelLoadEventData, PowerOfTwoNumber, PreviewOptions, PreviewServicePlugin, ProductCameraRig, REFLECTION_PROBE_RESOLUTION, RenderableContext, RenderableContextService, RenderingConfiguration, RenderingPipelineConfiguration, SharpenPipelineConfiguration, SpiffCommerce3DPreviewService, ThreeDPreviewService, Vector, VignettePipelineConfiguration, renderingPipelineDefaults, rotateAroundOrigin };
|
package/dist/index.esm.js
CHANGED
|
@@ -5,30 +5,30 @@ import { HighlightLayer as ve } from "@babylonjs/core/Layers/highlightLayer";
|
|
|
5
5
|
import { SceneLoader as ge } from "@babylonjs/core/Loading/sceneLoader";
|
|
6
6
|
import { CubeTexture as we } from "@babylonjs/core/Materials/Textures/cubeTexture";
|
|
7
7
|
import { Color4 as f, Color3 as w } from "@babylonjs/core/Maths/math.color";
|
|
8
|
-
import { Vector3 as g,
|
|
8
|
+
import { Vector3 as g, Vector2 as J, Matrix as ee, Quaternion as te } from "@babylonjs/core/Maths/math.vector";
|
|
9
9
|
import { DracoCompression as Ce } from "@babylonjs/core/Meshes/Compression/dracoCompression";
|
|
10
10
|
import { Observable as b } from "@babylonjs/core/Misc/observable";
|
|
11
|
-
import { Tools as
|
|
12
|
-
import { Scene as
|
|
11
|
+
import { Tools as Me } from "@babylonjs/core/Misc/tools";
|
|
12
|
+
import { Scene as Pe } from "@babylonjs/core/scene";
|
|
13
13
|
import { GLTF2 as ye } from "@babylonjs/loaders/glTF";
|
|
14
14
|
import { PBRMaterial as T } from "@babylonjs/core/Materials/PBR/pbrMaterial";
|
|
15
15
|
import { MirrorTexture as xe } from "@babylonjs/core/Materials/Textures/mirrorTexture";
|
|
16
|
-
import { Color3 as Le, Vector3 as
|
|
17
|
-
import { ReflectionProbe as
|
|
18
|
-
import { GlowLayer as
|
|
16
|
+
import { Color3 as Le, Vector3 as ie, Plane as Ae } from "@babylonjs/core/Maths/math";
|
|
17
|
+
import { ReflectionProbe as Oe } from "@babylonjs/core/Probes/reflectionProbe";
|
|
18
|
+
import { GlowLayer as Re } from "@babylonjs/core/Layers/glowLayer";
|
|
19
19
|
import { ActionManager as L } from "@babylonjs/core/Actions/actionManager";
|
|
20
|
-
import { ExecuteCodeAction as
|
|
21
|
-
import { Mesh as
|
|
22
|
-
import { TransformNode as
|
|
23
|
-
import { DynamicTexture as
|
|
24
|
-
import { Texture as
|
|
20
|
+
import { ExecuteCodeAction as se } from "@babylonjs/core/Actions/directActions";
|
|
21
|
+
import { Mesh as Ee } from "@babylonjs/core/Meshes/mesh";
|
|
22
|
+
import { TransformNode as Te } from "@babylonjs/core/Meshes/transformNode";
|
|
23
|
+
import { DynamicTexture as Ie } from "@babylonjs/core/Materials/Textures/dynamicTexture";
|
|
24
|
+
import { Texture as Se } from "@babylonjs/core/Materials/Textures/texture";
|
|
25
25
|
import { Animation as v } from "@babylonjs/core/Animations/animation";
|
|
26
|
-
import { QuadraticEase as
|
|
27
|
-
import { AssetsManager as
|
|
26
|
+
import { QuadraticEase as Fe, EasingFunction as Be } from "@babylonjs/core/Animations/easing";
|
|
27
|
+
import { AssetsManager as De } from "@babylonjs/core/Misc/assetsManager";
|
|
28
28
|
import { ColorCurves as ne } from "@babylonjs/core/Materials/colorCurves";
|
|
29
|
-
import { ImageProcessingConfiguration as
|
|
30
|
-
import { DefaultRenderingPipeline as
|
|
31
|
-
import { DepthOfFieldEffectBlurLevel as
|
|
29
|
+
import { ImageProcessingConfiguration as P } from "@babylonjs/core/Materials/imageProcessingConfiguration";
|
|
30
|
+
import { DefaultRenderingPipeline as ze } 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 R = /* @__PURE__ */ ((a) => (a[a.Orbit = 0] = "Orbit", a[a.Pan = 1] = "Pan", a))(R || {}), E = /* @__PURE__ */ ((a) => (a.None = "None", a.RemoveWhenSelected = "RemoveWhenSelected", a.ApplyWhenSelected = "ApplyWhenSelected", a))(E || {});
|
|
43
|
+
class ke {
|
|
44
44
|
constructor(e) {
|
|
45
45
|
this.getSceneClearColor = () => {
|
|
46
46
|
var i, r, n, s;
|
|
@@ -135,12 +135,12 @@ class ze {
|
|
|
135
135
|
return ((e = this.customOptions) == null ? void 0 : e.emissiveGlowIntensity) ?? 0.5;
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
|
-
class
|
|
138
|
+
class M {
|
|
139
139
|
/**
|
|
140
140
|
* Returns the resolution expected for generated textures.
|
|
141
141
|
*/
|
|
142
142
|
static getDynamicTextureResolution() {
|
|
143
|
-
return this.getIsMobile() || !
|
|
143
|
+
return this.getIsMobile() || !M.offscreenRenderingSupported() ? {
|
|
144
144
|
width: 1024,
|
|
145
145
|
height: 1024
|
|
146
146
|
} : {
|
|
@@ -176,7 +176,7 @@ class P {
|
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
|
-
const
|
|
179
|
+
const Ne = 128, h = {
|
|
180
180
|
antiAliasing: {
|
|
181
181
|
samples: 4,
|
|
182
182
|
fxaaEnabled: !1
|
|
@@ -233,7 +233,7 @@ const ke = 128, h = {
|
|
|
233
233
|
weight: 1
|
|
234
234
|
}
|
|
235
235
|
};
|
|
236
|
-
class
|
|
236
|
+
class Ve {
|
|
237
237
|
constructor(e) {
|
|
238
238
|
this.name = "glbPostProcessor", this.enabled = !0, this.loader = e;
|
|
239
239
|
}
|
|
@@ -324,7 +324,7 @@ class Ne {
|
|
|
324
324
|
return;
|
|
325
325
|
const l = new xe(
|
|
326
326
|
"mirror",
|
|
327
|
-
|
|
327
|
+
M.getMirrorTextureResolution(),
|
|
328
328
|
e,
|
|
329
329
|
!0
|
|
330
330
|
);
|
|
@@ -335,19 +335,19 @@ class Ne {
|
|
|
335
335
|
"Mirror attribute specified on: " + n.name + "But no normals exist to generate a mirror from!"
|
|
336
336
|
);
|
|
337
337
|
n.computeWorldMatrix(!0);
|
|
338
|
-
const d = n.getWorldMatrix(), u =
|
|
339
|
-
new
|
|
338
|
+
const d = n.getWorldMatrix(), u = ie.TransformNormal(
|
|
339
|
+
new ie(c[0], c[1], c[2]),
|
|
340
340
|
d
|
|
341
|
-
).normalize(), m =
|
|
341
|
+
).normalize(), m = Ae.FromPositionAndNormal(
|
|
342
342
|
n.position,
|
|
343
343
|
u.scale(-1)
|
|
344
344
|
);
|
|
345
345
|
l.mirrorPlane = m, l.level = s, o.reflectionTexture = l;
|
|
346
346
|
}
|
|
347
347
|
function r(n) {
|
|
348
|
-
const s = n.material, o = new
|
|
348
|
+
const s = n.material, o = new Oe(
|
|
349
349
|
"probe-" + s.name,
|
|
350
|
-
|
|
350
|
+
Ne,
|
|
351
351
|
e
|
|
352
352
|
);
|
|
353
353
|
o.attachToMesh(n), o.renderList && o.renderList.push(...t(e)), s.reflectionTexture = o.cubeTexture;
|
|
@@ -358,12 +358,12 @@ class Ne {
|
|
|
358
358
|
});
|
|
359
359
|
}
|
|
360
360
|
}
|
|
361
|
-
class
|
|
361
|
+
class Ge {
|
|
362
362
|
constructor(e, t) {
|
|
363
363
|
this.scene = e, this.intensity = t, this.meshCount = 0;
|
|
364
364
|
}
|
|
365
365
|
includeMeshes(e) {
|
|
366
|
-
this.glowLayer || (this.glowLayer = new
|
|
366
|
+
this.glowLayer || (this.glowLayer = new Re("glow", this.scene), this.glowLayer.intensity = this.intensity), e.forEach((t) => {
|
|
367
367
|
this.glowLayer.hasMesh(t) || (this.glowLayer.addIncludedOnlyMesh(t), this.meshCount++);
|
|
368
368
|
});
|
|
369
369
|
}
|
|
@@ -389,15 +389,15 @@ async function me(a, e, t) {
|
|
|
389
389
|
}).catch(r);
|
|
390
390
|
});
|
|
391
391
|
}
|
|
392
|
-
function
|
|
392
|
+
function He(a, e, t, i, r = "") {
|
|
393
393
|
t.forEach((n) => {
|
|
394
|
-
const s = n.getID(), o = n.getName(), l =
|
|
394
|
+
const s = n.getID(), o = n.getName(), l = M.getDynamicTextureResolution();
|
|
395
395
|
a.filter((d) => d.name === r + o).forEach((d) => {
|
|
396
396
|
const u = i.get(s), m = !1;
|
|
397
397
|
if (u)
|
|
398
398
|
ae(d, u), u.update(m);
|
|
399
399
|
else {
|
|
400
|
-
const p =
|
|
400
|
+
const p = _e(
|
|
401
401
|
o,
|
|
402
402
|
e,
|
|
403
403
|
l.width,
|
|
@@ -412,13 +412,13 @@ function Ge(a, e, t, i, r = "") {
|
|
|
412
412
|
});
|
|
413
413
|
});
|
|
414
414
|
}
|
|
415
|
-
function
|
|
416
|
-
const r = new
|
|
415
|
+
function _e(a, e, t, i) {
|
|
416
|
+
const r = new Ie(
|
|
417
417
|
a,
|
|
418
418
|
{ width: t, height: i },
|
|
419
419
|
e,
|
|
420
|
-
|
|
421
|
-
|
|
420
|
+
M.shouldMipMap(),
|
|
421
|
+
Se.TRILINEAR_SAMPLINGMODE,
|
|
422
422
|
ue.TEXTUREFORMAT_RGBA
|
|
423
423
|
), n = r.getContext();
|
|
424
424
|
return n && (n.fillStyle = "#f5f5f5", n.fillRect(0, 0, t, i), r.update()), r;
|
|
@@ -432,7 +432,7 @@ function ae(a, e) {
|
|
|
432
432
|
i && (e.wrapU = i.wrapU, e.wrapV = i.wrapV), t.diffuseTexture = e;
|
|
433
433
|
}
|
|
434
434
|
}
|
|
435
|
-
function
|
|
435
|
+
function qe() {
|
|
436
436
|
const a = () => Math.floor((1 + Math.random()) * 65536).toString(16).substring(1);
|
|
437
437
|
return a() + a() + "-" + a() + "-" + a() + "-" + a() + "-" + a() + a() + a();
|
|
438
438
|
}
|
|
@@ -440,7 +440,7 @@ const C = 60, oe = 1;
|
|
|
440
440
|
function le(a) {
|
|
441
441
|
return a.targetedAnimations.map((t) => t.animation.framePerSecond).reduce((t, i) => t + i, 0) / a.targetedAnimations.length || 0;
|
|
442
442
|
}
|
|
443
|
-
function
|
|
443
|
+
function Ke(a, e, t, i, r) {
|
|
444
444
|
const n = r ? a.filter((s) => s.name === r) : a;
|
|
445
445
|
if (n.length === 0) {
|
|
446
446
|
console.warn(`No animations found for name: ${r}`);
|
|
@@ -465,12 +465,12 @@ function pe(a) {
|
|
|
465
465
|
e.stop();
|
|
466
466
|
});
|
|
467
467
|
}
|
|
468
|
-
function
|
|
468
|
+
function Ue(a) {
|
|
469
469
|
const e = a.animationGroups;
|
|
470
470
|
pe(e);
|
|
471
471
|
}
|
|
472
|
-
function
|
|
473
|
-
a.stopAnimation(e), e.animations = [], Math.abs(e.alpha) > 2 * Math.PI && (e.alpha =
|
|
472
|
+
function We(a, e, t) {
|
|
473
|
+
a.stopAnimation(e), e.animations = [], Math.abs(e.alpha) > 2 * Math.PI && (e.alpha = Ze(e.alpha, 0, 2 * Math.PI));
|
|
474
474
|
const i = [], r = t.target, n = 0, s = r ? 1 : 0;
|
|
475
475
|
if (t.target && Object.keys(t.target).length > 0 && i.push(
|
|
476
476
|
y(
|
|
@@ -533,8 +533,8 @@ function he(a) {
|
|
|
533
533
|
return a * Math.PI / 180;
|
|
534
534
|
}
|
|
535
535
|
function y(a, e, t, i, r, n = 0, s = v.ANIMATIONLOOPMODE_CONSTANT) {
|
|
536
|
-
const o = new
|
|
537
|
-
o.setEasingMode(
|
|
536
|
+
const o = new Fe();
|
|
537
|
+
o.setEasingMode(Be.EASINGMODE_EASEINOUT);
|
|
538
538
|
const l = new v(
|
|
539
539
|
a,
|
|
540
540
|
e,
|
|
@@ -547,10 +547,10 @@ function y(a, e, t, i, r, n = 0, s = v.ANIMATIONLOOPMODE_CONSTANT) {
|
|
|
547
547
|
value: i
|
|
548
548
|
}), l.setKeys(c), l.setEasingFunction(o), l;
|
|
549
549
|
}
|
|
550
|
-
function
|
|
550
|
+
function Ze(a, e, t) {
|
|
551
551
|
return a < e ? a = t - (e - a) % (t - e) : a = e + (a - e) % (t - e);
|
|
552
552
|
}
|
|
553
|
-
const
|
|
553
|
+
const $e = {
|
|
554
554
|
albedoTexture: "albedoMap",
|
|
555
555
|
bumpTexture: "normalMap",
|
|
556
556
|
ambientTexture: "ambientMap",
|
|
@@ -559,7 +559,7 @@ const Qe = {
|
|
|
559
559
|
metallicTexture: "metallicMap",
|
|
560
560
|
refractionTexture: "refractionMap"
|
|
561
561
|
};
|
|
562
|
-
function
|
|
562
|
+
function Qe(a, e, t, i) {
|
|
563
563
|
[
|
|
564
564
|
"albedoTexture",
|
|
565
565
|
"bumpTexture",
|
|
@@ -569,32 +569,32 @@ function Ze(a, e, t, i) {
|
|
|
569
569
|
"metallicTexture",
|
|
570
570
|
"refractionTexture"
|
|
571
571
|
].forEach((n) => {
|
|
572
|
-
|
|
572
|
+
Ye(
|
|
573
573
|
n,
|
|
574
574
|
a,
|
|
575
575
|
e,
|
|
576
576
|
t,
|
|
577
577
|
i
|
|
578
578
|
);
|
|
579
|
-
}),
|
|
579
|
+
}), Je(a, e);
|
|
580
580
|
}
|
|
581
|
-
function
|
|
582
|
-
const n =
|
|
581
|
+
function Ye(a, e, t, i, r) {
|
|
582
|
+
const n = $e[a];
|
|
583
583
|
if (!n)
|
|
584
584
|
throw new Error("Unexpected texture name encountered.");
|
|
585
585
|
const s = e[n], o = s == null ? void 0 : s.fileLink;
|
|
586
|
-
o ? i.addTextureTask(a, o, !1, !1) : r && t[a] && (t[a] && t[a].dispose(), t[a] = null,
|
|
586
|
+
o ? i.addTextureTask(a, o, !1, !1) : r && t[a] && (t[a] && t[a].dispose(), t[a] = null, je(a, t));
|
|
587
587
|
}
|
|
588
|
-
function
|
|
588
|
+
function je(a, e) {
|
|
589
589
|
a === "opacityTexture" && (e.useAlphaFromAlbedoTexture = !0), a === "metallicTexture" && (e.useRoughnessFromMetallicTextureAlpha = !1, e.useRoughnessFromMetallicTextureGreen = !1, e.useMetallnessFromMetallicTextureBlue = !1), a === "refractionTexture" && (e.subSurface.isRefractionEnabled = !1, e.subSurface.refractionIntensity = 1), a === "emissiveTexture" && (e.emissiveIntensity = 0, e.emissiveColor = new w(0, 0, 0));
|
|
590
590
|
}
|
|
591
|
-
function
|
|
591
|
+
function Xe(a, e, t, i) {
|
|
592
592
|
a === "opacityTexture" && (e.useAlphaFromAlbedoTexture = !1), a === "metallicTexture" && (e.useRoughnessFromMetallicTextureAlpha = !1, e.useRoughnessFromMetallicTextureGreen = !0, e.useMetallnessFromMetallicTextureBlue = !0), a === "refractionTexture" && (e.subSurface.isRefractionEnabled = !0, e.subSurface.refractionIntensity = t.refractionIntensity || 1), e[a] = i, a === "emissiveTexture" && (e.emissiveColor = new w(1, 1, 1), e.emissiveIntensity = 1);
|
|
593
593
|
}
|
|
594
|
-
function
|
|
595
|
-
a.clearCoat && (a.clearCoat ===
|
|
594
|
+
function Je(a, e) {
|
|
595
|
+
a.clearCoat && (a.clearCoat === E.RemoveWhenSelected ? (e.clearCoat.isEnabled = !1, e.clearCoat.indexOfRefraction = 1.5) : a.clearCoat === E.ApplyWhenSelected && (e.clearCoat.isEnabled = !0, e.clearCoat.indexOfRefraction = a.clearCoatIOR || e.clearCoat.indexOfRefraction));
|
|
596
596
|
}
|
|
597
|
-
class
|
|
597
|
+
class et {
|
|
598
598
|
constructor(e, t, i) {
|
|
599
599
|
this.materialVariantMap = /* @__PURE__ */ new Map(), this.keysThatRemovedBaseModel = [], this.loadedContainerForKey = /* @__PURE__ */ new Map(), this.loadedMaterialsForKey = /* @__PURE__ */ new Map(), this.scene = e, this.renameClonedAsset = t, this.setBaseModelEnabled = i;
|
|
600
600
|
}
|
|
@@ -621,9 +621,9 @@ class Je {
|
|
|
621
621
|
n();
|
|
622
622
|
return;
|
|
623
623
|
}
|
|
624
|
-
const c = new
|
|
624
|
+
const c = new De(this.scene);
|
|
625
625
|
c.useDefaultLoadingScreen = !1, l.forEach(
|
|
626
|
-
(d) =>
|
|
626
|
+
(d) => Qe(
|
|
627
627
|
t,
|
|
628
628
|
d,
|
|
629
629
|
c,
|
|
@@ -635,7 +635,7 @@ class Je {
|
|
|
635
635
|
d.forEach((u) => {
|
|
636
636
|
const m = u;
|
|
637
637
|
i && i(100, 100, u.name), l.forEach(
|
|
638
|
-
(p) =>
|
|
638
|
+
(p) => Xe(
|
|
639
639
|
u.name,
|
|
640
640
|
p,
|
|
641
641
|
t,
|
|
@@ -707,7 +707,7 @@ function ce(a, e = "") {
|
|
|
707
707
|
from: t.from
|
|
708
708
|
}));
|
|
709
709
|
}
|
|
710
|
-
class
|
|
710
|
+
class tt {
|
|
711
711
|
constructor(e) {
|
|
712
712
|
this.metadata = /* @__PURE__ */ new Map(), this.materialSelectedObservable = new b(), this.materialDeselectedObservable = new b(), this.materialVariantObservable = new b(), this.modelVariantObservable = new b(), this.materialReadyToLoadCallbacks = /* @__PURE__ */ new Map(), this.modelReadyToLoadCallbacks = /* @__PURE__ */ new Map(), this.dynamicTextures = /* @__PURE__ */ new Map(), this.queuedMaterialChanges = /* @__PURE__ */ new Map(), this.materialChangesInProgress = [], this.queuedModelChanges = /* @__PURE__ */ new Map(), this.modelChangesInProgress = [], this.animations = [], this.initialized = !1, this.materials = [];
|
|
713
713
|
const {
|
|
@@ -717,13 +717,13 @@ class et {
|
|
|
717
717
|
progressHandler: n,
|
|
718
718
|
scene: s
|
|
719
719
|
} = e;
|
|
720
|
-
this.enablePicking = t, this.contextService = i.contextService, this.id =
|
|
720
|
+
this.enablePicking = t, this.contextService = i.contextService, this.id = qe(), this.previewService = r, this.scene = s, this.variantManager = new et(
|
|
721
721
|
s,
|
|
722
722
|
this.renameClonedAsset.bind(this),
|
|
723
723
|
this.setEnabled.bind(this)
|
|
724
724
|
), this.previewService.registerInitializedListener(
|
|
725
725
|
async () => await this.processQueuedEvents()
|
|
726
|
-
), this.transformRoot = new
|
|
726
|
+
), this.transformRoot = new Te("root", this.scene);
|
|
727
727
|
const o = async () => (this.assetContainer = await me(
|
|
728
728
|
i.model,
|
|
729
729
|
s,
|
|
@@ -847,7 +847,7 @@ class et {
|
|
|
847
847
|
this.queuedModelAnimation = e;
|
|
848
848
|
return;
|
|
849
849
|
}
|
|
850
|
-
this.modelInstance &&
|
|
850
|
+
this.modelInstance && Ke(
|
|
851
851
|
[
|
|
852
852
|
...this.modelInstance.animationGroups,
|
|
853
853
|
...this.variantManager.getAnimationGroups()
|
|
@@ -916,14 +916,14 @@ class et {
|
|
|
916
916
|
e.rootNodes.forEach((t) => {
|
|
917
917
|
t.getChildMeshes(!1).forEach((i) => {
|
|
918
918
|
i.name === "targetcube_t" || i.name === "backgroundShell" || (i.actionManager || (i.actionManager = new L(this.scene)), i.actionManager.registerAction(
|
|
919
|
-
new
|
|
919
|
+
new se(L.OnPointerOverTrigger, (r) => {
|
|
920
920
|
r.meshUnderPointer && i.material && this.materialSelectedObservable.notifyObservers({
|
|
921
921
|
id: i.material.id,
|
|
922
922
|
name: this.stripIdFromName(i.material.name)
|
|
923
923
|
});
|
|
924
924
|
})
|
|
925
925
|
), i.actionManager.registerAction(
|
|
926
|
-
new
|
|
926
|
+
new se(L.OnPointerOutTrigger, () => {
|
|
927
927
|
i.material && this.materialDeselectedObservable.notifyObservers({
|
|
928
928
|
id: i.material.id,
|
|
929
929
|
name: this.stripIdFromName(i.material.name)
|
|
@@ -958,11 +958,9 @@ class et {
|
|
|
958
958
|
configureModelInstance(e) {
|
|
959
959
|
var n;
|
|
960
960
|
const t = this.transformRoot.position, i = this.transformRoot.rotation, r = this.transformRoot.scaling;
|
|
961
|
-
this.transformRoot.position = g.Zero(), this.transformRoot.rotation = g.Zero(), this.transformRoot.scaling = g.One(),
|
|
962
|
-
s.
|
|
963
|
-
|
|
964
|
-
), s.setParent(this.rotationRoot, !0, !1);
|
|
965
|
-
}), this.rotationRoot.rotation = new g(0, Math.PI, 0), this.transformRoot.position = t, this.transformRoot.rotation = i, this.transformRoot.scaling = r, this.canvasPanels = ((n = this.contextService) == null ? void 0 : n.getAll()) || /* @__PURE__ */ new Map(), Ge(
|
|
961
|
+
this.transformRoot.position = g.Zero(), this.transformRoot.rotation = g.Zero(), this.transformRoot.scaling = g.One(), e.rootNodes.forEach((s) => {
|
|
962
|
+
s.parent = this.transformRoot;
|
|
963
|
+
}), this.transformRoot.position = t, this.transformRoot.rotation = i, this.transformRoot.scaling = r, this.canvasPanels = ((n = this.contextService) == null ? void 0 : n.getAll()) || /* @__PURE__ */ new Map(), He(
|
|
966
964
|
this.materials.concat(this.variantManager.getAllMaterials()),
|
|
967
965
|
this.scene,
|
|
968
966
|
this.canvasPanels,
|
|
@@ -980,7 +978,7 @@ class et {
|
|
|
980
978
|
getAllMeshes() {
|
|
981
979
|
var e;
|
|
982
980
|
return (e = this.modelInstance) == null ? void 0 : e.rootNodes.map(
|
|
983
|
-
(t) => t.getChildMeshes(!1).filter((i) => i instanceof
|
|
981
|
+
(t) => t.getChildMeshes(!1).filter((i) => i instanceof Ee)
|
|
984
982
|
).flat();
|
|
985
983
|
}
|
|
986
984
|
instantiate() {
|
|
@@ -1074,7 +1072,7 @@ class I extends de {
|
|
|
1074
1072
|
this.useFramingBehavior = !0;
|
|
1075
1073
|
const e = this.getFramingBehavior();
|
|
1076
1074
|
e.attach(this), e.framingTime = 0, e.elevationReturnTime = -1, e.zoomStopsAnimation = !1, this.lowerRadiusLimit = null;
|
|
1077
|
-
const t =
|
|
1075
|
+
const t = O(this._scene);
|
|
1078
1076
|
return e.zoomOnBoundingInfo(t.min, t.max), this.wheelPrecision = 100 / this.radius, this.lowerRadiusLimit === null && (this.lowerRadiusLimit = 0.1), this.lastFocus.copyFrom(this.target), e;
|
|
1079
1077
|
}
|
|
1080
1078
|
/**
|
|
@@ -1087,7 +1085,7 @@ class I extends de {
|
|
|
1087
1085
|
i.framingTime = t || 800;
|
|
1088
1086
|
const r = () => {
|
|
1089
1087
|
e && e();
|
|
1090
|
-
}, n =
|
|
1088
|
+
}, n = O(this._scene), s = n.max.subtract(n.min), o = n.min.add(s.scale(0.5));
|
|
1091
1089
|
this.setRadius(s.length() * 1.5), this.wheelPrecision = 100 / this.radius, this.panningInertia = 0, this.panningOriginTarget.copyFrom(o), this.panDenominator = s.length(), i.zoomOnBoundingInfo(
|
|
1092
1090
|
n.min,
|
|
1093
1091
|
n.max,
|
|
@@ -1122,7 +1120,7 @@ class I extends de {
|
|
|
1122
1120
|
* @param assignActive If true the camera will be assigned as the active camera on the scene.
|
|
1123
1121
|
*/
|
|
1124
1122
|
static create(e, t, i) {
|
|
1125
|
-
const r =
|
|
1123
|
+
const r = O(e), n = r.max.subtract(r.min), s = r.min.add(n.scale(0.5)), o = new I(
|
|
1126
1124
|
"ProductCamera",
|
|
1127
1125
|
-(Math.PI / 2),
|
|
1128
1126
|
Math.PI / 2,
|
|
@@ -1136,7 +1134,7 @@ class I extends de {
|
|
|
1136
1134
|
}), i && (e.activeCamera = o), o;
|
|
1137
1135
|
}
|
|
1138
1136
|
}
|
|
1139
|
-
function
|
|
1137
|
+
function O(a) {
|
|
1140
1138
|
if (a.meshes.length === 0)
|
|
1141
1139
|
return {
|
|
1142
1140
|
min: new g(-1, -1, -1),
|
|
@@ -1145,9 +1143,9 @@ function A(a) {
|
|
|
1145
1143
|
const e = a.meshes.filter((t) => t.name.toLowerCase().endsWith("_t") || t.name.toLowerCase().includes("_t_"));
|
|
1146
1144
|
return a.getWorldExtends((t) => t.isVisible && t.isEnabled() && (e.length === 0 || e.includes(t)));
|
|
1147
1145
|
}
|
|
1148
|
-
class
|
|
1146
|
+
class it {
|
|
1149
1147
|
constructor(e, t = !1, i = void 0) {
|
|
1150
|
-
this.renderingPipeline = new
|
|
1148
|
+
this.renderingPipeline = new ze(
|
|
1151
1149
|
"default",
|
|
1152
1150
|
t,
|
|
1153
1151
|
e,
|
|
@@ -1163,45 +1161,45 @@ class tt {
|
|
|
1163
1161
|
return this.currentConfiguration;
|
|
1164
1162
|
}
|
|
1165
1163
|
setConfiguration(e) {
|
|
1166
|
-
var t, i, r, n, s, o, l, c, d, u, m, p, S, F, B, D, z, k, N, V, G, H, _, q, K, U, W,
|
|
1164
|
+
var t, i, r, n, s, o, l, c, d, u, m, p, S, F, B, D, z, k, N, V, G, H, _, q, K, U, W, Z, $, Q, Y, j, X;
|
|
1167
1165
|
if (this.renderingPipeline.isSupported) {
|
|
1168
|
-
if (this.renderingPipeline.samples = ((t = e.antiAliasing) == null ? void 0 : t.samples) ?? h.antiAliasing.samples, this.renderingPipeline.fxaaEnabled = ((i = e.antiAliasing) == null ? void 0 : i.fxaaEnabled) ?? h.antiAliasing.fxaaEnabled, this.renderingPipeline.bloomEnabled = ((r = e.bloom) == null ? void 0 : r.enabled) ?? h.bloom.enabled, this.renderingPipeline.bloomKernel = ((n = e.bloom) == null ? void 0 : n.kernel) ?? h.bloom.kernel, this.renderingPipeline.bloomScale = ((s = e.bloom) == null ? void 0 : s.scale) ?? h.bloom.scale, this.renderingPipeline.bloomThreshold = ((o = e.bloom) == null ? void 0 : o.threshold) ?? h.bloom.threshold, this.renderingPipeline.bloomWeight = ((l = e.bloom) == null ? void 0 : l.weight) ?? h.bloom.weight, this.renderingPipeline.chromaticAberrationEnabled = ((c = e.chromaticAberration) == null ? void 0 : c.enabled) ?? h.chromaticAberration.enabled, this.renderingPipeline.chromaticAberration.aberrationAmount = ((d = e.chromaticAberration) == null ? void 0 : d.aberrationAmount) ?? h.chromaticAberration.aberrationAmount, this.renderingPipeline.chromaticAberration.radialIntensity = ((u = e.chromaticAberration) == null ? void 0 : u.radialIntensity) ?? h.chromaticAberration.radialIntensity, this.renderingPipeline.chromaticAberration.direction = (m = e.chromaticAberration) != null && m.direction ? new
|
|
1166
|
+
if (this.renderingPipeline.samples = ((t = e.antiAliasing) == null ? void 0 : t.samples) ?? h.antiAliasing.samples, this.renderingPipeline.fxaaEnabled = ((i = e.antiAliasing) == null ? void 0 : i.fxaaEnabled) ?? h.antiAliasing.fxaaEnabled, this.renderingPipeline.bloomEnabled = ((r = e.bloom) == null ? void 0 : r.enabled) ?? h.bloom.enabled, this.renderingPipeline.bloomKernel = ((n = e.bloom) == null ? void 0 : n.kernel) ?? h.bloom.kernel, this.renderingPipeline.bloomScale = ((s = e.bloom) == null ? void 0 : s.scale) ?? h.bloom.scale, this.renderingPipeline.bloomThreshold = ((o = e.bloom) == null ? void 0 : o.threshold) ?? h.bloom.threshold, this.renderingPipeline.bloomWeight = ((l = e.bloom) == null ? void 0 : l.weight) ?? h.bloom.weight, this.renderingPipeline.chromaticAberrationEnabled = ((c = e.chromaticAberration) == null ? void 0 : c.enabled) ?? h.chromaticAberration.enabled, this.renderingPipeline.chromaticAberration.aberrationAmount = ((d = e.chromaticAberration) == null ? void 0 : d.aberrationAmount) ?? h.chromaticAberration.aberrationAmount, this.renderingPipeline.chromaticAberration.radialIntensity = ((u = e.chromaticAberration) == null ? void 0 : u.radialIntensity) ?? h.chromaticAberration.radialIntensity, this.renderingPipeline.chromaticAberration.direction = (m = e.chromaticAberration) != null && m.direction ? new J(
|
|
1169
1167
|
e.chromaticAberration.direction.x,
|
|
1170
1168
|
e.chromaticAberration.direction.y
|
|
1171
|
-
) : new
|
|
1169
|
+
) : new J(
|
|
1172
1170
|
h.chromaticAberration.direction.x,
|
|
1173
1171
|
h.chromaticAberration.direction.y
|
|
1174
1172
|
), this.renderingPipeline.imageProcessing.colorCurvesEnabled = ((p = e.colorCurves) == null ? void 0 : p.enabled) ?? h.colorCurves.enabled, this.renderingPipeline.imageProcessing.colorCurves = e.colorCurves ? this.updateColorCurve(e.colorCurves) : new ne(), this.renderingPipeline.depthOfFieldEnabled = ((S = e.depthOfField) == null ? void 0 : S.enabled) ?? h.depthOfField.enabled, e.depthOfField)
|
|
1175
1173
|
switch (e.depthOfField.blurLevel ?? h.depthOfField.blurLevel) {
|
|
1176
1174
|
case "Low":
|
|
1177
|
-
this.renderingPipeline.depthOfFieldBlurLevel =
|
|
1175
|
+
this.renderingPipeline.depthOfFieldBlurLevel = A.Low;
|
|
1178
1176
|
break;
|
|
1179
1177
|
case "Medium":
|
|
1180
|
-
this.renderingPipeline.depthOfFieldBlurLevel =
|
|
1178
|
+
this.renderingPipeline.depthOfFieldBlurLevel = A.Medium;
|
|
1181
1179
|
break;
|
|
1182
1180
|
case "High":
|
|
1183
|
-
this.renderingPipeline.depthOfFieldBlurLevel =
|
|
1181
|
+
this.renderingPipeline.depthOfFieldBlurLevel = A.High;
|
|
1184
1182
|
break;
|
|
1185
1183
|
}
|
|
1186
1184
|
if (this.renderingPipeline.depthOfField.focalLength = ((F = e.depthOfField) == null ? void 0 : F.focalLength) ?? h.depthOfField.focalLength, this.renderingPipeline.depthOfField.fStop = ((B = e.depthOfField) == null ? void 0 : B.fStop) ?? h.depthOfField.fStop, this.renderingPipeline.depthOfField.focusDistance = ((D = e.depthOfField) == null ? void 0 : D.focusDistance) ?? h.depthOfField.focusDistance, this.renderingPipeline.depthOfField.lensSize = ((z = e.depthOfField) == null ? void 0 : z.lensSize) ?? h.depthOfField.lensSize, this.renderingPipeline.grainEnabled = ((k = e.grain) == null ? void 0 : k.enabled) ?? h.grain.enabled, this.renderingPipeline.grain.animated = ((N = e.grain) == null ? void 0 : N.animated) ?? h.grain.animated, this.renderingPipeline.grain.intensity = ((V = e.grain) == null ? void 0 : V.intensity) ?? h.grain.intensity, this.renderingPipeline.imageProcessing.contrast = ((G = e.misc) == null ? void 0 : G.contrast) ?? h.misc.contrast, this.renderingPipeline.imageProcessing.exposure = ((H = e.misc) == null ? void 0 : H.exposure) ?? h.misc.exposure, this.renderingPipeline.imageProcessing.toneMappingEnabled = ((_ = e.misc) == null ? void 0 : _.toneMappingEnabled) ?? h.misc.toneMappingEnabled, this.renderingPipeline.imageProcessing.toneMappingEnabled)
|
|
1187
1185
|
switch (e.misc.toneMappingType ?? h.misc.toneMappingType) {
|
|
1188
1186
|
case "Standard":
|
|
1189
|
-
this.renderingPipeline.imageProcessing.toneMappingType =
|
|
1187
|
+
this.renderingPipeline.imageProcessing.toneMappingType = P.TONEMAPPING_STANDARD;
|
|
1190
1188
|
break;
|
|
1191
1189
|
case "ACES":
|
|
1192
|
-
this.renderingPipeline.imageProcessing.toneMappingType =
|
|
1190
|
+
this.renderingPipeline.imageProcessing.toneMappingType = P.TONEMAPPING_ACES;
|
|
1193
1191
|
break;
|
|
1194
1192
|
}
|
|
1195
|
-
if (this.renderingPipeline.sharpenEnabled = ((q = e.sharpen) == null ? void 0 : q.enabled) ?? h.sharpen.enabled, this.renderingPipeline.sharpen.colorAmount = ((K = e.sharpen) == null ? void 0 : K.colorAmount) ?? h.sharpen.colorAmount, this.renderingPipeline.sharpen.edgeAmount = ((U = e.sharpen) == null ? void 0 : U.edgeAmount) ?? h.sharpen.edgeAmount, this.renderingPipeline.imageProcessing.vignetteEnabled = ((W = e.vignette) == null ? void 0 : W.enabled) ?? h.vignette.enabled, (
|
|
1196
|
-
switch (((
|
|
1193
|
+
if (this.renderingPipeline.sharpenEnabled = ((q = e.sharpen) == null ? void 0 : q.enabled) ?? h.sharpen.enabled, this.renderingPipeline.sharpen.colorAmount = ((K = e.sharpen) == null ? void 0 : K.colorAmount) ?? h.sharpen.colorAmount, this.renderingPipeline.sharpen.edgeAmount = ((U = e.sharpen) == null ? void 0 : U.edgeAmount) ?? h.sharpen.edgeAmount, this.renderingPipeline.imageProcessing.vignetteEnabled = ((W = e.vignette) == null ? void 0 : W.enabled) ?? h.vignette.enabled, (Z = e.vignette) != null && Z.center ? (this.renderingPipeline.imageProcessing.vignetteCenterX = e.vignette.center.x, this.renderingPipeline.imageProcessing.vignetteCenterY = e.vignette.center.y) : (this.renderingPipeline.imageProcessing.vignetteCenterX = h.vignette.center.x, this.renderingPipeline.imageProcessing.vignetteCenterY = h.vignette.center.y), e.vignette)
|
|
1194
|
+
switch ((($ = e.vignette) == null ? void 0 : $.blendMode) ?? h.vignette.blendMode) {
|
|
1197
1195
|
case "Multiply":
|
|
1198
|
-
this.renderingPipeline.imageProcessing.vignetteBlendMode =
|
|
1196
|
+
this.renderingPipeline.imageProcessing.vignetteBlendMode = P.VIGNETTEMODE_MULTIPLY;
|
|
1199
1197
|
break;
|
|
1200
1198
|
case "Opaque":
|
|
1201
|
-
this.renderingPipeline.imageProcessing.vignetteBlendMode =
|
|
1199
|
+
this.renderingPipeline.imageProcessing.vignetteBlendMode = P.VIGNETTEMODE_OPAQUE;
|
|
1202
1200
|
break;
|
|
1203
1201
|
}
|
|
1204
|
-
(
|
|
1202
|
+
(Q = e.vignette) != null && Q.colorRgba ? this.renderingPipeline.imageProcessing.vignetteColor = new f(
|
|
1205
1203
|
e.vignette.colorRgba.r,
|
|
1206
1204
|
e.vignette.colorRgba.g,
|
|
1207
1205
|
e.vignette.colorRgba.b,
|
|
@@ -1220,7 +1218,7 @@ class tt {
|
|
|
1220
1218
|
}
|
|
1221
1219
|
}
|
|
1222
1220
|
ye.GLTFLoader.RegisterExtension("glbPostProcessor", function(a) {
|
|
1223
|
-
return new
|
|
1221
|
+
return new Ve(a);
|
|
1224
1222
|
});
|
|
1225
1223
|
ge.OnPluginActivatedObservable.add((a) => {
|
|
1226
1224
|
if (a.name === "gltf") {
|
|
@@ -1229,11 +1227,11 @@ ge.OnPluginActivatedObservable.add((a) => {
|
|
|
1229
1227
|
}
|
|
1230
1228
|
});
|
|
1231
1229
|
const x = "initialScene";
|
|
1232
|
-
class
|
|
1230
|
+
class Kt {
|
|
1233
1231
|
constructor(e) {
|
|
1234
1232
|
this.loadProgress = /* @__PURE__ */ new Map([
|
|
1235
1233
|
[x, 0]
|
|
1236
|
-
]), this.focusLostNotified = !1, this.loadObservable = new b(), this.focusLostObservable = new b(), this.initializedCallbacks = [], this.isInitialized = !1, this.modelLoadEventCallbacks = [], this.modelContainers = /* @__PURE__ */ new Map(), this.plugins = [], this.configuration = new
|
|
1234
|
+
]), this.focusLostNotified = !1, this.loadObservable = new b(), this.focusLostObservable = new b(), this.initializedCallbacks = [], this.isInitialized = !1, this.modelLoadEventCallbacks = [], this.modelContainers = /* @__PURE__ */ new Map(), this.plugins = [], this.configuration = new ke(e);
|
|
1237
1235
|
const i = (() => {
|
|
1238
1236
|
if (!(e != null && e.noRender))
|
|
1239
1237
|
return this.configuration.createCanvas();
|
|
@@ -1257,11 +1255,11 @@ class qt {
|
|
|
1257
1255
|
stencil: this.configuration.highlights.enabled,
|
|
1258
1256
|
forceSRGBBufferSupportState: !0
|
|
1259
1257
|
}) : new be();
|
|
1260
|
-
console.log = n, s.hideLoadingUI(), window.addEventListener("resize", this.fireResizeEvent.bind(this)), this.engine = s, this.scene = new
|
|
1258
|
+
console.log = n, s.hideLoadingUI(), window.addEventListener("resize", this.fireResizeEvent.bind(this)), this.engine = s, this.scene = new Pe(s), this.camera = I.create(this.scene, this.configuration), this.renderingPipeline = new it(
|
|
1261
1259
|
this.scene,
|
|
1262
1260
|
!1,
|
|
1263
1261
|
this.camera
|
|
1264
|
-
), this.scene.imageProcessingConfiguration.exposure = this.configuration.lighting.exposure, this.scene.imageProcessingConfiguration.contrast = this.configuration.lighting.contrast, this.glowLayerManager = new
|
|
1262
|
+
), this.scene.imageProcessingConfiguration.exposure = this.configuration.lighting.exposure, this.scene.imageProcessingConfiguration.contrast = this.configuration.lighting.contrast, this.glowLayerManager = new Ge(
|
|
1265
1263
|
this.scene,
|
|
1266
1264
|
this.configuration.emissiveGlowIntensity
|
|
1267
1265
|
);
|
|
@@ -1306,7 +1304,7 @@ class qt {
|
|
|
1306
1304
|
}
|
|
1307
1305
|
registerView(e) {
|
|
1308
1306
|
const t = e.height, i = e.width;
|
|
1309
|
-
this.engine.registerView(e), e.setAttribute("height", t.toString()), e.setAttribute("width", i.toString()), this.orbitEnabled() || this.setCameraState(
|
|
1307
|
+
this.engine.registerView(e), e.setAttribute("height", t.toString()), e.setAttribute("width", i.toString()), this.orbitEnabled() || this.setCameraState(R.Pan), this.reattachControls(e);
|
|
1310
1308
|
}
|
|
1311
1309
|
getNumViewports() {
|
|
1312
1310
|
var e;
|
|
@@ -1336,7 +1334,7 @@ class qt {
|
|
|
1336
1334
|
s.loaded * 100 / s.total
|
|
1337
1335
|
), this.notifyLoadHandlers();
|
|
1338
1336
|
}
|
|
1339
|
-
).getInitializationPromise()), this.loadProgress.set(x, 100), this.notifyLoadHandlers(), this.scene.activeCamera = this.camera, this.camera.rerunFramingBehavior(void 0, 1),
|
|
1337
|
+
).getInitializationPromise()), this.loadProgress.set(x, 100), this.notifyLoadHandlers(), this.scene.activeCamera = this.camera, this.camera.rerunFramingBehavior(void 0, 1), Ue(this.scene), ((i = this.engine.views) == null ? void 0 : i.length) >= 1 && this.reattachControls(
|
|
1340
1338
|
this.engine.views[this.engine.views.length - 1].target
|
|
1341
1339
|
), this.queuedCameraAnimation && (this.executeCameraAnimation(this.queuedCameraAnimation), this.queuedCameraAnimation = void 0), this.isInitialized = !0, await Promise.all(this.initializedCallbacks.map((n) => n())), this.initializedCallbacks = [], (r = this.configuration.options) != null && r.renderingPipelineConfiguration && this.renderingPipeline.setConfiguration(
|
|
1342
1340
|
this.configuration.options.renderingPipelineConfiguration
|
|
@@ -1359,7 +1357,7 @@ class qt {
|
|
|
1359
1357
|
this.queuedCameraAnimation = e;
|
|
1360
1358
|
return;
|
|
1361
1359
|
}
|
|
1362
|
-
|
|
1360
|
+
We(
|
|
1363
1361
|
this.scene,
|
|
1364
1362
|
this.scene.activeCamera,
|
|
1365
1363
|
e
|
|
@@ -1391,7 +1389,7 @@ class qt {
|
|
|
1391
1389
|
throw new Error(
|
|
1392
1390
|
"No views attached, camera state requires a view to attach controls onto."
|
|
1393
1391
|
);
|
|
1394
|
-
e ===
|
|
1392
|
+
e === R.Orbit ? this.reattachControls(this.engine.views[0].target, 2) : this.reattachControls(this.engine.views[0].target, 0);
|
|
1395
1393
|
}
|
|
1396
1394
|
animateToLastCameraFocus() {
|
|
1397
1395
|
return new Promise((e) => {
|
|
@@ -1426,7 +1424,7 @@ class qt {
|
|
|
1426
1424
|
try {
|
|
1427
1425
|
const r = t.latDeg * Math.PI / 180, n = t.lonDeg * Math.PI / 180;
|
|
1428
1426
|
i.target = t.target ? new g(t.target.x, t.target.y, t.target.z) : g.Zero(), i.alpha = n, i.beta = r, i.radius = t.radius || this.camera.radius, i.minZ = 0.01, this.scene.render();
|
|
1429
|
-
const s = await
|
|
1427
|
+
const s = await Me.CreateScreenshotUsingRenderTargetAsync(
|
|
1430
1428
|
this.engine,
|
|
1431
1429
|
i,
|
|
1432
1430
|
e,
|
|
@@ -1479,7 +1477,7 @@ class qt {
|
|
|
1479
1477
|
this.renderingPipeline && this.renderingPipeline.setConfiguration(e);
|
|
1480
1478
|
}
|
|
1481
1479
|
loadModel(e, t) {
|
|
1482
|
-
const i = new
|
|
1480
|
+
const i = new tt({
|
|
1483
1481
|
enablePicking: this.configuration.highlights.enabled,
|
|
1484
1482
|
modelDetails: e,
|
|
1485
1483
|
scene: this.scene,
|
|
@@ -1571,11 +1569,28 @@ class qt {
|
|
|
1571
1569
|
this.loadObservable.notifyObservers(this.getLoadListenerEvent());
|
|
1572
1570
|
}
|
|
1573
1571
|
}
|
|
1572
|
+
function Ut(a, e = new g(0, 1, 0), t = Math.PI) {
|
|
1573
|
+
const {
|
|
1574
|
+
position: i = g.Zero(),
|
|
1575
|
+
rotation: r = g.Zero(),
|
|
1576
|
+
scale: n = g.One()
|
|
1577
|
+
} = a, s = ee.Compose(
|
|
1578
|
+
n,
|
|
1579
|
+
te.FromEulerVector(r),
|
|
1580
|
+
i
|
|
1581
|
+
), o = ee.RotationAxis(e, t), l = s.multiply(o), c = g.Zero(), d = te.Identity(), u = g.Zero();
|
|
1582
|
+
return l.decompose(u, d, c), {
|
|
1583
|
+
position: c,
|
|
1584
|
+
rotation: d.toEulerAngles(),
|
|
1585
|
+
scale: u
|
|
1586
|
+
};
|
|
1587
|
+
}
|
|
1574
1588
|
export {
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
h as renderingPipelineDefaults
|
|
1589
|
+
E as MaterialEffectMode,
|
|
1590
|
+
R as ProductCameraRig,
|
|
1591
|
+
Ne as REFLECTION_PROBE_RESOLUTION,
|
|
1592
|
+
M as RenderingConfiguration,
|
|
1593
|
+
Kt as SpiffCommerce3DPreviewService,
|
|
1594
|
+
h as renderingPipelineDefaults,
|
|
1595
|
+
Ut as rotateAroundOrigin
|
|
1581
1596
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(l,v){typeof exports=="object"&&typeof module<"u"?v(exports,require("@babylonjs/core/Cameras/arcRotateCamera"),require("@babylonjs/core/Engines/engine"),require("@babylonjs/core/Engines/nullEngine"),require("@babylonjs/core/Layers/highlightLayer"),require("@babylonjs/core/Loading/sceneLoader"),require("@babylonjs/core/Materials/Textures/cubeTexture"),require("@babylonjs/core/Maths/math.color"),require("@babylonjs/core/Maths/math.vector"),require("@babylonjs/core/Meshes/Compression/dracoCompression"),require("@babylonjs/core/Misc/observable"),require("@babylonjs/core/Misc/tools"),require("@babylonjs/core/scene"),require("@babylonjs/loaders/glTF"),require("@babylonjs/core/Materials/PBR/pbrMaterial"),require("@babylonjs/core/Materials/Textures/mirrorTexture"),require("@babylonjs/core/Maths/math"),require("@babylonjs/core/Probes/reflectionProbe"),require("@babylonjs/core/Layers/glowLayer"),require("@babylonjs/core/Actions/actionManager"),require("@babylonjs/core/Actions/directActions"),require("@babylonjs/core/Meshes/mesh"),require("@babylonjs/core/Meshes/transformNode"),require("@babylonjs/core/Materials/Textures/dynamicTexture"),require("@babylonjs/core/Materials/Textures/texture"),require("@babylonjs/core/Animations/animation"),require("@babylonjs/core/Animations/easing"),require("@babylonjs/core/Misc/assetsManager"),require("@babylonjs/core/Materials/colorCurves"),require("@babylonjs/core/Materials/imageProcessingConfiguration"),require("@babylonjs/core/PostProcesses/RenderPipeline"),require("@babylonjs/core/PostProcesses/depthOfFieldEffect"),require("@babylonjs/core/Rendering/depthRendererSceneComponent"),require("@babylonjs/core/Engines/Extensions/engine.views"),require("@babylonjs/core/Meshes/instancedMesh"),require("@babylonjs/core/Materials/Textures/Loaders/ddsTextureLoader"),require("@babylonjs/core/Materials/Textures/Loaders/envTextureLoader"),require("@babylonjs/core/Materials/Textures/Loaders/ktxTextureLoader"),require("@babylonjs/core/Animations/animatable"),require("@babylonjs/core/Misc/screenshotTools"),require("@babylonjs/core/Rendering/boundingBoxRenderer"),require("@babylonjs/loaders/glTF/2.0/Extensions")):typeof define=="function"&&define.amd?define(["exports","@babylonjs/core/Cameras/arcRotateCamera","@babylonjs/core/Engines/engine","@babylonjs/core/Engines/nullEngine","@babylonjs/core/Layers/highlightLayer","@babylonjs/core/Loading/sceneLoader","@babylonjs/core/Materials/Textures/cubeTexture","@babylonjs/core/Maths/math.color","@babylonjs/core/Maths/math.vector","@babylonjs/core/Meshes/Compression/dracoCompression","@babylonjs/core/Misc/observable","@babylonjs/core/Misc/tools","@babylonjs/core/scene","@babylonjs/loaders/glTF","@babylonjs/core/Materials/PBR/pbrMaterial","@babylonjs/core/Materials/Textures/mirrorTexture","@babylonjs/core/Maths/math","@babylonjs/core/Probes/reflectionProbe","@babylonjs/core/Layers/glowLayer","@babylonjs/core/Actions/actionManager","@babylonjs/core/Actions/directActions","@babylonjs/core/Meshes/mesh","@babylonjs/core/Meshes/transformNode","@babylonjs/core/Materials/Textures/dynamicTexture","@babylonjs/core/Materials/Textures/texture","@babylonjs/core/Animations/animation","@babylonjs/core/Animations/easing","@babylonjs/core/Misc/assetsManager","@babylonjs/core/Materials/colorCurves","@babylonjs/core/Materials/imageProcessingConfiguration","@babylonjs/core/PostProcesses/RenderPipeline","@babylonjs/core/PostProcesses/depthOfFieldEffect","@babylonjs/core/Rendering/depthRendererSceneComponent","@babylonjs/core/Engines/Extensions/engine.views","@babylonjs/core/Meshes/instancedMesh","@babylonjs/core/Materials/Textures/Loaders/ddsTextureLoader","@babylonjs/core/Materials/Textures/Loaders/envTextureLoader","@babylonjs/core/Materials/Textures/Loaders/ktxTextureLoader","@babylonjs/core/Animations/animatable","@babylonjs/core/Misc/screenshotTools","@babylonjs/core/Rendering/boundingBoxRenderer","@babylonjs/loaders/glTF/2.0/Extensions"],v):(l=typeof globalThis<"u"?globalThis:l||self,v(l.Preview={},l.arcRotateCamera,l.engine,l.nullEngine,l.highlightLayer,l.sceneLoader,l.cubeTexture,l.math_color,l.math_vector,l.dracoCompression,l.observable,l.tools,l.scene,l.glTF,l.pbrMaterial,l.mirrorTexture,l.math,l.reflectionProbe,l.glowLayer,l.actionManager,l.directActions,l.mesh,l.transformNode,l.dynamicTexture,l.texture,l.animation,l.easing,l.assetsManager,l.colorCurves,l.imageProcessingConfiguration,l.RenderPipeline,l.depthOfFieldEffect))})(this,function(l,v,j,fe,ve,B,ye,p,g,Ce,y,we,Me,Pe,E,xe,P,Le,Te,O,D,Re,q,Ae,Ee,C,V,Oe,z,x,Ie,I){"use strict";var L=(a=>(a[a.Orbit=0]="Orbit",a[a.Pan=1]="Pan",a))(L||{}),T=(a=>(a.None="None",a.RemoveWhenSelected="RemoveWhenSelected",a.ApplyWhenSelected="ApplyWhenSelected",a))(T||{});class Se{constructor(e){this.getSceneClearColor=()=>{var i,n,r,s;const t=(i=this.customOptions)!=null&&i.transparentBackground||(n=this.customOptions)!=null&&n.backgroundImage?0:1;if(this.customOptions&&((r=this.customOptions)!=null&&r.transparentBackground)||(s=this.customOptions)!=null&&s.backgroundImage)return new p.Color4(0,0,0,t).toLinearSpace();if(this.customOptions&&this.customOptions.backgroundColor){const o=p.Color3.FromHexString(this.customOptions.backgroundColor);return new p.Color4(o.r,o.g,o.b,t).toLinearSpace()}return new p.Color4(.98,.98,.98,t).toLinearSpace()},this.highlightColorFromConfig=()=>this.customOptions&&this.customOptions.highlightColor?this.hexToColor4(this.customOptions.highlightColor):new p.Color4(.98,.98,.98,1).toLinearSpace(),this.hexToColor4=(t,i=1)=>{const n=p.Color3.FromHexString(t);return new p.Color4(n.r,n.g,n.b,i).toLinearSpace()},this.customOptions=e}createCanvas(){var e;return(e=this.customOptions)!=null&&e.createCanvas?this.customOptions.createCanvas():document.createElement("canvas")}get options(){return this.customOptions}get scene(){var e,t,i;return{clearColor:this.getSceneClearColor(),transparentBackground:((e=this.customOptions)==null?void 0:e.transparentBackground)||((t=this.customOptions)==null?void 0:t.backgroundImage),environmentFile:((i=this.customOptions)==null?void 0:i.environmentFile)??"assets/model-viewer/default.env"}}get camera(){var e,t,i,n,r,s,o,c,d,u,m,b,f;return{autoOrientation:((e=this.customOptions)==null?void 0:e.disableAutomaticOrientation)??!0,autoRotation:{enabled:((t=this.customOptions)==null?void 0:t.autoRotation)??!1,idleTimeMs:((i=this.customOptions)==null?void 0:i.idleTimeBeforeRotation)??5e3},limits:{min:{alpha:(n=this.customOptions)!=null&&n.lowerAlphaLimitDeg?((r=this.customOptions)==null?void 0:r.lowerAlphaLimitDeg)*Math.PI/180:void 0,beta:(s=this.customOptions)!=null&&s.lowerBetaLimitDeg?((o=this.customOptions)==null?void 0:o.lowerBetaLimitDeg)*Math.PI/180:void 0,radius:(c=this.customOptions)==null?void 0:c.minZoomOverride},max:{alpha:(d=this.customOptions)!=null&&d.upperAlphaLimitDeg?((u=this.customOptions)==null?void 0:u.upperAlphaLimitDeg)*Math.PI/180:void 0,beta:(m=this.customOptions)!=null&&m.upperBetaLimitDeg?((b=this.customOptions)==null?void 0:b.upperBetaLimitDeg)*Math.PI/180:void 0,radius:(f=this.customOptions)==null?void 0:f.maxZoomOverride}}}}get highlights(){var e;return{enabled:((e=this.customOptions)==null?void 0:e.highlightOnMaterialHover)??!1,color:this.highlightColorFromConfig()}}get lighting(){var e,t,i,n;return{exposure:((t=(e=this.customOptions)==null?void 0:e.lighting)==null?void 0:t.exposure)??.9,contrast:((n=(i=this.customOptions)==null?void 0:i.lighting)==null?void 0:n.contrast)??1.6}}get emissiveGlowIntensity(){var e;return((e=this.customOptions)==null?void 0:e.emissiveGlowIntensity)??.5}}class w{static getDynamicTextureResolution(){return this.getIsMobile()||!w.offscreenRenderingSupported()?{width:1024,height:1024}:{width:2048,height:2048}}static shouldMipMap(){return!0}static offscreenRenderingSupported(){return navigator.userAgent.includes("SamsungBrowser")?!1:!!window.Worker&&!!window.OffscreenCanvas}static getMirrorTextureResolution(){return this.getIsMobile()?512:1024}static getIsMobile(){try{return typeof window>"u"||!window.navigator?!1:/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(window.navigator.userAgent)||window.innerWidth<=480}catch{return!1}}}const k=128,h={antiAliasing:{samples:4,fxaaEnabled:!1},bloom:{enabled:!1,kernel:64,scale:.5,threshold:.9,weight:.15},chromaticAberration:{enabled:!1,aberrationAmount:30,direction:{x:0,y:0},radialIntensity:0},colorCurves:{enabled:!1},depthOfField:{enabled:!1,blurLevel:"Low",focalLength:50,focusDistance:2e3,fStop:1.4,lensSize:50},grain:{enabled:!1,animated:!1,intensity:30},misc:{contrast:1,exposure:1,toneMappingEnabled:!1,toneMappingType:"Standard"},sharpen:{enabled:!1,colorAmount:1,edgeAmount:.3},vignette:{enabled:!1,blendMode:"Multiply",cameraFov:.5,center:{x:0,y:0},colorHex:"#000000ff",colorRgba:{r:0,g:0,b:0,a:1},stretch:0,weight:1}};class Fe{constructor(e){this.name="glbPostProcessor",this.enabled=!0,this.loader=e}onReady(){this.applyReflections(this.loader.babylonScene)}loadNodeAsync(e,t,i){return this.loader.loadNodeAsync(e,t,function(n){t.extras&&Object.keys(t.extras).forEach(r=>{const s=t.extras[r];n.metadata[r]=s}),i(n)})}async loadMaterialPropertiesAsync(e,t,i){await this.loader.loadMaterialPropertiesAsync(e,t,i),this.enableMaterialExtrasIfRequired(t,i),i.needDepthPrePass=!0}dispose(){}enableMaterialExtrasIfRequired(e,t){if(!(!e.extras||!(t instanceof E.PBRMaterial))){if(e.extras.sheen){const i=t;i.sheen.isEnabled=!0,i.sheen.intensity=e.extras.sheen}if(e.extras.translucency){const i=t;i.subSurface.isTranslucencyEnabled=!0,i.subSurface.translucencyIntensity=e.extras.translucency,e.extras.translucencyR&&e.extras.translucencyG&&e.extras.translucencyB&&(i.subSurface.tintColor=new P.Color3(e.extras.translucencyR,e.extras.translucencyG,e.extras.translucencyB))}if(e.extras.refractionIOR){const i=t;i.subSurface.isRefractionEnabled=!0,i.subSurface.volumeIndexOfRefraction=e.extras.refractionIOR}if(e.extras.useDepthPrePass){const i=t;i.needDepthPrePass=!0,i.forceIrradianceInFragment=!0}if(e.extras.useParallax){const i=t;i.useParallax=!0,i.useParallaxOcclusion=!0,i.parallaxScaleBias=e.extras.useParallax}}}applyReflections(e){function t(r){const s=[];return r.transformNodes.forEach(o=>{o.metadata&&o.metadata.reflective&&s.push(...o.getChildMeshes())}),r.meshes.forEach(o=>{o.metadata&&o.metadata.reflective&&!s.includes(o)&&s.push(o)}),s}function i(r,s=1){const o=r.material;if(!o)return;const c=new xe.MirrorTexture("mirror",w.getMirrorTextureResolution(),e,!0);c.renderList=t(e);const d=r.getVerticesData("normal");if(!d)throw new Error("Mirror attribute specified on: "+r.name+"But no normals exist to generate a mirror from!");r.computeWorldMatrix(!0);const u=r.getWorldMatrix(),m=P.Vector3.TransformNormal(new P.Vector3(d[0],d[1],d[2]),u).normalize(),b=P.Plane.FromPositionAndNormal(r.position,m.scale(-1));c.mirrorPlane=b,c.level=s,o.reflectionTexture=c}function n(r){const s=r.material,o=new Le.ReflectionProbe("probe-"+s.name,k,e);o.attachToMesh(r),o.renderList&&o.renderList.push(...t(e)),s.reflectionTexture=o.cubeTexture}e.meshes.forEach(r=>{const s=r.metadata;s&&(s.mirrorTexture&&i(r,s.mirrorTexture),s.reflectionProbe&&n(r))})}}class je{constructor(e,t){this.scene=e,this.intensity=t,this.meshCount=0}includeMeshes(e){this.glowLayer||(this.glowLayer=new Te.GlowLayer("glow",this.scene),this.glowLayer.intensity=this.intensity),e.forEach(t=>{this.glowLayer.hasMesh(t)||(this.glowLayer.addIncludedOnlyMesh(t),this.meshCount++)})}removeMeshes(e){this.glowLayer&&(e.forEach(t=>{this.glowLayer.hasMesh(t)&&(this.glowLayer.removeIncludedOnlyMesh(t),this.meshCount--)}),this.meshCount===0&&(this.glowLayer.dispose(),this.glowLayer=void 0))}}const N=new Map;async function G(a,e,t){return new Promise((i,n)=>{const r=N.get(a);if(r&&r.scene.uid===e.uid)return i(r);B.SceneLoader.LoadAssetContainerAsync(a,void 0,e,t).then(s=>{N.set(a,s),i(s)}).catch(n)})}function Be(a,e,t,i,n=""){t.forEach(r=>{const s=r.getID(),o=r.getName(),c=w.getDynamicTextureResolution();a.filter(u=>u.name===n+o).forEach(u=>{const m=i.get(s),b=!1;if(m)H(u,m),m.update(b);else{const f=De(o,e,c.width,c.height);i.set(s,f),r.setStaticContext(f.getContext()),H(u,f),f.onLoadObservable.addOnce(()=>{f.update(b)})}})})}function De(a,e,t,i){const n=new Ae.DynamicTexture(a,{width:t,height:i},e,w.shouldMipMap(),Ee.Texture.TRILINEAR_SAMPLINGMODE,j.Engine.TEXTUREFORMAT_RGBA),r=n.getContext();return r&&(r.fillStyle="#f5f5f5",r.fillRect(0,0,t,i),n.update()),n}function H(a,e){if(a instanceof E.PBRMaterial){const t=a,i=t.albedoTexture;i?(e.wrapU=i.wrapU,e.wrapV=i.wrapV):(e.wrapU=1,e.wrapV=1),t.albedoTexture=e}else{const t=a,i=t.diffuseTexture;i&&(e.wrapU=i.wrapU,e.wrapV=i.wrapV),t.diffuseTexture=e}}function qe(){const a=()=>Math.floor((1+Math.random())*65536).toString(16).substring(1);return a()+a()+"-"+a()+"-"+a()+"-"+a()+"-"+a()+a()+a()}const M=60,K=1;function U(a){return a.targetedAnimations.map(t=>t.animation.framePerSecond).reduce((t,i)=>t+i,0)/a.targetedAnimations.length||0}function Ve(a,e,t,i,n){const r=n?a.filter(s=>s.name===n):a;if(r.length===0){console.warn(`No animations found for name: ${n}`);return}if(i!==void 0&&t!==void 0&&i===t){r.forEach(s=>{s.stop();const o=U(s),c=i*o;s.start(e,K,c,c)});return}r.forEach(s=>{s.stop();const o=U(s),c=i!==void 0?i*o:void 0,d=t!==void 0?t*o:void 0;s.start(e,K,c,d)})}function W(a){a.forEach(e=>{e.stop()})}function ze(a){const e=a.animationGroups;W(e)}function ke(a,e,t){a.stopAnimation(e),e.animations=[],Math.abs(e.alpha)>2*Math.PI&&(e.alpha=Ne(e.alpha,0,2*Math.PI));const i=[],n=t.target,r=0,s=n?1:0;if(t.target&&Object.keys(t.target).length>0&&i.push(R("cameraTargetLerp","target",new g.Vector3().copyFrom(e.target),new g.Vector3(t.target.x,t.target.y,t.target.z),C.Animation.ANIMATIONTYPE_VECTOR3,r)),i.push(R("cameraAlphaLerp","alpha",e.alpha,Q(t.lonDeg),C.Animation.ANIMATIONTYPE_FLOAT,s)),i.push(R("cameraBetaLerp","beta",e.beta,Q(t.latDeg),C.Animation.ANIMATIONTYPE_FLOAT,s)),t.radius!==void 0){const d=Math.max(.01,t.radius);i.push(R("cameraRadiusLerp","radius",e.radius,d,C.Animation.ANIMATIONTYPE_FLOAT,s))}e.animations.push(...i);const c=e.useAutoRotationBehavior;e.disableAutoRotationBehavior(),a.beginAnimation(e,0,n?M*2:M,!1,1,()=>{e.animations=[],c&&e.enableAutoRotationBehavior()})}function Q(a){return a*Math.PI/180}function R(a,e,t,i,n,r=0,s=C.Animation.ANIMATIONLOOPMODE_CONSTANT){const o=new V.QuadraticEase;o.setEasingMode(V.EasingFunction.EASINGMODE_EASEINOUT);const c=new C.Animation(a,e,M,n,s),d=[];return r>0&&d.push({frame:0,value:t}),d.push({frame:M*r,value:t}),d.push({frame:M*(r+1),value:i}),c.setKeys(d),c.setEasingFunction(o),c}function Ne(a,e,t){return a<e?a=t-(e-a)%(t-e):a=e+(a-e)%(t-e)}const Ge={albedoTexture:"albedoMap",bumpTexture:"normalMap",ambientTexture:"ambientMap",emissiveTexture:"emissionMap",opacityTexture:"alphaMap",metallicTexture:"metallicMap",refractionTexture:"refractionMap"};function He(a,e,t,i){["albedoTexture","bumpTexture","ambientTexture","emissiveTexture","opacityTexture","metallicTexture","refractionTexture"].forEach(r=>{Ke(r,a,e,t,i)}),Qe(a,e)}function Ke(a,e,t,i,n){const r=Ge[a];if(!r)throw new Error("Unexpected texture name encountered.");const s=e[r],o=s==null?void 0:s.fileLink;o?i.addTextureTask(a,o,!1,!1):n&&t[a]&&(t[a]&&t[a].dispose(),t[a]=null,Ue(a,t))}function Ue(a,e){a==="opacityTexture"&&(e.useAlphaFromAlbedoTexture=!0),a==="metallicTexture"&&(e.useRoughnessFromMetallicTextureAlpha=!1,e.useRoughnessFromMetallicTextureGreen=!1,e.useMetallnessFromMetallicTextureBlue=!1),a==="refractionTexture"&&(e.subSurface.isRefractionEnabled=!1,e.subSurface.refractionIntensity=1),a==="emissiveTexture"&&(e.emissiveIntensity=0,e.emissiveColor=new p.Color3(0,0,0))}function We(a,e,t,i){a==="opacityTexture"&&(e.useAlphaFromAlbedoTexture=!1),a==="metallicTexture"&&(e.useRoughnessFromMetallicTextureAlpha=!1,e.useRoughnessFromMetallicTextureGreen=!0,e.useMetallnessFromMetallicTextureBlue=!0),a==="refractionTexture"&&(e.subSurface.isRefractionEnabled=!0,e.subSurface.refractionIntensity=t.refractionIntensity||1),e[a]=i,a==="emissiveTexture"&&(e.emissiveColor=new p.Color3(1,1,1),e.emissiveIntensity=1)}function Qe(a,e){a.clearCoat&&(a.clearCoat===T.RemoveWhenSelected?(e.clearCoat.isEnabled=!1,e.clearCoat.indexOfRefraction=1.5):a.clearCoat===T.ApplyWhenSelected&&(e.clearCoat.isEnabled=!0,e.clearCoat.indexOfRefraction=a.clearCoatIOR||e.clearCoat.indexOfRefraction))}class Ze{constructor(e,t,i){this.materialVariantMap=new Map,this.keysThatRemovedBaseModel=[],this.loadedContainerForKey=new Map,this.loadedMaterialsForKey=new Map,this.scene=e,this.renameClonedAsset=t,this.setBaseModelEnabled=i}async applyMaterial(e,t,i,n){return new Promise(r=>{const s=this.materialVariantMap.get(e);this.materialVariantMap.set(e,{...s,...t});const o=this.renameClonedAsset(e),c=this.scene.materials.filter(u=>u.name===o);if(c.length===0){r();return}const d=new Oe.AssetsManager(this.scene);d.useDefaultLoadingScreen=!1,c.forEach(u=>He(t,u,d,n)),d.onProgress=(u,m,b)=>{i&&i(u/m*100,100,b.name)},d.onFinish=u=>{u.forEach(m=>{const b=m;i&&i(100,100,m.name),c.forEach(f=>We(m.name,f,t,b.texture))}),r()},d.loadAsync()})}async applyModel(e,t,i,n){var c,d;if(i&&t&&!this.keysThatRemovedBaseModel.includes(e)&&this.keysThatRemovedBaseModel.push(e),!i)return this.keysThatRemovedBaseModel.includes(e)&&this.setBaseModelEnabled(!0),(c=this.loadedContainerForKey.get(e))==null||c.dispose(),this.loadedContainerForKey.delete(e),this.loadedMaterialsForKey.delete(e),Promise.resolve(void 0);this.loadedContainerForKey.has(e)&&((d=this.loadedContainerForKey.get(e))==null||d.dispose(),this.loadedContainerForKey.delete(e),this.loadedMaterialsForKey.delete(e)),t&&this.setBaseModelEnabled(!1);const s=(await G(i,this.scene,n)).instantiateModelsToScene(this.renameClonedAsset,!0);this.loadedContainerForKey.set(e,s),this.loadedMaterialsForKey.set(e,Z(s));const o=[];return this.materialVariantMap.forEach(async(u,m)=>{o.push(this.applyMaterial(m,u))}),await Promise.all(o),s}dispose(){this.loadedContainerForKey.forEach(e=>e==null?void 0:e.dispose()),this.loadedContainerForKey.clear(),this.loadedMaterialsForKey.forEach(e=>e.forEach(t=>t==null?void 0:t.dispose())),this.loadedMaterialsForKey.clear(),this.materialVariantMap.clear(),this.keysThatRemovedBaseModel=[]}getAllMaterials(){const e=[];return this.loadedMaterialsForKey.forEach(t=>{t.forEach(i=>{e.includes(i)||e.push(i)})}),e}getAnimationGroups(){const e=[];return this.loadedContainerForKey.forEach(t=>{e.push(...t.animationGroups)}),e}}function Z(a){const e=[];return a.rootNodes.forEach(t=>{t.getChildMeshes().forEach(i=>{i.material&&!e.includes(i.material)&&e.push(i.material),i.subMeshes&&i.subMeshes.forEach(n=>{const r=n.getMaterial(!1);r&&!e.includes(r)&&e.push(r)})})}),e}function $(a,e=""){return a.map(t=>({name:t.name.substring(e.length),loop:t.loopAnimation,to:t.to,from:t.from}))}class $e{constructor(e){this.metadata=new Map,this.materialSelectedObservable=new y.Observable,this.materialDeselectedObservable=new y.Observable,this.materialVariantObservable=new y.Observable,this.modelVariantObservable=new y.Observable,this.materialReadyToLoadCallbacks=new Map,this.modelReadyToLoadCallbacks=new Map,this.dynamicTextures=new Map,this.queuedMaterialChanges=new Map,this.materialChangesInProgress=[],this.queuedModelChanges=new Map,this.modelChangesInProgress=[],this.animations=[],this.initialized=!1,this.materials=[];const{enablePicking:t,modelDetails:i,previewService:n,progressHandler:r,scene:s}=e;this.enablePicking=t,this.contextService=i.contextService,this.id=qe(),this.previewService=n,this.scene=s,this.variantManager=new Ze(s,this.renameClonedAsset.bind(this),this.setEnabled.bind(this)),this.previewService.registerInitializedListener(async()=>await this.processQueuedEvents()),this.transformRoot=new q.TransformNode("root",this.scene),this.rotationRoot=new q.TransformNode("rotationRoot",this.scene),this.rotationRoot.setParent(this.transformRoot,!0,!1),this.rotationRoot.rotation=new g.Vector3(0,Math.PI,0);const o=async()=>(this.assetContainer=await G(i.model,s,r),this.initialized=!0,this.instantiate(),this);this.importPromise=o()}async applyMaterialVariant(e,t,i,n){if(this.previewService.getSceneInitializationProgress()!==100||!this.initialized){if(this.materialReadyToLoadCallbacks.has(e)){const s=this.materialReadyToLoadCallbacks.get(e);s==null||s.set(t,this.applyMaterialVariant.bind(this,e,t,i,n))}else{this.materialReadyToLoadCallbacks.set(e,new Map);const s=this.materialReadyToLoadCallbacks.get(e);s==null||s.set(t,this.applyMaterialVariant.bind(this,e,t,i,n))}return}const r=async()=>{await this.variantManager.applyMaterial(e,i,(s,o,c)=>{this.materialVariantObservable.notifyObservers({remainingCount:s,totalCount:o,taskName:c})},n)};if(this.materialChangesInProgress.includes(e)){if(this.queuedMaterialChanges.has(e)){const s=this.queuedMaterialChanges.get(e);s==null||s.set(t,r)}else{this.queuedMaterialChanges.set(e,new Map);const s=this.queuedMaterialChanges.get(e);s==null||s.set(t,r)}return}this.materialChangesInProgress.push(e),await r(),this.queuedMaterialChanges.has(e)&&(this.queuedMaterialChanges.get(e).forEach(async o=>{await o()}),this.queuedMaterialChanges.delete(e)),this.materialChangesInProgress.splice(this.materialChangesInProgress.indexOf(e),1),this.configureGlowLayer()}async applyModelVariant(e,t,i){if(!this.previewService.getIsInitialized()||!this.initialized){this.modelReadyToLoadCallbacks.set(e,this.applyModelVariant.bind(this,e,t,i));return}const n=()=>this.variantManager.applyModel(e,i,t==null?void 0:t.model,o=>{this.modelVariantObservable.notifyObservers({...o,key:e})});if(this.modelChangesInProgress.includes(e)){this.queuedModelChanges.set(e,n);return}const s=await(async()=>{this.modelChangesInProgress.push(e);let o=await n();return this.queuedModelChanges.has(e)&&(o=await this.queuedModelChanges.get(e)(),this.queuedModelChanges.delete(e)),this.modelChangesInProgress.splice(this.modelChangesInProgress.indexOf(e),1),o})();this.modelInstance&&W(this.modelInstance.animationGroups),this.contextService||(this.contextService=t==null?void 0:t.contextService),s?this.configureModelInstance(s):this.configureGlowLayer()}dispose(){var e;this.destroyInstance(),this.variantManager.dispose(),this.dynamicTextures.forEach(t=>t==null?void 0:t.dispose()),this.dynamicTextures.clear(),this.materials.forEach(t=>t&&(t==null?void 0:t.dispose())),this.materials=[],(e=this.transformRoot)==null||e.dispose(),this.transformRoot=void 0,this.previewService.modelUnloaded(this)}executeAnimation(e){if(!this.previewService.getIsInitialized()){this.queuedModelAnimation=e;return}this.modelInstance&&Ve([...this.modelInstance.animationGroups,...this.variantManager.getAnimationGroups()],e.loop,e.to,e.from,e.name?this.renameClonedAsset(e.name):void 0)}getAnimations(e){return[...this.animations,...e?$(this.variantManager.getAnimationGroups(),this.renameClonedAsset("")):[]]}getId(){return this.id}listMaterials(){var t;const e=(t=this.scene)==null?void 0:t.materials.filter(i=>i.name.startsWith(this.id));return e?e.map(i=>({id:i.id,name:this.stripIdFromName(i.name)})):[]}registerMaterialSelectedCallback(e){this.materialSelectedObservable.add(e)}unregisterMaterialSelectedCallback(e){this.materialSelectedObservable.removeCallback(e)}registerMaterialDeselectedCallback(e){this.materialDeselectedObservable.add(e)}unregisterMaterialDeselectedCallback(e){this.materialDeselectedObservable.removeCallback(e)}get position(){return this.transformRoot.position}set position(e){this.transformRoot.position=new g.Vector3(e.x,e.y,e.z)}get rotation(){return this.transformRoot.rotation}set rotation(e){this.transformRoot.rotation=new g.Vector3(e.x,e.y,e.z)}get scale(){return this.transformRoot.scaling}set scale(e){this.transformRoot.scaling=new g.Vector3(e.x,e.y,e.z)}attachPickingHandler(e){e.rootNodes.forEach(t=>{t.getChildMeshes(!1).forEach(i=>{i.name==="targetcube_t"||i.name==="backgroundShell"||(i.actionManager||(i.actionManager=new O.ActionManager(this.scene)),i.actionManager.registerAction(new D.ExecuteCodeAction(O.ActionManager.OnPointerOverTrigger,n=>{n.meshUnderPointer&&i.material&&this.materialSelectedObservable.notifyObservers({id:i.material.id,name:this.stripIdFromName(i.material.name)})})),i.actionManager.registerAction(new D.ExecuteCodeAction(O.ActionManager.OnPointerOutTrigger,()=>{i.material&&this.materialDeselectedObservable.notifyObservers({id:i.material.id,name:this.stripIdFromName(i.material.name)})})))})})}getInitializationPromise(){return this.importPromise}getIsInitialized(){return this.initialized}getQueuedMaterialVariantCount(){return this.materialReadyToLoadCallbacks.size}getQueuedModelVariantCount(){return this.modelReadyToLoadCallbacks.size}configureGlowLayer(){const e=i=>i instanceof E.PBRMaterial&&i.emissiveTexture!==null;this.materials.some(e)||this.variantManager.getAllMaterials().some(e)?this.previewService.getGlowLayerManager().includeMeshes(this.getAllMeshes()):this.previewService.getGlowLayerManager().removeMeshes(this.getAllMeshes())}configureModelInstance(e){var r;const t=this.transformRoot.position,i=this.transformRoot.rotation,n=this.transformRoot.scaling;this.transformRoot.position=g.Vector3.Zero(),this.transformRoot.rotation=g.Vector3.Zero(),this.transformRoot.scaling=g.Vector3.One(),this.rotationRoot.rotation=new g.Vector3(0,0,0),e.rootNodes.forEach(s=>{s.rotationQuaternion||(s.rotationQuaternion=g.Quaternion.FromEulerVector(s.rotation)),s.rotationQuaternion.subtractInPlace(g.Quaternion.FromEulerAngles(0,Math.PI,0)),s.setParent(this.rotationRoot,!0,!1)}),this.rotationRoot.rotation=new g.Vector3(0,Math.PI,0),this.transformRoot.position=t,this.transformRoot.rotation=i,this.transformRoot.scaling=n,this.canvasPanels=((r=this.contextService)==null?void 0:r.getAll())||new Map,Be(this.materials.concat(this.variantManager.getAllMaterials()),this.scene,this.canvasPanels,this.dynamicTextures,`${this.id}_`),this.enablePicking&&this.attachPickingHandler(e),this.configureGlowLayer()}destroyInstance(){var e;(e=this.modelInstance)==null||e.dispose(),this.modelInstance=void 0}getAllMeshes(){var e;return(e=this.modelInstance)==null?void 0:e.rootNodes.map(t=>t.getChildMeshes(!1).filter(i=>i instanceof Re.Mesh)).flat()}instantiate(){this.modelInstance=this.assetContainer.instantiateModelsToScene(this.renameClonedAsset.bind(this),!0),this.materials=Z(this.modelInstance),this.configureModelInstance(this.modelInstance),this.animations=$(this.modelInstance.animationGroups,this.renameClonedAsset("")),this.processQueuedEvents()}renameClonedAsset(e){return`${this.id}_${e}`}setEnabled(e){e&&!this.modelInstance?this.instantiate():!e&&this.modelInstance&&this.destroyInstance()}updateDynamicTextures(){var e;(e=this.canvasPanels)==null||e.forEach((t,i)=>{const n=this.dynamicTextures.get(i);n&&t.getStaticContextDirty()&&n.isReady()&&(n.update(!1),t.setStaticContextDirty(!1))})}registerMaterialVariantListener(e){this.materialVariantObservable.add(e)}unregisterMaterialVariantListener(e){this.materialVariantObservable.removeCallback(e)}registerModelVariantListener(e){this.modelVariantObservable.add(e)}unregisterModelVariantListener(e){this.modelVariantObservable.removeCallback(e)}stripIdFromName(e){return e.substring(this.id.length+1)}async processQueuedEvents(){this.previewService.getIsInitialized()&&(await Promise.all(Array.from(this.materialReadyToLoadCallbacks.values()).map(e=>Array.from(e.values()).map(t=>t()))),this.materialReadyToLoadCallbacks.clear(),await Promise.all(Array.from(this.modelReadyToLoadCallbacks.values()).map(e=>e())),this.modelReadyToLoadCallbacks.clear(),this.queuedModelAnimation&&(this.executeAnimation(this.queuedModelAnimation),this.queuedModelAnimation=void 0))}}class S extends v.ArcRotateCamera{constructor(e,t,i,n,r,s,o,c){super(e,t,i,n,r,s,c),this.lastFocus=new g.Vector3(0,0,0),this.panDenominator=1,this.minZ=.01,this.setRadius(this.radius),this.enableFramingBehavior(),this.wheelDeltaPercentage=.01,this.pinchDeltaPercentage=.005,this.useNaturalPinchZoom=!0,o.camera.autoOrientation&&(this.alpha+=Math.PI),o&&(o.camera.limits.min.beta&&(this.lowerBetaLimit=o.camera.limits.min.beta),o.camera.limits.max.beta&&(this.upperBetaLimit=o.camera.limits.max.beta),o.camera.limits.min.alpha&&(this.lowerAlphaLimit=o.camera.limits.min.alpha),o.camera.limits.max.alpha&&(this.upperAlphaLimit=o.camera.limits.max.alpha),o.camera.limits.min.radius&&(this.lowerRadiusLimit=o.camera.limits.min.radius),o.camera.limits.max.radius&&(this.upperRadiusLimit=o.camera.limits.max.radius),o.camera.autoRotation.enabled&&this.enableAutoRotationBehavior(o.camera.autoRotation.idleTimeMs))}getFramingBehavior(){return this.getBehaviorByName("Framing")}getAutoRotationBehavior(){const e=this.getBehaviorByName("AutoRotation");if(e)return e}enableFramingBehavior(){this.useFramingBehavior=!0;const e=this.getFramingBehavior();e.attach(this),e.framingTime=0,e.elevationReturnTime=-1,e.zoomStopsAnimation=!1,this.lowerRadiusLimit=null;const t=F(this._scene);return e.zoomOnBoundingInfo(t.min,t.max),this.wheelPrecision=100/this.radius,this.lowerRadiusLimit===null&&(this.lowerRadiusLimit=.1),this.lastFocus.copyFrom(this.target),e}rerunFramingBehavior(e,t){const i=this.getFramingBehavior();i.framingTime=t||800;const n=()=>{e&&e()},r=F(this._scene),s=r.max.subtract(r.min),o=r.min.add(s.scale(.5));this.setRadius(s.length()*1.5),this.wheelPrecision=100/this.radius,this.panningInertia=0,this.panningOriginTarget.copyFrom(o),this.panDenominator=s.length(),i.zoomOnBoundingInfo(r.min,r.max,void 0,n),i.framingTime=0}enableAutoRotationBehavior(e=5e3){this.useAutoRotationBehavior=!0;const t=this.getAutoRotationBehavior();t&&(t.idleRotationWaitTime=e)}disableAutoRotationBehavior(){this.useAutoRotationBehavior=!1}setRadius(e){this.radius=e,this.maxZ=this.radius*1e3,this.lowerRadiusLimit=this.radius*.01,this.upperRadiusLimit=1.5*this.radius,this.wheelPrecision=100/this.radius,this.pinchPrecision=300/this.radius}static create(e,t,i){const n=F(e),r=n.max.subtract(n.min),s=n.min.add(r.scale(.5)),o=new S("ProductCamera",-(Math.PI/2),Math.PI/2,r.length()*1.5,s,e,t);return o.panningInertia=0,o.panningOriginTarget.copyFrom(s),o.panDenominator=r.length(),o.onAfterCheckInputsObservable.add(()=>{o.panningSensibility=1e3/o.panDenominator}),i&&(e.activeCamera=o),o}}function F(a){if(a.meshes.length===0)return{min:new g.Vector3(-1,-1,-1),max:new g.Vector3(1,1,1)};const e=a.meshes.filter(t=>t.name.toLowerCase().endsWith("_t")||t.name.toLowerCase().includes("_t_"));return a.getWorldExtends(t=>t.isVisible&&t.isEnabled()&&(e.length===0||e.includes(t)))}class Ye{constructor(e,t=!1,i=void 0){this.renderingPipeline=new Ie.DefaultRenderingPipeline("default",t,e,i?[i]:void 0,!1),this.renderingPipeline.isSupported&&(this.renderingPipeline.prepare(),this.setConfiguration(h))}dispose(){this.renderingPipeline.dispose()}getConfiguration(){return this.currentConfiguration}setConfiguration(e){var t,i,n,r,s,o,c,d,u,m,b,f,Y,X,_,J,ee,te,ie,se,re,ne,ae,oe,le,he,ce,de,ue,ge,me,pe,be;if(this.renderingPipeline.isSupported){if(this.renderingPipeline.samples=((t=e.antiAliasing)==null?void 0:t.samples)??h.antiAliasing.samples,this.renderingPipeline.fxaaEnabled=((i=e.antiAliasing)==null?void 0:i.fxaaEnabled)??h.antiAliasing.fxaaEnabled,this.renderingPipeline.bloomEnabled=((n=e.bloom)==null?void 0:n.enabled)??h.bloom.enabled,this.renderingPipeline.bloomKernel=((r=e.bloom)==null?void 0:r.kernel)??h.bloom.kernel,this.renderingPipeline.bloomScale=((s=e.bloom)==null?void 0:s.scale)??h.bloom.scale,this.renderingPipeline.bloomThreshold=((o=e.bloom)==null?void 0:o.threshold)??h.bloom.threshold,this.renderingPipeline.bloomWeight=((c=e.bloom)==null?void 0:c.weight)??h.bloom.weight,this.renderingPipeline.chromaticAberrationEnabled=((d=e.chromaticAberration)==null?void 0:d.enabled)??h.chromaticAberration.enabled,this.renderingPipeline.chromaticAberration.aberrationAmount=((u=e.chromaticAberration)==null?void 0:u.aberrationAmount)??h.chromaticAberration.aberrationAmount,this.renderingPipeline.chromaticAberration.radialIntensity=((m=e.chromaticAberration)==null?void 0:m.radialIntensity)??h.chromaticAberration.radialIntensity,this.renderingPipeline.chromaticAberration.direction=(b=e.chromaticAberration)!=null&&b.direction?new g.Vector2(e.chromaticAberration.direction.x,e.chromaticAberration.direction.y):new g.Vector2(h.chromaticAberration.direction.x,h.chromaticAberration.direction.y),this.renderingPipeline.imageProcessing.colorCurvesEnabled=((f=e.colorCurves)==null?void 0:f.enabled)??h.colorCurves.enabled,this.renderingPipeline.imageProcessing.colorCurves=e.colorCurves?this.updateColorCurve(e.colorCurves):new z.ColorCurves,this.renderingPipeline.depthOfFieldEnabled=((Y=e.depthOfField)==null?void 0:Y.enabled)??h.depthOfField.enabled,e.depthOfField)switch(e.depthOfField.blurLevel??h.depthOfField.blurLevel){case"Low":this.renderingPipeline.depthOfFieldBlurLevel=I.DepthOfFieldEffectBlurLevel.Low;break;case"Medium":this.renderingPipeline.depthOfFieldBlurLevel=I.DepthOfFieldEffectBlurLevel.Medium;break;case"High":this.renderingPipeline.depthOfFieldBlurLevel=I.DepthOfFieldEffectBlurLevel.High;break}if(this.renderingPipeline.depthOfField.focalLength=((X=e.depthOfField)==null?void 0:X.focalLength)??h.depthOfField.focalLength,this.renderingPipeline.depthOfField.fStop=((_=e.depthOfField)==null?void 0:_.fStop)??h.depthOfField.fStop,this.renderingPipeline.depthOfField.focusDistance=((J=e.depthOfField)==null?void 0:J.focusDistance)??h.depthOfField.focusDistance,this.renderingPipeline.depthOfField.lensSize=((ee=e.depthOfField)==null?void 0:ee.lensSize)??h.depthOfField.lensSize,this.renderingPipeline.grainEnabled=((te=e.grain)==null?void 0:te.enabled)??h.grain.enabled,this.renderingPipeline.grain.animated=((ie=e.grain)==null?void 0:ie.animated)??h.grain.animated,this.renderingPipeline.grain.intensity=((se=e.grain)==null?void 0:se.intensity)??h.grain.intensity,this.renderingPipeline.imageProcessing.contrast=((re=e.misc)==null?void 0:re.contrast)??h.misc.contrast,this.renderingPipeline.imageProcessing.exposure=((ne=e.misc)==null?void 0:ne.exposure)??h.misc.exposure,this.renderingPipeline.imageProcessing.toneMappingEnabled=((ae=e.misc)==null?void 0:ae.toneMappingEnabled)??h.misc.toneMappingEnabled,this.renderingPipeline.imageProcessing.toneMappingEnabled)switch(e.misc.toneMappingType??h.misc.toneMappingType){case"Standard":this.renderingPipeline.imageProcessing.toneMappingType=x.ImageProcessingConfiguration.TONEMAPPING_STANDARD;break;case"ACES":this.renderingPipeline.imageProcessing.toneMappingType=x.ImageProcessingConfiguration.TONEMAPPING_ACES;break}if(this.renderingPipeline.sharpenEnabled=((oe=e.sharpen)==null?void 0:oe.enabled)??h.sharpen.enabled,this.renderingPipeline.sharpen.colorAmount=((le=e.sharpen)==null?void 0:le.colorAmount)??h.sharpen.colorAmount,this.renderingPipeline.sharpen.edgeAmount=((he=e.sharpen)==null?void 0:he.edgeAmount)??h.sharpen.edgeAmount,this.renderingPipeline.imageProcessing.vignetteEnabled=((ce=e.vignette)==null?void 0:ce.enabled)??h.vignette.enabled,(de=e.vignette)!=null&&de.center?(this.renderingPipeline.imageProcessing.vignetteCenterX=e.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=e.vignette.center.y):(this.renderingPipeline.imageProcessing.vignetteCenterX=h.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=h.vignette.center.y),e.vignette)switch(((ue=e.vignette)==null?void 0:ue.blendMode)??h.vignette.blendMode){case"Multiply":this.renderingPipeline.imageProcessing.vignetteBlendMode=x.ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY;break;case"Opaque":this.renderingPipeline.imageProcessing.vignetteBlendMode=x.ImageProcessingConfiguration.VIGNETTEMODE_OPAQUE;break}(ge=e.vignette)!=null&&ge.colorRgba?this.renderingPipeline.imageProcessing.vignetteColor=new p.Color4(e.vignette.colorRgba.r,e.vignette.colorRgba.g,e.vignette.colorRgba.b,e.vignette.colorRgba.a):(me=e.vignette)!=null&&me.colorHex?this.renderingPipeline.imageProcessing.vignetteColor=p.Color4.FromHexString(e.vignette.colorHex):this.renderingPipeline.imageProcessing.vignetteColor=new p.Color4(h.vignette.colorRgba.r,h.vignette.colorRgba.g,h.vignette.colorRgba.b,h.vignette.colorRgba.a),this.renderingPipeline.imageProcessing.vignetteStretch=((pe=e.vignette)==null?void 0:pe.stretch)??h.vignette.stretch,this.renderingPipeline.imageProcessing.vignetteWeight=((be=e.vignette)==null?void 0:be.weight)??h.vignette.weight,this.renderingPipeline.prepare(),this.currentConfiguration=e}}updateColorCurve(e){const t=new z.ColorCurves;return t.globalDensity=e.globalDensity??t.globalDensity,t.globalExposure=e.globalExposure??t.globalExposure,t.globalHue=e.globalHue??t.globalHue,t.globalSaturation=e.globalSaturation??t.globalSaturation,t.highlightsDensity=e.highlightsDensity??t.highlightsDensity,t.highlightsExposure=e.highlightsExposure??t.highlightsExposure,t.highlightsHue=e.highlightsHue??t.highlightsHue,t.highlightsSaturation=e.highlightsSaturation??t.highlightsSaturation,t.midtonesDensity=e.midtonesDensity??t.midtonesDensity,t.midtonesExposure=e.midtonesExposure??t.midtonesExposure,t.midtonesHue=e.midtonesHue??t.midtonesHue,t.midtonesSaturation=e.midtonesSaturation??t.midtonesSaturation,t.shadowsDensity=e.shadowsDensity??t.shadowsDensity,t.shadowsExposure=e.shadowsExposure??t.shadowsExposure,t.shadowsHue=e.shadowsHue??t.shadowsHue,t.shadowsSaturation=e.shadowsSaturation??t.shadowsSaturation,t}}Pe.GLTF2.GLTFLoader.RegisterExtension("glbPostProcessor",function(a){return new Fe(a)}),B.SceneLoader.OnPluginActivatedObservable.add(a=>{if(a.name==="gltf"){const e=a;e.transparencyAsCoverage=!0}});const A="initialScene";class Xe{constructor(e){this.loadProgress=new Map([[A,0]]),this.focusLostNotified=!1,this.loadObservable=new y.Observable,this.focusLostObservable=new y.Observable,this.initializedCallbacks=[],this.isInitialized=!1,this.modelLoadEventCallbacks=[],this.modelContainers=new Map,this.plugins=[],this.configuration=new Se(e);const i=(()=>{if(!(e!=null&&e.noRender))return this.configuration.createCanvas()})(),n="1.5.6";Ce.DracoCompression.Configuration={decoder:{wasmUrl:`https://www.gstatic.com/draco/versioned/decoders/${n}/draco_wasm_wrapper_gltf.js`,wasmBinaryUrl:`https://www.gstatic.com/draco/versioned/decoders/${n}/draco_decoder_gltf.wasm`,fallbackUrl:`https://www.gstatic.com/draco/versioned/decoders/${n}/draco_decoder_gltf.js`}},i&&(i.getContext("webgl2")||i.getContext("webgl"));const r=console.log;console.log=()=>{};const s=i?new j.Engine(i,!0,{adaptToDeviceRatio:!0,limitDeviceRatio:2,premultipliedAlpha:!1,preserveDrawingBuffer:!!(e!=null&&e.backgroundImage),audioEngine:!1,stencil:this.configuration.highlights.enabled,forceSRGBBufferSupportState:!0}):new fe.NullEngine;console.log=r,s.hideLoadingUI(),window.addEventListener("resize",this.fireResizeEvent.bind(this)),this.engine=s,this.scene=new Me.Scene(s),this.camera=S.create(this.scene,this.configuration),this.renderingPipeline=new Ye(this.scene,!1,this.camera),this.scene.imageProcessingConfiguration.exposure=this.configuration.lighting.exposure,this.scene.imageProcessingConfiguration.contrast=this.configuration.lighting.contrast,this.glowLayerManager=new je(this.scene,this.configuration.emissiveGlowIntensity)}getEngineContext(){return{engine:this.engine,scene:this.scene,camera:this.camera}}registerFocusLostListener(e){this.focusLostObservable.add(e)}unregisterFocusLostListener(e){this.focusLostObservable.removeCallback(e)}registerLoadProgressListener(e){this.loadObservable.add(e),e(this.getLoadListenerEvent())}unregisterLoadProgressListener(e){this.loadObservable.removeCallback(e)}registerInitializedListener(e){this.isInitialized||!this.isInitialized&&this.initializedCallbacks.push(e)}unregisterInitializedListener(e){if(this.isInitialized)return;const t=this.initializedCallbacks.indexOf(e);t>-1&&this.initializedCallbacks.splice(t,1)}getIsInitialized(){return this.isInitialized}registerModelLoadEventListener(e){this.modelLoadEventCallbacks.push(e)}unregisterModelLoadEventListener(e){const t=this.modelLoadEventCallbacks.indexOf(e);t>-1&&this.modelLoadEventCallbacks.splice(t,1)}registerView(e){const t=e.height,i=e.width;this.engine.registerView(e),e.setAttribute("height",t.toString()),e.setAttribute("width",i.toString()),this.orbitEnabled()||this.setCameraState(L.Pan),this.reattachControls(e)}getNumViewports(){var e;return((e=this.engine.views)==null?void 0:e.length)||0}unregisterView(e){this.engine.unRegisterView(e)}shutdown(){this.plugins.forEach(e=>e.dispose(!0)),this.renderingPipeline.dispose(),this.engine&&this.engine.dispose(),window.removeEventListener("resize",this.fireResizeEvent)}getSceneInitializationProgress(){return this.loadProgress.get(A)}async initialize(e){var i,n;this.scene.clearColor=this.configuration.scene.clearColor,this.scene.environmentTexture=ye.CubeTexture.CreateFromPrefilteredData(this.configuration.scene.environmentFile,this.scene);let t;return e&&(t=await this.loadModel(e,s=>{this.loadProgress.set(A,s.loaded*100/s.total),this.notifyLoadHandlers()}).getInitializationPromise()),this.loadProgress.set(A,100),this.notifyLoadHandlers(),this.scene.activeCamera=this.camera,this.camera.rerunFramingBehavior(void 0,1),ze(this.scene),((i=this.engine.views)==null?void 0:i.length)>=1&&this.reattachControls(this.engine.views[this.engine.views.length-1].target),this.queuedCameraAnimation&&(this.executeCameraAnimation(this.queuedCameraAnimation),this.queuedCameraAnimation=void 0),this.isInitialized=!0,await Promise.all(this.initializedCallbacks.map(r=>r())),this.initializedCallbacks=[],(n=this.configuration.options)!=null&&n.renderingPipelineConfiguration&&this.renderingPipeline.setConfiguration(this.configuration.options.renderingPipelineConfiguration),this.engine.runRenderLoop(()=>{this.engine.views&&(this.modelContainers.forEach(r=>{r.updateDynamicTextures()}),this.configuration.scene.transparentBackground&&this.engine.views.forEach(r=>{const s=this.engine.getRenderingCanvas();r.target.getContext("2d").clearRect(0,0,s.width,s.height)}),this.scene.render(),!this.camera.target.equalsWithEpsilon(this.camera.lastFocus,.1)&&!this.focusLostNotified&&(this.focusLostObservable.notifyObservers(void 0),this.focusLostNotified=!0),this.screenshotPrepareResolve&&(this.screenshotPrepareResolve(),this.screenshotPrepareResolve=void 0))}),t}executeCameraAnimation(e){if(this.getSceneInitializationProgress()!==100||!this.camera||this.scene.activeCamera!==this.camera){this.queuedCameraAnimation=e;return}ke(this.scene,this.scene.activeCamera,e)}getCameraPose(){if(this.scene&&this.camera)return{lonDeg:Math.round(this.camera.alpha*180/Math.PI),latDeg:Math.round(this.camera.beta*180/Math.PI),radius:Math.round((this.camera.radius+Number.EPSILON)*1e4)/1e4,target:{x:this.camera.target.x,y:this.camera.target.y,z:this.camera.target.z}}}setCameraPose(e){this.scene&&this.camera&&(this.camera.target=new g.Vector3(e.target.x,e.target.y,e.target.z),this.camera.radius=e.radius,this.camera.alpha=e.latDeg,this.camera.beta=e.lonDeg)}setCameraState(e){var t,i;if(!((t=this.engine)!=null&&t.views)||!((i=this.engine)!=null&&i.views[0]))throw new Error("No views attached, camera state requires a view to attach controls onto.");e===L.Orbit?this.reattachControls(this.engine.views[0].target,2):this.reattachControls(this.engine.views[0].target,0)}animateToLastCameraFocus(){return new Promise(e=>{const t=()=>{const i=this.configuration;this.camera.rerunFramingBehavior(()=>{this.focusLostNotified=!1,i.camera.limits.min.radius&&(this.camera.lowerRadiusLimit=i.camera.limits.min.radius),i.camera.limits.max.radius&&(this.camera.upperRadiusLimit=i.camera.limits.max.radius),e()})};this.scene.onAfterRenderObservable.addOnce(t)})}setAutoRotation(e){!this.configuration.camera.autoRotation.enabled||!this.camera||(e?this.camera.enableAutoRotationBehavior(this.configuration.camera.autoRotation.idleTimeMs):this.camera.disableAutoRotationBehavior())}getCurrentConfiguration(){return this.configuration.options}async renderSceneScreenshot(e,t){if(!this.camera)throw new Error("Missing product camera, cannot render screenshot!");const i=new v.ArcRotateCamera("screenshotCamera",0,0,0,g.Vector3.Zero(),this.scene);try{const n=t.latDeg*Math.PI/180,r=t.lonDeg*Math.PI/180;i.target=t.target?new g.Vector3(t.target.x,t.target.y,t.target.z):g.Vector3.Zero(),i.alpha=r,i.beta=n,i.radius=t.radius||this.camera.radius,i.minZ=.01,this.scene.render();const s=await we.Tools.CreateScreenshotUsingRenderTargetAsync(this.engine,i,e,"image/png",2,!0);return i.dispose(),s}catch{throw i.isDisposed()||i.dispose(),new Error("Failed to render screenshot")}}orbitEnabled(){const e=this.configuration;if(!e)return!0;const t=e.camera.limits.min.alpha,i=e.camera.limits.max.alpha,n=e.camera.limits.min.beta,r=e.camera.limits.max.beta;if(t===void 0||i===void 0||n===void 0||r===void 0)return!0;const s=[t,i],o=[n,r],c=s.every(u=>u===t),d=o.every(u=>u===n);return!c&&!d}fireResizeEvent(){this.getNumViewports()>0&&this.engine.resize()}setHighlights(e,t){var n;e.length===0&&((n=this.highlightLayer)==null||n.dispose(),this.highlightLayer=void 0),this.highlightLayer||(this.highlightLayer=new ve.HighlightLayer("highlights",this.scene,{isStroke:!0,blurVerticalSize:.85,blurHorizontalSize:.85}),this.highlightLayer.innerGlow=!0,this.highlightLayer.outerGlow=!1),this.highlightLayer.removeAllMeshes();const i=t?new p.Color3(t[0],t[1],t[2]).toLinearSpace():void 0;e.forEach(r=>{const s=this.scene.materials.find(o=>o.name===r.name&&o.id===r.id);s&&s.getBindedMeshes().forEach(o=>{var c;return(c=this.highlightLayer)==null?void 0:c.addMesh(o,i||p.Color3.FromHexString("#fcba03"))})})}setRenderingPipelineConfiguration(e){this.renderingPipeline&&this.renderingPipeline.setConfiguration(e)}loadModel(e,t){const i=new $e({enablePicking:this.configuration.highlights.enabled,modelDetails:e,scene:this.scene,previewService:this,progressHandler:t});return i.registerMaterialVariantListener(n=>this.handleMaterialProgressCallback(n.remainingCount,n.totalCount,n.taskName)),i.registerModelVariantListener(n=>this.handleModelProgressCallback(n,n.key)),this.configuration.highlights.enabled&&(i.registerMaterialSelectedCallback(n=>{this.setHighlights([n])}),i.registerMaterialDeselectedCallback(()=>{this.setHighlights([])})),this.modelContainers.set(i.getId(),i),this.triggerModelLoadEvent({eventType:"load",modelContainer:i}),i}getAllModels(){return Array.from(this.modelContainers.values())}getModelById(e){return this.modelContainers.get(e)}registerPlugin(e){this.plugins.push(e),e.initialize(this,{camera:this.camera,engine:this.engine,scene:this.scene})}unregisterPlugin(e){const t=this.plugins.indexOf(e);t>-1&&this.plugins.splice(t,1).forEach(n=>n.dispose(!1))}getGlowLayerManager(){return this.glowLayerManager}modelUnloaded(e){this.modelContainers.delete(e.getId()),this.triggerModelLoadEvent({eventType:"unload",modelContainer:e})}triggerModelLoadEvent(e){this.modelLoadEventCallbacks.forEach(t=>t(e))}handleMaterialProgressCallback(e,t,i){this.loadProgress.set(`key_${i}`,e/t*100),this.notifyLoadHandlers()}handleModelProgressCallback(e,t){this.loadProgress.set(t,e.loaded*100/e.total),this.notifyLoadHandlers()}reattachControls(e,t=2){if(this.scene.detachControl(),this.engine.inputElement=e,this.camera){this.camera.attachControl(!0,!1,t);const i=this.camera.inputs.attached.pointers;i.multiTouchPanning=!1}this.scene.attachControl(!0,!0,!0)}getLoadListenerEvent(){const e=Array.from(this.loadProgress.values()).filter(n=>n<100),i=e.reduce((n,r)=>n+r,0)/e.length||0;return{loadValue:e.length===0?100:i,sceneInitialized:this.getSceneInitializationProgress()===100}}notifyLoadHandlers(){this.loadObservable.notifyObservers(this.getLoadListenerEvent())}}l.MaterialEffectMode=T,l.ProductCameraRig=L,l.REFLECTION_PROBE_RESOLUTION=k,l.RenderingConfiguration=w,l.SpiffCommerce3DPreviewService=Xe,l.renderingPipelineDefaults=h,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(l,y){typeof exports=="object"&&typeof module<"u"?y(exports,require("@babylonjs/core/Cameras/arcRotateCamera"),require("@babylonjs/core/Engines/engine"),require("@babylonjs/core/Engines/nullEngine"),require("@babylonjs/core/Layers/highlightLayer"),require("@babylonjs/core/Loading/sceneLoader"),require("@babylonjs/core/Materials/Textures/cubeTexture"),require("@babylonjs/core/Maths/math.color"),require("@babylonjs/core/Maths/math.vector"),require("@babylonjs/core/Meshes/Compression/dracoCompression"),require("@babylonjs/core/Misc/observable"),require("@babylonjs/core/Misc/tools"),require("@babylonjs/core/scene"),require("@babylonjs/loaders/glTF"),require("@babylonjs/core/Materials/PBR/pbrMaterial"),require("@babylonjs/core/Materials/Textures/mirrorTexture"),require("@babylonjs/core/Maths/math"),require("@babylonjs/core/Probes/reflectionProbe"),require("@babylonjs/core/Layers/glowLayer"),require("@babylonjs/core/Actions/actionManager"),require("@babylonjs/core/Actions/directActions"),require("@babylonjs/core/Meshes/mesh"),require("@babylonjs/core/Meshes/transformNode"),require("@babylonjs/core/Materials/Textures/dynamicTexture"),require("@babylonjs/core/Materials/Textures/texture"),require("@babylonjs/core/Animations/animation"),require("@babylonjs/core/Animations/easing"),require("@babylonjs/core/Misc/assetsManager"),require("@babylonjs/core/Materials/colorCurves"),require("@babylonjs/core/Materials/imageProcessingConfiguration"),require("@babylonjs/core/PostProcesses/RenderPipeline"),require("@babylonjs/core/PostProcesses/depthOfFieldEffect"),require("@babylonjs/core/Rendering/depthRendererSceneComponent"),require("@babylonjs/core/Engines/Extensions/engine.views"),require("@babylonjs/core/Meshes/instancedMesh"),require("@babylonjs/core/Materials/Textures/Loaders/ddsTextureLoader"),require("@babylonjs/core/Materials/Textures/Loaders/envTextureLoader"),require("@babylonjs/core/Materials/Textures/Loaders/ktxTextureLoader"),require("@babylonjs/core/Animations/animatable"),require("@babylonjs/core/Misc/screenshotTools"),require("@babylonjs/core/Rendering/boundingBoxRenderer"),require("@babylonjs/loaders/glTF/2.0/Extensions")):typeof define=="function"&&define.amd?define(["exports","@babylonjs/core/Cameras/arcRotateCamera","@babylonjs/core/Engines/engine","@babylonjs/core/Engines/nullEngine","@babylonjs/core/Layers/highlightLayer","@babylonjs/core/Loading/sceneLoader","@babylonjs/core/Materials/Textures/cubeTexture","@babylonjs/core/Maths/math.color","@babylonjs/core/Maths/math.vector","@babylonjs/core/Meshes/Compression/dracoCompression","@babylonjs/core/Misc/observable","@babylonjs/core/Misc/tools","@babylonjs/core/scene","@babylonjs/loaders/glTF","@babylonjs/core/Materials/PBR/pbrMaterial","@babylonjs/core/Materials/Textures/mirrorTexture","@babylonjs/core/Maths/math","@babylonjs/core/Probes/reflectionProbe","@babylonjs/core/Layers/glowLayer","@babylonjs/core/Actions/actionManager","@babylonjs/core/Actions/directActions","@babylonjs/core/Meshes/mesh","@babylonjs/core/Meshes/transformNode","@babylonjs/core/Materials/Textures/dynamicTexture","@babylonjs/core/Materials/Textures/texture","@babylonjs/core/Animations/animation","@babylonjs/core/Animations/easing","@babylonjs/core/Misc/assetsManager","@babylonjs/core/Materials/colorCurves","@babylonjs/core/Materials/imageProcessingConfiguration","@babylonjs/core/PostProcesses/RenderPipeline","@babylonjs/core/PostProcesses/depthOfFieldEffect","@babylonjs/core/Rendering/depthRendererSceneComponent","@babylonjs/core/Engines/Extensions/engine.views","@babylonjs/core/Meshes/instancedMesh","@babylonjs/core/Materials/Textures/Loaders/ddsTextureLoader","@babylonjs/core/Materials/Textures/Loaders/envTextureLoader","@babylonjs/core/Materials/Textures/Loaders/ktxTextureLoader","@babylonjs/core/Animations/animatable","@babylonjs/core/Misc/screenshotTools","@babylonjs/core/Rendering/boundingBoxRenderer","@babylonjs/loaders/glTF/2.0/Extensions"],y):(l=typeof globalThis<"u"?globalThis:l||self,y(l.Preview={},l.arcRotateCamera,l.engine,l.nullEngine,l.highlightLayer,l.sceneLoader,l.cubeTexture,l.math_color,l.math_vector,l.dracoCompression,l.observable,l.tools,l.scene,l.glTF,l.pbrMaterial,l.mirrorTexture,l.math,l.reflectionProbe,l.glowLayer,l.actionManager,l.directActions,l.mesh,l.transformNode,l.dynamicTexture,l.texture,l.animation,l.easing,l.assetsManager,l.colorCurves,l.imageProcessingConfiguration,l.RenderPipeline,l.depthOfFieldEffect))})(this,function(l,y,j,be,fe,B,ye,p,g,ve,v,Ce,we,Me,E,xe,x,Pe,Le,O,D,Te,Ae,Re,Ee,C,q,Oe,V,P,Ie,I){"use strict";var L=(a=>(a[a.Orbit=0]="Orbit",a[a.Pan=1]="Pan",a))(L||{}),T=(a=>(a.None="None",a.RemoveWhenSelected="RemoveWhenSelected",a.ApplyWhenSelected="ApplyWhenSelected",a))(T||{});class Se{constructor(e){this.getSceneClearColor=()=>{var i,n,r,s;const t=(i=this.customOptions)!=null&&i.transparentBackground||(n=this.customOptions)!=null&&n.backgroundImage?0:1;if(this.customOptions&&((r=this.customOptions)!=null&&r.transparentBackground)||(s=this.customOptions)!=null&&s.backgroundImage)return new p.Color4(0,0,0,t).toLinearSpace();if(this.customOptions&&this.customOptions.backgroundColor){const o=p.Color3.FromHexString(this.customOptions.backgroundColor);return new p.Color4(o.r,o.g,o.b,t).toLinearSpace()}return new p.Color4(.98,.98,.98,t).toLinearSpace()},this.highlightColorFromConfig=()=>this.customOptions&&this.customOptions.highlightColor?this.hexToColor4(this.customOptions.highlightColor):new p.Color4(.98,.98,.98,1).toLinearSpace(),this.hexToColor4=(t,i=1)=>{const n=p.Color3.FromHexString(t);return new p.Color4(n.r,n.g,n.b,i).toLinearSpace()},this.customOptions=e}createCanvas(){var e;return(e=this.customOptions)!=null&&e.createCanvas?this.customOptions.createCanvas():document.createElement("canvas")}get options(){return this.customOptions}get scene(){var e,t,i;return{clearColor:this.getSceneClearColor(),transparentBackground:((e=this.customOptions)==null?void 0:e.transparentBackground)||((t=this.customOptions)==null?void 0:t.backgroundImage),environmentFile:((i=this.customOptions)==null?void 0:i.environmentFile)??"assets/model-viewer/default.env"}}get camera(){var e,t,i,n,r,s,o,h,d,u,m,b,f;return{autoOrientation:((e=this.customOptions)==null?void 0:e.disableAutomaticOrientation)??!0,autoRotation:{enabled:((t=this.customOptions)==null?void 0:t.autoRotation)??!1,idleTimeMs:((i=this.customOptions)==null?void 0:i.idleTimeBeforeRotation)??5e3},limits:{min:{alpha:(n=this.customOptions)!=null&&n.lowerAlphaLimitDeg?((r=this.customOptions)==null?void 0:r.lowerAlphaLimitDeg)*Math.PI/180:void 0,beta:(s=this.customOptions)!=null&&s.lowerBetaLimitDeg?((o=this.customOptions)==null?void 0:o.lowerBetaLimitDeg)*Math.PI/180:void 0,radius:(h=this.customOptions)==null?void 0:h.minZoomOverride},max:{alpha:(d=this.customOptions)!=null&&d.upperAlphaLimitDeg?((u=this.customOptions)==null?void 0:u.upperAlphaLimitDeg)*Math.PI/180:void 0,beta:(m=this.customOptions)!=null&&m.upperBetaLimitDeg?((b=this.customOptions)==null?void 0:b.upperBetaLimitDeg)*Math.PI/180:void 0,radius:(f=this.customOptions)==null?void 0:f.maxZoomOverride}}}}get highlights(){var e;return{enabled:((e=this.customOptions)==null?void 0:e.highlightOnMaterialHover)??!1,color:this.highlightColorFromConfig()}}get lighting(){var e,t,i,n;return{exposure:((t=(e=this.customOptions)==null?void 0:e.lighting)==null?void 0:t.exposure)??.9,contrast:((n=(i=this.customOptions)==null?void 0:i.lighting)==null?void 0:n.contrast)??1.6}}get emissiveGlowIntensity(){var e;return((e=this.customOptions)==null?void 0:e.emissiveGlowIntensity)??.5}}class w{static getDynamicTextureResolution(){return this.getIsMobile()||!w.offscreenRenderingSupported()?{width:1024,height:1024}:{width:2048,height:2048}}static shouldMipMap(){return!0}static offscreenRenderingSupported(){return navigator.userAgent.includes("SamsungBrowser")?!1:!!window.Worker&&!!window.OffscreenCanvas}static getMirrorTextureResolution(){return this.getIsMobile()?512:1024}static getIsMobile(){try{return typeof window>"u"||!window.navigator?!1:/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(window.navigator.userAgent)||window.innerWidth<=480}catch{return!1}}}const z=128,c={antiAliasing:{samples:4,fxaaEnabled:!1},bloom:{enabled:!1,kernel:64,scale:.5,threshold:.9,weight:.15},chromaticAberration:{enabled:!1,aberrationAmount:30,direction:{x:0,y:0},radialIntensity:0},colorCurves:{enabled:!1},depthOfField:{enabled:!1,blurLevel:"Low",focalLength:50,focusDistance:2e3,fStop:1.4,lensSize:50},grain:{enabled:!1,animated:!1,intensity:30},misc:{contrast:1,exposure:1,toneMappingEnabled:!1,toneMappingType:"Standard"},sharpen:{enabled:!1,colorAmount:1,edgeAmount:.3},vignette:{enabled:!1,blendMode:"Multiply",cameraFov:.5,center:{x:0,y:0},colorHex:"#000000ff",colorRgba:{r:0,g:0,b:0,a:1},stretch:0,weight:1}};class Fe{constructor(e){this.name="glbPostProcessor",this.enabled=!0,this.loader=e}onReady(){this.applyReflections(this.loader.babylonScene)}loadNodeAsync(e,t,i){return this.loader.loadNodeAsync(e,t,function(n){t.extras&&Object.keys(t.extras).forEach(r=>{const s=t.extras[r];n.metadata[r]=s}),i(n)})}async loadMaterialPropertiesAsync(e,t,i){await this.loader.loadMaterialPropertiesAsync(e,t,i),this.enableMaterialExtrasIfRequired(t,i),i.needDepthPrePass=!0}dispose(){}enableMaterialExtrasIfRequired(e,t){if(!(!e.extras||!(t instanceof E.PBRMaterial))){if(e.extras.sheen){const i=t;i.sheen.isEnabled=!0,i.sheen.intensity=e.extras.sheen}if(e.extras.translucency){const i=t;i.subSurface.isTranslucencyEnabled=!0,i.subSurface.translucencyIntensity=e.extras.translucency,e.extras.translucencyR&&e.extras.translucencyG&&e.extras.translucencyB&&(i.subSurface.tintColor=new x.Color3(e.extras.translucencyR,e.extras.translucencyG,e.extras.translucencyB))}if(e.extras.refractionIOR){const i=t;i.subSurface.isRefractionEnabled=!0,i.subSurface.volumeIndexOfRefraction=e.extras.refractionIOR}if(e.extras.useDepthPrePass){const i=t;i.needDepthPrePass=!0,i.forceIrradianceInFragment=!0}if(e.extras.useParallax){const i=t;i.useParallax=!0,i.useParallaxOcclusion=!0,i.parallaxScaleBias=e.extras.useParallax}}}applyReflections(e){function t(r){const s=[];return r.transformNodes.forEach(o=>{o.metadata&&o.metadata.reflective&&s.push(...o.getChildMeshes())}),r.meshes.forEach(o=>{o.metadata&&o.metadata.reflective&&!s.includes(o)&&s.push(o)}),s}function i(r,s=1){const o=r.material;if(!o)return;const h=new xe.MirrorTexture("mirror",w.getMirrorTextureResolution(),e,!0);h.renderList=t(e);const d=r.getVerticesData("normal");if(!d)throw new Error("Mirror attribute specified on: "+r.name+"But no normals exist to generate a mirror from!");r.computeWorldMatrix(!0);const u=r.getWorldMatrix(),m=x.Vector3.TransformNormal(new x.Vector3(d[0],d[1],d[2]),u).normalize(),b=x.Plane.FromPositionAndNormal(r.position,m.scale(-1));h.mirrorPlane=b,h.level=s,o.reflectionTexture=h}function n(r){const s=r.material,o=new Pe.ReflectionProbe("probe-"+s.name,z,e);o.attachToMesh(r),o.renderList&&o.renderList.push(...t(e)),s.reflectionTexture=o.cubeTexture}e.meshes.forEach(r=>{const s=r.metadata;s&&(s.mirrorTexture&&i(r,s.mirrorTexture),s.reflectionProbe&&n(r))})}}class je{constructor(e,t){this.scene=e,this.intensity=t,this.meshCount=0}includeMeshes(e){this.glowLayer||(this.glowLayer=new Le.GlowLayer("glow",this.scene),this.glowLayer.intensity=this.intensity),e.forEach(t=>{this.glowLayer.hasMesh(t)||(this.glowLayer.addIncludedOnlyMesh(t),this.meshCount++)})}removeMeshes(e){this.glowLayer&&(e.forEach(t=>{this.glowLayer.hasMesh(t)&&(this.glowLayer.removeIncludedOnlyMesh(t),this.meshCount--)}),this.meshCount===0&&(this.glowLayer.dispose(),this.glowLayer=void 0))}}const k=new Map;async function N(a,e,t){return new Promise((i,n)=>{const r=k.get(a);if(r&&r.scene.uid===e.uid)return i(r);B.SceneLoader.LoadAssetContainerAsync(a,void 0,e,t).then(s=>{k.set(a,s),i(s)}).catch(n)})}function Be(a,e,t,i,n=""){t.forEach(r=>{const s=r.getID(),o=r.getName(),h=w.getDynamicTextureResolution();a.filter(u=>u.name===n+o).forEach(u=>{const m=i.get(s),b=!1;if(m)G(u,m),m.update(b);else{const f=De(o,e,h.width,h.height);i.set(s,f),r.setStaticContext(f.getContext()),G(u,f),f.onLoadObservable.addOnce(()=>{f.update(b)})}})})}function De(a,e,t,i){const n=new Re.DynamicTexture(a,{width:t,height:i},e,w.shouldMipMap(),Ee.Texture.TRILINEAR_SAMPLINGMODE,j.Engine.TEXTUREFORMAT_RGBA),r=n.getContext();return r&&(r.fillStyle="#f5f5f5",r.fillRect(0,0,t,i),n.update()),n}function G(a,e){if(a instanceof E.PBRMaterial){const t=a,i=t.albedoTexture;i?(e.wrapU=i.wrapU,e.wrapV=i.wrapV):(e.wrapU=1,e.wrapV=1),t.albedoTexture=e}else{const t=a,i=t.diffuseTexture;i&&(e.wrapU=i.wrapU,e.wrapV=i.wrapV),t.diffuseTexture=e}}function qe(){const a=()=>Math.floor((1+Math.random())*65536).toString(16).substring(1);return a()+a()+"-"+a()+"-"+a()+"-"+a()+"-"+a()+a()+a()}const M=60,H=1;function K(a){return a.targetedAnimations.map(t=>t.animation.framePerSecond).reduce((t,i)=>t+i,0)/a.targetedAnimations.length||0}function Ve(a,e,t,i,n){const r=n?a.filter(s=>s.name===n):a;if(r.length===0){console.warn(`No animations found for name: ${n}`);return}if(i!==void 0&&t!==void 0&&i===t){r.forEach(s=>{s.stop();const o=K(s),h=i*o;s.start(e,H,h,h)});return}r.forEach(s=>{s.stop();const o=K(s),h=i!==void 0?i*o:void 0,d=t!==void 0?t*o:void 0;s.start(e,H,h,d)})}function U(a){a.forEach(e=>{e.stop()})}function ze(a){const e=a.animationGroups;U(e)}function ke(a,e,t){a.stopAnimation(e),e.animations=[],Math.abs(e.alpha)>2*Math.PI&&(e.alpha=Ne(e.alpha,0,2*Math.PI));const i=[],n=t.target,r=0,s=n?1:0;if(t.target&&Object.keys(t.target).length>0&&i.push(A("cameraTargetLerp","target",new g.Vector3().copyFrom(e.target),new g.Vector3(t.target.x,t.target.y,t.target.z),C.Animation.ANIMATIONTYPE_VECTOR3,r)),i.push(A("cameraAlphaLerp","alpha",e.alpha,W(t.lonDeg),C.Animation.ANIMATIONTYPE_FLOAT,s)),i.push(A("cameraBetaLerp","beta",e.beta,W(t.latDeg),C.Animation.ANIMATIONTYPE_FLOAT,s)),t.radius!==void 0){const d=Math.max(.01,t.radius);i.push(A("cameraRadiusLerp","radius",e.radius,d,C.Animation.ANIMATIONTYPE_FLOAT,s))}e.animations.push(...i);const h=e.useAutoRotationBehavior;e.disableAutoRotationBehavior(),a.beginAnimation(e,0,n?M*2:M,!1,1,()=>{e.animations=[],h&&e.enableAutoRotationBehavior()})}function W(a){return a*Math.PI/180}function A(a,e,t,i,n,r=0,s=C.Animation.ANIMATIONLOOPMODE_CONSTANT){const o=new q.QuadraticEase;o.setEasingMode(q.EasingFunction.EASINGMODE_EASEINOUT);const h=new C.Animation(a,e,M,n,s),d=[];return r>0&&d.push({frame:0,value:t}),d.push({frame:M*r,value:t}),d.push({frame:M*(r+1),value:i}),h.setKeys(d),h.setEasingFunction(o),h}function Ne(a,e,t){return a<e?a=t-(e-a)%(t-e):a=e+(a-e)%(t-e)}const Ge={albedoTexture:"albedoMap",bumpTexture:"normalMap",ambientTexture:"ambientMap",emissiveTexture:"emissionMap",opacityTexture:"alphaMap",metallicTexture:"metallicMap",refractionTexture:"refractionMap"};function He(a,e,t,i){["albedoTexture","bumpTexture","ambientTexture","emissiveTexture","opacityTexture","metallicTexture","refractionTexture"].forEach(r=>{Ke(r,a,e,t,i)}),Ze(a,e)}function Ke(a,e,t,i,n){const r=Ge[a];if(!r)throw new Error("Unexpected texture name encountered.");const s=e[r],o=s==null?void 0:s.fileLink;o?i.addTextureTask(a,o,!1,!1):n&&t[a]&&(t[a]&&t[a].dispose(),t[a]=null,Ue(a,t))}function Ue(a,e){a==="opacityTexture"&&(e.useAlphaFromAlbedoTexture=!0),a==="metallicTexture"&&(e.useRoughnessFromMetallicTextureAlpha=!1,e.useRoughnessFromMetallicTextureGreen=!1,e.useMetallnessFromMetallicTextureBlue=!1),a==="refractionTexture"&&(e.subSurface.isRefractionEnabled=!1,e.subSurface.refractionIntensity=1),a==="emissiveTexture"&&(e.emissiveIntensity=0,e.emissiveColor=new p.Color3(0,0,0))}function We(a,e,t,i){a==="opacityTexture"&&(e.useAlphaFromAlbedoTexture=!1),a==="metallicTexture"&&(e.useRoughnessFromMetallicTextureAlpha=!1,e.useRoughnessFromMetallicTextureGreen=!0,e.useMetallnessFromMetallicTextureBlue=!0),a==="refractionTexture"&&(e.subSurface.isRefractionEnabled=!0,e.subSurface.refractionIntensity=t.refractionIntensity||1),e[a]=i,a==="emissiveTexture"&&(e.emissiveColor=new p.Color3(1,1,1),e.emissiveIntensity=1)}function Ze(a,e){a.clearCoat&&(a.clearCoat===T.RemoveWhenSelected?(e.clearCoat.isEnabled=!1,e.clearCoat.indexOfRefraction=1.5):a.clearCoat===T.ApplyWhenSelected&&(e.clearCoat.isEnabled=!0,e.clearCoat.indexOfRefraction=a.clearCoatIOR||e.clearCoat.indexOfRefraction))}class $e{constructor(e,t,i){this.materialVariantMap=new Map,this.keysThatRemovedBaseModel=[],this.loadedContainerForKey=new Map,this.loadedMaterialsForKey=new Map,this.scene=e,this.renameClonedAsset=t,this.setBaseModelEnabled=i}async applyMaterial(e,t,i,n){return new Promise(r=>{const s=this.materialVariantMap.get(e);this.materialVariantMap.set(e,{...s,...t});const o=this.renameClonedAsset(e),h=this.scene.materials.filter(u=>u.name===o);if(h.length===0){r();return}const d=new Oe.AssetsManager(this.scene);d.useDefaultLoadingScreen=!1,h.forEach(u=>He(t,u,d,n)),d.onProgress=(u,m,b)=>{i&&i(u/m*100,100,b.name)},d.onFinish=u=>{u.forEach(m=>{const b=m;i&&i(100,100,m.name),h.forEach(f=>We(m.name,f,t,b.texture))}),r()},d.loadAsync()})}async applyModel(e,t,i,n){var h,d;if(i&&t&&!this.keysThatRemovedBaseModel.includes(e)&&this.keysThatRemovedBaseModel.push(e),!i)return this.keysThatRemovedBaseModel.includes(e)&&this.setBaseModelEnabled(!0),(h=this.loadedContainerForKey.get(e))==null||h.dispose(),this.loadedContainerForKey.delete(e),this.loadedMaterialsForKey.delete(e),Promise.resolve(void 0);this.loadedContainerForKey.has(e)&&((d=this.loadedContainerForKey.get(e))==null||d.dispose(),this.loadedContainerForKey.delete(e),this.loadedMaterialsForKey.delete(e)),t&&this.setBaseModelEnabled(!1);const s=(await N(i,this.scene,n)).instantiateModelsToScene(this.renameClonedAsset,!0);this.loadedContainerForKey.set(e,s),this.loadedMaterialsForKey.set(e,Z(s));const o=[];return this.materialVariantMap.forEach(async(u,m)=>{o.push(this.applyMaterial(m,u))}),await Promise.all(o),s}dispose(){this.loadedContainerForKey.forEach(e=>e==null?void 0:e.dispose()),this.loadedContainerForKey.clear(),this.loadedMaterialsForKey.forEach(e=>e.forEach(t=>t==null?void 0:t.dispose())),this.loadedMaterialsForKey.clear(),this.materialVariantMap.clear(),this.keysThatRemovedBaseModel=[]}getAllMaterials(){const e=[];return this.loadedMaterialsForKey.forEach(t=>{t.forEach(i=>{e.includes(i)||e.push(i)})}),e}getAnimationGroups(){const e=[];return this.loadedContainerForKey.forEach(t=>{e.push(...t.animationGroups)}),e}}function Z(a){const e=[];return a.rootNodes.forEach(t=>{t.getChildMeshes().forEach(i=>{i.material&&!e.includes(i.material)&&e.push(i.material),i.subMeshes&&i.subMeshes.forEach(n=>{const r=n.getMaterial(!1);r&&!e.includes(r)&&e.push(r)})})}),e}function $(a,e=""){return a.map(t=>({name:t.name.substring(e.length),loop:t.loopAnimation,to:t.to,from:t.from}))}class Qe{constructor(e){this.metadata=new Map,this.materialSelectedObservable=new v.Observable,this.materialDeselectedObservable=new v.Observable,this.materialVariantObservable=new v.Observable,this.modelVariantObservable=new v.Observable,this.materialReadyToLoadCallbacks=new Map,this.modelReadyToLoadCallbacks=new Map,this.dynamicTextures=new Map,this.queuedMaterialChanges=new Map,this.materialChangesInProgress=[],this.queuedModelChanges=new Map,this.modelChangesInProgress=[],this.animations=[],this.initialized=!1,this.materials=[];const{enablePicking:t,modelDetails:i,previewService:n,progressHandler:r,scene:s}=e;this.enablePicking=t,this.contextService=i.contextService,this.id=qe(),this.previewService=n,this.scene=s,this.variantManager=new $e(s,this.renameClonedAsset.bind(this),this.setEnabled.bind(this)),this.previewService.registerInitializedListener(async()=>await this.processQueuedEvents()),this.transformRoot=new Ae.TransformNode("root",this.scene);const o=async()=>(this.assetContainer=await N(i.model,s,r),this.initialized=!0,this.instantiate(),this);this.importPromise=o()}async applyMaterialVariant(e,t,i,n){if(this.previewService.getSceneInitializationProgress()!==100||!this.initialized){if(this.materialReadyToLoadCallbacks.has(e)){const s=this.materialReadyToLoadCallbacks.get(e);s==null||s.set(t,this.applyMaterialVariant.bind(this,e,t,i,n))}else{this.materialReadyToLoadCallbacks.set(e,new Map);const s=this.materialReadyToLoadCallbacks.get(e);s==null||s.set(t,this.applyMaterialVariant.bind(this,e,t,i,n))}return}const r=async()=>{await this.variantManager.applyMaterial(e,i,(s,o,h)=>{this.materialVariantObservable.notifyObservers({remainingCount:s,totalCount:o,taskName:h})},n)};if(this.materialChangesInProgress.includes(e)){if(this.queuedMaterialChanges.has(e)){const s=this.queuedMaterialChanges.get(e);s==null||s.set(t,r)}else{this.queuedMaterialChanges.set(e,new Map);const s=this.queuedMaterialChanges.get(e);s==null||s.set(t,r)}return}this.materialChangesInProgress.push(e),await r(),this.queuedMaterialChanges.has(e)&&(this.queuedMaterialChanges.get(e).forEach(async o=>{await o()}),this.queuedMaterialChanges.delete(e)),this.materialChangesInProgress.splice(this.materialChangesInProgress.indexOf(e),1),this.configureGlowLayer()}async applyModelVariant(e,t,i){if(!this.previewService.getIsInitialized()||!this.initialized){this.modelReadyToLoadCallbacks.set(e,this.applyModelVariant.bind(this,e,t,i));return}const n=()=>this.variantManager.applyModel(e,i,t==null?void 0:t.model,o=>{this.modelVariantObservable.notifyObservers({...o,key:e})});if(this.modelChangesInProgress.includes(e)){this.queuedModelChanges.set(e,n);return}const s=await(async()=>{this.modelChangesInProgress.push(e);let o=await n();return this.queuedModelChanges.has(e)&&(o=await this.queuedModelChanges.get(e)(),this.queuedModelChanges.delete(e)),this.modelChangesInProgress.splice(this.modelChangesInProgress.indexOf(e),1),o})();this.modelInstance&&U(this.modelInstance.animationGroups),this.contextService||(this.contextService=t==null?void 0:t.contextService),s?this.configureModelInstance(s):this.configureGlowLayer()}dispose(){var e;this.destroyInstance(),this.variantManager.dispose(),this.dynamicTextures.forEach(t=>t==null?void 0:t.dispose()),this.dynamicTextures.clear(),this.materials.forEach(t=>t&&(t==null?void 0:t.dispose())),this.materials=[],(e=this.transformRoot)==null||e.dispose(),this.transformRoot=void 0,this.previewService.modelUnloaded(this)}executeAnimation(e){if(!this.previewService.getIsInitialized()){this.queuedModelAnimation=e;return}this.modelInstance&&Ve([...this.modelInstance.animationGroups,...this.variantManager.getAnimationGroups()],e.loop,e.to,e.from,e.name?this.renameClonedAsset(e.name):void 0)}getAnimations(e){return[...this.animations,...e?$(this.variantManager.getAnimationGroups(),this.renameClonedAsset("")):[]]}getId(){return this.id}listMaterials(){var t;const e=(t=this.scene)==null?void 0:t.materials.filter(i=>i.name.startsWith(this.id));return e?e.map(i=>({id:i.id,name:this.stripIdFromName(i.name)})):[]}registerMaterialSelectedCallback(e){this.materialSelectedObservable.add(e)}unregisterMaterialSelectedCallback(e){this.materialSelectedObservable.removeCallback(e)}registerMaterialDeselectedCallback(e){this.materialDeselectedObservable.add(e)}unregisterMaterialDeselectedCallback(e){this.materialDeselectedObservable.removeCallback(e)}get position(){return this.transformRoot.position}set position(e){this.transformRoot.position=new g.Vector3(e.x,e.y,e.z)}get rotation(){return this.transformRoot.rotation}set rotation(e){this.transformRoot.rotation=new g.Vector3(e.x,e.y,e.z)}get scale(){return this.transformRoot.scaling}set scale(e){this.transformRoot.scaling=new g.Vector3(e.x,e.y,e.z)}attachPickingHandler(e){e.rootNodes.forEach(t=>{t.getChildMeshes(!1).forEach(i=>{i.name==="targetcube_t"||i.name==="backgroundShell"||(i.actionManager||(i.actionManager=new O.ActionManager(this.scene)),i.actionManager.registerAction(new D.ExecuteCodeAction(O.ActionManager.OnPointerOverTrigger,n=>{n.meshUnderPointer&&i.material&&this.materialSelectedObservable.notifyObservers({id:i.material.id,name:this.stripIdFromName(i.material.name)})})),i.actionManager.registerAction(new D.ExecuteCodeAction(O.ActionManager.OnPointerOutTrigger,()=>{i.material&&this.materialDeselectedObservable.notifyObservers({id:i.material.id,name:this.stripIdFromName(i.material.name)})})))})})}getInitializationPromise(){return this.importPromise}getIsInitialized(){return this.initialized}getQueuedMaterialVariantCount(){return this.materialReadyToLoadCallbacks.size}getQueuedModelVariantCount(){return this.modelReadyToLoadCallbacks.size}configureGlowLayer(){const e=i=>i instanceof E.PBRMaterial&&i.emissiveTexture!==null;this.materials.some(e)||this.variantManager.getAllMaterials().some(e)?this.previewService.getGlowLayerManager().includeMeshes(this.getAllMeshes()):this.previewService.getGlowLayerManager().removeMeshes(this.getAllMeshes())}configureModelInstance(e){var r;const t=this.transformRoot.position,i=this.transformRoot.rotation,n=this.transformRoot.scaling;this.transformRoot.position=g.Vector3.Zero(),this.transformRoot.rotation=g.Vector3.Zero(),this.transformRoot.scaling=g.Vector3.One(),e.rootNodes.forEach(s=>{s.parent=this.transformRoot}),this.transformRoot.position=t,this.transformRoot.rotation=i,this.transformRoot.scaling=n,this.canvasPanels=((r=this.contextService)==null?void 0:r.getAll())||new Map,Be(this.materials.concat(this.variantManager.getAllMaterials()),this.scene,this.canvasPanels,this.dynamicTextures,`${this.id}_`),this.enablePicking&&this.attachPickingHandler(e),this.configureGlowLayer()}destroyInstance(){var e;(e=this.modelInstance)==null||e.dispose(),this.modelInstance=void 0}getAllMeshes(){var e;return(e=this.modelInstance)==null?void 0:e.rootNodes.map(t=>t.getChildMeshes(!1).filter(i=>i instanceof Te.Mesh)).flat()}instantiate(){this.modelInstance=this.assetContainer.instantiateModelsToScene(this.renameClonedAsset.bind(this),!0),this.materials=Z(this.modelInstance),this.configureModelInstance(this.modelInstance),this.animations=$(this.modelInstance.animationGroups,this.renameClonedAsset("")),this.processQueuedEvents()}renameClonedAsset(e){return`${this.id}_${e}`}setEnabled(e){e&&!this.modelInstance?this.instantiate():!e&&this.modelInstance&&this.destroyInstance()}updateDynamicTextures(){var e;(e=this.canvasPanels)==null||e.forEach((t,i)=>{const n=this.dynamicTextures.get(i);n&&t.getStaticContextDirty()&&n.isReady()&&(n.update(!1),t.setStaticContextDirty(!1))})}registerMaterialVariantListener(e){this.materialVariantObservable.add(e)}unregisterMaterialVariantListener(e){this.materialVariantObservable.removeCallback(e)}registerModelVariantListener(e){this.modelVariantObservable.add(e)}unregisterModelVariantListener(e){this.modelVariantObservable.removeCallback(e)}stripIdFromName(e){return e.substring(this.id.length+1)}async processQueuedEvents(){this.previewService.getIsInitialized()&&(await Promise.all(Array.from(this.materialReadyToLoadCallbacks.values()).map(e=>Array.from(e.values()).map(t=>t()))),this.materialReadyToLoadCallbacks.clear(),await Promise.all(Array.from(this.modelReadyToLoadCallbacks.values()).map(e=>e())),this.modelReadyToLoadCallbacks.clear(),this.queuedModelAnimation&&(this.executeAnimation(this.queuedModelAnimation),this.queuedModelAnimation=void 0))}}class S extends y.ArcRotateCamera{constructor(e,t,i,n,r,s,o,h){super(e,t,i,n,r,s,h),this.lastFocus=new g.Vector3(0,0,0),this.panDenominator=1,this.minZ=.01,this.setRadius(this.radius),this.enableFramingBehavior(),this.wheelDeltaPercentage=.01,this.pinchDeltaPercentage=.005,this.useNaturalPinchZoom=!0,o.camera.autoOrientation&&(this.alpha+=Math.PI),o&&(o.camera.limits.min.beta&&(this.lowerBetaLimit=o.camera.limits.min.beta),o.camera.limits.max.beta&&(this.upperBetaLimit=o.camera.limits.max.beta),o.camera.limits.min.alpha&&(this.lowerAlphaLimit=o.camera.limits.min.alpha),o.camera.limits.max.alpha&&(this.upperAlphaLimit=o.camera.limits.max.alpha),o.camera.limits.min.radius&&(this.lowerRadiusLimit=o.camera.limits.min.radius),o.camera.limits.max.radius&&(this.upperRadiusLimit=o.camera.limits.max.radius),o.camera.autoRotation.enabled&&this.enableAutoRotationBehavior(o.camera.autoRotation.idleTimeMs))}getFramingBehavior(){return this.getBehaviorByName("Framing")}getAutoRotationBehavior(){const e=this.getBehaviorByName("AutoRotation");if(e)return e}enableFramingBehavior(){this.useFramingBehavior=!0;const e=this.getFramingBehavior();e.attach(this),e.framingTime=0,e.elevationReturnTime=-1,e.zoomStopsAnimation=!1,this.lowerRadiusLimit=null;const t=F(this._scene);return e.zoomOnBoundingInfo(t.min,t.max),this.wheelPrecision=100/this.radius,this.lowerRadiusLimit===null&&(this.lowerRadiusLimit=.1),this.lastFocus.copyFrom(this.target),e}rerunFramingBehavior(e,t){const i=this.getFramingBehavior();i.framingTime=t||800;const n=()=>{e&&e()},r=F(this._scene),s=r.max.subtract(r.min),o=r.min.add(s.scale(.5));this.setRadius(s.length()*1.5),this.wheelPrecision=100/this.radius,this.panningInertia=0,this.panningOriginTarget.copyFrom(o),this.panDenominator=s.length(),i.zoomOnBoundingInfo(r.min,r.max,void 0,n),i.framingTime=0}enableAutoRotationBehavior(e=5e3){this.useAutoRotationBehavior=!0;const t=this.getAutoRotationBehavior();t&&(t.idleRotationWaitTime=e)}disableAutoRotationBehavior(){this.useAutoRotationBehavior=!1}setRadius(e){this.radius=e,this.maxZ=this.radius*1e3,this.lowerRadiusLimit=this.radius*.01,this.upperRadiusLimit=1.5*this.radius,this.wheelPrecision=100/this.radius,this.pinchPrecision=300/this.radius}static create(e,t,i){const n=F(e),r=n.max.subtract(n.min),s=n.min.add(r.scale(.5)),o=new S("ProductCamera",-(Math.PI/2),Math.PI/2,r.length()*1.5,s,e,t);return o.panningInertia=0,o.panningOriginTarget.copyFrom(s),o.panDenominator=r.length(),o.onAfterCheckInputsObservable.add(()=>{o.panningSensibility=1e3/o.panDenominator}),i&&(e.activeCamera=o),o}}function F(a){if(a.meshes.length===0)return{min:new g.Vector3(-1,-1,-1),max:new g.Vector3(1,1,1)};const e=a.meshes.filter(t=>t.name.toLowerCase().endsWith("_t")||t.name.toLowerCase().includes("_t_"));return a.getWorldExtends(t=>t.isVisible&&t.isEnabled()&&(e.length===0||e.includes(t)))}class Ye{constructor(e,t=!1,i=void 0){this.renderingPipeline=new Ie.DefaultRenderingPipeline("default",t,e,i?[i]:void 0,!1),this.renderingPipeline.isSupported&&(this.renderingPipeline.prepare(),this.setConfiguration(c))}dispose(){this.renderingPipeline.dispose()}getConfiguration(){return this.currentConfiguration}setConfiguration(e){var t,i,n,r,s,o,h,d,u,m,b,f,Q,Y,X,J,_,ee,te,ie,se,re,ne,ae,oe,le,he,ce,de,ue,ge,me,pe;if(this.renderingPipeline.isSupported){if(this.renderingPipeline.samples=((t=e.antiAliasing)==null?void 0:t.samples)??c.antiAliasing.samples,this.renderingPipeline.fxaaEnabled=((i=e.antiAliasing)==null?void 0:i.fxaaEnabled)??c.antiAliasing.fxaaEnabled,this.renderingPipeline.bloomEnabled=((n=e.bloom)==null?void 0:n.enabled)??c.bloom.enabled,this.renderingPipeline.bloomKernel=((r=e.bloom)==null?void 0:r.kernel)??c.bloom.kernel,this.renderingPipeline.bloomScale=((s=e.bloom)==null?void 0:s.scale)??c.bloom.scale,this.renderingPipeline.bloomThreshold=((o=e.bloom)==null?void 0:o.threshold)??c.bloom.threshold,this.renderingPipeline.bloomWeight=((h=e.bloom)==null?void 0:h.weight)??c.bloom.weight,this.renderingPipeline.chromaticAberrationEnabled=((d=e.chromaticAberration)==null?void 0:d.enabled)??c.chromaticAberration.enabled,this.renderingPipeline.chromaticAberration.aberrationAmount=((u=e.chromaticAberration)==null?void 0:u.aberrationAmount)??c.chromaticAberration.aberrationAmount,this.renderingPipeline.chromaticAberration.radialIntensity=((m=e.chromaticAberration)==null?void 0:m.radialIntensity)??c.chromaticAberration.radialIntensity,this.renderingPipeline.chromaticAberration.direction=(b=e.chromaticAberration)!=null&&b.direction?new g.Vector2(e.chromaticAberration.direction.x,e.chromaticAberration.direction.y):new g.Vector2(c.chromaticAberration.direction.x,c.chromaticAberration.direction.y),this.renderingPipeline.imageProcessing.colorCurvesEnabled=((f=e.colorCurves)==null?void 0:f.enabled)??c.colorCurves.enabled,this.renderingPipeline.imageProcessing.colorCurves=e.colorCurves?this.updateColorCurve(e.colorCurves):new V.ColorCurves,this.renderingPipeline.depthOfFieldEnabled=((Q=e.depthOfField)==null?void 0:Q.enabled)??c.depthOfField.enabled,e.depthOfField)switch(e.depthOfField.blurLevel??c.depthOfField.blurLevel){case"Low":this.renderingPipeline.depthOfFieldBlurLevel=I.DepthOfFieldEffectBlurLevel.Low;break;case"Medium":this.renderingPipeline.depthOfFieldBlurLevel=I.DepthOfFieldEffectBlurLevel.Medium;break;case"High":this.renderingPipeline.depthOfFieldBlurLevel=I.DepthOfFieldEffectBlurLevel.High;break}if(this.renderingPipeline.depthOfField.focalLength=((Y=e.depthOfField)==null?void 0:Y.focalLength)??c.depthOfField.focalLength,this.renderingPipeline.depthOfField.fStop=((X=e.depthOfField)==null?void 0:X.fStop)??c.depthOfField.fStop,this.renderingPipeline.depthOfField.focusDistance=((J=e.depthOfField)==null?void 0:J.focusDistance)??c.depthOfField.focusDistance,this.renderingPipeline.depthOfField.lensSize=((_=e.depthOfField)==null?void 0:_.lensSize)??c.depthOfField.lensSize,this.renderingPipeline.grainEnabled=((ee=e.grain)==null?void 0:ee.enabled)??c.grain.enabled,this.renderingPipeline.grain.animated=((te=e.grain)==null?void 0:te.animated)??c.grain.animated,this.renderingPipeline.grain.intensity=((ie=e.grain)==null?void 0:ie.intensity)??c.grain.intensity,this.renderingPipeline.imageProcessing.contrast=((se=e.misc)==null?void 0:se.contrast)??c.misc.contrast,this.renderingPipeline.imageProcessing.exposure=((re=e.misc)==null?void 0:re.exposure)??c.misc.exposure,this.renderingPipeline.imageProcessing.toneMappingEnabled=((ne=e.misc)==null?void 0:ne.toneMappingEnabled)??c.misc.toneMappingEnabled,this.renderingPipeline.imageProcessing.toneMappingEnabled)switch(e.misc.toneMappingType??c.misc.toneMappingType){case"Standard":this.renderingPipeline.imageProcessing.toneMappingType=P.ImageProcessingConfiguration.TONEMAPPING_STANDARD;break;case"ACES":this.renderingPipeline.imageProcessing.toneMappingType=P.ImageProcessingConfiguration.TONEMAPPING_ACES;break}if(this.renderingPipeline.sharpenEnabled=((ae=e.sharpen)==null?void 0:ae.enabled)??c.sharpen.enabled,this.renderingPipeline.sharpen.colorAmount=((oe=e.sharpen)==null?void 0:oe.colorAmount)??c.sharpen.colorAmount,this.renderingPipeline.sharpen.edgeAmount=((le=e.sharpen)==null?void 0:le.edgeAmount)??c.sharpen.edgeAmount,this.renderingPipeline.imageProcessing.vignetteEnabled=((he=e.vignette)==null?void 0:he.enabled)??c.vignette.enabled,(ce=e.vignette)!=null&&ce.center?(this.renderingPipeline.imageProcessing.vignetteCenterX=e.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=e.vignette.center.y):(this.renderingPipeline.imageProcessing.vignetteCenterX=c.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=c.vignette.center.y),e.vignette)switch(((de=e.vignette)==null?void 0:de.blendMode)??c.vignette.blendMode){case"Multiply":this.renderingPipeline.imageProcessing.vignetteBlendMode=P.ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY;break;case"Opaque":this.renderingPipeline.imageProcessing.vignetteBlendMode=P.ImageProcessingConfiguration.VIGNETTEMODE_OPAQUE;break}(ue=e.vignette)!=null&&ue.colorRgba?this.renderingPipeline.imageProcessing.vignetteColor=new p.Color4(e.vignette.colorRgba.r,e.vignette.colorRgba.g,e.vignette.colorRgba.b,e.vignette.colorRgba.a):(ge=e.vignette)!=null&&ge.colorHex?this.renderingPipeline.imageProcessing.vignetteColor=p.Color4.FromHexString(e.vignette.colorHex):this.renderingPipeline.imageProcessing.vignetteColor=new p.Color4(c.vignette.colorRgba.r,c.vignette.colorRgba.g,c.vignette.colorRgba.b,c.vignette.colorRgba.a),this.renderingPipeline.imageProcessing.vignetteStretch=((me=e.vignette)==null?void 0:me.stretch)??c.vignette.stretch,this.renderingPipeline.imageProcessing.vignetteWeight=((pe=e.vignette)==null?void 0:pe.weight)??c.vignette.weight,this.renderingPipeline.prepare(),this.currentConfiguration=e}}updateColorCurve(e){const t=new V.ColorCurves;return t.globalDensity=e.globalDensity??t.globalDensity,t.globalExposure=e.globalExposure??t.globalExposure,t.globalHue=e.globalHue??t.globalHue,t.globalSaturation=e.globalSaturation??t.globalSaturation,t.highlightsDensity=e.highlightsDensity??t.highlightsDensity,t.highlightsExposure=e.highlightsExposure??t.highlightsExposure,t.highlightsHue=e.highlightsHue??t.highlightsHue,t.highlightsSaturation=e.highlightsSaturation??t.highlightsSaturation,t.midtonesDensity=e.midtonesDensity??t.midtonesDensity,t.midtonesExposure=e.midtonesExposure??t.midtonesExposure,t.midtonesHue=e.midtonesHue??t.midtonesHue,t.midtonesSaturation=e.midtonesSaturation??t.midtonesSaturation,t.shadowsDensity=e.shadowsDensity??t.shadowsDensity,t.shadowsExposure=e.shadowsExposure??t.shadowsExposure,t.shadowsHue=e.shadowsHue??t.shadowsHue,t.shadowsSaturation=e.shadowsSaturation??t.shadowsSaturation,t}}Me.GLTF2.GLTFLoader.RegisterExtension("glbPostProcessor",function(a){return new Fe(a)}),B.SceneLoader.OnPluginActivatedObservable.add(a=>{if(a.name==="gltf"){const e=a;e.transparencyAsCoverage=!0}});const R="initialScene";class Xe{constructor(e){this.loadProgress=new Map([[R,0]]),this.focusLostNotified=!1,this.loadObservable=new v.Observable,this.focusLostObservable=new v.Observable,this.initializedCallbacks=[],this.isInitialized=!1,this.modelLoadEventCallbacks=[],this.modelContainers=new Map,this.plugins=[],this.configuration=new Se(e);const i=(()=>{if(!(e!=null&&e.noRender))return this.configuration.createCanvas()})(),n="1.5.6";ve.DracoCompression.Configuration={decoder:{wasmUrl:`https://www.gstatic.com/draco/versioned/decoders/${n}/draco_wasm_wrapper_gltf.js`,wasmBinaryUrl:`https://www.gstatic.com/draco/versioned/decoders/${n}/draco_decoder_gltf.wasm`,fallbackUrl:`https://www.gstatic.com/draco/versioned/decoders/${n}/draco_decoder_gltf.js`}},i&&(i.getContext("webgl2")||i.getContext("webgl"));const r=console.log;console.log=()=>{};const s=i?new j.Engine(i,!0,{adaptToDeviceRatio:!0,limitDeviceRatio:2,premultipliedAlpha:!1,preserveDrawingBuffer:!!(e!=null&&e.backgroundImage),audioEngine:!1,stencil:this.configuration.highlights.enabled,forceSRGBBufferSupportState:!0}):new be.NullEngine;console.log=r,s.hideLoadingUI(),window.addEventListener("resize",this.fireResizeEvent.bind(this)),this.engine=s,this.scene=new we.Scene(s),this.camera=S.create(this.scene,this.configuration),this.renderingPipeline=new Ye(this.scene,!1,this.camera),this.scene.imageProcessingConfiguration.exposure=this.configuration.lighting.exposure,this.scene.imageProcessingConfiguration.contrast=this.configuration.lighting.contrast,this.glowLayerManager=new je(this.scene,this.configuration.emissiveGlowIntensity)}getEngineContext(){return{engine:this.engine,scene:this.scene,camera:this.camera}}registerFocusLostListener(e){this.focusLostObservable.add(e)}unregisterFocusLostListener(e){this.focusLostObservable.removeCallback(e)}registerLoadProgressListener(e){this.loadObservable.add(e),e(this.getLoadListenerEvent())}unregisterLoadProgressListener(e){this.loadObservable.removeCallback(e)}registerInitializedListener(e){this.isInitialized||!this.isInitialized&&this.initializedCallbacks.push(e)}unregisterInitializedListener(e){if(this.isInitialized)return;const t=this.initializedCallbacks.indexOf(e);t>-1&&this.initializedCallbacks.splice(t,1)}getIsInitialized(){return this.isInitialized}registerModelLoadEventListener(e){this.modelLoadEventCallbacks.push(e)}unregisterModelLoadEventListener(e){const t=this.modelLoadEventCallbacks.indexOf(e);t>-1&&this.modelLoadEventCallbacks.splice(t,1)}registerView(e){const t=e.height,i=e.width;this.engine.registerView(e),e.setAttribute("height",t.toString()),e.setAttribute("width",i.toString()),this.orbitEnabled()||this.setCameraState(L.Pan),this.reattachControls(e)}getNumViewports(){var e;return((e=this.engine.views)==null?void 0:e.length)||0}unregisterView(e){this.engine.unRegisterView(e)}shutdown(){this.plugins.forEach(e=>e.dispose(!0)),this.renderingPipeline.dispose(),this.engine&&this.engine.dispose(),window.removeEventListener("resize",this.fireResizeEvent)}getSceneInitializationProgress(){return this.loadProgress.get(R)}async initialize(e){var i,n;this.scene.clearColor=this.configuration.scene.clearColor,this.scene.environmentTexture=ye.CubeTexture.CreateFromPrefilteredData(this.configuration.scene.environmentFile,this.scene);let t;return e&&(t=await this.loadModel(e,s=>{this.loadProgress.set(R,s.loaded*100/s.total),this.notifyLoadHandlers()}).getInitializationPromise()),this.loadProgress.set(R,100),this.notifyLoadHandlers(),this.scene.activeCamera=this.camera,this.camera.rerunFramingBehavior(void 0,1),ze(this.scene),((i=this.engine.views)==null?void 0:i.length)>=1&&this.reattachControls(this.engine.views[this.engine.views.length-1].target),this.queuedCameraAnimation&&(this.executeCameraAnimation(this.queuedCameraAnimation),this.queuedCameraAnimation=void 0),this.isInitialized=!0,await Promise.all(this.initializedCallbacks.map(r=>r())),this.initializedCallbacks=[],(n=this.configuration.options)!=null&&n.renderingPipelineConfiguration&&this.renderingPipeline.setConfiguration(this.configuration.options.renderingPipelineConfiguration),this.engine.runRenderLoop(()=>{this.engine.views&&(this.modelContainers.forEach(r=>{r.updateDynamicTextures()}),this.configuration.scene.transparentBackground&&this.engine.views.forEach(r=>{const s=this.engine.getRenderingCanvas();r.target.getContext("2d").clearRect(0,0,s.width,s.height)}),this.scene.render(),!this.camera.target.equalsWithEpsilon(this.camera.lastFocus,.1)&&!this.focusLostNotified&&(this.focusLostObservable.notifyObservers(void 0),this.focusLostNotified=!0),this.screenshotPrepareResolve&&(this.screenshotPrepareResolve(),this.screenshotPrepareResolve=void 0))}),t}executeCameraAnimation(e){if(this.getSceneInitializationProgress()!==100||!this.camera||this.scene.activeCamera!==this.camera){this.queuedCameraAnimation=e;return}ke(this.scene,this.scene.activeCamera,e)}getCameraPose(){if(this.scene&&this.camera)return{lonDeg:Math.round(this.camera.alpha*180/Math.PI),latDeg:Math.round(this.camera.beta*180/Math.PI),radius:Math.round((this.camera.radius+Number.EPSILON)*1e4)/1e4,target:{x:this.camera.target.x,y:this.camera.target.y,z:this.camera.target.z}}}setCameraPose(e){this.scene&&this.camera&&(this.camera.target=new g.Vector3(e.target.x,e.target.y,e.target.z),this.camera.radius=e.radius,this.camera.alpha=e.latDeg,this.camera.beta=e.lonDeg)}setCameraState(e){var t,i;if(!((t=this.engine)!=null&&t.views)||!((i=this.engine)!=null&&i.views[0]))throw new Error("No views attached, camera state requires a view to attach controls onto.");e===L.Orbit?this.reattachControls(this.engine.views[0].target,2):this.reattachControls(this.engine.views[0].target,0)}animateToLastCameraFocus(){return new Promise(e=>{const t=()=>{const i=this.configuration;this.camera.rerunFramingBehavior(()=>{this.focusLostNotified=!1,i.camera.limits.min.radius&&(this.camera.lowerRadiusLimit=i.camera.limits.min.radius),i.camera.limits.max.radius&&(this.camera.upperRadiusLimit=i.camera.limits.max.radius),e()})};this.scene.onAfterRenderObservable.addOnce(t)})}setAutoRotation(e){!this.configuration.camera.autoRotation.enabled||!this.camera||(e?this.camera.enableAutoRotationBehavior(this.configuration.camera.autoRotation.idleTimeMs):this.camera.disableAutoRotationBehavior())}getCurrentConfiguration(){return this.configuration.options}async renderSceneScreenshot(e,t){if(!this.camera)throw new Error("Missing product camera, cannot render screenshot!");const i=new y.ArcRotateCamera("screenshotCamera",0,0,0,g.Vector3.Zero(),this.scene);try{const n=t.latDeg*Math.PI/180,r=t.lonDeg*Math.PI/180;i.target=t.target?new g.Vector3(t.target.x,t.target.y,t.target.z):g.Vector3.Zero(),i.alpha=r,i.beta=n,i.radius=t.radius||this.camera.radius,i.minZ=.01,this.scene.render();const s=await Ce.Tools.CreateScreenshotUsingRenderTargetAsync(this.engine,i,e,"image/png",2,!0);return i.dispose(),s}catch{throw i.isDisposed()||i.dispose(),new Error("Failed to render screenshot")}}orbitEnabled(){const e=this.configuration;if(!e)return!0;const t=e.camera.limits.min.alpha,i=e.camera.limits.max.alpha,n=e.camera.limits.min.beta,r=e.camera.limits.max.beta;if(t===void 0||i===void 0||n===void 0||r===void 0)return!0;const s=[t,i],o=[n,r],h=s.every(u=>u===t),d=o.every(u=>u===n);return!h&&!d}fireResizeEvent(){this.getNumViewports()>0&&this.engine.resize()}setHighlights(e,t){var n;e.length===0&&((n=this.highlightLayer)==null||n.dispose(),this.highlightLayer=void 0),this.highlightLayer||(this.highlightLayer=new fe.HighlightLayer("highlights",this.scene,{isStroke:!0,blurVerticalSize:.85,blurHorizontalSize:.85}),this.highlightLayer.innerGlow=!0,this.highlightLayer.outerGlow=!1),this.highlightLayer.removeAllMeshes();const i=t?new p.Color3(t[0],t[1],t[2]).toLinearSpace():void 0;e.forEach(r=>{const s=this.scene.materials.find(o=>o.name===r.name&&o.id===r.id);s&&s.getBindedMeshes().forEach(o=>{var h;return(h=this.highlightLayer)==null?void 0:h.addMesh(o,i||p.Color3.FromHexString("#fcba03"))})})}setRenderingPipelineConfiguration(e){this.renderingPipeline&&this.renderingPipeline.setConfiguration(e)}loadModel(e,t){const i=new Qe({enablePicking:this.configuration.highlights.enabled,modelDetails:e,scene:this.scene,previewService:this,progressHandler:t});return i.registerMaterialVariantListener(n=>this.handleMaterialProgressCallback(n.remainingCount,n.totalCount,n.taskName)),i.registerModelVariantListener(n=>this.handleModelProgressCallback(n,n.key)),this.configuration.highlights.enabled&&(i.registerMaterialSelectedCallback(n=>{this.setHighlights([n])}),i.registerMaterialDeselectedCallback(()=>{this.setHighlights([])})),this.modelContainers.set(i.getId(),i),this.triggerModelLoadEvent({eventType:"load",modelContainer:i}),i}getAllModels(){return Array.from(this.modelContainers.values())}getModelById(e){return this.modelContainers.get(e)}registerPlugin(e){this.plugins.push(e),e.initialize(this,{camera:this.camera,engine:this.engine,scene:this.scene})}unregisterPlugin(e){const t=this.plugins.indexOf(e);t>-1&&this.plugins.splice(t,1).forEach(n=>n.dispose(!1))}getGlowLayerManager(){return this.glowLayerManager}modelUnloaded(e){this.modelContainers.delete(e.getId()),this.triggerModelLoadEvent({eventType:"unload",modelContainer:e})}triggerModelLoadEvent(e){this.modelLoadEventCallbacks.forEach(t=>t(e))}handleMaterialProgressCallback(e,t,i){this.loadProgress.set(`key_${i}`,e/t*100),this.notifyLoadHandlers()}handleModelProgressCallback(e,t){this.loadProgress.set(t,e.loaded*100/e.total),this.notifyLoadHandlers()}reattachControls(e,t=2){if(this.scene.detachControl(),this.engine.inputElement=e,this.camera){this.camera.attachControl(!0,!1,t);const i=this.camera.inputs.attached.pointers;i.multiTouchPanning=!1}this.scene.attachControl(!0,!0,!0)}getLoadListenerEvent(){const e=Array.from(this.loadProgress.values()).filter(n=>n<100),i=e.reduce((n,r)=>n+r,0)/e.length||0;return{loadValue:e.length===0?100:i,sceneInitialized:this.getSceneInitializationProgress()===100}}notifyLoadHandlers(){this.loadObservable.notifyObservers(this.getLoadListenerEvent())}}function Je(a,e=new g.Vector3(0,1,0),t=Math.PI){const{position:i=g.Vector3.Zero(),rotation:n=g.Vector3.Zero(),scale:r=g.Vector3.One()}=a,s=g.Matrix.Compose(r,g.Quaternion.FromEulerVector(n),i),o=g.Matrix.RotationAxis(e,t),h=s.multiply(o),d=g.Vector3.Zero(),u=g.Quaternion.Identity(),m=g.Vector3.Zero();return h.decompose(m,u,d),{position:d,rotation:u.toEulerAngles(),scale:m}}l.MaterialEffectMode=T,l.ProductCameraRig=L,l.REFLECTION_PROBE_RESOLUTION=z,l.RenderingConfiguration=w,l.SpiffCommerce3DPreviewService=Xe,l.renderingPipelineDefaults=c,l.rotateAroundOrigin=Je,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED