@spiffcommerce/preview 5.11.7 → 5.11.8
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.esm.js +481 -753
- package/dist/index.umd.js +2 -1
- package/package.json +35 -55
- package/dist/index.d.mts +0 -1210
package/dist/index.esm.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import { ArcRotateCamera as
|
|
2
|
-
import { Engine as
|
|
3
|
-
import { NullEngine as
|
|
4
|
-
import { SceneLoader as
|
|
5
|
-
import { CubeTexture as
|
|
6
|
-
import { Color4 as
|
|
7
|
-
import { Vector3 as g, Quaternion as
|
|
8
|
-
import { DracoCompression as
|
|
9
|
-
import { Observable as
|
|
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
|
|
25
|
-
import { Animation as
|
|
26
|
-
import { QuadraticEase as
|
|
27
|
-
import { AssetsManager as
|
|
28
|
-
import { ColorCurves as
|
|
29
|
-
import { ImageProcessingConfiguration as
|
|
30
|
-
import { DefaultRenderingPipeline as
|
|
31
|
-
import { DepthOfFieldEffectBlurLevel as
|
|
1
|
+
import { ArcRotateCamera as j } from "@babylonjs/core/Cameras/arcRotateCamera";
|
|
2
|
+
import { Engine as I } from "@babylonjs/core/Engines/engine";
|
|
3
|
+
import { NullEngine as ee } from "@babylonjs/core/Engines/nullEngine";
|
|
4
|
+
import { SceneLoader as B } from "@babylonjs/core/Loading/sceneLoader";
|
|
5
|
+
import { CubeTexture as N } from "@babylonjs/core/Materials/Textures/cubeTexture";
|
|
6
|
+
import { Color4 as b, Color3 as v } from "@babylonjs/core/Maths/math.color";
|
|
7
|
+
import { Vector3 as g, Quaternion as A, Vector2 as z, Matrix as G } from "@babylonjs/core/Maths/math.vector";
|
|
8
|
+
import { DracoCompression as te } from "@babylonjs/core/Meshes/Compression/dracoCompression";
|
|
9
|
+
import { Observable as C } from "@babylonjs/core/Misc/observable";
|
|
10
|
+
import { Tools as ie } from "@babylonjs/core/Misc/tools";
|
|
11
|
+
import { Scene as ne } from "@babylonjs/core/scene";
|
|
12
|
+
import { GLTF2 as se } from "@babylonjs/loaders/glTF";
|
|
13
|
+
import { GLTFLoaderAnimationStartMode as re } from "@babylonjs/loaders/glTF/glTFFileLoader";
|
|
14
|
+
import { PBRMaterial as D } from "@babylonjs/core/Materials/PBR/pbrMaterial";
|
|
15
|
+
import { MirrorTexture as ae } from "@babylonjs/core/Materials/Textures/mirrorTexture";
|
|
16
|
+
import { Color3 as oe, Vector3 as V, Plane as le } from "@babylonjs/core/Maths/math";
|
|
17
|
+
import { ReflectionProbe as he } from "@babylonjs/core/Probes/reflectionProbe";
|
|
18
|
+
import { GlowLayer as ce } from "@babylonjs/core/Layers/glowLayer";
|
|
19
|
+
import { ActionManager as E } from "@babylonjs/core/Actions/actionManager";
|
|
20
|
+
import { ExecuteCodeAction as _ } from "@babylonjs/core/Actions/directActions";
|
|
21
|
+
import { Mesh as de } from "@babylonjs/core/Meshes/mesh";
|
|
22
|
+
import { TransformNode as ue } from "@babylonjs/core/Meshes/transformNode";
|
|
23
|
+
import { DynamicTexture as me } from "@babylonjs/core/Materials/Textures/dynamicTexture";
|
|
24
|
+
import { Texture as ge } from "@babylonjs/core/Materials/Textures/texture";
|
|
25
|
+
import { Animation as w } from "@babylonjs/core/Animations/animation";
|
|
26
|
+
import { QuadraticEase as pe, EasingFunction as fe } from "@babylonjs/core/Animations/easing";
|
|
27
|
+
import { AssetsManager as be } from "@babylonjs/core/Misc/assetsManager";
|
|
28
|
+
import { ColorCurves as H } from "@babylonjs/core/Materials/colorCurves";
|
|
29
|
+
import { ImageProcessingConfiguration as M } from "@babylonjs/core/Materials/imageProcessingConfiguration";
|
|
30
|
+
import { DefaultRenderingPipeline as ve } from "@babylonjs/core/PostProcesses/RenderPipeline";
|
|
31
|
+
import { DepthOfFieldEffectBlurLevel as R } from "@babylonjs/core/PostProcesses/depthOfFieldEffect";
|
|
32
32
|
import "@babylonjs/core/Rendering/depthRendererSceneComponent";
|
|
33
33
|
import "@babylonjs/core/Engines/Extensions/engine.views";
|
|
34
34
|
import "@babylonjs/core/Meshes/instancedMesh";
|
|
@@ -40,59 +40,40 @@ import "@babylonjs/core/Animations/animatable";
|
|
|
40
40
|
import "@babylonjs/core/Misc/screenshotTools";
|
|
41
41
|
import "@babylonjs/core/Rendering/boundingBoxRenderer";
|
|
42
42
|
import "@babylonjs/loaders/glTF/2.0/Extensions";
|
|
43
|
-
var
|
|
44
|
-
function
|
|
43
|
+
var F = /* @__PURE__ */ ((n) => (n[n.Orbit = 0] = "Orbit", n[n.Pan = 1] = "Pan", n))(F || {}), S = /* @__PURE__ */ ((n) => (n.None = "None", n.RemoveWhenSelected = "RemoveWhenSelected", n.ApplyWhenSelected = "ApplyWhenSelected", n))(S || {});
|
|
44
|
+
function we() {
|
|
45
45
|
const n = navigator.vendor.toLowerCase().includes("apple"), e = navigator.maxTouchPoints > 0, t = !navigator.userAgent.toLowerCase().includes("crios");
|
|
46
46
|
return n && e && t;
|
|
47
47
|
}
|
|
48
|
-
const
|
|
49
|
-
async function
|
|
50
|
-
const i = await
|
|
48
|
+
const U = /* @__PURE__ */ new Map();
|
|
49
|
+
async function q(n, e, t) {
|
|
50
|
+
const i = await U.get(n);
|
|
51
51
|
if (i && i.scene.uid === e.uid)
|
|
52
52
|
return i;
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
void 0,
|
|
56
|
-
e,
|
|
57
|
-
t
|
|
58
|
-
);
|
|
59
|
-
return !ze() && ce.set(n, r), r;
|
|
53
|
+
const a = B.LoadAssetContainerAsync(n, void 0, e, t);
|
|
54
|
+
return !we() && U.set(n, a), a;
|
|
60
55
|
}
|
|
61
|
-
|
|
62
|
-
n.name === "gltf" && (n.animationStartMode =
|
|
56
|
+
B.OnPluginActivatedObservable.add((n) => {
|
|
57
|
+
n.name === "gltf" && (n.animationStartMode = re.NONE);
|
|
63
58
|
});
|
|
64
|
-
class
|
|
59
|
+
class K {
|
|
65
60
|
constructor(e) {
|
|
66
61
|
this.getSceneClearColor = () => {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
return new v(0, 0, 0, t).toLinearSpace();
|
|
62
|
+
const t = this.customOptions?.transparentBackground || this.customOptions?.backgroundImage ? 0 : 1;
|
|
63
|
+
if (this.customOptions && this.customOptions?.transparentBackground || this.customOptions?.backgroundImage)
|
|
64
|
+
return new b(0, 0, 0, t).toLinearSpace();
|
|
71
65
|
if (this.customOptions && this.customOptions.backgroundColor) {
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
);
|
|
75
|
-
return new v(
|
|
76
|
-
a.r,
|
|
77
|
-
a.g,
|
|
78
|
-
a.b,
|
|
79
|
-
t
|
|
80
|
-
).toLinearSpace();
|
|
66
|
+
const i = v.FromHexString(this.customOptions.backgroundColor);
|
|
67
|
+
return new b(i.r, i.g, i.b, t).toLinearSpace();
|
|
81
68
|
}
|
|
82
|
-
return new
|
|
83
|
-
}, this.highlightColorFromConfig = () => this.customOptions && this.customOptions.highlightColor ? this.hexToColor4(this.customOptions.highlightColor) :
|
|
84
|
-
const
|
|
85
|
-
return new
|
|
86
|
-
r.r,
|
|
87
|
-
r.g,
|
|
88
|
-
r.b,
|
|
89
|
-
i
|
|
90
|
-
).toLinearSpace();
|
|
69
|
+
return new b(0.98, 0.98, 0.98, t).toLinearSpace();
|
|
70
|
+
}, this.highlightColorFromConfig = () => this.customOptions && this.customOptions.highlightColor ? this.hexToColor4(this.customOptions.highlightColor) : b.FromColor3(v.Gray()), this.hexToColor4 = (t, i = 1) => {
|
|
71
|
+
const a = v.FromHexString(t);
|
|
72
|
+
return new b(a.r, a.g, a.b, i).toLinearSpace();
|
|
91
73
|
}, this.customOptions = e;
|
|
92
74
|
}
|
|
93
75
|
createCanvas() {
|
|
94
|
-
|
|
95
|
-
return (e = this.customOptions) != null && e.createCanvas ? this.customOptions.createCanvas() : document.createElement("canvas");
|
|
76
|
+
return this.customOptions?.createCanvas ? this.customOptions.createCanvas() : document.createElement("canvas");
|
|
96
77
|
}
|
|
97
78
|
get options() {
|
|
98
79
|
return this.customOptions;
|
|
@@ -101,14 +82,13 @@ class de {
|
|
|
101
82
|
* Configuration related to the scene
|
|
102
83
|
*/
|
|
103
84
|
get scene() {
|
|
104
|
-
var e, t, i, r, s;
|
|
105
85
|
return {
|
|
106
86
|
clearColor: this.getSceneClearColor(),
|
|
107
|
-
transparentBackground:
|
|
87
|
+
transparentBackground: this.customOptions?.transparentBackground || this.customOptions?.backgroundImage,
|
|
108
88
|
environment: {
|
|
109
|
-
file:
|
|
110
|
-
intensity:
|
|
111
|
-
rotationY: (
|
|
89
|
+
file: this.customOptions?.environmentFile,
|
|
90
|
+
intensity: this.customOptions?.environmentIntensity ?? 1,
|
|
91
|
+
rotationY: (this.customOptions?.environmentRotationY ?? 0) * (Math.PI / 180)
|
|
112
92
|
// Convert to radians
|
|
113
93
|
}
|
|
114
94
|
};
|
|
@@ -117,23 +97,22 @@ class de {
|
|
|
117
97
|
* Configuration related to the camera used to view and interact with the scene.
|
|
118
98
|
*/
|
|
119
99
|
get camera() {
|
|
120
|
-
var e, t, i, r, s, o, a, l, c, h, d, m, f;
|
|
121
100
|
return {
|
|
122
|
-
autoOrientation:
|
|
101
|
+
autoOrientation: this.customOptions?.disableAutomaticOrientation ?? !0,
|
|
123
102
|
autoRotation: {
|
|
124
|
-
enabled:
|
|
125
|
-
idleTimeMs:
|
|
103
|
+
enabled: this.customOptions?.autoRotation ?? !1,
|
|
104
|
+
idleTimeMs: this.customOptions?.idleTimeBeforeRotation ?? 5e3
|
|
126
105
|
},
|
|
127
106
|
limits: {
|
|
128
107
|
min: {
|
|
129
|
-
alpha:
|
|
130
|
-
beta:
|
|
131
|
-
radius:
|
|
108
|
+
alpha: this.customOptions?.lowerAlphaLimitDeg ? this.customOptions?.lowerAlphaLimitDeg * Math.PI / 180 : void 0,
|
|
109
|
+
beta: this.customOptions?.lowerBetaLimitDeg ? this.customOptions?.lowerBetaLimitDeg * Math.PI / 180 : void 0,
|
|
110
|
+
radius: this.customOptions?.minZoomOverride
|
|
132
111
|
},
|
|
133
112
|
max: {
|
|
134
|
-
alpha:
|
|
135
|
-
beta:
|
|
136
|
-
radius:
|
|
113
|
+
alpha: this.customOptions?.upperAlphaLimitDeg ? this.customOptions?.upperAlphaLimitDeg * Math.PI / 180 : void 0,
|
|
114
|
+
beta: this.customOptions?.upperBetaLimitDeg ? this.customOptions?.upperBetaLimitDeg * Math.PI / 180 : void 0,
|
|
115
|
+
radius: this.customOptions?.maxZoomOverride
|
|
137
116
|
}
|
|
138
117
|
}
|
|
139
118
|
};
|
|
@@ -143,30 +122,27 @@ class de {
|
|
|
143
122
|
* a visual cue to the user that something is moused over in the preview.
|
|
144
123
|
*/
|
|
145
124
|
get highlights() {
|
|
146
|
-
var e;
|
|
147
125
|
return {
|
|
148
|
-
enabled:
|
|
126
|
+
enabled: this.customOptions?.highlightOnMaterialHover ?? !1,
|
|
149
127
|
color: this.highlightColorFromConfig()
|
|
150
128
|
};
|
|
151
129
|
}
|
|
152
130
|
get lighting() {
|
|
153
|
-
var e, t, i, r;
|
|
154
131
|
return {
|
|
155
|
-
exposure:
|
|
156
|
-
contrast:
|
|
132
|
+
exposure: this.customOptions?.lighting?.exposure ?? 0.9,
|
|
133
|
+
contrast: this.customOptions?.lighting?.contrast ?? 1.6
|
|
157
134
|
};
|
|
158
135
|
}
|
|
159
136
|
get emissiveGlowIntensity() {
|
|
160
|
-
|
|
161
|
-
return ((e = this.customOptions) == null ? void 0 : e.emissiveGlowIntensity) ?? 0.5;
|
|
137
|
+
return this.customOptions?.emissiveGlowIntensity ?? 0.5;
|
|
162
138
|
}
|
|
163
139
|
}
|
|
164
|
-
class
|
|
140
|
+
class x {
|
|
165
141
|
/**
|
|
166
142
|
* Returns the resolution expected for generated textures.
|
|
167
143
|
*/
|
|
168
144
|
static getDynamicTextureResolution(e = !1) {
|
|
169
|
-
return e ? { width: 1, height: 1 } : this.getIsMobile() || !
|
|
145
|
+
return e ? { width: 1, height: 1 } : this.getIsMobile() || !x.offscreenRenderingSupported() ? {
|
|
170
146
|
width: 1024,
|
|
171
147
|
height: 1024
|
|
172
148
|
} : {
|
|
@@ -194,15 +170,13 @@ class P {
|
|
|
194
170
|
}
|
|
195
171
|
static getIsMobile() {
|
|
196
172
|
try {
|
|
197
|
-
return typeof window > "u" || !window.navigator ? !1 : /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
|
|
198
|
-
window.navigator.userAgent
|
|
199
|
-
) || window.innerWidth / window.devicePixelRatio <= 480;
|
|
173
|
+
return typeof window > "u" || !window.navigator ? !1 : /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(window.navigator.userAgent) || window.innerWidth / window.devicePixelRatio <= 480;
|
|
200
174
|
} catch {
|
|
201
175
|
return !1;
|
|
202
176
|
}
|
|
203
177
|
}
|
|
204
178
|
}
|
|
205
|
-
const
|
|
179
|
+
const Ce = 128, d = {
|
|
206
180
|
antiAliasing: {
|
|
207
181
|
samples: 4,
|
|
208
182
|
fxaaEnabled: !1
|
|
@@ -259,7 +233,7 @@ const Ge = 128, u = {
|
|
|
259
233
|
weight: 1
|
|
260
234
|
}
|
|
261
235
|
};
|
|
262
|
-
class
|
|
236
|
+
class Ae {
|
|
263
237
|
constructor(e) {
|
|
264
238
|
this.name = "glbPostProcessor", this.enabled = !0, this.loader = e;
|
|
265
239
|
}
|
|
@@ -271,16 +245,12 @@ class Ve {
|
|
|
271
245
|
* write the properties into the object metadata for retrieval at runtime.
|
|
272
246
|
*/
|
|
273
247
|
loadNodeAsync(e, t, i) {
|
|
274
|
-
return this.loader.loadNodeAsync(
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
r.metadata[s] = o;
|
|
281
|
-
}), i(r);
|
|
282
|
-
}
|
|
283
|
-
);
|
|
248
|
+
return this.loader.loadNodeAsync(e, t, function(a) {
|
|
249
|
+
t.extras && Object.keys(t.extras).forEach((r) => {
|
|
250
|
+
const o = t.extras[r];
|
|
251
|
+
a.metadata[r] = o;
|
|
252
|
+
}), i(a);
|
|
253
|
+
});
|
|
284
254
|
}
|
|
285
255
|
/**
|
|
286
256
|
* Material properties can be set at load time as we don't depend
|
|
@@ -288,11 +258,7 @@ class Ve {
|
|
|
288
258
|
* The need for these properties may go over time as the relevant exporters/importers are updated.
|
|
289
259
|
*/
|
|
290
260
|
async loadMaterialPropertiesAsync(e, t, i) {
|
|
291
|
-
await this.loader.loadMaterialPropertiesAsync(
|
|
292
|
-
e,
|
|
293
|
-
t,
|
|
294
|
-
i
|
|
295
|
-
), this.enableMaterialExtrasIfRequired(t, i);
|
|
261
|
+
await this.loader.loadMaterialPropertiesAsync(e, t, i), this.enableMaterialExtrasIfRequired(t, i);
|
|
296
262
|
}
|
|
297
263
|
dispose() {
|
|
298
264
|
}
|
|
@@ -303,14 +269,14 @@ class Ve {
|
|
|
303
269
|
* @param babylonMaterial An instance of a material representation in babylon.
|
|
304
270
|
*/
|
|
305
271
|
enableMaterialExtrasIfRequired(e, t) {
|
|
306
|
-
if (!(!e.extras || !(t instanceof
|
|
272
|
+
if (!(!e.extras || !(t instanceof D))) {
|
|
307
273
|
if (e.extras.sheen) {
|
|
308
274
|
const i = t;
|
|
309
275
|
i.sheen.isEnabled = !0, i.sheen.intensity = e.extras.sheen;
|
|
310
276
|
}
|
|
311
277
|
if (e.extras.translucency) {
|
|
312
278
|
const i = t;
|
|
313
|
-
i.subSurface.isTranslucencyEnabled = !0, i.subSurface.translucencyIntensity = e.extras.translucency, e.extras.translucencyR && e.extras.translucencyG && e.extras.translucencyB && (i.subSurface.tintColor = new
|
|
279
|
+
i.subSurface.isTranslucencyEnabled = !0, i.subSurface.translucencyIntensity = e.extras.translucency, e.extras.translucencyR && e.extras.translucencyG && e.extras.translucencyB && (i.subSurface.tintColor = new oe(
|
|
314
280
|
e.extras.translucencyR,
|
|
315
281
|
e.extras.translucencyG,
|
|
316
282
|
e.extras.translucencyB
|
|
@@ -336,55 +302,48 @@ class Ve {
|
|
|
336
302
|
* @param scene The scene to parse.
|
|
337
303
|
*/
|
|
338
304
|
applyReflections(e) {
|
|
339
|
-
function t(
|
|
305
|
+
function t(r) {
|
|
340
306
|
const o = [];
|
|
341
|
-
return
|
|
342
|
-
|
|
343
|
-
}),
|
|
344
|
-
|
|
307
|
+
return r.transformNodes.forEach((s) => {
|
|
308
|
+
s.metadata && s.metadata.reflective && o.push(...s.getChildMeshes());
|
|
309
|
+
}), r.meshes.forEach((s) => {
|
|
310
|
+
s.metadata && s.metadata.reflective && !o.includes(s) && o.push(s);
|
|
345
311
|
}), o;
|
|
346
312
|
}
|
|
347
|
-
function i(
|
|
348
|
-
const
|
|
349
|
-
if (!
|
|
313
|
+
function i(r, o = 1) {
|
|
314
|
+
const s = r.material;
|
|
315
|
+
if (!s)
|
|
350
316
|
return;
|
|
351
|
-
const
|
|
317
|
+
const h = new ae(
|
|
352
318
|
"mirror",
|
|
353
|
-
|
|
319
|
+
x.getMirrorTextureResolution(),
|
|
354
320
|
e,
|
|
355
321
|
!0
|
|
356
322
|
);
|
|
357
|
-
|
|
358
|
-
const c =
|
|
323
|
+
h.renderList = t(e);
|
|
324
|
+
const c = r.getVerticesData("normal");
|
|
359
325
|
if (!c)
|
|
360
326
|
throw new Error(
|
|
361
|
-
"Mirror attribute specified on: " +
|
|
327
|
+
"Mirror attribute specified on: " + r.name + "But no normals exist to generate a mirror from!"
|
|
362
328
|
);
|
|
363
|
-
|
|
364
|
-
const
|
|
365
|
-
new
|
|
366
|
-
|
|
367
|
-
).normalize(),
|
|
368
|
-
|
|
369
|
-
d.scale(-1)
|
|
370
|
-
);
|
|
371
|
-
l.mirrorPlane = m, l.level = o, a.reflectionTexture = l;
|
|
329
|
+
r.computeWorldMatrix(!0);
|
|
330
|
+
const l = r.getWorldMatrix(), m = V.TransformNormal(
|
|
331
|
+
new V(c[0], c[1], c[2]),
|
|
332
|
+
l
|
|
333
|
+
).normalize(), u = le.FromPositionAndNormal(r.position, m.scale(-1));
|
|
334
|
+
h.mirrorPlane = u, h.level = o, s.reflectionTexture = h;
|
|
372
335
|
}
|
|
373
|
-
function r
|
|
374
|
-
const o =
|
|
375
|
-
|
|
376
|
-
Ge,
|
|
377
|
-
e
|
|
378
|
-
);
|
|
379
|
-
a.cubeTexture.name = "reflection-probe-cube-texture", a.attachToMesh(s), a.renderList && a.renderList.push(...t(e)), o.reflectionTexture = a.cubeTexture;
|
|
336
|
+
function a(r) {
|
|
337
|
+
const o = r.material, s = new he("probe-" + o.name, Ce, e);
|
|
338
|
+
s.cubeTexture.name = "reflection-probe-cube-texture", s.attachToMesh(r), s.renderList && s.renderList.push(...t(e)), o.reflectionTexture = s.cubeTexture;
|
|
380
339
|
}
|
|
381
|
-
e.meshes.forEach((
|
|
382
|
-
const o =
|
|
383
|
-
o && (o.mirrorTexture && i(
|
|
340
|
+
e.meshes.forEach((r) => {
|
|
341
|
+
const o = r.metadata;
|
|
342
|
+
o && (o.mirrorTexture && i(r, o.mirrorTexture), o.reflectionProbe && a(r));
|
|
384
343
|
});
|
|
385
344
|
}
|
|
386
345
|
}
|
|
387
|
-
class
|
|
346
|
+
class ye {
|
|
388
347
|
constructor(e, t) {
|
|
389
348
|
this.scene = e, this.intensity = t, this.meshCount = 0;
|
|
390
349
|
}
|
|
@@ -393,7 +352,7 @@ class _e {
|
|
|
393
352
|
}
|
|
394
353
|
includeMeshes(e) {
|
|
395
354
|
if (e) {
|
|
396
|
-
this.glowLayer || (this.glowLayer = new
|
|
355
|
+
this.glowLayer || (this.glowLayer = new ce("glow", this.scene), this.glowLayer.intensity = this.intensity);
|
|
397
356
|
for (const t of e)
|
|
398
357
|
this.glowLayer.hasMesh(t) || (this.glowLayer.addIncludedOnlyMesh(t), this.meshCount++);
|
|
399
358
|
}
|
|
@@ -406,44 +365,37 @@ class _e {
|
|
|
406
365
|
}
|
|
407
366
|
}
|
|
408
367
|
}
|
|
409
|
-
function
|
|
410
|
-
t.forEach((
|
|
411
|
-
const o =
|
|
412
|
-
|
|
368
|
+
function xe(n, e, t, i, a = "") {
|
|
369
|
+
t.forEach((r) => {
|
|
370
|
+
const o = r.getID(), s = r.getName(), h = r.getPanelSize && r.getPanelSize(), c = x.getDynamicTextureResolution(
|
|
371
|
+
h?.width === 1 || h?.height === 1
|
|
413
372
|
);
|
|
414
|
-
n.filter((
|
|
415
|
-
const
|
|
416
|
-
if (
|
|
417
|
-
|
|
373
|
+
n.filter((m) => m.name === a + s).forEach((m) => {
|
|
374
|
+
const u = i.get(o), p = !1;
|
|
375
|
+
if (u)
|
|
376
|
+
W(m, u), u.update(p);
|
|
418
377
|
else {
|
|
419
|
-
const
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
c.width,
|
|
423
|
-
c.height
|
|
424
|
-
);
|
|
425
|
-
i.set(o, p), s.setStaticContext(
|
|
426
|
-
p.getContext()
|
|
427
|
-
), ue(d, p), p.onLoadObservable.addOnce(() => {
|
|
428
|
-
p.update(f);
|
|
378
|
+
const f = Me(s, e, c.width, c.height);
|
|
379
|
+
i.set(o, f), r.setStaticContext(f.getContext()), W(m, f), f.onLoadObservable.addOnce(() => {
|
|
380
|
+
f.update(p);
|
|
429
381
|
});
|
|
430
382
|
}
|
|
431
383
|
});
|
|
432
384
|
});
|
|
433
385
|
}
|
|
434
|
-
function
|
|
435
|
-
const
|
|
386
|
+
function Me(n, e, t, i) {
|
|
387
|
+
const a = new me(
|
|
436
388
|
n,
|
|
437
389
|
{ width: t, height: i },
|
|
438
390
|
e,
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
),
|
|
443
|
-
return
|
|
391
|
+
x.shouldMipMap(),
|
|
392
|
+
ge.TRILINEAR_SAMPLINGMODE,
|
|
393
|
+
I.TEXTUREFORMAT_RGBA
|
|
394
|
+
), r = a.getContext();
|
|
395
|
+
return r && (r.fillStyle = "#f5f5f5", r.fillRect(0, 0, t, i), a.update()), a;
|
|
444
396
|
}
|
|
445
|
-
function
|
|
446
|
-
if (n instanceof
|
|
397
|
+
function W(n, e) {
|
|
398
|
+
if (n instanceof D) {
|
|
447
399
|
const t = n, i = t.albedoTexture;
|
|
448
400
|
i ? (e.wrapU = i.wrapU, e.wrapV = i.wrapV) : (e.wrapU = 1, e.wrapV = 1), t.albedoTexture = e;
|
|
449
401
|
} else {
|
|
@@ -451,136 +403,119 @@ function ue(n, e) {
|
|
|
451
403
|
i && (e.wrapU = i.wrapU, e.wrapV = i.wrapV), t.diffuseTexture = e;
|
|
452
404
|
}
|
|
453
405
|
}
|
|
454
|
-
function
|
|
406
|
+
function Pe() {
|
|
455
407
|
const n = () => Math.floor((1 + Math.random()) * 65536).toString(16).substring(1);
|
|
456
408
|
return n() + n() + "-" + n() + "-" + n() + "-" + n() + "-" + n() + n() + n();
|
|
457
409
|
}
|
|
458
|
-
const y = 60,
|
|
459
|
-
function
|
|
410
|
+
const y = 60, Q = 1;
|
|
411
|
+
function Y(n) {
|
|
460
412
|
return n.targetedAnimations.map((t) => t.animation.framePerSecond).reduce((t, i) => t + i, 0) / n.targetedAnimations.length || 0;
|
|
461
413
|
}
|
|
462
|
-
function
|
|
463
|
-
const o =
|
|
414
|
+
function X(n, e, t, i, a, r) {
|
|
415
|
+
const o = a ? n.filter((l) => l.name === a) : n;
|
|
464
416
|
if (o.length === 0) {
|
|
465
|
-
console.warn(`No animations found for name: ${
|
|
417
|
+
console.warn(`No animations found for name: ${a}`);
|
|
466
418
|
return;
|
|
467
419
|
}
|
|
468
|
-
let
|
|
469
|
-
const
|
|
470
|
-
|
|
471
|
-
}, c = (
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
}) :
|
|
475
|
-
|
|
420
|
+
let s = 0;
|
|
421
|
+
const h = () => {
|
|
422
|
+
s++, s === o.length && r && r();
|
|
423
|
+
}, c = (l, m, u, p, f) => {
|
|
424
|
+
l.stop(), l.start(m, u, p, f), r && (m == !1 || m === void 0 && !l.loopAnimation ? l.onAnimationGroupEndObservable.addOnce(() => {
|
|
425
|
+
h();
|
|
426
|
+
}) : l.onAnimationLoopObservable.addOnce(() => {
|
|
427
|
+
h();
|
|
476
428
|
}));
|
|
477
429
|
};
|
|
478
430
|
if (i !== void 0 && t !== void 0 && i === t) {
|
|
479
|
-
o.forEach((
|
|
480
|
-
const
|
|
481
|
-
c(
|
|
431
|
+
o.forEach((l) => {
|
|
432
|
+
const m = Y(l), u = i * m;
|
|
433
|
+
c(l, !1, Q, u, u);
|
|
482
434
|
});
|
|
483
435
|
return;
|
|
484
436
|
}
|
|
485
|
-
o.forEach((
|
|
486
|
-
const
|
|
487
|
-
c(
|
|
437
|
+
o.forEach((l) => {
|
|
438
|
+
const m = Y(l), u = i !== void 0 ? i * m : void 0, p = t !== void 0 ? t * m : void 0;
|
|
439
|
+
c(l, e, Q, u, p);
|
|
488
440
|
});
|
|
489
441
|
}
|
|
490
|
-
function
|
|
442
|
+
function Ee(n) {
|
|
491
443
|
n.forEach((e) => {
|
|
492
444
|
e.reset(), e.stop();
|
|
493
445
|
});
|
|
494
446
|
}
|
|
495
|
-
function
|
|
447
|
+
function Re(n) {
|
|
496
448
|
const e = n.animationGroups;
|
|
497
|
-
|
|
449
|
+
Ee(e);
|
|
498
450
|
}
|
|
499
|
-
function
|
|
451
|
+
function Te(n, e, t) {
|
|
500
452
|
return new Promise((i) => {
|
|
501
|
-
n.stopAnimation(e), e.animations = [], Math.abs(e.alpha) > 2 * Math.PI && (e.alpha =
|
|
502
|
-
const
|
|
503
|
-
if (t.target && Object.keys(t.target).length > 0 &&
|
|
504
|
-
|
|
453
|
+
n.stopAnimation(e), e.animations = [], Math.abs(e.alpha) > 2 * Math.PI && (e.alpha = Oe(e.alpha, 0, 2 * Math.PI));
|
|
454
|
+
const a = [], r = t.target;
|
|
455
|
+
if (t.target && Object.keys(t.target).length > 0 && a.push(
|
|
456
|
+
P(
|
|
505
457
|
"cameraTargetLerp",
|
|
506
458
|
"target",
|
|
507
459
|
new g().copyFrom(e.target),
|
|
508
|
-
new g(
|
|
509
|
-
|
|
510
|
-
t.target.y,
|
|
511
|
-
t.target.z
|
|
512
|
-
),
|
|
513
|
-
A.ANIMATIONTYPE_VECTOR3
|
|
460
|
+
new g(t.target.x, t.target.y, t.target.z),
|
|
461
|
+
w.ANIMATIONTYPE_VECTOR3
|
|
514
462
|
)
|
|
515
|
-
),
|
|
516
|
-
|
|
463
|
+
), a.push(
|
|
464
|
+
P(
|
|
517
465
|
"cameraAlphaLerp",
|
|
518
466
|
"alpha",
|
|
519
467
|
e.alpha,
|
|
520
|
-
|
|
521
|
-
|
|
468
|
+
Z(t.lonDeg),
|
|
469
|
+
w.ANIMATIONTYPE_FLOAT
|
|
522
470
|
)
|
|
523
|
-
),
|
|
524
|
-
|
|
471
|
+
), a.push(
|
|
472
|
+
P(
|
|
525
473
|
"cameraBetaLerp",
|
|
526
474
|
"beta",
|
|
527
475
|
e.beta,
|
|
528
|
-
|
|
529
|
-
|
|
476
|
+
Z(t.latDeg),
|
|
477
|
+
w.ANIMATIONTYPE_FLOAT
|
|
530
478
|
)
|
|
531
479
|
), t.radius !== void 0) {
|
|
532
|
-
const
|
|
533
|
-
|
|
534
|
-
|
|
480
|
+
const h = Math.max(0.01, t.radius);
|
|
481
|
+
a.push(
|
|
482
|
+
P(
|
|
535
483
|
"cameraRadiusLerp",
|
|
536
484
|
"radius",
|
|
537
485
|
e.radius,
|
|
538
|
-
|
|
539
|
-
|
|
486
|
+
h,
|
|
487
|
+
w.ANIMATIONTYPE_FLOAT
|
|
540
488
|
)
|
|
541
489
|
);
|
|
542
490
|
}
|
|
543
|
-
e.animations.push(...
|
|
544
|
-
const
|
|
545
|
-
e.disableAutoRotationBehavior(), n.beginAnimation(
|
|
546
|
-
e,
|
|
547
|
-
|
|
548
|
-
s ? y * 2 : y,
|
|
549
|
-
!1,
|
|
550
|
-
1,
|
|
551
|
-
() => {
|
|
552
|
-
e.animations = [], a && e.enableAutoRotationBehavior(), i();
|
|
553
|
-
}
|
|
554
|
-
);
|
|
491
|
+
e.animations.push(...a);
|
|
492
|
+
const s = e.useAutoRotationBehavior;
|
|
493
|
+
e.disableAutoRotationBehavior(), n.beginAnimation(e, 0, r ? y * 2 : y, !1, 1, () => {
|
|
494
|
+
e.animations = [], s && e.enableAutoRotationBehavior(), i();
|
|
495
|
+
});
|
|
555
496
|
});
|
|
556
497
|
}
|
|
557
|
-
function
|
|
498
|
+
function Z(n) {
|
|
558
499
|
return n * Math.PI / 180;
|
|
559
500
|
}
|
|
560
|
-
function
|
|
561
|
-
const
|
|
562
|
-
|
|
563
|
-
const
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
y,
|
|
567
|
-
r,
|
|
568
|
-
o
|
|
569
|
-
), c = [];
|
|
570
|
-
return s > 0 && c.push({ frame: 0, value: t }), c.push({ frame: y * s, value: t }), c.push({
|
|
571
|
-
frame: y * (s + 1),
|
|
501
|
+
function P(n, e, t, i, a, r = 0, o = w.ANIMATIONLOOPMODE_CONSTANT) {
|
|
502
|
+
const s = new pe();
|
|
503
|
+
s.setEasingMode(fe.EASINGMODE_EASEINOUT);
|
|
504
|
+
const h = new w(n, e, y, a, o), c = [];
|
|
505
|
+
return r > 0 && c.push({ frame: 0, value: t }), c.push({ frame: y * r, value: t }), c.push({
|
|
506
|
+
frame: y * (r + 1),
|
|
572
507
|
value: i
|
|
573
|
-
}),
|
|
508
|
+
}), h.setKeys(c), h.setEasingFunction(s), h;
|
|
574
509
|
}
|
|
575
|
-
function
|
|
510
|
+
function Oe(n, e, t) {
|
|
576
511
|
return n < e ? n = t - (e - n) % (t - e) : n = e + (n - e) % (t - e);
|
|
577
512
|
}
|
|
578
|
-
function
|
|
513
|
+
function Le(n, e, t) {
|
|
579
514
|
n.forEach((i) => {
|
|
580
515
|
t && i.name !== t || i.goToFrame(e);
|
|
581
516
|
});
|
|
582
517
|
}
|
|
583
|
-
const
|
|
518
|
+
const Ie = {
|
|
584
519
|
albedoTexture: "albedoMap",
|
|
585
520
|
bumpTexture: "normalMap",
|
|
586
521
|
ambientTexture: "ambientMap",
|
|
@@ -590,7 +525,7 @@ const je = {
|
|
|
590
525
|
refractionTexture: "refractionMap",
|
|
591
526
|
reflectionTexture: "reflectionMap"
|
|
592
527
|
};
|
|
593
|
-
function
|
|
528
|
+
function Fe(n, e, t, i) {
|
|
594
529
|
[
|
|
595
530
|
"albedoTexture",
|
|
596
531
|
"bumpTexture",
|
|
@@ -600,51 +535,37 @@ function Xe(n, e, t, i) {
|
|
|
600
535
|
"metallicTexture",
|
|
601
536
|
"refractionTexture",
|
|
602
537
|
"reflectionTexture"
|
|
603
|
-
].forEach((
|
|
604
|
-
|
|
605
|
-
|
|
538
|
+
].forEach((r) => {
|
|
539
|
+
Se(
|
|
540
|
+
r,
|
|
606
541
|
n,
|
|
607
542
|
e,
|
|
608
543
|
t,
|
|
609
544
|
i
|
|
610
545
|
);
|
|
611
|
-
}),
|
|
546
|
+
}), qe(n, e);
|
|
612
547
|
}
|
|
613
|
-
function
|
|
614
|
-
const
|
|
615
|
-
if (!
|
|
548
|
+
function Se(n, e, t, i, a) {
|
|
549
|
+
const r = Ie[n];
|
|
550
|
+
if (!r)
|
|
616
551
|
throw new Error("Unexpected texture name encountered.");
|
|
617
|
-
const
|
|
618
|
-
|
|
619
|
-
n,
|
|
620
|
-
a,
|
|
621
|
-
void 0,
|
|
622
|
-
!1,
|
|
623
|
-
void 0,
|
|
624
|
-
!0
|
|
625
|
-
) : a.endsWith(".hdr") ? i.addHDRCubeTextureTask(
|
|
626
|
-
n,
|
|
627
|
-
a,
|
|
628
|
-
128,
|
|
629
|
-
!1,
|
|
630
|
-
!0,
|
|
631
|
-
!1
|
|
632
|
-
) : i.addTextureTask(n, a, !1, !1) : i.addTextureTask(n, a, !1, !1) : r && t[n] && (t[n] && t[n].dispose(), t[n] = null, et(n, t));
|
|
552
|
+
const s = e[r]?.fileLink;
|
|
553
|
+
s ? n === "reflectionTexture" ? s.endsWith(".env") || s.endsWith(".dds") ? i.addCubeTextureTask(n, s, void 0, !1, void 0, !0) : s.endsWith(".hdr") ? i.addHDRCubeTextureTask(n, s, 128, !1, !0, !1) : i.addTextureTask(n, s, !1, !1) : i.addTextureTask(n, s, !1, !1) : a && t[n] && (t[n] && t[n].dispose(), t[n] = null, Be(n, t));
|
|
633
554
|
}
|
|
634
|
-
function
|
|
635
|
-
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
|
|
555
|
+
function Be(n, e) {
|
|
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 v(0, 0, 0), e.reflectionTexture);
|
|
636
557
|
}
|
|
637
|
-
function
|
|
558
|
+
function De(n, e, t, i) {
|
|
638
559
|
if (!e) {
|
|
639
560
|
console.error("Failed to apply texture to material: material is null.");
|
|
640
561
|
return;
|
|
641
562
|
}
|
|
642
|
-
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
|
|
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 v(1, 1, 1), e.emissiveIntensity = 1);
|
|
643
564
|
}
|
|
644
|
-
function
|
|
645
|
-
n.clearCoat && (n.clearCoat ===
|
|
565
|
+
function qe(n, e) {
|
|
566
|
+
n.clearCoat && (n.clearCoat === S.RemoveWhenSelected ? (e.clearCoat.isEnabled = !1, e.clearCoat.indexOfRefraction = 1.5) : n.clearCoat === S.ApplyWhenSelected && (e.clearCoat.isEnabled = !0, e.clearCoat.indexOfRefraction = n.clearCoatIOR || e.clearCoat.indexOfRefraction));
|
|
646
567
|
}
|
|
647
|
-
class
|
|
568
|
+
class ke {
|
|
648
569
|
constructor(e, t, i) {
|
|
649
570
|
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;
|
|
650
571
|
}
|
|
@@ -657,44 +578,34 @@ class nt {
|
|
|
657
578
|
* instead remove material textures when they aren't defined. this is useful for material editor applications
|
|
658
579
|
* where we want to undo changes are remove effects from display.
|
|
659
580
|
*/
|
|
660
|
-
async applyMaterial(e, t, i,
|
|
661
|
-
return new Promise((
|
|
581
|
+
async applyMaterial(e, t, i, a) {
|
|
582
|
+
return new Promise((r) => {
|
|
662
583
|
const o = this.materialVariantMap.get(e);
|
|
663
584
|
this.materialVariantMap.set(e, {
|
|
664
585
|
...o,
|
|
665
586
|
...t
|
|
666
587
|
});
|
|
667
|
-
const
|
|
668
|
-
(
|
|
588
|
+
const s = this.renameClonedAsset(e), h = this.scene.materials.filter(
|
|
589
|
+
(l) => l.name === s
|
|
669
590
|
);
|
|
670
|
-
if (
|
|
671
|
-
|
|
591
|
+
if (h.length === 0) {
|
|
592
|
+
r();
|
|
672
593
|
return;
|
|
673
594
|
}
|
|
674
|
-
const c = new
|
|
675
|
-
c.useDefaultLoadingScreen = !1,
|
|
676
|
-
(
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
const m = d;
|
|
687
|
-
i && i(100, 100, d.name), this.scene.materials.filter(
|
|
688
|
-
(p) => p.name === a
|
|
689
|
-
).forEach((p) => {
|
|
690
|
-
tt(
|
|
691
|
-
d.name,
|
|
692
|
-
p,
|
|
693
|
-
t,
|
|
694
|
-
m.texture
|
|
695
|
-
);
|
|
595
|
+
const c = new be(this.scene);
|
|
596
|
+
c.useDefaultLoadingScreen = !1, h.forEach(
|
|
597
|
+
(l) => Fe(t, l, c, a)
|
|
598
|
+
), c.onProgress = (l, m, u) => {
|
|
599
|
+
i && i(l / m * 100, 100, u.name);
|
|
600
|
+
}, c.onFinish = (l) => {
|
|
601
|
+
l.forEach((m) => {
|
|
602
|
+
const u = m;
|
|
603
|
+
i && i(100, 100, m.name), this.scene.materials.filter(
|
|
604
|
+
(f) => f.name === s
|
|
605
|
+
).forEach((f) => {
|
|
606
|
+
De(m.name, f, t, u.texture);
|
|
696
607
|
});
|
|
697
|
-
}),
|
|
608
|
+
}), r();
|
|
698
609
|
}, c.loadAsync();
|
|
699
610
|
});
|
|
700
611
|
}
|
|
@@ -708,45 +619,30 @@ class nt {
|
|
|
708
619
|
* @param getCurrentFrame A function that returns the current frame of the animation.
|
|
709
620
|
* @param getAnimationIsPlaying A function that returns whether the animation is currently playing.
|
|
710
621
|
*/
|
|
711
|
-
async applyModel(e, t, i,
|
|
712
|
-
var m, f, p;
|
|
622
|
+
async applyModel(e, t, i, a, r, o, s) {
|
|
713
623
|
if (i && t && !this.keysThatRemovedBaseModel.includes(e) && this.keysThatRemovedBaseModel.push(e), !i)
|
|
714
|
-
return this.keysThatRemovedBaseModel.includes(e) && this.keysThatRemovedBaseModel.length === 1 && await this.setBaseModelEnabled(!0),
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
const
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
this.loadedContainerForKey.has(e) && (this.loadedContainerForKey.get(e).dispose(), this.loadedContainerForKey.delete(e), (p = this.loadedMaterialsForKey.get(e)) == null || p.forEach((b) => b.dispose()), this.loadedMaterialsForKey.delete(e));
|
|
722
|
-
const h = s && s();
|
|
723
|
-
if (h) {
|
|
724
|
-
const b = o && o(), w = h.name ? this.renameClonedAsset(h.name) : void 0;
|
|
725
|
-
if (ve(
|
|
624
|
+
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 q(i, this.scene, a)).instantiateModelsToScene(this.renameClonedAsset, !0);
|
|
626
|
+
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 = r && r();
|
|
628
|
+
if (l) {
|
|
629
|
+
const u = o && o(), p = l.name ? this.renameClonedAsset(l.name) : void 0;
|
|
630
|
+
X(
|
|
726
631
|
c.animationGroups,
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
),
|
|
732
|
-
const R = a && a() || !0;
|
|
733
|
-
$e(
|
|
734
|
-
c.animationGroups,
|
|
735
|
-
b + (R ? 2 : 0),
|
|
736
|
-
w
|
|
737
|
-
);
|
|
738
|
-
}
|
|
632
|
+
l.loop,
|
|
633
|
+
l.to,
|
|
634
|
+
l.from,
|
|
635
|
+
p
|
|
636
|
+
), u != null && (s && s(), Le(c.animationGroups, u + 2, p));
|
|
739
637
|
}
|
|
740
|
-
t && await this.setBaseModelEnabled(!1), this.loadedContainerForKey.set(e, c), this.loadedMaterialsForKey.set(e,
|
|
741
|
-
const
|
|
742
|
-
return this.materialVariantMap.forEach(async (
|
|
743
|
-
|
|
744
|
-
}), await Promise.all(
|
|
638
|
+
t && await this.setBaseModelEnabled(!1), this.loadedContainerForKey.set(e, c), this.loadedMaterialsForKey.set(e, J(c));
|
|
639
|
+
const m = [];
|
|
640
|
+
return this.materialVariantMap.forEach(async (u, p) => {
|
|
641
|
+
m.push(this.applyMaterial(p, u));
|
|
642
|
+
}), await Promise.all(m), c;
|
|
745
643
|
}
|
|
746
644
|
dispose() {
|
|
747
|
-
this.loadedContainerForKey.forEach((e) => e
|
|
748
|
-
(e) => e.forEach((t) => t == null ? void 0 : t.dispose())
|
|
749
|
-
), this.loadedMaterialsForKey.clear(), this.materialVariantMap.clear(), this.keysThatRemovedBaseModel = [];
|
|
645
|
+
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 = [];
|
|
750
646
|
}
|
|
751
647
|
getAllMaterials() {
|
|
752
648
|
const e = [];
|
|
@@ -763,18 +659,18 @@ class nt {
|
|
|
763
659
|
}), e;
|
|
764
660
|
}
|
|
765
661
|
}
|
|
766
|
-
function
|
|
662
|
+
function J(n) {
|
|
767
663
|
const e = [];
|
|
768
664
|
return n.rootNodes.forEach((t) => {
|
|
769
665
|
t.getChildMeshes().forEach((i) => {
|
|
770
|
-
i.material && !e.includes(i.material) && e.push(i.material), i.subMeshes && i.subMeshes.forEach((
|
|
771
|
-
const
|
|
772
|
-
|
|
666
|
+
i.material && !e.includes(i.material) && e.push(i.material), i.subMeshes && i.subMeshes.forEach((a) => {
|
|
667
|
+
const r = a.getMaterial(!1);
|
|
668
|
+
r && !e.includes(r) && e.push(r);
|
|
773
669
|
});
|
|
774
670
|
});
|
|
775
671
|
}), e;
|
|
776
672
|
}
|
|
777
|
-
function
|
|
673
|
+
function $(n, e = "") {
|
|
778
674
|
return n.map((t) => ({
|
|
779
675
|
name: t.name.substring(e.length),
|
|
780
676
|
loop: t.loopAnimation,
|
|
@@ -782,198 +678,138 @@ function fe(n, e = "") {
|
|
|
782
678
|
from: t.from
|
|
783
679
|
}));
|
|
784
680
|
}
|
|
785
|
-
class
|
|
681
|
+
class Ne {
|
|
786
682
|
constructor(e) {
|
|
787
|
-
this.metadata = /* @__PURE__ */ new Map(), this.materialSelectedObservable = new
|
|
788
|
-
const {
|
|
789
|
-
|
|
790
|
-
modelDetails: i,
|
|
791
|
-
previewService: r,
|
|
792
|
-
progressHandler: s,
|
|
793
|
-
scene: o
|
|
794
|
-
} = e;
|
|
795
|
-
this.enablePicking = t, this.contextService = i.contextService, this.id = Ke(), this.previewService = r, this.scene = o, this.variantManager = new nt(
|
|
683
|
+
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: r, scene: o } = e;
|
|
685
|
+
this.enablePicking = t, this.contextService = i.contextService, this.id = Pe(), this.previewService = a, this.scene = o, this.variantManager = new ke(
|
|
796
686
|
o,
|
|
797
687
|
this.renameClonedAsset.bind(this),
|
|
798
688
|
this.setBaseModelEnabled.bind(this)
|
|
799
|
-
), this.transformRoot = new
|
|
800
|
-
const
|
|
689
|
+
), this.transformRoot = new ue("root", this.scene);
|
|
690
|
+
const s = async () => {
|
|
801
691
|
if (!i.model)
|
|
802
|
-
throw new Error(
|
|
803
|
-
|
|
804
|
-
);
|
|
805
|
-
return this.assetContainer = await z(
|
|
806
|
-
i.model,
|
|
807
|
-
o,
|
|
808
|
-
s
|
|
809
|
-
), await this.instantiate(), this;
|
|
692
|
+
throw new Error("Model container constructed with no URL. This is currently unsupported.");
|
|
693
|
+
return this.assetContainer = await q(i.model, o, r), await this.instantiate(), this;
|
|
810
694
|
};
|
|
811
|
-
this.importPromise =
|
|
695
|
+
this.importPromise = s();
|
|
812
696
|
}
|
|
813
697
|
//#region Interface implementation
|
|
814
|
-
async applyMaterialVariant(e, t, i,
|
|
698
|
+
async applyMaterialVariant(e, t, i, a) {
|
|
815
699
|
if (!this.initialized) {
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
t,
|
|
824
|
-
i,
|
|
825
|
-
r
|
|
826
|
-
)
|
|
827
|
-
);
|
|
828
|
-
} else {
|
|
829
|
-
this.materialReadyToLoadCallbacks.set(
|
|
830
|
-
e,
|
|
831
|
-
/* @__PURE__ */ new Map()
|
|
832
|
-
);
|
|
833
|
-
const o = this.materialReadyToLoadCallbacks.get(e);
|
|
834
|
-
o == null || o.set(
|
|
835
|
-
t,
|
|
836
|
-
this.applyMaterialVariant.bind(
|
|
837
|
-
this,
|
|
838
|
-
e,
|
|
839
|
-
t,
|
|
840
|
-
i,
|
|
841
|
-
r
|
|
842
|
-
)
|
|
843
|
-
);
|
|
844
|
-
}
|
|
700
|
+
this.materialReadyToLoadCallbacks.has(e) ? this.materialReadyToLoadCallbacks.get(e)?.set(
|
|
701
|
+
t,
|
|
702
|
+
this.applyMaterialVariant.bind(this, e, t, i, a)
|
|
703
|
+
) : (this.materialReadyToLoadCallbacks.set(e, /* @__PURE__ */ new Map()), this.materialReadyToLoadCallbacks.get(e)?.set(
|
|
704
|
+
t,
|
|
705
|
+
this.applyMaterialVariant.bind(this, e, t, i, a)
|
|
706
|
+
));
|
|
845
707
|
return;
|
|
846
708
|
}
|
|
847
|
-
const
|
|
709
|
+
const r = async () => {
|
|
848
710
|
await this.variantManager.applyMaterial(
|
|
849
711
|
e,
|
|
850
712
|
i,
|
|
851
|
-
(o,
|
|
713
|
+
(o, s, h) => {
|
|
852
714
|
this.materialVariantObservable.notifyObservers({
|
|
853
715
|
remainingCount: o,
|
|
854
|
-
totalCount:
|
|
855
|
-
taskName:
|
|
716
|
+
totalCount: s,
|
|
717
|
+
taskName: h
|
|
856
718
|
});
|
|
857
719
|
},
|
|
858
|
-
|
|
720
|
+
a
|
|
859
721
|
);
|
|
860
722
|
};
|
|
861
723
|
if (this.materialChangesInProgress.includes(e)) {
|
|
862
|
-
|
|
863
|
-
const o = this.queuedMaterialChanges.get(e);
|
|
864
|
-
o == null || o.set(t, s);
|
|
865
|
-
} else {
|
|
866
|
-
this.queuedMaterialChanges.set(
|
|
867
|
-
e,
|
|
868
|
-
/* @__PURE__ */ new Map()
|
|
869
|
-
);
|
|
870
|
-
const o = this.queuedMaterialChanges.get(e);
|
|
871
|
-
o == null || o.set(t, s);
|
|
872
|
-
}
|
|
724
|
+
this.queuedMaterialChanges.has(e) ? this.queuedMaterialChanges.get(e)?.set(t, r) : (this.queuedMaterialChanges.set(e, /* @__PURE__ */ new Map()), this.queuedMaterialChanges.get(e)?.set(t, r));
|
|
873
725
|
return;
|
|
874
726
|
}
|
|
875
|
-
if (this.materialChangesInProgress.push(e), await
|
|
727
|
+
if (this.materialChangesInProgress.push(e), await r(), this.queuedMaterialChanges.has(e)) {
|
|
876
728
|
const o = this.queuedMaterialChanges.get(e);
|
|
877
|
-
if (!o)
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
await a();
|
|
729
|
+
if (!o) throw new Error("Target material is undefined");
|
|
730
|
+
o.forEach(async (s) => {
|
|
731
|
+
await s();
|
|
881
732
|
}), this.queuedMaterialChanges.delete(e);
|
|
882
733
|
}
|
|
883
|
-
this.materialChangesInProgress.splice(
|
|
884
|
-
this.materialChangesInProgress.indexOf(e),
|
|
885
|
-
1
|
|
886
|
-
), this.configureGlowLayer(), this.scene.cleanCachedTextureBuffer();
|
|
734
|
+
this.materialChangesInProgress.splice(this.materialChangesInProgress.indexOf(e), 1), this.configureGlowLayer(), this.scene.cleanCachedTextureBuffer();
|
|
887
735
|
}
|
|
888
736
|
async applyModelVariant(e, t, i) {
|
|
889
|
-
const
|
|
737
|
+
const a = () => this.variantManager.applyModel(
|
|
890
738
|
e,
|
|
891
739
|
i,
|
|
892
|
-
t
|
|
893
|
-
(
|
|
740
|
+
t?.model,
|
|
741
|
+
(s) => {
|
|
894
742
|
this.modelVariantObservable.notifyObservers({
|
|
895
|
-
...
|
|
743
|
+
...s,
|
|
896
744
|
key: e
|
|
897
745
|
});
|
|
898
746
|
},
|
|
899
747
|
this.getLastRequestedAnimation.bind(this),
|
|
900
748
|
this.getCurrentAnimationFrame.bind(this),
|
|
901
749
|
this.getAnimationIsPlaying.bind(this)
|
|
902
|
-
),
|
|
750
|
+
), r = async () => {
|
|
903
751
|
this.modelChangesInProgress.push(e);
|
|
904
|
-
let
|
|
752
|
+
let s = await a();
|
|
905
753
|
if (this.queuedModelChanges.has(e)) {
|
|
906
|
-
const
|
|
907
|
-
if (!
|
|
908
|
-
|
|
909
|
-
a = await l(), this.queuedModelChanges.delete(e);
|
|
754
|
+
const h = this.queuedModelChanges.get(e);
|
|
755
|
+
if (!h) throw new Error("Queued change resolved undefined");
|
|
756
|
+
s = await h(), this.queuedModelChanges.delete(e);
|
|
910
757
|
}
|
|
911
|
-
return this.modelChangesInProgress.splice(
|
|
912
|
-
this.modelChangesInProgress.indexOf(e),
|
|
913
|
-
1
|
|
914
|
-
), a;
|
|
758
|
+
return this.modelChangesInProgress.splice(this.modelChangesInProgress.indexOf(e), 1), s;
|
|
915
759
|
};
|
|
916
760
|
if (!this.initialized || this.modelChangesInProgress.includes(e)) {
|
|
917
|
-
const
|
|
918
|
-
const
|
|
919
|
-
return
|
|
761
|
+
const s = async () => {
|
|
762
|
+
const h = await a();
|
|
763
|
+
return h ? this.configureModelInstance(h) : this.configureGlowLayer(), h;
|
|
920
764
|
};
|
|
921
|
-
this.queuedModelChanges.set(e,
|
|
765
|
+
this.queuedModelChanges.set(e, s);
|
|
922
766
|
return;
|
|
923
767
|
}
|
|
924
|
-
const o = await
|
|
925
|
-
this.contextService || (this.contextService = t
|
|
768
|
+
const o = await r();
|
|
769
|
+
this.contextService || (this.contextService = t?.contextService), o ? this.configureModelInstance(o) : this.configureGlowLayer();
|
|
926
770
|
}
|
|
927
771
|
dispose() {
|
|
928
|
-
|
|
929
|
-
this.destroyInstance(), this.variantManager.dispose(), this.dynamicTextures.forEach((t) => t == null ? void 0 : t.dispose()), this.dynamicTextures.clear(), this.materials.forEach((t) => t && (t == null ? void 0 : t.dispose())), this.materials = [], (e = this.transformRoot) == null || e.dispose(), this.transformRoot = void 0, this.previewService.modelUnloaded(this);
|
|
772
|
+
this.destroyInstance(), this.variantManager.dispose(), this.dynamicTextures.forEach((e) => e?.dispose()), this.dynamicTextures.clear(), this.materials.forEach((e) => e && e?.dispose()), this.materials = [], this.transformRoot?.dispose(), this.transformRoot = void 0, this.previewService.modelUnloaded(this);
|
|
930
773
|
}
|
|
931
774
|
executeAnimation(e, t) {
|
|
932
775
|
if (this.lastRequestedAnimation = e, !this.initialized)
|
|
933
776
|
return this.queuedModelAnimation = e, Promise.resolve();
|
|
934
777
|
let i = () => {
|
|
935
778
|
};
|
|
936
|
-
const
|
|
937
|
-
this.isExecutingAnimation = !0, await new Promise((
|
|
938
|
-
var a;
|
|
779
|
+
const a = async () => {
|
|
780
|
+
this.isExecutingAnimation = !0, await new Promise((r) => {
|
|
939
781
|
const o = [
|
|
940
|
-
...
|
|
782
|
+
...this.modelInstance?.animationGroups || [],
|
|
941
783
|
...this.variantManager.getAnimationGroups()
|
|
942
784
|
];
|
|
943
|
-
|
|
785
|
+
X(
|
|
944
786
|
o,
|
|
945
787
|
e.loop,
|
|
946
788
|
e.to,
|
|
947
789
|
e.from,
|
|
948
790
|
e.name ? this.renameClonedAsset(e.name) : void 0,
|
|
949
|
-
|
|
791
|
+
r
|
|
950
792
|
);
|
|
951
793
|
}), this.isExecutingAnimation = !1, this.queuedAnimationFunction && this.queuedAnimationFunction(), this.queuedAnimationFunction = void 0, i();
|
|
952
794
|
};
|
|
953
|
-
return t ? (
|
|
954
|
-
i =
|
|
955
|
-
})) :
|
|
795
|
+
return t ? (Re(this.scene), a()) : this.isExecutingAnimation ? (this.queuedAnimationFunction = a, new Promise((r) => {
|
|
796
|
+
i = r;
|
|
797
|
+
})) : a();
|
|
956
798
|
}
|
|
957
799
|
getAnimations(e) {
|
|
958
800
|
return [
|
|
959
801
|
...this.animations,
|
|
960
|
-
...e ?
|
|
961
|
-
|
|
962
|
-
this.renameClonedAsset("")
|
|
963
|
-
) : []
|
|
964
|
-
].map((t, i) => ({ ...t, name: t.name || `UNNAMED_ANIMATION_${i}` })).filter((t, i, r) => r.indexOf(r.find((s) => s.name === t.name)) == i);
|
|
802
|
+
...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((r) => r.name === t.name)) == i);
|
|
965
804
|
}
|
|
966
805
|
getId() {
|
|
967
806
|
return this.id;
|
|
968
807
|
}
|
|
969
808
|
listMaterials() {
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
return e ? e.map((i) => ({
|
|
975
|
-
id: i.id,
|
|
976
|
-
name: this.stripIdFromName(i.name)
|
|
809
|
+
const e = this.scene?.materials.filter((t) => t.name.startsWith(this.id));
|
|
810
|
+
return e ? e.map((t) => ({
|
|
811
|
+
id: t.id,
|
|
812
|
+
name: this.stripIdFromName(t.name)
|
|
977
813
|
})) : [];
|
|
978
814
|
}
|
|
979
815
|
registerMaterialSelectedCallback(e) {
|
|
@@ -989,38 +825,28 @@ class st {
|
|
|
989
825
|
this.materialDeselectedObservable.removeCallback(e);
|
|
990
826
|
}
|
|
991
827
|
get position() {
|
|
992
|
-
if (!this.transformRoot)
|
|
993
|
-
throw new Error("ModelContainer disposed prior to requesting position!");
|
|
828
|
+
if (!this.transformRoot) throw new Error("ModelContainer disposed prior to requesting position!");
|
|
994
829
|
return this.transformRoot.position;
|
|
995
830
|
}
|
|
996
831
|
set position(e) {
|
|
997
|
-
if (!this.transformRoot)
|
|
998
|
-
throw new Error("ModelContainer disposed prior to setting position!");
|
|
832
|
+
if (!this.transformRoot) throw new Error("ModelContainer disposed prior to setting position!");
|
|
999
833
|
this.transformRoot.position = new g(e.x, e.y, e.z);
|
|
1000
834
|
}
|
|
1001
835
|
get rotation() {
|
|
1002
|
-
|
|
1003
|
-
if (!((e = this.transformRoot) != null && e.rotationQuaternion))
|
|
836
|
+
if (!this.transformRoot?.rotationQuaternion)
|
|
1004
837
|
throw new Error("ModelContainer disposed prior to requesting rotation!");
|
|
1005
838
|
return this.transformRoot.rotationQuaternion.toEulerAngles();
|
|
1006
839
|
}
|
|
1007
840
|
set rotation(e) {
|
|
1008
|
-
if (!this.transformRoot)
|
|
1009
|
-
|
|
1010
|
-
this.transformRoot.rotationQuaternion = x.FromEulerAngles(
|
|
1011
|
-
e.x,
|
|
1012
|
-
e.y,
|
|
1013
|
-
e.z
|
|
1014
|
-
);
|
|
841
|
+
if (!this.transformRoot) throw new Error("ModelContainer disposed prior to setting rotation!");
|
|
842
|
+
this.transformRoot.rotationQuaternion = A.FromEulerAngles(e.x, e.y, e.z);
|
|
1015
843
|
}
|
|
1016
844
|
get scale() {
|
|
1017
|
-
if (!this.transformRoot)
|
|
1018
|
-
throw new Error("ModelContainer disposed prior to requesting scale!");
|
|
845
|
+
if (!this.transformRoot) throw new Error("ModelContainer disposed prior to requesting scale!");
|
|
1019
846
|
return this.transformRoot.scaling;
|
|
1020
847
|
}
|
|
1021
848
|
set scale(e) {
|
|
1022
|
-
if (!this.transformRoot)
|
|
1023
|
-
throw new Error("ModelContainer disposed prior to setting scale!");
|
|
849
|
+
if (!this.transformRoot) throw new Error("ModelContainer disposed prior to setting scale!");
|
|
1024
850
|
this.transformRoot.scaling = new g(e.x, e.y, e.z);
|
|
1025
851
|
}
|
|
1026
852
|
//#endregion
|
|
@@ -1028,15 +854,15 @@ class st {
|
|
|
1028
854
|
attachPickingHandler(e) {
|
|
1029
855
|
e.rootNodes.forEach((t) => {
|
|
1030
856
|
t.getChildMeshes(!1).forEach((i) => {
|
|
1031
|
-
i.name === "targetcube_t" || i.name === "backgroundShell" || (i.actionManager || (i.actionManager = new
|
|
1032
|
-
new
|
|
1033
|
-
|
|
857
|
+
i.name === "targetcube_t" || i.name === "backgroundShell" || (i.actionManager || (i.actionManager = new E(this.scene)), i.actionManager.registerAction(
|
|
858
|
+
new _(E.OnPointerOverTrigger, (a) => {
|
|
859
|
+
a.meshUnderPointer && i.material && this.materialSelectedObservable.notifyObservers({
|
|
1034
860
|
id: i.material.id,
|
|
1035
861
|
name: this.stripIdFromName(i.material.name)
|
|
1036
862
|
});
|
|
1037
863
|
})
|
|
1038
864
|
), i.actionManager.registerAction(
|
|
1039
|
-
new
|
|
865
|
+
new _(E.OnPointerOutTrigger, () => {
|
|
1040
866
|
i.material && this.materialDeselectedObservable.notifyObservers({
|
|
1041
867
|
id: i.material.id,
|
|
1042
868
|
name: this.stripIdFromName(i.material.name)
|
|
@@ -1065,23 +891,20 @@ class st {
|
|
|
1065
891
|
return this.queuedModelChanges.size;
|
|
1066
892
|
}
|
|
1067
893
|
configureGlowLayer() {
|
|
1068
|
-
const e = (i) => i instanceof
|
|
894
|
+
const e = (i) => i instanceof D && i.emissiveTexture !== null;
|
|
1069
895
|
this.materials.some(e) || this.variantManager.getAllMaterials().some(e) ? this.previewService.getGlowLayerManager().includeMeshes(this.getAllMeshes()) : this.previewService.getGlowLayerManager().removeMeshes(this.getAllMeshes());
|
|
1070
896
|
}
|
|
1071
897
|
configureModelInstance(e) {
|
|
1072
|
-
var s;
|
|
1073
898
|
if (!this.transformRoot)
|
|
1074
|
-
throw new Error(
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
const
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
for (const a of o.getChildMeshes(!1))
|
|
1082
|
-
a.alwaysSelectAsActiveMesh = !0;
|
|
899
|
+
throw new Error("Transform disposed! This should never happen unless there is a race condition present!");
|
|
900
|
+
const t = this.transformRoot.position, i = this.transformRoot.rotationQuaternion, a = this.transformRoot.scaling;
|
|
901
|
+
this.transformRoot.position = g.Zero(), this.transformRoot.rotationQuaternion = A.Identity(), this.transformRoot.scaling = g.One();
|
|
902
|
+
for (const r of e.rootNodes) {
|
|
903
|
+
r.parent = this.transformRoot;
|
|
904
|
+
for (const o of r.getChildMeshes(!1))
|
|
905
|
+
o.alwaysSelectAsActiveMesh = !0;
|
|
1083
906
|
}
|
|
1084
|
-
this.transformRoot.position = t, this.transformRoot.rotationQuaternion = i, this.transformRoot.scaling =
|
|
907
|
+
this.transformRoot.position = t, this.transformRoot.rotationQuaternion = i, this.transformRoot.scaling = a, this.canvasPanels = this.contextService?.getAll() || /* @__PURE__ */ new Map(), xe(
|
|
1085
908
|
this.materials.concat(this.variantManager.getAllMaterials()),
|
|
1086
909
|
this.scene,
|
|
1087
910
|
this.canvasPanels,
|
|
@@ -1093,27 +916,14 @@ class st {
|
|
|
1093
916
|
* Destroys the model instance.
|
|
1094
917
|
*/
|
|
1095
918
|
destroyInstance() {
|
|
1096
|
-
|
|
1097
|
-
(e = this.modelInstance) == null || e.dispose(), this.modelInstance = void 0;
|
|
919
|
+
this.modelInstance?.dispose(), this.modelInstance = void 0;
|
|
1098
920
|
}
|
|
1099
921
|
getAllMeshes() {
|
|
1100
|
-
|
|
1101
|
-
return (e = this.modelInstance) == null ? void 0 : e.rootNodes.map(
|
|
1102
|
-
(t) => t.getChildMeshes(!1).filter((i) => i instanceof Ie)
|
|
1103
|
-
).flat();
|
|
922
|
+
return this.modelInstance?.rootNodes.map((e) => e.getChildMeshes(!1).filter((t) => t instanceof de)).flat();
|
|
1104
923
|
}
|
|
1105
924
|
async instantiate() {
|
|
1106
|
-
if (!this.assetContainer)
|
|
1107
|
-
|
|
1108
|
-
"Attempted to instantiate ModelContainer without an AssetContainer"
|
|
1109
|
-
);
|
|
1110
|
-
this.modelInstance = this.assetContainer.instantiateModelsToScene(
|
|
1111
|
-
this.renameClonedAsset.bind(this),
|
|
1112
|
-
!0
|
|
1113
|
-
), this.materials = we(this.modelInstance), this.configureModelInstance(this.modelInstance), this.animations = fe(
|
|
1114
|
-
this.modelInstance.animationGroups,
|
|
1115
|
-
this.renameClonedAsset("")
|
|
1116
|
-
), this.initialized = !0, await this.processQueuedEvents();
|
|
925
|
+
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 = J(this.modelInstance), this.configureModelInstance(this.modelInstance), this.animations = $(this.modelInstance.animationGroups, this.renameClonedAsset("")), this.initialized = !0, await this.processQueuedEvents();
|
|
1117
927
|
}
|
|
1118
928
|
renameClonedAsset(e) {
|
|
1119
929
|
return `${this.id}_${e}`;
|
|
@@ -1122,13 +932,10 @@ class st {
|
|
|
1122
932
|
e && !this.modelInstance ? await this.instantiate() : !e && this.modelInstance && this.destroyInstance();
|
|
1123
933
|
}
|
|
1124
934
|
updateDynamicTextures() {
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
(
|
|
1128
|
-
|
|
1129
|
-
r && t.getStaticContextDirty() && r.isReady() && (r.update(!1), t.setStaticContextDirty(!1));
|
|
1130
|
-
}
|
|
1131
|
-
);
|
|
935
|
+
this.canvasPanels?.forEach((e, t) => {
|
|
936
|
+
const i = this.dynamicTextures.get(t);
|
|
937
|
+
i && e.getStaticContextDirty() && i.isReady() && (i.update(!1), e.setStaticContextDirty(!1));
|
|
938
|
+
});
|
|
1132
939
|
}
|
|
1133
940
|
//#region Listeners
|
|
1134
941
|
registerMaterialVariantListener(e) {
|
|
@@ -1148,24 +955,16 @@ class st {
|
|
|
1148
955
|
}
|
|
1149
956
|
//#endregion
|
|
1150
957
|
getCurrentAnimationFrame() {
|
|
1151
|
-
|
|
1152
|
-
const
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
];
|
|
1156
|
-
for (const i of e)
|
|
1157
|
-
if (i.animatables.length > 0 && i.animatables[0].masterFrame !== void 0 && i.animatables[0].masterFrame !== null)
|
|
1158
|
-
return i.animatables[0].masterFrame;
|
|
958
|
+
const e = [...this.modelInstance?.animationGroups || [], ...this.variantManager.getAnimationGroups()];
|
|
959
|
+
for (const t of e)
|
|
960
|
+
if (t.animatables.length > 0 && t.animatables[0].masterFrame !== void 0 && t.animatables[0].masterFrame !== null)
|
|
961
|
+
return t.animatables[0].masterFrame;
|
|
1159
962
|
return 0;
|
|
1160
963
|
}
|
|
1161
964
|
getAnimationIsPlaying() {
|
|
1162
|
-
|
|
1163
|
-
const
|
|
1164
|
-
|
|
1165
|
-
...this.variantManager.getAnimationGroups()
|
|
1166
|
-
];
|
|
1167
|
-
for (const i of e)
|
|
1168
|
-
if (i.isPlaying)
|
|
965
|
+
const e = [...this.modelInstance?.animationGroups || [], ...this.variantManager.getAnimationGroups()];
|
|
966
|
+
for (const t of e)
|
|
967
|
+
if (t.isPlaying)
|
|
1169
968
|
return !0;
|
|
1170
969
|
return !1;
|
|
1171
970
|
}
|
|
@@ -1177,34 +976,18 @@ class st {
|
|
|
1177
976
|
Array.from(this.materialReadyToLoadCallbacks.values()).flatMap(
|
|
1178
977
|
(e) => Array.from(e.values()).map((t) => t())
|
|
1179
978
|
)
|
|
1180
|
-
), this.materialReadyToLoadCallbacks.clear(), await Promise.all(
|
|
1181
|
-
Array.from(this.queuedModelChanges.values()).map(
|
|
1182
|
-
(e) => e()
|
|
1183
|
-
)
|
|
1184
|
-
), this.queuedModelChanges.clear(), this.scene.onAfterRenderObservable.addOnce(() => {
|
|
979
|
+
), this.materialReadyToLoadCallbacks.clear(), await Promise.all(Array.from(this.queuedModelChanges.values()).map((e) => e())), this.queuedModelChanges.clear(), this.scene.onAfterRenderObservable.addOnce(() => {
|
|
1185
980
|
this.queuedModelAnimation && (this.executeAnimation(this.queuedModelAnimation), this.queuedModelAnimation = void 0);
|
|
1186
981
|
});
|
|
1187
982
|
}
|
|
1188
983
|
//#endregion
|
|
1189
984
|
}
|
|
1190
|
-
class
|
|
1191
|
-
constructor(e, t, i,
|
|
1192
|
-
super(
|
|
1193
|
-
e,
|
|
1194
|
-
t,
|
|
1195
|
-
i,
|
|
1196
|
-
r,
|
|
1197
|
-
s,
|
|
1198
|
-
o,
|
|
1199
|
-
l
|
|
1200
|
-
), 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, a.camera.autoOrientation && (this.alpha += Math.PI), a && (a.camera.limits.min.beta && (this.lowerBetaLimit = a.camera.limits.min.beta), a.camera.limits.max.beta && (this.upperBetaLimit = a.camera.limits.max.beta), a.camera.limits.min.alpha && (this.lowerAlphaLimit = a.camera.limits.min.alpha), a.camera.limits.max.alpha && (this.upperAlphaLimit = a.camera.limits.max.alpha), a.camera.limits.min.radius && (this.lowerRadiusLimit = a.camera.limits.min.radius), a.camera.limits.max.radius && (this.upperRadiusLimit = a.camera.limits.max.radius), a.camera.autoRotation.enabled && this.enableAutoRotationBehavior(
|
|
1201
|
-
a.camera.autoRotation.idleTimeMs
|
|
1202
|
-
));
|
|
985
|
+
class k extends j {
|
|
986
|
+
constructor(e, t, i, a, r, o, s, h) {
|
|
987
|
+
super(e, t, i, a, r, 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, s.camera.autoOrientation && (this.alpha += Math.PI), s && (s.camera.limits.min.beta && (this.lowerBetaLimit = s.camera.limits.min.beta), s.camera.limits.max.beta && (this.upperBetaLimit = s.camera.limits.max.beta), s.camera.limits.min.alpha && (this.lowerAlphaLimit = s.camera.limits.min.alpha), s.camera.limits.max.alpha && (this.upperAlphaLimit = s.camera.limits.max.alpha), s.camera.limits.min.radius && (this.lowerRadiusLimit = s.camera.limits.min.radius), s.camera.limits.max.radius && (this.upperRadiusLimit = s.camera.limits.max.radius), s.camera.autoRotation.enabled && this.enableAutoRotationBehavior(s.camera.autoRotation.idleTimeMs));
|
|
1203
988
|
}
|
|
1204
989
|
updateConfiguration(e) {
|
|
1205
|
-
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(
|
|
1206
|
-
e.camera.autoRotation.idleTimeMs
|
|
1207
|
-
) : this.disableAutoRotationBehavior());
|
|
990
|
+
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());
|
|
1208
991
|
}
|
|
1209
992
|
get isRunningFramingBehavior() {
|
|
1210
993
|
return this._isRunningFramingBehavior;
|
|
@@ -1238,7 +1021,7 @@ class G extends be {
|
|
|
1238
1021
|
this.useFramingBehavior = !0;
|
|
1239
1022
|
const e = this.getFramingBehavior();
|
|
1240
1023
|
e.attach(this), e.framingTime = 0, e.elevationReturnTime = -1, e.zoomStopsAnimation = !1, this.lowerRadiusLimit = null;
|
|
1241
|
-
const t =
|
|
1024
|
+
const t = T(this._scene);
|
|
1242
1025
|
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;
|
|
1243
1026
|
}
|
|
1244
1027
|
/**
|
|
@@ -1250,15 +1033,10 @@ class G extends be {
|
|
|
1250
1033
|
this._isRunningFramingBehavior = !0, this.framingBehaviourCallback = e;
|
|
1251
1034
|
const i = this.getFramingBehavior();
|
|
1252
1035
|
i.framingTime = t || 800;
|
|
1253
|
-
const
|
|
1036
|
+
const a = () => {
|
|
1254
1037
|
this.isRunningFramingBehavior = !1;
|
|
1255
|
-
},
|
|
1256
|
-
this.updateRadiusBounds(o.length() * 1.5), this.wheelPrecision = 100 / this.radius, this.panningInertia = 0, this.panningOriginTarget.copyFrom(
|
|
1257
|
-
s.min,
|
|
1258
|
-
s.max,
|
|
1259
|
-
void 0,
|
|
1260
|
-
r
|
|
1261
|
-
), i.framingTime = 0;
|
|
1038
|
+
}, r = T(this._scene), o = r.max.subtract(r.min), s = r.min.add(o.scale(0.5));
|
|
1039
|
+
this.updateRadiusBounds(o.length() * 1.5), this.wheelPrecision = 100 / this.radius, this.panningInertia = 0, this.panningOriginTarget.copyFrom(s), this.panDenominator = o.length(), this.lastFocus.copyFrom(s), i.zoomOnBoundingInfo(r.min, r.max, void 0, a), i.framingTime = 0;
|
|
1262
1040
|
}
|
|
1263
1041
|
/**
|
|
1264
1042
|
* Activates the auto rotation behavior causing the camera to rotate slowly around
|
|
@@ -1288,24 +1066,21 @@ class G extends be {
|
|
|
1288
1066
|
* @param disablePan If true the camera will not allow panning.
|
|
1289
1067
|
*/
|
|
1290
1068
|
static create(e, t, i) {
|
|
1291
|
-
|
|
1292
|
-
const r = I(e), s = r.max.subtract(r.min), o = r.min.add(s.scale(0.5)), a = new G(
|
|
1069
|
+
const a = T(e), r = a.max.subtract(a.min), o = a.min.add(r.scale(0.5)), s = new k(
|
|
1293
1070
|
"ProductCamera",
|
|
1294
1071
|
-(Math.PI / 2),
|
|
1295
1072
|
Math.PI / 2,
|
|
1296
|
-
|
|
1073
|
+
r.length() * 1.5,
|
|
1297
1074
|
o,
|
|
1298
1075
|
e,
|
|
1299
1076
|
t
|
|
1300
1077
|
);
|
|
1301
|
-
return
|
|
1302
|
-
(
|
|
1303
|
-
),
|
|
1304
|
-
a.setPanEnabled(a.panEnabled);
|
|
1305
|
-
}), i && (e.activeCamera = a), a;
|
|
1078
|
+
return s.setPanEnabled(t.options?.noPan !== void 0 ? !t.options.noPan : !0), s.panningInertia = 0, s.panningOriginTarget.copyFrom(o), s.panDenominator = r.length(), s.onAfterCheckInputsObservable.addOnce(() => {
|
|
1079
|
+
s.setPanEnabled(s.panEnabled);
|
|
1080
|
+
}), i && (e.activeCamera = s), s;
|
|
1306
1081
|
}
|
|
1307
1082
|
}
|
|
1308
|
-
function
|
|
1083
|
+
function T(n) {
|
|
1309
1084
|
if (n.meshes.length === 0)
|
|
1310
1085
|
return {
|
|
1311
1086
|
min: new g(-1, -1, -1),
|
|
@@ -1314,16 +1089,16 @@ function I(n) {
|
|
|
1314
1089
|
const e = n.meshes.filter((t) => t.name.toLowerCase().endsWith("_t") || t.name.toLowerCase().includes("_t_"));
|
|
1315
1090
|
return n.getWorldExtends((t) => t.isVisible && t.isEnabled() && (e.length === 0 || e.includes(t)));
|
|
1316
1091
|
}
|
|
1317
|
-
class
|
|
1092
|
+
class ze {
|
|
1318
1093
|
constructor(e, t = !1, i = void 0) {
|
|
1319
|
-
this.renderingPipeline = new
|
|
1094
|
+
this.renderingPipeline = new ve(
|
|
1320
1095
|
"default",
|
|
1321
1096
|
t,
|
|
1322
1097
|
e,
|
|
1323
1098
|
i ? [i] : void 0,
|
|
1324
1099
|
!1
|
|
1325
1100
|
// Disable automatic build
|
|
1326
|
-
), this.renderingPipeline.isSupported && (this.renderingPipeline.prepare(), this.setConfiguration(
|
|
1101
|
+
), this.renderingPipeline.isSupported && (this.renderingPipeline.prepare(), this.setConfiguration(d));
|
|
1327
1102
|
}
|
|
1328
1103
|
dispose() {
|
|
1329
1104
|
this.renderingPipeline.dispose();
|
|
@@ -1332,143 +1107,126 @@ class rt {
|
|
|
1332
1107
|
return this.currentConfiguration;
|
|
1333
1108
|
}
|
|
1334
1109
|
setConfiguration(e) {
|
|
1335
|
-
var t, i, r, s, o, a, l, c, h, d, m, f, p, b, w, R, V, _, H, U, K, W, Q, Y, Z, $, j, X, J, ee, te, ie, ne;
|
|
1336
1110
|
if (this.renderingPipeline.isSupported) {
|
|
1337
|
-
if (this.renderingPipeline.samples =
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
) : new
|
|
1341
|
-
|
|
1342
|
-
u.chromaticAberration.direction.y
|
|
1343
|
-
), this.renderingPipeline.imageProcessing.colorCurvesEnabled = ((f = e.colorCurves) == null ? void 0 : f.enabled) ?? u.colorCurves.enabled, this.renderingPipeline.imageProcessing.colorCurves = e.colorCurves ? this.updateColorCurve(e.colorCurves) : new he(), this.renderingPipeline.depthOfFieldEnabled = ((p = e.depthOfField) == null ? void 0 : p.enabled) ?? u.depthOfField.enabled, e.depthOfField)
|
|
1344
|
-
switch (e.depthOfField.blurLevel ?? u.depthOfField.blurLevel) {
|
|
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 z(e.chromaticAberration.direction.x, e.chromaticAberration.direction.y) : new z(
|
|
1112
|
+
d.chromaticAberration.direction.x,
|
|
1113
|
+
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 H(), this.renderingPipeline.depthOfFieldEnabled = e.depthOfField?.enabled ?? d.depthOfField.enabled, e.depthOfField)
|
|
1115
|
+
switch (e.depthOfField.blurLevel ?? d.depthOfField.blurLevel) {
|
|
1345
1116
|
case "Low":
|
|
1346
|
-
this.renderingPipeline.depthOfFieldBlurLevel =
|
|
1117
|
+
this.renderingPipeline.depthOfFieldBlurLevel = R.Low;
|
|
1347
1118
|
break;
|
|
1348
1119
|
case "Medium":
|
|
1349
|
-
this.renderingPipeline.depthOfFieldBlurLevel =
|
|
1120
|
+
this.renderingPipeline.depthOfFieldBlurLevel = R.Medium;
|
|
1350
1121
|
break;
|
|
1351
1122
|
case "High":
|
|
1352
|
-
this.renderingPipeline.depthOfFieldBlurLevel =
|
|
1123
|
+
this.renderingPipeline.depthOfFieldBlurLevel = R.High;
|
|
1353
1124
|
break;
|
|
1354
1125
|
}
|
|
1355
|
-
if (this.renderingPipeline.depthOfField.focalLength =
|
|
1356
|
-
switch (e.misc
|
|
1126
|
+
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
|
+
switch (e.misc?.toneMappingType ?? d.misc.toneMappingType) {
|
|
1357
1128
|
case "Standard":
|
|
1358
|
-
this.renderingPipeline.imageProcessing.toneMappingType =
|
|
1129
|
+
this.renderingPipeline.imageProcessing.toneMappingType = M.TONEMAPPING_STANDARD;
|
|
1359
1130
|
break;
|
|
1360
1131
|
case "ACES":
|
|
1361
|
-
this.renderingPipeline.imageProcessing.toneMappingType =
|
|
1132
|
+
this.renderingPipeline.imageProcessing.toneMappingType = M.TONEMAPPING_ACES;
|
|
1362
1133
|
break;
|
|
1363
1134
|
}
|
|
1364
|
-
if (this.renderingPipeline.sharpenEnabled =
|
|
1365
|
-
switch (
|
|
1135
|
+
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
|
+
switch (e.vignette?.blendMode ?? d.vignette.blendMode) {
|
|
1366
1137
|
case "Multiply":
|
|
1367
|
-
this.renderingPipeline.imageProcessing.vignetteBlendMode =
|
|
1138
|
+
this.renderingPipeline.imageProcessing.vignetteBlendMode = M.VIGNETTEMODE_MULTIPLY;
|
|
1368
1139
|
break;
|
|
1369
1140
|
case "Opaque":
|
|
1370
|
-
this.renderingPipeline.imageProcessing.vignetteBlendMode =
|
|
1141
|
+
this.renderingPipeline.imageProcessing.vignetteBlendMode = M.VIGNETTEMODE_OPAQUE;
|
|
1371
1142
|
break;
|
|
1372
1143
|
}
|
|
1373
|
-
|
|
1144
|
+
e.vignette?.colorRgba ? this.renderingPipeline.imageProcessing.vignetteColor = new b(
|
|
1374
1145
|
e.vignette.colorRgba.r,
|
|
1375
1146
|
e.vignette.colorRgba.g,
|
|
1376
1147
|
e.vignette.colorRgba.b,
|
|
1377
1148
|
e.vignette.colorRgba.a
|
|
1378
|
-
) :
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1149
|
+
) : e.vignette?.colorHex ? this.renderingPipeline.imageProcessing.vignetteColor = b.FromHexString(
|
|
1150
|
+
e.vignette.colorHex
|
|
1151
|
+
) : this.renderingPipeline.imageProcessing.vignetteColor = new b(
|
|
1152
|
+
d.vignette.colorRgba.r,
|
|
1153
|
+
d.vignette.colorRgba.g,
|
|
1154
|
+
d.vignette.colorRgba.b,
|
|
1155
|
+
d.vignette.colorRgba.a
|
|
1156
|
+
), this.renderingPipeline.imageProcessing.vignetteStretch = e.vignette?.stretch ?? d.vignette.stretch, this.renderingPipeline.imageProcessing.vignetteWeight = e.vignette?.weight ?? d.vignette.weight, this.renderingPipeline.prepare(), this.currentConfiguration = e;
|
|
1384
1157
|
}
|
|
1385
1158
|
}
|
|
1386
1159
|
updateColorCurve(e) {
|
|
1387
|
-
const t = new
|
|
1160
|
+
const t = new H();
|
|
1388
1161
|
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;
|
|
1389
1162
|
}
|
|
1390
1163
|
}
|
|
1391
|
-
|
|
1392
|
-
return new
|
|
1164
|
+
se.GLTFLoader.RegisterExtension("glbPostProcessor", function(n) {
|
|
1165
|
+
return new Ae(n);
|
|
1393
1166
|
});
|
|
1394
|
-
|
|
1167
|
+
B.OnPluginActivatedObservable.add((n) => {
|
|
1395
1168
|
if (n.name === "gltf") {
|
|
1396
1169
|
const e = n;
|
|
1397
1170
|
e.transparencyAsCoverage = !0;
|
|
1398
1171
|
}
|
|
1399
1172
|
});
|
|
1400
|
-
function
|
|
1173
|
+
function O(n) {
|
|
1401
1174
|
return new g(n.x, n.y, n.z);
|
|
1402
1175
|
}
|
|
1403
|
-
function
|
|
1176
|
+
function L(n) {
|
|
1404
1177
|
return { x: n.x, y: n.y, z: n.z };
|
|
1405
1178
|
}
|
|
1406
|
-
class
|
|
1179
|
+
class Tt {
|
|
1407
1180
|
constructor(e) {
|
|
1408
|
-
|
|
1409
|
-
this.focusLostNotified = !1, this.focusLostObservable = new M(), this.modelLoadEventCallbacks = [], this.validHighlightMaterials = [], this.modelContainers = /* @__PURE__ */ new Map(), this.plugins = [], this.initComplete = !1, this.isAnimatingCamera = !1, this.renderLoop = () => {
|
|
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 = () => {
|
|
1410
1182
|
if (!this.engine.views)
|
|
1411
1183
|
return;
|
|
1412
|
-
this.modelContainers.forEach((
|
|
1413
|
-
|
|
1184
|
+
this.modelContainers.forEach((c) => {
|
|
1185
|
+
c.updateDynamicTextures();
|
|
1414
1186
|
}), this.scene.autoClear = !0, this.scene.autoClearDepthAndStencil = !0;
|
|
1415
|
-
const
|
|
1416
|
-
if (
|
|
1417
|
-
if (
|
|
1418
|
-
const
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
);
|
|
1422
|
-
} else
|
|
1423
|
-
l.getContext("2d") ? l.getContext("2d").clearRect(0, 0, l.width, l.height) : console.error(
|
|
1424
|
-
"SpiffCommerce: Failed to get any context on the rendering canvas."
|
|
1425
|
-
);
|
|
1187
|
+
const s = this.engine.getRenderingCanvas();
|
|
1188
|
+
if (s)
|
|
1189
|
+
if (s.getContext("webgl2") ?? s.getContext("webgl")) {
|
|
1190
|
+
const c = this.configuration.scene.clearColor, l = s.getContext("webgl2") ?? s.getContext("webgl");
|
|
1191
|
+
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 s.getContext("2d") ? s.getContext("2d").clearRect(0, 0, s.width, s.height) : console.error("SpiffCommerce: Failed to get any context on the rendering canvas.");
|
|
1426
1193
|
this.scene.render(), this.camera.isRunningFramingBehavior && this.camera.getFramingBehavior().isUserIsMoving && (this.camera.isRunningFramingBehavior = !1);
|
|
1427
|
-
const
|
|
1428
|
-
!this.camera.isRunningFramingBehavior && !this.camera.target.equalsWithEpsilon(this.camera.lastFocus,
|
|
1429
|
-
}, this.configuration = new
|
|
1194
|
+
const h = Math.max((this.camera.lowerRadiusLimit ?? 1) * 0.01, 1e-3);
|
|
1195
|
+
!this.camera.isRunningFramingBehavior && !this.camera.target.equalsWithEpsilon(this.camera.lastFocus, h) && !this.focusLostNotified && (this.focusLostObservable.notifyObservers(void 0), this.focusLostNotified = !0);
|
|
1196
|
+
}, this.configuration = new K(e);
|
|
1430
1197
|
const i = (() => {
|
|
1431
|
-
if (!
|
|
1198
|
+
if (!e?.noRender)
|
|
1432
1199
|
return this.configuration.createCanvas();
|
|
1433
|
-
})(),
|
|
1434
|
-
|
|
1200
|
+
})(), a = "1.5.7";
|
|
1201
|
+
te.Configuration = {
|
|
1435
1202
|
decoder: {
|
|
1436
|
-
wasmUrl: `https://www.gstatic.com/draco/versioned/decoders/${
|
|
1437
|
-
wasmBinaryUrl: `https://www.gstatic.com/draco/versioned/decoders/${
|
|
1438
|
-
fallbackUrl: `https://www.gstatic.com/draco/versioned/decoders/${
|
|
1203
|
+
wasmUrl: `https://www.gstatic.com/draco/versioned/decoders/${a}/draco_wasm_wrapper_gltf.js`,
|
|
1204
|
+
wasmBinaryUrl: `https://www.gstatic.com/draco/versioned/decoders/${a}/draco_decoder_gltf.wasm`,
|
|
1205
|
+
fallbackUrl: `https://www.gstatic.com/draco/versioned/decoders/${a}/draco_decoder_gltf.js`
|
|
1439
1206
|
}
|
|
1440
1207
|
}, i && (i.getContext("webgl2") || i.getContext("webgl"));
|
|
1441
|
-
const
|
|
1208
|
+
const r = console.log;
|
|
1442
1209
|
console.log = () => {
|
|
1443
1210
|
};
|
|
1444
|
-
const o = i ? new
|
|
1211
|
+
const o = i ? new I(i, !0, {
|
|
1445
1212
|
adaptToDeviceRatio: !0,
|
|
1446
1213
|
limitDeviceRatio: 2,
|
|
1447
1214
|
premultipliedAlpha: !1,
|
|
1448
|
-
preserveDrawingBuffer: !!
|
|
1215
|
+
preserveDrawingBuffer: !!e?.backgroundImage,
|
|
1449
1216
|
audioEngine: !1,
|
|
1450
1217
|
stencil: this.configuration.highlights.enabled,
|
|
1451
1218
|
forceSRGBBufferSupportState: !0
|
|
1452
|
-
}) : new
|
|
1453
|
-
if (o.enableOfflineSupport = !1, o.doNotHandleContextLost = !0, console.log =
|
|
1454
|
-
|
|
1455
|
-
!1,
|
|
1456
|
-
this.camera
|
|
1457
|
-
), this.scene.clearColor = this.configuration.scene.clearColor, this.configuration.scene.environment.file) {
|
|
1458
|
-
const l = se.CreateFromPrefilteredData(
|
|
1219
|
+
}) : new ee();
|
|
1220
|
+
if (o.enableOfflineSupport = !1, o.doNotHandleContextLost = !0, console.log = r, o.hideLoadingUI(), window.addEventListener("resize", this.fireResizeEvent.bind(this)), this.engine = o, this.scene = new ne(o), this.camera = k.create(this.scene, this.configuration), this.scene.activeCamera = this.camera, this.renderingPipeline = new ze(this.scene, !1, this.camera), this.scene.clearColor = this.configuration.scene.clearColor, this.configuration.scene.environment.file) {
|
|
1221
|
+
const s = N.CreateFromPrefilteredData(
|
|
1459
1222
|
this.configuration.scene.environment.file,
|
|
1460
1223
|
this.scene
|
|
1461
1224
|
);
|
|
1462
|
-
|
|
1225
|
+
s.name = "initial-environment-cube", s.rotationY = this.configuration.scene.environment.rotationY, this.scene.environmentTexture = s;
|
|
1463
1226
|
}
|
|
1464
|
-
this.scene.environmentIntensity = this.configuration.scene.environment.intensity,
|
|
1465
|
-
this.configuration.options.renderingPipelineConfiguration
|
|
1466
|
-
) : (this.scene.imageProcessingConfiguration.exposure = this.configuration.lighting.exposure, this.scene.imageProcessingConfiguration.contrast = this.configuration.lighting.contrast), this.glowLayerManager = new _e(
|
|
1467
|
-
this.scene,
|
|
1468
|
-
this.configuration.emissiveGlowIntensity
|
|
1469
|
-
), this.initPromise = new Promise((l) => {
|
|
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) => {
|
|
1470
1228
|
this.scene.onReadyObservable.addOnce(() => {
|
|
1471
|
-
this.initComplete = !0,
|
|
1229
|
+
this.initComplete = !0, s();
|
|
1472
1230
|
});
|
|
1473
1231
|
});
|
|
1474
1232
|
}
|
|
@@ -1500,32 +1258,27 @@ class Yt {
|
|
|
1500
1258
|
}
|
|
1501
1259
|
registerView(e) {
|
|
1502
1260
|
const t = e.height, i = e.width;
|
|
1503
|
-
this.engine.registerView(e, void 0, !0), e.setAttribute("height", t.toString()), e.setAttribute("width", i.toString()), this.orbitEnabled() || this.setCameraState(
|
|
1261
|
+
this.engine.registerView(e, void 0, !0), e.setAttribute("height", t.toString()), e.setAttribute("width", i.toString()), this.orbitEnabled() || this.setCameraState(F.Pan), this.reattachControls(e), this.engine.activeRenderLoops.length === 0 && this.engine.runRenderLoop(this.renderLoop);
|
|
1504
1262
|
}
|
|
1505
1263
|
unregisterView(e) {
|
|
1506
1264
|
this.engine.unRegisterView(e), this.engine.views && this.engine.views.length === 0 && this.engine.stopRenderLoop(this.renderLoop);
|
|
1507
1265
|
}
|
|
1508
1266
|
getNumViewports() {
|
|
1509
|
-
|
|
1510
|
-
return ((e = this.engine.views) == null ? void 0 : e.length) || 0;
|
|
1267
|
+
return this.engine.views?.length || 0;
|
|
1511
1268
|
}
|
|
1512
1269
|
shutdown() {
|
|
1513
1270
|
this.plugins.forEach((e) => e.dispose(!0)), this.renderingPipeline.dispose(), this.engine && this.engine.dispose(), window.removeEventListener("resize", this.fireResizeEvent);
|
|
1514
1271
|
}
|
|
1515
1272
|
executeCameraAnimation(e) {
|
|
1516
|
-
if (!this.camera || this.scene.activeCamera !== this.camera || this.getAllModels().length === 0 || !this.getAllModels().some((
|
|
1273
|
+
if (!this.camera || this.scene.activeCamera !== this.camera || this.getAllModels().length === 0 || !this.getAllModels().some((a) => a.getIsInitialized()))
|
|
1517
1274
|
return this.queuedCameraAnimation = e, Promise.resolve();
|
|
1518
1275
|
let t = () => {
|
|
1519
1276
|
};
|
|
1520
1277
|
const i = async () => {
|
|
1521
|
-
this.isAnimatingCamera = !0, await
|
|
1522
|
-
this.scene,
|
|
1523
|
-
this.scene.activeCamera,
|
|
1524
|
-
e
|
|
1525
|
-
), this.isAnimatingCamera = !1, this.queuedAnimationFunction && this.queuedAnimationFunction(), this.queuedAnimationFunction = void 0, t();
|
|
1278
|
+
this.isAnimatingCamera = !0, await Te(this.scene, this.scene.activeCamera, e), this.isAnimatingCamera = !1, this.queuedAnimationFunction && this.queuedAnimationFunction(), this.queuedAnimationFunction = void 0, t();
|
|
1526
1279
|
};
|
|
1527
|
-
return this.isAnimatingCamera ? (this.queuedAnimationFunction = i, new Promise((
|
|
1528
|
-
t =
|
|
1280
|
+
return this.isAnimatingCamera ? (this.queuedAnimationFunction = i, new Promise((a) => {
|
|
1281
|
+
t = a;
|
|
1529
1282
|
})) : i();
|
|
1530
1283
|
}
|
|
1531
1284
|
getCameraPose() {
|
|
@@ -1542,19 +1295,12 @@ class Yt {
|
|
|
1542
1295
|
};
|
|
1543
1296
|
}
|
|
1544
1297
|
setCameraPose(e) {
|
|
1545
|
-
this.scene && this.camera && (this.camera.target = new g(
|
|
1546
|
-
e.target.x,
|
|
1547
|
-
e.target.y,
|
|
1548
|
-
e.target.z
|
|
1549
|
-
), this.camera.radius = e.radius, this.camera.alpha = e.latDeg, this.camera.beta = e.lonDeg);
|
|
1298
|
+
this.scene && this.camera && (this.camera.target = new g(e.target.x, e.target.y, e.target.z), this.camera.radius = e.radius, this.camera.alpha = e.latDeg, this.camera.beta = e.lonDeg);
|
|
1550
1299
|
}
|
|
1551
1300
|
setCameraState(e) {
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
"No views attached, camera state requires a view to attach controls onto."
|
|
1556
|
-
);
|
|
1557
|
-
e === D.Orbit ? this.reattachControls(this.engine.views[0].target, 2) : this.reattachControls(this.engine.views[0].target, 0);
|
|
1301
|
+
if (!this.engine?.views || !this.engine?.views[0])
|
|
1302
|
+
throw new Error("No views attached, camera state requires a view to attach controls onto.");
|
|
1303
|
+
e === F.Orbit ? this.reattachControls(this.engine.views[0].target, 2) : this.reattachControls(this.engine.views[0].target, 0);
|
|
1558
1304
|
}
|
|
1559
1305
|
animateToLastCameraFocus() {
|
|
1560
1306
|
let e = () => {
|
|
@@ -1562,13 +1308,13 @@ class Yt {
|
|
|
1562
1308
|
const t = async () => {
|
|
1563
1309
|
this.isAnimatingCamera = !0, await new Promise((i) => {
|
|
1564
1310
|
this.focusLostNotified = !1;
|
|
1565
|
-
const
|
|
1566
|
-
const
|
|
1311
|
+
const a = () => {
|
|
1312
|
+
const r = this.configuration;
|
|
1567
1313
|
this.camera.rerunFramingBehavior(() => {
|
|
1568
|
-
|
|
1314
|
+
r.camera.limits.min.radius && (this.camera.lowerRadiusLimit = r.camera.limits.min.radius), r.camera.limits.max.radius && (this.camera.upperRadiusLimit = r.camera.limits.max.radius), i();
|
|
1569
1315
|
});
|
|
1570
1316
|
};
|
|
1571
|
-
this.scene.onAfterRenderObservable.addOnce(
|
|
1317
|
+
this.scene.onAfterRenderObservable.addOnce(a);
|
|
1572
1318
|
}), this.isAnimatingCamera = !1, this.queuedAnimationFunction && this.queuedAnimationFunction(), this.queuedAnimationFunction = void 0, e();
|
|
1573
1319
|
};
|
|
1574
1320
|
return this.isAnimatingCamera ? (this.queuedAnimationFunction = t, new Promise((i) => {
|
|
@@ -1576,13 +1322,10 @@ class Yt {
|
|
|
1576
1322
|
})) : t();
|
|
1577
1323
|
}
|
|
1578
1324
|
forceStopCameraAnimations() {
|
|
1579
|
-
|
|
1580
|
-
this.queuedAnimationFunction = void 0, this.queuedCameraAnimation = void 0, this.isAnimatingCamera = !1, (e = this.camera.framingBehavior) == null || e.stopAllAnimations(), this.scene.stopAnimation(this.camera);
|
|
1325
|
+
this.queuedAnimationFunction = void 0, this.queuedCameraAnimation = void 0, this.isAnimatingCamera = !1, this.camera.framingBehavior?.stopAllAnimations(), this.scene.stopAnimation(this.camera);
|
|
1581
1326
|
}
|
|
1582
1327
|
setAutoRotation(e) {
|
|
1583
|
-
!this.configuration.camera.autoRotation.enabled || !this.camera || (e ? this.camera.enableAutoRotationBehavior(
|
|
1584
|
-
this.configuration.camera.autoRotation.idleTimeMs
|
|
1585
|
-
) : this.camera.disableAutoRotationBehavior());
|
|
1328
|
+
!this.configuration.camera.autoRotation.enabled || !this.camera || (e ? this.camera.enableAutoRotationBehavior(this.configuration.camera.autoRotation.idleTimeMs) : this.camera.disableAutoRotationBehavior());
|
|
1586
1329
|
}
|
|
1587
1330
|
getCurrentConfiguration() {
|
|
1588
1331
|
return this.configuration.options;
|
|
@@ -1590,20 +1333,13 @@ class Yt {
|
|
|
1590
1333
|
async renderSceneScreenshot(e, t) {
|
|
1591
1334
|
if (!this.camera)
|
|
1592
1335
|
throw new Error("Missing product camera, cannot render screenshot!");
|
|
1593
|
-
const i = new
|
|
1594
|
-
|
|
1595
|
-
0,
|
|
1596
|
-
0,
|
|
1597
|
-
0,
|
|
1598
|
-
g.Zero(),
|
|
1599
|
-
this.scene
|
|
1600
|
-
), r = t.latDeg * Math.PI / 180, s = t.lonDeg * Math.PI / 180;
|
|
1601
|
-
i.target = t.target ? new g(t.target.x, t.target.y, t.target.z) : g.Zero(), i.alpha = s, i.beta = r, i.radius = t.radius || this.camera.radius, i.minZ = 0.01;
|
|
1336
|
+
const i = new j("screenshotCamera", 0, 0, 0, g.Zero(), this.scene), a = t.latDeg * Math.PI / 180, r = t.lonDeg * Math.PI / 180;
|
|
1337
|
+
i.target = t.target ? new g(t.target.x, t.target.y, t.target.z) : g.Zero(), i.alpha = r, i.beta = a, i.radius = t.radius || this.camera.radius, i.minZ = 0.01;
|
|
1602
1338
|
try {
|
|
1603
1339
|
return await new Promise((o) => {
|
|
1604
|
-
const
|
|
1605
|
-
this.scene.onBeforeRenderObservable.remove(
|
|
1606
|
-
const
|
|
1340
|
+
const s = this.scene.onBeforeRenderObservable.add(async () => {
|
|
1341
|
+
this.scene.onBeforeRenderObservable.remove(s);
|
|
1342
|
+
const h = await ie.CreateScreenshotUsingRenderTargetAsync(
|
|
1607
1343
|
this.engine,
|
|
1608
1344
|
i,
|
|
1609
1345
|
e,
|
|
@@ -1611,7 +1347,7 @@ class Yt {
|
|
|
1611
1347
|
2,
|
|
1612
1348
|
!0
|
|
1613
1349
|
);
|
|
1614
|
-
return i.dispose(), o(
|
|
1350
|
+
return i.dispose(), o(h);
|
|
1615
1351
|
});
|
|
1616
1352
|
this.scene.render(), this.engine.endFrame();
|
|
1617
1353
|
});
|
|
@@ -1623,11 +1359,11 @@ class Yt {
|
|
|
1623
1359
|
const e = this.configuration;
|
|
1624
1360
|
if (!e)
|
|
1625
1361
|
return !0;
|
|
1626
|
-
const t = e.camera.limits.min.alpha, i = e.camera.limits.max.alpha,
|
|
1627
|
-
if (t === void 0 || i === void 0 ||
|
|
1362
|
+
const t = e.camera.limits.min.alpha, i = e.camera.limits.max.alpha, a = e.camera.limits.min.beta, r = e.camera.limits.max.beta;
|
|
1363
|
+
if (t === void 0 || i === void 0 || a === void 0 || r === void 0)
|
|
1628
1364
|
return !0;
|
|
1629
|
-
const o = [t, i],
|
|
1630
|
-
return !
|
|
1365
|
+
const o = [t, i], s = [a, r], h = o.every((l) => l === t), c = s.every((l) => l === a);
|
|
1366
|
+
return !h && !c;
|
|
1631
1367
|
}
|
|
1632
1368
|
fireResizeEvent() {
|
|
1633
1369
|
this.getNumViewports() > 0 && this.engine.resize();
|
|
@@ -1635,33 +1371,29 @@ class Yt {
|
|
|
1635
1371
|
setHighlights(e) {
|
|
1636
1372
|
this.scene.materials.forEach(() => {
|
|
1637
1373
|
this.scene.materials.forEach((i) => {
|
|
1638
|
-
i.emissiveIntensity === 0.18 && (i.emissiveColor =
|
|
1374
|
+
i.emissiveIntensity === 0.18 && (i.emissiveColor = v.Black(), i.emissiveIntensity = 1);
|
|
1639
1375
|
});
|
|
1640
|
-
}), e.filter(
|
|
1641
|
-
(
|
|
1642
|
-
|
|
1643
|
-
const r = this.scene.materials.find(
|
|
1644
|
-
(s) => s.id === i.id
|
|
1645
|
-
);
|
|
1646
|
-
r && (r.emissiveColor = new C(
|
|
1376
|
+
}), e.filter((i) => this.validHighlightMaterials.includes(i.name)).forEach((i) => {
|
|
1377
|
+
const a = this.scene.materials.find((r) => r.id === i.id);
|
|
1378
|
+
a && (a.emissiveColor = new v(
|
|
1647
1379
|
this.configuration.highlights.color.r,
|
|
1648
1380
|
this.configuration.highlights.color.g,
|
|
1649
1381
|
this.configuration.highlights.color.b
|
|
1650
|
-
),
|
|
1382
|
+
), a.emissiveIntensity = 0.18);
|
|
1651
1383
|
});
|
|
1652
1384
|
}
|
|
1653
1385
|
setRenderingPipelineConfiguration(e) {
|
|
1654
1386
|
this.renderingPipeline && this.renderingPipeline.setConfiguration(e);
|
|
1655
1387
|
}
|
|
1656
1388
|
loadModel(e, t) {
|
|
1657
|
-
const { refocusCamera: i = !0, progressHandler:
|
|
1389
|
+
const { refocusCamera: i = !0, progressHandler: a } = t ?? {}, r = new Ne({
|
|
1658
1390
|
enablePicking: this.configuration.highlights.enabled,
|
|
1659
1391
|
modelDetails: e,
|
|
1660
1392
|
scene: this.scene,
|
|
1661
1393
|
previewService: this,
|
|
1662
|
-
progressHandler:
|
|
1394
|
+
progressHandler: a
|
|
1663
1395
|
});
|
|
1664
|
-
return
|
|
1396
|
+
return r.getInitializationPromise().then(() => {
|
|
1665
1397
|
if (this.modelContainers.size <= 1 && i) {
|
|
1666
1398
|
const o = this.queuedCameraAnimation;
|
|
1667
1399
|
this.forceStopCameraAnimations(), this.camera.rerunFramingBehavior(() => {
|
|
@@ -1670,17 +1402,17 @@ class Yt {
|
|
|
1670
1402
|
});
|
|
1671
1403
|
}, 1);
|
|
1672
1404
|
}
|
|
1673
|
-
}), this.configuration.highlights.enabled && (
|
|
1405
|
+
}), this.configuration.highlights.enabled && (r.registerMaterialSelectedCallback((o) => {
|
|
1674
1406
|
this.setHighlights([o]);
|
|
1675
|
-
}),
|
|
1407
|
+
}), r.registerMaterialDeselectedCallback(() => {
|
|
1676
1408
|
this.setHighlights([]);
|
|
1677
|
-
})), this.modelContainers.set(
|
|
1409
|
+
})), this.modelContainers.set(r.getId(), r), this.triggerModelLoadEvent({
|
|
1678
1410
|
eventType: "load",
|
|
1679
|
-
modelContainer:
|
|
1680
|
-
}),
|
|
1411
|
+
modelContainer: r
|
|
1412
|
+
}), r;
|
|
1681
1413
|
}
|
|
1682
1414
|
async preloadModel(e) {
|
|
1683
|
-
await
|
|
1415
|
+
await q(e, this.scene);
|
|
1684
1416
|
}
|
|
1685
1417
|
getAllModels() {
|
|
1686
1418
|
return Array.from(this.modelContainers.values());
|
|
@@ -1697,7 +1429,7 @@ class Yt {
|
|
|
1697
1429
|
}
|
|
1698
1430
|
unregisterPlugin(e) {
|
|
1699
1431
|
const t = this.plugins.indexOf(e);
|
|
1700
|
-
t > -1 && this.plugins.splice(t, 1).forEach((
|
|
1432
|
+
t > -1 && this.plugins.splice(t, 1).forEach((a) => a.dispose(!1));
|
|
1701
1433
|
}
|
|
1702
1434
|
getGlowLayerManager() {
|
|
1703
1435
|
return this.glowLayerManager;
|
|
@@ -1715,31 +1447,26 @@ class Yt {
|
|
|
1715
1447
|
* Flips a transform around the origin.
|
|
1716
1448
|
*/
|
|
1717
1449
|
flipTransform(e, t, i) {
|
|
1718
|
-
const
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
rotation: S(l.toEulerAngles()),
|
|
1728
|
-
scale: S(c)
|
|
1450
|
+
const a = G.Compose(
|
|
1451
|
+
O(i || { x: 1, y: 1, z: 1 }),
|
|
1452
|
+
A.FromEulerVector(O(t || { x: 0, y: 0, z: 0 })),
|
|
1453
|
+
O(e || { x: 0, y: 0, z: 0 })
|
|
1454
|
+
), r = G.RotationAxis(g.Up(), Math.PI), o = a.multiply(r), s = g.Zero(), h = A.Identity(), c = g.Zero();
|
|
1455
|
+
return o.decompose(c, h, s), h.multiplyInPlace(A.FromEulerAngles(0, Math.PI, 0)), {
|
|
1456
|
+
position: L(s),
|
|
1457
|
+
rotation: L(h.toEulerAngles()),
|
|
1458
|
+
scale: L(c)
|
|
1729
1459
|
};
|
|
1730
1460
|
}
|
|
1731
1461
|
updatePreviewOptions(e) {
|
|
1732
|
-
|
|
1733
|
-
const t = new de(e);
|
|
1462
|
+
const t = new K(e);
|
|
1734
1463
|
this.configuration.highlights.enabled !== t.highlights.enabled && this.engine.setStencilBuffer(t.highlights.enabled), this.scene.clearColor = t.scene.clearColor;
|
|
1735
1464
|
let i = this.scene.environmentTexture;
|
|
1736
|
-
t.scene.environment.file && this.configuration.scene.environment.file !== t.scene.environment.file && (i =
|
|
1465
|
+
t.scene.environment.file && this.configuration.scene.environment.file !== t.scene.environment.file && (i = N.CreateFromPrefilteredData(
|
|
1737
1466
|
t.scene.environment.file,
|
|
1738
1467
|
this.scene
|
|
1739
|
-
), i.name = "updated-environment-cube", this.scene.environmentTexture = i), i && (i.rotationY = t.scene.environment.rotationY), this.scene.environmentIntensity = t.scene.environment.intensity,
|
|
1740
|
-
t.options.
|
|
1741
|
-
) : (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(
|
|
1742
|
-
((s = t.options) == null ? void 0 : s.noPan) !== void 0 ? !t.options.noPan : !0
|
|
1468
|
+
), i.name = "updated-environment-cube", this.scene.environmentTexture = i), i && (i.rotationY = t.scene.environment.rotationY), 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
|
+
t.options?.noPan !== void 0 ? !t.options.noPan : !0
|
|
1743
1470
|
), this.configuration = t;
|
|
1744
1471
|
}
|
|
1745
1472
|
setHighlightMaterials(e) {
|
|
@@ -1759,14 +1486,15 @@ class Yt {
|
|
|
1759
1486
|
this.scene.attachControl(!0, !0, !0);
|
|
1760
1487
|
}
|
|
1761
1488
|
static isSupported() {
|
|
1762
|
-
return
|
|
1489
|
+
return I.isSupported();
|
|
1763
1490
|
}
|
|
1764
1491
|
}
|
|
1765
1492
|
export {
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1493
|
+
S as MaterialEffectMode,
|
|
1494
|
+
F as ProductCameraRig,
|
|
1495
|
+
Ce as REFLECTION_PROBE_RESOLUTION,
|
|
1496
|
+
x as RenderingConfiguration,
|
|
1497
|
+
Tt as SpiffCommerce3DPreviewService,
|
|
1498
|
+
d as renderingPipelineDefaults
|
|
1772
1499
|
};
|
|
1500
|
+
//# sourceMappingURL=index.esm.js.map
|