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