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