@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.
package/dist/module.js CHANGED
@@ -2238,6 +2238,28 @@ var /** @internal */ PromiseState;
2238
2238
  * @remarks The release principle is that it is not referenced by the components, including direct and indirect reference.
2239
2239
  */ _proto.gc = function gc() {
2240
2240
  this._gc(false);
2241
+ var engine = this.engine;
2242
+ engine._renderElementPool.garbageCollection();
2243
+ engine._spriteElementPool.garbageCollection();
2244
+ engine._spriteMaskElementPool.garbageCollection();
2245
+ engine._textElementPool.garbageCollection();
2246
+ var _componentsManager = engine._componentsManager, _lightManager = engine._lightManager;
2247
+ _componentsManager._renderers.garbageCollection();
2248
+ // @ts-ignore
2249
+ _componentsManager._onStartScripts.garbageCollection();
2250
+ // @ts-ignore
2251
+ _componentsManager._onUpdateScripts.garbageCollection();
2252
+ // @ts-ignore
2253
+ _componentsManager._onLateUpdateScripts.garbageCollection();
2254
+ // @ts-ignore
2255
+ _componentsManager._onPhysicsUpdateScripts.garbageCollection();
2256
+ // @ts-ignore
2257
+ _componentsManager._onUpdateAnimations.garbageCollection();
2258
+ // @ts-ignore
2259
+ _componentsManager._onUpdateRenderers.garbageCollection();
2260
+ _lightManager._spotLights.garbageCollection();
2261
+ _lightManager._pointLights.garbageCollection();
2262
+ _lightManager._directLights.garbageCollection();
2241
2263
  };
2242
2264
  /**
2243
2265
  * @internal
@@ -4080,6 +4102,11 @@ var TransformModifyFlags;
4080
4102
  * @returns Cloned entity
4081
4103
  */ _proto.clone = function clone() {
4082
4104
  var cloneEntity = new Entity(this._engine, this.name);
4105
+ var _this = this, hookResource = _this._hookResource;
4106
+ if (hookResource) {
4107
+ cloneEntity._hookResource = hookResource;
4108
+ hookResource._addRefCount(1);
4109
+ }
4083
4110
  cloneEntity._isActive = this._isActive;
4084
4111
  cloneEntity.transform.localMatrix = this.transform.localMatrix;
4085
4112
  var children = this._children;
@@ -4104,6 +4131,10 @@ var TransformModifyFlags;
4104
4131
  return;
4105
4132
  }
4106
4133
  EngineObject.prototype.destroy.call(this);
4134
+ if (this._hookResource) {
4135
+ this._hookResource._addRefCount(-1);
4136
+ this._hookResource = null;
4137
+ }
4107
4138
  var components = this._components;
