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