@galacean/engine 1.0.0-beta.10 → 1.0.0-beta.11

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
@@ -7116,6 +7116,29 @@
7116
7116
  * @remarks The release principle is that it is not referenced by the components, including direct and indirect reference.
7117
7117
  */ _proto.gc = function gc() {
7118
7118
  this._gc(false);
7119
+ var engine = this.engine;
7120
+ engine._renderElementPool.garbageCollection();
7121
+ engine._meshRenderDataPool.garbageCollection();
7122
+ engine._spriteRenderDataPool.garbageCollection();
7123
+ engine._spriteMaskRenderDataPool.garbageCollection();
7124
+ engine._textRenderDataPool.garbageCollection();
7125
+ var _componentsManager = engine._componentsManager, _lightManager = engine._lightManager;
7126
+ _componentsManager._renderers.garbageCollection();
7127
+ // @ts-ignore
7128
+ _componentsManager._onStartScripts.garbageCollection();
7129
+ // @ts-ignore
7130
+ _componentsManager._onUpdateScripts.garbageCollection();
7131
+ // @ts-ignore
7132
+ _componentsManager._onLateUpdateScripts.garbageCollection();
7133
+ // @ts-ignore
7134
+ _componentsManager._onPhysicsUpdateScripts.garbageCollection();
7135
+ // @ts-ignore
7136
+ _componentsManager._onUpdateAnimations.garbageCollection();
7137
+ // @ts-ignore
7138
+ _componentsManager._onUpdateRenderers.garbageCollection();
7139
+ _lightManager._spotLights.garbageCollection();
7140
+ _lightManager._pointLights.garbageCollection();
7141
+ _lightManager._directLights.garbageCollection();
7119
7142
  };
7120
7143
  /**
7121
7144
  * Add content restorer.
@@ -9532,6 +9555,11 @@
9532
9555
  * @returns Cloned entity
9533
9556
  */ _proto.clone = function clone() {
9534
9557
  var cloneEntity = new Entity(this._engine, this.name);
9558
+ var _this = this, hookResource = _this._hookResource;
9559
+ if (hookResource) {
9560
+ cloneEntity._hookResource = hookResource;
9561
+ hookResource._addReferCount(1);
9562
+ }
9535
9563
  cloneEntity._isActive = this._isActive;
9536
9564
  cloneEntity.transform.localMatrix = this.transform.localMatrix;
9537
9565
  var children = this._children;
@@ -9556,6 +9584,10 @@
9556
9584
  return;
9557
9585
  }
9558
9586
  EngineObject.prototype.destroy.call(this);
9587
+ if (this._hookResource) {
9588
+ this._hookResource._addReferCount(-1);
9589
+ this._hookResource = null;
9590
+ }
9559
9591
  var components = this._components;
9560
9592
  for(var i = components.length - 1; i >= 0; i--){
9561
9593
  components[i].destroy();
@@ -14146,9 +14178,9 @@
14146
14178
  var Material = function Material(engine, shader) {
14147
14179
  var _this;
14148
14180
  _this = ReferResource.call(this, engine) || this;
14149
- /** Shader data. */ _this.shaderData = new ShaderData(ShaderDataGroup.Material);
14150
14181
  /** @internal */ _this._renderStates = [] // todo: later will as a part of shaderData when shader effect frame is OK, that is more powerful and flexible.
14151
14182
  ;
14183
+ _this._shaderData = new ShaderData(ShaderDataGroup.Material);
14152
14184
  _this.shader = shader;
14153
14185
  return _this;
14154
14186
  };
@@ -14173,7 +14205,23 @@
14173
14205
  ReferResource.prototype._addReferCount.call(this, value);
14174
14206
  this.shaderData._addReferCount(value);
14175
14207
  };
