@galacean/engine-ui 2.0.0-alpha.2 → 2.0.0-alpha.5
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/browser.js +74 -27
- package/dist/browser.js.map +1 -1
- package/dist/browser.min.js +1 -1
- package/dist/browser.min.js.map +1 -1
- package/dist/main.js +74 -27
- package/dist/main.js.map +1 -1
- package/dist/module.js +74 -27
- package/dist/module.js.map +1 -1
- package/package.json +3 -3
- package/types/component/UICanvas.d.ts +10 -3
- package/types/component/advanced/Text.d.ts +7 -1
package/dist/browser.js
CHANGED
|
@@ -1502,7 +1502,18 @@
|
|
|
1502
1502
|
/**
|
|
1503
1503
|
* @internal
|
|
1504
1504
|
*/ _proto._canRender = function _canRender(camera) {
|
|
1505
|
-
return this.
|
|
1505
|
+
return this._realRenderMode !== CanvasRenderMode.ScreenSpaceCamera || this._camera === camera;
|
|
1506
|
+
};
|
|
1507
|
+
/**
|
|
1508
|
+
* @internal
|
|
1509
|
+
*/ _proto._canDispatchEvent = function _canDispatchEvent(camera) {
|
|
1510
|
+
var realMode = this._realRenderMode;
|
|
1511
|
+
if (realMode === CanvasRenderMode.ScreenSpaceOverlay) {
|
|
1512
|
+
return true;
|
|
1513
|
+
}
|
|
1514
|
+
var assignedCamera = this._camera;
|
|
1515
|
+
// @ts-ignore
|
|
1516
|
+
return !assignedCamera || !assignedCamera._phasedActiveInScene || assignedCamera === camera;
|
|
1506
1517
|
};
|
|
1507
1518
|
/**
|
|
1508
1519
|
* @internal
|
|
@@ -1604,13 +1615,13 @@
|
|
|
1604
1615
|
* @internal
|
|
1605
1616
|
*/ _proto._cloneTo = function _cloneTo(target, srcRoot, targetRoot) {
|
|
1606
1617
|
target.renderMode = this._renderMode;
|
|
1607
|
-
var
|
|
1608
|
-
if (
|
|
1618
|
+
var camera = this._camera;
|
|
1619
|
+
if (camera) {
|
|
1609
1620
|
var paths = UICanvas._targetTempPath;
|
|
1610
1621
|
// @ts-ignore
|
|
1611
|
-
var success = engine.Entity._getEntityHierarchyPath(srcRoot,
|
|
1622
|
+
var success = engine.Entity._getEntityHierarchyPath(srcRoot, camera.entity, paths);
|
|
1612
1623
|
// @ts-ignore
|
|
1613
|
-
target.
|
|
1624
|
+
target.camera = success ? engine.Entity._getEntityByHierarchyPath(targetRoot, paths).getComponent(engine.Camera) : camera;
|
|
1614
1625
|
}
|
|
1615
1626
|
};
|
|
1616
1627
|
_proto._getRenderers = function _getRenderers() {
|
|
@@ -1628,7 +1639,7 @@
|
|
|
1628
1639
|
var transform = this.entity.transform;
|
|
1629
1640
|
var realRenderMode = this._realRenderMode;
|
|
1630
1641
|
if (realRenderMode === CanvasRenderMode.ScreenSpaceCamera) {
|
|
1631
|
-
var cameraEntity = this.
|
|
1642
|
+
var cameraEntity = this._camera.entity;
|
|
1632
1643
|
if (!this._isSameOrChildEntity(cameraEntity)) {
|
|
1633
1644
|
var cameraTransform = cameraEntity.transform;
|
|
1634
1645
|
var cameraWorldPosition = cameraTransform.worldPosition, cameraWorldForward = cameraTransform.worldForward;
|
|
@@ -1649,9 +1660,9 @@
|
|
|
1649
1660
|
var curWidth;
|
|
1650
1661
|
var curHeight;
|
|
1651
1662
|
if (realRenderMode === CanvasRenderMode.ScreenSpaceCamera) {
|
|
1652
|
-
var
|
|
1653
|
-
curHeight =
|
|
1654
|
-
curWidth =
|
|
1663
|
+
var camera = this._camera;
|
|
1664
|
+
curHeight = camera.isOrthographic ? camera.orthographicSize * 2 : 2 * (Math.tan(engine.MathUtil.degreeToRadian(camera.fieldOfView * 0.5)) * this._distance);
|
|
1665
|
+
curWidth = camera.aspectRatio * curHeight;
|
|
1655
1666
|
} else {
|
|
1656
1667
|
var canvas = this.engine.canvas;
|
|
1657
1668
|
curHeight = canvas.height;
|
|
@@ -1721,7 +1732,7 @@
|
|
|
1721
1732
|
return depth;
|
|
1722
1733
|
};
|
|
1723
1734
|
_proto._updateCameraObserver = function _updateCameraObserver() {
|
|
1724
|
-
var camera = this._isRootCanvas && this._renderMode === CanvasRenderMode.ScreenSpaceCamera ? this.
|
|
1735
|
+
var camera = this._isRootCanvas && this._renderMode === CanvasRenderMode.ScreenSpaceCamera ? this._camera : null;
|
|
1725
1736
|
var preCamera = this._cameraObserver;
|
|
1726
1737
|
if (preCamera !== camera) {
|
|
1727
1738
|
this._cameraObserver = camera;
|
|
@@ -1747,10 +1758,10 @@
|
|
|
1747
1758
|
this._adapterSizeInScreenSpace();
|
|
1748
1759
|
break;
|
|
1749
1760
|
case engine.CameraModifyFlags.FieldOfView:
|
|
1750
|
-
!this.
|
|
1761
|
+
!this._camera.isOrthographic && this._adapterSizeInScreenSpace();
|
|
1751
1762
|
break;
|
|
1752
1763
|
case engine.CameraModifyFlags.OrthographicSize:
|
|
1753
|
-
this.
|
|
1764
|
+
this._camera.isOrthographic && this._adapterSizeInScreenSpace();
|
|
1754
1765
|
break;
|
|
1755
1766
|
case engine.CameraModifyFlags.DisableInScene:
|
|
1756
1767
|
this._setRealRenderMode(CanvasRenderMode.ScreenSpaceOverlay);
|
|
@@ -1821,9 +1832,10 @@
|
|
|
1821
1832
|
};
|
|
1822
1833
|
_proto._getRealRenderMode = function _getRealRenderMode() {
|
|
1823
1834
|
if (this._isRootCanvas) {
|
|
1824
|
-
var
|
|
1835
|
+
var _this__camera;
|
|
1825
1836
|
var mode = this._renderMode;
|
|
1826
|
-
|
|
1837
|
+
// @ts-ignore
|
|
1838
|
+
if (mode === CanvasRenderMode.ScreenSpaceCamera && !((_this__camera = this._camera) == null ? void 0 : _this__camera._phasedActiveInScene)) {
|
|
1827
1839
|
return CanvasRenderMode.ScreenSpaceOverlay;
|
|
1828
1840
|
} else {
|
|
1829
1841
|
return mode;
|
|
@@ -1913,18 +1925,22 @@
|
|
|
1913
1925
|
}
|
|
1914
1926
|
},
|
|
1915
1927
|
{
|
|
1916
|
-
key: "
|
|
1928
|
+
key: "camera",
|
|
1917
1929
|
get: /**
|
|
1918
|
-
* The camera
|
|
1919
|
-
* @remarks
|
|
1930
|
+
* The camera associated with this canvas.
|
|
1931
|
+
* @remarks
|
|
1932
|
+
* - `ScreenSpaceCamera` mode: Used for rendering adaptation. Defaults to `ScreenSpaceOverlay` if not assigned.
|
|
1933
|
+
* - `WorldSpace` mode: Used for event detection. If not assigned, events are handled by the highest-priority camera.
|
|
1920
1934
|
*/ function get() {
|
|
1921
|
-
return this.
|
|
1935
|
+
return this._camera;
|
|
1922
1936
|
},
|
|
1923
1937
|
set: function set(value) {
|
|
1924
|
-
var preCamera = this.
|
|
1938
|
+
var preCamera = this._camera;
|
|
1925
1939
|
if (preCamera !== value) {
|
|
1926
|
-
value && this._isSameOrChildEntity(value.entity)
|
|
1927
|
-
|
|
1940
|
+
if (value && this._isSameOrChildEntity(value.entity)) {
|
|
1941
|
+
engine.Logger.warn("Camera entity matching or nested within the canvas entity disables canvas auto-adaptation in ScreenSpaceCamera mode.");
|
|
1942
|
+
}
|
|
1943
|
+
this._camera = value;
|
|
1928
1944
|
this._updateCameraObserver();
|
|
1929
1945
|
var preRenderMode = this._realRenderMode;
|
|
1930
1946
|
var curRenderMode = this._getRealRenderMode();
|
|
@@ -1939,6 +1955,17 @@
|
|
|
1939
1955
|
}
|
|
1940
1956
|
}
|
|
1941
1957
|
},
|
|
1958
|
+
{
|
|
1959
|
+
key: "renderCamera",
|
|
1960
|
+
get: /**
|
|
1961
|
+
* @deprecated Use {@link camera} instead.
|
|
1962
|
+
*/ function get() {
|
|
1963
|
+
return this.camera;
|
|
1964
|
+
},
|
|
1965
|
+
set: function set(value) {
|
|
1966
|
+
this.camera = value;
|
|
1967
|
+
}
|
|
1968
|
+
},
|
|
1942
1969
|
{
|
|
1943
1970
|
key: "resolutionAdaptationMode",
|
|
1944
1971
|
get: /**
|
|
@@ -2034,7 +2061,7 @@
|
|
|
2034
2061
|
], exports.UICanvas.prototype, "_renderMode", void 0);
|
|
2035
2062
|
__decorate([
|
|
2036
2063
|
engine.ignoreClone
|
|
2037
|
-
], exports.UICanvas.prototype, "
|
|
2064
|
+
], exports.UICanvas.prototype, "_camera", void 0);
|
|
2038
2065
|
__decorate([
|
|
2039
2066
|
engine.ignoreClone
|
|
2040
2067
|
], exports.UICanvas.prototype, "_cameraObserver", void 0);
|
|
@@ -2146,6 +2173,7 @@
|
|
|
2146
2173
|
var _this;
|
|
2147
2174
|
_this = UIRenderer1.call(this, entity) || this, _this._sprite = null, _this._tileMode = engine.SpriteTileMode.Continuous, _this._tiledAdaptiveThreshold = 0.5;
|
|
2148
2175
|
_this.drawMode = engine.SpriteDrawMode.Simple;
|
|
2176
|
+
// @ts-ignore
|
|
2149
2177
|
_this.setMaterial(_this._engine._getUIDefaultMaterial());
|
|
2150
2178
|
_this._onSpriteChange = _this._onSpriteChange.bind(_this);
|
|
2151
2179
|
return _this;
|
|
@@ -2197,6 +2225,7 @@
|
|
|
2197
2225
|
}
|
|
2198
2226
|
// @todo: This question needs to be raised rather than hidden.
|
|
2199
2227
|
if (material.destroyed) {
|
|
2228
|
+
// @ts-ignore
|
|
2200
2229
|
material = this._engine._getUIDefaultMaterial();
|
|
2201
2230
|
}
|
|
2202
2231
|
var alpha = this._getGlobalAlpha();
|
|
@@ -2404,7 +2433,7 @@
|
|
|
2404
2433
|
_inherits(Text, UIRenderer1);
|
|
2405
2434
|
function Text(entity) {
|
|
2406
2435
|
var _this;
|
|
2407
|
-
_this = UIRenderer1.call(this, entity) || this, _this._textChunks = Array(), _this._subFont = null, _this._text = "", _this._localBounds = new engine.BoundingBox(), _this._font = null, _this._fontSize = 24, _this._fontStyle = engine.FontStyle.None, _this._lineSpacing = 0, _this._horizontalAlignment = engine.TextHorizontalAlignment.Center, _this._verticalAlignment = engine.TextVerticalAlignment.Center, _this._enableWrapping = false, _this._overflowMode = engine.OverflowMode.Overflow;
|
|
2436
|
+
_this = UIRenderer1.call(this, entity) || this, _this._textChunks = Array(), _this._subFont = null, _this._text = "", _this._localBounds = new engine.BoundingBox(), _this._font = null, _this._fontSize = 24, _this._fontStyle = engine.FontStyle.None, _this._lineSpacing = 0, _this._characterSpacing = 0, _this._horizontalAlignment = engine.TextHorizontalAlignment.Center, _this._verticalAlignment = engine.TextVerticalAlignment.Center, _this._enableWrapping = false, _this._overflowMode = engine.OverflowMode.Overflow;
|
|
2408
2437
|
var engine$1 = _this.engine;
|
|
2409
2438
|
// @ts-ignore
|
|
2410
2439
|
_this.font = engine$1._textDefaultFont;
|
|
@@ -2581,7 +2610,8 @@
|
|
|
2581
2610
|
var rendererHeight = size.y;
|
|
2582
2611
|
var offsetWidth = rendererWidth * (0.5 - pivot.x);
|
|
2583
2612
|
var offsetHeight = rendererHeight * (0.5 - pivot.y);
|
|
2584
|
-
var
|
|
2613
|
+
var characterSpacing = this._characterSpacing * this._fontSize;
|
|
2614
|
+
var textMetrics = this.enableWrapping ? engine.TextUtils.measureTextWithWrap(this, rendererWidth * pixelsPerResolution, rendererHeight * pixelsPerResolution, this._lineSpacing * this._fontSize, characterSpacing) : engine.TextUtils.measureTextWithoutWrap(this, rendererHeight * pixelsPerResolution, this._lineSpacing * this._fontSize, characterSpacing);
|
|
2585
2615
|
var height = textMetrics.height, lines = textMetrics.lines, lineWidths = textMetrics.lineWidths, lineHeight = textMetrics.lineHeight, lineMaxSizes = textMetrics.lineMaxSizes;
|
|
2586
2616
|
// @ts-ignore
|
|
2587
2617
|
var charRenderInfoPool = this.engine._charRenderInfoPool;
|
|
@@ -2653,7 +2683,7 @@
|
|
|
2653
2683
|
j === firstRow && (minX = Math.min(minX, left));
|
|
2654
2684
|
maxX = Math.max(maxX, right);
|
|
2655
2685
|
}
|
|
2656
|
-
startX += charInfo.xAdvance +
|
|
2686
|
+
startX += charInfo.xAdvance + characterSpacing;
|
|
2657
2687
|
}
|
|
2658
2688
|
}
|
|
2659
2689
|
startY -= lineHeight;
|
|
@@ -2825,7 +2855,7 @@
|
|
|
2825
2855
|
{
|
|
2826
2856
|
key: "lineSpacing",
|
|
2827
2857
|
get: /**
|
|
2828
|
-
* The space between two lines
|
|
2858
|
+
* The space between two lines, in em (ratio of fontSize).
|
|
2829
2859
|
*/ function get() {
|
|
2830
2860
|
return this._lineSpacing;
|
|
2831
2861
|
},
|
|
@@ -2836,6 +2866,20 @@
|
|
|
2836
2866
|
}
|
|
2837
2867
|
}
|
|
2838
2868
|
},
|
|
2869
|
+
{
|
|
2870
|
+
key: "characterSpacing",
|
|
2871
|
+
get: /**
|
|
2872
|
+
* The space between two characters, in em (ratio of fontSize).
|
|
2873
|
+
*/ function get() {
|
|
2874
|
+
return this._characterSpacing;
|
|
2875
|
+
},
|
|
2876
|
+
set: function set(value) {
|
|
2877
|
+
if (this._characterSpacing !== value) {
|
|
2878
|
+
this._characterSpacing = value;
|
|
2879
|
+
this._setDirtyFlagTrue(25);
|
|
2880
|
+
}
|
|
2881
|
+
}
|
|
2882
|
+
},
|
|
2839
2883
|
{
|
|
2840
2884
|
key: "horizontalAlignment",
|
|
2841
2885
|
get: /**
|
|
@@ -2961,6 +3005,9 @@
|
|
|
2961
3005
|
__decorate([
|
|
2962
3006
|
engine.assignmentClone
|
|
2963
3007
|
], Text.prototype, "_lineSpacing", void 0);
|
|
3008
|
+
__decorate([
|
|
3009
|
+
engine.assignmentClone
|
|
3010
|
+
], Text.prototype, "_characterSpacing", void 0);
|
|
2964
3011
|
__decorate([
|
|
2965
3012
|
engine.assignmentClone
|
|
2966
3013
|
], Text.prototype, "_horizontalAlignment", void 0);
|
|
@@ -3378,7 +3425,7 @@
|
|
|
3378
3425
|
// Post-rendering first detection
|
|
3379
3426
|
for(var k2 = 0, n2 = canvasElements.length; k2 < n2; k2++){
|
|
3380
3427
|
var canvas = canvasElements.get(k2);
|
|
3381
|
-
if (!canvas.
|
|
3428
|
+
if (!canvas._canDispatchEvent(camera)) continue;
|
|
3382
3429
|
if (canvas._raycast(ray, hitResult, farClipPlane)) {
|
|
3383
3430
|
this._updateRaycast(hitResult.component, pointer);
|
|
3384
3431
|
return;
|