@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,105 +0,0 @@
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 };
@@ -1,238 +0,0 @@
1
- import { T as ThinEngine, I as InternalTexture, a as InternalTextureSource, L as Logger } from './engine.esm.js';
2
- import { T as Texture } from './helperFunctions.esm.js';
3
-
4
- ThinEngine.prototype.createDynamicTexture = function (width, height, generateMipMaps, samplingMode) {
5
- const texture = new InternalTexture(this, InternalTextureSource.Dynamic);
6
- texture.baseWidth = width;
7
- texture.baseHeight = height;
8
- if (generateMipMaps) {
9
- width = this.needPOTTextures ? ThinEngine.GetExponentOfTwo(width, this._caps.maxTextureSize) : width;
10
- height = this.needPOTTextures ? ThinEngine.GetExponentOfTwo(height, this._caps.maxTextureSize) : height;
11
- }
12
- // this.resetTextureCache();
13
- texture.width = width;
14
- texture.height = height;
15
- texture.isReady = false;
16
- texture.generateMipMaps = generateMipMaps;
17
- texture.samplingMode = samplingMode;
18
- this.updateTextureSamplingMode(samplingMode, texture);
19
- this._internalTexturesCache.push(texture);
20
- return texture;
21
- };
22
- ThinEngine.prototype.updateDynamicTexture = function (texture, source, invertY, premulAlpha = false, format, forceBindTexture = false,
23
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
24
- allowGPUOptimization = false) {
25
- if (!texture) {
26
- return;
27
- }
28
- const gl = this._gl;
29
- const target = gl.TEXTURE_2D;
30
- const wasPreviouslyBound = this._bindTextureDirectly(target, texture, true, forceBindTexture);
31
- this._unpackFlipY(invertY === undefined ? texture.invertY : invertY);
32
- if (premulAlpha) {
33
- gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 1);
34
- }
35
- const textureType = this._getWebGLTextureType(texture.type);
36
- const glformat = this._getInternalFormat(format ? format : texture.format);
37
- const internalFormat = this._getRGBABufferInternalSizedFormat(texture.type, glformat);
38
- gl.texImage2D(target, 0, internalFormat, glformat, textureType, source);
39
- if (texture.generateMipMaps) {
40
- gl.generateMipmap(target);
41
- }
42
- if (!wasPreviouslyBound) {
43
- this._bindTextureDirectly(target, null);
44
- }
45
- if (premulAlpha) {
46
- gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0);
47
- }
48
- texture.isReady = true;
49
- };
50
-
51
- /**
52
- * A class extending Texture allowing drawing on a texture
53
- * @see https://doc.babylonjs.com/features/featuresDeepDive/materials/using/dynamicTexture
54
- */
55
- class DynamicTexture extends Texture {
56
- /**
57
- * Creates a DynamicTexture
58
- * @param name defines the name of the texture
59
- * @param options provides 3 alternatives for width and height of texture, a canvas, object with width and height properties, number for both width and height
60
- * @param scene defines the scene where you want the texture
61
- * @param generateMipMaps defines the use of MinMaps or not (default is false)
62
- * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
63
- * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
64
- * @param invertY defines if the texture needs to be inverted on the y axis during loading
65
- */
66
- constructor(name, options, scene = null, generateMipMaps = false, samplingMode = 3, format = 5, invertY) {
67
- super(null, scene, !generateMipMaps, invertY, samplingMode, undefined, undefined, undefined, undefined, format);
68
- this.name = name;
69
- this.wrapU = Texture.CLAMP_ADDRESSMODE;
70
- this.wrapV = Texture.CLAMP_ADDRESSMODE;
71
- this._generateMipMaps = generateMipMaps;
72
- const engine = this._getEngine();
73
- if (!engine) {
74
- return;
75
- }
76
- if (options.getContext) {
77
- this._canvas = options;
78
- this._texture = engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);
79
- }
80
- else {
81
- this._canvas = engine.createCanvas(1, 1);
82
- if (options.width || options.width === 0) {
83
- this._texture = engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);
84
- }
85
- else {
86
- this._texture = engine.createDynamicTexture(options, options, generateMipMaps, samplingMode);
87
- }
88
- }
89
- const textureSize = this.getSize();
90
- if (this._canvas.width !== textureSize.width) {
91
- this._canvas.width = textureSize.width;
92
- }
93
- if (this._canvas.height !== textureSize.height) {
94
- this._canvas.height = textureSize.height;
95
- }
96
- this._context = this._canvas.getContext("2d");
97
- }
98
- /**
99
- * Get the current class name of the texture useful for serialization or dynamic coding.
100
- * @returns "DynamicTexture"
101
- */
102
- getClassName() {
103
- return "DynamicTexture";
104
- }
105
- /**
106
- * Gets the current state of canRescale
107
- */
108
- get canRescale() {
109
- return true;
110
- }
111
- _recreate(textureSize) {
112
- this._canvas.width = textureSize.width;
113
- this._canvas.height = textureSize.height;
114
- this.releaseInternalTexture();
115
- this._texture = this._getEngine().createDynamicTexture(textureSize.width, textureSize.height, this._generateMipMaps, this.samplingMode);
116
- }
117
- /**
118
- * Scales the texture
119
- * @param ratio the scale factor to apply to both width and height
120
- */
121
- scale(ratio) {
122
- const textureSize = this.getSize();
123
- textureSize.width *= ratio;
124
- textureSize.height *= ratio;
125
- this._recreate(textureSize);
126
- }
127
- /**
128
- * Resizes the texture
129
- * @param width the new width
130
- * @param height the new height
131
- */
132
- scaleTo(width, height) {
133
- const textureSize = this.getSize();
134
- textureSize.width = width;
135
- textureSize.height = height;
136
- this._recreate(textureSize);
137
- }
138
- /**
139
- * Gets the context of the canvas used by the texture
140
- * @returns the canvas context of the dynamic texture
141
- */
142
- getContext() {
143
- return this._context;
144
- }
145
- /**
146
- * Clears the texture
147
- */
148
- clear() {
149
- const size = this.getSize();
150
- this._context.fillRect(0, 0, size.width, size.height);
151
- }
152
- /**
153
- * Updates the texture
154
- * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
155
- * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
156
- * @param allowGPUOptimization true to allow some specific GPU optimizations (subject to engine feature "allowGPUOptimizationsForGUI" being true)
157
- */
158
- update(invertY, premulAlpha = false, allowGPUOptimization = false) {
159
- this._getEngine().updateDynamicTexture(this._texture, this._canvas, invertY === undefined ? true : invertY, premulAlpha, this._format || undefined, undefined, allowGPUOptimization);
160
- }
161
- /**
162
- * Draws text onto the texture
163
- * @param text defines the text to be drawn
164
- * @param x defines the placement of the text from the left
165
- * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
166
- * @param font defines the font to be used with font-style, font-size, font-name
167
- * @param color defines the color used for the text
168
- * @param clearColor defines the color for the canvas, use null to not overwrite canvas
169
- * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
170
- * @param update defines whether texture is immediately update (default is true)
171
- */
172
- drawText(text, x, y, font, color, clearColor, invertY, update = true) {
173
- const size = this.getSize();
174
- if (clearColor) {
175
- this._context.fillStyle = clearColor;
176
- this._context.fillRect(0, 0, size.width, size.height);
177
- }
178
- this._context.font = font;
179
- if (x === null || x === undefined) {
180
- const textSize = this._context.measureText(text);
181
- x = (size.width - textSize.width) / 2;
182
- }
183
- if (y === null || y === undefined) {
184
- const fontSize = parseInt(font.replace(/\D/g, ""));
185
- y = size.height / 2 + fontSize / 3.65;
186
- }
187
- this._context.fillStyle = color || "";
188
- this._context.fillText(text, x, y);
189
- if (update) {
190
- this.update(invertY);
191
- }
192
- }
193
- /**
194
- * Clones the texture
195
- * @returns the clone of the texture.
196
- */
197
- clone() {
198
- const scene = this.getScene();
199
- if (!scene) {
200
- return this;
201
- }
202
- const textureSize = this.getSize();
203
- const newTexture = new DynamicTexture(this.name, textureSize, scene, this._generateMipMaps);
204
- // Base texture
205
- newTexture.hasAlpha = this.hasAlpha;
206
- newTexture.level = this.level;
207
- // Dynamic Texture
208
- newTexture.wrapU = this.wrapU;
209
- newTexture.wrapV = this.wrapV;
210
- return newTexture;
211
- }
212
- /**
213
- * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
214
- * @returns a serialized dynamic texture object
215
- */
216
- serialize() {
217
- const scene = this.getScene();
218
- if (scene && !scene.isReady()) {
219
- Logger.Warn("The scene must be ready before serializing the dynamic texture");
220
- }
221
- const serializationObject = super.serialize();
222
- if (DynamicTexture._IsCanvasElement(this._canvas)) {
223
- serializationObject.base64String = this._canvas.toDataURL();
224
- }
225
- serializationObject.invertY = this._invertY;
226
- serializationObject.samplingMode = this.samplingMode;
227
- return serializationObject;
228
- }
229
- static _IsCanvasElement(canvas) {
230
- return canvas.toDataURL !== undefined;
231
- }
232
- /** @internal */
233
- _rebuild() {
234
- this.update();
235
- }
236
- }
237
-
238
- export { DynamicTexture as D };
@@ -1,130 +0,0 @@
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 };