@galacean/engine 0.9.12 → 0.9.13

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/browser.js CHANGED
@@ -7026,6 +7026,28 @@
7026
7026
  * @remarks The release principle is that it is not referenced by the components, including direct and indirect reference.
7027
7027
  */ _proto.gc = function gc() {
7028
7028
  this._gc(false);
7029
+ var engine = this.engine;
7030
+ engine._renderElementPool.garbageCollection();
7031
+ engine._spriteElementPool.garbageCollection();
7032
+ engine._spriteMaskElementPool.garbageCollection();
7033
+ engine._textElementPool.garbageCollection();
7034
+ var _componentsManager = engine._componentsManager, _lightManager = engine._lightManager;
7035
+ _componentsManager._renderers.garbageCollection();
7036
+ // @ts-ignore
7037
+ _componentsManager._onStartScripts.garbageCollection();
7038
+ // @ts-ignore
7039
+ _componentsManager._onUpdateScripts.garbageCollection();
7040
+ // @ts-ignore
7041
+ _componentsManager._onLateUpdateScripts.garbageCollection();
7042
+ // @ts-ignore
7043
+ _componentsManager._onPhysicsUpdateScripts.garbageCollection();
7044
+ // @ts-ignore
7045
+ _componentsManager._onUpdateAnimations.garbageCollection();
7046
+ // @ts-ignore
7047
+ _componentsManager._onUpdateRenderers.garbageCollection();
7048
+ _lightManager._spotLights.garbageCollection();
7049
+ _lightManager._pointLights.garbageCollection();
7050
+ _lightManager._directLights.garbageCollection();
7029
7051
  };
7030
7052
  /**
7031
7053
  * @internal
@@ -8856,6 +8878,11 @@
8856
8878
  * @returns Cloned entity
8857
8879
  */ _proto.clone = function clone() {
8858
8880
  var cloneEntity = new Entity(this._engine, this.name);
8881
+ var _this = this, hookResource = _this._hookResource;
8882
+ if (hookResource) {
8883
+ cloneEntity._hookResource = hookResource;
8884
+ hookResource._addRefCount(1);
8885
+ }
8859
8886
  cloneEntity._isActive = this._isActive;
8860
8887
  cloneEntity.transform.localMatrix = this.transform.localMatrix;
8861
8888
  var children = this._children;
@@ -8880,6 +8907,10 @@
8880
8907
  return;
8881
8908
  }
8882
8909
  EngineObject.prototype.destroy.call(this);
8910
+ if (this._hookResource) {
8911
+ this._hookResource._addRefCount(-1);
8912
+ this._hookResource = null;
8913
+ }
8883
8914
  var components = this._components;
