@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/module.js CHANGED
@@ -1,90 +1,4 @@
1
- import { EntityModifyFlags, ignoreClone, assignmentClone, DisorderedArray, Component, TransformModifyFlags, Transform, deepClone, Vector2, Rect, MathUtil, Vector3, Matrix, Plane, ShaderProperty, dependentComponents, DependentMode, BatchUtils, ShaderMacroCollection, Renderer, Vector4, Color, RendererUpdateFlags, Entity, Script, Camera, CameraModifyFlags, Logger, SafeLoopArray, SpriteDrawMode, RenderQueueFlags, SpriteModifyFlags, SpriteTileMode, TiledSpriteAssembler, SlicedSpriteAssembler, SimpleSpriteAssembler, BoundingBox, ShaderData, ShaderDataGroup, TextUtils, Engine, TextVerticalAlignment, TextHorizontalAlignment, OverflowMode, CharRenderInfo, FontStyle, ReferResource, registerPointerEventEmitter, PointerEventEmitter, CameraClearFlags, ReflectionParser, Material, BlendFactor, BlendOperation, CullMode, RenderQueueType, Loader, Shader, ShaderPass, PipelineStage, Font } from '@galacean/engine';
2
-
3
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
4
- try {
5
- var info = gen[key](arg);
6
- var value = info.value;
7
- } catch (error) {
8
- reject(error);
9
- return;
10
- }
11
- if (info.done) resolve(value);
12
- else Promise.resolve(value).then(_next, _throw);
13
- }
14
- function _async_to_generator(fn) {
15
- return function() {
16
- var self = this, args = arguments;
17
-
18
- return new Promise(function(resolve, reject) {
19
- var gen = fn.apply(self, args);
20
-
21
- function _next(value) {
22
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
23
- }
24
-
25
- function _throw(err) {
26
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
27
- }
28
-
29
- _next(undefined);
30
- });
31
- };
32
- }
33
-
34
- /******************************************************************************
35
- Copyright (c) Microsoft Corporation.
36
-
37
- Permission to use, copy, modify, and/or distribute this software for any
38
- purpose with or without fee is hereby granted.
39
-
40
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
41
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
42
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
43
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
44
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
45
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
46
- PERFORMANCE OF THIS SOFTWARE.
47
- ***************************************************************************** */
48
-
49
- function __decorate(decorators, target, key, desc) {
50
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
51
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
52
- 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;
53
- return c > 3 && r && Object.defineProperty(target, key, r), r;
54
- }
55
-
56
- function __generator(thisArg, body) {
57
- 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);
58
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
59
- function verb(n) { return function (v) { return step([n, v]); }; }
60
- function step(op) {
61
- if (f) throw new TypeError("Generator is already executing.");
62
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
63
- 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;
64
- if (y = 0, t) op = [op[0] & 2, t.value];
65
- switch (op[0]) {
66
- case 0: case 1: t = op; break;
67
- case 4: _.label++; return { value: op[1], done: false };
68
- case 5: _.label++; y = op[1]; op = [0]; continue;
69
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
70
- default:
71
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
72
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
73
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
74
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
75
- if (t[2]) _.ops.pop();
76
- _.trys.pop(); continue;
77
- }
78
- op = body.call(thisArg, _);
79
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
80
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
81
- }
82
- }
83
-
84
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
85
- var e = new Error(message);
86
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
87
- };
1
+ import { EntityModifyFlags, ignoreClone, assignmentClone, DisorderedArray, Component, TransformModifyFlags, Transform, deepClone, Vector2, Rect, MathUtil, Vector3, Matrix, Plane, ShaderProperty, dependentComponents, DependentMode, BatchUtils, ShaderMacroCollection, Renderer, Vector4, Color, RendererUpdateFlags, Script, CameraModifyFlags, Logger, Signal, SpriteDrawMode, RenderQueueFlags, SpriteModifyFlags, SpriteTileMode, TiledSpriteAssembler, SlicedSpriteAssembler, SimpleSpriteAssembler, BoundingBox, ShaderData, ShaderDataGroup, TextUtils, Engine, TextVerticalAlignment, TextHorizontalAlignment, OverflowMode, CharRenderInfo, FontStyle, ReferResource, registerPointerEventEmitter, PointerEventEmitter, CameraClearFlags, Material, BlendFactor, BlendOperation, CullMode, RenderQueueType, Entity, Loader, Shader, ShaderPass, PipelineStage } from '@galacean/engine';
88
2
 
