@galacean/effects-core 2.10.0-alpha.2 → 2.10.0-alpha.4

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/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: Galacean Effects runtime core for the web
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
6
- * Version: v2.10.0-alpha.2
6
+ * Version: v2.10.0-alpha.4
7
7
  */
8
8
 
9
9
  'use strict';
@@ -7056,6 +7056,11 @@ function _create_class(Constructor, protoProps, staticProps) {
7056
7056
  // OVERRIDE
7057
7057
  };
7058
7058
  /**
7059
+ * Called when the owning item's sibling order changes.
7060
+ */ _proto.onOrderInParentChanged = function onOrderInParentChanged() {
7061
+ // OVERRIDE
7062
+ };
7063
+ /**
7059
7064
  * @internal
7060
7065
  */ _proto.enable = function enable() {
7061
7066
  if (this.item.composition) {
@@ -14013,6 +14018,7 @@ var seed$7 = 1;
14013
14018
  quat: new Quaternion(0, 0, 0, 1),
14014
14019
  scale: new Vector3(1, 1, 1)
14015
14020
  };
14021
+ this.eventEmitter = new EventEmitter();
14016
14022
  this.name = "transform_" + seed$7++;
14017
14023
  if (props) {
14018
14024
  this.setTransform(props);
@@ -14025,6 +14031,12 @@ var seed$7 = 1;
14025
14031
  }
14026
14032
  }
14027
14033
  var _proto = Transform.prototype;
14034
+ _proto.on = function on(eventName, listener, options) {
14035
+ this.eventEmitter.on(eventName, listener, options);
14036
+ };
14037
+ _proto.off = function off(eventName, listener) {
14038
+ this.eventEmitter.off(eventName, listener);
14039
+ };
14028
14040
  /**
14029
14041
  * 父 transform 切换时的 hook。子类可重写以接管订阅 / 解算等逻辑
14030
14042
  * @param oldParent - 切换前的父 transform(若没有则为 null)
@@ -14443,6 +14455,7 @@ var seed$7 = 1;
14443
14455
  this.children.forEach(function(c) {
14444
14456
  c.worldMatrixDirty = true;
14445
14457
  });
14458
+ this.eventEmitter.emit("changed", this);
14446
14459
  };
14447
14460
  /**
14448
14461
  * 转换右手坐标系左手螺旋对应的四元数到对应的旋转角
@@ -14461,14 +14474,16 @@ var seed$7 = 1;
14461
14474
  return this.parent;
14462
14475
  },
14463
14476
  set: function set(transform) {
14464
- if (!transform || this.parent === transform || this === transform) {
14477
+ if (this.parent === transform || this === transform) {
14465
14478
  return;
14466
14479
  }
14467
14480
  var oldParent = this.parent;
14468
14481
  if (this.parent) {
14469
14482
  this.parent.removeChild(this);
14470
14483
  }
14471
- transform.addChild(this);
14484
+ if (transform) {
14485
+ transform.addChild(this);
14486
+ }
14472
14487
  this.parent = transform;
14473
14488
  this.worldMatrixDirty = true;
14474
14489
  this.onParentTransformChanged(oldParent, transform);
@@ -14651,7 +14666,7 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
14651
14666
  return results;
14652
14667
  };
14653
14668
  _proto.setParent = function setParent(vfxItem) {
14654
- if (vfxItem === this && !vfxItem) {
14669
+ if (vfxItem === this || this.parent === vfxItem) {
14655
14670
  return;
14656
14671
  }
14657
14672
  if (this.parent) {
@@ -15038,6 +15053,12 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
15038
15053
  child.onParentChanged();
15039
15054
  }
15040
15055
  };
15056
+ _proto.onOrderInParentChanged = function onOrderInParentChanged() {
15057
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.components), _step; !(_step = _iterator()).done;){
15058
+ var component = _step.value;
15059
+ component.onOrderInParentChanged();
15060
+ }
15061
+ };
15041
15062
  /**
15042
15063
  * @internal
15043
15064
  */ _proto.setRendererComponentOrder = function setRendererComponentOrder(renderOrder) {
@@ -15122,15 +15143,16 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
15122
15143
  */ _proto.dispose = function dispose() {
15123
15144
  if (this.composition) {
15124
15145
  this.composition.destroyItem(this);
15125
- // component 调用 dispose() 会将自身从 this.components 数组删除,slice() 避免迭代错误
15126
- for(var _iterator = _create_for_of_iterator_helper_loose(this.components.slice()), _step; !(_step = _iterator()).done;){
15127
- var component = _step.value;
15128
- component.dispose();
15129
- }
15130
- this.components = [];
15131
- this._composition = null;
15132
- this.transform.setValid(false);
15133
15146
  }
15147
+ // component.dispose() removes itself from this.components. Use a snapshot
15148
+ // so Engine.root components are also disposed even without a Composition.
15149
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.components.slice()), _step; !(_step = _iterator()).done;){
15150
+ var component = _step.value;
15151
+ component.dispose();
15152
+ }
15153
+ this.components = [];
15154
+ this._composition = null;
15155
+ this.transform.setValid(false);
15134
15156
  this.resetChildrenParent();
15135
15157
  EffectsObject.prototype.dispose.call(this);
15136
15158
  };
@@ -15326,6 +15348,33 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
15326
15348
  this.setRendererComponentOrder(value);
15327
15349
  }
15328
15350
  },
