@spiffcommerce/preview 5.6.1 → 5.7.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +23 -3
- package/dist/index.esm.js +179 -175
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Engine } from '@babylonjs/core/Engines/engine';
|
|
2
1
|
import { ISceneLoaderProgressEvent } from '@babylonjs/core/Loading/sceneLoader';
|
|
2
|
+
import { Engine } from '@babylonjs/core/Engines/engine';
|
|
3
3
|
import { Scene } from '@babylonjs/core/scene';
|
|
4
4
|
import { Mesh } from '@babylonjs/core/Meshes/mesh';
|
|
5
5
|
import { AutoRotationBehavior } from '@babylonjs/core/Behaviors/Cameras/autoRotationBehavior';
|
|
@@ -174,9 +174,20 @@ type ThreeDPreviewService = {
|
|
|
174
174
|
/**
|
|
175
175
|
* Loads a model into the scene.
|
|
176
176
|
* @param modelDetails The details of the model to load.
|
|
177
|
+
* @param options Optional configuration.
|
|
177
178
|
* @returns A reference to the model container. Call `getInitializationPromise()` to wait for the model to be loaded.
|
|
178
179
|
*/
|
|
179
|
-
loadModel(modelDetails: ModelDetails
|
|
180
|
+
loadModel(modelDetails: ModelDetails, options?: {
|
|
181
|
+
/**
|
|
182
|
+
* When true, camera will automatically animate to the model after it loads.
|
|
183
|
+
* @default true
|
|
184
|
+
*/
|
|
185
|
+
refocusCamera?: boolean;
|
|
186
|
+
/**
|
|
187
|
+
* An event handler that is called when loading progress changes.
|
|
188
|
+
*/
|
|
189
|
+
progressHandler?: (event: ISceneLoaderProgressEvent) => void;
|
|
190
|
+
}): ModelContainer;
|
|
180
191
|
/**
|
|
181
192
|
* Preloads a model into the scene. This will load the model into memory, but it will not be visible in the scene.
|
|
182
193
|
* @param url The url of the model to preload.
|
|
@@ -208,6 +219,11 @@ type ThreeDPreviewService = {
|
|
|
208
219
|
* @param options The options to apply.
|
|
209
220
|
*/
|
|
210
221
|
updatePreviewOptions(options: PreviewOptions): void;
|
|
222
|
+
/**
|
|
223
|
+
* Forces the camera to stop any animations that are currently running.
|
|
224
|
+
* Note this will not resolve any existing promises.
|
|
225
|
+
*/
|
|
226
|
+
forceStopCameraAnimations(): void;
|
|
211
227
|
};
|
|
212
228
|
/**
|
|
213
229
|
* Represents a service capable of managing and returning contexts that
|
|
@@ -1101,6 +1117,7 @@ declare class SpiffCommerce3DPreviewService implements ThreeDPreviewService {
|
|
|
1101
1117
|
setCameraPose(cameraPose: CameraPose): void;
|
|
1102
1118
|
setCameraState(rigType: ProductCameraRig): void;
|
|
1103
1119
|
animateToLastCameraFocus(): Promise<void>;
|
|
1120
|
+
forceStopCameraAnimations(): void;
|
|
1104
1121
|
setAutoRotation(shouldAutoRotate: boolean): void;
|
|
1105
1122
|
getCurrentConfiguration(): PreviewOptions | undefined;
|
|
1106
1123
|
renderSceneScreenshot(resolution: number, camAnim: CameraAnimation): Promise<string>;
|
|
@@ -1108,7 +1125,10 @@ declare class SpiffCommerce3DPreviewService implements ThreeDPreviewService {
|
|
|
1108
1125
|
fireResizeEvent(): void;
|
|
1109
1126
|
setHighlights(materials: readonly MaterialHandle[], color?: readonly [number, number, number]): void;
|
|
1110
1127
|
setRenderingPipelineConfiguration(renderingPipelineConfiguration: RenderingPipelineConfiguration): void;
|
|
1111
|
-
loadModel(modelDetails: ModelDetails,
|
|
1128
|
+
loadModel(modelDetails: ModelDetails, options?: {
|
|
1129
|
+
refocusCamera?: boolean;
|
|
1130
|
+
progressHandler?: (event: ISceneLoaderProgressEvent) => void;
|
|
1131
|
+
}): ModelContainer;
|
|
1112
1132
|
preloadModel(url: string): Promise<void>;
|
|
1113
1133
|
getAllModels(): ReadonlyArray<ModelContainer>;
|
|
1114
1134
|
getModelById(id: string): ModelContainer | undefined;
|
package/dist/index.esm.js
CHANGED
|
@@ -6,9 +6,9 @@ import { SceneLoader as S } from "@babylonjs/core/Loading/sceneLoader";
|
|
|
6
6
|
import { CubeTexture as ne } from "@babylonjs/core/Materials/Textures/cubeTexture";
|
|
7
7
|
import { Color4 as b, Color3 as w } from "@babylonjs/core/Maths/math.color";
|
|
8
8
|
import { Vector3 as p, Quaternion as y, Vector2 as se, Matrix as re } from "@babylonjs/core/Maths/math.vector";
|
|
9
|
-
import { DracoCompression as
|
|
9
|
+
import { DracoCompression as Ae } 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 Me } from "@babylonjs/core/Misc/tools";
|
|
12
12
|
import { Scene as Pe } from "@babylonjs/core/scene";
|
|
13
13
|
import { GLTF2 as xe } from "@babylonjs/loaders/glTF";
|
|
14
14
|
import { GLTFLoaderAnimationStartMode as Re } from "@babylonjs/loaders/glTF/glTFFileLoader";
|
|
@@ -25,10 +25,10 @@ import { DynamicTexture as Be } from "@babylonjs/core/Materials/Textures/dynamic
|
|
|
25
25
|
import { Texture as De } from "@babylonjs/core/Materials/Textures/texture";
|
|
26
26
|
import { Animation as v } from "@babylonjs/core/Animations/animation";
|
|
27
27
|
import { QuadraticEase as ke, EasingFunction as ze } from "@babylonjs/core/Animations/easing";
|
|
28
|
-
import { AssetsManager as
|
|
28
|
+
import { AssetsManager as qe } from "@babylonjs/core/Misc/assetsManager";
|
|
29
29
|
import { ColorCurves as le } from "@babylonjs/core/Materials/colorCurves";
|
|
30
30
|
import { ImageProcessingConfiguration as P } from "@babylonjs/core/Materials/imageProcessingConfiguration";
|
|
31
|
-
import { DefaultRenderingPipeline as
|
|
31
|
+
import { DefaultRenderingPipeline as Ve } from "@babylonjs/core/PostProcesses/RenderPipeline";
|
|
32
32
|
import { DepthOfFieldEffectBlurLevel as E } from "@babylonjs/core/PostProcesses/depthOfFieldEffect";
|
|
33
33
|
import "@babylonjs/core/Rendering/depthRendererSceneComponent";
|
|
34
34
|
import "@babylonjs/core/Engines/Extensions/engine.views";
|
|
@@ -40,31 +40,31 @@ import "@babylonjs/core/Animations/animatable";
|
|
|
40
40
|
import "@babylonjs/core/Misc/screenshotTools";
|
|
41
41
|
import "@babylonjs/core/Rendering/boundingBoxRenderer";
|
|
42
42
|
import "@babylonjs/loaders/glTF/2.0/Extensions";
|
|
43
|
-
var I = /* @__PURE__ */ ((
|
|
43
|
+
var I = /* @__PURE__ */ ((s) => (s[s.Orbit = 0] = "Orbit", s[s.Pan = 1] = "Pan", s))(I || {}), F = /* @__PURE__ */ ((s) => (s.None = "None", s.RemoveWhenSelected = "RemoveWhenSelected", s.ApplyWhenSelected = "ApplyWhenSelected", s))(F || {});
|
|
44
44
|
const he = /* @__PURE__ */ new Map();
|
|
45
|
-
async function D(
|
|
46
|
-
const i = he.get(
|
|
45
|
+
async function D(s, e, t) {
|
|
46
|
+
const i = he.get(s);
|
|
47
47
|
if (i)
|
|
48
48
|
return i;
|
|
49
49
|
{
|
|
50
50
|
const r = S.LoadAssetContainerAsync(
|
|
51
|
-
|
|
51
|
+
s,
|
|
52
52
|
void 0,
|
|
53
53
|
e,
|
|
54
54
|
t
|
|
55
55
|
);
|
|
56
|
-
return he.set(
|
|
56
|
+
return he.set(s, r), r;
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
S.OnPluginActivatedObservable.add((
|
|
60
|
-
|
|
59
|
+
S.OnPluginActivatedObservable.add((s) => {
|
|
60
|
+
s.name === "gltf" && (s.animationStartMode = Re.NONE);
|
|
61
61
|
});
|
|
62
62
|
class ce {
|
|
63
63
|
constructor(e) {
|
|
64
64
|
this.getSceneClearColor = () => {
|
|
65
|
-
var i, r,
|
|
65
|
+
var i, r, n, o;
|
|
66
66
|
const t = (i = this.customOptions) != null && i.transparentBackground || (r = this.customOptions) != null && r.backgroundImage ? 0 : 1;
|
|
67
|
-
if (this.customOptions && ((
|
|
67
|
+
if (this.customOptions && ((n = this.customOptions) != null && n.transparentBackground) || (o = this.customOptions) != null && o.backgroundImage)
|
|
68
68
|
return new b(0, 0, 0, t).toLinearSpace();
|
|
69
69
|
if (this.customOptions && this.customOptions.backgroundColor) {
|
|
70
70
|
const a = w.FromHexString(
|
|
@@ -99,14 +99,14 @@ class ce {
|
|
|
99
99
|
* Configuration related to the scene
|
|
100
100
|
*/
|
|
101
101
|
get scene() {
|
|
102
|
-
var e, t, i, r,
|
|
102
|
+
var e, t, i, r, n;
|
|
103
103
|
return {
|
|
104
104
|
clearColor: this.getSceneClearColor(),
|
|
105
105
|
transparentBackground: ((e = this.customOptions) == null ? void 0 : e.transparentBackground) || ((t = this.customOptions) == null ? void 0 : t.backgroundImage),
|
|
106
106
|
environment: {
|
|
107
107
|
file: ((i = this.customOptions) == null ? void 0 : i.environmentFile) ?? "assets/model-viewer/default.env",
|
|
108
108
|
intensity: ((r = this.customOptions) == null ? void 0 : r.environmentIntensity) ?? 1,
|
|
109
|
-
rotationY: (((
|
|
109
|
+
rotationY: (((n = this.customOptions) == null ? void 0 : n.environmentRotationY) ?? 0) * (Math.PI / 180)
|
|
110
110
|
// Convert to radians
|
|
111
111
|
}
|
|
112
112
|
};
|
|
@@ -115,7 +115,7 @@ class ce {
|
|
|
115
115
|
* Configuration related to the camera used to view and interact with the scene.
|
|
116
116
|
*/
|
|
117
117
|
get camera() {
|
|
118
|
-
var e, t, i, r,
|
|
118
|
+
var e, t, i, r, n, o, a, l, c, h, u, m, g;
|
|
119
119
|
return {
|
|
120
120
|
autoOrientation: ((e = this.customOptions) == null ? void 0 : e.disableAutomaticOrientation) ?? !0,
|
|
121
121
|
autoRotation: {
|
|
@@ -124,7 +124,7 @@ class ce {
|
|
|
124
124
|
},
|
|
125
125
|
limits: {
|
|
126
126
|
min: {
|
|
127
|
-
alpha: (r = this.customOptions) != null && r.lowerAlphaLimitDeg ? ((
|
|
127
|
+
alpha: (r = this.customOptions) != null && r.lowerAlphaLimitDeg ? ((n = this.customOptions) == null ? void 0 : n.lowerAlphaLimitDeg) * Math.PI / 180 : void 0,
|
|
128
128
|
beta: (o = this.customOptions) != null && o.lowerBetaLimitDeg ? ((a = this.customOptions) == null ? void 0 : a.lowerBetaLimitDeg) * Math.PI / 180 : void 0,
|
|
129
129
|
radius: (l = this.customOptions) == null ? void 0 : l.minZoomOverride
|
|
130
130
|
},
|
|
@@ -159,12 +159,12 @@ class ce {
|
|
|
159
159
|
return ((e = this.customOptions) == null ? void 0 : e.emissiveGlowIntensity) ?? 0.5;
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
|
-
class
|
|
162
|
+
class M {
|
|
163
163
|
/**
|
|
164
164
|
* Returns the resolution expected for generated textures.
|
|
165
165
|
*/
|
|
166
166
|
static getDynamicTextureResolution() {
|
|
167
|
-
return this.getIsMobile() || !
|
|
167
|
+
return this.getIsMobile() || !M.offscreenRenderingSupported() ? {
|
|
168
168
|
width: 1024,
|
|
169
169
|
height: 1024
|
|
170
170
|
} : {
|
|
@@ -273,9 +273,9 @@ class Ge {
|
|
|
273
273
|
e,
|
|
274
274
|
t,
|
|
275
275
|
function(r) {
|
|
276
|
-
t.extras && Object.keys(t.extras).forEach((
|
|
277
|
-
const o = t.extras[
|
|
278
|
-
r.metadata[
|
|
276
|
+
t.extras && Object.keys(t.extras).forEach((n) => {
|
|
277
|
+
const o = t.extras[n];
|
|
278
|
+
r.metadata[n] = o;
|
|
279
279
|
}), i(r);
|
|
280
280
|
}
|
|
281
281
|
);
|
|
@@ -334,51 +334,51 @@ class Ge {
|
|
|
334
334
|
* @param scene The scene to parse.
|
|
335
335
|
*/
|
|
336
336
|
applyReflections(e) {
|
|
337
|
-
function t(
|
|
337
|
+
function t(n) {
|
|
338
338
|
const o = [];
|
|
339
|
-
return
|
|
339
|
+
return n.transformNodes.forEach((a) => {
|
|
340
340
|
a.metadata && a.metadata.reflective && o.push(...a.getChildMeshes());
|
|
341
|
-
}),
|
|
341
|
+
}), n.meshes.forEach((a) => {
|
|
342
342
|
a.metadata && a.metadata.reflective && !o.includes(a) && o.push(a);
|
|
343
343
|
}), o;
|
|
344
344
|
}
|
|
345
|
-
function i(
|
|
346
|
-
const a =
|
|
345
|
+
function i(n, o = 1) {
|
|
346
|
+
const a = n.material;
|
|
347
347
|
if (!a)
|
|
348
348
|
return;
|
|
349
349
|
const l = new Ee(
|
|
350
350
|
"mirror",
|
|
351
|
-
|
|
351
|
+
M.getMirrorTextureResolution(),
|
|
352
352
|
e,
|
|
353
353
|
!0
|
|
354
354
|
);
|
|
355
355
|
l.renderList = t(e);
|
|
356
|
-
const c =
|
|
356
|
+
const c = n.getVerticesData("normal");
|
|
357
357
|
if (!c)
|
|
358
358
|
throw new Error(
|
|
359
|
-
"Mirror attribute specified on: " +
|
|
359
|
+
"Mirror attribute specified on: " + n.name + "But no normals exist to generate a mirror from!"
|
|
360
360
|
);
|
|
361
|
-
|
|
362
|
-
const h =
|
|
361
|
+
n.computeWorldMatrix(!0);
|
|
362
|
+
const h = n.getWorldMatrix(), u = ae.TransformNormal(
|
|
363
363
|
new ae(c[0], c[1], c[2]),
|
|
364
364
|
h
|
|
365
365
|
).normalize(), m = Oe.FromPositionAndNormal(
|
|
366
|
-
|
|
366
|
+
n.position,
|
|
367
367
|
u.scale(-1)
|
|
368
368
|
);
|
|
369
369
|
l.mirrorPlane = m, l.level = o, a.reflectionTexture = l;
|
|
370
370
|
}
|
|
371
|
-
function r(
|
|
372
|
-
const o =
|
|
371
|
+
function r(n) {
|
|
372
|
+
const o = n.material, a = new Le(
|
|
373
373
|
"probe-" + o.name,
|
|
374
374
|
Ne,
|
|
375
375
|
e
|
|
376
376
|
);
|
|
377
|
-
a.attachToMesh(
|
|
377
|
+
a.attachToMesh(n), a.renderList && a.renderList.push(...t(e)), o.reflectionTexture = a.cubeTexture;
|
|
378
378
|
}
|
|
379
|
-
e.meshes.forEach((
|
|
380
|
-
const o =
|
|
381
|
-
o && (o.mirrorTexture && i(
|
|
379
|
+
e.meshes.forEach((n) => {
|
|
380
|
+
const o = n.metadata;
|
|
381
|
+
o && (o.mirrorTexture && i(n, o.mirrorTexture), o.reflectionProbe && r(n));
|
|
382
382
|
});
|
|
383
383
|
}
|
|
384
384
|
}
|
|
@@ -404,10 +404,10 @@ class _e {
|
|
|
404
404
|
}
|
|
405
405
|
}
|
|
406
406
|
}
|
|
407
|
-
function He(
|
|
408
|
-
t.forEach((
|
|
409
|
-
const o =
|
|
410
|
-
|
|
407
|
+
function He(s, e, t, i, r = "") {
|
|
408
|
+
t.forEach((n) => {
|
|
409
|
+
const o = n.getID(), a = n.getName(), l = M.getDynamicTextureResolution();
|
|
410
|
+
s.filter((h) => h.name === r + a).forEach((h) => {
|
|
411
411
|
const u = i.get(o), m = !1;
|
|
412
412
|
if (u)
|
|
413
413
|
de(h, u), u.update(m);
|
|
@@ -418,7 +418,7 @@ function He(n, e, t, i, r = "") {
|
|
|
418
418
|
l.width,
|
|
419
419
|
l.height
|
|
420
420
|
);
|
|
421
|
-
i.set(o, g),
|
|
421
|
+
i.set(o, g), n.setStaticContext(
|
|
422
422
|
g.getContext()
|
|
423
423
|
), de(h, g), g.onLoadObservable.addOnce(() => {
|
|
424
424
|
g.update(m);
|
|
@@ -427,45 +427,45 @@ function He(n, e, t, i, r = "") {
|
|
|
427
427
|
});
|
|
428
428
|
});
|
|
429
429
|
}
|
|
430
|
-
function Ke(
|
|
430
|
+
function Ke(s, e, t, i) {
|
|
431
431
|
const r = new Be(
|
|
432
|
-
|
|
432
|
+
s,
|
|
433
433
|
{ width: t, height: i },
|
|
434
434
|
e,
|
|
435
|
-
|
|
435
|
+
M.shouldMipMap(),
|
|
436
436
|
De.TRILINEAR_SAMPLINGMODE,
|
|
437
437
|
be.TEXTUREFORMAT_RGBA
|
|
438
|
-
),
|
|
439
|
-
return
|
|
438
|
+
), n = r.getContext();
|
|
439
|
+
return n && (n.fillStyle = "#f5f5f5", n.fillRect(0, 0, t, i), r.update()), r;
|
|
440
440
|
}
|
|
441
|
-
function de(
|
|
442
|
-
if (
|
|
443
|
-
const t =
|
|
441
|
+
function de(s, e) {
|
|
442
|
+
if (s instanceof B) {
|
|
443
|
+
const t = s, i = t.albedoTexture;
|
|
444
444
|
i ? (e.wrapU = i.wrapU, e.wrapV = i.wrapV) : (e.wrapU = 1, e.wrapV = 1), t.albedoTexture = e;
|
|
445
445
|
} else {
|
|
446
|
-
const t =
|
|
446
|
+
const t = s, i = t.diffuseTexture;
|
|
447
447
|
i && (e.wrapU = i.wrapU, e.wrapV = i.wrapV), t.diffuseTexture = e;
|
|
448
448
|
}
|
|
449
449
|
}
|
|
450
450
|
function Ue() {
|
|
451
|
-
const
|
|
452
|
-
return
|
|
451
|
+
const s = () => Math.floor((1 + Math.random()) * 65536).toString(16).substring(1);
|
|
452
|
+
return s() + s() + "-" + s() + "-" + s() + "-" + s() + "-" + s() + s() + s();
|
|
453
453
|
}
|
|
454
|
-
const
|
|
455
|
-
function me(
|
|
456
|
-
return
|
|
454
|
+
const A = 60, ue = 1;
|
|
455
|
+
function me(s) {
|
|
456
|
+
return s.targetedAnimations.map((t) => t.animation.framePerSecond).reduce((t, i) => t + i, 0) / s.targetedAnimations.length || 0;
|
|
457
457
|
}
|
|
458
|
-
function ve(
|
|
459
|
-
const o = r ?
|
|
458
|
+
function ve(s, e, t, i, r, n) {
|
|
459
|
+
const o = r ? s.filter((h) => h.name === r) : s;
|
|
460
460
|
if (o.length === 0) {
|
|
461
461
|
console.warn(`No animations found for name: ${r}`);
|
|
462
462
|
return;
|
|
463
463
|
}
|
|
464
464
|
let a = 0;
|
|
465
465
|
const l = () => {
|
|
466
|
-
a++, a === o.length &&
|
|
466
|
+
a++, a === o.length && n && n();
|
|
467
467
|
}, c = (h, u, m, g, f) => {
|
|
468
|
-
h.stop(), h.start(u, m, g, f),
|
|
468
|
+
h.stop(), h.start(u, m, g, f), n && (u == !1 || u === void 0 && !h.loopAnimation ? h.onAnimationGroupEndObservable.addOnce(() => {
|
|
469
469
|
l();
|
|
470
470
|
}) : h.onAnimationLoopObservable.addOnce(() => {
|
|
471
471
|
l();
|
|
@@ -483,10 +483,10 @@ function ve(n, e, t, i, r, s) {
|
|
|
483
483
|
c(h, e, ue, m, g);
|
|
484
484
|
});
|
|
485
485
|
}
|
|
486
|
-
function We(
|
|
486
|
+
function We(s, e, t) {
|
|
487
487
|
return new Promise((i) => {
|
|
488
|
-
|
|
489
|
-
const r = [],
|
|
488
|
+
s.stopAnimation(e), e.animations = [], Math.abs(e.alpha) > 2 * Math.PI && (e.alpha = Ye(e.alpha, 0, 2 * Math.PI));
|
|
489
|
+
const r = [], n = t.target, o = 0, a = n ? 1 : 0;
|
|
490
490
|
if (t.target && Object.keys(t.target).length > 0 && r.push(
|
|
491
491
|
x(
|
|
492
492
|
"cameraTargetLerp",
|
|
@@ -533,10 +533,10 @@ function We(n, e, t) {
|
|
|
533
533
|
}
|
|
534
534
|
e.animations.push(...r);
|
|
535
535
|
const c = e.useAutoRotationBehavior;
|
|
536
|
-
e.disableAutoRotationBehavior(),
|
|
536
|
+
e.disableAutoRotationBehavior(), s.beginAnimation(
|
|
537
537
|
e,
|
|
538
538
|
0,
|
|
539
|
-
|
|
539
|
+
n ? A * 2 : A,
|
|
540
540
|
!1,
|
|
541
541
|
1,
|
|
542
542
|
() => {
|
|
@@ -545,29 +545,29 @@ function We(n, e, t) {
|
|
|
545
545
|
);
|
|
546
546
|
});
|
|
547
547
|
}
|
|
548
|
-
function ge(
|
|
549
|
-
return
|
|
548
|
+
function ge(s) {
|
|
549
|
+
return s * Math.PI / 180;
|
|
550
550
|
}
|
|
551
|
-
function x(
|
|
551
|
+
function x(s, e, t, i, r, n = 0, o = v.ANIMATIONLOOPMODE_CONSTANT) {
|
|
552
552
|
const a = new ke();
|
|
553
553
|
a.setEasingMode(ze.EASINGMODE_EASEINOUT);
|
|
554
554
|
const l = new v(
|
|
555
|
-
|
|
555
|
+
s,
|
|
556
556
|
e,
|
|
557
|
-
|
|
557
|
+
A,
|
|
558
558
|
r,
|
|
559
559
|
o
|
|
560
560
|
), c = [];
|
|
561
|
-
return
|
|
562
|
-
frame:
|
|
561
|
+
return n > 0 && c.push({ frame: 0, value: t }), c.push({ frame: A * n, value: t }), c.push({
|
|
562
|
+
frame: A * (n + 1),
|
|
563
563
|
value: i
|
|
564
564
|
}), l.setKeys(c), l.setEasingFunction(a), l;
|
|
565
565
|
}
|
|
566
|
-
function Ye(
|
|
567
|
-
return
|
|
566
|
+
function Ye(s, e, t) {
|
|
567
|
+
return s < e ? s = t - (e - s) % (t - e) : s = e + (s - e) % (t - e);
|
|
568
568
|
}
|
|
569
|
-
function Qe(
|
|
570
|
-
|
|
569
|
+
function Qe(s, e, t) {
|
|
570
|
+
s.forEach((i) => {
|
|
571
571
|
t && i.name !== t || i.goToFrame(e);
|
|
572
572
|
});
|
|
573
573
|
}
|
|
@@ -581,7 +581,7 @@ const Ze = {
|
|
|
581
581
|
refractionTexture: "refractionMap",
|
|
582
582
|
reflectionTexture: "reflectionMap"
|
|
583
583
|
};
|
|
584
|
-
function $e(
|
|
584
|
+
function $e(s, e, t, i) {
|
|
585
585
|
[
|
|
586
586
|
"albedoTexture",
|
|
587
587
|
"bumpTexture",
|
|
@@ -591,49 +591,49 @@ function $e(n, e, t, i) {
|
|
|
591
591
|
"metallicTexture",
|
|
592
592
|
"refractionTexture",
|
|
593
593
|
"reflectionTexture"
|
|
594
|
-
].forEach((
|
|
594
|
+
].forEach((n) => {
|
|
595
595
|
je(
|
|
596
|
-
s,
|
|
597
596
|
n,
|
|
597
|
+
s,
|
|
598
598
|
e,
|
|
599
599
|
t,
|
|
600
600
|
i
|
|
601
601
|
);
|
|
602
|
-
}), et(
|
|
602
|
+
}), et(s, e);
|
|
603
603
|
}
|
|
604
|
-
function je(
|
|
605
|
-
const
|
|
606
|
-
if (!
|
|
604
|
+
function je(s, e, t, i, r) {
|
|
605
|
+
const n = Ze[s];
|
|
606
|
+
if (!n)
|
|
607
607
|
throw new Error("Unexpected texture name encountered.");
|
|
608
|
-
const o = e[
|
|
609
|
-
a ?
|
|
610
|
-
|
|
608
|
+
const o = e[n], a = o == null ? void 0 : o.fileLink;
|
|
609
|
+
a ? s === "reflectionTexture" ? a.endsWith(".env") || a.endsWith(".dds") ? i.addCubeTextureTask(
|
|
610
|
+
s,
|
|
611
611
|
a,
|
|
612
612
|
void 0,
|
|
613
613
|
!1,
|
|
614
614
|
void 0,
|
|
615
615
|
!0
|
|
616
616
|
) : a.endsWith(".hdr") ? i.addHDRCubeTextureTask(
|
|
617
|
-
|
|
617
|
+
s,
|
|
618
618
|
a,
|
|
619
619
|
128,
|
|
620
620
|
!1,
|
|
621
621
|
!0,
|
|
622
622
|
!1
|
|
623
|
-
) : i.addTextureTask(
|
|
623
|
+
) : i.addTextureTask(s, a, !1, !1) : i.addTextureTask(s, a, !1, !1) : r && t[s] && (t[s] && t[s].dispose(), t[s] = null, Xe(s, t));
|
|
624
624
|
}
|
|
625
|
-
function Xe(
|
|
626
|
-
|
|
625
|
+
function Xe(s, e) {
|
|
626
|
+
s === "opacityTexture" && (e.useAlphaFromAlbedoTexture = !0), s === "metallicTexture" && (e.useRoughnessFromMetallicTextureAlpha = !1, e.useRoughnessFromMetallicTextureGreen = !1, e.useMetallnessFromMetallicTextureBlue = !1), s === "refractionTexture" && (e.subSurface.isRefractionEnabled = !1, e.subSurface.refractionIntensity = 1), s === "reflectionTexture" && (e.environmentIntensity = 1), s === "emissiveTexture" && (e.emissiveIntensity = 0, e.emissiveColor = new w(0, 0, 0), e.reflectionTexture);
|
|
627
627
|
}
|
|
628
|
-
function Je(
|
|
628
|
+
function Je(s, e, t, i) {
|
|
629
629
|
if (!e) {
|
|
630
630
|
console.error("Failed to apply texture to material: material is null.");
|
|
631
631
|
return;
|
|
632
632
|
}
|
|
633
|
-
|
|
633
|
+
s === "opacityTexture" && (e.useAlphaFromAlbedoTexture = !1), s === "metallicTexture" && (e.useRoughnessFromMetallicTextureAlpha = !1, e.useRoughnessFromMetallicTextureGreen = !0, e.useMetallnessFromMetallicTextureBlue = !0), s === "refractionTexture" && (e.subSurface.isRefractionEnabled = !0, e.subSurface.refractionIntensity = t.refractionIntensity || 1), s === "reflectionTexture" && (e.environmentIntensity = t.reflectionIntensity || 1, i.isCube && (i.rotationY = t.reflectionRotation ? t.reflectionRotation * Math.PI / 180 : 0)), e[s] = i, s === "emissiveTexture" && (e.emissiveColor = new w(1, 1, 1), e.emissiveIntensity = 1);
|
|
634
634
|
}
|
|
635
|
-
function et(
|
|
636
|
-
|
|
635
|
+
function et(s, e) {
|
|
636
|
+
s.clearCoat && (s.clearCoat === F.RemoveWhenSelected ? (e.clearCoat.isEnabled = !1, e.clearCoat.indexOfRefraction = 1.5) : s.clearCoat === F.ApplyWhenSelected && (e.clearCoat.isEnabled = !0, e.clearCoat.indexOfRefraction = s.clearCoatIOR || e.clearCoat.indexOfRefraction));
|
|
637
637
|
}
|
|
638
638
|
class tt {
|
|
639
639
|
constructor(e, t, i) {
|
|
@@ -649,7 +649,7 @@ class tt {
|
|
|
649
649
|
* where we want to undo changes are remove effects from display.
|
|
650
650
|
*/
|
|
651
651
|
async applyMaterial(e, t, i, r) {
|
|
652
|
-
return new Promise((
|
|
652
|
+
return new Promise((n) => {
|
|
653
653
|
const o = this.materialVariantMap.get(e);
|
|
654
654
|
this.materialVariantMap.set(e, {
|
|
655
655
|
...o,
|
|
@@ -659,10 +659,10 @@ class tt {
|
|
|
659
659
|
(h) => h.name === a
|
|
660
660
|
);
|
|
661
661
|
if (l.length === 0) {
|
|
662
|
-
|
|
662
|
+
n();
|
|
663
663
|
return;
|
|
664
664
|
}
|
|
665
|
-
const c = new
|
|
665
|
+
const c = new qe(this.scene);
|
|
666
666
|
c.useDefaultLoadingScreen = !1, l.forEach(
|
|
667
667
|
(h) => $e(
|
|
668
668
|
t,
|
|
@@ -685,7 +685,7 @@ class tt {
|
|
|
685
685
|
m.texture
|
|
686
686
|
)
|
|
687
687
|
);
|
|
688
|
-
}),
|
|
688
|
+
}), n();
|
|
689
689
|
}, c.loadAsync();
|
|
690
690
|
});
|
|
691
691
|
}
|
|
@@ -699,7 +699,7 @@ class tt {
|
|
|
699
699
|
* @param getCurrentFrame A function that returns the current frame of the animation.
|
|
700
700
|
* @param getAnimationIsPlaying A function that returns whether the animation is currently playing.
|
|
701
701
|
*/
|
|
702
|
-
async applyModel(e, t, i, r,
|
|
702
|
+
async applyModel(e, t, i, r, n, o, a) {
|
|
703
703
|
var u;
|
|
704
704
|
if (i && t && !this.keysThatRemovedBaseModel.includes(e) && this.keysThatRemovedBaseModel.push(e), !i)
|
|
705
705
|
return this.keysThatRemovedBaseModel.includes(e) && this.keysThatRemovedBaseModel.length === 1 && await this.setBaseModelEnabled(!0), (u = this.loadedContainerForKey.get(e)) == null || u.dispose(), this.loadedContainerForKey.delete(e), this.loadedMaterialsForKey.delete(e), this.keysThatRemovedBaseModel = this.keysThatRemovedBaseModel.filter(
|
|
@@ -709,13 +709,13 @@ class tt {
|
|
|
709
709
|
this.renameClonedAsset,
|
|
710
710
|
!0
|
|
711
711
|
);
|
|
712
|
-
if (this.loadedContainerForKey.has(e) && (this.loadedContainerForKey.get(e).dispose(), this.loadedContainerForKey.delete(e), this.loadedMaterialsForKey.delete(e)),
|
|
713
|
-
const m = o && o(), g =
|
|
712
|
+
if (this.loadedContainerForKey.has(e) && (this.loadedContainerForKey.get(e).dispose(), this.loadedContainerForKey.delete(e), this.loadedMaterialsForKey.delete(e)), n) {
|
|
713
|
+
const m = o && o(), g = n.name ? this.renameClonedAsset(n.name) : void 0;
|
|
714
714
|
if (ve(
|
|
715
715
|
c.animationGroups,
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
716
|
+
n.loop,
|
|
717
|
+
n.to,
|
|
718
|
+
n.from,
|
|
719
719
|
g
|
|
720
720
|
), m != null) {
|
|
721
721
|
const f = a && a() || !0;
|
|
@@ -752,19 +752,19 @@ class tt {
|
|
|
752
752
|
}), e;
|
|
753
753
|
}
|
|
754
754
|
}
|
|
755
|
-
function we(
|
|
755
|
+
function we(s) {
|
|
756
756
|
const e = [];
|
|
757
|
-
return
|
|
757
|
+
return s.rootNodes.forEach((t) => {
|
|
758
758
|
t.getChildMeshes().forEach((i) => {
|
|
759
759
|
i.material && !e.includes(i.material) && e.push(i.material), i.subMeshes && i.subMeshes.forEach((r) => {
|
|
760
|
-
const
|
|
761
|
-
|
|
760
|
+
const n = r.getMaterial(!1);
|
|
761
|
+
n && !e.includes(n) && e.push(n);
|
|
762
762
|
});
|
|
763
763
|
});
|
|
764
764
|
}), e;
|
|
765
765
|
}
|
|
766
|
-
function pe(
|
|
767
|
-
return
|
|
766
|
+
function pe(s, e = "") {
|
|
767
|
+
return s.map((t) => ({
|
|
768
768
|
name: t.name.substring(e.length),
|
|
769
769
|
loop: t.loopAnimation,
|
|
770
770
|
to: t.to,
|
|
@@ -778,7 +778,7 @@ class it {
|
|
|
778
778
|
enablePicking: t,
|
|
779
779
|
modelDetails: i,
|
|
780
780
|
previewService: r,
|
|
781
|
-
progressHandler:
|
|
781
|
+
progressHandler: n,
|
|
782
782
|
scene: o
|
|
783
783
|
} = e;
|
|
784
784
|
this.enablePicking = t, this.contextService = i.contextService, this.id = Ue(), this.previewService = r, this.scene = o, this.variantManager = new tt(
|
|
@@ -794,7 +794,7 @@ class it {
|
|
|
794
794
|
return this.assetContainer = await D(
|
|
795
795
|
i.model,
|
|
796
796
|
o,
|
|
797
|
-
|
|
797
|
+
n
|
|
798
798
|
), await this.instantiate(), this;
|
|
799
799
|
};
|
|
800
800
|
this.importPromise = a();
|
|
@@ -833,7 +833,7 @@ class it {
|
|
|
833
833
|
}
|
|
834
834
|
return;
|
|
835
835
|
}
|
|
836
|
-
const
|
|
836
|
+
const n = async () => {
|
|
837
837
|
await this.variantManager.applyMaterial(
|
|
838
838
|
e,
|
|
839
839
|
i,
|
|
@@ -850,18 +850,18 @@ class it {
|
|
|
850
850
|
if (this.materialChangesInProgress.includes(e)) {
|
|
851
851
|
if (this.queuedMaterialChanges.has(e)) {
|
|
852
852
|
const o = this.queuedMaterialChanges.get(e);
|
|
853
|
-
o == null || o.set(t,
|
|
853
|
+
o == null || o.set(t, n);
|
|
854
854
|
} else {
|
|
855
855
|
this.queuedMaterialChanges.set(
|
|
856
856
|
e,
|
|
857
857
|
/* @__PURE__ */ new Map()
|
|
858
858
|
);
|
|
859
859
|
const o = this.queuedMaterialChanges.get(e);
|
|
860
|
-
o == null || o.set(t,
|
|
860
|
+
o == null || o.set(t, n);
|
|
861
861
|
}
|
|
862
862
|
return;
|
|
863
863
|
}
|
|
864
|
-
if (this.materialChangesInProgress.push(e), await
|
|
864
|
+
if (this.materialChangesInProgress.push(e), await n(), this.queuedMaterialChanges.has(e)) {
|
|
865
865
|
const o = this.queuedMaterialChanges.get(e);
|
|
866
866
|
if (!o)
|
|
867
867
|
throw new Error("Target material is undefined");
|
|
@@ -933,12 +933,12 @@ class it {
|
|
|
933
933
|
const i = async () => {
|
|
934
934
|
this.lastPlayedAnimation = e, this.isExecutingAnimation = !0, await new Promise((r) => {
|
|
935
935
|
var o;
|
|
936
|
-
const
|
|
936
|
+
const n = [
|
|
937
937
|
...((o = this.modelInstance) == null ? void 0 : o.animationGroups) || [],
|
|
938
938
|
...this.variantManager.getAnimationGroups()
|
|
939
939
|
];
|
|
940
940
|
ve(
|
|
941
|
-
|
|
941
|
+
n,
|
|
942
942
|
e.loop,
|
|
943
943
|
e.to,
|
|
944
944
|
e.from,
|
|
@@ -1066,7 +1066,7 @@ class it {
|
|
|
1066
1066
|
this.materials.some(e) || this.variantManager.getAllMaterials().some(e) ? this.previewService.getGlowLayerManager().includeMeshes(this.getAllMeshes()) : this.previewService.getGlowLayerManager().removeMeshes(this.getAllMeshes());
|
|
1067
1067
|
}
|
|
1068
1068
|
configureModelInstance(e) {
|
|
1069
|
-
var
|
|
1069
|
+
var n;
|
|
1070
1070
|
if (!this.transformRoot)
|
|
1071
1071
|
throw new Error(
|
|
1072
1072
|
"Transform disposed! This should never happen unless there is a race condition present!"
|
|
@@ -1078,7 +1078,7 @@ class it {
|
|
|
1078
1078
|
for (const a of o.getChildMeshes(!1))
|
|
1079
1079
|
a.alwaysSelectAsActiveMesh = !0;
|
|
1080
1080
|
}
|
|
1081
|
-
this.transformRoot.position = t, this.transformRoot.rotationQuaternion = i, this.transformRoot.scaling = r, this.canvasPanels = ((
|
|
1081
|
+
this.transformRoot.position = t, this.transformRoot.rotationQuaternion = i, this.transformRoot.scaling = r, this.canvasPanels = ((n = this.contextService) == null ? void 0 : n.getAll()) || /* @__PURE__ */ new Map(), He(
|
|
1082
1082
|
this.materials.concat(this.variantManager.getAllMaterials()),
|
|
1083
1083
|
this.scene,
|
|
1084
1084
|
this.canvasPanels,
|
|
@@ -1182,13 +1182,13 @@ class it {
|
|
|
1182
1182
|
//#endregion
|
|
1183
1183
|
}
|
|
1184
1184
|
class k extends fe {
|
|
1185
|
-
constructor(e, t, i, r,
|
|
1185
|
+
constructor(e, t, i, r, n, o, a, l) {
|
|
1186
1186
|
super(
|
|
1187
1187
|
e,
|
|
1188
1188
|
t,
|
|
1189
1189
|
i,
|
|
1190
1190
|
r,
|
|
1191
|
-
|
|
1191
|
+
n,
|
|
1192
1192
|
o,
|
|
1193
1193
|
l
|
|
1194
1194
|
), this.lastFocus = new p(0, 0, 0), this._isRunningFramingBehavior = !1, this.panDenominator = 1, this.panEnabled = !0, this.minZ = 0.01, this.updateRadiusBounds(this.radius), this.enableFramingBehavior(), this.wheelDeltaPercentage = 0.01, this.pinchDeltaPercentage = 5e-3, this.useNaturalPinchZoom = !0, a.camera.autoOrientation && (this.alpha += Math.PI), a && (a.camera.limits.min.beta && (this.lowerBetaLimit = a.camera.limits.min.beta), a.camera.limits.max.beta && (this.upperBetaLimit = a.camera.limits.max.beta), a.camera.limits.min.alpha && (this.lowerAlphaLimit = a.camera.limits.min.alpha), a.camera.limits.max.alpha && (this.upperAlphaLimit = a.camera.limits.max.alpha), a.camera.limits.min.radius && (this.lowerRadiusLimit = a.camera.limits.min.radius), a.camera.limits.max.radius && (this.upperRadiusLimit = a.camera.limits.max.radius), a.camera.autoRotation.enabled && this.enableAutoRotationBehavior(
|
|
@@ -1246,10 +1246,10 @@ class k extends fe {
|
|
|
1246
1246
|
i.framingTime = t || 800;
|
|
1247
1247
|
const r = () => {
|
|
1248
1248
|
this.isRunningFramingBehavior = !1;
|
|
1249
|
-
},
|
|
1249
|
+
}, n = T(this._scene), o = n.max.subtract(n.min), a = n.min.add(o.scale(0.5));
|
|
1250
1250
|
this.updateRadiusBounds(o.length() * 1.5), this.wheelPrecision = 100 / this.radius, this.panningInertia = 0, this.panningOriginTarget.copyFrom(a), this.panDenominator = o.length(), this.lastFocus.copyFrom(a), i.zoomOnBoundingInfo(
|
|
1251
|
-
|
|
1252
|
-
|
|
1251
|
+
n.min,
|
|
1252
|
+
n.max,
|
|
1253
1253
|
void 0,
|
|
1254
1254
|
r
|
|
1255
1255
|
), i.framingTime = 0;
|
|
@@ -1283,34 +1283,34 @@ class k extends fe {
|
|
|
1283
1283
|
*/
|
|
1284
1284
|
static create(e, t, i) {
|
|
1285
1285
|
var l;
|
|
1286
|
-
const r = T(e),
|
|
1286
|
+
const r = T(e), n = r.max.subtract(r.min), o = r.min.add(n.scale(0.5)), a = new k(
|
|
1287
1287
|
"ProductCamera",
|
|
1288
1288
|
-(Math.PI / 2),
|
|
1289
1289
|
Math.PI / 2,
|
|
1290
|
-
|
|
1290
|
+
n.length() * 1.5,
|
|
1291
1291
|
o,
|
|
1292
1292
|
e,
|
|
1293
1293
|
t
|
|
1294
1294
|
);
|
|
1295
1295
|
return a.setPanEnabled(
|
|
1296
1296
|
((l = t.options) == null ? void 0 : l.noPan) !== void 0 ? !t.options.noPan : !0
|
|
1297
|
-
), a.panningInertia = 0, a.panningOriginTarget.copyFrom(o), a.panDenominator =
|
|
1297
|
+
), a.panningInertia = 0, a.panningOriginTarget.copyFrom(o), a.panDenominator = n.length(), a.onAfterCheckInputsObservable.addOnce(() => {
|
|
1298
1298
|
a.setPanEnabled(a.panEnabled);
|
|
1299
1299
|
}), i && (e.activeCamera = a), a;
|
|
1300
1300
|
}
|
|
1301
1301
|
}
|
|
1302
|
-
function T(
|
|
1303
|
-
if (
|
|
1302
|
+
function T(s) {
|
|
1303
|
+
if (s.meshes.length === 0)
|
|
1304
1304
|
return {
|
|
1305
1305
|
min: new p(-1, -1, -1),
|
|
1306
1306
|
max: new p(1, 1, 1)
|
|
1307
1307
|
};
|
|
1308
|
-
const e =
|
|
1309
|
-
return
|
|
1308
|
+
const e = s.meshes.filter((t) => t.name.toLowerCase().endsWith("_t") || t.name.toLowerCase().includes("_t_"));
|
|
1309
|
+
return s.getWorldExtends((t) => t.isVisible && t.isEnabled() && (e.length === 0 || e.includes(t)));
|
|
1310
1310
|
}
|
|
1311
1311
|
class nt {
|
|
1312
1312
|
constructor(e, t = !1, i = void 0) {
|
|
1313
|
-
this.renderingPipeline = new
|
|
1313
|
+
this.renderingPipeline = new Ve(
|
|
1314
1314
|
"default",
|
|
1315
1315
|
t,
|
|
1316
1316
|
e,
|
|
@@ -1326,9 +1326,9 @@ class nt {
|
|
|
1326
1326
|
return this.currentConfiguration;
|
|
1327
1327
|
}
|
|
1328
1328
|
setConfiguration(e) {
|
|
1329
|
-
var t, i, r,
|
|
1329
|
+
var t, i, r, n, o, a, l, c, h, u, m, g, f, z, q, V, N, G, _, H, K, U, W, Y, Q, Z, $, j, X, J, ee, te, ie;
|
|
1330
1330
|
if (this.renderingPipeline.isSupported) {
|
|
1331
|
-
if (this.renderingPipeline.samples = ((t = e.antiAliasing) == null ? void 0 : t.samples) ?? d.antiAliasing.samples, this.renderingPipeline.fxaaEnabled = ((i = e.antiAliasing) == null ? void 0 : i.fxaaEnabled) ?? d.antiAliasing.fxaaEnabled, this.renderingPipeline.bloomEnabled = ((r = e.bloom) == null ? void 0 : r.enabled) ?? d.bloom.enabled, this.renderingPipeline.bloomKernel = ((
|
|
1331
|
+
if (this.renderingPipeline.samples = ((t = e.antiAliasing) == null ? void 0 : t.samples) ?? d.antiAliasing.samples, this.renderingPipeline.fxaaEnabled = ((i = e.antiAliasing) == null ? void 0 : i.fxaaEnabled) ?? d.antiAliasing.fxaaEnabled, this.renderingPipeline.bloomEnabled = ((r = e.bloom) == null ? void 0 : r.enabled) ?? d.bloom.enabled, this.renderingPipeline.bloomKernel = ((n = e.bloom) == null ? void 0 : n.kernel) ?? d.bloom.kernel, this.renderingPipeline.bloomScale = ((o = e.bloom) == null ? void 0 : o.scale) ?? d.bloom.scale, this.renderingPipeline.bloomThreshold = ((a = e.bloom) == null ? void 0 : a.threshold) ?? d.bloom.threshold, this.renderingPipeline.bloomWeight = ((l = e.bloom) == null ? void 0 : l.weight) ?? d.bloom.weight, this.renderingPipeline.chromaticAberrationEnabled = ((c = e.chromaticAberration) == null ? void 0 : c.enabled) ?? d.chromaticAberration.enabled, this.renderingPipeline.chromaticAberration.aberrationAmount = ((h = e.chromaticAberration) == null ? void 0 : h.aberrationAmount) ?? d.chromaticAberration.aberrationAmount, this.renderingPipeline.chromaticAberration.radialIntensity = ((u = e.chromaticAberration) == null ? void 0 : u.radialIntensity) ?? d.chromaticAberration.radialIntensity, this.renderingPipeline.chromaticAberration.direction = (m = e.chromaticAberration) != null && m.direction ? new se(
|
|
1332
1332
|
e.chromaticAberration.direction.x,
|
|
1333
1333
|
e.chromaticAberration.direction.y
|
|
1334
1334
|
) : new se(
|
|
@@ -1346,7 +1346,7 @@ class nt {
|
|
|
1346
1346
|
this.renderingPipeline.depthOfFieldBlurLevel = E.High;
|
|
1347
1347
|
break;
|
|
1348
1348
|
}
|
|
1349
|
-
if (this.renderingPipeline.depthOfField.focalLength = ((z = e.depthOfField) == null ? void 0 : z.focalLength) ?? d.depthOfField.focalLength, this.renderingPipeline.depthOfField.fStop = ((
|
|
1349
|
+
if (this.renderingPipeline.depthOfField.focalLength = ((z = e.depthOfField) == null ? void 0 : z.focalLength) ?? d.depthOfField.focalLength, this.renderingPipeline.depthOfField.fStop = ((q = e.depthOfField) == null ? void 0 : q.fStop) ?? d.depthOfField.fStop, this.renderingPipeline.depthOfField.focusDistance = ((V = e.depthOfField) == null ? void 0 : V.focusDistance) ?? d.depthOfField.focusDistance, this.renderingPipeline.depthOfField.lensSize = ((N = e.depthOfField) == null ? void 0 : N.lensSize) ?? d.depthOfField.lensSize, this.renderingPipeline.grainEnabled = ((G = e.grain) == null ? void 0 : G.enabled) ?? d.grain.enabled, this.renderingPipeline.grain.animated = ((_ = e.grain) == null ? void 0 : _.animated) ?? d.grain.animated, this.renderingPipeline.grain.intensity = ((H = e.grain) == null ? void 0 : H.intensity) ?? d.grain.intensity, this.renderingPipeline.imageProcessing.contrast = ((K = e.misc) == null ? void 0 : K.contrast) ?? d.misc.contrast, this.renderingPipeline.imageProcessing.exposure = ((U = e.misc) == null ? void 0 : U.exposure) ?? d.misc.exposure, this.renderingPipeline.imageProcessing.toneMappingEnabled = ((W = e.misc) == null ? void 0 : W.toneMappingEnabled) ?? d.misc.toneMappingEnabled, this.renderingPipeline.imageProcessing.toneMappingEnabled)
|
|
1350
1350
|
switch (e.misc.toneMappingType ?? d.misc.toneMappingType) {
|
|
1351
1351
|
case "Standard":
|
|
1352
1352
|
this.renderingPipeline.imageProcessing.toneMappingType = P.TONEMAPPING_STANDARD;
|
|
@@ -1382,20 +1382,20 @@ class nt {
|
|
|
1382
1382
|
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;
|
|
1383
1383
|
}
|
|
1384
1384
|
}
|
|
1385
|
-
xe.GLTFLoader.RegisterExtension("glbPostProcessor", function(
|
|
1386
|
-
return new Ge(
|
|
1385
|
+
xe.GLTFLoader.RegisterExtension("glbPostProcessor", function(s) {
|
|
1386
|
+
return new Ge(s);
|
|
1387
1387
|
});
|
|
1388
|
-
S.OnPluginActivatedObservable.add((
|
|
1389
|
-
if (
|
|
1390
|
-
const e =
|
|
1388
|
+
S.OnPluginActivatedObservable.add((s) => {
|
|
1389
|
+
if (s.name === "gltf") {
|
|
1390
|
+
const e = s;
|
|
1391
1391
|
e.transparencyAsCoverage = !0;
|
|
1392
1392
|
}
|
|
1393
1393
|
});
|
|
1394
|
-
function O(
|
|
1395
|
-
return new p(
|
|
1394
|
+
function O(s) {
|
|
1395
|
+
return new p(s.x, s.y, s.z);
|
|
1396
1396
|
}
|
|
1397
|
-
function L(
|
|
1398
|
-
return { x:
|
|
1397
|
+
function L(s) {
|
|
1398
|
+
return { x: s.x, y: s.y, z: s.z };
|
|
1399
1399
|
}
|
|
1400
1400
|
class Wt {
|
|
1401
1401
|
constructor(e) {
|
|
@@ -1413,14 +1413,14 @@ class Wt {
|
|
|
1413
1413
|
if (!(e != null && e.noRender))
|
|
1414
1414
|
return this.configuration.createCanvas();
|
|
1415
1415
|
})(), r = "1.5.6";
|
|
1416
|
-
|
|
1416
|
+
Ae.Configuration = {
|
|
1417
1417
|
decoder: {
|
|
1418
1418
|
wasmUrl: `https://www.gstatic.com/draco/versioned/decoders/${r}/draco_wasm_wrapper_gltf.js`,
|
|
1419
1419
|
wasmBinaryUrl: `https://www.gstatic.com/draco/versioned/decoders/${r}/draco_decoder_gltf.wasm`,
|
|
1420
1420
|
fallbackUrl: `https://www.gstatic.com/draco/versioned/decoders/${r}/draco_decoder_gltf.js`
|
|
1421
1421
|
}
|
|
1422
1422
|
}, i && (i.getContext("webgl2") || i.getContext("webgl"));
|
|
1423
|
-
const
|
|
1423
|
+
const n = console.log;
|
|
1424
1424
|
console.log = () => {
|
|
1425
1425
|
};
|
|
1426
1426
|
const o = i ? new be(i, !0, {
|
|
@@ -1432,7 +1432,7 @@ class Wt {
|
|
|
1432
1432
|
stencil: this.configuration.highlights.enabled,
|
|
1433
1433
|
forceSRGBBufferSupportState: !0
|
|
1434
1434
|
}) : new Ce();
|
|
1435
|
-
console.log =
|
|
1435
|
+
console.log = n, o.hideLoadingUI(), window.addEventListener("resize", this.fireResizeEvent.bind(this)), this.engine = o, this.scene = new Pe(o), this.camera = k.create(this.scene, this.configuration), this.scene.activeCamera = this.camera, this.renderingPipeline = new nt(
|
|
1436
1436
|
this.scene,
|
|
1437
1437
|
!1,
|
|
1438
1438
|
this.camera
|
|
@@ -1543,9 +1543,9 @@ class Wt {
|
|
|
1543
1543
|
this.isAnimatingCamera = !0, await new Promise((i) => {
|
|
1544
1544
|
this.focusLostNotified = !1;
|
|
1545
1545
|
const r = () => {
|
|
1546
|
-
const
|
|
1546
|
+
const n = this.configuration;
|
|
1547
1547
|
this.camera.rerunFramingBehavior(() => {
|
|
1548
|
-
|
|
1548
|
+
n.camera.limits.min.radius && (this.camera.lowerRadiusLimit = n.camera.limits.min.radius), n.camera.limits.max.radius && (this.camera.upperRadiusLimit = n.camera.limits.max.radius), i();
|
|
1549
1549
|
});
|
|
1550
1550
|
};
|
|
1551
1551
|
this.scene.onAfterRenderObservable.addOnce(r);
|
|
@@ -1555,6 +1555,10 @@ class Wt {
|
|
|
1555
1555
|
e = i;
|
|
1556
1556
|
})) : t();
|
|
1557
1557
|
}
|
|
1558
|
+
forceStopCameraAnimations() {
|
|
1559
|
+
var e;
|
|
1560
|
+
this.queuedAnimationFunction = void 0, this.queuedCameraAnimation = void 0, this.isAnimatingCamera = !1, (e = this.camera.framingBehavior) == null || e.stopAllAnimations(), this.scene.stopAnimation(this.camera);
|
|
1561
|
+
}
|
|
1558
1562
|
setAutoRotation(e) {
|
|
1559
1563
|
!this.configuration.camera.autoRotation.enabled || !this.camera || (e ? this.camera.enableAutoRotationBehavior(
|
|
1560
1564
|
this.configuration.camera.autoRotation.idleTimeMs
|
|
@@ -1575,9 +1579,9 @@ class Wt {
|
|
|
1575
1579
|
this.scene
|
|
1576
1580
|
);
|
|
1577
1581
|
try {
|
|
1578
|
-
const r = t.latDeg * Math.PI / 180,
|
|
1579
|
-
i.target = t.target ? new p(t.target.x, t.target.y, t.target.z) : p.Zero(), i.alpha =
|
|
1580
|
-
const o = await
|
|
1582
|
+
const r = t.latDeg * Math.PI / 180, n = t.lonDeg * Math.PI / 180;
|
|
1583
|
+
i.target = t.target ? new p(t.target.x, t.target.y, t.target.z) : p.Zero(), i.alpha = n, i.beta = r, i.radius = t.radius || this.camera.radius, i.minZ = 0.01, this.scene.render();
|
|
1584
|
+
const o = await Me.CreateScreenshotUsingRenderTargetAsync(
|
|
1581
1585
|
this.engine,
|
|
1582
1586
|
i,
|
|
1583
1587
|
e,
|
|
@@ -1594,10 +1598,10 @@ class Wt {
|
|
|
1594
1598
|
const e = this.configuration;
|
|
1595
1599
|
if (!e)
|
|
1596
1600
|
return !0;
|
|
1597
|
-
const t = e.camera.limits.min.alpha, i = e.camera.limits.max.alpha, r = e.camera.limits.min.beta,
|
|
1598
|
-
if (t === void 0 || i === void 0 || r === void 0 ||
|
|
1601
|
+
const t = e.camera.limits.min.alpha, i = e.camera.limits.max.alpha, r = e.camera.limits.min.beta, n = e.camera.limits.max.beta;
|
|
1602
|
+
if (t === void 0 || i === void 0 || r === void 0 || n === void 0)
|
|
1599
1603
|
return !0;
|
|
1600
|
-
const o = [t, i], a = [r,
|
|
1604
|
+
const o = [t, i], a = [r, n], l = o.every((h) => h === t), c = a.every((h) => h === r);
|
|
1601
1605
|
return !l && !c;
|
|
1602
1606
|
}
|
|
1603
1607
|
fireResizeEvent() {
|
|
@@ -1611,9 +1615,9 @@ class Wt {
|
|
|
1611
1615
|
blurHorizontalSize: 0.85
|
|
1612
1616
|
}), this.highlightLayer.innerGlow = !0, this.highlightLayer.outerGlow = !1), this.highlightLayer.removeAllMeshes();
|
|
1613
1617
|
const i = t ? new w(t[0], t[1], t[2]).toLinearSpace() : void 0;
|
|
1614
|
-
e.forEach((
|
|
1618
|
+
e.forEach((n) => {
|
|
1615
1619
|
const o = this.scene.materials.find(
|
|
1616
|
-
(a) => a.name ===
|
|
1620
|
+
(a) => a.name === n.name && a.id === n.id
|
|
1617
1621
|
);
|
|
1618
1622
|
o && o.getBindedMeshes().forEach(
|
|
1619
1623
|
(a) => {
|
|
@@ -1630,27 +1634,27 @@ class Wt {
|
|
|
1630
1634
|
this.renderingPipeline && this.renderingPipeline.setConfiguration(e);
|
|
1631
1635
|
}
|
|
1632
1636
|
loadModel(e, t) {
|
|
1633
|
-
const i = new it({
|
|
1637
|
+
const { refocusCamera: i = !0, progressHandler: r } = t ?? {}, n = new it({
|
|
1634
1638
|
enablePicking: this.configuration.highlights.enabled,
|
|
1635
1639
|
modelDetails: e,
|
|
1636
1640
|
scene: this.scene,
|
|
1637
1641
|
previewService: this,
|
|
1638
|
-
progressHandler:
|
|
1642
|
+
progressHandler: r
|
|
1639
1643
|
});
|
|
1640
|
-
return
|
|
1641
|
-
this.modelContainers.size <= 1 && this.camera.rerunFramingBehavior(() => {
|
|
1644
|
+
return n.getInitializationPromise().then(() => {
|
|
1645
|
+
this.modelContainers.size <= 1 && i && (this.forceStopCameraAnimations(), this.camera.rerunFramingBehavior(() => {
|
|
1642
1646
|
this.scene.onAfterRenderObservable.addOnce(() => {
|
|
1643
1647
|
this.queuedCameraAnimation && (this.executeCameraAnimation(this.queuedCameraAnimation), this.queuedCameraAnimation = void 0);
|
|
1644
1648
|
});
|
|
1645
|
-
}, 1);
|
|
1646
|
-
}), this.configuration.highlights.enabled && (
|
|
1647
|
-
this.setHighlights([
|
|
1648
|
-
}),
|
|
1649
|
+
}, 1));
|
|
1650
|
+
}), this.configuration.highlights.enabled && (n.registerMaterialSelectedCallback((o) => {
|
|
1651
|
+
this.setHighlights([o]);
|
|
1652
|
+
}), n.registerMaterialDeselectedCallback(() => {
|
|
1649
1653
|
this.setHighlights([]);
|
|
1650
|
-
})), this.modelContainers.set(
|
|
1654
|
+
})), this.modelContainers.set(n.getId(), n), this.triggerModelLoadEvent({
|
|
1651
1655
|
eventType: "load",
|
|
1652
|
-
modelContainer:
|
|
1653
|
-
}),
|
|
1656
|
+
modelContainer: n
|
|
1657
|
+
}), n;
|
|
1654
1658
|
}
|
|
1655
1659
|
async preloadModel(e) {
|
|
1656
1660
|
await D(e, this.scene);
|
|
@@ -1694,7 +1698,7 @@ class Wt {
|
|
|
1694
1698
|
O(t || { x: 0, y: 0, z: 0 })
|
|
1695
1699
|
),
|
|
1696
1700
|
O(e || { x: 0, y: 0, z: 0 })
|
|
1697
|
-
),
|
|
1701
|
+
), n = re.RotationAxis(p.Up(), Math.PI), o = r.multiply(n), a = p.Zero(), l = y.Identity(), c = p.Zero();
|
|
1698
1702
|
return o.decompose(c, l, a), l.multiplyInPlace(y.FromEulerAngles(0, Math.PI, 0)), {
|
|
1699
1703
|
position: L(a),
|
|
1700
1704
|
rotation: L(l.toEulerAngles()),
|
|
@@ -1702,7 +1706,7 @@ class Wt {
|
|
|
1702
1706
|
};
|
|
1703
1707
|
}
|
|
1704
1708
|
updatePreviewOptions(e) {
|
|
1705
|
-
var r,
|
|
1709
|
+
var r, n;
|
|
1706
1710
|
const t = new ce(e);
|
|
1707
1711
|
this.configuration.highlights.enabled !== t.highlights.enabled && this.engine.setStencilBuffer(t.highlights.enabled), this.scene.clearColor = t.scene.clearColor;
|
|
1708
1712
|
let i = this.scene.environmentTexture;
|
|
@@ -1712,7 +1716,7 @@ class Wt {
|
|
|
1712
1716
|
), i.rotationY = this.configuration.scene.environment.rotationY, this.scene.environmentTexture = i), i.rotationY = t.scene.environment.rotationY, this.scene.environmentIntensity = t.scene.environment.intensity, (r = t.options) != null && r.renderingPipelineConfiguration ? this.renderingPipeline.setConfiguration(
|
|
1713
1717
|
t.options.renderingPipelineConfiguration
|
|
1714
1718
|
) : (this.scene.imageProcessingConfiguration.exposure = t.lighting.exposure, this.scene.imageProcessingConfiguration.contrast = t.lighting.contrast), this.glowLayerManager.setIntensity(t.emissiveGlowIntensity), this.camera.updateConfiguration(t), this.camera.setPanEnabled(
|
|
1715
|
-
((
|
|
1719
|
+
((n = t.options) == null ? void 0 : n.noPan) !== void 0 ? !t.options.noPan : !0
|
|
1716
1720
|
), this.scene.autoClear = !0, this.scene.autoClearDepthAndStencil = !0, this.configuration = t;
|
|
1717
1721
|
}
|
|
1718
1722
|
/**
|
|
@@ -1733,7 +1737,7 @@ export {
|
|
|
1733
1737
|
F as MaterialEffectMode,
|
|
1734
1738
|
I as ProductCameraRig,
|
|
1735
1739
|
Ne as REFLECTION_PROBE_RESOLUTION,
|
|
1736
|
-
|
|
1740
|
+
M as RenderingConfiguration,
|
|
1737
1741
|
Wt as SpiffCommerce3DPreviewService,
|
|
1738
1742
|
d as renderingPipelineDefaults
|
|
1739
1743
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(c,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/loaders/glTF/glTFFileLoader"),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/loaders/glTF/glTFFileLoader","@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):(c=typeof globalThis<"u"?globalThis:c||self,y(c.Preview={},c.arcRotateCamera,c.engine,c.nullEngine,c.highlightLayer,c.sceneLoader,c.cubeTexture,c.math_color,c.math_vector,c.dracoCompression,c.observable,c.tools,c.scene,c.glTF,c.glTFFileLoader,c.pbrMaterial,c.mirrorTexture,c.math,c.reflectionProbe,c.glowLayer,c.actionManager,c.directActions,c.mesh,c.transformNode,c.dynamicTexture,c.texture,c.animation,c.easing,c.assetsManager,c.colorCurves,c.imageProcessingConfiguration,c.RenderPipeline,c.depthOfFieldEffect))})(this,function(c,y,V,ye,Ce,L,k,b,p,we,M,Me,xe,Pe,Ae,O,Te,P,Re,Ee,F,z,Le,Oe,Fe,Ie,C,N,Se,G,A,Be,I){"use strict";var T=(n=>(n[n.Orbit=0]="Orbit",n[n.Pan=1]="Pan",n))(T||{}),R=(n=>(n.None="None",n.RemoveWhenSelected="RemoveWhenSelected",n.ApplyWhenSelected="ApplyWhenSelected",n))(R||{});const H=new Map;async function S(n,e,t){const i=H.get(n);if(i)return i;{const r=L.SceneLoader.LoadAssetContainerAsync(n,void 0,e,t);return H.set(n,r),r}}L.SceneLoader.OnPluginActivatedObservable.add(n=>{n.name==="gltf"&&(n.animationStartMode=Ae.GLTFLoaderAnimationStartMode.NONE)});class K{constructor(e){this.getSceneClearColor=()=>{var i,r,s,o;const t=(i=this.customOptions)!=null&&i.transparentBackground||(r=this.customOptions)!=null&&r.backgroundImage?0:1;if(this.customOptions&&((s=this.customOptions)!=null&&s.transparentBackground)||(o=this.customOptions)!=null&&o.backgroundImage)return new b.Color4(0,0,0,t).toLinearSpace();if(this.customOptions&&this.customOptions.backgroundColor){const a=b.Color3.FromHexString(this.customOptions.backgroundColor);return new b.Color4(a.r,a.g,a.b,t).toLinearSpace()}return new b.Color4(.98,.98,.98,t).toLinearSpace()},this.highlightColorFromConfig=()=>this.customOptions&&this.customOptions.highlightColor?this.hexToColor4(this.customOptions.highlightColor):new b.Color4(.98,.98,.98,1).toLinearSpace(),this.hexToColor4=(t,i=1)=>{const r=b.Color3.FromHexString(t);return new b.Color4(r.r,r.g,r.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,r,s;return{clearColor:this.getSceneClearColor(),transparentBackground:((e=this.customOptions)==null?void 0:e.transparentBackground)||((t=this.customOptions)==null?void 0:t.backgroundImage),environment:{file:((i=this.customOptions)==null?void 0:i.environmentFile)??"assets/model-viewer/default.env",intensity:((r=this.customOptions)==null?void 0:r.environmentIntensity)??1,rotationY:(((s=this.customOptions)==null?void 0:s.environmentRotationY)??0)*(Math.PI/180)}}}get camera(){var e,t,i,r,s,o,a,l,d,h,g,m,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:(r=this.customOptions)!=null&&r.lowerAlphaLimitDeg?((s=this.customOptions)==null?void 0:s.lowerAlphaLimitDeg)*Math.PI/180:void 0,beta:(o=this.customOptions)!=null&&o.lowerBetaLimitDeg?((a=this.customOptions)==null?void 0:a.lowerBetaLimitDeg)*Math.PI/180:void 0,radius:(l=this.customOptions)==null?void 0:l.minZoomOverride},max:{alpha:(d=this.customOptions)!=null&&d.upperAlphaLimitDeg?((h=this.customOptions)==null?void 0:h.upperAlphaLimitDeg)*Math.PI/180:void 0,beta:(g=this.customOptions)!=null&&g.upperBetaLimitDeg?((m=this.customOptions)==null?void 0:m.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,r;return{exposure:((t=(e=this.customOptions)==null?void 0:e.lighting)==null?void 0:t.exposure)??.9,contrast:((r=(i=this.customOptions)==null?void 0:i.lighting)==null?void 0:r.contrast)??1.6}}get emissiveGlowIntensity(){var e;return((e=this.customOptions)==null?void 0:e.emissiveGlowIntensity)??.5}}class w{static getDynamicTextureResolution(){return this.getIsMobile()||!w.offscreenRenderingSupported()?{width:1024,height:1024}:{width:2048,height:2048}}static shouldMipMap(){return!0}static offscreenRenderingSupported(){return navigator.userAgent.includes("SamsungBrowser")?!1:!!window.Worker&&!!window.OffscreenCanvas}static getMirrorTextureResolution(){return this.getIsMobile()?512:1024}static getIsMobile(){try{return typeof window>"u"||!window.navigator?!1:/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(window.navigator.userAgent)||window.innerWidth/window.devicePixelRatio<=480}catch{return!1}}}const U=128,u={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(r){t.extras&&Object.keys(t.extras).forEach(s=>{const o=t.extras[s];r.metadata[s]=o}),i(r)})}async loadMaterialPropertiesAsync(e,t,i){await this.loader.loadMaterialPropertiesAsync(e,t,i),this.enableMaterialExtrasIfRequired(t,i),i.needDepthPrePass=!0}dispose(){}enableMaterialExtrasIfRequired(e,t){if(!(!e.extras||!(t instanceof O.PBRMaterial))){if(e.extras.sheen){const i=t;i.sheen.isEnabled=!0,i.sheen.intensity=e.extras.sheen}if(e.extras.translucency){const i=t;i.subSurface.isTranslucencyEnabled=!0,i.subSurface.translucencyIntensity=e.extras.translucency,e.extras.translucencyR&&e.extras.translucencyG&&e.extras.translucencyB&&(i.subSurface.tintColor=new P.Color3(e.extras.translucencyR,e.extras.translucencyG,e.extras.translucencyB))}if(e.extras.refractionIOR){const i=t;i.subSurface.isRefractionEnabled=!0,i.subSurface.volumeIndexOfRefraction=e.extras.refractionIOR}if(e.extras.useDepthPrePass){const i=t;i.needDepthPrePass=!0,i.forceIrradianceInFragment=!0}if(e.extras.useParallax){const i=t;i.useParallax=!0,i.useParallaxOcclusion=!0,i.parallaxScaleBias=e.extras.useParallax}}}applyReflections(e){function t(s){const o=[];return s.transformNodes.forEach(a=>{a.metadata&&a.metadata.reflective&&o.push(...a.getChildMeshes())}),s.meshes.forEach(a=>{a.metadata&&a.metadata.reflective&&!o.includes(a)&&o.push(a)}),o}function i(s,o=1){const a=s.material;if(!a)return;const l=new Te.MirrorTexture("mirror",w.getMirrorTextureResolution(),e,!0);l.renderList=t(e);const d=s.getVerticesData("normal");if(!d)throw new Error("Mirror attribute specified on: "+s.name+"But no normals exist to generate a mirror from!");s.computeWorldMatrix(!0);const h=s.getWorldMatrix(),g=P.Vector3.TransformNormal(new P.Vector3(d[0],d[1],d[2]),h).normalize(),m=P.Plane.FromPositionAndNormal(s.position,g.scale(-1));l.mirrorPlane=m,l.level=o,a.reflectionTexture=l}function r(s){const o=s.material,a=new Re.ReflectionProbe("probe-"+o.name,U,e);a.attachToMesh(s),a.renderList&&a.renderList.push(...t(e)),o.reflectionTexture=a.cubeTexture}e.meshes.forEach(s=>{const o=s.metadata;o&&(o.mirrorTexture&&i(s,o.mirrorTexture),o.reflectionProbe&&r(s))})}}class qe{constructor(e,t){this.scene=e,this.intensity=t,this.meshCount=0}setIntensity(e){this.intensity=e,this.glowLayer&&(this.glowLayer.intensity=e)}includeMeshes(e){if(e){this.glowLayer||(this.glowLayer=new Ee.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)}}}function De(n,e,t,i,r=""){t.forEach(s=>{const o=s.getID(),a=s.getName(),l=w.getDynamicTextureResolution();n.filter(h=>h.name===r+a).forEach(h=>{const g=i.get(o),m=!1;if(g)W(h,g),g.update(m);else{const f=Ve(a,e,l.width,l.height);i.set(o,f),s.setStaticContext(f.getContext()),W(h,f),f.onLoadObservable.addOnce(()=>{f.update(m)})}})})}function Ve(n,e,t,i){const r=new Fe.DynamicTexture(n,{width:t,height:i},e,w.shouldMipMap(),Ie.Texture.TRILINEAR_SAMPLINGMODE,V.Engine.TEXTUREFORMAT_RGBA),s=r.getContext();return s&&(s.fillStyle="#f5f5f5",s.fillRect(0,0,t,i),r.update()),r}function W(n,e){if(n instanceof O.PBRMaterial){const t=n,i=t.albedoTexture;i?(e.wrapU=i.wrapU,e.wrapV=i.wrapV):(e.wrapU=1,e.wrapV=1),t.albedoTexture=e}else{const t=n,i=t.diffuseTexture;i&&(e.wrapU=i.wrapU,e.wrapV=i.wrapV),t.diffuseTexture=e}}function ke(){const n=()=>Math.floor((1+Math.random())*65536).toString(16).substring(1);return n()+n()+"-"+n()+"-"+n()+"-"+n()+"-"+n()+n()+n()}const x=60,Q=1;function Y(n){return n.targetedAnimations.map(t=>t.animation.framePerSecond).reduce((t,i)=>t+i,0)/n.targetedAnimations.length||0}function Z(n,e,t,i,r,s){const o=r?n.filter(h=>h.name===r):n;if(o.length===0){console.warn(`No animations found for name: ${r}`);return}let a=0;const l=()=>{a++,a===o.length&&s&&s()},d=(h,g,m,f,v)=>{h.stop(),h.start(g,m,f,v),s&&(g==!1||g===void 0&&!h.loopAnimation?h.onAnimationGroupEndObservable.addOnce(()=>{l()}):h.onAnimationLoopObservable.addOnce(()=>{l()}))};if(i!==void 0&&t!==void 0&&i===t){o.forEach(h=>{const g=Y(h),m=i*g;d(h,!1,Q,m,m)});return}o.forEach(h=>{const g=Y(h),m=i!==void 0?i*g:void 0,f=t!==void 0?t*g:void 0;d(h,e,Q,m,f)})}function ze(n,e,t){return new Promise(i=>{n.stopAnimation(e),e.animations=[],Math.abs(e.alpha)>2*Math.PI&&(e.alpha=Ne(e.alpha,0,2*Math.PI));const r=[],s=t.target,o=0,a=s?1:0;if(t.target&&Object.keys(t.target).length>0&&r.push(E("cameraTargetLerp","target",new p.Vector3().copyFrom(e.target),new p.Vector3(t.target.x,t.target.y,t.target.z),C.Animation.ANIMATIONTYPE_VECTOR3,o)),r.push(E("cameraAlphaLerp","alpha",e.alpha,$(t.lonDeg),C.Animation.ANIMATIONTYPE_FLOAT,a)),r.push(E("cameraBetaLerp","beta",e.beta,$(t.latDeg),C.Animation.ANIMATIONTYPE_FLOAT,a)),t.radius!==void 0){const h=Math.max(.01,t.radius);r.push(E("cameraRadiusLerp","radius",e.radius,h,C.Animation.ANIMATIONTYPE_FLOAT,a))}e.animations.push(...r);const d=e.useAutoRotationBehavior;e.disableAutoRotationBehavior(),n.beginAnimation(e,0,s?x*2:x,!1,1,()=>{e.animations=[],d&&e.enableAutoRotationBehavior(),i()})})}function $(n){return n*Math.PI/180}function E(n,e,t,i,r,s=0,o=C.Animation.ANIMATIONLOOPMODE_CONSTANT){const a=new N.QuadraticEase;a.setEasingMode(N.EasingFunction.EASINGMODE_EASEINOUT);const l=new C.Animation(n,e,x,r,o),d=[];return s>0&&d.push({frame:0,value:t}),d.push({frame:x*s,value:t}),d.push({frame:x*(s+1),value:i}),l.setKeys(d),l.setEasingFunction(a),l}function Ne(n,e,t){return n<e?n=t-(e-n)%(t-e):n=e+(n-e)%(t-e)}function Ge(n,e,t){n.forEach(i=>{t&&i.name!==t||i.goToFrame(e)})}const He={albedoTexture:"albedoMap",bumpTexture:"normalMap",ambientTexture:"ambientMap",emissiveTexture:"emissionMap",opacityTexture:"alphaMap",metallicTexture:"metallicMap",refractionTexture:"refractionMap",reflectionTexture:"reflectionMap"};function Ke(n,e,t,i){["albedoTexture","bumpTexture","ambientTexture","emissiveTexture","opacityTexture","metallicTexture","refractionTexture","reflectionTexture"].forEach(s=>{Ue(s,n,e,t,i)}),Ye(n,e)}function Ue(n,e,t,i,r){const s=He[n];if(!s)throw new Error("Unexpected texture name encountered.");const o=e[s],a=o==null?void 0:o.fileLink;a?n==="reflectionTexture"?a.endsWith(".env")||a.endsWith(".dds")?i.addCubeTextureTask(n,a,void 0,!1,void 0,!0):a.endsWith(".hdr")?i.addHDRCubeTextureTask(n,a,128,!1,!0,!1):i.addTextureTask(n,a,!1,!1):i.addTextureTask(n,a,!1,!1):r&&t[n]&&(t[n]&&t[n].dispose(),t[n]=null,We(n,t))}function We(n,e){n==="opacityTexture"&&(e.useAlphaFromAlbedoTexture=!0),n==="metallicTexture"&&(e.useRoughnessFromMetallicTextureAlpha=!1,e.useRoughnessFromMetallicTextureGreen=!1,e.useMetallnessFromMetallicTextureBlue=!1),n==="refractionTexture"&&(e.subSurface.isRefractionEnabled=!1,e.subSurface.refractionIntensity=1),n==="reflectionTexture"&&(e.environmentIntensity=1),n==="emissiveTexture"&&(e.emissiveIntensity=0,e.emissiveColor=new b.Color3(0,0,0),e.reflectionTexture)}function Qe(n,e,t,i){if(!e){console.error("Failed to apply texture to material: material is null.");return}n==="opacityTexture"&&(e.useAlphaFromAlbedoTexture=!1),n==="metallicTexture"&&(e.useRoughnessFromMetallicTextureAlpha=!1,e.useRoughnessFromMetallicTextureGreen=!0,e.useMetallnessFromMetallicTextureBlue=!0),n==="refractionTexture"&&(e.subSurface.isRefractionEnabled=!0,e.subSurface.refractionIntensity=t.refractionIntensity||1),n==="reflectionTexture"&&(e.environmentIntensity=t.reflectionIntensity||1,i.isCube&&(i.rotationY=t.reflectionRotation?t.reflectionRotation*Math.PI/180:0)),e[n]=i,n==="emissiveTexture"&&(e.emissiveColor=new b.Color3(1,1,1),e.emissiveIntensity=1)}function Ye(n,e){n.clearCoat&&(n.clearCoat===R.RemoveWhenSelected?(e.clearCoat.isEnabled=!1,e.clearCoat.indexOfRefraction=1.5):n.clearCoat===R.ApplyWhenSelected&&(e.clearCoat.isEnabled=!0,e.clearCoat.indexOfRefraction=n.clearCoatIOR||e.clearCoat.indexOfRefraction))}class Ze{constructor(e,t,i){this.materialVariantMap=new Map,this.keysThatRemovedBaseModel=[],this.loadedContainerForKey=new Map,this.loadedMaterialsForKey=new Map,this.scene=e,this.renameClonedAsset=t,this.setBaseModelEnabled=i}async applyMaterial(e,t,i,r){return new Promise(s=>{const o=this.materialVariantMap.get(e);this.materialVariantMap.set(e,{...o,...t});const a=this.renameClonedAsset(e),l=this.scene.materials.filter(h=>h.name===a);if(l.length===0){s();return}const d=new Se.AssetsManager(this.scene);d.useDefaultLoadingScreen=!1,l.forEach(h=>Ke(t,h,d,r)),d.onProgress=(h,g,m)=>{i&&i(h/g*100,100,m.name)},d.onFinish=h=>{h.forEach(g=>{const m=g;i&&i(100,100,g.name),this.scene.materials.filter(v=>v.name===a).forEach(v=>Qe(g.name,v,t,m.texture))}),s()},d.loadAsync()})}async applyModel(e,t,i,r,s,o,a){var g;if(i&&t&&!this.keysThatRemovedBaseModel.includes(e)&&this.keysThatRemovedBaseModel.push(e),!i)return this.keysThatRemovedBaseModel.includes(e)&&this.keysThatRemovedBaseModel.length===1&&await this.setBaseModelEnabled(!0),(g=this.loadedContainerForKey.get(e))==null||g.dispose(),this.loadedContainerForKey.delete(e),this.loadedMaterialsForKey.delete(e),this.keysThatRemovedBaseModel=this.keysThatRemovedBaseModel.filter(m=>m!==e),Promise.resolve(void 0);const d=(await S(i,this.scene,r)).instantiateModelsToScene(this.renameClonedAsset,!0);if(this.loadedContainerForKey.has(e)&&(this.loadedContainerForKey.get(e).dispose(),this.loadedContainerForKey.delete(e),this.loadedMaterialsForKey.delete(e)),s){const m=o&&o(),f=s.name?this.renameClonedAsset(s.name):void 0;if(Z(d.animationGroups,s.loop,s.to,s.from,f),m!=null){const v=a&&a()||!0;Ge(d.animationGroups,m+(v?2:0),f)}}t&&await this.setBaseModelEnabled(!1),this.loadedContainerForKey.set(e,d),this.loadedMaterialsForKey.set(e,X(d));const h=[];return this.materialVariantMap.forEach(async(m,f)=>{h.push(this.applyMaterial(f,m))}),await Promise.all(h),d}dispose(){this.loadedContainerForKey.forEach(e=>e==null?void 0:e.dispose()),this.loadedContainerForKey.clear(),this.loadedMaterialsForKey.forEach(e=>e.forEach(t=>t==null?void 0:t.dispose())),this.loadedMaterialsForKey.clear(),this.materialVariantMap.clear(),this.keysThatRemovedBaseModel=[]}getAllMaterials(){const e=[];return this.loadedMaterialsForKey.forEach(t=>{t.forEach(i=>{e.includes(i)||e.push(i)})}),e}getAnimationGroups(){const e=[];return this.loadedContainerForKey.forEach(t=>{e.push(...t.animationGroups)}),e}}function X(n){const e=[];return n.rootNodes.forEach(t=>{t.getChildMeshes().forEach(i=>{i.material&&!e.includes(i.material)&&e.push(i.material),i.subMeshes&&i.subMeshes.forEach(r=>{const s=r.getMaterial(!1);s&&!e.includes(s)&&e.push(s)})})}),e}function J(n,e=""){return n.map(t=>({name:t.name.substring(e.length),loop:t.loopAnimation,to:t.to,from:t.from}))}class $e{constructor(e){this.metadata=new Map,this.materialSelectedObservable=new M.Observable,this.materialDeselectedObservable=new M.Observable,this.materialVariantObservable=new M.Observable,this.modelVariantObservable=new M.Observable,this.materialReadyToLoadCallbacks=new Map,this.modelReadyToLoadCallbacks=new Map,this.dynamicTextures=new Map,this.queuedMaterialChanges=new Map,this.materialChangesInProgress=[],this.queuedModelChanges=new Map,this.modelChangesInProgress=[],this.isExecutingAnimation=!1,this.animations=[],this.initialized=!1,this.materials=[];const{enablePicking:t,modelDetails:i,previewService:r,progressHandler:s,scene:o}=e;this.enablePicking=t,this.contextService=i.contextService,this.id=ke(),this.previewService=r,this.scene=o,this.variantManager=new Ze(o,this.renameClonedAsset.bind(this),this.setBaseModelEnabled.bind(this)),this.transformRoot=new Oe.TransformNode("root",this.scene);const a=async()=>{if(!i.model)throw new Error("Model container constructed with no URL. This is currently unsupported.");return this.assetContainer=await S(i.model,o,s),await this.instantiate(),this};this.importPromise=a()}async applyMaterialVariant(e,t,i,r){if(!this.initialized){if(this.materialReadyToLoadCallbacks.has(e)){const o=this.materialReadyToLoadCallbacks.get(e);o==null||o.set(t,this.applyMaterialVariant.bind(this,e,t,i,r))}else{this.materialReadyToLoadCallbacks.set(e,new Map);const o=this.materialReadyToLoadCallbacks.get(e);o==null||o.set(t,this.applyMaterialVariant.bind(this,e,t,i,r))}return}const s=async()=>{await this.variantManager.applyMaterial(e,i,(o,a,l)=>{this.materialVariantObservable.notifyObservers({remainingCount:o,totalCount:a,taskName:l})},r)};if(this.materialChangesInProgress.includes(e)){if(this.queuedMaterialChanges.has(e)){const o=this.queuedMaterialChanges.get(e);o==null||o.set(t,s)}else{this.queuedMaterialChanges.set(e,new Map);const o=this.queuedMaterialChanges.get(e);o==null||o.set(t,s)}return}if(this.materialChangesInProgress.push(e),await s(),this.queuedMaterialChanges.has(e)){const o=this.queuedMaterialChanges.get(e);if(!o)throw new Error("Target material is undefined");o.forEach(async a=>{await a()}),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 r=()=>this.variantManager.applyModel(e,i,t==null?void 0:t.model,a=>{this.modelVariantObservable.notifyObservers({...a,key:e})},this.lastPlayedAnimation,this.getCurrentAnimationFrame.bind(this),this.getAnimationIsPlaying.bind(this));if(this.modelChangesInProgress.includes(e)){this.queuedModelChanges.set(e,r);return}const o=await(async()=>{this.modelChangesInProgress.push(e);let a=await r();if(this.queuedModelChanges.has(e)){const l=this.queuedModelChanges.get(e);if(!l)throw new Error("Queued change resolved undefined");a=await l(),this.queuedModelChanges.delete(e)}return this.modelChangesInProgress.splice(this.modelChangesInProgress.indexOf(e),1),a})();this.contextService||(this.contextService=t==null?void 0:t.contextService),o?this.configureModelInstance(o):this.configureGlowLayer()}dispose(){var e;this.destroyInstance(),this.variantManager.dispose(),this.dynamicTextures.forEach(t=>t==null?void 0:t.dispose()),this.dynamicTextures.clear(),this.materials.forEach(t=>t&&(t==null?void 0:t.dispose())),this.materials=[],(e=this.transformRoot)==null||e.dispose(),this.transformRoot=void 0,this.previewService.modelUnloaded(this)}executeAnimation(e){if(!this.initialized)return this.queuedModelAnimation=e,Promise.resolve();let t=()=>{};const i=async()=>{this.lastPlayedAnimation=e,this.isExecutingAnimation=!0,await new Promise(r=>{var o;const s=[...((o=this.modelInstance)==null?void 0:o.animationGroups)||[],...this.variantManager.getAnimationGroups()];Z(s,e.loop,e.to,e.from,e.name?this.renameClonedAsset(e.name):void 0,r)}),this.isExecutingAnimation=!1,this.queuedAnimationFunction&&this.queuedAnimationFunction(),this.queuedAnimationFunction=void 0,t()};return this.isExecutingAnimation?(this.queuedAnimationFunction=i,new Promise(r=>{t=r})):i()}getAnimations(e){return[...this.animations,...e?J(this.variantManager.getAnimationGroups(),this.renameClonedAsset("")):[]]}getId(){return this.id}listMaterials(){var t;const e=(t=this.scene)==null?void 0:t.materials.filter(i=>i.name.startsWith(this.id));return e?e.map(i=>({id:i.id,name:this.stripIdFromName(i.name)})):[]}registerMaterialSelectedCallback(e){this.materialSelectedObservable.add(e)}unregisterMaterialSelectedCallback(e){this.materialSelectedObservable.removeCallback(e)}registerMaterialDeselectedCallback(e){this.materialDeselectedObservable.add(e)}unregisterMaterialDeselectedCallback(e){this.materialDeselectedObservable.removeCallback(e)}get position(){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to requesting position!");return this.transformRoot.position}set position(e){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to setting position!");this.transformRoot.position=new p.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=p.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 p.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 F.ActionManager(this.scene)),i.actionManager.registerAction(new z.ExecuteCodeAction(F.ActionManager.OnPointerOverTrigger,r=>{r.meshUnderPointer&&i.material&&this.materialSelectedObservable.notifyObservers({id:i.material.id,name:this.stripIdFromName(i.material.name)})})),i.actionManager.registerAction(new z.ExecuteCodeAction(F.ActionManager.OnPointerOutTrigger,()=>{i.material&&this.materialDeselectedObservable.notifyObservers({id:i.material.id,name:this.stripIdFromName(i.material.name)})})))})})}getInitializationPromise(){return this.importPromise}getIsInitialized(){return this.initialized}getQueuedMaterialVariantCount(){return this.materialReadyToLoadCallbacks.size}getQueuedModelVariantCount(){return this.modelReadyToLoadCallbacks.size}configureGlowLayer(){const e=i=>i instanceof O.PBRMaterial&&i.emissiveTexture!==null;this.materials.some(e)||this.variantManager.getAllMaterials().some(e)?this.previewService.getGlowLayerManager().includeMeshes(this.getAllMeshes()):this.previewService.getGlowLayerManager().removeMeshes(this.getAllMeshes())}configureModelInstance(e){var s;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,r=this.transformRoot.scaling;this.transformRoot.position=p.Vector3.Zero(),this.transformRoot.rotationQuaternion=p.Quaternion.Identity(),this.transformRoot.scaling=p.Vector3.One();for(const o of e.rootNodes){o.parent=this.transformRoot;for(const a of o.getChildMeshes(!1))a.alwaysSelectAsActiveMesh=!0}this.transformRoot.position=t,this.transformRoot.rotationQuaternion=i,this.transformRoot.scaling=r,this.canvasPanels=((s=this.contextService)==null?void 0:s.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 Le.Mesh)).flat()}async instantiate(){if(!this.assetContainer)throw new Error("Attempted to instantiate ModelContainer without an AssetContainer");this.modelInstance=this.assetContainer.instantiateModelsToScene(this.renameClonedAsset.bind(this),!0),this.materials=X(this.modelInstance),this.configureModelInstance(this.modelInstance),this.animations=J(this.modelInstance.animationGroups,this.renameClonedAsset("")),this.initialized=!0,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 r=this.dynamicTextures.get(i);r&&t.getStaticContextDirty()&&r.isReady()&&(r.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)}getCurrentAnimationFrame(){var t;const e=[...((t=this.modelInstance)==null?void 0:t.animationGroups)||[],...this.variantManager.getAnimationGroups()];for(const i of e)if(i.animatables.length>0&&i.animatables[0].masterFrame!==void 0&&i.animatables[0].masterFrame!==null)return i.animatables[0].masterFrame;return 0}getAnimationIsPlaying(){var t;const e=[...((t=this.modelInstance)==null?void 0:t.animationGroups)||[],...this.variantManager.getAnimationGroups()];for(const i of e)if(i.isPlaying)return!0;return!1}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.scene.onAfterRenderObservable.addOnce(()=>{this.queuedModelAnimation&&(this.executeAnimation(this.queuedModelAnimation),this.queuedModelAnimation=void 0)})}}class B extends y.ArcRotateCamera{constructor(e,t,i,r,s,o,a,l){super(e,t,i,r,s,o,l),this.lastFocus=new p.Vector3(0,0,0),this._isRunningFramingBehavior=!1,this.panDenominator=1,this.panEnabled=!0,this.minZ=.01,this.updateRadiusBounds(this.radius),this.enableFramingBehavior(),this.wheelDeltaPercentage=.01,this.pinchDeltaPercentage=.005,this.useNaturalPinchZoom=!0,a.camera.autoOrientation&&(this.alpha+=Math.PI),a&&(a.camera.limits.min.beta&&(this.lowerBetaLimit=a.camera.limits.min.beta),a.camera.limits.max.beta&&(this.upperBetaLimit=a.camera.limits.max.beta),a.camera.limits.min.alpha&&(this.lowerAlphaLimit=a.camera.limits.min.alpha),a.camera.limits.max.alpha&&(this.upperAlphaLimit=a.camera.limits.max.alpha),a.camera.limits.min.radius&&(this.lowerRadiusLimit=a.camera.limits.min.radius),a.camera.limits.max.radius&&(this.upperRadiusLimit=a.camera.limits.max.radius),a.camera.autoRotation.enabled&&this.enableAutoRotationBehavior(a.camera.autoRotation.idleTimeMs))}updateConfiguration(e){e&&(this.lowerBetaLimit=e.camera.limits.min.beta??null,this.upperBetaLimit=e.camera.limits.max.beta??null,this.lowerAlphaLimit=e.camera.limits.min.alpha??null,this.upperAlphaLimit=e.camera.limits.max.alpha??null,e.camera.autoRotation.enabled?this.enableAutoRotationBehavior(e.camera.autoRotation.idleTimeMs):this.disableAutoRotationBehavior())}get isRunningFramingBehavior(){return this._isRunningFramingBehavior}set isRunningFramingBehavior(e){this._isRunningFramingBehavior=e,!e&&this.framingBehaviourCallback&&(this.framingBehaviourCallback(),this.framingBehaviourCallback=void 0)}setPanEnabled(e){this.panEnabled=e,this.panningSensibility=1e3/this.panDenominator,this.panningAxis=e?new p.Vector3(1,1,0):new p.Vector3(0,0,0)}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=j(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){this._isRunningFramingBehavior=!0,this.framingBehaviourCallback=e;const i=this.getFramingBehavior();i.framingTime=t||800;const r=()=>{this.isRunningFramingBehavior=!1},s=j(this._scene),o=s.max.subtract(s.min),a=s.min.add(o.scale(.5));this.updateRadiusBounds(o.length()*1.5),this.wheelPrecision=100/this.radius,this.panningInertia=0,this.panningOriginTarget.copyFrom(a),this.panDenominator=o.length(),this.lastFocus.copyFrom(a),i.zoomOnBoundingInfo(s.min,s.max,void 0,r),i.framingTime=0}enableAutoRotationBehavior(e=5e3){this.useAutoRotationBehavior=!0;const t=this.getAutoRotationBehavior();t&&(t.idleRotationWaitTime=e)}disableAutoRotationBehavior(){this.useAutoRotationBehavior=!1}updateRadiusBounds(e){this.maxZ=e*1e3,this.lowerRadiusLimit=e*.01,this.upperRadiusLimit=1.5*e,this.wheelPrecision=100/e,this.pinchPrecision=300/e}static create(e,t,i){var l;const r=j(e),s=r.max.subtract(r.min),o=r.min.add(s.scale(.5)),a=new B("ProductCamera",-(Math.PI/2),Math.PI/2,s.length()*1.5,o,e,t);return a.setPanEnabled(((l=t.options)==null?void 0:l.noPan)!==void 0?!t.options.noPan:!0),a.panningInertia=0,a.panningOriginTarget.copyFrom(o),a.panDenominator=s.length(),a.onAfterCheckInputsObservable.addOnce(()=>{a.setPanEnabled(a.panEnabled)}),i&&(e.activeCamera=a),a}}function j(n){if(n.meshes.length===0)return{min:new p.Vector3(-1,-1,-1),max:new p.Vector3(1,1,1)};const e=n.meshes.filter(t=>t.name.toLowerCase().endsWith("_t")||t.name.toLowerCase().includes("_t_"));return n.getWorldExtends(t=>t.isVisible&&t.isEnabled()&&(e.length===0||e.includes(t)))}class Xe{constructor(e,t=!1,i=void 0){this.renderingPipeline=new Be.DefaultRenderingPipeline("default",t,e,i?[i]:void 0,!1),this.renderingPipeline.isSupported&&(this.renderingPipeline.prepare(),this.setConfiguration(u))}dispose(){this.renderingPipeline.dispose()}getConfiguration(){return this.currentConfiguration}setConfiguration(e){var t,i,r,s,o,a,l,d,h,g,m,f,v,_,ee,te,ie,ne,se,re,ae,oe,le,he,ce,de,ue,ge,me,pe,fe,be,ve;if(this.renderingPipeline.isSupported){if(this.renderingPipeline.samples=((t=e.antiAliasing)==null?void 0:t.samples)??u.antiAliasing.samples,this.renderingPipeline.fxaaEnabled=((i=e.antiAliasing)==null?void 0:i.fxaaEnabled)??u.antiAliasing.fxaaEnabled,this.renderingPipeline.bloomEnabled=((r=e.bloom)==null?void 0:r.enabled)??u.bloom.enabled,this.renderingPipeline.bloomKernel=((s=e.bloom)==null?void 0:s.kernel)??u.bloom.kernel,this.renderingPipeline.bloomScale=((o=e.bloom)==null?void 0:o.scale)??u.bloom.scale,this.renderingPipeline.bloomThreshold=((a=e.bloom)==null?void 0:a.threshold)??u.bloom.threshold,this.renderingPipeline.bloomWeight=((l=e.bloom)==null?void 0:l.weight)??u.bloom.weight,this.renderingPipeline.chromaticAberrationEnabled=((d=e.chromaticAberration)==null?void 0:d.enabled)??u.chromaticAberration.enabled,this.renderingPipeline.chromaticAberration.aberrationAmount=((h=e.chromaticAberration)==null?void 0:h.aberrationAmount)??u.chromaticAberration.aberrationAmount,this.renderingPipeline.chromaticAberration.radialIntensity=((g=e.chromaticAberration)==null?void 0:g.radialIntensity)??u.chromaticAberration.radialIntensity,this.renderingPipeline.chromaticAberration.direction=(m=e.chromaticAberration)!=null&&m.direction?new p.Vector2(e.chromaticAberration.direction.x,e.chromaticAberration.direction.y):new p.Vector2(u.chromaticAberration.direction.x,u.chromaticAberration.direction.y),this.renderingPipeline.imageProcessing.colorCurvesEnabled=((f=e.colorCurves)==null?void 0:f.enabled)??u.colorCurves.enabled,this.renderingPipeline.imageProcessing.colorCurves=e.colorCurves?this.updateColorCurve(e.colorCurves):new G.ColorCurves,this.renderingPipeline.depthOfFieldEnabled=((v=e.depthOfField)==null?void 0:v.enabled)??u.depthOfField.enabled,e.depthOfField)switch(e.depthOfField.blurLevel??u.depthOfField.blurLevel){case"Low":this.renderingPipeline.depthOfFieldBlurLevel=I.DepthOfFieldEffectBlurLevel.Low;break;case"Medium":this.renderingPipeline.depthOfFieldBlurLevel=I.DepthOfFieldEffectBlurLevel.Medium;break;case"High":this.renderingPipeline.depthOfFieldBlurLevel=I.DepthOfFieldEffectBlurLevel.High;break}if(this.renderingPipeline.depthOfField.focalLength=((_=e.depthOfField)==null?void 0:_.focalLength)??u.depthOfField.focalLength,this.renderingPipeline.depthOfField.fStop=((ee=e.depthOfField)==null?void 0:ee.fStop)??u.depthOfField.fStop,this.renderingPipeline.depthOfField.focusDistance=((te=e.depthOfField)==null?void 0:te.focusDistance)??u.depthOfField.focusDistance,this.renderingPipeline.depthOfField.lensSize=((ie=e.depthOfField)==null?void 0:ie.lensSize)??u.depthOfField.lensSize,this.renderingPipeline.grainEnabled=((ne=e.grain)==null?void 0:ne.enabled)??u.grain.enabled,this.renderingPipeline.grain.animated=((se=e.grain)==null?void 0:se.animated)??u.grain.animated,this.renderingPipeline.grain.intensity=((re=e.grain)==null?void 0:re.intensity)??u.grain.intensity,this.renderingPipeline.imageProcessing.contrast=((ae=e.misc)==null?void 0:ae.contrast)??u.misc.contrast,this.renderingPipeline.imageProcessing.exposure=((oe=e.misc)==null?void 0:oe.exposure)??u.misc.exposure,this.renderingPipeline.imageProcessing.toneMappingEnabled=((le=e.misc)==null?void 0:le.toneMappingEnabled)??u.misc.toneMappingEnabled,this.renderingPipeline.imageProcessing.toneMappingEnabled)switch(e.misc.toneMappingType??u.misc.toneMappingType){case"Standard":this.renderingPipeline.imageProcessing.toneMappingType=A.ImageProcessingConfiguration.TONEMAPPING_STANDARD;break;case"ACES":this.renderingPipeline.imageProcessing.toneMappingType=A.ImageProcessingConfiguration.TONEMAPPING_ACES;break}if(this.renderingPipeline.sharpenEnabled=((he=e.sharpen)==null?void 0:he.enabled)??u.sharpen.enabled,this.renderingPipeline.sharpen.colorAmount=((ce=e.sharpen)==null?void 0:ce.colorAmount)??u.sharpen.colorAmount,this.renderingPipeline.sharpen.edgeAmount=((de=e.sharpen)==null?void 0:de.edgeAmount)??u.sharpen.edgeAmount,this.renderingPipeline.imageProcessing.vignetteEnabled=((ue=e.vignette)==null?void 0:ue.enabled)??u.vignette.enabled,(ge=e.vignette)!=null&&ge.center?(this.renderingPipeline.imageProcessing.vignetteCenterX=e.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=e.vignette.center.y):(this.renderingPipeline.imageProcessing.vignetteCenterX=u.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=u.vignette.center.y),e.vignette)switch(((me=e.vignette)==null?void 0:me.blendMode)??u.vignette.blendMode){case"Multiply":this.renderingPipeline.imageProcessing.vignetteBlendMode=A.ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY;break;case"Opaque":this.renderingPipeline.imageProcessing.vignetteBlendMode=A.ImageProcessingConfiguration.VIGNETTEMODE_OPAQUE;break}(pe=e.vignette)!=null&&pe.colorRgba?this.renderingPipeline.imageProcessing.vignetteColor=new b.Color4(e.vignette.colorRgba.r,e.vignette.colorRgba.g,e.vignette.colorRgba.b,e.vignette.colorRgba.a):(fe=e.vignette)!=null&&fe.colorHex?this.renderingPipeline.imageProcessing.vignetteColor=b.Color4.FromHexString(e.vignette.colorHex):this.renderingPipeline.imageProcessing.vignetteColor=new b.Color4(u.vignette.colorRgba.r,u.vignette.colorRgba.g,u.vignette.colorRgba.b,u.vignette.colorRgba.a),this.renderingPipeline.imageProcessing.vignetteStretch=((be=e.vignette)==null?void 0:be.stretch)??u.vignette.stretch,this.renderingPipeline.imageProcessing.vignetteWeight=((ve=e.vignette)==null?void 0:ve.weight)??u.vignette.weight,this.renderingPipeline.prepare(),this.currentConfiguration=e}}updateColorCurve(e){const t=new G.ColorCurves;return t.globalDensity=e.globalDensity??t.globalDensity,t.globalExposure=e.globalExposure??t.globalExposure,t.globalHue=e.globalHue??t.globalHue,t.globalSaturation=e.globalSaturation??t.globalSaturation,t.highlightsDensity=e.highlightsDensity??t.highlightsDensity,t.highlightsExposure=e.highlightsExposure??t.highlightsExposure,t.highlightsHue=e.highlightsHue??t.highlightsHue,t.highlightsSaturation=e.highlightsSaturation??t.highlightsSaturation,t.midtonesDensity=e.midtonesDensity??t.midtonesDensity,t.midtonesExposure=e.midtonesExposure??t.midtonesExposure,t.midtonesHue=e.midtonesHue??t.midtonesHue,t.midtonesSaturation=e.midtonesSaturation??t.midtonesSaturation,t.shadowsDensity=e.shadowsDensity??t.shadowsDensity,t.shadowsExposure=e.shadowsExposure??t.shadowsExposure,t.shadowsHue=e.shadowsHue??t.shadowsHue,t.shadowsSaturation=e.shadowsSaturation??t.shadowsSaturation,t}}Pe.GLTF2.GLTFLoader.RegisterExtension("glbPostProcessor",function(n){return new je(n)}),L.SceneLoader.OnPluginActivatedObservable.add(n=>{if(n.name==="gltf"){const e=n;e.transparencyAsCoverage=!0}});function q(n){return new p.Vector3(n.x,n.y,n.z)}function D(n){return{x:n.x,y:n.y,z:n.z}}class Je{constructor(e){var l;this.focusLostNotified=!1,this.focusLostObservable=new M.Observable,this.modelLoadEventCallbacks=[],this.modelContainers=new Map,this.plugins=[],this.initComplete=!1,this.isAnimatingCamera=!1,this.renderLoop=()=>{if(!this.engine.views)return;this.modelContainers.forEach(h=>{h.updateDynamicTextures()}),this.scene.autoClear=!0,this.scene.autoClearDepthAndStencil=!0,this.scene.render(),this.camera.isRunningFramingBehavior&&this.camera.getFramingBehavior().isUserIsMoving&&(this.camera.isRunningFramingBehavior=!1);const d=Math.max((this.camera.lowerRadiusLimit??1)*.01,.001);!this.camera.isRunningFramingBehavior&&!this.camera.target.equalsWithEpsilon(this.camera.lastFocus,d)&&!this.focusLostNotified&&(this.focusLostObservable.notifyObservers(void 0),this.focusLostNotified=!0),this.screenshotPrepareResolve&&(this.screenshotPrepareResolve(),this.screenshotPrepareResolve=void 0)},this.configuration=new K(e);const i=(()=>{if(!(e!=null&&e.noRender))return this.configuration.createCanvas()})(),r="1.5.6";we.DracoCompression.Configuration={decoder:{wasmUrl:`https://www.gstatic.com/draco/versioned/decoders/${r}/draco_wasm_wrapper_gltf.js`,wasmBinaryUrl:`https://www.gstatic.com/draco/versioned/decoders/${r}/draco_decoder_gltf.wasm`,fallbackUrl:`https://www.gstatic.com/draco/versioned/decoders/${r}/draco_decoder_gltf.js`}},i&&(i.getContext("webgl2")||i.getContext("webgl"));const s=console.log;console.log=()=>{};const o=i?new V.Engine(i,!0,{adaptToDeviceRatio:!0,limitDeviceRatio:2,premultipliedAlpha:!1,preserveDrawingBuffer:!!(e!=null&&e.backgroundImage),audioEngine:!1,stencil:this.configuration.highlights.enabled,forceSRGBBufferSupportState:!0}):new ye.NullEngine;console.log=s,o.hideLoadingUI(),window.addEventListener("resize",this.fireResizeEvent.bind(this)),this.engine=o,this.scene=new xe.Scene(o),this.camera=B.create(this.scene,this.configuration),this.scene.activeCamera=this.camera,this.renderingPipeline=new Xe(this.scene,!1,this.camera),this.scene.clearColor=this.configuration.scene.clearColor;const a=k.CubeTexture.CreateFromPrefilteredData(this.configuration.scene.environment.file,this.scene);a.rotationY=this.configuration.scene.environment.rotationY,this.scene.environmentTexture=a,this.scene.environmentIntensity=this.configuration.scene.environment.intensity,(l=this.configuration.options)!=null&&l.renderingPipelineConfiguration?this.renderingPipeline.setConfiguration(this.configuration.options.renderingPipelineConfiguration):(this.scene.imageProcessingConfiguration.exposure=this.configuration.lighting.exposure,this.scene.imageProcessingConfiguration.contrast=this.configuration.lighting.contrast),this.glowLayerManager=new qe(this.scene,this.configuration.emissiveGlowIntensity),this.scene.autoClear=!0,this.scene.autoClearDepthAndStencil=!0,this.initPromise=new Promise(d=>{this.scene.onReadyObservable.addOnce(()=>{this.initComplete=!0,d()})}),this.engine.runRenderLoop(this.renderLoop)}getInitializationPromise(){return this.initPromise}getInitializationComplete(){return this.initComplete}getEngineContext(){return{engine:this.engine,scene:this.scene,camera:this.camera}}registerFocusLostListener(e){this.focusLostObservable.add(e)}unregisterFocusLostListener(e){this.focusLostObservable.removeCallback(e)}registerModelLoadEventListener(e){this.modelLoadEventCallbacks.push(e)}unregisterModelLoadEventListener(e){const t=this.modelLoadEventCallbacks.indexOf(e);t>-1&&this.modelLoadEventCallbacks.splice(t,1)}registerView(e){const t=e.height,i=e.width;this.engine.registerView(e,void 0,!0),e.setAttribute("height",t.toString()),e.setAttribute("width",i.toString()),this.orbitEnabled()||this.setCameraState(T.Pan),this.reattachControls(e)}getNumViewports(){var e;return((e=this.engine.views)==null?void 0:e.length)||0}unregisterView(e){this.engine.unRegisterView(e)}shutdown(){this.plugins.forEach(e=>e.dispose(!0)),this.renderingPipeline.dispose(),this.engine&&this.engine.dispose(),window.removeEventListener("resize",this.fireResizeEvent)}executeCameraAnimation(e){if(!this.camera||this.scene.activeCamera!==this.camera||this.getAllModels().length===0||!this.getAllModels().some(r=>r.getIsInitialized()))return this.queuedCameraAnimation=e,Promise.resolve();let t=()=>{};const i=async()=>{this.isAnimatingCamera=!0,await ze(this.scene,this.scene.activeCamera,e),this.isAnimatingCamera=!1,this.queuedAnimationFunction&&this.queuedAnimationFunction(),this.queuedAnimationFunction=void 0,t()};return this.isAnimatingCamera?(this.queuedAnimationFunction=i,new Promise(r=>{t=r})):i()}getCameraPose(){if(this.scene&&this.camera)return{lonDeg:Math.round(this.camera.alpha*180/Math.PI),latDeg:Math.round(this.camera.beta*180/Math.PI),radius:Math.round((this.camera.radius+Number.EPSILON)*1e4)/1e4,target:{x:this.camera.target.x,y:this.camera.target.y,z:this.camera.target.z}}}setCameraPose(e){this.scene&&this.camera&&(this.camera.target=new p.Vector3(e.target.x,e.target.y,e.target.z),this.camera.radius=e.radius,this.camera.alpha=e.latDeg,this.camera.beta=e.lonDeg)}setCameraState(e){var t,i;if(!((t=this.engine)!=null&&t.views)||!((i=this.engine)!=null&&i.views[0]))throw new Error("No views attached, camera state requires a view to attach controls onto.");e===T.Orbit?this.reattachControls(this.engine.views[0].target,2):this.reattachControls(this.engine.views[0].target,0)}animateToLastCameraFocus(){let e=()=>{};const t=async()=>{this.isAnimatingCamera=!0,await new Promise(i=>{this.focusLostNotified=!1;const r=()=>{const s=this.configuration;this.camera.rerunFramingBehavior(()=>{s.camera.limits.min.radius&&(this.camera.lowerRadiusLimit=s.camera.limits.min.radius),s.camera.limits.max.radius&&(this.camera.upperRadiusLimit=s.camera.limits.max.radius),i()})};this.scene.onAfterRenderObservable.addOnce(r)}),this.isAnimatingCamera=!1,this.queuedAnimationFunction&&this.queuedAnimationFunction(),this.queuedAnimationFunction=void 0,e()};return this.isAnimatingCamera?(this.queuedAnimationFunction=t,new Promise(i=>{e=i})):t()}setAutoRotation(e){!this.configuration.camera.autoRotation.enabled||!this.camera||(e?this.camera.enableAutoRotationBehavior(this.configuration.camera.autoRotation.idleTimeMs):this.camera.disableAutoRotationBehavior())}getCurrentConfiguration(){return this.configuration.options}async renderSceneScreenshot(e,t){if(!this.camera)throw new Error("Missing product camera, cannot render screenshot!");const i=new y.ArcRotateCamera("screenshotCamera",0,0,0,p.Vector3.Zero(),this.scene);try{const r=t.latDeg*Math.PI/180,s=t.lonDeg*Math.PI/180;i.target=t.target?new p.Vector3(t.target.x,t.target.y,t.target.z):p.Vector3.Zero(),i.alpha=s,i.beta=r,i.radius=t.radius||this.camera.radius,i.minZ=.01,this.scene.render();const o=await Me.Tools.CreateScreenshotUsingRenderTargetAsync(this.engine,i,e,"image/png",2,!0);return i.dispose(),o}catch{throw i.isDisposed()||i.dispose(),new Error("Failed to render screenshot")}}orbitEnabled(){const e=this.configuration;if(!e)return!0;const t=e.camera.limits.min.alpha,i=e.camera.limits.max.alpha,r=e.camera.limits.min.beta,s=e.camera.limits.max.beta;if(t===void 0||i===void 0||r===void 0||s===void 0)return!0;const o=[t,i],a=[r,s],l=o.every(h=>h===t),d=a.every(h=>h===r);return!l&&!d}fireResizeEvent(){this.getNumViewports()>0&&this.engine.resize()}setHighlights(e,t){var r;e.length===0&&((r=this.highlightLayer)==null||r.dispose(),this.highlightLayer=void 0),this.highlightLayer||(this.highlightLayer=new Ce.HighlightLayer("highlights",this.scene,{isStroke:!0,blurVerticalSize:.85,blurHorizontalSize:.85}),this.highlightLayer.innerGlow=!0,this.highlightLayer.outerGlow=!1),this.highlightLayer.removeAllMeshes();const i=t?new b.Color3(t[0],t[1],t[2]).toLinearSpace():void 0;e.forEach(s=>{const o=this.scene.materials.find(a=>a.name===s.name&&a.id===s.id);o&&o.getBindedMeshes().forEach(a=>{var l;return(l=this.highlightLayer)==null?void 0:l.addMesh(a,i||b.Color3.FromHexString("#fcba03"))})})}setRenderingPipelineConfiguration(e){this.renderingPipeline&&this.renderingPipeline.setConfiguration(e)}loadModel(e,t){const i=new $e({enablePicking:this.configuration.highlights.enabled,modelDetails:e,scene:this.scene,previewService:this,progressHandler:t});return i.getInitializationPromise().then(()=>{this.modelContainers.size<=1&&this.camera.rerunFramingBehavior(()=>{this.scene.onAfterRenderObservable.addOnce(()=>{this.queuedCameraAnimation&&(this.executeCameraAnimation(this.queuedCameraAnimation),this.queuedCameraAnimation=void 0)})},1)}),this.configuration.highlights.enabled&&(i.registerMaterialSelectedCallback(r=>{this.setHighlights([r])}),i.registerMaterialDeselectedCallback(()=>{this.setHighlights([])})),this.modelContainers.set(i.getId(),i),this.triggerModelLoadEvent({eventType:"load",modelContainer:i}),i}async preloadModel(e){await S(e,this.scene)}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(r=>r.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 r=p.Matrix.Compose(q(i||{x:1,y:1,z:1}),p.Quaternion.FromEulerVector(q(t||{x:0,y:0,z:0})),q(e||{x:0,y:0,z:0})),s=p.Matrix.RotationAxis(p.Vector3.Up(),Math.PI),o=r.multiply(s),a=p.Vector3.Zero(),l=p.Quaternion.Identity(),d=p.Vector3.Zero();return o.decompose(d,l,a),l.multiplyInPlace(p.Quaternion.FromEulerAngles(0,Math.PI,0)),{position:D(a),rotation:D(l.toEulerAngles()),scale:D(d)}}updatePreviewOptions(e){var r,s;const t=new K(e);this.configuration.highlights.enabled!==t.highlights.enabled&&this.engine.setStencilBuffer(t.highlights.enabled),this.scene.clearColor=t.scene.clearColor;let i=this.scene.environmentTexture;this.configuration.scene.environment.file!==t.scene.environment.file&&(i=k.CubeTexture.CreateFromPrefilteredData(t.scene.environment.file,this.scene),i.rotationY=this.configuration.scene.environment.rotationY,this.scene.environmentTexture=i),i.rotationY=t.scene.environment.rotationY,this.scene.environmentIntensity=t.scene.environment.intensity,(r=t.options)!=null&&r.renderingPipelineConfiguration?this.renderingPipeline.setConfiguration(t.options.renderingPipelineConfiguration):(this.scene.imageProcessingConfiguration.exposure=t.lighting.exposure,this.scene.imageProcessingConfiguration.contrast=t.lighting.contrast),this.glowLayerManager.setIntensity(t.emissiveGlowIntensity),this.camera.updateConfiguration(t),this.camera.setPanEnabled(((s=t.options)==null?void 0:s.noPan)!==void 0?!t.options.noPan:!0),this.scene.autoClear=!0,this.scene.autoClearDepthAndStencil=!0,this.configuration=t}reattachControls(e,t=2){if(this.scene.detachControl(),this.engine.inputElement=e,this.camera){this.camera.attachControl(!0,!1,t);const i=this.camera.inputs.attached.pointers;i.multiTouchPanning=!1}this.scene.attachControl(!0,!0,!0)}}c.MaterialEffectMode=R,c.ProductCameraRig=T,c.REFLECTION_PROBE_RESOLUTION=U,c.RenderingConfiguration=w,c.SpiffCommerce3DPreviewService=Je,c.renderingPipelineDefaults=u,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(c,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/loaders/glTF/glTFFileLoader"),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/loaders/glTF/glTFFileLoader","@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):(c=typeof globalThis<"u"?globalThis:c||self,y(c.Preview={},c.arcRotateCamera,c.engine,c.nullEngine,c.highlightLayer,c.sceneLoader,c.cubeTexture,c.math_color,c.math_vector,c.dracoCompression,c.observable,c.tools,c.scene,c.glTF,c.glTFFileLoader,c.pbrMaterial,c.mirrorTexture,c.math,c.reflectionProbe,c.glowLayer,c.actionManager,c.directActions,c.mesh,c.transformNode,c.dynamicTexture,c.texture,c.animation,c.easing,c.assetsManager,c.colorCurves,c.imageProcessingConfiguration,c.RenderPipeline,c.depthOfFieldEffect))})(this,function(c,y,V,ye,Ce,L,k,b,p,we,M,Me,xe,Ae,Pe,O,Te,A,Re,Ee,F,z,Le,Oe,Fe,Ie,C,N,Se,G,P,Be,I){"use strict";var T=(s=>(s[s.Orbit=0]="Orbit",s[s.Pan=1]="Pan",s))(T||{}),R=(s=>(s.None="None",s.RemoveWhenSelected="RemoveWhenSelected",s.ApplyWhenSelected="ApplyWhenSelected",s))(R||{});const H=new Map;async function S(s,e,t){const i=H.get(s);if(i)return i;{const r=L.SceneLoader.LoadAssetContainerAsync(s,void 0,e,t);return H.set(s,r),r}}L.SceneLoader.OnPluginActivatedObservable.add(s=>{s.name==="gltf"&&(s.animationStartMode=Pe.GLTFLoaderAnimationStartMode.NONE)});class K{constructor(e){this.getSceneClearColor=()=>{var i,r,n,o;const t=(i=this.customOptions)!=null&&i.transparentBackground||(r=this.customOptions)!=null&&r.backgroundImage?0:1;if(this.customOptions&&((n=this.customOptions)!=null&&n.transparentBackground)||(o=this.customOptions)!=null&&o.backgroundImage)return new b.Color4(0,0,0,t).toLinearSpace();if(this.customOptions&&this.customOptions.backgroundColor){const a=b.Color3.FromHexString(this.customOptions.backgroundColor);return new b.Color4(a.r,a.g,a.b,t).toLinearSpace()}return new b.Color4(.98,.98,.98,t).toLinearSpace()},this.highlightColorFromConfig=()=>this.customOptions&&this.customOptions.highlightColor?this.hexToColor4(this.customOptions.highlightColor):new b.Color4(.98,.98,.98,1).toLinearSpace(),this.hexToColor4=(t,i=1)=>{const r=b.Color3.FromHexString(t);return new b.Color4(r.r,r.g,r.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,r,n;return{clearColor:this.getSceneClearColor(),transparentBackground:((e=this.customOptions)==null?void 0:e.transparentBackground)||((t=this.customOptions)==null?void 0:t.backgroundImage),environment:{file:((i=this.customOptions)==null?void 0:i.environmentFile)??"assets/model-viewer/default.env",intensity:((r=this.customOptions)==null?void 0:r.environmentIntensity)??1,rotationY:(((n=this.customOptions)==null?void 0:n.environmentRotationY)??0)*(Math.PI/180)}}}get camera(){var e,t,i,r,n,o,a,l,d,h,g,m,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:(r=this.customOptions)!=null&&r.lowerAlphaLimitDeg?((n=this.customOptions)==null?void 0:n.lowerAlphaLimitDeg)*Math.PI/180:void 0,beta:(o=this.customOptions)!=null&&o.lowerBetaLimitDeg?((a=this.customOptions)==null?void 0:a.lowerBetaLimitDeg)*Math.PI/180:void 0,radius:(l=this.customOptions)==null?void 0:l.minZoomOverride},max:{alpha:(d=this.customOptions)!=null&&d.upperAlphaLimitDeg?((h=this.customOptions)==null?void 0:h.upperAlphaLimitDeg)*Math.PI/180:void 0,beta:(g=this.customOptions)!=null&&g.upperBetaLimitDeg?((m=this.customOptions)==null?void 0:m.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,r;return{exposure:((t=(e=this.customOptions)==null?void 0:e.lighting)==null?void 0:t.exposure)??.9,contrast:((r=(i=this.customOptions)==null?void 0:i.lighting)==null?void 0:r.contrast)??1.6}}get emissiveGlowIntensity(){var e;return((e=this.customOptions)==null?void 0:e.emissiveGlowIntensity)??.5}}class w{static getDynamicTextureResolution(){return this.getIsMobile()||!w.offscreenRenderingSupported()?{width:1024,height:1024}:{width:2048,height:2048}}static shouldMipMap(){return!0}static offscreenRenderingSupported(){return navigator.userAgent.includes("SamsungBrowser")?!1:!!window.Worker&&!!window.OffscreenCanvas}static getMirrorTextureResolution(){return this.getIsMobile()?512:1024}static getIsMobile(){try{return typeof window>"u"||!window.navigator?!1:/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(window.navigator.userAgent)||window.innerWidth/window.devicePixelRatio<=480}catch{return!1}}}const U=128,u={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(r){t.extras&&Object.keys(t.extras).forEach(n=>{const o=t.extras[n];r.metadata[n]=o}),i(r)})}async loadMaterialPropertiesAsync(e,t,i){await this.loader.loadMaterialPropertiesAsync(e,t,i),this.enableMaterialExtrasIfRequired(t,i),i.needDepthPrePass=!0}dispose(){}enableMaterialExtrasIfRequired(e,t){if(!(!e.extras||!(t instanceof O.PBRMaterial))){if(e.extras.sheen){const i=t;i.sheen.isEnabled=!0,i.sheen.intensity=e.extras.sheen}if(e.extras.translucency){const i=t;i.subSurface.isTranslucencyEnabled=!0,i.subSurface.translucencyIntensity=e.extras.translucency,e.extras.translucencyR&&e.extras.translucencyG&&e.extras.translucencyB&&(i.subSurface.tintColor=new A.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(n){const o=[];return n.transformNodes.forEach(a=>{a.metadata&&a.metadata.reflective&&o.push(...a.getChildMeshes())}),n.meshes.forEach(a=>{a.metadata&&a.metadata.reflective&&!o.includes(a)&&o.push(a)}),o}function i(n,o=1){const a=n.material;if(!a)return;const l=new Te.MirrorTexture("mirror",w.getMirrorTextureResolution(),e,!0);l.renderList=t(e);const d=n.getVerticesData("normal");if(!d)throw new Error("Mirror attribute specified on: "+n.name+"But no normals exist to generate a mirror from!");n.computeWorldMatrix(!0);const h=n.getWorldMatrix(),g=A.Vector3.TransformNormal(new A.Vector3(d[0],d[1],d[2]),h).normalize(),m=A.Plane.FromPositionAndNormal(n.position,g.scale(-1));l.mirrorPlane=m,l.level=o,a.reflectionTexture=l}function r(n){const o=n.material,a=new Re.ReflectionProbe("probe-"+o.name,U,e);a.attachToMesh(n),a.renderList&&a.renderList.push(...t(e)),o.reflectionTexture=a.cubeTexture}e.meshes.forEach(n=>{const o=n.metadata;o&&(o.mirrorTexture&&i(n,o.mirrorTexture),o.reflectionProbe&&r(n))})}}class qe{constructor(e,t){this.scene=e,this.intensity=t,this.meshCount=0}setIntensity(e){this.intensity=e,this.glowLayer&&(this.glowLayer.intensity=e)}includeMeshes(e){if(e){this.glowLayer||(this.glowLayer=new Ee.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)}}}function De(s,e,t,i,r=""){t.forEach(n=>{const o=n.getID(),a=n.getName(),l=w.getDynamicTextureResolution();s.filter(h=>h.name===r+a).forEach(h=>{const g=i.get(o),m=!1;if(g)W(h,g),g.update(m);else{const f=Ve(a,e,l.width,l.height);i.set(o,f),n.setStaticContext(f.getContext()),W(h,f),f.onLoadObservable.addOnce(()=>{f.update(m)})}})})}function Ve(s,e,t,i){const r=new Fe.DynamicTexture(s,{width:t,height:i},e,w.shouldMipMap(),Ie.Texture.TRILINEAR_SAMPLINGMODE,V.Engine.TEXTUREFORMAT_RGBA),n=r.getContext();return n&&(n.fillStyle="#f5f5f5",n.fillRect(0,0,t,i),r.update()),r}function W(s,e){if(s instanceof O.PBRMaterial){const t=s,i=t.albedoTexture;i?(e.wrapU=i.wrapU,e.wrapV=i.wrapV):(e.wrapU=1,e.wrapV=1),t.albedoTexture=e}else{const t=s,i=t.diffuseTexture;i&&(e.wrapU=i.wrapU,e.wrapV=i.wrapV),t.diffuseTexture=e}}function ke(){const s=()=>Math.floor((1+Math.random())*65536).toString(16).substring(1);return s()+s()+"-"+s()+"-"+s()+"-"+s()+"-"+s()+s()+s()}const x=60,Q=1;function Y(s){return s.targetedAnimations.map(t=>t.animation.framePerSecond).reduce((t,i)=>t+i,0)/s.targetedAnimations.length||0}function Z(s,e,t,i,r,n){const o=r?s.filter(h=>h.name===r):s;if(o.length===0){console.warn(`No animations found for name: ${r}`);return}let a=0;const l=()=>{a++,a===o.length&&n&&n()},d=(h,g,m,f,v)=>{h.stop(),h.start(g,m,f,v),n&&(g==!1||g===void 0&&!h.loopAnimation?h.onAnimationGroupEndObservable.addOnce(()=>{l()}):h.onAnimationLoopObservable.addOnce(()=>{l()}))};if(i!==void 0&&t!==void 0&&i===t){o.forEach(h=>{const g=Y(h),m=i*g;d(h,!1,Q,m,m)});return}o.forEach(h=>{const g=Y(h),m=i!==void 0?i*g:void 0,f=t!==void 0?t*g:void 0;d(h,e,Q,m,f)})}function ze(s,e,t){return new Promise(i=>{s.stopAnimation(e),e.animations=[],Math.abs(e.alpha)>2*Math.PI&&(e.alpha=Ne(e.alpha,0,2*Math.PI));const r=[],n=t.target,o=0,a=n?1:0;if(t.target&&Object.keys(t.target).length>0&&r.push(E("cameraTargetLerp","target",new p.Vector3().copyFrom(e.target),new p.Vector3(t.target.x,t.target.y,t.target.z),C.Animation.ANIMATIONTYPE_VECTOR3,o)),r.push(E("cameraAlphaLerp","alpha",e.alpha,$(t.lonDeg),C.Animation.ANIMATIONTYPE_FLOAT,a)),r.push(E("cameraBetaLerp","beta",e.beta,$(t.latDeg),C.Animation.ANIMATIONTYPE_FLOAT,a)),t.radius!==void 0){const h=Math.max(.01,t.radius);r.push(E("cameraRadiusLerp","radius",e.radius,h,C.Animation.ANIMATIONTYPE_FLOAT,a))}e.animations.push(...r);const d=e.useAutoRotationBehavior;e.disableAutoRotationBehavior(),s.beginAnimation(e,0,n?x*2:x,!1,1,()=>{e.animations=[],d&&e.enableAutoRotationBehavior(),i()})})}function $(s){return s*Math.PI/180}function E(s,e,t,i,r,n=0,o=C.Animation.ANIMATIONLOOPMODE_CONSTANT){const a=new N.QuadraticEase;a.setEasingMode(N.EasingFunction.EASINGMODE_EASEINOUT);const l=new C.Animation(s,e,x,r,o),d=[];return n>0&&d.push({frame:0,value:t}),d.push({frame:x*n,value:t}),d.push({frame:x*(n+1),value:i}),l.setKeys(d),l.setEasingFunction(a),l}function Ne(s,e,t){return s<e?s=t-(e-s)%(t-e):s=e+(s-e)%(t-e)}function Ge(s,e,t){s.forEach(i=>{t&&i.name!==t||i.goToFrame(e)})}const He={albedoTexture:"albedoMap",bumpTexture:"normalMap",ambientTexture:"ambientMap",emissiveTexture:"emissionMap",opacityTexture:"alphaMap",metallicTexture:"metallicMap",refractionTexture:"refractionMap",reflectionTexture:"reflectionMap"};function Ke(s,e,t,i){["albedoTexture","bumpTexture","ambientTexture","emissiveTexture","opacityTexture","metallicTexture","refractionTexture","reflectionTexture"].forEach(n=>{Ue(n,s,e,t,i)}),Ye(s,e)}function Ue(s,e,t,i,r){const n=He[s];if(!n)throw new Error("Unexpected texture name encountered.");const o=e[n],a=o==null?void 0:o.fileLink;a?s==="reflectionTexture"?a.endsWith(".env")||a.endsWith(".dds")?i.addCubeTextureTask(s,a,void 0,!1,void 0,!0):a.endsWith(".hdr")?i.addHDRCubeTextureTask(s,a,128,!1,!0,!1):i.addTextureTask(s,a,!1,!1):i.addTextureTask(s,a,!1,!1):r&&t[s]&&(t[s]&&t[s].dispose(),t[s]=null,We(s,t))}function We(s,e){s==="opacityTexture"&&(e.useAlphaFromAlbedoTexture=!0),s==="metallicTexture"&&(e.useRoughnessFromMetallicTextureAlpha=!1,e.useRoughnessFromMetallicTextureGreen=!1,e.useMetallnessFromMetallicTextureBlue=!1),s==="refractionTexture"&&(e.subSurface.isRefractionEnabled=!1,e.subSurface.refractionIntensity=1),s==="reflectionTexture"&&(e.environmentIntensity=1),s==="emissiveTexture"&&(e.emissiveIntensity=0,e.emissiveColor=new b.Color3(0,0,0),e.reflectionTexture)}function Qe(s,e,t,i){if(!e){console.error("Failed to apply texture to material: material is null.");return}s==="opacityTexture"&&(e.useAlphaFromAlbedoTexture=!1),s==="metallicTexture"&&(e.useRoughnessFromMetallicTextureAlpha=!1,e.useRoughnessFromMetallicTextureGreen=!0,e.useMetallnessFromMetallicTextureBlue=!0),s==="refractionTexture"&&(e.subSurface.isRefractionEnabled=!0,e.subSurface.refractionIntensity=t.refractionIntensity||1),s==="reflectionTexture"&&(e.environmentIntensity=t.reflectionIntensity||1,i.isCube&&(i.rotationY=t.reflectionRotation?t.reflectionRotation*Math.PI/180:0)),e[s]=i,s==="emissiveTexture"&&(e.emissiveColor=new b.Color3(1,1,1),e.emissiveIntensity=1)}function Ye(s,e){s.clearCoat&&(s.clearCoat===R.RemoveWhenSelected?(e.clearCoat.isEnabled=!1,e.clearCoat.indexOfRefraction=1.5):s.clearCoat===R.ApplyWhenSelected&&(e.clearCoat.isEnabled=!0,e.clearCoat.indexOfRefraction=s.clearCoatIOR||e.clearCoat.indexOfRefraction))}class Ze{constructor(e,t,i){this.materialVariantMap=new Map,this.keysThatRemovedBaseModel=[],this.loadedContainerForKey=new Map,this.loadedMaterialsForKey=new Map,this.scene=e,this.renameClonedAsset=t,this.setBaseModelEnabled=i}async applyMaterial(e,t,i,r){return new Promise(n=>{const o=this.materialVariantMap.get(e);this.materialVariantMap.set(e,{...o,...t});const a=this.renameClonedAsset(e),l=this.scene.materials.filter(h=>h.name===a);if(l.length===0){n();return}const d=new Se.AssetsManager(this.scene);d.useDefaultLoadingScreen=!1,l.forEach(h=>Ke(t,h,d,r)),d.onProgress=(h,g,m)=>{i&&i(h/g*100,100,m.name)},d.onFinish=h=>{h.forEach(g=>{const m=g;i&&i(100,100,g.name),this.scene.materials.filter(v=>v.name===a).forEach(v=>Qe(g.name,v,t,m.texture))}),n()},d.loadAsync()})}async applyModel(e,t,i,r,n,o,a){var g;if(i&&t&&!this.keysThatRemovedBaseModel.includes(e)&&this.keysThatRemovedBaseModel.push(e),!i)return this.keysThatRemovedBaseModel.includes(e)&&this.keysThatRemovedBaseModel.length===1&&await this.setBaseModelEnabled(!0),(g=this.loadedContainerForKey.get(e))==null||g.dispose(),this.loadedContainerForKey.delete(e),this.loadedMaterialsForKey.delete(e),this.keysThatRemovedBaseModel=this.keysThatRemovedBaseModel.filter(m=>m!==e),Promise.resolve(void 0);const d=(await S(i,this.scene,r)).instantiateModelsToScene(this.renameClonedAsset,!0);if(this.loadedContainerForKey.has(e)&&(this.loadedContainerForKey.get(e).dispose(),this.loadedContainerForKey.delete(e),this.loadedMaterialsForKey.delete(e)),n){const m=o&&o(),f=n.name?this.renameClonedAsset(n.name):void 0;if(Z(d.animationGroups,n.loop,n.to,n.from,f),m!=null){const v=a&&a()||!0;Ge(d.animationGroups,m+(v?2:0),f)}}t&&await this.setBaseModelEnabled(!1),this.loadedContainerForKey.set(e,d),this.loadedMaterialsForKey.set(e,X(d));const h=[];return this.materialVariantMap.forEach(async(m,f)=>{h.push(this.applyMaterial(f,m))}),await Promise.all(h),d}dispose(){this.loadedContainerForKey.forEach(e=>e==null?void 0:e.dispose()),this.loadedContainerForKey.clear(),this.loadedMaterialsForKey.forEach(e=>e.forEach(t=>t==null?void 0:t.dispose())),this.loadedMaterialsForKey.clear(),this.materialVariantMap.clear(),this.keysThatRemovedBaseModel=[]}getAllMaterials(){const e=[];return this.loadedMaterialsForKey.forEach(t=>{t.forEach(i=>{e.includes(i)||e.push(i)})}),e}getAnimationGroups(){const e=[];return this.loadedContainerForKey.forEach(t=>{e.push(...t.animationGroups)}),e}}function X(s){const e=[];return s.rootNodes.forEach(t=>{t.getChildMeshes().forEach(i=>{i.material&&!e.includes(i.material)&&e.push(i.material),i.subMeshes&&i.subMeshes.forEach(r=>{const n=r.getMaterial(!1);n&&!e.includes(n)&&e.push(n)})})}),e}function J(s,e=""){return s.map(t=>({name:t.name.substring(e.length),loop:t.loopAnimation,to:t.to,from:t.from}))}class $e{constructor(e){this.metadata=new Map,this.materialSelectedObservable=new M.Observable,this.materialDeselectedObservable=new M.Observable,this.materialVariantObservable=new M.Observable,this.modelVariantObservable=new M.Observable,this.materialReadyToLoadCallbacks=new Map,this.modelReadyToLoadCallbacks=new Map,this.dynamicTextures=new Map,this.queuedMaterialChanges=new Map,this.materialChangesInProgress=[],this.queuedModelChanges=new Map,this.modelChangesInProgress=[],this.isExecutingAnimation=!1,this.animations=[],this.initialized=!1,this.materials=[];const{enablePicking:t,modelDetails:i,previewService:r,progressHandler:n,scene:o}=e;this.enablePicking=t,this.contextService=i.contextService,this.id=ke(),this.previewService=r,this.scene=o,this.variantManager=new Ze(o,this.renameClonedAsset.bind(this),this.setBaseModelEnabled.bind(this)),this.transformRoot=new Oe.TransformNode("root",this.scene);const a=async()=>{if(!i.model)throw new Error("Model container constructed with no URL. This is currently unsupported.");return this.assetContainer=await S(i.model,o,n),await this.instantiate(),this};this.importPromise=a()}async applyMaterialVariant(e,t,i,r){if(!this.initialized){if(this.materialReadyToLoadCallbacks.has(e)){const o=this.materialReadyToLoadCallbacks.get(e);o==null||o.set(t,this.applyMaterialVariant.bind(this,e,t,i,r))}else{this.materialReadyToLoadCallbacks.set(e,new Map);const o=this.materialReadyToLoadCallbacks.get(e);o==null||o.set(t,this.applyMaterialVariant.bind(this,e,t,i,r))}return}const n=async()=>{await this.variantManager.applyMaterial(e,i,(o,a,l)=>{this.materialVariantObservable.notifyObservers({remainingCount:o,totalCount:a,taskName:l})},r)};if(this.materialChangesInProgress.includes(e)){if(this.queuedMaterialChanges.has(e)){const o=this.queuedMaterialChanges.get(e);o==null||o.set(t,n)}else{this.queuedMaterialChanges.set(e,new Map);const o=this.queuedMaterialChanges.get(e);o==null||o.set(t,n)}return}if(this.materialChangesInProgress.push(e),await n(),this.queuedMaterialChanges.has(e)){const o=this.queuedMaterialChanges.get(e);if(!o)throw new Error("Target material is undefined");o.forEach(async a=>{await a()}),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 r=()=>this.variantManager.applyModel(e,i,t==null?void 0:t.model,a=>{this.modelVariantObservable.notifyObservers({...a,key:e})},this.lastPlayedAnimation,this.getCurrentAnimationFrame.bind(this),this.getAnimationIsPlaying.bind(this));if(this.modelChangesInProgress.includes(e)){this.queuedModelChanges.set(e,r);return}const o=await(async()=>{this.modelChangesInProgress.push(e);let a=await r();if(this.queuedModelChanges.has(e)){const l=this.queuedModelChanges.get(e);if(!l)throw new Error("Queued change resolved undefined");a=await l(),this.queuedModelChanges.delete(e)}return this.modelChangesInProgress.splice(this.modelChangesInProgress.indexOf(e),1),a})();this.contextService||(this.contextService=t==null?void 0:t.contextService),o?this.configureModelInstance(o):this.configureGlowLayer()}dispose(){var e;this.destroyInstance(),this.variantManager.dispose(),this.dynamicTextures.forEach(t=>t==null?void 0:t.dispose()),this.dynamicTextures.clear(),this.materials.forEach(t=>t&&(t==null?void 0:t.dispose())),this.materials=[],(e=this.transformRoot)==null||e.dispose(),this.transformRoot=void 0,this.previewService.modelUnloaded(this)}executeAnimation(e){if(!this.initialized)return this.queuedModelAnimation=e,Promise.resolve();let t=()=>{};const i=async()=>{this.lastPlayedAnimation=e,this.isExecutingAnimation=!0,await new Promise(r=>{var o;const n=[...((o=this.modelInstance)==null?void 0:o.animationGroups)||[],...this.variantManager.getAnimationGroups()];Z(n,e.loop,e.to,e.from,e.name?this.renameClonedAsset(e.name):void 0,r)}),this.isExecutingAnimation=!1,this.queuedAnimationFunction&&this.queuedAnimationFunction(),this.queuedAnimationFunction=void 0,t()};return this.isExecutingAnimation?(this.queuedAnimationFunction=i,new Promise(r=>{t=r})):i()}getAnimations(e){return[...this.animations,...e?J(this.variantManager.getAnimationGroups(),this.renameClonedAsset("")):[]]}getId(){return this.id}listMaterials(){var t;const e=(t=this.scene)==null?void 0:t.materials.filter(i=>i.name.startsWith(this.id));return e?e.map(i=>({id:i.id,name:this.stripIdFromName(i.name)})):[]}registerMaterialSelectedCallback(e){this.materialSelectedObservable.add(e)}unregisterMaterialSelectedCallback(e){this.materialSelectedObservable.removeCallback(e)}registerMaterialDeselectedCallback(e){this.materialDeselectedObservable.add(e)}unregisterMaterialDeselectedCallback(e){this.materialDeselectedObservable.removeCallback(e)}get position(){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to requesting position!");return this.transformRoot.position}set position(e){if(!this.transformRoot)throw new Error("ModelContainer disposed prior to setting position!");this.transformRoot.position=new p.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=p.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 p.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 F.ActionManager(this.scene)),i.actionManager.registerAction(new z.ExecuteCodeAction(F.ActionManager.OnPointerOverTrigger,r=>{r.meshUnderPointer&&i.material&&this.materialSelectedObservable.notifyObservers({id:i.material.id,name:this.stripIdFromName(i.material.name)})})),i.actionManager.registerAction(new z.ExecuteCodeAction(F.ActionManager.OnPointerOutTrigger,()=>{i.material&&this.materialDeselectedObservable.notifyObservers({id:i.material.id,name:this.stripIdFromName(i.material.name)})})))})})}getInitializationPromise(){return this.importPromise}getIsInitialized(){return this.initialized}getQueuedMaterialVariantCount(){return this.materialReadyToLoadCallbacks.size}getQueuedModelVariantCount(){return this.modelReadyToLoadCallbacks.size}configureGlowLayer(){const e=i=>i instanceof O.PBRMaterial&&i.emissiveTexture!==null;this.materials.some(e)||this.variantManager.getAllMaterials().some(e)?this.previewService.getGlowLayerManager().includeMeshes(this.getAllMeshes()):this.previewService.getGlowLayerManager().removeMeshes(this.getAllMeshes())}configureModelInstance(e){var n;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,r=this.transformRoot.scaling;this.transformRoot.position=p.Vector3.Zero(),this.transformRoot.rotationQuaternion=p.Quaternion.Identity(),this.transformRoot.scaling=p.Vector3.One();for(const o of e.rootNodes){o.parent=this.transformRoot;for(const a of o.getChildMeshes(!1))a.alwaysSelectAsActiveMesh=!0}this.transformRoot.position=t,this.transformRoot.rotationQuaternion=i,this.transformRoot.scaling=r,this.canvasPanels=((n=this.contextService)==null?void 0:n.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 Le.Mesh)).flat()}async instantiate(){if(!this.assetContainer)throw new Error("Attempted to instantiate ModelContainer without an AssetContainer");this.modelInstance=this.assetContainer.instantiateModelsToScene(this.renameClonedAsset.bind(this),!0),this.materials=X(this.modelInstance),this.configureModelInstance(this.modelInstance),this.animations=J(this.modelInstance.animationGroups,this.renameClonedAsset("")),this.initialized=!0,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 r=this.dynamicTextures.get(i);r&&t.getStaticContextDirty()&&r.isReady()&&(r.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)}getCurrentAnimationFrame(){var t;const e=[...((t=this.modelInstance)==null?void 0:t.animationGroups)||[],...this.variantManager.getAnimationGroups()];for(const i of e)if(i.animatables.length>0&&i.animatables[0].masterFrame!==void 0&&i.animatables[0].masterFrame!==null)return i.animatables[0].masterFrame;return 0}getAnimationIsPlaying(){var t;const e=[...((t=this.modelInstance)==null?void 0:t.animationGroups)||[],...this.variantManager.getAnimationGroups()];for(const i of e)if(i.isPlaying)return!0;return!1}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.scene.onAfterRenderObservable.addOnce(()=>{this.queuedModelAnimation&&(this.executeAnimation(this.queuedModelAnimation),this.queuedModelAnimation=void 0)})}}class B extends y.ArcRotateCamera{constructor(e,t,i,r,n,o,a,l){super(e,t,i,r,n,o,l),this.lastFocus=new p.Vector3(0,0,0),this._isRunningFramingBehavior=!1,this.panDenominator=1,this.panEnabled=!0,this.minZ=.01,this.updateRadiusBounds(this.radius),this.enableFramingBehavior(),this.wheelDeltaPercentage=.01,this.pinchDeltaPercentage=.005,this.useNaturalPinchZoom=!0,a.camera.autoOrientation&&(this.alpha+=Math.PI),a&&(a.camera.limits.min.beta&&(this.lowerBetaLimit=a.camera.limits.min.beta),a.camera.limits.max.beta&&(this.upperBetaLimit=a.camera.limits.max.beta),a.camera.limits.min.alpha&&(this.lowerAlphaLimit=a.camera.limits.min.alpha),a.camera.limits.max.alpha&&(this.upperAlphaLimit=a.camera.limits.max.alpha),a.camera.limits.min.radius&&(this.lowerRadiusLimit=a.camera.limits.min.radius),a.camera.limits.max.radius&&(this.upperRadiusLimit=a.camera.limits.max.radius),a.camera.autoRotation.enabled&&this.enableAutoRotationBehavior(a.camera.autoRotation.idleTimeMs))}updateConfiguration(e){e&&(this.lowerBetaLimit=e.camera.limits.min.beta??null,this.upperBetaLimit=e.camera.limits.max.beta??null,this.lowerAlphaLimit=e.camera.limits.min.alpha??null,this.upperAlphaLimit=e.camera.limits.max.alpha??null,e.camera.autoRotation.enabled?this.enableAutoRotationBehavior(e.camera.autoRotation.idleTimeMs):this.disableAutoRotationBehavior())}get isRunningFramingBehavior(){return this._isRunningFramingBehavior}set isRunningFramingBehavior(e){this._isRunningFramingBehavior=e,!e&&this.framingBehaviourCallback&&(this.framingBehaviourCallback(),this.framingBehaviourCallback=void 0)}setPanEnabled(e){this.panEnabled=e,this.panningSensibility=1e3/this.panDenominator,this.panningAxis=e?new p.Vector3(1,1,0):new p.Vector3(0,0,0)}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=j(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){this._isRunningFramingBehavior=!0,this.framingBehaviourCallback=e;const i=this.getFramingBehavior();i.framingTime=t||800;const r=()=>{this.isRunningFramingBehavior=!1},n=j(this._scene),o=n.max.subtract(n.min),a=n.min.add(o.scale(.5));this.updateRadiusBounds(o.length()*1.5),this.wheelPrecision=100/this.radius,this.panningInertia=0,this.panningOriginTarget.copyFrom(a),this.panDenominator=o.length(),this.lastFocus.copyFrom(a),i.zoomOnBoundingInfo(n.min,n.max,void 0,r),i.framingTime=0}enableAutoRotationBehavior(e=5e3){this.useAutoRotationBehavior=!0;const t=this.getAutoRotationBehavior();t&&(t.idleRotationWaitTime=e)}disableAutoRotationBehavior(){this.useAutoRotationBehavior=!1}updateRadiusBounds(e){this.maxZ=e*1e3,this.lowerRadiusLimit=e*.01,this.upperRadiusLimit=1.5*e,this.wheelPrecision=100/e,this.pinchPrecision=300/e}static create(e,t,i){var l;const r=j(e),n=r.max.subtract(r.min),o=r.min.add(n.scale(.5)),a=new B("ProductCamera",-(Math.PI/2),Math.PI/2,n.length()*1.5,o,e,t);return a.setPanEnabled(((l=t.options)==null?void 0:l.noPan)!==void 0?!t.options.noPan:!0),a.panningInertia=0,a.panningOriginTarget.copyFrom(o),a.panDenominator=n.length(),a.onAfterCheckInputsObservable.addOnce(()=>{a.setPanEnabled(a.panEnabled)}),i&&(e.activeCamera=a),a}}function j(s){if(s.meshes.length===0)return{min:new p.Vector3(-1,-1,-1),max:new p.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 Be.DefaultRenderingPipeline("default",t,e,i?[i]:void 0,!1),this.renderingPipeline.isSupported&&(this.renderingPipeline.prepare(),this.setConfiguration(u))}dispose(){this.renderingPipeline.dispose()}getConfiguration(){return this.currentConfiguration}setConfiguration(e){var t,i,r,n,o,a,l,d,h,g,m,f,v,_,ee,te,ie,ne,se,re,ae,oe,le,he,ce,de,ue,ge,me,pe,fe,be,ve;if(this.renderingPipeline.isSupported){if(this.renderingPipeline.samples=((t=e.antiAliasing)==null?void 0:t.samples)??u.antiAliasing.samples,this.renderingPipeline.fxaaEnabled=((i=e.antiAliasing)==null?void 0:i.fxaaEnabled)??u.antiAliasing.fxaaEnabled,this.renderingPipeline.bloomEnabled=((r=e.bloom)==null?void 0:r.enabled)??u.bloom.enabled,this.renderingPipeline.bloomKernel=((n=e.bloom)==null?void 0:n.kernel)??u.bloom.kernel,this.renderingPipeline.bloomScale=((o=e.bloom)==null?void 0:o.scale)??u.bloom.scale,this.renderingPipeline.bloomThreshold=((a=e.bloom)==null?void 0:a.threshold)??u.bloom.threshold,this.renderingPipeline.bloomWeight=((l=e.bloom)==null?void 0:l.weight)??u.bloom.weight,this.renderingPipeline.chromaticAberrationEnabled=((d=e.chromaticAberration)==null?void 0:d.enabled)??u.chromaticAberration.enabled,this.renderingPipeline.chromaticAberration.aberrationAmount=((h=e.chromaticAberration)==null?void 0:h.aberrationAmount)??u.chromaticAberration.aberrationAmount,this.renderingPipeline.chromaticAberration.radialIntensity=((g=e.chromaticAberration)==null?void 0:g.radialIntensity)??u.chromaticAberration.radialIntensity,this.renderingPipeline.chromaticAberration.direction=(m=e.chromaticAberration)!=null&&m.direction?new p.Vector2(e.chromaticAberration.direction.x,e.chromaticAberration.direction.y):new p.Vector2(u.chromaticAberration.direction.x,u.chromaticAberration.direction.y),this.renderingPipeline.imageProcessing.colorCurvesEnabled=((f=e.colorCurves)==null?void 0:f.enabled)??u.colorCurves.enabled,this.renderingPipeline.imageProcessing.colorCurves=e.colorCurves?this.updateColorCurve(e.colorCurves):new G.ColorCurves,this.renderingPipeline.depthOfFieldEnabled=((v=e.depthOfField)==null?void 0:v.enabled)??u.depthOfField.enabled,e.depthOfField)switch(e.depthOfField.blurLevel??u.depthOfField.blurLevel){case"Low":this.renderingPipeline.depthOfFieldBlurLevel=I.DepthOfFieldEffectBlurLevel.Low;break;case"Medium":this.renderingPipeline.depthOfFieldBlurLevel=I.DepthOfFieldEffectBlurLevel.Medium;break;case"High":this.renderingPipeline.depthOfFieldBlurLevel=I.DepthOfFieldEffectBlurLevel.High;break}if(this.renderingPipeline.depthOfField.focalLength=((_=e.depthOfField)==null?void 0:_.focalLength)??u.depthOfField.focalLength,this.renderingPipeline.depthOfField.fStop=((ee=e.depthOfField)==null?void 0:ee.fStop)??u.depthOfField.fStop,this.renderingPipeline.depthOfField.focusDistance=((te=e.depthOfField)==null?void 0:te.focusDistance)??u.depthOfField.focusDistance,this.renderingPipeline.depthOfField.lensSize=((ie=e.depthOfField)==null?void 0:ie.lensSize)??u.depthOfField.lensSize,this.renderingPipeline.grainEnabled=((ne=e.grain)==null?void 0:ne.enabled)??u.grain.enabled,this.renderingPipeline.grain.animated=((se=e.grain)==null?void 0:se.animated)??u.grain.animated,this.renderingPipeline.grain.intensity=((re=e.grain)==null?void 0:re.intensity)??u.grain.intensity,this.renderingPipeline.imageProcessing.contrast=((ae=e.misc)==null?void 0:ae.contrast)??u.misc.contrast,this.renderingPipeline.imageProcessing.exposure=((oe=e.misc)==null?void 0:oe.exposure)??u.misc.exposure,this.renderingPipeline.imageProcessing.toneMappingEnabled=((le=e.misc)==null?void 0:le.toneMappingEnabled)??u.misc.toneMappingEnabled,this.renderingPipeline.imageProcessing.toneMappingEnabled)switch(e.misc.toneMappingType??u.misc.toneMappingType){case"Standard":this.renderingPipeline.imageProcessing.toneMappingType=P.ImageProcessingConfiguration.TONEMAPPING_STANDARD;break;case"ACES":this.renderingPipeline.imageProcessing.toneMappingType=P.ImageProcessingConfiguration.TONEMAPPING_ACES;break}if(this.renderingPipeline.sharpenEnabled=((he=e.sharpen)==null?void 0:he.enabled)??u.sharpen.enabled,this.renderingPipeline.sharpen.colorAmount=((ce=e.sharpen)==null?void 0:ce.colorAmount)??u.sharpen.colorAmount,this.renderingPipeline.sharpen.edgeAmount=((de=e.sharpen)==null?void 0:de.edgeAmount)??u.sharpen.edgeAmount,this.renderingPipeline.imageProcessing.vignetteEnabled=((ue=e.vignette)==null?void 0:ue.enabled)??u.vignette.enabled,(ge=e.vignette)!=null&&ge.center?(this.renderingPipeline.imageProcessing.vignetteCenterX=e.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=e.vignette.center.y):(this.renderingPipeline.imageProcessing.vignetteCenterX=u.vignette.center.x,this.renderingPipeline.imageProcessing.vignetteCenterY=u.vignette.center.y),e.vignette)switch(((me=e.vignette)==null?void 0:me.blendMode)??u.vignette.blendMode){case"Multiply":this.renderingPipeline.imageProcessing.vignetteBlendMode=P.ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY;break;case"Opaque":this.renderingPipeline.imageProcessing.vignetteBlendMode=P.ImageProcessingConfiguration.VIGNETTEMODE_OPAQUE;break}(pe=e.vignette)!=null&&pe.colorRgba?this.renderingPipeline.imageProcessing.vignetteColor=new b.Color4(e.vignette.colorRgba.r,e.vignette.colorRgba.g,e.vignette.colorRgba.b,e.vignette.colorRgba.a):(fe=e.vignette)!=null&&fe.colorHex?this.renderingPipeline.imageProcessing.vignetteColor=b.Color4.FromHexString(e.vignette.colorHex):this.renderingPipeline.imageProcessing.vignetteColor=new b.Color4(u.vignette.colorRgba.r,u.vignette.colorRgba.g,u.vignette.colorRgba.b,u.vignette.colorRgba.a),this.renderingPipeline.imageProcessing.vignetteStretch=((be=e.vignette)==null?void 0:be.stretch)??u.vignette.stretch,this.renderingPipeline.imageProcessing.vignetteWeight=((ve=e.vignette)==null?void 0:ve.weight)??u.vignette.weight,this.renderingPipeline.prepare(),this.currentConfiguration=e}}updateColorCurve(e){const t=new G.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}}Ae.GLTF2.GLTFLoader.RegisterExtension("glbPostProcessor",function(s){return new je(s)}),L.SceneLoader.OnPluginActivatedObservable.add(s=>{if(s.name==="gltf"){const e=s;e.transparencyAsCoverage=!0}});function q(s){return new p.Vector3(s.x,s.y,s.z)}function D(s){return{x:s.x,y:s.y,z:s.z}}class Je{constructor(e){var l;this.focusLostNotified=!1,this.focusLostObservable=new M.Observable,this.modelLoadEventCallbacks=[],this.modelContainers=new Map,this.plugins=[],this.initComplete=!1,this.isAnimatingCamera=!1,this.renderLoop=()=>{if(!this.engine.views)return;this.modelContainers.forEach(h=>{h.updateDynamicTextures()}),this.scene.autoClear=!0,this.scene.autoClearDepthAndStencil=!0,this.scene.render(),this.camera.isRunningFramingBehavior&&this.camera.getFramingBehavior().isUserIsMoving&&(this.camera.isRunningFramingBehavior=!1);const d=Math.max((this.camera.lowerRadiusLimit??1)*.01,.001);!this.camera.isRunningFramingBehavior&&!this.camera.target.equalsWithEpsilon(this.camera.lastFocus,d)&&!this.focusLostNotified&&(this.focusLostObservable.notifyObservers(void 0),this.focusLostNotified=!0),this.screenshotPrepareResolve&&(this.screenshotPrepareResolve(),this.screenshotPrepareResolve=void 0)},this.configuration=new K(e);const i=(()=>{if(!(e!=null&&e.noRender))return this.configuration.createCanvas()})(),r="1.5.6";we.DracoCompression.Configuration={decoder:{wasmUrl:`https://www.gstatic.com/draco/versioned/decoders/${r}/draco_wasm_wrapper_gltf.js`,wasmBinaryUrl:`https://www.gstatic.com/draco/versioned/decoders/${r}/draco_decoder_gltf.wasm`,fallbackUrl:`https://www.gstatic.com/draco/versioned/decoders/${r}/draco_decoder_gltf.js`}},i&&(i.getContext("webgl2")||i.getContext("webgl"));const n=console.log;console.log=()=>{};const o=i?new V.Engine(i,!0,{adaptToDeviceRatio:!0,limitDeviceRatio:2,premultipliedAlpha:!1,preserveDrawingBuffer:!!(e!=null&&e.backgroundImage),audioEngine:!1,stencil:this.configuration.highlights.enabled,forceSRGBBufferSupportState:!0}):new ye.NullEngine;console.log=n,o.hideLoadingUI(),window.addEventListener("resize",this.fireResizeEvent.bind(this)),this.engine=o,this.scene=new xe.Scene(o),this.camera=B.create(this.scene,this.configuration),this.scene.activeCamera=this.camera,this.renderingPipeline=new Xe(this.scene,!1,this.camera),this.scene.clearColor=this.configuration.scene.clearColor;const a=k.CubeTexture.CreateFromPrefilteredData(this.configuration.scene.environment.file,this.scene);a.rotationY=this.configuration.scene.environment.rotationY,this.scene.environmentTexture=a,this.scene.environmentIntensity=this.configuration.scene.environment.intensity,(l=this.configuration.options)!=null&&l.renderingPipelineConfiguration?this.renderingPipeline.setConfiguration(this.configuration.options.renderingPipelineConfiguration):(this.scene.imageProcessingConfiguration.exposure=this.configuration.lighting.exposure,this.scene.imageProcessingConfiguration.contrast=this.configuration.lighting.contrast),this.glowLayerManager=new qe(this.scene,this.configuration.emissiveGlowIntensity),this.scene.autoClear=!0,this.scene.autoClearDepthAndStencil=!0,this.initPromise=new Promise(d=>{this.scene.onReadyObservable.addOnce(()=>{this.initComplete=!0,d()})}),this.engine.runRenderLoop(this.renderLoop)}getInitializationPromise(){return this.initPromise}getInitializationComplete(){return this.initComplete}getEngineContext(){return{engine:this.engine,scene:this.scene,camera:this.camera}}registerFocusLostListener(e){this.focusLostObservable.add(e)}unregisterFocusLostListener(e){this.focusLostObservable.removeCallback(e)}registerModelLoadEventListener(e){this.modelLoadEventCallbacks.push(e)}unregisterModelLoadEventListener(e){const t=this.modelLoadEventCallbacks.indexOf(e);t>-1&&this.modelLoadEventCallbacks.splice(t,1)}registerView(e){const t=e.height,i=e.width;this.engine.registerView(e,void 0,!0),e.setAttribute("height",t.toString()),e.setAttribute("width",i.toString()),this.orbitEnabled()||this.setCameraState(T.Pan),this.reattachControls(e)}getNumViewports(){var e;return((e=this.engine.views)==null?void 0:e.length)||0}unregisterView(e){this.engine.unRegisterView(e)}shutdown(){this.plugins.forEach(e=>e.dispose(!0)),this.renderingPipeline.dispose(),this.engine&&this.engine.dispose(),window.removeEventListener("resize",this.fireResizeEvent)}executeCameraAnimation(e){if(!this.camera||this.scene.activeCamera!==this.camera||this.getAllModels().length===0||!this.getAllModels().some(r=>r.getIsInitialized()))return this.queuedCameraAnimation=e,Promise.resolve();let t=()=>{};const i=async()=>{this.isAnimatingCamera=!0,await ze(this.scene,this.scene.activeCamera,e),this.isAnimatingCamera=!1,this.queuedAnimationFunction&&this.queuedAnimationFunction(),this.queuedAnimationFunction=void 0,t()};return this.isAnimatingCamera?(this.queuedAnimationFunction=i,new Promise(r=>{t=r})):i()}getCameraPose(){if(this.scene&&this.camera)return{lonDeg:Math.round(this.camera.alpha*180/Math.PI),latDeg:Math.round(this.camera.beta*180/Math.PI),radius:Math.round((this.camera.radius+Number.EPSILON)*1e4)/1e4,target:{x:this.camera.target.x,y:this.camera.target.y,z:this.camera.target.z}}}setCameraPose(e){this.scene&&this.camera&&(this.camera.target=new p.Vector3(e.target.x,e.target.y,e.target.z),this.camera.radius=e.radius,this.camera.alpha=e.latDeg,this.camera.beta=e.lonDeg)}setCameraState(e){var t,i;if(!((t=this.engine)!=null&&t.views)||!((i=this.engine)!=null&&i.views[0]))throw new Error("No views attached, camera state requires a view to attach controls onto.");e===T.Orbit?this.reattachControls(this.engine.views[0].target,2):this.reattachControls(this.engine.views[0].target,0)}animateToLastCameraFocus(){let e=()=>{};const t=async()=>{this.isAnimatingCamera=!0,await new Promise(i=>{this.focusLostNotified=!1;const r=()=>{const n=this.configuration;this.camera.rerunFramingBehavior(()=>{n.camera.limits.min.radius&&(this.camera.lowerRadiusLimit=n.camera.limits.min.radius),n.camera.limits.max.radius&&(this.camera.upperRadiusLimit=n.camera.limits.max.radius),i()})};this.scene.onAfterRenderObservable.addOnce(r)}),this.isAnimatingCamera=!1,this.queuedAnimationFunction&&this.queuedAnimationFunction(),this.queuedAnimationFunction=void 0,e()};return this.isAnimatingCamera?(this.queuedAnimationFunction=t,new Promise(i=>{e=i})):t()}forceStopCameraAnimations(){var e;this.queuedAnimationFunction=void 0,this.queuedCameraAnimation=void 0,this.isAnimatingCamera=!1,(e=this.camera.framingBehavior)==null||e.stopAllAnimations(),this.scene.stopAnimation(this.camera)}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,p.Vector3.Zero(),this.scene);try{const r=t.latDeg*Math.PI/180,n=t.lonDeg*Math.PI/180;i.target=t.target?new p.Vector3(t.target.x,t.target.y,t.target.z):p.Vector3.Zero(),i.alpha=n,i.beta=r,i.radius=t.radius||this.camera.radius,i.minZ=.01,this.scene.render();const o=await Me.Tools.CreateScreenshotUsingRenderTargetAsync(this.engine,i,e,"image/png",2,!0);return i.dispose(),o}catch{throw i.isDisposed()||i.dispose(),new Error("Failed to render screenshot")}}orbitEnabled(){const e=this.configuration;if(!e)return!0;const t=e.camera.limits.min.alpha,i=e.camera.limits.max.alpha,r=e.camera.limits.min.beta,n=e.camera.limits.max.beta;if(t===void 0||i===void 0||r===void 0||n===void 0)return!0;const o=[t,i],a=[r,n],l=o.every(h=>h===t),d=a.every(h=>h===r);return!l&&!d}fireResizeEvent(){this.getNumViewports()>0&&this.engine.resize()}setHighlights(e,t){var r;e.length===0&&((r=this.highlightLayer)==null||r.dispose(),this.highlightLayer=void 0),this.highlightLayer||(this.highlightLayer=new Ce.HighlightLayer("highlights",this.scene,{isStroke:!0,blurVerticalSize:.85,blurHorizontalSize:.85}),this.highlightLayer.innerGlow=!0,this.highlightLayer.outerGlow=!1),this.highlightLayer.removeAllMeshes();const i=t?new b.Color3(t[0],t[1],t[2]).toLinearSpace():void 0;e.forEach(n=>{const o=this.scene.materials.find(a=>a.name===n.name&&a.id===n.id);o&&o.getBindedMeshes().forEach(a=>{var l;return(l=this.highlightLayer)==null?void 0:l.addMesh(a,i||b.Color3.FromHexString("#fcba03"))})})}setRenderingPipelineConfiguration(e){this.renderingPipeline&&this.renderingPipeline.setConfiguration(e)}loadModel(e,t){const{refocusCamera:i=!0,progressHandler:r}=t??{},n=new $e({enablePicking:this.configuration.highlights.enabled,modelDetails:e,scene:this.scene,previewService:this,progressHandler:r});return n.getInitializationPromise().then(()=>{this.modelContainers.size<=1&&i&&(this.forceStopCameraAnimations(),this.camera.rerunFramingBehavior(()=>{this.scene.onAfterRenderObservable.addOnce(()=>{this.queuedCameraAnimation&&(this.executeCameraAnimation(this.queuedCameraAnimation),this.queuedCameraAnimation=void 0)})},1))}),this.configuration.highlights.enabled&&(n.registerMaterialSelectedCallback(o=>{this.setHighlights([o])}),n.registerMaterialDeselectedCallback(()=>{this.setHighlights([])})),this.modelContainers.set(n.getId(),n),this.triggerModelLoadEvent({eventType:"load",modelContainer:n}),n}async preloadModel(e){await S(e,this.scene)}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(r=>r.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 r=p.Matrix.Compose(q(i||{x:1,y:1,z:1}),p.Quaternion.FromEulerVector(q(t||{x:0,y:0,z:0})),q(e||{x:0,y:0,z:0})),n=p.Matrix.RotationAxis(p.Vector3.Up(),Math.PI),o=r.multiply(n),a=p.Vector3.Zero(),l=p.Quaternion.Identity(),d=p.Vector3.Zero();return o.decompose(d,l,a),l.multiplyInPlace(p.Quaternion.FromEulerAngles(0,Math.PI,0)),{position:D(a),rotation:D(l.toEulerAngles()),scale:D(d)}}updatePreviewOptions(e){var r,n;const t=new K(e);this.configuration.highlights.enabled!==t.highlights.enabled&&this.engine.setStencilBuffer(t.highlights.enabled),this.scene.clearColor=t.scene.clearColor;let i=this.scene.environmentTexture;this.configuration.scene.environment.file!==t.scene.environment.file&&(i=k.CubeTexture.CreateFromPrefilteredData(t.scene.environment.file,this.scene),i.rotationY=this.configuration.scene.environment.rotationY,this.scene.environmentTexture=i),i.rotationY=t.scene.environment.rotationY,this.scene.environmentIntensity=t.scene.environment.intensity,(r=t.options)!=null&&r.renderingPipelineConfiguration?this.renderingPipeline.setConfiguration(t.options.renderingPipelineConfiguration):(this.scene.imageProcessingConfiguration.exposure=t.lighting.exposure,this.scene.imageProcessingConfiguration.contrast=t.lighting.contrast),this.glowLayerManager.setIntensity(t.emissiveGlowIntensity),this.camera.updateConfiguration(t),this.camera.setPanEnabled(((n=t.options)==null?void 0:n.noPan)!==void 0?!t.options.noPan:!0),this.scene.autoClear=!0,this.scene.autoClearDepthAndStencil=!0,this.configuration=t}reattachControls(e,t=2){if(this.scene.detachControl(),this.engine.inputElement=e,this.camera){this.camera.attachControl(!0,!1,t);const i=this.camera.inputs.attached.pointers;i.multiTouchPanning=!1}this.scene.attachControl(!0,!0,!0)}}c.MaterialEffectMode=R,c.ProductCameraRig=T,c.REFLECTION_PROBE_RESOLUTION=U,c.RenderingConfiguration=w,c.SpiffCommerce3DPreviewService=Je,c.renderingPipelineDefaults=u,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED