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