@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/module.js CHANGED
@@ -1,4 +1,4 @@
1
- import { MathUtil as MathUtil$1, Vector2, BoundingBox, Rect, Vector4, Quaternion, Vector3, Matrix3x3, Matrix, Color as Color$1, Ray, Plane, BoundingSphere, FrustumFace, CollisionUtil, BoundingFrustum, Rand } from '@galacean/engine-math';
1
+ import { MathUtil, Vector2, BoundingBox, Rect, Vector4, Quaternion, Vector3, Matrix3x3, Matrix, Color, Ray, Plane, BoundingSphere, FrustumFace, CollisionUtil, BoundingFrustum, Rand } from '@galacean/engine-math';
2
2
 
3
3
  /**
4
4
  * The platform (including operating system and hardware) is running on.
@@ -55,347 +55,6 @@ function _inherits(subClass, superClass) {
55
55
  if (superClass) _set_prototype_of(subClass, superClass);
56
56
  }
57
57
 
58
- /**
59
- * Common utility methods for math operations.
60
- */ var MathUtil = /*#__PURE__*/ function() {
61
- function MathUtil() {}
62
- /**
63
- * Clamps the specified value.
64
- * @param v - The specified value
65
- * @param min - The min value
66
- * @param max - The max value
67
- * @returns The result of clamping a value between min and max
68
- */ MathUtil.clamp = function clamp(v, min, max) {
69
- return Math.max(min, Math.min(max, v));
70
- };
71
- /**
72
- * Checks if a and b are almost equals.
73
- * The absolute value of the difference between a and b is close to zero.
74
- * @param a - The left value to compare
75
- * @param b - The right value to compare
76
- * @returns True if a almost equal to b, false otherwise
77
- */ MathUtil.equals = function equals(a, b) {
78
- return Math.abs(a - b) <= MathUtil.zeroTolerance;
79
- };
80
- /**
81
- * Determines whether the specified v is pow2.
82
- * @param v - The specified v
83
- * @returns True if the specified v is pow2, false otherwise
84
- */ MathUtil.isPowerOf2 = function isPowerOf2(v) {
85
- return (v & v - 1) === 0;
86
- };
87
- /**
88
- * Modify the specified r from radian to degree.
89
- * @param r - The specified r
90
- * @returns The degree value
91
- */ MathUtil.radianToDegree = function radianToDegree(r) {
92
- return r * MathUtil.radToDegreeFactor;
93
- };
94
- /**
95
- * Modify the specified d from degree to radian.
96
- * @param d - The specified d
97
- * @returns The radian value
98
- */ MathUtil.degreeToRadian = function degreeToRadian(d) {
99
- return d * MathUtil.degreeToRadFactor;
100
- };
101
- return MathUtil;
102
- }();
103
- (function() {
104
- /** The value for which all absolute numbers smaller than are considered equal to zero. */ MathUtil.zeroTolerance = 1e-6;
105
- })();
106
- (function() {
107
- /** The conversion factor that radian to degree. */ MathUtil.radToDegreeFactor = 180 / Math.PI;
108
- })();
109
- (function() {
110
- /** The conversion factor that degree to radian. */ MathUtil.degreeToRadFactor = Math.PI / 180;
111
- })();
112
-
113
- /**
114
- * Describes a color in the from of RGBA (in order: R, G, B, A).
115
- */ var Color = /*#__PURE__*/ function() {
116
- function Color(r, g, b, a) {
117
- if (r === void 0) r = 1;
118
- if (g === void 0) g = 1;
119
- if (b === void 0) b = 1;
120
- if (a === void 0) a = 1;
121
- /** @internal */ this._onValueChanged = null;
122
- this._r = r;
123
- this._g = g;
124
- this._b = b;
125
- this._a = a;
126
- }
127
- var _proto = Color.prototype;
128
- /**
129
- * Set the value of this color.
130
- * @param r - The red component of the color
131
- * @param g - The green component of the color
132
- * @param b - The blue component of the color
133
- * @param a - The alpha component of the color
134
- * @returns This color.
135
- */ _proto.set = function set(r, g, b, a) {
136
- this._r = r;
137
- this._g = g;
138
- this._b = b;
139
- this._a = a;
140
- this._onValueChanged && this._onValueChanged();
141
- return this;
142
- };
143
- /**
144
- * Determines the sum of this color and the specified color.
145
- * @param color - The specified color
146
- * @returns The added color
147
- */ _proto.add = function add(color) {
148
- this._r += color._r;
149
- this._g += color._g;
150
- this._b += color._b;
151
- this._a += color._a;
152
- this._onValueChanged && this._onValueChanged();
153
- return this;
154
- };
155
- /**
156
- * Scale this color by the given value.
157
- * @param s - The amount by which to scale the color
158
- * @returns The scaled color
159
- */ _proto.scale = function scale(s) {
160
- this._r *= s;
161
- this._g *= s;
162
- this._b *= s;
163
- this._a *= s;
164
- this._onValueChanged && this._onValueChanged();
165
- return this;
166
- };
167
- /**
168
- * Creates a clone of this color.
169
- * @returns A clone of this color
170
- */ _proto.clone = function clone() {
171
- var ret = new Color(this._r, this._g, this._b, this._a);
172
- return ret;
173
- };
174
- /**
175
- * Copy from color like object.
176
- * @param source - Color like object.
177
- * @returns This vector
178
- */ _proto.copyFrom = function copyFrom(source) {
179
- this._r = source.r;
180
- this._g = source.g;
181
- this._b = source.b;
182
- this._a = source.a;
183
- this._onValueChanged && this._onValueChanged();
184
- return this;
185
- };
186
- /**
187
- * Copy from array like object.
188
- * @param source - Array like object
189
- * @param offset - The start offset
190
- * @returns This color
191
- */ _proto.copyFromArray = function copyFromArray(source, offset) {
192
- if (offset === void 0) offset = 0;
193
- this._r = source[offset];
194
- this._g = source[offset + 1];
195
- this._b = source[offset + 2];
196
- this._a = source[offset + 3];
197
- this._onValueChanged && this._onValueChanged();
198
- return this;
199
- };
200
- /**
201
- * Copy the value of this color to an array.
202
- * @param out - The color
203
- * @param outOffset - The start offset
204
- */ _proto.copyToArray = function copyToArray(out, outOffset) {
205
- if (outOffset === void 0) outOffset = 0;
206
- out[outOffset] = this._r;
207
- out[outOffset + 1] = this._g;
208
- out[outOffset + 2] = this._b;
209
- out[outOffset + 3] = this._a;
210
- };
211
- /**
212
- * Modify components (r, g, b) of this color from gamma space to linear space.
213
- * @param out - The color in linear space
214
- * @returns The color in linear space
215
- */ _proto.toLinear = function toLinear(out) {
216
- out._r = Color.gammaToLinearSpace(this._r);
217
- out._g = Color.gammaToLinearSpace(this._g);
218
- out._b = Color.gammaToLinearSpace(this._b);
219
- this._onValueChanged && this._onValueChanged();
220
- return out;
221
- };
222
- /**
223
- * Modify components (r, g, b) of this color from linear space to gamma space.
224
- * @param out - The color in gamma space
225
- * @returns The color in gamma space
226
- */ _proto.toGamma = function toGamma(out) {
227
- out._r = Color.linearToGammaSpace(this._r);
228
- out._g = Color.linearToGammaSpace(this._g);
229
- out._b = Color.linearToGammaSpace(this._b);
230
- this._onValueChanged && this._onValueChanged();
231
- return out;
232
- };
233
- /**
234
- * Gets the brightness.
235
- * @returns The Hue-Saturation-Brightness (HSB) saturation for this
236
- */ _proto.getBrightness = function getBrightness() {
237
- var r = this.r;
238
- var g = this.g;
239
- var b = this.b;
240
- var max = r;
241
- var min = r;
242
- if (g > max) max = g;
243
- if (b > max) max = b;
244
- if (g < min) min = g;
245
- if (b < min) min = b;
246
- return (max + min) / 2;
247
- };
248
- /**
249
- * Serialize this color to a JSON representation.
250
- * @return A JSON representation of this color
251
- */ _proto.toJSON = function toJSON() {
252
- return {
253
- r: this._r,
254
- g: this._g,
255
- b: this._b,
256
- a: this._a
257
- };
258
- };
259
- /**
260
- * Modify a value from the gamma space to the linear space.
261
- * @param value - The value in gamma space
262
- * @returns The value in linear space
263
- */ Color.gammaToLinearSpace = function gammaToLinearSpace(value) {
264
- // https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_framebuffer_sRGB.txt
265
- // https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_texture_sRGB_decode.txt
266
- if (value <= 0.0) return 0.0;
267
- else if (value <= 0.04045) return value / 12.92;
268
- else if (value < 1.0) return Math.pow((value + 0.055) / 1.055, 2.4);
269
- else return Math.pow(value, 2.4);
270
- };
271
- /**
272
- * Modify a value from the linear space to the gamma space.
273
- * @param value - The value in linear space
274
- * @returns The value in gamma space
275
- */ Color.linearToGammaSpace = function linearToGammaSpace(value) {
276
- // https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_framebuffer_sRGB.txt
277
- // https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_texture_sRGB_decode.txt
278
- if (value <= 0.0) return 0.0;
279
- else if (value < 0.0031308) return 12.92 * value;
280
- else if (value < 1.0) return 1.055 * Math.pow(value, 0.41666) - 0.055;
281
- else return Math.pow(value, 0.41666);
282
- };
283
- /**
284
- * Determines whether the specified colors are equals.
285
- * @param left - The first color to compare
286
- * @param right - The second color to compare
287
- * @returns True if the specified colors are equals, false otherwise
288
- */ Color.equals = function equals(left, right) {
289
- 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);
290
- };
291
- /**
292
- * Determines the sum of two colors.
293
- * @param left - The first color to add
294
- * @param right - The second color to add
295
- * @param out - The sum of two colors
296
- * @returns The added color
297
- */ Color.add = function add(left, right, out) {
298
- out._r = left._r + right._r;
299
- out._g = left._g + right._g;
300
- out._b = left._b + right._b;
301
- out._a = left._a + right._a;
302
- out._onValueChanged && out._onValueChanged();
303
- return out;
304
- };
305
- /**
306
- * Determines the difference between two colors.
307
- * @param left - The first color to subtract
308
- * @param right - The second color to subtract
309
- * @param out - The difference between two colors
310
- */ Color.subtract = function subtract(left, right, out) {
311
- out._r = left._r - right._r;
312
- out._g = left._g - right._g;
313
- out._b = left._b - right._b;
314
- out._a = left._a - right._a;
315
- out._onValueChanged && out._onValueChanged();
316
- };
317
- /**
318
- * Scale a color by the given value.
319
- * @param left - The color to scale
320
- * @param s - The amount by which to scale the color
321
- * @param out - The scaled color
322
- * @returns The scaled color
323
- */ Color.scale = function scale(left, s, out) {
324
- out._r = left._r * s;
325
- out._g = left._g * s;
326
- out._b = left._b * s;
327
- out._a = left._a * s;
328
- out._onValueChanged && out._onValueChanged();
329
- return out;
330
- };
331
- /**
332
- * Performs a linear interpolation between two color.
333
- * @param start - The first color
334
- * @param end - The second color
335
- * @param t - The blend amount where 0 returns start and 1 end
336
- * @param out - The result of linear blending between two color
337
- */ Color.lerp = function lerp(start, end, t, out) {
338
- var _r = start._r, _g = start._g, _b = start._b, _a = start._a;
339
- out._r = _r + (end._r - _r) * t;
340
- out._g = _g + (end._g - _g) * t;
341
- out._b = _b + (end._b - _b) * t;
342
- out._a = _a + (end._a - _a) * t;
343
- out._onValueChanged && out._onValueChanged();
344
- return out;
345
- };
346
- _create_class(Color, [
347
- {
348
- key: "r",
349
- get: /**
350
- * The red component of the color, 0~1.
351
- */ function get() {
352
- return this._r;
353
- },
354
- set: function set(value) {
355
- this._r = value;
356
- this._onValueChanged && this._onValueChanged();
357
- }
358
- },
359
- {
360
- key: "g",
361
- get: /**
362
- * The green component of the color, 0~1.
363
- */ function get() {
364
- return this._g;
365
- },
366
- set: function set(value) {
367
- this._g = value;
368
- this._onValueChanged && this._onValueChanged();
369
- }
370
- },
371
- {
372
- key: "b",
373
- get: /**
374
- * The blue component of the color, 0~1.
375
- */ function get() {
376
- return this._b;
377
- },
378
- set: function set(value) {
379
- this._b = value;
380
- this._onValueChanged && this._onValueChanged();
381
- }
382
- },
383
- {
384
- key: "a",
385
- get: /**
386
- * The alpha component of the color, 0~1.
387
- */ function get() {
388
- return this._a;
389
- },
390
- set: function set(value) {
391
- this._a = value;
392
- this._onValueChanged && this._onValueChanged();
393
- }
394
- }
395
- ]);
396
- return Color;
397
- }();
398
-
399
58
  /**
400
59
  * Sprite mask interaction.
401
60
  */ var SpriteMaskInteraction;