89
3
  function _defineProperties(target, props) {
90
4
  for (var i = 0; i < props.length; i++) {
@@ -130,6 +44,33 @@ function _instanceof(left, right) {
130
44
  } else return left instanceof right;
131
45
  }
132
46
 
47
+ /******************************************************************************
48
+ Copyright (c) Microsoft Corporation.
49
+
50
+ Permission to use, copy, modify, and/or distribute this software for any
51
+ purpose with or without fee is hereby granted.
52
+
53
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
54
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
55
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
56
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
57
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
58
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
59
+ PERFORMANCE OF THIS SOFTWARE.
60
+ ***************************************************************************** */
61
+
62
+ function __decorate(decorators, target, key, desc) {
63
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
64
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
65
+ 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;
66
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
67
+ }
68
+
69
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
70
+ var e = new Error(message);
71
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
72
+ };
73
+
133
74
  var UIGroup = /*#__PURE__*/ function(Component) {
134
75
  _inherits(UIGroup, Component);
135
76
  function UIGroup(entity) {
@@ -292,12 +233,6 @@ __decorate([
292
233
  __decorate([
293
234
  ignoreClone
294
235
  ], UIGroup.prototype, "_indexInRootCanvas", void 0);
295
- __decorate([
296
- ignoreClone
297
- ], UIGroup.prototype, "_group", void 0);
298
- __decorate([
299
- ignoreClone
300
- ], UIGroup.prototype, "_rootCanvas", void 0);
301
236
  __decorate([
302
237
  ignoreClone
303
238
  ], UIGroup.prototype, "_disorderedElements", void 0);
@@ -553,9 +488,9 @@ var Utils = /*#__PURE__*/ function() {
553
488
  this._updateWorldFlagWithParentRectChange(TransformModifyFlags.WmWpWeWqWsWus);
554
489
  };
555
490
  // @ts-ignore
556
- _proto._cloneTo = function _cloneTo(target, srcRoot, targetRoot) {
491
+ _proto._cloneTo = function _cloneTo(target) {
557
492
  // @ts-ignore
558
- Transform.prototype._cloneTo.call(this, target, srcRoot, targetRoot);
493
+ Transform.prototype._cloneTo.call(this, target);
559
494
  var size = target._size, pivot = target._pivot;
560
495
  // @ts-ignore
561
496
  size._onValueChanged = pivot._onValueChanged = null;
@@ -1132,9 +1067,6 @@ var UIRenderer = /*#__PURE__*/ function(Renderer) {
1132
1067
  __decorate([
1133
1068
  deepClone
1134
1069
  ], UIRenderer.prototype, "raycastPadding", void 0);
1135
- __decorate([
1136
- ignoreClone
1137
- ], UIRenderer.prototype, "_rootCanvas", void 0);
1138
1070
  __decorate([
1139
1071
  ignoreClone
1140
1072
  ], UIRenderer.prototype, "_indexInRootCanvas", void 0);
@@ -1144,9 +1076,6 @@ __decorate([
1144
1076
  __decorate([
1145
1077
  ignoreClone
1146
1078
  ], UIRenderer.prototype, "_rootCanvasListeningEntities", void 0);
1147
- __decorate([
1148
- ignoreClone
1149
- ], UIRenderer.prototype, "_group", void 0);
1150
1079
  __decorate([
1151
1080
  ignoreClone
1152
1081
  ], UIRenderer.prototype, "_indexInGroup", void 0);
@@ -1263,26 +1192,6 @@ UIRenderer = __decorate([
1263
1192
  transitions[i].destroy();
1264
1193
  }
1265
1194
  };
1266
- // @ts-ignore
1267
- _proto._cloneTo = function _cloneTo(target, srcRoot, targetRoot) {
1268
- var transitions = this._transitions;
1269
- for(var i = 0, n = transitions.length; i < n; i++){
1270
- var srcTransition = transitions[i];
1271
- var dstTransition = new transitions[i].constructor();
1272
- dstTransition.normal = srcTransition.normal;
1273
- dstTransition.pressed = srcTransition.pressed;
1274
- dstTransition.hover = srcTransition.hover;
1275
- dstTransition.disabled = srcTransition.disabled;
1276
- var transitionTarget = srcTransition.target;
1277
- if (transitionTarget) {
1278
- var paths = UIInteractive._targetTempPath;
1279
- // @ts-ignore
1280
- var success = Entity._getEntityHierarchyPath(srcRoot, transitionTarget.entity, paths);
1281
- dstTransition.target = success ? Entity._getEntityByHierarchyPath(targetRoot, paths).getComponent(transitionTarget.constructor) : transitionTarget;
1282
- }
1283
- target.addTransition(dstTransition);
1284
- }
1285
- };
1286
1195
  /**
1287
1196
  * @internal
1288
1197
  */ _proto._getRootCanvas = function _getRootCanvas() {
@@ -1393,10 +1302,6 @@ UIRenderer = __decorate([
1393
1302
  ]);
1394
1303
  return UIInteractive;
1395
1304
  }(Script);
1396
- UIInteractive._targetTempPath = new Array();
1397
- __decorate([
1398
- ignoreClone
1399
- ], UIInteractive.prototype, "_rootCanvas", void 0);
1400
1305
  __decorate([
1401
1306
  ignoreClone
1402
1307
  ], UIInteractive.prototype, "_indexInRootCanvas", void 0);
@@ -1406,9 +1311,6 @@ __decorate([
1406
1311
  __decorate([
1407
1312
  ignoreClone
1408
1313
  ], UIInteractive.prototype, "_rootCanvasListeningEntities", void 0);
1409
- __decorate([
1410
- ignoreClone
1411
- ], UIInteractive.prototype, "_group", void 0);
1412
1314
  __decorate([
1413
1315
  ignoreClone
1414
1316
  ], UIInteractive.prototype, "_indexInGroup", void 0);
@@ -1425,7 +1327,7 @@ __decorate([
1425
1327
  ignoreClone
1426
1328
  ], UIInteractive.prototype, "_globalInteractiveDirty", void 0);
1427
1329
  __decorate([
1428
- ignoreClone
1330
+ deepClone
1429
1331
  ], UIInteractive.prototype, "_transitions", void 0);
1430
1332
  __decorate([
1431
1333
  assignmentClone
@@ -1498,7 +1400,18 @@ var UICanvas = /*#__PURE__*/ function(Component) {
1498
1400
  /**
1499
1401
  * @internal
1500
1402
  */ _proto._canRender = function _canRender(camera) {
1501
- return this._renderMode !== CanvasRenderMode.ScreenSpaceCamera || this._renderCamera === camera;
1403
+ return this._realRenderMode !== CanvasRenderMode.ScreenSpaceCamera || this._camera === camera;
1404
+ };
1405
+ /**
1406
+ * @internal
1407
+ */ _proto._canDispatchEvent = function _canDispatchEvent(camera) {
1408
+ var realMode = this._realRenderMode;
1409
+ if (realMode === CanvasRenderMode.ScreenSpaceOverlay) {
1410
+ return true;
1411
+ }
1412
+ var assignedCamera = this._camera;
1413
+ // @ts-ignore
1414
+ return !assignedCamera || !assignedCamera._phasedActiveInScene || assignedCamera === camera;
1502
1415
  };
1503
1416
  /**
1504
1417
  * @internal
@@ -1598,16 +1511,8 @@ var UICanvas = /*#__PURE__*/ function(Component) {
1598
1511
  };
1599
1512
  /**
1600
1513
  * @internal
1601
- */ _proto._cloneTo = function _cloneTo(target, srcRoot, targetRoot) {
1514
+ */ _proto._cloneTo = function _cloneTo(target) {
1602
1515
  target.renderMode = this._renderMode;
1603
- var renderCamera = this._renderCamera;
1604
- if (renderCamera) {
1605
- var paths = UICanvas._targetTempPath;
1606
- // @ts-ignore
1607
- var success = Entity._getEntityHierarchyPath(srcRoot, renderCamera.entity, paths);
1608
- // @ts-ignore
1609
- target.renderCamera = success ? Entity._getEntityByHierarchyPath(targetRoot, paths).getComponent(Camera) : renderCamera;
1610
- }
1611
1516
  };
1612
1517
  _proto._getRenderers = function _getRenderers() {
1613
1518
  var _this = this, renderers = _this._orderedRenderers, entity = _this.entity;
@@ -1624,7 +1529,7 @@ var UICanvas = /*#__PURE__*/ function(Component) {
1624
1529
  var transform = this.entity.transform;
1625
1530
  var realRenderMode = this._realRenderMode;
1626
1531
  if (realRenderMode === CanvasRenderMode.ScreenSpaceCamera) {
1627
- var cameraEntity = this._renderCamera.entity;
1532
+ var cameraEntity = this._camera.entity;
1628
1533
  if (!this._isSameOrChildEntity(cameraEntity)) {
1629
1534
  var cameraTransform = cameraEntity.transform;
1630
1535
  var cameraWorldPosition = cameraTransform.worldPosition, cameraWorldForward = cameraTransform.worldForward;
@@ -1645,9 +1550,9 @@ var UICanvas = /*#__PURE__*/ function(Component) {
1645
1550
  var curWidth;
1646
1551
  var curHeight;
1647
1552
  if (realRenderMode === CanvasRenderMode.ScreenSpaceCamera) {
1648
- var renderCamera = this._renderCamera;
1649
- curHeight = renderCamera.isOrthographic ? renderCamera.orthographicSize * 2 : 2 * (Math.tan(MathUtil.degreeToRadian(renderCamera.fieldOfView * 0.5)) * this._distance);
1650
- curWidth = renderCamera.aspectRatio * curHeight;
1553
+ var camera = this._camera;
1554
+ curHeight = camera.isOrthographic ? camera.orthographicSize * 2 : 2 * (Math.tan(MathUtil.degreeToRadian(camera.fieldOfView * 0.5)) * this._distance);
1555
+ curWidth = camera.aspectRatio * curHeight;
1651
1556
  } else {
1652
1557
  var canvas = this.engine.canvas;
1653
1558
  curHeight = canvas.height;
@@ -1717,7 +1622,7 @@ var UICanvas = /*#__PURE__*/ function(Component) {
1717
1622
  return depth;
1718
1623
  };
1719
1624
  _proto._updateCameraObserver = function _updateCameraObserver() {
1720
- var camera = this._isRootCanvas && this._renderMode === CanvasRenderMode.ScreenSpaceCamera ? this._renderCamera : null;
1625
+ var camera = this._isRootCanvas && this._renderMode === CanvasRenderMode.ScreenSpaceCamera ? this._camera : null;
1721
1626
  var preCamera = this._cameraObserver;
1722
1627
  if (preCamera !== camera) {
1723
1628
  this._cameraObserver = camera;
@@ -1743,10 +1648,10 @@ var UICanvas = /*#__PURE__*/ function(Component) {
1743
1648
  this._adapterSizeInScreenSpace();
1744
1649
  break;
1745
1650
  case CameraModifyFlags.FieldOfView:
1746
- !this._renderCamera.isOrthographic && this._adapterSizeInScreenSpace();
1651
+ !this._camera.isOrthographic && this._adapterSizeInScreenSpace();
1747
1652
  break;
1748
1653
  case CameraModifyFlags.OrthographicSize:
1749
- this._renderCamera.isOrthographic && this._adapterSizeInScreenSpace();
1654
+ this._camera.isOrthographic && this._adapterSizeInScreenSpace();
1750
1655
  break;
1751
1656
  case CameraModifyFlags.DisableInScene:
1752
1657
  this._setRealRenderMode(CanvasRenderMode.ScreenSpaceOverlay);
@@ -1817,9 +1722,10 @@ var UICanvas = /*#__PURE__*/ function(Component) {
1817
1722
  };
1818
1723
  _proto._getRealRenderMode = function _getRealRenderMode() {
1819
1724
  if (this._isRootCanvas) {
1820
- var _this__renderCamera;
1725
+ var _this__camera;
1821
1726
  var mode = this._renderMode;
1822
- if (mode === CanvasRenderMode.ScreenSpaceCamera && !((_this__renderCamera = this._renderCamera) == null ? void 0 : _this__renderCamera.enabled)) {
1727
+ // @ts-ignore
1728
+ if (mode === CanvasRenderMode.ScreenSpaceCamera && !((_this__camera = this._camera) == null ? void 0 : _this__camera._phasedActiveInScene)) {
1823
1729
  return CanvasRenderMode.ScreenSpaceOverlay;
1824
1730
  } else {
1825
1731
  return mode;
@@ -1909,18 +1815,22 @@ var UICanvas = /*#__PURE__*/ function(Component) {
1909
1815
  }
1910
1816
  },
1911
1817
  {
1912
- key: "renderCamera",
1818
+ key: "camera",
1913
1819
  get: /**
1914
- * The camera used to render the UI canvas in `ScreenSpaceCamera` mode.
1915
- * @remarks If set `ScreenSpaceCamera` but no corresponding camera is assigned, the actual rendering mode defaults to `ScreenSpaceOverlay`.
1820
+ * The camera associated with this canvas.
1821
+ * @remarks
1822
+ * - `ScreenSpaceCamera` mode: Used for rendering adaptation. Defaults to `ScreenSpaceOverlay` if not assigned.
1823
+ * - `WorldSpace` mode: Used for event detection. If not assigned, events are handled by the highest-priority camera.
1916
1824
  */ function get() {
1917
- return this._renderCamera;
1825
+ return this._camera;
1918
1826
  },
1919
1827
  set: function set(value) {
1920
- var preCamera = this._renderCamera;
1828
+ var preCamera = this._camera;
1921
1829
  if (preCamera !== value) {
1922
- value && this._isSameOrChildEntity(value.entity) && Logger.warn("Camera entity matching or nested within the canvas entity disables canvas auto-adaptation in ScreenSpaceCamera mode.");
1923
- this._renderCamera = value;
1830
+ if (value && this._isSameOrChildEntity(value.entity)) {
1831
+ Logger.warn("Camera entity matching or nested within the canvas entity disables canvas auto-adaptation in ScreenSpaceCamera mode.");
1832
+ }
1833
+ this._camera = value;
1924
1834
  this._updateCameraObserver();
1925
1835
  var preRenderMode = this._realRenderMode;
1926
1836
  var curRenderMode = this._getRealRenderMode();
@@ -1935,6 +1845,17 @@ var UICanvas = /*#__PURE__*/ function(Component) {
1935
1845
  }
1936
1846
  }
1937
1847
  },
1848
+ {
1849
+ key: "renderCamera",
1850
+ get: /**
1851
+ * @deprecated Use {@link camera} instead.
1852
+ */ function get() {
1853
+ return this.camera;
1854
+ },
1855
+ set: function set(value) {
1856
+ this.camera = value;
1857
+ }
1858
+ },
1938
1859
  {
1939
1860
  key: "resolutionAdaptationMode",
1940
1861
  get: /**
@@ -1988,16 +1909,12 @@ var UICanvas = /*#__PURE__*/ function(Component) {
1988
1909
  return UICanvas;
1989
1910
  }(Component);
1990
1911
  /** @internal */ UICanvas._hierarchyCounter = 1;
1991
- UICanvas._targetTempPath = [];
1992
1912
  UICanvas._tempGroupAbleList = [];
1993
1913
  UICanvas._tempVec3 = new Vector3();
1994
1914
  UICanvas._tempMat = new Matrix();
1995
1915
  __decorate([
1996
1916
  ignoreClone
1997
1917
  ], UICanvas.prototype, "_canvasIndex", void 0);
1998
- __decorate([
1999
- ignoreClone
2000
- ], UICanvas.prototype, "_rootCanvas", void 0);
2001
1918
  __decorate([
2002
1919
  ignoreClone
2003
1920
  ], UICanvas.prototype, "_indexInRootCanvas", void 0);
@@ -2028,12 +1945,6 @@ __decorate([
2028
1945
  __decorate([
2029
1946
  ignoreClone
2030
1947
  ], UICanvas.prototype, "_renderMode", void 0);
2031
- __decorate([
2032
- ignoreClone
2033
- ], UICanvas.prototype, "_renderCamera", void 0);
2034
- __decorate([
2035
- ignoreClone
2036
- ], UICanvas.prototype, "_cameraObserver", void 0);
2037
1948
  __decorate([
2038
1949
  assignmentClone
2039
1950
  ], UICanvas.prototype, "_resolutionAdaptationMode", void 0);
@@ -2094,45 +2005,35 @@ var Button = /*#__PURE__*/ function(UIInteractive) {
2094
2005
  _inherits(Button, UIInteractive);
2095
2006
  function Button() {
2096
2007
  var _this;
2097
- _this = UIInteractive.apply(this, arguments) || this, _this._listeners = new SafeLoopArray();
2008
+ _this = UIInteractive.apply(this, arguments) || this, /** Signal emitted when the button is clicked. */ _this.onClick = new Signal();
2098
2009
  return _this;
2099
2010
  }
2100
2011
  var _proto = Button.prototype;
2012
+ _proto.onPointerClick = function onPointerClick(event) {
2013
+ if (!this._getGlobalInteractive()) return;
2014
+ this.onClick.invoke(event);
2015
+ };
2016
+ _proto.onDestroy = function onDestroy() {
2017
+ UIInteractive.prototype.onDestroy.call(this);
2018
+ this.onClick.removeAll();
2019
+ };
2101
2020
  /**
2102
2021
  * Add a listening function for click.
2103
- * @param listener - The listening function
2022
+ * @deprecated Use `onClick.on(listener, context)` instead.
2104
2023
  */ _proto.addClicked = function addClicked(listener) {
2105
- this._listeners.push({
2106
- fn: listener
2107
- });
2024
+ this.onClick.on(listener);
2108
2025
  };
2109
2026
  /**
2110
2027
  * Remove a listening function of click.
2111
- * @param listener - The listening function
2028
+ * @deprecated Use `onClick.off(listener, context)` instead.
2112
2029
  */ _proto.removeClicked = function removeClicked(listener) {
2113
- this._listeners.findAndRemove(function(value) {
2114
- return value.fn === listener ? value.destroyed = true : false;
2115
- });
2116
- };
2117
- _proto.onPointerClick = function onPointerClick(event) {
2118
- if (!this._getGlobalInteractive()) return;
2119
- var listeners = this._listeners.getLoopArray();
2120
- for(var i = 0, n = listeners.length; i < n; i++){
2121
- var listener = listeners[i];
2122
- !listener.destroyed && listener.fn(event);
2123
- }
2124
- };
2125
- _proto.onDestroy = function onDestroy() {
2126
- UIInteractive.prototype.onDestroy.call(this);
2127
- this._listeners.findAndRemove(function(value) {
2128
- return value.destroyed = true;
2129
- });
2030
+ this.onClick.off(listener);
2130
2031
  };
2131
2032
  return Button;
2132
2033
  }(UIInteractive);
2133
2034
  __decorate([
2134
- ignoreClone
2135
- ], Button.prototype, "_listeners", void 0);
2035
+ deepClone
2036
+ ], Button.prototype, "onClick", void 0);
2136
2037
 
2137
2038
  /**
2138
2039
  * UI element that renders an image.
@@ -2142,6 +2043,7 @@ __decorate([
2142
2043
  var _this;
2143
2044
  _this = UIRenderer1.call(this, entity) || this, _this._sprite = null, _this._tileMode = SpriteTileMode.Continuous, _this._tiledAdaptiveThreshold = 0.5;
2144
2045
  _this.drawMode = SpriteDrawMode.Simple;
2046
+ // @ts-ignore
2145
2047
  _this.setMaterial(_this._engine._getUIDefaultMaterial());
2146
2048
  _this._onSpriteChange = _this._onSpriteChange.bind(_this);
2147
2049
  return _this;
@@ -2161,9 +2063,9 @@ __decorate([
2161
2063
  };
2162
2064
  /**
2163
2065
  * @internal
2164
- */ _proto._cloneTo = function _cloneTo(target, srcRoot, targetRoot) {
2066
+ */ _proto._cloneTo = function _cloneTo(target) {
2165
2067
  // @ts-ignore
2166
- UIRenderer1.prototype._cloneTo.call(this, target, srcRoot, targetRoot);
2068
+ UIRenderer1.prototype._cloneTo.call(this, target);
2167
2069
  target.sprite = this._sprite;
2168
2070
  target.drawMode = this._drawMode;
2169
2071
  };
@@ -2193,6 +2095,7 @@ __decorate([
2193
2095
  }
2194
2096
  // @todo: This question needs to be raised rather than hidden.
2195
2097
  if (material.destroyed) {
2098
+ // @ts-ignore
2196
2099
  material = this._engine._getUIDefaultMaterial();
2197
2100
  }
2198
2101
  var alpha = this._getGlobalAlpha();
@@ -2400,7 +2303,7 @@ __decorate([
2400
2303
  _inherits(Text, UIRenderer1);
2401
2304
  function Text(entity) {
2402
2305
  var _this;
2403
- _this = UIRenderer1.call(this, entity) || this, _this._textChunks = Array(), _this._subFont = null, _this._text = "", _this._localBounds = new BoundingBox(), _this._font = null, _this._fontSize = 24, _this._fontStyle = FontStyle.None, _this._lineSpacing = 0, _this._horizontalAlignment = TextHorizontalAlignment.Center, _this._verticalAlignment = TextVerticalAlignment.Center, _this._enableWrapping = false, _this._overflowMode = OverflowMode.Overflow;
2306
+ _this = UIRenderer1.call(this, entity) || this, _this._textChunks = Array(), _this._subFont = null, _this._text = "", _this._localBounds = new BoundingBox(), _this._font = null, _this._fontSize = 24, _this._fontStyle = FontStyle.None, _this._lineSpacing = 0, _this._characterSpacing = 0, _this._horizontalAlignment = TextHorizontalAlignment.Center, _this._verticalAlignment = TextVerticalAlignment.Center, _this._enableWrapping = false, _this._overflowMode = OverflowMode.Overflow;
2404
2307
  var engine = _this.engine;
2405
2308
  // @ts-ignore
2406
2309
  _this.font = engine._textDefaultFont;
@@ -2423,9 +2326,9 @@ __decorate([
2423
2326
  this._subFont && (this._subFont = null);
2424
2327
  };
2425
2328
  // @ts-ignore
2426
- _proto._cloneTo = function _cloneTo(target, srcRoot, targetRoot) {
2329
+ _proto._cloneTo = function _cloneTo(target) {
2427
2330
  // @ts-ignore
2428
- UIRenderer1.prototype._cloneTo.call(this, target, srcRoot, targetRoot);
2331
+ UIRenderer1.prototype._cloneTo.call(this, target);
2429
2332
  target.font = this._font;
2430
2333
  target._subFont = this._subFont;
2431
2334
  };
@@ -2478,7 +2381,7 @@ __decorate([
2478
2381
  var canvas = this._getRootCanvas();
2479
2382
  if (this._isContainDirtyFlag(8)) {
2480
2383
  this._updateLocalData();
2481
- this._setDirtyFlagTrue(8);
2384
+ this._setDirtyFlagFalse(8);
2482
2385
  }
2483
2386
  if (this._isContainDirtyFlag(16)) {
2484
2387
  this._updatePosition();
@@ -2577,7 +2480,8 @@ __decorate([
2577
2480
  var rendererHeight = size.y;
2578
2481
  var offsetWidth = rendererWidth * (0.5 - pivot.x);
2579
2482
  var offsetHeight = rendererHeight * (0.5 - pivot.y);
2580
- var textMetrics = this.enableWrapping ? TextUtils.measureTextWithWrap(this, rendererWidth * pixelsPerResolution, rendererHeight * pixelsPerResolution, this._lineSpacing * pixelsPerResolution) : TextUtils.measureTextWithoutWrap(this, rendererHeight * pixelsPerResolution, this._lineSpacing * pixelsPerResolution);
2483
+ var characterSpacing = this._characterSpacing * this._fontSize;
2484
+ var textMetrics = this.enableWrapping ? TextUtils.measureTextWithWrap(this, rendererWidth * pixelsPerResolution, rendererHeight * pixelsPerResolution, this._lineSpacing * this._fontSize, characterSpacing) : TextUtils.measureTextWithoutWrap(this, rendererHeight * pixelsPerResolution, this._lineSpacing * this._fontSize, characterSpacing);
2581
2485
  var height = textMetrics.height, lines = textMetrics.lines, lineWidths = textMetrics.lineWidths, lineHeight = textMetrics.lineHeight, lineMaxSizes = textMetrics.lineMaxSizes;
2582
2486
  // @ts-ignore
2583
2487
  var charRenderInfoPool = this.engine._charRenderInfoPool;
@@ -2649,7 +2553,7 @@ __decorate([
2649
2553
  j === firstRow && (minX = Math.min(minX, left));
2650
2554
  maxX = Math.max(maxX, right);
2651
2555
  }
2652
- startX += charInfo.xAdvance + charInfo.offsetX;
2556
+ startX += charInfo.xAdvance + characterSpacing;
2653
2557
  }
2654
2558
  }
2655
2559
  startY -= lineHeight;
@@ -2709,7 +2613,7 @@ __decorate([
2709
2613
  };
2710
2614
  _proto._isTextNoVisible = function _isTextNoVisible() {
2711
2615
  var size = this._transformEntity.transform.size;
2712
- return this._text === "" || this._fontSize === 0 || this.enableWrapping && size.x <= 0 || this.overflowMode === OverflowMode.Truncate && size.y <= 0 || !this._getRootCanvas();
2616
+ return !this._font || this._text === "" || this._fontSize === 0 || this.enableWrapping && size.x <= 0 || this.overflowMode === OverflowMode.Truncate && size.y <= 0 || !this._getRootCanvas();
2713
2617
  };
2714
2618
  _proto._buildChunk = function _buildChunk(textChunk, count) {
2715
2619
  var _this_color = this.color, r = _this_color.r, g = _this_color.g, b = _this_color.b, a = _this_color.a;
@@ -2821,7 +2725,7 @@ __decorate([
2821
2725
  {
2822
2726
  key: "lineSpacing",
2823
2727
  get: /**
2824
- * The space between two lines (in pixels).
2728
+ * The space between two lines, in em (ratio of fontSize).
2825
2729
  */ function get() {
2826
2730
  return this._lineSpacing;
2827
2731
  },
@@ -2832,6 +2736,20 @@ __decorate([
2832
2736
  }
2833
2737
  }
2834
2738
  },
2739
+ {
2740
+ key: "characterSpacing",
2741
+ get: /**
2742
+ * The space between two characters, in em (ratio of fontSize).
2743
+ */ function get() {
2744
+ return this._characterSpacing;
2745
+ },
2746
+ set: function set(value) {
2747
+ if (this._characterSpacing !== value) {
2748
+ this._characterSpacing = value;
2749
+ this._setDirtyFlagTrue(25);
2750
+ }
2751
+ }
2752
+ },
2835
2753
  {
2836
2754
  key: "horizontalAlignment",
2837
2755
  get: /**
@@ -2957,6 +2875,9 @@ __decorate([
2957
2875
  __decorate([
2958
2876
  assignmentClone
2959
2877
  ], Text.prototype, "_lineSpacing", void 0);
2878
+ __decorate([
2879
+ assignmentClone
2880
+ ], Text.prototype, "_characterSpacing", void 0);
2960
2881
  __decorate([
2961
2882
  assignmentClone
2962
2883
  ], Text.prototype, "_horizontalAlignment", void 0);
@@ -3374,7 +3295,7 @@ var UIPointerEventEmitter = /*#__PURE__*/ function(PointerEventEmitter1) {
3374
3295
  // Post-rendering first detection
3375
3296
  for(var k2 = 0, n2 = canvasElements.length; k2 < n2; k2++){
3376
3297
  var canvas = canvasElements.get(k2);
3377
- if (!canvas._canRender(camera)) continue;
3298
+ if (!canvas._canDispatchEvent(camera)) continue;
3378
3299
  if (canvas._raycast(ray, hitResult, farClipPlane)) {
3379
3300
  this._updateRaycast(hitResult.component, pointer);
3380
3301
  return;
@@ -3601,20 +3522,6 @@ ApplyMixins(Engine, [
3601
3522
  ApplyMixins(Entity, [
3602
3523
  EntityExtension
3603
3524
  ]);
3604
- ReflectionParser.registerCustomParseComponent("Text", /*#__PURE__*/ _async_to_generator(function(instance, item) {
3605
- var props;
3606
- return __generator(this, function(_state) {
3607
- props = item.props;
3608
- if (!props.font) {
3609
- // @ts-ignore
3610
- instance.font = Font.createFromOS(instance.engine, props.fontFamily || "Arial");
3611
- }
3612
- return [
3613
- 2,
3614
- instance
3615
- ];
3616
- });
3617
- }));
3618
3525
  /**
3619
3526
  * Register GUI components for the editor.
3620
3527
  */ function registerGUI() {