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