@babylonjs/materials 5.0.0-rc.0 → 5.0.0-rc.11

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,484 +1,511 @@
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 "./mix.fragment.js";
12
- import "./mix.vertex.js";
13
- import { EffectFallbacks } from '@babylonjs/core/Materials/effectFallbacks.js';
14
- var MixMaterialDefines = /** @class */ (function (_super) {
15
- __extends(MixMaterialDefines, _super);
16
- function MixMaterialDefines() {
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.SPECULARTERM = false;
30
- _this.NORMAL = false;
31
- _this.UV1 = false;
32
- _this.UV2 = false;
33
- _this.VERTEXCOLOR = false;
34
- _this.VERTEXALPHA = false;
35
- _this.NUM_BONE_INFLUENCERS = 0;
36
- _this.BonesPerMesh = 0;
37
- _this.INSTANCES = false;
38
- _this.INSTANCESCOLOR = false;
39
- _this.MIXMAP2 = false;
40
- _this.IMAGEPROCESSINGPOSTPROCESS = false;
41
- _this.SKIPFINALCOLORCLAMP = false;
42
- _this.rebuild();
43
- return _this;
44
- }
45
- return MixMaterialDefines;
46
- }(MaterialDefines));
47
- var MixMaterial = /** @class */ (function (_super) {
48
- __extends(MixMaterial, _super);
49
- function MixMaterial(name, scene) {
50
- var _this = _super.call(this, name, scene) || this;
51
- /**
52
- * Uniforms
53
- */
54
- _this.diffuseColor = new Color3(1, 1, 1);
55
- _this.specularColor = new Color3(0, 0, 0);
56
- _this.specularPower = 64;
57
- _this._disableLighting = false;
58
- _this._maxSimultaneousLights = 4;
59
- return _this;
60
- }
61
- MixMaterial.prototype.needAlphaBlending = function () {
62
- return (this.alpha < 1.0);
63
- };
64
- MixMaterial.prototype.needAlphaTesting = function () {
65
- return false;
66
- };
67
- MixMaterial.prototype.getAlphaTestTexture = function () {
68
- return null;
69
- };
70
- // Methods
71
- MixMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
72
- if (this.isFrozen) {
73
- if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
74
- return true;
75
- }
76
- }
77
- if (!subMesh.materialDefines) {
78
- subMesh.materialDefines = new MixMaterialDefines();
79
- }
80
- var defines = subMesh.materialDefines;
81
- var scene = this.getScene();
82
- if (this._isReadyForSubMesh(subMesh)) {
83
- return true;
84
- }
85
- var engine = scene.getEngine();
86
- // Textures
87
- if (scene.texturesEnabled) {
88
- if (!this._mixTexture1 || !this._mixTexture1.isReady()) {
89
- return false;
90
- }
91
- defines._needUVs = true;
92
- if (MaterialFlags.DiffuseTextureEnabled) {
93
- if (!this._diffuseTexture1 || !this._diffuseTexture1.isReady()) {
94
- return false;
95
- }
96
- defines.DIFFUSE = true;
97
- if (!this._diffuseTexture2 || !this._diffuseTexture2.isReady()) {
98
- return false;
99
- }
100
- if (!this._diffuseTexture3 || !this._diffuseTexture3.isReady()) {
101
- return false;
102
- }
103
- if (!this._diffuseTexture4 || !this._diffuseTexture4.isReady()) {
104
- return false;
105
- }
106
- if (this._mixTexture2) {
107
- if (!this._mixTexture2.isReady()) {
108
- return false;
109
- }
110
- defines.MIXMAP2 = true;
111
- if (!this._diffuseTexture5 || !this._diffuseTexture5.isReady()) {
112
- return false;
113
- }
114
- if (!this._diffuseTexture6 || !this._diffuseTexture6.isReady()) {
115
- return false;
116
- }
117
- if (!this._diffuseTexture7 || !this._diffuseTexture7.isReady()) {
118
- return false;
119
- }
120
- if (!this._diffuseTexture8 || !this._diffuseTexture8.isReady()) {
121
- return false;
122
- }
123
- }
124
- }
125
- }
126
- // Misc.
127
- MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
128
- // Lights
129
- defines._needNormals = MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
130
- // Values that need to be evaluated on every frame
131
- MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
132
- // Attribs
133
- MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true);
134
- // Get correct effect
135
- if (defines.isDirty) {
136
- defines.markAsProcessed();
137
- scene.resetCachedMaterial();
138
- // Fallbacks
139
- var fallbacks = new EffectFallbacks();
140
- if (defines.FOG) {
141
- fallbacks.addFallback(1, "FOG");
142
- }
143
- MaterialHelper.HandleFallbacksForShadows(defines, fallbacks, this.maxSimultaneousLights);
144
- if (defines.NUM_BONE_INFLUENCERS > 0) {
145
- fallbacks.addCPUSkinningFallback(0, mesh);
146
- }
147
- defines.IMAGEPROCESSINGPOSTPROCESS = scene.imageProcessingConfiguration.applyByPostProcess;
148
- //Attributes
149
- var attribs = [VertexBuffer.PositionKind];
150
- if (defines.NORMAL) {
151
- attribs.push(VertexBuffer.NormalKind);
152
- }
153
- if (defines.UV1) {
154
- attribs.push(VertexBuffer.UVKind);
155
- }
156
- if (defines.UV2) {
157
- attribs.push(VertexBuffer.UV2Kind);
158
- }
159
- if (defines.VERTEXCOLOR) {
160
- attribs.push(VertexBuffer.ColorKind);
161
- }
162
- MaterialHelper.PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
163
- MaterialHelper.PrepareAttributesForInstances(attribs, defines);
164
- // Legacy browser patch
165
- var shaderName = "mix";
166
- var join = defines.toString();
167
- var uniforms = [
168
- "world", "view", "viewProjection", "vEyePosition", "vLightsType", "vDiffuseColor", "vSpecularColor",
169
- "vFogInfos", "vFogColor", "pointSize",
170
- "vTextureInfos",
171
- "mBones",
172
- "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "textureMatrix",
173
- "diffuse1Infos", "diffuse2Infos", "diffuse3Infos", "diffuse4Infos",
174
- "diffuse5Infos", "diffuse6Infos", "diffuse7Infos", "diffuse8Infos"
175
- ];
176
- var samplers = [
177
- "mixMap1Sampler", "mixMap2Sampler",
178
- "diffuse1Sampler", "diffuse2Sampler", "diffuse3Sampler", "diffuse4Sampler",
179
- "diffuse5Sampler", "diffuse6Sampler", "diffuse7Sampler", "diffuse8Sampler"
180
- ];
181
- var uniformBuffers = new Array();
182
- MaterialHelper.PrepareUniformsAndSamplersList({
183
- uniformsNames: uniforms,
184
- uniformBuffersNames: uniformBuffers,
185
- samplers: samplers,
186
- defines: defines,
187
- maxSimultaneousLights: this.maxSimultaneousLights
188
- });
189
- subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
190
- attributes: attribs,
191
- uniformsNames: uniforms,
192
- uniformBuffersNames: uniformBuffers,
193
- samplers: samplers,
194
- defines: join,
195
- fallbacks: fallbacks,
196
- onCompiled: this.onCompiled,
197
- onError: this.onError,
198
- indexParameters: { maxSimultaneousLights: this.maxSimultaneousLights }
199
- }, engine), defines, this._materialContext);
200
- }
201
- if (!subMesh.effect || !subMesh.effect.isReady()) {
202
- return false;
203
- }
204
- defines._renderId = scene.getRenderId();
205
- subMesh.effect._wasPreviouslyReady = true;
206
- return true;
207
- };
208
- MixMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
209
- var scene = this.getScene();
210
- var defines = subMesh.materialDefines;
211
- if (!defines) {
212
- return;
213
- }
214
- var effect = subMesh.effect;
215
- if (!effect) {
216
- return;
217
- }
218
- this._activeEffect = effect;
219
- // Matrices
220
- this.bindOnlyWorldMatrix(world);
221
- this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
222
- // Bones
223
- MaterialHelper.BindBonesParameters(mesh, this._activeEffect);
224
- if (this._mustRebind(scene, effect)) {
225
- // Textures
226
- if (this._mixTexture1) {
227
- this._activeEffect.setTexture("mixMap1Sampler", this._mixTexture1);
228
- this._activeEffect.setFloat2("vTextureInfos", this._mixTexture1.coordinatesIndex, this._mixTexture1.level);
229
- this._activeEffect.setMatrix("textureMatrix", this._mixTexture1.getTextureMatrix());
230
- if (MaterialFlags.DiffuseTextureEnabled) {
231
- if (this._diffuseTexture1) {
232
- this._activeEffect.setTexture("diffuse1Sampler", this._diffuseTexture1);
233
- this._activeEffect.setFloat2("diffuse1Infos", this._diffuseTexture1.uScale, this._diffuseTexture1.vScale);
234
- }
235
- if (this._diffuseTexture2) {
236
- this._activeEffect.setTexture("diffuse2Sampler", this._diffuseTexture2);
237
- this._activeEffect.setFloat2("diffuse2Infos", this._diffuseTexture2.uScale, this._diffuseTexture2.vScale);
238
- }
239
- if (this._diffuseTexture3) {
240
- this._activeEffect.setTexture("diffuse3Sampler", this._diffuseTexture3);
241
- this._activeEffect.setFloat2("diffuse3Infos", this._diffuseTexture3.uScale, this._diffuseTexture3.vScale);
242
- }
243
- if (this._diffuseTexture4) {
244
- this._activeEffect.setTexture("diffuse4Sampler", this._diffuseTexture4);
245
- this._activeEffect.setFloat2("diffuse4Infos", this._diffuseTexture4.uScale, this._diffuseTexture4.vScale);
246
- }
247
- }
248
- }
249
- if (this._mixTexture2) {
250
- this._activeEffect.setTexture("mixMap2Sampler", this._mixTexture2);
251
- if (MaterialFlags.DiffuseTextureEnabled) {
252
- if (this._diffuseTexture5) {
253
- this._activeEffect.setTexture("diffuse5Sampler", this._diffuseTexture5);
254
- this._activeEffect.setFloat2("diffuse5Infos", this._diffuseTexture5.uScale, this._diffuseTexture5.vScale);
255
- }
256
- if (this._diffuseTexture6) {
257
- this._activeEffect.setTexture("diffuse6Sampler", this._diffuseTexture6);
258
- this._activeEffect.setFloat2("diffuse6Infos", this._diffuseTexture6.uScale, this._diffuseTexture6.vScale);
259
- }
260
- if (this._diffuseTexture7) {
261
- this._activeEffect.setTexture("diffuse7Sampler", this._diffuseTexture7);
262
- this._activeEffect.setFloat2("diffuse7Infos", this._diffuseTexture7.uScale, this._diffuseTexture7.vScale);
263
- }
264
- if (this._diffuseTexture8) {
265
- this._activeEffect.setTexture("diffuse8Sampler", this._diffuseTexture8);
266
- this._activeEffect.setFloat2("diffuse8Infos", this._diffuseTexture8.uScale, this._diffuseTexture8.vScale);
267
- }
268
- }
269
- }
270
- // Clip plane
271
- MaterialHelper.BindClipPlane(this._activeEffect, scene);
272
- // Point size
273
- if (this.pointsCloud) {
274
- this._activeEffect.setFloat("pointSize", this.pointSize);
275
- }
276
- scene.bindEyePosition(effect);
277
- }
278
- this._activeEffect.setColor4("vDiffuseColor", this.diffuseColor, this.alpha * mesh.visibility);
279
- if (defines.SPECULARTERM) {
280
- this._activeEffect.setColor4("vSpecularColor", this.specularColor, this.specularPower);
281
- }
282
- if (scene.lightsEnabled && !this.disableLighting) {
283
- MaterialHelper.BindLights(scene, mesh, this._activeEffect, defines, this.maxSimultaneousLights);
284
- }
285
- // View
286
- if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE) {
287
- this._activeEffect.setMatrix("view", scene.getViewMatrix());
288
- }
289
- // Fog
290
- MaterialHelper.BindFogParameters(scene, mesh, this._activeEffect);
291
- this._afterBind(mesh, this._activeEffect);
292
- };
293
- MixMaterial.prototype.getAnimatables = function () {
294
- var results = [];
295
- if (this._mixTexture1 && this._mixTexture1.animations && this._mixTexture1.animations.length > 0) {
296
- results.push(this._mixTexture1);
297
- }
298
- if (this._mixTexture2 && this._mixTexture2.animations && this._mixTexture2.animations.length > 0) {
299
- results.push(this._mixTexture2);
300
- }
301
- return results;
302
- };
303
- MixMaterial.prototype.getActiveTextures = function () {
304
- var activeTextures = _super.prototype.getActiveTextures.call(this);
305
- // Mix map 1
306
- if (this._mixTexture1) {
307
- activeTextures.push(this._mixTexture1);
308
- }
309
- if (this._diffuseTexture1) {
310
- activeTextures.push(this._diffuseTexture1);
311
- }
312
- if (this._diffuseTexture2) {
313
- activeTextures.push(this._diffuseTexture2);
314
- }
315
- if (this._diffuseTexture3) {
316
- activeTextures.push(this._diffuseTexture3);
317
- }
318
- if (this._diffuseTexture4) {
319
- activeTextures.push(this._diffuseTexture4);
320
- }
321
- // Mix map 2
322
- if (this._mixTexture2) {
323
- activeTextures.push(this._mixTexture2);
324
- }
325
- if (this._diffuseTexture5) {
326
- activeTextures.push(this._diffuseTexture5);
327
- }
328
- if (this._diffuseTexture6) {
329
- activeTextures.push(this._diffuseTexture6);
330
- }
331
- if (this._diffuseTexture7) {
332
- activeTextures.push(this._diffuseTexture7);
333
- }
334
- if (this._diffuseTexture8) {
335
- activeTextures.push(this._diffuseTexture8);
336
- }
337
- return activeTextures;
338
- };
339
- MixMaterial.prototype.hasTexture = function (texture) {
340
- if (_super.prototype.hasTexture.call(this, texture)) {
341
- return true;
342
- }
343
- // Mix map 1
344
- if (this._mixTexture1 === texture) {
345
- return true;
346
- }
347
- if (this._diffuseTexture1 === texture) {
348
- return true;
349
- }
350
- if (this._diffuseTexture2 === texture) {
351
- return true;
352
- }
353
- if (this._diffuseTexture3 === texture) {
354
- return true;
355
- }
356
- if (this._diffuseTexture4 === texture) {
357
- return true;
358
- }
359
- // Mix map 2
360
- if (this._mixTexture2 === texture) {
361
- return true;
362
- }
363
- if (this._diffuseTexture5 === texture) {
364
- return true;
365
- }
366
- if (this._diffuseTexture6 === texture) {
367
- return true;
368
- }
369
- if (this._diffuseTexture7 === texture) {
370
- return true;
371
- }
372
- if (this._diffuseTexture8 === texture) {
373
- return true;
374
- }
375
- return false;
376
- };
377
- MixMaterial.prototype.dispose = function (forceDisposeEffect) {
378
- if (this._mixTexture1) {
379
- this._mixTexture1.dispose();
380
- }
381
- _super.prototype.dispose.call(this, forceDisposeEffect);
382
- };
383
- MixMaterial.prototype.clone = function (name) {
384
- var _this = this;
385
- return SerializationHelper.Clone(function () { return new MixMaterial(name, _this.getScene()); }, this);
386
- };
387
- MixMaterial.prototype.serialize = function () {
388
- var serializationObject = _super.prototype.serialize.call(this);
389
- serializationObject.customType = "BABYLON.MixMaterial";
390
- return serializationObject;
391
- };
392
- MixMaterial.prototype.getClassName = function () {
393
- return "MixMaterial";
394
- };
395
- // Statics
396
- MixMaterial.Parse = function (source, scene, rootUrl) {
397
- return SerializationHelper.Parse(function () { return new MixMaterial(source.name, scene); }, source, scene, rootUrl);
398
- };
399
- __decorate([
400
- serializeAsTexture("mixTexture1")
401
- ], MixMaterial.prototype, "_mixTexture1", void 0);
402
- __decorate([
403
- expandToProperty("_markAllSubMeshesAsTexturesDirty")
404
- ], MixMaterial.prototype, "mixTexture1", void 0);
405
- __decorate([
406
- serializeAsTexture("mixTexture2")
407
- ], MixMaterial.prototype, "_mixTexture2", void 0);
408
- __decorate([
409
- expandToProperty("_markAllSubMeshesAsTexturesDirty")
410
- ], MixMaterial.prototype, "mixTexture2", void 0);
411
- __decorate([
412
- serializeAsTexture("diffuseTexture1")
413
- ], MixMaterial.prototype, "_diffuseTexture1", void 0);
414
- __decorate([
415
- expandToProperty("_markAllSubMeshesAsTexturesDirty")
416
- ], MixMaterial.prototype, "diffuseTexture1", void 0);
417
- __decorate([
418
- serializeAsTexture("diffuseTexture2")
419
- ], MixMaterial.prototype, "_diffuseTexture2", void 0);
420
- __decorate([
421
- expandToProperty("_markAllSubMeshesAsTexturesDirty")
422
- ], MixMaterial.prototype, "diffuseTexture2", void 0);
423
- __decorate([
424
- serializeAsTexture("diffuseTexture3")
425
- ], MixMaterial.prototype, "_diffuseTexture3", void 0);
426
- __decorate([
427
- expandToProperty("_markAllSubMeshesAsTexturesDirty")
428
- ], MixMaterial.prototype, "diffuseTexture3", void 0);
429
- __decorate([
430
- serializeAsTexture("diffuseTexture4")
431
- ], MixMaterial.prototype, "_diffuseTexture4", void 0);
432
- __decorate([
433
- expandToProperty("_markAllSubMeshesAsTexturesDirty")
434
- ], MixMaterial.prototype, "diffuseTexture4", void 0);
435
- __decorate([
436
- serializeAsTexture("diffuseTexture1")
437
- ], MixMaterial.prototype, "_diffuseTexture5", void 0);
438
- __decorate([
439
- expandToProperty("_markAllSubMeshesAsTexturesDirty")
440
- ], MixMaterial.prototype, "diffuseTexture5", void 0);
441
- __decorate([
442
- serializeAsTexture("diffuseTexture2")
443
- ], MixMaterial.prototype, "_diffuseTexture6", void 0);
444
- __decorate([
445
- expandToProperty("_markAllSubMeshesAsTexturesDirty")
446
- ], MixMaterial.prototype, "diffuseTexture6", void 0);
447
- __decorate([
448
- serializeAsTexture("diffuseTexture3")
449
- ], MixMaterial.prototype, "_diffuseTexture7", void 0);
450
- __decorate([
451
- expandToProperty("_markAllSubMeshesAsTexturesDirty")
452
- ], MixMaterial.prototype, "diffuseTexture7", void 0);
453
- __decorate([
454
- serializeAsTexture("diffuseTexture4")
455
- ], MixMaterial.prototype, "_diffuseTexture8", void 0);
456
- __decorate([
457
- expandToProperty("_markAllSubMeshesAsTexturesDirty")
458
- ], MixMaterial.prototype, "diffuseTexture8", void 0);
459
- __decorate([
460
- serializeAsColor3()
461
- ], MixMaterial.prototype, "diffuseColor", void 0);
462
- __decorate([
463
- serializeAsColor3()
464
- ], MixMaterial.prototype, "specularColor", void 0);
465
- __decorate([
466
- serialize()
467
- ], MixMaterial.prototype, "specularPower", void 0);
468
- __decorate([
469
- serialize("disableLighting")
470
- ], MixMaterial.prototype, "_disableLighting", void 0);
471
- __decorate([
472
- expandToProperty("_markAllSubMeshesAsLightsDirty")
473
- ], MixMaterial.prototype, "disableLighting", void 0);
474
- __decorate([
475
- serialize("maxSimultaneousLights")
476
- ], MixMaterial.prototype, "_maxSimultaneousLights", void 0);
477
- __decorate([
478
- expandToProperty("_markAllSubMeshesAsLightsDirty")
479
- ], MixMaterial.prototype, "maxSimultaneousLights", void 0);
480
- return MixMaterial;
481
- }(PushMaterial));
482
- export { MixMaterial };
483
- RegisterClass("BABYLON.MixMaterial", MixMaterial);
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 "./mix.fragment";
12
+ import "./mix.vertex";
13
+ import { EffectFallbacks } from "@babylonjs/core/Materials/effectFallbacks.js";
14
+ var MixMaterialDefines = /** @class */ (function (_super) {
15
+ __extends(MixMaterialDefines, _super);
16
+ function MixMaterialDefines() {
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.SPECULARTERM = false;
30
+ _this.NORMAL = false;
31
+ _this.UV1 = false;
32
+ _this.UV2 = false;
33
+ _this.VERTEXCOLOR = false;
34
+ _this.VERTEXALPHA = false;
35
+ _this.NUM_BONE_INFLUENCERS = 0;
36
+ _this.BonesPerMesh = 0;
37
+ _this.INSTANCES = false;
38
+ _this.INSTANCESCOLOR = false;
39
+ _this.MIXMAP2 = false;
40
+ _this.IMAGEPROCESSINGPOSTPROCESS = false;
41
+ _this.SKIPFINALCOLORCLAMP = false;
42
+ _this.rebuild();
43
+ return _this;
44
+ }
45
+ return MixMaterialDefines;
46
+ }(MaterialDefines));
47
+ var MixMaterial = /** @class */ (function (_super) {
48
+ __extends(MixMaterial, _super);
49
+ function MixMaterial(name, scene) {
50
+ var _this = _super.call(this, name, scene) || this;
51
+ /**
52
+ * Uniforms
53
+ */
54
+ _this.diffuseColor = new Color3(1, 1, 1);
55
+ _this.specularColor = new Color3(0, 0, 0);
56
+ _this.specularPower = 64;
57
+ _this._disableLighting = false;
58
+ _this._maxSimultaneousLights = 4;
59
+ return _this;
60
+ }
61
+ MixMaterial.prototype.needAlphaBlending = function () {
62
+ return this.alpha < 1.0;
63
+ };
64
+ MixMaterial.prototype.needAlphaTesting = function () {
65
+ return false;
66
+ };
67
+ MixMaterial.prototype.getAlphaTestTexture = function () {
68
+ return null;
69
+ };
70
+ // Methods
71
+ MixMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
72
+ if (this.isFrozen) {
73
+ if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
74
+ return true;
75
+ }
76
+ }
77
+ if (!subMesh.materialDefines) {
78
+ subMesh.materialDefines = new MixMaterialDefines();
79
+ }
80
+ var defines = subMesh.materialDefines;
81
+ var scene = this.getScene();
82
+ if (this._isReadyForSubMesh(subMesh)) {
83
+ return true;
84
+ }
85
+ var engine = scene.getEngine();
86
+ // Textures
87
+ if (scene.texturesEnabled) {
88
+ if (!this._mixTexture1 || !this._mixTexture1.isReady()) {
89
+ return false;
90
+ }
91
+ defines._needUVs = true;
92
+ if (MaterialFlags.DiffuseTextureEnabled) {
93
+ if (!this._diffuseTexture1 || !this._diffuseTexture1.isReady()) {
94
+ return false;
95
+ }
96
+ defines.DIFFUSE = true;
97
+ if (!this._diffuseTexture2 || !this._diffuseTexture2.isReady()) {
98
+ return false;
99
+ }
100
+ if (!this._diffuseTexture3 || !this._diffuseTexture3.isReady()) {
101
+ return false;
102
+ }
103
+ if (!this._diffuseTexture4 || !this._diffuseTexture4.isReady()) {
104
+ return false;
105
+ }
106
+ if (this._mixTexture2) {
107
+ if (!this._mixTexture2.isReady()) {
108
+ return false;
109
+ }
110
+ defines.MIXMAP2 = true;
111
+ if (!this._diffuseTexture5 || !this._diffuseTexture5.isReady()) {
112
+ return false;
113
+ }
114
+ if (!this._diffuseTexture6 || !this._diffuseTexture6.isReady()) {
115
+ return false;
116
+ }
117
+ if (!this._diffuseTexture7 || !this._diffuseTexture7.isReady()) {
118
+ return false;
119
+ }
120
+ if (!this._diffuseTexture8 || !this._diffuseTexture8.isReady()) {
121
+ return false;
122
+ }
123
+ }
124
+ }
125
+ }
126
+ // Misc.
127
+ MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
128
+ // Lights
129
+ defines._needNormals = MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
130
+ // Values that need to be evaluated on every frame
131
+ MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
132
+ // Attribs
133
+ MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true);
134
+ // Get correct effect
135
+ if (defines.isDirty) {
136
+ defines.markAsProcessed();
137
+ scene.resetCachedMaterial();
138
+ // Fallbacks
139
+ var fallbacks = new EffectFallbacks();
140
+ if (defines.FOG) {
141
+ fallbacks.addFallback(1, "FOG");
142
+ }
143
+ MaterialHelper.HandleFallbacksForShadows(defines, fallbacks, this.maxSimultaneousLights);
144
+ if (defines.NUM_BONE_INFLUENCERS > 0) {
145
+ fallbacks.addCPUSkinningFallback(0, mesh);
146
+ }
147
+ defines.IMAGEPROCESSINGPOSTPROCESS = scene.imageProcessingConfiguration.applyByPostProcess;
148
+ //Attributes
149
+ var attribs = [VertexBuffer.PositionKind];
150
+ if (defines.NORMAL) {
151
+ attribs.push(VertexBuffer.NormalKind);
152
+ }
153
+ if (defines.UV1) {
154
+ attribs.push(VertexBuffer.UVKind);
155
+ }
156
+ if (defines.UV2) {
157
+ attribs.push(VertexBuffer.UV2Kind);
158
+ }
159
+ if (defines.VERTEXCOLOR) {
160
+ attribs.push(VertexBuffer.ColorKind);
161
+ }
162
+ MaterialHelper.PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
163
+ MaterialHelper.PrepareAttributesForInstances(attribs, defines);
164
+ // Legacy browser patch
165
+ var shaderName = "mix";
166
+ var join = defines.toString();
167
+ var uniforms = [
168
+ "world",
169
+ "view",
170
+ "viewProjection",
171
+ "vEyePosition",
172
+ "vLightsType",
173
+ "vDiffuseColor",
174
+ "vSpecularColor",
175
+ "vFogInfos",
176
+ "vFogColor",
177
+ "pointSize",
178
+ "vTextureInfos",
179
+ "mBones",
180
+ "vClipPlane",
181
+ "vClipPlane2",
182
+ "vClipPlane3",
183
+ "vClipPlane4",
184
+ "vClipPlane5",
185
+ "vClipPlane6",
186
+ "textureMatrix",
187
+ "diffuse1Infos",
188
+ "diffuse2Infos",
189
+ "diffuse3Infos",
190
+ "diffuse4Infos",
191
+ "diffuse5Infos",
192
+ "diffuse6Infos",
193
+ "diffuse7Infos",
194
+ "diffuse8Infos",
195
+ ];
196
+ var samplers = [
197
+ "mixMap1Sampler",
198
+ "mixMap2Sampler",
199
+ "diffuse1Sampler",
200
+ "diffuse2Sampler",
201
+ "diffuse3Sampler",
202
+ "diffuse4Sampler",
203
+ "diffuse5Sampler",
204
+ "diffuse6Sampler",
205
+ "diffuse7Sampler",
206
+ "diffuse8Sampler",
207
+ ];
208
+ var uniformBuffers = new Array();
209
+ MaterialHelper.PrepareUniformsAndSamplersList({
210
+ uniformsNames: uniforms,
211
+ uniformBuffersNames: uniformBuffers,
212
+ samplers: samplers,
213
+ defines: defines,
214
+ maxSimultaneousLights: this.maxSimultaneousLights,
215
+ });
216
+ subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
217
+ attributes: attribs,
218
+ uniformsNames: uniforms,
219
+ uniformBuffersNames: uniformBuffers,
220
+ samplers: samplers,
221
+ defines: join,
222
+ fallbacks: fallbacks,
223
+ onCompiled: this.onCompiled,
224
+ onError: this.onError,
225
+ indexParameters: { maxSimultaneousLights: this.maxSimultaneousLights },
226
+ }, engine), defines, this._materialContext);
227
+ }
228
+ if (!subMesh.effect || !subMesh.effect.isReady()) {
229
+ return false;
230
+ }
231
+ defines._renderId = scene.getRenderId();
232
+ subMesh.effect._wasPreviouslyReady = true;
233
+ return true;
234
+ };
235
+ MixMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
236
+ var scene = this.getScene();
237
+ var defines = subMesh.materialDefines;
238
+ if (!defines) {
239
+ return;
240
+ }
241
+ var effect = subMesh.effect;
242
+ if (!effect) {
243
+ return;
244
+ }
245
+ this._activeEffect = effect;
246
+ // Matrices
247
+ this.bindOnlyWorldMatrix(world);
248
+ this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
249
+ // Bones
250
+ MaterialHelper.BindBonesParameters(mesh, this._activeEffect);
251
+ if (this._mustRebind(scene, effect)) {
252
+ // Textures
253
+ if (this._mixTexture1) {
254
+ this._activeEffect.setTexture("mixMap1Sampler", this._mixTexture1);
255
+ this._activeEffect.setFloat2("vTextureInfos", this._mixTexture1.coordinatesIndex, this._mixTexture1.level);
256
+ this._activeEffect.setMatrix("textureMatrix", this._mixTexture1.getTextureMatrix());
257
+ if (MaterialFlags.DiffuseTextureEnabled) {
258
+ if (this._diffuseTexture1) {
259
+ this._activeEffect.setTexture("diffuse1Sampler", this._diffuseTexture1);
260
+ this._activeEffect.setFloat2("diffuse1Infos", this._diffuseTexture1.uScale, this._diffuseTexture1.vScale);
261
+ }
262
+ if (this._diffuseTexture2) {
263
+ this._activeEffect.setTexture("diffuse2Sampler", this._diffuseTexture2);
264
+ this._activeEffect.setFloat2("diffuse2Infos", this._diffuseTexture2.uScale, this._diffuseTexture2.vScale);
265
+ }
266
+ if (this._diffuseTexture3) {
267
+ this._activeEffect.setTexture("diffuse3Sampler", this._diffuseTexture3);
268
+ this._activeEffect.setFloat2("diffuse3Infos", this._diffuseTexture3.uScale, this._diffuseTexture3.vScale);
269
+ }
270
+ if (this._diffuseTexture4) {
271
+ this._activeEffect.setTexture("diffuse4Sampler", this._diffuseTexture4);
272
+ this._activeEffect.setFloat2("diffuse4Infos", this._diffuseTexture4.uScale, this._diffuseTexture4.vScale);
273
+ }
274
+ }
275
+ }
276
+ if (this._mixTexture2) {
277
+ this._activeEffect.setTexture("mixMap2Sampler", this._mixTexture2);
278
+ if (MaterialFlags.DiffuseTextureEnabled) {
279
+ if (this._diffuseTexture5) {
280
+ this._activeEffect.setTexture("diffuse5Sampler", this._diffuseTexture5);
281
+ this._activeEffect.setFloat2("diffuse5Infos", this._diffuseTexture5.uScale, this._diffuseTexture5.vScale);
282
+ }
283
+ if (this._diffuseTexture6) {
284
+ this._activeEffect.setTexture("diffuse6Sampler", this._diffuseTexture6);
285
+ this._activeEffect.setFloat2("diffuse6Infos", this._diffuseTexture6.uScale, this._diffuseTexture6.vScale);
286
+ }
287
+ if (this._diffuseTexture7) {
288
+ this._activeEffect.setTexture("diffuse7Sampler", this._diffuseTexture7);
289
+ this._activeEffect.setFloat2("diffuse7Infos", this._diffuseTexture7.uScale, this._diffuseTexture7.vScale);
290
+ }
291
+ if (this._diffuseTexture8) {
292
+ this._activeEffect.setTexture("diffuse8Sampler", this._diffuseTexture8);
293
+ this._activeEffect.setFloat2("diffuse8Infos", this._diffuseTexture8.uScale, this._diffuseTexture8.vScale);
294
+ }
295
+ }
296
+ }
297
+ // Clip plane
298
+ MaterialHelper.BindClipPlane(this._activeEffect, scene);
299
+ // Point size
300
+ if (this.pointsCloud) {
301
+ this._activeEffect.setFloat("pointSize", this.pointSize);
302
+ }
303
+ scene.bindEyePosition(effect);
304
+ }
305
+ this._activeEffect.setColor4("vDiffuseColor", this.diffuseColor, this.alpha * mesh.visibility);
306
+ if (defines.SPECULARTERM) {
307
+ this._activeEffect.setColor4("vSpecularColor", this.specularColor, this.specularPower);
308
+ }
309
+ if (scene.lightsEnabled && !this.disableLighting) {
310
+ MaterialHelper.BindLights(scene, mesh, this._activeEffect, defines, this.maxSimultaneousLights);
311
+ }
312
+ // View
313
+ if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE) {
314
+ this._activeEffect.setMatrix("view", scene.getViewMatrix());
315
+ }
316
+ // Fog
317
+ MaterialHelper.BindFogParameters(scene, mesh, this._activeEffect);
318
+ this._afterBind(mesh, this._activeEffect);
319
+ };
320
+ MixMaterial.prototype.getAnimatables = function () {
321
+ var results = [];
322
+ if (this._mixTexture1 && this._mixTexture1.animations && this._mixTexture1.animations.length > 0) {
323
+ results.push(this._mixTexture1);
324
+ }
325
+ if (this._mixTexture2 && this._mixTexture2.animations && this._mixTexture2.animations.length > 0) {
326
+ results.push(this._mixTexture2);
327
+ }
328
+ return results;
329
+ };
330
+ MixMaterial.prototype.getActiveTextures = function () {
331
+ var activeTextures = _super.prototype.getActiveTextures.call(this);
332
+ // Mix map 1
333
+ if (this._mixTexture1) {
334
+ activeTextures.push(this._mixTexture1);
335
+ }
336
+ if (this._diffuseTexture1) {
337
+ activeTextures.push(this._diffuseTexture1);
338
+ }
339
+ if (this._diffuseTexture2) {
340
+ activeTextures.push(this._diffuseTexture2);
341
+ }
342
+ if (this._diffuseTexture3) {
343
+ activeTextures.push(this._diffuseTexture3);
344
+ }
345
+ if (this._diffuseTexture4) {
346
+ activeTextures.push(this._diffuseTexture4);
347
+ }
348
+ // Mix map 2
349
+ if (this._mixTexture2) {
350
+ activeTextures.push(this._mixTexture2);
351
+ }
352
+ if (this._diffuseTexture5) {
353
+ activeTextures.push(this._diffuseTexture5);
354
+ }
355
+ if (this._diffuseTexture6) {
356
+ activeTextures.push(this._diffuseTexture6);
357
+ }
358
+ if (this._diffuseTexture7) {
359
+ activeTextures.push(this._diffuseTexture7);
360
+ }
361
+ if (this._diffuseTexture8) {
362
+ activeTextures.push(this._diffuseTexture8);
363
+ }
364
+ return activeTextures;
365
+ };
366
+ MixMaterial.prototype.hasTexture = function (texture) {
367
+ if (_super.prototype.hasTexture.call(this, texture)) {
368
+ return true;
369
+ }
370
+ // Mix map 1
371
+ if (this._mixTexture1 === texture) {
372
+ return true;
373
+ }
374
+ if (this._diffuseTexture1 === texture) {
375
+ return true;
376
+ }
377
+ if (this._diffuseTexture2 === texture) {
378
+ return true;
379
+ }
380
+ if (this._diffuseTexture3 === texture) {
381
+ return true;
382
+ }
383
+ if (this._diffuseTexture4 === texture) {
384
+ return true;
385
+ }
386
+ // Mix map 2
387
+ if (this._mixTexture2 === texture) {
388
+ return true;
389
+ }
390
+ if (this._diffuseTexture5 === texture) {
391
+ return true;
392
+ }
393
+ if (this._diffuseTexture6 === texture) {
394
+ return true;
395
+ }
396
+ if (this._diffuseTexture7 === texture) {
397
+ return true;
398
+ }
399
+ if (this._diffuseTexture8 === texture) {
400
+ return true;
401
+ }
402
+ return false;
403
+ };
404
+ MixMaterial.prototype.dispose = function (forceDisposeEffect) {
405
+ if (this._mixTexture1) {
406
+ this._mixTexture1.dispose();
407
+ }
408
+ _super.prototype.dispose.call(this, forceDisposeEffect);
409
+ };
410
+ MixMaterial.prototype.clone = function (name) {
411
+ var _this = this;
412
+ return SerializationHelper.Clone(function () { return new MixMaterial(name, _this.getScene()); }, this);
413
+ };
414
+ MixMaterial.prototype.serialize = function () {
415
+ var serializationObject = _super.prototype.serialize.call(this);
416
+ serializationObject.customType = "BABYLON.MixMaterial";
417
+ return serializationObject;
418
+ };
419
+ MixMaterial.prototype.getClassName = function () {
420
+ return "MixMaterial";
421
+ };
422
+ // Statics
423
+ MixMaterial.Parse = function (source, scene, rootUrl) {
424
+ return SerializationHelper.Parse(function () { return new MixMaterial(source.name, scene); }, source, scene, rootUrl);
425
+ };
426
+ __decorate([
427
+ serializeAsTexture("mixTexture1")
428
+ ], MixMaterial.prototype, "_mixTexture1", void 0);
429
+ __decorate([
430
+ expandToProperty("_markAllSubMeshesAsTexturesDirty")
431
+ ], MixMaterial.prototype, "mixTexture1", void 0);
432
+ __decorate([
433
+ serializeAsTexture("mixTexture2")
434
+ ], MixMaterial.prototype, "_mixTexture2", void 0);
435
+ __decorate([
436
+ expandToProperty("_markAllSubMeshesAsTexturesDirty")
437
+ ], MixMaterial.prototype, "mixTexture2", void 0);
438
+ __decorate([
439
+ serializeAsTexture("diffuseTexture1")
440
+ ], MixMaterial.prototype, "_diffuseTexture1", void 0);
441
+ __decorate([
442
+ expandToProperty("_markAllSubMeshesAsTexturesDirty")
443
+ ], MixMaterial.prototype, "diffuseTexture1", void 0);
444
+ __decorate([
445
+ serializeAsTexture("diffuseTexture2")
446
+ ], MixMaterial.prototype, "_diffuseTexture2", void 0);
447
+ __decorate([
448
+ expandToProperty("_markAllSubMeshesAsTexturesDirty")
449
+ ], MixMaterial.prototype, "diffuseTexture2", void 0);
450
+ __decorate([
451
+ serializeAsTexture("diffuseTexture3")
452
+ ], MixMaterial.prototype, "_diffuseTexture3", void 0);
453
+ __decorate([
454
+ expandToProperty("_markAllSubMeshesAsTexturesDirty")
455
+ ], MixMaterial.prototype, "diffuseTexture3", void 0);
456
+ __decorate([
457
+ serializeAsTexture("diffuseTexture4")
458
+ ], MixMaterial.prototype, "_diffuseTexture4", void 0);
459
+ __decorate([
460
+ expandToProperty("_markAllSubMeshesAsTexturesDirty")
461
+ ], MixMaterial.prototype, "diffuseTexture4", void 0);
462
+ __decorate([
463
+ serializeAsTexture("diffuseTexture1")
464
+ ], MixMaterial.prototype, "_diffuseTexture5", void 0);
465
+ __decorate([
466
+ expandToProperty("_markAllSubMeshesAsTexturesDirty")
467
+ ], MixMaterial.prototype, "diffuseTexture5", void 0);
468
+ __decorate([
469
+ serializeAsTexture("diffuseTexture2")
470
+ ], MixMaterial.prototype, "_diffuseTexture6", void 0);
471
+ __decorate([
472
+ expandToProperty("_markAllSubMeshesAsTexturesDirty")
473
+ ], MixMaterial.prototype, "diffuseTexture6", void 0);
474
+ __decorate([
475
+ serializeAsTexture("diffuseTexture3")
476
+ ], MixMaterial.prototype, "_diffuseTexture7", void 0);
477
+ __decorate([
478
+ expandToProperty("_markAllSubMeshesAsTexturesDirty")
479
+ ], MixMaterial.prototype, "diffuseTexture7", void 0);
480
+ __decorate([
481
+ serializeAsTexture("diffuseTexture4")
482
+ ], MixMaterial.prototype, "_diffuseTexture8", void 0);
483
+ __decorate([
484
+ expandToProperty("_markAllSubMeshesAsTexturesDirty")
485
+ ], MixMaterial.prototype, "diffuseTexture8", void 0);
486
+ __decorate([
487
+ serializeAsColor3()
488
+ ], MixMaterial.prototype, "diffuseColor", void 0);
489
+ __decorate([
490
+ serializeAsColor3()
491
+ ], MixMaterial.prototype, "specularColor", void 0);
492
+ __decorate([
493
+ serialize()
494
+ ], MixMaterial.prototype, "specularPower", void 0);
495
+ __decorate([
496
+ serialize("disableLighting")
497
+ ], MixMaterial.prototype, "_disableLighting", void 0);
498
+ __decorate([
499
+ expandToProperty("_markAllSubMeshesAsLightsDirty")
500
+ ], MixMaterial.prototype, "disableLighting", void 0);
501
+ __decorate([
502
+ serialize("maxSimultaneousLights")
503
+ ], MixMaterial.prototype, "_maxSimultaneousLights", void 0);
504
+ __decorate([
505
+ expandToProperty("_markAllSubMeshesAsLightsDirty")
506
+ ], MixMaterial.prototype, "maxSimultaneousLights", void 0);
507
+ return MixMaterial;
508
+ }(PushMaterial));
509
+ export { MixMaterial };
510
+ RegisterClass("BABYLON.MixMaterial", MixMaterial);
484
511
  //# sourceMappingURL=mixMaterial.js.map