@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.
@@ -3526,6 +3526,28 @@ var /** @internal */ PromiseState;
3526
3526
  * @remarks The release principle is that it is not referenced by the components, including direct and indirect reference.
3527
3527
  */ _proto.gc = function gc() {
3528
3528
  this._gc(false);
3529
+ var engine = this.engine;
3530
+ engine._renderElementPool.garbageCollection();
3531
+ engine._spriteElementPool.garbageCollection();
3532
+ engine._spriteMaskElementPool.garbageCollection();
3533
+ engine._textElementPool.garbageCollection();
3534
+ var _componentsManager = engine._componentsManager, _lightManager = engine._lightManager;
3535
+ _componentsManager._renderers.garbageCollection();
3536
+ // @ts-ignore
3537
+ _componentsManager._onStartScripts.garbageCollection();
3538
+ // @ts-ignore
3539
+ _componentsManager._onUpdateScripts.garbageCollection();
3540
+ // @ts-ignore
3541
+ _componentsManager._onLateUpdateScripts.garbageCollection();
3542
+ // @ts-ignore
3543
+ _componentsManager._onPhysicsUpdateScripts.garbageCollection();
3544
+ // @ts-ignore
3545
+ _componentsManager._onUpdateAnimations.garbageCollection();
3546
+ // @ts-ignore
3547
+ _componentsManager._onUpdateRenderers.garbageCollection();
3548
+ _lightManager._spotLights.garbageCollection();
3549
+ _lightManager._pointLights.garbageCollection();
3550
+ _lightManager._directLights.garbageCollection();
3529
3551
  };
3530
3552
  /**
3531
3553
  * @internal
@@ -5368,6 +5390,11 @@ var TransformModifyFlags;
5368
5390
  * @returns Cloned entity
5369
5391
  */ _proto.clone = function clone() {
5370
5392
  var cloneEntity = new Entity(this._engine, this.name);
5393
+ var _this = this, hookResource = _this._hookResource;
5394
+ if (hookResource) {
5395
+ cloneEntity._hookResource = hookResource;
5396
+ hookResource._addRefCount(1);
5397
+ }
5371
5398
  cloneEntity._isActive = this._isActive;
5372
5399
  cloneEntity.transform.localMatrix = this.transform.localMatrix;
5373
5400
  var children = this._children;
@@ -5392,6 +5419,10 @@ var TransformModifyFlags;
5392
5419
  return;
5393
5420
  }
5394
5421
  EngineObject.prototype.destroy.call(this);
5422
+ if (this._hookResource) {
5423
+ this._hookResource._addRefCount(-1);
5424
+ this._hookResource = null;
5425
+ }
5395
5426
  var components = this._components;
