@galacean/engine-core 1.0.0-beta.1 → 1.0.0-beta.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.
Files changed (48) hide show
  1. package/dist/main.js +762 -335
  2. package/dist/main.js.map +1 -1
  3. package/dist/miniprogram.js +762 -335
  4. package/dist/module.js +757 -336
  5. package/dist/module.js.map +1 -1
  6. package/package.json +3 -3
  7. package/types/2d/atlas/SpriteAtlas.d.ts +0 -1
  8. package/types/2d/sprite/Sprite.d.ts +12 -3
  9. package/types/2d/sprite/SpriteMask.d.ts +16 -17
  10. package/types/2d/sprite/SpriteRenderer.d.ts +17 -11
  11. package/types/2d/text/Font.d.ts +0 -1
  12. package/types/2d/text/TextRenderer.d.ts +1 -9
  13. package/types/Camera.d.ts +0 -4
  14. package/types/Component.d.ts +0 -1
  15. package/types/Engine.d.ts +0 -2
  16. package/types/Renderer.d.ts +3 -11
  17. package/types/SafeLoopArray.d.ts +37 -0
  18. package/types/Script.d.ts +0 -1
  19. package/types/animation/Animator.d.ts +2 -3
  20. package/types/animation/internal/AnimationCurveLayerOwner.d.ts +1 -0
  21. package/types/animation/internal/AnimationCurveOwnerLayerData.d.ts +1 -0
  22. package/types/asset/GraphicsResource.d.ts +0 -1
  23. package/types/asset/ReferResource.d.ts +0 -1
  24. package/types/enums/ActiveChangeFlag.d.ts +6 -0
  25. package/types/env-probe/CubeProbe.d.ts +0 -1
  26. package/types/graphic/Buffer.d.ts +0 -1
  27. package/types/graphic/Mesh.d.ts +2 -6
  28. package/types/index.d.ts +1 -1
  29. package/types/lighting/Light.d.ts +0 -1
  30. package/types/material/PBRMaterial.d.ts +11 -2
  31. package/types/mesh/MeshRenderer.d.ts +8 -8
  32. package/types/mesh/ModelMesh.d.ts +0 -1
  33. package/types/mesh/SkinnedMeshRenderer.d.ts +0 -4
  34. package/types/physics/Collider.d.ts +0 -1
  35. package/types/physics/PhysicsScene.d.ts +75 -0
  36. package/types/shader/index.d.ts +1 -0
  37. package/types/shader/state/index.d.ts +6 -0
  38. package/types/shadow/CascadedShadowCasterPass.d.ts +1 -0
  39. package/types/sky/Sky.d.ts +12 -4
  40. package/types/texture/RenderTarget.d.ts +0 -1
  41. package/types/texture/Texture.d.ts +0 -1
  42. package/types/trail/TrailRenderer.d.ts +0 -2
  43. package/types/utils/BoolUpdateFlag.d.ts +12 -0
  44. package/types/utils/DisorderedArray.d.ts +18 -0
  45. package/types/utils/SafeLoopArray.d.ts +41 -0
  46. package/types/utils/UpdateFlag.d.ts +20 -0
  47. package/types/utils/UpdateFlagManager.d.ts +1 -0
  48. package/types/utils/Utils.d.ts +31 -0
package/dist/main.js CHANGED
@@ -682,7 +682,9 @@ __decorate([
682
682
  */ _proto._addToResourceManager = function _addToResourceManager(path) {
683
683
  this._engine.resourceManager._addAsset(path, this);
684
684
  };
685
- _proto._onDestroy = function _onDestroy() {
685
+ /**
686
+ * @internal
687
+ */ _proto._onDestroy = function _onDestroy() {
686
688
  EngineObject.prototype._onDestroy.call(this);
687
689
  this._engine.resourceManager._deleteReferResource(this);
688
690
  var refCount = this._getReferCount();
@@ -814,7 +816,9 @@ var GraphicsResource = /*#__PURE__*/ function(ReferResource) {
814
816
  return _this;
815
817
  }
816
818
  var _proto = GraphicsResource.prototype;
817
- _proto._onDestroy = function _onDestroy() {
819
+ /**
820
+ * @internal
821
+ */ _proto._onDestroy = function _onDestroy() {
818
822
  ReferResource.prototype._onDestroy.call(this);
819
823
  this.engine.resourceManager._deleteGraphicResource(this);
820
824
  };
@@ -893,7 +897,9 @@ var Logger = {
893
897
  platformTexture.depthCompareFunction = this._depthCompareFunction;
894
898
  platformTexture.setUseDepthCompareMode(this._useDepthCompareMode);
895
899
  };
896
- _proto._onDestroy = function _onDestroy() {
900
+ /**
901
+ * @internal
902
+ */ _proto._onDestroy = function _onDestroy() {
897
903
  GraphicsResource.prototype._onDestroy.call(this);
898
904
  this._platformTexture.destroy();
899
905
  this._platformTexture = null;
@@ -1043,9 +1049,11 @@ var Logger = {
1043
1049
  renderTexture
1044
1050
  ];
1045
1051
  for(var i = 0, n = colorTextures.length; i < n; i++){
1046
- if (colorTextures[i]._isDepthTexture) {
1052
+ var colorTexture = colorTextures[i];
1053
+ if (colorTexture._isDepthTexture) {
1047
1054
  throw "Render texture can't use depth format.";
1048
1055
  }
1056
+ colorTexture._addReferCount(1);
1049
1057
  }
1050
1058
  _this._colorTextures = colorTextures;
1051
1059
  } else {
@@ -1056,6 +1064,7 @@ var Logger = {
1056
1064
  throw "Depth texture must use depth format.";
1057
1065
  }
1058
1066
  _this._depthTexture = depth;
1067
+ _this._depthTexture._addReferCount(1);
1059
1068
  }
1060
1069
  _this._platformRenderTarget = engine._hardwareRenderer.createPlatformRenderTarget(_assert_this_initialized(_this));
1061
1070
  return _this;
@@ -1081,10 +1090,18 @@ var Logger = {
1081
1090
  this._depthTexture && this._depthTexture.generateMipmaps();
1082
1091
  }
1083
1092
  };
1084
- _proto._onDestroy = function _onDestroy() {
1093
+ /**
1094
+ * @internal
1095
+ */ _proto._onDestroy = function _onDestroy() {
1096
+ var _this__depthTexture;
1085
1097
  GraphicsResource.prototype._onDestroy.call(this);
1086
1098
  this._platformRenderTarget.destroy();
1087
- this._colorTextures.length = 0;
1099
+ var _this = this, colorTextures = _this._colorTextures;
1100
+ for(var i = 0, n = colorTextures.length; i < n; i++){
1101
+ colorTextures[i]._addReferCount(-1);
1102
+ }
1103
+ colorTextures.length = 0;
1104
+ (_this__depthTexture = this._depthTexture) == null ? void 0 : _this__depthTexture._addReferCount(-1);
1088
1105
  this._depthTexture = null;
1089
1106
  this._depth = null;
1090
1107
  };
@@ -1459,7 +1476,9 @@ var Logger = {
1459
1476
  _proto.getCharInfo = function getCharInfo(char) {
1460
1477
  return this._charInfoMap[char.charCodeAt(0)];
1461
1478
  };
1462
- _proto._onDestroy = function _onDestroy() {
1479
+ /**
1480
+ * @internal
1481
+ */ _proto._onDestroy = function _onDestroy() {
1463
1482
  ReferResource.prototype._onDestroy.call(this);
1464
1483
  this.texture.destroy();
1465
1484
  this.texture = null;
@@ -1966,6 +1985,7 @@ var Logger = {
1966
1985
  var fontAtlas = new FontAtlas(engine);
1967
1986
  var texture = new Texture2D(engine, 256, 256);
1968
1987
  fontAtlas.texture = texture;
1988
+ fontAtlas.isGCIgnored = texture.isGCIgnored = true;
1969
1989
  this._fontAtlases.push(fontAtlas);
1970
1990
  var nativeFontString = this.nativeFontString;
1971
1991
  engine.resourceManager.addContentRestorer(new /*#__PURE__*/ (function(ContentRestorer) {
@@ -2022,7 +2042,9 @@ var Logger = {
2022
2042
  subFontMap[key] = subFont;
2023
2043
  return subFont;
2024
2044
  };
2025
- _proto._onDestroy = function _onDestroy() {
2045
+ /**
2046
+ * @internal
2047
+ */ _proto._onDestroy = function _onDestroy() {
2026
2048
  ReferResource.prototype._onDestroy.call(this);
2027
2049
  var subFontMap = this._subFontMap;
2028
2050
  for(var k in subFontMap){
@@ -3241,7 +3263,9 @@ exports.GLCapabilityType = void 0;
3241
3263
  }
3242
3264
  }
3243
3265
  };
3244
- _proto._onDestroy = function _onDestroy() {
3266
+ /**
3267
+ * @internal
3268
+ */ _proto._onDestroy = function _onDestroy() {
3245
3269
  EngineObject.prototype._onDestroy.call(this);
3246
3270
  this._entity._removeComponent(this);
3247
3271
  if (this._entity.isActiveInHierarchy) {
@@ -5251,14 +5275,14 @@ SystemInfo._initialize();
5251
5275
  Keys[Keys[/** Tab or ⇥. */ "Tab"] = 63] = "Tab";
5252
5276
  Keys[Keys[/** Japanese: 変換 (henkan). */ "Convert"] = 64] = "Convert";
5253
5277
  Keys[Keys[/** Japanese: カタカナ/ひらがな/ローマ字 (katakana/hiragana/romaji). */ "KanaMode"] = 65] = "KanaMode";
5254
- Keys[Keys[/**
5255
- * Korean: HangulMode 한/영 (han/yeong).
5256
- * Japanese (Mac keyboard): かな (kana).
5257
- * */ "Lang1"] = 66] = "Lang1";
5258
5278
  Keys[Keys[/**
5259
- * Korean: Hanja 한자 (hanja).
5260
- * Japanese (Mac keyboard): 英数 (eisu).
5261
- */ "Lang2"] = 67] = "Lang2";
5279
+ * Korean: HangulMode 한/영 (han/yeong).
5280
+ * Japanese (Mac keyboard): かな (kana).
5281
+ * */ "Lang1"] = 66] = "Lang1";
5282
+ Keys[Keys[/**
5283
+ * Korean: Hanja 한자 (hanja).
5284
+ * Japanese (Mac keyboard): 英数 (eisu).
5285
+ */ "Lang2"] = 67] = "Lang2";
5262
5286
  Keys[Keys[/** Japanese (word-processing keyboard): Katakana. */ "Lang3"] = 68] = "Lang3";
5263
5287
  Keys[Keys[/** Japanese (word-processing keyboard): Hiragana. */ "Lang4"] = 69] = "Lang4";
5264
5288
  Keys[Keys[/** Japanese (word-processing keyboard): Zenkaku/Hankaku. */ "Lang5"] = 70] = "Lang5";
@@ -5275,46 +5299,46 @@ SystemInfo._initialize();
5275
5299
  Keys[Keys[/** → */ "ArrowRight"] = 81] = "ArrowRight";
5276
5300
  Keys[Keys[/** ↑ */ "ArrowUp"] = 82] = "ArrowUp";
5277
5301
  Keys[Keys[/** On the Mac, the "NumLock" code should be used for the numpad Clear key. */ "NumLock"] = 83] = "NumLock";
5278
- Keys[Keys[/**
5279
- * 0 Ins on a keyboard.
5280
- * 0 on a phone or remote control.
5281
- * */ "Numpad0"] = 84] = "Numpad0";
5282
5302
  Keys[Keys[/**
5283
- * 1 End on a keyboard.
5284
- * 1 or 1 QZ on a phone or remote control.
5285
- */ "Numpad1"] = 85] = "Numpad1";
5303
+ * 0 Ins on a keyboard.
5304
+ * 0 on a phone or remote control.
5305
+ * */ "Numpad0"] = 84] = "Numpad0";
5286
5306
  Keys[Keys[/**
5287
- * 2 on a keyboard.
5288
- * 2 ABC on a phone or remote control.
5289
- */ "Numpad2"] = 86] = "Numpad2";
5307
+ * 1 End on a keyboard.
5308
+ * 1 or 1 QZ on a phone or remote control.
5309
+ */ "Numpad1"] = 85] = "Numpad1";
5290
5310
  Keys[Keys[/**
5291
- * 3 PgDn on a keyboard.
5292
- * 3 DEF on a phone or remote control.
5293
- */ "Numpad3"] = 87] = "Numpad3";
5311
+ * 2 on a keyboard.
5312
+ * 2 ABC on a phone or remote control.
5313
+ */ "Numpad2"] = 86] = "Numpad2";
5294
5314
  Keys[Keys[/**
5295
- * 4 on a keyboard.
5296
- * 4 GHI on a phone or remote control.
5297
- */ "Numpad4"] = 88] = "Numpad4";
5315
+ * 3 PgDn on a keyboard.
5316
+ * 3 DEF on a phone or remote control.
5317
+ */ "Numpad3"] = 87] = "Numpad3";
5298
5318
  Keys[Keys[/**
5299
- * 5 on a keyboard.
5300
- * 5 JKL on a phone or remote control.
5301
- */ "Numpad5"] = 89] = "Numpad5";
5319
+ * 4 on a keyboard.
5320
+ * 4 GHI on a phone or remote control.
5321
+ */ "Numpad4"] = 88] = "Numpad4";
5302
5322
  Keys[Keys[/**
5303
- * 6 on a keyboard.
5304
- * 6 MNO on a phone or remote control.
5305
- */ "Numpad6"] = 90] = "Numpad6";
5323
+ * 5 on a keyboard.
5324
+ * 5 JKL on a phone or remote control.
5325
+ */ "Numpad5"] = 89] = "Numpad5";
5306
5326
  Keys[Keys[/**
5307
- * 7 Home on a keyboard.
5308
- * 7 PQRS or 7 PRS on a phone or remote control.
5309
- */ "Numpad7"] = 91] = "Numpad7";
5327
+ * 6 on a keyboard.
5328
+ * 6 MNO on a phone or remote control.
5329
+ */ "Numpad6"] = 90] = "Numpad6";
5310
5330
  Keys[Keys[/**
5311
- * 8 on a keyboard.
5312
- * 8 TUV on a phone or remote control.
5313
- */ "Numpad8"] = 92] = "Numpad8";
5331
+ * 7 Home on a keyboard.
5332
+ * 7 PQRS or 7 PRS on a phone or remote control.
5333
+ */ "Numpad7"] = 91] = "Numpad7";
5314
5334
  Keys[Keys[/**
5315
- * 9 PgUp on a keyboard.
5316
- * 9 WXYZ or 9 WXY on a phone or remote control.
5317
- */ "Numpad9"] = 93] = "Numpad9";
5335
+ * 8 on a keyboard.
5336
+ * 8 TUV on a phone or remote control.
5337
+ */ "Numpad8"] = 92] = "Numpad8";
5338
+ Keys[Keys[/**
5339
+ * 9 PgUp on a keyboard.
5340
+ * 9 WXYZ or 9 WXY on a phone or remote control.
5341
+ */ "Numpad9"] = 93] = "Numpad9";
5318
5342
  Keys[Keys[/** + */ "NumpadAdd"] = 94] = "NumpadAdd";
5319
5343
  Keys[Keys[/** Found on the Microsoft Natural Keyboard. */ "NumpadBackspace"] = 95] = "NumpadBackspace";
5320
5344
  Keys[Keys[/** C or AC (All Clear). Also for use with numpads that have a Clear key that is separate from the NumLock key. On the Mac, the numpad Clear key should always be encoded as "NumLock". */ "NumpadClear"] = 96] = "NumpadClear";
@@ -5330,16 +5354,16 @@ SystemInfo._initialize();
5330
5354
  Keys[Keys[/** MR Replace the current entry with the value stored in memory. */ "NumpadMemoryRecall"] = 106] = "NumpadMemoryRecall";
5331
5355
  Keys[Keys[/** MS Replace the value stored in memory with the current entry. */ "NumpadMemoryStore"] = 107] = "NumpadMemoryStore";
5332
5356
  Keys[Keys[/** M- Subtract current entry from the value stored in memory. */ "NumpadMemorySubtract"] = 108] = "NumpadMemorySubtract";
5333
- Keys[Keys[/**
5334
- * * on a keyboard. For use with numpads that provide mathematical operations (+, -, * and /).
5335
- * Use "NumpadStar" for the * key on phones and remote controls.
5336
- */ "NumpadMultiply"] = 109] = "NumpadMultiply";
5357
+ Keys[Keys[/**
5358
+ * * on a keyboard. For use with numpads that provide mathematical operations (+, -, * and /).
5359
+ * Use "NumpadStar" for the * key on phones and remote controls.
5360
+ */ "NumpadMultiply"] = 109] = "NumpadMultiply";
5337
5361
  Keys[Keys[/** ( Found on the Microsoft Natural Keyboard. */ "NumpadParenLeft"] = 110] = "NumpadParenLeft";
5338
5362
  Keys[Keys[/** ) Found on the Microsoft Natural Keyboard. */ "NumpadParenRight"] = 111] = "NumpadParenRight";
5339
5363
  Keys[Keys[/**
5340
- * * on a phone or remote control device. This key is typically found below the 7 key and to the left of the 0 key.
5341
- * Use "NumpadMultiply" for the * key on numeric keypads.
5342
- */ "NumpadStar"] = 112] = "NumpadStar";
5364
+ * * on a phone or remote control device. This key is typically found below the 7 key and to the left of the 0 key.
5365
+ * Use "NumpadMultiply" for the * key on numeric keypads.
5366
+ */ "NumpadStar"] = 112] = "NumpadStar";
5343
5367
  Keys[Keys[/** - */ "NumpadSubtract"] = 113] = "NumpadSubtract";
5344
5368
  Keys[Keys[/** Esc or ⎋. */ "Escape"] = 114] = "Escape";
5345
5369
  Keys[Keys[/** F1 */ "F1"] = 115] = "F1";
