@babylonjs/materials 9.15.0 → 9.16.0

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 (39) hide show
  1. package/cell/cellMaterial.d.ts +4 -4
  2. package/cell/cellMaterial.js +313 -268
  3. package/cell/cellMaterial.js.map +1 -1
  4. package/fire/fireMaterial.d.ts +3 -3
  5. package/fire/fireMaterial.js +344 -303
  6. package/fire/fireMaterial.js.map +1 -1
  7. package/fur/furMaterial.d.ts +4 -4
  8. package/fur/furMaterial.js +519 -450
  9. package/fur/furMaterial.js.map +1 -1
  10. package/gradient/gradientMaterial.d.ts +2 -2
  11. package/gradient/gradientMaterial.js +286 -246
  12. package/gradient/gradientMaterial.js.map +1 -1
  13. package/grid/gridMaterial.d.ts +1 -1
  14. package/grid/gridMaterial.js +453 -398
  15. package/grid/gridMaterial.js.map +1 -1
  16. package/lava/lavaMaterial.d.ts +4 -4
  17. package/lava/lavaMaterial.js +377 -318
  18. package/lava/lavaMaterial.js.map +1 -1
  19. package/mix/mixMaterial.d.ts +12 -12
  20. package/mix/mixMaterial.js +584 -456
  21. package/mix/mixMaterial.js.map +1 -1
  22. package/normal/normalMaterial.d.ts +3 -3
  23. package/normal/normalMaterial.js +301 -264
  24. package/normal/normalMaterial.js.map +1 -1
  25. package/package.json +2 -2
  26. package/simple/simpleMaterial.d.ts +3 -3
  27. package/simple/simpleMaterial.js +299 -262
  28. package/simple/simpleMaterial.js.map +1 -1
  29. package/sky/skyMaterial.js +380 -344
  30. package/sky/skyMaterial.js.map +1 -1
  31. package/terrain/terrainMaterial.d.ts +9 -9
  32. package/terrain/terrainMaterial.js +490 -395
  33. package/terrain/terrainMaterial.js.map +1 -1
  34. package/triPlanar/triPlanarMaterial.d.ts +8 -8
  35. package/triPlanar/triPlanarMaterial.js +460 -369
  36. package/triPlanar/triPlanarMaterial.js.map +1 -1
  37. package/water/waterMaterial.d.ts +7 -7
  38. package/water/waterMaterial.js +759 -659
  39. package/water/waterMaterial.js.map +1 -1
@@ -10,14 +10,14 @@ import { Scene } from "@babylonjs/core/scene.js";
10
10
  import { type IAnimatable } from "@babylonjs/core/Animations/animatable.interface.js";
