@babylonjs/materials 5.0.0-rc.5 → 5.0.0-rc.9

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 (153) hide show
  1. package/cell/cell.fragment.d.ts +17 -17
  2. package/cell/cell.fragment.js +20 -20
  3. package/cell/cell.vertex.d.ts +18 -18
  4. package/cell/cell.vertex.js +21 -21
  5. package/cell/cellMaterial.d.ts +37 -37
  6. package/cell/cellMaterial.js +304 -304
  7. package/cell/index.d.ts +1 -1
  8. package/cell/index.js +1 -1
  9. package/custom/customMaterial.d.ts +69 -69
  10. package/custom/customMaterial.js +216 -216
  11. package/custom/index.d.ts +2 -2
  12. package/custom/index.js +2 -2
  13. package/custom/pbrCustomMaterial.d.ts +71 -71
  14. package/custom/pbrCustomMaterial.js +241 -241
  15. package/fire/fire.fragment.d.ts +11 -11
  16. package/fire/fire.fragment.js +14 -14
  17. package/fire/fire.vertex.d.ts +15 -15
  18. package/fire/fire.vertex.js +18 -18
  19. package/fire/fireMaterial.d.ts +38 -38
  20. package/fire/fireMaterial.js +342 -342
  21. package/fire/index.d.ts +1 -1
  22. package/fire/index.js +1 -1
  23. package/fur/fur.fragment.d.ts +17 -17
  24. package/fur/fur.fragment.js +20 -20
  25. package/fur/fur.vertex.d.ts +18 -18
  26. package/fur/fur.vertex.js +21 -21
  27. package/fur/furMaterial.d.ts +56 -56
  28. package/fur/furMaterial.js +500 -500
  29. package/fur/index.d.ts +1 -1
  30. package/fur/index.js +1 -1
  31. package/gradient/gradient.fragment.d.ts +17 -17
  32. package/gradient/gradient.fragment.js +20 -20
  33. package/gradient/gradient.vertex.d.ts +18 -18
  34. package/gradient/gradient.vertex.js +21 -21
  35. package/gradient/gradientMaterial.d.ts +37 -37
  36. package/gradient/gradientMaterial.js +275 -275
  37. package/gradient/index.d.ts +1 -1
  38. package/gradient/index.js +1 -1
  39. package/grid/grid.fragment.d.ts +8 -8
  40. package/grid/grid.fragment.js +11 -11
  41. package/grid/grid.vertex.d.ts +9 -9
  42. package/grid/grid.vertex.js +12 -12
  43. package/grid/gridMaterial.d.ts +77 -77
  44. package/grid/gridMaterial.js +276 -276
  45. package/grid/index.d.ts +1 -1
  46. package/grid/index.js +1 -1
  47. package/index.d.ts +15 -15
  48. package/index.js +15 -15
  49. package/lava/index.d.ts +1 -1
  50. package/lava/index.js +1 -1
  51. package/lava/lava.fragment.d.ts +17 -17
  52. package/lava/lava.fragment.js +20 -20
  53. package/lava/lava.vertex.d.ts +18 -18
  54. package/lava/lava.vertex.js +21 -21
  55. package/lava/lavaMaterial.d.ts +45 -45
  56. package/lava/lavaMaterial.js +394 -394
  57. package/legacy/legacy-cell.d.ts +1 -1
  58. package/legacy/legacy-cell.js +12 -12
  59. package/legacy/legacy-custom.d.ts +1 -1
  60. package/legacy/legacy-custom.js +12 -12
  61. package/legacy/legacy-fire.d.ts +1 -1
  62. package/legacy/legacy-fire.js +12 -12
  63. package/legacy/legacy-fur.d.ts +1 -1
  64. package/legacy/legacy-fur.js +12 -12
  65. package/legacy/legacy-gradient.d.ts +1 -1
  66. package/legacy/legacy-gradient.js +12 -12
  67. package/legacy/legacy-grid.d.ts +1 -1
  68. package/legacy/legacy-grid.js +12 -12
  69. package/legacy/legacy-lava.d.ts +1 -1
  70. package/legacy/legacy-lava.js +12 -12
  71. package/legacy/legacy-mix.d.ts +1 -1
  72. package/legacy/legacy-mix.js +12 -12
  73. package/legacy/legacy-normal.d.ts +1 -1
  74. package/legacy/legacy-normal.js +12 -12
  75. package/legacy/legacy-shadowOnly.d.ts +1 -1
  76. package/legacy/legacy-shadowOnly.js +12 -12
  77. package/legacy/legacy-simple.d.ts +1 -1
  78. package/legacy/legacy-simple.js +12 -12
  79. package/legacy/legacy-sky.d.ts +1 -1
  80. package/legacy/legacy-sky.js +12 -12
  81. package/legacy/legacy-terrain.d.ts +1 -1
  82. package/legacy/legacy-terrain.js +12 -12
  83. package/legacy/legacy-triPlanar.d.ts +1 -1
  84. package/legacy/legacy-triPlanar.js +12 -12
  85. package/legacy/legacy-water.d.ts +1 -1
  86. package/legacy/legacy-water.js +12 -12
  87. package/legacy/legacy.d.ts +1 -1
  88. package/legacy/legacy.js +15 -15
  89. package/mix/index.d.ts +1 -1
  90. package/mix/index.js +1 -1
  91. package/mix/mix.fragment.d.ts +17 -17
  92. package/mix/mix.fragment.js +20 -20
  93. package/mix/mix.vertex.d.ts +18 -18
  94. package/mix/mix.vertex.js +21 -21
  95. package/mix/mixMaterial.d.ts +65 -65
  96. package/mix/mixMaterial.js +510 -510
  97. package/normal/index.d.ts +1 -1
  98. package/normal/index.js +1 -1
  99. package/normal/normal.fragment.d.ts +17 -17
  100. package/normal/normal.fragment.js +20 -20
  101. package/normal/normal.vertex.d.ts +18 -18
  102. package/normal/normal.vertex.js +21 -21
  103. package/normal/normalMaterial.d.ts +36 -36
  104. package/normal/normalMaterial.js +336 -336
  105. package/package.json +2 -2
  106. package/shadowOnly/index.d.ts +1 -1
  107. package/shadowOnly/index.js +1 -1
  108. package/shadowOnly/shadowOnly.fragment.d.ts +16 -16
  109. package/shadowOnly/shadowOnly.fragment.js +19 -19
  110. package/shadowOnly/shadowOnly.vertex.d.ts +18 -18
  111. package/shadowOnly/shadowOnly.vertex.js +21 -21
  112. package/shadowOnly/shadowOnlyMaterial.d.ts +30 -30
  113. package/shadowOnly/shadowOnlyMaterial.js +254 -254
  114. package/simple/index.d.ts +1 -1
  115. package/simple/index.js +1 -1
  116. package/simple/simple.fragment.d.ts +17 -17
  117. package/simple/simple.fragment.js +20 -20
  118. package/simple/simple.vertex.d.ts +18 -18
  119. package/simple/simple.vertex.js +21 -21
  120. package/simple/simpleMaterial.d.ts +35 -35
  121. package/simple/simpleMaterial.js +295 -295
  122. package/sky/index.d.ts +1 -1
  123. package/sky/index.js +1 -1
  124. package/sky/sky.fragment.d.ts +10 -10
  125. package/sky/sky.fragment.js +13 -13
  126. package/sky/sky.vertex.d.ts +9 -9
  127. package/sky/sky.vertex.js +12 -12
  128. package/sky/skyMaterial.d.ts +146 -146
  129. package/sky/skyMaterial.js +359 -359
  130. package/terrain/index.d.ts +1 -1
  131. package/terrain/index.js +1 -1
  132. package/terrain/terrain.fragment.d.ts +17 -17
  133. package/terrain/terrain.fragment.js +20 -20
  134. package/terrain/terrain.vertex.d.ts +18 -18
  135. package/terrain/terrain.vertex.js +21 -21
  136. package/terrain/terrainMaterial.d.ts +50 -50
  137. package/terrain/terrainMaterial.js +426 -426
  138. package/triPlanar/index.d.ts +1 -1
  139. package/triPlanar/index.js +1 -1
  140. package/triPlanar/triPlanarMaterial.d.ts +49 -49
  141. package/triPlanar/triPlanarMaterial.js +403 -403
  142. package/triPlanar/triplanar.fragment.d.ts +17 -17
  143. package/triPlanar/triplanar.fragment.js +20 -20
  144. package/triPlanar/triplanar.vertex.d.ts +18 -18
  145. package/triPlanar/triplanar.vertex.js +21 -21
  146. package/water/index.d.ts +1 -1
  147. package/water/index.js +1 -1
  148. package/water/water.fragment.d.ts +19 -19
  149. package/water/water.fragment.js +22 -22
  150. package/water/water.vertex.d.ts +20 -20
  151. package/water/water.vertex.js +23 -23
  152. package/water/waterMaterial.d.ts +135 -135
  153. package/water/waterMaterial.js +736 -736
@@ -1,305 +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 = [
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);
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);
305
305
  //# sourceMappingURL=cellMaterial.js.map
package/cell/index.d.ts CHANGED
@@ -1 +1 @@
1
- export * from "./cellMaterial";
1
+ export * from "./cellMaterial";
package/cell/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export * from "./cellMaterial.js";
1
+ export * from "./cellMaterial";
2
2
  //# sourceMappingURL=index.js.map