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