@@ -6014,7 +6038,9 @@ exports.Collider = /*#__PURE__*/ function(Component) {
6014
6038
  */ _proto._onDisable = function _onDisable() {
6015
6039
  this.engine.physicsManager._removeCollider(this);
6016
6040
  };
6017
- _proto._onDestroy = function _onDestroy() {
6041
+ /**
6042
+ * @internal
6043
+ */ _proto._onDestroy = function _onDestroy() {
6018
6044
  Component.prototype._onDestroy.call(this);
6019
6045
  this.clearShapes();
6020
6046
  this._nativeCollider.destroy();
@@ -7864,7 +7890,10 @@ exports.DynamicColliderConstraints = void 0;
7864
7890
  return _this;
7865
7891
  }
7866
7892
  var _proto = Light.prototype;
7867
- _proto._getLightColor = function _getLightColor() {
7893
+ /**
7894
+ * Light Color, include intensity.
7895
+ * @internal
7896
+ */ _proto._getLightIntensityColor = function _getLightIntensityColor() {
7868
7897
  this._lightColor.r = this.color.r * this.intensity;
7869
7898
  this._lightColor.g = this.color.g * this.intensity;
7870
7899
  this._lightColor.b = this.color.b * this.intensity;
@@ -7934,15 +7963,21 @@ __decorate([
7934
7963
  var cullingMaskStart = lightIndex * 2;
7935
7964
  var colorStart = lightIndex * 3;
7936
7965
  var directionStart = lightIndex * 3;
7937
- var lightColor = this._getLightColor();
7966
+ var lightColor = this._getLightIntensityColor();
7938
7967
  var direction = this.direction;
7939
7968
  var data = DirectLight._combinedData;
7940
7969
  var cullingMask = this.cullingMask;
7941
7970
  data.cullingMask[cullingMaskStart] = cullingMask & 65535;
7942
7971
  data.cullingMask[cullingMaskStart + 1] = cullingMask >>> 16 & 65535;
7943
- data.color[colorStart] = lightColor.r;
7944
- data.color[colorStart + 1] = lightColor.g;
7945
- data.color[colorStart + 2] = lightColor.b;
7972
+ if (this.engine.settings.colorSpace === exports.ColorSpace.Linear) {
7973
+ data.color[colorStart] = engineMath.Color.gammaToLinearSpace(lightColor.r);
7974
+ data.color[colorStart + 1] = engineMath.Color.gammaToLinearSpace(lightColor.g);
7975
+ data.color[colorStart + 2] = engineMath.Color.gammaToLinearSpace(lightColor.b);
7976
+ } else {
7977
+ data.color[colorStart] = lightColor.r;
7978
+ data.color[colorStart + 1] = lightColor.g;
7979
+ data.color[colorStart + 2] = lightColor.b;
7980
+ }
7946
7981
  data.direction[directionStart] = direction.x;
7947
7982
  data.direction[directionStart + 1] = direction.y;
7948
7983
  data.direction[directionStart + 2] = direction.z;
@@ -8031,15 +8066,21 @@ __decorate([
8031
8066
  var colorStart = lightIndex * 3;
8032
8067
  var positionStart = lightIndex * 3;
8033
8068
  var distanceStart = lightIndex;
8034
- var lightColor = this._getLightColor();
8069
+ var lightColor = this._getLightIntensityColor();
8035
8070
  var lightPosition = this.position;
8036
8071
  var data = PointLight._combinedData;
8037
8072
  var cullingMask = this.cullingMask;
8038
8073
  data.cullingMask[cullingMaskStart] = cullingMask & 65535;
8039
8074
  data.cullingMask[cullingMaskStart + 1] = cullingMask >>> 16 & 65535;
8040
- data.color[colorStart] = lightColor.r;
8041
- data.color[colorStart + 1] = lightColor.g;
8042
- data.color[colorStart + 2] = lightColor.b;
8075
+ if (this.engine.settings.colorSpace === exports.ColorSpace.Linear) {
8076
+ data.color[colorStart] = engineMath.Color.gammaToLinearSpace(lightColor.r);
8077
+ data.color[colorStart + 1] = engineMath.Color.gammaToLinearSpace(lightColor.g);
8078
+ data.color[colorStart + 2] = engineMath.Color.gammaToLinearSpace(lightColor.b);
8079
+ } else {
8080
+ data.color[colorStart] = lightColor.r;
8081
+ data.color[colorStart + 1] = lightColor.g;
8082
+ data.color[colorStart + 2] = lightColor.b;
8083
+ }
8043
8084
  data.position[positionStart] = lightPosition.x;
8044
8085
  data.position[positionStart + 1] = lightPosition.y;
8045
8086
  data.position[positionStart + 2] = lightPosition.z;
@@ -8132,16 +8173,22 @@ __decorate([
8132
8173
  var distanceStart = lightIndex;
8133
8174
  var penumbraCosStart = lightIndex;
8134
8175
  var angleCosStart = lightIndex;
8135
- var color = this._getLightColor();
8176
+ var lightColor = this._getLightIntensityColor();
8136
8177
  var position = this.position;
8137
8178
  var direction = this.direction;
8138
8179
  var data = SpotLight._combinedData;
8139
8180
  var cullingMask = this.cullingMask;
8140
8181
  data.cullingMask[cullingMaskStart] = cullingMask & 65535;
8141
8182
  data.cullingMask[cullingMaskStart + 1] = cullingMask >>> 16 & 65535;
8142
- data.color[colorStart] = color.r;
8143
- data.color[colorStart + 1] = color.g;
8144
- data.color[colorStart + 2] = color.b;
8183
+ if (this.engine.settings.colorSpace === exports.ColorSpace.Linear) {
8184
+ data.color[colorStart] = engineMath.Color.gammaToLinearSpace(lightColor.r);
8185
+ data.color[colorStart + 1] = engineMath.Color.gammaToLinearSpace(lightColor.g);
8186
+ data.color[colorStart + 2] = engineMath.Color.gammaToLinearSpace(lightColor.b);
8187
+ } else {
8188
+ data.color[colorStart] = lightColor.r;
8189
+ data.color[colorStart + 1] = lightColor.g;
8190
+ data.color[colorStart + 2] = lightColor.b;
8191
+ }
8145
8192
  data.position[positionStart] = position.x;
8146
8193
  data.position[positionStart + 1] = position.y;
8147
8194
  data.position[positionStart + 2] = position.z;
@@ -8784,6 +8831,7 @@ __decorate([
8784
8831
  _proto.cloneTo = function cloneTo(target) {
8785
8832
  CloneManager.deepCloneObject(this._macroCollection, target._macroCollection);
8786
8833
  Object.assign(target._macroMap, this._macroMap);
8834
+ var referCount = target._getReferCount();
8787
8835
  var propertyValueMap = this._propertyValueMap;
8788
8836
  var targetPropertyValueMap = target._propertyValueMap;
8789
8837
  var keys = Object.keys(propertyValueMap);
@@ -8795,6 +8843,7 @@ __decorate([
8795
8843
  targetPropertyValueMap[k] = property;
8796
8844
  } else if (_instanceof(property, Texture)) {
8797
8845
  targetPropertyValueMap[k] = property;
8846
+ referCount > 0 && property._addReferCount(referCount);
8798
8847
  } else if (_instanceof(property, Array) || _instanceof(property, Float32Array) || _instanceof(property, Int32Array)) {
8799
8848
  targetPropertyValueMap[k] = property.slice();
8800
8849
  } else {
@@ -9499,11 +9548,11 @@ var camera_declare = "#define GLSLIFY 1\nuniform vec3 camera_Position;"; // esli
9499
9548
 
9500
9549
  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);}\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
9501
9550
 
9502
- var common_vert = "#define GLSLIFY 1\nattribute vec3 POSITION;\n#ifdef RENDERER_HAS_UV\nattribute vec2 TEXCOORD_0;\n#endif\n#ifdef RENDERER_HAS_UV1\nattribute vec2 TEXCOORD_1;\n#endif\n#ifdef RENDERER_HAS_SKIN\nattribute vec4 JOINTS_0;attribute vec4 WEIGHTS_0;\n#ifdef RENDERER_USE_JOINT_TEXTURE\nuniform sampler2D renderer_JointSampler;uniform float renderer_JointCount;mat4 getJointMatrix(sampler2D smp,float index){float base=index/renderer_JointCount;float hf=0.5/renderer_JointCount;float v=base+hf;vec4 m0=texture2D(smp,vec2(0.125,v));vec4 m1=texture2D(smp,vec2(0.375,v));vec4 m2=texture2D(smp,vec2(0.625,v));vec4 m3=texture2D(smp,vec2(0.875,v));return mat4(m0,m1,m2,m3);}\n#else\nuniform mat4 renderer_JointMatrix[RENDERER_JOINTS_NUM];\n#endif\n#endif\n#ifdef RENDERER_HAS_VERTEXCOLOR\nattribute vec4 COLOR_0;\n#endif\n#include <transform_declare>\n#include <camera_declare>\nuniform vec4 material_TilingOffset;\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nattribute vec3 NORMAL;\n#endif\n#ifdef RENDERER_HAS_TANGENT\nattribute vec4 TANGENT;\n#endif\n#endif\n"; // eslint-disable-line
9551
+ var common_vert = "#define GLSLIFY 1\nattribute vec3 POSITION;\n#ifdef RENDERER_HAS_UV\nattribute vec2 TEXCOORD_0;\n#endif\n#ifdef RENDERER_HAS_UV1\nattribute vec2 TEXCOORD_1;\n#endif\n#ifdef RENDERER_HAS_SKIN\nattribute vec4 JOINTS_0;attribute vec4 WEIGHTS_0;\n#ifdef RENDERER_USE_JOINT_TEXTURE\nuniform sampler2D renderer_JointSampler;uniform float renderer_JointCount;mat4 getJointMatrix(sampler2D smp,float index){float base=index/renderer_JointCount;float hf=0.5/renderer_JointCount;float v=base+hf;vec4 m0=texture2D(smp,vec2(0.125,v));vec4 m1=texture2D(smp,vec2(0.375,v));vec4 m2=texture2D(smp,vec2(0.625,v));vec4 m3=texture2D(smp,vec2(0.875,v));return mat4(m0,m1,m2,m3);}\n#else\nuniform mat4 renderer_JointMatrix[RENDERER_JOINTS_NUM];\n#endif\n#endif\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nattribute vec4 COLOR_0;\n#endif\n#include <transform_declare>\n#include <camera_declare>\nuniform vec4 material_TilingOffset;\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nattribute vec3 NORMAL;\n#endif\n#ifdef RENDERER_HAS_TANGENT\nattribute vec4 TANGENT;\n#endif\n#endif\n"; // eslint-disable-line
9503
9552
 
9504
9553
  var transform_declare = "#define GLSLIFY 1\nuniform mat4 renderer_LocalMat;uniform mat4 renderer_ModelMat;uniform mat4 camera_ViewMat;uniform mat4 camera_ProjMat;uniform mat4 renderer_MVMat;uniform mat4 renderer_MVPMat;uniform mat4 renderer_NormalMat;"; // eslint-disable-line
9505
9554
 
9506
- var color_share = "#define GLSLIFY 1\n#ifdef RENDERER_HAS_VERTEXCOLOR\nvarying vec4 v_color;\n#endif\n"; // eslint-disable-line
9555
+ var color_share = "#define GLSLIFY 1\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nvarying vec4 v_color;\n#endif\n"; // eslint-disable-line
9507
9556
 
9508
9557
  var FogFragmentDeclaration = "#define GLSLIFY 1\n#if SCENE_FOG_MODE != 0\nvarying vec3 v_positionVS;uniform vec4 scene_FogColor;uniform vec4 scene_FogParams;float ComputeFogIntensity(float fogDepth){\n#if SCENE_FOG_MODE == 1\nreturn clamp(fogDepth*scene_FogParams.x+scene_FogParams.y,0.0,1.0);\n#elif SCENE_FOG_MODE == 2\nreturn clamp(exp2(-fogDepth*scene_FogParams.z),0.0,1.0);\n#elif SCENE_FOG_MODE == 3\nfloat factor=fogDepth*scene_FogParams.w;return clamp(exp2(-factor*factor),0.0,1.0);\n#endif\n}\n#endif\n"; // eslint-disable-line
9509
9558
 
@@ -9523,7 +9572,7 @@ var blendShape_input = "#define GLSLIFY 1\n#ifdef RENDERER_HAS_BLENDSHAPE\n#ifde
9523
9572
 
9524
9573
  var blendShape_vert = "#define GLSLIFY 1\n#ifdef RENDERER_HAS_BLENDSHAPE\n#ifdef RENDERER_BLENDSHAPE_USE_TEXTURE\nint vertexOffset=gl_VertexID*renderer_BlendShapeTextureInfo.x;for(int i=0;i<RENDERER_BLENDSHAPE_COUNT;i++){int vertexElementOffset=vertexOffset;float weight=renderer_BlendShapeWeights[i];position.xyz+=getBlendShapeVertexElement(i,vertexElementOffset)*weight;\n#ifndef MATERIAL_OMIT_NORMAL\n#if defined( RENDERER_HAS_NORMAL ) && defined( RENDERER_BLENDSHAPE_HAS_NORMAL )\nvertexElementOffset+=1;normal+=getBlendShapeVertexElement(i,vertexElementOffset)*weight;\n#endif\n#if defined( RENDERER_HAS_TANGENT ) && defined(RENDERER_BLENDSHAPE_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\nvertexElementOffset+=1;tangent.xyz+=getBlendShapeVertexElement(i,vertexElementOffset)*weight;\n#endif\n#endif\n}\n#else\nposition.xyz+=POSITION_BS0*renderer_BlendShapeWeights[0];position.xyz+=POSITION_BS1*renderer_BlendShapeWeights[1];\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) && defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nnormal+=NORMAL_BS0*renderer_BlendShapeWeights[0];normal+=NORMAL_BS1*renderer_BlendShapeWeights[1];\n#endif\n#if defined( RENDERER_HAS_TANGENT ) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\ntangent.xyz+=TANGENT_BS0*renderer_BlendShapeWeights[0];tangent.xyz+=TANGENT_BS1*renderer_BlendShapeWeights[1];\n#endif\n#endif\n#else\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) || defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\n#ifndef MATERIAL_OMIT_NORMAL\nposition.xyz+=POSITION_BS2*renderer_BlendShapeWeights[2];position.xyz+=POSITION_BS3*renderer_BlendShapeWeights[3];\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) && defined( RENDERER_HAS_NORMAL )\nnormal+=NORMAL_BS0*renderer_BlendShapeWeights[0];normal+=NORMAL_BS1*renderer_BlendShapeWeights[1];normal+=NORMAL_BS2*renderer_BlendShapeWeights[2];normal+=NORMAL_BS3*renderer_BlendShapeWeights[3];\n#endif\n#if defined(RENDERER_BLENDSHAPE_HAS_TANGENT) && defined( RENDERER_HAS_TANGENT ) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\ntangent.xyz+=TANGENT_BS0*renderer_BlendShapeWeights[0];tangent.xyz+=TANGENT_BS1*renderer_BlendShapeWeights[1];tangent.xyz+=TANGENT_BS2*renderer_BlendShapeWeights[2];tangent.xyz+=TANGENT_BS3*renderer_BlendShapeWeights[3];\n#endif\n#endif\n#else\nposition.xyz+=POSITION_BS2*renderer_BlendShapeWeights[2];position.xyz+=POSITION_BS3*renderer_BlendShapeWeights[3];position.xyz+=POSITION_BS4*renderer_BlendShapeWeights[4];position.xyz+=POSITION_BS5*renderer_BlendShapeWeights[5];position.xyz+=POSITION_BS6*renderer_BlendShapeWeights[6];position.xyz+=POSITION_BS7*renderer_BlendShapeWeights[7];\n#endif\n#endif\n#endif\n#endif\n"; // eslint-disable-line
9525
9574
 
9526
- var color_vert = "#define GLSLIFY 1\n#ifdef RENDERER_HAS_VERTEXCOLOR\nv_color=COLOR_0;\n#endif\n"; // eslint-disable-line
9575
+ var color_vert = "#define GLSLIFY 1\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nv_color=COLOR_0;\n#endif\n"; // eslint-disable-line
9527
9576
 
9528
9577
  var FogVertex = "#define GLSLIFY 1\n#if SCENE_FOG_MODE != 0\nvec4 positionVS=renderer_MVMat*position;v_positionVS=positionVS.xyz/positionVS.w;\n#endif\n"; // eslint-disable-line
9529
9578
 
@@ -9543,11 +9592,11 @@ var light_frag_define = "#define GLSLIFY 1\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nstr
9543
9592
 
9544
9593
  var mobile_material_frag = "#define GLSLIFY 1\nuniform vec4 material_EmissiveColor;uniform vec4 material_BaseColor;uniform vec4 material_SpecularColor;uniform float material_Shininess;uniform float material_NormalIntensity;uniform float material_AlphaCutoff;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nuniform sampler2D material_EmissiveTexture;\n#endif\n#ifdef MATERIAL_HAS_BASETEXTURE\nuniform sampler2D material_BaseTexture;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_TEXTURE\nuniform sampler2D material_SpecularTexture;\n#endif\n#ifdef MATERIAL_HAS_NORMALTEXTURE\nuniform sampler2D material_NormalTexture;\n#endif\n"; // eslint-disable-line
9545
9594
 
9546
- 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_HAS_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
9595
+ 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
9547
9596
 
9548
9597
  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
9549
9598
 
9550
- var mobile_blinnphong_frag = "#define GLSLIFY 1\n#ifdef MATERIAL_HAS_NORMALTEXTURE\nmat3 tbn=getTBN();vec3 N=getNormalByNormalTexture(tbn,material_NormalTexture,material_NormalIntensity,v_uv);\n#else\nvec3 N=getNormal();\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();int sunIndex=int(scene_ShadowInfo.z);\n#endif\nDirectLight directionalLight;for(int i=0;i<SCENE_DIRECT_LIGHT_COUNT;i++){if(isRendererCulledByLight(renderer_Layer.xy,scene_DirectLightCullingMask[i]))continue;directionalLight.color=scene_DirectLightColor[i];\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nif(i==sunIndex){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]))continue;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]))continue;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
9599
+ 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();int sunIndex=int(scene_ShadowInfo.z);\n#endif\nDirectLight directionalLight;for(int i=0;i<SCENE_DIRECT_LIGHT_COUNT;i++){if(isRendererCulledByLight(renderer_Layer.xy,scene_DirectLightCullingMask[i]))continue;directionalLight.color=scene_DirectLightColor[i];\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nif(i==sunIndex){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]))continue;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]))continue;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
9551
9600
 
9552
9601
  var noise_cellular = "#define GLSLIFY 1\n#include <noise_cellular_2D>\n#include <noise_cellular_3D>\n#include <noise_cellular_2x2>\n#include <noise_cellular_2x2x2>\n"; // eslint-disable-line
9553
9602
 
@@ -9581,9 +9630,9 @@ var noise_simplex_3D_grad = "#define GLSLIFY 1\nfloat simplex(vec3 v,out vec3 gr
9581
9630
 
9582
9631
  var noise_simplex_4D = "#define GLSLIFY 1\nvec4 grad4(float j,vec4 ip){const vec4 ones=vec4(1.0,1.0,1.0,-1.0);vec4 p,s;p.xyz=floor(fract(vec3(j)*ip.xyz)*7.0)*ip.z-1.0;p.w=1.5-dot(abs(p.xyz),ones.xyz);s=vec4(lessThan(p,vec4(0.0)));p.xyz=p.xyz+(s.xyz*2.0-1.0)*s.www;return p;}\n#define F4 0.309016994374947451\nfloat simplex(vec4 v){const vec4 C=vec4(0.138196601125011,0.276393202250021,0.414589803375032,-0.447213595499958);vec4 i=floor(v+dot(v,vec4(F4)));vec4 x0=v-i+dot(i,C.xxxx);vec4 i0;vec3 isX=step(x0.yzw,x0.xxx);vec3 isYZ=step(x0.zww,x0.yyz);i0.x=isX.x+isX.y+isX.z;i0.yzw=1.0-isX;i0.y+=isYZ.x+isYZ.y;i0.zw+=1.0-isYZ.xy;i0.z+=isYZ.z;i0.w+=1.0-isYZ.z;vec4 i3=clamp(i0,0.0,1.0);vec4 i2=clamp(i0-1.0,0.0,1.0);vec4 i1=clamp(i0-2.0,0.0,1.0);vec4 x1=x0-i1+C.xxxx;vec4 x2=x0-i2+C.yyyy;vec4 x3=x0-i3+C.zzzz;vec4 x4=x0+C.wwww;i=mod289(i);float j0=permute(permute(permute(permute(i.w)+i.z)+i.y)+i.x);vec4 j1=permute(permute(permute(permute(i.w+vec4(i1.w,i2.w,i3.w,1.0))+i.z+vec4(i1.z,i2.z,i3.z,1.0))+i.y+vec4(i1.y,i2.y,i3.y,1.0))+i.x+vec4(i1.x,i2.x,i3.x,1.0));vec4 ip=vec4(1.0/294.0,1.0/49.0,1.0/7.0,0.0);vec4 p0=grad4(j0,ip);vec4 p1=grad4(j1.x,ip);vec4 p2=grad4(j1.y,ip);vec4 p3=grad4(j1.z,ip);vec4 p4=grad4(j1.w,ip);vec4 norm=taylorInvSqrt(vec4(dot(p0,p0),dot(p1,p1),dot(p2,p2),dot(p3,p3)));p0*=norm.x;p1*=norm.y;p2*=norm.z;p3*=norm.w;p4*=taylorInvSqrt(dot(p4,p4));vec3 m0=max(0.6-vec3(dot(x0,x0),dot(x1,x1),dot(x2,x2)),0.0);vec2 m1=max(0.6-vec2(dot(x3,x3),dot(x4,x4)),0.0);m0=m0*m0;m1=m1*m1;return 49.0*(dot(m0*m0,vec3(dot(p0,x0),dot(p1,x1),dot(p2,x2)))+dot(m1*m1,vec2(dot(p3,x3),dot(p4,x4))));}"; // eslint-disable-line
9583
9632
 
9584
- var pbr_frag_define = "#define GLSLIFY 1\nuniform float material_AlphaCutoff;uniform vec4 material_BaseColor;uniform float material_Metal;uniform float material_Roughness;uniform vec3 material_PBRSpecularColor;uniform float material_Glossiness;uniform vec3 material_EmissiveColor;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nuniform float material_ClearCoat;uniform float material_ClearCoatRoughness;\n#endif\nuniform float material_NormalIntensity;uniform float material_OcclusionIntensity;uniform float material_OcclusionTextureCoord;\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_HAS_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\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\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};struct Material{vec3 diffuseColor;float roughness;vec3 specularColor;float opacity;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nfloat clearCoat;float clearCoatRoughness;\n#endif\n};"; // eslint-disable-line
9633
+ var pbr_frag_define = "#define GLSLIFY 1\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;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nuniform float material_ClearCoat;uniform float material_ClearCoatRoughness;\n#endif\nuniform float material_NormalIntensity;uniform float material_OcclusionIntensity;uniform float material_OcclusionTextureCoord;\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\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\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};struct Material{vec3 diffuseColor;float roughness;vec3 specularColor;float opacity;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nfloat clearCoat;float clearCoatRoughness;\n#endif\n};"; // eslint-disable-line
9585
9634
 
9586
- 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 0.04+max(max(dxy.x,dxy.y),dxy.z);\n#else\nreturn 0.04;\n#endif\n}void initGeometry(out Geometry geometry){geometry.position=v_pos;geometry.viewDir=normalize(camera_Position-v_pos);\n#if defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE)\nmat3 tbn=getTBN();\n#endif\n#ifdef MATERIAL_HAS_NORMALTEXTURE\ngeometry.normal=getNormalByNormalTexture(tbn,material_NormalTexture,material_NormalIntensity,v_uv);\n#else\ngeometry.normal=getNormal();\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);\n#else\ngeometry.clearCoatNormal=getNormal();\n#endif\ngeometry.clearCoatDotNV=saturate(dot(geometry.clearCoatNormal,geometry.viewDir));\n#endif\n}void initMaterial(out Material material,const in 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;\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_HAS_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(0.04),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}\n#include <brdf>\n#include <direct_irradiance_frag_define>\n#include <ibl_frag_define>\n"; // eslint-disable-line
9635
+ 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 0.04+max(max(dxy.x,dxy.y),dxy.z);\n#else\nreturn 0.04;\n#endif\n}void 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)\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}void initMaterial(out Material material,const in 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));\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}\n#include <brdf>\n#include <direct_irradiance_frag_define>\n#include <ibl_frag_define>\n"; // eslint-disable-line
9587
9636
 
9588
9637
  var brdf = "#define GLSLIFY 1\nfloat F_Schlick(float dotLH){return 0.04+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);}float 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);}vec3 BRDF_Specular_GGX(vec3 incidentDirection,vec3 viewDir,vec3 normal,vec3 specularColor,float roughness){float alpha=pow2(roughness);vec3 halfDir=normalize(incidentDirection+viewDir);float dotNL=saturate(dot(normal,incidentDirection));float dotNV=saturate(dot(normal,viewDir));float dotNH=saturate(dot(normal,halfDir));float dotLH=saturate(dot(incidentDirection,halfDir));vec3 F=F_Schlick(specularColor,dotLH);float G=G_GGX_SmithCorrelated(alpha,dotNL,dotNV);float D=D_GGX(alpha,dotNH);return F*(G*D);}vec3 BRDF_Diffuse_Lambert(vec3 diffuseColor){return RECIPROCAL_PI*diffuseColor;}"; // eslint-disable-line
9589
9638
 
@@ -9591,7 +9640,7 @@ var direct_irradiance_frag_define = "#define GLSLIFY 1\n#include <ShadowFragment
9591
9640
 
9592
9641
  var ibl_frag_define = "#define GLSLIFY 1\nvec3 getLightProbeIrradiance(vec3 sh[9],vec3 normal){normal.x=-normal.x;vec3 result=sh[0]+sh[1]*(normal.y)+sh[2]*(normal.z)+sh[3]*(normal.x)+sh[4]*(normal.y*normal.x)+sh[5]*(normal.y*normal.z)+sh[6]*(3.0*normal.z*normal.z-1.0)+sh[7]*(normal.z*normal.x)+sh[8]*(normal.x*normal.x-normal.y*normal.y);return max(result,vec3(0.0));}vec3 envBRDFApprox(vec3 specularColor,float roughness,float dotNV){const vec4 c0=vec4(-1,-0.0275,-0.572,0.022);const vec4 c1=vec4(1,0.0425,1.04,-0.04);vec4 r=roughness*c0+c1;float a004=min(r.x*r.x,exp2(-9.28*dotNV))*r.x+r.y;vec2 AB=vec2(-1.04,1.04)*a004+r.zw;return specularColor*AB.x+AB.y;}float getSpecularMIPLevel(float roughness,int maxMIPLevel){return roughness*float(maxMIPLevel);}vec3 getLightProbeRadiance(vec3 viewDir,vec3 normal,float roughness,int maxMIPLevel,float specularIntensity){\n#ifndef SCENE_USE_SPECULAR_ENV\nreturn vec3(0);\n#else\nvec3 reflectVec=reflect(-viewDir,normal);reflectVec.x=-reflectVec.x;float specularMIPLevel=getSpecularMIPLevel(roughness,maxMIPLevel);\n#ifdef HAS_TEX_LOD\nvec4 envMapColor=textureCubeLodEXT(scene_EnvSpecularSampler,reflectVec,specularMIPLevel);\n#else\nvec4 envMapColor=textureCube(scene_EnvSpecularSampler,reflectVec,specularMIPLevel);\n#endif\n#ifdef SCENE_IS_DECODE_ENV_RGBM\nenvMapColor.rgb=RGBMToLinear(envMapColor,5.0).rgb;\n#ifdef ENGINE_IS_COLORSPACE_GAMMA\nenvMapColor=linearToGamma(envMapColor);\n#endif\n#else\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nenvMapColor=gammaToLinear(envMapColor);\n#endif\n#endif\nreturn envMapColor.rgb*specularIntensity;\n#endif\n}"; // eslint-disable-line
9593
9642
 
9594
- var pbr_frag = "#define GLSLIFY 1\nGeometry geometry;Material material;ReflectedLight reflectedLight=ReflectedLight(vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0));initGeometry(geometry);initMaterial(material,geometry);addTotalDirectRadiance(geometry,material,reflectedLight);\n#ifdef SCENE_USE_SH\nvec3 irradiance=getLightProbeIrradiance(scene_EnvSH,geometry.normal);\n#ifdef ENGINE_IS_COLORSPACE_GAMMA\nirradiance=linearToGamma(vec4(irradiance,1.0)).rgb;\n#endif\nirradiance*=scene_EnvMapLight.diffuseIntensity;\n#else\nvec3 irradiance=scene_EnvMapLight.diffuse*scene_EnvMapLight.diffuseIntensity;irradiance*=PI;\n#endif\nreflectedLight.indirectDiffuse+=irradiance*BRDF_Diffuse_Lambert(material.diffuseColor);vec3 radiance=getLightProbeRadiance(geometry.viewDir,geometry.normal,material.roughness,int(scene_EnvMapLight.mipMapLevel),scene_EnvMapLight.specularIntensity);float radianceAttenuation=1.0;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nvec3 clearCoatRadiance=getLightProbeRadiance(geometry.viewDir,geometry.clearCoatNormal,material.clearCoatRoughness,int(scene_EnvMapLight.mipMapLevel),scene_EnvMapLight.specularIntensity);reflectedLight.indirectSpecular+=clearCoatRadiance*material.clearCoat*envBRDFApprox(vec3(0.04),material.clearCoatRoughness,geometry.clearCoatDotNV);radianceAttenuation-=material.clearCoat*F_Schlick(geometry.clearCoatDotNV);\n#endif\nreflectedLight.indirectSpecular+=radianceAttenuation*radiance*envBRDFApprox(material.specularColor,material.roughness,geometry.dotNV);\n#ifdef MATERIAL_HAS_OCCLUSION_TEXTURE\nvec2 aoUV=v_uv;\n#ifdef RENDERER_HAS_UV1\nif(material_OcclusionTextureCoord==1.0){aoUV=v_uv1;}\n#endif\nfloat ambientOcclusion=(texture2D(material_OcclusionTexture,aoUV).r-1.0)*material_OcclusionIntensity+1.0;reflectedLight.indirectDiffuse*=ambientOcclusion;\n#ifdef SCENE_USE_SPECULAR_ENV\nreflectedLight.indirectSpecular*=computeSpecularOcclusion(ambientOcclusion,material.roughness,geometry.dotNV);\n#endif\n#endif\nvec3 emissiveRadiance=material_EmissiveColor;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nvec4 emissiveColor=texture2D(material_EmissiveTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nemissiveColor=gammaToLinear(emissiveColor);\n#endif\nemissiveRadiance*=emissiveColor.rgb;\n#endif\nvec3 totalRadiance=reflectedLight.directDiffuse+reflectedLight.indirectDiffuse+reflectedLight.directSpecular+reflectedLight.indirectSpecular+emissiveRadiance;vec4 targetColor=vec4(totalRadiance,material.opacity);gl_FragColor=targetColor;"; // eslint-disable-line
9643
+ var pbr_frag = "#define GLSLIFY 1\nGeometry geometry;Material material;ReflectedLight reflectedLight=ReflectedLight(vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0));initGeometry(geometry,gl_FrontFacing);initMaterial(material,geometry);addTotalDirectRadiance(geometry,material,reflectedLight);\n#ifdef SCENE_USE_SH\nvec3 irradiance=getLightProbeIrradiance(scene_EnvSH,geometry.normal);\n#ifdef ENGINE_IS_COLORSPACE_GAMMA\nirradiance=linearToGamma(vec4(irradiance,1.0)).rgb;\n#endif\nirradiance*=scene_EnvMapLight.diffuseIntensity;\n#else\nvec3 irradiance=scene_EnvMapLight.diffuse*scene_EnvMapLight.diffuseIntensity;irradiance*=PI;\n#endif\nreflectedLight.indirectDiffuse+=irradiance*BRDF_Diffuse_Lambert(material.diffuseColor);vec3 radiance=getLightProbeRadiance(geometry.viewDir,geometry.normal,material.roughness,int(scene_EnvMapLight.mipMapLevel),scene_EnvMapLight.specularIntensity);float radianceAttenuation=1.0;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nvec3 clearCoatRadiance=getLightProbeRadiance(geometry.viewDir,geometry.clearCoatNormal,material.clearCoatRoughness,int(scene_EnvMapLight.mipMapLevel),scene_EnvMapLight.specularIntensity);reflectedLight.indirectSpecular+=clearCoatRadiance*material.clearCoat*envBRDFApprox(vec3(0.04),material.clearCoatRoughness,geometry.clearCoatDotNV);radianceAttenuation-=material.clearCoat*F_Schlick(geometry.clearCoatDotNV);\n#endif\nreflectedLight.indirectSpecular+=radianceAttenuation*radiance*envBRDFApprox(material.specularColor,material.roughness,geometry.dotNV);\n#ifdef MATERIAL_HAS_OCCLUSION_TEXTURE\nvec2 aoUV=v_uv;\n#ifdef RENDERER_HAS_UV1\nif(material_OcclusionTextureCoord==1.0){aoUV=v_uv1;}\n#endif\nfloat ambientOcclusion=(texture2D(material_OcclusionTexture,aoUV).r-1.0)*material_OcclusionIntensity+1.0;reflectedLight.indirectDiffuse*=ambientOcclusion;\n#ifdef SCENE_USE_SPECULAR_ENV\nreflectedLight.indirectSpecular*=computeSpecularOcclusion(ambientOcclusion,material.roughness,geometry.dotNV);\n#endif\n#endif\nvec3 emissiveRadiance=material_EmissiveColor;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nvec4 emissiveColor=texture2D(material_EmissiveTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nemissiveColor=gammaToLinear(emissiveColor);\n#endif\nemissiveRadiance*=emissiveColor.rgb;\n#endif\nvec3 totalRadiance=reflectedLight.directDiffuse+reflectedLight.indirectDiffuse+reflectedLight.directSpecular+reflectedLight.indirectSpecular+emissiveRadiance;vec4 targetColor=vec4(totalRadiance,material.opacity);gl_FragColor=targetColor;"; // eslint-disable-line
9595
9644
 
9596
9645
  var PBRShaderLib = {
9597
9646
  pbr_frag_define: pbr_frag_define,
@@ -9620,7 +9669,7 @@ var ShadowLib = {
9620
9669
  ShadowVertex: ShadowVertex
9621
9670
  };
9622
9671
 
9623
- var normal_get = "#define GLSLIFY 1\nvec3 getNormal(){\n#ifdef RENDERER_HAS_NORMAL\nvec3 normal=normalize(v_normal);\n#elif defined(HAS_DERIVATIVES)\nvec3 pos_dx=dFdx(v_pos);vec3 pos_dy=dFdy(v_pos);vec3 normal=normalize(cross(pos_dx,pos_dy));\n#else\nvec3 normal=vec3(0,0,1);\n#endif\nnormal*=float(gl_FrontFacing)*2.0-1.0;return normal;}vec3 getNormalByNormalTexture(mat3 tbn,sampler2D normalTexture,float normalIntensity,vec2 uv){vec3 normal=texture2D(normalTexture,uv).rgb;normal=normalize(tbn*((2.0*normal-1.0)*vec3(normalIntensity,normalIntensity,1.0)));normal*=float(gl_FrontFacing)*2.0-1.0;return normal;}mat3 getTBN(){\n#if defined(RENDERER_HAS_NORMAL) && defined(RENDERER_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\nmat3 tbn=v_TBN;\n#else\nvec3 normal=getNormal();vec3 position=v_pos;vec2 uv=gl_FrontFacing? v_uv:-v_uv;\n#ifdef HAS_DERIVATIVES\nvec3 dp1=dFdx(position);vec3 dp2=dFdy(position);vec2 duv1=dFdx(uv);vec2 duv2=dFdy(uv);vec3 dp2perp=cross(dp2,normal);vec3 dp1perp=cross(normal,dp1);vec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;vec3 binormal=dp2perp*duv1.y+dp1perp*duv2.y;float invmax=inversesqrt(max(dot(tangent,tangent),dot(binormal,binormal)));mat3 tbn=mat3(tangent*invmax,binormal*invmax,normal);\n#else\nmat3 tbn=mat3(vec3(0.0),vec3(0.0),normal);\n#endif\n#endif\nreturn tbn;}"; // eslint-disable-line
9672
+ var normal_get = "#define GLSLIFY 1\nvec3 getNormal(bool isFrontFacing){\n#ifdef RENDERER_HAS_NORMAL\nvec3 normal=normalize(v_normal);\n#elif defined(HAS_DERIVATIVES)\nvec3 pos_dx=dFdx(v_pos);vec3 pos_dy=dFdy(v_pos);vec3 normal=normalize(cross(pos_dx,pos_dy));\n#else\nvec3 normal=vec3(0,0,1);\n#endif\nnormal*=float(isFrontFacing)*2.0-1.0;return normal;}vec3 getNormalByNormalTexture(mat3 tbn,sampler2D normalTexture,float normalIntensity,vec2 uv,bool isFrontFacing){vec3 normal=texture2D(normalTexture,uv).rgb;normal=normalize(tbn*((2.0*normal-1.0)*vec3(normalIntensity,normalIntensity,1.0)));normal*=float(isFrontFacing)*2.0-1.0;return normal;}mat3 getTBN(bool isFrontFacing){\n#if defined(RENDERER_HAS_NORMAL) && defined(RENDERER_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\nmat3 tbn=v_TBN;\n#else\nvec3 normal=getNormal(isFrontFacing);vec3 position=v_pos;vec2 uv=isFrontFacing? v_uv:-v_uv;\n#ifdef HAS_DERIVATIVES\nvec3 dp1=dFdx(position);vec3 dp2=dFdy(position);vec2 duv1=dFdx(uv);vec2 duv2=dFdy(uv);vec3 dp2perp=cross(dp2,normal);vec3 dp1perp=cross(normal,dp1);vec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;vec3 binormal=dp2perp*duv1.y+dp1perp*duv2.y;float invmax=inversesqrt(max(dot(tangent,tangent),dot(binormal,binormal)));mat3 tbn=mat3(tangent*invmax,binormal*invmax,normal);\n#else\nmat3 tbn=mat3(vec3(0.0),vec3(0.0),normal);\n#endif\n#endif\nreturn tbn;}"; // eslint-disable-line
9624
9673
 
9625
9674
  var ShaderLib = _extends({
9626
9675
  common: common,
@@ -10771,6 +10820,14 @@ exports.Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
10771
10820
  };
10772
10821
  /**
10773
10822
  * @internal
10823
+ */ _proto._cloneTo = function _cloneTo(target) {
10824
+ var materials = this._materials;
10825
+ for(var i = 0, n = materials.length; i < n; i++){
10826
+ target._setMaterial(i, materials[i]);
10827
+ }
10828
+ };
10829
+ /**
10830
+ * @internal
10774
10831
  */ _proto._onDestroy = function _onDestroy() {
10775
10832
  Component.prototype._onDestroy.call(this);
10776
10833
  this.entity.transform._updateFlagManager.removeListener(this._onTransformChanged);
@@ -10781,14 +10838,18 @@ exports.Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
10781
10838
  (_materials_i = materials[i]) == null ? void 0 : _materials_i._addReferCount(-1);
10782
10839
  }
10783
10840
  };
10784
- _proto._updateShaderData = function _updateShaderData(context) {
10841
+ /**
10842
+ * @internal
10843
+ */ _proto._updateShaderData = function _updateShaderData(context) {
10785
10844
  var entity = this.entity;
10786
10845
  var worldMatrix = entity.transform.worldMatrix;
10787
10846
  this._updateTransformShaderData(context, worldMatrix);
10788
10847
  var layer = entity.layer;
10789
10848
  this._rendererLayer.set(layer & 65535, layer >>> 16 & 65535, 0, 0);
10790
10849
  };
10791
- _proto._updateTransformShaderData = function _updateTransformShaderData(context, worldMatrix) {
10850
+ /**
10851
+ * @internal
10852
+ */ _proto._updateTransformShaderData = function _updateTransformShaderData(context, worldMatrix) {
10792
10853
  var shaderData = this.shaderData;
10793
10854
  var virtualCamera = context.virtualCamera;
10794
10855
  var mvMatrix = this._mvMatrix;
@@ -10807,14 +10868,22 @@ exports.Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
10807
10868
  shaderData.setMatrix(exports.Renderer._mvInvMatrixProperty, mvInvMatrix);
10808
10869
  shaderData.setMatrix(exports.Renderer._normalMatrixProperty, normalMatrix);
10809
10870
  };
10810
- _proto._registerEntityTransformListener = function _registerEntityTransformListener() {
10871
+ /**
10872
+ * @internal
10873
+ */ _proto._registerEntityTransformListener = function _registerEntityTransformListener() {
10811
10874
  this.entity.transform._updateFlagManager.addListener(this._onTransformChanged);
10812
10875
  };
10813
- _proto._updateBounds = function _updateBounds(worldBounds) {};
10814
- _proto._render = function _render(context) {
10876
+ /**
10877
+ * @internal
10878
+ */ _proto._updateBounds = function _updateBounds(worldBounds) {};
10879
+ /**
10880
+ * @internal
10881
+ */ _proto._render = function _render(context) {
10815
10882
  throw "not implement";
10816
10883
  };
10817
- _proto._createInstanceMaterial = function _createInstanceMaterial(material, index) {
10884
+ /**
10885
+ * @internal
10886
+ */ _proto._createInstanceMaterial = function _createInstanceMaterial(material, index) {
10818
10887
  var insMaterial = material.clone();
10819
10888
  insMaterial.name = insMaterial.name + "(Instance)";
10820
10889
  material._addReferCount(-1);
@@ -10837,7 +10906,9 @@ exports.Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
10837
10906
  materials[index] = material;
10838
10907
  }
10839
10908
  };
10840
- _proto._onTransformChanged = function _onTransformChanged(type) {
10909
+ /**
10910
+ * @internal
10911
+ */ _proto._onTransformChanged = function _onTransformChanged(type) {
10841
10912
  this._dirtyUpdateFlag |= 0x1;
10842
10913
  };
10843
10914
  _create_class(Renderer1, [
@@ -10950,7 +11021,7 @@ __decorate([
10950
11021
  ignoreClone
10951
11022
  ], exports.Renderer.prototype, "_overrideUpdate", void 0);
10952
11023
  __decorate([
10953
- shallowClone
11024
+ ignoreClone
10954
11025
  ], exports.Renderer.prototype, "_materials", void 0);
10955
11026
  __decorate([
10956
11027
  ignoreClone
@@ -11144,8 +11215,10 @@ SimpleSpriteAssembler = __decorate([
11144
11215
  _this = Renderer.call(this, entity) || this;
11145
11216
  /** The mask layers the sprite mask influence to. */ _this.influenceLayers = exports.SpriteMaskLayer.Everything;
11146
11217
  _this._sprite = null;
11147
- _this._width = undefined;
11148
- _this._height = undefined;
11218
+ _this._automaticWidth = 0;
11219
+ _this._automaticHeight = 0;
11220
+ _this._customWidth = undefined;
11221
+ _this._customHeight = undefined;
11149
11222
  _this._flipX = false;
11150
11223
  _this._flipY = false;
11151
11224
  _this._alphaCutoff = 0.5;
@@ -11160,30 +11233,33 @@ SimpleSpriteAssembler = __decorate([
11160
11233
  /**
11161
11234
  * @internal
11162
11235
  */ _proto._cloneTo = function _cloneTo(target) {
11236
+ Renderer.prototype._cloneTo.call(this, target);
11163
11237
  target.sprite = this._sprite;
11164
11238
  };
11165
- _proto._updateBounds = function _updateBounds(worldBounds) {
11166
- var _this_sprite;
11167
- if (!((_this_sprite = this.sprite) == null ? void 0 : _this_sprite.texture) || !this.width || !this.height) {
11239
+ /**
11240
+ * @internal
11241
+ */ _proto._updateBounds = function _updateBounds(worldBounds) {
11242
+ if (this.sprite) {
11243
+ SimpleSpriteAssembler.updatePositions(this);
11244
+ } else {
11168
11245
  worldBounds.min.set(0, 0, 0);
11169
11246
  worldBounds.max.set(0, 0, 0);
11170
- } else {
11171
- SimpleSpriteAssembler.updatePositions(this);
11172
11247
  }
11173
11248
  };
11174
11249
  /**
11250
+ * @internal
11175
11251
  * @inheritdoc
11176
11252
  */ _proto._render = function _render(context) {
11177
11253
  var _this_sprite;
11178
11254
  if (!((_this_sprite = this.sprite) == null ? void 0 : _this_sprite.texture) || !this.width || !this.height) {
11179
11255
  return;
11180
11256
  }
11181
- // Update position.
11257
+ // Update position
11182
11258
  if (this._dirtyUpdateFlag & RendererUpdateFlags.WorldVolume) {
11183
11259
  SimpleSpriteAssembler.updatePositions(this);
11184
11260
  this._dirtyUpdateFlag &= ~RendererUpdateFlags.WorldVolume;
11185
11261
  }
11186
- // Update uv.
11262
+ // Update uv
11187
11263
  if (this._dirtyUpdateFlag & 0x2) {
11188
11264
  SimpleSpriteAssembler.updateUVs(this);
11189
11265
  this._dirtyUpdateFlag &= ~0x2;
@@ -11197,19 +11273,39 @@ SimpleSpriteAssembler = __decorate([
11197
11273
  this._maskElement = renderElement;
11198
11274
  };
11199
11275
  /**
11276
+ * @internal
11200
11277
  * @inheritdoc
11201
11278
  */ _proto._onDestroy = function _onDestroy() {
11202
- var _this__sprite;
11203
11279
  Renderer.prototype._onDestroy.call(this);
11204
- (_this__sprite = this._sprite) == null ? void 0 : _this__sprite._updateFlagManager.removeListener(this._onSpriteChange);
11280
+ var sprite = this._sprite;
11281
+ if (sprite) {
11282
+ sprite._addReferCount(-1);
11283
+ sprite._updateFlagManager.removeListener(this._onSpriteChange);
11284
+ }
11205
11285
  this._sprite = null;
11206
11286
  this._verticesData = null;
11207
11287
  };
11288
+ _proto._calDefaultSize = function _calDefaultSize() {
11289
+ var sprite = this._sprite;
11290
+ if (sprite) {
11291
+ this._automaticWidth = sprite.width;
11292
+ this._automaticHeight = sprite.height;
11293
+ } else {
11294
+ this._automaticWidth = this._automaticHeight = 0;
11295
+ }
11296
+ this._dirtyUpdateFlag &= ~0x4;
11297
+ };
11208
11298
  _proto._onSpriteChange = function _onSpriteChange(type) {
11209
11299
  switch(type){
11210
11300
  case SpriteModifyFlags.texture:
11211
11301
  this.shaderData.setTexture(SpriteMask._textureProperty, this.sprite.texture);
11212
11302
  break;
11303
+ case SpriteModifyFlags.size:
11304
+ this._dirtyUpdateFlag |= 0x4;
11305
+ if (this._customWidth === undefined || this._customHeight === undefined) {
11306
+ this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
11307
+ }
11308
+ break;
11213
11309
  case SpriteModifyFlags.region:
11214
11310
  case SpriteModifyFlags.atlasRegionOffset:
11215
11311
  this._dirtyUpdateFlag |= 0x3;
@@ -11217,22 +11313,31 @@ SimpleSpriteAssembler = __decorate([
11217
11313
  case SpriteModifyFlags.atlasRegion:
11218
11314
  this._dirtyUpdateFlag |= 0x2;
11219
11315
  break;
11316
+ case SpriteModifyFlags.pivot:
11317
+ this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
11318
+ break;
11220
11319
  }
11221
11320
  };
11222
11321
  _create_class(SpriteMask, [
11223
11322
  {
11224
11323
  key: "width",
11225
11324
  get: /**
11226
- * Render width.
11325
+ * Render width (in world coordinates).
11326
+ *
11327
+ * @remarks
11328
+ * If width is set, return the set value,
11329
+ * otherwise return `SpriteMask.sprite.width`.
11227
11330
  */ function get() {
11228
- if (this._width === undefined && this._sprite) {
11229
- this.width = this._sprite.width;
11331
+ if (this._customWidth !== undefined) {
11332
+ return this._customWidth;
11333
+ } else {
11334
+ this._dirtyUpdateFlag & 0x4 && this._calDefaultSize();
11335
+ return this._automaticWidth;
11230
11336
  }
11231
- return this._width;
11232
11337
  },
11233
11338
  set: function set(value) {
11234
- if (this._width !== value) {
11235
- this._width = value;
11339
+ if (this._customWidth !== value) {
11340
+ this._customWidth = value;
11236
11341
  this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
11237
11342
  }
11238
11343
  }
@@ -11240,16 +11345,22 @@ SimpleSpriteAssembler = __decorate([
11240
11345
  {
11241
11346
  key: "height",
11242
11347
  get: /**
11243
- * Render height.
11348
+ * Render height (in world coordinates).
11349
+ *
11350
+ * @remarks
11351
+ * If height is set, return the set value,
11352
+ * otherwise return `SpriteMask.sprite.height`.
11244
11353
  */ function get() {
11245
- if (this._height === undefined && this._sprite) {
11246
- this.height = this._sprite.height;
11354
+ if (this._customHeight !== undefined) {
11355
+ return this._customHeight;
11356
+ } else {
11357
+ this._dirtyUpdateFlag & 0x4 && this._calDefaultSize();
11358
+ return this._automaticHeight;
11247
11359
  }
11248
- return this._height;
11249
11360
  },
11250
11361
  set: function set(value) {
11251
- if (this._height !== value) {
11252
- this._height = value;
11362
+ if (this._customHeight !== value) {
11363
+ this._customHeight = value;
11253
11364
  this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
11254
11365
  }
11255
11366
  }
@@ -11292,10 +11403,14 @@ SimpleSpriteAssembler = __decorate([
11292
11403
  set: function set(value) {
11293
11404
  var lastSprite = this._sprite;
11294
11405
  if (lastSprite !== value) {
11295
- lastSprite && lastSprite._updateFlagManager.removeListener(this._onSpriteChange);
11406
+ if (lastSprite) {
11407
+ lastSprite._addReferCount(-1);
11408
+ lastSprite._updateFlagManager.removeListener(this._onSpriteChange);
11409
+ }
11410
+ this._dirtyUpdateFlag |= 0x7;
11296
11411
  if (value) {
11412
+ value._addReferCount(1);
11297
11413
  value._updateFlagManager.addListener(this._onSpriteChange);
11298
- this._dirtyUpdateFlag |= 0x3;
11299
11414
  this.shaderData.setTexture(SpriteMask._textureProperty, value.texture);
11300
11415
  } else {
11301
11416
  this.shaderData.setTexture(SpriteMask._textureProperty, null);
@@ -11335,10 +11450,16 @@ __decorate([
11335
11450
  ], SpriteMask.prototype, "_sprite", void 0);
11336
11451
  __decorate([
11337
11452
  ignoreClone
11338
- ], SpriteMask.prototype, "_width", void 0);
11453
+ ], SpriteMask.prototype, "_automaticWidth", void 0);
11339
11454
  __decorate([
11340
11455
  ignoreClone
11341
- ], SpriteMask.prototype, "_height", void 0);
11456
+ ], SpriteMask.prototype, "_automaticHeight", void 0);
11457
+ __decorate([
11458
+ assignmentClone
11459
+ ], SpriteMask.prototype, "_customWidth", void 0);
11460
+ __decorate([
11461
+ assignmentClone
11462
+ ], SpriteMask.prototype, "_customHeight", void 0);
11342
11463
  __decorate([
11343
11464
  assignmentClone
11344
11465
  ], SpriteMask.prototype, "_flipX", void 0);
@@ -11356,7 +11477,9 @@ var /**
11356
11477
  */ SpriteMaskUpdateFlags;
11357
11478
  (function(SpriteMaskUpdateFlags) {
11358
11479
  SpriteMaskUpdateFlags[SpriteMaskUpdateFlags[/** UV. */ "UV"] = 0x2] = "UV";
11359
- SpriteMaskUpdateFlags[SpriteMaskUpdateFlags[/** All. */ "All"] = 0x3] = "All";
11480
+ SpriteMaskUpdateFlags[SpriteMaskUpdateFlags[/** WorldVolume and UV . */ "RenderData"] = 0x3] = "RenderData";
11481
+ SpriteMaskUpdateFlags[SpriteMaskUpdateFlags[/** Automatic Size. */ "AutomaticSize"] = 0x4] = "AutomaticSize";
11482
+ SpriteMaskUpdateFlags[SpriteMaskUpdateFlags[/** All. */ "All"] = 0x7] = "All";
11360
11483
  })(SpriteMaskUpdateFlags || (SpriteMaskUpdateFlags = {}));
11361
11484
 
11362
11485
  /**
@@ -11621,7 +11744,9 @@ var BufferUtil = /*#__PURE__*/ function() {
11621
11744
  var platformBuffer = this._engine._hardwareRenderer.createPlatformBuffer(this._type, this._byteLength, this._bufferUsage);
11622
11745
  this._platformBuffer = platformBuffer;
11623
11746
  };
11624
- _proto._onDestroy = function _onDestroy() {
11747
+ /**
11748
+ * @internal
11749
+ */ _proto._onDestroy = function _onDestroy() {
11625
11750
  GraphicsResource.prototype._onDestroy.call(this);
11626
11751
  this._platformBuffer.destroy();
11627
11752
  };
@@ -11800,10 +11925,11 @@ var BufferUtil = /*#__PURE__*/ function() {
11800
11925
  /**
11801
11926
  * @internal
11802
11927
  */ _proto._setVertexBufferBinding = function _setVertexBufferBinding(index, binding) {
11803
- if (this._getReferCount() > 0) {
11804
- var lastBinding = this._vertexBufferBindings[index];
11805
- lastBinding && lastBinding._buffer._addReferCount(-1);
11806
- binding._buffer._addReferCount(1);
11928
+ var referCount = this._getReferCount();
11929
+ if (referCount > 0) {
11930
+ var _this__vertexBufferBindings_index;
11931
+ (_this__vertexBufferBindings_index = this._vertexBufferBindings[index]) == null ? void 0 : _this__vertexBufferBindings_index._buffer._addReferCount(-referCount);
11932
+ binding == null ? void 0 : binding._buffer._addReferCount(referCount);
11807
11933
  }
11808
11934
  this._vertexBufferBindings[index] = binding;
11809
11935
  this._bufferStructChanged = true;
@@ -11815,11 +11941,13 @@ var BufferUtil = /*#__PURE__*/ function() {
11815
11941
  this._bufferStructChanged = false;
11816
11942
  };
11817
11943
  _proto._addReferCount = function _addReferCount(value) {
11944
+ var _this__indexBufferBinding;
11818
11945
  GraphicsResource.prototype._addReferCount.call(this, value);
11819
11946
  var vertexBufferBindings = this._vertexBufferBindings;
11820
11947
  for(var i = 0, n = vertexBufferBindings.length; i < n; i++){
11821
11948
  vertexBufferBindings[i]._buffer._addReferCount(value);
11822
11949
  }
11950
+ (_this__indexBufferBinding = this._indexBufferBinding) == null ? void 0 : _this__indexBufferBinding._buffer._addReferCount(value);
11823
11951
  };
11824
11952
  _proto._rebuild = function _rebuild() {
11825
11953
  this._engine._hardwareRenderer.createPlatformPrimitive(this);
@@ -11834,14 +11962,23 @@ var BufferUtil = /*#__PURE__*/ function() {
11834
11962
  this._vertexElementMap = null;
11835
11963
  this._platformPrimitive.destroy();
11836
11964
  };
11837
- _proto._setVertexElements = function _setVertexElements(elements) {
11965
+ /**
11966
+ * @internal
11967
+ */ _proto._setVertexElements = function _setVertexElements(elements) {
11838
11968
  this._clearVertexElements();
11839
11969
  for(var i = 0, n = elements.length; i < n; i++){
11840
11970
  this._addVertexElement(elements[i]);
11841
11971
  }
11842
11972
  };
11843
- _proto._setIndexBufferBinding = function _setIndexBufferBinding(binding) {
11973
+ /**
11974
+ * @internal
11975
+ */ _proto._setIndexBufferBinding = function _setIndexBufferBinding(binding) {
11844
11976
  var lastBinding = this._indexBufferBinding;
11977
+ var referCount = this._getReferCount();
11978
+ if (referCount > 0) {
11979
+ lastBinding == null ? void 0 : lastBinding.buffer._addReferCount(-referCount);
11980
+ binding == null ? void 0 : binding.buffer._addReferCount(referCount);
11981
+ }
11845
11982
  if (binding) {
11846
11983
  this._indexBufferBinding = binding;
11847
11984
  this._glIndexType = BufferUtil._getGLIndexType(binding.format);
@@ -12157,6 +12294,7 @@ var MeshModifyFlags;
12157
12294
  var subDataDirtyFlags = this._subDataDirtyFlags;
12158
12295
  var blendShapeFloatStride = this._vertexElementCount * 3;
12159
12296
  var blendShapeByteStride = blendShapeFloatStride * 4;
12297
+ var bufferOffset = this._bufferBindingOffset;
12160
12298
  // @todo: should fix bug when dataChangedFlag is true
12161
12299
  for(var i = 0, n = blendShapes.length; i < n; i++){
12162
12300
  var dataChangedFlag = subDataDirtyFlags[i];
@@ -12174,7 +12312,7 @@ var MeshModifyFlags;
12174
12312
  var offset = indexInBuffer * blendShapeFloatStride;
12175
12313
  var storeInfo = storeInfos[i];
12176
12314
  storeInfo || (storeInfos[i] = storeInfo = new engineMath.Vector2());
12177
- storeInfo.set(bufferIndex + 1, indexInBuffer * blendShapeByteStride); // BlendShape buffer is start from 1
12315
+ storeInfo.set(bufferOffset + bufferIndex, indexInBuffer * blendShapeByteStride); // BufferOffset is mesh vertexBuffer offset
12178
12316
  var deltaPositions = endFrame.deltaPositions;
12179
12317
  for(var j = 0; j < vertexCount; j++){
12180
12318
  var start = offset + bufferFloatStride * j;
@@ -12978,7 +13116,9 @@ var MeshModifyFlags;
12978
13116
  }
12979
13117
  this.setTangents(tangents);
12980
13118
  };
12981
- _proto._onDestroy = function _onDestroy() {
13119
+ /**
13120
+ * @internal
13121
+ */ _proto._onDestroy = function _onDestroy() {
12982
13122
  Mesh.prototype._onDestroy.call(this);
12983
13123
  this._readable && this._releaseCache();
12984
13124
  };
@@ -13449,24 +13589,31 @@ var VertexChangedFlags;
13449
13589
  function MeshRenderer(entity) {
13450
13590
  var _this;
13451
13591
  _this = Renderer.call(this, entity) || this;
13592
+ _this._enableVertexColor = false;
13452
13593
  _this._onMeshChanged = _this._onMeshChanged.bind(_assert_this_initialized(_this));
13453
13594
  return _this;
13454
13595
  }
13455
13596
  var _proto = MeshRenderer.prototype;
13456
- _proto._onDestroy = function _onDestroy() {
13597
+ /**
13598
+ * @internal
13599
+ */ _proto._onDestroy = function _onDestroy() {
13457
13600
  Renderer.prototype._onDestroy.call(this);
13458
13601
  var mesh = this._mesh;
13459
13602
  if (mesh && !mesh.destroyed) {
13460
13603
  mesh._addReferCount(-1);
13604
+ mesh._updateFlagManager.removeListener(this._onMeshChanged);
13461
13605
  this._mesh = null;
13462
13606
  }
13463
13607
  };
13464
13608
  /**
13465
13609
  * @internal
13466
13610
  */ _proto._cloneTo = function _cloneTo(target) {
13611
+ Renderer.prototype._cloneTo.call(this, target);
13467
13612
  target.mesh = this._mesh;
13468
13613
  };
13469
- _proto._updateBounds = function _updateBounds(worldBounds) {
13614
+ /**
13615
+ * @internal
13616
+ */ _proto._updateBounds = function _updateBounds(worldBounds) {
13470
13617
  var mesh = this._mesh;
13471
13618
  if (mesh) {
13472
13619
  var localBounds = mesh.bounds;
@@ -13477,7 +13624,9 @@ var VertexChangedFlags;
13477
13624
  worldBounds.max.set(0, 0, 0);
13478
13625
  }
13479
13626
  };
13480
- _proto._render = function _render(context) {
13627
+ /**
13628
+ * @internal
13629
+ */ _proto._render = function _render(context) {
13481
13630
  var mesh = this._mesh;
13482
13631
  if (mesh) {
13483
13632
  if (this._dirtyUpdateFlag & 0x2) {
@@ -13487,7 +13636,7 @@ var VertexChangedFlags;
13487
13636
  shaderData.disableMacro(MeshRenderer._uv1Macro);
13488
13637
  shaderData.disableMacro(MeshRenderer._normalMacro);
13489
13638
  shaderData.disableMacro(MeshRenderer._tangentMacro);
13490
- shaderData.disableMacro(MeshRenderer._vertexColorMacro);
13639
+ shaderData.disableMacro(MeshRenderer._enableVertexColorMacro);
13491
13640
  for(var i = 0, n = vertexElements.length; i < n; i++){
13492
13641
  switch(vertexElements[i].semantic){
13493
13642
  case "TEXCOORD_0":
@@ -13503,7 +13652,7 @@ var VertexChangedFlags;
13503
13652
  shaderData.enableMacro(MeshRenderer._tangentMacro);
13504
13653
  break;
13505
13654
  case "COLOR_0":
13506
- shaderData.enableMacro(MeshRenderer._vertexColorMacro);
13655
+ this._enableVertexColor && shaderData.enableMacro(MeshRenderer._enableVertexColorMacro);
13507
13656
  break;
13508
13657
  }
13509
13658
  }
@@ -13554,6 +13703,20 @@ var VertexChangedFlags;
13554
13703
  this._setMesh(value);
13555
13704
  }
13556
13705
  }
13706
+ },
13707
+ {
13708
+ key: "enableVertexColor",
13709
+ get: /**
13710
+ * Whether enable vertex color.
13711
+ */ function get() {
13712
+ return this._enableVertexColor;
13713
+ },
13714
+ set: function set(value) {
13715
+ if (value !== this._enableVertexColor) {
13716
+ this._dirtyUpdateFlag |= 0x2;
13717
+ this._enableVertexColor = value;
13718
+ }
13719
+ }
13557
13720
  }
13558
13721
  ]);
13559
13722
  return MeshRenderer;
@@ -13571,7 +13734,7 @@ var VertexChangedFlags;
13571
13734
  MeshRenderer._tangentMacro = ShaderMacro.getByName("RENDERER_HAS_TANGENT");
13572
13735
  })();
13573
13736
  (function() {
13574
- MeshRenderer._vertexColorMacro = ShaderMacro.getByName("RENDERER_HAS_VERTEXCOLOR");
13737
+ MeshRenderer._enableVertexColorMacro = ShaderMacro.getByName("RENDERER_ENABLE_VERTEXCOLOR");
13575
13738
  })();
13576
13739
  __decorate([
13577
13740
  ignoreClone
@@ -13603,7 +13766,7 @@ var /**
13603
13766
  // Limit size to 256 to avoid some problem:
13604
13767
  // For renderer is "Apple GPU", when uniform is large than 256 the skeleton matrix array access in shader very slow in Safari or WKWebview. This may be a apple bug, Chrome and Firefox is OK!
13605
13768
  // For renderer is "ANGLE (AMD, AMD Radeon(TM) Graphics Direct3011 vs_5_0 ps_5_0, D3011)", compile shader si very slow because of max uniform is 4096.
13606
- maxVertexUniformVectors = Math.min(maxVertexUniformVectors, 256);
13769
+ maxVertexUniformVectors = Math.min(maxVertexUniformVectors, rhi._options._maxAllowSkinUniformVectorCount);
13607
13770
  _this._maxVertexUniformVectors = maxVertexUniformVectors;
13608
13771
  _this._onLocalBoundsChanged = _this._onLocalBoundsChanged.bind(_assert_this_initialized(_this));
13609
13772
  var localBounds = _this._localBounds;
@@ -13638,7 +13801,9 @@ var /**
13638
13801
  }
13639
13802
  }
13640
13803
  };
13641
- _proto._updateShaderData = function _updateShaderData(context) {
13804
+ /**
13805
+ * @internal
13806
+ */ _proto._updateShaderData = function _updateShaderData(context) {
13642
13807
  var entity = this.entity;
13643
13808
  var worldMatrix = this._rootBone ? this._rootBone.transform.worldMatrix : entity.transform.worldMatrix;
13644
13809
  this._updateTransformShaderData(context, worldMatrix);
@@ -13664,6 +13829,7 @@ var /**
13664
13829
  (_this__jointTexture = this._jointTexture) == null ? void 0 : _this__jointTexture.destroy();
13665
13830
  this._jointTexture = new Texture2D(engine, 4, jointCount, exports.TextureFormat.R32G32B32A32, false);
13666
13831
  this._jointTexture.filterMode = exports.TextureFilterMode.Point;
13832
+ this._jointTexture.isGCIgnored = true;
13667
13833
  }
13668
13834
  shaderData.disableMacro("RENDERER_JOINTS_NUM");
13669
13835
  shaderData.enableMacro("RENDERER_USE_JOINT_TEXTURE");
@@ -13689,14 +13855,26 @@ var /**
13689
13855
  };
13690
13856
  /**
13691
13857
  * @internal
13858
+ */ _proto._onDestroy = function _onDestroy() {
13859
+ var _this_rootBone, _this__jointTexture;
13860
+ MeshRenderer.prototype._onDestroy.call(this);
13861
+ (_this_rootBone = this.rootBone) == null ? void 0 : _this_rootBone.transform._updateFlagManager.removeListener(this._onTransformChanged);
13862
+ (_this__jointTexture = this._jointTexture) == null ? void 0 : _this__jointTexture.destroy();
13863
+ };
13864
+ /**
13865
+ * @internal
13692
13866
  */ _proto._cloneTo = function _cloneTo(target) {
13693
13867
  MeshRenderer.prototype._cloneTo.call(this, target);
13694
13868
  this._blendShapeWeights && (target._blendShapeWeights = this._blendShapeWeights.slice());
13695
13869
  };
13696
- _proto._registerEntityTransformListener = function _registerEntityTransformListener() {
13870
+ /**
13871
+ * @internal
13872
+ */ _proto._registerEntityTransformListener = function _registerEntityTransformListener() {
13697
13873
  // Cancel register listener to entity transform.
13698
13874
  };
13699
- _proto._updateBounds = function _updateBounds(worldBounds) {
13875
+ /**
13876
+ * @internal
13877
+ */ _proto._updateBounds = function _updateBounds(worldBounds) {
13700
13878
  if (this._rootBone) {
13701
13879
  var localBounds = this._localBounds;
13702
13880
  var worldMatrix = this._rootBone.transform.worldMatrix;
@@ -15149,14 +15327,17 @@ var Basic2DBatcher = /*#__PURE__*/ function() {
15149
15327
  _proto._createMesh = function _createMesh(engine, index) {
15150
15328
  var MAX_VERTEX_COUNT = Basic2DBatcher.MAX_VERTEX_COUNT;
15151
15329
  var mesh = new BufferMesh(engine, "BufferMesh" + index);
15330
+ mesh.isGCIgnored = true;
15152
15331
  var vertexElements = [];
15153
15332
  var vertexStride = this.createVertexElements(vertexElements);
15154
15333
  // vertices
15155
- this._vertexBuffers[index] = new Buffer(engine, exports.BufferBindFlag.VertexBuffer, MAX_VERTEX_COUNT * 4 * vertexStride, exports.BufferUsage.Dynamic);
15334
+ var vertexBuffer = this._vertexBuffers[index] = new Buffer(engine, exports.BufferBindFlag.VertexBuffer, MAX_VERTEX_COUNT * 4 * vertexStride, exports.BufferUsage.Dynamic);
15335
+ vertexBuffer.isGCIgnored = true;
15156
15336
  // indices
15157
- this._indiceBuffers[index] = new Buffer(engine, exports.BufferBindFlag.IndexBuffer, MAX_VERTEX_COUNT * 3, exports.BufferUsage.Dynamic);
15158
- mesh.setVertexBufferBinding(this._vertexBuffers[index], vertexStride);
15159
- mesh.setIndexBufferBinding(this._indiceBuffers[index], exports.IndexFormat.UInt16);
15337
+ var indiceBuffer = this._indiceBuffers[index] = new Buffer(engine, exports.BufferBindFlag.IndexBuffer, MAX_VERTEX_COUNT * 2 * 3, exports.BufferUsage.Dynamic);
15338
+ indiceBuffer.isGCIgnored = true;
15339
+ mesh.setVertexBufferBinding(vertexBuffer, vertexStride);
15340
+ mesh.setIndexBufferBinding(indiceBuffer, exports.IndexFormat.UInt16);
15160
15341
  mesh.setVertexElements(vertexElements);
15161
15342
  return mesh;
15162
15343
  };
@@ -15440,6 +15621,12 @@ var TextRenderData = /*#__PURE__*/ function(RenderData) {
15440
15621
  var _proto = Sky.prototype;
15441
15622
  /**
15442
15623
  * @internal
15624
+ */ _proto.destroy = function destroy() {
15625
+ this.mesh = null;
15626
+ this.material = null;
15627
+ };
15628
+ /**
15629
+ * @internal
15443
15630
  */ _proto._render = function _render(context) {
15444
15631
  var _this = this, material = _this.material, mesh = _this.mesh;
15445
15632
  if (!material) {
@@ -15480,6 +15667,40 @@ var TextRenderData = /*#__PURE__*/ function(RenderData) {
15480
15667
  rhi.drawPrimitive(mesh, mesh.subMesh, program);
15481
15668
  cameraShaderData.setMatrix(RenderContext.vpMatrixProperty, originViewProjMatrix);
15482
15669
  };
15670
+ _create_class(Sky, [
15671
+ {
15672
+ key: "material",
15673
+ get: /**
15674
+ * Material of the sky.
15675
+ */ function get() {
15676
+ return this._material;
15677
+ },
15678
+ set: function set(value) {
15679
+ if (this._material !== value) {
15680
+ var _this__material;
15681
+ value == null ? void 0 : value._addReferCount(1);
15682
+ (_this__material = this._material) == null ? void 0 : _this__material._addReferCount(-1);
15683
+ this._material = value;
15684
+ }
15685
+ }
15686
+ },
15687
+ {
15688
+ key: "mesh",
15689
+ get: /**
15690
+ * Mesh of the sky.
15691
+ */ function get() {
15692
+ return this._mesh;
15693
+ },
15694
+ set: function set(value) {
15695
+ if (this._mesh !== value) {
15696
+ var _this__mesh;
15697
+ value == null ? void 0 : value._addReferCount(1);
15698
+ (_this__mesh = this._mesh) == null ? void 0 : _this__mesh._addReferCount(-1);
15699
+ this._mesh = value;
15700
+ }
15701
+ }
15702
+ }
15703
+ ]);
15483
15704
  return Sky;
15484
15705
  }();
15485
15706
  (function() {
@@ -15515,9 +15736,19 @@ var TextRenderData = /*#__PURE__*/ function(RenderData) {
15515
15736
  var _proto = Background.prototype;
15516
15737
  /**
15517
15738
  * @internal
15739
+ */ _proto.destroy = function destroy() {
15740
+ this._mesh._addReferCount(-1);
15741
+ this._mesh = null;
15742
+ this.texture = null;
15743
+ this.solidColor = null;
15744
+ this.sky.destroy();
15745
+ };
15746
+ /**
15747
+ * @internal
15518
15748
  * Standalone for CanvasRenderer plugin.
15519
15749
  */ _proto._initMesh = function _initMesh(engine) {
15520
15750
  this._mesh = this._createPlane(engine);
15751
+ this._mesh._addReferCount(1);
15521
15752
  };
15522
15753
  /**
15523
15754
  * @internal
@@ -15589,6 +15820,9 @@ var TextRenderData = /*#__PURE__*/ function(RenderData) {
15589
15820
  },
15590
15821
  set: function set(value) {
15591
15822
  if (this._texture !== value) {
15823
+ var _this__texture;
15824
+ value == null ? void 0 : value._addReferCount(1);
15825
+ (_this__texture = this._texture) == null ? void 0 : _this__texture._addReferCount(-1);
15592
15826
  this._texture = value;
15593
15827
  this._engine._backgroundTextureMaterial.shaderData.setTexture("material_BaseTexture", value);
15594
15828
  }
@@ -16066,7 +16300,7 @@ var TextRenderData = /*#__PURE__*/ function(RenderData) {
16066
16300
  var sunLightIndex = lightManager._getSunLightIndex();
16067
16301
  if (sunLightIndex !== -1) {
16068
16302
  var sunlight = lightManager._directLights.get(sunLightIndex);
16069
- shaderData.setColor(Scene._sunlightColorProperty, sunlight.color);
16303
+ shaderData.setColor(Scene._sunlightColorProperty, sunlight._getLightIntensityColor());
16070
16304
  shaderData.setVector3(Scene._sunlightDirectionProperty, sunlight.direction);
16071
16305
  this._sunLight = sunlight;
16072
16306
  }
@@ -16097,6 +16331,7 @@ var TextRenderData = /*#__PURE__*/ function(RenderData) {
16097
16331
  this._rootEntities[0].destroy();
16098
16332
  }
16099
16333
  this._activeCameras.length = 0;
16334
+ this.background.destroy();
16100
16335
  this.shaderData._addReferCount(-1);
16101
16336
  };
16102
16337
  _proto._addToRootEntityList = function _addToRootEntityList(index, rootEntity) {
@@ -16554,7 +16789,7 @@ ShaderPool.init();
16554
16789
  _this._spriteDefaultMaterial = _this._createSpriteMaterial();
16555
16790
  _this._spriteMaskDefaultMaterial = _this._createSpriteMaskMaterial();
16556
16791
  _this._textDefaultFont = Font.createFromOS(_assert_this_initialized(_this), "Arial");
16557
- _this._textDefaultFont.isGCIgnored = false;
16792
+ _this._textDefaultFont.isGCIgnored = true;
16558
16793
  _this.inputManager = new InputManager(_assert_this_initialized(_this));
16559
16794
  _this._initMagentaTextures(hardwareRenderer);
16560
16795
  if (!hardwareRenderer.canIUse(exports.GLCapabilityType.depthTexture)) {
@@ -16565,6 +16800,7 @@ ShaderPool.init();
16565
16800
  _this._depthTexture2D = depthTexture2D;
16566
16801
  }
16567
16802
  var magentaMaterial = new Material(_assert_this_initialized(_this), Shader.find("unlit"));
16803
+ magentaMaterial.isGCIgnored = true;
16568
16804
  magentaMaterial.shaderData.setColor("material_BaseColor", new Color(1.0, 0.0, 1.01, 1.0));
16569
16805
  _this._magentaMaterial = magentaMaterial;
16570
16806
  var backgroundTextureMaterial = new Material(_assert_this_initialized(_this), Shader.find("background-texture"));
@@ -16791,7 +17027,9 @@ ShaderPool.init();
16791
17027
  this._magentaTexture2DArray = magentaTexture2DArray;
16792
17028
  }
16793
17029
  };
16794
- _proto._initialize = function _initialize(configuration) {
17030
+ /**
17031
+ * @internal
17032
+ */ _proto._initialize = function _initialize(configuration) {
16795
17033
  var _this = this;
16796
17034
  var physics = configuration.physics;
16797
17035
  if (physics) {
@@ -17113,7 +17351,9 @@ ShaderPool.init();
17113
17351
  this._entity._removeScript(this);
17114
17352
  this._waitHandlingInValid = false;
17115
17353
  };
17116
- _proto._onDestroy = function _onDestroy() {
17354
+ /**
17355
+ * @internal
17356
+ */ _proto._onDestroy = function _onDestroy() {
17117
17357
  Component.prototype._onDestroy.call(this);
17118
17358
  this._engine._componentsManager.addPendingDestroyScript(this);
17119
17359
  };
@@ -18063,7 +18303,7 @@ var /**
18063
18303
  // prepare render target
18064
18304
  var renderTarget = this._getAvailableRenderTarget();
18065
18305
  // @todo: shouldn't set viewport and scissor in activeRenderTarget
18066
- rhi.activeRenderTarget(renderTarget, null, 0);
18306
+ rhi.activeRenderTarget(renderTarget, CascadedShadowCasterPass._viewport, 0);
18067
18307
  if (this._supportDepthTexture) {
18068
18308
  rhi.clearRenderTarget(engine, exports.CameraClearFlags.Depth, null);
18069
18309
  } else {
@@ -18185,11 +18425,13 @@ var /**
18185
18425
  if (engine._hardwareRenderer._isWebGL2) {
18186
18426
  depthTexture.depthCompareFunction = exports.TextureDepthCompareFunction.Less;
18187
18427
  }
18428
+ renderTarget == null ? void 0 : renderTarget._addReferCount(-1);
18188
18429
  if (this._supportDepthTexture) {
18189
18430
  renderTarget = this._renderTargets = new RenderTarget(engine, width, height, null, depthTexture);
18190
18431
  } else {
18191
18432
  renderTarget = this._renderTargets = new RenderTarget(engine, width, height, depthTexture);
18192
18433
  }
18434
+ renderTarget._addReferCount(1);
18193
18435
  }
18194
18436
  return renderTarget;
18195
18437
  };
@@ -18212,7 +18454,12 @@ var /**
18212
18454
  var height = shadowCascades == exports.ShadowCascadesMode.TwoCascades ? shadowTileResolution : shadowTileResolution * 2;
18213
18455
  this._shadowMapSize.set(1.0 / width, 1.0 / height, width, height);
18214
18456
  }
18215
- this._renderTargets = null;
18457
+ var renderTargets = this._renderTargets;
18458
+ if (renderTargets) {
18459
+ renderTargets._addReferCount(-1);
18460
+ renderTargets.destroy();
18461
+ this._renderTargets = null;
18462
+ }
18216
18463
  var viewportOffset = this._viewportOffsets;
18217
18464
  var shadowTileResolution1 = this._shadowTileResolution;
18218
18465
  switch(shadowCascades){
@@ -18268,6 +18515,9 @@ var /**
18268
18515
  (function() {
18269
18516
  CascadedShadowCasterPass._cascadesSplitDistance = new Array(CascadedShadowCasterPass._maxCascades + 1);
18270
18517
  })();
18518
+ (function() {
18519
+ CascadedShadowCasterPass._viewport = new engineMath.Vector4(0, 0, 1, 1);
18520
+ })();
18271
18521
  (function() {
18272
18522
  CascadedShadowCasterPass._clearColor = new engineMath.Color(1, 1, 1, 1);
18273
18523
  })();
@@ -18796,6 +19046,7 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component) {
18796
19046
  this.entity.scene._detachRenderCamera(this);
18797
19047
  };
18798
19048
  /**
19049
+ * @internal
18799
19050
  * @inheritdoc
18800
19051
  */ _proto._onDestroy = function _onDestroy() {
18801
19052
  var _this__renderPipeline;
@@ -19001,7 +19252,12 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component) {
19001
19252
  return this._renderTarget;
19002
19253
  },
19003
19254
  set: function set(value) {
19004
- this._renderTarget = value;
19255
+ if (this._renderTarget !== value) {
19256
+ var _this__renderTarget;
19257
+ value == null ? void 0 : value._addReferCount(1);
19258
+ (_this__renderTarget = this._renderTarget) == null ? void 0 : _this__renderTarget._addReferCount(-1);
19259
+ this._renderTarget = value;
19260
+ }
19005
19261
  }
19006
19262
  }
19007
19263
  ]);
@@ -19990,6 +20246,7 @@ var BaseMaterial = /*#__PURE__*/ function(Material) {
19990
20246
  _this = PBRBaseMaterial.call(this, engine, Shader.find("pbr")) || this;
19991
20247
  _this.shaderData.setFloat(PBRMaterial._metallicProp, 1);
19992
20248
  _this.shaderData.setFloat(PBRMaterial._roughnessProp, 1);
20249
+ _this.shaderData.setFloat(PBRMaterial._iorProp, 1.5);
19993
20250
  return _this;
19994
20251
  }
19995
20252
  var _proto = PBRMaterial.prototype;
@@ -20001,10 +20258,23 @@ var BaseMaterial = /*#__PURE__*/ function(Material) {
20001
20258
  return dest;
20002
20259
  };
20003
20260
  _create_class(PBRMaterial, [
20261
+ {
20262
+ key: "ior",
20263
+ get: /**
20264
+ * Index Of Refraction.
20265
+ * @defaultValue `1.5`
20266
+ */ function get() {
20267
+ return this.shaderData.getFloat(PBRMaterial._iorProp);
20268
+ },
20269
+ set: function set(v) {
20270
+ this.shaderData.setFloat(PBRMaterial._iorProp, Math.max(v, 0));
20271
+ }
20272
+ },
20004
20273
  {
20005
20274
  key: "metallic",
20006
20275
  get: /**
20007
- * Metallic, default 1.0.
20276
+ * Metallic.
20277
+ * @defaultValue `1.0`
20008
20278
  */ function get() {
20009
20279
  return this.shaderData.getFloat(PBRMaterial._metallicProp);
20010
20280
  },
@@ -20015,7 +20285,8 @@ var BaseMaterial = /*#__PURE__*/ function(Material) {
20015
20285
  {
20016
20286
  key: "roughness",
20017
20287
  get: /**
20018
- * Roughness, default 1.0.
20288
+ * Roughness. default 1.0.
20289
+ * @defaultValue `1.0`
20019
20290
  */ function get() {
20020
20291
  return this.shaderData.getFloat(PBRMaterial._roughnessProp);
20021
20292
  },
@@ -20052,6 +20323,9 @@ var BaseMaterial = /*#__PURE__*/ function(Material) {
20052
20323
  (function() {
20053
20324
  PBRMaterial._roughnessMetallicTextureProp = ShaderProperty.getByName("material_RoughnessMetallicTexture");
20054
20325
  })();
20326
+ (function() {
20327
+ PBRMaterial._iorProp = Shader.getPropertyByName("material_IOR");
20328
+ })();
20055
20329
 
20056
20330
  /**
20057
20331
  * PBR (Specular-Glossiness Workflow) Material.
@@ -20263,9 +20537,18 @@ exports.TextVerticalAlignment = void 0;
20263
20537
  * @internal
20264
20538
  */ _proto._addSprite = function _addSprite(sprite) {
20265
20539
  this._spriteNamesToIndex[sprite.name] = this._sprites.push(sprite) - 1;
20540
+ sprite._atlas = this;
20541
+ sprite.isGCIgnored = true;
20266
20542
  };
20267
- _proto._onDestroy = function _onDestroy() {
20543
+ /**
20544
+ * @internal
20545
+ */ _proto._onDestroy = function _onDestroy() {
20268
20546
  ReferResource.prototype._onDestroy.call(this);
20547
+ var _this = this, sprites = _this._sprites;
20548
+ for(var i = 0, n = sprites.length; i < n; i++){
20549
+ sprites[i].destroy();
20550
+ }
20551
+ sprites.length = 0;
20269
20552
  this._sprites = null;
20270
20553
  this._spriteNamesToIndex = null;
20271
20554
  };
@@ -20313,8 +20596,10 @@ exports.TextVerticalAlignment = void 0;
20313
20596
  if (name === void 0) name = null;
20314
20597
  var _this;
20315
20598
  _this = ReferResource.call(this, engine) || this;
20316
- _this._width = undefined;
20317
- _this._height = undefined;
20599
+ _this._automaticWidth = 0;
20600
+ _this._automaticHeight = 0;
20601
+ _this._customWidth = undefined;
20602
+ _this._customHeight = undefined;
20318
20603
  _this._positions = [
20319
20604
  new engineMath.Vector2(),
20320
20605
  new engineMath.Vector2(),
@@ -20335,7 +20620,7 @@ exports.TextVerticalAlignment = void 0;
20335
20620
  _this._region = new engineMath.Rect(0, 0, 1, 1);
20336
20621
  _this._pivot = new engineMath.Vector2(0.5, 0.5);
20337
20622
  _this._border = new engineMath.Vector4(0, 0, 0, 0);
20338
- _this._dirtyUpdateFlag = 0x3;
20623
+ _this._dirtyUpdateFlag = 0x7;
20339
20624
  /** @internal */ _this._updateFlagManager = new UpdateFlagManager();
20340
20625
  _this._texture = texture;
20341
20626
  region && _this._region.copyFrom(region);
@@ -20373,17 +20658,41 @@ exports.TextVerticalAlignment = void 0;
20373
20658
  this._dirtyUpdateFlag & 0x1 && this._updatePositions();
20374
20659
  return this._bounds;
20375
20660
  };
20376
- _proto._onDestroy = function _onDestroy() {
20661
+ /**
20662
+ * @internal
20663
+ */ _proto._addReferCount = function _addReferCount(value) {
20664
+ var _this__atlas;
20665
+ ReferResource.prototype._addReferCount.call(this, value);
20666
+ (_this__atlas = this._atlas) == null ? void 0 : _this__atlas._addReferCount(value);
20667
+ };
20668
+ /**
20669
+ * @internal
20670
+ */ _proto._onDestroy = function _onDestroy() {
20377
20671
  ReferResource.prototype._onDestroy.call(this);
20672
+ this._positions.length = 0;
20673
+ this._positions = null;
20674
+ this._uvs.length = 0;
20675
+ this._uvs = null;
20676
+ this._atlasRegion = null;
20677
+ this._atlasRegionOffset = null;
20678
+ this._region = null;
20679
+ this._pivot = null;
20680
+ this._border = null;
20681
+ this._bounds = null;
20682
+ this._atlas = null;
20378
20683
  this._texture = null;
20684
+ this._updateFlagManager = null;
20379
20685
  };
20380
20686
  _proto._calDefaultSize = function _calDefaultSize() {
20381
20687
  if (this._texture) {
20382
20688
  var _this = this, _texture = _this._texture, _atlasRegion = _this._atlasRegion, _atlasRegionOffset = _this._atlasRegionOffset, _region = _this._region;
20383
20689
  var pixelsPerUnitReciprocal = 1.0 / Engine._pixelsPerUnit;
20384
- this._width = _texture.width * _atlasRegion.width / (1 - _atlasRegionOffset.x - _atlasRegionOffset.z) * _region.width * pixelsPerUnitReciprocal;
20385
- this._height = _texture.height * _atlasRegion.height / (1 - _atlasRegionOffset.y - _atlasRegionOffset.w) * _region.height * pixelsPerUnitReciprocal;
20690
+ this._automaticWidth = _texture.width * _atlasRegion.width / (1 - _atlasRegionOffset.x - _atlasRegionOffset.z) * _region.width * pixelsPerUnitReciprocal;
20691
+ this._automaticHeight = _texture.height * _atlasRegion.height / (1 - _atlasRegionOffset.y - _atlasRegionOffset.w) * _region.height * pixelsPerUnitReciprocal;
20692
+ } else {
20693
+ this._automaticWidth = this._automaticHeight = 0;
20386
20694
  }
20695
+ this._dirtyUpdateFlag &= ~0x4;
20387
20696
  };
20388
20697
  _proto._updatePositions = function _updatePositions() {
20389
20698
  var blank = this._atlasRegionOffset;
@@ -20437,11 +20746,16 @@ exports.TextVerticalAlignment = void 0;
20437
20746
  };
20438
20747
  _proto._dispatchSpriteChange = function _dispatchSpriteChange(type) {
20439
20748
  switch(type){
20749
+ case SpriteModifyFlags.texture:
20750
+ this._dirtyUpdateFlag |= 0x4;
20751
+ break;
20440
20752
  case SpriteModifyFlags.atlasRegionOffset:
20441
20753
  case SpriteModifyFlags.region:
20442
- this._dirtyUpdateFlag |= 0x3;
20754
+ this._dirtyUpdateFlag |= 0x7;
20443
20755
  break;
20444
20756
  case SpriteModifyFlags.atlasRegion:
20757
+ this._dirtyUpdateFlag |= 0x4 | 0x2;
20758
+ break;
20445
20759
  case SpriteModifyFlags.border:
20446
20760
  this._dirtyUpdateFlag |= 0x2;
20447
20761
  break;
@@ -20460,7 +20774,9 @@ exports.TextVerticalAlignment = void 0;
20460
20774
  if (this._texture !== value) {
20461
20775
  this._texture = value;
20462
20776
  this._dispatchSpriteChange(SpriteModifyFlags.texture);
20463
- (this._width === undefined || this._height === undefined) && this._dispatchSpriteChange(SpriteModifyFlags.size);
20777
+ if (this._customWidth === undefined || this._customHeight === undefined) {
20778
+ this._dispatchSpriteChange(SpriteModifyFlags.size);
20779
+ }
20464
20780
  }
20465
20781
  }
20466
20782
  },
@@ -20468,13 +20784,21 @@ exports.TextVerticalAlignment = void 0;
20468
20784
  key: "width",
20469
20785
  get: /**
20470
20786
  * The width of the sprite (in world coordinates).
20787
+ *
20788
+ * @remarks
20789
+ * If width is set, return the set value,
20790
+ * otherwise return the width calculated according to `Texture.width`, `Sprite.region`, `Sprite.atlasRegion`, `Sprite.atlasRegionOffset` and `Engine._pixelsPerUnit`.
20471
20791
  */ function get() {
20472
- this._width === undefined && this._calDefaultSize();
20473
- return this._width;
20792
+ if (this._customWidth !== undefined) {
20793
+ return this._customWidth;
20794
+ } else {
20795
+ this._dirtyUpdateFlag & 0x4 && this._calDefaultSize();
20796
+ return this._automaticWidth;
20797
+ }
20474
20798
  },
20475
20799
  set: function set(value) {
20476
- if (this._width !== value) {
20477
- this._width = value;
20800
+ if (this._customWidth !== value) {
20801
+ this._customWidth = value;
20478
20802
  this._dispatchSpriteChange(SpriteModifyFlags.size);
20479
20803
  }
20480
20804
  }
@@ -20483,13 +20807,21 @@ exports.TextVerticalAlignment = void 0;
20483
20807
  key: "height",
20484
20808
  get: /**
20485
20809
  * The height of the sprite (in world coordinates).
20810
+ *
20811
+ * @remarks
20812
+ * If height is set, return the set value,
20813
+ * otherwise return the height calculated according to `Texture.height`, `Sprite.region`, `Sprite.atlasRegion`, `Sprite.atlasRegionOffset` and `Engine._pixelsPerUnit`.
20486
20814
  */ function get() {
20487
- this._height === undefined && this._calDefaultSize();
20488
- return this._height;
20815
+ if (this._customHeight !== undefined) {
20816
+ return this._customHeight;
20817
+ } else {
20818
+ this._dirtyUpdateFlag & 0x4 && this._calDefaultSize();
20819
+ return this._automaticHeight;
20820
+ }
20489
20821
  },
20490
20822
  set: function set(value) {
20491
- if (this._height !== value) {
20492
- this._height = value;
20823
+ if (this._customHeight !== value) {
20824
+ this._customHeight = value;
20493
20825
  this._dispatchSpriteChange(SpriteModifyFlags.size);
20494
20826
  }
20495
20827
  }
@@ -20519,7 +20851,9 @@ exports.TextVerticalAlignment = void 0;
20519
20851
  var y = engineMath.MathUtil.clamp(value.y, 0, 1);
20520
20852
  this._atlasRegion.set(x, y, engineMath.MathUtil.clamp(value.width, 0, 1 - x), engineMath.MathUtil.clamp(value.height, 0, 1 - y));
20521
20853
  this._dispatchSpriteChange(SpriteModifyFlags.atlasRegion);
20522
- (this._width === undefined || this._height === undefined) && this._dispatchSpriteChange(SpriteModifyFlags.size);
20854
+ if (this._customWidth === undefined || this._customHeight === undefined) {
20855
+ this._dispatchSpriteChange(SpriteModifyFlags.size);
20856
+ }
20523
20857
  }
20524
20858
  },
20525
20859
  {
@@ -20534,7 +20868,9 @@ exports.TextVerticalAlignment = void 0;
20534
20868
  var y = engineMath.MathUtil.clamp(value.y, 0, 1);
20535
20869
  this._atlasRegionOffset.set(x, y, engineMath.MathUtil.clamp(value.z, 0, 1 - x), engineMath.MathUtil.clamp(value.w, 0, 1 - y));
20536
20870
  this._dispatchSpriteChange(SpriteModifyFlags.atlasRegionOffset);
20537
- (this._width === undefined || this._height === undefined) && this._dispatchSpriteChange(SpriteModifyFlags.size);
20871
+ if (this._customWidth === undefined || this._customHeight === undefined) {
20872
+ this._dispatchSpriteChange(SpriteModifyFlags.size);
20873
+ }
20538
20874
  }
20539
20875
  },
20540
20876
  {
@@ -20550,7 +20886,9 @@ exports.TextVerticalAlignment = void 0;
20550
20886
  var y = engineMath.MathUtil.clamp(value.y, 0, 1);
20551
20887
  region.set(x, y, engineMath.MathUtil.clamp(value.width, 0, 1 - x), engineMath.MathUtil.clamp(value.height, 0, 1 - y));
20552
20888
  this._dispatchSpriteChange(SpriteModifyFlags.region);
20553
- (this._width === undefined || this._height === undefined) && this._dispatchSpriteChange(SpriteModifyFlags.size);
20889
+ if (this._customWidth === undefined || this._customHeight === undefined) {
20890
+ this._dispatchSpriteChange(SpriteModifyFlags.size);
20891
+ }
20554
20892
  }
20555
20893
  },
20556
20894
  {
@@ -20600,7 +20938,8 @@ var SpriteUpdateFlags;
20600
20938
  (function(SpriteUpdateFlags) {
20601
20939
  SpriteUpdateFlags[SpriteUpdateFlags["positions"] = 0x1] = "positions";
20602
20940
  SpriteUpdateFlags[SpriteUpdateFlags["uvs"] = 0x2] = "uvs";
20603
- SpriteUpdateFlags[SpriteUpdateFlags["all"] = 0x3] = "all";
20941
+ SpriteUpdateFlags[SpriteUpdateFlags["automaticSize"] = 0x4] = "automaticSize";
20942
+ SpriteUpdateFlags[SpriteUpdateFlags["all"] = 0x7] = "all";
20604
20943
  })(SpriteUpdateFlags || (SpriteUpdateFlags = {}));
20605
20944
 
20606
20945
  var _SlicedSpriteAssembler;
@@ -21092,8 +21431,10 @@ var TiledType;
21092
21431
  _this._tiledAdaptiveThreshold = 0.5;
21093
21432
  _this._color = new engineMath.Color(1, 1, 1, 1);
21094
21433
  _this._sprite = null;
21095
- _this._width = undefined;
21096
- _this._height = undefined;
21434
+ _this._automaticWidth = 0;
21435
+ _this._automaticHeight = 0;
21436
+ _this._customWidth = undefined;
21437
+ _this._customHeight = undefined;
21097
21438
  _this._flipX = false;
21098
21439
  _this._flipY = false;
21099
21440
  _this._maskLayer = exports.SpriteMaskLayer.Layer0;
@@ -21108,38 +21449,45 @@ var TiledType;
21108
21449
  /**
21109
21450
  * @internal
21110
21451
  */ _proto._cloneTo = function _cloneTo(target) {
21452
+ Renderer.prototype._cloneTo.call(this, target);
21111
21453
  target._assembler.resetData(target);
21112
21454
  target.sprite = this._sprite;
21455
+ target.drawMode = this._drawMode;
21113
21456
  };
21114
- _proto._updateShaderData = function _updateShaderData(context) {
21457
+ /**
21458
+ * @internal
21459
+ */ _proto._updateShaderData = function _updateShaderData(context) {
21115
21460
  // @ts-ignore
21116
21461
  this._updateTransformShaderData(context, engineMath.Matrix._identity);
21117
21462
  };
21118
- _proto._updateBounds = function _updateBounds(worldBounds) {
21119
- var _this_sprite;
21120
- if (!((_this_sprite = this.sprite) == null ? void 0 : _this_sprite.texture) || !this.width || !this.height) {
21463
+ /**
21464
+ * @internal
21465
+ */ _proto._updateBounds = function _updateBounds(worldBounds) {
21466
+ if (this.sprite) {
21467
+ this._assembler.updatePositions(this);
21468
+ } else {
21121
21469
  worldBounds.min.set(0, 0, 0);
21122
21470
  worldBounds.max.set(0, 0, 0);
21123
- } else {
21124
- this._assembler.updatePositions(this);
21125
21471
  }
21126
21472
  };
21127
- _proto._render = function _render(context) {
21473
+ /**
21474
+ * @internal
21475
+ */ _proto._render = function _render(context) {
21128
21476
  var _this_sprite;
21129
21477
  if (!((_this_sprite = this.sprite) == null ? void 0 : _this_sprite.texture) || !this.width || !this.height) {
21130
21478
  return;
21131
21479
  }
21132
- // Update position.
21480
+ // Update position
21133
21481
  if (this._dirtyUpdateFlag & RendererUpdateFlags.WorldVolume) {
21134
21482
  this._assembler.updatePositions(this);
21135
21483
  this._dirtyUpdateFlag &= ~RendererUpdateFlags.WorldVolume;
21136
21484
  }
21137
- // Update uv.
21485
+ // Update uv
21138
21486
  if (this._dirtyUpdateFlag & 0x2) {
21139
21487
  this._assembler.updateUVs(this);
21140
21488
  this._dirtyUpdateFlag &= ~0x2;
21141
21489
  }
21142
- // Push render data
21490
+ // Push primitive
21143
21491
  var material = this.getMaterial();
21144
21492
  var texture = this.sprite.texture;
21145
21493
  var renderData = this._engine._spriteRenderDataPool.getFromPool();
@@ -21149,14 +21497,27 @@ var TiledType;
21149
21497
  /**
21150
21498
  * @internal
21151
21499
  */ _proto._onDestroy = function _onDestroy() {
21152
- var _this__sprite;
21153
21500
  Renderer.prototype._onDestroy.call(this);
21154
- (_this__sprite = this._sprite) == null ? void 0 : _this__sprite._updateFlagManager.removeListener(this._onSpriteChange);
21501
+ var sprite = this._sprite;
21502
+ if (sprite) {
21503
+ sprite._addReferCount(-1);
21504
+ sprite._updateFlagManager.removeListener(this._onSpriteChange);
21505
+ }
21155
21506
  this._color = null;
21156
21507
  this._sprite = null;
21157
21508
  this._assembler = null;
21158
21509
  this._verticesData = null;
21159
21510
  };
21511
+ _proto._calDefaultSize = function _calDefaultSize() {
21512
+ var sprite = this._sprite;
21513
+ if (sprite) {
21514
+ this._automaticWidth = sprite.width;
21515
+ this._automaticHeight = sprite.height;
21516
+ } else {
21517
+ this._automaticWidth = this._automaticHeight = 0;
21518
+ }
21519
+ this._dirtyUpdateFlag &= ~0x4;
21520
+ };
21160
21521
  _proto._updateStencilState = function _updateStencilState() {
21161
21522
  // Update stencil.
21162
21523
  var material = this.getInstanceMaterial();
@@ -21183,22 +21544,21 @@ var TiledType;
21183
21544
  break;
21184
21545
  case SpriteModifyFlags.size:
21185
21546
  var _this = this, drawMode = _this._drawMode;
21186
- if (drawMode === exports.SpriteDrawMode.Sliced) {
21547
+ this._dirtyUpdateFlag |= 0x4;
21548
+ if (this._drawMode === exports.SpriteDrawMode.Sliced) {
21187
21549
  this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
21188
21550
  } else if (drawMode === exports.SpriteDrawMode.Tiled) {
21189
21551
  this._dirtyUpdateFlag |= 0x3;
21190
21552
  } else {
21191
21553
  // When the width and height of `SpriteRenderer` are `undefined`,
21192
21554
  // the `size` of `Sprite` will affect the position of `SpriteRenderer`.
21193
- if (this._width === undefined || this._height === undefined) {
21555
+ if (this._customWidth === undefined || this._customHeight === undefined) {
21194
21556
  this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
21195
21557
  }
21196
21558
  }
21197
21559
  break;
21198
21560
  case SpriteModifyFlags.border:
21199
- if (this._drawMode === exports.SpriteDrawMode.Sliced || this._drawMode === exports.SpriteDrawMode.Tiled) {
21200
- this._dirtyUpdateFlag |= 0x3;
21201
- }
21561
+ this._drawMode === exports.SpriteDrawMode.Sliced && (this._dirtyUpdateFlag |= 0x3);
21202
21562
  break;
21203
21563
  case SpriteModifyFlags.region:
21204
21564
  case SpriteModifyFlags.atlasRegionOffset:
@@ -21282,10 +21642,14 @@ var TiledType;
21282
21642
  set: function set(value) {
21283
21643
  var lastSprite = this._sprite;
21284
21644
  if (lastSprite !== value) {
21285
- lastSprite && lastSprite._updateFlagManager.removeListener(this._onSpriteChange);
21645
+ if (lastSprite) {
21646
+ lastSprite._addReferCount(-1);
21647
+ lastSprite._updateFlagManager.removeListener(this._onSpriteChange);
21648
+ }
21649
+ this._dirtyUpdateFlag |= 0x7;
21286
21650
  if (value) {
21651
+ value._addReferCount(1);
21287
21652
  value._updateFlagManager.addListener(this._onSpriteChange);
21288
- this._dirtyUpdateFlag |= 0x3;
21289
21653
  this.shaderData.setTexture(SpriteRenderer._textureProperty, value.texture);
21290
21654
  } else {
21291
21655
  this.shaderData.setTexture(SpriteRenderer._textureProperty, null);
@@ -21310,16 +21674,22 @@ var TiledType;
21310
21674
  {
21311
21675
  key: "width",
21312
21676
  get: /**
21313
- * Render width.
21677
+ * Render width (in world coordinates).
21678
+ *
21679
+ * @remarks
21680
+ * If width is set, return the set value,
21681
+ * otherwise return `SpriteRenderer.sprite.width`.
21314
21682
  */ function get() {
21315
- this._width === undefined && this._sprite && (this.width = this._sprite.width);
21316
- return this._width;
21683
+ if (this._customWidth !== undefined) {
21684
+ return this._customWidth;
21685
+ } else {
21686
+ this._dirtyUpdateFlag & 0x4 && this._calDefaultSize();
21687
+ return this._automaticWidth;
21688
+ }
21317
21689
  },
21318
21690
  set: function set(value) {
21319
- // Update width if undefined
21320
- this._width === undefined && this._sprite && (this._width = this._sprite.width);
21321
- if (this._width !== value) {
21322
- this._width = value;
21691
+ if (this._customWidth !== value) {
21692
+ this._customWidth = value;
21323
21693
  this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
21324
21694
  }
21325
21695
  }
@@ -21327,16 +21697,22 @@ var TiledType;
21327
21697
  {
21328
21698
  key: "height",
21329
21699
  get: /**
21330
- * Render height.
21700
+ * Render height (in world coordinates).
21701
+ *
21702
+ * @remarks
21703
+ * If height is set, return the set value,
21704
+ * otherwise return `SpriteRenderer.sprite.height`.
21331
21705
  */ function get() {
21332
- this._height === undefined && this._sprite && (this.height = this._sprite.height);
21333
- return this._height;
21706
+ if (this._customHeight !== undefined) {
21707
+ return this._customHeight;
21708
+ } else {
21709
+ this._dirtyUpdateFlag & 0x4 && this._calDefaultSize();
21710
+ return this._automaticHeight;
21711
+ }
21334
21712
  },
21335
21713
  set: function set(value) {
21336
- // Update height if undefined
21337
- this._height === undefined && this._sprite && (this._height = this._sprite.height);
21338
- if (this._height !== value) {
21339
- this._height = value;
21714
+ if (this._customHeight !== value) {
21715
+ this._customHeight = value;
21340
21716
  this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
21341
21717
  }
21342
21718
  }
@@ -21423,10 +21799,16 @@ __decorate([
21423
21799
  ], SpriteRenderer.prototype, "_sprite", void 0);
21424
21800
  __decorate([
21425
21801
  ignoreClone
21426
- ], SpriteRenderer.prototype, "_width", void 0);
21802
+ ], SpriteRenderer.prototype, "_automaticWidth", void 0);
21427
21803
  __decorate([
21428
21804
  ignoreClone
21429
- ], SpriteRenderer.prototype, "_height", void 0);
21805
+ ], SpriteRenderer.prototype, "_automaticHeight", void 0);
21806
+ __decorate([
21807
+ assignmentClone
21808
+ ], SpriteRenderer.prototype, "_customWidth", void 0);
21809
+ __decorate([
21810
+ assignmentClone
21811
+ ], SpriteRenderer.prototype, "_customHeight", void 0);
21430
21812
  __decorate([
21431
21813
  assignmentClone
21432
21814
  ], SpriteRenderer.prototype, "_flipX", void 0);
@@ -21447,7 +21829,9 @@ var /**
21447
21829
  */ SpriteRendererUpdateFlags;
21448
21830
  (function(SpriteRendererUpdateFlags) {
21449
21831
  SpriteRendererUpdateFlags[SpriteRendererUpdateFlags[/** UV. */ "UV"] = 0x2] = "UV";
21450
- SpriteRendererUpdateFlags[SpriteRendererUpdateFlags[/** All. */ "All"] = 0x3] = "All";
21832
+ SpriteRendererUpdateFlags[SpriteRendererUpdateFlags[/** WorldVolume and UV . */ "RenderData"] = 0x3] = "RenderData";
21833
+ SpriteRendererUpdateFlags[SpriteRendererUpdateFlags[/** Automatic Size. */ "AutomaticSize"] = 0x4] = "AutomaticSize";
21834
+ SpriteRendererUpdateFlags[SpriteRendererUpdateFlags[/** All. */ "All"] = 0x7] = "All";
21451
21835
  })(SpriteRendererUpdateFlags || (SpriteRendererUpdateFlags = {}));
21452
21836
 
21453
21837
  /**
@@ -21535,7 +21919,9 @@ var /**
21535
21919
  this._font._addReferCount(1);
21536
21920
  this.setMaterial(engine._spriteDefaultMaterial);
21537
21921
  };
21538
- _proto._onDestroy = function _onDestroy() {
21922
+ /**
21923
+ * @internal
21924
+ */ _proto._onDestroy = function _onDestroy() {
21539
21925
  Renderer.prototype._onDestroy.call(this);
21540
21926
  // Clear render data.
21541
21927
  var charRenderDatas = this._charRenderDatas;
@@ -21552,6 +21938,7 @@ var /**
21552
21938
  /**
21553
21939
  * @internal
21554
21940
  */ _proto._cloneTo = function _cloneTo(target) {
21941
+ Renderer.prototype._cloneTo.call(this, target);
21555
21942
  target.font = this._font;
21556
21943
  target._subFont = this._subFont;
21557
21944
  };
@@ -21570,14 +21957,20 @@ var /**
21570
21957
  */ _proto._setDirtyFlagFalse = function _setDirtyFlagFalse(type) {
21571
21958
  this._dirtyFlag &= ~type;
21572
21959
  };
21573
- _proto._updateShaderData = function _updateShaderData(context) {
21960
+ /**
21961
+ * @internal
21962
+ */ _proto._updateShaderData = function _updateShaderData(context) {
21574
21963
  // @ts-ignore
21575
21964
  this._updateTransformShaderData(context, engineMath.Matrix._identity);
21576
21965
  };
21577
- _proto._updateBounds = function _updateBounds(worldBounds) {
21966
+ /**
21967
+ * @internal
21968
+ */ _proto._updateBounds = function _updateBounds(worldBounds) {
21578
21969
  engineMath.BoundingBox.transform(this._localBounds, this._entity.transform.worldMatrix, worldBounds);
21579
21970
  };
21580
- _proto._render = function _render(context) {
21971
+ /**
21972
+ * @internal
21973
+ */ _proto._render = function _render(context) {
21581
21974
  if (this._text === "" || this.enableWrapping && this.width <= 0 || this.overflowMode === exports.OverflowMode.Truncate && this.height <= 0) {
21582
21975
  return;
21583
21976
  }
@@ -21672,8 +22065,6 @@ var /**
21672
22065
  _proto._updateLocalData = function _updateLocalData() {
21673
22066
  var _this = this, color = _this.color, horizontalAlignment = _this.horizontalAlignment, verticalAlignment = _this.verticalAlignment, charRenderDatas = _this._charRenderDatas;
21674
22067
  var _this__localBounds = this._localBounds, min = _this__localBounds.min, max = _this__localBounds.max;
21675
- min.set(0, 0, 0);
21676
- max.set(0, 0, 0);
21677
22068
  var _pixelsPerUnit = Engine._pixelsPerUnit;
21678
22069
  var pixelsPerUnitReciprocal = 1.0 / _pixelsPerUnit;
21679
22070
  var charFont = this._subFont;
@@ -21700,54 +22091,65 @@ var /**
21700
22091
  break;
21701
22092
  }
21702
22093
  var renderDataCount = 0;
22094
+ var firstLine = -1;
21703
22095
  var minX = Number.MAX_SAFE_INTEGER;
21704
22096
  var minY = Number.MAX_SAFE_INTEGER;
21705
22097
  var maxX = Number.MIN_SAFE_INTEGER;
21706
22098
  var maxY = Number.MIN_SAFE_INTEGER;
21707
- var lastLineIndex = linesLen - 1;
21708
22099
  for(var i = 0; i < linesLen; ++i){
21709
- var line = lines[i];
21710
22100
  var lineWidth = lineWidths[i];
21711
- var startX = 0;
21712
- switch(horizontalAlignment){
21713
- case exports.TextHorizontalAlignment.Left:
21714
- startX = -halfRendererWidth;
21715
- break;
21716
- case exports.TextHorizontalAlignment.Center:
21717
- startX = -lineWidth * 0.5;
21718
- break;
21719
- case exports.TextHorizontalAlignment.Right:
21720
- startX = halfRendererWidth - lineWidth;
21721
- break;
21722
- }
21723
- for(var j = 0, m = line.length - 1; j <= m; ++j){
21724
- var char = line[j];
21725
- var charInfo = charFont._getCharInfo(char);
21726
- if (charInfo.h > 0) {
21727
- var charRenderData = charRenderDatas[renderDataCount] || charRenderDataPool.get();
21728
- var renderData = charRenderData.renderData, localPositions = charRenderData.localPositions;
21729
- charRenderData.texture = charFont._getTextureByIndex(charInfo.index);
21730
- renderData.color = color;
21731
- renderData.uvs = charInfo.uvs;
21732
- var w = charInfo.w, ascent = charInfo.ascent, descent = charInfo.descent;
21733
- var left = startX * pixelsPerUnitReciprocal;
21734
- var right = (startX + w) * pixelsPerUnitReciprocal;
21735
- var top = (startY + ascent) * pixelsPerUnitReciprocal;
21736
- var bottom = (startY - descent + 1) * pixelsPerUnitReciprocal;
21737
- localPositions.set(left, top, right, bottom);
21738
- charRenderDatas[renderDataCount] = charRenderData;
21739
- renderDataCount++;
21740
- i === 0 && (maxY = Math.max(maxY, top));
21741
- i === lastLineIndex && (minY = Math.min(minY, bottom));
21742
- j === 0 && (minX = Math.min(minX, left));
21743
- j === m && (maxX = Math.max(maxX, right));
21744
- }
21745
- startX += charInfo.xAdvance;
22101
+ if (lineWidth > 0) {
22102
+ var line = lines[i];
22103
+ var startX = 0;
22104
+ var firstRow = -1;
22105
+ if (firstLine < 0) {
22106
+ firstLine = i;
22107
+ }
22108
+ switch(horizontalAlignment){
22109
+ case exports.TextHorizontalAlignment.Left:
22110
+ startX = -halfRendererWidth;
22111
+ break;
22112
+ case exports.TextHorizontalAlignment.Center:
22113
+ startX = -lineWidth * 0.5;
22114
+ break;
22115
+ case exports.TextHorizontalAlignment.Right:
22116
+ startX = halfRendererWidth - lineWidth;
22117
+ break;
22118
+ }
22119
+ for(var j = 0, n = line.length; j < n; ++j){
22120
+ var char = line[j];
22121
+ var charInfo = charFont._getCharInfo(char);
22122
+ if (charInfo.h > 0) {
22123
+ var _charRenderDatas, _ref;
22124
+ firstRow < 0 && (firstRow = j);
22125
+ var charRenderData = (_charRenderDatas = charRenderDatas)[_ref = renderDataCount++] || (_charRenderDatas[_ref] = charRenderDataPool.get());
22126
+ var renderData = charRenderData.renderData, localPositions = charRenderData.localPositions;
22127
+ charRenderData.texture = charFont._getTextureByIndex(charInfo.index);
22128
+ renderData.color = color;
22129
+ renderData.uvs = charInfo.uvs;
22130
+ var w = charInfo.w, ascent = charInfo.ascent, descent = charInfo.descent;
22131
+ var left = startX * pixelsPerUnitReciprocal;
22132
+ var right = (startX + w) * pixelsPerUnitReciprocal;
22133
+ var top = (startY + ascent) * pixelsPerUnitReciprocal;
22134
+ var bottom = (startY - descent + 1) * pixelsPerUnitReciprocal;
22135
+ localPositions.set(left, top, right, bottom);
22136
+ i === firstLine && (maxY = Math.max(maxY, top));
22137
+ minY = Math.min(minY, bottom);
22138
+ j === firstRow && (minX = Math.min(minX, left));
22139
+ maxX = Math.max(maxX, right);
22140
+ }
22141
+ startX += charInfo.xAdvance;
22142
+ }
21746
22143
  }
21747
22144
  startY -= lineHeight;
21748
22145
  }
21749
- min.set(minX, minY, 0);
21750
- max.set(maxX, maxY, 0);
22146
+ if (firstLine < 0) {
22147
+ min.set(0, 0, 0);
22148
+ max.set(0, 0, 0);
22149
+ } else {
22150
+ min.set(minX, minY, 0);
22151
+ max.set(maxX, maxY, 0);
22152
+ }
21751
22153
  // Revert excess render data to pool.
21752
22154
  var lastRenderDataCount = charRenderDatas.length;
21753
22155
  if (lastRenderDataCount > renderDataCount) {
@@ -21760,7 +22162,9 @@ var /**
21760
22162
  return a.texture.instanceId - b.texture.instanceId;
21761
22163
  });
21762
22164
  };
21763
- _proto._onTransformChanged = function _onTransformChanged(bit) {
22165
+ /**
22166
+ * @internal
22167
+ */ _proto._onTransformChanged = function _onTransformChanged(bit) {
21764
22168
  Renderer.prototype._onTransformChanged.call(this, bit);
21765
22169
  this._setDirtyFlagTrue(0x4 | 0x8);
21766
22170
  };
@@ -22079,7 +22483,6 @@ var DirtyFlag;
22079
22483
  * @internal
22080
22484
  */ var AnimationCurveOwner = /*#__PURE__*/ function() {
22081
22485
  function AnimationCurveOwner(target, type, property, cureType) {
22082
- this.crossCurveMark = 0;
22083
22486
  this.hasSavedDefaultValue = false;
22084
22487
  this.baseEvaluateData = {
22085
22488
  curKeyframeIndex: 0,
@@ -22278,6 +22681,12 @@ AnimationCurveOwner.registerAssembler(Transform, "scale", ScaleAnimationCurveOwn
22278
22681
  }();
22279
22682
  AnimationCurveOwner.registerAssembler(SkinnedMeshRenderer, "blendShapeWeights", BlendShapeWeightsAnimationCurveOwnerAssembler);
22280
22683
 
22684
+ /**
22685
+ * @internal
22686
+ */ var AnimationCurveLayerOwner = function AnimationCurveLayerOwner() {
22687
+ this.crossCurveMark = 0;
22688
+ };
22689
+
22281
22690
  /**
22282
22691
  * Associate AnimationCurve and the Entity
22283
22692
  */ var AnimationClipCurveBinding = /*#__PURE__*/ function() {
@@ -22295,6 +22704,13 @@ AnimationCurveOwner.registerAssembler(SkinnedMeshRenderer, "blendShapeWeights",
22295
22704
  };
22296
22705
  /**
22297
22706
  * @internal
22707
+ */ _proto._createCurveLayerOwner = function _createCurveLayerOwner(owner) {
22708
+ var layerOwner = new AnimationCurveLayerOwner();
22709
+ layerOwner.curveOwner = owner;
22710
+ return layerOwner;
22711
+ };
22712
+ /**
22713
+ * @internal
22298
22714
  */ _proto._getTempCurveOwner = function _getTempCurveOwner(entity) {
22299
22715
  var instanceId = entity.instanceId;
22300
22716
  if (!this._tempCurveOwner[instanceId]) {
@@ -23449,12 +23865,14 @@ exports.AnimatorLayerBlendingMode = void 0;
23449
23865
  * @internal
23450
23866
  */ var AnimatorLayerData = /*#__PURE__*/ function() {
23451
23867
  function AnimatorLayerData() {
23868
+ this.curveOwnerPool = Object.create(null);
23452
23869
  this.animatorStateDataMap = {};
23453
23870
  this.srcPlayData = new AnimatorStatePlayData();
23454
23871
  this.destPlayData = new AnimatorStatePlayData();
23455
23872
  this.layerState = LayerState.Standby;
23456
23873
  this.crossCurveMark = 0;
23457
23874
  this.manuallyTransition = new AnimatorStateTransition();
23875
+ this.crossOwnerLayerDataCollection = [];
23458
23876
  }
23459
23877
  var _proto = AnimatorLayerData.prototype;
23460
23878
  _proto.switchPlayData = function switchPlayData() {
@@ -23469,7 +23887,7 @@ exports.AnimatorLayerBlendingMode = void 0;
23469
23887
  /**
23470
23888
  * @internal
23471
23889
  */ var AnimatorStateData = function AnimatorStateData() {
23472
- this.curveOwners = [];
23890
+ this.curveLayerOwner = [];
23473
23891
  this.eventHandlers = [];
23474
23892
  };
23475
23893
 
@@ -23483,8 +23901,7 @@ exports.AnimatorLayerBlendingMode = void 0;
23483
23901
  /** Culling mode of this Animator. */ _this.cullingMode = exports.AnimatorCullingMode.None;
23484
23902
  /** The playback speed of the Animator, 1.0 is normal playback speed. */ _this.speed = 1.0;
23485
23903
  _this._animatorLayersData = [];
23486
- _this._crossOwnerCollection = [];
23487
- _this._animationCurveOwners = [];
23904
+ _this._curveOwnerPool = Object.create(null);
23488
23905
  _this._animationEventHandlerPool = new ClassPool(AnimationEventHandler);
23489
23906
  _this._tempAnimatorStateInfo = {
23490
23907
  layerIndex: -1,
@@ -23516,7 +23933,6 @@ exports.AnimatorLayerBlendingMode = void 0;
23516
23933
  return;
23517
23934
  }
23518
23935
  var animatorLayerData = this._getAnimatorLayerData(stateInfo.layerIndex);
23519
- //TODO CM: Not consider same stateName, but different animation
23520
23936
  var animatorStateData = this._getAnimatorStateData(stateName, state, animatorLayerData);
23521
23937
  this._preparePlay(animatorLayerData, state, animatorStateData);
23522
23938
  animatorLayerData.layerState = LayerState.Playing;
@@ -23607,7 +24023,7 @@ exports.AnimatorLayerBlendingMode = void 0;
23607
24023
  /**
23608
24024
  * @internal
23609
24025
  */ _proto._reset = function _reset() {
23610
- var _this = this, animationCurveOwners = _this._animationCurveOwners;
24026
+ var _this = this, animationCurveOwners = _this._curveOwnerPool;
23611
24027
  for(var instanceId in animationCurveOwners){
23612
24028
  var propertyOwners = animationCurveOwners[instanceId];
23613
24029
  for(var property in propertyOwners){
@@ -23616,8 +24032,7 @@ exports.AnimatorLayerBlendingMode = void 0;
23616
24032
  }
23617
24033
  }
23618
24034
  this._animatorLayersData.length = 0;
23619
- this._crossOwnerCollection.length = 0;
23620
- this._animationCurveOwners.length = 0;
24035
+ this._curveOwnerPool = {};
23621
24036
  this._animationEventHandlerPool.resetPool();
23622
24037
  if (this._controllerUpdateFlag) {
23623
24038
  this._controllerUpdateFlag.flag = false;
@@ -23645,10 +24060,10 @@ exports.AnimatorLayerBlendingMode = void 0;
23645
24060
  return stateInfo;
23646
24061
  };
23647
24062
  _proto._saveDefaultValues = function _saveDefaultValues(stateData) {
23648
- var curveOwners = stateData.curveOwners;
23649
- for(var i = curveOwners.length - 1; i >= 0; i--){
23650
- var _curveOwners_i;
23651
- (_curveOwners_i = curveOwners[i]) == null ? void 0 : _curveOwners_i.saveDefaultValue();
24063
+ var curveLayerOwner = stateData.curveLayerOwner;
24064
+ for(var i = curveLayerOwner.length - 1; i >= 0; i--){
24065
+ var _curveLayerOwner_i;
24066
+ (_curveLayerOwner_i = curveLayerOwner[i]) == null ? void 0 : _curveLayerOwner_i.curveOwner.saveDefaultValue();
23652
24067
  }
23653
24068
  };
23654
24069
  _proto._getAnimatorStateData = function _getAnimatorStateData(stateName, animatorState, animatorLayerData) {
@@ -23657,25 +24072,32 @@ exports.AnimatorLayerBlendingMode = void 0;
23657
24072
  if (!animatorStateData) {
23658
24073
  animatorStateData = new AnimatorStateData();
23659
24074
  animatorStateDataMap[stateName] = animatorStateData;
23660
- this._saveAnimatorStateData(animatorState, animatorStateData);
24075
+ this._saveAnimatorStateData(animatorState, animatorStateData, animatorLayerData);
23661
24076
  this._saveAnimatorEventHandlers(animatorState, animatorStateData);
23662
24077
  }
23663
24078
  return animatorStateData;
23664
24079
  };
23665
- _proto._saveAnimatorStateData = function _saveAnimatorStateData(animatorState, animatorStateData) {
23666
- var _this = this, entity = _this.entity, animationCureOwners = _this._animationCurveOwners;
23667
- var curveOwners = animatorStateData.curveOwners;
24080
+ _proto._saveAnimatorStateData = function _saveAnimatorStateData(animatorState, animatorStateData, animatorLayerData) {
24081
+ var _this = this, entity = _this.entity, curveOwnerPool = _this._curveOwnerPool;
24082
+ var curveLayerOwner = animatorStateData.curveLayerOwner;
24083
+ var layerCurveOwnerPool = animatorLayerData.curveOwnerPool;
23668
24084
  var _animatorState_clip = animatorState.clip, curves = _animatorState_clip._curveBindings;
23669
24085
  for(var i = curves.length - 1; i >= 0; i--){
23670
24086
  var curve = curves[i];
23671
24087
  var targetEntity = curve.relativePath === "" ? entity : entity.findByPath(curve.relativePath);
23672
24088
  if (targetEntity) {
24089
+ var _curveOwnerPool, _instanceId, _propertyOwners, _property, _layerCurveOwnerPool, _instanceId1, _layerPropertyOwners, _property1;
23673
24090
  var property = curve.property;
23674
24091
  var instanceId = targetEntity.instanceId;
23675
- var propertyOwners = animationCureOwners[instanceId] || (animationCureOwners[instanceId] = {});
23676
- curveOwners[i] = propertyOwners[property] || (propertyOwners[property] = curve._createCurveOwner(targetEntity));
24092
+ // Get owner
24093
+ var propertyOwners = (_curveOwnerPool = curveOwnerPool)[_instanceId = instanceId] || (_curveOwnerPool[_instanceId] = Object.create(null));
24094
+ var owner = (_propertyOwners = propertyOwners)[_property = property] || (_propertyOwners[_property] = curve._createCurveOwner(targetEntity));
24095
+ // Get layer owner
24096
+ var layerPropertyOwners = (_layerCurveOwnerPool = layerCurveOwnerPool)[_instanceId1 = instanceId] || (_layerCurveOwnerPool[_instanceId1] = Object.create(null));
24097
+ var layerOwner = (_layerPropertyOwners = layerPropertyOwners)[_property1 = property] || (_layerPropertyOwners[_property1] = curve._createCurveLayerOwner(owner));
24098
+ curveLayerOwner[i] = layerOwner;
23677
24099
  } else {
23678
- curveOwners[i] = null;
24100
+ curveLayerOwner[i] = null;
23679
24101
  console.warn("The entity don't have the child entity which path is " + curve.relativePath + ".");
23680
24102
  }
23681
24103
  }
@@ -23703,65 +24125,61 @@ exports.AnimatorLayerBlendingMode = void 0;
23703
24125
  };
23704
24126
  _proto._clearCrossData = function _clearCrossData(animatorLayerData) {
23705
24127
  animatorLayerData.crossCurveMark++;
23706
- this._crossOwnerCollection.length = 0;
24128
+ animatorLayerData.crossOwnerLayerDataCollection.length = 0;
23707
24129
  };
23708
- _proto._addCrossCurveData = function _addCrossCurveData(crossCurveData, owner, curCurveIndex, nextCurveIndex) {
23709
- owner.crossSrcCurveIndex = curCurveIndex;
23710
- owner.crossDestCurveIndex = nextCurveIndex;
23711
- crossCurveData.push(owner);
24130
+ _proto._addCrossOwner = function _addCrossOwner(animatorLayerData, layerOwner, curCurveIndex, nextCurveIndex) {
24131
+ layerOwner.crossSrcCurveIndex = curCurveIndex;
24132
+ layerOwner.crossDestCurveIndex = nextCurveIndex;
24133
+ animatorLayerData.crossOwnerLayerDataCollection.push(layerOwner);
23712
24134
  };
23713
24135
  _proto._prepareCrossFading = function _prepareCrossFading(animatorLayerData) {
23714
- var crossCurveData = this._crossOwnerCollection;
23715
- var crossCurveMark = animatorLayerData.crossCurveMark;
23716
24136
  // Add src cross curve data.
23717
- this._prepareSrcCrossData(crossCurveData, animatorLayerData.srcPlayData, crossCurveMark, false);
24137
+ this._prepareSrcCrossData(animatorLayerData, false);
23718
24138
  // Add dest cross curve data.
23719
- this._prepareDestCrossData(crossCurveData, animatorLayerData.destPlayData, crossCurveMark, false);
24139
+ this._prepareDestCrossData(animatorLayerData, false);
23720
24140
  };
23721
24141
  _proto._prepareStandbyCrossFading = function _prepareStandbyCrossFading(animatorLayerData) {
23722
- var crossOwnerCollection = this._crossOwnerCollection;
23723
- var srcPlayData = animatorLayerData.srcPlayData, crossCurveMark = animatorLayerData.crossCurveMark;
23724
24142
  // Standby have two sub state, one is never play, one is finished, never play srcPlayData.state is null.
23725
- srcPlayData.state && this._prepareSrcCrossData(crossOwnerCollection, srcPlayData, crossCurveMark, true);
24143
+ animatorLayerData.srcPlayData.state && this._prepareSrcCrossData(animatorLayerData, true);
23726
24144
  // Add dest cross curve data.
23727
- this._prepareDestCrossData(crossOwnerCollection, animatorLayerData.destPlayData, crossCurveMark, true);
24145
+ this._prepareDestCrossData(animatorLayerData, true);
23728
24146
  };
23729
24147
  _proto._prepareFixedPoseCrossFading = function _prepareFixedPoseCrossFading(animatorLayerData) {
23730
- var crossOwnerCollection = this._crossOwnerCollection;
24148
+ var crossOwnerLayerDataCollection = animatorLayerData.crossOwnerLayerDataCollection;
23731
24149
  // Save current cross curve data owner fixed pose.
23732
- for(var i = crossOwnerCollection.length - 1; i >= 0; i--){
23733
- var item = crossOwnerCollection[i];
23734
- item.saveFixedPoseValue();
24150
+ for(var i = crossOwnerLayerDataCollection.length - 1; i >= 0; i--){
24151
+ var layerOwner = crossOwnerLayerDataCollection[i];
24152
+ if (!layerOwner) continue;
24153
+ layerOwner.curveOwner.saveFixedPoseValue();
23735
24154
  // Reset destCurveIndex When fixed pose crossFading again.
23736
- item.crossDestCurveIndex = -1;
24155
+ layerOwner.crossDestCurveIndex = -1;
23737
24156
  }
23738
24157
  // prepare dest AnimatorState cross data.
23739
- this._prepareDestCrossData(crossOwnerCollection, animatorLayerData.destPlayData, animatorLayerData.crossCurveMark, true);
23740
- };
23741
- _proto._prepareSrcCrossData = function _prepareSrcCrossData(crossCurveData, srcPlayData, crossCurveMark, saveFixed) {
23742
- var curveOwners = srcPlayData.stateData.curveOwners;
23743
- for(var i = curveOwners.length - 1; i >= 0; i--){
23744
- var owner = curveOwners[i];
23745
- if (!owner) continue;
23746
- owner.crossCurveMark = crossCurveMark;
23747
- owner.crossCurveDataIndex = crossCurveData.length;
23748
- saveFixed && owner.saveFixedPoseValue();
23749
- this._addCrossCurveData(crossCurveData, owner, i, -1);
23750
- }
23751
- };
23752
- _proto._prepareDestCrossData = function _prepareDestCrossData(crossCurveData, destPlayData, crossCurveMark, saveFixed) {
23753
- var curveOwners = destPlayData.stateData.curveOwners;
23754
- for(var i = curveOwners.length - 1; i >= 0; i--){
23755
- var owner = curveOwners[i];
23756
- if (!owner) continue;
23757
- if (owner.crossCurveMark === crossCurveMark) {
23758
- crossCurveData[owner.crossCurveDataIndex].crossDestCurveIndex = i;
24158
+ this._prepareDestCrossData(animatorLayerData, true);
24159
+ };
24160
+ _proto._prepareSrcCrossData = function _prepareSrcCrossData(animatorLayerData, saveFixed) {
24161
+ var curveLayerOwner = animatorLayerData.srcPlayData.stateData.curveLayerOwner;
24162
+ for(var i = curveLayerOwner.length - 1; i >= 0; i--){
24163
+ var layerOwner = curveLayerOwner[i];
24164
+ if (!layerOwner) continue;
24165
+ layerOwner.crossCurveMark = animatorLayerData.crossCurveMark;
24166
+ saveFixed && layerOwner.curveOwner.saveFixedPoseValue();
24167
+ this._addCrossOwner(animatorLayerData, layerOwner, i, -1);
24168
+ }
24169
+ };
24170
+ _proto._prepareDestCrossData = function _prepareDestCrossData(animatorLayerData, saveFixed) {
24171
+ var curveLayerOwner = animatorLayerData.destPlayData.stateData.curveLayerOwner;
24172
+ for(var i = curveLayerOwner.length - 1; i >= 0; i--){
24173
+ var layerOwner = curveLayerOwner[i];
24174
+ if (!layerOwner) continue;
24175
+ if (layerOwner.crossCurveMark === animatorLayerData.crossCurveMark) {
24176
+ layerOwner.crossDestCurveIndex = i;
23759
24177
  } else {
24178
+ var owner = layerOwner.curveOwner;
23760
24179
  owner.saveDefaultValue();
23761
24180
  saveFixed && owner.saveFixedPoseValue();
23762
- owner.crossCurveMark = crossCurveMark;
23763
- owner.crossCurveDataIndex = crossCurveData.length;
23764
- this._addCrossCurveData(crossCurveData, owner, -1, i);
24181
+ layerOwner.crossCurveMark = animatorLayerData.crossCurveMark;
24182
+ this._addCrossOwner(animatorLayerData, layerOwner, -1, i);
23765
24183
  }
23766
24184
  }
23767
24185
  };
@@ -23791,7 +24209,7 @@ exports.AnimatorLayerBlendingMode = void 0;
23791
24209
  }
23792
24210
  };
23793
24211
  _proto._updatePlayingState = function _updatePlayingState(playData, layerData, layerIndex, weight, delta, additive, aniUpdate) {
23794
- var _playData_stateData = playData.stateData, curveOwners = _playData_stateData.curveOwners, eventHandlers = _playData_stateData.eventHandlers;
24212
+ var _playData_stateData = playData.stateData, curveLayerOwner = _playData_stateData.curveLayerOwner, eventHandlers = _playData_stateData.eventHandlers;
23795
24213
  var state = playData.state, lastPlayState = playData.playState, lastClipTime = playData.clipTime;
23796
24214
  var _state_clip = state.clip, curveBindings = _state_clip._curveBindings;
23797
24215
  playData.update(this.speed < 0);
@@ -23801,8 +24219,8 @@ exports.AnimatorLayerBlendingMode = void 0;
23801
24219
  var clipTime = playData.clipTime, playState = playData.playState;
23802
24220
  eventHandlers.length && this._fireAnimationEvents(playData, eventHandlers, lastClipTime, clipTime);
23803
24221
  for(var i = curveBindings.length - 1; i >= 0; i--){
23804
- var owner = curveOwners[i];
23805
- owner == null ? void 0 : owner.evaluateAndApplyValue(curveBindings[i].curve, clipTime, weight, additive);
24222
+ var _curveLayerOwner_i;
24223
+ (_curveLayerOwner_i = curveLayerOwner[i]) == null ? void 0 : _curveLayerOwner_i.curveOwner.evaluateAndApplyValue(curveBindings[i].curve, clipTime, weight, additive);
23806
24224
  }
23807
24225
  playData.frameTime += state.speed * delta;
23808
24226
  if (playState === AnimatorStatePlayState.Finished) {
@@ -23818,7 +24236,7 @@ exports.AnimatorLayerBlendingMode = void 0;
23818
24236
  }
23819
24237
  };
23820
24238
  _proto._updateCrossFade = function _updateCrossFade(srcPlayData, destPlayData, layerData, layerIndex, weight, delta, additive, aniUpdate) {
23821
- var _this = this, crossCurveDataCollection = _this._crossOwnerCollection;
24239
+ var crossOwnerLayerDataCollection = layerData.crossOwnerLayerDataCollection;
23822
24240
  var _srcPlayData_state_clip = srcPlayData.state.clip, srcCurves = _srcPlayData_state_clip._curveBindings;
23823
24241
  var srcState = srcPlayData.state, srcStateData = srcPlayData.stateData, lastSrcPlayState = srcPlayData.playState;
23824
24242
  var srcEventHandlers = srcStateData.eventHandlers;
@@ -23857,14 +24275,16 @@ exports.AnimatorLayerBlendingMode = void 0;
23857
24275
  } else {
23858
24276
  this._callAnimatorScriptOnUpdate(destState, layerIndex);
23859
24277
  }
23860
- for(var i = crossCurveDataCollection.length - 1; i >= 0; i--){
23861
- var crossCurveData = crossCurveDataCollection[i];
23862
- var crossSrcCurveIndex = crossCurveData.crossSrcCurveIndex, crossDestCurveIndex = crossCurveData.crossDestCurveIndex;
23863
- crossCurveData.crossFadeAndApplyValue(crossSrcCurveIndex >= 0 ? srcCurves[crossSrcCurveIndex].curve : null, crossDestCurveIndex >= 0 ? destCurves[crossDestCurveIndex].curve : null, srcClipTime, destClipTime, crossWeight, weight, additive);
24278
+ for(var i = crossOwnerLayerDataCollection.length - 1; i >= 0; i--){
24279
+ var layerOwner = crossOwnerLayerDataCollection[i];
24280
+ if (!layerOwner) continue;
24281
+ var srcCurveIndex = layerOwner.crossSrcCurveIndex;
24282
+ var destCurveIndex = layerOwner.crossDestCurveIndex;
24283
+ layerOwner.curveOwner.crossFadeAndApplyValue(srcCurveIndex >= 0 ? srcCurves[srcCurveIndex].curve : null, destCurveIndex >= 0 ? destCurves[destCurveIndex].curve : null, srcClipTime, destClipTime, crossWeight, weight, additive);
23864
24284
  }
23865
24285
  };
23866
24286
  _proto._updateCrossFadeFromPose = function _updateCrossFadeFromPose(destPlayData, layerData, layerIndex, layerWeight, delta, additive, aniUpdate) {
23867
- var crossCurveDataCollection = this._crossOwnerCollection;
24287
+ var crossOwnerLayerDataCollection = layerData.crossOwnerLayerDataCollection;
23868
24288
  var state = destPlayData.state, stateData = destPlayData.stateData, lastPlayState = destPlayData.playState;
23869
24289
  var eventHandlers = stateData.eventHandlers;
23870
24290
  var _state_clip = state.clip, curveBindings = _state_clip._curveBindings;
@@ -23888,10 +24308,11 @@ exports.AnimatorLayerBlendingMode = void 0;
23888
24308
  } else {
23889
24309
  this._callAnimatorScriptOnUpdate(state, layerIndex);
23890
24310
  }
23891
- for(var i = crossCurveDataCollection.length - 1; i >= 0; i--){
23892
- var crossCurveData = crossCurveDataCollection[i];
23893
- var crossDestCurveIndex = crossCurveData.crossDestCurveIndex;
23894
- crossCurveData.crossFadeFromPoseAndApplyValue(crossDestCurveIndex >= 0 ? curveBindings[crossDestCurveIndex].curve : null, destClipTime, crossWeight, layerWeight, additive);
24311
+ for(var i = crossOwnerLayerDataCollection.length - 1; i >= 0; i--){
24312
+ var layerOwner = crossOwnerLayerDataCollection[i];
24313
+ if (!layerOwner) continue;
24314
+ var curveIndex = layerOwner.crossDestCurveIndex;
24315
+ layerOwner.curveOwner.crossFadeFromPoseAndApplyValue(curveIndex >= 0 ? curveBindings[curveIndex].curve : null, destClipTime, crossWeight, layerWeight, additive);
23895
24316
  }
23896
24317
  };
23897
24318
  _proto._updateCrossFadeData = function _updateCrossFadeData(layerData, crossWeight, delta, fixed) {
@@ -23913,18 +24334,19 @@ exports.AnimatorLayerBlendingMode = void 0;
23913
24334
  if (layerData.layerState === LayerState.Playing) {
23914
24335
  var srcPlayData = layerData.srcPlayData;
23915
24336
  if (srcPlayData.state !== playState) {
23916
- var curveOwners = srcPlayData.stateData.curveOwners;
23917
- for(var i = curveOwners.length - 1; i >= 0; i--){
23918
- var owner = curveOwners[i];
24337
+ var curveLayerOwner = srcPlayData.stateData.curveLayerOwner;
24338
+ for(var i = curveLayerOwner.length - 1; i >= 0; i--){
24339
+ var _curveLayerOwner_i;
24340
+ var owner = (_curveLayerOwner_i = curveLayerOwner[i]) == null ? void 0 : _curveLayerOwner_i.curveOwner;
23919
24341
  (owner == null ? void 0 : owner.hasSavedDefaultValue) && owner.revertDefaultValue();
23920
24342
  }
23921
24343
  this._saveDefaultValues(playStateData);
23922
24344
  }
23923
24345
  } else {
23924
24346
  // layerState is CrossFading, FixedCrossFading, Standby
23925
- var crossCurveDataCollection = this._crossOwnerCollection;
23926
- for(var i1 = crossCurveDataCollection.length - 1; i1 >= 0; i1--){
23927
- var owner1 = crossCurveDataCollection[i1];
24347
+ var crossOwnerLayerDataCollection = layerData.crossOwnerLayerDataCollection;
24348
+ for(var i1 = crossOwnerLayerDataCollection.length - 1; i1 >= 0; i1--){
24349
+ var owner1 = crossOwnerLayerDataCollection[i1].curveOwner;
23928
24350
  owner1.hasSavedDefaultValue && owner1.revertDefaultValue();
23929
24351
  }
23930
24352
  this._saveDefaultValues(playStateData);
@@ -24094,10 +24516,7 @@ __decorate([
24094
24516
  ], Animator.prototype, "_animatorLayersData", void 0);
24095
24517
  __decorate([
24096
24518
  ignoreClone
24097
- ], Animator.prototype, "_crossOwnerCollection", void 0);
24098
- __decorate([
24099
- ignoreClone
24100
- ], Animator.prototype, "_animationCurveOwners", void 0);
24519
+ ], Animator.prototype, "_curveOwnerPool", void 0);
24101
24520
  __decorate([
24102
24521
  ignoreClone
24103
24522
  ], Animator.prototype, "_animationEventHandlerPool", void 0);
@@ -25530,7 +25949,9 @@ var _tempVector3 = new engineMath.Vector3();
25530
25949
  this.getMaterial().shaderData.setTexture("u_texture", texture);
25531
25950
  }
25532
25951
  };
25533
- _proto._render = function _render(context) {
25952
+ /**
25953
+ * @internal
25954
+ */ _proto._render = function _render(context) {
25534
25955
  this._updateStrapVertices(context.camera, this._points);
25535
25956
  this._updateStrapCoords();
25536
25957
  this._vertexBuffer.setData(this._vertices);
@@ -25724,7 +26145,7 @@ var cacheDir = new engineMath.Vector3();
25724
26145
  /**
25725
26146
  * The position of the probe can be set, the default is the origin [0,0,0].
25726
26147
  */ _this.position = new engineMath.Vector3(0, 0, 0);
25727
- _this._isCube = true;
26148
+ /** @internal */ _this._isCube = true;
25728
26149
  _this.oriViewMatrix = new engineMath.Matrix();
25729
26150
  return _this;
25730
26151
  }
@@ -25814,6 +26235,7 @@ exports.Basic2DBatcher = Basic2DBatcher;
25814
26235
  exports.BasicRenderPipeline = BasicRenderPipeline;
25815
26236
  exports.BlendShape = BlendShape;
25816
26237
  exports.BlendShapeFrame = BlendShapeFrame;
26238
+ exports.BlendState = BlendState;
25817
26239
  exports.BlinnPhongMaterial = BlinnPhongMaterial;
25818
26240
  exports.BoolUpdateFlag = BoolUpdateFlag;
25819
26241
  exports.BoxColliderShape = BoxColliderShape;
@@ -25827,6 +26249,7 @@ exports.ColliderShape = ColliderShape;
25827
26249
  exports.Component = Component;
25828
26250
  exports.ContentRestorer = ContentRestorer;
25829
26251
  exports.CubeProbe = CubeProbe;
26252
+ exports.DepthState = DepthState;
25830
26253
  exports.DirectLight = DirectLight;
25831
26254
  exports.DynamicCollider = DynamicCollider;
25832
26255
  exports.Engine = Engine;
@@ -25860,10 +26283,13 @@ exports.PointLight = PointLight;
25860
26283
  exports.Pointer = Pointer;
25861
26284
  exports.PrimitiveMesh = PrimitiveMesh;
25862
26285
  exports.Probe = Probe;
26286
+ exports.RasterState = RasterState;
25863
26287
  exports.ReferResource = ReferResource;
25864
26288
  exports.RenderPass = RenderPass;
25865
26289
  exports.RenderQueue = RenderQueue;
26290
+ exports.RenderState = RenderState;
25866
26291
  exports.RenderTarget = RenderTarget;
26292
+ exports.RenderTargetBlendState = RenderTargetBlendState;
25867
26293
  exports.ResourceManager = ResourceManager;
25868
26294
  exports.Scene = Scene;
25869
26295
  exports.SceneManager = SceneManager;
@@ -25890,6 +26316,7 @@ exports.SpriteMask = SpriteMask;
25890
26316
  exports.SpriteRenderer = SpriteRenderer;
25891
26317
  exports.StateMachineScript = StateMachineScript;
25892
26318
  exports.StaticCollider = StaticCollider;
26319
+ exports.StencilState = StencilState;
25893
26320
  exports.SubMesh = SubMesh;
25894
26321
  exports.SubShader = SubShader;
25895
26322
  exports.SystemInfo = SystemInfo;