@babylonjs/core 5.55.0 → 5.56.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/Engines/WebGL/webGLPipelineContext.d.ts +30 -35
- package/Engines/WebGL/webGLPipelineContext.js +399 -94
- package/Engines/WebGL/webGLPipelineContext.js.map +1 -1
- package/Engines/thinEngine.js +2 -2
- package/Engines/thinEngine.js.map +1 -1
- package/Layers/highlightLayer.js +12 -7
- package/Layers/highlightLayer.js.map +1 -1
- package/Lights/Shadows/cascadedShadowGenerator.d.ts +2 -2
- package/Lights/Shadows/cascadedShadowGenerator.js.map +1 -1
- package/Materials/Textures/Filtering/hdrFiltering.js +4 -0
- package/Materials/Textures/Filtering/hdrFiltering.js.map +1 -1
- package/Materials/effect.d.ts +35 -35
- package/Materials/effect.js +375 -24
- package/Materials/effect.js.map +1 -1
- package/Physics/v2/physicsBody.d.ts +2 -1
- package/Physics/v2/physicsBody.js.map +1 -1
- package/PostProcesses/postProcess.d.ts +5 -0
- package/PostProcesses/postProcess.js +9 -1
- package/PostProcesses/postProcess.js.map +1 -1
- package/Sprites/spriteManager.js +3 -0
- package/Sprites/spriteManager.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,24 +1,3 @@
|
|
|
1
|
-
const floatNCache = [
|
|
2
|
-
"Int",
|
|
3
|
-
"Int2",
|
|
4
|
-
"Int3",
|
|
5
|
-
"Int4",
|
|
6
|
-
"UInt",
|
|
7
|
-
"UInt2",
|
|
8
|
-
"UInt3",
|
|
9
|
-
"UInt4",
|
|
10
|
-
"Vector2",
|
|
11
|
-
"Vector3",
|
|
12
|
-
"Vector4",
|
|
13
|
-
"Float2",
|
|
14
|
-
"Float",
|
|
15
|
-
"Float3",
|
|
16
|
-
"Float4",
|
|
17
|
-
"Quaternion",
|
|
18
|
-
"Color3",
|
|
19
|
-
"Color4",
|
|
20
|
-
"DirectColor4",
|
|
21
|
-
];
|
|
22
1
|
/** @internal */
|
|
23
2
|
export class WebGLPipelineContext {
|
|
24
3
|
constructor() {
|
|
@@ -27,51 +6,6 @@ export class WebGLPipelineContext {
|
|
|
27
6
|
this.fragmentCompilationError = null;
|
|
28
7
|
this.programLinkError = null;
|
|
29
8
|
this.programValidationError = null;
|
|
30
|
-
const args = [];
|
|
31
|
-
const prepareArray = function () {
|
|
32
|
-
args.length = 0;
|
|
33
|
-
Array.prototype.push.apply(args, arguments);
|
|
34
|
-
args[0] = this._uniforms[args[0]];
|
|
35
|
-
};
|
|
36
|
-
const proxyFunction = (functionName) => {
|
|
37
|
-
const cacheFunction = floatNCache.includes(functionName.substring(3)) && "FloatN";
|
|
38
|
-
if (cacheFunction) {
|
|
39
|
-
const cacheFunc = this[`_cache${cacheFunction}`];
|
|
40
|
-
return function () {
|
|
41
|
-
const func = this.engine[functionName];
|
|
42
|
-
prepareArray.apply(this, arguments);
|
|
43
|
-
if (cacheFunc.apply(this, arguments)) {
|
|
44
|
-
if (!func.apply(this.engine, args)) {
|
|
45
|
-
this._valueCache[arguments[0]] = null;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
return function () {
|
|
52
|
-
const func = this.engine[functionName];
|
|
53
|
-
prepareArray.apply(this, arguments);
|
|
54
|
-
if (arguments[1] !== undefined) {
|
|
55
|
-
this._valueCache[arguments[0]] = null;
|
|
56
|
-
func.apply(this.engine, args);
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
["Int?", "UInt?", "IntArray?", "UIntArray?", "Array?", "Float?", "Matrices", "Matrix3x3", "Matrix2x2"].forEach((functionName) => {
|
|
62
|
-
const name = `set${functionName}`;
|
|
63
|
-
if (this[name]) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
if (name.endsWith("?")) {
|
|
67
|
-
["", 2, 3, 4].forEach((n) => {
|
|
68
|
-
this[(name.slice(0, -1) + n)] = this[(name.slice(0, -1) + n)] || proxyFunction(name.slice(0, -1) + n).bind(this);
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
this[name] = this[name] || proxyFunction(name).bind(this);
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
9
|
}
|
|
76
10
|
get isAsync() {
|
|
77
11
|
return this.isParallelCompiled;
|
|
@@ -138,43 +72,310 @@ export class WebGLPipelineContext {
|
|
|
138
72
|
/**
|
|
139
73
|
* @internal
|
|
140
74
|
*/
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
let cache = this._valueCache[arguments[0]];
|
|
147
|
-
if (!cache || cache.length !== arguments.length - 1) {
|
|
148
|
-
cache = Array.prototype.slice.call(arguments, 1);
|
|
149
|
-
this._valueCache[arguments[0]] = cache;
|
|
75
|
+
_cacheFloat2(uniformName, x, y) {
|
|
76
|
+
let cache = this._valueCache[uniformName];
|
|
77
|
+
if (!cache || cache.length !== 2) {
|
|
78
|
+
cache = [x, y];
|
|
79
|
+
this._valueCache[uniformName] = cache;
|
|
150
80
|
return true;
|
|
151
81
|
}
|
|
152
82
|
let changed = false;
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
83
|
+
if (cache[0] !== x) {
|
|
84
|
+
cache[0] = x;
|
|
85
|
+
changed = true;
|
|
86
|
+
}
|
|
87
|
+
if (cache[1] !== y) {
|
|
88
|
+
cache[1] = y;
|
|
89
|
+
changed = true;
|
|
158
90
|
}
|
|
159
91
|
return changed;
|
|
160
92
|
}
|
|
161
93
|
/**
|
|
162
94
|
* @internal
|
|
163
95
|
*/
|
|
164
|
-
|
|
165
|
-
|
|
96
|
+
_cacheFloat3(uniformName, x, y, z) {
|
|
97
|
+
let cache = this._valueCache[uniformName];
|
|
98
|
+
if (!cache || cache.length !== 3) {
|
|
99
|
+
cache = [x, y, z];
|
|
100
|
+
this._valueCache[uniformName] = cache;
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
let changed = false;
|
|
104
|
+
if (cache[0] !== x) {
|
|
105
|
+
cache[0] = x;
|
|
106
|
+
changed = true;
|
|
107
|
+
}
|
|
108
|
+
if (cache[1] !== y) {
|
|
109
|
+
cache[1] = y;
|
|
110
|
+
changed = true;
|
|
111
|
+
}
|
|
112
|
+
if (cache[2] !== z) {
|
|
113
|
+
cache[2] = z;
|
|
114
|
+
changed = true;
|
|
115
|
+
}
|
|
116
|
+
return changed;
|
|
166
117
|
}
|
|
167
118
|
/**
|
|
168
119
|
* @internal
|
|
169
120
|
*/
|
|
170
|
-
|
|
171
|
-
|
|
121
|
+
_cacheFloat4(uniformName, x, y, z, w) {
|
|
122
|
+
let cache = this._valueCache[uniformName];
|
|
123
|
+
if (!cache || cache.length !== 4) {
|
|
124
|
+
cache = [x, y, z, w];
|
|
125
|
+
this._valueCache[uniformName] = cache;
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
let changed = false;
|
|
129
|
+
if (cache[0] !== x) {
|
|
130
|
+
cache[0] = x;
|
|
131
|
+
changed = true;
|
|
132
|
+
}
|
|
133
|
+
if (cache[1] !== y) {
|
|
134
|
+
cache[1] = y;
|
|
135
|
+
changed = true;
|
|
136
|
+
}
|
|
137
|
+
if (cache[2] !== z) {
|
|
138
|
+
cache[2] = z;
|
|
139
|
+
changed = true;
|
|
140
|
+
}
|
|
141
|
+
if (cache[3] !== w) {
|
|
142
|
+
cache[3] = w;
|
|
143
|
+
changed = true;
|
|
144
|
+
}
|
|
145
|
+
return changed;
|
|
172
146
|
}
|
|
173
147
|
/**
|
|
174
|
-
*
|
|
148
|
+
* Sets an integer value on a uniform variable.
|
|
149
|
+
* @param uniformName Name of the variable.
|
|
150
|
+
* @param value Value to be set.
|
|
175
151
|
*/
|
|
176
|
-
|
|
177
|
-
|
|
152
|
+
setInt(uniformName, value) {
|
|
153
|
+
const cache = this._valueCache[uniformName];
|
|
154
|
+
if (cache !== undefined && cache === value) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
if (this.engine.setInt(this._uniforms[uniformName], value)) {
|
|
158
|
+
this._valueCache[uniformName] = value;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Sets a int2 on a uniform variable.
|
|
163
|
+
* @param uniformName Name of the variable.
|
|
164
|
+
* @param x First int in int2.
|
|
165
|
+
* @param y Second int in int2.
|
|
166
|
+
*/
|
|
167
|
+
setInt2(uniformName, x, y) {
|
|
168
|
+
if (this._cacheFloat2(uniformName, x, y)) {
|
|
169
|
+
if (!this.engine.setInt2(this._uniforms[uniformName], x, y)) {
|
|
170
|
+
this._valueCache[uniformName] = null;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Sets a int3 on a uniform variable.
|
|
176
|
+
* @param uniformName Name of the variable.
|
|
177
|
+
* @param x First int in int3.
|
|
178
|
+
* @param y Second int in int3.
|
|
179
|
+
* @param z Third int in int3.
|
|
180
|
+
*/
|
|
181
|
+
setInt3(uniformName, x, y, z) {
|
|
182
|
+
if (this._cacheFloat3(uniformName, x, y, z)) {
|
|
183
|
+
if (!this.engine.setInt3(this._uniforms[uniformName], x, y, z)) {
|
|
184
|
+
this._valueCache[uniformName] = null;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Sets a int4 on a uniform variable.
|
|
190
|
+
* @param uniformName Name of the variable.
|
|
191
|
+
* @param x First int in int4.
|
|
192
|
+
* @param y Second int in int4.
|
|
193
|
+
* @param z Third int in int4.
|
|
194
|
+
* @param w Fourth int in int4.
|
|
195
|
+
*/
|
|
196
|
+
setInt4(uniformName, x, y, z, w) {
|
|
197
|
+
if (this._cacheFloat4(uniformName, x, y, z, w)) {
|
|
198
|
+
if (!this.engine.setInt4(this._uniforms[uniformName], x, y, z, w)) {
|
|
199
|
+
this._valueCache[uniformName] = null;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Sets an int array on a uniform variable.
|
|
205
|
+
* @param uniformName Name of the variable.
|
|
206
|
+
* @param array array to be set.
|
|
207
|
+
*/
|
|
208
|
+
setIntArray(uniformName, array) {
|
|
209
|
+
this._valueCache[uniformName] = null;
|
|
210
|
+
this.engine.setIntArray(this._uniforms[uniformName], array);
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Sets an int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
|
|
214
|
+
* @param uniformName Name of the variable.
|
|
215
|
+
* @param array array to be set.
|
|
216
|
+
*/
|
|
217
|
+
setIntArray2(uniformName, array) {
|
|
218
|
+
this._valueCache[uniformName] = null;
|
|
219
|
+
this.engine.setIntArray2(this._uniforms[uniformName], array);
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Sets an int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
|
|
223
|
+
* @param uniformName Name of the variable.
|
|
224
|
+
* @param array array to be set.
|
|
225
|
+
*/
|
|
226
|
+
setIntArray3(uniformName, array) {
|
|
227
|
+
this._valueCache[uniformName] = null;
|
|
228
|
+
this.engine.setIntArray3(this._uniforms[uniformName], array);
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Sets an int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
|
|
232
|
+
* @param uniformName Name of the variable.
|
|
233
|
+
* @param array array to be set.
|
|
234
|
+
*/
|
|
235
|
+
setIntArray4(uniformName, array) {
|
|
236
|
+
this._valueCache[uniformName] = null;
|
|
237
|
+
this.engine.setIntArray4(this._uniforms[uniformName], array);
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Sets an unsigned integer value on a uniform variable.
|
|
241
|
+
* @param uniformName Name of the variable.
|
|
242
|
+
* @param value Value to be set.
|
|
243
|
+
*/
|
|
244
|
+
setUInt(uniformName, value) {
|
|
245
|
+
const cache = this._valueCache[uniformName];
|
|
246
|
+
if (cache !== undefined && cache === value) {
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
if (this.engine.setUInt(this._uniforms[uniformName], value)) {
|
|
250
|
+
this._valueCache[uniformName] = value;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Sets an unsigned int2 value on a uniform variable.
|
|
255
|
+
* @param uniformName Name of the variable.
|
|
256
|
+
* @param x First unsigned int in uint2.
|
|
257
|
+
* @param y Second unsigned int in uint2.
|
|
258
|
+
*/
|
|
259
|
+
setUInt2(uniformName, x, y) {
|
|
260
|
+
if (this._cacheFloat2(uniformName, x, y)) {
|
|
261
|
+
if (!this.engine.setUInt2(this._uniforms[uniformName], x, y)) {
|
|
262
|
+
this._valueCache[uniformName] = null;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Sets an unsigned int3 value on a uniform variable.
|
|
268
|
+
* @param uniformName Name of the variable.
|
|
269
|
+
* @param x First unsigned int in uint3.
|
|
270
|
+
* @param y Second unsigned int in uint3.
|
|
271
|
+
* @param z Third unsigned int in uint3.
|
|
272
|
+
*/
|
|
273
|
+
setUInt3(uniformName, x, y, z) {
|
|
274
|
+
if (this._cacheFloat3(uniformName, x, y, z)) {
|
|
275
|
+
if (!this.engine.setUInt3(this._uniforms[uniformName], x, y, z)) {
|
|
276
|
+
this._valueCache[uniformName] = null;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Sets an unsigned int4 value on a uniform variable.
|
|
282
|
+
* @param uniformName Name of the variable.
|
|
283
|
+
* @param x First unsigned int in uint4.
|
|
284
|
+
* @param y Second unsigned int in uint4.
|
|
285
|
+
* @param z Third unsigned int in uint4.
|
|
286
|
+
* @param w Fourth unsigned int in uint4.
|
|
287
|
+
*/
|
|
288
|
+
setUInt4(uniformName, x, y, z, w) {
|
|
289
|
+
if (this._cacheFloat4(uniformName, x, y, z, w)) {
|
|
290
|
+
if (!this.engine.setUInt4(this._uniforms[uniformName], x, y, z, w)) {
|
|
291
|
+
this._valueCache[uniformName] = null;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Sets an unsigned int array on a uniform variable.
|
|
297
|
+
* @param uniformName Name of the variable.
|
|
298
|
+
* @param array array to be set.
|
|
299
|
+
*/
|
|
300
|
+
setUIntArray(uniformName, array) {
|
|
301
|
+
this._valueCache[uniformName] = null;
|
|
302
|
+
this.engine.setUIntArray(this._uniforms[uniformName], array);
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Sets an unsigned int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
|
|
306
|
+
* @param uniformName Name of the variable.
|
|
307
|
+
* @param array array to be set.
|
|
308
|
+
*/
|
|
309
|
+
setUIntArray2(uniformName, array) {
|
|
310
|
+
this._valueCache[uniformName] = null;
|
|
311
|
+
this.engine.setUIntArray2(this._uniforms[uniformName], array);
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Sets an unsigned int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
|
|
315
|
+
* @param uniformName Name of the variable.
|
|
316
|
+
* @param array array to be set.
|
|
317
|
+
*/
|
|
318
|
+
setUIntArray3(uniformName, array) {
|
|
319
|
+
this._valueCache[uniformName] = null;
|
|
320
|
+
this.engine.setUIntArray3(this._uniforms[uniformName], array);
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Sets an unsigned int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
|
|
324
|
+
* @param uniformName Name of the variable.
|
|
325
|
+
* @param array array to be set.
|
|
326
|
+
*/
|
|
327
|
+
setUIntArray4(uniformName, array) {
|
|
328
|
+
this._valueCache[uniformName] = null;
|
|
329
|
+
this.engine.setUIntArray4(this._uniforms[uniformName], array);
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Sets an array on a uniform variable.
|
|
333
|
+
* @param uniformName Name of the variable.
|
|
334
|
+
* @param array array to be set.
|
|
335
|
+
*/
|
|
336
|
+
setArray(uniformName, array) {
|
|
337
|
+
this._valueCache[uniformName] = null;
|
|
338
|
+
this.engine.setArray(this._uniforms[uniformName], array);
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Sets an array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
|
|
342
|
+
* @param uniformName Name of the variable.
|
|
343
|
+
* @param array array to be set.
|
|
344
|
+
*/
|
|
345
|
+
setArray2(uniformName, array) {
|
|
346
|
+
this._valueCache[uniformName] = null;
|
|
347
|
+
this.engine.setArray2(this._uniforms[uniformName], array);
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Sets an array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
|
|
351
|
+
* @param uniformName Name of the variable.
|
|
352
|
+
* @param array array to be set.
|
|
353
|
+
* @returns this effect.
|
|
354
|
+
*/
|
|
355
|
+
setArray3(uniformName, array) {
|
|
356
|
+
this._valueCache[uniformName] = null;
|
|
357
|
+
this.engine.setArray3(this._uniforms[uniformName], array);
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Sets an array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
|
|
361
|
+
* @param uniformName Name of the variable.
|
|
362
|
+
* @param array array to be set.
|
|
363
|
+
*/
|
|
364
|
+
setArray4(uniformName, array) {
|
|
365
|
+
this._valueCache[uniformName] = null;
|
|
366
|
+
this.engine.setArray4(this._uniforms[uniformName], array);
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Sets matrices on a uniform variable.
|
|
370
|
+
* @param uniformName Name of the variable.
|
|
371
|
+
* @param matrices matrices to be set.
|
|
372
|
+
*/
|
|
373
|
+
setMatrices(uniformName, matrices) {
|
|
374
|
+
if (!matrices) {
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
this._valueCache[uniformName] = null;
|
|
378
|
+
this.engine.setMatrices(this._uniforms[uniformName], matrices);
|
|
178
379
|
}
|
|
179
380
|
/**
|
|
180
381
|
* Sets matrix on a uniform variable.
|
|
@@ -188,13 +389,63 @@ export class WebGLPipelineContext {
|
|
|
188
389
|
}
|
|
189
390
|
}
|
|
190
391
|
}
|
|
392
|
+
/**
|
|
393
|
+
* Sets a 3x3 matrix on a uniform variable. (Specified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
|
|
394
|
+
* @param uniformName Name of the variable.
|
|
395
|
+
* @param matrix matrix to be set.
|
|
396
|
+
*/
|
|
397
|
+
setMatrix3x3(uniformName, matrix) {
|
|
398
|
+
this._valueCache[uniformName] = null;
|
|
399
|
+
this.engine.setMatrix3x3(this._uniforms[uniformName], matrix);
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Sets a 2x2 matrix on a uniform variable. (Specified as [1,2,3,4] will result in [1,2][3,4] matrix)
|
|
403
|
+
* @param uniformName Name of the variable.
|
|
404
|
+
* @param matrix matrix to be set.
|
|
405
|
+
*/
|
|
406
|
+
setMatrix2x2(uniformName, matrix) {
|
|
407
|
+
this._valueCache[uniformName] = null;
|
|
408
|
+
this.engine.setMatrix2x2(this._uniforms[uniformName], matrix);
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Sets a float on a uniform variable.
|
|
412
|
+
* @param uniformName Name of the variable.
|
|
413
|
+
* @param value value to be set.
|
|
414
|
+
* @returns this effect.
|
|
415
|
+
*/
|
|
416
|
+
setFloat(uniformName, value) {
|
|
417
|
+
const cache = this._valueCache[uniformName];
|
|
418
|
+
if (cache !== undefined && cache === value) {
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
if (this.engine.setFloat(this._uniforms[uniformName], value)) {
|
|
422
|
+
this._valueCache[uniformName] = value;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
191
425
|
/**
|
|
192
426
|
* Sets a Vector2 on a uniform variable.
|
|
193
427
|
* @param uniformName Name of the variable.
|
|
194
428
|
* @param vector2 vector2 to be set.
|
|
195
429
|
*/
|
|
196
430
|
setVector2(uniformName, vector2) {
|
|
197
|
-
this.
|
|
431
|
+
if (this._cacheFloat2(uniformName, vector2.x, vector2.y)) {
|
|
432
|
+
if (!this.engine.setFloat2(this._uniforms[uniformName], vector2.x, vector2.y)) {
|
|
433
|
+
this._valueCache[uniformName] = null;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Sets a float2 on a uniform variable.
|
|
439
|
+
* @param uniformName Name of the variable.
|
|
440
|
+
* @param x First float in float2.
|
|
441
|
+
* @param y Second float in float2.
|
|
442
|
+
*/
|
|
443
|
+
setFloat2(uniformName, x, y) {
|
|
444
|
+
if (this._cacheFloat2(uniformName, x, y)) {
|
|
445
|
+
if (!this.engine.setFloat2(this._uniforms[uniformName], x, y)) {
|
|
446
|
+
this._valueCache[uniformName] = null;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
198
449
|
}
|
|
199
450
|
/**
|
|
200
451
|
* Sets a Vector3 on a uniform variable.
|
|
@@ -202,7 +453,25 @@ export class WebGLPipelineContext {
|
|
|
202
453
|
* @param vector3 Value to be set.
|
|
203
454
|
*/
|
|
204
455
|
setVector3(uniformName, vector3) {
|
|
205
|
-
this.
|
|
456
|
+
if (this._cacheFloat3(uniformName, vector3.x, vector3.y, vector3.z)) {
|
|
457
|
+
if (!this.engine.setFloat3(this._uniforms[uniformName], vector3.x, vector3.y, vector3.z)) {
|
|
458
|
+
this._valueCache[uniformName] = null;
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* Sets a float3 on a uniform variable.
|
|
464
|
+
* @param uniformName Name of the variable.
|
|
465
|
+
* @param x First float in float3.
|
|
466
|
+
* @param y Second float in float3.
|
|
467
|
+
* @param z Third float in float3.
|
|
468
|
+
*/
|
|
469
|
+
setFloat3(uniformName, x, y, z) {
|
|
470
|
+
if (this._cacheFloat3(uniformName, x, y, z)) {
|
|
471
|
+
if (!this.engine.setFloat3(this._uniforms[uniformName], x, y, z)) {
|
|
472
|
+
this._valueCache[uniformName] = null;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
206
475
|
}
|
|
207
476
|
/**
|
|
208
477
|
* Sets a Vector4 on a uniform variable.
|
|
@@ -210,7 +479,11 @@ export class WebGLPipelineContext {
|
|
|
210
479
|
* @param vector4 Value to be set.
|
|
211
480
|
*/
|
|
212
481
|
setVector4(uniformName, vector4) {
|
|
213
|
-
this.
|
|
482
|
+
if (this._cacheFloat4(uniformName, vector4.x, vector4.y, vector4.z, vector4.w)) {
|
|
483
|
+
if (!this.engine.setFloat4(this._uniforms[uniformName], vector4.x, vector4.y, vector4.z, vector4.w)) {
|
|
484
|
+
this._valueCache[uniformName] = null;
|
|
485
|
+
}
|
|
486
|
+
}
|
|
214
487
|
}
|
|
215
488
|
/**
|
|
216
489
|
* Sets a Quaternion on a uniform variable.
|
|
@@ -218,7 +491,27 @@ export class WebGLPipelineContext {
|
|
|
218
491
|
* @param quaternion Value to be set.
|
|
219
492
|
*/
|
|
220
493
|
setQuaternion(uniformName, quaternion) {
|
|
221
|
-
this.
|
|
494
|
+
if (this._cacheFloat4(uniformName, quaternion.x, quaternion.y, quaternion.z, quaternion.w)) {
|
|
495
|
+
if (!this.engine.setFloat4(this._uniforms[uniformName], quaternion.x, quaternion.y, quaternion.z, quaternion.w)) {
|
|
496
|
+
this._valueCache[uniformName] = null;
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* Sets a float4 on a uniform variable.
|
|
502
|
+
* @param uniformName Name of the variable.
|
|
503
|
+
* @param x First float in float4.
|
|
504
|
+
* @param y Second float in float4.
|
|
505
|
+
* @param z Third float in float4.
|
|
506
|
+
* @param w Fourth float in float4.
|
|
507
|
+
* @returns this effect.
|
|
508
|
+
*/
|
|
509
|
+
setFloat4(uniformName, x, y, z, w) {
|
|
510
|
+
if (this._cacheFloat4(uniformName, x, y, z, w)) {
|
|
511
|
+
if (!this.engine.setFloat4(this._uniforms[uniformName], x, y, z, w)) {
|
|
512
|
+
this._valueCache[uniformName] = null;
|
|
513
|
+
}
|
|
514
|
+
}
|
|
222
515
|
}
|
|
223
516
|
/**
|
|
224
517
|
* Sets a Color3 on a uniform variable.
|
|
@@ -226,7 +519,11 @@ export class WebGLPipelineContext {
|
|
|
226
519
|
* @param color3 Value to be set.
|
|
227
520
|
*/
|
|
228
521
|
setColor3(uniformName, color3) {
|
|
229
|
-
this.
|
|
522
|
+
if (this._cacheFloat3(uniformName, color3.r, color3.g, color3.b)) {
|
|
523
|
+
if (!this.engine.setFloat3(this._uniforms[uniformName], color3.r, color3.g, color3.b)) {
|
|
524
|
+
this._valueCache[uniformName] = null;
|
|
525
|
+
}
|
|
526
|
+
}
|
|
230
527
|
}
|
|
231
528
|
/**
|
|
232
529
|
* Sets a Color4 on a uniform variable.
|
|
@@ -235,7 +532,11 @@ export class WebGLPipelineContext {
|
|
|
235
532
|
* @param alpha Alpha value to be set.
|
|
236
533
|
*/
|
|
237
534
|
setColor4(uniformName, color3, alpha) {
|
|
238
|
-
this.
|
|
535
|
+
if (this._cacheFloat4(uniformName, color3.r, color3.g, color3.b, alpha)) {
|
|
536
|
+
if (!this.engine.setFloat4(this._uniforms[uniformName], color3.r, color3.g, color3.b, alpha)) {
|
|
537
|
+
this._valueCache[uniformName] = null;
|
|
538
|
+
}
|
|
539
|
+
}
|
|
239
540
|
}
|
|
240
541
|
/**
|
|
241
542
|
* Sets a Color4 on a uniform variable
|
|
@@ -243,7 +544,11 @@ export class WebGLPipelineContext {
|
|
|
243
544
|
* @param color4 defines the value to be set
|
|
244
545
|
*/
|
|
245
546
|
setDirectColor4(uniformName, color4) {
|
|
246
|
-
this.
|
|
547
|
+
if (this._cacheFloat4(uniformName, color4.r, color4.g, color4.b, color4.a)) {
|
|
548
|
+
if (!this.engine.setFloat4(this._uniforms[uniformName], color4.r, color4.g, color4.b, color4.a)) {
|
|
549
|
+
this._valueCache[uniformName] = null;
|
|
550
|
+
}
|
|
551
|
+
}
|
|
247
552
|
}
|
|
248
553
|
_getVertexShaderCode() {
|
|
249
554
|
return this.vertexShader ? this.engine._getShaderSource(this.vertexShader) : null;
|