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