11
11
  export declare class CellMaterial extends PushMaterial {
12
12
  private _diffuseTexture;
13
- diffuseTexture: BaseTexture;
13
+ accessor diffuseTexture: BaseTexture;
14
14
  diffuseColor: Color3;
15
15
  _computeHighLevel: boolean;
16
- computeHighLevel: boolean;
16
+ accessor computeHighLevel: boolean;
17
17
  private _disableLighting;
18
- disableLighting: boolean;
18
+ accessor disableLighting: boolean;
19
19
  private _maxSimultaneousLights;
20
- maxSimultaneousLights: number;
20
+ accessor maxSimultaneousLights: number;
21
21
  private _shadersLoaded;
22
22
  /**
23
23
  * Instantiates a Cell Material in the given scene
@@ -1,4 +1,4 @@
1
- import { __decorate } from "@babylonjs/core/tslib.es6.js";
1
+ import { __classPrivateFieldGet, __classPrivateFieldSet, __esDecorate, __runInitializers } from "@babylonjs/core/tslib.es6.js";
2
2
  import { serializeAsTexture, serialize, expandToProperty, serializeAsColor3 } from "@babylonjs/core/Misc/decorators.js";
3
3
  import { SerializationHelper } from "@babylonjs/core/Misc/decorators.serialization.js";
4
4
  import { Color3 } from "@babylonjs/core/Maths/math.color.js";
@@ -45,286 +45,331 @@ class CellMaterialDefines extends MaterialDefines {
45
45
  this.rebuild();
46
46
  }
47
47
  }
48
- export class CellMaterial extends PushMaterial {
49
- /**
50
- * Instantiates a Cell Material in the given scene
51
- * @param name The friendly name of the material
52
- * @param scene The scene to add the material to
53
- * @param forceGLSL Use the GLSL code generation for the shader (even on WebGPU). Default is false
54
- */
55
- constructor(name, scene, forceGLSL = false) {
56
- super(name, scene, undefined, forceGLSL);
57
- this.diffuseColor = new Color3(1, 1, 1);
58
- this._computeHighLevel = false;
59
- this._disableLighting = false;
60
- this._maxSimultaneousLights = 4;
61
- this._shadersLoaded = false;
62
- }
63
- needAlphaBlending() {
64
- return this.alpha < 1.0;
65
- }
66
- needAlphaTesting() {
67
- return false;
68
- }
69
- getAlphaTestTexture() {
70
- return null;
71
- }
72
- // Methods
73
- isReadyForSubMesh(mesh, subMesh, useInstances) {
74
- const drawWrapper = subMesh._drawWrapper;
75
- if (this.isFrozen) {
76
- if (drawWrapper.effect && drawWrapper._wasPreviouslyReady && drawWrapper._wasPreviouslyUsingInstances === useInstances) {
77
- return true;
48
+ let CellMaterial = (() => {
49
+ var _a, _CellMaterial_diffuseTexture_accessor_storage, _CellMaterial_computeHighLevel_accessor_storage, _CellMaterial_disableLighting_accessor_storage, _CellMaterial_maxSimultaneousLights_accessor_storage;
50
+ let _classSuper = PushMaterial;
51
+ let __diffuseTexture_decorators;
52
+ let __diffuseTexture_initializers = [];
53
+ let __diffuseTexture_extraInitializers = [];
54
+ let _diffuseTexture_decorators;
55
+ let _diffuseTexture_initializers = [];
56
+ let _diffuseTexture_extraInitializers = [];
57
+ let _diffuseColor_decorators;
58
+ let _diffuseColor_initializers = [];
59
+ let _diffuseColor_extraInitializers = [];
60
+ let __computeHighLevel_decorators;
61
+ let __computeHighLevel_initializers = [];
62
+ let __computeHighLevel_extraInitializers = [];
63
+ let _computeHighLevel_decorators;
64
+ let _computeHighLevel_initializers = [];
65
+ let _computeHighLevel_extraInitializers = [];
66
+ let __disableLighting_decorators;
67
+ let __disableLighting_initializers = [];
68
+ let __disableLighting_extraInitializers = [];
69
+ let _disableLighting_decorators;
70
+ let _disableLighting_initializers = [];
71
+ let _disableLighting_extraInitializers = [];
72
+ let __maxSimultaneousLights_decorators;
73
+ let __maxSimultaneousLights_initializers = [];
74
+ let __maxSimultaneousLights_extraInitializers = [];
75
+ let _maxSimultaneousLights_decorators;
76
+ let _maxSimultaneousLights_initializers = [];
77
+ let _maxSimultaneousLights_extraInitializers = [];
78
+ return _a = class CellMaterial extends _classSuper {
79
+ get diffuseTexture() { return __classPrivateFieldGet(this, _CellMaterial_diffuseTexture_accessor_storage, "f"); }
80
+ set diffuseTexture(value) { __classPrivateFieldSet(this, _CellMaterial_diffuseTexture_accessor_storage, value, "f"); }
81
+ get computeHighLevel() { return __classPrivateFieldGet(this, _CellMaterial_computeHighLevel_accessor_storage, "f"); }
82
+ set computeHighLevel(value) { __classPrivateFieldSet(this, _CellMaterial_computeHighLevel_accessor_storage, value, "f"); }
83
+ get disableLighting() { return __classPrivateFieldGet(this, _CellMaterial_disableLighting_accessor_storage, "f"); }
84
+ set disableLighting(value) { __classPrivateFieldSet(this, _CellMaterial_disableLighting_accessor_storage, value, "f"); }
85
+ get maxSimultaneousLights() { return __classPrivateFieldGet(this, _CellMaterial_maxSimultaneousLights_accessor_storage, "f"); }
86
+ set maxSimultaneousLights(value) { __classPrivateFieldSet(this, _CellMaterial_maxSimultaneousLights_accessor_storage, value, "f"); }
87
+ /**
88
+ * Instantiates a Cell Material in the given scene
89
+ * @param name The friendly name of the material
90
+ * @param scene The scene to add the material to
91
+ * @param forceGLSL Use the GLSL code generation for the shader (even on WebGPU). Default is false
92
+ */
93
+ constructor(name, scene, forceGLSL = false) {
94
+ super(name, scene, undefined, forceGLSL);
95
+ this._diffuseTexture = __runInitializers(this, __diffuseTexture_initializers, void 0);
96
+ _CellMaterial_diffuseTexture_accessor_storage.set(this, (__runInitializers(this, __diffuseTexture_extraInitializers), __runInitializers(this, _diffuseTexture_initializers, void 0)));
97
+ this.diffuseColor = (__runInitializers(this, _diffuseTexture_extraInitializers), __runInitializers(this, _diffuseColor_initializers, new Color3(1, 1, 1)));
98
+ this._computeHighLevel = (__runInitializers(this, _diffuseColor_extraInitializers), __runInitializers(this, __computeHighLevel_initializers, false));
99
+ _CellMaterial_computeHighLevel_accessor_storage.set(this, (__runInitializers(this, __computeHighLevel_extraInitializers), __runInitializers(this, _computeHighLevel_initializers, void 0)));
100
+ this._disableLighting = (__runInitializers(this, _computeHighLevel_extraInitializers), __runInitializers(this, __disableLighting_initializers, false));
101
+ _CellMaterial_disableLighting_accessor_storage.set(this, (__runInitializers(this, __disableLighting_extraInitializers), __runInitializers(this, _disableLighting_initializers, void 0)));
102
+ this._maxSimultaneousLights = (__runInitializers(this, _disableLighting_extraInitializers), __runInitializers(this, __maxSimultaneousLights_initializers, 4));
103
+ _CellMaterial_maxSimultaneousLights_accessor_storage.set(this, (__runInitializers(this, __maxSimultaneousLights_extraInitializers), __runInitializers(this, _maxSimultaneousLights_initializers, void 0)));
104
+ this._shadersLoaded = (__runInitializers(this, _maxSimultaneousLights_extraInitializers), false);
105
+ }
106
+ needAlphaBlending() {
107
+ return this.alpha < 1.0;
108
+ }
109
+ needAlphaTesting() {
110
+ return false;
78
111
  }
79
- }
80
- if (!subMesh.materialDefines) {
81
- subMesh.materialDefines = new CellMaterialDefines();
82
- }
83
- const defines = subMesh.materialDefines;
84
- const scene = this.getScene();
85
- if (this._isReadyForSubMesh(subMesh)) {
86
- return true;
87
- }
88
- const engine = scene.getEngine();
89
- // Textures
90
- if (defines._areTexturesDirty) {
91
- defines._needUVs = false;
92
- if (scene.texturesEnabled) {
93
- if (this._diffuseTexture && MaterialFlags.DiffuseTextureEnabled) {
94
- if (!this._diffuseTexture.isReady()) {
95
- return false;
112
+ getAlphaTestTexture() {
113
+ return null;
114
+ }
115
+ // Methods
116
+ isReadyForSubMesh(mesh, subMesh, useInstances) {
117
+ const drawWrapper = subMesh._drawWrapper;
118
+ if (this.isFrozen) {
119
+ if (drawWrapper.effect && drawWrapper._wasPreviouslyReady && drawWrapper._wasPreviouslyUsingInstances === useInstances) {
120
+ return true;
96
121
  }
97
- else {
98
- defines._needUVs = true;
99
- defines.DIFFUSE = true;
122
+ }
123
+ if (!subMesh.materialDefines) {
124
+ subMesh.materialDefines = new CellMaterialDefines();
125
+ }
126
+ const defines = subMesh.materialDefines;
127
+ const scene = this.getScene();
128
+ if (this._isReadyForSubMesh(subMesh)) {
129
+ return true;
130
+ }
131
+ const engine = scene.getEngine();
132
+ // Textures
133
+ if (defines._areTexturesDirty) {
134
+ defines._needUVs = false;
135
+ if (scene.texturesEnabled) {
136
+ if (this._diffuseTexture && MaterialFlags.DiffuseTextureEnabled) {
137
+ if (!this._diffuseTexture.isReady()) {
138
+ return false;
139
+ }
140
+ else {
141
+ defines._needUVs = true;
142
+ defines.DIFFUSE = true;
143
+ }
144
+ }
100
145
  }
101
146
  }
147
+ // High level
148
+ defines.CELLBASIC = !this.computeHighLevel;
149
+ // Misc.
150
+ PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this.needAlphaTestingForMesh(mesh), defines, undefined, undefined, undefined, this._isVertexOutputInvariant);
151
+ // Lights
152
+ defines._needNormals = PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
153
+ // Values that need to be evaluated on every frame
154
+ PrepareDefinesForFrameBoundValues(scene, engine, this, defines, useInstances ? true : false);
155
+ // Attribs
156
+ PrepareDefinesForAttributes(mesh, defines, true, true);
157
+ // Get correct effect
158
+ if (defines.isDirty) {
159
+ defines.markAsProcessed();
160
+ scene.resetCachedMaterial();
161
+ // Fallbacks
162
+ const fallbacks = new EffectFallbacks();
163
+ if (defines.FOG) {
164
+ fallbacks.addFallback(1, "FOG");
165
+ }
166
+ HandleFallbacksForShadows(defines, fallbacks, this.maxSimultaneousLights);
167
+ if (defines.NUM_BONE_INFLUENCERS > 0) {
168
+ fallbacks.addCPUSkinningFallback(0, mesh);
169
+ }
170
+ defines.IMAGEPROCESSINGPOSTPROCESS = scene.imageProcessingConfiguration.applyByPostProcess;
171
+ //Attributes
172
+ const attribs = [VertexBuffer.PositionKind];
173
+ if (defines.NORMAL) {
174
+ attribs.push(VertexBuffer.NormalKind);
175
+ }
176
+ if (defines.UV1) {
177
+ attribs.push(VertexBuffer.UVKind);
178
+ }
179
+ if (defines.UV2) {
180
+ attribs.push(VertexBuffer.UV2Kind);
181
+ }
182
+ if (defines.VERTEXCOLOR) {
183
+ attribs.push(VertexBuffer.ColorKind);
184
+ }
185
+ PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
186
+ PrepareAttributesForInstances(attribs, defines);
187
+ const shaderName = "cell";
188
+ const join = defines.toString();
189
+ const uniforms = [
190
+ "world",
191
+ "view",
192
+ "viewProjection",
193
+ "vEyePosition",
194
+ "vLightsType",
195
+ "vDiffuseColor",
196
+ "vFogInfos",
197
+ "vFogColor",
198
+ "pointSize",
199
+ "vDiffuseInfos",
200
+ "mBones",
201
+ "diffuseMatrix",
202
+ "logarithmicDepthConstant",
203
+ ];
204
+ const samplers = ["diffuseSampler", "areaLightsLTC1Sampler", "areaLightsLTC2Sampler"];
205
+ const uniformBuffers = [];
206
+ AddClipPlaneUniforms(uniforms);
207
+ PrepareUniformsAndSamplersList({
208
+ uniformsNames: uniforms,
209
+ uniformBuffersNames: uniformBuffers,
210
+ samplers: samplers,
211
+ defines: defines,
212
+ maxSimultaneousLights: this.maxSimultaneousLights,
213
+ shaderLanguage: this._shaderLanguage,
214
+ });
215
+ subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
216
+ attributes: attribs,
217
+ uniformsNames: uniforms,
218
+ uniformBuffersNames: uniformBuffers,
219
+ samplers: samplers,
220
+ defines: join,
221
+ fallbacks: fallbacks,
222
+ onCompiled: this.onCompiled,
223
+ onError: this.onError,
224
+ indexParameters: { maxSimultaneousLights: this.maxSimultaneousLights - 1 },
225
+ shaderLanguage: this._shaderLanguage,
226
+ extraInitializationsAsync: this._shadersLoaded
227
+ ? undefined
228
+ : async () => {
229
+ if (this.shaderLanguage === 1 /* ShaderLanguage.WGSL */) {
230
+ await Promise.all([import("./wgsl/cell.vertex.js"), import("./wgsl/cell.fragment.js")]);
231
+ }
232
+ else {
233
+ await Promise.all([import("./cell.vertex.js"), import("./cell.fragment.js")]);
234
+ }
235
+ this._shadersLoaded = true;
236
+ },
237
+ }, engine), defines, this._materialContext);
238
+ }
239
+ // Check if Area Lights have LTC texture.
240
+ if (defines["AREALIGHTUSED"]) {
241
+ for (let index = 0; index < mesh.lightSources.length; index++) {
242
+ if (!mesh.lightSources[index]._isReady()) {
243
+ return false;
244
+ }
245
+ }
246
+ }
247
+ if (!subMesh.effect || !subMesh.effect.isReady()) {
248
+ return false;
249
+ }
250
+ defines._renderId = scene.getRenderId();
251
+ drawWrapper._wasPreviouslyReady = true;
252
+ drawWrapper._wasPreviouslyUsingInstances = !!useInstances;
253
+ return true;
102
254
  }
103
- }
104
- // High level
105
- defines.CELLBASIC = !this.computeHighLevel;
106
- // Misc.
107
- PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this.needAlphaTestingForMesh(mesh), defines, undefined, undefined, undefined, this._isVertexOutputInvariant);
108
- // Lights
109
- defines._needNormals = PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
110
- // Values that need to be evaluated on every frame
111
- PrepareDefinesForFrameBoundValues(scene, engine, this, defines, useInstances ? true : false);
112
- // Attribs
113
- PrepareDefinesForAttributes(mesh, defines, true, true);
114
- // Get correct effect
115
- if (defines.isDirty) {
116
- defines.markAsProcessed();
117
- scene.resetCachedMaterial();
118
- // Fallbacks
119
- const fallbacks = new EffectFallbacks();
120
- if (defines.FOG) {
121
- fallbacks.addFallback(1, "FOG");
122
- }
123
- HandleFallbacksForShadows(defines, fallbacks, this.maxSimultaneousLights);
124
- if (defines.NUM_BONE_INFLUENCERS > 0) {
125
- fallbacks.addCPUSkinningFallback(0, mesh);
126
- }
127
- defines.IMAGEPROCESSINGPOSTPROCESS = scene.imageProcessingConfiguration.applyByPostProcess;
128
- //Attributes
129
- const attribs = [VertexBuffer.PositionKind];
130
- if (defines.NORMAL) {
131
- attribs.push(VertexBuffer.NormalKind);
255
+ bindForSubMesh(world, mesh, subMesh) {
256
+ const scene = this.getScene();
257
+ const defines = subMesh.materialDefines;
258
+ if (!defines) {
259
+ return;
260
+ }
261
+ const effect = subMesh.effect;
262
+ if (!effect) {
263
+ return;
264
+ }
265
+ this._activeEffect = effect;
266
+ // Matrices
267
+ this.bindOnlyWorldMatrix(world);
268
+ this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
269
+ // Bones
270
+ BindBonesParameters(mesh, this._activeEffect);
271
+ if (this._mustRebind(scene, effect, subMesh)) {
272
+ // Textures
273
+ if (this._diffuseTexture && MaterialFlags.DiffuseTextureEnabled) {
274
+ this._activeEffect.setTexture("diffuseSampler", this._diffuseTexture);
275
+ this._activeEffect.setFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
276
+ this._activeEffect.setMatrix("diffuseMatrix", this._diffuseTexture.getTextureMatrix());
277
+ }
278
+ // Clip plane
279
+ BindClipPlane(this._activeEffect, this, scene);
280
+ // Point size
281
+ if (this.pointsCloud) {
282
+ this._activeEffect.setFloat("pointSize", this.pointSize);
283
+ }
284
+ // Log. depth
285
+ if (this._useLogarithmicDepth) {
286
+ BindLogDepth(defines, effect, scene);
287
+ }
288
+ scene.bindEyePosition(effect);
289
+ }
290
+ this._activeEffect.setColor4("vDiffuseColor", this.diffuseColor, this.alpha * mesh.visibility);
291
+ // Lights
292
+ if (scene.lightsEnabled && !this.disableLighting) {
293
+ BindLights(scene, mesh, this._activeEffect, defines, this._maxSimultaneousLights);
294
+ }
295
+ // View
296
+ if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE) {
297
+ this._activeEffect.setMatrix("view", scene.getViewMatrix());
298
+ }
299
+ // Fog
300
+ BindFogParameters(scene, mesh, this._activeEffect);
301
+ this._afterBind(mesh, this._activeEffect, subMesh);
132
302
  }
133
- if (defines.UV1) {
134
- attribs.push(VertexBuffer.UVKind);
303
+ getAnimatables() {
304
+ const results = [];
305
+ if (this._diffuseTexture && this._diffuseTexture.animations && this._diffuseTexture.animations.length > 0) {
306
+ results.push(this._diffuseTexture);
307
+ }
308
+ return results;
135
309
  }
136
- if (defines.UV2) {
137
- attribs.push(VertexBuffer.UV2Kind);
310
+ getActiveTextures() {
311
+ const activeTextures = super.getActiveTextures();
312
+ if (this._diffuseTexture) {
313
+ activeTextures.push(this._diffuseTexture);
314
+ }
315
+ return activeTextures;
138
316
  }
139
- if (defines.VERTEXCOLOR) {
140
- attribs.push(VertexBuffer.ColorKind);
317
+ hasTexture(texture) {
318
+ if (super.hasTexture(texture)) {
319
+ return true;
320
+ }
321
+ return this._diffuseTexture === texture;
141
322
  }
142
- PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
143
- PrepareAttributesForInstances(attribs, defines);
144
- const shaderName = "cell";
145
- const join = defines.toString();
146
- const uniforms = [
147
- "world",
148
- "view",
149
- "viewProjection",
150
- "vEyePosition",
151
- "vLightsType",
152
- "vDiffuseColor",
153
- "vFogInfos",
154
- "vFogColor",
155
- "pointSize",
156
- "vDiffuseInfos",
157
- "mBones",
158
- "diffuseMatrix",
159
- "logarithmicDepthConstant",
160
- ];
161
- const samplers = ["diffuseSampler", "areaLightsLTC1Sampler", "areaLightsLTC2Sampler"];
162
- const uniformBuffers = [];
163
- AddClipPlaneUniforms(uniforms);
164
- PrepareUniformsAndSamplersList({
165
- uniformsNames: uniforms,
166
- uniformBuffersNames: uniformBuffers,
167
- samplers: samplers,
168
- defines: defines,
169
- maxSimultaneousLights: this.maxSimultaneousLights,
170
- shaderLanguage: this._shaderLanguage,
171
- });
172
- subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
173
- attributes: attribs,
174
- uniformsNames: uniforms,
175
- uniformBuffersNames: uniformBuffers,
176
- samplers: samplers,
177
- defines: join,
178
- fallbacks: fallbacks,
179
- onCompiled: this.onCompiled,
180
- onError: this.onError,
181
- indexParameters: { maxSimultaneousLights: this.maxSimultaneousLights - 1 },
182
- shaderLanguage: this._shaderLanguage,
183
- extraInitializationsAsync: this._shadersLoaded
184
- ? undefined
185
- : async () => {
186
- if (this.shaderLanguage === 1 /* ShaderLanguage.WGSL */) {
187
- await Promise.all([import("./wgsl/cell.vertex.js"), import("./wgsl/cell.fragment.js")]);
188
- }
189
- else {
190
- await Promise.all([import("./cell.vertex.js"), import("./cell.fragment.js")]);
191
- }
192
- this._shadersLoaded = true;
193
- },
194
- }, engine), defines, this._materialContext);
195
- }
196
- // Check if Area Lights have LTC texture.
197
- if (defines["AREALIGHTUSED"]) {
198
- for (let index = 0; index < mesh.lightSources.length; index++) {
199
- if (!mesh.lightSources[index]._isReady()) {
200
- return false;
323
+ dispose(forceDisposeEffect) {
324
+ if (this._diffuseTexture) {
325
+ this._diffuseTexture.dispose();
201
326
  }
327
+ super.dispose(forceDisposeEffect);
202
328
  }
203
- }
204
- if (!subMesh.effect || !subMesh.effect.isReady()) {
205
- return false;
206
- }
207
- defines._renderId = scene.getRenderId();
208
- drawWrapper._wasPreviouslyReady = true;
209
- drawWrapper._wasPreviouslyUsingInstances = !!useInstances;
210
- return true;
211
- }
212
- bindForSubMesh(world, mesh, subMesh) {
213
- const scene = this.getScene();
214
- const defines = subMesh.materialDefines;
215
- if (!defines) {
216
- return;
217
- }
218
- const effect = subMesh.effect;
219
- if (!effect) {
220
- return;
221
- }
222
- this._activeEffect = effect;
223
- // Matrices
224
- this.bindOnlyWorldMatrix(world);
225
- this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
226
- // Bones
227
- BindBonesParameters(mesh, this._activeEffect);
228
- if (this._mustRebind(scene, effect, subMesh)) {
229
- // Textures
230
- if (this._diffuseTexture && MaterialFlags.DiffuseTextureEnabled) {
231
- this._activeEffect.setTexture("diffuseSampler", this._diffuseTexture);
232
- this._activeEffect.setFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
233
- this._activeEffect.setMatrix("diffuseMatrix", this._diffuseTexture.getTextureMatrix());
329
+ getClassName() {
330
+ return "CellMaterial";
234
331
  }
235
- // Clip plane
236
- BindClipPlane(this._activeEffect, this, scene);
237
- // Point size
238
- if (this.pointsCloud) {
239
- this._activeEffect.setFloat("pointSize", this.pointSize);
332
+ clone(name) {
333
+ return SerializationHelper.Clone(() => new _a(name, this.getScene()), this);
240
334
  }
241
- // Log. depth
242
- if (this._useLogarithmicDepth) {
243
- BindLogDepth(defines, effect, scene);
335
+ serialize() {
336
+ const serializationObject = super.serialize();
337
+ serializationObject.customType = "BABYLON.CellMaterial";
338
+ return serializationObject;
244
339
  }
245
- scene.bindEyePosition(effect);
246
- }
247
- this._activeEffect.setColor4("vDiffuseColor", this.diffuseColor, this.alpha * mesh.visibility);
248
- // Lights
249
- if (scene.lightsEnabled && !this.disableLighting) {
250
- BindLights(scene, mesh, this._activeEffect, defines, this._maxSimultaneousLights);
251
- }
252
- // View
253
- if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE) {
254
- this._activeEffect.setMatrix("view", scene.getViewMatrix());
255
- }
256
- // Fog
257
- BindFogParameters(scene, mesh, this._activeEffect);
258
- this._afterBind(mesh, this._activeEffect, subMesh);
259
- }
260
- getAnimatables() {
261
- const results = [];
262
- if (this._diffuseTexture && this._diffuseTexture.animations && this._diffuseTexture.animations.length > 0) {
263
- results.push(this._diffuseTexture);
264
- }
265
- return results;
266
- }
267
- getActiveTextures() {
268
- const activeTextures = super.getActiveTextures();
269
- if (this._diffuseTexture) {
270
- activeTextures.push(this._diffuseTexture);
271
- }
272
- return activeTextures;
273
- }
274
- hasTexture(texture) {
275
- if (super.hasTexture(texture)) {
276
- return true;
277
- }
278
- return this._diffuseTexture === texture;
279
- }
280
- dispose(forceDisposeEffect) {
281
- if (this._diffuseTexture) {
282
- this._diffuseTexture.dispose();
283
- }
284
- super.dispose(forceDisposeEffect);
285
- }
286
- getClassName() {
287
- return "CellMaterial";
288
- }
289
- clone(name) {
290
- return SerializationHelper.Clone(() => new CellMaterial(name, this.getScene()), this);
291
- }
292
- serialize() {
293
- const serializationObject = super.serialize();
294
- serializationObject.customType = "BABYLON.CellMaterial";
295
- return serializationObject;
296
- }
297
- // Statics
298
- static Parse(source, scene, rootUrl) {
299
- return SerializationHelper.Parse(() => new CellMaterial(source.name, scene), source, scene, rootUrl);
300
- }
301
- }
302
- __decorate([
303
- serializeAsTexture("diffuseTexture")
304
- ], CellMaterial.prototype, "_diffuseTexture", void 0);
305
- __decorate([
306
- expandToProperty("_markAllSubMeshesAsTexturesDirty")
307
- ], CellMaterial.prototype, "diffuseTexture", void 0);
308
- __decorate([
309
- serializeAsColor3("diffuse")
310
- ], CellMaterial.prototype, "diffuseColor", void 0);
311
- __decorate([
312
- serialize("computeHighLevel")
313
- ], CellMaterial.prototype, "_computeHighLevel", void 0);
314
- __decorate([
315
- expandToProperty("_markAllSubMeshesAsTexturesDirty")
316
- ], CellMaterial.prototype, "computeHighLevel", void 0);
317
- __decorate([
318
- serialize("disableLighting")
319
- ], CellMaterial.prototype, "_disableLighting", void 0);
320
- __decorate([
321
- expandToProperty("_markAllSubMeshesAsLightsDirty")
322
- ], CellMaterial.prototype, "disableLighting", void 0);
323
- __decorate([
324
- serialize("maxSimultaneousLights")
325
- ], CellMaterial.prototype, "_maxSimultaneousLights", void 0);
326
- __decorate([
327
- expandToProperty("_markAllSubMeshesAsLightsDirty")
328
- ], CellMaterial.prototype, "maxSimultaneousLights", void 0);
340
+ // Statics
341
+ static Parse(source, scene, rootUrl) {
342
+ return SerializationHelper.Parse(() => new _a(source.name, scene), source, scene, rootUrl);
343
+ }
344
+ },
345
+ _CellMaterial_diffuseTexture_accessor_storage = new WeakMap(),
346
+ _CellMaterial_computeHighLevel_accessor_storage = new WeakMap(),
347
+ _CellMaterial_disableLighting_accessor_storage = new WeakMap(),
348
+ _CellMaterial_maxSimultaneousLights_accessor_storage = new WeakMap(),
349
+ (() => {
350
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
351
+ __diffuseTexture_decorators = [serializeAsTexture("diffuseTexture")];
352
+ _diffuseTexture_decorators = [expandToProperty("_markAllSubMeshesAsTexturesDirty")];
353
+ _diffuseColor_decorators = [serializeAsColor3("diffuse")];
354
+ __computeHighLevel_decorators = [serialize("computeHighLevel")];
355
+ _computeHighLevel_decorators = [expandToProperty("_markAllSubMeshesAsTexturesDirty")];
356
+ __disableLighting_decorators = [serialize("disableLighting")];
357
+ _disableLighting_decorators = [expandToProperty("_markAllSubMeshesAsLightsDirty")];
358
+ __maxSimultaneousLights_decorators = [serialize("maxSimultaneousLights")];
359
+ _maxSimultaneousLights_decorators = [expandToProperty("_markAllSubMeshesAsLightsDirty")];
360
+ __esDecorate(_a, null, _diffuseTexture_decorators, { kind: "accessor", name: "diffuseTexture", static: false, private: false, access: { has: obj => "diffuseTexture" in obj, get: obj => obj.diffuseTexture, set: (obj, value) => { obj.diffuseTexture = value; } }, metadata: _metadata }, _diffuseTexture_initializers, _diffuseTexture_extraInitializers);
361
+ __esDecorate(_a, null, _computeHighLevel_decorators, { kind: "accessor", name: "computeHighLevel", static: false, private: false, access: { has: obj => "computeHighLevel" in obj, get: obj => obj.computeHighLevel, set: (obj, value) => { obj.computeHighLevel = value; } }, metadata: _metadata }, _computeHighLevel_initializers, _computeHighLevel_extraInitializers);
362
+ __esDecorate(_a, null, _disableLighting_decorators, { kind: "accessor", name: "disableLighting", static: false, private: false, access: { has: obj => "disableLighting" in obj, get: obj => obj.disableLighting, set: (obj, value) => { obj.disableLighting = value; } }, metadata: _metadata }, _disableLighting_initializers, _disableLighting_extraInitializers);
363
+ __esDecorate(_a, null, _maxSimultaneousLights_decorators, { kind: "accessor", name: "maxSimultaneousLights", static: false, private: false, access: { has: obj => "maxSimultaneousLights" in obj, get: obj => obj.maxSimultaneousLights, set: (obj, value) => { obj.maxSimultaneousLights = value; } }, metadata: _metadata }, _maxSimultaneousLights_initializers, _maxSimultaneousLights_extraInitializers);
364
+ __esDecorate(null, null, __diffuseTexture_decorators, { kind: "field", name: "_diffuseTexture", static: false, private: false, access: { has: obj => "_diffuseTexture" in obj, get: obj => obj._diffuseTexture, set: (obj, value) => { obj._diffuseTexture = value; } }, metadata: _metadata }, __diffuseTexture_initializers, __diffuseTexture_extraInitializers);
365
+ __esDecorate(null, null, _diffuseColor_decorators, { kind: "field", name: "diffuseColor", static: false, private: false, access: { has: obj => "diffuseColor" in obj, get: obj => obj.diffuseColor, set: (obj, value) => { obj.diffuseColor = value; } }, metadata: _metadata }, _diffuseColor_initializers, _diffuseColor_extraInitializers);
366
+ __esDecorate(null, null, __computeHighLevel_decorators, { kind: "field", name: "_computeHighLevel", static: false, private: false, access: { has: obj => "_computeHighLevel" in obj, get: obj => obj._computeHighLevel, set: (obj, value) => { obj._computeHighLevel = value; } }, metadata: _metadata }, __computeHighLevel_initializers, __computeHighLevel_extraInitializers);
367
+ __esDecorate(null, null, __disableLighting_decorators, { kind: "field", name: "_disableLighting", static: false, private: false, access: { has: obj => "_disableLighting" in obj, get: obj => obj._disableLighting, set: (obj, value) => { obj._disableLighting = value; } }, metadata: _metadata }, __disableLighting_initializers, __disableLighting_extraInitializers);
368
+ __esDecorate(null, null, __maxSimultaneousLights_decorators, { kind: "field", name: "_maxSimultaneousLights", static: false, private: false, access: { has: obj => "_maxSimultaneousLights" in obj, get: obj => obj._maxSimultaneousLights, set: (obj, value) => { obj._maxSimultaneousLights = value; } }, metadata: _metadata }, __maxSimultaneousLights_initializers, __maxSimultaneousLights_extraInitializers);
369
+ if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
370
+ })(),
371
+ _a;
372
+ })();
373
+ export { CellMaterial };
329
374
  RegisterClass("BABYLON.CellMaterial", CellMaterial);
330
375
  //# sourceMappingURL=cellMaterial.js.map