@spiffcommerce/preview 5.0.0-rc.4 → 5.0.0-rc.6
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 +21 -33
- package/dist/index.esm.js +200 -158
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -44,6 +44,15 @@ type CameraPose = {
|
|
|
44
44
|
};
|
|
45
45
|
};
|
|
46
46
|
type ThreeDPreviewService = {
|
|
47
|
+
/**
|
|
48
|
+
* Returns a promise which resolves when the scene has been initialized.
|
|
49
|
+
*/
|
|
50
|
+
getInitializationPromise(): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* True when the scene has been initialized. This is when the initializationPromise resolves. Remember you may need
|
|
53
|
+
* to await a model's initialization promise as well if you want to hide the scene until the model is loaded.
|
|
54
|
+
*/
|
|
55
|
+
getInitializationComplete(): boolean;
|
|
47
56
|
/**
|
|
48
57
|
* Allows listeners to be aware of the camera losing focus of the
|
|
49
58
|
* main product.
|
|
@@ -56,20 +65,6 @@ type ThreeDPreviewService = {
|
|
|
56
65
|
* @param listener The listener to remove.
|
|
57
66
|
*/
|
|
58
67
|
unregisterFocusLostListener(listener: () => void): void;
|
|
59
|
-
/**
|
|
60
|
-
* Provides a callback that will be called when the service has been initialized.
|
|
61
|
-
* @param listener The callback function to add.
|
|
62
|
-
*/
|
|
63
|
-
registerInitializedListener(listener: () => void | Promise<void>): void;
|
|
64
|
-
/**
|
|
65
|
-
* Removes a callback from the observables that would be called when the service has been initialized.
|
|
66
|
-
* @param listener The function to remove.
|
|
67
|
-
*/
|
|
68
|
-
unregisterInitializedListener(listener: () => void | Promise<void>): void;
|
|
69
|
-
/**
|
|
70
|
-
* Returns true if the service has been initialized.
|
|
71
|
-
*/
|
|
72
|
-
getIsInitialized(): boolean;
|
|
73
68
|
/**
|
|
74
69
|
* Provides listeners with information about model load events.
|
|
75
70
|
* @param listener A function to get load events. The eventType will be 'load' or 'unload',
|
|
@@ -888,13 +883,13 @@ declare class Configuration {
|
|
|
888
883
|
readonly customOptions?: PreviewOptions;
|
|
889
884
|
constructor(options?: PreviewOptions);
|
|
890
885
|
createCanvas(): HTMLCanvasElement;
|
|
891
|
-
get options(): PreviewOptions;
|
|
886
|
+
get options(): PreviewOptions | undefined;
|
|
892
887
|
/**
|
|
893
888
|
* Configuration related to the scene
|
|
894
889
|
*/
|
|
895
890
|
get scene(): {
|
|
896
891
|
clearColor: Color4;
|
|
897
|
-
transparentBackground: string | true;
|
|
892
|
+
transparentBackground: string | true | undefined;
|
|
898
893
|
environmentFile: string;
|
|
899
894
|
};
|
|
900
895
|
/**
|
|
@@ -908,14 +903,14 @@ declare class Configuration {
|
|
|
908
903
|
};
|
|
909
904
|
limits: {
|
|
910
905
|
min: {
|
|
911
|
-
alpha: number;
|
|
912
|
-
beta: number;
|
|
913
|
-
radius: number;
|
|
906
|
+
alpha: number | undefined;
|
|
907
|
+
beta: number | undefined;
|
|
908
|
+
radius: number | undefined;
|
|
914
909
|
};
|
|
915
910
|
max: {
|
|
916
|
-
alpha: number;
|
|
917
|
-
beta: number;
|
|
918
|
-
radius: number;
|
|
911
|
+
alpha: number | undefined;
|
|
912
|
+
beta: number | undefined;
|
|
913
|
+
radius: number | undefined;
|
|
919
914
|
};
|
|
920
915
|
};
|
|
921
916
|
};
|
|
@@ -1018,14 +1013,6 @@ declare class SpiffCommerce3DPreviewService implements ThreeDPreviewService {
|
|
|
1018
1013
|
* An observable handling loss of target focus by the camera.
|
|
1019
1014
|
*/
|
|
1020
1015
|
private focusLostObservable;
|
|
1021
|
-
/**
|
|
1022
|
-
* An observable handling the initialization of the preview service.
|
|
1023
|
-
*/
|
|
1024
|
-
private initializedCallbacks;
|
|
1025
|
-
/**
|
|
1026
|
-
* Whether or not the preview service has completed its first render
|
|
1027
|
-
*/
|
|
1028
|
-
private isInitialized;
|
|
1029
1016
|
/**
|
|
1030
1017
|
* A collection of callbacks to be invoked when a model is loaded or unloaded.
|
|
1031
1018
|
*/
|
|
@@ -1040,7 +1027,11 @@ declare class SpiffCommerce3DPreviewService implements ThreeDPreviewService {
|
|
|
1040
1027
|
private modelContainers;
|
|
1041
1028
|
private plugins;
|
|
1042
1029
|
private screenshotPrepareResolve;
|
|
1030
|
+
private readonly initPromise;
|
|
1031
|
+
private initComplete;
|
|
1043
1032
|
constructor(options?: PreviewOptions);
|
|
1033
|
+
getInitializationPromise(): Promise<void>;
|
|
1034
|
+
getInitializationComplete(): boolean;
|
|
1044
1035
|
getEngineContext(): {
|
|
1045
1036
|
engine: Engine;
|
|
1046
1037
|
scene: Scene;
|
|
@@ -1048,9 +1039,6 @@ declare class SpiffCommerce3DPreviewService implements ThreeDPreviewService {
|
|
|
1048
1039
|
};
|
|
1049
1040
|
registerFocusLostListener(listener: () => void): void;
|
|
1050
1041
|
unregisterFocusLostListener(listener: () => void): void;
|
|
1051
|
-
registerInitializedListener(listener: () => void | Promise<void>): void;
|
|
1052
|
-
unregisterInitializedListener(listener: () => void | Promise<void>): void;
|
|
1053
|
-
getIsInitialized(): boolean;
|
|
1054
1042
|
registerModelLoadEventListener(listener: (e: ModelLoadEventData) => void): void;
|
|
1055
1043
|
unregisterModelLoadEventListener(listener: (e: ModelLoadEventData) => void): void;
|
|
1056
1044
|
registerView(canvas: HTMLCanvasElement): void;
|
package/dist/index.esm.js
CHANGED
|
@@ -1,35 +1,34 @@
|
|
|
1
1
|
import { ArcRotateCamera as ue } from "@babylonjs/core/Cameras/arcRotateCamera";
|
|
2
2
|
import { Engine as me } from "@babylonjs/core/Engines/engine";
|
|
3
|
-
import { NullEngine as
|
|
4
|
-
import { HighlightLayer as
|
|
3
|
+
import { NullEngine as we } from "@babylonjs/core/Engines/nullEngine";
|
|
4
|
+
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 Ce } from "@babylonjs/core/Materials/Textures/cubeTexture";
|
|
7
|
-
import { Color4 as f, Color3 as
|
|
8
|
-
import { Vector3 as m, Quaternion as
|
|
9
|
-
import { DracoCompression as
|
|
7
|
+
import { Color4 as f, Color3 as v } from "@babylonjs/core/Maths/math.color";
|
|
8
|
+
import { Vector3 as m, Quaternion as M, Vector2 as te, Matrix as ie } from "@babylonjs/core/Maths/math.vector";
|
|
9
|
+
import { DracoCompression as Me } from "@babylonjs/core/Meshes/Compression/dracoCompression";
|
|
10
10
|
import { Observable as C } from "@babylonjs/core/Misc/observable";
|
|
11
|
-
import { Tools as
|
|
11
|
+
import { Tools as xe } from "@babylonjs/core/Misc/tools";
|
|
12
12
|
import { Scene as ye } from "@babylonjs/core/scene";
|
|
13
13
|
import { GLTF2 as Pe } from "@babylonjs/loaders/glTF";
|
|
14
14
|
import { PBRMaterial as F } from "@babylonjs/core/Materials/PBR/pbrMaterial";
|
|
15
|
-
import { MirrorTexture as
|
|
16
|
-
import { Color3 as
|
|
17
|
-
import { ReflectionProbe as
|
|
18
|
-
import { GlowLayer as
|
|
19
|
-
import { ActionManager as
|
|
15
|
+
import { MirrorTexture as Re } from "@babylonjs/core/Materials/Textures/mirrorTexture";
|
|
16
|
+
import { Color3 as Ee, Vector3 as se, Plane as Ae } from "@babylonjs/core/Maths/math";
|
|
17
|
+
import { ReflectionProbe as Te } from "@babylonjs/core/Probes/reflectionProbe";
|
|
18
|
+
import { GlowLayer as Oe } from "@babylonjs/core/Layers/glowLayer";
|
|
19
|
+
import { ActionManager as E } from "@babylonjs/core/Actions/actionManager";
|
|
20
20
|
import { ExecuteCodeAction as ne } from "@babylonjs/core/Actions/directActions";
|
|
21
21
|
import { Mesh as Le } from "@babylonjs/core/Meshes/mesh";
|
|
22
22
|
import { TransformNode as Ie } from "@babylonjs/core/Meshes/transformNode";
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import { AssetsManager as ke } from "@babylonjs/core/Misc/assetsManager";
|
|
23
|
+
import { DynamicTexture as Se } from "@babylonjs/core/Materials/Textures/dynamicTexture";
|
|
24
|
+
import { Texture as Fe } from "@babylonjs/core/Materials/Textures/texture";
|
|
25
|
+
import { Animation as w } from "@babylonjs/core/Animations/animation";
|
|
26
|
+
import { QuadraticEase as Be, EasingFunction as De } from "@babylonjs/core/Animations/easing";
|
|
27
|
+
import { AssetsManager as ze } from "@babylonjs/core/Misc/assetsManager";
|
|
29
28
|
import { ColorCurves as re } from "@babylonjs/core/Materials/colorCurves";
|
|
30
29
|
import { ImageProcessingConfiguration as P } from "@babylonjs/core/Materials/imageProcessingConfiguration";
|
|
31
30
|
import { DefaultRenderingPipeline as Ne } from "@babylonjs/core/PostProcesses/RenderPipeline";
|
|
32
|
-
import { DepthOfFieldEffectBlurLevel as
|
|
31
|
+
import { DepthOfFieldEffectBlurLevel as A } from "@babylonjs/core/PostProcesses/depthOfFieldEffect";
|
|
33
32
|
import "@babylonjs/core/Rendering/depthRendererSceneComponent";
|
|
34
33
|
import "@babylonjs/core/Engines/Extensions/engine.views";
|
|
35
34
|
import "@babylonjs/core/Meshes/instancedMesh";
|
|
@@ -41,7 +40,7 @@ import "@babylonjs/core/Misc/screenshotTools";
|
|
|
41
40
|
import "@babylonjs/core/Rendering/boundingBoxRenderer";
|
|
42
41
|
import "@babylonjs/loaders/glTF/2.0/Extensions";
|
|
43
42
|
var I = /* @__PURE__ */ ((s) => (s[s.Orbit = 0] = "Orbit", s[s.Pan = 1] = "Pan", s))(I || {}), S = /* @__PURE__ */ ((s) => (s.None = "None", s.RemoveWhenSelected = "RemoveWhenSelected", s.ApplyWhenSelected = "ApplyWhenSelected", s))(S || {});
|
|
44
|
-
class
|
|
43
|
+
class ke {
|
|
45
44
|
constructor(e) {
|
|
46
45
|
this.getSceneClearColor = () => {
|
|
47
46
|
var i, o, a, n;
|
|
@@ -49,7 +48,7 @@ class Ve {
|
|
|
49
48
|
if (this.customOptions && ((a = this.customOptions) != null && a.transparentBackground) || (n = this.customOptions) != null && n.backgroundImage)
|
|
50
49
|
return new f(0, 0, 0, t).toLinearSpace();
|
|
51
50
|
if (this.customOptions && this.customOptions.backgroundColor) {
|
|
52
|
-
const r =
|
|
51
|
+
const r = v.FromHexString(
|
|
53
52
|
this.customOptions.backgroundColor
|
|
54
53
|
);
|
|
55
54
|
return new f(
|
|
@@ -61,7 +60,7 @@ class Ve {
|
|
|
61
60
|
}
|
|
62
61
|
return new f(0.98, 0.98, 0.98, t).toLinearSpace();
|
|
63
62
|
}, this.highlightColorFromConfig = () => this.customOptions && this.customOptions.highlightColor ? this.hexToColor4(this.customOptions.highlightColor) : new f(0.98, 0.98, 0.98, 1).toLinearSpace(), this.hexToColor4 = (t, i = 1) => {
|
|
64
|
-
const o =
|
|
63
|
+
const o = v.FromHexString(t);
|
|
65
64
|
return new f(
|
|
66
65
|
o.r,
|
|
67
66
|
o.g,
|
|
@@ -177,7 +176,7 @@ class y {
|
|
|
177
176
|
}
|
|
178
177
|
}
|
|
179
178
|
}
|
|
180
|
-
const
|
|
179
|
+
const Ve = 128, h = {
|
|
181
180
|
antiAliasing: {
|
|
182
181
|
samples: 4,
|
|
183
182
|
fxaaEnabled: !1
|
|
@@ -234,7 +233,7 @@ const Ge = 128, h = {
|
|
|
234
233
|
weight: 1
|
|
235
234
|
}
|
|
236
235
|
};
|
|
237
|
-
class
|
|
236
|
+
class Ge {
|
|
238
237
|
constructor(e) {
|
|
239
238
|
this.name = "glbPostProcessor", this.enabled = !0, this.loader = e;
|
|
240
239
|
}
|
|
@@ -285,7 +284,7 @@ class He {
|
|
|
285
284
|
}
|
|
286
285
|
if (e.extras.translucency) {
|
|
287
286
|
const i = t;
|
|
288
|
-
i.subSurface.isTranslucencyEnabled = !0, i.subSurface.translucencyIntensity = e.extras.translucency, e.extras.translucencyR && e.extras.translucencyG && e.extras.translucencyB && (i.subSurface.tintColor = new
|
|
287
|
+
i.subSurface.isTranslucencyEnabled = !0, i.subSurface.translucencyIntensity = e.extras.translucency, e.extras.translucencyR && e.extras.translucencyG && e.extras.translucencyB && (i.subSurface.tintColor = new Ee(
|
|
289
288
|
e.extras.translucencyR,
|
|
290
289
|
e.extras.translucencyG,
|
|
291
290
|
e.extras.translucencyB
|
|
@@ -323,7 +322,7 @@ class He {
|
|
|
323
322
|
const r = a.material;
|
|
324
323
|
if (!r)
|
|
325
324
|
return;
|
|
326
|
-
const l = new
|
|
325
|
+
const l = new Re(
|
|
327
326
|
"mirror",
|
|
328
327
|
y.getMirrorTextureResolution(),
|
|
329
328
|
e,
|
|
@@ -339,16 +338,16 @@ class He {
|
|
|
339
338
|
const d = a.getWorldMatrix(), u = se.TransformNormal(
|
|
340
339
|
new se(c[0], c[1], c[2]),
|
|
341
340
|
d
|
|
342
|
-
).normalize(), g =
|
|
341
|
+
).normalize(), g = Ae.FromPositionAndNormal(
|
|
343
342
|
a.position,
|
|
344
343
|
u.scale(-1)
|
|
345
344
|
);
|
|
346
345
|
l.mirrorPlane = g, l.level = n, r.reflectionTexture = l;
|
|
347
346
|
}
|
|
348
347
|
function o(a) {
|
|
349
|
-
const n = a.material, r = new
|
|
348
|
+
const n = a.material, r = new Te(
|
|
350
349
|
"probe-" + n.name,
|
|
351
|
-
|
|
350
|
+
Ve,
|
|
352
351
|
e
|
|
353
352
|
);
|
|
354
353
|
r.attachToMesh(a), r.renderList && r.renderList.push(...t(e)), n.reflectionTexture = r.cubeTexture;
|
|
@@ -359,38 +358,41 @@ class He {
|
|
|
359
358
|
});
|
|
360
359
|
}
|
|
361
360
|
}
|
|
362
|
-
class
|
|
361
|
+
class qe {
|
|
363
362
|
constructor(e, t) {
|
|
364
363
|
this.scene = e, this.intensity = t, this.meshCount = 0;
|
|
365
364
|
}
|
|
366
365
|
includeMeshes(e) {
|
|
367
|
-
|
|
368
|
-
this.glowLayer
|
|
369
|
-
|
|
366
|
+
if (e) {
|
|
367
|
+
this.glowLayer || (this.glowLayer = new Oe("glow", this.scene), this.glowLayer.intensity = this.intensity);
|
|
368
|
+
for (const t of e)
|
|
369
|
+
this.glowLayer.hasMesh(t) || (this.glowLayer.addIncludedOnlyMesh(t), this.meshCount++);
|
|
370
|
+
}
|
|
370
371
|
}
|
|
371
372
|
removeMeshes(e) {
|
|
372
|
-
!this.glowLayer || !e
|
|
373
|
-
|
|
374
|
-
|
|
373
|
+
if (!(!this.glowLayer || !e)) {
|
|
374
|
+
for (const t of e)
|
|
375
|
+
this.glowLayer.hasMesh(t) && (this.glowLayer.removeIncludedOnlyMesh(t), this.meshCount--);
|
|
376
|
+
this.meshCount === 0 && (this.glowLayer.dispose(), this.glowLayer = void 0);
|
|
377
|
+
}
|
|
375
378
|
}
|
|
376
379
|
}
|
|
377
380
|
const ae = /* @__PURE__ */ new Map();
|
|
378
381
|
async function pe(s, e, t) {
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
ge.LoadAssetContainerAsync(
|
|
382
|
+
const i = ae.get(s);
|
|
383
|
+
if (i && i.scene.uid === e.uid)
|
|
384
|
+
return i;
|
|
385
|
+
{
|
|
386
|
+
const o = await ge.LoadAssetContainerAsync(
|
|
384
387
|
s,
|
|
385
388
|
void 0,
|
|
386
389
|
e,
|
|
387
390
|
t
|
|
388
|
-
)
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
});
|
|
391
|
+
);
|
|
392
|
+
return ae.set(s, o), o;
|
|
393
|
+
}
|
|
392
394
|
}
|
|
393
|
-
function
|
|
395
|
+
function He(s, e, t, i, o = "") {
|
|
394
396
|
t.forEach((a) => {
|
|
395
397
|
const n = a.getID(), r = a.getName(), l = y.getDynamicTextureResolution();
|
|
396
398
|
s.filter((d) => d.name === o + r).forEach((d) => {
|
|
@@ -398,7 +400,7 @@ function qe(s, e, t, i, o = "") {
|
|
|
398
400
|
if (u)
|
|
399
401
|
oe(d, u), u.update(g);
|
|
400
402
|
else {
|
|
401
|
-
const p =
|
|
403
|
+
const p = _e(
|
|
402
404
|
r,
|
|
403
405
|
e,
|
|
404
406
|
l.width,
|
|
@@ -413,13 +415,13 @@ function qe(s, e, t, i, o = "") {
|
|
|
413
415
|
});
|
|
414
416
|
});
|
|
415
417
|
}
|
|
416
|
-
function
|
|
417
|
-
const o = new
|
|
418
|
+
function _e(s, e, t, i) {
|
|
419
|
+
const o = new Se(
|
|
418
420
|
s,
|
|
419
421
|
{ width: t, height: i },
|
|
420
422
|
e,
|
|
421
423
|
y.shouldMipMap(),
|
|
422
|
-
|
|
424
|
+
Fe.TRILINEAR_SAMPLINGMODE,
|
|
423
425
|
me.TEXTUREFORMAT_RGBA
|
|
424
426
|
), a = o.getContext();
|
|
425
427
|
return a && (a.fillStyle = "#f5f5f5", a.fillRect(0, 0, t, i), o.update()), o;
|
|
@@ -433,15 +435,15 @@ function oe(s, e) {
|
|
|
433
435
|
i && (e.wrapU = i.wrapU, e.wrapV = i.wrapV), t.diffuseTexture = e;
|
|
434
436
|
}
|
|
435
437
|
}
|
|
436
|
-
function
|
|
438
|
+
function Ke() {
|
|
437
439
|
const s = () => Math.floor((1 + Math.random()) * 65536).toString(16).substring(1);
|
|
438
440
|
return s() + s() + "-" + s() + "-" + s() + "-" + s() + "-" + s() + s() + s();
|
|
439
441
|
}
|
|
440
|
-
const
|
|
442
|
+
const x = 60, le = 1;
|
|
441
443
|
function he(s) {
|
|
442
444
|
return s.targetedAnimations.map((t) => t.animation.framePerSecond).reduce((t, i) => t + i, 0) / s.targetedAnimations.length || 0;
|
|
443
445
|
}
|
|
444
|
-
function
|
|
446
|
+
function Ue(s, e, t, i, o) {
|
|
445
447
|
const a = o ? s.filter((n) => n.name === o) : s;
|
|
446
448
|
if (a.length === 0) {
|
|
447
449
|
console.warn(`No animations found for name: ${o}`);
|
|
@@ -466,15 +468,15 @@ function fe(s) {
|
|
|
466
468
|
e.stop();
|
|
467
469
|
});
|
|
468
470
|
}
|
|
469
|
-
function
|
|
471
|
+
function We(s) {
|
|
470
472
|
const e = s.animationGroups;
|
|
471
473
|
fe(e);
|
|
472
474
|
}
|
|
473
|
-
function
|
|
474
|
-
s.stopAnimation(e), e.animations = [], Math.abs(e.alpha) > 2 * Math.PI && (e.alpha =
|
|
475
|
+
function Qe(s, e, t) {
|
|
476
|
+
s.stopAnimation(e), e.animations = [], Math.abs(e.alpha) > 2 * Math.PI && (e.alpha = Ze(e.alpha, 0, 2 * Math.PI));
|
|
475
477
|
const i = [], o = t.target, a = 0, n = o ? 1 : 0;
|
|
476
478
|
if (t.target && Object.keys(t.target).length > 0 && i.push(
|
|
477
|
-
|
|
479
|
+
R(
|
|
478
480
|
"cameraTargetLerp",
|
|
479
481
|
"target",
|
|
480
482
|
new m().copyFrom(e.target),
|
|
@@ -483,36 +485,36 @@ function Ze(s, e, t) {
|
|
|
483
485
|
t.target.y,
|
|
484
486
|
t.target.z
|
|
485
487
|
),
|
|
486
|
-
|
|
488
|
+
w.ANIMATIONTYPE_VECTOR3,
|
|
487
489
|
a
|
|
488
490
|
)
|
|
489
491
|
), i.push(
|
|
490
|
-
|
|
492
|
+
R(
|
|
491
493
|
"cameraAlphaLerp",
|
|
492
494
|
"alpha",
|
|
493
495
|
e.alpha,
|
|
494
496
|
ce(t.lonDeg),
|
|
495
|
-
|
|
497
|
+
w.ANIMATIONTYPE_FLOAT,
|
|
496
498
|
n
|
|
497
499
|
)
|
|
498
500
|
), i.push(
|
|
499
|
-
|
|
501
|
+
R(
|
|
500
502
|
"cameraBetaLerp",
|
|
501
503
|
"beta",
|
|
502
504
|
e.beta,
|
|
503
505
|
ce(t.latDeg),
|
|
504
|
-
|
|
506
|
+
w.ANIMATIONTYPE_FLOAT,
|
|
505
507
|
n
|
|
506
508
|
)
|
|
507
509
|
), t.radius !== void 0) {
|
|
508
510
|
const c = Math.max(0.01, t.radius);
|
|
509
511
|
i.push(
|
|
510
|
-
|
|
512
|
+
R(
|
|
511
513
|
"cameraRadiusLerp",
|
|
512
514
|
"radius",
|
|
513
515
|
e.radius,
|
|
514
516
|
c,
|
|
515
|
-
|
|
517
|
+
w.ANIMATIONTYPE_FLOAT,
|
|
516
518
|
n
|
|
517
519
|
)
|
|
518
520
|
);
|
|
@@ -522,7 +524,7 @@ function Ze(s, e, t) {
|
|
|
522
524
|
e.disableAutoRotationBehavior(), s.beginAnimation(
|
|
523
525
|
e,
|
|
524
526
|
0,
|
|
525
|
-
o ?
|
|
527
|
+
o ? x * 2 : x,
|
|
526
528
|
!1,
|
|
527
529
|
1,
|
|
528
530
|
() => {
|
|
@@ -533,25 +535,25 @@ function Ze(s, e, t) {
|
|
|
533
535
|
function ce(s) {
|
|
534
536
|
return s * Math.PI / 180;
|
|
535
537
|
}
|
|
536
|
-
function
|
|
537
|
-
const r = new
|
|
538
|
-
r.setEasingMode(
|
|
539
|
-
const l = new
|
|
538
|
+
function R(s, e, t, i, o, a = 0, n = w.ANIMATIONLOOPMODE_CONSTANT) {
|
|
539
|
+
const r = new Be();
|
|
540
|
+
r.setEasingMode(De.EASINGMODE_EASEINOUT);
|
|
541
|
+
const l = new w(
|
|
540
542
|
s,
|
|
541
543
|
e,
|
|
542
|
-
|
|
544
|
+
x,
|
|
543
545
|
o,
|
|
544
546
|
n
|
|
545
547
|
), c = [];
|
|
546
|
-
return a > 0 && c.push({ frame: 0, value: t }), c.push({ frame:
|
|
547
|
-
frame:
|
|
548
|
+
return a > 0 && c.push({ frame: 0, value: t }), c.push({ frame: x * a, value: t }), c.push({
|
|
549
|
+
frame: x * (a + 1),
|
|
548
550
|
value: i
|
|
549
551
|
}), l.setKeys(c), l.setEasingFunction(r), l;
|
|
550
552
|
}
|
|
551
|
-
function
|
|
553
|
+
function Ze(s, e, t) {
|
|
552
554
|
return s < e ? s = t - (e - s) % (t - e) : s = e + (s - e) % (t - e);
|
|
553
555
|
}
|
|
554
|
-
const
|
|
556
|
+
const $e = {
|
|
555
557
|
albedoTexture: "albedoMap",
|
|
556
558
|
bumpTexture: "normalMap",
|
|
557
559
|
ambientTexture: "ambientMap",
|
|
@@ -560,7 +562,7 @@ const Ye = {
|
|
|
560
562
|
metallicTexture: "metallicMap",
|
|
561
563
|
refractionTexture: "refractionMap"
|
|
562
564
|
};
|
|
563
|
-
function
|
|
565
|
+
function Ye(s, e, t, i) {
|
|
564
566
|
[
|
|
565
567
|
"albedoTexture",
|
|
566
568
|
"bumpTexture",
|
|
@@ -570,36 +572,36 @@ function je(s, e, t, i) {
|
|
|
570
572
|
"metallicTexture",
|
|
571
573
|
"refractionTexture"
|
|
572
574
|
].forEach((a) => {
|
|
573
|
-
|
|
575
|
+
je(
|
|
574
576
|
a,
|
|
575
577
|
s,
|
|
576
578
|
e,
|
|
577
579
|
t,
|
|
578
580
|
i
|
|
579
581
|
);
|
|
580
|
-
}),
|
|
582
|
+
}), et(s, e);
|
|
581
583
|
}
|
|
582
|
-
function
|
|
583
|
-
const a =
|
|
584
|
+
function je(s, e, t, i, o) {
|
|
585
|
+
const a = $e[s];
|
|
584
586
|
if (!a)
|
|
585
587
|
throw new Error("Unexpected texture name encountered.");
|
|
586
588
|
const n = e[a], r = n == null ? void 0 : n.fileLink;
|
|
587
|
-
r ? i.addTextureTask(s, r, !1, !1) : o && t[s] && (t[s] && t[s].dispose(), t[s] = null,
|
|
589
|
+
r ? i.addTextureTask(s, r, !1, !1) : o && t[s] && (t[s] && t[s].dispose(), t[s] = null, Xe(s, t));
|
|
588
590
|
}
|
|
589
|
-
function
|
|
590
|
-
s === "opacityTexture" && (e.useAlphaFromAlbedoTexture = !0), s === "metallicTexture" && (e.useRoughnessFromMetallicTextureAlpha = !1, e.useRoughnessFromMetallicTextureGreen = !1, e.useMetallnessFromMetallicTextureBlue = !1), s === "refractionTexture" && (e.subSurface.isRefractionEnabled = !1, e.subSurface.refractionIntensity = 1), s === "emissiveTexture" && (e.emissiveIntensity = 0, e.emissiveColor = new
|
|
591
|
+
function Xe(s, e) {
|
|
592
|
+
s === "opacityTexture" && (e.useAlphaFromAlbedoTexture = !0), s === "metallicTexture" && (e.useRoughnessFromMetallicTextureAlpha = !1, e.useRoughnessFromMetallicTextureGreen = !1, e.useMetallnessFromMetallicTextureBlue = !1), s === "refractionTexture" && (e.subSurface.isRefractionEnabled = !1, e.subSurface.refractionIntensity = 1), s === "emissiveTexture" && (e.emissiveIntensity = 0, e.emissiveColor = new v(0, 0, 0));
|
|
591
593
|
}
|
|
592
|
-
function
|
|
594
|
+
function Je(s, e, t, i) {
|
|
593
595
|
if (!e) {
|
|
594
596
|
console.error("Failed to apply texture to material: material is null.");
|
|
595
597
|
return;
|
|
596
598
|
}
|
|
597
|
-
s === "opacityTexture" && (e.useAlphaFromAlbedoTexture = !1), s === "metallicTexture" && (e.useRoughnessFromMetallicTextureAlpha = !1, e.useRoughnessFromMetallicTextureGreen = !0, e.useMetallnessFromMetallicTextureBlue = !0), s === "refractionTexture" && (e.subSurface.isRefractionEnabled = !0, e.subSurface.refractionIntensity = t.refractionIntensity || 1), e[s] = i, s === "emissiveTexture" && (e.emissiveColor = new
|
|
599
|
+
s === "opacityTexture" && (e.useAlphaFromAlbedoTexture = !1), s === "metallicTexture" && (e.useRoughnessFromMetallicTextureAlpha = !1, e.useRoughnessFromMetallicTextureGreen = !0, e.useMetallnessFromMetallicTextureBlue = !0), s === "refractionTexture" && (e.subSurface.isRefractionEnabled = !0, e.subSurface.refractionIntensity = t.refractionIntensity || 1), e[s] = i, s === "emissiveTexture" && (e.emissiveColor = new v(1, 1, 1), e.emissiveIntensity = 1);
|
|
598
600
|
}
|
|
599
|
-
function
|
|
601
|
+
function et(s, e) {
|
|
600
602
|
s.clearCoat && (s.clearCoat === S.RemoveWhenSelected ? (e.clearCoat.isEnabled = !1, e.clearCoat.indexOfRefraction = 1.5) : s.clearCoat === S.ApplyWhenSelected && (e.clearCoat.isEnabled = !0, e.clearCoat.indexOfRefraction = s.clearCoatIOR || e.clearCoat.indexOfRefraction));
|
|
601
603
|
}
|
|
602
|
-
class
|
|
604
|
+
class tt {
|
|
603
605
|
constructor(e, t, i) {
|
|
604
606
|
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;
|
|
605
607
|
}
|
|
@@ -626,9 +628,9 @@ class it {
|
|
|
626
628
|
a();
|
|
627
629
|
return;
|
|
628
630
|
}
|
|
629
|
-
const c = new
|
|
631
|
+
const c = new ze(this.scene);
|
|
630
632
|
c.useDefaultLoadingScreen = !1, l.forEach(
|
|
631
|
-
(d) =>
|
|
633
|
+
(d) => Ye(
|
|
632
634
|
t,
|
|
633
635
|
d,
|
|
634
636
|
c,
|
|
@@ -642,7 +644,7 @@ class it {
|
|
|
642
644
|
i && i(100, 100, u.name), this.scene.materials.filter(
|
|
643
645
|
(b) => b.name === r
|
|
644
646
|
).forEach(
|
|
645
|
-
(b) =>
|
|
647
|
+
(b) => Je(
|
|
646
648
|
u.name,
|
|
647
649
|
b,
|
|
648
650
|
t,
|
|
@@ -713,7 +715,7 @@ function de(s, e = "") {
|
|
|
713
715
|
from: t.from
|
|
714
716
|
}));
|
|
715
717
|
}
|
|
716
|
-
class
|
|
718
|
+
class it {
|
|
717
719
|
constructor(e) {
|
|
718
720
|
this.metadata = /* @__PURE__ */ new Map(), this.materialSelectedObservable = new C(), this.materialDeselectedObservable = new C(), this.materialVariantObservable = new C(), this.modelVariantObservable = new C(), 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 = [];
|
|
719
721
|
const {
|
|
@@ -723,16 +725,22 @@ class st {
|
|
|
723
725
|
progressHandler: a,
|
|
724
726
|
scene: n
|
|
725
727
|
} = e;
|
|
726
|
-
this.enablePicking = t, this.contextService = i.contextService, this.id =
|
|
728
|
+
this.enablePicking = t, this.contextService = i.contextService, this.id = Ke(), this.previewService = o, this.scene = n, this.variantManager = new tt(
|
|
727
729
|
n,
|
|
728
730
|
this.renameClonedAsset.bind(this),
|
|
729
731
|
this.setBaseModelEnabled.bind(this)
|
|
730
732
|
), this.transformRoot = new Ie("root", this.scene);
|
|
731
|
-
const r = async () =>
|
|
732
|
-
i.model
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
733
|
+
const r = async () => {
|
|
734
|
+
if (!i.model)
|
|
735
|
+
throw new Error(
|
|
736
|
+
"Model container constructed with no URL. This is currently unsupported."
|
|
737
|
+
);
|
|
738
|
+
return this.assetContainer = await pe(
|
|
739
|
+
i.model,
|
|
740
|
+
n,
|
|
741
|
+
a
|
|
742
|
+
), this.initialized = !0, await this.instantiate(), this;
|
|
743
|
+
};
|
|
736
744
|
this.importPromise = r();
|
|
737
745
|
}
|
|
738
746
|
//#region Interface implementation
|
|
@@ -797,9 +805,15 @@ class st {
|
|
|
797
805
|
}
|
|
798
806
|
return;
|
|
799
807
|
}
|
|
800
|
-
this.materialChangesInProgress.push(e), await a(), this.queuedMaterialChanges.has(e)
|
|
801
|
-
|
|
802
|
-
|
|
808
|
+
if (this.materialChangesInProgress.push(e), await a(), this.queuedMaterialChanges.has(e)) {
|
|
809
|
+
const n = this.queuedMaterialChanges.get(e);
|
|
810
|
+
if (!n)
|
|
811
|
+
throw new Error("Target material is undefined");
|
|
812
|
+
n.forEach(async (r) => {
|
|
813
|
+
await r();
|
|
814
|
+
}), this.queuedMaterialChanges.delete(e);
|
|
815
|
+
}
|
|
816
|
+
this.materialChangesInProgress.splice(
|
|
803
817
|
this.materialChangesInProgress.indexOf(e),
|
|
804
818
|
1
|
|
805
819
|
), this.configureGlowLayer();
|
|
@@ -835,7 +849,13 @@ class st {
|
|
|
835
849
|
const n = await (async () => {
|
|
836
850
|
this.modelChangesInProgress.push(e);
|
|
837
851
|
let r = await o();
|
|
838
|
-
|
|
852
|
+
if (this.queuedModelChanges.has(e)) {
|
|
853
|
+
const l = this.queuedModelChanges.get(e);
|
|
854
|
+
if (!l)
|
|
855
|
+
throw new Error("Queued change resolved undefined");
|
|
856
|
+
r = await l(), this.queuedModelChanges.delete(e);
|
|
857
|
+
}
|
|
858
|
+
return this.modelChangesInProgress.splice(
|
|
839
859
|
this.modelChangesInProgress.indexOf(e),
|
|
840
860
|
1
|
|
841
861
|
), r;
|
|
@@ -847,11 +867,11 @@ class st {
|
|
|
847
867
|
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);
|
|
848
868
|
}
|
|
849
869
|
executeAnimation(e) {
|
|
850
|
-
if (!this.previewService.
|
|
870
|
+
if (!this.previewService.getInitializationComplete()) {
|
|
851
871
|
this.queuedModelAnimation = e;
|
|
852
872
|
return;
|
|
853
873
|
}
|
|
854
|
-
this.modelInstance &&
|
|
874
|
+
this.modelInstance && Ue(
|
|
855
875
|
[
|
|
856
876
|
...this.modelInstance.animationGroups,
|
|
857
877
|
...this.variantManager.getAnimationGroups()
|
|
@@ -897,25 +917,38 @@ class st {
|
|
|
897
917
|
this.materialDeselectedObservable.removeCallback(e);
|
|
898
918
|
}
|
|
899
919
|
get position() {
|
|
920
|
+
if (!this.transformRoot)
|
|
921
|
+
throw new Error("ModelContainer disposed prior to requesting position!");
|
|
900
922
|
return this.transformRoot.position;
|
|
901
923
|
}
|
|
902
924
|
set position(e) {
|
|
925
|
+
if (!this.transformRoot)
|
|
926
|
+
throw new Error("ModelContainer disposed prior to setting position!");
|
|
903
927
|
this.transformRoot.position = new m(e.x, e.y, e.z);
|
|
904
928
|
}
|
|
905
929
|
get rotation() {
|
|
930
|
+
var e;
|
|
931
|
+
if (!((e = this.transformRoot) != null && e.rotationQuaternion))
|
|
932
|
+
throw new Error("ModelContainer disposed prior to requesting rotation!");
|
|
906
933
|
return this.transformRoot.rotationQuaternion.toEulerAngles();
|
|
907
934
|
}
|
|
908
935
|
set rotation(e) {
|
|
909
|
-
this.transformRoot
|
|
936
|
+
if (!this.transformRoot)
|
|
937
|
+
throw new Error("ModelContainer disposed prior to setting rotation!");
|
|
938
|
+
this.transformRoot.rotationQuaternion = M.FromEulerAngles(
|
|
910
939
|
e.x,
|
|
911
940
|
e.y,
|
|
912
941
|
e.z
|
|
913
942
|
);
|
|
914
943
|
}
|
|
915
944
|
get scale() {
|
|
945
|
+
if (!this.transformRoot)
|
|
946
|
+
throw new Error("ModelContainer disposed prior to requesting scale!");
|
|
916
947
|
return this.transformRoot.scaling;
|
|
917
948
|
}
|
|
918
949
|
set scale(e) {
|
|
950
|
+
if (!this.transformRoot)
|
|
951
|
+
throw new Error("ModelContainer disposed prior to setting scale!");
|
|
919
952
|
this.transformRoot.scaling = new m(e.x, e.y, e.z);
|
|
920
953
|
}
|
|
921
954
|
//#endregion
|
|
@@ -923,15 +956,15 @@ class st {
|
|
|
923
956
|
attachPickingHandler(e) {
|
|
924
957
|
e.rootNodes.forEach((t) => {
|
|
925
958
|
t.getChildMeshes(!1).forEach((i) => {
|
|
926
|
-
i.name === "targetcube_t" || i.name === "backgroundShell" || (i.actionManager || (i.actionManager = new
|
|
927
|
-
new ne(
|
|
959
|
+
i.name === "targetcube_t" || i.name === "backgroundShell" || (i.actionManager || (i.actionManager = new E(this.scene)), i.actionManager.registerAction(
|
|
960
|
+
new ne(E.OnPointerOverTrigger, (o) => {
|
|
928
961
|
o.meshUnderPointer && i.material && this.materialSelectedObservable.notifyObservers({
|
|
929
962
|
id: i.material.id,
|
|
930
963
|
name: this.stripIdFromName(i.material.name)
|
|
931
964
|
});
|
|
932
965
|
})
|
|
933
966
|
), i.actionManager.registerAction(
|
|
934
|
-
new ne(
|
|
967
|
+
new ne(E.OnPointerOutTrigger, () => {
|
|
935
968
|
i.material && this.materialDeselectedObservable.notifyObservers({
|
|
936
969
|
id: i.material.id,
|
|
937
970
|
name: this.stripIdFromName(i.material.name)
|
|
@@ -965,10 +998,15 @@ class st {
|
|
|
965
998
|
}
|
|
966
999
|
configureModelInstance(e) {
|
|
967
1000
|
var a;
|
|
1001
|
+
if (!this.transformRoot)
|
|
1002
|
+
throw new Error(
|
|
1003
|
+
"Transform disposed! This should never happen unless there is a race condition present!"
|
|
1004
|
+
);
|
|
968
1005
|
const t = this.transformRoot.position, i = this.transformRoot.rotationQuaternion, o = this.transformRoot.scaling;
|
|
969
|
-
this.transformRoot.position = m.Zero(), this.transformRoot.rotationQuaternion =
|
|
1006
|
+
this.transformRoot.position = m.Zero(), this.transformRoot.rotationQuaternion = M.Identity(), this.transformRoot.scaling = m.One();
|
|
1007
|
+
for (const n of e.rootNodes)
|
|
970
1008
|
n.parent = this.transformRoot;
|
|
971
|
-
|
|
1009
|
+
this.transformRoot.position = t, this.transformRoot.rotationQuaternion = i, this.transformRoot.scaling = o, this.canvasPanels = ((a = this.contextService) == null ? void 0 : a.getAll()) || /* @__PURE__ */ new Map(), He(
|
|
972
1010
|
this.materials.concat(this.variantManager.getAllMaterials()),
|
|
973
1011
|
this.scene,
|
|
974
1012
|
this.canvasPanels,
|
|
@@ -990,6 +1028,10 @@ class st {
|
|
|
990
1028
|
).flat();
|
|
991
1029
|
}
|
|
992
1030
|
async instantiate() {
|
|
1031
|
+
if (!this.assetContainer)
|
|
1032
|
+
throw new Error(
|
|
1033
|
+
"Attempted to instantiate ModelContainer without an AssetContainer"
|
|
1034
|
+
);
|
|
993
1035
|
this.modelInstance = this.assetContainer.instantiateModelsToScene(
|
|
994
1036
|
this.renameClonedAsset.bind(this),
|
|
995
1037
|
!0
|
|
@@ -1032,7 +1074,7 @@ class st {
|
|
|
1032
1074
|
}
|
|
1033
1075
|
async processQueuedEvents() {
|
|
1034
1076
|
await Promise.all(
|
|
1035
|
-
Array.from(this.materialReadyToLoadCallbacks.values()).
|
|
1077
|
+
Array.from(this.materialReadyToLoadCallbacks.values()).flatMap(
|
|
1036
1078
|
(e) => Array.from(e.values()).map((t) => t())
|
|
1037
1079
|
)
|
|
1038
1080
|
), this.materialReadyToLoadCallbacks.clear(), await Promise.all(
|
|
@@ -1080,7 +1122,7 @@ class B extends ue {
|
|
|
1080
1122
|
this.useFramingBehavior = !0;
|
|
1081
1123
|
const e = this.getFramingBehavior();
|
|
1082
1124
|
e.attach(this), e.framingTime = 0, e.elevationReturnTime = -1, e.zoomStopsAnimation = !1, this.lowerRadiusLimit = null;
|
|
1083
|
-
const t =
|
|
1125
|
+
const t = T(this._scene);
|
|
1084
1126
|
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;
|
|
1085
1127
|
}
|
|
1086
1128
|
/**
|
|
@@ -1093,7 +1135,7 @@ class B extends ue {
|
|
|
1093
1135
|
i.framingTime = t || 800;
|
|
1094
1136
|
const o = () => {
|
|
1095
1137
|
e && e();
|
|
1096
|
-
}, a =
|
|
1138
|
+
}, a = T(this._scene), n = a.max.subtract(a.min), r = a.min.add(n.scale(0.5));
|
|
1097
1139
|
this.setRadius(n.length() * 1.5), this.wheelPrecision = 100 / this.radius, this.panningInertia = 0, this.panningOriginTarget.copyFrom(r), this.panDenominator = n.length(), i.zoomOnBoundingInfo(
|
|
1098
1140
|
a.min,
|
|
1099
1141
|
a.max,
|
|
@@ -1128,7 +1170,7 @@ class B extends ue {
|
|
|
1128
1170
|
* @param assignActive If true the camera will be assigned as the active camera on the scene.
|
|
1129
1171
|
*/
|
|
1130
1172
|
static create(e, t, i) {
|
|
1131
|
-
const o =
|
|
1173
|
+
const o = T(e), a = o.max.subtract(o.min), n = o.min.add(a.scale(0.5)), r = new B(
|
|
1132
1174
|
"ProductCamera",
|
|
1133
1175
|
-(Math.PI / 2),
|
|
1134
1176
|
Math.PI / 2,
|
|
@@ -1142,7 +1184,7 @@ class B extends ue {
|
|
|
1142
1184
|
}), i && (e.activeCamera = r), r;
|
|
1143
1185
|
}
|
|
1144
1186
|
}
|
|
1145
|
-
function
|
|
1187
|
+
function T(s) {
|
|
1146
1188
|
if (s.meshes.length === 0)
|
|
1147
1189
|
return {
|
|
1148
1190
|
min: new m(-1, -1, -1),
|
|
@@ -1151,7 +1193,7 @@ function O(s) {
|
|
|
1151
1193
|
const e = s.meshes.filter((t) => t.name.toLowerCase().endsWith("_t") || t.name.toLowerCase().includes("_t_"));
|
|
1152
1194
|
return s.getWorldExtends((t) => t.isVisible && t.isEnabled() && (e.length === 0 || e.includes(t)));
|
|
1153
1195
|
}
|
|
1154
|
-
class
|
|
1196
|
+
class st {
|
|
1155
1197
|
constructor(e, t = !1, i = void 0) {
|
|
1156
1198
|
this.renderingPipeline = new Ne(
|
|
1157
1199
|
"default",
|
|
@@ -1169,7 +1211,7 @@ class nt {
|
|
|
1169
1211
|
return this.currentConfiguration;
|
|
1170
1212
|
}
|
|
1171
1213
|
setConfiguration(e) {
|
|
1172
|
-
var t, i, o, a, n, r, l, c, d, u, g, p, b, D, z,
|
|
1214
|
+
var t, i, o, a, n, r, l, c, d, u, g, p, b, D, z, N, k, V, G, q, H, _, K, U, W, Q, Z, $, Y, j, X, J, ee;
|
|
1173
1215
|
if (this.renderingPipeline.isSupported) {
|
|
1174
1216
|
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 = ((o = e.bloom) == null ? void 0 : o.enabled) ?? h.bloom.enabled, this.renderingPipeline.bloomKernel = ((a = e.bloom) == null ? void 0 : a.kernel) ?? h.bloom.kernel, this.renderingPipeline.bloomScale = ((n = e.bloom) == null ? void 0 : n.scale) ?? h.bloom.scale, this.renderingPipeline.bloomThreshold = ((r = e.bloom) == null ? void 0 : r.threshold) ?? h.bloom.threshold, this.renderingPipeline.bloomWeight = ((l = e.bloom) == null ? void 0 : l.weight) ?? h.bloom.weight, this.renderingPipeline.chromaticAberrationEnabled = ((c = e.chromaticAberration) == null ? void 0 : c.enabled) ?? h.chromaticAberration.enabled, this.renderingPipeline.chromaticAberration.aberrationAmount = ((d = e.chromaticAberration) == null ? void 0 : d.aberrationAmount) ?? h.chromaticAberration.aberrationAmount, this.renderingPipeline.chromaticAberration.radialIntensity = ((u = e.chromaticAberration) == null ? void 0 : u.radialIntensity) ?? h.chromaticAberration.radialIntensity, this.renderingPipeline.chromaticAberration.direction = (g = e.chromaticAberration) != null && g.direction ? new te(
|
|
1175
1217
|
e.chromaticAberration.direction.x,
|
|
@@ -1180,16 +1222,16 @@ class nt {
|
|
|
1180
1222
|
), 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 re(), this.renderingPipeline.depthOfFieldEnabled = ((b = e.depthOfField) == null ? void 0 : b.enabled) ?? h.depthOfField.enabled, e.depthOfField)
|
|
1181
1223
|
switch (e.depthOfField.blurLevel ?? h.depthOfField.blurLevel) {
|
|
1182
1224
|
case "Low":
|
|
1183
|
-
this.renderingPipeline.depthOfFieldBlurLevel =
|
|
1225
|
+
this.renderingPipeline.depthOfFieldBlurLevel = A.Low;
|
|
1184
1226
|
break;
|
|
1185
1227
|
case "Medium":
|
|
1186
|
-
this.renderingPipeline.depthOfFieldBlurLevel =
|
|
1228
|
+
this.renderingPipeline.depthOfFieldBlurLevel = A.Medium;
|
|
1187
1229
|
break;
|
|
1188
1230
|
case "High":
|
|
1189
|
-
this.renderingPipeline.depthOfFieldBlurLevel =
|
|
1231
|
+
this.renderingPipeline.depthOfFieldBlurLevel = A.High;
|
|
1190
1232
|
break;
|
|
1191
1233
|
}
|
|
1192
|
-
if (this.renderingPipeline.depthOfField.focalLength = ((D = e.depthOfField) == null ? void 0 : D.focalLength) ?? h.depthOfField.focalLength, this.renderingPipeline.depthOfField.fStop = ((z = e.depthOfField) == null ? void 0 : z.fStop) ?? h.depthOfField.fStop, this.renderingPipeline.depthOfField.focusDistance = ((
|
|
1234
|
+
if (this.renderingPipeline.depthOfField.focalLength = ((D = e.depthOfField) == null ? void 0 : D.focalLength) ?? h.depthOfField.focalLength, this.renderingPipeline.depthOfField.fStop = ((z = e.depthOfField) == null ? void 0 : z.fStop) ?? h.depthOfField.fStop, this.renderingPipeline.depthOfField.focusDistance = ((N = e.depthOfField) == null ? void 0 : N.focusDistance) ?? h.depthOfField.focusDistance, this.renderingPipeline.depthOfField.lensSize = ((k = e.depthOfField) == null ? void 0 : k.lensSize) ?? h.depthOfField.lensSize, this.renderingPipeline.grainEnabled = ((V = e.grain) == null ? void 0 : V.enabled) ?? h.grain.enabled, this.renderingPipeline.grain.animated = ((G = e.grain) == null ? void 0 : G.animated) ?? h.grain.animated, this.renderingPipeline.grain.intensity = ((q = e.grain) == null ? void 0 : q.intensity) ?? h.grain.intensity, this.renderingPipeline.imageProcessing.contrast = ((H = e.misc) == null ? void 0 : H.contrast) ?? h.misc.contrast, this.renderingPipeline.imageProcessing.exposure = ((_ = e.misc) == null ? void 0 : _.exposure) ?? h.misc.exposure, this.renderingPipeline.imageProcessing.toneMappingEnabled = ((K = e.misc) == null ? void 0 : K.toneMappingEnabled) ?? h.misc.toneMappingEnabled, this.renderingPipeline.imageProcessing.toneMappingEnabled)
|
|
1193
1235
|
switch (e.misc.toneMappingType ?? h.misc.toneMappingType) {
|
|
1194
1236
|
case "Standard":
|
|
1195
1237
|
this.renderingPipeline.imageProcessing.toneMappingType = P.TONEMAPPING_STANDARD;
|
|
@@ -1226,7 +1268,7 @@ class nt {
|
|
|
1226
1268
|
}
|
|
1227
1269
|
}
|
|
1228
1270
|
Pe.GLTFLoader.RegisterExtension("glbPostProcessor", function(s) {
|
|
1229
|
-
return new
|
|
1271
|
+
return new Ge(s);
|
|
1230
1272
|
});
|
|
1231
1273
|
ge.OnPluginActivatedObservable.add((s) => {
|
|
1232
1274
|
if (s.name === "gltf") {
|
|
@@ -1234,28 +1276,32 @@ ge.OnPluginActivatedObservable.add((s) => {
|
|
|
1234
1276
|
e.transparencyAsCoverage = !0;
|
|
1235
1277
|
}
|
|
1236
1278
|
});
|
|
1237
|
-
function
|
|
1279
|
+
function O(s) {
|
|
1238
1280
|
return new m(s.x, s.y, s.z);
|
|
1239
1281
|
}
|
|
1240
1282
|
function L(s) {
|
|
1241
1283
|
return { x: s.x, y: s.y, z: s.z };
|
|
1242
1284
|
}
|
|
1243
|
-
class
|
|
1285
|
+
class Ut {
|
|
1244
1286
|
constructor(e) {
|
|
1245
1287
|
var r;
|
|
1246
|
-
this.focusLostNotified = !1, this.focusLostObservable = new C(), this.
|
|
1288
|
+
this.focusLostNotified = !1, this.focusLostObservable = new C(), this.modelLoadEventCallbacks = [], this.modelContainers = /* @__PURE__ */ new Map(), this.plugins = [], this.initComplete = !1, this.renderLoop = () => {
|
|
1247
1289
|
this.engine.views && (this.modelContainers.forEach((l) => {
|
|
1248
1290
|
l.updateDynamicTextures();
|
|
1249
1291
|
}), this.configuration.scene.transparentBackground && this.engine.views.forEach((l) => {
|
|
1250
|
-
const c = this.engine.getRenderingCanvas();
|
|
1251
|
-
|
|
1292
|
+
const c = this.engine.getRenderingCanvas(), d = l.target.getContext("2d");
|
|
1293
|
+
if (!c)
|
|
1294
|
+
throw new Error("Could not access rendering canvas");
|
|
1295
|
+
if (!d)
|
|
1296
|
+
throw new Error("Could not access 2D context for view target");
|
|
1297
|
+
d.clearRect(0, 0, c.width, c.height);
|
|
1252
1298
|
}), this.scene.render(), !this.camera.target.equalsWithEpsilon(this.camera.lastFocus, 0.1) && !this.focusLostNotified && (this.focusLostObservable.notifyObservers(void 0), this.focusLostNotified = !0), this.screenshotPrepareResolve && (this.screenshotPrepareResolve(), this.screenshotPrepareResolve = void 0));
|
|
1253
|
-
}, this.configuration = new
|
|
1299
|
+
}, this.configuration = new ke(e);
|
|
1254
1300
|
const i = (() => {
|
|
1255
1301
|
if (!(e != null && e.noRender))
|
|
1256
1302
|
return this.configuration.createCanvas();
|
|
1257
1303
|
})(), o = "1.5.6";
|
|
1258
|
-
|
|
1304
|
+
Me.Configuration = {
|
|
1259
1305
|
decoder: {
|
|
1260
1306
|
wasmUrl: `https://www.gstatic.com/draco/versioned/decoders/${o}/draco_wasm_wrapper_gltf.js`,
|
|
1261
1307
|
wasmBinaryUrl: `https://www.gstatic.com/draco/versioned/decoders/${o}/draco_decoder_gltf.wasm`,
|
|
@@ -1273,8 +1319,8 @@ class Qt {
|
|
|
1273
1319
|
audioEngine: !1,
|
|
1274
1320
|
stencil: this.configuration.highlights.enabled,
|
|
1275
1321
|
forceSRGBBufferSupportState: !0
|
|
1276
|
-
}) : new
|
|
1277
|
-
console.log = a, n.hideLoadingUI(), window.addEventListener("resize", this.fireResizeEvent.bind(this)), this.engine = n, this.scene = new ye(n), this.camera = B.create(this.scene, this.configuration), this.scene.activeCamera = this.camera, this.renderingPipeline = new
|
|
1322
|
+
}) : new we();
|
|
1323
|
+
console.log = a, n.hideLoadingUI(), window.addEventListener("resize", this.fireResizeEvent.bind(this)), this.engine = n, this.scene = new ye(n), this.camera = B.create(this.scene, this.configuration), this.scene.activeCamera = this.camera, this.renderingPipeline = new st(
|
|
1278
1324
|
this.scene,
|
|
1279
1325
|
!1,
|
|
1280
1326
|
this.camera
|
|
@@ -1283,13 +1329,21 @@ class Qt {
|
|
|
1283
1329
|
this.scene
|
|
1284
1330
|
), (r = this.configuration.options) != null && r.renderingPipelineConfiguration && this.renderingPipeline.setConfiguration(
|
|
1285
1331
|
this.configuration.options.renderingPipelineConfiguration
|
|
1286
|
-
), this.scene.imageProcessingConfiguration.exposure = this.configuration.lighting.exposure, this.scene.imageProcessingConfiguration.contrast = this.configuration.lighting.contrast, this.glowLayerManager = new
|
|
1332
|
+
), this.scene.imageProcessingConfiguration.exposure = this.configuration.lighting.exposure, this.scene.imageProcessingConfiguration.contrast = this.configuration.lighting.contrast, this.glowLayerManager = new qe(
|
|
1287
1333
|
this.scene,
|
|
1288
1334
|
this.configuration.emissiveGlowIntensity
|
|
1289
|
-
), this.
|
|
1290
|
-
this.
|
|
1335
|
+
), this.initPromise = new Promise((l) => {
|
|
1336
|
+
this.scene.onReadyObservable.addOnce(() => {
|
|
1337
|
+
this.initComplete = !0, l();
|
|
1338
|
+
});
|
|
1291
1339
|
}), this.engine.runRenderLoop(this.renderLoop);
|
|
1292
1340
|
}
|
|
1341
|
+
getInitializationPromise() {
|
|
1342
|
+
return this.initPromise;
|
|
1343
|
+
}
|
|
1344
|
+
getInitializationComplete() {
|
|
1345
|
+
return this.initComplete;
|
|
1346
|
+
}
|
|
1293
1347
|
getEngineContext() {
|
|
1294
1348
|
return {
|
|
1295
1349
|
engine: this.engine,
|
|
@@ -1303,18 +1357,6 @@ class Qt {
|
|
|
1303
1357
|
unregisterFocusLostListener(e) {
|
|
1304
1358
|
this.focusLostObservable.removeCallback(e);
|
|
1305
1359
|
}
|
|
1306
|
-
registerInitializedListener(e) {
|
|
1307
|
-
this.isInitialized || !this.isInitialized && this.initializedCallbacks.push(e);
|
|
1308
|
-
}
|
|
1309
|
-
unregisterInitializedListener(e) {
|
|
1310
|
-
if (this.isInitialized)
|
|
1311
|
-
return;
|
|
1312
|
-
const t = this.initializedCallbacks.indexOf(e);
|
|
1313
|
-
t > -1 && this.initializedCallbacks.splice(t, 1);
|
|
1314
|
-
}
|
|
1315
|
-
getIsInitialized() {
|
|
1316
|
-
return this.isInitialized;
|
|
1317
|
-
}
|
|
1318
1360
|
registerModelLoadEventListener(e) {
|
|
1319
1361
|
this.modelLoadEventCallbacks.push(e);
|
|
1320
1362
|
}
|
|
@@ -1341,7 +1383,7 @@ class Qt {
|
|
|
1341
1383
|
this.queuedCameraAnimation = e;
|
|
1342
1384
|
return;
|
|
1343
1385
|
}
|
|
1344
|
-
|
|
1386
|
+
Qe(
|
|
1345
1387
|
this.scene,
|
|
1346
1388
|
this.scene.activeCamera,
|
|
1347
1389
|
e
|
|
@@ -1408,7 +1450,7 @@ class Qt {
|
|
|
1408
1450
|
try {
|
|
1409
1451
|
const o = t.latDeg * Math.PI / 180, a = t.lonDeg * Math.PI / 180;
|
|
1410
1452
|
i.target = t.target ? new m(t.target.x, t.target.y, t.target.z) : m.Zero(), i.alpha = a, i.beta = o, i.radius = t.radius || this.camera.radius, i.minZ = 0.01, this.scene.render();
|
|
1411
|
-
const n = await
|
|
1453
|
+
const n = await xe.CreateScreenshotUsingRenderTargetAsync(
|
|
1412
1454
|
this.engine,
|
|
1413
1455
|
i,
|
|
1414
1456
|
e,
|
|
@@ -1436,12 +1478,12 @@ class Qt {
|
|
|
1436
1478
|
}
|
|
1437
1479
|
setHighlights(e, t) {
|
|
1438
1480
|
var o;
|
|
1439
|
-
e.length === 0 && ((o = this.highlightLayer) == null || o.dispose(), this.highlightLayer = void 0), this.highlightLayer || (this.highlightLayer = new
|
|
1481
|
+
e.length === 0 && ((o = this.highlightLayer) == null || o.dispose(), this.highlightLayer = void 0), this.highlightLayer || (this.highlightLayer = new ve("highlights", this.scene, {
|
|
1440
1482
|
isStroke: !0,
|
|
1441
1483
|
blurVerticalSize: 0.85,
|
|
1442
1484
|
blurHorizontalSize: 0.85
|
|
1443
1485
|
}), this.highlightLayer.innerGlow = !0, this.highlightLayer.outerGlow = !1), this.highlightLayer.removeAllMeshes();
|
|
1444
|
-
const i = t ? new
|
|
1486
|
+
const i = t ? new v(t[0], t[1], t[2]).toLinearSpace() : void 0;
|
|
1445
1487
|
e.forEach((a) => {
|
|
1446
1488
|
const n = this.scene.materials.find(
|
|
1447
1489
|
(r) => r.name === a.name && r.id === a.id
|
|
@@ -1451,7 +1493,7 @@ class Qt {
|
|
|
1451
1493
|
var l;
|
|
1452
1494
|
return (l = this.highlightLayer) == null ? void 0 : l.addMesh(
|
|
1453
1495
|
r,
|
|
1454
|
-
i ||
|
|
1496
|
+
i || v.FromHexString("#fcba03")
|
|
1455
1497
|
);
|
|
1456
1498
|
}
|
|
1457
1499
|
);
|
|
@@ -1461,7 +1503,7 @@ class Qt {
|
|
|
1461
1503
|
this.renderingPipeline && this.renderingPipeline.setConfiguration(e);
|
|
1462
1504
|
}
|
|
1463
1505
|
loadModel(e, t) {
|
|
1464
|
-
const i = new
|
|
1506
|
+
const i = new it({
|
|
1465
1507
|
enablePicking: this.configuration.highlights.enabled,
|
|
1466
1508
|
modelDetails: e,
|
|
1467
1509
|
scene: this.scene,
|
|
@@ -1469,7 +1511,7 @@ class Qt {
|
|
|
1469
1511
|
progressHandler: t
|
|
1470
1512
|
});
|
|
1471
1513
|
return i.getInitializationPromise().then(() => {
|
|
1472
|
-
this.modelContainers.size <= 1 && this.camera.rerunFramingBehavior(void 0, 1),
|
|
1514
|
+
this.modelContainers.size <= 1 && this.camera.rerunFramingBehavior(void 0, 1), We(this.scene), this.queuedCameraAnimation && (this.executeCameraAnimation(this.queuedCameraAnimation), this.queuedCameraAnimation = void 0);
|
|
1473
1515
|
}), this.configuration.highlights.enabled && (i.registerMaterialSelectedCallback((o) => {
|
|
1474
1516
|
this.setHighlights([o]);
|
|
1475
1517
|
}), i.registerMaterialDeselectedCallback(() => {
|
|
@@ -1513,13 +1555,13 @@ class Qt {
|
|
|
1513
1555
|
*/
|
|
1514
1556
|
flipTransform(e, t, i) {
|
|
1515
1557
|
const o = ie.Compose(
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1558
|
+
O(i || { x: 1, y: 1, z: 1 }),
|
|
1559
|
+
M.FromEulerVector(
|
|
1560
|
+
O(t || { x: 0, y: 0, z: 0 })
|
|
1519
1561
|
),
|
|
1520
|
-
|
|
1521
|
-
), a = ie.RotationAxis(m.Up(), Math.PI), n = o.multiply(a), r = m.Zero(), l =
|
|
1522
|
-
return n.decompose(c, l, r), l.multiplyInPlace(
|
|
1562
|
+
O(e || { x: 0, y: 0, z: 0 })
|
|
1563
|
+
), a = ie.RotationAxis(m.Up(), Math.PI), n = o.multiply(a), r = m.Zero(), l = M.Identity(), c = m.Zero();
|
|
1564
|
+
return n.decompose(c, l, r), l.multiplyInPlace(M.FromEulerAngles(0, Math.PI, 0)), {
|
|
1523
1565
|
position: L(r),
|
|
1524
1566
|
rotation: L(l.toEulerAngles()),
|
|
1525
1567
|
scale: L(c)
|
|
@@ -1542,8 +1584,8 @@ class Qt {
|
|
|
1542
1584
|
export {
|
|
1543
1585
|
S as MaterialEffectMode,
|
|
1544
1586
|
I as ProductCameraRig,
|
|
1545
|
-
|
|
1587
|
+
Ve as REFLECTION_PROBE_RESOLUTION,
|
|
1546
1588
|
y as RenderingConfiguration,
|
|
1547
|
-
|
|
1589
|
+
Ut as SpiffCommerce3DPreviewService,
|
|
1548
1590
|
h as renderingPipelineDefaults
|
|
1549
1591
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(h,y){typeof exports=="object"&&typeof module<"u"?y(exports,require("@babylonjs/core/Cameras/arcRotateCamera"),require("@babylonjs/core/Engines/engine"),require("@babylonjs/core/Engines/nullEngine"),require("@babylonjs/core/Layers/highlightLayer"),require("@babylonjs/core/Loading/sceneLoader"),require("@babylonjs/core/Materials/Textures/cubeTexture"),require("@babylonjs/core/Maths/math.color"),require("@babylonjs/core/Maths/math.vector"),require("@babylonjs/core/Meshes/Compression/dracoCompression"),require("@babylonjs/core/Misc/observable"),require("@babylonjs/core/Misc/tools"),require("@babylonjs/core/scene"),require("@babylonjs/loaders/glTF"),require("@babylonjs/core/Materials/PBR/pbrMaterial"),require("@babylonjs/core/Materials/Textures/mirrorTexture"),require("@babylonjs/core/Maths/math"),require("@babylonjs/core/Probes/reflectionProbe"),require("@babylonjs/core/Layers/glowLayer"),require("@babylonjs/core/Actions/actionManager"),require("@babylonjs/core/Actions/directActions"),require("@babylonjs/core/Meshes/mesh"),require("@babylonjs/core/Meshes/transformNode"),require("@babylonjs/core"),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","@babylonjs/core/Materials/Textures/dynamicTexture","@babylonjs/core/Materials/Textures/texture","@babylonjs/core/Animations/animation","@babylonjs/core/Animations/easing","@babylonjs/core/Misc/assetsManager","@babylonjs/core/Materials/colorCurves","@babylonjs/core/Materials/imageProcessingConfiguration","@babylonjs/core/PostProcesses/RenderPipeline","@babylonjs/core/PostProcesses/depthOfFieldEffect","@babylonjs/core/Rendering/depthRendererSceneComponent","@babylonjs/core/Engines/Extensions/engine.views","@babylonjs/core/Meshes/instancedMesh","@babylonjs/core/Materials/Textures/Loaders/ddsTextureLoader","@babylonjs/core/Materials/Textures/Loaders/envTextureLoader","@babylonjs/core/Materials/Textures/Loaders/ktxTextureLoader","@babylonjs/core/Animations/animatable","@babylonjs/core/Misc/screenshotTools","@babylonjs/core/Rendering/boundingBoxRenderer","@babylonjs/loaders/glTF/2.0/Extensions"],y):(h=typeof globalThis<"u"?globalThis:h||self,y(h.Preview={},h.arcRotateCamera,h.engine,h.nullEngine,h.highlightLayer,h.sceneLoader,h.cubeTexture,h.math_color,h.math_vector,h.dracoCompression,h.observable,h.tools,h.scene,h.glTF,h.pbrMaterial,h.mirrorTexture,h.math,h.reflectionProbe,h.glowLayer,h.actionManager,h.directActions,h.mesh,h.transformNode,h.core,h.dynamicTexture,h.texture,h.animation,h.easing,h.assetsManager,h.colorCurves,h.imageProcessingConfiguration,h.RenderPipeline,h.depthOfFieldEffect))})(this,function(h,y,D,fe,ye,q,Ce,p,g,ve,M,we,Me,xe,L,Pe,P,Te,Ae,O,V,Re,Ee,Le,Oe,Ie,C,z,Se,k,T,Fe,I){"use strict";var A=(s=>(s[s.Orbit=0]="Orbit",s[s.Pan=1]="Pan",s))(A||{}),R=(s=>(s.None="None",s.RemoveWhenSelected="RemoveWhenSelected",s.ApplyWhenSelected="ApplyWhenSelected",s))(R||{});class Be{constructor(e){this.getSceneClearColor=()=>{var i,o,a,n;const t=(i=this.customOptions)!=null&&i.transparentBackground||(o=this.customOptions)!=null&&o.backgroundImage?0:1;if(this.customOptions&&((a=this.customOptions)!=null&&a.transparentBackground)||(n=this.customOptions)!=null&&n.backgroundImage)return new p.Color4(0,0,0,t).toLinearSpace();if(this.customOptions&&this.customOptions.backgroundColor){const r=p.Color3.FromHexString(this.customOptions.backgroundColor);return new p.Color4(r.r,r.g,r.b,t).toLinearSpace()}return new p.Color4(.98,.98,.98,t).toLinearSpace()},this.highlightColorFromConfig=()=>this.customOptions&&this.customOptions.highlightColor?this.hexToColor4(this.customOptions.highlightColor):new p.Color4(.98,.98,.98,1).toLinearSpace(),this.hexToColor4=(t,i=1)=>{const o=p.Color3.FromHexString(t);return new p.Color4(o.r,o.g,o.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,o,a,n,r,l,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:(o=this.customOptions)!=null&&o.lowerAlphaLimitDeg?((a=this.customOptions)==null?void 0:a.lowerAlphaLimitDeg)*Math.PI/180:void 0,beta:(n=this.customOptions)!=null&&n.lowerBetaLimitDeg?((r=this.customOptions)==null?void 0:r.lowerBetaLimitDeg)*Math.PI/180:void 0,radius:(l=this.customOptions)==null?void 0:l.minZoomOverride},max:{alpha:(d=this.customOptions)!=null&&d.upperAlphaLimitDeg?((u=this.customOptions)==null?void 0:u.upperAlphaLimitDeg)*Math.PI/180:void 0,beta:(m=this.customOptions)!=null&&m.upperBetaLimitDeg?((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,o;return{exposure:((t=(e=this.customOptions)==null?void 0:e.lighting)==null?void 0:t.exposure)??.9,contrast:((o=(i=this.customOptions)==null?void 0:i.lighting)==null?void 0:o.contrast)??1.6}}get emissiveGlowIntensity(){var e;return((e=this.customOptions)==null?void 0:e.emissiveGlowIntensity)??.5}}class v{static getDynamicTextureResolution(){return this.getIsMobile()||!v.offscreenRenderingSupported()?{width:1024,height:1024}:{width:2048,height:2048}}static shouldMipMap(){return!0}static offscreenRenderingSupported(){return navigator.userAgent.includes("SamsungBrowser")?!1:!!window.Worker&&!!window.OffscreenCanvas}static getMirrorTextureResolution(){return this.getIsMobile()?512:1024}static getIsMobile(){try{return typeof window>"u"||!window.navigator?!1:/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(window.navigator.userAgent)||window.innerWidth<=480}catch{return!1}}}const N=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 je{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(o){t.extras&&Object.keys(t.extras).forEach(a=>{const n=t.extras[a];o.metadata[a]=n}),i(o)})}async loadMaterialPropertiesAsync(e,t,i){await this.loader.loadMaterialPropertiesAsync(e,t,i),this.enableMaterialExtrasIfRequired(t,i),i.needDepthPrePass=!0}dispose(){}enableMaterialExtrasIfRequired(e,t){if(!(!e.extras||!(t instanceof L.PBRMaterial))){if(e.extras.sheen){const i=t;i.sheen.isEnabled=!0,i.sheen.intensity=e.extras.sheen}if(e.extras.translucency){const i=t;i.subSurface.isTranslucencyEnabled=!0,i.subSurface.translucencyIntensity=e.extras.translucency,e.extras.translucencyR&&e.extras.translucencyG&&e.extras.translucencyB&&(i.subSurface.tintColor=new P.Color3(e.extras.translucencyR,e.extras.translucencyG,e.extras.translucencyB))}if(e.extras.refractionIOR){const i=t;i.subSurface.isRefractionEnabled=!0,i.subSurface.volumeIndexOfRefraction=e.extras.refractionIOR}if(e.extras.useDepthPrePass){const i=t;i.needDepthPrePass=!0,i.forceIrradianceInFragment=!0}if(e.extras.useParallax){const i=t;i.useParallax=!0,i.useParallaxOcclusion=!0,i.parallaxScaleBias=e.extras.useParallax}}}applyReflections(e){function t(a){const n=[];return a.transformNodes.forEach(r=>{r.metadata&&r.metadata.reflective&&n.push(...r.getChildMeshes())}),a.meshes.forEach(r=>{r.metadata&&r.metadata.reflective&&!n.includes(r)&&n.push(r)}),n}function i(a,n=1){const r=a.material;if(!r)return;const l=new Pe.MirrorTexture("mirror",v.getMirrorTextureResolution(),e,!0);l.renderList=t(e);const d=a.getVerticesData("normal");if(!d)throw new Error("Mirror attribute specified on: "+a.name+"But no normals exist to generate a mirror from!");a.computeWorldMatrix(!0);const u=a.getWorldMatrix(),m=P.Vector3.TransformNormal(new P.Vector3(d[0],d[1],d[2]),u).normalize(),b=P.Plane.FromPositionAndNormal(a.position,m.scale(-1));l.mirrorPlane=b,l.level=n,r.reflectionTexture=l}function o(a){const n=a.material,r=new Te.ReflectionProbe("probe-"+n.name,N,e);r.attachToMesh(a),r.renderList&&r.renderList.push(...t(e)),n.reflectionTexture=r.cubeTexture}e.meshes.forEach(a=>{const n=a.metadata;n&&(n.mirrorTexture&&i(a,n.mirrorTexture),n.reflectionProbe&&o(a))})}}class De{constructor(e,t){this.scene=e,this.intensity=t,this.meshCount=0}includeMeshes(e){e&&(this.glowLayer||(this.glowLayer=new Ae.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||(e.forEach(t=>{this.glowLayer.hasMesh(t)&&(this.glowLayer.removeIncludedOnlyMesh(t),this.meshCount--)}),this.meshCount===0&&(this.glowLayer.dispose(),this.glowLayer=void 0))}}const G=new Map;async function H(s,e,t){return await Le.DracoCompression.DecoderAvailable,new Promise((i,o)=>{const a=G.get(s);if(a&&a.scene.uid===e.uid)return i(a);q.SceneLoader.LoadAssetContainerAsync(s,void 0,e,t).then(n=>{G.set(s,n),i(n)}).catch(o)})}function qe(s,e,t,i,o=""){t.forEach(a=>{const n=a.getID(),r=a.getName(),l=v.getDynamicTextureResolution();s.filter(u=>u.name===o+r).forEach(u=>{const m=i.get(n),b=!1;if(m)K(u,m),m.update(b);else{const f=Ve(r,e,l.width,l.height);i.set(n,f),a.setStaticContext(f.getContext()),K(u,f),f.onLoadObservable.addOnce(()=>{f.update(b)})}})})}function Ve(s,e,t,i){const o=new Oe.DynamicTexture(s,{width:t,height:i},e,v.shouldMipMap(),Ie.Texture.TRILINEAR_SAMPLINGMODE,D.Engine.TEXTUREFORMAT_RGBA),a=o.getContext();return a&&(a.fillStyle="#f5f5f5",a.fillRect(0,0,t,i),o.update()),o}function K(s,e){if(s instanceof L.PBRMaterial){const t=s,i=t.albedoTexture;i?(e.wrapU=i.wrapU,e.wrapV=i.wrapV):(e.wrapU=1,e.wrapV=1),t.albedoTexture=e}else{const t=s,i=t.diffuseTexture;i&&(e.wrapU=i.wrapU,e.wrapV=i.wrapV),t.diffuseTexture=e}}function ze(){const s=()=>Math.floor((1+Math.random())*65536).toString(16).substring(1);return s()+s()+"-"+s()+"-"+s()+"-"+s()+"-"+s()+s()+s()}const x=60,U=1;function W(s){return s.targetedAnimations.map(t=>t.animation.framePerSecond).reduce((t,i)=>t+i,0)/s.targetedAnimations.length||0}function ke(s,e,t,i,o){const a=o?s.filter(n=>n.name===o):s;if(a.length===0){console.warn(`No animations found for name: ${o}`);return}if(i!==void 0&&t!==void 0&&i===t){a.forEach(n=>{n.stop();const r=W(n),l=i*r;n.start(e,U,l,l)});return}a.forEach(n=>{n.stop();const r=W(n),l=i!==void 0?i*r:void 0,d=t!==void 0?t*r:void 0;n.start(e,U,l,d)})}function Q(s){s.forEach(e=>{e.stop()})}function Ne(s){const e=s.animationGroups;Q(e)}function Ge(s,e,t){s.stopAnimation(e),e.animations=[],Math.abs(e.alpha)>2*Math.PI&&(e.alpha=He(e.alpha,0,2*Math.PI));const i=[],o=t.target,a=0,n=o?1:0;if(t.target&&Object.keys(t.target).length>0&&i.push(E("cameraTargetLerp","target",new g.Vector3().copyFrom(e.target),new g.Vector3(t.target.x,t.target.y,t.target.z),C.Animation.ANIMATIONTYPE_VECTOR3,a)),i.push(E("cameraAlphaLerp","alpha",e.alpha,Z(t.lonDeg),C.Animation.ANIMATIONTYPE_FLOAT,n)),i.push(E("cameraBetaLerp","beta",e.beta,Z(t.latDeg),C.Animation.ANIMATIONTYPE_FLOAT,n)),t.radius!==void 0){const d=Math.max(.01,t.radius);i.push(E("cameraRadiusLerp","radius",e.radius,d,C.Animation.ANIMATIONTYPE_FLOAT,n))}e.animations.push(...i);const l=e.useAutoRotationBehavior;e.disableAutoRotationBehavior(),s.beginAnimation(e,0,o?x*2:x,!1,1,()=>{e.animations=[],l&&e.enableAutoRotationBehavior()})}function Z(s){return s*Math.PI/180}function E(s,e,t,i,o,a=0,n=C.Animation.ANIMATIONLOOPMODE_CONSTANT){const r=new z.QuadraticEase;r.setEasingMode(z.EasingFunction.EASINGMODE_EASEINOUT);const l=new C.Animation(s,e,x,o,n),d=[];return a>0&&d.push({frame:0,value:t}),d.push({frame:x*a,value:t}),d.push({frame:x*(a+1),value:i}),l.setKeys(d),l.setEasingFunction(r),l}function He(s,e,t){return s<e?s=t-(e-s)%(t-e):s=e+(s-e)%(t-e)}const Ke={albedoTexture:"albedoMap",bumpTexture:"normalMap",ambientTexture:"ambientMap",emissiveTexture:"emissionMap",opacityTexture:"alphaMap",metallicTexture:"metallicMap",refractionTexture:"refractionMap"};function Ue(s,e,t,i){["albedoTexture","bumpTexture","ambientTexture","emissiveTexture","opacityTexture","metallicTexture","refractionTexture"].forEach(a=>{We(a,s,e,t,i)}),$e(s,e)}function We(s,e,t,i,o){const a=Ke[s];if(!a)throw new Error("Unexpected texture name encountered.");const n=e[a],r=n==null?void 0:n.fileLink;r?i.addTextureTask(s,r,!1,!1):o&&t[s]&&(t[s]&&t[s].dispose(),t[s]=null,Qe(s,t))}function Qe(s,e){s==="opacityTexture"&&(e.useAlphaFromAlbedoTexture=!0),s==="metallicTexture"&&(e.useRoughnessFromMetallicTextureAlpha=!1,e.useRoughnessFromMetallicTextureGreen=!1,e.useMetallnessFromMetallicTextureBlue=!1),s==="refractionTexture"&&(e.subSurface.isRefractionEnabled=!1,e.subSurface.refractionIntensity=1),s==="emissiveTexture"&&(e.emissiveIntensity=0,e.emissiveColor=new p.Color3(0,0,0))}function Ze(s,e,t,i){if(!e){console.error("Failed to apply texture to material: material is null.");return}s==="opacityTexture"&&(e.useAlphaFromAlbedoTexture=!1),s==="metallicTexture"&&(e.useRoughnessFromMetallicTextureAlpha=!1,e.useRoughnessFromMetallicTextureGreen=!0,e.useMetallnessFromMetallicTextureBlue=!0),s==="refractionTexture"&&(e.subSurface.isRefractionEnabled=!0,e.subSurface.refractionIntensity=t.refractionIntensity||1),e[s]=i,s==="emissiveTexture"&&(e.emissiveColor=new p.Color3(1,1,1),e.emissiveIntensity=1)}function $e(s,e){s.clearCoat&&(s.clearCoat===R.RemoveWhenSelected?(e.clearCoat.isEnabled=!1,e.clearCoat.indexOfRefraction=1.5):s.clearCoat===R.ApplyWhenSelected&&(e.clearCoat.isEnabled=!0,e.clearCoat.indexOfRefraction=s.clearCoatIOR||e.clearCoat.indexOfRefraction))}class Ye{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,o){return new Promise(a=>{const n=this.materialVariantMap.get(e);this.materialVariantMap.set(e,{...n,...t});const r=this.renameClonedAsset(e),l=this.scene.materials.filter(u=>u.name===r);if(l.length===0){a();return}const d=new Se.AssetsManager(this.scene);d.useDefaultLoadingScreen=!1,l.forEach(u=>Ue(t,u,d,o)),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),this.scene.materials.filter(w=>w.name===r).forEach(w=>Ze(m.name,w,t,b.texture))}),a()},d.loadAsync()})}async applyModel(e,t,i,o){var l,d;if(i&&t&&!this.keysThatRemovedBaseModel.includes(e)&&this.keysThatRemovedBaseModel.push(e),!i)return this.keysThatRemovedBaseModel.includes(e)&&await this.setBaseModelEnabled(!0),(l=this.loadedContainerForKey.get(e))==null||l.dispose(),this.loadedContainerForKey.delete(e),this.loadedMaterialsForKey.delete(e),Promise.resolve(void 0);const n=(await H(i,this.scene,o)).instantiateModelsToScene(this.renameClonedAsset,!0);this.loadedContainerForKey.has(e)&&((d=this.loadedContainerForKey.get(e))==null||d.dispose(),this.loadedContainerForKey.delete(e),this.loadedMaterialsForKey.delete(e)),t&&await this.setBaseModelEnabled(!1),this.loadedContainerForKey.set(e,n),this.loadedMaterialsForKey.set(e,$(n));const r=[];return this.materialVariantMap.forEach(async(u,m)=>{r.push(this.applyMaterial(m,u))}),await Promise.all(r),n}dispose(){this.loadedContainerForKey.forEach(e=>e==null?void 0:e.dispose()),this.loadedContainerForKey.clear(),this.loadedMaterialsForKey.forEach(e=>e.forEach(t=>t==null?void 0:t.dispose())),this.loadedMaterialsForKey.clear(),this.materialVariantMap.clear(),this.keysThatRemovedBaseModel=[]}getAllMaterials(){const e=[];return this.loadedMaterialsForKey.forEach(t=>{t.forEach(i=>{e.includes(i)||e.push(i)})}),e}getAnimationGroups(){const e=[];return this.loadedContainerForKey.forEach(t=>{e.push(...t.animationGroups)}),e}}function $(s){const e=[];return s.rootNodes.forEach(t=>{t.getChildMeshes().forEach(i=>{i.material&&!e.includes(i.material)&&e.push(i.material),i.subMeshes&&i.subMeshes.forEach(o=>{const a=o.getMaterial(!1);a&&!e.includes(a)&&e.push(a)})})}),e}function Y(s,e=""){return s.map(t=>({name:t.name.substring(e.length),loop:t.loopAnimation,to:t.to,from:t.from}))}class Xe{constructor(e){this.metadata=new Map,this.materialSelectedObservable=new M.Observable,this.materialDeselectedObservable=new M.Observable,this.materialVariantObservable=new M.Observable,this.modelVariantObservable=new M.Observable,this.materialReadyToLoadCallbacks=new Map,this.modelReadyToLoadCallbacks=new Map,this.dynamicTextures=new Map,this.queuedMaterialChanges=new Map,this.materialChangesInProgress=[],this.queuedModelChanges=new Map,this.modelChangesInProgress=[],this.animations=[],this.initialized=!1,this.materials=[];const{enablePicking:t,modelDetails:i,previewService:o,progressHandler:a,scene:n}=e;this.enablePicking=t,this.contextService=i.contextService,this.id=ze(),this.previewService=o,this.scene=n,this.variantManager=new Ye(n,this.renameClonedAsset.bind(this),this.setBaseModelEnabled.bind(this)),this.transformRoot=new Ee.TransformNode("root",this.scene);const r=async()=>(this.assetContainer=await H(i.model,n,a),this.initialized=!0,await this.instantiate(),this);this.importPromise=r()}async applyMaterialVariant(e,t,i,o){if(!this.initialized){if(this.materialReadyToLoadCallbacks.has(e)){const n=this.materialReadyToLoadCallbacks.get(e);n==null||n.set(t,this.applyMaterialVariant.bind(this,e,t,i,o))}else{this.materialReadyToLoadCallbacks.set(e,new Map);const n=this.materialReadyToLoadCallbacks.get(e);n==null||n.set(t,this.applyMaterialVariant.bind(this,e,t,i,o))}return}const a=async()=>{await this.variantManager.applyMaterial(e,i,(n,r,l)=>{this.materialVariantObservable.notifyObservers({remainingCount:n,totalCount:r,taskName:l})},o)};if(this.materialChangesInProgress.includes(e)){if(this.queuedMaterialChanges.has(e)){const n=this.queuedMaterialChanges.get(e);n==null||n.set(t,a)}else{this.queuedMaterialChanges.set(e,new Map);const n=this.queuedMaterialChanges.get(e);n==null||n.set(t,a)}return}this.materialChangesInProgress.push(e),await a(),this.queuedMaterialChanges.has(e)&&(this.queuedMaterialChanges.get(e).forEach(async r=>{await r()}),this.queuedMaterialChanges.delete(e)),this.materialChangesInProgress.splice(this.materialChangesInProgress.indexOf(e),1),this.configureGlowLayer()}async applyModelVariant(e,t,i){if(!this.initialized){this.modelReadyToLoadCallbacks.set(e,this.applyModelVariant.bind(this,e,t,i));return}const o=()=>this.variantManager.applyModel(e,i,t==null?void 0:t.model,r=>{this.modelVariantObservable.notifyObservers({...r,key:e})});if(this.modelChangesInProgress.includes(e)){this.queuedModelChanges.set(e,o);return}const n=await(async()=>{this.modelChangesInProgress.push(e);let r=await o();return this.queuedModelChanges.has(e)&&(r=await this.queuedModelChanges.get(e)(),this.queuedModelChanges.delete(e)),this.modelChangesInProgress.splice(this.modelChangesInProgress.indexOf(e),1),r})();this.modelInstance&&Q(this.modelInstance.animationGroups),this.contextService||(this.contextService=t==null?void 0:t.contextService),n?this.configureModelInstance(n):this.configureGlowLayer()}dispose(){var e;this.destroyInstance(),this.variantManager.dispose(),this.dynamicTextures.forEach(t=>t==null?void 0:t.dispose()),this.dynamicTextures.clear(),this.materials.forEach(t=>t&&(t==null?void 0:t.dispose())),this.materials=[],(e=this.transformRoot)==null||e.dispose(),this.transformRoot=void 0,this.previewService.modelUnloaded(this)}executeAnimation(e){if(!this.previewService.getIsInitialized()){this.queuedModelAnimation=e;return}this.modelInstance&&ke([...this.modelInstance.animationGroups,...this.variantManager.getAnimationGroups()],e.loop,e.to,e.from,e.name?this.renameClonedAsset(e.name):void 0)}getAnimations(e){return[...this.animations,...e?Y(this.variantManager.getAnimationGroups(),this.renameClonedAsset("")):[]]}getId(){return this.id}listMaterials(){var t;const e=(t=this.scene)==null?void 0:t.materials.filter(i=>i.name.startsWith(this.id));return e?e.map(i=>({id:i.id,name:this.stripIdFromName(i.name)})):[]}registerMaterialSelectedCallback(e){this.materialSelectedObservable.add(e)}unregisterMaterialSelectedCallback(e){this.materialSelectedObservable.removeCallback(e)}registerMaterialDeselectedCallback(e){this.materialDeselectedObservable.add(e)}unregisterMaterialDeselectedCallback(e){this.materialDeselectedObservable.removeCallback(e)}get position(){return this.transformRoot.position}set position(e){this.transformRoot.position=new g.Vector3(e.x,e.y,e.z)}get rotation(){return this.transformRoot.rotationQuaternion.toEulerAngles()}set rotation(e){this.transformRoot.rotationQuaternion=g.Quaternion.FromEulerAngles(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 V.ExecuteCodeAction(O.ActionManager.OnPointerOverTrigger,o=>{o.meshUnderPointer&&i.material&&this.materialSelectedObservable.notifyObservers({id:i.material.id,name:this.stripIdFromName(i.material.name)})})),i.actionManager.registerAction(new V.ExecuteCodeAction(O.ActionManager.OnPointerOutTrigger,()=>{i.material&&this.materialDeselectedObservable.notifyObservers({id:i.material.id,name:this.stripIdFromName(i.material.name)})})))})})}getInitializationPromise(){return this.importPromise}getIsInitialized(){return this.initialized}getQueuedMaterialVariantCount(){return this.materialReadyToLoadCallbacks.size}getQueuedModelVariantCount(){return this.modelReadyToLoadCallbacks.size}configureGlowLayer(){const e=i=>i instanceof L.PBRMaterial&&i.emissiveTexture!==null;this.materials.some(e)||this.variantManager.getAllMaterials().some(e)?this.previewService.getGlowLayerManager().includeMeshes(this.getAllMeshes()):this.previewService.getGlowLayerManager().removeMeshes(this.getAllMeshes())}configureModelInstance(e){var a;const t=this.transformRoot.position,i=this.transformRoot.rotationQuaternion,o=this.transformRoot.scaling;this.transformRoot.position=g.Vector3.Zero(),this.transformRoot.rotationQuaternion=g.Quaternion.Identity(),this.transformRoot.scaling=g.Vector3.One(),e.rootNodes.forEach(n=>{n.parent=this.transformRoot}),this.transformRoot.position=t,this.transformRoot.rotationQuaternion=i,this.transformRoot.scaling=o,this.canvasPanels=((a=this.contextService)==null?void 0:a.getAll())||new Map,qe(this.materials.concat(this.variantManager.getAllMaterials()),this.scene,this.canvasPanels,this.dynamicTextures,`${this.id}_`),this.enablePicking&&this.attachPickingHandler(e),this.configureGlowLayer()}destroyInstance(){var e;(e=this.modelInstance)==null||e.dispose(),this.modelInstance=void 0}getAllMeshes(){var e;return(e=this.modelInstance)==null?void 0:e.rootNodes.map(t=>t.getChildMeshes(!1).filter(i=>i instanceof Re.Mesh)).flat()}async instantiate(){this.modelInstance=this.assetContainer.instantiateModelsToScene(this.renameClonedAsset.bind(this),!0),this.materials=$(this.modelInstance),this.configureModelInstance(this.modelInstance),this.animations=Y(this.modelInstance.animationGroups,this.renameClonedAsset("")),await this.processQueuedEvents()}renameClonedAsset(e){return`${this.id}_${e}`}async setBaseModelEnabled(e){e&&!this.modelInstance?await this.instantiate():!e&&this.modelInstance&&this.destroyInstance()}updateDynamicTextures(){var e;(e=this.canvasPanels)==null||e.forEach((t,i)=>{const o=this.dynamicTextures.get(i);o&&t.getStaticContextDirty()&&o.isReady()&&(o.update(!1),t.setStaticContextDirty(!1))})}registerMaterialVariantListener(e){this.materialVariantObservable.add(e)}unregisterMaterialVariantListener(e){this.materialVariantObservable.removeCallback(e)}registerModelVariantListener(e){this.modelVariantObservable.add(e)}unregisterModelVariantListener(e){this.modelVariantObservable.removeCallback(e)}stripIdFromName(e){return e.substring(this.id.length+1)}async processQueuedEvents(){await Promise.all(Array.from(this.materialReadyToLoadCallbacks.values()).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,o,a,n,r,l){super(e,t,i,o,a,n,l),this.lastFocus=new g.Vector3(0,0,0),this.panDenominator=1,this.minZ=.01,this.setRadius(this.radius),this.enableFramingBehavior(),this.wheelDeltaPercentage=.01,this.pinchDeltaPercentage=.005,this.useNaturalPinchZoom=!0,r.camera.autoOrientation&&(this.alpha+=Math.PI),r&&(r.camera.limits.min.beta&&(this.lowerBetaLimit=r.camera.limits.min.beta),r.camera.limits.max.beta&&(this.upperBetaLimit=r.camera.limits.max.beta),r.camera.limits.min.alpha&&(this.lowerAlphaLimit=r.camera.limits.min.alpha),r.camera.limits.max.alpha&&(this.upperAlphaLimit=r.camera.limits.max.alpha),r.camera.limits.min.radius&&(this.lowerRadiusLimit=r.camera.limits.min.radius),r.camera.limits.max.radius&&(this.upperRadiusLimit=r.camera.limits.max.radius),r.camera.autoRotation.enabled&&this.enableAutoRotationBehavior(r.camera.autoRotation.idleTimeMs))}getFramingBehavior(){return this.getBehaviorByName("Framing")}getAutoRotationBehavior(){const e=this.getBehaviorByName("AutoRotation");if(e)return e}enableFramingBehavior(){this.useFramingBehavior=!0;const e=this.getFramingBehavior();e.attach(this),e.framingTime=0,e.elevationReturnTime=-1,e.zoomStopsAnimation=!1,this.lowerRadiusLimit=null;const t=F(this._scene);return e.zoomOnBoundingInfo(t.min,t.max),this.wheelPrecision=100/this.radius,this.lowerRadiusLimit===null&&(this.lowerRadiusLimit=.1),this.lastFocus.copyFrom(this.target),e}rerunFramingBehavior(e,t){const i=this.getFramingBehavior();i.framingTime=t||800;const o=()=>{e&&e()},a=F(this._scene),n=a.max.subtract(a.min),r=a.min.add(n.scale(.5));this.setRadius(n.length()*1.5),this.wheelPrecision=100/this.radius,this.panningInertia=0,this.panningOriginTarget.copyFrom(r),this.panDenominator=n.length(),i.zoomOnBoundingInfo(a.min,a.max,void 0,o),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 o=F(e),a=o.max.subtract(o.min),n=o.min.add(a.scale(.5)),r=new S("ProductCamera",-(Math.PI/2),Math.PI/2,a.length()*1.5,n,e,t);return r.panningInertia=0,r.panningOriginTarget.copyFrom(n),r.panDenominator=a.length(),r.onAfterCheckInputsObservable.add(()=>{r.panningSensibility=1e3/r.panDenominator}),i&&(e.activeCamera=r),r}}function F(s){if(s.meshes.length===0)return{min:new g.Vector3(-1,-1,-1),max:new g.Vector3(1,1,1)};const e=s.meshes.filter(t=>t.name.toLowerCase().endsWith("_t")||t.name.toLowerCase().includes("_t_"));return s.getWorldExtends(t=>t.isVisible&&t.isEnabled()&&(e.length===0||e.includes(t)))}class Je{constructor(e,t=!1,i=void 0){this.renderingPipeline=new Fe.DefaultRenderingPipeline("default",t,e,i?[i]:void 0,!1),this.renderingPipeline.isSupported&&(this.renderingPipeline.prepare(),this.setConfiguration(c))}dispose(){this.renderingPipeline.dispose()}getConfiguration(){return this.currentConfiguration}setConfiguration(e){var t,i,o,a,n,r,l,d,u,m,b,f,w,X,J,_,ee,te,ie,se,ne,re,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)??c.antiAliasing.samples,this.renderingPipeline.fxaaEnabled=((i=e.antiAliasing)==null?void 0:i.fxaaEnabled)??c.antiAliasing.fxaaEnabled,this.renderingPipeline.bloomEnabled=((o=e.bloom)==null?void 0:o.enabled)??c.bloom.enabled,this.renderingPipeline.bloomKernel=((a=e.bloom)==null?void 0:a.kernel)??c.bloom.kernel,this.renderingPipeline.bloomScale=((n=e.bloom)==null?void 0:n.scale)??c.bloom.scale,this.renderingPipeline.bloomThreshold=((r=e.bloom)==null?void 0:r.threshold)??c.bloom.threshold,this.renderingPipeline.bloomWeight=((l=e.bloom)==null?void 0:l.weight)??c.bloom.weight,this.renderingPipeline.chromaticAberrationEnabled=((d=e.chromaticAberration)==null?void 0:d.enabled)??c.chromaticAberration.enabled,this.renderingPipeline.chromaticAberration.aberrationAmount=((u=e.chromaticAberration)==null?void 0:u.aberrationAmount)??c.chromaticAberration.aberrationAmount,this.renderingPipeline.chromaticAberration.radialIntensity=((m=e.chromaticAberration)==null?void 0:m.radialIntensity)??c.chromaticAberration.radialIntensity,this.renderingPipeline.chromaticAberration.direction=(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 k.ColorCurves,this.renderingPipeline.depthOfFieldEnabled=((w=e.depthOfField)==null?void 0:w.enabled)??c.depthOfField.enabled,e.depthOfField)switch(e.depthOfField.blurLevel??c.depthOfField.blurLevel){case"Low":this.renderingPipeline.depthOfFieldBlurLevel=I.DepthOfFieldEffectBlurLevel.Low;break;case"Medium":this.renderingPipeline.depthOfFieldBlurLevel=I.DepthOfFieldEffectBlurLevel.Medium;break;case"High":this.renderingPipeline.depthOfFieldBlurLevel=I.DepthOfFieldEffectBlurLevel.High;break}if(this.renderingPipeline.depthOfField.focalLength=((X=e.depthOfField)==null?void 0:X.focalLength)??c.depthOfField.focalLength,this.renderingPipeline.depthOfField.fStop=((J=e.depthOfField)==null?void 0:J.fStop)??c.depthOfField.fStop,this.renderingPipeline.depthOfField.focusDistance=((_=e.depthOfField)==null?void 0:_.focusDistance)??c.depthOfField.focusDistance,this.renderingPipeline.depthOfField.lensSize=((ee=e.depthOfField)==null?void 0:ee.lensSize)??c.depthOfField.lensSize,this.renderingPipeline.grainEnabled=((te=e.grain)==null?void 0:te.enabled)??c.grain.enabled,this.renderingPipeline.grain.animated=((ie=e.grain)==null?void 0:ie.animated)??c.grain.animated,this.renderingPipeline.grain.intensity=((se=e.grain)==null?void 0:se.intensity)??c.grain.intensity,this.renderingPipeline.imageProcessing.contrast=((ne=e.misc)==null?void 0:ne.contrast)??c.misc.contrast,this.renderingPipeline.imageProcessing.exposure=((re=e.misc)==null?void 0:re.exposure)??c.misc.exposure,this.renderingPipeline.imageProcessing.toneMappingEnabled=((ae=e.misc)==null?void 0:ae.toneMappingEnabled)??c.misc.toneMappingEnabled,this.renderingPipeline.imageProcessing.toneMappingEnabled)switch(e.misc.toneMappingType??c.misc.toneMappingType){case"Standard":this.renderingPipeline.imageProcessing.toneMappingType=T.ImageProcessingConfiguration.TONEMAPPING_STANDARD;break;case"ACES":this.renderingPipeline.imageProcessing.toneMappingType=T.ImageProcessingConfiguration.TONEMAPPING_ACES;break}if(this.renderingPipeline.sharpenEnabled=((oe=e.sharpen)==null?void 0:oe.enabled)??c.sharpen.enabled,this.renderingPipeline.sharpen.colorAmount=((le=e.sharpen)==null?void 0:le.colorAmount)??c.sharpen.colorAmount,this.renderingPipeline.sharpen.edgeAmount=((he=e.sharpen)==null?void 0:he.edgeAmount)??c.sharpen.edgeAmount,this.renderingPipeline.imageProcessing.vignetteEnabled=((ce=e.vignette)==null?void 0:ce.enabled)??c.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=c.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=c.vignette.center.y),e.vignette)switch(((ue=e.vignette)==null?void 0:ue.blendMode)??c.vignette.blendMode){case"Multiply":this.renderingPipeline.imageProcessing.vignetteBlendMode=T.ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY;break;case"Opaque":this.renderingPipeline.imageProcessing.vignetteBlendMode=T.ImageProcessingConfiguration.VIGNETTEMODE_OPAQUE;break}(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(c.vignette.colorRgba.r,c.vignette.colorRgba.g,c.vignette.colorRgba.b,c.vignette.colorRgba.a),this.renderingPipeline.imageProcessing.vignetteStretch=((pe=e.vignette)==null?void 0:pe.stretch)??c.vignette.stretch,this.renderingPipeline.imageProcessing.vignetteWeight=((be=e.vignette)==null?void 0:be.weight)??c.vignette.weight,this.renderingPipeline.prepare(),this.currentConfiguration=e}}updateColorCurve(e){const t=new k.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}}xe.GLTF2.GLTFLoader.RegisterExtension("glbPostProcessor",function(s){return new je(s)}),q.SceneLoader.OnPluginActivatedObservable.add(s=>{if(s.name==="gltf"){const e=s;e.transparencyAsCoverage=!0}});function B(s){return new g.Vector3(s.x,s.y,s.z)}function j(s){return{x:s.x,y:s.y,z:s.z}}class _e{constructor(e){var r;this.focusLostNotified=!1,this.focusLostObservable=new M.Observable,this.initializedCallbacks=[],this.isInitialized=!1,this.modelLoadEventCallbacks=[],this.modelContainers=new Map,this.plugins=[],this.renderLoop=()=>{this.engine.views&&(this.modelContainers.forEach(l=>{l.updateDynamicTextures()}),this.configuration.scene.transparentBackground&&this.engine.views.forEach(l=>{const d=this.engine.getRenderingCanvas();l.target.getContext("2d").clearRect(0,0,d.width,d.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))},this.configuration=new Be(e);const i=(()=>{if(!(e!=null&&e.noRender))return this.configuration.createCanvas()})(),o="1.5.6";ve.DracoCompression.Configuration={decoder:{wasmUrl:`https://www.gstatic.com/draco/versioned/decoders/${o}/draco_wasm_wrapper_gltf.js`,wasmBinaryUrl:`https://www.gstatic.com/draco/versioned/decoders/${o}/draco_decoder_gltf.wasm`,fallbackUrl:`https://www.gstatic.com/draco/versioned/decoders/${o}/draco_decoder_gltf.js`}},i&&(i.getContext("webgl2")||i.getContext("webgl"));const a=console.log;console.log=()=>{};const n=i?new D.Engine(i,!0,{adaptToDeviceRatio:!0,limitDeviceRatio:2,premultipliedAlpha:!1,preserveDrawingBuffer:!!(e!=null&&e.backgroundImage),audioEngine:!1,stencil:this.configuration.highlights.enabled,forceSRGBBufferSupportState:!0}):new fe.NullEngine;console.log=a,n.hideLoadingUI(),window.addEventListener("resize",this.fireResizeEvent.bind(this)),this.engine=n,this.scene=new Me.Scene(n),this.camera=S.create(this.scene,this.configuration),this.scene.activeCamera=this.camera,this.renderingPipeline=new Je(this.scene,!1,this.camera),this.scene.clearColor=this.configuration.scene.clearColor,this.scene.environmentTexture=Ce.CubeTexture.CreateFromPrefilteredData(this.configuration.scene.environmentFile,this.scene),(r=this.configuration.options)!=null&&r.renderingPipelineConfiguration&&this.renderingPipeline.setConfiguration(this.configuration.options.renderingPipelineConfiguration),this.scene.imageProcessingConfiguration.exposure=this.configuration.lighting.exposure,this.scene.imageProcessingConfiguration.contrast=this.configuration.lighting.contrast,this.glowLayerManager=new De(this.scene,this.configuration.emissiveGlowIntensity),this.engine.onEndFrameObservable.addOnce(()=>{this.isInitialized=!0,this.initializedCallbacks.map(l=>l()),this.initializedCallbacks=[]}),this.engine.runRenderLoop(this.renderLoop)}getEngineContext(){return{engine:this.engine,scene:this.scene,camera:this.camera}}registerFocusLostListener(e){this.focusLostObservable.add(e)}unregisterFocusLostListener(e){this.focusLostObservable.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(A.Pan),this.reattachControls(e)}getNumViewports(){var e;return((e=this.engine.views)==null?void 0:e.length)||0}unregisterView(e){this.engine.unRegisterView(e)}shutdown(){this.plugins.forEach(e=>e.dispose(!0)),this.renderingPipeline.dispose(),this.engine&&this.engine.dispose(),window.removeEventListener("resize",this.fireResizeEvent)}executeCameraAnimation(e){if(!this.camera||this.scene.activeCamera!==this.camera){this.queuedCameraAnimation=e;return}Ge(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===A.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 o=t.latDeg*Math.PI/180,a=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=a,i.beta=o,i.radius=t.radius||this.camera.radius,i.minZ=.01,this.scene.render();const n=await we.Tools.CreateScreenshotUsingRenderTargetAsync(this.engine,i,e,"image/png",2,!0);return i.dispose(),n}catch{throw i.isDisposed()||i.dispose(),new Error("Failed to render screenshot")}}orbitEnabled(){const e=this.configuration;if(!e)return!0;const t=e.camera.limits.min.alpha,i=e.camera.limits.max.alpha,o=e.camera.limits.min.beta,a=e.camera.limits.max.beta;if(t===void 0||i===void 0||o===void 0||a===void 0)return!0;const n=[t,i],r=[o,a],l=n.every(u=>u===t),d=r.every(u=>u===o);return!l&&!d}fireResizeEvent(){this.getNumViewports()>0&&this.engine.resize()}setHighlights(e,t){var o;e.length===0&&((o=this.highlightLayer)==null||o.dispose(),this.highlightLayer=void 0),this.highlightLayer||(this.highlightLayer=new ye.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(a=>{const n=this.scene.materials.find(r=>r.name===a.name&&r.id===a.id);n&&n.getBindedMeshes().forEach(r=>{var l;return(l=this.highlightLayer)==null?void 0:l.addMesh(r,i||p.Color3.FromHexString("#fcba03"))})})}setRenderingPipelineConfiguration(e){this.renderingPipeline&&this.renderingPipeline.setConfiguration(e)}loadModel(e,t){const i=new Xe({enablePicking:this.configuration.highlights.enabled,modelDetails:e,scene:this.scene,previewService:this,progressHandler:t});return i.getInitializationPromise().then(()=>{this.modelContainers.size<=1&&this.camera.rerunFramingBehavior(void 0,1),Ne(this.scene),this.queuedCameraAnimation&&(this.executeCameraAnimation(this.queuedCameraAnimation),this.queuedCameraAnimation=void 0)}),this.configuration.highlights.enabled&&(i.registerMaterialSelectedCallback(o=>{this.setHighlights([o])}),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(o=>o.dispose(!1))}getGlowLayerManager(){return this.glowLayerManager}modelUnloaded(e){this.modelContainers.delete(e.getId()),this.triggerModelLoadEvent({eventType:"unload",modelContainer:e})}triggerModelLoadEvent(e){this.modelLoadEventCallbacks.forEach(t=>t(e))}flipTransform(e,t,i){const o=g.Matrix.Compose(B(i||{x:1,y:1,z:1}),g.Quaternion.FromEulerVector(B(t||{x:0,y:0,z:0})),B(e||{x:0,y:0,z:0})),a=g.Matrix.RotationAxis(g.Vector3.Up(),Math.PI),n=o.multiply(a),r=g.Vector3.Zero(),l=g.Quaternion.Identity(),d=g.Vector3.Zero();return n.decompose(d,l,r),l.multiplyInPlace(g.Quaternion.FromEulerAngles(0,Math.PI,0)),{position:j(r),rotation:j(l.toEulerAngles()),scale:j(d)}}reattachControls(e,t=2){if(this.scene.detachControl(),this.engine.inputElement=e,this.camera){this.camera.attachControl(!0,!1,t);const i=this.camera.inputs.attached.pointers;i.multiTouchPanning=!1}this.scene.attachControl(!0,!0,!0)}}h.MaterialEffectMode=R,h.ProductCameraRig=A,h.REFLECTION_PROBE_RESOLUTION=N,h.RenderingConfiguration=v,h.SpiffCommerce3DPreviewService=_e,h.renderingPipelineDefaults=c,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(h,y){typeof exports=="object"&&typeof module<"u"?y(exports,require("@babylonjs/core/Cameras/arcRotateCamera"),require("@babylonjs/core/Engines/engine"),require("@babylonjs/core/Engines/nullEngine"),require("@babylonjs/core/Layers/highlightLayer"),require("@babylonjs/core/Loading/sceneLoader"),require("@babylonjs/core/Materials/Textures/cubeTexture"),require("@babylonjs/core/Maths/math.color"),require("@babylonjs/core/Maths/math.vector"),require("@babylonjs/core/Meshes/Compression/dracoCompression"),require("@babylonjs/core/Misc/observable"),require("@babylonjs/core/Misc/tools"),require("@babylonjs/core/scene"),require("@babylonjs/loaders/glTF"),require("@babylonjs/core/Materials/PBR/pbrMaterial"),require("@babylonjs/core/Materials/Textures/mirrorTexture"),require("@babylonjs/core/Maths/math"),require("@babylonjs/core/Probes/reflectionProbe"),require("@babylonjs/core/Layers/glowLayer"),require("@babylonjs/core/Actions/actionManager"),require("@babylonjs/core/Actions/directActions"),require("@babylonjs/core/Meshes/mesh"),require("@babylonjs/core/Meshes/transformNode"),require("@babylonjs/core/Materials/Textures/dynamicTexture"),require("@babylonjs/core/Materials/Textures/texture"),require("@babylonjs/core/Animations/animation"),require("@babylonjs/core/Animations/easing"),require("@babylonjs/core/Misc/assetsManager"),require("@babylonjs/core/Materials/colorCurves"),require("@babylonjs/core/Materials/imageProcessingConfiguration"),require("@babylonjs/core/PostProcesses/RenderPipeline"),require("@babylonjs/core/PostProcesses/depthOfFieldEffect"),require("@babylonjs/core/Rendering/depthRendererSceneComponent"),require("@babylonjs/core/Engines/Extensions/engine.views"),require("@babylonjs/core/Meshes/instancedMesh"),require("@babylonjs/core/Materials/Textures/Loaders/ddsTextureLoader"),require("@babylonjs/core/Materials/Textures/Loaders/envTextureLoader"),require("@babylonjs/core/Materials/Textures/Loaders/ktxTextureLoader"),require("@babylonjs/core/Animations/animatable"),require("@babylonjs/core/Misc/screenshotTools"),require("@babylonjs/core/Rendering/boundingBoxRenderer"),require("@babylonjs/loaders/glTF/2.0/Extensions")):typeof define=="function"&&define.amd?define(["exports","@babylonjs/core/Cameras/arcRotateCamera","@babylonjs/core/Engines/engine","@babylonjs/core/Engines/nullEngine","@babylonjs/core/Layers/highlightLayer","@babylonjs/core/Loading/sceneLoader","@babylonjs/core/Materials/Textures/cubeTexture","@babylonjs/core/Maths/math.color","@babylonjs/core/Maths/math.vector","@babylonjs/core/Meshes/Compression/dracoCompression","@babylonjs/core/Misc/observable","@babylonjs/core/Misc/tools","@babylonjs/core/scene","@babylonjs/loaders/glTF","@babylonjs/core/Materials/PBR/pbrMaterial","@babylonjs/core/Materials/Textures/mirrorTexture","@babylonjs/core/Maths/math","@babylonjs/core/Probes/reflectionProbe","@babylonjs/core/Layers/glowLayer","@babylonjs/core/Actions/actionManager","@babylonjs/core/Actions/directActions","@babylonjs/core/Meshes/mesh","@babylonjs/core/Meshes/transformNode","@babylonjs/core/Materials/Textures/dynamicTexture","@babylonjs/core/Materials/Textures/texture","@babylonjs/core/Animations/animation","@babylonjs/core/Animations/easing","@babylonjs/core/Misc/assetsManager","@babylonjs/core/Materials/colorCurves","@babylonjs/core/Materials/imageProcessingConfiguration","@babylonjs/core/PostProcesses/RenderPipeline","@babylonjs/core/PostProcesses/depthOfFieldEffect","@babylonjs/core/Rendering/depthRendererSceneComponent","@babylonjs/core/Engines/Extensions/engine.views","@babylonjs/core/Meshes/instancedMesh","@babylonjs/core/Materials/Textures/Loaders/ddsTextureLoader","@babylonjs/core/Materials/Textures/Loaders/envTextureLoader","@babylonjs/core/Materials/Textures/Loaders/ktxTextureLoader","@babylonjs/core/Animations/animatable","@babylonjs/core/Misc/screenshotTools","@babylonjs/core/Rendering/boundingBoxRenderer","@babylonjs/loaders/glTF/2.0/Extensions"],y):(h=typeof globalThis<"u"?globalThis:h||self,y(h.Preview={},h.arcRotateCamera,h.engine,h.nullEngine,h.highlightLayer,h.sceneLoader,h.cubeTexture,h.math_color,h.math_vector,h.dracoCompression,h.observable,h.tools,h.scene,h.glTF,h.pbrMaterial,h.mirrorTexture,h.math,h.reflectionProbe,h.glowLayer,h.actionManager,h.directActions,h.mesh,h.transformNode,h.dynamicTexture,h.texture,h.animation,h.easing,h.assetsManager,h.colorCurves,h.imageProcessingConfiguration,h.RenderPipeline,h.depthOfFieldEffect))})(this,function(h,y,D,be,ye,q,we,p,g,Ce,M,ve,Me,xe,L,Pe,P,Te,Re,O,V,Ee,Ae,Le,Oe,w,N,Ie,k,T,Se,I){"use strict";var R=(s=>(s[s.Orbit=0]="Orbit",s[s.Pan=1]="Pan",s))(R||{}),E=(s=>(s.None="None",s.RemoveWhenSelected="RemoveWhenSelected",s.ApplyWhenSelected="ApplyWhenSelected",s))(E||{});class Fe{constructor(e){this.getSceneClearColor=()=>{var i,o,a,r;const t=(i=this.customOptions)!=null&&i.transparentBackground||(o=this.customOptions)!=null&&o.backgroundImage?0:1;if(this.customOptions&&((a=this.customOptions)!=null&&a.transparentBackground)||(r=this.customOptions)!=null&&r.backgroundImage)return new p.Color4(0,0,0,t).toLinearSpace();if(this.customOptions&&this.customOptions.backgroundColor){const n=p.Color3.FromHexString(this.customOptions.backgroundColor);return new p.Color4(n.r,n.g,n.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 o=p.Color3.FromHexString(t);return new p.Color4(o.r,o.g,o.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,o,a,r,n,l,d,u,m,f,b;return{autoOrientation:((e=this.customOptions)==null?void 0:e.disableAutomaticOrientation)??!0,autoRotation:{enabled:((t=this.customOptions)==null?void 0:t.autoRotation)??!1,idleTimeMs:((i=this.customOptions)==null?void 0:i.idleTimeBeforeRotation)??5e3},limits:{min:{alpha:(o=this.customOptions)!=null&&o.lowerAlphaLimitDeg?((a=this.customOptions)==null?void 0:a.lowerAlphaLimitDeg)*Math.PI/180:void 0,beta:(r=this.customOptions)!=null&&r.lowerBetaLimitDeg?((n=this.customOptions)==null?void 0:n.lowerBetaLimitDeg)*Math.PI/180:void 0,radius:(l=this.customOptions)==null?void 0:l.minZoomOverride},max:{alpha:(d=this.customOptions)!=null&&d.upperAlphaLimitDeg?((u=this.customOptions)==null?void 0:u.upperAlphaLimitDeg)*Math.PI/180:void 0,beta:(m=this.customOptions)!=null&&m.upperBetaLimitDeg?((f=this.customOptions)==null?void 0:f.upperBetaLimitDeg)*Math.PI/180:void 0,radius:(b=this.customOptions)==null?void 0:b.maxZoomOverride}}}}get highlights(){var e;return{enabled:((e=this.customOptions)==null?void 0:e.highlightOnMaterialHover)??!1,color:this.highlightColorFromConfig()}}get lighting(){var e,t,i,o;return{exposure:((t=(e=this.customOptions)==null?void 0:e.lighting)==null?void 0:t.exposure)??.9,contrast:((o=(i=this.customOptions)==null?void 0:i.lighting)==null?void 0:o.contrast)??1.6}}get emissiveGlowIntensity(){var e;return((e=this.customOptions)==null?void 0:e.emissiveGlowIntensity)??.5}}class C{static getDynamicTextureResolution(){return this.getIsMobile()||!C.offscreenRenderingSupported()?{width:1024,height:1024}:{width:2048,height:2048}}static shouldMipMap(){return!0}static offscreenRenderingSupported(){return navigator.userAgent.includes("SamsungBrowser")?!1:!!window.Worker&&!!window.OffscreenCanvas}static getMirrorTextureResolution(){return this.getIsMobile()?512:1024}static getIsMobile(){try{return typeof window>"u"||!window.navigator?!1:/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(window.navigator.userAgent)||window.innerWidth<=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 Be{constructor(e){this.name="glbPostProcessor",this.enabled=!0,this.loader=e}onReady(){this.applyReflections(this.loader.babylonScene)}loadNodeAsync(e,t,i){return this.loader.loadNodeAsync(e,t,function(o){t.extras&&Object.keys(t.extras).forEach(a=>{const r=t.extras[a];o.metadata[a]=r}),i(o)})}async loadMaterialPropertiesAsync(e,t,i){await this.loader.loadMaterialPropertiesAsync(e,t,i),this.enableMaterialExtrasIfRequired(t,i),i.needDepthPrePass=!0}dispose(){}enableMaterialExtrasIfRequired(e,t){if(!(!e.extras||!(t instanceof L.PBRMaterial))){if(e.extras.sheen){const i=t;i.sheen.isEnabled=!0,i.sheen.intensity=e.extras.sheen}if(e.extras.translucency){const i=t;i.subSurface.isTranslucencyEnabled=!0,i.subSurface.translucencyIntensity=e.extras.translucency,e.extras.translucencyR&&e.extras.translucencyG&&e.extras.translucencyB&&(i.subSurface.tintColor=new P.Color3(e.extras.translucencyR,e.extras.translucencyG,e.extras.translucencyB))}if(e.extras.refractionIOR){const i=t;i.subSurface.isRefractionEnabled=!0,i.subSurface.volumeIndexOfRefraction=e.extras.refractionIOR}if(e.extras.useDepthPrePass){const i=t;i.needDepthPrePass=!0,i.forceIrradianceInFragment=!0}if(e.extras.useParallax){const i=t;i.useParallax=!0,i.useParallaxOcclusion=!0,i.parallaxScaleBias=e.extras.useParallax}}}applyReflections(e){function t(a){const r=[];return a.transformNodes.forEach(n=>{n.metadata&&n.metadata.reflective&&r.push(...n.getChildMeshes())}),a.meshes.forEach(n=>{n.metadata&&n.metadata.reflective&&!r.includes(n)&&r.push(n)}),r}function i(a,r=1){const n=a.material;if(!n)return;const l=new Pe.MirrorTexture("mirror",C.getMirrorTextureResolution(),e,!0);l.renderList=t(e);const d=a.getVerticesData("normal");if(!d)throw new Error("Mirror attribute specified on: "+a.name+"But no normals exist to generate a mirror from!");a.computeWorldMatrix(!0);const u=a.getWorldMatrix(),m=P.Vector3.TransformNormal(new P.Vector3(d[0],d[1],d[2]),u).normalize(),f=P.Plane.FromPositionAndNormal(a.position,m.scale(-1));l.mirrorPlane=f,l.level=r,n.reflectionTexture=l}function o(a){const r=a.material,n=new Te.ReflectionProbe("probe-"+r.name,z,e);n.attachToMesh(a),n.renderList&&n.renderList.push(...t(e)),r.reflectionTexture=n.cubeTexture}e.meshes.forEach(a=>{const r=a.metadata;r&&(r.mirrorTexture&&i(a,r.mirrorTexture),r.reflectionProbe&&o(a))})}}class je{constructor(e,t){this.scene=e,this.intensity=t,this.meshCount=0}includeMeshes(e){if(e){this.glowLayer||(this.glowLayer=new Re.GlowLayer("glow",this.scene),this.glowLayer.intensity=this.intensity);for(const t of e)this.glowLayer.hasMesh(t)||(this.glowLayer.addIncludedOnlyMesh(t),this.meshCount++)}}removeMeshes(e){if(!(!this.glowLayer||!e)){for(const t of e)this.glowLayer.hasMesh(t)&&(this.glowLayer.removeIncludedOnlyMesh(t),this.meshCount--);this.meshCount===0&&(this.glowLayer.dispose(),this.glowLayer=void 0)}}}const G=new Map;async function H(s,e,t){const i=G.get(s);if(i&&i.scene.uid===e.uid)return i;{const o=await q.SceneLoader.LoadAssetContainerAsync(s,void 0,e,t);return G.set(s,o),o}}function De(s,e,t,i,o=""){t.forEach(a=>{const r=a.getID(),n=a.getName(),l=C.getDynamicTextureResolution();s.filter(u=>u.name===o+n).forEach(u=>{const m=i.get(r),f=!1;if(m)K(u,m),m.update(f);else{const b=qe(n,e,l.width,l.height);i.set(r,b),a.setStaticContext(b.getContext()),K(u,b),b.onLoadObservable.addOnce(()=>{b.update(f)})}})})}function qe(s,e,t,i){const o=new Le.DynamicTexture(s,{width:t,height:i},e,C.shouldMipMap(),Oe.Texture.TRILINEAR_SAMPLINGMODE,D.Engine.TEXTUREFORMAT_RGBA),a=o.getContext();return a&&(a.fillStyle="#f5f5f5",a.fillRect(0,0,t,i),o.update()),o}function K(s,e){if(s instanceof L.PBRMaterial){const t=s,i=t.albedoTexture;i?(e.wrapU=i.wrapU,e.wrapV=i.wrapV):(e.wrapU=1,e.wrapV=1),t.albedoTexture=e}else{const t=s,i=t.diffuseTexture;i&&(e.wrapU=i.wrapU,e.wrapV=i.wrapV),t.diffuseTexture=e}}function Ve(){const s=()=>Math.floor((1+Math.random())*65536).toString(16).substring(1);return s()+s()+"-"+s()+"-"+s()+"-"+s()+"-"+s()+s()+s()}const x=60,U=1;function Q(s){return s.targetedAnimations.map(t=>t.animation.framePerSecond).reduce((t,i)=>t+i,0)/s.targetedAnimations.length||0}function Ne(s,e,t,i,o){const a=o?s.filter(r=>r.name===o):s;if(a.length===0){console.warn(`No animations found for name: ${o}`);return}if(i!==void 0&&t!==void 0&&i===t){a.forEach(r=>{r.stop();const n=Q(r),l=i*n;r.start(e,U,l,l)});return}a.forEach(r=>{r.stop();const n=Q(r),l=i!==void 0?i*n:void 0,d=t!==void 0?t*n:void 0;r.start(e,U,l,d)})}function W(s){s.forEach(e=>{e.stop()})}function ke(s){const e=s.animationGroups;W(e)}function ze(s,e,t){s.stopAnimation(e),e.animations=[],Math.abs(e.alpha)>2*Math.PI&&(e.alpha=Ge(e.alpha,0,2*Math.PI));const i=[],o=t.target,a=0,r=o?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),w.Animation.ANIMATIONTYPE_VECTOR3,a)),i.push(A("cameraAlphaLerp","alpha",e.alpha,Z(t.lonDeg),w.Animation.ANIMATIONTYPE_FLOAT,r)),i.push(A("cameraBetaLerp","beta",e.beta,Z(t.latDeg),w.Animation.ANIMATIONTYPE_FLOAT,r)),t.radius!==void 0){const d=Math.max(.01,t.radius);i.push(A("cameraRadiusLerp","radius",e.radius,d,w.Animation.ANIMATIONTYPE_FLOAT,r))}e.animations.push(...i);const l=e.useAutoRotationBehavior;e.disableAutoRotationBehavior(),s.beginAnimation(e,0,o?x*2:x,!1,1,()=>{e.animations=[],l&&e.enableAutoRotationBehavior()})}function Z(s){return s*Math.PI/180}function A(s,e,t,i,o,a=0,r=w.Animation.ANIMATIONLOOPMODE_CONSTANT){const n=new N.QuadraticEase;n.setEasingMode(N.EasingFunction.EASINGMODE_EASEINOUT);const l=new w.Animation(s,e,x,o,r),d=[];return a>0&&d.push({frame:0,value:t}),d.push({frame:x*a,value:t}),d.push({frame:x*(a+1),value:i}),l.setKeys(d),l.setEasingFunction(n),l}function Ge(s,e,t){return s<e?s=t-(e-s)%(t-e):s=e+(s-e)%(t-e)}const He={albedoTexture:"albedoMap",bumpTexture:"normalMap",ambientTexture:"ambientMap",emissiveTexture:"emissionMap",opacityTexture:"alphaMap",metallicTexture:"metallicMap",refractionTexture:"refractionMap"};function Ke(s,e,t,i){["albedoTexture","bumpTexture","ambientTexture","emissiveTexture","opacityTexture","metallicTexture","refractionTexture"].forEach(a=>{Ue(a,s,e,t,i)}),Ze(s,e)}function Ue(s,e,t,i,o){const a=He[s];if(!a)throw new Error("Unexpected texture name encountered.");const r=e[a],n=r==null?void 0:r.fileLink;n?i.addTextureTask(s,n,!1,!1):o&&t[s]&&(t[s]&&t[s].dispose(),t[s]=null,Qe(s,t))}function Qe(s,e){s==="opacityTexture"&&(e.useAlphaFromAlbedoTexture=!0),s==="metallicTexture"&&(e.useRoughnessFromMetallicTextureAlpha=!1,e.useRoughnessFromMetallicTextureGreen=!1,e.useMetallnessFromMetallicTextureBlue=!1),s==="refractionTexture"&&(e.subSurface.isRefractionEnabled=!1,e.subSurface.refractionIntensity=1),s==="emissiveTexture"&&(e.emissiveIntensity=0,e.emissiveColor=new p.Color3(0,0,0))}function We(s,e,t,i){if(!e){console.error("Failed to apply texture to material: material is null.");return}s==="opacityTexture"&&(e.useAlphaFromAlbedoTexture=!1),s==="metallicTexture"&&(e.useRoughnessFromMetallicTextureAlpha=!1,e.useRoughnessFromMetallicTextureGreen=!0,e.useMetallnessFromMetallicTextureBlue=!0),s==="refractionTexture"&&(e.subSurface.isRefractionEnabled=!0,e.subSurface.refractionIntensity=t.refractionIntensity||1),e[s]=i,s==="emissiveTexture"&&(e.emissiveColor=new p.Color3(1,1,1),e.emissiveIntensity=1)}function Ze(s,e){s.clearCoat&&(s.clearCoat===E.RemoveWhenSelected?(e.clearCoat.isEnabled=!1,e.clearCoat.indexOfRefraction=1.5):s.clearCoat===E.ApplyWhenSelected&&(e.clearCoat.isEnabled=!0,e.clearCoat.indexOfRefraction=s.clearCoatIOR||e.clearCoat.indexOfRefraction))}class $e{constructor(e,t,i){this.materialVariantMap=new Map,this.keysThatRemovedBaseModel=[],this.loadedContainerForKey=new Map,this.loadedMaterialsForKey=new Map,this.scene=e,this.renameClonedAsset=t,this.setBaseModelEnabled=i}async applyMaterial(e,t,i,o){return new Promise(a=>{const r=this.materialVariantMap.get(e);this.materialVariantMap.set(e,{...r,...t});const n=this.renameClonedAsset(e),l=this.scene.materials.filter(u=>u.name===n);if(l.length===0){a();return}const d=new Ie.AssetsManager(this.scene);d.useDefaultLoadingScreen=!1,l.forEach(u=>Ke(t,u,d,o)),d.onProgress=(u,m,f)=>{i&&i(u/m*100,100,f.name)},d.onFinish=u=>{u.forEach(m=>{const f=m;i&&i(100,100,m.name),this.scene.materials.filter(v=>v.name===n).forEach(v=>We(m.name,v,t,f.texture))}),a()},d.loadAsync()})}async applyModel(e,t,i,o){var l,d;if(i&&t&&!this.keysThatRemovedBaseModel.includes(e)&&this.keysThatRemovedBaseModel.push(e),!i)return this.keysThatRemovedBaseModel.includes(e)&&await this.setBaseModelEnabled(!0),(l=this.loadedContainerForKey.get(e))==null||l.dispose(),this.loadedContainerForKey.delete(e),this.loadedMaterialsForKey.delete(e),Promise.resolve(void 0);const r=(await H(i,this.scene,o)).instantiateModelsToScene(this.renameClonedAsset,!0);this.loadedContainerForKey.has(e)&&((d=this.loadedContainerForKey.get(e))==null||d.dispose(),this.loadedContainerForKey.delete(e),this.loadedMaterialsForKey.delete(e)),t&&await this.setBaseModelEnabled(!1),this.loadedContainerForKey.set(e,r),this.loadedMaterialsForKey.set(e,$(r));const n=[];return this.materialVariantMap.forEach(async(u,m)=>{n.push(this.applyMaterial(m,u))}),await Promise.all(n),r}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 $(s){const e=[];return s.rootNodes.forEach(t=>{t.getChildMeshes().forEach(i=>{i.material&&!e.includes(i.material)&&e.push(i.material),i.subMeshes&&i.subMeshes.forEach(o=>{const a=o.getMaterial(!1);a&&!e.includes(a)&&e.push(a)})})}),e}function Y(s,e=""){return s.map(t=>({name:t.name.substring(e.length),loop:t.loopAnimation,to:t.to,from:t.from}))}class Ye{constructor(e){this.metadata=new Map,this.materialSelectedObservable=new M.Observable,this.materialDeselectedObservable=new M.Observable,this.materialVariantObservable=new M.Observable,this.modelVariantObservable=new M.Observable,this.materialReadyToLoadCallbacks=new Map,this.modelReadyToLoadCallbacks=new Map,this.dynamicTextures=new Map,this.queuedMaterialChanges=new Map,this.materialChangesInProgress=[],this.queuedModelChanges=new Map,this.modelChangesInProgress=[],this.animations=[],this.initialized=!1,this.materials=[];const{enablePicking:t,modelDetails:i,previewService:o,progressHandler:a,scene:r}=e;this.enablePicking=t,this.contextService=i.contextService,this.id=Ve(),this.previewService=o,this.scene=r,this.variantManager=new $e(r,this.renameClonedAsset.bind(this),this.setBaseModelEnabled.bind(this)),this.transformRoot=new Ae.TransformNode("root",this.scene);const n=async()=>{if(!i.model)throw new Error("Model container constructed with no URL. This is currently unsupported.");return this.assetContainer=await H(i.model,r,a),this.initialized=!0,await this.instantiate(),this};this.importPromise=n()}async applyMaterialVariant(e,t,i,o){if(!this.initialized){if(this.materialReadyToLoadCallbacks.has(e)){const r=this.materialReadyToLoadCallbacks.get(e);r==null||r.set(t,this.applyMaterialVariant.bind(this,e,t,i,o))}else{this.materialReadyToLoadCallbacks.set(e,new Map);const r=this.materialReadyToLoadCallbacks.get(e);r==null||r.set(t,this.applyMaterialVariant.bind(this,e,t,i,o))}return}const a=async()=>{await this.variantManager.applyMaterial(e,i,(r,n,l)=>{this.materialVariantObservable.notifyObservers({remainingCount:r,totalCount:n,taskName:l})},o)};if(this.materialChangesInProgress.includes(e)){if(this.queuedMaterialChanges.has(e)){const r=this.queuedMaterialChanges.get(e);r==null||r.set(t,a)}else{this.queuedMaterialChanges.set(e,new Map);const r=this.queuedMaterialChanges.get(e);r==null||r.set(t,a)}return}if(this.materialChangesInProgress.push(e),await a(),this.queuedMaterialChanges.has(e)){const r=this.queuedMaterialChanges.get(e);if(!r)throw new Error("Target material is undefined");r.forEach(async n=>{await n()}),this.queuedMaterialChanges.delete(e)}this.materialChangesInProgress.splice(this.materialChangesInProgress.indexOf(e),1),this.configureGlowLayer()}async applyModelVariant(e,t,i){if(!this.initialized){this.modelReadyToLoadCallbacks.set(e,this.applyModelVariant.bind(this,e,t,i));return}const o=()=>this.variantManager.applyModel(e,i,t==null?void 0:t.model,n=>{this.modelVariantObservable.notifyObservers({...n,key:e})});if(this.modelChangesInProgress.includes(e)){this.queuedModelChanges.set(e,o);return}const r=await(async()=>{this.modelChangesInProgress.push(e);let n=await o();if(this.queuedModelChanges.has(e)){const l=this.queuedModelChanges.get(e);if(!l)throw new Error("Queued change resolved undefined");n=await l(),this.queuedModelChanges.delete(e)}return this.modelChangesInProgress.splice(this.modelChangesInProgress.indexOf(e),1),n})();this.modelInstance&&W(this.modelInstance.animationGroups),this.contextService||(this.contextService=t==null?void 0:t.contextService),r?this.configureModelInstance(r):this.configureGlowLayer()}dispose(){var e;this.destroyInstance(),this.variantManager.dispose(),this.dynamicTextures.forEach(t=>t==null?void 0:t.dispose()),this.dynamicTextures.clear(),this.materials.forEach(t=>t&&(t==null?void 0:t.dispose())),this.materials=[],(e=this.transformRoot)==null||e.dispose(),this.transformRoot=void 0,this.previewService.modelUnloaded(this)}executeAnimation(e){if(!this.previewService.getInitializationComplete()){this.queuedModelAnimation=e;return}this.modelInstance&&Ne([...this.modelInstance.animationGroups,...this.variantManager.getAnimationGroups()],e.loop,e.to,e.from,e.name?this.renameClonedAsset(e.name):void 0)}getAnimations(e){return[...this.animations,...e?Y(this.variantManager.getAnimationGroups(),this.renameClonedAsset("")):[]]}getId(){return this.id}listMaterials(){var t;const e=(t=this.scene)==null?void 0:t.materials.filter(i=>i.name.startsWith(this.id));return e?e.map(i=>({id:i.id,name:this.stripIdFromName(i.name)})):[]}registerMaterialSelectedCallback(e){this.materialSelectedObservable.add(e)}unregisterMaterialSelectedCallback(e){this.materialSelectedObservable.removeCallback(e)}registerMaterialDeselectedCallback(e){this.materialDeselectedObservable.add(e)}unregisterMaterialDeselectedCallback(e){this.materialDeselectedObservable.removeCallback(e)}get position(){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to requesting position!");return this.transformRoot.position}set position(e){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to setting position!");this.transformRoot.position=new g.Vector3(e.x,e.y,e.z)}get rotation(){var e;if(!((e=this.transformRoot)!=null&&e.rotationQuaternion))throw new Error("ModelContainer disposed prior to requesting rotation!");return this.transformRoot.rotationQuaternion.toEulerAngles()}set rotation(e){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to setting rotation!");this.transformRoot.rotationQuaternion=g.Quaternion.FromEulerAngles(e.x,e.y,e.z)}get scale(){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to requesting scale!");return this.transformRoot.scaling}set scale(e){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to setting scale!");this.transformRoot.scaling=new g.Vector3(e.x,e.y,e.z)}attachPickingHandler(e){e.rootNodes.forEach(t=>{t.getChildMeshes(!1).forEach(i=>{i.name==="targetcube_t"||i.name==="backgroundShell"||(i.actionManager||(i.actionManager=new O.ActionManager(this.scene)),i.actionManager.registerAction(new V.ExecuteCodeAction(O.ActionManager.OnPointerOverTrigger,o=>{o.meshUnderPointer&&i.material&&this.materialSelectedObservable.notifyObservers({id:i.material.id,name:this.stripIdFromName(i.material.name)})})),i.actionManager.registerAction(new V.ExecuteCodeAction(O.ActionManager.OnPointerOutTrigger,()=>{i.material&&this.materialDeselectedObservable.notifyObservers({id:i.material.id,name:this.stripIdFromName(i.material.name)})})))})})}getInitializationPromise(){return this.importPromise}getIsInitialized(){return this.initialized}getQueuedMaterialVariantCount(){return this.materialReadyToLoadCallbacks.size}getQueuedModelVariantCount(){return this.modelReadyToLoadCallbacks.size}configureGlowLayer(){const e=i=>i instanceof L.PBRMaterial&&i.emissiveTexture!==null;this.materials.some(e)||this.variantManager.getAllMaterials().some(e)?this.previewService.getGlowLayerManager().includeMeshes(this.getAllMeshes()):this.previewService.getGlowLayerManager().removeMeshes(this.getAllMeshes())}configureModelInstance(e){var a;if(!this.transformRoot)throw new Error("Transform disposed! This should never happen unless there is a race condition present!");const t=this.transformRoot.position,i=this.transformRoot.rotationQuaternion,o=this.transformRoot.scaling;this.transformRoot.position=g.Vector3.Zero(),this.transformRoot.rotationQuaternion=g.Quaternion.Identity(),this.transformRoot.scaling=g.Vector3.One();for(const r of e.rootNodes)r.parent=this.transformRoot;this.transformRoot.position=t,this.transformRoot.rotationQuaternion=i,this.transformRoot.scaling=o,this.canvasPanels=((a=this.contextService)==null?void 0:a.getAll())||new Map,De(this.materials.concat(this.variantManager.getAllMaterials()),this.scene,this.canvasPanels,this.dynamicTextures,`${this.id}_`),this.enablePicking&&this.attachPickingHandler(e),this.configureGlowLayer()}destroyInstance(){var e;(e=this.modelInstance)==null||e.dispose(),this.modelInstance=void 0}getAllMeshes(){var e;return(e=this.modelInstance)==null?void 0:e.rootNodes.map(t=>t.getChildMeshes(!1).filter(i=>i instanceof Ee.Mesh)).flat()}async instantiate(){if(!this.assetContainer)throw new Error("Attempted to instantiate ModelContainer without an AssetContainer");this.modelInstance=this.assetContainer.instantiateModelsToScene(this.renameClonedAsset.bind(this),!0),this.materials=$(this.modelInstance),this.configureModelInstance(this.modelInstance),this.animations=Y(this.modelInstance.animationGroups,this.renameClonedAsset("")),await this.processQueuedEvents()}renameClonedAsset(e){return`${this.id}_${e}`}async setBaseModelEnabled(e){e&&!this.modelInstance?await this.instantiate():!e&&this.modelInstance&&this.destroyInstance()}updateDynamicTextures(){var e;(e=this.canvasPanels)==null||e.forEach((t,i)=>{const o=this.dynamicTextures.get(i);o&&t.getStaticContextDirty()&&o.isReady()&&(o.update(!1),t.setStaticContextDirty(!1))})}registerMaterialVariantListener(e){this.materialVariantObservable.add(e)}unregisterMaterialVariantListener(e){this.materialVariantObservable.removeCallback(e)}registerModelVariantListener(e){this.modelVariantObservable.add(e)}unregisterModelVariantListener(e){this.modelVariantObservable.removeCallback(e)}stripIdFromName(e){return e.substring(this.id.length+1)}async processQueuedEvents(){await Promise.all(Array.from(this.materialReadyToLoadCallbacks.values()).flatMap(e=>Array.from(e.values()).map(t=>t()))),this.materialReadyToLoadCallbacks.clear(),await Promise.all(Array.from(this.modelReadyToLoadCallbacks.values()).map(e=>e())),this.modelReadyToLoadCallbacks.clear(),this.queuedModelAnimation&&(this.executeAnimation(this.queuedModelAnimation),this.queuedModelAnimation=void 0)}}class S extends y.ArcRotateCamera{constructor(e,t,i,o,a,r,n,l){super(e,t,i,o,a,r,l),this.lastFocus=new g.Vector3(0,0,0),this.panDenominator=1,this.minZ=.01,this.setRadius(this.radius),this.enableFramingBehavior(),this.wheelDeltaPercentage=.01,this.pinchDeltaPercentage=.005,this.useNaturalPinchZoom=!0,n.camera.autoOrientation&&(this.alpha+=Math.PI),n&&(n.camera.limits.min.beta&&(this.lowerBetaLimit=n.camera.limits.min.beta),n.camera.limits.max.beta&&(this.upperBetaLimit=n.camera.limits.max.beta),n.camera.limits.min.alpha&&(this.lowerAlphaLimit=n.camera.limits.min.alpha),n.camera.limits.max.alpha&&(this.upperAlphaLimit=n.camera.limits.max.alpha),n.camera.limits.min.radius&&(this.lowerRadiusLimit=n.camera.limits.min.radius),n.camera.limits.max.radius&&(this.upperRadiusLimit=n.camera.limits.max.radius),n.camera.autoRotation.enabled&&this.enableAutoRotationBehavior(n.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 o=()=>{e&&e()},a=F(this._scene),r=a.max.subtract(a.min),n=a.min.add(r.scale(.5));this.setRadius(r.length()*1.5),this.wheelPrecision=100/this.radius,this.panningInertia=0,this.panningOriginTarget.copyFrom(n),this.panDenominator=r.length(),i.zoomOnBoundingInfo(a.min,a.max,void 0,o),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 o=F(e),a=o.max.subtract(o.min),r=o.min.add(a.scale(.5)),n=new S("ProductCamera",-(Math.PI/2),Math.PI/2,a.length()*1.5,r,e,t);return n.panningInertia=0,n.panningOriginTarget.copyFrom(r),n.panDenominator=a.length(),n.onAfterCheckInputsObservable.add(()=>{n.panningSensibility=1e3/n.panDenominator}),i&&(e.activeCamera=n),n}}function F(s){if(s.meshes.length===0)return{min:new g.Vector3(-1,-1,-1),max:new g.Vector3(1,1,1)};const e=s.meshes.filter(t=>t.name.toLowerCase().endsWith("_t")||t.name.toLowerCase().includes("_t_"));return s.getWorldExtends(t=>t.isVisible&&t.isEnabled()&&(e.length===0||e.includes(t)))}class Xe{constructor(e,t=!1,i=void 0){this.renderingPipeline=new Se.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,o,a,r,n,l,d,u,m,f,b,v,X,J,_,ee,te,ie,se,re,ne,ae,oe,le,he,ce,de,ue,ge,me,pe,fe;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=((o=e.bloom)==null?void 0:o.enabled)??c.bloom.enabled,this.renderingPipeline.bloomKernel=((a=e.bloom)==null?void 0:a.kernel)??c.bloom.kernel,this.renderingPipeline.bloomScale=((r=e.bloom)==null?void 0:r.scale)??c.bloom.scale,this.renderingPipeline.bloomThreshold=((n=e.bloom)==null?void 0:n.threshold)??c.bloom.threshold,this.renderingPipeline.bloomWeight=((l=e.bloom)==null?void 0:l.weight)??c.bloom.weight,this.renderingPipeline.chromaticAberrationEnabled=((d=e.chromaticAberration)==null?void 0:d.enabled)??c.chromaticAberration.enabled,this.renderingPipeline.chromaticAberration.aberrationAmount=((u=e.chromaticAberration)==null?void 0:u.aberrationAmount)??c.chromaticAberration.aberrationAmount,this.renderingPipeline.chromaticAberration.radialIntensity=((m=e.chromaticAberration)==null?void 0:m.radialIntensity)??c.chromaticAberration.radialIntensity,this.renderingPipeline.chromaticAberration.direction=(f=e.chromaticAberration)!=null&&f.direction?new g.Vector2(e.chromaticAberration.direction.x,e.chromaticAberration.direction.y):new g.Vector2(c.chromaticAberration.direction.x,c.chromaticAberration.direction.y),this.renderingPipeline.imageProcessing.colorCurvesEnabled=((b=e.colorCurves)==null?void 0:b.enabled)??c.colorCurves.enabled,this.renderingPipeline.imageProcessing.colorCurves=e.colorCurves?this.updateColorCurve(e.colorCurves):new k.ColorCurves,this.renderingPipeline.depthOfFieldEnabled=((v=e.depthOfField)==null?void 0:v.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=((X=e.depthOfField)==null?void 0:X.focalLength)??c.depthOfField.focalLength,this.renderingPipeline.depthOfField.fStop=((J=e.depthOfField)==null?void 0:J.fStop)??c.depthOfField.fStop,this.renderingPipeline.depthOfField.focusDistance=((_=e.depthOfField)==null?void 0:_.focusDistance)??c.depthOfField.focusDistance,this.renderingPipeline.depthOfField.lensSize=((ee=e.depthOfField)==null?void 0:ee.lensSize)??c.depthOfField.lensSize,this.renderingPipeline.grainEnabled=((te=e.grain)==null?void 0:te.enabled)??c.grain.enabled,this.renderingPipeline.grain.animated=((ie=e.grain)==null?void 0:ie.animated)??c.grain.animated,this.renderingPipeline.grain.intensity=((se=e.grain)==null?void 0:se.intensity)??c.grain.intensity,this.renderingPipeline.imageProcessing.contrast=((re=e.misc)==null?void 0:re.contrast)??c.misc.contrast,this.renderingPipeline.imageProcessing.exposure=((ne=e.misc)==null?void 0:ne.exposure)??c.misc.exposure,this.renderingPipeline.imageProcessing.toneMappingEnabled=((ae=e.misc)==null?void 0:ae.toneMappingEnabled)??c.misc.toneMappingEnabled,this.renderingPipeline.imageProcessing.toneMappingEnabled)switch(e.misc.toneMappingType??c.misc.toneMappingType){case"Standard":this.renderingPipeline.imageProcessing.toneMappingType=T.ImageProcessingConfiguration.TONEMAPPING_STANDARD;break;case"ACES":this.renderingPipeline.imageProcessing.toneMappingType=T.ImageProcessingConfiguration.TONEMAPPING_ACES;break}if(this.renderingPipeline.sharpenEnabled=((oe=e.sharpen)==null?void 0:oe.enabled)??c.sharpen.enabled,this.renderingPipeline.sharpen.colorAmount=((le=e.sharpen)==null?void 0:le.colorAmount)??c.sharpen.colorAmount,this.renderingPipeline.sharpen.edgeAmount=((he=e.sharpen)==null?void 0:he.edgeAmount)??c.sharpen.edgeAmount,this.renderingPipeline.imageProcessing.vignetteEnabled=((ce=e.vignette)==null?void 0:ce.enabled)??c.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=c.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=c.vignette.center.y),e.vignette)switch(((ue=e.vignette)==null?void 0:ue.blendMode)??c.vignette.blendMode){case"Multiply":this.renderingPipeline.imageProcessing.vignetteBlendMode=T.ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY;break;case"Opaque":this.renderingPipeline.imageProcessing.vignetteBlendMode=T.ImageProcessingConfiguration.VIGNETTEMODE_OPAQUE;break}(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(c.vignette.colorRgba.r,c.vignette.colorRgba.g,c.vignette.colorRgba.b,c.vignette.colorRgba.a),this.renderingPipeline.imageProcessing.vignetteStretch=((pe=e.vignette)==null?void 0:pe.stretch)??c.vignette.stretch,this.renderingPipeline.imageProcessing.vignetteWeight=((fe=e.vignette)==null?void 0:fe.weight)??c.vignette.weight,this.renderingPipeline.prepare(),this.currentConfiguration=e}}updateColorCurve(e){const t=new k.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}}xe.GLTF2.GLTFLoader.RegisterExtension("glbPostProcessor",function(s){return new Be(s)}),q.SceneLoader.OnPluginActivatedObservable.add(s=>{if(s.name==="gltf"){const e=s;e.transparencyAsCoverage=!0}});function B(s){return new g.Vector3(s.x,s.y,s.z)}function j(s){return{x:s.x,y:s.y,z:s.z}}class Je{constructor(e){var n;this.focusLostNotified=!1,this.focusLostObservable=new M.Observable,this.modelLoadEventCallbacks=[],this.modelContainers=new Map,this.plugins=[],this.initComplete=!1,this.renderLoop=()=>{this.engine.views&&(this.modelContainers.forEach(l=>{l.updateDynamicTextures()}),this.configuration.scene.transparentBackground&&this.engine.views.forEach(l=>{const d=this.engine.getRenderingCanvas(),u=l.target.getContext("2d");if(!d)throw new Error("Could not access rendering canvas");if(!u)throw new Error("Could not access 2D context for view target");u.clearRect(0,0,d.width,d.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))},this.configuration=new Fe(e);const i=(()=>{if(!(e!=null&&e.noRender))return this.configuration.createCanvas()})(),o="1.5.6";Ce.DracoCompression.Configuration={decoder:{wasmUrl:`https://www.gstatic.com/draco/versioned/decoders/${o}/draco_wasm_wrapper_gltf.js`,wasmBinaryUrl:`https://www.gstatic.com/draco/versioned/decoders/${o}/draco_decoder_gltf.wasm`,fallbackUrl:`https://www.gstatic.com/draco/versioned/decoders/${o}/draco_decoder_gltf.js`}},i&&(i.getContext("webgl2")||i.getContext("webgl"));const a=console.log;console.log=()=>{};const r=i?new D.Engine(i,!0,{adaptToDeviceRatio:!0,limitDeviceRatio:2,premultipliedAlpha:!1,preserveDrawingBuffer:!!(e!=null&&e.backgroundImage),audioEngine:!1,stencil:this.configuration.highlights.enabled,forceSRGBBufferSupportState:!0}):new be.NullEngine;console.log=a,r.hideLoadingUI(),window.addEventListener("resize",this.fireResizeEvent.bind(this)),this.engine=r,this.scene=new Me.Scene(r),this.camera=S.create(this.scene,this.configuration),this.scene.activeCamera=this.camera,this.renderingPipeline=new Xe(this.scene,!1,this.camera),this.scene.clearColor=this.configuration.scene.clearColor,this.scene.environmentTexture=we.CubeTexture.CreateFromPrefilteredData(this.configuration.scene.environmentFile,this.scene),(n=this.configuration.options)!=null&&n.renderingPipelineConfiguration&&this.renderingPipeline.setConfiguration(this.configuration.options.renderingPipelineConfiguration),this.scene.imageProcessingConfiguration.exposure=this.configuration.lighting.exposure,this.scene.imageProcessingConfiguration.contrast=this.configuration.lighting.contrast,this.glowLayerManager=new je(this.scene,this.configuration.emissiveGlowIntensity),this.initPromise=new Promise(l=>{this.scene.onReadyObservable.addOnce(()=>{this.initComplete=!0,l()})}),this.engine.runRenderLoop(this.renderLoop)}getInitializationPromise(){return this.initPromise}getInitializationComplete(){return this.initComplete}getEngineContext(){return{engine:this.engine,scene:this.scene,camera:this.camera}}registerFocusLostListener(e){this.focusLostObservable.add(e)}unregisterFocusLostListener(e){this.focusLostObservable.removeCallback(e)}registerModelLoadEventListener(e){this.modelLoadEventCallbacks.push(e)}unregisterModelLoadEventListener(e){const t=this.modelLoadEventCallbacks.indexOf(e);t>-1&&this.modelLoadEventCallbacks.splice(t,1)}registerView(e){const t=e.height,i=e.width;this.engine.registerView(e),e.setAttribute("height",t.toString()),e.setAttribute("width",i.toString()),this.orbitEnabled()||this.setCameraState(R.Pan),this.reattachControls(e)}getNumViewports(){var e;return((e=this.engine.views)==null?void 0:e.length)||0}unregisterView(e){this.engine.unRegisterView(e)}shutdown(){this.plugins.forEach(e=>e.dispose(!0)),this.renderingPipeline.dispose(),this.engine&&this.engine.dispose(),window.removeEventListener("resize",this.fireResizeEvent)}executeCameraAnimation(e){if(!this.camera||this.scene.activeCamera!==this.camera){this.queuedCameraAnimation=e;return}ze(this.scene,this.scene.activeCamera,e)}getCameraPose(){if(this.scene&&this.camera)return{lonDeg:Math.round(this.camera.alpha*180/Math.PI),latDeg:Math.round(this.camera.beta*180/Math.PI),radius:Math.round((this.camera.radius+Number.EPSILON)*1e4)/1e4,target:{x:this.camera.target.x,y:this.camera.target.y,z:this.camera.target.z}}}setCameraPose(e){this.scene&&this.camera&&(this.camera.target=new g.Vector3(e.target.x,e.target.y,e.target.z),this.camera.radius=e.radius,this.camera.alpha=e.latDeg,this.camera.beta=e.lonDeg)}setCameraState(e){var t,i;if(!((t=this.engine)!=null&&t.views)||!((i=this.engine)!=null&&i.views[0]))throw new Error("No views attached, camera state requires a view to attach controls onto.");e===R.Orbit?this.reattachControls(this.engine.views[0].target,2):this.reattachControls(this.engine.views[0].target,0)}animateToLastCameraFocus(){return new Promise(e=>{const t=()=>{const i=this.configuration;this.camera.rerunFramingBehavior(()=>{this.focusLostNotified=!1,i.camera.limits.min.radius&&(this.camera.lowerRadiusLimit=i.camera.limits.min.radius),i.camera.limits.max.radius&&(this.camera.upperRadiusLimit=i.camera.limits.max.radius),e()})};this.scene.onAfterRenderObservable.addOnce(t)})}setAutoRotation(e){!this.configuration.camera.autoRotation.enabled||!this.camera||(e?this.camera.enableAutoRotationBehavior(this.configuration.camera.autoRotation.idleTimeMs):this.camera.disableAutoRotationBehavior())}getCurrentConfiguration(){return this.configuration.options}async renderSceneScreenshot(e,t){if(!this.camera)throw new Error("Missing product camera, cannot render screenshot!");const i=new y.ArcRotateCamera("screenshotCamera",0,0,0,g.Vector3.Zero(),this.scene);try{const o=t.latDeg*Math.PI/180,a=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=a,i.beta=o,i.radius=t.radius||this.camera.radius,i.minZ=.01,this.scene.render();const r=await ve.Tools.CreateScreenshotUsingRenderTargetAsync(this.engine,i,e,"image/png",2,!0);return i.dispose(),r}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,o=e.camera.limits.min.beta,a=e.camera.limits.max.beta;if(t===void 0||i===void 0||o===void 0||a===void 0)return!0;const r=[t,i],n=[o,a],l=r.every(u=>u===t),d=n.every(u=>u===o);return!l&&!d}fireResizeEvent(){this.getNumViewports()>0&&this.engine.resize()}setHighlights(e,t){var o;e.length===0&&((o=this.highlightLayer)==null||o.dispose(),this.highlightLayer=void 0),this.highlightLayer||(this.highlightLayer=new ye.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(a=>{const r=this.scene.materials.find(n=>n.name===a.name&&n.id===a.id);r&&r.getBindedMeshes().forEach(n=>{var l;return(l=this.highlightLayer)==null?void 0:l.addMesh(n,i||p.Color3.FromHexString("#fcba03"))})})}setRenderingPipelineConfiguration(e){this.renderingPipeline&&this.renderingPipeline.setConfiguration(e)}loadModel(e,t){const i=new Ye({enablePicking:this.configuration.highlights.enabled,modelDetails:e,scene:this.scene,previewService:this,progressHandler:t});return i.getInitializationPromise().then(()=>{this.modelContainers.size<=1&&this.camera.rerunFramingBehavior(void 0,1),ke(this.scene),this.queuedCameraAnimation&&(this.executeCameraAnimation(this.queuedCameraAnimation),this.queuedCameraAnimation=void 0)}),this.configuration.highlights.enabled&&(i.registerMaterialSelectedCallback(o=>{this.setHighlights([o])}),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(o=>o.dispose(!1))}getGlowLayerManager(){return this.glowLayerManager}modelUnloaded(e){this.modelContainers.delete(e.getId()),this.triggerModelLoadEvent({eventType:"unload",modelContainer:e})}triggerModelLoadEvent(e){this.modelLoadEventCallbacks.forEach(t=>t(e))}flipTransform(e,t,i){const o=g.Matrix.Compose(B(i||{x:1,y:1,z:1}),g.Quaternion.FromEulerVector(B(t||{x:0,y:0,z:0})),B(e||{x:0,y:0,z:0})),a=g.Matrix.RotationAxis(g.Vector3.Up(),Math.PI),r=o.multiply(a),n=g.Vector3.Zero(),l=g.Quaternion.Identity(),d=g.Vector3.Zero();return r.decompose(d,l,n),l.multiplyInPlace(g.Quaternion.FromEulerAngles(0,Math.PI,0)),{position:j(n),rotation:j(l.toEulerAngles()),scale:j(d)}}reattachControls(e,t=2){if(this.scene.detachControl(),this.engine.inputElement=e,this.camera){this.camera.attachControl(!0,!1,t);const i=this.camera.inputs.attached.pointers;i.multiTouchPanning=!1}this.scene.attachControl(!0,!0,!0)}}h.MaterialEffectMode=E,h.ProductCameraRig=R,h.REFLECTION_PROBE_RESOLUTION=z,h.RenderingConfiguration=C,h.SpiffCommerce3DPreviewService=Je,h.renderingPipelineDefaults=c,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED