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