@galacean/engine-core 0.0.0-experimental-0.9-plus.7 → 0.0.0-experimental-0.9-plus.8

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
@@ -3521,6 +3521,28 @@ var /** @internal */ PromiseState;
3521
3521
  * @remarks The release principle is that it is not referenced by the components, including direct and indirect reference.
3522
3522
  */ _proto.gc = function gc() {
3523
3523
  this._gc(false);
3524
+ var engine = this.engine;
3525
+ engine._renderElementPool.garbageCollection();
3526
+ engine._spriteElementPool.garbageCollection();
3527
+ engine._spriteMaskElementPool.garbageCollection();
3528
+ engine._textElementPool.garbageCollection();
3529
+ var _componentsManager = engine._componentsManager, _lightManager = engine._lightManager;
3530
+ _componentsManager._renderers.garbageCollection();
3531
+ // @ts-ignore
3532
+ _componentsManager._onStartScripts.garbageCollection();
3533
+ // @ts-ignore
3534
+ _componentsManager._onUpdateScripts.garbageCollection();
3535
+ // @ts-ignore
3536
+ _componentsManager._onLateUpdateScripts.garbageCollection();
3537
+ // @ts-ignore
3538
+ _componentsManager._onPhysicsUpdateScripts.garbageCollection();
3539
+ // @ts-ignore
3540
+ _componentsManager._onUpdateAnimations.garbageCollection();
3541
+ // @ts-ignore
3542
+ _componentsManager._onUpdateRenderers.garbageCollection();
3543
+ _lightManager._spotLights.garbageCollection();
3544
+ _lightManager._pointLights.garbageCollection();
3545
+ _lightManager._directLights.garbageCollection();
3524
3546
  };
3525
3547
  /**
3526
3548
  * @internal
@@ -5363,6 +5385,11 @@ var TransformModifyFlags;
5363
5385
  * @returns Cloned entity
5364
5386
  */ _proto.clone = function clone() {
5365
5387
  var cloneEntity = new Entity(this._engine, this.name);
5388
+ var _this = this, hookResource = _this._hookResource;
5389
+ if (hookResource) {
5390
+ cloneEntity._hookResource = hookResource;
5391
+ hookResource._addRefCount(1);
5392
+ }
5366
5393
  cloneEntity._isActive = this._isActive;
5367
5394
  cloneEntity.transform.localMatrix = this.transform.localMatrix;
5368
5395
  var children = this._children;
@@ -5387,6 +5414,10 @@ var TransformModifyFlags;
5387
5414
  return;
5388
5415
  }
5389
5416
  EngineObject.prototype.destroy.call(this);
5417
+ if (this._hookResource) {
5418
+ this._hookResource._addRefCount(-1);
5419
+ this._hookResource = null;
5420
+ }
5390
5421
  var components = this._components;
