@galacean/engine-core 1.2.0-alpha.0 → 1.2.0-alpha.10
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/dist/main.js +1070 -875
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +1070 -875
- package/dist/module.js +1165 -970
- package/dist/module.js.map +1 -1
- package/package.json +3 -3
- package/types/2d/atlas/types.d.ts +2 -0
- package/types/2d/text/TextRenderer.d.ts +1 -0
- package/types/Camera.d.ts +11 -5
- package/types/Canvas.d.ts +2 -1
- package/types/Engine.d.ts +4 -2
- package/types/Scene.d.ts +5 -0
- package/types/SystemInfo.d.ts +2 -0
- package/types/Utils.d.ts +6 -0
- package/types/asset/AssetType.d.ts +2 -0
- package/types/asset/Loader.d.ts +7 -0
- package/types/asset/ResourceManager.d.ts +2 -0
- package/types/input/InputManager.d.ts +0 -2
- package/types/input/interface/IInput.d.ts +0 -8
- package/types/mesh/PrimitiveMesh.d.ts +22 -0
- package/types/particle/modules/MainModule.d.ts +2 -0
- package/types/particle/modules/shape/BaseShape.d.ts +2 -2
- package/types/particle/modules/shape/BoxShape.d.ts +2 -1
- package/types/particle/modules/shape/CircleShape.d.ts +2 -1
- package/types/particle/modules/shape/ConeShape.d.ts +2 -1
- package/types/particle/modules/shape/HemisphereShape.d.ts +2 -1
- package/types/particle/modules/shape/SphereShape.d.ts +2 -1
- package/types/particle/modules/shape/index.d.ts +1 -0
- package/types/physics/HitResult.d.ts +3 -0
- package/types/shaderlib/ShaderFactory.d.ts +6 -1
- package/types/shadow/CascadedShadowCasterPass.d.ts +0 -1
- package/types/texture/Texture.d.ts +1 -0
- package/types/texture/enums/TextureFormat.d.ts +28 -26
package/dist/main.js
CHANGED
|
@@ -59,347 +59,6 @@ function _inherits(subClass, superClass) {
|
|
|
59
59
|
if (superClass) _set_prototype_of(subClass, superClass);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
/**
|
|
63
|
-
* Common utility methods for math operations.
|
|
64
|
-
*/ var MathUtil = /*#__PURE__*/ function() {
|
|
65
|
-
function MathUtil() {}
|
|
66
|
-
/**
|
|
67
|
-
* Clamps the specified value.
|
|
68
|
-
* @param v - The specified value
|
|
69
|
-
* @param min - The min value
|
|
70
|
-
* @param max - The max value
|
|
71
|
-
* @returns The result of clamping a value between min and max
|
|
72
|
-
*/ MathUtil.clamp = function clamp(v, min, max) {
|
|
73
|
-
return Math.max(min, Math.min(max, v));
|
|
74
|
-
};
|
|
75
|
-
/**
|
|
76
|
-
* Checks if a and b are almost equals.
|
|
77
|
-
* The absolute value of the difference between a and b is close to zero.
|
|
78
|
-
* @param a - The left value to compare
|
|
79
|
-
* @param b - The right value to compare
|
|
80
|
-
* @returns True if a almost equal to b, false otherwise
|
|
81
|
-
*/ MathUtil.equals = function equals(a, b) {
|
|
82
|
-
return Math.abs(a - b) <= MathUtil.zeroTolerance;
|
|
83
|
-
};
|
|
84
|
-
/**
|
|
85
|
-
* Determines whether the specified v is pow2.
|
|
86
|
-
* @param v - The specified v
|
|
87
|
-
* @returns True if the specified v is pow2, false otherwise
|
|
88
|
-
*/ MathUtil.isPowerOf2 = function isPowerOf2(v) {
|
|
89
|
-
return (v & v - 1) === 0;
|
|
90
|
-
};
|
|
91
|
-
/**
|
|
92
|
-
* Modify the specified r from radian to degree.
|
|
93
|
-
* @param r - The specified r
|
|
94
|
-
* @returns The degree value
|
|
95
|
-
*/ MathUtil.radianToDegree = function radianToDegree(r) {
|
|
96
|
-
return r * MathUtil.radToDegreeFactor;
|
|
97
|
-
};
|
|
98
|
-
/**
|
|
99
|
-
* Modify the specified d from degree to radian.
|
|
100
|
-
* @param d - The specified d
|
|
101
|
-
* @returns The radian value
|
|
102
|
-
*/ MathUtil.degreeToRadian = function degreeToRadian(d) {
|
|
103
|
-
return d * MathUtil.degreeToRadFactor;
|
|
104
|
-
};
|
|
105
|
-
return MathUtil;
|
|
106
|
-
}();
|
|
107
|
-
(function() {
|
|
108
|
-
/** The value for which all absolute numbers smaller than are considered equal to zero. */ MathUtil.zeroTolerance = 1e-6;
|
|
109
|
-
})();
|
|
110
|
-
(function() {
|
|
111
|
-
/** The conversion factor that radian to degree. */ MathUtil.radToDegreeFactor = 180 / Math.PI;
|
|
112
|
-
})();
|
|
113
|
-
(function() {
|
|
114
|
-
/** The conversion factor that degree to radian. */ MathUtil.degreeToRadFactor = Math.PI / 180;
|
|
115
|
-
})();
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Describes a color in the from of RGBA (in order: R, G, B, A).
|
|
119
|
-
*/ var Color = /*#__PURE__*/ function() {
|
|
120
|
-
function Color(r, g, b, a) {
|
|
121
|
-
if (r === void 0) r = 1;
|
|
122
|
-
if (g === void 0) g = 1;
|
|
123
|
-
if (b === void 0) b = 1;
|
|
124
|
-
if (a === void 0) a = 1;
|
|
125
|
-
/** @internal */ this._onValueChanged = null;
|
|
126
|
-
this._r = r;
|
|
127
|
-
this._g = g;
|
|
128
|
-
this._b = b;
|
|
129
|
-
this._a = a;
|
|
130
|
-
}
|
|
131
|
-
var _proto = Color.prototype;
|
|
132
|
-
/**
|
|
133
|
-
* Set the value of this color.
|
|
134
|
-
* @param r - The red component of the color
|
|
135
|
-
* @param g - The green component of the color
|
|
136
|
-
* @param b - The blue component of the color
|
|
137
|
-
* @param a - The alpha component of the color
|
|
138
|
-
* @returns This color.
|
|
139
|
-
*/ _proto.set = function set(r, g, b, a) {
|
|
140
|
-
this._r = r;
|
|
141
|
-
this._g = g;
|
|
142
|
-
this._b = b;
|
|
143
|
-
this._a = a;
|
|
144
|
-
this._onValueChanged && this._onValueChanged();
|
|
145
|
-
return this;
|
|
146
|
-
};
|
|
147
|
-
/**
|
|
148
|
-
* Determines the sum of this color and the specified color.
|
|
149
|
-
* @param color - The specified color
|
|
150
|
-
* @returns The added color
|
|
151
|
-
*/ _proto.add = function add(color) {
|
|
152
|
-
this._r += color._r;
|
|
153
|
-
this._g += color._g;
|
|
154
|
-
this._b += color._b;
|
|
155
|
-
this._a += color._a;
|
|
156
|
-
this._onValueChanged && this._onValueChanged();
|
|
157
|
-
return this;
|
|
158
|
-
};
|
|
159
|
-
/**
|
|
160
|
-
* Scale this color by the given value.
|
|
161
|
-
* @param s - The amount by which to scale the color
|
|
162
|
-
* @returns The scaled color
|
|
163
|
-
*/ _proto.scale = function scale(s) {
|
|
164
|
-
this._r *= s;
|
|
165
|
-
this._g *= s;
|
|
166
|
-
this._b *= s;
|
|
167
|
-
this._a *= s;
|
|
168
|
-
this._onValueChanged && this._onValueChanged();
|
|
169
|
-
return this;
|
|
170
|
-
};
|
|
171
|
-
/**
|
|
172
|
-
* Creates a clone of this color.
|
|
173
|
-
* @returns A clone of this color
|
|
174
|
-
*/ _proto.clone = function clone() {
|
|
175
|
-
var ret = new Color(this._r, this._g, this._b, this._a);
|
|
176
|
-
return ret;
|
|
177
|
-
};
|
|
178
|
-
/**
|
|
179
|
-
* Copy from color like object.
|
|
180
|
-
* @param source - Color like object.
|
|
181
|
-
* @returns This vector
|
|
182
|
-
*/ _proto.copyFrom = function copyFrom(source) {
|
|
183
|
-
this._r = source.r;
|
|
184
|
-
this._g = source.g;
|
|
185
|
-
this._b = source.b;
|
|
186
|
-
this._a = source.a;
|
|
187
|
-
this._onValueChanged && this._onValueChanged();
|
|
188
|
-
return this;
|
|
189
|
-
};
|
|
190
|
-
/**
|
|
191
|
-
* Copy from array like object.
|
|
192
|
-
* @param source - Array like object
|
|
193
|
-
* @param offset - The start offset
|
|
194
|
-
* @returns This color
|
|
195
|
-
*/ _proto.copyFromArray = function copyFromArray(source, offset) {
|
|
196
|
-
if (offset === void 0) offset = 0;
|
|
197
|
-
this._r = source[offset];
|
|
198
|
-
this._g = source[offset + 1];
|
|
199
|
-
this._b = source[offset + 2];
|
|
200
|
-
this._a = source[offset + 3];
|
|
201
|
-
this._onValueChanged && this._onValueChanged();
|
|
202
|
-
return this;
|
|
203
|
-
};
|
|
204
|
-
/**
|
|
205
|
-
* Copy the value of this color to an array.
|
|
206
|
-
* @param out - The color
|
|
207
|
-
* @param outOffset - The start offset
|
|
208
|
-
*/ _proto.copyToArray = function copyToArray(out, outOffset) {
|
|
209
|
-
if (outOffset === void 0) outOffset = 0;
|
|
210
|
-
out[outOffset] = this._r;
|
|
211
|
-
out[outOffset + 1] = this._g;
|
|
212
|
-
out[outOffset + 2] = this._b;
|
|
213
|
-
out[outOffset + 3] = this._a;
|
|
214
|
-
};
|
|
215
|
-
/**
|
|
216
|
-
* Modify components (r, g, b) of this color from gamma space to linear space.
|
|
217
|
-
* @param out - The color in linear space
|
|
218
|
-
* @returns The color in linear space
|
|
219
|
-
*/ _proto.toLinear = function toLinear(out) {
|
|
220
|
-
out._r = Color.gammaToLinearSpace(this._r);
|
|
221
|
-
out._g = Color.gammaToLinearSpace(this._g);
|
|
222
|
-
out._b = Color.gammaToLinearSpace(this._b);
|
|
223
|
-
this._onValueChanged && this._onValueChanged();
|
|
224
|
-
return out;
|
|
225
|
-
};
|
|
226
|
-
/**
|
|
227
|
-
* Modify components (r, g, b) of this color from linear space to gamma space.
|
|
228
|
-
* @param out - The color in gamma space
|
|
229
|
-
* @returns The color in gamma space
|
|
230
|
-
*/ _proto.toGamma = function toGamma(out) {
|
|
231
|
-
out._r = Color.linearToGammaSpace(this._r);
|
|
232
|
-
out._g = Color.linearToGammaSpace(this._g);
|
|
233
|
-
out._b = Color.linearToGammaSpace(this._b);
|
|
234
|
-
this._onValueChanged && this._onValueChanged();
|
|
235
|
-
return out;
|
|
236
|
-
};
|
|
237
|
-
/**
|
|
238
|
-
* Gets the brightness.
|
|
239
|
-
* @returns The Hue-Saturation-Brightness (HSB) saturation for this
|
|
240
|
-
*/ _proto.getBrightness = function getBrightness() {
|
|
241
|
-
var r = this.r;
|
|
242
|
-
var g = this.g;
|
|
243
|
-
var b = this.b;
|
|
244
|
-
var max = r;
|
|
245
|
-
var min = r;
|
|
246
|
-
if (g > max) max = g;
|
|
247
|
-
if (b > max) max = b;
|
|
248
|
-
if (g < min) min = g;
|
|
249
|
-
if (b < min) min = b;
|
|
250
|
-
return (max + min) / 2;
|
|
251
|
-
};
|
|
252
|
-
/**
|
|
253
|
-
* Serialize this color to a JSON representation.
|
|
254
|
-
* @return A JSON representation of this color
|
|
255
|
-
*/ _proto.toJSON = function toJSON() {
|
|
256
|
-
return {
|
|
257
|
-
r: this._r,
|
|
258
|
-
g: this._g,
|
|
259
|
-
b: this._b,
|
|
260
|
-
a: this._a
|
|
261
|
-
};
|
|
262
|
-
};
|
|
263
|
-
/**
|
|
264
|
-
* Modify a value from the gamma space to the linear space.
|
|
265
|
-
* @param value - The value in gamma space
|
|
266
|
-
* @returns The value in linear space
|
|
267
|
-
*/ Color.gammaToLinearSpace = function gammaToLinearSpace(value) {
|
|
268
|
-
// https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_framebuffer_sRGB.txt
|
|
269
|
-
// https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_texture_sRGB_decode.txt
|
|
270
|
-
if (value <= 0.0) return 0.0;
|
|
271
|
-
else if (value <= 0.04045) return value / 12.92;
|
|
272
|
-
else if (value < 1.0) return Math.pow((value + 0.055) / 1.055, 2.4);
|
|
273
|
-
else return Math.pow(value, 2.4);
|
|
274
|
-
};
|
|
275
|
-
/**
|
|
276
|
-
* Modify a value from the linear space to the gamma space.
|
|
277
|
-
* @param value - The value in linear space
|
|
278
|
-
* @returns The value in gamma space
|
|
279
|
-
*/ Color.linearToGammaSpace = function linearToGammaSpace(value) {
|
|
280
|
-
// https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_framebuffer_sRGB.txt
|
|
281
|
-
// https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_texture_sRGB_decode.txt
|
|
282
|
-
if (value <= 0.0) return 0.0;
|
|
283
|
-
else if (value < 0.0031308) return 12.92 * value;
|
|
284
|
-
else if (value < 1.0) return 1.055 * Math.pow(value, 0.41666) - 0.055;
|
|
285
|
-
else return Math.pow(value, 0.41666);
|
|
286
|
-
};
|
|
287
|
-
/**
|
|
288
|
-
* Determines whether the specified colors are equals.
|
|
289
|
-
* @param left - The first color to compare
|
|
290
|
-
* @param right - The second color to compare
|
|
291
|
-
* @returns True if the specified colors are equals, false otherwise
|
|
292
|
-
*/ Color.equals = function equals(left, right) {
|
|
293
|
-
return MathUtil.equals(left._r, right._r) && MathUtil.equals(left._g, right._g) && MathUtil.equals(left._b, right._b) && MathUtil.equals(left._a, right._a);
|
|
294
|
-
};
|
|
295
|
-
/**
|
|
296
|
-
* Determines the sum of two colors.
|
|
297
|
-
* @param left - The first color to add
|
|
298
|
-
* @param right - The second color to add
|
|
299
|
-
* @param out - The sum of two colors
|
|
300
|
-
* @returns The added color
|
|
301
|
-
*/ Color.add = function add(left, right, out) {
|
|
302
|
-
out._r = left._r + right._r;
|
|
303
|
-
out._g = left._g + right._g;
|
|
304
|
-
out._b = left._b + right._b;
|
|
305
|
-
out._a = left._a + right._a;
|
|
306
|
-
out._onValueChanged && out._onValueChanged();
|
|
307
|
-
return out;
|
|
308
|
-
};
|
|
309
|
-
/**
|
|
310
|
-
* Determines the difference between two colors.
|
|
311
|
-
* @param left - The first color to subtract
|
|
312
|
-
* @param right - The second color to subtract
|
|
313
|
-
* @param out - The difference between two colors
|
|
314
|
-
*/ Color.subtract = function subtract(left, right, out) {
|
|
315
|
-
out._r = left._r - right._r;
|
|
316
|
-
out._g = left._g - right._g;
|
|
317
|
-
out._b = left._b - right._b;
|
|
318
|
-
out._a = left._a - right._a;
|
|
319
|
-
out._onValueChanged && out._onValueChanged();
|
|
320
|
-
};
|
|
321
|
-
/**
|
|
322
|
-
* Scale a color by the given value.
|
|
323
|
-
* @param left - The color to scale
|
|
324
|
-
* @param s - The amount by which to scale the color
|
|
325
|
-
* @param out - The scaled color
|
|
326
|
-
* @returns The scaled color
|
|
327
|
-
*/ Color.scale = function scale(left, s, out) {
|
|
328
|
-
out._r = left._r * s;
|
|
329
|
-
out._g = left._g * s;
|
|
330
|
-
out._b = left._b * s;
|
|
331
|
-
out._a = left._a * s;
|
|
332
|
-
out._onValueChanged && out._onValueChanged();
|
|
333
|
-
return out;
|
|
334
|
-
};
|
|
335
|
-
/**
|
|
336
|
-
* Performs a linear interpolation between two color.
|
|
337
|
-
* @param start - The first color
|
|
338
|
-
* @param end - The second color
|
|
339
|
-
* @param t - The blend amount where 0 returns start and 1 end
|
|
340
|
-
* @param out - The result of linear blending between two color
|
|
341
|
-
*/ Color.lerp = function lerp(start, end, t, out) {
|
|
342
|
-
var _r = start._r, _g = start._g, _b = start._b, _a = start._a;
|
|
343
|
-
out._r = _r + (end._r - _r) * t;
|
|
344
|
-
out._g = _g + (end._g - _g) * t;
|
|
345
|
-
out._b = _b + (end._b - _b) * t;
|
|
346
|
-
out._a = _a + (end._a - _a) * t;
|
|
347
|
-
out._onValueChanged && out._onValueChanged();
|
|
348
|
-
return out;
|
|
349
|
-
};
|
|
350
|
-
_create_class(Color, [
|
|
351
|
-
{
|
|
352
|
-
key: "r",
|
|
353
|
-
get: /**
|
|
354
|
-
* The red component of the color, 0~1.
|
|
355
|
-
*/ function get() {
|
|
356
|
-
return this._r;
|
|
357
|
-
},
|
|
358
|
-
set: function set(value) {
|
|
359
|
-
this._r = value;
|
|
360
|
-
this._onValueChanged && this._onValueChanged();
|
|
361
|
-
}
|
|
362
|
-
},
|
|
363
|
-
{
|
|
364
|
-
key: "g",
|
|
365
|
-
get: /**
|
|
366
|
-
* The green component of the color, 0~1.
|
|
367
|
-
*/ function get() {
|
|
368
|
-
return this._g;
|
|
369
|
-
},
|
|
370
|
-
set: function set(value) {
|
|
371
|
-
this._g = value;
|
|
372
|
-
this._onValueChanged && this._onValueChanged();
|
|
373
|
-
}
|
|
374
|
-
},
|
|
375
|
-
{
|
|
376
|
-
key: "b",
|
|
377
|
-
get: /**
|
|
378
|
-
* The blue component of the color, 0~1.
|
|
379
|
-
*/ function get() {
|
|
380
|
-
return this._b;
|
|
381
|
-
},
|
|
382
|
-
set: function set(value) {
|
|
383
|
-
this._b = value;
|
|
384
|
-
this._onValueChanged && this._onValueChanged();
|
|
385
|
-
}
|
|
386
|
-
},
|
|
387
|
-
{
|
|
388
|
-
key: "a",
|
|
389
|
-
get: /**
|
|
390
|
-
* The alpha component of the color, 0~1.
|
|
391
|
-
*/ function get() {
|
|
392
|
-
return this._a;
|
|
393
|
-
},
|
|
394
|
-
set: function set(value) {
|
|
395
|
-
this._a = value;
|
|
396
|
-
this._onValueChanged && this._onValueChanged();
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
]);
|
|
400
|
-
return Color;
|
|
401
|
-
}();
|
|
402
|
-
|
|
403
62
|
/**
|
|
404
63
|
* Sprite mask interaction.
|
|
405
64
|
*/ exports.SpriteMaskInteraction = void 0;
|
|
@@ -940,7 +599,14 @@ var Utils = /*#__PURE__*/ function() {
|
|
|
940
599
|
* @param url - The url to be judged.
|
|
941
600
|
* @returns Whether the url is absolute url.
|
|
942
601
|
*/ Utils.isAbsoluteUrl = function isAbsoluteUrl(url) {
|
|
943
|
-
return /^(
|
|
602
|
+
return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
|
|
603
|
+
};
|
|
604
|
+
/**
|
|
605
|
+
* Judge whether the url is base64 url.
|
|
606
|
+
* @param url - The url to be judged.
|
|
607
|
+
* @returns Whether the url is base64 url.
|
|
608
|
+
*/ Utils.isBase64Url = function isBase64Url(url) {
|
|
609
|
+
return /^data:.*,.*$/i.test(url);
|
|
944
610
|
};
|
|
945
611
|
/**
|
|
946
612
|
* Get the values of an object.
|
|
@@ -958,7 +624,10 @@ var Utils = /*#__PURE__*/ function() {
|
|
|
958
624
|
if (Utils.isAbsoluteUrl(relativeUrl)) {
|
|
959
625
|
return relativeUrl;
|
|
960
626
|
}
|
|
961
|
-
|
|
627
|
+
if (Utils.isBase64Url(relativeUrl)) {
|
|
628
|
+
return relativeUrl;
|
|
629
|
+
}
|
|
630
|
+
return relativeUrl ? baseUrl.replace(/\/+$/, "") + "/" + relativeUrl.replace(/^\/+/, "") : baseUrl;
|
|
962
631
|
};
|
|
963
632
|
/**
|
|
964
633
|
* @internal
|
|
@@ -2120,20 +1789,28 @@ var ActiveChangeFlag;
|
|
|
2120
1789
|
this._enabled = value;
|
|
2121
1790
|
if (this._entity._isActiveInScene) {
|
|
2122
1791
|
if (value) {
|
|
2123
|
-
this._phasedActiveInScene
|
|
2124
|
-
|
|
1792
|
+
if (!this._phasedActiveInScene) {
|
|
1793
|
+
this._phasedActiveInScene = true;
|
|
1794
|
+
this._onEnableInScene();
|
|
1795
|
+
}
|
|
2125
1796
|
} else {
|
|
2126
|
-
this._phasedActiveInScene
|
|
2127
|
-
|
|
1797
|
+
if (this._phasedActiveInScene) {
|
|
1798
|
+
this._phasedActiveInScene = false;
|
|
1799
|
+
this._onDisableInScene();
|
|
1800
|
+
}
|
|
2128
1801
|
}
|
|
2129
1802
|
}
|
|
2130
1803
|
if (this._entity.isActiveInHierarchy) {
|
|
2131
1804
|
if (value) {
|
|
2132
|
-
this._phasedActive
|
|
2133
|
-
|
|
1805
|
+
if (!this._phasedActive) {
|
|
1806
|
+
this._phasedActive = true;
|
|
1807
|
+
this._onEnable();
|
|
1808
|
+
}
|
|
2134
1809
|
} else {
|
|
2135
|
-
this._phasedActive
|
|
2136
|
-
|
|
1810
|
+
if (this._phasedActive) {
|
|
1811
|
+
this._phasedActive = false;
|
|
1812
|
+
this._onDisable();
|
|
1813
|
+
}
|
|
2137
1814
|
}
|
|
2138
1815
|
}
|
|
2139
1816
|
}
|
|
@@ -3506,7 +3183,7 @@ function _extends() {
|
|
|
3506
3183
|
return _extends.apply(this, arguments);
|
|
3507
3184
|
}
|
|
3508
3185
|
|
|
3509
|
-
var camera_declare = "#define GLSLIFY 1\nuniform vec3 camera_Position;"; // eslint-disable-line
|
|
3186
|
+
var camera_declare = "#define GLSLIFY 1\nuniform vec3 camera_Position;uniform vec3 camera_Forward;"; // eslint-disable-line
|
|
3510
3187
|
|
|
3511
3188
|
var common = "#define GLSLIFY 1\n#define PI 3.14159265359\n#define RECIPROCAL_PI 0.31830988618\n#define EPSILON 1e-6\n#define LOG2 1.442695\n#define saturate( a ) clamp( a, 0.0, 1.0 )\nfloat pow2(float x){return x*x;}vec4 RGBMToLinear(vec4 value,float maxRange){return vec4(value.rgb*value.a*maxRange,1.0);}vec4 gammaToLinear(vec4 srgbIn){return vec4(pow(srgbIn.rgb,vec3(2.2)),srgbIn.a);}vec4 linearToGamma(vec4 linearIn){return vec4(pow(linearIn.rgb,vec3(1.0/2.2)),linearIn.a);}uniform vec4 camera_DepthBufferParams;float remapDepthBufferLinear01(float z){return 1.0/(camera_DepthBufferParams.x*z+camera_DepthBufferParams.y);}\n#ifdef GRAPHICS_API_WEBGL2\n#define INVERSE_MAT(mat) inverse(mat)\n#else\nmat2 inverseMat(mat2 m){return mat2(m[1][1],-m[0][1],-m[1][0],m[0][0])/(m[0][0]*m[1][1]-m[0][1]*m[1][0]);}mat3 inverseMat(mat3 m){float a00=m[0][0],a01=m[0][1],a02=m[0][2];float a10=m[1][0],a11=m[1][1],a12=m[1][2];float a20=m[2][0],a21=m[2][1],a22=m[2][2];float b01=a22*a11-a12*a21;float b11=-a22*a10+a12*a20;float b21=a21*a10-a11*a20;float det=a00*b01+a01*b11+a02*b21;return mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11),b11,(a22*a00-a02*a20),(-a12*a00+a02*a10),b21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;}mat4 inverseMat(mat4 m){float a00=m[0][0],a01=m[0][1],a02=m[0][2],a03=m[0][3],a10=m[1][0],a11=m[1][1],a12=m[1][2],a13=m[1][3],a20=m[2][0],a21=m[2][1],a22=m[2][2],a23=m[2][3],a30=m[3][0],a31=m[3][1],a32=m[3][2],a33=m[3][3],b00=a00*a11-a01*a10,b01=a00*a12-a02*a10,b02=a00*a13-a03*a10,b03=a01*a12-a02*a11,b04=a01*a13-a03*a11,b05=a02*a13-a03*a12,b06=a20*a31-a21*a30,b07=a20*a32-a22*a30,b08=a20*a33-a23*a30,b09=a21*a32-a22*a31,b10=a21*a33-a23*a31,b11=a22*a33-a23*a32,det=b00*b11-b01*b10+b02*b09+b03*b08-b04*b07+b05*b06;return mat4(a11*b11-a12*b10+a13*b09,a02*b10-a01*b11-a03*b09,a31*b05-a32*b04+a33*b03,a22*b04-a21*b05-a23*b03,a12*b08-a10*b11-a13*b07,a00*b11-a02*b08+a03*b07,a32*b02-a30*b05-a33*b01,a20*b05-a22*b02+a23*b01,a10*b10-a11*b08+a13*b06,a01*b08-a00*b10-a03*b06,a30*b04-a31*b02+a33*b00,a21*b02-a20*b04-a23*b00,a11*b07-a10*b09-a12*b06,a00*b09-a01*b07+a02*b06,a31*b01-a30*b03-a32*b00,a20*b03-a21*b01+a22*b00)/det;}\n#define INVERSE_MAT(mat) inverseMat(mat)\n#endif\n"; // eslint-disable-line
|
|
3512
3189
|
|
|
@@ -3556,7 +3233,7 @@ var mobile_material_frag = "#define GLSLIFY 1\nuniform vec4 material_EmissiveCol
|
|
|
3556
3233
|
|
|
3557
3234
|
var begin_mobile_frag = "#define GLSLIFY 1\nvec4 ambient=vec4(0.0);vec4 emission=material_EmissiveColor;vec4 diffuse=material_BaseColor;vec4 specular=material_SpecularColor;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nvec4 emissiveTextureColor=texture2D(material_EmissiveTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nemissiveTextureColor=gammaToLinear(emissiveTextureColor);\n#endif\nemission*=emissiveTextureColor;\n#endif\n#ifdef MATERIAL_HAS_BASETEXTURE\nvec4 diffuseTextureColor=texture2D(material_BaseTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ndiffuseTextureColor=gammaToLinear(diffuseTextureColor);\n#endif\ndiffuse*=diffuseTextureColor;\n#endif\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\ndiffuse*=v_color;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_TEXTURE\nvec4 specularTextureColor=texture2D(material_SpecularTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nspecularTextureColor=gammaToLinear(specularTextureColor);\n#endif\nspecular*=specularTextureColor;\n#endif\nambient=vec4(scene_EnvMapLight.diffuse*scene_EnvMapLight.diffuseIntensity,1.0)*diffuse;"; // eslint-disable-line
|
|
3558
3235
|
|
|
3559
|
-
var begin_viewdir_frag = "#define GLSLIFY 1\n#ifdef MATERIAL_NEED_WORLD_POS\nvec3 V=normalize(camera_Position-v_pos);\n#endif\n"; // eslint-disable-line
|
|
3236
|
+
var begin_viewdir_frag = "#define GLSLIFY 1\n#ifdef CAMERA_ORTHOGRAPHIC\nvec3 V=-camera_Forward;\n#else\n#ifdef MATERIAL_NEED_WORLD_POS\nvec3 V=normalize(camera_Position-v_pos);\n#endif\n#endif\n"; // eslint-disable-line
|
|
3560
3237
|
|
|
3561
3238
|
var mobile_blinnphong_frag = "#define GLSLIFY 1\n#ifdef MATERIAL_HAS_NORMALTEXTURE\nmat3 tbn=getTBN(gl_FrontFacing);vec3 N=getNormalByNormalTexture(tbn,material_NormalTexture,material_NormalIntensity,v_uv,gl_FrontFacing);\n#else\nvec3 N=getNormal(gl_FrontFacing);\n#endif\nvec3 lightDiffuse=vec3(0.0,0.0,0.0);vec3 lightSpecular=vec3(0.0,0.0,0.0);float shadowAttenuation=1.0;\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nshadowAttenuation=1.0;\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nshadowAttenuation*=sampleShadowMap();\n#endif\nDirectLight directionalLight;for(int i=0;i<SCENE_DIRECT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_DirectLightCullingMask[i])){directionalLight.color=scene_DirectLightColor[i];\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nif(i==0){directionalLight.color*=shadowAttenuation;}\n#endif\ndirectionalLight.direction=scene_DirectLightDirection[i];float d=max(dot(N,-directionalLight.direction),0.0);lightDiffuse+=directionalLight.color*d;vec3 halfDir=normalize(V-directionalLight.direction);float s=pow(clamp(dot(N,halfDir),0.0,1.0),material_Shininess);lightSpecular+=directionalLight.color*s;}}\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nPointLight pointLight;for(int i=0;i<SCENE_POINT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_PointLightCullingMask[i])){pointLight.color=scene_PointLightColor[i];pointLight.position=scene_PointLightPosition[i];pointLight.distance=scene_PointLightDistance[i];vec3 direction=v_pos-pointLight.position;float dist=length(direction);direction/=dist;float decay=clamp(1.0-pow(dist/pointLight.distance,4.0),0.0,1.0);float d=max(dot(N,-direction),0.0)*decay;lightDiffuse+=pointLight.color*d;vec3 halfDir=normalize(V-direction);float s=pow(clamp(dot(N,halfDir),0.0,1.0),material_Shininess)*decay;lightSpecular+=pointLight.color*s;}}\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nSpotLight spotLight;for(int i=0;i<SCENE_SPOT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_SpotLightCullingMask[i])){spotLight.color=scene_SpotLightColor[i];spotLight.position=scene_SpotLightPosition[i];spotLight.direction=scene_SpotLightDirection[i];spotLight.distance=scene_SpotLightDistance[i];spotLight.angleCos=scene_SpotLightAngleCos[i];spotLight.penumbraCos=scene_SpotLightPenumbraCos[i];vec3 direction=spotLight.position-v_pos;float lightDistance=length(direction);direction/=lightDistance;float angleCos=dot(direction,-spotLight.direction);float decay=clamp(1.0-pow(lightDistance/spotLight.distance,4.0),0.0,1.0);float spotEffect=smoothstep(spotLight.penumbraCos,spotLight.angleCos,angleCos);float decayTotal=decay*spotEffect;float d=max(dot(N,direction),0.0)*decayTotal;lightDiffuse+=spotLight.color*d;vec3 halfDir=normalize(V+direction);float s=pow(clamp(dot(N,halfDir),0.0,1.0),material_Shininess)*decayTotal;lightSpecular+=spotLight.color*s;}}\n#endif\ndiffuse*=vec4(lightDiffuse,1.0);specular*=vec4(lightSpecular,1.0);\n#ifdef MATERIAL_IS_ALPHA_CUTOFF\nif(diffuse.a<material_AlphaCutoff){discard;}\n#endif\n"; // eslint-disable-line
|
|
3562
3239
|
|
|
@@ -3594,7 +3271,7 @@ var noise_simplex_4D = "#define GLSLIFY 1\nvec4 grad4(float j,vec4 ip){const vec
|
|
|
3594
3271
|
|
|
3595
3272
|
var pbr_frag_define = "#define GLSLIFY 1\n#define MIN_PERCEPTUAL_ROUGHNESS 0.045\n#define MIN_ROUGHNESS 0.002025\nuniform float material_AlphaCutoff;uniform vec4 material_BaseColor;uniform float material_Metal;uniform float material_Roughness;uniform float material_IOR;uniform vec3 material_PBRSpecularColor;uniform float material_Glossiness;uniform vec3 material_EmissiveColor;uniform float material_NormalIntensity;uniform float material_OcclusionIntensity;uniform float material_OcclusionTextureCoord;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nuniform float material_ClearCoat;uniform float material_ClearCoatRoughness;\n#ifdef MATERIAL_HAS_CLEAR_COAT_TEXTURE\nuniform sampler2D material_ClearCoatTexture;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE\nuniform sampler2D material_ClearCoatRoughnessTexture;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE\nuniform sampler2D material_ClearCoatNormalTexture;\n#endif\n#endif\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nuniform vec3 material_AnisotropyInfo;\n#ifdef MATERIAL_HAS_ANISOTROPY_TEXTURE\nuniform sampler2D material_AnisotropyTexture;\n#endif\n#endif\n#ifdef MATERIAL_HAS_BASETEXTURE\nuniform sampler2D material_BaseTexture;\n#endif\n#ifdef MATERIAL_HAS_NORMALTEXTURE\nuniform sampler2D material_NormalTexture;\n#endif\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nuniform sampler2D material_EmissiveTexture;\n#endif\n#ifdef MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE\nuniform sampler2D material_RoughnessMetallicTexture;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE\nuniform sampler2D material_SpecularGlossinessTexture;\n#endif\n#ifdef MATERIAL_HAS_OCCLUSION_TEXTURE\nuniform sampler2D material_OcclusionTexture;\n#endif\nstruct ReflectedLight{vec3 directDiffuse;vec3 directSpecular;vec3 indirectDiffuse;vec3 indirectSpecular;};struct Geometry{vec3 position;vec3 normal;vec3 viewDir;float dotNV;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nvec3 clearCoatNormal;float clearCoatDotNV;\n#endif\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 anisotropicT;vec3 anisotropicB;vec3 anisotropicN;float anisotropy;\n#endif\n};struct Material{vec3 diffuseColor;float roughness;vec3 specularColor;float opacity;float f0;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nfloat clearCoat;float clearCoatRoughness;\n#endif\n};"; // eslint-disable-line
|
|
3596
3273
|
|
|
3597
|
-
var pbr_helper = "#define GLSLIFY 1\n#include <normal_get>\nfloat computeSpecularOcclusion(float ambientOcclusion,float roughness,float dotNV){return saturate(pow(dotNV+ambientOcclusion,exp2(-16.0*roughness-1.0))-1.0+ambientOcclusion);}float getAARoughnessFactor(vec3 normal){\n#ifdef HAS_DERIVATIVES\nvec3 dxy=max(abs(dFdx(normal)),abs(dFdy(normal)));return MIN_PERCEPTUAL_ROUGHNESS+max(max(dxy.x,dxy.y),dxy.z);\n#else\nreturn MIN_PERCEPTUAL_ROUGHNESS;\n#endif\n}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 getAnisotropicBentNormal(Geometry geometry,vec3 n,float roughness){vec3 anisotropyDirection=geometry.anisotropy>=0.0 ? geometry.anisotropicB : geometry.anisotropicT;vec3 anisotropicTangent=cross(anisotropyDirection,geometry.viewDir);vec3 anisotropicNormal=cross(anisotropicTangent,anisotropyDirection);vec3 bentNormal=normalize(mix(n,anisotropicNormal,abs(geometry.anisotropy)*saturate(5.0*roughness)));return bentNormal;}\n#endif\nvoid initGeometry(out Geometry geometry,bool isFrontFacing){geometry.position=v_pos
|
|
3274
|
+
var pbr_helper = "#define GLSLIFY 1\n#include <normal_get>\nfloat computeSpecularOcclusion(float ambientOcclusion,float roughness,float dotNV){return saturate(pow(dotNV+ambientOcclusion,exp2(-16.0*roughness-1.0))-1.0+ambientOcclusion);}float getAARoughnessFactor(vec3 normal){\n#ifdef HAS_DERIVATIVES\nvec3 dxy=max(abs(dFdx(normal)),abs(dFdy(normal)));return MIN_PERCEPTUAL_ROUGHNESS+max(max(dxy.x,dxy.y),dxy.z);\n#else\nreturn MIN_PERCEPTUAL_ROUGHNESS;\n#endif\n}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 getAnisotropicBentNormal(Geometry geometry,vec3 n,float roughness){vec3 anisotropyDirection=geometry.anisotropy>=0.0 ? geometry.anisotropicB : geometry.anisotropicT;vec3 anisotropicTangent=cross(anisotropyDirection,geometry.viewDir);vec3 anisotropicNormal=cross(anisotropicTangent,anisotropyDirection);vec3 bentNormal=normalize(mix(n,anisotropicNormal,abs(geometry.anisotropy)*saturate(5.0*roughness)));return bentNormal;}\n#endif\nvoid initGeometry(out Geometry geometry,bool isFrontFacing){geometry.position=v_pos;\n#ifdef CAMERA_ORTHOGRAPHIC\ngeometry.viewDir=-camera_Forward;\n#else\ngeometry.viewDir=normalize(camera_Position-v_pos);\n#endif\n#if defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) || defined(MATERIAL_ENABLE_ANISOTROPY)\nmat3 tbn=getTBN(isFrontFacing);\n#endif\n#ifdef MATERIAL_HAS_NORMALTEXTURE\ngeometry.normal=getNormalByNormalTexture(tbn,material_NormalTexture,material_NormalIntensity,v_uv,isFrontFacing);\n#else\ngeometry.normal=getNormal(isFrontFacing);\n#endif\ngeometry.dotNV=saturate(dot(geometry.normal,geometry.viewDir));\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\n#ifdef MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE\ngeometry.clearCoatNormal=getNormalByNormalTexture(tbn,material_ClearCoatNormalTexture,material_NormalIntensity,v_uv,isFrontFacing);\n#else\ngeometry.clearCoatNormal=getNormal(isFrontFacing);\n#endif\ngeometry.clearCoatDotNV=saturate(dot(geometry.clearCoatNormal,geometry.viewDir));\n#endif\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nfloat anisotropy=material_AnisotropyInfo.z;vec3 anisotropicDirection=vec3(material_AnisotropyInfo.xy,0.0);\n#ifdef MATERIAL_HAS_ANISOTROPY_TEXTURE\nvec3 anisotropyTextureInfo=texture2D(material_AnisotropyTexture,v_uv).rgb;anisotropy*=anisotropyTextureInfo.b;anisotropicDirection.xy*=anisotropyTextureInfo.rg*2.0-1.0;\n#endif\ngeometry.anisotropy=anisotropy;geometry.anisotropicT=normalize(tbn*anisotropicDirection);geometry.anisotropicB=normalize(cross(geometry.normal,geometry.anisotropicT));\n#endif\n}void initMaterial(out Material material,inout Geometry geometry){vec4 baseColor=material_BaseColor;float metal=material_Metal;float roughness=material_Roughness;vec3 specularColor=material_PBRSpecularColor;float glossiness=material_Glossiness;float alphaCutoff=material_AlphaCutoff;float f0=pow2((material_IOR-1.0)/(material_IOR+1.0));material.f0=f0;\n#ifdef MATERIAL_HAS_BASETEXTURE\nvec4 baseTextureColor=texture2D(material_BaseTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nbaseTextureColor=gammaToLinear(baseTextureColor);\n#endif\nbaseColor*=baseTextureColor;\n#endif\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nbaseColor*=v_color;\n#endif\n#ifdef MATERIAL_IS_ALPHA_CUTOFF\nif(baseColor.a<alphaCutoff){discard;}\n#endif\n#ifdef MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE\nvec4 metalRoughMapColor=texture2D(material_RoughnessMetallicTexture,v_uv);roughness*=metalRoughMapColor.g;metal*=metalRoughMapColor.b;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE\nvec4 specularGlossinessColor=texture2D(material_SpecularGlossinessTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nspecularGlossinessColor=gammaToLinear(specularGlossinessColor);\n#endif\nspecularColor*=specularGlossinessColor.rgb;glossiness*=specularGlossinessColor.a;\n#endif\n#ifdef IS_METALLIC_WORKFLOW\nmaterial.diffuseColor=baseColor.rgb*(1.0-metal);material.specularColor=mix(vec3(f0),baseColor.rgb,metal);material.roughness=roughness;\n#else\nfloat specularStrength=max(max(specularColor.r,specularColor.g),specularColor.b);material.diffuseColor=baseColor.rgb*(1.0-specularStrength);material.specularColor=specularColor;material.roughness=1.0-glossiness;\n#endif\nmaterial.roughness=max(material.roughness,getAARoughnessFactor(geometry.normal));\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nmaterial.clearCoat=material_ClearCoat;material.clearCoatRoughness=material_ClearCoatRoughness;\n#ifdef MATERIAL_HAS_CLEAR_COAT_TEXTURE\nmaterial.clearCoat*=texture2D(material_ClearCoatTexture,v_uv).r;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE\nmaterial.clearCoatRoughness*=texture2D(material_ClearCoatRoughnessTexture,v_uv).g;\n#endif\nmaterial.clearCoat=saturate(material.clearCoat);material.clearCoatRoughness=max(material.clearCoatRoughness,getAARoughnessFactor(geometry.clearCoatNormal));\n#endif\n#ifdef MATERIAL_IS_TRANSPARENT\nmaterial.opacity=baseColor.a;\n#else\nmaterial.opacity=1.0;\n#endif\n#ifdef MATERIAL_ENABLE_ANISOTROPY\ngeometry.anisotropicN=getAnisotropicBentNormal(geometry,geometry.normal,material.roughness);\n#endif\n}\n#include <brdf>\n#include <direct_irradiance_frag_define>\n#include <ibl_frag_define>\n"; // eslint-disable-line
|
|
3598
3275
|
|
|
3599
3276
|
var brdf = "#define GLSLIFY 1\nfloat F_Schlick(float f0,float dotLH){return f0+0.96*(pow(1.0-dotLH,5.0));}vec3 F_Schlick(vec3 specularColor,float dotLH){float fresnel=exp2((-5.55473*dotLH-6.98316)*dotLH);return(1.0-specularColor)*fresnel+specularColor;}float G_GGX_SmithCorrelated(float alpha,float dotNL,float dotNV){float a2=pow2(alpha);float gv=dotNL*sqrt(a2+(1.0-a2)*pow2(dotNV));float gl=dotNV*sqrt(a2+(1.0-a2)*pow2(dotNL));return 0.5/max(gv+gl,EPSILON);}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nfloat G_GGX_SmithCorrelated_Anisotropic(float at,float ab,float ToV,float BoV,float ToL,float BoL,float NoV,float NoL){float lambdaV=NoL*length(vec3(at*ToV,ab*BoV,NoV));float lambdaL=NoV*length(vec3(at*ToL,ab*BoL,NoL));return 0.5/max(lambdaV+lambdaL,EPSILON);}\n#endif\nfloat D_GGX(float alpha,float dotNH){float a2=pow2(alpha);float denom=pow2(dotNH)*(a2-1.0)+1.0;return RECIPROCAL_PI*a2/pow2(denom);}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nfloat D_GGX_Anisotropic(float at,float ab,float ToH,float BoH,float NoH){float a2=at*ab;highp vec3 d=vec3(ab*ToH,at*BoH,a2*NoH);highp float d2=dot(d,d);float b2=a2/d2;return a2*b2*b2*RECIPROCAL_PI;}\n#endif\nvec3 isotropicLobe(vec3 specularColor,float alpha,float dotNV,float dotNL,float dotNH,float dotLH){vec3 F=F_Schlick(specularColor,dotLH);float D=D_GGX(alpha,dotNH);float G=G_GGX_SmithCorrelated(alpha,dotNL,dotNV);return F*(G*D);}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 anisotropicLobe(vec3 h,vec3 l,Geometry geometry,vec3 specularColor,float alpha,float dotNV,float dotNL,float dotNH,float dotLH){vec3 t=geometry.anisotropicT;vec3 b=geometry.anisotropicB;vec3 v=geometry.viewDir;float dotTV=dot(t,v);float dotBV=dot(b,v);float dotTL=dot(t,l);float dotBL=dot(b,l);float dotTH=dot(t,h);float dotBH=dot(b,h);float at=max(alpha*(1.0+geometry.anisotropy),MIN_ROUGHNESS);float ab=max(alpha*(1.0-geometry.anisotropy),MIN_ROUGHNESS);vec3 F=F_Schlick(specularColor,dotLH);float D=D_GGX_Anisotropic(at,ab,dotTH,dotBH,dotNH);float G=G_GGX_SmithCorrelated_Anisotropic(at,ab,dotTV,dotBV,dotTL,dotBL,dotNV,dotNL);return F*(G*D);}\n#endif\nvec3 BRDF_Specular_GGX(vec3 incidentDirection,Geometry geometry,vec3 normal,vec3 specularColor,float roughness){float alpha=pow2(roughness);vec3 halfDir=normalize(incidentDirection+geometry.viewDir);float dotNL=saturate(dot(normal,incidentDirection));float dotNV=saturate(dot(normal,geometry.viewDir));float dotNH=saturate(dot(normal,halfDir));float dotLH=saturate(dot(incidentDirection,halfDir));\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nreturn anisotropicLobe(halfDir,incidentDirection,geometry,specularColor,alpha,dotNV,dotNL,dotNH,dotLH);\n#else\nreturn isotropicLobe(specularColor,alpha,dotNV,dotNL,dotNH,dotLH);\n#endif\n}vec3 BRDF_Diffuse_Lambert(vec3 diffuseColor){return RECIPROCAL_PI*diffuseColor;}"; // eslint-disable-line
|
|
3600
3277
|
|
|
@@ -3615,7 +3292,7 @@ var PBRShaderLib = {
|
|
|
3615
3292
|
|
|
3616
3293
|
var ShadowCoord = "#define GLSLIFY 1\nuniform mat4 scene_ShadowMatrices[SCENE_SHADOW_CASCADED_COUNT+1];uniform vec4 scene_ShadowSplitSpheres[4];mediump int computeCascadeIndex(vec3 positionWS){vec3 fromCenter0=positionWS-scene_ShadowSplitSpheres[0].xyz;vec3 fromCenter1=positionWS-scene_ShadowSplitSpheres[1].xyz;vec3 fromCenter2=positionWS-scene_ShadowSplitSpheres[2].xyz;vec3 fromCenter3=positionWS-scene_ShadowSplitSpheres[3].xyz;mediump vec4 comparison=vec4(dot(fromCenter0,fromCenter0)<scene_ShadowSplitSpheres[0].w,dot(fromCenter1,fromCenter1)<scene_ShadowSplitSpheres[1].w,dot(fromCenter2,fromCenter2)<scene_ShadowSplitSpheres[2].w,dot(fromCenter3,fromCenter3)<scene_ShadowSplitSpheres[3].w);comparison.yzw=clamp(comparison.yzw-comparison.xyz,0.0,1.0);mediump vec4 indexCoefficient=vec4(4.0,3.0,2.0,1.0);mediump int index=4-int(dot(comparison,indexCoefficient));return index;}vec3 getShadowCoord(){\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nmediump int cascadeIndex=0;\n#else\nmediump int cascadeIndex=computeCascadeIndex(v_pos);\n#endif\n#ifdef GRAPHICS_API_WEBGL2\nmat4 shadowMatrix=scene_ShadowMatrices[cascadeIndex];\n#else\nmat4 shadowMatrix;\n#if SCENE_SHADOW_CASCADED_COUNT == 4\nif(cascadeIndex==0){shadowMatrix=scene_ShadowMatrices[0];}else if(cascadeIndex==1){shadowMatrix=scene_ShadowMatrices[1];}else if(cascadeIndex==2){shadowMatrix=scene_ShadowMatrices[2];}else if(cascadeIndex==3){shadowMatrix=scene_ShadowMatrices[3];}else{shadowMatrix=scene_ShadowMatrices[4];}\n#endif\n#if SCENE_SHADOW_CASCADED_COUNT == 2\nif(cascadeIndex==0){shadowMatrix=scene_ShadowMatrices[0];}else if(cascadeIndex==1){shadowMatrix=scene_ShadowMatrices[1];}else{shadowMatrix=scene_ShadowMatrices[2];}\n#endif\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nif(cascadeIndex==0){shadowMatrix=scene_ShadowMatrices[0];}else{shadowMatrix=scene_ShadowMatrices[1];}\n#endif\n#endif\nvec4 shadowCoord=shadowMatrix*vec4(v_pos,1.0);return shadowCoord.xyz;}"; // eslint-disable-line
|
|
3617
3294
|
|
|
3618
|
-
var ShadowFragmentDeclaration = "#define GLSLIFY 1\n#if defined(SCENE_SHADOW_TYPE) && defined(RENDERER_IS_RECEIVE_SHADOWS)\n#define SCENE_IS_CALCULATE_SHADOWS\n#endif\n#ifdef SCENE_IS_CALCULATE_SHADOWS\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nvarying vec3 v_shadowCoord;\n#else\n#include <ShadowCoord>\n#endif\nuniform
|
|
3295
|
+
var ShadowFragmentDeclaration = "#define GLSLIFY 1\n#if defined(SCENE_SHADOW_TYPE) && defined(RENDERER_IS_RECEIVE_SHADOWS)\n#define SCENE_IS_CALCULATE_SHADOWS\n#endif\n#ifdef SCENE_IS_CALCULATE_SHADOWS\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nvarying vec3 v_shadowCoord;\n#else\n#include <ShadowCoord>\n#endif\nuniform vec4 scene_ShadowInfo;uniform vec4 scene_ShadowMapSize;\n#ifdef GRAPHICS_API_WEBGL2\nuniform mediump sampler2DShadow scene_ShadowMap;\n#define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) textureLod(textureName, coord3 , 0.0)\n#define TEXTURE2D_SHADOW_PARAM(shadowMap) mediump sampler2DShadow shadowMap\n#else\nuniform sampler2D scene_ShadowMap;\n#ifdef ENGINE_NO_DEPTH_TEXTURE\nconst vec4 bitShift=vec4(1.0,1.0/256.0,1.0/(256.0*256.0),1.0/(256.0*256.0*256.0));float unpack(const in vec4 rgbaDepth){return dot(rgbaDepth,bitShift);}\n#define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) (unpack(texture2D(textureName, coord3.xy)) < coord3.z ? 0.0 : 1.0)\n#else\n#define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) (texture2D(textureName, coord3.xy).r < coord3.z ? 0.0 : 1.0)\n#endif\n#define TEXTURE2D_SHADOW_PARAM(shadowMap) mediump sampler2D shadowMap\n#endif\n#if SCENE_SHADOW_TYPE == 2\nfloat sampleShadowMapFiltered4(TEXTURE2D_SHADOW_PARAM(shadowMap),vec3 shadowCoord,vec4 shadowMapSize){float attenuation;vec4 attenuation4;vec2 offset=shadowMapSize.xy/2.0;vec3 shadowCoord0=shadowCoord+vec3(-offset,0.0);vec3 shadowCoord1=shadowCoord+vec3(offset.x,-offset.y,0.0);vec3 shadowCoord2=shadowCoord+vec3(-offset.x,offset.y,0.0);vec3 shadowCoord3=shadowCoord+vec3(offset,0.0);attenuation4.x=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord0);attenuation4.y=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord1);attenuation4.z=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord2);attenuation4.w=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord3);attenuation=dot(attenuation4,vec4(0.25));return attenuation;}\n#endif\n#if SCENE_SHADOW_TYPE == 3\n#include <shadow_sample_tent>\nfloat sampleShadowMapFiltered9(TEXTURE2D_SHADOW_PARAM(shadowMap),vec3 shadowCoord,vec4 shadowmapSize){float attenuation;float fetchesWeights[9];vec2 fetchesUV[9];sampleShadowComputeSamplesTent5x5(shadowmapSize,shadowCoord.xy,fetchesWeights,fetchesUV);attenuation=fetchesWeights[0]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[0].xy,shadowCoord.z));attenuation+=fetchesWeights[1]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[1].xy,shadowCoord.z));attenuation+=fetchesWeights[2]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[2].xy,shadowCoord.z));attenuation+=fetchesWeights[3]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[3].xy,shadowCoord.z));attenuation+=fetchesWeights[4]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[4].xy,shadowCoord.z));attenuation+=fetchesWeights[5]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[5].xy,shadowCoord.z));attenuation+=fetchesWeights[6]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[6].xy,shadowCoord.z));attenuation+=fetchesWeights[7]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[7].xy,shadowCoord.z));attenuation+=fetchesWeights[8]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[8].xy,shadowCoord.z));return attenuation;}\n#endif\nfloat getShadowFade(vec3 positionWS){vec3 camToPixel=positionWS-camera_Position;float distanceCamToPixel2=dot(camToPixel,camToPixel);return saturate(distanceCamToPixel2*scene_ShadowInfo.z+scene_ShadowInfo.w);}float sampleShadowMap(){\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nvec3 shadowCoord=v_shadowCoord;\n#else\nvec3 shadowCoord=getShadowCoord();\n#endif\nfloat attenuation=1.0;if(shadowCoord.z>0.0&&shadowCoord.z<1.0){\n#if SCENE_SHADOW_TYPE == 1\nattenuation=SAMPLE_TEXTURE2D_SHADOW(scene_ShadowMap,shadowCoord);\n#endif\n#if SCENE_SHADOW_TYPE == 2\nattenuation=sampleShadowMapFiltered4(scene_ShadowMap,shadowCoord,scene_ShadowMapSize);\n#endif\n#if SCENE_SHADOW_TYPE == 3\nattenuation=sampleShadowMapFiltered9(scene_ShadowMap,shadowCoord,scene_ShadowMapSize);\n#endif\nfloat shadowFade=getShadowFade(v_pos);attenuation=mix(1.0,mix(attenuation,1.0,shadowFade),scene_ShadowInfo.x);}return attenuation;}\n#endif\n"; // eslint-disable-line
|
|
3619
3296
|
|
|
3620
3297
|
var shadow_sample_tent = "#define GLSLIFY 1\nfloat sampleShadowGetIRTriangleTexelArea(float triangleHeight){return triangleHeight-0.5;}void sampleShadowGetTexelAreasTent3x3(float offset,out vec4 computedArea,out vec4 computedAreaUncut){float a=offset+0.5;float offsetSquaredHalved=a*a*0.5;computedAreaUncut.x=computedArea.x=offsetSquaredHalved-offset;computedAreaUncut.w=computedArea.w=offsetSquaredHalved;computedAreaUncut.y=sampleShadowGetIRTriangleTexelArea(1.5-offset);float clampedOffsetLeft=min(offset,0.0);float areaOfSmallLeftTriangle=clampedOffsetLeft*clampedOffsetLeft;computedArea.y=computedAreaUncut.y-areaOfSmallLeftTriangle;computedAreaUncut.z=sampleShadowGetIRTriangleTexelArea(1.5+offset);float clampedOffsetRight=max(offset,0.0);float areaOfSmallRightTriangle=clampedOffsetRight*clampedOffsetRight;computedArea.z=computedAreaUncut.z-areaOfSmallRightTriangle;}void sampleShadowGetTexelWeightsTent5x5(float offset,out vec3 texelsWeightsA,out vec3 texelsWeightsB){vec4 areaFrom3texelTriangle;vec4 areaUncutFrom3texelTriangle;sampleShadowGetTexelAreasTent3x3(offset,areaFrom3texelTriangle,areaUncutFrom3texelTriangle);texelsWeightsA.x=0.16*(areaFrom3texelTriangle.x);texelsWeightsA.y=0.16*(areaUncutFrom3texelTriangle.y);texelsWeightsA.z=0.16*(areaFrom3texelTriangle.y+1.0);texelsWeightsB.x=0.16*(areaFrom3texelTriangle.z+1.0);texelsWeightsB.y=0.16*(areaUncutFrom3texelTriangle.z);texelsWeightsB.z=0.16*(areaFrom3texelTriangle.w);}void sampleShadowComputeSamplesTent5x5(vec4 shadowMapTextureTexelSize,vec2 coord,out float fetchesWeights[9],out vec2 fetchesUV[9]){vec2 tentCenterInTexelSpace=coord.xy*shadowMapTextureTexelSize.zw;vec2 centerOfFetchesInTexelSpace=floor(tentCenterInTexelSpace+0.5);vec2 offsetFromTentCenterToCenterOfFetches=tentCenterInTexelSpace-centerOfFetchesInTexelSpace;vec3 texelsWeightsUA,texelsWeightsUB;vec3 texelsWeightsVA,texelsWeightsVB;sampleShadowGetTexelWeightsTent5x5(offsetFromTentCenterToCenterOfFetches.x,texelsWeightsUA,texelsWeightsUB);sampleShadowGetTexelWeightsTent5x5(offsetFromTentCenterToCenterOfFetches.y,texelsWeightsVA,texelsWeightsVB);vec3 fetchesWeightsU=vec3(texelsWeightsUA.xz,texelsWeightsUB.y)+vec3(texelsWeightsUA.y,texelsWeightsUB.xz);vec3 fetchesWeightsV=vec3(texelsWeightsVA.xz,texelsWeightsVB.y)+vec3(texelsWeightsVA.y,texelsWeightsVB.xz);vec3 fetchesOffsetsU=vec3(texelsWeightsUA.y,texelsWeightsUB.xz)/fetchesWeightsU.xyz+vec3(-2.5,-0.5,1.5);vec3 fetchesOffsetsV=vec3(texelsWeightsVA.y,texelsWeightsVB.xz)/fetchesWeightsV.xyz+vec3(-2.5,-0.5,1.5);fetchesOffsetsU*=shadowMapTextureTexelSize.xxx;fetchesOffsetsV*=shadowMapTextureTexelSize.yyy;vec2 bilinearFetchOrigin=centerOfFetchesInTexelSpace*shadowMapTextureTexelSize.xy;fetchesUV[0]=bilinearFetchOrigin+vec2(fetchesOffsetsU.x,fetchesOffsetsV.x);fetchesUV[1]=bilinearFetchOrigin+vec2(fetchesOffsetsU.y,fetchesOffsetsV.x);fetchesUV[2]=bilinearFetchOrigin+vec2(fetchesOffsetsU.z,fetchesOffsetsV.x);fetchesUV[3]=bilinearFetchOrigin+vec2(fetchesOffsetsU.x,fetchesOffsetsV.y);fetchesUV[4]=bilinearFetchOrigin+vec2(fetchesOffsetsU.y,fetchesOffsetsV.y);fetchesUV[5]=bilinearFetchOrigin+vec2(fetchesOffsetsU.z,fetchesOffsetsV.y);fetchesUV[6]=bilinearFetchOrigin+vec2(fetchesOffsetsU.x,fetchesOffsetsV.z);fetchesUV[7]=bilinearFetchOrigin+vec2(fetchesOffsetsU.y,fetchesOffsetsV.z);fetchesUV[8]=bilinearFetchOrigin+vec2(fetchesOffsetsU.z,fetchesOffsetsV.z);fetchesWeights[0]=fetchesWeightsU.x*fetchesWeightsV.x;fetchesWeights[1]=fetchesWeightsU.y*fetchesWeightsV.x;fetchesWeights[2]=fetchesWeightsU.z*fetchesWeightsV.x;fetchesWeights[3]=fetchesWeightsU.x*fetchesWeightsV.y;fetchesWeights[4]=fetchesWeightsU.y*fetchesWeightsV.y;fetchesWeights[5]=fetchesWeightsU.z*fetchesWeightsV.y;fetchesWeights[6]=fetchesWeightsU.x*fetchesWeightsV.z;fetchesWeights[7]=fetchesWeightsU.y*fetchesWeightsV.z;fetchesWeights[8]=fetchesWeightsU.z*fetchesWeightsV.z;}"; // eslint-disable-line
|
|
3621
3298
|
|
|
@@ -3730,16 +3407,22 @@ var ShaderFactory = /*#__PURE__*/ function() {
|
|
|
3730
3407
|
}
|
|
3731
3408
|
ShaderLib[includeName] = includeSource;
|
|
3732
3409
|
};
|
|
3733
|
-
ShaderFactory.
|
|
3410
|
+
ShaderFactory.unRegisterInclude = function unRegisterInclude(includeName) {
|
|
3411
|
+
delete ShaderLib[includeName];
|
|
3412
|
+
};
|
|
3413
|
+
/**
|
|
3414
|
+
* @param regex The default regex is for engine's builtin glsl `#include` syntax,
|
|
3415
|
+
* since `ShaderLab` use the same parsing function but different syntax for `#include` --- `/^[ \t]*#include +"([\w\d.]+)"/gm`
|
|
3416
|
+
*/ ShaderFactory.parseIncludes = function parseIncludes(src, regex) {
|
|
3417
|
+
if (regex === void 0) regex = /^[ \t]*#include +<([\w\d.]+)>/gm;
|
|
3734
3418
|
var replace = function replace(match, slice) {
|
|
3735
3419
|
var replace = ShaderLib[slice];
|
|
3736
3420
|
if (replace === undefined) {
|
|
3737
3421
|
Logger.error('Shader slice "' + match.trim() + '" not founded.');
|
|
3738
3422
|
return "";
|
|
3739
3423
|
}
|
|
3740
|
-
return ShaderFactory.parseIncludes(replace);
|
|
3424
|
+
return ShaderFactory.parseIncludes(replace, regex);
|
|
3741
3425
|
};
|
|
3742
|
-
var regex = /^[ \t]*#include +<([\w\d.]+)>/gm;
|
|
3743
3426
|
return src.replace(regex, replace);
|
|
3744
3427
|
};
|
|
3745
3428
|
/**
|
|
@@ -3850,16 +3533,6 @@ var ShaderFactory = /*#__PURE__*/ function() {
|
|
|
3850
3533
|
return ShaderPart;
|
|
3851
3534
|
}();
|
|
3852
3535
|
|
|
3853
|
-
/**
|
|
3854
|
-
* Shader data grouping.
|
|
3855
|
-
*/ var ShaderDataGroup;
|
|
3856
|
-
(function(ShaderDataGroup) {
|
|
3857
|
-
ShaderDataGroup[ShaderDataGroup[/** Scene group. */ "Scene"] = 0] = "Scene";
|
|
3858
|
-
ShaderDataGroup[ShaderDataGroup[/** Camera group. */ "Camera"] = 1] = "Camera";
|
|
3859
|
-
ShaderDataGroup[ShaderDataGroup[/** Renderer group. */ "Renderer"] = 2] = "Renderer";
|
|
3860
|
-
ShaderDataGroup[ShaderDataGroup[/** material group. */ "Material"] = 3] = "Material";
|
|
3861
|
-
})(ShaderDataGroup || (ShaderDataGroup = {}));
|
|
3862
|
-
|
|
3863
3536
|
/**
|
|
3864
3537
|
* Color Space.
|
|
3865
3538
|
*/ exports.ColorSpace = void 0;
|
|
@@ -4069,6 +3742,16 @@ var ShaderFactory = /*#__PURE__*/ function() {
|
|
|
4069
3742
|
this.textureUniforms = [];
|
|
4070
3743
|
};
|
|
4071
3744
|
|
|
3745
|
+
/**
|
|
3746
|
+
* Shader data grouping.
|
|
3747
|
+
*/ var ShaderDataGroup;
|
|
3748
|
+
(function(ShaderDataGroup) {
|
|
3749
|
+
ShaderDataGroup[ShaderDataGroup[/** Scene group. */ "Scene"] = 0] = "Scene";
|
|
3750
|
+
ShaderDataGroup[ShaderDataGroup[/** Camera group. */ "Camera"] = 1] = "Camera";
|
|
3751
|
+
ShaderDataGroup[ShaderDataGroup[/** Renderer group. */ "Renderer"] = 2] = "Renderer";
|
|
3752
|
+
ShaderDataGroup[ShaderDataGroup[/** material group. */ "Material"] = 3] = "Material";
|
|
3753
|
+
})(ShaderDataGroup || (ShaderDataGroup = {}));
|
|
3754
|
+
|
|
4072
3755
|
/**
|
|
4073
3756
|
* Shader program, corresponding to the GPU shader program.
|
|
4074
3757
|
* @internal
|
|
@@ -4364,6 +4047,7 @@ var ShaderFactory = /*#__PURE__*/ function() {
|
|
|
4364
4047
|
break;
|
|
4365
4048
|
case gl.SAMPLER_2D:
|
|
4366
4049
|
case gl.SAMPLER_CUBE:
|
|
4050
|
+
case gl.UNSIGNED_INT_SAMPLER_2D:
|
|
4367
4051
|
case gl.SAMPLER_2D_ARRAY:
|
|
4368
4052
|
case gl.SAMPLER_2D_SHADOW:
|
|
4369
4053
|
var defaultTexture;
|
|
@@ -4374,6 +4058,9 @@ var ShaderFactory = /*#__PURE__*/ function() {
|
|
|
4374
4058
|
case gl.SAMPLER_CUBE:
|
|
4375
4059
|
defaultTexture = _this._engine._magentaTextureCube;
|
|
4376
4060
|
break;
|
|
4061
|
+
case gl.UNSIGNED_INT_SAMPLER_2D:
|
|
4062
|
+
defaultTexture = _this._engine._uintMagentaTexture2D;
|
|
4063
|
+
break;
|
|
4377
4064
|
case gl.SAMPLER_2D_ARRAY:
|
|
4378
4065
|
defaultTexture = _this._engine._magentaTexture2DArray;
|
|
4379
4066
|
break;
|
|
@@ -5463,6 +5150,57 @@ var GraphicsResource = /*#__PURE__*/ function(ReferResource1) {
|
|
|
5463
5150
|
return GraphicsResource;
|
|
5464
5151
|
}(ReferResource);
|
|
5465
5152
|
|
|
5153
|
+
/**
|
|
5154
|
+
* The filter mode of the texture.
|
|
5155
|
+
*/ exports.TextureFilterMode = void 0;
|
|
5156
|
+
(function(TextureFilterMode) {
|
|
5157
|
+
TextureFilterMode[TextureFilterMode[/** Point filtering. */ "Point"] = 0] = "Point";
|
|
5158
|
+
TextureFilterMode[TextureFilterMode[/** Bilinear filtering. */ "Bilinear"] = 1] = "Bilinear";
|
|
5159
|
+
TextureFilterMode[TextureFilterMode[/** Trilinear filtering. */ "Trilinear"] = 2] = "Trilinear";
|
|
5160
|
+
})(exports.TextureFilterMode || (exports.TextureFilterMode = {}));
|
|
5161
|
+
|
|
5162
|
+
/**
|
|
5163
|
+
* Texture format enumeration.
|
|
5164
|
+
*/ exports.TextureFormat = void 0;
|
|
5165
|
+
(function(TextureFormat) {
|
|
5166
|
+
TextureFormat[TextureFormat[/** RGB format, 8 bits per channel. */ "R8G8B8"] = 0] = "R8G8B8";
|
|
5167
|
+
TextureFormat[TextureFormat[/** RGBA format, 8 bits per channel. */ "R8G8B8A8"] = 1] = "R8G8B8A8";
|
|
5168
|
+
TextureFormat[TextureFormat[/** RGBA format, 4 bits per channel. */ "R4G4B4A4"] = 2] = "R4G4B4A4";
|
|
5169
|
+
TextureFormat[TextureFormat[/** RGBA format, 5 bits in R channel, 5 bits in G channel, 5 bits in B channel, 1 bit in A channel. */ "R5G5B5A1"] = 3] = "R5G5B5A1";
|
|
5170
|
+
TextureFormat[TextureFormat[/** RGB format, 5 bits in R channel, 6 bits in G channel, 5 bits in B channel. */ "R5G6B5"] = 4] = "R5G6B5";
|
|
5171
|
+
TextureFormat[TextureFormat[/** Transparent format, 8 bits. */ "Alpha8"] = 5] = "Alpha8";
|
|
5172
|
+
TextureFormat[TextureFormat[/** Luminance/alpha in RGB channel, alpha in A channel. */ "LuminanceAlpha"] = 6] = "LuminanceAlpha";
|
|
5173
|
+
TextureFormat[TextureFormat[/** RGBA format, 16 bits per channel. */ "R16G16B16A16"] = 7] = "R16G16B16A16";
|
|
5174
|
+
TextureFormat[TextureFormat[/** RGBA format, 32 bits per channel. */ "R32G32B32A32"] = 8] = "R32G32B32A32";
|
|
5175
|
+
TextureFormat[TextureFormat[/** RGBA unsigned integer format, 32 bits per channel. */ "R32G32B32A32_UInt"] = 9] = "R32G32B32A32_UInt";
|
|
5176
|
+
TextureFormat[TextureFormat[/** RGB compressed format, 4 bits per pixel. */ "BC1"] = 10] = "BC1";
|
|
5177
|
+
TextureFormat[TextureFormat[/** RGBA compressed format, 8 bits per pixel. */ "BC3"] = 11] = "BC3";
|
|
5178
|
+
TextureFormat[TextureFormat[/** RGB(A) compressed format, 128 bits per 4x4 pixel block. */ "BC7"] = 12] = "BC7";
|
|
5179
|
+
TextureFormat[TextureFormat[/** RGB compressed format, 4 bits per pixel. */ "ETC1_RGB"] = 13] = "ETC1_RGB";
|
|
5180
|
+
TextureFormat[TextureFormat[/** RGB compressed format, 4 bits per pixel. */ "ETC2_RGB"] = 14] = "ETC2_RGB";
|
|
5181
|
+
TextureFormat[TextureFormat[/** RGBA compressed format, 5 bits per pixel, 4 bit in RGB, 1 bit in A. */ "ETC2_RGBA5"] = 15] = "ETC2_RGBA5";
|
|
5182
|
+
TextureFormat[TextureFormat[/** RGB compressed format, 8 bits per pixel. */ "ETC2_RGBA8"] = 16] = "ETC2_RGBA8";
|
|
5183
|
+
TextureFormat[TextureFormat[/** RGB compressed format, 2 bits per pixel. */ "PVRTC_RGB2"] = 17] = "PVRTC_RGB2";
|
|
5184
|
+
TextureFormat[TextureFormat[/** RGBA compressed format, 2 bits per pixel. */ "PVRTC_RGBA2"] = 18] = "PVRTC_RGBA2";
|
|
5185
|
+
TextureFormat[TextureFormat[/** RGB compressed format, 4 bits per pixel. */ "PVRTC_RGB4"] = 19] = "PVRTC_RGB4";
|
|
5186
|
+
TextureFormat[TextureFormat[/** RGBA compressed format, 4 bits per pixel. */ "PVRTC_RGBA4"] = 20] = "PVRTC_RGBA4";
|
|
5187
|
+
TextureFormat[TextureFormat[/** RGB(A) compressed format, 128 bits per 4x4 pixel block. */ "ASTC_4x4"] = 21] = "ASTC_4x4";
|
|
5188
|
+
TextureFormat[TextureFormat[/** RGB(A) compressed format, 128 bits per 5x5 pixel block. */ "ASTC_5x5"] = 22] = "ASTC_5x5";
|
|
5189
|
+
TextureFormat[TextureFormat[/** RGB(A) compressed format, 128 bits per 6x6 pixel block. */ "ASTC_6x6"] = 23] = "ASTC_6x6";
|
|
5190
|
+
TextureFormat[TextureFormat[/** RGB(A) compressed format, 128 bits per 8x8 pixel block. */ "ASTC_8x8"] = 24] = "ASTC_8x8";
|
|
5191
|
+
TextureFormat[TextureFormat[/** RGB(A) compressed format, 128 bits per 10x10 pixel block. */ "ASTC_10x10"] = 25] = "ASTC_10x10";
|
|
5192
|
+
TextureFormat[TextureFormat[/** RGB(A) compressed format, 128 bits per 12x12 pixel block. */ "ASTC_12x12"] = 26] = "ASTC_12x12";
|
|
5193
|
+
TextureFormat[TextureFormat[/** Automatic depth format, engine will automatically select the supported precision. */ "Depth"] = 27] = "Depth";
|
|
5194
|
+
TextureFormat[TextureFormat[/** Automatic depth stencil format, engine will automatically select the supported precision. */ "DepthStencil"] = 28] = "DepthStencil";
|
|
5195
|
+
TextureFormat[TextureFormat[/** 16-bit depth format. */ "Depth16"] = 29] = "Depth16";
|
|
5196
|
+
TextureFormat[TextureFormat[/** 24-bit depth format. */ "Depth24"] = 30] = "Depth24";
|
|
5197
|
+
TextureFormat[TextureFormat[/** 32-bit depth format. */ "Depth32"] = 31] = "Depth32";
|
|
5198
|
+
TextureFormat[TextureFormat[/** 16-bit depth + 8-bit stencil format. */ "Depth24Stencil8"] = 32] = "Depth24Stencil8";
|
|
5199
|
+
TextureFormat[TextureFormat[/** 32-bit depth + 8-bit stencil format. */ "Depth32Stencil8"] = 33] = "Depth32Stencil8";
|
|
5200
|
+
TextureFormat[TextureFormat[/** @deprecated Use `TextureFormat.BC1` instead. */ "DXT1"] = 34] = "DXT1";
|
|
5201
|
+
TextureFormat[TextureFormat[/** @deprecated Use `TextureFormat.BC3` instead. */ "DXT5"] = 35] = "DXT5";
|
|
5202
|
+
})(exports.TextureFormat || (exports.TextureFormat = {}));
|
|
5203
|
+
|
|
5466
5204
|
/**
|
|
5467
5205
|
* The base class of texture, contains some common functions of texture-related classes.
|
|
5468
5206
|
*/ var Texture = /*#__PURE__*/ function(GraphicsResource1) {
|
|
@@ -5519,6 +5257,12 @@ var GraphicsResource = /*#__PURE__*/ function(ReferResource1) {
|
|
|
5519
5257
|
_proto._getMipmapCount = function _getMipmapCount() {
|
|
5520
5258
|
return this._mipmap ? Math.floor(Math.log2(Math.max(this._width, this._height))) + 1 : 1;
|
|
5521
5259
|
};
|
|
5260
|
+
_proto._isIntFormat = function _isIntFormat() {
|
|
5261
|
+
if (exports.TextureFormat.R32G32B32A32_UInt === this._format) {
|
|
5262
|
+
return true;
|
|
5263
|
+
}
|
|
5264
|
+
return false;
|
|
5265
|
+
};
|
|
5522
5266
|
_create_class(Texture, [
|
|
5523
5267
|
{
|
|
5524
5268
|
key: "format",
|
|
@@ -5595,6 +5339,11 @@ var GraphicsResource = /*#__PURE__*/ function(ReferResource1) {
|
|
|
5595
5339
|
},
|
|
5596
5340
|
set: function set(value) {
|
|
5597
5341
|
if (value === this._filterMode) return;
|
|
5342
|
+
if (value !== exports.TextureFilterMode.Point && this._isIntFormat()) {
|
|
5343
|
+
value = exports.TextureFilterMode.Point;
|
|
5344
|
+
Logger.warn("Int or UInt format texture only support TextureFilterMode.Point");
|
|
5345
|
+
return;
|
|
5346
|
+
}
|
|
5598
5347
|
this._filterMode = value;
|
|
5599
5348
|
this._platformTexture.filterMode = value;
|
|
5600
5349
|
}
|
|
@@ -6721,7 +6470,7 @@ SlicedSpriteAssembler = __decorate([
|
|
|
6721
6470
|
_this._byteLength = byteLength;
|
|
6722
6471
|
_this._platformBuffer = engine._hardwareRenderer.createPlatformBuffer(type, byteLength, bufferUsage, data);
|
|
6723
6472
|
if (readable) {
|
|
6724
|
-
var buffer =
|
|
6473
|
+
var buffer = data.constructor === ArrayBuffer ? data.slice(0) : data.buffer.slice(data.byteOffset, data.byteOffset + byteLength);
|
|
6725
6474
|
_this._data = new Uint8Array(buffer);
|
|
6726
6475
|
}
|
|
6727
6476
|
}
|
|
@@ -7898,56 +7647,6 @@ var /**
|
|
|
7898
7647
|
TextureDepthCompareFunction[TextureDepthCompareFunction[/** always pass. */ "Always"] = 7] = "Always";
|
|
7899
7648
|
})(exports.TextureDepthCompareFunction || (exports.TextureDepthCompareFunction = {}));
|
|
7900
7649
|
|
|
7901
|
-
/**
|
|
7902
|
-
* The filter mode of the texture.
|
|
7903
|
-
*/ exports.TextureFilterMode = void 0;
|
|
7904
|
-
(function(TextureFilterMode) {
|
|
7905
|
-
TextureFilterMode[TextureFilterMode[/** Point filtering. */ "Point"] = 0] = "Point";
|
|
7906
|
-
TextureFilterMode[TextureFilterMode[/** Bilinear filtering. */ "Bilinear"] = 1] = "Bilinear";
|
|
7907
|
-
TextureFilterMode[TextureFilterMode[/** Trilinear filtering. */ "Trilinear"] = 2] = "Trilinear";
|
|
7908
|
-
})(exports.TextureFilterMode || (exports.TextureFilterMode = {}));
|
|
7909
|
-
|
|
7910
|
-
/**
|
|
7911
|
-
* Texture format enumeration.
|
|
7912
|
-
*/ exports.TextureFormat = void 0;
|
|
7913
|
-
(function(TextureFormat) {
|
|
7914
|
-
TextureFormat[TextureFormat[/** RGB format, 8 bits per channel. */ "R8G8B8"] = 0] = "R8G8B8";
|
|
7915
|
-
TextureFormat[TextureFormat[/** RGBA format, 8 bits per channel. */ "R8G8B8A8"] = 1] = "R8G8B8A8";
|
|
7916
|
-
TextureFormat[TextureFormat[/** RGBA format, 4 bits per channel. */ "R4G4B4A4"] = 2] = "R4G4B4A4";
|
|
7917
|
-
TextureFormat[TextureFormat[/** RGBA format, 5 bits in R channel, 5 bits in G channel, 5 bits in B channel, 1 bit in A channel. */ "R5G5B5A1"] = 3] = "R5G5B5A1";
|
|
7918
|
-
TextureFormat[TextureFormat[/** RGB format, 5 bits in R channel, 6 bits in G channel, 5 bits in B channel. */ "R5G6B5"] = 4] = "R5G6B5";
|
|
7919
|
-
TextureFormat[TextureFormat[/** Transparent format, 8 bits. */ "Alpha8"] = 5] = "Alpha8";
|
|
7920
|
-
TextureFormat[TextureFormat[/** Luminance/alpha in RGB channel, alpha in A channel. */ "LuminanceAlpha"] = 6] = "LuminanceAlpha";
|
|
7921
|
-
TextureFormat[TextureFormat[/** RGBA format, 16 bits per channel. */ "R16G16B16A16"] = 7] = "R16G16B16A16";
|
|
7922
|
-
TextureFormat[TextureFormat[/** RGBA format, 32 bits per channel. */ "R32G32B32A32"] = 8] = "R32G32B32A32";
|
|
7923
|
-
TextureFormat[TextureFormat[/** RGB compressed format, 4 bits per pixel. */ "BC1"] = 9] = "BC1";
|
|
7924
|
-
TextureFormat[TextureFormat[/** RGBA compressed format, 8 bits per pixel. */ "BC3"] = 10] = "BC3";
|
|
7925
|
-
TextureFormat[TextureFormat[/** RGB(A) compressed format, 128 bits per 4x4 pixel block. */ "BC7"] = 11] = "BC7";
|
|
7926
|
-
TextureFormat[TextureFormat[/** RGB compressed format, 4 bits per pixel. */ "ETC1_RGB"] = 12] = "ETC1_RGB";
|
|
7927
|
-
TextureFormat[TextureFormat[/** RGB compressed format, 4 bits per pixel. */ "ETC2_RGB"] = 13] = "ETC2_RGB";
|
|
7928
|
-
TextureFormat[TextureFormat[/** RGBA compressed format, 5 bits per pixel, 4 bit in RGB, 1 bit in A. */ "ETC2_RGBA5"] = 14] = "ETC2_RGBA5";
|
|
7929
|
-
TextureFormat[TextureFormat[/** RGB compressed format, 8 bits per pixel. */ "ETC2_RGBA8"] = 15] = "ETC2_RGBA8";
|
|
7930
|
-
TextureFormat[TextureFormat[/** RGB compressed format, 2 bits per pixel. */ "PVRTC_RGB2"] = 16] = "PVRTC_RGB2";
|
|
7931
|
-
TextureFormat[TextureFormat[/** RGBA compressed format, 2 bits per pixel. */ "PVRTC_RGBA2"] = 17] = "PVRTC_RGBA2";
|
|
7932
|
-
TextureFormat[TextureFormat[/** RGB compressed format, 4 bits per pixel. */ "PVRTC_RGB4"] = 18] = "PVRTC_RGB4";
|
|
7933
|
-
TextureFormat[TextureFormat[/** RGBA compressed format, 4 bits per pixel. */ "PVRTC_RGBA4"] = 19] = "PVRTC_RGBA4";
|
|
7934
|
-
TextureFormat[TextureFormat[/** RGB(A) compressed format, 128 bits per 4x4 pixel block. */ "ASTC_4x4"] = 20] = "ASTC_4x4";
|
|
7935
|
-
TextureFormat[TextureFormat[/** RGB(A) compressed format, 128 bits per 5x5 pixel block. */ "ASTC_5x5"] = 21] = "ASTC_5x5";
|
|
7936
|
-
TextureFormat[TextureFormat[/** RGB(A) compressed format, 128 bits per 6x6 pixel block. */ "ASTC_6x6"] = 22] = "ASTC_6x6";
|
|
7937
|
-
TextureFormat[TextureFormat[/** RGB(A) compressed format, 128 bits per 8x8 pixel block. */ "ASTC_8x8"] = 23] = "ASTC_8x8";
|
|
7938
|
-
TextureFormat[TextureFormat[/** RGB(A) compressed format, 128 bits per 10x10 pixel block. */ "ASTC_10x10"] = 24] = "ASTC_10x10";
|
|
7939
|
-
TextureFormat[TextureFormat[/** RGB(A) compressed format, 128 bits per 12x12 pixel block. */ "ASTC_12x12"] = 25] = "ASTC_12x12";
|
|
7940
|
-
TextureFormat[TextureFormat[/** Automatic depth format, engine will automatically select the supported precision. */ "Depth"] = 26] = "Depth";
|
|
7941
|
-
TextureFormat[TextureFormat[/** Automatic depth stencil format, engine will automatically select the supported precision. */ "DepthStencil"] = 27] = "DepthStencil";
|
|
7942
|
-
TextureFormat[TextureFormat[/** 16-bit depth format. */ "Depth16"] = 28] = "Depth16";
|
|
7943
|
-
TextureFormat[TextureFormat[/** 24-bit depth format. */ "Depth24"] = 29] = "Depth24";
|
|
7944
|
-
TextureFormat[TextureFormat[/** 32-bit depth format. */ "Depth32"] = 30] = "Depth32";
|
|
7945
|
-
TextureFormat[TextureFormat[/** 16-bit depth + 8-bit stencil format. */ "Depth24Stencil8"] = 31] = "Depth24Stencil8";
|
|
7946
|
-
TextureFormat[TextureFormat[/** 32-bit depth + 8-bit stencil format. */ "Depth32Stencil8"] = 32] = "Depth32Stencil8";
|
|
7947
|
-
TextureFormat[TextureFormat[/** @deprecated Use `TextureFormat.BC1` instead. */ "DXT1"] = 33] = "DXT1";
|
|
7948
|
-
TextureFormat[TextureFormat[/** @deprecated Use `TextureFormat.BC3` instead. */ "DXT5"] = 34] = "DXT5";
|
|
7949
|
-
})(exports.TextureFormat || (exports.TextureFormat = {}));
|
|
7950
|
-
|
|
7951
7650
|
/**
|
|
7952
7651
|
* Texture usage.
|
|
7953
7652
|
*/ exports.TextureUsage = void 0;
|
|
@@ -8131,7 +7830,7 @@ var /**
|
|
|
8131
7830
|
_this._mipmapCount = _this._getMipmapCount();
|
|
8132
7831
|
_this._isDepthTexture = format == exports.TextureFormat.Depth || format == exports.TextureFormat.DepthStencil || format == exports.TextureFormat.Depth16 || format == exports.TextureFormat.Depth24 || format == exports.TextureFormat.Depth32 || format == exports.TextureFormat.Depth24Stencil8 || format == exports.TextureFormat.Depth32Stencil8;
|
|
8133
7832
|
_this._platformTexture = engine._hardwareRenderer.createPlatformTexture2D(_assert_this_initialized(_this));
|
|
8134
|
-
_this.filterMode = exports.TextureFilterMode.Bilinear;
|
|
7833
|
+
_this.filterMode = _this._isIntFormat() ? exports.TextureFilterMode.Point : exports.TextureFilterMode.Bilinear;
|
|
8135
7834
|
_this.wrapModeU = _this.wrapModeV = exports.TextureWrapMode.Repeat;
|
|
8136
7835
|
return _this;
|
|
8137
7836
|
}
|
|
@@ -9930,6 +9629,10 @@ var VertexElementIndex;
|
|
|
9930
9629
|
var sphereInfo = primitiveInfo;
|
|
9931
9630
|
PrimitiveMesh._setSphereData(this.resource, sphereInfo.radius, sphereInfo.segments, sphereInfo.noLongerAccessible, true, sphereInfo.vertexBuffer);
|
|
9932
9631
|
break;
|
|
9632
|
+
case 7:
|
|
9633
|
+
var CCSphereInfo = primitiveInfo;
|
|
9634
|
+
PrimitiveMesh._setSubdivisionSurfaceSphereData(this.resource, CCSphereInfo.radius, CCSphereInfo.step, CCSphereInfo.noLongerAccessible, true, CCSphereInfo.vertexBuffer);
|
|
9635
|
+
break;
|
|
9933
9636
|
case 1:
|
|
9934
9637
|
var cuboidInfo = primitiveInfo;
|
|
9935
9638
|
PrimitiveMesh._setCuboidData(this.resource, cuboidInfo.width, cuboidInfo.height, cuboidInfo.depth, cuboidInfo.noLongerAccessible, true, cuboidInfo.vertexBuffer);
|
|
@@ -9967,6 +9670,7 @@ var PrimitiveType;
|
|
|
9967
9670
|
PrimitiveType[PrimitiveType["Torus"] = 4] = "Torus";
|
|
9968
9671
|
PrimitiveType[PrimitiveType["Cone"] = 5] = "Cone";
|
|
9969
9672
|
PrimitiveType[PrimitiveType["Capsule"] = 6] = "Capsule";
|
|
9673
|
+
PrimitiveType[PrimitiveType["CCSphere"] = 7] = "CCSphere";
|
|
9970
9674
|
})(PrimitiveType || (PrimitiveType = {}));
|
|
9971
9675
|
/**
|
|
9972
9676
|
* @internal
|
|
@@ -9988,6 +9692,19 @@ var PrimitiveType;
|
|
|
9988
9692
|
}
|
|
9989
9693
|
return SphereRestoreInfo;
|
|
9990
9694
|
}(PrimitiveRestoreInfo);
|
|
9695
|
+
/**
|
|
9696
|
+
* @internal
|
|
9697
|
+
*/ var SubdivisionSurfaceSphereRestoreInfo = /*#__PURE__*/ function(PrimitiveRestoreInfo) {
|
|
9698
|
+
_inherits(SubdivisionSurfaceSphereRestoreInfo, PrimitiveRestoreInfo);
|
|
9699
|
+
function SubdivisionSurfaceSphereRestoreInfo(radius, step, vertexBuffer, noLongerAccessible) {
|
|
9700
|
+
var _this;
|
|
9701
|
+
_this = PrimitiveRestoreInfo.call(this, 7, vertexBuffer, noLongerAccessible) || this;
|
|
9702
|
+
_this.radius = radius;
|
|
9703
|
+
_this.step = step;
|
|
9704
|
+
return _this;
|
|
9705
|
+
}
|
|
9706
|
+
return SubdivisionSurfaceSphereRestoreInfo;
|
|
9707
|
+
}(PrimitiveRestoreInfo);
|
|
9991
9708
|
/**
|
|
9992
9709
|
* @internal
|
|
9993
9710
|
*/ var CuboidRestoreInfo = /*#__PURE__*/ function(PrimitiveRestoreInfo) {
|
|
@@ -10102,6 +9819,24 @@ var PrimitiveType;
|
|
|
10102
9819
|
return sphereMesh;
|
|
10103
9820
|
};
|
|
10104
9821
|
/**
|
|
9822
|
+
* Create a sphere mesh by implementing Catmull-Clark Surface Subdivision Algorithm.
|
|
9823
|
+
* Max step is limited to 6.
|
|
9824
|
+
* @param engine - Engine
|
|
9825
|
+
* @param radius - Sphere radius
|
|
9826
|
+
* @param step - Number of subdiv steps
|
|
9827
|
+
* @param noLongerAccessible - No longer access the vertices of the mesh after creation
|
|
9828
|
+
* @returns Sphere model mesh
|
|
9829
|
+
*/ PrimitiveMesh.createSubdivisionSurfaceSphere = function createSubdivisionSurfaceSphere(engine, radius, step, noLongerAccessible) {
|
|
9830
|
+
if (radius === void 0) radius = 0.5;
|
|
9831
|
+
if (step === void 0) step = 3;
|
|
9832
|
+
if (noLongerAccessible === void 0) noLongerAccessible = true;
|
|
9833
|
+
var sphereMesh = new ModelMesh(engine);
|
|
9834
|
+
PrimitiveMesh._setSubdivisionSurfaceSphereData(sphereMesh, radius, step, noLongerAccessible, false);
|
|
9835
|
+
var vertexBuffer = sphereMesh.vertexBufferBindings[0].buffer;
|
|
9836
|
+
engine.resourceManager.addContentRestorer(new PrimitiveMeshRestorer(sphereMesh, new SubdivisionSurfaceSphereRestoreInfo(radius, step, vertexBuffer, noLongerAccessible)));
|
|
9837
|
+
return sphereMesh;
|
|
9838
|
+
};
|
|
9839
|
+
/**
|
|
10105
9840
|
* Create a cuboid mesh.
|
|
10106
9841
|
* @param engine - Engine
|
|
10107
9842
|
* @param width - Cuboid width
|
|
@@ -10231,6 +9966,90 @@ var PrimitiveType;
|
|
|
10231
9966
|
};
|
|
10232
9967
|
/**
|
|
10233
9968
|
* @internal
|
|
9969
|
+
*/ PrimitiveMesh._setSubdivisionSurfaceSphereData = function _setSubdivisionSurfaceSphereData(sphereMesh, radius, step, noLongerAccessible, isRestoreMode, restoreVertexBuffer) {
|
|
9970
|
+
// Max step is limited to 6. Because 7 step will generate a single mesh with over 98306 vertices
|
|
9971
|
+
step = engineMath.MathUtil.clamp(Math.floor(step), 1, 6);
|
|
9972
|
+
var positions = new Float32Array(3 * (6 * Math.pow(4, step) + 2));
|
|
9973
|
+
var cells = new Float32Array(24 * Math.pow(4, step));
|
|
9974
|
+
PrimitiveMesh._subdiveCatmullClark(step, positions, cells);
|
|
9975
|
+
var positionCount = positions.length / 3;
|
|
9976
|
+
var cellsCount = cells.length / 4;
|
|
9977
|
+
var poleOffset = positionCount + Math.pow(2, step + 1) - 1;
|
|
9978
|
+
// 16 extra vertices for pole uv
|
|
9979
|
+
// 2 vertices at each pole are idle
|
|
9980
|
+
var vertexCount = poleOffset + 16;
|
|
9981
|
+
var vertices = new Float32Array(vertexCount * 8);
|
|
9982
|
+
var indices = PrimitiveMesh._generateIndices(sphereMesh.engine, positionCount, cellsCount * 6);
|
|
9983
|
+
var seamCount = 0;
|
|
9984
|
+
var seamVertices = {};
|
|
9985
|
+
// Get normals, uvs, and scale to radius
|
|
9986
|
+
for(var i = 0; i < positionCount; i++){
|
|
9987
|
+
var offset = 3 * i;
|
|
9988
|
+
var x = positions[offset];
|
|
9989
|
+
var y = positions[offset + 1];
|
|
9990
|
+
var z = positions[offset + 2];
|
|
9991
|
+
var reciprocalLength = 1 / Math.sqrt(x * x + y * y + z * z);
|
|
9992
|
+
x *= reciprocalLength;
|
|
9993
|
+
y *= reciprocalLength;
|
|
9994
|
+
z *= reciprocalLength;
|
|
9995
|
+
offset = 8 * i;
|
|
9996
|
+
vertices[offset] = x * radius;
|
|
9997
|
+
vertices[offset + 1] = y * radius;
|
|
9998
|
+
vertices[offset + 2] = z * radius;
|
|
9999
|
+
vertices[offset + 3] = x;
|
|
10000
|
+
vertices[offset + 4] = y;
|
|
10001
|
+
vertices[offset + 5] = z;
|
|
10002
|
+
vertices[offset + 6] = (Math.PI - Math.atan2(z, x)) / (2 * Math.PI);
|
|
10003
|
+
vertices[offset + 7] = Math.acos(y) / Math.PI;
|
|
10004
|
+
if (vertices[offset + 6] === 0) {
|
|
10005
|
+
// Generate seam vertex
|
|
10006
|
+
var seamOffset = 8 * (positionCount + seamCount++);
|
|
10007
|
+
vertices.set(vertices.subarray(offset, offset + 8), seamOffset);
|
|
10008
|
+
vertices[seamOffset + 6] = 1.0;
|
|
10009
|
+
// Cache seam vertex
|
|
10010
|
+
seamVertices[offset / 8] = seamOffset / 8;
|
|
10011
|
+
}
|
|
10012
|
+
}
|
|
10013
|
+
// Get indices
|
|
10014
|
+
var offset1 = 0;
|
|
10015
|
+
this._spherePoleIdx = 0;
|
|
10016
|
+
for(var i1 = 0; i1 < cellsCount; i1++){
|
|
10017
|
+
var idx = 4 * i1;
|
|
10018
|
+
var indexA = cells[idx];
|
|
10019
|
+
var indexB = cells[idx + 1];
|
|
10020
|
+
var indexC = cells[idx + 2];
|
|
10021
|
+
var indexD = cells[idx + 3];
|
|
10022
|
+
// Handle seam by replacing vertex index to seam vertex index if necessary
|
|
10023
|
+
var floatIndexA = 8 * indexA;
|
|
10024
|
+
var floatIndexB = 8 * indexB;
|
|
10025
|
+
var floatIndexC = 8 * indexC;
|
|
10026
|
+
var floatIndexD = 8 * indexD;
|
|
10027
|
+
// If center Z is negative
|
|
10028
|
+
if (vertices[floatIndexA + 2] + vertices[floatIndexB + 2] + vertices[floatIndexC + 2] < 0) {
|
|
10029
|
+
vertices[floatIndexA + 6] === 0 && (indexA = seamVertices[indexA]);
|
|
10030
|
+
vertices[floatIndexB + 6] === 0 && (indexB = seamVertices[indexB]);
|
|
10031
|
+
vertices[floatIndexC + 6] === 0 && (indexC = seamVertices[indexC]);
|
|
10032
|
+
vertices[floatIndexD + 6] === 0 && (indexD = seamVertices[indexD]);
|
|
10033
|
+
}
|
|
10034
|
+
indices[offset1] = indexA;
|
|
10035
|
+
indices[offset1 + 1] = indexB;
|
|
10036
|
+
indices[offset1 + 2] = indexC;
|
|
10037
|
+
this._generateAndReplacePoleUV(indices, vertices, offset1, poleOffset);
|
|
10038
|
+
indices[offset1 + 3] = indexA;
|
|
10039
|
+
indices[offset1 + 4] = indexC;
|
|
10040
|
+
indices[offset1 + 5] = indexD;
|
|
10041
|
+
this._generateAndReplacePoleUV(indices, vertices, offset1 + 3, poleOffset);
|
|
10042
|
+
offset1 += 6;
|
|
10043
|
+
}
|
|
10044
|
+
if (!isRestoreMode) {
|
|
10045
|
+
var bounds = sphereMesh.bounds;
|
|
10046
|
+
bounds.min.set(-radius, -radius, -radius);
|
|
10047
|
+
bounds.max.set(radius, radius, radius);
|
|
10048
|
+
}
|
|
10049
|
+
PrimitiveMesh._initialize(sphereMesh, vertices, indices, noLongerAccessible, isRestoreMode, restoreVertexBuffer);
|
|
10050
|
+
};
|
|
10051
|
+
/**
|
|
10052
|
+
* @internal
|
|
10234
10053
|
*/ PrimitiveMesh._setSphereData = function _setSphereData(sphereMesh, radius, segments, noLongerAccessible, isRestoreMode, restoreVertexBuffer) {
|
|
10235
10054
|
segments = Math.max(2, Math.floor(segments));
|
|
10236
10055
|
var count = segments + 1;
|
|
@@ -10291,6 +10110,135 @@ var PrimitiveType;
|
|
|
10291
10110
|
};
|
|
10292
10111
|
/**
|
|
10293
10112
|
* @internal
|
|
10113
|
+
*/ PrimitiveMesh._subdiveCatmullClark = function _subdiveCatmullClark(step, positions, cells) {
|
|
10114
|
+
var edges = new Map();
|
|
10115
|
+
var faces = new Array();
|
|
10116
|
+
positions.set(PrimitiveMesh._sphereSeedPositions);
|
|
10117
|
+
cells.set(PrimitiveMesh._sphereSeedCells);
|
|
10118
|
+
for(var i = 0; i < step; i++){
|
|
10119
|
+
var cellCount = 6 * Math.pow(4, i);
|
|
10120
|
+
var positionCount = 4 * cellCount + 2;
|
|
10121
|
+
edges.clear();
|
|
10122
|
+
faces.length = 0;
|
|
10123
|
+
// Get cell face's facePoint
|
|
10124
|
+
for(var j = 0; j < cellCount; j++){
|
|
10125
|
+
var face = faces[j] = {
|
|
10126
|
+
facePoint: new engineMath.Vector3(),
|
|
10127
|
+
adjacentEdges: new Array(4)
|
|
10128
|
+
};
|
|
10129
|
+
// Get cell's edgePoint
|
|
10130
|
+
for(var k = 0; k < 4; k++){
|
|
10131
|
+
var offset = 3 * cells[4 * j + k];
|
|
10132
|
+
face.facePoint.x += 0.25 * positions[offset];
|
|
10133
|
+
face.facePoint.y += 0.25 * positions[offset + 1];
|
|
10134
|
+
face.facePoint.z += 0.25 * positions[offset + 2];
|
|
10135
|
+
}
|
|
10136
|
+
// Get cell edges
|
|
10137
|
+
for(var k1 = 0; k1 < 4; k1++){
|
|
10138
|
+
var vertexIdxA = cells[4 * j + k1];
|
|
10139
|
+
var vertexIdxB = cells[4 * j + (k1 + 1) % 4];
|
|
10140
|
+
var edgeIdxKey = Math.min(vertexIdxA, vertexIdxB) * positionCount + Math.max(vertexIdxA, vertexIdxB);
|
|
10141
|
+
if (!edges.has(edgeIdxKey)) {
|
|
10142
|
+
var edge = {
|
|
10143
|
+
edgePoint: new engineMath.Vector3(),
|
|
10144
|
+
edgePointIndex: undefined
|
|
10145
|
+
};
|
|
10146
|
+
var offsetA = 3 * vertexIdxA;
|
|
10147
|
+
var offsetB = 3 * vertexIdxB;
|
|
10148
|
+
edge.edgePoint.set(0.25 * (positions[offsetA] + positions[offsetB]), 0.25 * (positions[offsetA + 1] + positions[offsetB + 1]), 0.25 * (positions[offsetA + 2] + positions[offsetB + 2]));
|
|
10149
|
+
edges.set(edgeIdxKey, edge);
|
|
10150
|
+
}
|
|
10151
|
+
var edge1 = edges.get(edgeIdxKey);
|
|
10152
|
+
face.adjacentEdges[k1] = edge1;
|
|
10153
|
+
var edgePoint = edge1.edgePoint;
|
|
10154
|
+
var facePoint = face.facePoint;
|
|
10155
|
+
edgePoint.x += 0.25 * facePoint.x;
|
|
10156
|
+
edgePoint.y += 0.25 * facePoint.y;
|
|
10157
|
+
edgePoint.z += 0.25 * facePoint.z;
|
|
10158
|
+
}
|
|
10159
|
+
}
|
|
10160
|
+
var prePointCount = cellCount + 2;
|
|
10161
|
+
var edgePointOffset = prePointCount + cellCount;
|
|
10162
|
+
var pointIdx = 0;
|
|
10163
|
+
this._sphereEdgeIdx = 0;
|
|
10164
|
+
var preCells = cells.slice(0, 4 * cellCount);
|
|
10165
|
+
// Get New positions, which consists of updated positions of existing points, face points and edge points
|
|
10166
|
+
for(var j1 = 0; j1 < cellCount; j1++){
|
|
10167
|
+
// Add face point to new positions
|
|
10168
|
+
var face1 = faces[j1];
|
|
10169
|
+
face1.facePoint.copyToArray(positions, 3 * (prePointCount + j1));
|
|
10170
|
+
// Get the face point index
|
|
10171
|
+
var ic = prePointCount + j1;
|
|
10172
|
+
var id = void 0, ib = void 0, temp = void 0;
|
|
10173
|
+
// ia -- id -- ia
|
|
10174
|
+
// | | |
|
|
10175
|
+
// ib -- ic -- ib
|
|
10176
|
+
// | | |
|
|
10177
|
+
// ia -- id -- ia
|
|
10178
|
+
for(var k2 = 0; k2 < 4; k2++){
|
|
10179
|
+
// Get the updated existing point index
|
|
10180
|
+
var ia = preCells[pointIdx++];
|
|
10181
|
+
// ib and id share four edge points in one cell
|
|
10182
|
+
switch(k2){
|
|
10183
|
+
case 0:
|
|
10184
|
+
{
|
|
10185
|
+
var edgeB = face1.adjacentEdges[k2 % 4];
|
|
10186
|
+
var edgeD = face1.adjacentEdges[(k2 + 3) % 4];
|
|
10187
|
+
ib = this._calculateEdgeIndex(positions, edgeB, edgePointOffset);
|
|
10188
|
+
id = this._calculateEdgeIndex(positions, edgeD, edgePointOffset);
|
|
10189
|
+
temp = id;
|
|
10190
|
+
break;
|
|
10191
|
+
}
|
|
10192
|
+
case 1:
|
|
10193
|
+
case 2:
|
|
10194
|
+
{
|
|
10195
|
+
var edgeB1 = face1.adjacentEdges[k2 % 4];
|
|
10196
|
+
id = ib;
|
|
10197
|
+
ib = this._calculateEdgeIndex(positions, edgeB1, edgePointOffset);
|
|
10198
|
+
break;
|
|
10199
|
+
}
|
|
10200
|
+
case 3:
|
|
10201
|
+
{
|
|
10202
|
+
id = ib;
|
|
10203
|
+
ib = temp;
|
|
10204
|
+
break;
|
|
10205
|
+
}
|
|
10206
|
+
}
|
|
10207
|
+
var idx = 4 * (4 * j1 + k2);
|
|
10208
|
+
cells[idx] = ia;
|
|
10209
|
+
cells[idx + 1] = ib;
|
|
10210
|
+
cells[idx + 2] = ic;
|
|
10211
|
+
cells[idx + 3] = id;
|
|
10212
|
+
}
|
|
10213
|
+
}
|
|
10214
|
+
}
|
|
10215
|
+
};
|
|
10216
|
+
/**
|
|
10217
|
+
* Duplicate vertices at the poles and adjust their UV coordinates.
|
|
10218
|
+
*/ PrimitiveMesh._generateAndReplacePoleUV = function _generateAndReplacePoleUV(indices, vertices, idx, poleOffset) {
|
|
10219
|
+
var v = vertices[8 * indices[idx] + 7];
|
|
10220
|
+
if (v === 0 || v === 1) {
|
|
10221
|
+
var offset = 8 * indices[idx];
|
|
10222
|
+
var addedOffset = 8 * (poleOffset + this._spherePoleIdx);
|
|
10223
|
+
vertices.set(vertices.subarray(offset, offset + 8), addedOffset);
|
|
10224
|
+
vertices[addedOffset + 6] = 0.5 * (vertices[offset + 6] + vertices[8 * indices[idx + 1] + 6] + vertices[8 * indices[idx + 2] + 6] - 0.5);
|
|
10225
|
+
indices[idx] = poleOffset + this._spherePoleIdx++;
|
|
10226
|
+
}
|
|
10227
|
+
};
|
|
10228
|
+
/**
|
|
10229
|
+
* Get edge point index for subdivision surface sphere.
|
|
10230
|
+
*/ PrimitiveMesh._calculateEdgeIndex = function _calculateEdgeIndex(positions, edge, offset) {
|
|
10231
|
+
if (edge.edgePointIndex !== undefined) {
|
|
10232
|
+
return edge.edgePointIndex;
|
|
10233
|
+
} else {
|
|
10234
|
+
edge.edgePoint.copyToArray(positions, 3 * (offset + PrimitiveMesh._sphereEdgeIdx));
|
|
10235
|
+
var index = offset + PrimitiveMesh._sphereEdgeIdx++;
|
|
10236
|
+
edge.edgePointIndex = index;
|
|
10237
|
+
return index;
|
|
10238
|
+
}
|
|
10239
|
+
};
|
|
10240
|
+
/**
|
|
10241
|
+
* @internal
|
|
10294
10242
|
*/ PrimitiveMesh._setCuboidData = function _setCuboidData(cuboidMesh, width, height, depth, noLongerAccessible, isRestoreMode, restoreVertexBuffer) {
|
|
10295
10243
|
var halfWidth = width / 2;
|
|
10296
10244
|
var halfHeight = height / 2;
|
|
@@ -10692,7 +10640,7 @@ var PrimitiveType;
|
|
|
10692
10640
|
var theta = thetaStart + u * thetaRange;
|
|
10693
10641
|
var sinTheta = Math.sin(theta);
|
|
10694
10642
|
var cosTheta = Math.cos(theta);
|
|
10695
|
-
var curRadius = radius -
|
|
10643
|
+
var curRadius = radius - v * radius;
|
|
10696
10644
|
var posX = curRadius * sinTheta;
|
|
10697
10645
|
var posY = y * unitHeight - halfHeight;
|
|
10698
10646
|
var posZ = curRadius * cosTheta;
|
|
@@ -10826,8 +10774,8 @@ var PrimitiveType;
|
|
|
10826
10774
|
indices[indicesOffset++] = d;
|
|
10827
10775
|
indices[indicesOffset++] = c;
|
|
10828
10776
|
}
|
|
10829
|
-
PrimitiveMesh._createCapsuleCap(radius, height, radialSegments, thetaRange, torsoVertexCount, 1, vertices, indices, indicesOffset);
|
|
10830
|
-
PrimitiveMesh._createCapsuleCap(radius, height, radialSegments, -thetaRange, torsoVertexCount + capVertexCount, -1, vertices, indices, indicesOffset + 6 * capRectangleCount);
|
|
10777
|
+
PrimitiveMesh._createCapsuleCap(radius, height, radialSegments, thetaStart, thetaRange, torsoVertexCount, 1, vertices, indices, indicesOffset);
|
|
10778
|
+
PrimitiveMesh._createCapsuleCap(radius, height, radialSegments, thetaStart, -thetaRange, torsoVertexCount + capVertexCount, -1, vertices, indices, indicesOffset + 6 * capRectangleCount);
|
|
10831
10779
|
if (!isRestoreMode) {
|
|
10832
10780
|
var bounds = capsuleMesh.bounds;
|
|
10833
10781
|
bounds.min.set(-radius, -radius - halfHeight, -radius);
|
|
@@ -10868,7 +10816,7 @@ var PrimitiveType;
|
|
|
10868
10816
|
}
|
|
10869
10817
|
return indices;
|
|
10870
10818
|
};
|
|
10871
|
-
PrimitiveMesh._createCapsuleCap = function _createCapsuleCap(radius, height, radialSegments,
|
|
10819
|
+
PrimitiveMesh._createCapsuleCap = function _createCapsuleCap(radius, height, radialSegments, thetaStart, thetaRange, offset, posIndex, vertices, indices, indicesOffset) {
|
|
10872
10820
|
var radialCount = radialSegments + 1;
|
|
10873
10821
|
var halfHeight = height * 0.5 * posIndex;
|
|
10874
10822
|
var capVertexCount = radialCount * radialCount;
|
|
@@ -10881,12 +10829,12 @@ var PrimitiveType;
|
|
|
10881
10829
|
var y = i * radialCountReciprocal | 0;
|
|
10882
10830
|
var u = x * radialSegmentsReciprocal;
|
|
10883
10831
|
var v = y * radialSegmentsReciprocal;
|
|
10884
|
-
var
|
|
10885
|
-
var
|
|
10886
|
-
var
|
|
10887
|
-
var posX =
|
|
10888
|
-
var posY = radius * Math.cos(
|
|
10889
|
-
var posZ = radius * Math.
|
|
10832
|
+
var theta = thetaStart + u * thetaRange;
|
|
10833
|
+
var alpha = v * Math.PI * 0.5;
|
|
10834
|
+
var sinAlpha = Math.sin(alpha);
|
|
10835
|
+
var posX = radius * Math.sin(theta) * sinAlpha;
|
|
10836
|
+
var posY = radius * Math.cos(alpha) * posIndex + halfHeight;
|
|
10837
|
+
var posZ = radius * Math.cos(theta) * sinAlpha;
|
|
10890
10838
|
var index = (i + offset) * vertexFloatCount;
|
|
10891
10839
|
// Position
|
|
10892
10840
|
vertices[index++] = posX;
|
|
@@ -10920,29 +10868,91 @@ var PrimitiveType;
|
|
|
10920
10868
|
(function() {
|
|
10921
10869
|
PrimitiveMesh._tempVec30 = new engineMath.Vector3();
|
|
10922
10870
|
})();
|
|
10923
|
-
|
|
10924
|
-
|
|
10925
|
-
|
|
10926
|
-
|
|
10927
|
-
|
|
10928
|
-
|
|
10929
|
-
|
|
10930
|
-
|
|
10931
|
-
|
|
10932
|
-
|
|
10933
|
-
|
|
10934
|
-
|
|
10935
|
-
|
|
10936
|
-
|
|
10937
|
-
|
|
10938
|
-
|
|
10939
|
-
|
|
10940
|
-
|
|
10941
|
-
|
|
10942
|
-
|
|
10943
|
-
|
|
10944
|
-
|
|
10945
|
-
|
|
10871
|
+
(function() {
|
|
10872
|
+
PrimitiveMesh._sphereSeedPositions = new Float32Array([
|
|
10873
|
+
-1,
|
|
10874
|
+
1,
|
|
10875
|
+
1,
|
|
10876
|
+
-1,
|
|
10877
|
+
-1,
|
|
10878
|
+
1,
|
|
10879
|
+
1,
|
|
10880
|
+
-1,
|
|
10881
|
+
1,
|
|
10882
|
+
1,
|
|
10883
|
+
1,
|
|
10884
|
+
1,
|
|
10885
|
+
1,
|
|
10886
|
+
-1,
|
|
10887
|
+
-1,
|
|
10888
|
+
1,
|
|
10889
|
+
1,
|
|
10890
|
+
-1,
|
|
10891
|
+
-1,
|
|
10892
|
+
-1,
|
|
10893
|
+
-1,
|
|
10894
|
+
-1,
|
|
10895
|
+
1,
|
|
10896
|
+
-1
|
|
10897
|
+
]);
|
|
10898
|
+
})();
|
|
10899
|
+
(function() {
|
|
10900
|
+
PrimitiveMesh._sphereSeedCells = new Float32Array([
|
|
10901
|
+
0,
|
|
10902
|
+
1,
|
|
10903
|
+
2,
|
|
10904
|
+
3,
|
|
10905
|
+
3,
|
|
10906
|
+
2,
|
|
10907
|
+
4,
|
|
10908
|
+
5,
|
|
10909
|
+
5,
|
|
10910
|
+
4,
|
|
10911
|
+
6,
|
|
10912
|
+
7,
|
|
10913
|
+
7,
|
|
10914
|
+
0,
|
|
10915
|
+
3,
|
|
10916
|
+
5,
|
|
10917
|
+
7,
|
|
10918
|
+
6,
|
|
10919
|
+
1,
|
|
10920
|
+
0,
|
|
10921
|
+
6,
|
|
10922
|
+
4,
|
|
10923
|
+
2,
|
|
10924
|
+
1
|
|
10925
|
+
]);
|
|
10926
|
+
})();
|
|
10927
|
+
(function() {
|
|
10928
|
+
PrimitiveMesh._sphereEdgeIdx = 0;
|
|
10929
|
+
})();
|
|
10930
|
+
(function() {
|
|
10931
|
+
PrimitiveMesh._spherePoleIdx = 0;
|
|
10932
|
+
})();
|
|
10933
|
+
|
|
10934
|
+
/**
|
|
10935
|
+
* Mesh skin data, equal glTF skins define
|
|
10936
|
+
*/ var Skin = /*#__PURE__*/ function(EngineObject1) {
|
|
10937
|
+
_inherits(Skin, EngineObject1);
|
|
10938
|
+
function Skin(name) {
|
|
10939
|
+
var _this;
|
|
10940
|
+
_this = EngineObject1.call(this, null) || this;
|
|
10941
|
+
_this.name = name;
|
|
10942
|
+
_this._bones = [];
|
|
10943
|
+
_this.inverseBindMatrices = []; // inverse bind matrix array
|
|
10944
|
+
_this.joints = []; // joints name array, element type: string
|
|
10945
|
+
_this.skeleton = "none"; // root bone name
|
|
10946
|
+
return _this;
|
|
10947
|
+
}
|
|
10948
|
+
return Skin;
|
|
10949
|
+
}(EngineObject);
|
|
10950
|
+
|
|
10951
|
+
/**
|
|
10952
|
+
* SkinnedMeshRenderer.
|
|
10953
|
+
*/ var SkinnedMeshRenderer = /*#__PURE__*/ function(MeshRenderer1) {
|
|
10954
|
+
_inherits(SkinnedMeshRenderer, MeshRenderer1);
|
|
10955
|
+
function SkinnedMeshRenderer(entity) {
|
|
10946
10956
|
var _this;
|
|
10947
10957
|
_this = MeshRenderer1.call(this, entity) || this;
|
|
10948
10958
|
_this._localBounds = new engineMath.BoundingBox();
|
|
@@ -11383,7 +11393,9 @@ var Basic2DBatcher = /*#__PURE__*/ function() {
|
|
|
11383
11393
|
this._batchedQueue = null;
|
|
11384
11394
|
var _this = this, meshes = _this._meshes, vertexBuffers = _this._vertexBuffers, indiceBuffers = _this._indiceBuffers;
|
|
11385
11395
|
for(var i = 0, n = meshes.length; i < n; ++i){
|
|
11386
|
-
meshes[i]
|
|
11396
|
+
var mesh = meshes[i];
|
|
11397
|
+
mesh._addReferCount(-1);
|
|
11398
|
+
mesh.destroy();
|
|
11387
11399
|
}
|
|
11388
11400
|
this._meshes = null;
|
|
11389
11401
|
for(var i1 = 0, n1 = vertexBuffers.length; i1 < n1; ++i1){
|
|
@@ -11406,7 +11418,7 @@ var Basic2DBatcher = /*#__PURE__*/ function() {
|
|
|
11406
11418
|
_proto._createMesh = function _createMesh(engine, index) {
|
|
11407
11419
|
var MAX_VERTEX_COUNT = Basic2DBatcher.MAX_VERTEX_COUNT;
|
|
11408
11420
|
var mesh = new BufferMesh(engine, "BufferMesh" + index);
|
|
11409
|
-
mesh.
|
|
11421
|
+
mesh._addReferCount(1);
|
|
11410
11422
|
var vertexElements = [];
|
|
11411
11423
|
var vertexStride = this.createVertexElements(vertexElements);
|
|
11412
11424
|
// vertices
|
|
@@ -11464,8 +11476,10 @@ var Basic2DBatcher = /*#__PURE__*/ function() {
|
|
|
11464
11476
|
}
|
|
11465
11477
|
mesh.addSubMesh(this._getSubMeshFromPool(vertexStartIndex, vertexCount));
|
|
11466
11478
|
batchedQueue[curMeshIndex] = preElement;
|
|
11467
|
-
|
|
11468
|
-
|
|
11479
|
+
// Set data option use Discard, or will resulted in performance slowdown when open antialias and cross-rendering of 3D and 2D elements.
|
|
11480
|
+
// Device: iphone X(16.7.2)、iphone 15 pro max(17.1.1)、iphone XR(17.1.2) etc.
|
|
11481
|
+
this._vertexBuffers[_flushId].setData(vertices, 0, 0, vertexIndex, exports.SetDataOptions.Discard);
|
|
11482
|
+
this._indiceBuffers[_flushId].setData(indices, 0, 0, indiceIndex, exports.SetDataOptions.Discard);
|
|
11469
11483
|
};
|
|
11470
11484
|
_proto._getSubMeshFromPool = function _getSubMeshFromPool(start, count) {
|
|
11471
11485
|
var subMesh = this._subMeshPool.getFromPool();
|
|
@@ -12495,6 +12509,9 @@ var /**
|
|
|
12495
12509
|
__decorate([
|
|
12496
12510
|
assignmentClone
|
|
12497
12511
|
], SpriteMask.prototype, "influenceLayers", void 0);
|
|
12512
|
+
__decorate([
|
|
12513
|
+
ignoreClone
|
|
12514
|
+
], SpriteMask.prototype, "_verticesData", void 0);
|
|
12498
12515
|
__decorate([
|
|
12499
12516
|
ignoreClone
|
|
12500
12517
|
], SpriteMask.prototype, "_sprite", void 0);
|
|
@@ -12778,8 +12795,8 @@ var /**
|
|
|
12778
12795
|
} else {
|
|
12779
12796
|
word += char;
|
|
12780
12797
|
wordWidth += charInfo.xAdvance;
|
|
12781
|
-
wordMaxAscent =
|
|
12782
|
-
wordMaxDescent =
|
|
12798
|
+
wordMaxAscent = Math.max(wordMaxAscent, ascent);
|
|
12799
|
+
wordMaxDescent = Math.max(wordMaxDescent, descent);
|
|
12783
12800
|
}
|
|
12784
12801
|
}
|
|
12785
12802
|
}
|
|
@@ -12900,6 +12917,9 @@ var /**
|
|
|
12900
12917
|
var baseline = Math.ceil(context.measureText(TextUtils._measureBaseline).width);
|
|
12901
12918
|
var height = baseline * TextUtils._heightMultiplier;
|
|
12902
12919
|
baseline = TextUtils._baselineMultiplier * baseline | 0;
|
|
12920
|
+
var _extendHeight = TextUtils._extendHeight;
|
|
12921
|
+
height += _extendHeight;
|
|
12922
|
+
baseline += _extendHeight * 0.5;
|
|
12903
12923
|
canvas.width = width;
|
|
12904
12924
|
canvas.height = height;
|
|
12905
12925
|
context.font = fontString;
|
|
@@ -12934,6 +12954,7 @@ var /**
|
|
|
12934
12954
|
}
|
|
12935
12955
|
if (top !== -1 && bottom !== -1) {
|
|
12936
12956
|
ascent = baseline - top;
|
|
12957
|
+
// Baseline belong to descent
|
|
12937
12958
|
descent = bottom - baseline + 1;
|
|
12938
12959
|
size = ascent + descent;
|
|
12939
12960
|
}
|
|
@@ -13009,6 +13030,10 @@ var /**
|
|
|
13009
13030
|
"fangsong"
|
|
13010
13031
|
];
|
|
13011
13032
|
})();
|
|
13033
|
+
(function() {
|
|
13034
|
+
// _extendHeight used to extend the height of canvas, because in miniprogram performance is different from h5.
|
|
13035
|
+
/** @internal */ TextUtils._extendHeight = 0;
|
|
13036
|
+
})();
|
|
13012
13037
|
(function() {
|
|
13013
13038
|
/** These characters are all tall to help calculate the height required for text. */ TextUtils._measureString = "|\xc9q\xc5";
|
|
13014
13039
|
})();
|
|
@@ -13099,7 +13124,8 @@ var /**
|
|
|
13099
13124
|
_proto._createFontAtlas = function _createFontAtlas() {
|
|
13100
13125
|
var _this = this, engine = _this._engine;
|
|
13101
13126
|
var fontAtlas = new FontAtlas(engine);
|
|
13102
|
-
var texture = new Texture2D(engine, 256, 256);
|
|
13127
|
+
var texture = new Texture2D(engine, 256, 256, exports.TextureFormat.R8G8B8A8, false);
|
|
13128
|
+
texture.filterMode = exports.TextureFilterMode.Bilinear;
|
|
13103
13129
|
fontAtlas.texture = texture;
|
|
13104
13130
|
fontAtlas.isGCIgnored = texture.isGCIgnored = true;
|
|
13105
13131
|
this._fontAtlases.push(fontAtlas);
|
|
@@ -13337,7 +13363,7 @@ var /**
|
|
|
13337
13363
|
/**
|
|
13338
13364
|
* @internal
|
|
13339
13365
|
*/ _proto._render = function _render(context) {
|
|
13340
|
-
if (this.
|
|
13366
|
+
if (this._isTextNoVisible()) {
|
|
13341
13367
|
return;
|
|
13342
13368
|
}
|
|
13343
13369
|
if (this._isContainDirtyFlag(0x10)) {
|
|
@@ -13429,8 +13455,8 @@ var /**
|
|
|
13429
13455
|
}
|
|
13430
13456
|
};
|
|
13431
13457
|
_proto._updateLocalData = function _updateLocalData() {
|
|
13432
|
-
var _this = this, color = _this.color, charRenderDatas = _this._charRenderDatas, charFont = _this._subFont;
|
|
13433
13458
|
var _this__localBounds = this._localBounds, min = _this__localBounds.min, max = _this__localBounds.max;
|
|
13459
|
+
var _this = this, color = _this.color, charRenderDatas = _this._charRenderDatas, charFont = _this._subFont;
|
|
13434
13460
|
var textMetrics = this.enableWrapping ? TextUtils.measureTextWithWrap(this) : TextUtils.measureTextWithoutWrap(this);
|
|
13435
13461
|
var height = textMetrics.height, lines = textMetrics.lines, lineWidths = textMetrics.lineWidths, lineHeight = textMetrics.lineHeight, lineMaxSizes = textMetrics.lineMaxSizes;
|
|
13436
13462
|
var charRenderDataPool = TextRenderer._charRenderDataPool;
|
|
@@ -13498,7 +13524,7 @@ var /**
|
|
|
13498
13524
|
var left = startX * pixelsPerUnitReciprocal;
|
|
13499
13525
|
var right = (startX + w) * pixelsPerUnitReciprocal;
|
|
13500
13526
|
var top = (startY + ascent) * pixelsPerUnitReciprocal;
|
|
13501
|
-
var bottom = (startY - descent
|
|
13527
|
+
var bottom = (startY - descent) * pixelsPerUnitReciprocal;
|
|
13502
13528
|
localPositions.set(left, top, right, bottom);
|
|
13503
13529
|
i === firstLine && (maxY = Math.max(maxY, top));
|
|
13504
13530
|
minY = Math.min(minY, bottom);
|
|
@@ -13539,6 +13565,9 @@ var /**
|
|
|
13539
13565
|
Renderer1.prototype._onTransformChanged.call(this, bit);
|
|
13540
13566
|
this._setDirtyFlagTrue(0x4 | 0x8);
|
|
13541
13567
|
};
|
|
13568
|
+
_proto._isTextNoVisible = function _isTextNoVisible() {
|
|
13569
|
+
return this._text === "" || this._fontSize === 0 || this.enableWrapping && this.width <= 0 || this.overflowMode === exports.OverflowMode.Truncate && this.height <= 0;
|
|
13570
|
+
};
|
|
13542
13571
|
_create_class(TextRenderer, [
|
|
13543
13572
|
{
|
|
13544
13573
|
key: "color",
|
|
@@ -13741,6 +13770,16 @@ var /**
|
|
|
13741
13770
|
get: /**
|
|
13742
13771
|
* The bounding volume of the TextRenderer.
|
|
13743
13772
|
*/ function get() {
|
|
13773
|
+
if (this._isTextNoVisible()) {
|
|
13774
|
+
if (this._isContainDirtyFlag(0x8)) {
|
|
13775
|
+
var localBounds = this._localBounds;
|
|
13776
|
+
localBounds.min.set(0, 0, 0);
|
|
13777
|
+
localBounds.max.set(0, 0, 0);
|
|
13778
|
+
this._updateBounds(this._bounds);
|
|
13779
|
+
this._setDirtyFlagFalse(0x8);
|
|
13780
|
+
}
|
|
13781
|
+
return this._bounds;
|
|
13782
|
+
}
|
|
13744
13783
|
this._isContainDirtyFlag(0x1) && this._resetSubFont();
|
|
13745
13784
|
this._isContainDirtyFlag(0x2) && this._updateLocalData();
|
|
13746
13785
|
this._isContainDirtyFlag(0x4) && this._updatePosition();
|
|
@@ -14762,6 +14801,7 @@ var TextRenderData = /*#__PURE__*/ function(RenderData1) {
|
|
|
14762
14801
|
AssetType[/** Cube Compress Texture. */ "KTXCube"] = "KTXCube";
|
|
14763
14802
|
AssetType[/** KTX2 Compress Texture */ "KTX2"] = "KTX2";
|
|
14764
14803
|
AssetType[/** Sprite. */ "Sprite"] = "Sprite";
|
|
14804
|
+
AssetType[/** PrimitiveMesh. */ "PrimitiveMesh"] = "PrimitiveMesh";
|
|
14765
14805
|
AssetType[/** Sprite Atlas. */ "SpriteAtlas"] = "SpriteAtlas";
|
|
14766
14806
|
AssetType[/** Ambient light. */ "Env"] = "Environment";
|
|
14767
14807
|
AssetType[/** Scene. */ "Scene"] = "Scene";
|
|
@@ -15147,6 +15187,7 @@ var /** @internal */ PromiseState;
|
|
|
15147
15187
|
this./** The number of retries after failing to load assets. */ retryCount = 1;
|
|
15148
15188
|
this./** Retry delay time after failed to load assets, in milliseconds. */ retryInterval = 0;
|
|
15149
15189
|
this./** The default timeout period for loading assets, in milliseconds. */ timeout = Infinity;
|
|
15190
|
+
this./** Base url for loading assets. */ baseUrl = null;
|
|
15150
15191
|
this._loadingPromises = {};
|
|
15151
15192
|
this._assetPool = Object.create(null);
|
|
15152
15193
|
this._assetUrlPool = Object.create(null);
|
|
@@ -15350,6 +15391,8 @@ var /** @internal */ PromiseState;
|
|
|
15350
15391
|
// Check url mapping
|
|
15351
15392
|
var itemURL = item.url;
|
|
15352
15393
|
var url = this._virtualPathMap[itemURL] ? this._virtualPathMap[itemURL] : itemURL;
|
|
15394
|
+
// Not absolute and base url is set
|
|
15395
|
+
if (!Utils.isAbsoluteUrl(url) && this.baseUrl) url = Utils.resolveAbsoluteUrl(this.baseUrl, url);
|
|
15353
15396
|
// Parse url
|
|
15354
15397
|
var _this__parseURL = this._parseURL(url), assetBaseURL = _this__parseURL.assetBaseURL, queryPath = _this__parseURL.queryPath;
|
|
15355
15398
|
var paths = queryPath ? this._parseQueryPath(queryPath) : [];
|
|
@@ -15442,10 +15485,20 @@ var /** @internal */ PromiseState;
|
|
|
15442
15485
|
};
|
|
15443
15486
|
_proto._parseURL = function _parseURL(path) {
|
|
15444
15487
|
var _path_split = path.split("?"), baseUrl = _path_split[0], searchStr = _path_split[1];
|
|
15445
|
-
var
|
|
15446
|
-
var
|
|
15447
|
-
|
|
15448
|
-
|
|
15488
|
+
var queryPath = undefined;
|
|
15489
|
+
var assetBaseURL = baseUrl;
|
|
15490
|
+
if (searchStr) {
|
|
15491
|
+
var params = searchStr.split("&");
|
|
15492
|
+
for(var i = 0; i < params.length; i++){
|
|
15493
|
+
var param = params[i];
|
|
15494
|
+
if (param.startsWith("q=")) {
|
|
15495
|
+
queryPath = decodeURIComponent(param.split("=")[1]);
|
|
15496
|
+
params.splice(i, 1);
|
|
15497
|
+
break;
|
|
15498
|
+
}
|
|
15499
|
+
}
|
|
15500
|
+
assetBaseURL = params.length > 0 ? baseUrl + "?" + params.join("&") : baseUrl;
|
|
15501
|
+
}
|
|
15449
15502
|
return {
|
|
15450
15503
|
assetBaseURL: assetBaseURL,
|
|
15451
15504
|
queryPath: queryPath
|
|
@@ -15729,6 +15782,66 @@ var rePropName = RegExp(// Match anything that isn't a dot or bracket.
|
|
|
15729
15782
|
}
|
|
15730
15783
|
}
|
|
15731
15784
|
};
|
|
15785
|
+
/**
|
|
15786
|
+
* @internal
|
|
15787
|
+
*/ SystemInfo._detectSIMDSupported = function _detectSIMDSupported() {
|
|
15788
|
+
if (this._simdSupported === null) {
|
|
15789
|
+
this._simdSupported = WebAssembly.validate(new Uint8Array([
|
|
15790
|
+
0,
|
|
15791
|
+
97,
|
|
15792
|
+
115,
|
|
15793
|
+
109,
|
|
15794
|
+
1,
|
|
15795
|
+
0,
|
|
15796
|
+
0,
|
|
15797
|
+
0,
|
|
15798
|
+
1,
|
|
15799
|
+
4,
|
|
15800
|
+
1,
|
|
15801
|
+
96,
|
|
15802
|
+
0,
|
|
15803
|
+
0,
|
|
15804
|
+
3,
|
|
15805
|
+
3,
|
|
15806
|
+
2,
|
|
15807
|
+
0,
|
|
15808
|
+
0,
|
|
15809
|
+
5,
|
|
15810
|
+
3,
|
|
15811
|
+
1,
|
|
15812
|
+
0,
|
|
15813
|
+
1,
|
|
15814
|
+
12,
|
|
15815
|
+
1,
|
|
15816
|
+
0,
|
|
15817
|
+
10,
|
|
15818
|
+
22,
|
|
15819
|
+
2,
|
|
15820
|
+
12,
|
|
15821
|
+
0,
|
|
15822
|
+
65,
|
|
15823
|
+
0,
|
|
15824
|
+
65,
|
|
15825
|
+
0,
|
|
15826
|
+
65,
|
|
15827
|
+
0,
|
|
15828
|
+
252,
|
|
15829
|
+
10,
|
|
15830
|
+
0,
|
|
15831
|
+
0,
|
|
15832
|
+
11,
|
|
15833
|
+
7,
|
|
15834
|
+
0,
|
|
15835
|
+
65,
|
|
15836
|
+
0,
|
|
15837
|
+
253,
|
|
15838
|
+
15,
|
|
15839
|
+
26,
|
|
15840
|
+
11
|
|
15841
|
+
]));
|
|
15842
|
+
}
|
|
15843
|
+
return this._simdSupported;
|
|
15844
|
+
};
|
|
15732
15845
|
_create_class(SystemInfo, null, [
|
|
15733
15846
|
{
|
|
15734
15847
|
key: "devicePixelRatio",
|
|
@@ -15747,6 +15860,9 @@ var rePropName = RegExp(// Match anything that isn't a dot or bracket.
|
|
|
15747
15860
|
(function() {
|
|
15748
15861
|
/** The operating system is running on. */ SystemInfo.operatingSystem = "";
|
|
15749
15862
|
})();
|
|
15863
|
+
(function() {
|
|
15864
|
+
/** Whether the system support SIMD. */ SystemInfo._simdSupported = null;
|
|
15865
|
+
})();
|
|
15750
15866
|
SystemInfo._initialize();
|
|
15751
15867
|
|
|
15752
15868
|
/**
|
|
@@ -15977,7 +16093,7 @@ SystemInfo._initialize();
|
|
|
15977
16093
|
* Keyboard Manager.
|
|
15978
16094
|
* @internal
|
|
15979
16095
|
*/ var KeyboardManager = /*#__PURE__*/ function() {
|
|
15980
|
-
function KeyboardManager(engine) {
|
|
16096
|
+
function KeyboardManager(engine, target) {
|
|
15981
16097
|
/** @internal */ this._curHeldDownKeyToIndexMap = [];
|
|
15982
16098
|
/** @internal */ this._upKeyToFrameCountMap = [];
|
|
15983
16099
|
/** @internal */ this._downKeyToFrameCountMap = [];
|
|
@@ -15985,17 +16101,11 @@ SystemInfo._initialize();
|
|
|
15985
16101
|
/** @internal */ this._curFrameDownList = new DisorderedArray();
|
|
15986
16102
|
/** @internal */ this._curFrameUpList = new DisorderedArray();
|
|
15987
16103
|
this._nativeEvents = [];
|
|
15988
|
-
this._hadListener = false;
|
|
15989
|
-
// @ts-ignore
|
|
15990
|
-
var htmlCanvas = engine._canvas._webCanvas;
|
|
15991
16104
|
this._engine = engine;
|
|
15992
|
-
this.
|
|
15993
|
-
// Need to set tabIndex to make the canvas focus.
|
|
15994
|
-
htmlCanvas.tabIndex = htmlCanvas.tabIndex;
|
|
16105
|
+
this._onBlur = this._onBlur.bind(this);
|
|
15995
16106
|
this._onKeyEvent = this._onKeyEvent.bind(this);
|
|
15996
|
-
|
|
15997
|
-
|
|
15998
|
-
this._hadListener = true;
|
|
16107
|
+
this._target = target;
|
|
16108
|
+
this._addEventListener();
|
|
15999
16109
|
}
|
|
16000
16110
|
var _proto = KeyboardManager.prototype;
|
|
16001
16111
|
/**
|
|
@@ -16047,35 +16157,8 @@ SystemInfo._initialize();
|
|
|
16047
16157
|
};
|
|
16048
16158
|
/**
|
|
16049
16159
|
* @internal
|
|
16050
|
-
*/ _proto._onFocus = function _onFocus() {
|
|
16051
|
-
if (!this._hadListener) {
|
|
16052
|
-
this._htmlCanvas.addEventListener("keydown", this._onKeyEvent);
|
|
16053
|
-
this._htmlCanvas.addEventListener("keyup", this._onKeyEvent);
|
|
16054
|
-
this._hadListener = true;
|
|
16055
|
-
}
|
|
16056
|
-
};
|
|
16057
|
-
/**
|
|
16058
|
-
* @internal
|
|
16059
|
-
*/ _proto._onBlur = function _onBlur() {
|
|
16060
|
-
if (this._hadListener) {
|
|
16061
|
-
this._htmlCanvas.removeEventListener("keydown", this._onKeyEvent);
|
|
16062
|
-
this._htmlCanvas.removeEventListener("keyup", this._onKeyEvent);
|
|
16063
|
-
this._curHeldDownKeyToIndexMap.length = 0;
|
|
16064
|
-
this._curFrameHeldDownList.length = 0;
|
|
16065
|
-
this._curFrameDownList.length = 0;
|
|
16066
|
-
this._curFrameUpList.length = 0;
|
|
16067
|
-
this._nativeEvents.length = 0;
|
|
16068
|
-
this._hadListener = false;
|
|
16069
|
-
}
|
|
16070
|
-
};
|
|
16071
|
-
/**
|
|
16072
|
-
* @internal
|
|
16073
16160
|
*/ _proto._destroy = function _destroy() {
|
|
16074
|
-
|
|
16075
|
-
this._htmlCanvas.removeEventListener("keydown", this._onKeyEvent);
|
|
16076
|
-
this._htmlCanvas.removeEventListener("keyup", this._onKeyEvent);
|
|
16077
|
-
this._hadListener = false;
|
|
16078
|
-
}
|
|
16161
|
+
this._removeEventListener();
|
|
16079
16162
|
this._curHeldDownKeyToIndexMap.length = 0;
|
|
16080
16163
|
this._curHeldDownKeyToIndexMap = null;
|
|
16081
16164
|
this._upKeyToFrameCountMap.length = 0;
|
|
@@ -16090,12 +16173,30 @@ SystemInfo._initialize();
|
|
|
16090
16173
|
this._curFrameDownList = null;
|
|
16091
16174
|
this._curFrameUpList.length = 0;
|
|
16092
16175
|
this._curFrameUpList = null;
|
|
16093
|
-
this._htmlCanvas = null;
|
|
16094
16176
|
this._engine = null;
|
|
16095
16177
|
};
|
|
16178
|
+
_proto._onBlur = function _onBlur() {
|
|
16179
|
+
this._curHeldDownKeyToIndexMap.length = 0;
|
|
16180
|
+
this._curFrameHeldDownList.length = 0;
|
|
16181
|
+
this._curFrameDownList.length = 0;
|
|
16182
|
+
this._curFrameUpList.length = 0;
|
|
16183
|
+
this._nativeEvents.length = 0;
|
|
16184
|
+
};
|
|
16096
16185
|
_proto._onKeyEvent = function _onKeyEvent(evt) {
|
|
16097
16186
|
this._nativeEvents.push(evt);
|
|
16098
16187
|
};
|
|
16188
|
+
_proto._addEventListener = function _addEventListener() {
|
|
16189
|
+
var _this = this, target = _this._target;
|
|
16190
|
+
target.addEventListener("keydown", this._onKeyEvent);
|
|
16191
|
+
target.addEventListener("keyup", this._onKeyEvent);
|
|
16192
|
+
target.addEventListener("blur", this._onBlur);
|
|
16193
|
+
};
|
|
16194
|
+
_proto._removeEventListener = function _removeEventListener() {
|
|
16195
|
+
var _this = this, target = _this._target;
|
|
16196
|
+
target.removeEventListener("keydown", this._onKeyEvent);
|
|
16197
|
+
target.removeEventListener("keyup", this._onKeyEvent);
|
|
16198
|
+
target.removeEventListener("blur", this._onBlur);
|
|
16199
|
+
};
|
|
16099
16200
|
return KeyboardManager;
|
|
16100
16201
|
}();
|
|
16101
16202
|
|
|
@@ -16398,7 +16499,9 @@ var Collision = function Collision() {
|
|
|
16398
16499
|
};
|
|
16399
16500
|
if (hitResult != undefined) {
|
|
16400
16501
|
var result = this._nativePhysicsScene.raycast(ray, distance, onRaycast, function(idx, distance, position, normal) {
|
|
16401
|
-
|
|
16502
|
+
var hitShape = _this._scene.engine._physicalObjectsMap[idx];
|
|
16503
|
+
hitResult.entity = hitShape._collider.entity;
|
|
16504
|
+
hitResult.shape = hitShape;
|
|
16402
16505
|
hitResult.distance = distance;
|
|
16403
16506
|
hitResult.normal.copyFrom(normal);
|
|
16404
16507
|
hitResult.point.copyFrom(position);
|
|
@@ -16407,6 +16510,7 @@ var Collision = function Collision() {
|
|
|
16407
16510
|
return true;
|
|
16408
16511
|
} else {
|
|
16409
16512
|
hitResult.entity = null;
|
|
16513
|
+
hitResult.shape = null;
|
|
16410
16514
|
hitResult.distance = 0;
|
|
16411
16515
|
hitResult.point.set(0, 0, 0);
|
|
16412
16516
|
hitResult.normal.set(0, 0, 0);
|
|
@@ -17068,6 +17172,7 @@ exports.DynamicColliderConstraints = void 0;
|
|
|
17068
17172
|
/** The distance from the ray's origin to the impact point. */ this.distance = 0;
|
|
17069
17173
|
/** The impact point in world space where the ray hit the collider. */ this.point = new engineMath.Vector3();
|
|
17070
17174
|
/** The normal of the surface the ray hit. */ this.normal = new engineMath.Vector3();
|
|
17175
|
+
/** The shape of the collider that was hit. */ this.shape = null;
|
|
17071
17176
|
};
|
|
17072
17177
|
|
|
17073
17178
|
/**
|
|
@@ -18059,7 +18164,7 @@ __decorate([
|
|
|
18059
18164
|
* Pointer Manager.
|
|
18060
18165
|
* @internal
|
|
18061
18166
|
*/ var PointerManager = /*#__PURE__*/ function() {
|
|
18062
|
-
function PointerManager(engine) {
|
|
18167
|
+
function PointerManager(engine, target) {
|
|
18063
18168
|
/** @internal */ this._pointers = [];
|
|
18064
18169
|
/** @internal */ this._multiPointerEnabled = true;
|
|
18065
18170
|
/** @internal */ this._buttons = exports.PointerButton.None;
|
|
@@ -18068,16 +18173,18 @@ __decorate([
|
|
|
18068
18173
|
/** @internal */ this._upList = new DisorderedArray();
|
|
18069
18174
|
/** @internal */ this._downList = new DisorderedArray();
|
|
18070
18175
|
this._nativeEvents = [];
|
|
18071
|
-
|
|
18072
|
-
|
|
18073
|
-
|
|
18176
|
+
if (_instanceof(target, Window)) {
|
|
18177
|
+
throw "Do not set window as target because window cannot listen to pointer leave event.";
|
|
18178
|
+
}
|
|
18074
18179
|
this._engine = engine;
|
|
18180
|
+
this._target = target;
|
|
18075
18181
|
this._canvas = engine.canvas;
|
|
18076
|
-
|
|
18077
|
-
this.
|
|
18078
|
-
this._onFocus();
|
|
18182
|
+
// @ts-ignore
|
|
18183
|
+
this._htmlCanvas = engine._canvas._webCanvas;
|
|
18079
18184
|
// If there are no compatibility issues, navigator.maxTouchPoints should be used here
|
|
18080
18185
|
this._pointerPool = new Array(11);
|
|
18186
|
+
this._onPointerEvent = this._onPointerEvent.bind(this);
|
|
18187
|
+
this._addEventListener();
|
|
18081
18188
|
}
|
|
18082
18189
|
var _proto = PointerManager.prototype;
|
|
18083
18190
|
/**
|
|
@@ -18147,7 +18254,8 @@ __decorate([
|
|
|
18147
18254
|
var length = events.length;
|
|
18148
18255
|
if (length > 0) {
|
|
18149
18256
|
for(var i1 = 0; i1 < length; i1++){
|
|
18150
|
-
|
|
18257
|
+
var event = events[i1];
|
|
18258
|
+
switch(event.type){
|
|
18151
18259
|
case "pointerdown":
|
|
18152
18260
|
pointer.phase = exports.PointerPhase.Down;
|
|
18153
18261
|
pointer._firePointerDown(rayCastEntity);
|
|
@@ -18169,66 +18277,14 @@ __decorate([
|
|
|
18169
18277
|
};
|
|
18170
18278
|
/**
|
|
18171
18279
|
* @internal
|
|
18172
|
-
*/ _proto._onFocus = function _onFocus() {
|
|
18173
|
-
if (!this._hadListener) {
|
|
18174
|
-
var _this = this, htmlCanvas = _this._htmlCanvas, onPointerEvent = _this._onPointerEvent;
|
|
18175
|
-
htmlCanvas.addEventListener("pointerdown", onPointerEvent);
|
|
18176
|
-
htmlCanvas.addEventListener("pointerup", onPointerEvent);
|
|
18177
|
-
htmlCanvas.addEventListener("pointerleave", onPointerEvent);
|
|
18178
|
-
htmlCanvas.addEventListener("pointermove", onPointerEvent);
|
|
18179
|
-
htmlCanvas.addEventListener("pointercancel", onPointerEvent);
|
|
18180
|
-
this._hadListener = true;
|
|
18181
|
-
}
|
|
18182
|
-
};
|
|
18183
|
-
/**
|
|
18184
|
-
* @internal
|
|
18185
|
-
*/ _proto._onBlur = function _onBlur() {
|
|
18186
|
-
if (this._hadListener) {
|
|
18187
|
-
var _this = this, htmlCanvas = _this._htmlCanvas, onPointerEvent = _this._onPointerEvent;
|
|
18188
|
-
htmlCanvas.removeEventListener("pointerdown", onPointerEvent);
|
|
18189
|
-
htmlCanvas.removeEventListener("pointerup", onPointerEvent);
|
|
18190
|
-
htmlCanvas.removeEventListener("pointerleave", onPointerEvent);
|
|
18191
|
-
htmlCanvas.removeEventListener("pointermove", onPointerEvent);
|
|
18192
|
-
htmlCanvas.removeEventListener("pointercancel", onPointerEvent);
|
|
18193
|
-
this._hadListener = false;
|
|
18194
|
-
this._pointers.length = 0;
|
|
18195
|
-
this._downList.length = 0;
|
|
18196
|
-
this._upList.length = 0;
|
|
18197
|
-
}
|
|
18198
|
-
};
|
|
18199
|
-
/**
|
|
18200
|
-
* @internal
|
|
18201
18280
|
*/ _proto._destroy = function _destroy() {
|
|
18202
|
-
|
|
18203
|
-
if (this._hadListener) {
|
|
18204
|
-
var _this = this, htmlCanvas = _this._htmlCanvas, onPointerEvent = _this._onPointerEvent;
|
|
18205
|
-
htmlCanvas.removeEventListener("pointerdown", onPointerEvent);
|
|
18206
|
-
htmlCanvas.removeEventListener("pointerup", onPointerEvent);
|
|
18207
|
-
htmlCanvas.removeEventListener("pointerleave", onPointerEvent);
|
|
18208
|
-
htmlCanvas.removeEventListener("pointermove", onPointerEvent);
|
|
18209
|
-
htmlCanvas.removeEventListener("pointercancel", onPointerEvent);
|
|
18210
|
-
this._hadListener = false;
|
|
18211
|
-
}
|
|
18281
|
+
this._removeEventListener();
|
|
18212
18282
|
this._pointerPool.length = 0;
|
|
18213
|
-
this._pointerPool = null;
|
|
18214
|
-
this._pointers.length = 0;
|
|
18215
|
-
this._pointers = null;
|
|
18216
|
-
this._downList.length = 0;
|
|
18217
|
-
this._downList = null;
|
|
18218
|
-
this._upList.length = 0;
|
|
18219
|
-
this._upList = null;
|
|
18220
18283
|
this._nativeEvents.length = 0;
|
|
18221
|
-
this._nativeEvents = null;
|
|
18222
|
-
this._upMap.length = 0;
|
|
18223
|
-
this._upMap = null;
|
|
18224
18284
|
this._downMap.length = 0;
|
|
18225
|
-
this.
|
|
18226
|
-
this._htmlCanvas = null;
|
|
18227
|
-
this._canvas = null;
|
|
18228
|
-
this._engine = null;
|
|
18285
|
+
this._upMap.length = 0;
|
|
18229
18286
|
};
|
|
18230
18287
|
_proto._onPointerEvent = function _onPointerEvent(evt) {
|
|
18231
|
-
evt.type === "pointerdown" && this._htmlCanvas.focus();
|
|
18232
18288
|
this._nativeEvents.push(evt);
|
|
18233
18289
|
};
|
|
18234
18290
|
_proto._getPointerByID = function _getPointerByID(pointerId) {
|
|
@@ -18311,6 +18367,26 @@ __decorate([
|
|
|
18311
18367
|
}
|
|
18312
18368
|
return null;
|
|
18313
18369
|
};
|
|
18370
|
+
_proto._addEventListener = function _addEventListener() {
|
|
18371
|
+
var _this = this, target = _this._target, onPointerEvent = _this._onPointerEvent;
|
|
18372
|
+
target.addEventListener("pointerdown", onPointerEvent);
|
|
18373
|
+
target.addEventListener("pointerup", onPointerEvent);
|
|
18374
|
+
target.addEventListener("pointerleave", onPointerEvent);
|
|
18375
|
+
target.addEventListener("pointermove", onPointerEvent);
|
|
18376
|
+
target.addEventListener("pointercancel", onPointerEvent);
|
|
18377
|
+
};
|
|
18378
|
+
_proto._removeEventListener = function _removeEventListener() {
|
|
18379
|
+
var _this = this, target = _this._target, onPointerEvent = _this._onPointerEvent;
|
|
18380
|
+
target.removeEventListener("pointerdown", onPointerEvent);
|
|
18381
|
+
target.removeEventListener("pointerup", onPointerEvent);
|
|
18382
|
+
target.removeEventListener("pointerleave", onPointerEvent);
|
|
18383
|
+
target.removeEventListener("pointermove", onPointerEvent);
|
|
18384
|
+
target.removeEventListener("pointercancel", onPointerEvent);
|
|
18385
|
+
this._nativeEvents.length = 0;
|
|
18386
|
+
this._pointers.length = 0;
|
|
18387
|
+
this._downList.length = 0;
|
|
18388
|
+
this._upList.length = 0;
|
|
18389
|
+
};
|
|
18314
18390
|
return PointerManager;
|
|
18315
18391
|
}();
|
|
18316
18392
|
(function() {
|
|
@@ -18327,15 +18403,12 @@ __decorate([
|
|
|
18327
18403
|
* Wheel Manager.
|
|
18328
18404
|
* @internal
|
|
18329
18405
|
*/ var WheelManager = /*#__PURE__*/ function() {
|
|
18330
|
-
function WheelManager(engine) {
|
|
18406
|
+
function WheelManager(engine, target) {
|
|
18331
18407
|
/** @internal */ this._delta = new engineMath.Vector3();
|
|
18332
18408
|
this._nativeEvents = [];
|
|
18333
|
-
// @ts-ignore
|
|
18334
|
-
var htmlCanvas = engine._canvas._webCanvas;
|
|
18335
18409
|
this._onWheelEvent = this._onWheelEvent.bind(this);
|
|
18336
|
-
|
|
18337
|
-
this.
|
|
18338
|
-
this._hadListener = true;
|
|
18410
|
+
this._target = target;
|
|
18411
|
+
this._addEventListener();
|
|
18339
18412
|
}
|
|
18340
18413
|
var _proto = WheelManager.prototype;
|
|
18341
18414
|
/**
|
|
@@ -18356,35 +18429,24 @@ __decorate([
|
|
|
18356
18429
|
};
|
|
18357
18430
|
/**
|
|
18358
18431
|
* @internal
|
|
18359
|
-
*/ _proto.
|
|
18360
|
-
|
|
18361
|
-
this._canvas.addEventListener("wheel", this._onWheelEvent);
|
|
18362
|
-
this._hadListener = true;
|
|
18363
|
-
}
|
|
18432
|
+
*/ _proto._addEventListener = function _addEventListener() {
|
|
18433
|
+
this._target.addEventListener("wheel", this._onWheelEvent);
|
|
18364
18434
|
};
|
|
18365
18435
|
/**
|
|
18366
18436
|
* @internal
|
|
18367
|
-
*/ _proto.
|
|
18368
|
-
|
|
18369
|
-
|
|
18370
|
-
|
|
18371
|
-
this._delta.set(0, 0, 0);
|
|
18372
|
-
this._hadListener = false;
|
|
18373
|
-
}
|
|
18437
|
+
*/ _proto._removeEventListener = function _removeEventListener() {
|
|
18438
|
+
this._target.removeEventListener("wheel", this._onWheelEvent);
|
|
18439
|
+
this._nativeEvents.length = 0;
|
|
18440
|
+
this._delta.set(0, 0, 0);
|
|
18374
18441
|
};
|
|
18375
18442
|
/**
|
|
18376
18443
|
* @internal
|
|
18377
18444
|
*/ _proto._destroy = function _destroy() {
|
|
18378
|
-
|
|
18379
|
-
this._canvas.removeEventListener("wheel", this._onWheelEvent);
|
|
18380
|
-
this._hadListener = false;
|
|
18381
|
-
}
|
|
18445
|
+
this._removeEventListener();
|
|
18382
18446
|
this._nativeEvents = null;
|
|
18383
|
-
this._canvas = null;
|
|
18384
18447
|
this._delta = null;
|
|
18385
18448
|
};
|
|
18386
18449
|
_proto._onWheelEvent = function _onWheelEvent(evt) {
|
|
18387
|
-
evt.cancelable && evt.preventDefault();
|
|
18388
18450
|
this._nativeEvents.push(evt);
|
|
18389
18451
|
};
|
|
18390
18452
|
return WheelManager;
|
|
@@ -18393,19 +18455,19 @@ __decorate([
|
|
|
18393
18455
|
/**
|
|
18394
18456
|
* InputManager manages device input such as mouse, touch, keyboard, etc.
|
|
18395
18457
|
*/ var InputManager = /*#__PURE__*/ function() {
|
|
18396
|
-
function InputManager(engine) {
|
|
18458
|
+
function InputManager(engine, inputOptions) {
|
|
18397
18459
|
/** Sometimes the input module will not be initialized, such as off-screen rendering. */ this._initialized = false;
|
|
18398
18460
|
this._engine = engine;
|
|
18399
18461
|
// @ts-ignore
|
|
18400
18462
|
var canvas = engine._canvas._webCanvas;
|
|
18401
18463
|
if (typeof OffscreenCanvas === "undefined" || !_instanceof(canvas, OffscreenCanvas)) {
|
|
18402
|
-
|
|
18403
|
-
|
|
18404
|
-
this.
|
|
18405
|
-
|
|
18406
|
-
|
|
18407
|
-
|
|
18408
|
-
|
|
18464
|
+
var _inputOptions, _inputOptions1, _inputOptions2;
|
|
18465
|
+
var _inputOptions_wheelTarget;
|
|
18466
|
+
this._wheelManager = new WheelManager(engine, (_inputOptions_wheelTarget = (_inputOptions = inputOptions) == null ? void 0 : _inputOptions.wheelTarget) != null ? _inputOptions_wheelTarget : canvas);
|
|
18467
|
+
var _inputOptions_pointerTarget;
|
|
18468
|
+
this._pointerManager = new PointerManager(engine, (_inputOptions_pointerTarget = (_inputOptions1 = inputOptions) == null ? void 0 : _inputOptions1.pointerTarget) != null ? _inputOptions_pointerTarget : canvas);
|
|
18469
|
+
var _inputOptions_keyboardTarget;
|
|
18470
|
+
this._keyboardManager = new KeyboardManager(engine, (_inputOptions_keyboardTarget = (_inputOptions2 = inputOptions) == null ? void 0 : _inputOptions2.keyboardTarget) != null ? _inputOptions_keyboardTarget : window);
|
|
18409
18471
|
this._initialized = true;
|
|
18410
18472
|
}
|
|
18411
18473
|
}
|
|
@@ -18518,8 +18580,6 @@ __decorate([
|
|
|
18518
18580
|
* @internal
|
|
18519
18581
|
*/ _proto._destroy = function _destroy() {
|
|
18520
18582
|
if (this._initialized) {
|
|
18521
|
-
window.removeEventListener("blur", this._onBlur);
|
|
18522
|
-
window.removeEventListener("focus", this._onFocus);
|
|
18523
18583
|
this._wheelManager._destroy();
|
|
18524
18584
|
this._wheelManager = null;
|
|
18525
18585
|
this._pointerManager._destroy();
|
|
@@ -18528,16 +18588,6 @@ __decorate([
|
|
|
18528
18588
|
this._keyboardManager = null;
|
|
18529
18589
|
}
|
|
18530
18590
|
};
|
|
18531
|
-
_proto._onBlur = function _onBlur() {
|
|
18532
|
-
this._wheelManager._onBlur();
|
|
18533
|
-
this._pointerManager._onBlur();
|
|
18534
|
-
this._keyboardManager._onBlur();
|
|
18535
|
-
};
|
|
18536
|
-
_proto._onFocus = function _onFocus() {
|
|
18537
|
-
this._wheelManager._onFocus();
|
|
18538
|
-
this._pointerManager._onFocus();
|
|
18539
|
-
this._keyboardManager._onFocus();
|
|
18540
|
-
};
|
|
18541
18591
|
_create_class(InputManager, [
|
|
18542
18592
|
{
|
|
18543
18593
|
key: "pointers",
|
|
@@ -18580,6 +18630,8 @@ __decorate([
|
|
|
18580
18630
|
_this = ReferResource1.call(this, engine) || this;
|
|
18581
18631
|
/** @internal */ _this._renderStates = [] // todo: later will as a part of shaderData when shader effect frame is OK, that is more powerful and flexible.
|
|
18582
18632
|
;
|
|
18633
|
+
/** @internal */ _this._priority = 0 // todo: temporary resolution of submesh rendering order issue.
|
|
18634
|
+
;
|
|
18583
18635
|
_this._shaderData = new ShaderData(ShaderDataGroup.Material);
|
|
18584
18636
|
_this.shader = shader;
|
|
18585
18637
|
return _this;
|
|
@@ -18914,8 +18966,9 @@ var unlitVs = "#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#in
|
|
|
18914
18966
|
}
|
|
18915
18967
|
return;
|
|
18916
18968
|
}
|
|
18969
|
+
++hierarchy;
|
|
18917
18970
|
for(var k1 in cacheMap){
|
|
18918
|
-
this._recursiveDestroy(
|
|
18971
|
+
this._recursiveDestroy(hierarchy, cacheMap[k1]);
|
|
18919
18972
|
}
|
|
18920
18973
|
};
|
|
18921
18974
|
_proto._resizeCacheMapHierarchy = function _resizeCacheMapHierarchy(cacheMap, hierarchy, currentHierarchy, increaseHierarchy) {
|
|
@@ -19033,7 +19086,7 @@ ShaderPool.init();
|
|
|
19033
19086
|
_this._spriteMaskDefaultMaterial = _this._createSpriteMaskMaterial();
|
|
19034
19087
|
_this._textDefaultFont = Font.createFromOS(_assert_this_initialized(_this), "Arial");
|
|
19035
19088
|
_this._textDefaultFont.isGCIgnored = true;
|
|
19036
|
-
_this.inputManager = new InputManager(_assert_this_initialized(_this));
|
|
19089
|
+
_this.inputManager = new InputManager(_assert_this_initialized(_this), configuration.input);
|
|
19037
19090
|
var xrDevice = configuration.xrDevice;
|
|
19038
19091
|
if (xrDevice) {
|
|
19039
19092
|
_this.xrManager = new XRManager();
|
|
@@ -19049,11 +19102,11 @@ ShaderPool.init();
|
|
|
19049
19102
|
}
|
|
19050
19103
|
var meshMagentaMaterial = new Material(_assert_this_initialized(_this), Shader.find("unlit"));
|
|
19051
19104
|
meshMagentaMaterial.isGCIgnored = true;
|
|
19052
|
-
meshMagentaMaterial.shaderData.setColor("material_BaseColor", new Color(1.0, 0.0, 1.01, 1.0));
|
|
19105
|
+
meshMagentaMaterial.shaderData.setColor("material_BaseColor", new engineMath.Color(1.0, 0.0, 1.01, 1.0));
|
|
19053
19106
|
_this._meshMagentaMaterial = meshMagentaMaterial;
|
|
19054
19107
|
var particleMagentaMaterial = new Material(_assert_this_initialized(_this), Shader.find("particle-shader"));
|
|
19055
19108
|
particleMagentaMaterial.isGCIgnored = true;
|
|
19056
|
-
particleMagentaMaterial.shaderData.setColor("material_BaseColor", new Color(1.0, 0.0, 1.01, 1.0));
|
|
19109
|
+
particleMagentaMaterial.shaderData.setColor("material_BaseColor", new engineMath.Color(1.0, 0.0, 1.01, 1.0));
|
|
19057
19110
|
_this._particleMagentaMaterial = particleMagentaMaterial;
|
|
19058
19111
|
var innerSettings = _this._settings;
|
|
19059
19112
|
var colorSpace = configuration.colorSpace || exports.ColorSpace.Linear;
|
|
@@ -19327,6 +19380,26 @@ ShaderPool.init();
|
|
|
19327
19380
|
this._magentaTexture2D = magentaTexture2D;
|
|
19328
19381
|
this._magentaTextureCube = magentaTextureCube;
|
|
19329
19382
|
if (hardwareRenderer.isWebGL2) {
|
|
19383
|
+
var magentaPixel32 = new Uint32Array([
|
|
19384
|
+
255,
|
|
19385
|
+
0,
|
|
19386
|
+
255,
|
|
19387
|
+
255
|
|
19388
|
+
]);
|
|
19389
|
+
var uintMagentaTexture2D = new Texture2D(this, 1, 1, exports.TextureFormat.R32G32B32A32_UInt, false);
|
|
19390
|
+
uintMagentaTexture2D.setPixelBuffer(magentaPixel32);
|
|
19391
|
+
uintMagentaTexture2D.isGCIgnored = true;
|
|
19392
|
+
this.resourceManager.addContentRestorer(new /*#__PURE__*/ (function(ContentRestorer) {
|
|
19393
|
+
_inherits(_class, ContentRestorer);
|
|
19394
|
+
function _class() {
|
|
19395
|
+
return ContentRestorer.call(this, uintMagentaTexture2D);
|
|
19396
|
+
}
|
|
19397
|
+
var _proto = _class.prototype;
|
|
19398
|
+
_proto.restoreContent = function restoreContent() {
|
|
19399
|
+
this.resource.setPixelBuffer(magentaPixel32);
|
|
19400
|
+
};
|
|
19401
|
+
return _class;
|
|
19402
|
+
}(ContentRestorer))());
|
|
19330
19403
|
var magentaTexture2DArray = new Texture2DArray(this, 1, 1, 1, exports.TextureFormat.R8G8B8A8, false);
|
|
19331
19404
|
magentaTexture2DArray.setPixelBuffer(0, magentaPixel);
|
|
19332
19405
|
magentaTexture2DArray.isGCIgnored = true;
|
|
@@ -19341,6 +19414,7 @@ ShaderPool.init();
|
|
|
19341
19414
|
};
|
|
19342
19415
|
return _class;
|
|
19343
19416
|
}(ContentRestorer))());
|
|
19417
|
+
this._uintMagentaTexture2D = uintMagentaTexture2D;
|
|
19344
19418
|
this._magentaTexture2DArray = magentaTexture2DArray;
|
|
19345
19419
|
}
|
|
19346
19420
|
};
|
|
@@ -19573,8 +19647,8 @@ ShaderPool.init();
|
|
|
19573
19647
|
set: function set(value) {
|
|
19574
19648
|
if (this._width !== value) {
|
|
19575
19649
|
this._width = value;
|
|
19650
|
+
this._onWidthChanged(value);
|
|
19576
19651
|
this._sizeUpdateFlagManager.dispatch();
|
|
19577
|
-
this._onSizeChanged(value, this._width);
|
|
19578
19652
|
}
|
|
19579
19653
|
}
|
|
19580
19654
|
},
|
|
@@ -19588,8 +19662,8 @@ ShaderPool.init();
|
|
|
19588
19662
|
set: function set(value) {
|
|
19589
19663
|
if (this._height !== value) {
|
|
19590
19664
|
this._height = value;
|
|
19665
|
+
this._onHeightChange(value);
|
|
19591
19666
|
this._sizeUpdateFlagManager.dispatch();
|
|
19592
|
-
this._onSizeChanged(this._width, value);
|
|
19593
19667
|
}
|
|
19594
19668
|
}
|
|
19595
19669
|
}
|
|
@@ -20944,6 +21018,10 @@ __decorate([
|
|
|
20944
21018
|
/** The splits of two cascade distribution. */ _this.shadowTwoCascadeSplits = 1.0 / 3.0;
|
|
20945
21019
|
/** The splits of four cascade distribution. */ _this.shadowFourCascadeSplits = new engineMath.Vector3(1.0 / 15, 3.0 / 15.0, 7.0 / 15.0);
|
|
20946
21020
|
/** Max Shadow distance. */ _this.shadowDistance = 50;
|
|
21021
|
+
/**
|
|
21022
|
+
* Last shadow fade distance in percentage, range [0,1].
|
|
21023
|
+
* @remarks Value 0 is used for no shadow fade.
|
|
21024
|
+
*/ _this.shadowFadeBorder = 0.1;
|
|
20947
21025
|
/* @internal */ _this._lightManager = new LightManager();
|
|
20948
21026
|
/* @internal */ _this._componentsManager = new ComponentsManager();
|
|
20949
21027
|
/** @internal */ _this._isActiveInEngine = false;
|
|
@@ -21568,47 +21646,66 @@ __decorate([
|
|
|
21568
21646
|
DepthTextureMode[DepthTextureMode[/* Generate depth texture by pre-pass rendering. */ "PrePass"] = 1] = "PrePass";
|
|
21569
21647
|
})(exports.DepthTextureMode || (exports.DepthTextureMode = {}));
|
|
21570
21648
|
|
|
21571
|
-
var passNum = 0;
|
|
21572
21649
|
/**
|
|
21573
|
-
*
|
|
21574
|
-
*/ var
|
|
21575
|
-
|
|
21576
|
-
|
|
21577
|
-
|
|
21578
|
-
|
|
21579
|
-
|
|
21580
|
-
|
|
21581
|
-
|
|
21582
|
-
this.enabled = true;
|
|
21583
|
-
this.priority = priority;
|
|
21584
|
-
this.renderTarget = renderTarget;
|
|
21585
|
-
this.replaceMaterial = replaceMaterial;
|
|
21586
|
-
this.mask = mask || exports.Layer.Everything;
|
|
21587
|
-
this.renderOverride = false; // If renderOverride is set to true, you need to implement the render method
|
|
21588
|
-
}
|
|
21589
|
-
var _proto = RenderPass.prototype;
|
|
21590
|
-
/**
|
|
21591
|
-
* Rendering callback, will be executed if renderOverride is set to true.
|
|
21592
|
-
* @param camera - Camera
|
|
21593
|
-
* @param opaqueQueue - Opaque queue
|
|
21594
|
-
* @param alphaTestQueue - Alpha test queue
|
|
21595
|
-
* @param transparentQueue - Transparent queue
|
|
21596
|
-
*/ _proto.render = function render(camera, opaqueQueue, alphaTestQueue, transparentQueue) {};
|
|
21650
|
+
* PipelinePass is a base class for all pipeline passes.
|
|
21651
|
+
*/ var PipelinePass = function PipelinePass(engine) {
|
|
21652
|
+
this._engine = engine;
|
|
21653
|
+
};
|
|
21654
|
+
|
|
21655
|
+
/**
|
|
21656
|
+
* @internal
|
|
21657
|
+
*/ var PipelineUtils = /*#__PURE__*/ function() {
|
|
21658
|
+
function PipelineUtils() {}
|
|
21597
21659
|
/**
|
|
21598
|
-
*
|
|
21599
|
-
* @param
|
|
21600
|
-
* @param
|
|
21601
|
-
* @param
|
|
21602
|
-
* @param
|
|
21603
|
-
|
|
21660
|
+
* Recreate texture if needed.
|
|
21661
|
+
* @param engine - Engine
|
|
21662
|
+
* @param currentTexture - Current texture
|
|
21663
|
+
* @param width - Need texture width
|
|
21664
|
+
* @param height - Need texture height
|
|
21665
|
+
* @param format - Need texture format
|
|
21666
|
+
* @param mipmap - Need texture mipmap
|
|
21667
|
+
* @returns Texture
|
|
21668
|
+
*/ PipelineUtils.recreateTextureIfNeeded = function recreateTextureIfNeeded(engine, currentTexture, width, height, format, mipmap) {
|
|
21669
|
+
if (currentTexture) {
|
|
21670
|
+
if (currentTexture.width !== width || currentTexture.height !== height || currentTexture.format !== format || currentTexture.mipmapCount > 1 !== mipmap) {
|
|
21671
|
+
currentTexture.destroy();
|
|
21672
|
+
var texture = new Texture2D(engine, width, height, format, mipmap);
|
|
21673
|
+
texture.isGCIgnored = true;
|
|
21674
|
+
return texture;
|
|
21675
|
+
} else {
|
|
21676
|
+
return currentTexture;
|
|
21677
|
+
}
|
|
21678
|
+
} else {
|
|
21679
|
+
var texture1 = new Texture2D(engine, width, height, format, mipmap);
|
|
21680
|
+
texture1.isGCIgnored = true;
|
|
21681
|
+
return texture1;
|
|
21682
|
+
}
|
|
21683
|
+
};
|
|
21604
21684
|
/**
|
|
21605
|
-
*
|
|
21606
|
-
* @param
|
|
21607
|
-
* @param
|
|
21608
|
-
* @param
|
|
21609
|
-
* @param
|
|
21610
|
-
|
|
21611
|
-
|
|
21685
|
+
* Recreate render target if needed.
|
|
21686
|
+
* @param engine - Engine
|
|
21687
|
+
* @param currentRenderTarget - Current render target
|
|
21688
|
+
* @param width - Need render target width
|
|
21689
|
+
* @param height - Need render target height
|
|
21690
|
+
* @param colorFormat - Need render target color format
|
|
21691
|
+
* @param depthFormat - Need render target depth format
|
|
21692
|
+
* @param mipmap - Need render target mipmap
|
|
21693
|
+
* @returns Render target
|
|
21694
|
+
*/ PipelineUtils.recreateRenderTargetIfNeeded = function recreateRenderTargetIfNeeded(engine, currentRenderTarget, width, height, colorFormat, depthFormat, mipmap) {
|
|
21695
|
+
var _currentRenderTarget, _currentRenderTarget1;
|
|
21696
|
+
var currentColorTexture = (_currentRenderTarget = currentRenderTarget) == null ? void 0 : _currentRenderTarget.getColorTexture(0);
|
|
21697
|
+
var currentDepthTexture = (_currentRenderTarget1 = currentRenderTarget) == null ? void 0 : _currentRenderTarget1.depthTexture;
|
|
21698
|
+
var colorTexture = colorFormat ? PipelineUtils.recreateTextureIfNeeded(engine, currentColorTexture, width, height, colorFormat, mipmap) : null;
|
|
21699
|
+
var depthTexture = depthFormat ? PipelineUtils.recreateTextureIfNeeded(engine, currentDepthTexture, width, height, depthFormat, mipmap) : null;
|
|
21700
|
+
if (currentColorTexture !== colorTexture || currentDepthTexture !== depthTexture) {
|
|
21701
|
+
var _currentRenderTarget2;
|
|
21702
|
+
(_currentRenderTarget2 = currentRenderTarget) == null ? void 0 : _currentRenderTarget2.destroy();
|
|
21703
|
+
currentRenderTarget = new RenderTarget(engine, width, height, colorTexture, depthTexture);
|
|
21704
|
+
currentRenderTarget.isGCIgnored = true;
|
|
21705
|
+
}
|
|
21706
|
+
return currentRenderTarget;
|
|
21707
|
+
};
|
|
21708
|
+
return PipelineUtils;
|
|
21612
21709
|
}();
|
|
21613
21710
|
|
|
21614
21711
|
/**
|
|
@@ -21869,70 +21966,93 @@ var passNum = 0;
|
|
|
21869
21966
|
/**
|
|
21870
21967
|
* @internal
|
|
21871
21968
|
*/ RenderQueue._compareFromNearToFar = function _compareFromNearToFar(a, b) {
|
|
21872
|
-
|
|
21969
|
+
var dataA = a.data;
|
|
21970
|
+
var dataB = b.data;
|
|
21971
|
+
var componentA = dataA.component;
|
|
21972
|
+
var componentB = dataB.component;
|
|
21973
|
+
var priorityOrder = componentA.priority - componentB.priority;
|
|
21974
|
+
if (priorityOrder !== 0) {
|
|
21975
|
+
return priorityOrder;
|
|
21976
|
+
}
|
|
21977
|
+
// make suer from the same renderer.
|
|
21978
|
+
if (componentA.instanceId === componentB.instanceId) {
|
|
21979
|
+
return dataA.material._priority - dataB.material._priority;
|
|
21980
|
+
} else {
|
|
21981
|
+
var distanceDiff = componentA._distanceForSort - componentB._distanceForSort;
|
|
21982
|
+
if (distanceDiff === 0) {
|
|
21983
|
+
return componentA.instanceId - componentB.instanceId;
|
|
21984
|
+
} else {
|
|
21985
|
+
return distanceDiff;
|
|
21986
|
+
}
|
|
21987
|
+
}
|
|
21873
21988
|
};
|
|
21874
21989
|
/**
|
|
21875
21990
|
* @internal
|
|
21876
21991
|
*/ RenderQueue._compareFromFarToNear = function _compareFromFarToNear(a, b) {
|
|
21877
|
-
|
|
21992
|
+
var dataA = a.data;
|
|
21993
|
+
var dataB = b.data;
|
|
21994
|
+
var componentA = dataA.component;
|
|
21995
|
+
var componentB = dataB.component;
|
|
21996
|
+
var priorityOrder = componentA.priority - componentB.priority;
|
|
21997
|
+
if (priorityOrder !== 0) {
|
|
21998
|
+
return priorityOrder;
|
|
21999
|
+
}
|
|
22000
|
+
// make suer from the same renderer.
|
|
22001
|
+
if (componentA.instanceId === componentB.instanceId) {
|
|
22002
|
+
return dataA.material._priority - dataB.material._priority;
|
|
22003
|
+
} else {
|
|
22004
|
+
var distanceDiff = componentB._distanceForSort - componentA._distanceForSort;
|
|
22005
|
+
if (distanceDiff === 0) {
|
|
22006
|
+
return componentA.instanceId - componentB.instanceId;
|
|
22007
|
+
} else {
|
|
22008
|
+
return distanceDiff;
|
|
22009
|
+
}
|
|
22010
|
+
}
|
|
21878
22011
|
};
|
|
21879
22012
|
return RenderQueue;
|
|
21880
22013
|
}();
|
|
21881
22014
|
|
|
22015
|
+
var passNum = 0;
|
|
21882
22016
|
/**
|
|
21883
|
-
*
|
|
21884
|
-
*/ var
|
|
21885
|
-
function
|
|
22017
|
+
* RenderPass.
|
|
22018
|
+
*/ var RenderPass = /*#__PURE__*/ function() {
|
|
22019
|
+
function RenderPass(name, priority, renderTarget, replaceMaterial, mask) {
|
|
22020
|
+
if (name === void 0) name = "RENDER_PASS" + passNum++;
|
|
22021
|
+
if (priority === void 0) priority = 0;
|
|
22022
|
+
if (renderTarget === void 0) renderTarget = null;
|
|
22023
|
+
if (replaceMaterial === void 0) replaceMaterial = null;
|
|
22024
|
+
if (mask === void 0) mask = null;
|
|
22025
|
+
this.name = name;
|
|
22026
|
+
this.enabled = true;
|
|
22027
|
+
this.priority = priority;
|
|
22028
|
+
this.renderTarget = renderTarget;
|
|
22029
|
+
this.replaceMaterial = replaceMaterial;
|
|
22030
|
+
this.mask = mask || exports.Layer.Everything;
|
|
22031
|
+
this.renderOverride = false; // If renderOverride is set to true, you need to implement the render method
|
|
22032
|
+
}
|
|
22033
|
+
var _proto = RenderPass.prototype;
|
|
21886
22034
|
/**
|
|
21887
|
-
*
|
|
21888
|
-
* @param
|
|
21889
|
-
* @param
|
|
21890
|
-
* @param
|
|
21891
|
-
* @param
|
|
21892
|
-
|
|
21893
|
-
* @param mipmap - Need texture mipmap
|
|
21894
|
-
* @returns Texture
|
|
21895
|
-
*/ PipelineUtils.recreateTextureIfNeeded = function recreateTextureIfNeeded(engine, currentTexture, width, height, format, mipmap) {
|
|
21896
|
-
if (currentTexture) {
|
|
21897
|
-
if (currentTexture.width !== width || currentTexture.height !== height || currentTexture.format !== format || currentTexture.mipmapCount > 1 !== mipmap) {
|
|
21898
|
-
currentTexture.destroy();
|
|
21899
|
-
var texture = new Texture2D(engine, width, height, format, mipmap);
|
|
21900
|
-
texture.isGCIgnored = true;
|
|
21901
|
-
return texture;
|
|
21902
|
-
} else {
|
|
21903
|
-
return currentTexture;
|
|
21904
|
-
}
|
|
21905
|
-
} else {
|
|
21906
|
-
var texture1 = new Texture2D(engine, width, height, format, mipmap);
|
|
21907
|
-
texture1.isGCIgnored = true;
|
|
21908
|
-
return texture1;
|
|
21909
|
-
}
|
|
21910
|
-
};
|
|
22035
|
+
* Rendering callback, will be executed if renderOverride is set to true.
|
|
22036
|
+
* @param camera - Camera
|
|
22037
|
+
* @param opaqueQueue - Opaque queue
|
|
22038
|
+
* @param alphaTestQueue - Alpha test queue
|
|
22039
|
+
* @param transparentQueue - Transparent queue
|
|
22040
|
+
*/ _proto.render = function render(camera, opaqueQueue, alphaTestQueue, transparentQueue) {};
|
|
21911
22041
|
/**
|
|
21912
|
-
*
|
|
21913
|
-
* @param
|
|
21914
|
-
* @param
|
|
21915
|
-
* @param
|
|
21916
|
-
* @param
|
|
21917
|
-
|
|
21918
|
-
|
|
21919
|
-
*
|
|
21920
|
-
* @
|
|
21921
|
-
|
|
21922
|
-
|
|
21923
|
-
|
|
21924
|
-
|
|
21925
|
-
|
|
21926
|
-
var depthTexture = depthFormat ? PipelineUtils.recreateTextureIfNeeded(engine, currentDepthTexture, width, height, depthFormat, mipmap) : null;
|
|
21927
|
-
if (currentColorTexture !== colorTexture || currentDepthTexture !== depthTexture) {
|
|
21928
|
-
var _currentRenderTarget2;
|
|
21929
|
-
(_currentRenderTarget2 = currentRenderTarget) == null ? void 0 : _currentRenderTarget2.destroy();
|
|
21930
|
-
currentRenderTarget = new RenderTarget(engine, width, height, colorTexture, depthTexture);
|
|
21931
|
-
currentRenderTarget.isGCIgnored = true;
|
|
21932
|
-
}
|
|
21933
|
-
return currentRenderTarget;
|
|
21934
|
-
};
|
|
21935
|
-
return PipelineUtils;
|
|
22042
|
+
* Post rendering callback.
|
|
22043
|
+
* @param camera - Camera
|
|
22044
|
+
* @param opaqueQueue - Opaque queue
|
|
22045
|
+
* @param alphaTestQueue - Alpha test queue
|
|
22046
|
+
* @param transparentQueue - Transparent queue
|
|
22047
|
+
*/ _proto.preRender = function preRender(camera, opaqueQueue, alphaTestQueue, transparentQueue) {};
|
|
22048
|
+
/**
|
|
22049
|
+
* Post rendering callback.
|
|
22050
|
+
* @param camera - Camera
|
|
22051
|
+
* @param opaqueQueue - Opaque queue
|
|
22052
|
+
* @param alphaTestQueue - Alpha test queue
|
|
22053
|
+
* @param transparentQueue - Transparent queue
|
|
22054
|
+
*/ _proto.postRender = function postRender(camera, opaqueQueue, alphaTestQueue, transparentQueue) {};
|
|
22055
|
+
return RenderPass;
|
|
21936
22056
|
}();
|
|
21937
22057
|
|
|
21938
22058
|
/**
|
|
@@ -22200,6 +22320,26 @@ var /**
|
|
|
22200
22320
|
var offset = cascadeIndex * 16;
|
|
22201
22321
|
Utils._floatMatrixMultiply(sliceMatrix, outShadowMatrices, offset, outShadowMatrices, offset);
|
|
22202
22322
|
};
|
|
22323
|
+
/**
|
|
22324
|
+
* Extract scale and bias from a fade distance to achieve a linear fading of the fade distance.
|
|
22325
|
+
*/ ShadowUtils.getScaleAndBiasForLinearDistanceFade = function getScaleAndBiasForLinearDistanceFade(fadeDistance, border, outInfo) {
|
|
22326
|
+
// (P^2-N^2)/(F^2-N^2)
|
|
22327
|
+
// To avoid division from zero
|
|
22328
|
+
// This values ensure that fade within cascade will be 0 and outside 1
|
|
22329
|
+
if (border < 0.0001) {
|
|
22330
|
+
var multiplier = 1000; // To avoid blending if difference is in fractions
|
|
22331
|
+
outInfo.z = multiplier;
|
|
22332
|
+
outInfo.w = -fadeDistance * multiplier;
|
|
22333
|
+
return;
|
|
22334
|
+
}
|
|
22335
|
+
border = 1 - border;
|
|
22336
|
+
border *= border;
|
|
22337
|
+
// Fade with distance calculation is just a linear fade from 90% of fade distance to fade distance. 90% arbitrarily chosen but should work well enough.
|
|
22338
|
+
var distanceFadeNear = border * fadeDistance;
|
|
22339
|
+
var fadeRange = fadeDistance - distanceFadeNear;
|
|
22340
|
+
outInfo.z = 1.0 / fadeRange;
|
|
22341
|
+
outInfo.w = -distanceFadeNear / fadeRange;
|
|
22342
|
+
};
|
|
22203
22343
|
return ShadowUtils;
|
|
22204
22344
|
}();
|
|
22205
22345
|
(function() {
|
|
@@ -22444,12 +22584,6 @@ var /**
|
|
|
22444
22584
|
ShadowUtils.atlasBorderSize = 4.0;
|
|
22445
22585
|
})();
|
|
22446
22586
|
|
|
22447
|
-
/**
|
|
22448
|
-
* PipelinePass is a base class for all pipeline passes.
|
|
22449
|
-
*/ var PipelinePass = function PipelinePass(engine) {
|
|
22450
|
-
this._engine = engine;
|
|
22451
|
-
};
|
|
22452
|
-
|
|
22453
22587
|
/**
|
|
22454
22588
|
* Cascade shadow caster pass.
|
|
22455
22589
|
*/ var CascadedShadowCasterPass = /*#__PURE__*/ function(PipelinePass1) {
|
|
@@ -22462,11 +22596,10 @@ var /**
|
|
|
22462
22596
|
_this._shadowSliceData = new ShadowSliceData();
|
|
22463
22597
|
_this._lightUp = new engineMath.Vector3();
|
|
22464
22598
|
_this._lightSide = new engineMath.Vector3();
|
|
22465
|
-
_this._existShadowMap = false;
|
|
22466
22599
|
_this._splitBoundSpheres = new Float32Array(CascadedShadowCasterPass._maxCascades * 4);
|
|
22467
22600
|
/** The end is project precision problem in shader. */ _this._shadowMatrices = new Float32Array((CascadedShadowCasterPass._maxCascades + 1) * 16);
|
|
22468
|
-
//
|
|
22469
|
-
_this._shadowInfos = new engineMath.
|
|
22601
|
+
// intensity, null, fadeScale, fadeBias
|
|
22602
|
+
_this._shadowInfos = new engineMath.Vector4();
|
|
22470
22603
|
_this._viewportOffsets = [
|
|
22471
22604
|
new engineMath.Vector2(),
|
|
22472
22605
|
new engineMath.Vector2(),
|
|
@@ -22482,14 +22615,12 @@ var /**
|
|
|
22482
22615
|
/**
|
|
22483
22616
|
* @internal
|
|
22484
22617
|
*/ _proto.onRender = function onRender(context) {
|
|
22618
|
+
var light = this._camera.scene._lightManager._sunlight;
|
|
22485
22619
|
this._updateShadowSettings();
|
|
22486
|
-
this.
|
|
22487
|
-
this.
|
|
22488
|
-
if (this._existShadowMap) {
|
|
22489
|
-
this._updateReceiversShaderData();
|
|
22490
|
-
}
|
|
22620
|
+
this._renderDirectShadowMap(context, light);
|
|
22621
|
+
this._updateReceiversShaderData(light);
|
|
22491
22622
|
};
|
|
22492
|
-
_proto._renderDirectShadowMap = function _renderDirectShadowMap(context) {
|
|
22623
|
+
_proto._renderDirectShadowMap = function _renderDirectShadowMap(context, light) {
|
|
22493
22624
|
var _this = this, engine = _this._engine, camera = _this._camera, viewports = _this._viewportOffsets, shadowSliceData = _this._shadowSliceData, splitBoundSpheres = _this._splitBoundSpheres, shadowMatrices = _this._shadowMatrices;
|
|
22494
22625
|
var _camera__renderPipeline__cullingResults = camera._renderPipeline._cullingResults, opaqueQueue = _camera__renderPipeline__cullingResults.opaqueQueue, alphaTestQueue = _camera__renderPipeline__cullingResults.alphaTestQueue, transparentQueue = _camera__renderPipeline__cullingResults.transparentQueue;
|
|
22495
22626
|
var scene = camera.scene;
|
|
@@ -22503,91 +22634,87 @@ var /**
|
|
|
22503
22634
|
var lightUp = this._lightUp;
|
|
22504
22635
|
var lightSide = this._lightSide;
|
|
22505
22636
|
var lightForward = shadowSliceData.virtualCamera.forward;
|
|
22506
|
-
|
|
22507
|
-
|
|
22508
|
-
|
|
22509
|
-
|
|
22510
|
-
|
|
22511
|
-
|
|
22512
|
-
|
|
22513
|
-
|
|
22514
|
-
|
|
22515
|
-
|
|
22516
|
-
|
|
22517
|
-
|
|
22518
|
-
|
|
22519
|
-
|
|
22520
|
-
|
|
22521
|
-
|
|
22522
|
-
|
|
22523
|
-
|
|
22524
|
-
|
|
22525
|
-
|
|
22526
|
-
|
|
22527
|
-
|
|
22528
|
-
|
|
22529
|
-
rhi.
|
|
22530
|
-
|
|
22531
|
-
|
|
22532
|
-
|
|
22533
|
-
|
|
22534
|
-
|
|
22535
|
-
|
|
22536
|
-
|
|
22537
|
-
|
|
22538
|
-
|
|
22539
|
-
|
|
22540
|
-
|
|
22541
|
-
|
|
22542
|
-
|
|
22543
|
-
|
|
22544
|
-
|
|
22545
|
-
|
|
22546
|
-
|
|
22547
|
-
|
|
22548
|
-
|
|
22549
|
-
|
|
22550
|
-
|
|
22551
|
-
|
|
22552
|
-
|
|
22553
|
-
|
|
22554
|
-
|
|
22555
|
-
|
|
22556
|
-
|
|
22557
|
-
|
|
22558
|
-
|
|
22559
|
-
|
|
22560
|
-
|
|
22561
|
-
|
|
22562
|
-
|
|
22563
|
-
|
|
22564
|
-
|
|
22565
|
-
|
|
22566
|
-
|
|
22567
|
-
|
|
22568
|
-
|
|
22569
|
-
|
|
22570
|
-
|
|
22571
|
-
|
|
22572
|
-
|
|
22573
|
-
|
|
22574
|
-
|
|
22575
|
-
|
|
22576
|
-
|
|
22577
|
-
|
|
22578
|
-
|
|
22579
|
-
|
|
22580
|
-
|
|
22581
|
-
}
|
|
22582
|
-
}
|
|
22583
|
-
this._existShadowMap = true;
|
|
22584
|
-
}
|
|
22585
|
-
};
|
|
22586
|
-
_proto._updateReceiversShaderData = function _updateReceiversShaderData() {
|
|
22587
|
-
var scene = this._camera.scene;
|
|
22637
|
+
// Prepare render target
|
|
22638
|
+
var _this__shadowMapSize = this._shadowMapSize, width = _this__shadowMapSize.z, height = _this__shadowMapSize.w;
|
|
22639
|
+
var format = this._shadowMapFormat;
|
|
22640
|
+
var renderTarget;
|
|
22641
|
+
var shadowTexture;
|
|
22642
|
+
if (this._supportDepthTexture) {
|
|
22643
|
+
renderTarget = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._renderTarget, width, height, null, format, false);
|
|
22644
|
+
shadowTexture = renderTarget.depthTexture;
|
|
22645
|
+
} else {
|
|
22646
|
+
renderTarget = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._renderTarget, width, height, format, null, false);
|
|
22647
|
+
shadowTexture = renderTarget.getColorTexture(0);
|
|
22648
|
+
}
|
|
22649
|
+
shadowTexture.wrapModeU = shadowTexture.wrapModeV = exports.TextureWrapMode.Clamp;
|
|
22650
|
+
if (engine._hardwareRenderer._isWebGL2) {
|
|
22651
|
+
shadowTexture.depthCompareFunction = exports.TextureDepthCompareFunction.Less;
|
|
22652
|
+
}
|
|
22653
|
+
this._renderTarget = renderTarget;
|
|
22654
|
+
this._depthTexture = shadowTexture;
|
|
22655
|
+
// @todo: shouldn't set viewport and scissor in activeRenderTarget
|
|
22656
|
+
rhi.activeRenderTarget(renderTarget, CascadedShadowCasterPass._viewport, 0);
|
|
22657
|
+
if (this._supportDepthTexture) {
|
|
22658
|
+
rhi.clearRenderTarget(engine, exports.CameraClearFlags.Depth, null);
|
|
22659
|
+
} else {
|
|
22660
|
+
rhi.clearRenderTarget(engine, exports.CameraClearFlags.All, CascadedShadowCasterPass._clearColor);
|
|
22661
|
+
}
|
|
22662
|
+
// prepare light and camera direction
|
|
22663
|
+
engineMath.Matrix.rotationQuaternion(light.entity.transform.worldRotationQuaternion, lightWorld);
|
|
22664
|
+
lightSide.set(lightWorldE[0], lightWorldE[1], lightWorldE[2]);
|
|
22665
|
+
lightUp.set(lightWorldE[4], lightWorldE[5], lightWorldE[6]);
|
|
22666
|
+
lightForward.set(-lightWorldE[8], -lightWorldE[9], -lightWorldE[10]);
|
|
22667
|
+
var cameraForward = CascadedShadowCasterPass._tempVector;
|
|
22668
|
+
cameraForward.copyFrom(camera.entity.transform.worldForward);
|
|
22669
|
+
var shadowTileResolution = this._shadowTileResolution;
|
|
22670
|
+
for(var j = 0; j < shadowCascades; j++){
|
|
22671
|
+
ShadowUtils.getBoundSphereByFrustum(splitDistance[j], splitDistance[j + 1], camera, cameraForward, shadowSliceData);
|
|
22672
|
+
ShadowUtils.getDirectionLightShadowCullPlanes(camera._frustum, splitDistance[j], camera.nearClipPlane, lightForward, shadowSliceData);
|
|
22673
|
+
ShadowUtils.getDirectionalLightMatrices(lightUp, lightSide, lightForward, j, light.shadowNearPlane, shadowTileResolution, shadowSliceData, shadowMatrices);
|
|
22674
|
+
if (shadowCascades > 1) {
|
|
22675
|
+
ShadowUtils.applySliceTransform(shadowTileResolution, width, height, j, this._viewportOffsets[j], shadowMatrices);
|
|
22676
|
+
}
|
|
22677
|
+
this._updateSingleShadowCasterShaderData(light, shadowSliceData, context);
|
|
22678
|
+
// upload pre-cascade infos.
|
|
22679
|
+
var center = boundSphere.center;
|
|
22680
|
+
var radius = boundSphere.radius;
|
|
22681
|
+
var offset = j * 4;
|
|
22682
|
+
splitBoundSpheres[offset] = center.x;
|
|
22683
|
+
splitBoundSpheres[offset + 1] = center.y;
|
|
22684
|
+
splitBoundSpheres[offset + 2] = center.z;
|
|
22685
|
+
splitBoundSpheres[offset + 3] = radius * radius;
|
|
22686
|
+
opaqueQueue.clear();
|
|
22687
|
+
alphaTestQueue.clear();
|
|
22688
|
+
transparentQueue.clear();
|
|
22689
|
+
var renderers = componentsManager._renderers;
|
|
22690
|
+
var elements = renderers._elements;
|
|
22691
|
+
for(var k = renderers.length - 1; k >= 0; --k){
|
|
22692
|
+
ShadowUtils.shadowCullFrustum(context, light, elements[k], shadowSliceData);
|
|
22693
|
+
}
|
|
22694
|
+
if (opaqueQueue.elements.length || alphaTestQueue.elements.length) {
|
|
22695
|
+
opaqueQueue.sort(RenderQueue._compareFromNearToFar);
|
|
22696
|
+
alphaTestQueue.sort(RenderQueue._compareFromNearToFar);
|
|
22697
|
+
var _viewports_j = viewports[j], x = _viewports_j.x, y = _viewports_j.y;
|
|
22698
|
+
rhi.setGlobalDepthBias(1.0, 1.0);
|
|
22699
|
+
rhi.viewport(x, y, shadowTileResolution, shadowTileResolution);
|
|
22700
|
+
// for no cascade is for the edge,for cascade is for the beyond maxCascade pixel can use (0,0,0) trick sample the shadowMap
|
|
22701
|
+
rhi.scissor(x + 1, y + 1, shadowTileResolution - 2, shadowTileResolution - 2);
|
|
22702
|
+
engine._renderCount++;
|
|
22703
|
+
opaqueQueue.render(camera, exports.Layer.Everything, exports.PipelineStage.ShadowCaster);
|
|
22704
|
+
alphaTestQueue.render(camera, exports.Layer.Everything, exports.PipelineStage.ShadowCaster);
|
|
22705
|
+
rhi.setGlobalDepthBias(0, 0);
|
|
22706
|
+
}
|
|
22707
|
+
}
|
|
22708
|
+
};
|
|
22709
|
+
_proto._updateReceiversShaderData = function _updateReceiversShaderData(light) {
|
|
22710
|
+
var camera = this._camera;
|
|
22711
|
+
var scene = camera.scene;
|
|
22588
22712
|
var splitBoundSpheres = this._splitBoundSpheres;
|
|
22589
22713
|
var shadowMatrices = this._shadowMatrices;
|
|
22590
22714
|
var shadowCascades = scene.shadowCascades;
|
|
22715
|
+
var shadowFar = Math.min(scene.shadowDistance, camera.farClipPlane);
|
|
22716
|
+
ShadowUtils.getScaleAndBiasForLinearDistanceFade(Math.pow(shadowFar, 2), scene.shadowFadeBorder, this._shadowInfos);
|
|
22717
|
+
this._shadowInfos.x = light.shadowStrength;
|
|
22591
22718
|
// set zero matrix to project the index out of max cascade
|
|
22592
22719
|
if (shadowCascades > 1) {
|
|
22593
22720
|
for(var i = shadowCascades * 4, n = splitBoundSpheres.length; i < n; i++){
|
|
@@ -22600,7 +22727,7 @@ var /**
|
|
|
22600
22727
|
}
|
|
22601
22728
|
var shaderData = scene.shaderData;
|
|
22602
22729
|
shaderData.setFloatArray(CascadedShadowCasterPass._shadowMatricesProperty, this._shadowMatrices);
|
|
22603
|
-
shaderData.
|
|
22730
|
+
shaderData.setVector4(CascadedShadowCasterPass._shadowInfosProperty, this._shadowInfos);
|
|
22604
22731
|
shaderData.setTexture(CascadedShadowCasterPass._shadowMapsProperty, this._depthTexture);
|
|
22605
22732
|
shaderData.setFloatArray(CascadedShadowCasterPass._shadowSplitSpheresProperty, this._splitBoundSpheres);
|
|
22606
22733
|
shaderData.setVector4(CascadedShadowCasterPass._shadowMapSize, this._shadowMapSize);
|
|
@@ -22636,10 +22763,13 @@ var /**
|
|
|
22636
22763
|
return Math.sqrt(radius * radius / denominator);
|
|
22637
22764
|
};
|
|
22638
22765
|
_proto._updateShadowSettings = function _updateShadowSettings() {
|
|
22639
|
-
var
|
|
22766
|
+
var camera = this._camera;
|
|
22767
|
+
var scene = camera.scene;
|
|
22640
22768
|
var shadowFormat = ShadowUtils.shadowDepthFormat(scene.shadowResolution, this._supportDepthTexture);
|
|
22641
22769
|
var shadowResolution = ShadowUtils.shadowResolution(scene.shadowResolution);
|
|
22642
22770
|
var shadowCascades = scene.shadowCascades;
|
|
22771
|
+
var shadowFar = Math.min(scene.shadowDistance, camera.farClipPlane);
|
|
22772
|
+
this._getCascadesSplitDistance(shadowFar);
|
|
22643
22773
|
if (shadowFormat !== this._shadowMapFormat || shadowResolution !== this._shadowMapResolution || shadowCascades !== this._shadowCascadeMode) {
|
|
22644
22774
|
this._shadowMapFormat = shadowFormat;
|
|
22645
22775
|
this._shadowMapResolution = shadowResolution;
|
|
@@ -23087,14 +23217,14 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
23087
23217
|
/** @internal */ _this._cameraIndex = -1;
|
|
23088
23218
|
_this._priority = 0;
|
|
23089
23219
|
_this._shaderData = new ShaderData(ShaderDataGroup.Camera);
|
|
23090
|
-
_this.
|
|
23220
|
+
_this._isCustomViewMatrix = false;
|
|
23221
|
+
_this._isCustomProjectionMatrix = false;
|
|
23091
23222
|
_this._nearClipPlane = 0.1;
|
|
23092
23223
|
_this._farClipPlane = 100;
|
|
23093
23224
|
_this._fieldOfView = 45;
|
|
23094
23225
|
_this._orthographicSize = 10;
|
|
23095
23226
|
_this._isProjectionDirty = true;
|
|
23096
23227
|
_this._isInvProjMatDirty = true;
|
|
23097
|
-
_this._isFrustumProjectDirty = true;
|
|
23098
23228
|
_this._customAspectRatio = undefined;
|
|
23099
23229
|
_this._renderTarget = null;
|
|
23100
23230
|
_this._depthBufferParams = new engineMath.Vector4();
|
|
@@ -23106,7 +23236,7 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
23106
23236
|
_this._transform = transform;
|
|
23107
23237
|
_this._isViewMatrixDirty = transform.registerWorldChangeFlag();
|
|
23108
23238
|
_this._isInvViewProjDirty = transform.registerWorldChangeFlag();
|
|
23109
|
-
_this.
|
|
23239
|
+
_this._frustumChangeFlag = transform.registerWorldChangeFlag();
|
|
23110
23240
|
_this._renderPipeline = new BasicRenderPipeline(_assert_this_initialized(_this));
|
|
23111
23241
|
_this._addResourceReferCount(_this.shaderData, 1);
|
|
23112
23242
|
_this._updatePixelViewport();
|
|
@@ -23118,16 +23248,22 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
23118
23248
|
}
|
|
23119
23249
|
var _proto = Camera1.prototype;
|
|
23120
23250
|
/**
|
|
23251
|
+
* Restore the view matrix to the world matrix of the entity.
|
|
23252
|
+
*/ _proto.resetViewMatrix = function resetViewMatrix() {
|
|
23253
|
+
this._isCustomViewMatrix = false;
|
|
23254
|
+
this._viewMatrixChange();
|
|
23255
|
+
};
|
|
23256
|
+
/**
|
|
23121
23257
|
* Restore the automatic calculation of projection matrix through fieldOfView, nearClipPlane and farClipPlane.
|
|
23122
23258
|
*/ _proto.resetProjectionMatrix = function resetProjectionMatrix() {
|
|
23123
|
-
this.
|
|
23124
|
-
this.
|
|
23259
|
+
this._isCustomProjectionMatrix = false;
|
|
23260
|
+
this._projectionMatrixChange();
|
|
23125
23261
|
};
|
|
23126
23262
|
/**
|
|
23127
23263
|
* Restore the automatic calculation of the aspect ratio through the viewport aspect ratio.
|
|
23128
23264
|
*/ _proto.resetAspectRatio = function resetAspectRatio() {
|
|
23129
23265
|
this._customAspectRatio = undefined;
|
|
23130
|
-
this.
|
|
23266
|
+
this._projectionMatrixChange();
|
|
23131
23267
|
};
|
|
23132
23268
|
/**
|
|
23133
23269
|
* Transform a point from world space to viewport space.
|
|
@@ -23257,10 +23393,9 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
23257
23393
|
context.replacementShader = this._replacementShader;
|
|
23258
23394
|
context.replacementTag = this._replacementSubShaderTag;
|
|
23259
23395
|
// compute cull frustum.
|
|
23260
|
-
if (this.enableFrustumCulling &&
|
|
23396
|
+
if (this.enableFrustumCulling && this._frustumChangeFlag.flag) {
|
|
23261
23397
|
this._frustum.calculateFromMatrix(virtualCamera.viewProjectionMatrix);
|
|
23262
|
-
this.
|
|
23263
|
-
this._isFrustumProjectDirty = false;
|
|
23398
|
+
this._frustumChangeFlag.flag = false;
|
|
23264
23399
|
}
|
|
23265
23400
|
this._updateShaderData();
|
|
23266
23401
|
// union scene and camera macro.
|
|
@@ -23309,13 +23444,16 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
23309
23444
|
//@ts-ignore
|
|
23310
23445
|
this._viewport._onValueChanged = null;
|
|
23311
23446
|
this.engine.canvas._sizeUpdateFlagManager.removeListener(this._onPixelViewportChanged);
|
|
23447
|
+
//@ts-ignore
|
|
23448
|
+
this._viewport._onValueChanged = null;
|
|
23449
|
+
this.engine.canvas._sizeUpdateFlagManager.removeListener(this._onPixelViewportChanged);
|
|
23312
23450
|
this._entity = null;
|
|
23313
23451
|
this._globalShaderMacro = null;
|
|
23314
23452
|
this._frustum = null;
|
|
23315
23453
|
this._renderPipeline = null;
|
|
23316
23454
|
this._virtualCamera = null;
|
|
23317
23455
|
this._shaderData = null;
|
|
23318
|
-
this.
|
|
23456
|
+
this._frustumChangeFlag = null;
|
|
23319
23457
|
this._transform = null;
|
|
23320
23458
|
this._isViewMatrixDirty = null;
|
|
23321
23459
|
this._isInvViewProjDirty = null;
|
|
@@ -23337,11 +23475,16 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
23337
23475
|
var viewport = this._viewport;
|
|
23338
23476
|
this._pixelViewport.set(viewport.x * width, viewport.y * height, viewport.z * width, viewport.w * height);
|
|
23339
23477
|
};
|
|
23340
|
-
_proto.
|
|
23341
|
-
this.
|
|
23478
|
+
_proto._viewMatrixChange = function _viewMatrixChange() {
|
|
23479
|
+
this._isViewMatrixDirty.flag = true;
|
|
23480
|
+
this._isInvViewProjDirty.flag = true;
|
|
23481
|
+
this._frustumChangeFlag.flag = true;
|
|
23482
|
+
};
|
|
23483
|
+
_proto._projectionMatrixChange = function _projectionMatrixChange() {
|
|
23342
23484
|
this._isProjectionDirty = true;
|
|
23343
23485
|
this._isInvProjMatDirty = true;
|
|
23344
23486
|
this._isInvViewProjDirty.flag = true;
|
|
23487
|
+
this._frustumChangeFlag.flag = true;
|
|
23345
23488
|
};
|
|
23346
23489
|
_proto._innerViewportToWorldPoint = function _innerViewportToWorldPoint(x, y, z, invViewProjMat, out) {
|
|
23347
23490
|
// Depth is a normalized value, 0 is nearPlane, 1 is farClipPlane.
|
|
@@ -23384,7 +23527,7 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
23384
23527
|
_proto._onPixelViewportChanged = function _onPixelViewportChanged() {
|
|
23385
23528
|
this._updatePixelViewport();
|
|
23386
23529
|
var _this__customAspectRatio;
|
|
23387
|
-
(_this__customAspectRatio = this._customAspectRatio) != null ? _this__customAspectRatio : this.
|
|
23530
|
+
(_this__customAspectRatio = this._customAspectRatio) != null ? _this__customAspectRatio : this._projectionMatrixChange();
|
|
23388
23531
|
};
|
|
23389
23532
|
_create_class(Camera1, [
|
|
23390
23533
|
{
|
|
@@ -23404,7 +23547,7 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
23404
23547
|
},
|
|
23405
23548
|
set: function set(value) {
|
|
23406
23549
|
this._nearClipPlane = value;
|
|
23407
|
-
this.
|
|
23550
|
+
this._projectionMatrixChange();
|
|
23408
23551
|
}
|
|
23409
23552
|
},
|
|
23410
23553
|
{
|
|
@@ -23416,7 +23559,7 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
23416
23559
|
},
|
|
23417
23560
|
set: function set(value) {
|
|
23418
23561
|
this._farClipPlane = value;
|
|
23419
|
-
this.
|
|
23562
|
+
this._projectionMatrixChange();
|
|
23420
23563
|
}
|
|
23421
23564
|
},
|
|
23422
23565
|
{
|
|
@@ -23428,7 +23571,7 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
23428
23571
|
},
|
|
23429
23572
|
set: function set(value) {
|
|
23430
23573
|
this._fieldOfView = value;
|
|
23431
|
-
this.
|
|
23574
|
+
this._projectionMatrixChange();
|
|
23432
23575
|
}
|
|
23433
23576
|
},
|
|
23434
23577
|
{
|
|
@@ -23443,7 +23586,7 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
23443
23586
|
},
|
|
23444
23587
|
set: function set(value) {
|
|
23445
23588
|
this._customAspectRatio = value;
|
|
23446
|
-
this.
|
|
23589
|
+
this._projectionMatrixChange();
|
|
23447
23590
|
}
|
|
23448
23591
|
},
|
|
23449
23592
|
{
|
|
@@ -23495,7 +23638,12 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
23495
23638
|
},
|
|
23496
23639
|
set: function set(value) {
|
|
23497
23640
|
this._virtualCamera.isOrthographic = value;
|
|
23498
|
-
this.
|
|
23641
|
+
this._projectionMatrixChange();
|
|
23642
|
+
if (value) {
|
|
23643
|
+
this.shaderData.enableMacro("CAMERA_ORTHOGRAPHIC");
|
|
23644
|
+
} else {
|
|
23645
|
+
this.shaderData.disableMacro("CAMERA_ORTHOGRAPHIC");
|
|
23646
|
+
}
|
|
23499
23647
|
}
|
|
23500
23648
|
},
|
|
23501
23649
|
{
|
|
@@ -23507,7 +23655,7 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
23507
23655
|
},
|
|
23508
23656
|
set: function set(value) {
|
|
23509
23657
|
this._orthographicSize = value;
|
|
23510
|
-
this.
|
|
23658
|
+
this._projectionMatrixChange();
|
|
23511
23659
|
}
|
|
23512
23660
|
},
|
|
23513
23661
|
{
|
|
@@ -23516,22 +23664,31 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
23516
23664
|
* View matrix.
|
|
23517
23665
|
*/ function get() {
|
|
23518
23666
|
var viewMatrix = this._virtualCamera.viewMatrix;
|
|
23519
|
-
if (this._isViewMatrixDirty.flag) {
|
|
23520
|
-
|
|
23521
|
-
|
|
23522
|
-
|
|
23523
|
-
|
|
23524
|
-
|
|
23525
|
-
|
|
23667
|
+
if (!this._isViewMatrixDirty.flag || this._isCustomViewMatrix) {
|
|
23668
|
+
return viewMatrix;
|
|
23669
|
+
}
|
|
23670
|
+
this._isViewMatrixDirty.flag = false;
|
|
23671
|
+
// Ignore scale
|
|
23672
|
+
var transform = this._transform;
|
|
23673
|
+
engineMath.Matrix.rotationTranslation(transform.worldRotationQuaternion, transform.worldPosition, viewMatrix);
|
|
23674
|
+
viewMatrix.invert();
|
|
23526
23675
|
return viewMatrix;
|
|
23676
|
+
},
|
|
23677
|
+
set: function set(value) {
|
|
23678
|
+
this._virtualCamera.viewMatrix.copyFrom(value);
|
|
23679
|
+
this._isCustomViewMatrix = true;
|
|
23680
|
+
this._viewMatrixChange();
|
|
23527
23681
|
}
|
|
23528
23682
|
},
|
|
23529
23683
|
{
|
|
23530
23684
|
key: "projectionMatrix",
|
|
23531
|
-
get:
|
|
23685
|
+
get: /**
|
|
23686
|
+
* The projection matrix is calculated by the relevant parameters of the camera by default.
|
|
23687
|
+
* If it is manually set, the manual value will be maintained. Call resetProjectionMatrix() to restore it.
|
|
23688
|
+
*/ function get() {
|
|
23532
23689
|
var virtualCamera = this._virtualCamera;
|
|
23533
23690
|
var projectionMatrix = virtualCamera.projectionMatrix;
|
|
23534
|
-
if (!this._isProjectionDirty || this.
|
|
23691
|
+
if (!this._isProjectionDirty || this._isCustomProjectionMatrix) {
|
|
23535
23692
|
return projectionMatrix;
|
|
23536
23693
|
}
|
|
23537
23694
|
this._isProjectionDirty = false;
|
|
@@ -23545,13 +23702,10 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component1) {
|
|
|
23545
23702
|
}
|
|
23546
23703
|
return projectionMatrix;
|
|
23547
23704
|
},
|
|
23548
|
-
set:
|
|
23549
|
-
* The projection matrix is calculated by the relevant parameters of the camera by default.
|
|
23550
|
-
* If it is manually set, the manual value will be maintained. Call resetProjectionMatrix() to restore it.
|
|
23551
|
-
*/ function set(value) {
|
|
23705
|
+
set: function set(value) {
|
|
23552
23706
|
this._virtualCamera.projectionMatrix.copyFrom(value);
|
|
23553
|
-
this.
|
|
23554
|
-
this.
|
|
23707
|
+
this._isCustomProjectionMatrix = true;
|
|
23708
|
+
this._projectionMatrixChange();
|
|
23555
23709
|
}
|
|
23556
23710
|
},
|
|
23557
23711
|
{
|
|
@@ -23612,7 +23766,7 @@ __decorate([
|
|
|
23612
23766
|
], exports.Camera.prototype, "_cameraIndex", void 0);
|
|
23613
23767
|
__decorate([
|
|
23614
23768
|
ignoreClone
|
|
23615
|
-
], exports.Camera.prototype, "
|
|
23769
|
+
], exports.Camera.prototype, "_frustumChangeFlag", void 0);
|
|
23616
23770
|
__decorate([
|
|
23617
23771
|
ignoreClone
|
|
23618
23772
|
], exports.Camera.prototype, "_transform", void 0);
|
|
@@ -23799,6 +23953,7 @@ var MultiExecutor = /*#__PURE__*/ function() {
|
|
|
23799
23953
|
* @param obj - class object
|
|
23800
23954
|
*/ Loader.registerClass = function registerClass(className, classDefine) {
|
|
23801
23955
|
this._engineObjects[className] = classDefine;
|
|
23956
|
+
this._classNameMap.set(classDefine, className);
|
|
23802
23957
|
};
|
|
23803
23958
|
/**
|
|
23804
23959
|
* Get the class object by class name.
|
|
@@ -23807,11 +23962,21 @@ var MultiExecutor = /*#__PURE__*/ function() {
|
|
|
23807
23962
|
*/ Loader.getClass = function getClass(className) {
|
|
23808
23963
|
return this._engineObjects[className];
|
|
23809
23964
|
};
|
|
23965
|
+
/**
|
|
23966
|
+
* Get the class name by class object.
|
|
23967
|
+
* @param obj - class object
|
|
23968
|
+
* @returns class name
|
|
23969
|
+
*/ Loader.getClassName = function getClassName(obj) {
|
|
23970
|
+
return this._classNameMap.get(obj);
|
|
23971
|
+
};
|
|
23810
23972
|
return Loader;
|
|
23811
23973
|
}();
|
|
23812
23974
|
(function() {
|
|
23813
23975
|
Loader._engineObjects = {};
|
|
23814
23976
|
})();
|
|
23977
|
+
(function() {
|
|
23978
|
+
Loader._classNameMap = new Map();
|
|
23979
|
+
})();
|
|
23815
23980
|
|
|
23816
23981
|
/**
|
|
23817
23982
|
* Alpha blend mode.
|
|
@@ -25245,6 +25410,7 @@ AnimationCurveOwner.registerAssembler(SkinnedMeshRenderer, "blendShapeWeights",
|
|
|
25245
25410
|
_this = EngineObject1.call(this, null) || this;
|
|
25246
25411
|
_this.name = name;
|
|
25247
25412
|
_this./** @internal */ _curveBindings = [];
|
|
25413
|
+
_this./** @internal */ _updateFlagManager = new UpdateFlagManager();
|
|
25248
25414
|
_this._length = 0;
|
|
25249
25415
|
_this._events = [];
|
|
25250
25416
|
return _this;
|
|
@@ -25272,11 +25438,13 @@ AnimationCurveOwner.registerAssembler(SkinnedMeshRenderer, "blendShapeWeights",
|
|
|
25272
25438
|
while(--index >= 0 && eventTime < events[index].time);
|
|
25273
25439
|
events.splice(index + 1, 0, newEvent);
|
|
25274
25440
|
}
|
|
25441
|
+
this._updateFlagManager.dispatch();
|
|
25275
25442
|
};
|
|
25276
25443
|
/**
|
|
25277
25444
|
* Clears all events from the clip.
|
|
25278
25445
|
*/ _proto.clearEvents = function clearEvents() {
|
|
25279
25446
|
this._events.length = 0;
|
|
25447
|
+
this._updateFlagManager.dispatch();
|
|
25280
25448
|
};
|
|
25281
25449
|
_proto.addCurveBinding = function addCurveBinding(entityPath, componentType, propertyOrSetPropertyPathOrComponentIndex, curveOrSetPropertyPathOrGetPropertyPath, curveOrGetPropertyPath, curve) {
|
|
25282
25450
|
var curveBinding = new AnimationClipCurveBinding();
|
|
@@ -26833,26 +27001,31 @@ exports.AnimatorLayerBlendingMode = void 0;
|
|
|
26833
27001
|
}
|
|
26834
27002
|
};
|
|
26835
27003
|
_proto._saveAnimatorEventHandlers = function _saveAnimatorEventHandlers(state, animatorStateData) {
|
|
27004
|
+
var _this = this;
|
|
26836
27005
|
var eventHandlerPool = this._animationEventHandlerPool;
|
|
26837
27006
|
var scripts = [];
|
|
26838
|
-
this._entity.getComponents(Script, scripts);
|
|
26839
|
-
var scriptCount = scripts.length;
|
|
26840
27007
|
var eventHandlers = animatorStateData.eventHandlers;
|
|
26841
|
-
var
|
|
26842
|
-
|
|
26843
|
-
|
|
26844
|
-
var
|
|
26845
|
-
|
|
26846
|
-
var
|
|
26847
|
-
|
|
26848
|
-
|
|
26849
|
-
|
|
26850
|
-
|
|
26851
|
-
|
|
26852
|
-
|
|
27008
|
+
var clipChangedListener = function() {
|
|
27009
|
+
_this._entity.getComponents(Script, scripts);
|
|
27010
|
+
var scriptCount = scripts.length;
|
|
27011
|
+
var events = state.clip.events;
|
|
27012
|
+
eventHandlers.length = 0;
|
|
27013
|
+
for(var i = 0, n = events.length; i < n; i++){
|
|
27014
|
+
var event = events[i];
|
|
27015
|
+
var eventHandler = eventHandlerPool.getFromPool();
|
|
27016
|
+
var funcName = event.functionName;
|
|
27017
|
+
var handlers = eventHandler.handlers;
|
|
27018
|
+
eventHandler.event = event;
|
|
27019
|
+
handlers.length = 0;
|
|
27020
|
+
for(var j = scriptCount - 1; j >= 0; j--){
|
|
27021
|
+
var handler = scripts[j][funcName];
|
|
27022
|
+
handler && handlers.push(handler);
|
|
27023
|
+
}
|
|
27024
|
+
eventHandlers.push(eventHandler);
|
|
26853
27025
|
}
|
|
26854
|
-
|
|
26855
|
-
|
|
27026
|
+
};
|
|
27027
|
+
clipChangedListener();
|
|
27028
|
+
state._updateFlagManager.addListener(clipChangedListener);
|
|
26856
27029
|
};
|
|
26857
27030
|
_proto._clearCrossData = function _clearCrossData(animatorLayerData) {
|
|
26858
27031
|
animatorLayerData.crossCurveMark++;
|
|
@@ -27463,9 +27636,11 @@ __decorate([
|
|
|
27463
27636
|
this./** @internal */ _onStateEnterScripts = [];
|
|
27464
27637
|
this./** @internal */ _onStateUpdateScripts = [];
|
|
27465
27638
|
this./** @internal */ _onStateExitScripts = [];
|
|
27639
|
+
this./** @internal */ _updateFlagManager = new UpdateFlagManager();
|
|
27466
27640
|
this._clipStartTime = 0;
|
|
27467
27641
|
this._clipEndTime = 1;
|
|
27468
27642
|
this._transitions = [];
|
|
27643
|
+
this._onClipChanged = this._onClipChanged.bind(this);
|
|
27469
27644
|
}
|
|
27470
27645
|
var _proto = AnimatorState.prototype;
|
|
27471
27646
|
/**
|
|
@@ -27539,6 +27714,11 @@ __decorate([
|
|
|
27539
27714
|
index2 !== -1 && this._onStateExitScripts.splice(index2, 1);
|
|
27540
27715
|
}
|
|
27541
27716
|
};
|
|
27717
|
+
/**
|
|
27718
|
+
* @internal
|
|
27719
|
+
*/ _proto._onClipChanged = function _onClipChanged() {
|
|
27720
|
+
this._updateFlagManager.dispatch();
|
|
27721
|
+
};
|
|
27542
27722
|
_create_class(AnimatorState, [
|
|
27543
27723
|
{
|
|
27544
27724
|
key: "transitions",
|
|
@@ -27556,8 +27736,17 @@ __decorate([
|
|
|
27556
27736
|
return this._clip;
|
|
27557
27737
|
},
|
|
27558
27738
|
set: function set(clip) {
|
|
27739
|
+
var lastClip = this._clip;
|
|
27740
|
+
if (lastClip === clip) {
|
|
27741
|
+
return;
|
|
27742
|
+
}
|
|
27743
|
+
if (lastClip) {
|
|
27744
|
+
lastClip._updateFlagManager.removeListener(this._onClipChanged);
|
|
27745
|
+
}
|
|
27559
27746
|
this._clip = clip;
|
|
27560
27747
|
this._clipEndTime = Math.min(this._clipEndTime, 1);
|
|
27748
|
+
this._onClipChanged();
|
|
27749
|
+
clip && clip._updateFlagManager.addListener(this._onClipChanged);
|
|
27561
27750
|
}
|
|
27562
27751
|
},
|
|
27563
27752
|
{
|
|
@@ -28264,6 +28453,7 @@ __decorate([
|
|
|
28264
28453
|
ParticleRandomSubSeeds[ParticleRandomSubSeeds["RotationOverLifetime"] = 0x40eb95e4] = "RotationOverLifetime";
|
|
28265
28454
|
ParticleRandomSubSeeds[ParticleRandomSubSeeds["TextureSheetAnimation"] = 0xbc524e5] = "TextureSheetAnimation";
|
|
28266
28455
|
ParticleRandomSubSeeds[ParticleRandomSubSeeds["Shape"] = 0xaf502044] = "Shape";
|
|
28456
|
+
ParticleRandomSubSeeds[ParticleRandomSubSeeds["GravityModifier"] = 0xa47b8c4d] = "GravityModifier";
|
|
28267
28457
|
})(ParticleRandomSubSeeds || (ParticleRandomSubSeeds = {}));
|
|
28268
28458
|
|
|
28269
28459
|
/**
|
|
@@ -28977,6 +29167,7 @@ var MainModule = /*#__PURE__*/ function() {
|
|
|
28977
29167
|
/** @internal */ this._startColorRand = new engineMath.Rand(0, ParticleRandomSubSeeds.StartColor);
|
|
28978
29168
|
/** @internal */ this._startSizeRand = new engineMath.Rand(0, ParticleRandomSubSeeds.StartSize);
|
|
28979
29169
|
/** @internal */ this._startRotationRand = new engineMath.Rand(0, ParticleRandomSubSeeds.StartRotation);
|
|
29170
|
+
this._gravityModifierRand = new engineMath.Rand(0, ParticleRandomSubSeeds.GravityModifier);
|
|
28980
29171
|
this._gravity = new engineMath.Vector3();
|
|
28981
29172
|
this._generator = generator;
|
|
28982
29173
|
}
|
|
@@ -29037,7 +29228,7 @@ var MainModule = /*#__PURE__*/ function() {
|
|
|
29037
29228
|
break;
|
|
29038
29229
|
}
|
|
29039
29230
|
var particleGravity = this._gravity;
|
|
29040
|
-
var gravityModifierValue = this.gravityModifier.evaluate(undefined,
|
|
29231
|
+
var gravityModifierValue = this.gravityModifier.evaluate(undefined, this._gravityModifierRand.random());
|
|
29041
29232
|
engineMath.Vector3.scale(renderer.scene.physics.gravity, gravityModifierValue, particleGravity);
|
|
29042
29233
|
shaderData.setVector3(MainModule._gravity, particleGravity);
|
|
29043
29234
|
shaderData.setInt(MainModule._simulationSpace, this.simulationSpace);
|
|
@@ -29156,6 +29347,9 @@ __decorate([
|
|
|
29156
29347
|
__decorate([
|
|
29157
29348
|
ignoreClone
|
|
29158
29349
|
], MainModule.prototype, "_startRotationRand", void 0);
|
|
29350
|
+
__decorate([
|
|
29351
|
+
ignoreClone
|
|
29352
|
+
], MainModule.prototype, "_gravityModifierRand", void 0);
|
|
29159
29353
|
__decorate([
|
|
29160
29354
|
ignoreClone
|
|
29161
29355
|
], MainModule.prototype, "_generator", void 0);
|
|
@@ -29826,7 +30020,8 @@ __decorate([
|
|
|
29826
30020
|
var transform = this._renderer.entity.transform;
|
|
29827
30021
|
var shape = this.emission.shape;
|
|
29828
30022
|
for(var i = 0; i < count; i++){
|
|
29829
|
-
|
|
30023
|
+
var _shape;
|
|
30024
|
+
if ((_shape = shape) == null ? void 0 : _shape.enabled) {
|
|
29830
30025
|
shape._generatePositionAndDirection(this.emission._shapeRand, time, position, direction);
|
|
29831
30026
|
var positionScale = this.main._getPositionScale();
|
|
29832
30027
|
position.multiply(positionScale);
|
|
@@ -30406,7 +30601,7 @@ __decorate([
|
|
|
30406
30601
|
* Base class for all particle shapes.
|
|
30407
30602
|
*/ var BaseShape = /*#__PURE__*/ function() {
|
|
30408
30603
|
function BaseShape() {
|
|
30409
|
-
/** Specifies whether the ShapeModule is enabled or disabled. */ this.
|
|
30604
|
+
/** Specifies whether the ShapeModule is enabled or disabled. */ this.enabled = true;
|
|
30410
30605
|
/** Randomizes the starting direction of particles. */ this.randomDirectionAmount = 0;
|
|
30411
30606
|
}
|
|
30412
30607
|
var _proto = BaseShape.prototype;
|
|
@@ -30470,14 +30665,14 @@ __decorate([
|
|
|
30470
30665
|
|
|
30471
30666
|
/**
|
|
30472
30667
|
* The emission shape.
|
|
30473
|
-
*/
|
|
30668
|
+
*/ exports.ParticleShapeType = void 0;
|
|
30474
30669
|
(function(ParticleShapeType) {
|
|
30475
30670
|
ParticleShapeType[ParticleShapeType[/** Emit from the volume of a box. */ "Box"] = 0] = "Box";
|
|
30476
30671
|
ParticleShapeType[ParticleShapeType[/** Emit from a circle. */ "Circle"] = 1] = "Circle";
|
|
30477
30672
|
ParticleShapeType[ParticleShapeType[/** Emit from the base of a cone. */ "Cone"] = 2] = "Cone";
|
|
30478
30673
|
ParticleShapeType[ParticleShapeType[/** Emit from a half-sphere. */ "Hemisphere"] = 3] = "Hemisphere";
|
|
30479
30674
|
ParticleShapeType[ParticleShapeType[/** Emit from a sphere. */ "Sphere"] = 4] = "Sphere";
|
|
30480
|
-
})(ParticleShapeType || (ParticleShapeType = {}));
|
|
30675
|
+
})(exports.ParticleShapeType || (exports.ParticleShapeType = {}));
|
|
30481
30676
|
|
|
30482
30677
|
/**
|
|
30483
30678
|
* Particle shape that emits particles from a box.
|
|
@@ -30485,9 +30680,9 @@ __decorate([
|
|
|
30485
30680
|
_inherits(BoxShape, BaseShape1);
|
|
30486
30681
|
function BoxShape() {
|
|
30487
30682
|
var _this;
|
|
30488
|
-
_this = BaseShape1.
|
|
30683
|
+
_this = BaseShape1.apply(this, arguments) || this;
|
|
30684
|
+
_this.shapeType = exports.ParticleShapeType.Box;
|
|
30489
30685
|
/** The size of the box. */ _this.size = new engineMath.Vector3(1, 1, 1);
|
|
30490
|
-
_this.shapeType = ParticleShapeType.Box;
|
|
30491
30686
|
return _this;
|
|
30492
30687
|
}
|
|
30493
30688
|
var _proto = BoxShape.prototype;
|
|
@@ -30524,12 +30719,12 @@ __decorate([
|
|
|
30524
30719
|
_inherits(CircleShape, BaseShape1);
|
|
30525
30720
|
function CircleShape() {
|
|
30526
30721
|
var _this;
|
|
30527
|
-
_this = BaseShape1.
|
|
30722
|
+
_this = BaseShape1.apply(this, arguments) || this;
|
|
30723
|
+
_this.shapeType = exports.ParticleShapeType.Circle;
|
|
30528
30724
|
/** Radius of the shape to emit particles from. */ _this.radius = 1.0;
|
|
30529
30725
|
/** Angle of the circle arc to emit particles from. */ _this.arc = 360.0;
|
|
30530
30726
|
/** The mode to generate particles around the arc. */ _this.arcMode = exports.ParticleShapeArcMode.Random;
|
|
30531
30727
|
/** The speed of complete 360 degree rotation. */ _this.arcSpeed = 1.0;
|
|
30532
|
-
_this.shapeType = ParticleShapeType.Circle;
|
|
30533
30728
|
return _this;
|
|
30534
30729
|
}
|
|
30535
30730
|
var _proto = CircleShape.prototype;
|
|
@@ -30565,12 +30760,12 @@ __decorate([
|
|
|
30565
30760
|
_inherits(ConeShape, BaseShape1);
|
|
30566
30761
|
function ConeShape() {
|
|
30567
30762
|
var _this;
|
|
30568
|
-
_this = BaseShape1.
|
|
30763
|
+
_this = BaseShape1.apply(this, arguments) || this;
|
|
30764
|
+
_this.shapeType = exports.ParticleShapeType.Cone;
|
|
30569
30765
|
/** Angle of the cone to emit particles from. */ _this.angle = 25.0;
|
|
30570
30766
|
/** Radius of the shape to emit particles from. */ _this.radius = 1.0;
|
|
30571
30767
|
/** Length of the cone to emit particles from. */ _this.length = 5.0;
|
|
30572
30768
|
/** Cone emitter type. */ _this.emitType = /** Emit particles from the base of the cone. */ 0;
|
|
30573
|
-
_this.shapeType = ParticleShapeType.Cone;
|
|
30574
30769
|
return _this;
|
|
30575
30770
|
}
|
|
30576
30771
|
var _proto = ConeShape.prototype;
|
|
@@ -30630,9 +30825,9 @@ exports.ConeEmitType = void 0;
|
|
|
30630
30825
|
_inherits(HemisphereShape, BaseShape1);
|
|
30631
30826
|
function HemisphereShape() {
|
|
30632
30827
|
var _this;
|
|
30633
|
-
_this = BaseShape1.
|
|
30828
|
+
_this = BaseShape1.apply(this, arguments) || this;
|
|
30829
|
+
_this.shapeType = exports.ParticleShapeType.Hemisphere;
|
|
30634
30830
|
/** Radius of the shape to emit particles from. */ _this.radius = 1.0;
|
|
30635
|
-
_this.shapeType = ParticleShapeType.Hemisphere;
|
|
30636
30831
|
return _this;
|
|
30637
30832
|
}
|
|
30638
30833
|
var _proto = HemisphereShape.prototype;
|
|
@@ -30655,9 +30850,9 @@ exports.ConeEmitType = void 0;
|
|
|
30655
30850
|
_inherits(SphereShape, BaseShape1);
|
|
30656
30851
|
function SphereShape() {
|
|
30657
30852
|
var _this;
|
|
30658
|
-
_this = BaseShape1.
|
|
30853
|
+
_this = BaseShape1.apply(this, arguments) || this;
|
|
30854
|
+
_this.shapeType = exports.ParticleShapeType.Sphere;
|
|
30659
30855
|
/** Radius of the shape to emit particles from. */ _this.radius = 1.0;
|
|
30660
|
-
_this.shapeType = ParticleShapeType.Sphere;
|
|
30661
30856
|
return _this;
|
|
30662
30857
|
}
|
|
30663
30858
|
var _proto = SphereShape.prototype;
|