@spiffcommerce/preview 5.11.12 → 5.11.15
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.ts +1336 -0
- package/dist/index.esm.js +294 -245
- package/dist/index.umd.js +1 -1
- package/package.json +5 -9
package/dist/index.esm.js
CHANGED
|
@@ -1,33 +1,34 @@
|
|
|
1
1
|
import { ArcRotateCamera as j } from "@babylonjs/core/Cameras/arcRotateCamera";
|
|
2
2
|
import { Engine as I } from "@babylonjs/core/Engines/engine";
|
|
3
3
|
import { NullEngine as ee } from "@babylonjs/core/Engines/nullEngine";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { HemisphericLight as te } from "@babylonjs/core/Lights/hemisphericLight";
|
|
5
|
+
import { SceneLoader as D } from "@babylonjs/core/Loading/sceneLoader";
|
|
6
|
+
import { CubeTexture as ie } from "@babylonjs/core/Materials/Textures/cubeTexture";
|
|
7
|
+
import { Color4 as v, Color3 as b } from "@babylonjs/core/Maths/math.color";
|
|
7
8
|
import { Vector3 as g, Quaternion as A, Vector2 as z, Matrix as G } from "@babylonjs/core/Maths/math.vector";
|
|
8
|
-
import { DracoCompression as
|
|
9
|
+
import { DracoCompression as ne } from "@babylonjs/core/Meshes/Compression/dracoCompression";
|
|
9
10
|
import { Observable as C } from "@babylonjs/core/Misc/observable";
|
|
10
|
-
import { Tools as
|
|
11
|
-
import { Scene as
|
|
12
|
-
import { GLTF2 as
|
|
13
|
-
import { GLTFLoaderAnimationStartMode as
|
|
14
|
-
import { PBRMaterial as
|
|
15
|
-
import { MirrorTexture as
|
|
16
|
-
import { Color3 as
|
|
17
|
-
import { ReflectionProbe as
|
|
18
|
-
import { GlowLayer as
|
|
11
|
+
import { Tools as se } from "@babylonjs/core/Misc/tools";
|
|
12
|
+
import { Scene as re } from "@babylonjs/core/scene";
|
|
13
|
+
import { GLTF2 as ae } from "@babylonjs/loaders/glTF";
|
|
14
|
+
import { GLTFLoaderAnimationStartMode as oe } from "@babylonjs/loaders/glTF/glTFFileLoader";
|
|
15
|
+
import { PBRMaterial as k } from "@babylonjs/core/Materials/PBR/pbrMaterial";
|
|
16
|
+
import { MirrorTexture as le } from "@babylonjs/core/Materials/Textures/mirrorTexture";
|
|
17
|
+
import { Color3 as he, Vector3 as _, Plane as ce } from "@babylonjs/core/Maths/math";
|
|
18
|
+
import { ReflectionProbe as de } from "@babylonjs/core/Probes/reflectionProbe";
|
|
19
|
+
import { GlowLayer as ue } from "@babylonjs/core/Layers/glowLayer";
|
|
19
20
|
import { ActionManager as E } from "@babylonjs/core/Actions/actionManager";
|
|
20
|
-
import { ExecuteCodeAction as
|
|
21
|
-
import { Mesh as
|
|
22
|
-
import { TransformNode as
|
|
23
|
-
import { DynamicTexture as
|
|
24
|
-
import { Texture as
|
|
21
|
+
import { ExecuteCodeAction as V } from "@babylonjs/core/Actions/directActions";
|
|
22
|
+
import { Mesh as me } from "@babylonjs/core/Meshes/mesh";
|
|
23
|
+
import { TransformNode as ge } from "@babylonjs/core/Meshes/transformNode";
|
|
24
|
+
import { DynamicTexture as pe } from "@babylonjs/core/Materials/Textures/dynamicTexture";
|
|
25
|
+
import { Texture as fe } from "@babylonjs/core/Materials/Textures/texture";
|
|
25
26
|
import { Animation as w } from "@babylonjs/core/Animations/animation";
|
|
26
|
-
import { QuadraticEase as
|
|
27
|
-
import { AssetsManager as
|
|
27
|
+
import { QuadraticEase as be, EasingFunction as ve } from "@babylonjs/core/Animations/easing";
|
|
28
|
+
import { AssetsManager as we } from "@babylonjs/core/Misc/assetsManager";
|
|
28
29
|
import { ColorCurves as H } from "@babylonjs/core/Materials/colorCurves";
|
|
29
30
|
import { ImageProcessingConfiguration as M } from "@babylonjs/core/Materials/imageProcessingConfiguration";
|
|
30
|
-
import { DefaultRenderingPipeline as
|
|
31
|
+
import { DefaultRenderingPipeline as Ce } from "@babylonjs/core/PostProcesses/RenderPipeline";
|
|
31
32
|
import { DepthOfFieldEffectBlurLevel as R } from "@babylonjs/core/PostProcesses/depthOfFieldEffect";
|
|
32
33
|
import "@babylonjs/core/Rendering/depthRendererSceneComponent";
|
|
33
34
|
import "@babylonjs/core/Engines/Extensions/engine.views";
|
|
@@ -40,36 +41,36 @@ import "@babylonjs/core/Animations/animatable";
|
|
|
40
41
|
import "@babylonjs/core/Misc/screenshotTools";
|
|
41
42
|
import "@babylonjs/core/Rendering/boundingBoxRenderer";
|
|
42
43
|
import "@babylonjs/loaders/glTF/2.0/Extensions";
|
|
43
|
-
var
|
|
44
|
-
function
|
|
44
|
+
var S = /* @__PURE__ */ ((n) => (n[n.Orbit = 0] = "Orbit", n[n.Pan = 1] = "Pan", n))(S || {}), B = /* @__PURE__ */ ((n) => (n.None = "None", n.RemoveWhenSelected = "RemoveWhenSelected", n.ApplyWhenSelected = "ApplyWhenSelected", n))(B || {});
|
|
45
|
+
function Ae() {
|
|
45
46
|
const n = navigator.vendor.toLowerCase().includes("apple"), e = navigator.maxTouchPoints > 0, t = !navigator.userAgent.toLowerCase().includes("crios");
|
|
46
47
|
return n && e && t;
|
|
47
48
|
}
|
|
48
49
|
const U = /* @__PURE__ */ new Map();
|
|
49
|
-
async function
|
|
50
|
+
async function N(n, e, t) {
|
|
50
51
|
const i = await U.get(n);
|
|
51
52
|
if (i && i.scene.uid === e.uid)
|
|
52
53
|
return i;
|
|
53
|
-
const a =
|
|
54
|
-
return !
|
|
54
|
+
const a = D.LoadAssetContainerAsync(n, void 0, e, t);
|
|
55
|
+
return !Ae() && U.set(n, a), a;
|
|
55
56
|
}
|
|
56
|
-
|
|
57
|
-
n.name === "gltf" && (n.animationStartMode =
|
|
57
|
+
D.OnPluginActivatedObservable.add((n) => {
|
|
58
|
+
n.name === "gltf" && (n.animationStartMode = oe.NONE);
|
|
58
59
|
});
|
|
59
60
|
class K {
|
|
60
61
|
constructor(e) {
|
|
61
62
|
this.getSceneClearColor = () => {
|
|
62
63
|
const t = this.customOptions?.transparentBackground || this.customOptions?.backgroundImage ? 0 : 1;
|
|
63
64
|
if (this.customOptions && this.customOptions?.transparentBackground || this.customOptions?.backgroundImage)
|
|
64
|
-
return new
|
|
65
|
+
return new v(0, 0, 0, t).toLinearSpace();
|
|
65
66
|
if (this.customOptions && this.customOptions.backgroundColor) {
|
|
66
|
-
const i =
|
|
67
|
-
return new
|
|
67
|
+
const i = b.FromHexString(this.customOptions.backgroundColor);
|
|
68
|
+
return new v(i.r, i.g, i.b, t).toLinearSpace();
|
|
68
69
|
}
|
|
69
|
-
return new
|
|
70
|
-
}, this.highlightColorFromConfig = () => this.customOptions && this.customOptions.highlightColor ? this.hexToColor4(this.customOptions.highlightColor) :
|
|
71
|
-
const a =
|
|
72
|
-
return new
|
|
70
|
+
return new v(0.98, 0.98, 0.98, t).toLinearSpace();
|
|
71
|
+
}, this.highlightColorFromConfig = () => this.customOptions && this.customOptions.highlightColor ? this.hexToColor4(this.customOptions.highlightColor) : v.FromColor3(b.Gray()), this.hexToColor4 = (t, i = 1) => {
|
|
72
|
+
const a = b.FromHexString(t);
|
|
73
|
+
return new v(a.r, a.g, a.b, i).toLinearSpace();
|
|
73
74
|
}, this.customOptions = e;
|
|
74
75
|
}
|
|
75
76
|
createCanvas() {
|
|
@@ -133,6 +134,19 @@ class K {
|
|
|
133
134
|
contrast: this.customOptions?.lighting?.contrast ?? 1.6
|
|
134
135
|
};
|
|
135
136
|
}
|
|
137
|
+
/**
|
|
138
|
+
* Configuration for the light used when the environment isn't lighting the scene.
|
|
139
|
+
* See PreviewOptions.fallbackLighting.
|
|
140
|
+
*/
|
|
141
|
+
get fallbackLighting() {
|
|
142
|
+
const e = this.customOptions?.fallbackLighting;
|
|
143
|
+
return {
|
|
144
|
+
enabled: e?.enabled ?? !0,
|
|
145
|
+
intensity: e?.intensity ?? 1.2,
|
|
146
|
+
color: e?.color ? b.FromHexString(e.color) : b.White(),
|
|
147
|
+
groundColor: e?.groundColor ? b.FromHexString(e.groundColor) : new b(0.3, 0.3, 0.3)
|
|
148
|
+
};
|
|
149
|
+
}
|
|
136
150
|
get emissiveGlowIntensity() {
|
|
137
151
|
return this.customOptions?.emissiveGlowIntensity ?? 0.5;
|
|
138
152
|
}
|
|
@@ -176,7 +190,7 @@ class x {
|
|
|
176
190
|
}
|
|
177
191
|
}
|
|
178
192
|
}
|
|
179
|
-
const
|
|
193
|
+
const ye = 128, d = {
|
|
180
194
|
antiAliasing: {
|
|
181
195
|
samples: 4,
|
|
182
196
|
fxaaEnabled: !1
|
|
@@ -233,7 +247,7 @@ const Ce = 128, d = {
|
|
|
233
247
|
weight: 1
|
|
234
248
|
}
|
|
235
249
|
};
|
|
236
|
-
class
|
|
250
|
+
class xe {
|
|
237
251
|
constructor(e) {
|
|
238
252
|
this.name = "glbPostProcessor", this.enabled = !0, this.loader = e;
|
|
239
253
|
}
|
|
@@ -246,9 +260,9 @@ class Ae {
|
|
|
246
260
|
*/
|
|
247
261
|
loadNodeAsync(e, t, i) {
|
|
248
262
|
return this.loader.loadNodeAsync(e, t, function(a) {
|
|
249
|
-
t.extras && Object.keys(t.extras).forEach((
|
|
250
|
-
const o = t.extras[
|
|
251
|
-
a.metadata[
|
|
263
|
+
t.extras && Object.keys(t.extras).forEach((s) => {
|
|
264
|
+
const o = t.extras[s];
|
|
265
|
+
a.metadata[s] = o;
|
|
252
266
|
}), i(a);
|
|
253
267
|
});
|
|
254
268
|
}
|
|
@@ -269,14 +283,14 @@ class Ae {
|
|
|
269
283
|
* @param babylonMaterial An instance of a material representation in babylon.
|
|
270
284
|
*/
|
|
271
285
|
enableMaterialExtrasIfRequired(e, t) {
|
|
272
|
-
if (!(!e.extras || !(t instanceof
|
|
286
|
+
if (!(!e.extras || !(t instanceof k))) {
|
|
273
287
|
if (e.extras.sheen) {
|
|
274
288
|
const i = t;
|
|
275
289
|
i.sheen.isEnabled = !0, i.sheen.intensity = e.extras.sheen;
|
|
276
290
|
}
|
|
277
291
|
if (e.extras.translucency) {
|
|
278
292
|
const i = t;
|
|
279
|
-
i.subSurface.isTranslucencyEnabled = !0, i.subSurface.translucencyIntensity = e.extras.translucency, e.extras.translucencyR && e.extras.translucencyG && e.extras.translucencyB && (i.subSurface.tintColor = new
|
|
293
|
+
i.subSurface.isTranslucencyEnabled = !0, i.subSurface.translucencyIntensity = e.extras.translucency, e.extras.translucencyR && e.extras.translucencyG && e.extras.translucencyB && (i.subSurface.tintColor = new he(
|
|
280
294
|
e.extras.translucencyR,
|
|
281
295
|
e.extras.translucencyG,
|
|
282
296
|
e.extras.translucencyB
|
|
@@ -302,48 +316,48 @@ class Ae {
|
|
|
302
316
|
* @param scene The scene to parse.
|
|
303
317
|
*/
|
|
304
318
|
applyReflections(e) {
|
|
305
|
-
function t(
|
|
319
|
+
function t(s) {
|
|
306
320
|
const o = [];
|
|
307
|
-
return
|
|
308
|
-
|
|
309
|
-
}),
|
|
310
|
-
|
|
321
|
+
return s.transformNodes.forEach((r) => {
|
|
322
|
+
r.metadata && r.metadata.reflective && o.push(...r.getChildMeshes());
|
|
323
|
+
}), s.meshes.forEach((r) => {
|
|
324
|
+
r.metadata && r.metadata.reflective && !o.includes(r) && o.push(r);
|
|
311
325
|
}), o;
|
|
312
326
|
}
|
|
313
|
-
function i(
|
|
314
|
-
const
|
|
315
|
-
if (!
|
|
327
|
+
function i(s, o = 1) {
|
|
328
|
+
const r = s.material;
|
|
329
|
+
if (!r)
|
|
316
330
|
return;
|
|
317
|
-
const h = new
|
|
331
|
+
const h = new le(
|
|
318
332
|
"mirror",
|
|
319
333
|
x.getMirrorTextureResolution(),
|
|
320
334
|
e,
|
|
321
335
|
!0
|
|
322
336
|
);
|
|
323
337
|
h.renderList = t(e);
|
|
324
|
-
const c =
|
|
338
|
+
const c = s.getVerticesData("normal");
|
|
325
339
|
if (!c)
|
|
326
340
|
throw new Error(
|
|
327
|
-
"Mirror attribute specified on: " +
|
|
341
|
+
"Mirror attribute specified on: " + s.name + "But no normals exist to generate a mirror from!"
|
|
328
342
|
);
|
|
329
|
-
|
|
330
|
-
const l =
|
|
331
|
-
new
|
|
343
|
+
s.computeWorldMatrix(!0);
|
|
344
|
+
const l = s.getWorldMatrix(), m = _.TransformNormal(
|
|
345
|
+
new _(c[0], c[1], c[2]),
|
|
332
346
|
l
|
|
333
|
-
).normalize(), u =
|
|
334
|
-
h.mirrorPlane = u, h.level = o,
|
|
347
|
+
).normalize(), u = ce.FromPositionAndNormal(s.position, m.scale(-1));
|
|
348
|
+
h.mirrorPlane = u, h.level = o, r.reflectionTexture = h;
|
|
335
349
|
}
|
|
336
|
-
function a(
|
|
337
|
-
const o =
|
|
338
|
-
|
|
350
|
+
function a(s) {
|
|
351
|
+
const o = s.material, r = new de("probe-" + o.name, ye, e);
|
|
352
|
+
r.cubeTexture.name = "reflection-probe-cube-texture", r.attachToMesh(s), r.renderList && r.renderList.push(...t(e)), o.reflectionTexture = r.cubeTexture;
|
|
339
353
|
}
|
|
340
|
-
e.meshes.forEach((
|
|
341
|
-
const o =
|
|
342
|
-
o && (o.mirrorTexture && i(
|
|
354
|
+
e.meshes.forEach((s) => {
|
|
355
|
+
const o = s.metadata;
|
|
356
|
+
o && (o.mirrorTexture && i(s, o.mirrorTexture), o.reflectionProbe && a(s));
|
|
343
357
|
});
|
|
344
358
|
}
|
|
345
359
|
}
|
|
346
|
-
class
|
|
360
|
+
class Me {
|
|
347
361
|
constructor(e, t) {
|
|
348
362
|
this.scene = e, this.intensity = t, this.meshCount = 0;
|
|
349
363
|
}
|
|
@@ -352,7 +366,7 @@ class ye {
|
|
|
352
366
|
}
|
|
353
367
|
includeMeshes(e) {
|
|
354
368
|
if (e) {
|
|
355
|
-
this.glowLayer || (this.glowLayer = new
|
|
369
|
+
this.glowLayer || (this.glowLayer = new ue("glow", this.scene), this.glowLayer.intensity = this.intensity);
|
|
356
370
|
for (const t of e)
|
|
357
371
|
this.glowLayer.hasMesh(t) || (this.glowLayer.addIncludedOnlyMesh(t), this.meshCount++);
|
|
358
372
|
}
|
|
@@ -365,37 +379,37 @@ class ye {
|
|
|
365
379
|
}
|
|
366
380
|
}
|
|
367
381
|
}
|
|
368
|
-
function
|
|
369
|
-
t.forEach((
|
|
370
|
-
const o =
|
|
382
|
+
function Pe(n, e, t, i, a = "") {
|
|
383
|
+
t.forEach((s) => {
|
|
384
|
+
const o = s.getID(), r = s.getName(), h = s.getPanelSize && s.getPanelSize(), c = x.getDynamicTextureResolution(
|
|
371
385
|
h?.width === 1 || h?.height === 1
|
|
372
386
|
);
|
|
373
|
-
n.filter((m) => m.name === a +
|
|
387
|
+
n.filter((m) => m.name === a + r).forEach((m) => {
|
|
374
388
|
const u = i.get(o), p = !1;
|
|
375
389
|
if (u)
|
|
376
390
|
W(m, u), u.update(p);
|
|
377
391
|
else {
|
|
378
|
-
const f =
|
|
379
|
-
i.set(o, f),
|
|
392
|
+
const f = Ee(r, e, c.width, c.height);
|
|
393
|
+
i.set(o, f), s.setStaticContext(f.getContext()), W(m, f), f.onLoadObservable.addOnce(() => {
|
|
380
394
|
f.update(p);
|
|
381
395
|
});
|
|
382
396
|
}
|
|
383
397
|
});
|
|
384
398
|
});
|
|
385
399
|
}
|
|
386
|
-
function
|
|
387
|
-
const a = new
|
|
400
|
+
function Ee(n, e, t, i) {
|
|
401
|
+
const a = new pe(
|
|
388
402
|
n,
|
|
389
403
|
{ width: t, height: i },
|
|
390
404
|
e,
|
|
391
405
|
x.shouldMipMap(),
|
|
392
|
-
|
|
406
|
+
fe.TRILINEAR_SAMPLINGMODE,
|
|
393
407
|
I.TEXTUREFORMAT_RGBA
|
|
394
|
-
),
|
|
395
|
-
return
|
|
408
|
+
), s = a.getContext();
|
|
409
|
+
return s && (s.fillStyle = "#f5f5f5", s.fillRect(0, 0, t, i), a.update()), a;
|
|
396
410
|
}
|
|
397
411
|
function W(n, e) {
|
|
398
|
-
if (n instanceof
|
|
412
|
+
if (n instanceof k) {
|
|
399
413
|
const t = n, i = t.albedoTexture;
|
|
400
414
|
i ? (e.wrapU = i.wrapU, e.wrapV = i.wrapV) : (e.wrapU = 1, e.wrapV = 1), t.albedoTexture = e;
|
|
401
415
|
} else {
|
|
@@ -403,7 +417,7 @@ function W(n, e) {
|
|
|
403
417
|
i && (e.wrapU = i.wrapU, e.wrapV = i.wrapV), t.diffuseTexture = e;
|
|
404
418
|
}
|
|
405
419
|
}
|
|
406
|
-
function
|
|
420
|
+
function Re() {
|
|
407
421
|
const n = () => Math.floor((1 + Math.random()) * 65536).toString(16).substring(1);
|
|
408
422
|
return n() + n() + "-" + n() + "-" + n() + "-" + n() + "-" + n() + n() + n();
|
|
409
423
|
}
|
|
@@ -411,17 +425,17 @@ const y = 60, Q = 1;
|
|
|
411
425
|
function Y(n) {
|
|
412
426
|
return n.targetedAnimations.map((t) => t.animation.framePerSecond).reduce((t, i) => t + i, 0) / n.targetedAnimations.length || 0;
|
|
413
427
|
}
|
|
414
|
-
function X(n, e, t, i, a,
|
|
428
|
+
function X(n, e, t, i, a, s) {
|
|
415
429
|
const o = a ? n.filter((l) => l.name === a) : n;
|
|
416
430
|
if (o.length === 0) {
|
|
417
431
|
console.warn(`No animations found for name: ${a}`);
|
|
418
432
|
return;
|
|
419
433
|
}
|
|
420
|
-
let
|
|
434
|
+
let r = 0;
|
|
421
435
|
const h = () => {
|
|
422
|
-
|
|
436
|
+
r++, r === o.length && s && s();
|
|
423
437
|
}, c = (l, m, u, p, f) => {
|
|
424
|
-
l.stop(), l.start(m, u, p, f),
|
|
438
|
+
l.stop(), l.start(m, u, p, f), s && (m == !1 || m === void 0 && !l.loopAnimation ? l.onAnimationGroupEndObservable.addOnce(() => {
|
|
425
439
|
h();
|
|
426
440
|
}) : l.onAnimationLoopObservable.addOnce(() => {
|
|
427
441
|
h();
|
|
@@ -439,19 +453,19 @@ function X(n, e, t, i, a, r) {
|
|
|
439
453
|
c(l, e, Q, u, p);
|
|
440
454
|
});
|
|
441
455
|
}
|
|
442
|
-
function
|
|
456
|
+
function Te(n) {
|
|
443
457
|
n.forEach((e) => {
|
|
444
458
|
e.reset(), e.stop();
|
|
445
459
|
});
|
|
446
460
|
}
|
|
447
|
-
function
|
|
461
|
+
function Le(n) {
|
|
448
462
|
const e = n.animationGroups;
|
|
449
|
-
|
|
463
|
+
Te(e);
|
|
450
464
|
}
|
|
451
|
-
function
|
|
465
|
+
function Oe(n, e, t) {
|
|
452
466
|
return new Promise((i) => {
|
|
453
|
-
n.stopAnimation(e), e.animations = [], Math.abs(e.alpha) > 2 * Math.PI && (e.alpha =
|
|
454
|
-
const a = [],
|
|
467
|
+
n.stopAnimation(e), e.animations = [], Math.abs(e.alpha) > 2 * Math.PI && (e.alpha = Fe(e.alpha, 0, 2 * Math.PI));
|
|
468
|
+
const a = [], s = t.target;
|
|
455
469
|
if (t.target && Object.keys(t.target).length > 0 && a.push(
|
|
456
470
|
P(
|
|
457
471
|
"cameraTargetLerp",
|
|
@@ -489,33 +503,33 @@ function Te(n, e, t) {
|
|
|
489
503
|
);
|
|
490
504
|
}
|
|
491
505
|
e.animations.push(...a);
|
|
492
|
-
const
|
|
493
|
-
e.disableAutoRotationBehavior(), n.beginAnimation(e, 0,
|
|
494
|
-
e.animations = [],
|
|
506
|
+
const r = e.useAutoRotationBehavior;
|
|
507
|
+
e.disableAutoRotationBehavior(), n.beginAnimation(e, 0, s ? y * 2 : y, !1, 1, () => {
|
|
508
|
+
e.animations = [], r && e.enableAutoRotationBehavior(), i();
|
|
495
509
|
});
|
|
496
510
|
});
|
|
497
511
|
}
|
|
498
512
|
function Z(n) {
|
|
499
513
|
return n * Math.PI / 180;
|
|
500
514
|
}
|
|
501
|
-
function P(n, e, t, i, a,
|
|
502
|
-
const
|
|
503
|
-
|
|
515
|
+
function P(n, e, t, i, a, s = 0, o = w.ANIMATIONLOOPMODE_CONSTANT) {
|
|
516
|
+
const r = new be();
|
|
517
|
+
r.setEasingMode(ve.EASINGMODE_EASEINOUT);
|
|
504
518
|
const h = new w(n, e, y, a, o), c = [];
|
|
505
|
-
return
|
|
506
|
-
frame: y * (
|
|
519
|
+
return s > 0 && c.push({ frame: 0, value: t }), c.push({ frame: y * s, value: t }), c.push({
|
|
520
|
+
frame: y * (s + 1),
|
|
507
521
|
value: i
|
|
508
|
-
}), h.setKeys(c), h.setEasingFunction(
|
|
522
|
+
}), h.setKeys(c), h.setEasingFunction(r), h;
|
|
509
523
|
}
|
|
510
|
-
function
|
|
524
|
+
function Fe(n, e, t) {
|
|
511
525
|
return n < e ? n = t - (e - n) % (t - e) : n = e + (n - e) % (t - e);
|
|
512
526
|
}
|
|
513
|
-
function
|
|
527
|
+
function Ie(n, e, t) {
|
|
514
528
|
n.forEach((i) => {
|
|
515
529
|
t && i.name !== t || i.goToFrame(e);
|
|
516
530
|
});
|
|
517
531
|
}
|
|
518
|
-
const
|
|
532
|
+
const Se = {
|
|
519
533
|
albedoTexture: "albedoMap",
|
|
520
534
|
bumpTexture: "normalMap",
|
|
521
535
|
ambientTexture: "ambientMap",
|
|
@@ -525,7 +539,7 @@ const Ie = {
|
|
|
525
539
|
refractionTexture: "refractionMap",
|
|
526
540
|
reflectionTexture: "reflectionMap"
|
|
527
541
|
};
|
|
528
|
-
function
|
|
542
|
+
function Be(n, e, t, i) {
|
|
529
543
|
[
|
|
530
544
|
"albedoTexture",
|
|
531
545
|
"bumpTexture",
|
|
@@ -535,9 +549,9 @@ function Fe(n, e, t, i) {
|
|
|
535
549
|
"metallicTexture",
|
|
536
550
|
"refractionTexture",
|
|
537
551
|
"reflectionTexture"
|
|
538
|
-
].forEach((
|
|
539
|
-
|
|
540
|
-
|
|
552
|
+
].forEach((s) => {
|
|
553
|
+
De(
|
|
554
|
+
s,
|
|
541
555
|
n,
|
|
542
556
|
e,
|
|
543
557
|
t,
|
|
@@ -545,27 +559,27 @@ function Fe(n, e, t, i) {
|
|
|
545
559
|
);
|
|
546
560
|
}), qe(n, e);
|
|
547
561
|
}
|
|
548
|
-
function
|
|
549
|
-
const
|
|
550
|
-
if (!
|
|
562
|
+
function De(n, e, t, i, a) {
|
|
563
|
+
const s = Se[n];
|
|
564
|
+
if (!s)
|
|
551
565
|
throw new Error("Unexpected texture name encountered.");
|
|
552
|
-
const
|
|
553
|
-
|
|
566
|
+
const r = e[s]?.fileLink;
|
|
567
|
+
r ? n === "reflectionTexture" ? r.endsWith(".env") || r.endsWith(".dds") ? i.addCubeTextureTask(n, r, void 0, !1, void 0, !0) : r.endsWith(".hdr") ? i.addHDRCubeTextureTask(n, r, 128, !1, !0, !1) : i.addTextureTask(n, r, !1, !1) : i.addTextureTask(n, r, !1, !1) : a && t[n] && (t[n] && t[n].dispose(), t[n] = null, ke(n, t));
|
|
554
568
|
}
|
|
555
|
-
function
|
|
556
|
-
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
|
|
569
|
+
function ke(n, e) {
|
|
570
|
+
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(0, 0, 0), e.reflectionTexture);
|
|
557
571
|
}
|
|
558
|
-
function
|
|
572
|
+
function Ne(n, e, t, i) {
|
|
559
573
|
if (!e) {
|
|
560
574
|
console.error("Failed to apply texture to material: material is null.");
|
|
561
575
|
return;
|
|
562
576
|
}
|
|
563
|
-
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
|
|
577
|
+
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(1, 1, 1), e.emissiveIntensity = 1);
|
|
564
578
|
}
|
|
565
579
|
function qe(n, e) {
|
|
566
|
-
n.clearCoat && (n.clearCoat ===
|
|
580
|
+
n.clearCoat && (n.clearCoat === B.RemoveWhenSelected ? (e.clearCoat.isEnabled = !1, e.clearCoat.indexOfRefraction = 1.5) : n.clearCoat === B.ApplyWhenSelected && (e.clearCoat.isEnabled = !0, e.clearCoat.indexOfRefraction = n.clearCoatIOR || e.clearCoat.indexOfRefraction));
|
|
567
581
|
}
|
|
568
|
-
class
|
|
582
|
+
class ze {
|
|
569
583
|
constructor(e, t, i) {
|
|
570
584
|
this.materialVariantMap = /* @__PURE__ */ new Map(), this.keysThatRemovedBaseModel = [], this.loadedContainerForKey = /* @__PURE__ */ new Map(), this.loadedMaterialsForKey = /* @__PURE__ */ new Map(), this.scene = e, this.renameClonedAsset = t, this.setBaseModelEnabled = i;
|
|
571
585
|
}
|
|
@@ -579,33 +593,33 @@ class ke {
|
|
|
579
593
|
* where we want to undo changes are remove effects from display.
|
|
580
594
|
*/
|
|
581
595
|
async applyMaterial(e, t, i, a) {
|
|
582
|
-
return new Promise((
|
|
596
|
+
return new Promise((s) => {
|
|
583
597
|
const o = this.materialVariantMap.get(e);
|
|
584
598
|
this.materialVariantMap.set(e, {
|
|
585
599
|
...o,
|
|
586
600
|
...t
|
|
587
601
|
});
|
|
588
|
-
const
|
|
589
|
-
(l) => l.name ===
|
|
602
|
+
const r = this.renameClonedAsset(e), h = this.scene.materials.filter(
|
|
603
|
+
(l) => l.name === r
|
|
590
604
|
);
|
|
591
605
|
if (h.length === 0) {
|
|
592
|
-
|
|
606
|
+
s();
|
|
593
607
|
return;
|
|
594
608
|
}
|
|
595
|
-
const c = new
|
|
609
|
+
const c = new we(this.scene);
|
|
596
610
|
c.useDefaultLoadingScreen = !1, h.forEach(
|
|
597
|
-
(l) =>
|
|
611
|
+
(l) => Be(t, l, c, a)
|
|
598
612
|
), c.onProgress = (l, m, u) => {
|
|
599
613
|
i && i(l / m * 100, 100, u.name);
|
|
600
614
|
}, c.onFinish = (l) => {
|
|
601
615
|
l.forEach((m) => {
|
|
602
616
|
const u = m;
|
|
603
617
|
i && i(100, 100, m.name), this.scene.materials.filter(
|
|
604
|
-
(f) => f.name ===
|
|
618
|
+
(f) => f.name === r
|
|
605
619
|
).forEach((f) => {
|
|
606
|
-
|
|
620
|
+
Ne(m.name, f, t, u.texture);
|
|
607
621
|
});
|
|
608
|
-
}),
|
|
622
|
+
}), s();
|
|
609
623
|
}, c.loadAsync();
|
|
610
624
|
});
|
|
611
625
|
}
|
|
@@ -619,12 +633,12 @@ class ke {
|
|
|
619
633
|
* @param getCurrentFrame A function that returns the current frame of the animation.
|
|
620
634
|
* @param getAnimationIsPlaying A function that returns whether the animation is currently playing.
|
|
621
635
|
*/
|
|
622
|
-
async applyModel(e, t, i, a,
|
|
636
|
+
async applyModel(e, t, i, a, s, o, r) {
|
|
623
637
|
if (i && t && !this.keysThatRemovedBaseModel.includes(e) && this.keysThatRemovedBaseModel.push(e), !i)
|
|
624
638
|
return this.keysThatRemovedBaseModel.includes(e) && this.keysThatRemovedBaseModel.length === 1 && await this.setBaseModelEnabled(!0), this.loadedContainerForKey.get(e)?.dispose(), this.loadedContainerForKey.delete(e), this.loadedMaterialsForKey.get(e)?.forEach((u) => u.dispose()), this.loadedMaterialsForKey.delete(e), this.keysThatRemovedBaseModel = this.keysThatRemovedBaseModel.filter((u) => u !== e), Promise.resolve(void 0);
|
|
625
|
-
const c = (await
|
|
639
|
+
const c = (await N(i, this.scene, a)).instantiateModelsToScene(this.renameClonedAsset, !0);
|
|
626
640
|
this.loadedContainerForKey.has(e) && (this.loadedContainerForKey.get(e).dispose(), this.loadedContainerForKey.delete(e), this.loadedMaterialsForKey.get(e)?.forEach((u) => u.dispose()), this.loadedMaterialsForKey.delete(e));
|
|
627
|
-
const l =
|
|
641
|
+
const l = s && s();
|
|
628
642
|
if (l) {
|
|
629
643
|
const u = o && o(), p = l.name ? this.renameClonedAsset(l.name) : void 0;
|
|
630
644
|
X(
|
|
@@ -633,7 +647,7 @@ class ke {
|
|
|
633
647
|
l.to,
|
|
634
648
|
l.from,
|
|
635
649
|
p
|
|
636
|
-
), u != null && (
|
|
650
|
+
), u != null && (r && r(), Ie(c.animationGroups, u + 2, p));
|
|
637
651
|
}
|
|
638
652
|
t && await this.setBaseModelEnabled(!1), this.loadedContainerForKey.set(e, c), this.loadedMaterialsForKey.set(e, J(c));
|
|
639
653
|
const m = [];
|
|
@@ -664,8 +678,8 @@ function J(n) {
|
|
|
664
678
|
return n.rootNodes.forEach((t) => {
|
|
665
679
|
t.getChildMeshes().forEach((i) => {
|
|
666
680
|
i.material && !e.includes(i.material) && e.push(i.material), i.subMeshes && i.subMeshes.forEach((a) => {
|
|
667
|
-
const
|
|
668
|
-
|
|
681
|
+
const s = a.getMaterial(!1);
|
|
682
|
+
s && !e.includes(s) && e.push(s);
|
|
669
683
|
});
|
|
670
684
|
});
|
|
671
685
|
}), e;
|
|
@@ -678,21 +692,21 @@ function $(n, e = "") {
|
|
|
678
692
|
from: t.from
|
|
679
693
|
}));
|
|
680
694
|
}
|
|
681
|
-
class
|
|
695
|
+
class Ge {
|
|
682
696
|
constructor(e) {
|
|
683
697
|
this.metadata = /* @__PURE__ */ new Map(), this.materialSelectedObservable = new C(), this.materialDeselectedObservable = new C(), this.materialVariantObservable = new C(), this.modelVariantObservable = new C(), this.materialReadyToLoadCallbacks = /* @__PURE__ */ new Map(), this.dynamicTextures = /* @__PURE__ */ new Map(), this.queuedMaterialChanges = /* @__PURE__ */ new Map(), this.materialChangesInProgress = [], this.queuedModelChanges = /* @__PURE__ */ new Map(), this.modelChangesInProgress = [], this.isExecutingAnimation = !1, this.animations = [], this.initialized = !1, this.materials = [];
|
|
684
|
-
const { enablePicking: t, modelDetails: i, previewService: a, progressHandler:
|
|
685
|
-
this.enablePicking = t, this.contextService = i.contextService, this.id =
|
|
698
|
+
const { enablePicking: t, modelDetails: i, previewService: a, progressHandler: s, scene: o } = e;
|
|
699
|
+
this.enablePicking = t, this.contextService = i.contextService, this.id = Re(), this.previewService = a, this.scene = o, this.variantManager = new ze(
|
|
686
700
|
o,
|
|
687
701
|
this.renameClonedAsset.bind(this),
|
|
688
702
|
this.setBaseModelEnabled.bind(this)
|
|
689
|
-
), this.transformRoot = new
|
|
690
|
-
const
|
|
703
|
+
), this.transformRoot = new ge("root", this.scene);
|
|
704
|
+
const r = async () => {
|
|
691
705
|
if (!i.model)
|
|
692
706
|
throw new Error("Model container constructed with no URL. This is currently unsupported.");
|
|
693
|
-
return this.assetContainer = await
|
|
707
|
+
return this.assetContainer = await N(i.model, o, s), await this.instantiate(), this;
|
|
694
708
|
};
|
|
695
|
-
this.importPromise =
|
|
709
|
+
this.importPromise = r();
|
|
696
710
|
}
|
|
697
711
|
//#region Interface implementation
|
|
698
712
|
async applyMaterialVariant(e, t, i, a) {
|
|
@@ -706,14 +720,14 @@ class Ne {
|
|
|
706
720
|
));
|
|
707
721
|
return;
|
|
708
722
|
}
|
|
709
|
-
const
|
|
723
|
+
const s = async () => {
|
|
710
724
|
await this.variantManager.applyMaterial(
|
|
711
725
|
e,
|
|
712
726
|
i,
|
|
713
|
-
(o,
|
|
727
|
+
(o, r, h) => {
|
|
714
728
|
this.materialVariantObservable.notifyObservers({
|
|
715
729
|
remainingCount: o,
|
|
716
|
-
totalCount:
|
|
730
|
+
totalCount: r,
|
|
717
731
|
taskName: h
|
|
718
732
|
});
|
|
719
733
|
},
|
|
@@ -721,14 +735,14 @@ class Ne {
|
|
|
721
735
|
);
|
|
722
736
|
};
|
|
723
737
|
if (this.materialChangesInProgress.includes(e)) {
|
|
724
|
-
this.queuedMaterialChanges.has(e) ? this.queuedMaterialChanges.get(e)?.set(t,
|
|
738
|
+
this.queuedMaterialChanges.has(e) ? this.queuedMaterialChanges.get(e)?.set(t, s) : (this.queuedMaterialChanges.set(e, /* @__PURE__ */ new Map()), this.queuedMaterialChanges.get(e)?.set(t, s));
|
|
725
739
|
return;
|
|
726
740
|
}
|
|
727
|
-
if (this.materialChangesInProgress.push(e), await
|
|
741
|
+
if (this.materialChangesInProgress.push(e), await s(), this.queuedMaterialChanges.has(e)) {
|
|
728
742
|
const o = this.queuedMaterialChanges.get(e);
|
|
729
743
|
if (!o) throw new Error("Target material is undefined");
|
|
730
|
-
o.forEach(async (
|
|
731
|
-
await
|
|
744
|
+
o.forEach(async (r) => {
|
|
745
|
+
await r();
|
|
732
746
|
}), this.queuedMaterialChanges.delete(e);
|
|
733
747
|
}
|
|
734
748
|
this.materialChangesInProgress.splice(this.materialChangesInProgress.indexOf(e), 1), this.configureGlowLayer(), this.scene.cleanCachedTextureBuffer();
|
|
@@ -738,34 +752,34 @@ class Ne {
|
|
|
738
752
|
e,
|
|
739
753
|
i,
|
|
740
754
|
t?.model,
|
|
741
|
-
(
|
|
755
|
+
(r) => {
|
|
742
756
|
this.modelVariantObservable.notifyObservers({
|
|
743
|
-
...
|
|
757
|
+
...r,
|
|
744
758
|
key: e
|
|
745
759
|
});
|
|
746
760
|
},
|
|
747
761
|
this.getLastRequestedAnimation.bind(this),
|
|
748
762
|
this.getCurrentAnimationFrame.bind(this),
|
|
749
763
|
this.getAnimationIsPlaying.bind(this)
|
|
750
|
-
),
|
|
764
|
+
), s = async () => {
|
|
751
765
|
this.modelChangesInProgress.push(e);
|
|
752
|
-
let
|
|
766
|
+
let r = await a();
|
|
753
767
|
if (this.queuedModelChanges.has(e)) {
|
|
754
768
|
const h = this.queuedModelChanges.get(e);
|
|
755
769
|
if (!h) throw new Error("Queued change resolved undefined");
|
|
756
|
-
|
|
770
|
+
r = await h(), this.queuedModelChanges.delete(e);
|
|
757
771
|
}
|
|
758
|
-
return this.modelChangesInProgress.splice(this.modelChangesInProgress.indexOf(e), 1),
|
|
772
|
+
return this.modelChangesInProgress.splice(this.modelChangesInProgress.indexOf(e), 1), r;
|
|
759
773
|
};
|
|
760
774
|
if (!this.initialized || this.modelChangesInProgress.includes(e)) {
|
|
761
|
-
const
|
|
775
|
+
const r = async () => {
|
|
762
776
|
const h = await a();
|
|
763
777
|
return h ? this.configureModelInstance(h) : this.configureGlowLayer(), h;
|
|
764
778
|
};
|
|
765
|
-
this.queuedModelChanges.set(e,
|
|
779
|
+
this.queuedModelChanges.set(e, r);
|
|
766
780
|
return;
|
|
767
781
|
}
|
|
768
|
-
const o = await
|
|
782
|
+
const o = await s();
|
|
769
783
|
this.contextService || (this.contextService = t?.contextService), o ? this.configureModelInstance(o) : this.configureGlowLayer();
|
|
770
784
|
}
|
|
771
785
|
dispose() {
|
|
@@ -777,7 +791,7 @@ class Ne {
|
|
|
777
791
|
let i = () => {
|
|
778
792
|
};
|
|
779
793
|
const a = async () => {
|
|
780
|
-
this.isExecutingAnimation = !0, await new Promise((
|
|
794
|
+
this.isExecutingAnimation = !0, await new Promise((s) => {
|
|
781
795
|
const o = [
|
|
782
796
|
...this.modelInstance?.animationGroups || [],
|
|
783
797
|
...this.variantManager.getAnimationGroups()
|
|
@@ -788,19 +802,19 @@ class Ne {
|
|
|
788
802
|
e.to,
|
|
789
803
|
e.from,
|
|
790
804
|
e.name ? this.renameClonedAsset(e.name) : void 0,
|
|
791
|
-
|
|
805
|
+
s
|
|
792
806
|
);
|
|
793
807
|
}), this.isExecutingAnimation = !1, this.queuedAnimationFunction && this.queuedAnimationFunction(), this.queuedAnimationFunction = void 0, i();
|
|
794
808
|
};
|
|
795
|
-
return t ? (
|
|
796
|
-
i =
|
|
809
|
+
return t ? (Le(this.scene), a()) : this.isExecutingAnimation ? (this.queuedAnimationFunction = a, new Promise((s) => {
|
|
810
|
+
i = s;
|
|
797
811
|
})) : a();
|
|
798
812
|
}
|
|
799
813
|
getAnimations(e) {
|
|
800
814
|
return [
|
|
801
815
|
...this.animations,
|
|
802
816
|
...e ? $(this.variantManager.getAnimationGroups(), this.renameClonedAsset("")) : []
|
|
803
|
-
].map((t, i) => ({ ...t, name: t.name || `UNNAMED_ANIMATION_${i}` })).filter((t, i, a) => a.indexOf(a.find((
|
|
817
|
+
].map((t, i) => ({ ...t, name: t.name || `UNNAMED_ANIMATION_${i}` })).filter((t, i, a) => a.indexOf(a.find((s) => s.name === t.name)) == i);
|
|
804
818
|
}
|
|
805
819
|
getId() {
|
|
806
820
|
return this.id;
|
|
@@ -855,14 +869,14 @@ class Ne {
|
|
|
855
869
|
e.rootNodes.forEach((t) => {
|
|
856
870
|
t.getChildMeshes(!1).forEach((i) => {
|
|
857
871
|
i.name === "targetcube_t" || i.name === "backgroundShell" || (i.actionManager || (i.actionManager = new E(this.scene)), i.actionManager.registerAction(
|
|
858
|
-
new
|
|
872
|
+
new V(E.OnPointerOverTrigger, (a) => {
|
|
859
873
|
a.meshUnderPointer && i.material && this.materialSelectedObservable.notifyObservers({
|
|
860
874
|
id: i.material.id,
|
|
861
875
|
name: this.stripIdFromName(i.material.name)
|
|
862
876
|
});
|
|
863
877
|
})
|
|
864
878
|
), i.actionManager.registerAction(
|
|
865
|
-
new
|
|
879
|
+
new V(E.OnPointerOutTrigger, () => {
|
|
866
880
|
i.material && this.materialDeselectedObservable.notifyObservers({
|
|
867
881
|
id: i.material.id,
|
|
868
882
|
name: this.stripIdFromName(i.material.name)
|
|
@@ -891,7 +905,7 @@ class Ne {
|
|
|
891
905
|
return this.queuedModelChanges.size;
|
|
892
906
|
}
|
|
893
907
|
configureGlowLayer() {
|
|
894
|
-
const e = (i) => i instanceof
|
|
908
|
+
const e = (i) => i instanceof k && i.emissiveTexture !== null;
|
|
895
909
|
this.materials.some(e) || this.variantManager.getAllMaterials().some(e) ? this.previewService.getGlowLayerManager().includeMeshes(this.getAllMeshes()) : this.previewService.getGlowLayerManager().removeMeshes(this.getAllMeshes());
|
|
896
910
|
}
|
|
897
911
|
configureModelInstance(e) {
|
|
@@ -899,12 +913,12 @@ class Ne {
|
|
|
899
913
|
throw new Error("Transform disposed! This should never happen unless there is a race condition present!");
|
|
900
914
|
const t = this.transformRoot.position, i = this.transformRoot.rotationQuaternion, a = this.transformRoot.scaling;
|
|
901
915
|
this.transformRoot.position = g.Zero(), this.transformRoot.rotationQuaternion = A.Identity(), this.transformRoot.scaling = g.One();
|
|
902
|
-
for (const
|
|
903
|
-
|
|
904
|
-
for (const o of
|
|
916
|
+
for (const s of e.rootNodes) {
|
|
917
|
+
s.parent = this.transformRoot;
|
|
918
|
+
for (const o of s.getChildMeshes(!1))
|
|
905
919
|
o.alwaysSelectAsActiveMesh = !0;
|
|
906
920
|
}
|
|
907
|
-
this.transformRoot.position = t, this.transformRoot.rotationQuaternion = i, this.transformRoot.scaling = a, this.canvasPanels = this.contextService?.getAll() || /* @__PURE__ */ new Map(),
|
|
921
|
+
this.transformRoot.position = t, this.transformRoot.rotationQuaternion = i, this.transformRoot.scaling = a, this.canvasPanels = this.contextService?.getAll() || /* @__PURE__ */ new Map(), Pe(
|
|
908
922
|
this.materials.concat(this.variantManager.getAllMaterials()),
|
|
909
923
|
this.scene,
|
|
910
924
|
this.canvasPanels,
|
|
@@ -919,7 +933,7 @@ class Ne {
|
|
|
919
933
|
this.modelInstance?.dispose(), this.modelInstance = void 0;
|
|
920
934
|
}
|
|
921
935
|
getAllMeshes() {
|
|
922
|
-
return this.modelInstance?.rootNodes.map((e) => e.getChildMeshes(!1).filter((t) => t instanceof
|
|
936
|
+
return this.modelInstance?.rootNodes.map((e) => e.getChildMeshes(!1).filter((t) => t instanceof me)).flat();
|
|
923
937
|
}
|
|
924
938
|
async instantiate() {
|
|
925
939
|
if (!this.assetContainer) throw new Error("Attempted to instantiate ModelContainer without an AssetContainer");
|
|
@@ -982,9 +996,9 @@ class Ne {
|
|
|
982
996
|
}
|
|
983
997
|
//#endregion
|
|
984
998
|
}
|
|
985
|
-
class
|
|
986
|
-
constructor(e, t, i, a,
|
|
987
|
-
super(e, t, i, a,
|
|
999
|
+
class q extends j {
|
|
1000
|
+
constructor(e, t, i, a, s, o, r, h) {
|
|
1001
|
+
super(e, t, i, a, s, o, h), this.lastFocus = new g(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, r.camera.autoOrientation && (this.alpha += Math.PI), r && (r.camera.limits.min.beta && (this.lowerBetaLimit = r.camera.limits.min.beta), r.camera.limits.max.beta && (this.upperBetaLimit = r.camera.limits.max.beta), r.camera.limits.min.alpha && (this.lowerAlphaLimit = r.camera.limits.min.alpha), r.camera.limits.max.alpha && (this.upperAlphaLimit = r.camera.limits.max.alpha), r.camera.limits.min.radius && (this.lowerRadiusLimit = r.camera.limits.min.radius), r.camera.limits.max.radius && (this.upperRadiusLimit = r.camera.limits.max.radius), r.camera.autoRotation.enabled && this.enableAutoRotationBehavior(r.camera.autoRotation.idleTimeMs));
|
|
988
1002
|
}
|
|
989
1003
|
updateConfiguration(e) {
|
|
990
1004
|
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());
|
|
@@ -1035,8 +1049,8 @@ class k extends j {
|
|
|
1035
1049
|
i.framingTime = t || 800;
|
|
1036
1050
|
const a = () => {
|
|
1037
1051
|
this.isRunningFramingBehavior = !1;
|
|
1038
|
-
},
|
|
1039
|
-
this.updateRadiusBounds(o.length() * 1.5), this.wheelPrecision = 100 / this.radius, this.panningInertia = 0, this.panningOriginTarget.copyFrom(
|
|
1052
|
+
}, s = T(this._scene), o = s.max.subtract(s.min), r = s.min.add(o.scale(0.5));
|
|
1053
|
+
this.updateRadiusBounds(o.length() * 1.5), this.wheelPrecision = 100 / this.radius, this.panningInertia = 0, this.panningOriginTarget.copyFrom(r), this.panDenominator = o.length(), this.lastFocus.copyFrom(r), i.zoomOnBoundingInfo(s.min, s.max, void 0, a), i.framingTime = 0;
|
|
1040
1054
|
}
|
|
1041
1055
|
/**
|
|
1042
1056
|
* Activates the auto rotation behavior causing the camera to rotate slowly around
|
|
@@ -1066,18 +1080,18 @@ class k extends j {
|
|
|
1066
1080
|
* @param disablePan If true the camera will not allow panning.
|
|
1067
1081
|
*/
|
|
1068
1082
|
static create(e, t, i) {
|
|
1069
|
-
const a = T(e),
|
|
1083
|
+
const a = T(e), s = a.max.subtract(a.min), o = a.min.add(s.scale(0.5)), r = new q(
|
|
1070
1084
|
"ProductCamera",
|
|
1071
1085
|
-(Math.PI / 2),
|
|
1072
1086
|
Math.PI / 2,
|
|
1073
|
-
|
|
1087
|
+
s.length() * 1.5,
|
|
1074
1088
|
o,
|
|
1075
1089
|
e,
|
|
1076
1090
|
t
|
|
1077
1091
|
);
|
|
1078
|
-
return
|
|
1079
|
-
|
|
1080
|
-
}), i && (e.activeCamera =
|
|
1092
|
+
return r.setPanEnabled(t.options?.noPan !== void 0 ? !t.options.noPan : !0), r.panningInertia = 0, r.panningOriginTarget.copyFrom(o), r.panDenominator = s.length(), r.onAfterCheckInputsObservable.addOnce(() => {
|
|
1093
|
+
r.setPanEnabled(r.panEnabled);
|
|
1094
|
+
}), i && (e.activeCamera = r), r;
|
|
1081
1095
|
}
|
|
1082
1096
|
}
|
|
1083
1097
|
function T(n) {
|
|
@@ -1089,9 +1103,9 @@ function T(n) {
|
|
|
1089
1103
|
const e = n.meshes.filter((t) => t.name.toLowerCase().endsWith("_t") || t.name.toLowerCase().includes("_t_"));
|
|
1090
1104
|
return n.getWorldExtends((t) => t.isVisible && t.isEnabled() && (e.length === 0 || e.includes(t)));
|
|
1091
1105
|
}
|
|
1092
|
-
class
|
|
1106
|
+
class _e {
|
|
1093
1107
|
constructor(e, t = !1, i = void 0) {
|
|
1094
|
-
this.renderingPipeline = new
|
|
1108
|
+
this.renderingPipeline = new Ce(
|
|
1095
1109
|
"default",
|
|
1096
1110
|
t,
|
|
1097
1111
|
e,
|
|
@@ -1141,14 +1155,14 @@ class ze {
|
|
|
1141
1155
|
this.renderingPipeline.imageProcessing.vignetteBlendMode = M.VIGNETTEMODE_OPAQUE;
|
|
1142
1156
|
break;
|
|
1143
1157
|
}
|
|
1144
|
-
e.vignette?.colorRgba ? this.renderingPipeline.imageProcessing.vignetteColor = new
|
|
1158
|
+
e.vignette?.colorRgba ? this.renderingPipeline.imageProcessing.vignetteColor = new v(
|
|
1145
1159
|
e.vignette.colorRgba.r,
|
|
1146
1160
|
e.vignette.colorRgba.g,
|
|
1147
1161
|
e.vignette.colorRgba.b,
|
|
1148
1162
|
e.vignette.colorRgba.a
|
|
1149
|
-
) : e.vignette?.colorHex ? this.renderingPipeline.imageProcessing.vignetteColor =
|
|
1163
|
+
) : e.vignette?.colorHex ? this.renderingPipeline.imageProcessing.vignetteColor = v.FromHexString(
|
|
1150
1164
|
e.vignette.colorHex
|
|
1151
|
-
) : this.renderingPipeline.imageProcessing.vignetteColor = new
|
|
1165
|
+
) : this.renderingPipeline.imageProcessing.vignetteColor = new v(
|
|
1152
1166
|
d.vignette.colorRgba.r,
|
|
1153
1167
|
d.vignette.colorRgba.g,
|
|
1154
1168
|
d.vignette.colorRgba.b,
|
|
@@ -1161,35 +1175,36 @@ class ze {
|
|
|
1161
1175
|
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;
|
|
1162
1176
|
}
|
|
1163
1177
|
}
|
|
1164
|
-
|
|
1165
|
-
return new
|
|
1178
|
+
ae.GLTFLoader.RegisterExtension("glbPostProcessor", function(n) {
|
|
1179
|
+
return new xe(n);
|
|
1166
1180
|
});
|
|
1167
|
-
|
|
1181
|
+
D.OnPluginActivatedObservable.add((n) => {
|
|
1168
1182
|
if (n.name === "gltf") {
|
|
1169
1183
|
const e = n;
|
|
1170
1184
|
e.transparencyAsCoverage = !0;
|
|
1171
1185
|
}
|
|
1172
1186
|
});
|
|
1187
|
+
const L = "spiff-fallback-light";
|
|
1173
1188
|
function O(n) {
|
|
1174
1189
|
return new g(n.x, n.y, n.z);
|
|
1175
1190
|
}
|
|
1176
|
-
function
|
|
1191
|
+
function F(n) {
|
|
1177
1192
|
return { x: n.x, y: n.y, z: n.z };
|
|
1178
1193
|
}
|
|
1179
|
-
class
|
|
1194
|
+
class Ft {
|
|
1180
1195
|
constructor(e) {
|
|
1181
|
-
this.focusLostNotified = !1, this.focusLostObservable = new C(), this.modelLoadEventCallbacks = [], this.validHighlightMaterials = [], this.modelContainers = /* @__PURE__ */ new Map(), this.plugins = [], this.initComplete = !1, this.isAnimatingCamera = !1, this.renderLoop = () => {
|
|
1196
|
+
this.focusLostNotified = !1, this.focusLostObservable = new C(), this.modelLoadEventCallbacks = [], this.validHighlightMaterials = [], this.modelContainers = /* @__PURE__ */ new Map(), this.plugins = [], this.initComplete = !1, this.isAnimatingCamera = !1, this.environmentLightingAvailable = !1, this.renderLoop = () => {
|
|
1182
1197
|
if (!this.engine.views)
|
|
1183
1198
|
return;
|
|
1184
1199
|
this.modelContainers.forEach((c) => {
|
|
1185
1200
|
c.updateDynamicTextures();
|
|
1186
1201
|
}), this.scene.autoClear = !0, this.scene.autoClearDepthAndStencil = !0;
|
|
1187
|
-
const
|
|
1188
|
-
if (
|
|
1189
|
-
if (
|
|
1190
|
-
const c = this.configuration.scene.clearColor, l =
|
|
1202
|
+
const r = this.engine.getRenderingCanvas();
|
|
1203
|
+
if (r)
|
|
1204
|
+
if (r.getContext("webgl2") ?? r.getContext("webgl")) {
|
|
1205
|
+
const c = this.configuration.scene.clearColor, l = r.getContext("webgl2") ?? r.getContext("webgl");
|
|
1191
1206
|
l.clearDepth(1), l.depthFunc(l.LEQUAL), l.clearStencil(0), l.clearColor(c.r, c.g, c.b, c.a), l.clear(l.COLOR_BUFFER_BIT | l.DEPTH_BUFFER_BIT | l.STENCIL_BUFFER_BIT);
|
|
1192
|
-
} else
|
|
1207
|
+
} else r.getContext("2d") ? r.getContext("2d").clearRect(0, 0, r.width, r.height) : console.error("SpiffCommerce: Failed to get any context on the rendering canvas.");
|
|
1193
1208
|
this.scene.render(), this.camera.isRunningFramingBehavior && this.camera.getFramingBehavior().isUserIsMoving && (this.camera.isRunningFramingBehavior = !1);
|
|
1194
1209
|
const h = Math.max((this.camera.lowerRadiusLimit ?? 1) * 0.01, 1e-3);
|
|
1195
1210
|
!this.camera.isRunningFramingBehavior && !this.camera.target.equalsWithEpsilon(this.camera.lastFocus, h) && !this.focusLostNotified && (this.focusLostObservable.notifyObservers(void 0), this.focusLostNotified = !0);
|
|
@@ -1198,14 +1213,14 @@ class Tt {
|
|
|
1198
1213
|
if (!e?.noRender)
|
|
1199
1214
|
return this.configuration.createCanvas();
|
|
1200
1215
|
})(), a = "1.5.7";
|
|
1201
|
-
|
|
1216
|
+
ne.Configuration = {
|
|
1202
1217
|
decoder: {
|
|
1203
1218
|
wasmUrl: `https://www.gstatic.com/draco/versioned/decoders/${a}/draco_wasm_wrapper_gltf.js`,
|
|
1204
1219
|
wasmBinaryUrl: `https://www.gstatic.com/draco/versioned/decoders/${a}/draco_decoder_gltf.wasm`,
|
|
1205
1220
|
fallbackUrl: `https://www.gstatic.com/draco/versioned/decoders/${a}/draco_decoder_gltf.js`
|
|
1206
1221
|
}
|
|
1207
1222
|
}, i && (i.getContext("webgl2") || i.getContext("webgl"));
|
|
1208
|
-
const
|
|
1223
|
+
const s = console.log;
|
|
1209
1224
|
console.log = () => {
|
|
1210
1225
|
};
|
|
1211
1226
|
const o = i ? new I(i, !0, {
|
|
@@ -1217,16 +1232,9 @@ class Tt {
|
|
|
1217
1232
|
stencil: this.configuration.highlights.enabled,
|
|
1218
1233
|
forceSRGBBufferSupportState: !0
|
|
1219
1234
|
}) : new ee();
|
|
1220
|
-
|
|
1221
|
-
const s = N.CreateFromPrefilteredData(
|
|
1222
|
-
this.configuration.scene.environment.file,
|
|
1223
|
-
this.scene
|
|
1224
|
-
);
|
|
1225
|
-
s.name = "initial-environment-cube", s.rotationY = this.configuration.scene.environment.rotationY, this.scene.environmentTexture = s;
|
|
1226
|
-
}
|
|
1227
|
-
this.scene.environmentIntensity = this.configuration.scene.environment.intensity, this.configuration.options?.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 ye(this.scene, this.configuration.emissiveGlowIntensity), this.initPromise = new Promise((s) => {
|
|
1235
|
+
o.enableOfflineSupport = !1, o.doNotHandleContextLost = !0, console.log = s, o.hideLoadingUI(), window.addEventListener("resize", this.fireResizeEvent.bind(this)), this.engine = o, this.scene = new re(o), this.camera = q.create(this.scene, this.configuration), this.scene.activeCamera = this.camera, this.renderingPipeline = new _e(this.scene, !1, this.camera), this.scene.clearColor = this.configuration.scene.clearColor, this.setEnvironmentTexture(this.configuration, "initial-environment-cube"), this.scene.environmentIntensity = this.configuration.scene.environment.intensity, this.configuration.options?.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 Me(this.scene, this.configuration.emissiveGlowIntensity), this.initPromise = new Promise((r) => {
|
|
1228
1236
|
this.scene.onReadyObservable.addOnce(() => {
|
|
1229
|
-
this.initComplete = !0,
|
|
1237
|
+
this.initComplete = !0, r();
|
|
1230
1238
|
});
|
|
1231
1239
|
});
|
|
1232
1240
|
}
|
|
@@ -1258,7 +1266,7 @@ class Tt {
|
|
|
1258
1266
|
}
|
|
1259
1267
|
registerView(e) {
|
|
1260
1268
|
const t = e.height, i = e.width;
|
|
1261
|
-
this.engine.registerView(e, void 0, !0), e.setAttribute("height", t.toString()), e.setAttribute("width", i.toString()), this.orbitEnabled() || this.setCameraState(
|
|
1269
|
+
this.engine.registerView(e, void 0, !0), e.setAttribute("height", t.toString()), e.setAttribute("width", i.toString()), this.orbitEnabled() || this.setCameraState(S.Pan), this.reattachControls(e), this.engine.activeRenderLoops.length === 0 && this.engine.runRenderLoop(this.renderLoop);
|
|
1262
1270
|
}
|
|
1263
1271
|
unregisterView(e) {
|
|
1264
1272
|
this.engine.unRegisterView(e), this.engine.views && this.engine.views.length === 0 && this.engine.stopRenderLoop(this.renderLoop);
|
|
@@ -1275,7 +1283,7 @@ class Tt {
|
|
|
1275
1283
|
let t = () => {
|
|
1276
1284
|
};
|
|
1277
1285
|
const i = async () => {
|
|
1278
|
-
this.isAnimatingCamera = !0, await
|
|
1286
|
+
this.isAnimatingCamera = !0, await Oe(this.scene, this.scene.activeCamera, e), this.isAnimatingCamera = !1, this.queuedAnimationFunction && this.queuedAnimationFunction(), this.queuedAnimationFunction = void 0, t();
|
|
1279
1287
|
};
|
|
1280
1288
|
return this.isAnimatingCamera ? (this.queuedAnimationFunction = i, new Promise((a) => {
|
|
1281
1289
|
t = a;
|
|
@@ -1300,7 +1308,7 @@ class Tt {
|
|
|
1300
1308
|
setCameraState(e) {
|
|
1301
1309
|
if (!this.engine?.views || !this.engine?.views[0])
|
|
1302
1310
|
throw new Error("No views attached, camera state requires a view to attach controls onto.");
|
|
1303
|
-
e ===
|
|
1311
|
+
e === S.Orbit ? this.reattachControls(this.engine.views[0].target, 2) : this.reattachControls(this.engine.views[0].target, 0);
|
|
1304
1312
|
}
|
|
1305
1313
|
animateToLastCameraFocus() {
|
|
1306
1314
|
let e = () => {
|
|
@@ -1309,9 +1317,9 @@ class Tt {
|
|
|
1309
1317
|
this.isAnimatingCamera = !0, await new Promise((i) => {
|
|
1310
1318
|
this.focusLostNotified = !1;
|
|
1311
1319
|
const a = () => {
|
|
1312
|
-
const
|
|
1320
|
+
const s = this.configuration;
|
|
1313
1321
|
this.camera.rerunFramingBehavior(() => {
|
|
1314
|
-
|
|
1322
|
+
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();
|
|
1315
1323
|
});
|
|
1316
1324
|
};
|
|
1317
1325
|
this.scene.onAfterRenderObservable.addOnce(a);
|
|
@@ -1333,13 +1341,13 @@ class Tt {
|
|
|
1333
1341
|
async renderSceneScreenshot(e, t) {
|
|
1334
1342
|
if (!this.camera)
|
|
1335
1343
|
throw new Error("Missing product camera, cannot render screenshot!");
|
|
1336
|
-
const i = new j("screenshotCamera", 0, 0, 0, g.Zero(), this.scene), a = t.latDeg * Math.PI / 180,
|
|
1337
|
-
i.target = t.target ? new g(t.target.x, t.target.y, t.target.z) : g.Zero(), i.alpha =
|
|
1344
|
+
const i = new j("screenshotCamera", 0, 0, 0, g.Zero(), this.scene), a = t.latDeg * Math.PI / 180, s = t.lonDeg * Math.PI / 180;
|
|
1345
|
+
i.target = t.target ? new g(t.target.x, t.target.y, t.target.z) : g.Zero(), i.alpha = s, i.beta = a, i.radius = t.radius || this.camera.radius, i.minZ = 0.01;
|
|
1338
1346
|
try {
|
|
1339
1347
|
return await new Promise((o) => {
|
|
1340
|
-
const
|
|
1341
|
-
this.scene.onBeforeRenderObservable.remove(
|
|
1342
|
-
const h = await
|
|
1348
|
+
const r = this.scene.onBeforeRenderObservable.add(async () => {
|
|
1349
|
+
this.scene.onBeforeRenderObservable.remove(r);
|
|
1350
|
+
const h = await se.CreateScreenshotUsingRenderTargetAsync(
|
|
1343
1351
|
this.engine,
|
|
1344
1352
|
i,
|
|
1345
1353
|
e,
|
|
@@ -1359,10 +1367,10 @@ class Tt {
|
|
|
1359
1367
|
const e = this.configuration;
|
|
1360
1368
|
if (!e)
|
|
1361
1369
|
return !0;
|
|
1362
|
-
const t = e.camera.limits.min.alpha, i = e.camera.limits.max.alpha, a = e.camera.limits.min.beta,
|
|
1363
|
-
if (t === void 0 || i === void 0 || a === void 0 ||
|
|
1370
|
+
const t = e.camera.limits.min.alpha, i = e.camera.limits.max.alpha, a = e.camera.limits.min.beta, s = e.camera.limits.max.beta;
|
|
1371
|
+
if (t === void 0 || i === void 0 || a === void 0 || s === void 0)
|
|
1364
1372
|
return !0;
|
|
1365
|
-
const o = [t, i],
|
|
1373
|
+
const o = [t, i], r = [a, s], h = o.every((l) => l === t), c = r.every((l) => l === a);
|
|
1366
1374
|
return !h && !c;
|
|
1367
1375
|
}
|
|
1368
1376
|
fireResizeEvent() {
|
|
@@ -1371,11 +1379,11 @@ class Tt {
|
|
|
1371
1379
|
setHighlights(e) {
|
|
1372
1380
|
this.scene.materials.forEach(() => {
|
|
1373
1381
|
this.scene.materials.forEach((i) => {
|
|
1374
|
-
i.emissiveIntensity === 0.18 && (i.emissiveColor =
|
|
1382
|
+
i.emissiveIntensity === 0.18 && (i.emissiveColor = b.Black(), i.emissiveIntensity = 1);
|
|
1375
1383
|
});
|
|
1376
1384
|
}), e.filter((i) => this.validHighlightMaterials.includes(i.name)).forEach((i) => {
|
|
1377
|
-
const a = this.scene.materials.find((
|
|
1378
|
-
a && (a.emissiveColor = new
|
|
1385
|
+
const a = this.scene.materials.find((s) => s.id === i.id);
|
|
1386
|
+
a && (a.emissiveColor = new b(
|
|
1379
1387
|
this.configuration.highlights.color.r,
|
|
1380
1388
|
this.configuration.highlights.color.g,
|
|
1381
1389
|
this.configuration.highlights.color.b
|
|
@@ -1386,15 +1394,15 @@ class Tt {
|
|
|
1386
1394
|
this.renderingPipeline && this.renderingPipeline.setConfiguration(e);
|
|
1387
1395
|
}
|
|
1388
1396
|
loadModel(e, t) {
|
|
1389
|
-
const { refocusCamera: i = !0, progressHandler: a } = t ?? {},
|
|
1397
|
+
const { refocusCamera: i = !0, progressHandler: a } = t ?? {}, s = new Ge({
|
|
1390
1398
|
enablePicking: this.configuration.highlights.enabled,
|
|
1391
1399
|
modelDetails: e,
|
|
1392
1400
|
scene: this.scene,
|
|
1393
1401
|
previewService: this,
|
|
1394
1402
|
progressHandler: a
|
|
1395
1403
|
});
|
|
1396
|
-
return
|
|
1397
|
-
if (this.modelContainers.size <= 1 && i) {
|
|
1404
|
+
return s.getInitializationPromise().then(() => {
|
|
1405
|
+
if (this.reconcileFallbackLighting(this.configuration), this.modelContainers.size <= 1 && i) {
|
|
1398
1406
|
const o = this.queuedCameraAnimation;
|
|
1399
1407
|
this.forceStopCameraAnimations(), this.camera.rerunFramingBehavior(() => {
|
|
1400
1408
|
this.scene.onAfterRenderObservable.addOnce(() => {
|
|
@@ -1402,17 +1410,17 @@ class Tt {
|
|
|
1402
1410
|
});
|
|
1403
1411
|
}, 1);
|
|
1404
1412
|
}
|
|
1405
|
-
}), this.configuration.highlights.enabled && (
|
|
1413
|
+
}), this.configuration.highlights.enabled && (s.registerMaterialSelectedCallback((o) => {
|
|
1406
1414
|
this.setHighlights([o]);
|
|
1407
|
-
}),
|
|
1415
|
+
}), s.registerMaterialDeselectedCallback(() => {
|
|
1408
1416
|
this.setHighlights([]);
|
|
1409
|
-
})), this.modelContainers.set(
|
|
1417
|
+
})), this.modelContainers.set(s.getId(), s), this.triggerModelLoadEvent({
|
|
1410
1418
|
eventType: "load",
|
|
1411
|
-
modelContainer:
|
|
1412
|
-
}),
|
|
1419
|
+
modelContainer: s
|
|
1420
|
+
}), s;
|
|
1413
1421
|
}
|
|
1414
1422
|
async preloadModel(e) {
|
|
1415
|
-
await
|
|
1423
|
+
await N(e, this.scene);
|
|
1416
1424
|
}
|
|
1417
1425
|
getAllModels() {
|
|
1418
1426
|
return Array.from(this.modelContainers.values());
|
|
@@ -1435,7 +1443,7 @@ class Tt {
|
|
|
1435
1443
|
return this.glowLayerManager;
|
|
1436
1444
|
}
|
|
1437
1445
|
modelUnloaded(e) {
|
|
1438
|
-
this.modelContainers.delete(e.getId()), this.triggerModelLoadEvent({
|
|
1446
|
+
this.modelContainers.delete(e.getId()), this.reconcileFallbackLighting(this.configuration), this.triggerModelLoadEvent({
|
|
1439
1447
|
eventType: "unload",
|
|
1440
1448
|
modelContainer: e
|
|
1441
1449
|
});
|
|
@@ -1451,24 +1459,65 @@ class Tt {
|
|
|
1451
1459
|
O(i || { x: 1, y: 1, z: 1 }),
|
|
1452
1460
|
A.FromEulerVector(O(t || { x: 0, y: 0, z: 0 })),
|
|
1453
1461
|
O(e || { x: 0, y: 0, z: 0 })
|
|
1454
|
-
),
|
|
1455
|
-
return o.decompose(c, h,
|
|
1456
|
-
position:
|
|
1457
|
-
rotation:
|
|
1458
|
-
scale:
|
|
1462
|
+
), s = G.RotationAxis(g.Up(), Math.PI), o = a.multiply(s), r = g.Zero(), h = A.Identity(), c = g.Zero();
|
|
1463
|
+
return o.decompose(c, h, r), h.multiplyInPlace(A.FromEulerAngles(0, Math.PI, 0)), {
|
|
1464
|
+
position: F(r),
|
|
1465
|
+
rotation: F(h.toEulerAngles()),
|
|
1466
|
+
scale: F(c)
|
|
1459
1467
|
};
|
|
1460
1468
|
}
|
|
1461
1469
|
updatePreviewOptions(e) {
|
|
1462
1470
|
const t = new K(e);
|
|
1463
|
-
this.configuration.highlights.enabled !== t.highlights.enabled && this.engine.setStencilBuffer(t.highlights.enabled), this.scene.clearColor = t.scene.clearColor
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
this.
|
|
1468
|
-
|
|
1471
|
+
if (this.configuration.highlights.enabled !== t.highlights.enabled && this.engine.setStencilBuffer(t.highlights.enabled), this.scene.clearColor = t.scene.clearColor, this.configuration.scene.environment.file !== t.scene.environment.file)
|
|
1472
|
+
this.setEnvironmentTexture(t, "updated-environment-cube");
|
|
1473
|
+
else {
|
|
1474
|
+
const i = this.scene.environmentTexture;
|
|
1475
|
+
i && (i.rotationY = t.scene.environment.rotationY), this.reconcileFallbackLighting(t);
|
|
1476
|
+
}
|
|
1477
|
+
this.scene.environmentIntensity = t.scene.environment.intensity, t.options?.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(
|
|
1469
1478
|
t.options?.noPan !== void 0 ? !t.options.noPan : !0
|
|
1470
1479
|
), this.configuration = t;
|
|
1471
1480
|
}
|
|
1481
|
+
/**
|
|
1482
|
+
* Applies the environment file from the given configuration to the scene, replacing whatever
|
|
1483
|
+
* environment texture is currently set. When no file is configured, or when the configured file
|
|
1484
|
+
* fails to load, fallback lighting is applied instead so the product doesn't render black.
|
|
1485
|
+
* @param configuration The configuration holding the environment file to apply.
|
|
1486
|
+
* @param textureName The name to give the created cube texture.
|
|
1487
|
+
*/
|
|
1488
|
+
setEnvironmentTexture(e, t) {
|
|
1489
|
+
const i = e.scene.environment.file;
|
|
1490
|
+
if (!i) {
|
|
1491
|
+
this.scene.environmentTexture = null, this.environmentLightingAvailable = !1, this.reconcileFallbackLighting(e);
|
|
1492
|
+
return;
|
|
1493
|
+
}
|
|
1494
|
+
this.environmentLightingAvailable = !0;
|
|
1495
|
+
const a = this.scene.useDelayedTextureLoading;
|
|
1496
|
+
this.scene.useDelayedTextureLoading = !1;
|
|
1497
|
+
const s = new ie(i, this.scene, {
|
|
1498
|
+
prefiltered: !0,
|
|
1499
|
+
createPolynomials: !0,
|
|
1500
|
+
onError: () => {
|
|
1501
|
+
this.scene.environmentTexture === s && (this.environmentLightingAvailable = !1, this.reconcileFallbackLighting(this.configuration));
|
|
1502
|
+
}
|
|
1503
|
+
});
|
|
1504
|
+
this.scene.useDelayedTextureLoading = a, s.name = t, s.rotationY = e.scene.environment.rotationY, this.scene.environmentTexture = s, this.reconcileFallbackLighting(e);
|
|
1505
|
+
}
|
|
1506
|
+
/**
|
|
1507
|
+
* Adds, updates, or removes the fallback light so it is present exactly when the scene has no other
|
|
1508
|
+
* source of light: no working environment texture and no lights of its own (a GLB can bring its own
|
|
1509
|
+
* lighting via KHR_lights_punctual). Safe to call repeatedly.
|
|
1510
|
+
* @param configuration The configuration holding the fallback lighting settings to apply.
|
|
1511
|
+
*/
|
|
1512
|
+
reconcileFallbackLighting(e) {
|
|
1513
|
+
const t = e.fallbackLighting, i = this.scene.getLightByName(L), a = this.scene.lights.some((o) => o.name !== L);
|
|
1514
|
+
if (!t.enabled || this.environmentLightingAvailable || a) {
|
|
1515
|
+
i?.dispose();
|
|
1516
|
+
return;
|
|
1517
|
+
}
|
|
1518
|
+
const s = i ?? new te(L, new g(0, 1, 0), this.scene);
|
|
1519
|
+
s.intensity = t.intensity, s.diffuse = t.color, s.groundColor = t.groundColor;
|
|
1520
|
+
}
|
|
1472
1521
|
setHighlightMaterials(e) {
|
|
1473
1522
|
this.validHighlightMaterials = e;
|
|
1474
1523
|
}
|
|
@@ -1490,11 +1539,11 @@ class Tt {
|
|
|
1490
1539
|
}
|
|
1491
1540
|
}
|
|
1492
1541
|
export {
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1542
|
+
B as MaterialEffectMode,
|
|
1543
|
+
S as ProductCameraRig,
|
|
1544
|
+
ye as REFLECTION_PROBE_RESOLUTION,
|
|
1496
1545
|
x as RenderingConfiguration,
|
|
1497
|
-
|
|
1546
|
+
Ft as SpiffCommerce3DPreviewService,
|
|
1498
1547
|
d as renderingPipelineDefaults
|
|
1499
1548
|
};
|
|
1500
1549
|
//# sourceMappingURL=index.esm.js.map
|