@spiffcommerce/preview 3.6.2-rc.8 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/index.esm.js +1576 -38
  2. package/dist/index.umd.js +1 -0
  3. package/package.json +4 -6
  4. package/dist/_tslib.esm.js +0 -33
  5. package/dist/animation.esm.js +0 -1364
  6. package/dist/assetCache.esm.js +0 -6
  7. package/dist/assetCache.esm2.js +0 -825
  8. package/dist/blurPostProcess.esm.js +0 -327
  9. package/dist/bumpVertex.esm.js +0 -497
  10. package/dist/compatibilityOptions.esm.js +0 -68
  11. package/dist/configuration.esm.js +0 -121
  12. package/dist/core.esm.js +0 -8135
  13. package/dist/dynamicTexture.esm.js +0 -105
  14. package/dist/dynamicTexture.esm2.js +0 -238
  15. package/dist/easing.esm.js +0 -130
  16. package/dist/effectFallbacks.esm.js +0 -378
  17. package/dist/engine.esm.js +0 -25504
  18. package/dist/glbLoaderExtensions.esm.js +0 -690
  19. package/dist/glowLayer.esm.js +0 -1621
  20. package/dist/glowLayerManager.esm.js +0 -50
  21. package/dist/guid.esm.js +0 -21
  22. package/dist/hdrFilteringFunctions.esm.js +0 -816
  23. package/dist/helperFunctions.esm.js +0 -5145
  24. package/dist/material.esm.js +0 -115
  25. package/dist/material.esm2.js +0 -5245
  26. package/dist/math.axis.esm.js +0 -35
  27. package/dist/math.color.esm.js +0 -1661
  28. package/dist/math.path.esm.js +0 -15
  29. package/dist/math.size.esm.js +0 -137
  30. package/dist/mesh.esm.js +0 -11170
  31. package/dist/modelContainer.esm.js +0 -1895
  32. package/dist/node.esm.js +0 -795
  33. package/dist/pbrBRDFFunctions.esm.js +0 -124
  34. package/dist/pbrMaterial.esm.js +8 -8739
  35. package/dist/productAnimations.esm.js +0 -182
  36. package/dist/productCamera.esm.js +0 -14
  37. package/dist/productCamera.esm2.js +0 -3870
  38. package/dist/renderConstants.esm.js +0 -116
  39. package/dist/renderingPipeline.esm.js +0 -18
  40. package/dist/renderingPipeline.esm2.js +1 -3594
  41. package/dist/sceneLoaderFlags.esm.js +0 -51
  42. package/dist/types.esm.js +0 -30
  43. package/dist/variants.esm.js +0 -16
  44. package/dist/variants.esm2.js +0 -3097
  45. package/dist/webRequest.esm.js +0 -7777
