@galacean/engine-core 0.9.10 → 0.9.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.
@@ -1466,9 +1466,11 @@ exports.GLCapabilityType = void 0;
1466
1466
  renderTexture
1467
1467
  ];
1468
1468
  for(var i = 0, n = colorTextures.length; i < n; i++){
1469
- if (colorTextures[i]._isDepthTexture) {
1469
+ var colorTexture = colorTextures[i];
1470
+ if (colorTexture._isDepthTexture) {
1470
1471
  throw "Render texture can't use depth format.";
1471
1472
  }
1473
+ colorTexture._addRefCount(1);
1472
1474
  }
1473
1475
  _this._colorTextures = colorTextures;
1474
1476
  } else {
@@ -1479,6 +1481,7 @@ exports.GLCapabilityType = void 0;
1479
1481
  throw "Depth texture must use depth format.";
1480
1482
  }
1481
1483
  _this._depthTexture = depth;
1484
+ _this._depthTexture._addRefCount(1);
1482
1485
  }
1483
1486
  _this._platformRenderTarget = engine._hardwareRenderer.createPlatformRenderTarget(_assert_this_initialized(_this));
1484
1487
  return _this;
@@ -1507,8 +1510,14 @@ exports.GLCapabilityType = void 0;
1507
1510
  /**
1508
1511
  * Destroy render target.
1509
1512
  */ _proto.destroy = function destroy() {
1513
+ var _this__depthTexture;
1510
1514
  this._platformRenderTarget.destroy();
1511
- this._colorTextures.length = 0;
1515
+ var _this = this, colorTextures = _this._colorTextures;
1516
+ for(var i = 0, n = colorTextures.length; i < n; i++){
1517
+ colorTextures[i]._addRefCount(-1);
1518
+ }
1519
+ colorTextures.length = 0;
1520
+ (_this__depthTexture = this._depthTexture) == null ? void 0 : _this__depthTexture._addRefCount(-1);
1512
1521
  this._depthTexture = null;
1513
1522
  this._depth = null;
1514
1523
  };
@@ -1954,6 +1963,7 @@ exports.GLCapabilityType = void 0;
1954
1963
  var fontAtlas = new FontAtlas(engine);
1955
1964
  var texture = new Texture2D(engine, 256, 256);
1956
1965
  fontAtlas.texture = texture;
1966
+ fontAtlas.isGCIgnored = texture.isGCIgnored = true;
1957
1967
  this._fontAtlases.push(fontAtlas);
1958
1968
  return fontAtlas;
1959
1969
  };
