@galacean/engine-ui 0.0.0-experimental-2.0-migrate.6 → 0.0.0-experimental-2.0-migrate.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Matrix, BoundingBox, Utils as Utils$1, Vector2, Rect, TransformModifyFlags, Transform, ignoreClone, MathUtil, Vector4, Vector3, dependentComponents, DependentMode, Component, DisorderedArray, EntityModifyFlags, Plane, ShaderProperty, Color, RendererUpdateFlags, VertexMergeBatcher, ShaderMacroCollection, SpriteMaskInteraction, Renderer, CameraModifyFlags, Logger, Ray, Script, Signal, SpriteTileMode, SpriteFilledMode, SpriteFilledOrigin, SpriteDrawMode, SpriteModifyFlags, FilledSpriteAssembler, TiledSpriteAssembler, SlicedSpriteAssembler, SimpleSpriteAssembler, MaskRenderable, FontStyle, TextHorizontalAlignment, TextVerticalAlignment, OverflowMode, ShaderData, ShaderDataGroup, TextUtils, Engine, CharRenderInfo, DataObject, ReferResource, registerPointerEventEmitter, PointerEventEmitter, CameraClearFlags, Material, Entity, Loader, Shader } from '@galacean/engine';
1
+ import { Matrix, BoundingBox, Utils as Utils$1, ignoreClone, Vector2, Rect, TransformModifyFlags, Transform, MathUtil, dependentComponents, DependentMode, Vector4, Vector3, Component, DisorderedArray, EntityModifyFlags, Plane, ShaderProperty, Color, RendererUpdateFlags, VertexMergeBatcher, ShaderMacroCollection, SpriteMaskInteraction, Renderer, CameraModifyFlags, Logger, Ray, Script, Signal, SpriteTileMode, SpriteFilledMode, SpriteFilledOrigin, SpriteDrawMode, SpriteModifyFlags, FilledSpriteAssembler, TiledSpriteAssembler, SlicedSpriteAssembler, SimpleSpriteAssembler, MaskRenderable, FontStyle, TextHorizontalAlignment, TextVerticalAlignment, OverflowMode, ShaderData, ShaderDataGroup, TextUtils, Engine, CharRenderInfo, DataObject, ReferResource, registerPointerEventEmitter, PointerEventEmitter, CameraClearFlags, Material, Entity, Loader, Shader } from '@galacean/engine';
2
2
 
3
3
  function _set_prototype_of(o, p) {
4
4
  _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
@@ -38,32 +38,552 @@ function _create_class(Constructor, protoProps, staticProps) {
38
38
  return Constructor;
39
39
  }
40
40
 
41
- /******************************************************************************
42
- Copyright (c) Microsoft Corporation.
43
-
44
- Permission to use, copy, modify, and/or distribute this software for any
45
- purpose with or without fee is hereby granted.
46
-
47
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
48
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
49
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
50
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
51
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
52
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
53
- PERFORMANCE OF THIS SOFTWARE.
54
- ***************************************************************************** */
55
-
56
- function __decorate(decorators, target, key, desc) {
57
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
58
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
59
- 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;
60
- return c > 3 && r && Object.defineProperty(target, key, r), r;
61
- }
41
+ /* @minVersion 7.20.0 */
62
42
 
63
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
64
- var e = new Error(message);
65
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
66
- };
43
+ /**
44
+ Enums are used in this file, but not assigned to vars to avoid non-hoistable values
45
+
46
+ CONSTRUCTOR = 0;
47
+ PUBLIC = 1;
48
+ PRIVATE = 2;
49
+
50
+ FIELD = 0;
51
+ ACCESSOR = 1;
52
+ METHOD = 2;
53
+ GETTER = 3;
54
+ SETTER = 4;
55
+
56
+ STATIC = 5;
57
+
58
+ CLASS = 10; // only used in assertValidReturnValue
59
+ */
60
+
61
+ function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
62
+ function createAddInitializerMethod(initializers, decoratorFinishedRef) {
63
+ return function addInitializer(initializer) {
64
+ assertNotFinished(decoratorFinishedRef, "addInitializer");
65
+ assertCallable(initializer, "An initializer");
66
+ initializers.push(initializer);
67
+ };
68
+ }
69
+
70
+ function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
71
+ var kindStr;
72
+
73
+ switch (kind) {
74
+ case 1 /* ACCESSOR */:
75
+ kindStr = "accessor";
76
+ break;
77
+ case 2 /* METHOD */:
78
+ kindStr = "method";
79
+ break;
80
+ case 3 /* GETTER */:
81
+ kindStr = "getter";
82
+ break;
83
+ case 4 /* SETTER */:
84
+ kindStr = "setter";
85
+ break;
86
+ default:
87
+ kindStr = "field";
88
+ }
89
+
90
+ var ctx = { kind: kindStr, name: isPrivate ? "#" + name : name, static: isStatic, private: isPrivate, metadata: metadata };
91
+
92
+ var decoratorFinishedRef = { v: false };
93
+
94
+ ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
95
+
96
+ var get, set;
97
+ if (kind === 0 /* FIELD */) {
98
+ if (isPrivate) {
99
+ get = desc.get;
100
+ set = desc.set;
101
+ } else {
102
+ get = function() {
103
+ return this[name];
104
+ };
105
+ set = function(v) {
106
+ this[name] = v;
107
+ };
108
+ }
109
+ } else if (kind === 2 /* METHOD */) {
110
+ get = function() {
111
+ return desc.value;
112
+ };
113
+ } else {
114
+ // replace with values that will go through the final getter and setter
115
+ if (kind === 1 /* ACCESSOR */ || kind === 3 /* GETTER */) {
116
+ get = function() {
117
+ return desc.get.call(this);
118
+ };
119
+ }
120
+
121
+ if (kind === 1 /* ACCESSOR */ || kind === 4 /* SETTER */) {
122
+ set = function(v) {
123
+ desc.set.call(this, v);
124
+ };
125
+ }
126
+ }
127
+ ctx.access = get && set ? { get: get, set: set } : get ? { get: get } : { set: set };
128
+
129
+ try {
130
+ return dec(value, ctx);
131
+ } finally {
132
+ decoratorFinishedRef.v = true;
133
+ }
134
+ }
135
+
136
+ function assertNotFinished(decoratorFinishedRef, fnName) {
137
+ if (decoratorFinishedRef.v) {
138
+ throw new Error("attempted to call " + fnName + " after decoration was finished");
139
+ }
140
+ }
141
+
142
+ function assertCallable(fn, hint) {
143
+ if (typeof fn !== "function") {
144
+ throw new TypeError(hint + " must be a function");
145
+ }
146
+ }
147
+
148
+ function assertValidReturnValue(kind, value) {
149
+ var type = typeof value;
150
+
151
+ if (kind === 1 /* ACCESSOR */) {
152
+ if (type !== "object" || value === null) {
153
+ throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
154
+ }
155
+ if (value.get !== undefined) {
156
+ assertCallable(value.get, "accessor.get");
157
+ }
158
+ if (value.set !== undefined) {
159
+ assertCallable(value.set, "accessor.set");
160
+ }
161
+ if (value.init !== undefined) {
162
+ assertCallable(value.init, "accessor.init");
163
+ }
164
+ } else if (type !== "function") {
165
+ var hint;
166
+ if (kind === 0 /* FIELD */) {
167
+ hint = "field";
168
+ } else if (kind === 10 /* CLASS */) {
169
+ hint = "class";
170
+ } else {
171
+ hint = "method";
172
+ }
173
+ throw new TypeError(hint + " decorators must return a function or void 0");
174
+ }
175
+ }
176
+
177
+ function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
178
+ var decs = decInfo[0];
179
+
180
+ var desc, init, value;
181
+
182
+ if (isPrivate) {
183
+ if (kind === 0 /* FIELD */ || kind === 1 /* ACCESSOR */) {
184
+ desc = { get: decInfo[3], set: decInfo[4] };
185
+ } else if (kind === 3 /* GETTER */) {
186
+ desc = { get: decInfo[3] };
187
+ } else if (kind === 4 /* SETTER */) {
188
+ desc = { set: decInfo[3] };
189
+ } else {
190
+ desc = { value: decInfo[3] };
191
+ }
192
+ } else if (kind !== 0 /* FIELD */) {
193
+ desc = Object.getOwnPropertyDescriptor(base, name);
194
+ }
195
+
196
+ if (kind === 1 /* ACCESSOR */) {
197
+ value = { get: desc.get, set: desc.set };
198
+ } else if (kind === 2 /* METHOD */) {
199
+ value = desc.value;
200
+ } else if (kind === 3 /* GETTER */) {
201
+ value = desc.get;
202
+ } else if (kind === 4 /* SETTER */) {
203
+ value = desc.set;
204
+ }
205
+
206
+ var newValue, get, set;
207
+
208
+ if (typeof decs === "function") {
209
+ newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
210
+
211
+ if (newValue !== void 0) {
212
+ assertValidReturnValue(kind, newValue);
213
+
214
+ if (kind === 0 /* FIELD */) {
215
+ init = newValue;
216
+ } else if (kind === 1 /* ACCESSOR */) {
217
+ init = newValue.init;
218
+ get = newValue.get || value.get;
219
+ set = newValue.set || value.set;
220
+
221
+ value = { get: get, set: set };
222
+ } else {
223
+ value = newValue;
224
+ }
225
+ }
226
+ } else {
227
+ for (var i = decs.length - 1; i >= 0; i--) {
228
+ var dec = decs[i];
229
+
230
+ newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
231
+
232
+ if (newValue !== void 0) {
233
+ assertValidReturnValue(kind, newValue);
234
+ var newInit;
235
+
236
+ if (kind === 0 /* FIELD */) {
237
+ newInit = newValue;
238
+ } else if (kind === 1 /* ACCESSOR */) {
239
+ newInit = newValue.init;
240
+ get = newValue.get || value.get;
241
+ set = newValue.set || value.set;
242
+
243
+ value = { get: get, set: set };
244
+ } else {
245
+ value = newValue;
246
+ }
247
+
248
+ if (newInit !== void 0) {
249
+ if (init === void 0) {
250
+ init = newInit;
251
+ } else if (typeof init === "function") {
252
+ init = [init, newInit];
253
+ } else {
254
+ init.push(newInit);
255
+ }
256
+ }
257
+ }
258
+ }
259
+ }
260
+
261
+ if (kind === 0 /* FIELD */ || kind === 1 /* ACCESSOR */) {
262
+ if (init === void 0) {
263
+ // If the initializer was void 0, sub in a dummy initializer
264
+ init = function(instance, init) {
265
+ return init;
266
+ };
267
+ } else if (typeof init !== "function") {
268
+ var ownInitializers = init;
269
+
270
+ init = function(instance, init) {
271
+ var value = init;
272
+
273
+ for (var i = 0; i < ownInitializers.length; i++) value = ownInitializers[i].call(instance, value);
274
+
275
+ return value;
276
+ };
277
+ } else {
278
+ var originalInitializer = init;
279
+
280
+ init = function(instance, init) {
281
+ return originalInitializer.call(instance, init);
282
+ };
283
+ }
284
+
285
+ ret.push(init);
286
+ }
287
+
288
+ if (kind !== 0 /* FIELD */) {
289
+ if (kind === 1 /* ACCESSOR */) {
290
+ desc.get = value.get;
291
+ desc.set = value.set;
292
+ } else if (kind === 2 /* METHOD */) {
293
+ desc.value = value;
294
+ } else if (kind === 3 /* GETTER */) {
295
+ desc.get = value;
296
+ } else if (kind === 4 /* SETTER */) {
297
+ desc.set = value;
298
+ }
299
+
300
+ if (isPrivate) {
301
+ if (kind === 1 /* ACCESSOR */) {
302
+ ret.push(function(instance, args) {
303
+ return value.get.call(instance, args);
304
+ });
305
+ ret.push(function(instance, args) {
306
+ return value.set.call(instance, args);
307
+ });
308
+ } else if (kind === 2 /* METHOD */) {
309
+ ret.push(value);
310
+ } else {
311
+ ret.push(function(instance, args) {
312
+ return value.call(instance, args);
313
+ });
314
+ }
315
+ } else {
316
+ Object.defineProperty(base, name, desc);
317
+ }
318
+ }
319
+ }
320
+
321
+ function applyMemberDecs(Class, decInfos, metadata) {
322
+ var ret = [];
323
+ var protoInitializers;
324
+ var staticInitializers;
325
+
326
+ var existingProtoNonFields = new Map();
327
+ var existingStaticNonFields = new Map();
328
+
329
+ for (var i = 0; i < decInfos.length; i++) {
330
+ var decInfo = decInfos[i];
331
+
332
+ // skip computed property names
333
+ if (!Array.isArray(decInfo)) continue;
334
+
335
+ var kind = decInfo[1];
336
+ var name = decInfo[2];
337
+ var isPrivate = decInfo.length > 3;
338
+
339
+ var isStatic = kind >= 5; /* STATIC */
340
+ var base;
341
+ var initializers;
342
+
343
+ if (isStatic) {
344
+ base = Class;
345
+ kind = kind - 5 /* STATIC */;
346
+ // initialize staticInitializers when we see a non-field static member
347
+ staticInitializers = staticInitializers || [];
348
+ initializers = staticInitializers;
349
+ } else {
350
+ base = Class.prototype;
351
+ // initialize protoInitializers when we see a non-field member
352
+ protoInitializers = protoInitializers || [];
353
+ initializers = protoInitializers;
354
+ }
355
+
356
+ if (kind !== 0 /* FIELD */ && !isPrivate) {
357
+ var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
358
+
359
+ var existingKind = existingNonFields.get(name) || 0;
360
+
361
+ if (existingKind === true || (existingKind === 3 /* GETTER */ && kind !== 4) /* SETTER */ || (existingKind === 4 /* SETTER */ && kind !== 3) /* GETTER */) {
362
+ throw new Error(
363
+ "Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: "
364
+ + name
365
+ );
366
+ } else if (!existingKind && kind > 2 /* METHOD */) {
367
+ existingNonFields.set(name, kind);
368
+ } else {
369
+ existingNonFields.set(name, true);
370
+ }
371
+ }
372
+
373
+ applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
374
+ }
375
+
376
+ pushInitializers(ret, protoInitializers);
377
+ pushInitializers(ret, staticInitializers);
378
+ return ret;
379
+ }
380
+
381
+ function pushInitializers(ret, initializers) {
382
+ if (initializers) {
383
+ ret.push(function(instance) {
384
+ for (var i = 0; i < initializers.length; i++) initializers[i].call(instance);
385
+ return instance;
386
+ });
387
+ }
388
+ }
389
+
390
+ function applyClassDecs(targetClass, classDecs, metadata) {
391
+ if (classDecs.length > 0) {
392
+ var initializers = [];
393
+ var newClass = targetClass;
394
+ var name = targetClass.name;
395
+
396
+ for (var i = classDecs.length - 1; i >= 0; i--) {
397
+ var decoratorFinishedRef = { v: false };
398
+
399
+ try {
400
+ var nextNewClass = classDecs[i](newClass, { kind: "class", name: name, addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef), metadata });
401
+ } finally {
402
+ decoratorFinishedRef.v = true;
403
+ }
404
+
405
+ if (nextNewClass !== undefined) {
406
+ assertValidReturnValue(10, /* CLASS */ nextNewClass);
407
+ newClass = nextNewClass;
408
+ }
409
+ }
410
+
411
+ return [defineMetadata(newClass, metadata), function() {
412
+ for (var i = 0; i < initializers.length; i++) initializers[i].call(newClass);
413
+ }];
414
+ }
415
+ // The transformer will not emit assignment when there are no class decorators,
416
+ // so we don't have to return an empty array here.
417
+ }
418
+
419
+ function defineMetadata(Class, metadata) {
420
+ return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: true, enumerable: true, value: metadata });
421
+ }
422
+
423
+ /**
424
+ Basic usage:
425
+
426
+ applyDecs(
427
+ Class,
428
+ [
429
+ // member decorators
430
+ [
431
+ dec, // dec or array of decs
432
+ 0, // kind of value being decorated
433
+ 'prop', // name of public prop on class containing the value being decorated,
434
+ '#p', // the name of the private property (if is private, void 0 otherwise),
435
+ ]
436
+ ],
437
+ [
438
+ // class decorators
439
+ dec1, dec2
440
+ ]
441
+ )
442
+ ```
443
+
444
+ Fully transpiled example:
445
+
446
+ ```js
447
+ @dec
448
+ class Class {
449
+ @dec
450
+ a = 123;
451
+
452
+ @dec
453
+ #a = 123;
454
+
455
+ @dec
456
+ @dec2
457
+ accessor b = 123;
458
+
459
+ @dec
460
+ accessor #b = 123;
461
+
462
+ @dec
463
+ c() { console.log('c'); }
464
+
465
+ @dec
466
+ #c() { console.log('privC'); }
467
+
468
+ @dec
469
+ get d() { console.log('d'); }
470
+
471
+ @dec
472
+ get #d() { console.log('privD'); }
473
+
474
+ @dec
475
+ set e(v) { console.log('e'); }
476
+
477
+ @dec
478
+ set #e(v) { console.log('privE'); }
479
+ }
480
+
481
+
482
+ // becomes
483
+ let initializeInstance;
484
+ let initializeClass;
485
+
486
+ let initA;
487
+ let initPrivA;
488
+
489
+ let initB;
490
+ let initPrivB, getPrivB, setPrivB;
491
+
492
+ let privC;
493
+ let privD;
494
+ let privE;
495
+
496
+ let Class;
497
+ class _Class {
498
+ static {
499
+ let ret = applyDecs(
500
+ this,
501
+ [
502
+ [dec, 0, 'a'],
503
+ [dec, 0, 'a', (i) => i.#a, (i, v) => i.#a = v],
504
+ [[dec, dec2], 1, 'b'],
505
+ [dec, 1, 'b', (i) => i.#privBData, (i, v) => i.#privBData = v],
506
+ [dec, 2, 'c'],
507
+ [dec, 2, 'c', () => console.log('privC')],
508
+ [dec, 3, 'd'],
509
+ [dec, 3, 'd', () => console.log('privD')],
510
+ [dec, 4, 'e'],
511
+ [dec, 4, 'e', () => console.log('privE')],
512
+ ],
513
+ [
514
+ dec
515
+ ]
516
+ )
517
+
518
+ initA = ret[0];
519
+
520
+ initPrivA = ret[1];
521
+
522
+ initB = ret[2];
523
+
524
+ initPrivB = ret[3];
525
+ getPrivB = ret[4];
526
+ setPrivB = ret[5];
527
+
528
+ privC = ret[6];
529
+
530
+ privD = ret[7];
531
+
532
+ privE = ret[8];
533
+
534
+ initializeInstance = ret[9];
535
+
536
+ Class = ret[10]
537
+
538
+ initializeClass = ret[11];
539
+ }
540
+
541
+ a = (initializeInstance(this), initA(this, 123));
542
+
543
+ #a = initPrivA(this, 123);
544
+
545
+ #bData = initB(this, 123);
546
+ get b() { return this.#bData }
547
+ set b(v) { this.#bData = v }
548
+
549
+ #privBData = initPrivB(this, 123);
550
+ get #b() { return getPrivB(this); }
551
+ set #b(v) { setPrivB(this, v); }
552
+
553
+ c() { console.log('c'); }
554
+
555
+ #c(...args) { return privC(this, ...args) }
556
+
557
+ get d() { console.log('d'); }
558
+
559
+ get #d() { return privD(this); }
560
+
561
+ set e(v) { console.log('e'); }
562
+
563
+ set #e(v) { privE(this, v); }
564
+ }
565
+
566
+ initializeClass(Class);
567
+ */
568
+
569
+ _apply_decs_2203_r = function(targetClass, memberDecs, classDecs, parentClass) {
570
+ if (parentClass !== void 0) {
571
+ var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
572
+ }
573
+ var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
574
+ var e = applyMemberDecs(targetClass, memberDecs, metadata);
575
+ if (!classDecs.length) defineMetadata(targetClass, metadata);
576
+ return {
577
+ e: e,
578
+ // Lazily apply class decorations so that member init locals can be properly bound.
579
+ get c() {
580
+ return applyClassDecs(targetClass, classDecs, metadata);
581
+ }
582
+ };
583
+ };
584
+
585
+ return _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass);
586
+ }
67
587
 
68
588
  function _instanceof(left, right) {
69
589
  if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
@@ -71,6 +591,10 @@ function _instanceof(left, right) {
71
591
  } else return left instanceof right;
72
592
  }
73
593
 
594
+ function _identity(x) {
595
+ return x;
596
+ }
597
+
74
598
  /**
75
599
  * @internal
76
600
  * Visual-layering driven UI batching: solve visual correctness first, batching falls out for free.
@@ -270,13 +794,14 @@ var SortEntry = function SortEntry() {
270
794
  return VerticalAlignmentMode;
271
795
  }({});
272
796
 
797
+ var _init__size, _init__pivot;
273
798
  /**
274
799
  * The Transform component exclusive to the UI element.
275
800
  */ var UITransform = /*#__PURE__*/ function(Transform) {
276
801
  _inherits(UITransform, Transform);
277
802
  function UITransform(entity) {
278
803
  var _this;
279
- _this = Transform.call(this, entity) || this, _this._size = new Vector2(100, 100), _this._pivot = new Vector2(0.5, 0.5), _this._rect = new Rect(-50, -50, 100, 100), _this._alignLeft = 0, _this._alignRight = 0, _this._alignCenter = 0, _this._alignTop = 0, _this._alignBottom = 0, _this._alignMiddle = 0, _this._horizontalAlignment = HorizontalAlignmentMode.None, _this._verticalAlignment = VerticalAlignmentMode.None;
804
+ _this = Transform.call(this, entity) || this, _this._size = _init__size(_this, new Vector2(100, 100)), _this._pivot = _init__pivot(_this, new Vector2(0.5, 0.5)), _this._rect = new Rect(-50, -50, 100, 100), _this._alignLeft = 0, _this._alignRight = 0, _this._alignCenter = 0, _this._alignTop = 0, _this._alignBottom = 0, _this._alignMiddle = 0, _this._horizontalAlignment = HorizontalAlignmentMode.None, _this._verticalAlignment = VerticalAlignmentMode.None;
280
805
  _this._onSizeChanged = _this._onSizeChanged.bind(_this);
281
806
  _this._onPivotChanged = _this._onPivotChanged.bind(_this);
282
807
  // @ts-ignore
@@ -650,24 +1175,19 @@ var SortEntry = function SortEntry() {
650
1175
  ]);
651
1176
  return UITransform;
652
1177
  }(Transform);