@@ -936,7 +595,14 @@ var Utils = /*#__PURE__*/ function() {
936
595
  * @param url - The url to be judged.
937
596
  * @returns Whether the url is absolute url.
938
597
  */ Utils.isAbsoluteUrl = function isAbsoluteUrl(url) {
939
- return /^(?:http|blob|data:|\/)/.test(url);
598
+ return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
599
+ };
600
+ /**
601
+ * Judge whether the url is base64 url.
602
+ * @param url - The url to be judged.
603
+ * @returns Whether the url is base64 url.
604
+ */ Utils.isBase64Url = function isBase64Url(url) {
605
+ return /^data:.*,.*$/i.test(url);
940
606
  };
941
607
  /**
942
608
  * Get the values of an object.
@@ -954,7 +620,10 @@ var Utils = /*#__PURE__*/ function() {
954
620
  if (Utils.isAbsoluteUrl(relativeUrl)) {
955
621
  return relativeUrl;
956
622
  }
957
- return baseUrl.substring(0, baseUrl.lastIndexOf("/") + 1) + this._formatRelativePath(relativeUrl);
623
+ if (Utils.isBase64Url(relativeUrl)) {
624
+ return relativeUrl;
625
+ }
626
+ return relativeUrl ? baseUrl.replace(/\/+$/, "") + "/" + relativeUrl.replace(/^\/+/, "") : baseUrl;
958
627
  };
959
628
  /**
960
629
  * @internal
@@ -1400,9 +1069,9 @@ var rePropName$1 = RegExp(// Match anything that isn't a dot or bracket.
1400
1069
  var _this = this, region = _this._region;
1401
1070
  // @ts-ignore
1402
1071
  region._onValueChanged = null;
1403
- var x = MathUtil$1.clamp(region.x, 0, 1);
1404
- var y = MathUtil$1.clamp(region.y, 0, 1);
1405
- region.set(x, y, MathUtil$1.clamp(region.width, 0, 1 - x), MathUtil$1.clamp(region.height, 0, 1 - y));
1072
+ var x = MathUtil.clamp(region.x, 0, 1);
1073
+ var y = MathUtil.clamp(region.y, 0, 1);
1074
+ region.set(x, y, MathUtil.clamp(region.width, 0, 1 - x), MathUtil.clamp(region.height, 0, 1 - y));
1406
1075
  this._dispatchSpriteChange(SpriteModifyFlags.region);
1407
1076
  if (this._customWidth === undefined || this._customHeight === undefined) {
1408
1077
  this._dispatchSpriteChange(SpriteModifyFlags.size);
@@ -1417,9 +1086,9 @@ var rePropName$1 = RegExp(// Match anything that isn't a dot or bracket.
1417
1086
  var _this = this, border = _this._border;
1418
1087
  // @ts-ignore
1419
1088
  border._onValueChanged = null;
1420
- var x = MathUtil$1.clamp(border.x, 0, 1);
1421
- var y = MathUtil$1.clamp(border.y, 0, 1);
1422
- border.set(x, y, MathUtil$1.clamp(border.z, 0, 1 - x), MathUtil$1.clamp(border.w, 0, 1 - y));
1089
+ var x = MathUtil.clamp(border.x, 0, 1);
1090
+ var y = MathUtil.clamp(border.y, 0, 1);
1091
+ border.set(x, y, MathUtil.clamp(border.z, 0, 1 - x), MathUtil.clamp(border.w, 0, 1 - y));
1423
1092
  this._dispatchSpriteChange(SpriteModifyFlags.border);
1424
1093
  // @ts-ignore
1425
1094
  border._onValueChanged = this._onBorderChange;
@@ -1509,9 +1178,9 @@ var rePropName$1 = RegExp(// Match anything that isn't a dot or bracket.
1509
1178
  return this._atlasRegion;
1510
1179
  },
1511
1180
  set: function set(value) {
1512
- var x = MathUtil$1.clamp(value.x, 0, 1);
1513
- var y = MathUtil$1.clamp(value.y, 0, 1);
1514
- this._atlasRegion.set(x, y, MathUtil$1.clamp(value.width, 0, 1 - x), MathUtil$1.clamp(value.height, 0, 1 - y));
1181
+ var x = MathUtil.clamp(value.x, 0, 1);
1182
+ var y = MathUtil.clamp(value.y, 0, 1);
1183
+ this._atlasRegion.set(x, y, MathUtil.clamp(value.width, 0, 1 - x), MathUtil.clamp(value.height, 0, 1 - y));
1515
1184
  this._dispatchSpriteChange(SpriteModifyFlags.atlasRegion);
1516
1185
  if (this._customWidth === undefined || this._customHeight === undefined) {
1517
1186
  this._dispatchSpriteChange(SpriteModifyFlags.size);
@@ -1526,9 +1195,9 @@ var rePropName$1 = RegExp(// Match anything that isn't a dot or bracket.
1526
1195
  return this._atlasRegionOffset;
1527
1196
  },
1528
1197
  set: function set(value) {
1529
- var x = MathUtil$1.clamp(value.x, 0, 1);
1530
- var y = MathUtil$1.clamp(value.y, 0, 1);
1531
- this._atlasRegionOffset.set(x, y, MathUtil$1.clamp(value.z, 0, 1 - x), MathUtil$1.clamp(value.w, 0, 1 - y));
1198
+ var x = MathUtil.clamp(value.x, 0, 1);
1199
+ var y = MathUtil.clamp(value.y, 0, 1);
1200
+ this._atlasRegionOffset.set(x, y, MathUtil.clamp(value.z, 0, 1 - x), MathUtil.clamp(value.w, 0, 1 - y));
1532
1201
  this._dispatchSpriteChange(SpriteModifyFlags.atlasRegionOffset);
1533
1202
  if (this._customWidth === undefined || this._customHeight === undefined) {
1534
1203
  this._dispatchSpriteChange(SpriteModifyFlags.size);
@@ -2116,20 +1785,28 @@ var ActiveChangeFlag;
2116
1785
  this._enabled = value;
2117
1786
  if (this._entity._isActiveInScene) {
2118
1787
  if (value) {
2119
- this._phasedActiveInScene = true;
2120
- this._onEnableInScene();
1788
+ if (!this._phasedActiveInScene) {
1789
+ this._phasedActiveInScene = true;
1790
+ this._onEnableInScene();
1791
+ }
2121
1792
  } else {
2122
- this._phasedActiveInScene = false;
2123
- this._onDisableInScene();
1793
+ if (this._phasedActiveInScene) {
1794
+ this._phasedActiveInScene = false;
1795
+ this._onDisableInScene();
1796
+ }
2124
1797
  }
2125
1798
  }
2126
1799
  if (this._entity.isActiveInHierarchy) {
2127
1800
  if (value) {
2128
- this._phasedActive = true;
2129
- this._onEnable();
1801
+ if (!this._phasedActive) {
1802
+ this._phasedActive = true;
1803
+ this._onEnable();
1804
+ }
2130
1805
  } else {
2131
- this._phasedActive = false;
2132
- this._onDisable();
1806
+ if (this._phasedActive) {
1807
+ this._phasedActive = false;
1808
+ this._onDisable();
1809
+ }
2133
1810
  }
2134
1811
  }
2135
1812
  }
@@ -2442,7 +2119,7 @@ var DependentMode;
2442
2119
  * @param relativeToLocal = `true` - Relative to local space
2443
2120
  */ _proto.rotateByAxis = function rotateByAxis(axis, angle, relativeToLocal) {
2444
2121
  if (relativeToLocal === void 0) relativeToLocal = true;
2445
- var rad = angle * MathUtil$1.degreeToRadFactor;
2122
+ var rad = angle * MathUtil.degreeToRadFactor;
2446
2123
  Quaternion.rotationAxisAngle(axis, rad, Transform._tempQuat0);
2447
2124
  this._rotateByQuat(Transform._tempQuat0, relativeToLocal);
2448
2125
  };
@@ -2454,7 +2131,7 @@ var DependentMode;
2454
2131
  var zAxis = Transform._tempVec30;
2455
2132
  Vector3.subtract(this.worldPosition, targetPosition, zAxis);
2456
2133
  var axisLen = zAxis.length();
2457
- if (axisLen <= MathUtil$1.zeroTolerance) {
2134
+ if (axisLen <= MathUtil.zeroTolerance) {
2458
2135
  // The current position and the target position are almost the same.
2459
2136
  return;
2460
2137
  }
@@ -2466,7 +2143,7 @@ var DependentMode;
2466
2143
  xAxis.set(zAxis.z, 0, -zAxis.x);
2467
2144
  }
2468
2145
  axisLen = xAxis.length();
2469
- if (axisLen <= MathUtil$1.zeroTolerance) {
2146
+ if (axisLen <= MathUtil.zeroTolerance) {
2470
2147
  // @todo:
2471
2148
  // 1.worldUp is(0,0,0)
2472
2149
  // 2.worldUp is parallel to zAxis
@@ -2673,7 +2350,7 @@ var DependentMode;
2673
2350
  };
2674
2351
  _proto._rotateXYZ = function _rotateXYZ(x, y, z, relativeToLocal) {
2675
2352
  if (relativeToLocal === void 0) relativeToLocal = true;
2676
- var radFactor = MathUtil$1.degreeToRadFactor;
2353
+ var radFactor = MathUtil.degreeToRadFactor;
2677
2354
  var rotQuat = Transform._tempQuat0;
2678
2355
  Quaternion.rotationEuler(x * radFactor, y * radFactor, z * radFactor, rotQuat);
2679
2356
  this._rotateByQuat(rotQuat, relativeToLocal);
@@ -2700,7 +2377,7 @@ var DependentMode;
2700
2377
  };
2701
2378
  _proto._onWorldRotationChanged = function _onWorldRotationChanged() {
2702
2379
  var worldRotation = this._worldRotation;
2703
- Quaternion.rotationEuler(MathUtil$1.degreeToRadian(worldRotation.x), MathUtil$1.degreeToRadian(worldRotation.y), MathUtil$1.degreeToRadian(worldRotation.z), this._worldRotationQuaternion);
2380
+ Quaternion.rotationEuler(MathUtil.degreeToRadian(worldRotation.x), MathUtil.degreeToRadian(worldRotation.y), MathUtil.degreeToRadian(worldRotation.z), this._worldRotationQuaternion);
2704
2381
  this._setDirtyFlagFalse(0x8);
2705
2382
  };
2706
2383
  _proto._onRotationQuaternionChanged = function _onRotationQuaternionChanged() {
@@ -2775,7 +2452,7 @@ var DependentMode;
2775
2452
  //@ts-ignore
2776
2453
  rotation._onValueChanged = null;
2777
2454
  this._rotationQuaternion.toEuler(rotation);
2778
- rotation.scale(MathUtil$1.radToDegreeFactor); // radians to degrees
2455
+ rotation.scale(MathUtil.radToDegreeFactor); // radians to degrees
2779
2456
  //@ts-ignore
2780
2457
  rotation._onValueChanged = this._onRotationChanged;
2781
2458
  this._setDirtyFlagFalse(0x1);
@@ -2799,7 +2476,7 @@ var DependentMode;
2799
2476
  //@ts-ignore
2800
2477
  worldRotation._onValueChanged = null;
2801
2478
  this.worldRotationQuaternion.toEuler(worldRotation);
2802
- worldRotation.scale(MathUtil$1.radToDegreeFactor); // Radian to angle
2479
+ worldRotation.scale(MathUtil.radToDegreeFactor); // Radian to angle
2803
2480
  //@ts-ignore
2804
2481
  worldRotation._onValueChanged = this._onWorldRotationChanged;
2805
2482
  this._setDirtyFlagFalse(0x8);
@@ -2821,7 +2498,7 @@ var DependentMode;
2821
2498
  if (this._isContainDirtyFlag(0x2)) {
2822
2499
  //@ts-ignore
2823
2500
  rotationQuaternion._onValueChanged = null;
2824
- Quaternion.rotationEuler(MathUtil$1.degreeToRadian(this._rotation.x), MathUtil$1.degreeToRadian(this._rotation.y), MathUtil$1.degreeToRadian(this._rotation.z), rotationQuaternion);
2501
+ Quaternion.rotationEuler(MathUtil.degreeToRadian(this._rotation.x), MathUtil.degreeToRadian(this._rotation.y), MathUtil.degreeToRadian(this._rotation.z), rotationQuaternion);
2825
2502
  //@ts-ignore
2826
2503
  rotationQuaternion._onValueChanged = this._onRotationQuaternionChanged;
2827
2504
  this._setDirtyFlagFalse(0x2);
@@ -3502,7 +3179,7 @@ function _extends() {
3502
3179
  return _extends.apply(this, arguments);
3503
3180
  }
3504
3181
 
3505
- var camera_declare = "#define GLSLIFY 1\nuniform vec3 camera_Position;"; // eslint-disable-line
3182
+ var camera_declare = "#define GLSLIFY 1\nuniform vec3 camera_Position;uniform vec3 camera_Forward;"; // eslint-disable-line
3506
3183
 
3507
3184
  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
3508
3185
 
@@ -3552,7 +3229,7 @@ var mobile_material_frag = "#define GLSLIFY 1\nuniform vec4 material_EmissiveCol
3552
3229
 
3553
3230
  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
3554
3231
 
3555
- 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
3232
+ 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
3556
3233
 
3557
3234
  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
3558
3235
 
@@ -3590,7 +3267,7 @@ var noise_simplex_4D = "#define GLSLIFY 1\nvec4 grad4(float j,vec4 ip){const vec
3590
3267
 
3591
3268
  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
3592
3269
 
3593
- 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;geometry.viewDir=normalize(camera_Position-v_pos);\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
3270
+ 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
3594
3271
 
3595
3272
  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
3596
3273
 
@@ -3611,7 +3288,7 @@ var PBRShaderLib = {
3611
3288
 
3612
3289
  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
3613
3290
 
3614
- 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 vec3 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 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\nattenuation=mix(1.0,attenuation,scene_ShadowInfo.x);}return attenuation;}\n#endif\n"; // eslint-disable-line
3291
+ 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
3615
3292
 
3616
3293
  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
3617
3294
 
@@ -3726,16 +3403,22 @@ var ShaderFactory = /*#__PURE__*/ function() {
3726
3403
  }
3727
3404
  ShaderLib[includeName] = includeSource;
3728
3405
  };
3729
- ShaderFactory.parseIncludes = function parseIncludes(src) {
3406
+ ShaderFactory.unRegisterInclude = function unRegisterInclude(includeName) {
3407
+ delete ShaderLib[includeName];
3408
+ };
3409
+ /**
3410
+ * @param regex The default regex is for engine's builtin glsl `#include` syntax,
3411
+ * since `ShaderLab` use the same parsing function but different syntax for `#include` --- `/^[ \t]*#include +"([\w\d.]+)"/gm`
3412
+ */ ShaderFactory.parseIncludes = function parseIncludes(src, regex) {
3413
+ if (regex === void 0) regex = /^[ \t]*#include +<([\w\d.]+)>/gm;
3730
3414
  var replace = function replace(match, slice) {
3731
3415
  var replace = ShaderLib[slice];
3732
3416
  if (replace === undefined) {
3733
3417
  Logger.error('Shader slice "' + match.trim() + '" not founded.');
3734
3418
  return "";
3735
3419
  }
3736
- return ShaderFactory.parseIncludes(replace);
3420
+ return ShaderFactory.parseIncludes(replace, regex);
3737
3421
  };
3738
- var regex = /^[ \t]*#include +<([\w\d.]+)>/gm;
3739
3422
  return src.replace(regex, replace);
3740
3423
  };
3741
3424
  /**
@@ -3846,16 +3529,6 @@ var ShaderFactory = /*#__PURE__*/ function() {
3846
3529
  return ShaderPart;
3847
3530
  }();
3848
3531
 
3849
- /**
3850
- * Shader data grouping.
3851
- */ var ShaderDataGroup;
3852
- (function(ShaderDataGroup) {
3853
- ShaderDataGroup[ShaderDataGroup[/** Scene group. */ "Scene"] = 0] = "Scene";
3854
- ShaderDataGroup[ShaderDataGroup[/** Camera group. */ "Camera"] = 1] = "Camera";
3855
- ShaderDataGroup[ShaderDataGroup[/** Renderer group. */ "Renderer"] = 2] = "Renderer";
3856
- ShaderDataGroup[ShaderDataGroup[/** material group. */ "Material"] = 3] = "Material";
3857
- })(ShaderDataGroup || (ShaderDataGroup = {}));
3858
-
3859
3532
  /**
3860
3533
  * Color Space.
3861
3534
  */ var ColorSpace;
@@ -3890,7 +3563,7 @@ var ShaderFactory = /*#__PURE__*/ function() {
3890
3563
  if (value.r !== undefined) {
3891
3564
  if (cacheValue.x !== value.r || cacheValue.y !== value.g) {
3892
3565
  if (this._colorSpace === ColorSpace.Linear) {
3893
- this._gl.uniform2f(shaderUniform.location, Color$1.gammaToLinearSpace(value.r), Color$1.gammaToLinearSpace(value.g));
3566
+ this._gl.uniform2f(shaderUniform.location, Color.gammaToLinearSpace(value.r), Color.gammaToLinearSpace(value.g));
3894
3567
  } else {
3895
3568
  this._gl.uniform2f(shaderUniform.location, value.r, value.g);
3896
3569
  }
@@ -3913,7 +3586,7 @@ var ShaderFactory = /*#__PURE__*/ function() {
3913
3586
  if (value.r !== undefined) {
3914
3587
  if (cacheValue.x !== value.r || cacheValue.y !== value.g || cacheValue.z !== value.b) {
3915
3588
  if (this._colorSpace === ColorSpace.Linear) {
3916
- this._gl.uniform3f(shaderUniform.location, Color$1.gammaToLinearSpace(value.r), Color$1.gammaToLinearSpace(value.g), Color$1.gammaToLinearSpace(value.b));
3589
+ this._gl.uniform3f(shaderUniform.location, Color.gammaToLinearSpace(value.r), Color.gammaToLinearSpace(value.g), Color.gammaToLinearSpace(value.b));
3917
3590
  } else {
3918
3591
  this._gl.uniform3f(shaderUniform.location, value.r, value.g, value.b);
3919
3592
  }
@@ -3938,7 +3611,7 @@ var ShaderFactory = /*#__PURE__*/ function() {
3938
3611
  if (value.r !== undefined) {
3939
3612
  if (cacheValue.x !== value.r || cacheValue.y !== value.g || cacheValue.z !== value.b || cacheValue.w !== value.a) {
3940
3613
  if (this._colorSpace === ColorSpace.Linear) {
3941
- this._gl.uniform4f(shaderUniform.location, Color$1.gammaToLinearSpace(value.r), Color$1.gammaToLinearSpace(value.g), Color$1.gammaToLinearSpace(value.b), value.a);
3614
+ this._gl.uniform4f(shaderUniform.location, Color.gammaToLinearSpace(value.r), Color.gammaToLinearSpace(value.g), Color.gammaToLinearSpace(value.b), value.a);
3942
3615
  } else {
3943
3616
  this._gl.uniform4f(shaderUniform.location, value.r, value.g, value.b, value.a);
3944
3617
  }
@@ -4065,6 +3738,16 @@ var ShaderFactory = /*#__PURE__*/ function() {
4065
3738
  this.textureUniforms = [];
4066
3739
  };
4067
3740
 
3741
+ /**
3742
+ * Shader data grouping.
3743
+ */ var ShaderDataGroup;
3744
+ (function(ShaderDataGroup) {
3745
+ ShaderDataGroup[ShaderDataGroup[/** Scene group. */ "Scene"] = 0] = "Scene";
3746
+ ShaderDataGroup[ShaderDataGroup[/** Camera group. */ "Camera"] = 1] = "Camera";
3747
+ ShaderDataGroup[ShaderDataGroup[/** Renderer group. */ "Renderer"] = 2] = "Renderer";
3748
+ ShaderDataGroup[ShaderDataGroup[/** material group. */ "Material"] = 3] = "Material";
3749
+ })(ShaderDataGroup || (ShaderDataGroup = {}));
3750
+
4068
3751
  /**
4069
3752
  * Shader program, corresponding to the GPU shader program.
4070
3753
  * @internal
@@ -4360,6 +4043,7 @@ var ShaderFactory = /*#__PURE__*/ function() {
4360
4043
  break;
4361
4044
  case gl.SAMPLER_2D:
4362
4045
  case gl.SAMPLER_CUBE:
4046
+ case gl.UNSIGNED_INT_SAMPLER_2D:
4363
4047
  case gl.SAMPLER_2D_ARRAY:
4364
4048
  case gl.SAMPLER_2D_SHADOW:
4365
4049
  var defaultTexture;
@@ -4370,6 +4054,9 @@ var ShaderFactory = /*#__PURE__*/ function() {
4370
4054
  case gl.SAMPLER_CUBE:
4371
4055
  defaultTexture = _this._engine._magentaTextureCube;
4372
4056
  break;
4057
+ case gl.UNSIGNED_INT_SAMPLER_2D:
4058
+ defaultTexture = _this._engine._uintMagentaTexture2D;
4059
+ break;
4373
4060
  case gl.SAMPLER_2D_ARRAY:
4374
4061
  defaultTexture = _this._engine._magentaTexture2DArray;
4375
4062
  break;
@@ -4589,7 +4276,7 @@ var ShaderFactory = /*#__PURE__*/ function() {
4589
4276
  */ var BlendState = /*#__PURE__*/ function() {
4590
4277
  function BlendState() {
4591
4278
  /** The blend state of the render target. */ this.targetBlendState = new RenderTargetBlendState();
4592
- /** Constant blend color. */ this.blendColor = new Color$1(0, 0, 0, 0);
4279
+ /** Constant blend color. */ this.blendColor = new Color(0, 0, 0, 0);
4593
4280
  /** Whether to use (Alpha-to-Coverage) technology. */ this.alphaToCoverage = false;
4594
4281
  }
4595
4282
  var _proto = BlendState.prototype;
@@ -4683,7 +4370,7 @@ var ShaderFactory = /*#__PURE__*/ function() {
4683
4370
  }
4684
4371
  // apply blend color.
4685
4372
  var blendColor = this.blendColor;
4686
- if (!Color$1.equals(lastState.blendColor, blendColor)) {
4373
+ if (!Color.equals(lastState.blendColor, blendColor)) {
4687
4374
  gl.blendColor(blendColor.r, blendColor.g, blendColor.b, blendColor.a);
4688
4375
  lastState.blendColor.copyFrom(blendColor);
4689
4376
  }
@@ -5459,6 +5146,57 @@ var GraphicsResource = /*#__PURE__*/ function(ReferResource1) {
5459
5146
  return GraphicsResource;
5460
5147
  }(ReferResource);
5461
5148
 
5149
+ /**
5150
+ * The filter mode of the texture.
5151
+ */ var TextureFilterMode;
5152
+ (function(TextureFilterMode) {
5153
+ TextureFilterMode[TextureFilterMode[/** Point filtering. */ "Point"] = 0] = "Point";
5154
+ TextureFilterMode[TextureFilterMode[/** Bilinear filtering. */ "Bilinear"] = 1] = "Bilinear";
5155
+ TextureFilterMode[TextureFilterMode[/** Trilinear filtering. */ "Trilinear"] = 2] = "Trilinear";
5156
+ })(TextureFilterMode || (TextureFilterMode = {}));
5157
+
5158
+ /**
5159
+ * Texture format enumeration.
5160
+ */ var TextureFormat;
5161
+ (function(TextureFormat) {
5162
+ TextureFormat[TextureFormat[/** RGB format, 8 bits per channel. */ "R8G8B8"] = 0] = "R8G8B8";
5163
+ TextureFormat[TextureFormat[/** RGBA format, 8 bits per channel. */ "R8G8B8A8"] = 1] = "R8G8B8A8";
5164
+ TextureFormat[TextureFormat[/** RGBA format, 4 bits per channel. */ "R4G4B4A4"] = 2] = "R4G4B4A4";
5165
+ 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";
5166
+ TextureFormat[TextureFormat[/** RGB format, 5 bits in R channel, 6 bits in G channel, 5 bits in B channel. */ "R5G6B5"] = 4] = "R5G6B5";
5167
+ TextureFormat[TextureFormat[/** Transparent format, 8 bits. */ "Alpha8"] = 5] = "Alpha8";
5168
+ TextureFormat[TextureFormat[/** Luminance/alpha in RGB channel, alpha in A channel. */ "LuminanceAlpha"] = 6] = "LuminanceAlpha";
5169
+ TextureFormat[TextureFormat[/** RGBA format, 16 bits per channel. */ "R16G16B16A16"] = 7] = "R16G16B16A16";
5170
+ TextureFormat[TextureFormat[/** RGBA format, 32 bits per channel. */ "R32G32B32A32"] = 8] = "R32G32B32A32";
5171
+ TextureFormat[TextureFormat[/** RGBA unsigned integer format, 32 bits per channel. */ "R32G32B32A32_UInt"] = 9] = "R32G32B32A32_UInt";
5172
+ TextureFormat[TextureFormat[/** RGB compressed format, 4 bits per pixel. */ "BC1"] = 10] = "BC1";
5173
+ TextureFormat[TextureFormat[/** RGBA compressed format, 8 bits per pixel. */ "BC3"] = 11] = "BC3";
5174
+ TextureFormat[TextureFormat[/** RGB(A) compressed format, 128 bits per 4x4 pixel block. */ "BC7"] = 12] = "BC7";
5175
+ TextureFormat[TextureFormat[/** RGB compressed format, 4 bits per pixel. */ "ETC1_RGB"] = 13] = "ETC1_RGB";
5176
+ TextureFormat[TextureFormat[/** RGB compressed format, 4 bits per pixel. */ "ETC2_RGB"] = 14] = "ETC2_RGB";
5177
+ TextureFormat[TextureFormat[/** RGBA compressed format, 5 bits per pixel, 4 bit in RGB, 1 bit in A. */ "ETC2_RGBA5"] = 15] = "ETC2_RGBA5";
5178
+ TextureFormat[TextureFormat[/** RGB compressed format, 8 bits per pixel. */ "ETC2_RGBA8"] = 16] = "ETC2_RGBA8";
5179
+ TextureFormat[TextureFormat[/** RGB compressed format, 2 bits per pixel. */ "PVRTC_RGB2"] = 17] = "PVRTC_RGB2";
5180
+ TextureFormat[TextureFormat[/** RGBA compressed format, 2 bits per pixel. */ "PVRTC_RGBA2"] = 18] = "PVRTC_RGBA2";
5181
+ TextureFormat[TextureFormat[/** RGB compressed format, 4 bits per pixel. */ "PVRTC_RGB4"] = 19] = "PVRTC_RGB4";
5182
+ TextureFormat[TextureFormat[/** RGBA compressed format, 4 bits per pixel. */ "PVRTC_RGBA4"] = 20] = "PVRTC_RGBA4";
5183
+ TextureFormat[TextureFormat[/** RGB(A) compressed format, 128 bits per 4x4 pixel block. */ "ASTC_4x4"] = 21] = "ASTC_4x4";
5184
+ TextureFormat[TextureFormat[/** RGB(A) compressed format, 128 bits per 5x5 pixel block. */ "ASTC_5x5"] = 22] = "ASTC_5x5";
5185
+ TextureFormat[TextureFormat[/** RGB(A) compressed format, 128 bits per 6x6 pixel block. */ "ASTC_6x6"] = 23] = "ASTC_6x6";
5186
+ TextureFormat[TextureFormat[/** RGB(A) compressed format, 128 bits per 8x8 pixel block. */ "ASTC_8x8"] = 24] = "ASTC_8x8";
5187
+ TextureFormat[TextureFormat[/** RGB(A) compressed format, 128 bits per 10x10 pixel block. */ "ASTC_10x10"] = 25] = "ASTC_10x10";
5188
+ TextureFormat[TextureFormat[/** RGB(A) compressed format, 128 bits per 12x12 pixel block. */ "ASTC_12x12"] = 26] = "ASTC_12x12";
5189
+ TextureFormat[TextureFormat[/** Automatic depth format, engine will automatically select the supported precision. */ "Depth"] = 27] = "Depth";
5190
+ TextureFormat[TextureFormat[/** Automatic depth stencil format, engine will automatically select the supported precision. */ "DepthStencil"] = 28] = "DepthStencil";
5191
+ TextureFormat[TextureFormat[/** 16-bit depth format. */ "Depth16"] = 29] = "Depth16";
5192
+ TextureFormat[TextureFormat[/** 24-bit depth format. */ "Depth24"] = 30] = "Depth24";
5193
+ TextureFormat[TextureFormat[/** 32-bit depth format. */ "Depth32"] = 31] = "Depth32";
5194
+ TextureFormat[TextureFormat[/** 16-bit depth + 8-bit stencil format. */ "Depth24Stencil8"] = 32] = "Depth24Stencil8";
5195
+ TextureFormat[TextureFormat[/** 32-bit depth + 8-bit stencil format. */ "Depth32Stencil8"] = 33] = "Depth32Stencil8";
5196
+ TextureFormat[TextureFormat[/** @deprecated Use `TextureFormat.BC1` instead. */ "DXT1"] = 34] = "DXT1";
5197
+ TextureFormat[TextureFormat[/** @deprecated Use `TextureFormat.BC3` instead. */ "DXT5"] = 35] = "DXT5";
5198
+ })(TextureFormat || (TextureFormat = {}));
5199
+
5462
5200
  /**
5463
5201
  * The base class of texture, contains some common functions of texture-related classes.
5464
5202
  */ var Texture = /*#__PURE__*/ function(GraphicsResource1) {
@@ -5515,6 +5253,12 @@ var GraphicsResource = /*#__PURE__*/ function(ReferResource1) {
5515
5253
  _proto._getMipmapCount = function _getMipmapCount() {
5516
5254
  return this._mipmap ? Math.floor(Math.log2(Math.max(this._width, this._height))) + 1 : 1;
5517
5255
  };
5256
+ _proto._isIntFormat = function _isIntFormat() {
5257
+ if (TextureFormat.R32G32B32A32_UInt === this._format) {
5258
+ return true;
5259
+ }
5260
+ return false;
5261
+ };
5518
5262
  _create_class(Texture, [
5519
5263
  {
5520
5264
  key: "format",
@@ -5591,6 +5335,11 @@ var GraphicsResource = /*#__PURE__*/ function(ReferResource1) {
5591
5335
  },
5592
5336
  set: function set(value) {
5593
5337
  if (value === this._filterMode) return;
5338
+ if (value !== TextureFilterMode.Point && this._isIntFormat()) {
5339
+ value = TextureFilterMode.Point;
5340
+ Logger.warn("Int or UInt format texture only support TextureFilterMode.Point");
5341
+ return;
5342
+ }
5594
5343
  this._filterMode = value;
5595
5344
  this._platformTexture.filterMode = value;
5596
5345
  }
@@ -6717,7 +6466,7 @@ SlicedSpriteAssembler = __decorate([
6717
6466
  _this._byteLength = byteLength;
6718
6467
  _this._platformBuffer = engine._hardwareRenderer.createPlatformBuffer(type, byteLength, bufferUsage, data);
6719
6468
  if (readable) {
6720
- var buffer = (data.constructor === ArrayBuffer ? data : data.buffer).slice(0, byteLength);
6469
+ var buffer = data.constructor === ArrayBuffer ? data.slice(0) : data.buffer.slice(data.byteOffset, data.byteOffset + byteLength);
6721
6470
  _this._data = new Uint8Array(buffer);
6722
6471
  }
6723
6472
  }
@@ -7894,56 +7643,6 @@ var /**
7894
7643
  TextureDepthCompareFunction[TextureDepthCompareFunction[/** always pass. */ "Always"] = 7] = "Always";
7895
7644
  })(TextureDepthCompareFunction || (TextureDepthCompareFunction = {}));
7896
7645
 
7897
- /**
7898
- * The filter mode of the texture.
7899
- */ var TextureFilterMode;
7900
- (function(TextureFilterMode) {
7901
- TextureFilterMode[TextureFilterMode[/** Point filtering. */ "Point"] = 0] = "Point";
7902
- TextureFilterMode[TextureFilterMode[/** Bilinear filtering. */ "Bilinear"] = 1] = "Bilinear";
7903
- TextureFilterMode[TextureFilterMode[/** Trilinear filtering. */ "Trilinear"] = 2] = "Trilinear";
7904
- })(TextureFilterMode || (TextureFilterMode = {}));
7905
-
7906
- /**
7907
- * Texture format enumeration.
7908
- */ var TextureFormat;
7909
- (function(TextureFormat) {
7910
- TextureFormat[TextureFormat[/** RGB format, 8 bits per channel. */ "R8G8B8"] = 0] = "R8G8B8";
7911
- TextureFormat[TextureFormat[/** RGBA format, 8 bits per channel. */ "R8G8B8A8"] = 1] = "R8G8B8A8";
7912
- TextureFormat[TextureFormat[/** RGBA format, 4 bits per channel. */ "R4G4B4A4"] = 2] = "R4G4B4A4";
7913
- 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";
7914
- TextureFormat[TextureFormat[/** RGB format, 5 bits in R channel, 6 bits in G channel, 5 bits in B channel. */ "R5G6B5"] = 4] = "R5G6B5";
7915
- TextureFormat[TextureFormat[/** Transparent format, 8 bits. */ "Alpha8"] = 5] = "Alpha8";
7916
- TextureFormat[TextureFormat[/** Luminance/alpha in RGB channel, alpha in A channel. */ "LuminanceAlpha"] = 6] = "LuminanceAlpha";
7917
- TextureFormat[TextureFormat[/** RGBA format, 16 bits per channel. */ "R16G16B16A16"] = 7] = "R16G16B16A16";
7918
- TextureFormat[TextureFormat[/** RGBA format, 32 bits per channel. */ "R32G32B32A32"] = 8] = "R32G32B32A32";
7919
- TextureFormat[TextureFormat[/** RGB compressed format, 4 bits per pixel. */ "BC1"] = 9] = "BC1";
7920
- TextureFormat[TextureFormat[/** RGBA compressed format, 8 bits per pixel. */ "BC3"] = 10] = "BC3";
7921
- TextureFormat[TextureFormat[/** RGB(A) compressed format, 128 bits per 4x4 pixel block. */ "BC7"] = 11] = "BC7";
7922
- TextureFormat[TextureFormat[/** RGB compressed format, 4 bits per pixel. */ "ETC1_RGB"] = 12] = "ETC1_RGB";
7923
- TextureFormat[TextureFormat[/** RGB compressed format, 4 bits per pixel. */ "ETC2_RGB"] = 13] = "ETC2_RGB";
7924
- TextureFormat[TextureFormat[/** RGBA compressed format, 5 bits per pixel, 4 bit in RGB, 1 bit in A. */ "ETC2_RGBA5"] = 14] = "ETC2_RGBA5";
7925
- TextureFormat[TextureFormat[/** RGB compressed format, 8 bits per pixel. */ "ETC2_RGBA8"] = 15] = "ETC2_RGBA8";
7926
- TextureFormat[TextureFormat[/** RGB compressed format, 2 bits per pixel. */ "PVRTC_RGB2"] = 16] = "PVRTC_RGB2";
7927
- TextureFormat[TextureFormat[/** RGBA compressed format, 2 bits per pixel. */ "PVRTC_RGBA2"] = 17] = "PVRTC_RGBA2";
7928
- TextureFormat[TextureFormat[/** RGB compressed format, 4 bits per pixel. */ "PVRTC_RGB4"] = 18] = "PVRTC_RGB4";
7929
- TextureFormat[TextureFormat[/** RGBA compressed format, 4 bits per pixel. */ "PVRTC_RGBA4"] = 19] = "PVRTC_RGBA4";
7930
- TextureFormat[TextureFormat[/** RGB(A) compressed format, 128 bits per 4x4 pixel block. */ "ASTC_4x4"] = 20] = "ASTC_4x4";
7931
- TextureFormat[TextureFormat[/** RGB(A) compressed format, 128 bits per 5x5 pixel block. */ "ASTC_5x5"] = 21] = "ASTC_5x5";
7932
- TextureFormat[TextureFormat[/** RGB(A) compressed format, 128 bits per 6x6 pixel block. */ "ASTC_6x6"] = 22] = "ASTC_6x6";
7933
- TextureFormat[TextureFormat[/** RGB(A) compressed format, 128 bits per 8x8 pixel block. */ "ASTC_8x8"] = 23] = "ASTC_8x8";
7934
- TextureFormat[TextureFormat[/** RGB(A) compressed format, 128 bits per 10x10 pixel block. */ "ASTC_10x10"] = 24] = "ASTC_10x10";
7935
- TextureFormat[TextureFormat[/** RGB(A) compressed format, 128 bits per 12x12 pixel block. */ "ASTC_12x12"] = 25] = "ASTC_12x12";
7936
- TextureFormat[TextureFormat[/** Automatic depth format, engine will automatically select the supported precision. */ "Depth"] = 26] = "Depth";
7937
- TextureFormat[TextureFormat[/** Automatic depth stencil format, engine will automatically select the supported precision. */ "DepthStencil"] = 27] = "DepthStencil";
7938
- TextureFormat[TextureFormat[/** 16-bit depth format. */ "Depth16"] = 28] = "Depth16";
7939
- TextureFormat[TextureFormat[/** 24-bit depth format. */ "Depth24"] = 29] = "Depth24";
7940
- TextureFormat[TextureFormat[/** 32-bit depth format. */ "Depth32"] = 30] = "Depth32";
7941
- TextureFormat[TextureFormat[/** 16-bit depth + 8-bit stencil format. */ "Depth24Stencil8"] = 31] = "Depth24Stencil8";
7942
- TextureFormat[TextureFormat[/** 32-bit depth + 8-bit stencil format. */ "Depth32Stencil8"] = 32] = "Depth32Stencil8";
7943
- TextureFormat[TextureFormat[/** @deprecated Use `TextureFormat.BC1` instead. */ "DXT1"] = 33] = "DXT1";
7944
- TextureFormat[TextureFormat[/** @deprecated Use `TextureFormat.BC3` instead. */ "DXT5"] = 34] = "DXT5";
7945
- })(TextureFormat || (TextureFormat = {}));
7946
-
7947
7646
  /**
7948
7647
  * Texture usage.
7949
7648
  */ var TextureUsage;
@@ -8127,7 +7826,7 @@ var /**
8127
7826
  _this._mipmapCount = _this._getMipmapCount();
8128
7827
  _this._isDepthTexture = format == TextureFormat.Depth || format == TextureFormat.DepthStencil || format == TextureFormat.Depth16 || format == TextureFormat.Depth24 || format == TextureFormat.Depth32 || format == TextureFormat.Depth24Stencil8 || format == TextureFormat.Depth32Stencil8;
8129
7828
  _this._platformTexture = engine._hardwareRenderer.createPlatformTexture2D(_assert_this_initialized(_this));
8130
- _this.filterMode = TextureFilterMode.Bilinear;
7829
+ _this.filterMode = _this._isIntFormat() ? TextureFilterMode.Point : TextureFilterMode.Bilinear;
8131
7830
  _this.wrapModeU = _this.wrapModeV = TextureWrapMode.Repeat;
8132
7831
  return _this;
8133
7832
  }
@@ -9438,7 +9137,7 @@ var /**
9438
9137
  };
9439
9138
  _proto._readColorVertexData = function _readColorVertexData(attributeType) {
9440
9139
  return this._readVertexData(attributeType, function(dataReader, offset) {
9441
- return new Color$1(dataReader[offset], dataReader[offset + 1], dataReader[offset + 2], dataReader[offset + 3]);
9140
+ return new Color(dataReader[offset], dataReader[offset + 1], dataReader[offset + 2], dataReader[offset + 3]);
9442
9141
  });
9443
9142
  };
9444
9143
  _proto._readVertexData = function _readVertexData(attributeType, onVertexParse) {
@@ -9926,6 +9625,10 @@ var VertexElementIndex;
9926
9625
  var sphereInfo = primitiveInfo;
9927
9626
  PrimitiveMesh._setSphereData(this.resource, sphereInfo.radius, sphereInfo.segments, sphereInfo.noLongerAccessible, true, sphereInfo.vertexBuffer);
9928
9627
  break;
9628
+ case 7:
9629
+ var CCSphereInfo = primitiveInfo;
9630
+ PrimitiveMesh._setSubdivisionSurfaceSphereData(this.resource, CCSphereInfo.radius, CCSphereInfo.step, CCSphereInfo.noLongerAccessible, true, CCSphereInfo.vertexBuffer);
9631
+ break;
9929
9632
  case 1:
9930
9633
  var cuboidInfo = primitiveInfo;
9931
9634
  PrimitiveMesh._setCuboidData(this.resource, cuboidInfo.width, cuboidInfo.height, cuboidInfo.depth, cuboidInfo.noLongerAccessible, true, cuboidInfo.vertexBuffer);
@@ -9963,6 +9666,7 @@ var PrimitiveType;
9963
9666
  PrimitiveType[PrimitiveType["Torus"] = 4] = "Torus";
9964
9667
  PrimitiveType[PrimitiveType["Cone"] = 5] = "Cone";
9965
9668
  PrimitiveType[PrimitiveType["Capsule"] = 6] = "Capsule";
9669
+ PrimitiveType[PrimitiveType["CCSphere"] = 7] = "CCSphere";
9966
9670
  })(PrimitiveType || (PrimitiveType = {}));
9967
9671
  /**
9968
9672
  * @internal
@@ -9984,6 +9688,19 @@ var PrimitiveType;
9984
9688
  }
9985
9689
  return SphereRestoreInfo;
9986
9690
  }(PrimitiveRestoreInfo);
9691
+ /**
9692
+ * @internal
9693
+ */ var SubdivisionSurfaceSphereRestoreInfo = /*#__PURE__*/ function(PrimitiveRestoreInfo) {
9694
+ _inherits(SubdivisionSurfaceSphereRestoreInfo, PrimitiveRestoreInfo);
9695
+ function SubdivisionSurfaceSphereRestoreInfo(radius, step, vertexBuffer, noLongerAccessible) {
9696
+ var _this;
9697
+ _this = PrimitiveRestoreInfo.call(this, 7, vertexBuffer, noLongerAccessible) || this;
9698
+ _this.radius = radius;
9699
+ _this.step = step;
9700
+ return _this;
9701
+ }
9702
+ return SubdivisionSurfaceSphereRestoreInfo;
9703
+ }(PrimitiveRestoreInfo);
9987
9704
  /**
9988
9705
  * @internal
9989
9706
  */ var CuboidRestoreInfo = /*#__PURE__*/ function(PrimitiveRestoreInfo) {
@@ -10098,6 +9815,24 @@ var PrimitiveType;
10098
9815
  return sphereMesh;
10099
9816
  };
10100
9817
  /**
9818
+ * Create a sphere mesh by implementing Catmull-Clark Surface Subdivision Algorithm.
9819
+ * Max step is limited to 6.
9820
+ * @param engine - Engine
9821
+ * @param radius - Sphere radius
9822
+ * @param step - Number of subdiv steps
9823
+ * @param noLongerAccessible - No longer access the vertices of the mesh after creation
9824
+ * @returns Sphere model mesh
9825
+ */ PrimitiveMesh.createSubdivisionSurfaceSphere = function createSubdivisionSurfaceSphere(engine, radius, step, noLongerAccessible) {
9826
+ if (radius === void 0) radius = 0.5;
9827
+ if (step === void 0) step = 3;
9828
+ if (noLongerAccessible === void 0) noLongerAccessible = true;
9829
+ var sphereMesh = new ModelMesh(engine);
9830
+ PrimitiveMesh._setSubdivisionSurfaceSphereData(sphereMesh, radius, step, noLongerAccessible, false);
9831
+ var vertexBuffer = sphereMesh.vertexBufferBindings[0].buffer;
9832
+ engine.resourceManager.addContentRestorer(new PrimitiveMeshRestorer(sphereMesh, new SubdivisionSurfaceSphereRestoreInfo(radius, step, vertexBuffer, noLongerAccessible)));
9833
+ return sphereMesh;
9834
+ };
9835
+ /**
10101
9836
  * Create a cuboid mesh.
10102
9837
  * @param engine - Engine
10103
9838
  * @param width - Cuboid width
@@ -10227,6 +9962,90 @@ var PrimitiveType;
10227
9962
  };
10228
9963
  /**
10229
9964
  * @internal
9965
+ */ PrimitiveMesh._setSubdivisionSurfaceSphereData = function _setSubdivisionSurfaceSphereData(sphereMesh, radius, step, noLongerAccessible, isRestoreMode, restoreVertexBuffer) {
9966
+ // Max step is limited to 6. Because 7 step will generate a single mesh with over 98306 vertices
9967
+ step = MathUtil.clamp(Math.floor(step), 1, 6);
9968
+ var positions = new Float32Array(3 * (6 * Math.pow(4, step) + 2));
9969
+ var cells = new Float32Array(24 * Math.pow(4, step));
9970
+ PrimitiveMesh._subdiveCatmullClark(step, positions, cells);
9971
+ var positionCount = positions.length / 3;
9972
+ var cellsCount = cells.length / 4;
9973
+ var poleOffset = positionCount + Math.pow(2, step + 1) - 1;
9974
+ // 16 extra vertices for pole uv
9975
+ // 2 vertices at each pole are idle
9976
+ var vertexCount = poleOffset + 16;
9977
+ var vertices = new Float32Array(vertexCount * 8);
9978
+ var indices = PrimitiveMesh._generateIndices(sphereMesh.engine, positionCount, cellsCount * 6);
9979
+ var seamCount = 0;
9980
+ var seamVertices = {};
9981
+ // Get normals, uvs, and scale to radius
9982
+ for(var i = 0; i < positionCount; i++){
9983
+ var offset = 3 * i;
9984
+ var x = positions[offset];
9985
+ var y = positions[offset + 1];
9986
+ var z = positions[offset + 2];
9987
+ var reciprocalLength = 1 / Math.sqrt(x * x + y * y + z * z);
9988
+ x *= reciprocalLength;
9989
+ y *= reciprocalLength;
9990
+ z *= reciprocalLength;
9991
+ offset = 8 * i;
9992
+ vertices[offset] = x * radius;
9993
+ vertices[offset + 1] = y * radius;
9994
+ vertices[offset + 2] = z * radius;
9995
+ vertices[offset + 3] = x;
9996
+ vertices[offset + 4] = y;
9997
+ vertices[offset + 5] = z;
9998
+ vertices[offset + 6] = (Math.PI - Math.atan2(z, x)) / (2 * Math.PI);
9999
+ vertices[offset + 7] = Math.acos(y) / Math.PI;
10000
+ if (vertices[offset + 6] === 0) {
10001
+ // Generate seam vertex
10002
+ var seamOffset = 8 * (positionCount + seamCount++);
10003
+ vertices.set(vertices.subarray(offset, offset + 8), seamOffset);
10004
+ vertices[seamOffset + 6] = 1.0;
10005
+ // Cache seam vertex
10006
+ seamVertices[offset / 8] = seamOffset / 8;
10007
+ }
10008
+ }
10009
+ // Get indices
10010
+ var offset1 = 0;
10011
+ this._spherePoleIdx = 0;
10012
+ for(var i1 = 0; i1 < cellsCount; i1++){
10013
+ var idx = 4 * i1;
10014
+ var indexA = cells[idx];
10015
+ var indexB = cells[idx + 1];
10016
+ var indexC = cells[idx + 2];
10017
+ var indexD = cells[idx + 3];
10018
+ // Handle seam by replacing vertex index to seam vertex index if necessary
10019
+ var floatIndexA = 8 * indexA;
10020
+ var floatIndexB = 8 * indexB;
10021
+ var floatIndexC = 8 * indexC;
10022
+ var floatIndexD = 8 * indexD;
10023
+ // If center Z is negative
10024
+ if (vertices[floatIndexA + 2] + vertices[floatIndexB + 2] + vertices[floatIndexC + 2] < 0) {
10025
+ vertices[floatIndexA + 6] === 0 && (indexA = seamVertices[indexA]);
10026
+ vertices[floatIndexB + 6] === 0 && (indexB = seamVertices[indexB]);
10027
+ vertices[floatIndexC + 6] === 0 && (indexC = seamVertices[indexC]);
10028
+ vertices[floatIndexD + 6] === 0 && (indexD = seamVertices[indexD]);
10029
+ }
10030
+ indices[offset1] = indexA;
10031
+ indices[offset1 + 1] = indexB;
10032
+ indices[offset1 + 2] = indexC;
10033
+ this._generateAndReplacePoleUV(indices, vertices, offset1, poleOffset);
10034
+ indices[offset1 + 3] = indexA;
10035
+ indices[offset1 + 4] = indexC;
10036
+ indices[offset1 + 5] = indexD;
10037
+ this._generateAndReplacePoleUV(indices, vertices, offset1 + 3, poleOffset);
10038
+ offset1 += 6;
10039
+ }
10040
+ if (!isRestoreMode) {
10041
+ var bounds = sphereMesh.bounds;
10042
+ bounds.min.set(-radius, -radius, -radius);
10043
+ bounds.max.set(radius, radius, radius);
10044
+ }
10045
+ PrimitiveMesh._initialize(sphereMesh, vertices, indices, noLongerAccessible, isRestoreMode, restoreVertexBuffer);
10046
+ };
10047
+ /**
10048
+ * @internal
10230
10049
  */ PrimitiveMesh._setSphereData = function _setSphereData(sphereMesh, radius, segments, noLongerAccessible, isRestoreMode, restoreVertexBuffer) {
10231
10050
  segments = Math.max(2, Math.floor(segments));
10232
10051
  var count = segments + 1;
@@ -10287,6 +10106,135 @@ var PrimitiveType;
10287
10106
  };
10288
10107
  /**
10289
10108
  * @internal
10109
+ */ PrimitiveMesh._subdiveCatmullClark = function _subdiveCatmullClark(step, positions, cells) {
10110
+ var edges = new Map();
10111
+ var faces = new Array();
10112
+ positions.set(PrimitiveMesh._sphereSeedPositions);
10113
+ cells.set(PrimitiveMesh._sphereSeedCells);
10114
+ for(var i = 0; i < step; i++){
10115
+ var cellCount = 6 * Math.pow(4, i);
10116
+ var positionCount = 4 * cellCount + 2;
10117
+ edges.clear();
10118
+ faces.length = 0;
10119
+ // Get cell face's facePoint
10120
+ for(var j = 0; j < cellCount; j++){
10121
+ var face = faces[j] = {
10122
+ facePoint: new Vector3(),
10123
+ adjacentEdges: new Array(4)
10124
+ };
10125
+ // Get cell's edgePoint
10126
+ for(var k = 0; k < 4; k++){
10127
+ var offset = 3 * cells[4 * j + k];
10128
+ face.facePoint.x += 0.25 * positions[offset];
10129
+ face.facePoint.y += 0.25 * positions[offset + 1];
10130
+ face.facePoint.z += 0.25 * positions[offset + 2];
10131
+ }
10132
+ // Get cell edges
10133
+ for(var k1 = 0; k1 < 4; k1++){
10134
+ var vertexIdxA = cells[4 * j + k1];
10135
+ var vertexIdxB = cells[4 * j + (k1 + 1) % 4];
10136
+ var edgeIdxKey = Math.min(vertexIdxA, vertexIdxB) * positionCount + Math.max(vertexIdxA, vertexIdxB);
10137
+ if (!edges.has(edgeIdxKey)) {
10138
+ var edge = {
10139
+ edgePoint: new Vector3(),
10140
+ edgePointIndex: undefined
10141
+ };
10142
+ var offsetA = 3 * vertexIdxA;
10143
+ var offsetB = 3 * vertexIdxB;
10144
+ 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]));
10145
+ edges.set(edgeIdxKey, edge);
10146
+ }
10147
+ var edge1 = edges.get(edgeIdxKey);
10148
+ face.adjacentEdges[k1] = edge1;
10149
+ var edgePoint = edge1.edgePoint;
10150
+ var facePoint = face.facePoint;
10151
+ edgePoint.x += 0.25 * facePoint.x;
10152
+ edgePoint.y += 0.25 * facePoint.y;
10153
+ edgePoint.z += 0.25 * facePoint.z;
10154
+ }
10155
+ }
10156
+ var prePointCount = cellCount + 2;
10157
+ var edgePointOffset = prePointCount + cellCount;
10158
+ var pointIdx = 0;
10159
+ this._sphereEdgeIdx = 0;
10160
+ var preCells = cells.slice(0, 4 * cellCount);
10161
+ // Get New positions, which consists of updated positions of existing points, face points and edge points
10162
+ for(var j1 = 0; j1 < cellCount; j1++){
10163
+ // Add face point to new positions
10164
+ var face1 = faces[j1];
10165
+ face1.facePoint.copyToArray(positions, 3 * (prePointCount + j1));
10166
+ // Get the face point index
10167
+ var ic = prePointCount + j1;
10168
+ var id = void 0, ib = void 0, temp = void 0;
10169
+ // ia -- id -- ia
10170
+ // | | |
10171
+ // ib -- ic -- ib
10172
+ // | | |
10173
+ // ia -- id -- ia
10174
+ for(var k2 = 0; k2 < 4; k2++){
10175
+ // Get the updated existing point index
10176
+ var ia = preCells[pointIdx++];
10177
+ // ib and id share four edge points in one cell
10178
+ switch(k2){
10179
+ case 0:
10180
+ {
10181
+ var edgeB = face1.adjacentEdges[k2 % 4];
10182
+ var edgeD = face1.adjacentEdges[(k2 + 3) % 4];
10183
+ ib = this._calculateEdgeIndex(positions, edgeB, edgePointOffset);
10184
+ id = this._calculateEdgeIndex(positions, edgeD, edgePointOffset);
10185
+ temp = id;
10186
+ break;
10187
+ }
10188
+ case 1:
10189
+ case 2:
10190
+ {
10191
+ var edgeB1 = face1.adjacentEdges[k2 % 4];
10192
+ id = ib;
10193
+ ib = this._calculateEdgeIndex(positions, edgeB1, edgePointOffset);
10194
+ break;
10195
+ }
10196
+ case 3:
10197
+ {
10198
+ id = ib;
10199
+ ib = temp;
10200
+ break;
10201
+ }
10202
+ }
10203
+ var idx = 4 * (4 * j1 + k2);
10204
+ cells[idx] = ia;
10205
+ cells[idx + 1] = ib;
10206
+ cells[idx + 2] = ic;
10207
+ cells[idx + 3] = id;
10208
+ }
10209
+ }
10210
+ }
10211
+ };
10212
+ /**
10213
+ * Duplicate vertices at the poles and adjust their UV coordinates.
10214
+ */ PrimitiveMesh._generateAndReplacePoleUV = function _generateAndReplacePoleUV(indices, vertices, idx, poleOffset) {
10215
+ var v = vertices[8 * indices[idx] + 7];
10216
+ if (v === 0 || v === 1) {
10217
+ var offset = 8 * indices[idx];
10218
+ var addedOffset = 8 * (poleOffset + this._spherePoleIdx);
10219
+ vertices.set(vertices.subarray(offset, offset + 8), addedOffset);
10220
+ vertices[addedOffset + 6] = 0.5 * (vertices[offset + 6] + vertices[8 * indices[idx + 1] + 6] + vertices[8 * indices[idx + 2] + 6] - 0.5);
10221
+ indices[idx] = poleOffset + this._spherePoleIdx++;
10222
+ }
10223
+ };
10224
+ /**
10225
+ * Get edge point index for subdivision surface sphere.
10226
+ */ PrimitiveMesh._calculateEdgeIndex = function _calculateEdgeIndex(positions, edge, offset) {
10227
+ if (edge.edgePointIndex !== undefined) {
10228
+ return edge.edgePointIndex;
10229
+ } else {
10230
+ edge.edgePoint.copyToArray(positions, 3 * (offset + PrimitiveMesh._sphereEdgeIdx));
10231
+ var index = offset + PrimitiveMesh._sphereEdgeIdx++;
10232
+ edge.edgePointIndex = index;
10233
+ return index;
10234
+ }
10235
+ };
10236
+ /**
10237
+ * @internal
10290
10238
  */ PrimitiveMesh._setCuboidData = function _setCuboidData(cuboidMesh, width, height, depth, noLongerAccessible, isRestoreMode, restoreVertexBuffer) {
10291
10239
  var halfWidth = width / 2;
10292
10240
  var halfHeight = height / 2;
@@ -10688,7 +10636,7 @@ var PrimitiveType;
10688
10636
  var theta = thetaStart + u * thetaRange;
10689
10637
  var sinTheta = Math.sin(theta);
10690
10638
  var cosTheta = Math.cos(theta);
10691
- var curRadius = radius - y * radius;
10639
+ var curRadius = radius - v * radius;
10692
10640
  var posX = curRadius * sinTheta;
10693
10641
  var posY = y * unitHeight - halfHeight;
10694
10642
  var posZ = curRadius * cosTheta;
@@ -10822,8 +10770,8 @@ var PrimitiveType;
10822
10770
  indices[indicesOffset++] = d;
10823
10771
  indices[indicesOffset++] = c;
10824
10772
  }
10825
- PrimitiveMesh._createCapsuleCap(radius, height, radialSegments, thetaRange, torsoVertexCount, 1, vertices, indices, indicesOffset);
10826
- PrimitiveMesh._createCapsuleCap(radius, height, radialSegments, -thetaRange, torsoVertexCount + capVertexCount, -1, vertices, indices, indicesOffset + 6 * capRectangleCount);
10773
+ PrimitiveMesh._createCapsuleCap(radius, height, radialSegments, thetaStart, thetaRange, torsoVertexCount, 1, vertices, indices, indicesOffset);
10774
+ PrimitiveMesh._createCapsuleCap(radius, height, radialSegments, thetaStart, -thetaRange, torsoVertexCount + capVertexCount, -1, vertices, indices, indicesOffset + 6 * capRectangleCount);
10827
10775
  if (!isRestoreMode) {
10828
10776
  var bounds = capsuleMesh.bounds;
10829
10777
  bounds.min.set(-radius, -radius - halfHeight, -radius);
@@ -10864,7 +10812,7 @@ var PrimitiveType;
10864
10812
  }
10865
10813
  return indices;
10866
10814
  };
10867
- PrimitiveMesh._createCapsuleCap = function _createCapsuleCap(radius, height, radialSegments, capAlphaRange, offset, posIndex, vertices, indices, indicesOffset) {
10815
+ PrimitiveMesh._createCapsuleCap = function _createCapsuleCap(radius, height, radialSegments, thetaStart, thetaRange, offset, posIndex, vertices, indices, indicesOffset) {
10868
10816
  var radialCount = radialSegments + 1;
10869
10817
  var halfHeight = height * 0.5 * posIndex;
10870
10818
  var capVertexCount = radialCount * radialCount;
@@ -10877,12 +10825,12 @@ var PrimitiveType;
10877
10825
  var y = i * radialCountReciprocal | 0;
10878
10826
  var u = x * radialSegmentsReciprocal;
10879
10827
  var v = y * radialSegmentsReciprocal;
10880
- var alphaDelta = u * capAlphaRange;
10881
- var thetaDelta = v * Math.PI / 2;
10882
- var sinTheta = Math.sin(thetaDelta);
10883
- var posX = -radius * Math.cos(alphaDelta) * sinTheta;
10884
- var posY = radius * Math.cos(thetaDelta) * posIndex + halfHeight;
10885
- var posZ = radius * Math.sin(alphaDelta) * sinTheta;
10828
+ var theta = thetaStart + u * thetaRange;
10829
+ var alpha = v * Math.PI * 0.5;
10830
+ var sinAlpha = Math.sin(alpha);
10831
+ var posX = radius * Math.sin(theta) * sinAlpha;
10832
+ var posY = radius * Math.cos(alpha) * posIndex + halfHeight;
10833
+ var posZ = radius * Math.cos(theta) * sinAlpha;
10886
10834
  var index = (i + offset) * vertexFloatCount;
10887
10835
  // Position
10888
10836
  vertices[index++] = posX;
@@ -10916,29 +10864,91 @@ var PrimitiveType;
10916
10864
  (function() {
10917
10865
  PrimitiveMesh._tempVec30 = new Vector3();
10918
10866
  })();
10919
-
10920
- /**
10921
- * Mesh skin data, equal glTF skins define
10922
- */ var Skin = /*#__PURE__*/ function(EngineObject1) {
10923
- _inherits(Skin, EngineObject1);
10924
- function Skin(name) {
10925
- var _this;
10926
- _this = EngineObject1.call(this, null) || this;
10927
- _this.name = name;
10928
- _this._bones = [];
10929
- _this.inverseBindMatrices = []; // inverse bind matrix array
10930
- _this.joints = []; // joints name array, element type: string
10931
- _this.skeleton = "none"; // root bone name
10932
- return _this;
10933
- }
10934
- return Skin;
10935
- }(EngineObject);
10936
-
10937
- /**
10938
- * SkinnedMeshRenderer.
10939
- */ var SkinnedMeshRenderer = /*#__PURE__*/ function(MeshRenderer1) {
10940
- _inherits(SkinnedMeshRenderer, MeshRenderer1);
10941
- function SkinnedMeshRenderer(entity) {
10867
+ (function() {
10868
+ PrimitiveMesh._sphereSeedPositions = new Float32Array([
10869
+ -1,
10870
+ 1,
10871
+ 1,
10872
+ -1,
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
+ ]);
10894
+ })();
10895
+ (function() {
10896
+ PrimitiveMesh._sphereSeedCells = new Float32Array([
10897
+ 0,
10898
+ 1,
10899
+ 2,
10900
+ 3,
10901
+ 3,
10902
+ 2,
10903
+ 4,
10904
+ 5,
10905
+ 5,
10906
+ 4,
10907
+ 6,
10908
+ 7,
10909
+ 7,
10910
+ 0,
10911
+ 3,
10912
+ 5,
10913
+ 7,
10914
+ 6,
10915
+ 1,
10916
+ 0,
10917
+ 6,
10918
+ 4,
10919
+ 2,
10920
+ 1
10921
+ ]);
10922
+ })();
10923
+ (function() {
10924
+ PrimitiveMesh._sphereEdgeIdx = 0;
10925
+ })();
10926
+ (function() {
10927
+ PrimitiveMesh._spherePoleIdx = 0;
10928
+ })();
10929
+
10930
+ /**
10931
+ * Mesh skin data, equal glTF skins define
10932
+ */ var Skin = /*#__PURE__*/ function(EngineObject1) {
10933
+ _inherits(Skin, EngineObject1);
10934
+ function Skin(name) {
10935
+ var _this;
10936
+ _this = EngineObject1.call(this, null) || this;
10937
+ _this.name = name;
10938
+ _this._bones = [];
10939
+ _this.inverseBindMatrices = []; // inverse bind matrix array
10940
+ _this.joints = []; // joints name array, element type: string
10941
+ _this.skeleton = "none"; // root bone name
10942
+ return _this;
10943
+ }
10944
+ return Skin;
10945
+ }(EngineObject);
10946
+
10947
+ /**
10948
+ * SkinnedMeshRenderer.
10949
+ */ var SkinnedMeshRenderer = /*#__PURE__*/ function(MeshRenderer1) {
10950
+ _inherits(SkinnedMeshRenderer, MeshRenderer1);
10951
+ function SkinnedMeshRenderer(entity) {
10942
10952
  var _this;
10943
10953
  _this = MeshRenderer1.call(this, entity) || this;
10944
10954
  _this._localBounds = new BoundingBox();
@@ -11379,7 +11389,9 @@ var Basic2DBatcher = /*#__PURE__*/ function() {
11379
11389
  this._batchedQueue = null;
11380
11390
  var _this = this, meshes = _this._meshes, vertexBuffers = _this._vertexBuffers, indiceBuffers = _this._indiceBuffers;
11381
11391
  for(var i = 0, n = meshes.length; i < n; ++i){
11382
- meshes[i].destroy();
11392
+ var mesh = meshes[i];
11393
+ mesh._addReferCount(-1);
11394
+ mesh.destroy();
11383
11395
  }
11384
11396
  this._meshes = null;
11385
11397
  for(var i1 = 0, n1 = vertexBuffers.length; i1 < n1; ++i1){
@@ -11402,7 +11414,7 @@ var Basic2DBatcher = /*#__PURE__*/ function() {
11402
11414
  _proto._createMesh = function _createMesh(engine, index) {
11403
11415
  var MAX_VERTEX_COUNT = Basic2DBatcher.MAX_VERTEX_COUNT;
11404
11416
  var mesh = new BufferMesh(engine, "BufferMesh" + index);
11405
- mesh.isGCIgnored = true;
11417
+ mesh._addReferCount(1);
11406
11418
  var vertexElements = [];
11407
11419
  var vertexStride = this.createVertexElements(vertexElements);
11408
11420
  // vertices
@@ -11460,8 +11472,10 @@ var Basic2DBatcher = /*#__PURE__*/ function() {
11460
11472
  }
11461
11473
  mesh.addSubMesh(this._getSubMeshFromPool(vertexStartIndex, vertexCount));
11462
11474
  batchedQueue[curMeshIndex] = preElement;
11463
- this._vertexBuffers[_flushId].setData(vertices, 0, 0, vertexIndex);
11464
- this._indiceBuffers[_flushId].setData(indices, 0, 0, indiceIndex);
11475
+ // Set data option use Discard, or will resulted in performance slowdown when open antialias and cross-rendering of 3D and 2D elements.
11476
+ // Device: iphone X(16.7.2)、iphone 15 pro max(17.1.1)、iphone XR(17.1.2) etc.
11477
+ this._vertexBuffers[_flushId].setData(vertices, 0, 0, vertexIndex, SetDataOptions.Discard);
11478
+ this._indiceBuffers[_flushId].setData(indices, 0, 0, indiceIndex, SetDataOptions.Discard);
11465
11479
  };
11466
11480
  _proto._getSubMeshFromPool = function _getSubMeshFromPool(start, count) {
11467
11481
  var subMesh = this._subMeshPool.getFromPool();
@@ -11608,7 +11622,7 @@ var TiledSpriteAssembler = (_TiledSpriteAssembler = /*#__PURE__*/ function() {
11608
11622
  rVertCount = 3;
11609
11623
  rType = 0;
11610
11624
  } else {
11611
- if (fixedCW > MathUtil$1.zeroTolerance) {
11625
+ if (fixedCW > MathUtil.zeroTolerance) {
11612
11626
  rRepeatCount = (width - fixedLR) / fixedCW;
11613
11627
  rRepeatCount = rRepeatCount % 1 >= threshold ? Math.ceil(rRepeatCount) : Math.floor(rRepeatCount);
11614
11628
  rVertCount = 4 + rRepeatCount - 1;
@@ -11622,7 +11636,7 @@ var TiledSpriteAssembler = (_TiledSpriteAssembler = /*#__PURE__*/ function() {
11622
11636
  cVertCount = 3;
11623
11637
  cType = 0;
11624
11638
  } else {
11625
- if (fixedCH > MathUtil$1.zeroTolerance) {
11639
+ if (fixedCH > MathUtil.zeroTolerance) {
11626
11640
  cRepeatCount = (height - fixedTB) / fixedCH;
11627
11641
  cRepeatCount = cRepeatCount % 1 >= threshold ? Math.ceil(cRepeatCount) : Math.floor(cRepeatCount);
11628
11642
  cVertCount = 4 + cRepeatCount - 1;
@@ -11713,7 +11727,7 @@ var TiledSpriteAssembler = (_TiledSpriteAssembler = /*#__PURE__*/ function() {
11713
11727
  rVertCount = 3;
11714
11728
  rType = 0;
11715
11729
  } else {
11716
- if (fixedCW > MathUtil$1.zeroTolerance) {
11730
+ if (fixedCW > MathUtil.zeroTolerance) {
11717
11731
  rRepeatCount = (width - fixedLR) / fixedCW;
11718
11732
  rVertCount = 4 + (rRepeatCount | 0);
11719
11733
  rType = 2;
@@ -11726,7 +11740,7 @@ var TiledSpriteAssembler = (_TiledSpriteAssembler = /*#__PURE__*/ function() {
11726
11740
  cVertCount = 3;
11727
11741
  cType = 0;
11728
11742
  } else {
11729
- if (fixedCH > MathUtil$1.zeroTolerance) {
11743
+ if (fixedCH > MathUtil.zeroTolerance) {
11730
11744
  cRepeatCount = (height - fixedTB) / fixedCH;
11731
11745
  cVertCount = 4 + (cRepeatCount | 0);
11732
11746
  cType = 2;
@@ -11839,7 +11853,7 @@ var TiledType;
11839
11853
  _this = Renderer1.call(this, entity) || this;
11840
11854
  _this._tileMode = SpriteTileMode.Continuous;
11841
11855
  _this._tiledAdaptiveThreshold = 0.5;
11842
- _this._color = new Color$1(1, 1, 1, 1);
11856
+ _this._color = new Color(1, 1, 1, 1);
11843
11857
  _this._sprite = null;
11844
11858
  _this._automaticWidth = 0;
11845
11859
  _this._automaticHeight = 0;
@@ -12039,7 +12053,7 @@ var TiledType;
12039
12053
  },
12040
12054
  set: function set(value) {
12041
12055
  if (value !== this._tiledAdaptiveThreshold) {
12042
- value = MathUtil$1.clamp(value, 0, 1);
12056
+ value = MathUtil.clamp(value, 0, 1);
12043
12057
  this._tiledAdaptiveThreshold = value;
12044
12058
  if (this.drawMode === SpriteDrawMode.Tiled) {
12045
12059
  this._dirtyUpdateFlag |= 0x3;
@@ -12491,6 +12505,9 @@ var /**
12491
12505
  __decorate([
12492
12506
  assignmentClone
12493
12507
  ], SpriteMask.prototype, "influenceLayers", void 0);
12508
+ __decorate([
12509
+ ignoreClone
12510
+ ], SpriteMask.prototype, "_verticesData", void 0);
12494
12511
  __decorate([
12495
12512
  ignoreClone
12496
12513
  ], SpriteMask.prototype, "_sprite", void 0);
@@ -12774,8 +12791,8 @@ var /**
12774
12791
  } else {
12775
12792
  word += char;
12776
12793
  wordWidth += charInfo.xAdvance;
12777
- wordMaxAscent = lineMaxAscent = Math.max(wordMaxAscent, ascent);
12778
- wordMaxDescent = lineMaxDescent = Math.max(wordMaxDescent, descent);
12794
+ wordMaxAscent = Math.max(wordMaxAscent, ascent);
12795
+ wordMaxDescent = Math.max(wordMaxDescent, descent);
12779
12796
  }
12780
12797
  }
12781
12798
  }
@@ -12896,6 +12913,9 @@ var /**
12896
12913
  var baseline = Math.ceil(context.measureText(TextUtils._measureBaseline).width);
12897
12914
  var height = baseline * TextUtils._heightMultiplier;
12898
12915
  baseline = TextUtils._baselineMultiplier * baseline | 0;
12916
+ var _extendHeight = TextUtils._extendHeight;
12917
+ height += _extendHeight;
12918
+ baseline += _extendHeight * 0.5;
12899
12919
  canvas.width = width;
12900
12920
  canvas.height = height;
12901
12921
  context.font = fontString;
@@ -12930,6 +12950,7 @@ var /**
12930
12950
  }
12931
12951
  if (top !== -1 && bottom !== -1) {
12932
12952
  ascent = baseline - top;
12953
+ // Baseline belong to descent
12933
12954
  descent = bottom - baseline + 1;
12934
12955
  size = ascent + descent;
12935
12956
  }
@@ -13005,6 +13026,10 @@ var /**
13005
13026
  "fangsong"
13006
13027
  ];
13007
13028
  })();
13029
+ (function() {
13030
+ // _extendHeight used to extend the height of canvas, because in miniprogram performance is different from h5.
13031
+ /** @internal */ TextUtils._extendHeight = 0;
13032
+ })();
13008
13033
  (function() {
13009
13034
  /** These characters are all tall to help calculate the height required for text. */ TextUtils._measureString = "|\xc9q\xc5";
13010
13035
  })();
@@ -13095,7 +13120,8 @@ var /**
13095
13120
  _proto._createFontAtlas = function _createFontAtlas() {
13096
13121
  var _this = this, engine = _this._engine;
13097
13122
  var fontAtlas = new FontAtlas(engine);
13098
- var texture = new Texture2D(engine, 256, 256);
13123
+ var texture = new Texture2D(engine, 256, 256, TextureFormat.R8G8B8A8, false);
13124
+ texture.filterMode = TextureFilterMode.Bilinear;
13099
13125
  fontAtlas.texture = texture;
13100
13126
  fontAtlas.isGCIgnored = texture.isGCIgnored = true;
13101
13127
  this._fontAtlases.push(fontAtlas);
@@ -13253,7 +13279,7 @@ var /**
13253
13279
  /** @internal */ _this._subFont = null;
13254
13280
  /** @internal */ _this._charRenderDatas = [];
13255
13281
  _this._dirtyFlag = 15;
13256
- _this._color = new Color$1(1, 1, 1, 1);
13282
+ _this._color = new Color(1, 1, 1, 1);
13257
13283
  _this._text = "";
13258
13284
  _this._width = 0;
13259
13285
  _this._height = 0;
@@ -13333,7 +13359,7 @@ var /**
13333
13359
  /**
13334
13360
  * @internal
13335
13361
  */ _proto._render = function _render(context) {
13336
- if (this._text === "" || this.enableWrapping && this.width <= 0 || this.overflowMode === OverflowMode.Truncate && this.height <= 0) {
13362
+ if (this._isTextNoVisible()) {
13337
13363
  return;
13338
13364
  }
13339
13365
  if (this._isContainDirtyFlag(0x10)) {
@@ -13425,8 +13451,8 @@ var /**
13425
13451
  }
13426
13452
  };
13427
13453
  _proto._updateLocalData = function _updateLocalData() {
13428
- var _this = this, color = _this.color, charRenderDatas = _this._charRenderDatas, charFont = _this._subFont;
13429
13454
  var _this__localBounds = this._localBounds, min = _this__localBounds.min, max = _this__localBounds.max;
13455
+ var _this = this, color = _this.color, charRenderDatas = _this._charRenderDatas, charFont = _this._subFont;
13430
13456
  var textMetrics = this.enableWrapping ? TextUtils.measureTextWithWrap(this) : TextUtils.measureTextWithoutWrap(this);
13431
13457
  var height = textMetrics.height, lines = textMetrics.lines, lineWidths = textMetrics.lineWidths, lineHeight = textMetrics.lineHeight, lineMaxSizes = textMetrics.lineMaxSizes;
13432
13458
  var charRenderDataPool = TextRenderer._charRenderDataPool;
@@ -13494,7 +13520,7 @@ var /**
13494
13520
  var left = startX * pixelsPerUnitReciprocal;
13495
13521
  var right = (startX + w) * pixelsPerUnitReciprocal;
13496
13522
  var top = (startY + ascent) * pixelsPerUnitReciprocal;
13497
- var bottom = (startY - descent + 1) * pixelsPerUnitReciprocal;
13523
+ var bottom = (startY - descent) * pixelsPerUnitReciprocal;
13498
13524
  localPositions.set(left, top, right, bottom);
13499
13525
  i === firstLine && (maxY = Math.max(maxY, top));
13500
13526
  minY = Math.min(minY, bottom);
@@ -13535,6 +13561,9 @@ var /**
13535
13561
  Renderer1.prototype._onTransformChanged.call(this, bit);
13536
13562
  this._setDirtyFlagTrue(0x4 | 0x8);
13537
13563
  };
13564
+ _proto._isTextNoVisible = function _isTextNoVisible() {
13565
+ return this._text === "" || this._fontSize === 0 || this.enableWrapping && this.width <= 0 || this.overflowMode === OverflowMode.Truncate && this.height <= 0;
13566
+ };
13538
13567
  _create_class(TextRenderer, [
13539
13568
  {
13540
13569
  key: "color",
@@ -13737,6 +13766,16 @@ var /**
13737
13766
  get: /**
13738
13767
  * The bounding volume of the TextRenderer.
13739
13768
  */ function get() {
13769
+ if (this._isTextNoVisible()) {
13770
+ if (this._isContainDirtyFlag(0x8)) {
13771
+ var localBounds = this._localBounds;
13772
+ localBounds.min.set(0, 0, 0);
13773
+ localBounds.max.set(0, 0, 0);
13774
+ this._updateBounds(this._bounds);
13775
+ this._setDirtyFlagFalse(0x8);
13776
+ }
13777
+ return this._bounds;
13778
+ }
13740
13779
  this._isContainDirtyFlag(0x1) && this._resetSubFont();
13741
13780
  this._isContainDirtyFlag(0x2) && this._updateLocalData();
13742
13781
  this._isContainDirtyFlag(0x4) && this._updatePosition();
@@ -14758,6 +14797,7 @@ var TextRenderData = /*#__PURE__*/ function(RenderData1) {
14758
14797
  AssetType[/** Cube Compress Texture. */ "KTXCube"] = "KTXCube";
14759
14798
  AssetType[/** KTX2 Compress Texture */ "KTX2"] = "KTX2";
14760
14799
  AssetType[/** Sprite. */ "Sprite"] = "Sprite";
14800
+ AssetType[/** PrimitiveMesh. */ "PrimitiveMesh"] = "PrimitiveMesh";
14761
14801
  AssetType[/** Sprite Atlas. */ "SpriteAtlas"] = "SpriteAtlas";
14762
14802
  AssetType[/** Ambient light. */ "Env"] = "Environment";
14763
14803
  AssetType[/** Scene. */ "Scene"] = "Scene";
@@ -15143,6 +15183,7 @@ var /** @internal */ PromiseState;
15143
15183
  this./** The number of retries after failing to load assets. */ retryCount = 1;
15144
15184
  this./** Retry delay time after failed to load assets, in milliseconds. */ retryInterval = 0;
15145
15185
  this./** The default timeout period for loading assets, in milliseconds. */ timeout = Infinity;
15186
+ this./** Base url for loading assets. */ baseUrl = null;
15146
15187
  this._loadingPromises = {};
15147
15188
  this._assetPool = Object.create(null);
15148
15189
  this._assetUrlPool = Object.create(null);
@@ -15346,6 +15387,8 @@ var /** @internal */ PromiseState;
15346
15387
  // Check url mapping
15347
15388
  var itemURL = item.url;
15348
15389
  var url = this._virtualPathMap[itemURL] ? this._virtualPathMap[itemURL] : itemURL;
15390
+ // Not absolute and base url is set
15391
+ if (!Utils.isAbsoluteUrl(url) && this.baseUrl) url = Utils.resolveAbsoluteUrl(this.baseUrl, url);
15349
15392
  // Parse url
15350
15393
  var _this__parseURL = this._parseURL(url), assetBaseURL = _this__parseURL.assetBaseURL, queryPath = _this__parseURL.queryPath;
15351
15394
  var paths = queryPath ? this._parseQueryPath(queryPath) : [];
@@ -15438,10 +15481,20 @@ var /** @internal */ PromiseState;
15438
15481
  };
15439
15482
  _proto._parseURL = function _parseURL(path) {
15440
15483
  var _path_split = path.split("?"), baseUrl = _path_split[0], searchStr = _path_split[1];
15441
- var searchParams = new URLSearchParams(searchStr);
15442
- var queryPath = searchParams.get("q");
15443
- searchParams.delete("q");
15444
- var assetBaseURL = searchParams.size > 0 ? baseUrl + "?" + searchParams.toString() : baseUrl;
15484
+ var queryPath = undefined;
15485
+ var assetBaseURL = baseUrl;
15486
+ if (searchStr) {
15487
+ var params = searchStr.split("&");
15488
+ for(var i = 0; i < params.length; i++){
15489
+ var param = params[i];
15490
+ if (param.startsWith("q=")) {
15491
+ queryPath = decodeURIComponent(param.split("=")[1]);
15492
+ params.splice(i, 1);
15493
+ break;
15494
+ }
15495
+ }
15496
+ assetBaseURL = params.length > 0 ? baseUrl + "?" + params.join("&") : baseUrl;
15497
+ }
15445
15498
  return {
15446
15499
  assetBaseURL: assetBaseURL,
15447
15500
  queryPath: queryPath
@@ -15725,6 +15778,66 @@ var rePropName = RegExp(// Match anything that isn't a dot or bracket.
15725
15778
  }
15726
15779
  }
15727
15780
  };
15781
+ /**
15782
+ * @internal
15783
+ */ SystemInfo._detectSIMDSupported = function _detectSIMDSupported() {
15784
+ if (this._simdSupported === null) {
15785
+ this._simdSupported = WebAssembly.validate(new Uint8Array([
15786
+ 0,
15787
+ 97,
15788
+ 115,
15789
+ 109,
15790
+ 1,
15791
+ 0,
15792
+ 0,
15793
+ 0,
15794
+ 1,
15795
+ 4,
15796
+ 1,
15797
+ 96,
15798
+ 0,
15799
+ 0,
15800
+ 3,
15801
+ 3,
15802
+ 2,
15803
+ 0,
15804
+ 0,
15805
+ 5,
15806
+ 3,
15807
+ 1,
15808
+ 0,
15809
+ 1,
15810
+ 12,
15811
+ 1,
15812
+ 0,
15813
+ 10,
15814
+ 22,
15815
+ 2,
15816
+ 12,
15817
+ 0,
15818
+ 65,
15819
+ 0,
15820
+ 65,
15821
+ 0,
15822
+ 65,
15823
+ 0,
15824
+ 252,
15825
+ 10,
15826
+ 0,
15827
+ 0,
15828
+ 11,
15829
+ 7,
15830
+ 0,
15831
+ 65,
15832
+ 0,
15833
+ 253,
15834
+ 15,
15835
+ 26,
15836
+ 11
15837
+ ]));
15838
+ }
15839
+ return this._simdSupported;
15840
+ };
15728
15841
  _create_class(SystemInfo, null, [
15729
15842
  {
15730
15843
  key: "devicePixelRatio",
@@ -15743,6 +15856,9 @@ var rePropName = RegExp(// Match anything that isn't a dot or bracket.
15743
15856
  (function() {
15744
15857
  /** The operating system is running on. */ SystemInfo.operatingSystem = "";
15745
15858
  })();
15859
+ (function() {
15860
+ /** Whether the system support SIMD. */ SystemInfo._simdSupported = null;
15861
+ })();
15746
15862
  SystemInfo._initialize();
15747
15863
 
15748
15864
  /**
@@ -15973,7 +16089,7 @@ SystemInfo._initialize();
15973
16089
  * Keyboard Manager.
15974
16090
  * @internal
15975
16091
  */ var KeyboardManager = /*#__PURE__*/ function() {
15976
- function KeyboardManager(engine) {
16092
+ function KeyboardManager(engine, target) {
15977
16093
  /** @internal */ this._curHeldDownKeyToIndexMap = [];
15978
16094
  /** @internal */ this._upKeyToFrameCountMap = [];
15979
16095
  /** @internal */ this._downKeyToFrameCountMap = [];
@@ -15981,17 +16097,11 @@ SystemInfo._initialize();
15981
16097
  /** @internal */ this._curFrameDownList = new DisorderedArray();
15982
16098
  /** @internal */ this._curFrameUpList = new DisorderedArray();
15983
16099
  this._nativeEvents = [];
15984
- this._hadListener = false;
15985
- // @ts-ignore
15986
- var htmlCanvas = engine._canvas._webCanvas;
15987
16100
  this._engine = engine;
15988
- this._htmlCanvas = htmlCanvas;
15989
- // Need to set tabIndex to make the canvas focus.
15990
- htmlCanvas.tabIndex = htmlCanvas.tabIndex;
16101
+ this._onBlur = this._onBlur.bind(this);
15991
16102
  this._onKeyEvent = this._onKeyEvent.bind(this);
15992
- htmlCanvas.addEventListener("keydown", this._onKeyEvent);
15993
- htmlCanvas.addEventListener("keyup", this._onKeyEvent);
15994
- this._hadListener = true;
16103
+ this._target = target;
16104
+ this._addEventListener();
15995
16105
  }
15996
16106
  var _proto = KeyboardManager.prototype;
15997
16107
  /**
@@ -16043,35 +16153,8 @@ SystemInfo._initialize();
16043
16153
  };
16044
16154
  /**
16045
16155
  * @internal
16046
- */ _proto._onFocus = function _onFocus() {
16047
- if (!this._hadListener) {
16048
- this._htmlCanvas.addEventListener("keydown", this._onKeyEvent);
16049
- this._htmlCanvas.addEventListener("keyup", this._onKeyEvent);
16050
- this._hadListener = true;
16051
- }
16052
- };
16053
- /**
16054
- * @internal
16055
- */ _proto._onBlur = function _onBlur() {
16056
- if (this._hadListener) {
16057
- this._htmlCanvas.removeEventListener("keydown", this._onKeyEvent);
16058
- this._htmlCanvas.removeEventListener("keyup", this._onKeyEvent);
16059
- this._curHeldDownKeyToIndexMap.length = 0;
16060
- this._curFrameHeldDownList.length = 0;
16061
- this._curFrameDownList.length = 0;
16062
- this._curFrameUpList.length = 0;
16063
- this._nativeEvents.length = 0;
16064
- this._hadListener = false;
16065
- }
16066
- };
16067
- /**
16068
- * @internal
16069
16156
  */ _proto._destroy = function _destroy() {
16070
- if (this._hadListener) {
16071
- this._htmlCanvas.removeEventListener("keydown", this._onKeyEvent);
16072
- this._htmlCanvas.removeEventListener("keyup", this._onKeyEvent);
16073
- this._hadListener = false;
16074
- }
16157
+ this._removeEventListener();
16075
16158
  this._curHeldDownKeyToIndexMap.length = 0;
16076
16159
  this._curHeldDownKeyToIndexMap = null;
16077
16160
  this._upKeyToFrameCountMap.length = 0;
@@ -16086,12 +16169,30 @@ SystemInfo._initialize();
16086
16169
  this._curFrameDownList = null;
16087
16170
  this._curFrameUpList.length = 0;
16088
16171
  this._curFrameUpList = null;
16089
- this._htmlCanvas = null;
16090
16172
  this._engine = null;
16091
16173
  };
16174
+ _proto._onBlur = function _onBlur() {
16175
+ this._curHeldDownKeyToIndexMap.length = 0;
16176
+ this._curFrameHeldDownList.length = 0;
16177
+ this._curFrameDownList.length = 0;
16178
+ this._curFrameUpList.length = 0;
16179
+ this._nativeEvents.length = 0;
16180
+ };
16092
16181
  _proto._onKeyEvent = function _onKeyEvent(evt) {
16093
16182
  this._nativeEvents.push(evt);
16094
16183
  };
16184
+ _proto._addEventListener = function _addEventListener() {
16185
+ var _this = this, target = _this._target;
16186
+ target.addEventListener("keydown", this._onKeyEvent);
16187
+ target.addEventListener("keyup", this._onKeyEvent);
16188
+ target.addEventListener("blur", this._onBlur);
16189
+ };
16190
+ _proto._removeEventListener = function _removeEventListener() {
16191
+ var _this = this, target = _this._target;
16192
+ target.removeEventListener("keydown", this._onKeyEvent);
16193
+ target.removeEventListener("keyup", this._onKeyEvent);
16194
+ target.removeEventListener("blur", this._onBlur);
16195
+ };
16095
16196
  return KeyboardManager;
16096
16197
  }();
16097
16198
 
@@ -16394,7 +16495,9 @@ var Collision = function Collision() {
16394
16495
  };
16395
16496
  if (hitResult != undefined) {
16396
16497
  var result = this._nativePhysicsScene.raycast(ray, distance, onRaycast, function(idx, distance, position, normal) {
16397
- hitResult.entity = _this._scene.engine._physicalObjectsMap[idx]._collider.entity;
16498
+ var hitShape = _this._scene.engine._physicalObjectsMap[idx];
16499
+ hitResult.entity = hitShape._collider.entity;
16500
+ hitResult.shape = hitShape;
16398
16501
  hitResult.distance = distance;
16399
16502
  hitResult.normal.copyFrom(normal);
16400
16503
  hitResult.point.copyFrom(position);
@@ -16403,6 +16506,7 @@ var Collision = function Collision() {
16403
16506
  return true;
16404
16507
  } else {
16405
16508
  hitResult.entity = null;
16509
+ hitResult.shape = null;
16406
16510
  hitResult.distance = 0;
16407
16511
  hitResult.point.set(0, 0, 0);
16408
16512
  hitResult.normal.set(0, 0, 0);
@@ -16533,7 +16637,7 @@ var Collision = function Collision() {
16533
16637
  return this._fixedTimeStep;
16534
16638
  },
16535
16639
  set: function set(value) {
16536
- this._fixedTimeStep = Math.max(value, MathUtil$1.zeroTolerance);
16640
+ this._fixedTimeStep = Math.max(value, MathUtil.zeroTolerance);
16537
16641
  }
16538
16642
  }
16539
16643
  ]);
@@ -17064,6 +17168,7 @@ var DynamicColliderConstraints;
17064
17168
  /** The distance from the ray's origin to the impact point. */ this.distance = 0;
17065
17169
  /** The impact point in world space where the ray hit the collider. */ this.point = new Vector3();
17066
17170
  /** The normal of the surface the ray hit. */ this.normal = new Vector3();
17171
+ /** The shape of the collider that was hit. */ this.shape = null;
17067
17172
  };
17068
17173
 
17069
17174
  /**
@@ -18055,7 +18160,7 @@ __decorate([
18055
18160
  * Pointer Manager.
18056
18161
  * @internal
18057
18162
  */ var PointerManager = /*#__PURE__*/ function() {
18058
- function PointerManager(engine) {
18163
+ function PointerManager(engine, target) {
18059
18164
  /** @internal */ this._pointers = [];
18060
18165
  /** @internal */ this._multiPointerEnabled = true;
18061
18166
  /** @internal */ this._buttons = PointerButton.None;
@@ -18064,16 +18169,18 @@ __decorate([
18064
18169
  /** @internal */ this._upList = new DisorderedArray();
18065
18170
  /** @internal */ this._downList = new DisorderedArray();
18066
18171
  this._nativeEvents = [];
18067
- this._hadListener = false;
18068
- // @ts-ignore
18069
- var htmlCanvas = engine._canvas._webCanvas;
18172
+ if (_instanceof(target, Window)) {
18173
+ throw "Do not set window as target because window cannot listen to pointer leave event.";
18174
+ }
18070
18175
  this._engine = engine;
18176
+ this._target = target;
18071
18177
  this._canvas = engine.canvas;
18072
- this._htmlCanvas = htmlCanvas;
18073
- this._onPointerEvent = this._onPointerEvent.bind(this);
18074
- this._onFocus();
18178
+ // @ts-ignore
18179
+ this._htmlCanvas = engine._canvas._webCanvas;
18075
18180
  // If there are no compatibility issues, navigator.maxTouchPoints should be used here
18076
18181
  this._pointerPool = new Array(11);
18182
+ this._onPointerEvent = this._onPointerEvent.bind(this);
18183
+ this._addEventListener();
18077
18184
  }
18078
18185
  var _proto = PointerManager.prototype;
18079
18186
  /**
@@ -18143,7 +18250,8 @@ __decorate([
18143
18250
  var length = events.length;
18144
18251
  if (length > 0) {
18145
18252
  for(var i1 = 0; i1 < length; i1++){
18146
- switch(events[i1].type){
18253
+ var event = events[i1];
18254
+ switch(event.type){
18147
18255
  case "pointerdown":
18148
18256
  pointer.phase = PointerPhase.Down;
18149
18257
  pointer._firePointerDown(rayCastEntity);
@@ -18165,66 +18273,14 @@ __decorate([
18165
18273
  };
18166
18274
  /**
18167
18275
  * @internal
18168
- */ _proto._onFocus = function _onFocus() {
18169
- if (!this._hadListener) {
18170
- var _this = this, htmlCanvas = _this._htmlCanvas, onPointerEvent = _this._onPointerEvent;
18171
- htmlCanvas.addEventListener("pointerdown", onPointerEvent);
18172
- htmlCanvas.addEventListener("pointerup", onPointerEvent);
18173
- htmlCanvas.addEventListener("pointerleave", onPointerEvent);
18174
- htmlCanvas.addEventListener("pointermove", onPointerEvent);
18175
- htmlCanvas.addEventListener("pointercancel", onPointerEvent);
18176
- this._hadListener = true;
18177
- }
18178
- };
18179
- /**
18180
- * @internal
18181
- */ _proto._onBlur = function _onBlur() {
18182
- if (this._hadListener) {
18183
- var _this = this, htmlCanvas = _this._htmlCanvas, onPointerEvent = _this._onPointerEvent;
18184
- htmlCanvas.removeEventListener("pointerdown", onPointerEvent);
18185
- htmlCanvas.removeEventListener("pointerup", onPointerEvent);
18186
- htmlCanvas.removeEventListener("pointerleave", onPointerEvent);
18187
- htmlCanvas.removeEventListener("pointermove", onPointerEvent);
18188
- htmlCanvas.removeEventListener("pointercancel", onPointerEvent);
18189
- this._hadListener = false;
18190
- this._pointers.length = 0;
18191
- this._downList.length = 0;
18192
- this._upList.length = 0;
18193
- }
18194
- };
18195
- /**
18196
- * @internal
18197
18276
  */ _proto._destroy = function _destroy() {
18198
- // @ts-ignore
18199
- if (this._hadListener) {
18200
- var _this = this, htmlCanvas = _this._htmlCanvas, onPointerEvent = _this._onPointerEvent;
18201
- htmlCanvas.removeEventListener("pointerdown", onPointerEvent);
18202
- htmlCanvas.removeEventListener("pointerup", onPointerEvent);
18203
- htmlCanvas.removeEventListener("pointerleave", onPointerEvent);
18204
- htmlCanvas.removeEventListener("pointermove", onPointerEvent);
18205
- htmlCanvas.removeEventListener("pointercancel", onPointerEvent);
18206
- this._hadListener = false;
18207
- }
18277
+ this._removeEventListener();
18208
18278
  this._pointerPool.length = 0;
18209
- this._pointerPool = null;
18210
- this._pointers.length = 0;
18211
- this._pointers = null;
18212
- this._downList.length = 0;
18213
- this._downList = null;
18214
- this._upList.length = 0;
18215
- this._upList = null;
18216
18279
  this._nativeEvents.length = 0;
18217
- this._nativeEvents = null;
18218
- this._upMap.length = 0;
18219
- this._upMap = null;
18220
18280
  this._downMap.length = 0;
18221
- this._downMap = null;
18222
- this._htmlCanvas = null;
18223
- this._canvas = null;
18224
- this._engine = null;
18281
+ this._upMap.length = 0;
18225
18282
  };
18226
18283
  _proto._onPointerEvent = function _onPointerEvent(evt) {
18227
- evt.type === "pointerdown" && this._htmlCanvas.focus();
18228
18284
  this._nativeEvents.push(evt);
18229
18285
  };
18230
18286
  _proto._getPointerByID = function _getPointerByID(pointerId) {
@@ -18307,6 +18363,26 @@ __decorate([
18307
18363
  }
18308
18364
  return null;
18309
18365
  };
18366
+ _proto._addEventListener = function _addEventListener() {
18367
+ var _this = this, target = _this._target, onPointerEvent = _this._onPointerEvent;
18368
+ target.addEventListener("pointerdown", onPointerEvent);
18369
+ target.addEventListener("pointerup", onPointerEvent);
18370
+ target.addEventListener("pointerleave", onPointerEvent);
18371
+ target.addEventListener("pointermove", onPointerEvent);
18372
+ target.addEventListener("pointercancel", onPointerEvent);
18373
+ };
18374
+ _proto._removeEventListener = function _removeEventListener() {
18375
+ var _this = this, target = _this._target, onPointerEvent = _this._onPointerEvent;
18376
+ target.removeEventListener("pointerdown", onPointerEvent);
18377
+ target.removeEventListener("pointerup", onPointerEvent);
18378
+ target.removeEventListener("pointerleave", onPointerEvent);
18379
+ target.removeEventListener("pointermove", onPointerEvent);
18380
+ target.removeEventListener("pointercancel", onPointerEvent);
18381
+ this._nativeEvents.length = 0;
18382
+ this._pointers.length = 0;
18383
+ this._downList.length = 0;
18384
+ this._upList.length = 0;
18385
+ };
18310
18386
  return PointerManager;
18311
18387
  }();
18312
18388
  (function() {
@@ -18323,15 +18399,12 @@ __decorate([
18323
18399
  * Wheel Manager.
18324
18400
  * @internal
18325
18401
  */ var WheelManager = /*#__PURE__*/ function() {
18326
- function WheelManager(engine) {
18402
+ function WheelManager(engine, target) {
18327
18403
  /** @internal */ this._delta = new Vector3();
18328
18404
  this._nativeEvents = [];
18329
- // @ts-ignore
18330
- var htmlCanvas = engine._canvas._webCanvas;
18331
18405
  this._onWheelEvent = this._onWheelEvent.bind(this);
18332
- htmlCanvas.addEventListener("wheel", this._onWheelEvent);
18333
- this._canvas = htmlCanvas;
18334
- this._hadListener = true;
18406
+ this._target = target;
18407
+ this._addEventListener();
18335
18408
  }
18336
18409
  var _proto = WheelManager.prototype;
18337
18410
  /**
@@ -18352,35 +18425,24 @@ __decorate([
18352
18425
  };
18353
18426
  /**
18354
18427
  * @internal
18355
- */ _proto._onFocus = function _onFocus() {
18356
- if (!this._hadListener) {
18357
- this._canvas.addEventListener("wheel", this._onWheelEvent);
18358
- this._hadListener = true;
18359
- }
18428
+ */ _proto._addEventListener = function _addEventListener() {
18429
+ this._target.addEventListener("wheel", this._onWheelEvent);
18360
18430
  };
18361
18431
  /**
18362
18432
  * @internal
18363
- */ _proto._onBlur = function _onBlur() {
18364
- if (this._hadListener) {
18365
- this._canvas.removeEventListener("wheel", this._onWheelEvent);
18366
- this._nativeEvents.length = 0;
18367
- this._delta.set(0, 0, 0);
18368
- this._hadListener = false;
18369
- }
18433
+ */ _proto._removeEventListener = function _removeEventListener() {
18434
+ this._target.removeEventListener("wheel", this._onWheelEvent);
18435
+ this._nativeEvents.length = 0;
18436
+ this._delta.set(0, 0, 0);
18370
18437
  };
18371
18438
  /**
18372
18439
  * @internal
18373
18440
  */ _proto._destroy = function _destroy() {
18374
- if (this._hadListener) {
18375
- this._canvas.removeEventListener("wheel", this._onWheelEvent);
18376
- this._hadListener = false;
18377
- }
18441
+ this._removeEventListener();
18378
18442
  this._nativeEvents = null;
18379
- this._canvas = null;
18380
18443
  this._delta = null;
18381
18444
  };
18382
18445
  _proto._onWheelEvent = function _onWheelEvent(evt) {
18383
- evt.cancelable && evt.preventDefault();
18384
18446
  this._nativeEvents.push(evt);
18385
18447
  };
18386
18448
  return WheelManager;
@@ -18389,19 +18451,19 @@ __decorate([
18389
18451
  /**
18390
18452
  * InputManager manages device input such as mouse, touch, keyboard, etc.
18391
18453
  */ var InputManager = /*#__PURE__*/ function() {
18392
- function InputManager(engine) {
18454
+ function InputManager(engine, inputOptions) {
18393
18455
  /** Sometimes the input module will not be initialized, such as off-screen rendering. */ this._initialized = false;
18394
18456
  this._engine = engine;
18395
18457
  // @ts-ignore
18396
18458
  var canvas = engine._canvas._webCanvas;
18397
18459
  if (typeof OffscreenCanvas === "undefined" || !_instanceof(canvas, OffscreenCanvas)) {
18398
- this._wheelManager = new WheelManager(engine);
18399
- this._pointerManager = new PointerManager(engine);
18400
- this._keyboardManager = new KeyboardManager(engine);
18401
- this._onBlur = this._onBlur.bind(this);
18402
- window.addEventListener("blur", this._onBlur);
18403
- this._onFocus = this._onFocus.bind(this);
18404
- window.addEventListener("focus", this._onFocus);
18460
+ var _inputOptions, _inputOptions1, _inputOptions2;
18461
+ var _inputOptions_wheelTarget;
18462
+ this._wheelManager = new WheelManager(engine, (_inputOptions_wheelTarget = (_inputOptions = inputOptions) == null ? void 0 : _inputOptions.wheelTarget) != null ? _inputOptions_wheelTarget : canvas);
18463
+ var _inputOptions_pointerTarget;
18464
+ this._pointerManager = new PointerManager(engine, (_inputOptions_pointerTarget = (_inputOptions1 = inputOptions) == null ? void 0 : _inputOptions1.pointerTarget) != null ? _inputOptions_pointerTarget : canvas);
18465
+ var _inputOptions_keyboardTarget;
18466
+ this._keyboardManager = new KeyboardManager(engine, (_inputOptions_keyboardTarget = (_inputOptions2 = inputOptions) == null ? void 0 : _inputOptions2.keyboardTarget) != null ? _inputOptions_keyboardTarget : window);
18405
18467
  this._initialized = true;
18406
18468
  }
18407
18469
  }
@@ -18514,8 +18576,6 @@ __decorate([
18514
18576
  * @internal
18515
18577
  */ _proto._destroy = function _destroy() {
18516
18578
  if (this._initialized) {
18517
- window.removeEventListener("blur", this._onBlur);
18518
- window.removeEventListener("focus", this._onFocus);
18519
18579
  this._wheelManager._destroy();
18520
18580
  this._wheelManager = null;
18521
18581
  this._pointerManager._destroy();
@@ -18524,16 +18584,6 @@ __decorate([
18524
18584
  this._keyboardManager = null;
18525
18585
  }
18526
18586
  };
18527
- _proto._onBlur = function _onBlur() {
18528
- this._wheelManager._onBlur();
18529
- this._pointerManager._onBlur();
18530
- this._keyboardManager._onBlur();
18531
- };
18532
- _proto._onFocus = function _onFocus() {
18533
- this._wheelManager._onFocus();
18534
- this._pointerManager._onFocus();
18535
- this._keyboardManager._onFocus();
18536
- };
18537
18587
  _create_class(InputManager, [
18538
18588
  {
18539
18589
  key: "pointers",
@@ -18576,6 +18626,8 @@ __decorate([
18576
18626
  _this = ReferResource1.call(this, engine) || this;
18577
18627
  /** @internal */ _this._renderStates = [] // todo: later will as a part of shaderData when shader effect frame is OK, that is more powerful and flexible.
18578
18628
  ;
18629
+ /** @internal */ _this._priority = 0 // todo: temporary resolution of submesh rendering order issue.
18630
+ ;
18579
18631
  _this._shaderData = new ShaderData(ShaderDataGroup.Material);
18580
18632
  _this.shader = shader;
18581
18633
  return _this;
@@ -18910,8 +18962,9 @@ var unlitVs = "#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#in
18910
18962
  }
18911
18963
  return;
18912
18964
  }
18965
+ ++hierarchy;
18913
18966
  for(var k1 in cacheMap){
18914
- this._recursiveDestroy(++hierarchy, cacheMap[k1]);
18967
+ this._recursiveDestroy(hierarchy, cacheMap[k1]);
18915
18968
  }
18916
18969
  };
18917
18970
  _proto._resizeCacheMapHierarchy = function _resizeCacheMapHierarchy(cacheMap, hierarchy, currentHierarchy, increaseHierarchy) {
@@ -19029,7 +19082,7 @@ ShaderPool.init();
19029
19082
  _this._spriteMaskDefaultMaterial = _this._createSpriteMaskMaterial();
19030
19083
  _this._textDefaultFont = Font.createFromOS(_assert_this_initialized(_this), "Arial");
19031
19084
  _this._textDefaultFont.isGCIgnored = true;
19032
- _this.inputManager = new InputManager(_assert_this_initialized(_this));
19085
+ _this.inputManager = new InputManager(_assert_this_initialized(_this), configuration.input);
19033
19086
  var xrDevice = configuration.xrDevice;
19034
19087
  if (xrDevice) {
19035
19088
  _this.xrManager = new XRManager();
@@ -19323,6 +19376,26 @@ ShaderPool.init();
19323
19376
  this._magentaTexture2D = magentaTexture2D;
19324
19377
  this._magentaTextureCube = magentaTextureCube;
19325
19378
  if (hardwareRenderer.isWebGL2) {
19379
+ var magentaPixel32 = new Uint32Array([
19380
+ 255,
19381
+ 0,
19382
+ 255,
19383
+ 255
19384
+ ]);
19385
+ var uintMagentaTexture2D = new Texture2D(this, 1, 1, TextureFormat.R32G32B32A32_UInt, false);
19386
+ uintMagentaTexture2D.setPixelBuffer(magentaPixel32);
19387
+ uintMagentaTexture2D.isGCIgnored = true;
19388
+ this.resourceManager.addContentRestorer(new /*#__PURE__*/ (function(ContentRestorer) {
19389
+ _inherits(_class, ContentRestorer);
19390
+ function _class() {
19391
+ return ContentRestorer.call(this, uintMagentaTexture2D);
19392
+ }
19393
+ var _proto = _class.prototype;
19394
+ _proto.restoreContent = function restoreContent() {
19395
+ this.resource.setPixelBuffer(magentaPixel32);
19396
+ };
19397
+ return _class;
19398
+ }(ContentRestorer))());
19326
19399
  var magentaTexture2DArray = new Texture2DArray(this, 1, 1, 1, TextureFormat.R8G8B8A8, false);
19327
19400
  magentaTexture2DArray.setPixelBuffer(0, magentaPixel);
19328
19401
  magentaTexture2DArray.isGCIgnored = true;
@@ -19337,6 +19410,7 @@ ShaderPool.init();
19337
19410
  };
19338
19411
  return _class;
19339
19412
  }(ContentRestorer))());
19413
+ this._uintMagentaTexture2D = uintMagentaTexture2D;
19340
19414
  this._magentaTexture2DArray = magentaTexture2DArray;
19341
19415
  }
19342
19416
  };
@@ -19569,8 +19643,8 @@ ShaderPool.init();
19569
19643
  set: function set(value) {
19570
19644
  if (this._width !== value) {
19571
19645
  this._width = value;
19646
+ this._onWidthChanged(value);
19572
19647
  this._sizeUpdateFlagManager.dispatch();
19573
- this._onSizeChanged(value, this._width);
19574
19648
  }
19575
19649
  }
19576
19650
  },
@@ -19584,8 +19658,8 @@ ShaderPool.init();
19584
19658
  set: function set(value) {
19585
19659
  if (this._height !== value) {
19586
19660
  this._height = value;
19661
+ this._onHeightChange(value);
19587
19662
  this._sizeUpdateFlagManager.dispatch();
19588
- this._onSizeChanged(this._width, value);
19589
19663
  }
19590
19664
  }
19591
19665
  }
@@ -19652,7 +19726,7 @@ ShaderPool.init();
19652
19726
  var e = viewProjMatrix.elements;
19653
19727
  e[12] = e[13] = e[14] = 0;
19654
19728
  // epsilon-infinity projection matrix http://terathon.com/gdc07_lengyel.pdf
19655
- var f = 1.0 / Math.tan(MathUtil$1.degreeToRadian(fieldOfView) / 2);
19729
+ var f = 1.0 / Math.tan(MathUtil.degreeToRadian(fieldOfView) / 2);
19656
19730
  projectionMatrix.elements[0] = f / aspectRatio;
19657
19731
  projectionMatrix.elements[5] = f;
19658
19732
  // view-proj matrix
@@ -19733,7 +19807,7 @@ ShaderPool.init();
19733
19807
  * Background solid color.
19734
19808
  * @defaultValue `new Color(0.25, 0.25, 0.25, 1.0)`
19735
19809
  * @remarks When `mode` is `BackgroundMode.SolidColor`, the property will take effects.
19736
- */ solidColor = new Color$1(0.25, 0.25, 0.25, 1.0);
19810
+ */ solidColor = new Color(0.25, 0.25, 0.25, 1.0);
19737
19811
  this.sky = new Sky();
19738
19812
  this./** @internal */ _textureFillMode = BackgroundTextureFillMode.AspectFitHeight;
19739
19813
  this._texture = null;
@@ -20094,7 +20168,7 @@ ShaderPool.init();
20094
20168
  function AmbientLight(engine) {
20095
20169
  var _this;
20096
20170
  _this = ReferResource1.call(this, engine) || this;
20097
- _this._diffuseSolidColor = new Color$1(0.212, 0.227, 0.259);
20171
+ _this._diffuseSolidColor = new Color(0.212, 0.227, 0.259);
20098
20172
  _this._diffuseIntensity = 1.0;
20099
20173
  _this._specularIntensity = 1.0;
20100
20174
  _this._diffuseMode = DiffuseMode.SolidColor;
@@ -20391,8 +20465,8 @@ ShaderPool.init();
20391
20465
  /** Near plane value to use for shadow frustums. */ _this.shadowNearPlane = 0.1;
20392
20466
  /** Shadow intensity, the larger the value, the clearer and darker the shadow. */ _this.shadowStrength = 1.0;
20393
20467
  /** @internal */ _this._lightIndex = -1;
20394
- /** @internal */ _this._lightColor = new Color$1();
20395
- _this._color = new Color$1(1, 1, 1, 1);
20468
+ /** @internal */ _this._lightColor = new Color();
20469
+ _this._color = new Color(1, 1, 1, 1);
20396
20470
  return _this;
20397
20471
  }
20398
20472
  var _proto = Light.prototype;
@@ -20470,9 +20544,9 @@ __decorate([
20470
20544
  data.cullingMask[cullingMaskStart] = cullingMask & 65535;
20471
20545
  data.cullingMask[cullingMaskStart + 1] = cullingMask >>> 16 & 65535;
20472
20546
  if (this.engine.settings.colorSpace === ColorSpace.Linear) {
20473
- data.color[colorStart] = Color$1.gammaToLinearSpace(lightColor.r);
20474
- data.color[colorStart + 1] = Color$1.gammaToLinearSpace(lightColor.g);
20475
- data.color[colorStart + 2] = Color$1.gammaToLinearSpace(lightColor.b);
20547
+ data.color[colorStart] = Color.gammaToLinearSpace(lightColor.r);
20548
+ data.color[colorStart + 1] = Color.gammaToLinearSpace(lightColor.g);
20549
+ data.color[colorStart + 2] = Color.gammaToLinearSpace(lightColor.b);
20476
20550
  } else {
20477
20551
  data.color[colorStart] = lightColor.r;
20478
20552
  data.color[colorStart + 1] = lightColor.g;
@@ -20562,9 +20636,9 @@ __decorate([
20562
20636
  data.cullingMask[cullingMaskStart] = cullingMask & 65535;
20563
20637
  data.cullingMask[cullingMaskStart + 1] = cullingMask >>> 16 & 65535;
20564
20638
  if (this.engine.settings.colorSpace === ColorSpace.Linear) {
20565
- data.color[colorStart] = Color$1.gammaToLinearSpace(lightColor.r);
20566
- data.color[colorStart + 1] = Color$1.gammaToLinearSpace(lightColor.g);
20567
- data.color[colorStart + 2] = Color$1.gammaToLinearSpace(lightColor.b);
20639
+ data.color[colorStart] = Color.gammaToLinearSpace(lightColor.r);
20640
+ data.color[colorStart + 1] = Color.gammaToLinearSpace(lightColor.g);
20641
+ data.color[colorStart + 2] = Color.gammaToLinearSpace(lightColor.b);
20568
20642
  } else {
20569
20643
  data.color[colorStart] = lightColor.r;
20570
20644
  data.color[colorStart + 1] = lightColor.g;
@@ -20658,9 +20732,9 @@ __decorate([
20658
20732
  data.cullingMask[cullingMaskStart] = cullingMask & 65535;
20659
20733
  data.cullingMask[cullingMaskStart + 1] = cullingMask >>> 16 & 65535;
20660
20734
  if (this.engine.settings.colorSpace === ColorSpace.Linear) {
20661
- data.color[colorStart] = Color$1.gammaToLinearSpace(lightColor.r);
20662
- data.color[colorStart + 1] = Color$1.gammaToLinearSpace(lightColor.g);
20663
- data.color[colorStart + 2] = Color$1.gammaToLinearSpace(lightColor.b);
20735
+ data.color[colorStart] = Color.gammaToLinearSpace(lightColor.r);
20736
+ data.color[colorStart + 1] = Color.gammaToLinearSpace(lightColor.g);
20737
+ data.color[colorStart + 2] = Color.gammaToLinearSpace(lightColor.b);
20664
20738
  } else {
20665
20739
  data.color[colorStart] = lightColor.r;
20666
20740
  data.color[colorStart + 1] = lightColor.g;
@@ -20940,6 +21014,10 @@ __decorate([
20940
21014
  /** The splits of two cascade distribution. */ _this.shadowTwoCascadeSplits = 1.0 / 3.0;
20941
21015
  /** The splits of four cascade distribution. */ _this.shadowFourCascadeSplits = new Vector3(1.0 / 15, 3.0 / 15.0, 7.0 / 15.0);
20942
21016
  /** Max Shadow distance. */ _this.shadowDistance = 50;
21017
+ /**
21018
+ * Last shadow fade distance in percentage, range [0,1].
21019
+ * @remarks Value 0 is used for no shadow fade.
21020
+ */ _this.shadowFadeBorder = 0.1;
20943
21021
  /* @internal */ _this._lightManager = new LightManager();
20944
21022
  /* @internal */ _this._componentsManager = new ComponentsManager();
20945
21023
  /** @internal */ _this._isActiveInEngine = false;
@@ -20949,7 +21027,7 @@ __decorate([
20949
21027
  _this._shaderData = new ShaderData(ShaderDataGroup.Scene);
20950
21028
  _this._shadowCascades = ShadowCascadesMode.NoCascades;
20951
21029
  _this._fogMode = FogMode.None;
20952
- _this._fogColor = new Color$1(0.5, 0.5, 0.5, 1.0);
21030
+ _this._fogColor = new Color(0.5, 0.5, 0.5, 1.0);
20953
21031
  _this._fogStart = 0;
20954
21032
  _this._fogEnd = 300;
20955
21033
  _this._fogDensity = 0.01;
@@ -21564,47 +21642,66 @@ __decorate([
21564
21642
  DepthTextureMode[DepthTextureMode[/* Generate depth texture by pre-pass rendering. */ "PrePass"] = 1] = "PrePass";
21565
21643
  })(DepthTextureMode || (DepthTextureMode = {}));
21566
21644
 
21567
- var passNum = 0;
21568
21645
  /**
21569
- * RenderPass.
21570
- */ var RenderPass = /*#__PURE__*/ function() {
21571
- function RenderPass(name, priority, renderTarget, replaceMaterial, mask) {
21572
- if (name === void 0) name = "RENDER_PASS" + passNum++;
21573
- if (priority === void 0) priority = 0;
21574
- if (renderTarget === void 0) renderTarget = null;
21575
- if (replaceMaterial === void 0) replaceMaterial = null;
21576
- if (mask === void 0) mask = null;
21577
- this.name = name;
21578
- this.enabled = true;
21579
- this.priority = priority;
21580
- this.renderTarget = renderTarget;
21581
- this.replaceMaterial = replaceMaterial;
21582
- this.mask = mask || Layer.Everything;
21583
- this.renderOverride = false; // If renderOverride is set to true, you need to implement the render method
21584
- }
21585
- var _proto = RenderPass.prototype;
21586
- /**
21587
- * Rendering callback, will be executed if renderOverride is set to true.
21588
- * @param camera - Camera
21589
- * @param opaqueQueue - Opaque queue
21590
- * @param alphaTestQueue - Alpha test queue
21591
- * @param transparentQueue - Transparent queue
21592
- */ _proto.render = function render(camera, opaqueQueue, alphaTestQueue, transparentQueue) {};
21646
+ * PipelinePass is a base class for all pipeline passes.
21647
+ */ var PipelinePass = function PipelinePass(engine) {
21648
+ this._engine = engine;
21649
+ };
21650
+
21651
+ /**
21652
+ * @internal
21653
+ */ var PipelineUtils = /*#__PURE__*/ function() {
21654
+ function PipelineUtils() {}
21593
21655
  /**
21594
- * Post rendering callback.
21595
- * @param camera - Camera
21596
- * @param opaqueQueue - Opaque queue
21597
- * @param alphaTestQueue - Alpha test queue
21598
- * @param transparentQueue - Transparent queue
21599
- */ _proto.preRender = function preRender(camera, opaqueQueue, alphaTestQueue, transparentQueue) {};
21656
+ * Recreate texture if needed.
21657
+ * @param engine - Engine
21658
+ * @param currentTexture - Current texture
21659
+ * @param width - Need texture width
21660
+ * @param height - Need texture height
21661
+ * @param format - Need texture format
21662
+ * @param mipmap - Need texture mipmap
21663
+ * @returns Texture
21664
+ */ PipelineUtils.recreateTextureIfNeeded = function recreateTextureIfNeeded(engine, currentTexture, width, height, format, mipmap) {
21665
+ if (currentTexture) {
21666
+ if (currentTexture.width !== width || currentTexture.height !== height || currentTexture.format !== format || currentTexture.mipmapCount > 1 !== mipmap) {
21667
+ currentTexture.destroy();
21668
+ var texture = new Texture2D(engine, width, height, format, mipmap);
21669
+ texture.isGCIgnored = true;
21670
+ return texture;
21671
+ } else {
21672
+ return currentTexture;
21673
+ }
21674
+ } else {
21675
+ var texture1 = new Texture2D(engine, width, height, format, mipmap);
21676
+ texture1.isGCIgnored = true;
21677
+ return texture1;
21678
+ }
21679
+ };
21600
21680
  /**
21601
- * Post rendering callback.
21602
- * @param camera - Camera
21603
- * @param opaqueQueue - Opaque queue
21604
- * @param alphaTestQueue - Alpha test queue
21605
- * @param transparentQueue - Transparent queue
21606
- */ _proto.postRender = function postRender(camera, opaqueQueue, alphaTestQueue, transparentQueue) {};
21607
- return RenderPass;
21681
+ * Recreate render target if needed.
21682
+ * @param engine - Engine
21683
+ * @param currentRenderTarget - Current render target
21684
+ * @param width - Need render target width
21685
+ * @param height - Need render target height
21686
+ * @param colorFormat - Need render target color format
21687
+ * @param depthFormat - Need render target depth format
21688
+ * @param mipmap - Need render target mipmap
21689
+ * @returns Render target
21690
+ */ PipelineUtils.recreateRenderTargetIfNeeded = function recreateRenderTargetIfNeeded(engine, currentRenderTarget, width, height, colorFormat, depthFormat, mipmap) {
21691
+ var _currentRenderTarget, _currentRenderTarget1;
21692
+ var currentColorTexture = (_currentRenderTarget = currentRenderTarget) == null ? void 0 : _currentRenderTarget.getColorTexture(0);
21693
+ var currentDepthTexture = (_currentRenderTarget1 = currentRenderTarget) == null ? void 0 : _currentRenderTarget1.depthTexture;
21694
+ var colorTexture = colorFormat ? PipelineUtils.recreateTextureIfNeeded(engine, currentColorTexture, width, height, colorFormat, mipmap) : null;
21695
+ var depthTexture = depthFormat ? PipelineUtils.recreateTextureIfNeeded(engine, currentDepthTexture, width, height, depthFormat, mipmap) : null;
21696
+ if (currentColorTexture !== colorTexture || currentDepthTexture !== depthTexture) {
21697
+ var _currentRenderTarget2;
21698
+ (_currentRenderTarget2 = currentRenderTarget) == null ? void 0 : _currentRenderTarget2.destroy();
21699
+ currentRenderTarget = new RenderTarget(engine, width, height, colorTexture, depthTexture);
21700
+ currentRenderTarget.isGCIgnored = true;
21701
+ }
21702
+ return currentRenderTarget;
21703
+ };
21704
+ return PipelineUtils;
21608
21705
  }();
21609
21706
 
21610
21707
  /**
@@ -21865,70 +21962,93 @@ var passNum = 0;
21865
21962
  /**
21866
21963
  * @internal
21867
21964
  */ RenderQueue._compareFromNearToFar = function _compareFromNearToFar(a, b) {
21868
- return a.data.component.priority - b.data.component.priority || a.data.component._distanceForSort - b.data.component._distanceForSort;
21965
+ var dataA = a.data;
21966
+ var dataB = b.data;
21967
+ var componentA = dataA.component;
21968
+ var componentB = dataB.component;
21969
+ var priorityOrder = componentA.priority - componentB.priority;
21970
+ if (priorityOrder !== 0) {
21971
+ return priorityOrder;
21972
+ }
21973
+ // make suer from the same renderer.
21974
+ if (componentA.instanceId === componentB.instanceId) {
21975
+ return dataA.material._priority - dataB.material._priority;
21976
+ } else {
21977
+ var distanceDiff = componentA._distanceForSort - componentB._distanceForSort;
21978
+ if (distanceDiff === 0) {
21979
+ return componentA.instanceId - componentB.instanceId;
21980
+ } else {
21981
+ return distanceDiff;
21982
+ }
21983
+ }
21869
21984
  };
21870
21985
  /**
21871
21986
  * @internal
21872
21987
  */ RenderQueue._compareFromFarToNear = function _compareFromFarToNear(a, b) {
21873
- return a.data.component.priority - b.data.component.priority || b.data.component._distanceForSort - a.data.component._distanceForSort;
21988
+ var dataA = a.data;
21989
+ var dataB = b.data;
21990
+ var componentA = dataA.component;
21991
+ var componentB = dataB.component;
21992
+ var priorityOrder = componentA.priority - componentB.priority;
21993
+ if (priorityOrder !== 0) {
21994
+ return priorityOrder;
21995
+ }
21996
+ // make suer from the same renderer.
21997
+ if (componentA.instanceId === componentB.instanceId) {
21998
+ return dataA.material._priority - dataB.material._priority;
21999
+ } else {
22000
+ var distanceDiff = componentB._distanceForSort - componentA._distanceForSort;
22001
+ if (distanceDiff === 0) {
22002
+ return componentA.instanceId - componentB.instanceId;
22003
+ } else {
22004
+ return distanceDiff;
22005
+ }
22006
+ }
21874
22007
  };
21875
22008
  return RenderQueue;
21876
22009
  }();
21877
22010
 
22011
+ var passNum = 0;
21878
22012
  /**
21879
- * @internal
21880
- */ var PipelineUtils = /*#__PURE__*/ function() {
21881
- function PipelineUtils() {}
22013
+ * RenderPass.
22014
+ */ var RenderPass = /*#__PURE__*/ function() {
22015
+ function RenderPass(name, priority, renderTarget, replaceMaterial, mask) {
22016
+ if (name === void 0) name = "RENDER_PASS" + passNum++;
22017
+ if (priority === void 0) priority = 0;
22018
+ if (renderTarget === void 0) renderTarget = null;
22019
+ if (replaceMaterial === void 0) replaceMaterial = null;
22020
+ if (mask === void 0) mask = null;
22021
+ this.name = name;
22022
+ this.enabled = true;
22023
+ this.priority = priority;
22024
+ this.renderTarget = renderTarget;
22025
+ this.replaceMaterial = replaceMaterial;
22026
+ this.mask = mask || Layer.Everything;
22027
+ this.renderOverride = false; // If renderOverride is set to true, you need to implement the render method
22028
+ }
22029
+ var _proto = RenderPass.prototype;
21882
22030
  /**
21883
- * Recreate texture if needed.
21884
- * @param engine - Engine
21885
- * @param currentTexture - Current texture
21886
- * @param width - Need texture width
21887
- * @param height - Need texture height
21888
- * @param format - Need texture format
21889
- * @param mipmap - Need texture mipmap
21890
- * @returns Texture
21891
- */ PipelineUtils.recreateTextureIfNeeded = function recreateTextureIfNeeded(engine, currentTexture, width, height, format, mipmap) {
21892
- if (currentTexture) {
21893
- if (currentTexture.width !== width || currentTexture.height !== height || currentTexture.format !== format || currentTexture.mipmapCount > 1 !== mipmap) {
21894
- currentTexture.destroy();
21895
- var texture = new Texture2D(engine, width, height, format, mipmap);
21896
- texture.isGCIgnored = true;
21897
- return texture;
21898
- } else {
21899
- return currentTexture;
21900
- }
21901
- } else {
21902
- var texture1 = new Texture2D(engine, width, height, format, mipmap);
21903
- texture1.isGCIgnored = true;
21904
- return texture1;
21905
- }
21906
- };
22031
+ * Rendering callback, will be executed if renderOverride is set to true.
22032
+ * @param camera - Camera
22033
+ * @param opaqueQueue - Opaque queue
22034
+ * @param alphaTestQueue - Alpha test queue
22035
+ * @param transparentQueue - Transparent queue
22036
+ */ _proto.render = function render(camera, opaqueQueue, alphaTestQueue, transparentQueue) {};
21907
22037
  /**
21908
- * Recreate render target if needed.
21909
- * @param engine - Engine
21910
- * @param currentRenderTarget - Current render target
21911
- * @param width - Need render target width
21912
- * @param height - Need render target height
21913
- * @param colorFormat - Need render target color format
21914
- * @param depthFormat - Need render target depth format
21915
- * @param mipmap - Need render target mipmap
21916
- * @returns Render target
21917
- */ PipelineUtils.recreateRenderTargetIfNeeded = function recreateRenderTargetIfNeeded(engine, currentRenderTarget, width, height, colorFormat, depthFormat, mipmap) {
21918
- var _currentRenderTarget, _currentRenderTarget1;
21919
- var currentColorTexture = (_currentRenderTarget = currentRenderTarget) == null ? void 0 : _currentRenderTarget.getColorTexture(0);
21920
- var currentDepthTexture = (_currentRenderTarget1 = currentRenderTarget) == null ? void 0 : _currentRenderTarget1.depthTexture;
21921
- var colorTexture = colorFormat ? PipelineUtils.recreateTextureIfNeeded(engine, currentColorTexture, width, height, colorFormat, mipmap) : null;
21922
- var depthTexture = depthFormat ? PipelineUtils.recreateTextureIfNeeded(engine, currentDepthTexture, width, height, depthFormat, mipmap) : null;
21923
- if (currentColorTexture !== colorTexture || currentDepthTexture !== depthTexture) {
21924
- var _currentRenderTarget2;
21925
- (_currentRenderTarget2 = currentRenderTarget) == null ? void 0 : _currentRenderTarget2.destroy();
21926
- currentRenderTarget = new RenderTarget(engine, width, height, colorTexture, depthTexture);
21927
- currentRenderTarget.isGCIgnored = true;
21928
- }
21929
- return currentRenderTarget;
21930
- };
21931
- return PipelineUtils;
22038
+ * Post rendering callback.
22039
+ * @param camera - Camera
22040
+ * @param opaqueQueue - Opaque queue
22041
+ * @param alphaTestQueue - Alpha test queue
22042
+ * @param transparentQueue - Transparent queue
22043
+ */ _proto.preRender = function preRender(camera, opaqueQueue, alphaTestQueue, transparentQueue) {};
22044
+ /**
22045
+ * Post rendering callback.
22046
+ * @param camera - Camera
22047
+ * @param opaqueQueue - Opaque queue
22048
+ * @param alphaTestQueue - Alpha test queue
22049
+ * @param transparentQueue - Transparent queue
22050
+ */ _proto.postRender = function postRender(camera, opaqueQueue, alphaTestQueue, transparentQueue) {};
22051
+ return RenderPass;
21932
22052
  }();
21933
22053
 
21934
22054
  /**
@@ -22025,7 +22145,7 @@ var /**
22025
22145
  // https://lxjk.github.io/2017/04/15/Calculate-Minimal-Bounding-Sphere-of-Frustum.html
22026
22146
  var centerZ;
22027
22147
  var radius;
22028
- var k = Math.sqrt(1.0 + aspectRatio * aspectRatio) * Math.tan(MathUtil$1.degreeToRadian(fieldOfView) / 2.0);
22148
+ var k = Math.sqrt(1.0 + aspectRatio * aspectRatio) * Math.tan(MathUtil.degreeToRadian(fieldOfView) / 2.0);
22029
22149
  var k2 = k * k;
22030
22150
  var farSNear = far - near;
22031
22151
  var farANear = far + near;
@@ -22196,6 +22316,26 @@ var /**
22196
22316
  var offset = cascadeIndex * 16;
22197
22317
  Utils._floatMatrixMultiply(sliceMatrix, outShadowMatrices, offset, outShadowMatrices, offset);
22198
22318
  };
22319
+ /**
22320
+ * Extract scale and bias from a fade distance to achieve a linear fading of the fade distance.
22321
+ */ ShadowUtils.getScaleAndBiasForLinearDistanceFade = function getScaleAndBiasForLinearDistanceFade(fadeDistance, border, outInfo) {
22322
+ // (P^2-N^2)/(F^2-N^2)
22323
+ // To avoid division from zero
22324
+ // This values ensure that fade within cascade will be 0 and outside 1
22325
+ if (border < 0.0001) {
22326
+ var multiplier = 1000; // To avoid blending if difference is in fractions
22327
+ outInfo.z = multiplier;
22328
+ outInfo.w = -fadeDistance * multiplier;
22329
+ return;
22330
+ }
22331
+ border = 1 - border;
22332
+ border *= border;
22333
+ // 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.
22334
+ var distanceFadeNear = border * fadeDistance;
22335
+ var fadeRange = fadeDistance - distanceFadeNear;
22336
+ outInfo.z = 1.0 / fadeRange;
22337
+ outInfo.w = -distanceFadeNear / fadeRange;
22338
+ };
22199
22339
  return ShadowUtils;
22200
22340
  }();
22201
22341
  (function() {
@@ -22440,12 +22580,6 @@ var /**
22440
22580
  ShadowUtils.atlasBorderSize = 4.0;
22441
22581
  })();
22442
22582
 
22443
- /**
22444
- * PipelinePass is a base class for all pipeline passes.
22445
- */ var PipelinePass = function PipelinePass(engine) {
22446
- this._engine = engine;
22447
- };
22448
-
22449
22583
  /**
22450
22584
  * Cascade shadow caster pass.
22451
22585
  */ var CascadedShadowCasterPass = /*#__PURE__*/ function(PipelinePass1) {
@@ -22458,11 +22592,10 @@ var /**
22458
22592
  _this._shadowSliceData = new ShadowSliceData();
22459
22593
  _this._lightUp = new Vector3();
22460
22594
  _this._lightSide = new Vector3();
22461
- _this._existShadowMap = false;
22462
22595
  _this._splitBoundSpheres = new Float32Array(CascadedShadowCasterPass._maxCascades * 4);
22463
22596
  /** The end is project precision problem in shader. */ _this._shadowMatrices = new Float32Array((CascadedShadowCasterPass._maxCascades + 1) * 16);
22464
- // strength, null, lightIndex
22465
- _this._shadowInfos = new Vector3();
22597
+ // intensity, null, fadeScale, fadeBias
22598
+ _this._shadowInfos = new Vector4();
22466
22599
  _this._viewportOffsets = [
22467
22600
  new Vector2(),
22468
22601
  new Vector2(),
@@ -22478,14 +22611,12 @@ var /**
22478
22611
  /**
22479
22612
  * @internal
22480
22613
  */ _proto.onRender = function onRender(context) {
22614
+ var light = this._camera.scene._lightManager._sunlight;
22481
22615
  this._updateShadowSettings();
22482
- this._existShadowMap = false;
22483
- this._renderDirectShadowMap(context);
22484
- if (this._existShadowMap) {
22485
- this._updateReceiversShaderData();
22486
- }
22616
+ this._renderDirectShadowMap(context, light);
22617
+ this._updateReceiversShaderData(light);
22487
22618
  };
22488
- _proto._renderDirectShadowMap = function _renderDirectShadowMap(context) {
22619
+ _proto._renderDirectShadowMap = function _renderDirectShadowMap(context, light) {
22489
22620
  var _this = this, engine = _this._engine, camera = _this._camera, viewports = _this._viewportOffsets, shadowSliceData = _this._shadowSliceData, splitBoundSpheres = _this._splitBoundSpheres, shadowMatrices = _this._shadowMatrices;
22490
22621
  var _camera__renderPipeline__cullingResults = camera._renderPipeline._cullingResults, opaqueQueue = _camera__renderPipeline__cullingResults.opaqueQueue, alphaTestQueue = _camera__renderPipeline__cullingResults.alphaTestQueue, transparentQueue = _camera__renderPipeline__cullingResults.transparentQueue;
22491
22622
  var scene = camera.scene;
@@ -22499,91 +22630,87 @@ var /**
22499
22630
  var lightUp = this._lightUp;
22500
22631
  var lightSide = this._lightSide;
22501
22632
  var lightForward = shadowSliceData.virtualCamera.forward;
22502
- var light = scene._lightManager._sunlight;
22503
- if (light) {
22504
- var shadowFar = Math.min(camera.scene.shadowDistance, camera.farClipPlane);
22505
- this._getCascadesSplitDistance(shadowFar);
22506
- // Prepare render target
22507
- var _this__shadowMapSize = this._shadowMapSize, width = _this__shadowMapSize.z, height = _this__shadowMapSize.w;
22508
- var format = this._shadowMapFormat;
22509
- var renderTarget;
22510
- var shadowTexture;
22511
- if (this._supportDepthTexture) {
22512
- renderTarget = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._renderTarget, width, height, null, format, false);
22513
- shadowTexture = renderTarget.depthTexture;
22514
- } else {
22515
- renderTarget = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._renderTarget, width, height, format, null, false);
22516
- shadowTexture = renderTarget.getColorTexture(0);
22517
- }
22518
- shadowTexture.wrapModeU = shadowTexture.wrapModeV = TextureWrapMode.Clamp;
22519
- if (engine._hardwareRenderer._isWebGL2) {
22520
- shadowTexture.depthCompareFunction = TextureDepthCompareFunction.Less;
22521
- }
22522
- this._renderTarget = renderTarget;
22523
- this._depthTexture = shadowTexture;
22524
- // @todo: shouldn't set viewport and scissor in activeRenderTarget
22525
- rhi.activeRenderTarget(renderTarget, CascadedShadowCasterPass._viewport, 0);
22526
- if (this._supportDepthTexture) {
22527
- rhi.clearRenderTarget(engine, CameraClearFlags.Depth, null);
22528
- } else {
22529
- rhi.clearRenderTarget(engine, CameraClearFlags.All, CascadedShadowCasterPass._clearColor);
22530
- }
22531
- this._shadowInfos.x = light.shadowStrength;
22532
- this._shadowInfos.z = 0; // @todo: sun light index always 0
22533
- // prepare light and camera direction
22534
- Matrix.rotationQuaternion(light.entity.transform.worldRotationQuaternion, lightWorld);
22535
- lightSide.set(lightWorldE[0], lightWorldE[1], lightWorldE[2]);
22536
- lightUp.set(lightWorldE[4], lightWorldE[5], lightWorldE[6]);
22537
- lightForward.set(-lightWorldE[8], -lightWorldE[9], -lightWorldE[10]);
22538
- var cameraForward = CascadedShadowCasterPass._tempVector;
22539
- cameraForward.copyFrom(camera.entity.transform.worldForward);
22540
- var shadowTileResolution = this._shadowTileResolution;
22541
- for(var j = 0; j < shadowCascades; j++){
22542
- ShadowUtils.getBoundSphereByFrustum(splitDistance[j], splitDistance[j + 1], camera, cameraForward, shadowSliceData);
22543
- ShadowUtils.getDirectionLightShadowCullPlanes(camera._frustum, splitDistance[j], camera.nearClipPlane, lightForward, shadowSliceData);
22544
- ShadowUtils.getDirectionalLightMatrices(lightUp, lightSide, lightForward, j, light.shadowNearPlane, shadowTileResolution, shadowSliceData, shadowMatrices);
22545
- if (shadowCascades > 1) {
22546
- ShadowUtils.applySliceTransform(shadowTileResolution, width, height, j, this._viewportOffsets[j], shadowMatrices);
22547
- }
22548
- this._updateSingleShadowCasterShaderData(light, shadowSliceData, context);
22549
- // upload pre-cascade infos.
22550
- var center = boundSphere.center;
22551
- var radius = boundSphere.radius;
22552
- var offset = j * 4;
22553
- splitBoundSpheres[offset] = center.x;
22554
- splitBoundSpheres[offset + 1] = center.y;
22555
- splitBoundSpheres[offset + 2] = center.z;
22556
- splitBoundSpheres[offset + 3] = radius * radius;
22557
- opaqueQueue.clear();
22558
- alphaTestQueue.clear();
22559
- transparentQueue.clear();
22560
- var renderers = componentsManager._renderers;
22561
- var elements = renderers._elements;
22562
- for(var k = renderers.length - 1; k >= 0; --k){
22563
- ShadowUtils.shadowCullFrustum(context, light, elements[k], shadowSliceData);
22564
- }
22565
- if (opaqueQueue.elements.length || alphaTestQueue.elements.length) {
22566
- opaqueQueue.sort(RenderQueue._compareFromNearToFar);
22567
- alphaTestQueue.sort(RenderQueue._compareFromNearToFar);
22568
- var _viewports_j = viewports[j], x = _viewports_j.x, y = _viewports_j.y;
22569
- rhi.setGlobalDepthBias(1.0, 1.0);
22570
- rhi.viewport(x, y, shadowTileResolution, shadowTileResolution);
22571
- // for no cascade is for the edge,for cascade is for the beyond maxCascade pixel can use (0,0,0) trick sample the shadowMap
22572
- rhi.scissor(x + 1, y + 1, shadowTileResolution - 2, shadowTileResolution - 2);
22573
- engine._renderCount++;
22574
- opaqueQueue.render(camera, Layer.Everything, PipelineStage.ShadowCaster);
22575
- alphaTestQueue.render(camera, Layer.Everything, PipelineStage.ShadowCaster);
22576
- rhi.setGlobalDepthBias(0, 0);
22577
- }
22578
- }
22579
- this._existShadowMap = true;
22580
- }
22581
- };
22582
- _proto._updateReceiversShaderData = function _updateReceiversShaderData() {
22583
- var scene = this._camera.scene;
22633
+ // Prepare render target
22634
+ var _this__shadowMapSize = this._shadowMapSize, width = _this__shadowMapSize.z, height = _this__shadowMapSize.w;
22635
+ var format = this._shadowMapFormat;
22636
+ var renderTarget;
22637
+ var shadowTexture;
22638
+ if (this._supportDepthTexture) {
22639
+ renderTarget = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._renderTarget, width, height, null, format, false);
22640
+ shadowTexture = renderTarget.depthTexture;
22641
+ } else {
22642
+ renderTarget = PipelineUtils.recreateRenderTargetIfNeeded(engine, this._renderTarget, width, height, format, null, false);
22643
+ shadowTexture = renderTarget.getColorTexture(0);
22644
+ }
22645
+ shadowTexture.wrapModeU = shadowTexture.wrapModeV = TextureWrapMode.Clamp;
22646
+ if (engine._hardwareRenderer._isWebGL2) {
22647
+ shadowTexture.depthCompareFunction = TextureDepthCompareFunction.Less;
22648
+ }
22649
+ this._renderTarget = renderTarget;
22650
+ this._depthTexture = shadowTexture;
22651
+ // @todo: shouldn't set viewport and scissor in activeRenderTarget
22652
+ rhi.activeRenderTarget(renderTarget, CascadedShadowCasterPass._viewport, 0);
22653
+ if (this._supportDepthTexture) {
22654
+ rhi.clearRenderTarget(engine, CameraClearFlags.Depth, null);
22655
+ } else {
22656
+ rhi.clearRenderTarget(engine, CameraClearFlags.All, CascadedShadowCasterPass._clearColor);
22657
+ }
22658
+ // prepare light and camera direction
22659
+ Matrix.rotationQuaternion(light.entity.transform.worldRotationQuaternion, lightWorld);
22660
+ lightSide.set(lightWorldE[0], lightWorldE[1], lightWorldE[2]);
22661
+ lightUp.set(lightWorldE[4], lightWorldE[5], lightWorldE[6]);
22662
+ lightForward.set(-lightWorldE[8], -lightWorldE[9], -lightWorldE[10]);
22663
+ var cameraForward = CascadedShadowCasterPass._tempVector;
22664
+ cameraForward.copyFrom(camera.entity.transform.worldForward);
22665
+ var shadowTileResolution = this._shadowTileResolution;
22666
+ for(var j = 0; j < shadowCascades; j++){
22667
+ ShadowUtils.getBoundSphereByFrustum(splitDistance[j], splitDistance[j + 1], camera, cameraForward, shadowSliceData);
22668
+ ShadowUtils.getDirectionLightShadowCullPlanes(camera._frustum, splitDistance[j], camera.nearClipPlane, lightForward, shadowSliceData);
22669
+ ShadowUtils.getDirectionalLightMatrices(lightUp, lightSide, lightForward, j, light.shadowNearPlane, shadowTileResolution, shadowSliceData, shadowMatrices);
22670
+ if (shadowCascades > 1) {
22671
+ ShadowUtils.applySliceTransform(shadowTileResolution, width, height, j, this._viewportOffsets[j], shadowMatrices);
22672
+ }
22673
+ this._updateSingleShadowCasterShaderData(light, shadowSliceData, context);
22674
+ // upload pre-cascade infos.
22675
+ var center = boundSphere.center;
22676
+ var radius = boundSphere.radius;
22677
+ var offset = j * 4;
22678
+ splitBoundSpheres[offset] = center.x;
22679
+ splitBoundSpheres[offset + 1] = center.y;
22680
+ splitBoundSpheres[offset + 2] = center.z;
22681
+ splitBoundSpheres[offset + 3] = radius * radius;
22682
+ opaqueQueue.clear();
22683
+ alphaTestQueue.clear();
22684
+ transparentQueue.clear();
22685
+ var renderers = componentsManager._renderers;
22686
+ var elements = renderers._elements;
22687
+ for(var k = renderers.length - 1; k >= 0; --k){
22688
+ ShadowUtils.shadowCullFrustum(context, light, elements[k], shadowSliceData);
22689
+ }
22690
+ if (opaqueQueue.elements.length || alphaTestQueue.elements.length) {
22691
+ opaqueQueue.sort(RenderQueue._compareFromNearToFar);
22692
+ alphaTestQueue.sort(RenderQueue._compareFromNearToFar);
22693
+ var _viewports_j = viewports[j], x = _viewports_j.x, y = _viewports_j.y;
22694
+ rhi.setGlobalDepthBias(1.0, 1.0);
22695
+ rhi.viewport(x, y, shadowTileResolution, shadowTileResolution);
22696
+ // for no cascade is for the edge,for cascade is for the beyond maxCascade pixel can use (0,0,0) trick sample the shadowMap
22697
+ rhi.scissor(x + 1, y + 1, shadowTileResolution - 2, shadowTileResolution - 2);
22698
+ engine._renderCount++;
22699
+ opaqueQueue.render(camera, Layer.Everything, PipelineStage.ShadowCaster);
22700
+ alphaTestQueue.render(camera, Layer.Everything, PipelineStage.ShadowCaster);
22701
+ rhi.setGlobalDepthBias(0, 0);
22702
+ }
22703
+ }
22704
+ };
22705
+ _proto._updateReceiversShaderData = function _updateReceiversShaderData(light) {
22706
+ var camera = this._camera;
22707
+ var scene = camera.scene;
22584
22708
  var splitBoundSpheres = this._splitBoundSpheres;
22585
22709
  var shadowMatrices = this._shadowMatrices;
22586
22710
  var shadowCascades = scene.shadowCascades;
22711
+ var shadowFar = Math.min(scene.shadowDistance, camera.farClipPlane);
22712
+ ShadowUtils.getScaleAndBiasForLinearDistanceFade(Math.pow(shadowFar, 2), scene.shadowFadeBorder, this._shadowInfos);
22713
+ this._shadowInfos.x = light.shadowStrength;
22587
22714
  // set zero matrix to project the index out of max cascade
22588
22715
  if (shadowCascades > 1) {
22589
22716
  for(var i = shadowCascades * 4, n = splitBoundSpheres.length; i < n; i++){
@@ -22596,7 +22723,7 @@ var /**
22596
22723
  }
22597
22724
  var shaderData = scene.shaderData;
22598
22725
  shaderData.setFloatArray(CascadedShadowCasterPass._shadowMatricesProperty, this._shadowMatrices);
22599
- shaderData.setVector3(CascadedShadowCasterPass._shadowInfosProperty, this._shadowInfos);
22726
+ shaderData.setVector4(CascadedShadowCasterPass._shadowInfosProperty, this._shadowInfos);
22600
22727
  shaderData.setTexture(CascadedShadowCasterPass._shadowMapsProperty, this._depthTexture);
22601
22728
  shaderData.setFloatArray(CascadedShadowCasterPass._shadowSplitSpheresProperty, this._splitBoundSpheres);
22602
22729
  shaderData.setVector4(CascadedShadowCasterPass._shadowMapSize, this._shadowMapSize);
@@ -22607,7 +22734,7 @@ var /**
22607
22734
  var _this__camera = this._camera, nearClipPlane = _this__camera.nearClipPlane, aspectRatio = _this__camera.aspectRatio, fieldOfView = _this__camera.fieldOfView;
22608
22735
  cascadesSplitDistance[0] = nearClipPlane;
22609
22736
  var range = shadowFar - nearClipPlane;
22610
- var tFov = Math.tan(MathUtil$1.degreeToRadian(fieldOfView) * 0.5);
22737
+ var tFov = Math.tan(MathUtil.degreeToRadian(fieldOfView) * 0.5);
22611
22738
  var denominator = 1.0 + tFov * tFov * (aspectRatio * aspectRatio + 1.0);
22612
22739
  switch(shadowCascades){
22613
22740
  case ShadowCascadesMode.NoCascades:
@@ -22632,10 +22759,13 @@ var /**
22632
22759
  return Math.sqrt(radius * radius / denominator);
22633
22760
  };
22634
22761
  _proto._updateShadowSettings = function _updateShadowSettings() {
22635
- var scene = this._camera.scene;
22762
+ var camera = this._camera;
22763
+ var scene = camera.scene;
22636
22764
  var shadowFormat = ShadowUtils.shadowDepthFormat(scene.shadowResolution, this._supportDepthTexture);
22637
22765
  var shadowResolution = ShadowUtils.shadowResolution(scene.shadowResolution);
22638
22766
  var shadowCascades = scene.shadowCascades;
22767
+ var shadowFar = Math.min(scene.shadowDistance, camera.farClipPlane);
22768
+ this._getCascadesSplitDistance(shadowFar);
22639
22769
  if (shadowFormat !== this._shadowMapFormat || shadowResolution !== this._shadowMapResolution || shadowCascades !== this._shadowCascadeMode) {
22640
22770
  this._shadowMapFormat = shadowFormat;
22641
22771
  this._shadowMapResolution = shadowResolution;
@@ -22710,7 +22840,7 @@ var /**
22710
22840
  CascadedShadowCasterPass._viewport = new Vector4(0, 0, 1, 1);
22711
22841
  })();
22712
22842
  (function() {
22713
- CascadedShadowCasterPass._clearColor = new Color$1(1, 1, 1, 1);
22843
+ CascadedShadowCasterPass._clearColor = new Color(1, 1, 1, 1);
22714
22844
  })();
22715
22845
  (function() {
22716
22846
  CascadedShadowCasterPass._tempVector = new Vector3();
@@ -23083,14 +23213,14 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
23083
23213
  /** @internal */ _this._cameraIndex = -1;
23084
23214
  _this._priority = 0;
23085
23215
  _this._shaderData = new ShaderData(ShaderDataGroup.Camera);
23086
- _this._isProjMatSetting = false;
23216
+ _this._isCustomViewMatrix = false;
23217
+ _this._isCustomProjectionMatrix = false;
23087
23218
  _this._nearClipPlane = 0.1;
23088
23219
  _this._farClipPlane = 100;
23089
23220
  _this._fieldOfView = 45;
23090
23221
  _this._orthographicSize = 10;
23091
23222
  _this._isProjectionDirty = true;
23092
23223
  _this._isInvProjMatDirty = true;
23093
- _this._isFrustumProjectDirty = true;
23094
23224
  _this._customAspectRatio = undefined;
23095
23225
  _this._renderTarget = null;
23096
23226
  _this._depthBufferParams = new Vector4();
@@ -23102,7 +23232,7 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
23102
23232
  _this._transform = transform;
23103
23233
  _this._isViewMatrixDirty = transform.registerWorldChangeFlag();
23104
23234
  _this._isInvViewProjDirty = transform.registerWorldChangeFlag();
23105
- _this._frustumViewChangeFlag = transform.registerWorldChangeFlag();
23235
+ _this._frustumChangeFlag = transform.registerWorldChangeFlag();
23106
23236
  _this._renderPipeline = new BasicRenderPipeline(_assert_this_initialized(_this));
23107
23237
  _this._addResourceReferCount(_this.shaderData, 1);
23108
23238
  _this._updatePixelViewport();
@@ -23114,16 +23244,22 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
23114
23244
  }
23115
23245
  var _proto = Camera1.prototype;
23116
23246
  /**
23247
+ * Restore the view matrix to the world matrix of the entity.
23248
+ */ _proto.resetViewMatrix = function resetViewMatrix() {
23249
+ this._isCustomViewMatrix = false;
23250
+ this._viewMatrixChange();
23251
+ };
23252
+ /**
23117
23253
  * Restore the automatic calculation of projection matrix through fieldOfView, nearClipPlane and farClipPlane.
23118
23254
  */ _proto.resetProjectionMatrix = function resetProjectionMatrix() {
23119
- this._isProjMatSetting = false;
23120
- this._projMatChange();
23255
+ this._isCustomProjectionMatrix = false;
23256
+ this._projectionMatrixChange();
23121
23257
  };
23122
23258
  /**
23123
23259
  * Restore the automatic calculation of the aspect ratio through the viewport aspect ratio.
23124
23260
  */ _proto.resetAspectRatio = function resetAspectRatio() {
23125
23261
  this._customAspectRatio = undefined;
23126
- this._projMatChange();
23262
+ this._projectionMatrixChange();
23127
23263
  };
23128
23264
  /**
23129
23265
  * Transform a point from world space to viewport space.
@@ -23170,7 +23306,7 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
23170
23306
  // Use the intersection of the near clipping plane as the origin point.
23171
23307
  var origin = this._innerViewportToWorldPoint(point.x, point.y, 0.0, invViewProjMat, out.origin);
23172
23308
  // Use the intersection of the far clipping plane as the origin point.
23173
- var direction = this._innerViewportToWorldPoint(point.x, point.y, 1 - MathUtil$1.zeroTolerance, invViewProjMat, out.direction);
23309
+ var direction = this._innerViewportToWorldPoint(point.x, point.y, 1 - MathUtil.zeroTolerance, invViewProjMat, out.direction);
23174
23310
  Vector3.subtract(direction, origin, direction);
23175
23311
  direction.normalize();
23176
23312
  return out;
@@ -23253,10 +23389,9 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
23253
23389
  context.replacementShader = this._replacementShader;
23254
23390
  context.replacementTag = this._replacementSubShaderTag;
23255
23391
  // compute cull frustum.
23256
- if (this.enableFrustumCulling && (this._frustumViewChangeFlag.flag || this._isFrustumProjectDirty)) {
23392
+ if (this.enableFrustumCulling && this._frustumChangeFlag.flag) {
23257
23393
  this._frustum.calculateFromMatrix(virtualCamera.viewProjectionMatrix);
23258
- this._frustumViewChangeFlag.flag = false;
23259
- this._isFrustumProjectDirty = false;
23394
+ this._frustumChangeFlag.flag = false;
23260
23395
  }
23261
23396
  this._updateShaderData();
23262
23397
  // union scene and camera macro.
@@ -23305,13 +23440,16 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
23305
23440
  //@ts-ignore
23306
23441
  this._viewport._onValueChanged = null;
23307
23442
  this.engine.canvas._sizeUpdateFlagManager.removeListener(this._onPixelViewportChanged);
23443
+ //@ts-ignore
23444
+ this._viewport._onValueChanged = null;
23445
+ this.engine.canvas._sizeUpdateFlagManager.removeListener(this._onPixelViewportChanged);
23308
23446
  this._entity = null;
23309
23447
  this._globalShaderMacro = null;
23310
23448
  this._frustum = null;
23311
23449
  this._renderPipeline = null;
23312
23450
  this._virtualCamera = null;
23313
23451
  this._shaderData = null;
23314
- this._frustumViewChangeFlag = null;
23452
+ this._frustumChangeFlag = null;
23315
23453
  this._transform = null;
23316
23454
  this._isViewMatrixDirty = null;
23317
23455
  this._isInvViewProjDirty = null;
@@ -23333,11 +23471,16 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
23333
23471
  var viewport = this._viewport;
23334
23472
  this._pixelViewport.set(viewport.x * width, viewport.y * height, viewport.z * width, viewport.w * height);
23335
23473
  };
23336
- _proto._projMatChange = function _projMatChange() {
23337
- this._isFrustumProjectDirty = true;
23474
+ _proto._viewMatrixChange = function _viewMatrixChange() {
23475
+ this._isViewMatrixDirty.flag = true;
23476
+ this._isInvViewProjDirty.flag = true;
23477
+ this._frustumChangeFlag.flag = true;
23478
+ };
23479
+ _proto._projectionMatrixChange = function _projectionMatrixChange() {
23338
23480
  this._isProjectionDirty = true;
23339
23481
  this._isInvProjMatDirty = true;
23340
23482
  this._isInvViewProjDirty.flag = true;
23483
+ this._frustumChangeFlag.flag = true;
23341
23484
  };
23342
23485
  _proto._innerViewportToWorldPoint = function _innerViewportToWorldPoint(x, y, z, invViewProjMat, out) {
23343
23486
  // Depth is a normalized value, 0 is nearPlane, 1 is farClipPlane.
@@ -23380,7 +23523,7 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
23380
23523
  _proto._onPixelViewportChanged = function _onPixelViewportChanged() {
23381
23524
  this._updatePixelViewport();
23382
23525
  var _this__customAspectRatio;
23383
- (_this__customAspectRatio = this._customAspectRatio) != null ? _this__customAspectRatio : this._projMatChange();
23526
+ (_this__customAspectRatio = this._customAspectRatio) != null ? _this__customAspectRatio : this._projectionMatrixChange();
23384
23527
  };
23385
23528
  _create_class(Camera1, [
23386
23529
  {
@@ -23400,7 +23543,7 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
23400
23543
  },
23401
23544
  set: function set(value) {
23402
23545
  this._nearClipPlane = value;
23403
- this._projMatChange();
23546
+ this._projectionMatrixChange();
23404
23547
  }
23405
23548
  },
23406
23549
  {
@@ -23412,7 +23555,7 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
23412
23555
  },
23413
23556
  set: function set(value) {
23414
23557
  this._farClipPlane = value;
23415
- this._projMatChange();
23558
+ this._projectionMatrixChange();
23416
23559
  }
23417
23560
  },
23418
23561
  {
@@ -23424,7 +23567,7 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
23424
23567
  },
23425
23568
  set: function set(value) {
23426
23569
  this._fieldOfView = value;
23427
- this._projMatChange();
23570
+ this._projectionMatrixChange();
23428
23571
  }
23429
23572
  },
23430
23573
  {
@@ -23439,7 +23582,7 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
23439
23582
  },
23440
23583
  set: function set(value) {
23441
23584
  this._customAspectRatio = value;
23442
- this._projMatChange();
23585
+ this._projectionMatrixChange();
23443
23586
  }
23444
23587
  },
23445
23588
  {
@@ -23491,7 +23634,12 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
23491
23634
  },
23492
23635
  set: function set(value) {
23493
23636
  this._virtualCamera.isOrthographic = value;
23494
- this._projMatChange();
23637
+ this._projectionMatrixChange();
23638
+ if (value) {
23639
+ this.shaderData.enableMacro("CAMERA_ORTHOGRAPHIC");
23640
+ } else {
23641
+ this.shaderData.disableMacro("CAMERA_ORTHOGRAPHIC");
23642
+ }
23495
23643
  }
23496
23644
  },
23497
23645
  {
@@ -23503,7 +23651,7 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
23503
23651
  },
23504
23652
  set: function set(value) {
23505
23653
  this._orthographicSize = value;
23506
- this._projMatChange();
23654
+ this._projectionMatrixChange();
23507
23655
  }
23508
23656
  },
23509
23657
  {
@@ -23512,28 +23660,37 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
23512
23660
  * View matrix.
23513
23661
  */ function get() {
23514
23662
  var viewMatrix = this._virtualCamera.viewMatrix;
23515
- if (this._isViewMatrixDirty.flag) {
23516
- this._isViewMatrixDirty.flag = false;
23517
- // Ignore scale.
23518
- var transform = this._transform;
23519
- Matrix.rotationTranslation(transform.worldRotationQuaternion, transform.worldPosition, viewMatrix);
23520
- viewMatrix.invert();
23521
- }
23663
+ if (!this._isViewMatrixDirty.flag || this._isCustomViewMatrix) {
23664
+ return viewMatrix;
23665
+ }
23666
+ this._isViewMatrixDirty.flag = false;
23667
+ // Ignore scale
23668
+ var transform = this._transform;
23669
+ Matrix.rotationTranslation(transform.worldRotationQuaternion, transform.worldPosition, viewMatrix);
23670
+ viewMatrix.invert();
23522
23671
  return viewMatrix;
23672
+ },
23673
+ set: function set(value) {
23674
+ this._virtualCamera.viewMatrix.copyFrom(value);
23675
+ this._isCustomViewMatrix = true;
23676
+ this._viewMatrixChange();
23523
23677
  }
23524
23678
  },
23525
23679
  {
23526
23680
  key: "projectionMatrix",
23527
- get: function get() {
23681
+ get: /**
23682
+ * The projection matrix is ​​calculated by the relevant parameters of the camera by default.
23683
+ * If it is manually set, the manual value will be maintained. Call resetProjectionMatrix() to restore it.
23684
+ */ function get() {
23528
23685
  var virtualCamera = this._virtualCamera;
23529
23686
  var projectionMatrix = virtualCamera.projectionMatrix;
23530
- if (!this._isProjectionDirty || this._isProjMatSetting) {
23687
+ if (!this._isProjectionDirty || this._isCustomProjectionMatrix) {
23531
23688
  return projectionMatrix;
23532
23689
  }
23533
23690
  this._isProjectionDirty = false;
23534
23691
  var aspectRatio = this.aspectRatio;
23535
23692
  if (!virtualCamera.isOrthographic) {
23536
- Matrix.perspective(MathUtil$1.degreeToRadian(this._fieldOfView), aspectRatio, this._nearClipPlane, this._farClipPlane, projectionMatrix);
23693
+ Matrix.perspective(MathUtil.degreeToRadian(this._fieldOfView), aspectRatio, this._nearClipPlane, this._farClipPlane, projectionMatrix);
23537
23694
  } else {
23538
23695
  var width = this._orthographicSize * aspectRatio;
23539
23696
  var height = this._orthographicSize;
@@ -23541,13 +23698,10 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component1) {
23541
23698
  }
23542
23699
  return projectionMatrix;
23543
23700
  },
23544
- set: /**
23545
- * The projection matrix is ​​calculated by the relevant parameters of the camera by default.
23546
- * If it is manually set, the manual value will be maintained. Call resetProjectionMatrix() to restore it.
23547
- */ function set(value) {
23701
+ set: function set(value) {
23548
23702
  this._virtualCamera.projectionMatrix.copyFrom(value);
23549
- this._isProjMatSetting = true;
23550
- this._projMatChange();
23703
+ this._isCustomProjectionMatrix = true;
23704
+ this._projectionMatrixChange();
23551
23705
  }
23552
23706
  },
23553
23707
  {
@@ -23608,7 +23762,7 @@ __decorate([
23608
23762
  ], Camera.prototype, "_cameraIndex", void 0);
23609
23763
  __decorate([
23610
23764
  ignoreClone
23611
- ], Camera.prototype, "_frustumViewChangeFlag", void 0);
23765
+ ], Camera.prototype, "_frustumChangeFlag", void 0);
23612
23766
  __decorate([
23613
23767
  ignoreClone
23614
23768
  ], Camera.prototype, "_transform", void 0);
@@ -23795,6 +23949,7 @@ var MultiExecutor = /*#__PURE__*/ function() {
23795
23949
  * @param obj - class object
23796
23950
  */ Loader.registerClass = function registerClass(className, classDefine) {
23797
23951
  this._engineObjects[className] = classDefine;
23952
+ this._classNameMap.set(classDefine, className);
23798
23953
  };
23799
23954
  /**
23800
23955
  * Get the class object by class name.
@@ -23803,11 +23958,21 @@ var MultiExecutor = /*#__PURE__*/ function() {
23803
23958
  */ Loader.getClass = function getClass(className) {
23804
23959
  return this._engineObjects[className];
23805
23960
  };
23961
+ /**
23962
+ * Get the class name by class object.
23963
+ * @param obj - class object
23964
+ * @returns class name
23965
+ */ Loader.getClassName = function getClassName(obj) {
23966
+ return this._classNameMap.get(obj);
23967
+ };
23806
23968
  return Loader;
23807
23969
  }();
23808
23970
  (function() {
23809
23971
  Loader._engineObjects = {};
23810
23972
  })();
23973
+ (function() {
23974
+ Loader._classNameMap = new Map();
23975
+ })();
23811
23976
 
23812
23977
  /**
23813
23978
  * Alpha blend mode.
@@ -24084,9 +24249,9 @@ var BaseMaterial = /*#__PURE__*/ function(Material1) {
24084
24249
  var shaderData = _this.shaderData;
24085
24250
  shaderData.enableMacro("MATERIAL_NEED_WORLD_POS");
24086
24251
  shaderData.enableMacro("MATERIAL_NEED_TILING_OFFSET");
24087
- shaderData.setColor(BlinnPhongMaterial._baseColorProp, new Color$1(1, 1, 1, 1));
24088
- shaderData.setColor(BlinnPhongMaterial._specularColorProp, new Color$1(1, 1, 1, 1));
24089
- shaderData.setColor(BlinnPhongMaterial._emissiveColorProp, new Color$1(0, 0, 0, 1));
24252
+ shaderData.setColor(BlinnPhongMaterial._baseColorProp, new Color(1, 1, 1, 1));
24253
+ shaderData.setColor(BlinnPhongMaterial._specularColorProp, new Color(1, 1, 1, 1));
24254
+ shaderData.setColor(BlinnPhongMaterial._emissiveColorProp, new Color(0, 0, 0, 1));
24090
24255
  shaderData.setVector4(BlinnPhongMaterial._tilingOffsetProp, new Vector4(1, 1, 0, 0));
24091
24256
  shaderData.setFloat(BlinnPhongMaterial._shininessProp, 16);
24092
24257
  shaderData.setFloat(BlinnPhongMaterial._normalIntensityProp, 1);
@@ -24278,8 +24443,8 @@ var BaseMaterial = /*#__PURE__*/ function(Material1) {
24278
24443
  var shaderData = _this.shaderData;
24279
24444
  shaderData.enableMacro("MATERIAL_NEED_WORLD_POS");
24280
24445
  shaderData.enableMacro("MATERIAL_NEED_TILING_OFFSET");
24281
- shaderData.setColor(PBRBaseMaterial._baseColorProp, new Color$1(1, 1, 1, 1));
24282
- shaderData.setColor(PBRBaseMaterial._emissiveColorProp, new Color$1(0, 0, 0, 1));
24446
+ shaderData.setColor(PBRBaseMaterial._baseColorProp, new Color(1, 1, 1, 1));
24447
+ shaderData.setColor(PBRBaseMaterial._emissiveColorProp, new Color(0, 0, 0, 1));
24283
24448
  shaderData.setVector4(PBRBaseMaterial._tilingOffsetProp, new Vector4(1, 1, 0, 0));
24284
24449
  shaderData.setFloat(PBRBaseMaterial._normalIntensityProp, 1);
24285
24450
  shaderData.setFloat(PBRBaseMaterial._occlusionTextureIntensityProp, 1);
@@ -24646,7 +24811,7 @@ var BaseMaterial = /*#__PURE__*/ function(Material1) {
24646
24811
  if (this._anisotropyRotation !== value) {
24647
24812
  this._anisotropyRotation = value;
24648
24813
  var anisotropyInfo = this.shaderData.getVector3(PBRMaterial._anisotropyInfoProp);
24649
- var rad = MathUtil$1.degreeToRadFactor * value;
24814
+ var rad = MathUtil.degreeToRadFactor * value;
24650
24815
  anisotropyInfo.x = Math.cos(rad);
24651
24816
  anisotropyInfo.y = Math.sin(rad);
24652
24817
  }
@@ -24700,7 +24865,7 @@ var BaseMaterial = /*#__PURE__*/ function(Material1) {
24700
24865
  function PBRSpecularMaterial(engine) {
24701
24866
  var _this;
24702
24867
  _this = PBRBaseMaterial1.call(this, engine, Shader.find("pbr-specular")) || this;
24703
- _this.shaderData.setColor(PBRSpecularMaterial._specularColorProp, new Color$1(1, 1, 1, 1));
24868
+ _this.shaderData.setColor(PBRSpecularMaterial._specularColorProp, new Color(1, 1, 1, 1));
24704
24869
  _this.shaderData.setFloat(PBRSpecularMaterial._glossinessProp, 1.0);
24705
24870
  return _this;
24706
24871
  }
@@ -24781,7 +24946,7 @@ var BaseMaterial = /*#__PURE__*/ function(Material1) {
24781
24946
  var shaderData = _this.shaderData;
24782
24947
  shaderData.enableMacro("MATERIAL_OMIT_NORMAL");
24783
24948
  shaderData.enableMacro("MATERIAL_NEED_TILING_OFFSET");
24784
- shaderData.setColor(UnlitMaterial._baseColorProp, new Color$1(1, 1, 1, 1));
24949
+ shaderData.setColor(UnlitMaterial._baseColorProp, new Color(1, 1, 1, 1));
24785
24950
  shaderData.setVector4(UnlitMaterial._tilingOffsetProp, new Vector4(1, 1, 0, 0));
24786
24951
  return _this;
24787
24952
  }
@@ -25241,6 +25406,7 @@ AnimationCurveOwner.registerAssembler(SkinnedMeshRenderer, "blendShapeWeights",
25241
25406
  _this = EngineObject1.call(this, null) || this;
25242
25407
  _this.name = name;
25243
25408
  _this./** @internal */ _curveBindings = [];
25409
+ _this./** @internal */ _updateFlagManager = new UpdateFlagManager();
25244
25410
  _this._length = 0;
25245
25411
  _this._events = [];
25246
25412
  return _this;
@@ -25268,11 +25434,13 @@ AnimationCurveOwner.registerAssembler(SkinnedMeshRenderer, "blendShapeWeights",
25268
25434
  while(--index >= 0 && eventTime < events[index].time);
25269
25435
  events.splice(index + 1, 0, newEvent);
25270
25436
  }
25437
+ this._updateFlagManager.dispatch();
25271
25438
  };
25272
25439
  /**
25273
25440
  * Clears all events from the clip.
25274
25441
  */ _proto.clearEvents = function clearEvents() {
25275
25442
  this._events.length = 0;
25443
+ this._updateFlagManager.dispatch();
25276
25444
  };
25277
25445
  _proto.addCurveBinding = function addCurveBinding(entityPath, componentType, propertyOrSetPropertyPathOrComponentIndex, curveOrSetPropertyPathOrGetPropertyPath, curveOrGetPropertyPath, curve) {
25278
25446
  var curveBinding = new AnimationClipCurveBinding();
@@ -25669,32 +25837,32 @@ var AnimationColorCurve = (_AnimationColorCurve = /*#__PURE__*/ function(Animati
25669
25837
  function AnimationColorCurve() {
25670
25838
  var _this;
25671
25839
  _this = AnimationCurve1.call(this) || this;
25672
- _this._evaluateData.value = new Color$1();
25840
+ _this._evaluateData.value = new Color();
25673
25841
  return _this;
25674
25842
  }
25675
25843
  /**
25676
25844
  * @internal
25677
25845
  */ AnimationColorCurve._initializeOwner = function _initializeOwner(owner) {
25678
- owner.defaultValue = new Color$1();
25679
- owner.fixedPoseValue = new Color$1();
25680
- owner.baseEvaluateData.value = new Color$1();
25681
- owner.crossEvaluateData.value = new Color$1();
25846
+ owner.defaultValue = new Color();
25847
+ owner.fixedPoseValue = new Color();
25848
+ owner.baseEvaluateData.value = new Color();
25849
+ owner.crossEvaluateData.value = new Color();
25682
25850
  };
25683
25851
  /**
25684
25852
  * @internal
25685
25853
  */ AnimationColorCurve._initializeLayerOwner = function _initializeLayerOwner(owner) {
25686
- owner.finalValue = new Color$1();
25854
+ owner.finalValue = new Color();
25687
25855
  };
25688
25856
  /**
25689
25857
  * @internal
25690
25858
  */ AnimationColorCurve._lerpValue = function _lerpValue(srcValue, destValue, weight, out) {
25691
- Color$1.lerp(srcValue, destValue, weight, out);
25859
+ Color.lerp(srcValue, destValue, weight, out);
25692
25860
  return out;
25693
25861
  };
25694
25862
  /**
25695
25863
  * @internal
25696
25864
  */ AnimationColorCurve._subtractValue = function _subtractValue(src, base, out) {
25697
- Color$1.subtract(src, base, out);
25865
+ Color.subtract(src, base, out);
25698
25866
  return out;
25699
25867
  };
25700
25868
  /**
@@ -25706,8 +25874,8 @@ var AnimationColorCurve = (_AnimationColorCurve = /*#__PURE__*/ function(Animati
25706
25874
  /**
25707
25875
  * @internal
25708
25876
  */ AnimationColorCurve._additiveValue = function _additiveValue(value, weight, out) {
25709
- Color$1.scale(value, weight, value);
25710
- Color$1.add(out, value, out);
25877
+ Color.scale(value, weight, value);
25878
+ Color.add(out, value, out);
25711
25879
  return out;
25712
25880
  };
25713
25881
  /**
@@ -26829,26 +26997,31 @@ var AnimatorLayerBlendingMode;
26829
26997
  }
26830
26998
  };
26831
26999
  _proto._saveAnimatorEventHandlers = function _saveAnimatorEventHandlers(state, animatorStateData) {
27000
+ var _this = this;
26832
27001
  var eventHandlerPool = this._animationEventHandlerPool;
26833
27002
  var scripts = [];
26834
- this._entity.getComponents(Script, scripts);
26835
- var scriptCount = scripts.length;
26836
27003
  var eventHandlers = animatorStateData.eventHandlers;
26837
- var events = state.clip.events;
26838
- eventHandlers.length = 0;
26839
- for(var i = 0, n = events.length; i < n; i++){
26840
- var event = events[i];
26841
- var eventHandler = eventHandlerPool.getFromPool();
26842
- var funcName = event.functionName;
26843
- var handlers = eventHandler.handlers;
26844
- eventHandler.event = event;
26845
- handlers.length = 0;
26846
- for(var j = scriptCount - 1; j >= 0; j--){
26847
- var handler = scripts[j][funcName];
26848
- handler && handlers.push(handler);
27004
+ var clipChangedListener = function() {
27005
+ _this._entity.getComponents(Script, scripts);
27006
+ var scriptCount = scripts.length;
27007
+ var events = state.clip.events;
27008
+ eventHandlers.length = 0;
27009
+ for(var i = 0, n = events.length; i < n; i++){
27010
+ var event = events[i];
27011
+ var eventHandler = eventHandlerPool.getFromPool();
27012
+ var funcName = event.functionName;
27013
+ var handlers = eventHandler.handlers;
27014
+ eventHandler.event = event;
27015
+ handlers.length = 0;
27016
+ for(var j = scriptCount - 1; j >= 0; j--){
27017
+ var handler = scripts[j][funcName];
27018
+ handler && handlers.push(handler);
27019
+ }
27020
+ eventHandlers.push(eventHandler);
26849
27021
  }
26850
- eventHandlers.push(eventHandler);
26851
- }
27022
+ };
27023
+ clipChangedListener();
27024
+ state._updateFlagManager.addListener(clipChangedListener);
26852
27025
  };
26853
27026
  _proto._clearCrossData = function _clearCrossData(animatorLayerData) {
26854
27027
  animatorLayerData.crossCurveMark++;
@@ -27459,9 +27632,11 @@ __decorate([
27459
27632
  this./** @internal */ _onStateEnterScripts = [];
27460
27633
  this./** @internal */ _onStateUpdateScripts = [];
27461
27634
  this./** @internal */ _onStateExitScripts = [];
27635
+ this./** @internal */ _updateFlagManager = new UpdateFlagManager();
27462
27636
  this._clipStartTime = 0;
27463
27637
  this._clipEndTime = 1;
27464
27638
  this._transitions = [];
27639
+ this._onClipChanged = this._onClipChanged.bind(this);
27465
27640
  }
27466
27641
  var _proto = AnimatorState.prototype;
27467
27642
  /**
@@ -27535,6 +27710,11 @@ __decorate([
27535
27710
  index2 !== -1 && this._onStateExitScripts.splice(index2, 1);
27536
27711
  }
27537
27712
  };
27713
+ /**
27714
+ * @internal
27715
+ */ _proto._onClipChanged = function _onClipChanged() {
27716
+ this._updateFlagManager.dispatch();
27717
+ };
27538
27718
  _create_class(AnimatorState, [
27539
27719
  {
27540
27720
  key: "transitions",
@@ -27552,8 +27732,17 @@ __decorate([
27552
27732
  return this._clip;
27553
27733
  },
27554
27734
  set: function set(clip) {
27735
+ var lastClip = this._clip;
27736
+ if (lastClip === clip) {
27737
+ return;
27738
+ }
27739
+ if (lastClip) {
27740
+ lastClip._updateFlagManager.removeListener(this._onClipChanged);
27741
+ }
27555
27742
  this._clip = clip;
27556
27743
  this._clipEndTime = Math.min(this._clipEndTime, 1);
27744
+ this._onClipChanged();
27745
+ clip && clip._updateFlagManager.addListener(this._onClipChanged);
27557
27746
  }
27558
27747
  },
27559
27748
  {
@@ -27764,7 +27953,7 @@ var AnimatorConditionMode;
27764
27953
  var _this;
27765
27954
  _this = Material1.call(this, engine, Shader.find("skybox")) || this;
27766
27955
  _this._textureDecodeRGBM = false;
27767
- _this._tintColor = new Color$1(1, 1, 1, 1);
27956
+ _this._tintColor = new Color(1, 1, 1, 1);
27768
27957
  _this.renderState.rasterState.cullMode = CullMode.Off;
27769
27958
  _this.renderState.depthState.compareFunction = CompareFunction.LessEqual;
27770
27959
  _this.shaderData.setFloat(SkyBoxMaterial._rotationProp, 0);
@@ -27877,8 +28066,8 @@ var SunMode;
27877
28066
  _this.sunSize = 0.04;
27878
28067
  _this.sunSizeConvergence = 5;
27879
28068
  _this.atmosphereThickness = 1.0;
27880
- _this.skyTint = new Color$1(0.5, 0.5, 0.5, 1.0);
27881
- _this.groundTint = new Color$1(0.369, 0.349, 0.341, 1.0);
28069
+ _this.skyTint = new Color(0.5, 0.5, 0.5, 1.0);
28070
+ _this.groundTint = new Color(0.369, 0.349, 0.341, 1.0);
27882
28071
  _this.exposure = 1.3;
27883
28072
  _this.renderState.rasterState.cullMode = CullMode.Off;
27884
28073
  _this.renderState.depthState.compareFunction = CompareFunction.LessEqual;
@@ -28260,6 +28449,7 @@ __decorate([
28260
28449
  ParticleRandomSubSeeds[ParticleRandomSubSeeds["RotationOverLifetime"] = 0x40eb95e4] = "RotationOverLifetime";
28261
28450
  ParticleRandomSubSeeds[ParticleRandomSubSeeds["TextureSheetAnimation"] = 0xbc524e5] = "TextureSheetAnimation";
28262
28451
  ParticleRandomSubSeeds[ParticleRandomSubSeeds["Shape"] = 0xaf502044] = "Shape";
28452
+ ParticleRandomSubSeeds[ParticleRandomSubSeeds["GravityModifier"] = 0xa47b8c4d] = "GravityModifier";
28263
28453
  })(ParticleRandomSubSeeds || (ParticleRandomSubSeeds = {}));
28264
28454
 
28265
28455
  /**
@@ -28358,9 +28548,9 @@ __decorate([
28358
28548
  typeArray[offset] = key.time;
28359
28549
  var color = key.color;
28360
28550
  if (colorSpace === ColorSpace.Linear) {
28361
- typeArray[offset + 1] = Color$1.gammaToLinearSpace(color.r);
28362
- typeArray[offset + 2] = Color$1.gammaToLinearSpace(color.g);
28363
- typeArray[offset + 3] = Color$1.gammaToLinearSpace(color.b);
28551
+ typeArray[offset + 1] = Color.gammaToLinearSpace(color.r);
28552
+ typeArray[offset + 2] = Color.gammaToLinearSpace(color.g);
28553
+ typeArray[offset + 3] = Color.gammaToLinearSpace(color.b);
28364
28554
  } else {
28365
28555
  typeArray[offset + 1] = color.r;
28366
28556
  typeArray[offset + 2] = color.g;
@@ -28445,7 +28635,7 @@ __decorate([
28445
28635
  */ var GradientColorKey = /*#__PURE__*/ function() {
28446
28636
  function GradientColorKey(time, color) {
28447
28637
  /** @internal */ this._onValueChanged = null;
28448
- this._color = new Color$1();
28638
+ this._color = new Color();
28449
28639
  this._time = time;
28450
28640
  color && this._color.copyFrom(color);
28451
28641
  // @ts-ignore
@@ -28522,11 +28712,11 @@ __decorate([
28522
28712
  */ var ParticleCompositeGradient = /*#__PURE__*/ function() {
28523
28713
  function ParticleCompositeGradient(constantOrGradient, constantMaxOrGradientMax) {
28524
28714
  /** The gradient mode. */ this.mode = ParticleGradientMode.Constant;
28525
- /* The min constant color used by the gradient if mode is set to `TwoConstants`. */ this.constantMin = new Color$1();
28526
- /* The max constant color used by the gradient if mode is set to `TwoConstants`. */ this.constantMax = new Color$1();
28715
+ /* The min constant color used by the gradient if mode is set to `TwoConstants`. */ this.constantMin = new Color();
28716
+ /* The max constant color used by the gradient if mode is set to `TwoConstants`. */ this.constantMax = new Color();
28527
28717
  /** The min gradient used by the gradient if mode is set to `Gradient`. */ this.gradientMin = new ParticleGradient();
28528
28718
  /** The max gradient used by the gradient if mode is set to `Gradient`. */ this.gradientMax = new ParticleGradient();
28529
- if (constantOrGradient.constructor === Color$1) {
28719
+ if (constantOrGradient.constructor === Color) {
28530
28720
  if (constantMaxOrGradientMax) {
28531
28721
  this.constantMin.copyFrom(constantOrGradient);
28532
28722
  this.constantMax.copyFrom(constantMaxOrGradientMax);
@@ -28558,7 +28748,7 @@ __decorate([
28558
28748
  out.copyFrom(this.constant);
28559
28749
  break;
28560
28750
  case ParticleGradientMode.TwoConstants:
28561
- Color$1.lerp(this.constantMin, this.constantMax, lerpFactor, out);
28751
+ Color.lerp(this.constantMin, this.constantMax, lerpFactor, out);
28562
28752
  break;
28563
28753
  }
28564
28754
  };
@@ -28630,8 +28820,8 @@ __decorate([
28630
28820
  var _this;
28631
28821
  _this = ParticleGeneratorModule1.apply(this, arguments) || this;
28632
28822
  /** Color gradient over lifetime. */ _this.color = new ParticleCompositeGradient(new ParticleGradient([
28633
- new GradientColorKey(0.0, new Color$1(1, 1, 1)),
28634
- new GradientColorKey(1.0, new Color$1(1, 1, 1))
28823
+ new GradientColorKey(0.0, new Color(1, 1, 1)),
28824
+ new GradientColorKey(1.0, new Color(1, 1, 1))
28635
28825
  ], [
28636
28826
  new GradientAlphaKey(0, 1),
28637
28827
  new GradientAlphaKey(1, 1)
@@ -28961,7 +29151,7 @@ var MainModule = /*#__PURE__*/ function() {
28961
29151
  /** The initial rotation of particles around the y-axis when emitted. */ this.startRotationY = new ParticleCompositeCurve(0);
28962
29152
  /** The initial rotation of particles around the z-axis when emitted. */ this.startRotationZ = new ParticleCompositeCurve(0);
28963
29153
  /** Makes some particles spin in the opposite direction. */ this.flipRotation = 0;
28964
- /** The mode of start color */ this.startColor = new ParticleCompositeGradient(new Color$1(1, 1, 1, 1));
29154
+ /** The mode of start color */ this.startColor = new ParticleCompositeGradient(new Color(1, 1, 1, 1));
28965
29155
  /** A scale that this Particle Generator applies to gravity, defined by Physics.gravity. */ this.gravityModifier = new ParticleCompositeCurve(0);
28966
29156
  /** This selects the space in which to simulate particles. It can be either world or local space. */ this.simulationSpace = ParticleSimulationSpace.Local;
28967
29157
  /** Override the default playback speed of the Particle Generator. */ this.simulationSpeed = 1.0;
@@ -28973,6 +29163,7 @@ var MainModule = /*#__PURE__*/ function() {
28973
29163
  /** @internal */ this._startColorRand = new Rand(0, ParticleRandomSubSeeds.StartColor);
28974
29164
  /** @internal */ this._startSizeRand = new Rand(0, ParticleRandomSubSeeds.StartSize);
28975
29165
  /** @internal */ this._startRotationRand = new Rand(0, ParticleRandomSubSeeds.StartRotation);
29166
+ this._gravityModifierRand = new Rand(0, ParticleRandomSubSeeds.GravityModifier);
28976
29167
  this._gravity = new Vector3();
28977
29168
  this._generator = generator;
28978
29169
  }
@@ -29033,7 +29224,7 @@ var MainModule = /*#__PURE__*/ function() {
29033
29224
  break;
29034
29225
  }
29035
29226
  var particleGravity = this._gravity;
29036
- var gravityModifierValue = this.gravityModifier.evaluate(undefined, undefined);
29227
+ var gravityModifierValue = this.gravityModifier.evaluate(undefined, this._gravityModifierRand.random());
29037
29228
  Vector3.scale(renderer.scene.physics.gravity, gravityModifierValue, particleGravity);
29038
29229
  shaderData.setVector3(MainModule._gravity, particleGravity);
29039
29230
  shaderData.setInt(MainModule._simulationSpace, this.simulationSpace);
@@ -29152,6 +29343,9 @@ __decorate([
29152
29343
  __decorate([
29153
29344
  ignoreClone
29154
29345
  ], MainModule.prototype, "_startRotationRand", void 0);
29346
+ __decorate([
29347
+ ignoreClone
29348
+ ], MainModule.prototype, "_gravityModifierRand", void 0);
29155
29349
  __decorate([
29156
29350
  ignoreClone
29157
29351
  ], MainModule.prototype, "_generator", void 0);
@@ -29206,11 +29400,11 @@ __decorate([
29206
29400
  isCurveMacro = RotationOverLifetimeModule._curveModeMacro;
29207
29401
  } else {
29208
29402
  var constantMax = this._rotationMaxConstant;
29209
- constantMax.set(MathUtil$1.degreeToRadian(rotationX.constantMax), MathUtil$1.degreeToRadian(rotationY.constantMax), MathUtil$1.degreeToRadian(rotationZ.constantMax));
29403
+ constantMax.set(MathUtil.degreeToRadian(rotationX.constantMax), MathUtil.degreeToRadian(rotationY.constantMax), MathUtil.degreeToRadian(rotationZ.constantMax));
29210
29404
  shaderData.setVector3(RotationOverLifetimeModule._maxConstantProperty, constantMax);
29211
29405
  if (separateAxes ? rotationX.mode === ParticleCurveMode.TwoConstants && rotationY.mode === ParticleCurveMode.TwoConstants && rotationZ.mode === ParticleCurveMode.TwoConstants : rotationZ.mode === ParticleCurveMode.TwoConstants) {
29212
29406
  var constantMin = this._rotationMinConstant;
29213
- constantMin.set(MathUtil$1.degreeToRadian(rotationX.constantMin), MathUtil$1.degreeToRadian(rotationY.constantMin), MathUtil$1.degreeToRadian(rotationZ.constantMin));
29407
+ constantMin.set(MathUtil.degreeToRadian(rotationX.constantMin), MathUtil.degreeToRadian(rotationY.constantMin), MathUtil.degreeToRadian(rotationZ.constantMin));
29214
29408
  shaderData.setVector3(RotationOverLifetimeModule._minConstantProperty, constantMin);
29215
29409
  isRandomTwoMacro = RotationOverLifetimeModule._isRandomTwoMacro;
29216
29410
  }
@@ -29822,7 +30016,8 @@ __decorate([
29822
30016
  var transform = this._renderer.entity.transform;
29823
30017
  var shape = this.emission.shape;
29824
30018
  for(var i = 0; i < count; i++){
29825
- if (shape) {
30019
+ var _shape;
30020
+ if ((_shape = shape) == null ? void 0 : _shape.enabled) {
29826
30021
  shape._generatePositionAndDirection(this.emission._shapeRand, time, position, direction);
29827
30022
  var positionScale = this.main._getPositionScale();
29828
30023
  position.multiply(positionScale);
@@ -30094,11 +30289,11 @@ __decorate([
30094
30289
  // Start rotation
30095
30290
  var startRotationRand = main._startRotationRand;
30096
30291
  if (main.startRotation3D) {
30097
- instanceVertices[offset + 15] = MathUtil$1.degreeToRadian(main.startRotationX.evaluate(undefined, startRotationRand.random()));
30098
- instanceVertices[offset + 16] = MathUtil$1.degreeToRadian(main.startRotationY.evaluate(undefined, startRotationRand.random()));
30099
- instanceVertices[offset + 17] = MathUtil$1.degreeToRadian(main.startRotationZ.evaluate(undefined, startRotationRand.random()));
30292
+ instanceVertices[offset + 15] = MathUtil.degreeToRadian(main.startRotationX.evaluate(undefined, startRotationRand.random()));
30293
+ instanceVertices[offset + 16] = MathUtil.degreeToRadian(main.startRotationY.evaluate(undefined, startRotationRand.random()));
30294
+ instanceVertices[offset + 17] = MathUtil.degreeToRadian(main.startRotationZ.evaluate(undefined, startRotationRand.random()));
30100
30295
  } else {
30101
- instanceVertices[offset + 15] = MathUtil$1.degreeToRadian(main.startRotationZ.evaluate(undefined, startRotationRand.random()));
30296
+ instanceVertices[offset + 15] = MathUtil.degreeToRadian(main.startRotationZ.evaluate(undefined, startRotationRand.random()));
30102
30297
  }
30103
30298
  // Start speed
30104
30299
  instanceVertices[offset + 18] = startSpeed;
@@ -30261,7 +30456,7 @@ __decorate([
30261
30456
  /** @internal */ ParticleGenerator._tempVector31 = new Vector3();
30262
30457
  })();
30263
30458
  (function() {
30264
- /** @internal */ ParticleGenerator._tempColor0 = new Color$1();
30459
+ /** @internal */ ParticleGenerator._tempColor0 = new Color();
30265
30460
  })();
30266
30461
  (function() {
30267
30462
  /** @internal */ ParticleGenerator._tempParticleRenderers = new Array();
@@ -30341,7 +30536,7 @@ __decorate([
30341
30536
  var _this;
30342
30537
  _this = BaseMaterial1.call(this, engine, Shader.find("particle-shader")) || this;
30343
30538
  var shaderData = _this.shaderData;
30344
- shaderData.setColor(BaseMaterial._baseColorProp, new Color$1(1, 1, 1, 1));
30539
+ shaderData.setColor(BaseMaterial._baseColorProp, new Color(1, 1, 1, 1));
30345
30540
  _this.isTransparent = true;
30346
30541
  return _this;
30347
30542
  }
@@ -30402,7 +30597,7 @@ __decorate([
30402
30597
  * Base class for all particle shapes.
30403
30598
  */ var BaseShape = /*#__PURE__*/ function() {
30404
30599
  function BaseShape() {
30405
- /** Specifies whether the ShapeModule is enabled or disabled. */ this.enable = true;
30600
+ /** Specifies whether the ShapeModule is enabled or disabled. */ this.enabled = true;
30406
30601
  /** Randomizes the starting direction of particles. */ this.randomDirectionAmount = 0;
30407
30602
  }
30408
30603
  var _proto = BaseShape.prototype;
@@ -30481,9 +30676,9 @@ __decorate([
30481
30676
  _inherits(BoxShape, BaseShape1);
30482
30677
  function BoxShape() {
30483
30678
  var _this;
30484
- _this = BaseShape1.call(this) || this;
30485
- /** The size of the box. */ _this.size = new Vector3(1, 1, 1);
30679
+ _this = BaseShape1.apply(this, arguments) || this;
30486
30680
  _this.shapeType = ParticleShapeType.Box;
30681
+ /** The size of the box. */ _this.size = new Vector3(1, 1, 1);
30487
30682
  return _this;
30488
30683
  }
30489
30684
  var _proto = BoxShape.prototype;
@@ -30520,12 +30715,12 @@ __decorate([
30520
30715
  _inherits(CircleShape, BaseShape1);
30521
30716
  function CircleShape() {
30522
30717
  var _this;
30523
- _this = BaseShape1.call(this) || this;
30718
+ _this = BaseShape1.apply(this, arguments) || this;
30719
+ _this.shapeType = ParticleShapeType.Circle;
30524
30720
  /** Radius of the shape to emit particles from. */ _this.radius = 1.0;
30525
30721
  /** Angle of the circle arc to emit particles from. */ _this.arc = 360.0;
30526
30722
  /** The mode to generate particles around the arc. */ _this.arcMode = ParticleShapeArcMode.Random;
30527
30723
  /** The speed of complete 360 degree rotation. */ _this.arcSpeed = 1.0;
30528
- _this.shapeType = ParticleShapeType.Circle;
30529
30724
  return _this;
30530
30725
  }
30531
30726
  var _proto = CircleShape.prototype;
@@ -30536,12 +30731,12 @@ __decorate([
30536
30731
  switch(this.arcMode){
30537
30732
  case ParticleShapeArcMode.Loop:
30538
30733
  var normalizedEmitTime = emitTime * this.arcSpeed * (360 / this.arc) % 1;
30539
- var radian = MathUtil$1.degreeToRadian(this.arc * normalizedEmitTime);
30734
+ var radian = MathUtil.degreeToRadian(this.arc * normalizedEmitTime);
30540
30735
  positionPoint.set(Math.cos(radian), Math.sin(radian));
30541
30736
  positionPoint.scale(rand.random());
30542
30737
  break;
30543
30738
  case ParticleShapeArcMode.Random:
30544
- ShapeUtils.randomPointInsideUnitArcCircle(MathUtil$1.degreeToRadian(this.arc), positionPoint, rand);
30739
+ ShapeUtils.randomPointInsideUnitArcCircle(MathUtil.degreeToRadian(this.arc), positionPoint, rand);
30545
30740
  break;
30546
30741
  }
30547
30742
  position.set(positionPoint.x, positionPoint.y, 0);
@@ -30561,12 +30756,12 @@ __decorate([
30561
30756
  _inherits(ConeShape, BaseShape1);
30562
30757
  function ConeShape() {
30563
30758
  var _this;
30564
- _this = BaseShape1.call(this) || this;
30759
+ _this = BaseShape1.apply(this, arguments) || this;
30760
+ _this.shapeType = ParticleShapeType.Cone;
30565
30761
  /** Angle of the cone to emit particles from. */ _this.angle = 25.0;
30566
30762
  /** Radius of the shape to emit particles from. */ _this.radius = 1.0;
30567
30763
  /** Length of the cone to emit particles from. */ _this.length = 5.0;
30568
30764
  /** Cone emitter type. */ _this.emitType = /** Emit particles from the base of the cone. */ 0;
30569
- _this.shapeType = ParticleShapeType.Cone;
30570
30765
  return _this;
30571
30766
  }
30572
30767
  var _proto = ConeShape.prototype;
@@ -30574,7 +30769,7 @@ __decorate([
30574
30769
  * @internal
30575
30770
  */ _proto._generatePositionAndDirection = function _generatePositionAndDirection(rand, emitTime, position, direction) {
30576
30771
  var unitPosition = ConeShape._tempVector20;
30577
- var radian = MathUtil$1.degreeToRadian(this.angle);
30772
+ var radian = MathUtil.degreeToRadian(this.angle);
30578
30773
  var dirSinA = Math.sin(radian);
30579
30774
  var dirCosA = Math.cos(radian);
30580
30775
  switch(this.emitType){
@@ -30626,9 +30821,9 @@ var ConeEmitType;
30626
30821
  _inherits(HemisphereShape, BaseShape1);
30627
30822
  function HemisphereShape() {
30628
30823
  var _this;
30629
- _this = BaseShape1.call(this) || this;
30630
- /** Radius of the shape to emit particles from. */ _this.radius = 1.0;
30824
+ _this = BaseShape1.apply(this, arguments) || this;
30631
30825
  _this.shapeType = ParticleShapeType.Hemisphere;
30826
+ /** Radius of the shape to emit particles from. */ _this.radius = 1.0;
30632
30827
  return _this;
30633
30828
  }
30634
30829
  var _proto = HemisphereShape.prototype;
@@ -30651,9 +30846,9 @@ var ConeEmitType;
30651
30846
  _inherits(SphereShape, BaseShape1);
30652
30847
  function SphereShape() {
30653
30848
  var _this;
30654
- _this = BaseShape1.call(this) || this;
30655
- /** Radius of the shape to emit particles from. */ _this.radius = 1.0;
30849
+ _this = BaseShape1.apply(this, arguments) || this;
30656
30850
  _this.shapeType = ParticleShapeType.Sphere;
30851
+ /** Radius of the shape to emit particles from. */ _this.radius = 1.0;
30657
30852
  return _this;
30658
30853
  }
30659
30854
  var _proto = SphereShape.prototype;
@@ -31026,5 +31221,5 @@ var cacheDir = new Vector3();
31026
31221
  return CubeProbe;
31027
31222
  }(Probe);
31028
31223
 
31029
- export { AmbientLight, AnimationArrayCurve, AnimationBoolCurve, AnimationClip, AnimationClipCurveBinding, AnimationColorCurve, AnimationCurve, AnimationEvent, AnimationFloatArrayCurve, AnimationFloatCurve, AnimationQuaternionCurve, AnimationRectCurve, AnimationRefCurve, AnimationStringCurve, AnimationVector2Curve, AnimationVector3Curve, AnimationVector4Curve, Animator, AnimatorConditionMode, AnimatorController, AnimatorControllerLayer, AnimatorCullingMode, AnimatorLayerBlendingMode, AnimatorLayerMask, AnimatorState, AnimatorStateMachine, AnimatorStateTransition, AssetPromise, AssetType, Background, BackgroundMode, BackgroundTextureFillMode, BaseMaterial, Basic2DBatcher, BasicRenderPipeline, BlendFactor, BlendMode, BlendOperation, BlendShape, BlendShapeFrame, BlendState, BlinnPhongMaterial, BoolUpdateFlag, BoxColliderShape, BoxShape, Buffer, BufferBindFlag, BufferMesh, BufferUsage, BufferUtil, Burst, Camera, CameraClearFlags, CameraType, Canvas, CapsuleColliderShape, CharacterController, CircleShape, CloneManager, Collider, ColliderShape, ColliderShapeUpAxis, CollisionDetectionMode, ColorOverLifetimeModule, ColorSpace, ColorWriteMask, CompareFunction, Component, ConeEmitType, ConeShape, ContentRestorer, ControllerCollisionFlag, ControllerNonWalkableMode, CubeProbe, CullMode, CurveKey, DataType, DependentMode, DepthState, DepthTextureMode, DiffuseMode, DirectLight, DynamicCollider, DynamicColliderConstraints, EmissionModule, Engine, EngineObject, Entity, EventDispatcher, FixedJoint, FogMode, Font, FontStyle, GLCapabilityType, GradientAlphaKey, GradientColorKey, HemisphereShape, HingeJoint, HitResult, IndexBufferBinding, IndexFormat, InputManager, InterpolationType, Joint, JointLimits, JointMotor, Keyframe, Keys, Layer, Light, Loader, Logger, MainModule, Material, Mesh, MeshRenderer, MeshTopology, ModelMesh, OverflowMode, PBRBaseMaterial, PBRMaterial, PBRSpecularMaterial, ParticleCompositeCurve, ParticleCompositeGradient, ParticleCurve, ParticleCurveMode, ParticleGenerator, ParticleGradient, ParticleGradientMode, ParticleMaterial, ParticleRenderMode, ParticleRenderer, ParticleScaleMode, ParticleShapeArcMode, ParticleSimulationSpace, ParticleStopMode, PhysicsMaterial, PhysicsMaterialCombineMode, PhysicsScene, PipelineStage, PlaneColliderShape, Platform, PointLight, Pointer, PointerButton, PointerPhase, Primitive, PrimitiveMesh, Probe, RasterState, ReferResource, RenderBufferDepthFormat, RenderFace, RenderPass, RenderQueue, RenderQueueType, RenderState, RenderStateElementKey as RenderStateDataKey, RenderTarget, RenderTargetBlendState, Renderer, ResourceManager, RotationOverLifetimeModule, Scene, SceneManager, Script, SetDataOptions, Shader, ShaderData, ShaderFactory, ShaderMacro, ShaderMacroCollection, ShaderPass, ShaderProperty, ShaderPropertyType, ShaderTagKey, ShadowCascadesMode, ShadowResolution, ShadowType, SizeOverLifetimeModule, Skin, SkinnedMeshRenderer, Sky, SkyBoxMaterial, SkyProceduralMaterial, SphereColliderShape, SphereShape, SpotLight, SpringJoint, Sprite, SpriteAtlas, SpriteDrawMode, SpriteMask, SpriteMaskInteraction, SpriteMaskLayer, SpriteRenderer, SpriteTileMode, StateMachineScript, StaticCollider, StencilOperation, StencilState, SubMesh, SubShader, SunMode, SystemInfo, TextHorizontalAlignment, TextRenderer, TextUtils, TextVerticalAlignment, Texture, Texture2D, Texture2DArray, TextureCoordinate, TextureCube, TextureCubeFace, TextureDepthCompareFunction, TextureFilterMode, TextureFormat, TextureSheetAnimationModule, TextureUsage, TextureWrapMode, Time, TrailMaterial, TrailRenderer, Transform, UnlitMaterial, Utils, VelocityOverLifetimeModule, VertexAttribute, VertexBufferBinding, VertexElement, VertexElementFormat, WrapMode, XRManager, assignmentClone, deepClone, dependentComponents, ignoreClone, request, resourceLoader, shallowClone };
31224
+ export { AmbientLight, AnimationArrayCurve, AnimationBoolCurve, AnimationClip, AnimationClipCurveBinding, AnimationColorCurve, AnimationCurve, AnimationEvent, AnimationFloatArrayCurve, AnimationFloatCurve, AnimationQuaternionCurve, AnimationRectCurve, AnimationRefCurve, AnimationStringCurve, AnimationVector2Curve, AnimationVector3Curve, AnimationVector4Curve, Animator, AnimatorConditionMode, AnimatorController, AnimatorControllerLayer, AnimatorCullingMode, AnimatorLayerBlendingMode, AnimatorLayerMask, AnimatorState, AnimatorStateMachine, AnimatorStateTransition, AssetPromise, AssetType, Background, BackgroundMode, BackgroundTextureFillMode, BaseMaterial, Basic2DBatcher, BasicRenderPipeline, BlendFactor, BlendMode, BlendOperation, BlendShape, BlendShapeFrame, BlendState, BlinnPhongMaterial, BoolUpdateFlag, BoxColliderShape, BoxShape, Buffer, BufferBindFlag, BufferMesh, BufferUsage, BufferUtil, Burst, Camera, CameraClearFlags, CameraType, Canvas, CapsuleColliderShape, CharacterController, CircleShape, CloneManager, Collider, ColliderShape, ColliderShapeUpAxis, CollisionDetectionMode, ColorOverLifetimeModule, ColorSpace, ColorWriteMask, CompareFunction, Component, ConeEmitType, ConeShape, ContentRestorer, ControllerCollisionFlag, ControllerNonWalkableMode, CubeProbe, CullMode, CurveKey, DataType, DependentMode, DepthState, DepthTextureMode, DiffuseMode, DirectLight, DynamicCollider, DynamicColliderConstraints, EmissionModule, Engine, EngineObject, Entity, EventDispatcher, FixedJoint, FogMode, Font, FontStyle, GLCapabilityType, GradientAlphaKey, GradientColorKey, HemisphereShape, HingeJoint, HitResult, IndexBufferBinding, IndexFormat, InputManager, InterpolationType, Joint, JointLimits, JointMotor, Keyframe, Keys, Layer, Light, Loader, Logger, MainModule, Material, Mesh, MeshRenderer, MeshTopology, ModelMesh, OverflowMode, PBRBaseMaterial, PBRMaterial, PBRSpecularMaterial, ParticleCompositeCurve, ParticleCompositeGradient, ParticleCurve, ParticleCurveMode, ParticleGenerator, ParticleGradient, ParticleGradientMode, ParticleMaterial, ParticleRenderMode, ParticleRenderer, ParticleScaleMode, ParticleShapeArcMode, ParticleShapeType, ParticleSimulationSpace, ParticleStopMode, PhysicsMaterial, PhysicsMaterialCombineMode, PhysicsScene, PipelineStage, PlaneColliderShape, Platform, PointLight, Pointer, PointerButton, PointerPhase, Primitive, PrimitiveMesh, Probe, RasterState, ReferResource, RenderBufferDepthFormat, RenderFace, RenderPass, RenderQueue, RenderQueueType, RenderState, RenderStateElementKey as RenderStateDataKey, RenderTarget, RenderTargetBlendState, Renderer, ResourceManager, RotationOverLifetimeModule, Scene, SceneManager, Script, SetDataOptions, Shader, ShaderData, ShaderFactory, ShaderMacro, ShaderMacroCollection, ShaderPass, ShaderProperty, ShaderPropertyType, ShaderTagKey, ShadowCascadesMode, ShadowResolution, ShadowType, SizeOverLifetimeModule, Skin, SkinnedMeshRenderer, Sky, SkyBoxMaterial, SkyProceduralMaterial, SphereColliderShape, SphereShape, SpotLight, SpringJoint, Sprite, SpriteAtlas, SpriteDrawMode, SpriteMask, SpriteMaskInteraction, SpriteMaskLayer, SpriteRenderer, SpriteTileMode, StateMachineScript, StaticCollider, StencilOperation, StencilState, SubMesh, SubShader, SunMode, SystemInfo, TextHorizontalAlignment, TextRenderer, TextUtils, TextVerticalAlignment, Texture, Texture2D, Texture2DArray, TextureCoordinate, TextureCube, TextureCubeFace, TextureDepthCompareFunction, TextureFilterMode, TextureFormat, TextureSheetAnimationModule, TextureUsage, TextureWrapMode, Time, TrailMaterial, TrailRenderer, Transform, UnlitMaterial, Utils, VelocityOverLifetimeModule, VertexAttribute, VertexBufferBinding, VertexElement, VertexElementFormat, WrapMode, XRManager, assignmentClone, deepClone, dependentComponents, ignoreClone, request, resourceLoader, shallowClone };
31030
31225
  //# sourceMappingURL=module.js.map