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