653
- __decorate([
654
- ignoreClone
655
- ], UITransform.prototype, "_size", void 0);
656
- __decorate([
657
- ignoreClone
658
- ], UITransform.prototype, "_pivot", void 0);
659
- __decorate([
660
- ignoreClone
661
- ], UITransform.prototype, "_onPositionChanged", null);
662
- __decorate([
663
- ignoreClone
664
- ], UITransform.prototype, "_onWorldPositionChanged", null);
665
- __decorate([
666
- ignoreClone
667
- ], UITransform.prototype, "_onSizeChanged", null);
668
- __decorate([
669
- ignoreClone
670
- ], UITransform.prototype, "_onPivotChanged", null);
1178
+ var ref$5, ref1$5;
1179
+ ref$5 = _apply_decs_2203_r(UITransform, [
1180
+ [
1181
+ ignoreClone,
1182
+ 0,
1183
+ "_size"
1184
+ ],
1185
+ [
1186
+ ignoreClone,
1187
+ 0,
1188
+ "_pivot"
1189
+ ]
1190
+ ], []), ref1$5 = ref$5.e, _init__size = ref1$5[0], _init__pivot = ref1$5[1];
671
1191
  /**
672
1192
  * @internal
673
1193
  * extends TransformModifyFlags
@@ -677,139 +1197,155 @@ __decorate([
677
1197
  return UITransformModifyFlags;
678
1198
  }({});
679
1199
 
680
- var RectMask2D = /*#__PURE__*/ function(Component) {
681
- _inherits(RectMask2D, Component);
682
- function RectMask2D(entity) {
1200
+ var _class$3;
1201
+ var _dec$3, _initClass$3, _Component$1;
1202
+ var _RectMask2D;
1203
+ _dec$3 = dependentComponents(UITransform, DependentMode.AutoAdd);
1204
+ new (_class$3 = /*#__PURE__*/ function(_identity) {
1205
+ _inherits(_class, _identity);
1206
+ function _class() {
683
1207
  var _this;
684
- _this = Component.call(this, entity) || this, _this._softness = new Vector2(0, 0), _this._alphaClip = false;
685
- _this._onSoftnessChanged = _this._onSoftnessChanged.bind(_this);
686
- // @ts-ignore
687
- _this._softness._onValueChanged = _this._onSoftnessChanged;
1208
+ _this = _identity.apply(this, arguments) || this, _initClass$3();
688
1209
  return _this;
689
1210
  }
690
- var _proto = RectMask2D.prototype;
691
- /**
1211
+ return _class;
1212
+ }(_identity), function() {
1213
+ var RectMask2D = /*#__PURE__*/ function(_superClass) {
1214
+ _inherits(RectMask2D, _superClass);
1215
+ function RectMask2D(entity) {
1216
+ var _this;
1217
+ _this = _superClass.call(this, entity) || this, _this._softness = new Vector2(0, 0), _this._alphaClip = false;
1218
+ _this._onSoftnessChanged = _this._onSoftnessChanged.bind(_this);
1219
+ // @ts-ignore
1220
+ _this._softness._onValueChanged = _this._onSoftnessChanged;
1221
+ return _this;
1222
+ }
1223
+ var _proto = RectMask2D.prototype;
1224
+ /**
692
1225
  * @internal
693
1226
  */ _proto._getWorldRect = function _getWorldRect(out) {
694
- var transform = this.entity.transform;
695
- var _transform_size = transform.size, width = _transform_size.x, height = _transform_size.y;
696
- if (!width || !height) {
697
- return false;
698
- }
699
- var _transform_pivot = transform.pivot, pivotX = _transform_pivot.x, pivotY = _transform_pivot.y;
700
- var left = -width * pivotX;
701
- var right = width * (1 - pivotX);
702
- var bottom = -height * pivotY;
703
- var top = height * (1 - pivotY);
704
- var worldMatrix = transform.worldMatrix;
705
- var corner0 = RectMask2D._tempCorner0;
706
- var corner1 = RectMask2D._tempCorner1;
707
- var corner2 = RectMask2D._tempCorner2;
708
- var corner3 = RectMask2D._tempCorner3;
709
- Vector3.transformCoordinate(corner0.set(left, bottom, 0), worldMatrix, corner0);
710
- Vector3.transformCoordinate(corner1.set(left, top, 0), worldMatrix, corner1);
711
- Vector3.transformCoordinate(corner2.set(right, bottom, 0), worldMatrix, corner2);
712
- Vector3.transformCoordinate(corner3.set(right, top, 0), worldMatrix, corner3);
713
- var minX = Math.min(corner0.x, corner1.x, corner2.x, corner3.x);
714
- var minY = Math.min(corner0.y, corner1.y, corner2.y, corner3.y);
715
- var maxX = Math.max(corner0.x, corner1.x, corner2.x, corner3.x);
716
- var maxY = Math.max(corner0.y, corner1.y, corner2.y, corner3.y);
717
- out.set(minX, minY, maxX, maxY);
718
- return true;
719
- };
720
- /**
1227
+ var transform = this.entity.transform;
1228
+ var _transform_size = transform.size, width = _transform_size.x, height = _transform_size.y;
1229
+ if (!width || !height) {
1230
+ return false;
1231
+ }
1232
+ var _transform_pivot = transform.pivot, pivotX = _transform_pivot.x, pivotY = _transform_pivot.y;
1233
+ var left = -width * pivotX;
1234
+ var right = width * (1 - pivotX);
1235
+ var bottom = -height * pivotY;
1236
+ var top = height * (1 - pivotY);
1237
+ var worldMatrix = transform.worldMatrix;
1238
+ var corner0 = RectMask2D._tempCorner0;
1239
+ var corner1 = RectMask2D._tempCorner1;
1240
+ var corner2 = RectMask2D._tempCorner2;
1241
+ var corner3 = RectMask2D._tempCorner3;
1242
+ Vector3.transformCoordinate(corner0.set(left, bottom, 0), worldMatrix, corner0);
1243
+ Vector3.transformCoordinate(corner1.set(left, top, 0), worldMatrix, corner1);
1244
+ Vector3.transformCoordinate(corner2.set(right, bottom, 0), worldMatrix, corner2);
1245
+ Vector3.transformCoordinate(corner3.set(right, top, 0), worldMatrix, corner3);
1246
+ var minX = Math.min(corner0.x, corner1.x, corner2.x, corner3.x);
1247
+ var minY = Math.min(corner0.y, corner1.y, corner2.y, corner3.y);
1248
+ var maxX = Math.max(corner0.x, corner1.x, corner2.x, corner3.x);
1249
+ var maxY = Math.max(corner0.y, corner1.y, corner2.y, corner3.y);
1250
+ out.set(minX, minY, maxX, maxY);
1251
+ return true;
1252
+ };
1253
+ /**
721
1254
  * @internal
722
1255
  */ _proto._containsWorldPoint = function _containsWorldPoint(worldPoint) {
723
- var worldRect = RectMask2D._tempRect;
724
- if (!this._getWorldRect(worldRect)) {
725
- return false;
726
- }
727
- var x = worldPoint.x, y = worldPoint.y;
728
- return x >= worldRect.x && x <= worldRect.z && y >= worldRect.y && y <= worldRect.w;
729
- };
730
- // @ts-ignore
731
- _proto._onEnableInScene = function _onEnableInScene() {
732
- this.entity._updateUIHierarchyVersion(UICanvas._hierarchyCounter);
733
- };
734
- // @ts-ignore
735
- _proto._onDisableInScene = function _onDisableInScene() {
736
- this.entity._updateUIHierarchyVersion(UICanvas._hierarchyCounter);
737
- };
738
- _proto._onClone = function _onClone(target) {
739
- // RectMask2D extends Component directly, so it has no parent clone hook to call.
740
- var targetSoftness = target._softness;
741
- // @ts-ignore
742
- targetSoftness._onValueChanged = null;
743
- targetSoftness.copyFrom(this._softness);
744
- target._clampSoftness();
1256
+ var worldRect = RectMask2D._tempRect;
1257
+ if (!this._getWorldRect(worldRect)) {
1258
+ return false;
1259
+ }
1260
+ var x = worldPoint.x, y = worldPoint.y;
1261
+ return x >= worldRect.x && x <= worldRect.z && y >= worldRect.y && y <= worldRect.w;
1262
+ };
745
1263
  // @ts-ignore
746
- targetSoftness._onValueChanged = target._onSoftnessChanged;
747
- };
748
- _proto._onDestroy = function _onDestroy() {
1264
+ _proto._onEnableInScene = function _onEnableInScene() {
1265
+ this.entity._updateUIHierarchyVersion(_UICanvas._hierarchyCounter);
1266
+ };
749
1267
  // @ts-ignore
750
- this._softness._onValueChanged = null;
751
- this._softness = null;
752
- Component.prototype._onDestroy.call(this);
753
- };
754
- _proto._onSoftnessChanged = function _onSoftnessChanged() {
755
- this._clampSoftness();
756
- };
757
- _proto._clampSoftness = function _clampSoftness() {
758
- var softness = this._softness;
759
- if (softness.x < 0) {
760
- softness.x = 0;
761
- }
762
- if (softness.y < 0) {
763
- softness.y = 0;
764
- }
765
- };
766
- _create_class(RectMask2D, [
767
- {
768
- key: "softness",
769
- get: /**
1268
+ _proto._onDisableInScene = function _onDisableInScene() {
1269
+ this.entity._updateUIHierarchyVersion(_UICanvas._hierarchyCounter);
1270
+ };
1271
+ _proto._onClone = function _onClone(target) {
1272
+ // RectMask2D extends Component directly, so it has no parent clone hook to call.
1273
+ var targetSoftness = target._softness;
1274
+ // @ts-ignore
1275
+ targetSoftness._onValueChanged = null;
1276
+ targetSoftness.copyFrom(this._softness);
1277
+ target._clampSoftness();
1278
+ // @ts-ignore
1279
+ targetSoftness._onValueChanged = target._onSoftnessChanged;
1280
+ };
1281
+ _proto._onDestroy = function _onDestroy() {
1282
+ // @ts-ignore
1283
+ this._softness._onValueChanged = null;
1284
+ this._softness = null;
1285
+ _superClass.prototype._onDestroy.call(this);
1286
+ };
1287
+ _proto._onSoftnessChanged = function _onSoftnessChanged() {
1288
+ this._clampSoftness();
1289
+ };
1290
+ _proto._clampSoftness = function _clampSoftness() {
1291
+ var softness = this._softness;
1292
+ if (softness.x < 0) {
1293
+ softness.x = 0;
1294
+ }
1295
+ if (softness.y < 0) {
1296
+ softness.y = 0;
1297
+ }
1298
+ };
1299
+ _create_class(RectMask2D, [
1300
+ {
1301
+ key: "softness",
1302
+ get: /**
770
1303
  * Soft clipping width on X/Y axis in world space.
771
1304
  */ function get() {
772
- return this._softness;
773
- },
774
- set: function set(value) {
775
- var softness = this._softness;
776
- if (softness === value) {
777
- return;
778
- }
779
- if (softness.x !== value.x || softness.y !== value.y) {
780
- softness.copyFrom(value);
781
- this._clampSoftness();
1305
+ return this._softness;
1306
+ },
1307
+ set: function set(value) {
1308
+ var softness = this._softness;
1309
+ if (softness === value) {
1310
+ return;
1311
+ }
1312
+ if (softness.x !== value.x || softness.y !== value.y) {
1313
+ softness.copyFrom(value);
1314
+ this._clampSoftness();
1315
+ }
782
1316
  }
783
- }
784
- },
785
- {
786
- key: "alphaClip",
787
- get: /**
1317
+ },
1318
+ {
1319
+ key: "alphaClip",
1320
+ get: /**
788
1321
  * Whether to enable hard clip (discard) when outside the rect.
789
1322
  */ function get() {
790
- return this._alphaClip;
791
- },
792
- set: function set(value) {
793
- this._alphaClip = value;
1323
+ return this._alphaClip;
1324
+ },
1325
+ set: function set(value) {
1326
+ this._alphaClip = value;
1327
+ }
794
1328
  }
795
- }
796
- ]);
797
- return RectMask2D;
798
- }(Component);
799
- RectMask2D._tempRect = new Vector4();
800
- RectMask2D._tempCorner0 = new Vector3();
801
- RectMask2D._tempCorner1 = new Vector3();
802
- RectMask2D._tempCorner2 = new Vector3();
803
- RectMask2D._tempCorner3 = new Vector3();
804
- RectMask2D = __decorate([
805
- dependentComponents(UITransform, DependentMode.AutoAdd)
806
- ], RectMask2D);
1329
+ ]);
1330
+ return RectMask2D;
1331
+ }(_Component$1 = Component);
1332
+ var ref, ref1;
1333
+ ref = _apply_decs_2203_r(RectMask2D, [], [
1334
+ _dec$3
1335
+ ], _Component$1), ref1 = ref.c, _RectMask2D = ref1[0], _initClass$3 = ref1[1];
1336
+ RectMask2D._tempRect = new Vector4();
1337
+ RectMask2D._tempCorner0 = new Vector3();
1338
+ RectMask2D._tempCorner1 = new Vector3();
1339
+ RectMask2D._tempCorner2 = new Vector3();
1340
+ RectMask2D._tempCorner3 = new Vector3();
1341
+ }(), _class$3)();
807
1342
 
1343
+ var /** @internal */ _init__indexInGroup$2, /** @internal */ _init__indexInRootCanvas$3, /** @internal */ _init__globalAlpha, /** @internal */ _init__globalInteractive$1, /** @internal */ _init__rootCanvasListeningEntities$3, /** @internal */ _init__groupListeningEntities$2, /** @internal */ _init__isRootCanvasDirty$3, /** @internal */ _init__isGroupDirty$2, /** @internal */ _init__groupDirtyFlags;
808
1344
  var UIGroup = /*#__PURE__*/ function(Component) {
809
1345
  _inherits(UIGroup, Component);
810
1346
  function UIGroup(entity) {
811
1347
  var _this;
812
- _this = Component.call(this, entity) || this, /** @internal */ _this._indexInGroup = -1, /** @internal */ _this._indexInRootCanvas = -1, /** @internal */ _this._disorderedElements = new DisorderedArray(), /** @internal */ _this._globalAlpha = 1, /** @internal */ _this._globalInteractive = true, _this._alpha = 1, _this._interactive = true, _this._ignoreParentGroup = false, /** @internal */ _this._rootCanvasListeningEntities = [], /** @internal */ _this._groupListeningEntities = [], /** @internal */ _this._isRootCanvasDirty = false, /** @internal */ _this._isGroupDirty = false, /** @internal */ _this._groupDirtyFlags = 0;
1348
+ _this = Component.call(this, entity) || this, _this._indexInGroup = _init__indexInGroup$2(_this, -1), _this._indexInRootCanvas = _init__indexInRootCanvas$3(_this, -1), /** @internal */ _this._disorderedElements = new DisorderedArray(), _this._globalAlpha = _init__globalAlpha(_this, 1), _this._globalInteractive = _init__globalInteractive$1(_this, true), _this._alpha = 1, _this._interactive = true, _this._ignoreParentGroup = false, _this._rootCanvasListeningEntities = _init__rootCanvasListeningEntities$3(_this, []), _this._groupListeningEntities = _init__groupListeningEntities$2(_this, []), _this._isRootCanvasDirty = _init__isRootCanvasDirty$3(_this, false), _this._isGroupDirty = _init__isGroupDirty$2(_this, false), _this._groupDirtyFlags = _init__groupDirtyFlags(_this, 0);
813
1349
  _this._rootCanvasListener = _this._rootCanvasListener.bind(_this);
814
1350
  _this._groupListener = _this._groupListener.bind(_this);
815
1351
  return _this;
@@ -961,39 +1497,54 @@ var UIGroup = /*#__PURE__*/ function(Component) {
961
1497
  ]);
962
1498
  return UIGroup;
963
1499
  }(Component);
