@babylonjs/materials 5.0.0-rc.1 → 5.0.0-rc.10

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