5396
5427
  for(var i = components.length - 1; i >= 0; i--){
5397
5428
  components[i].destroy();
@@ -9799,9 +9830,9 @@ __decorate([
9799
9830
  function Material(engine, shader) {
9800
9831
  var _this;
9801
9832
  _this = RefObject.call(this, engine) || this;
9802
- /** Shader data. */ _this.shaderData = new ShaderData(ShaderDataGroup.Material);
9803
9833
  /** @internal */ _this._renderStates = [] // todo: later will as a part of shaderData when shader effect frame is OK, that is more powerful and flexible.
9804
9834
  ;
9835
+ _this._shaderData = new ShaderData(ShaderDataGroup.Material);
9805
9836
  _this.shader = shader;
9806
9837
  return _this;
9807
9838
  }
@@ -9833,8 +9864,21 @@ __decorate([
9833
9864
  */ _proto._preRender = function _preRender(renderElement) {};
9834
9865
  /**
9835
9866
  * @override
9836
- */ _proto._onDestroy = function _onDestroy() {};
9867
+ */ _proto._onDestroy = function _onDestroy() {
9868
+ this._shader = null;
9869
+ this._shaderData = null;
9870
+ this._renderStates.length = 0;
9871
+ this._renderStates = null;
9872
+ };
9837
9873
  _create_class(Material, [
9874
+ {
9875
+ key: "shaderData",
9876
+ get: /**
9877
+ * Shader data.
9878
+ */ function get() {
9879
+ return this._shaderData;
9880
+ }
9881
+ },
9838
9882
  {
9839
9883
  key: "shader",
9840
9884
  get: /**
@@ -9903,6 +9947,12 @@ __decorate([
9903
9947
  */ _proto.resetPool = function resetPool() {
9904
9948
  this._elementPoolIndex = 0;
9905
9949
  };
9950
+ _proto.garbageCollection = function garbageCollection() {
9951
+ var _this = this, pool = _this._elementPool;
9952
+ for(var i = pool.length - 1; i >= 0; i--){
9953
+ pool[i].dispose && pool[i].dispose();
9954
+ }
9955
+ };
9906
9956
  return ClassPool;
9907
9957
  }();
9908
9958
 
@@ -9925,6 +9975,9 @@ var RenderElement = function RenderElement() {
9925
9975
  this.renderState = renderState;
9926
9976
  this.shaderPass = shaderPass;
9927
9977
  };
9978
+ _proto.dispose = function dispose() {
9979
+ this.component = this.mesh = this.subMesh = this.material = this.renderState = this.shaderPass = null;
9980
+ };
9928
9981
  return MeshRenderElement;
9929
9982
  }(RenderElement);
9930
9983
 
@@ -9970,6 +10023,9 @@ var SpriteElement = /*#__PURE__*/ function(RenderElement) {
9970
10023
  this.renderState = renderState;
9971
10024
  this.shaderPass = shaderPass;
9972
10025
  };
10026
+ _proto.dispose = function dispose() {
10027
+ this.component = this.renderData = this.material = this.texture = this.renderState = this.shaderPass = null;
10028
+ };
9973
10029
  return SpriteElement;
9974
10030
  }(RenderElement);
9975
10031
 
@@ -9988,6 +10044,9 @@ var SpriteMaskElement = /*#__PURE__*/ function(RenderElement) {
9988
10044
  this.renderData = renderData;
9989
10045
  this.material = material;
9990
10046
  };
10047
+ _proto.dispose = function dispose() {
10048
+ this.component = this.renderData = this.material = null;
10049
+ };
9991
10050
  return SpriteMaskElement;
9992
10051
  }(RenderElement);
9993
10052
 
@@ -10006,7 +10065,6 @@ exports.Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
10006
10065
  function Renderer1(entity) {
10007
10066
  var _this;
10008
10067
  _this = Component.call(this, entity) || this;
10009
- /** ShaderData related to renderer. */ _this.shaderData = new ShaderData(ShaderDataGroup.Renderer);
10010
10068
  /** @internal */ _this._onUpdateIndex = -1;
10011
10069
  /** @internal */ _this._rendererIndex = -1;
10012
10070
  /** @internal */ _this._globalShaderMacro = new ShaderMacroCollection();
@@ -10014,6 +10072,7 @@ exports.Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
10014
10072
  _this._overrideUpdate = false;
10015
10073
  _this._materials = [];
10016
10074
  _this._dirtyUpdateFlag = 0;
10075
+ _this._shaderData = new ShaderData(ShaderDataGroup.Renderer);
10017
10076
  _this._mvMatrix = new miniprogram.Matrix();
10018
10077
  _this._mvpMatrix = new miniprogram.Matrix();
10019
10078
  _this._mvInvMatrix = new miniprogram.Matrix();
@@ -10160,6 +10219,17 @@ exports.Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
10160
10219
  var _materials_i;
10161
10220
  (_materials_i = materials[i]) == null ? void 0 : _materials_i._addRefCount(-1);
10162
10221
  }
10222
+ this._entity = null;
10223
+ this._globalShaderMacro = null;
10224
+ this._bounds = null;
10225
+ this._materials = null;
10226
+ this._shaderData = null;
10227
+ this._mvMatrix = null;
10228
+ this._mvpMatrix = null;
10229
+ this._mvInvMatrix = null;
10230
+ this._normalMatrix = null;
10231
+ this._materialsInstanced = null;
10232
+ this._rendererLayer = null;
10163
10233
  };
10164
10234
  _proto._updateShaderData = function _updateShaderData(context) {
10165
10235
  var entity = this.entity;
@@ -10221,6 +10291,14 @@ exports.Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
10221
10291
  this._dirtyUpdateFlag |= 0x1;
10222
10292
  };
10223
10293
  _create_class(Renderer1, [
10294
+ {
10295
+ key: "shaderData",
10296
+ get: /**
10297
+ * ShaderData related to renderer.
10298
+ */ function get() {
10299
+ return this._shaderData;
10300
+ }
10301
+ },
10224
10302
  {
10225
10303
  key: "isCulled",
10226
10304
  get: /**
@@ -10305,9 +10383,6 @@ exports.Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
10305
10383
  }(), function() {
10306
10384
  _Renderer._rendererLayerProperty = Shader.getPropertyByName("oasis_RendererLayer");
10307
10385
  }(), _Renderer);
10308
- __decorate([
10309
- deepClone
10310
- ], exports.Renderer.prototype, "shaderData", void 0);
10311
10386
  __decorate([
10312
10387
  ignoreClone
10313
10388
  ], exports.Renderer.prototype, "_distanceForSort", void 0);
@@ -10335,6 +10410,9 @@ __decorate([
10335
10410
  __decorate([
10336
10411
  ignoreClone
10337
10412
  ], exports.Renderer.prototype, "_dirtyUpdateFlag", void 0);
10413
+ __decorate([
10414
+ deepClone
10415
+ ], exports.Renderer.prototype, "_shaderData", void 0);
10338
10416
  __decorate([
10339
10417
  ignoreClone
10340
10418
  ], exports.Renderer.prototype, "_mvMatrix", void 0);
@@ -10589,6 +10667,7 @@ SimpleSpriteAssembler = __decorate([
10589
10667
  sprite._addRefCount(-1);
10590
10668
  sprite._updateFlagManager.removeListener(this._onSpriteChange);
10591
10669
  }
10670
+ this._entity = null;
10592
10671
  this._sprite = null;
10593
10672
  this._renderData = null;
10594
10673
  };
@@ -11194,14 +11273,19 @@ var BufferUtil = /*#__PURE__*/ function() {
11194
11273
 
11195
11274
  /**
11196
11275
  * Sub-mesh, mainly contains drawing information.
11197
- */ var SubMesh = function SubMesh(start, count, topology) {
11198
- if (start === void 0) start = 0;
11199
- if (count === void 0) count = 0;
11200
- if (topology === void 0) topology = exports.MeshTopology.Triangles;
11201
- this.start = start;
11202
- this.count = count;
11203
- this.topology = topology;
11204
- };
11276
+ */ var SubMesh = /*#__PURE__*/ function() {
11277
+ function SubMesh(start, count, topology) {
11278
+ if (start === void 0) start = 0;
11279
+ if (count === void 0) count = 0;
11280
+ if (topology === void 0) topology = exports.MeshTopology.Triangles;
11281
+ this.start = start;
11282
+ this.count = count;
11283
+ this.topology = topology;
11284
+ }
11285
+ var _proto = SubMesh.prototype;
11286
+ _proto.dispose = function dispose() {};
11287
+ return SubMesh;
11288
+ }();
11205
11289
 
11206
11290
  /**
11207
11291
  * Mesh.
@@ -11317,6 +11401,7 @@ var BufferUtil = /*#__PURE__*/ function() {
11317
11401
  this._indexBufferBinding = null;
11318
11402
  this._vertexElements = null;
11319
11403
  this._vertexElementMap = null;
11404
+ this._updateFlagManager = null;
11320
11405
  this._platformPrimitive.destroy();
11321
11406
  };
11322
11407
  _proto._setVertexElements = function _setVertexElements(elements) {
@@ -13002,8 +13087,8 @@ var VertexChangedFlags;
13002
13087
  */ _proto._onDestroy = function _onDestroy() {
13003
13088
  Renderer.prototype._onDestroy.call(this);
13004
13089
  var mesh = this._mesh;
13005
- if (mesh && !mesh.destroyed) {
13006
- mesh._addRefCount(-1);
13090
+ if (mesh) {
13091
+ mesh.destroyed || mesh._addRefCount(-1);
13007
13092
  mesh._updateFlagManager.removeListener(this._onMeshChanged);
13008
13093
  this._mesh = null;
13009
13094
  }
@@ -13340,10 +13425,21 @@ var rePropName = RegExp(// Match anything that isn't a dot or bracket.
13340
13425
  * @internal
13341
13426
  * @override
13342
13427
  */ _proto._onDestroy = function _onDestroy() {
13343
- var _this_rootBone, _this__jointTexture;
13428
+ var _this__rootBone, _this__jointTexture;
13344
13429
  MeshRenderer.prototype._onDestroy.call(this);
13345
- (_this_rootBone = this.rootBone) == null ? void 0 : _this_rootBone.transform._updateFlagManager.removeListener(this._onTransformChanged);
13430
+ (_this__rootBone = this._rootBone) == null ? void 0 : _this__rootBone.transform._updateFlagManager.removeListener(this._onTransformChanged);
13431
+ this._rootBone = null;
13432
+ this._jointDataCreateCache = null;
13433
+ this._skin = null;
13434
+ this._blendShapeWeights = null;
13435
+ this._localBounds = null;
13436
+ this._jointMatrices = null;
13346
13437
  (_this__jointTexture = this._jointTexture) == null ? void 0 : _this__jointTexture.destroy();
13438
+ this._jointTexture = null;
13439
+ if (this._jointEntities) {
13440
+ this._jointEntities.length = 0;
13441
+ this._jointEntities = null;
13442
+ }
13347
13443
  };
13348
13444
  /**
13349
13445
  * @internal
@@ -14731,6 +14827,11 @@ var TextRenderElement = /*#__PURE__*/ function(RenderElement) {
14731
14827
  _this.multiRenderData = true;
14732
14828
  return _this;
14733
14829
  }
14830
+ var _proto = TextRenderElement.prototype;
14831
+ _proto.dispose = function dispose() {
14832
+ this.component = this.material = this.renderState = this.shaderPass = null;
14833
+ this.charElements.length = 0;
14834
+ };
14734
14835
  return TextRenderElement;
14735
14836
  }(RenderElement);
14736
14837
 
@@ -14878,7 +14979,6 @@ var TextRenderElement = /*#__PURE__*/ function(RenderElement) {
14878
14979
  this.texture = null;
14879
14980
  this.solidColor = null;
14880
14981
  this.sky.destroy();
14881
- this._engine = null;
14882
14982
  };
14883
14983
  /**
14884
14984
  * @internal
@@ -15263,8 +15363,6 @@ var TextRenderElement = /*#__PURE__*/ function(RenderElement) {
15263
15363
  function Scene(engine, name) {
15264
15364
  var _this;
15265
15365
  _this = EngineObject.call(this, engine) || this;
15266
- /** The background of the scene. */ _this.background = new Background(_this._engine);
15267
- /** Scene-related shader data. */ _this.shaderData = new ShaderData(ShaderDataGroup.Scene);
15268
15366
  /** If cast shadows. */ _this.castShadows = true;
15269
15367
  /** The resolution of the shadow maps. */ _this.shadowResolution = exports.ShadowResolution.Medium;
15270
15368
  /** The splits of two cascade distribution. */ _this.shadowTwoCascadeSplits = 1.0 / 3.0;
@@ -15274,6 +15372,8 @@ var TextRenderElement = /*#__PURE__*/ function(RenderElement) {
15274
15372
  /** @internal */ _this._isActiveInEngine = false;
15275
15373
  /** @internal */ _this._globalShaderMacro = new ShaderMacroCollection();
15276
15374
  /** @internal */ _this._rootEntities = [];
15375
+ _this._background = new Background(_this._engine);
15376
+ _this._shaderData = new ShaderData(ShaderDataGroup.Scene);
15277
15377
  _this._shadowCascades = exports.ShadowCascadesMode.NoCascades;
15278
15378
  _this._fogMode = exports.FogMode.None;
15279
15379
  _this._fogColor = new miniprogram.Color(0.5, 0.5, 0.5, 1.0);
@@ -15444,6 +15544,8 @@ var TextRenderElement = /*#__PURE__*/ function(RenderElement) {
15444
15544
  shaderData.setVector3(Scene._sunlightColorProperty, this._sunlightVector3);
15445
15545
  shaderData.setVector3(Scene._sunlightDirectionProperty, sunlight.direction);
15446
15546
  this._sunLight = sunlight;
15547
+ } else {
15548
+ this._sunLight = null;
15447
15549
  }
15448
15550
  if (this.castShadows && this._sunLight && this._sunLight.shadowType !== exports.ShadowType.None) {
15449
15551
  shaderData.enableMacro("SHADOW_TYPE", this._sunLight.shadowType.toString());
@@ -15503,6 +15605,22 @@ var TextRenderElement = /*#__PURE__*/ function(RenderElement) {
15503
15605
  this._fogParams.w = density / Math.sqrt(Math.LN2);
15504
15606
  };
15505
15607
  _create_class(Scene, [
15608
+ {
15609
+ key: "shaderData",
15610
+ get: /**
15611
+ * Scene-related shader data.
15612
+ */ function get() {
15613
+ return this._shaderData;
15614
+ }
15615
+ },
15616
+ {
15617
+ key: "background",
15618
+ get: /**
15619
+ * The background of the scene.
15620
+ */ function get() {
15621
+ return this._background;
15622
+ }
15623
+ },
15506
15624
  {
15507
15625
  key: "shadowCascades",
15508
15626
  get: /**
@@ -17800,7 +17918,6 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component) {
17800
17918
  function Camera1(entity) {
17801
17919
  var _this;
17802
17920
  _this = Component.call(this, entity) || this;
17803
- /** Shader data. */ _this.shaderData = new ShaderData(ShaderDataGroup.Camera);
17804
17921
  /** Rendering priority - A Camera with higher priority will be rendered on top of a camera with lower priority. */ _this.priority = 0;
17805
17922
  /** Whether to enable frustum culling, it is enabled by default. */ _this.enableFrustumCulling = true;
17806
17923
  /**
@@ -17814,6 +17931,7 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component) {
17814
17931
  /** @internal */ _this._globalShaderMacro = new ShaderMacroCollection();
17815
17932
  /** @internal */ _this._frustum = new miniprogram.BoundingFrustum();
17816
17933
  /** @internal */ _this._virtualCamera = new VirtualCamera();
17934
+ _this._shaderData = new ShaderData(ShaderDataGroup.Camera);
17817
17935
  _this._isProjMatSetting = false;
17818
17936
  _this._nearClipPlane = 0.1;
17819
17937
  _this._farClipPlane = 100;
@@ -18012,6 +18130,20 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component) {
18012
18130
  this._isInvViewProjDirty.destroy();
18013
18131
  this._isViewMatrixDirty.destroy();
18014
18132
  this.shaderData._addRefCount(-1);
18133
+ this._entity = null;
18134
+ this._globalShaderMacro = null;
18135
+ this._frustum = null;
18136
+ this._renderPipeline = null;
18137
+ this._virtualCamera = null;
18138
+ this._shaderData = null;
18139
+ this._frustumViewChangeFlag = null;
18140
+ this._transform = null;
18141
+ this._isViewMatrixDirty = null;
18142
+ this._isInvViewProjDirty = null;
18143
+ this._viewport = null;
18144
+ this._inverseProjectionMatrix = null;
18145
+ this._lastAspectSize = null;
18146
+ this._invViewProjMat = null;
18015
18147
  };
18016
18148
  _proto._projMatChange = function _projMatChange() {
18017
18149
  this._isFrustumProjectDirty = true;
@@ -18051,6 +18183,14 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component) {
18051
18183
  return this._inverseProjectionMatrix;
18052
18184
  };
18053
18185
  _create_class(Camera1, [
18186
+ {
18187
+ key: "shaderData",
18188
+ get: /**
18189
+ * Shader data.
18190
+ */ function get() {
18191
+ return this._shaderData;
18192
+ }
18193
+ },
18054
18194
  {
18055
18195
  key: "nearClipPlane",
18056
18196
  get: /**
@@ -20119,6 +20259,7 @@ SlicedSpriteAssembler = __decorate([
20119
20259
  sprite._addRefCount(-1);
20120
20260
  sprite._updateFlagManager.removeListener(this._onSpriteChange);
20121
20261
  }
20262
+ this._entity = null;
20122
20263
  this._color = null;
20123
20264
  this._sprite = null;
20124
20265
  this._assembler = null;
@@ -22665,9 +22806,16 @@ exports.AnimatorLayerBlendingMode = void 0;
22665
22806
 
22666
22807
  /**
22667
22808
  * @internal
22668
- */ var AnimationEventHandler = function AnimationEventHandler() {
22669
- this.handlers = [];
22670
- };
22809
+ */ var AnimationEventHandler = /*#__PURE__*/ function() {
22810
+ function AnimationEventHandler() {
22811
+ this.handlers = [];
22812
+ }
22813
+ var _proto = AnimationEventHandler.prototype;
22814
+ _proto.dispose = function dispose() {
22815
+ this.handlers.length = 0;
22816
+ };
22817
+ return AnimationEventHandler;
22818
+ }();
22671
22819
 
22672
22820
  /**
22673
22821
  * Transitions define when and how the state machine switch from on state to another. AnimatorTransition always originate from a StateMachine or a StateMachine entry.