@babylonjs/materials 9.15.0 → 9.16.1
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.
- package/cell/cellMaterial.d.ts +4 -4
- package/cell/cellMaterial.js +313 -268
- package/cell/cellMaterial.js.map +1 -1
- package/fire/fireMaterial.d.ts +3 -3
- package/fire/fireMaterial.js +344 -303
- package/fire/fireMaterial.js.map +1 -1
- package/fur/furMaterial.d.ts +4 -4
- package/fur/furMaterial.js +519 -450
- package/fur/furMaterial.js.map +1 -1
- package/gradient/gradientMaterial.d.ts +2 -2
- package/gradient/gradientMaterial.js +286 -246
- package/gradient/gradientMaterial.js.map +1 -1
- package/grid/gridMaterial.d.ts +1 -1
- package/grid/gridMaterial.js +453 -398
- package/grid/gridMaterial.js.map +1 -1
- package/lava/lavaMaterial.d.ts +4 -4
- package/lava/lavaMaterial.js +377 -318
- package/lava/lavaMaterial.js.map +1 -1
- package/mix/mixMaterial.d.ts +12 -12
- package/mix/mixMaterial.js +584 -456
- package/mix/mixMaterial.js.map +1 -1
- package/normal/normalMaterial.d.ts +3 -3
- package/normal/normalMaterial.js +301 -264
- package/normal/normalMaterial.js.map +1 -1
- package/package.json +2 -2
- package/simple/simpleMaterial.d.ts +3 -3
- package/simple/simpleMaterial.js +299 -262
- package/simple/simpleMaterial.js.map +1 -1
- package/sky/skyMaterial.js +380 -344
- package/sky/skyMaterial.js.map +1 -1
- package/terrain/terrainMaterial.d.ts +9 -9
- package/terrain/terrainMaterial.js +490 -395
- package/terrain/terrainMaterial.js.map +1 -1
- package/triPlanar/triPlanarMaterial.d.ts +8 -8
- package/triPlanar/triPlanarMaterial.js +460 -369
- package/triPlanar/triPlanarMaterial.js.map +1 -1
- package/water/waterMaterial.d.ts +7 -7
- package/water/waterMaterial.js +759 -659
- package/water/waterMaterial.js.map +1 -1
package/lava/lavaMaterial.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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";
|
|
@@ -84,337 +84,396 @@ class LavaMaterialDefines extends MaterialDefines {
|
|
|
84
84
|
this.rebuild();
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
87
|
+
let LavaMaterial = (() => {
|
|
88
|
+
var _a, _LavaMaterial_diffuseTexture_accessor_storage, _LavaMaterial_disableLighting_accessor_storage, _LavaMaterial_unlit_accessor_storage, _LavaMaterial_maxSimultaneousLights_accessor_storage;
|
|
89
|
+
let _classSuper = PushMaterial;
|
|
90
|
+
let __diffuseTexture_decorators;
|
|
91
|
+
let __diffuseTexture_initializers = [];
|
|
92
|
+
let __diffuseTexture_extraInitializers = [];
|
|
93
|
+
let _diffuseTexture_decorators;
|
|
94
|
+
let _diffuseTexture_initializers = [];
|
|
95
|
+
let _diffuseTexture_extraInitializers = [];
|
|
96
|
+
let _noiseTexture_decorators;
|
|
97
|
+
let _noiseTexture_initializers = [];
|
|
98
|
+
let _noiseTexture_extraInitializers = [];
|
|
99
|
+
let _fogColor_decorators;
|
|
100
|
+
let _fogColor_initializers = [];
|
|
101
|
+
let _fogColor_extraInitializers = [];
|
|
102
|
+
let _speed_decorators;
|
|
103
|
+
let _speed_initializers = [];
|
|
104
|
+
let _speed_extraInitializers = [];
|
|
105
|
+
let _movingSpeed_decorators;
|
|
106
|
+
let _movingSpeed_initializers = [];
|
|
107
|
+
let _movingSpeed_extraInitializers = [];
|
|
108
|
+
let _lowFrequencySpeed_decorators;
|
|
109
|
+
let _lowFrequencySpeed_initializers = [];
|
|
110
|
+
let _lowFrequencySpeed_extraInitializers = [];
|
|
111
|
+
let _fogDensity_decorators;
|
|
112
|
+
let _fogDensity_initializers = [];
|
|
113
|
+
let _fogDensity_extraInitializers = [];
|
|
114
|
+
let _diffuseColor_decorators;
|
|
115
|
+
let _diffuseColor_initializers = [];
|
|
116
|
+
let _diffuseColor_extraInitializers = [];
|
|
117
|
+
let __disableLighting_decorators;
|
|
118
|
+
let __disableLighting_initializers = [];
|
|
119
|
+
let __disableLighting_extraInitializers = [];
|
|
120
|
+
let _disableLighting_decorators;
|
|
121
|
+
let _disableLighting_initializers = [];
|
|
122
|
+
let _disableLighting_extraInitializers = [];
|
|
123
|
+
let __unlit_decorators;
|
|
124
|
+
let __unlit_initializers = [];
|
|
125
|
+
let __unlit_extraInitializers = [];
|
|
126
|
+
let _unlit_decorators;
|
|
127
|
+
let _unlit_initializers = [];
|
|
128
|
+
let _unlit_extraInitializers = [];
|
|
129
|
+
let __maxSimultaneousLights_decorators;
|
|
130
|
+
let __maxSimultaneousLights_initializers = [];
|
|
131
|
+
let __maxSimultaneousLights_extraInitializers = [];
|
|
132
|
+
let _maxSimultaneousLights_decorators;
|
|
133
|
+
let _maxSimultaneousLights_initializers = [];
|
|
134
|
+
let _maxSimultaneousLights_extraInitializers = [];
|
|
135
|
+
return _a = class LavaMaterial extends _classSuper {
|
|
136
|
+
get diffuseTexture() { return __classPrivateFieldGet(this, _LavaMaterial_diffuseTexture_accessor_storage, "f"); }
|
|
137
|
+
set diffuseTexture(value) { __classPrivateFieldSet(this, _LavaMaterial_diffuseTexture_accessor_storage, value, "f"); }
|
|
138
|
+
get disableLighting() { return __classPrivateFieldGet(this, _LavaMaterial_disableLighting_accessor_storage, "f"); }
|
|
139
|
+
set disableLighting(value) { __classPrivateFieldSet(this, _LavaMaterial_disableLighting_accessor_storage, value, "f"); }
|
|
140
|
+
get unlit() { return __classPrivateFieldGet(this, _LavaMaterial_unlit_accessor_storage, "f"); }
|
|
141
|
+
set unlit(value) { __classPrivateFieldSet(this, _LavaMaterial_unlit_accessor_storage, value, "f"); }
|
|
142
|
+
get maxSimultaneousLights() { return __classPrivateFieldGet(this, _LavaMaterial_maxSimultaneousLights_accessor_storage, "f"); }
|
|
143
|
+
set maxSimultaneousLights(value) { __classPrivateFieldSet(this, _LavaMaterial_maxSimultaneousLights_accessor_storage, value, "f"); }
|
|
144
|
+
/**
|
|
145
|
+
* Instantiates a Lava Material in the given scene
|
|
146
|
+
* @param name The friendly name of the material
|
|
147
|
+
* @param scene The scene to add the material to
|
|
148
|
+
* @param forceGLSL Use the GLSL code generation for the shader (even on WebGPU). Default is false
|
|
149
|
+
*/
|
|
150
|
+
constructor(name, scene, forceGLSL = false) {
|
|
151
|
+
super(name, scene, undefined, forceGLSL);
|
|
152
|
+
this._diffuseTexture = __runInitializers(this, __diffuseTexture_initializers, void 0);
|
|
153
|
+
_LavaMaterial_diffuseTexture_accessor_storage.set(this, (__runInitializers(this, __diffuseTexture_extraInitializers), __runInitializers(this, _diffuseTexture_initializers, void 0)));
|
|
154
|
+
this.noiseTexture = (__runInitializers(this, _diffuseTexture_extraInitializers), __runInitializers(this, _noiseTexture_initializers, void 0));
|
|
155
|
+
this.fogColor = (__runInitializers(this, _noiseTexture_extraInitializers), __runInitializers(this, _fogColor_initializers, void 0));
|
|
156
|
+
this.speed = (__runInitializers(this, _fogColor_extraInitializers), __runInitializers(this, _speed_initializers, 1));
|
|
157
|
+
this.movingSpeed = (__runInitializers(this, _speed_extraInitializers), __runInitializers(this, _movingSpeed_initializers, 1));
|
|
158
|
+
this.lowFrequencySpeed = (__runInitializers(this, _movingSpeed_extraInitializers), __runInitializers(this, _lowFrequencySpeed_initializers, 1));
|
|
159
|
+
this.fogDensity = (__runInitializers(this, _lowFrequencySpeed_extraInitializers), __runInitializers(this, _fogDensity_initializers, 0.15));
|
|
160
|
+
this._lastTime = (__runInitializers(this, _fogDensity_extraInitializers), 0);
|
|
161
|
+
this.diffuseColor = __runInitializers(this, _diffuseColor_initializers, new Color3(1, 1, 1));
|
|
162
|
+
this._disableLighting = (__runInitializers(this, _diffuseColor_extraInitializers), __runInitializers(this, __disableLighting_initializers, false));
|
|
163
|
+
_LavaMaterial_disableLighting_accessor_storage.set(this, (__runInitializers(this, __disableLighting_extraInitializers), __runInitializers(this, _disableLighting_initializers, void 0)));
|
|
164
|
+
this._unlit = (__runInitializers(this, _disableLighting_extraInitializers), __runInitializers(this, __unlit_initializers, false));
|
|
165
|
+
_LavaMaterial_unlit_accessor_storage.set(this, (__runInitializers(this, __unlit_extraInitializers), __runInitializers(this, _unlit_initializers, void 0)));
|
|
166
|
+
this._maxSimultaneousLights = (__runInitializers(this, _unlit_extraInitializers), __runInitializers(this, __maxSimultaneousLights_initializers, 4));
|
|
167
|
+
_LavaMaterial_maxSimultaneousLights_accessor_storage.set(this, (__runInitializers(this, __maxSimultaneousLights_extraInitializers), __runInitializers(this, _maxSimultaneousLights_initializers, void 0)));
|
|
168
|
+
this._scaledDiffuse = (__runInitializers(this, _maxSimultaneousLights_extraInitializers), new Color3());
|
|
169
|
+
this._shadersLoaded = false;
|
|
170
|
+
}
|
|
171
|
+
needAlphaBlending() {
|
|
172
|
+
return this.alpha < 1.0;
|
|
173
|
+
}
|
|
174
|
+
needAlphaTesting() {
|
|
175
|
+
return false;
|
|
176
|
+
}
|
|
177
|
+
getAlphaTestTexture() {
|
|
178
|
+
return null;
|
|
123
179
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
if (this._isReadyForSubMesh(subMesh)) {
|
|
131
|
-
return true;
|
|
132
|
-
}
|
|
133
|
-
const engine = scene.getEngine();
|
|
134
|
-
// Textures
|
|
135
|
-
if (defines._areTexturesDirty) {
|
|
136
|
-
defines._needUVs = false;
|
|
137
|
-
if (scene.texturesEnabled) {
|
|
138
|
-
if (this._diffuseTexture && MaterialFlags.DiffuseTextureEnabled) {
|
|
139
|
-
if (!this._diffuseTexture.isReady()) {
|
|
140
|
-
return false;
|
|
180
|
+
// Methods
|
|
181
|
+
isReadyForSubMesh(mesh, subMesh, useInstances) {
|
|
182
|
+
const drawWrapper = subMesh._drawWrapper;
|
|
183
|
+
if (this.isFrozen) {
|
|
184
|
+
if (drawWrapper.effect && drawWrapper._wasPreviouslyReady && drawWrapper._wasPreviouslyUsingInstances === useInstances) {
|
|
185
|
+
return true;
|
|
141
186
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
187
|
+
}
|
|
188
|
+
if (!subMesh.materialDefines) {
|
|
189
|
+
subMesh.materialDefines = new LavaMaterialDefines();
|
|
190
|
+
}
|
|
191
|
+
const defines = subMesh.materialDefines;
|
|
192
|
+
const scene = this.getScene();
|
|
193
|
+
if (this._isReadyForSubMesh(subMesh)) {
|
|
194
|
+
return true;
|
|
195
|
+
}
|
|
196
|
+
const engine = scene.getEngine();
|
|
197
|
+
// Textures
|
|
198
|
+
if (defines._areTexturesDirty) {
|
|
199
|
+
defines._needUVs = false;
|
|
200
|
+
if (scene.texturesEnabled) {
|
|
201
|
+
if (this._diffuseTexture && MaterialFlags.DiffuseTextureEnabled) {
|
|
202
|
+
if (!this._diffuseTexture.isReady()) {
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
defines._needUVs = true;
|
|
207
|
+
defines.DIFFUSE = true;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
145
210
|
}
|
|
146
211
|
}
|
|
212
|
+
// Misc.
|
|
213
|
+
PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this.needAlphaTestingForMesh(mesh), defines, undefined, undefined, undefined, this._isVertexOutputInvariant);
|
|
214
|
+
// Lights
|
|
215
|
+
defines._needNormals = true;
|
|
216
|
+
PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
|
|
217
|
+
// Values that need to be evaluated on every frame
|
|
218
|
+
PrepareDefinesForFrameBoundValues(scene, engine, this, defines, useInstances ? true : false);
|
|
219
|
+
// Attribs
|
|
220
|
+
PrepareDefinesForAttributes(mesh, defines, true, true);
|
|
221
|
+
// Get correct effect
|
|
222
|
+
if (defines.isDirty) {
|
|
223
|
+
defines.markAsProcessed();
|
|
224
|
+
scene.resetCachedMaterial();
|
|
225
|
+
// Fallbacks
|
|
226
|
+
const fallbacks = new EffectFallbacks();
|
|
227
|
+
if (defines.FOG) {
|
|
228
|
+
fallbacks.addFallback(1, "FOG");
|
|
229
|
+
}
|
|
230
|
+
HandleFallbacksForShadows(defines, fallbacks);
|
|
231
|
+
if (defines.NUM_BONE_INFLUENCERS > 0) {
|
|
232
|
+
fallbacks.addCPUSkinningFallback(0, mesh);
|
|
233
|
+
}
|
|
234
|
+
defines.IMAGEPROCESSINGPOSTPROCESS = scene.imageProcessingConfiguration.applyByPostProcess;
|
|
235
|
+
//Attributes
|
|
236
|
+
const attribs = [VertexBuffer.PositionKind];
|
|
237
|
+
if (defines.NORMAL) {
|
|
238
|
+
attribs.push(VertexBuffer.NormalKind);
|
|
239
|
+
}
|
|
240
|
+
if (defines.UV1) {
|
|
241
|
+
attribs.push(VertexBuffer.UVKind);
|
|
242
|
+
}
|
|
243
|
+
if (defines.UV2) {
|
|
244
|
+
attribs.push(VertexBuffer.UV2Kind);
|
|
245
|
+
}
|
|
246
|
+
if (defines.VERTEXCOLOR) {
|
|
247
|
+
attribs.push(VertexBuffer.ColorKind);
|
|
248
|
+
}
|
|
249
|
+
PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
|
|
250
|
+
PrepareAttributesForInstances(attribs, defines);
|
|
251
|
+
// Legacy browser patch
|
|
252
|
+
const shaderName = "lava";
|
|
253
|
+
const join = defines.toString();
|
|
254
|
+
const uniforms = [
|
|
255
|
+
"world",
|
|
256
|
+
"view",
|
|
257
|
+
"viewProjection",
|
|
258
|
+
"vEyePosition",
|
|
259
|
+
"vLightsType",
|
|
260
|
+
"vDiffuseColor",
|
|
261
|
+
"vFogInfos",
|
|
262
|
+
"vFogColor",
|
|
263
|
+
"pointSize",
|
|
264
|
+
"vDiffuseInfos",
|
|
265
|
+
"mBones",
|
|
266
|
+
"diffuseMatrix",
|
|
267
|
+
"logarithmicDepthConstant",
|
|
268
|
+
"time",
|
|
269
|
+
"speed",
|
|
270
|
+
"movingSpeed",
|
|
271
|
+
"fogColor",
|
|
272
|
+
"fogDensity",
|
|
273
|
+
"lowFrequencySpeed",
|
|
274
|
+
];
|
|
275
|
+
AddClipPlaneUniforms(uniforms);
|
|
276
|
+
const samplers = ["diffuseSampler", "noiseTexture", "areaLightsLTC1Sampler", "areaLightsLTC2Sampler"];
|
|
277
|
+
const uniformBuffers = [];
|
|
278
|
+
PrepareUniformsAndSamplersList({
|
|
279
|
+
uniformsNames: uniforms,
|
|
280
|
+
uniformBuffersNames: uniformBuffers,
|
|
281
|
+
samplers: samplers,
|
|
282
|
+
defines: defines,
|
|
283
|
+
maxSimultaneousLights: this.maxSimultaneousLights,
|
|
284
|
+
shaderLanguage: this._shaderLanguage,
|
|
285
|
+
});
|
|
286
|
+
subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
|
|
287
|
+
attributes: attribs,
|
|
288
|
+
uniformsNames: uniforms,
|
|
289
|
+
uniformBuffersNames: uniformBuffers,
|
|
290
|
+
samplers: samplers,
|
|
291
|
+
defines: join,
|
|
292
|
+
fallbacks: fallbacks,
|
|
293
|
+
onCompiled: this.onCompiled,
|
|
294
|
+
onError: this.onError,
|
|
295
|
+
indexParameters: { maxSimultaneousLights: this.maxSimultaneousLights },
|
|
296
|
+
shaderLanguage: this._shaderLanguage,
|
|
297
|
+
extraInitializationsAsync: this._shadersLoaded
|
|
298
|
+
? undefined
|
|
299
|
+
: async () => {
|
|
300
|
+
if (this.shaderLanguage === 1 /* ShaderLanguage.WGSL */) {
|
|
301
|
+
await Promise.all([import("./wgsl/lava.vertex.js"), import("./wgsl/lava.fragment.js")]);
|
|
302
|
+
}
|
|
303
|
+
else {
|
|
304
|
+
await Promise.all([import("./lava.vertex.js"), import("./lava.fragment.js")]);
|
|
305
|
+
}
|
|
306
|
+
this._shadersLoaded = true;
|
|
307
|
+
},
|
|
308
|
+
}, engine), defines, this._materialContext);
|
|
309
|
+
}
|
|
310
|
+
// Check if Area Lights have LTC texture.
|
|
311
|
+
if (defines["AREALIGHTUSED"]) {
|
|
312
|
+
for (let index = 0; index < mesh.lightSources.length; index++) {
|
|
313
|
+
if (!mesh.lightSources[index]._isReady()) {
|
|
314
|
+
return false;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
if (!subMesh.effect || !subMesh.effect.isReady()) {
|
|
319
|
+
return false;
|
|
320
|
+
}
|
|
321
|
+
defines._renderId = scene.getRenderId();
|
|
322
|
+
drawWrapper._wasPreviouslyReady = true;
|
|
323
|
+
drawWrapper._wasPreviouslyUsingInstances = !!useInstances;
|
|
324
|
+
return true;
|
|
147
325
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
326
|
+
bindForSubMesh(world, mesh, subMesh) {
|
|
327
|
+
const scene = this.getScene();
|
|
328
|
+
const defines = subMesh.materialDefines;
|
|
329
|
+
if (!defines) {
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
const effect = subMesh.effect;
|
|
333
|
+
if (!effect) {
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
this._activeEffect = effect;
|
|
337
|
+
defines.UNLIT = this._unlit;
|
|
338
|
+
// Matrices
|
|
339
|
+
this.bindOnlyWorldMatrix(world);
|
|
340
|
+
this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
|
|
341
|
+
// Bones
|
|
342
|
+
BindBonesParameters(mesh, this._activeEffect);
|
|
343
|
+
if (this._mustRebind(scene, effect, subMesh)) {
|
|
344
|
+
// Textures
|
|
345
|
+
if (this.diffuseTexture && MaterialFlags.DiffuseTextureEnabled) {
|
|
346
|
+
this._activeEffect.setTexture("diffuseSampler", this.diffuseTexture);
|
|
347
|
+
this._activeEffect.setFloat2("vDiffuseInfos", this.diffuseTexture.coordinatesIndex, this.diffuseTexture.level);
|
|
348
|
+
this._activeEffect.setMatrix("diffuseMatrix", this.diffuseTexture.getTextureMatrix());
|
|
349
|
+
}
|
|
350
|
+
if (this.noiseTexture) {
|
|
351
|
+
this._activeEffect.setTexture("noiseTexture", this.noiseTexture);
|
|
352
|
+
}
|
|
353
|
+
// Clip plane
|
|
354
|
+
BindClipPlane(effect, this, scene);
|
|
355
|
+
// Point size
|
|
356
|
+
if (this.pointsCloud) {
|
|
357
|
+
this._activeEffect.setFloat("pointSize", this.pointSize);
|
|
358
|
+
}
|
|
359
|
+
// Log. depth
|
|
360
|
+
if (this._useLogarithmicDepth) {
|
|
361
|
+
BindLogDepth(defines, effect, scene);
|
|
362
|
+
}
|
|
363
|
+
scene.bindEyePosition(effect);
|
|
364
|
+
}
|
|
365
|
+
this._activeEffect.setColor4("vDiffuseColor", this._scaledDiffuse, this.alpha * mesh.visibility);
|
|
366
|
+
if (scene.lightsEnabled && !this.disableLighting) {
|
|
367
|
+
BindLights(scene, mesh, this._activeEffect, defines);
|
|
368
|
+
}
|
|
369
|
+
// View
|
|
370
|
+
if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE) {
|
|
371
|
+
this._activeEffect.setMatrix("view", scene.getViewMatrix());
|
|
372
|
+
}
|
|
373
|
+
// Fog
|
|
374
|
+
BindFogParameters(scene, mesh, this._activeEffect);
|
|
375
|
+
this._lastTime += scene.getEngine().getDeltaTime();
|
|
376
|
+
this._activeEffect.setFloat("time", (this._lastTime * this.speed) / 1000);
|
|
377
|
+
if (!this.fogColor) {
|
|
378
|
+
this.fogColor = Color3.Black();
|
|
379
|
+
}
|
|
380
|
+
this._activeEffect.setColor3("fogColor", this.fogColor);
|
|
381
|
+
this._activeEffect.setFloat("fogDensity", this.fogDensity);
|
|
382
|
+
this._activeEffect.setFloat("lowFrequencySpeed", this.lowFrequencySpeed);
|
|
383
|
+
this._activeEffect.setFloat("movingSpeed", this.movingSpeed);
|
|
384
|
+
this._afterBind(mesh, this._activeEffect, subMesh);
|
|
176
385
|
}
|
|
177
|
-
|
|
178
|
-
|
|
386
|
+
getAnimatables() {
|
|
387
|
+
const results = [];
|
|
388
|
+
if (this.diffuseTexture && this.diffuseTexture.animations && this.diffuseTexture.animations.length > 0) {
|
|
389
|
+
results.push(this.diffuseTexture);
|
|
390
|
+
}
|
|
391
|
+
if (this.noiseTexture && this.noiseTexture.animations && this.noiseTexture.animations.length > 0) {
|
|
392
|
+
results.push(this.noiseTexture);
|
|
393
|
+
}
|
|
394
|
+
return results;
|
|
179
395
|
}
|
|
180
|
-
|
|
181
|
-
|
|
396
|
+
getActiveTextures() {
|
|
397
|
+
const activeTextures = super.getActiveTextures();
|
|
398
|
+
if (this._diffuseTexture) {
|
|
399
|
+
activeTextures.push(this._diffuseTexture);
|
|
400
|
+
}
|
|
401
|
+
return activeTextures;
|
|
182
402
|
}
|
|
183
|
-
|
|
184
|
-
|
|
403
|
+
hasTexture(texture) {
|
|
404
|
+
if (super.hasTexture(texture)) {
|
|
405
|
+
return true;
|
|
406
|
+
}
|
|
407
|
+
if (this.diffuseTexture === texture) {
|
|
408
|
+
return true;
|
|
409
|
+
}
|
|
410
|
+
return false;
|
|
185
411
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
const shaderName = "lava";
|
|
190
|
-
const join = defines.toString();
|
|
191
|
-
const uniforms = [
|
|
192
|
-
"world",
|
|
193
|
-
"view",
|
|
194
|
-
"viewProjection",
|
|
195
|
-
"vEyePosition",
|
|
196
|
-
"vLightsType",
|
|
197
|
-
"vDiffuseColor",
|
|
198
|
-
"vFogInfos",
|
|
199
|
-
"vFogColor",
|
|
200
|
-
"pointSize",
|
|
201
|
-
"vDiffuseInfos",
|
|
202
|
-
"mBones",
|
|
203
|
-
"diffuseMatrix",
|
|
204
|
-
"logarithmicDepthConstant",
|
|
205
|
-
"time",
|
|
206
|
-
"speed",
|
|
207
|
-
"movingSpeed",
|
|
208
|
-
"fogColor",
|
|
209
|
-
"fogDensity",
|
|
210
|
-
"lowFrequencySpeed",
|
|
211
|
-
];
|
|
212
|
-
AddClipPlaneUniforms(uniforms);
|
|
213
|
-
const samplers = ["diffuseSampler", "noiseTexture", "areaLightsLTC1Sampler", "areaLightsLTC2Sampler"];
|
|
214
|
-
const uniformBuffers = [];
|
|
215
|
-
PrepareUniformsAndSamplersList({
|
|
216
|
-
uniformsNames: uniforms,
|
|
217
|
-
uniformBuffersNames: uniformBuffers,
|
|
218
|
-
samplers: samplers,
|
|
219
|
-
defines: defines,
|
|
220
|
-
maxSimultaneousLights: this.maxSimultaneousLights,
|
|
221
|
-
shaderLanguage: this._shaderLanguage,
|
|
222
|
-
});
|
|
223
|
-
subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
|
|
224
|
-
attributes: attribs,
|
|
225
|
-
uniformsNames: uniforms,
|
|
226
|
-
uniformBuffersNames: uniformBuffers,
|
|
227
|
-
samplers: samplers,
|
|
228
|
-
defines: join,
|
|
229
|
-
fallbacks: fallbacks,
|
|
230
|
-
onCompiled: this.onCompiled,
|
|
231
|
-
onError: this.onError,
|
|
232
|
-
indexParameters: { maxSimultaneousLights: this.maxSimultaneousLights },
|
|
233
|
-
shaderLanguage: this._shaderLanguage,
|
|
234
|
-
extraInitializationsAsync: this._shadersLoaded
|
|
235
|
-
? undefined
|
|
236
|
-
: async () => {
|
|
237
|
-
if (this.shaderLanguage === 1 /* ShaderLanguage.WGSL */) {
|
|
238
|
-
await Promise.all([import("./wgsl/lava.vertex.js"), import("./wgsl/lava.fragment.js")]);
|
|
239
|
-
}
|
|
240
|
-
else {
|
|
241
|
-
await Promise.all([import("./lava.vertex.js"), import("./lava.fragment.js")]);
|
|
242
|
-
}
|
|
243
|
-
this._shadersLoaded = true;
|
|
244
|
-
},
|
|
245
|
-
}, engine), defines, this._materialContext);
|
|
246
|
-
}
|
|
247
|
-
// Check if Area Lights have LTC texture.
|
|
248
|
-
if (defines["AREALIGHTUSED"]) {
|
|
249
|
-
for (let index = 0; index < mesh.lightSources.length; index++) {
|
|
250
|
-
if (!mesh.lightSources[index]._isReady()) {
|
|
251
|
-
return false;
|
|
412
|
+
dispose(forceDisposeEffect) {
|
|
413
|
+
if (this.diffuseTexture) {
|
|
414
|
+
this.diffuseTexture.dispose();
|
|
252
415
|
}
|
|
416
|
+
if (this.noiseTexture) {
|
|
417
|
+
this.noiseTexture.dispose();
|
|
418
|
+
}
|
|
419
|
+
super.dispose(forceDisposeEffect);
|
|
253
420
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
return false;
|
|
257
|
-
}
|
|
258
|
-
defines._renderId = scene.getRenderId();
|
|
259
|
-
drawWrapper._wasPreviouslyReady = true;
|
|
260
|
-
drawWrapper._wasPreviouslyUsingInstances = !!useInstances;
|
|
261
|
-
return true;
|
|
262
|
-
}
|
|
263
|
-
bindForSubMesh(world, mesh, subMesh) {
|
|
264
|
-
const scene = this.getScene();
|
|
265
|
-
const defines = subMesh.materialDefines;
|
|
266
|
-
if (!defines) {
|
|
267
|
-
return;
|
|
268
|
-
}
|
|
269
|
-
const effect = subMesh.effect;
|
|
270
|
-
if (!effect) {
|
|
271
|
-
return;
|
|
272
|
-
}
|
|
273
|
-
this._activeEffect = effect;
|
|
274
|
-
defines.UNLIT = this._unlit;
|
|
275
|
-
// Matrices
|
|
276
|
-
this.bindOnlyWorldMatrix(world);
|
|
277
|
-
this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
|
|
278
|
-
// Bones
|
|
279
|
-
BindBonesParameters(mesh, this._activeEffect);
|
|
280
|
-
if (this._mustRebind(scene, effect, subMesh)) {
|
|
281
|
-
// Textures
|
|
282
|
-
if (this.diffuseTexture && MaterialFlags.DiffuseTextureEnabled) {
|
|
283
|
-
this._activeEffect.setTexture("diffuseSampler", this.diffuseTexture);
|
|
284
|
-
this._activeEffect.setFloat2("vDiffuseInfos", this.diffuseTexture.coordinatesIndex, this.diffuseTexture.level);
|
|
285
|
-
this._activeEffect.setMatrix("diffuseMatrix", this.diffuseTexture.getTextureMatrix());
|
|
421
|
+
clone(name) {
|
|
422
|
+
return SerializationHelper.Clone(() => new _a(name, this.getScene()), this);
|
|
286
423
|
}
|
|
287
|
-
|
|
288
|
-
|
|
424
|
+
serialize() {
|
|
425
|
+
const serializationObject = super.serialize();
|
|
426
|
+
serializationObject.customType = "BABYLON.LavaMaterial";
|
|
427
|
+
return serializationObject;
|
|
289
428
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
// Point size
|
|
293
|
-
if (this.pointsCloud) {
|
|
294
|
-
this._activeEffect.setFloat("pointSize", this.pointSize);
|
|
429
|
+
getClassName() {
|
|
430
|
+
return "LavaMaterial";
|
|
295
431
|
}
|
|
296
|
-
//
|
|
297
|
-
|
|
298
|
-
|
|
432
|
+
// Statics
|
|
433
|
+
static Parse(source, scene, rootUrl) {
|
|
434
|
+
return SerializationHelper.Parse(() => new _a(source.name, scene), source, scene, rootUrl);
|
|
299
435
|
}
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
return true;
|
|
343
|
-
}
|
|
344
|
-
if (this.diffuseTexture === texture) {
|
|
345
|
-
return true;
|
|
346
|
-
}
|
|
347
|
-
return false;
|
|
348
|
-
}
|
|
349
|
-
dispose(forceDisposeEffect) {
|
|
350
|
-
if (this.diffuseTexture) {
|
|
351
|
-
this.diffuseTexture.dispose();
|
|
352
|
-
}
|
|
353
|
-
if (this.noiseTexture) {
|
|
354
|
-
this.noiseTexture.dispose();
|
|
355
|
-
}
|
|
356
|
-
super.dispose(forceDisposeEffect);
|
|
357
|
-
}
|
|
358
|
-
clone(name) {
|
|
359
|
-
return SerializationHelper.Clone(() => new LavaMaterial(name, this.getScene()), this);
|
|
360
|
-
}
|
|
361
|
-
serialize() {
|
|
362
|
-
const serializationObject = super.serialize();
|
|
363
|
-
serializationObject.customType = "BABYLON.LavaMaterial";
|
|
364
|
-
return serializationObject;
|
|
365
|
-
}
|
|
366
|
-
getClassName() {
|
|
367
|
-
return "LavaMaterial";
|
|
368
|
-
}
|
|
369
|
-
// Statics
|
|
370
|
-
static Parse(source, scene, rootUrl) {
|
|
371
|
-
return SerializationHelper.Parse(() => new LavaMaterial(source.name, scene), source, scene, rootUrl);
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
__decorate([
|
|
375
|
-
serializeAsTexture("diffuseTexture")
|
|
376
|
-
], LavaMaterial.prototype, "_diffuseTexture", void 0);
|
|
377
|
-
__decorate([
|
|
378
|
-
expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
|
379
|
-
], LavaMaterial.prototype, "diffuseTexture", void 0);
|
|
380
|
-
__decorate([
|
|
381
|
-
serializeAsTexture()
|
|
382
|
-
], LavaMaterial.prototype, "noiseTexture", void 0);
|
|
383
|
-
__decorate([
|
|
384
|
-
serializeAsColor3()
|
|
385
|
-
], LavaMaterial.prototype, "fogColor", void 0);
|
|
386
|
-
__decorate([
|
|
387
|
-
serialize()
|
|
388
|
-
], LavaMaterial.prototype, "speed", void 0);
|
|
389
|
-
__decorate([
|
|
390
|
-
serialize()
|
|
391
|
-
], LavaMaterial.prototype, "movingSpeed", void 0);
|
|
392
|
-
__decorate([
|
|
393
|
-
serialize()
|
|
394
|
-
], LavaMaterial.prototype, "lowFrequencySpeed", void 0);
|
|
395
|
-
__decorate([
|
|
396
|
-
serialize()
|
|
397
|
-
], LavaMaterial.prototype, "fogDensity", void 0);
|
|
398
|
-
__decorate([
|
|
399
|
-
serializeAsColor3()
|
|
400
|
-
], LavaMaterial.prototype, "diffuseColor", void 0);
|
|
401
|
-
__decorate([
|
|
402
|
-
serialize("disableLighting")
|
|
403
|
-
], LavaMaterial.prototype, "_disableLighting", void 0);
|
|
404
|
-
__decorate([
|
|
405
|
-
expandToProperty("_markAllSubMeshesAsLightsDirty")
|
|
406
|
-
], LavaMaterial.prototype, "disableLighting", void 0);
|
|
407
|
-
__decorate([
|
|
408
|
-
serialize("unlit")
|
|
409
|
-
], LavaMaterial.prototype, "_unlit", void 0);
|
|
410
|
-
__decorate([
|
|
411
|
-
expandToProperty("_markAllSubMeshesAsLightsDirty")
|
|
412
|
-
], LavaMaterial.prototype, "unlit", void 0);
|
|
413
|
-
__decorate([
|
|
414
|
-
serialize("maxSimultaneousLights")
|
|
415
|
-
], LavaMaterial.prototype, "_maxSimultaneousLights", void 0);
|
|
416
|
-
__decorate([
|
|
417
|
-
expandToProperty("_markAllSubMeshesAsLightsDirty")
|
|
418
|
-
], LavaMaterial.prototype, "maxSimultaneousLights", void 0);
|
|
436
|
+
},
|
|
437
|
+
_LavaMaterial_diffuseTexture_accessor_storage = new WeakMap(),
|
|
438
|
+
_LavaMaterial_disableLighting_accessor_storage = new WeakMap(),
|
|
439
|
+
_LavaMaterial_unlit_accessor_storage = new WeakMap(),
|
|
440
|
+
_LavaMaterial_maxSimultaneousLights_accessor_storage = new WeakMap(),
|
|
441
|
+
(() => {
|
|
442
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
443
|
+
__diffuseTexture_decorators = [serializeAsTexture("diffuseTexture")];
|
|
444
|
+
_diffuseTexture_decorators = [expandToProperty("_markAllSubMeshesAsTexturesDirty")];
|
|
445
|
+
_noiseTexture_decorators = [serializeAsTexture()];
|
|
446
|
+
_fogColor_decorators = [serializeAsColor3()];
|
|
447
|
+
_speed_decorators = [serialize()];
|
|
448
|
+
_movingSpeed_decorators = [serialize()];
|
|
449
|
+
_lowFrequencySpeed_decorators = [serialize()];
|
|
450
|
+
_fogDensity_decorators = [serialize()];
|
|
451
|
+
_diffuseColor_decorators = [serializeAsColor3()];
|
|
452
|
+
__disableLighting_decorators = [serialize("disableLighting")];
|
|
453
|
+
_disableLighting_decorators = [expandToProperty("_markAllSubMeshesAsLightsDirty")];
|
|
454
|
+
__unlit_decorators = [serialize("unlit")];
|
|
455
|
+
_unlit_decorators = [expandToProperty("_markAllSubMeshesAsLightsDirty")];
|
|
456
|
+
__maxSimultaneousLights_decorators = [serialize("maxSimultaneousLights")];
|
|
457
|
+
_maxSimultaneousLights_decorators = [expandToProperty("_markAllSubMeshesAsLightsDirty")];
|
|
458
|
+
__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);
|
|
459
|
+
__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);
|
|
460
|
+
__esDecorate(_a, null, _unlit_decorators, { kind: "accessor", name: "unlit", static: false, private: false, access: { has: obj => "unlit" in obj, get: obj => obj.unlit, set: (obj, value) => { obj.unlit = value; } }, metadata: _metadata }, _unlit_initializers, _unlit_extraInitializers);
|
|
461
|
+
__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);
|
|
462
|
+
__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);
|
|
463
|
+
__esDecorate(null, null, _noiseTexture_decorators, { kind: "field", name: "noiseTexture", static: false, private: false, access: { has: obj => "noiseTexture" in obj, get: obj => obj.noiseTexture, set: (obj, value) => { obj.noiseTexture = value; } }, metadata: _metadata }, _noiseTexture_initializers, _noiseTexture_extraInitializers);
|
|
464
|
+
__esDecorate(null, null, _fogColor_decorators, { kind: "field", name: "fogColor", static: false, private: false, access: { has: obj => "fogColor" in obj, get: obj => obj.fogColor, set: (obj, value) => { obj.fogColor = value; } }, metadata: _metadata }, _fogColor_initializers, _fogColor_extraInitializers);
|
|
465
|
+
__esDecorate(null, null, _speed_decorators, { kind: "field", name: "speed", static: false, private: false, access: { has: obj => "speed" in obj, get: obj => obj.speed, set: (obj, value) => { obj.speed = value; } }, metadata: _metadata }, _speed_initializers, _speed_extraInitializers);
|
|
466
|
+
__esDecorate(null, null, _movingSpeed_decorators, { kind: "field", name: "movingSpeed", static: false, private: false, access: { has: obj => "movingSpeed" in obj, get: obj => obj.movingSpeed, set: (obj, value) => { obj.movingSpeed = value; } }, metadata: _metadata }, _movingSpeed_initializers, _movingSpeed_extraInitializers);
|
|
467
|
+
__esDecorate(null, null, _lowFrequencySpeed_decorators, { kind: "field", name: "lowFrequencySpeed", static: false, private: false, access: { has: obj => "lowFrequencySpeed" in obj, get: obj => obj.lowFrequencySpeed, set: (obj, value) => { obj.lowFrequencySpeed = value; } }, metadata: _metadata }, _lowFrequencySpeed_initializers, _lowFrequencySpeed_extraInitializers);
|
|
468
|
+
__esDecorate(null, null, _fogDensity_decorators, { kind: "field", name: "fogDensity", static: false, private: false, access: { has: obj => "fogDensity" in obj, get: obj => obj.fogDensity, set: (obj, value) => { obj.fogDensity = value; } }, metadata: _metadata }, _fogDensity_initializers, _fogDensity_extraInitializers);
|
|
469
|
+
__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);
|
|
470
|
+
__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);
|
|
471
|
+
__esDecorate(null, null, __unlit_decorators, { kind: "field", name: "_unlit", static: false, private: false, access: { has: obj => "_unlit" in obj, get: obj => obj._unlit, set: (obj, value) => { obj._unlit = value; } }, metadata: _metadata }, __unlit_initializers, __unlit_extraInitializers);
|
|
472
|
+
__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);
|
|
473
|
+
if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
474
|
+
})(),
|
|
475
|
+
_a;
|
|
476
|
+
})();
|
|
477
|
+
export { LavaMaterial };
|
|
419
478
|
RegisterClass("BABYLON.LavaMaterial", LavaMaterial);
|
|
420
479
|
//# sourceMappingURL=lavaMaterial.js.map
|