@babylonjs/materials 5.0.0-rc.0 → 5.0.0-rc.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cell/cell.fragment.d.ts +17 -17
- package/cell/cell.fragment.js +20 -18
- package/cell/cell.fragment.js.map +1 -1
- package/cell/cell.vertex.d.ts +18 -18
- package/cell/cell.vertex.js +21 -19
- package/cell/cell.vertex.js.map +1 -1
- package/cell/cellMaterial.d.ts +37 -37
- package/cell/cellMaterial.js +304 -290
- package/cell/cellMaterial.js.map +1 -1
- package/cell/index.d.ts +1 -1
- package/cell/index.js +1 -1
- package/cell/index.js.map +1 -1
- package/custom/customMaterial.d.ts +69 -69
- package/custom/customMaterial.js +216 -218
- package/custom/customMaterial.js.map +1 -1
- package/custom/index.d.ts +2 -2
- package/custom/index.js +2 -2
- package/custom/index.js.map +1 -1
- package/custom/pbrCustomMaterial.d.ts +71 -71
- package/custom/pbrCustomMaterial.js +241 -243
- package/custom/pbrCustomMaterial.js.map +1 -1
- package/fire/fire.fragment.d.ts +11 -11
- package/fire/fire.fragment.js +14 -12
- package/fire/fire.fragment.js.map +1 -1
- package/fire/fire.vertex.d.ts +15 -15
- package/fire/fire.vertex.js +18 -16
- package/fire/fire.vertex.js.map +1 -1
- package/fire/fireMaterial.d.ts +38 -38
- package/fire/fireMaterial.js +342 -327
- package/fire/fireMaterial.js.map +1 -1
- package/fire/index.d.ts +1 -1
- package/fire/index.js +1 -1
- package/fire/index.js.map +1 -1
- package/fur/fur.fragment.d.ts +17 -17
- package/fur/fur.fragment.js +20 -18
- package/fur/fur.fragment.js.map +1 -1
- package/fur/fur.vertex.d.ts +18 -18
- package/fur/fur.vertex.js +21 -19
- package/fur/fur.vertex.js.map +1 -1
- package/fur/furMaterial.d.ts +57 -56
- package/fur/furMaterial.js +500 -480
- package/fur/furMaterial.js.map +1 -1
- package/fur/index.d.ts +1 -1
- package/fur/index.js +1 -1
- package/fur/index.js.map +1 -1
- package/gradient/gradient.fragment.d.ts +17 -17
- package/gradient/gradient.fragment.js +20 -18
- package/gradient/gradient.fragment.js.map +1 -1
- package/gradient/gradient.vertex.d.ts +18 -18
- package/gradient/gradient.vertex.js +21 -19
- package/gradient/gradient.vertex.js.map +1 -1
- package/gradient/gradientMaterial.d.ts +37 -37
- package/gradient/gradientMaterial.js +275 -259
- package/gradient/gradientMaterial.js.map +1 -1
- package/gradient/index.d.ts +1 -1
- package/gradient/index.js +1 -1
- package/gradient/index.js.map +1 -1
- package/grid/grid.fragment.d.ts +8 -8
- package/grid/grid.fragment.js +11 -9
- package/grid/grid.fragment.js.map +1 -1
- package/grid/grid.vertex.d.ts +9 -9
- package/grid/grid.vertex.js +12 -10
- package/grid/grid.vertex.js.map +1 -1
- package/grid/gridMaterial.d.ts +78 -77
- package/grid/gridMaterial.js +276 -261
- package/grid/gridMaterial.js.map +1 -1
- package/grid/index.d.ts +1 -1
- package/grid/index.js +1 -1
- package/grid/index.js.map +1 -1
- package/index.d.ts +15 -15
- package/index.js +16 -15
- package/index.js.map +1 -1
- package/lava/index.d.ts +1 -1
- package/lava/index.js +1 -1
- package/lava/index.js.map +1 -1
- package/lava/lava.fragment.d.ts +17 -17
- package/lava/lava.fragment.js +20 -18
- package/lava/lava.fragment.js.map +1 -1
- package/lava/lava.vertex.d.ts +18 -18
- package/lava/lava.vertex.js +21 -19
- package/lava/lava.vertex.js.map +1 -1
- package/lava/lavaMaterial.d.ts +45 -45
- package/lava/lavaMaterial.js +394 -378
- package/lava/lavaMaterial.js.map +1 -1
- package/legacy/legacy-cell.d.ts +1 -1
- package/legacy/legacy-cell.js +13 -12
- package/legacy/legacy-cell.js.map +1 -1
- package/legacy/legacy-custom.d.ts +1 -1
- package/legacy/legacy-custom.js +13 -12
- package/legacy/legacy-custom.js.map +1 -1
- package/legacy/legacy-fire.d.ts +1 -1
- package/legacy/legacy-fire.js +13 -12
- package/legacy/legacy-fire.js.map +1 -1
- package/legacy/legacy-fur.d.ts +1 -1
- package/legacy/legacy-fur.js +13 -12
- package/legacy/legacy-fur.js.map +1 -1
- package/legacy/legacy-gradient.d.ts +1 -1
- package/legacy/legacy-gradient.js +13 -12
- package/legacy/legacy-gradient.js.map +1 -1
- package/legacy/legacy-grid.d.ts +1 -1
- package/legacy/legacy-grid.js +13 -12
- package/legacy/legacy-grid.js.map +1 -1
- package/legacy/legacy-lava.d.ts +1 -1
- package/legacy/legacy-lava.js +13 -12
- package/legacy/legacy-lava.js.map +1 -1
- package/legacy/legacy-mix.d.ts +1 -1
- package/legacy/legacy-mix.js +13 -12
- package/legacy/legacy-mix.js.map +1 -1
- package/legacy/legacy-normal.d.ts +1 -1
- package/legacy/legacy-normal.js +13 -12
- package/legacy/legacy-normal.js.map +1 -1
- package/legacy/legacy-shadowOnly.d.ts +1 -1
- package/legacy/legacy-shadowOnly.js +13 -12
- package/legacy/legacy-shadowOnly.js.map +1 -1
- package/legacy/legacy-simple.d.ts +1 -1
- package/legacy/legacy-simple.js +13 -12
- package/legacy/legacy-simple.js.map +1 -1
- package/legacy/legacy-sky.d.ts +1 -1
- package/legacy/legacy-sky.js +13 -12
- package/legacy/legacy-sky.js.map +1 -1
- package/legacy/legacy-terrain.d.ts +1 -1
- package/legacy/legacy-terrain.js +13 -12
- package/legacy/legacy-terrain.js.map +1 -1
- package/legacy/legacy-triPlanar.d.ts +1 -1
- package/legacy/legacy-triPlanar.js +13 -12
- package/legacy/legacy-triPlanar.js.map +1 -1
- package/legacy/legacy-water.d.ts +1 -1
- package/legacy/legacy-water.js +13 -12
- package/legacy/legacy-water.js.map +1 -1
- package/legacy/legacy.d.ts +1 -1
- package/legacy/legacy.js +16 -15
- package/legacy/legacy.js.map +1 -1
- package/mix/index.d.ts +1 -1
- package/mix/index.js +1 -1
- package/mix/index.js.map +1 -1
- package/mix/mix.fragment.d.ts +17 -17
- package/mix/mix.fragment.js +20 -18
- package/mix/mix.fragment.js.map +1 -1
- package/mix/mix.vertex.d.ts +18 -18
- package/mix/mix.vertex.js +21 -19
- package/mix/mix.vertex.js.map +1 -1
- package/mix/mixMaterial.d.ts +65 -65
- package/mix/mixMaterial.js +510 -483
- package/mix/mixMaterial.js.map +1 -1
- package/normal/index.d.ts +1 -1
- package/normal/index.js +1 -1
- package/normal/index.js.map +1 -1
- package/normal/normal.fragment.d.ts +17 -17
- package/normal/normal.fragment.js +20 -18
- package/normal/normal.fragment.js.map +1 -1
- package/normal/normal.vertex.d.ts +18 -18
- package/normal/normal.vertex.js +21 -19
- package/normal/normal.vertex.js.map +1 -1
- package/normal/normalMaterial.d.ts +36 -36
- package/normal/normalMaterial.js +336 -322
- package/normal/normalMaterial.js.map +1 -1
- package/package.json +22 -254
- package/readme.md +2 -2
- package/shadowOnly/index.d.ts +1 -1
- package/shadowOnly/index.js +1 -1
- package/shadowOnly/index.js.map +1 -1
- package/shadowOnly/shadowOnly.fragment.d.ts +16 -16
- package/shadowOnly/shadowOnly.fragment.js +19 -17
- package/shadowOnly/shadowOnly.fragment.js.map +1 -1
- package/shadowOnly/shadowOnly.vertex.d.ts +18 -18
- package/shadowOnly/shadowOnly.vertex.js +21 -19
- package/shadowOnly/shadowOnly.vertex.js.map +1 -1
- package/shadowOnly/shadowOnlyMaterial.d.ts +30 -30
- package/shadowOnly/shadowOnlyMaterial.js +254 -240
- package/shadowOnly/shadowOnlyMaterial.js.map +1 -1
- package/simple/index.d.ts +1 -1
- package/simple/index.js +1 -1
- package/simple/index.js.map +1 -1
- package/simple/simple.fragment.d.ts +17 -17
- package/simple/simple.fragment.js +20 -18
- package/simple/simple.fragment.js.map +1 -1
- package/simple/simple.vertex.d.ts +18 -18
- package/simple/simple.vertex.js +21 -19
- package/simple/simple.vertex.js.map +1 -1
- package/simple/simpleMaterial.d.ts +35 -35
- package/simple/simpleMaterial.js +295 -281
- package/simple/simpleMaterial.js.map +1 -1
- package/sky/index.d.ts +1 -1
- package/sky/index.js +1 -1
- package/sky/index.js.map +1 -1
- package/sky/sky.fragment.d.ts +10 -10
- package/sky/sky.fragment.js +13 -11
- package/sky/sky.fragment.js.map +1 -1
- package/sky/sky.vertex.d.ts +9 -9
- package/sky/sky.vertex.js +12 -10
- package/sky/sky.vertex.js.map +1 -1
- package/sky/skyMaterial.d.ts +147 -147
- package/sky/skyMaterial.js +359 -340
- package/sky/skyMaterial.js.map +1 -1
- package/terrain/index.d.ts +1 -1
- package/terrain/index.js +1 -1
- package/terrain/index.js.map +1 -1
- package/terrain/terrain.fragment.d.ts +17 -17
- package/terrain/terrain.fragment.js +20 -18
- package/terrain/terrain.fragment.js.map +1 -1
- package/terrain/terrain.vertex.d.ts +18 -18
- package/terrain/terrain.vertex.js +21 -19
- package/terrain/terrain.vertex.js.map +1 -1
- package/terrain/terrainMaterial.d.ts +50 -50
- package/terrain/terrainMaterial.js +426 -411
- package/terrain/terrainMaterial.js.map +1 -1
- package/triPlanar/index.d.ts +1 -1
- package/triPlanar/index.js +1 -1
- package/triPlanar/index.js.map +1 -1
- package/triPlanar/triPlanarMaterial.d.ts +49 -49
- package/triPlanar/triPlanarMaterial.js +403 -391
- package/triPlanar/triPlanarMaterial.js.map +1 -1
- package/triPlanar/triplanar.fragment.d.ts +17 -17
- package/triPlanar/triplanar.fragment.js +20 -18
- package/triPlanar/triplanar.fragment.js.map +1 -1
- package/triPlanar/triplanar.vertex.d.ts +18 -18
- package/triPlanar/triplanar.vertex.js +21 -19
- package/triPlanar/triplanar.vertex.js.map +1 -1
- package/water/index.d.ts +1 -1
- package/water/index.js +1 -1
- package/water/index.js.map +1 -1
- package/water/water.fragment.d.ts +19 -19
- package/water/water.fragment.js +22 -20
- package/water/water.fragment.js.map +1 -1
- package/water/water.vertex.d.ts +20 -20
- package/water/water.vertex.js +23 -21
- package/water/water.vertex.js.map +1 -1
- package/water/waterMaterial.d.ts +135 -132
- package/water/waterMaterial.js +736 -705
- package/water/waterMaterial.js.map +1 -1
package/lava/lavaMaterial.js
CHANGED
@@ -1,379 +1,395 @@
|
|
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
|
11
|
-
import "./lava.fragment
|
12
|
-
import "./lava.vertex
|
13
|
-
import { EffectFallbacks } from
|
14
|
-
var LavaMaterialDefines = /** @class */ (function (_super) {
|
15
|
-
__extends(LavaMaterialDefines, _super);
|
16
|
-
function LavaMaterialDefines() {
|
17
|
-
var _this = _super.call(this) || this;
|
18
|
-
_this.DIFFUSE = false;
|
19
|
-
_this.CLIPPLANE = false;
|
20
|
-
_this.CLIPPLANE2 = false;
|
21
|
-
_this.CLIPPLANE3 = false;
|
22
|
-
_this.CLIPPLANE4 = false;
|
23
|
-
_this.CLIPPLANE5 = false;
|
24
|
-
_this.CLIPPLANE6 = false;
|
25
|
-
_this.ALPHATEST = false;
|
26
|
-
_this.DEPTHPREPASS = false;
|
27
|
-
_this.POINTSIZE = false;
|
28
|
-
_this.FOG = false;
|
29
|
-
_this.LIGHT0 = false;
|
30
|
-
_this.LIGHT1 = false;
|
31
|
-
_this.LIGHT2 = false;
|
32
|
-
_this.LIGHT3 = false;
|
33
|
-
_this.SPOTLIGHT0 = false;
|
34
|
-
_this.SPOTLIGHT1 = false;
|
35
|
-
_this.SPOTLIGHT2 = false;
|
36
|
-
_this.SPOTLIGHT3 = false;
|
37
|
-
_this.HEMILIGHT0 = false;
|
38
|
-
_this.HEMILIGHT1 = false;
|
39
|
-
_this.HEMILIGHT2 = false;
|
40
|
-
_this.HEMILIGHT3 = false;
|
41
|
-
_this.DIRLIGHT0 = false;
|
42
|
-
_this.DIRLIGHT1 = false;
|
43
|
-
_this.DIRLIGHT2 = false;
|
44
|
-
_this.DIRLIGHT3 = false;
|
45
|
-
_this.POINTLIGHT0 = false;
|
46
|
-
_this.POINTLIGHT1 = false;
|
47
|
-
_this.POINTLIGHT2 = false;
|
48
|
-
_this.POINTLIGHT3 = false;
|
49
|
-
_this.SHADOW0 = false;
|
50
|
-
_this.SHADOW1 = false;
|
51
|
-
_this.SHADOW2 = false;
|
52
|
-
_this.SHADOW3 = false;
|
53
|
-
_this.SHADOWS = false;
|
54
|
-
_this.SHADOWESM0 = false;
|
55
|
-
_this.SHADOWESM1 = false;
|
56
|
-
_this.SHADOWESM2 = false;
|
57
|
-
_this.SHADOWESM3 = false;
|
58
|
-
_this.SHADOWPOISSON0 = false;
|
59
|
-
_this.SHADOWPOISSON1 = false;
|
60
|
-
_this.SHADOWPOISSON2 = false;
|
61
|
-
_this.SHADOWPOISSON3 = false;
|
62
|
-
_this.SHADOWPCF0 = false;
|
63
|
-
_this.SHADOWPCF1 = false;
|
64
|
-
_this.SHADOWPCF2 = false;
|
65
|
-
_this.SHADOWPCF3 = false;
|
66
|
-
_this.SHADOWPCSS0 = false;
|
67
|
-
_this.SHADOWPCSS1 = false;
|
68
|
-
_this.SHADOWPCSS2 = false;
|
69
|
-
_this.SHADOWPCSS3 = false;
|
70
|
-
_this.NORMAL = false;
|
71
|
-
_this.UV1 = false;
|
72
|
-
_this.UV2 = false;
|
73
|
-
_this.VERTEXCOLOR = false;
|
74
|
-
_this.VERTEXALPHA = false;
|
75
|
-
_this.NUM_BONE_INFLUENCERS = 0;
|
76
|
-
_this.BonesPerMesh = 0;
|
77
|
-
_this.INSTANCES = false;
|
78
|
-
_this.INSTANCESCOLOR = false;
|
79
|
-
_this.UNLIT = false;
|
80
|
-
_this.IMAGEPROCESSINGPOSTPROCESS = false;
|
81
|
-
_this.SKIPFINALCOLORCLAMP = false;
|
82
|
-
_this.rebuild();
|
83
|
-
return _this;
|
84
|
-
}
|
85
|
-
return LavaMaterialDefines;
|
86
|
-
}(MaterialDefines));
|
87
|
-
var LavaMaterial = /** @class */ (function (_super) {
|
88
|
-
__extends(LavaMaterial, _super);
|
89
|
-
function LavaMaterial(name, scene) {
|
90
|
-
var _this = _super.call(this, name, scene) || this;
|
91
|
-
_this.speed = 1;
|
92
|
-
_this.movingSpeed = 1;
|
93
|
-
_this.lowFrequencySpeed = 1;
|
94
|
-
_this.fogDensity = 0.15;
|
95
|
-
_this._lastTime = 0;
|
96
|
-
_this.diffuseColor = new Color3(1, 1, 1);
|
97
|
-
_this._disableLighting = false;
|
98
|
-
_this._unlit = false;
|
99
|
-
_this._maxSimultaneousLights = 4;
|
100
|
-
_this._scaledDiffuse = new Color3();
|
101
|
-
return _this;
|
102
|
-
}
|
103
|
-
LavaMaterial.prototype.needAlphaBlending = function () {
|
104
|
-
return
|
105
|
-
};
|
106
|
-
LavaMaterial.prototype.needAlphaTesting = function () {
|
107
|
-
return false;
|
108
|
-
};
|
109
|
-
LavaMaterial.prototype.getAlphaTestTexture = function () {
|
110
|
-
return null;
|
111
|
-
};
|
112
|
-
// Methods
|
113
|
-
LavaMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
|
114
|
-
if (this.isFrozen) {
|
115
|
-
if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
|
116
|
-
return true;
|
117
|
-
}
|
118
|
-
}
|
119
|
-
if (!subMesh.materialDefines) {
|
120
|
-
subMesh.materialDefines = new LavaMaterialDefines();
|
121
|
-
}
|
122
|
-
var defines = subMesh.materialDefines;
|
123
|
-
var scene = this.getScene();
|
124
|
-
if (this._isReadyForSubMesh(subMesh)) {
|
125
|
-
return true;
|
126
|
-
}
|
127
|
-
var engine = scene.getEngine();
|
128
|
-
// Textures
|
129
|
-
if (defines._areTexturesDirty) {
|
130
|
-
defines._needUVs = false;
|
131
|
-
if (scene.texturesEnabled) {
|
132
|
-
if (this._diffuseTexture && MaterialFlags.DiffuseTextureEnabled) {
|
133
|
-
if (!this._diffuseTexture.isReady()) {
|
134
|
-
return false;
|
135
|
-
}
|
136
|
-
else {
|
137
|
-
defines._needUVs = true;
|
138
|
-
defines.DIFFUSE = true;
|
139
|
-
}
|
140
|
-
}
|
141
|
-
}
|
142
|
-
}
|
143
|
-
// Misc.
|
144
|
-
MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
|
145
|
-
// Lights
|
146
|
-
defines._needNormals = true;
|
147
|
-
MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
|
148
|
-
// Values that need to be evaluated on every frame
|
149
|
-
MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
|
150
|
-
// Attribs
|
151
|
-
MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true);
|
152
|
-
// Get correct effect
|
153
|
-
if (defines.isDirty) {
|
154
|
-
defines.markAsProcessed();
|
155
|
-
scene.resetCachedMaterial();
|
156
|
-
// Fallbacks
|
157
|
-
var fallbacks = new EffectFallbacks();
|
158
|
-
if (defines.FOG) {
|
159
|
-
fallbacks.addFallback(1, "FOG");
|
160
|
-
}
|
161
|
-
MaterialHelper.HandleFallbacksForShadows(defines, fallbacks);
|
162
|
-
if (defines.NUM_BONE_INFLUENCERS > 0) {
|
163
|
-
fallbacks.addCPUSkinningFallback(0, mesh);
|
164
|
-
}
|
165
|
-
defines.IMAGEPROCESSINGPOSTPROCESS = scene.imageProcessingConfiguration.applyByPostProcess;
|
166
|
-
//Attributes
|
167
|
-
var attribs = [VertexBuffer.PositionKind];
|
168
|
-
if (defines.NORMAL) {
|
169
|
-
attribs.push(VertexBuffer.NormalKind);
|
170
|
-
}
|
171
|
-
if (defines.UV1) {
|
172
|
-
attribs.push(VertexBuffer.UVKind);
|
173
|
-
}
|
174
|
-
if (defines.UV2) {
|
175
|
-
attribs.push(VertexBuffer.UV2Kind);
|
176
|
-
}
|
177
|
-
if (defines.VERTEXCOLOR) {
|
178
|
-
attribs.push(VertexBuffer.ColorKind);
|
179
|
-
}
|
180
|
-
MaterialHelper.PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
|
181
|
-
MaterialHelper.PrepareAttributesForInstances(attribs, defines);
|
182
|
-
// Legacy browser patch
|
183
|
-
var shaderName = "lava";
|
184
|
-
var join = defines.toString();
|
185
|
-
var uniforms = [
|
186
|
-
"
|
187
|
-
"
|
188
|
-
"
|
189
|
-
"
|
190
|
-
"
|
191
|
-
"
|
192
|
-
|
193
|
-
|
194
|
-
"
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
this._activeEffect.
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
if (
|
298
|
-
|
299
|
-
}
|
300
|
-
if (this.
|
301
|
-
|
302
|
-
}
|
303
|
-
return
|
304
|
-
};
|
305
|
-
LavaMaterial.prototype.
|
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
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
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 "./lava.fragment";
|
12
|
+
import "./lava.vertex";
|
13
|
+
import { EffectFallbacks } from "@babylonjs/core/Materials/effectFallbacks.js";
|
14
|
+
var LavaMaterialDefines = /** @class */ (function (_super) {
|
15
|
+
__extends(LavaMaterialDefines, _super);
|
16
|
+
function LavaMaterialDefines() {
|
17
|
+
var _this = _super.call(this) || this;
|
18
|
+
_this.DIFFUSE = false;
|
19
|
+
_this.CLIPPLANE = false;
|
20
|
+
_this.CLIPPLANE2 = false;
|
21
|
+
_this.CLIPPLANE3 = false;
|
22
|
+
_this.CLIPPLANE4 = false;
|
23
|
+
_this.CLIPPLANE5 = false;
|
24
|
+
_this.CLIPPLANE6 = false;
|
25
|
+
_this.ALPHATEST = false;
|
26
|
+
_this.DEPTHPREPASS = false;
|
27
|
+
_this.POINTSIZE = false;
|
28
|
+
_this.FOG = false;
|
29
|
+
_this.LIGHT0 = false;
|
30
|
+
_this.LIGHT1 = false;
|
31
|
+
_this.LIGHT2 = false;
|
32
|
+
_this.LIGHT3 = false;
|
33
|
+
_this.SPOTLIGHT0 = false;
|
34
|
+
_this.SPOTLIGHT1 = false;
|
35
|
+
_this.SPOTLIGHT2 = false;
|
36
|
+
_this.SPOTLIGHT3 = false;
|
37
|
+
_this.HEMILIGHT0 = false;
|
38
|
+
_this.HEMILIGHT1 = false;
|
39
|
+
_this.HEMILIGHT2 = false;
|
40
|
+
_this.HEMILIGHT3 = false;
|
41
|
+
_this.DIRLIGHT0 = false;
|
42
|
+
_this.DIRLIGHT1 = false;
|
43
|
+
_this.DIRLIGHT2 = false;
|
44
|
+
_this.DIRLIGHT3 = false;
|
45
|
+
_this.POINTLIGHT0 = false;
|
46
|
+
_this.POINTLIGHT1 = false;
|
47
|
+
_this.POINTLIGHT2 = false;
|
48
|
+
_this.POINTLIGHT3 = false;
|
49
|
+
_this.SHADOW0 = false;
|
50
|
+
_this.SHADOW1 = false;
|
51
|
+
_this.SHADOW2 = false;
|
52
|
+
_this.SHADOW3 = false;
|
53
|
+
_this.SHADOWS = false;
|
54
|
+
_this.SHADOWESM0 = false;
|
55
|
+
_this.SHADOWESM1 = false;
|
56
|
+
_this.SHADOWESM2 = false;
|
57
|
+
_this.SHADOWESM3 = false;
|
58
|
+
_this.SHADOWPOISSON0 = false;
|
59
|
+
_this.SHADOWPOISSON1 = false;
|
60
|
+
_this.SHADOWPOISSON2 = false;
|
61
|
+
_this.SHADOWPOISSON3 = false;
|
62
|
+
_this.SHADOWPCF0 = false;
|
63
|
+
_this.SHADOWPCF1 = false;
|
64
|
+
_this.SHADOWPCF2 = false;
|
65
|
+
_this.SHADOWPCF3 = false;
|
66
|
+
_this.SHADOWPCSS0 = false;
|
67
|
+
_this.SHADOWPCSS1 = false;
|
68
|
+
_this.SHADOWPCSS2 = false;
|
69
|
+
_this.SHADOWPCSS3 = false;
|
70
|
+
_this.NORMAL = false;
|
71
|
+
_this.UV1 = false;
|
72
|
+
_this.UV2 = false;
|
73
|
+
_this.VERTEXCOLOR = false;
|
74
|
+
_this.VERTEXALPHA = false;
|
75
|
+
_this.NUM_BONE_INFLUENCERS = 0;
|
76
|
+
_this.BonesPerMesh = 0;
|
77
|
+
_this.INSTANCES = false;
|
78
|
+
_this.INSTANCESCOLOR = false;
|
79
|
+
_this.UNLIT = false;
|
80
|
+
_this.IMAGEPROCESSINGPOSTPROCESS = false;
|
81
|
+
_this.SKIPFINALCOLORCLAMP = false;
|
82
|
+
_this.rebuild();
|
83
|
+
return _this;
|
84
|
+
}
|
85
|
+
return LavaMaterialDefines;
|
86
|
+
}(MaterialDefines));
|
87
|
+
var LavaMaterial = /** @class */ (function (_super) {
|
88
|
+
__extends(LavaMaterial, _super);
|
89
|
+
function LavaMaterial(name, scene) {
|
90
|
+
var _this = _super.call(this, name, scene) || this;
|
91
|
+
_this.speed = 1;
|
92
|
+
_this.movingSpeed = 1;
|
93
|
+
_this.lowFrequencySpeed = 1;
|
94
|
+
_this.fogDensity = 0.15;
|
95
|
+
_this._lastTime = 0;
|
96
|
+
_this.diffuseColor = new Color3(1, 1, 1);
|
97
|
+
_this._disableLighting = false;
|
98
|
+
_this._unlit = false;
|
99
|
+
_this._maxSimultaneousLights = 4;
|
100
|
+
_this._scaledDiffuse = new Color3();
|
101
|
+
return _this;
|
102
|
+
}
|
103
|
+
LavaMaterial.prototype.needAlphaBlending = function () {
|
104
|
+
return this.alpha < 1.0;
|
105
|
+
};
|
106
|
+
LavaMaterial.prototype.needAlphaTesting = function () {
|
107
|
+
return false;
|
108
|
+
};
|
109
|
+
LavaMaterial.prototype.getAlphaTestTexture = function () {
|
110
|
+
return null;
|
111
|
+
};
|
112
|
+
// Methods
|
113
|
+
LavaMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
|
114
|
+
if (this.isFrozen) {
|
115
|
+
if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
|
116
|
+
return true;
|
117
|
+
}
|
118
|
+
}
|
119
|
+
if (!subMesh.materialDefines) {
|
120
|
+
subMesh.materialDefines = new LavaMaterialDefines();
|
121
|
+
}
|
122
|
+
var defines = subMesh.materialDefines;
|
123
|
+
var scene = this.getScene();
|
124
|
+
if (this._isReadyForSubMesh(subMesh)) {
|
125
|
+
return true;
|
126
|
+
}
|
127
|
+
var engine = scene.getEngine();
|
128
|
+
// Textures
|
129
|
+
if (defines._areTexturesDirty) {
|
130
|
+
defines._needUVs = false;
|
131
|
+
if (scene.texturesEnabled) {
|
132
|
+
if (this._diffuseTexture && MaterialFlags.DiffuseTextureEnabled) {
|
133
|
+
if (!this._diffuseTexture.isReady()) {
|
134
|
+
return false;
|
135
|
+
}
|
136
|
+
else {
|
137
|
+
defines._needUVs = true;
|
138
|
+
defines.DIFFUSE = true;
|
139
|
+
}
|
140
|
+
}
|
141
|
+
}
|
142
|
+
}
|
143
|
+
// Misc.
|
144
|
+
MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
|
145
|
+
// Lights
|
146
|
+
defines._needNormals = true;
|
147
|
+
MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
|
148
|
+
// Values that need to be evaluated on every frame
|
149
|
+
MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
|
150
|
+
// Attribs
|
151
|
+
MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true);
|
152
|
+
// Get correct effect
|
153
|
+
if (defines.isDirty) {
|
154
|
+
defines.markAsProcessed();
|
155
|
+
scene.resetCachedMaterial();
|
156
|
+
// Fallbacks
|
157
|
+
var fallbacks = new EffectFallbacks();
|
158
|
+
if (defines.FOG) {
|
159
|
+
fallbacks.addFallback(1, "FOG");
|
160
|
+
}
|
161
|
+
MaterialHelper.HandleFallbacksForShadows(defines, fallbacks);
|
162
|
+
if (defines.NUM_BONE_INFLUENCERS > 0) {
|
163
|
+
fallbacks.addCPUSkinningFallback(0, mesh);
|
164
|
+
}
|
165
|
+
defines.IMAGEPROCESSINGPOSTPROCESS = scene.imageProcessingConfiguration.applyByPostProcess;
|
166
|
+
//Attributes
|
167
|
+
var attribs = [VertexBuffer.PositionKind];
|
168
|
+
if (defines.NORMAL) {
|
169
|
+
attribs.push(VertexBuffer.NormalKind);
|
170
|
+
}
|
171
|
+
if (defines.UV1) {
|
172
|
+
attribs.push(VertexBuffer.UVKind);
|
173
|
+
}
|
174
|
+
if (defines.UV2) {
|
175
|
+
attribs.push(VertexBuffer.UV2Kind);
|
176
|
+
}
|
177
|
+
if (defines.VERTEXCOLOR) {
|
178
|
+
attribs.push(VertexBuffer.ColorKind);
|
179
|
+
}
|
180
|
+
MaterialHelper.PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
|
181
|
+
MaterialHelper.PrepareAttributesForInstances(attribs, defines);
|
182
|
+
// Legacy browser patch
|
183
|
+
var shaderName = "lava";
|
184
|
+
var join = defines.toString();
|
185
|
+
var uniforms = [
|
186
|
+
"world",
|
187
|
+
"view",
|
188
|
+
"viewProjection",
|
189
|
+
"vEyePosition",
|
190
|
+
"vLightsType",
|
191
|
+
"vDiffuseColor",
|
192
|
+
"vFogInfos",
|
193
|
+
"vFogColor",
|
194
|
+
"pointSize",
|
195
|
+
"vDiffuseInfos",
|
196
|
+
"mBones",
|
197
|
+
"vClipPlane",
|
198
|
+
"vClipPlane2",
|
199
|
+
"vClipPlane3",
|
200
|
+
"vClipPlane4",
|
201
|
+
"vClipPlane5",
|
202
|
+
"vClipPlane6",
|
203
|
+
"diffuseMatrix",
|
204
|
+
"time",
|
205
|
+
"speed",
|
206
|
+
"movingSpeed",
|
207
|
+
"fogColor",
|
208
|
+
"fogDensity",
|
209
|
+
"lowFrequencySpeed",
|
210
|
+
];
|
211
|
+
var samplers = ["diffuseSampler", "noiseTexture"];
|
212
|
+
var uniformBuffers = new Array();
|
213
|
+
MaterialHelper.PrepareUniformsAndSamplersList({
|
214
|
+
uniformsNames: uniforms,
|
215
|
+
uniformBuffersNames: uniformBuffers,
|
216
|
+
samplers: samplers,
|
217
|
+
defines: defines,
|
218
|
+
maxSimultaneousLights: this.maxSimultaneousLights,
|
219
|
+
});
|
220
|
+
subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
|
221
|
+
attributes: attribs,
|
222
|
+
uniformsNames: uniforms,
|
223
|
+
uniformBuffersNames: uniformBuffers,
|
224
|
+
samplers: samplers,
|
225
|
+
defines: join,
|
226
|
+
fallbacks: fallbacks,
|
227
|
+
onCompiled: this.onCompiled,
|
228
|
+
onError: this.onError,
|
229
|
+
indexParameters: { maxSimultaneousLights: this.maxSimultaneousLights },
|
230
|
+
}, engine), defines, this._materialContext);
|
231
|
+
}
|
232
|
+
if (!subMesh.effect || !subMesh.effect.isReady()) {
|
233
|
+
return false;
|
234
|
+
}
|
235
|
+
defines._renderId = scene.getRenderId();
|
236
|
+
subMesh.effect._wasPreviouslyReady = true;
|
237
|
+
return true;
|
238
|
+
};
|
239
|
+
LavaMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
|
240
|
+
var scene = this.getScene();
|
241
|
+
var defines = subMesh.materialDefines;
|
242
|
+
if (!defines) {
|
243
|
+
return;
|
244
|
+
}
|
245
|
+
var effect = subMesh.effect;
|
246
|
+
if (!effect) {
|
247
|
+
return;
|
248
|
+
}
|
249
|
+
this._activeEffect = effect;
|
250
|
+
defines.UNLIT = this._unlit;
|
251
|
+
// Matrices
|
252
|
+
this.bindOnlyWorldMatrix(world);
|
253
|
+
this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
|
254
|
+
// Bones
|
255
|
+
MaterialHelper.BindBonesParameters(mesh, this._activeEffect);
|
256
|
+
if (this._mustRebind(scene, effect)) {
|
257
|
+
// Textures
|
258
|
+
if (this.diffuseTexture && MaterialFlags.DiffuseTextureEnabled) {
|
259
|
+
this._activeEffect.setTexture("diffuseSampler", this.diffuseTexture);
|
260
|
+
this._activeEffect.setFloat2("vDiffuseInfos", this.diffuseTexture.coordinatesIndex, this.diffuseTexture.level);
|
261
|
+
this._activeEffect.setMatrix("diffuseMatrix", this.diffuseTexture.getTextureMatrix());
|
262
|
+
}
|
263
|
+
if (this.noiseTexture) {
|
264
|
+
this._activeEffect.setTexture("noiseTexture", this.noiseTexture);
|
265
|
+
}
|
266
|
+
// Clip plane
|
267
|
+
MaterialHelper.BindClipPlane(this._activeEffect, scene);
|
268
|
+
// Point size
|
269
|
+
if (this.pointsCloud) {
|
270
|
+
this._activeEffect.setFloat("pointSize", this.pointSize);
|
271
|
+
}
|
272
|
+
scene.bindEyePosition(effect);
|
273
|
+
}
|
274
|
+
this._activeEffect.setColor4("vDiffuseColor", this._scaledDiffuse, this.alpha * mesh.visibility);
|
275
|
+
if (scene.lightsEnabled && !this.disableLighting) {
|
276
|
+
MaterialHelper.BindLights(scene, mesh, this._activeEffect, defines);
|
277
|
+
}
|
278
|
+
// View
|
279
|
+
if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE) {
|
280
|
+
this._activeEffect.setMatrix("view", scene.getViewMatrix());
|
281
|
+
}
|
282
|
+
// Fog
|
283
|
+
MaterialHelper.BindFogParameters(scene, mesh, this._activeEffect);
|
284
|
+
this._lastTime += scene.getEngine().getDeltaTime();
|
285
|
+
this._activeEffect.setFloat("time", (this._lastTime * this.speed) / 1000);
|
286
|
+
if (!this.fogColor) {
|
287
|
+
this.fogColor = Color3.Black();
|
288
|
+
}
|
289
|
+
this._activeEffect.setColor3("fogColor", this.fogColor);
|
290
|
+
this._activeEffect.setFloat("fogDensity", this.fogDensity);
|
291
|
+
this._activeEffect.setFloat("lowFrequencySpeed", this.lowFrequencySpeed);
|
292
|
+
this._activeEffect.setFloat("movingSpeed", this.movingSpeed);
|
293
|
+
this._afterBind(mesh, this._activeEffect);
|
294
|
+
};
|
295
|
+
LavaMaterial.prototype.getAnimatables = function () {
|
296
|
+
var results = [];
|
297
|
+
if (this.diffuseTexture && this.diffuseTexture.animations && this.diffuseTexture.animations.length > 0) {
|
298
|
+
results.push(this.diffuseTexture);
|
299
|
+
}
|
300
|
+
if (this.noiseTexture && this.noiseTexture.animations && this.noiseTexture.animations.length > 0) {
|
301
|
+
results.push(this.noiseTexture);
|
302
|
+
}
|
303
|
+
return results;
|
304
|
+
};
|
305
|
+
LavaMaterial.prototype.getActiveTextures = function () {
|
306
|
+
var activeTextures = _super.prototype.getActiveTextures.call(this);
|
307
|
+
if (this._diffuseTexture) {
|
308
|
+
activeTextures.push(this._diffuseTexture);
|
309
|
+
}
|
310
|
+
return activeTextures;
|
311
|
+
};
|
312
|
+
LavaMaterial.prototype.hasTexture = function (texture) {
|
313
|
+
if (_super.prototype.hasTexture.call(this, texture)) {
|
314
|
+
return true;
|
315
|
+
}
|
316
|
+
if (this.diffuseTexture === texture) {
|
317
|
+
return true;
|
318
|
+
}
|
319
|
+
return false;
|
320
|
+
};
|
321
|
+
LavaMaterial.prototype.dispose = function (forceDisposeEffect) {
|
322
|
+
if (this.diffuseTexture) {
|
323
|
+
this.diffuseTexture.dispose();
|
324
|
+
}
|
325
|
+
if (this.noiseTexture) {
|
326
|
+
this.noiseTexture.dispose();
|
327
|
+
}
|
328
|
+
_super.prototype.dispose.call(this, forceDisposeEffect);
|
329
|
+
};
|
330
|
+
LavaMaterial.prototype.clone = function (name) {
|
331
|
+
var _this = this;
|
332
|
+
return SerializationHelper.Clone(function () { return new LavaMaterial(name, _this.getScene()); }, this);
|
333
|
+
};
|
334
|
+
LavaMaterial.prototype.serialize = function () {
|
335
|
+
var serializationObject = _super.prototype.serialize.call(this);
|
336
|
+
serializationObject.customType = "BABYLON.LavaMaterial";
|
337
|
+
return serializationObject;
|
338
|
+
};
|
339
|
+
LavaMaterial.prototype.getClassName = function () {
|
340
|
+
return "LavaMaterial";
|
341
|
+
};
|
342
|
+
// Statics
|
343
|
+
LavaMaterial.Parse = function (source, scene, rootUrl) {
|
344
|
+
return SerializationHelper.Parse(function () { return new LavaMaterial(source.name, scene); }, source, scene, rootUrl);
|
345
|
+
};
|
346
|
+
__decorate([
|
347
|
+
serializeAsTexture("diffuseTexture")
|
348
|
+
], LavaMaterial.prototype, "_diffuseTexture", void 0);
|
349
|
+
__decorate([
|
350
|
+
expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
351
|
+
], LavaMaterial.prototype, "diffuseTexture", void 0);
|
352
|
+
__decorate([
|
353
|
+
serializeAsTexture()
|
354
|
+
], LavaMaterial.prototype, "noiseTexture", void 0);
|
355
|
+
__decorate([
|
356
|
+
serializeAsColor3()
|
357
|
+
], LavaMaterial.prototype, "fogColor", void 0);
|
358
|
+
__decorate([
|
359
|
+
serialize()
|
360
|
+
], LavaMaterial.prototype, "speed", void 0);
|
361
|
+
__decorate([
|
362
|
+
serialize()
|
363
|
+
], LavaMaterial.prototype, "movingSpeed", void 0);
|
364
|
+
__decorate([
|
365
|
+
serialize()
|
366
|
+
], LavaMaterial.prototype, "lowFrequencySpeed", void 0);
|
367
|
+
__decorate([
|
368
|
+
serialize()
|
369
|
+
], LavaMaterial.prototype, "fogDensity", void 0);
|
370
|
+
__decorate([
|
371
|
+
serializeAsColor3()
|
372
|
+
], LavaMaterial.prototype, "diffuseColor", void 0);
|
373
|
+
__decorate([
|
374
|
+
serialize("disableLighting")
|
375
|
+
], LavaMaterial.prototype, "_disableLighting", void 0);
|
376
|
+
__decorate([
|
377
|
+
expandToProperty("_markAllSubMeshesAsLightsDirty")
|
378
|
+
], LavaMaterial.prototype, "disableLighting", void 0);
|
379
|
+
__decorate([
|
380
|
+
serialize("unlit")
|
381
|
+
], LavaMaterial.prototype, "_unlit", void 0);
|
382
|
+
__decorate([
|
383
|
+
expandToProperty("_markAllSubMeshesAsLightsDirty")
|
384
|
+
], LavaMaterial.prototype, "unlit", void 0);
|
385
|
+
__decorate([
|
386
|
+
serialize("maxSimultaneousLights")
|
387
|
+
], LavaMaterial.prototype, "_maxSimultaneousLights", void 0);
|
388
|
+
__decorate([
|
389
|
+
expandToProperty("_markAllSubMeshesAsLightsDirty")
|
390
|
+
], LavaMaterial.prototype, "maxSimultaneousLights", void 0);
|
391
|
+
return LavaMaterial;
|
392
|
+
}(PushMaterial));
|
393
|
+
export { LavaMaterial };
|
394
|
+
RegisterClass("BABYLON.LavaMaterial", LavaMaterial);
|
379
395
|
//# sourceMappingURL=lavaMaterial.js.map
|