14208
+ /**
14209
+ * @override
14210
+ */ _proto._onDestroy = function _onDestroy() {
14211
+ this._shader = null;
14212
+ this._shaderData = null;
14213
+ this._renderStates.length = 0;
14214
+ this._renderStates = null;
14215
+ };
14176
14216
  _create_class$3(Material, [
14217
+ {
14218
+ key: "shaderData",
14219
+ get: /**
14220
+ * Shader data.
14221
+ */ function get() {
14222
+ return this._shaderData;
14223
+ }
14224
+ },
14177
14225
  {
14178
14226
  key: "shader",
14179
14227
  get: /**
@@ -14245,6 +14293,12 @@
14245
14293
  */ _proto.resetPool = function resetPool() {
14246
14294
  this._elementPoolIndex = 0;
14247
14295
  };
14296
+ _proto.garbageCollection = function garbageCollection() {
14297
+ var _this = this, pool = _this._elementPool;
14298
+ for(var i = pool.length - 1; i >= 0; i--){
14299
+ pool[i].dispose && pool[i].dispose();
14300
+ }
14301
+ };
14248
14302
  return ClassPool;
14249
14303
  }();
14250
14304
  var RenderData = function RenderData() {};
@@ -14262,6 +14316,9 @@
14262
14316
  this.mesh = mesh;
14263
14317
  this.subMesh = subMesh;
14264
14318
  };
14319
+ _proto.dispose = function dispose() {
14320
+ this.component = this.material = this.mesh = this.subMesh = null;
14321
+ };
14265
14322
  return MeshRenderData;
14266
14323
  }(RenderData);
14267
14324
  /**
@@ -15334,6 +15391,9 @@
15334
15391
  this.shaderPass = shaderPass;
15335
15392
  this.renderState = renderState;
15336
15393
  };
15394
+ _proto.dispose = function dispose() {
15395
+ this.data = this.shaderPass = this.renderState = null;
15396
+ };
15337
15397
  return RenderElement;
15338
15398
  }();
15339
15399
  /**
@@ -15350,7 +15410,6 @@
15350
15410
  var Renderer1 = function Renderer1(entity) {
15351
15411
  var _this;
15352
15412
  _this = Component.call(this, entity) || this;
15353
- /** ShaderData related to renderer. */ _this.shaderData = new ShaderData(ShaderDataGroup.Renderer);
15354
15413
  /** @internal */ _this._onUpdateIndex = -1;
15355
15414
  /** @internal */ _this._rendererIndex = -1;
15356
15415
  /** @internal */ _this._globalShaderMacro = new ShaderMacroCollection();
@@ -15358,6 +15417,7 @@
15358
15417
  _this._overrideUpdate = false;
15359
15418
  _this._materials = [];
15360
15419
  _this._dirtyUpdateFlag = 0;
15420
+ _this._shaderData = new ShaderData(ShaderDataGroup.Renderer);
15361
15421
  _this._mvMatrix = new Matrix();
15362
15422
  _this._mvpMatrix = new Matrix();
15363
15423
  _this._mvInvMatrix = new Matrix();
@@ -15504,6 +15564,17 @@
15504
15564
  var _materials_i;
15505
15565
  (_materials_i = materials[i]) == null ? void 0 : _materials_i._addReferCount(-1);
15506
15566
  }
15567
+ this._entity = null;
15568
+ this._globalShaderMacro = null;
15569
+ this._bounds = null;
15570
+ this._materials = null;
15571
+ this._shaderData = null;
15572
+ this._mvMatrix = null;
15573
+ this._mvpMatrix = null;
15574
+ this._mvInvMatrix = null;
15575
+ this._normalMatrix = null;
15576
+ this._materialsInstanced = null;
15577
+ this._rendererLayer = null;
15507
15578
  };
