@galacean/engine-core 0.9.12 → 0.9.13

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.
@@ -2243,6 +2243,28 @@ var /** @internal */ PromiseState;
2243
2243
  * @remarks The release principle is that it is not referenced by the components, including direct and indirect reference.
2244
2244
  */ _proto.gc = function gc() {
2245
2245
  this._gc(false);
2246
+ var engine = this.engine;
2247
+ engine._renderElementPool.garbageCollection();
2248
+ engine._spriteElementPool.garbageCollection();
2249
+ engine._spriteMaskElementPool.garbageCollection();
2250
+ engine._textElementPool.garbageCollection();
2251
+ var _componentsManager = engine._componentsManager, _lightManager = engine._lightManager;
2252
+ _componentsManager._renderers.garbageCollection();
2253
+ // @ts-ignore
2254
+ _componentsManager._onStartScripts.garbageCollection();
2255
+ // @ts-ignore
2256
+ _componentsManager._onUpdateScripts.garbageCollection();
2257
+ // @ts-ignore
2258
+ _componentsManager._onLateUpdateScripts.garbageCollection();
2259
+ // @ts-ignore
2260
+ _componentsManager._onPhysicsUpdateScripts.garbageCollection();
2261
+ // @ts-ignore
2262
+ _componentsManager._onUpdateAnimations.garbageCollection();
2263
+ // @ts-ignore
2264
+ _componentsManager._onUpdateRenderers.garbageCollection();
2265
+ _lightManager._spotLights.garbageCollection();
2266
+ _lightManager._pointLights.garbageCollection();
2267
+ _lightManager._directLights.garbageCollection();
2246
2268
  };
2247
2269
  /**
2248
2270
  * @internal
@@ -4085,6 +4107,11 @@ var TransformModifyFlags;
4085
4107
  * @returns Cloned entity
4086
4108
  */ _proto.clone = function clone() {
4087
4109
  var cloneEntity = new Entity(this._engine, this.name);
4110
+ var _this = this, hookResource = _this._hookResource;
4111
+ if (hookResource) {
4112
+ cloneEntity._hookResource = hookResource;
4113
+ hookResource._addRefCount(1);
4114
+ }
4088
4115
  cloneEntity._isActive = this._isActive;
4089
4116
  cloneEntity.transform.localMatrix = this.transform.localMatrix;
4090
4117
  var children = this._children;
@@ -4109,6 +4136,10 @@ var TransformModifyFlags;
4109
4136
  return;
4110
4137
  }
4111
4138
  EngineObject.prototype.destroy.call(this);
4139
+ if (this._hookResource) {
4140
+ this._hookResource._addRefCount(-1);
4141
+ this._hookResource = null;
4142
+ }
4112
4143
  var components = this._components;
