@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.
@@ -2289,6 +2289,29 @@ var /** @internal */ PromiseState;
2289
2289
  * @remarks The release principle is that it is not referenced by the components, including direct and indirect reference.
2290
2290
  */ _proto.gc = function gc() {
2291
2291
  this._gc(false);
2292
+ var engine = this.engine;
2293
+ engine._renderElementPool.garbageCollection();
2294
+ engine._meshRenderDataPool.garbageCollection();
2295
+ engine._spriteRenderDataPool.garbageCollection();
2296
+ engine._spriteMaskRenderDataPool.garbageCollection();
2297
+ engine._textRenderDataPool.garbageCollection();
2298
+ var _componentsManager = engine._componentsManager, _lightManager = engine._lightManager;
2299
+ _componentsManager._renderers.garbageCollection();
2300
+ // @ts-ignore
2301
+ _componentsManager._onStartScripts.garbageCollection();
2302
+ // @ts-ignore
2303
+ _componentsManager._onUpdateScripts.garbageCollection();
2304
+ // @ts-ignore
2305
+ _componentsManager._onLateUpdateScripts.garbageCollection();
2306
+ // @ts-ignore
2307
+ _componentsManager._onPhysicsUpdateScripts.garbageCollection();
2308
+ // @ts-ignore
2309
+ _componentsManager._onUpdateAnimations.garbageCollection();
2310
+ // @ts-ignore
2311
+ _componentsManager._onUpdateRenderers.garbageCollection();
2312
+ _lightManager._spotLights.garbageCollection();
2313
+ _lightManager._pointLights.garbageCollection();
2314
+ _lightManager._directLights.garbageCollection();
2292
2315
  };