15508
15579
  /**
15509
15580
  * @internal
@@ -15579,6 +15650,14 @@
15579
15650
  this._dirtyUpdateFlag |= 0x1;
15580
15651
  };
15581
15652
  _create_class$3(Renderer1, [
15653
+ {
15654
+ key: "shaderData",
15655
+ get: /**
15656
+ * ShaderData related to renderer.
15657
+ */ function get() {
15658
+ return this._shaderData;
15659
+ }
15660
+ },
15582
15661
  {
15583
15662
  key: "isCulled",
15584
15663
  get: /**
@@ -15663,9 +15742,6 @@
15663
15742
  }(), function() {
15664
15743
  _Renderer._rendererLayerProperty = ShaderProperty.getByName("renderer_Layer");
15665
15744
  }(), _Renderer);
15666
- __decorate$1([
15667
- deepClone
15668
- ], exports.Renderer.prototype, "shaderData", void 0);
15669
15745
  __decorate$1([
15670
15746
  ignoreClone
15671
15747
  ], exports.Renderer.prototype, "_distanceForSort", void 0);
@@ -15693,6 +15769,9 @@
15693
15769
  __decorate$1([
15694
15770
  ignoreClone
15695
15771
  ], exports.Renderer.prototype, "_dirtyUpdateFlag", void 0);
15772
+ __decorate$1([
15773
+ deepClone
15774
+ ], exports.Renderer.prototype, "_shaderData", void 0);
15696
15775
  __decorate$1([
15697
15776
  ignoreClone
15698
15777
  ], exports.Renderer.prototype, "_mvMatrix", void 0);
@@ -15942,6 +16021,7 @@
15942
16021
  sprite._addReferCount(-1);
15943
16022
  sprite._updateFlagManager.removeListener(this._onSpriteChange);
15944
16023
  }
16024
+ this._entity = null;
15945
16025
  this._sprite = null;
15946
16026
  this._verticesData = null;
15947
16027
  };
@@ -16485,14 +16565,19 @@
16485
16565
  }();
16486
16566
  /**
16487
16567
  * Sub-mesh, mainly contains drawing information.
16488
- */ var SubMesh = function SubMesh(start, count, topology) {
16489
- if (start === void 0) start = 0;
16490
- if (count === void 0) count = 0;
16491
- if (topology === void 0) topology = exports.MeshTopology.Triangles;
16492
- this.start = start;
16493
- this.count = count;
16494
- this.topology = topology;
16495
- };
16568
+ */ var SubMesh = /*#__PURE__*/ function() {
16569
+ var SubMesh = function SubMesh(start, count, topology) {
16570
+ if (start === void 0) start = 0;
16571
+ if (count === void 0) count = 0;
16572
+ if (topology === void 0) topology = exports.MeshTopology.Triangles;
16573
+ this.start = start;
16574
+ this.count = count;
16575
+ this.topology = topology;
16576
+ };
16577
+ var _proto = SubMesh.prototype;
16578
+ _proto.dispose = function dispose() {};
16579
+ return SubMesh;
16580
+ }();
16496
16581
  /**
16497
16582
  * Mesh.
16498
16583
  */ var Mesh = /*#__PURE__*/ function(GraphicsResource) {
@@ -18241,8 +18326,8 @@
18241
18326
  */ _proto._onDestroy = function _onDestroy() {
18242
18327
  Renderer.prototype._onDestroy.call(this);
18243
18328
  var mesh = this._mesh;
18244
- if (mesh && !mesh.destroyed) {
18245
- mesh._addReferCount(-1);
18329
+ if (mesh) {
18330
+ mesh.destroyed || mesh._addReferCount(-1);
18246
18331
  mesh._updateFlagManager.removeListener(this._onMeshChanged);
18247
18332
  this._mesh = null;
18248
18333
  }
@@ -18497,10 +18582,21 @@
18497
18582
  /**
18498
18583
  * @internal
18499
18584
  */ _proto._onDestroy = function _onDestroy() {
18500
- var _this_rootBone, _this__jointTexture;
18585
+ var _this__rootBone, _this__jointTexture;
18501
18586
  MeshRenderer.prototype._onDestroy.call(this);
18502
- (_this_rootBone = this.rootBone) == null ? void 0 : _this_rootBone.transform._updateFlagManager.removeListener(this._onTransformChanged);
18587
+ (_this__rootBone = this._rootBone) == null ? void 0 : _this__rootBone.transform._updateFlagManager.removeListener(this._onTransformChanged);
18588
+ this._rootBone = null;
18589
+ this._jointDataCreateCache = null;
18590
+ this._skin = null;
18591
+ this._blendShapeWeights = null;
18592
+ this._localBounds = null;
18593
+ this._jointMatrices = null;
18503
18594
  (_this__jointTexture = this._jointTexture) == null ? void 0 : _this__jointTexture.destroy();
18595
+ this._jointTexture = null;
18596
+ if (this._jointEntities) {
18597
+ this._jointEntities.length = 0;
18598
+ this._jointEntities = null;
18599
+ }
18504
18600
  };
18505
18601
  /**
18506
18602
  * @internal
@@ -20188,6 +20284,9 @@
20188
20284
  this.material = material;
20189
20285
  this.verticesData = verticesData;
20190
20286
  };
20287
+ _proto.dispose = function dispose() {
20288
+ this.component = this.material = this.verticesData = null;
20289
+ };
20191
20290
  return SpriteMaskRenderData;
20192
20291
  }(RenderData);
20193
20292
  var SpriteRenderData = /*#__PURE__*/ function(RenderData) {
@@ -20207,6 +20306,9 @@
20207
20306
  this.texture = texture;
20208
20307
  this.dataIndex = dataIndex;
20209
20308
  };
20309
+ _proto.dispose = function dispose() {
20310
+ this.component = this.material = this.verticesData = this.texture = null;
20311
+ };
20210
20312
  return SpriteRenderData;
20211
20313
  }(RenderData);
20212
20314
  var TextRenderData = /*#__PURE__*/ function(RenderData) {
@@ -20218,6 +20320,11 @@
20218
20320
  return _this;
20219
20321
  };
20220
20322
  _inherits$2(TextRenderData, RenderData);
20323
+ var _proto = TextRenderData.prototype;
20324
+ _proto.dispose = function dispose() {
20325
+ this.component = this.material = null;
20326
+ this.charsData.length = 0;
20327
+ };
20221
20328
  return TextRenderData;
20222
20329
  }(RenderData);
20223
20330
  /**
@@ -20743,8 +20850,6 @@
20743
20850
  function Scene(engine, name) {
20744
20851
  var _this;
20745
20852
  _this = EngineObject.call(this, engine) || this;
20746
- /** The background of the scene. */ _this.background = new Background(_this._engine);
20747
- /** Scene-related shader data. */ _this.shaderData = new ShaderData(ShaderDataGroup.Scene);
20748
20853
  /** If cast shadows. */ _this.castShadows = true;
20749
20854
  /** The resolution of the shadow maps. */ _this.shadowResolution = exports.ShadowResolution.Medium;
20750
20855
  /** The splits of two cascade distribution. */ _this.shadowTwoCascadeSplits = 1.0 / 3.0;
@@ -20754,6 +20859,8 @@
20754
20859
  /** @internal */ _this._isActiveInEngine = false;
20755
20860
  /** @internal */ _this._globalShaderMacro = new ShaderMacroCollection();
20756
20861
  /** @internal */ _this._rootEntities = [];
20862
+ _this._background = new Background(_this._engine);
20863
+ _this._shaderData = new ShaderData(ShaderDataGroup.Scene);
20757
20864
  _this._shadowCascades = exports.ShadowCascadesMode.NoCascades;
20758
20865
  _this._fogMode = exports.FogMode.None;
20759
20866
  _this._fogColor = new Color$1(0.5, 0.5, 0.5, 1.0);
@@ -20920,6 +21027,8 @@
20920
21027
  shaderData.setColor(Scene._sunlightColorProperty, sunlight._getLightIntensityColor());
20921
21028
  shaderData.setVector3(Scene._sunlightDirectionProperty, sunlight.direction);
20922
21029
  this._sunLight = sunlight;
21030
+ } else {
21031
+ this._sunLight = null;
20923
21032
  }
20924
21033
  if (this.castShadows && this._sunLight && this._sunLight.shadowType !== exports.ShadowType.None) {
20925
21034
  shaderData.enableMacro("SCENE_SHADOW_TYPE", this._sunLight.shadowType.toString());
@@ -20979,6 +21088,22 @@
20979
21088
  this._fogParams.w = density / Math.sqrt(Math.LN2);
20980
21089
  };
20981
21090
  _create_class$3(Scene, [
21091
+ {
21092
+ key: "shaderData",
21093
+ get: /**
21094
+ * Scene-related shader data.
21095
+ */ function get() {
21096
+ return this._shaderData;
21097
+ }
21098
+ },
21099
+ {
21100
+ key: "background",
21101
+ get: /**
21102
+ * The background of the scene.
21103
+ */ function get() {
21104
+ return this._background;
21105
+ }
21106
+ },
20982
21107
  {
20983
21108
  key: "shadowCascades",
20984
21109
  get: /**
@@ -23410,7 +23535,6 @@
23410
23535
  var Camera1 = function Camera1(entity) {
23411
23536
  var _this;
23412
23537
  _this = Component.call(this, entity) || this;
23413
- /** Shader data. */ _this.shaderData = new ShaderData(ShaderDataGroup.Camera);
23414
23538
  /** Rendering priority - A Camera with higher priority will be rendered on top of a camera with lower priority. */ _this.priority = 0;
23415
23539
  /** Whether to enable frustum culling, it is enabled by default. */ _this.enableFrustumCulling = true;
23416
23540
  /**
@@ -23426,6 +23550,7 @@
23426
23550
  /** @internal */ _this._virtualCamera = new VirtualCamera();
23427
23551
  /** @internal */ _this._replacementShader = null;
23428
23552
  /** @internal */ _this._replacementSubShaderTag = null;
23553
+ _this._shaderData = new ShaderData(ShaderDataGroup.Camera);
23429
23554
  _this._isProjMatSetting = false;
23430
23555
  _this._nearClipPlane = 0.1;
23431
23556
  _this._farClipPlane = 100;
@@ -23636,6 +23761,20 @@
23636
23761
  this._isInvViewProjDirty.destroy();
23637
23762
  this._isViewMatrixDirty.destroy();
23638
23763
  this.shaderData._addReferCount(-1);
23764
+ this._entity = null;
23765
+ this._globalShaderMacro = null;
23766
+ this._frustum = null;
23767
+ this._renderPipeline = null;
23768
+ this._virtualCamera = null;
23769
+ this._shaderData = null;
23770
+ this._frustumViewChangeFlag = null;
23771
+ this._transform = null;
23772
+ this._isViewMatrixDirty = null;
23773
+ this._isInvViewProjDirty = null;
23774
+ this._viewport = null;
23775
+ this._inverseProjectionMatrix = null;
23776
+ this._lastAspectSize = null;
23777
+ this._invViewProjMat = null;
23639
23778
  };
23640
23779
  _proto._projMatChange = function _projMatChange() {
23641
23780
  this._isFrustumProjectDirty = true;
@@ -23675,6 +23814,14 @@
23675
23814
  return this._inverseProjectionMatrix;
23676
23815
  };
23677
23816
  _create_class$3(Camera1, [
23817
+ {
23818
+ key: "shaderData",
23819
+ get: /**
23820
+ * Shader data.
23821
+ */ function get() {
23822
+ return this._shaderData;
23823
+ }
23824
+ },
23678
23825
  {
23679
23826
  key: "nearClipPlane",
23680
23827
  get: /**
@@ -26064,6 +26211,7 @@
26064
26211
  sprite._addReferCount(-1);
26065
26212
  sprite._updateFlagManager.removeListener(this._onSpriteChange);
26066
26213
  }
26214
+ this._entity = null;
26067
26215
  this._color = null;
26068
26216
  this._sprite = null;
26069
26217
  this._assembler = null;
@@ -28336,9 +28484,14 @@
28336
28484
  })(LayerState || (LayerState = {}));
28337
28485
  /**
28338
28486
  * @internal
28339
- */ var AnimationEventHandler = function AnimationEventHandler() {
28340
- this.handlers = [];
28341
- };
28487
+ */ var AnimationEventHandler = /*#__PURE__*/ function() {
28488
+ var AnimationEventHandler = function AnimationEventHandler() {
28489
+ this.handlers = [];
28490
+ };
28491
+ var _proto = AnimationEventHandler.prototype;
28492
+ _proto.dispose = function dispose() {};
28493
+ return AnimationEventHandler;
28494
+ }();
28342
28495
  /**
28343
28496
  * Transitions define when and how the state machine switch from on state to another. AnimatorTransition always originate from a StateMachine or a StateMachine entry.
28344
28497
  */ var AnimatorStateTransition = function AnimatorStateTransition() {
@@ -34817,6 +34970,10 @@
34817
34970
  }
34818
34971
  glTFResource.sceneRoots = sceneRoots;
34819
34972
  glTFResource.defaultSceneRoot = sceneRoots[sceneID];
34973
+ // @ts-ignore
34974
+ glTFResource.defaultSceneRoot._hookResource = glTFResource;
34975
+ // @ts-ignore
34976
+ glTFResource._addReferCount(1);
34820
34977
  };
34821
34978
  return GLTFEntityParser;
34822
34979
  }(GLTFParser);
@@ -35548,33 +35705,16 @@
35548
35705
  })();
35549
35706
  /**
35550
35707
  * Product after glTF parser, usually, `defaultSceneRoot` is only needed to use.
35551
- */ var GLTFResource = /*#__PURE__*/ function(EngineObject) {
35708
+ */ var GLTFResource = /*#__PURE__*/ function(ReferResource) {
35552
35709
  var GLTFResource = function GLTFResource(engine, url) {
35553
35710
  var _this;
35554
- _this = EngineObject.call(this, engine) || this;
35711
+ _this = ReferResource.call(this, engine) || this;
35555
35712
  _this.url = url;
35556
35713
  return _this;
35557
35714
  };
35558
- _inherits(GLTFResource, EngineObject);
35559
- var _proto = GLTFResource.prototype;
35560
- /**
35561
- * @internal
35562
- */ _proto._onDestroy = function _onDestroy() {
35563
- EngineObject.prototype._onDestroy.call(this);
35564
- this.defaultSceneRoot.destroy();
35565
- this.textures = null;
35566
- this.materials = null;
35567
- this.meshes = null;
35568
- this.skins = null;
35569
- this.animations = null;
35570
- this.entities = null;
35571
- this.cameras = null;
35572
- this.lights = null;
35573
- this.sceneRoots = null;
35574
- this.extensionsData = null;
35575
- };
35715
+ _inherits(GLTFResource, ReferResource);
35576
35716
  return GLTFResource;
35577
- }(EngineObject);
35717
+ }(ReferResource);
35578
35718
  var GLTFLoader = /*#__PURE__*/ function(Loader) {
35579
35719
  var GLTFLoader = function GLTFLoader() {
35580
35720
  return Loader.apply(this, arguments);
@@ -38016,7 +38156,7 @@
38016
38156
  ], GALACEAN_animation_event);
38017
38157
 
38018
38158
  //@ts-ignore
38019
- var version = "1.0.0-beta.10";
38159
+ var version = "1.0.0-beta.11";
38020
38160
  console.log("Galacean engine version: " + version);
38021
38161
  for(var key in CoreObjects){
38022
38162
  Loader.registerClass(key, CoreObjects[key]);