@@ -1,327 +0,0 @@
1
- import { _ as __decorate, S as SerializationHelper, s as serialize, h as serializeAsVector2 } from './webRequest.esm.js';
2
- import { P as PostProcess, T as Texture } from './helperFunctions.esm.js';
3
- import { e as ShaderStore } from './engine.esm.js';
4
- import { R as RegisterClass } from './math.color.esm.js';
5
-
6
- // Do not edit.
7
- const name$6 = "kernelBlurVaryingDeclaration";
8
- const shader$6 = `varying vec2 sampleCoord{X};`;
9
- // Sideeffect
10
- ShaderStore.IncludesShadersStore[name$6] = shader$6;
11
-
12
- // Do not edit.
13
- const name$5 = "packingFunctions";
14
- const shader$5 = `vec4 pack(float depth)
15
- // Sideeffect
16
- ShaderStore.IncludesShadersStore[name$5] = shader$5;
17
-
18
- // Do not edit.
19
- const name$4 = "kernelBlurFragment";
20
- const shader$4 = `#ifdef DOF
21
- factor=sampleCoC(sampleCoord{X});
22
- computedWeight=KERNEL_WEIGHT{X};
23
- #ifdef PACKEDFLOAT
24
- blend+=unpack(texture2D(textureSampler,sampleCoord{X}))*computedWeight;
25
- blend+=texture2D(textureSampler,sampleCoord{X})*computedWeight;
26
- `;
27
- // Sideeffect
28
- ShaderStore.IncludesShadersStore[name$4] = shader$4;
29
-
30
- // Do not edit.
31
- const name$3 = "kernelBlurFragment2";
32
- const shader$3 = `#ifdef DOF
33
- factor=sampleCoC(sampleCenter+delta*KERNEL_DEP_OFFSET{X});
34
- computedWeight=KERNEL_DEP_WEIGHT{X};
35
- #ifdef PACKEDFLOAT
36
- blend+=unpack(texture2D(textureSampler,sampleCenter+delta*KERNEL_DEP_OFFSET{X}))*computedWeight;
37
- blend+=texture2D(textureSampler,sampleCenter+delta*KERNEL_DEP_OFFSET{X})*computedWeight;
38
- `;
39
- // Sideeffect
40
- ShaderStore.IncludesShadersStore[name$3] = shader$3;
41
-
42
- // Do not edit.
43
- const name$2 = "kernelBlurPixelShader";
44
- const shader$2 = `uniform sampler2D textureSampler;
45
- uniform sampler2D circleOfConfusionSampler;
46
- #include<kernelBlurVaryingDeclaration>[0..varyingCount]
47
- #ifdef PACKEDFLOAT
48
- #include<packingFunctions>
49
- #endif
50
- #define CUSTOM_FRAGMENT_DEFINITIONS
51
- void main(void)
52
- float blend=0.;
53
- vec4 blend=vec4(0.);
54
- #ifdef DOF
55
- float sumOfWeights=CENTER_WEIGHT;
56
- blend+=unpack(texture2D(textureSampler,sampleCenter))*CENTER_WEIGHT;
57
- blend+=texture2D(textureSampler,sampleCenter)*CENTER_WEIGHT;
58
- #endif
59
- #include<kernelBlurFragment>[0..varyingCount]
60
- #include<kernelBlurFragment2>[0..depCount]
61
- #ifdef PACKEDFLOAT
62
- gl_FragColor=pack(blend);
63
- gl_FragColor=blend;
64
- #ifdef DOF
65
- gl_FragColor/=sumOfWeights;
66
- }`;
67
- // Sideeffect
68
- ShaderStore.ShadersStore[name$2] = shader$2;
69
-
70
- // Do not edit.
71
- const name$1 = "kernelBlurVertex";
72
- const shader$1 = `sampleCoord{X}=sampleCenter+delta*KERNEL_OFFSET{X};`;
73
- // Sideeffect
74
- ShaderStore.IncludesShadersStore[name$1] = shader$1;
75
-
76
- // Do not edit.
77
- const name = "kernelBlurVertexShader";
78
- const shader = `attribute vec2 position;
79
- const vec2 madd=vec2(0.5,0.5);
80
- void main(void) {
81
- sampleCenter=(position*madd+madd);
82
- gl_Position=vec4(position,0.0,1.0);
83
- }`;
84
- // Sideeffect
85
- ShaderStore.ShadersStore[name] = shader;
86
-
87
- /**
88
- * The Blur Post Process which blurs an image based on a kernel and direction.
89
- * Can be used twice in x and y directions to perform a gaussian blur in two passes.
90
- */
91
- class BlurPostProcess extends PostProcess {
92
- /**
93
- * Sets the length in pixels of the blur sample region
94
- */
95
- set kernel(v) {
96
- if (this._idealKernel === v) {
97
- return;
98
- }
99
- v = Math.max(v, 1);
100
- this._idealKernel = v;
101
- this._kernel = this._nearestBestKernel(v);
102
- if (!this._blockCompilation) {
103
- this._updateParameters();
104
- }
105
- }
106
- /**
107
- * Gets the length in pixels of the blur sample region
108
- */
109
- get kernel() {
110
- return this._idealKernel;
111
- }
112
- /**
113
- * Sets whether or not the blur needs to unpack/repack floats
114
- */
115
- set packedFloat(v) {
116
- if (this._packedFloat === v) {
117
- return;
118
- }
119
- this._packedFloat = v;
120
- if (!this._blockCompilation) {
121
- this._updateParameters();
122
- }
123
- }
124
- /**
125
- * Gets whether or not the blur is unpacking/repacking floats
126
- */
127
- get packedFloat() {
128
- return this._packedFloat;
129
- }
130
- /**
131
- * Gets a string identifying the name of the class
132
- * @returns "BlurPostProcess" string
133
- */
134
- getClassName() {
135
- return "BlurPostProcess";
136
- }
137
- /**
138
- * Creates a new instance BlurPostProcess
139
- * @param name The name of the effect.
140
- * @param direction The direction in which to blur the image.
141
- * @param kernel The size of the kernel to be used when computing the blur. eg. Size of 3 will blur the center pixel by 2 pixels surrounding it.
142
- * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
143
- * @param camera The camera to apply the render pass to.
144
- * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
145
- * @param engine The engine which the post process will be applied. (default: current engine)
146
- * @param reusable If the post process can be reused on the same frame. (default: false)
147
- * @param textureType Type of textures used when performing the post process. (default: 0)
148
- * @param defines
149
- * @param _blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
150
- * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
151
- */
152
- constructor(name, direction, kernel, options, camera, samplingMode = Texture.BILINEAR_SAMPLINGMODE, engine, reusable, textureType = 0, defines = "", _blockCompilation = false, textureFormat = 5) {
153
- super(name, "kernelBlur", ["delta", "direction"], ["circleOfConfusionSampler"], options, camera, samplingMode, engine, reusable, null, textureType, "kernelBlur", { varyingCount: 0, depCount: 0 }, true, textureFormat);
154
- this._blockCompilation = _blockCompilation;
155
- this._packedFloat = false;
156
- this._staticDefines = "";
157
- this._staticDefines = defines;
158
- this.direction = direction;
159
- this.onApplyObservable.add((effect) => {
160
- if (this._outputTexture) {
161
- effect.setFloat2("delta", (1 / this._outputTexture.width) * this.direction.x, (1 / this._outputTexture.height) * this.direction.y);
162
- }
163
- else {
164
- effect.setFloat2("delta", (1 / this.width) * this.direction.x, (1 / this.height) * this.direction.y);
165
- }
166
- });
167
- this.kernel = kernel;
168
- }
169
- /**
170
- * Updates the effect with the current post process compile time values and recompiles the shader.
171
- * @param defines Define statements that should be added at the beginning of the shader. (default: null)
172
- * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
173
- * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
174
- * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
175
- * @param onCompiled Called when the shader has been compiled.
176
- * @param onError Called if there is an error when compiling a shader.
177
- */
178
- updateEffect(defines = null, uniforms = null, samplers = null, indexParameters, onCompiled, onError) {
179
- this._updateParameters(onCompiled, onError);
180
- }
181
- _updateParameters(onCompiled, onError) {
182
- // Generate sampling offsets and weights
183
- const N = this._kernel;
184
- const centerIndex = (N - 1) / 2;
185
- // Generate Gaussian sampling weights over kernel
186
- let offsets = [];
187
- let weights = [];
188
- let totalWeight = 0;
189
- for (let i = 0; i < N; i++) {
190
- const u = i / (N - 1);
191
- const w = this._gaussianWeight(u * 2.0 - 1);
192
- offsets[i] = i - centerIndex;
193
- weights[i] = w;
194
- totalWeight += w;
195
- }
196
- // Normalize weights
197
- for (let i = 0; i < weights.length; i++) {
198
- weights[i] /= totalWeight;
199
- }
200
- // Optimize: combine samples to take advantage of hardware linear sampling
201
- // Walk from left to center, combining pairs (symmetrically)
202
- const linearSamplingWeights = [];
203
- const linearSamplingOffsets = [];
204
- const linearSamplingMap = [];
205
- for (let i = 0; i <= centerIndex; i += 2) {
206
- const j = Math.min(i + 1, Math.floor(centerIndex));
207
- const singleCenterSample = i === j;
208
- if (singleCenterSample) {
209
- linearSamplingMap.push({ o: offsets[i], w: weights[i] });
210
- }
211
- else {
212
- const sharedCell = j === centerIndex;
213
- const weightLinear = weights[i] + weights[j] * (sharedCell ? 0.5 : 1);
214
- const offsetLinear = offsets[i] + 1 / (1 + weights[i] / weights[j]);
215
- if (offsetLinear === 0) {
216
- linearSamplingMap.push({ o: offsets[i], w: weights[i] });
217
- linearSamplingMap.push({ o: offsets[i + 1], w: weights[i + 1] });
218
- }
219
- else {
220
- linearSamplingMap.push({ o: offsetLinear, w: weightLinear });
221
- linearSamplingMap.push({ o: -offsetLinear, w: weightLinear });
222
- }
223
- }
224
- }
225
- for (let i = 0; i < linearSamplingMap.length; i++) {
226
- linearSamplingOffsets[i] = linearSamplingMap[i].o;
227
- linearSamplingWeights[i] = linearSamplingMap[i].w;
228
- }
229
- // Replace with optimized
230
- offsets = linearSamplingOffsets;
231
- weights = linearSamplingWeights;
232
- // Generate shaders
233
- const maxVaryingRows = this.getEngine().getCaps().maxVaryingVectors;
234
- const freeVaryingVec2 = Math.max(maxVaryingRows, 0) - 1; // Because of sampleCenter
235
- let varyingCount = Math.min(offsets.length, freeVaryingVec2);
236
- let defines = "";
237
- defines += this._staticDefines;
238
- // The DOF fragment should ignore the center pixel when looping as it is handled manually in the fragment shader.
239
- if (this._staticDefines.indexOf("DOF") != -1) {
240
- defines += `#define CENTER_WEIGHT ${this._glslFloat(weights[varyingCount - 1])}\r\n`;
241
- varyingCount--;
242
- }
243
- for (let i = 0; i < varyingCount; i++) {
244
- defines += `#define KERNEL_OFFSET${i} ${this._glslFloat(offsets[i])}\r\n`;
245
- defines += `#define KERNEL_WEIGHT${i} ${this._glslFloat(weights[i])}\r\n`;
246
- }
247
- let depCount = 0;
248
- for (let i = freeVaryingVec2; i < offsets.length; i++) {
249
- defines += `#define KERNEL_DEP_OFFSET${depCount} ${this._glslFloat(offsets[i])}\r\n`;
250
- defines += `#define KERNEL_DEP_WEIGHT${depCount} ${this._glslFloat(weights[i])}\r\n`;
251
- depCount++;
252
- }
253
- if (this.packedFloat) {
254
- defines += `#define PACKEDFLOAT 1`;
255
- }
256
- this._blockCompilation = false;
257
- super.updateEffect(defines, null, null, {
258
- varyingCount: varyingCount,
259
- depCount: depCount,
260
- }, onCompiled, onError);
261
- }
262
- /**
263
- * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
264
- * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
265
- * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
266
- * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
267
- * The gaps between physical kernels are compensated for in the weighting of the samples
268
- * @param idealKernel Ideal blur kernel.
269
- * @returns Nearest best kernel.
270
- */
271
- _nearestBestKernel(idealKernel) {
272
- const v = Math.round(idealKernel);
273
- for (const k of [v, v - 1, v + 1, v - 2, v + 2]) {
274
- if (k % 2 !== 0 && Math.floor(k / 2) % 2 === 0 && k > 0) {
275
- return Math.max(k, 3);
276
- }
277
- }
278
- return Math.max(v, 3);
279
- }
280
- /**
281
- * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
282
- * @param x The point on the Gaussian distribution to sample.
283
- * @returns the value of the Gaussian function at x.
284
- */
285
- _gaussianWeight(x) {
286
- //reference: Engines/ImageProcessingBlur.cpp #dcc760
287
- // We are evaluating the Gaussian (normal) distribution over a kernel parameter space of [-1,1],
288
- // so we truncate at three standard deviations by setting stddev (sigma) to 1/3.
289
- // The choice of 3-sigma truncation is common but arbitrary, and means that the signal is
290
- // truncated at around 1.3% of peak strength.
291
- //the distribution is scaled to account for the difference between the actual kernel size and the requested kernel size
292
- const sigma = 1 / 3;
293
- const denominator = Math.sqrt(2.0 * Math.PI) * sigma;
294
- const exponent = -((x * x) / (2.0 * sigma * sigma));
295
- const weight = (1.0 / denominator) * Math.exp(exponent);
296
- return weight;
297
- }
298
- /**
299
- * Generates a string that can be used as a floating point number in GLSL.
300
- * @param x Value to print.
301
- * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
302
- * @returns GLSL float string.
303
- */
304
- _glslFloat(x, decimalFigures = 8) {
305
- return x.toFixed(decimalFigures).replace(/0+$/, "");
306
- }
307
- /**
308
- * @internal
309
- */
310
- static _Parse(parsedPostProcess, targetCamera, scene, rootUrl) {
311
- return SerializationHelper.Parse(() => {
312
- return new BlurPostProcess(parsedPostProcess.name, parsedPostProcess.direction, parsedPostProcess.kernel, parsedPostProcess.options, targetCamera, parsedPostProcess.renderTargetSamplingMode, scene.getEngine(), parsedPostProcess.reusable, parsedPostProcess.textureType, undefined, false);
313
- }, parsedPostProcess, scene, rootUrl);
314
- }
315
- }
316
- __decorate([
317
- serialize("kernel")
318
- ], BlurPostProcess.prototype, "_kernel", void 0);
319
- __decorate([
320
- serialize("packedFloat")
321
- ], BlurPostProcess.prototype, "_packedFloat", void 0);
322
- __decorate([
323
- serializeAsVector2()
324
- ], BlurPostProcess.prototype, "direction", void 0);
325
- RegisterClass("BABYLON.BlurPostProcess", BlurPostProcess);
326
-
327
- export { BlurPostProcess as B };