@galacean/engine-ui 0.0.0-experimental-2.0-migrate.6 → 0.0.0-experimental-2.0-skill.0
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 +3618 -0
- package/dist/browser.js.map +1 -0
- package/dist/browser.min.js +2 -0
- package/dist/browser.min.js.map +1 -0
- package/dist/main.js +1795 -2386
- package/dist/main.js.map +1 -1
- package/dist/module.js +1797 -2387
- package/dist/module.js.map +1 -1
- package/package.json +3 -3
- package/types/Utils.d.ts +0 -10
- package/types/component/UICanvas.d.ts +0 -1
- package/types/component/UIRenderer.d.ts +1 -15
- package/types/component/advanced/Image.d.ts +1 -26
- package/types/component/advanced/Text.d.ts +4 -19
- package/types/component/index.d.ts +4 -6
- package/types/component/advanced/Mask.d.ts +0 -22
- package/types/component/advanced/RectMask2D.d.ts +0 -30
package/dist/main.js
CHANGED
|
@@ -4,6 +4,24 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var engine = require('@galacean/engine');
|
|
6
6
|
|
|
7
|
+
function _defineProperties(target, props) {
|
|
8
|
+
for (var i = 0; i < props.length; i++) {
|
|
9
|
+
var descriptor = props[i];
|
|
10
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
11
|
+
descriptor.configurable = true;
|
|
12
|
+
|
|
13
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
14
|
+
|
|
15
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
19
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
20
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
21
|
+
|
|
22
|
+
return Constructor;
|
|
23
|
+
}
|
|
24
|
+
|
|
7
25
|
function _set_prototype_of(o, p) {
|
|
8
26
|
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
9
27
|
o.__proto__ = p;
|
|
@@ -24,22 +42,10 @@ function _inherits(subClass, superClass) {
|
|
|
24
42
|
if (superClass) _set_prototype_of(subClass, superClass);
|
|
25
43
|
}
|
|
26
44
|
|
|
27
|
-
function
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
descriptor.configurable = true;
|
|
32
|
-
|
|
33
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
34
|
-
|
|
35
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
function _create_class(Constructor, protoProps, staticProps) {
|
|
39
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
40
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
41
|
-
|
|
42
|
-
return Constructor;
|
|
45
|
+
function _instanceof(left, right) {
|
|
46
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
47
|
+
return !!right[Symbol.hasInstance](left);
|
|
48
|
+
} else return left instanceof right;
|
|
43
49
|
}
|
|
44
50
|
|
|
45
51
|
/******************************************************************************
|
|
@@ -69,2424 +75,2046 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
69
75
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
70
76
|
};
|
|
71
77
|
|
|
72
|
-
function
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
* Think of it as stacking elements onto numbered shelves (depths):
|
|
83
|
-
* - Non-overlapping elements share shelf 0 — free to cluster regardless of material.
|
|
84
|
-
* - Overlapping + batch-compatible — share the same shelf, still cluster.
|
|
85
|
-
* - Overlapping + batch-incompatible — bumped one shelf higher (drawn on top).
|
|
86
|
-
*
|
|
87
|
-
* `depth` is a global tag, not a spatial group: distant elements at the same visual layer
|
|
88
|
-
* share the same depth and get clustered together. Once depth is assigned, sort by
|
|
89
|
-
* (depth, material, texture, hierarchyIndex) — visual order is locked, batching is the
|
|
90
|
-
* by-product of materials clustering within each depth band.
|
|
91
|
-
*
|
|
92
|
-
* Overlap detection is accelerated by a 10×10 spatial grid. Grid origin and cell size
|
|
93
|
-
* are derived from the union AABB of input elements (the bounds transform itself is the
|
|
94
|
-
* work the loop must do anyway, so the union accumulation just piggybacks). This stays
|
|
95
|
-
* correct across SS/WS canvases, any pivot, and any element distribution — no dependency
|
|
96
|
-
* on canvas configuration.
|
|
97
|
-
*/ var UIBatchSorter = /*#__PURE__*/ function() {
|
|
98
|
-
function UIBatchSorter() {}
|
|
78
|
+
var UIGroup = /*#__PURE__*/ function(Component) {
|
|
79
|
+
_inherits(UIGroup, Component);
|
|
80
|
+
function UIGroup(entity) {
|
|
81
|
+
var _this;
|
|
82
|
+
_this = Component.call(this, entity) || this, /** @internal */ _this._indexInGroup = -1, /** @internal */ _this._indexInRootCanvas = -1, /** @internal */ _this._disorderedElements = new engine.DisorderedArray(), /** @internal */ _this._globalAlpha = 1, /** @internal */ _this._globalInteractive = true, _this._alpha = 1, _this._interactive = true, _this._ignoreParentGroup = false, /** @internal */ _this._rootCanvasListeningEntities = [], /** @internal */ _this._groupListeningEntities = [], /** @internal */ _this._isRootCanvasDirty = false, /** @internal */ _this._isGroupDirty = false, /** @internal */ _this._groupDirtyFlags = 0;
|
|
83
|
+
_this._rootCanvasListener = _this._rootCanvasListener.bind(_this);
|
|
84
|
+
_this._groupListener = _this._groupListener.bind(_this);
|
|
85
|
+
return _this;
|
|
86
|
+
}
|
|
87
|
+
var _proto = UIGroup.prototype;
|
|
99
88
|
/**
|
|
100
|
-
*
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
var grid = this._grid;
|
|
109
|
-
var dirtyCells = this._dirtyCells;
|
|
110
|
-
var localBoundsPool = this._localBoundsPool;
|
|
111
|
-
var worldToLocal = this._worldToLocal;
|
|
112
|
-
engine.Matrix.invert(canvasWorldMatrix, worldToLocal);
|
|
113
|
-
while(entries.length < count)entries.push(new SortEntry());
|
|
114
|
-
// Allocate grid once, reuse forever (each cell must be a real [], not a sparse hole)
|
|
115
|
-
if (grid.length < gridDim) {
|
|
116
|
-
while(grid.length < gridDim)grid.push([]);
|
|
117
|
-
for(var i = 0; i < gridDim; i++){
|
|
118
|
-
var row = grid[i];
|
|
119
|
-
while(row.length < gridDim)row.push([]);
|
|
89
|
+
* @internal
|
|
90
|
+
*/ _proto._getGlobalAlpha = function _getGlobalAlpha() {
|
|
91
|
+
if (this._isContainDirtyFlag(1)) {
|
|
92
|
+
if (this._ignoreParentGroup) {
|
|
93
|
+
this._globalAlpha = this._alpha;
|
|
94
|
+
} else {
|
|
95
|
+
var parentGroup = this._getGroup();
|
|
96
|
+
this._globalAlpha = this._alpha * (parentGroup ? parentGroup._getGlobalAlpha() : 1);
|
|
120
97
|
}
|
|
98
|
+
this._setDirtyFlagFalse(1);
|
|
121
99
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
var unionMaxY = -Infinity;
|
|
134
|
-
for(var i1 = 0; i1 < count; i1++){
|
|
135
|
-
var _localBoundsPool, _i;
|
|
136
|
-
var localBounds = (_localBoundsPool = localBoundsPool)[_i = i1] || (_localBoundsPool[_i] = new engine.BoundingBox());
|
|
137
|
-
engine.BoundingBox.transform(elements[i1].component.bounds, worldToLocal, localBounds);
|
|
138
|
-
var min = localBounds.min, max = localBounds.max;
|
|
139
|
-
if (min.x < unionMinX) unionMinX = min.x;
|
|
140
|
-
if (min.y < unionMinY) unionMinY = min.y;
|
|
141
|
-
if (max.x > unionMaxX) unionMaxX = max.x;
|
|
142
|
-
if (max.y > unionMaxY) unionMaxY = max.y;
|
|
143
|
-
}
|
|
144
|
-
// Guard against a degenerate union (all elements collapsed onto a single point /
|
|
145
|
-
// axis); the grid then collapses to cell 0 which is semantically correct
|
|
146
|
-
var cellSizeX = Math.max(1e-6, unionMaxX - unionMinX) / gridDim;
|
|
147
|
-
var cellSizeY = Math.max(1e-6, unionMaxY - unionMinY) / gridDim;
|
|
148
|
-
var maxCell = gridDim - 1;
|
|
149
|
-
// Pass 2: register each element into grid cells and compute its depth
|
|
150
|
-
for(var i2 = 0; i2 < count; i2++){
|
|
151
|
-
var element = elements[i2];
|
|
152
|
-
var localBounds1 = localBoundsPool[i2];
|
|
153
|
-
var materialId = element.material.instanceId;
|
|
154
|
-
var textureId = element.texture ? element.texture.instanceId : 0;
|
|
155
|
-
// Floor + clamp guards floating-point edge cases (a `max` exactly on the union
|
|
156
|
-
// boundary would otherwise produce `gridDim`)
|
|
157
|
-
var minCellX = Math.min(maxCell, Math.max(0, Math.floor((localBounds1.min.x - unionMinX) / cellSizeX)));
|
|
158
|
-
var maxCellX = Math.min(maxCell, Math.max(0, Math.floor((localBounds1.max.x - unionMinX) / cellSizeX)));
|
|
159
|
-
var minCellY = Math.min(maxCell, Math.max(0, Math.floor((localBounds1.min.y - unionMinY) / cellSizeY)));
|
|
160
|
-
var maxCellY = Math.min(maxCell, Math.max(0, Math.floor((localBounds1.max.y - unionMinY) / cellSizeY)));
|
|
161
|
-
// Find the deepest overlapping prior, and whether that shelf has any incompatible occupant
|
|
162
|
-
var maxDepth = -1;
|
|
163
|
-
var maxDepthIncompatible = false;
|
|
164
|
-
for(var cellY = minCellY; cellY <= maxCellY; cellY++){
|
|
165
|
-
for(var cellX = minCellX; cellX <= maxCellX; cellX++){
|
|
166
|
-
var cell = grid[cellX][cellY];
|
|
167
|
-
for(var j = 0, m = cell.length; j < m; j++){
|
|
168
|
-
var other = cell[j];
|
|
169
|
-
if (!UIBatchSorter._rectOverlap(localBounds1, other.bounds)) continue;
|
|
170
|
-
var otherDepth = other.depth;
|
|
171
|
-
var otherIncompatible = other.materialId !== materialId || other.textureId !== textureId;
|
|
172
|
-
if (otherDepth > maxDepth) {
|
|
173
|
-
maxDepth = otherDepth;
|
|
174
|
-
maxDepthIncompatible = otherIncompatible;
|
|
175
|
-
} else if (otherDepth === maxDepth && otherIncompatible) {
|
|
176
|
-
maxDepthIncompatible = true;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
var entry = entries[i2];
|
|
182
|
-
entry.element = element;
|
|
183
|
-
entry.hierarchyIndex = i2;
|
|
184
|
-
// Share the deepest shelf if compatible; bump up one if blocked by an incompatible occupant
|
|
185
|
-
entry.depth = maxDepth < 0 ? 0 : maxDepth + (maxDepthIncompatible ? 1 : 0);
|
|
186
|
-
entry.materialId = materialId;
|
|
187
|
-
entry.textureId = textureId;
|
|
188
|
-
entry.bounds = localBounds1;
|
|
189
|
-
for(var cellY1 = minCellY; cellY1 <= maxCellY; cellY1++){
|
|
190
|
-
for(var cellX1 = minCellX; cellX1 <= maxCellX; cellX1++){
|
|
191
|
-
var cell1 = grid[cellX1][cellY1];
|
|
192
|
-
if (cell1.length === 0) dirtyCells.push(cellX1, cellY1);
|
|
193
|
-
cell1.push(entry);
|
|
194
|
-
}
|
|
100
|
+
return this._globalAlpha;
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* @internal
|
|
104
|
+
*/ _proto._getGlobalInteractive = function _getGlobalInteractive() {
|
|
105
|
+
if (this._isContainDirtyFlag(2)) {
|
|
106
|
+
if (this._ignoreParentGroup) {
|
|
107
|
+
this._globalInteractive = this._interactive;
|
|
108
|
+
} else {
|
|
109
|
+
var parentGroup = this._getGroup();
|
|
110
|
+
this._globalInteractive = this._interactive && (!parentGroup || parentGroup._getGlobalInteractive());
|
|
195
111
|
}
|
|
112
|
+
this._setDirtyFlagFalse(2);
|
|
196
113
|
}
|
|
197
|
-
|
|
198
|
-
engine.Utils._quickSort(entries, 0, count, UIBatchSorter._compareEntries);
|
|
199
|
-
for(var i3 = 0; i3 < count; i3++)elements[i3] = entries[i3].element;
|
|
114
|
+
return this._globalInteractive;
|
|
200
115
|
};
|
|
201
|
-
|
|
202
|
-
|
|
116
|
+
// @ts-ignore
|
|
117
|
+
_proto._onEnableInScene = function _onEnableInScene() {
|
|
118
|
+
Utils.setRootCanvasDirty(this);
|
|
119
|
+
Utils.setGroupDirty(this);
|
|
120
|
+
// @ts-ignore
|
|
121
|
+
this.entity._dispatchModify(EntityUIModifyFlags.GroupEnableInScene);
|
|
203
122
|
};
|
|
204
|
-
|
|
205
|
-
|
|
123
|
+
// @ts-ignore
|
|
124
|
+
_proto._onDisableInScene = function _onDisableInScene() {
|
|
125
|
+
Utils.cleanRootCanvas(this);
|
|
126
|
+
Utils.cleanGroup(this);
|
|
127
|
+
var disorderedElements = this._disorderedElements;
|
|
128
|
+
disorderedElements.forEach(function(element) {
|
|
129
|
+
Utils.setGroupDirty(element);
|
|
130
|
+
});
|
|
131
|
+
disorderedElements.length = 0;
|
|
132
|
+
disorderedElements.garbageCollection();
|
|
133
|
+
this._isRootCanvasDirty = this._isGroupDirty = false;
|
|
206
134
|
};
|
|
207
|
-
return UIBatchSorter;
|
|
208
|
-
}();
|
|
209
|
-
// Spatial-hash is fastest when cell size ≈ typical element size (one element per cell).
|
|
210
|
-
// UI elements typically span ~10% of the canvas → 10×10 grid.
|
|
211
|
-
UIBatchSorter._gridDim = 10;
|
|
212
|
-
UIBatchSorter._entries = new Array();
|
|
213
|
-
UIBatchSorter._grid = [];
|
|
214
|
-
// Interleaved (x, y) cell coords touched in the previous frame
|
|
215
|
-
UIBatchSorter._dirtyCells = new Array();
|
|
216
|
-
UIBatchSorter._localBoundsPool = new Array();
|
|
217
|
-
UIBatchSorter._worldToLocal = new engine.Matrix();
|
|
218
|
-
// materialId/textureId/bounds are flattened from RenderElement to avoid
|
|
219
|
-
// multi-hop property access in the hot inner loop and the sort comparator.
|
|
220
|
-
var SortEntry = function SortEntry() {
|
|
221
|
-
this.hierarchyIndex = 0;
|
|
222
|
-
this.depth = 0;
|
|
223
|
-
this.materialId = 0;
|
|
224
|
-
this.textureId = 0;
|
|
225
|
-
};
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* Render mode for ui canvas.
|
|
229
|
-
*/ var CanvasRenderMode = /*#__PURE__*/ function(CanvasRenderMode) {
|
|
230
135
|
/**
|
|
231
|
-
*
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
136
|
+
* @internal
|
|
137
|
+
*/ _proto._getRootCanvas = function _getRootCanvas() {
|
|
138
|
+
this._isRootCanvasDirty && Utils.setRootCanvas(this, Utils.searchRootCanvasInParents(this));
|
|
139
|
+
return this._rootCanvas;
|
|
140
|
+
};
|
|
235
141
|
/**
|
|
236
|
-
*
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
* The UI canvas is placed in the 3D world space and rendered by every camera in the same scene.
|
|
243
|
-
*/ CanvasRenderMode[CanvasRenderMode["WorldSpace"] = 2] = "WorldSpace";
|
|
244
|
-
return CanvasRenderMode;
|
|
245
|
-
}({});
|
|
246
|
-
|
|
247
|
-
/**
|
|
248
|
-
* Resolution adaptation mode.
|
|
249
|
-
* @remarks Only effective in screen space.
|
|
250
|
-
*/ var ResolutionAdaptationMode = /*#__PURE__*/ function(ResolutionAdaptationMode) {
|
|
251
|
-
/** Adapt based on width.(`referenceResolution.x`) */ ResolutionAdaptationMode[ResolutionAdaptationMode["WidthAdaptation"] = 0] = "WidthAdaptation";
|
|
252
|
-
/** Adapt based on height.(`referenceResolution.y`) */ ResolutionAdaptationMode[ResolutionAdaptationMode["HeightAdaptation"] = 1] = "HeightAdaptation";
|
|
253
|
-
/** Adapt based on both width and height.(`referenceResolution`) */ ResolutionAdaptationMode[ResolutionAdaptationMode["BothAdaptation"] = 2] = "BothAdaptation";
|
|
254
|
-
/** Adapt to the side with a larger ratio. */ ResolutionAdaptationMode[ResolutionAdaptationMode["ExpandAdaptation"] = 3] = "ExpandAdaptation";
|
|
255
|
-
/** Adapt to the side with smaller ratio. */ ResolutionAdaptationMode[ResolutionAdaptationMode["ShrinkAdaptation"] = 4] = "ShrinkAdaptation";
|
|
256
|
-
return ResolutionAdaptationMode;
|
|
257
|
-
}({});
|
|
258
|
-
|
|
259
|
-
/** Horizontal alignment mode. */ var HorizontalAlignmentMode = /*#__PURE__*/ function(HorizontalAlignmentMode) {
|
|
260
|
-
/** No horizontal alignment. */ HorizontalAlignmentMode[HorizontalAlignmentMode["None"] = 0] = "None";
|
|
261
|
-
/** Left-aligned, `alignLeft` drives `position.x`. */ HorizontalAlignmentMode[HorizontalAlignmentMode["Left"] = 1] = "Left";
|
|
262
|
-
/** Right-aligned, `alignRight` drives `position.x`. */ HorizontalAlignmentMode[HorizontalAlignmentMode["Right"] = 2] = "Right";
|
|
263
|
-
/** Horizontal stretch, `alignLeft` and `alignRight` drive `position.x` and `size.x`. */ HorizontalAlignmentMode[HorizontalAlignmentMode["LeftAndRight"] = 3] = "LeftAndRight";
|
|
264
|
-
/** Center-aligned, `alignCenter` drives `position.x`. */ HorizontalAlignmentMode[HorizontalAlignmentMode["Center"] = 4] = "Center";
|
|
265
|
-
return HorizontalAlignmentMode;
|
|
266
|
-
}({});
|
|
267
|
-
|
|
268
|
-
/** Vertical alignment mode. */ var VerticalAlignmentMode = /*#__PURE__*/ function(VerticalAlignmentMode) {
|
|
269
|
-
/** No vertical alignment. */ VerticalAlignmentMode[VerticalAlignmentMode["None"] = 0] = "None";
|
|
270
|
-
/** Top-aligned, `alignTop` drives `position.y`. */ VerticalAlignmentMode[VerticalAlignmentMode["Top"] = 1] = "Top";
|
|
271
|
-
/** Bottom-aligned, `alignBottom` drives `position.y`. */ VerticalAlignmentMode[VerticalAlignmentMode["Bottom"] = 2] = "Bottom";
|
|
272
|
-
/** Vertical stretch, `alignTop` and `alignBottom` drive `position.y` and `size.y`. */ VerticalAlignmentMode[VerticalAlignmentMode["TopAndBottom"] = 3] = "TopAndBottom";
|
|
273
|
-
/** Middle-aligned, `alignMiddle` drives `position.y`. */ VerticalAlignmentMode[VerticalAlignmentMode["Middle"] = 4] = "Middle";
|
|
274
|
-
return VerticalAlignmentMode;
|
|
275
|
-
}({});
|
|
276
|
-
|
|
277
|
-
/**
|
|
278
|
-
* The Transform component exclusive to the UI element.
|
|
279
|
-
*/ var UITransform = /*#__PURE__*/ function(Transform) {
|
|
280
|
-
_inherits(UITransform, Transform);
|
|
281
|
-
function UITransform(entity) {
|
|
282
|
-
var _this;
|
|
283
|
-
_this = Transform.call(this, entity) || this, _this._size = new engine.Vector2(100, 100), _this._pivot = new engine.Vector2(0.5, 0.5), _this._rect = new engine.Rect(-50, -50, 100, 100), _this._alignLeft = 0, _this._alignRight = 0, _this._alignCenter = 0, _this._alignTop = 0, _this._alignBottom = 0, _this._alignMiddle = 0, _this._horizontalAlignment = HorizontalAlignmentMode.None, _this._verticalAlignment = VerticalAlignmentMode.None;
|
|
284
|
-
_this._onSizeChanged = _this._onSizeChanged.bind(_this);
|
|
285
|
-
_this._onPivotChanged = _this._onPivotChanged.bind(_this);
|
|
286
|
-
// @ts-ignore
|
|
287
|
-
_this._size._onValueChanged = _this._onSizeChanged;
|
|
288
|
-
// @ts-ignore
|
|
289
|
-
_this._pivot._onValueChanged = _this._onPivotChanged;
|
|
290
|
-
return _this;
|
|
291
|
-
}
|
|
292
|
-
var _proto = UITransform.prototype;
|
|
142
|
+
* @internal
|
|
143
|
+
*/ _proto._getGroup = function _getGroup() {
|
|
144
|
+
this._isGroupDirty && Utils.setGroup(this, Utils.searchGroupInParents(this));
|
|
145
|
+
return this._group;
|
|
146
|
+
};
|
|
293
147
|
/**
|
|
294
148
|
* @internal
|
|
295
|
-
*/ _proto.
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
};
|
|
299
|
-
/**
|
|
300
|
-
* @inheritdoc
|
|
301
|
-
*/ _proto._onClone = function _onClone(target) {
|
|
302
|
-
Transform.prototype._onClone.call(this, target);
|
|
303
|
-
var size = target._size, pivot = target._pivot;
|
|
304
|
-
// @ts-ignore
|
|
305
|
-
size._onValueChanged = pivot._onValueChanged = null;
|
|
306
|
-
size.copyFrom(this._size);
|
|
307
|
-
pivot.copyFrom(this._pivot);
|
|
308
|
-
// @ts-ignore
|
|
309
|
-
size._onValueChanged = target._onSizeChanged;
|
|
310
|
-
// @ts-ignore
|
|
311
|
-
pivot._onValueChanged = target._onPivotChanged;
|
|
312
|
-
};
|
|
313
|
-
_proto._onLocalMatrixChanging = function _onLocalMatrixChanging() {
|
|
314
|
-
// `super._onLocalMatrixChanging()` will set `LocalMatrix` dirty flag `false`
|
|
315
|
-
// If there is an alignment, `position` and `localMatrix` will be reset again
|
|
316
|
-
if (this._horizontalAlignment || this._verticalAlignment) {
|
|
317
|
-
this._updatePositionByAlignment();
|
|
318
|
-
this._setDirtyFlagTrue(engine.TransformModifyFlags.LocalMatrix);
|
|
319
|
-
} else {
|
|
320
|
-
Transform.prototype._onLocalMatrixChanging.call(this);
|
|
321
|
-
}
|
|
322
|
-
};
|
|
323
|
-
_proto._onWorldMatrixChanging = function _onWorldMatrixChanging() {
|
|
324
|
-
// `super._onWorldMatrixChanging()` will set `WorldMatrix` dirty flag `false`
|
|
325
|
-
// If there is an alignment, `position` and `worldMatrix` will be reset again(`worldMatrix` dirty flag is already `true`)
|
|
326
|
-
!this._horizontalAlignment && !this._verticalAlignment && Transform.prototype._onWorldMatrixChanging.call(this);
|
|
327
|
-
};
|
|
328
|
-
_proto._onPositionChanged = function _onPositionChanged() {
|
|
329
|
-
(this._horizontalAlignment || this._verticalAlignment) && this._updatePositionByAlignment();
|
|
330
|
-
Transform.prototype._onPositionChanged.call(this);
|
|
331
|
-
};
|
|
332
|
-
_proto._onWorldPositionChanged = function _onWorldPositionChanged() {
|
|
333
|
-
Transform.prototype._onWorldPositionChanged.call(this);
|
|
334
|
-
if (this._horizontalAlignment || this._verticalAlignment) {
|
|
335
|
-
this._setDirtyFlagTrue(engine.TransformModifyFlags.WorldPosition);
|
|
336
|
-
}
|
|
337
|
-
};
|
|
338
|
-
_proto._updatePositionByAlignment = function _updatePositionByAlignment() {
|
|
339
|
-
var _this__getParentTransform;
|
|
340
|
-
var parentRect = (_this__getParentTransform = this._getParentTransform()) == null ? void 0 : _this__getParentTransform._rect;
|
|
341
|
-
if (parentRect) {
|
|
342
|
-
var position = this.position;
|
|
343
|
-
// @ts-ignore
|
|
344
|
-
position._onValueChanged = null;
|
|
345
|
-
var rect = this._rect;
|
|
346
|
-
switch(this._horizontalAlignment){
|
|
347
|
-
case HorizontalAlignmentMode.Left:
|
|
348
|
-
case HorizontalAlignmentMode.LeftAndRight:
|
|
349
|
-
position.x = parentRect.x - rect.x + this._alignLeft;
|
|
350
|
-
break;
|
|
351
|
-
case HorizontalAlignmentMode.Center:
|
|
352
|
-
position.x = parentRect.x + parentRect.width * 0.5 - rect.x - rect.width * 0.5 + this._alignCenter;
|
|
353
|
-
break;
|
|
354
|
-
case HorizontalAlignmentMode.Right:
|
|
355
|
-
position.x = parentRect.x + parentRect.width - rect.x - rect.width - this._alignRight;
|
|
356
|
-
break;
|
|
357
|
-
}
|
|
358
|
-
switch(this._verticalAlignment){
|
|
359
|
-
case VerticalAlignmentMode.Top:
|
|
360
|
-
position.y = parentRect.y + parentRect.height - rect.y - rect.height - this._alignTop;
|
|
361
|
-
break;
|
|
362
|
-
case VerticalAlignmentMode.Middle:
|
|
363
|
-
position.y = parentRect.y + parentRect.height * 0.5 - rect.y - rect.height * 0.5 + this._alignMiddle;
|
|
364
|
-
break;
|
|
365
|
-
case VerticalAlignmentMode.Bottom:
|
|
366
|
-
case VerticalAlignmentMode.TopAndBottom:
|
|
367
|
-
position.y = parentRect.y - rect.y + this._alignBottom;
|
|
368
|
-
break;
|
|
369
|
-
}
|
|
370
|
-
// @ts-ignore
|
|
371
|
-
position._onValueChanged = this._onPositionChanged;
|
|
149
|
+
*/ _proto._groupListener = function _groupListener(flag) {
|
|
150
|
+
if (flag === engine.EntityModifyFlags.Parent || flag === EntityUIModifyFlags.GroupEnableInScene) {
|
|
151
|
+
Utils.setGroupDirty(this);
|
|
372
152
|
}
|
|
373
153
|
};
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
if (
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
size._onValueChanged = null;
|
|
381
|
-
// The values of size must be greater than 0
|
|
382
|
-
if (this._horizontalAlignment === HorizontalAlignmentMode.LeftAndRight) {
|
|
383
|
-
size.x = Math.max(parentRect.width - this._alignLeft - this._alignRight, 0);
|
|
384
|
-
}
|
|
385
|
-
if (this._verticalAlignment === VerticalAlignmentMode.TopAndBottom) {
|
|
386
|
-
size.y = Math.max(parentRect.height - this._alignTop - this._alignBottom, 0);
|
|
387
|
-
}
|
|
388
|
-
// @ts-ignore
|
|
389
|
-
size._onValueChanged = this._onSizeChanged;
|
|
154
|
+
/**
|
|
155
|
+
* @internal
|
|
156
|
+
*/ _proto._rootCanvasListener = function _rootCanvasListener(flag) {
|
|
157
|
+
if (flag === engine.EntityModifyFlags.Parent || flag === EntityUIModifyFlags.CanvasEnableInScene) {
|
|
158
|
+
Utils.setRootCanvasDirty(this);
|
|
159
|
+
Utils.setGroupDirty(this);
|
|
390
160
|
}
|
|
391
161
|
};
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
162
|
+
/**
|
|
163
|
+
* @internal
|
|
164
|
+
*/ _proto._onGroupModify = function _onGroupModify(flags, isPass) {
|
|
165
|
+
if (isPass === void 0) isPass = false;
|
|
166
|
+
if (isPass && this._ignoreParentGroup) return;
|
|
167
|
+
if (this._isContainDirtyFlags(flags)) return;
|
|
168
|
+
this._setDirtyFlagTrue(flags);
|
|
169
|
+
this._disorderedElements.forEach(function(element) {
|
|
170
|
+
element._onGroupModify(flags, true);
|
|
171
|
+
});
|
|
397
172
|
};
|
|
398
|
-
_proto.
|
|
399
|
-
|
|
400
|
-
this._updateSizeByAlignment();
|
|
401
|
-
}
|
|
402
|
-
this._updateRectBySizeAndPivot();
|
|
403
|
-
this._updateWorldFlagWithSelfRectChange();
|
|
404
|
-
// @ts-ignore
|
|
405
|
-
this._entity._updateFlagManager.dispatch(512);
|
|
173
|
+
_proto._isContainDirtyFlags = function _isContainDirtyFlags(targetDirtyFlags) {
|
|
174
|
+
return (this._groupDirtyFlags & targetDirtyFlags) === targetDirtyFlags;
|
|
406
175
|
};
|
|
407
|
-
_proto.
|
|
408
|
-
this.
|
|
409
|
-
this._updateWorldFlagWithSelfRectChange();
|
|
410
|
-
// @ts-ignore
|
|
411
|
-
this._entity._updateFlagManager.dispatch(1024);
|
|
176
|
+
_proto._isContainDirtyFlag = function _isContainDirtyFlag(type) {
|
|
177
|
+
return (this._groupDirtyFlags & type) != 0;
|
|
412
178
|
};
|
|
413
|
-
_proto.
|
|
414
|
-
|
|
415
|
-
if (this._horizontalAlignment || this._verticalAlignment) {
|
|
416
|
-
this._updatePositionByAlignment();
|
|
417
|
-
this._setDirtyFlagTrue(engine.TransformModifyFlags.LocalMatrix);
|
|
418
|
-
worldFlags = engine.TransformModifyFlags.WmWp;
|
|
419
|
-
!this._isContainDirtyFlags(worldFlags) && this._worldAssociatedChange(worldFlags);
|
|
420
|
-
}
|
|
421
|
-
var children = this.entity.children;
|
|
422
|
-
for(var i = 0, n = children.length; i < n; i++){
|
|
423
|
-
var _children_i_transform__updateWorldFlagWithParentRectChange, _children_i_transform;
|
|
424
|
-
(_children_i_transform = children[i].transform) == null ? void 0 : (_children_i_transform__updateWorldFlagWithParentRectChange = _children_i_transform._updateWorldFlagWithParentRectChange) == null ? void 0 : _children_i_transform__updateWorldFlagWithParentRectChange.call(_children_i_transform, worldFlags);
|
|
425
|
-
}
|
|
179
|
+
_proto._setDirtyFlagTrue = function _setDirtyFlagTrue(type) {
|
|
180
|
+
this._groupDirtyFlags |= type;
|
|
426
181
|
};
|
|
427
|
-
_proto.
|
|
428
|
-
|
|
429
|
-
var selfChange = false;
|
|
430
|
-
if (parentChange) {
|
|
431
|
-
var _this = this, horizontalAlignment = _this._horizontalAlignment, verticalAlignment = _this._verticalAlignment;
|
|
432
|
-
if (horizontalAlignment || verticalAlignment) {
|
|
433
|
-
if (horizontalAlignment === HorizontalAlignmentMode.LeftAndRight || verticalAlignment === VerticalAlignmentMode.TopAndBottom) {
|
|
434
|
-
this._updateSizeByAlignment();
|
|
435
|
-
this._updateRectBySizeAndPivot();
|
|
436
|
-
selfChange = true;
|
|
437
|
-
}
|
|
438
|
-
this._updatePositionByAlignment();
|
|
439
|
-
this._setDirtyFlagTrue(engine.TransformModifyFlags.LocalMatrix);
|
|
440
|
-
flags |= engine.TransformModifyFlags.WmWp;
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
var containDirtyFlags = this._isContainDirtyFlags(flags);
|
|
444
|
-
!containDirtyFlags && this._worldAssociatedChange(flags);
|
|
445
|
-
if (selfChange || !containDirtyFlags) {
|
|
446
|
-
var children = this.entity.children;
|
|
447
|
-
for(var i = 0, n = children.length; i < n; i++){
|
|
448
|
-
var _children_i_transform__updateWorldFlagWithParentRectChange, _children_i_transform;
|
|
449
|
-
(_children_i_transform = children[i].transform) == null ? void 0 : (_children_i_transform__updateWorldFlagWithParentRectChange = _children_i_transform._updateWorldFlagWithParentRectChange) == null ? void 0 : _children_i_transform__updateWorldFlagWithParentRectChange.call(_children_i_transform, flags, selfChange);
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
// @ts-ignore
|
|
453
|
-
selfChange && this._entity._updateFlagManager.dispatch(512);
|
|
182
|
+
_proto._setDirtyFlagFalse = function _setDirtyFlagFalse(type) {
|
|
183
|
+
this._groupDirtyFlags &= ~type;
|
|
454
184
|
};
|
|
455
|
-
_create_class(
|
|
185
|
+
_create_class(UIGroup, [
|
|
456
186
|
{
|
|
457
|
-
key: "
|
|
187
|
+
key: "ignoreParentGroup",
|
|
458
188
|
get: /**
|
|
459
|
-
*
|
|
189
|
+
* Whether to ignore the parent group.
|
|
190
|
+
* @remarks If this parameter set to `true`,
|
|
191
|
+
* all settings of the parent group will be ignored.
|
|
460
192
|
*/ function get() {
|
|
461
|
-
return this.
|
|
193
|
+
return this._ignoreParentGroup;
|
|
462
194
|
},
|
|
463
195
|
set: function set(value) {
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
196
|
+
if (this._ignoreParentGroup !== value) {
|
|
197
|
+
this._ignoreParentGroup = value;
|
|
198
|
+
this._onGroupModify(3);
|
|
199
|
+
}
|
|
467
200
|
}
|
|
468
201
|
},
|
|
469
202
|
{
|
|
470
|
-
key: "
|
|
203
|
+
key: "interactive",
|
|
471
204
|
get: /**
|
|
472
|
-
*
|
|
205
|
+
* Whether the group is interactive.
|
|
473
206
|
*/ function get() {
|
|
474
|
-
return this.
|
|
207
|
+
return this._interactive;
|
|
475
208
|
},
|
|
476
209
|
set: function set(value) {
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
}
|
|
481
|
-
},
|
|
482
|
-
{
|
|
483
|
-
key: "horizontalAlignment",
|
|
484
|
-
get: /**
|
|
485
|
-
* Horizontal alignment mode.
|
|
486
|
-
*
|
|
487
|
-
* @remarks
|
|
488
|
-
* Controls how the element aligns horizontally within its parent:
|
|
489
|
-
* - `Left` - Align to parent's left edge
|
|
490
|
-
* - `Center` - Align to parent's horizontal center
|
|
491
|
-
* - `Right` - Align to parent's right edge
|
|
492
|
-
* - `LeftAndRight` - Align to both left and right edges (stretch to fill width)
|
|
493
|
-
*/ function get() {
|
|
494
|
-
return this._horizontalAlignment;
|
|
495
|
-
},
|
|
496
|
-
set: function set(value) {
|
|
497
|
-
if (this._horizontalAlignment === value) return;
|
|
498
|
-
this._horizontalAlignment = value;
|
|
499
|
-
switch(value){
|
|
500
|
-
case HorizontalAlignmentMode.Left:
|
|
501
|
-
case HorizontalAlignmentMode.Right:
|
|
502
|
-
case HorizontalAlignmentMode.Center:
|
|
503
|
-
this._onPositionChanged();
|
|
504
|
-
break;
|
|
505
|
-
case HorizontalAlignmentMode.LeftAndRight:
|
|
506
|
-
this._onPositionChanged();
|
|
507
|
-
this._onSizeChanged();
|
|
508
|
-
break;
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
},
|
|
512
|
-
{
|
|
513
|
-
key: "alignLeft",
|
|
514
|
-
get: /**
|
|
515
|
-
* Left margin when horizontalAlignment is Left or LeftAndRight.
|
|
516
|
-
*
|
|
517
|
-
* @remarks
|
|
518
|
-
* Only effective when horizontalAlignment includes Left mode.
|
|
519
|
-
* Distance from the parent's left edge to the element's left edge.
|
|
520
|
-
*/ function get() {
|
|
521
|
-
return this._alignLeft;
|
|
522
|
-
},
|
|
523
|
-
set: function set(value) {
|
|
524
|
-
if (!Number.isFinite(value)) return;
|
|
525
|
-
if (engine.MathUtil.equals(value, this._alignLeft)) return;
|
|
526
|
-
this._alignLeft = value;
|
|
527
|
-
if (this._horizontalAlignment & HorizontalAlignmentMode.Left) {
|
|
528
|
-
this._onPositionChanged();
|
|
529
|
-
this._horizontalAlignment & HorizontalAlignmentMode.Right && this._onSizeChanged();
|
|
530
|
-
}
|
|
531
|
-
}
|
|
532
|
-
},
|
|
533
|
-
{
|
|
534
|
-
key: "alignRight",
|
|
535
|
-
get: /**
|
|
536
|
-
* Right margin when horizontalAlignment is Right or LeftAndRight.
|
|
537
|
-
*
|
|
538
|
-
* @remarks
|
|
539
|
-
* Only effective when horizontalAlignment includes Right mode.
|
|
540
|
-
* Distance from the parent's right edge to the element's right edge.
|
|
541
|
-
*/ function get() {
|
|
542
|
-
return this._alignRight;
|
|
543
|
-
},
|
|
544
|
-
set: function set(value) {
|
|
545
|
-
if (!Number.isFinite(value)) return;
|
|
546
|
-
if (engine.MathUtil.equals(value, this._alignRight)) return;
|
|
547
|
-
this._alignRight = value;
|
|
548
|
-
if (this._horizontalAlignment & HorizontalAlignmentMode.Right) {
|
|
549
|
-
this._onPositionChanged();
|
|
550
|
-
this._horizontalAlignment & HorizontalAlignmentMode.Left && this._onSizeChanged();
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
},
|
|
554
|
-
{
|
|
555
|
-
key: "alignCenter",
|
|
556
|
-
get: /**
|
|
557
|
-
* Horizontal center offset when horizontalAlignment is Center.
|
|
558
|
-
*
|
|
559
|
-
* @remarks
|
|
560
|
-
* Only effective when horizontalAlignment is Center mode.
|
|
561
|
-
* Positive values move the element to the right, negative values to the left.
|
|
562
|
-
*/ function get() {
|
|
563
|
-
return this._alignCenter;
|
|
564
|
-
},
|
|
565
|
-
set: function set(value) {
|
|
566
|
-
if (!Number.isFinite(value)) return;
|
|
567
|
-
if (engine.MathUtil.equals(value, this._alignCenter)) return;
|
|
568
|
-
this._alignCenter = value;
|
|
569
|
-
this._horizontalAlignment & HorizontalAlignmentMode.Center && this._onPositionChanged();
|
|
570
|
-
}
|
|
571
|
-
},
|
|
572
|
-
{
|
|
573
|
-
key: "verticalAlignment",
|
|
574
|
-
get: /**
|
|
575
|
-
* Vertical alignment mode.
|
|
576
|
-
*
|
|
577
|
-
* @remarks
|
|
578
|
-
* Controls how the element aligns vertically within its parent:
|
|
579
|
-
* - `Top` - Align to parent's top edge
|
|
580
|
-
* - `Middle` - Align to parent's vertical center
|
|
581
|
-
* - `Bottom` - Align to parent's bottom edge
|
|
582
|
-
* - `TopAndBottom` - Align to both top and bottom edges (stretch to fill height)
|
|
583
|
-
*/ function get() {
|
|
584
|
-
return this._verticalAlignment;
|
|
585
|
-
},
|
|
586
|
-
set: function set(value) {
|
|
587
|
-
if (this._verticalAlignment === value) return;
|
|
588
|
-
this._verticalAlignment = value;
|
|
589
|
-
switch(value){
|
|
590
|
-
case VerticalAlignmentMode.Top:
|
|
591
|
-
case VerticalAlignmentMode.Bottom:
|
|
592
|
-
case VerticalAlignmentMode.Middle:
|
|
593
|
-
this._onPositionChanged();
|
|
594
|
-
break;
|
|
595
|
-
case VerticalAlignmentMode.TopAndBottom:
|
|
596
|
-
this._onPositionChanged();
|
|
597
|
-
this._onSizeChanged();
|
|
598
|
-
break;
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
},
|
|
602
|
-
{
|
|
603
|
-
key: "alignTop",
|
|
604
|
-
get: /**
|
|
605
|
-
* Top margin when verticalAlignment is Top or TopAndBottom.
|
|
606
|
-
*
|
|
607
|
-
* @remarks
|
|
608
|
-
* Only effective when verticalAlignment includes Top mode.
|
|
609
|
-
* Used to offset the element from the parent's top edge.
|
|
610
|
-
*/ function get() {
|
|
611
|
-
return this._alignTop;
|
|
612
|
-
},
|
|
613
|
-
set: function set(value) {
|
|
614
|
-
if (!Number.isFinite(value)) return;
|
|
615
|
-
if (engine.MathUtil.equals(value, this._alignTop)) return;
|
|
616
|
-
this._alignTop = value;
|
|
617
|
-
if (this._verticalAlignment & VerticalAlignmentMode.Top) {
|
|
618
|
-
this._onPositionChanged();
|
|
619
|
-
this._verticalAlignment & VerticalAlignmentMode.Bottom && this._onSizeChanged();
|
|
210
|
+
if (this._interactive !== value) {
|
|
211
|
+
this._interactive = value;
|
|
212
|
+
this._onGroupModify(2);
|
|
620
213
|
}
|
|
621
214
|
}
|
|
622
215
|
},
|
|
623
216
|
{
|
|
624
|
-
key: "
|
|
217
|
+
key: "alpha",
|
|
625
218
|
get: /**
|
|
626
|
-
*
|
|
219
|
+
* The alpha value of the group.
|
|
627
220
|
*/ function get() {
|
|
628
|
-
return this.
|
|
221
|
+
return this._alpha;
|
|
629
222
|
},
|
|
630
223
|
set: function set(value) {
|
|
631
|
-
|
|
632
|
-
if (
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
this._onPositionChanged();
|
|
636
|
-
this._verticalAlignment & VerticalAlignmentMode.Top && this._onSizeChanged();
|
|
224
|
+
value = Math.max(0, Math.min(value, 1));
|
|
225
|
+
if (this._alpha !== value) {
|
|
226
|
+
this._alpha = value;
|
|
227
|
+
this._onGroupModify(1);
|
|
637
228
|
}
|
|
638
229
|
}
|
|
639
|
-
},
|
|
640
|
-
{
|
|
641
|
-
key: "alignMiddle",
|
|
642
|
-
get: /**
|
|
643
|
-
* Vertical middle offset relative to parent's middle.
|
|
644
|
-
*/ function get() {
|
|
645
|
-
return this._alignMiddle;
|
|
646
|
-
},
|
|
647
|
-
set: function set(value) {
|
|
648
|
-
if (!Number.isFinite(value)) return;
|
|
649
|
-
if (engine.MathUtil.equals(value, this._alignMiddle)) return;
|
|
650
|
-
this._alignMiddle = value;
|
|
651
|
-
this._verticalAlignment & VerticalAlignmentMode.Middle && this._onPositionChanged();
|
|
652
|
-
}
|
|
653
230
|
}
|
|
654
231
|
]);
|
|
655
|
-
return
|
|
656
|
-
}(engine.
|
|
232
|
+
return UIGroup;
|
|
233
|
+
}(engine.Component);
|
|
657
234
|
__decorate([
|
|
658
235
|
engine.ignoreClone
|
|
659
|
-
],
|
|
236
|
+
], UIGroup.prototype, "_indexInGroup", void 0);
|
|
660
237
|
__decorate([
|
|
661
238
|
engine.ignoreClone
|
|
662
|
-
],
|
|
239
|
+
], UIGroup.prototype, "_indexInRootCanvas", void 0);
|
|
663
240
|
__decorate([
|
|
664
241
|
engine.ignoreClone
|
|
665
|
-
],
|
|
242
|
+
], UIGroup.prototype, "_globalAlpha", void 0);
|
|
666
243
|
__decorate([
|
|
667
244
|
engine.ignoreClone
|
|
668
|
-
],
|
|
245
|
+
], UIGroup.prototype, "_globalInteractive", void 0);
|
|
669
246
|
__decorate([
|
|
670
247
|
engine.ignoreClone
|
|
671
|
-
],
|
|
248
|
+
], UIGroup.prototype, "_rootCanvasListeningEntities", void 0);
|
|
672
249
|
__decorate([
|
|
673
250
|
engine.ignoreClone
|
|
674
|
-
],
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
251
|
+
], UIGroup.prototype, "_groupListeningEntities", void 0);
|
|
252
|
+
__decorate([
|
|
253
|
+
engine.ignoreClone
|
|
254
|
+
], UIGroup.prototype, "_isRootCanvasDirty", void 0);
|
|
255
|
+
__decorate([
|
|
256
|
+
engine.ignoreClone
|
|
257
|
+
], UIGroup.prototype, "_isGroupDirty", void 0);
|
|
258
|
+
__decorate([
|
|
259
|
+
engine.ignoreClone
|
|
260
|
+
], UIGroup.prototype, "_groupDirtyFlags", void 0);
|
|
261
|
+
__decorate([
|
|
262
|
+
engine.ignoreClone
|
|
263
|
+
], UIGroup.prototype, "_groupListener", null);
|
|
264
|
+
__decorate([
|
|
265
|
+
engine.ignoreClone
|
|
266
|
+
], UIGroup.prototype, "_rootCanvasListener", null);
|
|
267
|
+
var GroupModifyFlags = /*#__PURE__*/ function(GroupModifyFlags) {
|
|
268
|
+
GroupModifyFlags[GroupModifyFlags["None"] = 0] = "None";
|
|
269
|
+
GroupModifyFlags[GroupModifyFlags["GlobalAlpha"] = 1] = "GlobalAlpha";
|
|
270
|
+
GroupModifyFlags[GroupModifyFlags["GlobalInteractive"] = 2] = "GlobalInteractive";
|
|
271
|
+
GroupModifyFlags[GroupModifyFlags["All"] = 3] = "All";
|
|
272
|
+
return GroupModifyFlags;
|
|
682
273
|
}({});
|
|
683
274
|
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
function
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
_this._softness._onValueChanged = _this._onSoftnessChanged;
|
|
692
|
-
return _this;
|
|
693
|
-
}
|
|
694
|
-
var _proto = RectMask2D.prototype;
|
|
695
|
-
/**
|
|
696
|
-
* @internal
|
|
697
|
-
*/ _proto._getWorldRect = function _getWorldRect(out) {
|
|
698
|
-
var transform = this.entity.transform;
|
|
699
|
-
var _transform_size = transform.size, width = _transform_size.x, height = _transform_size.y;
|
|
700
|
-
if (!width || !height) {
|
|
701
|
-
return false;
|
|
702
|
-
}
|
|
703
|
-
var _transform_pivot = transform.pivot, pivotX = _transform_pivot.x, pivotY = _transform_pivot.y;
|
|
704
|
-
var left = -width * pivotX;
|
|
705
|
-
var right = width * (1 - pivotX);
|
|
706
|
-
var bottom = -height * pivotY;
|
|
707
|
-
var top = height * (1 - pivotY);
|
|
708
|
-
var worldMatrix = transform.worldMatrix;
|
|
709
|
-
var corner0 = RectMask2D._tempCorner0;
|
|
710
|
-
var corner1 = RectMask2D._tempCorner1;
|
|
711
|
-
var corner2 = RectMask2D._tempCorner2;
|
|
712
|
-
var corner3 = RectMask2D._tempCorner3;
|
|
713
|
-
engine.Vector3.transformCoordinate(corner0.set(left, bottom, 0), worldMatrix, corner0);
|
|
714
|
-
engine.Vector3.transformCoordinate(corner1.set(left, top, 0), worldMatrix, corner1);
|
|
715
|
-
engine.Vector3.transformCoordinate(corner2.set(right, bottom, 0), worldMatrix, corner2);
|
|
716
|
-
engine.Vector3.transformCoordinate(corner3.set(right, top, 0), worldMatrix, corner3);
|
|
717
|
-
var minX = Math.min(corner0.x, corner1.x, corner2.x, corner3.x);
|
|
718
|
-
var minY = Math.min(corner0.y, corner1.y, corner2.y, corner3.y);
|
|
719
|
-
var maxX = Math.max(corner0.x, corner1.x, corner2.x, corner3.x);
|
|
720
|
-
var maxY = Math.max(corner0.y, corner1.y, corner2.y, corner3.y);
|
|
721
|
-
out.set(minX, minY, maxX, maxY);
|
|
722
|
-
return true;
|
|
723
|
-
};
|
|
724
|
-
/**
|
|
725
|
-
* @internal
|
|
726
|
-
*/ _proto._containsWorldPoint = function _containsWorldPoint(worldPoint) {
|
|
727
|
-
var worldRect = RectMask2D._tempRect;
|
|
728
|
-
if (!this._getWorldRect(worldRect)) {
|
|
729
|
-
return false;
|
|
730
|
-
}
|
|
731
|
-
var x = worldPoint.x, y = worldPoint.y;
|
|
732
|
-
return x >= worldRect.x && x <= worldRect.z && y >= worldRect.y && y <= worldRect.w;
|
|
275
|
+
var Utils = /*#__PURE__*/ function() {
|
|
276
|
+
function Utils() {}
|
|
277
|
+
Utils.setRootCanvasDirty = function setRootCanvasDirty(element) {
|
|
278
|
+
if (element._isRootCanvasDirty) return;
|
|
279
|
+
element._isRootCanvasDirty = true;
|
|
280
|
+
this._registerRootCanvas(element, null);
|
|
281
|
+
element._onRootCanvasModify == null ? void 0 : element._onRootCanvasModify.call(element, RootCanvasModifyFlags.All);
|
|
733
282
|
};
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
this.
|
|
283
|
+
Utils.setRootCanvas = function setRootCanvas(element, rootCanvas) {
|
|
284
|
+
element._isRootCanvasDirty = false;
|
|
285
|
+
this._registerRootCanvas(element, rootCanvas);
|
|
286
|
+
var fromEntity = _instanceof(element, exports.UICanvas) ? element.entity.parent : element.entity;
|
|
287
|
+
var _rootCanvas_entity_parent;
|
|
288
|
+
var toEntity = (_rootCanvas_entity_parent = rootCanvas == null ? void 0 : rootCanvas.entity.parent) != null ? _rootCanvas_entity_parent : null;
|
|
289
|
+
this._registerListener(fromEntity, toEntity, element._rootCanvasListener, element._rootCanvasListeningEntities);
|
|
737
290
|
};
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
this.
|
|
291
|
+
Utils.cleanRootCanvas = function cleanRootCanvas(element) {
|
|
292
|
+
this._registerRootCanvas(element, null);
|
|
293
|
+
this._unRegisterListener(element._rootCanvasListener, element._rootCanvasListeningEntities);
|
|
741
294
|
};
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
Component.prototype._onDestroy.call(this);
|
|
295
|
+
Utils.searchRootCanvasInParents = function searchRootCanvasInParents(element) {
|
|
296
|
+
var entity = _instanceof(element, exports.UICanvas) ? element.entity.parent : element.entity;
|
|
297
|
+
while(entity){
|
|
298
|
+
// @ts-ignore
|
|
299
|
+
var components = entity._components;
|
|
300
|
+
for(var i = 0, n = components.length; i < n; i++){
|
|
301
|
+
var component = components[i];
|
|
302
|
+
if (component.enabled && _instanceof(component, exports.UICanvas) && component._isRootCanvas) {
|
|
303
|
+
return component;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
entity = entity.parent;
|
|
307
|
+
}
|
|
308
|
+
return null;
|
|
757
309
|
};
|
|
758
|
-
|
|
759
|
-
|
|
310
|
+
Utils.setGroupDirty = function setGroupDirty(element) {
|
|
311
|
+
if (element._isGroupDirty) return;
|
|
312
|
+
element._isGroupDirty = true;
|
|
313
|
+
this._registerGroup(element, null);
|
|
314
|
+
element._onGroupModify(GroupModifyFlags.All);
|
|
760
315
|
};
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
316
|
+
Utils.setGroup = function setGroup(element, group) {
|
|
317
|
+
element._isGroupDirty = false;
|
|
318
|
+
this._registerGroup(element, group);
|
|
319
|
+
var rootCanvas = element._getRootCanvas();
|
|
320
|
+
if (rootCanvas) {
|
|
321
|
+
var fromEntity = _instanceof(element, UIGroup) ? element.entity.parent : element.entity;
|
|
322
|
+
var _group_entity;
|
|
323
|
+
var toEntity = (_group_entity = group == null ? void 0 : group.entity) != null ? _group_entity : rootCanvas.entity.parent;
|
|
324
|
+
this._registerListener(fromEntity, toEntity, element._groupListener, element._groupListeningEntities);
|
|
325
|
+
} else {
|
|
326
|
+
this._unRegisterListener(element._groupListener, element._groupListeningEntities);
|
|
768
327
|
}
|
|
769
328
|
};
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
329
|
+
Utils.cleanGroup = function cleanGroup(element) {
|
|
330
|
+
this._registerGroup(element, null);
|
|
331
|
+
this._unRegisterListener(element._groupListener, element._groupListeningEntities);
|
|
332
|
+
};
|
|
333
|
+
Utils.searchGroupInParents = function searchGroupInParents(element) {
|
|
334
|
+
var rootCanvas = element._getRootCanvas();
|
|
335
|
+
if (!rootCanvas) return null;
|
|
336
|
+
var entity = _instanceof(element, UIGroup) ? element.entity.parent : element.entity;
|
|
337
|
+
var rootCanvasParent = rootCanvas.entity.parent;
|
|
338
|
+
while(entity && entity !== rootCanvasParent){
|
|
339
|
+
// @ts-ignore
|
|
340
|
+
var components = entity._components;
|
|
341
|
+
for(var i = 0, n = components.length; i < n; i++){
|
|
342
|
+
var component = components[i];
|
|
343
|
+
if (component.enabled && _instanceof(component, UIGroup)) {
|
|
344
|
+
return component;
|
|
786
345
|
}
|
|
787
346
|
}
|
|
788
|
-
|
|
789
|
-
{
|
|
790
|
-
key: "alphaClip",
|
|
791
|
-
get: /**
|
|
792
|
-
* Whether to enable hard clip (discard) when outside the rect.
|
|
793
|
-
*/ function get() {
|
|
794
|
-
return this._alphaClip;
|
|
795
|
-
},
|
|
796
|
-
set: function set(value) {
|
|
797
|
-
this._alphaClip = value;
|
|
798
|
-
}
|
|
347
|
+
entity = entity.parent;
|
|
799
348
|
}
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
engine.dependentComponents(UITransform, engine.DependentMode.AutoAdd)
|
|
810
|
-
], exports.RectMask2D);
|
|
811
|
-
|
|
812
|
-
var UIGroup = /*#__PURE__*/ function(Component) {
|
|
813
|
-
_inherits(UIGroup, Component);
|
|
814
|
-
function UIGroup(entity) {
|
|
815
|
-
var _this;
|
|
816
|
-
_this = Component.call(this, entity) || this, /** @internal */ _this._indexInGroup = -1, /** @internal */ _this._indexInRootCanvas = -1, /** @internal */ _this._disorderedElements = new engine.DisorderedArray(), /** @internal */ _this._globalAlpha = 1, /** @internal */ _this._globalInteractive = true, _this._alpha = 1, _this._interactive = true, _this._ignoreParentGroup = false, /** @internal */ _this._rootCanvasListeningEntities = [], /** @internal */ _this._groupListeningEntities = [], /** @internal */ _this._isRootCanvasDirty = false, /** @internal */ _this._isGroupDirty = false, /** @internal */ _this._groupDirtyFlags = 0;
|
|
817
|
-
_this._rootCanvasListener = _this._rootCanvasListener.bind(_this);
|
|
818
|
-
_this._groupListener = _this._groupListener.bind(_this);
|
|
819
|
-
return _this;
|
|
820
|
-
}
|
|
821
|
-
var _proto = UIGroup.prototype;
|
|
822
|
-
/**
|
|
823
|
-
* @internal
|
|
824
|
-
*/ _proto._getGlobalAlpha = function _getGlobalAlpha() {
|
|
825
|
-
if (this._isContainDirtyFlag(1)) {
|
|
826
|
-
if (this._ignoreParentGroup) {
|
|
827
|
-
this._globalAlpha = this._alpha;
|
|
828
|
-
} else {
|
|
829
|
-
var parentGroup = this._getGroup();
|
|
830
|
-
this._globalAlpha = this._alpha * (parentGroup ? parentGroup._getGlobalAlpha() : 1);
|
|
349
|
+
return null;
|
|
350
|
+
};
|
|
351
|
+
Utils._registerRootCanvas = function _registerRootCanvas(element, canvas) {
|
|
352
|
+
var preCanvas = element._rootCanvas;
|
|
353
|
+
if (preCanvas !== canvas) {
|
|
354
|
+
if (preCanvas) {
|
|
355
|
+
var replaced = preCanvas._disorderedElements.deleteByIndex(element._indexInRootCanvas);
|
|
356
|
+
replaced && (replaced._indexInRootCanvas = element._indexInRootCanvas);
|
|
357
|
+
element._indexInRootCanvas = -1;
|
|
831
358
|
}
|
|
832
|
-
|
|
359
|
+
if (canvas) {
|
|
360
|
+
var disorderedElements = canvas._disorderedElements;
|
|
361
|
+
element._indexInRootCanvas = disorderedElements.length;
|
|
362
|
+
disorderedElements.add(element);
|
|
363
|
+
}
|
|
364
|
+
element._rootCanvas = canvas;
|
|
833
365
|
}
|
|
834
|
-
return this._globalAlpha;
|
|
835
366
|
};
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
var parentGroup = this._getGroup();
|
|
844
|
-
this._globalInteractive = this._interactive && (!parentGroup || parentGroup._getGlobalInteractive());
|
|
367
|
+
Utils._registerGroup = function _registerGroup(element, group) {
|
|
368
|
+
var preGroup = element._group;
|
|
369
|
+
if (preGroup !== group) {
|
|
370
|
+
if (preGroup) {
|
|
371
|
+
var replaced = preGroup._disorderedElements.deleteByIndex(element._indexInGroup);
|
|
372
|
+
replaced && (replaced._indexInGroup = element._indexInGroup);
|
|
373
|
+
element._indexInGroup = -1;
|
|
845
374
|
}
|
|
846
|
-
|
|
375
|
+
if (group) {
|
|
376
|
+
var disorderedElements = group._disorderedElements;
|
|
377
|
+
element._indexInGroup = disorderedElements.length;
|
|
378
|
+
disorderedElements.add(element);
|
|
379
|
+
}
|
|
380
|
+
element._group = group;
|
|
381
|
+
element._onGroupModify(GroupModifyFlags.All);
|
|
847
382
|
}
|
|
848
|
-
return this._globalInteractive;
|
|
849
|
-
};
|
|
850
|
-
// @ts-ignore
|
|
851
|
-
_proto._onEnableInScene = function _onEnableInScene() {
|
|
852
|
-
Utils.setRootCanvasDirty(this);
|
|
853
|
-
Utils.setGroupDirty(this);
|
|
854
|
-
// @ts-ignore
|
|
855
|
-
this.entity._dispatchModify(EntityUIModifyFlags.GroupEnableInScene);
|
|
856
|
-
};
|
|
857
|
-
// @ts-ignore
|
|
858
|
-
_proto._onDisableInScene = function _onDisableInScene() {
|
|
859
|
-
Utils.cleanRootCanvas(this);
|
|
860
|
-
Utils.cleanGroup(this);
|
|
861
|
-
var disorderedElements = this._disorderedElements;
|
|
862
|
-
disorderedElements.forEach(function(element) {
|
|
863
|
-
Utils.setGroupDirty(element);
|
|
864
|
-
});
|
|
865
|
-
disorderedElements.length = 0;
|
|
866
|
-
disorderedElements.garbageCollection();
|
|
867
|
-
this._isRootCanvasDirty = this._isGroupDirty = false;
|
|
868
|
-
};
|
|
869
|
-
/**
|
|
870
|
-
* @internal
|
|
871
|
-
*/ _proto._getRootCanvas = function _getRootCanvas() {
|
|
872
|
-
this._isRootCanvasDirty && Utils.setRootCanvas(this, Utils.searchRootCanvasInParents(this));
|
|
873
|
-
return this._rootCanvas;
|
|
874
|
-
};
|
|
875
|
-
/**
|
|
876
|
-
* @internal
|
|
877
|
-
*/ _proto._getGroup = function _getGroup() {
|
|
878
|
-
this._isGroupDirty && Utils.setGroup(this, Utils.searchGroupInParents(this));
|
|
879
|
-
return this._group;
|
|
880
383
|
};
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
384
|
+
Utils._registerListener = function _registerListener(entity, root, listener, listeningEntities) {
|
|
385
|
+
var count = 0;
|
|
386
|
+
while(entity && entity !== root){
|
|
387
|
+
var preEntity = listeningEntities[count];
|
|
388
|
+
if (preEntity !== entity) {
|
|
389
|
+
// @ts-ignore
|
|
390
|
+
preEntity == null ? void 0 : preEntity._unRegisterModifyListener(listener);
|
|
391
|
+
listeningEntities[count] = entity;
|
|
392
|
+
// @ts-ignore
|
|
393
|
+
entity._registerModifyListener(listener);
|
|
394
|
+
}
|
|
395
|
+
entity = entity.parent;
|
|
396
|
+
count++;
|
|
886
397
|
}
|
|
398
|
+
listeningEntities.length = count;
|
|
887
399
|
};
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
Utils.setRootCanvasDirty(this);
|
|
893
|
-
Utils.setGroupDirty(this);
|
|
400
|
+
Utils._unRegisterListener = function _unRegisterListener(listener, listeningEntities) {
|
|
401
|
+
for(var i = 0, n = listeningEntities.length; i < n; i++){
|
|
402
|
+
// @ts-ignore
|
|
403
|
+
listeningEntities[i]._unRegisterModifyListener(listener);
|
|
894
404
|
}
|
|
405
|
+
listeningEntities.length = 0;
|
|
895
406
|
};
|
|
407
|
+
return Utils;
|
|
408
|
+
}();
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* @internal
|
|
412
|
+
* Visual-layering driven UI batching: solve visual correctness first, batching falls out for free.
|
|
413
|
+
*
|
|
414
|
+
* Think of it as stacking elements onto numbered shelves (depths):
|
|
415
|
+
* - Non-overlapping elements share shelf 0 — free to cluster regardless of material.
|
|
416
|
+
* - Overlapping + batch-compatible — share the same shelf, still cluster.
|
|
417
|
+
* - Overlapping + batch-incompatible — bumped one shelf higher (drawn on top).
|
|
418
|
+
*
|
|
419
|
+
* `depth` is a global tag, not a spatial group: distant elements at the same visual layer
|
|
420
|
+
* share the same depth and get clustered together. Once depth is assigned, sort by
|
|
421
|
+
* (depth, material, texture, hierarchyIndex) — visual order is locked, batching is the
|
|
422
|
+
* by-product of materials clustering within each depth band.
|
|
423
|
+
*
|
|
424
|
+
* Overlap detection is accelerated by a 10×10 spatial grid. Grid origin and cell size
|
|
425
|
+
* are derived from the union AABB of input elements (the bounds transform itself is the
|
|
426
|
+
* work the loop must do anyway, so the union accumulation just piggybacks). This stays
|
|
427
|
+
* correct across SS/WS canvases, any pivot, and any element distribution — no dependency
|
|
428
|
+
* on canvas configuration.
|
|
429
|
+
*/ var UIBatchSorter = /*#__PURE__*/ function() {
|
|
430
|
+
function UIBatchSorter() {}
|
|
896
431
|
/**
|
|
897
|
-
*
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
this.
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
this._groupDirtyFlags &= ~type;
|
|
918
|
-
};
|
|
919
|
-
_create_class(UIGroup, [
|
|
920
|
-
{
|
|
921
|
-
key: "ignoreParentGroup",
|
|
922
|
-
get: /**
|
|
923
|
-
* Whether to ignore the parent group.
|
|
924
|
-
* @remarks If this parameter set to `true`,
|
|
925
|
-
* all settings of the parent group will be ignored.
|
|
926
|
-
*/ function get() {
|
|
927
|
-
return this._ignoreParentGroup;
|
|
928
|
-
},
|
|
929
|
-
set: function set(value) {
|
|
930
|
-
if (this._ignoreParentGroup !== value) {
|
|
931
|
-
this._ignoreParentGroup = value;
|
|
932
|
-
this._onGroupModify(3);
|
|
933
|
-
}
|
|
934
|
-
}
|
|
935
|
-
},
|
|
936
|
-
{
|
|
937
|
-
key: "interactive",
|
|
938
|
-
get: /**
|
|
939
|
-
* Whether the group is interactive.
|
|
940
|
-
*/ function get() {
|
|
941
|
-
return this._interactive;
|
|
942
|
-
},
|
|
943
|
-
set: function set(value) {
|
|
944
|
-
if (this._interactive !== value) {
|
|
945
|
-
this._interactive = value;
|
|
946
|
-
this._onGroupModify(2);
|
|
947
|
-
}
|
|
948
|
-
}
|
|
949
|
-
},
|
|
950
|
-
{
|
|
951
|
-
key: "alpha",
|
|
952
|
-
get: /**
|
|
953
|
-
* The alpha value of the group.
|
|
954
|
-
*/ function get() {
|
|
955
|
-
return this._alpha;
|
|
956
|
-
},
|
|
957
|
-
set: function set(value) {
|
|
958
|
-
value = Math.max(0, Math.min(value, 1));
|
|
959
|
-
if (this._alpha !== value) {
|
|
960
|
-
this._alpha = value;
|
|
961
|
-
this._onGroupModify(1);
|
|
962
|
-
}
|
|
963
|
-
}
|
|
964
|
-
}
|
|
965
|
-
]);
|
|
966
|
-
return UIGroup;
|
|
967
|
-
}(engine.Component);
|
|
968
|
-
__decorate([
|
|
969
|
-
engine.ignoreClone
|
|
970
|
-
], UIGroup.prototype, "_indexInGroup", void 0);
|
|
971
|
-
__decorate([
|
|
972
|
-
engine.ignoreClone
|
|
973
|
-
], UIGroup.prototype, "_indexInRootCanvas", void 0);
|
|
974
|
-
__decorate([
|
|
975
|
-
engine.ignoreClone
|
|
976
|
-
], UIGroup.prototype, "_globalAlpha", void 0);
|
|
977
|
-
__decorate([
|
|
978
|
-
engine.ignoreClone
|
|
979
|
-
], UIGroup.prototype, "_globalInteractive", void 0);
|
|
980
|
-
__decorate([
|
|
981
|
-
engine.ignoreClone
|
|
982
|
-
], UIGroup.prototype, "_rootCanvasListeningEntities", void 0);
|
|
983
|
-
__decorate([
|
|
984
|
-
engine.ignoreClone
|
|
985
|
-
], UIGroup.prototype, "_groupListeningEntities", void 0);
|
|
986
|
-
__decorate([
|
|
987
|
-
engine.ignoreClone
|
|
988
|
-
], UIGroup.prototype, "_isRootCanvasDirty", void 0);
|
|
989
|
-
__decorate([
|
|
990
|
-
engine.ignoreClone
|
|
991
|
-
], UIGroup.prototype, "_isGroupDirty", void 0);
|
|
992
|
-
__decorate([
|
|
993
|
-
engine.ignoreClone
|
|
994
|
-
], UIGroup.prototype, "_groupDirtyFlags", void 0);
|
|
995
|
-
__decorate([
|
|
996
|
-
engine.ignoreClone
|
|
997
|
-
], UIGroup.prototype, "_groupListener", null);
|
|
998
|
-
__decorate([
|
|
999
|
-
engine.ignoreClone
|
|
1000
|
-
], UIGroup.prototype, "_rootCanvasListener", null);
|
|
1001
|
-
var GroupModifyFlags = /*#__PURE__*/ function(GroupModifyFlags) {
|
|
1002
|
-
GroupModifyFlags[GroupModifyFlags["None"] = 0] = "None";
|
|
1003
|
-
GroupModifyFlags[GroupModifyFlags["GlobalAlpha"] = 1] = "GlobalAlpha";
|
|
1004
|
-
GroupModifyFlags[GroupModifyFlags["GlobalInteractive"] = 2] = "GlobalInteractive";
|
|
1005
|
-
GroupModifyFlags[GroupModifyFlags["All"] = 3] = "All";
|
|
1006
|
-
return GroupModifyFlags;
|
|
1007
|
-
}({});
|
|
1008
|
-
|
|
1009
|
-
exports.UIRenderer = /*#__PURE__*/ function(Renderer) {
|
|
1010
|
-
_inherits(UIRenderer, Renderer);
|
|
1011
|
-
function UIRenderer(entity) {
|
|
1012
|
-
var _this;
|
|
1013
|
-
_this = Renderer.call(this, entity) || this, /**
|
|
1014
|
-
* Custom boundary for raycast detection.
|
|
1015
|
-
* @remarks this is based on `this.entity.transform`.
|
|
1016
|
-
*/ _this.raycastPadding = new engine.Vector4(0, 0, 0, 0), /** @internal */ _this._indexInRootCanvas = -1, /** @internal */ _this._isRootCanvasDirty = false, /** @internal */ _this._rootCanvasListeningEntities = [], /** @internal */ _this._indexInGroup = -1, /** @internal */ _this._isGroupDirty = false, /** @internal */ _this._groupListeningEntities = [], /** @internal */ _this._rectMasks = [], /** @internal */ _this._rectMaskRect = new engine.Vector4(), /** @internal */ _this._rectMaskEnabled = false, /** @internal */ _this._rectMaskSoftness = new engine.Vector4(), /** @internal */ _this._rectMaskHardClip = false, _this._raycastEnabled = false, _this._color = new engine.Color(1, 1, 1, 1);
|
|
1017
|
-
_this._dirtyUpdateFlag = engine.RendererUpdateFlags.WorldVolume | 2;
|
|
1018
|
-
_this._onColorChanged = _this._onColorChanged.bind(_this);
|
|
1019
|
-
//@ts-ignore
|
|
1020
|
-
_this._color._onValueChanged = _this._onColorChanged;
|
|
1021
|
-
_this._groupListener = _this._groupListener.bind(_this);
|
|
1022
|
-
_this._rootCanvasListener = _this._rootCanvasListener.bind(_this);
|
|
1023
|
-
_this.shaderData.setFloat(UIRenderer._rectClipEnabledProperty, 0);
|
|
1024
|
-
_this.shaderData.setVector4(UIRenderer._rectClipSoftnessProperty, _this._rectMaskSoftness);
|
|
1025
|
-
_this.shaderData.setFloat(UIRenderer._rectClipHardClipProperty, 0);
|
|
1026
|
-
return _this;
|
|
1027
|
-
}
|
|
1028
|
-
var _proto = UIRenderer.prototype;
|
|
1029
|
-
// @ts-ignore
|
|
1030
|
-
_proto._canBatch = function _canBatch(preElement, curElement) {
|
|
1031
|
-
return engine.VertexMergeBatcher.canBatchSprite(preElement, curElement);
|
|
1032
|
-
};
|
|
1033
|
-
// @ts-ignore
|
|
1034
|
-
_proto._batch = function _batch(preElement, curElement) {
|
|
1035
|
-
engine.VertexMergeBatcher.batch(preElement, curElement);
|
|
1036
|
-
};
|
|
1037
|
-
// @ts-ignore
|
|
1038
|
-
_proto._updateTransformShaderData = function _updateTransformShaderData(context, onlyMVP) {
|
|
1039
|
-
// @ts-ignore
|
|
1040
|
-
this._updateWorldSpaceTransformShaderData(context, onlyMVP);
|
|
1041
|
-
};
|
|
1042
|
-
// @ts-ignore
|
|
1043
|
-
_proto._prepareRender = function _prepareRender(context) {
|
|
1044
|
-
// Update once per frame per renderer, not influenced by batched
|
|
1045
|
-
if (this._renderFrameCount !== this.engine.time.frameCount) {
|
|
1046
|
-
this._update(context);
|
|
1047
|
-
}
|
|
1048
|
-
this._updateRectMaskClipState();
|
|
1049
|
-
this._render(context);
|
|
1050
|
-
// union camera global macro and renderer macro.
|
|
1051
|
-
engine.ShaderMacroCollection.unionCollection(context.camera._globalShaderMacro, // @ts-ignore
|
|
1052
|
-
this.shaderData._macroCollection, //@ts-ignore
|
|
1053
|
-
this._globalShaderMacro);
|
|
1054
|
-
};
|
|
1055
|
-
// @ts-ignore
|
|
1056
|
-
_proto._onEnableInScene = function _onEnableInScene() {
|
|
1057
|
-
// @ts-ignore
|
|
1058
|
-
this._overrideUpdate && this.scene._componentsManager.addOnUpdateRenderers(this);
|
|
1059
|
-
this.entity._updateUIHierarchyVersion(exports.UICanvas._hierarchyCounter);
|
|
1060
|
-
Utils.setRootCanvasDirty(this);
|
|
1061
|
-
Utils.setGroupDirty(this);
|
|
1062
|
-
};
|
|
1063
|
-
// @ts-ignore
|
|
1064
|
-
_proto._onDisableInScene = function _onDisableInScene() {
|
|
1065
|
-
// @ts-ignore
|
|
1066
|
-
this._overrideUpdate && this.scene._componentsManager.removeOnUpdateRenderers(this);
|
|
1067
|
-
this.entity._updateUIHierarchyVersion(exports.UICanvas._hierarchyCounter);
|
|
1068
|
-
Utils.cleanRootCanvas(this);
|
|
1069
|
-
Utils.cleanGroup(this);
|
|
1070
|
-
};
|
|
1071
|
-
/**
|
|
1072
|
-
* @internal
|
|
1073
|
-
*/ _proto._getGlobalAlpha = function _getGlobalAlpha() {
|
|
1074
|
-
var _this__getGroup;
|
|
1075
|
-
var _this__getGroup__getGlobalAlpha;
|
|
1076
|
-
return (_this__getGroup__getGlobalAlpha = (_this__getGroup = this._getGroup()) == null ? void 0 : _this__getGroup._getGlobalAlpha()) != null ? _this__getGroup__getGlobalAlpha : 1;
|
|
1077
|
-
};
|
|
1078
|
-
/**
|
|
1079
|
-
* @internal
|
|
1080
|
-
*/ _proto._getRootCanvas = function _getRootCanvas() {
|
|
1081
|
-
this._isRootCanvasDirty && Utils.setRootCanvas(this, Utils.searchRootCanvasInParents(this));
|
|
1082
|
-
return this._rootCanvas;
|
|
1083
|
-
};
|
|
1084
|
-
/**
|
|
1085
|
-
* @internal
|
|
1086
|
-
*/ _proto._getGroup = function _getGroup() {
|
|
1087
|
-
this._isGroupDirty && Utils.setGroup(this, Utils.searchGroupInParents(this));
|
|
1088
|
-
return this._group;
|
|
1089
|
-
};
|
|
1090
|
-
/**
|
|
1091
|
-
* @internal
|
|
1092
|
-
*/ _proto._groupListener = function _groupListener(flag) {
|
|
1093
|
-
if (flag === engine.EntityModifyFlags.Parent || flag === EntityUIModifyFlags.GroupEnableInScene) {
|
|
1094
|
-
Utils.setGroupDirty(this);
|
|
1095
|
-
}
|
|
1096
|
-
};
|
|
1097
|
-
/**
|
|
1098
|
-
* @internal
|
|
1099
|
-
*/ _proto._rootCanvasListener = function _rootCanvasListener(flag, entity) {
|
|
1100
|
-
switch(flag){
|
|
1101
|
-
case engine.EntityModifyFlags.Parent:
|
|
1102
|
-
Utils.setRootCanvasDirty(this);
|
|
1103
|
-
Utils.setGroupDirty(this);
|
|
1104
|
-
case engine.EntityModifyFlags.Child:
|
|
1105
|
-
entity._updateUIHierarchyVersion(exports.UICanvas._hierarchyCounter);
|
|
1106
|
-
break;
|
|
1107
|
-
}
|
|
1108
|
-
};
|
|
1109
|
-
/**
|
|
1110
|
-
* @internal
|
|
1111
|
-
*/ _proto._onGroupModify = function _onGroupModify(flags) {
|
|
1112
|
-
if (flags & GroupModifyFlags.GlobalAlpha) {
|
|
1113
|
-
this._dirtyUpdateFlag |= 2;
|
|
1114
|
-
}
|
|
1115
|
-
};
|
|
1116
|
-
_proto._onColorChanged = function _onColorChanged() {
|
|
1117
|
-
this._dirtyUpdateFlag |= 2;
|
|
1118
|
-
};
|
|
1119
|
-
/**
|
|
1120
|
-
* @internal
|
|
1121
|
-
*/ _proto._getChunkManager = function _getChunkManager() {
|
|
1122
|
-
// @ts-ignore
|
|
1123
|
-
return this.engine._batcherManager.primitiveChunkManagerUI;
|
|
1124
|
-
};
|
|
1125
|
-
/**
|
|
1126
|
-
* @internal
|
|
1127
|
-
*/ _proto._setRectMasks = function _setRectMasks(rectMasks, count) {
|
|
1128
|
-
var targetMasks = this._rectMasks;
|
|
1129
|
-
targetMasks.length = count;
|
|
1130
|
-
for(var i = 0; i < count; i++){
|
|
1131
|
-
targetMasks[i] = rectMasks[i];
|
|
1132
|
-
}
|
|
1133
|
-
};
|
|
1134
|
-
/**
|
|
1135
|
-
* @internal
|
|
1136
|
-
*/ _proto._raycast = function _raycast(ray, out, distance) {
|
|
1137
|
-
if (distance === void 0) distance = Number.MAX_SAFE_INTEGER;
|
|
1138
|
-
var plane = UIRenderer._tempPlane;
|
|
1139
|
-
var transform = this._transformEntity.transform;
|
|
1140
|
-
var normal = plane.normal.copyFrom(transform.worldForward);
|
|
1141
|
-
plane.distance = -engine.Vector3.dot(normal, transform.worldPosition);
|
|
1142
|
-
var curDistance = ray.intersectPlane(plane);
|
|
1143
|
-
if (curDistance >= 0 && curDistance < distance) {
|
|
1144
|
-
var hitPointWorld = ray.getPoint(curDistance, UIRenderer._tempVec30);
|
|
1145
|
-
var worldMatrixInv = UIRenderer._tempMat;
|
|
1146
|
-
engine.Matrix.invert(transform.worldMatrix, worldMatrixInv);
|
|
1147
|
-
var localPosition = UIRenderer._tempVec31;
|
|
1148
|
-
engine.Vector3.transformCoordinate(hitPointWorld, worldMatrixInv, localPosition);
|
|
1149
|
-
if (this._hitTest(localPosition) && this._isRaycastVisibleByRectMask(hitPointWorld) && this._isRaycastVisibleByMask(hitPointWorld)) {
|
|
1150
|
-
out.component = this;
|
|
1151
|
-
out.distance = curDistance;
|
|
1152
|
-
out.entity = this.entity;
|
|
1153
|
-
out.normal.copyFrom(normal);
|
|
1154
|
-
out.point.copyFrom(hitPointWorld);
|
|
1155
|
-
return true;
|
|
1156
|
-
}
|
|
1157
|
-
}
|
|
1158
|
-
return false;
|
|
1159
|
-
};
|
|
1160
|
-
_proto._hitTest = function _hitTest(localPosition) {
|
|
1161
|
-
var x = localPosition.x, y = localPosition.y;
|
|
1162
|
-
var uiTransform = this._transformEntity.transform;
|
|
1163
|
-
var _uiTransform_size = uiTransform.size, width = _uiTransform_size.x, height = _uiTransform_size.y;
|
|
1164
|
-
var _uiTransform_pivot = uiTransform.pivot, pivotX = _uiTransform_pivot.x, pivotY = _uiTransform_pivot.y;
|
|
1165
|
-
var _this_raycastPadding = this.raycastPadding, paddingLeft = _this_raycastPadding.x, paddingBottom = _this_raycastPadding.y, paddingRight = _this_raycastPadding.z, paddingTop = _this_raycastPadding.w;
|
|
1166
|
-
return x >= -width * pivotX + paddingLeft && x <= width * (1 - pivotX) - paddingRight && y >= -height * pivotY + paddingTop && y <= height * (1 - pivotY) - paddingBottom;
|
|
1167
|
-
};
|
|
1168
|
-
_proto._isRaycastVisibleByMask = function _isRaycastVisibleByMask(hitPointWorld) {
|
|
1169
|
-
var maskInteraction = this._maskInteraction;
|
|
1170
|
-
if (maskInteraction === engine.SpriteMaskInteraction.None) {
|
|
1171
|
-
return true;
|
|
1172
|
-
}
|
|
1173
|
-
// @ts-ignore
|
|
1174
|
-
return this.scene._maskManager.isVisibleByMask(maskInteraction, this._maskLayer, hitPointWorld);
|
|
1175
|
-
};
|
|
1176
|
-
_proto._isRaycastVisibleByRectMask = function _isRaycastVisibleByRectMask(hitPointWorld) {
|
|
1177
|
-
var rectMasks = this._rectMasks;
|
|
1178
|
-
for(var i = 0, n = rectMasks.length; i < n; i++){
|
|
1179
|
-
var rectMask = rectMasks[i];
|
|
1180
|
-
if (!rectMask.enabled || !rectMask.entity.isActiveInHierarchy) {
|
|
1181
|
-
continue;
|
|
1182
|
-
}
|
|
1183
|
-
if (!rectMask._containsWorldPoint(hitPointWorld)) {
|
|
1184
|
-
return false;
|
|
1185
|
-
}
|
|
1186
|
-
}
|
|
1187
|
-
return true;
|
|
1188
|
-
};
|
|
1189
|
-
_proto._updateRectMaskClipState = function _updateRectMaskClipState() {
|
|
1190
|
-
var rectMasks = this._rectMasks;
|
|
1191
|
-
var count = rectMasks.length;
|
|
1192
|
-
if (count <= 0) {
|
|
1193
|
-
this._resetRectMaskClipState();
|
|
1194
|
-
return;
|
|
1195
|
-
}
|
|
1196
|
-
var minX = Number.NEGATIVE_INFINITY;
|
|
1197
|
-
var minY = Number.NEGATIVE_INFINITY;
|
|
1198
|
-
var maxX = Number.POSITIVE_INFINITY;
|
|
1199
|
-
var maxY = Number.POSITIVE_INFINITY;
|
|
1200
|
-
var clipSoftnessLeft = 0;
|
|
1201
|
-
var clipSoftnessBottom = 0;
|
|
1202
|
-
var clipSoftnessRight = 0;
|
|
1203
|
-
var clipSoftnessTop = 0;
|
|
1204
|
-
var clipHardClip = false;
|
|
1205
|
-
var hasActiveMask = false;
|
|
1206
|
-
var tempRect = UIRenderer._tempRect;
|
|
1207
|
-
for(var i = 0; i < count; i++){
|
|
1208
|
-
var rectMask = rectMasks[i];
|
|
1209
|
-
if (!rectMask.enabled || !rectMask.entity.isActiveInHierarchy) {
|
|
1210
|
-
continue;
|
|
1211
|
-
}
|
|
1212
|
-
hasActiveMask = true;
|
|
1213
|
-
var softness = rectMask.softness;
|
|
1214
|
-
if (!clipHardClip && rectMask.alphaClip) {
|
|
1215
|
-
clipHardClip = true;
|
|
1216
|
-
}
|
|
1217
|
-
if (!rectMask._getWorldRect(tempRect)) {
|
|
1218
|
-
minX = 1;
|
|
1219
|
-
minY = 1;
|
|
1220
|
-
maxX = 0;
|
|
1221
|
-
maxY = 0;
|
|
1222
|
-
break;
|
|
1223
|
-
}
|
|
1224
|
-
if (tempRect.x > minX) {
|
|
1225
|
-
minX = tempRect.x;
|
|
1226
|
-
clipSoftnessLeft = softness.x;
|
|
1227
|
-
}
|
|
1228
|
-
if (tempRect.y > minY) {
|
|
1229
|
-
minY = tempRect.y;
|
|
1230
|
-
clipSoftnessBottom = softness.y;
|
|
1231
|
-
}
|
|
1232
|
-
if (tempRect.z < maxX) {
|
|
1233
|
-
maxX = tempRect.z;
|
|
1234
|
-
clipSoftnessRight = softness.x;
|
|
1235
|
-
}
|
|
1236
|
-
if (tempRect.w < maxY) {
|
|
1237
|
-
maxY = tempRect.w;
|
|
1238
|
-
clipSoftnessTop = softness.y;
|
|
1239
|
-
}
|
|
1240
|
-
}
|
|
1241
|
-
if (!hasActiveMask) {
|
|
1242
|
-
this._resetRectMaskClipState();
|
|
1243
|
-
return;
|
|
1244
|
-
}
|
|
1245
|
-
if (minX >= maxX || minY >= maxY) {
|
|
1246
|
-
minX = 1;
|
|
1247
|
-
minY = 1;
|
|
1248
|
-
maxX = 0;
|
|
1249
|
-
maxY = 0;
|
|
1250
|
-
clipSoftnessLeft = 0;
|
|
1251
|
-
clipSoftnessBottom = 0;
|
|
1252
|
-
clipSoftnessRight = 0;
|
|
1253
|
-
clipSoftnessTop = 0;
|
|
1254
|
-
}
|
|
1255
|
-
var rectMaskRect = this._rectMaskRect;
|
|
1256
|
-
if (rectMaskRect.x !== minX || rectMaskRect.y !== minY || rectMaskRect.z !== maxX || rectMaskRect.w !== maxY) {
|
|
1257
|
-
rectMaskRect.set(minX, minY, maxX, maxY);
|
|
1258
|
-
this.shaderData.setVector4(UIRenderer._rectClipRectProperty, rectMaskRect);
|
|
1259
|
-
}
|
|
1260
|
-
var rectMaskSoftness = this._rectMaskSoftness;
|
|
1261
|
-
if (rectMaskSoftness.x !== clipSoftnessLeft || rectMaskSoftness.y !== clipSoftnessBottom || rectMaskSoftness.z !== clipSoftnessRight || rectMaskSoftness.w !== clipSoftnessTop) {
|
|
1262
|
-
rectMaskSoftness.set(clipSoftnessLeft, clipSoftnessBottom, clipSoftnessRight, clipSoftnessTop);
|
|
1263
|
-
this.shaderData.setVector4(UIRenderer._rectClipSoftnessProperty, rectMaskSoftness);
|
|
1264
|
-
}
|
|
1265
|
-
if (this._rectMaskHardClip !== clipHardClip) {
|
|
1266
|
-
this._rectMaskHardClip = clipHardClip;
|
|
1267
|
-
this.shaderData.setFloat(UIRenderer._rectClipHardClipProperty, clipHardClip ? 1 : 0);
|
|
1268
|
-
}
|
|
1269
|
-
if (!this._rectMaskEnabled) {
|
|
1270
|
-
this._rectMaskEnabled = true;
|
|
1271
|
-
this.shaderData.setFloat(UIRenderer._rectClipEnabledProperty, 1);
|
|
1272
|
-
}
|
|
1273
|
-
};
|
|
1274
|
-
_proto._resetRectMaskClipState = function _resetRectMaskClipState() {
|
|
1275
|
-
if (this._rectMaskEnabled) {
|
|
1276
|
-
this._rectMaskEnabled = false;
|
|
1277
|
-
this.shaderData.setFloat(UIRenderer._rectClipEnabledProperty, 0);
|
|
1278
|
-
}
|
|
1279
|
-
var rectMaskSoftness = this._rectMaskSoftness;
|
|
1280
|
-
if (rectMaskSoftness.x !== 0 || rectMaskSoftness.y !== 0 || rectMaskSoftness.z !== 0 || rectMaskSoftness.w !== 0) {
|
|
1281
|
-
rectMaskSoftness.set(0, 0, 0, 0);
|
|
1282
|
-
this.shaderData.setVector4(UIRenderer._rectClipSoftnessProperty, rectMaskSoftness);
|
|
1283
|
-
}
|
|
1284
|
-
if (this._rectMaskHardClip) {
|
|
1285
|
-
this._rectMaskHardClip = false;
|
|
1286
|
-
this.shaderData.setFloat(UIRenderer._rectClipHardClipProperty, 0);
|
|
1287
|
-
}
|
|
1288
|
-
};
|
|
1289
|
-
_proto._onDestroy = function _onDestroy() {
|
|
1290
|
-
if (this._subChunk) {
|
|
1291
|
-
this._getChunkManager().freeSubChunk(this._subChunk);
|
|
1292
|
-
this._subChunk = null;
|
|
1293
|
-
}
|
|
1294
|
-
Renderer.prototype._onDestroy.call(this);
|
|
1295
|
-
//@ts-ignore
|
|
1296
|
-
this._color._onValueChanged = null;
|
|
1297
|
-
this._color = null;
|
|
1298
|
-
this._rectMasks = null;
|
|
1299
|
-
this._rectMaskSoftness = null;
|
|
1300
|
-
};
|
|
1301
|
-
_create_class(UIRenderer, [
|
|
1302
|
-
{
|
|
1303
|
-
key: "color",
|
|
1304
|
-
get: /**
|
|
1305
|
-
* Rendering color for the ui renderer.
|
|
1306
|
-
*/ function get() {
|
|
1307
|
-
return this._color;
|
|
1308
|
-
},
|
|
1309
|
-
set: function set(value) {
|
|
1310
|
-
if (this._color !== value) {
|
|
1311
|
-
this._color.copyFrom(value);
|
|
1312
|
-
}
|
|
1313
|
-
}
|
|
1314
|
-
},
|
|
1315
|
-
{
|
|
1316
|
-
key: "maskLayer",
|
|
1317
|
-
get: /**
|
|
1318
|
-
* The mask layer the ui renderer belongs to.
|
|
1319
|
-
*/ function get() {
|
|
1320
|
-
return this._maskLayer;
|
|
1321
|
-
},
|
|
1322
|
-
set: function set(value) {
|
|
1323
|
-
this._maskLayer = value;
|
|
1324
|
-
}
|
|
1325
|
-
},
|
|
1326
|
-
{
|
|
1327
|
-
key: "maskInteraction",
|
|
1328
|
-
get: /**
|
|
1329
|
-
* Interacts with the masks.
|
|
1330
|
-
*/ function get() {
|
|
1331
|
-
return this._maskInteraction;
|
|
1332
|
-
},
|
|
1333
|
-
set: function set(value) {
|
|
1334
|
-
if (this._maskInteraction !== value) {
|
|
1335
|
-
this._maskInteraction = value;
|
|
1336
|
-
}
|
|
1337
|
-
}
|
|
1338
|
-
},
|
|
1339
|
-
{
|
|
1340
|
-
key: "raycastEnabled",
|
|
1341
|
-
get: /**
|
|
1342
|
-
* Whether this renderer be picked up by raycast.
|
|
1343
|
-
*/ function get() {
|
|
1344
|
-
return this._raycastEnabled;
|
|
1345
|
-
},
|
|
1346
|
-
set: function set(value) {
|
|
1347
|
-
this._raycastEnabled = value;
|
|
1348
|
-
}
|
|
1349
|
-
}
|
|
1350
|
-
]);
|
|
1351
|
-
return UIRenderer;
|
|
1352
|
-
}(engine.Renderer);
|
|
1353
|
-
/** @internal */ exports.UIRenderer._tempVec20 = new engine.Vector2();
|
|
1354
|
-
/** @internal */ exports.UIRenderer._tempVec30 = new engine.Vector3();
|
|
1355
|
-
/** @internal */ exports.UIRenderer._tempVec31 = new engine.Vector3();
|
|
1356
|
-
/** @internal */ exports.UIRenderer._tempMat = new engine.Matrix();
|
|
1357
|
-
/** @internal */ exports.UIRenderer._tempPlane = new engine.Plane();
|
|
1358
|
-
/** @internal */ exports.UIRenderer._textureProperty = engine.ShaderProperty.getByName("renderer_UITexture");
|
|
1359
|
-
/** @internal */ exports.UIRenderer._rectClipRectProperty = engine.ShaderProperty.getByName("renderer_UIRectClipRect");
|
|
1360
|
-
/** @internal */ exports.UIRenderer._rectClipEnabledProperty = engine.ShaderProperty.getByName("renderer_UIRectClipEnabled");
|
|
1361
|
-
/** @internal */ exports.UIRenderer._rectClipSoftnessProperty = engine.ShaderProperty.getByName("renderer_UIRectClipSoftness");
|
|
1362
|
-
/** @internal */ exports.UIRenderer._rectClipHardClipProperty = engine.ShaderProperty.getByName("renderer_UIRectClipHardClip");
|
|
1363
|
-
/** @internal */ exports.UIRenderer._tempRect = new engine.Vector4();
|
|
1364
|
-
__decorate([
|
|
1365
|
-
engine.ignoreClone
|
|
1366
|
-
], exports.UIRenderer.prototype, "_indexInRootCanvas", void 0);
|
|
1367
|
-
__decorate([
|
|
1368
|
-
engine.ignoreClone
|
|
1369
|
-
], exports.UIRenderer.prototype, "_isRootCanvasDirty", void 0);
|
|
1370
|
-
__decorate([
|
|
1371
|
-
engine.ignoreClone
|
|
1372
|
-
], exports.UIRenderer.prototype, "_rootCanvasListeningEntities", void 0);
|
|
1373
|
-
__decorate([
|
|
1374
|
-
engine.ignoreClone
|
|
1375
|
-
], exports.UIRenderer.prototype, "_indexInGroup", void 0);
|
|
1376
|
-
__decorate([
|
|
1377
|
-
engine.ignoreClone
|
|
1378
|
-
], exports.UIRenderer.prototype, "_isGroupDirty", void 0);
|
|
1379
|
-
__decorate([
|
|
1380
|
-
engine.ignoreClone
|
|
1381
|
-
], exports.UIRenderer.prototype, "_groupListeningEntities", void 0);
|
|
1382
|
-
__decorate([
|
|
1383
|
-
engine.ignoreClone
|
|
1384
|
-
], exports.UIRenderer.prototype, "_subChunk", void 0);
|
|
1385
|
-
__decorate([
|
|
1386
|
-
engine.ignoreClone
|
|
1387
|
-
], exports.UIRenderer.prototype, "_rectMasks", void 0);
|
|
1388
|
-
__decorate([
|
|
1389
|
-
engine.ignoreClone
|
|
1390
|
-
], exports.UIRenderer.prototype, "_rectMaskRect", void 0);
|
|
1391
|
-
__decorate([
|
|
1392
|
-
engine.ignoreClone
|
|
1393
|
-
], exports.UIRenderer.prototype, "_rectMaskEnabled", void 0);
|
|
1394
|
-
__decorate([
|
|
1395
|
-
engine.ignoreClone
|
|
1396
|
-
], exports.UIRenderer.prototype, "_rectMaskSoftness", void 0);
|
|
1397
|
-
__decorate([
|
|
1398
|
-
engine.ignoreClone
|
|
1399
|
-
], exports.UIRenderer.prototype, "_rectMaskHardClip", void 0);
|
|
1400
|
-
__decorate([
|
|
1401
|
-
engine.ignoreClone
|
|
1402
|
-
], exports.UIRenderer.prototype, "_groupListener", null);
|
|
1403
|
-
__decorate([
|
|
1404
|
-
engine.ignoreClone
|
|
1405
|
-
], exports.UIRenderer.prototype, "_rootCanvasListener", null);
|
|
1406
|
-
__decorate([
|
|
1407
|
-
engine.ignoreClone
|
|
1408
|
-
], exports.UIRenderer.prototype, "_onColorChanged", null);
|
|
1409
|
-
exports.UIRenderer = __decorate([
|
|
1410
|
-
engine.dependentComponents(UITransform, engine.DependentMode.AutoAdd)
|
|
1411
|
-
], exports.UIRenderer);
|
|
1412
|
-
/**
|
|
1413
|
-
* @remarks Extends `RendererUpdateFlags`.
|
|
1414
|
-
*/ var UIRendererUpdateFlags = /*#__PURE__*/ function(UIRendererUpdateFlags) {
|
|
1415
|
-
UIRendererUpdateFlags[UIRendererUpdateFlags["Color"] = 2] = "Color";
|
|
1416
|
-
return UIRendererUpdateFlags;
|
|
1417
|
-
}({});
|
|
1418
|
-
|
|
1419
|
-
exports.UICanvas = /*#__PURE__*/ function(Component) {
|
|
1420
|
-
_inherits(UICanvas, Component);
|
|
1421
|
-
function UICanvas(entity) {
|
|
1422
|
-
var _this;
|
|
1423
|
-
_this = Component.call(this, entity) || this, /** @internal */ _this._canvasIndex = -1, /** @internal */ _this._indexInRootCanvas = -1, /** @internal */ _this._isRootCanvasDirty = false, /** @internal */ _this._rootCanvasListeningEntities = [], /** @internal */ _this._isRootCanvas = false, /** @internal */ _this._renderElements = [], /** @internal */ _this._batchedRenderElements = [], /** @internal */ _this._sortDistance = 0, /** @internal */ _this._orderedRenderers = [], /** @internal */ _this._realRenderMode = 4, /** @internal */ _this._disorderedElements = new engine.DisorderedArray(), _this._renderMode = CanvasRenderMode.WorldSpace, _this._resolutionAdaptationMode = ResolutionAdaptationMode.HeightAdaptation, _this._sortOrder = 0, _this._distance = 10, _this._referenceResolution = new engine.Vector2(800, 600), _this._referenceResolutionPerUnit = 100, _this._hierarchyVersion = -1, _this._center = new engine.Vector3();
|
|
1424
|
-
_this._onCanvasSizeListener = _this._onCanvasSizeListener.bind(_this);
|
|
1425
|
-
_this._onCameraModifyListener = _this._onCameraModifyListener.bind(_this);
|
|
1426
|
-
_this._onCameraTransformListener = _this._onCameraTransformListener.bind(_this);
|
|
1427
|
-
_this._onReferenceResolutionChanged = _this._onReferenceResolutionChanged.bind(_this);
|
|
1428
|
-
// @ts-ignore
|
|
1429
|
-
_this._referenceResolution._onValueChanged = _this._onReferenceResolutionChanged;
|
|
1430
|
-
_this._rootCanvasListener = _this._rootCanvasListener.bind(_this);
|
|
1431
|
-
_this._centerDirtyFlag = entity.registerWorldChangeFlag();
|
|
1432
|
-
return _this;
|
|
1433
|
-
}
|
|
1434
|
-
var _proto = UICanvas.prototype;
|
|
1435
|
-
/**
|
|
1436
|
-
* @internal
|
|
1437
|
-
*/ _proto._raycast = function _raycast(ray, out, distance) {
|
|
1438
|
-
if (distance === void 0) distance = Number.MAX_SAFE_INTEGER;
|
|
1439
|
-
var renderers = this._getRenderers();
|
|
1440
|
-
for(var i = renderers.length - 1; i >= 0; i--){
|
|
1441
|
-
var element = renderers[i];
|
|
1442
|
-
if (element.raycastEnabled && element._raycast(ray, out, distance)) {
|
|
1443
|
-
return true;
|
|
1444
|
-
}
|
|
1445
|
-
}
|
|
1446
|
-
out.component = null;
|
|
1447
|
-
out.entity = null;
|
|
1448
|
-
out.distance = 0;
|
|
1449
|
-
out.point.set(0, 0, 0);
|
|
1450
|
-
out.normal.set(0, 0, 0);
|
|
1451
|
-
return false;
|
|
1452
|
-
};
|
|
1453
|
-
/**
|
|
1454
|
-
* @internal
|
|
1455
|
-
*/ _proto._getRootCanvas = function _getRootCanvas() {
|
|
1456
|
-
return this._rootCanvas;
|
|
1457
|
-
};
|
|
1458
|
-
/**
|
|
1459
|
-
* @internal
|
|
1460
|
-
*/ _proto._canRender = function _canRender(camera) {
|
|
1461
|
-
return this._realRenderMode !== CanvasRenderMode.ScreenSpaceCamera || this._camera === camera;
|
|
1462
|
-
};
|
|
1463
|
-
/**
|
|
1464
|
-
* @internal
|
|
1465
|
-
*/ _proto._canDispatchEvent = function _canDispatchEvent(camera) {
|
|
1466
|
-
var realMode = this._realRenderMode;
|
|
1467
|
-
if (realMode === CanvasRenderMode.ScreenSpaceOverlay) {
|
|
1468
|
-
return true;
|
|
1469
|
-
}
|
|
1470
|
-
var assignedCamera = this._camera;
|
|
1471
|
-
// @ts-ignore
|
|
1472
|
-
return !assignedCamera || !assignedCamera._phasedActiveInScene || assignedCamera === camera;
|
|
1473
|
-
};
|
|
1474
|
-
/**
|
|
1475
|
-
* @internal
|
|
1476
|
-
*/ _proto._prepareRender = function _prepareRender(context) {
|
|
1477
|
-
var _this = this, engine = _this.engine, mode = _this._realRenderMode;
|
|
1478
|
-
var _context_camera = context.camera, enableFrustumCulling = _context_camera.enableFrustumCulling, cullingMask = _context_camera.cullingMask, frustum = _context_camera._frustum;
|
|
1479
|
-
var frameCount = engine.time.frameCount;
|
|
1480
|
-
var renderElements = this._renderElements;
|
|
1481
|
-
renderElements.length = 0;
|
|
1482
|
-
var virtualCamera = context.virtualCamera;
|
|
1483
|
-
this._updateSortDistance(virtualCamera.isOrthographic, virtualCamera.position, virtualCamera.forward);
|
|
1484
|
-
var _engine_canvas = engine.canvas, width = _engine_canvas.width, height = _engine_canvas.height;
|
|
1485
|
-
var renderers = this._getRenderers();
|
|
1486
|
-
for(var i = 0, n = renderers.length; i < n; i++){
|
|
1487
|
-
var renderer = renderers[i];
|
|
1488
|
-
// Filter by camera culling mask
|
|
1489
|
-
if (!(cullingMask & renderer.entity.layer)) {
|
|
1490
|
-
continue;
|
|
432
|
+
* Reorders `elements` in place for optimal batching.
|
|
433
|
+
* @param elements - in hierarchy order (depth-first traversal); mutated in place
|
|
434
|
+
* @param canvasWorldMatrix - reduces world bounds to canvas-local for precise overlap
|
|
435
|
+
*/ UIBatchSorter.sort = function sort(elements, canvasWorldMatrix) {
|
|
436
|
+
var count = elements.length;
|
|
437
|
+
if (count <= 1) return;
|
|
438
|
+
var gridDim = this._gridDim;
|
|
439
|
+
var entries = this._entries;
|
|
440
|
+
var grid = this._grid;
|
|
441
|
+
var dirtyCells = this._dirtyCells;
|
|
442
|
+
var localBoundsPool = this._localBoundsPool;
|
|
443
|
+
var worldToLocal = this._worldToLocal;
|
|
444
|
+
engine.Matrix.invert(canvasWorldMatrix, worldToLocal);
|
|
445
|
+
while(entries.length < count)entries.push(new SortEntry());
|
|
446
|
+
// Allocate grid once, reuse forever (each cell must be a real [], not a sparse hole)
|
|
447
|
+
if (grid.length < gridDim) {
|
|
448
|
+
while(grid.length < gridDim)grid.push([]);
|
|
449
|
+
for(var i = 0; i < gridDim; i++){
|
|
450
|
+
var row = grid[i];
|
|
451
|
+
while(row.length < gridDim)row.push([]);
|
|
1491
452
|
}
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
453
|
+
}
|
|
454
|
+
// Clear only previously-used cells (no full sweep)
|
|
455
|
+
for(var k = 0, n = dirtyCells.length; k < n; k += 2){
|
|
456
|
+
grid[dirtyCells[k]][dirtyCells[k + 1]].length = 0;
|
|
457
|
+
}
|
|
458
|
+
dirtyCells.length = 0;
|
|
459
|
+
// Pass 1: transform world bounds to canvas-local + accumulate the union AABB.
|
|
460
|
+
// Transform is already required to do precise overlap, so the union accumulation
|
|
461
|
+
// is essentially free — just a few minmax compares riding on the existing pass
|
|
462
|
+
var unionMinX = Infinity;
|
|
463
|
+
var unionMinY = Infinity;
|
|
464
|
+
var unionMaxX = -Infinity;
|
|
465
|
+
var unionMaxY = -Infinity;
|
|
466
|
+
for(var i1 = 0; i1 < count; i1++){
|
|
467
|
+
var _localBoundsPool, _i;
|
|
468
|
+
var localBounds = (_localBoundsPool = localBoundsPool)[_i = i1] || (_localBoundsPool[_i] = new engine.BoundingBox());
|
|
469
|
+
engine.BoundingBox.transform(elements[i1].component.bounds, worldToLocal, localBounds);
|
|
470
|
+
var min = localBounds.min, max = localBounds.max;
|
|
471
|
+
if (min.x < unionMinX) unionMinX = min.x;
|
|
472
|
+
if (min.y < unionMinY) unionMinY = min.y;
|
|
473
|
+
if (max.x > unionMaxX) unionMaxX = max.x;
|
|
474
|
+
if (max.y > unionMaxY) unionMaxY = max.y;
|
|
475
|
+
}
|
|
476
|
+
// Guard against a degenerate union (all elements collapsed onto a single point /
|
|
477
|
+
// axis); the grid then collapses to cell 0 which is semantically correct
|
|
478
|
+
var cellSizeX = Math.max(1e-6, unionMaxX - unionMinX) / gridDim;
|
|
479
|
+
var cellSizeY = Math.max(1e-6, unionMaxY - unionMinY) / gridDim;
|
|
480
|
+
var maxCell = gridDim - 1;
|
|
481
|
+
// Pass 2: register each element into grid cells and compute its depth
|
|
482
|
+
for(var i2 = 0; i2 < count; i2++){
|
|
483
|
+
var element = elements[i2];
|
|
484
|
+
var localBounds1 = localBoundsPool[i2];
|
|
485
|
+
var materialId = element.material.instanceId;
|
|
486
|
+
var textureId = element.texture ? element.texture.instanceId : 0;
|
|
487
|
+
// Floor + clamp guards floating-point edge cases (a `max` exactly on the union
|
|
488
|
+
// boundary would otherwise produce `gridDim`)
|
|
489
|
+
var minCellX = Math.min(maxCell, Math.max(0, Math.floor((localBounds1.min.x - unionMinX) / cellSizeX)));
|
|
490
|
+
var maxCellX = Math.min(maxCell, Math.max(0, Math.floor((localBounds1.max.x - unionMinX) / cellSizeX)));
|
|
491
|
+
var minCellY = Math.min(maxCell, Math.max(0, Math.floor((localBounds1.min.y - unionMinY) / cellSizeY)));
|
|
492
|
+
var maxCellY = Math.min(maxCell, Math.max(0, Math.floor((localBounds1.max.y - unionMinY) / cellSizeY)));
|
|
493
|
+
// Find the deepest overlapping prior, and whether that shelf has any incompatible occupant
|
|
494
|
+
var maxDepth = -1;
|
|
495
|
+
var maxDepthIncompatible = false;
|
|
496
|
+
for(var cellY = minCellY; cellY <= maxCellY; cellY++){
|
|
497
|
+
for(var cellX = minCellX; cellX <= maxCellX; cellX++){
|
|
498
|
+
var cell = grid[cellX][cellY];
|
|
499
|
+
for(var j = 0, m = cell.length; j < m; j++){
|
|
500
|
+
var other = cell[j];
|
|
501
|
+
if (!UIBatchSorter._rectOverlap(localBounds1, other.bounds)) continue;
|
|
502
|
+
var otherDepth = other.depth;
|
|
503
|
+
var otherIncompatible = other.materialId !== materialId || other.textureId !== textureId;
|
|
504
|
+
if (otherDepth > maxDepth) {
|
|
505
|
+
maxDepth = otherDepth;
|
|
506
|
+
maxDepthIncompatible = otherIncompatible;
|
|
507
|
+
} else if (otherDepth === maxDepth && otherIncompatible) {
|
|
508
|
+
maxDepthIncompatible = true;
|
|
1505
509
|
}
|
|
1506
|
-
|
|
510
|
+
}
|
|
1507
511
|
}
|
|
1508
512
|
}
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
*/ _proto._updateSortDistance = function _updateSortDistance(isOrthographic, cameraPosition, cameraForward) {
|
|
1523
|
-
switch(this._realRenderMode){
|
|
1524
|
-
case CanvasRenderMode.ScreenSpaceOverlay:
|
|
1525
|
-
this._sortDistance = 0;
|
|
1526
|
-
break;
|
|
1527
|
-
case CanvasRenderMode.ScreenSpaceCamera:
|
|
1528
|
-
this._sortDistance = this._distance;
|
|
1529
|
-
break;
|
|
1530
|
-
case CanvasRenderMode.WorldSpace:
|
|
1531
|
-
var boundsCenter = this._getCenter();
|
|
1532
|
-
if (isOrthographic) {
|
|
1533
|
-
var distance = UICanvas._tempVec3;
|
|
1534
|
-
engine.Vector3.subtract(boundsCenter, cameraPosition, distance);
|
|
1535
|
-
this._sortDistance = engine.Vector3.dot(distance, cameraForward);
|
|
1536
|
-
} else {
|
|
1537
|
-
this._sortDistance = engine.Vector3.distanceSquared(boundsCenter, cameraPosition);
|
|
513
|
+
var entry = entries[i2];
|
|
514
|
+
entry.element = element;
|
|
515
|
+
entry.hierarchyIndex = i2;
|
|
516
|
+
// Share the deepest shelf if compatible; bump up one if blocked by an incompatible occupant
|
|
517
|
+
entry.depth = maxDepth < 0 ? 0 : maxDepth + (maxDepthIncompatible ? 1 : 0);
|
|
518
|
+
entry.materialId = materialId;
|
|
519
|
+
entry.textureId = textureId;
|
|
520
|
+
entry.bounds = localBounds1;
|
|
521
|
+
for(var cellY1 = minCellY; cellY1 <= maxCellY; cellY1++){
|
|
522
|
+
for(var cellX1 = minCellX; cellX1 <= maxCellX; cellX1++){
|
|
523
|
+
var cell1 = grid[cellX1][cellY1];
|
|
524
|
+
if (cell1.length === 0) dirtyCells.push(cellX1, cellY1);
|
|
525
|
+
cell1.push(entry);
|
|
1538
526
|
}
|
|
1539
|
-
|
|
527
|
+
}
|
|
1540
528
|
}
|
|
529
|
+
// @ts-ignore — Utils._quickSort is @internal
|
|
530
|
+
engine.Utils._quickSort(entries, 0, count, UIBatchSorter._compareEntries);
|
|
531
|
+
for(var i3 = 0; i3 < count; i3++)elements[i3] = entries[i3].element;
|
|
1541
532
|
};
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
var entity = this.entity;
|
|
1545
|
-
// @ts-ignore
|
|
1546
|
-
entity._dispatchModify(4, this);
|
|
1547
|
-
var rootCanvas = Utils.searchRootCanvasInParents(this);
|
|
1548
|
-
this._setIsRootCanvas(!rootCanvas);
|
|
1549
|
-
Utils.setRootCanvas(this, rootCanvas);
|
|
1550
|
-
};
|
|
1551
|
-
// @ts-ignore
|
|
1552
|
-
_proto._onDisableInScene = function _onDisableInScene() {
|
|
1553
|
-
this._setIsRootCanvas(false);
|
|
1554
|
-
Utils.cleanRootCanvas(this);
|
|
533
|
+
UIBatchSorter._rectOverlap = function _rectOverlap(a, b) {
|
|
534
|
+
return a.min.x < b.max.x && a.max.x > b.min.x && a.min.y < b.max.y && a.max.y > b.min.y;
|
|
1555
535
|
};
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
this._renderElements.length = 0;
|
|
1559
|
-
this._batchedRenderElements.length = 0;
|
|
536
|
+
UIBatchSorter._compareEntries = function _compareEntries(a, b) {
|
|
537
|
+
return a.depth - b.depth || a.materialId - b.materialId || a.textureId - b.textureId || a.hierarchyIndex - b.hierarchyIndex;
|
|
1560
538
|
};
|
|
539
|
+
return UIBatchSorter;
|
|
540
|
+
}();
|
|
541
|
+
// Spatial-hash is fastest when cell size ≈ typical element size (one element per cell).
|
|
542
|
+
// UI elements typically span ~10% of the canvas → 10×10 grid.
|
|
543
|
+
UIBatchSorter._gridDim = 10;
|
|
544
|
+
UIBatchSorter._entries = new Array();
|
|
545
|
+
UIBatchSorter._grid = [];
|
|
546
|
+
// Interleaved (x, y) cell coords touched in the previous frame
|
|
547
|
+
UIBatchSorter._dirtyCells = new Array();
|
|
548
|
+
UIBatchSorter._localBoundsPool = new Array();
|
|
549
|
+
UIBatchSorter._worldToLocal = new engine.Matrix();
|
|
550
|
+
// materialId/textureId/bounds are flattened from RenderElement to avoid
|
|
551
|
+
// multi-hop property access in the hot inner loop and the sort comparator.
|
|
552
|
+
var SortEntry = function SortEntry() {
|
|
553
|
+
this.hierarchyIndex = 0;
|
|
554
|
+
this.depth = 0;
|
|
555
|
+
this.materialId = 0;
|
|
556
|
+
this.textureId = 0;
|
|
557
|
+
};
|
|
558
|
+
|
|
559
|
+
/**
|
|
560
|
+
* Render mode for ui canvas.
|
|
561
|
+
*/ var CanvasRenderMode = /*#__PURE__*/ function(CanvasRenderMode) {
|
|
1561
562
|
/**
|
|
1562
|
-
*
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
563
|
+
* The UI canvas will be rendered directly onto the screen and adapted to screen space,
|
|
564
|
+
* overlaying other rendering elements in the same scene.
|
|
565
|
+
* @remarks if the `engine.canvas` size change, the UI canvas will automatically adapt.
|
|
566
|
+
*/ CanvasRenderMode[CanvasRenderMode["ScreenSpaceOverlay"] = 0] = "ScreenSpaceOverlay";
|
|
567
|
+
/**
|
|
568
|
+
* The UI canvas is placed at a specified distance in front of the camera and adapted to screen space,
|
|
569
|
+
* with all objects rendered by the camera.
|
|
570
|
+
* @remarks if the camera's properties or the `engine.canvas` size change, the UI canvas will automatically adapt.
|
|
571
|
+
* @remarks if set `ScreenSpaceCamera` but no corresponding camera is assigned, the actual rendering mode defaults to `ScreenSpaceOverlay`.
|
|
572
|
+
*/ CanvasRenderMode[CanvasRenderMode["ScreenSpaceCamera"] = 1] = "ScreenSpaceCamera";
|
|
573
|
+
/**
|
|
574
|
+
* The UI canvas is placed in the 3D world space and rendered by every camera in the same scene.
|
|
575
|
+
*/ CanvasRenderMode[CanvasRenderMode["WorldSpace"] = 2] = "WorldSpace";
|
|
576
|
+
return CanvasRenderMode;
|
|
577
|
+
}({});
|
|
578
|
+
|
|
579
|
+
/**
|
|
580
|
+
* Resolution adaptation mode.
|
|
581
|
+
* @remarks Only effective in screen space.
|
|
582
|
+
*/ var ResolutionAdaptationMode = /*#__PURE__*/ function(ResolutionAdaptationMode) {
|
|
583
|
+
/** Adapt based on width.(`referenceResolution.x`) */ ResolutionAdaptationMode[ResolutionAdaptationMode["WidthAdaptation"] = 0] = "WidthAdaptation";
|
|
584
|
+
/** Adapt based on height.(`referenceResolution.y`) */ ResolutionAdaptationMode[ResolutionAdaptationMode["HeightAdaptation"] = 1] = "HeightAdaptation";
|
|
585
|
+
/** Adapt based on both width and height.(`referenceResolution`) */ ResolutionAdaptationMode[ResolutionAdaptationMode["BothAdaptation"] = 2] = "BothAdaptation";
|
|
586
|
+
/** Adapt to the side with a larger ratio. */ ResolutionAdaptationMode[ResolutionAdaptationMode["ExpandAdaptation"] = 3] = "ExpandAdaptation";
|
|
587
|
+
/** Adapt to the side with smaller ratio. */ ResolutionAdaptationMode[ResolutionAdaptationMode["ShrinkAdaptation"] = 4] = "ShrinkAdaptation";
|
|
588
|
+
return ResolutionAdaptationMode;
|
|
589
|
+
}({});
|
|
590
|
+
|
|
591
|
+
/** Horizontal alignment mode. */ var HorizontalAlignmentMode = /*#__PURE__*/ function(HorizontalAlignmentMode) {
|
|
592
|
+
/** No horizontal alignment. */ HorizontalAlignmentMode[HorizontalAlignmentMode["None"] = 0] = "None";
|
|
593
|
+
/** Left-aligned, `alignLeft` drives `position.x`. */ HorizontalAlignmentMode[HorizontalAlignmentMode["Left"] = 1] = "Left";
|
|
594
|
+
/** Right-aligned, `alignRight` drives `position.x`. */ HorizontalAlignmentMode[HorizontalAlignmentMode["Right"] = 2] = "Right";
|
|
595
|
+
/** Horizontal stretch, `alignLeft` and `alignRight` drive `position.x` and `size.x`. */ HorizontalAlignmentMode[HorizontalAlignmentMode["LeftAndRight"] = 3] = "LeftAndRight";
|
|
596
|
+
/** Center-aligned, `alignCenter` drives `position.x`. */ HorizontalAlignmentMode[HorizontalAlignmentMode["Center"] = 4] = "Center";
|
|
597
|
+
return HorizontalAlignmentMode;
|
|
598
|
+
}({});
|
|
599
|
+
|
|
600
|
+
/** Vertical alignment mode. */ var VerticalAlignmentMode = /*#__PURE__*/ function(VerticalAlignmentMode) {
|
|
601
|
+
/** No vertical alignment. */ VerticalAlignmentMode[VerticalAlignmentMode["None"] = 0] = "None";
|
|
602
|
+
/** Top-aligned, `alignTop` drives `position.y`. */ VerticalAlignmentMode[VerticalAlignmentMode["Top"] = 1] = "Top";
|
|
603
|
+
/** Bottom-aligned, `alignBottom` drives `position.y`. */ VerticalAlignmentMode[VerticalAlignmentMode["Bottom"] = 2] = "Bottom";
|
|
604
|
+
/** Vertical stretch, `alignTop` and `alignBottom` drive `position.y` and `size.y`. */ VerticalAlignmentMode[VerticalAlignmentMode["TopAndBottom"] = 3] = "TopAndBottom";
|
|
605
|
+
/** Middle-aligned, `alignMiddle` drives `position.y`. */ VerticalAlignmentMode[VerticalAlignmentMode["Middle"] = 4] = "Middle";
|
|
606
|
+
return VerticalAlignmentMode;
|
|
607
|
+
}({});
|
|
608
|
+
|
|
609
|
+
/**
|
|
610
|
+
* The Transform component exclusive to the UI element.
|
|
611
|
+
*/ var UITransform = /*#__PURE__*/ function(Transform) {
|
|
612
|
+
_inherits(UITransform, Transform);
|
|
613
|
+
function UITransform(entity) {
|
|
614
|
+
var _this;
|
|
615
|
+
_this = Transform.call(this, entity) || this, _this._size = new engine.Vector2(100, 100), _this._pivot = new engine.Vector2(0.5, 0.5), _this._rect = new engine.Rect(-50, -50, 100, 100), _this._alignLeft = 0, _this._alignRight = 0, _this._alignCenter = 0, _this._alignTop = 0, _this._alignBottom = 0, _this._alignMiddle = 0, _this._horizontalAlignment = HorizontalAlignmentMode.None, _this._verticalAlignment = VerticalAlignmentMode.None;
|
|
616
|
+
_this._onSizeChanged = _this._onSizeChanged.bind(_this);
|
|
617
|
+
_this._onPivotChanged = _this._onPivotChanged.bind(_this);
|
|
618
|
+
// @ts-ignore
|
|
619
|
+
_this._size._onValueChanged = _this._onSizeChanged;
|
|
620
|
+
// @ts-ignore
|
|
621
|
+
_this._pivot._onValueChanged = _this._onPivotChanged;
|
|
622
|
+
return _this;
|
|
623
|
+
}
|
|
624
|
+
var _proto = UITransform.prototype;
|
|
625
|
+
/**
|
|
626
|
+
* @internal
|
|
627
|
+
*/ _proto._parentChange = function _parentChange() {
|
|
628
|
+
this._isParentDirty = true;
|
|
629
|
+
this._updateWorldFlagWithParentRectChange(engine.TransformModifyFlags.WmWpWeWqWsWus);
|
|
1580
630
|
};
|
|
1581
631
|
/**
|
|
1582
632
|
* @inheritdoc
|
|
1583
633
|
*/ _proto._onClone = function _onClone(target) {
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
++UICanvas._hierarchyCounter;
|
|
1595
|
-
}
|
|
1596
|
-
return renderers;
|
|
634
|
+
Transform.prototype._onClone.call(this, target);
|
|
635
|
+
var size = target._size, pivot = target._pivot;
|
|
636
|
+
// @ts-ignore
|
|
637
|
+
size._onValueChanged = pivot._onValueChanged = null;
|
|
638
|
+
size.copyFrom(this._size);
|
|
639
|
+
pivot.copyFrom(this._pivot);
|
|
640
|
+
// @ts-ignore
|
|
641
|
+
size._onValueChanged = target._onSizeChanged;
|
|
642
|
+
// @ts-ignore
|
|
643
|
+
pivot._onValueChanged = target._onPivotChanged;
|
|
1597
644
|
};
|
|
1598
|
-
_proto.
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
if (
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
var cameraTransform = cameraEntity.transform;
|
|
1605
|
-
var cameraWorldPosition = cameraTransform.worldPosition, cameraWorldForward = cameraTransform.worldForward;
|
|
1606
|
-
var distance = this._distance;
|
|
1607
|
-
transform.setWorldPosition(cameraWorldPosition.x + cameraWorldForward.x * distance, cameraWorldPosition.y + cameraWorldForward.y * distance, cameraWorldPosition.z + cameraWorldForward.z * distance);
|
|
1608
|
-
transform.worldRotationQuaternion.copyFrom(cameraTransform.worldRotationQuaternion);
|
|
1609
|
-
}
|
|
645
|
+
_proto._onLocalMatrixChanging = function _onLocalMatrixChanging() {
|
|
646
|
+
// `super._onLocalMatrixChanging()` will set `LocalMatrix` dirty flag `false`
|
|
647
|
+
// If there is an alignment, `position` and `localMatrix` will be reset again
|
|
648
|
+
if (this._horizontalAlignment || this._verticalAlignment) {
|
|
649
|
+
this._updatePositionByAlignment();
|
|
650
|
+
this._setDirtyFlagTrue(engine.TransformModifyFlags.LocalMatrix);
|
|
1610
651
|
} else {
|
|
1611
|
-
|
|
1612
|
-
transform.setWorldPosition(canvas.width * 0.5, canvas.height * 0.5, 0);
|
|
1613
|
-
transform.worldRotationQuaternion.set(0, 0, 0, 1);
|
|
652
|
+
Transform.prototype._onLocalMatrixChanging.call(this);
|
|
1614
653
|
}
|
|
1615
654
|
};
|
|
1616
|
-
_proto.
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
var curWidth;
|
|
1621
|
-
var curHeight;
|
|
1622
|
-
if (realRenderMode === CanvasRenderMode.ScreenSpaceCamera) {
|
|
1623
|
-
var camera = this._camera;
|
|
1624
|
-
curHeight = camera.isOrthographic ? camera.orthographicSize * 2 : 2 * (Math.tan(engine.MathUtil.degreeToRadian(camera.fieldOfView * 0.5)) * this._distance);
|
|
1625
|
-
curWidth = camera.aspectRatio * curHeight;
|
|
1626
|
-
} else {
|
|
1627
|
-
var canvas = this.engine.canvas;
|
|
1628
|
-
curHeight = canvas.height;
|
|
1629
|
-
curWidth = canvas.width;
|
|
1630
|
-
}
|
|
1631
|
-
var expectX, expectY, expectZ;
|
|
1632
|
-
switch(this._resolutionAdaptationMode){
|
|
1633
|
-
case ResolutionAdaptationMode.WidthAdaptation:
|
|
1634
|
-
expectX = expectY = expectZ = curWidth / width;
|
|
1635
|
-
break;
|
|
1636
|
-
case ResolutionAdaptationMode.HeightAdaptation:
|
|
1637
|
-
expectX = expectY = expectZ = curHeight / height;
|
|
1638
|
-
break;
|
|
1639
|
-
case ResolutionAdaptationMode.BothAdaptation:
|
|
1640
|
-
expectX = curWidth / width;
|
|
1641
|
-
expectY = curHeight / height;
|
|
1642
|
-
expectZ = (expectX + expectY) * 0.5;
|
|
1643
|
-
break;
|
|
1644
|
-
case ResolutionAdaptationMode.ExpandAdaptation:
|
|
1645
|
-
expectX = expectY = expectZ = Math.min(curWidth / width, curHeight / height);
|
|
1646
|
-
break;
|
|
1647
|
-
case ResolutionAdaptationMode.ShrinkAdaptation:
|
|
1648
|
-
expectX = expectY = expectZ = Math.max(curWidth / width, curHeight / height);
|
|
1649
|
-
break;
|
|
1650
|
-
}
|
|
1651
|
-
var worldMatrix = UICanvas._tempMat;
|
|
1652
|
-
engine.Matrix.affineTransformation(UICanvas._tempVec3.set(expectX, expectY, expectZ), transform.worldRotationQuaternion, transform.worldPosition, worldMatrix);
|
|
1653
|
-
transform.worldMatrix = worldMatrix;
|
|
1654
|
-
transform.size.set(curWidth / expectX, curHeight / expectY);
|
|
655
|
+
_proto._onWorldMatrixChanging = function _onWorldMatrixChanging() {
|
|
656
|
+
// `super._onWorldMatrixChanging()` will set `WorldMatrix` dirty flag `false`
|
|
657
|
+
// If there is an alignment, `position` and `worldMatrix` will be reset again(`worldMatrix` dirty flag is already `true`)
|
|
658
|
+
!this._horizontalAlignment && !this._verticalAlignment && Transform.prototype._onWorldMatrixChanging.call(this);
|
|
1655
659
|
};
|
|
1656
|
-
_proto.
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
if (rectMaskCount === void 0) rectMaskCount = 0;
|
|
1660
|
-
// @ts-ignore
|
|
1661
|
-
var components = entity._components;
|
|
1662
|
-
var tempGroupAbleList = UICanvas._tempGroupAbleList;
|
|
1663
|
-
var tempRectMaskList = UICanvas._tempRectMaskList;
|
|
1664
|
-
var rectMask = null;
|
|
1665
|
-
var groupAbleCount = 0;
|
|
1666
|
-
for(var i = 0, n = components.length; i < n; i++){
|
|
1667
|
-
var component = components[i];
|
|
1668
|
-
if (!component.enabled) continue;
|
|
1669
|
-
if (_instanceof(component, exports.UIRenderer)) {
|
|
1670
|
-
renderers[depth] = component;
|
|
1671
|
-
++depth;
|
|
1672
|
-
component._isRootCanvasDirty && Utils.setRootCanvas(component, this);
|
|
1673
|
-
if (component._isGroupDirty) {
|
|
1674
|
-
tempGroupAbleList[groupAbleCount++] = component;
|
|
1675
|
-
}
|
|
1676
|
-
component._setRectMasks(tempRectMaskList, rectMaskCount);
|
|
1677
|
-
} else if (_instanceof(component, UIInteractive)) {
|
|
1678
|
-
component._isRootCanvasDirty && Utils.setRootCanvas(component, this);
|
|
1679
|
-
if (component._isGroupDirty) {
|
|
1680
|
-
tempGroupAbleList[groupAbleCount++] = component;
|
|
1681
|
-
}
|
|
1682
|
-
} else if (_instanceof(component, exports.RectMask2D)) {
|
|
1683
|
-
rectMask = component;
|
|
1684
|
-
} else if (_instanceof(component, UIGroup)) {
|
|
1685
|
-
component._isRootCanvasDirty && Utils.setRootCanvas(component, this);
|
|
1686
|
-
component._isGroupDirty && Utils.setGroup(component, group);
|
|
1687
|
-
group = component;
|
|
1688
|
-
}
|
|
1689
|
-
}
|
|
1690
|
-
for(var i1 = 0; i1 < groupAbleCount; i1++){
|
|
1691
|
-
Utils.setGroup(tempGroupAbleList[i1], group);
|
|
1692
|
-
}
|
|
1693
|
-
if (rectMask) {
|
|
1694
|
-
tempRectMaskList[rectMaskCount++] = rectMask;
|
|
1695
|
-
}
|
|
1696
|
-
var children = entity.children;
|
|
1697
|
-
for(var i2 = 0, n1 = children.length; i2 < n1; i2++){
|
|
1698
|
-
var child = children[i2];
|
|
1699
|
-
child.isActive && (depth = this._walk(child, renderers, depth, group, rectMaskCount));
|
|
1700
|
-
}
|
|
1701
|
-
return depth;
|
|
660
|
+
_proto._onPositionChanged = function _onPositionChanged() {
|
|
661
|
+
(this._horizontalAlignment || this._verticalAlignment) && this._updatePositionByAlignment();
|
|
662
|
+
Transform.prototype._onPositionChanged.call(this);
|
|
1702
663
|
};
|
|
1703
|
-
_proto.
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
this._cameraObserver = camera;
|
|
1708
|
-
if (preCamera) {
|
|
1709
|
-
// @ts-ignore
|
|
1710
|
-
preCamera.entity._updateFlagManager.removeListener(this._onCameraTransformListener);
|
|
1711
|
-
// @ts-ignore
|
|
1712
|
-
preCamera._unRegisterModifyListener(this._onCameraModifyListener);
|
|
1713
|
-
}
|
|
1714
|
-
if (camera) {
|
|
1715
|
-
// @ts-ignore
|
|
1716
|
-
camera.entity._updateFlagManager.addListener(this._onCameraTransformListener);
|
|
1717
|
-
// @ts-ignore
|
|
1718
|
-
camera._registerModifyListener(this._onCameraModifyListener);
|
|
1719
|
-
}
|
|
664
|
+
_proto._onWorldPositionChanged = function _onWorldPositionChanged() {
|
|
665
|
+
Transform.prototype._onWorldPositionChanged.call(this);
|
|
666
|
+
if (this._horizontalAlignment || this._verticalAlignment) {
|
|
667
|
+
this._setDirtyFlagTrue(engine.TransformModifyFlags.WorldPosition);
|
|
1720
668
|
}
|
|
1721
669
|
};
|
|
1722
|
-
_proto.
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
670
|
+
_proto._updatePositionByAlignment = function _updatePositionByAlignment() {
|
|
671
|
+
var _this__getParentTransform;
|
|
672
|
+
var parentRect = (_this__getParentTransform = this._getParentTransform()) == null ? void 0 : _this__getParentTransform._rect;
|
|
673
|
+
if (parentRect) {
|
|
674
|
+
var position = this.position;
|
|
675
|
+
// @ts-ignore
|
|
676
|
+
position._onValueChanged = null;
|
|
677
|
+
var rect = this._rect;
|
|
678
|
+
switch(this._horizontalAlignment){
|
|
679
|
+
case HorizontalAlignmentMode.Left:
|
|
680
|
+
case HorizontalAlignmentMode.LeftAndRight:
|
|
681
|
+
position.x = parentRect.x - rect.x + this._alignLeft;
|
|
1728
682
|
break;
|
|
1729
|
-
case
|
|
1730
|
-
|
|
683
|
+
case HorizontalAlignmentMode.Center:
|
|
684
|
+
position.x = parentRect.x + parentRect.width * 0.5 - rect.x - rect.width * 0.5 + this._alignCenter;
|
|
1731
685
|
break;
|
|
1732
|
-
case
|
|
1733
|
-
|
|
686
|
+
case HorizontalAlignmentMode.Right:
|
|
687
|
+
position.x = parentRect.x + parentRect.width - rect.x - rect.width - this._alignRight;
|
|
1734
688
|
break;
|
|
1735
|
-
|
|
1736
|
-
|
|
689
|
+
}
|
|
690
|
+
switch(this._verticalAlignment){
|
|
691
|
+
case VerticalAlignmentMode.Top:
|
|
692
|
+
position.y = parentRect.y + parentRect.height - rect.y - rect.height - this._alignTop;
|
|
693
|
+
break;
|
|
694
|
+
case VerticalAlignmentMode.Middle:
|
|
695
|
+
position.y = parentRect.y + parentRect.height * 0.5 - rect.y - rect.height * 0.5 + this._alignMiddle;
|
|
696
|
+
break;
|
|
697
|
+
case VerticalAlignmentMode.Bottom:
|
|
698
|
+
case VerticalAlignmentMode.TopAndBottom:
|
|
699
|
+
position.y = parentRect.y - rect.y + this._alignBottom;
|
|
1737
700
|
break;
|
|
1738
701
|
}
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
}
|
|
1742
|
-
};
|
|
1743
|
-
_proto._onCameraTransformListener = function _onCameraTransformListener() {
|
|
1744
|
-
this._realRenderMode === CanvasRenderMode.ScreenSpaceCamera && this._adapterPoseInScreenSpace();
|
|
1745
|
-
};
|
|
1746
|
-
_proto._addCanvasListener = function _addCanvasListener() {
|
|
1747
|
-
// @ts-ignore
|
|
1748
|
-
this.engine.canvas._sizeUpdateFlagManager.addListener(this._onCanvasSizeListener);
|
|
1749
|
-
};
|
|
1750
|
-
_proto._removeCanvasListener = function _removeCanvasListener() {
|
|
1751
|
-
// @ts-ignore
|
|
1752
|
-
this.engine.canvas._sizeUpdateFlagManager.removeListener(this._onCanvasSizeListener);
|
|
1753
|
-
};
|
|
1754
|
-
_proto._onCanvasSizeListener = function _onCanvasSizeListener() {
|
|
1755
|
-
var canvas = this.engine.canvas;
|
|
1756
|
-
this.entity.transform.setWorldPosition(canvas.width * 0.5, canvas.height * 0.5, 0);
|
|
1757
|
-
this._adapterSizeInScreenSpace();
|
|
1758
|
-
};
|
|
1759
|
-
_proto._onReferenceResolutionChanged = function _onReferenceResolutionChanged() {
|
|
1760
|
-
var realRenderMode = this._realRenderMode;
|
|
1761
|
-
if (realRenderMode === CanvasRenderMode.ScreenSpaceOverlay || realRenderMode === CanvasRenderMode.ScreenSpaceCamera) {
|
|
1762
|
-
this._adapterSizeInScreenSpace();
|
|
702
|
+
// @ts-ignore
|
|
703
|
+
position._onValueChanged = this._onPositionChanged;
|
|
1763
704
|
}
|
|
1764
705
|
};
|
|
1765
|
-
_proto.
|
|
1766
|
-
var
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
this.
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
disorderedElements.forEach(function(element) {
|
|
1776
|
-
if (_instanceof(element, UICanvas)) {
|
|
1777
|
-
var rootCanvas = Utils.searchRootCanvasInParents(element);
|
|
1778
|
-
element._setIsRootCanvas(!rootCanvas);
|
|
1779
|
-
Utils.setRootCanvas(element, rootCanvas);
|
|
1780
|
-
} else {
|
|
1781
|
-
Utils.setRootCanvasDirty(_this);
|
|
1782
|
-
Utils.setGroupDirty(element);
|
|
1783
|
-
}
|
|
1784
|
-
});
|
|
1785
|
-
disorderedElements.length = 0;
|
|
1786
|
-
disorderedElements.garbageCollection();
|
|
1787
|
-
this._orderedRenderers.length = 0;
|
|
706
|
+
_proto._updateSizeByAlignment = function _updateSizeByAlignment() {
|
|
707
|
+
var _this__getParentTransform;
|
|
708
|
+
var parentRect = (_this__getParentTransform = this._getParentTransform()) == null ? void 0 : _this__getParentTransform._rect;
|
|
709
|
+
if (parentRect) {
|
|
710
|
+
var size = this._size;
|
|
711
|
+
// @ts-ignore
|
|
712
|
+
size._onValueChanged = null;
|
|
713
|
+
// The values of size must be greater than 0
|
|
714
|
+
if (this._horizontalAlignment === HorizontalAlignmentMode.LeftAndRight) {
|
|
715
|
+
size.x = Math.max(parentRect.width - this._alignLeft - this._alignRight, 0);
|
|
1788
716
|
}
|
|
717
|
+
if (this._verticalAlignment === VerticalAlignmentMode.TopAndBottom) {
|
|
718
|
+
size.y = Math.max(parentRect.height - this._alignTop - this._alignBottom, 0);
|
|
719
|
+
}
|
|
720
|
+
// @ts-ignore
|
|
721
|
+
size._onValueChanged = this._onSizeChanged;
|
|
1789
722
|
}
|
|
1790
723
|
};
|
|
1791
|
-
_proto.
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
724
|
+
_proto._updateRectBySizeAndPivot = function _updateRectBySizeAndPivot() {
|
|
725
|
+
var _this = this, size = _this.size, pivot = _this._pivot;
|
|
726
|
+
var x = -pivot.x * size.x;
|
|
727
|
+
var y = -pivot.y * size.y;
|
|
728
|
+
this._rect.set(x, y, size.x, size.y);
|
|
729
|
+
};
|
|
730
|
+
_proto._onSizeChanged = function _onSizeChanged() {
|
|
731
|
+
if (this._horizontalAlignment === HorizontalAlignmentMode.LeftAndRight || this._verticalAlignment === VerticalAlignmentMode.TopAndBottom) {
|
|
732
|
+
this._updateSizeByAlignment();
|
|
1799
733
|
}
|
|
1800
|
-
|
|
734
|
+
this._updateRectBySizeAndPivot();
|
|
735
|
+
this._updateWorldFlagWithSelfRectChange();
|
|
736
|
+
// @ts-ignore
|
|
737
|
+
this._entity._updateFlagManager.dispatch(512);
|
|
1801
738
|
};
|
|
1802
|
-
_proto.
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
739
|
+
_proto._onPivotChanged = function _onPivotChanged() {
|
|
740
|
+
this._updateRectBySizeAndPivot();
|
|
741
|
+
this._updateWorldFlagWithSelfRectChange();
|
|
742
|
+
// @ts-ignore
|
|
743
|
+
this._entity._updateFlagManager.dispatch(1024);
|
|
744
|
+
};
|
|
745
|
+
_proto._updateWorldFlagWithSelfRectChange = function _updateWorldFlagWithSelfRectChange() {
|
|
746
|
+
var worldFlags = 0;
|
|
747
|
+
if (this._horizontalAlignment || this._verticalAlignment) {
|
|
748
|
+
this._updatePositionByAlignment();
|
|
749
|
+
this._setDirtyFlagTrue(engine.TransformModifyFlags.LocalMatrix);
|
|
750
|
+
worldFlags = engine.TransformModifyFlags.WmWp;
|
|
751
|
+
!this._isContainDirtyFlags(worldFlags) && this._worldAssociatedChange(worldFlags);
|
|
752
|
+
}
|
|
753
|
+
var children = this.entity.children;
|
|
754
|
+
for(var i = 0, n = children.length; i < n; i++){
|
|
755
|
+
var _children_i_transform__updateWorldFlagWithParentRectChange, _children_i_transform;
|
|
756
|
+
(_children_i_transform = children[i].transform) == null ? void 0 : (_children_i_transform__updateWorldFlagWithParentRectChange = _children_i_transform._updateWorldFlagWithParentRectChange) == null ? void 0 : _children_i_transform__updateWorldFlagWithParentRectChange.call(_children_i_transform, worldFlags);
|
|
1814
757
|
}
|
|
1815
758
|
};
|
|
1816
|
-
_proto.
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
this.
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
switch(curRealMode){
|
|
1831
|
-
case CanvasRenderMode.ScreenSpaceOverlay:
|
|
1832
|
-
this._addCanvasListener();
|
|
1833
|
-
case CanvasRenderMode.ScreenSpaceCamera:
|
|
1834
|
-
this._adapterPoseInScreenSpace();
|
|
1835
|
-
this._adapterSizeInScreenSpace();
|
|
1836
|
-
case CanvasRenderMode.WorldSpace:
|
|
1837
|
-
componentsManager.addUICanvas(this, curRealMode === CanvasRenderMode.ScreenSpaceOverlay);
|
|
1838
|
-
break;
|
|
759
|
+
_proto._updateWorldFlagWithParentRectChange = function _updateWorldFlagWithParentRectChange(flags, parentChange) {
|
|
760
|
+
if (parentChange === void 0) parentChange = true;
|
|
761
|
+
var selfChange = false;
|
|
762
|
+
if (parentChange) {
|
|
763
|
+
var _this = this, horizontalAlignment = _this._horizontalAlignment, verticalAlignment = _this._verticalAlignment;
|
|
764
|
+
if (horizontalAlignment || verticalAlignment) {
|
|
765
|
+
if (horizontalAlignment === HorizontalAlignmentMode.LeftAndRight || verticalAlignment === VerticalAlignmentMode.TopAndBottom) {
|
|
766
|
+
this._updateSizeByAlignment();
|
|
767
|
+
this._updateRectBySizeAndPivot();
|
|
768
|
+
selfChange = true;
|
|
769
|
+
}
|
|
770
|
+
this._updatePositionByAlignment();
|
|
771
|
+
this._setDirtyFlagTrue(engine.TransformModifyFlags.LocalMatrix);
|
|
772
|
+
flags |= engine.TransformModifyFlags.WmWp;
|
|
1839
773
|
}
|
|
1840
774
|
}
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
775
|
+
var containDirtyFlags = this._isContainDirtyFlags(flags);
|
|
776
|
+
!containDirtyFlags && this._worldAssociatedChange(flags);
|
|
777
|
+
if (selfChange || !containDirtyFlags) {
|
|
778
|
+
var children = this.entity.children;
|
|
779
|
+
for(var i = 0, n = children.length; i < n; i++){
|
|
780
|
+
var _children_i_transform__updateWorldFlagWithParentRectChange, _children_i_transform;
|
|
781
|
+
(_children_i_transform = children[i].transform) == null ? void 0 : (_children_i_transform__updateWorldFlagWithParentRectChange = _children_i_transform._updateWorldFlagWithParentRectChange) == null ? void 0 : _children_i_transform__updateWorldFlagWithParentRectChange.call(_children_i_transform, flags, selfChange);
|
|
782
|
+
}
|
|
1847
783
|
}
|
|
1848
|
-
|
|
784
|
+
// @ts-ignore
|
|
785
|
+
selfChange && this._entity._updateFlagManager.dispatch(512);
|
|
1849
786
|
};
|
|
1850
|
-
_create_class(
|
|
787
|
+
_create_class(UITransform, [
|
|
1851
788
|
{
|
|
1852
|
-
key: "
|
|
789
|
+
key: "size",
|
|
1853
790
|
get: /**
|
|
1854
|
-
*
|
|
791
|
+
* Width and height of UI element.
|
|
1855
792
|
*/ function get() {
|
|
1856
|
-
return this.
|
|
793
|
+
return this._size;
|
|
1857
794
|
},
|
|
1858
795
|
set: function set(value) {
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
796
|
+
var _this = this, size = _this._size;
|
|
797
|
+
if (size === value) return;
|
|
798
|
+
(size.x !== value.x || size.y !== value.y) && size.copyFrom(value);
|
|
799
|
+
}
|
|
800
|
+
},
|
|
801
|
+
{
|
|
802
|
+
key: "pivot",
|
|
803
|
+
get: /**
|
|
804
|
+
* Pivot of UI element.
|
|
805
|
+
*/ function get() {
|
|
806
|
+
return this._pivot;
|
|
807
|
+
},
|
|
808
|
+
set: function set(value) {
|
|
809
|
+
var _this = this, pivot = _this._pivot;
|
|
810
|
+
if (pivot === value) return;
|
|
811
|
+
(pivot.x !== value.x || pivot.y !== value.y) && pivot.copyFrom(value);
|
|
812
|
+
}
|
|
813
|
+
},
|
|
814
|
+
{
|
|
815
|
+
key: "horizontalAlignment",
|
|
816
|
+
get: /**
|
|
817
|
+
* Horizontal alignment mode.
|
|
818
|
+
*
|
|
819
|
+
* @remarks
|
|
820
|
+
* Controls how the element aligns horizontally within its parent:
|
|
821
|
+
* - `Left` - Align to parent's left edge
|
|
822
|
+
* - `Center` - Align to parent's horizontal center
|
|
823
|
+
* - `Right` - Align to parent's right edge
|
|
824
|
+
* - `LeftAndRight` - Align to both left and right edges (stretch to fill width)
|
|
825
|
+
*/ function get() {
|
|
826
|
+
return this._horizontalAlignment;
|
|
827
|
+
},
|
|
828
|
+
set: function set(value) {
|
|
829
|
+
if (this._horizontalAlignment === value) return;
|
|
830
|
+
this._horizontalAlignment = value;
|
|
831
|
+
switch(value){
|
|
832
|
+
case HorizontalAlignmentMode.Left:
|
|
833
|
+
case HorizontalAlignmentMode.Right:
|
|
834
|
+
case HorizontalAlignmentMode.Center:
|
|
835
|
+
this._onPositionChanged();
|
|
836
|
+
break;
|
|
837
|
+
case HorizontalAlignmentMode.LeftAndRight:
|
|
838
|
+
this._onPositionChanged();
|
|
839
|
+
this._onSizeChanged();
|
|
840
|
+
break;
|
|
1864
841
|
}
|
|
1865
842
|
}
|
|
1866
843
|
},
|
|
1867
844
|
{
|
|
1868
|
-
key: "
|
|
845
|
+
key: "alignLeft",
|
|
1869
846
|
get: /**
|
|
1870
|
-
*
|
|
847
|
+
* Left margin when horizontalAlignment is Left or LeftAndRight.
|
|
848
|
+
*
|
|
849
|
+
* @remarks
|
|
850
|
+
* Only effective when horizontalAlignment includes Left mode.
|
|
851
|
+
* Distance from the parent's left edge to the element's left edge.
|
|
1871
852
|
*/ function get() {
|
|
1872
|
-
return this.
|
|
853
|
+
return this._alignLeft;
|
|
1873
854
|
},
|
|
1874
855
|
set: function set(value) {
|
|
1875
|
-
|
|
1876
|
-
if (
|
|
1877
|
-
|
|
856
|
+
if (!Number.isFinite(value)) return;
|
|
857
|
+
if (engine.MathUtil.equals(value, this._alignLeft)) return;
|
|
858
|
+
this._alignLeft = value;
|
|
859
|
+
if (this._horizontalAlignment & HorizontalAlignmentMode.Left) {
|
|
860
|
+
this._onPositionChanged();
|
|
861
|
+
this._horizontalAlignment & HorizontalAlignmentMode.Right && this._onSizeChanged();
|
|
862
|
+
}
|
|
1878
863
|
}
|
|
1879
864
|
},
|
|
1880
865
|
{
|
|
1881
|
-
key: "
|
|
866
|
+
key: "alignRight",
|
|
1882
867
|
get: /**
|
|
1883
|
-
*
|
|
868
|
+
* Right margin when horizontalAlignment is Right or LeftAndRight.
|
|
869
|
+
*
|
|
870
|
+
* @remarks
|
|
871
|
+
* Only effective when horizontalAlignment includes Right mode.
|
|
872
|
+
* Distance from the parent's right edge to the element's right edge.
|
|
1884
873
|
*/ function get() {
|
|
1885
|
-
return this.
|
|
874
|
+
return this._alignRight;
|
|
1886
875
|
},
|
|
1887
|
-
set: function set(
|
|
1888
|
-
|
|
1889
|
-
if (
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
this.
|
|
876
|
+
set: function set(value) {
|
|
877
|
+
if (!Number.isFinite(value)) return;
|
|
878
|
+
if (engine.MathUtil.equals(value, this._alignRight)) return;
|
|
879
|
+
this._alignRight = value;
|
|
880
|
+
if (this._horizontalAlignment & HorizontalAlignmentMode.Right) {
|
|
881
|
+
this._onPositionChanged();
|
|
882
|
+
this._horizontalAlignment & HorizontalAlignmentMode.Left && this._onSizeChanged();
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
},
|
|
886
|
+
{
|
|
887
|
+
key: "alignCenter",
|
|
888
|
+
get: /**
|
|
889
|
+
* Horizontal center offset when horizontalAlignment is Center.
|
|
890
|
+
*
|
|
891
|
+
* @remarks
|
|
892
|
+
* Only effective when horizontalAlignment is Center mode.
|
|
893
|
+
* Positive values move the element to the right, negative values to the left.
|
|
894
|
+
*/ function get() {
|
|
895
|
+
return this._alignCenter;
|
|
896
|
+
},
|
|
897
|
+
set: function set(value) {
|
|
898
|
+
if (!Number.isFinite(value)) return;
|
|
899
|
+
if (engine.MathUtil.equals(value, this._alignCenter)) return;
|
|
900
|
+
this._alignCenter = value;
|
|
901
|
+
this._horizontalAlignment & HorizontalAlignmentMode.Center && this._onPositionChanged();
|
|
902
|
+
}
|
|
903
|
+
},
|
|
904
|
+
{
|
|
905
|
+
key: "verticalAlignment",
|
|
906
|
+
get: /**
|
|
907
|
+
* Vertical alignment mode.
|
|
908
|
+
*
|
|
909
|
+
* @remarks
|
|
910
|
+
* Controls how the element aligns vertically within its parent:
|
|
911
|
+
* - `Top` - Align to parent's top edge
|
|
912
|
+
* - `Middle` - Align to parent's vertical center
|
|
913
|
+
* - `Bottom` - Align to parent's bottom edge
|
|
914
|
+
* - `TopAndBottom` - Align to both top and bottom edges (stretch to fill height)
|
|
915
|
+
*/ function get() {
|
|
916
|
+
return this._verticalAlignment;
|
|
917
|
+
},
|
|
918
|
+
set: function set(value) {
|
|
919
|
+
if (this._verticalAlignment === value) return;
|
|
920
|
+
this._verticalAlignment = value;
|
|
921
|
+
switch(value){
|
|
922
|
+
case VerticalAlignmentMode.Top:
|
|
923
|
+
case VerticalAlignmentMode.Bottom:
|
|
924
|
+
case VerticalAlignmentMode.Middle:
|
|
925
|
+
this._onPositionChanged();
|
|
926
|
+
break;
|
|
927
|
+
case VerticalAlignmentMode.TopAndBottom:
|
|
928
|
+
this._onPositionChanged();
|
|
929
|
+
this._onSizeChanged();
|
|
930
|
+
break;
|
|
1893
931
|
}
|
|
1894
932
|
}
|
|
1895
933
|
},
|
|
1896
934
|
{
|
|
1897
|
-
key: "
|
|
935
|
+
key: "alignTop",
|
|
1898
936
|
get: /**
|
|
1899
|
-
*
|
|
937
|
+
* Top margin when verticalAlignment is Top or TopAndBottom.
|
|
938
|
+
*
|
|
1900
939
|
* @remarks
|
|
1901
|
-
*
|
|
1902
|
-
*
|
|
940
|
+
* Only effective when verticalAlignment includes Top mode.
|
|
941
|
+
* Used to offset the element from the parent's top edge.
|
|
1903
942
|
*/ function get() {
|
|
1904
|
-
return this.
|
|
943
|
+
return this._alignTop;
|
|
1905
944
|
},
|
|
1906
945
|
set: function set(value) {
|
|
1907
|
-
|
|
1908
|
-
if (
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
this.
|
|
1913
|
-
this._updateCameraObserver();
|
|
1914
|
-
var preRenderMode = this._realRenderMode;
|
|
1915
|
-
var curRenderMode = this._getRealRenderMode();
|
|
1916
|
-
if (preRenderMode === curRenderMode) {
|
|
1917
|
-
if (curRenderMode === CanvasRenderMode.ScreenSpaceCamera) {
|
|
1918
|
-
this._adapterPoseInScreenSpace();
|
|
1919
|
-
this._adapterSizeInScreenSpace();
|
|
1920
|
-
}
|
|
1921
|
-
} else {
|
|
1922
|
-
this._setRealRenderMode(curRenderMode);
|
|
1923
|
-
}
|
|
946
|
+
if (!Number.isFinite(value)) return;
|
|
947
|
+
if (engine.MathUtil.equals(value, this._alignTop)) return;
|
|
948
|
+
this._alignTop = value;
|
|
949
|
+
if (this._verticalAlignment & VerticalAlignmentMode.Top) {
|
|
950
|
+
this._onPositionChanged();
|
|
951
|
+
this._verticalAlignment & VerticalAlignmentMode.Bottom && this._onSizeChanged();
|
|
1924
952
|
}
|
|
1925
953
|
}
|
|
1926
954
|
},
|
|
1927
955
|
{
|
|
1928
|
-
key: "
|
|
956
|
+
key: "alignBottom",
|
|
1929
957
|
get: /**
|
|
1930
|
-
*
|
|
958
|
+
* Bottom inset used in vertical alignment formulas.
|
|
1931
959
|
*/ function get() {
|
|
1932
|
-
return this.
|
|
960
|
+
return this._alignBottom;
|
|
1933
961
|
},
|
|
1934
962
|
set: function set(value) {
|
|
1935
|
-
|
|
963
|
+
if (!Number.isFinite(value)) return;
|
|
964
|
+
if (engine.MathUtil.equals(value, this._alignBottom)) return;
|
|
965
|
+
this._alignBottom = value;
|
|
966
|
+
if (this._verticalAlignment & VerticalAlignmentMode.Bottom) {
|
|
967
|
+
this._onPositionChanged();
|
|
968
|
+
this._verticalAlignment & VerticalAlignmentMode.Top && this._onSizeChanged();
|
|
969
|
+
}
|
|
1936
970
|
}
|
|
1937
971
|
},
|
|
1938
972
|
{
|
|
1939
|
-
key: "
|
|
973
|
+
key: "alignMiddle",
|
|
1940
974
|
get: /**
|
|
1941
|
-
*
|
|
975
|
+
* Vertical middle offset relative to parent's middle.
|
|
1942
976
|
*/ function get() {
|
|
1943
|
-
return this.
|
|
977
|
+
return this._alignMiddle;
|
|
1944
978
|
},
|
|
1945
979
|
set: function set(value) {
|
|
1946
|
-
if (
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
this._adapterSizeInScreenSpace();
|
|
1951
|
-
}
|
|
1952
|
-
}
|
|
980
|
+
if (!Number.isFinite(value)) return;
|
|
981
|
+
if (engine.MathUtil.equals(value, this._alignMiddle)) return;
|
|
982
|
+
this._alignMiddle = value;
|
|
983
|
+
this._verticalAlignment & VerticalAlignmentMode.Middle && this._onPositionChanged();
|
|
1953
984
|
}
|
|
1954
|
-
}
|
|
985
|
+
}
|
|
986
|
+
]);
|
|
987
|
+
return UITransform;
|
|
988
|
+
}(engine.Transform);
|
|
989
|
+
__decorate([
|
|
990
|
+
engine.ignoreClone
|
|
991
|
+
], UITransform.prototype, "_size", void 0);
|
|
992
|
+
__decorate([
|
|
993
|
+
engine.ignoreClone
|
|
994
|
+
], UITransform.prototype, "_pivot", void 0);
|
|
995
|
+
__decorate([
|
|
996
|
+
engine.ignoreClone
|
|
997
|
+
], UITransform.prototype, "_onPositionChanged", null);
|
|
998
|
+
__decorate([
|
|
999
|
+
engine.ignoreClone
|
|
1000
|
+
], UITransform.prototype, "_onWorldPositionChanged", null);
|
|
1001
|
+
__decorate([
|
|
1002
|
+
engine.ignoreClone
|
|
1003
|
+
], UITransform.prototype, "_onSizeChanged", null);
|
|
1004
|
+
__decorate([
|
|
1005
|
+
engine.ignoreClone
|
|
1006
|
+
], UITransform.prototype, "_onPivotChanged", null);
|
|
1007
|
+
/**
|
|
1008
|
+
* @internal
|
|
1009
|
+
* extends TransformModifyFlags
|
|
1010
|
+
*/ var UITransformModifyFlags = /*#__PURE__*/ function(UITransformModifyFlags) {
|
|
1011
|
+
UITransformModifyFlags[UITransformModifyFlags["Size"] = 512] = "Size";
|
|
1012
|
+
UITransformModifyFlags[UITransformModifyFlags["Pivot"] = 1024] = "Pivot";
|
|
1013
|
+
return UITransformModifyFlags;
|
|
1014
|
+
}({});
|
|
1015
|
+
|
|
1016
|
+
exports.UIRenderer = /*#__PURE__*/ function(Renderer) {
|
|
1017
|
+
_inherits(UIRenderer, Renderer);
|
|
1018
|
+
function UIRenderer(entity) {
|
|
1019
|
+
var _this;
|
|
1020
|
+
_this = Renderer.call(this, entity) || this, /**
|
|
1021
|
+
* Custom boundary for raycast detection.
|
|
1022
|
+
* @remarks this is based on `this.entity.transform`.
|
|
1023
|
+
*/ _this.raycastPadding = new engine.Vector4(0, 0, 0, 0), /** @internal */ _this._indexInRootCanvas = -1, /** @internal */ _this._isRootCanvasDirty = false, /** @internal */ _this._rootCanvasListeningEntities = [], /** @internal */ _this._indexInGroup = -1, /** @internal */ _this._isGroupDirty = false, /** @internal */ _this._groupListeningEntities = [], _this._raycastEnabled = true, _this._color = new engine.Color(1, 1, 1, 1);
|
|
1024
|
+
_this._dirtyUpdateFlag = engine.RendererUpdateFlags.WorldVolume | 2;
|
|
1025
|
+
_this._onColorChanged = _this._onColorChanged.bind(_this);
|
|
1026
|
+
//@ts-ignore
|
|
1027
|
+
_this._color._onValueChanged = _this._onColorChanged;
|
|
1028
|
+
_this._groupListener = _this._groupListener.bind(_this);
|
|
1029
|
+
_this._rootCanvasListener = _this._rootCanvasListener.bind(_this);
|
|
1030
|
+
return _this;
|
|
1031
|
+
}
|
|
1032
|
+
var _proto = UIRenderer.prototype;
|
|
1033
|
+
// @ts-ignore
|
|
1034
|
+
_proto._canBatch = function _canBatch(preElement, curElement) {
|
|
1035
|
+
return engine.VertexMergeBatcher.canBatchSprite(preElement, curElement);
|
|
1036
|
+
};
|
|
1037
|
+
// @ts-ignore
|
|
1038
|
+
_proto._batch = function _batch(preElement, curElement) {
|
|
1039
|
+
engine.VertexMergeBatcher.batch(preElement, curElement);
|
|
1040
|
+
};
|
|
1041
|
+
// @ts-ignore
|
|
1042
|
+
_proto._updateTransformShaderData = function _updateTransformShaderData(context, onlyMVP) {
|
|
1043
|
+
// @ts-ignore
|
|
1044
|
+
this._updateWorldSpaceTransformShaderData(context, onlyMVP);
|
|
1045
|
+
};
|
|
1046
|
+
// @ts-ignore
|
|
1047
|
+
_proto._prepareRender = function _prepareRender(context) {
|
|
1048
|
+
// Update once per frame per renderer, not influenced by batched
|
|
1049
|
+
if (this._renderFrameCount !== this.engine.time.frameCount) {
|
|
1050
|
+
this._update(context);
|
|
1051
|
+
}
|
|
1052
|
+
this._render(context);
|
|
1053
|
+
// union camera global macro and renderer macro.
|
|
1054
|
+
engine.ShaderMacroCollection.unionCollection(context.camera._globalShaderMacro, // @ts-ignore
|
|
1055
|
+
this.shaderData._macroCollection, //@ts-ignore
|
|
1056
|
+
this._globalShaderMacro);
|
|
1057
|
+
};
|
|
1058
|
+
// @ts-ignore
|
|
1059
|
+
_proto._onEnableInScene = function _onEnableInScene() {
|
|
1060
|
+
// @ts-ignore
|
|
1061
|
+
this._overrideUpdate && this.scene._componentsManager.addOnUpdateRenderers(this);
|
|
1062
|
+
this.entity._updateUIHierarchyVersion(exports.UICanvas._hierarchyCounter);
|
|
1063
|
+
Utils.setRootCanvasDirty(this);
|
|
1064
|
+
Utils.setGroupDirty(this);
|
|
1065
|
+
};
|
|
1066
|
+
// @ts-ignore
|
|
1067
|
+
_proto._onDisableInScene = function _onDisableInScene() {
|
|
1068
|
+
// @ts-ignore
|
|
1069
|
+
this._overrideUpdate && this.scene._componentsManager.removeOnUpdateRenderers(this);
|
|
1070
|
+
this.entity._updateUIHierarchyVersion(exports.UICanvas._hierarchyCounter);
|
|
1071
|
+
Utils.cleanRootCanvas(this);
|
|
1072
|
+
Utils.cleanGroup(this);
|
|
1073
|
+
};
|
|
1074
|
+
/**
|
|
1075
|
+
* @internal
|
|
1076
|
+
*/ _proto._getGlobalAlpha = function _getGlobalAlpha() {
|
|
1077
|
+
var _this__getGroup;
|
|
1078
|
+
var _this__getGroup__getGlobalAlpha;
|
|
1079
|
+
return (_this__getGroup__getGlobalAlpha = (_this__getGroup = this._getGroup()) == null ? void 0 : _this__getGroup._getGlobalAlpha()) != null ? _this__getGroup__getGlobalAlpha : 1;
|
|
1080
|
+
};
|
|
1081
|
+
/**
|
|
1082
|
+
* @internal
|
|
1083
|
+
*/ _proto._getRootCanvas = function _getRootCanvas() {
|
|
1084
|
+
this._isRootCanvasDirty && Utils.setRootCanvas(this, Utils.searchRootCanvasInParents(this));
|
|
1085
|
+
return this._rootCanvas;
|
|
1086
|
+
};
|
|
1087
|
+
/**
|
|
1088
|
+
* @internal
|
|
1089
|
+
*/ _proto._getGroup = function _getGroup() {
|
|
1090
|
+
this._isGroupDirty && Utils.setGroup(this, Utils.searchGroupInParents(this));
|
|
1091
|
+
return this._group;
|
|
1092
|
+
};
|
|
1093
|
+
/**
|
|
1094
|
+
* @internal
|
|
1095
|
+
*/ _proto._groupListener = function _groupListener(flag) {
|
|
1096
|
+
if (flag === engine.EntityModifyFlags.Parent || flag === EntityUIModifyFlags.GroupEnableInScene) {
|
|
1097
|
+
Utils.setGroupDirty(this);
|
|
1098
|
+
}
|
|
1099
|
+
};
|
|
1100
|
+
/**
|
|
1101
|
+
* @internal
|
|
1102
|
+
*/ _proto._rootCanvasListener = function _rootCanvasListener(flag, entity) {
|
|
1103
|
+
switch(flag){
|
|
1104
|
+
case engine.EntityModifyFlags.Parent:
|
|
1105
|
+
Utils.setRootCanvasDirty(this);
|
|
1106
|
+
Utils.setGroupDirty(this);
|
|
1107
|
+
case engine.EntityModifyFlags.Child:
|
|
1108
|
+
entity._updateUIHierarchyVersion(exports.UICanvas._hierarchyCounter);
|
|
1109
|
+
break;
|
|
1110
|
+
}
|
|
1111
|
+
};
|
|
1112
|
+
/**
|
|
1113
|
+
* @internal
|
|
1114
|
+
*/ _proto._onGroupModify = function _onGroupModify(flags) {
|
|
1115
|
+
if (flags & GroupModifyFlags.GlobalAlpha) {
|
|
1116
|
+
this._dirtyUpdateFlag |= 2;
|
|
1117
|
+
}
|
|
1118
|
+
};
|
|
1119
|
+
_proto._onColorChanged = function _onColorChanged() {
|
|
1120
|
+
this._dirtyUpdateFlag |= 2;
|
|
1121
|
+
};
|
|
1122
|
+
/**
|
|
1123
|
+
* @internal
|
|
1124
|
+
*/ _proto._getChunkManager = function _getChunkManager() {
|
|
1125
|
+
// @ts-ignore
|
|
1126
|
+
return this.engine._batcherManager.primitiveChunkManagerUI;
|
|
1127
|
+
};
|
|
1128
|
+
/**
|
|
1129
|
+
* @internal
|
|
1130
|
+
*/ _proto._raycast = function _raycast(ray, out, distance) {
|
|
1131
|
+
if (distance === void 0) distance = Number.MAX_SAFE_INTEGER;
|
|
1132
|
+
var plane = UIRenderer._tempPlane;
|
|
1133
|
+
var transform = this._transformEntity.transform;
|
|
1134
|
+
var normal = plane.normal.copyFrom(transform.worldForward);
|
|
1135
|
+
plane.distance = -engine.Vector3.dot(normal, transform.worldPosition);
|
|
1136
|
+
var curDistance = ray.intersectPlane(plane);
|
|
1137
|
+
if (curDistance >= 0 && curDistance < distance) {
|
|
1138
|
+
var hitPointWorld = ray.getPoint(curDistance, UIRenderer._tempVec30);
|
|
1139
|
+
var worldMatrixInv = UIRenderer._tempMat;
|
|
1140
|
+
engine.Matrix.invert(transform.worldMatrix, worldMatrixInv);
|
|
1141
|
+
var localPosition = UIRenderer._tempVec31;
|
|
1142
|
+
engine.Vector3.transformCoordinate(hitPointWorld, worldMatrixInv, localPosition);
|
|
1143
|
+
if (this._hitTest(localPosition)) {
|
|
1144
|
+
out.component = this;
|
|
1145
|
+
out.distance = curDistance;
|
|
1146
|
+
out.entity = this.entity;
|
|
1147
|
+
out.normal.copyFrom(normal);
|
|
1148
|
+
out.point.copyFrom(hitPointWorld);
|
|
1149
|
+
return true;
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
return false;
|
|
1153
|
+
};
|
|
1154
|
+
_proto._hitTest = function _hitTest(localPosition) {
|
|
1155
|
+
var x = localPosition.x, y = localPosition.y;
|
|
1156
|
+
var uiTransform = this._transformEntity.transform;
|
|
1157
|
+
var _uiTransform_size = uiTransform.size, width = _uiTransform_size.x, height = _uiTransform_size.y;
|
|
1158
|
+
var _uiTransform_pivot = uiTransform.pivot, pivotX = _uiTransform_pivot.x, pivotY = _uiTransform_pivot.y;
|
|
1159
|
+
var _this_raycastPadding = this.raycastPadding, paddingLeft = _this_raycastPadding.x, paddingBottom = _this_raycastPadding.y, paddingRight = _this_raycastPadding.z, paddingTop = _this_raycastPadding.w;
|
|
1160
|
+
return x >= -width * pivotX + paddingLeft && x <= width * (1 - pivotX) - paddingRight && y >= -height * pivotY + paddingTop && y <= height * (1 - pivotY) - paddingBottom;
|
|
1161
|
+
};
|
|
1162
|
+
_proto._onDestroy = function _onDestroy() {
|
|
1163
|
+
if (this._subChunk) {
|
|
1164
|
+
this._getChunkManager().freeSubChunk(this._subChunk);
|
|
1165
|
+
this._subChunk = null;
|
|
1166
|
+
}
|
|
1167
|
+
Renderer.prototype._onDestroy.call(this);
|
|
1168
|
+
//@ts-ignore
|
|
1169
|
+
this._color._onValueChanged = null;
|
|
1170
|
+
this._color = null;
|
|
1171
|
+
};
|
|
1172
|
+
_create_class(UIRenderer, [
|
|
1955
1173
|
{
|
|
1956
|
-
key: "
|
|
1174
|
+
key: "color",
|
|
1957
1175
|
get: /**
|
|
1958
|
-
*
|
|
1176
|
+
* Rendering color for the ui renderer.
|
|
1959
1177
|
*/ function get() {
|
|
1960
|
-
return this.
|
|
1178
|
+
return this._color;
|
|
1961
1179
|
},
|
|
1962
1180
|
set: function set(value) {
|
|
1963
|
-
if (this.
|
|
1964
|
-
this.
|
|
1965
|
-
this._realRenderMode === CanvasRenderMode.ScreenSpaceOverlay && // @ts-ignore
|
|
1966
|
-
(this.scene._componentsManager._overlayCanvasesSortingFlag = true);
|
|
1181
|
+
if (this._color !== value) {
|
|
1182
|
+
this._color.copyFrom(value);
|
|
1967
1183
|
}
|
|
1968
1184
|
}
|
|
1969
1185
|
},
|
|
1970
1186
|
{
|
|
1971
|
-
key: "
|
|
1187
|
+
key: "raycastEnabled",
|
|
1972
1188
|
get: /**
|
|
1973
|
-
*
|
|
1189
|
+
* Whether this renderer be picked up by raycast.
|
|
1974
1190
|
*/ function get() {
|
|
1975
|
-
return this.
|
|
1191
|
+
return this._raycastEnabled;
|
|
1976
1192
|
},
|
|
1977
1193
|
set: function set(value) {
|
|
1978
|
-
|
|
1979
|
-
this._distance = value;
|
|
1980
|
-
if (this._realRenderMode === CanvasRenderMode.ScreenSpaceCamera) {
|
|
1981
|
-
this._adapterPoseInScreenSpace();
|
|
1982
|
-
this._adapterSizeInScreenSpace();
|
|
1983
|
-
}
|
|
1984
|
-
}
|
|
1194
|
+
this._raycastEnabled = value;
|
|
1985
1195
|
}
|
|
1986
1196
|
}
|
|
1987
1197
|
]);
|
|
1988
|
-
return
|
|
1989
|
-
}(engine.
|
|
1990
|
-
/** @internal */ exports.
|
|
1991
|
-
exports.
|
|
1992
|
-
exports.
|
|
1993
|
-
exports.
|
|
1994
|
-
exports.
|
|
1198
|
+
return UIRenderer;
|
|
1199
|
+
}(engine.Renderer);
|
|
1200
|
+
/** @internal */ exports.UIRenderer._tempVec30 = new engine.Vector3();
|
|
1201
|
+
/** @internal */ exports.UIRenderer._tempVec31 = new engine.Vector3();
|
|
1202
|
+
/** @internal */ exports.UIRenderer._tempMat = new engine.Matrix();
|
|
1203
|
+
/** @internal */ exports.UIRenderer._tempPlane = new engine.Plane();
|
|
1204
|
+
/** @internal */ exports.UIRenderer._textureProperty = engine.ShaderProperty.getByName("renderer_UITexture");
|
|
1995
1205
|
__decorate([
|
|
1996
1206
|
engine.ignoreClone
|
|
1997
|
-
], exports.
|
|
1207
|
+
], exports.UIRenderer.prototype, "_indexInRootCanvas", void 0);
|
|
1998
1208
|
__decorate([
|
|
1999
1209
|
engine.ignoreClone
|
|
2000
|
-
], exports.
|
|
1210
|
+
], exports.UIRenderer.prototype, "_isRootCanvasDirty", void 0);
|
|
2001
1211
|
__decorate([
|
|
2002
1212
|
engine.ignoreClone
|
|
2003
|
-
], exports.
|
|
1213
|
+
], exports.UIRenderer.prototype, "_rootCanvasListeningEntities", void 0);
|
|
2004
1214
|
__decorate([
|
|
2005
1215
|
engine.ignoreClone
|
|
2006
|
-
], exports.
|
|
1216
|
+
], exports.UIRenderer.prototype, "_indexInGroup", void 0);
|
|
1217
|
+
__decorate([
|
|
1218
|
+
engine.ignoreClone
|
|
1219
|
+
], exports.UIRenderer.prototype, "_isGroupDirty", void 0);
|
|
1220
|
+
__decorate([
|
|
1221
|
+
engine.ignoreClone
|
|
1222
|
+
], exports.UIRenderer.prototype, "_groupListeningEntities", void 0);
|
|
1223
|
+
__decorate([
|
|
1224
|
+
engine.ignoreClone
|
|
1225
|
+
], exports.UIRenderer.prototype, "_subChunk", void 0);
|
|
1226
|
+
__decorate([
|
|
1227
|
+
engine.ignoreClone
|
|
1228
|
+
], exports.UIRenderer.prototype, "_groupListener", null);
|
|
1229
|
+
__decorate([
|
|
1230
|
+
engine.ignoreClone
|
|
1231
|
+
], exports.UIRenderer.prototype, "_rootCanvasListener", null);
|
|
1232
|
+
__decorate([
|
|
1233
|
+
engine.ignoreClone
|
|
1234
|
+
], exports.UIRenderer.prototype, "_onColorChanged", null);
|
|
1235
|
+
exports.UIRenderer = __decorate([
|
|
1236
|
+
engine.dependentComponents(UITransform, engine.DependentMode.AutoAdd)
|
|
1237
|
+
], exports.UIRenderer);
|
|
1238
|
+
/**
|
|
1239
|
+
* @remarks Extends `RendererUpdateFlags`.
|
|
1240
|
+
*/ var UIRendererUpdateFlags = /*#__PURE__*/ function(UIRendererUpdateFlags) {
|
|
1241
|
+
UIRendererUpdateFlags[UIRendererUpdateFlags["Color"] = 2] = "Color";
|
|
1242
|
+
return UIRendererUpdateFlags;
|
|
1243
|
+
}({});
|
|
1244
|
+
|
|
1245
|
+
/**
|
|
1246
|
+
* Interactive component.
|
|
1247
|
+
*/ var UIInteractive = /*#__PURE__*/ function(Script) {
|
|
1248
|
+
_inherits(UIInteractive, Script);
|
|
1249
|
+
function UIInteractive(entity) {
|
|
1250
|
+
var _this;
|
|
1251
|
+
_this = Script.call(this, entity) || this, /** @internal */ _this._indexInRootCanvas = -1, /** @internal */ _this._isRootCanvasDirty = false, /** @internal */ _this._rootCanvasListeningEntities = [], /** @internal */ _this._indexInGroup = -1, /** @internal */ _this._isGroupDirty = false, /** @internal */ _this._groupListeningEntities = [], /** @internal */ _this._globalInteractive = false, /** @internal */ _this._globalInteractiveDirty = false, _this._transitions = [], _this._interactive = true, _this._state = 0, /** @todo Multi-touch points are not considered yet. */ _this._isPointerInside = false, _this._isPointerDragging = false;
|
|
1252
|
+
_this._groupListener = _this._groupListener.bind(_this);
|
|
1253
|
+
_this._rootCanvasListener = _this._rootCanvasListener.bind(_this);
|
|
1254
|
+
return _this;
|
|
1255
|
+
}
|
|
1256
|
+
var _proto = UIInteractive.prototype;
|
|
1257
|
+
/**
|
|
1258
|
+
* Add transition on this interactive.
|
|
1259
|
+
* @param transition - The transition
|
|
1260
|
+
*/ _proto.addTransition = function addTransition(transition) {
|
|
1261
|
+
var interactive = transition._interactive;
|
|
1262
|
+
if (interactive !== this) {
|
|
1263
|
+
interactive == null ? void 0 : interactive.removeTransition(transition);
|
|
1264
|
+
this._transitions.push(transition);
|
|
1265
|
+
transition._interactive = this;
|
|
1266
|
+
transition._setState(this._state, true);
|
|
1267
|
+
}
|
|
1268
|
+
};
|
|
1269
|
+
/**
|
|
1270
|
+
* Remove a transition.
|
|
1271
|
+
* @param shape - The transition.
|
|
1272
|
+
*/ _proto.removeTransition = function removeTransition(transition) {
|
|
1273
|
+
var transitions = this._transitions;
|
|
1274
|
+
var lastOneIndex = transitions.length - 1;
|
|
1275
|
+
for(var i = lastOneIndex; i >= 0; i--){
|
|
1276
|
+
if (transitions[i] === transition) {
|
|
1277
|
+
i !== lastOneIndex && (transitions[i] = transitions[lastOneIndex]);
|
|
1278
|
+
transitions.length = lastOneIndex;
|
|
1279
|
+
transition._interactive = null;
|
|
1280
|
+
break;
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
};
|
|
1284
|
+
/**
|
|
1285
|
+
* Remove all transitions.
|
|
1286
|
+
*/ _proto.clearTransitions = function clearTransitions() {
|
|
1287
|
+
var transitions = this._transitions;
|
|
1288
|
+
for(var i = 0, n = transitions.length; i < n; i++){
|
|
1289
|
+
transitions[i]._interactive = null;
|
|
1290
|
+
}
|
|
1291
|
+
transitions.length = 0;
|
|
1292
|
+
};
|
|
1293
|
+
_proto.onUpdate = function onUpdate(deltaTime) {
|
|
1294
|
+
if (this._getGlobalInteractive()) {
|
|
1295
|
+
var transitions = this._transitions;
|
|
1296
|
+
for(var i = 0, n = transitions.length; i < n; i++){
|
|
1297
|
+
transitions[i]._onUpdate(deltaTime);
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
};
|
|
1301
|
+
_proto.onPointerBeginDrag = function onPointerBeginDrag() {
|
|
1302
|
+
this._isPointerDragging = true;
|
|
1303
|
+
this._updateState(false);
|
|
1304
|
+
};
|
|
1305
|
+
_proto.onPointerEndDrag = function onPointerEndDrag() {
|
|
1306
|
+
this._isPointerDragging = false;
|
|
1307
|
+
this._updateState(false);
|
|
1308
|
+
};
|
|
1309
|
+
_proto.onPointerEnter = function onPointerEnter() {
|
|
1310
|
+
this._isPointerInside = true;
|
|
1311
|
+
this._updateState(false);
|
|
1312
|
+
};
|
|
1313
|
+
_proto.onPointerExit = function onPointerExit() {
|
|
1314
|
+
this._isPointerInside = false;
|
|
1315
|
+
this._updateState(false);
|
|
1316
|
+
};
|
|
1317
|
+
_proto.onDestroy = function onDestroy() {
|
|
1318
|
+
Script.prototype.onDestroy.call(this);
|
|
1319
|
+
var transitions = this._transitions;
|
|
1320
|
+
for(var i = transitions.length - 1; i >= 0; i--){
|
|
1321
|
+
transitions[i].destroy();
|
|
1322
|
+
}
|
|
1323
|
+
};
|
|
1324
|
+
/**
|
|
1325
|
+
* @internal
|
|
1326
|
+
*/ _proto._getRootCanvas = function _getRootCanvas() {
|
|
1327
|
+
this._isRootCanvasDirty && Utils.setRootCanvas(this, Utils.searchRootCanvasInParents(this));
|
|
1328
|
+
return this._rootCanvas;
|
|
1329
|
+
};
|
|
1330
|
+
/**
|
|
1331
|
+
* @internal
|
|
1332
|
+
*/ _proto._getGroup = function _getGroup() {
|
|
1333
|
+
this._isGroupDirty && Utils.setGroup(this, Utils.searchGroupInParents(this));
|
|
1334
|
+
return this._group;
|
|
1335
|
+
};
|
|
1336
|
+
// @ts-ignore
|
|
1337
|
+
_proto._onEnableInScene = function _onEnableInScene() {
|
|
1338
|
+
// @ts-ignore
|
|
1339
|
+
Script.prototype._onEnableInScene.call(this);
|
|
1340
|
+
Utils.setRootCanvasDirty(this);
|
|
1341
|
+
Utils.setGroupDirty(this);
|
|
1342
|
+
this._updateState(true);
|
|
1343
|
+
};
|
|
1344
|
+
// @ts-ignore
|
|
1345
|
+
_proto._onDisableInScene = function _onDisableInScene() {
|
|
1346
|
+
// @ts-ignore
|
|
1347
|
+
Script.prototype._onDisableInScene.call(this);
|
|
1348
|
+
Utils.cleanRootCanvas(this);
|
|
1349
|
+
Utils.cleanGroup(this);
|
|
1350
|
+
this._isPointerInside = this._isPointerDragging = false;
|
|
1351
|
+
};
|
|
1352
|
+
/**
|
|
1353
|
+
* @internal
|
|
1354
|
+
*/ _proto._groupListener = function _groupListener(flag) {
|
|
1355
|
+
if (flag === engine.EntityModifyFlags.Parent || flag === EntityUIModifyFlags.GroupEnableInScene) {
|
|
1356
|
+
Utils.setGroupDirty(this);
|
|
1357
|
+
}
|
|
1358
|
+
};
|
|
1359
|
+
/**
|
|
1360
|
+
* @internal
|
|
1361
|
+
*/ _proto._rootCanvasListener = function _rootCanvasListener(flag) {
|
|
1362
|
+
if (flag === engine.EntityModifyFlags.Parent || flag === EntityUIModifyFlags.CanvasEnableInScene) {
|
|
1363
|
+
Utils.setRootCanvasDirty(this);
|
|
1364
|
+
Utils.setGroupDirty(this);
|
|
1365
|
+
}
|
|
1366
|
+
};
|
|
1367
|
+
/**
|
|
1368
|
+
* @internal
|
|
1369
|
+
*/ _proto._onGroupModify = function _onGroupModify(flags) {
|
|
1370
|
+
if (flags & GroupModifyFlags.GlobalInteractive) {
|
|
1371
|
+
this._globalInteractiveDirty = true;
|
|
1372
|
+
}
|
|
1373
|
+
};
|
|
1374
|
+
/**
|
|
1375
|
+
* @internal
|
|
1376
|
+
*/ _proto._getGlobalInteractive = function _getGlobalInteractive() {
|
|
1377
|
+
if (this._globalInteractiveDirty) {
|
|
1378
|
+
var group = this._getGroup();
|
|
1379
|
+
var globalInteractive = this._interactive && (!group || group._getGlobalInteractive());
|
|
1380
|
+
if (this._globalInteractive !== globalInteractive) {
|
|
1381
|
+
this._globalInteractive = globalInteractive;
|
|
1382
|
+
this._updateState(true);
|
|
1383
|
+
}
|
|
1384
|
+
this._globalInteractiveDirty = false;
|
|
1385
|
+
}
|
|
1386
|
+
return this._globalInteractive;
|
|
1387
|
+
};
|
|
1388
|
+
_proto._updateState = function _updateState(instant) {
|
|
1389
|
+
var state = this._getInteractiveState();
|
|
1390
|
+
if (this._state !== state) {
|
|
1391
|
+
this._state = state;
|
|
1392
|
+
var transitions = this._transitions;
|
|
1393
|
+
for(var i = 0, n = transitions.length; i < n; i++){
|
|
1394
|
+
transitions[i]._setState(state, instant);
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1397
|
+
};
|
|
1398
|
+
_proto._getInteractiveState = function _getInteractiveState() {
|
|
1399
|
+
if (!this._getGlobalInteractive()) {
|
|
1400
|
+
return 3;
|
|
1401
|
+
}
|
|
1402
|
+
if (this._isPointerDragging) {
|
|
1403
|
+
return 1;
|
|
1404
|
+
} else {
|
|
1405
|
+
return this._isPointerInside ? 2 : 0;
|
|
1406
|
+
}
|
|
1407
|
+
};
|
|
1408
|
+
_create_class(UIInteractive, [
|
|
1409
|
+
{
|
|
1410
|
+
key: "transitions",
|
|
1411
|
+
get: /**
|
|
1412
|
+
* The transitions of this interactive.
|
|
1413
|
+
*/ function get() {
|
|
1414
|
+
return this._transitions;
|
|
1415
|
+
}
|
|
1416
|
+
},
|
|
1417
|
+
{
|
|
1418
|
+
key: "interactive",
|
|
1419
|
+
get: /**
|
|
1420
|
+
* Whether the interactive is enabled.
|
|
1421
|
+
*/ function get() {
|
|
1422
|
+
return this._interactive;
|
|
1423
|
+
},
|
|
1424
|
+
set: function set(value) {
|
|
1425
|
+
if (this._interactive !== value) {
|
|
1426
|
+
this._interactive = value;
|
|
1427
|
+
this._globalInteractiveDirty = true;
|
|
1428
|
+
}
|
|
1429
|
+
}
|
|
1430
|
+
}
|
|
1431
|
+
]);
|
|
1432
|
+
return UIInteractive;
|
|
1433
|
+
}(engine.Script);
|
|
2007
1434
|
__decorate([
|
|
2008
1435
|
engine.ignoreClone
|
|
2009
|
-
],
|
|
1436
|
+
], UIInteractive.prototype, "_indexInRootCanvas", void 0);
|
|
2010
1437
|
__decorate([
|
|
2011
1438
|
engine.ignoreClone
|
|
2012
|
-
],
|
|
1439
|
+
], UIInteractive.prototype, "_isRootCanvasDirty", void 0);
|
|
2013
1440
|
__decorate([
|
|
2014
1441
|
engine.ignoreClone
|
|
2015
|
-
],
|
|
1442
|
+
], UIInteractive.prototype, "_rootCanvasListeningEntities", void 0);
|
|
2016
1443
|
__decorate([
|
|
2017
1444
|
engine.ignoreClone
|
|
2018
|
-
],
|
|
1445
|
+
], UIInteractive.prototype, "_indexInGroup", void 0);
|
|
2019
1446
|
__decorate([
|
|
2020
1447
|
engine.ignoreClone
|
|
2021
|
-
],
|
|
1448
|
+
], UIInteractive.prototype, "_isGroupDirty", void 0);
|
|
2022
1449
|
__decorate([
|
|
2023
1450
|
engine.ignoreClone
|
|
2024
|
-
],
|
|
1451
|
+
], UIInteractive.prototype, "_groupListeningEntities", void 0);
|
|
2025
1452
|
__decorate([
|
|
2026
1453
|
engine.ignoreClone
|
|
2027
|
-
],
|
|
1454
|
+
], UIInteractive.prototype, "_globalInteractive", void 0);
|
|
2028
1455
|
__decorate([
|
|
2029
1456
|
engine.ignoreClone
|
|
2030
|
-
],
|
|
1457
|
+
], UIInteractive.prototype, "_globalInteractiveDirty", void 0);
|
|
2031
1458
|
__decorate([
|
|
2032
1459
|
engine.ignoreClone
|
|
2033
|
-
],
|
|
1460
|
+
], UIInteractive.prototype, "_state", void 0);
|
|
2034
1461
|
__decorate([
|
|
2035
1462
|
engine.ignoreClone
|
|
2036
|
-
],
|
|
1463
|
+
], UIInteractive.prototype, "_isPointerInside", void 0);
|
|
2037
1464
|
__decorate([
|
|
2038
1465
|
engine.ignoreClone
|
|
2039
|
-
],
|
|
1466
|
+
], UIInteractive.prototype, "_isPointerDragging", void 0);
|
|
2040
1467
|
__decorate([
|
|
2041
1468
|
engine.ignoreClone
|
|
2042
|
-
],
|
|
1469
|
+
], UIInteractive.prototype, "_groupListener", null);
|
|
2043
1470
|
__decorate([
|
|
2044
1471
|
engine.ignoreClone
|
|
2045
|
-
],
|
|
1472
|
+
], UIInteractive.prototype, "_rootCanvasListener", null);
|
|
2046
1473
|
__decorate([
|
|
2047
1474
|
engine.ignoreClone
|
|
2048
|
-
],
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
]
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
EntityUIModifyFlags[EntityUIModifyFlags["CanvasEnableInScene"] = 4] = "CanvasEnableInScene";
|
|
2056
|
-
EntityUIModifyFlags[EntityUIModifyFlags["GroupEnableInScene"] = 8] = "GroupEnableInScene";
|
|
2057
|
-
return EntityUIModifyFlags;
|
|
2058
|
-
}({});
|
|
2059
|
-
var RootCanvasModifyFlags = /*#__PURE__*/ function(RootCanvasModifyFlags) {
|
|
2060
|
-
RootCanvasModifyFlags[RootCanvasModifyFlags["None"] = 0] = "None";
|
|
2061
|
-
RootCanvasModifyFlags[RootCanvasModifyFlags["ReferenceResolutionPerUnit"] = 1] = "ReferenceResolutionPerUnit";
|
|
2062
|
-
RootCanvasModifyFlags[RootCanvasModifyFlags["All"] = 1] = "All";
|
|
2063
|
-
return RootCanvasModifyFlags;
|
|
1475
|
+
], UIInteractive.prototype, "_onGroupModify", null);
|
|
1476
|
+
var InteractiveState = /*#__PURE__*/ function(InteractiveState) {
|
|
1477
|
+
InteractiveState[InteractiveState["Normal"] = 0] = "Normal";
|
|
1478
|
+
InteractiveState[InteractiveState["Pressed"] = 1] = "Pressed";
|
|
1479
|
+
InteractiveState[InteractiveState["Hover"] = 2] = "Hover";
|
|
1480
|
+
InteractiveState[InteractiveState["Disable"] = 3] = "Disable";
|
|
1481
|
+
return InteractiveState;
|
|
2064
1482
|
}({});
|
|
2065
1483
|
|
|
2066
|
-
|
|
2067
|
-
|
|
1484
|
+
exports.UICanvas = /*#__PURE__*/ function(Component) {
|
|
1485
|
+
_inherits(UICanvas, Component);
|
|
1486
|
+
function UICanvas(entity) {
|
|
1487
|
+
var _this;
|
|
1488
|
+
_this = Component.call(this, entity) || this, /** @internal */ _this._canvasIndex = -1, /** @internal */ _this._indexInRootCanvas = -1, /** @internal */ _this._isRootCanvasDirty = false, /** @internal */ _this._rootCanvasListeningEntities = [], /** @internal */ _this._isRootCanvas = false, /** @internal */ _this._renderElements = [], /** @internal */ _this._batchedRenderElements = [], /** @internal */ _this._sortDistance = 0, /** @internal */ _this._orderedRenderers = [], /** @internal */ _this._realRenderMode = 4, /** @internal */ _this._disorderedElements = new engine.DisorderedArray(), _this._renderMode = CanvasRenderMode.WorldSpace, _this._resolutionAdaptationMode = ResolutionAdaptationMode.HeightAdaptation, _this._sortOrder = 0, _this._distance = 10, _this._referenceResolution = new engine.Vector2(800, 600), _this._referenceResolutionPerUnit = 100, _this._hierarchyVersion = -1, _this._center = new engine.Vector3();
|
|
1489
|
+
_this._onCanvasSizeListener = _this._onCanvasSizeListener.bind(_this);
|
|
1490
|
+
_this._onCameraModifyListener = _this._onCameraModifyListener.bind(_this);
|
|
1491
|
+
_this._onCameraTransformListener = _this._onCameraTransformListener.bind(_this);
|
|
1492
|
+
_this._onReferenceResolutionChanged = _this._onReferenceResolutionChanged.bind(_this);
|
|
1493
|
+
// @ts-ignore
|
|
1494
|
+
_this._referenceResolution._onValueChanged = _this._onReferenceResolutionChanged;
|
|
1495
|
+
_this._rootCanvasListener = _this._rootCanvasListener.bind(_this);
|
|
1496
|
+
_this._centerDirtyFlag = entity.registerWorldChangeFlag();
|
|
1497
|
+
return _this;
|
|
1498
|
+
}
|
|
1499
|
+
var _proto = UICanvas.prototype;
|
|
2068
1500
|
/**
|
|
2069
|
-
*
|
|
2070
|
-
*/
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
var
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
var components = entity._components;
|
|
2078
|
-
for(var i = 0, n = components.length; i < n; i++){
|
|
2079
|
-
var component = components[i];
|
|
2080
|
-
if (component.enabled && _instanceof(component, exports.UICanvas) && component._isRootCanvas) {
|
|
2081
|
-
rootCanvas = component;
|
|
2082
|
-
}
|
|
1501
|
+
* @internal
|
|
1502
|
+
*/ _proto._raycast = function _raycast(ray, out, distance) {
|
|
1503
|
+
if (distance === void 0) distance = Number.MAX_SAFE_INTEGER;
|
|
1504
|
+
var renderers = this._getRenderers();
|
|
1505
|
+
for(var i = renderers.length - 1; i >= 0; i--){
|
|
1506
|
+
var element = renderers[i];
|
|
1507
|
+
if (element.raycastEnabled && element._raycast(ray, out, distance)) {
|
|
1508
|
+
return true;
|
|
2083
1509
|
}
|
|
2084
|
-
entity = entity.parent;
|
|
2085
|
-
}
|
|
2086
|
-
if (!rootCanvas) return false;
|
|
2087
|
-
// Calculate ray
|
|
2088
|
-
var ray = this._tempRay;
|
|
2089
|
-
switch(rootCanvas._realRenderMode){
|
|
2090
|
-
case CanvasRenderMode.ScreenSpaceOverlay:
|
|
2091
|
-
// Screen to world ( Assume that world units have a one-to-one relationship with pixel units )
|
|
2092
|
-
ray.origin.set(position.x, engine$1.canvas.height - position.y, 1);
|
|
2093
|
-
ray.direction.set(0, 0, -1);
|
|
2094
|
-
break;
|
|
2095
|
-
case CanvasRenderMode.ScreenSpaceCamera:
|
|
2096
|
-
rootCanvas.renderCamera.screenPointToRay(position, ray);
|
|
2097
|
-
break;
|
|
2098
|
-
default:
|
|
2099
|
-
// World space not yet supported, see issue #2793
|
|
2100
|
-
return false;
|
|
2101
|
-
}
|
|
2102
|
-
// Intersect ray with UI plane to get local coordinates
|
|
2103
|
-
var plane = this._tempPlane;
|
|
2104
|
-
var normal = plane.normal.copyFrom(transform.worldForward);
|
|
2105
|
-
plane.distance = -engine.Vector3.dot(normal, transform.worldPosition);
|
|
2106
|
-
var curDistance = ray.intersectPlane(plane);
|
|
2107
|
-
if (curDistance >= 0 && curDistance < Number.MAX_SAFE_INTEGER) {
|
|
2108
|
-
var hitPointWorld = ray.getPoint(curDistance, this._tempVec3);
|
|
2109
|
-
var worldMatrixInv = this._tempMat;
|
|
2110
|
-
engine.Matrix.invert(transform.worldMatrix, worldMatrixInv);
|
|
2111
|
-
engine.Vector3.transformCoordinate(hitPointWorld, worldMatrixInv, out);
|
|
2112
|
-
return true;
|
|
2113
1510
|
}
|
|
1511
|
+
out.component = null;
|
|
1512
|
+
out.entity = null;
|
|
1513
|
+
out.distance = 0;
|
|
1514
|
+
out.point.set(0, 0, 0);
|
|
1515
|
+
out.normal.set(0, 0, 0);
|
|
2114
1516
|
return false;
|
|
2115
1517
|
};
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
this.
|
|
2120
|
-
element._onRootCanvasModify == null ? void 0 : element._onRootCanvasModify.call(element, RootCanvasModifyFlags.All);
|
|
1518
|
+
/**
|
|
1519
|
+
* @internal
|
|
1520
|
+
*/ _proto._getRootCanvas = function _getRootCanvas() {
|
|
1521
|
+
return this._rootCanvas;
|
|
2121
1522
|
};
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
var _rootCanvas_entity_parent;
|
|
2127
|
-
var toEntity = (_rootCanvas_entity_parent = rootCanvas == null ? void 0 : rootCanvas.entity.parent) != null ? _rootCanvas_entity_parent : null;
|
|
2128
|
-
this._registerListener(fromEntity, toEntity, element._rootCanvasListener, element._rootCanvasListeningEntities);
|
|
1523
|
+
/**
|
|
1524
|
+
* @internal
|
|
1525
|
+
*/ _proto._canRender = function _canRender(camera) {
|
|
1526
|
+
return this._realRenderMode !== CanvasRenderMode.ScreenSpaceCamera || this._camera === camera;
|
|
2129
1527
|
};
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
1528
|
+
/**
|
|
1529
|
+
* @internal
|
|
1530
|
+
*/ _proto._canDispatchEvent = function _canDispatchEvent(camera) {
|
|
1531
|
+
var realMode = this._realRenderMode;
|
|
1532
|
+
if (realMode === CanvasRenderMode.ScreenSpaceOverlay) {
|
|
1533
|
+
return true;
|
|
1534
|
+
}
|
|
1535
|
+
var assignedCamera = this._camera;
|
|
1536
|
+
// @ts-ignore
|
|
1537
|
+
return !assignedCamera || !assignedCamera._phasedActiveInScene || assignedCamera === camera;
|
|
2133
1538
|
};
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
1539
|
+
/**
|
|
1540
|
+
* @internal
|
|
1541
|
+
*/ _proto._prepareRender = function _prepareRender(context) {
|
|
1542
|
+
var _this = this, engine = _this.engine, mode = _this._realRenderMode;
|
|
1543
|
+
var _context_camera = context.camera, enableFrustumCulling = _context_camera.enableFrustumCulling, cullingMask = _context_camera.cullingMask, frustum = _context_camera._frustum;
|
|
1544
|
+
var frameCount = engine.time.frameCount;
|
|
1545
|
+
var renderElements = this._renderElements;
|
|
1546
|
+
renderElements.length = 0;
|
|
1547
|
+
var virtualCamera = context.virtualCamera;
|
|
1548
|
+
this._updateSortDistance(virtualCamera.isOrthographic, virtualCamera.position, virtualCamera.forward);
|
|
1549
|
+
var _engine_canvas = engine.canvas, width = _engine_canvas.width, height = _engine_canvas.height;
|
|
1550
|
+
var renderers = this._getRenderers();
|
|
1551
|
+
for(var i = 0, n = renderers.length; i < n; i++){
|
|
1552
|
+
var renderer = renderers[i];
|
|
1553
|
+
// Filter by camera culling mask
|
|
1554
|
+
if (!(cullingMask & renderer.entity.layer)) {
|
|
1555
|
+
continue;
|
|
1556
|
+
}
|
|
1557
|
+
// Filter by camera frustum
|
|
1558
|
+
if (enableFrustumCulling) {
|
|
1559
|
+
switch(mode){
|
|
1560
|
+
case CanvasRenderMode.ScreenSpaceOverlay:
|
|
1561
|
+
var _renderer_bounds = renderer.bounds, min = _renderer_bounds.min, max = _renderer_bounds.max;
|
|
1562
|
+
if (min.x > width || max.x < 0 || min.y > height || max.y < 0) {
|
|
1563
|
+
continue;
|
|
1564
|
+
}
|
|
1565
|
+
break;
|
|
1566
|
+
case CanvasRenderMode.ScreenSpaceCamera:
|
|
1567
|
+
case CanvasRenderMode.WorldSpace:
|
|
1568
|
+
if (!frustum.intersectsBox(renderer.bounds)) {
|
|
1569
|
+
continue;
|
|
1570
|
+
}
|
|
1571
|
+
break;
|
|
2143
1572
|
}
|
|
2144
1573
|
}
|
|
2145
|
-
|
|
1574
|
+
renderer._prepareRender(context);
|
|
1575
|
+
renderer._renderFrameCount = frameCount;
|
|
1576
|
+
}
|
|
1577
|
+
var batchedRenderElements = this._batchedRenderElements;
|
|
1578
|
+
batchedRenderElements.length = 0;
|
|
1579
|
+
UIBatchSorter.sort(renderElements, this.entity.transform.worldMatrix);
|
|
1580
|
+
engine._batcherManager.batch(renderElements, batchedRenderElements);
|
|
1581
|
+
for(var i1 = 0, n1 = batchedRenderElements.length; i1 < n1; i1++){
|
|
1582
|
+
batchedRenderElements[i1].subDistancePriority = i1;
|
|
2146
1583
|
}
|
|
2147
|
-
return null;
|
|
2148
1584
|
};
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
this.
|
|
2153
|
-
|
|
1585
|
+
/**
|
|
1586
|
+
* @internal
|
|
1587
|
+
*/ _proto._updateSortDistance = function _updateSortDistance(isOrthographic, cameraPosition, cameraForward) {
|
|
1588
|
+
switch(this._realRenderMode){
|
|
1589
|
+
case CanvasRenderMode.ScreenSpaceOverlay:
|
|
1590
|
+
this._sortDistance = 0;
|
|
1591
|
+
break;
|
|
1592
|
+
case CanvasRenderMode.ScreenSpaceCamera:
|
|
1593
|
+
this._sortDistance = this._distance;
|
|
1594
|
+
break;
|
|
1595
|
+
case CanvasRenderMode.WorldSpace:
|
|
1596
|
+
var boundsCenter = this._getCenter();
|
|
1597
|
+
if (isOrthographic) {
|
|
1598
|
+
var distance = UICanvas._tempVec3;
|
|
1599
|
+
engine.Vector3.subtract(boundsCenter, cameraPosition, distance);
|
|
1600
|
+
this._sortDistance = engine.Vector3.dot(distance, cameraForward);
|
|
1601
|
+
} else {
|
|
1602
|
+
this._sortDistance = engine.Vector3.distanceSquared(boundsCenter, cameraPosition);
|
|
1603
|
+
}
|
|
1604
|
+
break;
|
|
1605
|
+
}
|
|
2154
1606
|
};
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
this.
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
1607
|
+
// @ts-ignore
|
|
1608
|
+
_proto._onEnableInScene = function _onEnableInScene() {
|
|
1609
|
+
var entity = this.entity;
|
|
1610
|
+
// @ts-ignore
|
|
1611
|
+
entity._dispatchModify(4, this);
|
|
1612
|
+
var rootCanvas = Utils.searchRootCanvasInParents(this);
|
|
1613
|
+
this._setIsRootCanvas(!rootCanvas);
|
|
1614
|
+
Utils.setRootCanvas(this, rootCanvas);
|
|
1615
|
+
};
|
|
1616
|
+
// @ts-ignore
|
|
1617
|
+
_proto._onDisableInScene = function _onDisableInScene() {
|
|
1618
|
+
this._setIsRootCanvas(false);
|
|
1619
|
+
Utils.cleanRootCanvas(this);
|
|
1620
|
+
};
|
|
1621
|
+
// @ts-ignore
|
|
1622
|
+
_proto._onDisable = function _onDisable() {
|
|
1623
|
+
this._renderElements.length = 0;
|
|
1624
|
+
this._batchedRenderElements.length = 0;
|
|
1625
|
+
};
|
|
1626
|
+
/**
|
|
1627
|
+
* @internal
|
|
1628
|
+
*/ _proto._rootCanvasListener = function _rootCanvasListener(flag, param) {
|
|
1629
|
+
if (this._isRootCanvas) {
|
|
1630
|
+
if (flag === engine.EntityModifyFlags.Parent) {
|
|
1631
|
+
var rootCanvas = Utils.searchRootCanvasInParents(this);
|
|
1632
|
+
this._setIsRootCanvas(!rootCanvas);
|
|
1633
|
+
Utils.setRootCanvas(this, rootCanvas);
|
|
1634
|
+
} else if (flag === 4) {
|
|
1635
|
+
this._setIsRootCanvas(false);
|
|
1636
|
+
Utils.setRootCanvas(this, param);
|
|
1637
|
+
}
|
|
2164
1638
|
} else {
|
|
2165
|
-
|
|
1639
|
+
if (flag === engine.EntityModifyFlags.Parent) {
|
|
1640
|
+
var rootCanvas1 = Utils.searchRootCanvasInParents(this);
|
|
1641
|
+
this._setIsRootCanvas(!rootCanvas1);
|
|
1642
|
+
Utils.setRootCanvas(this, rootCanvas1);
|
|
1643
|
+
}
|
|
2166
1644
|
}
|
|
2167
1645
|
};
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
1646
|
+
/**
|
|
1647
|
+
* @inheritdoc
|
|
1648
|
+
*/ _proto._onClone = function _onClone(target) {
|
|
1649
|
+
target.renderMode = this._renderMode;
|
|
2171
1650
|
};
|
|
2172
|
-
|
|
2173
|
-
var
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
for(var i = 0, n = components.length; i < n; i++){
|
|
2181
|
-
var component = components[i];
|
|
2182
|
-
if (component.enabled && _instanceof(component, UIGroup)) {
|
|
2183
|
-
return component;
|
|
2184
|
-
}
|
|
2185
|
-
}
|
|
2186
|
-
entity = entity.parent;
|
|
1651
|
+
_proto._getRenderers = function _getRenderers() {
|
|
1652
|
+
var _this = this, renderers = _this._orderedRenderers, entity = _this.entity;
|
|
1653
|
+
var uiHierarchyVersion = entity._uiHierarchyVersion;
|
|
1654
|
+
if (this._hierarchyVersion !== uiHierarchyVersion) {
|
|
1655
|
+
renderers.length = this._walk(this.entity, renderers);
|
|
1656
|
+
UICanvas._tempGroupAbleList.length = 0;
|
|
1657
|
+
this._hierarchyVersion = uiHierarchyVersion;
|
|
1658
|
+
++UICanvas._hierarchyCounter;
|
|
2187
1659
|
}
|
|
2188
|
-
return
|
|
1660
|
+
return renderers;
|
|
2189
1661
|
};
|
|
2190
|
-
|
|
2191
|
-
var
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
disorderedElements.add(element);
|
|
1662
|
+
_proto._adapterPoseInScreenSpace = function _adapterPoseInScreenSpace() {
|
|
1663
|
+
var transform = this.entity.transform;
|
|
1664
|
+
var realRenderMode = this._realRenderMode;
|
|
1665
|
+
if (realRenderMode === CanvasRenderMode.ScreenSpaceCamera) {
|
|
1666
|
+
var cameraEntity = this._camera.entity;
|
|
1667
|
+
if (!this._isSameOrChildEntity(cameraEntity)) {
|
|
1668
|
+
var cameraTransform = cameraEntity.transform;
|
|
1669
|
+
var cameraWorldPosition = cameraTransform.worldPosition, cameraWorldForward = cameraTransform.worldForward;
|
|
1670
|
+
var distance = this._distance;
|
|
1671
|
+
transform.setWorldPosition(cameraWorldPosition.x + cameraWorldForward.x * distance, cameraWorldPosition.y + cameraWorldForward.y * distance, cameraWorldPosition.z + cameraWorldForward.z * distance);
|
|
1672
|
+
transform.worldRotationQuaternion.copyFrom(cameraTransform.worldRotationQuaternion);
|
|
2202
1673
|
}
|
|
2203
|
-
|
|
1674
|
+
} else {
|
|
1675
|
+
var canvas = this.engine.canvas;
|
|
1676
|
+
transform.setWorldPosition(canvas.width * 0.5, canvas.height * 0.5, 0);
|
|
1677
|
+
transform.worldRotationQuaternion.set(0, 0, 0, 1);
|
|
2204
1678
|
}
|
|
2205
1679
|
};
|
|
2206
|
-
|
|
2207
|
-
var
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
1680
|
+
_proto._adapterSizeInScreenSpace = function _adapterSizeInScreenSpace() {
|
|
1681
|
+
var transform = this.entity.transform;
|
|
1682
|
+
var realRenderMode = this._realRenderMode;
|
|
1683
|
+
var _this__referenceResolution = this._referenceResolution, width = _this__referenceResolution.x, height = _this__referenceResolution.y;
|
|
1684
|
+
var curWidth;
|
|
1685
|
+
var curHeight;
|
|
1686
|
+
if (realRenderMode === CanvasRenderMode.ScreenSpaceCamera) {
|
|
1687
|
+
var camera = this._camera;
|
|
1688
|
+
curHeight = camera.isOrthographic ? camera.orthographicSize * 2 : 2 * (Math.tan(engine.MathUtil.degreeToRadian(camera.fieldOfView * 0.5)) * this._distance);
|
|
1689
|
+
curWidth = camera.aspectRatio * curHeight;
|
|
1690
|
+
} else {
|
|
1691
|
+
var canvas = this.engine.canvas;
|
|
1692
|
+
curHeight = canvas.height;
|
|
1693
|
+
curWidth = canvas.width;
|
|
1694
|
+
}
|
|
1695
|
+
var expectX, expectY, expectZ;
|
|
1696
|
+
switch(this._resolutionAdaptationMode){
|
|
1697
|
+
case ResolutionAdaptationMode.WidthAdaptation:
|
|
1698
|
+
expectX = expectY = expectZ = curWidth / width;
|
|
1699
|
+
break;
|
|
1700
|
+
case ResolutionAdaptationMode.HeightAdaptation:
|
|
1701
|
+
expectX = expectY = expectZ = curHeight / height;
|
|
1702
|
+
break;
|
|
1703
|
+
case ResolutionAdaptationMode.BothAdaptation:
|
|
1704
|
+
expectX = curWidth / width;
|
|
1705
|
+
expectY = curHeight / height;
|
|
1706
|
+
expectZ = (expectX + expectY) * 0.5;
|
|
1707
|
+
break;
|
|
1708
|
+
case ResolutionAdaptationMode.ExpandAdaptation:
|
|
1709
|
+
expectX = expectY = expectZ = Math.min(curWidth / width, curHeight / height);
|
|
1710
|
+
break;
|
|
1711
|
+
case ResolutionAdaptationMode.ShrinkAdaptation:
|
|
1712
|
+
expectX = expectY = expectZ = Math.max(curWidth / width, curHeight / height);
|
|
1713
|
+
break;
|
|
2221
1714
|
}
|
|
1715
|
+
var worldMatrix = UICanvas._tempMat;
|
|
1716
|
+
engine.Matrix.affineTransformation(UICanvas._tempVec3.set(expectX, expectY, expectZ), transform.worldRotationQuaternion, transform.worldPosition, worldMatrix);
|
|
1717
|
+
transform.worldMatrix = worldMatrix;
|
|
1718
|
+
transform.size.set(curWidth / expectX, curHeight / expectY);
|
|
2222
1719
|
};
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
1720
|
+
_proto._walk = function _walk(entity, renderers, depth, group) {
|
|
1721
|
+
if (depth === void 0) depth = 0;
|
|
1722
|
+
if (group === void 0) group = null;
|
|
1723
|
+
// @ts-ignore
|
|
1724
|
+
var components = entity._components;
|
|
1725
|
+
var tempGroupAbleList = UICanvas._tempGroupAbleList;
|
|
1726
|
+
var groupAbleCount = 0;
|
|
1727
|
+
for(var i = 0, n = components.length; i < n; i++){
|
|
1728
|
+
var component = components[i];
|
|
1729
|
+
if (!component.enabled) continue;
|
|
1730
|
+
if (_instanceof(component, exports.UIRenderer)) {
|
|
1731
|
+
renderers[depth] = component;
|
|
1732
|
+
++depth;
|
|
1733
|
+
component._isRootCanvasDirty && Utils.setRootCanvas(component, this);
|
|
1734
|
+
if (component._isGroupDirty) {
|
|
1735
|
+
tempGroupAbleList[groupAbleCount++] = component;
|
|
1736
|
+
}
|
|
1737
|
+
} else if (_instanceof(component, UIInteractive)) {
|
|
1738
|
+
component._isRootCanvasDirty && Utils.setRootCanvas(component, this);
|
|
1739
|
+
if (component._isGroupDirty) {
|
|
1740
|
+
tempGroupAbleList[groupAbleCount++] = component;
|
|
1741
|
+
}
|
|
1742
|
+
} else if (_instanceof(component, UIGroup)) {
|
|
1743
|
+
component._isRootCanvasDirty && Utils.setRootCanvas(component, this);
|
|
1744
|
+
component._isGroupDirty && Utils.setGroup(component, group);
|
|
1745
|
+
group = component;
|
|
2233
1746
|
}
|
|
2234
|
-
entity = entity.parent;
|
|
2235
|
-
count++;
|
|
2236
1747
|
}
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
Utils._unRegisterListener = function _unRegisterListener(listener, listeningEntities) {
|
|
2240
|
-
for(var i = 0, n = listeningEntities.length; i < n; i++){
|
|
2241
|
-
// @ts-ignore
|
|
2242
|
-
listeningEntities[i]._unRegisterModifyListener(listener);
|
|
1748
|
+
for(var i1 = 0; i1 < groupAbleCount; i1++){
|
|
1749
|
+
Utils.setGroup(tempGroupAbleList[i1], group);
|
|
2243
1750
|
}
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
Utils._tempRay = new engine.Ray();
|
|
2249
|
-
Utils._tempPlane = new engine.Plane();
|
|
2250
|
-
Utils._tempVec3 = new engine.Vector3();
|
|
2251
|
-
Utils._tempMat = new engine.Matrix();
|
|
2252
|
-
|
|
2253
|
-
/**
|
|
2254
|
-
* Interactive component.
|
|
2255
|
-
*/ var UIInteractive = /*#__PURE__*/ function(Script) {
|
|
2256
|
-
_inherits(UIInteractive, Script);
|
|
2257
|
-
function UIInteractive(entity) {
|
|
2258
|
-
var _this;
|
|
2259
|
-
_this = Script.call(this, entity) || this, /** @internal */ _this._indexInRootCanvas = -1, /** @internal */ _this._isRootCanvasDirty = false, /** @internal */ _this._rootCanvasListeningEntities = [], /** @internal */ _this._indexInGroup = -1, /** @internal */ _this._isGroupDirty = false, /** @internal */ _this._groupListeningEntities = [], /** @internal */ _this._globalInteractive = false, /** @internal */ _this._globalInteractiveDirty = false, _this._transitions = [], _this._interactive = true, _this._state = 0, /** @todo Multi-touch points are not considered yet. */ _this._isPointerInside = false, _this._isPointerDragging = false;
|
|
2260
|
-
_this._groupListener = _this._groupListener.bind(_this);
|
|
2261
|
-
_this._rootCanvasListener = _this._rootCanvasListener.bind(_this);
|
|
2262
|
-
return _this;
|
|
2263
|
-
}
|
|
2264
|
-
var _proto = UIInteractive.prototype;
|
|
2265
|
-
/**
|
|
2266
|
-
* Add transition on this interactive.
|
|
2267
|
-
* @param transition - The transition
|
|
2268
|
-
*/ _proto.addTransition = function addTransition(transition) {
|
|
2269
|
-
var interactive = transition._interactive;
|
|
2270
|
-
if (interactive !== this) {
|
|
2271
|
-
interactive == null ? void 0 : interactive.removeTransition(transition);
|
|
2272
|
-
this._transitions.push(transition);
|
|
2273
|
-
transition._interactive = this;
|
|
2274
|
-
transition._setState(this._state, true);
|
|
1751
|
+
var children = entity.children;
|
|
1752
|
+
for(var i2 = 0, n1 = children.length; i2 < n1; i2++){
|
|
1753
|
+
var child = children[i2];
|
|
1754
|
+
child.isActive && (depth = this._walk(child, renderers, depth, group));
|
|
2275
1755
|
}
|
|
1756
|
+
return depth;
|
|
2276
1757
|
};
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
1758
|
+
_proto._updateCameraObserver = function _updateCameraObserver() {
|
|
1759
|
+
var camera = this._isRootCanvas && this._renderMode === CanvasRenderMode.ScreenSpaceCamera ? this._camera : null;
|
|
1760
|
+
var preCamera = this._cameraObserver;
|
|
1761
|
+
if (preCamera !== camera) {
|
|
1762
|
+
this._cameraObserver = camera;
|
|
1763
|
+
if (preCamera) {
|
|
1764
|
+
// @ts-ignore
|
|
1765
|
+
preCamera.entity._updateFlagManager.removeListener(this._onCameraTransformListener);
|
|
1766
|
+
// @ts-ignore
|
|
1767
|
+
preCamera._unRegisterModifyListener(this._onCameraModifyListener);
|
|
1768
|
+
}
|
|
1769
|
+
if (camera) {
|
|
1770
|
+
// @ts-ignore
|
|
1771
|
+
camera.entity._updateFlagManager.addListener(this._onCameraTransformListener);
|
|
1772
|
+
// @ts-ignore
|
|
1773
|
+
camera._registerModifyListener(this._onCameraModifyListener);
|
|
2289
1774
|
}
|
|
2290
1775
|
}
|
|
2291
1776
|
};
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
1777
|
+
_proto._onCameraModifyListener = function _onCameraModifyListener(flag) {
|
|
1778
|
+
if (this._realRenderMode === CanvasRenderMode.ScreenSpaceCamera) {
|
|
1779
|
+
switch(flag){
|
|
1780
|
+
case engine.CameraModifyFlags.ProjectionType:
|
|
1781
|
+
case engine.CameraModifyFlags.AspectRatio:
|
|
1782
|
+
this._adapterSizeInScreenSpace();
|
|
1783
|
+
break;
|
|
1784
|
+
case engine.CameraModifyFlags.FieldOfView:
|
|
1785
|
+
!this._camera.isOrthographic && this._adapterSizeInScreenSpace();
|
|
1786
|
+
break;
|
|
1787
|
+
case engine.CameraModifyFlags.OrthographicSize:
|
|
1788
|
+
this._camera.isOrthographic && this._adapterSizeInScreenSpace();
|
|
1789
|
+
break;
|
|
1790
|
+
case engine.CameraModifyFlags.DisableInScene:
|
|
1791
|
+
this._setRealRenderMode(CanvasRenderMode.ScreenSpaceOverlay);
|
|
1792
|
+
break;
|
|
2306
1793
|
}
|
|
1794
|
+
} else {
|
|
1795
|
+
flag === engine.CameraModifyFlags.EnableInScene && this._setRealRenderMode(CanvasRenderMode.ScreenSpaceCamera);
|
|
2307
1796
|
}
|
|
2308
1797
|
};
|
|
2309
|
-
_proto.
|
|
2310
|
-
this.
|
|
2311
|
-
this._updateState(false);
|
|
1798
|
+
_proto._onCameraTransformListener = function _onCameraTransformListener() {
|
|
1799
|
+
this._realRenderMode === CanvasRenderMode.ScreenSpaceCamera && this._adapterPoseInScreenSpace();
|
|
2312
1800
|
};
|
|
2313
|
-
_proto.
|
|
2314
|
-
|
|
2315
|
-
this.
|
|
1801
|
+
_proto._addCanvasListener = function _addCanvasListener() {
|
|
1802
|
+
// @ts-ignore
|
|
1803
|
+
this.engine.canvas._sizeUpdateFlagManager.addListener(this._onCanvasSizeListener);
|
|
2316
1804
|
};
|
|
2317
|
-
_proto.
|
|
2318
|
-
|
|
2319
|
-
this.
|
|
1805
|
+
_proto._removeCanvasListener = function _removeCanvasListener() {
|
|
1806
|
+
// @ts-ignore
|
|
1807
|
+
this.engine.canvas._sizeUpdateFlagManager.removeListener(this._onCanvasSizeListener);
|
|
2320
1808
|
};
|
|
2321
|
-
_proto.
|
|
2322
|
-
|
|
2323
|
-
this.
|
|
1809
|
+
_proto._onCanvasSizeListener = function _onCanvasSizeListener() {
|
|
1810
|
+
var canvas = this.engine.canvas;
|
|
1811
|
+
this.entity.transform.setWorldPosition(canvas.width * 0.5, canvas.height * 0.5, 0);
|
|
1812
|
+
this._adapterSizeInScreenSpace();
|
|
2324
1813
|
};
|
|
2325
|
-
_proto.
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
transitions[i].destroy();
|
|
1814
|
+
_proto._onReferenceResolutionChanged = function _onReferenceResolutionChanged() {
|
|
1815
|
+
var realRenderMode = this._realRenderMode;
|
|
1816
|
+
if (realRenderMode === CanvasRenderMode.ScreenSpaceOverlay || realRenderMode === CanvasRenderMode.ScreenSpaceCamera) {
|
|
1817
|
+
this._adapterSizeInScreenSpace();
|
|
2330
1818
|
}
|
|
2331
1819
|
};
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
Utils.cleanRootCanvas(this);
|
|
2357
|
-
Utils.cleanGroup(this);
|
|
2358
|
-
this._isPointerInside = this._isPointerDragging = false;
|
|
2359
|
-
};
|
|
2360
|
-
/**
|
|
2361
|
-
* @internal
|
|
2362
|
-
*/ _proto._groupListener = function _groupListener(flag) {
|
|
2363
|
-
if (flag === engine.EntityModifyFlags.Parent || flag === EntityUIModifyFlags.GroupEnableInScene) {
|
|
2364
|
-
Utils.setGroupDirty(this);
|
|
1820
|
+
_proto._setIsRootCanvas = function _setIsRootCanvas(isRootCanvas) {
|
|
1821
|
+
var _this = this;
|
|
1822
|
+
if (this._isRootCanvas !== isRootCanvas) {
|
|
1823
|
+
this._isRootCanvas = isRootCanvas;
|
|
1824
|
+
this._updateCameraObserver();
|
|
1825
|
+
this._setRealRenderMode(this._getRealRenderMode());
|
|
1826
|
+
if (isRootCanvas) {
|
|
1827
|
+
this.entity._updateUIHierarchyVersion(UICanvas._hierarchyCounter);
|
|
1828
|
+
} else {
|
|
1829
|
+
var _this1 = this, disorderedElements = _this1._disorderedElements;
|
|
1830
|
+
disorderedElements.forEach(function(element) {
|
|
1831
|
+
if (_instanceof(element, UICanvas)) {
|
|
1832
|
+
var rootCanvas = Utils.searchRootCanvasInParents(element);
|
|
1833
|
+
element._setIsRootCanvas(!rootCanvas);
|
|
1834
|
+
Utils.setRootCanvas(element, rootCanvas);
|
|
1835
|
+
} else {
|
|
1836
|
+
Utils.setRootCanvasDirty(_this);
|
|
1837
|
+
Utils.setGroupDirty(element);
|
|
1838
|
+
}
|
|
1839
|
+
});
|
|
1840
|
+
disorderedElements.length = 0;
|
|
1841
|
+
disorderedElements.garbageCollection();
|
|
1842
|
+
this._orderedRenderers.length = 0;
|
|
1843
|
+
}
|
|
2365
1844
|
}
|
|
2366
1845
|
};
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
1846
|
+
_proto._getCenter = function _getCenter() {
|
|
1847
|
+
if (this._centerDirtyFlag.flag) {
|
|
1848
|
+
var center = this._center;
|
|
1849
|
+
var uiTransform = this.entity.transform;
|
|
1850
|
+
var pivot = uiTransform.pivot, size = uiTransform.size;
|
|
1851
|
+
center.set((0.5 - pivot.x) * size.x, (0.5 - pivot.y) * size.y, 0);
|
|
1852
|
+
engine.Vector3.transformCoordinate(center, uiTransform.worldMatrix, center);
|
|
1853
|
+
this._centerDirtyFlag.flag = false;
|
|
2373
1854
|
}
|
|
1855
|
+
return this._center;
|
|
2374
1856
|
};
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
1857
|
+
_proto._getRealRenderMode = function _getRealRenderMode() {
|
|
1858
|
+
if (this._isRootCanvas) {
|
|
1859
|
+
var _this__camera;
|
|
1860
|
+
var mode = this._renderMode;
|
|
1861
|
+
// @ts-ignore
|
|
1862
|
+
if (mode === CanvasRenderMode.ScreenSpaceCamera && !((_this__camera = this._camera) == null ? void 0 : _this__camera._phasedActiveInScene)) {
|
|
1863
|
+
return CanvasRenderMode.ScreenSpaceOverlay;
|
|
1864
|
+
} else {
|
|
1865
|
+
return mode;
|
|
1866
|
+
}
|
|
1867
|
+
} else {
|
|
1868
|
+
return 4;
|
|
2380
1869
|
}
|
|
2381
1870
|
};
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
var
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
1871
|
+
_proto._setRealRenderMode = function _setRealRenderMode(curRealMode) {
|
|
1872
|
+
var preRealMode = this._realRenderMode;
|
|
1873
|
+
if (preRealMode !== curRealMode) {
|
|
1874
|
+
this._realRenderMode = curRealMode;
|
|
1875
|
+
// @ts-ignore
|
|
1876
|
+
var componentsManager = this.scene._componentsManager;
|
|
1877
|
+
switch(preRealMode){
|
|
1878
|
+
case CanvasRenderMode.ScreenSpaceOverlay:
|
|
1879
|
+
this._removeCanvasListener();
|
|
1880
|
+
case CanvasRenderMode.ScreenSpaceCamera:
|
|
1881
|
+
case CanvasRenderMode.WorldSpace:
|
|
1882
|
+
componentsManager.removeUICanvas(this, preRealMode === CanvasRenderMode.ScreenSpaceOverlay);
|
|
1883
|
+
break;
|
|
1884
|
+
}
|
|
1885
|
+
switch(curRealMode){
|
|
1886
|
+
case CanvasRenderMode.ScreenSpaceOverlay:
|
|
1887
|
+
this._addCanvasListener();
|
|
1888
|
+
case CanvasRenderMode.ScreenSpaceCamera:
|
|
1889
|
+
this._adapterPoseInScreenSpace();
|
|
1890
|
+
this._adapterSizeInScreenSpace();
|
|
1891
|
+
case CanvasRenderMode.WorldSpace:
|
|
1892
|
+
componentsManager.addUICanvas(this, curRealMode === CanvasRenderMode.ScreenSpaceOverlay);
|
|
1893
|
+
break;
|
|
2391
1894
|
}
|
|
2392
|
-
this._globalInteractiveDirty = false;
|
|
2393
1895
|
}
|
|
2394
|
-
return this._globalInteractive;
|
|
2395
1896
|
};
|
|
2396
|
-
_proto.
|
|
2397
|
-
var
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
1897
|
+
_proto._isSameOrChildEntity = function _isSameOrChildEntity(cameraEntity) {
|
|
1898
|
+
var canvasEntity = this.entity;
|
|
1899
|
+
while(cameraEntity){
|
|
1900
|
+
if (cameraEntity === canvasEntity) return true;
|
|
1901
|
+
cameraEntity = cameraEntity.parent;
|
|
1902
|
+
}
|
|
1903
|
+
return false;
|
|
1904
|
+
};
|
|
1905
|
+
_create_class(UICanvas, [
|
|
1906
|
+
{
|
|
1907
|
+
key: "referenceResolutionPerUnit",
|
|
1908
|
+
get: /**
|
|
1909
|
+
* The conversion ratio between reference resolution and unit for UI elements in this canvas.
|
|
1910
|
+
*/ function get() {
|
|
1911
|
+
return this._referenceResolutionPerUnit;
|
|
1912
|
+
},
|
|
1913
|
+
set: function set(value) {
|
|
1914
|
+
if (this._referenceResolutionPerUnit !== value) {
|
|
1915
|
+
this._referenceResolutionPerUnit = value;
|
|
1916
|
+
this._disorderedElements.forEach(function(element) {
|
|
1917
|
+
element._onRootCanvasModify == null ? void 0 : element._onRootCanvasModify.call(element, 1);
|
|
1918
|
+
});
|
|
1919
|
+
}
|
|
1920
|
+
}
|
|
1921
|
+
},
|
|
1922
|
+
{
|
|
1923
|
+
key: "referenceResolution",
|
|
1924
|
+
get: /**
|
|
1925
|
+
* The reference resolution of the UI canvas in `ScreenSpaceCamera` and `ScreenSpaceOverlay` mode.
|
|
1926
|
+
*/ function get() {
|
|
1927
|
+
return this._referenceResolution;
|
|
1928
|
+
},
|
|
1929
|
+
set: function set(value) {
|
|
1930
|
+
var referenceResolution = this._referenceResolution;
|
|
1931
|
+
if (referenceResolution === value) return;
|
|
1932
|
+
(referenceResolution.x !== value.x || referenceResolution.y !== value.y) && referenceResolution.copyFrom(value);
|
|
1933
|
+
}
|
|
1934
|
+
},
|
|
1935
|
+
{
|
|
1936
|
+
key: "renderMode",
|
|
1937
|
+
get: /**
|
|
1938
|
+
* The rendering mode of the UI canvas.
|
|
1939
|
+
*/ function get() {
|
|
1940
|
+
return this._renderMode;
|
|
1941
|
+
},
|
|
1942
|
+
set: function set(mode) {
|
|
1943
|
+
var preMode = this._renderMode;
|
|
1944
|
+
if (preMode !== mode) {
|
|
1945
|
+
this._renderMode = mode;
|
|
1946
|
+
this._updateCameraObserver();
|
|
1947
|
+
this._setRealRenderMode(this._getRealRenderMode());
|
|
1948
|
+
}
|
|
1949
|
+
}
|
|
1950
|
+
},
|
|
1951
|
+
{
|
|
1952
|
+
key: "camera",
|
|
1953
|
+
get: /**
|
|
1954
|
+
* The camera associated with this canvas.
|
|
1955
|
+
* @remarks
|
|
1956
|
+
* - `ScreenSpaceCamera` mode: Used for rendering adaptation. Defaults to `ScreenSpaceOverlay` if not assigned.
|
|
1957
|
+
* - `WorldSpace` mode: Used for event detection. If not assigned, events are handled by the highest-priority camera.
|
|
1958
|
+
*/ function get() {
|
|
1959
|
+
return this._camera;
|
|
1960
|
+
},
|
|
1961
|
+
set: function set(value) {
|
|
1962
|
+
var preCamera = this._camera;
|
|
1963
|
+
if (preCamera !== value) {
|
|
1964
|
+
if (value && this._isSameOrChildEntity(value.entity)) {
|
|
1965
|
+
engine.Logger.warn("Camera entity matching or nested within the canvas entity disables canvas auto-adaptation in ScreenSpaceCamera mode.");
|
|
1966
|
+
}
|
|
1967
|
+
this._camera = value;
|
|
1968
|
+
this._updateCameraObserver();
|
|
1969
|
+
var preRenderMode = this._realRenderMode;
|
|
1970
|
+
var curRenderMode = this._getRealRenderMode();
|
|
1971
|
+
if (preRenderMode === curRenderMode) {
|
|
1972
|
+
if (curRenderMode === CanvasRenderMode.ScreenSpaceCamera) {
|
|
1973
|
+
this._adapterPoseInScreenSpace();
|
|
1974
|
+
this._adapterSizeInScreenSpace();
|
|
1975
|
+
}
|
|
1976
|
+
} else {
|
|
1977
|
+
this._setRealRenderMode(curRenderMode);
|
|
1978
|
+
}
|
|
1979
|
+
}
|
|
1980
|
+
}
|
|
1981
|
+
},
|
|
1982
|
+
{
|
|
1983
|
+
key: "renderCamera",
|
|
1984
|
+
get: /**
|
|
1985
|
+
* @deprecated Use {@link camera} instead.
|
|
1986
|
+
*/ function get() {
|
|
1987
|
+
return this.camera;
|
|
1988
|
+
},
|
|
1989
|
+
set: function set(value) {
|
|
1990
|
+
this.camera = value;
|
|
2403
1991
|
}
|
|
2404
|
-
}
|
|
2405
|
-
};
|
|
2406
|
-
_proto._getInteractiveState = function _getInteractiveState() {
|
|
2407
|
-
if (!this._getGlobalInteractive()) {
|
|
2408
|
-
return 3;
|
|
2409
|
-
}
|
|
2410
|
-
if (this._isPointerDragging) {
|
|
2411
|
-
return 1;
|
|
2412
|
-
} else {
|
|
2413
|
-
return this._isPointerInside ? 2 : 0;
|
|
2414
|
-
}
|
|
2415
|
-
};
|
|
2416
|
-
_create_class(UIInteractive, [
|
|
1992
|
+
},
|
|
2417
1993
|
{
|
|
2418
|
-
key: "
|
|
1994
|
+
key: "resolutionAdaptationMode",
|
|
2419
1995
|
get: /**
|
|
2420
|
-
* The
|
|
1996
|
+
* The screen resolution adaptation mode of the UI canvas in `ScreenSpaceCamera` and `ScreenSpaceOverlay` mode.
|
|
2421
1997
|
*/ function get() {
|
|
2422
|
-
return this.
|
|
1998
|
+
return this._resolutionAdaptationMode;
|
|
1999
|
+
},
|
|
2000
|
+
set: function set(value) {
|
|
2001
|
+
if (this._resolutionAdaptationMode !== value) {
|
|
2002
|
+
this._resolutionAdaptationMode = value;
|
|
2003
|
+
var realRenderMode = this._realRenderMode;
|
|
2004
|
+
if (realRenderMode === CanvasRenderMode.ScreenSpaceCamera || realRenderMode === CanvasRenderMode.ScreenSpaceOverlay) {
|
|
2005
|
+
this._adapterSizeInScreenSpace();
|
|
2006
|
+
}
|
|
2007
|
+
}
|
|
2423
2008
|
}
|
|
2424
2009
|
},
|
|
2425
2010
|
{
|
|
2426
|
-
key: "
|
|
2011
|
+
key: "sortOrder",
|
|
2427
2012
|
get: /**
|
|
2428
|
-
*
|
|
2013
|
+
* The rendering order priority of the UI canvas in `ScreenSpaceOverlay` mode.
|
|
2429
2014
|
*/ function get() {
|
|
2430
|
-
return this.
|
|
2015
|
+
return this._sortOrder;
|
|
2431
2016
|
},
|
|
2432
2017
|
set: function set(value) {
|
|
2433
|
-
if (this.
|
|
2434
|
-
this.
|
|
2435
|
-
this.
|
|
2018
|
+
if (this._sortOrder !== value) {
|
|
2019
|
+
this._sortOrder = value;
|
|
2020
|
+
this._realRenderMode === CanvasRenderMode.ScreenSpaceOverlay && // @ts-ignore
|
|
2021
|
+
(this.scene._componentsManager._overlayCanvasesSortingFlag = true);
|
|
2022
|
+
}
|
|
2023
|
+
}
|
|
2024
|
+
},
|
|
2025
|
+
{
|
|
2026
|
+
key: "distance",
|
|
2027
|
+
get: /**
|
|
2028
|
+
* The distance between the UI canvas and the camera in `ScreenSpaceCamera` mode.
|
|
2029
|
+
*/ function get() {
|
|
2030
|
+
return this._distance;
|
|
2031
|
+
},
|
|
2032
|
+
set: function set(value) {
|
|
2033
|
+
if (this._distance !== value) {
|
|
2034
|
+
this._distance = value;
|
|
2035
|
+
if (this._realRenderMode === CanvasRenderMode.ScreenSpaceCamera) {
|
|
2036
|
+
this._adapterPoseInScreenSpace();
|
|
2037
|
+
this._adapterSizeInScreenSpace();
|
|
2038
|
+
}
|
|
2436
2039
|
}
|
|
2437
2040
|
}
|
|
2438
2041
|
}
|
|
2439
2042
|
]);
|
|
2440
|
-
return
|
|
2441
|
-
}(engine.
|
|
2043
|
+
return UICanvas;
|
|
2044
|
+
}(engine.Component);
|
|
2045
|
+
/** @internal */ exports.UICanvas._hierarchyCounter = 1;
|
|
2046
|
+
exports.UICanvas._tempGroupAbleList = [];
|
|
2047
|
+
exports.UICanvas._tempVec3 = new engine.Vector3();
|
|
2048
|
+
exports.UICanvas._tempMat = new engine.Matrix();
|
|
2442
2049
|
__decorate([
|
|
2443
2050
|
engine.ignoreClone
|
|
2444
|
-
],
|
|
2051
|
+
], exports.UICanvas.prototype, "_canvasIndex", void 0);
|
|
2445
2052
|
__decorate([
|
|
2446
2053
|
engine.ignoreClone
|
|
2447
|
-
],
|
|
2054
|
+
], exports.UICanvas.prototype, "_indexInRootCanvas", void 0);
|
|
2448
2055
|
__decorate([
|
|
2449
2056
|
engine.ignoreClone
|
|
2450
|
-
],
|
|
2057
|
+
], exports.UICanvas.prototype, "_isRootCanvasDirty", void 0);
|
|
2451
2058
|
__decorate([
|
|
2452
2059
|
engine.ignoreClone
|
|
2453
|
-
],
|
|
2060
|
+
], exports.UICanvas.prototype, "_rootCanvasListeningEntities", void 0);
|
|
2454
2061
|
__decorate([
|
|
2455
2062
|
engine.ignoreClone
|
|
2456
|
-
],
|
|
2063
|
+
], exports.UICanvas.prototype, "_isRootCanvas", void 0);
|
|
2457
2064
|
__decorate([
|
|
2458
2065
|
engine.ignoreClone
|
|
2459
|
-
],
|
|
2066
|
+
], exports.UICanvas.prototype, "_renderElements", void 0);
|
|
2460
2067
|
__decorate([
|
|
2461
2068
|
engine.ignoreClone
|
|
2462
|
-
],
|
|
2069
|
+
], exports.UICanvas.prototype, "_batchedRenderElements", void 0);
|
|
2463
2070
|
__decorate([
|
|
2464
2071
|
engine.ignoreClone
|
|
2465
|
-
],
|
|
2072
|
+
], exports.UICanvas.prototype, "_sortDistance", void 0);
|
|
2466
2073
|
__decorate([
|
|
2467
2074
|
engine.ignoreClone
|
|
2468
|
-
],
|
|
2075
|
+
], exports.UICanvas.prototype, "_orderedRenderers", void 0);
|
|
2469
2076
|
__decorate([
|
|
2470
2077
|
engine.ignoreClone
|
|
2471
|
-
],
|
|
2078
|
+
], exports.UICanvas.prototype, "_realRenderMode", void 0);
|
|
2472
2079
|
__decorate([
|
|
2473
2080
|
engine.ignoreClone
|
|
2474
|
-
],
|
|
2081
|
+
], exports.UICanvas.prototype, "_renderMode", void 0);
|
|
2475
2082
|
__decorate([
|
|
2476
2083
|
engine.ignoreClone
|
|
2477
|
-
],
|
|
2084
|
+
], exports.UICanvas.prototype, "_hierarchyVersion", void 0);
|
|
2478
2085
|
__decorate([
|
|
2479
2086
|
engine.ignoreClone
|
|
2480
|
-
],
|
|
2087
|
+
], exports.UICanvas.prototype, "_center", void 0);
|
|
2481
2088
|
__decorate([
|
|
2482
2089
|
engine.ignoreClone
|
|
2483
|
-
],
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2090
|
+
], exports.UICanvas.prototype, "_rootCanvasListener", null);
|
|
2091
|
+
__decorate([
|
|
2092
|
+
engine.ignoreClone
|
|
2093
|
+
], exports.UICanvas.prototype, "_onCameraModifyListener", null);
|
|
2094
|
+
__decorate([
|
|
2095
|
+
engine.ignoreClone
|
|
2096
|
+
], exports.UICanvas.prototype, "_onCameraTransformListener", null);
|
|
2097
|
+
__decorate([
|
|
2098
|
+
engine.ignoreClone
|
|
2099
|
+
], exports.UICanvas.prototype, "_onCanvasSizeListener", null);
|
|
2100
|
+
__decorate([
|
|
2101
|
+
engine.ignoreClone
|
|
2102
|
+
], exports.UICanvas.prototype, "_onReferenceResolutionChanged", null);
|
|
2103
|
+
exports.UICanvas = __decorate([
|
|
2104
|
+
engine.dependentComponents(UITransform, engine.DependentMode.AutoAdd)
|
|
2105
|
+
], exports.UICanvas);
|
|
2106
|
+
/**
|
|
2107
|
+
* @remarks Extends `EntityModifyFlags`.
|
|
2108
|
+
*/ var EntityUIModifyFlags = /*#__PURE__*/ function(EntityUIModifyFlags) {
|
|
2109
|
+
EntityUIModifyFlags[EntityUIModifyFlags["CanvasEnableInScene"] = 4] = "CanvasEnableInScene";
|
|
2110
|
+
EntityUIModifyFlags[EntityUIModifyFlags["GroupEnableInScene"] = 8] = "GroupEnableInScene";
|
|
2111
|
+
return EntityUIModifyFlags;
|
|
2112
|
+
}({});
|
|
2113
|
+
var RootCanvasModifyFlags = /*#__PURE__*/ function(RootCanvasModifyFlags) {
|
|
2114
|
+
RootCanvasModifyFlags[RootCanvasModifyFlags["None"] = 0] = "None";
|
|
2115
|
+
RootCanvasModifyFlags[RootCanvasModifyFlags["ReferenceResolutionPerUnit"] = 1] = "ReferenceResolutionPerUnit";
|
|
2116
|
+
RootCanvasModifyFlags[RootCanvasModifyFlags["All"] = 1] = "All";
|
|
2117
|
+
return RootCanvasModifyFlags;
|
|
2490
2118
|
}({});
|
|
2491
2119
|
|
|
2492
2120
|
var Button = /*#__PURE__*/ function(UIInteractive) {
|
|
@@ -2526,7 +2154,7 @@ var Button = /*#__PURE__*/ function(UIInteractive) {
|
|
|
2526
2154
|
_inherits(Image, UIRenderer1);
|
|
2527
2155
|
function Image(entity) {
|
|
2528
2156
|
var _this;
|
|
2529
|
-
_this = UIRenderer1.call(this, entity) || this, _this._sprite = null, _this._tileMode = engine.SpriteTileMode.Continuous, _this._tiledAdaptiveThreshold = 0.5
|
|
2157
|
+
_this = UIRenderer1.call(this, entity) || this, _this._sprite = null, _this._tileMode = engine.SpriteTileMode.Continuous, _this._tiledAdaptiveThreshold = 0.5;
|
|
2530
2158
|
_this.drawMode = engine.SpriteDrawMode.Simple;
|
|
2531
2159
|
// @ts-ignore
|
|
2532
2160
|
_this.setMaterial(_this._engine._getUIDefaultMaterial());
|
|
@@ -2614,7 +2242,7 @@ var Button = /*#__PURE__*/ function(UIInteractive) {
|
|
|
2614
2242
|
canvas._renderElements.push(renderElement);
|
|
2615
2243
|
};
|
|
2616
2244
|
_proto._onTransformChanged = function _onTransformChanged(type) {
|
|
2617
|
-
if (type & UITransformModifyFlags.Size &&
|
|
2245
|
+
if (type & UITransformModifyFlags.Size && this._drawMode === engine.SpriteDrawMode.Tiled) {
|
|
2618
2246
|
this._dirtyUpdateFlag |= 15;
|
|
2619
2247
|
}
|
|
2620
2248
|
this._dirtyUpdateFlag |= engine.RendererUpdateFlags.WorldVolume;
|
|
@@ -2642,9 +2270,6 @@ var Button = /*#__PURE__*/ function(UIInteractive) {
|
|
|
2642
2270
|
case engine.SpriteDrawMode.Tiled:
|
|
2643
2271
|
this._dirtyUpdateFlag |= 7;
|
|
2644
2272
|
break;
|
|
2645
|
-
case engine.SpriteDrawMode.Filled:
|
|
2646
|
-
this._dirtyUpdateFlag |= 7;
|
|
2647
|
-
break;
|
|
2648
2273
|
}
|
|
2649
2274
|
break;
|
|
2650
2275
|
case engine.SpriteModifyFlags.border:
|
|
@@ -2662,25 +2287,13 @@ var Button = /*#__PURE__*/ function(UIInteractive) {
|
|
|
2662
2287
|
this._dirtyUpdateFlag |= 5;
|
|
2663
2288
|
break;
|
|
2664
2289
|
case engine.SpriteModifyFlags.atlasRegion:
|
|
2665
|
-
this._dirtyUpdateFlag |=
|
|
2290
|
+
this._dirtyUpdateFlag |= 4;
|
|
2666
2291
|
break;
|
|
2667
2292
|
case engine.SpriteModifyFlags.destroy:
|
|
2668
2293
|
this.sprite = null;
|
|
2669
2294
|
break;
|
|
2670
2295
|
}
|
|
2671
2296
|
};
|
|
2672
|
-
Image._correctOrigin = function _correctOrigin(mode, origin) {
|
|
2673
|
-
switch(mode){
|
|
2674
|
-
case engine.SpriteFilledMode.Horizontal:
|
|
2675
|
-
return origin === engine.SpriteFilledOrigin.Left || origin === engine.SpriteFilledOrigin.Right ? origin : engine.SpriteFilledOrigin.Left;
|
|
2676
|
-
case engine.SpriteFilledMode.Vertical:
|
|
2677
|
-
return origin === engine.SpriteFilledOrigin.Top || origin === engine.SpriteFilledOrigin.Bottom ? origin : engine.SpriteFilledOrigin.Bottom;
|
|
2678
|
-
case engine.SpriteFilledMode.Radial90:
|
|
2679
|
-
return origin === engine.SpriteFilledOrigin.TopLeft || origin === engine.SpriteFilledOrigin.TopRight || origin === engine.SpriteFilledOrigin.BottomLeft || origin === engine.SpriteFilledOrigin.BottomRight ? origin : engine.SpriteFilledOrigin.BottomLeft;
|
|
2680
|
-
default:
|
|
2681
|
-
return origin === engine.SpriteFilledOrigin.Top || origin === engine.SpriteFilledOrigin.Bottom || origin === engine.SpriteFilledOrigin.Left || origin === engine.SpriteFilledOrigin.Right ? origin : engine.SpriteFilledOrigin.Bottom;
|
|
2682
|
-
}
|
|
2683
|
-
};
|
|
2684
2297
|
_create_class(Image, [
|
|
2685
2298
|
{
|
|
2686
2299
|
key: "drawMode",
|
|
@@ -2702,9 +2315,6 @@ var Button = /*#__PURE__*/ function(UIInteractive) {
|
|
|
2702
2315
|
case engine.SpriteDrawMode.Tiled:
|
|
2703
2316
|
this._assembler = engine.TiledSpriteAssembler;
|
|
2704
2317
|
break;
|
|
2705
|
-
case engine.SpriteDrawMode.Filled:
|
|
2706
|
-
this._assembler = engine.FilledSpriteAssembler;
|
|
2707
|
-
break;
|
|
2708
2318
|
}
|
|
2709
2319
|
this._assembler.resetData(this);
|
|
2710
2320
|
this._dirtyUpdateFlag |= 7;
|
|
@@ -2744,73 +2354,6 @@ var Button = /*#__PURE__*/ function(UIInteractive) {
|
|
|
2744
2354
|
}
|
|
2745
2355
|
}
|
|
2746
2356
|
},
|
|
2747
|
-
{
|
|
2748
|
-
key: "filledAmount",
|
|
2749
|
-
get: /**
|
|
2750
|
-
* The fill amount of the image, range from 0 to 1. (Only works in filled mode.)
|
|
2751
|
-
*/ function get() {
|
|
2752
|
-
return this._filledAmount;
|
|
2753
|
-
},
|
|
2754
|
-
set: function set(value) {
|
|
2755
|
-
value = engine.MathUtil.clamp(value, 0, 1);
|
|
2756
|
-
if (this._filledAmount !== value) {
|
|
2757
|
-
this._filledAmount = value;
|
|
2758
|
-
if (this._drawMode === engine.SpriteDrawMode.Filled) {
|
|
2759
|
-
this._dirtyUpdateFlag |= 5;
|
|
2760
|
-
}
|
|
2761
|
-
}
|
|
2762
|
-
}
|
|
2763
|
-
},
|
|
2764
|
-
{
|
|
2765
|
-
key: "filledMode",
|
|
2766
|
-
get: /**
|
|
2767
|
-
* The fill mode of the image. (Only works in filled mode.)
|
|
2768
|
-
*/ function get() {
|
|
2769
|
-
return this._filledMode;
|
|
2770
|
-
},
|
|
2771
|
-
set: function set(value) {
|
|
2772
|
-
if (this._filledMode !== value) {
|
|
2773
|
-
this._filledMode = value;
|
|
2774
|
-
this._filledOrigin = Image._correctOrigin(value, this._filledOrigin);
|
|
2775
|
-
if (this._drawMode === engine.SpriteDrawMode.Filled) {
|
|
2776
|
-
this._dirtyUpdateFlag |= 5;
|
|
2777
|
-
}
|
|
2778
|
-
}
|
|
2779
|
-
}
|
|
2780
|
-
},
|
|
2781
|
-
{
|
|
2782
|
-
key: "filledOrigin",
|
|
2783
|
-
get: /**
|
|
2784
|
-
* The fill origin of the image. (Only works in filled mode.)
|
|
2785
|
-
*/ function get() {
|
|
2786
|
-
return this._filledOrigin;
|
|
2787
|
-
},
|
|
2788
|
-
set: function set(value) {
|
|
2789
|
-
value = Image._correctOrigin(this._filledMode, value);
|
|
2790
|
-
if (this._filledOrigin !== value) {
|
|
2791
|
-
this._filledOrigin = value;
|
|
2792
|
-
if (this._drawMode === engine.SpriteDrawMode.Filled) {
|
|
2793
|
-
this._dirtyUpdateFlag |= 5;
|
|
2794
|
-
}
|
|
2795
|
-
}
|
|
2796
|
-
}
|
|
2797
|
-
},
|
|
2798
|
-
{
|
|
2799
|
-
key: "filledClockWise",
|
|
2800
|
-
get: /**
|
|
2801
|
-
* Whether the fill is clockwise. (Only works in filled radial mode.)
|
|
2802
|
-
*/ function get() {
|
|
2803
|
-
return this._filledClockWise;
|
|
2804
|
-
},
|
|
2805
|
-
set: function set(value) {
|
|
2806
|
-
if (this._filledClockWise !== value) {
|
|
2807
|
-
this._filledClockWise = value;
|
|
2808
|
-
if (this._drawMode === engine.SpriteDrawMode.Filled) {
|
|
2809
|
-
this._dirtyUpdateFlag |= 5;
|
|
2810
|
-
}
|
|
2811
|
-
}
|
|
2812
|
-
}
|
|
2813
|
-
},
|
|
2814
2357
|
{
|
|
2815
2358
|
key: "sprite",
|
|
2816
2359
|
get: /**
|
|
@@ -2858,87 +2401,19 @@ __decorate([
|
|
|
2858
2401
|
engine.ignoreClone
|
|
2859
2402
|
], Image.prototype, "_onSpriteChange", null);
|
|
2860
2403
|
|
|
2861
|
-
/**
|
|
2862
|
-
* UI component that uses a sprite to mask child UI renderers via stencil.
|
|
2863
|
-
*/ var Mask = /*#__PURE__*/ function(_MaskRenderable) {
|
|
2864
|
-
_inherits(Mask, _MaskRenderable);
|
|
2865
|
-
function Mask(entity) {
|
|
2866
|
-
var _this;
|
|
2867
|
-
_this = _MaskRenderable.call(this, entity) || this;
|
|
2868
|
-
_this._initMask();
|
|
2869
|
-
_this.raycastEnabled = false;
|
|
2870
|
-
return _this;
|
|
2871
|
-
}
|
|
2872
|
-
var _proto = Mask.prototype;
|
|
2873
|
-
/**
|
|
2874
|
-
* @internal
|
|
2875
|
-
*/ _proto._getChunkManager = function _getChunkManager() {
|
|
2876
|
-
// @ts-ignore
|
|
2877
|
-
return this.engine._batcherManager.primitiveChunkManagerMask;
|
|
2878
|
-
};
|
|
2879
|
-
/**
|
|
2880
|
-
* @internal
|
|
2881
|
-
*/ // @ts-ignore
|
|
2882
|
-
_proto._onClone = function _onClone(target) {
|
|
2883
|
-
// @ts-ignore
|
|
2884
|
-
_MaskRenderable.prototype._onClone.call(this, target);
|
|
2885
|
-
this._cloneMaskData(target);
|
|
2886
|
-
};
|
|
2887
|
-
_proto._updateBounds = function _updateBounds(worldBounds) {
|
|
2888
|
-
var rootCanvas = this._getRootCanvas();
|
|
2889
|
-
if (this.sprite && rootCanvas) {
|
|
2890
|
-
this._updateMaskBounds(worldBounds);
|
|
2891
|
-
} else {
|
|
2892
|
-
var worldPosition = this._transformEntity.transform.worldPosition;
|
|
2893
|
-
worldBounds.min.copyFrom(worldPosition);
|
|
2894
|
-
worldBounds.max.copyFrom(worldPosition);
|
|
2895
|
-
}
|
|
2896
|
-
};
|
|
2897
|
-
/**
|
|
2898
|
-
* @inheritdoc
|
|
2899
|
-
*/ _proto._render = function _render(context) {
|
|
2900
|
-
this._renderMask(0);
|
|
2901
|
-
};
|
|
2902
|
-
/**
|
|
2903
|
-
* @inheritdoc
|
|
2904
|
-
*/ _proto._onDestroy = function _onDestroy() {
|
|
2905
|
-
this._destroyMaskResources();
|
|
2906
|
-
_MaskRenderable.prototype._onDestroy.call(this);
|
|
2907
|
-
if (this._subChunk) {
|
|
2908
|
-
this._getChunkManager().freeSubChunk(this._subChunk);
|
|
2909
|
-
this._subChunk = null;
|
|
2910
|
-
}
|
|
2911
|
-
};
|
|
2912
|
-
_proto._getSpriteWidth = function _getSpriteWidth() {
|
|
2913
|
-
return this._transformEntity.transform.size.x;
|
|
2914
|
-
};
|
|
2915
|
-
_proto._getSpriteHeight = function _getSpriteHeight() {
|
|
2916
|
-
return this._transformEntity.transform.size.y;
|
|
2917
|
-
};
|
|
2918
|
-
_proto._getSpritePivot = function _getSpritePivot() {
|
|
2919
|
-
return this._transformEntity.transform.pivot;
|
|
2920
|
-
};
|
|
2921
|
-
return Mask;
|
|
2922
|
-
}(engine.MaskRenderable(exports.UIRenderer));
|
|
2923
|
-
|
|
2924
2404
|
/**
|
|
2925
2405
|
* UI component used to render text.
|
|
2926
2406
|
*/ var Text = /*#__PURE__*/ function(UIRenderer1) {
|
|
2927
2407
|
_inherits(Text, UIRenderer1);
|
|
2928
2408
|
function Text(entity) {
|
|
2929
2409
|
var _this;
|
|
2930
|
-
_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
|
|
2410
|
+
_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;
|
|
2931
2411
|
var engine$1 = _this.engine;
|
|
2932
2412
|
// @ts-ignore
|
|
2933
2413
|
_this.font = engine$1._textDefaultFont;
|
|
2934
2414
|
_this.raycastEnabled = false;
|
|
2935
2415
|
// @ts-ignore
|
|
2936
2416
|
_this.setMaterial(engine$1._basicResources.textDefaultMaterial);
|
|
2937
|
-
var shaderData = _this.shaderData;
|
|
2938
|
-
shaderData.setFloat(Text._outlineWidthProperty, _this._outlineWidth);
|
|
2939
|
-
shaderData.setColor(Text._outlineColorProperty, _this._outlineColor);
|
|
2940
|
-
// @ts-ignore
|
|
2941
|
-
_this._outlineColor._onValueChanged = _this._onOutlineColorChanged.bind(_this);
|
|
2942
2417
|
return _this;
|
|
2943
2418
|
}
|
|
2944
2419
|
var _proto = Text.prototype;
|
|
@@ -2984,13 +2459,13 @@ __decorate([
|
|
|
2984
2459
|
this._setDirtyFlagTrue(25);
|
|
2985
2460
|
}
|
|
2986
2461
|
};
|
|
2987
|
-
/**
|
|
2988
|
-
* @internal
|
|
2989
|
-
*/ _proto._canBatch = function _canBatch(preElement, curElement) {
|
|
2990
|
-
return engine.VertexMergeBatcher.canBatchText(preElement, curElement);
|
|
2991
|
-
};
|
|
2992
2462
|
_proto._updateBounds = function _updateBounds(worldBounds) {
|
|
2993
|
-
|
|
2463
|
+
var transform = this._transformEntity.transform;
|
|
2464
|
+
var _transform_size = transform.size, width = _transform_size.x, height = _transform_size.y;
|
|
2465
|
+
var _transform_pivot = transform.pivot, pivotX = _transform_pivot.x, pivotY = _transform_pivot.y;
|
|
2466
|
+
worldBounds.min.set(-width * pivotX, -height * pivotY, 0);
|
|
2467
|
+
worldBounds.max.set(width * (1 - pivotX), height * (1 - pivotY), 0);
|
|
2468
|
+
engine.BoundingBox.transform(worldBounds, this._transformEntity.transform.worldMatrix, worldBounds);
|
|
2994
2469
|
};
|
|
2995
2470
|
_proto._render = function _render(context) {
|
|
2996
2471
|
if (this._isTextNoVisible()) {
|
|
@@ -3021,7 +2496,6 @@ __decorate([
|
|
|
3021
2496
|
var distanceForSort = canvas._sortDistance;
|
|
3022
2497
|
var textChunks = this._textChunks;
|
|
3023
2498
|
var subShader = material.shader.subShaders[0];
|
|
3024
|
-
var textTextureSize = Text._tempVec20;
|
|
3025
2499
|
for(var i = 0, n = textChunks.length; i < n; ++i){
|
|
3026
2500
|
var // @ts-ignore
|
|
3027
2501
|
_renderElement;
|
|
@@ -3030,7 +2504,6 @@ __decorate([
|
|
|
3030
2504
|
renderElement.set(this, material, subChunk.chunk.primitive, subChunk.subMesh, texture, subChunk);
|
|
3031
2505
|
(_renderElement = renderElement).shaderData || (_renderElement.shaderData = new engine.ShaderData(engine.ShaderDataGroup.RenderElement));
|
|
3032
2506
|
renderElement.shaderData.setTexture(Text._textTextureProperty, texture);
|
|
3033
|
-
renderElement.shaderData.setVector2(Text._textTextureSizeProperty, textTextureSize.set(texture.width, texture.height));
|
|
3034
2507
|
renderElement.subShader = subShader;
|
|
3035
2508
|
renderElement.priority = priority;
|
|
3036
2509
|
renderElement.distanceForSort = distanceForSort;
|
|
@@ -3043,15 +2516,6 @@ __decorate([
|
|
|
3043
2516
|
this._subFont = font._getSubFont(this.fontSize, this.fontStyle);
|
|
3044
2517
|
this._subFont.nativeFontString = engine.TextUtils.getNativeFontString(font.name, this.fontSize, this.fontStyle);
|
|
3045
2518
|
};
|
|
3046
|
-
/**
|
|
3047
|
-
* Switch the sub font to a specific font size, used by the SHRINK overflow measurement.
|
|
3048
|
-
*/ _proto._applyFontSizeForShrink = function _applyFontSizeForShrink(fontSize) {
|
|
3049
|
-
var font = this._font;
|
|
3050
|
-
// @ts-ignore
|
|
3051
|
-
var subFont = font._getSubFont(fontSize, this._fontStyle);
|
|
3052
|
-
subFont.nativeFontString = engine.TextUtils.getNativeFontString(font.name, fontSize, this._fontStyle);
|
|
3053
|
-
this._subFont = subFont;
|
|
3054
|
-
};
|
|
3055
2519
|
_proto._updatePosition = function _updatePosition() {
|
|
3056
2520
|
var e = this._transformEntity.transform.worldMatrix.elements;
|
|
3057
2521
|
// prettier-ignore
|
|
@@ -3104,30 +2568,18 @@ __decorate([
|
|
|
3104
2568
|
}
|
|
3105
2569
|
};
|
|
3106
2570
|
_proto._updateLocalData = function _updateLocalData() {
|
|
3107
|
-
var _this = this;
|
|
3108
2571
|
// @ts-ignore
|
|
3109
2572
|
var pixelsPerResolution = engine.Engine._pixelsPerUnit / this._getRootCanvas().referenceResolutionPerUnit;
|
|
3110
2573
|
var _this__localBounds = this._localBounds, min = _this__localBounds.min, max = _this__localBounds.max;
|
|
3111
2574
|
var charRenderInfos = Text._charRenderInfos;
|
|
2575
|
+
var charFont = this._getSubFont();
|
|
3112
2576
|
var _this__transformEntity_transform = this._transformEntity.transform, size = _this__transformEntity_transform.size, pivot = _this__transformEntity_transform.pivot;
|
|
3113
2577
|
var rendererWidth = size.x;
|
|
3114
2578
|
var rendererHeight = size.y;
|
|
3115
2579
|
var offsetWidth = rendererWidth * (0.5 - pivot.x);
|
|
3116
2580
|
var offsetHeight = rendererHeight * (0.5 - pivot.y);
|
|
3117
|
-
var
|
|
3118
|
-
var textMetrics;
|
|
3119
|
-
if (this._overflowMode === engine.OverflowMode.Shrink) {
|
|
3120
|
-
var result = engine.TextUtils.measureTextWithShrink(this, rendererWidth * pixelsPerResolution, rendererHeight * pixelsPerResolution, this._fontSize, this._lineSpacing, this._characterSpacing, this.enableWrapping, function(sizeValue) {
|
|
3121
|
-
return _this._applyFontSizeForShrink(sizeValue);
|
|
3122
|
-
});
|
|
3123
|
-
fontSize = result.fontSize;
|
|
3124
|
-
textMetrics = result.metrics;
|
|
3125
|
-
} else {
|
|
3126
|
-
var characterSpacing = this._characterSpacing * fontSize;
|
|
3127
|
-
textMetrics = this.enableWrapping ? engine.TextUtils.measureTextWithWrap(this, rendererWidth * pixelsPerResolution, rendererHeight * pixelsPerResolution, this._lineSpacing * fontSize, characterSpacing) : engine.TextUtils.measureTextWithoutWrap(this, rendererHeight * pixelsPerResolution, this._lineSpacing * fontSize, characterSpacing);
|
|
3128
|
-
}
|
|
3129
|
-
var charFont = this._getSubFont();
|
|
3130
|
-
var characterSpacing1 = this._characterSpacing * fontSize;
|
|
2581
|
+
var characterSpacing = this._characterSpacing * this._fontSize;
|
|
2582
|
+
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);
|
|
3131
2583
|
var height = textMetrics.height, lines = textMetrics.lines, lineWidths = textMetrics.lineWidths, lineHeight = textMetrics.lineHeight, lineMaxSizes = textMetrics.lineMaxSizes;
|
|
3132
2584
|
// @ts-ignore
|
|
3133
2585
|
var charRenderInfoPool = this.engine._charRenderInfoPool;
|
|
@@ -3148,10 +2600,7 @@ __decorate([
|
|
|
3148
2600
|
startY = rendererHeight * 0.5 - halfLineHeight + topDiff;
|
|
3149
2601
|
break;
|
|
3150
2602
|
case engine.TextVerticalAlignment.Center:
|
|
3151
|
-
|
|
3152
|
-
// `height` — which equals the renderer height for Truncate/Shrink and would otherwise
|
|
3153
|
-
// push the text upward by (rendererHeight - blockHeight) / 2 when the box is taller.
|
|
3154
|
-
startY = lineHeight * linesLen * 0.5 - halfLineHeight - (bottomDiff - topDiff) * 0.5;
|
|
2603
|
+
startY = height * 0.5 - halfLineHeight - (bottomDiff - topDiff) * 0.5;
|
|
3155
2604
|
break;
|
|
3156
2605
|
case engine.TextVerticalAlignment.Bottom:
|
|
3157
2606
|
startY = height - rendererHeight * 0.5 - halfLineHeight - bottomDiff;
|
|
@@ -3192,18 +2641,17 @@ __decorate([
|
|
|
3192
2641
|
charRenderInfo.texture = charFont._getTextureByIndex(charInfo.index);
|
|
3193
2642
|
charRenderInfo.uvs = charInfo.uvs;
|
|
3194
2643
|
var w = charInfo.w, ascent = charInfo.ascent, descent = charInfo.descent;
|
|
3195
|
-
var
|
|
3196
|
-
var
|
|
3197
|
-
var
|
|
3198
|
-
var
|
|
3199
|
-
var bottom = (startY - descent + offsetHeight) * pixelsPerUnitReciprocal - ow;
|
|
2644
|
+
var left = (startX + offsetWidth) * pixelsPerUnitReciprocal;
|
|
2645
|
+
var right = (startX + w + offsetWidth) * pixelsPerUnitReciprocal;
|
|
2646
|
+
var top = (startY + ascent + offsetHeight) * pixelsPerUnitReciprocal;
|
|
2647
|
+
var bottom = (startY - descent + offsetHeight) * pixelsPerUnitReciprocal;
|
|
3200
2648
|
localPositions.set(left, top, right, bottom);
|
|
3201
2649
|
i === firstLine && (maxY = Math.max(maxY, top));
|
|
3202
2650
|
minY = Math.min(minY, bottom);
|
|
3203
2651
|
j === firstRow && (minX = Math.min(minX, left));
|
|
3204
2652
|
maxX = Math.max(maxX, right);
|
|
3205
2653
|
}
|
|
3206
|
-
startX += charInfo.xAdvance +
|
|
2654
|
+
startX += charInfo.xAdvance + characterSpacing;
|
|
3207
2655
|
}
|
|
3208
2656
|
}
|
|
3209
2657
|
startY -= lineHeight;
|
|
@@ -3263,7 +2711,7 @@ __decorate([
|
|
|
3263
2711
|
};
|
|
3264
2712
|
_proto._isTextNoVisible = function _isTextNoVisible() {
|
|
3265
2713
|
var size = this._transformEntity.transform.size;
|
|
3266
|
-
return !this._font || this._text === "" || this._fontSize === 0 || this.enableWrapping && size.x <= 0 ||
|
|
2714
|
+
return !this._font || this._text === "" || this._fontSize === 0 || this.enableWrapping && size.x <= 0 || this.overflowMode === engine.OverflowMode.Truncate && size.y <= 0 || !this._getRootCanvas();
|
|
3267
2715
|
};
|
|
3268
2716
|
_proto._buildChunk = function _buildChunk(textChunk, count) {
|
|
3269
2717
|
var _this_color = this.color, r = _this_color.r, g = _this_color.g, b = _this_color.b, a = _this_color.a;
|
|
@@ -3274,10 +2722,6 @@ __decorate([
|
|
|
3274
2722
|
var vertices = subChunk.chunk.vertices;
|
|
3275
2723
|
var indices = subChunk.indices = [];
|
|
3276
2724
|
var charRenderInfos = textChunk.charRenderInfos;
|
|
3277
|
-
var ow = this._outlineWidth;
|
|
3278
|
-
var texture = textChunk.texture;
|
|
3279
|
-
var owU = ow > 0 ? ow / texture.width : 0;
|
|
3280
|
-
var owV = ow > 0 ? ow / texture.height : 0;
|
|
3281
2725
|
for(var i = 0, ii = 0, io = 0, vo = subChunk.vertexArea.start + 3; i < count; ++i, io += 4){
|
|
3282
2726
|
var charRenderInfo = charRenderInfos[i];
|
|
3283
2727
|
charRenderInfo.indexInChunk = i;
|
|
@@ -3285,13 +2729,10 @@ __decorate([
|
|
|
3285
2729
|
for(var j = 0; j < tempIndicesLength; ++j){
|
|
3286
2730
|
indices[ii++] = tempIndices[j] + io;
|
|
3287
2731
|
}
|
|
3288
|
-
// Set uv and color for vertices
|
|
2732
|
+
// Set uv and color for vertices
|
|
3289
2733
|
for(var j1 = 0; j1 < 4; ++j1, vo += 9){
|
|
3290
2734
|
var uv = charRenderInfo.uvs[j1];
|
|
3291
|
-
|
|
3292
|
-
var sv = j1 >= 2 ? 1 : -1;
|
|
3293
|
-
vertices[vo] = uv.x + owU * su;
|
|
3294
|
-
vertices[vo + 1] = uv.y + owV * sv;
|
|
2735
|
+
uv.copyToArray(vertices, vo);
|
|
3295
2736
|
vertices[vo + 2] = r;
|
|
3296
2737
|
vertices[vo + 3] = g;
|
|
3297
2738
|
vertices[vo + 4] = b;
|
|
@@ -3318,9 +2759,6 @@ __decorate([
|
|
|
3318
2759
|
}
|
|
3319
2760
|
textChunks.length = 0;
|
|
3320
2761
|
};
|
|
3321
|
-
_proto._onOutlineColorChanged = function _onOutlineColorChanged() {
|
|
3322
|
-
this.shaderData.setColor(Text._outlineColorProperty, this._outlineColor);
|
|
3323
|
-
};
|
|
3324
2762
|
_create_class(Text, [
|
|
3325
2763
|
{
|
|
3326
2764
|
key: "text",
|
|
@@ -3467,32 +2905,14 @@ __decorate([
|
|
|
3467
2905
|
}
|
|
3468
2906
|
},
|
|
3469
2907
|
{
|
|
3470
|
-
key: "
|
|
3471
|
-
get: /**
|
|
3472
|
-
* The outline width in pixels. 0 means outline is disabled. Clamped to [0, 8].
|
|
3473
|
-
*/ function get() {
|
|
3474
|
-
return this._outlineWidth;
|
|
3475
|
-
},
|
|
3476
|
-
set: function set(value) {
|
|
3477
|
-
value = Math.max(0, Math.min(value, 3));
|
|
3478
|
-
if (this._outlineWidth !== value) {
|
|
3479
|
-
this._outlineWidth = value;
|
|
3480
|
-
this.shaderData.setFloat(Text._outlineWidthProperty, value);
|
|
3481
|
-
this._setDirtyFlagTrue(25);
|
|
3482
|
-
}
|
|
3483
|
-
}
|
|
3484
|
-
},
|
|
3485
|
-
{
|
|
3486
|
-
key: "outlineColor",
|
|
2908
|
+
key: "maskLayer",
|
|
3487
2909
|
get: /**
|
|
3488
|
-
* The
|
|
2910
|
+
* The mask layer the sprite renderer belongs to.
|
|
3489
2911
|
*/ function get() {
|
|
3490
|
-
return this.
|
|
2912
|
+
return this._maskLayer;
|
|
3491
2913
|
},
|
|
3492
2914
|
set: function set(value) {
|
|
3493
|
-
|
|
3494
|
-
this._outlineColor.copyFrom(value);
|
|
3495
|
-
}
|
|
2915
|
+
this._maskLayer = value;
|
|
3496
2916
|
}
|
|
3497
2917
|
},
|
|
3498
2918
|
{
|
|
@@ -3503,14 +2923,8 @@ __decorate([
|
|
|
3503
2923
|
if (this._isTextNoVisible()) {
|
|
3504
2924
|
if (this._isContainDirtyFlag(engine.RendererUpdateFlags.WorldVolume)) {
|
|
3505
2925
|
var localBounds = this._localBounds;
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
localBounds.max.set(0, 0, 0);
|
|
3509
|
-
} else {
|
|
3510
|
-
var _this_entity_transform = this.entity.transform, size = _this_entity_transform.size, pivot = _this_entity_transform.pivot;
|
|
3511
|
-
localBounds.min.set(-size.x * pivot.x, -size.y * pivot.y, 0);
|
|
3512
|
-
localBounds.max.set(size.x * (1 - pivot.x), size.y * (1 - pivot.y), 0);
|
|
3513
|
-
}
|
|
2926
|
+
localBounds.min.set(0, 0, 0);
|
|
2927
|
+
localBounds.max.set(0, 0, 0);
|
|
3514
2928
|
this._updateBounds(this._bounds);
|
|
3515
2929
|
this._setDirtyFlagFalse(engine.RendererUpdateFlags.WorldVolume);
|
|
3516
2930
|
}
|
|
@@ -3528,9 +2942,6 @@ __decorate([
|
|
|
3528
2942
|
return Text;
|
|
3529
2943
|
}(exports.UIRenderer);
|
|
3530
2944
|
Text._textTextureProperty = engine.ShaderProperty.getByName("renderElement_TextTexture");
|
|
3531
|
-
Text._textTextureSizeProperty = engine.ShaderProperty.getByName("renderElement_TextTextureSize");
|
|
3532
|
-
Text._outlineColorProperty = engine.ShaderProperty.getByName("renderer_OutlineColor");
|
|
3533
|
-
Text._outlineWidthProperty = engine.ShaderProperty.getByName("renderer_OutlineWidth");
|
|
3534
2945
|
Text._worldPositions = [
|
|
3535
2946
|
new engine.Vector3(),
|
|
3536
2947
|
new engine.Vector3(),
|
|
@@ -3550,9 +2961,6 @@ __decorate([
|
|
|
3550
2961
|
__decorate([
|
|
3551
2962
|
engine.ignoreClone
|
|
3552
2963
|
], Text.prototype, "_onTransformChanged", null);
|
|
3553
|
-
__decorate([
|
|
3554
|
-
engine.ignoreClone
|
|
3555
|
-
], Text.prototype, "_onOutlineColorChanged", null);
|
|
3556
2964
|
var TextChunk = function TextChunk() {
|
|
3557
2965
|
this.charRenderInfos = new Array();
|
|
3558
2966
|
};
|
|
@@ -3877,19 +3285,17 @@ __decorate([
|
|
|
3877
3285
|
|
|
3878
3286
|
var GUIComponent = /*#__PURE__*/Object.freeze({
|
|
3879
3287
|
__proto__: null,
|
|
3288
|
+
get UICanvas () { return exports.UICanvas; },
|
|
3289
|
+
UIGroup: UIGroup,
|
|
3290
|
+
get UIRenderer () { return exports.UIRenderer; },
|
|
3291
|
+
UITransform: UITransform,
|
|
3880
3292
|
Button: Button,
|
|
3881
3293
|
Image: Image,
|
|
3882
|
-
Mask: Mask,
|
|
3883
|
-
get RectMask2D () { return exports.RectMask2D; },
|
|
3884
3294
|
Text: Text,
|
|
3885
3295
|
ColorTransition: ColorTransition,
|
|
3886
3296
|
ScaleTransition: ScaleTransition,
|
|
3887
3297
|
SpriteTransition: SpriteTransition,
|
|
3888
|
-
Transition: Transition
|
|
3889
|
-
get UICanvas () { return exports.UICanvas; },
|
|
3890
|
-
UIGroup: UIGroup,
|
|
3891
|
-
get UIRenderer () { return exports.UIRenderer; },
|
|
3892
|
-
UITransform: UITransform
|
|
3298
|
+
Transition: Transition
|
|
3893
3299
|
});
|
|
3894
3300
|
|
|
3895
3301
|
/**
|
|
@@ -3968,11 +3374,11 @@ exports.UIPointerEventEmitter = /*#__PURE__*/ function(PointerEventEmitter1) {
|
|
|
3968
3374
|
}
|
|
3969
3375
|
}
|
|
3970
3376
|
if (camera.clearFlags & engine.CameraClearFlags.Color) {
|
|
3971
|
-
this._updateRaycast(null
|
|
3377
|
+
this._updateRaycast(null);
|
|
3972
3378
|
return;
|
|
3973
3379
|
}
|
|
3974
3380
|
}
|
|
3975
|
-
this._updateRaycast(null
|
|
3381
|
+
this._updateRaycast(null);
|
|
3976
3382
|
}
|
|
3977
3383
|
};
|
|
3978
3384
|
_proto.processDrag = function processDrag(pointer) {
|
|
@@ -4002,7 +3408,10 @@ exports.UIPointerEventEmitter = /*#__PURE__*/ function(PointerEventEmitter1) {
|
|
|
4002
3408
|
if (pressedPath.length > 0) {
|
|
4003
3409
|
var common = UIPointerEventEmitter._tempArray0;
|
|
4004
3410
|
if (this._findCommonInPath(enteredPath, pressedPath, common)) {
|
|
4005
|
-
this.
|
|
3411
|
+
var eventData = this._createEventData(pointer);
|
|
3412
|
+
for(var i = 0, n = common.length; i < n; i++){
|
|
3413
|
+
this._fireClick(common[i], eventData);
|
|
3414
|
+
}
|
|
4006
3415
|
common.length = 0;
|
|
4007
3416
|
}
|
|
4008
3417
|
}
|
|
@@ -4034,16 +3443,18 @@ exports.UIPointerEventEmitter = /*#__PURE__*/ function(PointerEventEmitter1) {
|
|
|
4034
3443
|
this._enteredPath.length = this._pressedPath.length = this._draggedPath.length = 0;
|
|
4035
3444
|
};
|
|
4036
3445
|
_proto._updateRaycast = function _updateRaycast(element, pointer) {
|
|
3446
|
+
if (pointer === void 0) pointer = null;
|
|
4037
3447
|
var enteredPath = this._enteredPath;
|
|
4038
3448
|
var curPath = this._composedPath(element, UIPointerEventEmitter._path);
|
|
4039
3449
|
var add = UIPointerEventEmitter._tempArray0;
|
|
4040
3450
|
var del = UIPointerEventEmitter._tempArray1;
|
|
4041
3451
|
if (this._findDiffInPath(enteredPath, curPath, add, del)) {
|
|
3452
|
+
var eventData = this._createEventData(pointer);
|
|
4042
3453
|
for(var i = 0, n = add.length; i < n; i++){
|
|
4043
|
-
this._fireEnter(add[i],
|
|
3454
|
+
this._fireEnter(add[i], eventData);
|
|
4044
3455
|
}
|
|
4045
3456
|
for(var i1 = 0, n1 = del.length; i1 < n1; i1++){
|
|
4046
|
-
this._fireExit(del[i1],
|
|
3457
|
+
this._fireExit(del[i1], eventData);
|
|
4047
3458
|
}
|
|
4048
3459
|
var length = enteredPath.length = curPath.length;
|
|
4049
3460
|
for(var i2 = 0; i2 < length; i2++){
|
|
@@ -4113,9 +3524,8 @@ exports.UIPointerEventEmitter = /*#__PURE__*/ function(PointerEventEmitter1) {
|
|
|
4113
3524
|
_proto._bubble = function _bubble(path, pointer, fireEvent) {
|
|
4114
3525
|
var length = path.length;
|
|
4115
3526
|
if (length <= 0) return;
|
|
4116
|
-
var eventData = this._createEventData(pointer
|
|
3527
|
+
var eventData = this._createEventData(pointer);
|
|
4117
3528
|
for(var i = 0; i < length; i++){
|
|
4118
|
-
eventData.currentTarget = path[i];
|
|
4119
3529
|
fireEvent(path[i], eventData);
|
|
4120
3530
|
}
|
|
4121
3531
|
};
|
|
@@ -4192,7 +3602,6 @@ exports.EngineExtension = EngineExtension;
|
|
|
4192
3602
|
exports.EntityExtension = EntityExtension;
|
|
4193
3603
|
exports.HorizontalAlignmentMode = HorizontalAlignmentMode;
|
|
4194
3604
|
exports.Image = Image;
|
|
4195
|
-
exports.Mask = Mask;
|
|
4196
3605
|
exports.ResolutionAdaptationMode = ResolutionAdaptationMode;
|
|
4197
3606
|
exports.ScaleTransition = ScaleTransition;
|
|
4198
3607
|
exports.SpriteTransition = SpriteTransition;
|