@galacean/effects-threejs 2.10.0-alpha.2 → 2.10.0-alpha.3

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.mjs CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: Galacean Effects runtime threejs plugin 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.3
7
7
  */
8
8
 
9
9
  import * as THREE from 'three';
@@ -7059,6 +7059,11 @@ function _create_class(Constructor, protoProps, staticProps) {
7059
7059
  // OVERRIDE
7060
7060
  };
7061
7061
  /**
7062
+ * Called when the owning item's sibling order changes.
7063
+ */ _proto.onOrderInParentChanged = function onOrderInParentChanged() {
7064
+ // OVERRIDE
7065
+ };
7066
+ /**
7062
7067
  * @internal
7063
7068
  */ _proto.enable = function enable() {
7064
7069
  if (this.item.composition) {
@@ -14016,6 +14021,7 @@ var seed$7 = 1;
14016
14021
  quat: new Quaternion(0, 0, 0, 1),
14017
14022
  scale: new Vector3(1, 1, 1)
14018
14023
  };
14024
+ this.eventEmitter = new EventEmitter();
14019
14025
  this.name = "transform_" + seed$7++;
14020
14026
  if (props) {
14021
14027
  this.setTransform(props);
@@ -14028,6 +14034,12 @@ var seed$7 = 1;
14028
14034
  }
14029
14035
  }
14030
14036
  var _proto = Transform.prototype;
14037
+ _proto.on = function on(eventName, listener, options) {
14038
+ this.eventEmitter.on(eventName, listener, options);
14039
+ };
14040
+ _proto.off = function off(eventName, listener) {
14041
+ this.eventEmitter.off(eventName, listener);
14042
+ };
14031
14043
  /**
14032
14044
  * 父 transform 切换时的 hook。子类可重写以接管订阅 / 解算等逻辑
14033
14045
  * @param oldParent - 切换前的父 transform(若没有则为 null)
@@ -14446,6 +14458,7 @@ var seed$7 = 1;
14446
14458
  this.children.forEach(function(c) {
14447
14459
  c.worldMatrixDirty = true;
14448
14460
  });
14461
+ this.eventEmitter.emit("changed", this);
14449
14462
  };
14450
14463
  /**
14451
14464
  * 转换右手坐标系左手螺旋对应的四元数到对应的旋转角
@@ -14464,14 +14477,16 @@ var seed$7 = 1;
14464
14477
  return this.parent;
14465
14478
  },
14466
14479
  set: function set(transform) {
14467
- if (!transform || this.parent === transform || this === transform) {
14480
+ if (this.parent === transform || this === transform) {
14468
14481
  return;
14469
14482
  }
14470
14483
  var oldParent = this.parent;
14471
14484
  if (this.parent) {
14472
14485
  this.parent.removeChild(this);
14473
14486
  }
14474
- transform.addChild(this);
14487
+ if (transform) {
14488
+ transform.addChild(this);
14489
+ }
14475
14490
  this.parent = transform;
14476
14491
  this.worldMatrixDirty = true;
14477
14492
  this.onParentTransformChanged(oldParent, transform);
@@ -14654,7 +14669,7 @@ var VFXItem = /*#__PURE__*/ function(EffectsObject) {
14654
14669
  return results;
14655
14670
  };
14656
14671
  _proto.setParent = function setParent(vfxItem) {
14657
- if (vfxItem === this && !vfxItem) {
14672
+ if (vfxItem === this || this.parent === vfxItem) {
14658
14673
  return;
14659
14674
  }
14660
14675
  if (this.parent) {
@@ -15041,6 +15056,12 @@ var VFXItem = /*#__PURE__*/ function(EffectsObject) {
15041
15056
  child.onParentChanged();
15042
15057
  }
15043
15058
  };
15059
+ _proto.onOrderInParentChanged = function onOrderInParentChanged() {
15060
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.components), _step; !(_step = _iterator()).done;){
15061
+ var component = _step.value;
15062
+ component.onOrderInParentChanged();
15063
+ }
15064
+ };
15044
15065
  /**
15045
15066
  * @internal
15046
15067
  */ _proto.setRendererComponentOrder = function setRendererComponentOrder(renderOrder) {
@@ -15125,15 +15146,16 @@ var VFXItem = /*#__PURE__*/ function(EffectsObject) {
15125
15146
  */ _proto.dispose = function dispose() {
15126
15147
  if (this.composition) {
15127
15148
  this.composition.destroyItem(this);
15128
- // component 调用 dispose() 会将自身从 this.components 数组删除,slice() 避免迭代错误
15129
- for(var _iterator = _create_for_of_iterator_helper_loose(this.components.slice()), _step; !(_step = _iterator()).done;){
15130
- var component = _step.value;
15131
- component.dispose();
15132
- }
15133
- this.components = [];
15134
- this._composition = null;
15135
- this.transform.setValid(false);
15136
15149
  }
15150
+ // component.dispose() removes itself from this.components. Use a snapshot
15151
+ // so Engine.root components are also disposed even without a Composition.
15152
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.components.slice()), _step; !(_step = _iterator()).done;){
15153
+ var component = _step.value;
15154
+ component.dispose();
15155
+ }
15156
+ this.components = [];
15157
+ this._composition = null;
15158
+ this.transform.setValid(false);
15137
15159
  this.resetChildrenParent();
15138
15160
  EffectsObject.prototype.dispose.call(this);
15139
15161
  };
@@ -15329,6 +15351,33 @@ var VFXItem = /*#__PURE__*/ function(EffectsObject) {
15329
15351
  this.setRendererComponentOrder(value);
15330
15352
  }
15331
15353
  },