15351
+ {
15352
+ key: "orderInParent",
15353
+ get: /** Zero-based sibling order within the parent item. */ function get() {
15354
+ var _this_parent;
15355
+ var _this_parent_children_indexOf;
15356
+ return (_this_parent_children_indexOf = (_this_parent = this.parent) == null ? void 0 : _this_parent.children.indexOf(this)) != null ? _this_parent_children_indexOf : -1;
15357
+ },
15358
+ set: function set(value) {
15359
+ var _this_parent;
15360
+ var siblings = (_this_parent = this.parent) == null ? void 0 : _this_parent.children;
15361
+ var _siblings_indexOf;
15362
+ var oldIndex = (_siblings_indexOf = siblings == null ? void 0 : siblings.indexOf(this)) != null ? _siblings_indexOf : -1;
15363
+ if (!siblings || oldIndex === -1) {
15364
+ return;
15365
+ }
15366
+ var newIndex = Math.max(0, Math.min(Math.trunc(value), siblings.length - 1));
15367
+ if (oldIndex === newIndex) {
15368
+ return;
15369
+ }
15370
+ siblings.splice(oldIndex, 1);
15371
+ siblings.splice(newIndex, 0, this);
15372
+ for(var _iterator = _create_for_of_iterator_helper_loose(siblings), _step; !(_step = _iterator()).done;){
15373
+ var sibling = _step.value;
15374
+ sibling.onOrderInParentChanged();
15375
+ }
15376
+ }
15377
+ },
15329
15378
  {
15330
15379
  key: "isActive",
15331
15380
  get: /**
@@ -15582,35 +15631,35 @@ function vecMulCombine(out, a, b) {
15582
15631
  }
15583
15632
  return out;
15584
15633
  }
15585
- var _obj$5;
15586
- var particleOriginTranslateMap$1 = (_obj$5 = {}, _obj$5[ParticleOrigin.PARTICLE_ORIGIN_CENTER] = [
15634
+ var _obj$6;
15635
+ var particleOriginTranslateMap$1 = (_obj$6 = {}, _obj$6[ParticleOrigin.PARTICLE_ORIGIN_CENTER] = [
15587
15636
  0,
15588
15637
  0
15589
- ], _obj$5[ParticleOrigin.PARTICLE_ORIGIN_CENTER_BOTTOM] = [
15638
+ ], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_CENTER_BOTTOM] = [
15590
15639
  0,
15591
15640
  -0.5
15592
- ], _obj$5[ParticleOrigin.PARTICLE_ORIGIN_CENTER_TOP] = [
15641
+ ], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_CENTER_TOP] = [
15593
15642
  0,
15594
15643
  0.5
15595
- ], _obj$5[ParticleOrigin.PARTICLE_ORIGIN_LEFT_TOP] = [
15644
+ ], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_LEFT_TOP] = [
15596
15645
  -0.5,
15597
15646
  0.5
15598
- ], _obj$5[ParticleOrigin.PARTICLE_ORIGIN_LEFT_CENTER] = [
15647
+ ], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_LEFT_CENTER] = [
15599
15648
  -0.5,
15600
15649
  0
15601
- ], _obj$5[ParticleOrigin.PARTICLE_ORIGIN_LEFT_BOTTOM] = [
15650
+ ], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_LEFT_BOTTOM] = [
15602
15651
  -0.5,
15603
15652
  -0.5
15604
- ], _obj$5[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_CENTER] = [
15653
+ ], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_CENTER] = [
15605
15654
  0.5,
15606
15655
  0
15607
- ], _obj$5[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_BOTTOM] = [
15656
+ ], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_BOTTOM] = [
15608
15657
  0.5,
15609
15658
  -0.5
15610
- ], _obj$5[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_TOP] = [
15659
+ ], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_TOP] = [
15611
15660
  0.5,
15612
15661
  0.5
15613
- ], _obj$5);
15662
+ ], _obj$6);
15614
15663
  function nearestPowerOfTwo(value) {
15615
15664
  return Math.pow(2, Math.round(Math.log(value) / Math.LN2));
15616
15665
  }
@@ -17348,27 +17397,27 @@ function oldBezierKeyFramesToNew(props) {
17348
17397
  * 对象引用阶梯曲线(spec ValueType.REFERENCE_CURVE)。
17349
17398
  * props 为 [[time, value], ...],value 为已解析的对象引用实例。
17350
17399
  */ var REFERENCE_CURVE = 28;
17351
- var _obj$4;
17352
- var map$1 = (_obj$4 = {}, _obj$4[ValueType.RANDOM] = function(props) {
17400
+ var _obj$5;
17401
+ var map$1 = (_obj$5 = {}, _obj$5[ValueType.RANDOM] = function(props) {
17353
17402
  if (_instanceof1(props[0], Array)) {
17354
17403
  return new RandomVectorValue(props);
17355
17404
  }
17356
17405
  return new RandomValue(props);
17357
- }, _obj$4[ValueType.CONSTANT] = function(props) {
17406
+ }, _obj$5[ValueType.CONSTANT] = function(props) {
17358
17407
  return new StaticValue(props);
17359
- }, _obj$4[ValueType.CONSTANT_VEC2] = function(props) {
17408
+ }, _obj$5[ValueType.CONSTANT_VEC2] = function(props) {
17360
17409
  return new StaticValue(props);
17361
- }, _obj$4[ValueType.CONSTANT_VEC3] = function(props) {
17410
+ }, _obj$5[ValueType.CONSTANT_VEC3] = function(props) {
17362
17411
  return new StaticValue(props);
17363
- }, _obj$4[ValueType.CONSTANT_VEC4] = function(props) {
17412
+ }, _obj$5[ValueType.CONSTANT_VEC4] = function(props) {
17364
17413
  return new StaticValue(props);
17365
- }, _obj$4[ValueType.RGBA_COLOR] = function(props) {
17414
+ }, _obj$5[ValueType.RGBA_COLOR] = function(props) {
17366
17415
  return new StaticValue(props);
17367
- }, _obj$4[ValueType.COLORS] = function(props) {
17416
+ }, _obj$5[ValueType.COLORS] = function(props) {
17368
17417
  return new RandomSetValue(props.map(function(c) {
17369
17418
  return colorToArr$1(c, false);
17370
17419
  }));
17371
- }, _obj$4[ValueType.LINE] = function(props) {
17420
+ }, _obj$5[ValueType.LINE] = function(props) {
17372
17421
  if (props.length === 2 && props[0][0] === 0 && props[1][0] === 1) {
17373
17422
  return new LinearValue([
17374
17423
  props[0][1],
@@ -17376,38 +17425,38 @@ var map$1 = (_obj$4 = {}, _obj$4[ValueType.RANDOM] = function(props) {
17376
17425
  ]);
17377
17426
  }
17378
17427
  return new LineSegments(props);
17379
- }, _obj$4[ValueType.GRADIENT_COLOR] = function(props) {
17428
+ }, _obj$5[ValueType.GRADIENT_COLOR] = function(props) {
17380
17429
  return new GradientValue(props);
17381
- }, _obj$4[ValueType.LINEAR_PATH] = function(pros) {
17430
+ }, _obj$5[ValueType.LINEAR_PATH] = function(pros) {
17382
17431
  return new PathSegments(pros);
17383
- }, _obj$4[ValueType.BEZIER_CURVE] = function(props) {
17432
+ }, _obj$5[ValueType.BEZIER_CURVE] = function(props) {
17384
17433
  if (props.length === 1) {
17385
17434
  return new StaticValue(props[0][1][1]);
17386
17435
  }
17387
17436
  return new BezierCurve(props);
17388
- }, _obj$4[ValueType.BEZIER_CURVE_PATH] = function(props) {
17437
+ }, _obj$5[ValueType.BEZIER_CURVE_PATH] = function(props) {
17389
17438
  if (props[0].length === 1) {
17390
17439
  return new StaticValue(_construct(Vector3, [].concat(props[1][0])));
17391
17440
  }
17392
17441
  return new BezierCurvePath(props);
17393
- }, _obj$4[ValueType.BEZIER_CURVE_QUAT] = function(props) {
17442
+ }, _obj$5[ValueType.BEZIER_CURVE_QUAT] = function(props) {
17394
17443
  if (props[0].length === 1) {
17395
17444
  return new StaticValue(_construct(Quaternion, [].concat(props[1][0])));
17396
17445
  }
17397
17446
  return new BezierCurveQuat(props);
17398
- }, _obj$4[ValueType.COLOR_CURVE] = function(props) {
17447
+ }, _obj$5[ValueType.COLOR_CURVE] = function(props) {
17399
17448
  return new ColorCurve(props);
17400
- }, _obj$4[ValueType.VECTOR4_CURVE] = function(props) {
17449
+ }, _obj$5[ValueType.VECTOR4_CURVE] = function(props) {
17401
17450
  return new Vector4Curve(props);
17402
- }, _obj$4[ValueType.VECTOR2_CURVE] = function(props) {
17451
+ }, _obj$5[ValueType.VECTOR2_CURVE] = function(props) {
17403
17452
  return new Vector2Curve(props);
17404
17453
  }, // TODO: add spec
17405
- _obj$4[VECTOR3_CURVE] = function(props) {
17454
+ _obj$5[VECTOR3_CURVE] = function(props) {
17406
17455
  return new Vector3Curve(props);
17407
17456
  }, // 对象引用阶梯曲线(不插值):props.data 为 [time, value][],value 已解析为 EffectsObject
17408
- _obj$4[REFERENCE_CURVE] = function(props) {
17457
+ _obj$5[REFERENCE_CURVE] = function(props) {
17409
17458
  return new ReferenceCurve(props);
17410
- }, _obj$4);
17459
+ }, _obj$5);
17411
17460
  function createValueGetter(args) {
17412
17461
  if (!args || !isNaN(+args)) {
17413
17462
  return new StaticValue(args || 0);
@@ -20924,20 +20973,24 @@ var geometryId = 1;
20924
20973
  var vertexArrayObjects = this.vertexArrayObjects;
20925
20974
  var engine = this.engine;
20926
20975
  if (!vertexArrayObjects || !supportsVertexArrayObjects(engine)) {
20927
- engine.bindBuffers(this.vertexBuffers, this.indexBuffer, shader);
20976
+ var _this_indexBuffer;
20977
+ engine.bindBuffers(this.vertexBuffers, (_this_indexBuffer = this.indexBuffer) != null ? _this_indexBuffer : null, shader);
20928
20978
  return;
20929
20979
  }
20930
20980
  var vertexArrayObject = vertexArrayObjects[shader.key];
20931
20981
  if (!vertexArrayObject) {
20932
- vertexArrayObject = engine.recordVertexArrayObject(this.vertexBuffers, this.indexBuffer, shader);
20982
+ var _this_indexBuffer1;
20983
+ vertexArrayObject = engine.recordVertexArrayObject(this.vertexBuffers, (_this_indexBuffer1 = this.indexBuffer) != null ? _this_indexBuffer1 : null, shader);
20933
20984
  if (vertexArrayObject) {
20934
20985
  vertexArrayObjects[shader.key] = vertexArrayObject;
20935
20986
  }
20936
20987
  }
20937
20988
  if (vertexArrayObject) {
20938
- engine.bindVertexArrayObject(vertexArrayObject, this.indexBuffer);
20989
+ var _this_indexBuffer2;
20990
+ engine.bindVertexArrayObject(vertexArrayObject, (_this_indexBuffer2 = this.indexBuffer) != null ? _this_indexBuffer2 : null);
20939
20991
  } else {
20940
- engine.bindBuffers(this.vertexBuffers, this.indexBuffer, shader);
20992
+ var _this_indexBuffer3;
20993
+ engine.bindBuffers(this.vertexBuffers, (_this_indexBuffer3 = this.indexBuffer) != null ? _this_indexBuffer3 : null, shader);
20941
20994
  }
20942
20995
  };
20943
20996
  _proto.releaseVertexArrayObject = function releaseVertexArrayObject(key) {
@@ -21344,8 +21397,8 @@ var vertexBufferSemanticMap = {
21344
21397
  TANGENT_BS2: "aTargetTangent2",
21345
21398
  TANGENT_BS3: "aTargetTangent3"
21346
21399
  };
21347
- var _obj$3;
21348
- var BYTES_TYPE_MAP = (_obj$3 = {}, _obj$3[exports.BufferDataType.Float] = 4, _obj$3[exports.BufferDataType.Int] = 4, _obj$3[exports.BufferDataType.UnsignedInt] = 4, _obj$3[exports.BufferDataType.Short] = 2, _obj$3[exports.BufferDataType.UnsignedShort] = 2, _obj$3[exports.BufferDataType.Byte] = 1, _obj$3[exports.BufferDataType.UnsignedByte] = 1, _obj$3);
21400
+ var _obj$4;
21401
+ var BYTES_TYPE_MAP = (_obj$4 = {}, _obj$4[exports.BufferDataType.Float] = 4, _obj$4[exports.BufferDataType.Int] = 4, _obj$4[exports.BufferDataType.UnsignedInt] = 4, _obj$4[exports.BufferDataType.Short] = 2, _obj$4[exports.BufferDataType.UnsignedShort] = 2, _obj$4[exports.BufferDataType.Byte] = 1, _obj$4[exports.BufferDataType.UnsignedByte] = 1, _obj$4);
21349
21402
  function generateEmptyTypedArray(type) {
21350
21403
  return createTypedArray(type, 0);
21351
21404
  }
@@ -22355,7 +22408,7 @@ var Renderer = /*#__PURE__*/ function() {
22355
22408
  }
22356
22409
  };
22357
22410
  _proto.setViewport = function setViewport(x, y, width, height) {
22358
- this.engine.viewport(x, y, width, height);
22411
+ this.engine.setViewport(x, y, width, height);
22359
22412
  };
22360
22413
  _proto.clear = function clear(action) {
22361
22414
  this.engine.clear(action);
@@ -22418,7 +22471,40 @@ var Renderer = /*#__PURE__*/ function() {
22418
22471
  };
22419
22472
  _proto.drawGeometry = function drawGeometry(geometry, matrix, material, subMeshIndex) {
22420
22473
  if (subMeshIndex === void 0) subMeshIndex = 0;
22421
- this.engine.drawGeometry(geometry, matrix, material, subMeshIndex);
22474
+ if (!geometry || !material) {
22475
+ return;
22476
+ }
22477
+ material.initialize();
22478
+ geometry.initialize();
22479
+ geometry.flush();
22480
+ material.setMatrix("effects_ObjectToWorld", matrix);
22481
+ try {
22482
+ material.use(this, this.renderingData.currentFrame.globalUniforms);
22483
+ } catch (e) {
22484
+ console.error(e);
22485
+ this.engine.renderErrors.add(e);
22486
+ return;
22487
+ }
22488
+ var indexBuffer = geometry.getIndexBuffer();
22489
+ var offset = geometry.getDrawStart();
22490
+ var count = geometry.getDrawCount();
22491
+ var subMeshes = geometry.subMeshes;
22492
+ if (subMeshes.length > 0) {
22493
+ var subMesh = subMeshes[subMeshIndex];
22494
+ offset = subMesh.offset;
22495
+ var _subMesh_indexCount;
22496
+ count = indexBuffer ? (_subMesh_indexCount = subMesh.indexCount) != null ? _subMesh_indexCount : 0 : subMesh.vertexCount;
22497
+ }
22498
+ if (count <= 0) {
22499
+ return;
22500
+ }
22501
+ geometry.bind(material.shaderVariant);
22502
+ var instanceCount = geometry.instanceCount || undefined;
22503
+ if (indexBuffer) {
22504
+ this.engine.drawElementsType(geometry.mode, offset, count, instanceCount);
22505
+ } else {
22506
+ this.engine.drawArraysType(geometry.mode, offset, count, instanceCount);
22507
+ }
22422
22508
  };
22423
22509
  _proto.getTemporaryRT = function getTemporaryRT(name, width, height, depthBuffer, filter, format) {
22424
22510
  return this.engine.renderTargetPool.get(name, width, height, depthBuffer, filter, format);
@@ -22686,11 +22772,7 @@ var CanvasPool = /*#__PURE__*/ function() {
22686
22772
  var canvasPool = new CanvasPool();
22687
22773
 
22688
22774
  /**
22689
- * 字形纹理超采样倍数。canvas `fontSize * FONT_SCALE` 渲染,纹理像素也是 scale 倍,
22690
- * 但 quad 仍按 1x 逻辑尺寸绘制 — 双线性 downsample 后比原 1x 渲染清晰得多
22691
- */ var FONT_SCALE = 2;
22692
- /**
22693
- * 单张字符 atlas 的边长(像素,scale 后的实际像素,非逻辑尺寸)。
22775
+ * 单张字符 atlas 的逻辑边长。实际 canvas 像素尺寸会乘以渲染 resolution。
22694
22776
  * 512×512 在 24px 字号下约可容纳 250+ 字形,常见 demo 文本足够
22695
22777
  */ var ATLAS_SIZE = 512;
22696
22778
  /**
@@ -22712,7 +22794,7 @@ var canvasPool = new CanvasPool();
22712
22794
  * canvas 内容变更后需要 `uploadIfDirty` 重新上传到纹理 — 由调用方在使用纹理前主动触发,
22713
22795
  * 避免每加一字都 upload 一次造成的 GL 开销
22714
22796
  */ var GlyphAtlas = /*#__PURE__*/ function() {
22715
- function GlyphAtlas(engine, scaledFontString, /** baseline 距 cell 顶距离(像素,scale 后,仅 ascent 部分,不含 padding) */ ascentPx, /** baseline 距 cell 底距离(像素,scale 后,仅 descent 部分) */ descentPx, fontStyle) {
22797
+ function GlyphAtlas(engine, scaledFontString, /** baseline 距 cell 顶距离(像素,scale 后,仅 ascent 部分,不含 padding) */ ascentPx, /** baseline 距 cell 底距离(像素,scale 后,仅 descent 部分) */ descentPx, fontStyle, resolution) {
22716
22798
  this.engine = engine;
22717
22799
  this.scaledFontString = scaledFontString;
22718
22800
  this.glyphs = new Map();
@@ -22720,9 +22802,10 @@ var canvasPool = new CanvasPool();
22720
22802
  this.currentY = 0;
22721
22803
  this.full = false;
22722
22804
  this.dirty = true;
22805
+ this.resolution = resolution;
22723
22806
  this.canvas = document.createElement("canvas");
22724
- this.canvas.width = ATLAS_SIZE;
22725
- this.canvas.height = ATLAS_SIZE;
22807
+ this.canvas.width = Math.ceil(ATLAS_SIZE * resolution);
22808
+ this.canvas.height = Math.ceil(ATLAS_SIZE * resolution);
22726
22809
  var ctx = this.canvas.getContext("2d", {
22727
22810
  willReadFrequently: false
22728
22811
  });
@@ -22733,14 +22816,14 @@ var canvasPool = new CanvasPool();
22733
22816
  ctx.font = scaledFontString;
22734
22817
  ctx.textBaseline = "alphabetic";
22735
22818
  ctx.fillStyle = "#ffffff";
22736
- this.paddingPx = GLYPH_PADDING * FONT_SCALE;
22819
+ this.paddingPx = GLYPH_PADDING * resolution;
22737
22820
  this.italicScale = fontStyle === "italic" ? 2 : 1;
22738
22821
  // ascent/descent 由探针 '|ÉqÅM' 测得 actualBoundingBox(重音字已抬高 ink 顶),
22739
22822
  // 两者内部保持浮点,仅 cell 高做一次外层 ceil — 与 padding 共同保证 cell 内不裁切
22740
22823
  var fontHeightPx = ascentPx + descentPx;
22741
22824
  this.baselinePx = this.paddingPx + ascentPx;
22742
22825
  this.cellHPx = Math.ceil(fontHeightPx + this.paddingPx * 2);
22743
- this.lineHeight = this.cellHPx / FONT_SCALE;
22826
+ this.lineHeight = this.cellHPx / resolution;
22744
22827
  this.texture = Texture.create(engine, {
22745
22828
  sourceType: exports.TextureSourceType.image,
22746
22829
  image: this.canvas,
@@ -22749,7 +22832,8 @@ var canvasPool = new CanvasPool();
22749
22832
  magFilter: glContext.LINEAR,
22750
22833
  minFilter: glContext.LINEAR,
22751
22834
  wrapS: glContext.CLAMP_TO_EDGE,
22752
- wrapT: glContext.CLAMP_TO_EDGE
22835
+ wrapT: glContext.CLAMP_TO_EDGE,
22836
+ premultiplyAlpha: true
22753
22837
  });
22754
22838
  this.texture.initialize();
22755
22839
  }
@@ -22767,19 +22851,19 @@ var canvasPool = new CanvasPool();
22767
22851
  var ctx = this.ctx;
22768
22852
  // 每次重设字体,防御外部潜在污染(虽然 ctx 私有)
22769
22853
  ctx.font = this.scaledFontString;
22770
- // measureText 用的是 scaledFontString,advance 已经是 scale 后的像素,不能再乘 FONT_SCALE
22854
+ // measureText 用的是 scaledFontString,advance 已经是 resolution 后的像素
22771
22855
  var advancePx = ctx.measureText(char).width;
22772
22856
  // italic 放大 cell 宽防斜体越界;ceil 对齐像素网格避免相邻字采样重叠
22773
22857
  var widthPx = Math.max(1, Math.ceil(advancePx * this.italicScale));
22774
22858
  var paddedWidthPx = widthPx + this.paddingPx * 2;
22775
22859
  var cellH = this.cellHPx;
22776
22860
  // 行尾换行
22777
- if (this.currentX + paddedWidthPx > ATLAS_SIZE) {
22861
+ if (this.currentX + paddedWidthPx > this.canvas.width) {
22778
22862
  this.currentX = 0;
22779
22863
  this.currentY += cellH;
22780
22864
  }
22781
22865
  // atlas 满,后续不再尝试
22782
- if (this.currentY + cellH > ATLAS_SIZE) {
22866
+ if (this.currentY + cellH > this.canvas.height) {
22783
22867
  this.full = true;
22784
22868
  console.warn('GlyphAtlas full, dropping char "' + char + '"');
22785
22869
  return null;
@@ -22795,8 +22879,8 @@ var canvasPool = new CanvasPool();
22795
22879
  py: py,
22796
22880
  pw: paddedWidthPx,
22797
22881
  ph: cellH,
22798
- advance: advancePx / FONT_SCALE,
22799
- paddingLeft: this.paddingPx / FONT_SCALE
22882
+ advance: advancePx / this.resolution,
22883
+ paddingLeft: this.paddingPx / this.resolution
22800
22884
  };
22801
22885
  this.glyphs.set(char, info);
22802
22886
  return info;
@@ -22815,7 +22899,8 @@ var canvasPool = new CanvasPool();
22815
22899
  magFilter: glContext.LINEAR,
22816
22900
  minFilter: glContext.LINEAR,
22817
22901
  wrapS: glContext.CLAMP_TO_EDGE,
22818
- wrapT: glContext.CLAMP_TO_EDGE
22902
+ wrapT: glContext.CLAMP_TO_EDGE,
22903
+ premultiplyAlpha: true
22819
22904
  });
22820
22905
  this.dirty = false;
22821
22906
  };
@@ -22838,26 +22923,33 @@ var canvasPool = new CanvasPool();
22838
22923
  function TextCache(engine) {
22839
22924
  this.engine = engine;
22840
22925
  this.atlases = new Map();
22926
+ this.resolution = engine.pixelRatio;
22841
22927
  }
22842
22928
  var _proto = TextCache.prototype;
22843
22929
  /**
22844
22930
  * 取(必要时新建)对应字体的字符 atlas
22845
22931
  */ _proto.getAtlas = function getAtlas(fontSize, fontFamily, fontWeight, fontStyle) {
22846
- var fontKey = fontStyle + "|" + fontWeight + "|" + fontSize + "|" + fontFamily;
22932
+ // Pixi CanvasText 默认跟随 renderer.resolution;这里对应 Engine.pixelRatio。
22933
+ var resolution = this.engine.pixelRatio;
22934
+ if (resolution !== this.resolution) {
22935
+ this.clear();
22936
+ this.resolution = resolution;
22937
+ }
22938
+ var fontKey = fontStyle + "|" + fontWeight + "|" + fontSize + "|" + fontFamily + "|" + resolution;
22847
22939
  var cached = this.atlases.get(fontKey);
22848
22940
  if (cached) {
22849
22941
  return cached;
22850
22942
  }
22851
- var scaledFontString = fontStyle + " " + fontWeight + " " + fontSize * FONT_SCALE + "px " + fontFamily;
22943
+ var scaledFontString = fontStyle + " " + fontWeight + " " + fontSize * resolution + "px " + fontFamily;
22852
22944
  // 探一次得到字体级 ascent/descent(整张 atlas 共享 cell 高与 baseline,各字对齐)。
22853
- // 直接在 scaledFontString 下测,得到的就是 scale 后像素,无需再乘 FONT_SCALE。
22945
+ // 直接在 scaledFontString 下测,得到的就是 resolution 后像素。
22854
22946
  // 探针用 '|ÉqÅ' + 'M':带重音符的 ÉÅ 把 ink 顶推到接近字体真实 ascent,
22855
22947
  // 单字 'M' 只有 cap height(~0.7em) 太矮,CJK / 带重音字顶部会越过 cell 上界被裁。
22856
22948
  // 取 actualBoundingBoxAscent/Descent 度量 ink 边界,跨平台语义稳定
22857
22949
  var probeCanvasAndContext = canvasPool.getCanvasAndContext(1, 1);
22858
22950
  var probeCtx = probeCanvasAndContext.context;
22859
- var ascentPx = fontSize * 0.8 * FONT_SCALE;
22860
- var descentPx = fontSize * 0.2 * FONT_SCALE;
22951
+ var ascentPx = fontSize * 0.8 * resolution;
22952
+ var descentPx = fontSize * 0.2 * resolution;
22861
22953
  try {
22862
22954
  probeCtx.font = scaledFontString;
22863
22955
  var m = probeCtx.measureText(METRICS_STRING + BASELINE_SYMBOL);
@@ -22866,7 +22958,7 @@ var canvasPool = new CanvasPool();
22866
22958
  } finally{
22867
22959
  canvasPool.releaseCanvasAndContext(probeCanvasAndContext);
22868
22960
  }
22869
- var atlas = new GlyphAtlas(this.engine, scaledFontString, ascentPx, descentPx, fontStyle);
22961
+ var atlas = new GlyphAtlas(this.engine, scaledFontString, ascentPx, descentPx, fontStyle, resolution);
22870
22962
  this.atlases.set(fontKey, atlas);
22871
22963
  return atlas;
22872
22964
  };
@@ -22883,6 +22975,9 @@ var canvasPool = new CanvasPool();
22883
22975
  /**
22884
22976
  * 清空所有 atlas 并 dispose 对应纹理。Engine dispose 时调用
22885
22977
  */ _proto.dispose = function dispose() {
22978
+ this.clear();
22979
+ };
22980
+ _proto.clear = function clear() {
22886
22981
  for(var _iterator = _create_for_of_iterator_helper_loose(this.atlases.values()), _step; !(_step = _iterator()).done;){
22887
22982
  var atlas = _step.value;
22888
22983
  atlas.dispose();
@@ -23005,6 +23100,17 @@ var Graphics = /*#__PURE__*/ function() {
23005
23100
  this.texturedMaterial.depthTest = false;
23006
23101
  this.texturedMaterial.depthMask = false;
23007
23102
  this.texturedMaterial.blending = true;
23103
+ // 文本 atlas 按 Pixi 的方式在上传时预乘 alpha,因此采样后只需应用顶点色和顶点 alpha。
23104
+ // 单独使用 material,避免改变 drawTexture 对普通非预乘纹理的处理。
23105
+ this.textMaterial = Material.create(this.engine, {
23106
+ shader: {
23107
+ vertex: "precision highp float;\n attribute vec2 aPos;\n attribute vec4 aColor;\n attribute vec2 aUV;\n varying vec4 vColor;\n varying vec2 vUV;\n\n uniform mat4 effects_MatrixVP;\n void main() {\n vColor = aColor;\n vUV = aUV;\n gl_Position = effects_MatrixVP * vec4(aPos, 0.0, 1.0);\n }",
23108
+ fragment: "precision highp float;\n varying vec4 vColor;\n varying vec2 vUV;\n uniform sampler2D uMainTexture;\n void main() {\n float alpha = texture2D(uMainTexture, vUV).a * vColor.a;\n gl_FragColor = vec4(vColor.rgb * alpha, alpha);\n }"
23109
+ }
23110
+ });
23111
+ this.textMaterial.depthTest = false;
23112
+ this.textMaterial.depthMask = false;
23113
+ this.textMaterial.blending = true;
23008
23114
  this.textCache = new TextCache(engine);
23009
23115
  }
23010
23116
  var _proto = Graphics.prototype;
@@ -23019,13 +23125,14 @@ var Graphics = /*#__PURE__*/ function() {
23019
23125
  this.currentTransform = Matrix3.fromIdentity();
23020
23126
  this.currentBatchType = "colored";
23021
23127
  this.currentBatchTexture = null;
23022
- // 创建从屏幕坐标到 NDC 的投影矩阵,屏幕坐标: (0, 0) 在左下角,(width, height) 在右上角
23128
+ // 创建从屏幕坐标到 NDC 的投影矩阵,屏幕坐标:(0, 0) 在左上角,(width, height) 在右下角,+Y 向下。
23023
23129
  var _this_engine_canvas_getBoundingClientRect = this.engine.canvas.getBoundingClientRect(), width = _this_engine_canvas_getBoundingClientRect.width, height = _this_engine_canvas_getBoundingClientRect.height;
23024
23130
  // 正交投影矩阵:将屏幕坐标 [0, width] x [0, height] 映射到 NDC [-1, 1] x [-1, 1]
23025
- var projectionMatrix = new Matrix4(2 / width, 0, 0, 0, 0, 2 / height, 0, 0, 0, 0, -1, 0, -1, -1, 0, 1 // 第四列
23131
+ var projectionMatrix = new Matrix4(2 / width, 0, 0, 0, 0, -2 / height, 0, 0, 0, 0, -1, 0, -1, 1, 0, 1 // 第四列
23026
23132
  );
23027
23133
  this.coloredMaterial.setMatrix("effects_MatrixVP", projectionMatrix);
23028
23134
  this.texturedMaterial.setMatrix("effects_MatrixVP", projectionMatrix);
23135
+ this.textMaterial.setMatrix("effects_MatrixVP", projectionMatrix);
23029
23136
  };
23030
23137
  /**
23031
23138
  * 将当前变换压入栈,并设置新的变换
@@ -23053,7 +23160,7 @@ var Graphics = /*#__PURE__*/ function() {
23053
23160
  * 切换到指定批次类型/纹理。若与当前批次不一致,先 flush 已累积顶点
23054
23161
  */ _proto.ensureBatch = function ensureBatch(type, texture) {
23055
23162
  if (texture === void 0) texture = null;
23056
- var sameBatch = this.currentBatchType === type && (type !== "textured" || this.currentBatchTexture === texture);
23163
+ var sameBatch = this.currentBatchType === type && (type === "colored" || this.currentBatchTexture === texture);
23057
23164
  if (!sameBatch && this.currentVertexCount > 0) {
23058
23165
  this.flushBatch();
23059
23166
  }
@@ -23079,8 +23186,8 @@ var Graphics = /*#__PURE__*/ function() {
23079
23186
  this.geometry.setIndexData(indicesArray);
23080
23187
  this.geometry.setDrawCount(this.currentIndexCount);
23081
23188
  var material;
23082
- if (this.currentBatchType === "textured") {
23083
- material = this.texturedMaterial;
23189
+ if (this.currentBatchType === "textured" || this.currentBatchType === "text") {
23190
+ material = this.currentBatchType === "text" ? this.textMaterial : this.texturedMaterial;
23084
23191
  var _this_currentBatchTexture;
23085
23192
  var tex = (_this_currentBatchTexture = this.currentBatchTexture) != null ? _this_currentBatchTexture : this.engine.whiteTexture;
23086
23193
  material.setTexture("uMainTexture", tex);
@@ -23186,8 +23293,8 @@ var Graphics = /*#__PURE__*/ function() {
23186
23293
  };
23187
23294
  /**
23188
23295
  * 绘制矩形边框
23189
- * @param x - 矩形左下角 X 坐标
23190
- * @param y - 矩形左下角 Y 坐标
23296
+ * @param x - 矩形左上角 X 坐标
23297
+ * @param y - 矩形左上角 Y 坐标
23191
23298
  * @param width - 矩形宽度
23192
23299
  * @param height - 矩形高度
23193
23300
  * @param color - 边框颜色,默认白色,范围 0-1
@@ -23230,8 +23337,8 @@ var Graphics = /*#__PURE__*/ function() {
23230
23337
  };
23231
23338
  /**
23232
23339
  * 绘制填充矩形
23233
- * @param x - 矩形左下角 X 坐标
23234
- * @param y - 矩形左下角 Y 坐标
23340
+ * @param x - 矩形左上角 X 坐标
23341
+ * @param y - 矩形左上角 Y 坐标
23235
23342
  * @param width - 矩形宽度
23236
23343
  * @param height - 矩形高度
23237
23344
  * @param color - 填充颜色,默认白色,范围 0-1
@@ -23257,9 +23364,9 @@ var Graphics = /*#__PURE__*/ function() {
23257
23364
  this.buildShape(this.circleShape, color);
23258
23365
  };
23259
23366
  /**
23260
- * 绘制纹理矩形(本地坐标,Y 向上,(x, y) 为左下角)
23261
- * @param x - 矩形左下角 X 坐标
23262
- * @param y - 矩形左下角 Y 坐标
23367
+ * 绘制纹理矩形(本地坐标,Y 向下,(x, y) 为左上角)
23368
+ * @param x - 矩形左上角 X 坐标
23369
+ * @param y - 矩形左上角 Y 坐标
23263
23370
  * @param width - 矩形宽度
23264
23371
  * @param height - 矩形高度
23265
23372
  * @param texture - 要采样的纹理。同纹理连续绘制会合批,纹理切换会自动 flush 当前批次
@@ -23272,14 +23379,14 @@ var Graphics = /*#__PURE__*/ function() {
23272
23379
  this.pushQuad(x, y, width, height, color, region);
23273
23380
  };
23274
23381
  /**
23275
- * 绘制文本(本地坐标,Y 向上,(x, y) 为文本左下角)。
23382
+ * 绘制文本(本地坐标,Y 向下,(x, y) 为文本 cell 左上角)。
23276
23383
  *
23277
23384
  * 文本走字符级 bitmap atlas(同一字体下每个字只渲染一次,任意文本组合复用 atlas);
23278
23385
  * `color` 作为乘色与白色字形 alpha 相乘,任意颜色都不会污染 atlas。
23279
23386
  *
23280
23387
  * 字体参数全部展开,避免调用方每帧创建临时 style 对象触发 GC
23281
- * @param x - 文本左下角 X 坐标(首字 ink 起始处,含 padding 的 quad 会向左延伸)
23282
- * @param y - 文本左下角 Y 坐标(cell 底,含底部 padding;字形 ink 在其上方 padding+ascent 处)
23388
+ * @param x - 文本左上角 X 坐标(首字 ink 起始处,含 padding 的 quad 会向左延伸)
23389
+ * @param y - 文本 cell 顶部 Y 坐标
23283
23390
  * @param text - 要绘制的文本内容,空串直接 return
23284
23391
  * @param fontSize - 字号(逻辑像素)
23285
23392
  * @param color - 乘色,默认白色,范围 0-1
@@ -23295,7 +23402,7 @@ var Graphics = /*#__PURE__*/ function() {
23295
23402
  return;
23296
23403
  }
23297
23404
  var atlas = this.textCache.getAtlas(fontSize, fontFamily, fontWeight, fontStyle);
23298
- this.ensureBatch("textured", atlas.texture);
23405
+ this.ensureBatch("text", atlas.texture);
23299
23406
  var lineHeight = atlas.lineHeight;
23300
23407
  var cursorX = x;
23301
23408
  // ensureChar 可能往 atlas canvas 写新字并打 dirty 标;实际 upload 推迟到
@@ -23306,13 +23413,15 @@ var Graphics = /*#__PURE__*/ function() {
23306
23413
  continue;
23307
23414
  }
23308
23415
  // atlas 像素坐标 → UV(纹理 flipY 后,canvas 顶 → v=1,canvas 底 → v=0)
23309
- var u0 = info.px / ATLAS_SIZE;
23310
- var u1 = (info.px + info.pw) / ATLAS_SIZE;
23311
- var v0 = 1 - (info.py + info.ph) / ATLAS_SIZE;
23312
- var v1 = 1 - info.py / ATLAS_SIZE;
23416
+ var atlasWidth = atlas.canvas.width;
23417
+ var atlasHeight = atlas.canvas.height;
23418
+ var u0 = info.px / atlasWidth;
23419
+ var u1 = (info.px + info.pw) / atlasWidth;
23420
+ var v0 = 1 - (info.py + info.ph) / atlasHeight;
23421
+ var v1 = 1 - info.py / atlasHeight;
23313
23422
  // quad 宽与采样区都含四周 padding(cell 留白透明);但光标只按 advance 前进,
23314
23423
  // quad 起点左偏 paddingLeft 使字形 ink 落在 cursorX — padding 区重叠无妨
23315
- this.pushQuad(cursorX - info.paddingLeft, y, info.pw / FONT_SCALE, lineHeight, color, {
23424
+ this.pushQuad(cursorX - info.paddingLeft, y, info.pw / atlas.resolution, lineHeight, color, {
23316
23425
  u0: u0,
23317
23426
  v0: v0,
23318
23427
  u1: u1,
@@ -23325,6 +23434,7 @@ var Graphics = /*#__PURE__*/ function() {
23325
23434
  this.geometry.dispose();
23326
23435
  this.coloredMaterial.dispose();
23327
23436
  this.texturedMaterial.dispose();
23437
+ this.textMaterial.dispose();
23328
23438
  this.textCache.dispose();
23329
23439
  };
23330
23440
  _proto.buildShape = function buildShape(shape, color) {
@@ -23391,7 +23501,7 @@ var Graphics = /*#__PURE__*/ function() {
23391
23501
  * 在像素级亚像素精度下会暴露 1-2 像素缝隙,叠层时底层颜色透出形成可见的对角痕迹
23392
23502
  */ _proto.pushQuad = function pushQuad(x, y, width, height, color, region) {
23393
23503
  var vertexOffset = this.vertices.length / 2;
23394
- // 4 顶点(本地坐标,左下/右下/左上/右上),应用当前变换写入 vertices
23504
+ // 4 顶点(本地坐标,左上/右上/左下/右下),应用当前变换写入 vertices
23395
23505
  var corners = [
23396
23506
  [
23397
23507
  x,
@@ -23417,19 +23527,19 @@ var Graphics = /*#__PURE__*/ function() {
23417
23527
  var cornerUVs = [
23418
23528
  [
23419
23529
  u0,
23420
- v0
23530
+ v1
23421
23531
  ],
23422
23532
  [
23423
23533
  u1,
23424
- v0
23534
+ v1
23425
23535
  ],
23426
23536
  [
23427
23537
  u0,
23428
- v1
23538
+ v0
23429
23539
  ],
23430
23540
  [
23431
23541
  u1,
23432
- v1
23542
+ v0
23433
23543
  ]
23434
23544
  ];
23435
23545
  for(var i = 0; i < 4; i++){
@@ -24395,433 +24505,365 @@ exports.FrameComponent = __decorate([
24395
24505
  // 第四列 (位移) 乘 1,无需修改
24396
24506
  }
24397
24507
 
24398
- /**
24399
- * 画布层组件
24400
- *
24401
- * 作为一组顶层 CanvasItem 的容器:本层内所有 parent 为 null 的 CanvasItem 都登记在 canvasItems 中。
24402
- * 嵌套关系下的子 CanvasItem 通过其父 CanvasItem 的 children 数组管理,由父节点在 draw 时递归绘制。
24403
- */ var CanvasLayer = /*#__PURE__*/ function(Component) {
24404
- _inherits(CanvasLayer, Component);
24405
- function CanvasLayer() {
24406
- var _this;
24407
- _this = Component.apply(this, arguments) || this;
24408
- /**
24409
- * 当前层中的顶层 CanvasItem 列表(按注册顺序)。
24410
- * 仅包含 parent 为 null 的 CanvasItem;嵌套的子 CanvasItem 不会出现在此列表
24411
- */ _this.canvasItems = [];
24412
- /**
24413
- * 绘制层级,数值越小越先绘制
24414
- */ _this.layer = 0;
24415
- return _this;
24416
- }
24417
- var _proto = CanvasLayer.prototype;
24418
- /**
24419
- * 注册一个顶层 CanvasItem 到当前层
24420
- * @internal
24421
- */ _proto.addCanvasItem = function addCanvasItem(canvasItem) {
24422
- if (this.canvasItems.includes(canvasItem)) {
24423
- return;
24424
- }
24425
- this.canvasItems.push(canvasItem);
24426
- };
24427
- /**
24428
- * 从当前层注销一个顶层 CanvasItem
24429
- * @internal
24430
- */ _proto.removeCanvasItem = function removeCanvasItem(canvasItem) {
24431
- removeItem(this.canvasItems, canvasItem);
24432
- };
24433
- _proto.onEnable = function onEnable() {
24434
- var _this_item_composition;
24435
- var canvasLayers = (_this_item_composition = this.item.composition) == null ? void 0 : _this_item_composition.canvasLayers;
24436
- if (canvasLayers && !canvasLayers.includes(this)) {
24437
- canvasLayers.push(this);
24438
- }
24439
- };
24440
- _proto.onDisable = function onDisable() {
24441
- this.removeFromComposition();
24442
- this.refreshCanvasItemsLayer();
24508
+ function _assert_this_initialized(self) {
24509
+ if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
24510
+ return self;
24511
+ }
24512
+
24513
+ exports.MouseFilter = void 0;
24514
+ (function(MouseFilter) {
24515
+ MouseFilter[MouseFilter["Stop"] = 0] = "Stop";
24516
+ MouseFilter[MouseFilter["Pass"] = 1] = "Pass";
24517
+ MouseFilter[MouseFilter["Ignore"] = 2] = "Ignore";
24518
+ })(exports.MouseFilter || (exports.MouseFilter = {}));
24519
+ exports.MouseBehaviorRecursive = void 0;
24520
+ (function(MouseBehaviorRecursive) {
24521
+ MouseBehaviorRecursive[MouseBehaviorRecursive["Inherited"] = 0] = "Inherited";
24522
+ MouseBehaviorRecursive[MouseBehaviorRecursive["Disabled"] = 1] = "Disabled";
24523
+ MouseBehaviorRecursive[MouseBehaviorRecursive["Enabled"] = 2] = "Enabled";
24524
+ })(exports.MouseBehaviorRecursive || (exports.MouseBehaviorRecursive = {}));
24525
+ exports.MouseButton = void 0;
24526
+ (function(MouseButton) {
24527
+ MouseButton[MouseButton["None"] = 0] = "None";
24528
+ MouseButton[MouseButton["Left"] = 1] = "Left";
24529
+ MouseButton[MouseButton["Right"] = 2] = "Right";
24530
+ MouseButton[MouseButton["Middle"] = 3] = "Middle";
24531
+ MouseButton[MouseButton["WheelUp"] = 4] = "WheelUp";
24532
+ MouseButton[MouseButton["WheelDown"] = 5] = "WheelDown";
24533
+ MouseButton[MouseButton["WheelLeft"] = 6] = "WheelLeft";
24534
+ MouseButton[MouseButton["WheelRight"] = 7] = "WheelRight";
24535
+ MouseButton[MouseButton["Xbutton1"] = 8] = "Xbutton1";
24536
+ MouseButton[MouseButton["Xbutton2"] = 9] = "Xbutton2";
24537
+ })(exports.MouseButton || (exports.MouseButton = {}));
24538
+ exports.MouseButtonMask = void 0;
24539
+ (function(MouseButtonMask) {
24540
+ MouseButtonMask[MouseButtonMask["None"] = 0] = "None";
24541
+ MouseButtonMask[MouseButtonMask["Left"] = 1] = "Left";
24542
+ MouseButtonMask[MouseButtonMask["Right"] = 2] = "Right";
24543
+ MouseButtonMask[MouseButtonMask["Middle"] = 4] = "Middle";
24544
+ MouseButtonMask[MouseButtonMask["Xbutton1"] = 128] = "Xbutton1";
24545
+ MouseButtonMask[MouseButtonMask["Xbutton2"] = 256] = "Xbutton2";
24546
+ })(exports.MouseButtonMask || (exports.MouseButtonMask = {}));
24547
+ exports.FocusMode = void 0;
24548
+ (function(FocusMode) {
24549
+ FocusMode[FocusMode["None"] = 0] = "None";
24550
+ FocusMode[FocusMode["Click"] = 1] = "Click";
24551
+ FocusMode[FocusMode["All"] = 2] = "All";
24552
+ FocusMode[FocusMode["Accessibility"] = 3] = "Accessibility";
24553
+ })(exports.FocusMode || (exports.FocusMode = {}));
24554
+ exports.FocusBehaviorRecursive = void 0;
24555
+ (function(FocusBehaviorRecursive) {
24556
+ FocusBehaviorRecursive[FocusBehaviorRecursive["Inherited"] = 0] = "Inherited";
24557
+ FocusBehaviorRecursive[FocusBehaviorRecursive["Disabled"] = 1] = "Disabled";
24558
+ FocusBehaviorRecursive[FocusBehaviorRecursive["Enabled"] = 2] = "Enabled";
24559
+ })(exports.FocusBehaviorRecursive || (exports.FocusBehaviorRecursive = {}));
24560
+ exports.KeyLocation = void 0;
24561
+ (function(KeyLocation) {
24562
+ KeyLocation[KeyLocation["Unspecified"] = 0] = "Unspecified";
24563
+ KeyLocation[KeyLocation["Left"] = 1] = "Left";
24564
+ KeyLocation[KeyLocation["Right"] = 2] = "Right";
24565
+ })(exports.KeyLocation || (exports.KeyLocation = {}));
24566
+ exports.CursorShape = void 0;
24567
+ (function(CursorShape) {
24568
+ CursorShape[CursorShape["Arrow"] = 0] = "Arrow";
24569
+ CursorShape[CursorShape["Ibeam"] = 1] = "Ibeam";
24570
+ CursorShape[CursorShape["PointingHand"] = 2] = "PointingHand";
24571
+ CursorShape[CursorShape["Cross"] = 3] = "Cross";
24572
+ CursorShape[CursorShape["Wait"] = 4] = "Wait";
24573
+ CursorShape[CursorShape["Busy"] = 5] = "Busy";
24574
+ CursorShape[CursorShape["Drag"] = 6] = "Drag";
24575
+ CursorShape[CursorShape["CanDrop"] = 7] = "CanDrop";
24576
+ CursorShape[CursorShape["Forbidden"] = 8] = "Forbidden";
24577
+ CursorShape[CursorShape["Vsize"] = 9] = "Vsize";
24578
+ CursorShape[CursorShape["Hsize"] = 10] = "Hsize";
24579
+ CursorShape[CursorShape["Bdiagsize"] = 11] = "Bdiagsize";
24580
+ CursorShape[CursorShape["Fdiagsize"] = 12] = "Fdiagsize";
24581
+ CursorShape[CursorShape["Move"] = 13] = "Move";
24582
+ CursorShape[CursorShape["Vsplit"] = 14] = "Vsplit";
24583
+ CursorShape[CursorShape["Hsplit"] = 15] = "Hsplit";
24584
+ CursorShape[CursorShape["Help"] = 16] = "Help";
24585
+ })(exports.CursorShape || (exports.CursorShape = {}));
24586
+
24587
+ function _get_prototype_of(o) {
24588
+ _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
24589
+ return o.__proto__ || Object.getPrototypeOf(o);
24443
24590
  };
24444
- _proto.removeFromComposition = function removeFromComposition() {
24445
- var _this_item_composition;
24446
- var canvasLayers = (_this_item_composition = this.item.composition) == null ? void 0 : _this_item_composition.canvasLayers;
24447
- if (canvasLayers) {
24448
- removeItem(canvasLayers, this);
24591
+ return _get_prototype_of(o);
24592
+ }
24593
+
24594
+ function _is_native_function(fn) {
24595
+ return Function.toString.call(fn).indexOf("[native code]") !== -1;
24596
+ }
24597
+
24598
+ function _wrap_native_super(Class) {
24599
+ var _cache = typeof Map === "function" ? new Map() : undefined;
24600
+ _wrap_native_super = function _wrap_native_super(Class) {
24601
+ if (Class === null || !_is_native_function(Class)) return Class;
24602
+ if (typeof Class !== "function") throw new TypeError("Super expression must either be null or a function");
24603
+ if (typeof _cache !== "undefined") {
24604
+ if (_cache.has(Class)) return _cache.get(Class);
24605
+ _cache.set(Class, Wrapper);
24449
24606
  }
24450
- };
24451
- _proto.refreshCanvasItemsLayer = function refreshCanvasItemsLayer() {
24452
- // CanvasLayer 失效时,让其下挂的 CanvasItem 重新查找归属层
24453
- // 拷贝一份避免迭代过程中数组被修改
24454
- var items = this.canvasItems.slice();
24455
- this.canvasItems.length = 0;
24456
- for(var _iterator = _create_for_of_iterator_helper_loose(items), _step; !(_step = _iterator()).done;){
24457
- var canvasItem = _step.value;
24458
- canvasItem.updateCanvasLayer();
24607
+ function Wrapper() {
24608
+ return _construct(Class, arguments, _get_prototype_of(this).constructor);
24459
24609
  }
24460
- };
24461
- /**
24462
- * 绘制当前层
24463
- *
24464
- * 遍历顶层 CanvasItem 进行绘制,由 CanvasItem.drawInternal 内部递归子节点。
24465
- * 整棵跳过看 `vfxItem.isActive`(item 级开关);self 自身是否画由 drawInternal 内的 `component.enabled` 决定。
24466
- *
24467
- * 注:画布尺寸到 RectTransform.size 的同步目前未在此处处理(由 RectTransform 自身按需 resolve);
24468
- * 后续若需要在每帧强制刷新顶层 size,可在此处补回写入与 sizeChanged 传播
24469
- *
24470
- * @internal
24471
- */ _proto.draw = function draw() {
24472
- for(var _iterator = _create_for_of_iterator_helper_loose(this.canvasItems), _step; !(_step = _iterator()).done;){
24473
- var canvasItem = _step.value;
24474
- if (!canvasItem.item.isActive) {
24475
- continue;
24610
+ Wrapper.prototype = Object.create(Class.prototype, {
24611
+ constructor: {
24612
+ value: Wrapper,
24613
+ enumerable: false,
24614
+ writable: true,
24615
+ configurable: true
24476
24616
  }
24477
- canvasItem.drawInternal();
24478
- }
24617
+ });
24618
+ return _set_prototype_of(Wrapper, Class);
24479
24619
  };
24480
- return CanvasLayer;
24481
- }(Component);
24620
+ return _wrap_native_super(Class);
24621
+ }
24482
24622
 
24483
- /**
24484
- * 画布元素组件
24485
- *
24486
- * 进入场景树时沿父链向上查找最近的 CanvasLayer 祖先并注册自己;
24487
- * 父级改变或自身销毁时,刷新 / 注销在所属 CanvasLayer 的登记。
24488
- *
24489
- * 注:拓扑(parent / children / 所属 layer)与 enabled/active 解耦
24490
- * `component.enabled=false` 仅让自身 draw 被跳过,**不**改父子关系,也**不**从 layer 注销;
24491
- * 整棵子树的隐藏由 `vfxItem.setActive(false)` 配合 drawInternal 中的 `isActive` 检查处理
24492
- */ var CanvasItem = /*#__PURE__*/ function(Component) {
24493
- _inherits(CanvasItem, Component);
24494
- function CanvasItem() {
24495
- var _this;
24496
- _this = Component.apply(this, arguments) || this;
24497
- /**
24498
- * 父 CanvasItem
24499
- * 沿 VFXItem 父链向上查找到的最近的 CanvasItem(只看类型,不看 active/enabled — 拓扑跟激活状态解耦)。
24500
- * 若不存在 CanvasItem 祖先(即直属于 CanvasLayer 或处于游离状态),该值为 null。
24501
- */ _this.parent = null;
24502
- /**
24503
- * 子 CanvasItem 列表(按注册顺序)
24504
- * 由子节点在维护自身 parent 时反向写入,draw 时按数组顺序递归绘制
24505
- */ _this.children = [];
24506
- /**
24507
- * 当前所属的 CanvasLayer,未注册到任何 CanvasLayer 时为 null
24508
- */ _this.canvasLayerNode = null;
24509
- return _this;
24623
+ function transformPoint(transform, value) {
24624
+ var elements = transform.elements;
24625
+ return new Vector2(elements[0] * value.x + elements[3] * value.y + elements[6], elements[1] * value.x + elements[4] * value.y + elements[7]);
24626
+ }
24627
+ function transformVector(transform, value) {
24628
+ var elements = transform.elements;
24629
+ return new Vector2(elements[0] * value.x + elements[3] * value.y, elements[1] * value.x + elements[4] * value.y);
24630
+ }
24631
+ var InputEvent = /*#__PURE__*/ function() {
24632
+ function InputEvent() {
24633
+ this.device = 0;
24634
+ this.pressed = false;
24635
+ this.canceled = false;
24636
+ this._accepted = false;
24510
24637
  }
24511
- var _proto = CanvasItem.prototype;
24512
- _proto.onEnable = function onEnable() {
24513
- // 首次接入 / 重新接入场景树时把自己挂上(若拓扑还没建立)。
24514
- // 注意 enable/disable 不再改变 CanvasItem 父子拓扑 — 拓扑由 VFXItem 父链(setParent / onParentChanged)维护,
24515
- // enable 在这里只是兜底首次入树
24516
- this.updateCanvasLayer();
24517
- this.updateParentItem();
24638
+ var _proto = InputEvent.prototype;
24639
+ _proto.accept = function accept() {
24640
+ this._accepted = true;
24518
24641
  };
24519
- _proto.onDisable = function onDisable() {
24520
- // 组件禁用 = 仅 self.draw 跳过,不应改父子拓扑(否则 enable 回来位置就乱了)。
24521
- // 整棵子树的隐藏由 `vfxItem.setActive(false)` 配合 drawInternal 中的 `item.isActive` 检查处理
24642
+ _proto.clearAccepted = function clearAccepted() {
24643
+ this._accepted = false;
24522
24644
  };
24523
- _proto.onParentChanged = function onParentChanged() {
24524
- // VFXItem 的父级(或间接父级)发生变化时,CanvasLayer 与父 CanvasItem 都可能改变,需要联动刷新
24525
- this.updateCanvasLayer();
24526
- this.updateParentItem();
24645
+ _proto.isAccepted = function isAccepted() {
24646
+ return this._accepted;
24527
24647
  };
24528
- _proto.onDestroy = function onDestroy() {
24529
- this.removeFromParent();
24530
- this.removeFromCanvasLayer();
24531
- // 防止子 canvasItem updateParentItem 的时候继续找到当前已销毁的 canvasItem
24532
- this.enabled = false;
24533
- this.updateChildrenParentItems();
24648
+ _proto.isPressed = function isPressed() {
24649
+ return this.pressed && !this.canceled;
24534
24650
  };
24535
- /**
24536
- * 重新计算并更新当前 CanvasItem 应归属的 CanvasLayer
24537
- * 在父级变化、所在 CanvasLayer 失效等场景中调用
24538
- *
24539
- * 仅当自身是顶层 CanvasItem(parent 为 null)时才会登记到 CanvasLayer.canvasItems;
24540
- * 嵌套的子 CanvasItem 仅记录 canvasLayerNode 引用,不进入 layer 的顶层列表。
24541
- * @internal
24542
- */ _proto.updateCanvasLayer = function updateCanvasLayer() {
24543
- // 拓扑跟 enabled/active 解耦,只看 item 是否还在
24544
- if (!this.item) {
24545
- this.removeFromCanvasLayer();
24546
- return;
24547
- }
24548
- var newLayer = this.getCanvasLayerNode();
24549
- if (newLayer === this.canvasLayerNode) {
24550
- return;
24551
- }
24552
- // 仅当自身是顶层 CanvasItem 时,才需要在 layer 的 canvasItems 中迁移
24553
- if (this.parent === null && this.canvasLayerNode) {
24554
- this.canvasLayerNode.removeCanvasItem(this);
24555
- }
24556
- this.canvasLayerNode = newLayer;
24557
- if (this.parent === null && newLayer) {
24558
- newLayer.addCanvasItem(this);
24559
- }
24651
+ _proto.isReleased = function isReleased() {
24652
+ return !this.pressed && !this.canceled;
24560
24653
  };
24561
- /**
24562
- * 重新计算并更新当前 CanvasItem 的父 CanvasItem
24563
- * 在 VFXItem 父级变化、自身启用/禁用、父 CanvasItem 失效等场景中调用
24564
- *
24565
- * parent 的变化会同步影响在 CanvasLayer.canvasItems 中的归属:
24566
- * - 由有 parent 变成无 parent 且仍归属某 layer:加入 layer.canvasItems
24567
- * - 由无 parent 变成有 parent:从 layer.canvasItems 中移除
24568
- * @internal
24569
- */ _proto.updateParentItem = function updateParentItem() {
24570
- // 拓扑跟 enabled/active 解耦,只看 item 是否还在
24571
- if (!this.item) {
24572
- this.removeFromParent();
24573
- return;
24574
- }
24575
- var newParent = this.getParentItem();
24576
- if (newParent === this.parent) {
24577
- return;
24578
- }
24579
- var wasTopLevel = this.parent === null;
24580
- this.removeFromParent();
24581
- if (newParent) {
24582
- this.parent = newParent;
24583
- newParent.children.push(this);
24584
- // 由顶层变成嵌套:从 layer 的顶层列表中移除
24585
- if (wasTopLevel && this.canvasLayerNode) {
24586
- this.canvasLayerNode.removeCanvasItem(this);
24587
- }
24588
- } else if (!wasTopLevel && this.canvasLayerNode) {
24589
- // 由嵌套变成顶层:加入 layer 的顶层列表
24590
- this.canvasLayerNode.addCanvasItem(this);
24591
- }
24592
- };
24593
- /**
24594
- * 绘制函数
24595
- * 子类重写此方法以输出实际的绘制内容;调用时 graphics 的变换栈顶已经累积了从根到当前节点的所有父变换,
24596
- * 子类直接使用 this.drawXxx / this.fillXxx 系列封装方法绘制即可,绘制坐标视为本地坐标。
24597
- */ _proto.draw = function draw() {
24598
- // OVERRIDE
24599
- };
24600
- /**
24601
- * 绘制单条线段
24602
- * @param x1 - 起点 x
24603
- * @param y1 - 起点 y
24604
- * @param x2 - 终点 x
24605
- * @param y2 - 终点 y
24606
- * @param color - 线条颜色
24607
- * @param thickness - 线宽
24608
- */ _proto.drawLine = function drawLine(x1, y1, x2, y2, color, thickness) {
24609
- this.engine.graphics.drawLine(x1, y1, x2, y2, color, thickness);
24610
- };
24611
- /**
24612
- * 按顺序连接所有点绘制折线(首尾相同则视为闭合)
24613
- * @param points - 点数组,格式 [x1,y1,x2,y2,...]
24614
- * @param color - 线条颜色
24615
- * @param thickness - 线宽
24616
- */ _proto.drawPolyline = function drawPolyline(points, color, thickness) {
24617
- this.engine.graphics.drawLines(points, color, thickness);
24618
- };
24619
- /**
24620
- * 绘制三次贝塞尔曲线
24621
- */ _proto.drawBezier = function drawBezier(x1, y1, x2, y2, x3, y3, x4, y4, color, thickness) {
24622
- this.engine.graphics.drawBezier(x1, y1, x2, y2, x3, y3, x4, y4, color, thickness);
24623
- };
24624
- /**
24625
- * 绘制三角形边框
24626
- */ _proto.drawTriangle = function drawTriangle(x1, y1, x2, y2, x3, y3, color, thickness) {
24627
- this.engine.graphics.drawTriangle(x1, y1, x2, y2, x3, y3, color, thickness);
24628
- };
24629
- /**
24630
- * 绘制矩形边框
24631
- * @param x - 矩形左下角 x 坐标
24632
- * @param y - 矩形左下角 y 坐标
24633
- */ _proto.drawRect = function drawRect(x, y, width, height, color, thickness) {
24634
- this.engine.graphics.drawRectangle(x, y, width, height, color, thickness);
24635
- };
24636
- /**
24637
- * 绘制圆形边框
24638
- */ _proto.drawCircle = function drawCircle(cx, cy, radius, color, thickness) {
24639
- this.engine.graphics.drawCircle(cx, cy, radius, color, thickness);
24640
- };
24641
- /**
24642
- * 绘制填充三角形
24643
- */ _proto.fillTriangle = function fillTriangle(x1, y1, x2, y2, x3, y3, color) {
24644
- this.engine.graphics.fillTriangle(x1, y1, x2, y2, x3, y3, color);
24645
- };
24646
- /**
24647
- * 绘制填充矩形
24648
- * @param x - 矩形左下角 x 坐标
24649
- * @param y - 矩形左下角 y 坐标
24650
- */ _proto.fillRect = function fillRect(x, y, width, height, color) {
24651
- this.engine.graphics.fillRectangle(x, y, width, height, color);
24652
- };
24653
- /**
24654
- * 绘制填充圆形
24655
- */ _proto.fillCircle = function fillCircle(cx, cy, radius, color) {
24656
- this.engine.graphics.fillCircle(cx, cy, radius, color);
24657
- };
24658
- /**
24659
- * 绘制纹理矩形(本地坐标,Y 向上,(x, y) 为左下角)
24660
- * @param region - 纹理 UV 子矩形,默认全图。Y 向上,(u0, v0) 为左下角 UV
24661
- * @param color - 乘色,默认白色
24662
- */ _proto.drawTexture = function drawTexture(x, y, width, height, texture, region, color) {
24663
- this.engine.graphics.drawTexture(x, y, width, height, texture, region, color);
24664
- };
24665
- /**
24666
- * 绘制文本(本地坐标,Y 向上,(x, y) 为文本左下角)。
24667
- *
24668
- * 同一段文本不同颜色不会重复 upload — 颜色由 `color` 参数透传作为乘色,纹理只缓存白色字形。
24669
- * 字体参数全部展开,避免调用方每帧创建临时 style 对象触发 GC
24670
- */ _proto.drawText = function drawText(x, y, text, fontSize, color, fontFamily, fontWeight, fontStyle) {
24671
- this.engine.graphics.drawText(x, y, text, fontSize, color, fontFamily, fontWeight, fontStyle);
24672
- };
24673
- /**
24674
- * 绘制自身并按 children 数组顺序递归绘制所有子 CanvasItem。
24675
- * @internal
24676
- */ _proto.drawInternal = function drawInternal() {
24677
- var graphics = this.engine.graphics;
24678
- var localMatrix2D = this.transform.getMatrix2D();
24679
- graphics.pushTransform(localMatrix2D);
24680
- // self 是否绘制只看 component.enabled — 其它都不影响。
24681
- // transform 始终被 push,children 始终被遍历,这样 component.enabled=false 时 self 隐藏
24682
- // 但 children 的位置不受影响
24683
- if (this.enabled) {
24684
- this.draw();
24685
- }
24686
- // 子是否参与绘制看 VFXItem.isActive(整棵跳过的语义)。
24687
- // 子自身的 component.enabled 在它自己的 drawInternal 里再判断
24688
- for(var _iterator = _create_for_of_iterator_helper_loose(this.children), _step; !(_step = _iterator()).done;){
24689
- var child = _step.value;
24690
- if (!child.item.isActive) {
24691
- continue;
24692
- }
24693
- child.drawInternal();
24694
- }
24695
- graphics.popTransform();
24696
- };
24697
- /**
24698
- * 从当前所属的 CanvasLayer 注销自身(如果有)
24699
- * 仅当自身是顶层 CanvasItem 时,才会触发 layer 顶层列表的移除
24700
- */ _proto.removeFromCanvasLayer = function removeFromCanvasLayer() {
24701
- if (!this.canvasLayerNode) {
24702
- return;
24703
- }
24704
- if (this.parent === null) {
24705
- this.canvasLayerNode.removeCanvasItem(this);
24706
- }
24707
- this.canvasLayerNode = null;
24708
- };
24709
- /**
24710
- * 从当前父 CanvasItem 的 children 中移除自身(如果有)
24711
- */ _proto.removeFromParent = function removeFromParent() {
24712
- if (!this.parent) {
24713
- return;
24714
- }
24715
- removeItem(this.parent.children, this);
24716
- this.parent = null;
24654
+ _proto.isCanceled = function isCanceled() {
24655
+ return this.canceled;
24717
24656
  };
24718
- /**
24719
- * 更新所有子 CanvasItem 的层级归属。
24720
- * 自身失效时调用,子节点会跳过自己向上找到新的父 CanvasItem(可能为 null)。
24721
- */ _proto.updateChildrenParentItems = function updateChildrenParentItems() {
24722
- if (this.children.length === 0) {
24723
- return;
24724
- }
24725
- // 拷贝避免迭代过程中数组被 removeFromParent 修改
24726
- var snapshot = this.children.slice();
24727
- for(var _iterator = _create_for_of_iterator_helper_loose(snapshot), _step; !(_step = _iterator()).done;){
24728
- var child = _step.value;
24729
- child.updateParentItem();
24730
- }
24657
+ _proto.isEcho = function isEcho() {
24658
+ return false;
24731
24659
  };
24732
- /**
24733
- * 沿父链向上查找最近的 CanvasLayer 祖先
24734
- * 注意:自身所在 VFXItem 上的 CanvasLayer 也参与查找(同节点上可能并存 CanvasLayer 与 CanvasItem)
24735
- */ _proto.getCanvasLayerNode = function getCanvasLayerNode() {
24736
- var current = this.item;
24737
- while(current){
24738
- var layer = getCanvasLayerFromItem(current);
24739
- if (layer) {
24740
- return layer;
24741
- }
24742
- var _current_parent;
24743
- current = (_current_parent = current.parent) != null ? _current_parent : null;
24744
- }
24745
- return null;
24660
+ _proto.xformedBy = function xformedBy(transform) {
24661
+ return this;
24746
24662
  };
24747
- /**
24748
- * 沿 VFXItem 父链向上查找最近的 CanvasItem 祖先(不包含自身,只看类型不看 active/enabled)
24749
- */ _proto.getParentItem = function getParentItem() {
24750
- var _this_item;
24751
- var _this_item_parent;
24752
- var current = (_this_item_parent = (_this_item = this.item) == null ? void 0 : _this_item.parent) != null ? _this_item_parent : null;
24753
- while(current){
24754
- var canvasItem = getCanvasItemFromItem(current);
24755
- if (canvasItem) {
24756
- return canvasItem;
24757
- }
24758
- var _current_parent;
24759
- current = (_current_parent = current.parent) != null ? _current_parent : null;
24760
- }
24761
- return null;
24663
+ return InputEvent;
24664
+ }();
24665
+ InputEvent.deviceIdEmulation = -1;
24666
+ InputEvent.deviceIdInternal = -2;
24667
+ InputEvent.deviceIdKeyboard = 16;
24668
+ InputEvent.deviceIdMouse = 32;
24669
+ var InputEventWithModifiers = /*#__PURE__*/ function(InputEvent) {
24670
+ _inherits(InputEventWithModifiers, InputEvent);
24671
+ function InputEventWithModifiers() {
24672
+ var _this;
24673
+ _this = InputEvent.apply(this, arguments) || this;
24674
+ _this.commandOrControlAutoremap = false;
24675
+ _this.shiftPressed = false;
24676
+ _this.altPressed = false;
24677
+ _this.metaPressed = false;
24678
+ _this.ctrlPressed = false;
24679
+ return _this;
24680
+ }
24681
+ var _proto = InputEventWithModifiers.prototype;
24682
+ _proto.copyModifiersTo = function copyModifiersTo(event) {
24683
+ event.device = this.device;
24684
+ event.pressed = this.pressed;
24685
+ event.canceled = this.canceled;
24686
+ event.commandOrControlAutoremap = this.commandOrControlAutoremap;
24687
+ event.shiftPressed = this.shiftPressed;
24688
+ event.altPressed = this.altPressed;
24689
+ event.metaPressed = this.metaPressed;
24690
+ event.ctrlPressed = this.ctrlPressed;
24691
+ };
24692
+ return InputEventWithModifiers;
24693
+ }(_wrap_native_super(InputEvent));
24694
+ var InputEventKey = /*#__PURE__*/ function(InputEventWithModifiers) {
24695
+ _inherits(InputEventKey, InputEventWithModifiers);
24696
+ function InputEventKey() {
24697
+ var _this;
24698
+ _this = InputEventWithModifiers.apply(this, arguments) || this;
24699
+ _this.keycode = "";
24700
+ _this.physicalKeycode = "";
24701
+ _this.keyLabel = "";
24702
+ _this.unicode = 0;
24703
+ _this.location = exports.KeyLocation.Unspecified;
24704
+ _this.echo = false;
24705
+ return _this;
24706
+ }
24707
+ var _proto = InputEventKey.prototype;
24708
+ _proto.isEcho = function isEcho() {
24709
+ return this.echo;
24762
24710
  };
24763
- _create_class(CanvasItem, [
24764
- {
24765
- key: "canvasLayer",
24766
- get: /**
24767
- * 获取当前所属的 CanvasLayer
24768
- */ function get() {
24769
- return this.canvasLayerNode;
24770
- }
24771
- }
24772
- ]);
24773
- return CanvasItem;
24774
- }(Component);
24775
- /**
24776
- * 在指定 VFXItem 上查找一个激活的 CanvasLayer 组件
24777
- */ function getCanvasLayerFromItem(item) {
24778
- for(var _iterator = _create_for_of_iterator_helper_loose(item.components), _step; !(_step = _iterator()).done;){
24779
- var component = _step.value;
24780
- if (_instanceof1(component, CanvasLayer) && component.isActiveAndEnabled) {
24781
- return component;
24782
- }
24711
+ return InputEventKey;
24712
+ }(InputEventWithModifiers);
24713
+ var InputEventMouse = /*#__PURE__*/ function(InputEventWithModifiers) {
24714
+ _inherits(InputEventMouse, InputEventWithModifiers);
24715
+ function InputEventMouse() {
24716
+ var _this;
24717
+ _this = InputEventWithModifiers.apply(this, arguments) || this;
24718
+ _this.buttonMask = exports.MouseButtonMask.None;
24719
+ _this.position = new Vector2();
24720
+ _this.globalPosition = new Vector2();
24721
+ return _this;
24783
24722
  }
24784
- return null;
24785
- }
24786
- /**
24787
- * 在指定 VFXItem 上查找 CanvasItem 组件(只看类型,不看 active/enabled — 拓扑跟激活状态解耦)
24788
- */ function getCanvasItemFromItem(item) {
24789
- for(var _iterator = _create_for_of_iterator_helper_loose(item.components), _step; !(_step = _iterator()).done;){
24790
- var component = _step.value;
24791
- if (_instanceof1(component, CanvasItem)) {
24792
- return component;
24793
- }
24723
+ var _proto = InputEventMouse.prototype;
24724
+ _proto.copyMouseTo = function copyMouseTo(event) {
24725
+ this.copyModifiersTo(event);
24726
+ event.buttonMask = this.buttonMask;
24727
+ event.position.copyFrom(this.position);
24728
+ event.globalPosition.copyFrom(this.globalPosition);
24729
+ };
24730
+ return InputEventMouse;
24731
+ }(InputEventWithModifiers);
24732
+ var InputEventMouseButton = /*#__PURE__*/ function(InputEventMouse) {
24733
+ _inherits(InputEventMouseButton, InputEventMouse);
24734
+ function InputEventMouseButton() {
24735
+ var _this;
24736
+ _this = InputEventMouse.apply(this, arguments) || this;
24737
+ _this.factor = 1;
24738
+ _this.buttonIndex = exports.MouseButton.None;
24739
+ _this.doubleClick = false;
24740
+ return _this;
24794
24741
  }
24795
- return null;
24796
- }
24797
-
24798
- /**
24799
- * 16 个 preset 对应的 anchorMin / anchorMax(Y 向上)
24800
- */ var ANCHOR_PRESET_TABLE = {
24801
- // [anchorMin.x, anchorMin.y, anchorMax.x, anchorMax.y]
24742
+ var _proto = InputEventMouseButton.prototype;
24743
+ _proto.xformedBy = function xformedBy(transform) {
24744
+ var event = new InputEventMouseButton();
24745
+ this.copyMouseTo(event);
24746
+ event.position.copyFrom(transformPoint(transform, this.position));
24747
+ event.factor = this.factor;
24748
+ event.buttonIndex = this.buttonIndex;
24749
+ event.doubleClick = this.doubleClick;
24750
+ return event;
24751
+ };
24752
+ return InputEventMouseButton;
24753
+ }(InputEventMouse);
24754
+ var InputEventMouseMotion = /*#__PURE__*/ function(InputEventMouse) {
24755
+ _inherits(InputEventMouseMotion, InputEventMouse);
24756
+ function InputEventMouseMotion() {
24757
+ var _this;
24758
+ _this = InputEventMouse.apply(this, arguments) || this;
24759
+ _this.tilt = new Vector2();
24760
+ _this.pressure = 0;
24761
+ _this.relative = new Vector2();
24762
+ _this.screenRelative = new Vector2();
24763
+ _this.velocity = new Vector2();
24764
+ _this.screenVelocity = new Vector2();
24765
+ _this.penInverted = false;
24766
+ return _this;
24767
+ }
24768
+ var _proto = InputEventMouseMotion.prototype;
24769
+ _proto.xformedBy = function xformedBy(transform) {
24770
+ var event = new InputEventMouseMotion();
24771
+ this.copyMouseTo(event);
24772
+ event.position.copyFrom(transformPoint(transform, this.position));
24773
+ event.tilt.copyFrom(this.tilt);
24774
+ event.pressure = this.pressure;
24775
+ event.relative.copyFrom(transformVector(transform, this.relative));
24776
+ event.screenRelative.copyFrom(this.screenRelative);
24777
+ event.velocity.copyFrom(transformVector(transform, this.velocity));
24778
+ event.screenVelocity.copyFrom(this.screenVelocity);
24779
+ event.penInverted = this.penInverted;
24780
+ return event;
24781
+ };
24782
+ return InputEventMouseMotion;
24783
+ }(InputEventMouse);
24784
+ var InputEventScreenTouch = /*#__PURE__*/ function(InputEvent) {
24785
+ _inherits(InputEventScreenTouch, InputEvent);
24786
+ function InputEventScreenTouch() {
24787
+ var _this;
24788
+ _this = InputEvent.apply(this, arguments) || this;
24789
+ _this.index = 0;
24790
+ _this.position = new Vector2();
24791
+ _this.doubleTap = false;
24792
+ return _this;
24793
+ }
24794
+ var _proto = InputEventScreenTouch.prototype;
24795
+ _proto.xformedBy = function xformedBy(transform) {
24796
+ var event = new InputEventScreenTouch();
24797
+ event.device = this.device;
24798
+ event.pressed = this.pressed;
24799
+ event.canceled = this.canceled;
24800
+ event.index = this.index;
24801
+ event.position.copyFrom(transformPoint(transform, this.position));
24802
+ event.doubleTap = this.doubleTap;
24803
+ return event;
24804
+ };
24805
+ return InputEventScreenTouch;
24806
+ }(_wrap_native_super(InputEvent));
24807
+ var InputEventScreenDrag = /*#__PURE__*/ function(InputEvent) {
24808
+ _inherits(InputEventScreenDrag, InputEvent);
24809
+ function InputEventScreenDrag() {
24810
+ var _this;
24811
+ _this = InputEvent.apply(this, arguments) || this;
24812
+ _this.index = 0;
24813
+ _this.position = new Vector2();
24814
+ _this.relative = new Vector2();
24815
+ _this.screenRelative = new Vector2();
24816
+ _this.velocity = new Vector2();
24817
+ _this.screenVelocity = new Vector2();
24818
+ _this.pressure = 0;
24819
+ _this.tilt = new Vector2();
24820
+ _this.penInverted = false;
24821
+ return _this;
24822
+ }
24823
+ var _proto = InputEventScreenDrag.prototype;
24824
+ _proto.xformedBy = function xformedBy(transform) {
24825
+ var event = new InputEventScreenDrag();
24826
+ event.device = this.device;
24827
+ event.pressed = this.pressed;
24828
+ event.canceled = this.canceled;
24829
+ event.index = this.index;
24830
+ event.position.copyFrom(transformPoint(transform, this.position));
24831
+ event.relative.copyFrom(transformVector(transform, this.relative));
24832
+ event.screenRelative.copyFrom(this.screenRelative);
24833
+ event.velocity.copyFrom(transformVector(transform, this.velocity));
24834
+ event.screenVelocity.copyFrom(this.screenVelocity);
24835
+ event.pressure = this.pressure;
24836
+ event.tilt.copyFrom(this.tilt);
24837
+ event.penInverted = this.penInverted;
24838
+ return event;
24839
+ };
24840
+ return InputEventScreenDrag;
24841
+ }(_wrap_native_super(InputEvent));
24842
+
24843
+ var ANCHOR_PRESET_TABLE = {
24802
24844
  topLeft: [
24803
24845
  0,
24804
- 1,
24805
24846
  0,
24806
- 1
24847
+ 0,
24848
+ 0
24807
24849
  ],
24808
24850
  topRight: [
24809
24851
  1,
24852
+ 0,
24810
24853
  1,
24811
- 1,
24812
- 1
24854
+ 0
24813
24855
  ],
24814
24856
  bottomLeft: [
24815
24857
  0,
24858
+ 1,
24816
24859
  0,
24817
- 0,
24818
- 0
24860
+ 1
24819
24861
  ],
24820
24862
  bottomRight: [
24821
24863
  1,
24822
- 0,
24823
24864
  1,
24824
- 0
24865
+ 1,
24866
+ 1
24825
24867
  ],
24826
24868
  centerLeft: [
24827
24869
  0,
@@ -24831,9 +24873,9 @@ exports.FrameComponent = __decorate([
24831
24873
  ],
24832
24874
  centerTop: [
24833
24875
  0.5,
24834
- 1,
24876
+ 0,
24835
24877
  0.5,
24836
- 1
24878
+ 0
24837
24879
  ],
24838
24880
  centerRight: [
24839
24881
  1,
@@ -24843,9 +24885,9 @@ exports.FrameComponent = __decorate([
24843
24885
  ],
24844
24886
  centerBottom: [
24845
24887
  0.5,
24846
- 0,
24888
+ 1,
24847
24889
  0.5,
24848
- 0
24890
+ 1
24849
24891
  ],
24850
24892
  center: [
24851
24893
  0.5,
@@ -24860,10 +24902,10 @@ exports.FrameComponent = __decorate([
24860
24902
  1
24861
24903
  ],
24862
24904
  topWide: [
24905
+ 0,
24863
24906
  0,
24864
24907
  1,
24865
- 1,
24866
- 1
24908
+ 0
24867
24909
  ],
24868
24910
  rightWide: [
24869
24911
  1,
@@ -24872,10 +24914,10 @@ exports.FrameComponent = __decorate([
24872
24914
  1
24873
24915
  ],
24874
24916
  bottomWide: [
24875
- 0,
24876
24917
  0,
24877
24918
  1,
24878
- 0
24919
+ 1,
24920
+ 1
24879
24921
  ],
24880
24922
  vcenterWide: [
24881
24923
  0.5,
@@ -24897,306 +24939,171 @@ exports.FrameComponent = __decorate([
24897
24939
  ]
24898
24940
  };
24899
24941
  /**
24900
- * 锚点布局变换。`RectTransform extends Transform`,在 Transform position/rotation/scale/size/anchor(=pivot 偏移)
24901
- * 之上额外维护 4 边锚点 + 4 边像素偏移,提供 rect 解算与编辑 API。
24902
- *
24903
- * 解算公式(Y 向上,父 vertex 坐标原点 = 父 rect 左下角):
24904
- * ```
24905
- * left = offsetMin.x + anchorMin.x * parentSize.x
24906
- * bottom = offsetMin.y + anchorMin.y * parentSize.y
24907
- * right = offsetMax.x + anchorMax.x * parentSize.x
24908
- * top = offsetMax.y + anchorMax.y * parentSize.y
24909
- * ```
24910
- *
24911
- * 写回 Transform:
24912
- * - `position` ← `(left, bottom)`(rect 左下角,父 vertex 坐标)
24913
- * - `size` ← rect 尺寸
24914
- * - `anchor`(Vector3 像素 pivot 偏移)由用户独立设置,仅作旋转/缩放中心
24915
- *
24916
- * **解算入口** 是 `sizeChanged()` 方法:
24917
- * - 父是 RectTransform → 用 `parent.size` parentSize 解算自身,写回 `position` / `size`
24918
- * - 否则(顶层 / 没父):自身 size 视为权威值(由外部 通常是 CanvasLayer 直接写),不再自解算
24919
- * - 末尾遍历 `children` 中的 RectTransform,直接调它们的 `sizeChanged()`,链式向下传播
24920
- *
24921
- * **重写 `setPosition` / `setSize`** 让其语义变为"用户输入 rect 位置 / 尺寸":
24922
- * - 顶层(无 RectTransform 父):直接写 `super.setPosition / super.setSize`,然后 `sizeChanged` 传播给子节点
24923
- * - 否则:反推 offset 维持当前 anchor,然后 `sizeChanged` 重算并向下传
24924
- */ var RectTransform = /*#__PURE__*/ function(Transform) {
24925
- _inherits(RectTransform, Transform);
24926
- function RectTransform() {
24927
- var _this;
24928
- _this = Transform.apply(this, arguments) || this;
24929
- /**
24930
- * 父 rect 上的归一化最小角 `(anchorLeft, anchorBottom)`
24931
- */ _this.anchorMin = new Vector2(0, 0);
24932
- /**
24933
- * 父 rect 上的归一化最大角 `(anchorRight, anchorTop)`
24934
- */ _this.anchorMax = new Vector2(0, 0);
24935
- /**
24936
- * rect 左/下边相对 anchorMin 锚点的像素偏移 `(offsetLeft, offsetBottom)`
24937
- */ _this.offsetMin = new Vector2(0, 0);
24938
- /**
24939
- * rect 右/上边相对 anchorMax 锚点的像素偏移 `(offsetRight, offsetTop)`
24940
- */ _this.offsetMax = new Vector2(0, 0);
24941
- /**
24942
- * 自身 rect 上的归一化轴心 `(0..1)`,默认 `(0.5, 0.5)`(中心)。两层效果:
24943
- * 1. **Layout**:`setSize` 时 rect 围绕此点对称缩放(pivot=(0.5, 0.5) → 居中扩展;pivot=(0, 0) → 从左下扩展;pivot=(1, 1) → 向左下缩)
24944
- * 2. **矩阵**:`pivot` 自动同步到 `transform.anchor = pivot * size`(像素值,矩阵旋转/缩放中心),
24945
- * 所以旋转/缩放也围绕同一点。`setPivot` 和每次 `sizeChanged`(size 重算后)都会刷新 `transform.anchor`
24946
- */ _this.pivot = new Vector2(0.5, 0.5);
24947
- return _this;
24942
+ * A drawable GUI object. Controls form a tree independent from the VFXItem
24943
+ * scene tree. UIControl is the bridge between both trees.
24944
+ */ var Control = /*#__PURE__*/ function() {
24945
+ function Control(engine) {
24946
+ this.engine = engine;
24947
+ this._parent = null;
24948
+ this._visible = true;
24949
+ this._enabled = true;
24950
+ this._mouseFilter = exports.MouseFilter.Stop;
24951
+ this._mouseBehaviorRecursive = exports.MouseBehaviorRecursive.Inherited;
24952
+ this._focusMode = exports.FocusMode.None;
24953
+ this._focusBehaviorRecursive = exports.FocusBehaviorRecursive.Inherited;
24954
+ this._defaultCursorShape = exports.CursorShape.Arrow;
24955
+ this._rotation = 0;
24956
+ this.transformDirty = true;
24957
+ this.cachedTransform = new Matrix3();
24958
+ this.eventEmitter = new EventEmitter();
24959
+ this.disposed = false;
24960
+ this./** Scene-tree bridge that owns this GUI object, if any. */ owner = null;
24961
+ this.position = new Vector2();
24962
+ this.size = new Vector2(1, 1);
24963
+ this.anchorMin = new Vector2();
24964
+ this.anchorMax = new Vector2();
24965
+ this.offsetMin = new Vector2();
24966
+ this.offsetMax = new Vector2(1, 1);
24967
+ this.pivot = new Vector2(0.5, 0.5);
24968
+ this.scale = new Vector2(1, 1);
24969
+ this.shear = new Vector2();
24970
+ this.mouseForcePassScrollEvents = true;
24971
+ this.clipContents = false;
24948
24972
  }
24949
- var _proto = RectTransform.prototype;
24950
- /**
24951
- * 反序列化:在 `Transform.fromData` 基础上还原 RectTransform 特有的 `pivot` /
24952
- * `anchorMin` / `anchorMax` / `offsetMin` / `offsetMax`。
24953
- *
24954
- * 顺序:
24955
- * 1. `super.fromData` 还原 `position` / `rotation` / `scale` / `size` / `anchor`
24956
- * 2. 若数据有 size,从 `anchor / size` 反推 `pivot`,保持 `anchor = pivot * size` 一致
24957
- * 3. 应用 `anchorMin/Max` / `offsetMin/Max`,每个 setter 末尾会触发 `sizeChanged`
24958
- * 重新解算 rect 与同步 `transform.anchor`
24959
- */ _proto.fromData = function fromData(data) {
24960
- Transform.prototype.fromData.call(this, data);
24961
- if (this.size.x !== 0 && this.size.y !== 0) {
24962
- this.pivot.set(this.anchor.x / this.size.x, this.anchor.y / this.size.y);
24973
+ var _proto = Control.prototype;
24974
+ _proto.on = function on(eventName, listener, options) {
24975
+ this.eventEmitter.on(eventName, listener, options);
24976
+ };
24977
+ _proto.off = function off(eventName, listener) {
24978
+ this.eventEmitter.off(eventName, listener);
24979
+ };
24980
+ _proto.setPosition = function setPosition(x, y, keepOffsets) {
24981
+ if (keepOffsets === void 0) keepOffsets = false;
24982
+ if (this.position.x === x && this.position.y === y) {
24983
+ return;
24963
24984
  }
24964
- // @ts-expect-error spec.TransformData 暂未声明 RectTransform 字段
24965
- if (data.anchorMin) {
24966
- // @ts-expect-error
24967
- this.setAnchorMin(data.anchorMin.x, data.anchorMin.y);
24985
+ var rect = {
24986
+ position: new Vector2(x, y),
24987
+ size: this.size.clone()
24988
+ };
24989
+ if (keepOffsets && this.parent) {
24990
+ this.computeAnchors(rect, this.getParentRect());
24991
+ } else {
24992
+ this.computeOffsets(rect, this.getParentRect());
24968
24993
  }
24969
- // @ts-expect-error
24970
- if (data.anchorMax) {
24971
- // @ts-expect-error
24972
- this.setAnchorMax(data.anchorMax.x, data.anchorMax.y);
24994
+ this.updateLayout();
24995
+ };
24996
+ _proto.setSize = function setSize(width, height) {
24997
+ if (this.size.x === width && this.size.y === height) {
24998
+ return;
24973
24999
  }
24974
- // @ts-expect-error
24975
- if (data.offsetMin) {
24976
- // @ts-expect-error
24977
- this.setOffsetMin(data.offsetMin.x, data.offsetMin.y);
25000
+ var rect = {
25001
+ position: this.position.clone(),
25002
+ size: new Vector2(width, height)
25003
+ };
25004
+ this.computeOffsets(rect, this.getParentRect());
25005
+ this.updateLayout();
25006
+ };
25007
+ _proto.setScale = function setScale(x, y) {
25008
+ if (this.scale.x !== x || this.scale.y !== y) {
25009
+ this.scale.set(x, y);
25010
+ this.markTransformDirty();
24978
25011
  }
24979
- // @ts-expect-error
24980
- if (data.offsetMax) {
24981
- // @ts-expect-error
24982
- this.setOffsetMax(data.offsetMax.x, data.offsetMax.y);
25012
+ };
25013
+ _proto.setRotation = function setRotation(degrees) {
25014
+ if (this._rotation !== degrees) {
25015
+ this._rotation = degrees;
25016
+ this.markTransformDirty();
25017
+ }
25018
+ };
25019
+ _proto.setShear = function setShear(x, y) {
25020
+ if (this.shear.x !== x || this.shear.y !== y) {
25021
+ this.shear.set(x, y);
25022
+ this.markTransformDirty();
25023
+ }
25024
+ };
25025
+ _proto.setPivot = function setPivot(x, y) {
25026
+ if (this.pivot.x !== x || this.pivot.y !== y) {
25027
+ this.pivot.set(x, y);
25028
+ this.markTransformDirty();
24983
25029
  }
24984
25030
  };
24985
- // ── layout-input setters(改完 → sizeChanged 重算)──────
24986
25031
  _proto.setAnchorMin = function setAnchorMin(x, y) {
24987
25032
  if (this.anchorMin.x !== x || this.anchorMin.y !== y) {
24988
- this.anchorMin.x = x;
24989
- this.anchorMin.y = y;
24990
- this.sizeChanged();
25033
+ this.anchorMin.set(x, y);
25034
+ this.updateLayout();
24991
25035
  }
24992
25036
  };
24993
25037
  _proto.setAnchorMax = function setAnchorMax(x, y) {
24994
25038
  if (this.anchorMax.x !== x || this.anchorMax.y !== y) {
24995
- this.anchorMax.x = x;
24996
- this.anchorMax.y = y;
24997
- this.sizeChanged();
25039
+ this.anchorMax.set(x, y);
25040
+ this.updateLayout();
24998
25041
  }
24999
25042
  };
25000
25043
  _proto.setOffsetMin = function setOffsetMin(x, y) {
25001
25044
  if (this.offsetMin.x !== x || this.offsetMin.y !== y) {
25002
- this.offsetMin.x = x;
25003
- this.offsetMin.y = y;
25004
- this.sizeChanged();
25045
+ this.offsetMin.set(x, y);
25046
+ this.updateLayout();
25005
25047
  }
25006
25048
  };
25007
25049
  _proto.setOffsetMax = function setOffsetMax(x, y) {
25008
25050
  if (this.offsetMax.x !== x || this.offsetMax.y !== y) {
25009
- this.offsetMax.x = x;
25010
- this.offsetMax.y = y;
25011
- this.sizeChanged();
25012
- }
25013
- };
25014
- /**
25015
- * 设置 rect 内的归一化轴心 `(0..1)`,同时把 `transform.anchor`(矩阵旋转/缩放中心)同步到 `pivot * size`。
25016
- * 不重算 rect(pivot 只决定 setSize 行为,不直接影响当前 rect 位置 / 尺寸)
25017
- */ _proto.setPivot = function setPivot(x, y) {
25018
- if (this.pivot.x !== x || this.pivot.y !== y) {
25019
- this.pivot.x = x;
25020
- this.pivot.y = y;
25021
- // 同步 transform.anchor(像素 pivot)= pivot * size,让旋转/缩放绕同一点
25022
- this.anchor.set(this.pivot.x * this.size.x, this.pivot.y * this.size.y, this.anchor.z);
25051
+ this.offsetMax.set(x, y);
25052
+ this.updateLayout();
25023
25053
  }
25024
25054
  };
25025
- /**
25026
- * 重写父类 `setPosition`:
25027
- * - 顶层(无 RectTransform 父):直接 `super.setPosition` 写位置,触发 `sizeChanged` 传播
25028
- * - 非顶层:语义为"设置 rect 左下角到 (x, y)",反推 offset 维持当前 anchor,然后 `sizeChanged` 重算
25029
- *
25030
- * @param keepOffsets - 默认 false。true 时反推 anchor 而非 offset(rect 在屏幕上不动,但 anchor 比例改变)
25031
- */ _proto.setPosition = function setPosition(x, y, z, keepOffsets) {
25032
- if (keepOffsets === void 0) keepOffsets = false;
25033
- if (!_instanceof1(this.parentTransform, RectTransform)) {
25034
- // 顶层:直接写,然后传播给子节点
25035
- Transform.prototype.setPosition.call(this, x, y, z);
25036
- this.sizeChanged();
25037
- return;
25038
- }
25039
- var parentRect = {
25040
- position: new Vector2(0, 0),
25041
- size: this.parentTransform.size.clone()
25042
- };
25043
- var newRect = {
25044
- position: new Vector2(x, y),
25045
- size: this.size.clone()
25046
- };
25047
- if (keepOffsets) {
25048
- this.computeAnchors(newRect, parentRect);
25049
- } else {
25050
- this.computeOffsets(newRect, parentRect);
25051
- }
25052
- this.sizeChanged();
25053
- if (this.position.z !== z) {
25054
- Transform.prototype.setPosition.call(this, this.position.x, this.position.y, z);
25055
- }
25056
- };
25057
- /**
25058
- * 重写父类 `setSize`:
25059
- * - 顶层:直接 `super.setSize`,触发 `sizeChanged` 传播
25060
- * - 非顶层:反推 offset 维持当前 anchor,然后 `sizeChanged` 重算
25061
- */ _proto.setSize = function setSize(x, y) {
25062
- if (this.size.x === x && this.size.y === y) {
25063
- return;
25064
- }
25065
- if (!_instanceof1(this.parentTransform, RectTransform)) {
25066
- Transform.prototype.setSize.call(this, x, y);
25067
- this.sizeChanged();
25068
- return;
25069
- }
25070
- // 围绕 pivot 对称缩放:Δsize 在 offsetMin / offsetMax 上按 pivot / (1-pivot) 比例分配。
25071
- // 例如 pivot=(0.5, 0.5) → 两边各 ±Δ/2,rect 居中扩展;pivot=(0, 0) → offsetMin 不动、offsetMax 全吃,rect 从左下扩展
25072
- var dw = x - this.size.x;
25073
- var dh = y - this.size.y;
25074
- this.offsetMin.set(this.offsetMin.x - this.pivot.x * dw, this.offsetMin.y - this.pivot.y * dh);
25075
- this.offsetMax.set(this.offsetMax.x + (1 - this.pivot.x) * dw, this.offsetMax.y + (1 - this.pivot.y) * dh);
25076
- this.sizeChanged();
25077
- };
25078
- // ── rect query ───────────────────────────────────────
25079
- /**
25080
- * 当前自身 rect(在父 vertex 坐标下,Y 向上)。`sizeChanged` 之后才有意义
25081
- */ _proto.getRect = function getRect() {
25055
+ _proto.getRect = function getRect() {
25082
25056
  return {
25083
- position: new Vector2(this.position.x, this.position.y),
25057
+ position: this.position.clone(),
25084
25058
  size: this.size.clone()
25085
25059
  };
25086
25060
  };
25087
- // ── parent linkage ───────────────────────────────────
25088
- /**
25089
- * transform 切换时重算自身布局。子节点链路通过 `Transform.children` 直接访问,无需事件订阅
25090
- * @internal
25091
- */ _proto.onParentTransformChanged = function onParentTransformChanged(_oldParent, _newParent) {
25092
- if (_instanceof1(_oldParent, RectTransform)) {
25093
- this.engine.off("resize", this.onCanvasResize.bind(this));
25094
- }
25095
- if (!_instanceof1(_newParent, RectTransform)) {
25096
- this.onCanvasResize();
25097
- this.engine.on("resize", this.onCanvasResize.bind(this));
25098
- }
25099
- this.sizeChanged();
25100
- };
25101
- _proto.onCanvasResize = function onCanvasResize() {
25102
- var rect = this.engine.canvas.getBoundingClientRect();
25103
- this.setSize(rect.width, rect.height);
25104
- };
25105
- // ── layout solver──────────────
25106
- /**
25107
- * 解算入口:
25108
- *
25109
- * 1. 父是 RectTransform → 从 `parent.size` 求自身 rect,通过 `super.setPosition / super.setSize` 写回
25110
- * (避免触发本类 setPosition / setSize 重写)
25111
- * 2. 顶层(无 RectTransform 父):自身 size 视为权威值(由 CanvasLayer 等外部直接写),不自解算
25112
- * 3. 遍历 `children` 中所有 RectTransform 子节点,直接调它们的 `sizeChanged()` 链式传播
25113
- */ _proto.sizeChanged = function sizeChanged() {
25114
- if (_instanceof1(this.parentTransform, RectTransform)) {
25115
- var parentSize = this.parentTransform.size;
25116
- var left = this.offsetMin.x + this.anchorMin.x * parentSize.x;
25117
- var bottom = this.offsetMin.y + this.anchorMin.y * parentSize.y;
25118
- var right = this.offsetMax.x + this.anchorMax.x * parentSize.x;
25119
- var top = this.offsetMax.y + this.anchorMax.y * parentSize.y;
25120
- Transform.prototype.setPosition.call(this, left, bottom, this.position.z);
25121
- Transform.prototype.setSize.call(this, right - left, top - bottom);
25122
- }
25123
- // size 更新后同步 transform.anchor(矩阵旋转/缩放中心)= pivot * size,跟 setPivot 保持统一
25124
- this.anchor.set(this.pivot.x * this.size.x, this.pivot.y * this.size.y, this.anchor.z);
25125
- for(var _iterator = _create_for_of_iterator_helper_loose(this.children), _step; !(_step = _iterator()).done;){
25126
- var child = _step.value;
25127
- if (_instanceof1(child, RectTransform)) {
25128
- child.sizeChanged();
25129
- }
25130
- }
25131
- };
25132
- /**
25133
- * 给定目标 rect 反推 offsetMin/Max,保持当前 anchor 不变
25134
- */ _proto.computeOffsets = function computeOffsets(rect, parentRect) {
25135
- this.offsetMin.set(rect.position.x - parentRect.position.x - this.anchorMin.x * parentRect.size.x, rect.position.y - parentRect.position.y - this.anchorMin.y * parentRect.size.y);
25136
- this.offsetMax.set(rect.position.x + rect.size.x - parentRect.position.x - this.anchorMax.x * parentRect.size.x, rect.position.y + rect.size.y - parentRect.position.y - this.anchorMax.y * parentRect.size.y);
25137
- };
25138
- /**
25139
- * 给定目标 rect 反推 anchorMin/Max,保持当前 offset 不变。父 size 为 0 的方向不修改
25140
- */ _proto.computeAnchors = function computeAnchors(rect, parentRect) {
25141
- if (parentRect.size.x !== 0) {
25142
- var aMinX = (rect.position.x - parentRect.position.x - this.offsetMin.x) / parentRect.size.x;
25143
- var aMaxX = (rect.position.x + rect.size.x - parentRect.position.x - this.offsetMax.x) / parentRect.size.x;
25144
- this.anchorMin.x = aMinX;
25145
- this.anchorMax.x = aMaxX;
25146
- }
25147
- if (parentRect.size.y !== 0) {
25148
- var aMinY = (rect.position.y - parentRect.position.y - this.offsetMin.y) / parentRect.size.y;
25149
- var aMaxY = (rect.position.y + rect.size.y - parentRect.position.y - this.offsetMax.y) / parentRect.size.y;
25150
- this.anchorMin.y = aMinY;
25151
- this.anchorMax.y = aMaxY;
25152
- }
25153
- };
25154
- // ── preset API ───────────────────────────────────────
25155
- /**
25156
- * 把 anchorMin/Max 设为内建预设。
25157
- * @param keepOffsets - 默认 true:offset 不动,rect 实际位置会跳到新 anchor 计算的位置(要求保留视觉位置请用 setAnchorsAndOffsetsPreset)
25158
- */ _proto.setAnchorsPreset = function setAnchorsPreset(preset, keepOffsets) {
25061
+ _proto.getTransform2D = function getTransform2D() {
25062
+ if (this.transformDirty) {
25063
+ var radians = this._rotation * Math.PI / 180;
25064
+ var sin = Math.sin(radians);
25065
+ var cos = Math.cos(radians);
25066
+ var shearX = Math.tan(Math.max(-89, Math.min(89, this.shear.x)) * Math.PI / 180);
25067
+ var shearY = Math.tan(Math.max(-89, Math.min(89, this.shear.y)) * Math.PI / 180);
25068
+ var a = this.scale.x * (cos - sin * shearY);
25069
+ var b = this.scale.x * (sin + cos * shearY);
25070
+ var c = this.scale.y * (cos * shearX - sin);
25071
+ var d = this.scale.y * (sin * shearX + cos);
25072
+ var pivotX = this.pivot.x * this.size.x;
25073
+ var pivotY = this.pivot.y * this.size.y;
25074
+ var tx = this.position.x + pivotX - a * pivotX - c * pivotY;
25075
+ var ty = this.position.y + pivotY - b * pivotX - d * pivotY;
25076
+ this.cachedTransform.set(a, b, 0, c, d, 0, tx, ty, 1);
25077
+ this.transformDirty = false;
25078
+ }
25079
+ return this.cachedTransform;
25080
+ };
25081
+ _proto.setAnchorsPreset = function setAnchorsPreset(preset, keepOffsets) {
25159
25082
  if (keepOffsets === void 0) keepOffsets = true;
25160
- var _ANCHOR_PRESET_TABLE_preset = ANCHOR_PRESET_TABLE[preset], aMinX = _ANCHOR_PRESET_TABLE_preset[0], aMinY = _ANCHOR_PRESET_TABLE_preset[1], aMaxX = _ANCHOR_PRESET_TABLE_preset[2], aMaxY = _ANCHOR_PRESET_TABLE_preset[3];
25083
+ var _ANCHOR_PRESET_TABLE_preset = ANCHOR_PRESET_TABLE[preset], minX = _ANCHOR_PRESET_TABLE_preset[0], minY = _ANCHOR_PRESET_TABLE_preset[1], maxX = _ANCHOR_PRESET_TABLE_preset[2], maxY = _ANCHOR_PRESET_TABLE_preset[3];
25161
25084
  if (keepOffsets) {
25162
- this.anchorMin.set(aMinX, aMinY);
25163
- this.anchorMax.set(aMaxX, aMaxY);
25164
- } else if (_instanceof1(this.parentTransform, RectTransform)) {
25165
- var parentRect = {
25166
- position: new Vector2(0, 0),
25167
- size: this.parentTransform.size.clone()
25168
- };
25169
- var rect = this.getRect();
25170
- this.anchorMin.set(aMinX, aMinY);
25171
- this.anchorMax.set(aMaxX, aMaxY);
25172
- this.computeOffsets(rect, parentRect);
25085
+ this.anchorMin.set(minX, minY);
25086
+ this.anchorMax.set(maxX, maxY);
25173
25087
  } else {
25174
- // 顶层无父 rect 可参考,降级为 keepOffsets
25175
- this.anchorMin.set(aMinX, aMinY);
25176
- this.anchorMax.set(aMaxX, aMaxY);
25088
+ var rect = this.getRect();
25089
+ this.anchorMin.set(minX, minY);
25090
+ this.anchorMax.set(maxX, maxY);
25091
+ this.computeOffsets(rect, this.getParentRect());
25177
25092
  }
25178
- this.sizeChanged();
25093
+ this.updateLayout();
25179
25094
  };
25180
- /**
25181
- * 把 offsetMin/Max 设为预设值,使 rect 在父 rect 内落在视觉上对应的位置(留 margin 像素边距)。
25182
- * 当 anchor 已经按相同 preset 设定时,等价于“贴边放置带 margin 的 rect”。
25183
- * 使用当前 size 作为 rect 尺寸。
25184
- */ _proto.setOffsetsPreset = function setOffsetsPreset(preset, margin) {
25095
+ _proto.setOffsetsPreset = function setOffsetsPreset(preset, margin) {
25185
25096
  if (margin === void 0) margin = 0;
25186
- if (!_instanceof1(this.parentTransform, RectTransform)) {
25097
+ if (!this.parent) {
25187
25098
  return;
25188
25099
  }
25189
- var newSizeX = this.size.x;
25190
- var newSizeY = this.size.y;
25100
+ var parentSize = this.parent.size;
25101
+ var width = this.size.x;
25102
+ var height = this.size.y;
25191
25103
  var a = this.anchorMin;
25192
25104
  var b = this.anchorMax;
25193
- var pw = this.parentTransform.size.x;
25194
- var ph = this.parentTransform.size.y;
25195
- var offMinX = 0;
25196
- var offMaxX = 0;
25197
- var offMinY = 0;
25198
- var offMaxY = 0;
25199
- // X 方向(left / right)
25105
+ var minX = 0, maxX = 0, minY = 0, maxY = 0;
25106
+ // Left edge.
25200
25107
  switch(preset){
25201
25108
  case "topLeft":
25202
25109
  case "bottomLeft":
@@ -25206,119 +25113,1498 @@ exports.FrameComponent = __decorate([
25206
25113
  case "leftWide":
25207
25114
  case "hcenterWide":
25208
25115
  case "fullRect":
25209
- offMinX = margin - a.x * pw;
25210
- offMaxX = margin + newSizeX - b.x * pw;
25116
+ minX = margin - a.x * parentSize.x;
25211
25117
  break;
25212
25118
  case "centerTop":
25213
25119
  case "centerBottom":
25214
25120
  case "center":
25215
25121
  case "vcenterWide":
25216
- offMinX = 0.5 * pw - newSizeX / 2 - a.x * pw;
25217
- offMaxX = 0.5 * pw + newSizeX / 2 - b.x * pw;
25122
+ minX = 0.5 * parentSize.x - width / 2 - a.x * parentSize.x;
25218
25123
  break;
25219
- case "topRight":
25220
- case "bottomRight":
25221
- case "centerRight":
25222
- case "rightWide":
25223
- offMinX = pw - margin - newSizeX - a.x * pw;
25224
- offMaxX = pw - margin - b.x * pw;
25124
+ default:
25125
+ minX = parentSize.x - margin - width - a.x * parentSize.x;
25225
25126
  break;
25226
25127
  }
25227
- // Y 方向(bottom / top)— Y 向上
25228
25128
  switch(preset){
25129
+ case "topLeft":
25229
25130
  case "bottomLeft":
25230
- case "bottomRight":
25131
+ case "centerLeft":
25132
+ case "leftWide":
25133
+ maxX = margin + width - b.x * parentSize.x;
25134
+ break;
25135
+ case "centerTop":
25231
25136
  case "centerBottom":
25137
+ case "center":
25138
+ case "vcenterWide":
25139
+ maxX = 0.5 * parentSize.x + width / 2 - b.x * parentSize.x;
25140
+ break;
25141
+ default:
25142
+ maxX = parentSize.x - margin - b.x * parentSize.x;
25143
+ break;
25144
+ }
25145
+ // Top edge.
25146
+ switch(preset){
25147
+ case "topLeft":
25148
+ case "topRight":
25149
+ case "centerTop":
25232
25150
  case "leftWide":
25233
25151
  case "rightWide":
25234
- case "bottomWide":
25152
+ case "topWide":
25235
25153
  case "vcenterWide":
25236
25154
  case "fullRect":
25237
- offMinY = margin - a.y * ph;
25238
- offMaxY = margin + newSizeY - b.y * ph;
25155
+ minY = margin - a.y * parentSize.y;
25239
25156
  break;
25240
25157
  case "centerLeft":
25241
25158
  case "centerRight":
25242
25159
  case "center":
25243
25160
  case "hcenterWide":
25244
- offMinY = 0.5 * ph - newSizeY / 2 - a.y * ph;
25245
- offMaxY = 0.5 * ph + newSizeY / 2 - b.y * ph;
25161
+ minY = 0.5 * parentSize.y - height / 2 - a.y * parentSize.y;
25162
+ break;
25163
+ default:
25164
+ minY = parentSize.y - margin - height - a.y * parentSize.y;
25246
25165
  break;
25166
+ }
25167
+ // Bottom edge.
25168
+ switch(preset){
25247
25169
  case "topLeft":
25248
25170
  case "topRight":
25249
25171
  case "centerTop":
25250
25172
  case "topWide":
25251
- offMinY = ph - margin - newSizeY - a.y * ph;
25252
- offMaxY = ph - margin - b.y * ph;
25173
+ maxY = margin + height - b.y * parentSize.y;
25174
+ break;
25175
+ case "centerLeft":
25176
+ case "centerRight":
25177
+ case "center":
25178
+ case "hcenterWide":
25179
+ maxY = 0.5 * parentSize.y + height / 2 - b.y * parentSize.y;
25180
+ break;
25181
+ default:
25182
+ maxY = parentSize.y - margin - b.y * parentSize.y;
25253
25183
  break;
25254
25184
  }
25255
- this.offsetMin.set(offMinX, offMinY);
25256
- this.offsetMax.set(offMaxX, offMaxY);
25257
- this.sizeChanged();
25185
+ this.offsetMin.set(minX, minY);
25186
+ this.offsetMax.set(maxX, maxY);
25187
+ this.updateLayout();
25258
25188
  };
25259
- /**
25260
- * 同时设置 anchor 和 offset,达到“按 preset 摆放并贴边带 margin”的效果。
25261
- *
25262
- * 注意第一步用 `keepOffsets=false`(反推 offset 维持 rect 视觉位置),不能用默认 `true`:
25263
- * 后者会让 rect 的 size 在中间步先跳到错值(因为 anchor 改了 offset 没改),
25264
- * 第二步 `setOffsetsPreset` 又用这个错 size 算 offset,最终 rect size 不对
25265
- */ _proto.setAnchorsAndOffsetsPreset = function setAnchorsAndOffsetsPreset(preset, margin) {
25189
+ _proto.setAnchorsAndOffsetsPreset = function setAnchorsAndOffsetsPreset(preset, margin) {
25266
25190
  if (margin === void 0) margin = 0;
25267
25191
  this.setAnchorsPreset(preset, false);
25268
25192
  this.setOffsetsPreset(preset, margin);
25269
25193
  };
25270
- /**
25271
- * 用既有 Transform 的状态创建 RectTransform。
25272
- * 用于 Control / CanvasLayer 接管 VFXItem 时,把 VFXItem 自带的 Transform 升级为 RectTransform 而不丢失 position/rotation/scale 等已设置好的状态。
25273
- */ RectTransform.fromTransform = function fromTransform(t) {
25274
- if (_instanceof1(t, RectTransform)) {
25275
- return t;
25194
+ _proto.getGlobalTransform2D = function getGlobalTransform2D() {
25195
+ var local = this.getTransform2D();
25196
+ return this.parent ? new Matrix3().multiplyMatrices(this.parent.getGlobalTransform2D(), local) : local.clone();
25197
+ };
25198
+ _proto.hasPoint = function hasPoint(point) {
25199
+ return point.x >= 0 && point.y >= 0 && point.x <= this.size.x && point.y <= this.size.y;
25200
+ };
25201
+ _proto.getEffectiveMouseFilter = function getEffectiveMouseFilter() {
25202
+ return this.enabledInHierarchy && this.isMouseRecursiveEnabled() ? this.mouseFilter : exports.MouseFilter.Ignore;
25203
+ };
25204
+ _proto.getFocusModeWithOverride = function getFocusModeWithOverride() {
25205
+ return this.enabledInHierarchy && this.isFocusRecursiveEnabled() ? this.focusMode : exports.FocusMode.None;
25206
+ };
25207
+ _proto.getCursorShape = function getCursorShape(position) {
25208
+ return this.defaultCursorShape;
25209
+ };
25210
+ _proto.focus = function focus() {
25211
+ var _this_root;
25212
+ (_this_root = this.root) == null ? void 0 : _this_root.grabControlFocus(this);
25213
+ };
25214
+ _proto.grabFocus = function grabFocus() {
25215
+ this.focus();
25216
+ };
25217
+ _proto.grabClickFocus = function grabClickFocus() {
25218
+ var _this_root;
25219
+ (_this_root = this.root) == null ? void 0 : _this_root.grabControlClickFocus(this);
25220
+ };
25221
+ _proto.releaseFocus = function releaseFocus() {
25222
+ var _this_root;
25223
+ (_this_root = this.root) == null ? void 0 : _this_root.releaseControlFocus(this);
25224
+ };
25225
+ _proto.warpMouse = function warpMouse(position) {
25226
+ var _this_root;
25227
+ var matrix = this.getGlobalTransform2D().elements;
25228
+ (_this_root = this.root) == null ? void 0 : _this_root.warpControlMouse(new Vector2(matrix[0] * position.x + matrix[3] * position.y + matrix[6], matrix[1] * position.x + matrix[4] * position.y + matrix[7]));
25229
+ };
25230
+ /** Converts a window-space position into this control's local coordinates. */ _proto.makePositionLocal = function makePositionLocal(position) {
25231
+ var transform = this.getGlobalTransform2D().clone();
25232
+ if (Math.abs(transform.determinant()) < 1e-12) {
25233
+ return new Vector2();
25234
+ }
25235
+ var elements = transform.invert().elements;
25236
+ return new Vector2(elements[0] * position.x + elements[3] * position.y + elements[6], elements[1] * position.x + elements[4] * position.y + elements[7]);
25237
+ };
25238
+ /** Gets the current mouse position transformed into this control's coordinates. */ _proto.getLocalMousePosition = function getLocalMousePosition() {
25239
+ var root = this.root;
25240
+ return root ? this.makePositionLocal(root.getMousePosition()) : new Vector2();
25241
+ };
25242
+ _proto.update = function update(deltaTime) {};
25243
+ _proto.draw = function draw() {
25244
+ // OVERRIDE
25245
+ };
25246
+ _proto.onDestroy = function onDestroy() {};
25247
+ /** @internal */ _proto.drawInternal = function drawInternal() {
25248
+ if (!this.visibleInHierarchy || this.disposed) {
25249
+ return;
25250
+ }
25251
+ var graphics = this.engine.graphics;
25252
+ graphics.pushTransform(this.getTransform2D());
25253
+ this.draw();
25254
+ graphics.popTransform();
25255
+ };
25256
+ _proto.drawLine = function drawLine(x1, y1, x2, y2, color, thickness) {
25257
+ this.engine.graphics.drawLine(x1, y1, x2, y2, color, thickness);
25258
+ };
25259
+ _proto.drawPolyline = function drawPolyline(points, color, thickness) {
25260
+ this.engine.graphics.drawLines(points, color, thickness);
25261
+ };
25262
+ _proto.drawBezier = function drawBezier(x1, y1, x2, y2, x3, y3, x4, y4, color, thickness) {
25263
+ this.engine.graphics.drawBezier(x1, y1, x2, y2, x3, y3, x4, y4, color, thickness);
25264
+ };
25265
+ _proto.drawTriangle = function drawTriangle(x1, y1, x2, y2, x3, y3, color, thickness) {
25266
+ this.engine.graphics.drawTriangle(x1, y1, x2, y2, x3, y3, color, thickness);
25267
+ };
25268
+ _proto.drawRect = function drawRect(x, y, width, height, color, thickness) {
25269
+ this.engine.graphics.drawRectangle(x, y, width, height, color, thickness);
25270
+ };
25271
+ _proto.drawCircle = function drawCircle(cx, cy, radius, color, thickness) {
25272
+ this.engine.graphics.drawCircle(cx, cy, radius, color, thickness);
25273
+ };
25274
+ _proto.fillTriangle = function fillTriangle(x1, y1, x2, y2, x3, y3, color) {
25275
+ this.engine.graphics.fillTriangle(x1, y1, x2, y2, x3, y3, color);
25276
+ };
25277
+ _proto.fillRect = function fillRect(x, y, width, height, color) {
25278
+ this.engine.graphics.fillRectangle(x, y, width, height, color);
25279
+ };
25280
+ _proto.fillCircle = function fillCircle(cx, cy, radius, color) {
25281
+ this.engine.graphics.fillCircle(cx, cy, radius, color);
25282
+ };
25283
+ _proto.drawTexture = function drawTexture(x, y, width, height, texture, region, color) {
25284
+ this.engine.graphics.drawTexture(x, y, width, height, texture, region, color);
25285
+ };
25286
+ _proto.drawText = function drawText(x, y, text, fontSize, color, fontFamily, fontWeight, fontStyle) {
25287
+ this.engine.graphics.drawText(x, y, text, fontSize, color, fontFamily, fontWeight, fontStyle);
25288
+ };
25289
+ _proto.onMouseEnter = function onMouseEnter(location) {};
25290
+ _proto.onMouseMove = function onMouseMove(event) {};
25291
+ _proto.onMouseLeave = function onMouseLeave() {};
25292
+ _proto.onMouseWheel = function onMouseWheel(event) {};
25293
+ _proto.onMouseDown = function onMouseDown(event) {};
25294
+ _proto.onMouseUp = function onMouseUp(event) {};
25295
+ _proto.onTouchDown = function onTouchDown(event) {};
25296
+ _proto.onTouchMove = function onTouchMove(event) {};
25297
+ _proto.onTouchUp = function onTouchUp(event) {};
25298
+ _proto.onKeyDown = function onKeyDown(event) {};
25299
+ _proto.onKeyUp = function onKeyUp(event) {};
25300
+ _proto.onGotFocus = function onGotFocus() {};
25301
+ _proto.onLostFocus = function onLostFocus() {};
25302
+ /** @internal */ _proto.invokeGetDragData = function invokeGetDragData(position) {
25303
+ return this.getDragData(position);
25304
+ };
25305
+ /** @internal */ _proto.invokeCanDropData = function invokeCanDropData(position, data) {
25306
+ return this.canDropData(position, data);
25307
+ };
25308
+ /** @internal */ _proto.invokeDropData = function invokeDropData(position, data) {
25309
+ this.dropData(position, data);
25310
+ };
25311
+ _proto.getDragData = function getDragData(position) {
25312
+ return null;
25313
+ };
25314
+ _proto.canDropData = function canDropData(position, data) {
25315
+ return false;
25316
+ };
25317
+ _proto.dropData = function dropData(position, data) {};
25318
+ _proto.dispose = function dispose() {
25319
+ if (this.disposed) {
25320
+ return;
25321
+ }
25322
+ this.disposed = true;
25323
+ this.onDestroy();
25324
+ this.parent = null;
25325
+ this.owner = null;
25326
+ };
25327
+ /** @internal */ _proto.updateLayout = function updateLayout() {
25328
+ var _this_parent;
25329
+ var _this_parent_size;
25330
+ var parentSize = (_this_parent_size = (_this_parent = this.parent) == null ? void 0 : _this_parent.size) != null ? _this_parent_size : new Vector2();
25331
+ var left = this.offsetMin.x + this.anchorMin.x * parentSize.x;
25332
+ var top = this.offsetMin.y + this.anchorMin.y * parentSize.y;
25333
+ var right = this.offsetMax.x + this.anchorMax.x * parentSize.x;
25334
+ var bottom = this.offsetMax.y + this.anchorMax.y * parentSize.y;
25335
+ this.applyBounds(left, top, right - left, bottom - top);
25336
+ };
25337
+ _proto.applyBounds = function applyBounds(x, y, width, height) {
25338
+ var locationChanged = this.position.x !== x || this.position.y !== y;
25339
+ var sizeChanged = this.size.x !== width || this.size.y !== height;
25340
+ if (!locationChanged && !sizeChanged) {
25341
+ return;
25342
+ }
25343
+ this.position.set(x, y);
25344
+ this.size.set(width, height);
25345
+ this.markTransformDirty();
25346
+ if (locationChanged) {
25347
+ this.eventEmitter.emit("locationChanged", this);
25348
+ }
25349
+ if (sizeChanged) {
25350
+ this.eventEmitter.emit("sizeChanged", this);
25351
+ if (_instanceof1(this, ContainerControl)) {
25352
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.children.slice()), _step; !(_step = _iterator()).done;){
25353
+ var child = _step.value;
25354
+ child.updateLayout();
25355
+ }
25356
+ }
25357
+ }
25358
+ };
25359
+ _proto.markTransformDirty = function markTransformDirty() {
25360
+ var _this_root;
25361
+ this.transformDirty = true;
25362
+ (_this_root = this.root) == null ? void 0 : _this_root.controlTreeChanged();
25363
+ };
25364
+ _proto.getParentRect = function getParentRect() {
25365
+ var _this_parent;
25366
+ var _this_parent_size_clone;
25367
+ return {
25368
+ position: new Vector2(),
25369
+ size: (_this_parent_size_clone = (_this_parent = this.parent) == null ? void 0 : _this_parent.size.clone()) != null ? _this_parent_size_clone : new Vector2()
25370
+ };
25371
+ };
25372
+ _proto.computeOffsets = function computeOffsets(rect, parentRect) {
25373
+ this.offsetMin.set(rect.position.x - parentRect.position.x - this.anchorMin.x * parentRect.size.x, rect.position.y - parentRect.position.y - this.anchorMin.y * parentRect.size.y);
25374
+ this.offsetMax.set(rect.position.x + rect.size.x - parentRect.position.x - this.anchorMax.x * parentRect.size.x, rect.position.y + rect.size.y - parentRect.position.y - this.anchorMax.y * parentRect.size.y);
25375
+ };
25376
+ _proto.computeAnchors = function computeAnchors(rect, parentRect) {
25377
+ if (parentRect.size.x !== 0) {
25378
+ this.anchorMin.x = (rect.position.x - parentRect.position.x - this.offsetMin.x) / parentRect.size.x;
25379
+ this.anchorMax.x = (rect.position.x + rect.size.x - parentRect.position.x - this.offsetMax.x) / parentRect.size.x;
25380
+ }
25381
+ if (parentRect.size.y !== 0) {
25382
+ this.anchorMin.y = (rect.position.y - parentRect.position.y - this.offsetMin.y) / parentRect.size.y;
25383
+ this.anchorMax.y = (rect.position.y + rect.size.y - parentRect.position.y - this.offsetMax.y) / parentRect.size.y;
25384
+ }
25385
+ };
25386
+ _proto.isMouseRecursiveEnabled = function isMouseRecursiveEnabled() {
25387
+ if (this.mouseBehaviorRecursive === exports.MouseBehaviorRecursive.Inherited) {
25388
+ var _this_parent;
25389
+ var _this_parent_isMouseRecursiveEnabled;
25390
+ return (_this_parent_isMouseRecursiveEnabled = (_this_parent = this.parent) == null ? void 0 : _this_parent.isMouseRecursiveEnabled()) != null ? _this_parent_isMouseRecursiveEnabled : true;
25391
+ }
25392
+ return this.mouseBehaviorRecursive === exports.MouseBehaviorRecursive.Enabled;
25393
+ };
25394
+ _proto.isFocusRecursiveEnabled = function isFocusRecursiveEnabled() {
25395
+ if (this.focusBehaviorRecursive === exports.FocusBehaviorRecursive.Inherited) {
25396
+ var _this_parent;
25397
+ var _this_parent_isFocusRecursiveEnabled;
25398
+ return (_this_parent_isFocusRecursiveEnabled = (_this_parent = this.parent) == null ? void 0 : _this_parent.isFocusRecursiveEnabled()) != null ? _this_parent_isFocusRecursiveEnabled : true;
25399
+ }
25400
+ return this.focusBehaviorRecursive === exports.FocusBehaviorRecursive.Enabled;
25401
+ };
25402
+ _create_class(Control, [
25403
+ {
25404
+ key: "parent",
25405
+ get: function get() {
25406
+ return this._parent;
25407
+ },
25408
+ set: function set(value) {
25409
+ var _this__parent;
25410
+ if (value === this._parent) {
25411
+ return;
25412
+ }
25413
+ var previousRoot = this.root;
25414
+ (_this__parent = this._parent) == null ? void 0 : _this__parent.removeChildInternal(this);
25415
+ this._parent = value;
25416
+ value == null ? void 0 : value.addChildInternal(this);
25417
+ this.updateLayout();
25418
+ var nextRoot = this.root;
25419
+ if (previousRoot && previousRoot !== nextRoot) {
25420
+ previousRoot.controlRemoved(this);
25421
+ }
25422
+ nextRoot == null ? void 0 : nextRoot.controlTreeChanged();
25423
+ this.eventEmitter.emit("parentChanged", this);
25424
+ }
25425
+ },
25426
+ {
25427
+ key: "item",
25428
+ get: /** Scene item exposed through the optional UIControl bridge. */ function get() {
25429
+ var _this_owner;
25430
+ var _this_owner_item;
25431
+ return (_this_owner_item = (_this_owner = this.owner) == null ? void 0 : _this_owner.item) != null ? _this_owner_item : null;
25432
+ }
25433
+ },
25434
+ {
25435
+ key: "indexInParent",
25436
+ get: function get() {
25437
+ var _this_parent;
25438
+ var _this_parent_getChildIndex;
25439
+ return (_this_parent_getChildIndex = (_this_parent = this.parent) == null ? void 0 : _this_parent.getChildIndex(this)) != null ? _this_parent_getChildIndex : -1;
25440
+ },
25441
+ set: function set(value) {
25442
+ var _this_parent;
25443
+ (_this_parent = this.parent) == null ? void 0 : _this_parent.changeChildIndex(this, value);
25444
+ }
25445
+ },
25446
+ {
25447
+ key: "visible",
25448
+ get: function get() {
25449
+ return this._visible;
25450
+ },
25451
+ set: function set(value) {
25452
+ if (this._visible !== value) {
25453
+ var _this_root;
25454
+ this._visible = value;
25455
+ (_this_root = this.root) == null ? void 0 : _this_root.controlStateChanged(this);
25456
+ }
25457
+ }
25458
+ },
25459
+ {
25460
+ key: "visibleInHierarchy",
25461
+ get: function get() {
25462
+ var _this_parent;
25463
+ var _this_parent_visibleInHierarchy;
25464
+ return this.visible && ((_this_parent_visibleInHierarchy = (_this_parent = this.parent) == null ? void 0 : _this_parent.visibleInHierarchy) != null ? _this_parent_visibleInHierarchy : true);
25465
+ }
25466
+ },
25467
+ {
25468
+ key: "enabled",
25469
+ get: function get() {
25470
+ return this._enabled;
25471
+ },
25472
+ set: function set(value) {
25473
+ if (this._enabled !== value) {
25474
+ var _this_root;
25475
+ this._enabled = value;
25476
+ (_this_root = this.root) == null ? void 0 : _this_root.controlStateChanged(this);
25477
+ }
25478
+ }
25479
+ },
25480
+ {
25481
+ key: "enabledInHierarchy",
25482
+ get: function get() {
25483
+ var _this_parent;
25484
+ var _this_parent_enabledInHierarchy;
25485
+ return this.enabled && ((_this_parent_enabledInHierarchy = (_this_parent = this.parent) == null ? void 0 : _this_parent.enabledInHierarchy) != null ? _this_parent_enabledInHierarchy : true);
25486
+ }
25487
+ },
25488
+ {
25489
+ key: "mouseFilter",
25490
+ get: function get() {
25491
+ return this._mouseFilter;
25492
+ },
25493
+ set: function set(value) {
25494
+ if (this._mouseFilter !== value) {
25495
+ var _this_root;
25496
+ this._mouseFilter = value;
25497
+ (_this_root = this.root) == null ? void 0 : _this_root.controlStateChanged(this);
25498
+ }
25499
+ }
25500
+ },
25501
+ {
25502
+ key: "mouseBehaviorRecursive",
25503
+ get: function get() {
25504
+ return this._mouseBehaviorRecursive;
25505
+ },
25506
+ set: function set(value) {
25507
+ if (this._mouseBehaviorRecursive !== value) {
25508
+ var _this_root;
25509
+ this._mouseBehaviorRecursive = value;
25510
+ (_this_root = this.root) == null ? void 0 : _this_root.controlStateChanged(this);
25511
+ }
25512
+ }
25513
+ },
25514
+ {
25515
+ key: "focusMode",
25516
+ get: function get() {
25517
+ return this._focusMode;
25518
+ },
25519
+ set: function set(value) {
25520
+ if (this._focusMode !== value) {
25521
+ var _this_root;
25522
+ this._focusMode = value;
25523
+ (_this_root = this.root) == null ? void 0 : _this_root.controlStateChanged(this);
25524
+ }
25525
+ }
25526
+ },
25527
+ {
25528
+ key: "focusBehaviorRecursive",
25529
+ get: function get() {
25530
+ return this._focusBehaviorRecursive;
25531
+ },
25532
+ set: function set(value) {
25533
+ if (this._focusBehaviorRecursive !== value) {
25534
+ var _this_root;
25535
+ this._focusBehaviorRecursive = value;
25536
+ (_this_root = this.root) == null ? void 0 : _this_root.controlStateChanged(this);
25537
+ }
25538
+ }
25539
+ },
25540
+ {
25541
+ key: "defaultCursorShape",
25542
+ get: function get() {
25543
+ return this._defaultCursorShape;
25544
+ },
25545
+ set: function set(value) {
25546
+ var _this_root;
25547
+ if (this._defaultCursorShape === value) {
25548
+ return;
25549
+ }
25550
+ this._defaultCursorShape = value;
25551
+ (_this_root = this.root) == null ? void 0 : _this_root.updateMouseCursorState();
25552
+ }
25553
+ },
25554
+ {
25555
+ key: "location",
25556
+ get: function get() {
25557
+ return this.position;
25558
+ },
25559
+ set: function set(value) {
25560
+ this.setPosition(value.x, value.y);
25561
+ }
25562
+ },
25563
+ {
25564
+ key: "rotation",
25565
+ get: function get() {
25566
+ return this._rotation;
25567
+ }
25568
+ },
25569
+ {
25570
+ key: "x",
25571
+ get: function get() {
25572
+ return this.position.x;
25573
+ },
25574
+ set: function set(value) {
25575
+ this.setPosition(value, this.position.y);
25576
+ }
25577
+ },
25578
+ {
25579
+ key: "y",
25580
+ get: function get() {
25581
+ return this.position.y;
25582
+ },
25583
+ set: function set(value) {
25584
+ this.setPosition(this.position.x, value);
25585
+ }
25586
+ },
25587
+ {
25588
+ key: "width",
25589
+ get: function get() {
25590
+ return this.size.x;
25591
+ },
25592
+ set: function set(value) {
25593
+ this.setSize(value, this.size.y);
25594
+ }
25595
+ },
25596
+ {
25597
+ key: "height",
25598
+ get: function get() {
25599
+ return this.size.y;
25600
+ },
25601
+ set: function set(value) {
25602
+ this.setSize(this.size.x, value);
25603
+ }
25604
+ },
25605
+ {
25606
+ key: "root",
25607
+ get: function get() {
25608
+ var _this_parent;
25609
+ var _this_parent_root;
25610
+ return _instanceof1(this, RootControl) ? this : (_this_parent_root = (_this_parent = this.parent) == null ? void 0 : _this_parent.root) != null ? _this_parent_root : null;
25611
+ }
25612
+ },
25613
+ {
25614
+ key: "isDisposed",
25615
+ get: function get() {
25616
+ return this.disposed;
25617
+ }
25618
+ }
25619
+ ]);
25620
+ return Control;
25621
+ }();
25622
+ /** A Control that owns child Controls. */ var ContainerControl = /*#__PURE__*/ function(Control) {
25623
+ _inherits(ContainerControl, Control);
25624
+ function ContainerControl() {
25625
+ var _this;
25626
+ _this = Control.apply(this, arguments) || this;
25627
+ _this.children = [];
25628
+ return _this;
25629
+ }
25630
+ var _proto = ContainerControl.prototype;
25631
+ _proto.addChild = function addChild(child) {
25632
+ child.parent = this;
25633
+ return child;
25634
+ };
25635
+ _proto.removeChild = function removeChild(child) {
25636
+ if (child.parent === this) {
25637
+ child.parent = null;
25638
+ }
25639
+ };
25640
+ _proto.getChildIndex = function getChildIndex(child) {
25641
+ return this.children.indexOf(child);
25642
+ };
25643
+ /** @internal */ _proto.changeChildIndex = function changeChildIndex(child, newIndex) {
25644
+ var _this_root;
25645
+ var oldIndex = this.children.indexOf(child);
25646
+ if (oldIndex === newIndex || oldIndex === -1) {
25647
+ return;
25648
+ }
25649
+ this.children.splice(oldIndex, 1);
25650
+ if (newIndex < 0 || newIndex >= this.children.length) {
25651
+ this.children.push(child);
25652
+ } else {
25653
+ this.children.splice(newIndex, 0, child);
25654
+ }
25655
+ (_this_root = this.root) == null ? void 0 : _this_root.controlTreeChanged();
25656
+ };
25657
+ /** @internal */ _proto.addChildInternal = function addChildInternal(child) {
25658
+ if (!this.children.includes(child)) {
25659
+ this.children.push(child);
25660
+ }
25661
+ };
25662
+ /** @internal */ _proto.removeChildInternal = function removeChildInternal(child) {
25663
+ var index = this.children.indexOf(child);
25664
+ if (index !== -1) {
25665
+ this.children.splice(index, 1);
25666
+ }
25667
+ };
25668
+ _proto.drawSelf = function drawSelf() {
25669
+ Control.prototype.draw.call(this);
25670
+ };
25671
+ _proto.draw = function draw() {
25672
+ this.drawSelf();
25673
+ this.drawChildren();
25674
+ };
25675
+ _proto.drawChildren = function drawChildren() {
25676
+ var graphics = this.engine.graphics;
25677
+ if (this.clipContents) ;
25678
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.children), _step; !(_step = _iterator()).done;){
25679
+ var child = _step.value;
25680
+ if (!child.visible || child.isDisposed) {
25681
+ continue;
25682
+ }
25683
+ graphics.pushTransform(child.getTransform2D());
25684
+ child.draw();
25685
+ graphics.popTransform();
25686
+ }
25687
+ };
25688
+ _proto.update = function update(deltaTime) {
25689
+ Control.prototype.update.call(this, deltaTime);
25690
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.children.slice()), _step; !(_step = _iterator()).done;){
25691
+ var child = _step.value;
25692
+ if (child.enabled && !child.isDisposed) {
25693
+ child.update(deltaTime);
25694
+ }
25695
+ }
25696
+ };
25697
+ _proto.dispose = function dispose() {
25698
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.children.slice()), _step; !(_step = _iterator()).done;){
25699
+ var child = _step.value;
25700
+ child.dispose();
25701
+ }
25702
+ Control.prototype.dispose.call(this);
25703
+ };
25704
+ return ContainerControl;
25705
+ }(Control);
25706
+ /** Base class for GUI tree roots and input dispatchers. */ var RootControl = /*#__PURE__*/ function(ContainerControl) {
25707
+ _inherits(RootControl, ContainerControl);
25708
+ function RootControl() {
25709
+ return ContainerControl.apply(this, arguments);
25710
+ }
25711
+ return RootControl;
25712
+ }(ContainerControl);
25713
+
25714
+ var _obj$3;
25715
+ var cursorNames = (_obj$3 = {}, _obj$3[exports.CursorShape.Arrow] = "default", _obj$3[exports.CursorShape.Ibeam] = "text", _obj$3[exports.CursorShape.PointingHand] = "pointer", _obj$3[exports.CursorShape.Cross] = "crosshair", _obj$3[exports.CursorShape.Wait] = "wait", _obj$3[exports.CursorShape.Busy] = "progress", _obj$3[exports.CursorShape.Drag] = "grab", _obj$3[exports.CursorShape.CanDrop] = "copy", _obj$3[exports.CursorShape.Forbidden] = "not-allowed", _obj$3[exports.CursorShape.Vsize] = "ns-resize", _obj$3[exports.CursorShape.Hsize] = "ew-resize", _obj$3[exports.CursorShape.Bdiagsize] = "nesw-resize", _obj$3[exports.CursorShape.Fdiagsize] = "nwse-resize", _obj$3[exports.CursorShape.Move] = "move", _obj$3[exports.CursorShape.Vsplit] = "row-resize", _obj$3[exports.CursorShape.Hsplit] = "col-resize", _obj$3[exports.CursorShape.Help] = "help", _obj$3);
25716
+ function getButtonMask(button) {
25717
+ switch(button){
25718
+ case exports.MouseButton.Left:
25719
+ return exports.MouseButtonMask.Left;
25720
+ case exports.MouseButton.Right:
25721
+ return exports.MouseButtonMask.Right;
25722
+ case exports.MouseButton.Middle:
25723
+ return exports.MouseButtonMask.Middle;
25724
+ case exports.MouseButton.Xbutton1:
25725
+ return exports.MouseButtonMask.Xbutton1;
25726
+ case exports.MouseButton.Xbutton2:
25727
+ return exports.MouseButtonMask.Xbutton2;
25728
+ default:
25729
+ return exports.MouseButtonMask.None;
25730
+ }
25731
+ }
25732
+ function isWheelButton(button) {
25733
+ return button >= exports.MouseButton.WheelUp && button <= exports.MouseButton.WheelRight;
25734
+ }
25735
+ /** CanvasLayer-like boundary for a single UICanvas GUI tree. */ var CanvasRootControl = /*#__PURE__*/ function(ContainerControl) {
25736
+ _inherits(CanvasRootControl, ContainerControl);
25737
+ function CanvasRootControl(engine, canvas) {
25738
+ var _this;
25739
+ _this = ContainerControl.call(this, engine) || this;
25740
+ _this.canvas = canvas;
25741
+ _this.mouseFilter = exports.MouseFilter.Ignore;
25742
+ _this.setSize(engine.canvas.width, engine.canvas.height);
25743
+ return _this;
25744
+ }
25745
+ _create_class(CanvasRootControl, [
25746
+ {
25747
+ key: "inputDisabled",
25748
+ get: function get() {
25749
+ var _this_canvas_item;
25750
+ return !this.canvas.receivesEvents || !this.canvas.enabled || !((_this_canvas_item = this.canvas.item) == null ? void 0 : _this_canvas_item.isActive);
25751
+ }
25752
+ }
25753
+ ]);
25754
+ return CanvasRootControl;
25755
+ }(ContainerControl);
25756
+ /** Global ordered collection of UICanvas roots. */ var CanvasContainer = /*#__PURE__*/ function(ContainerControl) {
25757
+ _inherits(CanvasContainer, ContainerControl);
25758
+ function CanvasContainer(engine) {
25759
+ var _this;
25760
+ _this = ContainerControl.call(this, engine) || this;
25761
+ _this.mouseFilter = exports.MouseFilter.Ignore;
25762
+ _this.setSize(engine.canvas.width, engine.canvas.height);
25763
+ return _this;
25764
+ }
25765
+ var _proto = CanvasContainer.prototype;
25766
+ _proto.sortCanvases = function sortCanvases() {
25767
+ this.children.sort(function(left, right) {
25768
+ return left.canvas.order - right.canvas.order;
25769
+ });
25770
+ };
25771
+ _proto.addChildInternal = function addChildInternal(child) {
25772
+ ContainerControl.prototype.addChildInternal.call(this, child);
25773
+ this.sortCanvases();
25774
+ };
25775
+ _proto.draw = function draw() {
25776
+ this.sortCanvases();
25777
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.children), _step; !(_step = _iterator()).done;){
25778
+ var child = _step.value;
25779
+ var root = child;
25780
+ if (root.canvas.isVisible) {
25781
+ root.draw();
25782
+ }
25783
+ }
25784
+ };
25785
+ return CanvasContainer;
25786
+ }(ContainerControl);
25787
+ /** Engine window GUI root. Routes events across all UICanvas roots. */ var WindowRootControl = /*#__PURE__*/ function(RootControl) {
25788
+ _inherits(WindowRootControl, RootControl);
25789
+ function WindowRootControl(engine) {
25790
+ var _this;
25791
+ _this = RootControl.call(this, engine) || this;
25792
+ _this.dragThreshold = 10;
25793
+ _this.lastInput = null;
25794
+ _this.gui = {
25795
+ mouseFocus: null,
25796
+ mouseClickGrabber: null,
25797
+ mouseFocusMask: exports.MouseButtonMask.None,
25798
+ mouseOver: null,
25799
+ mouseOverHierarchy: [],
25800
+ touchFocus: new Map(),
25801
+ keyFocus: null,
25802
+ dragAccum: new Vector2(),
25803
+ dragAttempted: false,
25804
+ dragging: false,
25805
+ dragData: null,
25806
+ dragMouseOver: null,
25807
+ dragSuccessful: false,
25808
+ lastMousePosition: new Vector2(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY),
25809
+ sendingMouseEnterExit: false,
25810
+ mouseOverUpdatePending: false
25811
+ };
25812
+ _this.mouseFilter = exports.MouseFilter.Ignore;
25813
+ _this.setSize(engine.canvas.width, engine.canvas.height);
25814
+ _this.canvases = new CanvasContainer(engine);
25815
+ _this.canvases.parent = _assert_this_initialized(_this);
25816
+ return _this;
25817
+ }
25818
+ var _proto = WindowRootControl.prototype;
25819
+ _proto.pushInput = function pushInput(event) {
25820
+ event.clearAccepted();
25821
+ this.lastInput = event;
25822
+ this.cleanupInternalState();
25823
+ this.processGUIInput(event);
25824
+ this.postGrabClickFocus();
25825
+ };
25826
+ _proto.isInputHandled = function isInputHandled() {
25827
+ var _this_lastInput;
25828
+ var _this_lastInput_isAccepted;
25829
+ return (_this_lastInput_isAccepted = (_this_lastInput = this.lastInput) == null ? void 0 : _this_lastInput.isAccepted()) != null ? _this_lastInput_isAccepted : false;
25830
+ };
25831
+ _proto.getMousePosition = function getMousePosition() {
25832
+ return this.gui.lastMousePosition.clone();
25833
+ };
25834
+ _proto.guiGetFocusOwner = function guiGetFocusOwner() {
25835
+ return this.isFocusTargetUsable(this.gui.keyFocus) ? this.gui.keyFocus : null;
25836
+ };
25837
+ _proto.guiReleaseFocus = function guiReleaseFocus() {
25838
+ this.releaseControlFocus();
25839
+ };
25840
+ _proto.guiIsDragging = function guiIsDragging() {
25841
+ return this.gui.dragging;
25842
+ };
25843
+ _proto.guiGetDragData = function guiGetDragData() {
25844
+ return this.gui.dragData;
25845
+ };
25846
+ _proto.guiIsDragSuccessful = function guiIsDragSuccessful() {
25847
+ return this.gui.dragSuccessful;
25848
+ };
25849
+ _proto.guiCancelDrag = function guiCancelDrag() {
25850
+ this.endDragging(false);
25851
+ };
25852
+ _proto.grabControlFocus = function grabControlFocus(control) {
25853
+ if (!this.isFocusTargetUsable(control) || this.gui.keyFocus === control) {
25854
+ return;
25855
+ }
25856
+ var previous = this.gui.keyFocus;
25857
+ this.gui.keyFocus = control;
25858
+ if (previous && !previous.isDisposed) {
25859
+ previous.onLostFocus();
25860
+ }
25861
+ control.onGotFocus();
25862
+ };
25863
+ _proto.grabControlClickFocus = function grabControlClickFocus(control) {
25864
+ var _this = this;
25865
+ if (this.isControlValid(control)) {
25866
+ this.gui.mouseClickGrabber = control;
25867
+ queueMicrotask(function() {
25868
+ return _this.postGrabClickFocus();
25869
+ });
25870
+ }
25871
+ };
25872
+ _proto.releaseControlFocus = function releaseControlFocus(control) {
25873
+ var previous = this.gui.keyFocus;
25874
+ if (!previous || control && previous !== control) {
25875
+ return;
25876
+ }
25877
+ this.gui.keyFocus = null;
25878
+ if (!previous.isDisposed) {
25879
+ previous.onLostFocus();
25880
+ }
25881
+ };
25882
+ _proto.warpControlMouse = function warpControlMouse(position) {
25883
+ this.gui.lastMousePosition.copyFrom(position);
25884
+ this.updateMouseOver(position);
25885
+ this.updateMouseCursorState();
25886
+ };
25887
+ _proto.updateMouseCursorState = function updateMouseCursorState() {
25888
+ var position = this.gui.lastMousePosition;
25889
+ var target = this.isControlUsable(this.gui.mouseFocus) ? this.gui.mouseFocus : this.isControlUsable(this.gui.mouseOver) ? this.gui.mouseOver : null;
25890
+ this.updateCursor(target, position);
25891
+ };
25892
+ _proto.controlStateChanged = function controlStateChanged(control) {
25893
+ if (!this.isControlUsable(control)) {
25894
+ this.dropControlState(control);
25895
+ }
25896
+ this.requestMouseOverUpdate();
25897
+ };
25898
+ _proto.controlRemoved = function controlRemoved(control) {
25899
+ this.dropControlState(control);
25900
+ this.cleanupInternalState();
25901
+ this.requestMouseOverUpdate();
25902
+ };
25903
+ _proto.controlTreeChanged = function controlTreeChanged() {
25904
+ this.requestMouseOverUpdate();
25905
+ };
25906
+ _proto.cancelPointerInput = function cancelPointerInput() {
25907
+ this.dropMouseFocus();
25908
+ this.dropMouseOver();
25909
+ this.gui.touchFocus.clear();
25910
+ this.endDragging(false);
25911
+ this.releaseControlFocus();
25912
+ };
25913
+ _proto.resize = function resize(width, height) {
25914
+ this.setSize(width, height);
25915
+ this.canvases.setSize(width, height);
25916
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.canvases.children), _step; !(_step = _iterator()).done;){
25917
+ var root = _step.value;
25918
+ root.setSize(width, height);
25919
+ }
25920
+ };
25921
+ _proto.render = function render() {
25922
+ if (this.canvases.children.length === 0) {
25923
+ return;
25924
+ }
25925
+ this.engine.graphics.begin();
25926
+ this.draw();
25927
+ this.engine.graphics.end();
25928
+ };
25929
+ _proto.update = function update(deltaTime) {
25930
+ if (this.gui.mouseOverUpdatePending) {
25931
+ this.gui.mouseOverUpdatePending = false;
25932
+ this.updateMouseOver(this.gui.lastMousePosition);
25276
25933
  }
25277
- var rt = new RectTransform();
25278
- rt.engine = t.engine;
25279
- rt.name = t.name;
25280
- rt.position.copyFrom(t.position);
25281
- rt.quat.copyFrom(t.quat);
25282
- rt.rotation.copyFrom(t.rotation);
25283
- rt.scale.copyFrom(t.scale);
25284
- rt.size.copyFrom(t.size);
25285
- // 不拷贝源 anchor — 升级为 RectTransform 时使用默认 pivot=(0.5, 0.5)
25286
- // anchor 同步成 pivot * size,获得“中心轴心”默认行为
25287
- rt.anchor.set(rt.pivot.x * rt.size.x, rt.pivot.y * rt.size.y, t.anchor.z);
25288
- if (t.parentTransform) {
25289
- rt.parentTransform = t.parentTransform;
25934
+ RootControl.prototype.update.call(this, deltaTime);
25935
+ };
25936
+ _proto.dispose = function dispose() {
25937
+ this.cancelPointerInput();
25938
+ RootControl.prototype.dispose.call(this);
25939
+ };
25940
+ _proto.processGUIInput = function processGUIInput(event) {
25941
+ if (_instanceof1(event, InputEventKey)) {
25942
+ var target = this.guiGetFocusOwner();
25943
+ if (target) {
25944
+ this.callControlInput(target, event);
25945
+ }
25946
+ } else if (_instanceof1(event, InputEventMouse)) {
25947
+ this.gui.lastMousePosition.copyFrom(event.globalPosition);
25948
+ this.updateMouseOver(event.globalPosition);
25949
+ if (_instanceof1(event, InputEventMouseButton)) {
25950
+ this.processMouseButton(event);
25951
+ } else if (_instanceof1(event, InputEventMouseMotion)) {
25952
+ this.processMouseMotion(event);
25953
+ }
25954
+ } else if (_instanceof1(event, InputEventScreenTouch)) {
25955
+ this.processScreenTouch(event);
25956
+ } else if (_instanceof1(event, InputEventScreenDrag)) {
25957
+ this.processScreenDrag(event);
25958
+ }
25959
+ };
25960
+ _proto.processMouseButton = function processMouseButton(event) {
25961
+ if (isWheelButton(event.buttonIndex)) {
25962
+ var target = this.findInputControl(event.globalPosition);
25963
+ if (target) {
25964
+ this.callGUIInput(target, event);
25965
+ }
25966
+ return;
25967
+ }
25968
+ var mask = getButtonMask(event.buttonIndex);
25969
+ if (event.isPressed()) {
25970
+ var target1 = this.gui.mouseFocusMask !== 0 ? this.gui.mouseFocus : this.findInputControl(event.globalPosition);
25971
+ this.gui.mouseFocus = target1;
25972
+ if (!target1) {
25973
+ return;
25974
+ }
25975
+ this.gui.mouseFocusMask |= mask;
25976
+ if (event.buttonIndex === exports.MouseButton.Left) {
25977
+ this.gui.dragAccum.setZero();
25978
+ this.gui.dragAttempted = false;
25979
+ this.findClickFocus(target1);
25980
+ }
25981
+ this.callGUIInput(target1, event);
25982
+ } else {
25983
+ if (event.buttonIndex === exports.MouseButton.Left && this.gui.dragging) {
25984
+ this.finishDrop(event.globalPosition);
25985
+ }
25986
+ this.gui.mouseFocusMask &= ~mask;
25987
+ var target2 = this.gui.mouseFocus;
25988
+ if (this.gui.mouseFocusMask === 0) {
25989
+ this.gui.mouseFocus = null;
25990
+ }
25991
+ if (this.isControlUsable(target2)) {
25992
+ this.callGUIInput(target2, event);
25993
+ }
25290
25994
  }
25291
- return rt;
25292
25995
  };
25293
- return RectTransform;
25294
- }(Transform);
25996
+ _proto.processMouseMotion = function processMouseMotion(event) {
25997
+ if (!this.gui.dragging && !this.gui.dragAttempted && this.gui.mouseFocus && (this.gui.mouseFocusMask & exports.MouseButtonMask.Left) !== 0) {
25998
+ this.gui.dragAccum.add(event.relative);
25999
+ if (this.gui.dragAccum.length() > this.dragThreshold) {
26000
+ var origin = event.globalPosition.clone().subtract(this.gui.dragAccum);
26001
+ this.beginDragging(this.gui.mouseFocus, origin);
26002
+ this.gui.dragAttempted = true;
26003
+ }
26004
+ }
26005
+ var target = this.isControlUsable(this.gui.mouseFocus) ? this.gui.mouseFocus : this.findInputControl(event.globalPosition);
26006
+ if (target) {
26007
+ this.callGUIInput(target, event);
26008
+ }
26009
+ if (this.gui.dragging) {
26010
+ this.gui.dragMouseOver = this.findDropTarget(this.findInputControl(event.globalPosition), event.globalPosition);
26011
+ }
26012
+ this.updateCursor(target, event.globalPosition);
26013
+ };
26014
+ _proto.processScreenTouch = function processScreenTouch(event) {
26015
+ var target;
26016
+ if (event.isPressed()) {
26017
+ target = this.findInputControl(event.position);
26018
+ if (target) {
26019
+ this.gui.touchFocus.set(event.index, target);
26020
+ }
26021
+ } else {
26022
+ var _this_gui_touchFocus_get;
26023
+ target = (_this_gui_touchFocus_get = this.gui.touchFocus.get(event.index)) != null ? _this_gui_touchFocus_get : null;
26024
+ this.gui.touchFocus.delete(event.index);
26025
+ }
26026
+ if (this.isControlUsable(target)) {
26027
+ this.callGUIInput(target, event);
26028
+ }
26029
+ };
26030
+ _proto.processScreenDrag = function processScreenDrag(event) {
26031
+ var _this_gui_touchFocus_get;
26032
+ var target = (_this_gui_touchFocus_get = this.gui.touchFocus.get(event.index)) != null ? _this_gui_touchFocus_get : this.findInputControl(event.position);
26033
+ if (this.isControlUsable(target)) {
26034
+ this.callGUIInput(target, event);
26035
+ }
26036
+ };
26037
+ _proto.callGUIInput = function callGUIInput(target, event) {
26038
+ var current = target;
26039
+ var pointerEvent = _instanceof1(event, InputEventMouse) || _instanceof1(event, InputEventScreenTouch) || _instanceof1(event, InputEventScreenDrag);
26040
+ while(current && current !== this && this.isControlUsable(current)){
26041
+ var filter = current.getEffectiveMouseFilter();
26042
+ if (filter !== exports.MouseFilter.Ignore) {
26043
+ var localEvent = event.xformedBy(this.getGlobalInverse(current));
26044
+ this.callControlInput(current, localEvent);
26045
+ if (localEvent.isAccepted()) {
26046
+ event.accept();
26047
+ }
26048
+ }
26049
+ var forcePassWheel = _instanceof1(event, InputEventMouseButton) && isWheelButton(event.buttonIndex) && current.mouseForcePassScrollEvents;
26050
+ if (event.isAccepted() || filter === exports.MouseFilter.Stop && pointerEvent && !forcePassWheel) {
26051
+ event.accept();
26052
+ return;
26053
+ }
26054
+ current = current.parent;
26055
+ }
26056
+ };
26057
+ _proto.callControlInput = function callControlInput(control, event) {
26058
+ if (_instanceof1(event, InputEventMouseButton)) {
26059
+ if (isWheelButton(event.buttonIndex)) {
26060
+ control.onMouseWheel(event);
26061
+ } else if (event.isPressed()) {
26062
+ control.onMouseDown(event);
26063
+ } else {
26064
+ control.onMouseUp(event);
26065
+ }
26066
+ } else if (_instanceof1(event, InputEventMouseMotion)) {
26067
+ control.onMouseMove(event);
26068
+ } else if (_instanceof1(event, InputEventScreenTouch)) {
26069
+ if (event.isPressed()) {
26070
+ control.onTouchDown(event);
26071
+ } else {
26072
+ control.onTouchUp(event);
26073
+ }
26074
+ } else if (_instanceof1(event, InputEventScreenDrag)) {
26075
+ control.onTouchMove(event);
26076
+ } else if (_instanceof1(event, InputEventKey)) {
26077
+ if (event.isPressed()) {
26078
+ control.onKeyDown(event);
26079
+ } else if (event.isReleased()) {
26080
+ control.onKeyUp(event);
26081
+ }
26082
+ }
26083
+ };
26084
+ _proto.findInputControl = function findInputControl(position) {
26085
+ this.canvases.sortCanvases();
26086
+ for(var index = this.canvases.children.length - 1; index >= 0; index--){
26087
+ var root = this.canvases.children[index];
26088
+ if (!root.canvas.isVisible || root.inputDisabled) {
26089
+ continue;
26090
+ }
26091
+ var target = this.findControlAtPosition(root, position, true);
26092
+ if (target) {
26093
+ return target;
26094
+ }
26095
+ }
26096
+ return null;
26097
+ };
26098
+ _proto.findControlAtPosition = function findControlAtPosition(container, position, skipSelf) {
26099
+ if (skipSelf === void 0) skipSelf = false;
26100
+ if (!container.visibleInHierarchy || container.isDisposed) {
26101
+ return null;
26102
+ }
26103
+ var localPosition = this.toLocal(container, position);
26104
+ if (container.clipContents && !container.hasPoint(localPosition)) {
26105
+ return null;
26106
+ }
26107
+ for(var index = container.children.length - 1; index >= 0; index--){
26108
+ var child = container.children[index];
26109
+ if (!child.visibleInHierarchy || child.isDisposed) {
26110
+ continue;
26111
+ }
26112
+ if (_instanceof1(child, ContainerControl)) {
26113
+ var found = this.findControlAtPosition(child, position);
26114
+ if (found) {
26115
+ return found;
26116
+ }
26117
+ } else if (child.getEffectiveMouseFilter() !== exports.MouseFilter.Ignore && child.hasPoint(this.toLocal(child, position))) {
26118
+ return child;
26119
+ }
26120
+ }
26121
+ if (!skipSelf && container.getEffectiveMouseFilter() !== exports.MouseFilter.Ignore && container.hasPoint(localPosition)) {
26122
+ return container;
26123
+ }
26124
+ return null;
26125
+ };
26126
+ _proto.updateMouseOver = function updateMouseOver(position) {
26127
+ if (this.gui.sendingMouseEnterExit) {
26128
+ this.gui.mouseOverUpdatePending = true;
26129
+ return;
26130
+ }
26131
+ this.gui.mouseOverUpdatePending = false;
26132
+ var target = this.findInputControl(position);
26133
+ var next = this.buildHoverHierarchy(target);
26134
+ var previous = this.gui.mouseOverHierarchy;
26135
+ var common = 0;
26136
+ while(common < previous.length && common < next.length && previous[common] === next[common]){
26137
+ common++;
26138
+ }
26139
+ this.gui.sendingMouseEnterExit = true;
26140
+ for(var index = previous.length - 1; index >= common; index--){
26141
+ if (!previous[index].isDisposed) {
26142
+ previous[index].onMouseLeave();
26143
+ }
26144
+ }
26145
+ for(var index1 = common; index1 < next.length; index1++){
26146
+ next[index1].onMouseEnter(this.toLocal(next[index1], position));
26147
+ }
26148
+ this.gui.sendingMouseEnterExit = false;
26149
+ this.gui.mouseOver = target;
26150
+ this.gui.mouseOverHierarchy = next;
26151
+ };
26152
+ _proto.buildHoverHierarchy = function buildHoverHierarchy(target) {
26153
+ var hierarchy = [];
26154
+ var current = target;
26155
+ while(current && current !== this){
26156
+ if (current.getEffectiveMouseFilter() !== exports.MouseFilter.Ignore) {
26157
+ hierarchy.push(current);
26158
+ }
26159
+ if (current.getEffectiveMouseFilter() === exports.MouseFilter.Stop) {
26160
+ break;
26161
+ }
26162
+ current = current.parent;
26163
+ }
26164
+ hierarchy.reverse();
26165
+ return hierarchy;
26166
+ };
26167
+ _proto.findClickFocus = function findClickFocus(target) {
26168
+ var current = target;
26169
+ while(current && current !== this){
26170
+ var mode = current.getFocusModeWithOverride();
26171
+ if (mode === exports.FocusMode.Click || mode === exports.FocusMode.All) {
26172
+ this.grabControlFocus(current);
26173
+ return;
26174
+ }
26175
+ if (current.getEffectiveMouseFilter() === exports.MouseFilter.Stop) {
26176
+ return;
26177
+ }
26178
+ current = current.parent;
26179
+ }
26180
+ };
26181
+ _proto.beginDragging = function beginDragging(source, position) {
26182
+ var current = source;
26183
+ while(current && current !== this){
26184
+ var data = current.invokeGetDragData(this.toLocal(current, position));
26185
+ if (data !== null && data !== undefined) {
26186
+ this.gui.dragging = true;
26187
+ this.gui.dragData = data;
26188
+ this.gui.mouseFocus = null;
26189
+ this.gui.mouseFocusMask = exports.MouseButtonMask.None;
26190
+ return;
26191
+ }
26192
+ if (current.getEffectiveMouseFilter() === exports.MouseFilter.Stop) {
26193
+ return;
26194
+ }
26195
+ current = current.parent;
26196
+ }
26197
+ };
26198
+ _proto.finishDrop = function finishDrop(position) {
26199
+ var target = this.findDropTarget(this.findInputControl(position), position);
26200
+ if (target) {
26201
+ target.invokeDropData(this.toLocal(target, position), this.gui.dragData);
26202
+ }
26203
+ this.endDragging(!!target);
26204
+ };
26205
+ _proto.findDropTarget = function findDropTarget(target, position) {
26206
+ var current = target;
26207
+ while(current && current !== this){
26208
+ if (current.invokeCanDropData(this.toLocal(current, position), this.gui.dragData)) {
26209
+ return current;
26210
+ }
26211
+ if (current.getEffectiveMouseFilter() === exports.MouseFilter.Stop) {
26212
+ return null;
26213
+ }
26214
+ current = current.parent;
26215
+ }
26216
+ return null;
26217
+ };
26218
+ _proto.endDragging = function endDragging(successful) {
26219
+ this.gui.dragSuccessful = successful;
26220
+ this.gui.dragging = false;
26221
+ this.gui.dragData = null;
26222
+ this.gui.dragMouseOver = null;
26223
+ };
26224
+ _proto.updateCursor = function updateCursor(target, position) {
26225
+ var current = target;
26226
+ var cursor = exports.CursorShape.Arrow;
26227
+ while(current && current !== this){
26228
+ var candidate = current.getCursorShape(this.toLocal(current, position));
26229
+ if (candidate !== exports.CursorShape.Arrow) {
26230
+ cursor = candidate;
26231
+ break;
26232
+ }
26233
+ if (current.getEffectiveMouseFilter() === exports.MouseFilter.Stop) {
26234
+ break;
26235
+ }
26236
+ current = current.parent;
26237
+ }
26238
+ this.engine.canvas.style.cursor = typeof cursor === "string" ? cursor : cursorNames[cursor];
26239
+ };
26240
+ _proto.postGrabClickFocus = function postGrabClickFocus() {
26241
+ var target = this.gui.mouseClickGrabber;
26242
+ this.gui.mouseClickGrabber = null;
26243
+ if (this.isControlUsable(target)) {
26244
+ this.gui.mouseFocus = target;
26245
+ }
26246
+ };
26247
+ _proto.cleanupInternalState = function cleanupInternalState() {
26248
+ if (!this.isControlUsable(this.gui.mouseFocus)) {
26249
+ this.dropMouseFocus();
26250
+ }
26251
+ if (this.gui.keyFocus && !this.isFocusTargetUsable(this.gui.keyFocus)) {
26252
+ this.releaseControlFocus(this.gui.keyFocus);
26253
+ }
26254
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.gui.touchFocus), _step; !(_step = _iterator()).done;){
26255
+ var _step_value = _step.value, index = _step_value[0], control = _step_value[1];
26256
+ if (!this.isControlUsable(control)) {
26257
+ this.gui.touchFocus.delete(index);
26258
+ }
26259
+ }
26260
+ };
26261
+ _proto.dropMouseFocus = function dropMouseFocus() {
26262
+ this.gui.mouseFocus = null;
26263
+ this.gui.mouseFocusMask = exports.MouseButtonMask.None;
26264
+ };
26265
+ _proto.dropMouseOver = function dropMouseOver() {
26266
+ for(var index = this.gui.mouseOverHierarchy.length - 1; index >= 0; index--){
26267
+ var control = this.gui.mouseOverHierarchy[index];
26268
+ if (!control.isDisposed) {
26269
+ control.onMouseLeave();
26270
+ }
26271
+ }
26272
+ this.gui.mouseOver = null;
26273
+ this.gui.mouseOverHierarchy = [];
26274
+ };
26275
+ _proto.dropControlState = function dropControlState(control) {
26276
+ if (this.controlBelongsToSubtree(this.gui.mouseFocus, control)) {
26277
+ this.dropMouseFocus();
26278
+ }
26279
+ if (this.controlBelongsToSubtree(this.gui.mouseClickGrabber, control)) {
26280
+ this.gui.mouseClickGrabber = null;
26281
+ }
26282
+ if (this.controlBelongsToSubtree(this.gui.keyFocus, control)) {
26283
+ var _this_gui_keyFocus;
26284
+ this.releaseControlFocus((_this_gui_keyFocus = this.gui.keyFocus) != null ? _this_gui_keyFocus : undefined);
26285
+ }
26286
+ if (this.controlBelongsToSubtree(this.gui.mouseOver, control)) {
26287
+ this.dropMouseOver();
26288
+ }
26289
+ if (this.controlBelongsToSubtree(this.gui.dragMouseOver, control)) {
26290
+ this.gui.dragMouseOver = null;
26291
+ }
26292
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.gui.touchFocus), _step; !(_step = _iterator()).done;){
26293
+ var _step_value = _step.value, index = _step_value[0], target = _step_value[1];
26294
+ if (this.controlBelongsToSubtree(target, control)) {
26295
+ this.gui.touchFocus.delete(index);
26296
+ }
26297
+ }
26298
+ };
26299
+ _proto.requestMouseOverUpdate = function requestMouseOverUpdate() {
26300
+ if (Number.isFinite(this.gui.lastMousePosition.x)) {
26301
+ this.updateMouseOver(this.gui.lastMousePosition);
26302
+ }
26303
+ };
26304
+ _proto.getGlobalInverse = function getGlobalInverse(control) {
26305
+ var transform = control.getGlobalTransform2D().clone();
26306
+ return Math.abs(transform.determinant()) < 1e-12 ? new Matrix3() : transform.invert();
26307
+ };
26308
+ _proto.toLocal = function toLocal(control, position) {
26309
+ var elements = this.getGlobalInverse(control).elements;
26310
+ return new Vector2(elements[0] * position.x + elements[3] * position.y + elements[6], elements[1] * position.x + elements[4] * position.y + elements[7]);
26311
+ };
26312
+ _proto.controlBelongsToSubtree = function controlBelongsToSubtree(control, subtree) {
26313
+ var current = control;
26314
+ while(current){
26315
+ if (current === subtree) {
26316
+ return true;
26317
+ }
26318
+ current = current.parent;
26319
+ }
26320
+ return false;
26321
+ };
26322
+ _proto.isControlValid = function isControlValid(control) {
26323
+ return !!control && !control.isDisposed && control.root === this;
26324
+ };
26325
+ _proto.isControlUsable = function isControlUsable(control) {
26326
+ if (!this.isControlValid(control) || !control.visibleInHierarchy || !control.enabledInHierarchy) {
26327
+ return false;
26328
+ }
26329
+ var root = this.findCanvasRoot(control);
26330
+ return !root || !root.inputDisabled;
26331
+ };
26332
+ _proto.findCanvasRoot = function findCanvasRoot(control) {
26333
+ var current = control;
26334
+ while(current && current !== this){
26335
+ if (_instanceof1(current, CanvasRootControl)) {
26336
+ return current;
26337
+ }
26338
+ current = current.parent;
26339
+ }
26340
+ return null;
26341
+ };
26342
+ _proto.isFocusTargetUsable = function isFocusTargetUsable(control) {
26343
+ return this.isControlUsable(control) && control.getFocusModeWithOverride() !== exports.FocusMode.None;
26344
+ };
26345
+ return WindowRootControl;
26346
+ }(RootControl);
26347
+
26348
+ exports.CanvasRenderMode = void 0;
26349
+ (function(CanvasRenderMode) {
26350
+ CanvasRenderMode[CanvasRenderMode["ScreenSpace"] = 0] = "ScreenSpace";
26351
+ CanvasRenderMode[CanvasRenderMode["CameraSpace"] = 1] = "CameraSpace";
26352
+ CanvasRenderMode[CanvasRenderMode["WorldSpace"] = 2] = "WorldSpace";
26353
+ CanvasRenderMode[CanvasRenderMode["WorldSpaceFaceCamera"] = 3] = "WorldSpaceFaceCamera";
26354
+ })(exports.CanvasRenderMode || (exports.CanvasRenderMode = {}));
26355
+ /** Canvas-layer boundary attached to a VFXItem. Input state remains owned by the window root. */ var UICanvas = /*#__PURE__*/ function(Component) {
26356
+ _inherits(UICanvas, Component);
26357
+ function UICanvas(engine) {
26358
+ var _this;
26359
+ _this = Component.call(this, engine) || this;
26360
+ _this.renderMode = 0;
26361
+ _this.receivesEvents = true;
26362
+ _this._order = 0;
26363
+ _this.registered = false;
26364
+ _this.rootControl = new CanvasRootControl(engine, _assert_this_initialized(_this));
26365
+ return _this;
26366
+ }
26367
+ var _proto = UICanvas.prototype;
26368
+ _proto.onEnable = function onEnable() {
26369
+ this.register();
26370
+ };
26371
+ _proto.onDisable = function onDisable() {
26372
+ this.unregister();
26373
+ };
26374
+ _proto.onDestroy = function onDestroy() {
26375
+ this.destroyCanvas();
26376
+ };
26377
+ _proto.dispose = function dispose() {
26378
+ this.destroyCanvas();
26379
+ Component.prototype.dispose.call(this);
26380
+ };
26381
+ _proto.register = function register() {
26382
+ if (!this.registered) {
26383
+ this.rootControl.parent = this.engine.windowRoot.canvases;
26384
+ this.registered = true;
26385
+ }
26386
+ };
26387
+ _proto.unregister = function unregister() {
26388
+ if (this.registered) {
26389
+ this.rootControl.parent = null;
26390
+ this.registered = false;
26391
+ }
26392
+ };
26393
+ _proto.destroyCanvas = function destroyCanvas() {
26394
+ this.unregister();
26395
+ if (!this.rootControl.isDisposed) {
26396
+ this.rootControl.dispose();
26397
+ }
26398
+ };
26399
+ _create_class(UICanvas, [
26400
+ {
26401
+ key: "order",
26402
+ get: function get() {
26403
+ return this._order;
26404
+ },
26405
+ set: function set(value) {
26406
+ if (this._order !== value) {
26407
+ this._order = value;
26408
+ this.engine.windowRoot.canvases.sortCanvases();
26409
+ }
26410
+ }
26411
+ },
26412
+ {
26413
+ key: "isVisible",
26414
+ get: function get() {
26415
+ var _this_item;
26416
+ return this.renderMode === 0 && this.enabled && !!((_this_item = this.item) == null ? void 0 : _this_item.isActive);
26417
+ }
26418
+ }
26419
+ ]);
26420
+ return UICanvas;
26421
+ }(Component);
25295
26422
 
25296
26423
  /**
25297
- * 锚点布局组件
25298
- *
25299
- * `Control extends CanvasItem`。CanvasItem 仅承担绘制与节点层级,Control 在挂到 VFXItem 时把
25300
- * `item.transform` 升级为 {@link RectTransform}。
25301
- *
25302
- * 布局完全由 RectTransform 自治:父子节点关系沿 `Transform.parentTransform / children` 走,
25303
- * 父节点 size 变化时通过 `RectTransform.sizeChanged()` 直接调用子节点 sizeChanged 链式传播。
25304
- * Control 本身不持有任何与布局相关的状态
25305
- */ var Control = /*#__PURE__*/ function(CanvasItem) {
25306
- _inherits(Control, CanvasItem);
25307
- function Control() {
25308
- return CanvasItem.apply(this, arguments);
26424
+ * Scene-tree bridge for a GUI Control. The VFXItem tree owns lifecycle and
26425
+ * serialization while the Control tree owns layout, drawing and input.
26426
+ */ var UIControl = /*#__PURE__*/ function(Component) {
26427
+ _inherits(UIControl, Component);
26428
+ function UIControl(engine) {
26429
+ var _this;
26430
+ _this = Component.call(this, engine) || this;
26431
+ _this.controlNode = null;
26432
+ _this.linkedItemTransform = null;
26433
+ _this.linkedControl = null;
26434
+ _this.syncingLocation = false;
26435
+ _this.itemTransformChanged = function() {
26436
+ return _this.syncItemLocationToControl();
26437
+ };
26438
+ _this.controlLocationChanged = function() {
26439
+ return _this.syncControlLocationToItem();
26440
+ };
26441
+ return _this;
25309
26442
  }
25310
- var _proto = Control.prototype;
25311
- /**
25312
- * 在挂到 VFXItem 时确保 `item.transform` 是 `RectTransform`。
25313
- * 既有 Transform 状态(position / rotation / scale / size / anchor 等)通过 `RectTransform.fromTransform` 复制
25314
- */ _proto.onAwake = function onAwake() {
25315
- var item = this.item;
25316
- if (!_instanceof1(item.transform, RectTransform)) {
25317
- item.transform = RectTransform.fromTransform(item.transform);
26443
+ var _proto = UIControl.prototype;
26444
+ _proto.onAwake = function onAwake() {
26445
+ this.syncControl();
26446
+ };
26447
+ _proto.onEnable = function onEnable() {
26448
+ if (this.controlNode) {
26449
+ this.controlNode.visible = this.item.isActive;
26450
+ this.controlNode.enabled = true;
25318
26451
  }
25319
26452
  };
25320
- return Control;
25321
- }(CanvasItem);
26453
+ _proto.onDisable = function onDisable() {
26454
+ if (this.controlNode) {
26455
+ this.controlNode.visible = this.item.isActive;
26456
+ this.controlNode.enabled = false;
26457
+ }
26458
+ };
26459
+ _proto.onParentChanged = function onParentChanged() {
26460
+ this.syncControl();
26461
+ };
26462
+ _proto.onOrderInParentChanged = function onOrderInParentChanged() {
26463
+ this.syncControlOrder();
26464
+ };
26465
+ _proto.onDestroy = function onDestroy() {
26466
+ this.disposeControl();
26467
+ };
26468
+ _proto.dispose = function dispose() {
26469
+ this.disposeControl();
26470
+ Component.prototype.dispose.call(this);
26471
+ };
26472
+ /** Unlinks the GUI object without disposing or modifying it. */ _proto.unlinkControl = function unlinkControl() {
26473
+ if (this.controlNode) {
26474
+ this.unbindLocationSync();
26475
+ this.controlNode = null;
26476
+ }
26477
+ };
26478
+ _proto.disposeControl = function disposeControl() {
26479
+ var control = this.controlNode;
26480
+ if (control) {
26481
+ this.unbindLocationSync();
26482
+ this.controlNode = null;
26483
+ control.dispose();
26484
+ }
26485
+ };
26486
+ _proto.syncControl = function syncControl() {
26487
+ var control = this.controlNode;
26488
+ if (!control || !this.item) {
26489
+ return;
26490
+ }
26491
+ this.syncingLocation = true;
26492
+ try {
26493
+ control.visible = this.item.isActive;
26494
+ control.enabled = this.enabled;
26495
+ control.parent = this.resolveParent();
26496
+ this.syncControlOrder();
26497
+ this.copyItemLocationToControl();
26498
+ } finally{
26499
+ this.syncingLocation = false;
26500
+ }
26501
+ this.bindLocationSync();
26502
+ };
26503
+ _proto.syncControlOrder = function syncControlOrder() {
26504
+ if (this.controlNode && this.item) {
26505
+ this.controlNode.indexInParent = this.item.orderInParent;
26506
+ }
26507
+ };
26508
+ _proto.resolveParent = function resolveParent() {
26509
+ var parentItem = this.item.parent;
26510
+ if (!parentItem) {
26511
+ var _UIControl_fallbackParentGetDelegate;
26512
+ return (_UIControl_fallbackParentGetDelegate = UIControl.fallbackParentGetDelegate == null ? void 0 : UIControl.fallbackParentGetDelegate.call(UIControl, this)) != null ? _UIControl_fallbackParentGetDelegate : null;
26513
+ }
26514
+ var uiControl = parentItem.getComponent(UIControl);
26515
+ if ((uiControl == null ? void 0 : uiControl.control) && "children" in uiControl.control) {
26516
+ return uiControl.control;
26517
+ }
26518
+ var canvas = parentItem.getComponent(UICanvas);
26519
+ var _canvas_rootControl, _ref;
26520
+ return (_ref = (_canvas_rootControl = canvas == null ? void 0 : canvas.rootControl) != null ? _canvas_rootControl : UIControl.fallbackParentGetDelegate == null ? void 0 : UIControl.fallbackParentGetDelegate.call(UIControl, this)) != null ? _ref : null;
26521
+ };
26522
+ _proto.bindLocationSync = function bindLocationSync() {
26523
+ var itemTransform = this.item.transform;
26524
+ var control = this.controlNode;
26525
+ if (this.linkedItemTransform === itemTransform && this.linkedControl === control) {
26526
+ return;
26527
+ }
26528
+ this.unbindLocationSync();
26529
+ if (control) {
26530
+ this.linkedItemTransform = itemTransform;
26531
+ this.linkedControl = control;
26532
+ itemTransform.on("changed", this.itemTransformChanged);
26533
+ control.on("locationChanged", this.controlLocationChanged);
26534
+ }
26535
+ };
26536
+ _proto.unbindLocationSync = function unbindLocationSync() {
26537
+ var _this_linkedItemTransform, _this_linkedControl;
26538
+ (_this_linkedItemTransform = this.linkedItemTransform) == null ? void 0 : _this_linkedItemTransform.off("changed", this.itemTransformChanged);
26539
+ (_this_linkedControl = this.linkedControl) == null ? void 0 : _this_linkedControl.off("locationChanged", this.controlLocationChanged);
26540
+ this.linkedItemTransform = null;
26541
+ this.linkedControl = null;
26542
+ };
26543
+ _proto.syncItemLocationToControl = function syncItemLocationToControl() {
26544
+ if (!this.syncingLocation && this.controlNode) {
26545
+ this.syncingLocation = true;
26546
+ try {
26547
+ this.copyItemLocationToControl();
26548
+ } finally{
26549
+ this.syncingLocation = false;
26550
+ }
26551
+ }
26552
+ };
26553
+ _proto.syncControlLocationToItem = function syncControlLocationToItem() {
26554
+ var control = this.controlNode;
26555
+ if (!this.syncingLocation && control) {
26556
+ var source = control.location;
26557
+ var target = this.item.transform.position;
26558
+ if (source.x !== target.x || source.y !== target.y) {
26559
+ this.syncingLocation = true;
26560
+ try {
26561
+ this.item.transform.setPosition(source.x, source.y, target.z);
26562
+ } finally{
26563
+ this.syncingLocation = false;
26564
+ }
26565
+ }
26566
+ }
26567
+ };
26568
+ _proto.copyItemLocationToControl = function copyItemLocationToControl() {
26569
+ var control = this.controlNode;
26570
+ if (control) {
26571
+ var source = this.item.transform.position;
26572
+ var target = control.location;
26573
+ if (source.x !== target.x || source.y !== target.y) {
26574
+ control.setPosition(source.x, source.y);
26575
+ }
26576
+ }
26577
+ };
26578
+ _create_class(UIControl, [
26579
+ {
26580
+ key: "control",
26581
+ get: function get() {
26582
+ return this.controlNode;
26583
+ },
26584
+ set: function set(value) {
26585
+ if (value === this.controlNode) {
26586
+ return;
26587
+ }
26588
+ this.disposeControl();
26589
+ if (value) {
26590
+ if (value.owner && value.owner !== this && value.owner.control === value) {
26591
+ throw new Error("A Control can only be owned by one UIControl.");
26592
+ }
26593
+ this.controlNode = value;
26594
+ value.owner = this;
26595
+ this.syncControl();
26596
+ }
26597
+ }
26598
+ },
26599
+ {
26600
+ key: "hasControl",
26601
+ get: function get() {
26602
+ return this.controlNode !== null;
26603
+ }
26604
+ }
26605
+ ]);
26606
+ return UIControl;
26607
+ }(Component);
25322
26608
 
25323
26609
  exports.CameraController = /*#__PURE__*/ function(Component) {
25324
26610
  _inherits(CameraController, Component);
@@ -25354,42 +26640,6 @@ exports.CameraController = __decorate([
25354
26640
  effectsClass(DataType.CameraController)
25355
26641
  ], exports.CameraController);
25356
26642
 
25357
- function _get_prototype_of(o) {
25358
- _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
25359
- return o.__proto__ || Object.getPrototypeOf(o);
25360
- };
25361
- return _get_prototype_of(o);
25362
- }
25363
-
25364
- function _is_native_function(fn) {
25365
- return Function.toString.call(fn).indexOf("[native code]") !== -1;
25366
- }
25367
-
25368
- function _wrap_native_super(Class) {
25369
- var _cache = typeof Map === "function" ? new Map() : undefined;
25370
- _wrap_native_super = function _wrap_native_super(Class) {
25371
- if (Class === null || !_is_native_function(Class)) return Class;
25372
- if (typeof Class !== "function") throw new TypeError("Super expression must either be null or a function");
25373
- if (typeof _cache !== "undefined") {
25374
- if (_cache.has(Class)) return _cache.get(Class);
25375
- _cache.set(Class, Wrapper);
25376
- }
25377
- function Wrapper() {
25378
- return _construct(Class, arguments, _get_prototype_of(this).constructor);
25379
- }
25380
- Wrapper.prototype = Object.create(Class.prototype, {
25381
- constructor: {
25382
- value: Wrapper,
25383
- enumerable: false,
25384
- writable: true,
25385
- configurable: true
25386
- }
25387
- });
25388
- return _set_prototype_of(Wrapper, Class);
25389
- };
25390
- return _wrap_native_super(Class);
25391
- }
25392
-
25393
26643
  var CameraVFXItemLoader = /*#__PURE__*/ function(Plugin) {
25394
26644
  _inherits(CameraVFXItemLoader, Plugin);
25395
26645
  function CameraVFXItemLoader() {
@@ -25410,142 +26660,202 @@ exports.PointerEventType = void 0;
25410
26660
  })(exports.PointerEventType || (exports.PointerEventType = {}));
25411
26661
  var EventSystem = /*#__PURE__*/ function() {
25412
26662
  function EventSystem(engine, allowPropagation) {
26663
+ var _this = this;
25413
26664
  if (allowPropagation === void 0) allowPropagation = false;
25414
26665
  this.engine = engine;
25415
26666
  this.allowPropagation = allowPropagation;
25416
- this.enabled = true;
25417
26667
  this.skipPointerMovePicking = true;
26668
+ this.emulateMouseFromTouch = true;
26669
+ this.emulateTouchFromMouse = false;
26670
+ this._enabled = true;
25418
26671
  this.handlers = {};
25419
- this.nativeHandlers = {};
26672
+ this.nativeHandlers = [];
25420
26673
  this.target = null;
25421
- }
25422
- var _proto = EventSystem.prototype;
25423
- _proto.bindListeners = function bindListeners(target) {
25424
- var _this = this;
25425
- this.target = target;
25426
- var x;
25427
- var y;
25428
- var currentTouch;
25429
- var lastTouch;
25430
- var getTouch;
25431
- getTouch = function(event) {
25432
- return event;
26674
+ this.mouseState = null;
26675
+ this.touchStates = new Map();
26676
+ this.mouseFromTouchIndex = null;
26677
+ this.touchFromMousePressed = false;
26678
+ this.addedTabIndex = false;
26679
+ this.addedOutlineStyle = false;
26680
+ this.onNativeWheel = function(event) {
26681
+ if (!_this.enabled || !_this.target) {
26682
+ return;
26683
+ }
26684
+ var position = _this.getCanvasPosition(event.clientX, event.clientY);
26685
+ var handled = false;
26686
+ if (event.deltaY !== 0) {
26687
+ handled = _this.pushWheelButton(event.deltaY < 0 ? exports.MouseButton.WheelUp : exports.MouseButton.WheelDown, Math.abs(event.deltaY), position, event) || handled;
26688
+ }
26689
+ if (event.deltaX !== 0) {
26690
+ handled = _this.pushWheelButton(event.deltaX < 0 ? exports.MouseButton.WheelLeft : exports.MouseButton.WheelRight, Math.abs(event.deltaX), position, event) || handled;
26691
+ }
26692
+ _this.consumeNativeEvent(event, handled);
25433
26693
  };
25434
- var touchstart = "mousedown";
25435
- var touchmove = "mousemove";
25436
- var touchend = "mouseup";
25437
- var touchcancel = "mouseleave";
25438
- var getTouchEventValue = function(event, x, y, dx, dy) {
25439
- if (dx === void 0) dx = 0;
25440
- if (dy === void 0) dy = 0;
25441
- var vx = 0;
25442
- var vy = 0;
25443
- var ts = performance.now();
25444
- if (!_this.target) {
25445
- logger.warn("Trigger TouchEvent after EventSystem is disposed.");
25446
- return {
25447
- x: x,
25448
- y: y,
25449
- vx: 0,
25450
- vy: vy,
25451
- dx: dx,
25452
- dy: dy,
25453
- ts: ts,
25454
- width: 0,
25455
- height: 0,
25456
- origin: event
25457
- };
26694
+ this.onNativeKeyDown = function(event) {
26695
+ _this.handleNativeKey(event, true);
26696
+ };
26697
+ this.onNativeKeyUp = function(event) {
26698
+ _this.handleNativeKey(event, false);
26699
+ };
26700
+ this.onNativeMouseDown = function(event) {
26701
+ _this.handleNativeMouseDown(event);
26702
+ };
26703
+ this.onNativeMouseMove = function(event) {
26704
+ var _state;
26705
+ if (!_this.enabled || !_this.target) {
26706
+ return;
25458
26707
  }
25459
- var _this_target = _this.target, width = _this_target.width, height = _this_target.height;
25460
- if (lastTouch) {
25461
- var dt = ts - lastTouch.ts;
25462
- vx = (dx - lastTouch.dx) / dt || 0;
25463
- vy = (dy - lastTouch.dy) / dt || 0;
25464
- lastTouch = {
25465
- dx: dx,
25466
- dy: dy,
25467
- ts: ts
25468
- };
26708
+ var position = _this.getCanvasPosition(event.clientX, event.clientY);
26709
+ var _this_mouseState;
26710
+ var state = (_this_mouseState = _this.mouseState) != null ? _this_mouseState : _this.createPointerState(position);
26711
+ _this.mouseState = state;
26712
+ var relative = new Vector2(position.x - state.last.x, position.y - state.last.y);
26713
+ var velocity = _this.getVelocity(state, position);
26714
+ var handled = _this.pushNativeMouseMotion(event, position, relative, velocity);
26715
+ (_state = state).controlHandled || (_state.controlHandled = handled);
26716
+ if (!handled && (!state.pressed || !state.controlHandled)) {
26717
+ var pointerEvent = _this.createPointerEvent(event, position, state, velocity);
26718
+ _this.dispatchEvent(EVENT_TYPE_TOUCH_MOVE, pointerEvent);
26719
+ }
26720
+ _this.updatePointerState(state, position);
26721
+ _this.consumeNativeEvent(event, handled);
26722
+ };
26723
+ this.onNativeMouseUp = function(event) {
26724
+ if (!_this.enabled || !_this.target) {
26725
+ return;
25469
26726
  }
25470
- return {
25471
- x: x,
25472
- y: y,
25473
- vx: vx,
25474
- vy: vy,
25475
- dx: dx,
25476
- dy: dy,
25477
- ts: ts,
25478
- width: width,
25479
- height: height,
25480
- origin: event
25481
- };
26727
+ var position = _this.getCanvasPosition(event.clientX, event.clientY);
26728
+ var existingState = _this.mouseState;
26729
+ if (!(existingState == null ? void 0 : existingState.pressed)) {
26730
+ return;
26731
+ }
26732
+ var state = existingState;
26733
+ var handled = _this.pushNativeMouseButton(event, position, false);
26734
+ var pointerEvent = _this.createPointerEvent(event, position, state);
26735
+ if (!state.controlHandled && !handled && _this.isClick(state, position)) {
26736
+ _this.dispatchEvent(EVENT_TYPE_CLICK, pointerEvent);
26737
+ }
26738
+ if (!handled && !state.controlHandled) {
26739
+ _this.dispatchEvent(EVENT_TYPE_TOUCH_END, pointerEvent);
26740
+ }
26741
+ _this.mouseState = null;
26742
+ _this.consumeNativeEvent(event, handled || state.controlHandled || !_this.allowPropagation);
25482
26743
  };
25483
- if (isSimulatorCellPhone()) {
25484
- getTouch = function(event) {
25485
- var touches = event.touches, changedTouches = event.changedTouches;
25486
- return touches[0] || changedTouches[0];
25487
- };
25488
- touchstart = "touchstart";
25489
- touchmove = "touchmove";
25490
- touchend = "touchend";
25491
- touchcancel = "touchcancel";
25492
- }
25493
- var _obj;
25494
- this.nativeHandlers = (_obj = {}, _obj[touchstart] = function(event) {
25495
- if (_this.enabled) {
25496
- var touch = getTouch(event);
25497
- var cood = getCoord(touch);
25498
- x = cood.x;
25499
- y = cood.y;
25500
- lastTouch = currentTouch = {
25501
- clientX: touch.clientX,
25502
- clientY: touch.clientY,
25503
- ts: performance.now(),
25504
- x: x,
25505
- y: y
25506
- };
25507
- _this.dispatchEvent(EVENT_TYPE_TOUCH_START, getTouchEventValue(event, x, y));
25508
- }
25509
- }, _obj[touchmove] = function(event) {
25510
- if (currentTouch && _this.enabled) {
25511
- var cood = getCoord(getTouch(event));
25512
- x = cood.x;
25513
- y = cood.y;
25514
- _this.dispatchEvent(EVENT_TYPE_TOUCH_MOVE, getTouchEventValue(event, x, y, x - currentTouch.x, y - currentTouch.y));
25515
- }
25516
- }, _obj[touchend] = function(event) {
25517
- if (currentTouch && _this.enabled) {
25518
- if (!_this.allowPropagation && event.cancelable) {
25519
- event.preventDefault();
25520
- event.stopPropagation();
26744
+ this.onNativeTouchStart = function(event) {
26745
+ if (!_this.enabled) {
26746
+ return;
26747
+ }
26748
+ _this.focusTarget();
26749
+ for(var _iterator = _create_for_of_iterator_helper_loose(Array.from(event.changedTouches)), _step; !(_step = _iterator()).done;){
26750
+ var touch = _step.value;
26751
+ var position = _this.getCanvasPosition(touch.clientX, touch.clientY);
26752
+ var state = _this.createPointerState(position);
26753
+ _this.touchStates.set(touch.identifier, state);
26754
+ state.pressed = true;
26755
+ var handled = _this.pushNativeScreenTouch(touch.identifier, position, true, false, false);
26756
+ state.controlHandled = handled;
26757
+ if (!handled) {
26758
+ var pointerEvent = _this.createPointerEvent(event, position, state);
26759
+ _this.dispatchEvent(EVENT_TYPE_TOUCH_START, pointerEvent);
25521
26760
  }
25522
- var touch = getTouch(event);
25523
- var cood = getCoord(touch);
25524
- var dt = Math.abs(currentTouch.clientX - touch.clientX) + Math.abs(currentTouch.clientY - touch.clientY);
25525
- x = cood.x;
25526
- y = cood.y;
25527
- if (dt < 4) {
25528
- _this.dispatchEvent(EVENT_TYPE_CLICK, getTouchEventValue(event, x, y));
26761
+ _this.consumeNativeEvent(event, handled);
26762
+ }
26763
+ _this.preventTouchDefaults(event);
26764
+ };
26765
+ this.onNativeTouchMove = function(event) {
26766
+ if (!_this.enabled) {
26767
+ return;
26768
+ }
26769
+ for(var _iterator = _create_for_of_iterator_helper_loose(Array.from(event.changedTouches)), _step; !(_step = _iterator()).done;){
26770
+ var touch = _step.value;
26771
+ var _state;
26772
+ var position = _this.getCanvasPosition(touch.clientX, touch.clientY);
26773
+ var _this_touchStates_get;
26774
+ var state = (_this_touchStates_get = _this.touchStates.get(touch.identifier)) != null ? _this_touchStates_get : _this.createPointerState(position);
26775
+ _this.touchStates.set(touch.identifier, state);
26776
+ var relative = new Vector2(position.x - state.last.x, position.y - state.last.y);
26777
+ var velocity = _this.getVelocity(state, position);
26778
+ var handled = _this.pushNativeScreenDrag(touch.identifier, position, relative, velocity);
26779
+ (_state = state).controlHandled || (_state.controlHandled = handled);
26780
+ if (!handled && !state.controlHandled) {
26781
+ var pointerEvent = _this.createPointerEvent(event, position, state, velocity);
26782
+ _this.dispatchEvent(EVENT_TYPE_TOUCH_MOVE, pointerEvent);
25529
26783
  }
25530
- _this.dispatchEvent(EVENT_TYPE_TOUCH_END, getTouchEventValue(event, x, y, x - currentTouch.x, y - currentTouch.y));
25531
- }
25532
- currentTouch = 0;
25533
- }, _obj);
25534
- this.nativeHandlers[touchcancel] = this.nativeHandlers[touchend];
25535
- Object.keys(this.nativeHandlers).forEach(function(name) {
25536
- var _this_target;
25537
- (_this_target = _this.target) == null ? void 0 : _this_target.addEventListener(String(name), _this.nativeHandlers[name]);
26784
+ _this.updatePointerState(state, position);
26785
+ _this.consumeNativeEvent(event, handled);
26786
+ }
26787
+ _this.preventTouchDefaults(event);
26788
+ };
26789
+ this.onNativeTouchEnd = function(event) {
26790
+ _this.handleNativeTouchEnd(event, false);
26791
+ };
26792
+ this.onNativeTouchCancel = function(event) {
26793
+ _this.handleNativeTouchEnd(event, true);
26794
+ };
26795
+ this.onWindowBlur = function() {
26796
+ if (_this.enabled) {
26797
+ _this.mouseState = null;
26798
+ _this.touchStates.clear();
26799
+ _this.mouseFromTouchIndex = null;
26800
+ _this.touchFromMousePressed = false;
26801
+ _this.engine.windowRoot.cancelPointerInput();
26802
+ }
26803
+ };
26804
+ }
26805
+ var _proto = EventSystem.prototype;
26806
+ _proto.bindListeners = function bindListeners(target) {
26807
+ this.unbindListeners();
26808
+ this.target = target;
26809
+ if (!target || typeof window === "undefined") {
26810
+ return;
26811
+ }
26812
+ if (!target.hasAttribute("tabindex")) {
26813
+ target.tabIndex = 0;
26814
+ this.addedTabIndex = true;
26815
+ }
26816
+ if (!target.style.outline) {
26817
+ target.style.outline = "none";
26818
+ this.addedOutlineStyle = true;
26819
+ }
26820
+ this.addNativeHandler(target, "mousedown", this.onNativeMouseDown);
26821
+ // The Window listener runs after the event reaches the host container, so keep a
26822
+ // target listener to preserve notifyTouch/allowPropagation for in-canvas releases.
26823
+ this.addNativeHandler(target, "mouseup", this.onNativeMouseUp);
26824
+ this.addNativeHandler(window, "mouseup", this.onNativeMouseUp);
26825
+ this.addNativeHandler(window, "pointermove", this.onNativeMouseMove);
26826
+ this.addNativeHandler(target, "touchstart", this.onNativeTouchStart, {
26827
+ passive: false
26828
+ });
26829
+ this.addNativeHandler(target, "touchmove", this.onNativeTouchMove, {
26830
+ passive: false
26831
+ });
26832
+ this.addNativeHandler(target, "touchend", this.onNativeTouchEnd, {
26833
+ passive: false
26834
+ });
26835
+ this.addNativeHandler(target, "touchcancel", this.onNativeTouchCancel, {
26836
+ passive: false
25538
26837
  });
25539
- this.addEventListener(EVENT_TYPE_CLICK, this.onClick.bind(this));
25540
- this.addEventListener(EVENT_TYPE_TOUCH_START, this.onPointerDown.bind(this));
25541
- this.addEventListener(EVENT_TYPE_TOUCH_END, this.onPointerUp.bind(this));
25542
- this.addEventListener(EVENT_TYPE_TOUCH_MOVE, this.onPointerMove.bind(this));
26838
+ this.addNativeHandler(target, "wheel", this.onNativeWheel, {
26839
+ passive: false
26840
+ });
26841
+ this.addNativeHandler(target, "keydown", this.onNativeKeyDown);
26842
+ this.addNativeHandler(target, "keyup", this.onNativeKeyUp);
26843
+ this.addNativeHandler(window, "blur", this.onWindowBlur);
25543
26844
  };
25544
26845
  _proto.dispatchEvent = function dispatchEvent(type, event) {
25545
26846
  var handlers = this.handlers[type];
25546
- handlers == null ? void 0 : handlers.forEach(function(fn) {
26847
+ handlers == null ? void 0 : handlers.slice().forEach(function(fn) {
25547
26848
  return fn(event);
25548
26849
  });
26850
+ if (type === EVENT_TYPE_CLICK) {
26851
+ this.onClick(event);
26852
+ } else if (type === EVENT_TYPE_TOUCH_START) {
26853
+ this.onPointerDown(event);
26854
+ } else if (type === EVENT_TYPE_TOUCH_END) {
26855
+ this.onPointerUp(event);
26856
+ } else if (type === EVENT_TYPE_TOUCH_MOVE) {
26857
+ this.onPointerMove(event);
26858
+ }
25549
26859
  };
25550
26860
  _proto.addEventListener = function addEventListener(type, callback) {
25551
26861
  var handlers = this.handlers[type];
@@ -25563,14 +26873,229 @@ var EventSystem = /*#__PURE__*/ function() {
25563
26873
  removeItem(handlers, callback);
25564
26874
  }
25565
26875
  };
25566
- _proto.onClick = function onClick(e) {
25567
- var x = e.x, y = e.y;
26876
+ _proto.dispose = function dispose() {
26877
+ this.engine.windowRoot.cancelPointerInput();
26878
+ this.mouseState = null;
26879
+ this.touchStates.clear();
26880
+ this.mouseFromTouchIndex = null;
26881
+ this.touchFromMousePressed = false;
26882
+ this.handlers = {};
26883
+ this.unbindListeners();
26884
+ this.target = null;
26885
+ };
26886
+ _proto.handleNativeMouseDown = function handleNativeMouseDown(event) {
26887
+ if (!this.enabled || !this.target) {
26888
+ return;
26889
+ }
26890
+ var position = this.getCanvasPosition(event.clientX, event.clientY);
26891
+ this.focusTarget();
26892
+ var state = this.createPointerState(position);
26893
+ this.mouseState = state;
26894
+ state.pressed = true;
26895
+ var handled = this.pushNativeMouseButton(event, position, true);
26896
+ state.controlHandled = handled;
26897
+ if (!handled) {
26898
+ var pointerEvent = this.createPointerEvent(event, position, state);
26899
+ this.dispatchEvent(EVENT_TYPE_TOUCH_START, pointerEvent);
26900
+ }
26901
+ this.consumeNativeEvent(event, handled);
26902
+ };
26903
+ _proto.handleNativeKey = function handleNativeKey(event, pressed) {
26904
+ if (!this.enabled) {
26905
+ return;
26906
+ }
26907
+ var input = new InputEventKey();
26908
+ input.device = InputEvent.deviceIdKeyboard;
26909
+ input.pressed = pressed;
26910
+ input.echo = pressed && event.repeat;
26911
+ input.keycode = event.key;
26912
+ input.physicalKeycode = event.code;
26913
+ input.keyLabel = event.key;
26914
+ input.unicode = getUnicode(event.key);
26915
+ input.location = getKeyLocation(event.location);
26916
+ input.shiftPressed = event.shiftKey;
26917
+ input.altPressed = event.altKey;
26918
+ input.metaPressed = event.metaKey;
26919
+ input.ctrlPressed = event.ctrlKey;
26920
+ this.engine.windowRoot.pushInput(input);
26921
+ this.consumeNativeEvent(event, this.engine.windowRoot.isInputHandled());
26922
+ };
26923
+ _proto.handleNativeTouchEnd = function handleNativeTouchEnd(event, canceled) {
26924
+ if (!this.enabled) {
26925
+ return;
26926
+ }
26927
+ for(var _iterator = _create_for_of_iterator_helper_loose(Array.from(event.changedTouches)), _step; !(_step = _iterator()).done;){
26928
+ var touch = _step.value;
26929
+ var position = this.getCanvasPosition(touch.clientX, touch.clientY);
26930
+ var state = this.touchStates.get(touch.identifier);
26931
+ if (!(state == null ? void 0 : state.pressed)) {
26932
+ continue;
26933
+ }
26934
+ var handled = this.pushNativeScreenTouch(touch.identifier, position, false, canceled, false);
26935
+ var pointerEvent = this.createPointerEvent(event, position, state);
26936
+ if (!canceled && !state.controlHandled && !handled && this.isClick(state, position)) {
26937
+ this.dispatchEvent(EVENT_TYPE_CLICK, pointerEvent);
26938
+ }
26939
+ if (!handled && !canceled && !state.controlHandled) {
26940
+ this.dispatchEvent(EVENT_TYPE_TOUCH_END, pointerEvent);
26941
+ }
26942
+ this.touchStates.delete(touch.identifier);
26943
+ this.consumeNativeEvent(event, handled || state.controlHandled || !this.allowPropagation);
26944
+ }
26945
+ this.preventTouchDefaults(event);
26946
+ };
26947
+ _proto.pushNativeMouseButton = function pushNativeMouseButton(event, position, pressed) {
26948
+ var handled = false;
26949
+ var button = getMouseButton(event.button);
26950
+ if (pressed && this.emulateTouchFromMouse && button === exports.MouseButton.Left) {
26951
+ this.touchFromMousePressed = true;
26952
+ }
26953
+ if (this.touchFromMousePressed && button === exports.MouseButton.Left) {
26954
+ handled = this.pushScreenTouch(0, position, pressed, false, event.detail > 1, InputEvent.deviceIdEmulation);
26955
+ if (!pressed) {
26956
+ this.touchFromMousePressed = false;
26957
+ }
26958
+ }
26959
+ return this.pushMouseButton(event, position, pressed) || handled;
26960
+ };
26961
+ _proto.pushNativeMouseMotion = function pushNativeMouseMotion(event, position, relative, velocity) {
26962
+ var handled = false;
26963
+ if (this.touchFromMousePressed && (event.buttons & 1) !== 0) {
26964
+ handled = this.pushScreenDrag(0, position, relative, velocity, InputEvent.deviceIdEmulation);
26965
+ }
26966
+ return this.pushMouseMotion(event, position, relative, velocity) || handled;
26967
+ };
26968
+ _proto.pushNativeScreenTouch = function pushNativeScreenTouch(index, position, pressed, canceled, doubleTap) {
26969
+ var handled = false;
26970
+ var emulateMouse = false;
26971
+ if (pressed && this.emulateMouseFromTouch && this.mouseFromTouchIndex === null) {
26972
+ this.mouseFromTouchIndex = index;
26973
+ emulateMouse = true;
26974
+ } else if (!pressed && this.mouseFromTouchIndex === index) {
26975
+ emulateMouse = true;
26976
+ this.mouseFromTouchIndex = null;
26977
+ }
26978
+ if (emulateMouse) {
26979
+ handled = this.pushEmulatedMouseButton(position, pressed, canceled, doubleTap);
26980
+ }
26981
+ return this.pushScreenTouch(index, position, pressed, canceled, doubleTap, 0) || handled;
26982
+ };
26983
+ _proto.pushNativeScreenDrag = function pushNativeScreenDrag(index, position, relative, velocity) {
26984
+ var handled = false;
26985
+ if (this.emulateMouseFromTouch && this.mouseFromTouchIndex === index) {
26986
+ handled = this.pushEmulatedMouseMotion(position, relative, velocity);
26987
+ }
26988
+ return this.pushScreenDrag(index, position, relative, velocity, 0) || handled;
26989
+ };
26990
+ _proto.pushEmulatedMouseButton = function pushEmulatedMouseButton(position, pressed, canceled, doubleClick) {
26991
+ var input = new InputEventMouseButton();
26992
+ input.device = InputEvent.deviceIdEmulation;
26993
+ input.position.copyFrom(position);
26994
+ input.globalPosition.copyFrom(position);
26995
+ input.buttonIndex = exports.MouseButton.Left;
26996
+ input.buttonMask = pressed ? exports.MouseButtonMask.Left : exports.MouseButtonMask.None;
26997
+ input.pressed = pressed;
26998
+ input.canceled = canceled;
26999
+ input.doubleClick = doubleClick;
27000
+ this.engine.windowRoot.pushInput(input);
27001
+ return this.engine.windowRoot.isInputHandled();
27002
+ };
27003
+ _proto.pushEmulatedMouseMotion = function pushEmulatedMouseMotion(position, relative, velocity) {
27004
+ var input = new InputEventMouseMotion();
27005
+ input.device = InputEvent.deviceIdEmulation;
27006
+ input.position.copyFrom(position);
27007
+ input.globalPosition.copyFrom(position);
27008
+ input.buttonMask = exports.MouseButtonMask.Left;
27009
+ input.pressed = true;
27010
+ input.relative.copyFrom(relative);
27011
+ input.screenRelative.copyFrom(relative);
27012
+ input.velocity.copyFrom(velocity);
27013
+ input.screenVelocity.copyFrom(velocity);
27014
+ this.engine.windowRoot.pushInput(input);
27015
+ return this.engine.windowRoot.isInputHandled();
27016
+ };
27017
+ _proto.pushMouseButton = function pushMouseButton(event, position, pressed) {
27018
+ var input = new InputEventMouseButton();
27019
+ this.copyMouseFields(input, event, position);
27020
+ input.device = InputEvent.deviceIdMouse;
27021
+ input.buttonIndex = getMouseButton(event.button);
27022
+ input.buttonMask = getMouseButtonMask(event.buttons);
27023
+ if (pressed) {
27024
+ input.buttonMask |= getMouseButtonBit(input.buttonIndex);
27025
+ } else {
27026
+ input.buttonMask &= ~getMouseButtonBit(input.buttonIndex);
27027
+ }
27028
+ input.pressed = pressed;
27029
+ input.doubleClick = event.detail > 1;
27030
+ this.engine.windowRoot.pushInput(input);
27031
+ return this.engine.windowRoot.isInputHandled();
27032
+ };
27033
+ _proto.pushWheelButton = function pushWheelButton(button, factor, position, event) {
27034
+ var input = new InputEventMouseButton();
27035
+ this.copyMouseFields(input, event, position);
27036
+ input.device = InputEvent.deviceIdMouse;
27037
+ input.buttonIndex = button;
27038
+ input.buttonMask = getMouseButtonMask(event.buttons);
27039
+ input.factor = factor;
27040
+ input.pressed = true;
27041
+ this.engine.windowRoot.pushInput(input);
27042
+ return this.engine.windowRoot.isInputHandled();
27043
+ };
27044
+ _proto.pushMouseMotion = function pushMouseMotion(event, position, relative, velocity) {
27045
+ var input = new InputEventMouseMotion();
27046
+ this.copyMouseFields(input, event, position);
27047
+ input.device = InputEvent.deviceIdMouse;
27048
+ input.buttonMask = getMouseButtonMask(event.buttons);
27049
+ input.pressed = event.buttons !== 0;
27050
+ input.relative.copyFrom(relative);
27051
+ input.screenRelative.copyFrom(relative);
27052
+ input.velocity.copyFrom(velocity);
27053
+ input.screenVelocity.copyFrom(velocity);
27054
+ if ("pressure" in event) {
27055
+ input.pressure = event.pressure;
27056
+ input.tilt.set(event.tiltX, event.tiltY);
27057
+ }
27058
+ this.engine.windowRoot.pushInput(input);
27059
+ return this.engine.windowRoot.isInputHandled();
27060
+ };
27061
+ _proto.pushScreenTouch = function pushScreenTouch(index, position, pressed, canceled, doubleTap, device) {
27062
+ var input = new InputEventScreenTouch();
27063
+ input.index = index;
27064
+ input.device = device;
27065
+ input.position.copyFrom(position);
27066
+ input.pressed = pressed;
27067
+ input.canceled = canceled;
27068
+ input.doubleTap = doubleTap;
27069
+ this.engine.windowRoot.pushInput(input);
27070
+ return this.engine.windowRoot.isInputHandled();
27071
+ };
27072
+ _proto.pushScreenDrag = function pushScreenDrag(index, position, relative, velocity, device) {
27073
+ var input = new InputEventScreenDrag();
27074
+ input.index = index;
27075
+ input.device = device;
27076
+ input.position.copyFrom(position);
27077
+ input.relative.copyFrom(relative);
27078
+ input.screenRelative.copyFrom(relative);
27079
+ input.velocity.copyFrom(velocity);
27080
+ input.screenVelocity.copyFrom(velocity);
27081
+ input.pressed = true;
27082
+ this.engine.windowRoot.pushInput(input);
27083
+ return this.engine.windowRoot.isInputHandled();
27084
+ };
27085
+ _proto.copyMouseFields = function copyMouseFields(input, event, position) {
27086
+ input.position.copyFrom(position);
27087
+ input.globalPosition.copyFrom(position);
27088
+ input.shiftPressed = event.shiftKey;
27089
+ input.altPressed = event.altKey;
27090
+ input.metaPressed = event.metaKey;
27091
+ input.ctrlPressed = event.ctrlKey;
27092
+ };
27093
+ _proto.onClick = function onClick(event) {
25568
27094
  var hitResults = [];
25569
- // 收集所有的点击测试结果,click 回调执行可能会对 composition 点击结果有影响,放在点击测试执行完后再统一触发。
25570
27095
  for(var _iterator = _create_for_of_iterator_helper_loose(this.engine.compositions), _step; !(_step = _iterator()).done;){
25571
27096
  var composition = _step.value;
25572
27097
  var _hitResults;
25573
- (_hitResults = hitResults).push.apply(_hitResults, [].concat(composition.hitTest(x, y)));
27098
+ (_hitResults = hitResults).push.apply(_hitResults, [].concat(composition.hitTest(event.x, event.y)));
25574
27099
  }
25575
27100
  for(var _iterator1 = _create_for_of_iterator_helper_loose(hitResults), _step1; !(_step1 = _iterator1()).done;){
25576
27101
  var hitResult = _step1.value;
@@ -25587,49 +27112,36 @@ var EventSystem = /*#__PURE__*/ function() {
25587
27112
  this.engine.emit("click", clickInfo);
25588
27113
  }
25589
27114
  };
25590
- _proto.onPointerDown = function onPointerDown(e) {
25591
- this.handlePointerEvent(e, 0);
27115
+ _proto.onPointerDown = function onPointerDown(event) {
27116
+ this.handlePointerEvent(event, 0);
25592
27117
  };
25593
- _proto.onPointerUp = function onPointerUp(e) {
25594
- this.handlePointerEvent(e, 1);
27118
+ _proto.onPointerUp = function onPointerUp(event) {
27119
+ this.handlePointerEvent(event, 1);
25595
27120
  };
25596
- _proto.onPointerMove = function onPointerMove(e) {
25597
- this.handlePointerEvent(e, 2);
27121
+ _proto.onPointerMove = function onPointerMove(event) {
27122
+ this.handlePointerEvent(event, 2);
25598
27123
  };
25599
- _proto.handlePointerEvent = function handlePointerEvent(e, type) {
27124
+ _proto.handlePointerEvent = function handlePointerEvent(event, type) {
25600
27125
  var hitRegion = null;
25601
- var x = e.x, y = e.y, width = e.width, height = e.height;
25602
27126
  if (!(type === 2 && this.skipPointerMovePicking)) {
25603
27127
  for(var _iterator = _create_for_of_iterator_helper_loose(this.engine.compositions), _step; !(_step = _iterator()).done;){
25604
27128
  var composition = _step.value;
25605
- var regions = composition.hitTest(x, y);
27129
+ var regions = composition.hitTest(event.x, event.y);
25606
27130
  if (regions.length > 0) {
25607
27131
  hitRegion = regions[regions.length - 1];
25608
27132
  }
25609
27133
  }
25610
27134
  }
25611
27135
  var eventData = new PointerEventData();
25612
- eventData.position.x = (x + 1) / 2 * width;
25613
- eventData.position.y = (y + 1) / 2 * height;
25614
- eventData.delta.x = e.vx * width;
25615
- eventData.delta.y = e.vy * height;
25616
- var raycast = eventData.pointerCurrentRaycast;
27136
+ eventData.position.x = (event.x + 1) / 2 * event.width;
27137
+ eventData.position.y = (event.y + 1) / 2 * event.height;
27138
+ eventData.delta.x = event.vx * event.width;
27139
+ eventData.delta.y = event.vy * event.height;
25617
27140
  if (hitRegion) {
25618
- raycast.point = hitRegion.position;
25619
- raycast.item = hitRegion.item;
25620
- }
25621
- var eventName = "pointerdown";
25622
- switch(type){
25623
- case 0:
25624
- eventName = "pointerdown";
25625
- break;
25626
- case 1:
25627
- eventName = "pointerup";
25628
- break;
25629
- case 2:
25630
- eventName = "pointermove";
25631
- break;
27141
+ eventData.pointerCurrentRaycast.point = hitRegion.position;
27142
+ eventData.pointerCurrentRaycast.item = hitRegion.item;
25632
27143
  }
27144
+ var eventName = type === 0 ? "pointerdown" : type === 1 ? "pointerup" : "pointermove";
25633
27145
  if (hitRegion) {
25634
27146
  var hitItem = hitRegion.item;
25635
27147
  var hitComposition = hitItem.composition;
@@ -25638,29 +27150,185 @@ var EventSystem = /*#__PURE__*/ function() {
25638
27150
  this.engine.emit(eventName, eventData);
25639
27151
  }
25640
27152
  };
25641
- _proto.dispose = function dispose() {
25642
- var _this = this;
25643
- if (this.target) {
25644
- this.handlers = {};
25645
- Object.keys(this.nativeHandlers).forEach(function(name) {
25646
- var _this_target;
25647
- (_this_target = _this.target) == null ? void 0 : _this_target.removeEventListener(String(name), _this.nativeHandlers[name]);
25648
- });
25649
- this.nativeHandlers = {};
27153
+ _proto.createPointerState = function createPointerState(position) {
27154
+ var state = {
27155
+ start: position.clone(),
27156
+ last: position.clone(),
27157
+ lastTime: performance.now(),
27158
+ controlHandled: false,
27159
+ pressed: false
27160
+ };
27161
+ return state;
27162
+ };
27163
+ _proto.updatePointerState = function updatePointerState(state, position) {
27164
+ state.last.copyFrom(position);
27165
+ state.lastTime = performance.now();
27166
+ };
27167
+ _proto.getVelocity = function getVelocity(state, position) {
27168
+ var elapsed = Math.max(performance.now() - state.lastTime, 1);
27169
+ return new Vector2((position.x - state.last.x) / elapsed, (position.y - state.last.y) / elapsed);
27170
+ };
27171
+ _proto.isClick = function isClick(state, position) {
27172
+ return Math.abs(position.x - state.start.x) + Math.abs(position.y - state.start.y) < 4;
27173
+ };
27174
+ _proto.createPointerEvent = function createPointerEvent(origin, position, state, velocity) {
27175
+ if (velocity === void 0) velocity = new Vector2();
27176
+ var target = this.target;
27177
+ var rect = target == null ? void 0 : target.getBoundingClientRect();
27178
+ var cssWidth = (rect == null ? void 0 : rect.width) || 1;
27179
+ var cssHeight = (rect == null ? void 0 : rect.height) || 1;
27180
+ var _target_width, _target_height;
27181
+ return {
27182
+ x: position.x / cssWidth * 2 - 1,
27183
+ // Legacy composition picking uses bottom-left, Y-up NDC even though GUI
27184
+ // input follows the DOM convention of top-left, Y-down pixels.
27185
+ y: 1 - position.y / cssHeight * 2,
27186
+ vx: velocity.x / cssWidth * 2,
27187
+ vy: -velocity.y / cssHeight * 2,
27188
+ ts: performance.now(),
27189
+ dx: (position.x - state.start.x) / cssWidth * 2,
27190
+ dy: -(position.y - state.start.y) / cssHeight * 2,
27191
+ width: (_target_width = target == null ? void 0 : target.width) != null ? _target_width : 0,
27192
+ height: (_target_height = target == null ? void 0 : target.height) != null ? _target_height : 0,
27193
+ origin: origin
27194
+ };
27195
+ };
27196
+ _proto.getCanvasPosition = function getCanvasPosition(clientX, clientY) {
27197
+ var _this_target;
27198
+ var rect = (_this_target = this.target) == null ? void 0 : _this_target.getBoundingClientRect();
27199
+ if (!rect) {
27200
+ return new Vector2();
27201
+ }
27202
+ return new Vector2(clientX - rect.left, clientY - rect.top);
27203
+ };
27204
+ _proto.consumeNativeEvent = function consumeNativeEvent(event, handled) {
27205
+ if (handled && !this.allowPropagation) {
27206
+ if (event.cancelable) {
27207
+ event.preventDefault();
27208
+ }
27209
+ event.stopPropagation();
27210
+ }
27211
+ };
27212
+ _proto.preventTouchDefaults = function preventTouchDefaults(event) {
27213
+ if (event.cancelable) {
27214
+ event.preventDefault();
27215
+ }
27216
+ };
27217
+ _proto.focusTarget = function focusTarget() {
27218
+ var _this_target;
27219
+ (_this_target = this.target) == null ? void 0 : _this_target.focus();
27220
+ };
27221
+ _proto.addNativeHandler = function addNativeHandler(target, name, handler, options) {
27222
+ target.addEventListener(name, handler, options);
27223
+ this.nativeHandlers.push({
27224
+ target: target,
27225
+ name: name,
27226
+ handler: handler,
27227
+ options: options
27228
+ });
27229
+ };
27230
+ _proto.unbindListeners = function unbindListeners() {
27231
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.nativeHandlers), _step; !(_step = _iterator()).done;){
27232
+ var nativeHandler = _step.value;
27233
+ nativeHandler.target.removeEventListener(nativeHandler.name, nativeHandler.handler, nativeHandler.options);
27234
+ }
27235
+ this.nativeHandlers = [];
27236
+ if (this.addedTabIndex && this.target) {
27237
+ this.target.removeAttribute("tabindex");
25650
27238
  }
27239
+ if (this.addedOutlineStyle && this.target) {
27240
+ this.target.style.removeProperty("outline");
27241
+ }
27242
+ this.addedTabIndex = false;
27243
+ this.addedOutlineStyle = false;
25651
27244
  };
27245
+ _create_class(EventSystem, [
27246
+ {
27247
+ key: "enabled",
27248
+ get: function get() {
27249
+ return this._enabled;
27250
+ },
27251
+ set: function set(value) {
27252
+ if (this._enabled === value) {
27253
+ return;
27254
+ }
27255
+ this._enabled = value;
27256
+ if (!value) {
27257
+ this.mouseState = null;
27258
+ this.touchStates.clear();
27259
+ this.mouseFromTouchIndex = null;
27260
+ this.touchFromMousePressed = false;
27261
+ this.engine.windowRoot.cancelPointerInput();
27262
+ }
27263
+ }
27264
+ }
27265
+ ]);
25652
27266
  return EventSystem;
25653
27267
  }();
25654
- function getCoord(event) {
25655
- var ele = event.target;
25656
- var clientX = event.clientX, clientY = event.clientY;
25657
- var _ele_getBoundingClientRect = ele.getBoundingClientRect(), left = _ele_getBoundingClientRect.left, top = _ele_getBoundingClientRect.top, width = _ele_getBoundingClientRect.width, height = _ele_getBoundingClientRect.height;
25658
- var x = (clientX - left) / width * 2 - 1;
25659
- var y = 1 - (clientY - top) / height * 2;
25660
- return {
25661
- x: x,
25662
- y: y
25663
- };
27268
+ function getKeyLocation(location) {
27269
+ if (location === 1) {
27270
+ return exports.KeyLocation.Left;
27271
+ }
27272
+ if (location === 2) {
27273
+ return exports.KeyLocation.Right;
27274
+ }
27275
+ return exports.KeyLocation.Unspecified;
27276
+ }
27277
+ function getUnicode(key) {
27278
+ var characters = Array.from(key);
27279
+ var _characters__codePointAt;
27280
+ return characters.length === 1 ? (_characters__codePointAt = characters[0].codePointAt(0)) != null ? _characters__codePointAt : 0 : 0;
27281
+ }
27282
+ function getMouseButton(button) {
27283
+ switch(button){
27284
+ case 0:
27285
+ return exports.MouseButton.Left;
27286
+ case 1:
27287
+ return exports.MouseButton.Middle;
27288
+ case 2:
27289
+ return exports.MouseButton.Right;
27290
+ case 3:
27291
+ return exports.MouseButton.Xbutton1;
27292
+ case 4:
27293
+ return exports.MouseButton.Xbutton2;
27294
+ default:
27295
+ return exports.MouseButton.None;
27296
+ }
27297
+ }
27298
+ function getMouseButtonMask(buttons) {
27299
+ var mask = exports.MouseButtonMask.None;
27300
+ if ((buttons & 1) !== 0) {
27301
+ mask |= exports.MouseButtonMask.Left;
27302
+ }
27303
+ if ((buttons & 2) !== 0) {
27304
+ mask |= exports.MouseButtonMask.Right;
27305
+ }
27306
+ if ((buttons & 4) !== 0) {
27307
+ mask |= exports.MouseButtonMask.Middle;
27308
+ }
27309
+ if ((buttons & 8) !== 0) {
27310
+ mask |= exports.MouseButtonMask.Xbutton1;
27311
+ }
27312
+ if ((buttons & 16) !== 0) {
27313
+ mask |= exports.MouseButtonMask.Xbutton2;
27314
+ }
27315
+ return mask;
27316
+ }
27317
+ function getMouseButtonBit(button) {
27318
+ switch(button){
27319
+ case exports.MouseButton.Left:
27320
+ return exports.MouseButtonMask.Left;
27321
+ case exports.MouseButton.Right:
27322
+ return exports.MouseButtonMask.Right;
27323
+ case exports.MouseButton.Middle:
27324
+ return exports.MouseButtonMask.Middle;
27325
+ case exports.MouseButton.Xbutton1:
27326
+ return exports.MouseButtonMask.Xbutton1;
27327
+ case exports.MouseButton.Xbutton2:
27328
+ return exports.MouseButtonMask.Xbutton2;
27329
+ default:
27330
+ return exports.MouseButtonMask.None;
27331
+ }
25664
27332
  }
25665
27333
 
25666
27334
  var InteractLoader = /*#__PURE__*/ function(Plugin) {
@@ -27681,11 +29349,6 @@ exports.SpritePropertyTrack = __decorate([
27681
29349
  effectsClass("SpritePropertyTrack")
27682
29350
  ], exports.SpritePropertyTrack);
27683
29351
 
27684
- function _assert_this_initialized(self) {
27685
- if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
27686
- return self;
27687
- }
27688
-
27689
29352
  var Cone = /*#__PURE__*/ function() {
27690
29353
  function Cone(props) {
27691
29354
  var _this = this;
@@ -37690,7 +39353,7 @@ function getStandardSpriteContent(sprite, transform) {
37690
39353
  return ret;
37691
39354
  }
37692
39355
 
37693
- var version$1 = "2.10.0-alpha.2";
39356
+ var version$1 = "2.10.0-alpha.4";
37694
39357
  var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
37695
39358
  var standardVersion = /^(\d+)\.(\d+)$/;
37696
39359
  var reverseParticle = false;
@@ -39642,10 +41305,11 @@ var PreRenderTickData = /*#__PURE__*/ function(TickData) {
39642
41305
  _this./**
39643
41306
  * 是否开启后处理
39644
41307
  */ postProcessingEnabled = false;
39645
- _this.canvasLayers = [];
39646
41308
  _this.destroyed = false;
39647
41309
  _this.paused = true;
39648
41310
  _this.isEndCalled = false;
41311
+ _this._renderOrder = 0;
41312
+ _this._interactive = true;
39649
41313
  _this._textures = [];
39650
41314
  var _ref = props != null ? props : {}, _ref_reusable = _ref.reusable, reusable = _ref_reusable === void 0 ? false : _ref_reusable, _ref_speed = _ref.speed, speed = _ref_speed === void 0 ? 1 : _ref_speed, _ref_baseRenderOrder = _ref.baseRenderOrder, baseRenderOrder = _ref_baseRenderOrder === void 0 ? 0 : _ref_baseRenderOrder, onItemMessage = _ref.onItemMessage;
39651
41315
  _this.engine.addComposition(_assert_this_initialized(_this));
@@ -39678,13 +41342,14 @@ var PreRenderTickData = /*#__PURE__*/ function(TickData) {
39678
41342
  _this.root = new exports.VFXItem(_this.engine);
39679
41343
  _this.root.name = "root";
39680
41344
  _this.root.composition = _assert_this_initialized(_this);
41345
+ _this.root.setParent(_this.engine.root);
39681
41346
  _this.pluginRoot = new exports.VFXItem(_this.engine);
39682
41347
  _this.pluginRoot.name = "pluginRoot";
39683
41348
  _this.pluginRoot.setParent(_this.root);
39684
- _this.pluginRoot.addComponent(CanvasLayer);
39685
41349
  // Instantiate composition rootItem
39686
41350
  _this.sceneRoot = new exports.VFXItem(_this.engine);
39687
41351
  _this.sceneRoot.setParent(_this.root);
41352
+ _this.uiCanvas = _this.sceneRoot.addComponent(UICanvas);
39688
41353
  if (sourceContent) {
39689
41354
  _this.sceneRoot.setInstanceId(sourceContent.id);
39690
41355
  _this.sceneRoot.instantiatePreComposition(sourceContent, false);
@@ -39883,9 +41548,13 @@ var PreRenderTickData = /*#__PURE__*/ function(TickData) {
39883
41548
  this.isEndCalled = false;
39884
41549
  this.rootComposition.setTime(0);
39885
41550
  };
39886
- _proto.render = function render() {
41551
+ /** Renders this Composition content. Screen-space UI is rendered by Engine. */ _proto.render = function render() {
41552
+ this.renderContent();
41553
+ };
41554
+ /**
41555
+ * Renders only the Composition scene content.
41556
+ */ _proto.renderContent = function renderContent() {
39887
41557
  this.renderer.renderRenderFrame(this.renderFrame);
39888
- this.renderCanvasLayers();
39889
41558
  };
39890
41559
  /**
39891
41560
  * 合成更新,针对所有 item 的更新
@@ -39974,17 +41643,6 @@ var PreRenderTickData = /*#__PURE__*/ function(TickData) {
39974
41643
  }
39975
41644
  }
39976
41645
  };
39977
- _proto.renderCanvasLayers = function renderCanvasLayers() {
39978
- this.engine.graphics.begin();
39979
- this.canvasLayers.sort(function(leftLayer, rightLayer) {
39980
- return leftLayer.layer - rightLayer.layer;
39981
- });
39982
- for(var _iterator = _create_for_of_iterator_helper_loose(this.canvasLayers), _step; !(_step = _iterator()).done;){
39983
- var canvasLayer = _step.value;
39984
- canvasLayer.draw();
39985
- }
39986
- this.engine.graphics.end();
39987
- };
39988
41646
  /**
39989
41647
  * @internal
39990
41648
  */ _proto.createTexturesFromData = function createTexturesFromData(textureDataList) {
@@ -40253,6 +41911,35 @@ var PreRenderTickData = /*#__PURE__*/ function(TickData) {
40253
41911
  })();
40254
41912
  };
40255
41913
  _create_class(Composition, [
41914
+ {
41915
+ key: "renderOrder",
41916
+ get: /**
41917
+ * 合成渲染顺序,默认按升序渲染
41918
+ */ function get() {
41919
+ return this._renderOrder;
41920
+ },
41921
+ set: function set(value) {
41922
+ this._renderOrder = value;
41923
+ if (this.uiCanvas) {
41924
+ this.uiCanvas.order = value;
41925
+ }
41926
+ }
41927
+ },
41928
+ {
41929
+ key: "interactive",
41930
+ get: /**
41931
+ * 合成内的元素否允许点击、拖拽交互
41932
+ * @since 1.6.0
41933
+ */ function get() {
41934
+ return this._interactive;
41935
+ },
41936
+ set: function set(value) {
41937
+ this._interactive = !!value;
41938
+ if (this.uiCanvas) {
41939
+ this.uiCanvas.receivesEvents = this._interactive;
41940
+ }
41941
+ }
41942
+ },
40256
41943
  {
40257
41944
  key: "width",
40258
41945
  get: /**
@@ -42030,7 +43717,6 @@ var DEFAULT_FPS = 60;
42030
43717
  /**
42031
43718
  * 渲染过程中错误队列
42032
43719
  */ _this.renderErrors = new Set();
42033
- _this.compositions = [];
42034
43720
  _this.assetManagers = [];
42035
43721
  _this.env = "";
42036
43722
  /**
@@ -42052,6 +43738,7 @@ var DEFAULT_FPS = 60;
42052
43738
  _this.framebuffers = [];
42053
43739
  _this.renderbuffers = [];
42054
43740
  _this.particleSystems = [];
43741
+ _this._compositions = [];
42055
43742
  _this.clearAction = {
42056
43743
  stencilAction: exports.TextureLoadAction.clear,
42057
43744
  clearStencil: 0,
@@ -42076,6 +43763,9 @@ var DEFAULT_FPS = 60;
42076
43763
  _this.pixelRatio = (_options_pixelRatio = options == null ? void 0 : options.pixelRatio) != null ? _options_pixelRatio : getPixelRatio();
42077
43764
  _this.jsonSceneData = {};
42078
43765
  _this.objectInstance = {};
43766
+ _this.root = new exports.VFXItem(_assert_this_initialized(_this));
43767
+ _this.root.name = "root";
43768
+ _this.windowRoot = new WindowRootControl(_assert_this_initialized(_this));
42079
43769
  _this.whiteTexture = generateWhiteTexture(_assert_this_initialized(_this));
42080
43770
  _this.transparentTexture = generateEmptyTexture(_assert_this_initialized(_this));
42081
43771
  if (!(options == null ? void 0 : options.manualRender)) {
@@ -42210,9 +43900,6 @@ var DEFAULT_FPS = 60;
42210
43900
  // Sort compositions by index
42211
43901
  //-------------------------------------------------------------------------
42212
43902
  var compositions = this.compositions;
42213
- compositions.sort(function(a, b) {
42214
- return a.getIndex() - b.getIndex();
42215
- });
42216
43903
  var skipRender = false;
42217
43904
  // Update Compositions
42218
43905
  //-------------------------------------------------------------------------
@@ -42231,6 +43918,7 @@ var DEFAULT_FPS = 60;
42231
43918
  (_this_ticker1 = this.ticker) == null ? void 0 : _this_ticker1.pause();
42232
43919
  return;
42233
43920
  }
43921
+ this.windowRoot.update(dt);
42234
43922
  // Tick compositions onPreRender
42235
43923
  //-------------------------------------------------------------------------
42236
43924
  for(var _iterator1 = _create_for_of_iterator_helper_loose(compositions), _step1; !(_step1 = _iterator1()).done;){
@@ -42243,8 +43931,9 @@ var DEFAULT_FPS = 60;
42243
43931
  this.renderer.clear(this.clearAction);
42244
43932
  for(var _iterator2 = _create_for_of_iterator_helper_loose(compositions), _step2; !(_step2 = _iterator2()).done;){
42245
43933
  var composition2 = _step2.value;
42246
- composition2.render();
43934
+ composition2.renderContent();
42247
43935
  }
43936
+ this.windowRoot.render();
42248
43937
  this.renderTargetPool.flush();
42249
43938
  };
42250
43939
  /**
@@ -42286,6 +43975,7 @@ var DEFAULT_FPS = 60;
42286
43975
  this.canvas.style.height = containerHeight + "px";
42287
43976
  logger.info("Resize engine " + this.name + " [" + canvasWidth + "," + canvasHeight + "," + containerWidth + "," + containerHeight + "].");
42288
43977
  this.setSize(canvasWidth, canvasHeight);
43978
+ this.windowRoot.resize(canvasWidth, canvasHeight);
42289
43979
  }
42290
43980
  };
42291
43981
  _proto.setSize = function setSize(width, height) {
@@ -42293,7 +43983,7 @@ var DEFAULT_FPS = 60;
42293
43983
  if (this.getWidth() !== width || this.getHeight() !== height) {
42294
43984
  this.canvas.width = width;
42295
43985
  this.canvas.height = height;
42296
- this.viewport(0, 0, width, height);
43986
+ this.setViewport(0, 0, width, height);
42297
43987
  }
42298
43988
  (_this_compositions = this.compositions) == null ? void 0 : _this_compositions.forEach(function(comp) {
42299
43989
  comp.camera.aspect = width / height;
@@ -42322,6 +44012,26 @@ var DEFAULT_FPS = 60;
42322
44012
  /** @hide */ _proto.bindBuffers = function bindBuffers(vertexBuffers, indexBuffer, effect) {
42323
44013
  throw new Error("The active rendering backend cannot bind geometry buffers.");
42324
44014
  };
44015
+ /**
44016
+ * 使用当前绑定的顶点和索引缓冲区绘制图元。
44017
+ * @param mode - 图元类型
44018
+ * @param indexOffset - 索引缓冲区中的字节偏移
44019
+ * @param indexCount - 索引数量
44020
+ * @param instanceCount - 实例数量
44021
+ * @hide
44022
+ */ _proto.drawElementsType = function drawElementsType(mode, indexOffset, indexCount, instanceCount) {
44023
+ throw new Error("The active rendering backend cannot draw indexed primitives.");
44024
+ };
44025
+ /**
44026
+ * 使用当前绑定的顶点缓冲区绘制图元。
44027
+ * @param mode - 图元类型
44028
+ * @param vertexStart - 起始顶点
44029
+ * @param vertexCount - 顶点数量
44030
+ * @param instanceCount - 实例数量
44031
+ * @hide
44032
+ */ _proto.drawArraysType = function drawArraysType(mode, vertexStart, vertexCount, instanceCount) {
44033
+ throw new Error("The active rendering backend cannot draw primitives.");
44034
+ };
42325
44035
  _proto.addTexture = function addTexture(tex) {
42326
44036
  if (this.disposed) {
42327
44037
  return;
@@ -42453,15 +44163,12 @@ var DEFAULT_FPS = 60;
42453
44163
  * @param height
42454
44164
  * example:
42455
44165
  * gl.viewport(0, 0, width, height);
42456
- */ _proto.viewport = function viewport(x, y, width, height) {
44166
+ */ _proto.setViewport = function setViewport(x, y, width, height) {
42457
44167
  // OVERRIDE
42458
44168
  };
42459
44169
  _proto.clear = function clear(action) {
42460
44170
  // OVERRIDE
42461
44171
  };
42462
- _proto.drawGeometry = function drawGeometry(geometry, matrix, material, subMeshIndex) {
42463
- // OVERRIDE
42464
- };
42465
44172
  /*** 渲染状态控制 ***/ _proto.setSampleAlphaToCoverage = function setSampleAlphaToCoverage(enable) {
42466
44173
  // OVERRIDE
42467
44174
  };
@@ -42546,6 +44253,12 @@ var DEFAULT_FPS = 60;
42546
44253
  }
42547
44254
  (_this_ticker = this.ticker) == null ? void 0 : _this_ticker.stop();
42548
44255
  (_this_eventSystem = this.eventSystem) == null ? void 0 : _this_eventSystem.dispose();
44256
+ for(var _iterator = _create_for_of_iterator_helper_loose(this._compositions.slice()), _step; !(_step = _iterator()).done;){
44257
+ var composition = _step.value;
44258
+ composition.dispose();
44259
+ }
44260
+ this.root.dispose();
44261
+ this.windowRoot.dispose();
42549
44262
  (_this_assetService = this.assetService) == null ? void 0 : _this_assetService.dispose();
42550
44263
  (_this__graphics = this._graphics) == null ? void 0 : _this__graphics.dispose();
42551
44264
  this.renderPasses.forEach(function(pass) {
@@ -42566,16 +44279,13 @@ var DEFAULT_FPS = 60;
42566
44279
  this.assetManagers.forEach(function(assetManager) {
42567
44280
  return assetManager.dispose();
42568
44281
  });
42569
- this.compositions.forEach(function(comp) {
42570
- return comp.dispose();
42571
- });
42572
44282
  this.textures = [];
42573
44283
  this.materials = [];
42574
44284
  this.geometries = [];
42575
44285
  this.meshes = [];
42576
44286
  this.renderPasses = [];
42577
- this.compositions = [];
42578
44287
  this.particleSystems = [];
44288
+ this._compositions = [];
42579
44289
  };
42580
44290
  _proto.getTargetSize = function getTargetSize(parentEle) {
42581
44291
  if (parentEle === undefined || parentEle === null) {
@@ -42628,6 +44338,14 @@ var DEFAULT_FPS = 60;
42628
44338
  ];
42629
44339
  };
42630
44340
  _create_class(Engine, [
44341
+ {
44342
+ key: "compositions",
44343
+ get: function get() {
44344
+ return this._compositions.sort(function(a, b) {
44345
+ return a.getIndex() - b.getIndex();
44346
+ });
44347
+ }
44348
+ },
42631
44349
  {
42632
44350
  key: "graphics",
42633
44351
  get: function get() {
@@ -42865,7 +44583,7 @@ registerPlugin("text", TextLoader);
42865
44583
  registerPlugin("sprite", SpriteLoader);
42866
44584
  registerPlugin("particle", ParticleLoader);
42867
44585
  registerPlugin("interact", InteractLoader);
42868
- var version = "2.10.0-alpha.2";
44586
+ var version = "2.10.0-alpha.4";
42869
44587
  logger.info("Core version: " + version + ".");
42870
44588
 
42871
44589
  exports.ATLAS_SIZE = ATLAS_SIZE;
@@ -42900,8 +44618,8 @@ exports.COPY_MESH_SHADER_ID = COPY_MESH_SHADER_ID;
42900
44618
  exports.COPY_VERTEX_SHADER = COPY_VERTEX_SHADER;
42901
44619
  exports.Camera = Camera;
42902
44620
  exports.CameraVFXItemLoader = CameraVFXItemLoader;
42903
- exports.CanvasItem = CanvasItem;
42904
- exports.CanvasLayer = CanvasLayer;
44621
+ exports.CanvasContainer = CanvasContainer;
44622
+ exports.CanvasRootControl = CanvasRootControl;
42905
44623
  exports.Circle = Circle$1;
42906
44624
  exports.ColorCurve = ColorCurve;
42907
44625
  exports.ColorPlayable = ColorPlayable;
@@ -42914,6 +44632,7 @@ exports.Composition = Composition;
42914
44632
  exports.ConstBoolNode = ConstBoolNode;
42915
44633
  exports.ConstFloatNode = ConstFloatNode;
42916
44634
  exports.ConstraintTarget = ConstraintTarget;
44635
+ exports.ContainerControl = ContainerControl;
42917
44636
  exports.Control = Control;
42918
44637
  exports.ControlParameterBoolNode = ControlParameterBoolNode;
42919
44638
  exports.ControlParameterFloatNode = ControlParameterFloatNode;
@@ -42937,7 +44656,6 @@ exports.Ellipse = Ellipse;
42937
44656
  exports.Engine = Engine;
42938
44657
  exports.EventEmitter = EventEmitter;
42939
44658
  exports.EventSystem = EventSystem;
42940
- exports.FONT_SCALE = FONT_SCALE;
42941
44659
  exports.Float16ArrayWrapper = Float16ArrayWrapper;
42942
44660
  exports.FloatComparisonNode = FloatComparisonNode;
42943
44661
  exports.FloatComparisonNodeData = FloatComparisonNodeData;
@@ -42954,6 +44672,14 @@ exports.GraphNode = GraphNode;
42954
44672
  exports.GraphNodeData = GraphNodeData;
42955
44673
  exports.Graphics = Graphics;
42956
44674
  exports.HELP_LINK = HELP_LINK;
44675
+ exports.InputEvent = InputEvent;
44676
+ exports.InputEventKey = InputEventKey;
44677
+ exports.InputEventMouse = InputEventMouse;
44678
+ exports.InputEventMouseButton = InputEventMouseButton;
44679
+ exports.InputEventMouseMotion = InputEventMouseMotion;
44680
+ exports.InputEventScreenDrag = InputEventScreenDrag;
44681
+ exports.InputEventScreenTouch = InputEventScreenTouch;
44682
+ exports.InputEventWithModifiers = InputEventWithModifiers;
42957
44683
  exports.InteractLoader = InteractLoader;
42958
44684
  exports.InteractMesh = InteractMesh;
42959
44685
  exports.InvalidIndex = InvalidIndex;
@@ -43002,7 +44728,6 @@ exports.RandomSetValue = RandomSetValue;
43002
44728
  exports.RandomValue = RandomValue;
43003
44729
  exports.RandomVectorValue = RandomVectorValue;
43004
44730
  exports.RaycastResult = RaycastResult;
43005
- exports.RectTransform = RectTransform;
43006
44731
  exports.Rectangle = Rectangle$1;
43007
44732
  exports.ReferenceCurve = ReferenceCurve;
43008
44733
  exports.RenderFrame = RenderFrame;
@@ -43015,6 +44740,7 @@ exports.RenderTargetPool = RenderTargetPool;
43015
44740
  exports.Renderbuffer = Renderbuffer;
43016
44741
  exports.Renderer = Renderer;
43017
44742
  exports.RendererComponent = RendererComponent;
44743
+ exports.RootControl = RootControl;
43018
44744
  exports.RuntimeClip = RuntimeClip;
43019
44745
  exports.SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0 = SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0;
43020
44746
  exports.SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0 = SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0;
@@ -43052,6 +44778,8 @@ exports.TransformPlayable = TransformPlayable;
43052
44778
  exports.TransitionNode = TransitionNode;
43053
44779
  exports.Triangle = Triangle;
43054
44780
  exports.TrimPath = TrimPath;
44781
+ exports.UICanvas = UICanvas;
44782
+ exports.UIControl = UIControl;
43055
44783
  exports.ValueGetter = ValueGetter;
43056
44784
  exports.ValueNode = ValueNode;
43057
44785
  exports.Vector2Curve = Vector2Curve;
@@ -43061,6 +44789,7 @@ exports.Vector3PropertyMixerPlayable = Vector3PropertyMixerPlayable;
43061
44789
  exports.Vector4Curve = Vector4Curve;
43062
44790
  exports.Vector4PropertyMixerPlayable = Vector4PropertyMixerPlayable;
43063
44791
  exports.VertexBuffer = VertexBuffer;
44792
+ exports.WindowRootControl = WindowRootControl;
43064
44793
  exports.addByOrder = addByOrder;
43065
44794
  exports.addItem = addItem;
43066
44795
  exports.addItemWithOrder = addItemWithOrder;