@babylonjs/materials 5.0.0-rc.7 → 5.0.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 (187) hide show
  1. package/cell/cell.fragment.d.ts +17 -17
  2. package/cell/cell.fragment.js +20 -20
  3. package/cell/cell.vertex.d.ts +18 -18
  4. package/cell/cell.vertex.js +21 -21
  5. package/cell/cellMaterial.d.ts +37 -37
  6. package/cell/cellMaterial.js +304 -304
  7. package/cell/cellMaterial.js.map +1 -1
  8. package/cell/index.d.ts +1 -1
  9. package/cell/index.js +1 -1
  10. package/custom/customMaterial.d.ts +69 -69
  11. package/custom/customMaterial.js +216 -216
  12. package/custom/customMaterial.js.map +1 -1
  13. package/custom/index.d.ts +2 -2
  14. package/custom/index.js +2 -2
  15. package/custom/pbrCustomMaterial.d.ts +71 -71
  16. package/custom/pbrCustomMaterial.js +241 -241
  17. package/custom/pbrCustomMaterial.js.map +1 -1
  18. package/fire/fire.fragment.d.ts +11 -11
  19. package/fire/fire.fragment.js +14 -14
  20. package/fire/fire.vertex.d.ts +15 -15
  21. package/fire/fire.vertex.js +18 -18
  22. package/fire/fireMaterial.d.ts +38 -38
  23. package/fire/fireMaterial.js +342 -342
  24. package/fire/fireMaterial.js.map +1 -1
  25. package/fire/index.d.ts +1 -1
  26. package/fire/index.js +1 -1
  27. package/fur/fur.fragment.d.ts +17 -17
  28. package/fur/fur.fragment.js +20 -20
  29. package/fur/fur.vertex.d.ts +18 -18
  30. package/fur/fur.vertex.js +21 -21
  31. package/fur/furMaterial.d.ts +57 -56
  32. package/fur/furMaterial.js +500 -500
  33. package/fur/furMaterial.js.map +1 -1
  34. package/fur/index.d.ts +1 -1
  35. package/fur/index.js +1 -1
  36. package/gradient/gradient.fragment.d.ts +17 -17
  37. package/gradient/gradient.fragment.js +20 -20
  38. package/gradient/gradient.vertex.d.ts +18 -18
  39. package/gradient/gradient.vertex.js +21 -21
  40. package/gradient/gradientMaterial.d.ts +37 -37
  41. package/gradient/gradientMaterial.js +275 -275
  42. package/gradient/gradientMaterial.js.map +1 -1
  43. package/gradient/index.d.ts +1 -1
  44. package/gradient/index.js +1 -1
  45. package/grid/grid.fragment.d.ts +8 -8
  46. package/grid/grid.fragment.js +11 -11
  47. package/grid/grid.vertex.d.ts +9 -9
  48. package/grid/grid.vertex.js +12 -12
  49. package/grid/gridMaterial.d.ts +78 -77
  50. package/grid/gridMaterial.js +276 -276
  51. package/grid/gridMaterial.js.map +1 -1
  52. package/grid/index.d.ts +1 -1
  53. package/grid/index.js +1 -1
  54. package/index.d.ts +15 -15
  55. package/index.js +16 -15
  56. package/index.js.map +1 -1
  57. package/lava/index.d.ts +1 -1
  58. package/lava/index.js +1 -1
  59. package/lava/lava.fragment.d.ts +17 -17
  60. package/lava/lava.fragment.js +20 -20
  61. package/lava/lava.vertex.d.ts +18 -18
  62. package/lava/lava.vertex.js +21 -21
  63. package/lava/lavaMaterial.d.ts +45 -45
  64. package/lava/lavaMaterial.js +394 -394
  65. package/lava/lavaMaterial.js.map +1 -1
  66. package/legacy/legacy-cell.d.ts +1 -1
  67. package/legacy/legacy-cell.js +13 -12
  68. package/legacy/legacy-cell.js.map +1 -1
  69. package/legacy/legacy-custom.d.ts +1 -1
  70. package/legacy/legacy-custom.js +13 -12
  71. package/legacy/legacy-custom.js.map +1 -1
  72. package/legacy/legacy-fire.d.ts +1 -1
  73. package/legacy/legacy-fire.js +13 -12
  74. package/legacy/legacy-fire.js.map +1 -1
  75. package/legacy/legacy-fur.d.ts +1 -1
  76. package/legacy/legacy-fur.js +13 -12
  77. package/legacy/legacy-fur.js.map +1 -1
  78. package/legacy/legacy-gradient.d.ts +1 -1
  79. package/legacy/legacy-gradient.js +13 -12
  80. package/legacy/legacy-gradient.js.map +1 -1
  81. package/legacy/legacy-grid.d.ts +1 -1
  82. package/legacy/legacy-grid.js +13 -12
  83. package/legacy/legacy-grid.js.map +1 -1
  84. package/legacy/legacy-lava.d.ts +1 -1
  85. package/legacy/legacy-lava.js +13 -12
  86. package/legacy/legacy-lava.js.map +1 -1
  87. package/legacy/legacy-mix.d.ts +1 -1
  88. package/legacy/legacy-mix.js +13 -12
  89. package/legacy/legacy-mix.js.map +1 -1
  90. package/legacy/legacy-normal.d.ts +1 -1
  91. package/legacy/legacy-normal.js +13 -12
  92. package/legacy/legacy-normal.js.map +1 -1
  93. package/legacy/legacy-shadowOnly.d.ts +1 -1
  94. package/legacy/legacy-shadowOnly.js +13 -12
  95. package/legacy/legacy-shadowOnly.js.map +1 -1
  96. package/legacy/legacy-simple.d.ts +1 -1
  97. package/legacy/legacy-simple.js +13 -12
  98. package/legacy/legacy-simple.js.map +1 -1
  99. package/legacy/legacy-sky.d.ts +1 -1
  100. package/legacy/legacy-sky.js +13 -12
  101. package/legacy/legacy-sky.js.map +1 -1
  102. package/legacy/legacy-terrain.d.ts +1 -1
  103. package/legacy/legacy-terrain.js +13 -12
  104. package/legacy/legacy-terrain.js.map +1 -1
  105. package/legacy/legacy-triPlanar.d.ts +1 -1
  106. package/legacy/legacy-triPlanar.js +13 -12
  107. package/legacy/legacy-triPlanar.js.map +1 -1
  108. package/legacy/legacy-water.d.ts +1 -1
  109. package/legacy/legacy-water.js +13 -12
  110. package/legacy/legacy-water.js.map +1 -1
  111. package/legacy/legacy.d.ts +1 -1
  112. package/legacy/legacy.js +16 -15
  113. package/legacy/legacy.js.map +1 -1
  114. package/license.md +71 -0
  115. package/mix/index.d.ts +1 -1
  116. package/mix/index.js +1 -1
  117. package/mix/mix.fragment.d.ts +17 -17
  118. package/mix/mix.fragment.js +20 -20
  119. package/mix/mix.vertex.d.ts +18 -18
  120. package/mix/mix.vertex.js +21 -21
  121. package/mix/mixMaterial.d.ts +65 -65
  122. package/mix/mixMaterial.js +510 -510
  123. package/mix/mixMaterial.js.map +1 -1
  124. package/normal/index.d.ts +1 -1
  125. package/normal/index.js +1 -1
  126. package/normal/normal.fragment.d.ts +17 -17
  127. package/normal/normal.fragment.js +20 -20
  128. package/normal/normal.vertex.d.ts +18 -18
  129. package/normal/normal.vertex.js +21 -21
  130. package/normal/normalMaterial.d.ts +36 -36
  131. package/normal/normalMaterial.js +336 -336
  132. package/normal/normalMaterial.js.map +1 -1
  133. package/package.json +24 -5
  134. package/shadowOnly/index.d.ts +1 -1
  135. package/shadowOnly/index.js +1 -1
  136. package/shadowOnly/shadowOnly.fragment.d.ts +16 -16
  137. package/shadowOnly/shadowOnly.fragment.js +19 -19
  138. package/shadowOnly/shadowOnly.vertex.d.ts +18 -18
  139. package/shadowOnly/shadowOnly.vertex.js +21 -21
  140. package/shadowOnly/shadowOnlyMaterial.d.ts +30 -30
  141. package/shadowOnly/shadowOnlyMaterial.js +254 -254
  142. package/shadowOnly/shadowOnlyMaterial.js.map +1 -1
  143. package/simple/index.d.ts +1 -1
  144. package/simple/index.js +1 -1
  145. package/simple/simple.fragment.d.ts +17 -17
  146. package/simple/simple.fragment.js +20 -20
  147. package/simple/simple.vertex.d.ts +18 -18
  148. package/simple/simple.vertex.js +21 -21
  149. package/simple/simpleMaterial.d.ts +35 -35
  150. package/simple/simpleMaterial.js +295 -295
  151. package/simple/simpleMaterial.js.map +1 -1
  152. package/sky/index.d.ts +1 -1
  153. package/sky/index.js +1 -1
  154. package/sky/sky.fragment.d.ts +10 -10
  155. package/sky/sky.fragment.js +13 -13
  156. package/sky/sky.vertex.d.ts +9 -9
  157. package/sky/sky.vertex.js +12 -12
  158. package/sky/skyMaterial.d.ts +147 -146
  159. package/sky/skyMaterial.js +359 -359
  160. package/sky/skyMaterial.js.map +1 -1
  161. package/terrain/index.d.ts +1 -1
  162. package/terrain/index.js +1 -1
  163. package/terrain/terrain.fragment.d.ts +17 -17
  164. package/terrain/terrain.fragment.js +20 -20
  165. package/terrain/terrain.vertex.d.ts +18 -18
  166. package/terrain/terrain.vertex.js +21 -21
  167. package/terrain/terrainMaterial.d.ts +50 -50
  168. package/terrain/terrainMaterial.js +426 -426
  169. package/terrain/terrainMaterial.js.map +1 -1
  170. package/triPlanar/index.d.ts +1 -1
  171. package/triPlanar/index.js +1 -1
  172. package/triPlanar/triPlanarMaterial.d.ts +49 -49
  173. package/triPlanar/triPlanarMaterial.js +403 -403
  174. package/triPlanar/triPlanarMaterial.js.map +1 -1
  175. package/triPlanar/triplanar.fragment.d.ts +17 -17
  176. package/triPlanar/triplanar.fragment.js +20 -20
  177. package/triPlanar/triplanar.vertex.d.ts +18 -18
  178. package/triPlanar/triplanar.vertex.js +21 -21
  179. package/water/index.d.ts +1 -1
  180. package/water/index.js +1 -1
  181. package/water/water.fragment.d.ts +19 -19
  182. package/water/water.fragment.js +22 -22
  183. package/water/water.vertex.d.ts +20 -20
  184. package/water/water.vertex.js +23 -23
  185. package/water/waterMaterial.d.ts +135 -135
  186. package/water/waterMaterial.js +736 -736
  187. package/water/waterMaterial.js.map +1 -1