15354
+ {
15355
+ key: "orderInParent",
15356
+ get: /** Zero-based sibling order within the parent item. */ function get() {
15357
+ var _this_parent;
15358
+ var _this_parent_children_indexOf;
15359
+ return (_this_parent_children_indexOf = (_this_parent = this.parent) == null ? void 0 : _this_parent.children.indexOf(this)) != null ? _this_parent_children_indexOf : -1;
15360
+ },
15361
+ set: function set(value) {
15362
+ var _this_parent;
15363
+ var siblings = (_this_parent = this.parent) == null ? void 0 : _this_parent.children;
15364
+ var _siblings_indexOf;
15365
+ var oldIndex = (_siblings_indexOf = siblings == null ? void 0 : siblings.indexOf(this)) != null ? _siblings_indexOf : -1;
15366
+ if (!siblings || oldIndex === -1) {
15367
+ return;
15368
+ }
15369
+ var newIndex = Math.max(0, Math.min(Math.trunc(value), siblings.length - 1));
15370
+ if (oldIndex === newIndex) {
15371
+ return;
15372
+ }
15373
+ siblings.splice(oldIndex, 1);
15374
+ siblings.splice(newIndex, 0, this);
15375
+ for(var _iterator = _create_for_of_iterator_helper_loose(siblings), _step; !(_step = _iterator()).done;){
15376
+ var sibling = _step.value;
15377
+ sibling.onOrderInParentChanged();
15378
+ }
15379
+ }
15380
+ },
15332
15381
  {
15333
15382
  key: "isActive",
15334
15383
  get: /**
@@ -15585,35 +15634,35 @@ function vecMulCombine(out, a, b) {
15585
15634
  }
15586
15635
  return out;
15587
15636
  }
15588
- var _obj$6;
15589
- var particleOriginTranslateMap$1 = (_obj$6 = {}, _obj$6[ParticleOrigin.PARTICLE_ORIGIN_CENTER] = [
15637
+ var _obj$7;
15638
+ var particleOriginTranslateMap$1 = (_obj$7 = {}, _obj$7[ParticleOrigin.PARTICLE_ORIGIN_CENTER] = [
15590
15639
  0,
15591
15640
  0
15592
- ], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_CENTER_BOTTOM] = [
15641
+ ], _obj$7[ParticleOrigin.PARTICLE_ORIGIN_CENTER_BOTTOM] = [
15593
15642
  0,
15594
15643
  -0.5
15595
- ], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_CENTER_TOP] = [
15644
+ ], _obj$7[ParticleOrigin.PARTICLE_ORIGIN_CENTER_TOP] = [
15596
15645
  0,
15597
15646
  0.5
15598
- ], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_LEFT_TOP] = [
15647
+ ], _obj$7[ParticleOrigin.PARTICLE_ORIGIN_LEFT_TOP] = [
15599
15648
  -0.5,
15600
15649
  0.5
15601
- ], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_LEFT_CENTER] = [
15650
+ ], _obj$7[ParticleOrigin.PARTICLE_ORIGIN_LEFT_CENTER] = [
15602
15651
  -0.5,
15603
15652
  0
15604
- ], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_LEFT_BOTTOM] = [
15653
+ ], _obj$7[ParticleOrigin.PARTICLE_ORIGIN_LEFT_BOTTOM] = [
15605
15654
  -0.5,
15606
15655
  -0.5
15607
- ], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_CENTER] = [
15656
+ ], _obj$7[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_CENTER] = [
15608
15657
  0.5,
15609
15658
  0
15610
- ], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_BOTTOM] = [
15659
+ ], _obj$7[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_BOTTOM] = [
15611
15660
  0.5,
15612
15661
  -0.5
15613
- ], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_TOP] = [
15662
+ ], _obj$7[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_TOP] = [
15614
15663
  0.5,
15615
15664
  0.5
15616
- ], _obj$6);
15665
+ ], _obj$7);
15617
15666
  function nearestPowerOfTwo(value) {
15618
15667
  return Math.pow(2, Math.round(Math.log(value) / Math.LN2));
15619
15668
  }
@@ -17351,27 +17400,27 @@ function oldBezierKeyFramesToNew(props) {
17351
17400
  * 对象引用阶梯曲线(spec ValueType.REFERENCE_CURVE)。
17352
17401
  * props 为 [[time, value], ...],value 为已解析的对象引用实例。
17353
17402
  */ var REFERENCE_CURVE = 28;
17354
- var _obj$5;
17355
- var map$1 = (_obj$5 = {}, _obj$5[ValueType.RANDOM] = function(props) {
17403
+ var _obj$6;
17404
+ var map$1 = (_obj$6 = {}, _obj$6[ValueType.RANDOM] = function(props) {
17356
17405
  if (_instanceof1(props[0], Array)) {
17357
17406
  return new RandomVectorValue(props);
17358
17407
  }
17359
17408
  return new RandomValue(props);
17360
- }, _obj$5[ValueType.CONSTANT] = function(props) {
17409
+ }, _obj$6[ValueType.CONSTANT] = function(props) {
17361
17410
  return new StaticValue(props);
17362
- }, _obj$5[ValueType.CONSTANT_VEC2] = function(props) {
17411
+ }, _obj$6[ValueType.CONSTANT_VEC2] = function(props) {
17363
17412
  return new StaticValue(props);
17364
- }, _obj$5[ValueType.CONSTANT_VEC3] = function(props) {
17413
+ }, _obj$6[ValueType.CONSTANT_VEC3] = function(props) {
17365
17414
  return new StaticValue(props);
17366
- }, _obj$5[ValueType.CONSTANT_VEC4] = function(props) {
17415
+ }, _obj$6[ValueType.CONSTANT_VEC4] = function(props) {
17367
17416
  return new StaticValue(props);
17368
- }, _obj$5[ValueType.RGBA_COLOR] = function(props) {
17417
+ }, _obj$6[ValueType.RGBA_COLOR] = function(props) {
17369
17418
  return new StaticValue(props);
17370
- }, _obj$5[ValueType.COLORS] = function(props) {
17419
+ }, _obj$6[ValueType.COLORS] = function(props) {
17371
17420
  return new RandomSetValue(props.map(function(c) {
17372
17421
  return colorToArr$1(c, false);
17373
17422
  }));
17374
- }, _obj$5[ValueType.LINE] = function(props) {
17423
+ }, _obj$6[ValueType.LINE] = function(props) {
17375
17424
  if (props.length === 2 && props[0][0] === 0 && props[1][0] === 1) {
17376
17425
  return new LinearValue([
17377
17426
  props[0][1],
@@ -17379,38 +17428,38 @@ var map$1 = (_obj$5 = {}, _obj$5[ValueType.RANDOM] = function(props) {
17379
17428
  ]);
17380
17429
  }
17381
17430
  return new LineSegments(props);
17382
- }, _obj$5[ValueType.GRADIENT_COLOR] = function(props) {
17431
+ }, _obj$6[ValueType.GRADIENT_COLOR] = function(props) {
17383
17432
  return new GradientValue(props);
17384
- }, _obj$5[ValueType.LINEAR_PATH] = function(pros) {
17433
+ }, _obj$6[ValueType.LINEAR_PATH] = function(pros) {
17385
17434
  return new PathSegments(pros);
17386
- }, _obj$5[ValueType.BEZIER_CURVE] = function(props) {
17435
+ }, _obj$6[ValueType.BEZIER_CURVE] = function(props) {
17387
17436
  if (props.length === 1) {
17388
17437
  return new StaticValue(props[0][1][1]);
17389
17438
  }
17390
17439
  return new BezierCurve(props);
17391
- }, _obj$5[ValueType.BEZIER_CURVE_PATH] = function(props) {
17440
+ }, _obj$6[ValueType.BEZIER_CURVE_PATH] = function(props) {
17392
17441
  if (props[0].length === 1) {
17393
17442
  return new StaticValue(_construct(Vector3, [].concat(props[1][0])));
17394
17443
  }
17395
17444
  return new BezierCurvePath(props);
17396
- }, _obj$5[ValueType.BEZIER_CURVE_QUAT] = function(props) {
17445
+ }, _obj$6[ValueType.BEZIER_CURVE_QUAT] = function(props) {
17397
17446
  if (props[0].length === 1) {
17398
17447
  return new StaticValue(_construct(Quaternion, [].concat(props[1][0])));
17399
17448
  }
17400
17449
  return new BezierCurveQuat(props);
17401
- }, _obj$5[ValueType.COLOR_CURVE] = function(props) {
17450
+ }, _obj$6[ValueType.COLOR_CURVE] = function(props) {
17402
17451
  return new ColorCurve(props);
17403
- }, _obj$5[ValueType.VECTOR4_CURVE] = function(props) {
17452
+ }, _obj$6[ValueType.VECTOR4_CURVE] = function(props) {
17404
17453
  return new Vector4Curve(props);
17405
- }, _obj$5[ValueType.VECTOR2_CURVE] = function(props) {
17454
+ }, _obj$6[ValueType.VECTOR2_CURVE] = function(props) {
17406
17455
  return new Vector2Curve(props);
17407
17456
  }, // TODO: add spec
17408
- _obj$5[VECTOR3_CURVE] = function(props) {
17457
+ _obj$6[VECTOR3_CURVE] = function(props) {
17409
17458
  return new Vector3Curve(props);
17410
17459
  }, // 对象引用阶梯曲线(不插值):props.data 为 [time, value][],value 已解析为 EffectsObject
17411
- _obj$5[REFERENCE_CURVE] = function(props) {
17460
+ _obj$6[REFERENCE_CURVE] = function(props) {
17412
17461
  return new ReferenceCurve(props);
17413
- }, _obj$5);
17462
+ }, _obj$6);
17414
17463
  function createValueGetter(args) {
17415
17464
  if (!args || !isNaN(+args)) {
17416
17465
  return new StaticValue(args || 0);
@@ -20927,20 +20976,24 @@ var geometryId = 1;
20927
20976
  var vertexArrayObjects = this.vertexArrayObjects;
20928
20977
  var engine = this.engine;
20929
20978
  if (!vertexArrayObjects || !supportsVertexArrayObjects(engine)) {
20930
- engine.bindBuffers(this.vertexBuffers, this.indexBuffer, shader);
20979
+ var _this_indexBuffer;
20980
+ engine.bindBuffers(this.vertexBuffers, (_this_indexBuffer = this.indexBuffer) != null ? _this_indexBuffer : null, shader);
20931
20981
  return;
20932
20982
  }
20933
20983
  var vertexArrayObject = vertexArrayObjects[shader.key];
20934
20984
  if (!vertexArrayObject) {
20935
- vertexArrayObject = engine.recordVertexArrayObject(this.vertexBuffers, this.indexBuffer, shader);
20985
+ var _this_indexBuffer1;
20986
+ vertexArrayObject = engine.recordVertexArrayObject(this.vertexBuffers, (_this_indexBuffer1 = this.indexBuffer) != null ? _this_indexBuffer1 : null, shader);
20936
20987
  if (vertexArrayObject) {
20937
20988
  vertexArrayObjects[shader.key] = vertexArrayObject;
20938
20989
  }
20939
20990
  }
20940
20991
  if (vertexArrayObject) {
20941
- engine.bindVertexArrayObject(vertexArrayObject, this.indexBuffer);
20992
+ var _this_indexBuffer2;
20993
+ engine.bindVertexArrayObject(vertexArrayObject, (_this_indexBuffer2 = this.indexBuffer) != null ? _this_indexBuffer2 : null);
20942
20994
  } else {
20943
- engine.bindBuffers(this.vertexBuffers, this.indexBuffer, shader);
20995
+ var _this_indexBuffer3;
20996
+ engine.bindBuffers(this.vertexBuffers, (_this_indexBuffer3 = this.indexBuffer) != null ? _this_indexBuffer3 : null, shader);
20944
20997
  }
20945
20998
  };
20946
20999
  _proto.releaseVertexArrayObject = function releaseVertexArrayObject(key) {
@@ -21347,8 +21400,8 @@ var vertexBufferSemanticMap = {
21347
21400
  TANGENT_BS2: "aTargetTangent2",
21348
21401
  TANGENT_BS3: "aTargetTangent3"
21349
21402
  };
21350
- var _obj$4;
21351
- var BYTES_TYPE_MAP = (_obj$4 = {}, _obj$4[BufferDataType.Float] = 4, _obj$4[BufferDataType.Int] = 4, _obj$4[BufferDataType.UnsignedInt] = 4, _obj$4[BufferDataType.Short] = 2, _obj$4[BufferDataType.UnsignedShort] = 2, _obj$4[BufferDataType.Byte] = 1, _obj$4[BufferDataType.UnsignedByte] = 1, _obj$4);
21403
+ var _obj$5;
21404
+ var BYTES_TYPE_MAP = (_obj$5 = {}, _obj$5[BufferDataType.Float] = 4, _obj$5[BufferDataType.Int] = 4, _obj$5[BufferDataType.UnsignedInt] = 4, _obj$5[BufferDataType.Short] = 2, _obj$5[BufferDataType.UnsignedShort] = 2, _obj$5[BufferDataType.Byte] = 1, _obj$5[BufferDataType.UnsignedByte] = 1, _obj$5);
21352
21405
  function generateEmptyTypedArray(type) {
21353
21406
  return createTypedArray(type, 0);
21354
21407
  }
@@ -22358,7 +22411,7 @@ var Renderer = /*#__PURE__*/ function() {
22358
22411
  }
22359
22412
  };
22360
22413
  _proto.setViewport = function setViewport(x, y, width, height) {
22361
- this.engine.viewport(x, y, width, height);
22414
+ this.engine.setViewport(x, y, width, height);
22362
22415
  };
22363
22416
  _proto.clear = function clear(action) {
22364
22417
  this.engine.clear(action);
@@ -22421,7 +22474,40 @@ var Renderer = /*#__PURE__*/ function() {
22421
22474
  };
22422
22475
  _proto.drawGeometry = function drawGeometry(geometry, matrix, material, subMeshIndex) {
22423
22476
  if (subMeshIndex === void 0) subMeshIndex = 0;
22424
- this.engine.drawGeometry(geometry, matrix, material, subMeshIndex);
22477
+ if (!geometry || !material) {
22478
+ return;
22479
+ }
22480
+ material.initialize();
22481
+ geometry.initialize();
22482
+ geometry.flush();
22483
+ material.setMatrix("effects_ObjectToWorld", matrix);
22484
+ try {
22485
+ material.use(this, this.renderingData.currentFrame.globalUniforms);
22486
+ } catch (e) {
22487
+ console.error(e);
22488
+ this.engine.renderErrors.add(e);
22489
+ return;
22490
+ }
22491
+ var indexBuffer = geometry.getIndexBuffer();
22492
+ var offset = geometry.getDrawStart();
22493
+ var count = geometry.getDrawCount();
22494
+ var subMeshes = geometry.subMeshes;
22495
+ if (subMeshes.length > 0) {
22496
+ var subMesh = subMeshes[subMeshIndex];
22497
+ offset = subMesh.offset;
22498
+ var _subMesh_indexCount;
22499
+ count = indexBuffer ? (_subMesh_indexCount = subMesh.indexCount) != null ? _subMesh_indexCount : 0 : subMesh.vertexCount;
22500
+ }
22501
+ if (count <= 0) {
22502
+ return;
22503
+ }
22504
+ geometry.bind(material.shaderVariant);
22505
+ var instanceCount = geometry.instanceCount || undefined;
22506
+ if (indexBuffer) {
22507
+ this.engine.drawElementsType(geometry.mode, offset, count, instanceCount);
22508
+ } else {
22509
+ this.engine.drawArraysType(geometry.mode, offset, count, instanceCount);
22510
+ }
22425
22511
  };
22426
22512
  _proto.getTemporaryRT = function getTemporaryRT(name, width, height, depthBuffer, filter, format) {
22427
22513
  return this.engine.renderTargetPool.get(name, width, height, depthBuffer, filter, format);
@@ -22689,11 +22775,7 @@ var CanvasPool = /*#__PURE__*/ function() {
22689
22775
  var canvasPool = new CanvasPool();
22690
22776
 
22691
22777
  /**
22692
- * 字形纹理超采样倍数。canvas `fontSize * FONT_SCALE` 渲染,纹理像素也是 scale 倍,
22693
- * 但 quad 仍按 1x 逻辑尺寸绘制 — 双线性 downsample 后比原 1x 渲染清晰得多
22694
- */ var FONT_SCALE = 2;
22695
- /**
22696
- * 单张字符 atlas 的边长(像素,scale 后的实际像素,非逻辑尺寸)。
22778
+ * 单张字符 atlas 的逻辑边长。实际 canvas 像素尺寸会乘以渲染 resolution。
22697
22779
  * 512×512 在 24px 字号下约可容纳 250+ 字形,常见 demo 文本足够
22698
22780
  */ var ATLAS_SIZE = 512;
22699
22781
  /**
@@ -22715,7 +22797,7 @@ var canvasPool = new CanvasPool();
22715
22797
  * canvas 内容变更后需要 `uploadIfDirty` 重新上传到纹理 — 由调用方在使用纹理前主动触发,
22716
22798
  * 避免每加一字都 upload 一次造成的 GL 开销
22717
22799
  */ var GlyphAtlas = /*#__PURE__*/ function() {
22718
- function GlyphAtlas(engine, scaledFontString, /** baseline 距 cell 顶距离(像素,scale 后,仅 ascent 部分,不含 padding) */ ascentPx, /** baseline 距 cell 底距离(像素,scale 后,仅 descent 部分) */ descentPx, fontStyle) {
22800
+ function GlyphAtlas(engine, scaledFontString, /** baseline 距 cell 顶距离(像素,scale 后,仅 ascent 部分,不含 padding) */ ascentPx, /** baseline 距 cell 底距离(像素,scale 后,仅 descent 部分) */ descentPx, fontStyle, resolution) {
22719
22801
  this.engine = engine;
22720
22802
  this.scaledFontString = scaledFontString;
22721
22803
  this.glyphs = new Map();
@@ -22723,9 +22805,10 @@ var canvasPool = new CanvasPool();
22723
22805
  this.currentY = 0;
22724
22806
  this.full = false;
22725
22807
  this.dirty = true;
22808
+ this.resolution = resolution;
22726
22809
  this.canvas = document.createElement("canvas");
22727
- this.canvas.width = ATLAS_SIZE;
22728
- this.canvas.height = ATLAS_SIZE;
22810
+ this.canvas.width = Math.ceil(ATLAS_SIZE * resolution);
22811
+ this.canvas.height = Math.ceil(ATLAS_SIZE * resolution);
22729
22812
  var ctx = this.canvas.getContext("2d", {
22730
22813
  willReadFrequently: false
22731
22814
  });
@@ -22736,14 +22819,14 @@ var canvasPool = new CanvasPool();
22736
22819
  ctx.font = scaledFontString;
22737
22820
  ctx.textBaseline = "alphabetic";
22738
22821
  ctx.fillStyle = "#ffffff";
22739
- this.paddingPx = GLYPH_PADDING * FONT_SCALE;
22822
+ this.paddingPx = GLYPH_PADDING * resolution;
22740
22823
  this.italicScale = fontStyle === "italic" ? 2 : 1;
22741
22824
  // ascent/descent 由探针 '|ÉqÅM' 测得 actualBoundingBox(重音字已抬高 ink 顶),
22742
22825
  // 两者内部保持浮点,仅 cell 高做一次外层 ceil — 与 padding 共同保证 cell 内不裁切
22743
22826
  var fontHeightPx = ascentPx + descentPx;
22744
22827
  this.baselinePx = this.paddingPx + ascentPx;
22745
22828
  this.cellHPx = Math.ceil(fontHeightPx + this.paddingPx * 2);
22746
- this.lineHeight = this.cellHPx / FONT_SCALE;
22829
+ this.lineHeight = this.cellHPx / resolution;
22747
22830
  this.texture = Texture.create(engine, {
22748
22831
  sourceType: TextureSourceType.image,
22749
22832
  image: this.canvas,
@@ -22752,7 +22835,8 @@ var canvasPool = new CanvasPool();
22752
22835
  magFilter: glContext.LINEAR,
22753
22836
  minFilter: glContext.LINEAR,
22754
22837
  wrapS: glContext.CLAMP_TO_EDGE,
22755
- wrapT: glContext.CLAMP_TO_EDGE
22838
+ wrapT: glContext.CLAMP_TO_EDGE,
22839
+ premultiplyAlpha: true
22756
22840
  });
22757
22841
  this.texture.initialize();
22758
22842
  }
@@ -22770,19 +22854,19 @@ var canvasPool = new CanvasPool();
22770
22854
  var ctx = this.ctx;
22771
22855
  // 每次重设字体,防御外部潜在污染(虽然 ctx 私有)
22772
22856
  ctx.font = this.scaledFontString;
22773
- // measureText 用的是 scaledFontString,advance 已经是 scale 后的像素,不能再乘 FONT_SCALE
22857
+ // measureText 用的是 scaledFontString,advance 已经是 resolution 后的像素
22774
22858
  var advancePx = ctx.measureText(char).width;
22775
22859
  // italic 放大 cell 宽防斜体越界;ceil 对齐像素网格避免相邻字采样重叠
22776
22860
  var widthPx = Math.max(1, Math.ceil(advancePx * this.italicScale));
22777
22861
  var paddedWidthPx = widthPx + this.paddingPx * 2;
22778
22862
  var cellH = this.cellHPx;
22779
22863
  // 行尾换行
22780
- if (this.currentX + paddedWidthPx > ATLAS_SIZE) {
22864
+ if (this.currentX + paddedWidthPx > this.canvas.width) {
22781
22865
  this.currentX = 0;
22782
22866
  this.currentY += cellH;
22783
22867
  }
22784
22868
  // atlas 满,后续不再尝试
22785
- if (this.currentY + cellH > ATLAS_SIZE) {
22869
+ if (this.currentY + cellH > this.canvas.height) {
22786
22870
  this.full = true;
22787
22871
  console.warn('GlyphAtlas full, dropping char "' + char + '"');
22788
22872
  return null;
@@ -22798,8 +22882,8 @@ var canvasPool = new CanvasPool();
22798
22882
  py: py,
22799
22883
  pw: paddedWidthPx,
22800
22884
  ph: cellH,
22801
- advance: advancePx / FONT_SCALE,
22802
- paddingLeft: this.paddingPx / FONT_SCALE
22885
+ advance: advancePx / this.resolution,
22886
+ paddingLeft: this.paddingPx / this.resolution
22803
22887
  };
22804
22888
  this.glyphs.set(char, info);
22805
22889
  return info;
@@ -22818,7 +22902,8 @@ var canvasPool = new CanvasPool();
22818
22902
  magFilter: glContext.LINEAR,
22819
22903
  minFilter: glContext.LINEAR,
22820
22904
  wrapS: glContext.CLAMP_TO_EDGE,
22821
- wrapT: glContext.CLAMP_TO_EDGE
22905
+ wrapT: glContext.CLAMP_TO_EDGE,
22906
+ premultiplyAlpha: true
22822
22907
  });
22823
22908
  this.dirty = false;
22824
22909
  };
@@ -22841,26 +22926,33 @@ var canvasPool = new CanvasPool();
22841
22926
  function TextCache(engine) {
22842
22927
  this.engine = engine;
22843
22928
  this.atlases = new Map();
22929
+ this.resolution = engine.pixelRatio;
22844
22930
  }
22845
22931
  var _proto = TextCache.prototype;
22846
22932
  /**
22847
22933
  * 取(必要时新建)对应字体的字符 atlas
22848
22934
  */ _proto.getAtlas = function getAtlas(fontSize, fontFamily, fontWeight, fontStyle) {
22849
- var fontKey = fontStyle + "|" + fontWeight + "|" + fontSize + "|" + fontFamily;
22935
+ // Pixi CanvasText 默认跟随 renderer.resolution;这里对应 Engine.pixelRatio。
22936
+ var resolution = this.engine.pixelRatio;
22937
+ if (resolution !== this.resolution) {
22938
+ this.clear();
22939
+ this.resolution = resolution;
22940
+ }
22941
+ var fontKey = fontStyle + "|" + fontWeight + "|" + fontSize + "|" + fontFamily + "|" + resolution;
22850
22942
  var cached = this.atlases.get(fontKey);
22851
22943
  if (cached) {
22852
22944
  return cached;
22853
22945
  }
22854
- var scaledFontString = fontStyle + " " + fontWeight + " " + fontSize * FONT_SCALE + "px " + fontFamily;
22946
+ var scaledFontString = fontStyle + " " + fontWeight + " " + fontSize * resolution + "px " + fontFamily;
22855
22947
  // 探一次得到字体级 ascent/descent(整张 atlas 共享 cell 高与 baseline,各字对齐)。
22856
- // 直接在 scaledFontString 下测,得到的就是 scale 后像素,无需再乘 FONT_SCALE。
22948
+ // 直接在 scaledFontString 下测,得到的就是 resolution 后像素。
22857
22949
  // 探针用 '|ÉqÅ' + 'M':带重音符的 ÉÅ 把 ink 顶推到接近字体真实 ascent,
22858
22950
  // 单字 'M' 只有 cap height(~0.7em) 太矮,CJK / 带重音字顶部会越过 cell 上界被裁。
22859
22951
  // 取 actualBoundingBoxAscent/Descent 度量 ink 边界,跨平台语义稳定
22860
22952
  var probeCanvasAndContext = canvasPool.getCanvasAndContext(1, 1);
22861
22953
  var probeCtx = probeCanvasAndContext.context;
22862
- var ascentPx = fontSize * 0.8 * FONT_SCALE;
22863
- var descentPx = fontSize * 0.2 * FONT_SCALE;
22954
+ var ascentPx = fontSize * 0.8 * resolution;
22955
+ var descentPx = fontSize * 0.2 * resolution;
22864
22956
  try {
22865
22957
  probeCtx.font = scaledFontString;
22866
22958
  var m = probeCtx.measureText(METRICS_STRING + BASELINE_SYMBOL);
@@ -22869,7 +22961,7 @@ var canvasPool = new CanvasPool();
22869
22961
  } finally{
22870
22962
  canvasPool.releaseCanvasAndContext(probeCanvasAndContext);
22871
22963
  }
22872
- var atlas = new GlyphAtlas(this.engine, scaledFontString, ascentPx, descentPx, fontStyle);
22964
+ var atlas = new GlyphAtlas(this.engine, scaledFontString, ascentPx, descentPx, fontStyle, resolution);
22873
22965
  this.atlases.set(fontKey, atlas);
22874
22966
  return atlas;
22875
22967
  };
@@ -22886,6 +22978,9 @@ var canvasPool = new CanvasPool();
22886
22978
  /**
22887
22979
  * 清空所有 atlas 并 dispose 对应纹理。Engine dispose 时调用
22888
22980
  */ _proto.dispose = function dispose() {
22981
+ this.clear();
22982
+ };
22983
+ _proto.clear = function clear() {
22889
22984
  for(var _iterator = _create_for_of_iterator_helper_loose(this.atlases.values()), _step; !(_step = _iterator()).done;){
22890
22985
  var atlas = _step.value;
22891
22986
  atlas.dispose();
@@ -23008,6 +23103,17 @@ var Graphics = /*#__PURE__*/ function() {
23008
23103
  this.texturedMaterial.depthTest = false;
23009
23104
  this.texturedMaterial.depthMask = false;
23010
23105
  this.texturedMaterial.blending = true;
23106
+ // 文本 atlas 按 Pixi 的方式在上传时预乘 alpha,因此采样后只需应用顶点色和顶点 alpha。
23107
+ // 单独使用 material,避免改变 drawTexture 对普通非预乘纹理的处理。
23108
+ this.textMaterial = Material.create(this.engine, {
23109
+ shader: {
23110
+ 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 }",
23111
+ 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 }"
23112
+ }
23113
+ });
23114
+ this.textMaterial.depthTest = false;
23115
+ this.textMaterial.depthMask = false;
23116
+ this.textMaterial.blending = true;
23011
23117
  this.textCache = new TextCache(engine);
23012
23118
  }
23013
23119
  var _proto = Graphics.prototype;
@@ -23029,6 +23135,7 @@ var Graphics = /*#__PURE__*/ function() {
23029
23135
  );
23030
23136
  this.coloredMaterial.setMatrix("effects_MatrixVP", projectionMatrix);
23031
23137
  this.texturedMaterial.setMatrix("effects_MatrixVP", projectionMatrix);
23138
+ this.textMaterial.setMatrix("effects_MatrixVP", projectionMatrix);
23032
23139
  };
23033
23140
  /**
23034
23141
  * 将当前变换压入栈,并设置新的变换
@@ -23056,7 +23163,7 @@ var Graphics = /*#__PURE__*/ function() {
23056
23163
  * 切换到指定批次类型/纹理。若与当前批次不一致,先 flush 已累积顶点
23057
23164
  */ _proto.ensureBatch = function ensureBatch(type, texture) {
23058
23165
  if (texture === void 0) texture = null;
23059
- var sameBatch = this.currentBatchType === type && (type !== "textured" || this.currentBatchTexture === texture);
23166
+ var sameBatch = this.currentBatchType === type && (type === "colored" || this.currentBatchTexture === texture);
23060
23167
  if (!sameBatch && this.currentVertexCount > 0) {
23061
23168
  this.flushBatch();
23062
23169
  }
@@ -23082,8 +23189,8 @@ var Graphics = /*#__PURE__*/ function() {
23082
23189
  this.geometry.setIndexData(indicesArray);
23083
23190
  this.geometry.setDrawCount(this.currentIndexCount);
23084
23191
  var material;
23085
- if (this.currentBatchType === "textured") {
23086
- material = this.texturedMaterial;
23192
+ if (this.currentBatchType === "textured" || this.currentBatchType === "text") {
23193
+ material = this.currentBatchType === "text" ? this.textMaterial : this.texturedMaterial;
23087
23194
  var _this_currentBatchTexture;
23088
23195
  var tex = (_this_currentBatchTexture = this.currentBatchTexture) != null ? _this_currentBatchTexture : this.engine.whiteTexture;
23089
23196
  material.setTexture("uMainTexture", tex);
@@ -23298,7 +23405,7 @@ var Graphics = /*#__PURE__*/ function() {
23298
23405
  return;
23299
23406
  }
23300
23407
  var atlas = this.textCache.getAtlas(fontSize, fontFamily, fontWeight, fontStyle);
23301
- this.ensureBatch("textured", atlas.texture);
23408
+ this.ensureBatch("text", atlas.texture);
23302
23409
  var lineHeight = atlas.lineHeight;
23303
23410
  var cursorX = x;
23304
23411
  // ensureChar 可能往 atlas canvas 写新字并打 dirty 标;实际 upload 推迟到
@@ -23309,13 +23416,15 @@ var Graphics = /*#__PURE__*/ function() {
23309
23416
  continue;
23310
23417
  }
23311
23418
  // atlas 像素坐标 → UV(纹理 flipY 后,canvas 顶 → v=1,canvas 底 → v=0)
23312
- var u0 = info.px / ATLAS_SIZE;
23313
- var u1 = (info.px + info.pw) / ATLAS_SIZE;
23314
- var v0 = 1 - (info.py + info.ph) / ATLAS_SIZE;
23315
- var v1 = 1 - info.py / ATLAS_SIZE;
23419
+ var atlasWidth = atlas.canvas.width;
23420
+ var atlasHeight = atlas.canvas.height;
23421
+ var u0 = info.px / atlasWidth;
23422
+ var u1 = (info.px + info.pw) / atlasWidth;
23423
+ var v0 = 1 - (info.py + info.ph) / atlasHeight;
23424
+ var v1 = 1 - info.py / atlasHeight;
23316
23425
  // quad 宽与采样区都含四周 padding(cell 留白透明);但光标只按 advance 前进,
23317
23426
  // quad 起点左偏 paddingLeft 使字形 ink 落在 cursorX — padding 区重叠无妨
23318
- this.pushQuad(cursorX - info.paddingLeft, y, info.pw / FONT_SCALE, lineHeight, color, {
23427
+ this.pushQuad(cursorX - info.paddingLeft, y, info.pw / atlas.resolution, lineHeight, color, {
23319
23428
  u0: u0,
23320
23429
  v0: v0,
23321
23430
  u1: u1,
@@ -23328,6 +23437,7 @@ var Graphics = /*#__PURE__*/ function() {
23328
23437
  this.geometry.dispose();
23329
23438
  this.coloredMaterial.dispose();
23330
23439
  this.texturedMaterial.dispose();
23440
+ this.textMaterial.dispose();
23331
23441
  this.textCache.dispose();
23332
23442
  };
23333
23443
  _proto.buildShape = function buildShape(shape, color) {
@@ -24398,410 +24508,358 @@ FrameComponent = __decorate([
24398
24508
  // 第四列 (位移) 乘 1,无需修改
24399
24509
  }
24400
24510
 
24401
- /**
24402
- * 画布层组件
24403
- *
24404
- * 作为一组顶层 CanvasItem 的容器:本层内所有 parent 为 null 的 CanvasItem 都登记在 canvasItems 中。
24405
- * 嵌套关系下的子 CanvasItem 通过其父 CanvasItem 的 children 数组管理,由父节点在 draw 时递归绘制。
24406
- */ var CanvasLayer = /*#__PURE__*/ function(Component) {
24407
- _inherits(CanvasLayer, Component);
24408
- function CanvasLayer() {
24409
- var _this;
24410
- _this = Component.apply(this, arguments) || this;
24411
- /**
24412
- * 当前层中的顶层 CanvasItem 列表(按注册顺序)。
24413
- * 仅包含 parent 为 null 的 CanvasItem;嵌套的子 CanvasItem 不会出现在此列表
24414
- */ _this.canvasItems = [];
24415
- /**
24416
- * 绘制层级,数值越小越先绘制
24417
- */ _this.layer = 0;
24418
- return _this;
24419
- }
24420
- var _proto = CanvasLayer.prototype;
24421
- /**
24422
- * 注册一个顶层 CanvasItem 到当前层
24423
- * @internal
24424
- */ _proto.addCanvasItem = function addCanvasItem(canvasItem) {
24425
- if (this.canvasItems.includes(canvasItem)) {
24426
- return;
24427
- }
24428
- this.canvasItems.push(canvasItem);
24429
- };
24430
- /**
24431
- * 从当前层注销一个顶层 CanvasItem
24432
- * @internal
24433
- */ _proto.removeCanvasItem = function removeCanvasItem(canvasItem) {
24434
- removeItem(this.canvasItems, canvasItem);
24435
- };
24436
- _proto.onEnable = function onEnable() {
24437
- var _this_item_composition;
24438
- var canvasLayers = (_this_item_composition = this.item.composition) == null ? void 0 : _this_item_composition.canvasLayers;
24439
- if (canvasLayers && !canvasLayers.includes(this)) {
24440
- canvasLayers.push(this);
24441
- }
24442
- };
24443
- _proto.onDisable = function onDisable() {
24444
- this.removeFromComposition();
24445
- this.refreshCanvasItemsLayer();
24511
+ function _assert_this_initialized(self) {
24512
+ if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
24513
+ return self;
24514
+ }
24515
+
24516
+ var MouseFilter;
24517
+ (function(MouseFilter) {
24518
+ MouseFilter[MouseFilter["Stop"] = 0] = "Stop";
24519
+ MouseFilter[MouseFilter["Pass"] = 1] = "Pass";
24520
+ MouseFilter[MouseFilter["Ignore"] = 2] = "Ignore";
24521
+ })(MouseFilter || (MouseFilter = {}));
24522
+ var MouseBehaviorRecursive;
24523
+ (function(MouseBehaviorRecursive) {
24524
+ MouseBehaviorRecursive[MouseBehaviorRecursive["Inherited"] = 0] = "Inherited";
24525
+ MouseBehaviorRecursive[MouseBehaviorRecursive["Disabled"] = 1] = "Disabled";
24526
+ MouseBehaviorRecursive[MouseBehaviorRecursive["Enabled"] = 2] = "Enabled";
24527
+ })(MouseBehaviorRecursive || (MouseBehaviorRecursive = {}));
24528
+ var MouseButton;
24529
+ (function(MouseButton) {
24530
+ MouseButton[MouseButton["None"] = 0] = "None";
24531
+ MouseButton[MouseButton["Left"] = 1] = "Left";
24532
+ MouseButton[MouseButton["Right"] = 2] = "Right";
24533
+ MouseButton[MouseButton["Middle"] = 3] = "Middle";
24534
+ MouseButton[MouseButton["WheelUp"] = 4] = "WheelUp";
24535
+ MouseButton[MouseButton["WheelDown"] = 5] = "WheelDown";
24536
+ MouseButton[MouseButton["WheelLeft"] = 6] = "WheelLeft";
24537
+ MouseButton[MouseButton["WheelRight"] = 7] = "WheelRight";
24538
+ MouseButton[MouseButton["Xbutton1"] = 8] = "Xbutton1";
24539
+ MouseButton[MouseButton["Xbutton2"] = 9] = "Xbutton2";
24540
+ })(MouseButton || (MouseButton = {}));
24541
+ var MouseButtonMask;
24542
+ (function(MouseButtonMask) {
24543
+ MouseButtonMask[MouseButtonMask["None"] = 0] = "None";
24544
+ MouseButtonMask[MouseButtonMask["Left"] = 1] = "Left";
24545
+ MouseButtonMask[MouseButtonMask["Right"] = 2] = "Right";
24546
+ MouseButtonMask[MouseButtonMask["Middle"] = 4] = "Middle";
24547
+ MouseButtonMask[MouseButtonMask["Xbutton1"] = 128] = "Xbutton1";
24548
+ MouseButtonMask[MouseButtonMask["Xbutton2"] = 256] = "Xbutton2";
24549
+ })(MouseButtonMask || (MouseButtonMask = {}));
24550
+ var FocusMode;
24551
+ (function(FocusMode) {
24552
+ FocusMode[FocusMode["None"] = 0] = "None";
24553
+ FocusMode[FocusMode["Click"] = 1] = "Click";
24554
+ FocusMode[FocusMode["All"] = 2] = "All";
24555
+ FocusMode[FocusMode["Accessibility"] = 3] = "Accessibility";
24556
+ })(FocusMode || (FocusMode = {}));
24557
+ var FocusBehaviorRecursive;
24558
+ (function(FocusBehaviorRecursive) {
24559
+ FocusBehaviorRecursive[FocusBehaviorRecursive["Inherited"] = 0] = "Inherited";
24560
+ FocusBehaviorRecursive[FocusBehaviorRecursive["Disabled"] = 1] = "Disabled";
24561
+ FocusBehaviorRecursive[FocusBehaviorRecursive["Enabled"] = 2] = "Enabled";
24562
+ })(FocusBehaviorRecursive || (FocusBehaviorRecursive = {}));
24563
+ var KeyLocation;
24564
+ (function(KeyLocation) {
24565
+ KeyLocation[KeyLocation["Unspecified"] = 0] = "Unspecified";
24566
+ KeyLocation[KeyLocation["Left"] = 1] = "Left";
24567
+ KeyLocation[KeyLocation["Right"] = 2] = "Right";
24568
+ })(KeyLocation || (KeyLocation = {}));
24569
+ var CursorShape;
24570
+ (function(CursorShape) {
24571
+ CursorShape[CursorShape["Arrow"] = 0] = "Arrow";
24572
+ CursorShape[CursorShape["Ibeam"] = 1] = "Ibeam";
24573
+ CursorShape[CursorShape["PointingHand"] = 2] = "PointingHand";
24574
+ CursorShape[CursorShape["Cross"] = 3] = "Cross";
24575
+ CursorShape[CursorShape["Wait"] = 4] = "Wait";
24576
+ CursorShape[CursorShape["Busy"] = 5] = "Busy";
24577
+ CursorShape[CursorShape["Drag"] = 6] = "Drag";
24578
+ CursorShape[CursorShape["CanDrop"] = 7] = "CanDrop";
24579
+ CursorShape[CursorShape["Forbidden"] = 8] = "Forbidden";
24580
+ CursorShape[CursorShape["Vsize"] = 9] = "Vsize";
24581
+ CursorShape[CursorShape["Hsize"] = 10] = "Hsize";
24582
+ CursorShape[CursorShape["Bdiagsize"] = 11] = "Bdiagsize";
24583
+ CursorShape[CursorShape["Fdiagsize"] = 12] = "Fdiagsize";
24584
+ CursorShape[CursorShape["Move"] = 13] = "Move";
24585
+ CursorShape[CursorShape["Vsplit"] = 14] = "Vsplit";
24586
+ CursorShape[CursorShape["Hsplit"] = 15] = "Hsplit";
24587
+ CursorShape[CursorShape["Help"] = 16] = "Help";
24588
+ })(CursorShape || (CursorShape = {}));
24589
+
24590
+ function _get_prototype_of(o) {
24591
+ _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
24592
+ return o.__proto__ || Object.getPrototypeOf(o);
24446
24593
  };
24447
- _proto.removeFromComposition = function removeFromComposition() {
24448
- var _this_item_composition;
24449
- var canvasLayers = (_this_item_composition = this.item.composition) == null ? void 0 : _this_item_composition.canvasLayers;
24450
- if (canvasLayers) {
24451
- removeItem(canvasLayers, this);
24594
+ return _get_prototype_of(o);
24595
+ }
24596
+
24597
+ function _is_native_function(fn) {
24598
+ return Function.toString.call(fn).indexOf("[native code]") !== -1;
24599
+ }
24600
+
24601
+ function _wrap_native_super(Class) {
24602
+ var _cache = typeof Map === "function" ? new Map() : undefined;
24603
+ _wrap_native_super = function _wrap_native_super(Class) {
24604
+ if (Class === null || !_is_native_function(Class)) return Class;
24605
+ if (typeof Class !== "function") throw new TypeError("Super expression must either be null or a function");
24606
+ if (typeof _cache !== "undefined") {
24607
+ if (_cache.has(Class)) return _cache.get(Class);
24608
+ _cache.set(Class, Wrapper);
24452
24609
  }
24453
- };
24454
- _proto.refreshCanvasItemsLayer = function refreshCanvasItemsLayer() {
24455
- // CanvasLayer 失效时,让其下挂的 CanvasItem 重新查找归属层
24456
- // 拷贝一份避免迭代过程中数组被修改
24457
- var items = this.canvasItems.slice();
24458
- this.canvasItems.length = 0;
24459
- for(var _iterator = _create_for_of_iterator_helper_loose(items), _step; !(_step = _iterator()).done;){
24460
- var canvasItem = _step.value;
24461
- canvasItem.updateCanvasLayer();
24610
+ function Wrapper() {
24611
+ return _construct(Class, arguments, _get_prototype_of(this).constructor);
24462
24612
  }
24463
- };
24464
- /**
24465
- * 绘制当前层
24466
- *
24467
- * 遍历顶层 CanvasItem 进行绘制,由 CanvasItem.drawInternal 内部递归子节点。
24468
- * 整棵跳过看 `vfxItem.isActive`(item 级开关);self 自身是否画由 drawInternal 内的 `component.enabled` 决定。
24469
- *
24470
- * 注:画布尺寸到 RectTransform.size 的同步目前未在此处处理(由 RectTransform 自身按需 resolve);
24471
- * 后续若需要在每帧强制刷新顶层 size,可在此处补回写入与 sizeChanged 传播
24472
- *
24473
- * @internal
24474
- */ _proto.draw = function draw() {
24475
- for(var _iterator = _create_for_of_iterator_helper_loose(this.canvasItems), _step; !(_step = _iterator()).done;){
24476
- var canvasItem = _step.value;
24477
- if (!canvasItem.item.isActive) {
24478
- continue;
24613
+ Wrapper.prototype = Object.create(Class.prototype, {
24614
+ constructor: {
24615
+ value: Wrapper,
24616
+ enumerable: false,
24617
+ writable: true,
24618
+ configurable: true
24479
24619
  }
24480
- canvasItem.drawInternal();
24481
- }
24620
+ });
24621
+ return _set_prototype_of(Wrapper, Class);
24482
24622
  };
24483
- return CanvasLayer;
24484
- }(Component);
24623
+ return _wrap_native_super(Class);
24624
+ }
24485
24625
 
24486
- /**
24487
- * 画布元素组件
24488
- *
24489
- * 进入场景树时沿父链向上查找最近的 CanvasLayer 祖先并注册自己;
24490
- * 父级改变或自身销毁时,刷新 / 注销在所属 CanvasLayer 的登记。
24491
- *
24492
- * 注:拓扑(parent / children / 所属 layer)与 enabled/active 解耦
24493
- * `component.enabled=false` 仅让自身 draw 被跳过,**不**改父子关系,也**不**从 layer 注销;
24494
- * 整棵子树的隐藏由 `vfxItem.setActive(false)` 配合 drawInternal 中的 `isActive` 检查处理
24495
- */ var CanvasItem = /*#__PURE__*/ function(Component) {
24496
- _inherits(CanvasItem, Component);
24497
- function CanvasItem() {
24498
- var _this;
24499
- _this = Component.apply(this, arguments) || this;
24500
- /**
24501
- * 父 CanvasItem
24502
- * 沿 VFXItem 父链向上查找到的最近的 CanvasItem(只看类型,不看 active/enabled — 拓扑跟激活状态解耦)。
24503
- * 若不存在 CanvasItem 祖先(即直属于 CanvasLayer 或处于游离状态),该值为 null。
24504
- */ _this.parent = null;
24505
- /**
24506
- * 子 CanvasItem 列表(按注册顺序)
24507
- * 由子节点在维护自身 parent 时反向写入,draw 时按数组顺序递归绘制
24508
- */ _this.children = [];
24509
- /**
24510
- * 当前所属的 CanvasLayer,未注册到任何 CanvasLayer 时为 null
24511
- */ _this.canvasLayerNode = null;
24512
- return _this;
24626
+ function transformPoint(transform, value) {
24627
+ var elements = transform.elements;
24628
+ return new Vector2(elements[0] * value.x + elements[3] * value.y + elements[6], elements[1] * value.x + elements[4] * value.y + elements[7]);
24629
+ }
24630
+ function transformVector(transform, value) {
24631
+ var elements = transform.elements;
24632
+ return new Vector2(elements[0] * value.x + elements[3] * value.y, elements[1] * value.x + elements[4] * value.y);
24633
+ }
24634
+ var InputEvent = /*#__PURE__*/ function() {
24635
+ function InputEvent() {
24636
+ this.device = 0;
24637
+ this.pressed = false;
24638
+ this.canceled = false;
24513
24639
  }
24514
- var _proto = CanvasItem.prototype;
24515
- _proto.onEnable = function onEnable() {
24516
- // 首次接入 / 重新接入场景树时把自己挂上(若拓扑还没建立)。
24517
- // 注意 enable/disable 不再改变 CanvasItem 父子拓扑 — 拓扑由 VFXItem 父链(setParent / onParentChanged)维护,
24518
- // enable 在这里只是兜底首次入树
24519
- this.updateCanvasLayer();
24520
- this.updateParentItem();
24521
- };
24522
- _proto.onDisable = function onDisable() {
24523
- // 组件禁用 = 仅 self.draw 跳过,不应改父子拓扑(否则 enable 回来位置就乱了)。
24524
- // 整棵子树的隐藏由 `vfxItem.setActive(false)` 配合 drawInternal 中的 `item.isActive` 检查处理
24640
+ var _proto = InputEvent.prototype;
24641
+ _proto.isPressed = function isPressed() {
24642
+ return this.pressed && !this.canceled;
24525
24643
  };
24526
- _proto.onParentChanged = function onParentChanged() {
24527
- // VFXItem 的父级(或间接父级)发生变化时,CanvasLayer 与父 CanvasItem 都可能改变,需要联动刷新
24528
- this.updateCanvasLayer();
24529
- this.updateParentItem();
24644
+ _proto.isReleased = function isReleased() {
24645
+ return !this.pressed && !this.canceled;
24530
24646
  };
24531
- _proto.onDestroy = function onDestroy() {
24532
- this.removeFromParent();
24533
- this.removeFromCanvasLayer();
24534
- // 防止子 canvasItem updateParentItem 的时候继续找到当前已销毁的 canvasItem
24535
- this.enabled = false;
24536
- this.updateChildrenParentItems();
24647
+ _proto.isCanceled = function isCanceled() {
24648
+ return this.canceled;
24537
24649
  };
24538
- /**
24539
- * 重新计算并更新当前 CanvasItem 应归属的 CanvasLayer
24540
- * 在父级变化、所在 CanvasLayer 失效等场景中调用
24541
- *
24542
- * 仅当自身是顶层 CanvasItem(parent 为 null)时才会登记到 CanvasLayer.canvasItems;
24543
- * 嵌套的子 CanvasItem 仅记录 canvasLayerNode 引用,不进入 layer 的顶层列表。
24544
- * @internal
24545
- */ _proto.updateCanvasLayer = function updateCanvasLayer() {
24546
- // 拓扑跟 enabled/active 解耦,只看 item 是否还在
24547
- if (!this.item) {
24548
- this.removeFromCanvasLayer();
24549
- return;
24550
- }
24551
- var newLayer = this.getCanvasLayerNode();
24552
- if (newLayer === this.canvasLayerNode) {
24553
- return;
24554
- }
24555
- // 仅当自身是顶层 CanvasItem 时,才需要在 layer 的 canvasItems 中迁移
24556
- if (this.parent === null && this.canvasLayerNode) {
24557
- this.canvasLayerNode.removeCanvasItem(this);
24558
- }
24559
- this.canvasLayerNode = newLayer;
24560
- if (this.parent === null && newLayer) {
24561
- newLayer.addCanvasItem(this);
24562
- }
24563
- };
24564
- /**
24565
- * 重新计算并更新当前 CanvasItem 的父 CanvasItem
24566
- * 在 VFXItem 父级变化、自身启用/禁用、父 CanvasItem 失效等场景中调用
24567
- *
24568
- * parent 的变化会同步影响在 CanvasLayer.canvasItems 中的归属:
24569
- * - 由有 parent 变成无 parent 且仍归属某 layer:加入 layer.canvasItems
24570
- * - 由无 parent 变成有 parent:从 layer.canvasItems 中移除
24571
- * @internal
24572
- */ _proto.updateParentItem = function updateParentItem() {
24573
- // 拓扑跟 enabled/active 解耦,只看 item 是否还在
24574
- if (!this.item) {
24575
- this.removeFromParent();
24576
- return;
24577
- }
24578
- var newParent = this.getParentItem();
24579
- if (newParent === this.parent) {
24580
- return;
24581
- }
24582
- var wasTopLevel = this.parent === null;
24583
- this.removeFromParent();
24584
- if (newParent) {
24585
- this.parent = newParent;
24586
- newParent.children.push(this);
24587
- // 由顶层变成嵌套:从 layer 的顶层列表中移除
24588
- if (wasTopLevel && this.canvasLayerNode) {
24589
- this.canvasLayerNode.removeCanvasItem(this);
24590
- }
24591
- } else if (!wasTopLevel && this.canvasLayerNode) {
24592
- // 由嵌套变成顶层:加入 layer 的顶层列表
24593
- this.canvasLayerNode.addCanvasItem(this);
24594
- }
24595
- };
24596
- /**
24597
- * 绘制函数
24598
- * 子类重写此方法以输出实际的绘制内容;调用时 graphics 的变换栈顶已经累积了从根到当前节点的所有父变换,
24599
- * 子类直接使用 this.drawXxx / this.fillXxx 系列封装方法绘制即可,绘制坐标视为本地坐标。
24600
- */ _proto.draw = function draw() {
24601
- // OVERRIDE
24602
- };
24603
- /**
24604
- * 绘制单条线段
24605
- * @param x1 - 起点 x
24606
- * @param y1 - 起点 y
24607
- * @param x2 - 终点 x
24608
- * @param y2 - 终点 y
24609
- * @param color - 线条颜色
24610
- * @param thickness - 线宽
24611
- */ _proto.drawLine = function drawLine(x1, y1, x2, y2, color, thickness) {
24612
- this.engine.graphics.drawLine(x1, y1, x2, y2, color, thickness);
24613
- };
24614
- /**
24615
- * 按顺序连接所有点绘制折线(首尾相同则视为闭合)
24616
- * @param points - 点数组,格式 [x1,y1,x2,y2,...]
24617
- * @param color - 线条颜色
24618
- * @param thickness - 线宽
24619
- */ _proto.drawPolyline = function drawPolyline(points, color, thickness) {
24620
- this.engine.graphics.drawLines(points, color, thickness);
24621
- };
24622
- /**
24623
- * 绘制三次贝塞尔曲线
24624
- */ _proto.drawBezier = function drawBezier(x1, y1, x2, y2, x3, y3, x4, y4, color, thickness) {
24625
- this.engine.graphics.drawBezier(x1, y1, x2, y2, x3, y3, x4, y4, color, thickness);
24626
- };
24627
- /**
24628
- * 绘制三角形边框
24629
- */ _proto.drawTriangle = function drawTriangle(x1, y1, x2, y2, x3, y3, color, thickness) {
24630
- this.engine.graphics.drawTriangle(x1, y1, x2, y2, x3, y3, color, thickness);
24631
- };
24632
- /**
24633
- * 绘制矩形边框
24634
- * @param x - 矩形左下角 x 坐标
24635
- * @param y - 矩形左下角 y 坐标
24636
- */ _proto.drawRect = function drawRect(x, y, width, height, color, thickness) {
24637
- this.engine.graphics.drawRectangle(x, y, width, height, color, thickness);
24638
- };
24639
- /**
24640
- * 绘制圆形边框
24641
- */ _proto.drawCircle = function drawCircle(cx, cy, radius, color, thickness) {
24642
- this.engine.graphics.drawCircle(cx, cy, radius, color, thickness);
24643
- };
24644
- /**
24645
- * 绘制填充三角形
24646
- */ _proto.fillTriangle = function fillTriangle(x1, y1, x2, y2, x3, y3, color) {
24647
- this.engine.graphics.fillTriangle(x1, y1, x2, y2, x3, y3, color);
24648
- };
24649
- /**
24650
- * 绘制填充矩形
24651
- * @param x - 矩形左下角 x 坐标
24652
- * @param y - 矩形左下角 y 坐标
24653
- */ _proto.fillRect = function fillRect(x, y, width, height, color) {
24654
- this.engine.graphics.fillRectangle(x, y, width, height, color);
24655
- };
24656
- /**
24657
- * 绘制填充圆形
24658
- */ _proto.fillCircle = function fillCircle(cx, cy, radius, color) {
24659
- this.engine.graphics.fillCircle(cx, cy, radius, color);
24660
- };
24661
- /**
24662
- * 绘制纹理矩形(本地坐标,Y 向上,(x, y) 为左下角)
24663
- * @param region - 纹理 UV 子矩形,默认全图。Y 向上,(u0, v0) 为左下角 UV
24664
- * @param color - 乘色,默认白色
24665
- */ _proto.drawTexture = function drawTexture(x, y, width, height, texture, region, color) {
24666
- this.engine.graphics.drawTexture(x, y, width, height, texture, region, color);
24667
- };
24668
- /**
24669
- * 绘制文本(本地坐标,Y 向上,(x, y) 为文本左下角)。
24670
- *
24671
- * 同一段文本不同颜色不会重复 upload — 颜色由 `color` 参数透传作为乘色,纹理只缓存白色字形。
24672
- * 字体参数全部展开,避免调用方每帧创建临时 style 对象触发 GC
24673
- */ _proto.drawText = function drawText(x, y, text, fontSize, color, fontFamily, fontWeight, fontStyle) {
24674
- this.engine.graphics.drawText(x, y, text, fontSize, color, fontFamily, fontWeight, fontStyle);
24675
- };
24676
- /**
24677
- * 绘制自身并按 children 数组顺序递归绘制所有子 CanvasItem。
24678
- * @internal
24679
- */ _proto.drawInternal = function drawInternal() {
24680
- var graphics = this.engine.graphics;
24681
- var localMatrix2D = this.transform.getMatrix2D();
24682
- graphics.pushTransform(localMatrix2D);
24683
- // self 是否绘制只看 component.enabled — 其它都不影响。
24684
- // transform 始终被 push,children 始终被遍历,这样 component.enabled=false 时 self 隐藏
24685
- // 但 children 的位置不受影响
24686
- if (this.enabled) {
24687
- this.draw();
24688
- }
24689
- // 子是否参与绘制看 VFXItem.isActive(整棵跳过的语义)。
24690
- // 子自身的 component.enabled 在它自己的 drawInternal 里再判断
24691
- for(var _iterator = _create_for_of_iterator_helper_loose(this.children), _step; !(_step = _iterator()).done;){
24692
- var child = _step.value;
24693
- if (!child.item.isActive) {
24694
- continue;
24695
- }
24696
- child.drawInternal();
24697
- }
24698
- graphics.popTransform();
24699
- };
24700
- /**
24701
- * 从当前所属的 CanvasLayer 注销自身(如果有)
24702
- * 仅当自身是顶层 CanvasItem 时,才会触发 layer 顶层列表的移除
24703
- */ _proto.removeFromCanvasLayer = function removeFromCanvasLayer() {
24704
- if (!this.canvasLayerNode) {
24705
- return;
24706
- }
24707
- if (this.parent === null) {
24708
- this.canvasLayerNode.removeCanvasItem(this);
24709
- }
24710
- this.canvasLayerNode = null;
24711
- };
24712
- /**
24713
- * 从当前父 CanvasItem 的 children 中移除自身(如果有)
24714
- */ _proto.removeFromParent = function removeFromParent() {
24715
- if (!this.parent) {
24716
- return;
24717
- }
24718
- removeItem(this.parent.children, this);
24719
- this.parent = null;
24720
- };
24721
- /**
24722
- * 更新所有子 CanvasItem 的层级归属。
24723
- * 自身失效时调用,子节点会跳过自己向上找到新的父 CanvasItem(可能为 null)。
24724
- */ _proto.updateChildrenParentItems = function updateChildrenParentItems() {
24725
- if (this.children.length === 0) {
24726
- return;
24727
- }
24728
- // 拷贝避免迭代过程中数组被 removeFromParent 修改
24729
- var snapshot = this.children.slice();
24730
- for(var _iterator = _create_for_of_iterator_helper_loose(snapshot), _step; !(_step = _iterator()).done;){
24731
- var child = _step.value;
24732
- child.updateParentItem();
24733
- }
24734
- };
24735
- /**
24736
- * 沿父链向上查找最近的 CanvasLayer 祖先
24737
- * 注意:自身所在 VFXItem 上的 CanvasLayer 也参与查找(同节点上可能并存 CanvasLayer 与 CanvasItem)
24738
- */ _proto.getCanvasLayerNode = function getCanvasLayerNode() {
24739
- var current = this.item;
24740
- while(current){
24741
- var layer = getCanvasLayerFromItem(current);
24742
- if (layer) {
24743
- return layer;
24744
- }
24745
- var _current_parent;
24746
- current = (_current_parent = current.parent) != null ? _current_parent : null;
24747
- }
24748
- return null;
24650
+ _proto.isEcho = function isEcho() {
24651
+ return false;
24749
24652
  };
24750
- /**
24751
- * 沿 VFXItem 父链向上查找最近的 CanvasItem 祖先(不包含自身,只看类型不看 active/enabled)
24752
- */ _proto.getParentItem = function getParentItem() {
24753
- var _this_item;
24754
- var _this_item_parent;
24755
- var current = (_this_item_parent = (_this_item = this.item) == null ? void 0 : _this_item.parent) != null ? _this_item_parent : null;
24756
- while(current){
24757
- var canvasItem = getCanvasItemFromItem(current);
24758
- if (canvasItem) {
24759
- return canvasItem;
24760
- }
24761
- var _current_parent;
24762
- current = (_current_parent = current.parent) != null ? _current_parent : null;
24763
- }
24764
- return null;
24653
+ _proto.xformedBy = function xformedBy(transform) {
24654
+ var event = new InputEvent();
24655
+ event.device = this.device;
24656
+ event.pressed = this.pressed;
24657
+ event.canceled = this.canceled;
24658
+ return event;
24765
24659
  };
24766
- _create_class(CanvasItem, [
24767
- {
24768
- key: "canvasLayer",
24769
- get: /**
24770
- * 获取当前所属的 CanvasLayer
24771
- */ function get() {
24772
- return this.canvasLayerNode;
24773
- }
24774
- }
24775
- ]);
24776
- return CanvasItem;
24777
- }(Component);
24778
- /**
24779
- * 在指定 VFXItem 上查找一个激活的 CanvasLayer 组件
24780
- */ function getCanvasLayerFromItem(item) {
24781
- for(var _iterator = _create_for_of_iterator_helper_loose(item.components), _step; !(_step = _iterator()).done;){
24782
- var component = _step.value;
24783
- if (_instanceof1(component, CanvasLayer) && component.isActiveAndEnabled) {
24784
- return component;
24785
- }
24660
+ return InputEvent;
24661
+ }();
24662
+ InputEvent.deviceIdEmulation = -1;
24663
+ InputEvent.deviceIdInternal = -2;
24664
+ InputEvent.deviceIdKeyboard = 16;
24665
+ InputEvent.deviceIdMouse = 32;
24666
+ var InputEventWithModifiers = /*#__PURE__*/ function(InputEvent) {
24667
+ _inherits(InputEventWithModifiers, InputEvent);
24668
+ function InputEventWithModifiers() {
24669
+ var _this;
24670
+ _this = InputEvent.apply(this, arguments) || this;
24671
+ _this.commandOrControlAutoremap = false;
24672
+ _this.shiftPressed = false;
24673
+ _this.altPressed = false;
24674
+ _this.metaPressed = false;
24675
+ _this.ctrlPressed = false;
24676
+ return _this;
24786
24677
  }
24787
- return null;
24788
- }
24789
- /**
24790
- * 在指定 VFXItem 上查找 CanvasItem 组件(只看类型,不看 active/enabled — 拓扑跟激活状态解耦)
24791
- */ function getCanvasItemFromItem(item) {
24792
- for(var _iterator = _create_for_of_iterator_helper_loose(item.components), _step; !(_step = _iterator()).done;){
24793
- var component = _step.value;
24794
- if (_instanceof1(component, CanvasItem)) {
24795
- return component;
24796
- }
24678
+ var _proto = InputEventWithModifiers.prototype;
24679
+ _proto.copyModifiersTo = function copyModifiersTo(event) {
24680
+ event.device = this.device;
24681
+ event.pressed = this.pressed;
24682
+ event.canceled = this.canceled;
24683
+ event.commandOrControlAutoremap = this.commandOrControlAutoremap;
24684
+ event.shiftPressed = this.shiftPressed;
24685
+ event.altPressed = this.altPressed;
24686
+ event.metaPressed = this.metaPressed;
24687
+ event.ctrlPressed = this.ctrlPressed;
24688
+ };
24689
+ _proto.xformedBy = function xformedBy(transform) {
24690
+ var event = new InputEventWithModifiers();
24691
+ this.copyModifiersTo(event);
24692
+ return event;
24693
+ };
24694
+ return InputEventWithModifiers;
24695
+ }(_wrap_native_super(InputEvent));
24696
+ var InputEventKey = /*#__PURE__*/ function(InputEventWithModifiers) {
24697
+ _inherits(InputEventKey, InputEventWithModifiers);
24698
+ function InputEventKey() {
24699
+ var _this;
24700
+ _this = InputEventWithModifiers.apply(this, arguments) || this;
24701
+ _this.keycode = "";
24702
+ _this.physicalKeycode = "";
24703
+ _this.keyLabel = "";
24704
+ _this.unicode = 0;
24705
+ _this.location = KeyLocation.Unspecified;
24706
+ _this.echo = false;
24707
+ return _this;
24797
24708
  }
24798
- return null;
24799
- }
24800
-
24801
- /**
24802
- * 16 preset 对应的 anchorMin / anchorMax(Y 向上)
24803
- */ var ANCHOR_PRESET_TABLE = {
24804
- // [anchorMin.x, anchorMin.y, anchorMax.x, anchorMax.y]
24709
+ var _proto = InputEventKey.prototype;
24710
+ _proto.isEcho = function isEcho() {
24711
+ return this.echo;
24712
+ };
24713
+ _proto.xformedBy = function xformedBy(transform) {
24714
+ var event = new InputEventKey();
24715
+ this.copyModifiersTo(event);
24716
+ event.keycode = this.keycode;
24717
+ event.physicalKeycode = this.physicalKeycode;
24718
+ event.keyLabel = this.keyLabel;
24719
+ event.unicode = this.unicode;
24720
+ event.location = this.location;
24721
+ event.echo = this.echo;
24722
+ return event;
24723
+ };
24724
+ return InputEventKey;
24725
+ }(InputEventWithModifiers);
24726
+ var InputEventMouse = /*#__PURE__*/ function(InputEventWithModifiers) {
24727
+ _inherits(InputEventMouse, InputEventWithModifiers);
24728
+ function InputEventMouse() {
24729
+ var _this;
24730
+ _this = InputEventWithModifiers.apply(this, arguments) || this;
24731
+ _this.buttonMask = MouseButtonMask.None;
24732
+ _this.position = new Vector2();
24733
+ _this.globalPosition = new Vector2();
24734
+ return _this;
24735
+ }
24736
+ var _proto = InputEventMouse.prototype;
24737
+ _proto.copyMouseTo = function copyMouseTo(event) {
24738
+ this.copyModifiersTo(event);
24739
+ event.buttonMask = this.buttonMask;
24740
+ event.position.copyFrom(this.position);
24741
+ event.globalPosition.copyFrom(this.globalPosition);
24742
+ };
24743
+ _proto.xformedBy = function xformedBy(transform) {
24744
+ var event = new InputEventMouse();
24745
+ this.copyMouseTo(event);
24746
+ event.position.copyFrom(transformPoint(transform, this.position));
24747
+ return event;
24748
+ };
24749
+ return InputEventMouse;
24750
+ }(InputEventWithModifiers);
24751
+ var InputEventMouseButton = /*#__PURE__*/ function(InputEventMouse) {
24752
+ _inherits(InputEventMouseButton, InputEventMouse);
24753
+ function InputEventMouseButton() {
24754
+ var _this;
24755
+ _this = InputEventMouse.apply(this, arguments) || this;
24756
+ _this.factor = 1;
24757
+ _this.buttonIndex = MouseButton.None;
24758
+ _this.doubleClick = false;
24759
+ return _this;
24760
+ }
24761
+ var _proto = InputEventMouseButton.prototype;
24762
+ _proto.xformedBy = function xformedBy(transform) {
24763
+ var event = new InputEventMouseButton();
24764
+ this.copyMouseTo(event);
24765
+ event.position.copyFrom(transformPoint(transform, this.position));
24766
+ event.factor = this.factor;
24767
+ event.buttonIndex = this.buttonIndex;
24768
+ event.doubleClick = this.doubleClick;
24769
+ return event;
24770
+ };
24771
+ return InputEventMouseButton;
24772
+ }(InputEventMouse);
24773
+ var InputEventMouseMotion = /*#__PURE__*/ function(InputEventMouse) {
24774
+ _inherits(InputEventMouseMotion, InputEventMouse);
24775
+ function InputEventMouseMotion() {
24776
+ var _this;
24777
+ _this = InputEventMouse.apply(this, arguments) || this;
24778
+ _this.tilt = new Vector2();
24779
+ _this.pressure = 0;
24780
+ _this.relative = new Vector2();
24781
+ _this.screenRelative = new Vector2();
24782
+ _this.velocity = new Vector2();
24783
+ _this.screenVelocity = new Vector2();
24784
+ _this.penInverted = false;
24785
+ return _this;
24786
+ }
24787
+ var _proto = InputEventMouseMotion.prototype;
24788
+ _proto.xformedBy = function xformedBy(transform) {
24789
+ var event = new InputEventMouseMotion();
24790
+ this.copyMouseTo(event);
24791
+ event.position.copyFrom(transformPoint(transform, this.position));
24792
+ event.tilt.copyFrom(this.tilt);
24793
+ event.pressure = this.pressure;
24794
+ event.relative.copyFrom(transformVector(transform, this.relative));
24795
+ event.screenRelative.copyFrom(this.screenRelative);
24796
+ event.velocity.copyFrom(transformVector(transform, this.velocity));
24797
+ event.screenVelocity.copyFrom(this.screenVelocity);
24798
+ event.penInverted = this.penInverted;
24799
+ return event;
24800
+ };
24801
+ return InputEventMouseMotion;
24802
+ }(InputEventMouse);
24803
+ var InputEventScreenTouch = /*#__PURE__*/ function(InputEvent) {
24804
+ _inherits(InputEventScreenTouch, InputEvent);
24805
+ function InputEventScreenTouch() {
24806
+ var _this;
24807
+ _this = InputEvent.apply(this, arguments) || this;
24808
+ _this.index = 0;
24809
+ _this.position = new Vector2();
24810
+ _this.doubleTap = false;
24811
+ return _this;
24812
+ }
24813
+ var _proto = InputEventScreenTouch.prototype;
24814
+ _proto.xformedBy = function xformedBy(transform) {
24815
+ var event = new InputEventScreenTouch();
24816
+ event.device = this.device;
24817
+ event.pressed = this.pressed;
24818
+ event.canceled = this.canceled;
24819
+ event.index = this.index;
24820
+ event.position.copyFrom(transformPoint(transform, this.position));
24821
+ event.doubleTap = this.doubleTap;
24822
+ return event;
24823
+ };
24824
+ return InputEventScreenTouch;
24825
+ }(_wrap_native_super(InputEvent));
24826
+ var InputEventScreenDrag = /*#__PURE__*/ function(InputEvent) {
24827
+ _inherits(InputEventScreenDrag, InputEvent);
24828
+ function InputEventScreenDrag() {
24829
+ var _this;
24830
+ _this = InputEvent.apply(this, arguments) || this;
24831
+ _this.index = 0;
24832
+ _this.position = new Vector2();
24833
+ _this.relative = new Vector2();
24834
+ _this.screenRelative = new Vector2();
24835
+ _this.velocity = new Vector2();
24836
+ _this.screenVelocity = new Vector2();
24837
+ _this.pressure = 0;
24838
+ _this.tilt = new Vector2();
24839
+ _this.penInverted = false;
24840
+ return _this;
24841
+ }
24842
+ var _proto = InputEventScreenDrag.prototype;
24843
+ _proto.xformedBy = function xformedBy(transform) {
24844
+ var event = new InputEventScreenDrag();
24845
+ event.device = this.device;
24846
+ event.pressed = this.pressed;
24847
+ event.canceled = this.canceled;
24848
+ event.index = this.index;
24849
+ event.position.copyFrom(transformPoint(transform, this.position));
24850
+ event.relative.copyFrom(transformVector(transform, this.relative));
24851
+ event.screenRelative.copyFrom(this.screenRelative);
24852
+ event.velocity.copyFrom(transformVector(transform, this.velocity));
24853
+ event.screenVelocity.copyFrom(this.screenVelocity);
24854
+ event.pressure = this.pressure;
24855
+ event.tilt.copyFrom(this.tilt);
24856
+ event.penInverted = this.penInverted;
24857
+ return event;
24858
+ };
24859
+ return InputEventScreenDrag;
24860
+ }(_wrap_native_super(InputEvent));
24861
+
24862
+ var ANCHOR_PRESET_TABLE = {
24805
24863
  topLeft: [
24806
24864
  0,
24807
24865
  1,
@@ -24900,306 +24958,170 @@ FrameComponent = __decorate([
24900
24958
  ]
24901
24959
  };
24902
24960
  /**
24903
- * 锚点布局变换。`RectTransform extends Transform`,在 Transform position/rotation/scale/size/anchor(=pivot 偏移)
24904
- * 之上额外维护 4 边锚点 + 4 边像素偏移,提供 rect 解算与编辑 API。
24905
- *
24906
- * 解算公式(Y 向上,父 vertex 坐标原点 = 父 rect 左下角):
24907
- * ```
24908
- * left = offsetMin.x + anchorMin.x * parentSize.x
24909
- * bottom = offsetMin.y + anchorMin.y * parentSize.y
24910
- * right = offsetMax.x + anchorMax.x * parentSize.x
24911
- * top = offsetMax.y + anchorMax.y * parentSize.y
24912
- * ```
24913
- *
24914
- * 写回 Transform:
24915
- * - `position` ← `(left, bottom)`(rect 左下角,父 vertex 坐标)
24916
- * - `size` ← rect 尺寸
24917
- * - `anchor`(Vector3 像素 pivot 偏移)由用户独立设置,仅作旋转/缩放中心
24918
- *
24919
- * **解算入口** 是 `sizeChanged()` 方法:
24920
- * - 父是 RectTransform → 用 `parent.size` parentSize 解算自身,写回 `position` / `size`
24921
- * - 否则(顶层 / 没父):自身 size 视为权威值(由外部 通常是 CanvasLayer 直接写),不再自解算
24922
- * - 末尾遍历 `children` 中的 RectTransform,直接调它们的 `sizeChanged()`,链式向下传播
24923
- *
24924
- * **重写 `setPosition` / `setSize`** 让其语义变为"用户输入 rect 位置 / 尺寸":
24925
- * - 顶层(无 RectTransform 父):直接写 `super.setPosition / super.setSize`,然后 `sizeChanged` 传播给子节点
24926
- * - 否则:反推 offset 维持当前 anchor,然后 `sizeChanged` 重算并向下传
24927
- */ var RectTransform = /*#__PURE__*/ function(Transform) {
24928
- _inherits(RectTransform, Transform);
24929
- function RectTransform() {
24930
- var _this;
24931
- _this = Transform.apply(this, arguments) || this;
24932
- /**
24933
- * 父 rect 上的归一化最小角 `(anchorLeft, anchorBottom)`
24934
- */ _this.anchorMin = new Vector2(0, 0);
24935
- /**
24936
- * 父 rect 上的归一化最大角 `(anchorRight, anchorTop)`
24937
- */ _this.anchorMax = new Vector2(0, 0);
24938
- /**
24939
- * rect 左/下边相对 anchorMin 锚点的像素偏移 `(offsetLeft, offsetBottom)`
24940
- */ _this.offsetMin = new Vector2(0, 0);
24941
- /**
24942
- * rect 右/上边相对 anchorMax 锚点的像素偏移 `(offsetRight, offsetTop)`
24943
- */ _this.offsetMax = new Vector2(0, 0);
24944
- /**
24945
- * 自身 rect 上的归一化轴心 `(0..1)`,默认 `(0.5, 0.5)`(中心)。两层效果:
24946
- * 1. **Layout**:`setSize` 时 rect 围绕此点对称缩放(pivot=(0.5, 0.5) → 居中扩展;pivot=(0, 0) → 从左下扩展;pivot=(1, 1) → 向左下缩)
24947
- * 2. **矩阵**:`pivot` 自动同步到 `transform.anchor = pivot * size`(像素值,矩阵旋转/缩放中心),
24948
- * 所以旋转/缩放也围绕同一点。`setPivot` 和每次 `sizeChanged`(size 重算后)都会刷新 `transform.anchor`
24949
- */ _this.pivot = new Vector2(0.5, 0.5);
24950
- return _this;
24961
+ * A drawable GUI object. Controls form a tree independent from the VFXItem
24962
+ * scene tree. UIControl is the bridge between both trees.
24963
+ */ var Control = /*#__PURE__*/ function() {
24964
+ function Control(engine) {
24965
+ this.engine = engine;
24966
+ this._parent = null;
24967
+ this._visible = true;
24968
+ this._enabled = true;
24969
+ this._mouseFilter = MouseFilter.Stop;
24970
+ this._mouseBehaviorRecursive = MouseBehaviorRecursive.Inherited;
24971
+ this._focusMode = FocusMode.None;
24972
+ this._focusBehaviorRecursive = FocusBehaviorRecursive.Inherited;
24973
+ this._defaultCursorShape = CursorShape.Arrow;
24974
+ this._rotation = 0;
24975
+ this.transformDirty = true;
24976
+ this.cachedTransform = new Matrix3();
24977
+ this.eventEmitter = new EventEmitter();
24978
+ this.disposed = false;
24979
+ this./** Scene-tree bridge that owns this GUI object, if any. */ owner = null;
24980
+ this.position = new Vector2();
24981
+ this.size = new Vector2(1, 1);
24982
+ this.anchorMin = new Vector2();
24983
+ this.anchorMax = new Vector2();
24984
+ this.offsetMin = new Vector2();
24985
+ this.offsetMax = new Vector2(1, 1);
24986
+ this.pivot = new Vector2(0.5, 0.5);
24987
+ this.scale = new Vector2(1, 1);
24988
+ this.shear = new Vector2();
24989
+ this.mouseForcePassScrollEvents = true;
24990
+ this.clipContents = false;
24951
24991
  }
24952
- var _proto = RectTransform.prototype;
24953
- /**
24954
- * 反序列化:在 `Transform.fromData` 基础上还原 RectTransform 特有的 `pivot` /
24955
- * `anchorMin` / `anchorMax` / `offsetMin` / `offsetMax`。
24956
- *
24957
- * 顺序:
24958
- * 1. `super.fromData` 还原 `position` / `rotation` / `scale` / `size` / `anchor`
24959
- * 2. 若数据有 size,从 `anchor / size` 反推 `pivot`,保持 `anchor = pivot * size` 一致
24960
- * 3. 应用 `anchorMin/Max` / `offsetMin/Max`,每个 setter 末尾会触发 `sizeChanged`
24961
- * 重新解算 rect 与同步 `transform.anchor`
24962
- */ _proto.fromData = function fromData(data) {
24963
- Transform.prototype.fromData.call(this, data);
24964
- if (this.size.x !== 0 && this.size.y !== 0) {
24965
- this.pivot.set(this.anchor.x / this.size.x, this.anchor.y / this.size.y);
24992
+ var _proto = Control.prototype;
24993
+ _proto.on = function on(eventName, listener, options) {
24994
+ this.eventEmitter.on(eventName, listener, options);
24995
+ };
24996
+ _proto.off = function off(eventName, listener) {
24997
+ this.eventEmitter.off(eventName, listener);
24998
+ };
24999
+ _proto.setPosition = function setPosition(x, y, keepOffsets) {
25000
+ if (keepOffsets === void 0) keepOffsets = false;
25001
+ if (this.position.x === x && this.position.y === y) {
25002
+ return;
24966
25003
  }
24967
- // @ts-expect-error spec.TransformData 暂未声明 RectTransform 字段
24968
- if (data.anchorMin) {
24969
- // @ts-expect-error
24970
- this.setAnchorMin(data.anchorMin.x, data.anchorMin.y);
25004
+ var rect = {
25005
+ position: new Vector2(x, y),
25006
+ size: this.size.clone()
25007
+ };
25008
+ if (keepOffsets && this.parent) {
25009
+ this.computeAnchors(rect, this.getParentRect());
25010
+ } else {
25011
+ this.computeOffsets(rect, this.getParentRect());
24971
25012
  }
24972
- // @ts-expect-error
24973
- if (data.anchorMax) {
24974
- // @ts-expect-error
24975
- this.setAnchorMax(data.anchorMax.x, data.anchorMax.y);
25013
+ this.updateLayout();
25014
+ };
25015
+ _proto.setSize = function setSize(width, height) {
25016
+ if (this.size.x === width && this.size.y === height) {
25017
+ return;
24976
25018
  }
24977
- // @ts-expect-error
24978
- if (data.offsetMin) {
24979
- // @ts-expect-error
24980
- this.setOffsetMin(data.offsetMin.x, data.offsetMin.y);
25019
+ var rect = {
25020
+ position: this.position.clone(),
25021
+ size: new Vector2(width, height)
25022
+ };
25023
+ this.computeOffsets(rect, this.getParentRect());
25024
+ this.updateLayout();
25025
+ };
25026
+ _proto.setScale = function setScale(x, y) {
25027
+ if (this.scale.x !== x || this.scale.y !== y) {
25028
+ this.scale.set(x, y);
25029
+ this.markTransformDirty();
24981
25030
  }
24982
- // @ts-expect-error
24983
- if (data.offsetMax) {
24984
- // @ts-expect-error
24985
- this.setOffsetMax(data.offsetMax.x, data.offsetMax.y);
25031
+ };
25032
+ _proto.setRotation = function setRotation(degrees) {
25033
+ if (this._rotation !== degrees) {
25034
+ this._rotation = degrees;
25035
+ this.markTransformDirty();
25036
+ }
25037
+ };
25038
+ _proto.setShear = function setShear(x, y) {
25039
+ if (this.shear.x !== x || this.shear.y !== y) {
25040
+ this.shear.set(x, y);
25041
+ this.markTransformDirty();
25042
+ }
25043
+ };
25044
+ _proto.setPivot = function setPivot(x, y) {
25045
+ if (this.pivot.x !== x || this.pivot.y !== y) {
25046
+ this.pivot.set(x, y);
25047
+ this.markTransformDirty();
24986
25048
  }
24987
25049
  };
24988
- // ── layout-input setters(改完 → sizeChanged 重算)──────
24989
25050
  _proto.setAnchorMin = function setAnchorMin(x, y) {
24990
25051
  if (this.anchorMin.x !== x || this.anchorMin.y !== y) {
24991
- this.anchorMin.x = x;
24992
- this.anchorMin.y = y;
24993
- this.sizeChanged();
25052
+ this.anchorMin.set(x, y);
25053
+ this.updateLayout();
24994
25054
  }
24995
25055
  };
24996
25056
  _proto.setAnchorMax = function setAnchorMax(x, y) {
24997
25057
  if (this.anchorMax.x !== x || this.anchorMax.y !== y) {
24998
- this.anchorMax.x = x;
24999
- this.anchorMax.y = y;
25000
- this.sizeChanged();
25058
+ this.anchorMax.set(x, y);
25059
+ this.updateLayout();
25001
25060
  }
25002
25061
  };
25003
25062
  _proto.setOffsetMin = function setOffsetMin(x, y) {
25004
25063
  if (this.offsetMin.x !== x || this.offsetMin.y !== y) {
25005
- this.offsetMin.x = x;
25006
- this.offsetMin.y = y;
25007
- this.sizeChanged();
25064
+ this.offsetMin.set(x, y);
25065
+ this.updateLayout();
25008
25066
  }
25009
25067
  };
25010
25068
  _proto.setOffsetMax = function setOffsetMax(x, y) {
25011
25069
  if (this.offsetMax.x !== x || this.offsetMax.y !== y) {
25012
- this.offsetMax.x = x;
25013
- this.offsetMax.y = y;
25014
- this.sizeChanged();
25015
- }
25016
- };
25017
- /**
25018
- * 设置 rect 内的归一化轴心 `(0..1)`,同时把 `transform.anchor`(矩阵旋转/缩放中心)同步到 `pivot * size`。
25019
- * 不重算 rect(pivot 只决定 setSize 行为,不直接影响当前 rect 位置 / 尺寸)
25020
- */ _proto.setPivot = function setPivot(x, y) {
25021
- if (this.pivot.x !== x || this.pivot.y !== y) {
25022
- this.pivot.x = x;
25023
- this.pivot.y = y;
25024
- // 同步 transform.anchor(像素 pivot)= pivot * size,让旋转/缩放绕同一点
25025
- this.anchor.set(this.pivot.x * this.size.x, this.pivot.y * this.size.y, this.anchor.z);
25070
+ this.offsetMax.set(x, y);
25071
+ this.updateLayout();
25026
25072
  }
25027
25073
  };
25028
- /**
25029
- * 重写父类 `setPosition`:
25030
- * - 顶层(无 RectTransform 父):直接 `super.setPosition` 写位置,触发 `sizeChanged` 传播
25031
- * - 非顶层:语义为"设置 rect 左下角到 (x, y)",反推 offset 维持当前 anchor,然后 `sizeChanged` 重算
25032
- *
25033
- * @param keepOffsets - 默认 false。true 时反推 anchor 而非 offset(rect 在屏幕上不动,但 anchor 比例改变)
25034
- */ _proto.setPosition = function setPosition(x, y, z, keepOffsets) {
25035
- if (keepOffsets === void 0) keepOffsets = false;
25036
- if (!_instanceof1(this.parentTransform, RectTransform)) {
25037
- // 顶层:直接写,然后传播给子节点
25038
- Transform.prototype.setPosition.call(this, x, y, z);
25039
- this.sizeChanged();
25040
- return;
25041
- }
25042
- var parentRect = {
25043
- position: new Vector2(0, 0),
25044
- size: this.parentTransform.size.clone()
25045
- };
25046
- var newRect = {
25047
- position: new Vector2(x, y),
25048
- size: this.size.clone()
25049
- };
25050
- if (keepOffsets) {
25051
- this.computeAnchors(newRect, parentRect);
25052
- } else {
25053
- this.computeOffsets(newRect, parentRect);
25054
- }
25055
- this.sizeChanged();
25056
- if (this.position.z !== z) {
25057
- Transform.prototype.setPosition.call(this, this.position.x, this.position.y, z);
25058
- }
25059
- };
25060
- /**
25061
- * 重写父类 `setSize`:
25062
- * - 顶层:直接 `super.setSize`,触发 `sizeChanged` 传播
25063
- * - 非顶层:反推 offset 维持当前 anchor,然后 `sizeChanged` 重算
25064
- */ _proto.setSize = function setSize(x, y) {
25065
- if (this.size.x === x && this.size.y === y) {
25066
- return;
25067
- }
25068
- if (!_instanceof1(this.parentTransform, RectTransform)) {
25069
- Transform.prototype.setSize.call(this, x, y);
25070
- this.sizeChanged();
25071
- return;
25072
- }
25073
- // 围绕 pivot 对称缩放:Δsize 在 offsetMin / offsetMax 上按 pivot / (1-pivot) 比例分配。
25074
- // 例如 pivot=(0.5, 0.5) → 两边各 ±Δ/2,rect 居中扩展;pivot=(0, 0) → offsetMin 不动、offsetMax 全吃,rect 从左下扩展
25075
- var dw = x - this.size.x;
25076
- var dh = y - this.size.y;
25077
- this.offsetMin.set(this.offsetMin.x - this.pivot.x * dw, this.offsetMin.y - this.pivot.y * dh);
25078
- this.offsetMax.set(this.offsetMax.x + (1 - this.pivot.x) * dw, this.offsetMax.y + (1 - this.pivot.y) * dh);
25079
- this.sizeChanged();
25080
- };
25081
- // ── rect query ───────────────────────────────────────
25082
- /**
25083
- * 当前自身 rect(在父 vertex 坐标下,Y 向上)。`sizeChanged` 之后才有意义
25084
- */ _proto.getRect = function getRect() {
25074
+ _proto.getRect = function getRect() {
25085
25075
  return {
25086
- position: new Vector2(this.position.x, this.position.y),
25076
+ position: this.position.clone(),
25087
25077
  size: this.size.clone()
25088
25078
  };
25089
25079
  };
25090
- // ── parent linkage ───────────────────────────────────
25091
- /**
25092
- * transform 切换时重算自身布局。子节点链路通过 `Transform.children` 直接访问,无需事件订阅
25093
- * @internal
25094
- */ _proto.onParentTransformChanged = function onParentTransformChanged(_oldParent, _newParent) {
25095
- if (_instanceof1(_oldParent, RectTransform)) {
25096
- this.engine.off("resize", this.onCanvasResize.bind(this));
25097
- }
25098
- if (!_instanceof1(_newParent, RectTransform)) {
25099
- this.onCanvasResize();
25100
- this.engine.on("resize", this.onCanvasResize.bind(this));
25101
- }
25102
- this.sizeChanged();
25103
- };
25104
- _proto.onCanvasResize = function onCanvasResize() {
25105
- var rect = this.engine.canvas.getBoundingClientRect();
25106
- this.setSize(rect.width, rect.height);
25107
- };
25108
- // ── layout solver──────────────
25109
- /**
25110
- * 解算入口:
25111
- *
25112
- * 1. 父是 RectTransform → 从 `parent.size` 求自身 rect,通过 `super.setPosition / super.setSize` 写回
25113
- * (避免触发本类 setPosition / setSize 重写)
25114
- * 2. 顶层(无 RectTransform 父):自身 size 视为权威值(由 CanvasLayer 等外部直接写),不自解算
25115
- * 3. 遍历 `children` 中所有 RectTransform 子节点,直接调它们的 `sizeChanged()` 链式传播
25116
- */ _proto.sizeChanged = function sizeChanged() {
25117
- if (_instanceof1(this.parentTransform, RectTransform)) {
25118
- var parentSize = this.parentTransform.size;
25119
- var left = this.offsetMin.x + this.anchorMin.x * parentSize.x;
25120
- var bottom = this.offsetMin.y + this.anchorMin.y * parentSize.y;
25121
- var right = this.offsetMax.x + this.anchorMax.x * parentSize.x;
25122
- var top = this.offsetMax.y + this.anchorMax.y * parentSize.y;
25123
- Transform.prototype.setPosition.call(this, left, bottom, this.position.z);
25124
- Transform.prototype.setSize.call(this, right - left, top - bottom);
25125
- }
25126
- // size 更新后同步 transform.anchor(矩阵旋转/缩放中心)= pivot * size,跟 setPivot 保持统一
25127
- this.anchor.set(this.pivot.x * this.size.x, this.pivot.y * this.size.y, this.anchor.z);
25128
- for(var _iterator = _create_for_of_iterator_helper_loose(this.children), _step; !(_step = _iterator()).done;){
25129
- var child = _step.value;
25130
- if (_instanceof1(child, RectTransform)) {
25131
- child.sizeChanged();
25132
- }
25133
- }
25134
- };
25135
- /**
25136
- * 给定目标 rect 反推 offsetMin/Max,保持当前 anchor 不变
25137
- */ _proto.computeOffsets = function computeOffsets(rect, parentRect) {
25138
- 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);
25139
- 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);
25140
- };
25141
- /**
25142
- * 给定目标 rect 反推 anchorMin/Max,保持当前 offset 不变。父 size 为 0 的方向不修改
25143
- */ _proto.computeAnchors = function computeAnchors(rect, parentRect) {
25144
- if (parentRect.size.x !== 0) {
25145
- var aMinX = (rect.position.x - parentRect.position.x - this.offsetMin.x) / parentRect.size.x;
25146
- var aMaxX = (rect.position.x + rect.size.x - parentRect.position.x - this.offsetMax.x) / parentRect.size.x;
25147
- this.anchorMin.x = aMinX;
25148
- this.anchorMax.x = aMaxX;
25149
- }
25150
- if (parentRect.size.y !== 0) {
25151
- var aMinY = (rect.position.y - parentRect.position.y - this.offsetMin.y) / parentRect.size.y;
25152
- var aMaxY = (rect.position.y + rect.size.y - parentRect.position.y - this.offsetMax.y) / parentRect.size.y;
25153
- this.anchorMin.y = aMinY;
25154
- this.anchorMax.y = aMaxY;
25155
- }
25156
- };
25157
- // ── preset API ───────────────────────────────────────
25158
- /**
25159
- * 把 anchorMin/Max 设为内建预设。
25160
- * @param keepOffsets - 默认 true:offset 不动,rect 实际位置会跳到新 anchor 计算的位置(要求保留视觉位置请用 setAnchorsAndOffsetsPreset)
25161
- */ _proto.setAnchorsPreset = function setAnchorsPreset(preset, keepOffsets) {
25080
+ _proto.getTransform2D = function getTransform2D() {
25081
+ if (this.transformDirty) {
25082
+ var radians = this._rotation * Math.PI / 180;
25083
+ var sin = Math.sin(radians);
25084
+ var cos = Math.cos(radians);
25085
+ var shearX = Math.tan(Math.max(-89, Math.min(89, this.shear.x)) * Math.PI / 180);
25086
+ var shearY = Math.tan(Math.max(-89, Math.min(89, this.shear.y)) * Math.PI / 180);
25087
+ var a = this.scale.x * (cos - sin * shearY);
25088
+ var b = this.scale.x * (sin + cos * shearY);
25089
+ var c = this.scale.y * (cos * shearX - sin);
25090
+ var d = this.scale.y * (sin * shearX + cos);
25091
+ var pivotX = this.pivot.x * this.size.x;
25092
+ var pivotY = this.pivot.y * this.size.y;
25093
+ var tx = this.position.x + pivotX - a * pivotX - c * pivotY;
25094
+ var ty = this.position.y + pivotY - b * pivotX - d * pivotY;
25095
+ this.cachedTransform.set(a, b, 0, c, d, 0, tx, ty, 1);
25096
+ this.transformDirty = false;
25097
+ }
25098
+ return this.cachedTransform;
25099
+ };
25100
+ _proto.setAnchorsPreset = function setAnchorsPreset(preset, keepOffsets) {
25162
25101
  if (keepOffsets === void 0) keepOffsets = true;
25163
- 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];
25102
+ 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];
25164
25103
  if (keepOffsets) {
25165
- this.anchorMin.set(aMinX, aMinY);
25166
- this.anchorMax.set(aMaxX, aMaxY);
25167
- } else if (_instanceof1(this.parentTransform, RectTransform)) {
25168
- var parentRect = {
25169
- position: new Vector2(0, 0),
25170
- size: this.parentTransform.size.clone()
25171
- };
25172
- var rect = this.getRect();
25173
- this.anchorMin.set(aMinX, aMinY);
25174
- this.anchorMax.set(aMaxX, aMaxY);
25175
- this.computeOffsets(rect, parentRect);
25104
+ this.anchorMin.set(minX, minY);
25105
+ this.anchorMax.set(maxX, maxY);
25176
25106
  } else {
25177
- // 顶层无父 rect 可参考,降级为 keepOffsets
25178
- this.anchorMin.set(aMinX, aMinY);
25179
- this.anchorMax.set(aMaxX, aMaxY);
25107
+ var rect = this.getRect();
25108
+ this.anchorMin.set(minX, minY);
25109
+ this.anchorMax.set(maxX, maxY);
25110
+ this.computeOffsets(rect, this.getParentRect());
25180
25111
  }
25181
- this.sizeChanged();
25112
+ this.updateLayout();
25182
25113
  };
25183
- /**
25184
- * 把 offsetMin/Max 设为预设值,使 rect 在父 rect 内落在视觉上对应的位置(留 margin 像素边距)。
25185
- * 当 anchor 已经按相同 preset 设定时,等价于“贴边放置带 margin 的 rect”。
25186
- * 使用当前 size 作为 rect 尺寸。
25187
- */ _proto.setOffsetsPreset = function setOffsetsPreset(preset, margin) {
25114
+ _proto.setOffsetsPreset = function setOffsetsPreset(preset, margin) {
25188
25115
  if (margin === void 0) margin = 0;
25189
- if (!_instanceof1(this.parentTransform, RectTransform)) {
25116
+ if (!this.parent) {
25190
25117
  return;
25191
25118
  }
25192
- var newSizeX = this.size.x;
25193
- var newSizeY = this.size.y;
25119
+ var parentSize = this.parent.size;
25120
+ var width = this.size.x;
25121
+ var height = this.size.y;
25194
25122
  var a = this.anchorMin;
25195
25123
  var b = this.anchorMax;
25196
- var pw = this.parentTransform.size.x;
25197
- var ph = this.parentTransform.size.y;
25198
- var offMinX = 0;
25199
- var offMaxX = 0;
25200
- var offMinY = 0;
25201
- var offMaxY = 0;
25202
- // X 方向(left / right)
25124
+ var minX = 0, maxX = 0, minY = 0, maxY = 0;
25203
25125
  switch(preset){
25204
25126
  case "topLeft":
25205
25127
  case "bottomLeft":
@@ -25209,25 +25131,21 @@ FrameComponent = __decorate([
25209
25131
  case "leftWide":
25210
25132
  case "hcenterWide":
25211
25133
  case "fullRect":
25212
- offMinX = margin - a.x * pw;
25213
- offMaxX = margin + newSizeX - b.x * pw;
25134
+ minX = margin - a.x * parentSize.x;
25135
+ maxX = margin + width - b.x * parentSize.x;
25214
25136
  break;
25215
25137
  case "centerTop":
25216
25138
  case "centerBottom":
25217
25139
  case "center":
25218
25140
  case "vcenterWide":
25219
- offMinX = 0.5 * pw - newSizeX / 2 - a.x * pw;
25220
- offMaxX = 0.5 * pw + newSizeX / 2 - b.x * pw;
25141
+ minX = 0.5 * parentSize.x - width / 2 - a.x * parentSize.x;
25142
+ maxX = 0.5 * parentSize.x + width / 2 - b.x * parentSize.x;
25221
25143
  break;
25222
- case "topRight":
25223
- case "bottomRight":
25224
- case "centerRight":
25225
- case "rightWide":
25226
- offMinX = pw - margin - newSizeX - a.x * pw;
25227
- offMaxX = pw - margin - b.x * pw;
25144
+ default:
25145
+ minX = parentSize.x - margin - width - a.x * parentSize.x;
25146
+ maxX = parentSize.x - margin - b.x * parentSize.x;
25228
25147
  break;
25229
25148
  }
25230
- // Y 方向(bottom / top)— Y 向上
25231
25149
  switch(preset){
25232
25150
  case "bottomLeft":
25233
25151
  case "bottomRight":
@@ -25237,91 +25155,1438 @@ FrameComponent = __decorate([
25237
25155
  case "bottomWide":
25238
25156
  case "vcenterWide":
25239
25157
  case "fullRect":
25240
- offMinY = margin - a.y * ph;
25241
- offMaxY = margin + newSizeY - b.y * ph;
25158
+ minY = margin - a.y * parentSize.y;
25159
+ maxY = margin + height - b.y * parentSize.y;
25242
25160
  break;
25243
25161
  case "centerLeft":
25244
25162
  case "centerRight":
25245
25163
  case "center":
25246
25164
  case "hcenterWide":
25247
- offMinY = 0.5 * ph - newSizeY / 2 - a.y * ph;
25248
- offMaxY = 0.5 * ph + newSizeY / 2 - b.y * ph;
25165
+ minY = 0.5 * parentSize.y - height / 2 - a.y * parentSize.y;
25166
+ maxY = 0.5 * parentSize.y + height / 2 - b.y * parentSize.y;
25249
25167
  break;
25250
- case "topLeft":
25251
- case "topRight":
25252
- case "centerTop":
25253
- case "topWide":
25254
- offMinY = ph - margin - newSizeY - a.y * ph;
25255
- offMaxY = ph - margin - b.y * ph;
25168
+ default:
25169
+ minY = parentSize.y - margin - height - a.y * parentSize.y;
25170
+ maxY = parentSize.y - margin - b.y * parentSize.y;
25256
25171
  break;
25257
25172
  }
25258
- this.offsetMin.set(offMinX, offMinY);
25259
- this.offsetMax.set(offMaxX, offMaxY);
25260
- this.sizeChanged();
25173
+ this.offsetMin.set(minX, minY);
25174
+ this.offsetMax.set(maxX, maxY);
25175
+ this.updateLayout();
25261
25176
  };
25262
- /**
25263
- * 同时设置 anchor 和 offset,达到“按 preset 摆放并贴边带 margin”的效果。
25264
- *
25265
- * 注意第一步用 `keepOffsets=false`(反推 offset 维持 rect 视觉位置),不能用默认 `true`:
25266
- * 后者会让 rect 的 size 在中间步先跳到错值(因为 anchor 改了 offset 没改),
25267
- * 第二步 `setOffsetsPreset` 又用这个错 size 算 offset,最终 rect size 不对
25268
- */ _proto.setAnchorsAndOffsetsPreset = function setAnchorsAndOffsetsPreset(preset, margin) {
25177
+ _proto.setAnchorsAndOffsetsPreset = function setAnchorsAndOffsetsPreset(preset, margin) {
25269
25178
  if (margin === void 0) margin = 0;
25270
25179
  this.setAnchorsPreset(preset, false);
25271
25180
  this.setOffsetsPreset(preset, margin);
25272
25181
  };
25273
- /**
25274
- * 用既有 Transform 的状态创建 RectTransform。
25275
- * 用于 Control / CanvasLayer 接管 VFXItem 时,把 VFXItem 自带的 Transform 升级为 RectTransform 而不丢失 position/rotation/scale 等已设置好的状态。
25276
- */ RectTransform.fromTransform = function fromTransform(t) {
25277
- if (_instanceof1(t, RectTransform)) {
25278
- return t;
25182
+ _proto.getGlobalTransform2D = function getGlobalTransform2D() {
25183
+ var local = this.getTransform2D();
25184
+ return this.parent ? new Matrix3().multiplyMatrices(this.parent.getGlobalTransform2D(), local) : local.clone();
25185
+ };
25186
+ _proto.hasPoint = function hasPoint(point) {
25187
+ return point.x >= 0 && point.y >= 0 && point.x <= this.size.x && point.y <= this.size.y;
25188
+ };
25189
+ _proto.getEffectiveMouseFilter = function getEffectiveMouseFilter() {
25190
+ return this.enabledInHierarchy && this.isMouseRecursiveEnabled() ? this.mouseFilter : MouseFilter.Ignore;
25191
+ };
25192
+ _proto.getFocusModeWithOverride = function getFocusModeWithOverride() {
25193
+ return this.enabledInHierarchy && this.isFocusRecursiveEnabled() ? this.focusMode : FocusMode.None;
25194
+ };
25195
+ _proto.getCursorShape = function getCursorShape(position) {
25196
+ return this.defaultCursorShape;
25197
+ };
25198
+ _proto.acceptEvent = function acceptEvent() {
25199
+ var _this_root;
25200
+ (_this_root = this.root) == null ? void 0 : _this_root.acceptControlEvent(this);
25201
+ };
25202
+ _proto.focus = function focus() {
25203
+ var _this_root;
25204
+ (_this_root = this.root) == null ? void 0 : _this_root.grabControlFocus(this);
25205
+ };
25206
+ _proto.grabFocus = function grabFocus() {
25207
+ this.focus();
25208
+ };
25209
+ _proto.grabClickFocus = function grabClickFocus() {
25210
+ var _this_root;
25211
+ (_this_root = this.root) == null ? void 0 : _this_root.grabControlClickFocus(this);
25212
+ };
25213
+ _proto.releaseFocus = function releaseFocus() {
25214
+ var _this_root;
25215
+ (_this_root = this.root) == null ? void 0 : _this_root.releaseControlFocus(this);
25216
+ };
25217
+ _proto.warpMouse = function warpMouse(position) {
25218
+ var _this_root;
25219
+ var matrix = this.getGlobalTransform2D().elements;
25220
+ (_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]));
25221
+ };
25222
+ /** Converts a window-space position into this control's local coordinates. */ _proto.makePositionLocal = function makePositionLocal(position) {
25223
+ var transform = this.getGlobalTransform2D().clone();
25224
+ if (Math.abs(transform.determinant()) < 1e-12) {
25225
+ return new Vector2();
25226
+ }
25227
+ var elements = transform.invert().elements;
25228
+ return new Vector2(elements[0] * position.x + elements[3] * position.y + elements[6], elements[1] * position.x + elements[4] * position.y + elements[7]);
25229
+ };
25230
+ /** Gets the current mouse position transformed into this control's coordinates. */ _proto.getLocalMousePosition = function getLocalMousePosition() {
25231
+ var root = this.root;
25232
+ return root ? this.makePositionLocal(root.getMousePosition()) : new Vector2();
25233
+ };
25234
+ _proto.update = function update(deltaTime) {};
25235
+ _proto.draw = function draw() {
25236
+ // OVERRIDE
25237
+ };
25238
+ _proto.onDestroy = function onDestroy() {};
25239
+ /** @internal */ _proto.drawInternal = function drawInternal() {
25240
+ if (!this.visibleInHierarchy || this.disposed) {
25241
+ return;
25242
+ }
25243
+ var graphics = this.engine.graphics;
25244
+ graphics.pushTransform(this.getTransform2D());
25245
+ this.draw();
25246
+ graphics.popTransform();
25247
+ };
25248
+ _proto.drawLine = function drawLine(x1, y1, x2, y2, color, thickness) {
25249
+ this.engine.graphics.drawLine(x1, y1, x2, y2, color, thickness);
25250
+ };
25251
+ _proto.drawPolyline = function drawPolyline(points, color, thickness) {
25252
+ this.engine.graphics.drawLines(points, color, thickness);
25253
+ };
25254
+ _proto.drawBezier = function drawBezier(x1, y1, x2, y2, x3, y3, x4, y4, color, thickness) {
25255
+ this.engine.graphics.drawBezier(x1, y1, x2, y2, x3, y3, x4, y4, color, thickness);
25256
+ };
25257
+ _proto.drawTriangle = function drawTriangle(x1, y1, x2, y2, x3, y3, color, thickness) {
25258
+ this.engine.graphics.drawTriangle(x1, y1, x2, y2, x3, y3, color, thickness);
25259
+ };
25260
+ _proto.drawRect = function drawRect(x, y, width, height, color, thickness) {
25261
+ this.engine.graphics.drawRectangle(x, y, width, height, color, thickness);
25262
+ };
25263
+ _proto.drawCircle = function drawCircle(cx, cy, radius, color, thickness) {
25264
+ this.engine.graphics.drawCircle(cx, cy, radius, color, thickness);
25265
+ };
25266
+ _proto.fillTriangle = function fillTriangle(x1, y1, x2, y2, x3, y3, color) {
25267
+ this.engine.graphics.fillTriangle(x1, y1, x2, y2, x3, y3, color);
25268
+ };
25269
+ _proto.fillRect = function fillRect(x, y, width, height, color) {
25270
+ this.engine.graphics.fillRectangle(x, y, width, height, color);
25271
+ };
25272
+ _proto.fillCircle = function fillCircle(cx, cy, radius, color) {
25273
+ this.engine.graphics.fillCircle(cx, cy, radius, color);
25274
+ };
25275
+ _proto.drawTexture = function drawTexture(x, y, width, height, texture, region, color) {
25276
+ this.engine.graphics.drawTexture(x, y, width, height, texture, region, color);
25277
+ };
25278
+ _proto.drawText = function drawText(x, y, text, fontSize, color, fontFamily, fontWeight, fontStyle) {
25279
+ this.engine.graphics.drawText(x, y, text, fontSize, color, fontFamily, fontWeight, fontStyle);
25280
+ };
25281
+ _proto.onMouseEnter = function onMouseEnter(location) {};
25282
+ _proto.onMouseMove = function onMouseMove(location, event) {};
25283
+ _proto.onMouseLeave = function onMouseLeave() {};
25284
+ _proto.onMouseWheel = function onMouseWheel(location, delta, event) {};
25285
+ _proto.onMouseDown = function onMouseDown(location, button, event) {};
25286
+ _proto.onMouseUp = function onMouseUp(location, button, event) {};
25287
+ _proto.onTouchDown = function onTouchDown(location, pointerId, event) {};
25288
+ _proto.onTouchMove = function onTouchMove(location, pointerId, event) {};
25289
+ _proto.onTouchUp = function onTouchUp(location, pointerId, event) {};
25290
+ _proto.onKeyDown = function onKeyDown(event) {};
25291
+ _proto.onKeyUp = function onKeyUp(event) {};
25292
+ _proto.onGotFocus = function onGotFocus() {};
25293
+ _proto.onLostFocus = function onLostFocus() {};
25294
+ /** @internal */ _proto.invokeGetDragData = function invokeGetDragData(position) {
25295
+ return this.getDragData(position);
25296
+ };
25297
+ /** @internal */ _proto.invokeCanDropData = function invokeCanDropData(position, data) {
25298
+ return this.canDropData(position, data);
25299
+ };
25300
+ /** @internal */ _proto.invokeDropData = function invokeDropData(position, data) {
25301
+ this.dropData(position, data);
25302
+ };
25303
+ _proto.getDragData = function getDragData(position) {
25304
+ return null;
25305
+ };
25306
+ _proto.canDropData = function canDropData(position, data) {
25307
+ return false;
25308
+ };
25309
+ _proto.dropData = function dropData(position, data) {};
25310
+ _proto.dispose = function dispose() {
25311
+ if (this.disposed) {
25312
+ return;
25313
+ }
25314
+ this.disposed = true;
25315
+ this.onDestroy();
25316
+ this.parent = null;
25317
+ this.owner = null;
25318
+ };
25319
+ /** @internal */ _proto.updateLayout = function updateLayout() {
25320
+ var _this_parent;
25321
+ var _this_parent_size;
25322
+ var parentSize = (_this_parent_size = (_this_parent = this.parent) == null ? void 0 : _this_parent.size) != null ? _this_parent_size : new Vector2();
25323
+ var left = this.offsetMin.x + this.anchorMin.x * parentSize.x;
25324
+ var bottom = this.offsetMin.y + this.anchorMin.y * parentSize.y;
25325
+ var right = this.offsetMax.x + this.anchorMax.x * parentSize.x;
25326
+ var top = this.offsetMax.y + this.anchorMax.y * parentSize.y;
25327
+ this.applyBounds(left, bottom, right - left, top - bottom);
25328
+ };
25329
+ _proto.applyBounds = function applyBounds(x, y, width, height) {
25330
+ var locationChanged = this.position.x !== x || this.position.y !== y;
25331
+ var sizeChanged = this.size.x !== width || this.size.y !== height;
25332
+ if (!locationChanged && !sizeChanged) {
25333
+ return;
25334
+ }
25335
+ this.position.set(x, y);
25336
+ this.size.set(width, height);
25337
+ this.markTransformDirty();
25338
+ if (locationChanged) {
25339
+ this.eventEmitter.emit("locationChanged", this);
25340
+ }
25341
+ if (sizeChanged) {
25342
+ this.eventEmitter.emit("sizeChanged", this);
25343
+ if (_instanceof1(this, ContainerControl)) {
25344
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.children.slice()), _step; !(_step = _iterator()).done;){
25345
+ var child = _step.value;
25346
+ child.updateLayout();
25347
+ }
25348
+ }
25349
+ }
25350
+ };
25351
+ _proto.markTransformDirty = function markTransformDirty() {
25352
+ var _this_root;
25353
+ this.transformDirty = true;
25354
+ (_this_root = this.root) == null ? void 0 : _this_root.controlTreeChanged();
25355
+ };
25356
+ _proto.getParentRect = function getParentRect() {
25357
+ var _this_parent;
25358
+ var _this_parent_size_clone;
25359
+ return {
25360
+ position: new Vector2(),
25361
+ size: (_this_parent_size_clone = (_this_parent = this.parent) == null ? void 0 : _this_parent.size.clone()) != null ? _this_parent_size_clone : new Vector2()
25362
+ };
25363
+ };
25364
+ _proto.computeOffsets = function computeOffsets(rect, parentRect) {
25365
+ 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);
25366
+ 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);
25367
+ };
25368
+ _proto.computeAnchors = function computeAnchors(rect, parentRect) {
25369
+ if (parentRect.size.x !== 0) {
25370
+ this.anchorMin.x = (rect.position.x - parentRect.position.x - this.offsetMin.x) / parentRect.size.x;
25371
+ this.anchorMax.x = (rect.position.x + rect.size.x - parentRect.position.x - this.offsetMax.x) / parentRect.size.x;
25372
+ }
25373
+ if (parentRect.size.y !== 0) {
25374
+ this.anchorMin.y = (rect.position.y - parentRect.position.y - this.offsetMin.y) / parentRect.size.y;
25375
+ this.anchorMax.y = (rect.position.y + rect.size.y - parentRect.position.y - this.offsetMax.y) / parentRect.size.y;
25376
+ }
25377
+ };
25378
+ _proto.isMouseRecursiveEnabled = function isMouseRecursiveEnabled() {
25379
+ if (this.mouseBehaviorRecursive === MouseBehaviorRecursive.Inherited) {
25380
+ var _this_parent;
25381
+ var _this_parent_isMouseRecursiveEnabled;
25382
+ return (_this_parent_isMouseRecursiveEnabled = (_this_parent = this.parent) == null ? void 0 : _this_parent.isMouseRecursiveEnabled()) != null ? _this_parent_isMouseRecursiveEnabled : true;
25383
+ }
25384
+ return this.mouseBehaviorRecursive === MouseBehaviorRecursive.Enabled;
25385
+ };
25386
+ _proto.isFocusRecursiveEnabled = function isFocusRecursiveEnabled() {
25387
+ if (this.focusBehaviorRecursive === FocusBehaviorRecursive.Inherited) {
25388
+ var _this_parent;
25389
+ var _this_parent_isFocusRecursiveEnabled;
25390
+ return (_this_parent_isFocusRecursiveEnabled = (_this_parent = this.parent) == null ? void 0 : _this_parent.isFocusRecursiveEnabled()) != null ? _this_parent_isFocusRecursiveEnabled : true;
25391
+ }
25392
+ return this.focusBehaviorRecursive === FocusBehaviorRecursive.Enabled;
25393
+ };
25394
+ _create_class(Control, [
25395
+ {
25396
+ key: "parent",
25397
+ get: function get() {
25398
+ return this._parent;
25399
+ },
25400
+ set: function set(value) {
25401
+ var _this__parent;
25402
+ if (value === this._parent) {
25403
+ return;
25404
+ }
25405
+ var previousRoot = this.root;
25406
+ (_this__parent = this._parent) == null ? void 0 : _this__parent.removeChildInternal(this);
25407
+ this._parent = value;
25408
+ value == null ? void 0 : value.addChildInternal(this);
25409
+ this.updateLayout();
25410
+ var nextRoot = this.root;
25411
+ if (previousRoot && previousRoot !== nextRoot) {
25412
+ previousRoot.controlRemoved(this);
25413
+ }
25414
+ nextRoot == null ? void 0 : nextRoot.controlTreeChanged();
25415
+ this.eventEmitter.emit("parentChanged", this);
25416
+ }
25417
+ },
25418
+ {
25419
+ key: "item",
25420
+ get: /** Scene item exposed through the optional UIControl bridge. */ function get() {
25421
+ var _this_owner;
25422
+ var _this_owner_item;
25423
+ return (_this_owner_item = (_this_owner = this.owner) == null ? void 0 : _this_owner.item) != null ? _this_owner_item : null;
25424
+ }
25425
+ },
25426
+ {
25427
+ key: "indexInParent",
25428
+ get: function get() {
25429
+ var _this_parent;
25430
+ var _this_parent_getChildIndex;
25431
+ return (_this_parent_getChildIndex = (_this_parent = this.parent) == null ? void 0 : _this_parent.getChildIndex(this)) != null ? _this_parent_getChildIndex : -1;
25432
+ },
25433
+ set: function set(value) {
25434
+ var _this_parent;
25435
+ (_this_parent = this.parent) == null ? void 0 : _this_parent.changeChildIndex(this, value);
25436
+ }
25437
+ },
25438
+ {
25439
+ key: "visible",
25440
+ get: function get() {
25441
+ return this._visible;
25442
+ },
25443
+ set: function set(value) {
25444
+ if (this._visible !== value) {
25445
+ var _this_root;
25446
+ this._visible = value;
25447
+ (_this_root = this.root) == null ? void 0 : _this_root.controlStateChanged(this);
25448
+ }
25449
+ }
25450
+ },
25451
+ {
25452
+ key: "visibleInHierarchy",
25453
+ get: function get() {
25454
+ var _this_parent;
25455
+ var _this_parent_visibleInHierarchy;
25456
+ return this.visible && ((_this_parent_visibleInHierarchy = (_this_parent = this.parent) == null ? void 0 : _this_parent.visibleInHierarchy) != null ? _this_parent_visibleInHierarchy : true);
25457
+ }
25458
+ },
25459
+ {
25460
+ key: "enabled",
25461
+ get: function get() {
25462
+ return this._enabled;
25463
+ },
25464
+ set: function set(value) {
25465
+ if (this._enabled !== value) {
25466
+ var _this_root;
25467
+ this._enabled = value;
25468
+ (_this_root = this.root) == null ? void 0 : _this_root.controlStateChanged(this);
25469
+ }
25470
+ }
25471
+ },
25472
+ {
25473
+ key: "enabledInHierarchy",
25474
+ get: function get() {
25475
+ var _this_parent;
25476
+ var _this_parent_enabledInHierarchy;
25477
+ return this.enabled && ((_this_parent_enabledInHierarchy = (_this_parent = this.parent) == null ? void 0 : _this_parent.enabledInHierarchy) != null ? _this_parent_enabledInHierarchy : true);
25478
+ }
25479
+ },
25480
+ {
25481
+ key: "mouseFilter",
25482
+ get: function get() {
25483
+ return this._mouseFilter;
25484
+ },
25485
+ set: function set(value) {
25486
+ if (this._mouseFilter !== value) {
25487
+ var _this_root;
25488
+ this._mouseFilter = value;
25489
+ (_this_root = this.root) == null ? void 0 : _this_root.controlStateChanged(this);
25490
+ }
25491
+ }
25492
+ },
25493
+ {
25494
+ key: "mouseBehaviorRecursive",
25495
+ get: function get() {
25496
+ return this._mouseBehaviorRecursive;
25497
+ },
25498
+ set: function set(value) {
25499
+ if (this._mouseBehaviorRecursive !== value) {
25500
+ var _this_root;
25501
+ this._mouseBehaviorRecursive = value;
25502
+ (_this_root = this.root) == null ? void 0 : _this_root.controlStateChanged(this);
25503
+ }
25504
+ }
25505
+ },
25506
+ {
25507
+ key: "focusMode",
25508
+ get: function get() {
25509
+ return this._focusMode;
25510
+ },
25511
+ set: function set(value) {
25512
+ if (this._focusMode !== value) {
25513
+ var _this_root;
25514
+ this._focusMode = value;
25515
+ (_this_root = this.root) == null ? void 0 : _this_root.controlStateChanged(this);
25516
+ }
25517
+ }
25518
+ },
25519
+ {
25520
+ key: "focusBehaviorRecursive",
25521
+ get: function get() {
25522
+ return this._focusBehaviorRecursive;
25523
+ },
25524
+ set: function set(value) {
25525
+ if (this._focusBehaviorRecursive !== value) {
25526
+ var _this_root;
25527
+ this._focusBehaviorRecursive = value;
25528
+ (_this_root = this.root) == null ? void 0 : _this_root.controlStateChanged(this);
25529
+ }
25530
+ }
25531
+ },
25532
+ {
25533
+ key: "defaultCursorShape",
25534
+ get: function get() {
25535
+ return this._defaultCursorShape;
25536
+ },
25537
+ set: function set(value) {
25538
+ this._defaultCursorShape = value;
25539
+ }
25540
+ },
25541
+ {
25542
+ key: "location",
25543
+ get: function get() {
25544
+ return this.position;
25545
+ },
25546
+ set: function set(value) {
25547
+ this.setPosition(value.x, value.y);
25548
+ }
25549
+ },
25550
+ {
25551
+ key: "rotation",
25552
+ get: function get() {
25553
+ return this._rotation;
25554
+ }
25555
+ },
25556
+ {
25557
+ key: "x",
25558
+ get: function get() {
25559
+ return this.position.x;
25560
+ },
25561
+ set: function set(value) {
25562
+ this.setPosition(value, this.position.y);
25563
+ }
25564
+ },
25565
+ {
25566
+ key: "y",
25567
+ get: function get() {
25568
+ return this.position.y;
25569
+ },
25570
+ set: function set(value) {
25571
+ this.setPosition(this.position.x, value);
25572
+ }
25573
+ },
25574
+ {
25575
+ key: "width",
25576
+ get: function get() {
25577
+ return this.size.x;
25578
+ },
25579
+ set: function set(value) {
25580
+ this.setSize(value, this.size.y);
25581
+ }
25582
+ },
25583
+ {
25584
+ key: "height",
25585
+ get: function get() {
25586
+ return this.size.y;
25587
+ },
25588
+ set: function set(value) {
25589
+ this.setSize(this.size.x, value);
25590
+ }
25591
+ },
25592
+ {
25593
+ key: "root",
25594
+ get: function get() {
25595
+ var _this_parent;
25596
+ var _this_parent_root;
25597
+ return _instanceof1(this, RootControl) ? this : (_this_parent_root = (_this_parent = this.parent) == null ? void 0 : _this_parent.root) != null ? _this_parent_root : null;
25598
+ }
25599
+ },
25600
+ {
25601
+ key: "isDisposed",
25602
+ get: function get() {
25603
+ return this.disposed;
25604
+ }
25605
+ }
25606
+ ]);
25607
+ return Control;
25608
+ }();
25609
+ /** A Control that owns child Controls. */ var ContainerControl = /*#__PURE__*/ function(Control) {
25610
+ _inherits(ContainerControl, Control);
25611
+ function ContainerControl() {
25612
+ var _this;
25613
+ _this = Control.apply(this, arguments) || this;
25614
+ _this.children = [];
25615
+ return _this;
25616
+ }
25617
+ var _proto = ContainerControl.prototype;
25618
+ _proto.addChild = function addChild(child) {
25619
+ child.parent = this;
25620
+ return child;
25621
+ };
25622
+ _proto.removeChild = function removeChild(child) {
25623
+ if (child.parent === this) {
25624
+ child.parent = null;
25625
+ }
25626
+ };
25627
+ _proto.getChildIndex = function getChildIndex(child) {
25628
+ return this.children.indexOf(child);
25629
+ };
25630
+ /** @internal */ _proto.changeChildIndex = function changeChildIndex(child, newIndex) {
25631
+ var _this_root;
25632
+ var oldIndex = this.children.indexOf(child);
25633
+ if (oldIndex === newIndex || oldIndex === -1) {
25634
+ return;
25635
+ }
25636
+ this.children.splice(oldIndex, 1);
25637
+ if (newIndex < 0 || newIndex >= this.children.length) {
25638
+ this.children.push(child);
25639
+ } else {
25640
+ this.children.splice(newIndex, 0, child);
25641
+ }
25642
+ (_this_root = this.root) == null ? void 0 : _this_root.controlTreeChanged();
25643
+ };
25644
+ /** @internal */ _proto.addChildInternal = function addChildInternal(child) {
25645
+ if (!this.children.includes(child)) {
25646
+ this.children.push(child);
25647
+ }
25648
+ };
25649
+ /** @internal */ _proto.removeChildInternal = function removeChildInternal(child) {
25650
+ var index = this.children.indexOf(child);
25651
+ if (index !== -1) {
25652
+ this.children.splice(index, 1);
25653
+ }
25654
+ };
25655
+ _proto.drawSelf = function drawSelf() {
25656
+ Control.prototype.draw.call(this);
25657
+ };
25658
+ _proto.draw = function draw() {
25659
+ this.drawSelf();
25660
+ this.drawChildren();
25661
+ };
25662
+ _proto.drawChildren = function drawChildren() {
25663
+ var graphics = this.engine.graphics;
25664
+ if (this.clipContents) ;
25665
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.children), _step; !(_step = _iterator()).done;){
25666
+ var child = _step.value;
25667
+ if (!child.visible || child.isDisposed) {
25668
+ continue;
25669
+ }
25670
+ graphics.pushTransform(child.getTransform2D());
25671
+ child.draw();
25672
+ graphics.popTransform();
25673
+ }
25674
+ };
25675
+ _proto.update = function update(deltaTime) {
25676
+ Control.prototype.update.call(this, deltaTime);
25677
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.children.slice()), _step; !(_step = _iterator()).done;){
25678
+ var child = _step.value;
25679
+ if (child.enabled && !child.isDisposed) {
25680
+ child.update(deltaTime);
25681
+ }
25682
+ }
25683
+ };
25684
+ _proto.dispose = function dispose() {
25685
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.children.slice()), _step; !(_step = _iterator()).done;){
25686
+ var child = _step.value;
25687
+ child.dispose();
25688
+ }
25689
+ Control.prototype.dispose.call(this);
25690
+ };
25691
+ return ContainerControl;
25692
+ }(Control);
25693
+ /** Base class for GUI tree roots and input dispatchers. */ var RootControl = /*#__PURE__*/ function(ContainerControl) {
25694
+ _inherits(RootControl, ContainerControl);
25695
+ function RootControl() {
25696
+ return ContainerControl.apply(this, arguments);
25697
+ }
25698
+ return RootControl;
25699
+ }(ContainerControl);
25700
+
25701
+ var _obj$4;
25702
+ var cursorNames = (_obj$4 = {}, _obj$4[CursorShape.Arrow] = "default", _obj$4[CursorShape.Ibeam] = "text", _obj$4[CursorShape.PointingHand] = "pointer", _obj$4[CursorShape.Cross] = "crosshair", _obj$4[CursorShape.Wait] = "wait", _obj$4[CursorShape.Busy] = "progress", _obj$4[CursorShape.Drag] = "grab", _obj$4[CursorShape.CanDrop] = "copy", _obj$4[CursorShape.Forbidden] = "not-allowed", _obj$4[CursorShape.Vsize] = "ns-resize", _obj$4[CursorShape.Hsize] = "ew-resize", _obj$4[CursorShape.Bdiagsize] = "nesw-resize", _obj$4[CursorShape.Fdiagsize] = "nwse-resize", _obj$4[CursorShape.Move] = "move", _obj$4[CursorShape.Vsplit] = "row-resize", _obj$4[CursorShape.Hsplit] = "col-resize", _obj$4[CursorShape.Help] = "help", _obj$4);
25703
+ function getButtonMask(button) {
25704
+ switch(button){
25705
+ case MouseButton.Left:
25706
+ return MouseButtonMask.Left;
25707
+ case MouseButton.Right:
25708
+ return MouseButtonMask.Right;
25709
+ case MouseButton.Middle:
25710
+ return MouseButtonMask.Middle;
25711
+ case MouseButton.Xbutton1:
25712
+ return MouseButtonMask.Xbutton1;
25713
+ case MouseButton.Xbutton2:
25714
+ return MouseButtonMask.Xbutton2;
25715
+ default:
25716
+ return MouseButtonMask.None;
25717
+ }
25718
+ }
25719
+ function isWheelButton(button) {
25720
+ return button >= MouseButton.WheelUp && button <= MouseButton.WheelRight;
25721
+ }
25722
+ function getWheelDelta(event) {
25723
+ return event.buttonIndex === MouseButton.WheelUp || event.buttonIndex === MouseButton.WheelLeft ? event.factor : -event.factor;
25724
+ }
25725
+ /** CanvasLayer-like boundary for a single UICanvas GUI tree. */ var CanvasRootControl = /*#__PURE__*/ function(ContainerControl) {
25726
+ _inherits(CanvasRootControl, ContainerControl);
25727
+ function CanvasRootControl(engine, canvas) {
25728
+ var _this;
25729
+ _this = ContainerControl.call(this, engine) || this;
25730
+ _this.canvas = canvas;
25731
+ _this.mouseFilter = MouseFilter.Ignore;
25732
+ _this.setSize(engine.canvas.width, engine.canvas.height);
25733
+ return _this;
25734
+ }
25735
+ _create_class(CanvasRootControl, [
25736
+ {
25737
+ key: "inputDisabled",
25738
+ get: function get() {
25739
+ var _this_canvas_item;
25740
+ return !this.canvas.receivesEvents || !this.canvas.enabled || !((_this_canvas_item = this.canvas.item) == null ? void 0 : _this_canvas_item.isActive);
25741
+ }
25742
+ }
25743
+ ]);
25744
+ return CanvasRootControl;
25745
+ }(ContainerControl);
25746
+ /** Global ordered collection of UICanvas roots. */ var CanvasContainer = /*#__PURE__*/ function(ContainerControl) {
25747
+ _inherits(CanvasContainer, ContainerControl);
25748
+ function CanvasContainer(engine) {
25749
+ var _this;
25750
+ _this = ContainerControl.call(this, engine) || this;
25751
+ _this.mouseFilter = MouseFilter.Ignore;
25752
+ _this.setSize(engine.canvas.width, engine.canvas.height);
25753
+ return _this;
25754
+ }
25755
+ var _proto = CanvasContainer.prototype;
25756
+ _proto.sortCanvases = function sortCanvases() {
25757
+ this.children.sort(function(left, right) {
25758
+ return left.canvas.order - right.canvas.order;
25759
+ });
25760
+ };
25761
+ _proto.addChildInternal = function addChildInternal(child) {
25762
+ ContainerControl.prototype.addChildInternal.call(this, child);
25763
+ this.sortCanvases();
25764
+ };
25765
+ _proto.draw = function draw() {
25766
+ this.sortCanvases();
25767
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.children), _step; !(_step = _iterator()).done;){
25768
+ var child = _step.value;
25769
+ var root = child;
25770
+ if (root.canvas.isVisible) {
25771
+ root.draw();
25772
+ }
25773
+ }
25774
+ };
25775
+ return CanvasContainer;
25776
+ }(ContainerControl);
25777
+ /** Engine window GUI root. Routes events across all UICanvas roots. */ var WindowRootControl = /*#__PURE__*/ function(RootControl) {
25778
+ _inherits(WindowRootControl, RootControl);
25779
+ function WindowRootControl(engine) {
25780
+ var _this;
25781
+ _this = RootControl.call(this, engine) || this;
25782
+ _this.dragThreshold = 10;
25783
+ _this.inputHandled = false;
25784
+ _this.gui = {
25785
+ mouseFocus: null,
25786
+ mouseClickGrabber: null,
25787
+ mouseFocusMask: MouseButtonMask.None,
25788
+ mouseOver: null,
25789
+ mouseOverHierarchy: [],
25790
+ touchFocus: new Map(),
25791
+ keyFocus: null,
25792
+ dragAccum: new Vector2(),
25793
+ dragAttempted: false,
25794
+ dragging: false,
25795
+ dragData: null,
25796
+ dragMouseOver: null,
25797
+ dragSuccessful: false,
25798
+ lastMousePosition: new Vector2(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY),
25799
+ sendingMouseEnterExit: false,
25800
+ mouseOverUpdatePending: false
25801
+ };
25802
+ _this.mouseFilter = MouseFilter.Ignore;
25803
+ _this.setSize(engine.canvas.width, engine.canvas.height);
25804
+ _this.canvases = new CanvasContainer(engine);
25805
+ _this.canvases.parent = _assert_this_initialized(_this);
25806
+ return _this;
25807
+ }
25808
+ var _proto = WindowRootControl.prototype;
25809
+ _proto.pushInput = function pushInput(event) {
25810
+ this.inputHandled = false;
25811
+ this.cleanupInternalState();
25812
+ this.processGUIInput(event);
25813
+ this.postGrabClickFocus();
25814
+ };
25815
+ _proto.isInputHandled = function isInputHandled() {
25816
+ return this.inputHandled;
25817
+ };
25818
+ _proto.getMousePosition = function getMousePosition() {
25819
+ return this.gui.lastMousePosition.clone();
25820
+ };
25821
+ _proto.guiGetFocusOwner = function guiGetFocusOwner() {
25822
+ return this.isFocusTargetUsable(this.gui.keyFocus) ? this.gui.keyFocus : null;
25823
+ };
25824
+ _proto.guiReleaseFocus = function guiReleaseFocus() {
25825
+ this.releaseControlFocus();
25826
+ };
25827
+ _proto.guiIsDragging = function guiIsDragging() {
25828
+ return this.gui.dragging;
25829
+ };
25830
+ _proto.guiGetDragData = function guiGetDragData() {
25831
+ return this.gui.dragData;
25832
+ };
25833
+ _proto.guiIsDragSuccessful = function guiIsDragSuccessful() {
25834
+ return this.gui.dragSuccessful;
25835
+ };
25836
+ _proto.guiCancelDrag = function guiCancelDrag() {
25837
+ this.endDragging(false);
25838
+ };
25839
+ _proto.acceptControlEvent = function acceptControlEvent(control) {
25840
+ if (this.isControlUsable(control)) {
25841
+ this.inputHandled = true;
25842
+ }
25843
+ };
25844
+ _proto.grabControlFocus = function grabControlFocus(control) {
25845
+ if (!this.isFocusTargetUsable(control) || this.gui.keyFocus === control) {
25846
+ return;
25847
+ }
25848
+ var previous = this.gui.keyFocus;
25849
+ this.gui.keyFocus = control;
25850
+ if (previous && !previous.isDisposed) {
25851
+ previous.onLostFocus();
25852
+ }
25853
+ control.onGotFocus();
25854
+ };
25855
+ _proto.grabControlClickFocus = function grabControlClickFocus(control) {
25856
+ var _this = this;
25857
+ if (this.isControlValid(control)) {
25858
+ this.gui.mouseClickGrabber = control;
25859
+ queueMicrotask(function() {
25860
+ return _this.postGrabClickFocus();
25861
+ });
25862
+ }
25863
+ };
25864
+ _proto.releaseControlFocus = function releaseControlFocus(control) {
25865
+ var previous = this.gui.keyFocus;
25866
+ if (!previous || control && previous !== control) {
25867
+ return;
25868
+ }
25869
+ this.gui.keyFocus = null;
25870
+ if (!previous.isDisposed) {
25871
+ previous.onLostFocus();
25872
+ }
25873
+ };
25874
+ _proto.warpControlMouse = function warpControlMouse(position) {
25875
+ this.gui.lastMousePosition.copyFrom(position);
25876
+ this.updateMouseOver(position);
25877
+ };
25878
+ _proto.controlStateChanged = function controlStateChanged(control) {
25879
+ if (!this.isControlUsable(control)) {
25880
+ this.dropControlState(control);
25881
+ }
25882
+ this.requestMouseOverUpdate();
25883
+ };
25884
+ _proto.controlRemoved = function controlRemoved(control) {
25885
+ this.dropControlState(control);
25886
+ this.cleanupInternalState();
25887
+ this.requestMouseOverUpdate();
25888
+ };
25889
+ _proto.controlTreeChanged = function controlTreeChanged() {
25890
+ this.requestMouseOverUpdate();
25891
+ };
25892
+ _proto.cancelPointerInput = function cancelPointerInput() {
25893
+ this.dropMouseFocus();
25894
+ this.dropMouseOver();
25895
+ this.gui.touchFocus.clear();
25896
+ this.endDragging(false);
25897
+ this.releaseControlFocus();
25898
+ };
25899
+ _proto.resize = function resize(width, height) {
25900
+ this.setSize(width, height);
25901
+ this.canvases.setSize(width, height);
25902
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.canvases.children), _step; !(_step = _iterator()).done;){
25903
+ var root = _step.value;
25904
+ root.setSize(width, height);
25905
+ }
25906
+ };
25907
+ _proto.render = function render() {
25908
+ if (this.canvases.children.length === 0) {
25909
+ return;
25910
+ }
25911
+ this.engine.graphics.begin();
25912
+ this.draw();
25913
+ this.engine.graphics.end();
25914
+ };
25915
+ _proto.update = function update(deltaTime) {
25916
+ if (this.gui.mouseOverUpdatePending) {
25917
+ this.gui.mouseOverUpdatePending = false;
25918
+ this.updateMouseOver(this.gui.lastMousePosition);
25919
+ }
25920
+ RootControl.prototype.update.call(this, deltaTime);
25921
+ };
25922
+ _proto.dispose = function dispose() {
25923
+ this.cancelPointerInput();
25924
+ RootControl.prototype.dispose.call(this);
25925
+ };
25926
+ _proto.processGUIInput = function processGUIInput(event) {
25927
+ if (_instanceof1(event, InputEventKey)) {
25928
+ var target = this.guiGetFocusOwner();
25929
+ if (target) {
25930
+ this.callControlInput(target, event);
25931
+ }
25932
+ } else if (_instanceof1(event, InputEventMouse)) {
25933
+ this.gui.lastMousePosition.copyFrom(event.globalPosition);
25934
+ this.updateMouseOver(event.globalPosition);
25935
+ if (_instanceof1(event, InputEventMouseButton)) {
25936
+ this.processMouseButton(event);
25937
+ } else if (_instanceof1(event, InputEventMouseMotion)) {
25938
+ this.processMouseMotion(event);
25939
+ }
25940
+ } else if (_instanceof1(event, InputEventScreenTouch)) {
25941
+ this.processScreenTouch(event);
25942
+ } else if (_instanceof1(event, InputEventScreenDrag)) {
25943
+ this.processScreenDrag(event);
25944
+ }
25945
+ };
25946
+ _proto.processMouseButton = function processMouseButton(event) {
25947
+ if (isWheelButton(event.buttonIndex)) {
25948
+ var target = this.findInputControl(event.globalPosition);
25949
+ if (target) {
25950
+ this.callGUIInput(target, event);
25951
+ }
25952
+ return;
25953
+ }
25954
+ var mask = getButtonMask(event.buttonIndex);
25955
+ if (event.isPressed()) {
25956
+ var target1 = this.gui.mouseFocusMask !== 0 ? this.gui.mouseFocus : this.findInputControl(event.globalPosition);
25957
+ this.gui.mouseFocus = target1;
25958
+ if (!target1) {
25959
+ return;
25960
+ }
25961
+ this.gui.mouseFocusMask |= mask;
25962
+ if (event.buttonIndex === MouseButton.Left) {
25963
+ this.gui.dragAccum.setZero();
25964
+ this.gui.dragAttempted = false;
25965
+ this.findClickFocus(target1);
25966
+ }
25967
+ this.callGUIInput(target1, event);
25968
+ } else {
25969
+ if (event.buttonIndex === MouseButton.Left && this.gui.dragging) {
25970
+ this.finishDrop(event.globalPosition);
25971
+ }
25972
+ this.gui.mouseFocusMask &= ~mask;
25973
+ var target2 = this.gui.mouseFocus;
25974
+ if (this.gui.mouseFocusMask === 0) {
25975
+ this.gui.mouseFocus = null;
25976
+ }
25977
+ if (this.isControlUsable(target2)) {
25978
+ this.callGUIInput(target2, event);
25979
+ }
25980
+ }
25981
+ };
25982
+ _proto.processMouseMotion = function processMouseMotion(event) {
25983
+ if (!this.gui.dragging && !this.gui.dragAttempted && this.gui.mouseFocus && (this.gui.mouseFocusMask & MouseButtonMask.Left) !== 0) {
25984
+ this.gui.dragAccum.add(event.relative);
25985
+ if (this.gui.dragAccum.length() > this.dragThreshold) {
25986
+ var origin = event.globalPosition.clone().subtract(this.gui.dragAccum);
25987
+ this.beginDragging(this.gui.mouseFocus, origin);
25988
+ this.gui.dragAttempted = true;
25989
+ }
25990
+ }
25991
+ var target = this.isControlUsable(this.gui.mouseFocus) ? this.gui.mouseFocus : this.findInputControl(event.globalPosition);
25992
+ if (target) {
25993
+ this.callGUIInput(target, event);
25994
+ }
25995
+ if (this.gui.dragging) {
25996
+ this.gui.dragMouseOver = this.findDropTarget(this.findInputControl(event.globalPosition), event.globalPosition);
25997
+ }
25998
+ this.updateCursor(target, event.globalPosition);
25999
+ };
26000
+ _proto.processScreenTouch = function processScreenTouch(event) {
26001
+ var target;
26002
+ if (event.isPressed()) {
26003
+ target = this.findInputControl(event.position);
26004
+ if (target) {
26005
+ this.gui.touchFocus.set(event.index, target);
26006
+ }
26007
+ } else {
26008
+ var _this_gui_touchFocus_get;
26009
+ target = (_this_gui_touchFocus_get = this.gui.touchFocus.get(event.index)) != null ? _this_gui_touchFocus_get : null;
26010
+ this.gui.touchFocus.delete(event.index);
26011
+ }
26012
+ if (this.isControlUsable(target)) {
26013
+ this.callGUIInput(target, event);
26014
+ }
26015
+ };
26016
+ _proto.processScreenDrag = function processScreenDrag(event) {
26017
+ var _this_gui_touchFocus_get;
26018
+ var target = (_this_gui_touchFocus_get = this.gui.touchFocus.get(event.index)) != null ? _this_gui_touchFocus_get : this.findInputControl(event.position);
26019
+ if (this.isControlUsable(target)) {
26020
+ this.callGUIInput(target, event);
26021
+ }
26022
+ };
26023
+ _proto.callGUIInput = function callGUIInput(target, event) {
26024
+ var current = target;
26025
+ var pointerEvent = _instanceof1(event, InputEventMouse) || _instanceof1(event, InputEventScreenTouch) || _instanceof1(event, InputEventScreenDrag);
26026
+ while(current && current !== this && this.isControlUsable(current)){
26027
+ var filter = current.getEffectiveMouseFilter();
26028
+ if (filter !== MouseFilter.Ignore) {
26029
+ this.callControlInput(current, event.xformedBy(this.getGlobalInverse(current)));
26030
+ }
26031
+ var forcePassWheel = _instanceof1(event, InputEventMouseButton) && isWheelButton(event.buttonIndex) && current.mouseForcePassScrollEvents;
26032
+ if (this.inputHandled || filter === MouseFilter.Stop && pointerEvent && !forcePassWheel) {
26033
+ this.inputHandled = true;
26034
+ return;
26035
+ }
26036
+ current = current.parent;
26037
+ }
26038
+ };
26039
+ _proto.callControlInput = function callControlInput(control, event) {
26040
+ if (_instanceof1(event, InputEventMouseButton)) {
26041
+ if (isWheelButton(event.buttonIndex)) {
26042
+ control.onMouseWheel(event.position, getWheelDelta(event), event);
26043
+ } else if (event.isPressed()) {
26044
+ control.onMouseDown(event.position, event.buttonIndex, event);
26045
+ } else {
26046
+ control.onMouseUp(event.position, event.buttonIndex, event);
26047
+ }
26048
+ } else if (_instanceof1(event, InputEventMouseMotion)) {
26049
+ control.onMouseMove(event.position, event);
26050
+ } else if (_instanceof1(event, InputEventScreenTouch)) {
26051
+ if (event.isPressed()) {
26052
+ control.onTouchDown(event.position, event.index, event);
26053
+ } else {
26054
+ control.onTouchUp(event.position, event.index, event);
26055
+ }
26056
+ } else if (_instanceof1(event, InputEventScreenDrag)) {
26057
+ control.onTouchMove(event.position, event.index, event);
26058
+ } else if (_instanceof1(event, InputEventKey)) {
26059
+ if (event.isPressed()) {
26060
+ control.onKeyDown(event);
26061
+ } else if (event.isReleased()) {
26062
+ control.onKeyUp(event);
26063
+ }
26064
+ }
26065
+ };
26066
+ _proto.findInputControl = function findInputControl(position) {
26067
+ this.canvases.sortCanvases();
26068
+ for(var index = this.canvases.children.length - 1; index >= 0; index--){
26069
+ var root = this.canvases.children[index];
26070
+ if (!root.canvas.isVisible || root.inputDisabled) {
26071
+ continue;
26072
+ }
26073
+ var target = this.findControlAtPosition(root, position, true);
26074
+ if (target) {
26075
+ return target;
26076
+ }
26077
+ }
26078
+ return null;
26079
+ };
26080
+ _proto.findControlAtPosition = function findControlAtPosition(container, position, skipSelf) {
26081
+ if (skipSelf === void 0) skipSelf = false;
26082
+ if (!container.visibleInHierarchy || container.isDisposed) {
26083
+ return null;
26084
+ }
26085
+ var localPosition = this.toLocal(container, position);
26086
+ if (container.clipContents && !container.hasPoint(localPosition)) {
26087
+ return null;
26088
+ }
26089
+ for(var index = container.children.length - 1; index >= 0; index--){
26090
+ var child = container.children[index];
26091
+ if (!child.visibleInHierarchy || child.isDisposed) {
26092
+ continue;
26093
+ }
26094
+ if (_instanceof1(child, ContainerControl)) {
26095
+ var found = this.findControlAtPosition(child, position);
26096
+ if (found) {
26097
+ return found;
26098
+ }
26099
+ } else if (child.getEffectiveMouseFilter() !== MouseFilter.Ignore && child.hasPoint(this.toLocal(child, position))) {
26100
+ return child;
26101
+ }
26102
+ }
26103
+ if (!skipSelf && container.getEffectiveMouseFilter() !== MouseFilter.Ignore && container.hasPoint(localPosition)) {
26104
+ return container;
26105
+ }
26106
+ return null;
26107
+ };
26108
+ _proto.updateMouseOver = function updateMouseOver(position) {
26109
+ if (this.gui.sendingMouseEnterExit) {
26110
+ this.gui.mouseOverUpdatePending = true;
26111
+ return;
26112
+ }
26113
+ this.gui.mouseOverUpdatePending = false;
26114
+ var target = this.findInputControl(position);
26115
+ var next = this.buildHoverHierarchy(target);
26116
+ var previous = this.gui.mouseOverHierarchy;
26117
+ var common = 0;
26118
+ while(common < previous.length && common < next.length && previous[common] === next[common]){
26119
+ common++;
26120
+ }
26121
+ this.gui.sendingMouseEnterExit = true;
26122
+ for(var index = previous.length - 1; index >= common; index--){
26123
+ if (!previous[index].isDisposed) {
26124
+ previous[index].onMouseLeave();
26125
+ }
26126
+ }
26127
+ for(var index1 = common; index1 < next.length; index1++){
26128
+ next[index1].onMouseEnter(this.toLocal(next[index1], position));
26129
+ }
26130
+ this.gui.sendingMouseEnterExit = false;
26131
+ this.gui.mouseOver = target;
26132
+ this.gui.mouseOverHierarchy = next;
26133
+ };
26134
+ _proto.buildHoverHierarchy = function buildHoverHierarchy(target) {
26135
+ var hierarchy = [];
26136
+ var current = target;
26137
+ while(current && current !== this){
26138
+ if (current.getEffectiveMouseFilter() !== MouseFilter.Ignore) {
26139
+ hierarchy.push(current);
26140
+ }
26141
+ if (current.getEffectiveMouseFilter() === MouseFilter.Stop) {
26142
+ break;
26143
+ }
26144
+ current = current.parent;
26145
+ }
26146
+ hierarchy.reverse();
26147
+ return hierarchy;
26148
+ };
26149
+ _proto.findClickFocus = function findClickFocus(target) {
26150
+ var current = target;
26151
+ while(current && current !== this){
26152
+ var mode = current.getFocusModeWithOverride();
26153
+ if (mode === FocusMode.Click || mode === FocusMode.All) {
26154
+ this.grabControlFocus(current);
26155
+ return;
26156
+ }
26157
+ if (current.getEffectiveMouseFilter() === MouseFilter.Stop) {
26158
+ return;
26159
+ }
26160
+ current = current.parent;
26161
+ }
26162
+ };
26163
+ _proto.beginDragging = function beginDragging(source, position) {
26164
+ var current = source;
26165
+ while(current && current !== this){
26166
+ var data = current.invokeGetDragData(this.toLocal(current, position));
26167
+ if (data !== null && data !== undefined) {
26168
+ this.gui.dragging = true;
26169
+ this.gui.dragData = data;
26170
+ this.gui.mouseFocus = null;
26171
+ this.gui.mouseFocusMask = MouseButtonMask.None;
26172
+ return;
26173
+ }
26174
+ if (current.getEffectiveMouseFilter() === MouseFilter.Stop) {
26175
+ return;
26176
+ }
26177
+ current = current.parent;
26178
+ }
26179
+ };
26180
+ _proto.finishDrop = function finishDrop(position) {
26181
+ var target = this.findDropTarget(this.findInputControl(position), position);
26182
+ if (target) {
26183
+ target.invokeDropData(this.toLocal(target, position), this.gui.dragData);
26184
+ }
26185
+ this.endDragging(!!target);
26186
+ };
26187
+ _proto.findDropTarget = function findDropTarget(target, position) {
26188
+ var current = target;
26189
+ while(current && current !== this){
26190
+ if (current.invokeCanDropData(this.toLocal(current, position), this.gui.dragData)) {
26191
+ return current;
26192
+ }
26193
+ if (current.getEffectiveMouseFilter() === MouseFilter.Stop) {
26194
+ return null;
26195
+ }
26196
+ current = current.parent;
26197
+ }
26198
+ return null;
26199
+ };
26200
+ _proto.endDragging = function endDragging(successful) {
26201
+ this.gui.dragSuccessful = successful;
26202
+ this.gui.dragging = false;
26203
+ this.gui.dragData = null;
26204
+ this.gui.dragMouseOver = null;
26205
+ };
26206
+ _proto.updateCursor = function updateCursor(target, position) {
26207
+ var current = target;
26208
+ var shape = CursorShape.Arrow;
26209
+ while(current && current !== this){
26210
+ var candidate = current.getCursorShape(this.toLocal(current, position));
26211
+ if (candidate !== CursorShape.Arrow) {
26212
+ shape = candidate;
26213
+ break;
26214
+ }
26215
+ if (current.getEffectiveMouseFilter() === MouseFilter.Stop) {
26216
+ break;
26217
+ }
26218
+ current = current.parent;
26219
+ }
26220
+ this.engine.canvas.style.cursor = cursorNames[shape];
26221
+ };
26222
+ _proto.postGrabClickFocus = function postGrabClickFocus() {
26223
+ var target = this.gui.mouseClickGrabber;
26224
+ this.gui.mouseClickGrabber = null;
26225
+ if (this.isControlUsable(target)) {
26226
+ this.gui.mouseFocus = target;
26227
+ }
26228
+ };
26229
+ _proto.cleanupInternalState = function cleanupInternalState() {
26230
+ if (!this.isControlUsable(this.gui.mouseFocus)) {
26231
+ this.dropMouseFocus();
26232
+ }
26233
+ if (this.gui.keyFocus && !this.isFocusTargetUsable(this.gui.keyFocus)) {
26234
+ this.releaseControlFocus(this.gui.keyFocus);
26235
+ }
26236
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.gui.touchFocus), _step; !(_step = _iterator()).done;){
26237
+ var _step_value = _step.value, index = _step_value[0], control = _step_value[1];
26238
+ if (!this.isControlUsable(control)) {
26239
+ this.gui.touchFocus.delete(index);
26240
+ }
26241
+ }
26242
+ };
26243
+ _proto.dropMouseFocus = function dropMouseFocus() {
26244
+ this.gui.mouseFocus = null;
26245
+ this.gui.mouseFocusMask = MouseButtonMask.None;
26246
+ };
26247
+ _proto.dropMouseOver = function dropMouseOver() {
26248
+ for(var index = this.gui.mouseOverHierarchy.length - 1; index >= 0; index--){
26249
+ var control = this.gui.mouseOverHierarchy[index];
26250
+ if (!control.isDisposed) {
26251
+ control.onMouseLeave();
26252
+ }
26253
+ }
26254
+ this.gui.mouseOver = null;
26255
+ this.gui.mouseOverHierarchy = [];
26256
+ };
26257
+ _proto.dropControlState = function dropControlState(control) {
26258
+ if (this.controlBelongsToSubtree(this.gui.mouseFocus, control)) {
26259
+ this.dropMouseFocus();
26260
+ }
26261
+ if (this.controlBelongsToSubtree(this.gui.mouseClickGrabber, control)) {
26262
+ this.gui.mouseClickGrabber = null;
26263
+ }
26264
+ if (this.controlBelongsToSubtree(this.gui.keyFocus, control)) {
26265
+ var _this_gui_keyFocus;
26266
+ this.releaseControlFocus((_this_gui_keyFocus = this.gui.keyFocus) != null ? _this_gui_keyFocus : undefined);
26267
+ }
26268
+ if (this.controlBelongsToSubtree(this.gui.mouseOver, control)) {
26269
+ this.dropMouseOver();
26270
+ }
26271
+ if (this.controlBelongsToSubtree(this.gui.dragMouseOver, control)) {
26272
+ this.gui.dragMouseOver = null;
26273
+ }
26274
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.gui.touchFocus), _step; !(_step = _iterator()).done;){
26275
+ var _step_value = _step.value, index = _step_value[0], target = _step_value[1];
26276
+ if (this.controlBelongsToSubtree(target, control)) {
26277
+ this.gui.touchFocus.delete(index);
26278
+ }
26279
+ }
26280
+ };
26281
+ _proto.requestMouseOverUpdate = function requestMouseOverUpdate() {
26282
+ if (Number.isFinite(this.gui.lastMousePosition.x)) {
26283
+ this.updateMouseOver(this.gui.lastMousePosition);
26284
+ }
26285
+ };
26286
+ _proto.getGlobalInverse = function getGlobalInverse(control) {
26287
+ var transform = control.getGlobalTransform2D().clone();
26288
+ return Math.abs(transform.determinant()) < 1e-12 ? new Matrix3() : transform.invert();
26289
+ };
26290
+ _proto.toLocal = function toLocal(control, position) {
26291
+ var elements = this.getGlobalInverse(control).elements;
26292
+ return new Vector2(elements[0] * position.x + elements[3] * position.y + elements[6], elements[1] * position.x + elements[4] * position.y + elements[7]);
26293
+ };
26294
+ _proto.controlBelongsToSubtree = function controlBelongsToSubtree(control, subtree) {
26295
+ var current = control;
26296
+ while(current){
26297
+ if (current === subtree) {
26298
+ return true;
26299
+ }
26300
+ current = current.parent;
26301
+ }
26302
+ return false;
26303
+ };
26304
+ _proto.isControlValid = function isControlValid(control) {
26305
+ return !!control && !control.isDisposed && control.root === this;
26306
+ };
26307
+ _proto.isControlUsable = function isControlUsable(control) {
26308
+ if (!this.isControlValid(control) || !control.visibleInHierarchy || !control.enabledInHierarchy) {
26309
+ return false;
26310
+ }
26311
+ var root = this.findCanvasRoot(control);
26312
+ return !root || !root.inputDisabled;
26313
+ };
26314
+ _proto.findCanvasRoot = function findCanvasRoot(control) {
26315
+ var current = control;
26316
+ while(current && current !== this){
26317
+ if (_instanceof1(current, CanvasRootControl)) {
26318
+ return current;
26319
+ }
26320
+ current = current.parent;
26321
+ }
26322
+ return null;
26323
+ };
26324
+ _proto.isFocusTargetUsable = function isFocusTargetUsable(control) {
26325
+ return this.isControlUsable(control) && control.getFocusModeWithOverride() !== FocusMode.None;
26326
+ };
26327
+ return WindowRootControl;
26328
+ }(RootControl);
26329
+
26330
+ var CanvasRenderMode;
26331
+ (function(CanvasRenderMode) {
26332
+ CanvasRenderMode[CanvasRenderMode["ScreenSpace"] = 0] = "ScreenSpace";
26333
+ CanvasRenderMode[CanvasRenderMode["CameraSpace"] = 1] = "CameraSpace";
26334
+ CanvasRenderMode[CanvasRenderMode["WorldSpace"] = 2] = "WorldSpace";
26335
+ CanvasRenderMode[CanvasRenderMode["WorldSpaceFaceCamera"] = 3] = "WorldSpaceFaceCamera";
26336
+ })(CanvasRenderMode || (CanvasRenderMode = {}));
26337
+ /** Canvas-layer boundary attached to a VFXItem. Input state remains owned by the window root. */ var UICanvas = /*#__PURE__*/ function(Component) {
26338
+ _inherits(UICanvas, Component);
26339
+ function UICanvas(engine) {
26340
+ var _this;
26341
+ _this = Component.call(this, engine) || this;
26342
+ _this.renderMode = 0;
26343
+ _this.receivesEvents = true;
26344
+ _this._order = 0;
26345
+ _this.registered = false;
26346
+ _this.rootControl = new CanvasRootControl(engine, _assert_this_initialized(_this));
26347
+ return _this;
26348
+ }
26349
+ var _proto = UICanvas.prototype;
26350
+ _proto.onEnable = function onEnable() {
26351
+ this.register();
26352
+ };
26353
+ _proto.onDisable = function onDisable() {
26354
+ this.unregister();
26355
+ };
26356
+ _proto.onDestroy = function onDestroy() {
26357
+ this.destroyCanvas();
26358
+ };
26359
+ _proto.dispose = function dispose() {
26360
+ this.destroyCanvas();
26361
+ Component.prototype.dispose.call(this);
26362
+ };
26363
+ _proto.register = function register() {
26364
+ if (!this.registered) {
26365
+ this.rootControl.parent = this.engine.windowRoot.canvases;
26366
+ this.registered = true;
25279
26367
  }
25280
- var rt = new RectTransform();
25281
- rt.engine = t.engine;
25282
- rt.name = t.name;
25283
- rt.position.copyFrom(t.position);
25284
- rt.quat.copyFrom(t.quat);
25285
- rt.rotation.copyFrom(t.rotation);
25286
- rt.scale.copyFrom(t.scale);
25287
- rt.size.copyFrom(t.size);
25288
- // 不拷贝源 anchor — 升级为 RectTransform 时使用默认 pivot=(0.5, 0.5)
25289
- // anchor 同步成 pivot * size,获得“中心轴心”默认行为
25290
- rt.anchor.set(rt.pivot.x * rt.size.x, rt.pivot.y * rt.size.y, t.anchor.z);
25291
- if (t.parentTransform) {
25292
- rt.parentTransform = t.parentTransform;
26368
+ };
26369
+ _proto.unregister = function unregister() {
26370
+ if (this.registered) {
26371
+ this.rootControl.parent = null;
26372
+ this.registered = false;
26373
+ }
26374
+ };
26375
+ _proto.destroyCanvas = function destroyCanvas() {
26376
+ this.unregister();
26377
+ if (!this.rootControl.isDisposed) {
26378
+ this.rootControl.dispose();
25293
26379
  }
25294
- return rt;
25295
26380
  };
25296
- return RectTransform;
25297
- }(Transform);
26381
+ _create_class(UICanvas, [
26382
+ {
26383
+ key: "order",
26384
+ get: function get() {
26385
+ return this._order;
26386
+ },
26387
+ set: function set(value) {
26388
+ if (this._order !== value) {
26389
+ this._order = value;
26390
+ this.engine.windowRoot.canvases.sortCanvases();
26391
+ }
26392
+ }
26393
+ },
26394
+ {
26395
+ key: "isVisible",
26396
+ get: function get() {
26397
+ var _this_item;
26398
+ return this.renderMode === 0 && this.enabled && !!((_this_item = this.item) == null ? void 0 : _this_item.isActive);
26399
+ }
26400
+ }
26401
+ ]);
26402
+ return UICanvas;
26403
+ }(Component);
25298
26404
 
25299
26405
  /**
25300
- * 锚点布局组件
25301
- *
25302
- * `Control extends CanvasItem`。CanvasItem 仅承担绘制与节点层级,Control 在挂到 VFXItem 时把
25303
- * `item.transform` 升级为 {@link RectTransform}。
25304
- *
25305
- * 布局完全由 RectTransform 自治:父子节点关系沿 `Transform.parentTransform / children` 走,
25306
- * 父节点 size 变化时通过 `RectTransform.sizeChanged()` 直接调用子节点 sizeChanged 链式传播。
25307
- * Control 本身不持有任何与布局相关的状态
25308
- */ var Control = /*#__PURE__*/ function(CanvasItem) {
25309
- _inherits(Control, CanvasItem);
25310
- function Control() {
25311
- return CanvasItem.apply(this, arguments);
26406
+ * Scene-tree bridge for a GUI Control. The VFXItem tree owns lifecycle and
26407
+ * serialization while the Control tree owns layout, drawing and input.
26408
+ */ var UIControl = /*#__PURE__*/ function(Component) {
26409
+ _inherits(UIControl, Component);
26410
+ function UIControl(engine) {
26411
+ var _this;
26412
+ _this = Component.call(this, engine) || this;
26413
+ _this.controlNode = null;
26414
+ _this.linkedItemTransform = null;
26415
+ _this.linkedControl = null;
26416
+ _this.syncingLocation = false;
26417
+ _this.itemTransformChanged = function() {
26418
+ return _this.syncItemLocationToControl();
26419
+ };
26420
+ _this.controlLocationChanged = function() {
26421
+ return _this.syncControlLocationToItem();
26422
+ };
26423
+ return _this;
25312
26424
  }
25313
- var _proto = Control.prototype;
25314
- /**
25315
- * 在挂到 VFXItem 时确保 `item.transform` 是 `RectTransform`。
25316
- * 既有 Transform 状态(position / rotation / scale / size / anchor 等)通过 `RectTransform.fromTransform` 复制
25317
- */ _proto.onAwake = function onAwake() {
25318
- var item = this.item;
25319
- if (!_instanceof1(item.transform, RectTransform)) {
25320
- item.transform = RectTransform.fromTransform(item.transform);
26425
+ var _proto = UIControl.prototype;
26426
+ _proto.onAwake = function onAwake() {
26427
+ this.syncControl();
26428
+ };
26429
+ _proto.onEnable = function onEnable() {
26430
+ if (this.controlNode) {
26431
+ this.controlNode.visible = this.item.isActive;
26432
+ this.controlNode.enabled = true;
25321
26433
  }
25322
26434
  };
25323
- return Control;
25324
- }(CanvasItem);
26435
+ _proto.onDisable = function onDisable() {
26436
+ if (this.controlNode) {
26437
+ this.controlNode.visible = this.item.isActive;
26438
+ this.controlNode.enabled = false;
26439
+ }
26440
+ };
26441
+ _proto.onParentChanged = function onParentChanged() {
26442
+ this.syncControl();
26443
+ };
26444
+ _proto.onOrderInParentChanged = function onOrderInParentChanged() {
26445
+ this.syncControlOrder();
26446
+ };
26447
+ _proto.onDestroy = function onDestroy() {
26448
+ this.disposeControl();
26449
+ };
26450
+ _proto.dispose = function dispose() {
26451
+ this.disposeControl();
26452
+ Component.prototype.dispose.call(this);
26453
+ };
26454
+ /** Unlinks the GUI object without disposing or modifying it. */ _proto.unlinkControl = function unlinkControl() {
26455
+ if (this.controlNode) {
26456
+ this.unbindLocationSync();
26457
+ this.controlNode = null;
26458
+ }
26459
+ };
26460
+ _proto.disposeControl = function disposeControl() {
26461
+ var control = this.controlNode;
26462
+ if (control) {
26463
+ this.unbindLocationSync();
26464
+ this.controlNode = null;
26465
+ control.dispose();
26466
+ }
26467
+ };
26468
+ _proto.syncControl = function syncControl() {
26469
+ var control = this.controlNode;
26470
+ if (!control || !this.item) {
26471
+ return;
26472
+ }
26473
+ this.syncingLocation = true;
26474
+ try {
26475
+ control.visible = this.item.isActive;
26476
+ control.enabled = this.enabled;
26477
+ control.parent = this.resolveParent();
26478
+ this.syncControlOrder();
26479
+ this.copyItemLocationToControl();
26480
+ } finally{
26481
+ this.syncingLocation = false;
26482
+ }
26483
+ this.bindLocationSync();
26484
+ };
26485
+ _proto.syncControlOrder = function syncControlOrder() {
26486
+ if (this.controlNode && this.item) {
26487
+ this.controlNode.indexInParent = this.item.orderInParent;
26488
+ }
26489
+ };
26490
+ _proto.resolveParent = function resolveParent() {
26491
+ var parentItem = this.item.parent;
26492
+ if (!parentItem) {
26493
+ var _UIControl_fallbackParentGetDelegate;
26494
+ return (_UIControl_fallbackParentGetDelegate = UIControl.fallbackParentGetDelegate == null ? void 0 : UIControl.fallbackParentGetDelegate.call(UIControl, this)) != null ? _UIControl_fallbackParentGetDelegate : null;
26495
+ }
26496
+ var uiControl = parentItem.getComponent(UIControl);
26497
+ if ((uiControl == null ? void 0 : uiControl.control) && "children" in uiControl.control) {
26498
+ return uiControl.control;
26499
+ }
26500
+ var canvas = parentItem.getComponent(UICanvas);
26501
+ var _canvas_rootControl, _ref;
26502
+ 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;
26503
+ };
26504
+ _proto.bindLocationSync = function bindLocationSync() {
26505
+ var itemTransform = this.item.transform;
26506
+ var control = this.controlNode;
26507
+ if (this.linkedItemTransform === itemTransform && this.linkedControl === control) {
26508
+ return;
26509
+ }
26510
+ this.unbindLocationSync();
26511
+ if (control) {
26512
+ this.linkedItemTransform = itemTransform;
26513
+ this.linkedControl = control;
26514
+ itemTransform.on("changed", this.itemTransformChanged);
26515
+ control.on("locationChanged", this.controlLocationChanged);
26516
+ }
26517
+ };
26518
+ _proto.unbindLocationSync = function unbindLocationSync() {
26519
+ var _this_linkedItemTransform, _this_linkedControl;
26520
+ (_this_linkedItemTransform = this.linkedItemTransform) == null ? void 0 : _this_linkedItemTransform.off("changed", this.itemTransformChanged);
26521
+ (_this_linkedControl = this.linkedControl) == null ? void 0 : _this_linkedControl.off("locationChanged", this.controlLocationChanged);
26522
+ this.linkedItemTransform = null;
26523
+ this.linkedControl = null;
26524
+ };
26525
+ _proto.syncItemLocationToControl = function syncItemLocationToControl() {
26526
+ if (!this.syncingLocation && this.controlNode) {
26527
+ this.syncingLocation = true;
26528
+ try {
26529
+ this.copyItemLocationToControl();
26530
+ } finally{
26531
+ this.syncingLocation = false;
26532
+ }
26533
+ }
26534
+ };
26535
+ _proto.syncControlLocationToItem = function syncControlLocationToItem() {
26536
+ var control = this.controlNode;
26537
+ if (!this.syncingLocation && control) {
26538
+ var source = control.location;
26539
+ var target = this.item.transform.position;
26540
+ if (source.x !== target.x || source.y !== target.y) {
26541
+ this.syncingLocation = true;
26542
+ try {
26543
+ this.item.transform.setPosition(source.x, source.y, target.z);
26544
+ } finally{
26545
+ this.syncingLocation = false;
26546
+ }
26547
+ }
26548
+ }
26549
+ };
26550
+ _proto.copyItemLocationToControl = function copyItemLocationToControl() {
26551
+ var control = this.controlNode;
26552
+ if (control) {
26553
+ var source = this.item.transform.position;
26554
+ var target = control.location;
26555
+ if (source.x !== target.x || source.y !== target.y) {
26556
+ control.setPosition(source.x, source.y);
26557
+ }
26558
+ }
26559
+ };
26560
+ _create_class(UIControl, [
26561
+ {
26562
+ key: "control",
26563
+ get: function get() {
26564
+ return this.controlNode;
26565
+ },
26566
+ set: function set(value) {
26567
+ if (value === this.controlNode) {
26568
+ return;
26569
+ }
26570
+ this.disposeControl();
26571
+ if (value) {
26572
+ if (value.owner && value.owner !== this && value.owner.control === value) {
26573
+ throw new Error("A Control can only be owned by one UIControl.");
26574
+ }
26575
+ this.controlNode = value;
26576
+ value.owner = this;
26577
+ this.syncControl();
26578
+ }
26579
+ }
26580
+ },
26581
+ {
26582
+ key: "hasControl",
26583
+ get: function get() {
26584
+ return this.controlNode !== null;
26585
+ }
26586
+ }
26587
+ ]);
26588
+ return UIControl;
26589
+ }(Component);
25325
26590
 
25326
26591
  var CameraController = /*#__PURE__*/ function(Component) {
25327
26592
  _inherits(CameraController, Component);
@@ -25357,42 +26622,6 @@ CameraController = __decorate([
25357
26622
  effectsClass(DataType.CameraController)
25358
26623
  ], CameraController);
25359
26624
 
25360
- function _get_prototype_of(o) {
25361
- _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
25362
- return o.__proto__ || Object.getPrototypeOf(o);
25363
- };
25364
- return _get_prototype_of(o);
25365
- }
25366
-
25367
- function _is_native_function(fn) {
25368
- return Function.toString.call(fn).indexOf("[native code]") !== -1;
25369
- }
25370
-
25371
- function _wrap_native_super(Class) {
25372
- var _cache = typeof Map === "function" ? new Map() : undefined;
25373
- _wrap_native_super = function _wrap_native_super(Class) {
25374
- if (Class === null || !_is_native_function(Class)) return Class;
25375
- if (typeof Class !== "function") throw new TypeError("Super expression must either be null or a function");
25376
- if (typeof _cache !== "undefined") {
25377
- if (_cache.has(Class)) return _cache.get(Class);
25378
- _cache.set(Class, Wrapper);
25379
- }
25380
- function Wrapper() {
25381
- return _construct(Class, arguments, _get_prototype_of(this).constructor);
25382
- }
25383
- Wrapper.prototype = Object.create(Class.prototype, {
25384
- constructor: {
25385
- value: Wrapper,
25386
- enumerable: false,
25387
- writable: true,
25388
- configurable: true
25389
- }
25390
- });
25391
- return _set_prototype_of(Wrapper, Class);
25392
- };
25393
- return _wrap_native_super(Class);
25394
- }
25395
-
25396
26625
  var CameraVFXItemLoader = /*#__PURE__*/ function(Plugin) {
25397
26626
  _inherits(CameraVFXItemLoader, Plugin);
25398
26627
  function CameraVFXItemLoader() {
@@ -25413,142 +26642,202 @@ var PointerEventType;
25413
26642
  })(PointerEventType || (PointerEventType = {}));
25414
26643
  var EventSystem = /*#__PURE__*/ function() {
25415
26644
  function EventSystem(engine, allowPropagation) {
26645
+ var _this = this;
25416
26646
  if (allowPropagation === void 0) allowPropagation = false;
25417
26647
  this.engine = engine;
25418
26648
  this.allowPropagation = allowPropagation;
25419
- this.enabled = true;
25420
26649
  this.skipPointerMovePicking = true;
26650
+ this.emulateMouseFromTouch = true;
26651
+ this.emulateTouchFromMouse = false;
26652
+ this._enabled = true;
25421
26653
  this.handlers = {};
25422
- this.nativeHandlers = {};
26654
+ this.nativeHandlers = [];
25423
26655
  this.target = null;
25424
- }
25425
- var _proto = EventSystem.prototype;
25426
- _proto.bindListeners = function bindListeners(target) {
25427
- var _this = this;
25428
- this.target = target;
25429
- var x;
25430
- var y;
25431
- var currentTouch;
25432
- var lastTouch;
25433
- var getTouch;
25434
- getTouch = function(event) {
25435
- return event;
26656
+ this.mouseState = null;
26657
+ this.touchStates = new Map();
26658
+ this.mouseFromTouchIndex = null;
26659
+ this.touchFromMousePressed = false;
26660
+ this.addedTabIndex = false;
26661
+ this.addedOutlineStyle = false;
26662
+ this.onNativeWheel = function(event) {
26663
+ if (!_this.enabled || !_this.target) {
26664
+ return;
26665
+ }
26666
+ var position = _this.getCanvasPosition(event.clientX, event.clientY);
26667
+ var handled = false;
26668
+ if (event.deltaY !== 0) {
26669
+ handled = _this.pushWheelButton(event.deltaY < 0 ? MouseButton.WheelUp : MouseButton.WheelDown, Math.abs(event.deltaY), position, event) || handled;
26670
+ }
26671
+ if (event.deltaX !== 0) {
26672
+ handled = _this.pushWheelButton(event.deltaX < 0 ? MouseButton.WheelLeft : MouseButton.WheelRight, Math.abs(event.deltaX), position, event) || handled;
26673
+ }
26674
+ _this.consumeNativeEvent(event, handled);
25436
26675
  };
25437
- var touchstart = "mousedown";
25438
- var touchmove = "mousemove";
25439
- var touchend = "mouseup";
25440
- var touchcancel = "mouseleave";
25441
- var getTouchEventValue = function(event, x, y, dx, dy) {
25442
- if (dx === void 0) dx = 0;
25443
- if (dy === void 0) dy = 0;
25444
- var vx = 0;
25445
- var vy = 0;
25446
- var ts = performance.now();
25447
- if (!_this.target) {
25448
- logger.warn("Trigger TouchEvent after EventSystem is disposed.");
25449
- return {
25450
- x: x,
25451
- y: y,
25452
- vx: 0,
25453
- vy: vy,
25454
- dx: dx,
25455
- dy: dy,
25456
- ts: ts,
25457
- width: 0,
25458
- height: 0,
25459
- origin: event
25460
- };
26676
+ this.onNativeKeyDown = function(event) {
26677
+ _this.handleNativeKey(event, true);
26678
+ };
26679
+ this.onNativeKeyUp = function(event) {
26680
+ _this.handleNativeKey(event, false);
26681
+ };
26682
+ this.onNativeMouseDown = function(event) {
26683
+ _this.handleNativeMouseDown(event);
26684
+ };
26685
+ this.onNativeMouseMove = function(event) {
26686
+ var _state;
26687
+ if (!_this.enabled || !_this.target) {
26688
+ return;
25461
26689
  }
25462
- var _this_target = _this.target, width = _this_target.width, height = _this_target.height;
25463
- if (lastTouch) {
25464
- var dt = ts - lastTouch.ts;
25465
- vx = (dx - lastTouch.dx) / dt || 0;
25466
- vy = (dy - lastTouch.dy) / dt || 0;
25467
- lastTouch = {
25468
- dx: dx,
25469
- dy: dy,
25470
- ts: ts
25471
- };
26690
+ var position = _this.getCanvasPosition(event.clientX, event.clientY);
26691
+ var _this_mouseState;
26692
+ var state = (_this_mouseState = _this.mouseState) != null ? _this_mouseState : _this.createPointerState(position);
26693
+ _this.mouseState = state;
26694
+ var relative = new Vector2(position.x - state.last.x, position.y - state.last.y);
26695
+ var velocity = _this.getVelocity(state, position);
26696
+ var handled = _this.pushNativeMouseMotion(event, position, relative, velocity);
26697
+ (_state = state).controlHandled || (_state.controlHandled = handled);
26698
+ if (!handled && (!state.pressed || !state.controlHandled)) {
26699
+ var pointerEvent = _this.createPointerEvent(event, position, state, velocity);
26700
+ _this.dispatchEvent(EVENT_TYPE_TOUCH_MOVE, pointerEvent);
26701
+ }
26702
+ _this.updatePointerState(state, position);
26703
+ _this.consumeNativeEvent(event, handled);
26704
+ };
26705
+ this.onNativeMouseUp = function(event) {
26706
+ if (!_this.enabled || !_this.target) {
26707
+ return;
25472
26708
  }
25473
- return {
25474
- x: x,
25475
- y: y,
25476
- vx: vx,
25477
- vy: vy,
25478
- dx: dx,
25479
- dy: dy,
25480
- ts: ts,
25481
- width: width,
25482
- height: height,
25483
- origin: event
25484
- };
26709
+ var position = _this.getCanvasPosition(event.clientX, event.clientY);
26710
+ var existingState = _this.mouseState;
26711
+ if (!(existingState == null ? void 0 : existingState.pressed)) {
26712
+ return;
26713
+ }
26714
+ var state = existingState;
26715
+ var handled = _this.pushNativeMouseButton(event, position, false);
26716
+ var pointerEvent = _this.createPointerEvent(event, position, state);
26717
+ if (!state.controlHandled && !handled && _this.isClick(state, position)) {
26718
+ _this.dispatchEvent(EVENT_TYPE_CLICK, pointerEvent);
26719
+ }
26720
+ if (!handled && !state.controlHandled) {
26721
+ _this.dispatchEvent(EVENT_TYPE_TOUCH_END, pointerEvent);
26722
+ }
26723
+ _this.mouseState = null;
26724
+ _this.consumeNativeEvent(event, handled || state.controlHandled || !_this.allowPropagation);
25485
26725
  };
25486
- if (isSimulatorCellPhone()) {
25487
- getTouch = function(event) {
25488
- var touches = event.touches, changedTouches = event.changedTouches;
25489
- return touches[0] || changedTouches[0];
25490
- };
25491
- touchstart = "touchstart";
25492
- touchmove = "touchmove";
25493
- touchend = "touchend";
25494
- touchcancel = "touchcancel";
25495
- }
25496
- var _obj;
25497
- this.nativeHandlers = (_obj = {}, _obj[touchstart] = function(event) {
25498
- if (_this.enabled) {
25499
- var touch = getTouch(event);
25500
- var cood = getCoord(touch);
25501
- x = cood.x;
25502
- y = cood.y;
25503
- lastTouch = currentTouch = {
25504
- clientX: touch.clientX,
25505
- clientY: touch.clientY,
25506
- ts: performance.now(),
25507
- x: x,
25508
- y: y
25509
- };
25510
- _this.dispatchEvent(EVENT_TYPE_TOUCH_START, getTouchEventValue(event, x, y));
25511
- }
25512
- }, _obj[touchmove] = function(event) {
25513
- if (currentTouch && _this.enabled) {
25514
- var cood = getCoord(getTouch(event));
25515
- x = cood.x;
25516
- y = cood.y;
25517
- _this.dispatchEvent(EVENT_TYPE_TOUCH_MOVE, getTouchEventValue(event, x, y, x - currentTouch.x, y - currentTouch.y));
25518
- }
25519
- }, _obj[touchend] = function(event) {
25520
- if (currentTouch && _this.enabled) {
25521
- if (!_this.allowPropagation && event.cancelable) {
25522
- event.preventDefault();
25523
- event.stopPropagation();
26726
+ this.onNativeTouchStart = function(event) {
26727
+ if (!_this.enabled) {
26728
+ return;
26729
+ }
26730
+ _this.focusTarget();
26731
+ for(var _iterator = _create_for_of_iterator_helper_loose(Array.from(event.changedTouches)), _step; !(_step = _iterator()).done;){
26732
+ var touch = _step.value;
26733
+ var position = _this.getCanvasPosition(touch.clientX, touch.clientY);
26734
+ var state = _this.createPointerState(position);
26735
+ _this.touchStates.set(touch.identifier, state);
26736
+ state.pressed = true;
26737
+ var handled = _this.pushNativeScreenTouch(touch.identifier, position, true, false, false);
26738
+ state.controlHandled = handled;
26739
+ if (!handled) {
26740
+ var pointerEvent = _this.createPointerEvent(event, position, state);
26741
+ _this.dispatchEvent(EVENT_TYPE_TOUCH_START, pointerEvent);
25524
26742
  }
25525
- var touch = getTouch(event);
25526
- var cood = getCoord(touch);
25527
- var dt = Math.abs(currentTouch.clientX - touch.clientX) + Math.abs(currentTouch.clientY - touch.clientY);
25528
- x = cood.x;
25529
- y = cood.y;
25530
- if (dt < 4) {
25531
- _this.dispatchEvent(EVENT_TYPE_CLICK, getTouchEventValue(event, x, y));
26743
+ _this.consumeNativeEvent(event, handled);
26744
+ }
26745
+ _this.preventTouchDefaults(event);
26746
+ };
26747
+ this.onNativeTouchMove = function(event) {
26748
+ if (!_this.enabled) {
26749
+ return;
26750
+ }
26751
+ for(var _iterator = _create_for_of_iterator_helper_loose(Array.from(event.changedTouches)), _step; !(_step = _iterator()).done;){
26752
+ var touch = _step.value;
26753
+ var _state;
26754
+ var position = _this.getCanvasPosition(touch.clientX, touch.clientY);
26755
+ var _this_touchStates_get;
26756
+ var state = (_this_touchStates_get = _this.touchStates.get(touch.identifier)) != null ? _this_touchStates_get : _this.createPointerState(position);
26757
+ _this.touchStates.set(touch.identifier, state);
26758
+ var relative = new Vector2(position.x - state.last.x, position.y - state.last.y);
26759
+ var velocity = _this.getVelocity(state, position);
26760
+ var handled = _this.pushNativeScreenDrag(touch.identifier, position, relative, velocity);
26761
+ (_state = state).controlHandled || (_state.controlHandled = handled);
26762
+ if (!handled && !state.controlHandled) {
26763
+ var pointerEvent = _this.createPointerEvent(event, position, state, velocity);
26764
+ _this.dispatchEvent(EVENT_TYPE_TOUCH_MOVE, pointerEvent);
25532
26765
  }
25533
- _this.dispatchEvent(EVENT_TYPE_TOUCH_END, getTouchEventValue(event, x, y, x - currentTouch.x, y - currentTouch.y));
25534
- }
25535
- currentTouch = 0;
25536
- }, _obj);
25537
- this.nativeHandlers[touchcancel] = this.nativeHandlers[touchend];
25538
- Object.keys(this.nativeHandlers).forEach(function(name) {
25539
- var _this_target;
25540
- (_this_target = _this.target) == null ? void 0 : _this_target.addEventListener(String(name), _this.nativeHandlers[name]);
26766
+ _this.updatePointerState(state, position);
26767
+ _this.consumeNativeEvent(event, handled);
26768
+ }
26769
+ _this.preventTouchDefaults(event);
26770
+ };
26771
+ this.onNativeTouchEnd = function(event) {
26772
+ _this.handleNativeTouchEnd(event, false);
26773
+ };
26774
+ this.onNativeTouchCancel = function(event) {
26775
+ _this.handleNativeTouchEnd(event, true);
26776
+ };
26777
+ this.onWindowBlur = function() {
26778
+ if (_this.enabled) {
26779
+ _this.mouseState = null;
26780
+ _this.touchStates.clear();
26781
+ _this.mouseFromTouchIndex = null;
26782
+ _this.touchFromMousePressed = false;
26783
+ _this.engine.windowRoot.cancelPointerInput();
26784
+ }
26785
+ };
26786
+ }
26787
+ var _proto = EventSystem.prototype;
26788
+ _proto.bindListeners = function bindListeners(target) {
26789
+ this.unbindListeners();
26790
+ this.target = target;
26791
+ if (!target || typeof window === "undefined") {
26792
+ return;
26793
+ }
26794
+ if (!target.hasAttribute("tabindex")) {
26795
+ target.tabIndex = 0;
26796
+ this.addedTabIndex = true;
26797
+ }
26798
+ if (!target.style.outline) {
26799
+ target.style.outline = "none";
26800
+ this.addedOutlineStyle = true;
26801
+ }
26802
+ this.addNativeHandler(target, "mousedown", this.onNativeMouseDown);
26803
+ // The Window listener runs after the event reaches the host container, so keep a
26804
+ // target listener to preserve notifyTouch/allowPropagation for in-canvas releases.
26805
+ this.addNativeHandler(target, "mouseup", this.onNativeMouseUp);
26806
+ this.addNativeHandler(window, "mouseup", this.onNativeMouseUp);
26807
+ this.addNativeHandler(window, "pointermove", this.onNativeMouseMove);
26808
+ this.addNativeHandler(target, "touchstart", this.onNativeTouchStart, {
26809
+ passive: false
26810
+ });
26811
+ this.addNativeHandler(target, "touchmove", this.onNativeTouchMove, {
26812
+ passive: false
26813
+ });
26814
+ this.addNativeHandler(target, "touchend", this.onNativeTouchEnd, {
26815
+ passive: false
26816
+ });
26817
+ this.addNativeHandler(target, "touchcancel", this.onNativeTouchCancel, {
26818
+ passive: false
26819
+ });
26820
+ this.addNativeHandler(target, "wheel", this.onNativeWheel, {
26821
+ passive: false
25541
26822
  });
25542
- this.addEventListener(EVENT_TYPE_CLICK, this.onClick.bind(this));
25543
- this.addEventListener(EVENT_TYPE_TOUCH_START, this.onPointerDown.bind(this));
25544
- this.addEventListener(EVENT_TYPE_TOUCH_END, this.onPointerUp.bind(this));
25545
- this.addEventListener(EVENT_TYPE_TOUCH_MOVE, this.onPointerMove.bind(this));
26823
+ this.addNativeHandler(target, "keydown", this.onNativeKeyDown);
26824
+ this.addNativeHandler(target, "keyup", this.onNativeKeyUp);
26825
+ this.addNativeHandler(window, "blur", this.onWindowBlur);
25546
26826
  };
25547
26827
  _proto.dispatchEvent = function dispatchEvent(type, event) {
25548
26828
  var handlers = this.handlers[type];
25549
- handlers == null ? void 0 : handlers.forEach(function(fn) {
26829
+ handlers == null ? void 0 : handlers.slice().forEach(function(fn) {
25550
26830
  return fn(event);
25551
26831
  });
26832
+ if (type === EVENT_TYPE_CLICK) {
26833
+ this.onClick(event);
26834
+ } else if (type === EVENT_TYPE_TOUCH_START) {
26835
+ this.onPointerDown(event);
26836
+ } else if (type === EVENT_TYPE_TOUCH_END) {
26837
+ this.onPointerUp(event);
26838
+ } else if (type === EVENT_TYPE_TOUCH_MOVE) {
26839
+ this.onPointerMove(event);
26840
+ }
25552
26841
  };
25553
26842
  _proto.addEventListener = function addEventListener(type, callback) {
25554
26843
  var handlers = this.handlers[type];
@@ -25566,14 +26855,229 @@ var EventSystem = /*#__PURE__*/ function() {
25566
26855
  removeItem(handlers, callback);
25567
26856
  }
25568
26857
  };
25569
- _proto.onClick = function onClick(e) {
25570
- var x = e.x, y = e.y;
26858
+ _proto.dispose = function dispose() {
26859
+ this.engine.windowRoot.cancelPointerInput();
26860
+ this.mouseState = null;
26861
+ this.touchStates.clear();
26862
+ this.mouseFromTouchIndex = null;
26863
+ this.touchFromMousePressed = false;
26864
+ this.handlers = {};
26865
+ this.unbindListeners();
26866
+ this.target = null;
26867
+ };
26868
+ _proto.handleNativeMouseDown = function handleNativeMouseDown(event) {
26869
+ if (!this.enabled || !this.target) {
26870
+ return;
26871
+ }
26872
+ this.focusTarget();
26873
+ var position = this.getCanvasPosition(event.clientX, event.clientY);
26874
+ var state = this.createPointerState(position);
26875
+ this.mouseState = state;
26876
+ state.pressed = true;
26877
+ var handled = this.pushNativeMouseButton(event, position, true);
26878
+ state.controlHandled = handled;
26879
+ if (!handled) {
26880
+ var pointerEvent = this.createPointerEvent(event, position, state);
26881
+ this.dispatchEvent(EVENT_TYPE_TOUCH_START, pointerEvent);
26882
+ }
26883
+ this.consumeNativeEvent(event, handled);
26884
+ };
26885
+ _proto.handleNativeKey = function handleNativeKey(event, pressed) {
26886
+ if (!this.enabled) {
26887
+ return;
26888
+ }
26889
+ var input = new InputEventKey();
26890
+ input.device = InputEvent.deviceIdKeyboard;
26891
+ input.pressed = pressed;
26892
+ input.echo = pressed && event.repeat;
26893
+ input.keycode = event.key;
26894
+ input.physicalKeycode = event.code;
26895
+ input.keyLabel = event.key;
26896
+ input.unicode = getUnicode(event.key);
26897
+ input.location = getKeyLocation(event.location);
26898
+ input.shiftPressed = event.shiftKey;
26899
+ input.altPressed = event.altKey;
26900
+ input.metaPressed = event.metaKey;
26901
+ input.ctrlPressed = event.ctrlKey;
26902
+ this.engine.windowRoot.pushInput(input);
26903
+ this.consumeNativeEvent(event, this.engine.windowRoot.isInputHandled());
26904
+ };
26905
+ _proto.handleNativeTouchEnd = function handleNativeTouchEnd(event, canceled) {
26906
+ if (!this.enabled) {
26907
+ return;
26908
+ }
26909
+ for(var _iterator = _create_for_of_iterator_helper_loose(Array.from(event.changedTouches)), _step; !(_step = _iterator()).done;){
26910
+ var touch = _step.value;
26911
+ var position = this.getCanvasPosition(touch.clientX, touch.clientY);
26912
+ var state = this.touchStates.get(touch.identifier);
26913
+ if (!(state == null ? void 0 : state.pressed)) {
26914
+ continue;
26915
+ }
26916
+ var handled = this.pushNativeScreenTouch(touch.identifier, position, false, canceled, false);
26917
+ var pointerEvent = this.createPointerEvent(event, position, state);
26918
+ if (!canceled && !state.controlHandled && !handled && this.isClick(state, position)) {
26919
+ this.dispatchEvent(EVENT_TYPE_CLICK, pointerEvent);
26920
+ }
26921
+ if (!handled && !canceled && !state.controlHandled) {
26922
+ this.dispatchEvent(EVENT_TYPE_TOUCH_END, pointerEvent);
26923
+ }
26924
+ this.touchStates.delete(touch.identifier);
26925
+ this.consumeNativeEvent(event, handled || state.controlHandled || !this.allowPropagation);
26926
+ }
26927
+ this.preventTouchDefaults(event);
26928
+ };
26929
+ _proto.pushNativeMouseButton = function pushNativeMouseButton(event, position, pressed) {
26930
+ var handled = false;
26931
+ var button = getMouseButton(event.button);
26932
+ if (pressed && this.emulateTouchFromMouse && button === MouseButton.Left) {
26933
+ this.touchFromMousePressed = true;
26934
+ }
26935
+ if (this.touchFromMousePressed && button === MouseButton.Left) {
26936
+ handled = this.pushScreenTouch(0, position, pressed, false, event.detail > 1, InputEvent.deviceIdEmulation);
26937
+ if (!pressed) {
26938
+ this.touchFromMousePressed = false;
26939
+ }
26940
+ }
26941
+ return this.pushMouseButton(event, position, pressed) || handled;
26942
+ };
26943
+ _proto.pushNativeMouseMotion = function pushNativeMouseMotion(event, position, relative, velocity) {
26944
+ var handled = false;
26945
+ if (this.touchFromMousePressed && (event.buttons & 1) !== 0) {
26946
+ handled = this.pushScreenDrag(0, position, relative, velocity, InputEvent.deviceIdEmulation);
26947
+ }
26948
+ return this.pushMouseMotion(event, position, relative, velocity) || handled;
26949
+ };
26950
+ _proto.pushNativeScreenTouch = function pushNativeScreenTouch(index, position, pressed, canceled, doubleTap) {
26951
+ var handled = false;
26952
+ var emulateMouse = false;
26953
+ if (pressed && this.emulateMouseFromTouch && this.mouseFromTouchIndex === null) {
26954
+ this.mouseFromTouchIndex = index;
26955
+ emulateMouse = true;
26956
+ } else if (!pressed && this.mouseFromTouchIndex === index) {
26957
+ emulateMouse = true;
26958
+ this.mouseFromTouchIndex = null;
26959
+ }
26960
+ if (emulateMouse) {
26961
+ handled = this.pushEmulatedMouseButton(position, pressed, canceled, doubleTap);
26962
+ }
26963
+ return this.pushScreenTouch(index, position, pressed, canceled, doubleTap, 0) || handled;
26964
+ };
26965
+ _proto.pushNativeScreenDrag = function pushNativeScreenDrag(index, position, relative, velocity) {
26966
+ var handled = false;
26967
+ if (this.emulateMouseFromTouch && this.mouseFromTouchIndex === index) {
26968
+ handled = this.pushEmulatedMouseMotion(position, relative, velocity);
26969
+ }
26970
+ return this.pushScreenDrag(index, position, relative, velocity, 0) || handled;
26971
+ };
26972
+ _proto.pushEmulatedMouseButton = function pushEmulatedMouseButton(position, pressed, canceled, doubleClick) {
26973
+ var input = new InputEventMouseButton();
26974
+ input.device = InputEvent.deviceIdEmulation;
26975
+ input.position.copyFrom(position);
26976
+ input.globalPosition.copyFrom(position);
26977
+ input.buttonIndex = MouseButton.Left;
26978
+ input.buttonMask = pressed ? MouseButtonMask.Left : MouseButtonMask.None;
26979
+ input.pressed = pressed;
26980
+ input.canceled = canceled;
26981
+ input.doubleClick = doubleClick;
26982
+ this.engine.windowRoot.pushInput(input);
26983
+ return this.engine.windowRoot.isInputHandled();
26984
+ };
26985
+ _proto.pushEmulatedMouseMotion = function pushEmulatedMouseMotion(position, relative, velocity) {
26986
+ var input = new InputEventMouseMotion();
26987
+ input.device = InputEvent.deviceIdEmulation;
26988
+ input.position.copyFrom(position);
26989
+ input.globalPosition.copyFrom(position);
26990
+ input.buttonMask = MouseButtonMask.Left;
26991
+ input.pressed = true;
26992
+ input.relative.copyFrom(relative);
26993
+ input.screenRelative.copyFrom(relative);
26994
+ input.velocity.copyFrom(velocity);
26995
+ input.screenVelocity.copyFrom(velocity);
26996
+ this.engine.windowRoot.pushInput(input);
26997
+ return this.engine.windowRoot.isInputHandled();
26998
+ };
26999
+ _proto.pushMouseButton = function pushMouseButton(event, position, pressed) {
27000
+ var input = new InputEventMouseButton();
27001
+ this.copyMouseFields(input, event, position);
27002
+ input.device = InputEvent.deviceIdMouse;
27003
+ input.buttonIndex = getMouseButton(event.button);
27004
+ input.buttonMask = getMouseButtonMask(event.buttons);
27005
+ if (pressed) {
27006
+ input.buttonMask |= getMouseButtonBit(input.buttonIndex);
27007
+ } else {
27008
+ input.buttonMask &= ~getMouseButtonBit(input.buttonIndex);
27009
+ }
27010
+ input.pressed = pressed;
27011
+ input.doubleClick = event.detail > 1;
27012
+ this.engine.windowRoot.pushInput(input);
27013
+ return this.engine.windowRoot.isInputHandled();
27014
+ };
27015
+ _proto.pushWheelButton = function pushWheelButton(button, factor, position, event) {
27016
+ var input = new InputEventMouseButton();
27017
+ this.copyMouseFields(input, event, position);
27018
+ input.device = InputEvent.deviceIdMouse;
27019
+ input.buttonIndex = button;
27020
+ input.buttonMask = getMouseButtonMask(event.buttons);
27021
+ input.factor = factor;
27022
+ input.pressed = true;
27023
+ this.engine.windowRoot.pushInput(input);
27024
+ return this.engine.windowRoot.isInputHandled();
27025
+ };
27026
+ _proto.pushMouseMotion = function pushMouseMotion(event, position, relative, velocity) {
27027
+ var input = new InputEventMouseMotion();
27028
+ this.copyMouseFields(input, event, position);
27029
+ input.device = InputEvent.deviceIdMouse;
27030
+ input.buttonMask = getMouseButtonMask(event.buttons);
27031
+ input.pressed = event.buttons !== 0;
27032
+ input.relative.copyFrom(relative);
27033
+ input.screenRelative.copyFrom(relative);
27034
+ input.velocity.copyFrom(velocity);
27035
+ input.screenVelocity.copyFrom(velocity);
27036
+ if ("pressure" in event) {
27037
+ input.pressure = event.pressure;
27038
+ input.tilt.set(event.tiltX, event.tiltY);
27039
+ }
27040
+ this.engine.windowRoot.pushInput(input);
27041
+ return this.engine.windowRoot.isInputHandled();
27042
+ };
27043
+ _proto.pushScreenTouch = function pushScreenTouch(index, position, pressed, canceled, doubleTap, device) {
27044
+ var input = new InputEventScreenTouch();
27045
+ input.index = index;
27046
+ input.device = device;
27047
+ input.position.copyFrom(position);
27048
+ input.pressed = pressed;
27049
+ input.canceled = canceled;
27050
+ input.doubleTap = doubleTap;
27051
+ this.engine.windowRoot.pushInput(input);
27052
+ return this.engine.windowRoot.isInputHandled();
27053
+ };
27054
+ _proto.pushScreenDrag = function pushScreenDrag(index, position, relative, velocity, device) {
27055
+ var input = new InputEventScreenDrag();
27056
+ input.index = index;
27057
+ input.device = device;
27058
+ input.position.copyFrom(position);
27059
+ input.relative.copyFrom(relative);
27060
+ input.screenRelative.copyFrom(relative);
27061
+ input.velocity.copyFrom(velocity);
27062
+ input.screenVelocity.copyFrom(velocity);
27063
+ input.pressed = true;
27064
+ this.engine.windowRoot.pushInput(input);
27065
+ return this.engine.windowRoot.isInputHandled();
27066
+ };
27067
+ _proto.copyMouseFields = function copyMouseFields(input, event, position) {
27068
+ input.position.copyFrom(position);
27069
+ input.globalPosition.copyFrom(position);
27070
+ input.shiftPressed = event.shiftKey;
27071
+ input.altPressed = event.altKey;
27072
+ input.metaPressed = event.metaKey;
27073
+ input.ctrlPressed = event.ctrlKey;
27074
+ };
27075
+ _proto.onClick = function onClick(event) {
25571
27076
  var hitResults = [];
25572
- // 收集所有的点击测试结果,click 回调执行可能会对 composition 点击结果有影响,放在点击测试执行完后再统一触发。
25573
27077
  for(var _iterator = _create_for_of_iterator_helper_loose(this.engine.compositions), _step; !(_step = _iterator()).done;){
25574
27078
  var composition = _step.value;
25575
27079
  var _hitResults;
25576
- (_hitResults = hitResults).push.apply(_hitResults, [].concat(composition.hitTest(x, y)));
27080
+ (_hitResults = hitResults).push.apply(_hitResults, [].concat(composition.hitTest(event.x, event.y)));
25577
27081
  }
25578
27082
  for(var _iterator1 = _create_for_of_iterator_helper_loose(hitResults), _step1; !(_step1 = _iterator1()).done;){
25579
27083
  var hitResult = _step1.value;
@@ -25590,49 +27094,36 @@ var EventSystem = /*#__PURE__*/ function() {
25590
27094
  this.engine.emit("click", clickInfo);
25591
27095
  }
25592
27096
  };
25593
- _proto.onPointerDown = function onPointerDown(e) {
25594
- this.handlePointerEvent(e, 0);
27097
+ _proto.onPointerDown = function onPointerDown(event) {
27098
+ this.handlePointerEvent(event, 0);
25595
27099
  };
25596
- _proto.onPointerUp = function onPointerUp(e) {
25597
- this.handlePointerEvent(e, 1);
27100
+ _proto.onPointerUp = function onPointerUp(event) {
27101
+ this.handlePointerEvent(event, 1);
25598
27102
  };
25599
- _proto.onPointerMove = function onPointerMove(e) {
25600
- this.handlePointerEvent(e, 2);
27103
+ _proto.onPointerMove = function onPointerMove(event) {
27104
+ this.handlePointerEvent(event, 2);
25601
27105
  };
25602
- _proto.handlePointerEvent = function handlePointerEvent(e, type) {
27106
+ _proto.handlePointerEvent = function handlePointerEvent(event, type) {
25603
27107
  var hitRegion = null;
25604
- var x = e.x, y = e.y, width = e.width, height = e.height;
25605
27108
  if (!(type === 2 && this.skipPointerMovePicking)) {
25606
27109
  for(var _iterator = _create_for_of_iterator_helper_loose(this.engine.compositions), _step; !(_step = _iterator()).done;){
25607
27110
  var composition = _step.value;
25608
- var regions = composition.hitTest(x, y);
27111
+ var regions = composition.hitTest(event.x, event.y);
25609
27112
  if (regions.length > 0) {
25610
27113
  hitRegion = regions[regions.length - 1];
25611
27114
  }
25612
27115
  }
25613
27116
  }
25614
27117
  var eventData = new PointerEventData();
25615
- eventData.position.x = (x + 1) / 2 * width;
25616
- eventData.position.y = (y + 1) / 2 * height;
25617
- eventData.delta.x = e.vx * width;
25618
- eventData.delta.y = e.vy * height;
25619
- var raycast = eventData.pointerCurrentRaycast;
27118
+ eventData.position.x = (event.x + 1) / 2 * event.width;
27119
+ eventData.position.y = (event.y + 1) / 2 * event.height;
27120
+ eventData.delta.x = event.vx * event.width;
27121
+ eventData.delta.y = event.vy * event.height;
25620
27122
  if (hitRegion) {
25621
- raycast.point = hitRegion.position;
25622
- raycast.item = hitRegion.item;
25623
- }
25624
- var eventName = "pointerdown";
25625
- switch(type){
25626
- case 0:
25627
- eventName = "pointerdown";
25628
- break;
25629
- case 1:
25630
- eventName = "pointerup";
25631
- break;
25632
- case 2:
25633
- eventName = "pointermove";
25634
- break;
27123
+ eventData.pointerCurrentRaycast.point = hitRegion.position;
27124
+ eventData.pointerCurrentRaycast.item = hitRegion.item;
25635
27125
  }
27126
+ var eventName = type === 0 ? "pointerdown" : type === 1 ? "pointerup" : "pointermove";
25636
27127
  if (hitRegion) {
25637
27128
  var hitItem = hitRegion.item;
25638
27129
  var hitComposition = hitItem.composition;
@@ -25641,29 +27132,184 @@ var EventSystem = /*#__PURE__*/ function() {
25641
27132
  this.engine.emit(eventName, eventData);
25642
27133
  }
25643
27134
  };
25644
- _proto.dispose = function dispose() {
25645
- var _this = this;
25646
- if (this.target) {
25647
- this.handlers = {};
25648
- Object.keys(this.nativeHandlers).forEach(function(name) {
25649
- var _this_target;
25650
- (_this_target = _this.target) == null ? void 0 : _this_target.removeEventListener(String(name), _this.nativeHandlers[name]);
25651
- });
25652
- this.nativeHandlers = {};
27135
+ _proto.createPointerState = function createPointerState(position) {
27136
+ var state = {
27137
+ start: position.clone(),
27138
+ last: position.clone(),
27139
+ lastTime: performance.now(),
27140
+ controlHandled: false,
27141
+ pressed: false
27142
+ };
27143
+ return state;
27144
+ };
27145
+ _proto.updatePointerState = function updatePointerState(state, position) {
27146
+ state.last.copyFrom(position);
27147
+ state.lastTime = performance.now();
27148
+ };
27149
+ _proto.getVelocity = function getVelocity(state, position) {
27150
+ var elapsed = Math.max(performance.now() - state.lastTime, 1);
27151
+ return new Vector2((position.x - state.last.x) / elapsed, (position.y - state.last.y) / elapsed);
27152
+ };
27153
+ _proto.isClick = function isClick(state, position) {
27154
+ return Math.abs(position.x - state.start.x) + Math.abs(position.y - state.start.y) < 4;
27155
+ };
27156
+ _proto.createPointerEvent = function createPointerEvent(origin, position, state, velocity) {
27157
+ if (velocity === void 0) velocity = new Vector2();
27158
+ var target = this.target;
27159
+ var rect = target == null ? void 0 : target.getBoundingClientRect();
27160
+ var cssWidth = (rect == null ? void 0 : rect.width) || 1;
27161
+ var cssHeight = (rect == null ? void 0 : rect.height) || 1;
27162
+ var _target_width, _target_height;
27163
+ return {
27164
+ x: position.x / cssWidth * 2 - 1,
27165
+ y: position.y / cssHeight * 2 - 1,
27166
+ vx: velocity.x / cssWidth * 2,
27167
+ vy: velocity.y / cssHeight * 2,
27168
+ ts: performance.now(),
27169
+ dx: (position.x - state.start.x) / cssWidth * 2,
27170
+ dy: (position.y - state.start.y) / cssHeight * 2,
27171
+ width: (_target_width = target == null ? void 0 : target.width) != null ? _target_width : 0,
27172
+ height: (_target_height = target == null ? void 0 : target.height) != null ? _target_height : 0,
27173
+ origin: origin
27174
+ };
27175
+ };
27176
+ _proto.getCanvasPosition = function getCanvasPosition(clientX, clientY) {
27177
+ var _this_target;
27178
+ var rect = (_this_target = this.target) == null ? void 0 : _this_target.getBoundingClientRect();
27179
+ if (!rect) {
27180
+ return new Vector2();
27181
+ }
27182
+ return new Vector2(clientX - rect.left, rect.bottom - clientY);
27183
+ };
27184
+ _proto.consumeNativeEvent = function consumeNativeEvent(event, handled) {
27185
+ if (handled && !this.allowPropagation) {
27186
+ if (event.cancelable) {
27187
+ event.preventDefault();
27188
+ }
27189
+ event.stopPropagation();
27190
+ }
27191
+ };
27192
+ _proto.preventTouchDefaults = function preventTouchDefaults(event) {
27193
+ if (event.cancelable) {
27194
+ event.preventDefault();
25653
27195
  }
25654
27196
  };
27197
+ _proto.focusTarget = function focusTarget() {
27198
+ if (this.target && document.activeElement !== this.target) {
27199
+ this.target.focus();
27200
+ }
27201
+ };
27202
+ _proto.addNativeHandler = function addNativeHandler(target, name, handler, options) {
27203
+ target.addEventListener(name, handler, options);
27204
+ this.nativeHandlers.push({
27205
+ target: target,
27206
+ name: name,
27207
+ handler: handler,
27208
+ options: options
27209
+ });
27210
+ };
27211
+ _proto.unbindListeners = function unbindListeners() {
27212
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.nativeHandlers), _step; !(_step = _iterator()).done;){
27213
+ var nativeHandler = _step.value;
27214
+ nativeHandler.target.removeEventListener(nativeHandler.name, nativeHandler.handler, nativeHandler.options);
27215
+ }
27216
+ this.nativeHandlers = [];
27217
+ if (this.addedTabIndex && this.target) {
27218
+ this.target.removeAttribute("tabindex");
27219
+ }
27220
+ if (this.addedOutlineStyle && this.target) {
27221
+ this.target.style.removeProperty("outline");
27222
+ }
27223
+ this.addedTabIndex = false;
27224
+ this.addedOutlineStyle = false;
27225
+ };
27226
+ _create_class(EventSystem, [
27227
+ {
27228
+ key: "enabled",
27229
+ get: function get() {
27230
+ return this._enabled;
27231
+ },
27232
+ set: function set(value) {
27233
+ if (this._enabled === value) {
27234
+ return;
27235
+ }
27236
+ this._enabled = value;
27237
+ if (!value) {
27238
+ this.mouseState = null;
27239
+ this.touchStates.clear();
27240
+ this.mouseFromTouchIndex = null;
27241
+ this.touchFromMousePressed = false;
27242
+ this.engine.windowRoot.cancelPointerInput();
27243
+ }
27244
+ }
27245
+ }
27246
+ ]);
25655
27247
  return EventSystem;
25656
27248
  }();
25657
- function getCoord(event) {
25658
- var ele = event.target;
25659
- var clientX = event.clientX, clientY = event.clientY;
25660
- var _ele_getBoundingClientRect = ele.getBoundingClientRect(), left = _ele_getBoundingClientRect.left, top = _ele_getBoundingClientRect.top, width = _ele_getBoundingClientRect.width, height = _ele_getBoundingClientRect.height;
25661
- var x = (clientX - left) / width * 2 - 1;
25662
- var y = 1 - (clientY - top) / height * 2;
25663
- return {
25664
- x: x,
25665
- y: y
25666
- };
27249
+ function getKeyLocation(location) {
27250
+ if (location === 1) {
27251
+ return KeyLocation.Left;
27252
+ }
27253
+ if (location === 2) {
27254
+ return KeyLocation.Right;
27255
+ }
27256
+ return KeyLocation.Unspecified;
27257
+ }
27258
+ function getUnicode(key) {
27259
+ var characters = Array.from(key);
27260
+ var _characters__codePointAt;
27261
+ return characters.length === 1 ? (_characters__codePointAt = characters[0].codePointAt(0)) != null ? _characters__codePointAt : 0 : 0;
27262
+ }
27263
+ function getMouseButton(button) {
27264
+ switch(button){
27265
+ case 0:
27266
+ return MouseButton.Left;
27267
+ case 1:
27268
+ return MouseButton.Middle;
27269
+ case 2:
27270
+ return MouseButton.Right;
27271
+ case 3:
27272
+ return MouseButton.Xbutton1;
27273
+ case 4:
27274
+ return MouseButton.Xbutton2;
27275
+ default:
27276
+ return MouseButton.None;
27277
+ }
27278
+ }
27279
+ function getMouseButtonMask(buttons) {
27280
+ var mask = MouseButtonMask.None;
27281
+ if ((buttons & 1) !== 0) {
27282
+ mask |= MouseButtonMask.Left;
27283
+ }
27284
+ if ((buttons & 2) !== 0) {
27285
+ mask |= MouseButtonMask.Right;
27286
+ }
27287
+ if ((buttons & 4) !== 0) {
27288
+ mask |= MouseButtonMask.Middle;
27289
+ }
27290
+ if ((buttons & 8) !== 0) {
27291
+ mask |= MouseButtonMask.Xbutton1;
27292
+ }
27293
+ if ((buttons & 16) !== 0) {
27294
+ mask |= MouseButtonMask.Xbutton2;
27295
+ }
27296
+ return mask;
27297
+ }
27298
+ function getMouseButtonBit(button) {
27299
+ switch(button){
27300
+ case MouseButton.Left:
27301
+ return MouseButtonMask.Left;
27302
+ case MouseButton.Right:
27303
+ return MouseButtonMask.Right;
27304
+ case MouseButton.Middle:
27305
+ return MouseButtonMask.Middle;
27306
+ case MouseButton.Xbutton1:
27307
+ return MouseButtonMask.Xbutton1;
27308
+ case MouseButton.Xbutton2:
27309
+ return MouseButtonMask.Xbutton2;
27310
+ default:
27311
+ return MouseButtonMask.None;
27312
+ }
25667
27313
  }
25668
27314
 
25669
27315
  var InteractLoader = /*#__PURE__*/ function(Plugin) {
@@ -27684,11 +29330,6 @@ SpritePropertyTrack = __decorate([
27684
29330
  effectsClass("SpritePropertyTrack")
27685
29331
  ], SpritePropertyTrack);
27686
29332
 
27687
- function _assert_this_initialized(self) {
27688
- if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
27689
- return self;
27690
- }
27691
-
27692
29333
  var Cone = /*#__PURE__*/ function() {
27693
29334
  function Cone(props) {
27694
29335
  var _this = this;
@@ -37693,7 +39334,7 @@ function getStandardSpriteContent(sprite, transform) {
37693
39334
  return ret;
37694
39335
  }
37695
39336
 
37696
- var version$2 = "2.10.0-alpha.2";
39337
+ var version$2 = "2.10.0-alpha.3";
37697
39338
  var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
37698
39339
  var standardVersion = /^(\d+)\.(\d+)$/;
37699
39340
  var reverseParticle = false;
@@ -39645,10 +41286,11 @@ var PreRenderTickData = /*#__PURE__*/ function(TickData) {
39645
41286
  _this./**
39646
41287
  * 是否开启后处理
39647
41288
  */ postProcessingEnabled = false;
39648
- _this.canvasLayers = [];
39649
41289
  _this.destroyed = false;
39650
41290
  _this.paused = true;
39651
41291
  _this.isEndCalled = false;
41292
+ _this._renderOrder = 0;
41293
+ _this._interactive = true;
39652
41294
  _this._textures = [];
39653
41295
  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;
39654
41296
  _this.engine.addComposition(_assert_this_initialized(_this));
@@ -39681,13 +41323,14 @@ var PreRenderTickData = /*#__PURE__*/ function(TickData) {
39681
41323
  _this.root = new VFXItem(_this.engine);
39682
41324
  _this.root.name = "root";
39683
41325
  _this.root.composition = _assert_this_initialized(_this);
41326
+ _this.root.setParent(_this.engine.root);
39684
41327
  _this.pluginRoot = new VFXItem(_this.engine);
39685
41328
  _this.pluginRoot.name = "pluginRoot";
39686
41329
  _this.pluginRoot.setParent(_this.root);
39687
- _this.pluginRoot.addComponent(CanvasLayer);
39688
41330
  // Instantiate composition rootItem
39689
41331
  _this.sceneRoot = new VFXItem(_this.engine);
39690
41332
  _this.sceneRoot.setParent(_this.root);
41333
+ _this.uiCanvas = _this.sceneRoot.addComponent(UICanvas);
39691
41334
  if (sourceContent) {
39692
41335
  _this.sceneRoot.setInstanceId(sourceContent.id);
39693
41336
  _this.sceneRoot.instantiatePreComposition(sourceContent, false);
@@ -39886,9 +41529,13 @@ var PreRenderTickData = /*#__PURE__*/ function(TickData) {
39886
41529
  this.isEndCalled = false;
39887
41530
  this.rootComposition.setTime(0);
39888
41531
  };
39889
- _proto.render = function render() {
41532
+ /** Renders this Composition content. Screen-space UI is rendered by Engine. */ _proto.render = function render() {
41533
+ this.renderContent();
41534
+ };
41535
+ /**
41536
+ * Renders only the Composition scene content.
41537
+ */ _proto.renderContent = function renderContent() {
39890
41538
  this.renderer.renderRenderFrame(this.renderFrame);
39891
- this.renderCanvasLayers();
39892
41539
  };
39893
41540
  /**
39894
41541
  * 合成更新,针对所有 item 的更新
@@ -39977,17 +41624,6 @@ var PreRenderTickData = /*#__PURE__*/ function(TickData) {
39977
41624
  }
39978
41625
  }
39979
41626
  };
39980
- _proto.renderCanvasLayers = function renderCanvasLayers() {
39981
- this.engine.graphics.begin();
39982
- this.canvasLayers.sort(function(leftLayer, rightLayer) {
39983
- return leftLayer.layer - rightLayer.layer;
39984
- });
39985
- for(var _iterator = _create_for_of_iterator_helper_loose(this.canvasLayers), _step; !(_step = _iterator()).done;){
39986
- var canvasLayer = _step.value;
39987
- canvasLayer.draw();
39988
- }
39989
- this.engine.graphics.end();
39990
- };
39991
41627
  /**
39992
41628
  * @internal
39993
41629
  */ _proto.createTexturesFromData = function createTexturesFromData(textureDataList) {
@@ -40256,6 +41892,35 @@ var PreRenderTickData = /*#__PURE__*/ function(TickData) {
40256
41892
  })();
40257
41893
  };
40258
41894
  _create_class(Composition, [
41895
+ {
41896
+ key: "renderOrder",
41897
+ get: /**
41898
+ * 合成渲染顺序,默认按升序渲染
41899
+ */ function get() {
41900
+ return this._renderOrder;
41901
+ },
41902
+ set: function set(value) {
41903
+ this._renderOrder = value;
41904
+ if (this.uiCanvas) {
41905
+ this.uiCanvas.order = value;
41906
+ }
41907
+ }
41908
+ },
41909
+ {
41910
+ key: "interactive",
41911
+ get: /**
41912
+ * 合成内的元素否允许点击、拖拽交互
41913
+ * @since 1.6.0
41914
+ */ function get() {
41915
+ return this._interactive;
41916
+ },
41917
+ set: function set(value) {
41918
+ this._interactive = !!value;
41919
+ if (this.uiCanvas) {
41920
+ this.uiCanvas.receivesEvents = this._interactive;
41921
+ }
41922
+ }
41923
+ },
40259
41924
  {
40260
41925
  key: "width",
40261
41926
  get: /**
@@ -42033,7 +43698,6 @@ var DEFAULT_FPS = 60;
42033
43698
  /**
42034
43699
  * 渲染过程中错误队列
42035
43700
  */ _this.renderErrors = new Set();
42036
- _this.compositions = [];
42037
43701
  _this.assetManagers = [];
42038
43702
  _this.env = "";
42039
43703
  /**
@@ -42055,6 +43719,7 @@ var DEFAULT_FPS = 60;
42055
43719
  _this.framebuffers = [];
42056
43720
  _this.renderbuffers = [];
42057
43721
  _this.particleSystems = [];
43722
+ _this._compositions = [];
42058
43723
  _this.clearAction = {
42059
43724
  stencilAction: TextureLoadAction.clear,
42060
43725
  clearStencil: 0,
@@ -42079,6 +43744,9 @@ var DEFAULT_FPS = 60;
42079
43744
  _this.pixelRatio = (_options_pixelRatio = options == null ? void 0 : options.pixelRatio) != null ? _options_pixelRatio : getPixelRatio();
42080
43745
  _this.jsonSceneData = {};
42081
43746
  _this.objectInstance = {};
43747
+ _this.root = new VFXItem(_assert_this_initialized(_this));
43748
+ _this.root.name = "root";
43749
+ _this.windowRoot = new WindowRootControl(_assert_this_initialized(_this));
42082
43750
  _this.whiteTexture = generateWhiteTexture(_assert_this_initialized(_this));
42083
43751
  _this.transparentTexture = generateEmptyTexture(_assert_this_initialized(_this));
42084
43752
  if (!(options == null ? void 0 : options.manualRender)) {
@@ -42213,9 +43881,6 @@ var DEFAULT_FPS = 60;
42213
43881
  // Sort compositions by index
42214
43882
  //-------------------------------------------------------------------------
42215
43883
  var compositions = this.compositions;
42216
- compositions.sort(function(a, b) {
42217
- return a.getIndex() - b.getIndex();
42218
- });
42219
43884
  var skipRender = false;
42220
43885
  // Update Compositions
42221
43886
  //-------------------------------------------------------------------------
@@ -42234,6 +43899,7 @@ var DEFAULT_FPS = 60;
42234
43899
  (_this_ticker1 = this.ticker) == null ? void 0 : _this_ticker1.pause();
42235
43900
  return;
42236
43901
  }
43902
+ this.windowRoot.update(dt);
42237
43903
  // Tick compositions onPreRender
42238
43904
  //-------------------------------------------------------------------------
42239
43905
  for(var _iterator1 = _create_for_of_iterator_helper_loose(compositions), _step1; !(_step1 = _iterator1()).done;){
@@ -42246,8 +43912,9 @@ var DEFAULT_FPS = 60;
42246
43912
  this.renderer.clear(this.clearAction);
42247
43913
  for(var _iterator2 = _create_for_of_iterator_helper_loose(compositions), _step2; !(_step2 = _iterator2()).done;){
42248
43914
  var composition2 = _step2.value;
42249
- composition2.render();
43915
+ composition2.renderContent();
42250
43916
  }
43917
+ this.windowRoot.render();
42251
43918
  this.renderTargetPool.flush();
42252
43919
  };
42253
43920
  /**
@@ -42289,6 +43956,7 @@ var DEFAULT_FPS = 60;
42289
43956
  this.canvas.style.height = containerHeight + "px";
42290
43957
  logger.info("Resize engine " + this.name + " [" + canvasWidth + "," + canvasHeight + "," + containerWidth + "," + containerHeight + "].");
42291
43958
  this.setSize(canvasWidth, canvasHeight);
43959
+ this.windowRoot.resize(canvasWidth, canvasHeight);
42292
43960
  }
42293
43961
  };
42294
43962
  _proto.setSize = function setSize(width, height) {
@@ -42296,7 +43964,7 @@ var DEFAULT_FPS = 60;
42296
43964
  if (this.getWidth() !== width || this.getHeight() !== height) {
42297
43965
  this.canvas.width = width;
42298
43966
  this.canvas.height = height;
42299
- this.viewport(0, 0, width, height);
43967
+ this.setViewport(0, 0, width, height);
42300
43968
  }
42301
43969
  (_this_compositions = this.compositions) == null ? void 0 : _this_compositions.forEach(function(comp) {
42302
43970
  comp.camera.aspect = width / height;
@@ -42325,6 +43993,26 @@ var DEFAULT_FPS = 60;
42325
43993
  /** @hide */ _proto.bindBuffers = function bindBuffers(vertexBuffers, indexBuffer, effect) {
42326
43994
  throw new Error("The active rendering backend cannot bind geometry buffers.");
42327
43995
  };
43996
+ /**
43997
+ * 使用当前绑定的顶点和索引缓冲区绘制图元。
43998
+ * @param mode - 图元类型
43999
+ * @param indexOffset - 索引缓冲区中的字节偏移
44000
+ * @param indexCount - 索引数量
44001
+ * @param instanceCount - 实例数量
44002
+ * @hide
44003
+ */ _proto.drawElementsType = function drawElementsType(mode, indexOffset, indexCount, instanceCount) {
44004
+ throw new Error("The active rendering backend cannot draw indexed primitives.");
44005
+ };
44006
+ /**
44007
+ * 使用当前绑定的顶点缓冲区绘制图元。
44008
+ * @param mode - 图元类型
44009
+ * @param vertexStart - 起始顶点
44010
+ * @param vertexCount - 顶点数量
44011
+ * @param instanceCount - 实例数量
44012
+ * @hide
44013
+ */ _proto.drawArraysType = function drawArraysType(mode, vertexStart, vertexCount, instanceCount) {
44014
+ throw new Error("The active rendering backend cannot draw primitives.");
44015
+ };
42328
44016
  _proto.addTexture = function addTexture(tex) {
42329
44017
  if (this.disposed) {
42330
44018
  return;
@@ -42456,15 +44144,12 @@ var DEFAULT_FPS = 60;
42456
44144
  * @param height
42457
44145
  * example:
42458
44146
  * gl.viewport(0, 0, width, height);
42459
- */ _proto.viewport = function viewport(x, y, width, height) {
44147
+ */ _proto.setViewport = function setViewport(x, y, width, height) {
42460
44148
  // OVERRIDE
42461
44149
  };
42462
44150
  _proto.clear = function clear(action) {
42463
44151
  // OVERRIDE
42464
44152
  };
42465
- _proto.drawGeometry = function drawGeometry(geometry, matrix, material, subMeshIndex) {
42466
- // OVERRIDE
42467
- };
42468
44153
  /*** 渲染状态控制 ***/ _proto.setSampleAlphaToCoverage = function setSampleAlphaToCoverage(enable) {
42469
44154
  // OVERRIDE
42470
44155
  };
@@ -42549,6 +44234,12 @@ var DEFAULT_FPS = 60;
42549
44234
  }
42550
44235
  (_this_ticker = this.ticker) == null ? void 0 : _this_ticker.stop();
42551
44236
  (_this_eventSystem = this.eventSystem) == null ? void 0 : _this_eventSystem.dispose();
44237
+ for(var _iterator = _create_for_of_iterator_helper_loose(this._compositions.slice()), _step; !(_step = _iterator()).done;){
44238
+ var composition = _step.value;
44239
+ composition.dispose();
44240
+ }
44241
+ this.root.dispose();
44242
+ this.windowRoot.dispose();
42552
44243
  (_this_assetService = this.assetService) == null ? void 0 : _this_assetService.dispose();
42553
44244
  (_this__graphics = this._graphics) == null ? void 0 : _this__graphics.dispose();
42554
44245
  this.renderPasses.forEach(function(pass) {
@@ -42569,16 +44260,13 @@ var DEFAULT_FPS = 60;
42569
44260
  this.assetManagers.forEach(function(assetManager) {
42570
44261
  return assetManager.dispose();
42571
44262
  });
42572
- this.compositions.forEach(function(comp) {
42573
- return comp.dispose();
42574
- });
42575
44263
  this.textures = [];
42576
44264
  this.materials = [];
42577
44265
  this.geometries = [];
42578
44266
  this.meshes = [];
42579
44267
  this.renderPasses = [];
42580
- this.compositions = [];
42581
44268
  this.particleSystems = [];
44269
+ this._compositions = [];
42582
44270
  };
42583
44271
  _proto.getTargetSize = function getTargetSize(parentEle) {
42584
44272
  if (parentEle === undefined || parentEle === null) {
@@ -42631,6 +44319,14 @@ var DEFAULT_FPS = 60;
42631
44319
  ];
42632
44320
  };
42633
44321
  _create_class(Engine, [
44322
+ {
44323
+ key: "compositions",
44324
+ get: function get() {
44325
+ return this._compositions.sort(function(a, b) {
44326
+ return a.getIndex() - b.getIndex();
44327
+ });
44328
+ }
44329
+ },
42634
44330
  {
42635
44331
  key: "graphics",
42636
44332
  get: function get() {
@@ -42868,7 +44564,7 @@ registerPlugin("text", TextLoader);
42868
44564
  registerPlugin("sprite", SpriteLoader);
42869
44565
  registerPlugin("particle", ParticleLoader);
42870
44566
  registerPlugin("interact", InteractLoader);
42871
- var version$1 = "2.10.0-alpha.2";
44567
+ var version$1 = "2.10.0-alpha.3";
42872
44568
  logger.info("Core version: " + version$1 + ".");
42873
44569
 
42874
44570
  var _obj;
@@ -43815,7 +45511,7 @@ function disposeThreeGeometry(source) {
43815
45511
  return Composition.call(this, engine, props, scene);
43816
45512
  }
43817
45513
  var _proto = ThreeComposition.prototype;
43818
- _proto.render = function render() {
45514
+ _proto.renderContent = function renderContent() {
43819
45515
  var render = this.renderer;
43820
45516
  var frame = this.renderFrame;
43821
45517
  frame.renderPasses[0].meshes.length = 0;
@@ -43850,6 +45546,8 @@ var ThreeRenderer = /*#__PURE__*/ function(Renderer) {
43850
45546
  _proto.getHeight = function getHeight() {
43851
45547
  return this.engine.canvas.height;
43852
45548
  };
45549
+ _proto.drawGeometry = function drawGeometry(geometry, matrix, material, subMeshIndex) {
45550
+ };
43853
45551
  return ThreeRenderer;
43854
45552
  }(Renderer);
43855
45553
 
@@ -44359,8 +46057,8 @@ applyMixins(ThreeTextComponent, [
44359
46057
  */ Mesh.create = function(engine, props) {
44360
46058
  return new ThreeMesh(engine, props);
44361
46059
  };
44362
- var version = "2.10.0-alpha.2";
46060
+ var version = "2.10.0-alpha.3";
44363
46061
  logger.info("THREEJS plugin version: " + version + ".");
44364
46062
 
44365
- export { ATLAS_SIZE, ActivationMixerPlayable, ActivationPlayable, ActivationPlayableAsset, ActivationTrack, AndNode, AndNodeData, Animatable, AnimationClip, AnimationClipNode, AnimationClipNodeData, AnimationEvent, AnimationGraphAsset, Animator, ApplyAdditiveNode, ApplyAdditiveNodeData, Asset, AssetLoader, AssetManager, AssetService, BYTES_TYPE_MAP, Behaviour, BezierCurve, BezierCurvePath, BezierCurveQuat, BezierDataMap, BezierEasing, BezierLengthData, BezierMap, BezierPath, BezierQuat, BinaryAsset, BlendNode, BlendNodeData, BoolValueNode, BoundingBoxInfo, Buffer, BufferDataType, BufferUsage, CONSTANT_MAP_BLEND, CONSTANT_MAP_DEPTH, CONSTANT_MAP_STENCIL_FUNC, CONSTANT_MAP_STENCIL_OP, COPY_FRAGMENT_SHADER, COPY_MESH_SHADER_ID, COPY_VERTEX_SHADER, Camera, CameraController, CameraVFXItemLoader, CanvasItem, CanvasLayer, Circle$1 as Circle, ColorCurve, ColorPlayable, ColorPropertyMixerPlayable, ColorPropertyPlayableAsset, ColorPropertyTrack, Component, ComponentTimePlayable, ComponentTimePlayableAsset, ComponentTimeTrack, Composition, CompositionComponent, CompressTextureCapabilityType, ConstBoolNode, ConstBoolNodeData, ConstFloatNode, ConstFloatNodeData, ConstraintTarget, Control, ControlParameterBoolNode, ControlParameterBoolNodeData, ControlParameterFloatNode, ControlParameterFloatNodeData, ControlParameterTriggerNode, ControlParameterTriggerNodeData, DEFAULT_FONTS, DEFAULT_FPS, DataBuffer, Database, Deferred, DestroyOptions, Downloader, DrawObjectPass, EFFECTS_COPY_MESH_NAME, EVENT_TYPE_CLICK, EVENT_TYPE_TOUCH_END, EVENT_TYPE_TOUCH_MOVE, EVENT_TYPE_TOUCH_START, EffectComponent, EffectComponentTimeTrack, EffectsObject, EffectsPackage, Ellipse, Engine, EqualNodeData, EventEmitter, EventSystem, FONT_SCALE, Fake3DAnimationMode, Fake3DComponent, FilterMode, Float16ArrayWrapper, FloatComparisonNode, FloatComparisonNodeData, FloatPropertyMixerPlayable, FloatPropertyPlayableAsset, FloatPropertyTrack, FloatValueNode, FrameComponent, Framebuffer, GLSLVersion, GPUCapability, Geometry, GlobalUniforms, GlyphAtlas, GradientValue, GraphInstance, GraphNode, GraphNodeData, Graphics, GreaterNodeData, HELP_LINK, HitTestType, InteractComponent, InteractLoader, InteractMesh, InvalidIndex, Item, LayerBlendNode, LayerBlendNodeData, LessNodeData, LineSegments, LinearValue, MaskMode, MaskProcessor, MaskableGraphic, Material, MaterialDataBlock, MaterialRenderType, MaterialState, MaterialTrack, Mesh, NodeTransform, NotNode, NotNodeData, NotifyEvent, ObjectBindingTrack, OrNode, OrNodeData, OrderType, PLAYER_OPTIONS_ENV_EDITOR, POST_PROCESS_SETTINGS, ParticleBehaviourPlayable, ParticleBehaviourPlayableAsset, ParticleLoader, ParticleMesh, ParticleMixerPlayable, ParticleSystem, ParticleSystemRenderer, ParticleTrack, PassTextureCache, PathSegments, PlayState, Playable, PlayableAsset, PlayableOutput, Plugin, PluginSystem, PointerEventData, PointerEventType, PolyStar, Polygon, Pose, PoseNode, PositionConstraint, PostProcessVolume, Precomposition, PrecompositionManager, PropertyClipPlayable, PropertyTrack, REFERENCE_CURVE, RENDER_PREFER_LOOKUP_TEXTURE, RUNTIME_ENV, RandomSetValue, RandomValue, RandomVectorValue, RaycastResult, RectTransform, Rectangle$1 as Rectangle, ReferenceCurve, RenderFrame, RenderPass, RenderPassAttachmentStorageType, RenderPassDestroyAttachmentType, RenderPassPriorityNormal, RenderPassPriorityPostprocess, RenderPassPriorityPrepare, RenderTargetHandle, RenderTargetPool, RenderTextureFormat, Renderbuffer, Renderer, RendererComponent, RuntimeClip, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0, SEMANTIC_PRE_COLOR_ATTACHMENT_0, SEMANTIC_PRE_COLOR_ATTACHMENT_SIZE_0, SPRITE_VERTEX_STRIDE, Scene, SceneLoader, SerializationHelper, Shader, ShaderCompileResultStatus, ShaderFactory, ShaderType, ShaderVariant, ShapeComponent, SourceType, Sprite, SpriteColorMixerPlayable, SpriteColorPlayableAsset, SpriteColorTrack, SpriteComponent, SpriteComponentTimeTrack, SpriteLoader, SpritePropertyMixerPlayable, SpritePropertyPlayableAsset, SpritePropertyTrack, SpriteRotation, StarType, StateMachineNode, StateMachineNodeData, StateNode, StateNodeData, StaticValue, SubCompositionClipPlayable, SubCompositionMixerPlayable, SubCompositionPlayableAsset, SubCompositionTrack, TEMPLATE_USE_OFFSCREEN_CANVAS, TEXTURE_UNIFORM_MAP, TangentMode, TextCache, TextComponent, TextComponentBase, TextLayout, TextLoader, TextStyle, Texture, TextureFactory, TextureLoadAction, TexturePaintScaleMode, TextureSourceType, TextureStoreAction, ThreeComposition, ThreeDisplayObject, ThreeEngine, ThreeMaterial, ThreeSpriteComponent, ThreeTextComponent, ThreeTexture, Ticker, TimelineAsset, TimelineClip, TimelineInstance, TrackAsset, TrackMixerPlayable, TrackType, Transform, TransformMixerPlayable, TransformPlayable, TransformPlayableAsset, TransformTrack, TransitionNode, TransitionNodeData, TransitionState, Triangle, TrimPath, TrimPathMode, UpdateModes, VFXItem, ValueGetter, ValueNode, Vector2Curve, Vector2PropertyMixerPlayable, Vector2PropertyPlayableAsset, Vector2PropertyTrack, Vector3Curve, Vector3PropertyMixerPlayable, Vector3PropertyTrack, Vector3ropertyPlayableAsset, Vector4Curve, Vector4PropertyMixerPlayable, Vector4PropertyPlayableAsset, Vector4PropertyTrack, VertexBuffer, WeightedMode, addByOrder, addItem, addItemWithOrder, applyMixins, assertExist, asserts, base64ToFile, breakOpportunityAfter, buildBezierData, buildEasingCurve, buildLine, calculateTranslation, canUseBOM, canvasPool, closePointEps, colorGradingFrag, colorStopsFromGradient, colorToArr$1 as colorToArr, combineImageTemplate, createGLContext, createKeyFrameMeta, createShape, createTypedArray, createValueGetter, curveEps, decimalEqual, deserializeMipmapTexture, earcut, effectsClass, effectsClassStore, enlargeBuffer, ensureFixedNumber, ensureVec3, extractMinAndMax, gaussianDownHFrag, gaussianDownVFrag, gaussianUpFrag, generateEmptyTexture, generateEmptyTypedArray, generateGUID, generateHalfFloatTexture, generateWhiteTexture, getBackgroundImage, getBytesPerElement, getClass, getColorFromGradientStops, getConfig, getControlPoints, getDataByteLength, getDataType, getDefaultTextureFactory, getGeometryByShape, getGeometryTriangles, getKeyFrameMetaByRawValue, getMergedStore, getNodeDataClass, getParticleMeshShader, getPixelRatio, getPluginUsageInfo, getPreMultiAlpha, getStandardComposition, getStandardImage, getStandardItem, getStandardJSON, getTextureSize, glContext, glType2VertexFormatType, gpuTimer, imageDataFromColor, imageDataFromGradient, initErrors, initGLContext, integrate, interpolateColor, isAlipayMiniApp, isAndroid, isArray, isBreakChar, isCJKLike, isCanvas, isFunction, isIOS, isIOSByUA, isMiniProgram, isObject, isOpenHarmony, isPlainObject, isPowerOfTwo, isSafeFontFamily, isSimulatorCellPhone, isString, isUniformStruct, isUniformStructArray, isValidFontFamily, isWebGL2, isWechatMiniApp, itemFrag, itemVert, loadAVIFOptional, loadBinary, loadBlob, loadImage, loadMedia, loadVideo, loadWebPOptional, logger, index as math, modifyMaxKeyframeShader, nearestPowerOfTwo, nodeDataClass, noop, normalizeColor, numberToFix, oldBezierKeyFramesToNew, parsePercent$1 as parsePercent, particleFrag, particleOriginTranslateMap$1 as particleOriginTranslateMap, particleUniformTypeMap, particleVert, passRenderLevel, pluginLoaderMap, randomInRange, registerPlugin, removeItem, rotateVec2, screenMeshVert, serialize, setBlendMode, setConfig, setDefaultTextureFactory, setMaskMode, setRayFromCamera, setSideMode, setUniformValue, sortByOrder, index$1 as spec, textureLoaderRegistry, thresholdFrag, throwDestroyedError, toBufferView, trailVert, translatePoint, trianglesFromRect, unregisterPlugin, valIfUndefined, value, valueDefine, vecFill, vecMulCombine, version, vertexFormatType2GLType };
46063
+ export { ATLAS_SIZE, ActivationMixerPlayable, ActivationPlayable, ActivationPlayableAsset, ActivationTrack, AndNode, AndNodeData, Animatable, AnimationClip, AnimationClipNode, AnimationClipNodeData, AnimationEvent, AnimationGraphAsset, Animator, ApplyAdditiveNode, ApplyAdditiveNodeData, Asset, AssetLoader, AssetManager, AssetService, BYTES_TYPE_MAP, Behaviour, BezierCurve, BezierCurvePath, BezierCurveQuat, BezierDataMap, BezierEasing, BezierLengthData, BezierMap, BezierPath, BezierQuat, BinaryAsset, BlendNode, BlendNodeData, BoolValueNode, BoundingBoxInfo, Buffer, BufferDataType, BufferUsage, CONSTANT_MAP_BLEND, CONSTANT_MAP_DEPTH, CONSTANT_MAP_STENCIL_FUNC, CONSTANT_MAP_STENCIL_OP, COPY_FRAGMENT_SHADER, COPY_MESH_SHADER_ID, COPY_VERTEX_SHADER, Camera, CameraController, CameraVFXItemLoader, CanvasContainer, CanvasRenderMode, CanvasRootControl, Circle$1 as Circle, ColorCurve, ColorPlayable, ColorPropertyMixerPlayable, ColorPropertyPlayableAsset, ColorPropertyTrack, Component, ComponentTimePlayable, ComponentTimePlayableAsset, ComponentTimeTrack, Composition, CompositionComponent, CompressTextureCapabilityType, ConstBoolNode, ConstBoolNodeData, ConstFloatNode, ConstFloatNodeData, ConstraintTarget, ContainerControl, Control, ControlParameterBoolNode, ControlParameterBoolNodeData, ControlParameterFloatNode, ControlParameterFloatNodeData, ControlParameterTriggerNode, ControlParameterTriggerNodeData, CursorShape, DEFAULT_FONTS, DEFAULT_FPS, DataBuffer, Database, Deferred, DestroyOptions, Downloader, DrawObjectPass, EFFECTS_COPY_MESH_NAME, EVENT_TYPE_CLICK, EVENT_TYPE_TOUCH_END, EVENT_TYPE_TOUCH_MOVE, EVENT_TYPE_TOUCH_START, EffectComponent, EffectComponentTimeTrack, EffectsObject, EffectsPackage, Ellipse, Engine, EqualNodeData, EventEmitter, EventSystem, Fake3DAnimationMode, Fake3DComponent, FilterMode, Float16ArrayWrapper, FloatComparisonNode, FloatComparisonNodeData, FloatPropertyMixerPlayable, FloatPropertyPlayableAsset, FloatPropertyTrack, FloatValueNode, FocusBehaviorRecursive, FocusMode, FrameComponent, Framebuffer, GLSLVersion, GPUCapability, Geometry, GlobalUniforms, GlyphAtlas, GradientValue, GraphInstance, GraphNode, GraphNodeData, Graphics, GreaterNodeData, HELP_LINK, HitTestType, InputEvent, InputEventKey, InputEventMouse, InputEventMouseButton, InputEventMouseMotion, InputEventScreenDrag, InputEventScreenTouch, InputEventWithModifiers, InteractComponent, InteractLoader, InteractMesh, InvalidIndex, Item, KeyLocation, LayerBlendNode, LayerBlendNodeData, LessNodeData, LineSegments, LinearValue, MaskMode, MaskProcessor, MaskableGraphic, Material, MaterialDataBlock, MaterialRenderType, MaterialState, MaterialTrack, Mesh, MouseBehaviorRecursive, MouseButton, MouseButtonMask, MouseFilter, NodeTransform, NotNode, NotNodeData, NotifyEvent, ObjectBindingTrack, OrNode, OrNodeData, OrderType, PLAYER_OPTIONS_ENV_EDITOR, POST_PROCESS_SETTINGS, ParticleBehaviourPlayable, ParticleBehaviourPlayableAsset, ParticleLoader, ParticleMesh, ParticleMixerPlayable, ParticleSystem, ParticleSystemRenderer, ParticleTrack, PassTextureCache, PathSegments, PlayState, Playable, PlayableAsset, PlayableOutput, Plugin, PluginSystem, PointerEventData, PointerEventType, PolyStar, Polygon, Pose, PoseNode, PositionConstraint, PostProcessVolume, Precomposition, PrecompositionManager, PropertyClipPlayable, PropertyTrack, REFERENCE_CURVE, RENDER_PREFER_LOOKUP_TEXTURE, RUNTIME_ENV, RandomSetValue, RandomValue, RandomVectorValue, RaycastResult, Rectangle$1 as Rectangle, ReferenceCurve, RenderFrame, RenderPass, RenderPassAttachmentStorageType, RenderPassDestroyAttachmentType, RenderPassPriorityNormal, RenderPassPriorityPostprocess, RenderPassPriorityPrepare, RenderTargetHandle, RenderTargetPool, RenderTextureFormat, Renderbuffer, Renderer, RendererComponent, RootControl, RuntimeClip, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0, SEMANTIC_PRE_COLOR_ATTACHMENT_0, SEMANTIC_PRE_COLOR_ATTACHMENT_SIZE_0, SPRITE_VERTEX_STRIDE, Scene, SceneLoader, SerializationHelper, Shader, ShaderCompileResultStatus, ShaderFactory, ShaderType, ShaderVariant, ShapeComponent, SourceType, Sprite, SpriteColorMixerPlayable, SpriteColorPlayableAsset, SpriteColorTrack, SpriteComponent, SpriteComponentTimeTrack, SpriteLoader, SpritePropertyMixerPlayable, SpritePropertyPlayableAsset, SpritePropertyTrack, SpriteRotation, StarType, StateMachineNode, StateMachineNodeData, StateNode, StateNodeData, StaticValue, SubCompositionClipPlayable, SubCompositionMixerPlayable, SubCompositionPlayableAsset, SubCompositionTrack, TEMPLATE_USE_OFFSCREEN_CANVAS, TEXTURE_UNIFORM_MAP, TangentMode, TextCache, TextComponent, TextComponentBase, TextLayout, TextLoader, TextStyle, Texture, TextureFactory, TextureLoadAction, TexturePaintScaleMode, TextureSourceType, TextureStoreAction, ThreeComposition, ThreeDisplayObject, ThreeEngine, ThreeMaterial, ThreeSpriteComponent, ThreeTextComponent, ThreeTexture, Ticker, TimelineAsset, TimelineClip, TimelineInstance, TrackAsset, TrackMixerPlayable, TrackType, Transform, TransformMixerPlayable, TransformPlayable, TransformPlayableAsset, TransformTrack, TransitionNode, TransitionNodeData, TransitionState, Triangle, TrimPath, TrimPathMode, UICanvas, UIControl, UpdateModes, VFXItem, ValueGetter, ValueNode, Vector2Curve, Vector2PropertyMixerPlayable, Vector2PropertyPlayableAsset, Vector2PropertyTrack, Vector3Curve, Vector3PropertyMixerPlayable, Vector3PropertyTrack, Vector3ropertyPlayableAsset, Vector4Curve, Vector4PropertyMixerPlayable, Vector4PropertyPlayableAsset, Vector4PropertyTrack, VertexBuffer, WeightedMode, WindowRootControl, addByOrder, addItem, addItemWithOrder, applyMixins, assertExist, asserts, base64ToFile, breakOpportunityAfter, buildBezierData, buildEasingCurve, buildLine, calculateTranslation, canUseBOM, canvasPool, closePointEps, colorGradingFrag, colorStopsFromGradient, colorToArr$1 as colorToArr, combineImageTemplate, createGLContext, createKeyFrameMeta, createShape, createTypedArray, createValueGetter, curveEps, decimalEqual, deserializeMipmapTexture, earcut, effectsClass, effectsClassStore, enlargeBuffer, ensureFixedNumber, ensureVec3, extractMinAndMax, gaussianDownHFrag, gaussianDownVFrag, gaussianUpFrag, generateEmptyTexture, generateEmptyTypedArray, generateGUID, generateHalfFloatTexture, generateWhiteTexture, getBackgroundImage, getBytesPerElement, getClass, getColorFromGradientStops, getConfig, getControlPoints, getDataByteLength, getDataType, getDefaultTextureFactory, getGeometryByShape, getGeometryTriangles, getKeyFrameMetaByRawValue, getMergedStore, getNodeDataClass, getParticleMeshShader, getPixelRatio, getPluginUsageInfo, getPreMultiAlpha, getStandardComposition, getStandardImage, getStandardItem, getStandardJSON, getTextureSize, glContext, glType2VertexFormatType, gpuTimer, imageDataFromColor, imageDataFromGradient, initErrors, initGLContext, integrate, interpolateColor, isAlipayMiniApp, isAndroid, isArray, isBreakChar, isCJKLike, isCanvas, isFunction, isIOS, isIOSByUA, isMiniProgram, isObject, isOpenHarmony, isPlainObject, isPowerOfTwo, isSafeFontFamily, isSimulatorCellPhone, isString, isUniformStruct, isUniformStructArray, isValidFontFamily, isWebGL2, isWechatMiniApp, itemFrag, itemVert, loadAVIFOptional, loadBinary, loadBlob, loadImage, loadMedia, loadVideo, loadWebPOptional, logger, index as math, modifyMaxKeyframeShader, nearestPowerOfTwo, nodeDataClass, noop, normalizeColor, numberToFix, oldBezierKeyFramesToNew, parsePercent$1 as parsePercent, particleFrag, particleOriginTranslateMap$1 as particleOriginTranslateMap, particleUniformTypeMap, particleVert, passRenderLevel, pluginLoaderMap, randomInRange, registerPlugin, removeItem, rotateVec2, screenMeshVert, serialize, setBlendMode, setConfig, setDefaultTextureFactory, setMaskMode, setRayFromCamera, setSideMode, setUniformValue, sortByOrder, index$1 as spec, textureLoaderRegistry, thresholdFrag, throwDestroyedError, toBufferView, trailVert, translatePoint, trianglesFromRect, unregisterPlugin, valIfUndefined, value, valueDefine, vecFill, vecMulCombine, version, vertexFormatType2GLType };
44366
46064
  //# sourceMappingURL=index.mjs.map