2293
2316
  /**
2294
2317
  * Add content restorer.
@@ -4724,6 +4747,11 @@ var ComponentCloner = /*#__PURE__*/ function() {
4724
4747
  * @returns Cloned entity
4725
4748
  */ _proto.clone = function clone() {
4726
4749
  var cloneEntity = new Entity(this._engine, this.name);
4750
+ var _this = this, hookResource = _this._hookResource;
4751
+ if (hookResource) {
4752
+ cloneEntity._hookResource = hookResource;
4753
+ hookResource._addReferCount(1);
4754
+ }
4727
4755
  cloneEntity._isActive = this._isActive;
4728
4756
  cloneEntity.transform.localMatrix = this.transform.localMatrix;
4729
4757
  var children = this._children;
@@ -4748,6 +4776,10 @@ var ComponentCloner = /*#__PURE__*/ function() {
4748
4776
  return;
4749
4777
  }
4750
4778
  EngineObject.prototype.destroy.call(this);
4779
+ if (this._hookResource) {
4780
+ this._hookResource._addReferCount(-1);
4781
+ this._hookResource = null;
4782
+ }
4751
4783
  var components = this._components;
4752
4784
  for(var i = components.length - 1; i >= 0; i--){
4753
4785
  components[i].destroy();
@@ -9402,9 +9434,9 @@ __decorate([
9402
9434
  function Material(engine, shader) {
9403
9435
  var _this;
9404
9436
  _this = ReferResource.call(this, engine) || this;
9405
- /** Shader data. */ _this.shaderData = new ShaderData(ShaderDataGroup.Material);
9406
9437
  /** @internal */ _this._renderStates = [] // todo: later will as a part of shaderData when shader effect frame is OK, that is more powerful and flexible.
9407
9438
  ;
9439
+ _this._shaderData = new ShaderData(ShaderDataGroup.Material);
9408
9440
  _this.shader = shader;
9409
9441
  return _this;
9410
9442
  }
@@ -9428,7 +9460,23 @@ __decorate([
9428
9460
  ReferResource.prototype._addReferCount.call(this, value);
9429
9461
  this.shaderData._addReferCount(value);
9430
9462
  };
9463
+ /**
9464
+ * @override
9465
+ */ _proto._onDestroy = function _onDestroy() {
9466
+ this._shader = null;
9467
+ this._shaderData = null;
9468
+ this._renderStates.length = 0;
9469
+ this._renderStates = null;
9470
+ };
9431
9471
  _create_class(Material, [
9472
+ {
9473
+ key: "shaderData",
9474
+ get: /**
9475
+ * Shader data.
9476
+ */ function get() {
9477
+ return this._shaderData;
9478
+ }
9479
+ },
9432
9480
  {
9433
9481
  key: "shader",
9434
9482
  get: /**
@@ -9501,6 +9549,12 @@ __decorate([
9501
9549
  */ _proto.resetPool = function resetPool() {
9502
9550
  this._elementPoolIndex = 0;
9503
9551
  };
9552
+ _proto.garbageCollection = function garbageCollection() {
9553
+ var _this = this, pool = _this._elementPool;
9554
+ for(var i = pool.length - 1; i >= 0; i--){
9555
+ pool[i].dispose && pool[i].dispose();
9556
+ }
9557
+ };
9504
9558
  return ClassPool;
9505
9559
  }();
9506
9560
 
@@ -9521,6 +9575,9 @@ var RenderData = function RenderData() {
9521
9575
  this.mesh = mesh;
9522
9576
  this.subMesh = subMesh;
9523
9577
  };
9578
+ _proto.dispose = function dispose() {
9579
+ this.component = this.material = this.mesh = this.subMesh = null;
9580
+ };
9524
9581
  return MeshRenderData;
9525
9582
  }(RenderData);
9526
9583
 
@@ -10666,6 +10723,9 @@ var RenderElement = /*#__PURE__*/ function() {
10666
10723
  this.shaderPass = shaderPass;
10667
10724
  this.renderState = renderState;
10668
10725
  };
10726
+ _proto.dispose = function dispose() {
10727
+ this.data = this.shaderPass = this.renderState = null;
10728
+ };
10669
10729
  return RenderElement;
10670
10730
  }();
10671
10731
 
@@ -10685,7 +10745,6 @@ exports.Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
10685
10745
  function Renderer1(entity) {
10686
10746
  var _this;
10687
10747
  _this = Component.call(this, entity) || this;
10688
- /** ShaderData related to renderer. */ _this.shaderData = new ShaderData(ShaderDataGroup.Renderer);
10689
10748
  /** @internal */ _this._onUpdateIndex = -1;
10690
10749
  /** @internal */ _this._rendererIndex = -1;
10691
10750
  /** @internal */ _this._globalShaderMacro = new ShaderMacroCollection();
@@ -10693,6 +10752,7 @@ exports.Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
10693
10752
  _this._overrideUpdate = false;
10694
10753
  _this._materials = [];
10695
10754
  _this._dirtyUpdateFlag = 0;
10755
+ _this._shaderData = new ShaderData(ShaderDataGroup.Renderer);
10696
10756
  _this._mvMatrix = new miniprogram.Matrix();
10697
10757
  _this._mvpMatrix = new miniprogram.Matrix();
10698
10758
  _this._mvInvMatrix = new miniprogram.Matrix();
@@ -10838,6 +10898,17 @@ exports.Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
10838
10898
  var _materials_i;
10839
10899
  (_materials_i = materials[i]) == null ? void 0 : _materials_i._addReferCount(-1);
10840
10900
  }
10901
+ this._entity = null;
10902
+ this._globalShaderMacro = null;
10903
+ this._bounds = null;
10904
+ this._materials = null;
10905
+ this._shaderData = null;
10906
+ this._mvMatrix = null;
10907
+ this._mvpMatrix = null;
10908
+ this._mvInvMatrix = null;
10909
+ this._normalMatrix = null;
10910
+ this._materialsInstanced = null;
10911
+ this._rendererLayer = null;
10841
10912
  };
10842
10913
  /**
10843
10914
  * @internal
@@ -10913,6 +10984,14 @@ exports.Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
10913
10984
  this._dirtyUpdateFlag |= 0x1;
10914
10985
  };
10915
10986
  _create_class(Renderer1, [
10987
+ {
10988
+ key: "shaderData",
10989
+ get: /**
10990
+ * ShaderData related to renderer.
10991
+ */ function get() {
10992
+ return this._shaderData;
10993
+ }
10994
+ },
10916
10995
  {
10917
10996
  key: "isCulled",
10918
10997
  get: /**
@@ -10997,9 +11076,6 @@ exports.Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
10997
11076
  }(), function() {
10998
11077
  _Renderer._rendererLayerProperty = ShaderProperty.getByName("renderer_Layer");
10999
11078
  }(), _Renderer);
11000
- __decorate([
11001
- deepClone
11002
- ], exports.Renderer.prototype, "shaderData", void 0);
11003
11079
  __decorate([
11004
11080
  ignoreClone
11005
11081
  ], exports.Renderer.prototype, "_distanceForSort", void 0);
@@ -11027,6 +11103,9 @@ __decorate([
11027
11103
  __decorate([
11028
11104
  ignoreClone
11029
11105
  ], exports.Renderer.prototype, "_dirtyUpdateFlag", void 0);
11106
+ __decorate([
11107
+ deepClone
11108
+ ], exports.Renderer.prototype, "_shaderData", void 0);
11030
11109
  __decorate([
11031
11110
  ignoreClone
11032
11111
  ], exports.Renderer.prototype, "_mvMatrix", void 0);
@@ -11283,6 +11362,7 @@ SimpleSpriteAssembler = __decorate([
11283
11362
  sprite._addReferCount(-1);
11284
11363
  sprite._updateFlagManager.removeListener(this._onSpriteChange);
11285
11364
  }
11365
+ this._entity = null;
11286
11366
  this._sprite = null;
11287
11367
  this._verticesData = null;
11288
11368
  };
@@ -11837,14 +11917,19 @@ var BufferUtil = /*#__PURE__*/ function() {
11837
11917
 
11838
11918
  /**
11839
11919
  * Sub-mesh, mainly contains drawing information.
11840
- */ var SubMesh = function SubMesh(start, count, topology) {
11841
- if (start === void 0) start = 0;
11842
- if (count === void 0) count = 0;
11843
- if (topology === void 0) topology = exports.MeshTopology.Triangles;
11844
- this.start = start;
11845
- this.count = count;
11846
- this.topology = topology;
11847
- };
11920
+ */ var SubMesh = /*#__PURE__*/ function() {
11921
+ function SubMesh(start, count, topology) {
11922
+ if (start === void 0) start = 0;
11923
+ if (count === void 0) count = 0;
11924
+ if (topology === void 0) topology = exports.MeshTopology.Triangles;
11925
+ this.start = start;
11926
+ this.count = count;
11927
+ this.topology = topology;
11928
+ }
11929
+ var _proto = SubMesh.prototype;
11930
+ _proto.dispose = function dispose() {};
11931
+ return SubMesh;
11932
+ }();
11848
11933
 
11849
11934
  /**
11850
11935
  * Mesh.
@@ -13600,8 +13685,8 @@ var VertexChangedFlags;
13600
13685
  */ _proto._onDestroy = function _onDestroy() {
13601
13686
  Renderer.prototype._onDestroy.call(this);
13602
13687
  var mesh = this._mesh;
13603
- if (mesh && !mesh.destroyed) {
13604
- mesh._addReferCount(-1);
13688
+ if (mesh) {
13689
+ mesh.destroyed || mesh._addReferCount(-1);
13605
13690
  mesh._updateFlagManager.removeListener(this._onMeshChanged);
13606
13691
  this._mesh = null;
13607
13692
  }
@@ -13857,10 +13942,21 @@ var /**
13857
13942
  /**
13858
13943
  * @internal
13859
13944
  */ _proto._onDestroy = function _onDestroy() {
13860
- var _this_rootBone, _this__jointTexture;
13945
+ var _this__rootBone, _this__jointTexture;
13861
13946
  MeshRenderer.prototype._onDestroy.call(this);
13862
- (_this_rootBone = this.rootBone) == null ? void 0 : _this_rootBone.transform._updateFlagManager.removeListener(this._onTransformChanged);
13947
+ (_this__rootBone = this._rootBone) == null ? void 0 : _this__rootBone.transform._updateFlagManager.removeListener(this._onTransformChanged);
13948
+ this._rootBone = null;
13949
+ this._jointDataCreateCache = null;
13950
+ this._skin = null;
13951
+ this._blendShapeWeights = null;
13952
+ this._localBounds = null;
13953
+ this._jointMatrices = null;
13863
13954
  (_this__jointTexture = this._jointTexture) == null ? void 0 : _this__jointTexture.destroy();
13955
+ this._jointTexture = null;
13956
+ if (this._jointEntities) {
13957
+ this._jointEntities.length = 0;
13958
+ this._jointEntities = null;
13959
+ }
13864
13960
  };
13865
13961
  /**
13866
13962
  * @internal
@@ -15562,6 +15658,9 @@ var SpriteMaskRenderData = /*#__PURE__*/ function(RenderData) {
15562
15658
  this.material = material;
15563
15659
  this.verticesData = verticesData;
15564
15660
  };
15661
+ _proto.dispose = function dispose() {
15662
+ this.component = this.material = this.verticesData = null;
15663
+ };
15565
15664
  return SpriteMaskRenderData;
15566
15665
  }(RenderData);
15567
15666
 
@@ -15582,6 +15681,9 @@ var SpriteRenderData = /*#__PURE__*/ function(RenderData) {
15582
15681
  this.texture = texture;
15583
15682
  this.dataIndex = dataIndex;
15584
15683
  };
15684
+ _proto.dispose = function dispose() {
15685
+ this.component = this.material = this.verticesData = this.texture = null;
15686
+ };
15585
15687
  return SpriteRenderData;
15586
15688
  }(RenderData);
15587
15689
 
@@ -15594,6 +15696,11 @@ var TextRenderData = /*#__PURE__*/ function(RenderData) {
15594
15696
  _this.multiRenderData = true;
15595
15697
  return _this;
15596
15698
  }
15699
+ var _proto = TextRenderData.prototype;
15700
+ _proto.dispose = function dispose() {
15701
+ this.component = this.material = null;
15702
+ this.charsData.length = 0;
15703
+ };
15597
15704
  return TextRenderData;
15598
15705
  }(RenderData);
15599
15706
 
@@ -16127,8 +16234,6 @@ var TextRenderData = /*#__PURE__*/ function(RenderData) {
16127
16234
  function Scene(engine, name) {
16128
16235
  var _this;
16129
16236
  _this = EngineObject.call(this, engine) || this;
16130
- /** The background of the scene. */ _this.background = new Background(_this._engine);
16131
- /** Scene-related shader data. */ _this.shaderData = new ShaderData(ShaderDataGroup.Scene);
16132
16237
  /** If cast shadows. */ _this.castShadows = true;
16133
16238
  /** The resolution of the shadow maps. */ _this.shadowResolution = exports.ShadowResolution.Medium;
16134
16239
  /** The splits of two cascade distribution. */ _this.shadowTwoCascadeSplits = 1.0 / 3.0;
@@ -16138,6 +16243,8 @@ var TextRenderData = /*#__PURE__*/ function(RenderData) {
16138
16243
  /** @internal */ _this._isActiveInEngine = false;
16139
16244
  /** @internal */ _this._globalShaderMacro = new ShaderMacroCollection();
16140
16245
  /** @internal */ _this._rootEntities = [];
16246
+ _this._background = new Background(_this._engine);
16247
+ _this._shaderData = new ShaderData(ShaderDataGroup.Scene);
16141
16248
  _this._shadowCascades = exports.ShadowCascadesMode.NoCascades;
16142
16249
  _this._fogMode = exports.FogMode.None;
16143
16250
  _this._fogColor = new miniprogram.Color(0.5, 0.5, 0.5, 1.0);
@@ -16304,6 +16411,8 @@ var TextRenderData = /*#__PURE__*/ function(RenderData) {
16304
16411
  shaderData.setColor(Scene._sunlightColorProperty, sunlight._getLightIntensityColor());
16305
16412
  shaderData.setVector3(Scene._sunlightDirectionProperty, sunlight.direction);
16306
16413
  this._sunLight = sunlight;
16414
+ } else {
16415
+ this._sunLight = null;
16307
16416
  }
16308
16417
  if (this.castShadows && this._sunLight && this._sunLight.shadowType !== exports.ShadowType.None) {
16309
16418
  shaderData.enableMacro("SCENE_SHADOW_TYPE", this._sunLight.shadowType.toString());
@@ -16363,6 +16472,22 @@ var TextRenderData = /*#__PURE__*/ function(RenderData) {
16363
16472
  this._fogParams.w = density / Math.sqrt(Math.LN2);
16364
16473
  };
16365
16474
  _create_class(Scene, [
16475
+ {
16476
+ key: "shaderData",
16477
+ get: /**
16478
+ * Scene-related shader data.
16479
+ */ function get() {
16480
+ return this._shaderData;
16481
+ }
16482
+ },
16483
+ {
16484
+ key: "background",
16485
+ get: /**
16486
+ * The background of the scene.
16487
+ */ function get() {
16488
+ return this._background;
16489
+ }
16490
+ },
16366
16491
  {
16367
16492
  key: "shadowCascades",
16368
16493
  get: /**
@@ -18831,7 +18956,6 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component) {
18831
18956
  function Camera1(entity) {
18832
18957
  var _this;
18833
18958
  _this = Component.call(this, entity) || this;
18834
- /** Shader data. */ _this.shaderData = new ShaderData(ShaderDataGroup.Camera);
18835
18959
  /** Rendering priority - A Camera with higher priority will be rendered on top of a camera with lower priority. */ _this.priority = 0;
18836
18960
  /** Whether to enable frustum culling, it is enabled by default. */ _this.enableFrustumCulling = true;
18837
18961
  /**
@@ -18847,6 +18971,7 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component) {
18847
18971
  /** @internal */ _this._virtualCamera = new VirtualCamera();
18848
18972
  /** @internal */ _this._replacementShader = null;
18849
18973
  /** @internal */ _this._replacementSubShaderTag = null;
18974
+ _this._shaderData = new ShaderData(ShaderDataGroup.Camera);
18850
18975
  _this._isProjMatSetting = false;
18851
18976
  _this._nearClipPlane = 0.1;
18852
18977
  _this._farClipPlane = 100;
@@ -19056,6 +19181,20 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component) {
19056
19181
  this._isInvViewProjDirty.destroy();
19057
19182
  this._isViewMatrixDirty.destroy();
19058
19183
  this.shaderData._addReferCount(-1);
19184
+ this._entity = null;
19185
+ this._globalShaderMacro = null;
19186
+ this._frustum = null;
19187
+ this._renderPipeline = null;
19188
+ this._virtualCamera = null;
19189
+ this._shaderData = null;
19190
+ this._frustumViewChangeFlag = null;
19191
+ this._transform = null;
19192
+ this._isViewMatrixDirty = null;
19193
+ this._isInvViewProjDirty = null;
19194
+ this._viewport = null;
19195
+ this._inverseProjectionMatrix = null;
19196
+ this._lastAspectSize = null;
19197
+ this._invViewProjMat = null;
19059
19198
  };
19060
19199
  _proto._projMatChange = function _projMatChange() {
19061
19200
  this._isFrustumProjectDirty = true;
@@ -19095,6 +19234,14 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component) {
19095
19234
  return this._inverseProjectionMatrix;
19096
19235
  };
19097
19236
  _create_class(Camera1, [
19237
+ {
19238
+ key: "shaderData",
19239
+ get: /**
19240
+ * Shader data.
19241
+ */ function get() {
19242
+ return this._shaderData;
19243
+ }
19244
+ },
19098
19245
  {
19099
19246
  key: "nearClipPlane",
19100
19247
  get: /**
@@ -21504,6 +21651,7 @@ var TiledType;
21504
21651
  sprite._addReferCount(-1);
21505
21652
  sprite._updateFlagManager.removeListener(this._onSpriteChange);
21506
21653
  }
21654
+ this._entity = null;
21507
21655
  this._color = null;
21508
21656
  this._sprite = null;
21509
21657
  this._assembler = null;
@@ -23806,9 +23954,14 @@ exports.AnimatorLayerBlendingMode = void 0;
23806
23954
 
23807
23955
  /**
23808
23956
  * @internal
23809
- */ var AnimationEventHandler = function AnimationEventHandler() {
23810
- this.handlers = [];
23811
- };
23957
+ */ var AnimationEventHandler = /*#__PURE__*/ function() {
23958
+ function AnimationEventHandler() {
23959
+ this.handlers = [];
23960
+ }
23961
+ var _proto = AnimationEventHandler.prototype;
23962
+ _proto.dispose = function dispose() {};
23963
+ return AnimationEventHandler;
23964
+ }();
23812
23965
 
23813
23966
  /**
23814
23967
  * Transitions define when and how the state machine switch from on state to another. AnimatorTransition always originate from a StateMachine or a StateMachine entry.