5391
5422
  for(var i = components.length - 1; i >= 0; i--){
5392
5423
  components[i].destroy();
@@ -9794,9 +9825,9 @@ __decorate([
9794
9825
  function Material(engine, shader) {
9795
9826
  var _this;
9796
9827
  _this = RefObject.call(this, engine) || this;
9797
- /** Shader data. */ _this.shaderData = new ShaderData(ShaderDataGroup.Material);
9798
9828
  /** @internal */ _this._renderStates = [] // todo: later will as a part of shaderData when shader effect frame is OK, that is more powerful and flexible.
9799
9829
  ;
9830
+ _this._shaderData = new ShaderData(ShaderDataGroup.Material);
9800
9831
  _this.shader = shader;
9801
9832
  return _this;
9802
9833
  }
@@ -9828,8 +9859,21 @@ __decorate([
9828
9859
  */ _proto._preRender = function _preRender(renderElement) {};
9829
9860
  /**
9830
9861
  * @override
9831
- */ _proto._onDestroy = function _onDestroy() {};
9862
+ */ _proto._onDestroy = function _onDestroy() {
9863
+ this._shader = null;
9864
+ this._shaderData = null;
9865
+ this._renderStates.length = 0;
9866
+ this._renderStates = null;
9867
+ };
9832
9868
  _create_class(Material, [
9869
+ {
9870
+ key: "shaderData",
9871
+ get: /**
9872
+ * Shader data.
9873
+ */ function get() {
9874
+ return this._shaderData;
9875
+ }
9876
+ },
9833
9877
  {
9834
9878
  key: "shader",
9835
9879
  get: /**
@@ -9898,6 +9942,12 @@ __decorate([
9898
9942
  */ _proto.resetPool = function resetPool() {
9899
9943
  this._elementPoolIndex = 0;
9900
9944
  };
9945
+ _proto.garbageCollection = function garbageCollection() {
9946
+ var _this = this, pool = _this._elementPool;
9947
+ for(var i = pool.length - 1; i >= 0; i--){
9948
+ pool[i].dispose && pool[i].dispose();
9949
+ }
9950
+ };
9901
9951
  return ClassPool;
9902
9952
  }();
9903
9953
 
@@ -9920,6 +9970,9 @@ var RenderElement = function RenderElement() {
9920
9970
  this.renderState = renderState;
9921
9971
  this.shaderPass = shaderPass;
9922
9972
  };
9973
+ _proto.dispose = function dispose() {
9974
+ this.component = this.mesh = this.subMesh = this.material = this.renderState = this.shaderPass = null;
9975
+ };
9923
9976
  return MeshRenderElement;
9924
9977
  }(RenderElement);
9925
9978
 
@@ -9965,6 +10018,9 @@ var SpriteElement = /*#__PURE__*/ function(RenderElement) {
9965
10018
  this.renderState = renderState;
9966
10019
  this.shaderPass = shaderPass;
9967
10020
  };
10021
+ _proto.dispose = function dispose() {
10022
+ this.component = this.renderData = this.material = this.texture = this.renderState = this.shaderPass = null;
10023
+ };
9968
10024
  return SpriteElement;
9969
10025
  }(RenderElement);
9970
10026
 
@@ -9983,6 +10039,9 @@ var SpriteMaskElement = /*#__PURE__*/ function(RenderElement) {
9983
10039
  this.renderData = renderData;
9984
10040
  this.material = material;
9985
10041
  };
10042
+ _proto.dispose = function dispose() {
10043
+ this.component = this.renderData = this.material = null;
10044
+ };
9986
10045
  return SpriteMaskElement;
9987
10046
  }(RenderElement);
9988
10047
 
@@ -10001,7 +10060,6 @@ var Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
10001
10060
  function Renderer1(entity) {
10002
10061
  var _this;
10003
10062
  _this = Component.call(this, entity) || this;
10004
- /** ShaderData related to renderer. */ _this.shaderData = new ShaderData(ShaderDataGroup.Renderer);
10005
10063
  /** @internal */ _this._onUpdateIndex = -1;
10006
10064
  /** @internal */ _this._rendererIndex = -1;
10007
10065
  /** @internal */ _this._globalShaderMacro = new ShaderMacroCollection();
@@ -10009,6 +10067,7 @@ var Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
10009
10067
  _this._overrideUpdate = false;
10010
10068
  _this._materials = [];
10011
10069
  _this._dirtyUpdateFlag = 0;
10070
+ _this._shaderData = new ShaderData(ShaderDataGroup.Renderer);
10012
10071
  _this._mvMatrix = new Matrix();
10013
10072
  _this._mvpMatrix = new Matrix();
10014
10073
  _this._mvInvMatrix = new Matrix();
@@ -10155,6 +10214,17 @@ var Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
10155
10214
  var _materials_i;
10156
10215
  (_materials_i = materials[i]) == null ? void 0 : _materials_i._addRefCount(-1);
10157
10216
  }
10217
+ this._entity = null;
10218
+ this._globalShaderMacro = null;
10219
+ this._bounds = null;
10220
+ this._materials = null;
10221
+ this._shaderData = null;
10222
+ this._mvMatrix = null;
10223
+ this._mvpMatrix = null;
10224
+ this._mvInvMatrix = null;
10225
+ this._normalMatrix = null;
10226
+ this._materialsInstanced = null;
10227
+ this._rendererLayer = null;
10158
10228
  };
10159
10229
  _proto._updateShaderData = function _updateShaderData(context) {
10160
10230
  var entity = this.entity;
@@ -10216,6 +10286,14 @@ var Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
10216
10286
  this._dirtyUpdateFlag |= 0x1;
10217
10287
  };
10218
10288
  _create_class(Renderer1, [
10289
+ {
10290
+ key: "shaderData",
10291
+ get: /**
10292
+ * ShaderData related to renderer.
10293
+ */ function get() {
10294
+ return this._shaderData;
10295
+ }
10296
+ },
10219
10297
  {
10220
10298
  key: "isCulled",
10221
10299
  get: /**
@@ -10300,9 +10378,6 @@ var Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
10300
10378
  }(), function() {
10301
10379
  _Renderer._rendererLayerProperty = Shader.getPropertyByName("oasis_RendererLayer");
10302
10380
  }(), _Renderer);
10303
- __decorate([
10304
- deepClone
10305
- ], Renderer.prototype, "shaderData", void 0);
10306
10381
  __decorate([
10307
10382
  ignoreClone
10308
10383
  ], Renderer.prototype, "_distanceForSort", void 0);
@@ -10330,6 +10405,9 @@ __decorate([
10330
10405
  __decorate([
10331
10406
  ignoreClone
10332
10407
  ], Renderer.prototype, "_dirtyUpdateFlag", void 0);
10408
+ __decorate([
10409
+ deepClone
10410
+ ], Renderer.prototype, "_shaderData", void 0);
10333
10411
  __decorate([
10334
10412
  ignoreClone
10335
10413
  ], Renderer.prototype, "_mvMatrix", void 0);
@@ -10584,6 +10662,7 @@ SimpleSpriteAssembler = __decorate([
10584
10662
  sprite._addRefCount(-1);
10585
10663
  sprite._updateFlagManager.removeListener(this._onSpriteChange);
10586
10664
  }
10665
+ this._entity = null;
10587
10666
  this._sprite = null;
10588
10667
  this._renderData = null;
10589
10668
  };
@@ -11189,14 +11268,19 @@ var BufferUtil = /*#__PURE__*/ function() {
11189
11268
 
11190
11269
  /**
11191
11270
  * Sub-mesh, mainly contains drawing information.
11192
- */ var SubMesh = function SubMesh(start, count, topology) {
11193
- if (start === void 0) start = 0;
11194
- if (count === void 0) count = 0;
11195
- if (topology === void 0) topology = MeshTopology.Triangles;
11196
- this.start = start;
11197
- this.count = count;
11198
- this.topology = topology;
11199
- };
11271
+ */ var SubMesh = /*#__PURE__*/ function() {
11272
+ function SubMesh(start, count, topology) {
11273
+ if (start === void 0) start = 0;
11274
+ if (count === void 0) count = 0;
11275
+ if (topology === void 0) topology = MeshTopology.Triangles;
11276
+ this.start = start;
11277
+ this.count = count;
11278
+ this.topology = topology;
11279
+ }
11280
+ var _proto = SubMesh.prototype;
11281
+ _proto.dispose = function dispose() {};
11282
+ return SubMesh;
11283
+ }();
11200
11284
 
11201
11285
  /**
11202
11286
  * Mesh.
@@ -11312,6 +11396,7 @@ var BufferUtil = /*#__PURE__*/ function() {
11312
11396
  this._indexBufferBinding = null;
11313
11397
  this._vertexElements = null;
11314
11398
  this._vertexElementMap = null;
11399
+ this._updateFlagManager = null;
11315
11400
  this._platformPrimitive.destroy();
11316
11401
  };
11317
11402
  _proto._setVertexElements = function _setVertexElements(elements) {
@@ -12997,8 +13082,8 @@ var VertexChangedFlags;
12997
13082
  */ _proto._onDestroy = function _onDestroy() {
12998
13083
  Renderer.prototype._onDestroy.call(this);
12999
13084
  var mesh = this._mesh;
13000
- if (mesh && !mesh.destroyed) {
13001
- mesh._addRefCount(-1);
13085
+ if (mesh) {
13086
+ mesh.destroyed || mesh._addRefCount(-1);
13002
13087
  mesh._updateFlagManager.removeListener(this._onMeshChanged);
13003
13088
  this._mesh = null;
13004
13089
  }
@@ -13335,10 +13420,21 @@ var rePropName = RegExp(// Match anything that isn't a dot or bracket.
13335
13420
  * @internal
13336
13421
  * @override
13337
13422
  */ _proto._onDestroy = function _onDestroy() {
13338
- var _this_rootBone, _this__jointTexture;
13423
+ var _this__rootBone, _this__jointTexture;
13339
13424
  MeshRenderer.prototype._onDestroy.call(this);
13340
- (_this_rootBone = this.rootBone) == null ? void 0 : _this_rootBone.transform._updateFlagManager.removeListener(this._onTransformChanged);
13425
+ (_this__rootBone = this._rootBone) == null ? void 0 : _this__rootBone.transform._updateFlagManager.removeListener(this._onTransformChanged);
13426
+ this._rootBone = null;
13427
+ this._jointDataCreateCache = null;
13428
+ this._skin = null;
13429
+ this._blendShapeWeights = null;
13430
+ this._localBounds = null;
13431
+ this._jointMatrices = null;
13341
13432
  (_this__jointTexture = this._jointTexture) == null ? void 0 : _this__jointTexture.destroy();
13433
+ this._jointTexture = null;
13434
+ if (this._jointEntities) {
13435
+ this._jointEntities.length = 0;
13436
+ this._jointEntities = null;
13437
+ }
13342
13438
  };
13343
13439
  /**
13344
13440
  * @internal
@@ -14726,6 +14822,11 @@ var TextRenderElement = /*#__PURE__*/ function(RenderElement) {
14726
14822
  _this.multiRenderData = true;
14727
14823
  return _this;
14728
14824
  }
14825
+ var _proto = TextRenderElement.prototype;
14826
+ _proto.dispose = function dispose() {
14827
+ this.component = this.material = this.renderState = this.shaderPass = null;
14828
+ this.charElements.length = 0;
14829
+ };
14729
14830
  return TextRenderElement;
14730
14831
  }(RenderElement);
14731
14832
 
@@ -14873,7 +14974,6 @@ var TextRenderElement = /*#__PURE__*/ function(RenderElement) {
14873
14974
  this.texture = null;
14874
14975
  this.solidColor = null;
14875
14976
  this.sky.destroy();
14876
- this._engine = null;
14877
14977
  };
14878
14978
  /**
14879
14979
  * @internal
@@ -15258,8 +15358,6 @@ var TextRenderElement = /*#__PURE__*/ function(RenderElement) {
15258
15358
  function Scene(engine, name) {
15259
15359
  var _this;
15260
15360
  _this = EngineObject.call(this, engine) || this;
15261
- /** The background of the scene. */ _this.background = new Background(_this._engine);
15262
- /** Scene-related shader data. */ _this.shaderData = new ShaderData(ShaderDataGroup.Scene);
15263
15361
  /** If cast shadows. */ _this.castShadows = true;
15264
15362
  /** The resolution of the shadow maps. */ _this.shadowResolution = ShadowResolution.Medium;
15265
15363
  /** The splits of two cascade distribution. */ _this.shadowTwoCascadeSplits = 1.0 / 3.0;
@@ -15269,6 +15367,8 @@ var TextRenderElement = /*#__PURE__*/ function(RenderElement) {
15269
15367
  /** @internal */ _this._isActiveInEngine = false;
15270
15368
  /** @internal */ _this._globalShaderMacro = new ShaderMacroCollection();
15271
15369
  /** @internal */ _this._rootEntities = [];
15370
+ _this._background = new Background(_this._engine);
15371
+ _this._shaderData = new ShaderData(ShaderDataGroup.Scene);
15272
15372
  _this._shadowCascades = ShadowCascadesMode.NoCascades;
15273
15373
  _this._fogMode = FogMode.None;
15274
15374
  _this._fogColor = new Color$1(0.5, 0.5, 0.5, 1.0);
@@ -15439,6 +15539,8 @@ var TextRenderElement = /*#__PURE__*/ function(RenderElement) {
15439
15539
  shaderData.setVector3(Scene._sunlightColorProperty, this._sunlightVector3);
15440
15540
  shaderData.setVector3(Scene._sunlightDirectionProperty, sunlight.direction);
15441
15541
  this._sunLight = sunlight;
15542
+ } else {
15543
+ this._sunLight = null;
15442
15544
  }
15443
15545
  if (this.castShadows && this._sunLight && this._sunLight.shadowType !== ShadowType.None) {
15444
15546
  shaderData.enableMacro("SHADOW_TYPE", this._sunLight.shadowType.toString());
@@ -15498,6 +15600,22 @@ var TextRenderElement = /*#__PURE__*/ function(RenderElement) {
15498
15600
  this._fogParams.w = density / Math.sqrt(Math.LN2);
15499
15601
  };
15500
15602
  _create_class(Scene, [
15603
+ {
15604
+ key: "shaderData",
15605
+ get: /**
15606
+ * Scene-related shader data.
15607
+ */ function get() {
15608
+ return this._shaderData;
15609
+ }
15610
+ },
15611
+ {
15612
+ key: "background",
15613
+ get: /**
15614
+ * The background of the scene.
15615
+ */ function get() {
15616
+ return this._background;
15617
+ }
15618
+ },
15501
15619
  {
15502
15620
  key: "shadowCascades",
15503
15621
  get: /**
@@ -17795,7 +17913,6 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component) {
17795
17913
  function Camera1(entity) {
17796
17914
  var _this;
17797
17915
  _this = Component.call(this, entity) || this;
17798
- /** Shader data. */ _this.shaderData = new ShaderData(ShaderDataGroup.Camera);
17799
17916
  /** Rendering priority - A Camera with higher priority will be rendered on top of a camera with lower priority. */ _this.priority = 0;
17800
17917
  /** Whether to enable frustum culling, it is enabled by default. */ _this.enableFrustumCulling = true;
17801
17918
  /**
@@ -17809,6 +17926,7 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component) {
17809
17926
  /** @internal */ _this._globalShaderMacro = new ShaderMacroCollection();
17810
17927
  /** @internal */ _this._frustum = new BoundingFrustum();
17811
17928
  /** @internal */ _this._virtualCamera = new VirtualCamera();
17929
+ _this._shaderData = new ShaderData(ShaderDataGroup.Camera);
17812
17930
  _this._isProjMatSetting = false;
17813
17931
  _this._nearClipPlane = 0.1;
17814
17932
  _this._farClipPlane = 100;
@@ -18007,6 +18125,20 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component) {
18007
18125
  this._isInvViewProjDirty.destroy();
18008
18126
  this._isViewMatrixDirty.destroy();
18009
18127
  this.shaderData._addRefCount(-1);
18128
+ this._entity = null;
18129
+ this._globalShaderMacro = null;
18130
+ this._frustum = null;
18131
+ this._renderPipeline = null;
18132
+ this._virtualCamera = null;
18133
+ this._shaderData = null;
18134
+ this._frustumViewChangeFlag = null;
18135
+ this._transform = null;
18136
+ this._isViewMatrixDirty = null;
18137
+ this._isInvViewProjDirty = null;
18138
+ this._viewport = null;
18139
+ this._inverseProjectionMatrix = null;
18140
+ this._lastAspectSize = null;
18141
+ this._invViewProjMat = null;
18010
18142
  };
18011
18143
  _proto._projMatChange = function _projMatChange() {
18012
18144
  this._isFrustumProjectDirty = true;
@@ -18046,6 +18178,14 @@ var Camera = (_Camera = /*#__PURE__*/ function(Component) {
18046
18178
  return this._inverseProjectionMatrix;
18047
18179
  };
18048
18180
  _create_class(Camera1, [
18181
+ {
18182
+ key: "shaderData",
18183
+ get: /**
18184
+ * Shader data.
18185
+ */ function get() {
18186
+ return this._shaderData;
18187
+ }
18188
+ },
18049
18189
  {
18050
18190
  key: "nearClipPlane",
18051
18191
  get: /**
@@ -20114,6 +20254,7 @@ SlicedSpriteAssembler = __decorate([
20114
20254
  sprite._addRefCount(-1);
20115
20255
  sprite._updateFlagManager.removeListener(this._onSpriteChange);
20116
20256
  }
20257
+ this._entity = null;
20117
20258
  this._color = null;
20118
20259
  this._sprite = null;
20119
20260
  this._assembler = null;
@@ -22660,9 +22801,16 @@ var AnimatorLayerBlendingMode;
22660
22801
 
22661
22802
  /**
22662
22803
  * @internal
22663
- */ var AnimationEventHandler = function AnimationEventHandler() {
22664
- this.handlers = [];
22665
- };
22804
+ */ var AnimationEventHandler = /*#__PURE__*/ function() {
22805
+ function AnimationEventHandler() {
22806
+ this.handlers = [];
22807
+ }
22808
+ var _proto = AnimationEventHandler.prototype;
22809
+ _proto.dispose = function dispose() {
22810
+ this.handlers.length = 0;
22811
+ };
22812
+ return AnimationEventHandler;
22813
+ }();
22666
22814
 
22667
22815
  /**
22668
22816
  * Transitions define when and how the state machine switch from on state to another. AnimatorTransition always originate from a StateMachine or a StateMachine entry.