@@ -8759,6 +8769,7 @@ var ShaderFactory = /*#__PURE__*/ function() {
8759
8769
  _proto.cloneTo = function cloneTo(target) {
8760
8770
  CloneManager.deepCloneObject(this._macroCollection, target._macroCollection);
8761
8771
  Object.assign(target._macroMap, this._macroMap);
8772
+ var referCount = target._getRefCount();
8762
8773
  var propertyValueMap = this._propertyValueMap;
8763
8774
  var targetPropertyValueMap = target._propertyValueMap;
8764
8775
  var keys = Object.keys(propertyValueMap);
@@ -8770,6 +8781,7 @@ var ShaderFactory = /*#__PURE__*/ function() {
8770
8781
  targetPropertyValueMap[k] = property;
8771
8782
  } else if (_instanceof(property, Texture)) {
8772
8783
  targetPropertyValueMap[k] = property;
8784
+ referCount > 0 && property._addRefCount(referCount);
8773
8785
  } else if (_instanceof(property, Array) || _instanceof(property, Float32Array) || _instanceof(property, Int32Array)) {
8774
8786
  targetPropertyValueMap[k] = property.slice();
8775
8787
  } else {
@@ -10118,6 +10130,14 @@ exports.Renderer = (_Renderer = /*#__PURE__*/ function(Component) {
10118
10130
  };
10119
10131
  /**
10120
10132
  * @internal
10133
+ */ _proto._cloneTo = function _cloneTo(target) {
10134
+ var materials = this._materials;
10135
+ for(var i = 0, n = materials.length; i < n; i++){
10136
+ target._setMaterial(i, materials[i]);
10137
+ }
10138
+ };
10139
+ /**
10140
+ * @internal
10121
10141
  */ _proto._onDestroy = function _onDestroy() {
10122
10142
  this.entity.transform._updateFlagManager.removeListener(this._onTransformChanged);
10123
10143
  this.shaderData._addRefCount(-1);
@@ -10296,7 +10316,7 @@ __decorate([
10296
10316
  ignoreClone
10297
10317
  ], exports.Renderer.prototype, "_overrideUpdate", void 0);
10298
10318
  __decorate([
10299
- shallowClone
10319
+ ignoreClone
10300
10320
  ], exports.Renderer.prototype, "_materials", void 0);
10301
10321
  __decorate([
10302
10322
  ignoreClone
@@ -10506,18 +10526,9 @@ SimpleSpriteAssembler = __decorate([
10506
10526
  }
10507
10527
  var _proto = SpriteMask.prototype;
10508
10528
  /**
10509
- * @override
10510
- * @inheritdoc
10511
- */ _proto._onDestroy = function _onDestroy() {
10512
- var _this__sprite;
10513
- (_this__sprite = this._sprite) == null ? void 0 : _this__sprite._updateFlagManager.removeListener(this._onSpriteChange);
10514
- this._sprite = null;
10515
- this._renderData = null;
10516
- Renderer.prototype._onDestroy.call(this);
10517
- };
10518
- /**
10519
10529
  * @internal
10520
10530
  */ _proto._cloneTo = function _cloneTo(target) {
10531
+ Renderer.prototype._cloneTo.call(this, target);
10521
10532
  target.sprite = this._sprite;
10522
10533
  };
10523
10534
  /**
@@ -10554,6 +10565,19 @@ SimpleSpriteAssembler = __decorate([
10554
10565
  context.camera._renderPipeline._allSpriteMasks.add(this);
10555
10566
  this._maskElement = maskElement;
10556
10567
  };
10568
+ /**
10569
+ * @internal
10570
+ * @inheritdoc
10571
+ */ _proto._onDestroy = function _onDestroy() {
10572
+ Renderer.prototype._onDestroy.call(this);
10573
+ var sprite = this._sprite;
10574
+ if (sprite) {
10575
+ sprite._addRefCount(-1);
10576
+ sprite._updateFlagManager.removeListener(this._onSpriteChange);
10577
+ }
10578
+ this._sprite = null;
10579
+ this._renderData = null;
10580
+ };
10557
10581
  _proto._calDefaultSize = function _calDefaultSize() {
10558
10582
  var sprite = this._sprite;
10559
10583
  if (sprite) {
@@ -10672,9 +10696,13 @@ SimpleSpriteAssembler = __decorate([
10672
10696
  set: function set(value) {
10673
10697
  var lastSprite = this._sprite;
10674
10698
  if (lastSprite !== value) {
10675
- lastSprite && lastSprite._updateFlagManager.removeListener(this._onSpriteChange);
10699
+ if (lastSprite) {
10700
+ lastSprite._addRefCount(-1);
10701
+ lastSprite._updateFlagManager.removeListener(this._onSpriteChange);
10702
+ }
10676
10703
  this._dirtyUpdateFlag |= 0x7;
10677
10704
  if (value) {
10705
+ value._addRefCount(1);
10678
10706
  value._updateFlagManager.addListener(this._onSpriteChange);
10679
10707
  this.shaderData.setTexture(SpriteMask._textureProperty, value.texture);
10680
10708
  } else {
@@ -11241,10 +11269,11 @@ var BufferUtil = /*#__PURE__*/ function() {
11241
11269
  /**
11242
11270
  * @internal
11243
11271
  */ _proto._setVertexBufferBinding = function _setVertexBufferBinding(index, binding) {
11244
- if (this._getRefCount() > 0) {
11245
- var lastBinding = this._vertexBufferBindings[index];
11246
- lastBinding && lastBinding._buffer._addRefCount(-1);
11247
- binding._buffer._addRefCount(1);
11272
+ var referCount = this._getRefCount();
11273
+ if (referCount > 0) {
11274
+ var _this__vertexBufferBindings_index;
11275
+ (_this__vertexBufferBindings_index = this._vertexBufferBindings[index]) == null ? void 0 : _this__vertexBufferBindings_index._buffer._addRefCount(-referCount);
11276
+ binding == null ? void 0 : binding._buffer._addRefCount(referCount);
11248
11277
  }
11249
11278
  this._vertexBufferBindings[index] = binding;
11250
11279
  this._bufferStructChanged = true;
@@ -11258,11 +11287,13 @@ var BufferUtil = /*#__PURE__*/ function() {
11258
11287
  /**
11259
11288
  * @override
11260
11289
  */ _proto._addRefCount = function _addRefCount(value) {
11290
+ var _this__indexBufferBinding;
11261
11291
  RefObject.prototype._addRefCount.call(this, value);
11262
11292
  var vertexBufferBindings = this._vertexBufferBindings;
11263
11293
  for(var i = 0, n = vertexBufferBindings.length; i < n; i++){
11264
11294
  vertexBufferBindings[i]._buffer._addRefCount(value);
11265
11295
  }
11296
+ (_this__indexBufferBinding = this._indexBufferBinding) == null ? void 0 : _this__indexBufferBinding._buffer._addRefCount(value);
11266
11297
  };
11267
11298
  /**
11268
11299
  * @override
@@ -11282,6 +11313,11 @@ var BufferUtil = /*#__PURE__*/ function() {
11282
11313
  };
11283
11314
  _proto._setIndexBufferBinding = function _setIndexBufferBinding(binding) {
11284
11315
  var lastBinding = this._indexBufferBinding;
11316
+ var referCount = this._getRefCount();
11317
+ if (referCount > 0) {
11318
+ lastBinding == null ? void 0 : lastBinding.buffer._addRefCount(-referCount);
11319
+ binding == null ? void 0 : binding.buffer._addRefCount(referCount);
11320
+ }
11285
11321
  if (binding) {
11286
11322
  this._indexBufferBinding = binding;
11287
11323
  this._glIndexType = BufferUtil._getGLIndexType(binding.format);
@@ -12954,12 +12990,14 @@ var VertexChangedFlags;
12954
12990
  var mesh = this._mesh;
12955
12991
  if (mesh && !mesh.destroyed) {
12956
12992
  mesh._addRefCount(-1);
12993
+ mesh._updateFlagManager.removeListener(this._onMeshChanged);
12957
12994
  this._mesh = null;
12958
12995
  }
12959
12996
  };
12960
12997
  /**
12961
12998
  * @internal
12962
12999
  */ _proto._cloneTo = function _cloneTo(target) {
13000
+ Renderer.prototype._cloneTo.call(this, target);
12963
13001
  target.mesh = this._mesh;
12964
13002
  };
12965
13003
  /**
@@ -13252,6 +13290,7 @@ var rePropName = RegExp(// Match anything that isn't a dot or bracket.
13252
13290
  (_this__jointTexture = this._jointTexture) == null ? void 0 : _this__jointTexture.destroy();
13253
13291
  this._jointTexture = new Texture2D(engine, 4, jointCount, exports.TextureFormat.R32G32B32A32, false);
13254
13292
  this._jointTexture.filterMode = exports.TextureFilterMode.Point;
13293
+ this._jointTexture.isGCIgnored = true;
13255
13294
  }
13256
13295
  shaderData.disableMacro("O3_JOINTS_NUM");
13257
13296
  shaderData.enableMacro("O3_USE_JOINT_TEXTURE");
@@ -13285,6 +13324,15 @@ var rePropName = RegExp(// Match anything that isn't a dot or bracket.
13285
13324
  };
13286
13325
  /**
13287
13326
  * @internal
13327
+ * @override
13328
+ */ _proto._onDestroy = function _onDestroy() {
13329
+ var _this_rootBone, _this__jointTexture;
13330
+ MeshRenderer.prototype._onDestroy.call(this);
13331
+ (_this_rootBone = this.rootBone) == null ? void 0 : _this_rootBone.transform._updateFlagManager.removeListener(this._onTransformChanged);
13332
+ (_this__jointTexture = this._jointTexture) == null ? void 0 : _this__jointTexture.destroy();
13333
+ };
13334
+ /**
13335
+ * @internal
13288
13336
  */ _proto._cloneTo = function _cloneTo(target) {
13289
13337
  MeshRenderer.prototype._cloneTo.call(this, target);
13290
13338
  this._blendShapeWeights && (target._blendShapeWeights = this._blendShapeWeights.slice());
@@ -14448,14 +14496,17 @@ var Basic2DBatcher = /*#__PURE__*/ function() {
14448
14496
  _proto._createMesh = function _createMesh(engine, index) {
14449
14497
  var MAX_VERTEX_COUNT = Basic2DBatcher.MAX_VERTEX_COUNT;
14450
14498
  var mesh = new BufferMesh(engine, "BufferMesh" + index);
14499
+ mesh.isGCIgnored = true;
14451
14500
  var vertexElements = [];
14452
14501
  var vertexStride = this.createVertexElements(vertexElements);
14453
14502
  // vertices
14454
- this._vertexBuffers[index] = new Buffer(engine, exports.BufferBindFlag.VertexBuffer, MAX_VERTEX_COUNT * 4 * vertexStride, exports.BufferUsage.Dynamic);
14503
+ var vertexBuffer = this._vertexBuffers[index] = new Buffer(engine, exports.BufferBindFlag.VertexBuffer, MAX_VERTEX_COUNT * 4 * vertexStride, exports.BufferUsage.Dynamic);
14504
+ vertexBuffer.isGCIgnored = true;
14455
14505
  // indices
14456
- this._indiceBuffers[index] = new Buffer(engine, exports.BufferBindFlag.IndexBuffer, MAX_VERTEX_COUNT * 2 * 3, exports.BufferUsage.Dynamic);
14457
- mesh.setVertexBufferBinding(this._vertexBuffers[index], vertexStride);
14458
- mesh.setIndexBufferBinding(this._indiceBuffers[index], exports.IndexFormat.UInt16);
14506
+ var indiceBuffer = this._indiceBuffers[index] = new Buffer(engine, exports.BufferBindFlag.IndexBuffer, MAX_VERTEX_COUNT * 2 * 3, exports.BufferUsage.Dynamic);
14507
+ indiceBuffer.isGCIgnored = true;
14508
+ mesh.setVertexBufferBinding(vertexBuffer, vertexStride);
14509
+ mesh.setIndexBufferBinding(indiceBuffer, exports.IndexFormat.UInt16);
14459
14510
  mesh.setVertexElements(vertexElements);
14460
14511
  return mesh;
14461
14512
  };
@@ -14694,6 +14745,12 @@ var TextRenderElement = /*#__PURE__*/ function(RenderElement) {
14694
14745
  var _proto = Sky.prototype;
14695
14746
  /**
14696
14747
  * @internal
14748
+ */ _proto.destroy = function destroy() {
14749
+ this.mesh = null;
14750
+ this.material = null;
14751
+ };
14752
+ /**
14753
+ * @internal
14697
14754
  */ _proto._render = function _render(context) {
14698
14755
  var _this = this, material = _this.material, mesh = _this.mesh;
14699
14756
  if (!material) {
@@ -14732,6 +14789,40 @@ var TextRenderElement = /*#__PURE__*/ function(RenderElement) {
14732
14789
  rhi.drawPrimitive(mesh, mesh.subMesh, program);
14733
14790
  cameraShaderData.setMatrix(RenderContext._vpMatrixProperty, originViewProjMatrix);
14734
14791
  };
14792
+ _create_class(Sky, [
14793
+ {
14794
+ key: "material",
14795
+ get: /**
14796
+ * Material of the sky.
14797
+ */ function get() {
14798
+ return this._material;
14799
+ },
14800
+ set: function set(value) {
14801
+ if (this._material !== value) {
14802
+ var _this__material;
14803
+ value == null ? void 0 : value._addRefCount(1);
14804
+ (_this__material = this._material) == null ? void 0 : _this__material._addRefCount(-1);
14805
+ this._material = value;
14806
+ }
14807
+ }
14808
+ },
14809
+ {
14810
+ key: "mesh",
14811
+ get: /**
14812
+ * Mesh of the sky.
14813
+ */ function get() {
14814
+ return this._mesh;
14815
+ },
14816
+ set: function set(value) {
14817
+ if (this._mesh !== value) {
14818
+ var _this__mesh;
14819
+ value == null ? void 0 : value._addRefCount(1);
14820
+ (_this__mesh = this._mesh) == null ? void 0 : _this__mesh._addRefCount(-1);
14821
+ this._mesh = value;
14822
+ }
14823
+ }
14824
+ }
14825
+ ]);
14735
14826
  return Sky;
14736
14827
  }();
14737
14828
  (function() {
@@ -14762,11 +14853,28 @@ var TextRenderElement = /*#__PURE__*/ function(RenderElement) {
14762
14853
  this.sky = new Sky();
14763
14854
  this./** @internal */ _textureFillMode = exports.BackgroundTextureFillMode.AspectFitHeight;
14764
14855
  this._texture = null;
14765
- this._mesh = this._createPlane(_engine);
14856
+ this._initMesh(_engine);
14766
14857
  }
14767
14858
  var _proto = Background.prototype;
14768
14859
  /**
14769
14860
  * @internal
14861
+ */ _proto.destroy = function destroy() {
14862
+ this._mesh._addRefCount(-1);
14863
+ this._mesh = null;
14864
+ this.texture = null;
14865
+ this.solidColor = null;
14866
+ this.sky.destroy();
14867
+ this._engine = null;
14868
+ };
14869
+ /**
14870
+ * @internal
14871
+ * Standalone for CanvasRenderer plugin.
14872
+ */ _proto._initMesh = function _initMesh(engine) {
14873
+ this._mesh = this._createPlane(engine);
14874
+ this._mesh._addRefCount(1);
14875
+ };
14876
+ /**
14877
+ * @internal
14770
14878
  */ _proto._resizeBackgroundTexture = function _resizeBackgroundTexture() {
14771
14879
  if (!this._texture) {
14772
14880
  return;
@@ -14835,6 +14943,9 @@ var TextRenderElement = /*#__PURE__*/ function(RenderElement) {
14835
14943
  },
14836
14944
  set: function set(value) {
14837
14945
  if (this._texture !== value) {
14946
+ var _this__texture;
14947
+ value == null ? void 0 : value._addRefCount(1);
14948
+ (_this__texture = this._texture) == null ? void 0 : _this__texture._addRefCount(-1);
14838
14949
  this._texture = value;
14839
14950
  this._engine._backgroundTextureMaterial.shaderData.setTexture("u_baseTexture", value);
14840
14951
  }
@@ -15338,6 +15449,7 @@ var TextRenderElement = /*#__PURE__*/ function(RenderElement) {
15338
15449
  this._rootEntities[0].destroy();
15339
15450
  }
15340
15451
  this._activeCameras.length = 0;
15452
+ this.background.destroy();
15341
15453
  this.shaderData._addRefCount(-1);
15342
15454
  };
15343
15455
  _proto._addToRootEntityList = function _addToRootEntityList(index, rootEntity) {
@@ -15751,7 +15863,7 @@ ShaderPool.init();
15751
15863
  _this._spriteDefaultMaterial = _this._createSpriteMaterial();
15752
15864
  _this._spriteMaskDefaultMaterial = _this._createSpriteMaskMaterial();
15753
15865
  _this._textDefaultFont = Font.createFromOS(_assert_this_initialized(_this), "Arial");
15754
- _this._textDefaultFont.isGCIgnored = false;
15866
+ _this._textDefaultFont.isGCIgnored = true;
15755
15867
  _this.inputManager = new InputManager(_assert_this_initialized(_this));
15756
15868
  var magentaPixel = new Uint8Array([
15757
15869
  255,
@@ -15786,6 +15898,7 @@ ShaderPool.init();
15786
15898
  _this._magentaTexture2DArray = magentaTexture2DArray;
15787
15899
  }
15788
15900
  var magentaMaterial = new Material(_assert_this_initialized(_this), Shader.find("unlit"));
15901
+ magentaMaterial.isGCIgnored = true;
15789
15902
  magentaMaterial.shaderData.setColor("u_baseColor", new Color(1.0, 0.0, 1.01, 1.0));
15790
15903
  _this._magentaMaterial = magentaMaterial;
15791
15904
  var backgroundTextureMaterial = new Material(_assert_this_initialized(_this), Shader.find("background-texture"));
@@ -17318,7 +17431,11 @@ var /**
17318
17431
  var height = shadowCascades == exports.ShadowCascadesMode.TwoCascades ? shadowTileResolution : shadowTileResolution * 2;
17319
17432
  this._shadowMapSize.set(1.0 / width, 1.0 / height, width, height);
17320
17433
  }
17321
- this._renderTargets = null;
17434
+ var renderTargets = this._renderTargets;
17435
+ if (renderTargets) {
17436
+ renderTargets.destroy();
17437
+ this._renderTargets = null;
17438
+ }
17322
17439
  var viewportOffset = this._viewportOffsets;
17323
17440
  var shadowTileResolution1 = this._shadowTileResolution;
17324
17441
  switch(shadowCascades){
@@ -19360,10 +19477,17 @@ exports.TextVerticalAlignment = void 0;
19360
19477
  * @internal
19361
19478
  */ _proto._addSprite = function _addSprite(sprite) {
19362
19479
  this._spriteNamesToIndex[sprite.name] = this._sprites.push(sprite) - 1;
19480
+ sprite._atlas = this;
19481
+ sprite.isGCIgnored = true;
19363
19482
  };
19364
19483
  /**
19365
19484
  * @override
19366
19485
  */ _proto._onDestroy = function _onDestroy() {
19486
+ var _this = this, sprites = _this._sprites;
19487
+ for(var i = 0, n = sprites.length; i < n; i++){
19488
+ sprites[i].destroy();
19489
+ }
19490
+ sprites.length = 0;
19367
19491
  this._sprites = null;
19368
19492
  this._spriteNamesToIndex = null;
19369
19493
  };
@@ -19464,10 +19588,29 @@ exports.TextVerticalAlignment = void 0;
19464
19588
  };
19465
19589
  /**
19466
19590
  * @override
19591
+ * @internal
19592
+ */ _proto._addRefCount = function _addRefCount(value) {
19593
+ var _this__atlas;
19594
+ RefObject.prototype._addRefCount.call(this, value);
19595
+ (_this__atlas = this._atlas) == null ? void 0 : _this__atlas._addRefCount(value);
19596
+ };
19597
+ /**
19598
+ * @override
19599
+ * @internal
19467
19600
  */ _proto._onDestroy = function _onDestroy() {
19468
- if (this._texture) {
19469
- this._texture = null;
19470
- }
19601
+ this._positions.length = 0;
19602
+ this._positions = null;
19603
+ this._uvs.length = 0;
19604
+ this._uvs = null;
19605
+ this._atlasRegion = null;
19606
+ this._atlasRegionOffset = null;
19607
+ this._region = null;
19608
+ this._pivot = null;
19609
+ this._border = null;
19610
+ this._bounds = null;
19611
+ this._atlas = null;
19612
+ this._texture = null;
19613
+ this._updateFlagManager = null;
19471
19614
  };
19472
19615
  _proto._calDefaultSize = function _calDefaultSize() {
19473
19616
  if (this._texture) {
@@ -19570,7 +19713,7 @@ exports.TextVerticalAlignment = void 0;
19570
19713
  key: "width",
19571
19714
  get: /**
19572
19715
  * The width of the sprite (in world coordinates).
19573
- *
19716
+ *
19574
19717
  * @remarks
19575
19718
  * If width is set, return the set value,
19576
19719
  * otherwise return the width calculated according to `Texture.width`, `Sprite.region`, `Sprite.atlasRegion`, `Sprite.atlasRegionOffset` and `Engine._pixelsPerUnit`.
@@ -19593,7 +19736,7 @@ exports.TextVerticalAlignment = void 0;
19593
19736
  key: "height",
19594
19737
  get: /**
19595
19738
  * The height of the sprite (in world coordinates).
19596
- *
19739
+ *
19597
19740
  * @remarks
19598
19741
  * If height is set, return the set value,
19599
19742
  * otherwise return the height calculated according to `Texture.height`, `Sprite.region`, `Sprite.atlasRegion`, `Sprite.atlasRegionOffset` and `Engine._pixelsPerUnit`.
@@ -19896,21 +20039,11 @@ SlicedSpriteAssembler = __decorate([
19896
20039
  /**
19897
20040
  * @internal
19898
20041
  */ _proto._cloneTo = function _cloneTo(target) {
20042
+ Renderer.prototype._cloneTo.call(this, target);
19899
20043
  target.sprite = this._sprite;
19900
20044
  target.drawMode = this._drawMode;
19901
20045
  };
19902
20046
  /**
19903
- * @internal
19904
- */ _proto._onDestroy = function _onDestroy() {
19905
- var _this__sprite;
19906
- (_this__sprite = this._sprite) == null ? void 0 : _this__sprite._updateFlagManager.removeListener(this._onSpriteChange);
19907
- this._color = null;
19908
- this._sprite = null;
19909
- this._assembler = null;
19910
- this._renderData = null;
19911
- Renderer.prototype._onDestroy.call(this);
19912
- };
19913
- /**
19914
20047
  * @override
19915
20048
  */ _proto._updateBounds = function _updateBounds(worldBounds) {
19916
20049
  if (this.sprite) {
@@ -19948,6 +20081,20 @@ SlicedSpriteAssembler = __decorate([
19948
20081
  context.camera._renderPipeline.pushPrimitive(spriteElement);
19949
20082
  }
19950
20083
  };
20084
+ /**
20085
+ * @internal
20086
+ */ _proto._onDestroy = function _onDestroy() {
20087
+ Renderer.prototype._onDestroy.call(this);
20088
+ var sprite = this._sprite;
20089
+ if (sprite) {
20090
+ sprite._addRefCount(-1);
20091
+ sprite._updateFlagManager.removeListener(this._onSpriteChange);
20092
+ }
20093
+ this._color = null;
20094
+ this._sprite = null;
20095
+ this._assembler = null;
20096
+ this._renderData = null;
20097
+ };
19951
20098
  _proto._calDefaultSize = function _calDefaultSize() {
19952
20099
  var sprite = this._sprite;
19953
20100
  if (sprite) {
@@ -20039,9 +20186,13 @@ SlicedSpriteAssembler = __decorate([
20039
20186
  set: function set(value) {
20040
20187
  var lastSprite = this._sprite;
20041
20188
  if (lastSprite !== value) {
20042
- lastSprite && lastSprite._updateFlagManager.removeListener(this._onSpriteChange);
20189
+ if (lastSprite) {
20190
+ lastSprite._addRefCount(-1);
20191
+ lastSprite._updateFlagManager.removeListener(this._onSpriteChange);
20192
+ }
20043
20193
  this._dirtyUpdateFlag |= 0x7;
20044
20194
  if (value) {
20195
+ value._addRefCount(1);
20045
20196
  value._updateFlagManager.addListener(this._onSpriteChange);
20046
20197
  this.shaderData.setTexture(SpriteRenderer._textureProperty, value.texture);
20047
20198
  } else {
@@ -20649,6 +20800,7 @@ var /**
20649
20800
  /**
20650
20801
  * @internal
20651
20802
  */ _proto._cloneTo = function _cloneTo(target) {
20803
+ Renderer.prototype._cloneTo.call(this, target);
20652
20804
  target.font = this._font;
20653
20805
  target._subFont = this._subFont;
20654
20806
  };