@galacean/engine-core 0.9.7 → 0.9.9

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.
@@ -10490,8 +10490,10 @@ SimpleSpriteAssembler = __decorate([
10490
10490
  _this = Renderer.call(this, entity) || this;
10491
10491
  /** The mask layers the sprite mask influence to. */ _this.influenceLayers = exports.SpriteMaskLayer.Everything;
10492
10492
  _this._sprite = null;
10493
- _this._width = undefined;
10494
- _this._height = undefined;
10493
+ _this._automaticWidth = 0;
10494
+ _this._automaticHeight = 0;
10495
+ _this._customWidth = undefined;
10496
+ _this._customHeight = undefined;
10495
10497
  _this._flipX = false;
10496
10498
  _this._flipY = false;
10497
10499
  _this._alphaCutoff = 0.5;
@@ -10521,12 +10523,11 @@ SimpleSpriteAssembler = __decorate([
10521
10523
  /**
10522
10524
  * @override
10523
10525
  */ _proto._updateBounds = function _updateBounds(worldBounds) {
10524
- var _this_sprite;
10525
- if (!((_this_sprite = this.sprite) == null ? void 0 : _this_sprite.texture) || !this.width || !this.height) {
10526
+ if (this.sprite) {
10527
+ SimpleSpriteAssembler.updatePositions(this);
10528
+ } else {
10526
10529
  worldBounds.min.set(0, 0, 0);
10527
10530
  worldBounds.max.set(0, 0, 0);
10528
- } else {
10529
- SimpleSpriteAssembler.updatePositions(this);
10530
10531
  }
10531
10532
  };
10532
10533
  /**
@@ -10537,12 +10538,12 @@ SimpleSpriteAssembler = __decorate([
10537
10538
  if (!((_this_sprite = this.sprite) == null ? void 0 : _this_sprite.texture) || !this.width || !this.height) {
10538
10539
  return;
10539
10540
  }
10540
- // Update position.
10541
+ // Update position
10541
10542
  if (this._dirtyUpdateFlag & RendererUpdateFlags.WorldVolume) {
10542
10543
  SimpleSpriteAssembler.updatePositions(this);
10543
10544
  this._dirtyUpdateFlag &= ~RendererUpdateFlags.WorldVolume;
10544
10545
  }
10545
- // Update uv.
10546
+ // Update uv
10546
10547
  if (this._dirtyUpdateFlag & 0x2) {
10547
10548
  SimpleSpriteAssembler.updateUVs(this);
10548
10549
  this._dirtyUpdateFlag &= ~0x2;
@@ -10553,11 +10554,27 @@ SimpleSpriteAssembler = __decorate([
10553
10554
  context.camera._renderPipeline._allSpriteMasks.add(this);
10554
10555
  this._maskElement = maskElement;
10555
10556
  };
10557
+ _proto._calDefaultSize = function _calDefaultSize() {
10558
+ var sprite = this._sprite;
10559
+ if (sprite) {
10560
+ this._automaticWidth = sprite.width;
10561
+ this._automaticHeight = sprite.height;
10562
+ } else {
10563
+ this._automaticWidth = this._automaticHeight = 0;
10564
+ }
10565
+ this._dirtyUpdateFlag &= ~0x4;
10566
+ };
10556
10567
  _proto._onSpriteChange = function _onSpriteChange(type) {
10557
10568
  switch(type){
10558
10569
  case SpriteModifyFlags.texture:
10559
10570
  this.shaderData.setTexture(SpriteMask._textureProperty, this.sprite.texture);
10560
10571
  break;
10572
+ case SpriteModifyFlags.size:
10573
+ this._dirtyUpdateFlag |= 0x4;
10574
+ if (this._customWidth === undefined || this._customHeight === undefined) {
10575
+ this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
10576
+ }
10577
+ break;
10561
10578
  case SpriteModifyFlags.region:
10562
10579
  case SpriteModifyFlags.atlasRegionOffset:
10563
10580
  this._dirtyUpdateFlag |= 0x3;
@@ -10565,22 +10582,31 @@ SimpleSpriteAssembler = __decorate([
10565
10582
  case SpriteModifyFlags.atlasRegion:
10566
10583
  this._dirtyUpdateFlag |= 0x2;
10567
10584
  break;
10585
+ case SpriteModifyFlags.pivot:
10586
+ this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
10587
+ break;
10568
10588
  }
10569
10589
  };
10570
10590
  _create_class(SpriteMask, [
10571
10591
  {
10572
10592
  key: "width",
10573
10593
  get: /**
10574
- * Render width.
10594
+ * Render width (in world coordinates).
10595
+ *
10596
+ * @remarks
10597
+ * If width is set, return the set value,
10598
+ * otherwise return `SpriteMask.sprite.width`.
10575
10599
  */ function get() {
10576
- if (this._width === undefined && this._sprite) {
10577
- this.width = this._sprite.width;
10600
+ if (this._customWidth !== undefined) {
10601
+ return this._customWidth;
10602
+ } else {
10603
+ this._dirtyUpdateFlag & 0x4 && this._calDefaultSize();
10604
+ return this._automaticWidth;
10578
10605
  }
10579
- return this._width;
10580
10606
  },
10581
10607
  set: function set(value) {
10582
- if (this._width !== value) {
10583
- this._width = value;
10608
+ if (this._customWidth !== value) {
10609
+ this._customWidth = value;
10584
10610
  this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
10585
10611
  }
10586
10612
  }
@@ -10588,16 +10614,22 @@ SimpleSpriteAssembler = __decorate([
10588
10614
  {
10589
10615
  key: "height",
10590
10616
  get: /**
10591
- * Render height.
10617
+ * Render height (in world coordinates).
10618
+ *
10619
+ * @remarks
10620
+ * If height is set, return the set value,
10621
+ * otherwise return `SpriteMask.sprite.height`.
10592
10622
  */ function get() {
10593
- if (this._height === undefined && this._sprite) {
10594
- this.height = this._sprite.height;
10623
+ if (this._customHeight !== undefined) {
10624
+ return this._customHeight;
10625
+ } else {
10626
+ this._dirtyUpdateFlag & 0x4 && this._calDefaultSize();
10627
+ return this._automaticHeight;
10595
10628
  }
10596
- return this._height;
10597
10629
  },
10598
10630
  set: function set(value) {
10599
- if (this._height !== value) {
10600
- this._height = value;
10631
+ if (this._customHeight !== value) {
10632
+ this._customHeight = value;
10601
10633
  this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
10602
10634
  }
10603
10635
  }
@@ -10641,9 +10673,9 @@ SimpleSpriteAssembler = __decorate([
10641
10673
  var lastSprite = this._sprite;
10642
10674
  if (lastSprite !== value) {
10643
10675
  lastSprite && lastSprite._updateFlagManager.removeListener(this._onSpriteChange);
10676
+ this._dirtyUpdateFlag |= 0x7;
10644
10677
  if (value) {
10645
10678
  value._updateFlagManager.addListener(this._onSpriteChange);
10646
- this._dirtyUpdateFlag |= 0x3;
10647
10679
  this.shaderData.setTexture(SpriteMask._textureProperty, value.texture);
10648
10680
  } else {
10649
10681
  this.shaderData.setTexture(SpriteMask._textureProperty, null);
@@ -10683,10 +10715,16 @@ __decorate([
10683
10715
  ], SpriteMask.prototype, "_sprite", void 0);
10684
10716
  __decorate([
10685
10717
  ignoreClone
10686
- ], SpriteMask.prototype, "_width", void 0);
10718
+ ], SpriteMask.prototype, "_automaticWidth", void 0);
10687
10719
  __decorate([
10688
10720
  ignoreClone
10689
- ], SpriteMask.prototype, "_height", void 0);
10721
+ ], SpriteMask.prototype, "_automaticHeight", void 0);
10722
+ __decorate([
10723
+ assignmentClone
10724
+ ], SpriteMask.prototype, "_customWidth", void 0);
10725
+ __decorate([
10726
+ assignmentClone
10727
+ ], SpriteMask.prototype, "_customHeight", void 0);
10690
10728
  __decorate([
10691
10729
  assignmentClone
10692
10730
  ], SpriteMask.prototype, "_flipX", void 0);
@@ -10704,7 +10742,9 @@ var /**
10704
10742
  */ SpriteMaskUpdateFlags;
10705
10743
  (function(SpriteMaskUpdateFlags) {
10706
10744
  SpriteMaskUpdateFlags[SpriteMaskUpdateFlags[/** UV. */ "UV"] = 0x2] = "UV";
10707
- SpriteMaskUpdateFlags[SpriteMaskUpdateFlags[/** All. */ "All"] = 0x3] = "All";
10745
+ SpriteMaskUpdateFlags[SpriteMaskUpdateFlags[/** WorldVolume and UV . */ "RenderData"] = 0x3] = "RenderData";
10746
+ SpriteMaskUpdateFlags[SpriteMaskUpdateFlags[/** Automatic Size. */ "AutomaticSize"] = 0x4] = "AutomaticSize";
10747
+ SpriteMaskUpdateFlags[SpriteMaskUpdateFlags[/** All. */ "All"] = 0x7] = "All";
10708
10748
  })(SpriteMaskUpdateFlags || (SpriteMaskUpdateFlags = {}));
10709
10749
 
10710
10750
  /**
@@ -11569,6 +11609,7 @@ var MeshModifyFlags;
11569
11609
  var subDataDirtyFlags = this._subDataDirtyFlags;
11570
11610
  var blendShapeFloatStride = this._vertexElementCount * 3;
11571
11611
  var blendShapeByteStride = blendShapeFloatStride * 4;
11612
+ var bufferOffset = this._bufferBindingOffset;
11572
11613
  // @todo: should fix bug when dataChangedFlag is true
11573
11614
  for(var i = 0, n = blendShapes.length; i < n; i++){
11574
11615
  var dataChangedFlag = subDataDirtyFlags[i];
@@ -11586,7 +11627,7 @@ var MeshModifyFlags;
11586
11627
  var offset = indexInBuffer * blendShapeFloatStride;
11587
11628
  var storeInfo = storeInfos[i];
11588
11629
  storeInfo || (storeInfos[i] = storeInfo = new miniprogram.Vector2());
11589
- storeInfo.set(bufferIndex + 1, indexInBuffer * blendShapeByteStride); // BlendShape buffer is start from 1
11630
+ storeInfo.set(bufferOffset + bufferIndex, indexInBuffer * blendShapeByteStride); // BufferOffset is mesh vertexBuffer offset
11590
11631
  var deltaPositions = endFrame.deltaPositions;
11591
11632
  for(var j = 0; j < vertexCount; j++){
11592
11633
  var start = offset + bufferFloatStride * j;
@@ -19359,8 +19400,10 @@ exports.TextVerticalAlignment = void 0;
19359
19400
  if (name === void 0) name = null;
19360
19401
  var _this;
19361
19402
  _this = RefObject.call(this, engine) || this;
19362
- _this._width = undefined;
19363
- _this._height = undefined;
19403
+ _this._automaticWidth = 0;
19404
+ _this._automaticHeight = 0;
19405
+ _this._customWidth = undefined;
19406
+ _this._customHeight = undefined;
19364
19407
  _this._positions = [
19365
19408
  new miniprogram.Vector2(),
19366
19409
  new miniprogram.Vector2(),
@@ -19381,7 +19424,7 @@ exports.TextVerticalAlignment = void 0;
19381
19424
  _this._region = new miniprogram.Rect(0, 0, 1, 1);
19382
19425
  _this._pivot = new miniprogram.Vector2(0.5, 0.5);
19383
19426
  _this._border = new miniprogram.Vector4(0, 0, 0, 0);
19384
- _this._dirtyUpdateFlag = 0x3;
19427
+ _this._dirtyUpdateFlag = 0x7;
19385
19428
  /** @internal */ _this._updateFlagManager = new UpdateFlagManager();
19386
19429
  _this._texture = texture;
19387
19430
  region && _this._region.copyFrom(region);
@@ -19430,9 +19473,12 @@ exports.TextVerticalAlignment = void 0;
19430
19473
  if (this._texture) {
19431
19474
  var _this = this, _texture = _this._texture, _atlasRegion = _this._atlasRegion, _atlasRegionOffset = _this._atlasRegionOffset, _region = _this._region;
19432
19475
  var pixelsPerUnitReciprocal = 1.0 / Engine._pixelsPerUnit;
19433
- this._width = _texture.width * _atlasRegion.width / (1 - _atlasRegionOffset.x - _atlasRegionOffset.z) * _region.width * pixelsPerUnitReciprocal;
19434
- this._height = _texture.height * _atlasRegion.height / (1 - _atlasRegionOffset.y - _atlasRegionOffset.w) * _region.height * pixelsPerUnitReciprocal;
19476
+ this._automaticWidth = _texture.width * _atlasRegion.width / (1 - _atlasRegionOffset.x - _atlasRegionOffset.z) * _region.width * pixelsPerUnitReciprocal;
19477
+ this._automaticHeight = _texture.height * _atlasRegion.height / (1 - _atlasRegionOffset.y - _atlasRegionOffset.w) * _region.height * pixelsPerUnitReciprocal;
19478
+ } else {
19479
+ this._automaticWidth = this._automaticHeight = 0;
19435
19480
  }
19481
+ this._dirtyUpdateFlag &= ~0x4;
19436
19482
  };
19437
19483
  _proto._updatePositions = function _updatePositions() {
19438
19484
  var blank = this._atlasRegionOffset;
@@ -19486,11 +19532,16 @@ exports.TextVerticalAlignment = void 0;
19486
19532
  };
19487
19533
  _proto._dispatchSpriteChange = function _dispatchSpriteChange(type) {
19488
19534
  switch(type){
19535
+ case SpriteModifyFlags.texture:
19536
+ this._dirtyUpdateFlag |= 0x4;
19537
+ break;
19489
19538
  case SpriteModifyFlags.atlasRegionOffset:
19490
19539
  case SpriteModifyFlags.region:
19491
- this._dirtyUpdateFlag |= 0x3;
19540
+ this._dirtyUpdateFlag |= 0x7;
19492
19541
  break;
19493
19542
  case SpriteModifyFlags.atlasRegion:
19543
+ this._dirtyUpdateFlag |= 0x4 | 0x2;
19544
+ break;
19494
19545
  case SpriteModifyFlags.border:
19495
19546
  this._dirtyUpdateFlag |= 0x2;
19496
19547
  break;
@@ -19509,7 +19560,9 @@ exports.TextVerticalAlignment = void 0;
19509
19560
  if (this._texture !== value) {
19510
19561
  this._texture = value;
19511
19562
  this._dispatchSpriteChange(SpriteModifyFlags.texture);
19512
- (this._width === undefined || this._height === undefined) && this._dispatchSpriteChange(SpriteModifyFlags.size);
19563
+ if (this._customWidth === undefined || this._customHeight === undefined) {
19564
+ this._dispatchSpriteChange(SpriteModifyFlags.size);
19565
+ }
19513
19566
  }
19514
19567
  }
19515
19568
  },
@@ -19517,13 +19570,21 @@ exports.TextVerticalAlignment = void 0;
19517
19570
  key: "width",
19518
19571
  get: /**
19519
19572
  * The width of the sprite (in world coordinates).
19573
+ *
19574
+ * @remarks
19575
+ * If width is set, return the set value,
19576
+ * otherwise return the width calculated according to `Texture.width`, `Sprite.region`, `Sprite.atlasRegion`, `Sprite.atlasRegionOffset` and `Engine._pixelsPerUnit`.
19520
19577
  */ function get() {
19521
- this._width === undefined && this._calDefaultSize();
19522
- return this._width;
19578
+ if (this._customWidth !== undefined) {
19579
+ return this._customWidth;
19580
+ } else {
19581
+ this._dirtyUpdateFlag & 0x4 && this._calDefaultSize();
19582
+ return this._automaticWidth;
19583
+ }
19523
19584
  },
19524
19585
  set: function set(value) {
19525
- if (this._width !== value) {
19526
- this._width = value;
19586
+ if (this._customWidth !== value) {
19587
+ this._customWidth = value;
19527
19588
  this._dispatchSpriteChange(SpriteModifyFlags.size);
19528
19589
  }
19529
19590
  }
@@ -19532,13 +19593,21 @@ exports.TextVerticalAlignment = void 0;
19532
19593
  key: "height",
19533
19594
  get: /**
19534
19595
  * The height of the sprite (in world coordinates).
19596
+ *
19597
+ * @remarks
19598
+ * If height is set, return the set value,
19599
+ * otherwise return the height calculated according to `Texture.height`, `Sprite.region`, `Sprite.atlasRegion`, `Sprite.atlasRegionOffset` and `Engine._pixelsPerUnit`.
19535
19600
  */ function get() {
19536
- this._height === undefined && this._calDefaultSize();
19537
- return this._height;
19601
+ if (this._customHeight !== undefined) {
19602
+ return this._customHeight;
19603
+ } else {
19604
+ this._dirtyUpdateFlag & 0x4 && this._calDefaultSize();
19605
+ return this._automaticHeight;
19606
+ }
19538
19607
  },
19539
19608
  set: function set(value) {
19540
- if (this._height !== value) {
19541
- this._height = value;
19609
+ if (this._customHeight !== value) {
19610
+ this._customHeight = value;
19542
19611
  this._dispatchSpriteChange(SpriteModifyFlags.size);
19543
19612
  }
19544
19613
  }
@@ -19568,7 +19637,9 @@ exports.TextVerticalAlignment = void 0;
19568
19637
  var y = miniprogram.MathUtil.clamp(value.y, 0, 1);
19569
19638
  this._atlasRegion.set(x, y, miniprogram.MathUtil.clamp(value.width, 0, 1 - x), miniprogram.MathUtil.clamp(value.height, 0, 1 - y));
19570
19639
  this._dispatchSpriteChange(SpriteModifyFlags.atlasRegion);
19571
- (this._width === undefined || this._height === undefined) && this._dispatchSpriteChange(SpriteModifyFlags.size);
19640
+ if (this._customWidth === undefined || this._customHeight === undefined) {
19641
+ this._dispatchSpriteChange(SpriteModifyFlags.size);
19642
+ }
19572
19643
  }
19573
19644
  },
19574
19645
  {
@@ -19583,7 +19654,9 @@ exports.TextVerticalAlignment = void 0;
19583
19654
  var y = miniprogram.MathUtil.clamp(value.y, 0, 1);
19584
19655
  this._atlasRegionOffset.set(x, y, miniprogram.MathUtil.clamp(value.z, 0, 1 - x), miniprogram.MathUtil.clamp(value.w, 0, 1 - y));
19585
19656
  this._dispatchSpriteChange(SpriteModifyFlags.atlasRegionOffset);
19586
- (this._width === undefined || this._height === undefined) && this._dispatchSpriteChange(SpriteModifyFlags.size);
19657
+ if (this._customWidth === undefined || this._customHeight === undefined) {
19658
+ this._dispatchSpriteChange(SpriteModifyFlags.size);
19659
+ }
19587
19660
  }
19588
19661
  },
19589
19662
  {
@@ -19599,7 +19672,9 @@ exports.TextVerticalAlignment = void 0;
19599
19672
  var y = miniprogram.MathUtil.clamp(value.y, 0, 1);
19600
19673
  region.set(x, y, miniprogram.MathUtil.clamp(value.width, 0, 1 - x), miniprogram.MathUtil.clamp(value.height, 0, 1 - y));
19601
19674
  this._dispatchSpriteChange(SpriteModifyFlags.region);
19602
- (this._width === undefined || this._height === undefined) && this._dispatchSpriteChange(SpriteModifyFlags.size);
19675
+ if (this._customWidth === undefined || this._customHeight === undefined) {
19676
+ this._dispatchSpriteChange(SpriteModifyFlags.size);
19677
+ }
19603
19678
  }
19604
19679
  },
19605
19680
  {
@@ -19649,7 +19724,8 @@ var SpriteUpdateFlags;
19649
19724
  (function(SpriteUpdateFlags) {
19650
19725
  SpriteUpdateFlags[SpriteUpdateFlags["positions"] = 0x1] = "positions";
19651
19726
  SpriteUpdateFlags[SpriteUpdateFlags["uvs"] = 0x2] = "uvs";
19652
- SpriteUpdateFlags[SpriteUpdateFlags["all"] = 0x3] = "all";
19727
+ SpriteUpdateFlags[SpriteUpdateFlags["automaticSize"] = 0x4] = "automaticSize";
19728
+ SpriteUpdateFlags[SpriteUpdateFlags["all"] = 0x7] = "all";
19653
19729
  })(SpriteUpdateFlags || (SpriteUpdateFlags = {}));
19654
19730
 
19655
19731
  var _SlicedSpriteAssembler;
@@ -19802,8 +19878,10 @@ SlicedSpriteAssembler = __decorate([
19802
19878
  _this = Renderer.call(this, entity) || this;
19803
19879
  _this._color = new miniprogram.Color(1, 1, 1, 1);
19804
19880
  _this._sprite = null;
19805
- _this._width = undefined;
19806
- _this._height = undefined;
19881
+ _this._automaticWidth = 0;
19882
+ _this._automaticHeight = 0;
19883
+ _this._customWidth = undefined;
19884
+ _this._customHeight = undefined;
19807
19885
  _this._flipX = false;
19808
19886
  _this._flipY = false;
19809
19887
  _this._maskLayer = exports.SpriteMaskLayer.Layer0;
@@ -19819,6 +19897,7 @@ SlicedSpriteAssembler = __decorate([
19819
19897
  * @internal
19820
19898
  */ _proto._cloneTo = function _cloneTo(target) {
19821
19899
  target.sprite = this._sprite;
19900
+ target.drawMode = this._drawMode;
19822
19901
  };
19823
19902
  /**
19824
19903
  * @internal
@@ -19834,12 +19913,11 @@ SlicedSpriteAssembler = __decorate([
19834
19913
  /**
19835
19914
  * @override
19836
19915
  */ _proto._updateBounds = function _updateBounds(worldBounds) {
19837
- var _this_sprite;
19838
- if (!((_this_sprite = this.sprite) == null ? void 0 : _this_sprite.texture) || !this.width || !this.height) {
19916
+ if (this.sprite) {
19917
+ this._assembler.updatePositions(this);
19918
+ } else {
19839
19919
  worldBounds.min.set(0, 0, 0);
19840
19920
  worldBounds.max.set(0, 0, 0);
19841
- } else {
19842
- this._assembler.updatePositions(this);
19843
19921
  }
19844
19922
  };
19845
19923
  /**
@@ -19849,17 +19927,17 @@ SlicedSpriteAssembler = __decorate([
19849
19927
  if (!((_this_sprite = this.sprite) == null ? void 0 : _this_sprite.texture) || !this.width || !this.height) {
19850
19928
  return;
19851
19929
  }
19852
- // Update position.
19930
+ // Update position
19853
19931
  if (this._dirtyUpdateFlag & RendererUpdateFlags.WorldVolume) {
19854
19932
  this._assembler.updatePositions(this);
19855
19933
  this._dirtyUpdateFlag &= ~RendererUpdateFlags.WorldVolume;
19856
19934
  }
19857
- // Update uv.
19935
+ // Update uv
19858
19936
  if (this._dirtyUpdateFlag & 0x2) {
19859
19937
  this._assembler.updateUVs(this);
19860
19938
  this._dirtyUpdateFlag &= ~0x2;
19861
19939
  }
19862
- // Push primitive.
19940
+ // Push primitive
19863
19941
  var material = this.getMaterial();
19864
19942
  var passes = material.shader.passes;
19865
19943
  var renderStates = material.renderStates;
@@ -19870,6 +19948,16 @@ SlicedSpriteAssembler = __decorate([
19870
19948
  context.camera._renderPipeline.pushPrimitive(spriteElement);
19871
19949
  }
19872
19950
  };
19951
+ _proto._calDefaultSize = function _calDefaultSize() {
19952
+ var sprite = this._sprite;
19953
+ if (sprite) {
19954
+ this._automaticWidth = sprite.width;
19955
+ this._automaticHeight = sprite.height;
19956
+ } else {
19957
+ this._automaticWidth = this._automaticHeight = 0;
19958
+ }
19959
+ this._dirtyUpdateFlag &= ~0x4;
19960
+ };
19873
19961
  _proto._updateStencilState = function _updateStencilState() {
19874
19962
  // Update stencil.
19875
19963
  var material = this.getInstanceMaterial();
@@ -19895,9 +19983,10 @@ SlicedSpriteAssembler = __decorate([
19895
19983
  this.shaderData.setTexture(SpriteRenderer._textureProperty, this.sprite.texture);
19896
19984
  break;
19897
19985
  case SpriteModifyFlags.size:
19986
+ this._dirtyUpdateFlag |= 0x4;
19898
19987
  // When the width and height of `SpriteRenderer` are `undefined`,
19899
19988
  // the `size` of `Sprite` will affect the position of `SpriteRenderer`.
19900
- if (this._drawMode === exports.SpriteDrawMode.Sliced || this._width === undefined || this._height === undefined) {
19989
+ if (this._drawMode === exports.SpriteDrawMode.Sliced || this._customWidth === undefined || this._customHeight === undefined) {
19901
19990
  this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
19902
19991
  }
19903
19992
  break;
@@ -19951,9 +20040,9 @@ SlicedSpriteAssembler = __decorate([
19951
20040
  var lastSprite = this._sprite;
19952
20041
  if (lastSprite !== value) {
19953
20042
  lastSprite && lastSprite._updateFlagManager.removeListener(this._onSpriteChange);
20043
+ this._dirtyUpdateFlag |= 0x7;
19954
20044
  if (value) {
19955
20045
  value._updateFlagManager.addListener(this._onSpriteChange);
19956
- this._dirtyUpdateFlag |= 0x3;
19957
20046
  this.shaderData.setTexture(SpriteRenderer._textureProperty, value.texture);
19958
20047
  } else {
19959
20048
  this.shaderData.setTexture(SpriteRenderer._textureProperty, null);
@@ -19978,16 +20067,22 @@ SlicedSpriteAssembler = __decorate([
19978
20067
  {
19979
20068
  key: "width",
19980
20069
  get: /**
19981
- * Render width.
20070
+ * Render width (in world coordinates).
20071
+ *
20072
+ * @remarks
20073
+ * If width is set, return the set value,
20074
+ * otherwise return `SpriteRenderer.sprite.width`.
19982
20075
  */ function get() {
19983
- this._width === undefined && this._sprite && (this.width = this._sprite.width);
19984
- return this._width;
20076
+ if (this._customWidth !== undefined) {
20077
+ return this._customWidth;
20078
+ } else {
20079
+ this._dirtyUpdateFlag & 0x4 && this._calDefaultSize();
20080
+ return this._automaticWidth;
20081
+ }
19985
20082
  },
19986
20083
  set: function set(value) {
19987
- // Update width if undefined
19988
- this._width === undefined && this._sprite && (this._width = this._sprite.width);
19989
- if (this._width !== value) {
19990
- this._width = value;
20084
+ if (this._customWidth !== value) {
20085
+ this._customWidth = value;
19991
20086
  this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
19992
20087
  }
19993
20088
  }
@@ -19995,16 +20090,22 @@ SlicedSpriteAssembler = __decorate([
19995
20090
  {
19996
20091
  key: "height",
19997
20092
  get: /**
19998
- * Render height.
20093
+ * Render height (in world coordinates).
20094
+ *
20095
+ * @remarks
20096
+ * If height is set, return the set value,
20097
+ * otherwise return `SpriteRenderer.sprite.height`.
19999
20098
  */ function get() {
20000
- this._height === undefined && this._sprite && (this.height = this._sprite.height);
20001
- return this._height;
20099
+ if (this._customHeight !== undefined) {
20100
+ return this._customHeight;
20101
+ } else {
20102
+ this._dirtyUpdateFlag & 0x4 && this._calDefaultSize();
20103
+ return this._automaticHeight;
20104
+ }
20002
20105
  },
20003
20106
  set: function set(value) {
20004
- // Update height if undefined
20005
- this._height === undefined && this._sprite && (this._height = this._sprite.height);
20006
- if (this._height !== value) {
20007
- this._height = value;
20107
+ if (this._customHeight !== value) {
20108
+ this._customHeight = value;
20008
20109
  this._dirtyUpdateFlag |= RendererUpdateFlags.WorldVolume;
20009
20110
  }
20010
20111
  }
@@ -20085,10 +20186,16 @@ __decorate([
20085
20186
  ], SpriteRenderer.prototype, "_sprite", void 0);
20086
20187
  __decorate([
20087
20188
  ignoreClone
20088
- ], SpriteRenderer.prototype, "_width", void 0);
20189
+ ], SpriteRenderer.prototype, "_automaticWidth", void 0);
20089
20190
  __decorate([
20090
20191
  ignoreClone
20091
- ], SpriteRenderer.prototype, "_height", void 0);
20192
+ ], SpriteRenderer.prototype, "_automaticHeight", void 0);
20193
+ __decorate([
20194
+ assignmentClone
20195
+ ], SpriteRenderer.prototype, "_customWidth", void 0);
20196
+ __decorate([
20197
+ assignmentClone
20198
+ ], SpriteRenderer.prototype, "_customHeight", void 0);
20092
20199
  __decorate([
20093
20200
  assignmentClone
20094
20201
  ], SpriteRenderer.prototype, "_flipX", void 0);
@@ -20109,7 +20216,9 @@ var /**
20109
20216
  */ SpriteRendererUpdateFlags;
20110
20217
  (function(SpriteRendererUpdateFlags) {
20111
20218
  SpriteRendererUpdateFlags[SpriteRendererUpdateFlags[/** UV. */ "UV"] = 0x2] = "UV";
20112
- SpriteRendererUpdateFlags[SpriteRendererUpdateFlags[/** All. */ "All"] = 0x3] = "All";
20219
+ SpriteRendererUpdateFlags[SpriteRendererUpdateFlags[/** WorldVolume and UV . */ "RenderData"] = 0x3] = "RenderData";
20220
+ SpriteRendererUpdateFlags[SpriteRendererUpdateFlags[/** Automatic Size. */ "AutomaticSize"] = 0x4] = "AutomaticSize";
20221
+ SpriteRendererUpdateFlags[SpriteRendererUpdateFlags[/** All. */ "All"] = 0x7] = "All";
20113
20222
  })(SpriteRendererUpdateFlags || (SpriteRendererUpdateFlags = {}));
20114
20223
 
20115
20224
  /**