@@ -1,343 +1,343 @@
1
- import { __decorate, __extends } from "tslib";
2
- import { serializeAsTexture, serialize, expandToProperty, serializeAsColor3, SerializationHelper } from "@babylonjs/core/Misc/decorators.js";
3
- import { Color3 } from "@babylonjs/core/Maths/math.color.js";
4
- import { Tags } from "@babylonjs/core/Misc/tags.js";
5
- import { Texture } from "@babylonjs/core/Materials/Textures/texture.js";
6
- import { MaterialDefines } from "@babylonjs/core/Materials/materialDefines.js";
7
- import { MaterialHelper } from "@babylonjs/core/Materials/materialHelper.js";
8
- import { PushMaterial } from "@babylonjs/core/Materials/pushMaterial.js";
9
- import { MaterialFlags } from "@babylonjs/core/Materials/materialFlags.js";
10
- import { VertexBuffer } from "@babylonjs/core/Buffers/buffer.js";
11
- import { Scene } from "@babylonjs/core/scene.js";
12
- import { RegisterClass } from "@babylonjs/core/Misc/typeStore.js";
13
- import "./fire.fragment.js";
14
- import "./fire.vertex.js";
15
- import { EffectFallbacks } from "@babylonjs/core/Materials/effectFallbacks.js";
16
- var FireMaterialDefines = /** @class */ (function (_super) {
17
- __extends(FireMaterialDefines, _super);
18
- function FireMaterialDefines() {
19
- var _this = _super.call(this) || this;
20
- _this.DIFFUSE = false;
21
- _this.CLIPPLANE = false;
22
- _this.CLIPPLANE2 = false;
23
- _this.CLIPPLANE3 = false;
24
- _this.CLIPPLANE4 = false;
25
- _this.CLIPPLANE5 = false;
26
- _this.CLIPPLANE6 = false;
27
- _this.ALPHATEST = false;
28
- _this.DEPTHPREPASS = false;
29
- _this.POINTSIZE = false;
30
- _this.FOG = false;
31
- _this.UV1 = false;
32
- _this.VERTEXCOLOR = false;
33
- _this.VERTEXALPHA = false;
34
- _this.BonesPerMesh = 0;
35
- _this.NUM_BONE_INFLUENCERS = 0;
36
- _this.INSTANCES = false;
37
- _this.INSTANCESCOLOR = false;
38
- _this.IMAGEPROCESSINGPOSTPROCESS = false;
39
- _this.SKIPFINALCOLORCLAMP = false;
40
- _this.rebuild();
41
- return _this;
42
- }
43
- return FireMaterialDefines;
44
- }(MaterialDefines));
45
- var FireMaterial = /** @class */ (function (_super) {
46
- __extends(FireMaterial, _super);
47
- function FireMaterial(name, scene) {
48
- var _this = _super.call(this, name, scene) || this;
49
- _this.diffuseColor = new Color3(1, 1, 1);
50
- _this.speed = 1.0;
51
- _this._scaledDiffuse = new Color3();
52
- _this._lastTime = 0;
53
- return _this;
54
- }
55
- FireMaterial.prototype.needAlphaBlending = function () {
56
- return false;
57
- };
58
- FireMaterial.prototype.needAlphaTesting = function () {
59
- return true;
60
- };
61
- FireMaterial.prototype.getAlphaTestTexture = function () {
62
- return null;
63
- };
64
- // Methods
65
- FireMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
66
- if (this.isFrozen) {
67
- if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
68
- return true;
69
- }
70
- }
71
- if (!subMesh.materialDefines) {
72
- subMesh.materialDefines = new FireMaterialDefines();
73
- }
74
- var defines = subMesh.materialDefines;
75
- var scene = this.getScene();
76
- if (this._isReadyForSubMesh(subMesh)) {
77
- return true;
78
- }
79
- var engine = scene.getEngine();
80
- // Textures
81
- if (defines._areTexturesDirty) {
82
- defines._needUVs = false;
83
- if (this._diffuseTexture && MaterialFlags.DiffuseTextureEnabled) {
84
- if (!this._diffuseTexture.isReady()) {
85
- return false;
86
- }
87
- else {
88
- defines._needUVs = true;
89
- defines.DIFFUSE = true;
90
- }
91
- }
92
- }
93
- defines.ALPHATEST = this._opacityTexture ? true : false;
94
- // Misc.
95
- if (defines._areMiscDirty) {
96
- defines.POINTSIZE = this.pointsCloud || scene.forcePointsCloud;
97
- defines.FOG = scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE && this.fogEnabled;
98
- }
99
- // Values that need to be evaluated on every frame
100
- MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
101
- // Attribs
102
- MaterialHelper.PrepareDefinesForAttributes(mesh, defines, false, true);
103
- // Get correct effect
104
- if (defines.isDirty) {
105
- defines.markAsProcessed();
106
- scene.resetCachedMaterial();
107
- // Fallbacks
108
- var fallbacks = new EffectFallbacks();
109
- if (defines.FOG) {
110
- fallbacks.addFallback(1, "FOG");
111
- }
112
- if (defines.NUM_BONE_INFLUENCERS > 0) {
113
- fallbacks.addCPUSkinningFallback(0, mesh);
114
- }
115
- defines.IMAGEPROCESSINGPOSTPROCESS = scene.imageProcessingConfiguration.applyByPostProcess;
116
- //Attributes
117
- var attribs = [VertexBuffer.PositionKind];
118
- if (defines.UV1) {
119
- attribs.push(VertexBuffer.UVKind);
120
- }
121
- if (defines.VERTEXCOLOR) {
122
- attribs.push(VertexBuffer.ColorKind);
123
- }
124
- MaterialHelper.PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
125
- MaterialHelper.PrepareAttributesForInstances(attribs, defines);
126
- // Legacy browser patch
127
- var shaderName = "fire";
128
- var join = defines.toString();
129
- subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
130
- attributes: attribs,
131
- uniformsNames: [
132
- "world",
133
- "view",
134
- "viewProjection",
135
- "vEyePosition",
136
- "vFogInfos",
137
- "vFogColor",
138
- "pointSize",
139
- "vDiffuseInfos",
140
- "mBones",
141
- "vClipPlane",
142
- "vClipPlane2",
143
- "vClipPlane3",
144
- "vClipPlane4",
145
- "vClipPlane5",
146
- "vClipPlane6",
147
- "diffuseMatrix",
148
- // Fire
149
- "time",
150
- "speed",
151
- ],
152
- uniformBuffersNames: [],
153
- samplers: [
154
- "diffuseSampler",
155
- // Fire
156
- "distortionSampler",
157
- "opacitySampler",
158
- ],
159
- defines: join,
160
- fallbacks: fallbacks,
161
- onCompiled: this.onCompiled,
162
- onError: this.onError,
163
- indexParameters: null,
164
- maxSimultaneousLights: 4,
165
- transformFeedbackVaryings: null,
166
- }, engine), defines, this._materialContext);
167
- }
168
- if (!subMesh.effect || !subMesh.effect.isReady()) {
169
- return false;
170
- }
171
- defines._renderId = scene.getRenderId();
172
- subMesh.effect._wasPreviouslyReady = true;
173
- return true;
174
- };
175
- FireMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
176
- var scene = this.getScene();
177
- var defines = subMesh.materialDefines;
178
- if (!defines) {
179
- return;
180
- }
181
- var effect = subMesh.effect;
182
- if (!effect) {
183
- return;
184
- }
185
- this._activeEffect = effect;
186
- // Matrices
187
- this.bindOnlyWorldMatrix(world);
188
- this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
189
- // Bones
190
- MaterialHelper.BindBonesParameters(mesh, this._activeEffect);
191
- if (this._mustRebind(scene, effect)) {
192
- // Textures
193
- if (this._diffuseTexture && MaterialFlags.DiffuseTextureEnabled) {
194
- this._activeEffect.setTexture("diffuseSampler", this._diffuseTexture);
195
- this._activeEffect.setFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
196
- this._activeEffect.setMatrix("diffuseMatrix", this._diffuseTexture.getTextureMatrix());
197
- this._activeEffect.setTexture("distortionSampler", this._distortionTexture);
198
- this._activeEffect.setTexture("opacitySampler", this._opacityTexture);
199
- }
200
- // Clip plane
201
- MaterialHelper.BindClipPlane(this._activeEffect, scene);
202
- // Point size
203
- if (this.pointsCloud) {
204
- this._activeEffect.setFloat("pointSize", this.pointSize);
205
- }
206
- scene.bindEyePosition(effect);
207
- }
208
- this._activeEffect.setColor4("vDiffuseColor", this._scaledDiffuse, this.alpha * mesh.visibility);
209
- // View
210
- if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE) {
211
- this._activeEffect.setMatrix("view", scene.getViewMatrix());
212
- }
213
- // Fog
214
- MaterialHelper.BindFogParameters(scene, mesh, this._activeEffect);
215
- // Time
216
- this._lastTime += scene.getEngine().getDeltaTime();
217
- this._activeEffect.setFloat("time", this._lastTime);
218
- // Speed
219
- this._activeEffect.setFloat("speed", this.speed);
220
- this._afterBind(mesh, this._activeEffect);
221
- };
222
- FireMaterial.prototype.getAnimatables = function () {
223
- var results = [];
224
- if (this._diffuseTexture && this._diffuseTexture.animations && this._diffuseTexture.animations.length > 0) {
225
- results.push(this._diffuseTexture);
226
- }
227
- if (this._distortionTexture && this._distortionTexture.animations && this._distortionTexture.animations.length > 0) {
228
- results.push(this._distortionTexture);
229
- }
230
- if (this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0) {
231
- results.push(this._opacityTexture);
232
- }
233
- return results;
234
- };
235
- FireMaterial.prototype.getActiveTextures = function () {
236
- var activeTextures = _super.prototype.getActiveTextures.call(this);
237
- if (this._diffuseTexture) {
238
- activeTextures.push(this._diffuseTexture);
239
- }
240
- if (this._distortionTexture) {
241
- activeTextures.push(this._distortionTexture);
242
- }
243
- if (this._opacityTexture) {
244
- activeTextures.push(this._opacityTexture);
245
- }
246
- return activeTextures;
247
- };
248
- FireMaterial.prototype.hasTexture = function (texture) {
249
- if (_super.prototype.hasTexture.call(this, texture)) {
250
- return true;
251
- }
252
- if (this._diffuseTexture === texture) {
253
- return true;
254
- }
255
- if (this._distortionTexture === texture) {
256
- return true;
257
- }
258
- if (this._opacityTexture === texture) {
259
- return true;
260
- }
261
- return false;
262
- };
263
- FireMaterial.prototype.getClassName = function () {
264
- return "FireMaterial";
265
- };
266
- FireMaterial.prototype.dispose = function (forceDisposeEffect) {
267
- if (this._diffuseTexture) {
268
- this._diffuseTexture.dispose();
269
- }
270
- if (this._distortionTexture) {
271
- this._distortionTexture.dispose();
272
- }
273
- _super.prototype.dispose.call(this, forceDisposeEffect);
274
- };
275
- FireMaterial.prototype.clone = function (name) {
276
- var _this = this;
277
- return SerializationHelper.Clone(function () { return new FireMaterial(name, _this.getScene()); }, this);
278
- };
279
- FireMaterial.prototype.serialize = function () {
280
- var serializationObject = _super.prototype.serialize.call(this);
281
- serializationObject.customType = "BABYLON.FireMaterial";
282
- serializationObject.diffuseColor = this.diffuseColor.asArray();
283
- serializationObject.speed = this.speed;
284
- if (this._diffuseTexture) {
285
- serializationObject._diffuseTexture = this._diffuseTexture.serialize();
286
- }
287
- if (this._distortionTexture) {
288
- serializationObject._distortionTexture = this._distortionTexture.serialize();
289
- }
290
- if (this._opacityTexture) {
291
- serializationObject._opacityTexture = this._opacityTexture.serialize();
292
- }
293
- return serializationObject;
294
- };
295
- FireMaterial.Parse = function (source, scene, rootUrl) {
296
- var material = new FireMaterial(source.name, scene);
297
- material.diffuseColor = Color3.FromArray(source.diffuseColor);
298
- material.speed = source.speed;
299
- material.alpha = source.alpha;
300
- material.id = source.id;
301
- Tags.AddTagsTo(material, source.tags);
302
- material.backFaceCulling = source.backFaceCulling;
303
- material.wireframe = source.wireframe;
304
- if (source._diffuseTexture) {
305
- material._diffuseTexture = Texture.Parse(source._diffuseTexture, scene, rootUrl);
306
- }
307
- if (source._distortionTexture) {
308
- material._distortionTexture = Texture.Parse(source._distortionTexture, scene, rootUrl);
309
- }
310
- if (source._opacityTexture) {
311
- material._opacityTexture = Texture.Parse(source._opacityTexture, scene, rootUrl);
312
- }
313
- return material;
314
- };
315
- __decorate([
316
- serializeAsTexture("diffuseTexture")
317
- ], FireMaterial.prototype, "_diffuseTexture", void 0);
318
- __decorate([
319
- expandToProperty("_markAllSubMeshesAsTexturesDirty")
320
- ], FireMaterial.prototype, "diffuseTexture", void 0);
321
- __decorate([
322
- serializeAsTexture("distortionTexture")
323
- ], FireMaterial.prototype, "_distortionTexture", void 0);
324
- __decorate([
325
- expandToProperty("_markAllSubMeshesAsTexturesDirty")
326
- ], FireMaterial.prototype, "distortionTexture", void 0);
327
- __decorate([
328
- serializeAsTexture("opacityTexture")
329
- ], FireMaterial.prototype, "_opacityTexture", void 0);
330
- __decorate([
331
- expandToProperty("_markAllSubMeshesAsTexturesDirty")
332
- ], FireMaterial.prototype, "opacityTexture", void 0);
333
- __decorate([
334
- serializeAsColor3("diffuse")
335
- ], FireMaterial.prototype, "diffuseColor", void 0);
336
- __decorate([
337
- serialize()
338
- ], FireMaterial.prototype, "speed", void 0);
339
- return FireMaterial;
340
- }(PushMaterial));
341
- export { FireMaterial };
342
- RegisterClass("BABYLON.FireMaterial", FireMaterial);
1
+ import { __decorate, __extends } from "tslib";
2
+ import { serializeAsTexture, serialize, expandToProperty, serializeAsColor3, SerializationHelper } from "@babylonjs/core/Misc/decorators.js";
3
+ import { Color3 } from "@babylonjs/core/Maths/math.color.js";
4
+ import { Tags } from "@babylonjs/core/Misc/tags.js";
5
+ import { Texture } from "@babylonjs/core/Materials/Textures/texture.js";
6
+ import { MaterialDefines } from "@babylonjs/core/Materials/materialDefines.js";
7
+ import { MaterialHelper } from "@babylonjs/core/Materials/materialHelper.js";
8
+ import { PushMaterial } from "@babylonjs/core/Materials/pushMaterial.js";
9
+ import { MaterialFlags } from "@babylonjs/core/Materials/materialFlags.js";
10
+ import { VertexBuffer } from "@babylonjs/core/Buffers/buffer.js";
11
+ import { Scene } from "@babylonjs/core/scene.js";
12
+ import { RegisterClass } from "@babylonjs/core/Misc/typeStore.js";
13
+ import "./fire.fragment.js";
14
+ import "./fire.vertex.js";
15
+ import { EffectFallbacks } from "@babylonjs/core/Materials/effectFallbacks.js";
16
+ var FireMaterialDefines = /** @class */ (function (_super) {
17
+ __extends(FireMaterialDefines, _super);
18
+ function FireMaterialDefines() {
19
+ var _this = _super.call(this) || this;
20
+ _this.DIFFUSE = false;
21
+ _this.CLIPPLANE = false;
22
+ _this.CLIPPLANE2 = false;
23
+ _this.CLIPPLANE3 = false;
24
+ _this.CLIPPLANE4 = false;
25
+ _this.CLIPPLANE5 = false;
26
+ _this.CLIPPLANE6 = false;
27
+ _this.ALPHATEST = false;
28
+ _this.DEPTHPREPASS = false;
29
+ _this.POINTSIZE = false;
30
+ _this.FOG = false;
31
+ _this.UV1 = false;
32
+ _this.VERTEXCOLOR = false;
33
+ _this.VERTEXALPHA = false;
34
+ _this.BonesPerMesh = 0;
35
+ _this.NUM_BONE_INFLUENCERS = 0;
36
+ _this.INSTANCES = false;
37
+ _this.INSTANCESCOLOR = false;
38
+ _this.IMAGEPROCESSINGPOSTPROCESS = false;
39
+ _this.SKIPFINALCOLORCLAMP = false;
40
+ _this.rebuild();
41
+ return _this;
42
+ }
43
+ return FireMaterialDefines;
44
+ }(MaterialDefines));
45
+ var FireMaterial = /** @class */ (function (_super) {
46
+ __extends(FireMaterial, _super);
47
+ function FireMaterial(name, scene) {
48
+ var _this = _super.call(this, name, scene) || this;
49
+ _this.diffuseColor = new Color3(1, 1, 1);
50
+ _this.speed = 1.0;
51
+ _this._scaledDiffuse = new Color3();
52
+ _this._lastTime = 0;
53
+ return _this;
54
+ }
55
+ FireMaterial.prototype.needAlphaBlending = function () {
56
+ return false;
57
+ };
58
+ FireMaterial.prototype.needAlphaTesting = function () {
59
+ return true;
60
+ };
61
+ FireMaterial.prototype.getAlphaTestTexture = function () {
62
+ return null;
63
+ };
64
+ // Methods
65
+ FireMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
66
+ if (this.isFrozen) {
67
+ if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
68
+ return true;
69
+ }
70
+ }
71
+ if (!subMesh.materialDefines) {
72
+ subMesh.materialDefines = new FireMaterialDefines();
73
+ }
74
+ var defines = subMesh.materialDefines;
75
+ var scene = this.getScene();
76
+ if (this._isReadyForSubMesh(subMesh)) {
77
+ return true;
78
+ }
79
+ var engine = scene.getEngine();
80
+ // Textures
81
+ if (defines._areTexturesDirty) {
82
+ defines._needUVs = false;
83
+ if (this._diffuseTexture && MaterialFlags.DiffuseTextureEnabled) {
84
+ if (!this._diffuseTexture.isReady()) {
85
+ return false;
86
+ }
87
+ else {
88
+ defines._needUVs = true;
89
+ defines.DIFFUSE = true;
90
+ }
91
+ }
92
+ }
93
+ defines.ALPHATEST = this._opacityTexture ? true : false;
94
+ // Misc.
95
+ if (defines._areMiscDirty) {
96
+ defines.POINTSIZE = this.pointsCloud || scene.forcePointsCloud;
97
+ defines.FOG = scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE && this.fogEnabled;
98
+ }
99
+ // Values that need to be evaluated on every frame
100
+ MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
101
+ // Attribs
102
+ MaterialHelper.PrepareDefinesForAttributes(mesh, defines, false, true);
103
+ // Get correct effect
104
+ if (defines.isDirty) {
105
+ defines.markAsProcessed();
106
+ scene.resetCachedMaterial();
107
+ // Fallbacks
108
+ var fallbacks = new EffectFallbacks();
109
+ if (defines.FOG) {
110
+ fallbacks.addFallback(1, "FOG");
111
+ }
112
+ if (defines.NUM_BONE_INFLUENCERS > 0) {
113
+ fallbacks.addCPUSkinningFallback(0, mesh);
114
+ }
115
+ defines.IMAGEPROCESSINGPOSTPROCESS = scene.imageProcessingConfiguration.applyByPostProcess;
116
+ //Attributes
117
+ var attribs = [VertexBuffer.PositionKind];
118
+ if (defines.UV1) {
119
+ attribs.push(VertexBuffer.UVKind);
120
+ }
121
+ if (defines.VERTEXCOLOR) {
122
+ attribs.push(VertexBuffer.ColorKind);
123
+ }
124
+ MaterialHelper.PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
125
+ MaterialHelper.PrepareAttributesForInstances(attribs, defines);
126
+ // Legacy browser patch
127
+ var shaderName = "fire";
128
+ var join = defines.toString();
129
+ subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
130
+ attributes: attribs,
131
+ uniformsNames: [
132
+ "world",
133
+ "view",
134
+ "viewProjection",
135
+ "vEyePosition",
136
+ "vFogInfos",
137
+ "vFogColor",
138
+ "pointSize",
139
+ "vDiffuseInfos",
140
+ "mBones",
141
+ "vClipPlane",
142
+ "vClipPlane2",
143
+ "vClipPlane3",
144
+ "vClipPlane4",
145
+ "vClipPlane5",
146
+ "vClipPlane6",
147
+ "diffuseMatrix",
148
+ // Fire
149
+ "time",
150
+ "speed",
151
+ ],
152
+ uniformBuffersNames: [],
153
+ samplers: [
154
+ "diffuseSampler",
155
+ // Fire
156
+ "distortionSampler",
157
+ "opacitySampler",
158
+ ],
159
+ defines: join,
160
+ fallbacks: fallbacks,
161
+ onCompiled: this.onCompiled,
162
+ onError: this.onError,
163
+ indexParameters: null,
164
+ maxSimultaneousLights: 4,
165
+ transformFeedbackVaryings: null,
166
+ }, engine), defines, this._materialContext);
167
+ }
168
+ if (!subMesh.effect || !subMesh.effect.isReady()) {
169
+ return false;
170
+ }
171
+ defines._renderId = scene.getRenderId();
172
+ subMesh.effect._wasPreviouslyReady = true;
173
+ return true;
174
+ };
175
+ FireMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
176
+ var scene = this.getScene();
177
+ var defines = subMesh.materialDefines;
178
+ if (!defines) {
179
+ return;
180
+ }
181
+ var effect = subMesh.effect;
182
+ if (!effect) {
183
+ return;
184
+ }
185
+ this._activeEffect = effect;
186
+ // Matrices
187
+ this.bindOnlyWorldMatrix(world);
188
+ this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
189
+ // Bones
190
+ MaterialHelper.BindBonesParameters(mesh, this._activeEffect);
191
+ if (this._mustRebind(scene, effect)) {
192
+ // Textures
193
+ if (this._diffuseTexture && MaterialFlags.DiffuseTextureEnabled) {
194
+ this._activeEffect.setTexture("diffuseSampler", this._diffuseTexture);
195
+ this._activeEffect.setFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
196
+ this._activeEffect.setMatrix("diffuseMatrix", this._diffuseTexture.getTextureMatrix());
197
+ this._activeEffect.setTexture("distortionSampler", this._distortionTexture);
198
+ this._activeEffect.setTexture("opacitySampler", this._opacityTexture);
199
+ }
200
+ // Clip plane
201
+ MaterialHelper.BindClipPlane(this._activeEffect, scene);
202
+ // Point size
203
+ if (this.pointsCloud) {
204
+ this._activeEffect.setFloat("pointSize", this.pointSize);
205
+ }
206
+ scene.bindEyePosition(effect);
207
+ }
208
+ this._activeEffect.setColor4("vDiffuseColor", this._scaledDiffuse, this.alpha * mesh.visibility);
209
+ // View
210
+ if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE) {
211
+ this._activeEffect.setMatrix("view", scene.getViewMatrix());
212
+ }
213
+ // Fog
214
+ MaterialHelper.BindFogParameters(scene, mesh, this._activeEffect);
215
+ // Time
216
+ this._lastTime += scene.getEngine().getDeltaTime();
217
+ this._activeEffect.setFloat("time", this._lastTime);
218
+ // Speed
219
+ this._activeEffect.setFloat("speed", this.speed);
220
+ this._afterBind(mesh, this._activeEffect);
221
+ };
222
+ FireMaterial.prototype.getAnimatables = function () {
223
+ var results = [];
224
+ if (this._diffuseTexture && this._diffuseTexture.animations && this._diffuseTexture.animations.length > 0) {
225
+ results.push(this._diffuseTexture);
226
+ }
227
+ if (this._distortionTexture && this._distortionTexture.animations && this._distortionTexture.animations.length > 0) {
228
+ results.push(this._distortionTexture);
229
+ }
230
+ if (this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0) {
231
+ results.push(this._opacityTexture);
232
+ }
233
+ return results;
234
+ };
235
+ FireMaterial.prototype.getActiveTextures = function () {
236
+ var activeTextures = _super.prototype.getActiveTextures.call(this);
237
+ if (this._diffuseTexture) {
238
+ activeTextures.push(this._diffuseTexture);
239
+ }
240
+ if (this._distortionTexture) {
241
+ activeTextures.push(this._distortionTexture);
242
+ }
243
+ if (this._opacityTexture) {
244
+ activeTextures.push(this._opacityTexture);
245
+ }
246
+ return activeTextures;
247
+ };
248
+ FireMaterial.prototype.hasTexture = function (texture) {
249
+ if (_super.prototype.hasTexture.call(this, texture)) {
250
+ return true;
251
+ }
252
+ if (this._diffuseTexture === texture) {
253
+ return true;
254
+ }
255
+ if (this._distortionTexture === texture) {
256
+ return true;
257
+ }
258
+ if (this._opacityTexture === texture) {
259
+ return true;
260
+ }
261
+ return false;
262
+ };
263
+ FireMaterial.prototype.getClassName = function () {
264
+ return "FireMaterial";
265
+ };
266
+ FireMaterial.prototype.dispose = function (forceDisposeEffect) {
267
+ if (this._diffuseTexture) {
268
+ this._diffuseTexture.dispose();
269
+ }
270
+ if (this._distortionTexture) {
271
+ this._distortionTexture.dispose();
272
+ }
273
+ _super.prototype.dispose.call(this, forceDisposeEffect);
274
+ };
275
+ FireMaterial.prototype.clone = function (name) {
276
+ var _this = this;
277
+ return SerializationHelper.Clone(function () { return new FireMaterial(name, _this.getScene()); }, this);
278
+ };
279
+ FireMaterial.prototype.serialize = function () {
280
+ var serializationObject = _super.prototype.serialize.call(this);
281
+ serializationObject.customType = "BABYLON.FireMaterial";
282
+ serializationObject.diffuseColor = this.diffuseColor.asArray();
283
+ serializationObject.speed = this.speed;
284
+ if (this._diffuseTexture) {
285
+ serializationObject._diffuseTexture = this._diffuseTexture.serialize();
286
+ }
287
+ if (this._distortionTexture) {
288
+ serializationObject._distortionTexture = this._distortionTexture.serialize();
289
+ }
290
+ if (this._opacityTexture) {
291
+ serializationObject._opacityTexture = this._opacityTexture.serialize();
292
+ }
293
+ return serializationObject;
294
+ };
295
+ FireMaterial.Parse = function (source, scene, rootUrl) {
296
+ var material = new FireMaterial(source.name, scene);
297
+ material.diffuseColor = Color3.FromArray(source.diffuseColor);
298
+ material.speed = source.speed;
299
+ material.alpha = source.alpha;
300
+ material.id = source.id;
301
+ Tags.AddTagsTo(material, source.tags);
302
+ material.backFaceCulling = source.backFaceCulling;
303
+ material.wireframe = source.wireframe;
304
+ if (source._diffuseTexture) {
305
+ material._diffuseTexture = Texture.Parse(source._diffuseTexture, scene, rootUrl);
306
+ }
307
+ if (source._distortionTexture) {
308
+ material._distortionTexture = Texture.Parse(source._distortionTexture, scene, rootUrl);
309
+ }
310
+ if (source._opacityTexture) {
311
+ material._opacityTexture = Texture.Parse(source._opacityTexture, scene, rootUrl);
312
+ }
313
+ return material;
314
+ };
315
+ __decorate([
316
+ serializeAsTexture("diffuseTexture")
317
+ ], FireMaterial.prototype, "_diffuseTexture", void 0);
318
+ __decorate([
319
+ expandToProperty("_markAllSubMeshesAsTexturesDirty")
320
+ ], FireMaterial.prototype, "diffuseTexture", void 0);
321
+ __decorate([
322
+ serializeAsTexture("distortionTexture")
323
+ ], FireMaterial.prototype, "_distortionTexture", void 0);
324
+ __decorate([
325
+ expandToProperty("_markAllSubMeshesAsTexturesDirty")
326
+ ], FireMaterial.prototype, "distortionTexture", void 0);
327
+ __decorate([
328
+ serializeAsTexture("opacityTexture")
329
+ ], FireMaterial.prototype, "_opacityTexture", void 0);
330
+ __decorate([
331
+ expandToProperty("_markAllSubMeshesAsTexturesDirty")
332
+ ], FireMaterial.prototype, "opacityTexture", void 0);
333
+ __decorate([
334
+ serializeAsColor3("diffuse")
335
+ ], FireMaterial.prototype, "diffuseColor", void 0);
336
+ __decorate([
337
+ serialize()
338
+ ], FireMaterial.prototype, "speed", void 0);
339
+ return FireMaterial;
340
+ }(PushMaterial));
341
+ export { FireMaterial };
342
+ RegisterClass("BABYLON.FireMaterial", FireMaterial);
343
343
  //# sourceMappingURL=fireMaterial.js.map