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