@galacean/engine-ui 0.0.0-experimental-2.0-migrate.5 → 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 +1608 -2203
- package/dist/browser.js.map +1 -1
- package/dist/browser.min.js +1 -1
- package/dist/browser.min.js.map +1 -1
- package/dist/main.js +1608 -2203
- package/dist/main.js.map +1 -1
- package/dist/module.js +1610 -2204
- package/dist/module.js.map +1 -1
- package/package.json +5 -4
- package/types/Utils.d.ts +0 -10
- package/types/component/UICanvas.d.ts +6 -2
- package/types/component/UIRenderer.d.ts +1 -15
- package/types/component/UITransform.d.ts +4 -1
- package/types/component/advanced/Image.d.ts +5 -26
- package/types/component/advanced/Text.d.ts +4 -19
- package/types/component/index.d.ts +4 -6
- package/types/component/interactive/transition/Transition.d.ts +6 -1
- 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,944 +75,942 @@ 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
|
-
// @ts-ignore
|
|
300
|
-
_proto._cloneTo = function _cloneTo(target) {
|
|
301
|
-
// @ts-ignore
|
|
302
|
-
Transform.prototype._cloneTo.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;
|
|
733
|
-
};
|
|
734
|
-
// @ts-ignore
|
|
735
|
-
_proto._onEnableInScene = function _onEnableInScene() {
|
|
736
|
-
this.entity._updateUIHierarchyVersion(exports.UICanvas._hierarchyCounter);
|
|
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);
|
|
737
282
|
};
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
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);
|
|
741
290
|
};
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
// 不能 super._cloneTo(target) — 会拿到 undefined 报 "Cannot read properties of undefined (reading 'call')"。
|
|
746
|
-
// (Image/Mask 走 Renderer 链路所以能 super;RectMask2D 不在 Renderer 链路里。)
|
|
747
|
-
var targetSoftness = target._softness;
|
|
748
|
-
// @ts-ignore
|
|
749
|
-
targetSoftness._onValueChanged = null;
|
|
750
|
-
targetSoftness.copyFrom(this._softness);
|
|
751
|
-
target._clampSoftness();
|
|
752
|
-
// @ts-ignore
|
|
753
|
-
targetSoftness._onValueChanged = target._onSoftnessChanged;
|
|
291
|
+
Utils.cleanRootCanvas = function cleanRootCanvas(element) {
|
|
292
|
+
this._registerRootCanvas(element, null);
|
|
293
|
+
this._unRegisterListener(element._rootCanvasListener, element._rootCanvasListeningEntities);
|
|
754
294
|
};
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
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;
|
|
760
309
|
};
|
|
761
|
-
|
|
762
|
-
|
|
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);
|
|
763
315
|
};
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
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);
|
|
771
327
|
}
|
|
772
328
|
};
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
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;
|
|
789
345
|
}
|
|
790
346
|
}
|
|
791
|
-
|
|
792
|
-
{
|
|
793
|
-
key: "alphaClip",
|
|
794
|
-
get: /**
|
|
795
|
-
* Whether to enable hard clip (discard) when outside the rect.
|
|
796
|
-
*/ function get() {
|
|
797
|
-
return this._alphaClip;
|
|
798
|
-
},
|
|
799
|
-
set: function set(value) {
|
|
800
|
-
this._alphaClip = value;
|
|
801
|
-
}
|
|
347
|
+
entity = entity.parent;
|
|
802
348
|
}
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
engine.dependentComponents(UITransform, engine.DependentMode.AutoAdd)
|
|
813
|
-
], exports.RectMask2D);
|
|
814
|
-
|
|
815
|
-
var UIGroup = /*#__PURE__*/ function(Component) {
|
|
816
|
-
_inherits(UIGroup, Component);
|
|
817
|
-
function UIGroup(entity) {
|
|
818
|
-
var _this;
|
|
819
|
-
_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;
|
|
820
|
-
_this._rootCanvasListener = _this._rootCanvasListener.bind(_this);
|
|
821
|
-
_this._groupListener = _this._groupListener.bind(_this);
|
|
822
|
-
return _this;
|
|
823
|
-
}
|
|
824
|
-
var _proto = UIGroup.prototype;
|
|
825
|
-
/**
|
|
826
|
-
* @internal
|
|
827
|
-
*/ _proto._getGlobalAlpha = function _getGlobalAlpha() {
|
|
828
|
-
if (this._isContainDirtyFlag(1)) {
|
|
829
|
-
if (this._ignoreParentGroup) {
|
|
830
|
-
this._globalAlpha = this._alpha;
|
|
831
|
-
} else {
|
|
832
|
-
var parentGroup = this._getGroup();
|
|
833
|
-
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;
|
|
834
358
|
}
|
|
835
|
-
|
|
359
|
+
if (canvas) {
|
|
360
|
+
var disorderedElements = canvas._disorderedElements;
|
|
361
|
+
element._indexInRootCanvas = disorderedElements.length;
|
|
362
|
+
disorderedElements.add(element);
|
|
363
|
+
}
|
|
364
|
+
element._rootCanvas = canvas;
|
|
836
365
|
}
|
|
837
|
-
return this._globalAlpha;
|
|
838
366
|
};
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
var parentGroup = this._getGroup();
|
|
847
|
-
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;
|
|
848
374
|
}
|
|
849
|
-
|
|
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);
|
|
850
382
|
}
|
|
851
|
-
return this._globalInteractive;
|
|
852
|
-
};
|
|
853
|
-
// @ts-ignore
|
|
854
|
-
_proto._onEnableInScene = function _onEnableInScene() {
|
|
855
|
-
Utils.setRootCanvasDirty(this);
|
|
856
|
-
Utils.setGroupDirty(this);
|
|
857
|
-
// @ts-ignore
|
|
858
|
-
this.entity._dispatchModify(EntityUIModifyFlags.GroupEnableInScene);
|
|
859
|
-
};
|
|
860
|
-
// @ts-ignore
|
|
861
|
-
_proto._onDisableInScene = function _onDisableInScene() {
|
|
862
|
-
Utils.cleanRootCanvas(this);
|
|
863
|
-
Utils.cleanGroup(this);
|
|
864
|
-
var disorderedElements = this._disorderedElements;
|
|
865
|
-
disorderedElements.forEach(function(element) {
|
|
866
|
-
Utils.setGroupDirty(element);
|
|
867
|
-
});
|
|
868
|
-
disorderedElements.length = 0;
|
|
869
|
-
disorderedElements.garbageCollection();
|
|
870
|
-
this._isRootCanvasDirty = this._isGroupDirty = false;
|
|
871
|
-
};
|
|
872
|
-
/**
|
|
873
|
-
* @internal
|
|
874
|
-
*/ _proto._getRootCanvas = function _getRootCanvas() {
|
|
875
|
-
this._isRootCanvasDirty && Utils.setRootCanvas(this, Utils.searchRootCanvasInParents(this));
|
|
876
|
-
return this._rootCanvas;
|
|
877
|
-
};
|
|
878
|
-
/**
|
|
879
|
-
* @internal
|
|
880
|
-
*/ _proto._getGroup = function _getGroup() {
|
|
881
|
-
this._isGroupDirty && Utils.setGroup(this, Utils.searchGroupInParents(this));
|
|
882
|
-
return this._group;
|
|
883
383
|
};
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
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++;
|
|
889
397
|
}
|
|
398
|
+
listeningEntities.length = count;
|
|
890
399
|
};
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
Utils.setRootCanvasDirty(this);
|
|
896
|
-
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);
|
|
897
404
|
}
|
|
405
|
+
listeningEntities.length = 0;
|
|
898
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() {}
|
|
899
431
|
/**
|
|
900
|
-
*
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
this.
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
{
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
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([]);
|
|
452
|
+
}
|
|
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;
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
}
|
|
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);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
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;
|
|
532
|
+
};
|
|
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;
|
|
535
|
+
};
|
|
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;
|
|
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) {
|
|
562
|
+
/**
|
|
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);
|
|
630
|
+
};
|
|
631
|
+
/**
|
|
632
|
+
* @inheritdoc
|
|
633
|
+
*/ _proto._onClone = function _onClone(target) {
|
|
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;
|
|
644
|
+
};
|
|
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);
|
|
651
|
+
} else {
|
|
652
|
+
Transform.prototype._onLocalMatrixChanging.call(this);
|
|
653
|
+
}
|
|
654
|
+
};
|
|
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);
|
|
659
|
+
};
|
|
660
|
+
_proto._onPositionChanged = function _onPositionChanged() {
|
|
661
|
+
(this._horizontalAlignment || this._verticalAlignment) && this._updatePositionByAlignment();
|
|
662
|
+
Transform.prototype._onPositionChanged.call(this);
|
|
663
|
+
};
|
|
664
|
+
_proto._onWorldPositionChanged = function _onWorldPositionChanged() {
|
|
665
|
+
Transform.prototype._onWorldPositionChanged.call(this);
|
|
666
|
+
if (this._horizontalAlignment || this._verticalAlignment) {
|
|
667
|
+
this._setDirtyFlagTrue(engine.TransformModifyFlags.WorldPosition);
|
|
668
|
+
}
|
|
669
|
+
};
|
|
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;
|
|
682
|
+
break;
|
|
683
|
+
case HorizontalAlignmentMode.Center:
|
|
684
|
+
position.x = parentRect.x + parentRect.width * 0.5 - rect.x - rect.width * 0.5 + this._alignCenter;
|
|
685
|
+
break;
|
|
686
|
+
case HorizontalAlignmentMode.Right:
|
|
687
|
+
position.x = parentRect.x + parentRect.width - rect.x - rect.width - this._alignRight;
|
|
688
|
+
break;
|
|
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;
|
|
700
|
+
break;
|
|
701
|
+
}
|
|
702
|
+
// @ts-ignore
|
|
703
|
+
position._onValueChanged = this._onPositionChanged;
|
|
704
|
+
}
|
|
705
|
+
};
|
|
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);
|
|
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;
|
|
722
|
+
}
|
|
723
|
+
};
|
|
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();
|
|
733
|
+
}
|
|
734
|
+
this._updateRectBySizeAndPivot();
|
|
735
|
+
this._updateWorldFlagWithSelfRectChange();
|
|
736
|
+
// @ts-ignore
|
|
737
|
+
this._entity._updateFlagManager.dispatch(512);
|
|
738
|
+
};
|
|
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);
|
|
757
|
+
}
|
|
758
|
+
};
|
|
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;
|
|
773
|
+
}
|
|
774
|
+
}
|
|
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
|
+
}
|
|
783
|
+
}
|
|
784
|
+
// @ts-ignore
|
|
785
|
+
selfChange && this._entity._updateFlagManager.dispatch(512);
|
|
786
|
+
};
|
|
787
|
+
_create_class(UITransform, [
|
|
788
|
+
{
|
|
789
|
+
key: "size",
|
|
790
|
+
get: /**
|
|
791
|
+
* Width and height of UI element.
|
|
943
792
|
*/ function get() {
|
|
944
|
-
return this.
|
|
793
|
+
return this._size;
|
|
945
794
|
},
|
|
946
795
|
set: function set(value) {
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
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;
|
|
950
841
|
}
|
|
951
842
|
}
|
|
952
843
|
},
|
|
953
844
|
{
|
|
954
|
-
key: "
|
|
845
|
+
key: "alignLeft",
|
|
955
846
|
get: /**
|
|
956
|
-
*
|
|
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.
|
|
957
852
|
*/ function get() {
|
|
958
|
-
return this.
|
|
853
|
+
return this._alignLeft;
|
|
959
854
|
},
|
|
960
855
|
set: function set(value) {
|
|
961
|
-
|
|
962
|
-
if (this.
|
|
963
|
-
|
|
964
|
-
|
|
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();
|
|
965
862
|
}
|
|
966
863
|
}
|
|
967
|
-
}
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
864
|
+
},
|
|
865
|
+
{
|
|
866
|
+
key: "alignRight",
|
|
867
|
+
get: /**
|
|
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.
|
|
873
|
+
*/ function get() {
|
|
874
|
+
return this._alignRight;
|
|
875
|
+
},
|
|
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;
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
},
|
|
934
|
+
{
|
|
935
|
+
key: "alignTop",
|
|
936
|
+
get: /**
|
|
937
|
+
* Top margin when verticalAlignment is Top or TopAndBottom.
|
|
938
|
+
*
|
|
939
|
+
* @remarks
|
|
940
|
+
* Only effective when verticalAlignment includes Top mode.
|
|
941
|
+
* Used to offset the element from the parent's top edge.
|
|
942
|
+
*/ function get() {
|
|
943
|
+
return this._alignTop;
|
|
944
|
+
},
|
|
945
|
+
set: function set(value) {
|
|
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();
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
},
|
|
955
|
+
{
|
|
956
|
+
key: "alignBottom",
|
|
957
|
+
get: /**
|
|
958
|
+
* Bottom inset used in vertical alignment formulas.
|
|
959
|
+
*/ function get() {
|
|
960
|
+
return this._alignBottom;
|
|
961
|
+
},
|
|
962
|
+
set: function set(value) {
|
|
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
|
+
}
|
|
970
|
+
}
|
|
971
|
+
},
|
|
972
|
+
{
|
|
973
|
+
key: "alignMiddle",
|
|
974
|
+
get: /**
|
|
975
|
+
* Vertical middle offset relative to parent's middle.
|
|
976
|
+
*/ function get() {
|
|
977
|
+
return this._alignMiddle;
|
|
978
|
+
},
|
|
979
|
+
set: function set(value) {
|
|
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();
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
]);
|
|
987
|
+
return UITransform;
|
|
988
|
+
}(engine.Transform);
|
|
986
989
|
__decorate([
|
|
987
990
|
engine.ignoreClone
|
|
988
|
-
],
|
|
991
|
+
], UITransform.prototype, "_size", void 0);
|
|
989
992
|
__decorate([
|
|
990
993
|
engine.ignoreClone
|
|
991
|
-
],
|
|
994
|
+
], UITransform.prototype, "_pivot", void 0);
|
|
992
995
|
__decorate([
|
|
993
996
|
engine.ignoreClone
|
|
994
|
-
],
|
|
997
|
+
], UITransform.prototype, "_onPositionChanged", null);
|
|
995
998
|
__decorate([
|
|
996
999
|
engine.ignoreClone
|
|
997
|
-
],
|
|
1000
|
+
], UITransform.prototype, "_onWorldPositionChanged", null);
|
|
998
1001
|
__decorate([
|
|
999
1002
|
engine.ignoreClone
|
|
1000
|
-
],
|
|
1003
|
+
], UITransform.prototype, "_onSizeChanged", null);
|
|
1001
1004
|
__decorate([
|
|
1002
1005
|
engine.ignoreClone
|
|
1003
|
-
],
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
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;
|
|
1010
1014
|
}({});
|
|
1011
1015
|
|
|
1012
1016
|
exports.UIRenderer = /*#__PURE__*/ function(Renderer) {
|
|
@@ -1016,16 +1020,13 @@ exports.UIRenderer = /*#__PURE__*/ function(Renderer) {
|
|
|
1016
1020
|
_this = Renderer.call(this, entity) || this, /**
|
|
1017
1021
|
* Custom boundary for raycast detection.
|
|
1018
1022
|
* @remarks this is based on `this.entity.transform`.
|
|
1019
|
-
*/ _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 = [],
|
|
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);
|
|
1020
1024
|
_this._dirtyUpdateFlag = engine.RendererUpdateFlags.WorldVolume | 2;
|
|
1021
1025
|
_this._onColorChanged = _this._onColorChanged.bind(_this);
|
|
1022
1026
|
//@ts-ignore
|
|
1023
1027
|
_this._color._onValueChanged = _this._onColorChanged;
|
|
1024
1028
|
_this._groupListener = _this._groupListener.bind(_this);
|
|
1025
1029
|
_this._rootCanvasListener = _this._rootCanvasListener.bind(_this);
|
|
1026
|
-
_this.shaderData.setFloat(UIRenderer._rectClipEnabledProperty, 0);
|
|
1027
|
-
_this.shaderData.setVector4(UIRenderer._rectClipSoftnessProperty, _this._rectMaskSoftness);
|
|
1028
|
-
_this.shaderData.setFloat(UIRenderer._rectClipHardClipProperty, 0);
|
|
1029
1030
|
return _this;
|
|
1030
1031
|
}
|
|
1031
1032
|
var _proto = UIRenderer.prototype;
|
|
@@ -1048,7 +1049,6 @@ exports.UIRenderer = /*#__PURE__*/ function(Renderer) {
|
|
|
1048
1049
|
if (this._renderFrameCount !== this.engine.time.frameCount) {
|
|
1049
1050
|
this._update(context);
|
|
1050
1051
|
}
|
|
1051
|
-
this._updateRectMaskClipState();
|
|
1052
1052
|
this._render(context);
|
|
1053
1053
|
// union camera global macro and renderer macro.
|
|
1054
1054
|
engine.ShaderMacroCollection.unionCollection(context.camera._globalShaderMacro, // @ts-ignore
|
|
@@ -1127,15 +1127,6 @@ exports.UIRenderer = /*#__PURE__*/ function(Renderer) {
|
|
|
1127
1127
|
};
|
|
1128
1128
|
/**
|
|
1129
1129
|
* @internal
|
|
1130
|
-
*/ _proto._setRectMasks = function _setRectMasks(rectMasks, count) {
|
|
1131
|
-
var targetMasks = this._rectMasks;
|
|
1132
|
-
targetMasks.length = count;
|
|
1133
|
-
for(var i = 0; i < count; i++){
|
|
1134
|
-
targetMasks[i] = rectMasks[i];
|
|
1135
|
-
}
|
|
1136
|
-
};
|
|
1137
|
-
/**
|
|
1138
|
-
* @internal
|
|
1139
1130
|
*/ _proto._raycast = function _raycast(ray, out, distance) {
|
|
1140
1131
|
if (distance === void 0) distance = Number.MAX_SAFE_INTEGER;
|
|
1141
1132
|
var plane = UIRenderer._tempPlane;
|
|
@@ -1149,7 +1140,7 @@ exports.UIRenderer = /*#__PURE__*/ function(Renderer) {
|
|
|
1149
1140
|
engine.Matrix.invert(transform.worldMatrix, worldMatrixInv);
|
|
1150
1141
|
var localPosition = UIRenderer._tempVec31;
|
|
1151
1142
|
engine.Vector3.transformCoordinate(hitPointWorld, worldMatrixInv, localPosition);
|
|
1152
|
-
if (this._hitTest(localPosition)
|
|
1143
|
+
if (this._hitTest(localPosition)) {
|
|
1153
1144
|
out.component = this;
|
|
1154
1145
|
out.distance = curDistance;
|
|
1155
1146
|
out.entity = this.entity;
|
|
@@ -1168,127 +1159,6 @@ exports.UIRenderer = /*#__PURE__*/ function(Renderer) {
|
|
|
1168
1159
|
var _this_raycastPadding = this.raycastPadding, paddingLeft = _this_raycastPadding.x, paddingBottom = _this_raycastPadding.y, paddingRight = _this_raycastPadding.z, paddingTop = _this_raycastPadding.w;
|
|
1169
1160
|
return x >= -width * pivotX + paddingLeft && x <= width * (1 - pivotX) - paddingRight && y >= -height * pivotY + paddingTop && y <= height * (1 - pivotY) - paddingBottom;
|
|
1170
1161
|
};
|
|
1171
|
-
_proto._isRaycastVisibleByMask = function _isRaycastVisibleByMask(hitPointWorld) {
|
|
1172
|
-
var maskInteraction = this._maskInteraction;
|
|
1173
|
-
if (maskInteraction === engine.SpriteMaskInteraction.None) {
|
|
1174
|
-
return true;
|
|
1175
|
-
}
|
|
1176
|
-
// @ts-ignore
|
|
1177
|
-
return this.scene._maskManager.isVisibleByMask(maskInteraction, this._maskLayer, hitPointWorld);
|
|
1178
|
-
};
|
|
1179
|
-
_proto._isRaycastVisibleByRectMask = function _isRaycastVisibleByRectMask(hitPointWorld) {
|
|
1180
|
-
var rectMasks = this._rectMasks;
|
|
1181
|
-
for(var i = 0, n = rectMasks.length; i < n; i++){
|
|
1182
|
-
var rectMask = rectMasks[i];
|
|
1183
|
-
if (!rectMask.enabled || !rectMask.entity.isActiveInHierarchy) {
|
|
1184
|
-
continue;
|
|
1185
|
-
}
|
|
1186
|
-
if (!rectMask._containsWorldPoint(hitPointWorld)) {
|
|
1187
|
-
return false;
|
|
1188
|
-
}
|
|
1189
|
-
}
|
|
1190
|
-
return true;
|
|
1191
|
-
};
|
|
1192
|
-
_proto._updateRectMaskClipState = function _updateRectMaskClipState() {
|
|
1193
|
-
var rectMasks = this._rectMasks;
|
|
1194
|
-
var count = rectMasks.length;
|
|
1195
|
-
if (count <= 0) {
|
|
1196
|
-
this._resetRectMaskClipState();
|
|
1197
|
-
return;
|
|
1198
|
-
}
|
|
1199
|
-
var minX = Number.NEGATIVE_INFINITY;
|
|
1200
|
-
var minY = Number.NEGATIVE_INFINITY;
|
|
1201
|
-
var maxX = Number.POSITIVE_INFINITY;
|
|
1202
|
-
var maxY = Number.POSITIVE_INFINITY;
|
|
1203
|
-
var clipSoftnessLeft = 0;
|
|
1204
|
-
var clipSoftnessBottom = 0;
|
|
1205
|
-
var clipSoftnessRight = 0;
|
|
1206
|
-
var clipSoftnessTop = 0;
|
|
1207
|
-
var clipHardClip = false;
|
|
1208
|
-
var hasActiveMask = false;
|
|
1209
|
-
var tempRect = UIRenderer._tempRect;
|
|
1210
|
-
for(var i = 0; i < count; i++){
|
|
1211
|
-
var rectMask = rectMasks[i];
|
|
1212
|
-
if (!rectMask.enabled || !rectMask.entity.isActiveInHierarchy) {
|
|
1213
|
-
continue;
|
|
1214
|
-
}
|
|
1215
|
-
hasActiveMask = true;
|
|
1216
|
-
var softness = rectMask.softness;
|
|
1217
|
-
if (!clipHardClip && rectMask.alphaClip) {
|
|
1218
|
-
clipHardClip = true;
|
|
1219
|
-
}
|
|
1220
|
-
if (!rectMask._getWorldRect(tempRect)) {
|
|
1221
|
-
minX = 1;
|
|
1222
|
-
minY = 1;
|
|
1223
|
-
maxX = 0;
|
|
1224
|
-
maxY = 0;
|
|
1225
|
-
break;
|
|
1226
|
-
}
|
|
1227
|
-
if (tempRect.x > minX) {
|
|
1228
|
-
minX = tempRect.x;
|
|
1229
|
-
clipSoftnessLeft = softness.x;
|
|
1230
|
-
}
|
|
1231
|
-
if (tempRect.y > minY) {
|
|
1232
|
-
minY = tempRect.y;
|
|
1233
|
-
clipSoftnessBottom = softness.y;
|
|
1234
|
-
}
|
|
1235
|
-
if (tempRect.z < maxX) {
|
|
1236
|
-
maxX = tempRect.z;
|
|
1237
|
-
clipSoftnessRight = softness.x;
|
|
1238
|
-
}
|
|
1239
|
-
if (tempRect.w < maxY) {
|
|
1240
|
-
maxY = tempRect.w;
|
|
1241
|
-
clipSoftnessTop = softness.y;
|
|
1242
|
-
}
|
|
1243
|
-
}
|
|
1244
|
-
if (!hasActiveMask) {
|
|
1245
|
-
this._resetRectMaskClipState();
|
|
1246
|
-
return;
|
|
1247
|
-
}
|
|
1248
|
-
if (minX >= maxX || minY >= maxY) {
|
|
1249
|
-
minX = 1;
|
|
1250
|
-
minY = 1;
|
|
1251
|
-
maxX = 0;
|
|
1252
|
-
maxY = 0;
|
|
1253
|
-
clipSoftnessLeft = 0;
|
|
1254
|
-
clipSoftnessBottom = 0;
|
|
1255
|
-
clipSoftnessRight = 0;
|
|
1256
|
-
clipSoftnessTop = 0;
|
|
1257
|
-
}
|
|
1258
|
-
var rectMaskRect = this._rectMaskRect;
|
|
1259
|
-
if (rectMaskRect.x !== minX || rectMaskRect.y !== minY || rectMaskRect.z !== maxX || rectMaskRect.w !== maxY) {
|
|
1260
|
-
rectMaskRect.set(minX, minY, maxX, maxY);
|
|
1261
|
-
this.shaderData.setVector4(UIRenderer._rectClipRectProperty, rectMaskRect);
|
|
1262
|
-
}
|
|
1263
|
-
var rectMaskSoftness = this._rectMaskSoftness;
|
|
1264
|
-
if (rectMaskSoftness.x !== clipSoftnessLeft || rectMaskSoftness.y !== clipSoftnessBottom || rectMaskSoftness.z !== clipSoftnessRight || rectMaskSoftness.w !== clipSoftnessTop) {
|
|
1265
|
-
rectMaskSoftness.set(clipSoftnessLeft, clipSoftnessBottom, clipSoftnessRight, clipSoftnessTop);
|
|
1266
|
-
this.shaderData.setVector4(UIRenderer._rectClipSoftnessProperty, rectMaskSoftness);
|
|
1267
|
-
}
|
|
1268
|
-
if (this._rectMaskHardClip !== clipHardClip) {
|
|
1269
|
-
this._rectMaskHardClip = clipHardClip;
|
|
1270
|
-
this.shaderData.setFloat(UIRenderer._rectClipHardClipProperty, clipHardClip ? 1 : 0);
|
|
1271
|
-
}
|
|
1272
|
-
if (!this._rectMaskEnabled) {
|
|
1273
|
-
this._rectMaskEnabled = true;
|
|
1274
|
-
this.shaderData.setFloat(UIRenderer._rectClipEnabledProperty, 1);
|
|
1275
|
-
}
|
|
1276
|
-
};
|
|
1277
|
-
_proto._resetRectMaskClipState = function _resetRectMaskClipState() {
|
|
1278
|
-
if (this._rectMaskEnabled) {
|
|
1279
|
-
this._rectMaskEnabled = false;
|
|
1280
|
-
this.shaderData.setFloat(UIRenderer._rectClipEnabledProperty, 0);
|
|
1281
|
-
}
|
|
1282
|
-
var rectMaskSoftness = this._rectMaskSoftness;
|
|
1283
|
-
if (rectMaskSoftness.x !== 0 || rectMaskSoftness.y !== 0 || rectMaskSoftness.z !== 0 || rectMaskSoftness.w !== 0) {
|
|
1284
|
-
rectMaskSoftness.set(0, 0, 0, 0);
|
|
1285
|
-
this.shaderData.setVector4(UIRenderer._rectClipSoftnessProperty, rectMaskSoftness);
|
|
1286
|
-
}
|
|
1287
|
-
if (this._rectMaskHardClip) {
|
|
1288
|
-
this._rectMaskHardClip = false;
|
|
1289
|
-
this.shaderData.setFloat(UIRenderer._rectClipHardClipProperty, 0);
|
|
1290
|
-
}
|
|
1291
|
-
};
|
|
1292
1162
|
_proto._onDestroy = function _onDestroy() {
|
|
1293
1163
|
if (this._subChunk) {
|
|
1294
1164
|
this._getChunkManager().freeSubChunk(this._subChunk);
|
|
@@ -1298,8 +1168,6 @@ exports.UIRenderer = /*#__PURE__*/ function(Renderer) {
|
|
|
1298
1168
|
//@ts-ignore
|
|
1299
1169
|
this._color._onValueChanged = null;
|
|
1300
1170
|
this._color = null;
|
|
1301
|
-
this._rectMasks = null;
|
|
1302
|
-
this._rectMaskSoftness = null;
|
|
1303
1171
|
};
|
|
1304
1172
|
_create_class(UIRenderer, [
|
|
1305
1173
|
{
|
|
@@ -1315,30 +1183,6 @@ exports.UIRenderer = /*#__PURE__*/ function(Renderer) {
|
|
|
1315
1183
|
}
|
|
1316
1184
|
}
|
|
1317
1185
|
},
|
|
1318
|
-
{
|
|
1319
|
-
key: "maskLayer",
|
|
1320
|
-
get: /**
|
|
1321
|
-
* The mask layer the ui renderer belongs to.
|
|
1322
|
-
*/ function get() {
|
|
1323
|
-
return this._maskLayer;
|
|
1324
|
-
},
|
|
1325
|
-
set: function set(value) {
|
|
1326
|
-
this._maskLayer = value;
|
|
1327
|
-
}
|
|
1328
|
-
},
|
|
1329
|
-
{
|
|
1330
|
-
key: "maskInteraction",
|
|
1331
|
-
get: /**
|
|
1332
|
-
* Interacts with the masks.
|
|
1333
|
-
*/ function get() {
|
|
1334
|
-
return this._maskInteraction;
|
|
1335
|
-
},
|
|
1336
|
-
set: function set(value) {
|
|
1337
|
-
if (this._maskInteraction !== value) {
|
|
1338
|
-
this._maskInteraction = value;
|
|
1339
|
-
}
|
|
1340
|
-
}
|
|
1341
|
-
},
|
|
1342
1186
|
{
|
|
1343
1187
|
key: "raycastEnabled",
|
|
1344
1188
|
get: /**
|
|
@@ -1353,17 +1197,11 @@ exports.UIRenderer = /*#__PURE__*/ function(Renderer) {
|
|
|
1353
1197
|
]);
|
|
1354
1198
|
return UIRenderer;
|
|
1355
1199
|
}(engine.Renderer);
|
|
1356
|
-
/** @internal */ exports.UIRenderer._tempVec20 = new engine.Vector2();
|
|
1357
1200
|
/** @internal */ exports.UIRenderer._tempVec30 = new engine.Vector3();
|
|
1358
1201
|
/** @internal */ exports.UIRenderer._tempVec31 = new engine.Vector3();
|
|
1359
1202
|
/** @internal */ exports.UIRenderer._tempMat = new engine.Matrix();
|
|
1360
1203
|
/** @internal */ exports.UIRenderer._tempPlane = new engine.Plane();
|
|
1361
1204
|
/** @internal */ exports.UIRenderer._textureProperty = engine.ShaderProperty.getByName("renderer_UITexture");
|
|
1362
|
-
/** @internal */ exports.UIRenderer._rectClipRectProperty = engine.ShaderProperty.getByName("renderer_UIRectClipRect");
|
|
1363
|
-
/** @internal */ exports.UIRenderer._rectClipEnabledProperty = engine.ShaderProperty.getByName("renderer_UIRectClipEnabled");
|
|
1364
|
-
/** @internal */ exports.UIRenderer._rectClipSoftnessProperty = engine.ShaderProperty.getByName("renderer_UIRectClipSoftness");
|
|
1365
|
-
/** @internal */ exports.UIRenderer._rectClipHardClipProperty = engine.ShaderProperty.getByName("renderer_UIRectClipHardClip");
|
|
1366
|
-
/** @internal */ exports.UIRenderer._tempRect = new engine.Vector4();
|
|
1367
1205
|
__decorate([
|
|
1368
1206
|
engine.ignoreClone
|
|
1369
1207
|
], exports.UIRenderer.prototype, "_indexInRootCanvas", void 0);
|
|
@@ -1385,21 +1223,6 @@ __decorate([
|
|
|
1385
1223
|
__decorate([
|
|
1386
1224
|
engine.ignoreClone
|
|
1387
1225
|
], exports.UIRenderer.prototype, "_subChunk", void 0);
|
|
1388
|
-
__decorate([
|
|
1389
|
-
engine.ignoreClone
|
|
1390
|
-
], exports.UIRenderer.prototype, "_rectMasks", void 0);
|
|
1391
|
-
__decorate([
|
|
1392
|
-
engine.ignoreClone
|
|
1393
|
-
], exports.UIRenderer.prototype, "_rectMaskRect", void 0);
|
|
1394
|
-
__decorate([
|
|
1395
|
-
engine.ignoreClone
|
|
1396
|
-
], exports.UIRenderer.prototype, "_rectMaskEnabled", void 0);
|
|
1397
|
-
__decorate([
|
|
1398
|
-
engine.ignoreClone
|
|
1399
|
-
], exports.UIRenderer.prototype, "_rectMaskSoftness", void 0);
|
|
1400
|
-
__decorate([
|
|
1401
|
-
engine.ignoreClone
|
|
1402
|
-
], exports.UIRenderer.prototype, "_rectMaskHardClip", void 0);
|
|
1403
1226
|
__decorate([
|
|
1404
1227
|
engine.ignoreClone
|
|
1405
1228
|
], exports.UIRenderer.prototype, "_groupListener", null);
|
|
@@ -1419,1077 +1242,879 @@ exports.UIRenderer = __decorate([
|
|
|
1419
1242
|
return UIRendererUpdateFlags;
|
|
1420
1243
|
}({});
|
|
1421
1244
|
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1245
|
+
/**
|
|
1246
|
+
* Interactive component.
|
|
1247
|
+
*/ var UIInteractive = /*#__PURE__*/ function(Script) {
|
|
1248
|
+
_inherits(UIInteractive, Script);
|
|
1249
|
+
function UIInteractive(entity) {
|
|
1425
1250
|
var _this;
|
|
1426
|
-
_this =
|
|
1427
|
-
_this.
|
|
1428
|
-
_this._onCameraModifyListener = _this._onCameraModifyListener.bind(_this);
|
|
1429
|
-
_this._onCameraTransformListener = _this._onCameraTransformListener.bind(_this);
|
|
1430
|
-
_this._onReferenceResolutionChanged = _this._onReferenceResolutionChanged.bind(_this);
|
|
1431
|
-
// @ts-ignore
|
|
1432
|
-
_this._referenceResolution._onValueChanged = _this._onReferenceResolutionChanged;
|
|
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);
|
|
1433
1253
|
_this._rootCanvasListener = _this._rootCanvasListener.bind(_this);
|
|
1434
|
-
_this._centerDirtyFlag = entity.registerWorldChangeFlag();
|
|
1435
1254
|
return _this;
|
|
1436
1255
|
}
|
|
1437
|
-
var _proto =
|
|
1438
|
-
/**
|
|
1439
|
-
* @internal
|
|
1440
|
-
*/ _proto._raycast = function _raycast(ray, out, distance) {
|
|
1441
|
-
if (distance === void 0) distance = Number.MAX_SAFE_INTEGER;
|
|
1442
|
-
var renderers = this._getRenderers();
|
|
1443
|
-
for(var i = renderers.length - 1; i >= 0; i--){
|
|
1444
|
-
var element = renderers[i];
|
|
1445
|
-
if (element.raycastEnabled && element._raycast(ray, out, distance)) {
|
|
1446
|
-
return true;
|
|
1447
|
-
}
|
|
1448
|
-
}
|
|
1449
|
-
out.component = null;
|
|
1450
|
-
out.entity = null;
|
|
1451
|
-
out.distance = 0;
|
|
1452
|
-
out.point.set(0, 0, 0);
|
|
1453
|
-
out.normal.set(0, 0, 0);
|
|
1454
|
-
return false;
|
|
1455
|
-
};
|
|
1456
|
-
/**
|
|
1457
|
-
* @internal
|
|
1458
|
-
*/ _proto._getRootCanvas = function _getRootCanvas() {
|
|
1459
|
-
return this._rootCanvas;
|
|
1460
|
-
};
|
|
1461
|
-
/**
|
|
1462
|
-
* @internal
|
|
1463
|
-
*/ _proto._canRender = function _canRender(camera) {
|
|
1464
|
-
return this._realRenderMode !== CanvasRenderMode.ScreenSpaceCamera || this._camera === camera;
|
|
1465
|
-
};
|
|
1466
|
-
/**
|
|
1467
|
-
* @internal
|
|
1468
|
-
*/ _proto._canDispatchEvent = function _canDispatchEvent(camera) {
|
|
1469
|
-
var realMode = this._realRenderMode;
|
|
1470
|
-
if (realMode === CanvasRenderMode.ScreenSpaceOverlay) {
|
|
1471
|
-
return true;
|
|
1472
|
-
}
|
|
1473
|
-
var assignedCamera = this._camera;
|
|
1474
|
-
// @ts-ignore
|
|
1475
|
-
return !assignedCamera || !assignedCamera._phasedActiveInScene || assignedCamera === camera;
|
|
1476
|
-
};
|
|
1477
|
-
/**
|
|
1478
|
-
* @internal
|
|
1479
|
-
*/ _proto._prepareRender = function _prepareRender(context) {
|
|
1480
|
-
var _this = this, engine = _this.engine, mode = _this._realRenderMode;
|
|
1481
|
-
var _context_camera = context.camera, enableFrustumCulling = _context_camera.enableFrustumCulling, cullingMask = _context_camera.cullingMask, frustum = _context_camera._frustum;
|
|
1482
|
-
var frameCount = engine.time.frameCount;
|
|
1483
|
-
var renderElements = this._renderElements;
|
|
1484
|
-
renderElements.length = 0;
|
|
1485
|
-
var virtualCamera = context.virtualCamera;
|
|
1486
|
-
this._updateSortDistance(virtualCamera.isOrthographic, virtualCamera.position, virtualCamera.forward);
|
|
1487
|
-
var _engine_canvas = engine.canvas, width = _engine_canvas.width, height = _engine_canvas.height;
|
|
1488
|
-
var renderers = this._getRenderers();
|
|
1489
|
-
for(var i = 0, n = renderers.length; i < n; i++){
|
|
1490
|
-
var renderer = renderers[i];
|
|
1491
|
-
// Filter by camera culling mask
|
|
1492
|
-
if (!(cullingMask & renderer.entity.layer)) {
|
|
1493
|
-
continue;
|
|
1494
|
-
}
|
|
1495
|
-
// Filter by camera frustum
|
|
1496
|
-
if (enableFrustumCulling) {
|
|
1497
|
-
switch(mode){
|
|
1498
|
-
case CanvasRenderMode.ScreenSpaceOverlay:
|
|
1499
|
-
var _renderer_bounds = renderer.bounds, min = _renderer_bounds.min, max = _renderer_bounds.max;
|
|
1500
|
-
if (min.x > width || max.x < 0 || min.y > height || max.y < 0) {
|
|
1501
|
-
continue;
|
|
1502
|
-
}
|
|
1503
|
-
break;
|
|
1504
|
-
case CanvasRenderMode.ScreenSpaceCamera:
|
|
1505
|
-
case CanvasRenderMode.WorldSpace:
|
|
1506
|
-
if (!frustum.intersectsBox(renderer.bounds)) {
|
|
1507
|
-
continue;
|
|
1508
|
-
}
|
|
1509
|
-
break;
|
|
1510
|
-
}
|
|
1511
|
-
}
|
|
1512
|
-
renderer._prepareRender(context);
|
|
1513
|
-
renderer._renderFrameCount = frameCount;
|
|
1514
|
-
}
|
|
1515
|
-
var batchedRenderElements = this._batchedRenderElements;
|
|
1516
|
-
batchedRenderElements.length = 0;
|
|
1517
|
-
UIBatchSorter.sort(renderElements, this.entity.transform.worldMatrix);
|
|
1518
|
-
engine._batcherManager.batch(renderElements, batchedRenderElements);
|
|
1519
|
-
for(var i1 = 0, n1 = batchedRenderElements.length; i1 < n1; i1++){
|
|
1520
|
-
batchedRenderElements[i1].subDistancePriority = i1;
|
|
1521
|
-
}
|
|
1522
|
-
};
|
|
1256
|
+
var _proto = UIInteractive.prototype;
|
|
1523
1257
|
/**
|
|
1524
|
-
*
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
var boundsCenter = this._getCenter();
|
|
1535
|
-
if (isOrthographic) {
|
|
1536
|
-
var distance = UICanvas._tempVec3;
|
|
1537
|
-
engine.Vector3.subtract(boundsCenter, cameraPosition, distance);
|
|
1538
|
-
this._sortDistance = engine.Vector3.dot(distance, cameraForward);
|
|
1539
|
-
} else {
|
|
1540
|
-
this._sortDistance = engine.Vector3.distanceSquared(boundsCenter, cameraPosition);
|
|
1541
|
-
}
|
|
1542
|
-
break;
|
|
1543
|
-
}
|
|
1544
|
-
};
|
|
1545
|
-
// @ts-ignore
|
|
1546
|
-
_proto._onEnableInScene = function _onEnableInScene() {
|
|
1547
|
-
var entity = this.entity;
|
|
1548
|
-
// @ts-ignore
|
|
1549
|
-
entity._dispatchModify(4, this);
|
|
1550
|
-
var rootCanvas = Utils.searchRootCanvasInParents(this);
|
|
1551
|
-
this._setIsRootCanvas(!rootCanvas);
|
|
1552
|
-
Utils.setRootCanvas(this, rootCanvas);
|
|
1553
|
-
};
|
|
1554
|
-
// @ts-ignore
|
|
1555
|
-
_proto._onDisableInScene = function _onDisableInScene() {
|
|
1556
|
-
this._setIsRootCanvas(false);
|
|
1557
|
-
Utils.cleanRootCanvas(this);
|
|
1558
|
-
};
|
|
1559
|
-
// @ts-ignore
|
|
1560
|
-
_proto._onDisable = function _onDisable() {
|
|
1561
|
-
this._renderElements.length = 0;
|
|
1562
|
-
this._batchedRenderElements.length = 0;
|
|
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
|
+
}
|
|
1563
1268
|
};
|
|
1564
1269
|
/**
|
|
1565
|
-
*
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
} else {
|
|
1577
|
-
if (flag === engine.EntityModifyFlags.Parent) {
|
|
1578
|
-
var rootCanvas1 = Utils.searchRootCanvasInParents(this);
|
|
1579
|
-
this._setIsRootCanvas(!rootCanvas1);
|
|
1580
|
-
Utils.setRootCanvas(this, rootCanvas1);
|
|
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;
|
|
1581
1281
|
}
|
|
1582
1282
|
}
|
|
1583
1283
|
};
|
|
1584
1284
|
/**
|
|
1585
|
-
*
|
|
1586
|
-
*/ _proto.
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
var _this = this, renderers = _this._orderedRenderers, entity = _this.entity;
|
|
1591
|
-
var uiHierarchyVersion = entity._uiHierarchyVersion;
|
|
1592
|
-
if (this._hierarchyVersion !== uiHierarchyVersion) {
|
|
1593
|
-
UICanvas._tempRectMaskList.length = 0;
|
|
1594
|
-
renderers.length = this._walk(this.entity, renderers, 0, null, 0);
|
|
1595
|
-
UICanvas._tempGroupAbleList.length = 0;
|
|
1596
|
-
this._hierarchyVersion = uiHierarchyVersion;
|
|
1597
|
-
++UICanvas._hierarchyCounter;
|
|
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;
|
|
1598
1290
|
}
|
|
1599
|
-
|
|
1291
|
+
transitions.length = 0;
|
|
1600
1292
|
};
|
|
1601
|
-
_proto.
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
if (!this._isSameOrChildEntity(cameraEntity)) {
|
|
1607
|
-
var cameraTransform = cameraEntity.transform;
|
|
1608
|
-
var cameraWorldPosition = cameraTransform.worldPosition, cameraWorldForward = cameraTransform.worldForward;
|
|
1609
|
-
var distance = this._distance;
|
|
1610
|
-
transform.setWorldPosition(cameraWorldPosition.x + cameraWorldForward.x * distance, cameraWorldPosition.y + cameraWorldForward.y * distance, cameraWorldPosition.z + cameraWorldForward.z * distance);
|
|
1611
|
-
transform.worldRotationQuaternion.copyFrom(cameraTransform.worldRotationQuaternion);
|
|
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);
|
|
1612
1298
|
}
|
|
1613
|
-
} else {
|
|
1614
|
-
var canvas = this.engine.canvas;
|
|
1615
|
-
transform.setWorldPosition(canvas.width * 0.5, canvas.height * 0.5, 0);
|
|
1616
|
-
transform.worldRotationQuaternion.set(0, 0, 0, 1);
|
|
1617
1299
|
}
|
|
1618
1300
|
};
|
|
1619
|
-
_proto.
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
var _this__referenceResolution = this._referenceResolution, width = _this__referenceResolution.x, height = _this__referenceResolution.y;
|
|
1623
|
-
var curWidth;
|
|
1624
|
-
var curHeight;
|
|
1625
|
-
if (realRenderMode === CanvasRenderMode.ScreenSpaceCamera) {
|
|
1626
|
-
var camera = this._camera;
|
|
1627
|
-
curHeight = camera.isOrthographic ? camera.orthographicSize * 2 : 2 * (Math.tan(engine.MathUtil.degreeToRadian(camera.fieldOfView * 0.5)) * this._distance);
|
|
1628
|
-
curWidth = camera.aspectRatio * curHeight;
|
|
1629
|
-
} else {
|
|
1630
|
-
var canvas = this.engine.canvas;
|
|
1631
|
-
curHeight = canvas.height;
|
|
1632
|
-
curWidth = canvas.width;
|
|
1633
|
-
}
|
|
1634
|
-
var expectX, expectY, expectZ;
|
|
1635
|
-
switch(this._resolutionAdaptationMode){
|
|
1636
|
-
case ResolutionAdaptationMode.WidthAdaptation:
|
|
1637
|
-
expectX = expectY = expectZ = curWidth / width;
|
|
1638
|
-
break;
|
|
1639
|
-
case ResolutionAdaptationMode.HeightAdaptation:
|
|
1640
|
-
expectX = expectY = expectZ = curHeight / height;
|
|
1641
|
-
break;
|
|
1642
|
-
case ResolutionAdaptationMode.BothAdaptation:
|
|
1643
|
-
expectX = curWidth / width;
|
|
1644
|
-
expectY = curHeight / height;
|
|
1645
|
-
expectZ = (expectX + expectY) * 0.5;
|
|
1646
|
-
break;
|
|
1647
|
-
case ResolutionAdaptationMode.ExpandAdaptation:
|
|
1648
|
-
expectX = expectY = expectZ = Math.min(curWidth / width, curHeight / height);
|
|
1649
|
-
break;
|
|
1650
|
-
case ResolutionAdaptationMode.ShrinkAdaptation:
|
|
1651
|
-
expectX = expectY = expectZ = Math.max(curWidth / width, curHeight / height);
|
|
1652
|
-
break;
|
|
1653
|
-
}
|
|
1654
|
-
var worldMatrix = UICanvas._tempMat;
|
|
1655
|
-
engine.Matrix.affineTransformation(UICanvas._tempVec3.set(expectX, expectY, expectZ), transform.worldRotationQuaternion, transform.worldPosition, worldMatrix);
|
|
1656
|
-
transform.worldMatrix = worldMatrix;
|
|
1657
|
-
transform.size.set(curWidth / expectX, curHeight / expectY);
|
|
1301
|
+
_proto.onPointerBeginDrag = function onPointerBeginDrag() {
|
|
1302
|
+
this._isPointerDragging = true;
|
|
1303
|
+
this._updateState(false);
|
|
1658
1304
|
};
|
|
1659
|
-
_proto.
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
if (rectMaskCount === void 0) rectMaskCount = 0;
|
|
1663
|
-
// @ts-ignore
|
|
1664
|
-
var components = entity._components;
|
|
1665
|
-
var tempGroupAbleList = UICanvas._tempGroupAbleList;
|
|
1666
|
-
var tempRectMaskList = UICanvas._tempRectMaskList;
|
|
1667
|
-
var rectMask = null;
|
|
1668
|
-
var groupAbleCount = 0;
|
|
1669
|
-
for(var i = 0, n = components.length; i < n; i++){
|
|
1670
|
-
var component = components[i];
|
|
1671
|
-
if (!component.enabled) continue;
|
|
1672
|
-
if (_instanceof(component, exports.UIRenderer)) {
|
|
1673
|
-
renderers[depth] = component;
|
|
1674
|
-
++depth;
|
|
1675
|
-
component._isRootCanvasDirty && Utils.setRootCanvas(component, this);
|
|
1676
|
-
if (component._isGroupDirty) {
|
|
1677
|
-
tempGroupAbleList[groupAbleCount++] = component;
|
|
1678
|
-
}
|
|
1679
|
-
component._setRectMasks(tempRectMaskList, rectMaskCount);
|
|
1680
|
-
} else if (_instanceof(component, UIInteractive)) {
|
|
1681
|
-
component._isRootCanvasDirty && Utils.setRootCanvas(component, this);
|
|
1682
|
-
if (component._isGroupDirty) {
|
|
1683
|
-
tempGroupAbleList[groupAbleCount++] = component;
|
|
1684
|
-
}
|
|
1685
|
-
} else if (_instanceof(component, exports.RectMask2D)) {
|
|
1686
|
-
rectMask = component;
|
|
1687
|
-
} else if (_instanceof(component, UIGroup)) {
|
|
1688
|
-
component._isRootCanvasDirty && Utils.setRootCanvas(component, this);
|
|
1689
|
-
component._isGroupDirty && Utils.setGroup(component, group);
|
|
1690
|
-
group = component;
|
|
1691
|
-
}
|
|
1692
|
-
}
|
|
1693
|
-
for(var i1 = 0; i1 < groupAbleCount; i1++){
|
|
1694
|
-
Utils.setGroup(tempGroupAbleList[i1], group);
|
|
1695
|
-
}
|
|
1696
|
-
if (rectMask) {
|
|
1697
|
-
tempRectMaskList[rectMaskCount++] = rectMask;
|
|
1698
|
-
}
|
|
1699
|
-
var children = entity.children;
|
|
1700
|
-
for(var i2 = 0, n1 = children.length; i2 < n1; i2++){
|
|
1701
|
-
var child = children[i2];
|
|
1702
|
-
child.isActive && (depth = this._walk(child, renderers, depth, group, rectMaskCount));
|
|
1703
|
-
}
|
|
1704
|
-
return depth;
|
|
1305
|
+
_proto.onPointerEndDrag = function onPointerEndDrag() {
|
|
1306
|
+
this._isPointerDragging = false;
|
|
1307
|
+
this._updateState(false);
|
|
1705
1308
|
};
|
|
1706
|
-
_proto.
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
if (preCamera !== camera) {
|
|
1710
|
-
this._cameraObserver = camera;
|
|
1711
|
-
if (preCamera) {
|
|
1712
|
-
// @ts-ignore
|
|
1713
|
-
preCamera.entity._updateFlagManager.removeListener(this._onCameraTransformListener);
|
|
1714
|
-
// @ts-ignore
|
|
1715
|
-
preCamera._unRegisterModifyListener(this._onCameraModifyListener);
|
|
1716
|
-
}
|
|
1717
|
-
if (camera) {
|
|
1718
|
-
// @ts-ignore
|
|
1719
|
-
camera.entity._updateFlagManager.addListener(this._onCameraTransformListener);
|
|
1720
|
-
// @ts-ignore
|
|
1721
|
-
camera._registerModifyListener(this._onCameraModifyListener);
|
|
1722
|
-
}
|
|
1723
|
-
}
|
|
1309
|
+
_proto.onPointerEnter = function onPointerEnter() {
|
|
1310
|
+
this._isPointerInside = true;
|
|
1311
|
+
this._updateState(false);
|
|
1724
1312
|
};
|
|
1725
|
-
_proto.
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
break;
|
|
1735
|
-
case engine.CameraModifyFlags.OrthographicSize:
|
|
1736
|
-
this._camera.isOrthographic && this._adapterSizeInScreenSpace();
|
|
1737
|
-
break;
|
|
1738
|
-
case engine.CameraModifyFlags.DisableInScene:
|
|
1739
|
-
this._setRealRenderMode(CanvasRenderMode.ScreenSpaceOverlay);
|
|
1740
|
-
break;
|
|
1741
|
-
}
|
|
1742
|
-
} else {
|
|
1743
|
-
flag === engine.CameraModifyFlags.EnableInScene && this._setRealRenderMode(CanvasRenderMode.ScreenSpaceCamera);
|
|
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();
|
|
1744
1322
|
}
|
|
1745
1323
|
};
|
|
1746
|
-
|
|
1747
|
-
|
|
1324
|
+
/**
|
|
1325
|
+
* @internal
|
|
1326
|
+
*/ _proto._getRootCanvas = function _getRootCanvas() {
|
|
1327
|
+
this._isRootCanvasDirty && Utils.setRootCanvas(this, Utils.searchRootCanvasInParents(this));
|
|
1328
|
+
return this._rootCanvas;
|
|
1748
1329
|
};
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1330
|
+
/**
|
|
1331
|
+
* @internal
|
|
1332
|
+
*/ _proto._getGroup = function _getGroup() {
|
|
1333
|
+
this._isGroupDirty && Utils.setGroup(this, Utils.searchGroupInParents(this));
|
|
1334
|
+
return this._group;
|
|
1752
1335
|
};
|
|
1753
|
-
|
|
1336
|
+
// @ts-ignore
|
|
1337
|
+
_proto._onEnableInScene = function _onEnableInScene() {
|
|
1754
1338
|
// @ts-ignore
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
};
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
this._setRealRenderMode(this._getRealRenderMode());
|
|
1774
|
-
if (isRootCanvas) {
|
|
1775
|
-
this.entity._updateUIHierarchyVersion(UICanvas._hierarchyCounter);
|
|
1776
|
-
} else {
|
|
1777
|
-
var _this1 = this, disorderedElements = _this1._disorderedElements;
|
|
1778
|
-
disorderedElements.forEach(function(element) {
|
|
1779
|
-
if (_instanceof(element, UICanvas)) {
|
|
1780
|
-
var rootCanvas = Utils.searchRootCanvasInParents(element);
|
|
1781
|
-
element._setIsRootCanvas(!rootCanvas);
|
|
1782
|
-
Utils.setRootCanvas(element, rootCanvas);
|
|
1783
|
-
} else {
|
|
1784
|
-
Utils.setRootCanvasDirty(_this);
|
|
1785
|
-
Utils.setGroupDirty(element);
|
|
1786
|
-
}
|
|
1787
|
-
});
|
|
1788
|
-
disorderedElements.length = 0;
|
|
1789
|
-
disorderedElements.garbageCollection();
|
|
1790
|
-
this._orderedRenderers.length = 0;
|
|
1791
|
-
}
|
|
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);
|
|
1792
1357
|
}
|
|
1793
1358
|
};
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
engine.Vector3.transformCoordinate(center, uiTransform.worldMatrix, center);
|
|
1801
|
-
this._centerDirtyFlag.flag = false;
|
|
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);
|
|
1802
1365
|
}
|
|
1803
|
-
return this._center;
|
|
1804
1366
|
};
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
if (mode === CanvasRenderMode.ScreenSpaceCamera && !((_this__camera = this._camera) == null ? void 0 : _this__camera._phasedActiveInScene)) {
|
|
1811
|
-
return CanvasRenderMode.ScreenSpaceOverlay;
|
|
1812
|
-
} else {
|
|
1813
|
-
return mode;
|
|
1814
|
-
}
|
|
1815
|
-
} else {
|
|
1816
|
-
return 4;
|
|
1367
|
+
/**
|
|
1368
|
+
* @internal
|
|
1369
|
+
*/ _proto._onGroupModify = function _onGroupModify(flags) {
|
|
1370
|
+
if (flags & GroupModifyFlags.GlobalInteractive) {
|
|
1371
|
+
this._globalInteractiveDirty = true;
|
|
1817
1372
|
}
|
|
1818
1373
|
};
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
var
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
case CanvasRenderMode.ScreenSpaceCamera:
|
|
1829
|
-
case CanvasRenderMode.WorldSpace:
|
|
1830
|
-
componentsManager.removeUICanvas(this, preRealMode === CanvasRenderMode.ScreenSpaceOverlay);
|
|
1831
|
-
break;
|
|
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);
|
|
1832
1383
|
}
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
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);
|
|
1842
1395
|
}
|
|
1843
1396
|
}
|
|
1844
1397
|
};
|
|
1845
|
-
_proto.
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
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;
|
|
1850
1406
|
}
|
|
1851
|
-
return false;
|
|
1852
1407
|
};
|
|
1853
|
-
_create_class(
|
|
1854
|
-
{
|
|
1855
|
-
key: "referenceResolutionPerUnit",
|
|
1856
|
-
get: /**
|
|
1857
|
-
* The conversion ratio between reference resolution and unit for UI elements in this canvas.
|
|
1858
|
-
*/ function get() {
|
|
1859
|
-
return this._referenceResolutionPerUnit;
|
|
1860
|
-
},
|
|
1861
|
-
set: function set(value) {
|
|
1862
|
-
if (this._referenceResolutionPerUnit !== value) {
|
|
1863
|
-
this._referenceResolutionPerUnit = value;
|
|
1864
|
-
this._disorderedElements.forEach(function(element) {
|
|
1865
|
-
element._onRootCanvasModify == null ? void 0 : element._onRootCanvasModify.call(element, 1);
|
|
1866
|
-
});
|
|
1867
|
-
}
|
|
1868
|
-
}
|
|
1869
|
-
},
|
|
1870
|
-
{
|
|
1871
|
-
key: "referenceResolution",
|
|
1872
|
-
get: /**
|
|
1873
|
-
* The reference resolution of the UI canvas in `ScreenSpaceCamera` and `ScreenSpaceOverlay` mode.
|
|
1874
|
-
*/ function get() {
|
|
1875
|
-
return this._referenceResolution;
|
|
1876
|
-
},
|
|
1877
|
-
set: function set(value) {
|
|
1878
|
-
var referenceResolution = this._referenceResolution;
|
|
1879
|
-
if (referenceResolution === value) return;
|
|
1880
|
-
(referenceResolution.x !== value.x || referenceResolution.y !== value.y) && referenceResolution.copyFrom(value);
|
|
1881
|
-
}
|
|
1882
|
-
},
|
|
1883
|
-
{
|
|
1884
|
-
key: "renderMode",
|
|
1885
|
-
get: /**
|
|
1886
|
-
* The rendering mode of the UI canvas.
|
|
1887
|
-
*/ function get() {
|
|
1888
|
-
return this._renderMode;
|
|
1889
|
-
},
|
|
1890
|
-
set: function set(mode) {
|
|
1891
|
-
var preMode = this._renderMode;
|
|
1892
|
-
if (preMode !== mode) {
|
|
1893
|
-
this._renderMode = mode;
|
|
1894
|
-
this._updateCameraObserver();
|
|
1895
|
-
this._setRealRenderMode(this._getRealRenderMode());
|
|
1896
|
-
}
|
|
1897
|
-
}
|
|
1898
|
-
},
|
|
1899
|
-
{
|
|
1900
|
-
key: "camera",
|
|
1901
|
-
get: /**
|
|
1902
|
-
* The camera associated with this canvas.
|
|
1903
|
-
* @remarks
|
|
1904
|
-
* - `ScreenSpaceCamera` mode: Used for rendering adaptation. Defaults to `ScreenSpaceOverlay` if not assigned.
|
|
1905
|
-
* - `WorldSpace` mode: Used for event detection. If not assigned, events are handled by the highest-priority camera.
|
|
1906
|
-
*/ function get() {
|
|
1907
|
-
return this._camera;
|
|
1908
|
-
},
|
|
1909
|
-
set: function set(value) {
|
|
1910
|
-
var preCamera = this._camera;
|
|
1911
|
-
if (preCamera !== value) {
|
|
1912
|
-
if (value && this._isSameOrChildEntity(value.entity)) {
|
|
1913
|
-
engine.Logger.warn("Camera entity matching or nested within the canvas entity disables canvas auto-adaptation in ScreenSpaceCamera mode.");
|
|
1914
|
-
}
|
|
1915
|
-
this._camera = value;
|
|
1916
|
-
this._updateCameraObserver();
|
|
1917
|
-
var preRenderMode = this._realRenderMode;
|
|
1918
|
-
var curRenderMode = this._getRealRenderMode();
|
|
1919
|
-
if (preRenderMode === curRenderMode) {
|
|
1920
|
-
if (curRenderMode === CanvasRenderMode.ScreenSpaceCamera) {
|
|
1921
|
-
this._adapterPoseInScreenSpace();
|
|
1922
|
-
this._adapterSizeInScreenSpace();
|
|
1923
|
-
}
|
|
1924
|
-
} else {
|
|
1925
|
-
this._setRealRenderMode(curRenderMode);
|
|
1926
|
-
}
|
|
1927
|
-
}
|
|
1928
|
-
}
|
|
1929
|
-
},
|
|
1930
|
-
{
|
|
1931
|
-
key: "renderCamera",
|
|
1932
|
-
get: /**
|
|
1933
|
-
* @deprecated Use {@link camera} instead.
|
|
1934
|
-
*/ function get() {
|
|
1935
|
-
return this.camera;
|
|
1936
|
-
},
|
|
1937
|
-
set: function set(value) {
|
|
1938
|
-
this.camera = value;
|
|
1939
|
-
}
|
|
1940
|
-
},
|
|
1941
|
-
{
|
|
1942
|
-
key: "resolutionAdaptationMode",
|
|
1943
|
-
get: /**
|
|
1944
|
-
* The screen resolution adaptation mode of the UI canvas in `ScreenSpaceCamera` and `ScreenSpaceOverlay` mode.
|
|
1945
|
-
*/ function get() {
|
|
1946
|
-
return this._resolutionAdaptationMode;
|
|
1947
|
-
},
|
|
1948
|
-
set: function set(value) {
|
|
1949
|
-
if (this._resolutionAdaptationMode !== value) {
|
|
1950
|
-
this._resolutionAdaptationMode = value;
|
|
1951
|
-
var realRenderMode = this._realRenderMode;
|
|
1952
|
-
if (realRenderMode === CanvasRenderMode.ScreenSpaceCamera || realRenderMode === CanvasRenderMode.ScreenSpaceOverlay) {
|
|
1953
|
-
this._adapterSizeInScreenSpace();
|
|
1954
|
-
}
|
|
1955
|
-
}
|
|
1956
|
-
}
|
|
1957
|
-
},
|
|
1408
|
+
_create_class(UIInteractive, [
|
|
1958
1409
|
{
|
|
1959
|
-
key: "
|
|
1410
|
+
key: "transitions",
|
|
1960
1411
|
get: /**
|
|
1961
|
-
* The
|
|
1412
|
+
* The transitions of this interactive.
|
|
1962
1413
|
*/ function get() {
|
|
1963
|
-
return this.
|
|
1964
|
-
},
|
|
1965
|
-
set: function set(value) {
|
|
1966
|
-
if (this._sortOrder !== value) {
|
|
1967
|
-
this._sortOrder = value;
|
|
1968
|
-
this._realRenderMode === CanvasRenderMode.ScreenSpaceOverlay && // @ts-ignore
|
|
1969
|
-
(this.scene._componentsManager._overlayCanvasesSortingFlag = true);
|
|
1970
|
-
}
|
|
1414
|
+
return this._transitions;
|
|
1971
1415
|
}
|
|
1972
1416
|
},
|
|
1973
1417
|
{
|
|
1974
|
-
key: "
|
|
1418
|
+
key: "interactive",
|
|
1975
1419
|
get: /**
|
|
1976
|
-
*
|
|
1420
|
+
* Whether the interactive is enabled.
|
|
1977
1421
|
*/ function get() {
|
|
1978
|
-
return this.
|
|
1422
|
+
return this._interactive;
|
|
1979
1423
|
},
|
|
1980
1424
|
set: function set(value) {
|
|
1981
|
-
if (this.
|
|
1982
|
-
this.
|
|
1983
|
-
|
|
1984
|
-
this._adapterPoseInScreenSpace();
|
|
1985
|
-
this._adapterSizeInScreenSpace();
|
|
1986
|
-
}
|
|
1425
|
+
if (this._interactive !== value) {
|
|
1426
|
+
this._interactive = value;
|
|
1427
|
+
this._globalInteractiveDirty = true;
|
|
1987
1428
|
}
|
|
1988
1429
|
}
|
|
1989
1430
|
}
|
|
1990
1431
|
]);
|
|
1991
|
-
return
|
|
1992
|
-
}(engine.
|
|
1993
|
-
/** @internal */ exports.UICanvas._hierarchyCounter = 1;
|
|
1994
|
-
exports.UICanvas._tempGroupAbleList = [];
|
|
1995
|
-
exports.UICanvas._tempRectMaskList = [];
|
|
1996
|
-
exports.UICanvas._tempVec3 = new engine.Vector3();
|
|
1997
|
-
exports.UICanvas._tempMat = new engine.Matrix();
|
|
1998
|
-
__decorate([
|
|
1999
|
-
engine.ignoreClone
|
|
2000
|
-
], exports.UICanvas.prototype, "_canvasIndex", void 0);
|
|
2001
|
-
__decorate([
|
|
2002
|
-
engine.ignoreClone
|
|
2003
|
-
], exports.UICanvas.prototype, "_indexInRootCanvas", void 0);
|
|
2004
|
-
__decorate([
|
|
2005
|
-
engine.ignoreClone
|
|
2006
|
-
], exports.UICanvas.prototype, "_isRootCanvasDirty", void 0);
|
|
2007
|
-
__decorate([
|
|
2008
|
-
engine.ignoreClone
|
|
2009
|
-
], exports.UICanvas.prototype, "_rootCanvasListeningEntities", void 0);
|
|
1432
|
+
return UIInteractive;
|
|
1433
|
+
}(engine.Script);
|
|
2010
1434
|
__decorate([
|
|
2011
1435
|
engine.ignoreClone
|
|
2012
|
-
],
|
|
1436
|
+
], UIInteractive.prototype, "_indexInRootCanvas", void 0);
|
|
2013
1437
|
__decorate([
|
|
2014
1438
|
engine.ignoreClone
|
|
2015
|
-
],
|
|
1439
|
+
], UIInteractive.prototype, "_isRootCanvasDirty", void 0);
|
|
2016
1440
|
__decorate([
|
|
2017
1441
|
engine.ignoreClone
|
|
2018
|
-
],
|
|
1442
|
+
], UIInteractive.prototype, "_rootCanvasListeningEntities", void 0);
|
|
2019
1443
|
__decorate([
|
|
2020
1444
|
engine.ignoreClone
|
|
2021
|
-
],
|
|
1445
|
+
], UIInteractive.prototype, "_indexInGroup", void 0);
|
|
2022
1446
|
__decorate([
|
|
2023
1447
|
engine.ignoreClone
|
|
2024
|
-
],
|
|
1448
|
+
], UIInteractive.prototype, "_isGroupDirty", void 0);
|
|
2025
1449
|
__decorate([
|
|
2026
1450
|
engine.ignoreClone
|
|
2027
|
-
],
|
|
1451
|
+
], UIInteractive.prototype, "_groupListeningEntities", void 0);
|
|
2028
1452
|
__decorate([
|
|
2029
1453
|
engine.ignoreClone
|
|
2030
|
-
],
|
|
1454
|
+
], UIInteractive.prototype, "_globalInteractive", void 0);
|
|
2031
1455
|
__decorate([
|
|
2032
1456
|
engine.ignoreClone
|
|
2033
|
-
],
|
|
1457
|
+
], UIInteractive.prototype, "_globalInteractiveDirty", void 0);
|
|
2034
1458
|
__decorate([
|
|
2035
1459
|
engine.ignoreClone
|
|
2036
|
-
],
|
|
1460
|
+
], UIInteractive.prototype, "_state", void 0);
|
|
2037
1461
|
__decorate([
|
|
2038
1462
|
engine.ignoreClone
|
|
2039
|
-
],
|
|
1463
|
+
], UIInteractive.prototype, "_isPointerInside", void 0);
|
|
2040
1464
|
__decorate([
|
|
2041
1465
|
engine.ignoreClone
|
|
2042
|
-
],
|
|
1466
|
+
], UIInteractive.prototype, "_isPointerDragging", void 0);
|
|
2043
1467
|
__decorate([
|
|
2044
1468
|
engine.ignoreClone
|
|
2045
|
-
],
|
|
1469
|
+
], UIInteractive.prototype, "_groupListener", null);
|
|
2046
1470
|
__decorate([
|
|
2047
1471
|
engine.ignoreClone
|
|
2048
|
-
],
|
|
1472
|
+
], UIInteractive.prototype, "_rootCanvasListener", null);
|
|
2049
1473
|
__decorate([
|
|
2050
1474
|
engine.ignoreClone
|
|
2051
|
-
],
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
]
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
EntityUIModifyFlags[EntityUIModifyFlags["CanvasEnableInScene"] = 4] = "CanvasEnableInScene";
|
|
2059
|
-
EntityUIModifyFlags[EntityUIModifyFlags["GroupEnableInScene"] = 8] = "GroupEnableInScene";
|
|
2060
|
-
return EntityUIModifyFlags;
|
|
2061
|
-
}({});
|
|
2062
|
-
var RootCanvasModifyFlags = /*#__PURE__*/ function(RootCanvasModifyFlags) {
|
|
2063
|
-
RootCanvasModifyFlags[RootCanvasModifyFlags["None"] = 0] = "None";
|
|
2064
|
-
RootCanvasModifyFlags[RootCanvasModifyFlags["ReferenceResolutionPerUnit"] = 1] = "ReferenceResolutionPerUnit";
|
|
2065
|
-
RootCanvasModifyFlags[RootCanvasModifyFlags["All"] = 1] = "All";
|
|
2066
|
-
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;
|
|
2067
1482
|
}({});
|
|
2068
1483
|
|
|
2069
|
-
|
|
2070
|
-
|
|
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;
|
|
2071
1500
|
/**
|
|
2072
|
-
*
|
|
2073
|
-
*/
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
var
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
var components = entity._components;
|
|
2081
|
-
for(var i = 0, n = components.length; i < n; i++){
|
|
2082
|
-
var component = components[i];
|
|
2083
|
-
if (component.enabled && _instanceof(component, exports.UICanvas) && component._isRootCanvas) {
|
|
2084
|
-
rootCanvas = component;
|
|
2085
|
-
}
|
|
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;
|
|
2086
1509
|
}
|
|
2087
|
-
entity = entity.parent;
|
|
2088
|
-
}
|
|
2089
|
-
if (!rootCanvas) return false;
|
|
2090
|
-
// Calculate ray
|
|
2091
|
-
var ray = this._tempRay;
|
|
2092
|
-
switch(rootCanvas._realRenderMode){
|
|
2093
|
-
case CanvasRenderMode.ScreenSpaceOverlay:
|
|
2094
|
-
// Screen to world ( Assume that world units have a one-to-one relationship with pixel units )
|
|
2095
|
-
ray.origin.set(position.x, engine$1.canvas.height - position.y, 1);
|
|
2096
|
-
ray.direction.set(0, 0, -1);
|
|
2097
|
-
break;
|
|
2098
|
-
case CanvasRenderMode.ScreenSpaceCamera:
|
|
2099
|
-
rootCanvas.renderCamera.screenPointToRay(position, ray);
|
|
2100
|
-
break;
|
|
2101
|
-
default:
|
|
2102
|
-
// World space not yet supported, see issue #2793
|
|
2103
|
-
return false;
|
|
2104
|
-
}
|
|
2105
|
-
// Intersect ray with UI plane to get local coordinates
|
|
2106
|
-
var plane = this._tempPlane;
|
|
2107
|
-
var normal = plane.normal.copyFrom(transform.worldForward);
|
|
2108
|
-
plane.distance = -engine.Vector3.dot(normal, transform.worldPosition);
|
|
2109
|
-
var curDistance = ray.intersectPlane(plane);
|
|
2110
|
-
if (curDistance >= 0 && curDistance < Number.MAX_SAFE_INTEGER) {
|
|
2111
|
-
var hitPointWorld = ray.getPoint(curDistance, this._tempVec3);
|
|
2112
|
-
var worldMatrixInv = this._tempMat;
|
|
2113
|
-
engine.Matrix.invert(transform.worldMatrix, worldMatrixInv);
|
|
2114
|
-
engine.Vector3.transformCoordinate(hitPointWorld, worldMatrixInv, out);
|
|
2115
|
-
return true;
|
|
2116
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);
|
|
2117
1516
|
return false;
|
|
2118
1517
|
};
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
this.
|
|
2123
|
-
element._onRootCanvasModify == null ? void 0 : element._onRootCanvasModify.call(element, RootCanvasModifyFlags.All);
|
|
2124
|
-
};
|
|
2125
|
-
Utils.setRootCanvas = function setRootCanvas(element, rootCanvas) {
|
|
2126
|
-
element._isRootCanvasDirty = false;
|
|
2127
|
-
this._registerRootCanvas(element, rootCanvas);
|
|
2128
|
-
var fromEntity = _instanceof(element, exports.UICanvas) ? element.entity.parent : element.entity;
|
|
2129
|
-
var _rootCanvas_entity_parent;
|
|
2130
|
-
var toEntity = (_rootCanvas_entity_parent = rootCanvas == null ? void 0 : rootCanvas.entity.parent) != null ? _rootCanvas_entity_parent : null;
|
|
2131
|
-
this._registerListener(fromEntity, toEntity, element._rootCanvasListener, element._rootCanvasListeningEntities);
|
|
2132
|
-
};
|
|
2133
|
-
Utils.cleanRootCanvas = function cleanRootCanvas(element) {
|
|
2134
|
-
this._registerRootCanvas(element, null);
|
|
2135
|
-
this._unRegisterListener(element._rootCanvasListener, element._rootCanvasListeningEntities);
|
|
2136
|
-
};
|
|
2137
|
-
Utils.searchRootCanvasInParents = function searchRootCanvasInParents(element) {
|
|
2138
|
-
var entity = _instanceof(element, exports.UICanvas) ? element.entity.parent : element.entity;
|
|
2139
|
-
while(entity){
|
|
2140
|
-
// @ts-ignore
|
|
2141
|
-
var components = entity._components;
|
|
2142
|
-
for(var i = 0, n = components.length; i < n; i++){
|
|
2143
|
-
var component = components[i];
|
|
2144
|
-
if (component.enabled && _instanceof(component, exports.UICanvas) && component._isRootCanvas) {
|
|
2145
|
-
return component;
|
|
2146
|
-
}
|
|
2147
|
-
}
|
|
2148
|
-
entity = entity.parent;
|
|
2149
|
-
}
|
|
2150
|
-
return null;
|
|
2151
|
-
};
|
|
2152
|
-
Utils.setGroupDirty = function setGroupDirty(element) {
|
|
2153
|
-
if (element._isGroupDirty) return;
|
|
2154
|
-
element._isGroupDirty = true;
|
|
2155
|
-
this._registerGroup(element, null);
|
|
2156
|
-
element._onGroupModify(GroupModifyFlags.All);
|
|
2157
|
-
};
|
|
2158
|
-
Utils.setGroup = function setGroup(element, group) {
|
|
2159
|
-
element._isGroupDirty = false;
|
|
2160
|
-
this._registerGroup(element, group);
|
|
2161
|
-
var rootCanvas = element._getRootCanvas();
|
|
2162
|
-
if (rootCanvas) {
|
|
2163
|
-
var fromEntity = _instanceof(element, UIGroup) ? element.entity.parent : element.entity;
|
|
2164
|
-
var _group_entity;
|
|
2165
|
-
var toEntity = (_group_entity = group == null ? void 0 : group.entity) != null ? _group_entity : rootCanvas.entity.parent;
|
|
2166
|
-
this._registerListener(fromEntity, toEntity, element._groupListener, element._groupListeningEntities);
|
|
2167
|
-
} else {
|
|
2168
|
-
this._unRegisterListener(element._groupListener, element._groupListeningEntities);
|
|
2169
|
-
}
|
|
2170
|
-
};
|
|
2171
|
-
Utils.cleanGroup = function cleanGroup(element) {
|
|
2172
|
-
this._registerGroup(element, null);
|
|
2173
|
-
this._unRegisterListener(element._groupListener, element._groupListeningEntities);
|
|
1518
|
+
/**
|
|
1519
|
+
* @internal
|
|
1520
|
+
*/ _proto._getRootCanvas = function _getRootCanvas() {
|
|
1521
|
+
return this._rootCanvas;
|
|
2174
1522
|
};
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
var rootCanvasParent = rootCanvas.entity.parent;
|
|
2180
|
-
while(entity && entity !== rootCanvasParent){
|
|
2181
|
-
// @ts-ignore
|
|
2182
|
-
var components = entity._components;
|
|
2183
|
-
for(var i = 0, n = components.length; i < n; i++){
|
|
2184
|
-
var component = components[i];
|
|
2185
|
-
if (component.enabled && _instanceof(component, UIGroup)) {
|
|
2186
|
-
return component;
|
|
2187
|
-
}
|
|
2188
|
-
}
|
|
2189
|
-
entity = entity.parent;
|
|
2190
|
-
}
|
|
2191
|
-
return null;
|
|
1523
|
+
/**
|
|
1524
|
+
* @internal
|
|
1525
|
+
*/ _proto._canRender = function _canRender(camera) {
|
|
1526
|
+
return this._realRenderMode !== CanvasRenderMode.ScreenSpaceCamera || this._camera === camera;
|
|
2192
1527
|
};
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
element._indexInRootCanvas = -1;
|
|
2200
|
-
}
|
|
2201
|
-
if (canvas) {
|
|
2202
|
-
var disorderedElements = canvas._disorderedElements;
|
|
2203
|
-
element._indexInRootCanvas = disorderedElements.length;
|
|
2204
|
-
disorderedElements.add(element);
|
|
2205
|
-
}
|
|
2206
|
-
element._rootCanvas = canvas;
|
|
1528
|
+
/**
|
|
1529
|
+
* @internal
|
|
1530
|
+
*/ _proto._canDispatchEvent = function _canDispatchEvent(camera) {
|
|
1531
|
+
var realMode = this._realRenderMode;
|
|
1532
|
+
if (realMode === CanvasRenderMode.ScreenSpaceOverlay) {
|
|
1533
|
+
return true;
|
|
2207
1534
|
}
|
|
1535
|
+
var assignedCamera = this._camera;
|
|
1536
|
+
// @ts-ignore
|
|
1537
|
+
return !assignedCamera || !assignedCamera._phasedActiveInScene || assignedCamera === camera;
|
|
2208
1538
|
};
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
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;
|
|
2221
1556
|
}
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
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;
|
|
1572
|
+
}
|
|
2236
1573
|
}
|
|
2237
|
-
|
|
2238
|
-
|
|
1574
|
+
renderer._prepareRender(context);
|
|
1575
|
+
renderer._renderFrameCount = frameCount;
|
|
2239
1576
|
}
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
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;
|
|
2246
1583
|
}
|
|
2247
|
-
listeningEntities.length = 0;
|
|
2248
1584
|
};
|
|
2249
|
-
return Utils;
|
|
2250
|
-
}();
|
|
2251
|
-
Utils._tempRay = new engine.Ray();
|
|
2252
|
-
Utils._tempPlane = new engine.Plane();
|
|
2253
|
-
Utils._tempVec3 = new engine.Vector3();
|
|
2254
|
-
Utils._tempMat = new engine.Matrix();
|
|
2255
|
-
|
|
2256
|
-
/**
|
|
2257
|
-
* Interactive component.
|
|
2258
|
-
*/ var UIInteractive = /*#__PURE__*/ function(Script) {
|
|
2259
|
-
_inherits(UIInteractive, Script);
|
|
2260
|
-
function UIInteractive(entity) {
|
|
2261
|
-
var _this;
|
|
2262
|
-
_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;
|
|
2263
|
-
_this._groupListener = _this._groupListener.bind(_this);
|
|
2264
|
-
_this._rootCanvasListener = _this._rootCanvasListener.bind(_this);
|
|
2265
|
-
return _this;
|
|
2266
|
-
}
|
|
2267
|
-
var _proto = UIInteractive.prototype;
|
|
2268
1585
|
/**
|
|
2269
|
-
*
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
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;
|
|
2278
1605
|
}
|
|
2279
1606
|
};
|
|
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
|
+
};
|
|
2280
1626
|
/**
|
|
2281
|
-
*
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
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
|
+
}
|
|
1638
|
+
} else {
|
|
1639
|
+
if (flag === engine.EntityModifyFlags.Parent) {
|
|
1640
|
+
var rootCanvas1 = Utils.searchRootCanvasInParents(this);
|
|
1641
|
+
this._setIsRootCanvas(!rootCanvas1);
|
|
1642
|
+
Utils.setRootCanvas(this, rootCanvas1);
|
|
2292
1643
|
}
|
|
2293
1644
|
}
|
|
2294
1645
|
};
|
|
2295
1646
|
/**
|
|
2296
|
-
*
|
|
2297
|
-
*/ _proto.
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
1647
|
+
* @inheritdoc
|
|
1648
|
+
*/ _proto._onClone = function _onClone(target) {
|
|
1649
|
+
target.renderMode = this._renderMode;
|
|
1650
|
+
};
|
|
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;
|
|
2301
1659
|
}
|
|
2302
|
-
|
|
1660
|
+
return renderers;
|
|
2303
1661
|
};
|
|
2304
|
-
_proto.
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
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);
|
|
2309
1673
|
}
|
|
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);
|
|
2310
1678
|
}
|
|
2311
1679
|
};
|
|
2312
|
-
_proto.
|
|
2313
|
-
|
|
2314
|
-
this.
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
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;
|
|
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);
|
|
2323
1719
|
};
|
|
2324
|
-
_proto.
|
|
2325
|
-
|
|
2326
|
-
|
|
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;
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
for(var i1 = 0; i1 < groupAbleCount; i1++){
|
|
1749
|
+
Utils.setGroup(tempGroupAbleList[i1], group);
|
|
1750
|
+
}
|
|
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));
|
|
1755
|
+
}
|
|
1756
|
+
return depth;
|
|
2327
1757
|
};
|
|
2328
|
-
_proto.
|
|
2329
|
-
|
|
2330
|
-
var
|
|
2331
|
-
|
|
2332
|
-
|
|
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);
|
|
1774
|
+
}
|
|
2333
1775
|
}
|
|
2334
1776
|
};
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
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;
|
|
1793
|
+
}
|
|
1794
|
+
} else {
|
|
1795
|
+
flag === engine.CameraModifyFlags.EnableInScene && this._setRealRenderMode(CanvasRenderMode.ScreenSpaceCamera);
|
|
1796
|
+
}
|
|
2340
1797
|
};
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
*/ _proto._getGroup = function _getGroup() {
|
|
2344
|
-
this._isGroupDirty && Utils.setGroup(this, Utils.searchGroupInParents(this));
|
|
2345
|
-
return this._group;
|
|
1798
|
+
_proto._onCameraTransformListener = function _onCameraTransformListener() {
|
|
1799
|
+
this._realRenderMode === CanvasRenderMode.ScreenSpaceCamera && this._adapterPoseInScreenSpace();
|
|
2346
1800
|
};
|
|
2347
|
-
|
|
2348
|
-
_proto._onEnableInScene = function _onEnableInScene() {
|
|
1801
|
+
_proto._addCanvasListener = function _addCanvasListener() {
|
|
2349
1802
|
// @ts-ignore
|
|
2350
|
-
|
|
2351
|
-
Utils.setRootCanvasDirty(this);
|
|
2352
|
-
Utils.setGroupDirty(this);
|
|
2353
|
-
this._updateState(true);
|
|
1803
|
+
this.engine.canvas._sizeUpdateFlagManager.addListener(this._onCanvasSizeListener);
|
|
2354
1804
|
};
|
|
2355
|
-
|
|
2356
|
-
_proto._onDisableInScene = function _onDisableInScene() {
|
|
1805
|
+
_proto._removeCanvasListener = function _removeCanvasListener() {
|
|
2357
1806
|
// @ts-ignore
|
|
2358
|
-
|
|
2359
|
-
Utils.cleanRootCanvas(this);
|
|
2360
|
-
Utils.cleanGroup(this);
|
|
2361
|
-
this._isPointerInside = this._isPointerDragging = false;
|
|
1807
|
+
this.engine.canvas._sizeUpdateFlagManager.removeListener(this._onCanvasSizeListener);
|
|
2362
1808
|
};
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
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();
|
|
1813
|
+
};
|
|
1814
|
+
_proto._onReferenceResolutionChanged = function _onReferenceResolutionChanged() {
|
|
1815
|
+
var realRenderMode = this._realRenderMode;
|
|
1816
|
+
if (realRenderMode === CanvasRenderMode.ScreenSpaceOverlay || realRenderMode === CanvasRenderMode.ScreenSpaceCamera) {
|
|
1817
|
+
this._adapterSizeInScreenSpace();
|
|
2368
1818
|
}
|
|
2369
1819
|
};
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
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
|
+
}
|
|
2376
1844
|
}
|
|
2377
1845
|
};
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
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;
|
|
2383
1854
|
}
|
|
1855
|
+
return this._center;
|
|
2384
1856
|
};
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
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;
|
|
2394
1866
|
}
|
|
2395
|
-
|
|
1867
|
+
} else {
|
|
1868
|
+
return 4;
|
|
2396
1869
|
}
|
|
2397
|
-
return this._globalInteractive;
|
|
2398
1870
|
};
|
|
2399
|
-
_proto.
|
|
2400
|
-
var
|
|
2401
|
-
if (
|
|
2402
|
-
this.
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
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;
|
|
1894
|
+
}
|
|
1895
|
+
}
|
|
1896
|
+
};
|
|
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;
|
|
2406
1991
|
}
|
|
2407
|
-
}
|
|
2408
|
-
};
|
|
2409
|
-
_proto._getInteractiveState = function _getInteractiveState() {
|
|
2410
|
-
if (!this._getGlobalInteractive()) {
|
|
2411
|
-
return 3;
|
|
2412
|
-
}
|
|
2413
|
-
if (this._isPointerDragging) {
|
|
2414
|
-
return 1;
|
|
2415
|
-
} else {
|
|
2416
|
-
return this._isPointerInside ? 2 : 0;
|
|
2417
|
-
}
|
|
2418
|
-
};
|
|
2419
|
-
_create_class(UIInteractive, [
|
|
1992
|
+
},
|
|
2420
1993
|
{
|
|
2421
|
-
key: "
|
|
1994
|
+
key: "resolutionAdaptationMode",
|
|
2422
1995
|
get: /**
|
|
2423
|
-
* The
|
|
1996
|
+
* The screen resolution adaptation mode of the UI canvas in `ScreenSpaceCamera` and `ScreenSpaceOverlay` mode.
|
|
2424
1997
|
*/ function get() {
|
|
2425
|
-
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
|
+
}
|
|
2426
2008
|
}
|
|
2427
2009
|
},
|
|
2428
2010
|
{
|
|
2429
|
-
key: "
|
|
2011
|
+
key: "sortOrder",
|
|
2430
2012
|
get: /**
|
|
2431
|
-
*
|
|
2013
|
+
* The rendering order priority of the UI canvas in `ScreenSpaceOverlay` mode.
|
|
2432
2014
|
*/ function get() {
|
|
2433
|
-
return this.
|
|
2015
|
+
return this._sortOrder;
|
|
2434
2016
|
},
|
|
2435
2017
|
set: function set(value) {
|
|
2436
|
-
if (this.
|
|
2437
|
-
this.
|
|
2438
|
-
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
|
+
}
|
|
2439
2039
|
}
|
|
2440
2040
|
}
|
|
2441
2041
|
}
|
|
2442
2042
|
]);
|
|
2443
|
-
return
|
|
2444
|
-
}(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();
|
|
2445
2049
|
__decorate([
|
|
2446
2050
|
engine.ignoreClone
|
|
2447
|
-
],
|
|
2051
|
+
], exports.UICanvas.prototype, "_canvasIndex", void 0);
|
|
2448
2052
|
__decorate([
|
|
2449
2053
|
engine.ignoreClone
|
|
2450
|
-
],
|
|
2054
|
+
], exports.UICanvas.prototype, "_indexInRootCanvas", void 0);
|
|
2451
2055
|
__decorate([
|
|
2452
2056
|
engine.ignoreClone
|
|
2453
|
-
],
|
|
2057
|
+
], exports.UICanvas.prototype, "_isRootCanvasDirty", void 0);
|
|
2454
2058
|
__decorate([
|
|
2455
2059
|
engine.ignoreClone
|
|
2456
|
-
],
|
|
2060
|
+
], exports.UICanvas.prototype, "_rootCanvasListeningEntities", void 0);
|
|
2457
2061
|
__decorate([
|
|
2458
2062
|
engine.ignoreClone
|
|
2459
|
-
],
|
|
2063
|
+
], exports.UICanvas.prototype, "_isRootCanvas", void 0);
|
|
2460
2064
|
__decorate([
|
|
2461
2065
|
engine.ignoreClone
|
|
2462
|
-
],
|
|
2066
|
+
], exports.UICanvas.prototype, "_renderElements", void 0);
|
|
2463
2067
|
__decorate([
|
|
2464
2068
|
engine.ignoreClone
|
|
2465
|
-
],
|
|
2069
|
+
], exports.UICanvas.prototype, "_batchedRenderElements", void 0);
|
|
2466
2070
|
__decorate([
|
|
2467
2071
|
engine.ignoreClone
|
|
2468
|
-
],
|
|
2072
|
+
], exports.UICanvas.prototype, "_sortDistance", void 0);
|
|
2469
2073
|
__decorate([
|
|
2470
2074
|
engine.ignoreClone
|
|
2471
|
-
],
|
|
2075
|
+
], exports.UICanvas.prototype, "_orderedRenderers", void 0);
|
|
2472
2076
|
__decorate([
|
|
2473
2077
|
engine.ignoreClone
|
|
2474
|
-
],
|
|
2078
|
+
], exports.UICanvas.prototype, "_realRenderMode", void 0);
|
|
2475
2079
|
__decorate([
|
|
2476
2080
|
engine.ignoreClone
|
|
2477
|
-
],
|
|
2081
|
+
], exports.UICanvas.prototype, "_renderMode", void 0);
|
|
2478
2082
|
__decorate([
|
|
2479
2083
|
engine.ignoreClone
|
|
2480
|
-
],
|
|
2084
|
+
], exports.UICanvas.prototype, "_hierarchyVersion", void 0);
|
|
2481
2085
|
__decorate([
|
|
2482
2086
|
engine.ignoreClone
|
|
2483
|
-
],
|
|
2087
|
+
], exports.UICanvas.prototype, "_center", void 0);
|
|
2484
2088
|
__decorate([
|
|
2485
2089
|
engine.ignoreClone
|
|
2486
|
-
],
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
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;
|
|
2493
2118
|
}({});
|
|
2494
2119
|
|
|
2495
2120
|
var Button = /*#__PURE__*/ function(UIInteractive) {
|
|
@@ -2529,7 +2154,7 @@ var Button = /*#__PURE__*/ function(UIInteractive) {
|
|
|
2529
2154
|
_inherits(Image, UIRenderer1);
|
|
2530
2155
|
function Image(entity) {
|
|
2531
2156
|
var _this;
|
|
2532
|
-
_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;
|
|
2533
2158
|
_this.drawMode = engine.SpriteDrawMode.Simple;
|
|
2534
2159
|
// @ts-ignore
|
|
2535
2160
|
_this.setMaterial(_this._engine._getUIDefaultMaterial());
|
|
@@ -2550,10 +2175,9 @@ var Button = /*#__PURE__*/ function(UIInteractive) {
|
|
|
2550
2175
|
}
|
|
2551
2176
|
};
|
|
2552
2177
|
/**
|
|
2553
|
-
* @
|
|
2554
|
-
*/ _proto.
|
|
2555
|
-
|
|
2556
|
-
UIRenderer1.prototype._cloneTo.call(this, target);
|
|
2178
|
+
* @inheritdoc
|
|
2179
|
+
*/ _proto._onClone = function _onClone(target) {
|
|
2180
|
+
UIRenderer1.prototype._onClone.call(this, target);
|
|
2557
2181
|
target.sprite = this._sprite;
|
|
2558
2182
|
target.drawMode = this._drawMode;
|
|
2559
2183
|
};
|
|
@@ -2618,7 +2242,7 @@ var Button = /*#__PURE__*/ function(UIInteractive) {
|
|
|
2618
2242
|
canvas._renderElements.push(renderElement);
|
|
2619
2243
|
};
|
|
2620
2244
|
_proto._onTransformChanged = function _onTransformChanged(type) {
|
|
2621
|
-
if (type & UITransformModifyFlags.Size &&
|
|
2245
|
+
if (type & UITransformModifyFlags.Size && this._drawMode === engine.SpriteDrawMode.Tiled) {
|
|
2622
2246
|
this._dirtyUpdateFlag |= 15;
|
|
2623
2247
|
}
|
|
2624
2248
|
this._dirtyUpdateFlag |= engine.RendererUpdateFlags.WorldVolume;
|
|
@@ -2646,9 +2270,6 @@ var Button = /*#__PURE__*/ function(UIInteractive) {
|
|
|
2646
2270
|
case engine.SpriteDrawMode.Tiled:
|
|
2647
2271
|
this._dirtyUpdateFlag |= 7;
|
|
2648
2272
|
break;
|
|
2649
|
-
case engine.SpriteDrawMode.Filled:
|
|
2650
|
-
this._dirtyUpdateFlag |= 7;
|
|
2651
|
-
break;
|
|
2652
2273
|
}
|
|
2653
2274
|
break;
|
|
2654
2275
|
case engine.SpriteModifyFlags.border:
|
|
@@ -2666,25 +2287,13 @@ var Button = /*#__PURE__*/ function(UIInteractive) {
|
|
|
2666
2287
|
this._dirtyUpdateFlag |= 5;
|
|
2667
2288
|
break;
|
|
2668
2289
|
case engine.SpriteModifyFlags.atlasRegion:
|
|
2669
|
-
this._dirtyUpdateFlag |=
|
|
2290
|
+
this._dirtyUpdateFlag |= 4;
|
|
2670
2291
|
break;
|
|
2671
2292
|
case engine.SpriteModifyFlags.destroy:
|
|
2672
2293
|
this.sprite = null;
|
|
2673
2294
|
break;
|
|
2674
2295
|
}
|
|
2675
2296
|
};
|
|
2676
|
-
Image._correctOrigin = function _correctOrigin(mode, origin) {
|
|
2677
|
-
switch(mode){
|
|
2678
|
-
case engine.SpriteFilledMode.Horizontal:
|
|
2679
|
-
return origin === engine.SpriteFilledOrigin.Left || origin === engine.SpriteFilledOrigin.Right ? origin : engine.SpriteFilledOrigin.Left;
|
|
2680
|
-
case engine.SpriteFilledMode.Vertical:
|
|
2681
|
-
return origin === engine.SpriteFilledOrigin.Top || origin === engine.SpriteFilledOrigin.Bottom ? origin : engine.SpriteFilledOrigin.Bottom;
|
|
2682
|
-
case engine.SpriteFilledMode.Radial90:
|
|
2683
|
-
return origin === engine.SpriteFilledOrigin.TopLeft || origin === engine.SpriteFilledOrigin.TopRight || origin === engine.SpriteFilledOrigin.BottomLeft || origin === engine.SpriteFilledOrigin.BottomRight ? origin : engine.SpriteFilledOrigin.BottomLeft;
|
|
2684
|
-
default:
|
|
2685
|
-
return origin === engine.SpriteFilledOrigin.Top || origin === engine.SpriteFilledOrigin.Bottom || origin === engine.SpriteFilledOrigin.Left || origin === engine.SpriteFilledOrigin.Right ? origin : engine.SpriteFilledOrigin.Bottom;
|
|
2686
|
-
}
|
|
2687
|
-
};
|
|
2688
2297
|
_create_class(Image, [
|
|
2689
2298
|
{
|
|
2690
2299
|
key: "drawMode",
|
|
@@ -2706,9 +2315,6 @@ var Button = /*#__PURE__*/ function(UIInteractive) {
|
|
|
2706
2315
|
case engine.SpriteDrawMode.Tiled:
|
|
2707
2316
|
this._assembler = engine.TiledSpriteAssembler;
|
|
2708
2317
|
break;
|
|
2709
|
-
case engine.SpriteDrawMode.Filled:
|
|
2710
|
-
this._assembler = engine.FilledSpriteAssembler;
|
|
2711
|
-
break;
|
|
2712
2318
|
}
|
|
2713
2319
|
this._assembler.resetData(this);
|
|
2714
2320
|
this._dirtyUpdateFlag |= 7;
|
|
@@ -2748,73 +2354,6 @@ var Button = /*#__PURE__*/ function(UIInteractive) {
|
|
|
2748
2354
|
}
|
|
2749
2355
|
}
|
|
2750
2356
|
},
|
|
2751
|
-
{
|
|
2752
|
-
key: "filledAmount",
|
|
2753
|
-
get: /**
|
|
2754
|
-
* The fill amount of the image, range from 0 to 1. (Only works in filled mode.)
|
|
2755
|
-
*/ function get() {
|
|
2756
|
-
return this._filledAmount;
|
|
2757
|
-
},
|
|
2758
|
-
set: function set(value) {
|
|
2759
|
-
value = engine.MathUtil.clamp(value, 0, 1);
|
|
2760
|
-
if (this._filledAmount !== value) {
|
|
2761
|
-
this._filledAmount = value;
|
|
2762
|
-
if (this._drawMode === engine.SpriteDrawMode.Filled) {
|
|
2763
|
-
this._dirtyUpdateFlag |= 5;
|
|
2764
|
-
}
|
|
2765
|
-
}
|
|
2766
|
-
}
|
|
2767
|
-
},
|
|
2768
|
-
{
|
|
2769
|
-
key: "filledMode",
|
|
2770
|
-
get: /**
|
|
2771
|
-
* The fill mode of the image. (Only works in filled mode.)
|
|
2772
|
-
*/ function get() {
|
|
2773
|
-
return this._filledMode;
|
|
2774
|
-
},
|
|
2775
|
-
set: function set(value) {
|
|
2776
|
-
if (this._filledMode !== value) {
|
|
2777
|
-
this._filledMode = value;
|
|
2778
|
-
this._filledOrigin = Image._correctOrigin(value, this._filledOrigin);
|
|
2779
|
-
if (this._drawMode === engine.SpriteDrawMode.Filled) {
|
|
2780
|
-
this._dirtyUpdateFlag |= 5;
|
|
2781
|
-
}
|
|
2782
|
-
}
|
|
2783
|
-
}
|
|
2784
|
-
},
|
|
2785
|
-
{
|
|
2786
|
-
key: "filledOrigin",
|
|
2787
|
-
get: /**
|
|
2788
|
-
* The fill origin of the image. (Only works in filled mode.)
|
|
2789
|
-
*/ function get() {
|
|
2790
|
-
return this._filledOrigin;
|
|
2791
|
-
},
|
|
2792
|
-
set: function set(value) {
|
|
2793
|
-
value = Image._correctOrigin(this._filledMode, value);
|
|
2794
|
-
if (this._filledOrigin !== value) {
|
|
2795
|
-
this._filledOrigin = value;
|
|
2796
|
-
if (this._drawMode === engine.SpriteDrawMode.Filled) {
|
|
2797
|
-
this._dirtyUpdateFlag |= 5;
|
|
2798
|
-
}
|
|
2799
|
-
}
|
|
2800
|
-
}
|
|
2801
|
-
},
|
|
2802
|
-
{
|
|
2803
|
-
key: "filledClockWise",
|
|
2804
|
-
get: /**
|
|
2805
|
-
* Whether the fill is clockwise. (Only works in filled radial mode.)
|
|
2806
|
-
*/ function get() {
|
|
2807
|
-
return this._filledClockWise;
|
|
2808
|
-
},
|
|
2809
|
-
set: function set(value) {
|
|
2810
|
-
if (this._filledClockWise !== value) {
|
|
2811
|
-
this._filledClockWise = value;
|
|
2812
|
-
if (this._drawMode === engine.SpriteDrawMode.Filled) {
|
|
2813
|
-
this._dirtyUpdateFlag |= 5;
|
|
2814
|
-
}
|
|
2815
|
-
}
|
|
2816
|
-
}
|
|
2817
|
-
},
|
|
2818
2357
|
{
|
|
2819
2358
|
key: "sprite",
|
|
2820
2359
|
get: /**
|
|
@@ -2862,87 +2401,19 @@ __decorate([
|
|
|
2862
2401
|
engine.ignoreClone
|
|
2863
2402
|
], Image.prototype, "_onSpriteChange", null);
|
|
2864
2403
|
|
|
2865
|
-
/**
|
|
2866
|
-
* UI component that uses a sprite to mask child UI renderers via stencil.
|
|
2867
|
-
*/ var Mask = /*#__PURE__*/ function(_MaskRenderable) {
|
|
2868
|
-
_inherits(Mask, _MaskRenderable);
|
|
2869
|
-
function Mask(entity) {
|
|
2870
|
-
var _this;
|
|
2871
|
-
_this = _MaskRenderable.call(this, entity) || this;
|
|
2872
|
-
_this._initMask();
|
|
2873
|
-
_this.raycastEnabled = false;
|
|
2874
|
-
return _this;
|
|
2875
|
-
}
|
|
2876
|
-
var _proto = Mask.prototype;
|
|
2877
|
-
/**
|
|
2878
|
-
* @internal
|
|
2879
|
-
*/ _proto._getChunkManager = function _getChunkManager() {
|
|
2880
|
-
// @ts-ignore
|
|
2881
|
-
return this.engine._batcherManager.primitiveChunkManagerMask;
|
|
2882
|
-
};
|
|
2883
|
-
/**
|
|
2884
|
-
* @internal
|
|
2885
|
-
*/ // @ts-ignore
|
|
2886
|
-
_proto._cloneTo = function _cloneTo(target) {
|
|
2887
|
-
// @ts-ignore
|
|
2888
|
-
_MaskRenderable.prototype._cloneTo.call(this, target);
|
|
2889
|
-
this._cloneMaskData(target);
|
|
2890
|
-
};
|
|
2891
|
-
_proto._updateBounds = function _updateBounds(worldBounds) {
|
|
2892
|
-
var rootCanvas = this._getRootCanvas();
|
|
2893
|
-
if (this.sprite && rootCanvas) {
|
|
2894
|
-
this._updateMaskBounds(worldBounds);
|
|
2895
|
-
} else {
|
|
2896
|
-
var worldPosition = this._transformEntity.transform.worldPosition;
|
|
2897
|
-
worldBounds.min.copyFrom(worldPosition);
|
|
2898
|
-
worldBounds.max.copyFrom(worldPosition);
|
|
2899
|
-
}
|
|
2900
|
-
};
|
|
2901
|
-
/**
|
|
2902
|
-
* @inheritdoc
|
|
2903
|
-
*/ _proto._render = function _render(context) {
|
|
2904
|
-
this._renderMask(0);
|
|
2905
|
-
};
|
|
2906
|
-
/**
|
|
2907
|
-
* @inheritdoc
|
|
2908
|
-
*/ _proto._onDestroy = function _onDestroy() {
|
|
2909
|
-
this._destroyMaskResources();
|
|
2910
|
-
_MaskRenderable.prototype._onDestroy.call(this);
|
|
2911
|
-
if (this._subChunk) {
|
|
2912
|
-
this._getChunkManager().freeSubChunk(this._subChunk);
|
|
2913
|
-
this._subChunk = null;
|
|
2914
|
-
}
|
|
2915
|
-
};
|
|
2916
|
-
_proto._getSpriteWidth = function _getSpriteWidth() {
|
|
2917
|
-
return this._transformEntity.transform.size.x;
|
|
2918
|
-
};
|
|
2919
|
-
_proto._getSpriteHeight = function _getSpriteHeight() {
|
|
2920
|
-
return this._transformEntity.transform.size.y;
|
|
2921
|
-
};
|
|
2922
|
-
_proto._getSpritePivot = function _getSpritePivot() {
|
|
2923
|
-
return this._transformEntity.transform.pivot;
|
|
2924
|
-
};
|
|
2925
|
-
return Mask;
|
|
2926
|
-
}(engine.MaskRenderable(exports.UIRenderer));
|
|
2927
|
-
|
|
2928
2404
|
/**
|
|
2929
2405
|
* UI component used to render text.
|
|
2930
2406
|
*/ var Text = /*#__PURE__*/ function(UIRenderer1) {
|
|
2931
2407
|
_inherits(Text, UIRenderer1);
|
|
2932
2408
|
function Text(entity) {
|
|
2933
2409
|
var _this;
|
|
2934
|
-
_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;
|
|
2935
2411
|
var engine$1 = _this.engine;
|
|
2936
2412
|
// @ts-ignore
|
|
2937
2413
|
_this.font = engine$1._textDefaultFont;
|
|
2938
2414
|
_this.raycastEnabled = false;
|
|
2939
2415
|
// @ts-ignore
|
|
2940
2416
|
_this.setMaterial(engine$1._basicResources.textDefaultMaterial);
|
|
2941
|
-
var shaderData = _this.shaderData;
|
|
2942
|
-
shaderData.setFloat(Text._outlineWidthProperty, _this._outlineWidth);
|
|
2943
|
-
shaderData.setColor(Text._outlineColorProperty, _this._outlineColor);
|
|
2944
|
-
// @ts-ignore
|
|
2945
|
-
_this._outlineColor._onValueChanged = _this._onOutlineColorChanged.bind(_this);
|
|
2946
2417
|
return _this;
|
|
2947
2418
|
}
|
|
2948
2419
|
var _proto = Text.prototype;
|
|
@@ -2988,13 +2459,13 @@ __decorate([
|
|
|
2988
2459
|
this._setDirtyFlagTrue(25);
|
|
2989
2460
|
}
|
|
2990
2461
|
};
|
|
2991
|
-
/**
|
|
2992
|
-
* @internal
|
|
2993
|
-
*/ _proto._canBatch = function _canBatch(preElement, curElement) {
|
|
2994
|
-
return engine.VertexMergeBatcher.canBatchText(preElement, curElement);
|
|
2995
|
-
};
|
|
2996
2462
|
_proto._updateBounds = function _updateBounds(worldBounds) {
|
|
2997
|
-
|
|
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);
|
|
2998
2469
|
};
|
|
2999
2470
|
_proto._render = function _render(context) {
|
|
3000
2471
|
if (this._isTextNoVisible()) {
|
|
@@ -3025,7 +2496,6 @@ __decorate([
|
|
|
3025
2496
|
var distanceForSort = canvas._sortDistance;
|
|
3026
2497
|
var textChunks = this._textChunks;
|
|
3027
2498
|
var subShader = material.shader.subShaders[0];
|
|
3028
|
-
var textTextureSize = Text._tempVec20;
|
|
3029
2499
|
for(var i = 0, n = textChunks.length; i < n; ++i){
|
|
3030
2500
|
var // @ts-ignore
|
|
3031
2501
|
_renderElement;
|
|
@@ -3034,7 +2504,6 @@ __decorate([
|
|
|
3034
2504
|
renderElement.set(this, material, subChunk.chunk.primitive, subChunk.subMesh, texture, subChunk);
|
|
3035
2505
|
(_renderElement = renderElement).shaderData || (_renderElement.shaderData = new engine.ShaderData(engine.ShaderDataGroup.RenderElement));
|
|
3036
2506
|
renderElement.shaderData.setTexture(Text._textTextureProperty, texture);
|
|
3037
|
-
renderElement.shaderData.setVector2(Text._textTextureSizeProperty, textTextureSize.set(texture.width, texture.height));
|
|
3038
2507
|
renderElement.subShader = subShader;
|
|
3039
2508
|
renderElement.priority = priority;
|
|
3040
2509
|
renderElement.distanceForSort = distanceForSort;
|
|
@@ -3047,15 +2516,6 @@ __decorate([
|
|
|
3047
2516
|
this._subFont = font._getSubFont(this.fontSize, this.fontStyle);
|
|
3048
2517
|
this._subFont.nativeFontString = engine.TextUtils.getNativeFontString(font.name, this.fontSize, this.fontStyle);
|
|
3049
2518
|
};
|
|
3050
|
-
/**
|
|
3051
|
-
* Switch the sub font to a specific font size, used by the SHRINK overflow measurement.
|
|
3052
|
-
*/ _proto._applyFontSizeForShrink = function _applyFontSizeForShrink(fontSize) {
|
|
3053
|
-
var font = this._font;
|
|
3054
|
-
// @ts-ignore
|
|
3055
|
-
var subFont = font._getSubFont(fontSize, this._fontStyle);
|
|
3056
|
-
subFont.nativeFontString = engine.TextUtils.getNativeFontString(font.name, fontSize, this._fontStyle);
|
|
3057
|
-
this._subFont = subFont;
|
|
3058
|
-
};
|
|
3059
2519
|
_proto._updatePosition = function _updatePosition() {
|
|
3060
2520
|
var e = this._transformEntity.transform.worldMatrix.elements;
|
|
3061
2521
|
// prettier-ignore
|
|
@@ -3108,30 +2568,18 @@ __decorate([
|
|
|
3108
2568
|
}
|
|
3109
2569
|
};
|
|
3110
2570
|
_proto._updateLocalData = function _updateLocalData() {
|
|
3111
|
-
var _this = this;
|
|
3112
2571
|
// @ts-ignore
|
|
3113
2572
|
var pixelsPerResolution = engine.Engine._pixelsPerUnit / this._getRootCanvas().referenceResolutionPerUnit;
|
|
3114
2573
|
var _this__localBounds = this._localBounds, min = _this__localBounds.min, max = _this__localBounds.max;
|
|
3115
2574
|
var charRenderInfos = Text._charRenderInfos;
|
|
2575
|
+
var charFont = this._getSubFont();
|
|
3116
2576
|
var _this__transformEntity_transform = this._transformEntity.transform, size = _this__transformEntity_transform.size, pivot = _this__transformEntity_transform.pivot;
|
|
3117
2577
|
var rendererWidth = size.x;
|
|
3118
2578
|
var rendererHeight = size.y;
|
|
3119
2579
|
var offsetWidth = rendererWidth * (0.5 - pivot.x);
|
|
3120
2580
|
var offsetHeight = rendererHeight * (0.5 - pivot.y);
|
|
3121
|
-
var
|
|
3122
|
-
var textMetrics;
|
|
3123
|
-
if (this._overflowMode === engine.OverflowMode.Shrink) {
|
|
3124
|
-
var result = engine.TextUtils.measureTextWithShrink(this, rendererWidth * pixelsPerResolution, rendererHeight * pixelsPerResolution, this._fontSize, this._lineSpacing, this._characterSpacing, this.enableWrapping, function(sizeValue) {
|
|
3125
|
-
return _this._applyFontSizeForShrink(sizeValue);
|
|
3126
|
-
});
|
|
3127
|
-
fontSize = result.fontSize;
|
|
3128
|
-
textMetrics = result.metrics;
|
|
3129
|
-
} else {
|
|
3130
|
-
var characterSpacing = this._characterSpacing * fontSize;
|
|
3131
|
-
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);
|
|
3132
|
-
}
|
|
3133
|
-
var charFont = this._getSubFont();
|
|
3134
|
-
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);
|
|
3135
2583
|
var height = textMetrics.height, lines = textMetrics.lines, lineWidths = textMetrics.lineWidths, lineHeight = textMetrics.lineHeight, lineMaxSizes = textMetrics.lineMaxSizes;
|
|
3136
2584
|
// @ts-ignore
|
|
3137
2585
|
var charRenderInfoPool = this.engine._charRenderInfoPool;
|
|
@@ -3152,10 +2600,7 @@ __decorate([
|
|
|
3152
2600
|
startY = rendererHeight * 0.5 - halfLineHeight + topDiff;
|
|
3153
2601
|
break;
|
|
3154
2602
|
case engine.TextVerticalAlignment.Center:
|
|
3155
|
-
|
|
3156
|
-
// `height` — which equals the renderer height for Truncate/Shrink and would otherwise
|
|
3157
|
-
// push the text upward by (rendererHeight - blockHeight) / 2 when the box is taller.
|
|
3158
|
-
startY = lineHeight * linesLen * 0.5 - halfLineHeight - (bottomDiff - topDiff) * 0.5;
|
|
2603
|
+
startY = height * 0.5 - halfLineHeight - (bottomDiff - topDiff) * 0.5;
|
|
3159
2604
|
break;
|
|
3160
2605
|
case engine.TextVerticalAlignment.Bottom:
|
|
3161
2606
|
startY = height - rendererHeight * 0.5 - halfLineHeight - bottomDiff;
|
|
@@ -3196,18 +2641,17 @@ __decorate([
|
|
|
3196
2641
|
charRenderInfo.texture = charFont._getTextureByIndex(charInfo.index);
|
|
3197
2642
|
charRenderInfo.uvs = charInfo.uvs;
|
|
3198
2643
|
var w = charInfo.w, ascent = charInfo.ascent, descent = charInfo.descent;
|
|
3199
|
-
var
|
|
3200
|
-
var
|
|
3201
|
-
var
|
|
3202
|
-
var
|
|
3203
|
-
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;
|
|
3204
2648
|
localPositions.set(left, top, right, bottom);
|
|
3205
2649
|
i === firstLine && (maxY = Math.max(maxY, top));
|
|
3206
2650
|
minY = Math.min(minY, bottom);
|
|
3207
2651
|
j === firstRow && (minX = Math.min(minX, left));
|
|
3208
2652
|
maxX = Math.max(maxX, right);
|
|
3209
2653
|
}
|
|
3210
|
-
startX += charInfo.xAdvance +
|
|
2654
|
+
startX += charInfo.xAdvance + characterSpacing;
|
|
3211
2655
|
}
|
|
3212
2656
|
}
|
|
3213
2657
|
startY -= lineHeight;
|
|
@@ -3267,7 +2711,7 @@ __decorate([
|
|
|
3267
2711
|
};
|
|
3268
2712
|
_proto._isTextNoVisible = function _isTextNoVisible() {
|
|
3269
2713
|
var size = this._transformEntity.transform.size;
|
|
3270
|
-
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();
|
|
3271
2715
|
};
|
|
3272
2716
|
_proto._buildChunk = function _buildChunk(textChunk, count) {
|
|
3273
2717
|
var _this_color = this.color, r = _this_color.r, g = _this_color.g, b = _this_color.b, a = _this_color.a;
|
|
@@ -3278,10 +2722,6 @@ __decorate([
|
|
|
3278
2722
|
var vertices = subChunk.chunk.vertices;
|
|
3279
2723
|
var indices = subChunk.indices = [];
|
|
3280
2724
|
var charRenderInfos = textChunk.charRenderInfos;
|
|
3281
|
-
var ow = this._outlineWidth;
|
|
3282
|
-
var texture = textChunk.texture;
|
|
3283
|
-
var owU = ow > 0 ? ow / texture.width : 0;
|
|
3284
|
-
var owV = ow > 0 ? ow / texture.height : 0;
|
|
3285
2725
|
for(var i = 0, ii = 0, io = 0, vo = subChunk.vertexArea.start + 3; i < count; ++i, io += 4){
|
|
3286
2726
|
var charRenderInfo = charRenderInfos[i];
|
|
3287
2727
|
charRenderInfo.indexInChunk = i;
|
|
@@ -3289,13 +2729,10 @@ __decorate([
|
|
|
3289
2729
|
for(var j = 0; j < tempIndicesLength; ++j){
|
|
3290
2730
|
indices[ii++] = tempIndices[j] + io;
|
|
3291
2731
|
}
|
|
3292
|
-
// Set uv and color for vertices
|
|
2732
|
+
// Set uv and color for vertices
|
|
3293
2733
|
for(var j1 = 0; j1 < 4; ++j1, vo += 9){
|
|
3294
2734
|
var uv = charRenderInfo.uvs[j1];
|
|
3295
|
-
|
|
3296
|
-
var sv = j1 >= 2 ? 1 : -1;
|
|
3297
|
-
vertices[vo] = uv.x + owU * su;
|
|
3298
|
-
vertices[vo + 1] = uv.y + owV * sv;
|
|
2735
|
+
uv.copyToArray(vertices, vo);
|
|
3299
2736
|
vertices[vo + 2] = r;
|
|
3300
2737
|
vertices[vo + 3] = g;
|
|
3301
2738
|
vertices[vo + 4] = b;
|
|
@@ -3322,9 +2759,6 @@ __decorate([
|
|
|
3322
2759
|
}
|
|
3323
2760
|
textChunks.length = 0;
|
|
3324
2761
|
};
|
|
3325
|
-
_proto._onOutlineColorChanged = function _onOutlineColorChanged() {
|
|
3326
|
-
this.shaderData.setColor(Text._outlineColorProperty, this._outlineColor);
|
|
3327
|
-
};
|
|
3328
2762
|
_create_class(Text, [
|
|
3329
2763
|
{
|
|
3330
2764
|
key: "text",
|
|
@@ -3471,32 +2905,14 @@ __decorate([
|
|
|
3471
2905
|
}
|
|
3472
2906
|
},
|
|
3473
2907
|
{
|
|
3474
|
-
key: "
|
|
3475
|
-
get: /**
|
|
3476
|
-
* The outline width in pixels. 0 means outline is disabled. Clamped to [0, 8].
|
|
3477
|
-
*/ function get() {
|
|
3478
|
-
return this._outlineWidth;
|
|
3479
|
-
},
|
|
3480
|
-
set: function set(value) {
|
|
3481
|
-
value = Math.max(0, Math.min(value, 3));
|
|
3482
|
-
if (this._outlineWidth !== value) {
|
|
3483
|
-
this._outlineWidth = value;
|
|
3484
|
-
this.shaderData.setFloat(Text._outlineWidthProperty, value);
|
|
3485
|
-
this._setDirtyFlagTrue(25);
|
|
3486
|
-
}
|
|
3487
|
-
}
|
|
3488
|
-
},
|
|
3489
|
-
{
|
|
3490
|
-
key: "outlineColor",
|
|
2908
|
+
key: "maskLayer",
|
|
3491
2909
|
get: /**
|
|
3492
|
-
* The
|
|
2910
|
+
* The mask layer the sprite renderer belongs to.
|
|
3493
2911
|
*/ function get() {
|
|
3494
|
-
return this.
|
|
2912
|
+
return this._maskLayer;
|
|
3495
2913
|
},
|
|
3496
2914
|
set: function set(value) {
|
|
3497
|
-
|
|
3498
|
-
this._outlineColor.copyFrom(value);
|
|
3499
|
-
}
|
|
2915
|
+
this._maskLayer = value;
|
|
3500
2916
|
}
|
|
3501
2917
|
},
|
|
3502
2918
|
{
|
|
@@ -3507,14 +2923,8 @@ __decorate([
|
|
|
3507
2923
|
if (this._isTextNoVisible()) {
|
|
3508
2924
|
if (this._isContainDirtyFlag(engine.RendererUpdateFlags.WorldVolume)) {
|
|
3509
2925
|
var localBounds = this._localBounds;
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
localBounds.max.set(0, 0, 0);
|
|
3513
|
-
} else {
|
|
3514
|
-
var _this_entity_transform = this.entity.transform, size = _this_entity_transform.size, pivot = _this_entity_transform.pivot;
|
|
3515
|
-
localBounds.min.set(-size.x * pivot.x, -size.y * pivot.y, 0);
|
|
3516
|
-
localBounds.max.set(size.x * (1 - pivot.x), size.y * (1 - pivot.y), 0);
|
|
3517
|
-
}
|
|
2926
|
+
localBounds.min.set(0, 0, 0);
|
|
2927
|
+
localBounds.max.set(0, 0, 0);
|
|
3518
2928
|
this._updateBounds(this._bounds);
|
|
3519
2929
|
this._setDirtyFlagFalse(engine.RendererUpdateFlags.WorldVolume);
|
|
3520
2930
|
}
|
|
@@ -3532,9 +2942,6 @@ __decorate([
|
|
|
3532
2942
|
return Text;
|
|
3533
2943
|
}(exports.UIRenderer);
|
|
3534
2944
|
Text._textTextureProperty = engine.ShaderProperty.getByName("renderElement_TextTexture");
|
|
3535
|
-
Text._textTextureSizeProperty = engine.ShaderProperty.getByName("renderElement_TextTextureSize");
|
|
3536
|
-
Text._outlineColorProperty = engine.ShaderProperty.getByName("renderer_OutlineColor");
|
|
3537
|
-
Text._outlineWidthProperty = engine.ShaderProperty.getByName("renderer_OutlineWidth");
|
|
3538
2945
|
Text._worldPositions = [
|
|
3539
2946
|
new engine.Vector3(),
|
|
3540
2947
|
new engine.Vector3(),
|
|
@@ -3554,9 +2961,6 @@ __decorate([
|
|
|
3554
2961
|
__decorate([
|
|
3555
2962
|
engine.ignoreClone
|
|
3556
2963
|
], Text.prototype, "_onTransformChanged", null);
|
|
3557
|
-
__decorate([
|
|
3558
|
-
engine.ignoreClone
|
|
3559
|
-
], Text.prototype, "_onOutlineColorChanged", null);
|
|
3560
2964
|
var TextChunk = function TextChunk() {
|
|
3561
2965
|
this.charRenderInfos = new Array();
|
|
3562
2966
|
};
|
|
@@ -3580,8 +2984,8 @@ var TextChunk = function TextChunk() {
|
|
|
3580
2984
|
this._target = null;
|
|
3581
2985
|
};
|
|
3582
2986
|
/**
|
|
3583
|
-
* @
|
|
3584
|
-
*/ _proto.
|
|
2987
|
+
* @inheritdoc
|
|
2988
|
+
*/ _proto._onClone = function _onClone(target) {
|
|
3585
2989
|
target._addStateValuesReferCount(1);
|
|
3586
2990
|
};
|
|
3587
2991
|
/**
|
|
@@ -3881,19 +3285,17 @@ __decorate([
|
|
|
3881
3285
|
|
|
3882
3286
|
var GUIComponent = /*#__PURE__*/Object.freeze({
|
|
3883
3287
|
__proto__: null,
|
|
3288
|
+
get UICanvas () { return exports.UICanvas; },
|
|
3289
|
+
UIGroup: UIGroup,
|
|
3290
|
+
get UIRenderer () { return exports.UIRenderer; },
|
|
3291
|
+
UITransform: UITransform,
|
|
3884
3292
|
Button: Button,
|
|
3885
3293
|
Image: Image,
|
|
3886
|
-
Mask: Mask,
|
|
3887
|
-
get RectMask2D () { return exports.RectMask2D; },
|
|
3888
3294
|
Text: Text,
|
|
3889
3295
|
ColorTransition: ColorTransition,
|
|
3890
3296
|
ScaleTransition: ScaleTransition,
|
|
3891
3297
|
SpriteTransition: SpriteTransition,
|
|
3892
|
-
Transition: Transition
|
|
3893
|
-
get UICanvas () { return exports.UICanvas; },
|
|
3894
|
-
UIGroup: UIGroup,
|
|
3895
|
-
get UIRenderer () { return exports.UIRenderer; },
|
|
3896
|
-
UITransform: UITransform
|
|
3298
|
+
Transition: Transition
|
|
3897
3299
|
});
|
|
3898
3300
|
|
|
3899
3301
|
/**
|
|
@@ -3972,11 +3374,11 @@ exports.UIPointerEventEmitter = /*#__PURE__*/ function(PointerEventEmitter1) {
|
|
|
3972
3374
|
}
|
|
3973
3375
|
}
|
|
3974
3376
|
if (camera.clearFlags & engine.CameraClearFlags.Color) {
|
|
3975
|
-
this._updateRaycast(null
|
|
3377
|
+
this._updateRaycast(null);
|
|
3976
3378
|
return;
|
|
3977
3379
|
}
|
|
3978
3380
|
}
|
|
3979
|
-
this._updateRaycast(null
|
|
3381
|
+
this._updateRaycast(null);
|
|
3980
3382
|
}
|
|
3981
3383
|
};
|
|
3982
3384
|
_proto.processDrag = function processDrag(pointer) {
|
|
@@ -4006,7 +3408,10 @@ exports.UIPointerEventEmitter = /*#__PURE__*/ function(PointerEventEmitter1) {
|
|
|
4006
3408
|
if (pressedPath.length > 0) {
|
|
4007
3409
|
var common = UIPointerEventEmitter._tempArray0;
|
|
4008
3410
|
if (this._findCommonInPath(enteredPath, pressedPath, common)) {
|
|
4009
|
-
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
|
+
}
|
|
4010
3415
|
common.length = 0;
|
|
4011
3416
|
}
|
|
4012
3417
|
}
|
|
@@ -4038,16 +3443,18 @@ exports.UIPointerEventEmitter = /*#__PURE__*/ function(PointerEventEmitter1) {
|
|
|
4038
3443
|
this._enteredPath.length = this._pressedPath.length = this._draggedPath.length = 0;
|
|
4039
3444
|
};
|
|
4040
3445
|
_proto._updateRaycast = function _updateRaycast(element, pointer) {
|
|
3446
|
+
if (pointer === void 0) pointer = null;
|
|
4041
3447
|
var enteredPath = this._enteredPath;
|
|
4042
3448
|
var curPath = this._composedPath(element, UIPointerEventEmitter._path);
|
|
4043
3449
|
var add = UIPointerEventEmitter._tempArray0;
|
|
4044
3450
|
var del = UIPointerEventEmitter._tempArray1;
|
|
4045
3451
|
if (this._findDiffInPath(enteredPath, curPath, add, del)) {
|
|
3452
|
+
var eventData = this._createEventData(pointer);
|
|
4046
3453
|
for(var i = 0, n = add.length; i < n; i++){
|
|
4047
|
-
this._fireEnter(add[i],
|
|
3454
|
+
this._fireEnter(add[i], eventData);
|
|
4048
3455
|
}
|
|
4049
3456
|
for(var i1 = 0, n1 = del.length; i1 < n1; i1++){
|
|
4050
|
-
this._fireExit(del[i1],
|
|
3457
|
+
this._fireExit(del[i1], eventData);
|
|
4051
3458
|
}
|
|
4052
3459
|
var length = enteredPath.length = curPath.length;
|
|
4053
3460
|
for(var i2 = 0; i2 < length; i2++){
|
|
@@ -4117,9 +3524,8 @@ exports.UIPointerEventEmitter = /*#__PURE__*/ function(PointerEventEmitter1) {
|
|
|
4117
3524
|
_proto._bubble = function _bubble(path, pointer, fireEvent) {
|
|
4118
3525
|
var length = path.length;
|
|
4119
3526
|
if (length <= 0) return;
|
|
4120
|
-
var eventData = this._createEventData(pointer
|
|
3527
|
+
var eventData = this._createEventData(pointer);
|
|
4121
3528
|
for(var i = 0; i < length; i++){
|
|
4122
|
-
eventData.currentTarget = path[i];
|
|
4123
3529
|
fireEvent(path[i], eventData);
|
|
4124
3530
|
}
|
|
4125
3531
|
};
|
|
@@ -4196,7 +3602,6 @@ exports.EngineExtension = EngineExtension;
|
|
|
4196
3602
|
exports.EntityExtension = EntityExtension;
|
|
4197
3603
|
exports.HorizontalAlignmentMode = HorizontalAlignmentMode;
|
|
4198
3604
|
exports.Image = Image;
|
|
4199
|
-
exports.Mask = Mask;
|
|
4200
3605
|
exports.ResolutionAdaptationMode = ResolutionAdaptationMode;
|
|
4201
3606
|
exports.ScaleTransition = ScaleTransition;
|
|
4202
3607
|
exports.SpriteTransition = SpriteTransition;
|