4108
4139
  for(var i = components.length - 1; i >= 0; i--){
4109
4140
  components[i].destroy();
@@ -9780,9 +9811,9 @@ __decorate([
9780
9811
  function Material(engine, shader) {
9781
9812
  var _this;
9782
9813
  _this = RefObject.call(this, engine) || this;
9783
- /** Shader data. */ _this.shaderData = new ShaderData(ShaderDataGroup.Material);
9784
9814
  /** @internal */ _this._renderStates = [] // todo: later will as a part of shaderData when shader effect frame is OK, that is more powerful and flexible.
9785
9815
  ;
9816
+ _this._shaderData = new ShaderData(ShaderDataGroup.Material);
9786
9817
  _this.shader = shader;
9787
9818
  return _this;
9788
9819
  }
@@ -9814,8 +9845,21 @@ __decorate([
9814
9845
  */ _proto._preRender = function _preRender(renderElement) {};
9815
9846
  /**
9816
9847
  * @override
9817
- */ _proto._onDestroy = function _onDestroy() {};
9848
+ */ _proto._onDestroy = function _onDestroy() {
9849
+ this._shader = null;
9850
+ this._shaderData = null;
9851
+ this._renderStates.length = 0;
9852
+ this._renderStates = null;
9853
+ };
9818
9854
  _create_class(Material, [
9855
+ {
9856
+ key: "shaderData",
9857
+ get: /**
9858
+ * Shader data.
9859
+ */ function get() {
9860
+ return this._shaderData;
9861
+ }
9862
+ },
9819
9863
  {
9820
9864
  key: "shader",
9821
9865
  get: /**
@@ -9884,6 +9928,12 @@ __decorate([
9884
9928
  */ _proto.resetPool = function resetPool() {
9885
9929
  this._elementPoolIndex = 0;
9886
9930
  };
9931
+ _proto.garbageCollection = function garbageCollection() {
9932
+ var _this = this, pool = _this._elementPool;
9933
+ for(var i = pool.length - 1; i >= 0; i--){
9934
+ pool[i].dispose && pool[i].dispose();
9935
+ }
9936
+ };
9887
9937
  return ClassPool;
9888
9938
  }();
9889
9939
 
@@ -9906,6 +9956,9 @@ var RenderElement = function RenderElement() {
9906
9956
  this.renderState = renderState;
9907
9957
  this.shaderPass = shaderPass;
9908
9958
  };
9959
+ _proto.dispose = function dispose() {
9960
+ this.component = this.mesh = this.subMesh = this.material = this.renderState = this.shaderPass = null;
9961
+ };
9909
9962
  return MeshRenderElement;
9910
9963
  }(RenderElement);
9911
9964
 
@@ -9951,6 +10004,9 @@ var SpriteElement = /*#__PURE__*/ function(RenderElement) {
9951
10004
  this.renderState = renderState;
9952
10005
  this.shaderPass = shaderPass;
9953
10006
  };
10007
+ _proto.dispose = function dispose() {
10008
+ this.component = this.renderData = this.material = this.texture = this.renderState = this.shaderPass = null;
10009
+ };
9954
10010
  return SpriteElement;
9955
10011
  }(RenderElement);
9956
10012
 
@@ -9969,6 +10025,9 @@ var SpriteMaskElement = /*#__PURE__*/ function(RenderElement) {
9969
10025
  this.renderData = renderData;
9970
10026
  this.material = material;
9971
10027
  };
10028
+ _proto.dispose = function dispose() {
10029
+ this.component = this.renderData = this.material = null;
10030
+ };
9972
10031
  return SpriteMaskElement;
9973
10032
  }(RenderElement);
9974
10033
 
@@ -9987,7 +10046,6 @@ var Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
9987
10046
  function Renderer1(entity) {
9988
10047
  var _this;
9989
10048
  _this = Component.call(this, entity) || this;
9990
- /** ShaderData related to renderer. */ _this.shaderData = new ShaderData(ShaderDataGroup.Renderer);
9991
10049
  /** @internal */ _this._onUpdateIndex = -1;
9992
10050
  /** @internal */ _this._rendererIndex = -1;
9993
10051
  /** @internal */ _this._globalShaderMacro = new ShaderMacroCollection();
@@ -9995,6 +10053,7 @@ var Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
9995
10053
  _this._overrideUpdate = false;
9996
10054
  _this._materials = [];
9997
10055
  _this._dirtyUpdateFlag = 0;
10056
+ _this._shaderData = new ShaderData(ShaderDataGroup.Renderer);
9998
10057
  _this._mvMatrix = new Matrix();
9999
10058
  _this._mvpMatrix = new Matrix();
10000
10059
  _this._mvInvMatrix = new Matrix();
@@ -10141,6 +10200,17 @@ var Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
10141
10200
  var _materials_i;
10142
10201
  (_materials_i = materials[i]) == null ? void 0 : _materials_i._addRefCount(-1);
10143
10202
  }
10203
+ this._entity = null;
10204
+ this._globalShaderMacro = null;
10205
+ this._bounds = null;
10206
+ this._materials = null;
10207
+ this._shaderData = null;
10208
+ this._mvMatrix = null;
10209
+ this._mvpMatrix = null;
10210
+ this._mvInvMatrix = null;
10211
+ this._normalMatrix = null;
10212
+ this._materialsInstanced = null;
10213
+ this._rendererLayer = null;
10144
10214
  };
10145
10215
  _proto._updateShaderData = function _updateShaderData(context) {
10146
10216
  var entity = this.entity;
@@ -10202,6 +10272,14 @@ var Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
10202
10272
  this._dirtyUpdateFlag |= 0x1;
10203
10273
  };
10204
10274
  _create_class(Renderer1, [
10275
+ {
10276
+ key: "shaderData",
10277
+ get: /**
10278
+ * ShaderData related to renderer.
10279
+ */ function get() {
10280
+ return this._shaderData;
10281
+ }
10282
+ },
10205
10283
  {
10206
10284
  key: "isCulled",
10207
10285
  get: /**
@@ -10286,9 +10364,6 @@ var Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
10286
10364
  }(), function() {
10287
10365
  _Renderer._rendererLayerProperty = Shader.getPropertyByName("oasis_RendererLayer");
10288
10366
  }(), _Renderer);
10289
- __decorate([
10290
- deepClone
10291
- ], Renderer.prototype, "shaderData", void 0);
10292
10367
  __decorate([
10293
10368
  ignoreClone
10294
10369
  ], Renderer.prototype, "_distanceForSort", void 0);
@@ -10316,6 +10391,9 @@ __decorate([
10316
10391
  __decorate([
10317
10392
  ignoreClone
10318
10393
  ], Renderer.prototype, "_dirtyUpdateFlag", void 0);
10394
+ __decorate([
10395
+ deepClone
10396
+ ], Renderer.prototype, "_shaderData", void 0);
10319
10397
  __decorate([
10320
10398
  ignoreClone
10321
10399
  ], Renderer.prototype, "_mvMatrix", void 0);
@@ -10570,6 +10648,7 @@ SimpleSpriteAssembler = __decorate([
10570
10648
  sprite._addRefCount(-1);
10571
10649
  sprite._updateFlagManager.removeListener(this._onSpriteChange);
10572
10650
  }
10651
+ this._entity = null;
10573
10652
  this._sprite = null;
10574
10653
  this._renderData = null;
10575
10654
  };
@@ -11175,14 +11254,19 @@ var BufferUtil = /*#__PURE__*/ function() {
11175
11254
 
11176
11255
  /**
11177
11256
  * Sub-mesh, mainly contains drawing information.
11178
- */ var SubMesh = function SubMesh(start, count, topology) {
11179
- if (start === void 0) start = 0;
11180
- if (count === void 0) count = 0;
11181
- if (topology === void 0) topology = MeshTopology.Triangles;
11182
- this.start = start;
11183
- this.count = count;
11184
- this.topology = topology;
11185
- };
11257
+ */ var SubMesh = /*#__PURE__*/ function() {
11258
+ function SubMesh(start, count, topology) {
11259
+ if (start === void 0) start = 0;
11260
+ if (count === void 0) count = 0;
11261
+ if (topology === void 0) topology = MeshTopology.Triangles;
11262
+ this.start = start;
11263
+ this.count = count;
11264
+ this.topology = topology;
11265
+ }
11266
+ var _proto = SubMesh.prototype;
11267
+ _proto.dispose = function dispose() {};
11268
+ return SubMesh;
11269
+ }();
11186
11270
 
11187
11271
  /**
11188
11272
  * Mesh.
@@ -11298,6 +11382,7 @@ var BufferUtil = /*#__PURE__*/ function() {
11298
11382
  this._indexBufferBinding = null;
11299
11383
  this._vertexElements = null;
11300
11384
  this._vertexElementMap = null;
11385
+ this._updateFlagManager = null;
11301
11386
  this._platformPrimitive.destroy();
11302
11387
  };
11303
11388
  _proto._setVertexElements = function _setVertexElements(elements) {
@@ -12983,8 +13068,8 @@ var VertexChangedFlags;
12983
13068
  */ _proto._onDestroy = function _onDestroy() {
12984
13069
  Renderer.prototype._onDestroy.call(this);
12985
13070
  var mesh = this._mesh;
12986
- if (mesh && !mesh.destroyed) {
12987
- mesh._addRefCount(-1);
13071
+ if (mesh) {
13072
+ mesh.destroyed || mesh._addRefCount(-1);
12988
13073
  mesh._updateFlagManager.removeListener(this._onMeshChanged);
12989
13074
  this._mesh = null;
12990
13075
  }
@@ -13321,10 +13406,21 @@ var rePropName = RegExp(// Match anything that isn't a dot or bracket.
13321
13406
  * @internal
13322
13407
  * @override
13323
13408
  */ _proto._onDestroy = function _onDestroy() {
13324
- var _this_rootBone, _this__jointTexture;
13409
+ var _this__rootBone, _this__jointTexture;
13325
13410
  MeshRenderer.prototype._onDestroy.call(this);
13326
- (_this_rootBone = this.rootBone) == null ? void 0 : _this_rootBone.transform._updateFlagManager.removeListener(this._onTransformChanged);
13411
+ (_this__rootBone = this._rootBone) == null ? void 0 : _this__rootBone.transform._updateFlagManager.removeListener(this._onTransformChanged);
13412
+ this._rootBone = null;
13413
+ this._jointDataCreateCache = null;
13414
+ this._skin = null;
13415
+ this._blendShapeWeights = null;
13416
+ this._localBounds = null;
13417
+ this._jointMatrices = null;
13327
13418
  (_this__jointTexture = this._jointTexture) == null ? void 0 : _this__jointTexture.destroy();
13419
+ this._jointTexture = null;
13420
+ if (this._jointEntities) {
13421
+ this._jointEntities.length = 0;
13422
+ this._jointEntities = null;
13423
+ }
13328
13424
  };
13329
13425
  /**
13330
13426
  * @internal
@@ -14712,6 +14808,11 @@ var TextRenderElement = /*#__PURE__*/ function(RenderElement) {
14712
14808
  _this.multiRenderData = true;
14713
14809
  return _this;
14714
14810
  }
14811
+ var _proto = TextRenderElement.prototype;
14812
+ _proto.dispose = function dispose() {
14813
+ this.component = this.material = this.renderState = this.shaderPass = null;
14814
+ this.charElements.length = 0;
14815
+ };
14715
14816
  return TextRenderElement;
14716
14817
  }(RenderElement);
14717
14818
 
@@ -14859,7 +14960,6 @@ var TextRenderElement = /*#__PURE__*/ function(RenderElement) {
14859
14960
  this.texture = null;
14860
14961
  this.solidColor = null;
14861
14962
  this.sky.destroy();
14862
- this._engine = null;
14863
14963
  };
14864
14964
  /**
14865
14965
  * @internal
@@ -15244,8 +15344,6 @@ var TextRenderElement = /*#__PURE__*/ function(RenderElement) {
15244
15344
  function Scene(engine, name) {
15245
15345
  var _this;
15246
15346
  _this = EngineObject.call(this, engine) || this;
15247
- /** The background of the scene. */ _this.background = new Background(_this._engine);
15248
- /** Scene-related shader data. */ _this.shaderData = new ShaderData(ShaderDataGroup.Scene);
15249
15347
  /** If cast shadows. */ _this.castShadows = true;
15250
15348
  /** The resolution of the shadow maps. */ _this.shadowResolution = ShadowResolution.Medium;
15251
15349
  /** The splits of two cascade distribution. */ _this.shadowTwoCascadeSplits = 1.0 / 3.0;
@@ -15255,6 +15353,8 @@ var TextRenderElement = /*#__PURE__*/ function(RenderElement) {
15255
15353
  /** @internal */ _this._isActiveInEngine = false;
15256
15354
  /** @internal */ _this._globalShaderMacro = new ShaderMacroCollection();
15257
15355
  /** @internal */ _this._rootEntities = [];
15356
+ _this._background = new Background(_this._engine);
15357
+ _this._shaderData = new ShaderData(ShaderDataGroup.Scene);
15258
15358
  _this._shadowCascades = ShadowCascadesMode.NoCascades;
15259
15359
  _this._fogMode = FogMode.None;
15260
15360
  _this._fogColor = new Color$1(0.5, 0.5, 0.5, 1.0);
@@ -15416,6 +15516,8 @@ var TextRenderElement = /*#__PURE__*/ function(RenderElement) {
15416
15516
  var sunLightIndex = lightManager._getSunLightIndex();
15417
15517
  if (sunLightIndex !== -1) {
15418
15518
  this._sunLight = lightManager._directLights.get(sunLightIndex);
15519
+ } else {
15520
+ this._sunLight = null;
15419
15521
  }
15420
15522
  if (this.castShadows && this._sunLight && this._sunLight.shadowType !== ShadowType.None) {
15421
15523
  shaderData.enableMacro("SHADOW_TYPE", this._sunLight.shadowType.toString());
@@ -15475,6 +15577,22 @@ var TextRenderElement = /*#__PURE__*/ function(RenderElement) {
15475
15577
  this._fogParams.w = density / Math.sqrt(Math.LN2);
15476
15578
  };
15477
15579
  _create_class(Scene, [
15580
+ {
15581
+ key: "shaderData",
15582
+ get: /**
15583
+ * Scene-related shader data.
15584
+ */ function get() {
15585
+ return this._shaderData;
15586
+ }
15587
+ },
15588
+ {
15589
+ key: "background",
15590
+ get: /**
15591
+ * The background of the scene.
15592
+ */ function get() {
15593
+ return this._background;
15594
+ }
15595
+ },
15478
15596
  {
15479
15597
  key: "shadowCascades",
15480
15598
  get: /**
@@ -17766,7 +17884,6 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component) {
17766
17884
  function Camera1(entity) {
17767
17885
  var _this;
17768
17886
  _this = Component.call(this, entity) || this;
17769
- /** Shader data. */ _this.shaderData = new ShaderData(ShaderDataGroup.Camera);
17770
17887
  /** Rendering priority - A Camera with higher priority will be rendered on top of a camera with lower priority. */ _this.priority = 0;
17771
17888
  /** Whether to enable frustum culling, it is enabled by default. */ _this.enableFrustumCulling = true;
17772
17889
  /**
@@ -17780,6 +17897,7 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component) {
17780
17897
  /** @internal */ _this._globalShaderMacro = new ShaderMacroCollection();
17781
17898
  /** @internal */ _this._frustum = new BoundingFrustum();
17782
17899
  /** @internal */ _this._virtualCamera = new VirtualCamera();
17900
+ _this._shaderData = new ShaderData(ShaderDataGroup.Camera);
17783
17901
  _this._isProjMatSetting = false;
17784
17902
  _this._nearClipPlane = 0.1;
17785
17903
  _this._farClipPlane = 100;
@@ -17978,6 +18096,20 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component) {
17978
18096
  this._isInvViewProjDirty.destroy();
17979
18097
  this._isViewMatrixDirty.destroy();
17980
18098
  this.shaderData._addRefCount(-1);
18099
+ this._entity = null;
18100
+ this._globalShaderMacro = null;
18101
+ this._frustum = null;
18102
+ this._renderPipeline = null;
18103
+ this._virtualCamera = null;
18104
+ this._shaderData = null;
18105
+ this._frustumViewChangeFlag = null;
18106
+ this._transform = null;
18107
+ this._isViewMatrixDirty = null;
18108
+ this._isInvViewProjDirty = null;
18109
+ this._viewport = null;
18110
+ this._inverseProjectionMatrix = null;
18111
+ this._lastAspectSize = null;
18112
+ this._invViewProjMat = null;
17981
18113
  };
17982
18114
  _proto._projMatChange = function _projMatChange() {
17983
18115
  this._isFrustumProjectDirty = true;
@@ -18017,6 +18149,14 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component) {
18017
18149
  return this._inverseProjectionMatrix;
18018
18150
  };
18019
18151
  _create_class(Camera1, [
18152
+ {
18153
+ key: "shaderData",
18154
+ get: /**
18155
+ * Shader data.
18156
+ */ function get() {
18157
+ return this._shaderData;
18158
+ }
18159
+ },
18020
18160
  {
18021
18161
  key: "nearClipPlane",
18022
18162
  get: /**
@@ -20085,6 +20225,7 @@ SlicedSpriteAssembler = __decorate([
20085
20225
  sprite._addRefCount(-1);
20086
20226
  sprite._updateFlagManager.removeListener(this._onSpriteChange);
20087
20227
  }
20228
+ this._entity = null;
20088
20229
  this._color = null;
20089
20230
  this._sprite = null;
20090
20231
  this._assembler = null;
@@ -22631,9 +22772,16 @@ var AnimatorLayerBlendingMode;
22631
22772
 
22632
22773
  /**
22633
22774
  * @internal
22634
- */ var AnimationEventHandler = function AnimationEventHandler() {
22635
- this.handlers = [];
22636
- };
22775
+ */ var AnimationEventHandler = /*#__PURE__*/ function() {
22776
+ function AnimationEventHandler() {
22777
+ this.handlers = [];
22778
+ }
22779
+ var _proto = AnimationEventHandler.prototype;
22780
+ _proto.dispose = function dispose() {
22781
+ this.handlers.length = 0;
22782
+ };
22783
+ return AnimationEventHandler;
22784
+ }();
22637
22785
 
22638
22786
  /**
22639
22787
  * Transitions define when and how the state machine switch from on state to another. AnimatorTransition always originate from a StateMachine or a StateMachine entry.