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