@galacean/engine-ui 0.0.0-experimental-1.4-small-language.3 → 0.0.0-experimental-backup.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/main.js DELETED
@@ -1,3242 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var engine = require('@galacean/engine');
6
-
7
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
8
- try {
9
- var info = gen[key](arg);
10
- var value = info.value;
11
- } catch (error) {
12
- reject(error);
13
- return;
14
- }
15
- if (info.done) resolve(value);
16
- else Promise.resolve(value).then(_next, _throw);
17
- }
18
- function _async_to_generator(fn) {
19
- return function() {
20
- var self = this, args = arguments;
21
-
22
- return new Promise(function(resolve, reject) {
23
- var gen = fn.apply(self, args);
24
-
25
- function _next(value) {
26
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
27
- }
28
-
29
- function _throw(err) {
30
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
31
- }
32
-
33
- _next(undefined);
34
- });
35
- };
36
- }
37
-
38
- /******************************************************************************
39
- Copyright (c) Microsoft Corporation.
40
-
41
- Permission to use, copy, modify, and/or distribute this software for any
42
- purpose with or without fee is hereby granted.
43
-
44
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
45
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
46
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
47
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
48
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
49
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
50
- PERFORMANCE OF THIS SOFTWARE.
51
- ***************************************************************************** */
52
-
53
- function __decorate(decorators, target, key, desc) {
54
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
55
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
56
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
57
- return c > 3 && r && Object.defineProperty(target, key, r), r;
58
- }
59
-
60
- function __generator(thisArg, body) {
61
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
62
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
63
- function verb(n) { return function (v) { return step([n, v]); }; }
64
- function step(op) {
65
- if (f) throw new TypeError("Generator is already executing.");
66
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
67
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
68
- if (y = 0, t) op = [op[0] & 2, t.value];
69
- switch (op[0]) {
70
- case 0: case 1: t = op; break;
71
- case 4: _.label++; return { value: op[1], done: false };
72
- case 5: _.label++; y = op[1]; op = [0]; continue;
73
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
74
- default:
75
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
76
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
77
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
78
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
79
- if (t[2]) _.ops.pop();
80
- _.trys.pop(); continue;
81
- }
82
- op = body.call(thisArg, _);
83
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
84
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
85
- }
86
- }
87
-
88
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
89
- var e = new Error(message);
90
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
91
- };
92
-
93
- function _defineProperties(target, props) {
94
- for (var i = 0; i < props.length; i++) {
95
- var descriptor = props[i];
96
- descriptor.enumerable = descriptor.enumerable || false;
97
- descriptor.configurable = true;
98
-
99
- if ("value" in descriptor) descriptor.writable = true;
100
-
101
- Object.defineProperty(target, descriptor.key, descriptor);
102
- }
103
- }
104
- function _create_class(Constructor, protoProps, staticProps) {
105
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
106
- if (staticProps) _defineProperties(Constructor, staticProps);
107
-
108
- return Constructor;
109
- }
110
-
111
- function _set_prototype_of(o, p) {
112
- _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
113
- o.__proto__ = p;
114
-
115
- return o;
116
- };
117
-
118
- return _set_prototype_of(o, p);
119
- }
120
-
121
- function _inherits(subClass, superClass) {
122
- if (typeof superClass !== "function" && superClass !== null) {
123
- throw new TypeError("Super expression must either be null or a function");
124
- }
125
-
126
- subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } });
127
-
128
- if (superClass) _set_prototype_of(subClass, superClass);
129
- }
130
-
131
- function _instanceof(left, right) {
132
- if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
133
- return !!right[Symbol.hasInstance](left);
134
- } else return left instanceof right;
135
- }
136
-
137
- var UIGroup = /*#__PURE__*/ function(Component) {
138
- _inherits(UIGroup, Component);
139
- function UIGroup(entity) {
140
- var _this;
141
- _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 = true, /** @internal */ _this._isGroupDirty = true, /** @internal */ _this._groupDirtyFlags = 0;
142
- _this._rootCanvasListener = _this._rootCanvasListener.bind(_this);
143
- _this._groupListener = _this._groupListener.bind(_this);
144
- return _this;
145
- }
146
- var _proto = UIGroup.prototype;
147
- /**
148
- * @internal
149
- */ _proto._getGlobalAlpha = function _getGlobalAlpha() {
150
- if (this._isContainDirtyFlag(1)) {
151
- if (this._ignoreParentGroup) {
152
- this._globalAlpha = this._alpha;
153
- } else {
154
- var parentGroup = this._getGroup();
155
- this._globalAlpha = this._alpha * (parentGroup ? parentGroup._getGlobalAlpha() : 1);
156
- }
157
- this._setDirtyFlagFalse(1);
158
- }
159
- return this._globalAlpha;
160
- };
161
- /**
162
- * @internal
163
- */ _proto._getGlobalInteractive = function _getGlobalInteractive() {
164
- if (this._isContainDirtyFlag(2)) {
165
- if (this._ignoreParentGroup) {
166
- this._globalInteractive = this._interactive;
167
- } else {
168
- var parentGroup = this._getGroup();
169
- this._globalInteractive = this._interactive && (!parentGroup || parentGroup._getGlobalInteractive());
170
- }
171
- this._setDirtyFlagFalse(2);
172
- }
173
- return this._globalInteractive;
174
- };
175
- // @ts-ignore
176
- _proto._onEnableInScene = function _onEnableInScene() {
177
- Utils.setRootCanvasDirty(this);
178
- Utils.setGroupDirty(this);
179
- // @ts-ignore
180
- this.entity._dispatchModify(EntityUIModifyFlags.GroupEnableInScene);
181
- };
182
- // @ts-ignore
183
- _proto._onDisableInScene = function _onDisableInScene() {
184
- Utils.cleanRootCanvas(this);
185
- Utils.cleanGroup(this);
186
- var disorderedElements = this._disorderedElements;
187
- disorderedElements.forEach(function(element) {
188
- Utils.setGroupDirty(element);
189
- });
190
- disorderedElements.length = 0;
191
- disorderedElements.garbageCollection();
192
- this._isRootCanvasDirty = this._isGroupDirty = false;
193
- };
194
- /**
195
- * @internal
196
- */ _proto._getRootCanvas = function _getRootCanvas() {
197
- this._isRootCanvasDirty && Utils.setRootCanvas(this, Utils.searchRootCanvasInParents(this));
198
- return this._rootCanvas;
199
- };
200
- /**
201
- * @internal
202
- */ _proto._getGroup = function _getGroup() {
203
- this._isGroupDirty && Utils.setGroup(this, Utils.searchGroupInParents(this));
204
- return this._group;
205
- };
206
- /**
207
- * @internal
208
- */ _proto._groupListener = function _groupListener(flag) {
209
- if (flag === engine.EntityModifyFlags.Parent || flag === EntityUIModifyFlags.GroupEnableInScene) {
210
- Utils.setGroupDirty(this);
211
- }
212
- };
213
- /**
214
- * @internal
215
- */ _proto._rootCanvasListener = function _rootCanvasListener(flag) {
216
- if (flag === engine.EntityModifyFlags.Parent || flag === EntityUIModifyFlags.CanvasEnableInScene) {
217
- Utils.setRootCanvasDirty(this);
218
- Utils.setGroupDirty(this);
219
- }
220
- };
221
- /**
222
- * @internal
223
- */ _proto._onGroupModify = function _onGroupModify(flags, isPass) {
224
- if (isPass === void 0) isPass = false;
225
- if (isPass && this._ignoreParentGroup) return;
226
- if (this._isContainDirtyFlags(flags)) return;
227
- this._setDirtyFlagTrue(flags);
228
- this._disorderedElements.forEach(function(element) {
229
- element._onGroupModify(flags, true);
230
- });
231
- };
232
- _proto._isContainDirtyFlags = function _isContainDirtyFlags(targetDirtyFlags) {
233
- return (this._groupDirtyFlags & targetDirtyFlags) === targetDirtyFlags;
234
- };
235
- _proto._isContainDirtyFlag = function _isContainDirtyFlag(type) {
236
- return (this._groupDirtyFlags & type) != 0;
237
- };
238
- _proto._setDirtyFlagTrue = function _setDirtyFlagTrue(type) {
239
- this._groupDirtyFlags |= type;
240
- };
241
- _proto._setDirtyFlagFalse = function _setDirtyFlagFalse(type) {
242
- this._groupDirtyFlags &= ~type;
243
- };
244
- _create_class(UIGroup, [
245
- {
246
- key: "ignoreParentGroup",
247
- get: /**
248
- * Whether to ignore the parent group.
249
- * @remarks If this parameter set to `true`,
250
- * all settings of the parent group will be ignored.
251
- */ function get() {
252
- return this._ignoreParentGroup;
253
- },
254
- set: function set(value) {
255
- if (this._ignoreParentGroup !== value) {
256
- this._ignoreParentGroup = value;
257
- this._onGroupModify(3);
258
- }
259
- }
260
- },
261
- {
262
- key: "interactive",
263
- get: /**
264
- * Whether the group is interactive.
265
- */ function get() {
266
- return this._interactive;
267
- },
268
- set: function set(value) {
269
- if (this._interactive !== value) {
270
- this._interactive = value;
271
- this._onGroupModify(2);
272
- }
273
- }
274
- },
275
- {
276
- key: "alpha",
277
- get: /**
278
- * The alpha value of the group.
279
- */ function get() {
280
- return this._alpha;
281
- },
282
- set: function set(value) {
283
- value = Math.max(0, Math.min(value, 1));
284
- if (this._alpha !== value) {
285
- this._alpha = value;
286
- this._onGroupModify(1);
287
- }
288
- }
289
- }
290
- ]);
291
- return UIGroup;
292
- }(engine.Component);
293
- __decorate([
294
- engine.ignoreClone
295
- ], UIGroup.prototype, "_indexInGroup", void 0);
296
- __decorate([
297
- engine.ignoreClone
298
- ], UIGroup.prototype, "_indexInRootCanvas", void 0);
299
- __decorate([
300
- engine.ignoreClone
301
- ], UIGroup.prototype, "_group", void 0);
302
- __decorate([
303
- engine.ignoreClone
304
- ], UIGroup.prototype, "_rootCanvas", void 0);
305
- __decorate([
306
- engine.ignoreClone
307
- ], UIGroup.prototype, "_disorderedElements", void 0);
308
- __decorate([
309
- engine.ignoreClone
310
- ], UIGroup.prototype, "_globalAlpha", void 0);
311
- __decorate([
312
- engine.assignmentClone
313
- ], UIGroup.prototype, "_alpha", void 0);
314
- __decorate([
315
- engine.assignmentClone
316
- ], UIGroup.prototype, "_interactive", void 0);
317
- __decorate([
318
- engine.assignmentClone
319
- ], UIGroup.prototype, "_ignoreParentGroup", void 0);
320
- __decorate([
321
- engine.ignoreClone
322
- ], UIGroup.prototype, "_rootCanvasListeningEntities", void 0);
323
- __decorate([
324
- engine.ignoreClone
325
- ], UIGroup.prototype, "_groupListeningEntities", void 0);
326
- __decorate([
327
- engine.ignoreClone
328
- ], UIGroup.prototype, "_isRootCanvasDirty", void 0);
329
- __decorate([
330
- engine.ignoreClone
331
- ], UIGroup.prototype, "_isGroupDirty", void 0);
332
- __decorate([
333
- engine.ignoreClone
334
- ], UIGroup.prototype, "_groupDirtyFlags", void 0);
335
- __decorate([
336
- engine.ignoreClone
337
- ], UIGroup.prototype, "_groupListener", null);
338
- __decorate([
339
- engine.ignoreClone
340
- ], UIGroup.prototype, "_rootCanvasListener", null);
341
- var GroupModifyFlags = /*#__PURE__*/ function(GroupModifyFlags) {
342
- GroupModifyFlags[GroupModifyFlags["None"] = 0] = "None";
343
- GroupModifyFlags[GroupModifyFlags["GlobalAlpha"] = 1] = "GlobalAlpha";
344
- GroupModifyFlags[GroupModifyFlags["GlobalInteractive"] = 2] = "GlobalInteractive";
345
- GroupModifyFlags[GroupModifyFlags["All"] = 3] = "All";
346
- return GroupModifyFlags;
347
- }({});
348
-
349
- var Utils = /*#__PURE__*/ function() {
350
- function Utils() {}
351
- Utils.setRootCanvasDirty = function setRootCanvasDirty(element) {
352
- if (element._isRootCanvasDirty) return;
353
- element._isRootCanvasDirty = true;
354
- this._registerRootCanvas(element, null);
355
- element._onRootCanvasModify == null ? void 0 : element._onRootCanvasModify.call(element, RootCanvasModifyFlags.All);
356
- };
357
- Utils.setRootCanvas = function setRootCanvas(element, rootCanvas) {
358
- element._isRootCanvasDirty = false;
359
- this._registerRootCanvas(element, rootCanvas);
360
- var fromEntity = _instanceof(element, exports.UICanvas) ? element.entity.parent : element.entity;
361
- var _rootCanvas_entity_parent;
362
- var toEntity = (_rootCanvas_entity_parent = rootCanvas == null ? void 0 : rootCanvas.entity.parent) != null ? _rootCanvas_entity_parent : null;
363
- this._registerListener(fromEntity, toEntity, element._rootCanvasListener, element._rootCanvasListeningEntities);
364
- };
365
- Utils.cleanRootCanvas = function cleanRootCanvas(element) {
366
- this._registerRootCanvas(element, null);
367
- this._unRegisterListener(element._rootCanvasListener, element._rootCanvasListeningEntities);
368
- };
369
- Utils.searchRootCanvasInParents = function searchRootCanvasInParents(element) {
370
- var entity = _instanceof(element, exports.UICanvas) ? element.entity.parent : element.entity;
371
- while(entity){
372
- // @ts-ignore
373
- var components = entity._components;
374
- for(var i = 0, n = components.length; i < n; i++){
375
- var component = components[i];
376
- if (component.enabled && _instanceof(component, exports.UICanvas) && component._isRootCanvas) {
377
- return component;
378
- }
379
- }
380
- entity = entity.parent;
381
- }
382
- return null;
383
- };
384
- Utils.setGroupDirty = function setGroupDirty(element) {
385
- if (element._isGroupDirty) return;
386
- element._isGroupDirty = true;
387
- this._registerGroup(element, null);
388
- element._onGroupModify(GroupModifyFlags.All);
389
- };
390
- Utils.setGroup = function setGroup(element, group) {
391
- element._isGroupDirty = false;
392
- this._registerGroup(element, group);
393
- var rootCanvas = element._getRootCanvas();
394
- if (rootCanvas) {
395
- var fromEntity = _instanceof(element, UIGroup) ? element.entity.parent : element.entity;
396
- var _group_entity;
397
- var toEntity = (_group_entity = group == null ? void 0 : group.entity) != null ? _group_entity : rootCanvas.entity.parent;
398
- this._registerListener(fromEntity, toEntity, element._groupListener, element._groupListeningEntities);
399
- } else {
400
- this._unRegisterListener(element._groupListener, element._groupListeningEntities);
401
- }
402
- };
403
- Utils.cleanGroup = function cleanGroup(element) {
404
- this._registerGroup(element, null);
405
- this._unRegisterListener(element._groupListener, element._groupListeningEntities);
406
- };
407
- Utils.searchGroupInParents = function searchGroupInParents(element) {
408
- var rootCanvas = element._getRootCanvas();
409
- if (!rootCanvas) return null;
410
- var entity = _instanceof(element, UIGroup) ? element.entity.parent : element.entity;
411
- var rootCanvasParent = rootCanvas.entity.parent;
412
- while(entity && entity !== rootCanvasParent){
413
- // @ts-ignore
414
- var components = entity._components;
415
- for(var i = 0, n = components.length; i < n; i++){
416
- var component = components[i];
417
- if (component.enabled && _instanceof(component, UIGroup)) {
418
- return component;
419
- }
420
- }
421
- entity = entity.parent;
422
- }
423
- return null;
424
- };
425
- Utils._registerRootCanvas = function _registerRootCanvas(element, canvas) {
426
- var preCanvas = element._rootCanvas;
427
- if (preCanvas !== canvas) {
428
- if (preCanvas) {
429
- var replaced = preCanvas._disorderedElements.deleteByIndex(element._indexInRootCanvas);
430
- replaced && (replaced._indexInRootCanvas = element._indexInRootCanvas);
431
- element._indexInRootCanvas = -1;
432
- }
433
- if (canvas) {
434
- var disorderedElements = canvas._disorderedElements;
435
- element._indexInRootCanvas = disorderedElements.length;
436
- disorderedElements.add(element);
437
- }
438
- element._rootCanvas = canvas;
439
- }
440
- };
441
- Utils._registerGroup = function _registerGroup(element, group) {
442
- var preGroup = element._group;
443
- if (preGroup !== group) {
444
- if (preGroup) {
445
- var replaced = preGroup._disorderedElements.deleteByIndex(element._indexInGroup);
446
- replaced && (replaced._indexInGroup = element._indexInGroup);
447
- element._indexInGroup = -1;
448
- }
449
- if (group) {
450
- var disorderedElements = group._disorderedElements;
451
- element._indexInGroup = disorderedElements.length;
452
- disorderedElements.add(element);
453
- }
454
- element._group = group;
455
- element._onGroupModify(GroupModifyFlags.All);
456
- }
457
- };
458
- Utils._registerListener = function _registerListener(entity, root, listener, listeningEntities) {
459
- var count = 0;
460
- while(entity && entity !== root){
461
- var preEntity = listeningEntities[count];
462
- if (preEntity !== entity) {
463
- // @ts-ignore
464
- preEntity == null ? void 0 : preEntity._unRegisterModifyListener(listener);
465
- listeningEntities[count] = entity;
466
- // @ts-ignore
467
- entity._registerModifyListener(listener);
468
- }
469
- entity = entity.parent;
470
- count++;
471
- }
472
- listeningEntities.length = count;
473
- };
474
- Utils._unRegisterListener = function _unRegisterListener(listener, listeningEntities) {
475
- for(var i = 0, n = listeningEntities.length; i < n; i++){
476
- // @ts-ignore
477
- listeningEntities[i]._unRegisterModifyListener(listener);
478
- }
479
- listeningEntities.length = 0;
480
- };
481
- return Utils;
482
- }();
483
-
484
- /**
485
- * Render mode for ui canvas.
486
- */ var CanvasRenderMode = /*#__PURE__*/ function(CanvasRenderMode) {
487
- /**
488
- * The UI canvas will be rendered directly onto the screen and adapted to screen space,
489
- * overlaying other rendering elements in the same scene.
490
- * @remarks if the `engine.canvas` size change, the UI canvas will automatically adapt.
491
- */ CanvasRenderMode[CanvasRenderMode["ScreenSpaceOverlay"] = 0] = "ScreenSpaceOverlay";
492
- /**
493
- * The UI canvas is placed at a specified distance in front of the camera and adapted to screen space,
494
- * with all objects rendered by the camera.
495
- * @remarks if the camera's properties or the `engine.canvas` size change, the UI canvas will automatically adapt.
496
- * @remarks if set `ScreenSpaceCamera` but no corresponding camera is assigned, the actual rendering mode defaults to `ScreenSpaceOverlay`.
497
- */ CanvasRenderMode[CanvasRenderMode["ScreenSpaceCamera"] = 1] = "ScreenSpaceCamera";
498
- /**
499
- * The UI canvas is placed in the 3D world space and rendered by every camera in the same scene.
500
- */ CanvasRenderMode[CanvasRenderMode["WorldSpace"] = 2] = "WorldSpace";
501
- return CanvasRenderMode;
502
- }({});
503
-
504
- /**
505
- * Resolution adaptation mode.
506
- * @remarks Only effective in screen space.
507
- */ var ResolutionAdaptationMode = /*#__PURE__*/ function(ResolutionAdaptationMode) {
508
- /** Adapt based on width.(`referenceResolution.x`) */ ResolutionAdaptationMode[ResolutionAdaptationMode["WidthAdaptation"] = 0] = "WidthAdaptation";
509
- /** Adapt based on height.(`referenceResolution.y`) */ ResolutionAdaptationMode[ResolutionAdaptationMode["HeightAdaptation"] = 1] = "HeightAdaptation";
510
- /** Adapt based on both width and height.(`referenceResolution`) */ ResolutionAdaptationMode[ResolutionAdaptationMode["BothAdaptation"] = 2] = "BothAdaptation";
511
- /** Adapt to the side with a larger ratio. */ ResolutionAdaptationMode[ResolutionAdaptationMode["ExpandAdaptation"] = 3] = "ExpandAdaptation";
512
- /** Adapt to the side with smaller ratio. */ ResolutionAdaptationMode[ResolutionAdaptationMode["ShrinkAdaptation"] = 4] = "ShrinkAdaptation";
513
- return ResolutionAdaptationMode;
514
- }({});
515
-
516
- /**
517
- * The Transform component exclusive to the UI element.
518
- */ var UITransform = /*#__PURE__*/ function(Transform) {
519
- _inherits(UITransform, Transform);
520
- function UITransform(entity) {
521
- var _this;
522
- _this = Transform.call(this, entity) || this, _this._size = new engine.Vector2(100, 100), _this._pivot = new engine.Vector2(0.5, 0.5);
523
- // @ts-ignore
524
- _this._size._onValueChanged = _this._onSizeChange.bind(_this);
525
- // @ts-ignore
526
- _this._pivot._onValueChanged = _this._onPivotChange.bind(_this);
527
- return _this;
528
- }
529
- var _proto = UITransform.prototype;
530
- _proto._onSizeChange = function _onSizeChange() {
531
- // @ts-ignore
532
- this._entity._updateFlagManager.dispatch(512);
533
- };
534
- _proto._onPivotChange = function _onPivotChange() {
535
- // @ts-ignore
536
- this._entity._updateFlagManager.dispatch(1024);
537
- };
538
- _create_class(UITransform, [
539
- {
540
- key: "size",
541
- get: /**
542
- * Width and height of UI element.
543
- */ function get() {
544
- return this._size;
545
- },
546
- set: function set(value) {
547
- var _this = this, size = _this._size;
548
- if (size === value) return;
549
- (size.x !== value.x || size.y !== value.y) && size.copyFrom(value);
550
- }
551
- },
552
- {
553
- key: "pivot",
554
- get: /**
555
- * Pivot of UI element.
556
- */ function get() {
557
- return this._pivot;
558
- },
559
- set: function set(value) {
560
- var _this = this, pivot = _this._pivot;
561
- if (pivot === value) return;
562
- (pivot.x !== value.x || pivot.y !== value.y) && pivot.copyFrom(value);
563
- }
564
- }
565
- ]);
566
- return UITransform;
567
- }(engine.Transform);
568
- __decorate([
569
- engine.deepClone
570
- ], UITransform.prototype, "_size", void 0);
571
- __decorate([
572
- engine.deepClone
573
- ], UITransform.prototype, "_pivot", void 0);
574
- __decorate([
575
- engine.ignoreClone
576
- ], UITransform.prototype, "_onSizeChange", null);
577
- __decorate([
578
- engine.ignoreClone
579
- ], UITransform.prototype, "_onPivotChange", null);
580
- /**
581
- * @internal
582
- * extends TransformModifyFlags
583
- */ var UITransformModifyFlags = /*#__PURE__*/ function(UITransformModifyFlags) {
584
- /** Size. */ UITransformModifyFlags[UITransformModifyFlags["Size"] = 512] = "Size";
585
- /** Pivot. */ UITransformModifyFlags[UITransformModifyFlags["Pivot"] = 1024] = "Pivot";
586
- return UITransformModifyFlags;
587
- }({});
588
-
589
- exports.UIRenderer = /*#__PURE__*/ function(Renderer) {
590
- _inherits(UIRenderer, Renderer);
591
- function UIRenderer(entity) {
592
- var _this;
593
- _this = Renderer.call(this, entity) || this, /**
594
- * Custom boundary for raycast detection.
595
- * @remarks this is based on `this.entity.transform`.
596
- */ _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);
597
- _this._dirtyUpdateFlag = engine.RendererUpdateFlags.WorldVolume | 2;
598
- _this._onColorChanged = _this._onColorChanged.bind(_this);
599
- //@ts-ignore
600
- _this._color._onValueChanged = _this._onColorChanged;
601
- _this._groupListener = _this._groupListener.bind(_this);
602
- _this._rootCanvasListener = _this._rootCanvasListener.bind(_this);
603
- return _this;
604
- }
605
- var _proto = UIRenderer.prototype;
606
- // @ts-ignore
607
- _proto._canBatch = function _canBatch(elementA, elementB) {
608
- return engine.BatchUtils.canBatchSprite(elementA, elementB);
609
- };
610
- // @ts-ignore
611
- _proto._batch = function _batch(elementA, elementB) {
612
- engine.BatchUtils.batchFor2D(elementA, elementB);
613
- };
614
- // @ts-ignore
615
- _proto._updateTransformShaderData = function _updateTransformShaderData(context, onlyMVP, batched) {
616
- // @ts-ignore
617
- Renderer.prototype._updateTransformShaderData.call(this, context, onlyMVP, true);
618
- };
619
- // @ts-ignore
620
- _proto._prepareRender = function _prepareRender(context) {
621
- // Update once per frame per renderer, not influenced by batched
622
- if (this._renderFrameCount !== this.engine.time.frameCount) {
623
- this._update(context);
624
- }
625
- this._render(context);
626
- // union camera global macro and renderer macro.
627
- engine.ShaderMacroCollection.unionCollection(context.camera._globalShaderMacro, // @ts-ignore
628
- this.shaderData._macroCollection, //@ts-ignore
629
- this._globalShaderMacro);
630
- };
631
- // @ts-ignore
632
- _proto._onEnableInScene = function _onEnableInScene() {
633
- // @ts-ignore
634
- this._overrideUpdate && this.scene._componentsManager.addOnUpdateRenderers(this);
635
- this.entity._updateUIHierarchyVersion(exports.UICanvas._hierarchyCounter);
636
- Utils.setRootCanvasDirty(this);
637
- Utils.setGroupDirty(this);
638
- };
639
- // @ts-ignore
640
- _proto._onDisableInScene = function _onDisableInScene() {
641
- // @ts-ignore
642
- this._overrideUpdate && this.scene._componentsManager.removeOnUpdateRenderers(this);
643
- this.entity._updateUIHierarchyVersion(exports.UICanvas._hierarchyCounter);
644
- Utils.cleanRootCanvas(this);
645
- Utils.cleanGroup(this);
646
- };
647
- /**
648
- * @internal
649
- */ _proto._getGlobalAlpha = function _getGlobalAlpha() {
650
- var _this__getGroup;
651
- var _this__getGroup__getGlobalAlpha;
652
- return (_this__getGroup__getGlobalAlpha = (_this__getGroup = this._getGroup()) == null ? void 0 : _this__getGroup._getGlobalAlpha()) != null ? _this__getGroup__getGlobalAlpha : 1;
653
- };
654
- /**
655
- * @internal
656
- */ _proto._getRootCanvas = function _getRootCanvas() {
657
- this._isRootCanvasDirty && Utils.setRootCanvas(this, Utils.searchRootCanvasInParents(this));
658
- return this._rootCanvas;
659
- };
660
- /**
661
- * @internal
662
- */ _proto._getGroup = function _getGroup() {
663
- this._isGroupDirty && Utils.setGroup(this, Utils.searchGroupInParents(this));
664
- return this._group;
665
- };
666
- /**
667
- * @internal
668
- */ _proto._groupListener = function _groupListener(flag) {
669
- if (flag === engine.EntityModifyFlags.Parent || flag === EntityUIModifyFlags.GroupEnableInScene) {
670
- Utils.setGroupDirty(this);
671
- }
672
- };
673
- /**
674
- * @internal
675
- */ _proto._rootCanvasListener = function _rootCanvasListener(flag, entity) {
676
- switch(flag){
677
- case engine.EntityModifyFlags.Parent:
678
- Utils.setRootCanvasDirty(this);
679
- Utils.setGroupDirty(this);
680
- case engine.EntityModifyFlags.Child:
681
- entity._updateUIHierarchyVersion(exports.UICanvas._hierarchyCounter);
682
- break;
683
- }
684
- };
685
- /**
686
- * @internal
687
- */ _proto._onGroupModify = function _onGroupModify(flags) {
688
- if (flags & GroupModifyFlags.GlobalAlpha) {
689
- this._dirtyUpdateFlag |= 2;
690
- }
691
- };
692
- _proto._onColorChanged = function _onColorChanged() {
693
- this._dirtyUpdateFlag |= 2;
694
- };
695
- /**
696
- * @internal
697
- */ _proto._getChunkManager = function _getChunkManager() {
698
- // @ts-ignore
699
- return this.engine._batcherManager.primitiveChunkManagerUI;
700
- };
701
- /**
702
- * @internal
703
- */ _proto._raycast = function _raycast(ray, out, distance) {
704
- if (distance === void 0) distance = Number.MAX_SAFE_INTEGER;
705
- var plane = UIRenderer._tempPlane;
706
- var transform = this._transformEntity.transform;
707
- var normal = plane.normal.copyFrom(transform.worldForward);
708
- plane.distance = -engine.Vector3.dot(normal, transform.worldPosition);
709
- var curDistance = ray.intersectPlane(plane);
710
- if (curDistance >= 0 && curDistance < distance) {
711
- var hitPointWorld = ray.getPoint(curDistance, UIRenderer._tempVec30);
712
- var worldMatrixInv = UIRenderer._tempMat;
713
- engine.Matrix.invert(transform.worldMatrix, worldMatrixInv);
714
- var localPosition = UIRenderer._tempVec31;
715
- engine.Vector3.transformCoordinate(hitPointWorld, worldMatrixInv, localPosition);
716
- if (this._hitTest(localPosition)) {
717
- out.component = this;
718
- out.distance = curDistance;
719
- out.entity = this.entity;
720
- out.normal.copyFrom(normal);
721
- out.point.copyFrom(hitPointWorld);
722
- return true;
723
- }
724
- }
725
- return false;
726
- };
727
- _proto._hitTest = function _hitTest(localPosition) {
728
- var x = localPosition.x, y = localPosition.y;
729
- var uiTransform = this._transformEntity.transform;
730
- var _uiTransform_size = uiTransform.size, width = _uiTransform_size.x, height = _uiTransform_size.y;
731
- var _uiTransform_pivot = uiTransform.pivot, pivotX = _uiTransform_pivot.x, pivotY = _uiTransform_pivot.y;
732
- var _this_raycastPadding = this.raycastPadding, paddingLeft = _this_raycastPadding.x, paddingBottom = _this_raycastPadding.y, paddingRight = _this_raycastPadding.z, paddingTop = _this_raycastPadding.w;
733
- return x >= -width * pivotX + paddingLeft && x <= width * (1 - pivotX) - paddingRight && y >= -height * pivotY + paddingTop && y <= height * (1 - pivotY) - paddingBottom;
734
- };
735
- _proto._onDestroy = function _onDestroy() {
736
- if (this._subChunk) {
737
- this._getChunkManager().freeSubChunk(this._subChunk);
738
- this._subChunk = null;
739
- }
740
- Renderer.prototype._onDestroy.call(this);
741
- //@ts-ignore
742
- this._color._onValueChanged = null;
743
- this._color = null;
744
- };
745
- _create_class(UIRenderer, [
746
- {
747
- key: "color",
748
- get: /**
749
- * Rendering color for the ui renderer.
750
- */ function get() {
751
- return this._color;
752
- },
753
- set: function set(value) {
754
- if (this._color !== value) {
755
- this._color.copyFrom(value);
756
- }
757
- }
758
- },
759
- {
760
- key: "raycastEnabled",
761
- get: /**
762
- * Whether this renderer be picked up by raycast.
763
- */ function get() {
764
- return this._raycastEnabled;
765
- },
766
- set: function set(value) {
767
- this._raycastEnabled = value;
768
- }
769
- }
770
- ]);
771
- return UIRenderer;
772
- }(engine.Renderer);
773
- /** @internal */ exports.UIRenderer._tempVec30 = new engine.Vector3();
774
- /** @internal */ exports.UIRenderer._tempVec31 = new engine.Vector3();
775
- /** @internal */ exports.UIRenderer._tempMat = new engine.Matrix();
776
- /** @internal */ exports.UIRenderer._tempPlane = new engine.Plane();
777
- /** @internal */ exports.UIRenderer._textureProperty = engine.ShaderProperty.getByName("renderer_UITexture");
778
- __decorate([
779
- engine.deepClone
780
- ], exports.UIRenderer.prototype, "raycastPadding", void 0);
781
- __decorate([
782
- engine.ignoreClone
783
- ], exports.UIRenderer.prototype, "_rootCanvas", void 0);
784
- __decorate([
785
- engine.ignoreClone
786
- ], exports.UIRenderer.prototype, "_indexInRootCanvas", void 0);
787
- __decorate([
788
- engine.ignoreClone
789
- ], exports.UIRenderer.prototype, "_isRootCanvasDirty", void 0);
790
- __decorate([
791
- engine.ignoreClone
792
- ], exports.UIRenderer.prototype, "_rootCanvasListeningEntities", void 0);
793
- __decorate([
794
- engine.ignoreClone
795
- ], exports.UIRenderer.prototype, "_group", void 0);
796
- __decorate([
797
- engine.ignoreClone
798
- ], exports.UIRenderer.prototype, "_indexInGroup", void 0);
799
- __decorate([
800
- engine.ignoreClone
801
- ], exports.UIRenderer.prototype, "_isGroupDirty", void 0);
802
- __decorate([
803
- engine.ignoreClone
804
- ], exports.UIRenderer.prototype, "_groupListeningEntities", void 0);
805
- __decorate([
806
- engine.ignoreClone
807
- ], exports.UIRenderer.prototype, "_subChunk", void 0);
808
- __decorate([
809
- engine.ignoreClone
810
- ], exports.UIRenderer.prototype, "_raycastEnabled", void 0);
811
- __decorate([
812
- engine.deepClone
813
- ], exports.UIRenderer.prototype, "_color", void 0);
814
- __decorate([
815
- engine.ignoreClone
816
- ], exports.UIRenderer.prototype, "_groupListener", null);
817
- __decorate([
818
- engine.ignoreClone
819
- ], exports.UIRenderer.prototype, "_rootCanvasListener", null);
820
- __decorate([
821
- engine.ignoreClone
822
- ], exports.UIRenderer.prototype, "_onColorChanged", null);
823
- exports.UIRenderer = __decorate([
824
- engine.dependentComponents(UITransform, engine.DependentMode.AutoAdd)
825
- ], exports.UIRenderer);
826
- /**
827
- * @remarks Extends `RendererUpdateFlags`.
828
- */ var UIRendererUpdateFlags = /*#__PURE__*/ function(UIRendererUpdateFlags) {
829
- UIRendererUpdateFlags[UIRendererUpdateFlags["Color"] = 2] = "Color";
830
- return UIRendererUpdateFlags;
831
- }({});
832
-
833
- /**
834
- * Interactive component.
835
- */ var UIInteractive = /*#__PURE__*/ function(Script) {
836
- _inherits(UIInteractive, Script);
837
- function UIInteractive(entity) {
838
- var _this;
839
- _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._interactive = true, _this._state = 0, _this._transitions = [], /** @todo Multi-touch points are not considered yet. */ _this._isPointerInside = false, _this._isPointerDragging = false;
840
- _this._groupListener = _this._groupListener.bind(_this);
841
- _this._rootCanvasListener = _this._rootCanvasListener.bind(_this);
842
- return _this;
843
- }
844
- var _proto = UIInteractive.prototype;
845
- /**
846
- * Add transition on this interactive.
847
- * @param transition - The transition
848
- */ _proto.addTransition = function addTransition(transition) {
849
- var interactive = transition._interactive;
850
- if (interactive !== this) {
851
- interactive == null ? void 0 : interactive.removeTransition(transition);
852
- this._transitions.push(transition);
853
- transition._interactive = this;
854
- transition._setState(this._state, true);
855
- }
856
- };
857
- /**
858
- * Remove a transition.
859
- * @param shape - The transition.
860
- */ _proto.removeTransition = function removeTransition(transition) {
861
- var transitions = this._transitions;
862
- var lastOneIndex = transitions.length - 1;
863
- for(var i = lastOneIndex; i >= 0; i--){
864
- if (transitions[i] === transition) {
865
- i !== lastOneIndex && (transitions[i] = transitions[lastOneIndex]);
866
- transitions.length = lastOneIndex;
867
- transition._interactive = null;
868
- break;
869
- }
870
- }
871
- };
872
- /**
873
- * Remove all transitions.
874
- */ _proto.clearTransitions = function clearTransitions() {
875
- var transitions = this._transitions;
876
- for(var i = 0, n = transitions.length; i < n; i++){
877
- transitions[i]._interactive = null;
878
- }
879
- transitions.length = 0;
880
- };
881
- _proto.onUpdate = function onUpdate(deltaTime) {
882
- if (this._getGlobalInteractive()) {
883
- var transitions = this._transitions;
884
- for(var i = 0, n = transitions.length; i < n; i++){
885
- transitions[i]._onUpdate(deltaTime);
886
- }
887
- }
888
- };
889
- _proto.onPointerBeginDrag = function onPointerBeginDrag() {
890
- this._isPointerDragging = true;
891
- this._updateState(false);
892
- };
893
- _proto.onPointerEndDrag = function onPointerEndDrag() {
894
- this._isPointerDragging = false;
895
- this._updateState(false);
896
- };
897
- _proto.onPointerEnter = function onPointerEnter() {
898
- this._isPointerInside = true;
899
- this._updateState(false);
900
- };
901
- _proto.onPointerExit = function onPointerExit() {
902
- this._isPointerInside = false;
903
- this._updateState(false);
904
- };
905
- _proto.onDestroy = function onDestroy() {
906
- Script.prototype.onDestroy.call(this);
907
- var transitions = this._transitions;
908
- for(var i = transitions.length - 1; i >= 0; i--){
909
- transitions[i].destroy();
910
- }
911
- };
912
- /**
913
- * @internal
914
- */ _proto._getRootCanvas = function _getRootCanvas() {
915
- this._isRootCanvasDirty && Utils.setRootCanvas(this, Utils.searchRootCanvasInParents(this));
916
- return this._rootCanvas;
917
- };
918
- /**
919
- * @internal
920
- */ _proto._getGroup = function _getGroup() {
921
- this._isGroupDirty && Utils.setGroup(this, Utils.searchGroupInParents(this));
922
- return this._group;
923
- };
924
- // @ts-ignore
925
- _proto._onEnableInScene = function _onEnableInScene() {
926
- // @ts-ignore
927
- Script.prototype._onEnableInScene.call(this);
928
- Utils.setRootCanvasDirty(this);
929
- Utils.setGroupDirty(this);
930
- this._updateState(true);
931
- };
932
- // @ts-ignore
933
- _proto._onDisableInScene = function _onDisableInScene() {
934
- // @ts-ignore
935
- Script.prototype._onDisableInScene.call(this);
936
- Utils.cleanRootCanvas(this);
937
- Utils.cleanGroup(this);
938
- this._isPointerInside = this._isPointerDragging = false;
939
- };
940
- /**
941
- * @internal
942
- */ _proto._groupListener = function _groupListener(flag) {
943
- if (flag === engine.EntityModifyFlags.Parent || flag === EntityUIModifyFlags.GroupEnableInScene) {
944
- Utils.setGroupDirty(this);
945
- }
946
- };
947
- /**
948
- * @internal
949
- */ _proto._rootCanvasListener = function _rootCanvasListener(flag) {
950
- if (flag === engine.EntityModifyFlags.Parent || flag === EntityUIModifyFlags.CanvasEnableInScene) {
951
- Utils.setRootCanvasDirty(this);
952
- Utils.setGroupDirty(this);
953
- }
954
- };
955
- /**
956
- * @internal
957
- */ _proto._onGroupModify = function _onGroupModify(flags) {
958
- if (flags & GroupModifyFlags.GlobalInteractive) {
959
- this._globalInteractiveDirty = true;
960
- }
961
- };
962
- /**
963
- * @internal
964
- */ _proto._getGlobalInteractive = function _getGlobalInteractive() {
965
- if (this._globalInteractiveDirty) {
966
- var group = this._getGroup();
967
- var globalInteractive = this._interactive && (!group || group._getGlobalInteractive());
968
- if (this._globalInteractive !== globalInteractive) {
969
- this._globalInteractive = globalInteractive;
970
- this._updateState(true);
971
- }
972
- this._globalInteractiveDirty = false;
973
- }
974
- return this._globalInteractive;
975
- };
976
- _proto._updateState = function _updateState(instant) {
977
- var state = this._getInteractiveState();
978
- if (this._state !== state) {
979
- this._state = state;
980
- var transitions = this._transitions;
981
- for(var i = 0, n = transitions.length; i < n; i++){
982
- transitions[i]._setState(state, instant);
983
- }
984
- }
985
- };
986
- _proto._getInteractiveState = function _getInteractiveState() {
987
- if (!this._getGlobalInteractive()) {
988
- return 3;
989
- }
990
- if (this._isPointerDragging) {
991
- return 1;
992
- } else {
993
- return this._isPointerInside ? 2 : 0;
994
- }
995
- };
996
- _create_class(UIInteractive, [
997
- {
998
- key: "transitions",
999
- get: /**
1000
- * The transitions of this interactive.
1001
- */ function get() {
1002
- return this._transitions;
1003
- }
1004
- },
1005
- {
1006
- key: "interactive",
1007
- get: /**
1008
- * Whether the interactive is enabled.
1009
- */ function get() {
1010
- return this._interactive;
1011
- },
1012
- set: function set(value) {
1013
- if (this._interactive !== value) {
1014
- this._interactive = value;
1015
- this._globalInteractiveDirty = true;
1016
- }
1017
- }
1018
- }
1019
- ]);
1020
- return UIInteractive;
1021
- }(engine.Script);
1022
- __decorate([
1023
- engine.ignoreClone
1024
- ], UIInteractive.prototype, "_rootCanvas", void 0);
1025
- __decorate([
1026
- engine.ignoreClone
1027
- ], UIInteractive.prototype, "_indexInRootCanvas", void 0);
1028
- __decorate([
1029
- engine.ignoreClone
1030
- ], UIInteractive.prototype, "_isRootCanvasDirty", void 0);
1031
- __decorate([
1032
- engine.ignoreClone
1033
- ], UIInteractive.prototype, "_rootCanvasListeningEntities", void 0);
1034
- __decorate([
1035
- engine.ignoreClone
1036
- ], UIInteractive.prototype, "_group", void 0);
1037
- __decorate([
1038
- engine.ignoreClone
1039
- ], UIInteractive.prototype, "_indexInGroup", void 0);
1040
- __decorate([
1041
- engine.ignoreClone
1042
- ], UIInteractive.prototype, "_isGroupDirty", void 0);
1043
- __decorate([
1044
- engine.ignoreClone
1045
- ], UIInteractive.prototype, "_groupListeningEntities", void 0);
1046
- __decorate([
1047
- engine.ignoreClone
1048
- ], UIInteractive.prototype, "_globalInteractive", void 0);
1049
- __decorate([
1050
- engine.ignoreClone
1051
- ], UIInteractive.prototype, "_globalInteractiveDirty", void 0);
1052
- __decorate([
1053
- engine.ignoreClone
1054
- ], UIInteractive.prototype, "_groupListener", null);
1055
- __decorate([
1056
- engine.ignoreClone
1057
- ], UIInteractive.prototype, "_rootCanvasListener", null);
1058
- __decorate([
1059
- engine.ignoreClone
1060
- ], UIInteractive.prototype, "_onGroupModify", null);
1061
- var InteractiveState = /*#__PURE__*/ function(InteractiveState) {
1062
- InteractiveState[InteractiveState["Normal"] = 0] = "Normal";
1063
- InteractiveState[InteractiveState["Pressed"] = 1] = "Pressed";
1064
- InteractiveState[InteractiveState["Hover"] = 2] = "Hover";
1065
- InteractiveState[InteractiveState["Disable"] = 3] = "Disable";
1066
- return InteractiveState;
1067
- }({});
1068
-
1069
- exports.UICanvas = /*#__PURE__*/ function(Component) {
1070
- _inherits(UICanvas, Component);
1071
- function UICanvas(entity) {
1072
- var _this;
1073
- _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._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();
1074
- _this._onCanvasSizeListener = _this._onCanvasSizeListener.bind(_this);
1075
- _this._onCameraModifyListener = _this._onCameraModifyListener.bind(_this);
1076
- _this._onCameraTransformListener = _this._onCameraTransformListener.bind(_this);
1077
- _this._onReferenceResolutionChanged = _this._onReferenceResolutionChanged.bind(_this);
1078
- // @ts-ignore
1079
- _this._referenceResolution._onValueChanged = _this._onReferenceResolutionChanged;
1080
- _this._rootCanvasListener = _this._rootCanvasListener.bind(_this);
1081
- _this._centerDirtyFlag = entity.registerWorldChangeFlag();
1082
- return _this;
1083
- }
1084
- var _proto = UICanvas.prototype;
1085
- /**
1086
- * @internal
1087
- */ _proto._raycast = function _raycast(ray, out, distance) {
1088
- if (distance === void 0) distance = Number.MAX_SAFE_INTEGER;
1089
- var renderers = this._getRenderers();
1090
- for(var i = renderers.length - 1; i >= 0; i--){
1091
- var element = renderers[i];
1092
- if (element.raycastEnabled && element._raycast(ray, out, distance)) {
1093
- return true;
1094
- }
1095
- }
1096
- out.component = null;
1097
- out.entity = null;
1098
- out.distance = 0;
1099
- out.point.set(0, 0, 0);
1100
- out.normal.set(0, 0, 0);
1101
- return false;
1102
- };
1103
- /**
1104
- * @internal
1105
- */ _proto._getRootCanvas = function _getRootCanvas() {
1106
- return this._rootCanvas;
1107
- };
1108
- /**
1109
- * @internal
1110
- */ _proto._canRender = function _canRender(camera) {
1111
- return this._renderMode !== CanvasRenderMode.ScreenSpaceCamera || this._renderCamera === camera;
1112
- };
1113
- /**
1114
- * @internal
1115
- */ _proto._prepareRender = function _prepareRender(context) {
1116
- var _this = this, engine = _this.engine, mode = _this._realRenderMode;
1117
- var _context_camera = context.camera, enableFrustumCulling = _context_camera.enableFrustumCulling, cullingMask = _context_camera.cullingMask, frustum = _context_camera._frustum;
1118
- var frameCount = engine.time.frameCount;
1119
- // @ts-ignore
1120
- var renderElement = this._renderElement = engine._renderElementPool.get();
1121
- var virtualCamera = context.virtualCamera;
1122
- this._updateSortDistance(virtualCamera.isOrthographic, virtualCamera.position, virtualCamera.forward);
1123
- renderElement.set(this.sortOrder, this._sortDistance);
1124
- var _engine_canvas = engine.canvas, width = _engine_canvas.width, height = _engine_canvas.height;
1125
- var renderers = this._getRenderers();
1126
- for(var i = 0, n = renderers.length; i < n; i++){
1127
- var renderer = renderers[i];
1128
- // Filter by camera culling mask
1129
- if (!(cullingMask & renderer.entity.layer)) {
1130
- continue;
1131
- }
1132
- // Filter by camera frustum
1133
- if (enableFrustumCulling) {
1134
- switch(mode){
1135
- case CanvasRenderMode.ScreenSpaceOverlay:
1136
- var _renderer_bounds = renderer.bounds, min = _renderer_bounds.min, max = _renderer_bounds.max;
1137
- if (min.x > width || max.x < 0 || min.y > height || max.y < 0) {
1138
- continue;
1139
- }
1140
- break;
1141
- case CanvasRenderMode.ScreenSpaceCamera:
1142
- case CanvasRenderMode.WorldSpace:
1143
- if (!frustum.intersectsBox(renderer.bounds)) {
1144
- continue;
1145
- }
1146
- break;
1147
- }
1148
- }
1149
- renderer._prepareRender(context);
1150
- renderer._renderFrameCount = frameCount;
1151
- }
1152
- };
1153
- /**
1154
- * @internal
1155
- */ _proto._updateSortDistance = function _updateSortDistance(isOrthographic, cameraPosition, cameraForward) {
1156
- switch(this._realRenderMode){
1157
- case CanvasRenderMode.ScreenSpaceOverlay:
1158
- this._sortDistance = 0;
1159
- break;
1160
- case CanvasRenderMode.ScreenSpaceCamera:
1161
- this._sortDistance = this._distance;
1162
- break;
1163
- case CanvasRenderMode.WorldSpace:
1164
- var boundsCenter = this._getCenter();
1165
- if (isOrthographic) {
1166
- var distance = UICanvas._tempVec3;
1167
- engine.Vector3.subtract(boundsCenter, cameraPosition, distance);
1168
- this._sortDistance = engine.Vector3.dot(distance, cameraForward);
1169
- } else {
1170
- this._sortDistance = engine.Vector3.distanceSquared(boundsCenter, cameraPosition);
1171
- }
1172
- break;
1173
- }
1174
- };
1175
- // @ts-ignore
1176
- _proto._onEnableInScene = function _onEnableInScene() {
1177
- var entity = this.entity;
1178
- // @ts-ignore
1179
- entity._dispatchModify(4, this);
1180
- var rootCanvas = Utils.searchRootCanvasInParents(this);
1181
- this._setIsRootCanvas(!rootCanvas);
1182
- Utils.setRootCanvas(this, rootCanvas);
1183
- };
1184
- // @ts-ignore
1185
- _proto._onDisableInScene = function _onDisableInScene() {
1186
- this._setIsRootCanvas(false);
1187
- Utils.cleanRootCanvas(this);
1188
- };
1189
- /**
1190
- * @internal
1191
- */ _proto._rootCanvasListener = function _rootCanvasListener(flag, param) {
1192
- if (this._isRootCanvas) {
1193
- if (flag === engine.EntityModifyFlags.Parent) {
1194
- var rootCanvas = Utils.searchRootCanvasInParents(this);
1195
- this._setIsRootCanvas(!rootCanvas);
1196
- Utils.setRootCanvas(this, rootCanvas);
1197
- } else if (flag === 4) {
1198
- this._setIsRootCanvas(false);
1199
- Utils.setRootCanvas(this, param);
1200
- }
1201
- } else {
1202
- if (flag === engine.EntityModifyFlags.Parent) {
1203
- var rootCanvas1 = Utils.searchRootCanvasInParents(this);
1204
- this._setIsRootCanvas(!rootCanvas1);
1205
- Utils.setRootCanvas(this, rootCanvas1);
1206
- }
1207
- }
1208
- };
1209
- /**
1210
- * @internal
1211
- */ _proto._cloneTo = function _cloneTo(target, srcRoot, targetRoot) {
1212
- target.renderMode = this._renderMode;
1213
- };
1214
- _proto._getRenderers = function _getRenderers() {
1215
- var _this = this, renderers = _this._orderedRenderers, entity = _this.entity;
1216
- var uiHierarchyVersion = entity._uiHierarchyVersion;
1217
- if (this._hierarchyVersion !== uiHierarchyVersion) {
1218
- renderers.length = this._walk(this.entity, renderers);
1219
- UICanvas._tempGroupAbleList.length = 0;
1220
- this._hierarchyVersion = uiHierarchyVersion;
1221
- ++UICanvas._hierarchyCounter;
1222
- }
1223
- return renderers;
1224
- };
1225
- _proto._adapterPoseInScreenSpace = function _adapterPoseInScreenSpace() {
1226
- var transform = this.entity.transform;
1227
- var realRenderMode = this._realRenderMode;
1228
- if (realRenderMode === CanvasRenderMode.ScreenSpaceCamera) {
1229
- var cameraEntity = this._renderCamera.entity;
1230
- if (!this._isSameOrChildEntity(cameraEntity)) {
1231
- var cameraTransform = cameraEntity.transform;
1232
- var cameraWorldPosition = cameraTransform.worldPosition, cameraWorldForward = cameraTransform.worldForward;
1233
- var distance = this._distance;
1234
- transform.setWorldPosition(cameraWorldPosition.x + cameraWorldForward.x * distance, cameraWorldPosition.y + cameraWorldForward.y * distance, cameraWorldPosition.z + cameraWorldForward.z * distance);
1235
- transform.worldRotationQuaternion.copyFrom(cameraTransform.worldRotationQuaternion);
1236
- }
1237
- } else {
1238
- var canvas = this.engine.canvas;
1239
- transform.setWorldPosition(canvas.width * 0.5, canvas.height * 0.5, 0);
1240
- transform.worldRotationQuaternion.set(0, 0, 0, 1);
1241
- }
1242
- };
1243
- _proto._adapterSizeInScreenSpace = function _adapterSizeInScreenSpace() {
1244
- var transform = this.entity.transform;
1245
- var realRenderMode = this._realRenderMode;
1246
- var _this__referenceResolution = this._referenceResolution, width = _this__referenceResolution.x, height = _this__referenceResolution.y;
1247
- var curWidth;
1248
- var curHeight;
1249
- if (realRenderMode === CanvasRenderMode.ScreenSpaceCamera) {
1250
- var renderCamera = this._renderCamera;
1251
- curHeight = renderCamera.isOrthographic ? renderCamera.orthographicSize * 2 : 2 * (Math.tan(engine.MathUtil.degreeToRadian(renderCamera.fieldOfView * 0.5)) * this._distance);
1252
- curWidth = renderCamera.aspectRatio * curHeight;
1253
- } else {
1254
- var canvas = this.engine.canvas;
1255
- curHeight = canvas.height;
1256
- curWidth = canvas.width;
1257
- }
1258
- var expectX, expectY, expectZ;
1259
- switch(this._resolutionAdaptationMode){
1260
- case ResolutionAdaptationMode.WidthAdaptation:
1261
- expectX = expectY = expectZ = curWidth / width;
1262
- break;
1263
- case ResolutionAdaptationMode.HeightAdaptation:
1264
- expectX = expectY = expectZ = curHeight / height;
1265
- break;
1266
- case ResolutionAdaptationMode.BothAdaptation:
1267
- expectX = curWidth / width;
1268
- expectY = curHeight / height;
1269
- expectZ = (expectX + expectY) * 0.5;
1270
- break;
1271
- case ResolutionAdaptationMode.ExpandAdaptation:
1272
- expectX = expectY = expectZ = Math.min(curWidth / width, curHeight / height);
1273
- break;
1274
- case ResolutionAdaptationMode.ShrinkAdaptation:
1275
- expectX = expectY = expectZ = Math.max(curWidth / width, curHeight / height);
1276
- break;
1277
- }
1278
- var worldMatrix = UICanvas._tempMat;
1279
- engine.Matrix.affineTransformation(UICanvas._tempVec3.set(expectX, expectY, expectZ), transform.worldRotationQuaternion, transform.worldPosition, worldMatrix);
1280
- transform.worldMatrix = worldMatrix;
1281
- transform.size.set(curWidth / expectX, curHeight / expectY);
1282
- };
1283
- _proto._walk = function _walk(entity, renderers, depth, group) {
1284
- if (depth === void 0) depth = 0;
1285
- if (group === void 0) group = null;
1286
- // @ts-ignore
1287
- var components = entity._components;
1288
- var tempGroupAbleList = UICanvas._tempGroupAbleList;
1289
- var groupAbleCount = 0;
1290
- for(var i = 0, n = components.length; i < n; i++){
1291
- var component = components[i];
1292
- if (!component.enabled) continue;
1293
- if (_instanceof(component, exports.UIRenderer)) {
1294
- renderers[depth] = component;
1295
- ++depth;
1296
- component._isRootCanvasDirty && Utils.setRootCanvas(component, this);
1297
- if (component._isGroupDirty) {
1298
- tempGroupAbleList[groupAbleCount++] = component;
1299
- }
1300
- } else if (_instanceof(component, UIInteractive)) {
1301
- component._isRootCanvasDirty && Utils.setRootCanvas(component, this);
1302
- if (component._isGroupDirty) {
1303
- tempGroupAbleList[groupAbleCount++] = component;
1304
- }
1305
- } else if (_instanceof(component, UIGroup)) {
1306
- component._isRootCanvasDirty && Utils.setRootCanvas(component, this);
1307
- component._isGroupDirty && Utils.setGroup(component, group);
1308
- group = component;
1309
- }
1310
- }
1311
- for(var i1 = 0; i1 < groupAbleCount; i1++){
1312
- Utils.setGroup(tempGroupAbleList[i1], group);
1313
- }
1314
- var children = entity.children;
1315
- for(var i2 = 0, n1 = children.length; i2 < n1; i2++){
1316
- var child = children[i2];
1317
- child.isActive && (depth = this._walk(child, renderers, depth, group));
1318
- }
1319
- return depth;
1320
- };
1321
- _proto._updateCameraObserver = function _updateCameraObserver() {
1322
- var camera = this._isRootCanvas && this._renderMode === CanvasRenderMode.ScreenSpaceCamera ? this._renderCamera : null;
1323
- var preCamera = this._cameraObserver;
1324
- if (preCamera !== camera) {
1325
- this._cameraObserver = camera;
1326
- if (preCamera) {
1327
- // @ts-ignore
1328
- preCamera.entity._updateFlagManager.removeListener(this._onCameraTransformListener);
1329
- // @ts-ignore
1330
- preCamera._unRegisterModifyListener(this._onCameraModifyListener);
1331
- }
1332
- if (camera) {
1333
- // @ts-ignore
1334
- camera.entity._updateFlagManager.addListener(this._onCameraTransformListener);
1335
- // @ts-ignore
1336
- camera._registerModifyListener(this._onCameraModifyListener);
1337
- }
1338
- }
1339
- };
1340
- _proto._onCameraModifyListener = function _onCameraModifyListener(flag) {
1341
- if (this._realRenderMode === CanvasRenderMode.ScreenSpaceCamera) {
1342
- switch(flag){
1343
- case engine.CameraModifyFlags.ProjectionType:
1344
- case engine.CameraModifyFlags.AspectRatio:
1345
- this._adapterSizeInScreenSpace();
1346
- break;
1347
- case engine.CameraModifyFlags.FieldOfView:
1348
- !this._renderCamera.isOrthographic && this._adapterSizeInScreenSpace();
1349
- break;
1350
- case engine.CameraModifyFlags.OrthographicSize:
1351
- this._renderCamera.isOrthographic && this._adapterSizeInScreenSpace();
1352
- break;
1353
- case engine.CameraModifyFlags.DisableInScene:
1354
- this._setRealRenderMode(CanvasRenderMode.ScreenSpaceOverlay);
1355
- break;
1356
- }
1357
- } else {
1358
- flag === engine.CameraModifyFlags.EnableInScene && this._setRealRenderMode(CanvasRenderMode.ScreenSpaceCamera);
1359
- }
1360
- };
1361
- _proto._onCameraTransformListener = function _onCameraTransformListener() {
1362
- this._realRenderMode === CanvasRenderMode.ScreenSpaceCamera && this._adapterPoseInScreenSpace();
1363
- };
1364
- _proto._addCanvasListener = function _addCanvasListener() {
1365
- // @ts-ignore
1366
- this.engine.canvas._sizeUpdateFlagManager.addListener(this._onCanvasSizeListener);
1367
- };
1368
- _proto._removeCanvasListener = function _removeCanvasListener() {
1369
- // @ts-ignore
1370
- this.engine.canvas._sizeUpdateFlagManager.removeListener(this._onCanvasSizeListener);
1371
- };
1372
- _proto._onCanvasSizeListener = function _onCanvasSizeListener() {
1373
- var canvas = this.engine.canvas;
1374
- this.entity.transform.setWorldPosition(canvas.width * 0.5, canvas.height * 0.5, 0);
1375
- this._adapterSizeInScreenSpace();
1376
- };
1377
- _proto._onReferenceResolutionChanged = function _onReferenceResolutionChanged() {
1378
- var realRenderMode = this._realRenderMode;
1379
- if (realRenderMode === CanvasRenderMode.ScreenSpaceOverlay || realRenderMode === CanvasRenderMode.ScreenSpaceCamera) {
1380
- this._adapterSizeInScreenSpace();
1381
- }
1382
- };
1383
- _proto._setIsRootCanvas = function _setIsRootCanvas(isRootCanvas) {
1384
- var _this = this;
1385
- if (this._isRootCanvas !== isRootCanvas) {
1386
- this._isRootCanvas = isRootCanvas;
1387
- this._updateCameraObserver();
1388
- this._setRealRenderMode(this._getRealRenderMode());
1389
- if (isRootCanvas) {
1390
- this.entity._updateUIHierarchyVersion(UICanvas._hierarchyCounter);
1391
- } else {
1392
- var _this1 = this, disorderedElements = _this1._disorderedElements;
1393
- disorderedElements.forEach(function(element) {
1394
- if (_instanceof(element, UICanvas)) {
1395
- var rootCanvas = Utils.searchRootCanvasInParents(element);
1396
- element._setIsRootCanvas(!rootCanvas);
1397
- Utils.setRootCanvas(element, rootCanvas);
1398
- } else {
1399
- Utils.setRootCanvasDirty(_this);
1400
- Utils.setGroupDirty(element);
1401
- }
1402
- });
1403
- disorderedElements.length = 0;
1404
- disorderedElements.garbageCollection();
1405
- this._orderedRenderers.length = 0;
1406
- }
1407
- }
1408
- };
1409
- _proto._getCenter = function _getCenter() {
1410
- if (this._centerDirtyFlag.flag) {
1411
- var center = this._center;
1412
- var uiTransform = this.entity.transform;
1413
- var pivot = uiTransform.pivot, size = uiTransform.size;
1414
- center.set((0.5 - pivot.x) * size.x, (0.5 - pivot.y) * size.y, 0);
1415
- engine.Vector3.transformCoordinate(center, uiTransform.worldMatrix, center);
1416
- this._centerDirtyFlag.flag = false;
1417
- }
1418
- return this._center;
1419
- };
1420
- _proto._getRealRenderMode = function _getRealRenderMode() {
1421
- if (this._isRootCanvas) {
1422
- var _this__renderCamera;
1423
- var mode = this._renderMode;
1424
- if (mode === CanvasRenderMode.ScreenSpaceCamera && !((_this__renderCamera = this._renderCamera) == null ? void 0 : _this__renderCamera.enabled)) {
1425
- return CanvasRenderMode.ScreenSpaceOverlay;
1426
- } else {
1427
- return mode;
1428
- }
1429
- } else {
1430
- return 4;
1431
- }
1432
- };
1433
- _proto._setRealRenderMode = function _setRealRenderMode(curRealMode) {
1434
- var preRealMode = this._realRenderMode;
1435
- if (preRealMode !== curRealMode) {
1436
- this._realRenderMode = curRealMode;
1437
- // @ts-ignore
1438
- var componentsManager = this.scene._componentsManager;
1439
- switch(preRealMode){
1440
- case CanvasRenderMode.ScreenSpaceOverlay:
1441
- this._removeCanvasListener();
1442
- case CanvasRenderMode.ScreenSpaceCamera:
1443
- case CanvasRenderMode.WorldSpace:
1444
- componentsManager.removeUICanvas(this, preRealMode === CanvasRenderMode.ScreenSpaceOverlay);
1445
- break;
1446
- }
1447
- switch(curRealMode){
1448
- case CanvasRenderMode.ScreenSpaceOverlay:
1449
- this._addCanvasListener();
1450
- case CanvasRenderMode.ScreenSpaceCamera:
1451
- this._adapterPoseInScreenSpace();
1452
- this._adapterSizeInScreenSpace();
1453
- case CanvasRenderMode.WorldSpace:
1454
- componentsManager.addUICanvas(this, curRealMode === CanvasRenderMode.ScreenSpaceOverlay);
1455
- break;
1456
- }
1457
- }
1458
- };
1459
- _proto._isSameOrChildEntity = function _isSameOrChildEntity(cameraEntity) {
1460
- var canvasEntity = this.entity;
1461
- while(cameraEntity){
1462
- if (cameraEntity === canvasEntity) return true;
1463
- cameraEntity = cameraEntity.parent;
1464
- }
1465
- return false;
1466
- };
1467
- _create_class(UICanvas, [
1468
- {
1469
- key: "referenceResolutionPerUnit",
1470
- get: /**
1471
- * The conversion ratio between reference resolution and unit for UI elements in this canvas.
1472
- */ function get() {
1473
- return this._referenceResolutionPerUnit;
1474
- },
1475
- set: function set(value) {
1476
- if (this._referenceResolutionPerUnit !== value) {
1477
- this._referenceResolutionPerUnit = value;
1478
- this._disorderedElements.forEach(function(element) {
1479
- element._onRootCanvasModify == null ? void 0 : element._onRootCanvasModify.call(element, 1);
1480
- });
1481
- }
1482
- }
1483
- },
1484
- {
1485
- key: "referenceResolution",
1486
- get: /**
1487
- * The reference resolution of the UI canvas in `ScreenSpaceCamera` and `ScreenSpaceOverlay` mode.
1488
- */ function get() {
1489
- return this._referenceResolution;
1490
- },
1491
- set: function set(value) {
1492
- var referenceResolution = this._referenceResolution;
1493
- if (referenceResolution === value) return;
1494
- (referenceResolution.x !== value.x || referenceResolution.y !== value.y) && referenceResolution.copyFrom(value);
1495
- }
1496
- },
1497
- {
1498
- key: "renderMode",
1499
- get: /**
1500
- * The rendering mode of the UI canvas.
1501
- */ function get() {
1502
- return this._renderMode;
1503
- },
1504
- set: function set(mode) {
1505
- var preMode = this._renderMode;
1506
- if (preMode !== mode) {
1507
- this._renderMode = mode;
1508
- this._updateCameraObserver();
1509
- this._setRealRenderMode(this._getRealRenderMode());
1510
- }
1511
- }
1512
- },
1513
- {
1514
- key: "renderCamera",
1515
- get: /**
1516
- * The camera used to render the UI canvas in `ScreenSpaceCamera` mode.
1517
- * @remarks If set `ScreenSpaceCamera` but no corresponding camera is assigned, the actual rendering mode defaults to `ScreenSpaceOverlay`.
1518
- */ function get() {
1519
- return this._renderCamera;
1520
- },
1521
- set: function set(value) {
1522
- var preCamera = this._renderCamera;
1523
- if (preCamera !== value) {
1524
- value && this._isSameOrChildEntity(value.entity) && engine.Logger.warn("Camera entity matching or nested within the canvas entity disables canvas auto-adaptation in ScreenSpaceCamera mode.");
1525
- this._renderCamera = value;
1526
- this._updateCameraObserver();
1527
- var preRenderMode = this._realRenderMode;
1528
- var curRenderMode = this._getRealRenderMode();
1529
- if (preRenderMode === curRenderMode) {
1530
- if (curRenderMode === CanvasRenderMode.ScreenSpaceCamera) {
1531
- this._adapterPoseInScreenSpace();
1532
- this._adapterSizeInScreenSpace();
1533
- }
1534
- } else {
1535
- this._setRealRenderMode(curRenderMode);
1536
- }
1537
- }
1538
- }
1539
- },
1540
- {
1541
- key: "resolutionAdaptationMode",
1542
- get: /**
1543
- * The screen resolution adaptation mode of the UI canvas in `ScreenSpaceCamera` and `ScreenSpaceOverlay` mode.
1544
- */ function get() {
1545
- return this._resolutionAdaptationMode;
1546
- },
1547
- set: function set(value) {
1548
- if (this._resolutionAdaptationMode !== value) {
1549
- this._resolutionAdaptationMode = value;
1550
- var realRenderMode = this._realRenderMode;
1551
- if (realRenderMode === CanvasRenderMode.ScreenSpaceCamera || realRenderMode === CanvasRenderMode.ScreenSpaceOverlay) {
1552
- this._adapterSizeInScreenSpace();
1553
- }
1554
- }
1555
- }
1556
- },
1557
- {
1558
- key: "sortOrder",
1559
- get: /**
1560
- * The rendering order priority of the UI canvas in `ScreenSpaceOverlay` mode.
1561
- */ function get() {
1562
- return this._sortOrder;
1563
- },
1564
- set: function set(value) {
1565
- if (this._sortOrder !== value) {
1566
- this._sortOrder = value;
1567
- this._realRenderMode === CanvasRenderMode.ScreenSpaceOverlay && // @ts-ignore
1568
- (this.scene._componentsManager._overlayCanvasesSortingFlag = true);
1569
- }
1570
- }
1571
- },
1572
- {
1573
- key: "distance",
1574
- get: /**
1575
- * The distance between the UI canvas and the camera in `ScreenSpaceCamera` mode.
1576
- */ function get() {
1577
- return this._distance;
1578
- },
1579
- set: function set(value) {
1580
- if (this._distance !== value) {
1581
- this._distance = value;
1582
- if (this._realRenderMode === CanvasRenderMode.ScreenSpaceCamera) {
1583
- this._adapterPoseInScreenSpace();
1584
- this._adapterSizeInScreenSpace();
1585
- }
1586
- }
1587
- }
1588
- }
1589
- ]);
1590
- return UICanvas;
1591
- }(engine.Component);
1592
- /** @internal */ exports.UICanvas._hierarchyCounter = 1;
1593
- exports.UICanvas._tempGroupAbleList = [];
1594
- exports.UICanvas._tempVec3 = new engine.Vector3();
1595
- exports.UICanvas._tempMat = new engine.Matrix();
1596
- __decorate([
1597
- engine.ignoreClone
1598
- ], exports.UICanvas.prototype, "_canvasIndex", void 0);
1599
- __decorate([
1600
- engine.ignoreClone
1601
- ], exports.UICanvas.prototype, "_rootCanvas", void 0);
1602
- __decorate([
1603
- engine.ignoreClone
1604
- ], exports.UICanvas.prototype, "_indexInRootCanvas", void 0);
1605
- __decorate([
1606
- engine.ignoreClone
1607
- ], exports.UICanvas.prototype, "_isRootCanvasDirty", void 0);
1608
- __decorate([
1609
- engine.ignoreClone
1610
- ], exports.UICanvas.prototype, "_rootCanvasListeningEntities", void 0);
1611
- __decorate([
1612
- engine.ignoreClone
1613
- ], exports.UICanvas.prototype, "_isRootCanvas", void 0);
1614
- __decorate([
1615
- engine.ignoreClone
1616
- ], exports.UICanvas.prototype, "_renderElement", void 0);
1617
- __decorate([
1618
- engine.ignoreClone
1619
- ], exports.UICanvas.prototype, "_sortDistance", void 0);
1620
- __decorate([
1621
- engine.ignoreClone
1622
- ], exports.UICanvas.prototype, "_orderedRenderers", void 0);
1623
- __decorate([
1624
- engine.ignoreClone
1625
- ], exports.UICanvas.prototype, "_realRenderMode", void 0);
1626
- __decorate([
1627
- engine.ignoreClone
1628
- ], exports.UICanvas.prototype, "_disorderedElements", void 0);
1629
- __decorate([
1630
- engine.ignoreClone
1631
- ], exports.UICanvas.prototype, "_renderMode", void 0);
1632
- __decorate([
1633
- engine.assignmentClone
1634
- ], exports.UICanvas.prototype, "_renderCamera", void 0);
1635
- __decorate([
1636
- engine.ignoreClone
1637
- ], exports.UICanvas.prototype, "_cameraObserver", void 0);
1638
- __decorate([
1639
- engine.assignmentClone
1640
- ], exports.UICanvas.prototype, "_resolutionAdaptationMode", void 0);
1641
- __decorate([
1642
- engine.assignmentClone
1643
- ], exports.UICanvas.prototype, "_sortOrder", void 0);
1644
- __decorate([
1645
- engine.assignmentClone
1646
- ], exports.UICanvas.prototype, "_distance", void 0);
1647
- __decorate([
1648
- engine.deepClone
1649
- ], exports.UICanvas.prototype, "_referenceResolution", void 0);
1650
- __decorate([
1651
- engine.assignmentClone
1652
- ], exports.UICanvas.prototype, "_referenceResolutionPerUnit", void 0);
1653
- __decorate([
1654
- engine.ignoreClone
1655
- ], exports.UICanvas.prototype, "_hierarchyVersion", void 0);
1656
- __decorate([
1657
- engine.ignoreClone
1658
- ], exports.UICanvas.prototype, "_center", void 0);
1659
- __decorate([
1660
- engine.ignoreClone
1661
- ], exports.UICanvas.prototype, "_centerDirtyFlag", void 0);
1662
- __decorate([
1663
- engine.ignoreClone
1664
- ], exports.UICanvas.prototype, "_rootCanvasListener", null);
1665
- __decorate([
1666
- engine.ignoreClone
1667
- ], exports.UICanvas.prototype, "_onCameraModifyListener", null);
1668
- __decorate([
1669
- engine.ignoreClone
1670
- ], exports.UICanvas.prototype, "_onCameraTransformListener", null);
1671
- __decorate([
1672
- engine.ignoreClone
1673
- ], exports.UICanvas.prototype, "_onCanvasSizeListener", null);
1674
- __decorate([
1675
- engine.ignoreClone
1676
- ], exports.UICanvas.prototype, "_onReferenceResolutionChanged", null);
1677
- exports.UICanvas = __decorate([
1678
- engine.dependentComponents(UITransform, engine.DependentMode.AutoAdd)
1679
- ], exports.UICanvas);
1680
- /**
1681
- * @remarks Extends `EntityModifyFlags`.
1682
- */ var EntityUIModifyFlags = /*#__PURE__*/ function(EntityUIModifyFlags) {
1683
- EntityUIModifyFlags[EntityUIModifyFlags["CanvasEnableInScene"] = 4] = "CanvasEnableInScene";
1684
- EntityUIModifyFlags[EntityUIModifyFlags["GroupEnableInScene"] = 8] = "GroupEnableInScene";
1685
- return EntityUIModifyFlags;
1686
- }({});
1687
- var RootCanvasModifyFlags = /*#__PURE__*/ function(RootCanvasModifyFlags) {
1688
- RootCanvasModifyFlags[RootCanvasModifyFlags["None"] = 0] = "None";
1689
- RootCanvasModifyFlags[RootCanvasModifyFlags["ReferenceResolutionPerUnit"] = 1] = "ReferenceResolutionPerUnit";
1690
- RootCanvasModifyFlags[RootCanvasModifyFlags["All"] = 1] = "All";
1691
- return RootCanvasModifyFlags;
1692
- }({});
1693
-
1694
- var Button = /*#__PURE__*/ function(UIInteractive) {
1695
- _inherits(Button, UIInteractive);
1696
- function Button() {
1697
- var _this;
1698
- _this = UIInteractive.apply(this, arguments) || this, _this._listeners = new engine.SafeLoopArray();
1699
- return _this;
1700
- }
1701
- var _proto = Button.prototype;
1702
- /**
1703
- * Add a listening function for click.
1704
- * @param listener - The listening function
1705
- */ _proto.addClicked = function addClicked(listener) {
1706
- this._listeners.push({
1707
- fn: listener
1708
- });
1709
- };
1710
- /**
1711
- * Remove a listening function of click.
1712
- * @param listener - The listening function
1713
- */ _proto.removeClicked = function removeClicked(listener) {
1714
- this._listeners.findAndRemove(function(value) {
1715
- return value.fn === listener ? value.destroyed = true : false;
1716
- });
1717
- };
1718
- _proto.onPointerClick = function onPointerClick(event) {
1719
- if (!this._getGlobalInteractive()) return;
1720
- var listeners = this._listeners.getLoopArray();
1721
- for(var i = 0, n = listeners.length; i < n; i++){
1722
- var listener = listeners[i];
1723
- !listener.destroyed && listener.fn(event);
1724
- }
1725
- };
1726
- _proto.onDestroy = function onDestroy() {
1727
- UIInteractive.prototype.onDestroy.call(this);
1728
- this._listeners.findAndRemove(function(value) {
1729
- return value.destroyed = true;
1730
- });
1731
- };
1732
- return Button;
1733
- }(UIInteractive);
1734
-
1735
- /**
1736
- * UI element that renders an image.
1737
- */ var Image = /*#__PURE__*/ function(UIRenderer1) {
1738
- _inherits(Image, UIRenderer1);
1739
- function Image(entity) {
1740
- var _this;
1741
- _this = UIRenderer1.call(this, entity) || this, _this._sprite = null, _this._tileMode = engine.SpriteTileMode.Continuous, _this._tiledAdaptiveThreshold = 0.5;
1742
- _this.drawMode = engine.SpriteDrawMode.Simple;
1743
- _this.setMaterial(_this._engine._getUIDefaultMaterial());
1744
- _this._onSpriteChange = _this._onSpriteChange.bind(_this);
1745
- return _this;
1746
- }
1747
- var _proto = Image.prototype;
1748
- /**
1749
- * @internal
1750
- */ _proto._onRootCanvasModify = function _onRootCanvasModify(flag) {
1751
- if (flag & RootCanvasModifyFlags.ReferenceResolutionPerUnit) {
1752
- var drawMode = this._drawMode;
1753
- if (drawMode === engine.SpriteDrawMode.Tiled) {
1754
- this._dirtyUpdateFlag |= 15;
1755
- } else if (drawMode === engine.SpriteDrawMode.Sliced) {
1756
- this._dirtyUpdateFlag |= engine.RendererUpdateFlags.WorldVolume;
1757
- }
1758
- }
1759
- };
1760
- /**
1761
- * @internal
1762
- */ _proto._cloneTo = function _cloneTo(target, srcRoot, targetRoot) {
1763
- // @ts-ignore
1764
- UIRenderer1.prototype._cloneTo.call(this, target, srcRoot, targetRoot);
1765
- target.sprite = this._sprite;
1766
- target.drawMode = this._drawMode;
1767
- };
1768
- _proto._updateBounds = function _updateBounds(worldBounds) {
1769
- var sprite = this._sprite;
1770
- var rootCanvas = this._getRootCanvas();
1771
- if (sprite && rootCanvas) {
1772
- var transform = this._transformEntity.transform;
1773
- var size = transform.size;
1774
- this._assembler.updatePositions(this, transform.worldMatrix, size.x, size.y, transform.pivot, false, false, rootCanvas.referenceResolutionPerUnit);
1775
- } else {
1776
- var worldPosition = this._transformEntity.transform.worldPosition;
1777
- worldBounds.min.copyFrom(worldPosition);
1778
- worldBounds.max.copyFrom(worldPosition);
1779
- }
1780
- };
1781
- _proto._render = function _render(context) {
1782
- var _this = this, sprite = _this._sprite;
1783
- var transform = this._transformEntity.transform;
1784
- var _transform_size = transform.size, width = _transform_size.x, height = _transform_size.y;
1785
- if (!(sprite == null ? void 0 : sprite.texture) || !width || !height) {
1786
- return;
1787
- }
1788
- var material = this.getMaterial();
1789
- if (!material) {
1790
- return;
1791
- }
1792
- // @todo: This question needs to be raised rather than hidden.
1793
- if (material.destroyed) {
1794
- material = this._engine._getUIDefaultMaterial();
1795
- }
1796
- var alpha = this._getGlobalAlpha();
1797
- if (this._color.a * alpha <= 0) {
1798
- return;
1799
- }
1800
- var _this1 = this, dirtyUpdateFlag = _this1._dirtyUpdateFlag;
1801
- var canvas = this._getRootCanvas();
1802
- // Update position
1803
- if (dirtyUpdateFlag & engine.RendererUpdateFlags.WorldVolume) {
1804
- this._assembler.updatePositions(this, transform.worldMatrix, width, height, transform.pivot, false, false, canvas.referenceResolutionPerUnit);
1805
- dirtyUpdateFlag &= ~engine.RendererUpdateFlags.WorldVolume;
1806
- }
1807
- // Update uv
1808
- if (dirtyUpdateFlag & 4) {
1809
- this._assembler.updateUVs(this);
1810
- dirtyUpdateFlag &= ~4;
1811
- }
1812
- // Update color
1813
- if (dirtyUpdateFlag & UIRendererUpdateFlags.Color) {
1814
- this._assembler.updateColor(this, alpha);
1815
- dirtyUpdateFlag &= ~UIRendererUpdateFlags.Color;
1816
- }
1817
- this._dirtyUpdateFlag = dirtyUpdateFlag;
1818
- // Init sub render element.
1819
- var engine$1 = context.camera.engine;
1820
- var subRenderElement = engine$1._subRenderElementPool.get();
1821
- var subChunk = this._subChunk;
1822
- subRenderElement.set(this, material, subChunk.chunk.primitive, subChunk.subMesh, this.sprite.texture, subChunk);
1823
- if (canvas._realRenderMode === CanvasRenderMode.ScreenSpaceOverlay) {
1824
- subRenderElement.shaderPasses = material.shader.subShaders[0].passes;
1825
- subRenderElement.renderQueueFlags = engine.RenderQueueFlags.All;
1826
- }
1827
- canvas._renderElement.addSubRenderElement(subRenderElement);
1828
- };
1829
- _proto._onTransformChanged = function _onTransformChanged(type) {
1830
- if (type & UITransformModifyFlags.Size && this._drawMode === engine.SpriteDrawMode.Tiled) {
1831
- this._dirtyUpdateFlag |= 15;
1832
- }
1833
- this._dirtyUpdateFlag |= engine.RendererUpdateFlags.WorldVolume;
1834
- };
1835
- _proto._onDestroy = function _onDestroy() {
1836
- var sprite = this._sprite;
1837
- if (sprite) {
1838
- this._addResourceReferCount(sprite, -1);
1839
- // @ts-ignore
1840
- sprite._updateFlagManager.removeListener(this._onSpriteChange);
1841
- this._sprite = null;
1842
- }
1843
- UIRenderer1.prototype._onDestroy.call(this);
1844
- };
1845
- _proto._onSpriteChange = function _onSpriteChange(type) {
1846
- switch(type){
1847
- case engine.SpriteModifyFlags.texture:
1848
- this.shaderData.setTexture(exports.UIRenderer._textureProperty, this.sprite.texture);
1849
- break;
1850
- case engine.SpriteModifyFlags.size:
1851
- switch(this._drawMode){
1852
- case engine.SpriteDrawMode.Sliced:
1853
- this._dirtyUpdateFlag |= engine.RendererUpdateFlags.WorldVolume;
1854
- break;
1855
- case engine.SpriteDrawMode.Tiled:
1856
- this._dirtyUpdateFlag |= 7;
1857
- break;
1858
- }
1859
- break;
1860
- case engine.SpriteModifyFlags.border:
1861
- switch(this._drawMode){
1862
- case engine.SpriteDrawMode.Sliced:
1863
- this._dirtyUpdateFlag |= 5;
1864
- break;
1865
- case engine.SpriteDrawMode.Tiled:
1866
- this._dirtyUpdateFlag |= 7;
1867
- break;
1868
- }
1869
- break;
1870
- case engine.SpriteModifyFlags.region:
1871
- case engine.SpriteModifyFlags.atlasRegionOffset:
1872
- this._dirtyUpdateFlag |= 5;
1873
- break;
1874
- case engine.SpriteModifyFlags.atlasRegion:
1875
- this._dirtyUpdateFlag |= 4;
1876
- break;
1877
- case engine.SpriteModifyFlags.destroy:
1878
- this.sprite = null;
1879
- break;
1880
- }
1881
- };
1882
- _create_class(Image, [
1883
- {
1884
- key: "drawMode",
1885
- get: /**
1886
- * The draw mode of the image.
1887
- */ function get() {
1888
- return this._drawMode;
1889
- },
1890
- set: function set(value) {
1891
- if (this._drawMode !== value) {
1892
- this._drawMode = value;
1893
- switch(value){
1894
- case engine.SpriteDrawMode.Simple:
1895
- this._assembler = engine.SimpleSpriteAssembler;
1896
- break;
1897
- case engine.SpriteDrawMode.Sliced:
1898
- this._assembler = engine.SlicedSpriteAssembler;
1899
- break;
1900
- case engine.SpriteDrawMode.Tiled:
1901
- this._assembler = engine.TiledSpriteAssembler;
1902
- break;
1903
- }
1904
- this._assembler.resetData(this);
1905
- this._dirtyUpdateFlag |= 7;
1906
- }
1907
- }
1908
- },
1909
- {
1910
- key: "tileMode",
1911
- get: /**
1912
- * The tiling mode of the image. (Only works in tiled mode.)
1913
- */ function get() {
1914
- return this._tileMode;
1915
- },
1916
- set: function set(value) {
1917
- if (this._tileMode !== value) {
1918
- this._tileMode = value;
1919
- if (this.drawMode === engine.SpriteDrawMode.Tiled) {
1920
- this._dirtyUpdateFlag |= 7;
1921
- }
1922
- }
1923
- }
1924
- },
1925
- {
1926
- key: "tiledAdaptiveThreshold",
1927
- get: /**
1928
- * Stretch Threshold in Tile Adaptive Mode, specified in normalized. (Only works in tiled adaptive mode.)
1929
- */ function get() {
1930
- return this._tiledAdaptiveThreshold;
1931
- },
1932
- set: function set(value) {
1933
- if (value !== this._tiledAdaptiveThreshold) {
1934
- value = engine.MathUtil.clamp(value, 0, 1);
1935
- this._tiledAdaptiveThreshold = value;
1936
- if (this.drawMode === engine.SpriteDrawMode.Tiled) {
1937
- this._dirtyUpdateFlag |= 7;
1938
- }
1939
- }
1940
- }
1941
- },
1942
- {
1943
- key: "sprite",
1944
- get: /**
1945
- * The Sprite to render.
1946
- */ function get() {
1947
- return this._sprite;
1948
- },
1949
- set: function set(value) {
1950
- var lastSprite = this._sprite;
1951
- if (lastSprite !== value) {
1952
- if (lastSprite) {
1953
- this._addResourceReferCount(lastSprite, -1);
1954
- // @ts-ignore
1955
- lastSprite._updateFlagManager.removeListener(this._onSpriteChange);
1956
- }
1957
- this._dirtyUpdateFlag |= 7;
1958
- if (value) {
1959
- this._addResourceReferCount(value, 1);
1960
- // @ts-ignore
1961
- value._updateFlagManager.addListener(this._onSpriteChange);
1962
- this.shaderData.setTexture(exports.UIRenderer._textureProperty, value.texture);
1963
- } else {
1964
- this.shaderData.setTexture(exports.UIRenderer._textureProperty, null);
1965
- }
1966
- this._sprite = value;
1967
- }
1968
- }
1969
- }
1970
- ]);
1971
- return Image;
1972
- }(exports.UIRenderer);
1973
- __decorate([
1974
- engine.ignoreClone
1975
- ], Image.prototype, "_sprite", void 0);
1976
- __decorate([
1977
- engine.ignoreClone
1978
- ], Image.prototype, "_drawMode", void 0);
1979
- __decorate([
1980
- engine.ignoreClone
1981
- ], Image.prototype, "_assembler", void 0);
1982
- __decorate([
1983
- engine.assignmentClone
1984
- ], Image.prototype, "_tileMode", void 0);
1985
- __decorate([
1986
- engine.assignmentClone
1987
- ], Image.prototype, "_tiledAdaptiveThreshold", void 0);
1988
- __decorate([
1989
- engine.ignoreClone
1990
- ], Image.prototype, "_onTransformChanged", null);
1991
- __decorate([
1992
- engine.ignoreClone
1993
- ], Image.prototype, "_onSpriteChange", null);
1994
-
1995
- /**
1996
- * UI component used to render text.
1997
- */ var Text = /*#__PURE__*/ function(UIRenderer1) {
1998
- _inherits(Text, UIRenderer1);
1999
- function Text(entity) {
2000
- var _this;
2001
- _this = UIRenderer1.call(this, entity) || this, _this._textChunks = Array(), _this._subFont = null, _this._text = "", _this._localBounds = new engine.BoundingBox(), _this._font = null, _this._fontSize = 24, _this._fontStyle = engine.FontStyle.None, _this._lineSpacing = 0, _this._horizontalAlignment = engine.TextHorizontalAlignment.Center, _this._verticalAlignment = engine.TextVerticalAlignment.Center, _this._enableWrapping = false, _this._overflowMode = engine.OverflowMode.Overflow;
2002
- var engine$1 = _this.engine;
2003
- // @ts-ignore
2004
- _this.font = engine$1._textDefaultFont;
2005
- _this.raycastEnabled = false;
2006
- // @ts-ignore
2007
- _this.setMaterial(engine$1._basicResources.textDefaultMaterial);
2008
- return _this;
2009
- }
2010
- var _proto = Text.prototype;
2011
- /**
2012
- * @internal
2013
- */ _proto._onDestroy = function _onDestroy() {
2014
- if (this._font) {
2015
- this._addResourceReferCount(this._font, -1);
2016
- this._font = null;
2017
- }
2018
- UIRenderer1.prototype._onDestroy.call(this);
2019
- this._freeTextChunks();
2020
- this._textChunks = null;
2021
- this._subFont && (this._subFont = null);
2022
- };
2023
- // @ts-ignore
2024
- _proto._cloneTo = function _cloneTo(target, srcRoot, targetRoot) {
2025
- // @ts-ignore
2026
- UIRenderer1.prototype._cloneTo.call(this, target, srcRoot, targetRoot);
2027
- target.font = this._font;
2028
- target._subFont = this._subFont;
2029
- };
2030
- /**
2031
- * @internal
2032
- */ _proto._isContainDirtyFlag = function _isContainDirtyFlag(type) {
2033
- return (this._dirtyUpdateFlag & type) != 0;
2034
- };
2035
- /**
2036
- * @internal
2037
- */ _proto._setDirtyFlagTrue = function _setDirtyFlagTrue(type) {
2038
- this._dirtyUpdateFlag |= type;
2039
- };
2040
- /**
2041
- * @internal
2042
- */ _proto._setDirtyFlagFalse = function _setDirtyFlagFalse(type) {
2043
- this._dirtyUpdateFlag &= ~type;
2044
- };
2045
- /**
2046
- * @internal
2047
- */ _proto._getSubFont = function _getSubFont() {
2048
- if (!this._subFont) {
2049
- this._resetSubFont();
2050
- }
2051
- return this._subFont;
2052
- };
2053
- /**
2054
- * @internal
2055
- */ _proto._onRootCanvasModify = function _onRootCanvasModify(flag) {
2056
- if (flag === RootCanvasModifyFlags.ReferenceResolutionPerUnit) {
2057
- this._setDirtyFlagTrue(8);
2058
- }
2059
- };
2060
- _proto._updateBounds = function _updateBounds(worldBounds) {
2061
- var transform = this._transformEntity.transform;
2062
- var _transform_size = transform.size, width = _transform_size.x, height = _transform_size.y;
2063
- var _transform_pivot = transform.pivot, pivotX = _transform_pivot.x, pivotY = _transform_pivot.y;
2064
- worldBounds.min.set(-width * pivotX, -height * pivotY, 0);
2065
- worldBounds.max.set(width * (1 - pivotX), height * (1 - pivotY), 0);
2066
- engine.BoundingBox.transform(worldBounds, this._transformEntity.transform.worldMatrix, worldBounds);
2067
- };
2068
- _proto._render = function _render(context) {
2069
- if (this._isTextNoVisible()) {
2070
- return;
2071
- }
2072
- if (this._isContainDirtyFlag(4)) {
2073
- this._resetSubFont();
2074
- this._setDirtyFlagFalse(4);
2075
- }
2076
- var canvas = this._getRootCanvas();
2077
- if (this._isContainDirtyFlag(8)) {
2078
- this._updateLocalData();
2079
- this._setDirtyFlagTrue(8);
2080
- }
2081
- if (this._isContainDirtyFlag(16)) {
2082
- this._updatePosition();
2083
- this._setDirtyFlagFalse(16);
2084
- }
2085
- if (this._isContainDirtyFlag(UIRendererUpdateFlags.Color)) {
2086
- this._updateColor();
2087
- this._setDirtyFlagFalse(UIRendererUpdateFlags.Color);
2088
- }
2089
- var engine$1 = context.camera.engine;
2090
- var textSubRenderElementPool = engine$1._textSubRenderElementPool;
2091
- var material = this.getMaterial();
2092
- var renderElement = canvas._renderElement;
2093
- var textChunks = this._textChunks;
2094
- var isOverlay = canvas._realRenderMode === CanvasRenderMode.ScreenSpaceOverlay;
2095
- for(var i = 0, n = textChunks.length; i < n; ++i){
2096
- var // @ts-ignore
2097
- _subRenderElement;
2098
- var _textChunks_i = textChunks[i], subChunk = _textChunks_i.subChunk, texture = _textChunks_i.texture;
2099
- var subRenderElement = textSubRenderElementPool.get();
2100
- subRenderElement.set(this, material, subChunk.chunk.primitive, subChunk.subMesh, texture, subChunk);
2101
- (_subRenderElement = subRenderElement).shaderData || (_subRenderElement.shaderData = new engine.ShaderData(engine.ShaderDataGroup.RenderElement));
2102
- subRenderElement.shaderData.setTexture(Text._textTextureProperty, texture);
2103
- if (isOverlay) {
2104
- subRenderElement.shaderPasses = material.shader.subShaders[0].passes;
2105
- subRenderElement.renderQueueFlags = engine.RenderQueueFlags.All;
2106
- }
2107
- renderElement.addSubRenderElement(subRenderElement);
2108
- }
2109
- };
2110
- _proto._resetSubFont = function _resetSubFont() {
2111
- var font = this._font;
2112
- // @ts-ignore
2113
- this._subFont = font._getSubFont(this.fontSize, this.fontStyle);
2114
- this._subFont.nativeFontString = engine.TextUtils.getNativeFontString(font.name, this.fontSize, this.fontStyle);
2115
- };
2116
- _proto._updatePosition = function _updatePosition() {
2117
- var e = this._transformEntity.transform.worldMatrix.elements;
2118
- // prettier-ignore
2119
- var e0 = e[0], e1 = e[1], e2 = e[2], e4 = e[4], e5 = e[5], e6 = e[6], e12 = e[12], e13 = e[13], e14 = e[14];
2120
- var up = exports.UIRenderer._tempVec31.set(e4, e5, e6);
2121
- var right = exports.UIRenderer._tempVec30.set(e0, e1, e2);
2122
- var worldPositions = Text._worldPositions;
2123
- var worldPosition0 = worldPositions[0], worldPosition1 = worldPositions[1], worldPosition2 = worldPositions[2], worldPosition3 = worldPositions[3];
2124
- var textChunks = this._textChunks;
2125
- for(var i = 0, n = textChunks.length; i < n; ++i){
2126
- var _textChunks_i = textChunks[i], subChunk = _textChunks_i.subChunk, charRenderInfos = _textChunks_i.charRenderInfos;
2127
- for(var j = 0, m = charRenderInfos.length; j < m; ++j){
2128
- var charRenderInfo = charRenderInfos[j];
2129
- var localPositions = charRenderInfo.localPositions;
2130
- var topLeftX = localPositions.x, topLeftY = localPositions.y;
2131
- // Top-Left
2132
- worldPosition0.set(topLeftX * e0 + topLeftY * e4 + e12, topLeftX * e1 + topLeftY * e5 + e13, topLeftX * e2 + topLeftY * e6 + e14);
2133
- // Right offset
2134
- engine.Vector3.scale(right, localPositions.z - topLeftX, worldPosition1);
2135
- // Top-Right
2136
- engine.Vector3.add(worldPosition0, worldPosition1, worldPosition1);
2137
- // Up offset
2138
- engine.Vector3.scale(up, localPositions.w - topLeftY, worldPosition2);
2139
- // Bottom-Left
2140
- engine.Vector3.add(worldPosition0, worldPosition2, worldPosition3);
2141
- // Bottom-Right
2142
- engine.Vector3.add(worldPosition1, worldPosition2, worldPosition2);
2143
- var vertices = subChunk.chunk.vertices;
2144
- for(var k = 0, o = subChunk.vertexArea.start + charRenderInfo.indexInChunk * 36; k < 4; ++k, o += 9){
2145
- worldPositions[k].copyToArray(vertices, o);
2146
- }
2147
- }
2148
- }
2149
- };
2150
- _proto._updateColor = function _updateColor() {
2151
- var _this__color = this._color, r = _this__color.r, g = _this__color.g, b = _this__color.b, a = _this__color.a;
2152
- var finalAlpha = a * this._getGlobalAlpha();
2153
- var textChunks = this._textChunks;
2154
- for(var i = 0, n = textChunks.length; i < n; ++i){
2155
- var subChunk = textChunks[i].subChunk;
2156
- var vertexArea = subChunk.vertexArea;
2157
- var vertexCount = vertexArea.size / 9;
2158
- var vertices = subChunk.chunk.vertices;
2159
- for(var j = 0, o = vertexArea.start + 5; j < vertexCount; ++j, o += 9){
2160
- vertices[o] = r;
2161
- vertices[o + 1] = g;
2162
- vertices[o + 2] = b;
2163
- vertices[o + 3] = finalAlpha;
2164
- }
2165
- }
2166
- };
2167
- _proto._updateLocalData = function _updateLocalData() {
2168
- // @ts-ignore
2169
- var pixelsPerResolution = engine.Engine._pixelsPerUnit / this._getRootCanvas().referenceResolutionPerUnit;
2170
- var _this__localBounds = this._localBounds, min = _this__localBounds.min, max = _this__localBounds.max;
2171
- var charRenderInfos = Text._charRenderInfos;
2172
- var charFont = this._getSubFont();
2173
- var _this__transformEntity_transform = this._transformEntity.transform, size = _this__transformEntity_transform.size, pivot = _this__transformEntity_transform.pivot;
2174
- var rendererWidth = size.x;
2175
- var rendererHeight = size.y;
2176
- var offsetWidth = rendererWidth * (0.5 - pivot.x);
2177
- var offsetHeight = rendererHeight * (0.5 - pivot.y);
2178
- var textMetrics = this.enableWrapping ? engine.TextUtils.measureTextWithWrap(this, rendererWidth * pixelsPerResolution, rendererHeight * pixelsPerResolution, this._lineSpacing * pixelsPerResolution) : engine.TextUtils.measureTextWithoutWrap(this, rendererHeight * pixelsPerResolution, this._lineSpacing * pixelsPerResolution);
2179
- var height = textMetrics.height, lines = textMetrics.lines, lineWidths = textMetrics.lineWidths, lineHeight = textMetrics.lineHeight, lineMaxSizes = textMetrics.lineMaxSizes;
2180
- // @ts-ignore
2181
- var charRenderInfoPool = this.engine._charRenderInfoPool;
2182
- var linesLen = lines.length;
2183
- var renderElementCount = 0;
2184
- if (linesLen > 0) {
2185
- var horizontalAlignment = this.horizontalAlignment;
2186
- var pixelsPerUnitReciprocal = 1.0 / pixelsPerResolution;
2187
- rendererWidth *= pixelsPerResolution;
2188
- rendererHeight *= pixelsPerResolution;
2189
- var halfRendererWidth = rendererWidth * 0.5;
2190
- var halfLineHeight = lineHeight * 0.5;
2191
- var startY = 0;
2192
- var topDiff = lineHeight * 0.5 - lineMaxSizes[0].ascent;
2193
- var bottomDiff = lineHeight * 0.5 - lineMaxSizes[linesLen - 1].descent - 1;
2194
- switch(this.verticalAlignment){
2195
- case engine.TextVerticalAlignment.Top:
2196
- startY = rendererHeight * 0.5 - halfLineHeight + topDiff;
2197
- break;
2198
- case engine.TextVerticalAlignment.Center:
2199
- startY = height * 0.5 - halfLineHeight - (bottomDiff - topDiff) * 0.5;
2200
- break;
2201
- case engine.TextVerticalAlignment.Bottom:
2202
- startY = height - rendererHeight * 0.5 - halfLineHeight - bottomDiff;
2203
- break;
2204
- }
2205
- var firstLine = -1;
2206
- var minX = Number.MAX_SAFE_INTEGER;
2207
- var minY = Number.MAX_SAFE_INTEGER;
2208
- var maxX = Number.MIN_SAFE_INTEGER;
2209
- var maxY = Number.MIN_SAFE_INTEGER;
2210
- for(var i = 0; i < linesLen; ++i){
2211
- var lineWidth = lineWidths[i];
2212
- if (lineWidth > 0) {
2213
- var line = lines[i];
2214
- var startX = 0;
2215
- var firstRow = -1;
2216
- if (firstLine < 0) {
2217
- firstLine = i;
2218
- }
2219
- switch(horizontalAlignment){
2220
- case engine.TextHorizontalAlignment.Left:
2221
- startX = -halfRendererWidth;
2222
- break;
2223
- case engine.TextHorizontalAlignment.Center:
2224
- startX = -lineWidth * 0.5;
2225
- break;
2226
- case engine.TextHorizontalAlignment.Right:
2227
- startX = halfRendererWidth - lineWidth;
2228
- break;
2229
- }
2230
- for(var j = 0, n = line.length; j < n; ++j){
2231
- var char = line[j];
2232
- var charInfo = charFont._getCharInfo(char);
2233
- if (charInfo.h > 0) {
2234
- firstRow < 0 && (firstRow = j);
2235
- var charRenderInfo = charRenderInfos[renderElementCount++] = charRenderInfoPool.get();
2236
- var localPositions = charRenderInfo.localPositions;
2237
- charRenderInfo.texture = charFont._getTextureByIndex(charInfo.index);
2238
- charRenderInfo.uvs = charInfo.uvs;
2239
- var w = charInfo.w, ascent = charInfo.ascent, descent = charInfo.descent;
2240
- var left = (startX + offsetWidth) * pixelsPerUnitReciprocal;
2241
- var right = (startX + w + offsetWidth) * pixelsPerUnitReciprocal;
2242
- var top = (startY + ascent + offsetHeight) * pixelsPerUnitReciprocal;
2243
- var bottom = (startY - descent + offsetHeight) * pixelsPerUnitReciprocal;
2244
- localPositions.set(left, top, right, bottom);
2245
- i === firstLine && (maxY = Math.max(maxY, top));
2246
- minY = Math.min(minY, bottom);
2247
- j === firstRow && (minX = Math.min(minX, left));
2248
- maxX = Math.max(maxX, right);
2249
- }
2250
- startX += charInfo.xAdvance + charInfo.offsetX;
2251
- }
2252
- }
2253
- startY -= lineHeight;
2254
- }
2255
- if (firstLine < 0) {
2256
- min.set(0, 0, 0);
2257
- max.set(0, 0, 0);
2258
- } else {
2259
- min.set(minX, minY, 0);
2260
- max.set(maxX, maxY, 0);
2261
- }
2262
- } else {
2263
- min.set(0, 0, 0);
2264
- max.set(0, 0, 0);
2265
- }
2266
- charFont._getLastIndex() > 0 && charRenderInfos.sort(function(a, b) {
2267
- return a.texture.instanceId - b.texture.instanceId;
2268
- });
2269
- this._freeTextChunks();
2270
- if (renderElementCount === 0) {
2271
- return;
2272
- }
2273
- var textChunks = this._textChunks;
2274
- var curTextChunk = new TextChunk();
2275
- textChunks.push(curTextChunk);
2276
- var chunkMaxVertexCount = this._getChunkManager().maxVertexCount;
2277
- var curCharRenderInfo = charRenderInfos[0];
2278
- var curTexture = curCharRenderInfo.texture;
2279
- curTextChunk.texture = curTexture;
2280
- var curCharInfos = curTextChunk.charRenderInfos;
2281
- curCharInfos.push(curCharRenderInfo);
2282
- for(var i1 = 1; i1 < renderElementCount; ++i1){
2283
- var charRenderInfo1 = charRenderInfos[i1];
2284
- var texture = charRenderInfo1.texture;
2285
- if (curTexture !== texture || curCharInfos.length * 4 + 4 > chunkMaxVertexCount) {
2286
- this._buildChunk(curTextChunk, curCharInfos.length);
2287
- curTextChunk = new TextChunk();
2288
- textChunks.push(curTextChunk);
2289
- curTexture = texture;
2290
- curTextChunk.texture = texture;
2291
- curCharInfos = curTextChunk.charRenderInfos;
2292
- }
2293
- curCharInfos.push(charRenderInfo1);
2294
- }
2295
- var charLength = curCharInfos.length;
2296
- if (charLength > 0) {
2297
- this._buildChunk(curTextChunk, charLength);
2298
- }
2299
- charRenderInfos.length = 0;
2300
- };
2301
- _proto._onTransformChanged = function _onTransformChanged(type) {
2302
- if (type & UITransformModifyFlags.Size || type & UITransformModifyFlags.Pivot) {
2303
- this._dirtyUpdateFlag |= 8;
2304
- }
2305
- UIRenderer1.prototype._onTransformChanged.call(this, type);
2306
- this._setDirtyFlagTrue(16);
2307
- };
2308
- _proto._isTextNoVisible = function _isTextNoVisible() {
2309
- var size = this._transformEntity.transform.size;
2310
- return this._text === "" || this._fontSize === 0 || this.enableWrapping && size.x <= 0 || this.overflowMode === engine.OverflowMode.Truncate && size.y <= 0 || !this._getRootCanvas();
2311
- };
2312
- _proto._buildChunk = function _buildChunk(textChunk, count) {
2313
- var _this_color = this.color, r = _this_color.r, g = _this_color.g, b = _this_color.b, a = _this_color.a;
2314
- var tempIndices = engine.CharRenderInfo.triangles;
2315
- var tempIndicesLength = tempIndices.length;
2316
- var subChunk = textChunk.subChunk = this._getChunkManager().allocateSubChunk(count * 4);
2317
- var vertices = subChunk.chunk.vertices;
2318
- var indices = subChunk.indices = [];
2319
- var charRenderInfos = textChunk.charRenderInfos;
2320
- for(var i = 0, ii = 0, io = 0, vo = subChunk.vertexArea.start + 3; i < count; ++i, io += 4){
2321
- var charRenderInfo = charRenderInfos[i];
2322
- charRenderInfo.indexInChunk = i;
2323
- // Set indices
2324
- for(var j = 0; j < tempIndicesLength; ++j){
2325
- indices[ii++] = tempIndices[j] + io;
2326
- }
2327
- // Set uv and color for vertices
2328
- for(var j1 = 0; j1 < 4; ++j1, vo += 9){
2329
- var uv = charRenderInfo.uvs[j1];
2330
- uv.copyToArray(vertices, vo);
2331
- vertices[vo + 2] = r;
2332
- vertices[vo + 3] = g;
2333
- vertices[vo + 4] = b;
2334
- vertices[vo + 5] = a;
2335
- }
2336
- }
2337
- return subChunk;
2338
- };
2339
- _proto._freeTextChunks = function _freeTextChunks() {
2340
- var textChunks = this._textChunks;
2341
- // @ts-ignore
2342
- var charRenderInfoPool = this.engine._charRenderInfoPool;
2343
- var manager = this._getChunkManager();
2344
- for(var i = 0, n = textChunks.length; i < n; ++i){
2345
- var textChunk = textChunks[i];
2346
- var charRenderInfos = textChunk.charRenderInfos;
2347
- for(var j = 0, m = charRenderInfos.length; j < m; ++j){
2348
- charRenderInfoPool.return(charRenderInfos[j]);
2349
- }
2350
- charRenderInfos.length = 0;
2351
- manager.freeSubChunk(textChunk.subChunk);
2352
- textChunk.subChunk = null;
2353
- textChunk.texture = null;
2354
- }
2355
- textChunks.length = 0;
2356
- };
2357
- _create_class(Text, [
2358
- {
2359
- key: "text",
2360
- get: /**
2361
- * Rendering string for the Text.
2362
- */ function get() {
2363
- return this._text;
2364
- },
2365
- set: function set(value) {
2366
- value = value || "";
2367
- if (this._text !== value) {
2368
- this._text = value;
2369
- this._setDirtyFlagTrue(25);
2370
- }
2371
- }
2372
- },
2373
- {
2374
- key: "font",
2375
- get: /**
2376
- * The font of the Text.
2377
- */ function get() {
2378
- return this._font;
2379
- },
2380
- set: function set(value) {
2381
- var lastFont = this._font;
2382
- if (lastFont !== value) {
2383
- lastFont && this._addResourceReferCount(lastFont, -1);
2384
- value && this._addResourceReferCount(value, 1);
2385
- this._font = value;
2386
- this._setDirtyFlagTrue(29);
2387
- }
2388
- }
2389
- },
2390
- {
2391
- key: "fontSize",
2392
- get: /**
2393
- * The font size of the Text.
2394
- */ function get() {
2395
- return this._fontSize;
2396
- },
2397
- set: function set(value) {
2398
- if (this._fontSize !== value) {
2399
- this._fontSize = value;
2400
- this._setDirtyFlagTrue(29);
2401
- }
2402
- }
2403
- },
2404
- {
2405
- key: "fontStyle",
2406
- get: /**
2407
- * The style of the font.
2408
- */ function get() {
2409
- return this._fontStyle;
2410
- },
2411
- set: function set(value) {
2412
- if (this.fontStyle !== value) {
2413
- this._fontStyle = value;
2414
- this._setDirtyFlagTrue(29);
2415
- }
2416
- }
2417
- },
2418
- {
2419
- key: "lineSpacing",
2420
- get: /**
2421
- * The space between two lines (in pixels).
2422
- */ function get() {
2423
- return this._lineSpacing;
2424
- },
2425
- set: function set(value) {
2426
- if (this._lineSpacing !== value) {
2427
- this._lineSpacing = value;
2428
- this._setDirtyFlagTrue(25);
2429
- }
2430
- }
2431
- },
2432
- {
2433
- key: "horizontalAlignment",
2434
- get: /**
2435
- * The horizontal alignment.
2436
- */ function get() {
2437
- return this._horizontalAlignment;
2438
- },
2439
- set: function set(value) {
2440
- if (this._horizontalAlignment !== value) {
2441
- this._horizontalAlignment = value;
2442
- this._setDirtyFlagTrue(25);
2443
- }
2444
- }
2445
- },
2446
- {
2447
- key: "verticalAlignment",
2448
- get: /**
2449
- * The vertical alignment.
2450
- */ function get() {
2451
- return this._verticalAlignment;
2452
- },
2453
- set: function set(value) {
2454
- if (this._verticalAlignment !== value) {
2455
- this._verticalAlignment = value;
2456
- this._setDirtyFlagTrue(25);
2457
- }
2458
- }
2459
- },
2460
- {
2461
- key: "enableWrapping",
2462
- get: /**
2463
- * Whether wrap text to next line when exceeds the width of the container.
2464
- */ function get() {
2465
- return this._enableWrapping;
2466
- },
2467
- set: function set(value) {
2468
- if (this._enableWrapping !== value) {
2469
- this._enableWrapping = value;
2470
- this._setDirtyFlagTrue(25);
2471
- }
2472
- }
2473
- },
2474
- {
2475
- key: "overflowMode",
2476
- get: /**
2477
- * The overflow mode.
2478
- */ function get() {
2479
- return this._overflowMode;
2480
- },
2481
- set: function set(value) {
2482
- if (this._overflowMode !== value) {
2483
- this._overflowMode = value;
2484
- this._setDirtyFlagTrue(25);
2485
- }
2486
- }
2487
- },
2488
- {
2489
- key: "maskLayer",
2490
- get: /**
2491
- * The mask layer the sprite renderer belongs to.
2492
- */ function get() {
2493
- return this._maskLayer;
2494
- },
2495
- set: function set(value) {
2496
- this._maskLayer = value;
2497
- }
2498
- },
2499
- {
2500
- key: "bounds",
2501
- get: /**
2502
- * The bounding volume of the TextRenderer.
2503
- */ function get() {
2504
- if (this._isTextNoVisible()) {
2505
- if (this._isContainDirtyFlag(engine.RendererUpdateFlags.WorldVolume)) {
2506
- var localBounds = this._localBounds;
2507
- localBounds.min.set(0, 0, 0);
2508
- localBounds.max.set(0, 0, 0);
2509
- this._updateBounds(this._bounds);
2510
- this._setDirtyFlagFalse(engine.RendererUpdateFlags.WorldVolume);
2511
- }
2512
- return this._bounds;
2513
- }
2514
- this._isContainDirtyFlag(4) && this._resetSubFont();
2515
- this._isContainDirtyFlag(8) && this._updateLocalData();
2516
- this._isContainDirtyFlag(16) && this._updatePosition();
2517
- this._isContainDirtyFlag(engine.RendererUpdateFlags.WorldVolume) && this._updateBounds(this._bounds);
2518
- this._setDirtyFlagFalse(29);
2519
- return this._bounds;
2520
- }
2521
- }
2522
- ]);
2523
- return Text;
2524
- }(exports.UIRenderer);
2525
- Text._textTextureProperty = engine.ShaderProperty.getByName("renderElement_TextTexture");
2526
- Text._worldPositions = [
2527
- new engine.Vector3(),
2528
- new engine.Vector3(),
2529
- new engine.Vector3(),
2530
- new engine.Vector3()
2531
- ];
2532
- Text._charRenderInfos = [];
2533
- __decorate([
2534
- engine.ignoreClone
2535
- ], Text.prototype, "_textChunks", void 0);
2536
- __decorate([
2537
- engine.ignoreClone
2538
- ], Text.prototype, "_subFont", void 0);
2539
- __decorate([
2540
- engine.assignmentClone
2541
- ], Text.prototype, "_text", void 0);
2542
- __decorate([
2543
- engine.ignoreClone
2544
- ], Text.prototype, "_localBounds", void 0);
2545
- __decorate([
2546
- engine.assignmentClone
2547
- ], Text.prototype, "_font", void 0);
2548
- __decorate([
2549
- engine.assignmentClone
2550
- ], Text.prototype, "_fontSize", void 0);
2551
- __decorate([
2552
- engine.assignmentClone
2553
- ], Text.prototype, "_fontStyle", void 0);
2554
- __decorate([
2555
- engine.assignmentClone
2556
- ], Text.prototype, "_lineSpacing", void 0);
2557
- __decorate([
2558
- engine.assignmentClone
2559
- ], Text.prototype, "_horizontalAlignment", void 0);
2560
- __decorate([
2561
- engine.assignmentClone
2562
- ], Text.prototype, "_verticalAlignment", void 0);
2563
- __decorate([
2564
- engine.assignmentClone
2565
- ], Text.prototype, "_enableWrapping", void 0);
2566
- __decorate([
2567
- engine.assignmentClone
2568
- ], Text.prototype, "_overflowMode", void 0);
2569
- __decorate([
2570
- engine.ignoreClone
2571
- ], Text.prototype, "_onTransformChanged", null);
2572
- var TextChunk = function TextChunk() {
2573
- this.charRenderInfos = new Array();
2574
- };
2575
-
2576
- /**
2577
- * The transition behavior of UIInteractive.
2578
- */ var Transition = /*#__PURE__*/ function() {
2579
- function Transition() {
2580
- this._duration = 0;
2581
- this._countDown = 0;
2582
- this._finalState = InteractiveState.Normal;
2583
- }
2584
- var _proto = Transition.prototype;
2585
- _proto.destroy = function destroy() {
2586
- var _this__interactive;
2587
- (_this__interactive = this._interactive) == null ? void 0 : _this__interactive.removeTransition(this);
2588
- this._target = null;
2589
- };
2590
- /**
2591
- * @internal
2592
- */ _proto._setState = function _setState(state, instant) {
2593
- this._finalState = state;
2594
- var value = this._getValueByState(state);
2595
- if (instant) {
2596
- this._countDown = 0;
2597
- this._initialValue = this._finalValue = value;
2598
- } else {
2599
- this._countDown = this._duration;
2600
- this._initialValue = this._getTargetValueCopy();
2601
- this._finalValue = value;
2602
- }
2603
- this._updateValue();
2604
- };
2605
- /**
2606
- * @internal
2607
- */ _proto._onUpdate = function _onUpdate(delta) {
2608
- if (this._countDown > 0) {
2609
- this._countDown -= delta;
2610
- this._updateValue();
2611
- }
2612
- };
2613
- _proto._onStateValueDirty = function _onStateValueDirty(state, preValue, curValue) {
2614
- // @ts-ignore
2615
- _instanceof(preValue, engine.ReferResource) && preValue._addReferCount(-1);
2616
- // @ts-ignore
2617
- _instanceof(curValue, engine.ReferResource) && curValue._addReferCount(1);
2618
- if (this._finalState === state) {
2619
- this._finalValue = curValue;
2620
- this._updateValue();
2621
- }
2622
- };
2623
- _proto._updateValue = function _updateValue() {
2624
- var _this__target;
2625
- var weight = this._duration ? 1 - this._countDown / this._duration : 1;
2626
- this._updateCurrentValue(this._initialValue, this._finalValue, weight);
2627
- ((_this__target = this._target) == null ? void 0 : _this__target.enabled) && this._applyValue(this._currentValue);
2628
- };
2629
- _proto._getValueByState = function _getValueByState(state) {
2630
- switch(state){
2631
- case InteractiveState.Normal:
2632
- return this.normal;
2633
- case InteractiveState.Pressed:
2634
- return this.pressed;
2635
- case InteractiveState.Hover:
2636
- return this.hover;
2637
- case InteractiveState.Disable:
2638
- return this.disabled;
2639
- }
2640
- };
2641
- _create_class(Transition, [
2642
- {
2643
- key: "normal",
2644
- get: /**
2645
- * The normal state of the transition.
2646
- */ function get() {
2647
- return this._normal;
2648
- },
2649
- set: function set(value) {
2650
- var preNormal = this._normal;
2651
- if (preNormal !== value) {
2652
- this._normal = value;
2653
- this._onStateValueDirty(InteractiveState.Normal, preNormal, value);
2654
- }
2655
- }
2656
- },
2657
- {
2658
- key: "pressed",
2659
- get: /**
2660
- * The pressed state of the transition.
2661
- */ function get() {
2662
- return this._pressed;
2663
- },
2664
- set: function set(value) {
2665
- var prePressed = this._pressed;
2666
- if (prePressed !== value) {
2667
- this._pressed = value;
2668
- this._onStateValueDirty(InteractiveState.Pressed, prePressed, value);
2669
- }
2670
- }
2671
- },
2672
- {
2673
- key: "hover",
2674
- get: /**
2675
- * The hover state of the transition.
2676
- */ function get() {
2677
- return this._hover;
2678
- },
2679
- set: function set(value) {
2680
- var preHover = this._hover;
2681
- if (preHover !== value) {
2682
- this._hover = value;
2683
- this._onStateValueDirty(InteractiveState.Hover, preHover, value);
2684
- }
2685
- }
2686
- },
2687
- {
2688
- key: "disabled",
2689
- get: /**
2690
- * The disabled state of the transition.
2691
- */ function get() {
2692
- return this._disabled;
2693
- },
2694
- set: function set(value) {
2695
- var preDisabled = this._disabled;
2696
- if (preDisabled !== value) {
2697
- this._disabled = value;
2698
- this._onStateValueDirty(InteractiveState.Disable, preDisabled, value);
2699
- }
2700
- }
2701
- },
2702
- {
2703
- key: "target",
2704
- get: /**
2705
- * The target of the transition.
2706
- */ function get() {
2707
- return this._target;
2708
- },
2709
- set: function set(value) {
2710
- if (this._target !== value) {
2711
- this._target = value;
2712
- (value == null ? void 0 : value.enabled) && this._applyValue(this._currentValue);
2713
- }
2714
- }
2715
- },
2716
- {
2717
- key: "duration",
2718
- get: /**
2719
- * The duration of the transition.
2720
- */ function get() {
2721
- return this._duration;
2722
- },
2723
- set: function set(value) {
2724
- if (value < 0) value = 0;
2725
- var preDuration = this._duration;
2726
- if (preDuration !== value) {
2727
- this._duration = value;
2728
- if (this._countDown > 0) {
2729
- this._countDown = value * (1 - this._countDown / preDuration);
2730
- this._updateValue();
2731
- }
2732
- }
2733
- }
2734
- }
2735
- ]);
2736
- return Transition;
2737
- }();
2738
-
2739
- /**
2740
- * Color transition.
2741
- */ var ColorTransition = /*#__PURE__*/ function(Transition) {
2742
- _inherits(ColorTransition, Transition);
2743
- function ColorTransition() {
2744
- var _this;
2745
- _this = Transition.call(this) || this, _this._color = new engine.Color();
2746
- _this._normal = new engine.Color(1, 1, 1, 1);
2747
- _this._hover = new engine.Color(245 / 255, 245 / 255, 245 / 255, 1);
2748
- _this._pressed = new engine.Color(200 / 255, 200 / 255, 200 / 255, 1);
2749
- _this._disabled = new engine.Color(200 / 255, 200 / 255, 200 / 255, 1);
2750
- _this._duration = 0.1;
2751
- _this._currentValue = new engine.Color();
2752
- _this._onNormalValueChanged = _this._onNormalValueChanged.bind(_this);
2753
- _this._onHoverValueChanged = _this._onHoverValueChanged.bind(_this);
2754
- _this._onPressedValueChanged = _this._onPressedValueChanged.bind(_this);
2755
- _this._onDisabledValueChanged = _this._onDisabledValueChanged.bind(_this);
2756
- // @ts-ignore
2757
- _this._normal._onValueChanged = _this._onNormalValueChanged;
2758
- // @ts-ignore
2759
- _this._hover._onValueChanged = _this._onHoverValueChanged;
2760
- // @ts-ignore
2761
- _this._pressed._onValueChanged = _this._onPressedValueChanged;
2762
- // @ts-ignore
2763
- _this._disabled._onValueChanged = _this._onDisabledValueChanged;
2764
- return _this;
2765
- }
2766
- var _proto = ColorTransition.prototype;
2767
- _proto._onNormalValueChanged = function _onNormalValueChanged() {
2768
- if (this._finalState === InteractiveState.Normal) {
2769
- this._finalValue = this._normal;
2770
- this._updateValue();
2771
- }
2772
- };
2773
- _proto._onHoverValueChanged = function _onHoverValueChanged() {
2774
- if (this._finalState === InteractiveState.Hover) {
2775
- this._finalValue = this._hover;
2776
- this._updateValue();
2777
- }
2778
- };
2779
- _proto._onPressedValueChanged = function _onPressedValueChanged() {
2780
- if (this._finalState === InteractiveState.Pressed) {
2781
- this._finalValue = this._pressed;
2782
- this._updateValue();
2783
- }
2784
- };
2785
- _proto._onDisabledValueChanged = function _onDisabledValueChanged() {
2786
- if (this._finalState === InteractiveState.Disable) {
2787
- this._finalValue = this._disabled;
2788
- this._updateValue();
2789
- }
2790
- };
2791
- _proto._getTargetValueCopy = function _getTargetValueCopy() {
2792
- var _this__target;
2793
- var color = this._color;
2794
- color.copyFrom(((_this__target = this._target) == null ? void 0 : _this__target.color) || this._normal);
2795
- return color;
2796
- };
2797
- _proto._updateCurrentValue = function _updateCurrentValue(srcValue, destValue, weight) {
2798
- if (weight >= 1) {
2799
- this._currentValue.copyFrom(destValue);
2800
- } else {
2801
- engine.Color.lerp(srcValue, destValue, weight, this._currentValue);
2802
- }
2803
- };
2804
- _proto._applyValue = function _applyValue(value) {
2805
- this._target.color = value;
2806
- };
2807
- return ColorTransition;
2808
- }(Transition);
2809
-
2810
- /**
2811
- * Scale transition.
2812
- */ var ScaleTransition = /*#__PURE__*/ function(Transition) {
2813
- _inherits(ScaleTransition, Transition);
2814
- function ScaleTransition() {
2815
- var _this;
2816
- _this = Transition.call(this) || this;
2817
- _this._normal = 1;
2818
- _this._hover = 1;
2819
- _this._pressed = 1.2;
2820
- _this._disabled = 1;
2821
- _this._duration = 0.1;
2822
- return _this;
2823
- }
2824
- var _proto = ScaleTransition.prototype;
2825
- _proto._getTargetValueCopy = function _getTargetValueCopy() {
2826
- var _this__target;
2827
- return ((_this__target = this._target) == null ? void 0 : _this__target.entity.transform.scale.x) || this._normal;
2828
- };
2829
- _proto._updateCurrentValue = function _updateCurrentValue(srcValue, destValue, weight) {
2830
- this._currentValue = weight >= 1 ? destValue : (destValue - srcValue) * weight + srcValue;
2831
- };
2832
- _proto._applyValue = function _applyValue(value) {
2833
- this._target.entity.transform.setScale(value, value, value);
2834
- };
2835
- return ScaleTransition;
2836
- }(Transition);
2837
-
2838
- /**
2839
- * Sprite transition.
2840
- */ var SpriteTransition = /*#__PURE__*/ function(Transition) {
2841
- _inherits(SpriteTransition, Transition);
2842
- function SpriteTransition() {
2843
- return Transition.apply(this, arguments) || this;
2844
- }
2845
- var _proto = SpriteTransition.prototype;
2846
- /**
2847
- * @internal
2848
- */ _proto.destroy = function destroy() {
2849
- Transition.prototype.destroy.call(this);
2850
- if (this._normal) {
2851
- // @ts-ignore
2852
- this._normal._addReferCount(-1);
2853
- this._normal = null;
2854
- }
2855
- if (this._hover) {
2856
- // @ts-ignore
2857
- this._hover._addReferCount(-1);
2858
- this._hover = null;
2859
- }
2860
- if (this._pressed) {
2861
- // @ts-ignore
2862
- this._pressed._addReferCount(-1);
2863
- this._pressed = null;
2864
- }
2865
- if (this._disabled) {
2866
- // @ts-ignore
2867
- this._disabled._addReferCount(-1);
2868
- this._disabled = null;
2869
- }
2870
- this._initialValue = this._currentValue = this._finalValue = null;
2871
- this._target = null;
2872
- };
2873
- _proto._getTargetValueCopy = function _getTargetValueCopy() {
2874
- var _this__target;
2875
- return (_this__target = this._target) == null ? void 0 : _this__target.sprite;
2876
- };
2877
- _proto._updateCurrentValue = function _updateCurrentValue(srcValue, destValue, weight) {
2878
- this._currentValue = weight >= 1 ? destValue : srcValue;
2879
- };
2880
- _proto._applyValue = function _applyValue(value) {
2881
- this._target.sprite = value;
2882
- };
2883
- return SpriteTransition;
2884
- }(Transition);
2885
-
2886
- var GUIComponent = /*#__PURE__*/Object.freeze({
2887
- __proto__: null,
2888
- get UICanvas () { return exports.UICanvas; },
2889
- UIGroup: UIGroup,
2890
- get UIRenderer () { return exports.UIRenderer; },
2891
- UITransform: UITransform,
2892
- Button: Button,
2893
- Image: Image,
2894
- Text: Text,
2895
- ColorTransition: ColorTransition,
2896
- ScaleTransition: ScaleTransition,
2897
- SpriteTransition: SpriteTransition,
2898
- Transition: Transition
2899
- });
2900
-
2901
- var uiDefaultFs = "#define GLSLIFY 1\nuniform sampler2D renderer_UITexture;\n\nvarying vec2 v_uv;\nvarying vec4 v_color;\n\nvoid main() {\n vec4 baseColor = texture2D(renderer_UITexture, v_uv);\n gl_FragColor = baseColor * v_color;\n}\n"; // eslint-disable-line
2902
-
2903
- var uiDefaultVs = "#define GLSLIFY 1\nuniform mat4 renderer_MVPMat;\n\nattribute vec3 POSITION;\nattribute vec2 TEXCOORD_0;\nattribute vec4 COLOR_0;\n\nvarying vec2 v_uv;\nvarying vec4 v_color;\n\nvoid main() {\n gl_Position = renderer_MVPMat * vec4(POSITION, 1.0);\n\n v_uv = TEXCOORD_0;\n v_color = COLOR_0;\n}\n"; // eslint-disable-line
2904
-
2905
- /**
2906
- * @internal
2907
- */ var UIHitResult = function UIHitResult() {
2908
- this.entity = null;
2909
- this.distance = 0;
2910
- this.point = new engine.Vector3();
2911
- this.normal = new engine.Vector3();
2912
- this.component = null;
2913
- };
2914
-
2915
- exports.UIPointerEventEmitter = /*#__PURE__*/ function(PointerEventEmitter1) {
2916
- _inherits(UIPointerEventEmitter, PointerEventEmitter1);
2917
- function UIPointerEventEmitter() {
2918
- var _this;
2919
- _this = PointerEventEmitter1.apply(this, arguments) || this, _this._enteredPath = [], _this._pressedPath = [], _this._draggedPath = [];
2920
- return _this;
2921
- }
2922
- var _proto = UIPointerEventEmitter.prototype;
2923
- _proto._init = function _init() {
2924
- this._hitResult = new UIHitResult();
2925
- };
2926
- _proto.processRaycast = function processRaycast(scenes, pointer) {
2927
- var ray = engine.PointerEventEmitter._tempRay;
2928
- var hitResult = this._hitResult;
2929
- var position = pointer.position;
2930
- var x = position.x, y = position.y;
2931
- for(var i = scenes.length - 1; i >= 0; i--){
2932
- var scene = scenes[i];
2933
- if (!scene.isActive || scene.destroyed) continue;
2934
- // @ts-ignore
2935
- var componentsManager = scene._componentsManager;
2936
- // Overlay Canvas
2937
- var canvasElements = componentsManager._overlayCanvases;
2938
- // Screen to world ( Assume that world units have a one-to-one relationship with pixel units )
2939
- ray.origin.set(position.x, scene.engine.canvas.height - position.y, 1);
2940
- ray.direction.set(0, 0, -1);
2941
- for(var j = canvasElements.length - 1; j >= 0; j--){
2942
- if (canvasElements.get(j)._raycast(ray, hitResult)) {
2943
- this._updateRaycast(hitResult.component, pointer);
2944
- return;
2945
- }
2946
- }
2947
- var cameras = componentsManager._activeCameras;
2948
- for(var j1 = cameras.length - 1; j1 >= 0; j1--){
2949
- var camera = cameras.get(j1);
2950
- if (camera.renderTarget) continue;
2951
- var pixelViewport = camera.pixelViewport;
2952
- if (x < pixelViewport.x || y < pixelViewport.y || x > pixelViewport.x + pixelViewport.width || y > pixelViewport.y + pixelViewport.height) {
2953
- continue;
2954
- }
2955
- camera.screenPointToRay(pointer.position, ray);
2956
- // Other canvases
2957
- var isOrthographic = camera.isOrthographic;
2958
- var _camera_entity_transform = camera.entity.transform, cameraPosition = _camera_entity_transform.worldPosition, cameraForward = _camera_entity_transform.worldForward;
2959
- // Sort by rendering order
2960
- canvasElements = componentsManager._canvases;
2961
- for(var k = 0, n = canvasElements.length; k < n; k++){
2962
- canvasElements.get(k)._updateSortDistance(isOrthographic, cameraPosition, cameraForward);
2963
- }
2964
- canvasElements.sort(function(a, b) {
2965
- return a.sortOrder - b.sortOrder || a._sortDistance - b._sortDistance;
2966
- });
2967
- for(var k1 = 0, n1 = canvasElements.length; k1 < n1; k1++){
2968
- canvasElements.get(k1)._canvasIndex = k1;
2969
- }
2970
- var farClipPlane = camera.farClipPlane;
2971
- // Post-rendering first detection
2972
- for(var k2 = 0, n2 = canvasElements.length; k2 < n2; k2++){
2973
- var canvas = canvasElements.get(k2);
2974
- if (!canvas._canRender(camera)) continue;
2975
- if (canvas._raycast(ray, hitResult, farClipPlane)) {
2976
- this._updateRaycast(hitResult.component, pointer);
2977
- return;
2978
- }
2979
- }
2980
- if (camera.clearFlags & engine.CameraClearFlags.Color) {
2981
- this._updateRaycast(null);
2982
- return;
2983
- }
2984
- }
2985
- this._updateRaycast(null);
2986
- }
2987
- };
2988
- _proto.processDrag = function processDrag(pointer) {
2989
- var draggedPath = this._draggedPath;
2990
- if (draggedPath.length > 0) {
2991
- this._bubble(draggedPath, pointer, this._fireDrag);
2992
- }
2993
- };
2994
- _proto.processDown = function processDown(pointer) {
2995
- var enteredPath = this._enteredPath;
2996
- var pressedPath = this._pressedPath;
2997
- var draggedPath = this._draggedPath;
2998
- var length = draggedPath.length = pressedPath.length = enteredPath.length;
2999
- if (length > 0) {
3000
- for(var i = 0; i < length; i++){
3001
- pressedPath[i] = draggedPath[i] = enteredPath[i];
3002
- }
3003
- this._bubble(pressedPath, pointer, this._fireDown);
3004
- this._bubble(draggedPath, pointer, this._fireBeginDrag);
3005
- }
3006
- };
3007
- _proto.processUp = function processUp(pointer) {
3008
- var enteredPath = this._enteredPath;
3009
- var pressedPath = this._pressedPath;
3010
- if (enteredPath.length > 0) {
3011
- this._bubble(enteredPath, pointer, this._fireUp);
3012
- if (pressedPath.length > 0) {
3013
- var common = UIPointerEventEmitter._tempArray0;
3014
- if (this._findCommonInPath(enteredPath, pressedPath, common)) {
3015
- var eventData = this._createEventData(pointer);
3016
- for(var i = 0, n = common.length; i < n; i++){
3017
- this._fireClick(common[i], eventData);
3018
- }
3019
- common.length = 0;
3020
- }
3021
- }
3022
- }
3023
- pressedPath.length = 0;
3024
- var draggedPath = this._draggedPath;
3025
- if (draggedPath.length > 0) {
3026
- this._bubble(draggedPath, pointer, this._fireEndDrag);
3027
- draggedPath.length = 0;
3028
- }
3029
- if (enteredPath.length > 0) {
3030
- this._bubble(enteredPath, pointer, this._fireDrop);
3031
- }
3032
- };
3033
- _proto.processLeave = function processLeave(pointer) {
3034
- var enteredPath = this._enteredPath;
3035
- if (enteredPath.length > 0) {
3036
- this._bubble(enteredPath, pointer, this._fireExit);
3037
- enteredPath.length = 0;
3038
- }
3039
- var draggedPath = this._draggedPath;
3040
- if (draggedPath.length > 0) {
3041
- this._bubble(draggedPath, pointer, this._fireEndDrag);
3042
- draggedPath.length = 0;
3043
- }
3044
- this._pressedPath.length = 0;
3045
- };
3046
- _proto.dispose = function dispose() {
3047
- this._enteredPath.length = this._pressedPath.length = this._draggedPath.length = 0;
3048
- };
3049
- _proto._updateRaycast = function _updateRaycast(element, pointer) {
3050
- if (pointer === void 0) pointer = null;
3051
- var enteredPath = this._enteredPath;
3052
- var curPath = this._composedPath(element, UIPointerEventEmitter._path);
3053
- var add = UIPointerEventEmitter._tempArray0;
3054
- var del = UIPointerEventEmitter._tempArray1;
3055
- if (this._findDiffInPath(enteredPath, curPath, add, del)) {
3056
- var eventData = this._createEventData(pointer);
3057
- for(var i = 0, n = add.length; i < n; i++){
3058
- this._fireEnter(add[i], eventData);
3059
- }
3060
- for(var i1 = 0, n1 = del.length; i1 < n1; i1++){
3061
- this._fireExit(del[i1], eventData);
3062
- }
3063
- var length = enteredPath.length = curPath.length;
3064
- for(var i2 = 0; i2 < length; i2++){
3065
- enteredPath[i2] = curPath[i2];
3066
- }
3067
- add.length = del.length = 0;
3068
- }
3069
- curPath.length = 0;
3070
- };
3071
- _proto._composedPath = function _composedPath(element, path) {
3072
- if (!element) {
3073
- path.length = 0;
3074
- return path;
3075
- }
3076
- var entity = path[0] = element.entity;
3077
- var i = 1;
3078
- var rootEntity = element._getRootCanvas().entity;
3079
- for(; i < UIPointerEventEmitter._MAX_PATH_DEPTH && !!entity && entity !== rootEntity; i++){
3080
- entity = path[i] = entity.parent;
3081
- }
3082
- path.length = i;
3083
- return path;
3084
- };
3085
- _proto._findCommonInPath = function _findCommonInPath(prePath, curPath, common) {
3086
- var idSet = UIPointerEventEmitter._tempSet;
3087
- idSet.clear();
3088
- for(var i = 0, n = prePath.length; i < n; i++){
3089
- idSet.add(prePath[i].instanceId);
3090
- }
3091
- var hasCommon = false;
3092
- for(var i1 = 0, n1 = curPath.length; i1 < n1; i1++){
3093
- var entity = curPath[i1];
3094
- if (idSet.has(entity.instanceId)) {
3095
- common.push(entity);
3096
- hasCommon = true;
3097
- }
3098
- }
3099
- return hasCommon;
3100
- };
3101
- _proto._findDiffInPath = function _findDiffInPath(prePath, curPath, add, del) {
3102
- var idSet = UIPointerEventEmitter._tempSet;
3103
- idSet.clear();
3104
- var changed = false;
3105
- for(var i = 0, n = prePath.length; i < n; i++){
3106
- idSet.add(prePath[i].instanceId);
3107
- }
3108
- for(var i1 = 0, n1 = curPath.length; i1 < n1; i1++){
3109
- var entity = curPath[i1];
3110
- if (!idSet.has(entity.instanceId)) {
3111
- add.push(entity);
3112
- changed = true;
3113
- }
3114
- }
3115
- idSet.clear();
3116
- for(var i2 = 0, n2 = curPath.length; i2 < n2; i2++){
3117
- idSet.add(curPath[i2].instanceId);
3118
- }
3119
- for(var i3 = 0, n3 = prePath.length; i3 < n3; i3++){
3120
- var entity1 = prePath[i3];
3121
- if (!idSet.has(entity1.instanceId)) {
3122
- del.push(entity1);
3123
- changed = true;
3124
- }
3125
- }
3126
- return changed;
3127
- };
3128
- _proto._bubble = function _bubble(path, pointer, fireEvent) {
3129
- var length = path.length;
3130
- if (length <= 0) return;
3131
- var eventData = this._createEventData(pointer);
3132
- for(var i = 0; i < length; i++){
3133
- fireEvent(path[i], eventData);
3134
- }
3135
- };
3136
- return UIPointerEventEmitter;
3137
- }(engine.PointerEventEmitter);
3138
- exports.UIPointerEventEmitter._MAX_PATH_DEPTH = 2048;
3139
- exports.UIPointerEventEmitter._tempSet = new Set();
3140
- exports.UIPointerEventEmitter._path = [];
3141
- exports.UIPointerEventEmitter._tempArray0 = [];
3142
- exports.UIPointerEventEmitter._tempArray1 = [];
3143
- exports.UIPointerEventEmitter = __decorate([
3144
- engine.registerPointerEventEmitter()
3145
- ], exports.UIPointerEventEmitter);
3146
-
3147
- var EngineExtension = /*#__PURE__*/ function() {
3148
- function EngineExtension() {}
3149
- var _proto = EngineExtension.prototype;
3150
- _proto._getUIDefaultMaterial = function _getUIDefaultMaterial() {
3151
- if (!this._uiDefaultMaterial) {
3152
- var _Shader_find;
3153
- var shader = (_Shader_find = engine.Shader.find("ui")) != null ? _Shader_find : engine.Shader.create("ui", [
3154
- new engine.ShaderPass("Forward", uiDefaultVs, uiDefaultFs, {
3155
- pipelineStage: engine.PipelineStage.Forward
3156
- })
3157
- ]);
3158
- // @ts-ignore
3159
- var material = new engine.Material(this, shader);
3160
- var renderState = material.renderState;
3161
- var target = renderState.blendState.targetBlendState;
3162
- target.enabled = true;
3163
- target.sourceColorBlendFactor = engine.BlendFactor.SourceAlpha;
3164
- target.destinationColorBlendFactor = engine.BlendFactor.OneMinusSourceAlpha;
3165
- target.sourceAlphaBlendFactor = engine.BlendFactor.One;
3166
- target.destinationAlphaBlendFactor = engine.BlendFactor.OneMinusSourceAlpha;
3167
- target.colorBlendOperation = target.alphaBlendOperation = engine.BlendOperation.Add;
3168
- renderState.depthState.writeEnabled = false;
3169
- renderState.rasterState.cullMode = engine.CullMode.Off;
3170
- renderState.renderQueueType = engine.RenderQueueType.Transparent;
3171
- material.isGCIgnored = true;
3172
- this._uiDefaultMaterial = material;
3173
- }
3174
- return this._uiDefaultMaterial;
3175
- };
3176
- return EngineExtension;
3177
- }();
3178
- var EntityExtension = /*#__PURE__*/ function() {
3179
- function EntityExtension() {
3180
- this._uiHierarchyVersion = 0;
3181
- }
3182
- var _proto = EntityExtension.prototype;
3183
- _proto._updateUIHierarchyVersion = function _updateUIHierarchyVersion(version) {
3184
- if (this._uiHierarchyVersion !== version) {
3185
- var // @ts-ignore
3186
- _this_parent;
3187
- this._uiHierarchyVersion = version;
3188
- (_this_parent = this.parent) == null ? void 0 : _this_parent._updateUIHierarchyVersion(version);
3189
- }
3190
- };
3191
- return EntityExtension;
3192
- }();
3193
- function ApplyMixins(derivedCtor, baseCtors) {
3194
- baseCtors.forEach(function(baseCtor) {
3195
- Object.getOwnPropertyNames(baseCtor.prototype).forEach(function(name) {
3196
- Object.defineProperty(derivedCtor.prototype, name, Object.getOwnPropertyDescriptor(baseCtor.prototype, name) || Object.create(null));
3197
- });
3198
- });
3199
- }
3200
- ApplyMixins(engine.Engine, [
3201
- EngineExtension
3202
- ]);
3203
- ApplyMixins(engine.Entity, [
3204
- EntityExtension
3205
- ]);
3206
- engine.ReflectionParser.registerCustomParseComponent("Text", /*#__PURE__*/ _async_to_generator(function(instance, item) {
3207
- var props;
3208
- return __generator(this, function(_state) {
3209
- props = item.props;
3210
- if (!props.font) {
3211
- // @ts-ignore
3212
- instance.font = engine.Font.createFromOS(instance.engine, props.fontFamily || "Arial");
3213
- }
3214
- return [
3215
- 2,
3216
- instance
3217
- ];
3218
- });
3219
- }));
3220
- /**
3221
- * Register GUI components for the editor.
3222
- */ function registerGUI() {
3223
- for(var key in GUIComponent){
3224
- engine.Loader.registerClass(key, GUIComponent[key]);
3225
- }
3226
- }
3227
-
3228
- exports.Button = Button;
3229
- exports.CanvasRenderMode = CanvasRenderMode;
3230
- exports.ColorTransition = ColorTransition;
3231
- exports.EngineExtension = EngineExtension;
3232
- exports.EntityExtension = EntityExtension;
3233
- exports.Image = Image;
3234
- exports.ResolutionAdaptationMode = ResolutionAdaptationMode;
3235
- exports.ScaleTransition = ScaleTransition;
3236
- exports.SpriteTransition = SpriteTransition;
3237
- exports.Text = Text;
3238
- exports.Transition = Transition;
3239
- exports.UIGroup = UIGroup;
3240
- exports.UITransform = UITransform;
3241
- exports.registerGUI = registerGUI;
3242
- //# sourceMappingURL=main.js.map