@galacean/engine-core 1.0.0-beta.1 → 1.0.0-beta.11

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 (58) hide show
  1. package/dist/main.js +936 -356
  2. package/dist/main.js.map +1 -1
  3. package/dist/miniprogram.js +936 -356
  4. package/dist/module.js +931 -357
  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 +5 -6
  14. package/types/Component.d.ts +0 -1
  15. package/types/Engine.d.ts +0 -2
  16. package/types/RenderPipeline/ClassPool.d.ts +3 -1
  17. package/types/RenderPipeline/IPoolElement.d.ts +3 -0
  18. package/types/RenderPipeline/MeshRenderData.d.ts +3 -1
  19. package/types/RenderPipeline/RenderElement.d.ts +3 -1
  20. package/types/RenderPipeline/SpriteMaskRenderData.d.ts +3 -1
  21. package/types/RenderPipeline/SpriteRenderData.d.ts +3 -1
  22. package/types/RenderPipeline/TextRenderData.d.ts +3 -1
  23. package/types/Renderer.d.ts +8 -13
  24. package/types/SafeLoopArray.d.ts +37 -0
  25. package/types/Scene.d.ts +10 -4
  26. package/types/Script.d.ts +0 -1
  27. package/types/animation/Animator.d.ts +2 -3
  28. package/types/animation/internal/AnimationCurveLayerOwner.d.ts +1 -0
  29. package/types/animation/internal/AnimationCurveOwnerLayerData.d.ts +1 -0
  30. package/types/asset/GraphicsResource.d.ts +0 -1
  31. package/types/asset/ReferResource.d.ts +0 -1
  32. package/types/enums/ActiveChangeFlag.d.ts +6 -0
  33. package/types/env-probe/CubeProbe.d.ts +0 -1
  34. package/types/graphic/Buffer.d.ts +0 -1
  35. package/types/graphic/Mesh.d.ts +2 -6
  36. package/types/graphic/SubMesh.d.ts +3 -1
  37. package/types/index.d.ts +1 -1
  38. package/types/lighting/Light.d.ts +0 -1
  39. package/types/material/Material.d.ts +9 -2
  40. package/types/material/PBRMaterial.d.ts +11 -2
  41. package/types/mesh/MeshRenderer.d.ts +8 -8
  42. package/types/mesh/ModelMesh.d.ts +0 -1
  43. package/types/mesh/SkinnedMeshRenderer.d.ts +0 -4
  44. package/types/physics/Collider.d.ts +0 -1
  45. package/types/physics/PhysicsScene.d.ts +75 -0
  46. package/types/shader/index.d.ts +1 -0
  47. package/types/shader/state/index.d.ts +6 -0
  48. package/types/shadow/CascadedShadowCasterPass.d.ts +1 -0
  49. package/types/sky/Sky.d.ts +12 -4
  50. package/types/texture/RenderTarget.d.ts +0 -1
  51. package/types/texture/Texture.d.ts +0 -1
  52. package/types/trail/TrailRenderer.d.ts +0 -2
  53. package/types/utils/BoolUpdateFlag.d.ts +12 -0
  54. package/types/utils/DisorderedArray.d.ts +18 -0
  55. package/types/utils/SafeLoopArray.d.ts +41 -0
  56. package/types/utils/UpdateFlag.d.ts +20 -0
  57. package/types/utils/UpdateFlagManager.d.ts +1 -0
  58. package/types/utils/Utils.d.ts +31 -0
package/dist/module.js CHANGED
@@ -678,7 +678,9 @@ __decorate([
678
678
  */ _proto._addToResourceManager = function _addToResourceManager(path) {
679
679
  this._engine.resourceManager._addAsset(path, this);
680
680
  };
681
- _proto._onDestroy = function _onDestroy() {
681
+ /**
682
+ * @internal
683
+ */ _proto._onDestroy = function _onDestroy() {
682
684
  EngineObject.prototype._onDestroy.call(this);
683
685
  this._engine.resourceManager._deleteReferResource(this);
684
686
  var refCount = this._getReferCount();
@@ -810,7 +812,9 @@ var GraphicsResource = /*#__PURE__*/ function(ReferResource) {
810
812
  return _this;
811
813
  }
812
814
  var _proto = GraphicsResource.prototype;
813
- _proto._onDestroy = function _onDestroy() {
815
+ /**
816
+ * @internal
817
+ */ _proto._onDestroy = function _onDestroy() {
814
818
  ReferResource.prototype._onDestroy.call(this);
815
819
  this.engine.resourceManager._deleteGraphicResource(this);
816
820
  };
@@ -889,7 +893,9 @@ var Logger = {
889
893
  platformTexture.depthCompareFunction = this._depthCompareFunction;
890
894
  platformTexture.setUseDepthCompareMode(this._useDepthCompareMode);
891
895
  };
892
- _proto._onDestroy = function _onDestroy() {
896
+ /**
897
+ * @internal
898
+ */ _proto._onDestroy = function _onDestroy() {
893
899
  GraphicsResource.prototype._onDestroy.call(this);
894
900
  this._platformTexture.destroy();
895
901
  this._platformTexture = null;
@@ -1039,9 +1045,11 @@ var Logger = {
1039
1045
  renderTexture
1040
1046
  ];
1041
1047
  for(var i = 0, n = colorTextures.length; i < n; i++){
1042
- if (colorTextures[i]._isDepthTexture) {
1048
+ var colorTexture = colorTextures[i];
1049
+ if (colorTexture._isDepthTexture) {
1043
1050
  throw "Render texture can't use depth format.";
1044
1051
  }
1052
+ colorTexture._addReferCount(1);
1045
1053
  }
1046
1054
  _this._colorTextures = colorTextures;
1047
1055
  } else {
@@ -1052,6 +1060,7 @@ var Logger = {
1052
1060
  throw "Depth texture must use depth format.";
1053
1061
  }
1054
1062
  _this._depthTexture = depth;
1063
+ _this._depthTexture._addReferCount(1);
1055
1064
  }
1056
1065
  _this._platformRenderTarget = engine._hardwareRenderer.createPlatformRenderTarget(_assert_this_initialized(_this));
1057
1066
  return _this;
@@ -1077,10 +1086,18 @@ var Logger = {
1077
1086
  this._depthTexture && this._depthTexture.generateMipmaps();
1078
1087
  }
1079
1088
  };
1080
- _proto._onDestroy = function _onDestroy() {
1089
+ /**
1090
+ * @internal
1091
+ */ _proto._onDestroy = function _onDestroy() {
1092
+ var _this__depthTexture;
1081
1093
  GraphicsResource.prototype._onDestroy.call(this);
1082
1094
  this._platformRenderTarget.destroy();
1083
- this._colorTextures.length = 0;
1095
+ var _this = this, colorTextures = _this._colorTextures;
1096
+ for(var i = 0, n = colorTextures.length; i < n; i++){
1097
+ colorTextures[i]._addReferCount(-1);
1098
+ }
1099
+ colorTextures.length = 0;
1100
+ (_this__depthTexture = this._depthTexture) == null ? void 0 : _this__depthTexture._addReferCount(-1);
1084
1101
  this._depthTexture = null;
1085
1102
  this._depth = null;
1086
1103
  };
@@ -1455,7 +1472,9 @@ var Logger = {
1455
1472
  _proto.getCharInfo = function getCharInfo(char) {
1456
1473
  return this._charInfoMap[char.charCodeAt(0)];
1457
1474
  };
1458
- _proto._onDestroy = function _onDestroy() {
1475
+ /**
1476
+ * @internal
1477
+ */ _proto._onDestroy = function _onDestroy() {
1459
1478
  ReferResource.prototype._onDestroy.call(this);
1460
1479
  this.texture.destroy();
1461
1480
  this.texture = null;
@@ -1962,6 +1981,7 @@ var Logger = {
1962
1981
  var fontAtlas = new FontAtlas(engine);
1963
1982
  var texture = new Texture2D(engine, 256, 256);
1964
1983
  fontAtlas.texture = texture;
1984
+ fontAtlas.isGCIgnored = texture.isGCIgnored = true;
1965
1985
  this._fontAtlases.push(fontAtlas);
1966
1986
  var nativeFontString = this.nativeFontString;
1967
1987
  engine.resourceManager.addContentRestorer(new /*#__PURE__*/ (function(ContentRestorer) {
@@ -2018,7 +2038,9 @@ var Logger = {
2018
2038
  subFontMap[key] = subFont;
2019
2039
  return subFont;
2020
2040
  };
2021
- _proto._onDestroy = function _onDestroy() {
2041
+ /**
2042
+ * @internal
2043
+ */ _proto._onDestroy = function _onDestroy() {
2022
2044
  ReferResource.prototype._onDestroy.call(this);
2023
2045
  var subFontMap = this._subFontMap;
2024
2046
  for(var k in subFontMap){
@@ -2262,6 +2284,29 @@ var /** @internal */ PromiseState;
2262
2284
  * @remarks The release principle is that it is not referenced by the components, including direct and indirect reference.
2263
2285
  */ _proto.gc = function gc() {
2264
2286
  this._gc(false);
2287
+ var engine = this.engine;
2288
+ engine._renderElementPool.garbageCollection();
2289
+ engine._meshRenderDataPool.garbageCollection();
2290
+ engine._spriteRenderDataPool.garbageCollection();
2291
+ engine._spriteMaskRenderDataPool.garbageCollection();
2292
+ engine._textRenderDataPool.garbageCollection();
2293
+ var _componentsManager = engine._componentsManager, _lightManager = engine._lightManager;
2294
+ _componentsManager._renderers.garbageCollection();
2295
+ // @ts-ignore
2296
+ _componentsManager._onStartScripts.garbageCollection();
2297
+ // @ts-ignore
2298
+ _componentsManager._onUpdateScripts.garbageCollection();
2299
+ // @ts-ignore
2300
+ _componentsManager._onLateUpdateScripts.garbageCollection();
2301
+ // @ts-ignore
2302
+ _componentsManager._onPhysicsUpdateScripts.garbageCollection();
2303
+ // @ts-ignore
2304
+ _componentsManager._onUpdateAnimations.garbageCollection();
2305
+ // @ts-ignore
2306
+ _componentsManager._onUpdateRenderers.garbageCollection();
2307
+ _lightManager._spotLights.garbageCollection();
2308
+ _lightManager._pointLights.garbageCollection();
2309
+ _lightManager._directLights.garbageCollection();
2265
2310
  };
2266
2311
  /**
2267
2312
  * Add content restorer.
@@ -3237,7 +3282,9 @@ var GLCapabilityType;
3237
3282
  }
3238
3283
  }
3239
3284
  };
3240
- _proto._onDestroy = function _onDestroy() {
3285
+ /**
3286
+ * @internal
3287
+ */ _proto._onDestroy = function _onDestroy() {
3241
3288
  EngineObject.prototype._onDestroy.call(this);
3242
3289
  this._entity._removeComponent(this);
3243
3290
  if (this._entity.isActiveInHierarchy) {
@@ -4695,6 +4742,11 @@ var ComponentCloner = /*#__PURE__*/ function() {
4695
4742
  * @returns Cloned entity
4696
4743
  */ _proto.clone = function clone() {
4697
4744
  var cloneEntity = new Entity(this._engine, this.name);
4745
+ var _this = this, hookResource = _this._hookResource;
4746
+ if (hookResource) {
4747
+ cloneEntity._hookResource = hookResource;
4748
+ hookResource._addReferCount(1);
4749
+ }
4698
4750
  cloneEntity._isActive = this._isActive;
4699
4751
  cloneEntity.transform.localMatrix = this.transform.localMatrix;
4700
4752
  var children = this._children;
@@ -4719,6 +4771,10 @@ var ComponentCloner = /*#__PURE__*/ function() {
4719
4771
  return;
4720
4772
  }
4721
4773
  EngineObject.prototype.destroy.call(this);
4774
+ if (this._hookResource) {
4775
+ this._hookResource._addReferCount(-1);
4776
+ this._hookResource = null;
4777
+ }
4722
4778
  var components = this._components;
4723
4779
  for(var i = components.length - 1; i >= 0; i--){
4724
4780
  components[i].destroy();
@@ -5247,14 +5303,14 @@ SystemInfo._initialize();
5247
5303
  Keys[Keys[/** Tab or ⇥. */ "Tab"] = 63] = "Tab";
5248
5304
  Keys[Keys[/** Japanese: 変換 (henkan). */ "Convert"] = 64] = "Convert";
5249
5305
  Keys[Keys[/** Japanese: カタカナ/ひらがな/ローマ字 (katakana/hiragana/romaji). */ "KanaMode"] = 65] = "KanaMode";
5250
- Keys[Keys[/**
5251
- * Korean: HangulMode 한/영 (han/yeong).
5252
- * Japanese (Mac keyboard): かな (kana).
5253
- * */ "Lang1"] = 66] = "Lang1";
5254
5306
  Keys[Keys[/**
5255
- * Korean: Hanja 한자 (hanja).
5256
- * Japanese (Mac keyboard): 英数 (eisu).
5257
- */ "Lang2"] = 67] = "Lang2";
5307
+ * Korean: HangulMode 한/영 (han/yeong).
5308
+ * Japanese (Mac keyboard): かな (kana).
5309
+ * */ "Lang1"] = 66] = "Lang1";
5310
+ Keys[Keys[/**
5311
+ * Korean: Hanja 한자 (hanja).
5312
+ * Japanese (Mac keyboard): 英数 (eisu).
5313
+ */ "Lang2"] = 67] = "Lang2";
5258
5314
  Keys[Keys[/** Japanese (word-processing keyboard): Katakana. */ "Lang3"] = 68] = "Lang3";
5259
5315
  Keys[Keys[/** Japanese (word-processing keyboard): Hiragana. */ "Lang4"] = 69] = "Lang4";
5260
5316
  Keys[Keys[/** Japanese (word-processing keyboard): Zenkaku/Hankaku. */ "Lang5"] = 70] = "Lang5";
@@ -5271,46 +5327,46 @@ SystemInfo._initialize();
5271
5327
  Keys[Keys[/** → */ "ArrowRight"] = 81] = "ArrowRight";
5272
5328
  Keys[Keys[/** ↑ */ "ArrowUp"] = 82] = "ArrowUp";
5273
5329
  Keys[Keys[/** On the Mac, the "NumLock" code should be used for the numpad Clear key. */ "NumLock"] = 83] = "NumLock";
5274
- Keys[Keys[/**
5275
- * 0 Ins on a keyboard.
5276
- * 0 on a phone or remote control.
5277
- * */ "Numpad0"] = 84] = "Numpad0";
5278
5330
  Keys[Keys[/**
5279
- * 1 End on a keyboard.
5280
- * 1 or 1 QZ on a phone or remote control.
5281
- */ "Numpad1"] = 85] = "Numpad1";
5331
+ * 0 Ins on a keyboard.
5332
+ * 0 on a phone or remote control.
5333
+ * */ "Numpad0"] = 84] = "Numpad0";
5334
+ Keys[Keys[/**
5335
+ * 1 End on a keyboard.
5336
+ * 1 or 1 QZ on a phone or remote control.
5337
+ */ "Numpad1"] = 85] = "Numpad1";
5282
5338
  Keys[Keys[/**
5283
- * 2 ↓ on a keyboard.
5284
- * 2 ABC on a phone or remote control.
5285
- */ "Numpad2"] = 86] = "Numpad2";
5339
+ * 2 ↓ on a keyboard.
5340
+ * 2 ABC on a phone or remote control.
5341
+ */ "Numpad2"] = 86] = "Numpad2";
5286
5342
  Keys[Keys[/**
5287
- * 3 PgDn on a keyboard.
5288
- * 3 DEF on a phone or remote control.
5289
- */ "Numpad3"] = 87] = "Numpad3";
5343
+ * 3 PgDn on a keyboard.
5344
+ * 3 DEF on a phone or remote control.
5345
+ */ "Numpad3"] = 87] = "Numpad3";
5290
5346
  Keys[Keys[/**
5291
- * 4 ← on a keyboard.
5292
- * 4 GHI on a phone or remote control.
5293
- */ "Numpad4"] = 88] = "Numpad4";
5347
+ * 4 ← on a keyboard.
5348
+ * 4 GHI on a phone or remote control.
5349
+ */ "Numpad4"] = 88] = "Numpad4";
5294
5350
  Keys[Keys[/**
5295
- * 5 on a keyboard.
5296
- * 5 JKL on a phone or remote control.
5297
- */ "Numpad5"] = 89] = "Numpad5";
5351
+ * 5 on a keyboard.
5352
+ * 5 JKL on a phone or remote control.
5353
+ */ "Numpad5"] = 89] = "Numpad5";
5298
5354
  Keys[Keys[/**
5299
- * 6 → on a keyboard.
5300
- * 6 MNO on a phone or remote control.
5301
- */ "Numpad6"] = 90] = "Numpad6";
5355
+ * 6 → on a keyboard.
5356
+ * 6 MNO on a phone or remote control.
5357
+ */ "Numpad6"] = 90] = "Numpad6";
5302
5358
  Keys[Keys[/**
5303
- * 7 Home on a keyboard.
5304
- * 7 PQRS or 7 PRS on a phone or remote control.
5305
- */ "Numpad7"] = 91] = "Numpad7";
5359
+ * 7 Home on a keyboard.
5360
+ * 7 PQRS or 7 PRS on a phone or remote control.
5361
+ */ "Numpad7"] = 91] = "Numpad7";
5306
5362
  Keys[Keys[/**
5307
- * 8 ↑ on a keyboard.
5308
- * 8 TUV on a phone or remote control.
5309
- */ "Numpad8"] = 92] = "Numpad8";
5363
+ * 8 ↑ on a keyboard.
5364
+ * 8 TUV on a phone or remote control.
5365
+ */ "Numpad8"] = 92] = "Numpad8";
5310
5366
  Keys[Keys[/**
5311
- * 9 PgUp on a keyboard.
5312
- * 9 WXYZ or 9 WXY on a phone or remote control.
5313
- */ "Numpad9"] = 93] = "Numpad9";
5367
+ * 9 PgUp on a keyboard.
5368
+ * 9 WXYZ or 9 WXY on a phone or remote control.
5369
+ */ "Numpad9"] = 93] = "Numpad9";
5314
5370
  Keys[Keys[/** + */ "NumpadAdd"] = 94] = "NumpadAdd";
5315
5371
  Keys[Keys[/** Found on the Microsoft Natural Keyboard. */ "NumpadBackspace"] = 95] = "NumpadBackspace";
5316
5372
  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";
@@ -5326,16 +5382,16 @@ SystemInfo._initialize();
5326
5382
  Keys[Keys[/** MR Replace the current entry with the value stored in memory. */ "NumpadMemoryRecall"] = 106] = "NumpadMemoryRecall";
5327
5383
  Keys[Keys[/** MS Replace the value stored in memory with the current entry. */ "NumpadMemoryStore"] = 107] = "NumpadMemoryStore";
5328
5384
  Keys[Keys[/** M- Subtract current entry from the value stored in memory. */ "NumpadMemorySubtract"] = 108] = "NumpadMemorySubtract";
5329
- Keys[Keys[/**
5330
- * * on a keyboard. For use with numpads that provide mathematical operations (+, -, * and /).
5331
- * Use "NumpadStar" for the * key on phones and remote controls.
5332
- */ "NumpadMultiply"] = 109] = "NumpadMultiply";
5385
+ Keys[Keys[/**
5386
+ * * on a keyboard. For use with numpads that provide mathematical operations (+, -, * and /).
5387
+ * Use "NumpadStar" for the * key on phones and remote controls.
5388
+ */ "NumpadMultiply"] = 109] = "NumpadMultiply";
5333
5389
  Keys[Keys[/** ( Found on the Microsoft Natural Keyboard. */ "NumpadParenLeft"] = 110] = "NumpadParenLeft";
5334
5390
  Keys[Keys[/** ) Found on the Microsoft Natural Keyboard. */ "NumpadParenRight"] = 111] = "NumpadParenRight";
5335
5391
  Keys[Keys[/**
5336
- * * on a phone or remote control device. This key is typically found below the 7 key and to the left of the 0 key.
5337
- * Use "NumpadMultiply" for the * key on numeric keypads.
5338
- */ "NumpadStar"] = 112] = "NumpadStar";
5392
+ * * on a phone or remote control device. This key is typically found below the 7 key and to the left of the 0 key.
5393
+ * Use "NumpadMultiply" for the * key on numeric keypads.
5394
+ */ "NumpadStar"] = 112] = "NumpadStar";
5339
5395
  Keys[Keys[/** - */ "NumpadSubtract"] = 113] = "NumpadSubtract";
