@babylonjs/materials 5.0.0-rc.6 → 5.0.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.
- package/cell/cell.fragment.d.ts +17 -17
- package/cell/cell.fragment.js +20 -20
- package/cell/cell.vertex.d.ts +18 -18
- package/cell/cell.vertex.js +21 -21
- package/cell/cellMaterial.d.ts +37 -37
- package/cell/cellMaterial.js +304 -304
- package/cell/cellMaterial.js.map +1 -1
- package/cell/index.d.ts +1 -1
- package/cell/index.js +1 -1
- package/custom/customMaterial.d.ts +69 -69
- package/custom/customMaterial.js +216 -216
- package/custom/customMaterial.js.map +1 -1
- package/custom/index.d.ts +2 -2
- package/custom/index.js +2 -2
- package/custom/pbrCustomMaterial.d.ts +71 -71
- package/custom/pbrCustomMaterial.js +241 -241
- package/custom/pbrCustomMaterial.js.map +1 -1
- package/fire/fire.fragment.d.ts +11 -11
- package/fire/fire.fragment.js +14 -14
- package/fire/fire.vertex.d.ts +15 -15
- package/fire/fire.vertex.js +18 -18
- package/fire/fireMaterial.d.ts +38 -38
- package/fire/fireMaterial.js +342 -342
- package/fire/fireMaterial.js.map +1 -1
- package/fire/index.d.ts +1 -1
- package/fire/index.js +1 -1
- package/fur/fur.fragment.d.ts +17 -17
- package/fur/fur.fragment.js +20 -20
- package/fur/fur.vertex.d.ts +18 -18
- package/fur/fur.vertex.js +21 -21
- package/fur/furMaterial.d.ts +57 -56
- package/fur/furMaterial.js +500 -500
- package/fur/furMaterial.js.map +1 -1
- package/fur/index.d.ts +1 -1
- package/fur/index.js +1 -1
- package/gradient/gradient.fragment.d.ts +17 -17
- package/gradient/gradient.fragment.js +20 -20
- package/gradient/gradient.vertex.d.ts +18 -18
- package/gradient/gradient.vertex.js +21 -21
- package/gradient/gradientMaterial.d.ts +37 -37
- package/gradient/gradientMaterial.js +275 -275
- package/gradient/gradientMaterial.js.map +1 -1
- package/gradient/index.d.ts +1 -1
- package/gradient/index.js +1 -1
- package/grid/grid.fragment.d.ts +8 -8
- package/grid/grid.fragment.js +11 -11
- package/grid/grid.vertex.d.ts +9 -9
- package/grid/grid.vertex.js +12 -12
- package/grid/gridMaterial.d.ts +78 -77
- package/grid/gridMaterial.js +276 -276
- package/grid/gridMaterial.js.map +1 -1
- package/grid/index.d.ts +1 -1
- package/grid/index.js +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/lava.fragment.d.ts +17 -17
- package/lava/lava.fragment.js +20 -20
- package/lava/lava.vertex.d.ts +18 -18
- package/lava/lava.vertex.js +21 -21
- package/lava/lavaMaterial.d.ts +45 -45
- package/lava/lavaMaterial.js +394 -394
- 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/license.md +71 -0
- package/mix/index.d.ts +1 -1
- package/mix/index.js +1 -1
- package/mix/mix.fragment.d.ts +17 -17
- package/mix/mix.fragment.js +20 -20
- package/mix/mix.vertex.d.ts +18 -18
- package/mix/mix.vertex.js +21 -21
- package/mix/mixMaterial.d.ts +65 -65
- package/mix/mixMaterial.js +510 -510
- package/mix/mixMaterial.js.map +1 -1
- package/normal/index.d.ts +1 -1
- package/normal/index.js +1 -1
- package/normal/normal.fragment.d.ts +17 -17
- package/normal/normal.fragment.js +20 -20
- package/normal/normal.vertex.d.ts +18 -18
- package/normal/normal.vertex.js +21 -21
- package/normal/normalMaterial.d.ts +36 -36
- package/normal/normalMaterial.js +336 -336
- package/normal/normalMaterial.js.map +1 -1
- package/package.json +24 -5
- package/shadowOnly/index.d.ts +1 -1
- package/shadowOnly/index.js +1 -1
- package/shadowOnly/shadowOnly.fragment.d.ts +16 -16
- package/shadowOnly/shadowOnly.fragment.js +19 -19
- package/shadowOnly/shadowOnly.vertex.d.ts +18 -18
- package/shadowOnly/shadowOnly.vertex.js +21 -21
- package/shadowOnly/shadowOnlyMaterial.d.ts +30 -30
- package/shadowOnly/shadowOnlyMaterial.js +254 -254
- package/shadowOnly/shadowOnlyMaterial.js.map +1 -1
- package/simple/index.d.ts +1 -1
- package/simple/index.js +1 -1
- package/simple/simple.fragment.d.ts +17 -17
- package/simple/simple.fragment.js +20 -20
- package/simple/simple.vertex.d.ts +18 -18
- package/simple/simple.vertex.js +21 -21
- package/simple/simpleMaterial.d.ts +35 -35
- package/simple/simpleMaterial.js +295 -295
- package/simple/simpleMaterial.js.map +1 -1
- package/sky/index.d.ts +1 -1
- package/sky/index.js +1 -1
- package/sky/sky.fragment.d.ts +10 -10
- package/sky/sky.fragment.js +13 -13
- package/sky/sky.vertex.d.ts +9 -9
- package/sky/sky.vertex.js +12 -12
- package/sky/skyMaterial.d.ts +147 -146
- package/sky/skyMaterial.js +359 -359
- package/sky/skyMaterial.js.map +1 -1
- package/terrain/index.d.ts +1 -1
- package/terrain/index.js +1 -1
- package/terrain/terrain.fragment.d.ts +17 -17
- package/terrain/terrain.fragment.js +20 -20
- package/terrain/terrain.vertex.d.ts +18 -18
- package/terrain/terrain.vertex.js +21 -21
- package/terrain/terrainMaterial.d.ts +50 -50
- package/terrain/terrainMaterial.js +426 -426
- package/terrain/terrainMaterial.js.map +1 -1
- package/triPlanar/index.d.ts +1 -1
- package/triPlanar/index.js +1 -1
- package/triPlanar/triPlanarMaterial.d.ts +49 -49
- package/triPlanar/triPlanarMaterial.js +403 -403
- package/triPlanar/triPlanarMaterial.js.map +1 -1
- package/triPlanar/triplanar.fragment.d.ts +17 -17
- package/triPlanar/triplanar.fragment.js +20 -20
- package/triPlanar/triplanar.vertex.d.ts +18 -18
- package/triPlanar/triplanar.vertex.js +21 -21
- package/water/index.d.ts +1 -1
- package/water/index.js +1 -1
- package/water/water.fragment.d.ts +19 -19
- package/water/water.fragment.js +22 -22
- package/water/water.vertex.d.ts +20 -20
- package/water/water.vertex.js +23 -23
- package/water/waterMaterial.d.ts +135 -135
- package/water/waterMaterial.js +736 -736
- package/water/waterMaterial.js.map +1 -1
@@ -1,427 +1,427 @@
|
|
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 "./terrain.fragment.js";
|
12
|
-
import "./terrain.vertex.js";
|
13
|
-
import { EffectFallbacks } from "@babylonjs/core/Materials/effectFallbacks.js";
|
14
|
-
var TerrainMaterialDefines = /** @class */ (function (_super) {
|
15
|
-
__extends(TerrainMaterialDefines, _super);
|
16
|
-
function TerrainMaterialDefines() {
|
17
|
-
var _this = _super.call(this) || this;
|
18
|
-
_this.DIFFUSE = false;
|
19
|
-
_this.BUMP = false;
|
20
|
-
_this.CLIPPLANE = false;
|
21
|
-
_this.CLIPPLANE2 = false;
|
22
|
-
_this.CLIPPLANE3 = false;
|
23
|
-
_this.CLIPPLANE4 = false;
|
24
|
-
_this.CLIPPLANE5 = false;
|
25
|
-
_this.CLIPPLANE6 = false;
|
26
|
-
_this.ALPHATEST = false;
|
27
|
-
_this.DEPTHPREPASS = false;
|
28
|
-
_this.POINTSIZE = false;
|
29
|
-
_this.FOG = false;
|
30
|
-
_this.SPECULARTERM = false;
|
31
|
-
_this.NORMAL = false;
|
32
|
-
_this.UV1 = false;
|
33
|
-
_this.UV2 = false;
|
34
|
-
_this.VERTEXCOLOR = false;
|
35
|
-
_this.VERTEXALPHA = false;
|
36
|
-
_this.NUM_BONE_INFLUENCERS = 0;
|
37
|
-
_this.BonesPerMesh = 0;
|
38
|
-
_this.INSTANCES = false;
|
39
|
-
_this.INSTANCESCOLOR = false;
|
40
|
-
_this.IMAGEPROCESSINGPOSTPROCESS = false;
|
41
|
-
_this.SKIPFINALCOLORCLAMP = false;
|
42
|
-
_this.rebuild();
|
43
|
-
return _this;
|
44
|
-
}
|
45
|
-
return TerrainMaterialDefines;
|
46
|
-
}(MaterialDefines));
|
47
|
-
var TerrainMaterial = /** @class */ (function (_super) {
|
48
|
-
__extends(TerrainMaterial, _super);
|
49
|
-
function TerrainMaterial(name, scene) {
|
50
|
-
var _this = _super.call(this, name, scene) || this;
|
51
|
-
_this.diffuseColor = new Color3(1, 1, 1);
|
52
|
-
_this.specularColor = new Color3(0, 0, 0);
|
53
|
-
_this.specularPower = 64;
|
54
|
-
_this._disableLighting = false;
|
55
|
-
_this._maxSimultaneousLights = 4;
|
56
|
-
return _this;
|
57
|
-
}
|
58
|
-
TerrainMaterial.prototype.needAlphaBlending = function () {
|
59
|
-
return this.alpha < 1.0;
|
60
|
-
};
|
61
|
-
TerrainMaterial.prototype.needAlphaTesting = function () {
|
62
|
-
return false;
|
63
|
-
};
|
64
|
-
TerrainMaterial.prototype.getAlphaTestTexture = function () {
|
65
|
-
return null;
|
66
|
-
};
|
67
|
-
// Methods
|
68
|
-
TerrainMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
|
69
|
-
if (this.isFrozen) {
|
70
|
-
if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
|
71
|
-
return true;
|
72
|
-
}
|
73
|
-
}
|
74
|
-
if (!subMesh.materialDefines) {
|
75
|
-
subMesh.materialDefines = new TerrainMaterialDefines();
|
76
|
-
}
|
77
|
-
var defines = subMesh.materialDefines;
|
78
|
-
var scene = this.getScene();
|
79
|
-
if (this._isReadyForSubMesh(subMesh)) {
|
80
|
-
return true;
|
81
|
-
}
|
82
|
-
var engine = scene.getEngine();
|
83
|
-
// Textures
|
84
|
-
if (scene.texturesEnabled) {
|
85
|
-
if (!this.mixTexture || !this.mixTexture.isReady()) {
|
86
|
-
return false;
|
87
|
-
}
|
88
|
-
defines._needUVs = true;
|
89
|
-
if (MaterialFlags.DiffuseTextureEnabled) {
|
90
|
-
if (!this.diffuseTexture1 || !this.diffuseTexture1.isReady()) {
|
91
|
-
return false;
|
92
|
-
}
|
93
|
-
if (!this.diffuseTexture2 || !this.diffuseTexture2.isReady()) {
|
94
|
-
return false;
|
95
|
-
}
|
96
|
-
if (!this.diffuseTexture3 || !this.diffuseTexture3.isReady()) {
|
97
|
-
return false;
|
98
|
-
}
|
99
|
-
defines.DIFFUSE = true;
|
100
|
-
}
|
101
|
-
if (this.bumpTexture1 && this.bumpTexture2 && this.bumpTexture3 && MaterialFlags.BumpTextureEnabled) {
|
102
|
-
if (!this.bumpTexture1.isReady()) {
|
103
|
-
return false;
|
104
|
-
}
|
105
|
-
if (!this.bumpTexture2.isReady()) {
|
106
|
-
return false;
|
107
|
-
}
|
108
|
-
if (!this.bumpTexture3.isReady()) {
|
109
|
-
return false;
|
110
|
-
}
|
111
|
-
defines._needNormals = true;
|
112
|
-
defines.BUMP = true;
|
113
|
-
}
|
114
|
-
}
|
115
|
-
// Misc.
|
116
|
-
MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
|
117
|
-
// Lights
|
118
|
-
defines._needNormals = MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
|
119
|
-
// Values that need to be evaluated on every frame
|
120
|
-
MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
|
121
|
-
// Attribs
|
122
|
-
MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true);
|
123
|
-
// Get correct effect
|
124
|
-
if (defines.isDirty) {
|
125
|
-
defines.markAsProcessed();
|
126
|
-
scene.resetCachedMaterial();
|
127
|
-
// Fallbacks
|
128
|
-
var fallbacks = new EffectFallbacks();
|
129
|
-
if (defines.FOG) {
|
130
|
-
fallbacks.addFallback(1, "FOG");
|
131
|
-
}
|
132
|
-
MaterialHelper.HandleFallbacksForShadows(defines, fallbacks, this.maxSimultaneousLights);
|
133
|
-
if (defines.NUM_BONE_INFLUENCERS > 0) {
|
134
|
-
fallbacks.addCPUSkinningFallback(0, mesh);
|
135
|
-
}
|
136
|
-
defines.IMAGEPROCESSINGPOSTPROCESS = scene.imageProcessingConfiguration.applyByPostProcess;
|
137
|
-
//Attributes
|
138
|
-
var attribs = [VertexBuffer.PositionKind];
|
139
|
-
if (defines.NORMAL) {
|
140
|
-
attribs.push(VertexBuffer.NormalKind);
|
141
|
-
}
|
142
|
-
if (defines.UV1) {
|
143
|
-
attribs.push(VertexBuffer.UVKind);
|
144
|
-
}
|
145
|
-
if (defines.UV2) {
|
146
|
-
attribs.push(VertexBuffer.UV2Kind);
|
147
|
-
}
|
148
|
-
if (defines.VERTEXCOLOR) {
|
149
|
-
attribs.push(VertexBuffer.ColorKind);
|
150
|
-
}
|
151
|
-
MaterialHelper.PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
|
152
|
-
MaterialHelper.PrepareAttributesForInstances(attribs, defines);
|
153
|
-
// Legacy browser patch
|
154
|
-
var shaderName = "terrain";
|
155
|
-
var join = defines.toString();
|
156
|
-
var uniforms = [
|
157
|
-
"world",
|
158
|
-
"view",
|
159
|
-
"viewProjection",
|
160
|
-
"vEyePosition",
|
161
|
-
"vLightsType",
|
162
|
-
"vDiffuseColor",
|
163
|
-
"vSpecularColor",
|
164
|
-
"vFogInfos",
|
165
|
-
"vFogColor",
|
166
|
-
"pointSize",
|
167
|
-
"vTextureInfos",
|
168
|
-
"mBones",
|
169
|
-
"vClipPlane",
|
170
|
-
"vClipPlane2",
|
171
|
-
"vClipPlane3",
|
172
|
-
"vClipPlane4",
|
173
|
-
"vClipPlane5",
|
174
|
-
"vClipPlane6",
|
175
|
-
"textureMatrix",
|
176
|
-
"diffuse1Infos",
|
177
|
-
"diffuse2Infos",
|
178
|
-
"diffuse3Infos",
|
179
|
-
];
|
180
|
-
var samplers = ["textureSampler", "diffuse1Sampler", "diffuse2Sampler", "diffuse3Sampler", "bump1Sampler", "bump2Sampler", "bump3Sampler"];
|
181
|
-
var uniformBuffers = new Array();
|
182
|
-
MaterialHelper.PrepareUniformsAndSamplersList({
|
183
|
-
uniformsNames: uniforms,
|
184
|
-
uniformBuffersNames: uniformBuffers,
|
185
|
-
samplers: samplers,
|
186
|
-
defines: defines,
|
187
|
-
maxSimultaneousLights: this.maxSimultaneousLights,
|
188
|
-
});
|
189
|
-
subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
|
190
|
-
attributes: attribs,
|
191
|
-
uniformsNames: uniforms,
|
192
|
-
uniformBuffersNames: uniformBuffers,
|
193
|
-
samplers: samplers,
|
194
|
-
defines: join,
|
195
|
-
fallbacks: fallbacks,
|
196
|
-
onCompiled: this.onCompiled,
|
197
|
-
onError: this.onError,
|
198
|
-
indexParameters: { maxSimultaneousLights: this.maxSimultaneousLights },
|
199
|
-
}, engine), defines, this._materialContext);
|
200
|
-
}
|
201
|
-
if (!subMesh.effect || !subMesh.effect.isReady()) {
|
202
|
-
return false;
|
203
|
-
}
|
204
|
-
defines._renderId = scene.getRenderId();
|
205
|
-
subMesh.effect._wasPreviouslyReady = true;
|
206
|
-
return true;
|
207
|
-
};
|
208
|
-
TerrainMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
|
209
|
-
var scene = this.getScene();
|
210
|
-
var defines = subMesh.materialDefines;
|
211
|
-
if (!defines) {
|
212
|
-
return;
|
213
|
-
}
|
214
|
-
var effect = subMesh.effect;
|
215
|
-
if (!effect) {
|
216
|
-
return;
|
217
|
-
}
|
218
|
-
this._activeEffect = effect;
|
219
|
-
// Matrices
|
220
|
-
this.bindOnlyWorldMatrix(world);
|
221
|
-
this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
|
222
|
-
// Bones
|
223
|
-
MaterialHelper.BindBonesParameters(mesh, this._activeEffect);
|
224
|
-
if (this._mustRebind(scene, effect)) {
|
225
|
-
// Textures
|
226
|
-
if (this.mixTexture) {
|
227
|
-
this._activeEffect.setTexture("textureSampler", this._mixTexture);
|
228
|
-
this._activeEffect.setFloat2("vTextureInfos", this._mixTexture.coordinatesIndex, this._mixTexture.level);
|
229
|
-
this._activeEffect.setMatrix("textureMatrix", this._mixTexture.getTextureMatrix());
|
230
|
-
if (MaterialFlags.DiffuseTextureEnabled) {
|
231
|
-
if (this._diffuseTexture1) {
|
232
|
-
this._activeEffect.setTexture("diffuse1Sampler", this._diffuseTexture1);
|
233
|
-
this._activeEffect.setFloat2("diffuse1Infos", this._diffuseTexture1.uScale, this._diffuseTexture1.vScale);
|
234
|
-
}
|
235
|
-
if (this._diffuseTexture2) {
|
236
|
-
this._activeEffect.setTexture("diffuse2Sampler", this._diffuseTexture2);
|
237
|
-
this._activeEffect.setFloat2("diffuse2Infos", this._diffuseTexture2.uScale, this._diffuseTexture2.vScale);
|
238
|
-
}
|
239
|
-
if (this._diffuseTexture3) {
|
240
|
-
this._activeEffect.setTexture("diffuse3Sampler", this._diffuseTexture3);
|
241
|
-
this._activeEffect.setFloat2("diffuse3Infos", this._diffuseTexture3.uScale, this._diffuseTexture3.vScale);
|
242
|
-
}
|
243
|
-
}
|
244
|
-
if (MaterialFlags.BumpTextureEnabled && scene.getEngine().getCaps().standardDerivatives) {
|
245
|
-
if (this._bumpTexture1) {
|
246
|
-
this._activeEffect.setTexture("bump1Sampler", this._bumpTexture1);
|
247
|
-
}
|
248
|
-
if (this._bumpTexture2) {
|
249
|
-
this._activeEffect.setTexture("bump2Sampler", this._bumpTexture2);
|
250
|
-
}
|
251
|
-
if (this._bumpTexture3) {
|
252
|
-
this._activeEffect.setTexture("bump3Sampler", this._bumpTexture3);
|
253
|
-
}
|
254
|
-
}
|
255
|
-
}
|
256
|
-
// Clip plane
|
257
|
-
MaterialHelper.BindClipPlane(this._activeEffect, scene);
|
258
|
-
// Point size
|
259
|
-
if (this.pointsCloud) {
|
260
|
-
this._activeEffect.setFloat("pointSize", this.pointSize);
|
261
|
-
}
|
262
|
-
scene.bindEyePosition(effect);
|
263
|
-
}
|
264
|
-
this._activeEffect.setColor4("vDiffuseColor", this.diffuseColor, this.alpha * mesh.visibility);
|
265
|
-
if (defines.SPECULARTERM) {
|
266
|
-
this._activeEffect.setColor4("vSpecularColor", this.specularColor, this.specularPower);
|
267
|
-
}
|
268
|
-
if (scene.lightsEnabled && !this.disableLighting) {
|
269
|
-
MaterialHelper.BindLights(scene, mesh, this._activeEffect, defines, this.maxSimultaneousLights);
|
270
|
-
}
|
271
|
-
// View
|
272
|
-
if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE) {
|
273
|
-
this._activeEffect.setMatrix("view", scene.getViewMatrix());
|
274
|
-
}
|
275
|
-
// Fog
|
276
|
-
MaterialHelper.BindFogParameters(scene, mesh, this._activeEffect);
|
277
|
-
this._afterBind(mesh, this._activeEffect);
|
278
|
-
};
|
279
|
-
TerrainMaterial.prototype.getAnimatables = function () {
|
280
|
-
var results = [];
|
281
|
-
if (this.mixTexture && this.mixTexture.animations && this.mixTexture.animations.length > 0) {
|
282
|
-
results.push(this.mixTexture);
|
283
|
-
}
|
284
|
-
return results;
|
285
|
-
};
|
286
|
-
TerrainMaterial.prototype.getActiveTextures = function () {
|
287
|
-
var activeTextures = _super.prototype.getActiveTextures.call(this);
|
288
|
-
if (this._mixTexture) {
|
289
|
-
activeTextures.push(this._mixTexture);
|
290
|
-
}
|
291
|
-
if (this._diffuseTexture1) {
|
292
|
-
activeTextures.push(this._diffuseTexture1);
|
293
|
-
}
|
294
|
-
if (this._diffuseTexture2) {
|
295
|
-
activeTextures.push(this._diffuseTexture2);
|
296
|
-
}
|
297
|
-
if (this._diffuseTexture3) {
|
298
|
-
activeTextures.push(this._diffuseTexture3);
|
299
|
-
}
|
300
|
-
if (this._bumpTexture1) {
|
301
|
-
activeTextures.push(this._bumpTexture1);
|
302
|
-
}
|
303
|
-
if (this._bumpTexture2) {
|
304
|
-
activeTextures.push(this._bumpTexture2);
|
305
|
-
}
|
306
|
-
if (this._bumpTexture3) {
|
307
|
-
activeTextures.push(this._bumpTexture3);
|
308
|
-
}
|
309
|
-
return activeTextures;
|
310
|
-
};
|
311
|
-
TerrainMaterial.prototype.hasTexture = function (texture) {
|
312
|
-
if (_super.prototype.hasTexture.call(this, texture)) {
|
313
|
-
return true;
|
314
|
-
}
|
315
|
-
if (this._mixTexture === texture) {
|
316
|
-
return true;
|
317
|
-
}
|
318
|
-
if (this._diffuseTexture1 === texture) {
|
319
|
-
return true;
|
320
|
-
}
|
321
|
-
if (this._diffuseTexture2 === texture) {
|
322
|
-
return true;
|
323
|
-
}
|
324
|
-
if (this._diffuseTexture3 === texture) {
|
325
|
-
return true;
|
326
|
-
}
|
327
|
-
if (this._bumpTexture1 === texture) {
|
328
|
-
return true;
|
329
|
-
}
|
330
|
-
if (this._bumpTexture2 === texture) {
|
331
|
-
return true;
|
332
|
-
}
|
333
|
-
if (this._bumpTexture3 === texture) {
|
334
|
-
return true;
|
335
|
-
}
|
336
|
-
return false;
|
337
|
-
};
|
338
|
-
TerrainMaterial.prototype.dispose = function (forceDisposeEffect) {
|
339
|
-
if (this.mixTexture) {
|
340
|
-
this.mixTexture.dispose();
|
341
|
-
}
|
342
|
-
_super.prototype.dispose.call(this, forceDisposeEffect);
|
343
|
-
};
|
344
|
-
TerrainMaterial.prototype.clone = function (name) {
|
345
|
-
var _this = this;
|
346
|
-
return SerializationHelper.Clone(function () { return new TerrainMaterial(name, _this.getScene()); }, this);
|
347
|
-
};
|
348
|
-
TerrainMaterial.prototype.serialize = function () {
|
349
|
-
var serializationObject = _super.prototype.serialize.call(this);
|
350
|
-
serializationObject.customType = "BABYLON.TerrainMaterial";
|
351
|
-
return serializationObject;
|
352
|
-
};
|
353
|
-
TerrainMaterial.prototype.getClassName = function () {
|
354
|
-
return "TerrainMaterial";
|
355
|
-
};
|
356
|
-
// Statics
|
357
|
-
TerrainMaterial.Parse = function (source, scene, rootUrl) {
|
358
|
-
return SerializationHelper.Parse(function () { return new TerrainMaterial(source.name, scene); }, source, scene, rootUrl);
|
359
|
-
};
|
360
|
-
__decorate([
|
361
|
-
serializeAsTexture("mixTexture")
|
362
|
-
], TerrainMaterial.prototype, "_mixTexture", void 0);
|
363
|
-
__decorate([
|
364
|
-
expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
365
|
-
], TerrainMaterial.prototype, "mixTexture", void 0);
|
366
|
-
__decorate([
|
367
|
-
serializeAsTexture("diffuseTexture1")
|
368
|
-
], TerrainMaterial.prototype, "_diffuseTexture1", void 0);
|
369
|
-
__decorate([
|
370
|
-
expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
371
|
-
], TerrainMaterial.prototype, "diffuseTexture1", void 0);
|
372
|
-
__decorate([
|
373
|
-
serializeAsTexture("diffuseTexture2")
|
374
|
-
], TerrainMaterial.prototype, "_diffuseTexture2", void 0);
|
375
|
-
__decorate([
|
376
|
-
expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
377
|
-
], TerrainMaterial.prototype, "diffuseTexture2", void 0);
|
378
|
-
__decorate([
|
379
|
-
serializeAsTexture("diffuseTexture3")
|
380
|
-
], TerrainMaterial.prototype, "_diffuseTexture3", void 0);
|
381
|
-
__decorate([
|
382
|
-
expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
383
|
-
], TerrainMaterial.prototype, "diffuseTexture3", void 0);
|
384
|
-
__decorate([
|
385
|
-
serializeAsTexture("bumpTexture1")
|
386
|
-
], TerrainMaterial.prototype, "_bumpTexture1", void 0);
|
387
|
-
__decorate([
|
388
|
-
expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
389
|
-
], TerrainMaterial.prototype, "bumpTexture1", void 0);
|
390
|
-
__decorate([
|
391
|
-
serializeAsTexture("bumpTexture2")
|
392
|
-
], TerrainMaterial.prototype, "_bumpTexture2", void 0);
|
393
|
-
__decorate([
|
394
|
-
expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
395
|
-
], TerrainMaterial.prototype, "bumpTexture2", void 0);
|
396
|
-
__decorate([
|
397
|
-
serializeAsTexture("bumpTexture3")
|
398
|
-
], TerrainMaterial.prototype, "_bumpTexture3", void 0);
|
399
|
-
__decorate([
|
400
|
-
expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
401
|
-
], TerrainMaterial.prototype, "bumpTexture3", void 0);
|
402
|
-
__decorate([
|
403
|
-
serializeAsColor3()
|
404
|
-
], TerrainMaterial.prototype, "diffuseColor", void 0);
|
405
|
-
__decorate([
|
406
|
-
serializeAsColor3()
|
407
|
-
], TerrainMaterial.prototype, "specularColor", void 0);
|
408
|
-
__decorate([
|
409
|
-
serialize()
|
410
|
-
], TerrainMaterial.prototype, "specularPower", void 0);
|
411
|
-
__decorate([
|
412
|
-
serialize("disableLighting")
|
413
|
-
], TerrainMaterial.prototype, "_disableLighting", void 0);
|
414
|
-
__decorate([
|
415
|
-
expandToProperty("_markAllSubMeshesAsLightsDirty")
|
416
|
-
], TerrainMaterial.prototype, "disableLighting", void 0);
|
417
|
-
__decorate([
|
418
|
-
serialize("maxSimultaneousLights")
|
419
|
-
], TerrainMaterial.prototype, "_maxSimultaneousLights", void 0);
|
420
|
-
__decorate([
|
421
|
-
expandToProperty("_markAllSubMeshesAsLightsDirty")
|
422
|
-
], TerrainMaterial.prototype, "maxSimultaneousLights", void 0);
|
423
|
-
return TerrainMaterial;
|
424
|
-
}(PushMaterial));
|
425
|
-
export { TerrainMaterial };
|
426
|
-
RegisterClass("BABYLON.TerrainMaterial", TerrainMaterial);
|
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 "./terrain.fragment.js";
|
12
|
+
import "./terrain.vertex.js";
|
13
|
+
import { EffectFallbacks } from "@babylonjs/core/Materials/effectFallbacks.js";
|
14
|
+
var TerrainMaterialDefines = /** @class */ (function (_super) {
|
15
|
+
__extends(TerrainMaterialDefines, _super);
|
16
|
+
function TerrainMaterialDefines() {
|
17
|
+
var _this = _super.call(this) || this;
|
18
|
+
_this.DIFFUSE = false;
|
19
|
+
_this.BUMP = false;
|
20
|
+
_this.CLIPPLANE = false;
|
21
|
+
_this.CLIPPLANE2 = false;
|
22
|
+
_this.CLIPPLANE3 = false;
|
23
|
+
_this.CLIPPLANE4 = false;
|
24
|
+
_this.CLIPPLANE5 = false;
|
25
|
+
_this.CLIPPLANE6 = false;
|
26
|
+
_this.ALPHATEST = false;
|
27
|
+
_this.DEPTHPREPASS = false;
|
28
|
+
_this.POINTSIZE = false;
|
29
|
+
_this.FOG = false;
|
30
|
+
_this.SPECULARTERM = false;
|
31
|
+
_this.NORMAL = false;
|
32
|
+
_this.UV1 = false;
|
33
|
+
_this.UV2 = false;
|
34
|
+
_this.VERTEXCOLOR = false;
|
35
|
+
_this.VERTEXALPHA = false;
|
36
|
+
_this.NUM_BONE_INFLUENCERS = 0;
|
37
|
+
_this.BonesPerMesh = 0;
|
38
|
+
_this.INSTANCES = false;
|
39
|
+
_this.INSTANCESCOLOR = false;
|
40
|
+
_this.IMAGEPROCESSINGPOSTPROCESS = false;
|
41
|
+
_this.SKIPFINALCOLORCLAMP = false;
|
42
|
+
_this.rebuild();
|
43
|
+
return _this;
|
44
|
+
}
|
45
|
+
return TerrainMaterialDefines;
|
46
|
+
}(MaterialDefines));
|
47
|
+
var TerrainMaterial = /** @class */ (function (_super) {
|
48
|
+
__extends(TerrainMaterial, _super);
|
49
|
+
function TerrainMaterial(name, scene) {
|
50
|
+
var _this = _super.call(this, name, scene) || this;
|
51
|
+
_this.diffuseColor = new Color3(1, 1, 1);
|
52
|
+
_this.specularColor = new Color3(0, 0, 0);
|
53
|
+
_this.specularPower = 64;
|
54
|
+
_this._disableLighting = false;
|
55
|
+
_this._maxSimultaneousLights = 4;
|
56
|
+
return _this;
|
57
|
+
}
|
58
|
+
TerrainMaterial.prototype.needAlphaBlending = function () {
|
59
|
+
return this.alpha < 1.0;
|
60
|
+
};
|
61
|
+
TerrainMaterial.prototype.needAlphaTesting = function () {
|
62
|
+
return false;
|
63
|
+
};
|
64
|
+
TerrainMaterial.prototype.getAlphaTestTexture = function () {
|
65
|
+
return null;
|
66
|
+
};
|
67
|
+
// Methods
|
68
|
+
TerrainMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
|
69
|
+
if (this.isFrozen) {
|
70
|
+
if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
|
71
|
+
return true;
|
72
|
+
}
|
73
|
+
}
|
74
|
+
if (!subMesh.materialDefines) {
|
75
|
+
subMesh.materialDefines = new TerrainMaterialDefines();
|
76
|
+
}
|
77
|
+
var defines = subMesh.materialDefines;
|
78
|
+
var scene = this.getScene();
|
79
|
+
if (this._isReadyForSubMesh(subMesh)) {
|
80
|
+
return true;
|
81
|
+
}
|
82
|
+
var engine = scene.getEngine();
|
83
|
+
// Textures
|
84
|
+
if (scene.texturesEnabled) {
|
85
|
+
if (!this.mixTexture || !this.mixTexture.isReady()) {
|
86
|
+
return false;
|
87
|
+
}
|
88
|
+
defines._needUVs = true;
|
89
|
+
if (MaterialFlags.DiffuseTextureEnabled) {
|
90
|
+
if (!this.diffuseTexture1 || !this.diffuseTexture1.isReady()) {
|
91
|
+
return false;
|
92
|
+
}
|
93
|
+
if (!this.diffuseTexture2 || !this.diffuseTexture2.isReady()) {
|
94
|
+
return false;
|
95
|
+
}
|
96
|
+
if (!this.diffuseTexture3 || !this.diffuseTexture3.isReady()) {
|
97
|
+
return false;
|
98
|
+
}
|
99
|
+
defines.DIFFUSE = true;
|
100
|
+
}
|
101
|
+
if (this.bumpTexture1 && this.bumpTexture2 && this.bumpTexture3 && MaterialFlags.BumpTextureEnabled) {
|
102
|
+
if (!this.bumpTexture1.isReady()) {
|
103
|
+
return false;
|
104
|
+
}
|
105
|
+
if (!this.bumpTexture2.isReady()) {
|
106
|
+
return false;
|
107
|
+
}
|
108
|
+
if (!this.bumpTexture3.isReady()) {
|
109
|
+
return false;
|
110
|
+
}
|
111
|
+
defines._needNormals = true;
|
112
|
+
defines.BUMP = true;
|
113
|
+
}
|
114
|
+
}
|
115
|
+
// Misc.
|
116
|
+
MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
|
117
|
+
// Lights
|
118
|
+
defines._needNormals = MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
|
119
|
+
// Values that need to be evaluated on every frame
|
120
|
+
MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
|
121
|
+
// Attribs
|
122
|
+
MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true);
|
123
|
+
// Get correct effect
|
124
|
+
if (defines.isDirty) {
|
125
|
+
defines.markAsProcessed();
|
126
|
+
scene.resetCachedMaterial();
|
127
|
+
// Fallbacks
|
128
|
+
var fallbacks = new EffectFallbacks();
|
129
|
+
if (defines.FOG) {
|
130
|
+
fallbacks.addFallback(1, "FOG");
|
131
|
+
}
|
132
|
+
MaterialHelper.HandleFallbacksForShadows(defines, fallbacks, this.maxSimultaneousLights);
|
133
|
+
if (defines.NUM_BONE_INFLUENCERS > 0) {
|
134
|
+
fallbacks.addCPUSkinningFallback(0, mesh);
|
135
|
+
}
|
136
|
+
defines.IMAGEPROCESSINGPOSTPROCESS = scene.imageProcessingConfiguration.applyByPostProcess;
|
137
|
+
//Attributes
|
138
|
+
var attribs = [VertexBuffer.PositionKind];
|
139
|
+
if (defines.NORMAL) {
|
140
|
+
attribs.push(VertexBuffer.NormalKind);
|
141
|
+
}
|
142
|
+
if (defines.UV1) {
|
143
|
+
attribs.push(VertexBuffer.UVKind);
|
144
|
+
}
|
145
|
+
if (defines.UV2) {
|
146
|
+
attribs.push(VertexBuffer.UV2Kind);
|
147
|
+
}
|
148
|
+
if (defines.VERTEXCOLOR) {
|
149
|
+
attribs.push(VertexBuffer.ColorKind);
|
150
|
+
}
|
151
|
+
MaterialHelper.PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
|
152
|
+
MaterialHelper.PrepareAttributesForInstances(attribs, defines);
|
153
|
+
// Legacy browser patch
|
154
|
+
var shaderName = "terrain";
|
155
|
+
var join = defines.toString();
|
156
|
+
var uniforms = [
|
157
|
+
"world",
|
158
|
+
"view",
|
159
|
+
"viewProjection",
|
160
|
+
"vEyePosition",
|
161
|
+
"vLightsType",
|
162
|
+
"vDiffuseColor",
|
163
|
+
"vSpecularColor",
|
164
|
+
"vFogInfos",
|
165
|
+
"vFogColor",
|
166
|
+
"pointSize",
|
167
|
+
"vTextureInfos",
|
168
|
+
"mBones",
|
169
|
+
"vClipPlane",
|
170
|
+
"vClipPlane2",
|
171
|
+
"vClipPlane3",
|
172
|
+
"vClipPlane4",
|
173
|
+
"vClipPlane5",
|
174
|
+
"vClipPlane6",
|
175
|
+
"textureMatrix",
|
176
|
+
"diffuse1Infos",
|
177
|
+
"diffuse2Infos",
|
178
|
+
"diffuse3Infos",
|
179
|
+
];
|
180
|
+
var samplers = ["textureSampler", "diffuse1Sampler", "diffuse2Sampler", "diffuse3Sampler", "bump1Sampler", "bump2Sampler", "bump3Sampler"];
|
181
|
+
var uniformBuffers = new Array();
|
182
|
+
MaterialHelper.PrepareUniformsAndSamplersList({
|
183
|
+
uniformsNames: uniforms,
|
184
|
+
uniformBuffersNames: uniformBuffers,
|
185
|
+
samplers: samplers,
|
186
|
+
defines: defines,
|
187
|
+
maxSimultaneousLights: this.maxSimultaneousLights,
|
188
|
+
});
|
189
|
+
subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
|
190
|
+
attributes: attribs,
|
191
|
+
uniformsNames: uniforms,
|
192
|
+
uniformBuffersNames: uniformBuffers,
|
193
|
+
samplers: samplers,
|
194
|
+
defines: join,
|
195
|
+
fallbacks: fallbacks,
|
196
|
+
onCompiled: this.onCompiled,
|
197
|
+
onError: this.onError,
|
198
|
+
indexParameters: { maxSimultaneousLights: this.maxSimultaneousLights },
|
199
|
+
}, engine), defines, this._materialContext);
|
200
|
+
}
|
201
|
+
if (!subMesh.effect || !subMesh.effect.isReady()) {
|
202
|
+
return false;
|
203
|
+
}
|
204
|
+
defines._renderId = scene.getRenderId();
|
205
|
+
subMesh.effect._wasPreviouslyReady = true;
|
206
|
+
return true;
|
207
|
+
};
|
208
|
+
TerrainMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
|
209
|
+
var scene = this.getScene();
|
210
|
+
var defines = subMesh.materialDefines;
|
211
|
+
if (!defines) {
|
212
|
+
return;
|
213
|
+
}
|
214
|
+
var effect = subMesh.effect;
|
215
|
+
if (!effect) {
|
216
|
+
return;
|
217
|
+
}
|
218
|
+
this._activeEffect = effect;
|
219
|
+
// Matrices
|
220
|
+
this.bindOnlyWorldMatrix(world);
|
221
|
+
this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
|
222
|
+
// Bones
|
223
|
+
MaterialHelper.BindBonesParameters(mesh, this._activeEffect);
|
224
|
+
if (this._mustRebind(scene, effect)) {
|
225
|
+
// Textures
|
226
|
+
if (this.mixTexture) {
|
227
|
+
this._activeEffect.setTexture("textureSampler", this._mixTexture);
|
228
|
+
this._activeEffect.setFloat2("vTextureInfos", this._mixTexture.coordinatesIndex, this._mixTexture.level);
|
229
|
+
this._activeEffect.setMatrix("textureMatrix", this._mixTexture.getTextureMatrix());
|
230
|
+
if (MaterialFlags.DiffuseTextureEnabled) {
|
231
|
+
if (this._diffuseTexture1) {
|
232
|
+
this._activeEffect.setTexture("diffuse1Sampler", this._diffuseTexture1);
|
233
|
+
this._activeEffect.setFloat2("diffuse1Infos", this._diffuseTexture1.uScale, this._diffuseTexture1.vScale);
|
234
|
+
}
|
235
|
+
if (this._diffuseTexture2) {
|
236
|
+
this._activeEffect.setTexture("diffuse2Sampler", this._diffuseTexture2);
|
237
|
+
this._activeEffect.setFloat2("diffuse2Infos", this._diffuseTexture2.uScale, this._diffuseTexture2.vScale);
|
238
|
+
}
|
239
|
+
if (this._diffuseTexture3) {
|
240
|
+
this._activeEffect.setTexture("diffuse3Sampler", this._diffuseTexture3);
|
241
|
+
this._activeEffect.setFloat2("diffuse3Infos", this._diffuseTexture3.uScale, this._diffuseTexture3.vScale);
|
242
|
+
}
|
243
|
+
}
|
244
|
+
if (MaterialFlags.BumpTextureEnabled && scene.getEngine().getCaps().standardDerivatives) {
|
245
|
+
if (this._bumpTexture1) {
|
246
|
+
this._activeEffect.setTexture("bump1Sampler", this._bumpTexture1);
|
247
|
+
}
|
248
|
+
if (this._bumpTexture2) {
|
249
|
+
this._activeEffect.setTexture("bump2Sampler", this._bumpTexture2);
|
250
|
+
}
|
251
|
+
if (this._bumpTexture3) {
|
252
|
+
this._activeEffect.setTexture("bump3Sampler", this._bumpTexture3);
|
253
|
+
}
|
254
|
+
}
|
255
|
+
}
|
256
|
+
// Clip plane
|
257
|
+
MaterialHelper.BindClipPlane(this._activeEffect, scene);
|
258
|
+
// Point size
|
259
|
+
if (this.pointsCloud) {
|
260
|
+
this._activeEffect.setFloat("pointSize", this.pointSize);
|
261
|
+
}
|
262
|
+
scene.bindEyePosition(effect);
|
263
|
+
}
|
264
|
+
this._activeEffect.setColor4("vDiffuseColor", this.diffuseColor, this.alpha * mesh.visibility);
|
265
|
+
if (defines.SPECULARTERM) {
|
266
|
+
this._activeEffect.setColor4("vSpecularColor", this.specularColor, this.specularPower);
|
267
|
+
}
|
268
|
+
if (scene.lightsEnabled && !this.disableLighting) {
|
269
|
+
MaterialHelper.BindLights(scene, mesh, this._activeEffect, defines, this.maxSimultaneousLights);
|
270
|
+
}
|
271
|
+
// View
|
272
|
+
if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE) {
|
273
|
+
this._activeEffect.setMatrix("view", scene.getViewMatrix());
|
274
|
+
}
|
275
|
+
// Fog
|
276
|
+
MaterialHelper.BindFogParameters(scene, mesh, this._activeEffect);
|
277
|
+
this._afterBind(mesh, this._activeEffect);
|
278
|
+
};
|
279
|
+
TerrainMaterial.prototype.getAnimatables = function () {
|
280
|
+
var results = [];
|
281
|
+
if (this.mixTexture && this.mixTexture.animations && this.mixTexture.animations.length > 0) {
|
282
|
+
results.push(this.mixTexture);
|
283
|
+
}
|
284
|
+
return results;
|
285
|
+
};
|
286
|
+
TerrainMaterial.prototype.getActiveTextures = function () {
|
287
|
+
var activeTextures = _super.prototype.getActiveTextures.call(this);
|
288
|
+
if (this._mixTexture) {
|
289
|
+
activeTextures.push(this._mixTexture);
|
290
|
+
}
|
291
|
+
if (this._diffuseTexture1) {
|
292
|
+
activeTextures.push(this._diffuseTexture1);
|
293
|
+
}
|
294
|
+
if (this._diffuseTexture2) {
|
295
|
+
activeTextures.push(this._diffuseTexture2);
|
296
|
+
}
|
297
|
+
if (this._diffuseTexture3) {
|
298
|
+
activeTextures.push(this._diffuseTexture3);
|
299
|
+
}
|
300
|
+
if (this._bumpTexture1) {
|
301
|
+
activeTextures.push(this._bumpTexture1);
|
302
|
+
}
|
303
|
+
if (this._bumpTexture2) {
|
304
|
+
activeTextures.push(this._bumpTexture2);
|
305
|
+
}
|
306
|
+
if (this._bumpTexture3) {
|
307
|
+
activeTextures.push(this._bumpTexture3);
|
308
|
+
}
|
309
|
+
return activeTextures;
|
310
|
+
};
|
311
|
+
TerrainMaterial.prototype.hasTexture = function (texture) {
|
312
|
+
if (_super.prototype.hasTexture.call(this, texture)) {
|
313
|
+
return true;
|
314
|
+
}
|
315
|
+
if (this._mixTexture === texture) {
|
316
|
+
return true;
|
317
|
+
}
|
318
|
+
if (this._diffuseTexture1 === texture) {
|
319
|
+
return true;
|
320
|
+
}
|
321
|
+
if (this._diffuseTexture2 === texture) {
|
322
|
+
return true;
|
323
|
+
}
|
324
|
+
if (this._diffuseTexture3 === texture) {
|
325
|
+
return true;
|
326
|
+
}
|
327
|
+
if (this._bumpTexture1 === texture) {
|
328
|
+
return true;
|
329
|
+
}
|
330
|
+
if (this._bumpTexture2 === texture) {
|
331
|
+
return true;
|
332
|
+
}
|
333
|
+
if (this._bumpTexture3 === texture) {
|
334
|
+
return true;
|
335
|
+
}
|
336
|
+
return false;
|
337
|
+
};
|
338
|
+
TerrainMaterial.prototype.dispose = function (forceDisposeEffect) {
|
339
|
+
if (this.mixTexture) {
|
340
|
+
this.mixTexture.dispose();
|
341
|
+
}
|
342
|
+
_super.prototype.dispose.call(this, forceDisposeEffect);
|
343
|
+
};
|
344
|
+
TerrainMaterial.prototype.clone = function (name) {
|
345
|
+
var _this = this;
|
346
|
+
return SerializationHelper.Clone(function () { return new TerrainMaterial(name, _this.getScene()); }, this);
|
347
|
+
};
|
348
|
+
TerrainMaterial.prototype.serialize = function () {
|
349
|
+
var serializationObject = _super.prototype.serialize.call(this);
|
350
|
+
serializationObject.customType = "BABYLON.TerrainMaterial";
|
351
|
+
return serializationObject;
|
352
|
+
};
|
353
|
+
TerrainMaterial.prototype.getClassName = function () {
|
354
|
+
return "TerrainMaterial";
|
355
|
+
};
|
356
|
+
// Statics
|
357
|
+
TerrainMaterial.Parse = function (source, scene, rootUrl) {
|
358
|
+
return SerializationHelper.Parse(function () { return new TerrainMaterial(source.name, scene); }, source, scene, rootUrl);
|
359
|
+
};
|
360
|
+
__decorate([
|
361
|
+
serializeAsTexture("mixTexture")
|
362
|
+
], TerrainMaterial.prototype, "_mixTexture", void 0);
|
363
|
+
__decorate([
|
364
|
+
expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
365
|
+
], TerrainMaterial.prototype, "mixTexture", void 0);
|
366
|
+
__decorate([
|
367
|
+
serializeAsTexture("diffuseTexture1")
|
368
|
+
], TerrainMaterial.prototype, "_diffuseTexture1", void 0);
|
369
|
+
__decorate([
|
370
|
+
expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
371
|
+
], TerrainMaterial.prototype, "diffuseTexture1", void 0);
|
372
|
+
__decorate([
|
373
|
+
serializeAsTexture("diffuseTexture2")
|
374
|
+
], TerrainMaterial.prototype, "_diffuseTexture2", void 0);
|
375
|
+
__decorate([
|
376
|
+
expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
377
|
+
], TerrainMaterial.prototype, "diffuseTexture2", void 0);
|
378
|
+
__decorate([
|
379
|
+
serializeAsTexture("diffuseTexture3")
|
380
|
+
], TerrainMaterial.prototype, "_diffuseTexture3", void 0);
|
381
|
+
__decorate([
|
382
|
+
expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
383
|
+
], TerrainMaterial.prototype, "diffuseTexture3", void 0);
|
384
|
+
__decorate([
|
385
|
+
serializeAsTexture("bumpTexture1")
|
386
|
+
], TerrainMaterial.prototype, "_bumpTexture1", void 0);
|
387
|
+
__decorate([
|
388
|
+
expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
389
|
+
], TerrainMaterial.prototype, "bumpTexture1", void 0);
|
390
|
+
__decorate([
|
391
|
+
serializeAsTexture("bumpTexture2")
|
392
|
+
], TerrainMaterial.prototype, "_bumpTexture2", void 0);
|
393
|
+
__decorate([
|
394
|
+
expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
395
|
+
], TerrainMaterial.prototype, "bumpTexture2", void 0);
|
396
|
+
__decorate([
|
397
|
+
serializeAsTexture("bumpTexture3")
|
398
|
+
], TerrainMaterial.prototype, "_bumpTexture3", void 0);
|
399
|
+
__decorate([
|
400
|
+
expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
401
|
+
], TerrainMaterial.prototype, "bumpTexture3", void 0);
|
402
|
+
__decorate([
|
403
|
+
serializeAsColor3()
|
404
|
+
], TerrainMaterial.prototype, "diffuseColor", void 0);
|
405
|
+
__decorate([
|
406
|
+
serializeAsColor3()
|
407
|
+
], TerrainMaterial.prototype, "specularColor", void 0);
|
408
|
+
__decorate([
|
409
|
+
serialize()
|
410
|
+
], TerrainMaterial.prototype, "specularPower", void 0);
|
411
|
+
__decorate([
|
412
|
+
serialize("disableLighting")
|
413
|
+
], TerrainMaterial.prototype, "_disableLighting", void 0);
|
414
|
+
__decorate([
|
415
|
+
expandToProperty("_markAllSubMeshesAsLightsDirty")
|
416
|
+
], TerrainMaterial.prototype, "disableLighting", void 0);
|
417
|
+
__decorate([
|
418
|
+
serialize("maxSimultaneousLights")
|
419
|
+
], TerrainMaterial.prototype, "_maxSimultaneousLights", void 0);
|
420
|
+
__decorate([
|
421
|
+
expandToProperty("_markAllSubMeshesAsLightsDirty")
|
422
|
+
], TerrainMaterial.prototype, "maxSimultaneousLights", void 0);
|
423
|
+
return TerrainMaterial;
|
424
|
+
}(PushMaterial));
|
425
|
+
export { TerrainMaterial };
|
426
|
+
RegisterClass("BABYLON.TerrainMaterial", TerrainMaterial);
|
427
427
|
//# sourceMappingURL=terrainMaterial.js.map
|