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