5340
5396
  Keys[Keys[/** Esc or ⎋. */ "Escape"] = 114] = "Escape";
5341
5397
  Keys[Keys[/** F1 */ "F1"] = 115] = "F1";
@@ -6010,7 +6066,9 @@ var Collider = /*#__PURE__*/ function(Component) {
6010
6066
  */ _proto._onDisable = function _onDisable() {
6011
6067
  this.engine.physicsManager._removeCollider(this);
6012
6068
  };
6013
- _proto._onDestroy = function _onDestroy() {
6069
+ /**
6070
+ * @internal
6071
+ */ _proto._onDestroy = function _onDestroy() {
6014
6072
  Component.prototype._onDestroy.call(this);
6015
6073
  this.clearShapes();
6016
6074
  this._nativeCollider.destroy();
@@ -7860,7 +7918,10 @@ var DynamicColliderConstraints;
7860
7918
  return _this;
7861
7919
  }
7862
7920
  var _proto = Light.prototype;
7863
- _proto._getLightColor = function _getLightColor() {
7921
+ /**
7922
+ * Light Color, include intensity.
7923
+ * @internal
7924
+ */ _proto._getLightIntensityColor = function _getLightIntensityColor() {
7864
7925
  this._lightColor.r = this.color.r * this.intensity;
7865
7926
  this._lightColor.g = this.color.g * this.intensity;
7866
7927
  this._lightColor.b = this.color.b * this.intensity;
@@ -7930,15 +7991,21 @@ __decorate([
7930
7991
  var cullingMaskStart = lightIndex * 2;
7931
7992
  var colorStart = lightIndex * 3;
7932
7993
  var directionStart = lightIndex * 3;
7933
- var lightColor = this._getLightColor();
7994
+ var lightColor = this._getLightIntensityColor();
7934
7995
  var direction = this.direction;
7935
7996
  var data = DirectLight._combinedData;
7936
7997
  var cullingMask = this.cullingMask;
7937
7998
  data.cullingMask[cullingMaskStart] = cullingMask & 65535;
7938
7999
  data.cullingMask[cullingMaskStart + 1] = cullingMask >>> 16 & 65535;
7939
- data.color[colorStart] = lightColor.r;
7940
- data.color[colorStart + 1] = lightColor.g;
7941
- data.color[colorStart + 2] = lightColor.b;
8000
+ if (this.engine.settings.colorSpace === ColorSpace.Linear) {
8001
+ data.color[colorStart] = Color$1.gammaToLinearSpace(lightColor.r);
8002
+ data.color[colorStart + 1] = Color$1.gammaToLinearSpace(lightColor.g);
8003
+ data.color[colorStart + 2] = Color$1.gammaToLinearSpace(lightColor.b);
8004
+ } else {
8005
+ data.color[colorStart] = lightColor.r;
8006
+ data.color[colorStart + 1] = lightColor.g;
8007
+ data.color[colorStart + 2] = lightColor.b;
8008
+ }
7942
8009
  data.direction[directionStart] = direction.x;
7943
8010
  data.direction[directionStart + 1] = direction.y;
7944
8011
  data.direction[directionStart + 2] = direction.z;
@@ -8027,15 +8094,21 @@ __decorate([
8027
8094
  var colorStart = lightIndex * 3;
8028
8095
  var positionStart = lightIndex * 3;
8029
8096
  var distanceStart = lightIndex;
8030
- var lightColor = this._getLightColor();
8097
+ var lightColor = this._getLightIntensityColor();
8031
8098
  var lightPosition = this.position;
8032
8099
  var data = PointLight._combinedData;
8033
8100
  var cullingMask = this.cullingMask;
8034
8101
  data.cullingMask[cullingMaskStart] = cullingMask & 65535;
8035
8102
  data.cullingMask[cullingMaskStart + 1] = cullingMask >>> 16 & 65535;
8036
- data.color[colorStart] = lightColor.r;
8037
- data.color[colorStart + 1] = lightColor.g;
8038
- data.color[colorStart + 2] = lightColor.b;
8103
+ if (this.engine.settings.colorSpace === ColorSpace.Linear) {
8104
+ data.color[colorStart] = Color$1.gammaToLinearSpace(lightColor.r);
8105
+ data.color[colorStart + 1] = Color$1.gammaToLinearSpace(lightColor.g);
8106
+ data.color[colorStart + 2] = Color$1.gammaToLinearSpace(lightColor.b);
8107
+ } else {
8108
+ data.color[colorStart] = lightColor.r;
8109
+ data.color[colorStart + 1] = lightColor.g;
8110
+ data.color[colorStart + 2] = lightColor.b;
8111
+ }
8039
8112
  data.position[positionStart] = lightPosition.x;
8040
8113
  data.position[positionStart + 1] = lightPosition.y;
8041
8114
  data.position[positionStart + 2] = lightPosition.z;
@@ -8128,16 +8201,22 @@ __decorate([
8128
8201
  var distanceStart = lightIndex;
8129
8202
  var penumbraCosStart = lightIndex;
8130
8203
  var angleCosStart = lightIndex;
8131
- var color = this._getLightColor();
8204
+ var lightColor = this._getLightIntensityColor();
8132
8205
  var position = this.position;
8133
8206
  var direction = this.direction;
8134
8207
  var data = SpotLight._combinedData;
8135
8208
  var cullingMask = this.cullingMask;
8136
8209
  data.cullingMask[cullingMaskStart] = cullingMask & 65535;
8137
8210
  data.cullingMask[cullingMaskStart + 1] = cullingMask >>> 16 & 65535;
8138
- data.color[colorStart] = color.r;
8139
- data.color[colorStart + 1] = color.g;
8140
- data.color[colorStart + 2] = color.b;
8211
+ if (this.engine.settings.colorSpace === ColorSpace.Linear) {
8212
+ data.color[colorStart] = Color$1.gammaToLinearSpace(lightColor.r);
8213
+ data.color[colorStart + 1] = Color$1.gammaToLinearSpace(lightColor.g);
8214
+ data.color[colorStart + 2] = Color$1.gammaToLinearSpace(lightColor.b);
8215
+ } else {
8216
+ data.color[colorStart] = lightColor.r;
8217
+ data.color[colorStart + 1] = lightColor.g;
8218
+ data.color[colorStart + 2] = lightColor.b;
8219
+ }
8141
8220
  data.position[positionStart] = position.x;
8142
8221
  data.position[positionStart + 1] = position.y;
8143
8222
  data.position[positionStart + 2] = position.z;
@@ -8780,6 +8859,7 @@ __decorate([
8780
8859
  _proto.cloneTo = function cloneTo(target) {
8781
8860
  CloneManager.deepCloneObject(this._macroCollection, target._macroCollection);
8782
8861
  Object.assign(target._macroMap, this._macroMap);
8862
+ var referCount = target._getReferCount();
8783
8863
  var propertyValueMap = this._propertyValueMap;
8784
8864
  var targetPropertyValueMap = target._propertyValueMap;
8785
8865
  var keys = Object.keys(propertyValueMap);
@@ -8791,6 +8871,7 @@ __decorate([
8791
8871
  targetPropertyValueMap[k] = property;
8792
8872
  } else if (_instanceof(property, Texture)) {
8793
8873
  targetPropertyValueMap[k] = property;
8874
+ referCount > 0 && property._addReferCount(referCount);
8794
8875
  } else if (_instanceof(property, Array) || _instanceof(property, Float32Array) || _instanceof(property, Int32Array)) {
8795
8876
  targetPropertyValueMap[k] = property.slice();
8796
8877
  } else {
@@ -9348,9 +9429,9 @@ __decorate([
9348
9429
  function Material(engine, shader) {
9349
9430
  var _this;
9350
9431
  _this = ReferResource.call(this, engine) || this;
9351
- /** Shader data. */ _this.shaderData = new ShaderData(ShaderDataGroup.Material);
9352
9432
  /** @internal */ _this._renderStates = [] // todo: later will as a part of shaderData when shader effect frame is OK, that is more powerful and flexible.
9353
9433
  ;
9434
+ _this._shaderData = new ShaderData(ShaderDataGroup.Material);
9354
9435
  _this.shader = shader;
9355
9436
  return _this;
9356
9437
  }
@@ -9374,7 +9455,23 @@ __decorate([
9374
9455
  ReferResource.prototype._addReferCount.call(this, value);
9375
9456
  this.shaderData._addReferCount(value);
9376
9457
  };
9458
+ /**
9459
+ * @override
9460
+ */ _proto._onDestroy = function _onDestroy() {
9461
+ this._shader = null;
9462
+ this._shaderData = null;
9463
+ this._renderStates.length = 0;
9464
+ this._renderStates = null;
9465
+ };
9377
9466
  _create_class(Material, [
9467
+ {
9468
+ key: "shaderData",
9469
+ get: /**
9470
+ * Shader data.
9471
+ */ function get() {
9472
+ return this._shaderData;
9473
+ }
9474
+ },
9378
9475
  {
9379
9476
  key: "shader",
9380
9477
  get: /**
@@ -9447,6 +9544,12 @@ __decorate([
9447
9544
  */ _proto.resetPool = function resetPool() {
9448
9545
  this._elementPoolIndex = 0;
9449
9546
  };
9547
+ _proto.garbageCollection = function garbageCollection() {
9548
+ var _this = this, pool = _this._elementPool;
9549
+ for(var i = pool.length - 1; i >= 0; i--){
9550
+ pool[i].dispose && pool[i].dispose();
9551
+ }
9552
+ };
9450
9553
  return ClassPool;
9451
9554
  }();
9452
9555
 
@@ -9467,6 +9570,9 @@ var RenderData = function RenderData() {
9467
9570
  this.mesh = mesh;
9468
9571
  this.subMesh = subMesh;
9469
9572
  };
9573
+ _proto.dispose = function dispose() {
9574
+ this.component = this.material = this.mesh = this.subMesh = null;
9575
+ };
9470
9576
  return MeshRenderData;
9471
9577
  }(RenderData);
9472
9578
 
@@ -9495,11 +9601,11 @@ var camera_declare = "#define GLSLIFY 1\nuniform vec3 camera_Position;"; // esli
9495
9601
 
9496
9602
  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
9497
9603
 
9498
- 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
9604
+ 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
9499
9605
 
9500
9606
  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
9501
9607
 
9502
- var color_share = "#define GLSLIFY 1\n#ifdef RENDERER_HAS_VERTEXCOLOR\nvarying vec4 v_color;\n#endif\n"; // eslint-disable-line
9608
+ var color_share = "#define GLSLIFY 1\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nvarying vec4 v_color;\n#endif\n"; // eslint-disable-line
9503
9609
 
9504
9610
  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
9505
9611
 
@@ -9519,7 +9625,7 @@ var blendShape_input = "#define GLSLIFY 1\n#ifdef RENDERER_HAS_BLENDSHAPE\n#ifde
9519
9625
 
9520
9626
  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
9521
9627
 
9522
- var color_vert = "#define GLSLIFY 1\n#ifdef RENDERER_HAS_VERTEXCOLOR\nv_color=COLOR_0;\n#endif\n"; // eslint-disable-line
9628
+ var color_vert = "#define GLSLIFY 1\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nv_color=COLOR_0;\n#endif\n"; // eslint-disable-line
9523
9629
 
9524
9630
  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
9525
9631
 
@@ -9539,11 +9645,11 @@ var light_frag_define = "#define GLSLIFY 1\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nstr
9539
9645
 
9540
9646
  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
9541
9647
 
9542
- 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
9648
+ 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
9543
9649
 
9544
9650
  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
9545
9651
 
9546
- 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
9652
+ 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
9547
9653
 
9548
9654
  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
9549
9655
 
@@ -9577,9 +9683,9 @@ var noise_simplex_3D_grad = "#define GLSLIFY 1\nfloat simplex(vec3 v,out vec3 gr
9577
9683
 
9578
9684
  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
9579
9685
 
9580
- 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
9686
+ 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
9581
9687
 
9582
- 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
9688
+ 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
9583
9689
 
9584
9690
  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
9585
9691
 
@@ -9587,7 +9693,7 @@ var direct_irradiance_frag_define = "#define GLSLIFY 1\n#include <ShadowFragment
9587
9693
 
9588
9694
  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
9589
9695
 
9590
- 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
9696
+ 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
9591
9697
 
9592
9698
  var PBRShaderLib = {
9593
9699
  pbr_frag_define: pbr_frag_define,
@@ -9616,7 +9722,7 @@ var ShadowLib = {
9616
9722
  ShadowVertex: ShadowVertex
9617
9723
  };
9618
9724
 
9619
- 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
9725
+ 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
9620
9726
 
9621
9727
  var ShaderLib = _extends({
9622
9728
  common: common,
@@ -10612,6 +10718,9 @@ var RenderElement = /*#__PURE__*/ function() {
10612
10718
  this.shaderPass = shaderPass;
10613
10719
  this.renderState = renderState;
10614
10720
  };
10721
+ _proto.dispose = function dispose() {
10722
+ this.data = this.shaderPass = this.renderState = null;
10723
+ };
10615
10724
  return RenderElement;
10616
10725
  }();
10617
10726
 
@@ -10631,7 +10740,6 @@ var Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
10631
10740
  function Renderer1(entity) {
10632
10741
  var _this;
10633
10742
  _this = Component.call(this, entity) || this;
10634
- /** ShaderData related to renderer. */ _this.shaderData = new ShaderData(ShaderDataGroup.Renderer);
10635
10743
  /** @internal */ _this._onUpdateIndex = -1;
10636
10744
  /** @internal */ _this._rendererIndex = -1;
10637
10745
  /** @internal */ _this._globalShaderMacro = new ShaderMacroCollection();
@@ -10639,6 +10747,7 @@ var Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
10639
10747
  _this._overrideUpdate = false;
10640
10748
  _this._materials = [];
10641
10749
  _this._dirtyUpdateFlag = 0;
10750
+ _this._shaderData = new ShaderData(ShaderDataGroup.Renderer);
10642
10751
  _this._mvMatrix = new Matrix();
10643
10752
  _this._mvpMatrix = new Matrix();
10644
10753
  _this._mvInvMatrix = new Matrix();
@@ -10767,6 +10876,14 @@ var Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
10767
10876
  };
10768
10877
  /**
10769
10878
  * @internal
10879
+ */ _proto._cloneTo = function _cloneTo(target) {
10880
+ var materials = this._materials;
10881
+ for(var i = 0, n = materials.length; i < n; i++){
10882
+ target._setMaterial(i, materials[i]);
10883
+ }
10884
+ };
10885
+ /**
10886
+ * @internal
10770
10887
  */ _proto._onDestroy = function _onDestroy() {
10771
10888
  Component.prototype._onDestroy.call(this);
10772
10889
  this.entity.transform._updateFlagManager.removeListener(this._onTransformChanged);
@@ -10776,15 +10893,30 @@ var Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
10776
10893
  var _materials_i;
10777
10894
  (_materials_i = materials[i]) == null ? void 0 : _materials_i._addReferCount(-1);
10778
10895
  }
10896
+ this._entity = null;
10897
+ this._globalShaderMacro = null;
10898
+ this._bounds = null;
10899
+ this._materials = null;
10900
+ this._shaderData = null;
10901
+ this._mvMatrix = null;
10902
+ this._mvpMatrix = null;
10903
+ this._mvInvMatrix = null;
10904
+ this._normalMatrix = null;
10905
+ this._materialsInstanced = null;
10906
+ this._rendererLayer = null;
10779
10907
  };
10780
- _proto._updateShaderData = function _updateShaderData(context) {
10908
+ /**
10909
+ * @internal
10910
+ */ _proto._updateShaderData = function _updateShaderData(context) {
10781
10911
  var entity = this.entity;
10782
10912
  var worldMatrix = entity.transform.worldMatrix;
10783
10913
  this._updateTransformShaderData(context, worldMatrix);
10784
10914
  var layer = entity.layer;
10785
10915
  this._rendererLayer.set(layer & 65535, layer >>> 16 & 65535, 0, 0);
10786
10916
  };
10787
- _proto._updateTransformShaderData = function _updateTransformShaderData(context, worldMatrix) {
10917
+ /**
10918
+ * @internal
10919
+ */ _proto._updateTransformShaderData = function _updateTransformShaderData(context, worldMatrix) {
10788
10920
  var shaderData = this.shaderData;
10789
10921
  var virtualCamera = context.virtualCamera;
10790
10922
  var mvMatrix = this._mvMatrix;
@@ -10803,14 +10935,22 @@ var Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
10803
10935
  shaderData.setMatrix(Renderer._mvInvMatrixProperty, mvInvMatrix);
10804
10936
  shaderData.setMatrix(Renderer._normalMatrixProperty, normalMatrix);
10805
10937
  };
10806
- _proto._registerEntityTransformListener = function _registerEntityTransformListener() {
10938
+ /**
10939
+ * @internal
10940
+ */ _proto._registerEntityTransformListener = function _registerEntityTransformListener() {
10807
10941
  this.entity.transform._updateFlagManager.addListener(this._onTransformChanged);
10808
10942
  };
10809
- _proto._updateBounds = function _updateBounds(worldBounds) {};
10810
- _proto._render = function _render(context) {
10943
+ /**
10944
+ * @internal
10945
+ */ _proto._updateBounds = function _updateBounds(worldBounds) {};
10946
+ /**
10947
+ * @internal
10948
+ */ _proto._render = function _render(context) {
10811
10949
  throw "not implement";
10812
10950
  };
10813
- _proto._createInstanceMaterial = function _createInstanceMaterial(material, index) {
10951
+ /**
10952
+ * @internal
10953
+ */ _proto._createInstanceMaterial = function _createInstanceMaterial(material, index) {
10814
10954
  var insMaterial = material.clone();
10815
10955
  insMaterial.name = insMaterial.name + "(Instance)";
10816
10956
  material._addReferCount(-1);
@@ -10833,10 +10973,20 @@ var Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
10833
10973
  materials[index] = material;
10834
10974
  }
10835
10975
  };
10836
- _proto._onTransformChanged = function _onTransformChanged(type) {
10976
+ /**
10977
+ * @internal
10978
+ */ _proto._onTransformChanged = function _onTransformChanged(type) {
10837
10979
  this._dirtyUpdateFlag |= 0x1;
10838
10980
  };
10839
10981
  _create_class(Renderer1, [
10982
+ {
10983
+ key: "shaderData",
10984
+ get: /**
10985
+ * ShaderData related to renderer.
10986
+ */ function get() {
10987
+ return this._shaderData;
10988
+ }
10989
+ },
10840
10990
  {
10841
10991
  key: "isCulled",
10842
10992
  get: /**
@@ -10921,9 +11071,6 @@ var Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
10921
11071
  }(), function() {
10922
11072
  _Renderer._rendererLayerProperty = ShaderProperty.getByName("renderer_Layer");
10923
11073
  }(), _Renderer);
10924
- __decorate([
10925
- deepClone
10926
- ], Renderer.prototype, "shaderData", void 0);
10927
11074
  __decorate([
10928
11075
  ignoreClone
10929
11076
  ], Renderer.prototype, "_distanceForSort", void 0);
@@ -10946,11 +11093,14 @@ __decorate([
10946
11093
  ignoreClone
10947
11094
  ], Renderer.prototype, "_overrideUpdate", void 0);
10948
11095
  __decorate([
10949
- shallowClone
11096
+ ignoreClone
10950
11097
  ], Renderer.prototype, "_materials", void 0);
10951
11098
  __decorate([
10952
11099
  ignoreClone
10953
11100
  ], Renderer.prototype, "_dirtyUpdateFlag", void 0);
11101
+ __decorate([
11102
+ deepClone
11103
+ ], Renderer.prototype, "_shaderData", void 0);
10954
11104
  __decorate([
10955
11105
  ignoreClone
10956
11106
  ], Renderer.prototype, "_mvMatrix", void 0);
@@ -11140,8 +11290,10 @@ SimpleSpriteAssembler = __decorate([
11140
11290
  _this = Renderer.call(this, entity) || this;
11141
11291
  /** The mask layers the sprite mask influence to. */ _this.influenceLayers = SpriteMaskLayer.Everything;
11142
11292
  _this._sprite = null;
11143
- _this._width = undefined;
11144
- _this._height = undefined;
11293
+ _this._automaticWidth = 0;
11294
+ _this._automaticHeight = 0;
11295
+ _this._customWidth = undefined;
11296
+ _this._customHeight = undefined;
11145
11297
  _this._flipX = false;
11146
11298
  _this._flipY = false;
11147
11299
  _this._alphaCutoff = 0.5;
@@ -11156,30 +11308,33 @@ SimpleSpriteAssembler = __decorate([
11156
11308
  /**
11157
11309
  * @internal
11158
11310
  */ _proto._cloneTo = function _cloneTo(target) {
11311
+ Renderer.prototype._cloneTo.call(this, target);
11159
11312
  target.sprite = this._sprite;
11160
11313
  };
11161
- _proto._updateBounds = function _updateBounds(worldBounds) {
11162
- var _this_sprite;
11163
- if (!((_this_sprite = this.sprite) == null ? void 0 : _this_sprite.texture) || !this.width || !this.height) {
11314
+ /**
11315
+ * @internal
11316
+ */ _proto._updateBounds = function _updateBounds(worldBounds) {
11317
+ if (this.sprite) {
11318
+ SimpleSpriteAssembler.updatePositions(this);
11319
+ } else {
11164
11320
  worldBounds.min.set(0, 0, 0);
11165
11321
  worldBounds.max.set(0, 0, 0);
11166
- } else {
11167
- SimpleSpriteAssembler.updatePositions(this);
11168
11322
  }
11169
11323
  };
11170
11324
  /**
11325
+ * @internal
11171
11326
  * @inheritdoc
11172
11327
  */ _proto._render = function _render(context) {
11173
11328
  var _this_sprite;
11174
11329
  if (!((_this_sprite = this.sprite) == null ? void 0 : _this_sprite.texture) || !this.width || !this.height) {
11175
11330
  return;
11176
11331
  }
11177
- // Update position.
11332
+ // Update position
11178
11333
  if (this._dirtyUpdateFlag & RendererUpdateFlags.WorldVolume) {
11179
11334
  SimpleSpriteAssembler.updatePositions(this);
11180
11335
  this._dirtyUpdateFlag &= ~RendererUpdateFlags.WorldVolume;
11181
11336
  }
11182
- // Update uv.
11337
+ // Update uv
11183
11338
  if (this._dirtyUpdateFlag & 0x2) {
11184
11339
  SimpleSpriteAssembler.updateUVs(this);
11185
11340
  this._dirtyUpdateFlag &= ~0x2;
@@ -11193,19 +11348,40 @@ SimpleSpriteAssembler = __decorate([
11193
11348
  this._maskElement = renderElement;
11194
11349
  };
11195
11350
  /**
11351
+ * @internal
11196
11352
  * @inheritdoc
11197
11353
  */ _proto._onDestroy = function _onDestroy() {
11198
- var _this__sprite;
11199
11354
  Renderer.prototype._onDestroy.call(this);
11200
- (_this__sprite = this._sprite) == null ? void 0 : _this__sprite._updateFlagManager.removeListener(this._onSpriteChange);
11355
+ var sprite = this._sprite;
11356
+ if (sprite) {
11357
+ sprite._addReferCount(-1);
11358
+ sprite._updateFlagManager.removeListener(this._onSpriteChange);
11359
+ }
11360
+ this._entity = null;
11201
11361
  this._sprite = null;
11202
11362
  this._verticesData = null;
11203
11363
  };
11364
+ _proto._calDefaultSize = function _calDefaultSize() {
11365
+ var sprite = this._sprite;
11366
+ if (sprite) {
11367
+ this._automaticWidth = sprite.width;
11368
+ this._automaticHeight = sprite.height;
11369
+ } else {
11370
+ this._automaticWidth = this._automaticHeight = 0;
11371
+ }
11372
+ this._dirtyUpdateFlag &= ~0x4;
11373
+ };
11204
11374
  _proto._onSpriteChange = function _onSpriteChange(type) {
11205
11375
  switch(type){
11206
11376
  case SpriteModifyFlags.texture:
11207
11377
  this.shaderData.setTexture(SpriteMask._textureProperty, this.sprite.texture);
11208
11378
  break;
11379
+ case SpriteModifyFlags.size:
11380
+ this._dirtyUpdateFlag |= 0x4;
11381
+ if (this._customWidth === undefined || this._customHeight === undefined) {
11382
+ this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
11383
+ }
11384
+ break;
11209
11385
  case SpriteModifyFlags.region:
11210
11386
  case SpriteModifyFlags.atlasRegionOffset:
11211
11387
  this._dirtyUpdateFlag |= 0x3;
@@ -11213,22 +11389,31 @@ SimpleSpriteAssembler = __decorate([
11213
11389
  case SpriteModifyFlags.atlasRegion:
11214
11390
  this._dirtyUpdateFlag |= 0x2;
11215
11391
  break;
11392
+ case SpriteModifyFlags.pivot:
11393
+ this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
11394
+ break;
11216
11395
  }
11217
11396
  };
11218
11397
  _create_class(SpriteMask, [
11219
11398
  {
11220
11399
  key: "width",
11221
11400
  get: /**
11222
- * Render width.
11401
+ * Render width (in world coordinates).
11402
+ *
11403
+ * @remarks
11404
+ * If width is set, return the set value,
11405
+ * otherwise return `SpriteMask.sprite.width`.
11223
11406
  */ function get() {
11224
- if (this._width === undefined && this._sprite) {
11225
- this.width = this._sprite.width;
11407
+ if (this._customWidth !== undefined) {
11408
+ return this._customWidth;
11409
+ } else {
11410
+ this._dirtyUpdateFlag & 0x4 && this._calDefaultSize();
11411
+ return this._automaticWidth;
11226
11412
  }
11227
- return this._width;
11228
11413
  },
11229
11414
  set: function set(value) {
11230
- if (this._width !== value) {
11231
- this._width = value;
11415
+ if (this._customWidth !== value) {
11416
+ this._customWidth = value;
11232
11417
  this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
11233
11418
  }
11234
11419
  }
@@ -11236,16 +11421,22 @@ SimpleSpriteAssembler = __decorate([
11236
11421
  {
11237
11422
  key: "height",
11238
11423
  get: /**
11239
- * Render height.
11424
+ * Render height (in world coordinates).
11425
+ *
11426
+ * @remarks
11427
+ * If height is set, return the set value,
11428
+ * otherwise return `SpriteMask.sprite.height`.
11240
11429
  */ function get() {
11241
- if (this._height === undefined && this._sprite) {
11242
- this.height = this._sprite.height;
11430
+ if (this._customHeight !== undefined) {
11431
+ return this._customHeight;
11432
+ } else {
11433
+ this._dirtyUpdateFlag & 0x4 && this._calDefaultSize();
11434
+ return this._automaticHeight;
11243
11435
  }
11244
- return this._height;
11245
11436
  },
11246
11437
  set: function set(value) {
11247
- if (this._height !== value) {
11248
- this._height = value;
11438
+ if (this._customHeight !== value) {
11439
+ this._customHeight = value;
11249
11440
  this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
11250
11441
  }
11251
11442
  }
@@ -11288,10 +11479,14 @@ SimpleSpriteAssembler = __decorate([
11288
11479
  set: function set(value) {
11289
11480
  var lastSprite = this._sprite;
11290
11481
  if (lastSprite !== value) {
11291
- lastSprite && lastSprite._updateFlagManager.removeListener(this._onSpriteChange);
11482
+ if (lastSprite) {
11483
+ lastSprite._addReferCount(-1);
11484
+ lastSprite._updateFlagManager.removeListener(this._onSpriteChange);
11485
+ }
11486
+ this._dirtyUpdateFlag |= 0x7;
11292
11487
  if (value) {
11488
+ value._addReferCount(1);
11293
11489
  value._updateFlagManager.addListener(this._onSpriteChange);
11294
- this._dirtyUpdateFlag |= 0x3;
11295
11490
  this.shaderData.setTexture(SpriteMask._textureProperty, value.texture);
11296
11491
  } else {
11297
11492
  this.shaderData.setTexture(SpriteMask._textureProperty, null);
@@ -11331,10 +11526,16 @@ __decorate([
11331
11526
  ], SpriteMask.prototype, "_sprite", void 0);
11332
11527
  __decorate([
11333
11528
  ignoreClone
11334
- ], SpriteMask.prototype, "_width", void 0);
11529
+ ], SpriteMask.prototype, "_automaticWidth", void 0);
11335
11530
  __decorate([
11336
11531
  ignoreClone
11337
- ], SpriteMask.prototype, "_height", void 0);
11532
+ ], SpriteMask.prototype, "_automaticHeight", void 0);
11533
+ __decorate([
11534
+ assignmentClone
11535
+ ], SpriteMask.prototype, "_customWidth", void 0);
11536
+ __decorate([
11537
+ assignmentClone
11538
+ ], SpriteMask.prototype, "_customHeight", void 0);
11338
11539
  __decorate([
11339
11540
  assignmentClone
11340
11541
  ], SpriteMask.prototype, "_flipX", void 0);
@@ -11352,7 +11553,9 @@ var /**
11352
11553
  */ SpriteMaskUpdateFlags;
11353
11554
  (function(SpriteMaskUpdateFlags) {
11354
11555
  SpriteMaskUpdateFlags[SpriteMaskUpdateFlags[/** UV. */ "UV"] = 0x2] = "UV";
11355
- SpriteMaskUpdateFlags[SpriteMaskUpdateFlags[/** All. */ "All"] = 0x3] = "All";
11556
+ SpriteMaskUpdateFlags[SpriteMaskUpdateFlags[/** WorldVolume and UV . */ "RenderData"] = 0x3] = "RenderData";
11557
+ SpriteMaskUpdateFlags[SpriteMaskUpdateFlags[/** Automatic Size. */ "AutomaticSize"] = 0x4] = "AutomaticSize";
11558
+ SpriteMaskUpdateFlags[SpriteMaskUpdateFlags[/** All. */ "All"] = 0x7] = "All";
11356
11559
  })(SpriteMaskUpdateFlags || (SpriteMaskUpdateFlags = {}));
11357
11560
 
11358
11561
  /**
@@ -11617,7 +11820,9 @@ var BufferUtil = /*#__PURE__*/ function() {
11617
11820
  var platformBuffer = this._engine._hardwareRenderer.createPlatformBuffer(this._type, this._byteLength, this._bufferUsage);
11618
11821
  this._platformBuffer = platformBuffer;
11619
11822
  };
11620
- _proto._onDestroy = function _onDestroy() {
11823
+ /**
11824
+ * @internal
11825
+ */ _proto._onDestroy = function _onDestroy() {
11621
11826
  GraphicsResource.prototype._onDestroy.call(this);
11622
11827
  this._platformBuffer.destroy();
11623
11828
  };
@@ -11707,14 +11912,19 @@ var BufferUtil = /*#__PURE__*/ function() {
11707
11912
 
11708
11913
  /**
11709
11914
  * Sub-mesh, mainly contains drawing information.
11710
- */ var SubMesh = function SubMesh(start, count, topology) {
11711
- if (start === void 0) start = 0;
11712
- if (count === void 0) count = 0;
11713
- if (topology === void 0) topology = MeshTopology.Triangles;
11714
- this.start = start;
11715
- this.count = count;
11716
- this.topology = topology;
11717
- };
11915
+ */ var SubMesh = /*#__PURE__*/ function() {
11916
+ function SubMesh(start, count, topology) {
11917
+ if (start === void 0) start = 0;
11918
+ if (count === void 0) count = 0;
11919
+ if (topology === void 0) topology = MeshTopology.Triangles;
11920
+ this.start = start;
11921
+ this.count = count;
11922
+ this.topology = topology;
11923
+ }
11924
+ var _proto = SubMesh.prototype;
11925
+ _proto.dispose = function dispose() {};
11926
+ return SubMesh;
11927
+ }();
11718
11928
 
11719
11929
  /**
11720
11930
  * Mesh.
@@ -11796,10 +12006,11 @@ var BufferUtil = /*#__PURE__*/ function() {
11796
12006
  /**
11797
12007
  * @internal
11798
12008
  */ _proto._setVertexBufferBinding = function _setVertexBufferBinding(index, binding) {
11799
- if (this._getReferCount() > 0) {
11800
- var lastBinding = this._vertexBufferBindings[index];
11801
- lastBinding && lastBinding._buffer._addReferCount(-1);
11802
- binding._buffer._addReferCount(1);
12009
+ var referCount = this._getReferCount();
12010
+ if (referCount > 0) {
12011
+ var _this__vertexBufferBindings_index;
12012
+ (_this__vertexBufferBindings_index = this._vertexBufferBindings[index]) == null ? void 0 : _this__vertexBufferBindings_index._buffer._addReferCount(-referCount);
12013
+ binding == null ? void 0 : binding._buffer._addReferCount(referCount);
11803
12014
  }
11804
12015
  this._vertexBufferBindings[index] = binding;
11805
12016
  this._bufferStructChanged = true;
@@ -11811,11 +12022,13 @@ var BufferUtil = /*#__PURE__*/ function() {
11811
12022
  this._bufferStructChanged = false;
11812
12023
  };
11813
12024
  _proto._addReferCount = function _addReferCount(value) {
12025
+ var _this__indexBufferBinding;
11814
12026
  GraphicsResource.prototype._addReferCount.call(this, value);
11815
12027
  var vertexBufferBindings = this._vertexBufferBindings;
11816
12028
  for(var i = 0, n = vertexBufferBindings.length; i < n; i++){
11817
12029
  vertexBufferBindings[i]._buffer._addReferCount(value);
11818
12030
  }
12031
+ (_this__indexBufferBinding = this._indexBufferBinding) == null ? void 0 : _this__indexBufferBinding._buffer._addReferCount(value);
11819
12032
  };
11820
12033
  _proto._rebuild = function _rebuild() {
11821
12034
  this._engine._hardwareRenderer.createPlatformPrimitive(this);
@@ -11830,14 +12043,23 @@ var BufferUtil = /*#__PURE__*/ function() {
11830
12043
  this._vertexElementMap = null;
11831
12044
  this._platformPrimitive.destroy();
11832
12045
  };
11833
- _proto._setVertexElements = function _setVertexElements(elements) {
12046
+ /**
12047
+ * @internal
12048
+ */ _proto._setVertexElements = function _setVertexElements(elements) {
11834
12049
  this._clearVertexElements();
11835
12050
  for(var i = 0, n = elements.length; i < n; i++){
11836
12051
  this._addVertexElement(elements[i]);
11837
12052
  }
11838
12053
  };
11839
- _proto._setIndexBufferBinding = function _setIndexBufferBinding(binding) {
12054
+ /**
12055
+ * @internal
12056
+ */ _proto._setIndexBufferBinding = function _setIndexBufferBinding(binding) {
11840
12057
  var lastBinding = this._indexBufferBinding;
12058
+ var referCount = this._getReferCount();
12059
+ if (referCount > 0) {
12060
+ lastBinding == null ? void 0 : lastBinding.buffer._addReferCount(-referCount);
12061
+ binding == null ? void 0 : binding.buffer._addReferCount(referCount);
12062
+ }
11841
12063
  if (binding) {
11842
12064
  this._indexBufferBinding = binding;
11843
12065
  this._glIndexType = BufferUtil._getGLIndexType(binding.format);
@@ -12153,6 +12375,7 @@ var MeshModifyFlags;
12153
12375
  var subDataDirtyFlags = this._subDataDirtyFlags;
12154
12376
  var blendShapeFloatStride = this._vertexElementCount * 3;
12155
12377
  var blendShapeByteStride = blendShapeFloatStride * 4;
12378
+ var bufferOffset = this._bufferBindingOffset;
12156
12379
  // @todo: should fix bug when dataChangedFlag is true
12157
12380
  for(var i = 0, n = blendShapes.length; i < n; i++){
12158
12381
  var dataChangedFlag = subDataDirtyFlags[i];
@@ -12170,7 +12393,7 @@ var MeshModifyFlags;
12170
12393
  var offset = indexInBuffer * blendShapeFloatStride;
12171
12394
  var storeInfo = storeInfos[i];
12172
12395
  storeInfo || (storeInfos[i] = storeInfo = new Vector2());
12173
- storeInfo.set(bufferIndex + 1, indexInBuffer * blendShapeByteStride); // BlendShape buffer is start from 1
12396
+ storeInfo.set(bufferOffset + bufferIndex, indexInBuffer * blendShapeByteStride); // BufferOffset is mesh vertexBuffer offset
12174
12397
  var deltaPositions = endFrame.deltaPositions;
12175
12398
  for(var j = 0; j < vertexCount; j++){
12176
12399
  var start = offset + bufferFloatStride * j;
@@ -12974,7 +13197,9 @@ var MeshModifyFlags;
12974
13197
  }
12975
13198
  this.setTangents(tangents);
12976
13199
  };
12977
- _proto._onDestroy = function _onDestroy() {
13200
+ /**
13201
+ * @internal
13202
+ */ _proto._onDestroy = function _onDestroy() {
12978
13203
  Mesh.prototype._onDestroy.call(this);
12979
13204
  this._readable && this._releaseCache();
12980
13205
  };
@@ -13445,24 +13670,31 @@ var VertexChangedFlags;
13445
13670
  function MeshRenderer(entity) {
13446
13671
  var _this;
13447
13672
  _this = Renderer.call(this, entity) || this;
13673
+ _this._enableVertexColor = false;
13448
13674
  _this._onMeshChanged = _this._onMeshChanged.bind(_assert_this_initialized(_this));
13449
13675
  return _this;
13450
13676
  }
13451
13677
  var _proto = MeshRenderer.prototype;
13452
- _proto._onDestroy = function _onDestroy() {
13678
+ /**
13679
+ * @internal
13680
+ */ _proto._onDestroy = function _onDestroy() {
13453
13681
  Renderer.prototype._onDestroy.call(this);
13454
13682
  var mesh = this._mesh;
13455
- if (mesh && !mesh.destroyed) {
13456
- mesh._addReferCount(-1);
13683
+ if (mesh) {
13684
+ mesh.destroyed || mesh._addReferCount(-1);
13685
+ mesh._updateFlagManager.removeListener(this._onMeshChanged);
13457
13686
  this._mesh = null;
13458
13687
  }
13459
13688
  };
13460
13689
  /**
13461
13690
  * @internal
13462
13691
  */ _proto._cloneTo = function _cloneTo(target) {
13692
+ Renderer.prototype._cloneTo.call(this, target);
13463
13693
  target.mesh = this._mesh;
13464
13694
  };
13465
- _proto._updateBounds = function _updateBounds(worldBounds) {
13695
+ /**
13696
+ * @internal
13697
+ */ _proto._updateBounds = function _updateBounds(worldBounds) {
13466
13698
  var mesh = this._mesh;
13467
13699
  if (mesh) {
13468
13700
  var localBounds = mesh.bounds;
@@ -13473,7 +13705,9 @@ var VertexChangedFlags;
13473
13705
  worldBounds.max.set(0, 0, 0);
13474
13706
  }
13475
13707
  };
13476
- _proto._render = function _render(context) {
13708
+ /**
13709
+ * @internal
13710
+ */ _proto._render = function _render(context) {
13477
13711
  var mesh = this._mesh;
13478
13712
  if (mesh) {
13479
13713
  if (this._dirtyUpdateFlag & 0x2) {
@@ -13483,7 +13717,7 @@ var VertexChangedFlags;
13483
13717
  shaderData.disableMacro(MeshRenderer._uv1Macro);
13484
13718
  shaderData.disableMacro(MeshRenderer._normalMacro);
13485
13719
  shaderData.disableMacro(MeshRenderer._tangentMacro);
13486
- shaderData.disableMacro(MeshRenderer._vertexColorMacro);
13720
+ shaderData.disableMacro(MeshRenderer._enableVertexColorMacro);
13487
13721
  for(var i = 0, n = vertexElements.length; i < n; i++){
13488
13722
  switch(vertexElements[i].semantic){
13489
13723
  case "TEXCOORD_0":
@@ -13499,7 +13733,7 @@ var VertexChangedFlags;
13499
13733
  shaderData.enableMacro(MeshRenderer._tangentMacro);
13500
13734
  break;
13501
13735
  case "COLOR_0":
13502
- shaderData.enableMacro(MeshRenderer._vertexColorMacro);
13736
+ this._enableVertexColor && shaderData.enableMacro(MeshRenderer._enableVertexColorMacro);
13503
13737
  break;
13504
13738
  }
13505
13739
  }
@@ -13550,6 +13784,20 @@ var VertexChangedFlags;
13550
13784
  this._setMesh(value);
13551
13785
  }
13552
13786
  }
13787
+ },
13788
+ {
13789
+ key: "enableVertexColor",
13790
+ get: /**
13791
+ * Whether enable vertex color.
13792
+ */ function get() {
13793
+ return this._enableVertexColor;
13794
+ },
13795
+ set: function set(value) {
13796
+ if (value !== this._enableVertexColor) {
13797
+ this._dirtyUpdateFlag |= 0x2;
13798
+ this._enableVertexColor = value;
13799
+ }
13800
+ }
13553
13801
  }
13554
13802
  ]);
13555
13803
  return MeshRenderer;
@@ -13567,7 +13815,7 @@ var VertexChangedFlags;
13567
13815
  MeshRenderer._tangentMacro = ShaderMacro.getByName("RENDERER_HAS_TANGENT");
13568
13816
  })();
13569
13817
  (function() {
13570
- MeshRenderer._vertexColorMacro = ShaderMacro.getByName("RENDERER_HAS_VERTEXCOLOR");
13818
+ MeshRenderer._enableVertexColorMacro = ShaderMacro.getByName("RENDERER_ENABLE_VERTEXCOLOR");
13571
13819
  })();
13572
13820
  __decorate([
13573
13821
  ignoreClone
@@ -13599,7 +13847,7 @@ var /**
13599
13847
  // Limit size to 256 to avoid some problem:
13600
13848
  // 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!
13601
13849
  // 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.
13602
- maxVertexUniformVectors = Math.min(maxVertexUniformVectors, 256);
13850
+ maxVertexUniformVectors = Math.min(maxVertexUniformVectors, rhi._options._maxAllowSkinUniformVectorCount);
13603
13851
  _this._maxVertexUniformVectors = maxVertexUniformVectors;
13604
13852
  _this._onLocalBoundsChanged = _this._onLocalBoundsChanged.bind(_assert_this_initialized(_this));
13605
13853
  var localBounds = _this._localBounds;
@@ -13634,7 +13882,9 @@ var /**
13634
13882
  }
13635
13883
  }
13636
13884
  };
13637
- _proto._updateShaderData = function _updateShaderData(context) {
13885
+ /**
13886
+ * @internal
13887
+ */ _proto._updateShaderData = function _updateShaderData(context) {
13638
13888
  var entity = this.entity;
13639
13889
  var worldMatrix = this._rootBone ? this._rootBone.transform.worldMatrix : entity.transform.worldMatrix;
13640
13890
  this._updateTransformShaderData(context, worldMatrix);
@@ -13660,6 +13910,7 @@ var /**
13660
13910
  (_this__jointTexture = this._jointTexture) == null ? void 0 : _this__jointTexture.destroy();
13661
13911
  this._jointTexture = new Texture2D(engine, 4, jointCount, TextureFormat.R32G32B32A32, false);
13662
13912
  this._jointTexture.filterMode = TextureFilterMode.Point;
13913
+ this._jointTexture.isGCIgnored = true;
13663
13914
  }
13664
13915
  shaderData.disableMacro("RENDERER_JOINTS_NUM");
13665
13916
  shaderData.enableMacro("RENDERER_USE_JOINT_TEXTURE");
@@ -13685,14 +13936,37 @@ var /**
13685
13936
  };
13686
13937
  /**
13687
13938
  * @internal
13939
+ */ _proto._onDestroy = function _onDestroy() {
13940
+ var _this__rootBone, _this__jointTexture;
13941
+ MeshRenderer.prototype._onDestroy.call(this);
13942
+ (_this__rootBone = this._rootBone) == null ? void 0 : _this__rootBone.transform._updateFlagManager.removeListener(this._onTransformChanged);
13943
+ this._rootBone = null;
13944
+ this._jointDataCreateCache = null;
13945
+ this._skin = null;
13946
+ this._blendShapeWeights = null;
13947
+ this._localBounds = null;
13948
+ this._jointMatrices = null;
13949
+ (_this__jointTexture = this._jointTexture) == null ? void 0 : _this__jointTexture.destroy();
13950
+ this._jointTexture = null;
13951
+ if (this._jointEntities) {
13952
+ this._jointEntities.length = 0;
13953
+ this._jointEntities = null;
13954
+ }
13955
+ };
13956
+ /**
13957
+ * @internal
13688
13958
  */ _proto._cloneTo = function _cloneTo(target) {
13689
13959
  MeshRenderer.prototype._cloneTo.call(this, target);
13690
13960
  this._blendShapeWeights && (target._blendShapeWeights = this._blendShapeWeights.slice());
13691
13961
  };
13692
- _proto._registerEntityTransformListener = function _registerEntityTransformListener() {
13962
+ /**
13963
+ * @internal
13964
+ */ _proto._registerEntityTransformListener = function _registerEntityTransformListener() {
13693
13965
  // Cancel register listener to entity transform.
13694
13966
  };
13695
- _proto._updateBounds = function _updateBounds(worldBounds) {
13967
+ /**
13968
+ * @internal
13969
+ */ _proto._updateBounds = function _updateBounds(worldBounds) {
13696
13970
  if (this._rootBone) {
13697
13971
  var localBounds = this._localBounds;
13698
13972
  var worldMatrix = this._rootBone.transform.worldMatrix;
@@ -15145,14 +15419,17 @@ var Basic2DBatcher = /*#__PURE__*/ function() {
15145
15419
  _proto._createMesh = function _createMesh(engine, index) {
15146
15420
  var MAX_VERTEX_COUNT = Basic2DBatcher.MAX_VERTEX_COUNT;
15147
15421
  var mesh = new BufferMesh(engine, "BufferMesh" + index);
15422
+ mesh.isGCIgnored = true;
15148
15423
  var vertexElements = [];
15149
15424
  var vertexStride = this.createVertexElements(vertexElements);
15150
15425
  // vertices
15151
- this._vertexBuffers[index] = new Buffer(engine, BufferBindFlag.VertexBuffer, MAX_VERTEX_COUNT * 4 * vertexStride, BufferUsage.Dynamic);
15426
+ var vertexBuffer = this._vertexBuffers[index] = new Buffer(engine, BufferBindFlag.VertexBuffer, MAX_VERTEX_COUNT * 4 * vertexStride, BufferUsage.Dynamic);
15427
+ vertexBuffer.isGCIgnored = true;
15152
15428
  // indices
15153
- this._indiceBuffers[index] = new Buffer(engine, BufferBindFlag.IndexBuffer, MAX_VERTEX_COUNT * 3, BufferUsage.Dynamic);
15154
- mesh.setVertexBufferBinding(this._vertexBuffers[index], vertexStride);
15155
- mesh.setIndexBufferBinding(this._indiceBuffers[index], IndexFormat.UInt16);
15429
+ var indiceBuffer = this._indiceBuffers[index] = new Buffer(engine, BufferBindFlag.IndexBuffer, MAX_VERTEX_COUNT * 2 * 3, BufferUsage.Dynamic);
15430
+ indiceBuffer.isGCIgnored = true;
15431
+ mesh.setVertexBufferBinding(vertexBuffer, vertexStride);
15432
+ mesh.setIndexBufferBinding(indiceBuffer, IndexFormat.UInt16);
15156
15433
  mesh.setVertexElements(vertexElements);
15157
15434
  return mesh;
15158
15435
  };
@@ -15376,6 +15653,9 @@ var SpriteMaskRenderData = /*#__PURE__*/ function(RenderData) {
15376
15653
  this.material = material;
15377
15654
  this.verticesData = verticesData;
15378
15655
  };
15656
+ _proto.dispose = function dispose() {
15657
+ this.component = this.material = this.verticesData = null;
15658
+ };
15379
15659
  return SpriteMaskRenderData;
15380
15660
  }(RenderData);
15381
15661
 
@@ -15396,6 +15676,9 @@ var SpriteRenderData = /*#__PURE__*/ function(RenderData) {
15396
15676
  this.texture = texture;
15397
15677
  this.dataIndex = dataIndex;
15398
15678
  };
15679
+ _proto.dispose = function dispose() {
15680
+ this.component = this.material = this.verticesData = this.texture = null;
15681
+ };
15399
15682
  return SpriteRenderData;
15400
15683
  }(RenderData);
15401
15684
 
@@ -15408,6 +15691,11 @@ var TextRenderData = /*#__PURE__*/ function(RenderData) {
15408
15691
  _this.multiRenderData = true;
15409
15692
  return _this;
15410
15693
  }
15694
+ var _proto = TextRenderData.prototype;
15695
+ _proto.dispose = function dispose() {
15696
+ this.component = this.material = null;
15697
+ this.charsData.length = 0;
15698
+ };
15411
15699
  return TextRenderData;
15412
15700
  }(RenderData);
15413
15701
 
@@ -15436,6 +15724,12 @@ var TextRenderData = /*#__PURE__*/ function(RenderData) {
15436
15724
  var _proto = Sky.prototype;
15437
15725
  /**
15438
15726
  * @internal
15727
+ */ _proto.destroy = function destroy() {
15728
+ this.mesh = null;
15729
+ this.material = null;
15730
+ };
15731
+ /**
15732
+ * @internal
15439
15733
  */ _proto._render = function _render(context) {
15440
15734
  var _this = this, material = _this.material, mesh = _this.mesh;
15441
15735
  if (!material) {
@@ -15476,6 +15770,40 @@ var TextRenderData = /*#__PURE__*/ function(RenderData) {
15476
15770
  rhi.drawPrimitive(mesh, mesh.subMesh, program);
15477
15771
  cameraShaderData.setMatrix(RenderContext.vpMatrixProperty, originViewProjMatrix);
15478
15772
  };
15773
+ _create_class(Sky, [
15774
+ {
15775
+ key: "material",
15776
+ get: /**
15777
+ * Material of the sky.
15778
+ */ function get() {
15779
+ return this._material;
15780
+ },
15781
+ set: function set(value) {
15782
+ if (this._material !== value) {
15783
+ var _this__material;
15784
+ value == null ? void 0 : value._addReferCount(1);
15785
+ (_this__material = this._material) == null ? void 0 : _this__material._addReferCount(-1);
15786
+ this._material = value;
15787
+ }
15788
+ }
15789
+ },
15790
+ {
15791
+ key: "mesh",
15792
+ get: /**
15793
+ * Mesh of the sky.
15794
+ */ function get() {
15795
+ return this._mesh;
15796
+ },
15797
+ set: function set(value) {
15798
+ if (this._mesh !== value) {
15799
+ var _this__mesh;
15800
+ value == null ? void 0 : value._addReferCount(1);
15801
+ (_this__mesh = this._mesh) == null ? void 0 : _this__mesh._addReferCount(-1);
15802
+ this._mesh = value;
15803
+ }
15804
+ }
15805
+ }
15806
+ ]);
15479
15807
  return Sky;
15480
15808
  }();
15481
15809
  (function() {
@@ -15511,9 +15839,19 @@ var TextRenderData = /*#__PURE__*/ function(RenderData) {
15511
15839
  var _proto = Background.prototype;
15512
15840
  /**
15513
15841
  * @internal
15842
+ */ _proto.destroy = function destroy() {
15843
+ this._mesh._addReferCount(-1);
15844
+ this._mesh = null;
15845
+ this.texture = null;
15846
+ this.solidColor = null;
15847
+ this.sky.destroy();
15848
+ };
15849
+ /**
15850
+ * @internal
15514
15851
  * Standalone for CanvasRenderer plugin.
15515
15852
  */ _proto._initMesh = function _initMesh(engine) {
15516
15853
  this._mesh = this._createPlane(engine);
15854
+ this._mesh._addReferCount(1);
15517
15855
  };
15518
15856
  /**
15519
15857
  * @internal
@@ -15585,6 +15923,9 @@ var TextRenderData = /*#__PURE__*/ function(RenderData) {
15585
15923
  },
15586
15924
  set: function set(value) {
15587
15925
  if (this._texture !== value) {
15926
+ var _this__texture;
15927
+ value == null ? void 0 : value._addReferCount(1);
15928
+ (_this__texture = this._texture) == null ? void 0 : _this__texture._addReferCount(-1);
15588
15929
  this._texture = value;
15589
15930
  this._engine._backgroundTextureMaterial.shaderData.setTexture("material_BaseTexture", value);
15590
15931
  }
@@ -15888,8 +16229,6 @@ var TextRenderData = /*#__PURE__*/ function(RenderData) {
15888
16229
  function Scene(engine, name) {
15889
16230
  var _this;
15890
16231
  _this = EngineObject.call(this, engine) || this;
15891
- /** The background of the scene. */ _this.background = new Background(_this._engine);
15892
- /** Scene-related shader data. */ _this.shaderData = new ShaderData(ShaderDataGroup.Scene);
15893
16232
  /** If cast shadows. */ _this.castShadows = true;
15894
16233
  /** The resolution of the shadow maps. */ _this.shadowResolution = ShadowResolution.Medium;
15895
16234
  /** The splits of two cascade distribution. */ _this.shadowTwoCascadeSplits = 1.0 / 3.0;
@@ -15899,6 +16238,8 @@ var TextRenderData = /*#__PURE__*/ function(RenderData) {
15899
16238
  /** @internal */ _this._isActiveInEngine = false;
15900
16239
  /** @internal */ _this._globalShaderMacro = new ShaderMacroCollection();
15901
16240
  /** @internal */ _this._rootEntities = [];
16241
+ _this._background = new Background(_this._engine);
16242
+ _this._shaderData = new ShaderData(ShaderDataGroup.Scene);
15902
16243
  _this._shadowCascades = ShadowCascadesMode.NoCascades;
15903
16244
  _this._fogMode = FogMode.None;
15904
16245
  _this._fogColor = new Color$1(0.5, 0.5, 0.5, 1.0);
@@ -16062,9 +16403,11 @@ var TextRenderData = /*#__PURE__*/ function(RenderData) {
16062
16403
  var sunLightIndex = lightManager._getSunLightIndex();
16063
16404
  if (sunLightIndex !== -1) {
16064
16405
  var sunlight = lightManager._directLights.get(sunLightIndex);
16065
- shaderData.setColor(Scene._sunlightColorProperty, sunlight.color);
16406
+ shaderData.setColor(Scene._sunlightColorProperty, sunlight._getLightIntensityColor());
16066
16407
  shaderData.setVector3(Scene._sunlightDirectionProperty, sunlight.direction);
16067
16408
  this._sunLight = sunlight;
16409
+ } else {
16410
+ this._sunLight = null;
16068
16411
  }
16069
16412
  if (this.castShadows && this._sunLight && this._sunLight.shadowType !== ShadowType.None) {
16070
16413
  shaderData.enableMacro("SCENE_SHADOW_TYPE", this._sunLight.shadowType.toString());
@@ -16093,6 +16436,7 @@ var TextRenderData = /*#__PURE__*/ function(RenderData) {
16093
16436
  this._rootEntities[0].destroy();
16094
16437
  }
16095
16438
  this._activeCameras.length = 0;
16439
+ this.background.destroy();
16096
16440
  this.shaderData._addReferCount(-1);
16097
16441
  };
16098
16442
  _proto._addToRootEntityList = function _addToRootEntityList(index, rootEntity) {
@@ -16123,6 +16467,22 @@ var TextRenderData = /*#__PURE__*/ function(RenderData) {
16123
16467
  this._fogParams.w = density / Math.sqrt(Math.LN2);
16124
16468
  };
16125
16469
  _create_class(Scene, [
16470
+ {
16471
+ key: "shaderData",
16472
+ get: /**
16473
+ * Scene-related shader data.
16474
+ */ function get() {
16475
+ return this._shaderData;
16476
+ }
16477
+ },
16478
+ {
16479
+ key: "background",
16480
+ get: /**
16481
+ * The background of the scene.
16482
+ */ function get() {
16483
+ return this._background;
16484
+ }
16485
+ },
16126
16486
  {
16127
16487
  key: "shadowCascades",
16128
16488
  get: /**
@@ -16550,7 +16910,7 @@ ShaderPool.init();
16550
16910
  _this._spriteDefaultMaterial = _this._createSpriteMaterial();
16551
16911
  _this._spriteMaskDefaultMaterial = _this._createSpriteMaskMaterial();
16552
16912
  _this._textDefaultFont = Font.createFromOS(_assert_this_initialized(_this), "Arial");
16553
- _this._textDefaultFont.isGCIgnored = false;
16913
+ _this._textDefaultFont.isGCIgnored = true;
16554
16914
  _this.inputManager = new InputManager(_assert_this_initialized(_this));
16555
16915
  _this._initMagentaTextures(hardwareRenderer);
16556
16916
  if (!hardwareRenderer.canIUse(GLCapabilityType.depthTexture)) {
@@ -16561,6 +16921,7 @@ ShaderPool.init();
16561
16921
  _this._depthTexture2D = depthTexture2D;
16562
16922
  }
16563
16923
  var magentaMaterial = new Material(_assert_this_initialized(_this), Shader.find("unlit"));
16924
+ magentaMaterial.isGCIgnored = true;
16564
16925
  magentaMaterial.shaderData.setColor("material_BaseColor", new Color(1.0, 0.0, 1.01, 1.0));
16565
16926
  _this._magentaMaterial = magentaMaterial;
16566
16927
  var backgroundTextureMaterial = new Material(_assert_this_initialized(_this), Shader.find("background-texture"));
@@ -16787,7 +17148,9 @@ ShaderPool.init();
16787
17148
  this._magentaTexture2DArray = magentaTexture2DArray;
16788
17149
  }
16789
17150
  };
16790
- _proto._initialize = function _initialize(configuration) {
17151
+ /**
17152
+ * @internal
17153
+ */ _proto._initialize = function _initialize(configuration) {
16791
17154
  var _this = this;
16792
17155
  var physics = configuration.physics;
16793
17156
  if (physics) {
@@ -17109,7 +17472,9 @@ ShaderPool.init();
17109
17472
  this._entity._removeScript(this);
17110
17473
  this._waitHandlingInValid = false;
17111
17474
  };
17112
- _proto._onDestroy = function _onDestroy() {
17475
+ /**
17476
+ * @internal
17477
+ */ _proto._onDestroy = function _onDestroy() {
17113
17478
  Component.prototype._onDestroy.call(this);
17114
17479
  this._engine._componentsManager.addPendingDestroyScript(this);
17115
17480
  };
@@ -18059,7 +18424,7 @@ var /**
18059
18424
  // prepare render target
18060
18425
  var renderTarget = this._getAvailableRenderTarget();
18061
18426
  // @todo: shouldn't set viewport and scissor in activeRenderTarget
18062
- rhi.activeRenderTarget(renderTarget, null, 0);
18427
+ rhi.activeRenderTarget(renderTarget, CascadedShadowCasterPass._viewport, 0);
18063
18428
  if (this._supportDepthTexture) {
18064
18429
  rhi.clearRenderTarget(engine, CameraClearFlags.Depth, null);
18065
18430
  } else {
@@ -18181,11 +18546,13 @@ var /**
18181
18546
  if (engine._hardwareRenderer._isWebGL2) {
18182
18547
  depthTexture.depthCompareFunction = TextureDepthCompareFunction.Less;
18183
18548
  }
18549
+ renderTarget == null ? void 0 : renderTarget._addReferCount(-1);
18184
18550
  if (this._supportDepthTexture) {
18185
18551
  renderTarget = this._renderTargets = new RenderTarget(engine, width, height, null, depthTexture);
18186
18552
  } else {
18187
18553
  renderTarget = this._renderTargets = new RenderTarget(engine, width, height, depthTexture);
18188
18554
  }
18555
+ renderTarget._addReferCount(1);
18189
18556
  }
18190
18557
  return renderTarget;
18191
18558
  };
@@ -18208,7 +18575,12 @@ var /**
18208
18575
  var height = shadowCascades == ShadowCascadesMode.TwoCascades ? shadowTileResolution : shadowTileResolution * 2;
18209
18576
  this._shadowMapSize.set(1.0 / width, 1.0 / height, width, height);
18210
18577
  }
18211
- this._renderTargets = null;
18578
+ var renderTargets = this._renderTargets;
18579
+ if (renderTargets) {
18580
+ renderTargets._addReferCount(-1);
18581
+ renderTargets.destroy();
18582
+ this._renderTargets = null;
18583
+ }
18212
18584
  var viewportOffset = this._viewportOffsets;
18213
18585
  var shadowTileResolution1 = this._shadowTileResolution;
18214
18586
  switch(shadowCascades){
@@ -18264,6 +18636,9 @@ var /**
18264
18636
  (function() {
18265
18637
  CascadedShadowCasterPass._cascadesSplitDistance = new Array(CascadedShadowCasterPass._maxCascades + 1);
18266
18638
  })();
18639
+ (function() {
18640
+ CascadedShadowCasterPass._viewport = new Vector4(0, 0, 1, 1);
18641
+ })();
18267
18642
  (function() {
18268
18643
  CascadedShadowCasterPass._clearColor = new Color$1(1, 1, 1, 1);
18269
18644
  })();
@@ -18576,7 +18951,6 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component) {
18576
18951
  function Camera1(entity) {
18577
18952
  var _this;
18578
18953
  _this = Component.call(this, entity) || this;
18579
- /** Shader data. */ _this.shaderData = new ShaderData(ShaderDataGroup.Camera);
18580
18954
  /** Rendering priority - A Camera with higher priority will be rendered on top of a camera with lower priority. */ _this.priority = 0;
18581
18955
  /** Whether to enable frustum culling, it is enabled by default. */ _this.enableFrustumCulling = true;
18582
18956
  /**
@@ -18592,6 +18966,7 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component) {
18592
18966
  /** @internal */ _this._virtualCamera = new VirtualCamera();
18593
18967
  /** @internal */ _this._replacementShader = null;
18594
18968
  /** @internal */ _this._replacementSubShaderTag = null;
18969
+ _this._shaderData = new ShaderData(ShaderDataGroup.Camera);
18595
18970
  _this._isProjMatSetting = false;
18596
18971
  _this._nearClipPlane = 0.1;
18597
18972
  _this._farClipPlane = 100;
@@ -18792,6 +19167,7 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component) {
18792
19167
  this.entity.scene._detachRenderCamera(this);
18793
19168
  };
18794
19169
  /**
19170
+ * @internal
18795
19171
  * @inheritdoc
18796
19172
  */ _proto._onDestroy = function _onDestroy() {
18797
19173
  var _this__renderPipeline;
@@ -18800,6 +19176,20 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component) {
18800
19176
  this._isInvViewProjDirty.destroy();
18801
19177
  this._isViewMatrixDirty.destroy();
18802
19178
  this.shaderData._addReferCount(-1);
19179
+ this._entity = null;
19180
+ this._globalShaderMacro = null;
19181
+ this._frustum = null;
19182
+ this._renderPipeline = null;
19183
+ this._virtualCamera = null;
19184
+ this._shaderData = null;
19185
+ this._frustumViewChangeFlag = null;
19186
+ this._transform = null;
19187
+ this._isViewMatrixDirty = null;
19188
+ this._isInvViewProjDirty = null;
19189
+ this._viewport = null;
19190
+ this._inverseProjectionMatrix = null;
19191
+ this._lastAspectSize = null;
19192
+ this._invViewProjMat = null;
18803
19193
  };
18804
19194
  _proto._projMatChange = function _projMatChange() {
18805
19195
  this._isFrustumProjectDirty = true;
@@ -18839,6 +19229,14 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component) {
18839
19229
  return this._inverseProjectionMatrix;
18840
19230
  };
18841
19231
  _create_class(Camera1, [
19232
+ {
19233
+ key: "shaderData",
19234
+ get: /**
19235
+ * Shader data.
19236
+ */ function get() {
19237
+ return this._shaderData;
19238
+ }
19239
+ },
18842
19240
  {
18843
19241
  key: "nearClipPlane",
18844
19242
  get: /**
@@ -18997,7 +19395,12 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component) {
18997
19395
  return this._renderTarget;
18998
19396
  },
18999
19397
  set: function set(value) {
19000
- this._renderTarget = value;
19398
+ if (this._renderTarget !== value) {
19399
+ var _this__renderTarget;
19400
+ value == null ? void 0 : value._addReferCount(1);
19401
+ (_this__renderTarget = this._renderTarget) == null ? void 0 : _this__renderTarget._addReferCount(-1);
19402
+ this._renderTarget = value;
19403
+ }
19001
19404
  }
19002
19405
  }
19003
19406
  ]);
@@ -19986,6 +20389,7 @@ var BaseMaterial = /*#__PURE__*/ function(Material) {
19986
20389
  _this = PBRBaseMaterial.call(this, engine, Shader.find("pbr")) || this;
19987
20390
  _this.shaderData.setFloat(PBRMaterial._metallicProp, 1);
19988
20391
  _this.shaderData.setFloat(PBRMaterial._roughnessProp, 1);
20392
+ _this.shaderData.setFloat(PBRMaterial._iorProp, 1.5);
19989
20393
  return _this;
19990
20394
  }
19991
20395
  var _proto = PBRMaterial.prototype;
@@ -19997,10 +20401,23 @@ var BaseMaterial = /*#__PURE__*/ function(Material) {
19997
20401
  return dest;
19998
20402
  };
19999
20403
  _create_class(PBRMaterial, [
20404
+ {
20405
+ key: "ior",
20406
+ get: /**
20407
+ * Index Of Refraction.
20408
+ * @defaultValue `1.5`
20409
+ */ function get() {
20410
+ return this.shaderData.getFloat(PBRMaterial._iorProp);
20411
+ },
20412
+ set: function set(v) {
20413
+ this.shaderData.setFloat(PBRMaterial._iorProp, Math.max(v, 0));
20414
+ }
20415
+ },
20000
20416
  {
20001
20417
  key: "metallic",
20002
20418
  get: /**
20003
- * Metallic, default 1.0.
20419
+ * Metallic.
20420
+ * @defaultValue `1.0`
20004
20421
  */ function get() {
20005
20422
  return this.shaderData.getFloat(PBRMaterial._metallicProp);
20006
20423
  },
@@ -20011,7 +20428,8 @@ var BaseMaterial = /*#__PURE__*/ function(Material) {
20011
20428
  {
20012
20429
  key: "roughness",
20013
20430
  get: /**
20014
- * Roughness, default 1.0.
20431
+ * Roughness. default 1.0.
20432
+ * @defaultValue `1.0`
20015
20433
  */ function get() {
20016
20434
  return this.shaderData.getFloat(PBRMaterial._roughnessProp);
20017
20435
  },
@@ -20048,6 +20466,9 @@ var BaseMaterial = /*#__PURE__*/ function(Material) {
20048
20466
  (function() {
20049
20467
  PBRMaterial._roughnessMetallicTextureProp = ShaderProperty.getByName("material_RoughnessMetallicTexture");
20050
20468
  })();
20469
+ (function() {
20470
+ PBRMaterial._iorProp = Shader.getPropertyByName("material_IOR");
20471
+ })();
20051
20472
 
20052
20473
  /**
20053
20474
  * PBR (Specular-Glossiness Workflow) Material.
@@ -20259,9 +20680,18 @@ var TextVerticalAlignment;
20259
20680
  * @internal
20260
20681
  */ _proto._addSprite = function _addSprite(sprite) {
20261
20682
  this._spriteNamesToIndex[sprite.name] = this._sprites.push(sprite) - 1;
20683
+ sprite._atlas = this;
20684
+ sprite.isGCIgnored = true;
20262
20685
  };
20263
- _proto._onDestroy = function _onDestroy() {
20686
+ /**
20687
+ * @internal
20688
+ */ _proto._onDestroy = function _onDestroy() {
20264
20689
  ReferResource.prototype._onDestroy.call(this);
20690
+ var _this = this, sprites = _this._sprites;
20691
+ for(var i = 0, n = sprites.length; i < n; i++){
20692
+ sprites[i].destroy();
20693
+ }
20694
+ sprites.length = 0;
20265
20695
  this._sprites = null;
20266
20696
  this._spriteNamesToIndex = null;
20267
20697
  };
@@ -20309,8 +20739,10 @@ var TextVerticalAlignment;
20309
20739
  if (name === void 0) name = null;
20310
20740
  var _this;
20311
20741
  _this = ReferResource.call(this, engine) || this;
20312
- _this._width = undefined;
20313
- _this._height = undefined;
20742
+ _this._automaticWidth = 0;
20743
+ _this._automaticHeight = 0;
20744
+ _this._customWidth = undefined;
20745
+ _this._customHeight = undefined;
20314
20746
  _this._positions = [
20315
20747
  new Vector2(),
20316
20748
  new Vector2(),
@@ -20331,7 +20763,7 @@ var TextVerticalAlignment;
20331
20763
  _this._region = new Rect(0, 0, 1, 1);
20332
20764
  _this._pivot = new Vector2(0.5, 0.5);
20333
20765
  _this._border = new Vector4(0, 0, 0, 0);
20334
- _this._dirtyUpdateFlag = 0x3;
20766
+ _this._dirtyUpdateFlag = 0x7;
20335
20767
  /** @internal */ _this._updateFlagManager = new UpdateFlagManager();
20336
20768
  _this._texture = texture;
20337
20769
  region && _this._region.copyFrom(region);
@@ -20369,17 +20801,41 @@ var TextVerticalAlignment;
20369
20801
  this._dirtyUpdateFlag & 0x1 && this._updatePositions();
20370
20802
  return this._bounds;
20371
20803
  };
20372
- _proto._onDestroy = function _onDestroy() {
20804
+ /**
20805
+ * @internal
20806
+ */ _proto._addReferCount = function _addReferCount(value) {
20807
+ var _this__atlas;
20808
+ ReferResource.prototype._addReferCount.call(this, value);
20809
+ (_this__atlas = this._atlas) == null ? void 0 : _this__atlas._addReferCount(value);
20810
+ };
20811
+ /**
20812
+ * @internal
20813
+ */ _proto._onDestroy = function _onDestroy() {
20373
20814
  ReferResource.prototype._onDestroy.call(this);
20815
+ this._positions.length = 0;
20816
+ this._positions = null;
20817
+ this._uvs.length = 0;
20818
+ this._uvs = null;
20819
+ this._atlasRegion = null;
20820
+ this._atlasRegionOffset = null;
20821
+ this._region = null;
20822
+ this._pivot = null;
20823
+ this._border = null;
20824
+ this._bounds = null;
20825
+ this._atlas = null;
20374
20826
  this._texture = null;
20827
+ this._updateFlagManager = null;
20375
20828
  };
20376
20829
  _proto._calDefaultSize = function _calDefaultSize() {
20377
20830
  if (this._texture) {
20378
20831
  var _this = this, _texture = _this._texture, _atlasRegion = _this._atlasRegion, _atlasRegionOffset = _this._atlasRegionOffset, _region = _this._region;
20379
20832
  var pixelsPerUnitReciprocal = 1.0 / Engine._pixelsPerUnit;
20380
- this._width = _texture.width * _atlasRegion.width / (1 - _atlasRegionOffset.x - _atlasRegionOffset.z) * _region.width * pixelsPerUnitReciprocal;
20381
- this._height = _texture.height * _atlasRegion.height / (1 - _atlasRegionOffset.y - _atlasRegionOffset.w) * _region.height * pixelsPerUnitReciprocal;
20833
+ this._automaticWidth = _texture.width * _atlasRegion.width / (1 - _atlasRegionOffset.x - _atlasRegionOffset.z) * _region.width * pixelsPerUnitReciprocal;
20834
+ this._automaticHeight = _texture.height * _atlasRegion.height / (1 - _atlasRegionOffset.y - _atlasRegionOffset.w) * _region.height * pixelsPerUnitReciprocal;
20835
+ } else {
20836
+ this._automaticWidth = this._automaticHeight = 0;
20382
20837
  }
20838
+ this._dirtyUpdateFlag &= ~0x4;
20383
20839
  };
20384
20840
  _proto._updatePositions = function _updatePositions() {
20385
20841
  var blank = this._atlasRegionOffset;
@@ -20433,11 +20889,16 @@ var TextVerticalAlignment;
20433
20889
  };
20434
20890
  _proto._dispatchSpriteChange = function _dispatchSpriteChange(type) {
20435
20891
  switch(type){
20892
+ case SpriteModifyFlags.texture:
20893
+ this._dirtyUpdateFlag |= 0x4;
20894
+ break;
20436
20895
  case SpriteModifyFlags.atlasRegionOffset:
20437
20896
  case SpriteModifyFlags.region:
20438
- this._dirtyUpdateFlag |= 0x3;
20897
+ this._dirtyUpdateFlag |= 0x7;
20439
20898
  break;
20440
20899
  case SpriteModifyFlags.atlasRegion:
20900
+ this._dirtyUpdateFlag |= 0x4 | 0x2;
20901
+ break;
20441
20902
  case SpriteModifyFlags.border:
20442
20903
  this._dirtyUpdateFlag |= 0x2;
20443
20904
  break;
@@ -20456,7 +20917,9 @@ var TextVerticalAlignment;
20456
20917
  if (this._texture !== value) {
20457
20918
  this._texture = value;
20458
20919
  this._dispatchSpriteChange(SpriteModifyFlags.texture);
20459
- (this._width === undefined || this._height === undefined) && this._dispatchSpriteChange(SpriteModifyFlags.size);
20920
+ if (this._customWidth === undefined || this._customHeight === undefined) {
20921
+ this._dispatchSpriteChange(SpriteModifyFlags.size);
20922
+ }
20460
20923
  }
20461
20924
  }
20462
20925
  },
@@ -20464,13 +20927,21 @@ var TextVerticalAlignment;
20464
20927
  key: "width",
20465
20928
  get: /**
20466
20929
  * The width of the sprite (in world coordinates).
20930
+ *
20931
+ * @remarks
20932
+ * If width is set, return the set value,
20933
+ * otherwise return the width calculated according to `Texture.width`, `Sprite.region`, `Sprite.atlasRegion`, `Sprite.atlasRegionOffset` and `Engine._pixelsPerUnit`.
20467
20934
  */ function get() {
20468
- this._width === undefined && this._calDefaultSize();
20469
- return this._width;
20935
+ if (this._customWidth !== undefined) {
20936
+ return this._customWidth;
20937
+ } else {
20938
+ this._dirtyUpdateFlag & 0x4 && this._calDefaultSize();
20939
+ return this._automaticWidth;
20940
+ }
20470
20941
  },
20471
20942
  set: function set(value) {
20472
- if (this._width !== value) {
20473
- this._width = value;
20943
+ if (this._customWidth !== value) {
20944
+ this._customWidth = value;
20474
20945
  this._dispatchSpriteChange(SpriteModifyFlags.size);
20475
20946
  }
20476
20947
  }
@@ -20479,13 +20950,21 @@ var TextVerticalAlignment;
20479
20950
  key: "height",
20480
20951
  get: /**
20481
20952
  * The height of the sprite (in world coordinates).
20953
+ *
20954
+ * @remarks
20955
+ * If height is set, return the set value,
20956
+ * otherwise return the height calculated according to `Texture.height`, `Sprite.region`, `Sprite.atlasRegion`, `Sprite.atlasRegionOffset` and `Engine._pixelsPerUnit`.
20482
20957
  */ function get() {
20483
- this._height === undefined && this._calDefaultSize();
20484
- return this._height;
20958
+ if (this._customHeight !== undefined) {
20959
+ return this._customHeight;
20960
+ } else {
20961
+ this._dirtyUpdateFlag & 0x4 && this._calDefaultSize();
20962
+ return this._automaticHeight;
20963
+ }
20485
20964
  },
20486
20965
  set: function set(value) {
20487
- if (this._height !== value) {
20488
- this._height = value;
20966
+ if (this._customHeight !== value) {
20967
+ this._customHeight = value;
20489
20968
  this._dispatchSpriteChange(SpriteModifyFlags.size);
20490
20969
  }
20491
20970
  }
@@ -20515,7 +20994,9 @@ var TextVerticalAlignment;
20515
20994
  var y = MathUtil$1.clamp(value.y, 0, 1);
20516
20995
  this._atlasRegion.set(x, y, MathUtil$1.clamp(value.width, 0, 1 - x), MathUtil$1.clamp(value.height, 0, 1 - y));
20517
20996
  this._dispatchSpriteChange(SpriteModifyFlags.atlasRegion);
20518
- (this._width === undefined || this._height === undefined) && this._dispatchSpriteChange(SpriteModifyFlags.size);
20997
+ if (this._customWidth === undefined || this._customHeight === undefined) {
20998
+ this._dispatchSpriteChange(SpriteModifyFlags.size);
20999
+ }
20519
21000
  }
20520
21001
  },
20521
21002
  {
@@ -20530,7 +21011,9 @@ var TextVerticalAlignment;
20530
21011
  var y = MathUtil$1.clamp(value.y, 0, 1);
20531
21012
  this._atlasRegionOffset.set(x, y, MathUtil$1.clamp(value.z, 0, 1 - x), MathUtil$1.clamp(value.w, 0, 1 - y));
20532
21013
  this._dispatchSpriteChange(SpriteModifyFlags.atlasRegionOffset);
20533
- (this._width === undefined || this._height === undefined) && this._dispatchSpriteChange(SpriteModifyFlags.size);
21014
+ if (this._customWidth === undefined || this._customHeight === undefined) {
21015
+ this._dispatchSpriteChange(SpriteModifyFlags.size);
21016
+ }
20534
21017
  }
20535
21018
  },
20536
21019
  {
@@ -20546,7 +21029,9 @@ var TextVerticalAlignment;
20546
21029
  var y = MathUtil$1.clamp(value.y, 0, 1);
20547
21030
  region.set(x, y, MathUtil$1.clamp(value.width, 0, 1 - x), MathUtil$1.clamp(value.height, 0, 1 - y));
20548
21031
  this._dispatchSpriteChange(SpriteModifyFlags.region);
20549
- (this._width === undefined || this._height === undefined) && this._dispatchSpriteChange(SpriteModifyFlags.size);
21032
+ if (this._customWidth === undefined || this._customHeight === undefined) {
21033
+ this._dispatchSpriteChange(SpriteModifyFlags.size);
21034
+ }
20550
21035
  }
20551
21036
  },
20552
21037
  {
@@ -20596,7 +21081,8 @@ var SpriteUpdateFlags;
20596
21081
  (function(SpriteUpdateFlags) {
20597
21082
  SpriteUpdateFlags[SpriteUpdateFlags["positions"] = 0x1] = "positions";
20598
21083
  SpriteUpdateFlags[SpriteUpdateFlags["uvs"] = 0x2] = "uvs";
20599
- SpriteUpdateFlags[SpriteUpdateFlags["all"] = 0x3] = "all";
21084
+ SpriteUpdateFlags[SpriteUpdateFlags["automaticSize"] = 0x4] = "automaticSize";
21085
+ SpriteUpdateFlags[SpriteUpdateFlags["all"] = 0x7] = "all";
20600
21086
  })(SpriteUpdateFlags || (SpriteUpdateFlags = {}));
20601
21087
 
20602
21088
  var _SlicedSpriteAssembler;
@@ -21088,8 +21574,10 @@ var TiledType;
21088
21574
  _this._tiledAdaptiveThreshold = 0.5;
21089
21575
  _this._color = new Color$1(1, 1, 1, 1);
21090
21576
  _this._sprite = null;
21091
- _this._width = undefined;
21092
- _this._height = undefined;
21577
+ _this._automaticWidth = 0;
21578
+ _this._automaticHeight = 0;
21579
+ _this._customWidth = undefined;
21580
+ _this._customHeight = undefined;
21093
21581
  _this._flipX = false;
21094
21582
  _this._flipY = false;
21095
21583
  _this._maskLayer = SpriteMaskLayer.Layer0;
@@ -21104,38 +21592,45 @@ var TiledType;
21104
21592
  /**
21105
21593
  * @internal
21106
21594
  */ _proto._cloneTo = function _cloneTo(target) {
21595
+ Renderer.prototype._cloneTo.call(this, target);
21107
21596
  target._assembler.resetData(target);
21108
21597
  target.sprite = this._sprite;
21598
+ target.drawMode = this._drawMode;
21109
21599
  };
21110
- _proto._updateShaderData = function _updateShaderData(context) {
21600
+ /**
21601
+ * @internal
21602
+ */ _proto._updateShaderData = function _updateShaderData(context) {
21111
21603
  // @ts-ignore
21112
21604
  this._updateTransformShaderData(context, Matrix._identity);
21113
21605
  };
21114
- _proto._updateBounds = function _updateBounds(worldBounds) {
21115
- var _this_sprite;
21116
- if (!((_this_sprite = this.sprite) == null ? void 0 : _this_sprite.texture) || !this.width || !this.height) {
21606
+ /**
21607
+ * @internal
21608
+ */ _proto._updateBounds = function _updateBounds(worldBounds) {
21609
+ if (this.sprite) {
21610
+ this._assembler.updatePositions(this);
21611
+ } else {
21117
21612
  worldBounds.min.set(0, 0, 0);
21118
21613
  worldBounds.max.set(0, 0, 0);
21119
- } else {
21120
- this._assembler.updatePositions(this);
21121
21614
  }
21122
21615
  };
21123
- _proto._render = function _render(context) {
21616
+ /**
21617
+ * @internal
21618
+ */ _proto._render = function _render(context) {
21124
21619
  var _this_sprite;
21125
21620
  if (!((_this_sprite = this.sprite) == null ? void 0 : _this_sprite.texture) || !this.width || !this.height) {
21126
21621
  return;
21127
21622
  }
21128
- // Update position.
21623
+ // Update position
21129
21624
  if (this._dirtyUpdateFlag & RendererUpdateFlags.WorldVolume) {
21130
21625
  this._assembler.updatePositions(this);
21131
21626
  this._dirtyUpdateFlag &= ~RendererUpdateFlags.WorldVolume;
21132
21627
  }
21133
- // Update uv.
21628
+ // Update uv
21134
21629
  if (this._dirtyUpdateFlag & 0x2) {
21135
21630
  this._assembler.updateUVs(this);
21136
21631
  this._dirtyUpdateFlag &= ~0x2;
21137
21632
  }
21138
- // Push render data
21633
+ // Push primitive
21139
21634
  var material = this.getMaterial();
21140
21635
  var texture = this.sprite.texture;
21141
21636
  var renderData = this._engine._spriteRenderDataPool.getFromPool();
@@ -21145,14 +21640,28 @@ var TiledType;
21145
21640
  /**
21146
21641
  * @internal
21147
21642
  */ _proto._onDestroy = function _onDestroy() {
21148
- var _this__sprite;
21149
21643
  Renderer.prototype._onDestroy.call(this);
21150
- (_this__sprite = this._sprite) == null ? void 0 : _this__sprite._updateFlagManager.removeListener(this._onSpriteChange);
21644
+ var sprite = this._sprite;
21645
+ if (sprite) {
21646
+ sprite._addReferCount(-1);
21647
+ sprite._updateFlagManager.removeListener(this._onSpriteChange);
21648
+ }
21649
+ this._entity = null;
21151
21650
  this._color = null;
21152
21651
  this._sprite = null;
21153
21652
  this._assembler = null;
21154
21653
  this._verticesData = null;
21155
21654
  };
21655
+ _proto._calDefaultSize = function _calDefaultSize() {
21656
+ var sprite = this._sprite;
21657
+ if (sprite) {
21658
+ this._automaticWidth = sprite.width;
21659
+ this._automaticHeight = sprite.height;
21660
+ } else {
21661
+ this._automaticWidth = this._automaticHeight = 0;
21662
+ }
21663
+ this._dirtyUpdateFlag &= ~0x4;
21664
+ };
21156
21665
  _proto._updateStencilState = function _updateStencilState() {
21157
21666
  // Update stencil.
21158
21667
  var material = this.getInstanceMaterial();
@@ -21179,22 +21688,21 @@ var TiledType;
21179
21688
  break;
21180
21689
  case SpriteModifyFlags.size:
21181
21690
  var _this = this, drawMode = _this._drawMode;
21182
- if (drawMode === SpriteDrawMode.Sliced) {
21691
+ this._dirtyUpdateFlag |= 0x4;
21692
+ if (this._drawMode === SpriteDrawMode.Sliced) {
21183
21693
  this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
21184
21694
  } else if (drawMode === SpriteDrawMode.Tiled) {
21185
21695
  this._dirtyUpdateFlag |= 0x3;
21186
21696
  } else {
21187
21697
  // When the width and height of `SpriteRenderer` are `undefined`,
21188
21698
  // the `size` of `Sprite` will affect the position of `SpriteRenderer`.
21189
- if (this._width === undefined || this._height === undefined) {
21699
+ if (this._customWidth === undefined || this._customHeight === undefined) {
21190
21700
  this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
21191
21701
  }
21192
21702
  }
21193
21703
  break;
21194
21704
  case SpriteModifyFlags.border:
21195
- if (this._drawMode === SpriteDrawMode.Sliced || this._drawMode === SpriteDrawMode.Tiled) {
21196
- this._dirtyUpdateFlag |= 0x3;
21197
- }
21705
+ this._drawMode === SpriteDrawMode.Sliced && (this._dirtyUpdateFlag |= 0x3);
21198
21706
  break;
21199
21707
  case SpriteModifyFlags.region:
21200
21708
  case SpriteModifyFlags.atlasRegionOffset:
@@ -21278,10 +21786,14 @@ var TiledType;
21278
21786
  set: function set(value) {
21279
21787
  var lastSprite = this._sprite;
21280
21788
  if (lastSprite !== value) {
21281
- lastSprite && lastSprite._updateFlagManager.removeListener(this._onSpriteChange);
21789
+ if (lastSprite) {
21790
+ lastSprite._addReferCount(-1);
21791
+ lastSprite._updateFlagManager.removeListener(this._onSpriteChange);
21792
+ }
21793
+ this._dirtyUpdateFlag |= 0x7;
21282
21794
  if (value) {
21795
+ value._addReferCount(1);
21283
21796
  value._updateFlagManager.addListener(this._onSpriteChange);
21284
- this._dirtyUpdateFlag |= 0x3;
21285
21797
  this.shaderData.setTexture(SpriteRenderer._textureProperty, value.texture);
21286
21798
  } else {
21287
21799
  this.shaderData.setTexture(SpriteRenderer._textureProperty, null);
@@ -21306,16 +21818,22 @@ var TiledType;
21306
21818
  {
21307
21819
  key: "width",
21308
21820
  get: /**
21309
- * Render width.
21821
+ * Render width (in world coordinates).
21822
+ *
21823
+ * @remarks
21824
+ * If width is set, return the set value,
21825
+ * otherwise return `SpriteRenderer.sprite.width`.
21310
21826
  */ function get() {
21311
- this._width === undefined && this._sprite && (this.width = this._sprite.width);
21312
- return this._width;
21827
+ if (this._customWidth !== undefined) {
21828
+ return this._customWidth;
21829
+ } else {
21830
+ this._dirtyUpdateFlag & 0x4 && this._calDefaultSize();
21831
+ return this._automaticWidth;
21832
+ }
21313
21833
  },
21314
21834
  set: function set(value) {
21315
- // Update width if undefined
21316
- this._width === undefined && this._sprite && (this._width = this._sprite.width);
21317
- if (this._width !== value) {
21318
- this._width = value;
21835
+ if (this._customWidth !== value) {
21836
+ this._customWidth = value;
21319
21837
  this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
21320
21838
  }
21321
21839
  }
@@ -21323,16 +21841,22 @@ var TiledType;
21323
21841
  {
21324
21842
  key: "height",
21325
21843
  get: /**
21326
- * Render height.
21844
+ * Render height (in world coordinates).
21845
+ *
21846
+ * @remarks
21847
+ * If height is set, return the set value,
21848
+ * otherwise return `SpriteRenderer.sprite.height`.
21327
21849
  */ function get() {
21328
- this._height === undefined && this._sprite && (this.height = this._sprite.height);
21329
- return this._height;
21850
+ if (this._customHeight !== undefined) {
21851
+ return this._customHeight;
21852
+ } else {
21853
+ this._dirtyUpdateFlag & 0x4 && this._calDefaultSize();
21854
+ return this._automaticHeight;
21855
+ }
21330
21856
  },
21331
21857
  set: function set(value) {
21332
- // Update height if undefined
21333
- this._height === undefined && this._sprite && (this._height = this._sprite.height);
21334
- if (this._height !== value) {
21335
- this._height = value;
21858
+ if (this._customHeight !== value) {
21859
+ this._customHeight = value;
21336
21860
  this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
21337
21861
  }
21338
21862
  }
@@ -21419,10 +21943,16 @@ __decorate([
21419
21943
  ], SpriteRenderer.prototype, "_sprite", void 0);
21420
21944
  __decorate([
21421
21945
  ignoreClone
21422
- ], SpriteRenderer.prototype, "_width", void 0);
21946
+ ], SpriteRenderer.prototype, "_automaticWidth", void 0);
21423
21947
  __decorate([
21424
21948
  ignoreClone
21425
- ], SpriteRenderer.prototype, "_height", void 0);
21949
+ ], SpriteRenderer.prototype, "_automaticHeight", void 0);
21950
+ __decorate([
21951
+ assignmentClone
21952
+ ], SpriteRenderer.prototype, "_customWidth", void 0);
21953
+ __decorate([
21954
+ assignmentClone
21955
+ ], SpriteRenderer.prototype, "_customHeight", void 0);
21426
21956
  __decorate([
21427
21957
  assignmentClone
21428
21958
  ], SpriteRenderer.prototype, "_flipX", void 0);
@@ -21443,7 +21973,9 @@ var /**
21443
21973
  */ SpriteRendererUpdateFlags;
21444
21974
  (function(SpriteRendererUpdateFlags) {
21445
21975
  SpriteRendererUpdateFlags[SpriteRendererUpdateFlags[/** UV. */ "UV"] = 0x2] = "UV";
21446
- SpriteRendererUpdateFlags[SpriteRendererUpdateFlags[/** All. */ "All"] = 0x3] = "All";
21976
+ SpriteRendererUpdateFlags[SpriteRendererUpdateFlags[/** WorldVolume and UV . */ "RenderData"] = 0x3] = "RenderData";
21977
+ SpriteRendererUpdateFlags[SpriteRendererUpdateFlags[/** Automatic Size. */ "AutomaticSize"] = 0x4] = "AutomaticSize";
21978
+ SpriteRendererUpdateFlags[SpriteRendererUpdateFlags[/** All. */ "All"] = 0x7] = "All";
21447
21979
  })(SpriteRendererUpdateFlags || (SpriteRendererUpdateFlags = {}));
21448
21980
 
21449
21981
  /**
@@ -21531,7 +22063,9 @@ var /**
21531
22063
  this._font._addReferCount(1);
21532
22064
  this.setMaterial(engine._spriteDefaultMaterial);
21533
22065
  };
21534
- _proto._onDestroy = function _onDestroy() {
22066
+ /**
22067
+ * @internal
22068
+ */ _proto._onDestroy = function _onDestroy() {
21535
22069
  Renderer.prototype._onDestroy.call(this);
21536
22070
  // Clear render data.
21537
22071
  var charRenderDatas = this._charRenderDatas;
@@ -21548,6 +22082,7 @@ var /**
21548
22082
  /**
21549
22083
  * @internal
21550
22084
  */ _proto._cloneTo = function _cloneTo(target) {
22085
+ Renderer.prototype._cloneTo.call(this, target);
21551
22086
  target.font = this._font;
21552
22087
  target._subFont = this._subFont;
21553
22088
  };
@@ -21566,14 +22101,20 @@ var /**
21566
22101
  */ _proto._setDirtyFlagFalse = function _setDirtyFlagFalse(type) {
21567
22102
  this._dirtyFlag &= ~type;
21568
22103
  };
21569
- _proto._updateShaderData = function _updateShaderData(context) {
22104
+ /**
22105
+ * @internal
22106
+ */ _proto._updateShaderData = function _updateShaderData(context) {
21570
22107
  // @ts-ignore
21571
22108
  this._updateTransformShaderData(context, Matrix._identity);
21572
22109
  };
21573
- _proto._updateBounds = function _updateBounds(worldBounds) {
22110
+ /**
22111
+ * @internal
22112
+ */ _proto._updateBounds = function _updateBounds(worldBounds) {
21574
22113
  BoundingBox.transform(this._localBounds, this._entity.transform.worldMatrix, worldBounds);
21575
22114
  };
21576
- _proto._render = function _render(context) {
22115
+ /**
22116
+ * @internal
22117
+ */ _proto._render = function _render(context) {
21577
22118
  if (this._text === "" || this.enableWrapping && this.width <= 0 || this.overflowMode === OverflowMode.Truncate && this.height <= 0) {
21578
22119
  return;
21579
22120
  }
@@ -21668,8 +22209,6 @@ var /**
21668
22209
  _proto._updateLocalData = function _updateLocalData() {
21669
22210
  var _this = this, color = _this.color, horizontalAlignment = _this.horizontalAlignment, verticalAlignment = _this.verticalAlignment, charRenderDatas = _this._charRenderDatas;
21670
22211
  var _this__localBounds = this._localBounds, min = _this__localBounds.min, max = _this__localBounds.max;
21671
- min.set(0, 0, 0);
21672
- max.set(0, 0, 0);
21673
22212
  var _pixelsPerUnit = Engine._pixelsPerUnit;
21674
22213
  var pixelsPerUnitReciprocal = 1.0 / _pixelsPerUnit;
21675
22214
  var charFont = this._subFont;
@@ -21696,54 +22235,65 @@ var /**
21696
22235
  break;
21697
22236
  }
21698
22237
  var renderDataCount = 0;
22238
+ var firstLine = -1;
21699
22239
  var minX = Number.MAX_SAFE_INTEGER;
21700
22240
  var minY = Number.MAX_SAFE_INTEGER;
21701
22241
  var maxX = Number.MIN_SAFE_INTEGER;
21702
22242
  var maxY = Number.MIN_SAFE_INTEGER;
21703
- var lastLineIndex = linesLen - 1;
21704
22243
  for(var i = 0; i < linesLen; ++i){
21705
- var line = lines[i];
21706
22244
  var lineWidth = lineWidths[i];
21707
- var startX = 0;
21708
- switch(horizontalAlignment){
21709
- case TextHorizontalAlignment.Left:
21710
- startX = -halfRendererWidth;
21711
- break;
21712
- case TextHorizontalAlignment.Center:
21713
- startX = -lineWidth * 0.5;
21714
- break;
21715
- case TextHorizontalAlignment.Right:
21716
- startX = halfRendererWidth - lineWidth;
21717
- break;
21718
- }
21719
- for(var j = 0, m = line.length - 1; j <= m; ++j){
21720
- var char = line[j];
21721
- var charInfo = charFont._getCharInfo(char);
21722
- if (charInfo.h > 0) {
21723
- var charRenderData = charRenderDatas[renderDataCount] || charRenderDataPool.get();
21724
- var renderData = charRenderData.renderData, localPositions = charRenderData.localPositions;
21725
- charRenderData.texture = charFont._getTextureByIndex(charInfo.index);
21726
- renderData.color = color;
21727
- renderData.uvs = charInfo.uvs;
21728
- var w = charInfo.w, ascent = charInfo.ascent, descent = charInfo.descent;
21729
- var left = startX * pixelsPerUnitReciprocal;
21730
- var right = (startX + w) * pixelsPerUnitReciprocal;
21731
- var top = (startY + ascent) * pixelsPerUnitReciprocal;
21732
- var bottom = (startY - descent + 1) * pixelsPerUnitReciprocal;
21733
- localPositions.set(left, top, right, bottom);
21734
- charRenderDatas[renderDataCount] = charRenderData;
21735
- renderDataCount++;
21736
- i === 0 && (maxY = Math.max(maxY, top));
21737
- i === lastLineIndex && (minY = Math.min(minY, bottom));
21738
- j === 0 && (minX = Math.min(minX, left));
21739
- j === m && (maxX = Math.max(maxX, right));
21740
- }
21741
- startX += charInfo.xAdvance;
22245
+ if (lineWidth > 0) {
22246
+ var line = lines[i];
22247
+ var startX = 0;
22248
+ var firstRow = -1;
22249
+ if (firstLine < 0) {
22250
+ firstLine = i;
22251
+ }
22252
+ switch(horizontalAlignment){
22253
+ case TextHorizontalAlignment.Left:
22254
+ startX = -halfRendererWidth;
22255
+ break;
22256
+ case TextHorizontalAlignment.Center:
22257
+ startX = -lineWidth * 0.5;
22258
+ break;
22259
+ case TextHorizontalAlignment.Right:
22260
+ startX = halfRendererWidth - lineWidth;
22261
+ break;
22262
+ }
22263
+ for(var j = 0, n = line.length; j < n; ++j){
22264
+ var char = line[j];
22265
+ var charInfo = charFont._getCharInfo(char);
22266
+ if (charInfo.h > 0) {
22267
+ var _charRenderDatas, _ref;
22268
+ firstRow < 0 && (firstRow = j);
22269
+ var charRenderData = (_charRenderDatas = charRenderDatas)[_ref = renderDataCount++] || (_charRenderDatas[_ref] = charRenderDataPool.get());
22270
+ var renderData = charRenderData.renderData, localPositions = charRenderData.localPositions;
22271
+ charRenderData.texture = charFont._getTextureByIndex(charInfo.index);
22272
+ renderData.color = color;
22273
+ renderData.uvs = charInfo.uvs;
22274
+ var w = charInfo.w, ascent = charInfo.ascent, descent = charInfo.descent;
22275
+ var left = startX * pixelsPerUnitReciprocal;
22276
+ var right = (startX + w) * pixelsPerUnitReciprocal;
22277
+ var top = (startY + ascent) * pixelsPerUnitReciprocal;
22278
+ var bottom = (startY - descent + 1) * pixelsPerUnitReciprocal;
22279
+ localPositions.set(left, top, right, bottom);
22280
+ i === firstLine && (maxY = Math.max(maxY, top));
22281
+ minY = Math.min(minY, bottom);
22282
+ j === firstRow && (minX = Math.min(minX, left));
22283
+ maxX = Math.max(maxX, right);
22284
+ }
22285
+ startX += charInfo.xAdvance;
22286
+ }
21742
22287
  }
21743
22288
  startY -= lineHeight;
21744
22289
  }
21745
- min.set(minX, minY, 0);
21746
- max.set(maxX, maxY, 0);
22290
+ if (firstLine < 0) {
22291
+ min.set(0, 0, 0);
22292
+ max.set(0, 0, 0);
22293
+ } else {
22294
+ min.set(minX, minY, 0);
22295
+ max.set(maxX, maxY, 0);
22296
+ }
21747
22297
  // Revert excess render data to pool.
21748
22298
  var lastRenderDataCount = charRenderDatas.length;
21749
22299
  if (lastRenderDataCount > renderDataCount) {
@@ -21756,7 +22306,9 @@ var /**
21756
22306
  return a.texture.instanceId - b.texture.instanceId;
21757
22307
  });
21758
22308
  };
21759
- _proto._onTransformChanged = function _onTransformChanged(bit) {
22309
+ /**
22310
+ * @internal
22311
+ */ _proto._onTransformChanged = function _onTransformChanged(bit) {
21760
22312
  Renderer.prototype._onTransformChanged.call(this, bit);
21761
22313
  this._setDirtyFlagTrue(0x4 | 0x8);
21762
22314
  };
@@ -22075,7 +22627,6 @@ var DirtyFlag;
22075
22627
  * @internal
22076
22628
  */ var AnimationCurveOwner = /*#__PURE__*/ function() {
22077
22629
  function AnimationCurveOwner(target, type, property, cureType) {
22078
- this.crossCurveMark = 0;
22079
22630
  this.hasSavedDefaultValue = false;
22080
22631
  this.baseEvaluateData = {
22081
22632
  curKeyframeIndex: 0,
@@ -22274,6 +22825,12 @@ AnimationCurveOwner.registerAssembler(Transform, "scale", ScaleAnimationCurveOwn
22274
22825
  }();
22275
22826
  AnimationCurveOwner.registerAssembler(SkinnedMeshRenderer, "blendShapeWeights", BlendShapeWeightsAnimationCurveOwnerAssembler);
22276
22827
 
22828
+ /**
22829
+ * @internal
22830
+ */ var AnimationCurveLayerOwner = function AnimationCurveLayerOwner() {
22831
+ this.crossCurveMark = 0;
22832
+ };
22833
+
22277
22834
  /**
22278
22835
  * Associate AnimationCurve and the Entity
22279
22836
  */ var AnimationClipCurveBinding = /*#__PURE__*/ function() {
@@ -22291,6 +22848,13 @@ AnimationCurveOwner.registerAssembler(SkinnedMeshRenderer, "blendShapeWeights",
22291
22848
  };
22292
22849
  /**
22293
22850
  * @internal
22851
+ */ _proto._createCurveLayerOwner = function _createCurveLayerOwner(owner) {
22852
+ var layerOwner = new AnimationCurveLayerOwner();
22853
+ layerOwner.curveOwner = owner;
22854
+ return layerOwner;
22855
+ };
22856
+ /**
22857
+ * @internal
22294
22858
  */ _proto._getTempCurveOwner = function _getTempCurveOwner(entity) {
22295
22859
  var instanceId = entity.instanceId;
22296
22860
  if (!this._tempCurveOwner[instanceId]) {
@@ -23385,9 +23949,14 @@ var AnimatorLayerBlendingMode;
23385
23949
 
23386
23950
  /**
23387
23951
  * @internal
23388
- */ var AnimationEventHandler = function AnimationEventHandler() {
23389
- this.handlers = [];
23390
- };
23952
+ */ var AnimationEventHandler = /*#__PURE__*/ function() {
23953
+ function AnimationEventHandler() {
23954
+ this.handlers = [];
23955
+ }
23956
+ var _proto = AnimationEventHandler.prototype;
23957
+ _proto.dispose = function dispose() {};
23958
+ return AnimationEventHandler;
23959
+ }();
23391
23960
 
23392
23961
  /**
23393
23962
  * Transitions define when and how the state machine switch from on state to another. AnimatorTransition always originate from a StateMachine or a StateMachine entry.
@@ -23445,12 +24014,14 @@ var AnimatorLayerBlendingMode;
23445
24014
  * @internal
23446
24015
  */ var AnimatorLayerData = /*#__PURE__*/ function() {
23447
24016
  function AnimatorLayerData() {
24017
+ this.curveOwnerPool = Object.create(null);
23448
24018
  this.animatorStateDataMap = {};
23449
24019
  this.srcPlayData = new AnimatorStatePlayData();
23450
24020
  this.destPlayData = new AnimatorStatePlayData();
23451
24021
  this.layerState = LayerState.Standby;
23452
24022
  this.crossCurveMark = 0;
23453
24023
  this.manuallyTransition = new AnimatorStateTransition();
24024
+ this.crossOwnerLayerDataCollection = [];
23454
24025
  }
23455
24026
  var _proto = AnimatorLayerData.prototype;
23456
24027
  _proto.switchPlayData = function switchPlayData() {
@@ -23465,7 +24036,7 @@ var AnimatorLayerBlendingMode;
23465
24036
  /**
23466
24037
  * @internal
23467
24038
  */ var AnimatorStateData = function AnimatorStateData() {
23468
- this.curveOwners = [];
24039
+ this.curveLayerOwner = [];
23469
24040
  this.eventHandlers = [];
23470
24041
  };
23471
24042
 
@@ -23479,8 +24050,7 @@ var AnimatorLayerBlendingMode;
23479
24050
  /** Culling mode of this Animator. */ _this.cullingMode = AnimatorCullingMode.None;
23480
24051
  /** The playback speed of the Animator, 1.0 is normal playback speed. */ _this.speed = 1.0;
23481
24052
  _this._animatorLayersData = [];
23482
- _this._crossOwnerCollection = [];
23483
- _this._animationCurveOwners = [];
24053
+ _this._curveOwnerPool = Object.create(null);
23484
24054
  _this._animationEventHandlerPool = new ClassPool(AnimationEventHandler);
23485
24055
  _this._tempAnimatorStateInfo = {
23486
24056
  layerIndex: -1,
@@ -23512,7 +24082,6 @@ var AnimatorLayerBlendingMode;
23512
24082
  return;
23513
24083
  }
23514
24084
  var animatorLayerData = this._getAnimatorLayerData(stateInfo.layerIndex);
23515
- //TODO CM: Not consider same stateName, but different animation
23516
24085
  var animatorStateData = this._getAnimatorStateData(stateName, state, animatorLayerData);
23517
24086
  this._preparePlay(animatorLayerData, state, animatorStateData);
23518
24087
  animatorLayerData.layerState = LayerState.Playing;
@@ -23603,7 +24172,7 @@ var AnimatorLayerBlendingMode;
23603
24172
  /**
23604
24173
  * @internal
23605
24174
  */ _proto._reset = function _reset() {
23606
- var _this = this, animationCurveOwners = _this._animationCurveOwners;
24175
+ var _this = this, animationCurveOwners = _this._curveOwnerPool;
23607
24176
  for(var instanceId in animationCurveOwners){
23608
24177
  var propertyOwners = animationCurveOwners[instanceId];
23609
24178
  for(var property in propertyOwners){
@@ -23612,8 +24181,7 @@ var AnimatorLayerBlendingMode;
23612
24181
  }
23613
24182
  }
23614
24183
  this._animatorLayersData.length = 0;
23615
- this._crossOwnerCollection.length = 0;
23616
- this._animationCurveOwners.length = 0;
24184
+ this._curveOwnerPool = {};
23617
24185
  this._animationEventHandlerPool.resetPool();
23618
24186
  if (this._controllerUpdateFlag) {
23619
24187
  this._controllerUpdateFlag.flag = false;
@@ -23641,10 +24209,10 @@ var AnimatorLayerBlendingMode;
23641
24209
  return stateInfo;
23642
24210
  };
23643
24211
  _proto._saveDefaultValues = function _saveDefaultValues(stateData) {
23644
- var curveOwners = stateData.curveOwners;
23645
- for(var i = curveOwners.length - 1; i >= 0; i--){
23646
- var _curveOwners_i;
23647
- (_curveOwners_i = curveOwners[i]) == null ? void 0 : _curveOwners_i.saveDefaultValue();
24212
+ var curveLayerOwner = stateData.curveLayerOwner;
24213
+ for(var i = curveLayerOwner.length - 1; i >= 0; i--){
24214
+ var _curveLayerOwner_i;
24215
+ (_curveLayerOwner_i = curveLayerOwner[i]) == null ? void 0 : _curveLayerOwner_i.curveOwner.saveDefaultValue();
23648
24216
  }
23649
24217
  };
23650
24218
  _proto._getAnimatorStateData = function _getAnimatorStateData(stateName, animatorState, animatorLayerData) {
@@ -23653,25 +24221,32 @@ var AnimatorLayerBlendingMode;
23653
24221
  if (!animatorStateData) {
23654
24222
  animatorStateData = new AnimatorStateData();
23655
24223
  animatorStateDataMap[stateName] = animatorStateData;
23656
- this._saveAnimatorStateData(animatorState, animatorStateData);
24224
+ this._saveAnimatorStateData(animatorState, animatorStateData, animatorLayerData);
23657
24225
  this._saveAnimatorEventHandlers(animatorState, animatorStateData);
23658
24226
  }
23659
24227
  return animatorStateData;
23660
24228
  };
23661
- _proto._saveAnimatorStateData = function _saveAnimatorStateData(animatorState, animatorStateData) {
23662
- var _this = this, entity = _this.entity, animationCureOwners = _this._animationCurveOwners;
23663
- var curveOwners = animatorStateData.curveOwners;
24229
+ _proto._saveAnimatorStateData = function _saveAnimatorStateData(animatorState, animatorStateData, animatorLayerData) {
24230
+ var _this = this, entity = _this.entity, curveOwnerPool = _this._curveOwnerPool;
24231
+ var curveLayerOwner = animatorStateData.curveLayerOwner;
24232
+ var layerCurveOwnerPool = animatorLayerData.curveOwnerPool;
23664
24233
  var _animatorState_clip = animatorState.clip, curves = _animatorState_clip._curveBindings;
23665
24234
  for(var i = curves.length - 1; i >= 0; i--){
23666
24235
  var curve = curves[i];
23667
24236
  var targetEntity = curve.relativePath === "" ? entity : entity.findByPath(curve.relativePath);
23668
24237
  if (targetEntity) {
24238
+ var _curveOwnerPool, _instanceId, _propertyOwners, _property, _layerCurveOwnerPool, _instanceId1, _layerPropertyOwners, _property1;
23669
24239
  var property = curve.property;
23670
24240
  var instanceId = targetEntity.instanceId;
23671
- var propertyOwners = animationCureOwners[instanceId] || (animationCureOwners[instanceId] = {});
23672
- curveOwners[i] = propertyOwners[property] || (propertyOwners[property] = curve._createCurveOwner(targetEntity));
24241
+ // Get owner
24242
+ var propertyOwners = (_curveOwnerPool = curveOwnerPool)[_instanceId = instanceId] || (_curveOwnerPool[_instanceId] = Object.create(null));
24243
+ var owner = (_propertyOwners = propertyOwners)[_property = property] || (_propertyOwners[_property] = curve._createCurveOwner(targetEntity));
24244
+ // Get layer owner
24245
+ var layerPropertyOwners = (_layerCurveOwnerPool = layerCurveOwnerPool)[_instanceId1 = instanceId] || (_layerCurveOwnerPool[_instanceId1] = Object.create(null));
24246
+ var layerOwner = (_layerPropertyOwners = layerPropertyOwners)[_property1 = property] || (_layerPropertyOwners[_property1] = curve._createCurveLayerOwner(owner));
24247
+ curveLayerOwner[i] = layerOwner;
23673
24248
  } else {
23674
- curveOwners[i] = null;
24249
+ curveLayerOwner[i] = null;
23675
24250
  console.warn("The entity don't have the child entity which path is " + curve.relativePath + ".");
23676
24251
  }
23677
24252
  }
@@ -23699,65 +24274,61 @@ var AnimatorLayerBlendingMode;
23699
24274
  };
23700
24275
  _proto._clearCrossData = function _clearCrossData(animatorLayerData) {
23701
24276
  animatorLayerData.crossCurveMark++;
23702
- this._crossOwnerCollection.length = 0;
24277
+ animatorLayerData.crossOwnerLayerDataCollection.length = 0;
23703
24278
  };
23704
- _proto._addCrossCurveData = function _addCrossCurveData(crossCurveData, owner, curCurveIndex, nextCurveIndex) {
23705
- owner.crossSrcCurveIndex = curCurveIndex;
23706
- owner.crossDestCurveIndex = nextCurveIndex;
23707
- crossCurveData.push(owner);
24279
+ _proto._addCrossOwner = function _addCrossOwner(animatorLayerData, layerOwner, curCurveIndex, nextCurveIndex) {
24280
+ layerOwner.crossSrcCurveIndex = curCurveIndex;
24281
+ layerOwner.crossDestCurveIndex = nextCurveIndex;
24282
+ animatorLayerData.crossOwnerLayerDataCollection.push(layerOwner);
23708
24283
  };
23709
24284
  _proto._prepareCrossFading = function _prepareCrossFading(animatorLayerData) {
23710
- var crossCurveData = this._crossOwnerCollection;
23711
- var crossCurveMark = animatorLayerData.crossCurveMark;
23712
24285
  // Add src cross curve data.
23713
- this._prepareSrcCrossData(crossCurveData, animatorLayerData.srcPlayData, crossCurveMark, false);
24286
+ this._prepareSrcCrossData(animatorLayerData, false);
23714
24287
  // Add dest cross curve data.
23715
- this._prepareDestCrossData(crossCurveData, animatorLayerData.destPlayData, crossCurveMark, false);
24288
+ this._prepareDestCrossData(animatorLayerData, false);
23716
24289
  };
23717
24290
  _proto._prepareStandbyCrossFading = function _prepareStandbyCrossFading(animatorLayerData) {
23718
- var crossOwnerCollection = this._crossOwnerCollection;
23719
- var srcPlayData = animatorLayerData.srcPlayData, crossCurveMark = animatorLayerData.crossCurveMark;
23720
24291
  // Standby have two sub state, one is never play, one is finished, never play srcPlayData.state is null.
23721
- srcPlayData.state && this._prepareSrcCrossData(crossOwnerCollection, srcPlayData, crossCurveMark, true);
24292
+ animatorLayerData.srcPlayData.state && this._prepareSrcCrossData(animatorLayerData, true);
23722
24293
  // Add dest cross curve data.
23723
- this._prepareDestCrossData(crossOwnerCollection, animatorLayerData.destPlayData, crossCurveMark, true);
24294
+ this._prepareDestCrossData(animatorLayerData, true);
23724
24295
  };
23725
24296
  _proto._prepareFixedPoseCrossFading = function _prepareFixedPoseCrossFading(animatorLayerData) {
23726
- var crossOwnerCollection = this._crossOwnerCollection;
24297
+ var crossOwnerLayerDataCollection = animatorLayerData.crossOwnerLayerDataCollection;
23727
24298
  // Save current cross curve data owner fixed pose.
23728
- for(var i = crossOwnerCollection.length - 1; i >= 0; i--){
23729
- var item = crossOwnerCollection[i];
23730
- item.saveFixedPoseValue();
24299
+ for(var i = crossOwnerLayerDataCollection.length - 1; i >= 0; i--){
24300
+ var layerOwner = crossOwnerLayerDataCollection[i];
24301
+ if (!layerOwner) continue;
24302
+ layerOwner.curveOwner.saveFixedPoseValue();
23731
24303
  // Reset destCurveIndex When fixed pose crossFading again.
23732
- item.crossDestCurveIndex = -1;
24304
+ layerOwner.crossDestCurveIndex = -1;
23733
24305
  }
23734
24306
  // prepare dest AnimatorState cross data.
23735
- this._prepareDestCrossData(crossOwnerCollection, animatorLayerData.destPlayData, animatorLayerData.crossCurveMark, true);
23736
- };
23737
- _proto._prepareSrcCrossData = function _prepareSrcCrossData(crossCurveData, srcPlayData, crossCurveMark, saveFixed) {
23738
- var curveOwners = srcPlayData.stateData.curveOwners;
23739
- for(var i = curveOwners.length - 1; i >= 0; i--){
23740
- var owner = curveOwners[i];
23741
- if (!owner) continue;
23742
- owner.crossCurveMark = crossCurveMark;
23743
- owner.crossCurveDataIndex = crossCurveData.length;
23744
- saveFixed && owner.saveFixedPoseValue();
23745
- this._addCrossCurveData(crossCurveData, owner, i, -1);
23746
- }
23747
- };
23748
- _proto._prepareDestCrossData = function _prepareDestCrossData(crossCurveData, destPlayData, crossCurveMark, saveFixed) {
23749
- var curveOwners = destPlayData.stateData.curveOwners;
23750
- for(var i = curveOwners.length - 1; i >= 0; i--){
23751
- var owner = curveOwners[i];
23752
- if (!owner) continue;
23753
- if (owner.crossCurveMark === crossCurveMark) {
23754
- crossCurveData[owner.crossCurveDataIndex].crossDestCurveIndex = i;
24307
+ this._prepareDestCrossData(animatorLayerData, true);
24308
+ };
24309
+ _proto._prepareSrcCrossData = function _prepareSrcCrossData(animatorLayerData, saveFixed) {
24310
+ var curveLayerOwner = animatorLayerData.srcPlayData.stateData.curveLayerOwner;
24311
+ for(var i = curveLayerOwner.length - 1; i >= 0; i--){
24312
+ var layerOwner = curveLayerOwner[i];
24313
+ if (!layerOwner) continue;
24314
+ layerOwner.crossCurveMark = animatorLayerData.crossCurveMark;
24315
+ saveFixed && layerOwner.curveOwner.saveFixedPoseValue();
24316
+ this._addCrossOwner(animatorLayerData, layerOwner, i, -1);
24317
+ }
24318
+ };
24319
+ _proto._prepareDestCrossData = function _prepareDestCrossData(animatorLayerData, saveFixed) {
24320
+ var curveLayerOwner = animatorLayerData.destPlayData.stateData.curveLayerOwner;
24321
+ for(var i = curveLayerOwner.length - 1; i >= 0; i--){
24322
+ var layerOwner = curveLayerOwner[i];
24323
+ if (!layerOwner) continue;
24324
+ if (layerOwner.crossCurveMark === animatorLayerData.crossCurveMark) {
24325
+ layerOwner.crossDestCurveIndex = i;
23755
24326
  } else {
24327
+ var owner = layerOwner.curveOwner;
23756
24328
  owner.saveDefaultValue();
23757
24329
  saveFixed && owner.saveFixedPoseValue();
23758
- owner.crossCurveMark = crossCurveMark;
23759
- owner.crossCurveDataIndex = crossCurveData.length;
23760
- this._addCrossCurveData(crossCurveData, owner, -1, i);
24330
+ layerOwner.crossCurveMark = animatorLayerData.crossCurveMark;
24331
+ this._addCrossOwner(animatorLayerData, layerOwner, -1, i);
23761
24332
  }
23762
24333
  }
23763
24334
  };
@@ -23787,7 +24358,7 @@ var AnimatorLayerBlendingMode;
23787
24358
  }
23788
24359
  };
23789
24360
  _proto._updatePlayingState = function _updatePlayingState(playData, layerData, layerIndex, weight, delta, additive, aniUpdate) {
23790
- var _playData_stateData = playData.stateData, curveOwners = _playData_stateData.curveOwners, eventHandlers = _playData_stateData.eventHandlers;
24361
+ var _playData_stateData = playData.stateData, curveLayerOwner = _playData_stateData.curveLayerOwner, eventHandlers = _playData_stateData.eventHandlers;
23791
24362
  var state = playData.state, lastPlayState = playData.playState, lastClipTime = playData.clipTime;
23792
24363
  var _state_clip = state.clip, curveBindings = _state_clip._curveBindings;
23793
24364
  playData.update(this.speed < 0);
@@ -23797,8 +24368,8 @@ var AnimatorLayerBlendingMode;
23797
24368
  var clipTime = playData.clipTime, playState = playData.playState;
23798
24369
  eventHandlers.length && this._fireAnimationEvents(playData, eventHandlers, lastClipTime, clipTime);
23799
24370
  for(var i = curveBindings.length - 1; i >= 0; i--){
23800
- var owner = curveOwners[i];
23801
- owner == null ? void 0 : owner.evaluateAndApplyValue(curveBindings[i].curve, clipTime, weight, additive);
24371
+ var _curveLayerOwner_i;
24372
+ (_curveLayerOwner_i = curveLayerOwner[i]) == null ? void 0 : _curveLayerOwner_i.curveOwner.evaluateAndApplyValue(curveBindings[i].curve, clipTime, weight, additive);
23802
24373
  }
23803
24374
  playData.frameTime += state.speed * delta;
23804
24375
  if (playState === AnimatorStatePlayState.Finished) {
@@ -23814,7 +24385,7 @@ var AnimatorLayerBlendingMode;
23814
24385
  }
23815
24386
  };
23816
24387
  _proto._updateCrossFade = function _updateCrossFade(srcPlayData, destPlayData, layerData, layerIndex, weight, delta, additive, aniUpdate) {
23817
- var _this = this, crossCurveDataCollection = _this._crossOwnerCollection;
24388
+ var crossOwnerLayerDataCollection = layerData.crossOwnerLayerDataCollection;
23818
24389
  var _srcPlayData_state_clip = srcPlayData.state.clip, srcCurves = _srcPlayData_state_clip._curveBindings;
23819
24390
  var srcState = srcPlayData.state, srcStateData = srcPlayData.stateData, lastSrcPlayState = srcPlayData.playState;
23820
24391
  var srcEventHandlers = srcStateData.eventHandlers;
@@ -23853,14 +24424,16 @@ var AnimatorLayerBlendingMode;
23853
24424
  } else {
23854
24425
  this._callAnimatorScriptOnUpdate(destState, layerIndex);
23855
24426
  }
23856
- for(var i = crossCurveDataCollection.length - 1; i >= 0; i--){
23857
- var crossCurveData = crossCurveDataCollection[i];
23858
- var crossSrcCurveIndex = crossCurveData.crossSrcCurveIndex, crossDestCurveIndex = crossCurveData.crossDestCurveIndex;
23859
- crossCurveData.crossFadeAndApplyValue(crossSrcCurveIndex >= 0 ? srcCurves[crossSrcCurveIndex].curve : null, crossDestCurveIndex >= 0 ? destCurves[crossDestCurveIndex].curve : null, srcClipTime, destClipTime, crossWeight, weight, additive);
24427
+ for(var i = crossOwnerLayerDataCollection.length - 1; i >= 0; i--){
24428
+ var layerOwner = crossOwnerLayerDataCollection[i];
24429
+ if (!layerOwner) continue;
24430
+ var srcCurveIndex = layerOwner.crossSrcCurveIndex;
24431
+ var destCurveIndex = layerOwner.crossDestCurveIndex;
24432
+ layerOwner.curveOwner.crossFadeAndApplyValue(srcCurveIndex >= 0 ? srcCurves[srcCurveIndex].curve : null, destCurveIndex >= 0 ? destCurves[destCurveIndex].curve : null, srcClipTime, destClipTime, crossWeight, weight, additive);
23860
24433
  }
23861
24434
  };
23862
24435
  _proto._updateCrossFadeFromPose = function _updateCrossFadeFromPose(destPlayData, layerData, layerIndex, layerWeight, delta, additive, aniUpdate) {
23863
- var crossCurveDataCollection = this._crossOwnerCollection;
24436
+ var crossOwnerLayerDataCollection = layerData.crossOwnerLayerDataCollection;
23864
24437
  var state = destPlayData.state, stateData = destPlayData.stateData, lastPlayState = destPlayData.playState;
23865
24438
  var eventHandlers = stateData.eventHandlers;
23866
24439
  var _state_clip = state.clip, curveBindings = _state_clip._curveBindings;
@@ -23884,10 +24457,11 @@ var AnimatorLayerBlendingMode;
23884
24457
  } else {
23885
24458
  this._callAnimatorScriptOnUpdate(state, layerIndex);
23886
24459
  }
23887
- for(var i = crossCurveDataCollection.length - 1; i >= 0; i--){
23888
- var crossCurveData = crossCurveDataCollection[i];
23889
- var crossDestCurveIndex = crossCurveData.crossDestCurveIndex;
23890
- crossCurveData.crossFadeFromPoseAndApplyValue(crossDestCurveIndex >= 0 ? curveBindings[crossDestCurveIndex].curve : null, destClipTime, crossWeight, layerWeight, additive);
24460
+ for(var i = crossOwnerLayerDataCollection.length - 1; i >= 0; i--){
24461
+ var layerOwner = crossOwnerLayerDataCollection[i];
24462
+ if (!layerOwner) continue;
24463
+ var curveIndex = layerOwner.crossDestCurveIndex;
24464
+ layerOwner.curveOwner.crossFadeFromPoseAndApplyValue(curveIndex >= 0 ? curveBindings[curveIndex].curve : null, destClipTime, crossWeight, layerWeight, additive);
23891
24465
  }
23892
24466
  };
23893
24467
  _proto._updateCrossFadeData = function _updateCrossFadeData(layerData, crossWeight, delta, fixed) {
@@ -23909,18 +24483,19 @@ var AnimatorLayerBlendingMode;
23909
24483
  if (layerData.layerState === LayerState.Playing) {
23910
24484
  var srcPlayData = layerData.srcPlayData;
23911
24485
  if (srcPlayData.state !== playState) {
23912
- var curveOwners = srcPlayData.stateData.curveOwners;
23913
- for(var i = curveOwners.length - 1; i >= 0; i--){
23914
- var owner = curveOwners[i];
24486
+ var curveLayerOwner = srcPlayData.stateData.curveLayerOwner;
24487
+ for(var i = curveLayerOwner.length - 1; i >= 0; i--){
24488
+ var _curveLayerOwner_i;
24489
+ var owner = (_curveLayerOwner_i = curveLayerOwner[i]) == null ? void 0 : _curveLayerOwner_i.curveOwner;
23915
24490
  (owner == null ? void 0 : owner.hasSavedDefaultValue) && owner.revertDefaultValue();
23916
24491
  }
23917
24492
  this._saveDefaultValues(playStateData);
23918
24493
  }
23919
24494
  } else {
23920
24495
  // layerState is CrossFading, FixedCrossFading, Standby
23921
- var crossCurveDataCollection = this._crossOwnerCollection;
23922
- for(var i1 = crossCurveDataCollection.length - 1; i1 >= 0; i1--){
23923
- var owner1 = crossCurveDataCollection[i1];
24496
+ var crossOwnerLayerDataCollection = layerData.crossOwnerLayerDataCollection;
24497
+ for(var i1 = crossOwnerLayerDataCollection.length - 1; i1 >= 0; i1--){
24498
+ var owner1 = crossOwnerLayerDataCollection[i1].curveOwner;
23924
24499
  owner1.hasSavedDefaultValue && owner1.revertDefaultValue();
23925
24500
  }
23926
24501
  this._saveDefaultValues(playStateData);
@@ -24090,10 +24665,7 @@ __decorate([
24090
24665
  ], Animator.prototype, "_animatorLayersData", void 0);
24091
24666
  __decorate([
24092
24667
  ignoreClone
24093
- ], Animator.prototype, "_crossOwnerCollection", void 0);
24094
- __decorate([
24095
- ignoreClone
24096
- ], Animator.prototype, "_animationCurveOwners", void 0);
24668
+ ], Animator.prototype, "_curveOwnerPool", void 0);
24097
24669
  __decorate([
24098
24670
  ignoreClone
24099
24671
  ], Animator.prototype, "_animationEventHandlerPool", void 0);
@@ -25526,7 +26098,9 @@ var _tempVector3 = new Vector3();
25526
26098
  this.getMaterial().shaderData.setTexture("u_texture", texture);
25527
26099
  }
25528
26100
  };
25529
- _proto._render = function _render(context) {
26101
+ /**
26102
+ * @internal
26103
+ */ _proto._render = function _render(context) {
25530
26104
  this._updateStrapVertices(context.camera, this._points);
25531
26105
  this._updateStrapCoords();
25532
26106
  this._vertexBuffer.setData(this._vertices);
@@ -25720,7 +26294,7 @@ var cacheDir = new Vector3();
25720
26294
  /**
25721
26295
  * The position of the probe can be set, the default is the origin [0,0,0].
25722
26296
  */ _this.position = new Vector3(0, 0, 0);
25723
- _this._isCube = true;
26297
+ /** @internal */ _this._isCube = true;
25724
26298
  _this.oriViewMatrix = new Matrix();
25725
26299
  return _this;
25726
26300
  }
@@ -25792,5 +26366,5 @@ var cacheDir = new Vector3();
25792
26366
  return CubeProbe;
25793
26367
  }(Probe);
25794
26368
 
25795
- export { AmbientLight, AnimationArrayCurve, AnimationBoolCurve, AnimationClip, AnimationClipCurveBinding, AnimationColorCurve, AnimationCurve, AnimationEvent, AnimationFloatArrayCurve, AnimationFloatCurve, AnimationQuaternionCurve, AnimationVector2Curve, AnimationVector3Curve, AnimationVector4Curve, Animator, AnimatorConditionMode, AnimatorController, AnimatorControllerLayer, AnimatorCullingMode, AnimatorLayerBlendingMode, AnimatorState, AnimatorStateMachine, AnimatorStateTransition, AssetPromise, AssetType, Background, BackgroundMode, BackgroundTextureFillMode, BaseMaterial, Basic2DBatcher, BasicRenderPipeline, BlendFactor, BlendMode, BlendOperation, BlendShape, BlendShapeFrame, BlinnPhongMaterial, BoolUpdateFlag, BoxColliderShape, Buffer, BufferBindFlag, BufferMesh, BufferUsage, BufferUtil, Camera, CameraClearFlags, CapsuleColliderShape, CharacterController, CloneManager, Collider, ColliderShape, ColliderShapeUpAxis, CollisionDetectionMode, ColorSpace, ColorWriteMask, CompareFunction, Component, ContentRestorer, ControllerCollisionFlag, ControllerNonWalkableMode, CubeProbe, CullMode, DataType, DependentMode, DiffuseMode, DirectLight, DynamicCollider, DynamicColliderConstraints, Engine, EngineObject, Entity, EventDispatcher, FixedJoint, FogMode, Font, FontStyle, GLCapabilityType, HingeJoint, HitResult, IndexBufferBinding, IndexFormat, InputManager, InterpolationType, Joint, JointLimits, JointMotor, Keyframe, Keys, Layer, Light, Loader, Logger, Material, Mesh, MeshRenderer, MeshTopology, ModelMesh, OverflowMode, PBRBaseMaterial, PBRMaterial, PBRSpecularMaterial, ParticleRenderer, ParticleRendererBlendMode, PhysicsManager, PhysicsMaterial, PhysicsMaterialCombineMode, PipelineStage, PlaneColliderShape, Platform, PointLight, Pointer, PointerButton, PointerPhase, PrimitiveMesh, Probe, ReferResource, RenderBufferDepthFormat, RenderFace, RenderPass, RenderQueue, RenderQueueType, RenderTarget, Renderer, ResourceManager, Scene, SceneManager, Script, SetDataOptions, Shader, ShaderData, ShaderFactory, ShaderMacro, ShaderMacroCollection, ShaderPass, ShaderProperty, ShaderPropertyType, ShaderTagKey, ShadowCascadesMode, ShadowResolution, ShadowType, Skin, SkinnedMeshRenderer, Sky, SkyBoxMaterial, SkyProceduralMaterial, SphereColliderShape, SpotLight, SpringJoint, Sprite, SpriteAtlas, SpriteDrawMode, SpriteMask, SpriteMaskInteraction, SpriteMaskLayer, SpriteRenderer, SpriteTileMode, StateMachineScript, StaticCollider, StencilOperation, SubMesh, SubShader, SunMode, SystemInfo, TextHorizontalAlignment, TextRenderer, TextUtils, TextVerticalAlignment, Texture, Texture2D, Texture2DArray, TextureCoordinate, TextureCube, TextureCubeFace, TextureDepthCompareFunction, TextureFilterMode, TextureFormat, TextureWrapMode, Time, TrailMaterial, TrailRenderer, Transform, UnlitMaterial, Utils, VertexBufferBinding, VertexElement, VertexElementFormat, WrapMode, assignmentClone, deepClone, dependentComponents, ignoreClone, request, resourceLoader, shallowClone };
26369
+ export { AmbientLight, AnimationArrayCurve, AnimationBoolCurve, AnimationClip, AnimationClipCurveBinding, AnimationColorCurve, AnimationCurve, AnimationEvent, AnimationFloatArrayCurve, AnimationFloatCurve, AnimationQuaternionCurve, AnimationVector2Curve, AnimationVector3Curve, AnimationVector4Curve, Animator, AnimatorConditionMode, AnimatorController, AnimatorControllerLayer, AnimatorCullingMode, AnimatorLayerBlendingMode, AnimatorState, AnimatorStateMachine, AnimatorStateTransition, AssetPromise, AssetType, Background, BackgroundMode, BackgroundTextureFillMode, BaseMaterial, Basic2DBatcher, BasicRenderPipeline, BlendFactor, BlendMode, BlendOperation, BlendShape, BlendShapeFrame, BlendState, BlinnPhongMaterial, BoolUpdateFlag, BoxColliderShape, Buffer, BufferBindFlag, BufferMesh, BufferUsage, BufferUtil, Camera, CameraClearFlags, CapsuleColliderShape, CharacterController, CloneManager, Collider, ColliderShape, ColliderShapeUpAxis, CollisionDetectionMode, ColorSpace, ColorWriteMask, CompareFunction, Component, ContentRestorer, ControllerCollisionFlag, ControllerNonWalkableMode, CubeProbe, CullMode, DataType, DependentMode, DepthState, DiffuseMode, DirectLight, DynamicCollider, DynamicColliderConstraints, Engine, EngineObject, Entity, EventDispatcher, FixedJoint, FogMode, Font, FontStyle, GLCapabilityType, HingeJoint, HitResult, IndexBufferBinding, IndexFormat, InputManager, InterpolationType, Joint, JointLimits, JointMotor, Keyframe, Keys, Layer, Light, Loader, Logger, Material, Mesh, MeshRenderer, MeshTopology, ModelMesh, OverflowMode, PBRBaseMaterial, PBRMaterial, PBRSpecularMaterial, ParticleRenderer, ParticleRendererBlendMode, PhysicsManager, PhysicsMaterial, PhysicsMaterialCombineMode, PipelineStage, PlaneColliderShape, Platform, PointLight, Pointer, PointerButton, PointerPhase, PrimitiveMesh, Probe, RasterState, ReferResource, RenderBufferDepthFormat, RenderFace, RenderPass, RenderQueue, RenderQueueType, RenderState, RenderTarget, RenderTargetBlendState, Renderer, ResourceManager, Scene, SceneManager, Script, SetDataOptions, Shader, ShaderData, ShaderFactory, ShaderMacro, ShaderMacroCollection, ShaderPass, ShaderProperty, ShaderPropertyType, ShaderTagKey, ShadowCascadesMode, ShadowResolution, ShadowType, Skin, SkinnedMeshRenderer, Sky, SkyBoxMaterial, SkyProceduralMaterial, SphereColliderShape, SpotLight, SpringJoint, Sprite, SpriteAtlas, SpriteDrawMode, SpriteMask, SpriteMaskInteraction, SpriteMaskLayer, SpriteRenderer, SpriteTileMode, StateMachineScript, StaticCollider, StencilOperation, StencilState, SubMesh, SubShader, SunMode, SystemInfo, TextHorizontalAlignment, TextRenderer, TextUtils, TextVerticalAlignment, Texture, Texture2D, Texture2DArray, TextureCoordinate, TextureCube, TextureCubeFace, TextureDepthCompareFunction, TextureFilterMode, TextureFormat, TextureWrapMode, Time, TrailMaterial, TrailRenderer, Transform, UnlitMaterial, Utils, VertexBufferBinding, VertexElement, VertexElementFormat, WrapMode, assignmentClone, deepClone, dependentComponents, ignoreClone, request, resourceLoader, shallowClone };
25796
26370
  //# sourceMappingURL=module.js.map