@galacean/engine-core 1.0.0-beta.10 → 1.0.0-beta.12

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.
@@ -799,6 +799,14 @@ __decorate([
799
799
  TextureFormat[TextureFormat[/** 32-bit depth + 8-bit stencil format. */ "Depth32Stencil8"] = 31] = "Depth32Stencil8";
800
800
  })(exports.TextureFormat || (exports.TextureFormat = {}));
801
801
 
802
+ /**
803
+ * Texture usage.
804
+ */ exports.TextureUsage = void 0;
805
+ (function(TextureUsage) {
806
+ TextureUsage[TextureUsage[/** The content of the texture is intended to be specified once. */ "Static"] = 0] = "Static";
807
+ TextureUsage[TextureUsage[/** The content of the texture is intended to be updated frequently, with better performance. */ "Dynamic"] = 1] = "Dynamic";
808
+ })(exports.TextureUsage || (exports.TextureUsage = {}));
809
+
802
810
  /**
803
811
  * Wrapping mode of the texture.
804
812
  */ exports.TextureWrapMode = void 0;
@@ -939,6 +947,14 @@ var Logger = {
939
947
  return this._height;
940
948
  }
941
949
  },
950
+ {
951
+ key: "usage",
952
+ get: /**
953
+ * The usage of the texture.
954
+ */ function get() {
955
+ return this._usage;
956
+ }
957
+ },
942
958
  {
943
959
  key: "wrapModeU",
944
960
  get: /**
@@ -1182,14 +1198,16 @@ var Logger = {
1182
1198
  * Two-dimensional texture.
1183
1199
  */ var Texture2D = /*#__PURE__*/ function(Texture) {
1184
1200
  _inherits(Texture2D, Texture);
1185
- function Texture2D(engine, width, height, format, mipmap) {
1201
+ function Texture2D(engine, width, height, format, mipmap, usage) {
1186
1202
  if (format === void 0) format = exports.TextureFormat.R8G8B8A8;
1187
1203
  if (mipmap === void 0) mipmap = true;
1204
+ if (usage === void 0) usage = exports.TextureUsage.Static;
1188
1205
  var _this;
1189
1206
  _this = Texture.call(this, engine) || this;
1190
1207
  _this._mipmap = mipmap;
1191
1208
  _this._width = width;
1192
1209
  _this._height = height;
1210
+ _this._usage = usage;
1193
1211
  _this._format = format;
1194
1212
  _this._mipmapCount = _this._getMipmapCount();
1195
1213
  _this._isDepthTexture = format == exports.TextureFormat.Depth || format == exports.TextureFormat.DepthStencil || format == exports.TextureFormat.Depth16 || format == exports.TextureFormat.Depth24 || format == exports.TextureFormat.Depth32 || format == exports.TextureFormat.Depth24Stencil8 || format == exports.TextureFormat.Depth32Stencil8;
@@ -2289,6 +2307,29 @@ var /** @internal */ PromiseState;
2289
2307
  * @remarks The release principle is that it is not referenced by the components, including direct and indirect reference.
2290
2308
  */ _proto.gc = function gc() {
2291
2309
  this._gc(false);
2310
+ var engine = this.engine;
2311
+ engine._renderElementPool.garbageCollection();
2312
+ engine._meshRenderDataPool.garbageCollection();
2313
+ engine._spriteRenderDataPool.garbageCollection();
2314
+ engine._spriteMaskRenderDataPool.garbageCollection();
2315
+ engine._textRenderDataPool.garbageCollection();
2316
+ var _componentsManager = engine._componentsManager, _lightManager = engine._lightManager;
2317
+ _componentsManager._renderers.garbageCollection();
2318
+ // @ts-ignore
2319
+ _componentsManager._onStartScripts.garbageCollection();
2320
+ // @ts-ignore
2321
+ _componentsManager._onUpdateScripts.garbageCollection();
2322
+ // @ts-ignore
2323
+ _componentsManager._onLateUpdateScripts.garbageCollection();
2324
+ // @ts-ignore
2325
+ _componentsManager._onPhysicsUpdateScripts.garbageCollection();
2326
+ // @ts-ignore
2327
+ _componentsManager._onUpdateAnimations.garbageCollection();
2328
+ // @ts-ignore
2329
+ _componentsManager._onUpdateRenderers.garbageCollection();
2330
+ _lightManager._spotLights.garbageCollection();
2331
+ _lightManager._pointLights.garbageCollection();
2332
+ _lightManager._directLights.garbageCollection();
2292
2333
  };
2293
2334
  /**
2294
2335
  * Add content restorer.
@@ -4724,6 +4765,11 @@ var ComponentCloner = /*#__PURE__*/ function() {
4724
4765
  * @returns Cloned entity
4725
4766
  */ _proto.clone = function clone() {
4726
4767
  var cloneEntity = new Entity(this._engine, this.name);
4768
+ var _this = this, hookResource = _this._hookResource;
4769
+ if (hookResource) {
4770
+ cloneEntity._hookResource = hookResource;
4771
+ hookResource._addReferCount(1);
4772
+ }
4727
4773
  cloneEntity._isActive = this._isActive;
4728
4774
  cloneEntity.transform.localMatrix = this.transform.localMatrix;
4729
4775
  var children = this._children;
@@ -4748,6 +4794,10 @@ var ComponentCloner = /*#__PURE__*/ function() {
4748
4794
  return;
4749
4795
  }
4750
4796
  EngineObject.prototype.destroy.call(this);
4797
+ if (this._hookResource) {
4798
+ this._hookResource._addReferCount(-1);
4799
+ this._hookResource = null;
4800
+ }
4751
4801
  var components = this._components;
4752
4802
  for(var i = components.length - 1; i >= 0; i--){
4753
4803
  components[i].destroy();
@@ -9402,9 +9452,9 @@ __decorate([
9402
9452
  function Material(engine, shader) {
9403
9453
  var _this;
9404
9454
  _this = ReferResource.call(this, engine) || this;
9405
- /** Shader data. */ _this.shaderData = new ShaderData(ShaderDataGroup.Material);
9406
9455
  /** @internal */ _this._renderStates = [] // todo: later will as a part of shaderData when shader effect frame is OK, that is more powerful and flexible.
9407
9456
  ;
9457
+ _this._shaderData = new ShaderData(ShaderDataGroup.Material);
9408
9458
  _this.shader = shader;
9409
9459
  return _this;
9410
9460
  }
@@ -9428,7 +9478,23 @@ __decorate([
9428
9478
  ReferResource.prototype._addReferCount.call(this, value);
9429
9479
  this.shaderData._addReferCount(value);
9430
9480
  };
9481
+ /**
9482
+ * @override
9483
+ */ _proto._onDestroy = function _onDestroy() {
9484
+ this._shader = null;
9485
+ this._shaderData = null;
9486
+ this._renderStates.length = 0;
9487
+ this._renderStates = null;
9488
+ };
9431
9489
  _create_class(Material, [
9490
+ {
9491
+ key: "shaderData",
9492
+ get: /**
9493
+ * Shader data.
9494
+ */ function get() {
9495
+ return this._shaderData;
9496
+ }
9497
+ },
9432
9498
  {
9433
9499
  key: "shader",
9434
9500
  get: /**
@@ -9501,6 +9567,12 @@ __decorate([
9501
9567
  */ _proto.resetPool = function resetPool() {
9502
9568
  this._elementPoolIndex = 0;
9503
9569
  };
9570
+ _proto.garbageCollection = function garbageCollection() {
9571
+ var _this = this, pool = _this._elementPool;
9572
+ for(var i = pool.length - 1; i >= 0; i--){
9573
+ pool[i].dispose && pool[i].dispose();
9574
+ }
9575
+ };
9504
9576
  return ClassPool;
9505
9577
  }();
9506
9578
 
@@ -9521,6 +9593,9 @@ var RenderData = function RenderData() {
9521
9593
  this.mesh = mesh;
9522
9594
  this.subMesh = subMesh;
9523
9595
  };
9596
+ _proto.dispose = function dispose() {
9597
+ this.component = this.material = this.mesh = this.subMesh = null;
9598
+ };
9524
9599
  return MeshRenderData;
9525
9600
  }(RenderData);
9526
9601
 
@@ -10666,6 +10741,9 @@ var RenderElement = /*#__PURE__*/ function() {
10666
10741
  this.shaderPass = shaderPass;
10667
10742
  this.renderState = renderState;
10668
10743
  };
10744
+ _proto.dispose = function dispose() {
10745
+ this.data = this.shaderPass = this.renderState = null;
10746
+ };
10669
10747
  return RenderElement;
10670
10748
  }();
10671
10749
 
@@ -10685,7 +10763,6 @@ exports.Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
10685
10763
  function Renderer1(entity) {
10686
10764
  var _this;
10687
10765
  _this = Component.call(this, entity) || this;
10688
- /** ShaderData related to renderer. */ _this.shaderData = new ShaderData(ShaderDataGroup.Renderer);
10689
10766
  /** @internal */ _this._onUpdateIndex = -1;
10690
10767
  /** @internal */ _this._rendererIndex = -1;
10691
10768
  /** @internal */ _this._globalShaderMacro = new ShaderMacroCollection();
@@ -10693,6 +10770,7 @@ exports.Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
10693
10770
  _this._overrideUpdate = false;
10694
10771
  _this._materials = [];
10695
10772
  _this._dirtyUpdateFlag = 0;
10773
+ _this._shaderData = new ShaderData(ShaderDataGroup.Renderer);
10696
10774
  _this._mvMatrix = new miniprogram.Matrix();
10697
10775
  _this._mvpMatrix = new miniprogram.Matrix();
10698
10776
  _this._mvInvMatrix = new miniprogram.Matrix();
@@ -10838,6 +10916,17 @@ exports.Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
10838
10916
  var _materials_i;
10839
10917
  (_materials_i = materials[i]) == null ? void 0 : _materials_i._addReferCount(-1);
10840
10918
  }
10919
+ this._entity = null;
10920
+ this._globalShaderMacro = null;
10921
+ this._bounds = null;
10922
+ this._materials = null;
10923
+ this._shaderData = null;
10924
+ this._mvMatrix = null;
10925
+ this._mvpMatrix = null;
10926
+ this._mvInvMatrix = null;
10927
+ this._normalMatrix = null;
10928
+ this._materialsInstanced = null;
10929
+ this._rendererLayer = null;
10841
10930
  };
10842
10931
  /**
10843
10932
  * @internal
@@ -10913,6 +11002,14 @@ exports.Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
10913
11002
  this._dirtyUpdateFlag |= 0x1;
10914
11003
  };
10915
11004
  _create_class(Renderer1, [
11005
+ {
11006
+ key: "shaderData",
11007
+ get: /**
11008
+ * ShaderData related to renderer.
11009
+ */ function get() {
11010
+ return this._shaderData;
11011
+ }
11012
+ },
10916
11013
  {
10917
11014
  key: "isCulled",
10918
11015
  get: /**
@@ -10997,9 +11094,6 @@ exports.Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
10997
11094
  }(), function() {
10998
11095
  _Renderer._rendererLayerProperty = ShaderProperty.getByName("renderer_Layer");
10999
11096
  }(), _Renderer);
11000
- __decorate([
11001
- deepClone
11002
- ], exports.Renderer.prototype, "shaderData", void 0);
11003
11097
  __decorate([
11004
11098
  ignoreClone
11005
11099
  ], exports.Renderer.prototype, "_distanceForSort", void 0);
@@ -11027,6 +11121,9 @@ __decorate([
11027
11121
  __decorate([
11028
11122
  ignoreClone
11029
11123
  ], exports.Renderer.prototype, "_dirtyUpdateFlag", void 0);
11124
+ __decorate([
11125
+ deepClone
11126
+ ], exports.Renderer.prototype, "_shaderData", void 0);
11030
11127
  __decorate([
11031
11128
  ignoreClone
11032
11129
  ], exports.Renderer.prototype, "_mvMatrix", void 0);
@@ -11283,6 +11380,7 @@ SimpleSpriteAssembler = __decorate([
11283
11380
  sprite._addReferCount(-1);
11284
11381
  sprite._updateFlagManager.removeListener(this._onSpriteChange);
11285
11382
  }
11383
+ this._entity = null;
11286
11384
  this._sprite = null;
11287
11385
  this._verticesData = null;
11288
11386
  };
@@ -11837,14 +11935,19 @@ var BufferUtil = /*#__PURE__*/ function() {
11837
11935
 
11838
11936
  /**
11839
11937
  * Sub-mesh, mainly contains drawing information.
11840
- */ var SubMesh = function SubMesh(start, count, topology) {
11841
- if (start === void 0) start = 0;
11842
- if (count === void 0) count = 0;
11843
- if (topology === void 0) topology = exports.MeshTopology.Triangles;
11844
- this.start = start;
11845
- this.count = count;
11846
- this.topology = topology;
11847
- };
11938
+ */ var SubMesh = /*#__PURE__*/ function() {
11939
+ function SubMesh(start, count, topology) {
11940
+ if (start === void 0) start = 0;
11941
+ if (count === void 0) count = 0;
11942
+ if (topology === void 0) topology = exports.MeshTopology.Triangles;
11943
+ this.start = start;
11944
+ this.count = count;
11945
+ this.topology = topology;
11946
+ }
11947
+ var _proto = SubMesh.prototype;
11948
+ _proto.dispose = function dispose() {};
11949
+ return SubMesh;
11950
+ }();
11848
11951
 
11849
11952
  /**
11850
11953
  * Mesh.
@@ -13600,8 +13703,8 @@ var VertexChangedFlags;
13600
13703
  */ _proto._onDestroy = function _onDestroy() {
13601
13704
  Renderer.prototype._onDestroy.call(this);
13602
13705
  var mesh = this._mesh;
13603
- if (mesh && !mesh.destroyed) {
13604
- mesh._addReferCount(-1);
13706
+ if (mesh) {
13707
+ mesh.destroyed || mesh._addReferCount(-1);
13605
13708
  mesh._updateFlagManager.removeListener(this._onMeshChanged);
13606
13709
  this._mesh = null;
13607
13710
  }
@@ -13857,10 +13960,21 @@ var /**
13857
13960
  /**
13858
13961
  * @internal
13859
13962
  */ _proto._onDestroy = function _onDestroy() {
13860
- var _this_rootBone, _this__jointTexture;
13963
+ var _this__rootBone, _this__jointTexture;
13861
13964
  MeshRenderer.prototype._onDestroy.call(this);
13862
- (_this_rootBone = this.rootBone) == null ? void 0 : _this_rootBone.transform._updateFlagManager.removeListener(this._onTransformChanged);
13965
+ (_this__rootBone = this._rootBone) == null ? void 0 : _this__rootBone.transform._updateFlagManager.removeListener(this._onTransformChanged);
13966
+ this._rootBone = null;
13967
+ this._jointDataCreateCache = null;
13968
+ this._skin = null;
13969
+ this._blendShapeWeights = null;
13970
+ this._localBounds = null;
13971
+ this._jointMatrices = null;
13863
13972
  (_this__jointTexture = this._jointTexture) == null ? void 0 : _this__jointTexture.destroy();
13973
+ this._jointTexture = null;
13974
+ if (this._jointEntities) {
13975
+ this._jointEntities.length = 0;
13976
+ this._jointEntities = null;
13977
+ }
13864
13978
  };
13865
13979
  /**
13866
13980
  * @internal
@@ -15562,6 +15676,9 @@ var SpriteMaskRenderData = /*#__PURE__*/ function(RenderData) {
15562
15676
  this.material = material;
15563
15677
  this.verticesData = verticesData;
15564
15678
  };
15679
+ _proto.dispose = function dispose() {
15680
+ this.component = this.material = this.verticesData = null;
15681
+ };
15565
15682
  return SpriteMaskRenderData;
15566
15683
  }(RenderData);
15567
15684
 
@@ -15582,6 +15699,9 @@ var SpriteRenderData = /*#__PURE__*/ function(RenderData) {
15582
15699
  this.texture = texture;
15583
15700
  this.dataIndex = dataIndex;
15584
15701
  };
15702
+ _proto.dispose = function dispose() {
15703
+ this.component = this.material = this.verticesData = this.texture = null;
15704
+ };
15585
15705
  return SpriteRenderData;
15586
15706
  }(RenderData);
15587
15707
 
@@ -15594,6 +15714,11 @@ var TextRenderData = /*#__PURE__*/ function(RenderData) {
15594
15714
  _this.multiRenderData = true;
15595
15715
  return _this;
15596
15716
  }
15717
+ var _proto = TextRenderData.prototype;
15718
+ _proto.dispose = function dispose() {
15719
+ this.component = this.material = null;
15720
+ this.charsData.length = 0;
15721
+ };
15597
15722
  return TextRenderData;
15598
15723
  }(RenderData);
15599
15724
 
@@ -16127,8 +16252,6 @@ var TextRenderData = /*#__PURE__*/ function(RenderData) {
16127
16252
  function Scene(engine, name) {
16128
16253
  var _this;
16129
16254
  _this = EngineObject.call(this, engine) || this;
16130
- /** The background of the scene. */ _this.background = new Background(_this._engine);
16131
- /** Scene-related shader data. */ _this.shaderData = new ShaderData(ShaderDataGroup.Scene);
16132
16255
  /** If cast shadows. */ _this.castShadows = true;
16133
16256
  /** The resolution of the shadow maps. */ _this.shadowResolution = exports.ShadowResolution.Medium;
16134
16257
  /** The splits of two cascade distribution. */ _this.shadowTwoCascadeSplits = 1.0 / 3.0;
@@ -16138,6 +16261,8 @@ var TextRenderData = /*#__PURE__*/ function(RenderData) {
16138
16261
  /** @internal */ _this._isActiveInEngine = false;
16139
16262
  /** @internal */ _this._globalShaderMacro = new ShaderMacroCollection();
16140
16263
  /** @internal */ _this._rootEntities = [];
16264
+ _this._background = new Background(_this._engine);
16265
+ _this._shaderData = new ShaderData(ShaderDataGroup.Scene);
16141
16266
  _this._shadowCascades = exports.ShadowCascadesMode.NoCascades;
16142
16267
  _this._fogMode = exports.FogMode.None;
16143
16268
  _this._fogColor = new miniprogram.Color(0.5, 0.5, 0.5, 1.0);
@@ -16304,6 +16429,8 @@ var TextRenderData = /*#__PURE__*/ function(RenderData) {
16304
16429
  shaderData.setColor(Scene._sunlightColorProperty, sunlight._getLightIntensityColor());
16305
16430
  shaderData.setVector3(Scene._sunlightDirectionProperty, sunlight.direction);
16306
16431
  this._sunLight = sunlight;
16432
+ } else {
16433
+ this._sunLight = null;
16307
16434
  }
16308
16435
  if (this.castShadows && this._sunLight && this._sunLight.shadowType !== exports.ShadowType.None) {
16309
16436
  shaderData.enableMacro("SCENE_SHADOW_TYPE", this._sunLight.shadowType.toString());
@@ -16363,6 +16490,22 @@ var TextRenderData = /*#__PURE__*/ function(RenderData) {
16363
16490
  this._fogParams.w = density / Math.sqrt(Math.LN2);
16364
16491
  };
16365
16492
  _create_class(Scene, [
16493
+ {
16494
+ key: "shaderData",
16495
+ get: /**
16496
+ * Scene-related shader data.
16497
+ */ function get() {
16498
+ return this._shaderData;
16499
+ }
16500
+ },
16501
+ {
16502
+ key: "background",
16503
+ get: /**
16504
+ * The background of the scene.
16505
+ */ function get() {
16506
+ return this._background;
16507
+ }
16508
+ },
16366
16509
  {
16367
16510
  key: "shadowCascades",
16368
16511
  get: /**
@@ -18831,7 +18974,6 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component) {
18831
18974
  function Camera1(entity) {
18832
18975
  var _this;
18833
18976
  _this = Component.call(this, entity) || this;
18834
- /** Shader data. */ _this.shaderData = new ShaderData(ShaderDataGroup.Camera);
18835
18977
  /** Rendering priority - A Camera with higher priority will be rendered on top of a camera with lower priority. */ _this.priority = 0;
18836
18978
  /** Whether to enable frustum culling, it is enabled by default. */ _this.enableFrustumCulling = true;
18837
18979
  /**
@@ -18847,6 +18989,7 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component) {
18847
18989
  /** @internal */ _this._virtualCamera = new VirtualCamera();
18848
18990
  /** @internal */ _this._replacementShader = null;
18849
18991
  /** @internal */ _this._replacementSubShaderTag = null;
18992
+ _this._shaderData = new ShaderData(ShaderDataGroup.Camera);
18850
18993
  _this._isProjMatSetting = false;
18851
18994
  _this._nearClipPlane = 0.1;
18852
18995
  _this._farClipPlane = 100;
@@ -19056,6 +19199,20 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component) {
19056
19199
  this._isInvViewProjDirty.destroy();
19057
19200
  this._isViewMatrixDirty.destroy();
19058
19201
  this.shaderData._addReferCount(-1);
19202
+ this._entity = null;
19203
+ this._globalShaderMacro = null;
19204
+ this._frustum = null;
19205
+ this._renderPipeline = null;
19206
+ this._virtualCamera = null;
19207
+ this._shaderData = null;
19208
+ this._frustumViewChangeFlag = null;
19209
+ this._transform = null;
19210
+ this._isViewMatrixDirty = null;
19211
+ this._isInvViewProjDirty = null;
19212
+ this._viewport = null;
19213
+ this._inverseProjectionMatrix = null;
19214
+ this._lastAspectSize = null;
19215
+ this._invViewProjMat = null;
19059
19216
  };
19060
19217
  _proto._projMatChange = function _projMatChange() {
19061
19218
  this._isFrustumProjectDirty = true;
@@ -19095,6 +19252,14 @@ exports.Camera = (_Camera = /*#__PURE__*/ function(Component) {
19095
19252
  return this._inverseProjectionMatrix;
19096
19253
  };
19097
19254
  _create_class(Camera1, [
19255
+ {
19256
+ key: "shaderData",
19257
+ get: /**
19258
+ * Shader data.
19259
+ */ function get() {
19260
+ return this._shaderData;
19261
+ }
19262
+ },
19098
19263
  {
19099
19264
  key: "nearClipPlane",
19100
19265
  get: /**
@@ -21504,6 +21669,7 @@ var TiledType;
21504
21669
  sprite._addReferCount(-1);
21505
21670
  sprite._updateFlagManager.removeListener(this._onSpriteChange);
21506
21671
  }
21672
+ this._entity = null;
21507
21673
  this._color = null;
21508
21674
  this._sprite = null;
21509
21675
  this._assembler = null;
@@ -23806,9 +23972,14 @@ exports.AnimatorLayerBlendingMode = void 0;
23806
23972
 
23807
23973
  /**
23808
23974
  * @internal
23809
- */ var AnimationEventHandler = function AnimationEventHandler() {
23810
- this.handlers = [];
23811
- };
23975
+ */ var AnimationEventHandler = /*#__PURE__*/ function() {
23976
+ function AnimationEventHandler() {
23977
+ this.handlers = [];
23978
+ }
23979
+ var _proto = AnimationEventHandler.prototype;
23980
+ _proto.dispose = function dispose() {};
23981
+ return AnimationEventHandler;
23982
+ }();
23812
23983
 
23813
23984
  /**
23814
23985
  * Transitions define when and how the state machine switch from on state to another. AnimatorTransition always originate from a StateMachine or a StateMachine entry.