8884
8915
  for(var i = components.length - 1; i >= 0; i--){
8885
8916
  components[i].destroy();
@@ -14426,9 +14457,9 @@
14426
14457
  var Material = function Material(engine, shader) {
14427
14458
  var _this;
14428
14459
  _this = RefObject.call(this, engine) || this;
14429
- /** Shader data. */ _this.shaderData = new ShaderData(ShaderDataGroup.Material);
14430
14460
  /** @internal */ _this._renderStates = [] // todo: later will as a part of shaderData when shader effect frame is OK, that is more powerful and flexible.
14431
14461
  ;
14462
+ _this._shaderData = new ShaderData(ShaderDataGroup.Material);
14432
14463
  _this.shader = shader;
14433
14464
  return _this;
14434
14465
  };
@@ -14461,8 +14492,21 @@
14461
14492
  */ _proto._preRender = function _preRender(renderElement) {};
14462
14493
  /**
14463
14494
  * @override
14464
- */ _proto._onDestroy = function _onDestroy() {};
14495
+ */ _proto._onDestroy = function _onDestroy() {
14496
+ this._shader = null;
14497
+ this._shaderData = null;
14498
+ this._renderStates.length = 0;
14499
+ this._renderStates = null;
14500
+ };
14465
14501
  _create_class$3(Material, [
14502
+ {
14503
+ key: "shaderData",
14504
+ get: /**
14505
+ * Shader data.
14506
+ */ function get() {
14507
+ return this._shaderData;
14508
+ }
14509
+ },
14466
14510
  {
14467
14511
  key: "shader",
14468
14512
  get: /**
@@ -14530,6 +14574,12 @@
14530
14574
  */ _proto.resetPool = function resetPool() {
14531
14575
  this._elementPoolIndex = 0;
14532
14576
  };
14577
+ _proto.garbageCollection = function garbageCollection() {
14578
+ var _this = this, pool = _this._elementPool;
14579
+ for(var i = pool.length - 1; i >= 0; i--){
14580
+ pool[i].dispose && pool[i].dispose();
14581
+ }
14582
+ };
14533
14583
  return ClassPool;
14534
14584
  }();
14535
14585
  var RenderElement = function RenderElement() {};
@@ -14549,6 +14599,9 @@
14549
14599
  this.renderState = renderState;
14550
14600
  this.shaderPass = shaderPass;
14551
14601
  };
14602
+ _proto.dispose = function dispose() {
14603
+ this.component = this.mesh = this.subMesh = this.material = this.renderState = this.shaderPass = null;
14604
+ };
14552
14605
  return MeshRenderElement;
14553
14606
  }(RenderElement);
14554
14607
  /**
@@ -14592,6 +14645,9 @@
14592
14645
  this.renderState = renderState;
14593
14646
  this.shaderPass = shaderPass;
14594
14647
  };
14648
+ _proto.dispose = function dispose() {
14649
+ this.component = this.renderData = this.material = this.texture = this.renderState = this.shaderPass = null;
14650
+ };
14595
14651
  return SpriteElement;
14596
14652
  }(RenderElement);
14597
14653
  var SpriteMaskElement = /*#__PURE__*/ function(RenderElement) {
@@ -14609,6 +14665,9 @@
14609
14665
  this.renderData = renderData;
14610
14666
  this.material = material;
14611
14667
  };
14668
+ _proto.dispose = function dispose() {
14669
+ this.component = this.renderData = this.material = null;
14670
+ };
14612
14671
  return SpriteMaskElement;
14613
14672
  }(RenderElement);
14614
14673
  /**
@@ -14624,7 +14683,6 @@
14624
14683
  var Renderer1 = function Renderer1(entity) {
14625
14684
  var _this;
14626
14685
  _this = Component.call(this, entity) || this;
14627
- /** ShaderData related to renderer. */ _this.shaderData = new ShaderData(ShaderDataGroup.Renderer);
14628
14686
  /** @internal */ _this._onUpdateIndex = -1;
14629
14687
  /** @internal */ _this._rendererIndex = -1;
14630
14688
  /** @internal */ _this._globalShaderMacro = new ShaderMacroCollection();
@@ -14632,6 +14690,7 @@
14632
14690
  _this._overrideUpdate = false;
14633
14691
  _this._materials = [];
14634
14692
  _this._dirtyUpdateFlag = 0;
14693
+ _this._shaderData = new ShaderData(ShaderDataGroup.Renderer);
14635
14694
  _this._mvMatrix = new Matrix();
14636
14695
  _this._mvpMatrix = new Matrix();
14637
14696
  _this._mvInvMatrix = new Matrix();
@@ -14779,6 +14838,17 @@
14779
14838
  var _materials_i;
14780
14839
  (_materials_i = materials[i]) == null ? void 0 : _materials_i._addRefCount(-1);
14781
14840
  }
14841
+ this._entity = null;
14842
+ this._globalShaderMacro = null;
14843
+ this._bounds = null;
14844
+ this._materials = null;
14845
+ this._shaderData = null;
14846
+ this._mvMatrix = null;
14847
+ this._mvpMatrix = null;
14848
+ this._mvInvMatrix = null;
14849
+ this._normalMatrix = null;
14850
+ this._materialsInstanced = null;
14851
+ this._rendererLayer = null;
14782
14852
  };
