@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/sky/skyMaterial.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __esDecorate, __runInitializers } from "@babylonjs/core/tslib.es6.js";
|
|
2
2
|
import { serializeAsVector3, serialize } from "@babylonjs/core/Misc/decorators.js";
|
|
3
3
|
import { SerializationHelper } from "@babylonjs/core/Misc/decorators.serialization.js";
|
|
4
4
|
import { Vector3, Quaternion, TmpVectors } from "@babylonjs/core/Maths/math.vector.js";
|
|
@@ -35,354 +35,390 @@ class SkyMaterialDefines extends MaterialDefines {
|
|
|
35
35
|
* This is the sky material which allows to create dynamic and texture free effects for skyboxes.
|
|
36
36
|
* @see https://doc.babylonjs.com/toolsAndResources/assetLibraries/materialsLibrary/skyMat
|
|
37
37
|
*/
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
38
|
+
let SkyMaterial = (() => {
|
|
39
|
+
var _a;
|
|
40
|
+
let _classSuper = PushMaterial;
|
|
41
|
+
let _luminance_decorators;
|
|
42
|
+
let _luminance_initializers = [];
|
|
43
|
+
let _luminance_extraInitializers = [];
|
|
44
|
+
let _turbidity_decorators;
|
|
45
|
+
let _turbidity_initializers = [];
|
|
46
|
+
let _turbidity_extraInitializers = [];
|
|
47
|
+
let _rayleigh_decorators;
|
|
48
|
+
let _rayleigh_initializers = [];
|
|
49
|
+
let _rayleigh_extraInitializers = [];
|
|
50
|
+
let _mieCoefficient_decorators;
|
|
51
|
+
let _mieCoefficient_initializers = [];
|
|
52
|
+
let _mieCoefficient_extraInitializers = [];
|
|
53
|
+
let _mieDirectionalG_decorators;
|
|
54
|
+
let _mieDirectionalG_initializers = [];
|
|
55
|
+
let _mieDirectionalG_extraInitializers = [];
|
|
56
|
+
let _distance_decorators;
|
|
57
|
+
let _distance_initializers = [];
|
|
58
|
+
let _distance_extraInitializers = [];
|
|
59
|
+
let _inclination_decorators;
|
|
60
|
+
let _inclination_initializers = [];
|
|
61
|
+
let _inclination_extraInitializers = [];
|
|
62
|
+
let _azimuth_decorators;
|
|
63
|
+
let _azimuth_initializers = [];
|
|
64
|
+
let _azimuth_extraInitializers = [];
|
|
65
|
+
let _sunPosition_decorators;
|
|
66
|
+
let _sunPosition_initializers = [];
|
|
67
|
+
let _sunPosition_extraInitializers = [];
|
|
68
|
+
let _useSunPosition_decorators;
|
|
69
|
+
let _useSunPosition_initializers = [];
|
|
70
|
+
let _useSunPosition_extraInitializers = [];
|
|
71
|
+
let _cameraOffset_decorators;
|
|
72
|
+
let _cameraOffset_initializers = [];
|
|
73
|
+
let _cameraOffset_extraInitializers = [];
|
|
74
|
+
let _up_decorators;
|
|
75
|
+
let _up_initializers = [];
|
|
76
|
+
let _up_extraInitializers = [];
|
|
77
|
+
let _dithering_decorators;
|
|
78
|
+
let _dithering_initializers = [];
|
|
79
|
+
let _dithering_extraInitializers = [];
|
|
80
|
+
return _a = class SkyMaterial extends _classSuper {
|
|
81
|
+
/**
|
|
82
|
+
* Instantiates a new sky material.
|
|
83
|
+
* This material allows to create dynamic and texture free
|
|
84
|
+
* effects for skyboxes by taking care of the atmosphere state.
|
|
85
|
+
* @see https://doc.babylonjs.com/toolsAndResources/assetLibraries/materialsLibrary/skyMat
|
|
86
|
+
* @param name Define the name of the material in the scene
|
|
87
|
+
* @param scene Define the scene the material belong to
|
|
88
|
+
* @param forceGLSL Use the GLSL code generation for the shader (even on WebGPU). Default is false
|
|
89
|
+
*/
|
|
90
|
+
constructor(name, scene, forceGLSL = false) {
|
|
91
|
+
super(name, scene, undefined, forceGLSL);
|
|
92
|
+
/**
|
|
93
|
+
* Defines the overall luminance of sky in interval ]0, 1[.
|
|
94
|
+
*/
|
|
95
|
+
this.luminance = __runInitializers(this, _luminance_initializers, 1.0);
|
|
96
|
+
/**
|
|
97
|
+
* Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
|
|
98
|
+
*/
|
|
99
|
+
this.turbidity = (__runInitializers(this, _luminance_extraInitializers), __runInitializers(this, _turbidity_initializers, 10.0));
|
|
100
|
+
/**
|
|
101
|
+
* Defines the sky appearance (light intensity).
|
|
102
|
+
*/
|
|
103
|
+
this.rayleigh = (__runInitializers(this, _turbidity_extraInitializers), __runInitializers(this, _rayleigh_initializers, 2.0));
|
|
104
|
+
/**
|
|
105
|
+
* Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
|
|
106
|
+
*/
|
|
107
|
+
this.mieCoefficient = (__runInitializers(this, _rayleigh_extraInitializers), __runInitializers(this, _mieCoefficient_initializers, 0.005));
|
|
108
|
+
/**
|
|
109
|
+
* Defines the amount of haze particles following the Mie scattering theory.
|
|
110
|
+
*/
|
|
111
|
+
this.mieDirectionalG = (__runInitializers(this, _mieCoefficient_extraInitializers), __runInitializers(this, _mieDirectionalG_initializers, 0.8));
|
|
112
|
+
/**
|
|
113
|
+
* Defines the distance of the sun according to the active scene camera.
|
|
114
|
+
*/
|
|
115
|
+
this.distance = (__runInitializers(this, _mieDirectionalG_extraInitializers), __runInitializers(this, _distance_initializers, 500));
|
|
116
|
+
/**
|
|
117
|
+
* Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
|
|
118
|
+
* "inclined".
|
|
119
|
+
*/
|
|
120
|
+
this.inclination = (__runInitializers(this, _distance_extraInitializers), __runInitializers(this, _inclination_initializers, 0.49));
|
|
121
|
+
/**
|
|
122
|
+
* Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
|
|
123
|
+
* an object direction and a reference direction.
|
|
124
|
+
*/
|
|
125
|
+
this.azimuth = (__runInitializers(this, _inclination_extraInitializers), __runInitializers(this, _azimuth_initializers, 0.25));
|
|
126
|
+
/**
|
|
127
|
+
* Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
|
|
128
|
+
* the property is overridden by the inclination and the azimuth and can be read at any moment.
|
|
129
|
+
*/
|
|
130
|
+
this.sunPosition = (__runInitializers(this, _azimuth_extraInitializers), __runInitializers(this, _sunPosition_initializers, new Vector3(0, 100, 0)));
|
|
131
|
+
/**
|
|
132
|
+
* Defines if the sun position should be computed (inclination and azimuth) according to the given
|
|
133
|
+
* .sunPosition property.
|
|
134
|
+
*/
|
|
135
|
+
this.useSunPosition = (__runInitializers(this, _sunPosition_extraInitializers), __runInitializers(this, _useSunPosition_initializers, false));
|
|
136
|
+
/**
|
|
137
|
+
* Defines an offset vector used to get a horizon offset.
|
|
138
|
+
* @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
|
|
139
|
+
*/
|
|
140
|
+
this.cameraOffset = (__runInitializers(this, _useSunPosition_extraInitializers), __runInitializers(this, _cameraOffset_initializers, Vector3.Zero()));
|
|
141
|
+
/**
|
|
142
|
+
* Defines the vector the skyMaterial should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
|
|
143
|
+
*/
|
|
144
|
+
this.up = (__runInitializers(this, _cameraOffset_extraInitializers), __runInitializers(this, _up_initializers, Vector3.Up()));
|
|
145
|
+
/**
|
|
146
|
+
* Defines if sky should be dithered.
|
|
147
|
+
*/
|
|
148
|
+
this.dithering = (__runInitializers(this, _up_extraInitializers), __runInitializers(this, _dithering_initializers, false));
|
|
149
|
+
// Private members
|
|
150
|
+
this._cameraPosition = (__runInitializers(this, _dithering_extraInitializers), Vector3.Zero());
|
|
151
|
+
this._skyOrientation = new Quaternion();
|
|
152
|
+
this._shadersLoaded = false;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Specifies if the material will require alpha blending
|
|
156
|
+
* @returns a boolean specifying if alpha blending is needed
|
|
157
|
+
*/
|
|
158
|
+
needAlphaBlending() {
|
|
159
|
+
return this.alpha < 1.0;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Specifies if this material should be rendered in alpha test mode
|
|
163
|
+
* @returns false as the sky material doesn't need alpha testing.
|
|
164
|
+
*/
|
|
165
|
+
needAlphaTesting() {
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Get the texture used for alpha test purpose.
|
|
170
|
+
* @returns null as the sky material has no texture.
|
|
171
|
+
*/
|
|
172
|
+
getAlphaTestTexture() {
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Get if the submesh is ready to be used and all its information available.
|
|
177
|
+
* Child classes can use it to update shaders
|
|
178
|
+
* @param mesh defines the mesh to check
|
|
179
|
+
* @param subMesh defines which submesh to check
|
|
180
|
+
* @returns a boolean indicating that the submesh is ready or not
|
|
181
|
+
*/
|
|
182
|
+
isReadyForSubMesh(mesh, subMesh) {
|
|
183
|
+
const drawWrapper = subMesh._drawWrapper;
|
|
184
|
+
if (this.isFrozen) {
|
|
185
|
+
if (drawWrapper.effect && drawWrapper._wasPreviouslyReady) {
|
|
186
|
+
return true;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
if (!subMesh.materialDefines) {
|
|
190
|
+
subMesh.materialDefines = new SkyMaterialDefines();
|
|
191
|
+
}
|
|
192
|
+
const defines = subMesh.materialDefines;
|
|
193
|
+
const scene = this.getScene();
|
|
194
|
+
if (this._isReadyForSubMesh(subMesh)) {
|
|
195
|
+
return true;
|
|
196
|
+
}
|
|
197
|
+
PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, false, defines, undefined, undefined, undefined, this._isVertexOutputInvariant);
|
|
198
|
+
// Attribs
|
|
199
|
+
PrepareDefinesForAttributes(mesh, defines, true, false);
|
|
200
|
+
if (defines.IMAGEPROCESSINGPOSTPROCESS !== scene.imageProcessingConfiguration.applyByPostProcess) {
|
|
201
|
+
defines.markAsMiscDirty();
|
|
202
|
+
}
|
|
203
|
+
if (defines.DITHER !== this.dithering) {
|
|
204
|
+
defines.markAsMiscDirty();
|
|
205
|
+
}
|
|
206
|
+
// Get correct effect
|
|
207
|
+
if (defines.isDirty) {
|
|
208
|
+
defines.markAsProcessed();
|
|
209
|
+
scene.resetCachedMaterial();
|
|
210
|
+
// Fallbacks
|
|
211
|
+
const fallbacks = new EffectFallbacks();
|
|
212
|
+
if (defines.FOG) {
|
|
213
|
+
fallbacks.addFallback(1, "FOG");
|
|
214
|
+
}
|
|
215
|
+
defines.IMAGEPROCESSINGPOSTPROCESS = scene.imageProcessingConfiguration.applyByPostProcess;
|
|
216
|
+
defines.DITHER = this.dithering;
|
|
217
|
+
//Attributes
|
|
218
|
+
const attribs = [VertexBuffer.PositionKind];
|
|
219
|
+
if (defines.VERTEXCOLOR) {
|
|
220
|
+
attribs.push(VertexBuffer.ColorKind);
|
|
221
|
+
}
|
|
222
|
+
const shaderName = "sky";
|
|
223
|
+
const uniforms = [
|
|
224
|
+
"world",
|
|
225
|
+
"viewProjection",
|
|
226
|
+
"view",
|
|
227
|
+
"vFogInfos",
|
|
228
|
+
"vFogColor",
|
|
229
|
+
"logarithmicDepthConstant",
|
|
230
|
+
"pointSize",
|
|
231
|
+
"luminance",
|
|
232
|
+
"turbidity",
|
|
233
|
+
"rayleigh",
|
|
234
|
+
"mieCoefficient",
|
|
235
|
+
"mieDirectionalG",
|
|
236
|
+
"sunPosition",
|
|
237
|
+
"cameraPosition",
|
|
238
|
+
"cameraOffset",
|
|
239
|
+
"up",
|
|
240
|
+
];
|
|
241
|
+
AddClipPlaneUniforms(uniforms);
|
|
242
|
+
const join = defines.toString();
|
|
243
|
+
subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
|
|
244
|
+
attributes: attribs,
|
|
245
|
+
uniformsNames: uniforms,
|
|
246
|
+
uniformBuffersNames: [],
|
|
247
|
+
samplers: [],
|
|
248
|
+
defines: join,
|
|
249
|
+
fallbacks: fallbacks,
|
|
250
|
+
onCompiled: this.onCompiled,
|
|
251
|
+
onError: this.onError,
|
|
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/sky.vertex.js"), import("./wgsl/sky.fragment.js")]);
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
await Promise.all([import("./sky.vertex.js"), import("./sky.fragment.js")]);
|
|
261
|
+
}
|
|
262
|
+
this._shadersLoaded = true;
|
|
263
|
+
},
|
|
264
|
+
}, scene.getEngine()), defines, this._materialContext);
|
|
265
|
+
}
|
|
266
|
+
if (!subMesh.effect || !subMesh.effect.isReady()) {
|
|
267
|
+
return false;
|
|
268
|
+
}
|
|
269
|
+
defines._renderId = scene.getRenderId();
|
|
270
|
+
drawWrapper._wasPreviouslyReady = true;
|
|
144
271
|
return true;
|
|
145
272
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
273
|
+
/**
|
|
274
|
+
* Binds the submesh to this material by preparing the effect and shader to draw
|
|
275
|
+
* @param world defines the world transformation matrix
|
|
276
|
+
* @param mesh defines the mesh containing the submesh
|
|
277
|
+
* @param subMesh defines the submesh to bind the material to
|
|
278
|
+
*/
|
|
279
|
+
bindForSubMesh(world, mesh, subMesh) {
|
|
280
|
+
const scene = this.getScene();
|
|
281
|
+
const defines = subMesh.materialDefines;
|
|
282
|
+
if (!defines) {
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
const effect = subMesh.effect;
|
|
286
|
+
if (!effect) {
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
this._activeEffect = effect;
|
|
290
|
+
// Matrices
|
|
291
|
+
this.bindOnlyWorldMatrix(world);
|
|
292
|
+
this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
|
|
293
|
+
if (this._mustRebind(scene, effect, subMesh)) {
|
|
294
|
+
BindClipPlane(effect, this, scene);
|
|
295
|
+
// Point size
|
|
296
|
+
if (this.pointsCloud) {
|
|
297
|
+
this._activeEffect.setFloat("pointSize", this.pointSize);
|
|
298
|
+
}
|
|
299
|
+
// Log. depth
|
|
300
|
+
if (this._useLogarithmicDepth) {
|
|
301
|
+
BindLogDepth(defines, effect, scene);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
// View
|
|
305
|
+
if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE) {
|
|
306
|
+
this._activeEffect.setMatrix("view", scene.getViewMatrix());
|
|
307
|
+
}
|
|
308
|
+
// Fog
|
|
309
|
+
BindFogParameters(scene, mesh, this._activeEffect);
|
|
310
|
+
// Sky
|
|
311
|
+
const camera = scene.activeCamera;
|
|
312
|
+
if (camera) {
|
|
313
|
+
const cameraWorldMatrix = camera.getWorldMatrix();
|
|
314
|
+
this._cameraPosition.x = cameraWorldMatrix.m[12];
|
|
315
|
+
this._cameraPosition.y = cameraWorldMatrix.m[13];
|
|
316
|
+
this._cameraPosition.z = cameraWorldMatrix.m[14];
|
|
317
|
+
this._activeEffect.setVector3("cameraPosition", TmpVectors.Vector3[0].copyFrom(this._cameraPosition).subtractInPlace(scene.floatingOriginOffset));
|
|
318
|
+
}
|
|
319
|
+
this._activeEffect.setVector3("cameraOffset", this.cameraOffset);
|
|
320
|
+
this._activeEffect.setVector3("up", this.up);
|
|
321
|
+
if (this.luminance > 0) {
|
|
322
|
+
this._activeEffect.setFloat("luminance", this.luminance);
|
|
323
|
+
}
|
|
324
|
+
this._activeEffect.setFloat("turbidity", this.turbidity);
|
|
325
|
+
this._activeEffect.setFloat("rayleigh", this.rayleigh);
|
|
326
|
+
this._activeEffect.setFloat("mieCoefficient", this.mieCoefficient);
|
|
327
|
+
this._activeEffect.setFloat("mieDirectionalG", this.mieDirectionalG);
|
|
328
|
+
if (!this.useSunPosition) {
|
|
329
|
+
const theta = Math.PI * (this.inclination - 0.5);
|
|
330
|
+
const phi = 2 * Math.PI * (this.azimuth - 0.5);
|
|
331
|
+
this.sunPosition.x = this.distance * Math.cos(phi) * Math.cos(theta);
|
|
332
|
+
this.sunPosition.y = this.distance * Math.sin(-theta);
|
|
333
|
+
this.sunPosition.z = this.distance * Math.sin(phi) * Math.cos(theta);
|
|
334
|
+
Quaternion.FromUnitVectorsToRef(Vector3.UpReadOnly, this.up, this._skyOrientation);
|
|
335
|
+
this.sunPosition.rotateByQuaternionToRef(this._skyOrientation, this.sunPosition);
|
|
336
|
+
}
|
|
337
|
+
this._activeEffect.setVector3("sunPosition", this.sunPosition);
|
|
338
|
+
this._afterBind(mesh, this._activeEffect, subMesh);
|
|
172
339
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
340
|
+
/**
|
|
341
|
+
* Get the list of animatables in the material.
|
|
342
|
+
* @returns the list of animatables object used in the material
|
|
343
|
+
*/
|
|
344
|
+
getAnimatables() {
|
|
345
|
+
return [];
|
|
179
346
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
"vFogColor",
|
|
187
|
-
"logarithmicDepthConstant",
|
|
188
|
-
"pointSize",
|
|
189
|
-
"luminance",
|
|
190
|
-
"turbidity",
|
|
191
|
-
"rayleigh",
|
|
192
|
-
"mieCoefficient",
|
|
193
|
-
"mieDirectionalG",
|
|
194
|
-
"sunPosition",
|
|
195
|
-
"cameraPosition",
|
|
196
|
-
"cameraOffset",
|
|
197
|
-
"up",
|
|
198
|
-
];
|
|
199
|
-
AddClipPlaneUniforms(uniforms);
|
|
200
|
-
const join = defines.toString();
|
|
201
|
-
subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
|
|
202
|
-
attributes: attribs,
|
|
203
|
-
uniformsNames: uniforms,
|
|
204
|
-
uniformBuffersNames: [],
|
|
205
|
-
samplers: [],
|
|
206
|
-
defines: join,
|
|
207
|
-
fallbacks: fallbacks,
|
|
208
|
-
onCompiled: this.onCompiled,
|
|
209
|
-
onError: this.onError,
|
|
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/sky.vertex.js"), import("./wgsl/sky.fragment.js")]);
|
|
216
|
-
}
|
|
217
|
-
else {
|
|
218
|
-
await Promise.all([import("./sky.vertex.js"), import("./sky.fragment.js")]);
|
|
219
|
-
}
|
|
220
|
-
this._shadersLoaded = true;
|
|
221
|
-
},
|
|
222
|
-
}, scene.getEngine()), defines, this._materialContext);
|
|
223
|
-
}
|
|
224
|
-
if (!subMesh.effect || !subMesh.effect.isReady()) {
|
|
225
|
-
return false;
|
|
226
|
-
}
|
|
227
|
-
defines._renderId = scene.getRenderId();
|
|
228
|
-
drawWrapper._wasPreviouslyReady = true;
|
|
229
|
-
return true;
|
|
230
|
-
}
|
|
231
|
-
/**
|
|
232
|
-
* Binds the submesh to this material by preparing the effect and shader to draw
|
|
233
|
-
* @param world defines the world transformation matrix
|
|
234
|
-
* @param mesh defines the mesh containing the submesh
|
|
235
|
-
* @param subMesh defines the submesh to bind the material to
|
|
236
|
-
*/
|
|
237
|
-
bindForSubMesh(world, mesh, subMesh) {
|
|
238
|
-
const scene = this.getScene();
|
|
239
|
-
const defines = subMesh.materialDefines;
|
|
240
|
-
if (!defines) {
|
|
241
|
-
return;
|
|
242
|
-
}
|
|
243
|
-
const effect = subMesh.effect;
|
|
244
|
-
if (!effect) {
|
|
245
|
-
return;
|
|
246
|
-
}
|
|
247
|
-
this._activeEffect = effect;
|
|
248
|
-
// Matrices
|
|
249
|
-
this.bindOnlyWorldMatrix(world);
|
|
250
|
-
this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
|
|
251
|
-
if (this._mustRebind(scene, effect, subMesh)) {
|
|
252
|
-
BindClipPlane(effect, this, scene);
|
|
253
|
-
// Point size
|
|
254
|
-
if (this.pointsCloud) {
|
|
255
|
-
this._activeEffect.setFloat("pointSize", this.pointSize);
|
|
347
|
+
/**
|
|
348
|
+
* Disposes the material
|
|
349
|
+
* @param forceDisposeEffect specifies if effects should be forcefully disposed
|
|
350
|
+
*/
|
|
351
|
+
dispose(forceDisposeEffect) {
|
|
352
|
+
super.dispose(forceDisposeEffect);
|
|
256
353
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
354
|
+
/**
|
|
355
|
+
* Makes a duplicate of the material, and gives it a new name
|
|
356
|
+
* @param name defines the new name for the duplicated material
|
|
357
|
+
* @returns the cloned material
|
|
358
|
+
*/
|
|
359
|
+
clone(name) {
|
|
360
|
+
return SerializationHelper.Clone(() => new _a(name, this.getScene()), this);
|
|
260
361
|
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
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
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
* @returns the serialized material object
|
|
323
|
-
*/
|
|
324
|
-
serialize() {
|
|
325
|
-
const serializationObject = super.serialize();
|
|
326
|
-
serializationObject.customType = "BABYLON.SkyMaterial";
|
|
327
|
-
return serializationObject;
|
|
328
|
-
}
|
|
329
|
-
/**
|
|
330
|
-
* Gets the current class name of the material e.g. "SkyMaterial"
|
|
331
|
-
* Mainly use in serialization.
|
|
332
|
-
* @returns the class name
|
|
333
|
-
*/
|
|
334
|
-
getClassName() {
|
|
335
|
-
return "SkyMaterial";
|
|
336
|
-
}
|
|
337
|
-
/**
|
|
338
|
-
* Creates a sky material from parsed material data
|
|
339
|
-
* @param source defines the JSON representation of the material
|
|
340
|
-
* @param scene defines the hosting scene
|
|
341
|
-
* @param rootUrl defines the root URL to use to load textures and relative dependencies
|
|
342
|
-
* @returns a new sky material
|
|
343
|
-
*/
|
|
344
|
-
static Parse(source, scene, rootUrl) {
|
|
345
|
-
return SerializationHelper.Parse(() => new SkyMaterial(source.name, scene), source, scene, rootUrl);
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
__decorate([
|
|
349
|
-
serialize()
|
|
350
|
-
], SkyMaterial.prototype, "luminance", void 0);
|
|
351
|
-
__decorate([
|
|
352
|
-
serialize()
|
|
353
|
-
], SkyMaterial.prototype, "turbidity", void 0);
|
|
354
|
-
__decorate([
|
|
355
|
-
serialize()
|
|
356
|
-
], SkyMaterial.prototype, "rayleigh", void 0);
|
|
357
|
-
__decorate([
|
|
358
|
-
serialize()
|
|
359
|
-
], SkyMaterial.prototype, "mieCoefficient", void 0);
|
|
360
|
-
__decorate([
|
|
361
|
-
serialize()
|
|
362
|
-
], SkyMaterial.prototype, "mieDirectionalG", void 0);
|
|
363
|
-
__decorate([
|
|
364
|
-
serialize()
|
|
365
|
-
], SkyMaterial.prototype, "distance", void 0);
|
|
366
|
-
__decorate([
|
|
367
|
-
serialize()
|
|
368
|
-
], SkyMaterial.prototype, "inclination", void 0);
|
|
369
|
-
__decorate([
|
|
370
|
-
serialize()
|
|
371
|
-
], SkyMaterial.prototype, "azimuth", void 0);
|
|
372
|
-
__decorate([
|
|
373
|
-
serializeAsVector3()
|
|
374
|
-
], SkyMaterial.prototype, "sunPosition", void 0);
|
|
375
|
-
__decorate([
|
|
376
|
-
serialize()
|
|
377
|
-
], SkyMaterial.prototype, "useSunPosition", void 0);
|
|
378
|
-
__decorate([
|
|
379
|
-
serializeAsVector3()
|
|
380
|
-
], SkyMaterial.prototype, "cameraOffset", void 0);
|
|
381
|
-
__decorate([
|
|
382
|
-
serializeAsVector3()
|
|
383
|
-
], SkyMaterial.prototype, "up", void 0);
|
|
384
|
-
__decorate([
|
|
385
|
-
serialize()
|
|
386
|
-
], SkyMaterial.prototype, "dithering", void 0);
|
|
362
|
+
/**
|
|
363
|
+
* Serializes this material in a JSON representation
|
|
364
|
+
* @returns the serialized material object
|
|
365
|
+
*/
|
|
366
|
+
serialize() {
|
|
367
|
+
const serializationObject = super.serialize();
|
|
368
|
+
serializationObject.customType = "BABYLON.SkyMaterial";
|
|
369
|
+
return serializationObject;
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Gets the current class name of the material e.g. "SkyMaterial"
|
|
373
|
+
* Mainly use in serialization.
|
|
374
|
+
* @returns the class name
|
|
375
|
+
*/
|
|
376
|
+
getClassName() {
|
|
377
|
+
return "SkyMaterial";
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Creates a sky material from parsed material data
|
|
381
|
+
* @param source defines the JSON representation of the material
|
|
382
|
+
* @param scene defines the hosting scene
|
|
383
|
+
* @param rootUrl defines the root URL to use to load textures and relative dependencies
|
|
384
|
+
* @returns a new sky material
|
|
385
|
+
*/
|
|
386
|
+
static Parse(source, scene, rootUrl) {
|
|
387
|
+
return SerializationHelper.Parse(() => new _a(source.name, scene), source, scene, rootUrl);
|
|
388
|
+
}
|
|
389
|
+
},
|
|
390
|
+
(() => {
|
|
391
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
392
|
+
_luminance_decorators = [serialize()];
|
|
393
|
+
_turbidity_decorators = [serialize()];
|
|
394
|
+
_rayleigh_decorators = [serialize()];
|
|
395
|
+
_mieCoefficient_decorators = [serialize()];
|
|
396
|
+
_mieDirectionalG_decorators = [serialize()];
|
|
397
|
+
_distance_decorators = [serialize()];
|
|
398
|
+
_inclination_decorators = [serialize()];
|
|
399
|
+
_azimuth_decorators = [serialize()];
|
|
400
|
+
_sunPosition_decorators = [serializeAsVector3()];
|
|
401
|
+
_useSunPosition_decorators = [serialize()];
|
|
402
|
+
_cameraOffset_decorators = [serializeAsVector3()];
|
|
403
|
+
_up_decorators = [serializeAsVector3()];
|
|
404
|
+
_dithering_decorators = [serialize()];
|
|
405
|
+
__esDecorate(null, null, _luminance_decorators, { kind: "field", name: "luminance", static: false, private: false, access: { has: obj => "luminance" in obj, get: obj => obj.luminance, set: (obj, value) => { obj.luminance = value; } }, metadata: _metadata }, _luminance_initializers, _luminance_extraInitializers);
|
|
406
|
+
__esDecorate(null, null, _turbidity_decorators, { kind: "field", name: "turbidity", static: false, private: false, access: { has: obj => "turbidity" in obj, get: obj => obj.turbidity, set: (obj, value) => { obj.turbidity = value; } }, metadata: _metadata }, _turbidity_initializers, _turbidity_extraInitializers);
|
|
407
|
+
__esDecorate(null, null, _rayleigh_decorators, { kind: "field", name: "rayleigh", static: false, private: false, access: { has: obj => "rayleigh" in obj, get: obj => obj.rayleigh, set: (obj, value) => { obj.rayleigh = value; } }, metadata: _metadata }, _rayleigh_initializers, _rayleigh_extraInitializers);
|
|
408
|
+
__esDecorate(null, null, _mieCoefficient_decorators, { kind: "field", name: "mieCoefficient", static: false, private: false, access: { has: obj => "mieCoefficient" in obj, get: obj => obj.mieCoefficient, set: (obj, value) => { obj.mieCoefficient = value; } }, metadata: _metadata }, _mieCoefficient_initializers, _mieCoefficient_extraInitializers);
|
|
409
|
+
__esDecorate(null, null, _mieDirectionalG_decorators, { kind: "field", name: "mieDirectionalG", static: false, private: false, access: { has: obj => "mieDirectionalG" in obj, get: obj => obj.mieDirectionalG, set: (obj, value) => { obj.mieDirectionalG = value; } }, metadata: _metadata }, _mieDirectionalG_initializers, _mieDirectionalG_extraInitializers);
|
|
410
|
+
__esDecorate(null, null, _distance_decorators, { kind: "field", name: "distance", static: false, private: false, access: { has: obj => "distance" in obj, get: obj => obj.distance, set: (obj, value) => { obj.distance = value; } }, metadata: _metadata }, _distance_initializers, _distance_extraInitializers);
|
|
411
|
+
__esDecorate(null, null, _inclination_decorators, { kind: "field", name: "inclination", static: false, private: false, access: { has: obj => "inclination" in obj, get: obj => obj.inclination, set: (obj, value) => { obj.inclination = value; } }, metadata: _metadata }, _inclination_initializers, _inclination_extraInitializers);
|
|
412
|
+
__esDecorate(null, null, _azimuth_decorators, { kind: "field", name: "azimuth", static: false, private: false, access: { has: obj => "azimuth" in obj, get: obj => obj.azimuth, set: (obj, value) => { obj.azimuth = value; } }, metadata: _metadata }, _azimuth_initializers, _azimuth_extraInitializers);
|
|
413
|
+
__esDecorate(null, null, _sunPosition_decorators, { kind: "field", name: "sunPosition", static: false, private: false, access: { has: obj => "sunPosition" in obj, get: obj => obj.sunPosition, set: (obj, value) => { obj.sunPosition = value; } }, metadata: _metadata }, _sunPosition_initializers, _sunPosition_extraInitializers);
|
|
414
|
+
__esDecorate(null, null, _useSunPosition_decorators, { kind: "field", name: "useSunPosition", static: false, private: false, access: { has: obj => "useSunPosition" in obj, get: obj => obj.useSunPosition, set: (obj, value) => { obj.useSunPosition = value; } }, metadata: _metadata }, _useSunPosition_initializers, _useSunPosition_extraInitializers);
|
|
415
|
+
__esDecorate(null, null, _cameraOffset_decorators, { kind: "field", name: "cameraOffset", static: false, private: false, access: { has: obj => "cameraOffset" in obj, get: obj => obj.cameraOffset, set: (obj, value) => { obj.cameraOffset = value; } }, metadata: _metadata }, _cameraOffset_initializers, _cameraOffset_extraInitializers);
|
|
416
|
+
__esDecorate(null, null, _up_decorators, { kind: "field", name: "up", static: false, private: false, access: { has: obj => "up" in obj, get: obj => obj.up, set: (obj, value) => { obj.up = value; } }, metadata: _metadata }, _up_initializers, _up_extraInitializers);
|
|
417
|
+
__esDecorate(null, null, _dithering_decorators, { kind: "field", name: "dithering", static: false, private: false, access: { has: obj => "dithering" in obj, get: obj => obj.dithering, set: (obj, value) => { obj.dithering = value; } }, metadata: _metadata }, _dithering_initializers, _dithering_extraInitializers);
|
|
418
|
+
if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
419
|
+
})(),
|
|
420
|
+
_a;
|
|
421
|
+
})();
|
|
422
|
+
export { SkyMaterial };
|
|
387
423
|
RegisterClass("BABYLON.SkyMaterial", SkyMaterial);
|
|
388
424
|
//# sourceMappingURL=skyMaterial.js.map
|