@galacean/engine-core 1.0.0-beta.10 → 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.
package/dist/module.js CHANGED
@@ -2284,6 +2284,29 @@ var /** @internal */ PromiseState;
2284
2284
  * @remarks The release principle is that it is not referenced by the components, including direct and indirect reference.
2285
2285
  */ _proto.gc = function gc() {
2286
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();
2287
2310
  };
2288
2311
  /**
2289
2312
  * Add content restorer.
@@ -4719,6 +4742,11 @@ var ComponentCloner = /*#__PURE__*/ function() {
4719
4742
  * @returns Cloned entity
4720
4743
  */ _proto.clone = function clone() {
4721
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
+ }
4722
4750
  cloneEntity._isActive = this._isActive;
4723
4751
  cloneEntity.transform.localMatrix = this.transform.localMatrix;
4724
4752
  var children = this._children;
@@ -4743,6 +4771,10 @@ var ComponentCloner = /*#__PURE__*/ function() {
4743
4771
  return;
4744
4772
  }
4745
4773
  EngineObject.prototype.destroy.call(this);
4774
+ if (this._hookResource) {
4775
+ this._hookResource._addReferCount(-1);
4776
+ this._hookResource = null;
4777
+ }
4746
4778
  var components = this._components;
4747
4779
  for(var i = components.length - 1; i >= 0; i--){
4748
4780
  components[i].destroy();
@@ -9397,9 +9429,9 @@ __decorate([
9397
9429
  function Material(engine, shader) {
9398
9430
  var _this;
9399
9431
  _this = ReferResource.call(this, engine) || this;
9400
- /** Shader data. */ _this.shaderData = new ShaderData(ShaderDataGroup.Material);
9401
9432
  /** @internal */ _this._renderStates = [] // todo: later will as a part of shaderData when shader effect frame is OK, that is more powerful and flexible.
9402
9433
  ;
9434
+ _this._shaderData = new ShaderData(ShaderDataGroup.Material);
9403
9435
  _this.shader = shader;
9404
9436
  return _this;
9405
9437
  }
@@ -9423,7 +9455,23 @@ __decorate([
9423
9455
  ReferResource.prototype._addReferCount.call(this, value);
9424
9456
  this.shaderData._addReferCount(value);
9425
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
+ };
9426
9466
  _create_class(Material, [
9467
+ {
9468
+ key: "shaderData",
9469
+ get: /**
9470
+ * Shader data.
9471
+ */ function get() {
9472
+ return this._shaderData;
9473
+ }
9474
+ },
9427
9475
  {
9428
9476
  key: "shader",
9429
9477
  get: /**
@@ -9496,6 +9544,12 @@ __decorate([
9496
9544
  */ _proto.resetPool = function resetPool() {
9497
9545
  this._elementPoolIndex = 0;
9498
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
+ };
9499
9553
  return ClassPool;
9500
9554
  }();
9501
9555
 
@@ -9516,6 +9570,9 @@ var RenderData = function RenderData() {
9516
9570
  this.mesh = mesh;
9517
9571
  this.subMesh = subMesh;
9518
9572
  };
9573
+ _proto.dispose = function dispose() {
9574
+ this.component = this.material = this.mesh = this.subMesh = null;
9575
+ };
9519
9576
  return MeshRenderData;
9520
9577
  }(RenderData);
9521
9578
 
@@ -10661,6 +10718,9 @@ var RenderElement = /*#__PURE__*/ function() {
10661
10718
  this.shaderPass = shaderPass;
10662
10719
  this.renderState = renderState;
10663
10720
  };
10721
+ _proto.dispose = function dispose() {
10722
+ this.data = this.shaderPass = this.renderState = null;
10723
+ };
10664
10724
  return RenderElement;
10665
10725
  }();
10666
10726
 
@@ -10680,7 +10740,6 @@ var Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
10680
10740
  function Renderer1(entity) {
10681
10741
  var _this;
10682
10742
  _this = Component.call(this, entity) || this;
10683
- /** ShaderData related to renderer. */ _this.shaderData = new ShaderData(ShaderDataGroup.Renderer);
10684
10743
  /** @internal */ _this._onUpdateIndex = -1;
10685
10744
  /** @internal */ _this._rendererIndex = -1;
10686
10745
  /** @internal */ _this._globalShaderMacro = new ShaderMacroCollection();
@@ -10688,6 +10747,7 @@ var Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
10688
10747
  _this._overrideUpdate = false;
10689
10748
  _this._materials = [];
10690
10749
  _this._dirtyUpdateFlag = 0;
10750
+ _this._shaderData = new ShaderData(ShaderDataGroup.Renderer);
10691
10751
  _this._mvMatrix = new Matrix();
10692
10752
  _this._mvpMatrix = new Matrix();
10693
10753
  _this._mvInvMatrix = new Matrix();
@@ -10833,6 +10893,17 @@ var Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
10833
10893
  var _materials_i;
10834
10894
  (_materials_i = materials[i]) == null ? void 0 : _materials_i._addReferCount(-1);
10835
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;
10836
10907
  };
10837
10908
  /**
10838
10909
  * @internal
@@ -10908,6 +10979,14 @@ var Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
10908
10979
  this._dirtyUpdateFlag |= 0x1;
10909
10980
  };
10910
10981
  _create_class(Renderer1, [
10982
+ {
10983
+ key: "shaderData",
10984
+ get: /**
10985
+ * ShaderData related to renderer.
10986
+ */ function get() {
10987
+ return this._shaderData;
10988
+ }
10989
+ },
10911
10990
  {
10912
10991
  key: "isCulled",
10913
10992
  get: /**
@@ -10992,9 +11071,6 @@ var Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
10992
11071
  }(), function() {
10993
11072
  _Renderer._rendererLayerProperty = ShaderProperty.getByName("renderer_Layer");
10994
11073
  }(), _Renderer);
10995
- __decorate([
10996
- deepClone
10997
- ], Renderer.prototype, "shaderData", void 0);
10998
11074
  __decorate([
10999
11075
  ignoreClone
11000
11076
  ], Renderer.prototype, "_distanceForSort", void 0);
@@ -11022,6 +11098,9 @@ __decorate([
11022
11098
  __decorate([
11023
11099
  ignoreClone
11024
11100
  ], Renderer.prototype, "_dirtyUpdateFlag", void 0);
11101
+ __decorate([
11102
+ deepClone
11103
+ ], Renderer.prototype, "_shaderData", void 0);
11025
11104
  __decorate([
11026
11105
  ignoreClone
11027
11106
  ], Renderer.prototype, "_mvMatrix", void 0);
@@ -11278,6 +11357,7 @@ SimpleSpriteAssembler = __decorate([
11278
11357
  sprite._addReferCount(-1);
11279
11358
  sprite._updateFlagManager.removeListener(this._onSpriteChange);
11280
11359
  }
11360
+ this._entity = null;
11281
11361
  this._sprite = null;
11282
11362
  this._verticesData = null;
11283
11363
  };
@@ -11832,14 +11912,19 @@ var BufferUtil = /*#__PURE__*/ function() {
11832
11912
 
11833
11913
  /**
11834
11914
  * Sub-mesh, mainly contains drawing information.
11835
- */ var SubMesh = function SubMesh(start, count, topology) {
11836
- if (start === void 0) start = 0;
11837
- if (count === void 0) count = 0;
11838
- if (topology === void 0) topology = MeshTopology.Triangles;
11839
- this.start = start;
11840
- this.count = count;
11841
- this.topology = topology;
11842
- };
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
+ }();
11843
11928
 
11844
11929
  /**
11845
11930
  * Mesh.
@@ -13595,8 +13680,8 @@ var VertexChangedFlags;
13595
13680
  */ _proto._onDestroy = function _onDestroy() {
13596
13681
  Renderer.prototype._onDestroy.call(this);
13597
13682
  var mesh = this._mesh;
13598
- if (mesh && !mesh.destroyed) {
13599
- mesh._addReferCount(-1);
13683
+ if (mesh) {
13684
+ mesh.destroyed || mesh._addReferCount(-1);
13600
13685
  mesh._updateFlagManager.removeListener(this._onMeshChanged);
13601
13686
  this._mesh = null;
13602
13687
  }
@@ -13852,10 +13937,21 @@ var /**
13852
13937
  /**
13853
13938
  * @internal
13854
13939
  */ _proto._onDestroy = function _onDestroy() {
13855
- var _this_rootBone, _this__jointTexture;
13940
+ var _this__rootBone, _this__jointTexture;
13856
13941
  MeshRenderer.prototype._onDestroy.call(this);
13857
- (_this_rootBone = this.rootBone) == null ? void 0 : _this_rootBone.transform._updateFlagManager.removeListener(this._onTransformChanged);
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;
13858
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
+ }
13859
13955
  };
13860
13956
  /**
13861
13957
  * @internal
@@ -15557,6 +15653,9 @@ var SpriteMaskRenderData = /*#__PURE__*/ function(RenderData) {
15557
15653
  this.material = material;
15558
15654
  this.verticesData = verticesData;
15559
15655
  };
15656
+ _proto.dispose = function dispose() {
15657
+ this.component = this.material = this.verticesData = null;
15658
+ };
15560
15659
  return SpriteMaskRenderData;
15561
15660
  }(RenderData);
15562
15661
 
@@ -15577,6 +15676,9 @@ var SpriteRenderData = /*#__PURE__*/ function(RenderData) {
15577
15676
  this.texture = texture;
15578
15677
  this.dataIndex = dataIndex;
15579
15678
  };
15679
+ _proto.dispose = function dispose() {
15680
+ this.component = this.material = this.verticesData = this.texture = null;
15681
+ };
15580
15682
  return SpriteRenderData;
15581
15683
  }(RenderData);
15582
15684
 
@@ -15589,6 +15691,11 @@ var TextRenderData = /*#__PURE__*/ function(RenderData) {
15589
15691
  _this.multiRenderData = true;
15590
15692
  return _this;
15591
15693
  }
15694
+ var _proto = TextRenderData.prototype;
15695
+ _proto.dispose = function dispose() {
15696
+ this.component = this.material = null;
15697
+ this.charsData.length = 0;
15698
+ };
15592
15699
  return TextRenderData;
15593
15700
  }(RenderData);
15594
15701
 
@@ -16122,8 +16229,6 @@ var TextRenderData = /*#__PURE__*/ function(RenderData) {
16122
16229
  function Scene(engine, name) {
16123
16230
  var _this;
16124
16231
  _this = EngineObject.call(this, engine) || this;
16125
- /** The background of the scene. */ _this.background = new Background(_this._engine);
16126
- /** Scene-related shader data. */ _this.shaderData = new ShaderData(ShaderDataGroup.Scene);
16127
16232
  /** If cast shadows. */ _this.castShadows = true;
16128
16233
  /** The resolution of the shadow maps. */ _this.shadowResolution = ShadowResolution.Medium;
16129
16234
  /** The splits of two cascade distribution. */ _this.shadowTwoCascadeSplits = 1.0 / 3.0;
@@ -16133,6 +16238,8 @@ var TextRenderData = /*#__PURE__*/ function(RenderData) {
16133
16238
  /** @internal */ _this._isActiveInEngine = false;
16134
16239
  /** @internal */ _this._globalShaderMacro = new ShaderMacroCollection();
16135
16240
  /** @internal */ _this._rootEntities = [];
16241
+ _this._background = new Background(_this._engine);
16242
+ _this._shaderData = new ShaderData(ShaderDataGroup.Scene);
16136
16243
  _this._shadowCascades = ShadowCascadesMode.NoCascades;
16137
16244
  _this._fogMode = FogMode.None;
16138
16245
  _this._fogColor = new Color$1(0.5, 0.5, 0.5, 1.0);
@@ -16299,6 +16406,8 @@ var TextRenderData = /*#__PURE__*/ function(RenderData) {
16299
16406
  shaderData.setColor(Scene._sunlightColorProperty, sunlight._getLightIntensityColor());
16300
16407
  shaderData.setVector3(Scene._sunlightDirectionProperty, sunlight.direction);
16301
16408
  this._sunLight = sunlight;
16409
+ } else {
16410
+ this._sunLight = null;
16302
16411
  }
16303
16412
  if (this.castShadows && this._sunLight && this._sunLight.shadowType !== ShadowType.None) {
16304
16413
  shaderData.enableMacro("SCENE_SHADOW_TYPE", this._sunLight.shadowType.toString());
@@ -16358,6 +16467,22 @@ var TextRenderData = /*#__PURE__*/ function(RenderData) {
16358
16467
  this._fogParams.w = density / Math.sqrt(Math.LN2);
16359
16468
  };
16360
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
+ },
16361
16486
  {
16362
16487
  key: "shadowCascades",
16363
16488
  get: /**
@@ -18826,7 +18951,6 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component) {
18826
18951
  function Camera1(entity) {
18827
18952
  var _this;
18828
18953
  _this = Component.call(this, entity) || this;
18829
- /** Shader data. */ _this.shaderData = new ShaderData(ShaderDataGroup.Camera);
18830
18954
  /** Rendering priority - A Camera with higher priority will be rendered on top of a camera with lower priority. */ _this.priority = 0;
18831
18955
  /** Whether to enable frustum culling, it is enabled by default. */ _this.enableFrustumCulling = true;
18832
18956
  /**
@@ -18842,6 +18966,7 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component) {
18842
18966
  /** @internal */ _this._virtualCamera = new VirtualCamera();
18843
18967
  /** @internal */ _this._replacementShader = null;
18844
18968
  /** @internal */ _this._replacementSubShaderTag = null;
18969
+ _this._shaderData = new ShaderData(ShaderDataGroup.Camera);
18845
18970
  _this._isProjMatSetting = false;
18846
18971
  _this._nearClipPlane = 0.1;
18847
18972
  _this._farClipPlane = 100;
@@ -19051,6 +19176,20 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component) {
19051
19176
  this._isInvViewProjDirty.destroy();
19052
19177
  this._isViewMatrixDirty.destroy();
19053
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;
19054
19193
  };
19055
19194
  _proto._projMatChange = function _projMatChange() {
19056
19195
  this._isFrustumProjectDirty = true;
@@ -19090,6 +19229,14 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component) {
19090
19229
  return this._inverseProjectionMatrix;
19091
19230
  };
19092
19231
  _create_class(Camera1, [
19232
+ {
19233
+ key: "shaderData",
19234
+ get: /**
19235
+ * Shader data.
19236
+ */ function get() {
19237
+ return this._shaderData;
19238
+ }
19239
+ },
19093
19240
  {
19094
19241
  key: "nearClipPlane",
19095
19242
  get: /**
@@ -21499,6 +21646,7 @@ var TiledType;
21499
21646
  sprite._addReferCount(-1);
21500
21647
  sprite._updateFlagManager.removeListener(this._onSpriteChange);
21501
21648
  }
21649
+ this._entity = null;
21502
21650
  this._color = null;
21503
21651
  this._sprite = null;
21504
21652
  this._assembler = null;
@@ -23801,9 +23949,14 @@ var AnimatorLayerBlendingMode;
23801
23949
 
23802
23950
  /**
23803
23951
  * @internal
23804
- */ var AnimationEventHandler = function AnimationEventHandler() {
23805
- this.handlers = [];
23806
- };
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
+ }();
23807
23960
 
23808
23961
  /**
23809
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.