@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,395 +1,395 @@
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 { MaterialDefines } from "@babylonjs/core/Materials/materialDefines.js";
5
- import { MaterialHelper } from "@babylonjs/core/Materials/materialHelper.js";
6
- import { PushMaterial } from "@babylonjs/core/Materials/pushMaterial.js";
7
- import { MaterialFlags } from "@babylonjs/core/Materials/materialFlags.js";
8
- import { VertexBuffer } from "@babylonjs/core/Buffers/buffer.js";
9
- import { Scene } from "@babylonjs/core/scene.js";
10
- import { RegisterClass } from "@babylonjs/core/Misc/typeStore.js";
11
- import "./lava.fragment.js";
12
- import "./lava.vertex.js";
13
- import { EffectFallbacks } from "@babylonjs/core/Materials/effectFallbacks.js";
14
- var LavaMaterialDefines = /** @class */ (function (_super) {
15
- __extends(LavaMaterialDefines, _super);
16
- function LavaMaterialDefines() {
17
- var _this = _super.call(this) || this;
18
- _this.DIFFUSE = false;
19
- _this.CLIPPLANE = false;
20
- _this.CLIPPLANE2 = false;
21
- _this.CLIPPLANE3 = false;
22
- _this.CLIPPLANE4 = false;
23
- _this.CLIPPLANE5 = false;
24
- _this.CLIPPLANE6 = false;
25
- _this.ALPHATEST = false;
26
- _this.DEPTHPREPASS = false;
27
- _this.POINTSIZE = false;
28
- _this.FOG = false;
29
- _this.LIGHT0 = false;
30
- _this.LIGHT1 = false;
31
- _this.LIGHT2 = false;
32
- _this.LIGHT3 = false;
33
- _this.SPOTLIGHT0 = false;
34
- _this.SPOTLIGHT1 = false;
35
- _this.SPOTLIGHT2 = false;
36
- _this.SPOTLIGHT3 = false;
37
- _this.HEMILIGHT0 = false;
38
- _this.HEMILIGHT1 = false;
39
- _this.HEMILIGHT2 = false;
40
- _this.HEMILIGHT3 = false;
41
- _this.DIRLIGHT0 = false;
42
- _this.DIRLIGHT1 = false;
43
- _this.DIRLIGHT2 = false;
44
- _this.DIRLIGHT3 = false;
45
- _this.POINTLIGHT0 = false;
46
- _this.POINTLIGHT1 = false;
47
- _this.POINTLIGHT2 = false;
48
- _this.POINTLIGHT3 = false;
49
- _this.SHADOW0 = false;
50
- _this.SHADOW1 = false;
51
- _this.SHADOW2 = false;
52
- _this.SHADOW3 = false;
53
- _this.SHADOWS = false;
54
- _this.SHADOWESM0 = false;
55
- _this.SHADOWESM1 = false;
56
- _this.SHADOWESM2 = false;
57
- _this.SHADOWESM3 = false;
58
- _this.SHADOWPOISSON0 = false;
59
- _this.SHADOWPOISSON1 = false;
60
- _this.SHADOWPOISSON2 = false;
61
- _this.SHADOWPOISSON3 = false;
62
- _this.SHADOWPCF0 = false;
63
- _this.SHADOWPCF1 = false;
64
- _this.SHADOWPCF2 = false;
65
- _this.SHADOWPCF3 = false;
66
- _this.SHADOWPCSS0 = false;
67
- _this.SHADOWPCSS1 = false;
68
- _this.SHADOWPCSS2 = false;
69
- _this.SHADOWPCSS3 = false;
70
- _this.NORMAL = false;
71
- _this.UV1 = false;
72
- _this.UV2 = false;
73
- _this.VERTEXCOLOR = false;
74
- _this.VERTEXALPHA = false;
75
- _this.NUM_BONE_INFLUENCERS = 0;
76
- _this.BonesPerMesh = 0;
77
- _this.INSTANCES = false;
78
- _this.INSTANCESCOLOR = false;
79
- _this.UNLIT = false;
80
- _this.IMAGEPROCESSINGPOSTPROCESS = false;
81
- _this.SKIPFINALCOLORCLAMP = false;
82
- _this.rebuild();
83
- return _this;
84
- }
85
- return LavaMaterialDefines;
86
- }(MaterialDefines));
87
- var LavaMaterial = /** @class */ (function (_super) {
88
- __extends(LavaMaterial, _super);
89
- function LavaMaterial(name, scene) {
90
- var _this = _super.call(this, name, scene) || this;
91
- _this.speed = 1;
92
- _this.movingSpeed = 1;
93
- _this.lowFrequencySpeed = 1;
94
- _this.fogDensity = 0.15;
95
- _this._lastTime = 0;
96
- _this.diffuseColor = new Color3(1, 1, 1);
97
- _this._disableLighting = false;
98
- _this._unlit = false;
99
- _this._maxSimultaneousLights = 4;
100
- _this._scaledDiffuse = new Color3();
101
- return _this;
102
- }
103
- LavaMaterial.prototype.needAlphaBlending = function () {
104
- return this.alpha < 1.0;
105
- };
106
- LavaMaterial.prototype.needAlphaTesting = function () {
107
- return false;
108
- };
109
- LavaMaterial.prototype.getAlphaTestTexture = function () {
110
- return null;
111
- };
112
- // Methods
113
- LavaMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
114
- if (this.isFrozen) {
115
- if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
116
- return true;
117
- }
118
- }
119
- if (!subMesh.materialDefines) {
120
- subMesh.materialDefines = new LavaMaterialDefines();
121
- }
122
- var defines = subMesh.materialDefines;
123
- var scene = this.getScene();
124
- if (this._isReadyForSubMesh(subMesh)) {
125
- return true;
126
- }
127
- var engine = scene.getEngine();
128
- // Textures
129
- if (defines._areTexturesDirty) {
130
- defines._needUVs = false;
131
- if (scene.texturesEnabled) {
132
- if (this._diffuseTexture && MaterialFlags.DiffuseTextureEnabled) {
133
- if (!this._diffuseTexture.isReady()) {
134
- return false;
135
- }
136
- else {
137
- defines._needUVs = true;
138
- defines.DIFFUSE = true;
139
- }
140
- }
141
- }
142
- }
143
- // Misc.
144
- MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
145
- // Lights
146
- defines._needNormals = true;
147
- MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
148
- // Values that need to be evaluated on every frame
149
- MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
150
- // Attribs
151
- MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true);
152
- // Get correct effect
153
- if (defines.isDirty) {
154
- defines.markAsProcessed();
155
- scene.resetCachedMaterial();
156
- // Fallbacks
157
- var fallbacks = new EffectFallbacks();
158
- if (defines.FOG) {
159
- fallbacks.addFallback(1, "FOG");
160
- }
161
- MaterialHelper.HandleFallbacksForShadows(defines, fallbacks);
162
- if (defines.NUM_BONE_INFLUENCERS > 0) {
163
- fallbacks.addCPUSkinningFallback(0, mesh);
164
- }
165
- defines.IMAGEPROCESSINGPOSTPROCESS = scene.imageProcessingConfiguration.applyByPostProcess;
166
- //Attributes
167
- var attribs = [VertexBuffer.PositionKind];
168
- if (defines.NORMAL) {
169
- attribs.push(VertexBuffer.NormalKind);
170
- }
171
- if (defines.UV1) {
172
- attribs.push(VertexBuffer.UVKind);
173
- }
174
- if (defines.UV2) {
175
- attribs.push(VertexBuffer.UV2Kind);
176
- }
177
- if (defines.VERTEXCOLOR) {
178
- attribs.push(VertexBuffer.ColorKind);
179
- }
180
- MaterialHelper.PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
181
- MaterialHelper.PrepareAttributesForInstances(attribs, defines);
182
- // Legacy browser patch
183
- var shaderName = "lava";
184
- var join = defines.toString();
185
- var uniforms = [
186
- "world",
187
- "view",
188
- "viewProjection",
189
- "vEyePosition",
190
- "vLightsType",
191
- "vDiffuseColor",
192
- "vFogInfos",
193
- "vFogColor",
194
- "pointSize",
195
- "vDiffuseInfos",
196
- "mBones",
197
- "vClipPlane",
198
- "vClipPlane2",
199
- "vClipPlane3",
200
- "vClipPlane4",
201
- "vClipPlane5",
202
- "vClipPlane6",
203
- "diffuseMatrix",
204
- "time",
205
- "speed",
206
- "movingSpeed",
207
- "fogColor",
208
- "fogDensity",
209
- "lowFrequencySpeed",
210
- ];
211
- var samplers = ["diffuseSampler", "noiseTexture"];
212
- var uniformBuffers = new Array();
213
- MaterialHelper.PrepareUniformsAndSamplersList({
214
- uniformsNames: uniforms,
215
- uniformBuffersNames: uniformBuffers,
216
- samplers: samplers,
217
- defines: defines,
218
- maxSimultaneousLights: this.maxSimultaneousLights,
219
- });
220
- subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
221
- attributes: attribs,
222
- uniformsNames: uniforms,
223
- uniformBuffersNames: uniformBuffers,
224
- samplers: samplers,
225
- defines: join,
226
- fallbacks: fallbacks,
227
- onCompiled: this.onCompiled,
228
- onError: this.onError,
229
- indexParameters: { maxSimultaneousLights: this.maxSimultaneousLights },
230
- }, engine), defines, this._materialContext);
231
- }
232
- if (!subMesh.effect || !subMesh.effect.isReady()) {
233
- return false;
234
- }
235
- defines._renderId = scene.getRenderId();
236
- subMesh.effect._wasPreviouslyReady = true;
237
- return true;
238
- };
239
- LavaMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
240
- var scene = this.getScene();
241
- var defines = subMesh.materialDefines;
242
- if (!defines) {
243
- return;
244
- }
245
- var effect = subMesh.effect;
246
- if (!effect) {
247
- return;
248
- }
249
- this._activeEffect = effect;
250
- defines.UNLIT = this._unlit;
251
- // Matrices
252
- this.bindOnlyWorldMatrix(world);
253
- this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
254
- // Bones
255
- MaterialHelper.BindBonesParameters(mesh, this._activeEffect);
256
- if (this._mustRebind(scene, effect)) {
257
- // Textures
258
- if (this.diffuseTexture && MaterialFlags.DiffuseTextureEnabled) {
259
- this._activeEffect.setTexture("diffuseSampler", this.diffuseTexture);
260
- this._activeEffect.setFloat2("vDiffuseInfos", this.diffuseTexture.coordinatesIndex, this.diffuseTexture.level);
261
- this._activeEffect.setMatrix("diffuseMatrix", this.diffuseTexture.getTextureMatrix());
262
- }
263
- if (this.noiseTexture) {
264
- this._activeEffect.setTexture("noiseTexture", this.noiseTexture);
265
- }
266
- // Clip plane
267
- MaterialHelper.BindClipPlane(this._activeEffect, scene);
268
- // Point size
269
- if (this.pointsCloud) {
270
- this._activeEffect.setFloat("pointSize", this.pointSize);
271
- }
272
- scene.bindEyePosition(effect);
273
- }
274
- this._activeEffect.setColor4("vDiffuseColor", this._scaledDiffuse, this.alpha * mesh.visibility);
275
- if (scene.lightsEnabled && !this.disableLighting) {
276
- MaterialHelper.BindLights(scene, mesh, this._activeEffect, defines);
277
- }
278
- // View
279
- if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE) {
280
- this._activeEffect.setMatrix("view", scene.getViewMatrix());
281
- }
282
- // Fog
283
- MaterialHelper.BindFogParameters(scene, mesh, this._activeEffect);
284
- this._lastTime += scene.getEngine().getDeltaTime();
285
- this._activeEffect.setFloat("time", (this._lastTime * this.speed) / 1000);
286
- if (!this.fogColor) {
287
- this.fogColor = Color3.Black();
288
- }
289
- this._activeEffect.setColor3("fogColor", this.fogColor);
290
- this._activeEffect.setFloat("fogDensity", this.fogDensity);
291
- this._activeEffect.setFloat("lowFrequencySpeed", this.lowFrequencySpeed);
292
- this._activeEffect.setFloat("movingSpeed", this.movingSpeed);
293
- this._afterBind(mesh, this._activeEffect);
294
- };
295
- LavaMaterial.prototype.getAnimatables = function () {
296
- var results = [];
297
- if (this.diffuseTexture && this.diffuseTexture.animations && this.diffuseTexture.animations.length > 0) {
298
- results.push(this.diffuseTexture);
299
- }
300
- if (this.noiseTexture && this.noiseTexture.animations && this.noiseTexture.animations.length > 0) {
301
- results.push(this.noiseTexture);
302
- }
303
- return results;
304
- };
305
- LavaMaterial.prototype.getActiveTextures = function () {
306
- var activeTextures = _super.prototype.getActiveTextures.call(this);
307
- if (this._diffuseTexture) {
308
- activeTextures.push(this._diffuseTexture);
309
- }
310
- return activeTextures;
311
- };
312
- LavaMaterial.prototype.hasTexture = function (texture) {
313
- if (_super.prototype.hasTexture.call(this, texture)) {
314
- return true;
315
- }
316
- if (this.diffuseTexture === texture) {
317
- return true;
318
- }
319
- return false;
320
- };
321
- LavaMaterial.prototype.dispose = function (forceDisposeEffect) {
322
- if (this.diffuseTexture) {
323
- this.diffuseTexture.dispose();
324
- }
325
- if (this.noiseTexture) {
326
- this.noiseTexture.dispose();
327
- }
328
- _super.prototype.dispose.call(this, forceDisposeEffect);
329
- };
330
- LavaMaterial.prototype.clone = function (name) {
331
- var _this = this;
332
- return SerializationHelper.Clone(function () { return new LavaMaterial(name, _this.getScene()); }, this);
333
- };
334
- LavaMaterial.prototype.serialize = function () {
335
- var serializationObject = _super.prototype.serialize.call(this);
336
- serializationObject.customType = "BABYLON.LavaMaterial";
337
- return serializationObject;
338
- };
339
- LavaMaterial.prototype.getClassName = function () {
340
- return "LavaMaterial";
341
- };
342
- // Statics
343
- LavaMaterial.Parse = function (source, scene, rootUrl) {
344
- return SerializationHelper.Parse(function () { return new LavaMaterial(source.name, scene); }, source, scene, rootUrl);
345
- };
346
- __decorate([
347
- serializeAsTexture("diffuseTexture")
348
- ], LavaMaterial.prototype, "_diffuseTexture", void 0);
349
- __decorate([
350
- expandToProperty("_markAllSubMeshesAsTexturesDirty")
351
- ], LavaMaterial.prototype, "diffuseTexture", void 0);
352
- __decorate([
353
- serializeAsTexture()
354
- ], LavaMaterial.prototype, "noiseTexture", void 0);
355
- __decorate([
356
- serializeAsColor3()
357
- ], LavaMaterial.prototype, "fogColor", void 0);
358
- __decorate([
359
- serialize()
360
- ], LavaMaterial.prototype, "speed", void 0);
361
- __decorate([
362
- serialize()
363
- ], LavaMaterial.prototype, "movingSpeed", void 0);
364
- __decorate([
365
- serialize()
366
- ], LavaMaterial.prototype, "lowFrequencySpeed", void 0);
367
- __decorate([
368
- serialize()
369
- ], LavaMaterial.prototype, "fogDensity", void 0);
370
- __decorate([
371
- serializeAsColor3()
372
- ], LavaMaterial.prototype, "diffuseColor", void 0);
373
- __decorate([
374
- serialize("disableLighting")
375
- ], LavaMaterial.prototype, "_disableLighting", void 0);
376
- __decorate([
377
- expandToProperty("_markAllSubMeshesAsLightsDirty")
378
- ], LavaMaterial.prototype, "disableLighting", void 0);
379
- __decorate([
380
- serialize("unlit")
381
- ], LavaMaterial.prototype, "_unlit", void 0);
382
- __decorate([
383
- expandToProperty("_markAllSubMeshesAsLightsDirty")
384
- ], LavaMaterial.prototype, "unlit", void 0);
385
- __decorate([
386
- serialize("maxSimultaneousLights")
387
- ], LavaMaterial.prototype, "_maxSimultaneousLights", void 0);
388
- __decorate([
389
- expandToProperty("_markAllSubMeshesAsLightsDirty")
390
- ], LavaMaterial.prototype, "maxSimultaneousLights", void 0);
391
- return LavaMaterial;
392
- }(PushMaterial));
393
- export { LavaMaterial };
394
- RegisterClass("BABYLON.LavaMaterial", LavaMaterial);
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 { MaterialDefines } from "@babylonjs/core/Materials/materialDefines.js";
5
+ import { MaterialHelper } from "@babylonjs/core/Materials/materialHelper.js";
6
+ import { PushMaterial } from "@babylonjs/core/Materials/pushMaterial.js";
7
+ import { MaterialFlags } from "@babylonjs/core/Materials/materialFlags.js";
8
+ import { VertexBuffer } from "@babylonjs/core/Buffers/buffer.js";
9
+ import { Scene } from "@babylonjs/core/scene.js";
10
+ import { RegisterClass } from "@babylonjs/core/Misc/typeStore.js";
11
+ import "./lava.fragment.js";
12
+ import "./lava.vertex.js";
13
+ import { EffectFallbacks } from "@babylonjs/core/Materials/effectFallbacks.js";
14
+ var LavaMaterialDefines = /** @class */ (function (_super) {
15
+ __extends(LavaMaterialDefines, _super);
16
+ function LavaMaterialDefines() {
17
+ var _this = _super.call(this) || this;
18
+ _this.DIFFUSE = false;
19
+ _this.CLIPPLANE = false;
20
+ _this.CLIPPLANE2 = false;
21
+ _this.CLIPPLANE3 = false;
22
+ _this.CLIPPLANE4 = false;
23
+ _this.CLIPPLANE5 = false;
24
+ _this.CLIPPLANE6 = false;
25
+ _this.ALPHATEST = false;
26
+ _this.DEPTHPREPASS = false;
27
+ _this.POINTSIZE = false;
28
+ _this.FOG = false;
29
+ _this.LIGHT0 = false;
30
+ _this.LIGHT1 = false;
31
+ _this.LIGHT2 = false;
32
+ _this.LIGHT3 = false;
33
+ _this.SPOTLIGHT0 = false;
34
+ _this.SPOTLIGHT1 = false;
35
+ _this.SPOTLIGHT2 = false;
36
+ _this.SPOTLIGHT3 = false;
37
+ _this.HEMILIGHT0 = false;
38
+ _this.HEMILIGHT1 = false;
39
+ _this.HEMILIGHT2 = false;
40
+ _this.HEMILIGHT3 = false;
41
+ _this.DIRLIGHT0 = false;
42
+ _this.DIRLIGHT1 = false;
43
+ _this.DIRLIGHT2 = false;
44
+ _this.DIRLIGHT3 = false;
45
+ _this.POINTLIGHT0 = false;
46
+ _this.POINTLIGHT1 = false;
47
+ _this.POINTLIGHT2 = false;
48
+ _this.POINTLIGHT3 = false;
49
+ _this.SHADOW0 = false;
50
+ _this.SHADOW1 = false;
51
+ _this.SHADOW2 = false;
52
+ _this.SHADOW3 = false;
53
+ _this.SHADOWS = false;
54
+ _this.SHADOWESM0 = false;
55
+ _this.SHADOWESM1 = false;
56
+ _this.SHADOWESM2 = false;
57
+ _this.SHADOWESM3 = false;
58
+ _this.SHADOWPOISSON0 = false;
59
+ _this.SHADOWPOISSON1 = false;
60
+ _this.SHADOWPOISSON2 = false;
61
+ _this.SHADOWPOISSON3 = false;
62
+ _this.SHADOWPCF0 = false;
63
+ _this.SHADOWPCF1 = false;
64
+ _this.SHADOWPCF2 = false;
65
+ _this.SHADOWPCF3 = false;
66
+ _this.SHADOWPCSS0 = false;
67
+ _this.SHADOWPCSS1 = false;
68
+ _this.SHADOWPCSS2 = false;
69
+ _this.SHADOWPCSS3 = false;
70
+ _this.NORMAL = false;
71
+ _this.UV1 = false;
72
+ _this.UV2 = false;
73
+ _this.VERTEXCOLOR = false;
74
+ _this.VERTEXALPHA = false;
75
+ _this.NUM_BONE_INFLUENCERS = 0;
76
+ _this.BonesPerMesh = 0;
77
+ _this.INSTANCES = false;
78
+ _this.INSTANCESCOLOR = false;
79
+ _this.UNLIT = false;
80
+ _this.IMAGEPROCESSINGPOSTPROCESS = false;
81
+ _this.SKIPFINALCOLORCLAMP = false;
82
+ _this.rebuild();
83
+ return _this;
84
+ }
85
+ return LavaMaterialDefines;
86
+ }(MaterialDefines));
87
+ var LavaMaterial = /** @class */ (function (_super) {
88
+ __extends(LavaMaterial, _super);
89
+ function LavaMaterial(name, scene) {
90
+ var _this = _super.call(this, name, scene) || this;
91
+ _this.speed = 1;
92
+ _this.movingSpeed = 1;
93
+ _this.lowFrequencySpeed = 1;
94
+ _this.fogDensity = 0.15;
95
+ _this._lastTime = 0;
96
+ _this.diffuseColor = new Color3(1, 1, 1);
97
+ _this._disableLighting = false;
98
+ _this._unlit = false;
99
+ _this._maxSimultaneousLights = 4;
100
+ _this._scaledDiffuse = new Color3();
101
+ return _this;
102
+ }
103
+ LavaMaterial.prototype.needAlphaBlending = function () {
104
+ return this.alpha < 1.0;
105
+ };
106
+ LavaMaterial.prototype.needAlphaTesting = function () {
107
+ return false;
108
+ };
109
+ LavaMaterial.prototype.getAlphaTestTexture = function () {
110
+ return null;
111
+ };
112
+ // Methods
113
+ LavaMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
114
+ if (this.isFrozen) {
115
+ if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
116
+ return true;
117
+ }
118
+ }
119
+ if (!subMesh.materialDefines) {
120
+ subMesh.materialDefines = new LavaMaterialDefines();
121
+ }
122
+ var defines = subMesh.materialDefines;
123
+ var scene = this.getScene();
124
+ if (this._isReadyForSubMesh(subMesh)) {
125
+ return true;
126
+ }
127
+ var engine = scene.getEngine();
128
+ // Textures
129
+ if (defines._areTexturesDirty) {
130
+ defines._needUVs = false;
131
+ if (scene.texturesEnabled) {
132
+ if (this._diffuseTexture && MaterialFlags.DiffuseTextureEnabled) {
133
+ if (!this._diffuseTexture.isReady()) {
134
+ return false;
135
+ }
136
+ else {
137
+ defines._needUVs = true;
138
+ defines.DIFFUSE = true;
139
+ }
140
+ }
141
+ }
142
+ }
143
+ // Misc.
144
+ MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
145
+ // Lights
146
+ defines._needNormals = true;
147
+ MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
148
+ // Values that need to be evaluated on every frame
149
+ MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
150
+ // Attribs
151
+ MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true);
152
+ // Get correct effect
153
+ if (defines.isDirty) {
154
+ defines.markAsProcessed();
155
+ scene.resetCachedMaterial();
156
+ // Fallbacks
157
+ var fallbacks = new EffectFallbacks();
158
+ if (defines.FOG) {
159
+ fallbacks.addFallback(1, "FOG");
160
+ }
161
+ MaterialHelper.HandleFallbacksForShadows(defines, fallbacks);
162
+ if (defines.NUM_BONE_INFLUENCERS > 0) {
163
+ fallbacks.addCPUSkinningFallback(0, mesh);
164
+ }
165
+ defines.IMAGEPROCESSINGPOSTPROCESS = scene.imageProcessingConfiguration.applyByPostProcess;
166
+ //Attributes
167
+ var attribs = [VertexBuffer.PositionKind];
168
+ if (defines.NORMAL) {
169
+ attribs.push(VertexBuffer.NormalKind);
170
+ }
171
+ if (defines.UV1) {
172
+ attribs.push(VertexBuffer.UVKind);
173
+ }
174
+ if (defines.UV2) {
175
+ attribs.push(VertexBuffer.UV2Kind);
176
+ }
177
+ if (defines.VERTEXCOLOR) {
178
+ attribs.push(VertexBuffer.ColorKind);
179
+ }
180
+ MaterialHelper.PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
181
+ MaterialHelper.PrepareAttributesForInstances(attribs, defines);
182
+ // Legacy browser patch
183
+ var shaderName = "lava";
184
+ var join = defines.toString();
185
+ var uniforms = [
186
+ "world",
187
+ "view",
188
+ "viewProjection",
189
+ "vEyePosition",
190
+ "vLightsType",
191
+ "vDiffuseColor",
192
+ "vFogInfos",
193
+ "vFogColor",
194
+ "pointSize",
195
+ "vDiffuseInfos",
196
+ "mBones",
197
+ "vClipPlane",
198
+ "vClipPlane2",
199
+ "vClipPlane3",
200
+ "vClipPlane4",
201
+ "vClipPlane5",
202
+ "vClipPlane6",
203
+ "diffuseMatrix",
204
+ "time",
205
+ "speed",
206
+ "movingSpeed",
207
+ "fogColor",
208
+ "fogDensity",
209
+ "lowFrequencySpeed",
210
+ ];
211
+ var samplers = ["diffuseSampler", "noiseTexture"];
212
+ var uniformBuffers = new Array();
213
+ MaterialHelper.PrepareUniformsAndSamplersList({
214
+ uniformsNames: uniforms,
215
+ uniformBuffersNames: uniformBuffers,
216
+ samplers: samplers,
217
+ defines: defines,
218
+ maxSimultaneousLights: this.maxSimultaneousLights,
219
+ });
220
+ subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
221
+ attributes: attribs,
222
+ uniformsNames: uniforms,
223
+ uniformBuffersNames: uniformBuffers,
224
+ samplers: samplers,
225
+ defines: join,
226
+ fallbacks: fallbacks,
227
+ onCompiled: this.onCompiled,
228
+ onError: this.onError,
229
+ indexParameters: { maxSimultaneousLights: this.maxSimultaneousLights },
230
+ }, engine), defines, this._materialContext);
231
+ }
232
+ if (!subMesh.effect || !subMesh.effect.isReady()) {
233
+ return false;
234
+ }
235
+ defines._renderId = scene.getRenderId();
236
+ subMesh.effect._wasPreviouslyReady = true;
237
+ return true;
238
+ };
239
+ LavaMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
240
+ var scene = this.getScene();
241
+ var defines = subMesh.materialDefines;
242
+ if (!defines) {
243
+ return;
244
+ }
245
+ var effect = subMesh.effect;
246
+ if (!effect) {
247
+ return;
248
+ }
249
+ this._activeEffect = effect;
250
+ defines.UNLIT = this._unlit;
251
+ // Matrices
252
+ this.bindOnlyWorldMatrix(world);
253
+ this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
254
+ // Bones
255
+ MaterialHelper.BindBonesParameters(mesh, this._activeEffect);
256
+ if (this._mustRebind(scene, effect)) {
257
+ // Textures
258
+ if (this.diffuseTexture && MaterialFlags.DiffuseTextureEnabled) {
259
+ this._activeEffect.setTexture("diffuseSampler", this.diffuseTexture);
260
+ this._activeEffect.setFloat2("vDiffuseInfos", this.diffuseTexture.coordinatesIndex, this.diffuseTexture.level);
261
+ this._activeEffect.setMatrix("diffuseMatrix", this.diffuseTexture.getTextureMatrix());
262
+ }
263
+ if (this.noiseTexture) {
264
+ this._activeEffect.setTexture("noiseTexture", this.noiseTexture);
265
+ }
266
+ // Clip plane
267
+ MaterialHelper.BindClipPlane(this._activeEffect, scene);
268
+ // Point size
269
+ if (this.pointsCloud) {
270
+ this._activeEffect.setFloat("pointSize", this.pointSize);
271
+ }
272
+ scene.bindEyePosition(effect);
273
+ }
274
+ this._activeEffect.setColor4("vDiffuseColor", this._scaledDiffuse, this.alpha * mesh.visibility);
275
+ if (scene.lightsEnabled && !this.disableLighting) {
276
+ MaterialHelper.BindLights(scene, mesh, this._activeEffect, defines);
277
+ }
278
+ // View
279
+ if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE) {
280
+ this._activeEffect.setMatrix("view", scene.getViewMatrix());
281
+ }
282
+ // Fog
283
+ MaterialHelper.BindFogParameters(scene, mesh, this._activeEffect);
284
+ this._lastTime += scene.getEngine().getDeltaTime();
285
+ this._activeEffect.setFloat("time", (this._lastTime * this.speed) / 1000);
286
+ if (!this.fogColor) {
287
+ this.fogColor = Color3.Black();
288
+ }
289
+ this._activeEffect.setColor3("fogColor", this.fogColor);
290
+ this._activeEffect.setFloat("fogDensity", this.fogDensity);
291
+ this._activeEffect.setFloat("lowFrequencySpeed", this.lowFrequencySpeed);
292
+ this._activeEffect.setFloat("movingSpeed", this.movingSpeed);
293
+ this._afterBind(mesh, this._activeEffect);
294
+ };
295
+ LavaMaterial.prototype.getAnimatables = function () {
296
+ var results = [];
297
+ if (this.diffuseTexture && this.diffuseTexture.animations && this.diffuseTexture.animations.length > 0) {
298
+ results.push(this.diffuseTexture);
299
+ }
300
+ if (this.noiseTexture && this.noiseTexture.animations && this.noiseTexture.animations.length > 0) {
301
+ results.push(this.noiseTexture);
302
+ }
303
+ return results;
304
+ };
305
+ LavaMaterial.prototype.getActiveTextures = function () {
306
+ var activeTextures = _super.prototype.getActiveTextures.call(this);
307
+ if (this._diffuseTexture) {
308
+ activeTextures.push(this._diffuseTexture);
309
+ }
310
+ return activeTextures;
311
+ };
312
+ LavaMaterial.prototype.hasTexture = function (texture) {
313
+ if (_super.prototype.hasTexture.call(this, texture)) {
314
+ return true;
315
+ }
316
+ if (this.diffuseTexture === texture) {
317
+ return true;
318
+ }
319
+ return false;
320
+ };
321
+ LavaMaterial.prototype.dispose = function (forceDisposeEffect) {
322
+ if (this.diffuseTexture) {
323
+ this.diffuseTexture.dispose();
324
+ }
325
+ if (this.noiseTexture) {
326
+ this.noiseTexture.dispose();
327
+ }
328
+ _super.prototype.dispose.call(this, forceDisposeEffect);
329
+ };
330
+ LavaMaterial.prototype.clone = function (name) {
331
+ var _this = this;
332
+ return SerializationHelper.Clone(function () { return new LavaMaterial(name, _this.getScene()); }, this);
333
+ };
334
+ LavaMaterial.prototype.serialize = function () {
335
+ var serializationObject = _super.prototype.serialize.call(this);
336
+ serializationObject.customType = "BABYLON.LavaMaterial";
337
+ return serializationObject;
338
+ };
339
+ LavaMaterial.prototype.getClassName = function () {
340
+ return "LavaMaterial";
341
+ };
342
+ // Statics
343
+ LavaMaterial.Parse = function (source, scene, rootUrl) {
344
+ return SerializationHelper.Parse(function () { return new LavaMaterial(source.name, scene); }, source, scene, rootUrl);
345
+ };
346
+ __decorate([
347
+ serializeAsTexture("diffuseTexture")
348
+ ], LavaMaterial.prototype, "_diffuseTexture", void 0);
349
+ __decorate([
350
+ expandToProperty("_markAllSubMeshesAsTexturesDirty")
351
+ ], LavaMaterial.prototype, "diffuseTexture", void 0);
352
+ __decorate([
353
+ serializeAsTexture()
354
+ ], LavaMaterial.prototype, "noiseTexture", void 0);
355
+ __decorate([
356
+ serializeAsColor3()
357
+ ], LavaMaterial.prototype, "fogColor", void 0);
358
+ __decorate([
359
+ serialize()
360
+ ], LavaMaterial.prototype, "speed", void 0);
361
+ __decorate([
362
+ serialize()
363
+ ], LavaMaterial.prototype, "movingSpeed", void 0);
364
+ __decorate([
365
+ serialize()
366
+ ], LavaMaterial.prototype, "lowFrequencySpeed", void 0);
367
+ __decorate([
368
+ serialize()
369
+ ], LavaMaterial.prototype, "fogDensity", void 0);
370
+ __decorate([
371
+ serializeAsColor3()
372
+ ], LavaMaterial.prototype, "diffuseColor", void 0);
373
+ __decorate([
374
+ serialize("disableLighting")
375
+ ], LavaMaterial.prototype, "_disableLighting", void 0);
376
+ __decorate([
377
+ expandToProperty("_markAllSubMeshesAsLightsDirty")
378
+ ], LavaMaterial.prototype, "disableLighting", void 0);
379
+ __decorate([
380
+ serialize("unlit")
381
+ ], LavaMaterial.prototype, "_unlit", void 0);
382
+ __decorate([
383
+ expandToProperty("_markAllSubMeshesAsLightsDirty")
384
+ ], LavaMaterial.prototype, "unlit", void 0);
385
+ __decorate([
386
+ serialize("maxSimultaneousLights")
387
+ ], LavaMaterial.prototype, "_maxSimultaneousLights", void 0);
388
+ __decorate([
389
+ expandToProperty("_markAllSubMeshesAsLightsDirty")
390
+ ], LavaMaterial.prototype, "maxSimultaneousLights", void 0);
391
+ return LavaMaterial;
392
+ }(PushMaterial));
393
+ export { LavaMaterial };
394
+ RegisterClass("BABYLON.LavaMaterial", LavaMaterial);
395
395
  //# sourceMappingURL=lavaMaterial.js.map