@galacean/engine-ui 2.0.0-alpha.2 → 2.0.0-alpha.21
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 +121 -214
- 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 +121 -214
- package/dist/main.js.map +1 -1
- package/dist/module.js +122 -215
- package/dist/module.js.map +1 -1
- package/package.json +3 -3
- package/types/component/UICanvas.d.ts +10 -4
- package/types/component/UITransform.d.ts +2 -2
- package/types/component/advanced/Button.d.ts +7 -10
- package/types/component/advanced/Text.d.ts +8 -2
- package/types/component/interactive/UIInteractive.d.ts +1 -3
- package/types/index.d.ts +2 -2
package/dist/main.js
CHANGED
|
@@ -4,92 +4,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var engine = require('@galacean/engine');
|
|
6
6
|
|
|
7
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
8
|
-
try {
|
|
9
|
-
var info = gen[key](arg);
|
|
10
|
-
var value = info.value;
|
|
11
|
-
} catch (error) {
|
|
12
|
-
reject(error);
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
if (info.done) resolve(value);
|
|
16
|
-
else Promise.resolve(value).then(_next, _throw);
|
|
17
|
-
}
|
|
18
|
-
function _async_to_generator(fn) {
|
|
19
|
-
return function() {
|
|
20
|
-
var self = this, args = arguments;
|
|
21
|
-
|
|
22
|
-
return new Promise(function(resolve, reject) {
|
|
23
|
-
var gen = fn.apply(self, args);
|
|
24
|
-
|
|
25
|
-
function _next(value) {
|
|
26
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function _throw(err) {
|
|
30
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
_next(undefined);
|
|
34
|
-
});
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/******************************************************************************
|
|
39
|
-
Copyright (c) Microsoft Corporation.
|
|
40
|
-
|
|
41
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
42
|
-
purpose with or without fee is hereby granted.
|
|
43
|
-
|
|
44
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
45
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
46
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
47
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
48
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
49
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
50
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
51
|
-
***************************************************************************** */
|
|
52
|
-
|
|
53
|
-
function __decorate(decorators, target, key, desc) {
|
|
54
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
55
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
56
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
57
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function __generator(thisArg, body) {
|
|
61
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
62
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
63
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
64
|
-
function step(op) {
|
|
65
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
66
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
67
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
68
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
69
|
-
switch (op[0]) {
|
|
70
|
-
case 0: case 1: t = op; break;
|
|
71
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
72
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
73
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
74
|
-
default:
|
|
75
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
76
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
77
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
78
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
79
|
-
if (t[2]) _.ops.pop();
|
|
80
|
-
_.trys.pop(); continue;
|
|
81
|
-
}
|
|
82
|
-
op = body.call(thisArg, _);
|
|
83
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
84
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
89
|
-
var e = new Error(message);
|
|
90
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
91
|
-
};
|
|
92
|
-
|
|
93
7
|
function _defineProperties(target, props) {
|
|
94
8
|
for (var i = 0; i < props.length; i++) {
|
|
95
9
|
var descriptor = props[i];
|
|
@@ -134,6 +48,33 @@ function _instanceof(left, right) {
|
|
|
134
48
|
} else return left instanceof right;
|
|
135
49
|
}
|
|
136
50
|
|
|
51
|
+
/******************************************************************************
|
|
52
|
+
Copyright (c) Microsoft Corporation.
|
|
53
|
+
|
|
54
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
55
|
+
purpose with or without fee is hereby granted.
|
|
56
|
+
|
|
57
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
58
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
59
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
60
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
61
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
62
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
63
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
64
|
+
***************************************************************************** */
|
|
65
|
+
|
|
66
|
+
function __decorate(decorators, target, key, desc) {
|
|
67
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
68
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
69
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
70
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
74
|
+
var e = new Error(message);
|
|
75
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
76
|
+
};
|
|
77
|
+
|
|
137
78
|
var UIGroup = /*#__PURE__*/ function(Component) {
|
|
138
79
|
_inherits(UIGroup, Component);
|
|
139
80
|
function UIGroup(entity) {
|
|
@@ -296,12 +237,6 @@ __decorate([
|
|
|
296
237
|
__decorate([
|
|
297
238
|
engine.ignoreClone
|
|
298
239
|
], UIGroup.prototype, "_indexInRootCanvas", void 0);
|
|
299
|
-
__decorate([
|
|
300
|
-
engine.ignoreClone
|
|
301
|
-
], UIGroup.prototype, "_group", void 0);
|
|
302
|
-
__decorate([
|
|
303
|
-
engine.ignoreClone
|
|
304
|
-
], UIGroup.prototype, "_rootCanvas", void 0);
|
|
305
240
|
__decorate([
|
|
306
241
|
engine.ignoreClone
|
|
307
242
|
], UIGroup.prototype, "_disorderedElements", void 0);
|
|
@@ -557,9 +492,9 @@ var Utils = /*#__PURE__*/ function() {
|
|
|
557
492
|
this._updateWorldFlagWithParentRectChange(engine.TransformModifyFlags.WmWpWeWqWsWus);
|
|
558
493
|
};
|
|
559
494
|
// @ts-ignore
|
|
560
|
-
_proto._cloneTo = function _cloneTo(target
|
|
495
|
+
_proto._cloneTo = function _cloneTo(target) {
|
|
561
496
|
// @ts-ignore
|
|
562
|
-
Transform.prototype._cloneTo.call(this, target
|
|
497
|
+
Transform.prototype._cloneTo.call(this, target);
|
|
563
498
|
var size = target._size, pivot = target._pivot;
|
|
564
499
|
// @ts-ignore
|
|
565
500
|
size._onValueChanged = pivot._onValueChanged = null;
|
|
@@ -1136,9 +1071,6 @@ exports.UIRenderer = /*#__PURE__*/ function(Renderer) {
|
|
|
1136
1071
|
__decorate([
|
|
1137
1072
|
engine.deepClone
|
|
1138
1073
|
], exports.UIRenderer.prototype, "raycastPadding", void 0);
|
|
1139
|
-
__decorate([
|
|
1140
|
-
engine.ignoreClone
|
|
1141
|
-
], exports.UIRenderer.prototype, "_rootCanvas", void 0);
|
|
1142
1074
|
__decorate([
|
|
1143
1075
|
engine.ignoreClone
|
|
1144
1076
|
], exports.UIRenderer.prototype, "_indexInRootCanvas", void 0);
|
|
@@ -1148,9 +1080,6 @@ __decorate([
|
|
|
1148
1080
|
__decorate([
|
|
1149
1081
|
engine.ignoreClone
|
|
1150
1082
|
], exports.UIRenderer.prototype, "_rootCanvasListeningEntities", void 0);
|
|
1151
|
-
__decorate([
|
|
1152
|
-
engine.ignoreClone
|
|
1153
|
-
], exports.UIRenderer.prototype, "_group", void 0);
|
|
1154
1083
|
__decorate([
|
|
1155
1084
|
engine.ignoreClone
|
|
1156
1085
|
], exports.UIRenderer.prototype, "_indexInGroup", void 0);
|
|
@@ -1267,26 +1196,6 @@ exports.UIRenderer = __decorate([
|
|
|
1267
1196
|
transitions[i].destroy();
|
|
1268
1197
|
}
|
|
1269
1198
|
};
|
|
1270
|
-
// @ts-ignore
|
|
1271
|
-
_proto._cloneTo = function _cloneTo(target, srcRoot, targetRoot) {
|
|
1272
|
-
var transitions = this._transitions;
|
|
1273
|
-
for(var i = 0, n = transitions.length; i < n; i++){
|
|
1274
|
-
var srcTransition = transitions[i];
|
|
1275
|
-
var dstTransition = new transitions[i].constructor();
|
|
1276
|
-
dstTransition.normal = srcTransition.normal;
|
|
1277
|
-
dstTransition.pressed = srcTransition.pressed;
|
|
1278
|
-
dstTransition.hover = srcTransition.hover;
|
|
1279
|
-
dstTransition.disabled = srcTransition.disabled;
|
|
1280
|
-
var transitionTarget = srcTransition.target;
|
|
1281
|
-
if (transitionTarget) {
|
|
1282
|
-
var paths = UIInteractive._targetTempPath;
|
|
1283
|
-
// @ts-ignore
|
|
1284
|
-
var success = engine.Entity._getEntityHierarchyPath(srcRoot, transitionTarget.entity, paths);
|
|
1285
|
-
dstTransition.target = success ? engine.Entity._getEntityByHierarchyPath(targetRoot, paths).getComponent(transitionTarget.constructor) : transitionTarget;
|
|
1286
|
-
}
|
|
1287
|
-
target.addTransition(dstTransition);
|
|
1288
|
-
}
|
|
1289
|
-
};
|
|
1290
1199
|
/**
|
|
1291
1200
|
* @internal
|
|
1292
1201
|
*/ _proto._getRootCanvas = function _getRootCanvas() {
|
|
@@ -1397,10 +1306,6 @@ exports.UIRenderer = __decorate([
|
|
|
1397
1306
|
]);
|
|
1398
1307
|
return UIInteractive;
|
|
1399
1308
|
}(engine.Script);
|
|
1400
|
-
UIInteractive._targetTempPath = new Array();
|
|
1401
|
-
__decorate([
|
|
1402
|
-
engine.ignoreClone
|
|
1403
|
-
], UIInteractive.prototype, "_rootCanvas", void 0);
|
|
1404
1309
|
__decorate([
|
|
1405
1310
|
engine.ignoreClone
|
|
1406
1311
|
], UIInteractive.prototype, "_indexInRootCanvas", void 0);
|
|
@@ -1410,9 +1315,6 @@ __decorate([
|
|
|
1410
1315
|
__decorate([
|
|
1411
1316
|
engine.ignoreClone
|
|
1412
1317
|
], UIInteractive.prototype, "_rootCanvasListeningEntities", void 0);
|
|
1413
|
-
__decorate([
|
|
1414
|
-
engine.ignoreClone
|
|
1415
|
-
], UIInteractive.prototype, "_group", void 0);
|
|
1416
1318
|
__decorate([
|
|
1417
1319
|
engine.ignoreClone
|
|
1418
1320
|
], UIInteractive.prototype, "_indexInGroup", void 0);
|
|
@@ -1429,7 +1331,7 @@ __decorate([
|
|
|
1429
1331
|
engine.ignoreClone
|
|
1430
1332
|
], UIInteractive.prototype, "_globalInteractiveDirty", void 0);
|
|
1431
1333
|
__decorate([
|
|
1432
|
-
engine.
|
|
1334
|
+
engine.deepClone
|
|
1433
1335
|
], UIInteractive.prototype, "_transitions", void 0);
|
|
1434
1336
|
__decorate([
|
|
1435
1337
|
engine.assignmentClone
|
|
@@ -1502,7 +1404,18 @@ exports.UICanvas = /*#__PURE__*/ function(Component) {
|
|
|
1502
1404
|
/**
|
|
1503
1405
|
* @internal
|
|
1504
1406
|
*/ _proto._canRender = function _canRender(camera) {
|
|
1505
|
-
return this.
|
|
1407
|
+
return this._realRenderMode !== CanvasRenderMode.ScreenSpaceCamera || this._camera === camera;
|
|
1408
|
+
};
|
|
1409
|
+
/**
|
|
1410
|
+
* @internal
|
|
1411
|
+
*/ _proto._canDispatchEvent = function _canDispatchEvent(camera) {
|
|
1412
|
+
var realMode = this._realRenderMode;
|
|
1413
|
+
if (realMode === CanvasRenderMode.ScreenSpaceOverlay) {
|
|
1414
|
+
return true;
|
|
1415
|
+
}
|
|
1416
|
+
var assignedCamera = this._camera;
|
|
1417
|
+
// @ts-ignore
|
|
1418
|
+
return !assignedCamera || !assignedCamera._phasedActiveInScene || assignedCamera === camera;
|
|
1506
1419
|
};
|
|
1507
1420
|
/**
|
|
1508
1421
|
* @internal
|
|
@@ -1602,16 +1515,8 @@ exports.UICanvas = /*#__PURE__*/ function(Component) {
|
|
|
1602
1515
|
};
|
|
1603
1516
|
/**
|
|
1604
1517
|
* @internal
|
|
1605
|
-
*/ _proto._cloneTo = function _cloneTo(target
|
|
1518
|
+
*/ _proto._cloneTo = function _cloneTo(target) {
|
|
1606
1519
|
target.renderMode = this._renderMode;
|
|
1607
|
-
var renderCamera = this._renderCamera;
|
|
1608
|
-
if (renderCamera) {
|
|
1609
|
-
var paths = UICanvas._targetTempPath;
|
|
1610
|
-
// @ts-ignore
|
|
1611
|
-
var success = engine.Entity._getEntityHierarchyPath(srcRoot, renderCamera.entity, paths);
|
|
1612
|
-
// @ts-ignore
|
|
1613
|
-
target.renderCamera = success ? engine.Entity._getEntityByHierarchyPath(targetRoot, paths).getComponent(engine.Camera) : renderCamera;
|
|
1614
|
-
}
|
|
1615
1520
|
};
|
|
1616
1521
|
_proto._getRenderers = function _getRenderers() {
|
|
1617
1522
|
var _this = this, renderers = _this._orderedRenderers, entity = _this.entity;
|
|
@@ -1628,7 +1533,7 @@ exports.UICanvas = /*#__PURE__*/ function(Component) {
|
|
|
1628
1533
|
var transform = this.entity.transform;
|
|
1629
1534
|
var realRenderMode = this._realRenderMode;
|
|
1630
1535
|
if (realRenderMode === CanvasRenderMode.ScreenSpaceCamera) {
|
|
1631
|
-
var cameraEntity = this.
|
|
1536
|
+
var cameraEntity = this._camera.entity;
|
|
1632
1537
|
if (!this._isSameOrChildEntity(cameraEntity)) {
|
|
1633
1538
|
var cameraTransform = cameraEntity.transform;
|
|
1634
1539
|
var cameraWorldPosition = cameraTransform.worldPosition, cameraWorldForward = cameraTransform.worldForward;
|
|
@@ -1649,9 +1554,9 @@ exports.UICanvas = /*#__PURE__*/ function(Component) {
|
|
|
1649
1554
|
var curWidth;
|
|
1650
1555
|
var curHeight;
|
|
1651
1556
|
if (realRenderMode === CanvasRenderMode.ScreenSpaceCamera) {
|
|
1652
|
-
var
|
|
1653
|
-
curHeight =
|
|
1654
|
-
curWidth =
|
|
1557
|
+
var camera = this._camera;
|
|
1558
|
+
curHeight = camera.isOrthographic ? camera.orthographicSize * 2 : 2 * (Math.tan(engine.MathUtil.degreeToRadian(camera.fieldOfView * 0.5)) * this._distance);
|
|
1559
|
+
curWidth = camera.aspectRatio * curHeight;
|
|
1655
1560
|
} else {
|
|
1656
1561
|
var canvas = this.engine.canvas;
|
|
1657
1562
|
curHeight = canvas.height;
|
|
@@ -1721,7 +1626,7 @@ exports.UICanvas = /*#__PURE__*/ function(Component) {
|
|
|
1721
1626
|
return depth;
|
|
1722
1627
|
};
|
|
1723
1628
|
_proto._updateCameraObserver = function _updateCameraObserver() {
|
|
1724
|
-
var camera = this._isRootCanvas && this._renderMode === CanvasRenderMode.ScreenSpaceCamera ? this.
|
|
1629
|
+
var camera = this._isRootCanvas && this._renderMode === CanvasRenderMode.ScreenSpaceCamera ? this._camera : null;
|
|
1725
1630
|
var preCamera = this._cameraObserver;
|
|
1726
1631
|
if (preCamera !== camera) {
|
|
1727
1632
|
this._cameraObserver = camera;
|
|
@@ -1747,10 +1652,10 @@ exports.UICanvas = /*#__PURE__*/ function(Component) {
|
|
|
1747
1652
|
this._adapterSizeInScreenSpace();
|
|
1748
1653
|
break;
|
|
1749
1654
|
case engine.CameraModifyFlags.FieldOfView:
|
|
1750
|
-
!this.
|
|
1655
|
+
!this._camera.isOrthographic && this._adapterSizeInScreenSpace();
|
|
1751
1656
|
break;
|
|
1752
1657
|
case engine.CameraModifyFlags.OrthographicSize:
|
|
1753
|
-
this.
|
|
1658
|
+
this._camera.isOrthographic && this._adapterSizeInScreenSpace();
|
|
1754
1659
|
break;
|
|
1755
1660
|
case engine.CameraModifyFlags.DisableInScene:
|
|
1756
1661
|
this._setRealRenderMode(CanvasRenderMode.ScreenSpaceOverlay);
|
|
@@ -1821,9 +1726,10 @@ exports.UICanvas = /*#__PURE__*/ function(Component) {
|
|
|
1821
1726
|
};
|
|
1822
1727
|
_proto._getRealRenderMode = function _getRealRenderMode() {
|
|
1823
1728
|
if (this._isRootCanvas) {
|
|
1824
|
-
var
|
|
1729
|
+
var _this__camera;
|
|
1825
1730
|
var mode = this._renderMode;
|
|
1826
|
-
|
|
1731
|
+
// @ts-ignore
|
|
1732
|
+
if (mode === CanvasRenderMode.ScreenSpaceCamera && !((_this__camera = this._camera) == null ? void 0 : _this__camera._phasedActiveInScene)) {
|
|
1827
1733
|
return CanvasRenderMode.ScreenSpaceOverlay;
|
|
1828
1734
|
} else {
|
|
1829
1735
|
return mode;
|
|
@@ -1913,18 +1819,22 @@ exports.UICanvas = /*#__PURE__*/ function(Component) {
|
|
|
1913
1819
|
}
|
|
1914
1820
|
},
|
|
1915
1821
|
{
|
|
1916
|
-
key: "
|
|
1822
|
+
key: "camera",
|
|
1917
1823
|
get: /**
|
|
1918
|
-
* The camera
|
|
1919
|
-
* @remarks
|
|
1824
|
+
* The camera associated with this canvas.
|
|
1825
|
+
* @remarks
|
|
1826
|
+
* - `ScreenSpaceCamera` mode: Used for rendering adaptation. Defaults to `ScreenSpaceOverlay` if not assigned.
|
|
1827
|
+
* - `WorldSpace` mode: Used for event detection. If not assigned, events are handled by the highest-priority camera.
|
|
1920
1828
|
*/ function get() {
|
|
1921
|
-
return this.
|
|
1829
|
+
return this._camera;
|
|
1922
1830
|
},
|
|
1923
1831
|
set: function set(value) {
|
|
1924
|
-
var preCamera = this.
|
|
1832
|
+
var preCamera = this._camera;
|
|
1925
1833
|
if (preCamera !== value) {
|
|
1926
|
-
value && this._isSameOrChildEntity(value.entity)
|
|
1927
|
-
|
|
1834
|
+
if (value && this._isSameOrChildEntity(value.entity)) {
|
|
1835
|
+
engine.Logger.warn("Camera entity matching or nested within the canvas entity disables canvas auto-adaptation in ScreenSpaceCamera mode.");
|
|
1836
|
+
}
|
|
1837
|
+
this._camera = value;
|
|
1928
1838
|
this._updateCameraObserver();
|
|
1929
1839
|
var preRenderMode = this._realRenderMode;
|
|
1930
1840
|
var curRenderMode = this._getRealRenderMode();
|
|
@@ -1939,6 +1849,17 @@ exports.UICanvas = /*#__PURE__*/ function(Component) {
|
|
|
1939
1849
|
}
|
|
1940
1850
|
}
|
|
1941
1851
|
},
|
|
1852
|
+
{
|
|
1853
|
+
key: "renderCamera",
|
|
1854
|
+
get: /**
|
|
1855
|
+
* @deprecated Use {@link camera} instead.
|
|
1856
|
+
*/ function get() {
|
|
1857
|
+
return this.camera;
|
|
1858
|
+
},
|
|
1859
|
+
set: function set(value) {
|
|
1860
|
+
this.camera = value;
|
|
1861
|
+
}
|
|
1862
|
+
},
|
|
1942
1863
|
{
|
|
1943
1864
|
key: "resolutionAdaptationMode",
|
|
1944
1865
|
get: /**
|
|
@@ -1992,16 +1913,12 @@ exports.UICanvas = /*#__PURE__*/ function(Component) {
|
|
|
1992
1913
|
return UICanvas;
|
|
1993
1914
|
}(engine.Component);
|
|
1994
1915
|
/** @internal */ exports.UICanvas._hierarchyCounter = 1;
|
|
1995
|
-
exports.UICanvas._targetTempPath = [];
|
|
1996
1916
|
exports.UICanvas._tempGroupAbleList = [];
|
|
1997
1917
|
exports.UICanvas._tempVec3 = new engine.Vector3();
|
|
1998
1918
|
exports.UICanvas._tempMat = new engine.Matrix();
|
|
1999
1919
|
__decorate([
|
|
2000
1920
|
engine.ignoreClone
|
|
2001
1921
|
], exports.UICanvas.prototype, "_canvasIndex", void 0);
|
|
2002
|
-
__decorate([
|
|
2003
|
-
engine.ignoreClone
|
|
2004
|
-
], exports.UICanvas.prototype, "_rootCanvas", void 0);
|
|
2005
1922
|
__decorate([
|
|
2006
1923
|
engine.ignoreClone
|
|
2007
1924
|
], exports.UICanvas.prototype, "_indexInRootCanvas", void 0);
|
|
@@ -2032,12 +1949,6 @@ __decorate([
|
|
|
2032
1949
|
__decorate([
|
|
2033
1950
|
engine.ignoreClone
|
|
2034
1951
|
], exports.UICanvas.prototype, "_renderMode", void 0);
|
|
2035
|
-
__decorate([
|
|
2036
|
-
engine.ignoreClone
|
|
2037
|
-
], exports.UICanvas.prototype, "_renderCamera", void 0);
|
|
2038
|
-
__decorate([
|
|
2039
|
-
engine.ignoreClone
|
|
2040
|
-
], exports.UICanvas.prototype, "_cameraObserver", void 0);
|
|
2041
1952
|
__decorate([
|
|
2042
1953
|
engine.assignmentClone
|
|
2043
1954
|
], exports.UICanvas.prototype, "_resolutionAdaptationMode", void 0);
|
|
@@ -2098,45 +2009,35 @@ var Button = /*#__PURE__*/ function(UIInteractive) {
|
|
|
2098
2009
|
_inherits(Button, UIInteractive);
|
|
2099
2010
|
function Button() {
|
|
2100
2011
|
var _this;
|
|
2101
|
-
_this = UIInteractive.apply(this, arguments) || this, _this.
|
|
2012
|
+
_this = UIInteractive.apply(this, arguments) || this, /** Signal emitted when the button is clicked. */ _this.onClick = new engine.Signal();
|
|
2102
2013
|
return _this;
|
|
2103
2014
|
}
|
|
2104
2015
|
var _proto = Button.prototype;
|
|
2016
|
+
_proto.onPointerClick = function onPointerClick(event) {
|
|
2017
|
+
if (!this._getGlobalInteractive()) return;
|
|
2018
|
+
this.onClick.invoke(event);
|
|
2019
|
+
};
|
|
2020
|
+
_proto.onDestroy = function onDestroy() {
|
|
2021
|
+
UIInteractive.prototype.onDestroy.call(this);
|
|
2022
|
+
this.onClick.removeAll();
|
|
2023
|
+
};
|
|
2105
2024
|
/**
|
|
2106
2025
|
* Add a listening function for click.
|
|
2107
|
-
* @
|
|
2026
|
+
* @deprecated Use `onClick.on(listener, context)` instead.
|
|
2108
2027
|
*/ _proto.addClicked = function addClicked(listener) {
|
|
2109
|
-
this.
|
|
2110
|
-
fn: listener
|
|
2111
|
-
});
|
|
2028
|
+
this.onClick.on(listener);
|
|
2112
2029
|
};
|
|
2113
2030
|
/**
|
|
2114
2031
|
* Remove a listening function of click.
|
|
2115
|
-
* @
|
|
2032
|
+
* @deprecated Use `onClick.off(listener, context)` instead.
|
|
2116
2033
|
*/ _proto.removeClicked = function removeClicked(listener) {
|
|
2117
|
-
this.
|
|
2118
|
-
return value.fn === listener ? value.destroyed = true : false;
|
|
2119
|
-
});
|
|
2120
|
-
};
|
|
2121
|
-
_proto.onPointerClick = function onPointerClick(event) {
|
|
2122
|
-
if (!this._getGlobalInteractive()) return;
|
|
2123
|
-
var listeners = this._listeners.getLoopArray();
|
|
2124
|
-
for(var i = 0, n = listeners.length; i < n; i++){
|
|
2125
|
-
var listener = listeners[i];
|
|
2126
|
-
!listener.destroyed && listener.fn(event);
|
|
2127
|
-
}
|
|
2128
|
-
};
|
|
2129
|
-
_proto.onDestroy = function onDestroy() {
|
|
2130
|
-
UIInteractive.prototype.onDestroy.call(this);
|
|
2131
|
-
this._listeners.findAndRemove(function(value) {
|
|
2132
|
-
return value.destroyed = true;
|
|
2133
|
-
});
|
|
2034
|
+
this.onClick.off(listener);
|
|
2134
2035
|
};
|
|
2135
2036
|
return Button;
|
|
2136
2037
|
}(UIInteractive);
|
|
2137
2038
|
__decorate([
|
|
2138
|
-
engine.
|
|
2139
|
-
], Button.prototype, "
|
|
2039
|
+
engine.deepClone
|
|
2040
|
+
], Button.prototype, "onClick", void 0);
|
|
2140
2041
|
|
|
2141
2042
|
/**
|
|
2142
2043
|
* UI element that renders an image.
|
|
@@ -2146,6 +2047,7 @@ __decorate([
|
|
|
2146
2047
|
var _this;
|
|
2147
2048
|
_this = UIRenderer1.call(this, entity) || this, _this._sprite = null, _this._tileMode = engine.SpriteTileMode.Continuous, _this._tiledAdaptiveThreshold = 0.5;
|
|
2148
2049
|
_this.drawMode = engine.SpriteDrawMode.Simple;
|
|
2050
|
+
// @ts-ignore
|
|
2149
2051
|
_this.setMaterial(_this._engine._getUIDefaultMaterial());
|
|
2150
2052
|
_this._onSpriteChange = _this._onSpriteChange.bind(_this);
|
|
2151
2053
|
return _this;
|
|
@@ -2165,9 +2067,9 @@ __decorate([
|
|
|
2165
2067
|
};
|
|
2166
2068
|
/**
|
|
2167
2069
|
* @internal
|
|
2168
|
-
*/ _proto._cloneTo = function _cloneTo(target
|
|
2070
|
+
*/ _proto._cloneTo = function _cloneTo(target) {
|
|
2169
2071
|
// @ts-ignore
|
|
2170
|
-
UIRenderer1.prototype._cloneTo.call(this, target
|
|
2072
|
+
UIRenderer1.prototype._cloneTo.call(this, target);
|
|
2171
2073
|
target.sprite = this._sprite;
|
|
2172
2074
|
target.drawMode = this._drawMode;
|
|
2173
2075
|
};
|
|
@@ -2197,6 +2099,7 @@ __decorate([
|
|
|
2197
2099
|
}
|
|
2198
2100
|
// @todo: This question needs to be raised rather than hidden.
|
|
2199
2101
|
if (material.destroyed) {
|
|
2102
|
+
// @ts-ignore
|
|
2200
2103
|
material = this._engine._getUIDefaultMaterial();
|
|
2201
2104
|
}
|
|
2202
2105
|
var alpha = this._getGlobalAlpha();
|
|
@@ -2404,7 +2307,7 @@ __decorate([
|
|
|
2404
2307
|
_inherits(Text, UIRenderer1);
|
|
2405
2308
|
function Text(entity) {
|
|
2406
2309
|
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;
|
|
2310
|
+
_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
2311
|
var engine$1 = _this.engine;
|
|
2409
2312
|
// @ts-ignore
|
|
2410
2313
|
_this.font = engine$1._textDefaultFont;
|
|
@@ -2427,9 +2330,9 @@ __decorate([
|
|
|
2427
2330
|
this._subFont && (this._subFont = null);
|
|
2428
2331
|
};
|
|
2429
2332
|
// @ts-ignore
|
|
2430
|
-
_proto._cloneTo = function _cloneTo(target
|
|
2333
|
+
_proto._cloneTo = function _cloneTo(target) {
|
|
2431
2334
|
// @ts-ignore
|
|
2432
|
-
UIRenderer1.prototype._cloneTo.call(this, target
|
|
2335
|
+
UIRenderer1.prototype._cloneTo.call(this, target);
|
|
2433
2336
|
target.font = this._font;
|
|
2434
2337
|
target._subFont = this._subFont;
|
|
2435
2338
|
};
|
|
@@ -2482,7 +2385,7 @@ __decorate([
|
|
|
2482
2385
|
var canvas = this._getRootCanvas();
|
|
2483
2386
|
if (this._isContainDirtyFlag(8)) {
|
|
2484
2387
|
this._updateLocalData();
|
|
2485
|
-
this.
|
|
2388
|
+
this._setDirtyFlagFalse(8);
|
|
2486
2389
|
}
|
|
2487
2390
|
if (this._isContainDirtyFlag(16)) {
|
|
2488
2391
|
this._updatePosition();
|
|
@@ -2581,7 +2484,8 @@ __decorate([
|
|
|
2581
2484
|
var rendererHeight = size.y;
|
|
2582
2485
|
var offsetWidth = rendererWidth * (0.5 - pivot.x);
|
|
2583
2486
|
var offsetHeight = rendererHeight * (0.5 - pivot.y);
|
|
2584
|
-
var
|
|
2487
|
+
var characterSpacing = this._characterSpacing * this._fontSize;
|
|
2488
|
+
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
2489
|
var height = textMetrics.height, lines = textMetrics.lines, lineWidths = textMetrics.lineWidths, lineHeight = textMetrics.lineHeight, lineMaxSizes = textMetrics.lineMaxSizes;
|
|
2586
2490
|
// @ts-ignore
|
|
2587
2491
|
var charRenderInfoPool = this.engine._charRenderInfoPool;
|
|
@@ -2653,7 +2557,7 @@ __decorate([
|
|
|
2653
2557
|
j === firstRow && (minX = Math.min(minX, left));
|
|
2654
2558
|
maxX = Math.max(maxX, right);
|
|
2655
2559
|
}
|
|
2656
|
-
startX += charInfo.xAdvance +
|
|
2560
|
+
startX += charInfo.xAdvance + characterSpacing;
|
|
2657
2561
|
}
|
|
2658
2562
|
}
|
|
2659
2563
|
startY -= lineHeight;
|
|
@@ -2713,7 +2617,7 @@ __decorate([
|
|
|
2713
2617
|
};
|
|
2714
2618
|
_proto._isTextNoVisible = function _isTextNoVisible() {
|
|
2715
2619
|
var size = this._transformEntity.transform.size;
|
|
2716
|
-
return this._text === "" || this._fontSize === 0 || this.enableWrapping && size.x <= 0 || this.overflowMode === engine.OverflowMode.Truncate && size.y <= 0 || !this._getRootCanvas();
|
|
2620
|
+
return !this._font || this._text === "" || this._fontSize === 0 || this.enableWrapping && size.x <= 0 || this.overflowMode === engine.OverflowMode.Truncate && size.y <= 0 || !this._getRootCanvas();
|
|
2717
2621
|
};
|
|
2718
2622
|
_proto._buildChunk = function _buildChunk(textChunk, count) {
|
|
2719
2623
|
var _this_color = this.color, r = _this_color.r, g = _this_color.g, b = _this_color.b, a = _this_color.a;
|
|
@@ -2825,7 +2729,7 @@ __decorate([
|
|
|
2825
2729
|
{
|
|
2826
2730
|
key: "lineSpacing",
|
|
2827
2731
|
get: /**
|
|
2828
|
-
* The space between two lines
|
|
2732
|
+
* The space between two lines, in em (ratio of fontSize).
|
|
2829
2733
|
*/ function get() {
|
|
2830
2734
|
return this._lineSpacing;
|
|
2831
2735
|
},
|
|
@@ -2836,6 +2740,20 @@ __decorate([
|
|
|
2836
2740
|
}
|
|
2837
2741
|
}
|
|
2838
2742
|
},
|
|
2743
|
+
{
|
|
2744
|
+
key: "characterSpacing",
|
|
2745
|
+
get: /**
|
|
2746
|
+
* The space between two characters, in em (ratio of fontSize).
|
|
2747
|
+
*/ function get() {
|
|
2748
|
+
return this._characterSpacing;
|
|
2749
|
+
},
|
|
2750
|
+
set: function set(value) {
|
|
2751
|
+
if (this._characterSpacing !== value) {
|
|
2752
|
+
this._characterSpacing = value;
|
|
2753
|
+
this._setDirtyFlagTrue(25);
|
|
2754
|
+
}
|
|
2755
|
+
}
|
|
2756
|
+
},
|
|
2839
2757
|
{
|
|
2840
2758
|
key: "horizontalAlignment",
|
|
2841
2759
|
get: /**
|
|
@@ -2961,6 +2879,9 @@ __decorate([
|
|
|
2961
2879
|
__decorate([
|
|
2962
2880
|
engine.assignmentClone
|
|
2963
2881
|
], Text.prototype, "_lineSpacing", void 0);
|
|
2882
|
+
__decorate([
|
|
2883
|
+
engine.assignmentClone
|
|
2884
|
+
], Text.prototype, "_characterSpacing", void 0);
|
|
2964
2885
|
__decorate([
|
|
2965
2886
|
engine.assignmentClone
|
|
2966
2887
|
], Text.prototype, "_horizontalAlignment", void 0);
|
|
@@ -3378,7 +3299,7 @@ exports.UIPointerEventEmitter = /*#__PURE__*/ function(PointerEventEmitter1) {
|
|
|
3378
3299
|
// Post-rendering first detection
|
|
3379
3300
|
for(var k2 = 0, n2 = canvasElements.length; k2 < n2; k2++){
|
|
3380
3301
|
var canvas = canvasElements.get(k2);
|
|
3381
|
-
if (!canvas.
|
|
3302
|
+
if (!canvas._canDispatchEvent(camera)) continue;
|
|
3382
3303
|
if (canvas._raycast(ray, hitResult, farClipPlane)) {
|
|
3383
3304
|
this._updateRaycast(hitResult.component, pointer);
|
|
3384
3305
|
return;
|
|
@@ -3605,20 +3526,6 @@ ApplyMixins(engine.Engine, [
|
|
|
3605
3526
|
ApplyMixins(engine.Entity, [
|
|
3606
3527
|
EntityExtension
|
|
3607
3528
|
]);
|
|
3608
|
-
engine.ReflectionParser.registerCustomParseComponent("Text", /*#__PURE__*/ _async_to_generator(function(instance, item) {
|
|
3609
|
-
var props;
|
|
3610
|
-
return __generator(this, function(_state) {
|
|
3611
|
-
props = item.props;
|
|
3612
|
-
if (!props.font) {
|
|
3613
|
-
// @ts-ignore
|
|
3614
|
-
instance.font = engine.Font.createFromOS(instance.engine, props.fontFamily || "Arial");
|
|
3615
|
-
}
|
|
3616
|
-
return [
|
|
3617
|
-
2,
|
|
3618
|
-
instance
|
|
3619
|
-
];
|
|
3620
|
-
});
|
|
3621
|
-
}));
|
|
3622
3529
|
/**
|
|
3623
3530
|
* Register GUI components for the editor.
|
|
3624
3531
|
*/ function registerGUI() {
|