@spiffcommerce/preview 3.6.2-rc.6 → 3.6.2-rc.7

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.
Files changed (39) hide show
  1. package/dist/_tslib.esm.js +33 -0
  2. package/dist/animation.esm.js +1364 -0
  3. package/dist/assetCache.esm.js +6 -0
  4. package/dist/blurPostProcess.esm.js +327 -0
  5. package/dist/bumpVertex.esm.js +497 -0
  6. package/dist/compatibilityOptions.esm.js +68 -0
  7. package/dist/configuration.esm.js +121 -0
  8. package/dist/core.esm.js +8135 -0
  9. package/dist/dynamicTexture.esm.js +105 -0
  10. package/dist/easing.esm.js +130 -0
  11. package/dist/effectFallbacks.esm.js +378 -0
  12. package/dist/engine.esm.js +25504 -0
  13. package/dist/glbLoaderExtensions.esm.js +690 -0
  14. package/dist/glowLayer.esm.js +1621 -0
  15. package/dist/glowLayerManager.esm.js +50 -0
  16. package/dist/guid.esm.js +21 -0
  17. package/dist/hdrFilteringFunctions.esm.js +816 -0
  18. package/dist/helperFunctions.esm.js +5145 -0
  19. package/dist/index.esm.js +38 -79096
  20. package/dist/material.esm.js +115 -0
  21. package/dist/math.axis.esm.js +35 -0
  22. package/dist/math.color.esm.js +1661 -0
  23. package/dist/math.path.esm.js +15 -0
  24. package/dist/math.size.esm.js +137 -0
  25. package/dist/mesh.esm.js +11170 -0
  26. package/dist/modelContainer.esm.js +1895 -0
  27. package/dist/node.esm.js +795 -0
  28. package/dist/pbrBRDFFunctions.esm.js +122 -2
  29. package/dist/pbrMaterial.esm.js +8747 -0
  30. package/dist/productAnimations.esm.js +182 -0
  31. package/dist/productCamera.esm.js +14 -0
  32. package/dist/renderConstants.esm.js +116 -0
  33. package/dist/renderingPipeline.esm.js +18 -0
  34. package/dist/sceneLoaderFlags.esm.js +51 -0
  35. package/dist/types.esm.js +30 -0
  36. package/dist/variants.esm.js +16 -0
  37. package/dist/webRequest.esm.js +7777 -0
  38. package/package.json +6 -4
  39. package/dist/index.umd.js +0 -10010
