@babylonjs/materials 9.15.0 → 9.16.1

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/cell/cellMaterial.d.ts +4 -4
  2. package/cell/cellMaterial.js +313 -268
  3. package/cell/cellMaterial.js.map +1 -1
  4. package/fire/fireMaterial.d.ts +3 -3
  5. package/fire/fireMaterial.js +344 -303
  6. package/fire/fireMaterial.js.map +1 -1
  7. package/fur/furMaterial.d.ts +4 -4
  8. package/fur/furMaterial.js +519 -450
  9. package/fur/furMaterial.js.map +1 -1
  10. package/gradient/gradientMaterial.d.ts +2 -2
  11. package/gradient/gradientMaterial.js +286 -246
  12. package/gradient/gradientMaterial.js.map +1 -1
  13. package/grid/gridMaterial.d.ts +1 -1
  14. package/grid/gridMaterial.js +453 -398
  15. package/grid/gridMaterial.js.map +1 -1
  16. package/lava/lavaMaterial.d.ts +4 -4
  17. package/lava/lavaMaterial.js +377 -318
  18. package/lava/lavaMaterial.js.map +1 -1
  19. package/mix/mixMaterial.d.ts +12 -12
  20. package/mix/mixMaterial.js +584 -456
  21. package/mix/mixMaterial.js.map +1 -1
  22. package/normal/normalMaterial.d.ts +3 -3
  23. package/normal/normalMaterial.js +301 -264
  24. package/normal/normalMaterial.js.map +1 -1
  25. package/package.json +2 -2
  26. package/simple/simpleMaterial.d.ts +3 -3
  27. package/simple/simpleMaterial.js +299 -262
  28. package/simple/simpleMaterial.js.map +1 -1
  29. package/sky/skyMaterial.js +380 -344
  30. package/sky/skyMaterial.js.map +1 -1
  31. package/terrain/terrainMaterial.d.ts +9 -9
  32. package/terrain/terrainMaterial.js +490 -395
  33. package/terrain/terrainMaterial.js.map +1 -1
  34. package/triPlanar/triPlanarMaterial.d.ts +8 -8
  35. package/triPlanar/triPlanarMaterial.js +460 -369
  36. package/triPlanar/triPlanarMaterial.js.map +1 -1
  37. package/water/waterMaterial.d.ts +7 -7
  38. package/water/waterMaterial.js +759 -659
  39. package/water/waterMaterial.js.map +1 -1
@@ -1,4 +1,4 @@
1
- import { __decorate } from "@babylonjs/core/tslib.es6.js";
1
+ import { __classPrivateFieldGet, __classPrivateFieldSet, __esDecorate, __runInitializers } from "@babylonjs/core/tslib.es6.js";
2
2
  import { serializeAsTexture, serialize, expandToProperty, serializeAsColor3 } from "@babylonjs/core/Misc/decorators.js";
3
3
  import { SerializationHelper } from "@babylonjs/core/Misc/decorators.serialization.js";
4
4
  import { Color3 } from "@babylonjs/core/Maths/math.color.js";
@@ -40,320 +40,361 @@ class FireMaterialDefines extends MaterialDefines {
40
40
  this.rebuild();
41
41
  }
42
42
  }
