@galacean/engine-physics-lite 0.0.0-experimental-0.9-plus.6 → 0.0.0-experimental-0.9-plus.7

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.
@@ -2734,9 +2734,11 @@ function ObjectValues(obj) {
2734
2734
  renderTexture
2735
2735
  ];
2736
2736
  for(var i = 0, n = colorTextures.length; i < n; i++){
2737
- if (colorTextures[i]._isDepthTexture) {
2737
+ var colorTexture = colorTextures[i];
2738
+ if (colorTexture._isDepthTexture) {
2738
2739
  throw "Render texture can't use depth format.";
2739
2740
  }
2741
+ colorTexture._addRefCount(1);
2740
2742
  }
2741
2743
  _this._colorTextures = colorTextures;
2742
2744
  } else {
@@ -2747,6 +2749,7 @@ function ObjectValues(obj) {
2747
2749
  throw "Depth texture must use depth format.";
2748
2750
  }
2749
2751
  _this._depthTexture = depth;
2752
+ _this._depthTexture._addRefCount(1);
2750
2753
  }
2751
2754
  _this._platformRenderTarget = engine._hardwareRenderer.createPlatformRenderTarget(_assert_this_initialized(_this));
2752
2755
  return _this;
@@ -2776,8 +2779,14 @@ function ObjectValues(obj) {
2776
2779
  /**
2777
2780
  * Destroy render target.
2778
2781
  */ _proto.destroy = function destroy() {
2782
+ var _this__depthTexture;
2779
2783
  this._platformRenderTarget.destroy();
2780
- this._colorTextures.length = 0;
2784
+ var _this = this, colorTextures = _this._colorTextures;
2785
+ for(var i = 0, n = colorTextures.length; i < n; i++){
2786
+ colorTextures[i]._addRefCount(-1);
2787
+ }
2788
+ colorTextures.length = 0;
2789
+ (_this__depthTexture = this._depthTexture) == null ? void 0 : _this__depthTexture._addRefCount(-1);
2781
2790
  this._depthTexture = null;
2782
2791
  this._depth = null;
2783
2792
  };
@@ -3218,6 +3227,7 @@ function ObjectValues(obj) {
3218
3227
  var fontAtlas = new FontAtlas(engine);
3219
3228
  var texture = new Texture2D(engine, 256, 256);
3220
3229
  fontAtlas.texture = texture;
3230
+ fontAtlas.isGCIgnored = texture.isGCIgnored = true;
3221
3231
  this._fontAtlases.push(fontAtlas);
3222
3232
  return fontAtlas;
3223
3233
  };
@@ -8693,6 +8703,7 @@ exports.DynamicColliderConstraints = void 0;
8693
8703
  _proto.cloneTo = function cloneTo(target) {
8694
8704
  CloneManager.deepCloneObject(this._macroCollection, target._macroCollection);
8695
8705
  Object.assign(target._macroMap, this._macroMap);
8706
+ var referCount = target._getRefCount();
8696
8707
  var propertyValueMap = this._propertyValueMap;
8697
8708
  var targetPropertyValueMap = target._propertyValueMap;
8698
8709
  var keys = Object.keys(propertyValueMap);
@@ -8704,6 +8715,7 @@ exports.DynamicColliderConstraints = void 0;
8704
8715
  targetPropertyValueMap[k] = property;
8705
8716
  } else if (_instanceof1$2(property, Texture)) {
8706
8717
  targetPropertyValueMap[k] = property;
8718
+ referCount > 0 && property._addRefCount(referCount);
8707
8719
  } else if (_instanceof1$2(property, Array) || _instanceof1$2(property, Float32Array) || _instanceof1$2(property, Int32Array)) {
8708
8720
  targetPropertyValueMap[k] = property.slice();
8709
8721
  } else {
@@ -10420,16 +10432,6 @@ SimpleSpriteAssembler = __decorate$1([
10420
10432
  }
10421
10433
  var _proto = SpriteMask.prototype;
10422
10434
  /**
10423
- * @override
10424
- * @inheritdoc
10425
- */ _proto._onDestroy = function _onDestroy() {
10426
- var _this__sprite;
10427
- (_this__sprite = this._sprite) == null ? void 0 : _this__sprite._updateFlagManager.removeListener(this._onSpriteChange);
10428
- this._sprite = null;
10429
- this._renderData = null;
10430
- Renderer.prototype._onDestroy.call(this);
10431
- };
10432
- /**
10433
10435
  * @internal
10434
10436
  */ _proto._cloneTo = function _cloneTo(target) {
10435
10437
  Renderer.prototype._cloneTo.call(this, target);
@@ -10469,6 +10471,19 @@ SimpleSpriteAssembler = __decorate$1([
10469
10471
  context.camera._renderPipeline._allSpriteMasks.add(this);
10470
10472
  this._maskElement = maskElement;
10471
10473
  };
10474
+ /**
10475
+ * @internal
10476
+ * @inheritdoc
10477
+ */ _proto._onDestroy = function _onDestroy() {
10478
+ Renderer.prototype._onDestroy.call(this);
10479
+ var sprite = this._sprite;
10480
+ if (sprite) {
10481
+ sprite._addRefCount(-1);
10482
+ sprite._updateFlagManager.removeListener(this._onSpriteChange);
10483
+ }
10484
+ this._sprite = null;
10485
+ this._renderData = null;
10486
+ };
10472
10487
  _proto._calDefaultSize = function _calDefaultSize() {
10473
10488
  var sprite = this._sprite;
10474
10489
  if (sprite) {
@@ -10587,9 +10602,13 @@ SimpleSpriteAssembler = __decorate$1([
10587
10602
  set: function set(value) {
10588
10603
  var lastSprite = this._sprite;
10589
10604
  if (lastSprite !== value) {
10590
- lastSprite && lastSprite._updateFlagManager.removeListener(this._onSpriteChange);
10605
+ if (lastSprite) {
10606
+ lastSprite._addRefCount(-1);
10607
+ lastSprite._updateFlagManager.removeListener(this._onSpriteChange);
10608
+ }
10591
10609
  this._dirtyUpdateFlag |= 0x7;
10592
10610
  if (value) {
10611
+ value._addRefCount(1);
10593
10612
  value._updateFlagManager.addListener(this._onSpriteChange);
10594
10613
  this.shaderData.setTexture(SpriteMask._textureProperty, value.texture);
10595
10614
  } else {
@@ -11144,10 +11163,11 @@ var BufferUtil = /*#__PURE__*/ function() {
11144
11163
  /**
11145
11164
  * @internal
11146
11165
  */ _proto._setVertexBufferBinding = function _setVertexBufferBinding(index, binding) {
11147
- if (this._getRefCount() > 0) {
11148
- var lastBinding = this._vertexBufferBindings[index];
11149
- lastBinding && lastBinding._buffer._addRefCount(-1);
11150
- binding._buffer._addRefCount(1);
11166
+ var referCount = this._getRefCount();
11167
+ if (referCount > 0) {
11168
+ var _this__vertexBufferBindings_index;
11169
+ (_this__vertexBufferBindings_index = this._vertexBufferBindings[index]) == null ? void 0 : _this__vertexBufferBindings_index._buffer._addRefCount(-referCount);
11170
+ binding == null ? void 0 : binding._buffer._addRefCount(referCount);
11151
11171
  }
11152
11172
  this._vertexBufferBindings[index] = binding;
11153
11173
  this._bufferStructChanged = true;
@@ -11161,11 +11181,13 @@ var BufferUtil = /*#__PURE__*/ function() {
11161
11181
  /**
11162
11182
  * @override
11163
11183
  */ _proto._addRefCount = function _addRefCount(value) {
11184
+ var _this__indexBufferBinding;
11164
11185
  RefObject.prototype._addRefCount.call(this, value);
11165
11186
  var vertexBufferBindings = this._vertexBufferBindings;
11166
11187
  for(var i = 0, n = vertexBufferBindings.length; i < n; i++){
11167
11188
  vertexBufferBindings[i]._buffer._addRefCount(value);
11168
11189
  }
11190
+ (_this__indexBufferBinding = this._indexBufferBinding) == null ? void 0 : _this__indexBufferBinding._buffer._addRefCount(value);
11169
11191
  };
11170
11192
  /**
11171
11193
  * @override
@@ -11185,6 +11207,11 @@ var BufferUtil = /*#__PURE__*/ function() {
11185
11207
  };
11186
11208
  _proto._setIndexBufferBinding = function _setIndexBufferBinding(binding) {
11187
11209
  var lastBinding = this._indexBufferBinding;
11210
+ var referCount = this._getRefCount();
11211
+ if (referCount > 0) {
11212
+ lastBinding == null ? void 0 : lastBinding.buffer._addRefCount(-referCount);
11213
+ binding == null ? void 0 : binding.buffer._addRefCount(referCount);
11214
+ }
11188
11215
  if (binding) {
11189
11216
  this._indexBufferBinding = binding;
11190
11217
  this._glIndexType = BufferUtil._getGLIndexType(binding.format);
@@ -14344,14 +14371,17 @@ var Basic2DBatcher = /*#__PURE__*/ function() {
14344
14371
  _proto._createMesh = function _createMesh(engine, index) {
14345
14372
  var MAX_VERTEX_COUNT = Basic2DBatcher.MAX_VERTEX_COUNT;
14346
14373
  var mesh = new BufferMesh(engine, "BufferMesh" + index);
14374
+ mesh.isGCIgnored = true;
14347
14375
  var vertexElements = [];
14348
14376
  var vertexStride = this.createVertexElements(vertexElements);
14349
14377
  // vertices
14350
- this._vertexBuffers[index] = new Buffer(engine, exports.BufferBindFlag.VertexBuffer, MAX_VERTEX_COUNT * 4 * vertexStride, exports.BufferUsage.Dynamic);
14378
+ var vertexBuffer = this._vertexBuffers[index] = new Buffer(engine, exports.BufferBindFlag.VertexBuffer, MAX_VERTEX_COUNT * 4 * vertexStride, exports.BufferUsage.Dynamic);
14379
+ vertexBuffer.isGCIgnored = true;
14351
14380
  // indices
14352
- this._indiceBuffers[index] = new Buffer(engine, exports.BufferBindFlag.IndexBuffer, MAX_VERTEX_COUNT * 2 * 3, exports.BufferUsage.Dynamic);
14353
- mesh.setVertexBufferBinding(this._vertexBuffers[index], vertexStride);
14354
- mesh.setIndexBufferBinding(this._indiceBuffers[index], exports.IndexFormat.UInt16);
14381
+ var indiceBuffer = this._indiceBuffers[index] = new Buffer(engine, exports.BufferBindFlag.IndexBuffer, MAX_VERTEX_COUNT * 2 * 3, exports.BufferUsage.Dynamic);
14382
+ indiceBuffer.isGCIgnored = true;
14383
+ mesh.setVertexBufferBinding(vertexBuffer, vertexStride);
14384
+ mesh.setIndexBufferBinding(indiceBuffer, exports.IndexFormat.UInt16);
14355
14385
  mesh.setVertexElements(vertexElements);
14356
14386
  return mesh;
14357
14387
  };
@@ -14584,6 +14614,12 @@ var TextRenderElement = /*#__PURE__*/ function(RenderElement) {
14584
14614
  var _proto = Sky.prototype;
14585
14615
  /**
14586
14616
  * @internal
14617
+ */ _proto.destroy = function destroy() {
14618
+ this.mesh = null;
14619
+ this.material = null;
14620
+ };
14621
+ /**
14622
+ * @internal
14587
14623
  */ _proto._render = function _render(context) {
14588
14624
  var _this = this, material = _this.material, mesh = _this.mesh;
14589
14625
  if (!material) {
@@ -14622,6 +14658,40 @@ var TextRenderElement = /*#__PURE__*/ function(RenderElement) {
14622
14658
  rhi.drawPrimitive(mesh, mesh.subMesh, program);
14623
14659
  cameraShaderData.setMatrix(RenderContext._vpMatrixProperty, originViewProjMatrix);
14624
14660
  };
14661
+ _create_class$2(Sky, [
14662
+ {
14663
+ key: "material",
14664
+ get: /**
14665
+ * Material of the sky.
14666
+ */ function get() {
14667
+ return this._material;
14668
+ },
14669
+ set: function set(value) {
14670
+ if (this._material !== value) {
14671
+ var _this__material;
14672
+ value == null ? void 0 : value._addRefCount(1);
14673
+ (_this__material = this._material) == null ? void 0 : _this__material._addRefCount(-1);
14674
+ this._material = value;
14675
+ }
14676
+ }
14677
+ },
14678
+ {
14679
+ key: "mesh",
14680
+ get: /**
14681
+ * Mesh of the sky.
14682
+ */ function get() {
14683
+ return this._mesh;
14684
+ },
14685
+ set: function set(value) {
14686
+ if (this._mesh !== value) {
14687
+ var _this__mesh;
14688
+ value == null ? void 0 : value._addRefCount(1);
14689
+ (_this__mesh = this._mesh) == null ? void 0 : _this__mesh._addRefCount(-1);
14690
+ this._mesh = value;
14691
+ }
14692
+ }
14693
+ }
14694
+ ]);
14625
14695
  return Sky;
14626
14696
  }();
14627
14697
  (function() {
@@ -14651,11 +14721,28 @@ var TextRenderElement = /*#__PURE__*/ function(RenderElement) {
14651
14721
  this.sky = new Sky();
14652
14722
  this./** @internal */ _textureFillMode = exports.BackgroundTextureFillMode.AspectFitHeight;
14653
14723
  this._texture = null;
14654
- this._mesh = this._createPlane(_engine);
14724
+ this._initMesh(_engine);
14655
14725
  };
14656
14726
  var _proto = Background.prototype;
14657
14727
  /**
14658
14728
  * @internal
14729
+ */ _proto.destroy = function destroy() {
14730
+ this._mesh._addRefCount(-1);
14731
+ this._mesh = null;
14732
+ this.texture = null;
14733
+ this.solidColor = null;
14734
+ this.sky.destroy();
14735
+ this._engine = null;
14736
+ };
14737
+ /**
14738
+ * @internal
14739
+ * Standalone for CanvasRenderer plugin.
14740
+ */ _proto._initMesh = function _initMesh(engine) {
14741
+ this._mesh = this._createPlane(engine);
14742
+ this._mesh._addRefCount(1);
14743
+ };
14744
+ /**
14745
+ * @internal
14659
14746
  */ _proto._resizeBackgroundTexture = function _resizeBackgroundTexture() {
14660
14747
  if (!this._texture) {
14661
14748
  return;
@@ -14724,6 +14811,9 @@ var TextRenderElement = /*#__PURE__*/ function(RenderElement) {
14724
14811
  },
14725
14812
  set: function set(value) {
14726
14813
  if (this._texture !== value) {
14814
+ var _this__texture;
14815
+ value == null ? void 0 : value._addRefCount(1);
14816
+ (_this__texture = this._texture) == null ? void 0 : _this__texture._addRefCount(-1);
14727
14817
  this._texture = value;
14728
14818
  this._engine._backgroundTextureMaterial.shaderData.setTexture("u_baseTexture", value);
14729
14819
  }
@@ -15232,6 +15322,7 @@ var TextRenderElement = /*#__PURE__*/ function(RenderElement) {
15232
15322
  this._rootEntities[0].destroy();
15233
15323
  }
15234
15324
  this._activeCameras.length = 0;
15325
+ this.background.destroy();
15235
15326
  this.shaderData._addRefCount(-1);
15236
15327
  };
15237
15328
  _proto._addToRootEntityList = function _addToRootEntityList(index, rootEntity) {
@@ -15628,7 +15719,7 @@ ShaderPool.init();
15628
15719
  _this._spriteDefaultMaterial = _this._createSpriteMaterial();
15629
15720
  _this._spriteMaskDefaultMaterial = _this._createSpriteMaskMaterial();
15630
15721
  _this._textDefaultFont = Font.createFromOS(_assert_this_initialized(_this), "Arial");
15631
- _this._textDefaultFont.isGCIgnored = false;
15722
+ _this._textDefaultFont.isGCIgnored = true;
15632
15723
  _this.inputManager = new InputManager(_assert_this_initialized(_this));
15633
15724
  var magentaPixel = new Uint8Array([
15634
15725
  255,
@@ -15663,6 +15754,7 @@ ShaderPool.init();
15663
15754
  _this._magentaTexture2DArray = magentaTexture2DArray;
15664
15755
  }
15665
15756
  var magentaMaterial = new Material(_assert_this_initialized(_this), Shader.find("unlit"));
15757
+ magentaMaterial.isGCIgnored = true;
15666
15758
  magentaMaterial.shaderData.setColor("u_baseColor", new Color(1.0, 0.0, 1.01, 1.0));
15667
15759
  _this._magentaMaterial = magentaMaterial;
15668
15760
  var backgroundTextureMaterial = new Material(_assert_this_initialized(_this), Shader.find("background-texture"));
@@ -17188,7 +17280,11 @@ var /**
17188
17280
  var height = shadowCascades == exports.ShadowCascadesMode.TwoCascades ? shadowTileResolution : shadowTileResolution * 2;
17189
17281
  this._shadowMapSize.set(1.0 / width, 1.0 / height, width, height);
17190
17282
  }
17191
- this._renderTargets = null;
17283
+ var renderTargets = this._renderTargets;
17284
+ if (renderTargets) {
17285
+ renderTargets.destroy();
17286
+ this._renderTargets = null;
17287
+ }
17192
17288
  var viewportOffset = this._viewportOffsets;
17193
17289
  var shadowTileResolution1 = this._shadowTileResolution;
17194
17290
  switch(shadowCascades){
@@ -19210,10 +19306,17 @@ exports.TextVerticalAlignment = void 0;
19210
19306
  * @internal
19211
19307
  */ _proto._addSprite = function _addSprite(sprite) {
19212
19308
  this._spriteNamesToIndex[sprite.name] = this._sprites.push(sprite) - 1;
19309
+ sprite._atlas = this;
19310
+ sprite.isGCIgnored = true;
19213
19311
  };
19214
19312
  /**
19215
19313
  * @override
19216
19314
  */ _proto._onDestroy = function _onDestroy() {
19315
+ var _this = this, sprites = _this._sprites;
19316
+ for(var i = 0, n = sprites.length; i < n; i++){
19317
+ sprites[i].destroy();
19318
+ }
19319
+ sprites.length = 0;
19217
19320
  this._sprites = null;
19218
19321
  this._spriteNamesToIndex = null;
19219
19322
  };
@@ -19312,10 +19415,29 @@ exports.TextVerticalAlignment = void 0;
19312
19415
  };
19313
19416
  /**
19314
19417
  * @override
19418
+ * @internal
19419
+ */ _proto._addRefCount = function _addRefCount(value) {
19420
+ var _this__atlas;
19421
+ RefObject.prototype._addRefCount.call(this, value);
19422
+ (_this__atlas = this._atlas) == null ? void 0 : _this__atlas._addRefCount(value);
19423
+ };
19424
+ /**
19425
+ * @override
19426
+ * @internal
19315
19427
  */ _proto._onDestroy = function _onDestroy() {
19316
- if (this._texture) {
19317
- this._texture = null;
19318
- }
19428
+ this._positions.length = 0;
19429
+ this._positions = null;
19430
+ this._uvs.length = 0;
19431
+ this._uvs = null;
19432
+ this._atlasRegion = null;
19433
+ this._atlasRegionOffset = null;
19434
+ this._region = null;
19435
+ this._pivot = null;
19436
+ this._border = null;
19437
+ this._bounds = null;
19438
+ this._atlas = null;
19439
+ this._texture = null;
19440
+ this._updateFlagManager = null;
19319
19441
  };
19320
19442
  _proto._calDefaultSize = function _calDefaultSize() {
19321
19443
  if (this._texture) {
@@ -19418,7 +19540,7 @@ exports.TextVerticalAlignment = void 0;
19418
19540
  key: "width",
19419
19541
  get: /**
19420
19542
  * The width of the sprite (in world coordinates).
19421
- *
19543
+ *
19422
19544
  * @remarks
19423
19545
  * If width is set, return the set value,
19424
19546
  * otherwise return the width calculated according to `Texture.width`, `Sprite.region`, `Sprite.atlasRegion`, `Sprite.atlasRegionOffset` and `Engine._pixelsPerUnit`.
@@ -19441,7 +19563,7 @@ exports.TextVerticalAlignment = void 0;
19441
19563
  key: "height",
19442
19564
  get: /**
19443
19565
  * The height of the sprite (in world coordinates).
19444
- *
19566
+ *
19445
19567
  * @remarks
19446
19568
  * If height is set, return the set value,
19447
19569
  * otherwise return the height calculated according to `Texture.height`, `Sprite.region`, `Sprite.atlasRegion`, `Sprite.atlasRegionOffset` and `Engine._pixelsPerUnit`.
@@ -19747,17 +19869,6 @@ SlicedSpriteAssembler = __decorate$1([
19747
19869
  target.drawMode = this._drawMode;
19748
19870
  };
19749
19871
  /**
19750
- * @internal
19751
- */ _proto._onDestroy = function _onDestroy() {
19752
- var _this__sprite;
19753
- (_this__sprite = this._sprite) == null ? void 0 : _this__sprite._updateFlagManager.removeListener(this._onSpriteChange);
19754
- this._color = null;
19755
- this._sprite = null;
19756
- this._assembler = null;
19757
- this._renderData = null;
19758
- Renderer.prototype._onDestroy.call(this);
19759
- };
19760
- /**
19761
19872
  * @override
19762
19873
  */ _proto._updateBounds = function _updateBounds(worldBounds) {
19763
19874
  if (this.sprite) {
@@ -19795,6 +19906,20 @@ SlicedSpriteAssembler = __decorate$1([
19795
19906
  context.camera._renderPipeline.pushPrimitive(spriteElement);
19796
19907
  }
19797
19908
  };
19909
+ /**
19910
+ * @internal
19911
+ */ _proto._onDestroy = function _onDestroy() {
19912
+ Renderer.prototype._onDestroy.call(this);
19913
+ var sprite = this._sprite;
19914
+ if (sprite) {
19915
+ sprite._addRefCount(-1);
19916
+ sprite._updateFlagManager.removeListener(this._onSpriteChange);
19917
+ }
19918
+ this._color = null;
19919
+ this._sprite = null;
19920
+ this._assembler = null;
19921
+ this._renderData = null;
19922
+ };
19798
19923
  _proto._calDefaultSize = function _calDefaultSize() {
19799
19924
  var sprite = this._sprite;
19800
19925
  if (sprite) {
@@ -19886,9 +20011,13 @@ SlicedSpriteAssembler = __decorate$1([
19886
20011
  set: function set(value) {
19887
20012
  var lastSprite = this._sprite;
19888
20013
  if (lastSprite !== value) {
19889
- lastSprite && lastSprite._updateFlagManager.removeListener(this._onSpriteChange);
20014
+ if (lastSprite) {
20015
+ lastSprite._addRefCount(-1);
20016
+ lastSprite._updateFlagManager.removeListener(this._onSpriteChange);
20017
+ }
19890
20018
  this._dirtyUpdateFlag |= 0x7;
19891
20019
  if (value) {
20020
+ value._addRefCount(1);
19892
20021
  value._updateFlagManager.addListener(this._onSpriteChange);
19893
20022
  this.shaderData.setTexture(SpriteRenderer._textureProperty, value.texture);
19894
20023
  } else {
@@ -36020,7 +36149,7 @@ function _interopNamespace(e) {
36020
36149
  }
36021
36150
  var CoreObjects__namespace = /*#__PURE__*/ _interopNamespace(CoreObjects);
36022
36151
  //@ts-ignore
36023
- var version = "0.0.0-experimental-0.9-plus.6";
36152
+ var version = "0.0.0-experimental-0.9-plus.7";
36024
36153
  console.log("Galacean engine version: " + version);
36025
36154
  for(var key in CoreObjects__namespace){
36026
36155
  CoreObjects.Loader.registerClass(key, CoreObjects__namespace[key]);