@@ -0,0 +1,105 @@
1
+ import { E as Engine } from './engine.esm.js';
2
+ import { P as PBRMaterial } from './pbrMaterial.esm.js';
3
+ import { D as DynamicTexture } from './dynamicTexture.esm2.js';
4
+ import { T as Texture } from './helperFunctions.esm.js';
5
+ import { RenderingConfiguration } from './renderConstants.esm.js';
6
+ import './webRequest.esm.js';
7
+ import './math.color.esm.js';
8
+ import './hdrFilteringFunctions.esm.js';
9
+ import './pbrBRDFFunctions.esm.js';
10
+ import './math.axis.esm.js';
11
+ import './math.path.esm.js';
12
+ import './material.esm2.js';
13
+ import './node.esm.js';
14
+ import './compatibilityOptions.esm.js';
15
+ import './bumpVertex.esm.js';
16
+ import './effectFallbacks.esm.js';
17
+ import './math.size.esm.js';
18
+
19
+ /**
20
+ * Iterates through the given panels and
21
+ * attaches a dynamic texture to the relevant material in the array. This allows changes
22
+ * on the panel to be represented on a 3D model.
23
+ * @param materials The materials to search for the relevant material in. Supply scene.materials if you want to search all materials.
24
+ * @param scene The scene to search for materials in.
25
+ * @param renderableContexts A list of canvas panels associated to the current workflow.
26
+ * @param existingTextures Any generated textures will be stored in this map against the panel name they relate to.
27
+ * @param materialPrefix An optional prefix to apply to the material name when searching for the relevant material.
28
+ * Materials attached to a ModelContainer should all be prefixed with the id of the container.
29
+ */
30
+ function attachDynamicTextures(materials, scene, renderableContexts, existingTextures, materialPrefix = '') {
31
+ renderableContexts.forEach((context) => {
32
+ const contextID = context.getID();
33
+ const contextName = context.getName();
34
+ const renderDims = RenderingConfiguration.getDynamicTextureResolution();
35
+ // Find any materials in the supplied array with the name of
36
+ // this layout and are included in our filter if one is provided.
37
+ const targetMaterials = materials.filter((mat) => {
38
+ return mat.name === materialPrefix + contextName;
39
+ });
40
+ targetMaterials.forEach((mat) => {
41
+ const curDynamicTexture = existingTextures.get(contextID);
42
+ const invertYAxis = false;
43
+ if (!curDynamicTexture) {
44
+ const newTexture = createDynamicTexture(contextName, scene, renderDims.width, renderDims.height);
45
+ existingTextures.set(contextID, newTexture);
46
+ context.setStaticContext(newTexture.getContext());
47
+ applyDynamicTexture(mat, newTexture);
48
+ newTexture.onLoadObservable.addOnce(() => {
49
+ newTexture.update(invertYAxis);
50
+ });
51
+ }
52
+ else {
53
+ applyDynamicTexture(mat, curDynamicTexture);
54
+ curDynamicTexture.update(invertYAxis);
55
+ }
56
+ });
57
+ });
58
+ }
59
+ /**
60
+ * Construct a new dynamic texture to listen for changes to a panel.
61
+ * @param scene The screen the resource will be associated to.
62
+ * @param layoutKey The key for the layout this dynamic texture relates to.
63
+ * @param RenderableContextService The canvas service, used to pull the layout with the given key.
64
+ */
65
+ function createDynamicTexture(name, scene, width, height) {
66
+ const dynamicTex = new DynamicTexture(name, { width, height }, scene, RenderingConfiguration.shouldMipMap(), Texture.TRILINEAR_SAMPLINGMODE, Engine.TEXTUREFORMAT_RGBA);
67
+ const ctx = dynamicTex.getContext();
68
+ if (ctx) {
69
+ ctx.fillStyle = '#f5f5f5';
70
+ ctx.fillRect(0, 0, width, height);
71
+ dynamicTex.update();
72
+ }
73
+ return dynamicTex;
74
+ }
75
+ /**
76
+ * Applies a given dynamic texture to a target material.
77
+ * @param mat The material to apply to.
78
+ * @param dynamicTexture The dynamic texture we want to apply.
79
+ */
80
+ function applyDynamicTexture(mat, dynamicTexture) {
81
+ if (mat instanceof PBRMaterial) {
82
+ const pbrMat = mat;
83
+ const albedoTexture = pbrMat.albedoTexture;
84
+ if (albedoTexture) {
85
+ dynamicTexture.wrapU = albedoTexture.wrapU;
86
+ dynamicTexture.wrapV = albedoTexture.wrapV;
87
+ }
88
+ else {
89
+ dynamicTexture.wrapU = 1;
90
+ dynamicTexture.wrapV = 1;
91
+ }
92
+ pbrMat.albedoTexture = dynamicTexture;
93
+ }
94
+ else {
95
+ const standardMat = mat;
96
+ const diffuseTexture = standardMat.diffuseTexture;
97
+ if (diffuseTexture) {
98
+ dynamicTexture.wrapU = diffuseTexture.wrapU;
99
+ dynamicTexture.wrapV = diffuseTexture.wrapV;
100
+ }
101
+ standardMat.diffuseTexture = dynamicTexture;
102
+ }
103
+ }
104
+
105
+ export { attachDynamicTextures };
@@ -0,0 +1,130 @@
1
+ import './math.path.esm.js';
2
+
3
+ /**
4
+ * Base class used for every default easing function.
5
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/animation/advanced_animations#easing-functions
6
+ */
7
+ class EasingFunction {
8
+ constructor() {
9
+ this._easingMode = EasingFunction.EASINGMODE_EASEIN;
10
+ }
11
+ /**
12
+ * Sets the easing mode of the current function.
13
+ * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
14
+ */
15
+ setEasingMode(easingMode) {
16
+ const n = Math.min(Math.max(easingMode, 0), 2);
17
+ this._easingMode = n;
18
+ }
19
+ /**
20
+ * Gets the current easing mode.
21
+ * @returns the easing mode
22
+ */
23
+ getEasingMode() {
24
+ return this._easingMode;
25
+ }
26
+ /**
27
+ * @internal
28
+ */
29
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
30
+ easeInCore(gradient) {
31
+ throw new Error("You must implement this method");
32
+ }
33
+ /**
34
+ * Given an input gradient between 0 and 1, this returns the corresponding value
35
+ * of the easing function.
36
+ * @param gradient Defines the value between 0 and 1 we want the easing value for
37
+ * @returns the corresponding value on the curve defined by the easing function
38
+ */
39
+ ease(gradient) {
40
+ switch (this._easingMode) {
41
+ case EasingFunction.EASINGMODE_EASEIN:
42
+ return this.easeInCore(gradient);
43
+ case EasingFunction.EASINGMODE_EASEOUT:
44
+ return 1 - this.easeInCore(1 - gradient);
45
+ }
46
+ if (gradient >= 0.5) {
47
+ return (1 - this.easeInCore((1 - gradient) * 2)) * 0.5 + 0.5;
48
+ }
49
+ return this.easeInCore(gradient * 2) * 0.5;
50
+ }
51
+ }
52
+ /**
53
+ * Interpolation follows the mathematical formula associated with the easing function.
54
+ */
55
+ EasingFunction.EASINGMODE_EASEIN = 0;
56
+ /**
57
+ * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
58
+ */
59
+ EasingFunction.EASINGMODE_EASEOUT = 1;
60
+ /**
61
+ * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
62
+ */
63
+ EasingFunction.EASINGMODE_EASEINOUT = 2;
64
+ /**
65
+ * Easing function with a ease back shape (see link below).
66
+ * @see https://easings.net/#easeInBack
67
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/animation/advanced_animations#easing-functions
68
+ */
69
+ class BackEase extends EasingFunction {
70
+ /**
71
+ * Instantiates a back ease easing
72
+ * @see https://easings.net/#easeInBack
73
+ * @param amplitude Defines the amplitude of the function
74
+ */
75
+ constructor(
76
+ /** Defines the amplitude of the function */
77
+ amplitude = 1) {
78
+ super();
79
+ this.amplitude = amplitude;
80
+ }
81
+ /**
82
+ * @internal
83
+ */
84
+ easeInCore(gradient) {
85
+ const num = Math.max(0, this.amplitude);
86
+ return Math.pow(gradient, 3.0) - gradient * num * Math.sin(3.1415926535897931 * gradient);
87
+ }
88
+ }
89
+ /**
90
+ * Easing function with an exponential shape (see link below).
91
+ * @see https://easings.net/#easeInExpo
92
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/animation/advanced_animations#easing-functions
93
+ */
94
+ class ExponentialEase extends EasingFunction {
95
+ /**
96
+ * Instantiates an exponential easing function
97
+ * @see https://easings.net/#easeInExpo
98
+ * @param exponent Defines the exponent of the function
99
+ */
100
+ constructor(
101
+ /** Defines the exponent of the function */
102
+ exponent = 2) {
103
+ super();
104
+ this.exponent = exponent;
105
+ }
106
+ /**
107
+ * @internal
108
+ */
109
+ easeInCore(gradient) {
110
+ if (this.exponent <= 0) {
111
+ return gradient;
112
+ }
113
+ return (Math.exp(this.exponent * gradient) - 1.0) / (Math.exp(this.exponent) - 1.0);
114
+ }
115
+ }
116
+ /**
117
+ * Easing function with a power of 2 shape (see link below).
118
+ * @see https://easings.net/#easeInQuad
119
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/animation/advanced_animations#easing-functions
120
+ */
121
+ class QuadraticEase extends EasingFunction {
122
+ /**
123
+ * @internal
124
+ */
125
+ easeInCore(gradient) {
126
+ return gradient * gradient;
127
+ }
128
+ }
129
+
130
+ export { BackEase as B, EasingFunction as E, QuadraticEase as Q, ExponentialEase as a };
@@ -0,0 +1,378 @@
1
+ import { e as ShaderStore } from './engine.esm.js';
2
+
3
+ // Do not edit.
4
+ const name$d = "clipPlaneFragmentDeclaration";
5
+ const shader$d = `#ifdef CLIPPLANE
6
+ varying float fClipDistance;
7
+ #ifdef CLIPPLANE2
8
+ varying float fClipDistance2;
9
+ #ifdef CLIPPLANE3
10
+ varying float fClipDistance3;
11
+ #ifdef CLIPPLANE4
12
+ varying float fClipDistance4;
13
+ #ifdef CLIPPLANE5
14
+ varying float fClipDistance5;
15
+ #ifdef CLIPPLANE6
16
+ varying float fClipDistance6;
17
+ `;
18
+ // Sideeffect
19
+ ShaderStore.IncludesShadersStore[name$d] = shader$d;
20
+
21
+ // Do not edit.
22
+ const name$c = "clipPlaneFragment";
23
+ const shader$c = `#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)
24
+ if (false) {}
25
+ #ifdef CLIPPLANE
26
+ else if (fClipDistance>0.0)
27
+ #ifdef CLIPPLANE2
28
+ else if (fClipDistance2>0.0)
29
+ #ifdef CLIPPLANE3
30
+ else if (fClipDistance3>0.0)
31
+ #ifdef CLIPPLANE4
32
+ else if (fClipDistance4>0.0)
33
+ #ifdef CLIPPLANE5
34
+ else if (fClipDistance5>0.0)
35
+ #ifdef CLIPPLANE6
36
+ else if (fClipDistance6>0.0)
37
+ `;
38
+ // Sideeffect
39
+ ShaderStore.IncludesShadersStore[name$c] = shader$c;
40
+
41
+ // Do not edit.
42
+ const name$b = "bonesDeclaration";
43
+ const shader$b = `#if NUM_BONE_INFLUENCERS>0
44
+ attribute vec4 matricesIndices;
45
+ attribute vec4 matricesIndicesExtra;
46
+ #ifndef BAKED_VERTEX_ANIMATION_TEXTURE
47
+ #ifdef BONETEXTURE
48
+ uniform sampler2D boneSampler;
49
+ uniform mat4 mBones[BonesPerMesh];
50
+ uniform mat4 mPreviousBones[BonesPerMesh];
51
+ #endif
52
+ #ifdef BONETEXTURE
53
+ #define inline
54
+ mat4 readMatrixFromRawSampler(sampler2D smp,float index)
55
+ #endif
56
+ #endif
57
+ `;
58
+ // Sideeffect
59
+ ShaderStore.IncludesShadersStore[name$b] = shader$b;
60
+
61
+ // Do not edit.
62
+ const name$a = "bakedVertexAnimationDeclaration";
63
+ const shader$a = `#ifdef BAKED_VERTEX_ANIMATION_TEXTURE
64
+ uniform float bakedVertexAnimationTime;
65
+ attribute vec4 bakedVertexAnimationSettingsInstanced;
66
+ #define inline
67
+ mat4 readMatrixFromRawSamplerVAT(sampler2D smp,float index,float frame)
68
+ `;
69
+ // Sideeffect
70
+ ShaderStore.IncludesShadersStore[name$a] = shader$a;
71
+
72
+ // Do not edit.
73
+ const name$9 = "morphTargetsVertexGlobalDeclaration";
74
+ const shader$9 = `#ifdef MORPHTARGETS
75
+ uniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS];
76
+ precision mediump sampler2DArray;
77
+ #endif
78
+ `;
79
+ // Sideeffect
80
+ ShaderStore.IncludesShadersStore[name$9] = shader$9;
81
+
82
+ // Do not edit.
83
+ const name$8 = "morphTargetsVertexDeclaration";
84
+ const shader$8 = `#ifdef MORPHTARGETS
85
+ #ifndef MORPHTARGETS_TEXTURE
86
+ attribute vec3 position{X};
87
+ attribute vec3 normal{X};
88
+ #ifdef MORPHTARGETS_TANGENT
89
+ attribute vec3 tangent{X};
90
+ #ifdef MORPHTARGETS_UV
91
+ attribute vec2 uv_{X};
92
+ #endif
93
+ #endif
94
+ `;
95
+ // Sideeffect
96
+ ShaderStore.IncludesShadersStore[name$8] = shader$8;
97
+
98
+ // Do not edit.
99
+ const name$7 = "clipPlaneVertexDeclaration";
100
+ const shader$7 = `#ifdef CLIPPLANE
101
+ uniform vec4 vClipPlane;
102
+ #ifdef CLIPPLANE2
103
+ uniform vec4 vClipPlane2;
104
+ #ifdef CLIPPLANE3
105
+ uniform vec4 vClipPlane3;
106
+ #ifdef CLIPPLANE4
107
+ uniform vec4 vClipPlane4;
108
+ #ifdef CLIPPLANE5
109
+ uniform vec4 vClipPlane5;
110
+ #ifdef CLIPPLANE6
111
+ uniform vec4 vClipPlane6;
112
+ `;
113
+ // Sideeffect
114
+ ShaderStore.IncludesShadersStore[name$7] = shader$7;
115
+
116
+ // Do not edit.
117
+ const name$6 = "instancesDeclaration";
118
+ const shader$6 = `#ifdef INSTANCES
119
+ attribute vec4 world0;
120
+ attribute vec4 instanceColor;
121
+ #if defined(THIN_INSTANCES) && !defined(WORLD_UBO)
122
+ uniform mat4 world;
123
+ #if defined(VELOCITY) || defined(PREPASS_VELOCITY)
124
+ attribute vec4 previousWorld0;
125
+ uniform mat4 previousWorld;
126
+ #endif
127
+ #else
128
+ #if !defined(WORLD_UBO)
129
+ uniform mat4 world;
130
+ #if defined(VELOCITY) || defined(PREPASS_VELOCITY)
131
+ uniform mat4 previousWorld;
132
+ #endif
133
+ `;
134
+ // Sideeffect
135
+ ShaderStore.IncludesShadersStore[name$6] = shader$6;
136
+
137
+ // Do not edit.
138
+ const name$5 = "morphTargetsVertexGlobal";
139
+ const shader$5 = `#ifdef MORPHTARGETS
140
+ #ifdef MORPHTARGETS_TEXTURE
141
+ float vertexID;
142
+ #endif
143
+ `;
144
+ // Sideeffect
145
+ ShaderStore.IncludesShadersStore[name$5] = shader$5;
146
+
147
+ // Do not edit.
148
+ const name$4 = "morphTargetsVertex";
149
+ const shader$4 = `#ifdef MORPHTARGETS
150
+ #ifdef MORPHTARGETS_TEXTURE
151
+ vertexID=float(gl_VertexID)*morphTargetTextureInfo.x;
152
+ normalUpdated+=(readVector3FromRawSampler({X},vertexID) -normal)*morphTargetInfluences[{X}];
153
+ #ifdef MORPHTARGETS_UV
154
+ uvUpdated+=(readVector3FromRawSampler({X},vertexID).xy-uv)*morphTargetInfluences[{X}];
155
+ #ifdef MORPHTARGETS_TANGENT
156
+ tangentUpdated.xyz+=(readVector3FromRawSampler({X},vertexID) -tangent.xyz)*morphTargetInfluences[{X}];
157
+ #else
158
+ positionUpdated+=(position{X}-position)*morphTargetInfluences[{X}];
159
+ normalUpdated+=(normal{X}-normal)*morphTargetInfluences[{X}];
160
+ #ifdef MORPHTARGETS_TANGENT
161
+ tangentUpdated.xyz+=(tangent{X}-tangent.xyz)*morphTargetInfluences[{X}];
162
+ #ifdef MORPHTARGETS_UV
163
+ uvUpdated+=(uv_{X}-uv)*morphTargetInfluences[{X}];
164
+ #endif
165
+ #endif
166
+ `;
167
+ // Sideeffect
168
+ ShaderStore.IncludesShadersStore[name$4] = shader$4;
169
+
170
+ // Do not edit.
171
+ const name$3 = "instancesVertex";
172
+ const shader$3 = `#ifdef INSTANCES
173
+ mat4 finalWorld=mat4(world0,world1,world2,world3);
174
+ mat4 finalPreviousWorld=mat4(previousWorld0,previousWorld1,previousWorld2,previousWorld3);
175
+ #ifdef THIN_INSTANCES
176
+ finalWorld=world*finalWorld;
177
+ finalPreviousWorld=previousWorld*finalPreviousWorld;
178
+ #endif
179
+ #else
180
+ mat4 finalWorld=world;
181
+ mat4 finalPreviousWorld=previousWorld;
182
+ #endif
183
+ `;
184
+ // Sideeffect
185
+ ShaderStore.IncludesShadersStore[name$3] = shader$3;
186
+
187
+ // Do not edit.
188
+ const name$2 = "bonesVertex";
189
+ const shader$2 = `#ifndef BAKED_VERTEX_ANIMATION_TEXTURE
190
+ #if NUM_BONE_INFLUENCERS>0
191
+ mat4 influence;
192
+ influence=readMatrixFromRawSampler(boneSampler,matricesIndices[0])*matricesWeights[0];
193
+ influence+=readMatrixFromRawSampler(boneSampler,matricesIndices[1])*matricesWeights[1];
194
+ #if NUM_BONE_INFLUENCERS>2
195
+ influence+=readMatrixFromRawSampler(boneSampler,matricesIndices[2])*matricesWeights[2];
196
+ #if NUM_BONE_INFLUENCERS>3
197
+ influence+=readMatrixFromRawSampler(boneSampler,matricesIndices[3])*matricesWeights[3];
198
+ #if NUM_BONE_INFLUENCERS>4
199
+ influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[0])*matricesWeightsExtra[0];
200
+ #if NUM_BONE_INFLUENCERS>5
201
+ influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[1])*matricesWeightsExtra[1];
202
+ #if NUM_BONE_INFLUENCERS>6
203
+ influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[2])*matricesWeightsExtra[2];
204
+ #if NUM_BONE_INFLUENCERS>7
205
+ influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[3])*matricesWeightsExtra[3];
206
+ #else
207
+ influence=mBones[int(matricesIndices[0])]*matricesWeights[0];
208
+ influence+=mBones[int(matricesIndices[1])]*matricesWeights[1];
209
+ #if NUM_BONE_INFLUENCERS>2
210
+ influence+=mBones[int(matricesIndices[2])]*matricesWeights[2];
211
+ #if NUM_BONE_INFLUENCERS>3
212
+ influence+=mBones[int(matricesIndices[3])]*matricesWeights[3];
213
+ #if NUM_BONE_INFLUENCERS>4
214
+ influence+=mBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];
215
+ #if NUM_BONE_INFLUENCERS>5
216
+ influence+=mBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];
217
+ #if NUM_BONE_INFLUENCERS>6
218
+ influence+=mBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];
219
+ #if NUM_BONE_INFLUENCERS>7
220
+ influence+=mBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];
221
+ #endif
222
+ finalWorld=finalWorld*influence;
223
+ #endif
224
+ `;
225
+ // Sideeffect
226
+ ShaderStore.IncludesShadersStore[name$2] = shader$2;
227
+
228
+ // Do not edit.
229
+ const name$1 = "bakedVertexAnimation";
230
+ const shader$1 = `#ifdef BAKED_VERTEX_ANIMATION_TEXTURE
231
+ {
232
+ #define BVASNAME bakedVertexAnimationSettingsInstanced
233
+ #else
234
+ #define BVASNAME bakedVertexAnimationSettings
235
+ #endif
236
+ float VATStartFrame=BVASNAME.x;
237
+ VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[1],VATFrameNum)*matricesWeights[1];
238
+ #if NUM_BONE_INFLUENCERS>2
239
+ VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[2],VATFrameNum)*matricesWeights[2];
240
+ #if NUM_BONE_INFLUENCERS>3
241
+ VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[3],VATFrameNum)*matricesWeights[3];
242
+ #if NUM_BONE_INFLUENCERS>4
243
+ VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[0],VATFrameNum)*matricesWeightsExtra[0];
244
+ #if NUM_BONE_INFLUENCERS>5
245
+ VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[1],VATFrameNum)*matricesWeightsExtra[1];
246
+ #if NUM_BONE_INFLUENCERS>6
247
+ VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[2],VATFrameNum)*matricesWeightsExtra[2];
248
+ #if NUM_BONE_INFLUENCERS>7
249
+ VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[3],VATFrameNum)*matricesWeightsExtra[3];
250
+ finalWorld=finalWorld*VATInfluence;
251
+ `;
252
+ // Sideeffect
253
+ ShaderStore.IncludesShadersStore[name$1] = shader$1;
254
+
255
+ // Do not edit.
256
+ const name = "clipPlaneVertex";
257
+ const shader = `#ifdef CLIPPLANE
258
+ fClipDistance=dot(worldPos,vClipPlane);
259
+ #ifdef CLIPPLANE2
260
+ fClipDistance2=dot(worldPos,vClipPlane2);
261
+ #ifdef CLIPPLANE3
262
+ fClipDistance3=dot(worldPos,vClipPlane3);
263
+ #ifdef CLIPPLANE4
264
+ fClipDistance4=dot(worldPos,vClipPlane4);
265
+ #ifdef CLIPPLANE5
266
+ fClipDistance5=dot(worldPos,vClipPlane5);
267
+ #ifdef CLIPPLANE6
268
+ fClipDistance6=dot(worldPos,vClipPlane6);
269
+ `;
270
+ // Sideeffect
271
+ ShaderStore.IncludesShadersStore[name] = shader;
272
+
273
+ /**
274
+ * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
275
+ * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
276
+ */
277
+ class EffectFallbacks {
278
+ constructor() {
279
+ this._defines = {};
280
+ this._currentRank = 32;
281
+ this._maxRank = -1;
282
+ this._mesh = null;
283
+ }
284
+ /**
285
+ * Removes the fallback from the bound mesh.
286
+ */
287
+ unBindMesh() {
288
+ this._mesh = null;
289
+ }
290
+ /**
291
+ * Adds a fallback on the specified property.
292
+ * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
293
+ * @param define The name of the define in the shader
294
+ */
295
+ addFallback(rank, define) {
296
+ if (!this._defines[rank]) {
297
+ if (rank < this._currentRank) {
298
+ this._currentRank = rank;
299
+ }
300
+ if (rank > this._maxRank) {
301
+ this._maxRank = rank;
302
+ }
303
+ this._defines[rank] = new Array();
304
+ }
305
+ this._defines[rank].push(define);
306
+ }
307
+ /**
308
+ * Sets the mesh to use CPU skinning when needing to fallback.
309
+ * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
310
+ * @param mesh The mesh to use the fallbacks.
311
+ */
312
+ addCPUSkinningFallback(rank, mesh) {
313
+ this._mesh = mesh;
314
+ if (rank < this._currentRank) {
315
+ this._currentRank = rank;
316
+ }
317
+ if (rank > this._maxRank) {
318
+ this._maxRank = rank;
319
+ }
320
+ }
321
+ /**
322
+ * Checks to see if more fallbacks are still available.
323
+ */
324
+ get hasMoreFallbacks() {
325
+ return this._currentRank <= this._maxRank;
326
+ }
327
+ /**
328
+ * Removes the defines that should be removed when falling back.
329
+ * @param currentDefines defines the current define statements for the shader.
330
+ * @param effect defines the current effect we try to compile
331
+ * @returns The resulting defines with defines of the current rank removed.
332
+ */
333
+ reduce(currentDefines, effect) {
334
+ // First we try to switch to CPU skinning
335
+ if (this._mesh && this._mesh.computeBonesUsingShaders && this._mesh.numBoneInfluencers > 0) {
336
+ this._mesh.computeBonesUsingShaders = false;
337
+ currentDefines = currentDefines.replace("#define NUM_BONE_INFLUENCERS " + this._mesh.numBoneInfluencers, "#define NUM_BONE_INFLUENCERS 0");
338
+ effect._bonesComputationForcedToCPU = true;
339
+ const scene = this._mesh.getScene();
340
+ for (let index = 0; index < scene.meshes.length; index++) {
341
+ const otherMesh = scene.meshes[index];
342
+ if (!otherMesh.material) {
343
+ if (!this._mesh.material && otherMesh.computeBonesUsingShaders && otherMesh.numBoneInfluencers > 0) {
344
+ otherMesh.computeBonesUsingShaders = false;
345
+ }
346
+ continue;
347
+ }
348
+ if (!otherMesh.computeBonesUsingShaders || otherMesh.numBoneInfluencers === 0) {
349
+ continue;
350
+ }
351
+ if (otherMesh.material.getEffect() === effect) {
352
+ otherMesh.computeBonesUsingShaders = false;
353
+ }
354
+ else if (otherMesh.subMeshes) {
355
+ for (const subMesh of otherMesh.subMeshes) {
356
+ const subMeshEffect = subMesh.effect;
357
+ if (subMeshEffect === effect) {
358
+ otherMesh.computeBonesUsingShaders = false;
359
+ break;
360
+ }
361
+ }
362
+ }
363
+ }
364
+ }
365
+ else {
366
+ const currentFallbacks = this._defines[this._currentRank];
367
+ if (currentFallbacks) {
368
+ for (let index = 0; index < currentFallbacks.length; index++) {
369
+ currentDefines = currentDefines.replace("#define " + currentFallbacks[index], "");
370
+ }
371
+ }
372
+ this._currentRank++;
373
+ }
374
+ return currentDefines;
375
+ }
376
+ }
377
+
378
+ export { EffectFallbacks as E };