43
- export class FireMaterial extends PushMaterial {
44
- /**
45
- * Instantiates a Fire Material in the given scene
46
- * @param name The friendly name of the material
47
- * @param scene The scene to add the material to
48
- * @param forceGLSL Use the GLSL code generation for the shader (even on WebGPU). Default is false
49
- */
50
- constructor(name, scene, forceGLSL = false) {
51
- super(name, scene, undefined, forceGLSL);
52
- this.diffuseColor = new Color3(1, 1, 1);
53
- this.speed = 1.0;
54
- this._scaledDiffuse = new Color3();
55
- this._lastTime = 0;
56
- this._shadersLoaded = false;
57
- }
58
- needAlphaBlending() {
59
- return false;
60
- }
61
- needAlphaTesting() {
62
- return true;
63
- }
64
- getAlphaTestTexture() {
65
- return null;
66
- }
67
- // Methods
68
- isReadyForSubMesh(mesh, subMesh, useInstances) {
69
- const drawWrapper = subMesh._drawWrapper;
70
- if (this.isFrozen) {
71
- if (drawWrapper._wasPreviouslyReady && drawWrapper._wasPreviouslyUsingInstances === useInstances) {
43
+ let FireMaterial = (() => {
44
+ var _a, _FireMaterial_diffuseTexture_accessor_storage, _FireMaterial_distortionTexture_accessor_storage, _FireMaterial_opacityTexture_accessor_storage;
45
+ let _classSuper = PushMaterial;
46
+ let __diffuseTexture_decorators;
47
+ let __diffuseTexture_initializers = [];
48
+ let __diffuseTexture_extraInitializers = [];
49
+ let _diffuseTexture_decorators;
50
+ let _diffuseTexture_initializers = [];
51
+ let _diffuseTexture_extraInitializers = [];
52
+ let __distortionTexture_decorators;
53
+ let __distortionTexture_initializers = [];
54
+ let __distortionTexture_extraInitializers = [];
55
+ let _distortionTexture_decorators;
56
+ let _distortionTexture_initializers = [];
57
+ let _distortionTexture_extraInitializers = [];
58
+ let __opacityTexture_decorators;
59
+ let __opacityTexture_initializers = [];
60
+ let __opacityTexture_extraInitializers = [];
61
+ let _opacityTexture_decorators;
62
+ let _opacityTexture_initializers = [];
63
+ let _opacityTexture_extraInitializers = [];
64
+ let _diffuseColor_decorators;
65
+ let _diffuseColor_initializers = [];
66
+ let _diffuseColor_extraInitializers = [];
67
+ let _speed_decorators;
68
+ let _speed_initializers = [];
69
+ let _speed_extraInitializers = [];
70
+ return _a = class FireMaterial extends _classSuper {
71
+ get diffuseTexture() { return __classPrivateFieldGet(this, _FireMaterial_diffuseTexture_accessor_storage, "f"); }
72
+ set diffuseTexture(value) { __classPrivateFieldSet(this, _FireMaterial_diffuseTexture_accessor_storage, value, "f"); }
73
+ get distortionTexture() { return __classPrivateFieldGet(this, _FireMaterial_distortionTexture_accessor_storage, "f"); }
74
+ set distortionTexture(value) { __classPrivateFieldSet(this, _FireMaterial_distortionTexture_accessor_storage, value, "f"); }
75
+ get opacityTexture() { return __classPrivateFieldGet(this, _FireMaterial_opacityTexture_accessor_storage, "f"); }
76
+ set opacityTexture(value) { __classPrivateFieldSet(this, _FireMaterial_opacityTexture_accessor_storage, value, "f"); }
77
+ /**
78
+ * Instantiates a Fire Material in the given scene
79
+ * @param name The friendly name of the material
80
+ * @param scene The scene to add the material to
81
+ * @param forceGLSL Use the GLSL code generation for the shader (even on WebGPU). Default is false
82
+ */
83
+ constructor(name, scene, forceGLSL = false) {
84
+ super(name, scene, undefined, forceGLSL);
85
+ this._diffuseTexture = __runInitializers(this, __diffuseTexture_initializers, void 0);
86
+ _FireMaterial_diffuseTexture_accessor_storage.set(this, (__runInitializers(this, __diffuseTexture_extraInitializers), __runInitializers(this, _diffuseTexture_initializers, void 0)));
87
+ this._distortionTexture = (__runInitializers(this, _diffuseTexture_extraInitializers), __runInitializers(this, __distortionTexture_initializers, void 0));
88
+ _FireMaterial_distortionTexture_accessor_storage.set(this, (__runInitializers(this, __distortionTexture_extraInitializers), __runInitializers(this, _distortionTexture_initializers, void 0)));
89
+ this._opacityTexture = (__runInitializers(this, _distortionTexture_extraInitializers), __runInitializers(this, __opacityTexture_initializers, void 0));
90
+ _FireMaterial_opacityTexture_accessor_storage.set(this, (__runInitializers(this, __opacityTexture_extraInitializers), __runInitializers(this, _opacityTexture_initializers, void 0)));
91
+ this.diffuseColor = (__runInitializers(this, _opacityTexture_extraInitializers), __runInitializers(this, _diffuseColor_initializers, new Color3(1, 1, 1)));
92
+ this.speed = (__runInitializers(this, _diffuseColor_extraInitializers), __runInitializers(this, _speed_initializers, 1.0));
93
+ this._scaledDiffuse = (__runInitializers(this, _speed_extraInitializers), new Color3());
94
+ this._lastTime = 0;
95
+ this._shadersLoaded = false;
96
+ }
97
+ needAlphaBlending() {
98
+ return false;
99
+ }
100
+ needAlphaTesting() {
72
101
  return true;
73
102
  }
74
- }
75
- if (!subMesh.materialDefines) {
76
- subMesh.materialDefines = new FireMaterialDefines();
77
- }
78
- const defines = subMesh.materialDefines;
79
- const scene = this.getScene();
80
- if (this._isReadyForSubMesh(subMesh)) {
81
- return true;
82
- }
83
- const engine = scene.getEngine();
84
- // Textures
85
- if (defines._areTexturesDirty) {
86
- defines._needUVs = false;
87
- if (this._diffuseTexture && MaterialFlags.DiffuseTextureEnabled) {
88
- if (!this._diffuseTexture.isReady()) {
103
+ getAlphaTestTexture() {
104
+ return null;
105
+ }
106
+ // Methods
107
+ isReadyForSubMesh(mesh, subMesh, useInstances) {
108
+ const drawWrapper = subMesh._drawWrapper;
109
+ if (this.isFrozen) {
110
+ if (drawWrapper._wasPreviouslyReady && drawWrapper._wasPreviouslyUsingInstances === useInstances) {
111
+ return true;
112
+ }
113
+ }
114
+ if (!subMesh.materialDefines) {
115
+ subMesh.materialDefines = new FireMaterialDefines();
116
+ }
117
+ const defines = subMesh.materialDefines;
118
+ const scene = this.getScene();
119
+ if (this._isReadyForSubMesh(subMesh)) {
120
+ return true;
121
+ }
122
+ const engine = scene.getEngine();
123
+ // Textures
124
+ if (defines._areTexturesDirty) {
125
+ defines._needUVs = false;
126
+ if (this._diffuseTexture && MaterialFlags.DiffuseTextureEnabled) {
127
+ if (!this._diffuseTexture.isReady()) {
128
+ return false;
129
+ }
130
+ else {
131
+ defines._needUVs = true;
132
+ defines.DIFFUSE = true;
133
+ }
134
+ }
135
+ }
136
+ defines.ALPHATEST = this._opacityTexture ? true : false;
137
+ // Misc.
138
+ if (defines._areMiscDirty) {
139
+ defines.POINTSIZE = this.pointsCloud || scene.forcePointsCloud;
140
+ defines.FOG = scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE && this.fogEnabled;
141
+ defines.LOGARITHMICDEPTH = this._useLogarithmicDepth;
142
+ }
143
+ // Values that need to be evaluated on every frame
144
+ PrepareDefinesForFrameBoundValues(scene, engine, this, defines, useInstances ? true : false);
145
+ // Attribs
146
+ PrepareDefinesForAttributes(mesh, defines, false, true);
147
+ // Get correct effect
148
+ if (defines.isDirty) {
149
+ defines.markAsProcessed();
150
+ scene.resetCachedMaterial();
151
+ // Fallbacks
152
+ const fallbacks = new EffectFallbacks();
153
+ if (defines.FOG) {
154
+ fallbacks.addFallback(1, "FOG");
155
+ }
156
+ if (defines.NUM_BONE_INFLUENCERS > 0) {
157
+ fallbacks.addCPUSkinningFallback(0, mesh);
158
+ }
159
+ defines.IMAGEPROCESSINGPOSTPROCESS = scene.imageProcessingConfiguration.applyByPostProcess;
160
+ //Attributes
161
+ const attribs = [VertexBuffer.PositionKind];
162
+ if (defines.UV1) {
163
+ attribs.push(VertexBuffer.UVKind);
164
+ }
165
+ if (defines.VERTEXCOLOR) {
166
+ attribs.push(VertexBuffer.ColorKind);
167
+ }
168
+ PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
169
+ PrepareAttributesForInstances(attribs, defines);
170
+ // Legacy browser patch
171
+ const shaderName = "fire";
172
+ const uniforms = [
173
+ "world",
174
+ "view",
175
+ "viewProjection",
176
+ "vEyePosition",
177
+ "vFogInfos",
178
+ "vFogColor",
179
+ "pointSize",
180
+ "vDiffuseInfos",
181
+ "mBones",
182
+ "diffuseMatrix",
183
+ "logarithmicDepthConstant",
184
+ // Fire
185
+ "time",
186
+ "speed",
187
+ ];
188
+ AddClipPlaneUniforms(uniforms);
189
+ const join = defines.toString();
190
+ subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
191
+ attributes: attribs,
192
+ uniformsNames: uniforms,
193
+ uniformBuffersNames: [],
194
+ samplers: [
195
+ "diffuseSampler",
196
+ // Fire
197
+ "distortionSampler",
198
+ "opacitySampler",
199
+ ],
200
+ defines: join,
201
+ fallbacks: fallbacks,
202
+ onCompiled: this.onCompiled,
203
+ onError: this.onError,
204
+ indexParameters: null,
205
+ maxSimultaneousLights: 4,
206
+ transformFeedbackVaryings: null,
207
+ shaderLanguage: this._shaderLanguage,
208
+ extraInitializationsAsync: this._shadersLoaded
209
+ ? undefined
210
+ : async () => {
211
+ if (this.shaderLanguage === 1 /* ShaderLanguage.WGSL */) {
212
+ await Promise.all([import("./wgsl/fire.vertex.js"), import("./wgsl/fire.fragment.js")]);
213
+ }
214
+ else {
215
+ await Promise.all([import("./fire.vertex.js"), import("./fire.fragment.js")]);
216
+ }
217
+ this._shadersLoaded = true;
218
+ },
219
+ }, engine), defines, this._materialContext);
220
+ }
221
+ if (!subMesh.effect || !subMesh.effect.isReady()) {
89
222
  return false;
90
223
  }
91
- else {
92
- defines._needUVs = true;
93
- defines.DIFFUSE = true;
224
+ defines._renderId = scene.getRenderId();
225
+ drawWrapper._wasPreviouslyReady = true;
226
+ drawWrapper._wasPreviouslyUsingInstances = !!useInstances;
227
+ return true;
228
+ }
229
+ bindForSubMesh(world, mesh, subMesh) {
230
+ const scene = this.getScene();
231
+ const defines = subMesh.materialDefines;
232
+ if (!defines) {
233
+ return;
234
+ }
235
+ const effect = subMesh.effect;
236
+ if (!effect) {
237
+ return;
238
+ }
239
+ this._activeEffect = effect;
240
+ // Matrices
241
+ this.bindOnlyWorldMatrix(world);
242
+ this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
243
+ // Bones
244
+ BindBonesParameters(mesh, this._activeEffect);
245
+ if (this._mustRebind(scene, effect, subMesh)) {
246
+ // Textures
247
+ if (this._diffuseTexture && MaterialFlags.DiffuseTextureEnabled) {
248
+ this._activeEffect.setTexture("diffuseSampler", this._diffuseTexture);
249
+ this._activeEffect.setFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
250
+ this._activeEffect.setMatrix("diffuseMatrix", this._diffuseTexture.getTextureMatrix());
251
+ this._activeEffect.setTexture("distortionSampler", this._distortionTexture);
252
+ this._activeEffect.setTexture("opacitySampler", this._opacityTexture);
253
+ }
254
+ // Clip plane
255
+ BindClipPlane(this._activeEffect, this, scene);
256
+ // Point size
257
+ if (this.pointsCloud) {
258
+ this._activeEffect.setFloat("pointSize", this.pointSize);
259
+ }
260
+ // Log. depth
261
+ if (this._useLogarithmicDepth) {
262
+ BindLogDepth(defines, effect, scene);
263
+ }
264
+ scene.bindEyePosition(effect);
265
+ }
266
+ this._activeEffect.setColor4("vDiffuseColor", this._scaledDiffuse, this.alpha * mesh.visibility);
267
+ // View
268
+ if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE) {
269
+ this._activeEffect.setMatrix("view", scene.getViewMatrix());
94
270
  }
271
+ // Fog
272
+ BindFogParameters(scene, mesh, this._activeEffect);
273
+ // Time
274
+ this._lastTime += scene.getEngine().getDeltaTime();
275
+ this._activeEffect.setFloat("time", this._lastTime);
276
+ // Speed
277
+ this._activeEffect.setFloat("speed", this.speed);
278
+ this._afterBind(mesh, this._activeEffect, subMesh);
95
279
  }
96
- }
97
- defines.ALPHATEST = this._opacityTexture ? true : false;
98
- // Misc.
99
- if (defines._areMiscDirty) {
100
- defines.POINTSIZE = this.pointsCloud || scene.forcePointsCloud;
101
- defines.FOG = scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE && this.fogEnabled;
102
- defines.LOGARITHMICDEPTH = this._useLogarithmicDepth;
103
- }
104
- // Values that need to be evaluated on every frame
105
- PrepareDefinesForFrameBoundValues(scene, engine, this, defines, useInstances ? true : false);
106
- // Attribs
107
- PrepareDefinesForAttributes(mesh, defines, false, true);
108
- // Get correct effect
109
- if (defines.isDirty) {
110
- defines.markAsProcessed();
111
- scene.resetCachedMaterial();
112
- // Fallbacks
113
- const fallbacks = new EffectFallbacks();
114
- if (defines.FOG) {
115
- fallbacks.addFallback(1, "FOG");
280
+ getAnimatables() {
281
+ const results = [];
282
+ if (this._diffuseTexture && this._diffuseTexture.animations && this._diffuseTexture.animations.length > 0) {
283
+ results.push(this._diffuseTexture);
284
+ }
285
+ if (this._distortionTexture && this._distortionTexture.animations && this._distortionTexture.animations.length > 0) {
286
+ results.push(this._distortionTexture);
287
+ }
288
+ if (this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0) {
289
+ results.push(this._opacityTexture);
290
+ }
291
+ return results;
292
+ }
293
+ getActiveTextures() {
294
+ const activeTextures = super.getActiveTextures();
295
+ if (this._diffuseTexture) {
296
+ activeTextures.push(this._diffuseTexture);
297
+ }
298
+ if (this._distortionTexture) {
299
+ activeTextures.push(this._distortionTexture);
300
+ }
301
+ if (this._opacityTexture) {
302
+ activeTextures.push(this._opacityTexture);
303
+ }
304
+ return activeTextures;
116
305
  }
117
- if (defines.NUM_BONE_INFLUENCERS > 0) {
118
- fallbacks.addCPUSkinningFallback(0, mesh);
306
+ hasTexture(texture) {
307
+ if (super.hasTexture(texture)) {
308
+ return true;
309
+ }
310
+ if (this._diffuseTexture === texture) {
311
+ return true;
312
+ }
313
+ if (this._distortionTexture === texture) {
314
+ return true;
315
+ }
316
+ if (this._opacityTexture === texture) {
317
+ return true;
318
+ }
319
+ return false;
119
320
  }
120
- defines.IMAGEPROCESSINGPOSTPROCESS = scene.imageProcessingConfiguration.applyByPostProcess;
121
- //Attributes
122
- const attribs = [VertexBuffer.PositionKind];
123
- if (defines.UV1) {
124
- attribs.push(VertexBuffer.UVKind);
321
+ getClassName() {
322
+ return "FireMaterial";
125
323
  }
126
- if (defines.VERTEXCOLOR) {
127
- attribs.push(VertexBuffer.ColorKind);
324
+ dispose(forceDisposeEffect) {
325
+ if (this._diffuseTexture) {
326
+ this._diffuseTexture.dispose();
327
+ }
328
+ if (this._distortionTexture) {
329
+ this._distortionTexture.dispose();
330
+ }
331
+ super.dispose(forceDisposeEffect);
128
332
  }
129
- PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
130
- PrepareAttributesForInstances(attribs, defines);
131
- // Legacy browser patch
132
- const shaderName = "fire";
133
- const uniforms = [
134
- "world",
135
- "view",
136
- "viewProjection",
137
- "vEyePosition",
138
- "vFogInfos",
139
- "vFogColor",
140
- "pointSize",
141
- "vDiffuseInfos",
142
- "mBones",
143
- "diffuseMatrix",
144
- "logarithmicDepthConstant",
145
- // Fire
146
- "time",
147
- "speed",
148
- ];
149
- AddClipPlaneUniforms(uniforms);
150
- const join = defines.toString();
151
- subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
152
- attributes: attribs,
153
- uniformsNames: uniforms,
154
- uniformBuffersNames: [],
155
- samplers: [
156
- "diffuseSampler",
157
- // Fire
158
- "distortionSampler",
159
- "opacitySampler",
160
- ],
161
- defines: join,
162
- fallbacks: fallbacks,
163
- onCompiled: this.onCompiled,
164
- onError: this.onError,
165
- indexParameters: null,
166
- maxSimultaneousLights: 4,
167
- transformFeedbackVaryings: null,
168
- shaderLanguage: this._shaderLanguage,
169
- extraInitializationsAsync: this._shadersLoaded
170
- ? undefined
171
- : async () => {
172
- if (this.shaderLanguage === 1 /* ShaderLanguage.WGSL */) {
173
- await Promise.all([import("./wgsl/fire.vertex.js"), import("./wgsl/fire.fragment.js")]);
174
- }
175
- else {
176
- await Promise.all([import("./fire.vertex.js"), import("./fire.fragment.js")]);
177
- }
178
- this._shadersLoaded = true;
179
- },
180
- }, engine), defines, this._materialContext);
181
- }
182
- if (!subMesh.effect || !subMesh.effect.isReady()) {
183
- return false;
184
- }
185
- defines._renderId = scene.getRenderId();
186
- drawWrapper._wasPreviouslyReady = true;
187
- drawWrapper._wasPreviouslyUsingInstances = !!useInstances;
188
- return true;
189
- }
190
- bindForSubMesh(world, mesh, subMesh) {
191
- const scene = this.getScene();
192
- const defines = subMesh.materialDefines;
193
- if (!defines) {
194
- return;
195
- }
196
- const effect = subMesh.effect;
197
- if (!effect) {
198
- return;
199
- }
200
- this._activeEffect = effect;
201
- // Matrices
202
- this.bindOnlyWorldMatrix(world);
203
- this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
204
- // Bones
205
- BindBonesParameters(mesh, this._activeEffect);
206
- if (this._mustRebind(scene, effect, subMesh)) {
207
- // Textures
208
- if (this._diffuseTexture && MaterialFlags.DiffuseTextureEnabled) {
209
- this._activeEffect.setTexture("diffuseSampler", this._diffuseTexture);
210
- this._activeEffect.setFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
211
- this._activeEffect.setMatrix("diffuseMatrix", this._diffuseTexture.getTextureMatrix());
212
- this._activeEffect.setTexture("distortionSampler", this._distortionTexture);
213
- this._activeEffect.setTexture("opacitySampler", this._opacityTexture);
333
+ clone(name) {
334
+ return SerializationHelper.Clone(() => new _a(name, this.getScene()), this);
214
335
  }
215
- // Clip plane
216
- BindClipPlane(this._activeEffect, this, scene);
217
- // Point size
218
- if (this.pointsCloud) {
219
- this._activeEffect.setFloat("pointSize", this.pointSize);
336
+ serialize() {
337
+ const serializationObject = super.serialize();
338
+ serializationObject.customType = "BABYLON.FireMaterial";
339
+ serializationObject.diffuseColor = this.diffuseColor.asArray();
340
+ serializationObject.speed = this.speed;
341
+ if (this._diffuseTexture) {
342
+ serializationObject._diffuseTexture = this._diffuseTexture.serialize();
343
+ }
344
+ if (this._distortionTexture) {
345
+ serializationObject._distortionTexture = this._distortionTexture.serialize();
346
+ }
347
+ if (this._opacityTexture) {
348
+ serializationObject._opacityTexture = this._opacityTexture.serialize();
349
+ }
350
+ return serializationObject;
220
351
  }
221
- // Log. depth
222
- if (this._useLogarithmicDepth) {
223
- BindLogDepth(defines, effect, scene);
352
+ static Parse(source, scene, rootUrl) {
353
+ const material = new _a(source.name, scene);
354
+ material.diffuseColor = Color3.FromArray(source.diffuseColor);
355
+ material.speed = source.speed;
356
+ material.alpha = source.alpha;
357
+ material.id = source.id;
358
+ Tags.AddTagsTo(material, source.tags);
359
+ material.backFaceCulling = source.backFaceCulling;
360
+ material.wireframe = source.wireframe;
361
+ if (source._diffuseTexture) {
362
+ material._diffuseTexture = Texture.Parse(source._diffuseTexture, scene, rootUrl);
363
+ }
364
+ if (source._distortionTexture) {
365
+ material._distortionTexture = Texture.Parse(source._distortionTexture, scene, rootUrl);
366
+ }
367
+ if (source._opacityTexture) {
368
+ material._opacityTexture = Texture.Parse(source._opacityTexture, scene, rootUrl);
369
+ }
370
+ return material;
224
371
  }
225
- scene.bindEyePosition(effect);
226
- }
227
- this._activeEffect.setColor4("vDiffuseColor", this._scaledDiffuse, this.alpha * mesh.visibility);
228
- // View
229
- if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE) {
230
- this._activeEffect.setMatrix("view", scene.getViewMatrix());
231
- }
232
- // Fog
233
- BindFogParameters(scene, mesh, this._activeEffect);
234
- // Time
235
- this._lastTime += scene.getEngine().getDeltaTime();
236
- this._activeEffect.setFloat("time", this._lastTime);
237
- // Speed
238
- this._activeEffect.setFloat("speed", this.speed);
239
- this._afterBind(mesh, this._activeEffect, subMesh);
240
- }
241
- getAnimatables() {
242
- const results = [];
243
- if (this._diffuseTexture && this._diffuseTexture.animations && this._diffuseTexture.animations.length > 0) {
244
- results.push(this._diffuseTexture);
245
- }
246
- if (this._distortionTexture && this._distortionTexture.animations && this._distortionTexture.animations.length > 0) {
247
- results.push(this._distortionTexture);
248
- }
249
- if (this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0) {
250
- results.push(this._opacityTexture);
251
- }
252
- return results;
253
- }
254
- getActiveTextures() {
255
- const activeTextures = super.getActiveTextures();
256
- if (this._diffuseTexture) {
257
- activeTextures.push(this._diffuseTexture);
258
- }
259
- if (this._distortionTexture) {
260
- activeTextures.push(this._distortionTexture);
261
- }
262
- if (this._opacityTexture) {
263
- activeTextures.push(this._opacityTexture);
264
- }
265
- return activeTextures;
266
- }
267
- hasTexture(texture) {
268
- if (super.hasTexture(texture)) {
269
- return true;
270
- }
271
- if (this._diffuseTexture === texture) {
272
- return true;
273
- }
274
- if (this._distortionTexture === texture) {
275
- return true;
276
- }
277
- if (this._opacityTexture === texture) {
278
- return true;
279
- }
280
- return false;
281
- }
282
- getClassName() {
283
- return "FireMaterial";
284
- }
285
- dispose(forceDisposeEffect) {
286
- if (this._diffuseTexture) {
287
- this._diffuseTexture.dispose();
288
- }
289
- if (this._distortionTexture) {
290
- this._distortionTexture.dispose();
291
- }
292
- super.dispose(forceDisposeEffect);
293
- }
294
- clone(name) {
295
- return SerializationHelper.Clone(() => new FireMaterial(name, this.getScene()), this);
296
- }
297
- serialize() {
298
- const serializationObject = super.serialize();
299
- serializationObject.customType = "BABYLON.FireMaterial";
300
- serializationObject.diffuseColor = this.diffuseColor.asArray();
301
- serializationObject.speed = this.speed;
302
- if (this._diffuseTexture) {
303
- serializationObject._diffuseTexture = this._diffuseTexture.serialize();
304
- }
305
- if (this._distortionTexture) {
306
- serializationObject._distortionTexture = this._distortionTexture.serialize();
307
- }
308
- if (this._opacityTexture) {
309
- serializationObject._opacityTexture = this._opacityTexture.serialize();
310
- }
311
- return serializationObject;
312
- }
313
- static Parse(source, scene, rootUrl) {
314
- const material = new FireMaterial(source.name, scene);
315
- material.diffuseColor = Color3.FromArray(source.diffuseColor);
316
- material.speed = source.speed;
317
- material.alpha = source.alpha;
318
- material.id = source.id;
319
- Tags.AddTagsTo(material, source.tags);
320
- material.backFaceCulling = source.backFaceCulling;
321
- material.wireframe = source.wireframe;
322
- if (source._diffuseTexture) {
323
- material._diffuseTexture = Texture.Parse(source._diffuseTexture, scene, rootUrl);
324
- }
325
- if (source._distortionTexture) {
326
- material._distortionTexture = Texture.Parse(source._distortionTexture, scene, rootUrl);
327
- }
328
- if (source._opacityTexture) {
329
- material._opacityTexture = Texture.Parse(source._opacityTexture, scene, rootUrl);
330
- }
331
- return material;
332
- }
333
- }
334
- __decorate([
335
- serializeAsTexture("diffuseTexture")
336
- ], FireMaterial.prototype, "_diffuseTexture", void 0);
337
- __decorate([
338
- expandToProperty("_markAllSubMeshesAsTexturesDirty")
339
- ], FireMaterial.prototype, "diffuseTexture", void 0);
340
- __decorate([
341
- serializeAsTexture("distortionTexture")
342
- ], FireMaterial.prototype, "_distortionTexture", void 0);
343
- __decorate([
344
- expandToProperty("_markAllSubMeshesAsTexturesDirty")
345
- ], FireMaterial.prototype, "distortionTexture", void 0);
346
- __decorate([
347
- serializeAsTexture("opacityTexture")
348
- ], FireMaterial.prototype, "_opacityTexture", void 0);
349
- __decorate([
350
- expandToProperty("_markAllSubMeshesAsTexturesDirty")
351
- ], FireMaterial.prototype, "opacityTexture", void 0);
352
- __decorate([
353
- serializeAsColor3("diffuse")
354
- ], FireMaterial.prototype, "diffuseColor", void 0);
355
- __decorate([
356
- serialize()
357
- ], FireMaterial.prototype, "speed", void 0);
372
+ },
373
+ _FireMaterial_diffuseTexture_accessor_storage = new WeakMap(),
374
+ _FireMaterial_distortionTexture_accessor_storage = new WeakMap(),
375
+ _FireMaterial_opacityTexture_accessor_storage = new WeakMap(),
376
+ (() => {
377
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
378
+ __diffuseTexture_decorators = [serializeAsTexture("diffuseTexture")];
379
+ _diffuseTexture_decorators = [expandToProperty("_markAllSubMeshesAsTexturesDirty")];
380
+ __distortionTexture_decorators = [serializeAsTexture("distortionTexture")];
381
+ _distortionTexture_decorators = [expandToProperty("_markAllSubMeshesAsTexturesDirty")];
382
+ __opacityTexture_decorators = [serializeAsTexture("opacityTexture")];
383
+ _opacityTexture_decorators = [expandToProperty("_markAllSubMeshesAsTexturesDirty")];
384
+ _diffuseColor_decorators = [serializeAsColor3("diffuse")];
385
+ _speed_decorators = [serialize()];
386
+ __esDecorate(_a, null, _diffuseTexture_decorators, { kind: "accessor", name: "diffuseTexture", static: false, private: false, access: { has: obj => "diffuseTexture" in obj, get: obj => obj.diffuseTexture, set: (obj, value) => { obj.diffuseTexture = value; } }, metadata: _metadata }, _diffuseTexture_initializers, _diffuseTexture_extraInitializers);
387
+ __esDecorate(_a, null, _distortionTexture_decorators, { kind: "accessor", name: "distortionTexture", static: false, private: false, access: { has: obj => "distortionTexture" in obj, get: obj => obj.distortionTexture, set: (obj, value) => { obj.distortionTexture = value; } }, metadata: _metadata }, _distortionTexture_initializers, _distortionTexture_extraInitializers);
388
+ __esDecorate(_a, null, _opacityTexture_decorators, { kind: "accessor", name: "opacityTexture", static: false, private: false, access: { has: obj => "opacityTexture" in obj, get: obj => obj.opacityTexture, set: (obj, value) => { obj.opacityTexture = value; } }, metadata: _metadata }, _opacityTexture_initializers, _opacityTexture_extraInitializers);
389
+ __esDecorate(null, null, __diffuseTexture_decorators, { kind: "field", name: "_diffuseTexture", static: false, private: false, access: { has: obj => "_diffuseTexture" in obj, get: obj => obj._diffuseTexture, set: (obj, value) => { obj._diffuseTexture = value; } }, metadata: _metadata }, __diffuseTexture_initializers, __diffuseTexture_extraInitializers);
390
+ __esDecorate(null, null, __distortionTexture_decorators, { kind: "field", name: "_distortionTexture", static: false, private: false, access: { has: obj => "_distortionTexture" in obj, get: obj => obj._distortionTexture, set: (obj, value) => { obj._distortionTexture = value; } }, metadata: _metadata }, __distortionTexture_initializers, __distortionTexture_extraInitializers);
391
+ __esDecorate(null, null, __opacityTexture_decorators, { kind: "field", name: "_opacityTexture", static: false, private: false, access: { has: obj => "_opacityTexture" in obj, get: obj => obj._opacityTexture, set: (obj, value) => { obj._opacityTexture = value; } }, metadata: _metadata }, __opacityTexture_initializers, __opacityTexture_extraInitializers);
392
+ __esDecorate(null, null, _diffuseColor_decorators, { kind: "field", name: "diffuseColor", static: false, private: false, access: { has: obj => "diffuseColor" in obj, get: obj => obj.diffuseColor, set: (obj, value) => { obj.diffuseColor = value; } }, metadata: _metadata }, _diffuseColor_initializers, _diffuseColor_extraInitializers);
393
+ __esDecorate(null, null, _speed_decorators, { kind: "field", name: "speed", static: false, private: false, access: { has: obj => "speed" in obj, get: obj => obj.speed, set: (obj, value) => { obj.speed = value; } }, metadata: _metadata }, _speed_initializers, _speed_extraInitializers);
394
+ if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
395
+ })(),
396
+ _a;
397
+ })();
398
+ export { FireMaterial };
358
399
  RegisterClass("BABYLON.FireMaterial", FireMaterial);
359
400
  //# sourceMappingURL=fireMaterial.js.map