@babylonjs/materials 5.0.0-beta.9 → 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,291 +1,305 @@
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 "./cell.fragment.js";
12
- import "./cell.vertex.js";
13
- import { EffectFallbacks } from '@babylonjs/core/Materials/effectFallbacks.js';
14
- var CellMaterialDefines = /** @class */ (function (_super) {
15
- __extends(CellMaterialDefines, _super);
16
- function CellMaterialDefines() {
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.POINTSIZE = false;
27
- _this.FOG = false;
28
- _this.NORMAL = false;
29
- _this.UV1 = false;
30
- _this.UV2 = false;
31
- _this.VERTEXCOLOR = false;
32
- _this.VERTEXALPHA = false;
33
- _this.NUM_BONE_INFLUENCERS = 0;
34
- _this.BonesPerMesh = 0;
35
- _this.INSTANCES = false;
36
- _this.INSTANCESCOLOR = false;
37
- _this.NDOTL = true;
38
- _this.CUSTOMUSERLIGHTING = true;
39
- _this.CELLBASIC = true;
40
- _this.DEPTHPREPASS = false;
41
- _this.IMAGEPROCESSINGPOSTPROCESS = false;
42
- _this.SKIPFINALCOLORCLAMP = false;
43
- _this.rebuild();
44
- return _this;
45
- }
46
- return CellMaterialDefines;
47
- }(MaterialDefines));
48
- var CellMaterial = /** @class */ (function (_super) {
49
- __extends(CellMaterial, _super);
50
- function CellMaterial(name, scene) {
51
- var _this = _super.call(this, name, scene) || this;
52
- _this.diffuseColor = new Color3(1, 1, 1);
53
- _this._computeHighLevel = false;
54
- _this._disableLighting = false;
55
- _this._maxSimultaneousLights = 4;
56
- return _this;
57
- }
58
- CellMaterial.prototype.needAlphaBlending = function () {
59
- return (this.alpha < 1.0);
60
- };
61
- CellMaterial.prototype.needAlphaTesting = function () {
62
- return false;
63
- };
64
- CellMaterial.prototype.getAlphaTestTexture = function () {
65
- return null;
66
- };
67
- // Methods
68
- CellMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
69
- if (this.isFrozen) {
70
- if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
71
- return true;
72
- }
73
- }
74
- if (!subMesh.materialDefines) {
75
- subMesh.materialDefines = new CellMaterialDefines();
76
- }
77
- var defines = subMesh.materialDefines;
78
- var scene = this.getScene();
79
- if (this._isReadyForSubMesh(subMesh)) {
80
- return true;
81
- }
82
- var engine = scene.getEngine();
83
- // Textures
84
- if (defines._areTexturesDirty) {
85
- defines._needUVs = false;
86
- if (scene.texturesEnabled) {
87
- if (this._diffuseTexture && MaterialFlags.DiffuseTextureEnabled) {
88
- if (!this._diffuseTexture.isReady()) {
89
- return false;
90
- }
91
- else {
92
- defines._needUVs = true;
93
- defines.DIFFUSE = true;
94
- }
95
- }
96
- }
97
- }
98
- // High level
99
- defines.CELLBASIC = !this.computeHighLevel;
100
- // Misc.
101
- MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
102
- // Lights
103
- defines._needNormals = MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
104
- // Values that need to be evaluated on every frame
105
- MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
106
- // Attribs
107
- MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true);
108
- // Get correct effect
109
- if (defines.isDirty) {
110
- defines.markAsProcessed();
111
- scene.resetCachedMaterial();
112
- // Fallbacks
113
- var fallbacks = new EffectFallbacks();
114
- if (defines.FOG) {
115
- fallbacks.addFallback(1, "FOG");
116
- }
117
- MaterialHelper.HandleFallbacksForShadows(defines, fallbacks, this.maxSimultaneousLights);
118
- if (defines.NUM_BONE_INFLUENCERS > 0) {
119
- fallbacks.addCPUSkinningFallback(0, mesh);
120
- }
121
- defines.IMAGEPROCESSINGPOSTPROCESS = scene.imageProcessingConfiguration.applyByPostProcess;
122
- //Attributes
123
- var attribs = [VertexBuffer.PositionKind];
124
- if (defines.NORMAL) {
125
- attribs.push(VertexBuffer.NormalKind);
126
- }
127
- if (defines.UV1) {
128
- attribs.push(VertexBuffer.UVKind);
129
- }
130
- if (defines.UV2) {
131
- attribs.push(VertexBuffer.UV2Kind);
132
- }
133
- if (defines.VERTEXCOLOR) {
134
- attribs.push(VertexBuffer.ColorKind);
135
- }
136
- MaterialHelper.PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
137
- MaterialHelper.PrepareAttributesForInstances(attribs, defines);
138
- var shaderName = "cell";
139
- var join = defines.toString();
140
- var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vDiffuseColor",
141
- "vFogInfos", "vFogColor", "pointSize",
142
- "vDiffuseInfos",
143
- "mBones",
144
- "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "diffuseMatrix"
145
- ];
146
- var samplers = ["diffuseSampler"];
147
- var uniformBuffers = new Array();
148
- MaterialHelper.PrepareUniformsAndSamplersList({
149
- uniformsNames: uniforms,
150
- uniformBuffersNames: uniformBuffers,
151
- samplers: samplers,
152
- defines: defines,
153
- maxSimultaneousLights: this.maxSimultaneousLights
154
- });
155
- subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
156
- attributes: attribs,
157
- uniformsNames: uniforms,
158
- uniformBuffersNames: uniformBuffers,
159
- samplers: samplers,
160
- defines: join,
161
- fallbacks: fallbacks,
162
- onCompiled: this.onCompiled,
163
- onError: this.onError,
164
- indexParameters: { maxSimultaneousLights: this.maxSimultaneousLights - 1 }
165
- }, engine), defines, this._materialContext);
166
- }
167
- if (!subMesh.effect || !subMesh.effect.isReady()) {
168
- return false;
169
- }
170
- defines._renderId = scene.getRenderId();
171
- subMesh.effect._wasPreviouslyReady = true;
172
- return true;
173
- };
174
- CellMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
175
- var scene = this.getScene();
176
- var defines = subMesh.materialDefines;
177
- if (!defines) {
178
- return;
179
- }
180
- var effect = subMesh.effect;
181
- if (!effect) {
182
- return;
183
- }
184
- this._activeEffect = effect;
185
- // Matrices
186
- this.bindOnlyWorldMatrix(world);
187
- this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
188
- // Bones
189
- MaterialHelper.BindBonesParameters(mesh, this._activeEffect);
190
- if (this._mustRebind(scene, effect)) {
191
- // Textures
192
- if (this._diffuseTexture && MaterialFlags.DiffuseTextureEnabled) {
193
- this._activeEffect.setTexture("diffuseSampler", this._diffuseTexture);
194
- this._activeEffect.setFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
195
- this._activeEffect.setMatrix("diffuseMatrix", this._diffuseTexture.getTextureMatrix());
196
- }
197
- // Clip plane
198
- MaterialHelper.BindClipPlane(this._activeEffect, scene);
199
- // Point size
200
- if (this.pointsCloud) {
201
- this._activeEffect.setFloat("pointSize", this.pointSize);
202
- }
203
- scene.bindEyePosition(effect);
204
- }
205
- this._activeEffect.setColor4("vDiffuseColor", this.diffuseColor, this.alpha * mesh.visibility);
206
- // Lights
207
- if (scene.lightsEnabled && !this.disableLighting) {
208
- MaterialHelper.BindLights(scene, mesh, this._activeEffect, defines, this._maxSimultaneousLights);
209
- }
210
- // View
211
- if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE) {
212
- this._activeEffect.setMatrix("view", scene.getViewMatrix());
213
- }
214
- // Fog
215
- MaterialHelper.BindFogParameters(scene, mesh, this._activeEffect);
216
- this._afterBind(mesh, this._activeEffect);
217
- };
218
- CellMaterial.prototype.getAnimatables = function () {
219
- var results = [];
220
- if (this._diffuseTexture && this._diffuseTexture.animations && this._diffuseTexture.animations.length > 0) {
221
- results.push(this._diffuseTexture);
222
- }
223
- return results;
224
- };
225
- CellMaterial.prototype.getActiveTextures = function () {
226
- var activeTextures = _super.prototype.getActiveTextures.call(this);
227
- if (this._diffuseTexture) {
228
- activeTextures.push(this._diffuseTexture);
229
- }
230
- return activeTextures;
231
- };
232
- CellMaterial.prototype.hasTexture = function (texture) {
233
- if (_super.prototype.hasTexture.call(this, texture)) {
234
- return true;
235
- }
236
- return this._diffuseTexture === texture;
237
- };
238
- CellMaterial.prototype.dispose = function (forceDisposeEffect) {
239
- if (this._diffuseTexture) {
240
- this._diffuseTexture.dispose();
241
- }
242
- _super.prototype.dispose.call(this, forceDisposeEffect);
243
- };
244
- CellMaterial.prototype.getClassName = function () {
245
- return "CellMaterial";
246
- };
247
- CellMaterial.prototype.clone = function (name) {
248
- var _this = this;
249
- return SerializationHelper.Clone(function () { return new CellMaterial(name, _this.getScene()); }, this);
250
- };
251
- CellMaterial.prototype.serialize = function () {
252
- var serializationObject = _super.prototype.serialize.call(this);
253
- serializationObject.customType = "BABYLON.CellMaterial";
254
- return serializationObject;
255
- };
256
- // Statics
257
- CellMaterial.Parse = function (source, scene, rootUrl) {
258
- return SerializationHelper.Parse(function () { return new CellMaterial(source.name, scene); }, source, scene, rootUrl);
259
- };
260
- __decorate([
261
- serializeAsTexture("diffuseTexture")
262
- ], CellMaterial.prototype, "_diffuseTexture", void 0);
263
- __decorate([
264
- expandToProperty("_markAllSubMeshesAsTexturesDirty")
265
- ], CellMaterial.prototype, "diffuseTexture", void 0);
266
- __decorate([
267
- serializeAsColor3("diffuse")
268
- ], CellMaterial.prototype, "diffuseColor", void 0);
269
- __decorate([
270
- serialize("computeHighLevel")
271
- ], CellMaterial.prototype, "_computeHighLevel", void 0);
272
- __decorate([
273
- expandToProperty("_markAllSubMeshesAsTexturesDirty")
274
- ], CellMaterial.prototype, "computeHighLevel", void 0);
275
- __decorate([
276
- serialize("disableLighting")
277
- ], CellMaterial.prototype, "_disableLighting", void 0);
278
- __decorate([
279
- expandToProperty("_markAllSubMeshesAsLightsDirty")
280
- ], CellMaterial.prototype, "disableLighting", void 0);
281
- __decorate([
282
- serialize("maxSimultaneousLights")
283
- ], CellMaterial.prototype, "_maxSimultaneousLights", void 0);
284
- __decorate([
285
- expandToProperty("_markAllSubMeshesAsLightsDirty")
286
- ], CellMaterial.prototype, "maxSimultaneousLights", void 0);
287
- return CellMaterial;
288
- }(PushMaterial));
289
- export { CellMaterial };
290
- RegisterClass("BABYLON.CellMaterial", CellMaterial);
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 "./cell.fragment";
12
+ import "./cell.vertex";
13
+ import { EffectFallbacks } from "@babylonjs/core/Materials/effectFallbacks.js";
14
+ var CellMaterialDefines = /** @class */ (function (_super) {
15
+ __extends(CellMaterialDefines, _super);
16
+ function CellMaterialDefines() {
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.POINTSIZE = false;
27
+ _this.FOG = false;
28
+ _this.NORMAL = false;
29
+ _this.UV1 = false;
30
+ _this.UV2 = false;
31
+ _this.VERTEXCOLOR = false;
32
+ _this.VERTEXALPHA = false;
33
+ _this.NUM_BONE_INFLUENCERS = 0;
34
+ _this.BonesPerMesh = 0;
35
+ _this.INSTANCES = false;
36
+ _this.INSTANCESCOLOR = false;
37
+ _this.NDOTL = true;
38
+ _this.CUSTOMUSERLIGHTING = true;
39
+ _this.CELLBASIC = true;
40
+ _this.DEPTHPREPASS = false;
41
+ _this.IMAGEPROCESSINGPOSTPROCESS = false;
42
+ _this.SKIPFINALCOLORCLAMP = false;
43
+ _this.rebuild();
44
+ return _this;
45
+ }
46
+ return CellMaterialDefines;
47
+ }(MaterialDefines));
48
+ var CellMaterial = /** @class */ (function (_super) {
49
+ __extends(CellMaterial, _super);
50
+ function CellMaterial(name, scene) {
51
+ var _this = _super.call(this, name, scene) || this;
52
+ _this.diffuseColor = new Color3(1, 1, 1);
53
+ _this._computeHighLevel = false;
54
+ _this._disableLighting = false;
55
+ _this._maxSimultaneousLights = 4;
56
+ return _this;
57
+ }
58
+ CellMaterial.prototype.needAlphaBlending = function () {
59
+ return this.alpha < 1.0;
60
+ };
61
+ CellMaterial.prototype.needAlphaTesting = function () {
62
+ return false;
63
+ };
64
+ CellMaterial.prototype.getAlphaTestTexture = function () {
65
+ return null;
66
+ };
67
+ // Methods
68
+ CellMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
69
+ if (this.isFrozen) {
70
+ if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
71
+ return true;
72
+ }
73
+ }
74
+ if (!subMesh.materialDefines) {
75
+ subMesh.materialDefines = new CellMaterialDefines();
76
+ }
77
+ var defines = subMesh.materialDefines;
78
+ var scene = this.getScene();
79
+ if (this._isReadyForSubMesh(subMesh)) {
80
+ return true;
81
+ }
82
+ var engine = scene.getEngine();
83
+ // Textures
84
+ if (defines._areTexturesDirty) {
85
+ defines._needUVs = false;
86
+ if (scene.texturesEnabled) {
87
+ if (this._diffuseTexture && MaterialFlags.DiffuseTextureEnabled) {
88
+ if (!this._diffuseTexture.isReady()) {
89
+ return false;
90
+ }
91
+ else {
92
+ defines._needUVs = true;
93
+ defines.DIFFUSE = true;
94
+ }
95
+ }
96
+ }
97
+ }
98
+ // High level
99
+ defines.CELLBASIC = !this.computeHighLevel;
100
+ // Misc.
101
+ MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
102
+ // Lights
103
+ defines._needNormals = MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
104
+ // Values that need to be evaluated on every frame
105
+ MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
106
+ // Attribs
107
+ MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true);
108
+ // Get correct effect
109
+ if (defines.isDirty) {
110
+ defines.markAsProcessed();
111
+ scene.resetCachedMaterial();
112
+ // Fallbacks
113
+ var fallbacks = new EffectFallbacks();
114
+ if (defines.FOG) {
115
+ fallbacks.addFallback(1, "FOG");
116
+ }
117
+ MaterialHelper.HandleFallbacksForShadows(defines, fallbacks, this.maxSimultaneousLights);
118
+ if (defines.NUM_BONE_INFLUENCERS > 0) {
119
+ fallbacks.addCPUSkinningFallback(0, mesh);
120
+ }
121
+ defines.IMAGEPROCESSINGPOSTPROCESS = scene.imageProcessingConfiguration.applyByPostProcess;
122
+ //Attributes
123
+ var attribs = [VertexBuffer.PositionKind];
124
+ if (defines.NORMAL) {
125
+ attribs.push(VertexBuffer.NormalKind);
126
+ }
127
+ if (defines.UV1) {
128
+ attribs.push(VertexBuffer.UVKind);
129
+ }
130
+ if (defines.UV2) {
131
+ attribs.push(VertexBuffer.UV2Kind);
132
+ }
133
+ if (defines.VERTEXCOLOR) {
134
+ attribs.push(VertexBuffer.ColorKind);
135
+ }
136
+ MaterialHelper.PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
137
+ MaterialHelper.PrepareAttributesForInstances(attribs, defines);
138
+ var shaderName = "cell";
139
+ var join = defines.toString();
140
+ var uniforms = [
141
+ "world",
142
+ "view",
143
+ "viewProjection",
144
+ "vEyePosition",
145
+ "vLightsType",
146
+ "vDiffuseColor",
147
+ "vFogInfos",
148
+ "vFogColor",
149
+ "pointSize",
150
+ "vDiffuseInfos",
151
+ "mBones",
152
+ "vClipPlane",
153
+ "vClipPlane2",
154
+ "vClipPlane3",
155
+ "vClipPlane4",
156
+ "vClipPlane5",
157
+ "vClipPlane6",
158
+ "diffuseMatrix",
159
+ ];
160
+ var samplers = ["diffuseSampler"];
161
+ var uniformBuffers = new Array();
162
+ MaterialHelper.PrepareUniformsAndSamplersList({
163
+ uniformsNames: uniforms,
164
+ uniformBuffersNames: uniformBuffers,
165
+ samplers: samplers,
166
+ defines: defines,
167
+ maxSimultaneousLights: this.maxSimultaneousLights,
168
+ });
169
+ subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
170
+ attributes: attribs,
171
+ uniformsNames: uniforms,
172
+ uniformBuffersNames: uniformBuffers,
173
+ samplers: samplers,
174
+ defines: join,
175
+ fallbacks: fallbacks,
176
+ onCompiled: this.onCompiled,
177
+ onError: this.onError,
178
+ indexParameters: { maxSimultaneousLights: this.maxSimultaneousLights - 1 },
179
+ }, engine), defines, this._materialContext);
180
+ }
181
+ if (!subMesh.effect || !subMesh.effect.isReady()) {
182
+ return false;
183
+ }
184
+ defines._renderId = scene.getRenderId();
185
+ subMesh.effect._wasPreviouslyReady = true;
186
+ return true;
187
+ };
188
+ CellMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
189
+ var scene = this.getScene();
190
+ var defines = subMesh.materialDefines;
191
+ if (!defines) {
192
+ return;
193
+ }
194
+ var effect = subMesh.effect;
195
+ if (!effect) {
196
+ return;
197
+ }
198
+ this._activeEffect = effect;
199
+ // Matrices
200
+ this.bindOnlyWorldMatrix(world);
201
+ this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
202
+ // Bones
203
+ MaterialHelper.BindBonesParameters(mesh, this._activeEffect);
204
+ if (this._mustRebind(scene, effect)) {
205
+ // Textures
206
+ if (this._diffuseTexture && MaterialFlags.DiffuseTextureEnabled) {
207
+ this._activeEffect.setTexture("diffuseSampler", this._diffuseTexture);
208
+ this._activeEffect.setFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
209
+ this._activeEffect.setMatrix("diffuseMatrix", this._diffuseTexture.getTextureMatrix());
210
+ }
211
+ // Clip plane
212
+ MaterialHelper.BindClipPlane(this._activeEffect, scene);
213
+ // Point size
214
+ if (this.pointsCloud) {
215
+ this._activeEffect.setFloat("pointSize", this.pointSize);
216
+ }
217
+ scene.bindEyePosition(effect);
218
+ }
219
+ this._activeEffect.setColor4("vDiffuseColor", this.diffuseColor, this.alpha * mesh.visibility);
220
+ // Lights
221
+ if (scene.lightsEnabled && !this.disableLighting) {
222
+ MaterialHelper.BindLights(scene, mesh, this._activeEffect, defines, this._maxSimultaneousLights);
223
+ }
224
+ // View
225
+ if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE) {
226
+ this._activeEffect.setMatrix("view", scene.getViewMatrix());
227
+ }
228
+ // Fog
229
+ MaterialHelper.BindFogParameters(scene, mesh, this._activeEffect);
230
+ this._afterBind(mesh, this._activeEffect);
231
+ };
232
+ CellMaterial.prototype.getAnimatables = function () {
233
+ var results = [];
234
+ if (this._diffuseTexture && this._diffuseTexture.animations && this._diffuseTexture.animations.length > 0) {
235
+ results.push(this._diffuseTexture);
236
+ }
237
+ return results;
238
+ };
239
+ CellMaterial.prototype.getActiveTextures = function () {
240
+ var activeTextures = _super.prototype.getActiveTextures.call(this);
241
+ if (this._diffuseTexture) {
242
+ activeTextures.push(this._diffuseTexture);
243
+ }
244
+ return activeTextures;
245
+ };
246
+ CellMaterial.prototype.hasTexture = function (texture) {
247
+ if (_super.prototype.hasTexture.call(this, texture)) {
248
+ return true;
249
+ }
250
+ return this._diffuseTexture === texture;
251
+ };
252
+ CellMaterial.prototype.dispose = function (forceDisposeEffect) {
253
+ if (this._diffuseTexture) {
254
+ this._diffuseTexture.dispose();
255
+ }
256
+ _super.prototype.dispose.call(this, forceDisposeEffect);
257
+ };
258
+ CellMaterial.prototype.getClassName = function () {
259
+ return "CellMaterial";
260
+ };
261
+ CellMaterial.prototype.clone = function (name) {
262
+ var _this = this;
263
+ return SerializationHelper.Clone(function () { return new CellMaterial(name, _this.getScene()); }, this);
264
+ };
265
+ CellMaterial.prototype.serialize = function () {
266
+ var serializationObject = _super.prototype.serialize.call(this);
267
+ serializationObject.customType = "BABYLON.CellMaterial";
268
+ return serializationObject;
269
+ };
270
+ // Statics
271
+ CellMaterial.Parse = function (source, scene, rootUrl) {
272
+ return SerializationHelper.Parse(function () { return new CellMaterial(source.name, scene); }, source, scene, rootUrl);
273
+ };
274
+ __decorate([
275
+ serializeAsTexture("diffuseTexture")
276
+ ], CellMaterial.prototype, "_diffuseTexture", void 0);
277
+ __decorate([
278
+ expandToProperty("_markAllSubMeshesAsTexturesDirty")
279
+ ], CellMaterial.prototype, "diffuseTexture", void 0);
280
+ __decorate([
281
+ serializeAsColor3("diffuse")
282
+ ], CellMaterial.prototype, "diffuseColor", void 0);
283
+ __decorate([
284
+ serialize("computeHighLevel")
285
+ ], CellMaterial.prototype, "_computeHighLevel", void 0);
286
+ __decorate([
287
+ expandToProperty("_markAllSubMeshesAsTexturesDirty")
288
+ ], CellMaterial.prototype, "computeHighLevel", void 0);
289
+ __decorate([
290
+ serialize("disableLighting")
291
+ ], CellMaterial.prototype, "_disableLighting", void 0);
292
+ __decorate([
293
+ expandToProperty("_markAllSubMeshesAsLightsDirty")
294
+ ], CellMaterial.prototype, "disableLighting", void 0);
295
+ __decorate([
296
+ serialize("maxSimultaneousLights")
297
+ ], CellMaterial.prototype, "_maxSimultaneousLights", void 0);
298
+ __decorate([
299
+ expandToProperty("_markAllSubMeshesAsLightsDirty")
300
+ ], CellMaterial.prototype, "maxSimultaneousLights", void 0);
301
+ return CellMaterial;
302
+ }(PushMaterial));
303
+ export { CellMaterial };
304
+ RegisterClass("BABYLON.CellMaterial", CellMaterial);
291
305
  //# sourceMappingURL=cellMaterial.js.map