14783
14853
  _proto._updateShaderData = function _updateShaderData(context) {
14784
14854
  var entity = this.entity;
@@ -14840,6 +14910,14 @@
14840
14910
  this._dirtyUpdateFlag |= 0x1;
14841
14911
  };
14842
14912
  _create_class$3(Renderer1, [
14913
+ {
14914
+ key: "shaderData",
14915
+ get: /**
14916
+ * ShaderData related to renderer.
14917
+ */ function get() {
14918
+ return this._shaderData;
14919
+ }
14920
+ },
14843
14921
  {
14844
14922
  key: "isCulled",
14845
14923
  get: /**
@@ -14924,9 +15002,6 @@
14924
15002
  }(), function() {
14925
15003
  _Renderer._rendererLayerProperty = Shader.getPropertyByName("oasis_RendererLayer");
14926
15004
  }(), _Renderer);
14927
- __decorate$1([
14928
- deepClone
14929
- ], exports.Renderer.prototype, "shaderData", void 0);
14930
15005
  __decorate$1([
14931
15006
  ignoreClone
14932
15007
  ], exports.Renderer.prototype, "_distanceForSort", void 0);
@@ -14954,6 +15029,9 @@
14954
15029
  __decorate$1([
14955
15030
  ignoreClone
14956
15031
  ], exports.Renderer.prototype, "_dirtyUpdateFlag", void 0);
15032
+ __decorate$1([
15033
+ deepClone
15034
+ ], exports.Renderer.prototype, "_shaderData", void 0);
14957
15035
  __decorate$1([
14958
15036
  ignoreClone
14959
15037
  ], exports.Renderer.prototype, "_mvMatrix", void 0);
@@ -15201,6 +15279,7 @@
15201
15279
  sprite._addRefCount(-1);
15202
15280
  sprite._updateFlagManager.removeListener(this._onSpriteChange);
15203
15281
  }
15282
+ this._entity = null;
15204
15283
  this._sprite = null;
15205
15284
  this._renderData = null;
15206
15285
  };
@@ -15795,14 +15874,19 @@
15795
15874
  }();
15796
15875
  /**
15797
15876
  * Sub-mesh, mainly contains drawing information.
15798
- */ var SubMesh = function SubMesh(start, count, topology) {
15799
- if (start === void 0) start = 0;
15800
- if (count === void 0) count = 0;
15801
- if (topology === void 0) topology = exports.MeshTopology.Triangles;
15802
- this.start = start;
15803
- this.count = count;
15804
- this.topology = topology;
15805
- };
15877
+ */ var SubMesh = /*#__PURE__*/ function() {
15878
+ var SubMesh = function SubMesh(start, count, topology) {
15879
+ if (start === void 0) start = 0;
15880
+ if (count === void 0) count = 0;
15881
+ if (topology === void 0) topology = exports.MeshTopology.Triangles;
15882
+ this.start = start;
15883
+ this.count = count;
15884
+ this.topology = topology;
15885
+ };
15886
+ var _proto = SubMesh.prototype;
15887
+ _proto.dispose = function dispose() {};
15888
+ return SubMesh;
15889
+ }();
15806
15890
  /**
15807
15891
  * Mesh.
15808
15892
  */ var Mesh = /*#__PURE__*/ function(RefObject) {
@@ -15917,6 +16001,7 @@
15917
16001
  this._indexBufferBinding = null;
15918
16002
  this._vertexElements = null;
15919
16003
  this._vertexElementMap = null;
16004
+ this._updateFlagManager = null;
15920
16005
  this._platformPrimitive.destroy();
15921
16006
  };
15922
16007
  _proto._setVertexElements = function _setVertexElements(elements) {
@@ -17596,8 +17681,8 @@
17596
17681
  */ _proto._onDestroy = function _onDestroy() {
17597
17682
  Renderer.prototype._onDestroy.call(this);
17598
17683
  var mesh = this._mesh;
17599
- if (mesh && !mesh.destroyed) {
17600
- mesh._addRefCount(-1);
17684
+ if (mesh) {
17685
+ mesh.destroyed || mesh._addRefCount(-1);
17601
17686
  mesh._updateFlagManager.removeListener(this._onMeshChanged);
17602
17687
  this._mesh = null;
17603
17688
  }
@@ -17931,10 +18016,21 @@
17931
18016
  * @internal
17932
18017
  * @override
17933
18018
  */ _proto._onDestroy = function _onDestroy() {
17934
- var _this_rootBone, _this__jointTexture;
18019
+ var _this__rootBone, _this__jointTexture;
17935
18020
  MeshRenderer.prototype._onDestroy.call(this);
17936
- (_this_rootBone = this.rootBone) == null ? void 0 : _this_rootBone.transform._updateFlagManager.removeListener(this._onTransformChanged);
18021
+ (_this__rootBone = this._rootBone) == null ? void 0 : _this__rootBone.transform._updateFlagManager.removeListener(this._onTransformChanged);
18022
+ this._rootBone = null;
18023
+ this._jointDataCreateCache = null;
18024
+ this._skin = null;
18025
+ this._blendShapeWeights = null;
18026
+ this._localBounds = null;
18027
+ this._jointMatrices = null;
17937
18028
  (_this__jointTexture = this._jointTexture) == null ? void 0 : _this__jointTexture.destroy();
18029
+ this._jointTexture = null;
18030
+ if (this._jointEntities) {
18031
+ this._jointEntities.length = 0;
18032
+ this._jointEntities = null;
18033
+ }
17938
18034
  };
17939
18035
  /**
17940
18036
  * @internal
@@ -19309,6 +19405,11 @@
19309
19405
  return _this;
19310
19406
  };
19311
19407
  _inherits$2(TextRenderElement, RenderElement);
19408
+ var _proto = TextRenderElement.prototype;
19409
+ _proto.dispose = function dispose() {
19410
+ this.component = this.material = this.renderState = this.shaderPass = null;
19411
+ this.charElements.length = 0;
19412
+ };
19312
19413
  return TextRenderElement;
19313
19414
  }(RenderElement);
19314
19415
  /**
@@ -19452,7 +19553,6 @@
19452
19553
  this.texture = null;
19453
19554
  this.solidColor = null;
19454
19555
  this.sky.destroy();
19455
- this._engine = null;
19456
19556
  };
19457
19557
  /**
19458
19558
  * @internal
@@ -19833,8 +19933,6 @@
19833
19933
  function Scene(engine, name) {
19834
19934
  var _this;
19835
19935
  _this = EngineObject.call(this, engine) || this;
19836
- /** The background of the scene. */ _this.background = new Background(_this._engine);
19837
- /** Scene-related shader data. */ _this.shaderData = new ShaderData(ShaderDataGroup.Scene);
19838
19936
  /** If cast shadows. */ _this.castShadows = true;
19839
19937
  /** The resolution of the shadow maps. */ _this.shadowResolution = exports.ShadowResolution.Medium;
19840
19938
  /** The splits of two cascade distribution. */ _this.shadowTwoCascadeSplits = 1.0 / 3.0;
@@ -19844,6 +19942,8 @@
19844
19942
  /** @internal */ _this._isActiveInEngine = false;
19845
19943
  /** @internal */ _this._globalShaderMacro = new ShaderMacroCollection();
19846
19944
  /** @internal */ _this._rootEntities = [];
19945
+ _this._background = new Background(_this._engine);
19946
+ _this._shaderData = new ShaderData(ShaderDataGroup.Scene);
19847
19947
  _this._shadowCascades = exports.ShadowCascadesMode.NoCascades;
19848
19948
  _this._fogMode = exports.FogMode.None;
19849
19949
  _this._fogColor = new Color$1(0.5, 0.5, 0.5, 1.0);
@@ -20005,6 +20105,8 @@
20005
20105
  var sunLightIndex = lightManager._getSunLightIndex();
20006
20106
  if (sunLightIndex !== -1) {
20007
20107
  this._sunLight = lightManager._directLights.get(sunLightIndex);
20108
+ } else {
20109
+ this._sunLight = null;
20008
20110
  }
20009
20111
  if (this.castShadows && this._sunLight && this._sunLight.shadowType !== exports.ShadowType.None) {
20010
20112
  shaderData.enableMacro("SHADOW_TYPE", this._sunLight.shadowType.toString());
@@ -20064,6 +20166,22 @@
20064
20166
  this._fogParams.w = density / Math.sqrt(Math.LN2);
20065
20167
  };
20066
20168
  _create_class$3(Scene, [
20169
+ {
20170
+ key: "shaderData",
20171
+ get: /**
20172
+ * Scene-related shader data.
20173
+ */ function get() {
20174
+ return this._shaderData;
20175
+ }
20176
+ },
20177
+ {
20178
+ key: "background",
20179
+ get: /**
20180
+ * The background of the scene.
20181
+ */ function get() {
20182
+ return this._background;
20183
+ }
20184
+ },
20067
20185
  {
20068
20186
  key: "shadowCascades",
20069
20187
  get: /**
@@ -22320,7 +22438,6 @@
22320
22438
  var Camera1 = function Camera1(entity) {
22321
22439
  var _this;
22322
22440
  _this = Component.call(this, entity) || this;
22323
- /** Shader data. */ _this.shaderData = new ShaderData(ShaderDataGroup.Camera);
22324
22441
  /** Rendering priority - A Camera with higher priority will be rendered on top of a camera with lower priority. */ _this.priority = 0;
22325
22442
  /** Whether to enable frustum culling, it is enabled by default. */ _this.enableFrustumCulling = true;
22326
22443
  /**
@@ -22334,6 +22451,7 @@
22334
22451
  /** @internal */ _this._globalShaderMacro = new ShaderMacroCollection();
22335
22452
  /** @internal */ _this._frustum = new BoundingFrustum();
22336
22453
  /** @internal */ _this._virtualCamera = new VirtualCamera();
22454
+ _this._shaderData = new ShaderData(ShaderDataGroup.Camera);
22337
22455
  _this._isProjMatSetting = false;
22338
22456
  _this._nearClipPlane = 0.1;
22339
22457
  _this._farClipPlane = 100;
@@ -22533,6 +22651,20 @@
22533
22651
  this._isInvViewProjDirty.destroy();
22534
22652
  this._isViewMatrixDirty.destroy();
22535
22653
  this.shaderData._addRefCount(-1);
22654
+ this._entity = null;
22655
+ this._globalShaderMacro = null;
22656
+ this._frustum = null;
22657
+ this._renderPipeline = null;
22658
+ this._virtualCamera = null;
22659
+ this._shaderData = null;
22660
+ this._frustumViewChangeFlag = null;
22661
+ this._transform = null;
22662
+ this._isViewMatrixDirty = null;
22663
+ this._isInvViewProjDirty = null;
22664
+ this._viewport = null;
22665
+ this._inverseProjectionMatrix = null;
22666
+ this._lastAspectSize = null;
22667
+ this._invViewProjMat = null;
22536
22668
  };
22537
22669
  _proto._projMatChange = function _projMatChange() {
22538
22670
  this._isFrustumProjectDirty = true;
@@ -22572,6 +22704,14 @@
22572
22704
  return this._inverseProjectionMatrix;
22573
22705
  };
22574
22706
  _create_class$3(Camera1, [
22707
+ {
22708
+ key: "shaderData",
22709
+ get: /**
22710
+ * Shader data.
22711
+ */ function get() {
22712
+ return this._shaderData;
22713
+ }
22714
+ },
22575
22715
  {
22576
22716
  key: "nearClipPlane",
22577
22717
  get: /**
@@ -24620,6 +24760,7 @@
24620
24760
  sprite._addRefCount(-1);
24621
24761
  sprite._updateFlagManager.removeListener(this._onSpriteChange);
24622
24762
  }
24763
+ this._entity = null;
24623
24764
  this._color = null;
24624
24765
  this._sprite = null;
24625
24766
  this._assembler = null;
@@ -27136,9 +27277,16 @@
27136
27277
  })(LayerState || (LayerState = {}));
27137
27278
  /**
27138
27279
  * @internal
27139
- */ var AnimationEventHandler = function AnimationEventHandler() {
27140
- this.handlers = [];
27141
- };
27280
+ */ var AnimationEventHandler = /*#__PURE__*/ function() {
27281
+ var AnimationEventHandler = function AnimationEventHandler() {
27282
+ this.handlers = [];
27283
+ };
27284
+ var _proto = AnimationEventHandler.prototype;
27285
+ _proto.dispose = function dispose() {
27286
+ this.handlers.length = 0;
27287
+ };
27288
+ return AnimationEventHandler;
27289
+ }();
27142
27290
  /**
27143
27291
  * Transitions define when and how the state machine switch from on state to another. AnimatorTransition always originate from a StateMachine or a StateMachine entry.
27144
27292
  */ var AnimatorStateTransition = function AnimatorStateTransition() {
@@ -33370,6 +33518,10 @@
33370
33518
  }
33371
33519
  glTFResource.sceneRoots = sceneRoots;
33372
33520
  glTFResource.defaultSceneRoot = sceneRoots[sceneID];
33521
+ // @ts-ignore
33522
+ glTFResource.defaultSceneRoot._hookResource = glTFResource;
33523
+ // @ts-ignore
33524
+ glTFResource._addRefCount(1);
33373
33525
  };
33374
33526
  return EntityParser;
33375
33527
  }(Parser);
@@ -34101,36 +34253,20 @@
34101
34253
  })();
34102
34254
  /**
34103
34255
  * Product after GLTF parser, usually, `defaultSceneRoot` is only needed to use.
34104
- */ var GLTFResource = /*#__PURE__*/ function(EngineObject) {
34256
+ */ var GLTFResource = /*#__PURE__*/ function(RefObject) {
34105
34257
  var GLTFResource = function GLTFResource(engine, url) {
34106
34258
  var _this;
34107
- _this = EngineObject.call(this, engine) || this;
34259
+ _this = RefObject.call(this, engine) || this;
34108
34260
  _this.url = url;
34109
34261
  return _this;
34110
34262
  };
34111
- _inherits(GLTFResource, EngineObject);
34263
+ _inherits(GLTFResource, RefObject);
34112
34264
  var _proto = GLTFResource.prototype;
34113
34265
  /**
34114
- * @override
34115
- */ _proto.destroy = function destroy() {
34116
- if (this._destroyed) {
34117
- return;
34118
- }
34119
- EngineObject.prototype.destroy.call(this);
34120
- this.defaultSceneRoot.destroy();
34121
- this.textures = null;
34122
- this.materials = null;
34123
- this.meshes = null;
34124
- this.skins = null;
34125
- this.animations = null;
34126
- this.entities = null;
34127
- this.cameras = null;
34128
- this.lights = null;
34129
- this.sceneRoots = null;
34130
- this.variants = null;
34131
- };
34266
+ * @internal
34267
+ */ _proto._onDestroy = function _onDestroy() {};
34132
34268
  return GLTFResource;
34133
- }(EngineObject);
34269
+ }(RefObject);
34134
34270
  var GLTFLoader = /*#__PURE__*/ function(Loader) {
34135
34271
  var GLTFLoader = function GLTFLoader() {
34136
34272
  return Loader.apply(this, arguments);
@@ -36139,7 +36275,7 @@
36139
36275
  }));
36140
36276
 
36141
36277
  //@ts-ignore
36142
- var version = "0.9.12";
36278
+ var version = "0.9.13";
36143
36279
  console.log("Galacean engine version: " + version);
36144
36280
  for(var key in CoreObjects){
36145
36281
  Loader.registerClass(key, CoreObjects[key]);