4113
4144
  for(var i = components.length - 1; i >= 0; i--){
4114
4145
  components[i].destroy();
@@ -9785,9 +9816,9 @@ __decorate([
9785
9816
  function Material(engine, shader) {
9786
9817
  var _this;
9787
9818
  _this = RefObject.call(this, engine) || this;
9788
- /** Shader data. */ _this.shaderData = new ShaderData(ShaderDataGroup.Material);
9789
9819
  /** @internal */ _this._renderStates = [] // todo: later will as a part of shaderData when shader effect frame is OK, that is more powerful and flexible.
9790
9820
  ;
9821
+ _this._shaderData = new ShaderData(ShaderDataGroup.Material);
9791
9822
  _this.shader = shader;
9792
9823
  return _this;
9793
9824
  }
@@ -9819,8 +9850,21 @@ __decorate([
9819
9850
  */ _proto._preRender = function _preRender(renderElement) {};
9820
9851
  /**
9821
9852
  * @override
9822
- */ _proto._onDestroy = function _onDestroy() {};
9853
+ */ _proto._onDestroy = function _onDestroy() {
9854
+ this._shader = null;
9855
+ this._shaderData = null;
9856
+ this._renderStates.length = 0;
9857
+ this._renderStates = null;
9858
+ };
9823
9859
  _create_class(Material, [
9860
+ {
9861
+ key: "shaderData",
9862
+ get: /**
9863
+ * Shader data.
9864
+ */ function get() {
9865
+ return this._shaderData;
9866
+ }
9867
+ },
9824
9868
  {
9825
9869
  key: "shader",
9826
9870
  get: /**
@@ -9889,6 +9933,12 @@ __decorate([
9889
9933
  */ _proto.resetPool = function resetPool() {
9890
9934
  this._elementPoolIndex = 0;
9891
9935
  };
9936
+ _proto.garbageCollection = function garbageCollection() {
9937
+ var _this = this, pool = _this._elementPool;
9938
+ for(var i = pool.length - 1; i >= 0; i--){
9939
+ pool[i].dispose && pool[i].dispose();
9940
+ }
9941
+ };
9892
9942
  return ClassPool;
9893
9943
  }();
9894
9944
 
@@ -9911,6 +9961,9 @@ var RenderElement = function RenderElement() {
9911
9961
  this.renderState = renderState;
9912
9962
  this.shaderPass = shaderPass;
9913
9963
  };
9964
+ _proto.dispose = function dispose() {
9965
+ this.component = this.mesh = this.subMesh = this.material = this.renderState = this.shaderPass = null;
9966
+ };
9914
9967
  return MeshRenderElement;
9915
9968
  }(RenderElement);
9916
9969
 
@@ -9956,6 +10009,9 @@ var SpriteElement = /*#__PURE__*/ function(RenderElement) {
9956
10009
  this.renderState = renderState;
9957
10010
  this.shaderPass = shaderPass;
9958
10011
  };
10012
+ _proto.dispose = function dispose() {
10013
+ this.component = this.renderData = this.material = this.texture = this.renderState = this.shaderPass = null;
10014
+ };
9959
10015
  return SpriteElement;
9960
10016
  }(RenderElement);
9961
10017
 
@@ -9974,6 +10030,9 @@ var SpriteMaskElement = /*#__PURE__*/ function(RenderElement) {
9974
10030
  this.renderData = renderData;
9975
10031
  this.material = material;
9976
10032
  };
10033
+ _proto.dispose = function dispose() {
10034
+ this.component = this.renderData = this.material = null;
10035
+ };
9977
10036
  return SpriteMaskElement;
9978
10037
  }(RenderElement);
9979
10038
 
@@ -9992,7 +10051,6 @@ exports.Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
9992
10051
  function Renderer1(entity) {
9993
10052
  var _this;
9994
10053
  _this = Component.call(this, entity) || this;
9995
- /** ShaderData related to renderer. */ _this.shaderData = new ShaderData(ShaderDataGroup.Renderer);
9996
10054
  /** @internal */ _this._onUpdateIndex = -1;
9997
10055
  /** @internal */ _this._rendererIndex = -1;
9998
10056
  /** @internal */ _this._globalShaderMacro = new ShaderMacroCollection();
@@ -10000,6 +10058,7 @@ exports.Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
10000
10058
  _this._overrideUpdate = false;
10001
10059
  _this._materials = [];
10002
10060
  _this._dirtyUpdateFlag = 0;
10061
+ _this._shaderData = new ShaderData(ShaderDataGroup.Renderer);
10003
10062
  _this._mvMatrix = new miniprogram.Matrix();
10004
10063
  _this._mvpMatrix = new miniprogram.Matrix();
10005
10064
  _this._mvInvMatrix = new miniprogram.Matrix();
@@ -10146,6 +10205,17 @@ exports.Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
10146
10205
  var _materials_i;
10147
10206
  (_materials_i = materials[i]) == null ? void 0 : _materials_i._addRefCount(-1);
10148
10207
  }
10208
+ this._entity = null;
10209
+ this._globalShaderMacro = null;
10210
+ this._bounds = null;
10211
+ this._materials = null;
10212
+ this._shaderData = null;
10213
+ this._mvMatrix = null;
10214
+ this._mvpMatrix = null;
10215
+ this._mvInvMatrix = null;
10216
+ this._normalMatrix = null;
10217
+ this._materialsInstanced = null;
10218
+ this._rendererLayer = null;
10149
10219
  };
10150
10220
  _proto._updateShaderData = function _updateShaderData(context) {
10151
10221
  var entity = this.entity;
@@ -10207,6 +10277,14 @@ exports.Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
10207
10277
  this._dirtyUpdateFlag |= 0x1;
10208
10278
  };
10209
10279
  _create_class(Renderer1, [
10280
+ {
10281
+ key: "shaderData",
10282
+ get: /**
10283
+ * ShaderData related to renderer.
10284
+ */ function get() {
10285
+ return this._shaderData;
10286
+ }
10287
+ },
10210
10288
  {
10211
10289
  key: "isCulled",
10212
10290
  get: /**
@@ -10291,9 +10369,6 @@ exports.Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
10291
10369
  }(), function() {
10292
10370
  _Renderer._rendererLayerProperty = Shader.getPropertyByName("oasis_RendererLayer");
10293
10371
  }(), _Renderer);
10294
- __decorate([
10295
- deepClone
10296
- ], exports.Renderer.prototype, "shaderData", void 0);
10297
10372
  __decorate([
10298
10373
  ignoreClone
10299
10374
  ], exports.Renderer.prototype, "_distanceForSort", void 0);
@@ -10321,6 +10396,9 @@ __decorate([
10321
10396
  __decorate([
10322
10397
  ignoreClone
10323
10398
  ], exports.Renderer.prototype, "_dirtyUpdateFlag", void 0);
10399
+ __decorate([
10400
+ deepClone
10401
+ ], exports.Renderer.prototype, "_shaderData", void 0);
10324
10402
  __decorate([
10325
10403
  ignoreClone
10326
10404
  ], exports.Renderer.prototype, "_mvMatrix", void 0);
@@ -10575,6 +10653,7 @@ SimpleSpriteAssembler = __decorate([
10575
10653
  sprite._addRefCount(-1);
10576
10654
  sprite._updateFlagManager.removeListener(this._onSpriteChange);
10577
10655
  }
10656
+ this._entity = null;
10578
10657
  this._sprite = null;
10579
10658
  this._renderData = null;
10580
10659
  };
@@ -11180,14 +11259,19 @@ var BufferUtil = /*#__PURE__*/ function() {
11180
11259
 
11181
11260
  /**
11182
11261
  * Sub-mesh, mainly contains drawing information.
11183
- */ var SubMesh = function SubMesh(start, count, topology) {
11184
- if (start === void 0) start = 0;
11185
- if (count === void 0) count = 0;
11186
- if (topology === void 0) topology = exports.MeshTopology.Triangles;
11187
- this.start = start;
11188
- this.count = count;
11189
- this.topology = topology;
11190
- };
11262
+ */ var SubMesh = /*#__PURE__*/ function() {
11263
+ function SubMesh(start, count, topology) {
11264
+ if (start === void 0) start = 0;
11265
+ if (count === void 0) count = 0;
11266
+ if (topology === void 0) topology = exports.MeshTopology.Triangles;
11267
+ this.start = start;
11268
+ this.count = count;
11269
+ this.topology = topology;
11270
+ }
11271
+ var _proto = SubMesh.prototype;
11272
+ _proto.dispose = function dispose() {};
11273
+ return SubMesh;
11274
+ }();
11191
11275
 
11192
11276
  /**
11193
11277
  * Mesh.
@@ -11303,6 +11387,7 @@ var BufferUtil = /*#__PURE__*/ function() {
11303
11387
  this._indexBufferBinding = null;
11304
11388
  this._vertexElements = null;
11305
11389
  this._vertexElementMap = null;
11390
+ this._updateFlagManager = null;
11306
11391
  this._platformPrimitive.destroy();
11307
11392
  };
11308
11393
  _proto._setVertexElements = function _setVertexElements(elements) {
@@ -12988,8 +13073,8 @@ var VertexChangedFlags;
12988
13073
  */ _proto._onDestroy = function _onDestroy() {
12989
13074
  Renderer.prototype._onDestroy.call(this);
12990
13075
  var mesh = this._mesh;
12991
- if (mesh && !mesh.destroyed) {
12992
- mesh._addRefCount(-1);
13076
+ if (mesh) {
13077
+ mesh.destroyed || mesh._addRefCount(-1);
12993
13078
  mesh._updateFlagManager.removeListener(this._onMeshChanged);
12994
13079
  this._mesh = null;
12995
13080
  }
@@ -13326,10 +13411,21 @@ var rePropName = RegExp(// Match anything that isn't a dot or bracket.
13326
13411
  * @internal
13327
13412
  * @override
13328
13413
  */ _proto._onDestroy = function _onDestroy() {
13329
- var _this_rootBone, _this__jointTexture;
13414
+ var _this__rootBone, _this__jointTexture;
13330
13415
  MeshRenderer.prototype._onDestroy.call(this);
13331
- (_this_rootBone = this.rootBone) == null ? void 0 : _this_rootBone.transform._updateFlagManager.removeListener(this._onTransformChanged);
13416
+ (_this__rootBone = this._rootBone) == null ? void 0 : _this__rootBone.transform._updateFlagManager.removeListener(this._onTransformChanged);
13417
+ this._rootBone = null;
13418
+ this._jointDataCreateCache = null;
13419
+ this._skin = null;
13420
+ this._blendShapeWeights = null;
13421
+ this._localBounds = null;
13422
+ this._jointMatrices = null;
13332
13423
  (_this__jointTexture = this._jointTexture) == null ? void 0 : _this__jointTexture.destroy();
13424
+ this._jointTexture = null;
13425
+ if (this._jointEntities) {
13426
+ this._jointEntities.length = 0;
13427
+ this._jointEntities = null;
13428
+ }
13333
13429
  };
13334
13430
  /**
13335
13431
  * @internal
@@ -14717,6 +14813,11 @@ var TextRenderElement = /*#__PURE__*/ function(RenderElement) {
14717
14813
  _this.multiRenderData = true;
14718
14814
  return _this;
14719
14815
  }
14816
+ var _proto = TextRenderElement.prototype;
14817
+ _proto.dispose = function dispose() {
14818
+ this.component = this.material = this.renderState = this.shaderPass = null;
14819
+ this.charElements.length = 0;
14820
+ };
14720
14821
  return TextRenderElement;
14721
14822
  }(RenderElement);
14722
14823
 
@@ -14864,7 +14965,6 @@ var TextRenderElement = /*#__PURE__*/ function(RenderElement) {
14864
14965
  this.texture = null;
14865
14966
  this.solidColor = null;
14866
14967
  this.sky.destroy();
14867
- this._engine = null;
14868
14968
  };
14869
14969
  /**
14870
14970
  * @internal
@@ -15249,8 +15349,6 @@ var TextRenderElement = /*#__PURE__*/ function(RenderElement) {
15249
15349
  function Scene(engine, name) {
15250
15350
  var _this;
15251
15351
  _this = EngineObject.call(this, engine) || this;
15252
- /** The background of the scene. */ _this.background = new Background(_this._engine);
15253
- /** Scene-related shader data. */ _this.shaderData = new ShaderData(ShaderDataGroup.Scene);
15254
15352
  /** If cast shadows. */ _this.castShadows = true;
15255
15353
  /** The resolution of the shadow maps. */ _this.shadowResolution = exports.ShadowResolution.Medium;
15256
15354
  /** The splits of two cascade distribution. */ _this.shadowTwoCascadeSplits = 1.0 / 3.0;
@@ -15260,6 +15358,8 @@ var TextRenderElement = /*#__PURE__*/ function(RenderElement) {
15260
15358
  /** @internal */ _this._isActiveInEngine = false;
15261
15359
  /** @internal */ _this._globalShaderMacro = new ShaderMacroCollection();
15262
15360
  /** @internal */ _this._rootEntities = [];
15361
+ _this._background = new Background(_this._engine);
15362
+ _this._shaderData = new ShaderData(ShaderDataGroup.Scene);
15263
15363
  _this._shadowCascades = exports.ShadowCascadesMode.NoCascades;
15264
15364
  _this._fogMode = exports.FogMode.None;
15265
15365
  _this._fogColor = new miniprogram.Color(0.5, 0.5, 0.5, 1.0);
@@ -15421,6 +15521,8 @@ var TextRenderElement = /*#__PURE__*/ function(RenderElement) {
15421
15521
  var sunLightIndex = lightManager._getSunLightIndex();
15422
15522
  if (sunLightIndex !== -1) {
15423
15523
  this._sunLight = lightManager._directLights.get(sunLightIndex);
15524
+ } else {
15525
+ this._sunLight = null;
15424
15526
  }
15425
15527
  if (this.castShadows && this._sunLight && this._sunLight.shadowType !== exports.ShadowType.None) {
15426
15528
  shaderData.enableMacro("SHADOW_TYPE", this._sunLight.shadowType.toString());
@@ -15480,6 +15582,22 @@ var TextRenderElement = /*#__PURE__*/ function(RenderElement) {
15480
15582
  this._fogParams.w = density / Math.sqrt(Math.LN2);
15481
15583
  };
15482
15584
  _create_class(Scene, [
15585
+ {
15586
+ key: "shaderData",
15587
+ get: /**
15588
+ * Scene-related shader data.
15589
+ */ function get() {
15590
+ return this._shaderData;
15591
+ }
15592
+ },
15593
+ {
15594
+ key: "background",
15595
+ get: /**
15596
+ * The background of the scene.
15597
+ */ function get() {
15598
+ return this._background;
15599
+ }
15600
+ },
15483
15601
  {
15484
15602
  key: "shadowCascades",
15485
15603
  get: /**
@@ -17771,7 +17889,6 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component) {
17771
17889
  function Camera1(entity) {
17772
17890
  var _this;
17773
17891
  _this = Component.call(this, entity) || this;
17774
- /** Shader data. */ _this.shaderData = new ShaderData(ShaderDataGroup.Camera);
17775
17892
  /** Rendering priority - A Camera with higher priority will be rendered on top of a camera with lower priority. */ _this.priority = 0;
17776
17893
  /** Whether to enable frustum culling, it is enabled by default. */ _this.enableFrustumCulling = true;
17777
17894
  /**
@@ -17785,6 +17902,7 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component) {
17785
17902
  /** @internal */ _this._globalShaderMacro = new ShaderMacroCollection();
17786
17903
  /** @internal */ _this._frustum = new miniprogram.BoundingFrustum();
17787
17904
  /** @internal */ _this._virtualCamera = new VirtualCamera();
17905
+ _this._shaderData = new ShaderData(ShaderDataGroup.Camera);
17788
17906
  _this._isProjMatSetting = false;
17789
17907
  _this._nearClipPlane = 0.1;
17790
17908
  _this._farClipPlane = 100;
@@ -17983,6 +18101,20 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component) {
17983
18101
  this._isInvViewProjDirty.destroy();
17984
18102
  this._isViewMatrixDirty.destroy();
17985
18103
  this.shaderData._addRefCount(-1);
18104
+ this._entity = null;
18105
+ this._globalShaderMacro = null;
18106
+ this._frustum = null;
18107
+ this._renderPipeline = null;
18108
+ this._virtualCamera = null;
18109
+ this._shaderData = null;
18110
+ this._frustumViewChangeFlag = null;
18111
+ this._transform = null;
18112
+ this._isViewMatrixDirty = null;
18113
+ this._isInvViewProjDirty = null;
18114
+ this._viewport = null;
18115
+ this._inverseProjectionMatrix = null;
18116
+ this._lastAspectSize = null;
18117
+ this._invViewProjMat = null;
17986
18118
  };
17987
18119
  _proto._projMatChange = function _projMatChange() {
17988
18120
  this._isFrustumProjectDirty = true;
@@ -18022,6 +18154,14 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component) {
18022
18154
  return this._inverseProjectionMatrix;
18023
18155
  };
18024
18156
  _create_class(Camera1, [
18157
+ {
18158
+ key: "shaderData",
18159
+ get: /**
18160
+ * Shader data.
18161
+ */ function get() {
18162
+ return this._shaderData;
18163
+ }
18164
+ },
18025
18165
  {
18026
18166
  key: "nearClipPlane",
18027
18167
  get: /**
@@ -20090,6 +20230,7 @@ SlicedSpriteAssembler = __decorate([
20090
20230
  sprite._addRefCount(-1);
20091
20231
  sprite._updateFlagManager.removeListener(this._onSpriteChange);
20092
20232
  }
20233
+ this._entity = null;
20093
20234
  this._color = null;
20094
20235
  this._sprite = null;
20095
20236
  this._assembler = null;
@@ -22636,9 +22777,16 @@ exports.AnimatorLayerBlendingMode = void 0;
22636
22777
 
22637
22778
  /**
22638
22779
  * @internal
22639
- */ var AnimationEventHandler = function AnimationEventHandler() {
22640
- this.handlers = [];
22641
- };
22780
+ */ var AnimationEventHandler = /*#__PURE__*/ function() {
22781
+ function AnimationEventHandler() {
22782
+ this.handlers = [];
22783
+ }
22784
+ var _proto = AnimationEventHandler.prototype;
22785
+ _proto.dispose = function dispose() {
22786
+ this.handlers.length = 0;
22787
+ };
22788
+ return AnimationEventHandler;
22789
+ }();
22642
22790
 
22643
22791
  /**
22644
22792
  * Transitions define when and how the state machine switch from on state to another. AnimatorTransition always originate from a StateMachine or a StateMachine entry.