964
- __decorate([
965
- ignoreClone
966
- ], UIGroup.prototype, "_indexInGroup", void 0);
967
- __decorate([
968
- ignoreClone
969
- ], UIGroup.prototype, "_indexInRootCanvas", void 0);
970
- __decorate([
971
- ignoreClone
972
- ], UIGroup.prototype, "_globalAlpha", void 0);
973
- __decorate([
974
- ignoreClone
975
- ], UIGroup.prototype, "_globalInteractive", void 0);
976
- __decorate([
977
- ignoreClone
978
- ], UIGroup.prototype, "_rootCanvasListeningEntities", void 0);
979
- __decorate([
980
- ignoreClone
981
- ], UIGroup.prototype, "_groupListeningEntities", void 0);
982
- __decorate([
983
- ignoreClone
984
- ], UIGroup.prototype, "_isRootCanvasDirty", void 0);
985
- __decorate([
986
- ignoreClone
987
- ], UIGroup.prototype, "_isGroupDirty", void 0);
988
- __decorate([
989
- ignoreClone
990
- ], UIGroup.prototype, "_groupDirtyFlags", void 0);
991
- __decorate([
992
- ignoreClone
993
- ], UIGroup.prototype, "_groupListener", null);
994
- __decorate([
995
- ignoreClone
996
- ], UIGroup.prototype, "_rootCanvasListener", null);
1500
+ var ref$4, ref1$4;
1501
+ ref$4 = _apply_decs_2203_r(UIGroup, [
1502
+ [
1503
+ ignoreClone,
1504
+ 0,
1505
+ "_indexInGroup"
1506
+ ],
1507
+ [
1508
+ ignoreClone,
1509
+ 0,
1510
+ "_indexInRootCanvas"
1511
+ ],
1512
+ [
1513
+ ignoreClone,
1514
+ 0,
1515
+ "_globalAlpha"
1516
+ ],
1517
+ [
1518
+ ignoreClone,
1519
+ 0,
1520
+ "_globalInteractive"
1521
+ ],
1522
+ [
1523
+ ignoreClone,
1524
+ 0,
1525
+ "_rootCanvasListeningEntities"
1526
+ ],
1527
+ [
1528
+ ignoreClone,
1529
+ 0,
1530
+ "_groupListeningEntities"
1531
+ ],
1532
+ [
1533
+ ignoreClone,
1534
+ 0,
1535
+ "_isRootCanvasDirty"
1536
+ ],
1537
+ [
1538
+ ignoreClone,
1539
+ 0,
1540
+ "_isGroupDirty"
1541
+ ],
1542
+ [
1543
+ ignoreClone,
1544
+ 0,
1545
+ "_groupDirtyFlags"
1546
+ ]
1547
+ ], []), ref1$4 = ref$4.e, _init__indexInGroup$2 = ref1$4[0], _init__indexInRootCanvas$3 = ref1$4[1], _init__globalAlpha = ref1$4[2], _init__globalInteractive$1 = ref1$4[3], _init__rootCanvasListeningEntities$3 = ref1$4[4], _init__groupListeningEntities$2 = ref1$4[5], _init__isRootCanvasDirty$3 = ref1$4[6], _init__isGroupDirty$2 = ref1$4[7], _init__groupDirtyFlags = ref1$4[8];
997
1548
  var GroupModifyFlags = /*#__PURE__*/ function(GroupModifyFlags) {
998
1549
  GroupModifyFlags[GroupModifyFlags["None"] = 0] = "None";
999
1550
  GroupModifyFlags[GroupModifyFlags["GlobalAlpha"] = 1] = "GlobalAlpha";
@@ -1002,409 +1553,440 @@ var GroupModifyFlags = /*#__PURE__*/ function(GroupModifyFlags) {
1002
1553
  return GroupModifyFlags;
1003
1554
  }({});
1004
1555
 
1005
- var UIRenderer = /*#__PURE__*/ function(Renderer) {
1006
- _inherits(UIRenderer, Renderer);
1007
- function UIRenderer(entity) {
1556
+ var _class$2;
1557
+ var _dec$2, _initClass$2, _Renderer, /** @internal */ _init__indexInRootCanvas$2, /** @internal */ _init__isRootCanvasDirty$2, /** @internal */ _init__rootCanvasListeningEntities$2, /** @internal */ _init__indexInGroup$1, /** @internal */ _init__isGroupDirty$1, /** @internal */ _init__groupListeningEntities$1, /** @internal */ _init__subChunk, /** @internal */ _init__rectMasks, /** @internal */ _init__rectMaskRect, /** @internal */ _init__rectMaskEnabled, /** @internal */ _init__rectMaskSoftness, /** @internal */ _init__rectMaskHardClip;
1558
+ var _UIRenderer;
1559
+ _dec$2 = dependentComponents(UITransform, DependentMode.AutoAdd);
1560
+ new (_class$2 = /*#__PURE__*/ function(_identity) {
1561
+ _inherits(_class, _identity);
1562
+ function _class() {
1008
1563
  var _this;
1009
- _this = Renderer.call(this, entity) || this, /**
1010
- * Custom boundary for raycast detection.
1011
- * @remarks this is based on `this.entity.transform`.
1012
- */ _this.raycastPadding = new Vector4(0, 0, 0, 0), /** @internal */ _this._indexInRootCanvas = -1, /** @internal */ _this._isRootCanvasDirty = false, /** @internal */ _this._rootCanvasListeningEntities = [], /** @internal */ _this._indexInGroup = -1, /** @internal */ _this._isGroupDirty = false, /** @internal */ _this._groupListeningEntities = [], /** @internal */ _this._rectMasks = [], /** @internal */ _this._rectMaskRect = new Vector4(), /** @internal */ _this._rectMaskEnabled = false, /** @internal */ _this._rectMaskSoftness = new Vector4(), /** @internal */ _this._rectMaskHardClip = false, _this._raycastEnabled = false, _this._color = new Color(1, 1, 1, 1);
1013
- _this._dirtyUpdateFlag = RendererUpdateFlags.WorldVolume | 2;
1014
- _this._onColorChanged = _this._onColorChanged.bind(_this);
1015
- //@ts-ignore
1016
- _this._color._onValueChanged = _this._onColorChanged;
1017
- _this._groupListener = _this._groupListener.bind(_this);
1018
- _this._rootCanvasListener = _this._rootCanvasListener.bind(_this);
1019
- _this.shaderData.setFloat(UIRenderer._rectClipEnabledProperty, 0);
1020
- _this.shaderData.setVector4(UIRenderer._rectClipSoftnessProperty, _this._rectMaskSoftness);
1021
- _this.shaderData.setFloat(UIRenderer._rectClipHardClipProperty, 0);
1564
+ _this = _identity.apply(this, arguments) || this, _initClass$2();
1022
1565
  return _this;
1023
1566
  }
1024
- var _proto = UIRenderer.prototype;
1025
- // @ts-ignore
1026
- _proto._canBatch = function _canBatch(preElement, curElement) {
1027
- return VertexMergeBatcher.canBatchSprite(preElement, curElement);
1028
- };
1029
- // @ts-ignore
1030
- _proto._batch = function _batch(preElement, curElement) {
1031
- VertexMergeBatcher.batch(preElement, curElement);
1032
- };
1033
- // @ts-ignore
1034
- _proto._updateTransformShaderData = function _updateTransformShaderData(context, onlyMVP) {
1567
+ return _class;
1568
+ }(_identity), function() {
1569
+ var UIRenderer = /*#__PURE__*/ function(_superClass) {
1570
+ _inherits(UIRenderer, _superClass);
1571
+ function UIRenderer(entity) {
1572
+ var _this;
1573
+ _this = _superClass.call(this, entity) || this, /**
1574
+ * Custom boundary for raycast detection.
1575
+ * @remarks this is based on `this.entity.transform`.
1576
+ */ _this.raycastPadding = new Vector4(0, 0, 0, 0), _this._indexInRootCanvas = _init__indexInRootCanvas$2(_this, -1), _this._isRootCanvasDirty = _init__isRootCanvasDirty$2(_this, false), _this._rootCanvasListeningEntities = _init__rootCanvasListeningEntities$2(_this, []), _this._indexInGroup = _init__indexInGroup$1(_this, -1), _this._isGroupDirty = _init__isGroupDirty$1(_this, false), _this._groupListeningEntities = _init__groupListeningEntities$1(_this, []), _this._subChunk = _init__subChunk(_this), _this._rectMasks = _init__rectMasks(_this, []), _this._rectMaskRect = _init__rectMaskRect(_this, new Vector4()), _this._rectMaskEnabled = _init__rectMaskEnabled(_this, false), _this._rectMaskSoftness = _init__rectMaskSoftness(_this, new Vector4()), _this._rectMaskHardClip = _init__rectMaskHardClip(_this, false), _this._raycastEnabled = false, _this._color = new Color(1, 1, 1, 1);
1577
+ _this._dirtyUpdateFlag = RendererUpdateFlags.WorldVolume | 2;
1578
+ _this._onColorChanged = _this._onColorChanged.bind(_this);
1579
+ //@ts-ignore
1580
+ _this._color._onValueChanged = _this._onColorChanged;
1581
+ _this._groupListener = _this._groupListener.bind(_this);
1582
+ _this._rootCanvasListener = _this._rootCanvasListener.bind(_this);
1583
+ _this.shaderData.setFloat(UIRenderer._rectClipEnabledProperty, 0);
1584
+ _this.shaderData.setVector4(UIRenderer._rectClipSoftnessProperty, _this._rectMaskSoftness);
1585
+ _this.shaderData.setFloat(UIRenderer._rectClipHardClipProperty, 0);
1586
+ return _this;
1587
+ }
1588
+ var _proto = UIRenderer.prototype;
1035
1589
  // @ts-ignore
1036
- this._updateWorldSpaceTransformShaderData(context, onlyMVP);
1037
- };
1038
- // @ts-ignore
1039
- _proto._prepareRender = function _prepareRender(context) {
1040
- // Update once per frame per renderer, not influenced by batched
1041
- if (this._renderFrameCount !== this.engine.time.frameCount) {
1042
- this._update(context);
1043
- }
1044
- this._updateRectMaskClipState();
1045
- this._render(context);
1046
- // union camera global macro and renderer macro.
1047
- ShaderMacroCollection.unionCollection(context.camera._globalShaderMacro, // @ts-ignore
1048
- this.shaderData._macroCollection, //@ts-ignore
1049
- this._globalShaderMacro);
1050
- };
1051
- // @ts-ignore
1052
- _proto._onEnableInScene = function _onEnableInScene() {
1590
+ _proto._canBatch = function _canBatch(preElement, curElement) {
1591
+ return VertexMergeBatcher.canBatchSprite(preElement, curElement);
1592
+ };
1053
1593
  // @ts-ignore
1054
- this._overrideUpdate && this.scene._componentsManager.addOnUpdateRenderers(this);
1055
- this.entity._updateUIHierarchyVersion(UICanvas._hierarchyCounter);
1056
- Utils.setRootCanvasDirty(this);
1057
- Utils.setGroupDirty(this);
1058
- };
1059
- // @ts-ignore
1060
- _proto._onDisableInScene = function _onDisableInScene() {
1594
+ _proto._batch = function _batch(preElement, curElement) {
1595
+ VertexMergeBatcher.batch(preElement, curElement);
1596
+ };
1061
1597
  // @ts-ignore
1062
- this._overrideUpdate && this.scene._componentsManager.removeOnUpdateRenderers(this);
1063
- this.entity._updateUIHierarchyVersion(UICanvas._hierarchyCounter);
1064
- Utils.cleanRootCanvas(this);
1065
- Utils.cleanGroup(this);
1066
- };
1067
- /**
1598
+ _proto._updateTransformShaderData = function _updateTransformShaderData(context, onlyMVP) {
1599
+ // @ts-ignore
1600
+ this._updateWorldSpaceTransformShaderData(context, onlyMVP);
1601
+ };
1602
+ // @ts-ignore
1603
+ _proto._prepareRender = function _prepareRender(context) {
1604
+ // Update once per frame per renderer, not influenced by batched
1605
+ if (this._renderFrameCount !== this.engine.time.frameCount) {
1606
+ this._update(context);
1607
+ }
1608
+ this._updateRectMaskClipState();
1609
+ this._render(context);
1610
+ // union camera global macro and renderer macro.
1611
+ ShaderMacroCollection.unionCollection(context.camera._globalShaderMacro, // @ts-ignore
1612
+ this.shaderData._macroCollection, //@ts-ignore
1613
+ this._globalShaderMacro);
1614
+ };
1615
+ // @ts-ignore
1616
+ _proto._onEnableInScene = function _onEnableInScene() {
1617
+ // @ts-ignore
1618
+ this._overrideUpdate && this.scene._componentsManager.addOnUpdateRenderers(this);
1619
+ this.entity._updateUIHierarchyVersion(_UICanvas._hierarchyCounter);
1620
+ Utils.setRootCanvasDirty(this);
1621
+ Utils.setGroupDirty(this);
1622
+ };
1623
+ // @ts-ignore
1624
+ _proto._onDisableInScene = function _onDisableInScene() {
1625
+ // @ts-ignore
1626
+ this._overrideUpdate && this.scene._componentsManager.removeOnUpdateRenderers(this);
1627
+ this.entity._updateUIHierarchyVersion(_UICanvas._hierarchyCounter);
1628
+ Utils.cleanRootCanvas(this);
1629
+ Utils.cleanGroup(this);
1630
+ };
1631
+ /**
1068
1632
  * @internal
1069
1633
  */ _proto._getGlobalAlpha = function _getGlobalAlpha() {
1070
- var _this__getGroup;
1071
- var _this__getGroup__getGlobalAlpha;
1072
- return (_this__getGroup__getGlobalAlpha = (_this__getGroup = this._getGroup()) == null ? void 0 : _this__getGroup._getGlobalAlpha()) != null ? _this__getGroup__getGlobalAlpha : 1;
1073
- };
1074
- /**
1634
+ var _this__getGroup;
1635
+ var _this__getGroup__getGlobalAlpha;
1636
+ return (_this__getGroup__getGlobalAlpha = (_this__getGroup = this._getGroup()) == null ? void 0 : _this__getGroup._getGlobalAlpha()) != null ? _this__getGroup__getGlobalAlpha : 1;
1637
+ };
1638
+ /**
1075
1639
  * @internal
1076
1640
  */ _proto._getRootCanvas = function _getRootCanvas() {
1077
- this._isRootCanvasDirty && Utils.setRootCanvas(this, Utils.searchRootCanvasInParents(this));
1078
- return this._rootCanvas;
1079
- };
1080
- /**
1641
+ this._isRootCanvasDirty && Utils.setRootCanvas(this, Utils.searchRootCanvasInParents(this));
1642
+ return this._rootCanvas;
1643
+ };
1644
+ /**
1081
1645
  * @internal
1082
1646
  */ _proto._getGroup = function _getGroup() {
1083
- this._isGroupDirty && Utils.setGroup(this, Utils.searchGroupInParents(this));
1084
- return this._group;
1085
- };
1086
- /**
1647
+ this._isGroupDirty && Utils.setGroup(this, Utils.searchGroupInParents(this));
1648
+ return this._group;
1649
+ };
1650
+ /**
1087
1651
  * @internal
1088
1652
  */ _proto._groupListener = function _groupListener(flag) {
1089
- if (flag === EntityModifyFlags.Parent || flag === EntityUIModifyFlags.GroupEnableInScene) {
1090
- Utils.setGroupDirty(this);
1091
- }
1092
- };
1093
- /**
1653
+ if (flag === EntityModifyFlags.Parent || flag === EntityUIModifyFlags.GroupEnableInScene) {
1654
+ Utils.setGroupDirty(this);
1655
+ }
1656
+ };
1657
+ /**
1094
1658
  * @internal
1095
1659
  */ _proto._rootCanvasListener = function _rootCanvasListener(flag, entity) {
1096
- switch(flag){
1097
- case EntityModifyFlags.Parent:
1098
- Utils.setRootCanvasDirty(this);
1099
- Utils.setGroupDirty(this);
1100
- case EntityModifyFlags.Child:
1101
- entity._updateUIHierarchyVersion(UICanvas._hierarchyCounter);
1102
- break;
1103
- }
1104
- };
1105
- /**
1660
+ switch(flag){
1661
+ case EntityModifyFlags.Parent:
1662
+ Utils.setRootCanvasDirty(this);
1663
+ Utils.setGroupDirty(this);
1664
+ case EntityModifyFlags.Child:
1665
+ entity._updateUIHierarchyVersion(_UICanvas._hierarchyCounter);
1666
+ break;
1667
+ }
1668
+ };
1669
+ /**
1106
1670
  * @internal
1107
1671
  */ _proto._onGroupModify = function _onGroupModify(flags) {
1108
- if (flags & GroupModifyFlags.GlobalAlpha) {
1672
+ if (flags & GroupModifyFlags.GlobalAlpha) {
1673
+ this._dirtyUpdateFlag |= 2;
1674
+ }
1675
+ };
1676
+ _proto._onColorChanged = function _onColorChanged() {
1109
1677
  this._dirtyUpdateFlag |= 2;
1110
- }
1111
- };
1112
- _proto._onColorChanged = function _onColorChanged() {
1113
- this._dirtyUpdateFlag |= 2;
1114
- };
1115
- /**
1678
+ };
1679
+ /**
1116
1680
  * @internal
1117
1681
  */ _proto._getChunkManager = function _getChunkManager() {
1118
- // @ts-ignore
1119
- return this.engine._batcherManager.primitiveChunkManagerUI;
1120
- };
1121
- /**
1682
+ // @ts-ignore
1683
+ return this.engine._batcherManager.primitiveChunkManagerUI;
1684
+ };
1685
+ /**
1122
1686
  * @internal
1123
1687
  */ _proto._setRectMasks = function _setRectMasks(rectMasks, count) {
1124
- var targetMasks = this._rectMasks;
1125
- targetMasks.length = count;
1126
- for(var i = 0; i < count; i++){
1127
- targetMasks[i] = rectMasks[i];
1128
- }
1129
- };
1130
- /**
1688
+ var targetMasks = this._rectMasks;
1689
+ targetMasks.length = count;
1690
+ for(var i = 0; i < count; i++){
1691
+ targetMasks[i] = rectMasks[i];
1692
+ }
1693
+ };
1694
+ /**
1131
1695
  * @internal
1132
1696
  */ _proto._raycast = function _raycast(ray, out, distance) {
1133
- if (distance === void 0) distance = Number.MAX_SAFE_INTEGER;
1134
- var plane = UIRenderer._tempPlane;
1135
- var transform = this._transformEntity.transform;
1136
- var normal = plane.normal.copyFrom(transform.worldForward);
1137
- plane.distance = -Vector3.dot(normal, transform.worldPosition);
1138
- var curDistance = ray.intersectPlane(plane);
1139
- if (curDistance >= 0 && curDistance < distance) {
1140
- var hitPointWorld = ray.getPoint(curDistance, UIRenderer._tempVec30);
1141
- var worldMatrixInv = UIRenderer._tempMat;
1142
- Matrix.invert(transform.worldMatrix, worldMatrixInv);
1143
- var localPosition = UIRenderer._tempVec31;
1144
- Vector3.transformCoordinate(hitPointWorld, worldMatrixInv, localPosition);
1145
- if (this._hitTest(localPosition) && this._isRaycastVisibleByRectMask(hitPointWorld) && this._isRaycastVisibleByMask(hitPointWorld)) {
1146
- out.component = this;
1147
- out.distance = curDistance;
1148
- out.entity = this.entity;
1149
- out.normal.copyFrom(normal);
1150
- out.point.copyFrom(hitPointWorld);
1697
+ if (distance === void 0) distance = Number.MAX_SAFE_INTEGER;
1698
+ var plane = UIRenderer._tempPlane;
1699
+ var transform = this._transformEntity.transform;
1700
+ var normal = plane.normal.copyFrom(transform.worldForward);
1701
+ plane.distance = -Vector3.dot(normal, transform.worldPosition);
1702
+ var curDistance = ray.intersectPlane(plane);
1703
+ if (curDistance >= 0 && curDistance < distance) {
1704
+ var hitPointWorld = ray.getPoint(curDistance, UIRenderer._tempVec30);
1705
+ var worldMatrixInv = UIRenderer._tempMat;
1706
+ Matrix.invert(transform.worldMatrix, worldMatrixInv);
1707
+ var localPosition = UIRenderer._tempVec31;
1708
+ Vector3.transformCoordinate(hitPointWorld, worldMatrixInv, localPosition);
1709
+ if (this._hitTest(localPosition) && this._isRaycastVisibleByRectMask(hitPointWorld) && this._isRaycastVisibleByMask(hitPointWorld)) {
1710
+ out.component = this;
1711
+ out.distance = curDistance;
1712
+ out.entity = this.entity;
1713
+ out.normal.copyFrom(normal);
1714
+ out.point.copyFrom(hitPointWorld);
1715
+ return true;
1716
+ }
1717
+ }
1718
+ return false;
1719
+ };
1720
+ _proto._hitTest = function _hitTest(localPosition) {
1721
+ var x = localPosition.x, y = localPosition.y;
1722
+ var uiTransform = this._transformEntity.transform;
1723
+ var _uiTransform_size = uiTransform.size, width = _uiTransform_size.x, height = _uiTransform_size.y;
1724
+ var _uiTransform_pivot = uiTransform.pivot, pivotX = _uiTransform_pivot.x, pivotY = _uiTransform_pivot.y;
1725
+ var _this_raycastPadding = this.raycastPadding, paddingLeft = _this_raycastPadding.x, paddingBottom = _this_raycastPadding.y, paddingRight = _this_raycastPadding.z, paddingTop = _this_raycastPadding.w;
1726
+ return x >= -width * pivotX + paddingLeft && x <= width * (1 - pivotX) - paddingRight && y >= -height * pivotY + paddingTop && y <= height * (1 - pivotY) - paddingBottom;
1727
+ };
1728
+ _proto._isRaycastVisibleByMask = function _isRaycastVisibleByMask(hitPointWorld) {
1729
+ var maskInteraction = this._maskInteraction;
1730
+ if (maskInteraction === SpriteMaskInteraction.None) {
1151
1731
  return true;
1152
1732
  }
1153
- }
1154
- return false;
1155
- };
1156
- _proto._hitTest = function _hitTest(localPosition) {
1157
- var x = localPosition.x, y = localPosition.y;
1158
- var uiTransform = this._transformEntity.transform;
1159
- var _uiTransform_size = uiTransform.size, width = _uiTransform_size.x, height = _uiTransform_size.y;
1160
- var _uiTransform_pivot = uiTransform.pivot, pivotX = _uiTransform_pivot.x, pivotY = _uiTransform_pivot.y;
1161
- var _this_raycastPadding = this.raycastPadding, paddingLeft = _this_raycastPadding.x, paddingBottom = _this_raycastPadding.y, paddingRight = _this_raycastPadding.z, paddingTop = _this_raycastPadding.w;
1162
- return x >= -width * pivotX + paddingLeft && x <= width * (1 - pivotX) - paddingRight && y >= -height * pivotY + paddingTop && y <= height * (1 - pivotY) - paddingBottom;
1163
- };
1164
- _proto._isRaycastVisibleByMask = function _isRaycastVisibleByMask(hitPointWorld) {
1165
- var maskInteraction = this._maskInteraction;
1166
- if (maskInteraction === SpriteMaskInteraction.None) {
1733
+ // @ts-ignore
1734
+ return this.scene._maskManager.isVisibleByMask(maskInteraction, this._maskLayer, hitPointWorld);
1735
+ };
1736
+ _proto._isRaycastVisibleByRectMask = function _isRaycastVisibleByRectMask(hitPointWorld) {
1737
+ var rectMasks = this._rectMasks;
1738
+ for(var i = 0, n = rectMasks.length; i < n; i++){
1739
+ var rectMask = rectMasks[i];
1740
+ if (!rectMask.enabled || !rectMask.entity.isActiveInHierarchy) {
1741
+ continue;
1742
+ }
1743
+ if (!rectMask._containsWorldPoint(hitPointWorld)) {
1744
+ return false;
1745
+ }
1746
+ }
1167
1747
  return true;
1168
- }
1169
- // @ts-ignore
1170
- return this.scene._maskManager.isVisibleByMask(maskInteraction, this._maskLayer, hitPointWorld);
1171
- };
1172
- _proto._isRaycastVisibleByRectMask = function _isRaycastVisibleByRectMask(hitPointWorld) {
1173
- var rectMasks = this._rectMasks;
1174
- for(var i = 0, n = rectMasks.length; i < n; i++){
1175
- var rectMask = rectMasks[i];
1176
- if (!rectMask.enabled || !rectMask.entity.isActiveInHierarchy) {
1177
- continue;
1178
- }
1179
- if (!rectMask._containsWorldPoint(hitPointWorld)) {
1180
- return false;
1748
+ };
1749
+ _proto._updateRectMaskClipState = function _updateRectMaskClipState() {
1750
+ var rectMasks = this._rectMasks;
1751
+ var count = rectMasks.length;
1752
+ if (count <= 0) {
1753
+ this._resetRectMaskClipState();
1754
+ return;
1181
1755
  }
1182
- }
1183
- return true;
1184
- };
1185
- _proto._updateRectMaskClipState = function _updateRectMaskClipState() {
1186
- var rectMasks = this._rectMasks;
1187
- var count = rectMasks.length;
1188
- if (count <= 0) {
1189
- this._resetRectMaskClipState();
1190
- return;
1191
- }
1192
- var minX = Number.NEGATIVE_INFINITY;
1193
- var minY = Number.NEGATIVE_INFINITY;
1194
- var maxX = Number.POSITIVE_INFINITY;
1195
- var maxY = Number.POSITIVE_INFINITY;
1196
- var clipSoftnessLeft = 0;
1197
- var clipSoftnessBottom = 0;
1198
- var clipSoftnessRight = 0;
1199
- var clipSoftnessTop = 0;
1200
- var clipHardClip = false;
1201
- var hasActiveMask = false;
1202
- var tempRect = UIRenderer._tempRect;
1203
- for(var i = 0; i < count; i++){
1204
- var rectMask = rectMasks[i];
1205
- if (!rectMask.enabled || !rectMask.entity.isActiveInHierarchy) {
1206
- continue;
1207
- }
1208
- hasActiveMask = true;
1209
- var softness = rectMask.softness;
1210
- if (!clipHardClip && rectMask.alphaClip) {
1211
- clipHardClip = true;
1212
- }
1213
- if (!rectMask._getWorldRect(tempRect)) {
1756
+ var minX = Number.NEGATIVE_INFINITY;
1757
+ var minY = Number.NEGATIVE_INFINITY;
1758
+ var maxX = Number.POSITIVE_INFINITY;
1759
+ var maxY = Number.POSITIVE_INFINITY;
1760
+ var clipSoftnessLeft = 0;
1761
+ var clipSoftnessBottom = 0;
1762
+ var clipSoftnessRight = 0;
1763
+ var clipSoftnessTop = 0;
1764
+ var clipHardClip = false;
1765
+ var hasActiveMask = false;
1766
+ var tempRect = UIRenderer._tempRect;
1767
+ for(var i = 0; i < count; i++){
1768
+ var rectMask = rectMasks[i];
1769
+ if (!rectMask.enabled || !rectMask.entity.isActiveInHierarchy) {
1770
+ continue;
1771
+ }
1772
+ hasActiveMask = true;
1773
+ var softness = rectMask.softness;
1774
+ if (!clipHardClip && rectMask.alphaClip) {
1775
+ clipHardClip = true;
1776
+ }
1777
+ if (!rectMask._getWorldRect(tempRect)) {
1778
+ minX = 1;
1779
+ minY = 1;
1780
+ maxX = 0;
1781
+ maxY = 0;
1782
+ break;
1783
+ }
1784
+ if (tempRect.x > minX) {
1785
+ minX = tempRect.x;
1786
+ clipSoftnessLeft = softness.x;
1787
+ }
1788
+ if (tempRect.y > minY) {
1789
+ minY = tempRect.y;
1790
+ clipSoftnessBottom = softness.y;
1791
+ }
1792
+ if (tempRect.z < maxX) {
1793
+ maxX = tempRect.z;
1794
+ clipSoftnessRight = softness.x;
1795
+ }
1796
+ if (tempRect.w < maxY) {
1797
+ maxY = tempRect.w;
1798
+ clipSoftnessTop = softness.y;
1799
+ }
1800
+ }
1801
+ if (!hasActiveMask) {
1802
+ this._resetRectMaskClipState();
1803
+ return;
1804
+ }
1805
+ if (minX >= maxX || minY >= maxY) {
1214
1806
  minX = 1;
1215
1807
  minY = 1;
1216
1808
  maxX = 0;
1217
1809
  maxY = 0;
1218
- break;
1810
+ clipSoftnessLeft = 0;
1811
+ clipSoftnessBottom = 0;
1812
+ clipSoftnessRight = 0;
1813
+ clipSoftnessTop = 0;
1219
1814
  }
1220
- if (tempRect.x > minX) {
1221
- minX = tempRect.x;
1222
- clipSoftnessLeft = softness.x;
1815
+ var rectMaskRect = this._rectMaskRect;
1816
+ if (rectMaskRect.x !== minX || rectMaskRect.y !== minY || rectMaskRect.z !== maxX || rectMaskRect.w !== maxY) {
1817
+ rectMaskRect.set(minX, minY, maxX, maxY);
1818
+ this.shaderData.setVector4(UIRenderer._rectClipRectProperty, rectMaskRect);
1223
1819
  }
1224
- if (tempRect.y > minY) {
1225
- minY = tempRect.y;
1226
- clipSoftnessBottom = softness.y;
1820
+ var rectMaskSoftness = this._rectMaskSoftness;
1821
+ if (rectMaskSoftness.x !== clipSoftnessLeft || rectMaskSoftness.y !== clipSoftnessBottom || rectMaskSoftness.z !== clipSoftnessRight || rectMaskSoftness.w !== clipSoftnessTop) {
1822
+ rectMaskSoftness.set(clipSoftnessLeft, clipSoftnessBottom, clipSoftnessRight, clipSoftnessTop);
1823
+ this.shaderData.setVector4(UIRenderer._rectClipSoftnessProperty, rectMaskSoftness);
1227
1824
  }
1228
- if (tempRect.z < maxX) {
1229
- maxX = tempRect.z;
1230
- clipSoftnessRight = softness.x;
1825
+ if (this._rectMaskHardClip !== clipHardClip) {
1826
+ this._rectMaskHardClip = clipHardClip;
1827
+ this.shaderData.setFloat(UIRenderer._rectClipHardClipProperty, clipHardClip ? 1 : 0);
1231
1828
  }
1232
- if (tempRect.w < maxY) {
1233
- maxY = tempRect.w;
1234
- clipSoftnessTop = softness.y;
1829
+ if (!this._rectMaskEnabled) {
1830
+ this._rectMaskEnabled = true;
1831
+ this.shaderData.setFloat(UIRenderer._rectClipEnabledProperty, 1);
1235
1832
  }
1236
- }
1237
- if (!hasActiveMask) {
1238
- this._resetRectMaskClipState();
1239
- return;
1240
- }
1241
- if (minX >= maxX || minY >= maxY) {
1242
- minX = 1;
1243
- minY = 1;
1244
- maxX = 0;
1245
- maxY = 0;
1246
- clipSoftnessLeft = 0;
1247
- clipSoftnessBottom = 0;
1248
- clipSoftnessRight = 0;
1249
- clipSoftnessTop = 0;
1250
- }
1251
- var rectMaskRect = this._rectMaskRect;
1252
- if (rectMaskRect.x !== minX || rectMaskRect.y !== minY || rectMaskRect.z !== maxX || rectMaskRect.w !== maxY) {
1253
- rectMaskRect.set(minX, minY, maxX, maxY);
1254
- this.shaderData.setVector4(UIRenderer._rectClipRectProperty, rectMaskRect);
1255
- }
1256
- var rectMaskSoftness = this._rectMaskSoftness;
1257
- if (rectMaskSoftness.x !== clipSoftnessLeft || rectMaskSoftness.y !== clipSoftnessBottom || rectMaskSoftness.z !== clipSoftnessRight || rectMaskSoftness.w !== clipSoftnessTop) {
1258
- rectMaskSoftness.set(clipSoftnessLeft, clipSoftnessBottom, clipSoftnessRight, clipSoftnessTop);
1259
- this.shaderData.setVector4(UIRenderer._rectClipSoftnessProperty, rectMaskSoftness);
1260
- }
1261
- if (this._rectMaskHardClip !== clipHardClip) {
1262
- this._rectMaskHardClip = clipHardClip;
1263
- this.shaderData.setFloat(UIRenderer._rectClipHardClipProperty, clipHardClip ? 1 : 0);
1264
- }
1265
- if (!this._rectMaskEnabled) {
1266
- this._rectMaskEnabled = true;
1267
- this.shaderData.setFloat(UIRenderer._rectClipEnabledProperty, 1);
1268
- }
1269
- };
1270
- _proto._resetRectMaskClipState = function _resetRectMaskClipState() {
1271
- if (this._rectMaskEnabled) {
1272
- this._rectMaskEnabled = false;
1273
- this.shaderData.setFloat(UIRenderer._rectClipEnabledProperty, 0);
1274
- }
1275
- var rectMaskSoftness = this._rectMaskSoftness;
1276
- if (rectMaskSoftness.x !== 0 || rectMaskSoftness.y !== 0 || rectMaskSoftness.z !== 0 || rectMaskSoftness.w !== 0) {
1277
- rectMaskSoftness.set(0, 0, 0, 0);
1278
- this.shaderData.setVector4(UIRenderer._rectClipSoftnessProperty, rectMaskSoftness);
1279
- }
1280
- if (this._rectMaskHardClip) {
1281
- this._rectMaskHardClip = false;
1282
- this.shaderData.setFloat(UIRenderer._rectClipHardClipProperty, 0);
1283
- }
1284
- };
1285
- _proto._onDestroy = function _onDestroy() {
1286
- if (this._subChunk) {
1287
- this._getChunkManager().freeSubChunk(this._subChunk);
1288
- this._subChunk = null;
1289
- }
1290
- Renderer.prototype._onDestroy.call(this);
1291
- //@ts-ignore
1292
- this._color._onValueChanged = null;
1293
- this._color = null;
1294
- this._rectMasks = null;
1295
- this._rectMaskSoftness = null;
1296
- };
1297
- _create_class(UIRenderer, [
1298
- {
1299
- key: "color",
1300
- get: /**
1833
+ };
1834
+ _proto._resetRectMaskClipState = function _resetRectMaskClipState() {
1835
+ if (this._rectMaskEnabled) {
1836
+ this._rectMaskEnabled = false;
1837
+ this.shaderData.setFloat(UIRenderer._rectClipEnabledProperty, 0);
1838
+ }
1839
+ var rectMaskSoftness = this._rectMaskSoftness;
1840
+ if (rectMaskSoftness.x !== 0 || rectMaskSoftness.y !== 0 || rectMaskSoftness.z !== 0 || rectMaskSoftness.w !== 0) {
1841
+ rectMaskSoftness.set(0, 0, 0, 0);
1842
+ this.shaderData.setVector4(UIRenderer._rectClipSoftnessProperty, rectMaskSoftness);
1843
+ }
1844
+ if (this._rectMaskHardClip) {
1845
+ this._rectMaskHardClip = false;
1846
+ this.shaderData.setFloat(UIRenderer._rectClipHardClipProperty, 0);
1847
+ }
1848
+ };
1849
+ _proto._onDestroy = function _onDestroy() {
1850
+ if (this._subChunk) {
1851
+ this._getChunkManager().freeSubChunk(this._subChunk);
1852
+ this._subChunk = null;
1853
+ }
1854
+ _superClass.prototype._onDestroy.call(this);
1855
+ //@ts-ignore
1856
+ this._color._onValueChanged = null;
1857
+ this._color = null;
1858
+ this._rectMasks = null;
1859
+ this._rectMaskSoftness = null;
1860
+ };
1861
+ _create_class(UIRenderer, [
1862
+ {
1863
+ key: "color",
1864
+ get: /**
1301
1865
  * Rendering color for the ui renderer.
1302
1866
  */ function get() {
1303
- return this._color;
1304
- },
1305
- set: function set(value) {
1306
- if (this._color !== value) {
1307
- this._color.copyFrom(value);
1867
+ return this._color;
1868
+ },
1869
+ set: function set(value) {
1870
+ if (this._color !== value) {
1871
+ this._color.copyFrom(value);
1872
+ }
1308
1873
  }
1309
- }
1310
- },
1311
- {
1312
- key: "maskLayer",
1313
- get: /**
1874
+ },
1875
+ {
1876
+ key: "maskLayer",
1877
+ get: /**
1314
1878
  * The mask layer the ui renderer belongs to.
1315
1879
  */ function get() {
1316
- return this._maskLayer;
1880
+ return this._maskLayer;
1881
+ },
1882
+ set: function set(value) {
1883
+ this._maskLayer = value;
1884
+ }
1317
1885
  },
1318
- set: function set(value) {
1319
- this._maskLayer = value;
1320
- }
1321
- },
1322
- {
1323
- key: "maskInteraction",
1324
- get: /**
1886
+ {
1887
+ key: "maskInteraction",
1888
+ get: /**
1325
1889
  * Interacts with the masks.
1326
1890
  */ function get() {
1327
- return this._maskInteraction;
1328
- },
1329
- set: function set(value) {
1330
- if (this._maskInteraction !== value) {
1331
- this._maskInteraction = value;
1891
+ return this._maskInteraction;
1892
+ },
1893
+ set: function set(value) {
1894
+ if (this._maskInteraction !== value) {
1895
+ this._maskInteraction = value;
1896
+ }
1332
1897
  }
1333
- }
1334
- },
1335
- {
1336
- key: "raycastEnabled",
1337
- get: /**
1898
+ },
1899
+ {
1900
+ key: "raycastEnabled",
1901
+ get: /**
1338
1902
  * Whether this renderer be picked up by raycast.
1339
1903
  */ function get() {
1340
- return this._raycastEnabled;
1341
- },
1342
- set: function set(value) {
1343
- this._raycastEnabled = value;
1904
+ return this._raycastEnabled;
1905
+ },
1906
+ set: function set(value) {
1907
+ this._raycastEnabled = value;
1908
+ }
1344
1909
  }
1345
- }
1346
- ]);
1347
- return UIRenderer;
1348
- }(Renderer);
1349
- /** @internal */ UIRenderer._tempVec20 = new Vector2();
1350
- /** @internal */ UIRenderer._tempVec30 = new Vector3();
1351
- /** @internal */ UIRenderer._tempVec31 = new Vector3();
1352
- /** @internal */ UIRenderer._tempMat = new Matrix();
1353
- /** @internal */ UIRenderer._tempPlane = new Plane();
1354
- /** @internal */ UIRenderer._textureProperty = ShaderProperty.getByName("renderer_UITexture");
1355
- /** @internal */ UIRenderer._rectClipRectProperty = ShaderProperty.getByName("renderer_UIRectClipRect");
1356
- /** @internal */ UIRenderer._rectClipEnabledProperty = ShaderProperty.getByName("renderer_UIRectClipEnabled");
1357
- /** @internal */ UIRenderer._rectClipSoftnessProperty = ShaderProperty.getByName("renderer_UIRectClipSoftness");
1358
- /** @internal */ UIRenderer._rectClipHardClipProperty = ShaderProperty.getByName("renderer_UIRectClipHardClip");
1359
- /** @internal */ UIRenderer._tempRect = new Vector4();
1360
- __decorate([
1361
- ignoreClone
1362
- ], UIRenderer.prototype, "_indexInRootCanvas", void 0);
1363
- __decorate([
1364
- ignoreClone
1365
- ], UIRenderer.prototype, "_isRootCanvasDirty", void 0);
1366
- __decorate([
1367
- ignoreClone
1368
- ], UIRenderer.prototype, "_rootCanvasListeningEntities", void 0);
1369
- __decorate([
1370
- ignoreClone
1371
- ], UIRenderer.prototype, "_indexInGroup", void 0);
1372
- __decorate([
1373
- ignoreClone
1374
- ], UIRenderer.prototype, "_isGroupDirty", void 0);
1375
- __decorate([
1376
- ignoreClone
1377
- ], UIRenderer.prototype, "_groupListeningEntities", void 0);
1378
- __decorate([
1379
- ignoreClone
1380
- ], UIRenderer.prototype, "_subChunk", void 0);
1381
- __decorate([
1382
- ignoreClone
1383
- ], UIRenderer.prototype, "_rectMasks", void 0);
1384
- __decorate([
1385
- ignoreClone
1386
- ], UIRenderer.prototype, "_rectMaskRect", void 0);
1387
- __decorate([
1388
- ignoreClone
1389
- ], UIRenderer.prototype, "_rectMaskEnabled", void 0);
1390
- __decorate([
1391
- ignoreClone
1392
- ], UIRenderer.prototype, "_rectMaskSoftness", void 0);
1393
- __decorate([
1394
- ignoreClone
1395
- ], UIRenderer.prototype, "_rectMaskHardClip", void 0);
1396
- __decorate([
1397
- ignoreClone
1398
- ], UIRenderer.prototype, "_groupListener", null);
1399
- __decorate([
1400
- ignoreClone
1401
- ], UIRenderer.prototype, "_rootCanvasListener", null);
1402
- __decorate([
1403
- ignoreClone
1404
- ], UIRenderer.prototype, "_onColorChanged", null);
1405
- UIRenderer = __decorate([
1406
- dependentComponents(UITransform, DependentMode.AutoAdd)
1407
- ], UIRenderer);
1910
+ ]);
1911
+ return UIRenderer;
1912
+ }(_Renderer = Renderer);
1913
+ var ref, ref1, ref2;
1914
+ ref = _apply_decs_2203_r(UIRenderer, [
1915
+ [
1916
+ ignoreClone,
1917
+ 0,
1918
+ "_indexInRootCanvas"
1919
+ ],
1920
+ [
1921
+ ignoreClone,
1922
+ 0,
1923
+ "_isRootCanvasDirty"
1924
+ ],
1925
+ [
1926
+ ignoreClone,
1927
+ 0,
1928
+ "_rootCanvasListeningEntities"
1929
+ ],
1930
+ [
1931
+ ignoreClone,
1932
+ 0,
1933
+ "_indexInGroup"
1934
+ ],
1935
+ [
1936
+ ignoreClone,
1937
+ 0,
1938
+ "_isGroupDirty"
1939
+ ],
1940
+ [
1941
+ ignoreClone,
1942
+ 0,
1943
+ "_groupListeningEntities"
1944
+ ],
1945
+ [
1946
+ ignoreClone,
1947
+ 0,
1948
+ "_subChunk"
1949
+ ],
1950
+ [
1951
+ ignoreClone,
1952
+ 0,
1953
+ "_rectMasks"
1954
+ ],
1955
+ [
1956
+ ignoreClone,
1957
+ 0,
1958
+ "_rectMaskRect"
1959
+ ],
1960
+ [
1961
+ ignoreClone,
1962
+ 0,
1963
+ "_rectMaskEnabled"
1964
+ ],
1965
+ [
1966
+ ignoreClone,
1967
+ 0,
1968
+ "_rectMaskSoftness"
1969
+ ],
1970
+ [
1971
+ ignoreClone,
1972
+ 0,
1973
+ "_rectMaskHardClip"
1974
+ ]
1975
+ ], [
1976
+ _dec$2
1977
+ ], _Renderer), ref1 = ref.e, _init__indexInRootCanvas$2 = ref1[0], _init__isRootCanvasDirty$2 = ref1[1], _init__rootCanvasListeningEntities$2 = ref1[2], _init__indexInGroup$1 = ref1[3], _init__isGroupDirty$1 = ref1[4], _init__groupListeningEntities$1 = ref1[5], _init__subChunk = ref1[6], _init__rectMasks = ref1[7], _init__rectMaskRect = ref1[8], _init__rectMaskEnabled = ref1[9], _init__rectMaskSoftness = ref1[10], _init__rectMaskHardClip = ref1[11], ref2 = ref.c, _UIRenderer = ref2[0], _initClass$2 = ref2[1];
1978
+ /** @internal */ UIRenderer._tempVec20 = new Vector2();
1979
+ /** @internal */ UIRenderer._tempVec30 = new Vector3();
1980
+ /** @internal */ UIRenderer._tempVec31 = new Vector3();
1981
+ /** @internal */ UIRenderer._tempMat = new Matrix();
1982
+ /** @internal */ UIRenderer._tempPlane = new Plane();
1983
+ /** @internal */ UIRenderer._textureProperty = ShaderProperty.getByName("renderer_UITexture");
1984
+ /** @internal */ UIRenderer._rectClipRectProperty = ShaderProperty.getByName("renderer_UIRectClipRect");
1985
+ /** @internal */ UIRenderer._rectClipEnabledProperty = ShaderProperty.getByName("renderer_UIRectClipEnabled");
1986
+ /** @internal */ UIRenderer._rectClipSoftnessProperty = ShaderProperty.getByName("renderer_UIRectClipSoftness");
1987
+ /** @internal */ UIRenderer._rectClipHardClipProperty = ShaderProperty.getByName("renderer_UIRectClipHardClip");
1988
+ /** @internal */ UIRenderer._tempRect = new Vector4();
1989
+ }(), _class$2)();
1408
1990
  /**
1409
1991
  * @remarks Extends `RendererUpdateFlags`.
1410
1992
  */ var UIRendererUpdateFlags = /*#__PURE__*/ function(UIRendererUpdateFlags) {
@@ -1412,639 +1994,666 @@ UIRenderer = __decorate([
1412
1994
  return UIRendererUpdateFlags;
1413
1995
  }({});
1414
1996
 
1415
- var UICanvas = /*#__PURE__*/ function(Component) {
1416
- _inherits(UICanvas, Component);
1417
- function UICanvas(entity) {
1997
+ var _class$1;
1998
+ var _dec$1, _initClass$1, _Component, /** @internal */ _init__canvasIndex, /** @internal */ _init__indexInRootCanvas$1, /** @internal */ _init__isRootCanvasDirty$1, /** @internal */ _init__rootCanvasListeningEntities$1, /** @internal */ _init__isRootCanvas, /** @internal */ _init__renderElements, /** @internal */ _init__batchedRenderElements, /** @internal */ _init__sortDistance, /** @internal */ _init__orderedRenderers, /** @internal */ _init__realRenderMode, _init__renderMode, _init__hierarchyVersion, _init__center;
1999
+ var _UICanvas;
2000
+ _dec$1 = dependentComponents(UITransform, DependentMode.AutoAdd);
2001
+ new (_class$1 = /*#__PURE__*/ function(_identity) {
2002
+ _inherits(_class, _identity);
2003
+ function _class() {
1418
2004
  var _this;
1419
- _this = Component.call(this, entity) || this, /** @internal */ _this._canvasIndex = -1, /** @internal */ _this._indexInRootCanvas = -1, /** @internal */ _this._isRootCanvasDirty = false, /** @internal */ _this._rootCanvasListeningEntities = [], /** @internal */ _this._isRootCanvas = false, /** @internal */ _this._renderElements = [], /** @internal */ _this._batchedRenderElements = [], /** @internal */ _this._sortDistance = 0, /** @internal */ _this._orderedRenderers = [], /** @internal */ _this._realRenderMode = 4, /** @internal */ _this._disorderedElements = new DisorderedArray(), _this._renderMode = CanvasRenderMode.WorldSpace, _this._resolutionAdaptationMode = ResolutionAdaptationMode.HeightAdaptation, _this._sortOrder = 0, _this._distance = 10, _this._referenceResolution = new Vector2(800, 600), _this._referenceResolutionPerUnit = 100, _this._hierarchyVersion = -1, _this._center = new Vector3();
1420
- _this._onCanvasSizeListener = _this._onCanvasSizeListener.bind(_this);
1421
- _this._onCameraModifyListener = _this._onCameraModifyListener.bind(_this);
1422
- _this._onCameraTransformListener = _this._onCameraTransformListener.bind(_this);
1423
- _this._onReferenceResolutionChanged = _this._onReferenceResolutionChanged.bind(_this);
1424
- // @ts-ignore
1425
- _this._referenceResolution._onValueChanged = _this._onReferenceResolutionChanged;
1426
- _this._rootCanvasListener = _this._rootCanvasListener.bind(_this);
1427
- _this._centerDirtyFlag = entity.registerWorldChangeFlag();
2005
+ _this = _identity.apply(this, arguments) || this, _initClass$1();
1428
2006
  return _this;
1429
2007
  }
1430
- var _proto = UICanvas.prototype;
1431
- /**
2008
+ return _class;
2009
+ }(_identity), function() {
2010
+ var UICanvas = /*#__PURE__*/ function(_superClass) {
2011
+ _inherits(UICanvas, _superClass);
2012
+ function UICanvas(entity) {
2013
+ var _this;
2014
+ _this = _superClass.call(this, entity) || this, _this._canvasIndex = _init__canvasIndex(_this, -1), _this._indexInRootCanvas = _init__indexInRootCanvas$1(_this, -1), _this._isRootCanvasDirty = _init__isRootCanvasDirty$1(_this, false), _this._rootCanvasListeningEntities = _init__rootCanvasListeningEntities$1(_this, []), _this._isRootCanvas = _init__isRootCanvas(_this, false), _this._renderElements = _init__renderElements(_this, []), _this._batchedRenderElements = _init__batchedRenderElements(_this, []), _this._sortDistance = _init__sortDistance(_this, 0), _this._orderedRenderers = _init__orderedRenderers(_this, []), _this._realRenderMode = _init__realRenderMode(_this, 4), /** @internal */ _this._disorderedElements = new DisorderedArray(), _this._renderMode = _init__renderMode(_this, CanvasRenderMode.WorldSpace), _this._resolutionAdaptationMode = ResolutionAdaptationMode.HeightAdaptation, _this._sortOrder = 0, _this._distance = 10, _this._referenceResolution = new Vector2(800, 600), _this._referenceResolutionPerUnit = 100, _this._hierarchyVersion = _init__hierarchyVersion(_this, -1), _this._center = _init__center(_this, new Vector3());
2015
+ _this._onCanvasSizeListener = _this._onCanvasSizeListener.bind(_this);
2016
+ _this._onCameraModifyListener = _this._onCameraModifyListener.bind(_this);
2017
+ _this._onCameraTransformListener = _this._onCameraTransformListener.bind(_this);
2018
+ _this._onReferenceResolutionChanged = _this._onReferenceResolutionChanged.bind(_this);
2019
+ // @ts-ignore
2020
+ _this._referenceResolution._onValueChanged = _this._onReferenceResolutionChanged;
2021
+ _this._rootCanvasListener = _this._rootCanvasListener.bind(_this);
2022
+ _this._centerDirtyFlag = entity.registerWorldChangeFlag();
2023
+ return _this;
2024
+ }
2025
+ var _proto = UICanvas.prototype;
2026
+ /**
1432
2027
  * @internal
1433
2028
  */ _proto._raycast = function _raycast(ray, out, distance) {
1434
- if (distance === void 0) distance = Number.MAX_SAFE_INTEGER;
1435
- var renderers = this._getRenderers();
1436
- for(var i = renderers.length - 1; i >= 0; i--){
1437
- var element = renderers[i];
1438
- if (element.raycastEnabled && element._raycast(ray, out, distance)) {
1439
- return true;
2029
+ if (distance === void 0) distance = Number.MAX_SAFE_INTEGER;
2030
+ var renderers = this._getRenderers();
2031
+ for(var i = renderers.length - 1; i >= 0; i--){
2032
+ var element = renderers[i];
2033
+ if (element.raycastEnabled && element._raycast(ray, out, distance)) {
2034
+ return true;
2035
+ }
1440
2036
  }
1441
- }
1442
- out.component = null;
1443
- out.entity = null;
1444
- out.distance = 0;
1445
- out.point.set(0, 0, 0);
1446
- out.normal.set(0, 0, 0);
1447
- return false;
1448
- };
1449
- /**
2037
+ out.component = null;
2038
+ out.entity = null;
2039
+ out.distance = 0;
2040
+ out.point.set(0, 0, 0);
2041
+ out.normal.set(0, 0, 0);
2042
+ return false;
2043
+ };
2044
+ /**
1450
2045
  * @internal
1451
2046
  */ _proto._getRootCanvas = function _getRootCanvas() {
1452
- return this._rootCanvas;
1453
- };
1454
- /**
2047
+ return this._rootCanvas;
2048
+ };
2049
+ /**
1455
2050
  * @internal
1456
2051
  */ _proto._canRender = function _canRender(camera) {
1457
- return this._realRenderMode !== CanvasRenderMode.ScreenSpaceCamera || this._camera === camera;
1458
- };
1459
- /**
2052
+ return this._realRenderMode !== CanvasRenderMode.ScreenSpaceCamera || this._camera === camera;
2053
+ };
2054
+ /**
1460
2055
  * @internal
1461
2056
  */ _proto._canDispatchEvent = function _canDispatchEvent(camera) {
1462
- var realMode = this._realRenderMode;
1463
- if (realMode === CanvasRenderMode.ScreenSpaceOverlay) {
1464
- return true;
1465
- }
1466
- var assignedCamera = this._camera;
1467
- // @ts-ignore
1468
- return !assignedCamera || !assignedCamera._phasedActiveInScene || assignedCamera === camera;
1469
- };
1470
- /**
2057
+ var realMode = this._realRenderMode;
2058
+ if (realMode === CanvasRenderMode.ScreenSpaceOverlay) {
2059
+ return true;
2060
+ }
2061
+ var assignedCamera = this._camera;
2062
+ // @ts-ignore
2063
+ return !assignedCamera || !assignedCamera._phasedActiveInScene || assignedCamera === camera;
2064
+ };
2065
+ /**
1471
2066
  * @internal
1472
2067
  */ _proto._prepareRender = function _prepareRender(context) {
1473
- var _this = this, engine = _this.engine, mode = _this._realRenderMode;
1474
- var _context_camera = context.camera, enableFrustumCulling = _context_camera.enableFrustumCulling, cullingMask = _context_camera.cullingMask, frustum = _context_camera._frustum;
1475
- var frameCount = engine.time.frameCount;
1476
- var renderElements = this._renderElements;
1477
- renderElements.length = 0;
1478
- var virtualCamera = context.virtualCamera;
1479
- this._updateSortDistance(virtualCamera.isOrthographic, virtualCamera.position, virtualCamera.forward);
1480
- var _engine_canvas = engine.canvas, width = _engine_canvas.width, height = _engine_canvas.height;
1481
- var renderers = this._getRenderers();
1482
- for(var i = 0, n = renderers.length; i < n; i++){
1483
- var renderer = renderers[i];
1484
- // Filter by camera culling mask
1485
- if (!(cullingMask & renderer.entity.layer)) {
1486
- continue;
1487
- }
1488
- // Filter by camera frustum
1489
- if (enableFrustumCulling) {
1490
- switch(mode){
1491
- case CanvasRenderMode.ScreenSpaceOverlay:
1492
- var _renderer_bounds = renderer.bounds, min = _renderer_bounds.min, max = _renderer_bounds.max;
1493
- if (min.x > width || max.x < 0 || min.y > height || max.y < 0) {
1494
- continue;
1495
- }
1496
- break;
1497
- case CanvasRenderMode.ScreenSpaceCamera:
1498
- case CanvasRenderMode.WorldSpace:
1499
- if (!frustum.intersectsBox(renderer.bounds)) {
1500
- continue;
1501
- }
1502
- break;
2068
+ var _this = this, engine = _this.engine, mode = _this._realRenderMode;
2069
+ var _context_camera = context.camera, enableFrustumCulling = _context_camera.enableFrustumCulling, cullingMask = _context_camera.cullingMask, frustum = _context_camera._frustum;
2070
+ var frameCount = engine.time.frameCount;
2071
+ var renderElements = this._renderElements;
2072
+ renderElements.length = 0;
2073
+ var virtualCamera = context.virtualCamera;
2074
+ this._updateSortDistance(virtualCamera.isOrthographic, virtualCamera.position, virtualCamera.forward);
2075
+ var _engine_canvas = engine.canvas, width = _engine_canvas.width, height = _engine_canvas.height;
2076
+ var renderers = this._getRenderers();
2077
+ for(var i = 0, n = renderers.length; i < n; i++){
2078
+ var renderer = renderers[i];
2079
+ // Filter by camera culling mask
2080
+ if (!(cullingMask & renderer.entity.layer)) {
2081
+ continue;
1503
2082
  }
1504
- }
1505
- renderer._prepareRender(context);
1506
- renderer._renderFrameCount = frameCount;
1507
- }
1508
- var batchedRenderElements = this._batchedRenderElements;
1509
- batchedRenderElements.length = 0;
1510
- UIBatchSorter.sort(renderElements, this.entity.transform.worldMatrix);
1511
- engine._batcherManager.batch(renderElements, batchedRenderElements);
1512
- for(var i1 = 0, n1 = batchedRenderElements.length; i1 < n1; i1++){
1513
- batchedRenderElements[i1].subDistancePriority = i1;
1514
- }
1515
- };
1516
- /**
1517
- * @internal
1518
- */ _proto._updateSortDistance = function _updateSortDistance(isOrthographic, cameraPosition, cameraForward) {
1519
- switch(this._realRenderMode){
1520
- case CanvasRenderMode.ScreenSpaceOverlay:
1521
- this._sortDistance = 0;
1522
- break;
1523
- case CanvasRenderMode.ScreenSpaceCamera:
1524
- this._sortDistance = this._distance;
1525
- break;
1526
- case CanvasRenderMode.WorldSpace:
1527
- var boundsCenter = this._getCenter();
1528
- if (isOrthographic) {
1529
- var distance = UICanvas._tempVec3;
1530
- Vector3.subtract(boundsCenter, cameraPosition, distance);
1531
- this._sortDistance = Vector3.dot(distance, cameraForward);
1532
- } else {
1533
- this._sortDistance = Vector3.distanceSquared(boundsCenter, cameraPosition);
2083
+ // Filter by camera frustum
2084
+ if (enableFrustumCulling) {
2085
+ switch(mode){
2086
+ case CanvasRenderMode.ScreenSpaceOverlay:
2087
+ var _renderer_bounds = renderer.bounds, min = _renderer_bounds.min, max = _renderer_bounds.max;
2088
+ if (min.x > width || max.x < 0 || min.y > height || max.y < 0) {
2089
+ continue;
2090
+ }
2091
+ break;
2092
+ case CanvasRenderMode.ScreenSpaceCamera:
2093
+ case CanvasRenderMode.WorldSpace:
2094
+ if (!frustum.intersectsBox(renderer.bounds)) {
2095
+ continue;
2096
+ }
2097
+ break;
2098
+ }
1534
2099
  }
1535
- break;
1536
- }
1537
- };
1538
- // @ts-ignore
1539
- _proto._onEnableInScene = function _onEnableInScene() {
1540
- var entity = this.entity;
1541
- // @ts-ignore
1542
- entity._dispatchModify(4, this);
1543
- var rootCanvas = Utils.searchRootCanvasInParents(this);
1544
- this._setIsRootCanvas(!rootCanvas);
1545
- Utils.setRootCanvas(this, rootCanvas);
1546
- };
1547
- // @ts-ignore
1548
- _proto._onDisableInScene = function _onDisableInScene() {
1549
- this._setIsRootCanvas(false);
1550
- Utils.cleanRootCanvas(this);
1551
- };
1552
- // @ts-ignore
1553
- _proto._onDisable = function _onDisable() {
1554
- this._renderElements.length = 0;
1555
- this._batchedRenderElements.length = 0;
1556
- };
1557
- /**
1558
- * @internal
1559
- */ _proto._rootCanvasListener = function _rootCanvasListener(flag, param) {
1560
- if (this._isRootCanvas) {
1561
- if (flag === EntityModifyFlags.Parent) {
1562
- var rootCanvas = Utils.searchRootCanvasInParents(this);
1563
- this._setIsRootCanvas(!rootCanvas);
1564
- Utils.setRootCanvas(this, rootCanvas);
1565
- } else if (flag === 4) {
1566
- this._setIsRootCanvas(false);
1567
- Utils.setRootCanvas(this, param);
2100
+ renderer._prepareRender(context);
2101
+ renderer._renderFrameCount = frameCount;
1568
2102
  }
1569
- } else {
1570
- if (flag === EntityModifyFlags.Parent) {
1571
- var rootCanvas1 = Utils.searchRootCanvasInParents(this);
1572
- this._setIsRootCanvas(!rootCanvas1);
1573
- Utils.setRootCanvas(this, rootCanvas1);
2103
+ var batchedRenderElements = this._batchedRenderElements;
2104
+ batchedRenderElements.length = 0;
2105
+ UIBatchSorter.sort(renderElements, this.entity.transform.worldMatrix);
2106
+ engine._batcherManager.batch(renderElements, batchedRenderElements);
2107
+ for(var i1 = 0, n1 = batchedRenderElements.length; i1 < n1; i1++){
2108
+ batchedRenderElements[i1].subDistancePriority = i1;
1574
2109
  }
1575
- }
1576
- };
1577
- /**
1578
- * @inheritdoc
1579
- */ _proto._onClone = function _onClone(target) {
1580
- target.renderMode = this._renderMode;
1581
- };
1582
- _proto._getRenderers = function _getRenderers() {
1583
- var _this = this, renderers = _this._orderedRenderers, entity = _this.entity;
1584
- var uiHierarchyVersion = entity._uiHierarchyVersion;
1585
- if (this._hierarchyVersion !== uiHierarchyVersion) {
1586
- UICanvas._tempRectMaskList.length = 0;
1587
- renderers.length = this._walk(this.entity, renderers, 0, null, 0);
1588
- UICanvas._tempGroupAbleList.length = 0;
1589
- this._hierarchyVersion = uiHierarchyVersion;
1590
- ++UICanvas._hierarchyCounter;
1591
- }
1592
- return renderers;
1593
- };
1594
- _proto._adapterPoseInScreenSpace = function _adapterPoseInScreenSpace() {
1595
- var transform = this.entity.transform;
1596
- var realRenderMode = this._realRenderMode;
1597
- if (realRenderMode === CanvasRenderMode.ScreenSpaceCamera) {
1598
- var cameraEntity = this._camera.entity;
1599
- if (!this._isSameOrChildEntity(cameraEntity)) {
1600
- var cameraTransform = cameraEntity.transform;
1601
- var cameraWorldPosition = cameraTransform.worldPosition, cameraWorldForward = cameraTransform.worldForward;
1602
- var distance = this._distance;
1603
- transform.setWorldPosition(cameraWorldPosition.x + cameraWorldForward.x * distance, cameraWorldPosition.y + cameraWorldForward.y * distance, cameraWorldPosition.z + cameraWorldForward.z * distance);
1604
- transform.worldRotationQuaternion.copyFrom(cameraTransform.worldRotationQuaternion);
1605
- }
1606
- } else {
1607
- var canvas = this.engine.canvas;
1608
- transform.setWorldPosition(canvas.width * 0.5, canvas.height * 0.5, 0);
1609
- transform.worldRotationQuaternion.set(0, 0, 0, 1);
1610
- }
1611
- };
1612
- _proto._adapterSizeInScreenSpace = function _adapterSizeInScreenSpace() {
1613
- var transform = this.entity.transform;
1614
- var realRenderMode = this._realRenderMode;
1615
- var _this__referenceResolution = this._referenceResolution, width = _this__referenceResolution.x, height = _this__referenceResolution.y;
1616
- var curWidth;
1617
- var curHeight;
1618
- if (realRenderMode === CanvasRenderMode.ScreenSpaceCamera) {
1619
- var camera = this._camera;
1620
- curHeight = camera.isOrthographic ? camera.orthographicSize * 2 : 2 * (Math.tan(MathUtil.degreeToRadian(camera.fieldOfView * 0.5)) * this._distance);
1621
- curWidth = camera.aspectRatio * curHeight;
1622
- } else {
1623
- var canvas = this.engine.canvas;
1624
- curHeight = canvas.height;
1625
- curWidth = canvas.width;
1626
- }
1627
- var expectX, expectY, expectZ;
1628
- switch(this._resolutionAdaptationMode){
1629
- case ResolutionAdaptationMode.WidthAdaptation:
1630
- expectX = expectY = expectZ = curWidth / width;
1631
- break;
1632
- case ResolutionAdaptationMode.HeightAdaptation:
1633
- expectX = expectY = expectZ = curHeight / height;
1634
- break;
1635
- case ResolutionAdaptationMode.BothAdaptation:
1636
- expectX = curWidth / width;
1637
- expectY = curHeight / height;
1638
- expectZ = (expectX + expectY) * 0.5;
1639
- break;
1640
- case ResolutionAdaptationMode.ExpandAdaptation:
1641
- expectX = expectY = expectZ = Math.min(curWidth / width, curHeight / height);
1642
- break;
1643
- case ResolutionAdaptationMode.ShrinkAdaptation:
1644
- expectX = expectY = expectZ = Math.max(curWidth / width, curHeight / height);
1645
- break;
1646
- }
1647
- var worldMatrix = UICanvas._tempMat;
1648
- Matrix.affineTransformation(UICanvas._tempVec3.set(expectX, expectY, expectZ), transform.worldRotationQuaternion, transform.worldPosition, worldMatrix);
1649
- transform.worldMatrix = worldMatrix;
1650
- transform.size.set(curWidth / expectX, curHeight / expectY);
1651
- };
1652
- _proto._walk = function _walk(entity, renderers, depth, group, rectMaskCount) {
1653
- if (depth === void 0) depth = 0;
1654
- if (group === void 0) group = null;
1655
- if (rectMaskCount === void 0) rectMaskCount = 0;
2110
+ };
2111
+ /**
2112
+ * @internal
2113
+ */ _proto._updateSortDistance = function _updateSortDistance(isOrthographic, cameraPosition, cameraForward) {
2114
+ switch(this._realRenderMode){
2115
+ case CanvasRenderMode.ScreenSpaceOverlay:
2116
+ this._sortDistance = 0;
2117
+ break;
2118
+ case CanvasRenderMode.ScreenSpaceCamera:
2119
+ this._sortDistance = this._distance;
2120
+ break;
2121
+ case CanvasRenderMode.WorldSpace:
2122
+ var boundsCenter = this._getCenter();
2123
+ if (isOrthographic) {
2124
+ var distance = UICanvas._tempVec3;
2125
+ Vector3.subtract(boundsCenter, cameraPosition, distance);
2126
+ this._sortDistance = Vector3.dot(distance, cameraForward);
2127
+ } else {
2128
+ this._sortDistance = Vector3.distanceSquared(boundsCenter, cameraPosition);
2129
+ }
2130
+ break;
2131
+ }
2132
+ };
1656
2133
  // @ts-ignore
1657
- var components = entity._components;
1658
- var tempGroupAbleList = UICanvas._tempGroupAbleList;
1659
- var tempRectMaskList = UICanvas._tempRectMaskList;
1660
- var rectMask = null;
1661
- var groupAbleCount = 0;
1662
- for(var i = 0, n = components.length; i < n; i++){
1663
- var component = components[i];
1664
- if (!component.enabled) continue;
1665
- if (_instanceof(component, UIRenderer)) {
1666
- renderers[depth] = component;
1667
- ++depth;
1668
- component._isRootCanvasDirty && Utils.setRootCanvas(component, this);
1669
- if (component._isGroupDirty) {
1670
- tempGroupAbleList[groupAbleCount++] = component;
2134
+ _proto._onEnableInScene = function _onEnableInScene() {
2135
+ var entity = this.entity;
2136
+ // @ts-ignore
2137
+ entity._dispatchModify(4, this);
2138
+ var rootCanvas = Utils.searchRootCanvasInParents(this);
2139
+ this._setIsRootCanvas(!rootCanvas);
2140
+ Utils.setRootCanvas(this, rootCanvas);
2141
+ };
2142
+ // @ts-ignore
2143
+ _proto._onDisableInScene = function _onDisableInScene() {
2144
+ this._setIsRootCanvas(false);
2145
+ Utils.cleanRootCanvas(this);
2146
+ };
2147
+ // @ts-ignore
2148
+ _proto._onDisable = function _onDisable() {
2149
+ this._renderElements.length = 0;
2150
+ this._batchedRenderElements.length = 0;
2151
+ };
2152
+ /**
2153
+ * @internal
2154
+ */ _proto._rootCanvasListener = function _rootCanvasListener(flag, param) {
2155
+ if (this._isRootCanvas) {
2156
+ if (flag === EntityModifyFlags.Parent) {
2157
+ var rootCanvas = Utils.searchRootCanvasInParents(this);
2158
+ this._setIsRootCanvas(!rootCanvas);
2159
+ Utils.setRootCanvas(this, rootCanvas);
2160
+ } else if (flag === 4) {
2161
+ this._setIsRootCanvas(false);
2162
+ Utils.setRootCanvas(this, param);
1671
2163
  }
1672
- component._setRectMasks(tempRectMaskList, rectMaskCount);
1673
- } else if (_instanceof(component, UIInteractive)) {
1674
- component._isRootCanvasDirty && Utils.setRootCanvas(component, this);
1675
- if (component._isGroupDirty) {
1676
- tempGroupAbleList[groupAbleCount++] = component;
2164
+ } else {
2165
+ if (flag === EntityModifyFlags.Parent) {
2166
+ var rootCanvas1 = Utils.searchRootCanvasInParents(this);
2167
+ this._setIsRootCanvas(!rootCanvas1);
2168
+ Utils.setRootCanvas(this, rootCanvas1);
1677
2169
  }
1678
- } else if (_instanceof(component, RectMask2D)) {
1679
- rectMask = component;
1680
- } else if (_instanceof(component, UIGroup)) {
1681
- component._isRootCanvasDirty && Utils.setRootCanvas(component, this);
1682
- component._isGroupDirty && Utils.setGroup(component, group);
1683
- group = component;
1684
2170
  }
1685
- }
1686
- for(var i1 = 0; i1 < groupAbleCount; i1++){
1687
- Utils.setGroup(tempGroupAbleList[i1], group);
1688
- }
1689
- if (rectMask) {
1690
- tempRectMaskList[rectMaskCount++] = rectMask;
1691
- }
1692
- var children = entity.children;
1693
- for(var i2 = 0, n1 = children.length; i2 < n1; i2++){
1694
- var child = children[i2];
1695
- child.isActive && (depth = this._walk(child, renderers, depth, group, rectMaskCount));
1696
- }
1697
- return depth;
1698
- };
1699
- _proto._updateCameraObserver = function _updateCameraObserver() {
1700
- var camera = this._isRootCanvas && this._renderMode === CanvasRenderMode.ScreenSpaceCamera ? this._camera : null;
1701
- var preCamera = this._cameraObserver;
1702
- if (preCamera !== camera) {
1703
- this._cameraObserver = camera;
1704
- if (preCamera) {
1705
- // @ts-ignore
1706
- preCamera.entity._updateFlagManager.removeListener(this._onCameraTransformListener);
1707
- // @ts-ignore
1708
- preCamera._unRegisterModifyListener(this._onCameraModifyListener);
2171
+ };
2172
+ /**
2173
+ * @inheritdoc
2174
+ */ _proto._onClone = function _onClone(target) {
2175
+ target.renderMode = this._renderMode;
2176
+ };
2177
+ _proto._getRenderers = function _getRenderers() {
2178
+ var _this = this, renderers = _this._orderedRenderers, entity = _this.entity;
2179
+ var uiHierarchyVersion = entity._uiHierarchyVersion;
2180
+ if (this._hierarchyVersion !== uiHierarchyVersion) {
2181
+ UICanvas._tempRectMaskList.length = 0;
2182
+ renderers.length = this._walk(this.entity, renderers, 0, null, 0);
2183
+ UICanvas._tempGroupAbleList.length = 0;
2184
+ this._hierarchyVersion = uiHierarchyVersion;
2185
+ ++UICanvas._hierarchyCounter;
1709
2186
  }
1710
- if (camera) {
1711
- // @ts-ignore
1712
- camera.entity._updateFlagManager.addListener(this._onCameraTransformListener);
1713
- // @ts-ignore
1714
- camera._registerModifyListener(this._onCameraModifyListener);
2187
+ return renderers;
2188
+ };
2189
+ _proto._adapterPoseInScreenSpace = function _adapterPoseInScreenSpace() {
2190
+ var transform = this.entity.transform;
2191
+ var realRenderMode = this._realRenderMode;
2192
+ if (realRenderMode === CanvasRenderMode.ScreenSpaceCamera) {
2193
+ var cameraEntity = this._camera.entity;
2194
+ if (!this._isSameOrChildEntity(cameraEntity)) {
2195
+ var cameraTransform = cameraEntity.transform;
2196
+ var cameraWorldPosition = cameraTransform.worldPosition, cameraWorldForward = cameraTransform.worldForward;
2197
+ var distance = this._distance;
2198
+ transform.setWorldPosition(cameraWorldPosition.x + cameraWorldForward.x * distance, cameraWorldPosition.y + cameraWorldForward.y * distance, cameraWorldPosition.z + cameraWorldForward.z * distance);
2199
+ transform.worldRotationQuaternion.copyFrom(cameraTransform.worldRotationQuaternion);
2200
+ }
2201
+ } else {
2202
+ var canvas = this.engine.canvas;
2203
+ transform.setWorldPosition(canvas.width * 0.5, canvas.height * 0.5, 0);
2204
+ transform.worldRotationQuaternion.set(0, 0, 0, 1);
1715
2205
  }
1716
- }
1717
- };
1718
- _proto._onCameraModifyListener = function _onCameraModifyListener(flag) {
1719
- if (this._realRenderMode === CanvasRenderMode.ScreenSpaceCamera) {
1720
- switch(flag){
1721
- case CameraModifyFlags.ProjectionType:
1722
- case CameraModifyFlags.AspectRatio:
1723
- this._adapterSizeInScreenSpace();
2206
+ };
2207
+ _proto._adapterSizeInScreenSpace = function _adapterSizeInScreenSpace() {
2208
+ var transform = this.entity.transform;
2209
+ var realRenderMode = this._realRenderMode;
2210
+ var _this__referenceResolution = this._referenceResolution, width = _this__referenceResolution.x, height = _this__referenceResolution.y;
2211
+ var curWidth;
2212
+ var curHeight;
2213
+ if (realRenderMode === CanvasRenderMode.ScreenSpaceCamera) {
2214
+ var camera = this._camera;
2215
+ curHeight = camera.isOrthographic ? camera.orthographicSize * 2 : 2 * (Math.tan(MathUtil.degreeToRadian(camera.fieldOfView * 0.5)) * this._distance);
2216
+ curWidth = camera.aspectRatio * curHeight;
2217
+ } else {
2218
+ var canvas = this.engine.canvas;
2219
+ curHeight = canvas.height;
2220
+ curWidth = canvas.width;
2221
+ }
2222
+ var expectX, expectY, expectZ;
2223
+ switch(this._resolutionAdaptationMode){
2224
+ case ResolutionAdaptationMode.WidthAdaptation:
2225
+ expectX = expectY = expectZ = curWidth / width;
1724
2226
  break;
1725
- case CameraModifyFlags.FieldOfView:
1726
- !this._camera.isOrthographic && this._adapterSizeInScreenSpace();
2227
+ case ResolutionAdaptationMode.HeightAdaptation:
2228
+ expectX = expectY = expectZ = curHeight / height;
1727
2229
  break;
1728
- case CameraModifyFlags.OrthographicSize:
1729
- this._camera.isOrthographic && this._adapterSizeInScreenSpace();
2230
+ case ResolutionAdaptationMode.BothAdaptation:
2231
+ expectX = curWidth / width;
2232
+ expectY = curHeight / height;
2233
+ expectZ = (expectX + expectY) * 0.5;
1730
2234
  break;
1731
- case CameraModifyFlags.DisableInScene:
1732
- this._setRealRenderMode(CanvasRenderMode.ScreenSpaceOverlay);
2235
+ case ResolutionAdaptationMode.ExpandAdaptation:
2236
+ expectX = expectY = expectZ = Math.min(curWidth / width, curHeight / height);
2237
+ break;
2238
+ case ResolutionAdaptationMode.ShrinkAdaptation:
2239
+ expectX = expectY = expectZ = Math.max(curWidth / width, curHeight / height);
1733
2240
  break;
1734
2241
  }
1735
- } else {
1736
- flag === CameraModifyFlags.EnableInScene && this._setRealRenderMode(CanvasRenderMode.ScreenSpaceCamera);
1737
- }
1738
- };
1739
- _proto._onCameraTransformListener = function _onCameraTransformListener() {
1740
- this._realRenderMode === CanvasRenderMode.ScreenSpaceCamera && this._adapterPoseInScreenSpace();
1741
- };
1742
- _proto._addCanvasListener = function _addCanvasListener() {
1743
- // @ts-ignore
1744
- this.engine.canvas._sizeUpdateFlagManager.addListener(this._onCanvasSizeListener);
1745
- };
1746
- _proto._removeCanvasListener = function _removeCanvasListener() {
1747
- // @ts-ignore
1748
- this.engine.canvas._sizeUpdateFlagManager.removeListener(this._onCanvasSizeListener);
1749
- };
1750
- _proto._onCanvasSizeListener = function _onCanvasSizeListener() {
1751
- var canvas = this.engine.canvas;
1752
- this.entity.transform.setWorldPosition(canvas.width * 0.5, canvas.height * 0.5, 0);
1753
- this._adapterSizeInScreenSpace();
1754
- };
1755
- _proto._onReferenceResolutionChanged = function _onReferenceResolutionChanged() {
1756
- var realRenderMode = this._realRenderMode;
1757
- if (realRenderMode === CanvasRenderMode.ScreenSpaceOverlay || realRenderMode === CanvasRenderMode.ScreenSpaceCamera) {
1758
- this._adapterSizeInScreenSpace();
1759
- }
1760
- };
1761
- _proto._setIsRootCanvas = function _setIsRootCanvas(isRootCanvas) {
1762
- var _this = this;
1763
- if (this._isRootCanvas !== isRootCanvas) {
1764
- this._isRootCanvas = isRootCanvas;
1765
- this._updateCameraObserver();
1766
- this._setRealRenderMode(this._getRealRenderMode());
1767
- if (isRootCanvas) {
1768
- this.entity._updateUIHierarchyVersion(UICanvas._hierarchyCounter);
1769
- } else {
1770
- var _this1 = this, disorderedElements = _this1._disorderedElements;
1771
- disorderedElements.forEach(function(element) {
1772
- if (_instanceof(element, UICanvas)) {
1773
- var rootCanvas = Utils.searchRootCanvasInParents(element);
1774
- element._setIsRootCanvas(!rootCanvas);
1775
- Utils.setRootCanvas(element, rootCanvas);
1776
- } else {
1777
- Utils.setRootCanvasDirty(_this);
1778
- Utils.setGroupDirty(element);
2242
+ var worldMatrix = UICanvas._tempMat;
2243
+ Matrix.affineTransformation(UICanvas._tempVec3.set(expectX, expectY, expectZ), transform.worldRotationQuaternion, transform.worldPosition, worldMatrix);
2244
+ transform.worldMatrix = worldMatrix;
2245
+ transform.size.set(curWidth / expectX, curHeight / expectY);
2246
+ };
2247
+ _proto._walk = function _walk(entity, renderers, depth, group, rectMaskCount) {
2248
+ if (depth === void 0) depth = 0;
2249
+ if (group === void 0) group = null;
2250
+ if (rectMaskCount === void 0) rectMaskCount = 0;
2251
+ // @ts-ignore
2252
+ var components = entity._components;
2253
+ var tempGroupAbleList = UICanvas._tempGroupAbleList;
2254
+ var tempRectMaskList = UICanvas._tempRectMaskList;
2255
+ var rectMask = null;
2256
+ var groupAbleCount = 0;
2257
+ for(var i = 0, n = components.length; i < n; i++){
2258
+ var component = components[i];
2259
+ if (!component.enabled) continue;
2260
+ if (_instanceof(component, _UIRenderer)) {
2261
+ renderers[depth] = component;
2262
+ ++depth;
2263
+ component._isRootCanvasDirty && Utils.setRootCanvas(component, this);
2264
+ if (component._isGroupDirty) {
2265
+ tempGroupAbleList[groupAbleCount++] = component;
1779
2266
  }
1780
- });
1781
- disorderedElements.length = 0;
1782
- disorderedElements.garbageCollection();
1783
- this._orderedRenderers.length = 0;
2267
+ component._setRectMasks(tempRectMaskList, rectMaskCount);
2268
+ } else if (_instanceof(component, UIInteractive)) {
2269
+ component._isRootCanvasDirty && Utils.setRootCanvas(component, this);
2270
+ if (component._isGroupDirty) {
2271
+ tempGroupAbleList[groupAbleCount++] = component;
2272
+ }
2273
+ } else if (_instanceof(component, _RectMask2D)) {
2274
+ rectMask = component;
2275
+ } else if (_instanceof(component, UIGroup)) {
2276
+ component._isRootCanvasDirty && Utils.setRootCanvas(component, this);
2277
+ component._isGroupDirty && Utils.setGroup(component, group);
2278
+ group = component;
2279
+ }
1784
2280
  }
1785
- }
1786
- };
1787
- _proto._getCenter = function _getCenter() {
1788
- if (this._centerDirtyFlag.flag) {
1789
- var center = this._center;
1790
- var uiTransform = this.entity.transform;
1791
- var pivot = uiTransform.pivot, size = uiTransform.size;
1792
- center.set((0.5 - pivot.x) * size.x, (0.5 - pivot.y) * size.y, 0);
1793
- Vector3.transformCoordinate(center, uiTransform.worldMatrix, center);
1794
- this._centerDirtyFlag.flag = false;
1795
- }
1796
- return this._center;
1797
- };
1798
- _proto._getRealRenderMode = function _getRealRenderMode() {
1799
- if (this._isRootCanvas) {
1800
- var _this__camera;
1801
- var mode = this._renderMode;
1802
- // @ts-ignore
1803
- if (mode === CanvasRenderMode.ScreenSpaceCamera && !((_this__camera = this._camera) == null ? void 0 : _this__camera._phasedActiveInScene)) {
1804
- return CanvasRenderMode.ScreenSpaceOverlay;
2281
+ for(var i1 = 0; i1 < groupAbleCount; i1++){
2282
+ Utils.setGroup(tempGroupAbleList[i1], group);
2283
+ }
2284
+ if (rectMask) {
2285
+ tempRectMaskList[rectMaskCount++] = rectMask;
2286
+ }
2287
+ var children = entity.children;
2288
+ for(var i2 = 0, n1 = children.length; i2 < n1; i2++){
2289
+ var child = children[i2];
2290
+ child.isActive && (depth = this._walk(child, renderers, depth, group, rectMaskCount));
2291
+ }
2292
+ return depth;
2293
+ };
2294
+ _proto._updateCameraObserver = function _updateCameraObserver() {
2295
+ var camera = this._isRootCanvas && this._renderMode === CanvasRenderMode.ScreenSpaceCamera ? this._camera : null;
2296
+ var preCamera = this._cameraObserver;
2297
+ if (preCamera !== camera) {
2298
+ this._cameraObserver = camera;
2299
+ if (preCamera) {
2300
+ // @ts-ignore
2301
+ preCamera.entity._updateFlagManager.removeListener(this._onCameraTransformListener);
2302
+ // @ts-ignore
2303
+ preCamera._unRegisterModifyListener(this._onCameraModifyListener);
2304
+ }
2305
+ if (camera) {
2306
+ // @ts-ignore
2307
+ camera.entity._updateFlagManager.addListener(this._onCameraTransformListener);
2308
+ // @ts-ignore
2309
+ camera._registerModifyListener(this._onCameraModifyListener);
2310
+ }
2311
+ }
2312
+ };
2313
+ _proto._onCameraModifyListener = function _onCameraModifyListener(flag) {
2314
+ if (this._realRenderMode === CanvasRenderMode.ScreenSpaceCamera) {
2315
+ switch(flag){
2316
+ case CameraModifyFlags.ProjectionType:
2317
+ case CameraModifyFlags.AspectRatio:
2318
+ this._adapterSizeInScreenSpace();
2319
+ break;
2320
+ case CameraModifyFlags.FieldOfView:
2321
+ !this._camera.isOrthographic && this._adapterSizeInScreenSpace();
2322
+ break;
2323
+ case CameraModifyFlags.OrthographicSize:
2324
+ this._camera.isOrthographic && this._adapterSizeInScreenSpace();
2325
+ break;
2326
+ case CameraModifyFlags.DisableInScene:
2327
+ this._setRealRenderMode(CanvasRenderMode.ScreenSpaceOverlay);
2328
+ break;
2329
+ }
1805
2330
  } else {
1806
- return mode;
2331
+ flag === CameraModifyFlags.EnableInScene && this._setRealRenderMode(CanvasRenderMode.ScreenSpaceCamera);
1807
2332
  }
1808
- } else {
1809
- return 4;
1810
- }
1811
- };
1812
- _proto._setRealRenderMode = function _setRealRenderMode(curRealMode) {
1813
- var preRealMode = this._realRenderMode;
1814
- if (preRealMode !== curRealMode) {
1815
- this._realRenderMode = curRealMode;
2333
+ };
2334
+ _proto._onCameraTransformListener = function _onCameraTransformListener() {
2335
+ this._realRenderMode === CanvasRenderMode.ScreenSpaceCamera && this._adapterPoseInScreenSpace();
2336
+ };
2337
+ _proto._addCanvasListener = function _addCanvasListener() {
1816
2338
  // @ts-ignore
1817
- var componentsManager = this.scene._componentsManager;
1818
- switch(preRealMode){
1819
- case CanvasRenderMode.ScreenSpaceOverlay:
1820
- this._removeCanvasListener();
1821
- case CanvasRenderMode.ScreenSpaceCamera:
1822
- case CanvasRenderMode.WorldSpace:
1823
- componentsManager.removeUICanvas(this, preRealMode === CanvasRenderMode.ScreenSpaceOverlay);
1824
- break;
2339
+ this.engine.canvas._sizeUpdateFlagManager.addListener(this._onCanvasSizeListener);
2340
+ };
2341
+ _proto._removeCanvasListener = function _removeCanvasListener() {
2342
+ // @ts-ignore
2343
+ this.engine.canvas._sizeUpdateFlagManager.removeListener(this._onCanvasSizeListener);
2344
+ };
2345
+ _proto._onCanvasSizeListener = function _onCanvasSizeListener() {
2346
+ var canvas = this.engine.canvas;
2347
+ this.entity.transform.setWorldPosition(canvas.width * 0.5, canvas.height * 0.5, 0);
2348
+ this._adapterSizeInScreenSpace();
2349
+ };
2350
+ _proto._onReferenceResolutionChanged = function _onReferenceResolutionChanged() {
2351
+ var realRenderMode = this._realRenderMode;
2352
+ if (realRenderMode === CanvasRenderMode.ScreenSpaceOverlay || realRenderMode === CanvasRenderMode.ScreenSpaceCamera) {
2353
+ this._adapterSizeInScreenSpace();
1825
2354
  }
1826
- switch(curRealMode){
1827
- case CanvasRenderMode.ScreenSpaceOverlay:
1828
- this._addCanvasListener();
1829
- case CanvasRenderMode.ScreenSpaceCamera:
1830
- this._adapterPoseInScreenSpace();
1831
- this._adapterSizeInScreenSpace();
1832
- case CanvasRenderMode.WorldSpace:
1833
- componentsManager.addUICanvas(this, curRealMode === CanvasRenderMode.ScreenSpaceOverlay);
1834
- break;
2355
+ };
2356
+ _proto._setIsRootCanvas = function _setIsRootCanvas(isRootCanvas) {
2357
+ var _this = this;
2358
+ if (this._isRootCanvas !== isRootCanvas) {
2359
+ this._isRootCanvas = isRootCanvas;
2360
+ this._updateCameraObserver();
2361
+ this._setRealRenderMode(this._getRealRenderMode());
2362
+ if (isRootCanvas) {
2363
+ this.entity._updateUIHierarchyVersion(UICanvas._hierarchyCounter);
2364
+ } else {
2365
+ var _this1 = this, disorderedElements = _this1._disorderedElements;
2366
+ disorderedElements.forEach(function(element) {
2367
+ if (_instanceof(element, UICanvas)) {
2368
+ var rootCanvas = Utils.searchRootCanvasInParents(element);
2369
+ element._setIsRootCanvas(!rootCanvas);
2370
+ Utils.setRootCanvas(element, rootCanvas);
2371
+ } else {
2372
+ Utils.setRootCanvasDirty(_this);
2373
+ Utils.setGroupDirty(element);
2374
+ }
2375
+ });
2376
+ disorderedElements.length = 0;
2377
+ disorderedElements.garbageCollection();
2378
+ this._orderedRenderers.length = 0;
2379
+ }
1835
2380
  }
1836
- }
1837
- };
1838
- _proto._isSameOrChildEntity = function _isSameOrChildEntity(cameraEntity) {
1839
- var canvasEntity = this.entity;
1840
- while(cameraEntity){
1841
- if (cameraEntity === canvasEntity) return true;
1842
- cameraEntity = cameraEntity.parent;
1843
- }
1844
- return false;
1845
- };
1846
- _create_class(UICanvas, [
1847
- {
1848
- key: "referenceResolutionPerUnit",
1849
- get: /**
2381
+ };
2382
+ _proto._getCenter = function _getCenter() {
2383
+ if (this._centerDirtyFlag.flag) {
2384
+ var center = this._center;
2385
+ var uiTransform = this.entity.transform;
2386
+ var pivot = uiTransform.pivot, size = uiTransform.size;
2387
+ center.set((0.5 - pivot.x) * size.x, (0.5 - pivot.y) * size.y, 0);
2388
+ Vector3.transformCoordinate(center, uiTransform.worldMatrix, center);
2389
+ this._centerDirtyFlag.flag = false;
2390
+ }
2391
+ return this._center;
2392
+ };
2393
+ _proto._getRealRenderMode = function _getRealRenderMode() {
2394
+ if (this._isRootCanvas) {
2395
+ var _this__camera;
2396
+ var mode = this._renderMode;
2397
+ // @ts-ignore
2398
+ if (mode === CanvasRenderMode.ScreenSpaceCamera && !((_this__camera = this._camera) == null ? void 0 : _this__camera._phasedActiveInScene)) {
2399
+ return CanvasRenderMode.ScreenSpaceOverlay;
2400
+ } else {
2401
+ return mode;
2402
+ }
2403
+ } else {
2404
+ return 4;
2405
+ }
2406
+ };
2407
+ _proto._setRealRenderMode = function _setRealRenderMode(curRealMode) {
2408
+ var preRealMode = this._realRenderMode;
2409
+ if (preRealMode !== curRealMode) {
2410
+ this._realRenderMode = curRealMode;
2411
+ // @ts-ignore
2412
+ var componentsManager = this.scene._componentsManager;
2413
+ switch(preRealMode){
2414
+ case CanvasRenderMode.ScreenSpaceOverlay:
2415
+ this._removeCanvasListener();
2416
+ case CanvasRenderMode.ScreenSpaceCamera:
2417
+ case CanvasRenderMode.WorldSpace:
2418
+ componentsManager.removeUICanvas(this, preRealMode === CanvasRenderMode.ScreenSpaceOverlay);
2419
+ break;
2420
+ }
2421
+ switch(curRealMode){
2422
+ case CanvasRenderMode.ScreenSpaceOverlay:
2423
+ this._addCanvasListener();
2424
+ case CanvasRenderMode.ScreenSpaceCamera:
2425
+ this._adapterPoseInScreenSpace();
2426
+ this._adapterSizeInScreenSpace();
2427
+ case CanvasRenderMode.WorldSpace:
2428
+ componentsManager.addUICanvas(this, curRealMode === CanvasRenderMode.ScreenSpaceOverlay);
2429
+ break;
2430
+ }
2431
+ }
2432
+ };
2433
+ _proto._isSameOrChildEntity = function _isSameOrChildEntity(cameraEntity) {
2434
+ var canvasEntity = this.entity;
2435
+ while(cameraEntity){
2436
+ if (cameraEntity === canvasEntity) return true;
2437
+ cameraEntity = cameraEntity.parent;
2438
+ }
2439
+ return false;
2440
+ };
2441
+ _create_class(UICanvas, [
2442
+ {
2443
+ key: "referenceResolutionPerUnit",
2444
+ get: /**
1850
2445
  * The conversion ratio between reference resolution and unit for UI elements in this canvas.
1851
2446
  */ function get() {
1852
- return this._referenceResolutionPerUnit;
1853
- },
1854
- set: function set(value) {
1855
- if (this._referenceResolutionPerUnit !== value) {
1856
- this._referenceResolutionPerUnit = value;
1857
- this._disorderedElements.forEach(function(element) {
1858
- element._onRootCanvasModify == null ? void 0 : element._onRootCanvasModify.call(element, 1);
1859
- });
2447
+ return this._referenceResolutionPerUnit;
2448
+ },
2449
+ set: function set(value) {
2450
+ if (this._referenceResolutionPerUnit !== value) {
2451
+ this._referenceResolutionPerUnit = value;
2452
+ this._disorderedElements.forEach(function(element) {
2453
+ element._onRootCanvasModify == null ? void 0 : element._onRootCanvasModify.call(element, 1);
2454
+ });
2455
+ }
1860
2456
  }
1861
- }
1862
- },
1863
- {
1864
- key: "referenceResolution",
1865
- get: /**
2457
+ },
2458
+ {
2459
+ key: "referenceResolution",
2460
+ get: /**
1866
2461
  * The reference resolution of the UI canvas in `ScreenSpaceCamera` and `ScreenSpaceOverlay` mode.
1867
2462
  */ function get() {
1868
- return this._referenceResolution;
2463
+ return this._referenceResolution;
2464
+ },
2465
+ set: function set(value) {
2466
+ var referenceResolution = this._referenceResolution;
2467
+ if (referenceResolution === value) return;
2468
+ (referenceResolution.x !== value.x || referenceResolution.y !== value.y) && referenceResolution.copyFrom(value);
2469
+ }
1869
2470
  },
1870
- set: function set(value) {
1871
- var referenceResolution = this._referenceResolution;
1872
- if (referenceResolution === value) return;
1873
- (referenceResolution.x !== value.x || referenceResolution.y !== value.y) && referenceResolution.copyFrom(value);
1874
- }
1875
- },
1876
- {
1877
- key: "renderMode",
1878
- get: /**
2471
+ {
2472
+ key: "renderMode",
2473
+ get: /**
1879
2474
  * The rendering mode of the UI canvas.
1880
2475
  */ function get() {
1881
- return this._renderMode;
1882
- },
1883
- set: function set(mode) {
1884
- var preMode = this._renderMode;
1885
- if (preMode !== mode) {
1886
- this._renderMode = mode;
1887
- this._updateCameraObserver();
1888
- this._setRealRenderMode(this._getRealRenderMode());
2476
+ return this._renderMode;
2477
+ },
2478
+ set: function set(mode) {
2479
+ var preMode = this._renderMode;
2480
+ if (preMode !== mode) {
2481
+ this._renderMode = mode;
2482
+ this._updateCameraObserver();
2483
+ this._setRealRenderMode(this._getRealRenderMode());
2484
+ }
1889
2485
  }
1890
- }
1891
- },
1892
- {
1893
- key: "camera",
1894
- get: /**
2486
+ },
2487
+ {
2488
+ key: "camera",
2489
+ get: /**
1895
2490
  * The camera associated with this canvas.
1896
2491
  * @remarks
1897
2492
  * - `ScreenSpaceCamera` mode: Used for rendering adaptation. Defaults to `ScreenSpaceOverlay` if not assigned.
1898
2493
  * - `WorldSpace` mode: Used for event detection. If not assigned, events are handled by the highest-priority camera.
1899
2494
  */ function get() {
1900
- return this._camera;
1901
- },
1902
- set: function set(value) {
1903
- var preCamera = this._camera;
1904
- if (preCamera !== value) {
1905
- if (value && this._isSameOrChildEntity(value.entity)) {
1906
- Logger.warn("Camera entity matching or nested within the canvas entity disables canvas auto-adaptation in ScreenSpaceCamera mode.");
1907
- }
1908
- this._camera = value;
1909
- this._updateCameraObserver();
1910
- var preRenderMode = this._realRenderMode;
1911
- var curRenderMode = this._getRealRenderMode();
1912
- if (preRenderMode === curRenderMode) {
1913
- if (curRenderMode === CanvasRenderMode.ScreenSpaceCamera) {
1914
- this._adapterPoseInScreenSpace();
1915
- this._adapterSizeInScreenSpace();
2495
+ return this._camera;
2496
+ },
2497
+ set: function set(value) {
2498
+ var preCamera = this._camera;
2499
+ if (preCamera !== value) {
2500
+ if (value && this._isSameOrChildEntity(value.entity)) {
2501
+ Logger.warn("Camera entity matching or nested within the canvas entity disables canvas auto-adaptation in ScreenSpaceCamera mode.");
2502
+ }
2503
+ this._camera = value;
2504
+ this._updateCameraObserver();
2505
+ var preRenderMode = this._realRenderMode;
2506
+ var curRenderMode = this._getRealRenderMode();
2507
+ if (preRenderMode === curRenderMode) {
2508
+ if (curRenderMode === CanvasRenderMode.ScreenSpaceCamera) {
2509
+ this._adapterPoseInScreenSpace();
2510
+ this._adapterSizeInScreenSpace();
2511
+ }
2512
+ } else {
2513
+ this._setRealRenderMode(curRenderMode);
1916
2514
  }
1917
- } else {
1918
- this._setRealRenderMode(curRenderMode);
1919
2515
  }
1920
2516
  }
1921
- }
1922
- },
1923
- {
1924
- key: "renderCamera",
1925
- get: /**
2517
+ },
2518
+ {
2519
+ key: "renderCamera",
2520
+ get: /**
1926
2521
  * @deprecated Use {@link camera} instead.
1927
2522
  */ function get() {
1928
- return this.camera;
2523
+ return this.camera;
2524
+ },
2525
+ set: function set(value) {
2526
+ this.camera = value;
2527
+ }
1929
2528
  },
1930
- set: function set(value) {
1931
- this.camera = value;
1932
- }
1933
- },
1934
- {
1935
- key: "resolutionAdaptationMode",
1936
- get: /**
2529
+ {
2530
+ key: "resolutionAdaptationMode",
2531
+ get: /**
1937
2532
  * The screen resolution adaptation mode of the UI canvas in `ScreenSpaceCamera` and `ScreenSpaceOverlay` mode.
1938
2533
  */ function get() {
1939
- return this._resolutionAdaptationMode;
1940
- },
1941
- set: function set(value) {
1942
- if (this._resolutionAdaptationMode !== value) {
1943
- this._resolutionAdaptationMode = value;
1944
- var realRenderMode = this._realRenderMode;
1945
- if (realRenderMode === CanvasRenderMode.ScreenSpaceCamera || realRenderMode === CanvasRenderMode.ScreenSpaceOverlay) {
1946
- this._adapterSizeInScreenSpace();
2534
+ return this._resolutionAdaptationMode;
2535
+ },
2536
+ set: function set(value) {
2537
+ if (this._resolutionAdaptationMode !== value) {
2538
+ this._resolutionAdaptationMode = value;
2539
+ var realRenderMode = this._realRenderMode;
2540
+ if (realRenderMode === CanvasRenderMode.ScreenSpaceCamera || realRenderMode === CanvasRenderMode.ScreenSpaceOverlay) {
2541
+ this._adapterSizeInScreenSpace();
2542
+ }
1947
2543
  }
1948
2544
  }
1949
- }
1950
- },
1951
- {
1952
- key: "sortOrder",
1953
- get: /**
2545
+ },
2546
+ {
2547
+ key: "sortOrder",
2548
+ get: /**
1954
2549
  * The rendering order priority of the UI canvas in `ScreenSpaceOverlay` mode.
1955
2550
  */ function get() {
1956
- return this._sortOrder;
1957
- },
1958
- set: function set(value) {
1959
- if (this._sortOrder !== value) {
1960
- this._sortOrder = value;
1961
- this._realRenderMode === CanvasRenderMode.ScreenSpaceOverlay && // @ts-ignore
1962
- (this.scene._componentsManager._overlayCanvasesSortingFlag = true);
2551
+ return this._sortOrder;
2552
+ },
2553
+ set: function set(value) {
2554
+ if (this._sortOrder !== value) {
2555
+ this._sortOrder = value;
2556
+ this._realRenderMode === CanvasRenderMode.ScreenSpaceOverlay && // @ts-ignore
2557
+ (this.scene._componentsManager._overlayCanvasesSortingFlag = true);
2558
+ }
1963
2559
  }
1964
- }
1965
- },
1966
- {
1967
- key: "distance",
1968
- get: /**
2560
+ },
2561
+ {
2562
+ key: "distance",
2563
+ get: /**
1969
2564
  * The distance between the UI canvas and the camera in `ScreenSpaceCamera` mode.
1970
2565
  */ function get() {
1971
- return this._distance;
1972
- },
1973
- set: function set(value) {
1974
- if (this._distance !== value) {
1975
- this._distance = value;
1976
- if (this._realRenderMode === CanvasRenderMode.ScreenSpaceCamera) {
1977
- this._adapterPoseInScreenSpace();
1978
- this._adapterSizeInScreenSpace();
2566
+ return this._distance;
2567
+ },
2568
+ set: function set(value) {
2569
+ if (this._distance !== value) {
2570
+ this._distance = value;
2571
+ if (this._realRenderMode === CanvasRenderMode.ScreenSpaceCamera) {
2572
+ this._adapterPoseInScreenSpace();
2573
+ this._adapterSizeInScreenSpace();
2574
+ }
1979
2575
  }
1980
2576
  }
1981
2577
  }
1982
- }
1983
- ]);
1984
- return UICanvas;
1985
- }(Component);
1986
- /** @internal */ UICanvas._hierarchyCounter = 1;
1987
- UICanvas._tempGroupAbleList = [];
1988
- UICanvas._tempRectMaskList = [];
1989
- UICanvas._tempVec3 = new Vector3();
1990
- UICanvas._tempMat = new Matrix();
1991
- __decorate([
1992
- ignoreClone
1993
- ], UICanvas.prototype, "_canvasIndex", void 0);
1994
- __decorate([
1995
- ignoreClone
1996
- ], UICanvas.prototype, "_indexInRootCanvas", void 0);
1997
- __decorate([
1998
- ignoreClone
1999
- ], UICanvas.prototype, "_isRootCanvasDirty", void 0);
2000
- __decorate([
2001
- ignoreClone
2002
- ], UICanvas.prototype, "_rootCanvasListeningEntities", void 0);
2003
- __decorate([
2004
- ignoreClone
2005
- ], UICanvas.prototype, "_isRootCanvas", void 0);
2006
- __decorate([
2007
- ignoreClone
2008
- ], UICanvas.prototype, "_renderElements", void 0);
2009
- __decorate([
2010
- ignoreClone
2011
- ], UICanvas.prototype, "_batchedRenderElements", void 0);
2012
- __decorate([
2013
- ignoreClone
2014
- ], UICanvas.prototype, "_sortDistance", void 0);
2015
- __decorate([
2016
- ignoreClone
2017
- ], UICanvas.prototype, "_orderedRenderers", void 0);
2018
- __decorate([
2019
- ignoreClone
2020
- ], UICanvas.prototype, "_realRenderMode", void 0);
2021
- __decorate([
2022
- ignoreClone
2023
- ], UICanvas.prototype, "_renderMode", void 0);
2024
- __decorate([
2025
- ignoreClone
2026
- ], UICanvas.prototype, "_hierarchyVersion", void 0);
2027
- __decorate([
2028
- ignoreClone
2029
- ], UICanvas.prototype, "_center", void 0);
2030
- __decorate([
2031
- ignoreClone
2032
- ], UICanvas.prototype, "_rootCanvasListener", null);
2033
- __decorate([
2034
- ignoreClone
2035
- ], UICanvas.prototype, "_onCameraModifyListener", null);
2036
- __decorate([
2037
- ignoreClone
2038
- ], UICanvas.prototype, "_onCameraTransformListener", null);
2039
- __decorate([
2040
- ignoreClone
2041
- ], UICanvas.prototype, "_onCanvasSizeListener", null);
2042
- __decorate([
2043
- ignoreClone
2044
- ], UICanvas.prototype, "_onReferenceResolutionChanged", null);
2045
- UICanvas = __decorate([
2046
- dependentComponents(UITransform, DependentMode.AutoAdd)
2047
- ], UICanvas);
2578
+ ]);
2579
+ return UICanvas;
2580
+ }(_Component = Component);
2581
+ var ref, ref1, ref2;
2582
+ ref = _apply_decs_2203_r(UICanvas, [
2583
+ [
2584
+ ignoreClone,
2585
+ 0,
2586
+ "_canvasIndex"
2587
+ ],
2588
+ [
2589
+ ignoreClone,
2590
+ 0,
2591
+ "_indexInRootCanvas"
2592
+ ],
2593
+ [
2594
+ ignoreClone,
2595
+ 0,
2596
+ "_isRootCanvasDirty"
2597
+ ],
2598
+ [
2599
+ ignoreClone,
2600
+ 0,
2601
+ "_rootCanvasListeningEntities"
2602
+ ],
2603
+ [
2604
+ ignoreClone,
2605
+ 0,
2606
+ "_isRootCanvas"
2607
+ ],
2608
+ [
2609
+ ignoreClone,
2610
+ 0,
2611
+ "_renderElements"
2612
+ ],
2613
+ [
2614
+ ignoreClone,
2615
+ 0,
2616
+ "_batchedRenderElements"
2617
+ ],
2618
+ [
2619
+ ignoreClone,
2620
+ 0,
2621
+ "_sortDistance"
2622
+ ],
2623
+ [
2624
+ ignoreClone,
2625
+ 0,
2626
+ "_orderedRenderers"
2627
+ ],
2628
+ [
2629
+ ignoreClone,
2630
+ 0,
2631
+ "_realRenderMode"
2632
+ ],
2633
+ [
2634
+ ignoreClone,
2635
+ 0,
2636
+ "_renderMode"
2637
+ ],
2638
+ [
2639
+ ignoreClone,
2640
+ 0,
2641
+ "_hierarchyVersion"
2642
+ ],
2643
+ [
2644
+ ignoreClone,
2645
+ 0,
2646
+ "_center"
2647
+ ]
2648
+ ], [
2649
+ _dec$1
2650
+ ], _Component), ref1 = ref.e, _init__canvasIndex = ref1[0], _init__indexInRootCanvas$1 = ref1[1], _init__isRootCanvasDirty$1 = ref1[2], _init__rootCanvasListeningEntities$1 = ref1[3], _init__isRootCanvas = ref1[4], _init__renderElements = ref1[5], _init__batchedRenderElements = ref1[6], _init__sortDistance = ref1[7], _init__orderedRenderers = ref1[8], _init__realRenderMode = ref1[9], _init__renderMode = ref1[10], _init__hierarchyVersion = ref1[11], _init__center = ref1[12], ref2 = ref.c, _UICanvas = ref2[0], _initClass$1 = ref2[1];
2651
+ /** @internal */ UICanvas._hierarchyCounter = 1;
2652
+ UICanvas._tempGroupAbleList = [];
2653
+ UICanvas._tempRectMaskList = [];
2654
+ UICanvas._tempVec3 = new Vector3();
2655
+ UICanvas._tempMat = new Matrix();
2656
+ }(), _class$1)();
2048
2657
  /**
2049
2658
  * @remarks Extends `EntityModifyFlags`.
2050
2659
  */ var EntityUIModifyFlags = /*#__PURE__*/ function(EntityUIModifyFlags) {
@@ -2073,7 +2682,7 @@ var Utils = /*#__PURE__*/ function() {
2073
2682
  var components = entity._components;
2074
2683
  for(var i = 0, n = components.length; i < n; i++){
2075
2684
  var component = components[i];
2076
- if (component.enabled && _instanceof(component, UICanvas) && component._isRootCanvas) {
2685
+ if (component.enabled && _instanceof(component, _UICanvas) && component._isRootCanvas) {
2077
2686
  rootCanvas = component;
2078
2687
  }
2079
2688
  }
@@ -2118,7 +2727,7 @@ var Utils = /*#__PURE__*/ function() {
2118
2727
  Utils.setRootCanvas = function setRootCanvas(element, rootCanvas) {
2119
2728
  element._isRootCanvasDirty = false;
2120
2729
  this._registerRootCanvas(element, rootCanvas);
2121
- var fromEntity = _instanceof(element, UICanvas) ? element.entity.parent : element.entity;
2730
+ var fromEntity = _instanceof(element, _UICanvas) ? element.entity.parent : element.entity;
2122
2731
  var _rootCanvas_entity_parent;
2123
2732
  var toEntity = (_rootCanvas_entity_parent = rootCanvas == null ? void 0 : rootCanvas.entity.parent) != null ? _rootCanvas_entity_parent : null;
2124
2733
  this._registerListener(fromEntity, toEntity, element._rootCanvasListener, element._rootCanvasListeningEntities);
@@ -2128,13 +2737,13 @@ var Utils = /*#__PURE__*/ function() {
2128
2737
  this._unRegisterListener(element._rootCanvasListener, element._rootCanvasListeningEntities);
2129
2738
  };
2130
2739
  Utils.searchRootCanvasInParents = function searchRootCanvasInParents(element) {
2131
- var entity = _instanceof(element, UICanvas) ? element.entity.parent : element.entity;
2740
+ var entity = _instanceof(element, _UICanvas) ? element.entity.parent : element.entity;
2132
2741
  while(entity){
2133
2742
  // @ts-ignore
2134
2743
  var components = entity._components;
2135
2744
  for(var i = 0, n = components.length; i < n; i++){
2136
2745
  var component = components[i];
2137
- if (component.enabled && _instanceof(component, UICanvas) && component._isRootCanvas) {
2746
+ if (component.enabled && _instanceof(component, _UICanvas) && component._isRootCanvas) {
2138
2747
  return component;
2139
2748
  }
2140
2749
  }
@@ -2246,13 +2855,14 @@ Utils._tempPlane = new Plane();
2246
2855
  Utils._tempVec3 = new Vector3();
2247
2856
  Utils._tempMat = new Matrix();
2248
2857
 
2858
+ var /** @internal */ _init__indexInRootCanvas, /** @internal */ _init__isRootCanvasDirty, /** @internal */ _init__rootCanvasListeningEntities, /** @internal */ _init__indexInGroup, /** @internal */ _init__isGroupDirty, /** @internal */ _init__groupListeningEntities, /** @internal */ _init__globalInteractive, /** @internal */ _init__globalInteractiveDirty, _init__state, /** @todo Multi-touch points are not considered yet. */ _init__isPointerInside, _init__isPointerDragging;
2249
2859
  /**
2250
2860
  * Interactive component.
2251
2861
  */ var UIInteractive = /*#__PURE__*/ function(Script) {
2252
2862
  _inherits(UIInteractive, Script);
2253
2863
  function UIInteractive(entity) {
2254
2864
  var _this;
2255
- _this = Script.call(this, entity) || this, /** @internal */ _this._indexInRootCanvas = -1, /** @internal */ _this._isRootCanvasDirty = false, /** @internal */ _this._rootCanvasListeningEntities = [], /** @internal */ _this._indexInGroup = -1, /** @internal */ _this._isGroupDirty = false, /** @internal */ _this._groupListeningEntities = [], /** @internal */ _this._globalInteractive = false, /** @internal */ _this._globalInteractiveDirty = false, _this._transitions = [], _this._interactive = true, _this._state = 0, /** @todo Multi-touch points are not considered yet. */ _this._isPointerInside = false, _this._isPointerDragging = false;
2865
+ _this = Script.call(this, entity) || this, _this._indexInRootCanvas = _init__indexInRootCanvas(_this, -1), _this._isRootCanvasDirty = _init__isRootCanvasDirty(_this, false), _this._rootCanvasListeningEntities = _init__rootCanvasListeningEntities(_this, []), _this._indexInGroup = _init__indexInGroup(_this, -1), _this._isGroupDirty = _init__isGroupDirty(_this, false), _this._groupListeningEntities = _init__groupListeningEntities(_this, []), _this._globalInteractive = _init__globalInteractive(_this, false), _this._globalInteractiveDirty = _init__globalInteractiveDirty(_this, false), _this._transitions = [], _this._interactive = true, _this._state = _init__state(_this, 0), _this._isPointerInside = _init__isPointerInside(_this, false), _this._isPointerDragging = _init__isPointerDragging(_this, false);
2256
2866
  _this._groupListener = _this._groupListener.bind(_this);
2257
2867
  _this._rootCanvasListener = _this._rootCanvasListener.bind(_this);
2258
2868
  return _this;
@@ -2435,48 +3045,64 @@ Utils._tempMat = new Matrix();
2435
3045
  ]);
2436
3046
  return UIInteractive;
2437
3047
  }(Script);
2438
- __decorate([
2439
- ignoreClone
2440
- ], UIInteractive.prototype, "_indexInRootCanvas", void 0);
2441
- __decorate([
2442
- ignoreClone
2443
- ], UIInteractive.prototype, "_isRootCanvasDirty", void 0);
2444
- __decorate([
2445
- ignoreClone
2446
- ], UIInteractive.prototype, "_rootCanvasListeningEntities", void 0);
2447
- __decorate([
2448
- ignoreClone
2449
- ], UIInteractive.prototype, "_indexInGroup", void 0);
2450
- __decorate([
2451
- ignoreClone
2452
- ], UIInteractive.prototype, "_isGroupDirty", void 0);
2453
- __decorate([
2454
- ignoreClone
2455
- ], UIInteractive.prototype, "_groupListeningEntities", void 0);
2456
- __decorate([
2457
- ignoreClone
2458
- ], UIInteractive.prototype, "_globalInteractive", void 0);
2459
- __decorate([
2460
- ignoreClone
2461
- ], UIInteractive.prototype, "_globalInteractiveDirty", void 0);
2462
- __decorate([
2463
- ignoreClone
2464
- ], UIInteractive.prototype, "_state", void 0);
2465
- __decorate([
2466
- ignoreClone
2467
- ], UIInteractive.prototype, "_isPointerInside", void 0);
2468
- __decorate([
2469
- ignoreClone
2470
- ], UIInteractive.prototype, "_isPointerDragging", void 0);
2471
- __decorate([
2472
- ignoreClone
2473
- ], UIInteractive.prototype, "_groupListener", null);
2474
- __decorate([
2475
- ignoreClone
2476
- ], UIInteractive.prototype, "_rootCanvasListener", null);
2477
- __decorate([
2478
- ignoreClone
2479
- ], UIInteractive.prototype, "_onGroupModify", null);
3048
+ var ref$3, ref1$3;
3049
+ ref$3 = _apply_decs_2203_r(UIInteractive, [
3050
+ [
3051
+ ignoreClone,
3052
+ 0,
3053
+ "_indexInRootCanvas"
3054
+ ],
3055
+ [
3056
+ ignoreClone,
3057
+ 0,
3058
+ "_isRootCanvasDirty"
3059
+ ],
3060
+ [
3061
+ ignoreClone,
3062
+ 0,
3063
+ "_rootCanvasListeningEntities"
3064
+ ],
3065
+ [
3066
+ ignoreClone,
3067
+ 0,
3068
+ "_indexInGroup"
3069
+ ],
3070
+ [
3071
+ ignoreClone,
3072
+ 0,
3073
+ "_isGroupDirty"
3074
+ ],
3075
+ [
3076
+ ignoreClone,
3077
+ 0,
3078
+ "_groupListeningEntities"
3079
+ ],
3080
+ [
3081
+ ignoreClone,
3082
+ 0,
3083
+ "_globalInteractive"
3084
+ ],
3085
+ [
3086
+ ignoreClone,
3087
+ 0,
3088
+ "_globalInteractiveDirty"
3089
+ ],
3090
+ [
3091
+ ignoreClone,
3092
+ 0,
3093
+ "_state"
3094
+ ],
3095
+ [
3096
+ ignoreClone,
3097
+ 0,
3098
+ "_isPointerInside"
3099
+ ],
3100
+ [
3101
+ ignoreClone,
3102
+ 0,
3103
+ "_isPointerDragging"
3104
+ ]
3105
+ ], []), ref1$3 = ref$3.e, _init__indexInRootCanvas = ref1$3[0], _init__isRootCanvasDirty = ref1$3[1], _init__rootCanvasListeningEntities = ref1$3[2], _init__indexInGroup = ref1$3[3], _init__isGroupDirty = ref1$3[4], _init__groupListeningEntities = ref1$3[5], _init__globalInteractive = ref1$3[6], _init__globalInteractiveDirty = ref1$3[7], _init__state = ref1$3[8], _init__isPointerInside = ref1$3[9], _init__isPointerDragging = ref1$3[10];
2480
3106
  var InteractiveState = /*#__PURE__*/ function(InteractiveState) {
2481
3107
  InteractiveState[InteractiveState["Normal"] = 0] = "Normal";
2482
3108
  InteractiveState[InteractiveState["Pressed"] = 1] = "Pressed";
@@ -2516,13 +3142,14 @@ var Button = /*#__PURE__*/ function(UIInteractive) {
2516
3142
  return Button;
2517
3143
  }(UIInteractive);
2518
3144
 
3145
+ var _init__sprite, _init__drawMode, _init__assembler;
2519
3146
  /**
2520
3147
  * UI element that renders an image.
2521
3148
  */ var Image = /*#__PURE__*/ function(UIRenderer1) {
2522
3149
  _inherits(Image, UIRenderer1);
2523
3150
  function Image(entity) {
2524
3151
  var _this;
2525
- _this = UIRenderer1.call(this, entity) || this, _this._sprite = null, _this._tileMode = SpriteTileMode.Continuous, _this._tiledAdaptiveThreshold = 0.5, _this._filledMode = SpriteFilledMode.Radial360, _this._filledAmount = 1, _this._filledOrigin = SpriteFilledOrigin.Bottom, _this._filledClockWise = true;
3152
+ _this = UIRenderer1.call(this, entity) || this, _this._sprite = _init__sprite(_this, null), _this._drawMode = _init__drawMode(_this), _this._assembler = _init__assembler(_this), _this._tileMode = SpriteTileMode.Continuous, _this._tiledAdaptiveThreshold = 0.5, _this._filledMode = SpriteFilledMode.Radial360, _this._filledAmount = 1, _this._filledOrigin = SpriteFilledOrigin.Bottom, _this._filledClockWise = true;
2526
3153
  _this.drawMode = SpriteDrawMode.Simple;
2527
3154
  // @ts-ignore
2528
3155
  _this.setMaterial(_this._engine._getUIDefaultMaterial());
@@ -2628,7 +3255,7 @@ var Button = /*#__PURE__*/ function(UIInteractive) {
2628
3255
  _proto._onSpriteChange = function _onSpriteChange(type) {
2629
3256
  switch(type){
2630
3257
  case SpriteModifyFlags.texture:
2631
- this.shaderData.setTexture(UIRenderer._textureProperty, this.sprite.texture);
3258
+ this.shaderData.setTexture(_UIRenderer._textureProperty, this.sprite.texture);
2632
3259
  break;
2633
3260
  case SpriteModifyFlags.size:
2634
3261
  switch(this._drawMode){
@@ -2827,9 +3454,9 @@ var Button = /*#__PURE__*/ function(UIInteractive) {
2827
3454
  this._addResourceReferCount(value, 1);
2828
3455
  // @ts-ignore
2829
3456
  value._updateFlagManager.addListener(this._onSpriteChange);
2830
- this.shaderData.setTexture(UIRenderer._textureProperty, value.texture);
3457
+ this.shaderData.setTexture(_UIRenderer._textureProperty, value.texture);
2831
3458
  } else {
2832
- this.shaderData.setTexture(UIRenderer._textureProperty, null);
3459
+ this.shaderData.setTexture(_UIRenderer._textureProperty, null);
2833
3460
  }
2834
3461
  this._sprite = value;
2835
3462
  }
@@ -2837,22 +3464,25 @@ var Button = /*#__PURE__*/ function(UIInteractive) {
2837
3464
  }
2838
3465
  ]);
2839
3466
  return Image;
2840
- }(UIRenderer);
2841
- __decorate([
2842
- ignoreClone
2843
- ], Image.prototype, "_sprite", void 0);
2844
- __decorate([
2845
- ignoreClone
2846
- ], Image.prototype, "_drawMode", void 0);
2847
- __decorate([
2848
- ignoreClone
2849
- ], Image.prototype, "_assembler", void 0);
2850
- __decorate([
2851
- ignoreClone
2852
- ], Image.prototype, "_onTransformChanged", null);
2853
- __decorate([
2854
- ignoreClone
2855
- ], Image.prototype, "_onSpriteChange", null);
3467
+ }(_UIRenderer);
3468
+ var ref$2, ref1$2;
3469
+ ref$2 = _apply_decs_2203_r(Image, [
3470
+ [
3471
+ ignoreClone,
3472
+ 0,
3473
+ "_sprite"
3474
+ ],
3475
+ [
3476
+ ignoreClone,
3477
+ 0,
3478
+ "_drawMode"
3479
+ ],
3480
+ [
3481
+ ignoreClone,
3482
+ 0,
3483
+ "_assembler"
3484
+ ]
3485
+ ], []), ref1$2 = ref$2.e, _init__sprite = ref1$2[0], _init__drawMode = ref1$2[1], _init__assembler = ref1$2[2];
2856
3486
 
2857
3487
  /**
2858
3488
  * UI component that uses a sprite to mask child UI renderers via stencil.
@@ -2915,15 +3545,16 @@ __decorate([
2915
3545
  return this._transformEntity.transform.pivot;
2916
3546
  };
2917
3547
  return Mask;
2918
- }(MaskRenderable(UIRenderer));
3548
+ }(MaskRenderable(_UIRenderer));
2919
3549
 
3550
+ var _init__textChunks, _init__subFont, _init__localBounds;
2920
3551
  /**
2921
3552
  * UI component used to render text.
2922
3553
  */ var Text = /*#__PURE__*/ function(UIRenderer1) {
2923
3554
  _inherits(Text, UIRenderer1);
2924
3555
  function Text(entity) {
2925
3556
  var _this;
2926
- _this = UIRenderer1.call(this, entity) || this, _this._textChunks = Array(), _this._subFont = null, _this._text = "", _this._localBounds = new BoundingBox(), _this._font = null, _this._fontSize = 24, _this._fontStyle = FontStyle.None, _this._lineSpacing = 0, _this._characterSpacing = 0, _this._horizontalAlignment = TextHorizontalAlignment.Center, _this._verticalAlignment = TextVerticalAlignment.Center, _this._enableWrapping = false, _this._overflowMode = OverflowMode.Overflow, _this._outlineColor = new Color(0, 0, 0, 1), _this._outlineWidth = 0;
3557
+ _this = UIRenderer1.call(this, entity) || this, _this._textChunks = _init__textChunks(_this, Array()), _this._subFont = _init__subFont(_this, null), _this._text = "", _this._localBounds = _init__localBounds(_this, new BoundingBox()), _this._font = null, _this._fontSize = 24, _this._fontStyle = FontStyle.None, _this._lineSpacing = 0, _this._characterSpacing = 0, _this._horizontalAlignment = TextHorizontalAlignment.Center, _this._verticalAlignment = TextVerticalAlignment.Center, _this._enableWrapping = false, _this._overflowMode = OverflowMode.Overflow, _this._outlineColor = new Color(0, 0, 0, 1), _this._outlineWidth = 0;
2927
3558
  var engine = _this.engine;
2928
3559
  // @ts-ignore
2929
3560
  _this.font = engine._textDefaultFont;
@@ -3052,8 +3683,8 @@ __decorate([
3052
3683
  var e = this._transformEntity.transform.worldMatrix.elements;
3053
3684
  // prettier-ignore
3054
3685
  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];
3055
- var up = UIRenderer._tempVec31.set(e4, e5, e6);
3056
- var right = UIRenderer._tempVec30.set(e0, e1, e2);
3686
+ var up = _UIRenderer._tempVec31.set(e4, e5, e6);
3687
+ var right = _UIRenderer._tempVec30.set(e0, e1, e2);
3057
3688
  var worldPositions = Text._worldPositions;
3058
3689
  var worldPosition0 = worldPositions[0], worldPosition1 = worldPositions[1], worldPosition2 = worldPositions[2], worldPosition3 = worldPositions[3];
3059
3690
  var textChunks = this._textChunks;
@@ -3522,7 +4153,25 @@ __decorate([
3522
4153
  }
3523
4154
  ]);
3524
4155
  return Text;
3525
- }(UIRenderer);
4156
+ }(_UIRenderer);
4157
+ var ref$1, ref1$1;
4158
+ ref$1 = _apply_decs_2203_r(Text, [
4159
+ [
4160
+ ignoreClone,
4161
+ 0,
4162
+ "_textChunks"
4163
+ ],
4164
+ [
4165
+ ignoreClone,
4166
+ 0,
4167
+ "_subFont"
4168
+ ],
4169
+ [
4170
+ ignoreClone,
4171
+ 0,
4172
+ "_localBounds"
4173
+ ]
4174
+ ], []), ref1$1 = ref$1.e, _init__textChunks = ref1$1[0], _init__subFont = ref1$1[1], _init__localBounds = ref1$1[2];
3526
4175
  Text._textTextureProperty = ShaderProperty.getByName("renderElement_TextTexture");
3527
4176
  Text._textTextureSizeProperty = ShaderProperty.getByName("renderElement_TextTextureSize");
3528
4177
  Text._outlineColorProperty = ShaderProperty.getByName("renderer_OutlineColor");
@@ -3534,32 +4183,18 @@ Text._worldPositions = [
3534
4183
  new Vector3()
3535
4184
  ];
3536
4185
  Text._charRenderInfos = [];
3537
- __decorate([
3538
- ignoreClone
3539
- ], Text.prototype, "_textChunks", void 0);
3540
- __decorate([
3541
- ignoreClone
3542
- ], Text.prototype, "_subFont", void 0);
3543
- __decorate([
3544
- ignoreClone
3545
- ], Text.prototype, "_localBounds", void 0);
3546
- __decorate([
3547
- ignoreClone
3548
- ], Text.prototype, "_onTransformChanged", null);
3549
- __decorate([
3550
- ignoreClone
3551
- ], Text.prototype, "_onOutlineColorChanged", null);
3552
4186
  var TextChunk = function TextChunk() {
3553
4187
  this.charRenderInfos = new Array();
3554
4188
  };
3555
4189
 
4190
+ var _init__countDown, _init__initialValue, _init__finalValue, _init__currentValue, _init__finalState;
3556
4191
  /**
3557
4192
  * The transition behavior of UIInteractive.
3558
4193
  */ var Transition = /*#__PURE__*/ function(DataObject) {
3559
4194
  _inherits(Transition, DataObject);
3560
4195
  function Transition() {
3561
4196
  var _this;
3562
- _this = DataObject.apply(this, arguments) || this, _this._duration = 0, _this._countDown = 0, _this._finalState = InteractiveState.Normal;
4197
+ _this = DataObject.apply(this, arguments) || this, _this._duration = 0, _this._countDown = _init__countDown(_this, 0), _this._initialValue = _init__initialValue(_this), _this._finalValue = _init__finalValue(_this), _this._currentValue = _init__currentValue(_this), _this._finalState = _init__finalState(_this, InteractiveState.Normal);
3563
4198
  return _this;
3564
4199
  }
3565
4200
  var _proto = Transition.prototype;
@@ -3735,21 +4370,34 @@ var TextChunk = function TextChunk() {
3735
4370
  ]);
3736
4371
  return Transition;
3737
4372
  }(DataObject);
3738
- __decorate([
3739
- ignoreClone
3740
- ], Transition.prototype, "_countDown", void 0);
3741
- __decorate([
3742
- ignoreClone
3743
- ], Transition.prototype, "_initialValue", void 0);
3744
- __decorate([
3745
- ignoreClone
3746
- ], Transition.prototype, "_finalValue", void 0);
3747
- __decorate([
3748
- ignoreClone
3749
- ], Transition.prototype, "_currentValue", void 0);
3750
- __decorate([
3751
- ignoreClone
3752
- ], Transition.prototype, "_finalState", void 0);
4373
+ var ref, ref1;
4374
+ ref = _apply_decs_2203_r(Transition, [
4375
+ [
4376
+ ignoreClone,
4377
+ 0,
4378
+ "_countDown"
4379
+ ],
4380
+ [
4381
+ ignoreClone,
4382
+ 0,
4383
+ "_initialValue"
4384
+ ],
4385
+ [
4386
+ ignoreClone,
4387
+ 0,
4388
+ "_finalValue"
4389
+ ],
4390
+ [
4391
+ ignoreClone,
4392
+ 0,
4393
+ "_currentValue"
4394
+ ],
4395
+ [
4396
+ ignoreClone,
4397
+ 0,
4398
+ "_finalState"
4399
+ ]
4400
+ ], []), ref1 = ref.e, _init__countDown = ref1[0], _init__initialValue = ref1[1], _init__finalValue = ref1[2], _init__currentValue = ref1[3], _init__finalState = ref1[4];
3753
4401
 
3754
4402
  /**
3755
4403
  * Color transition.
@@ -3876,15 +4524,15 @@ var GUIComponent = /*#__PURE__*/Object.freeze({
3876
4524
  Button: Button,
3877
4525
  Image: Image,
3878
4526
  Mask: Mask,
3879
- get RectMask2D () { return RectMask2D; },
4527
+ get RectMask2D () { return _RectMask2D; },
3880
4528
  Text: Text,
3881
4529
  ColorTransition: ColorTransition,
3882
4530
  ScaleTransition: ScaleTransition,
3883
4531
  SpriteTransition: SpriteTransition,
3884
4532
  Transition: Transition,
3885
- get UICanvas () { return UICanvas; },
4533
+ get UICanvas () { return _UICanvas; },
3886
4534
  UIGroup: UIGroup,
3887
- get UIRenderer () { return UIRenderer; },
4535
+ get UIRenderer () { return _UIRenderer; },
3888
4536
  UITransform: UITransform
3889
4537
  });
3890
4538
 
@@ -3898,233 +4546,248 @@ var GUIComponent = /*#__PURE__*/Object.freeze({
3898
4546
  this.component = null;
3899
4547
  };
3900
4548
 
3901
- var UIPointerEventEmitter = /*#__PURE__*/ function(PointerEventEmitter1) {
3902
- _inherits(UIPointerEventEmitter, PointerEventEmitter1);
3903
- function UIPointerEventEmitter() {
4549
+ var _class;
4550
+ var _dec, _initClass, _PointerEventEmitter;
4551
+ var _UIPointerEventEmitter;
4552
+ _dec = registerPointerEventEmitter();
4553
+ new (_class = /*#__PURE__*/ function(_identity) {
4554
+ _inherits(_class, _identity);
4555
+ function _class() {
3904
4556
  var _this;
3905
- _this = PointerEventEmitter1.apply(this, arguments) || this, _this._enteredPath = [], _this._pressedPath = [], _this._draggedPath = [];
4557
+ _this = _identity.apply(this, arguments) || this, _initClass();
3906
4558
  return _this;
3907
4559
  }
3908
- var _proto = UIPointerEventEmitter.prototype;
3909
- _proto._init = function _init() {
3910
- this._hitResult = new UIHitResult();
3911
- };
3912
- _proto.processRaycast = function processRaycast(scenes, pointer) {
3913
- var ray = PointerEventEmitter._tempRay;
3914
- var hitResult = this._hitResult;
3915
- var position = pointer.position;
3916
- var x = position.x, y = position.y;
3917
- for(var i = scenes.length - 1; i >= 0; i--){
3918
- var scene = scenes[i];
3919
- if (!scene.isActive || scene.destroyed) continue;
3920
- // @ts-ignore
3921
- var componentsManager = scene._componentsManager;
3922
- // Overlay Canvas
3923
- var canvasElements = componentsManager._overlayCanvases;
3924
- // Screen to world ( Assume that world units have a one-to-one relationship with pixel units )
3925
- ray.origin.set(position.x, scene.engine.canvas.height - position.y, 1);
3926
- ray.direction.set(0, 0, -1);
3927
- for(var j = canvasElements.length - 1; j >= 0; j--){
3928
- if (canvasElements.get(j)._raycast(ray, hitResult)) {
3929
- this._updateRaycast(hitResult.component, pointer);
3930
- return;
4560
+ return _class;
4561
+ }(_identity), function() {
4562
+ var UIPointerEventEmitter = /*#__PURE__*/ function(_superClass) {
4563
+ _inherits(UIPointerEventEmitter, _superClass);
4564
+ function UIPointerEventEmitter() {
4565
+ var _this;
4566
+ _this = _superClass.apply(this, arguments) || this, _this._enteredPath = [], _this._pressedPath = [], _this._draggedPath = [];
4567
+ return _this;
4568
+ }
4569
+ var _proto = UIPointerEventEmitter.prototype;
4570
+ _proto._init = function _init() {
4571
+ this._hitResult = new UIHitResult();
4572
+ };
4573
+ _proto.processRaycast = function processRaycast(scenes, pointer) {
4574
+ var ray = PointerEventEmitter._tempRay;
4575
+ var hitResult = this._hitResult;
4576
+ var position = pointer.position;
4577
+ var x = position.x, y = position.y;
4578
+ for(var i = scenes.length - 1; i >= 0; i--){
4579
+ var scene = scenes[i];
4580
+ if (!scene.isActive || scene.destroyed) continue;
4581
+ // @ts-ignore
4582
+ var componentsManager = scene._componentsManager;
4583
+ // Overlay Canvas
4584
+ var canvasElements = componentsManager._overlayCanvases;
4585
+ // Screen to world ( Assume that world units have a one-to-one relationship with pixel units )
4586
+ ray.origin.set(position.x, scene.engine.canvas.height - position.y, 1);
4587
+ ray.direction.set(0, 0, -1);
4588
+ for(var j = canvasElements.length - 1; j >= 0; j--){
4589
+ if (canvasElements.get(j)._raycast(ray, hitResult)) {
4590
+ this._updateRaycast(hitResult.component, pointer);
4591
+ return;
4592
+ }
4593
+ }
4594
+ var cameras = componentsManager._activeCameras;
4595
+ for(var j1 = cameras.length - 1; j1 >= 0; j1--){
4596
+ var camera = cameras.get(j1);
4597
+ if (camera.renderTarget) continue;
4598
+ var pixelViewport = camera.pixelViewport;
4599
+ if (x < pixelViewport.x || y < pixelViewport.y || x > pixelViewport.x + pixelViewport.width || y > pixelViewport.y + pixelViewport.height) {
4600
+ continue;
4601
+ }
4602
+ camera.screenPointToRay(pointer.position, ray);
4603
+ // Other canvases
4604
+ var isOrthographic = camera.isOrthographic;
4605
+ var _camera_entity_transform = camera.entity.transform, cameraPosition = _camera_entity_transform.worldPosition, cameraForward = _camera_entity_transform.worldForward;
4606
+ // Sort by rendering order
4607
+ canvasElements = componentsManager._canvases;
4608
+ for(var k = 0, n = canvasElements.length; k < n; k++){
4609
+ canvasElements.get(k)._updateSortDistance(isOrthographic, cameraPosition, cameraForward);
4610
+ }
4611
+ canvasElements.sort(function(a, b) {
4612
+ return a.sortOrder - b.sortOrder || a._sortDistance - b._sortDistance;
4613
+ });
4614
+ for(var k1 = 0, n1 = canvasElements.length; k1 < n1; k1++){
4615
+ canvasElements.get(k1)._canvasIndex = k1;
4616
+ }
4617
+ var farClipPlane = camera.farClipPlane;
4618
+ // Post-rendering first detection
4619
+ for(var k2 = 0, n2 = canvasElements.length; k2 < n2; k2++){
4620
+ var canvas = canvasElements.get(k2);
4621
+ if (!canvas._canDispatchEvent(camera)) continue;
4622
+ if (canvas._raycast(ray, hitResult, farClipPlane)) {
4623
+ this._updateRaycast(hitResult.component, pointer);
4624
+ return;
4625
+ }
4626
+ }
4627
+ if (camera.clearFlags & CameraClearFlags.Color) {
4628
+ this._updateRaycast(null, pointer);
4629
+ return;
4630
+ }
3931
4631
  }
4632
+ this._updateRaycast(null, pointer);
3932
4633
  }
3933
- var cameras = componentsManager._activeCameras;
3934
- for(var j1 = cameras.length - 1; j1 >= 0; j1--){
3935
- var camera = cameras.get(j1);
3936
- if (camera.renderTarget) continue;
3937
- var pixelViewport = camera.pixelViewport;
3938
- if (x < pixelViewport.x || y < pixelViewport.y || x > pixelViewport.x + pixelViewport.width || y > pixelViewport.y + pixelViewport.height) {
3939
- continue;
4634
+ };
4635
+ _proto.processDrag = function processDrag(pointer) {
4636
+ var draggedPath = this._draggedPath;
4637
+ if (draggedPath.length > 0) {
4638
+ this._bubble(draggedPath, pointer, this._fireDrag);
4639
+ }
4640
+ };
4641
+ _proto.processDown = function processDown(pointer) {
4642
+ var enteredPath = this._enteredPath;
4643
+ var pressedPath = this._pressedPath;
4644
+ var draggedPath = this._draggedPath;
4645
+ var length = draggedPath.length = pressedPath.length = enteredPath.length;
4646
+ if (length > 0) {
4647
+ for(var i = 0; i < length; i++){
4648
+ pressedPath[i] = draggedPath[i] = enteredPath[i];
3940
4649
  }
3941
- camera.screenPointToRay(pointer.position, ray);
3942
- // Other canvases
3943
- var isOrthographic = camera.isOrthographic;
3944
- var _camera_entity_transform = camera.entity.transform, cameraPosition = _camera_entity_transform.worldPosition, cameraForward = _camera_entity_transform.worldForward;
3945
- // Sort by rendering order
3946
- canvasElements = componentsManager._canvases;
3947
- for(var k = 0, n = canvasElements.length; k < n; k++){
3948
- canvasElements.get(k)._updateSortDistance(isOrthographic, cameraPosition, cameraForward);
4650
+ this._bubble(pressedPath, pointer, this._fireDown);
4651
+ this._bubble(draggedPath, pointer, this._fireBeginDrag);
4652
+ }
4653
+ };
4654
+ _proto.processUp = function processUp(pointer) {
4655
+ var enteredPath = this._enteredPath;
4656
+ var pressedPath = this._pressedPath;
4657
+ if (enteredPath.length > 0) {
4658
+ this._bubble(enteredPath, pointer, this._fireUp);
4659
+ if (pressedPath.length > 0) {
4660
+ var common = UIPointerEventEmitter._tempArray0;
4661
+ if (this._findCommonInPath(enteredPath, pressedPath, common)) {
4662
+ this._bubble(common, pointer, this._fireClick);
4663
+ common.length = 0;
4664
+ }
3949
4665
  }
3950
- canvasElements.sort(function(a, b) {
3951
- return a.sortOrder - b.sortOrder || a._sortDistance - b._sortDistance;
3952
- });
3953
- for(var k1 = 0, n1 = canvasElements.length; k1 < n1; k1++){
3954
- canvasElements.get(k1)._canvasIndex = k1;
4666
+ }
4667
+ pressedPath.length = 0;
4668
+ var draggedPath = this._draggedPath;
4669
+ if (draggedPath.length > 0) {
4670
+ this._bubble(draggedPath, pointer, this._fireEndDrag);
4671
+ draggedPath.length = 0;
4672
+ }
4673
+ if (enteredPath.length > 0) {
4674
+ this._bubble(enteredPath, pointer, this._fireDrop);
4675
+ }
4676
+ };
4677
+ _proto.processLeave = function processLeave(pointer) {
4678
+ var enteredPath = this._enteredPath;
4679
+ if (enteredPath.length > 0) {
4680
+ this._bubble(enteredPath, pointer, this._fireExit);
4681
+ enteredPath.length = 0;
4682
+ }
4683
+ var draggedPath = this._draggedPath;
4684
+ if (draggedPath.length > 0) {
4685
+ this._bubble(draggedPath, pointer, this._fireEndDrag);
4686
+ draggedPath.length = 0;
4687
+ }
4688
+ this._pressedPath.length = 0;
4689
+ };
4690
+ _proto.dispose = function dispose() {
4691
+ this._enteredPath.length = this._pressedPath.length = this._draggedPath.length = 0;
4692
+ };
4693
+ _proto._updateRaycast = function _updateRaycast(element, pointer) {
4694
+ var enteredPath = this._enteredPath;
4695
+ var curPath = this._composedPath(element, UIPointerEventEmitter._path);
4696
+ var add = UIPointerEventEmitter._tempArray0;
4697
+ var del = UIPointerEventEmitter._tempArray1;
4698
+ if (this._findDiffInPath(enteredPath, curPath, add, del)) {
4699
+ for(var i = 0, n = add.length; i < n; i++){
4700
+ this._fireEnter(add[i], this._createEventData(pointer, add[i]));
3955
4701
  }
3956
- var farClipPlane = camera.farClipPlane;
3957
- // Post-rendering first detection
3958
- for(var k2 = 0, n2 = canvasElements.length; k2 < n2; k2++){
3959
- var canvas = canvasElements.get(k2);
3960
- if (!canvas._canDispatchEvent(camera)) continue;
3961
- if (canvas._raycast(ray, hitResult, farClipPlane)) {
3962
- this._updateRaycast(hitResult.component, pointer);
3963
- return;
3964
- }
4702
+ for(var i1 = 0, n1 = del.length; i1 < n1; i1++){
4703
+ this._fireExit(del[i1], this._createEventData(pointer, del[i1]));
3965
4704
  }
3966
- if (camera.clearFlags & CameraClearFlags.Color) {
3967
- this._updateRaycast(null, pointer);
3968
- return;
4705
+ var length = enteredPath.length = curPath.length;
4706
+ for(var i2 = 0; i2 < length; i2++){
4707
+ enteredPath[i2] = curPath[i2];
3969
4708
  }
4709
+ add.length = del.length = 0;
3970
4710
  }
3971
- this._updateRaycast(null, pointer);
3972
- }
3973
- };
3974
- _proto.processDrag = function processDrag(pointer) {
3975
- var draggedPath = this._draggedPath;
3976
- if (draggedPath.length > 0) {
3977
- this._bubble(draggedPath, pointer, this._fireDrag);
3978
- }
3979
- };
3980
- _proto.processDown = function processDown(pointer) {
3981
- var enteredPath = this._enteredPath;
3982
- var pressedPath = this._pressedPath;
3983
- var draggedPath = this._draggedPath;
3984
- var length = draggedPath.length = pressedPath.length = enteredPath.length;
3985
- if (length > 0) {
3986
- for(var i = 0; i < length; i++){
3987
- pressedPath[i] = draggedPath[i] = enteredPath[i];
4711
+ curPath.length = 0;
4712
+ };
4713
+ _proto._composedPath = function _composedPath(element, path) {
4714
+ if (!element) {
4715
+ path.length = 0;
4716
+ return path;
3988
4717
  }
3989
- this._bubble(pressedPath, pointer, this._fireDown);
3990
- this._bubble(draggedPath, pointer, this._fireBeginDrag);
3991
- }
3992
- };
3993
- _proto.processUp = function processUp(pointer) {
3994
- var enteredPath = this._enteredPath;
3995
- var pressedPath = this._pressedPath;
3996
- if (enteredPath.length > 0) {
3997
- this._bubble(enteredPath, pointer, this._fireUp);
3998
- if (pressedPath.length > 0) {
3999
- var common = UIPointerEventEmitter._tempArray0;
4000
- if (this._findCommonInPath(enteredPath, pressedPath, common)) {
4001
- this._bubble(common, pointer, this._fireClick);
4002
- common.length = 0;
4003
- }
4718
+ var entity = path[0] = element.entity;
4719
+ var i = 1;
4720
+ var rootEntity = element._getRootCanvas().entity;
4721
+ for(; i < UIPointerEventEmitter._MAX_PATH_DEPTH && !!entity && entity !== rootEntity; i++){
4722
+ entity = path[i] = entity.parent;
4004
4723
  }
4005
- }
4006
- pressedPath.length = 0;
4007
- var draggedPath = this._draggedPath;
4008
- if (draggedPath.length > 0) {
4009
- this._bubble(draggedPath, pointer, this._fireEndDrag);
4010
- draggedPath.length = 0;
4011
- }
4012
- if (enteredPath.length > 0) {
4013
- this._bubble(enteredPath, pointer, this._fireDrop);
4014
- }
4015
- };
4016
- _proto.processLeave = function processLeave(pointer) {
4017
- var enteredPath = this._enteredPath;
4018
- if (enteredPath.length > 0) {
4019
- this._bubble(enteredPath, pointer, this._fireExit);
4020
- enteredPath.length = 0;
4021
- }
4022
- var draggedPath = this._draggedPath;
4023
- if (draggedPath.length > 0) {
4024
- this._bubble(draggedPath, pointer, this._fireEndDrag);
4025
- draggedPath.length = 0;
4026
- }
4027
- this._pressedPath.length = 0;
4028
- };
4029
- _proto.dispose = function dispose() {
4030
- this._enteredPath.length = this._pressedPath.length = this._draggedPath.length = 0;
4031
- };
4032
- _proto._updateRaycast = function _updateRaycast(element, pointer) {
4033
- var enteredPath = this._enteredPath;
4034
- var curPath = this._composedPath(element, UIPointerEventEmitter._path);
4035
- var add = UIPointerEventEmitter._tempArray0;
4036
- var del = UIPointerEventEmitter._tempArray1;
4037
- if (this._findDiffInPath(enteredPath, curPath, add, del)) {
4038
- for(var i = 0, n = add.length; i < n; i++){
4039
- this._fireEnter(add[i], this._createEventData(pointer, add[i]));
4040
- }
4041
- for(var i1 = 0, n1 = del.length; i1 < n1; i1++){
4042
- this._fireExit(del[i1], this._createEventData(pointer, del[i1]));
4043
- }
4044
- var length = enteredPath.length = curPath.length;
4045
- for(var i2 = 0; i2 < length; i2++){
4046
- enteredPath[i2] = curPath[i2];
4047
- }
4048
- add.length = del.length = 0;
4049
- }
4050
- curPath.length = 0;
4051
- };
4052
- _proto._composedPath = function _composedPath(element, path) {
4053
- if (!element) {
4054
- path.length = 0;
4724
+ path.length = i;
4055
4725
  return path;
4056
- }
4057
- var entity = path[0] = element.entity;
4058
- var i = 1;
4059
- var rootEntity = element._getRootCanvas().entity;
4060
- for(; i < UIPointerEventEmitter._MAX_PATH_DEPTH && !!entity && entity !== rootEntity; i++){
4061
- entity = path[i] = entity.parent;
4062
- }
4063
- path.length = i;
4064
- return path;
4065
- };
4066
- _proto._findCommonInPath = function _findCommonInPath(prePath, curPath, common) {
4067
- var idSet = UIPointerEventEmitter._tempSet;
4068
- idSet.clear();
4069
- for(var i = 0, n = prePath.length; i < n; i++){
4070
- idSet.add(prePath[i].instanceId);
4071
- }
4072
- var hasCommon = false;
4073
- for(var i1 = 0, n1 = curPath.length; i1 < n1; i1++){
4074
- var entity = curPath[i1];
4075
- if (idSet.has(entity.instanceId)) {
4076
- common.push(entity);
4077
- hasCommon = true;
4726
+ };
4727
+ _proto._findCommonInPath = function _findCommonInPath(prePath, curPath, common) {
4728
+ var idSet = UIPointerEventEmitter._tempSet;
4729
+ idSet.clear();
4730
+ for(var i = 0, n = prePath.length; i < n; i++){
4731
+ idSet.add(prePath[i].instanceId);
4078
4732
  }
4079
- }
4080
- return hasCommon;
4081
- };
4082
- _proto._findDiffInPath = function _findDiffInPath(prePath, curPath, add, del) {
4083
- var idSet = UIPointerEventEmitter._tempSet;
4084
- idSet.clear();
4085
- var changed = false;
4086
- for(var i = 0, n = prePath.length; i < n; i++){
4087
- idSet.add(prePath[i].instanceId);
4088
- }
4089
- for(var i1 = 0, n1 = curPath.length; i1 < n1; i1++){
4090
- var entity = curPath[i1];
4091
- if (!idSet.has(entity.instanceId)) {
4092
- add.push(entity);
4093
- changed = true;
4733
+ var hasCommon = false;
4734
+ for(var i1 = 0, n1 = curPath.length; i1 < n1; i1++){
4735
+ var entity = curPath[i1];
4736
+ if (idSet.has(entity.instanceId)) {
4737
+ common.push(entity);
4738
+ hasCommon = true;
4739
+ }
4094
4740
  }
4095
- }
4096
- idSet.clear();
4097
- for(var i2 = 0, n2 = curPath.length; i2 < n2; i2++){
4098
- idSet.add(curPath[i2].instanceId);
4099
- }
4100
- for(var i3 = 0, n3 = prePath.length; i3 < n3; i3++){
4101
- var entity1 = prePath[i3];
4102
- if (!idSet.has(entity1.instanceId)) {
4103
- del.push(entity1);
4104
- changed = true;
4741
+ return hasCommon;
4742
+ };
4743
+ _proto._findDiffInPath = function _findDiffInPath(prePath, curPath, add, del) {
4744
+ var idSet = UIPointerEventEmitter._tempSet;
4745
+ idSet.clear();
4746
+ var changed = false;
4747
+ for(var i = 0, n = prePath.length; i < n; i++){
4748
+ idSet.add(prePath[i].instanceId);
4105
4749
  }
4106
- }
4107
- return changed;
4108
- };
4109
- _proto._bubble = function _bubble(path, pointer, fireEvent) {
4110
- var length = path.length;
4111
- if (length <= 0) return;
4112
- var eventData = this._createEventData(pointer, path[0]);
4113
- for(var i = 0; i < length; i++){
4114
- eventData.currentTarget = path[i];
4115
- fireEvent(path[i], eventData);
4116
- }
4117
- };
4118
- return UIPointerEventEmitter;
4119
- }(PointerEventEmitter);
4120
- UIPointerEventEmitter._MAX_PATH_DEPTH = 2048;
4121
- UIPointerEventEmitter._tempSet = new Set();
4122
- UIPointerEventEmitter._path = [];
4123
- UIPointerEventEmitter._tempArray0 = [];
4124
- UIPointerEventEmitter._tempArray1 = [];
4125
- UIPointerEventEmitter = __decorate([
4126
- registerPointerEventEmitter()
4127
- ], UIPointerEventEmitter);
4750
+ for(var i1 = 0, n1 = curPath.length; i1 < n1; i1++){
4751
+ var entity = curPath[i1];
4752
+ if (!idSet.has(entity.instanceId)) {
4753
+ add.push(entity);
4754
+ changed = true;
4755
+ }
4756
+ }
4757
+ idSet.clear();
4758
+ for(var i2 = 0, n2 = curPath.length; i2 < n2; i2++){
4759
+ idSet.add(curPath[i2].instanceId);
4760
+ }
4761
+ for(var i3 = 0, n3 = prePath.length; i3 < n3; i3++){
4762
+ var entity1 = prePath[i3];
4763
+ if (!idSet.has(entity1.instanceId)) {
4764
+ del.push(entity1);
4765
+ changed = true;
4766
+ }
4767
+ }
4768
+ return changed;
4769
+ };
4770
+ _proto._bubble = function _bubble(path, pointer, fireEvent) {
4771
+ var length = path.length;
4772
+ if (length <= 0) return;
4773
+ var eventData = this._createEventData(pointer, path[0]);
4774
+ for(var i = 0; i < length; i++){
4775
+ eventData.currentTarget = path[i];
4776
+ fireEvent(path[i], eventData);
4777
+ }
4778
+ };
4779
+ return UIPointerEventEmitter;
4780
+ }(_PointerEventEmitter = PointerEventEmitter);
4781
+ var ref, ref1;
4782
+ ref = _apply_decs_2203_r(UIPointerEventEmitter, [], [
4783
+ _dec
4784
+ ], _PointerEventEmitter), ref1 = ref.c, _UIPointerEventEmitter = ref1[0], _initClass = ref1[1];
4785
+ UIPointerEventEmitter._MAX_PATH_DEPTH = 2048;
4786
+ UIPointerEventEmitter._tempSet = new Set();
4787
+ UIPointerEventEmitter._path = [];
4788
+ UIPointerEventEmitter._tempArray0 = [];
4789
+ UIPointerEventEmitter._tempArray1 = [];
4790
+ }(), _class)();
4128
4791
 
4129
4792
  var EngineExtension = /*#__PURE__*/ function() {
4130
4793
  function EngineExtension() {}
@@ -4181,5 +4844,5 @@ function _getOrCreateUIShader() {
4181
4844
  return Shader.find("2D/UIDefault");
4182
4845
  }
4183
4846
 
4184
- export { Button, CanvasRenderMode, ColorTransition, EngineExtension, EntityExtension, HorizontalAlignmentMode, Image, Mask, RectMask2D, ResolutionAdaptationMode, ScaleTransition, SpriteTransition, Text, Transition, UICanvas, UIGroup, UIPointerEventEmitter, UIRenderer, UITransform, VerticalAlignmentMode, registerGUI };
4847
+ export { Button, CanvasRenderMode, ColorTransition, EngineExtension, EntityExtension, HorizontalAlignmentMode, Image, Mask, _RectMask2D as RectMask2D, ResolutionAdaptationMode, ScaleTransition, SpriteTransition, Text, Transition, _UICanvas as UICanvas, UIGroup, _UIPointerEventEmitter as UIPointerEventEmitter, _UIRenderer as UIRenderer, UITransform, VerticalAlignmentMode, registerGUI };
4185
4848
  //# sourceMappingURL=module.js.map