@galacean/effects-core 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 core for the web
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
6
- * Version: v2.10.0-alpha.2
6
+ * Version: v2.10.0-alpha.3
7
7
  */
8
8
 
9
9
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
@@ -7052,6 +7052,11 @@ function _create_class(Constructor, protoProps, staticProps) {
7052
7052
  // OVERRIDE
7053
7053
  };
7054
7054
  /**
7055
+ * Called when the owning item's sibling order changes.
7056
+ */ _proto.onOrderInParentChanged = function onOrderInParentChanged() {
7057
+ // OVERRIDE
7058
+ };
7059
+ /**
7055
7060
  * @internal
7056
7061
  */ _proto.enable = function enable() {
7057
7062
  if (this.item.composition) {
@@ -14009,6 +14014,7 @@ var seed$7 = 1;
14009
14014
  quat: new Quaternion(0, 0, 0, 1),
14010
14015
  scale: new Vector3(1, 1, 1)
14011
14016
  };
14017
+ this.eventEmitter = new EventEmitter();
14012
14018
  this.name = "transform_" + seed$7++;
14013
14019
  if (props) {
14014
14020
  this.setTransform(props);
@@ -14021,6 +14027,12 @@ var seed$7 = 1;
14021
14027
  }
14022
14028
  }
14023
14029
  var _proto = Transform.prototype;
14030
+ _proto.on = function on(eventName, listener, options) {
14031
+ this.eventEmitter.on(eventName, listener, options);
14032
+ };
14033
+ _proto.off = function off(eventName, listener) {
14034
+ this.eventEmitter.off(eventName, listener);
14035
+ };
14024
14036
  /**
14025
14037
  * 父 transform 切换时的 hook。子类可重写以接管订阅 / 解算等逻辑
14026
14038
  * @param oldParent - 切换前的父 transform(若没有则为 null)
@@ -14439,6 +14451,7 @@ var seed$7 = 1;
14439
14451
  this.children.forEach(function(c) {
14440
14452
  c.worldMatrixDirty = true;
14441
14453
  });
14454
+ this.eventEmitter.emit("changed", this);
14442
14455
  };
14443
14456
  /**
14444
14457
  * 转换右手坐标系左手螺旋对应的四元数到对应的旋转角
@@ -14457,14 +14470,16 @@ var seed$7 = 1;
14457
14470
  return this.parent;
14458
14471
  },
14459
14472
  set: function set(transform) {
14460
- if (!transform || this.parent === transform || this === transform) {
14473
+ if (this.parent === transform || this === transform) {
14461
14474
  return;
14462
14475
  }
14463
14476
  var oldParent = this.parent;
14464
14477
  if (this.parent) {
14465
14478
  this.parent.removeChild(this);
14466
14479
  }
14467
- transform.addChild(this);
14480
+ if (transform) {
14481
+ transform.addChild(this);
14482
+ }
14468
14483
  this.parent = transform;
14469
14484
  this.worldMatrixDirty = true;
14470
14485
  this.onParentTransformChanged(oldParent, transform);
@@ -14647,7 +14662,7 @@ var VFXItem = /*#__PURE__*/ function(EffectsObject) {
14647
14662
  return results;
14648
14663
  };
14649
14664
  _proto.setParent = function setParent(vfxItem) {
14650
- if (vfxItem === this && !vfxItem) {
14665
+ if (vfxItem === this || this.parent === vfxItem) {
14651
14666
  return;
14652
14667
  }
14653
14668
  if (this.parent) {
@@ -15034,6 +15049,12 @@ var VFXItem = /*#__PURE__*/ function(EffectsObject) {
15034
15049
  child.onParentChanged();
15035
15050
  }
15036
15051
  };
15052
+ _proto.onOrderInParentChanged = function onOrderInParentChanged() {
15053
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.components), _step; !(_step = _iterator()).done;){
15054
+ var component = _step.value;
15055
+ component.onOrderInParentChanged();
15056
+ }
15057
+ };
15037
15058
  /**
15038
15059
  * @internal
15039
15060
  */ _proto.setRendererComponentOrder = function setRendererComponentOrder(renderOrder) {
@@ -15118,15 +15139,16 @@ var VFXItem = /*#__PURE__*/ function(EffectsObject) {
15118
15139
  */ _proto.dispose = function dispose() {
15119
15140
  if (this.composition) {
15120
15141
  this.composition.destroyItem(this);
15121
- // component 调用 dispose() 会将自身从 this.components 数组删除,slice() 避免迭代错误
15122
- for(var _iterator = _create_for_of_iterator_helper_loose(this.components.slice()), _step; !(_step = _iterator()).done;){
15123
- var component = _step.value;
15124
- component.dispose();
15125
- }
15126
- this.components = [];
15127
- this._composition = null;
15128
- this.transform.setValid(false);
15129
15142
  }
15143
+ // component.dispose() removes itself from this.components. Use a snapshot
15144
+ // so Engine.root components are also disposed even without a Composition.
15145
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.components.slice()), _step; !(_step = _iterator()).done;){
15146
+ var component = _step.value;
15147
+ component.dispose();
15148
+ }
15149
+ this.components = [];
15150
+ this._composition = null;
15151
+ this.transform.setValid(false);
15130
15152
  this.resetChildrenParent();
15131
15153
  EffectsObject.prototype.dispose.call(this);
15132
15154
  };
@@ -15322,6 +15344,33 @@ var VFXItem = /*#__PURE__*/ function(EffectsObject) {
15322
15344
  this.setRendererComponentOrder(value);
15323
15345
  }
15324
15346
  },
15347
+ {
15348
+ key: "orderInParent",
15349
+ get: /** Zero-based sibling order within the parent item. */ function get() {
15350
+ var _this_parent;
15351
+ var _this_parent_children_indexOf;
15352
+ return (_this_parent_children_indexOf = (_this_parent = this.parent) == null ? void 0 : _this_parent.children.indexOf(this)) != null ? _this_parent_children_indexOf : -1;
15353
+ },
15354
+ set: function set(value) {
15355
+ var _this_parent;
15356
+ var siblings = (_this_parent = this.parent) == null ? void 0 : _this_parent.children;
15357
+ var _siblings_indexOf;
15358
+ var oldIndex = (_siblings_indexOf = siblings == null ? void 0 : siblings.indexOf(this)) != null ? _siblings_indexOf : -1;
15359
+ if (!siblings || oldIndex === -1) {
15360
+ return;
15361
+ }
15362
+ var newIndex = Math.max(0, Math.min(Math.trunc(value), siblings.length - 1));
15363
+ if (oldIndex === newIndex) {
15364
+ return;
15365
+ }
15366
+ siblings.splice(oldIndex, 1);
15367
+ siblings.splice(newIndex, 0, this);
15368
+ for(var _iterator = _create_for_of_iterator_helper_loose(siblings), _step; !(_step = _iterator()).done;){
15369
+ var sibling = _step.value;
15370
+ sibling.onOrderInParentChanged();
15371
+ }
15372
+ }
15373
+ },
15325
15374
  {
15326
15375
  key: "isActive",
15327
15376
  get: /**
@@ -15578,35 +15627,35 @@ function vecMulCombine(out, a, b) {
15578
15627
  }
15579
15628
  return out;
15580
15629
  }
15581
- var _obj$5;
15582
- var particleOriginTranslateMap$1 = (_obj$5 = {}, _obj$5[ParticleOrigin.PARTICLE_ORIGIN_CENTER] = [
15630
+ var _obj$6;
15631
+ var particleOriginTranslateMap$1 = (_obj$6 = {}, _obj$6[ParticleOrigin.PARTICLE_ORIGIN_CENTER] = [
15583
15632
  0,
15584
15633
  0
15585
- ], _obj$5[ParticleOrigin.PARTICLE_ORIGIN_CENTER_BOTTOM] = [
15634
+ ], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_CENTER_BOTTOM] = [
15586
15635
  0,
15587
15636
  -0.5
15588
- ], _obj$5[ParticleOrigin.PARTICLE_ORIGIN_CENTER_TOP] = [
15637
+ ], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_CENTER_TOP] = [
15589
15638
  0,
15590
15639
  0.5
15591
- ], _obj$5[ParticleOrigin.PARTICLE_ORIGIN_LEFT_TOP] = [
15640
+ ], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_LEFT_TOP] = [
15592
15641
  -0.5,
15593
15642
  0.5
15594
- ], _obj$5[ParticleOrigin.PARTICLE_ORIGIN_LEFT_CENTER] = [
15643
+ ], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_LEFT_CENTER] = [
15595
15644
  -0.5,
15596
15645
  0
15597
- ], _obj$5[ParticleOrigin.PARTICLE_ORIGIN_LEFT_BOTTOM] = [
15646
+ ], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_LEFT_BOTTOM] = [
15598
15647
  -0.5,
15599
15648
  -0.5
15600
- ], _obj$5[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_CENTER] = [
15649
+ ], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_CENTER] = [
15601
15650
  0.5,
15602
15651
  0
15603
- ], _obj$5[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_BOTTOM] = [
15652
+ ], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_BOTTOM] = [
15604
15653
  0.5,
15605
15654
  -0.5
15606
- ], _obj$5[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_TOP] = [
15655
+ ], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_TOP] = [
15607
15656
  0.5,
15608
15657
  0.5
15609
- ], _obj$5);
15658
+ ], _obj$6);
15610
15659
  function nearestPowerOfTwo(value) {
15611
15660
  return Math.pow(2, Math.round(Math.log(value) / Math.LN2));
15612
15661
  }
@@ -17344,27 +17393,27 @@ function oldBezierKeyFramesToNew(props) {
17344
17393
  * 对象引用阶梯曲线(spec ValueType.REFERENCE_CURVE)。
17345
17394
  * props 为 [[time, value], ...],value 为已解析的对象引用实例。
17346
17395
  */ var REFERENCE_CURVE = 28;
17347
- var _obj$4;
17348
- var map$1 = (_obj$4 = {}, _obj$4[ValueType.RANDOM] = function(props) {
17396
+ var _obj$5;
17397
+ var map$1 = (_obj$5 = {}, _obj$5[ValueType.RANDOM] = function(props) {
17349
17398
  if (_instanceof1(props[0], Array)) {
17350
17399
  return new RandomVectorValue(props);
17351
17400
  }
17352
17401
  return new RandomValue(props);
17353
- }, _obj$4[ValueType.CONSTANT] = function(props) {
17402
+ }, _obj$5[ValueType.CONSTANT] = function(props) {
17354
17403
  return new StaticValue(props);
17355
- }, _obj$4[ValueType.CONSTANT_VEC2] = function(props) {
17404
+ }, _obj$5[ValueType.CONSTANT_VEC2] = function(props) {
17356
17405
  return new StaticValue(props);
17357
- }, _obj$4[ValueType.CONSTANT_VEC3] = function(props) {
17406
+ }, _obj$5[ValueType.CONSTANT_VEC3] = function(props) {
17358
17407
  return new StaticValue(props);
17359
- }, _obj$4[ValueType.CONSTANT_VEC4] = function(props) {
17408
+ }, _obj$5[ValueType.CONSTANT_VEC4] = function(props) {
17360
17409
  return new StaticValue(props);
17361
- }, _obj$4[ValueType.RGBA_COLOR] = function(props) {
17410
+ }, _obj$5[ValueType.RGBA_COLOR] = function(props) {
17362
17411
  return new StaticValue(props);
17363
- }, _obj$4[ValueType.COLORS] = function(props) {
17412
+ }, _obj$5[ValueType.COLORS] = function(props) {
17364
17413
  return new RandomSetValue(props.map(function(c) {
17365
17414
  return colorToArr$1(c, false);
17366
17415
  }));
17367
- }, _obj$4[ValueType.LINE] = function(props) {
17416
+ }, _obj$5[ValueType.LINE] = function(props) {
17368
17417
  if (props.length === 2 && props[0][0] === 0 && props[1][0] === 1) {
17369
17418
  return new LinearValue([
17370
17419
  props[0][1],
@@ -17372,38 +17421,38 @@ var map$1 = (_obj$4 = {}, _obj$4[ValueType.RANDOM] = function(props) {
17372
17421
  ]);
17373
17422
  }
17374
17423
  return new LineSegments(props);
17375
- }, _obj$4[ValueType.GRADIENT_COLOR] = function(props) {
17424
+ }, _obj$5[ValueType.GRADIENT_COLOR] = function(props) {
17376
17425
  return new GradientValue(props);
17377
- }, _obj$4[ValueType.LINEAR_PATH] = function(pros) {
17426
+ }, _obj$5[ValueType.LINEAR_PATH] = function(pros) {
17378
17427
  return new PathSegments(pros);
17379
- }, _obj$4[ValueType.BEZIER_CURVE] = function(props) {
17428
+ }, _obj$5[ValueType.BEZIER_CURVE] = function(props) {
17380
17429
  if (props.length === 1) {
17381
17430
  return new StaticValue(props[0][1][1]);
17382
17431
  }
17383
17432
  return new BezierCurve(props);
17384
- }, _obj$4[ValueType.BEZIER_CURVE_PATH] = function(props) {
17433
+ }, _obj$5[ValueType.BEZIER_CURVE_PATH] = function(props) {
17385
17434
  if (props[0].length === 1) {
17386
17435
  return new StaticValue(_construct(Vector3, [].concat(props[1][0])));
17387
17436
  }
17388
17437
  return new BezierCurvePath(props);
17389
- }, _obj$4[ValueType.BEZIER_CURVE_QUAT] = function(props) {
17438
+ }, _obj$5[ValueType.BEZIER_CURVE_QUAT] = function(props) {
17390
17439
  if (props[0].length === 1) {
17391
17440
  return new StaticValue(_construct(Quaternion, [].concat(props[1][0])));
17392
17441
  }
17393
17442
  return new BezierCurveQuat(props);
17394
- }, _obj$4[ValueType.COLOR_CURVE] = function(props) {
17443
+ }, _obj$5[ValueType.COLOR_CURVE] = function(props) {
17395
17444
  return new ColorCurve(props);
17396
- }, _obj$4[ValueType.VECTOR4_CURVE] = function(props) {
17445
+ }, _obj$5[ValueType.VECTOR4_CURVE] = function(props) {
17397
17446
  return new Vector4Curve(props);
17398
- }, _obj$4[ValueType.VECTOR2_CURVE] = function(props) {
17447
+ }, _obj$5[ValueType.VECTOR2_CURVE] = function(props) {
17399
17448
  return new Vector2Curve(props);
17400
17449
  }, // TODO: add spec
17401
- _obj$4[VECTOR3_CURVE] = function(props) {
17450
+ _obj$5[VECTOR3_CURVE] = function(props) {
17402
17451
  return new Vector3Curve(props);
17403
17452
  }, // 对象引用阶梯曲线(不插值):props.data 为 [time, value][],value 已解析为 EffectsObject
17404
- _obj$4[REFERENCE_CURVE] = function(props) {
17453
+ _obj$5[REFERENCE_CURVE] = function(props) {
17405
17454
  return new ReferenceCurve(props);
17406
- }, _obj$4);
17455
+ }, _obj$5);
17407
17456
  function createValueGetter(args) {
17408
17457
  if (!args || !isNaN(+args)) {
17409
17458
  return new StaticValue(args || 0);
@@ -20920,20 +20969,24 @@ var geometryId = 1;
20920
20969
  var vertexArrayObjects = this.vertexArrayObjects;
20921
20970
  var engine = this.engine;
20922
20971
  if (!vertexArrayObjects || !supportsVertexArrayObjects(engine)) {
20923
- engine.bindBuffers(this.vertexBuffers, this.indexBuffer, shader);
20972
+ var _this_indexBuffer;
20973
+ engine.bindBuffers(this.vertexBuffers, (_this_indexBuffer = this.indexBuffer) != null ? _this_indexBuffer : null, shader);
20924
20974
  return;
20925
20975
  }
20926
20976
  var vertexArrayObject = vertexArrayObjects[shader.key];
20927
20977
  if (!vertexArrayObject) {
20928
- vertexArrayObject = engine.recordVertexArrayObject(this.vertexBuffers, this.indexBuffer, shader);
20978
+ var _this_indexBuffer1;
20979
+ vertexArrayObject = engine.recordVertexArrayObject(this.vertexBuffers, (_this_indexBuffer1 = this.indexBuffer) != null ? _this_indexBuffer1 : null, shader);
20929
20980
  if (vertexArrayObject) {
20930
20981
  vertexArrayObjects[shader.key] = vertexArrayObject;
20931
20982
  }
20932
20983
  }
20933
20984
  if (vertexArrayObject) {
20934
- engine.bindVertexArrayObject(vertexArrayObject, this.indexBuffer);
20985
+ var _this_indexBuffer2;
20986
+ engine.bindVertexArrayObject(vertexArrayObject, (_this_indexBuffer2 = this.indexBuffer) != null ? _this_indexBuffer2 : null);
20935
20987
  } else {
20936
- engine.bindBuffers(this.vertexBuffers, this.indexBuffer, shader);
20988
+ var _this_indexBuffer3;
20989
+ engine.bindBuffers(this.vertexBuffers, (_this_indexBuffer3 = this.indexBuffer) != null ? _this_indexBuffer3 : null, shader);
20937
20990
  }
20938
20991
  };
20939
20992
  _proto.releaseVertexArrayObject = function releaseVertexArrayObject(key) {
@@ -21340,8 +21393,8 @@ var vertexBufferSemanticMap = {
21340
21393
  TANGENT_BS2: "aTargetTangent2",
21341
21394
  TANGENT_BS3: "aTargetTangent3"
21342
21395
  };
21343
- var _obj$3;
21344
- var BYTES_TYPE_MAP = (_obj$3 = {}, _obj$3[BufferDataType.Float] = 4, _obj$3[BufferDataType.Int] = 4, _obj$3[BufferDataType.UnsignedInt] = 4, _obj$3[BufferDataType.Short] = 2, _obj$3[BufferDataType.UnsignedShort] = 2, _obj$3[BufferDataType.Byte] = 1, _obj$3[BufferDataType.UnsignedByte] = 1, _obj$3);
21396
+ var _obj$4;
21397
+ 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);
21345
21398
  function generateEmptyTypedArray(type) {
21346
21399
  return createTypedArray(type, 0);
21347
21400
  }
@@ -22351,7 +22404,7 @@ var Renderer = /*#__PURE__*/ function() {
22351
22404
  }
22352
22405
  };
22353
22406
  _proto.setViewport = function setViewport(x, y, width, height) {
22354
- this.engine.viewport(x, y, width, height);
22407
+ this.engine.setViewport(x, y, width, height);
22355
22408
  };
22356
22409
  _proto.clear = function clear(action) {
22357
22410
  this.engine.clear(action);
@@ -22414,7 +22467,40 @@ var Renderer = /*#__PURE__*/ function() {
22414
22467
  };
22415
22468
  _proto.drawGeometry = function drawGeometry(geometry, matrix, material, subMeshIndex) {
22416
22469
  if (subMeshIndex === void 0) subMeshIndex = 0;
22417
- this.engine.drawGeometry(geometry, matrix, material, subMeshIndex);
22470
+ if (!geometry || !material) {
22471
+ return;
22472
+ }
22473
+ material.initialize();
22474
+ geometry.initialize();
22475
+ geometry.flush();
22476
+ material.setMatrix("effects_ObjectToWorld", matrix);
22477
+ try {
22478
+ material.use(this, this.renderingData.currentFrame.globalUniforms);
22479
+ } catch (e) {
22480
+ console.error(e);
22481
+ this.engine.renderErrors.add(e);
22482
+ return;
22483
+ }
22484
+ var indexBuffer = geometry.getIndexBuffer();
22485
+ var offset = geometry.getDrawStart();
22486
+ var count = geometry.getDrawCount();
22487
+ var subMeshes = geometry.subMeshes;
22488
+ if (subMeshes.length > 0) {
22489
+ var subMesh = subMeshes[subMeshIndex];
22490
+ offset = subMesh.offset;
22491
+ var _subMesh_indexCount;
22492
+ count = indexBuffer ? (_subMesh_indexCount = subMesh.indexCount) != null ? _subMesh_indexCount : 0 : subMesh.vertexCount;
22493
+ }
22494
+ if (count <= 0) {
22495
+ return;
22496
+ }
22497
+ geometry.bind(material.shaderVariant);
22498
+ var instanceCount = geometry.instanceCount || undefined;
22499
+ if (indexBuffer) {
22500
+ this.engine.drawElementsType(geometry.mode, offset, count, instanceCount);
22501
+ } else {
22502
+ this.engine.drawArraysType(geometry.mode, offset, count, instanceCount);
22503
+ }
22418
22504
  };
22419
22505
  _proto.getTemporaryRT = function getTemporaryRT(name, width, height, depthBuffer, filter, format) {
22420
22506
  return this.engine.renderTargetPool.get(name, width, height, depthBuffer, filter, format);
@@ -22682,11 +22768,7 @@ var CanvasPool = /*#__PURE__*/ function() {
22682
22768
  var canvasPool = new CanvasPool();
22683
22769
 
22684
22770
  /**
22685
- * 字形纹理超采样倍数。canvas `fontSize * FONT_SCALE` 渲染,纹理像素也是 scale 倍,
22686
- * 但 quad 仍按 1x 逻辑尺寸绘制 — 双线性 downsample 后比原 1x 渲染清晰得多
22687
- */ var FONT_SCALE = 2;
22688
- /**
22689
- * 单张字符 atlas 的边长(像素,scale 后的实际像素,非逻辑尺寸)。
22771
+ * 单张字符 atlas 的逻辑边长。实际 canvas 像素尺寸会乘以渲染 resolution。
22690
22772
  * 512×512 在 24px 字号下约可容纳 250+ 字形,常见 demo 文本足够
22691
22773
  */ var ATLAS_SIZE = 512;
22692
22774
  /**
@@ -22708,7 +22790,7 @@ var canvasPool = new CanvasPool();
22708
22790
  * canvas 内容变更后需要 `uploadIfDirty` 重新上传到纹理 — 由调用方在使用纹理前主动触发,
22709
22791
  * 避免每加一字都 upload 一次造成的 GL 开销
22710
22792
  */ var GlyphAtlas = /*#__PURE__*/ function() {
22711
- function GlyphAtlas(engine, scaledFontString, /** baseline 距 cell 顶距离(像素,scale 后,仅 ascent 部分,不含 padding) */ ascentPx, /** baseline 距 cell 底距离(像素,scale 后,仅 descent 部分) */ descentPx, fontStyle) {
22793
+ function GlyphAtlas(engine, scaledFontString, /** baseline 距 cell 顶距离(像素,scale 后,仅 ascent 部分,不含 padding) */ ascentPx, /** baseline 距 cell 底距离(像素,scale 后,仅 descent 部分) */ descentPx, fontStyle, resolution) {
22712
22794
  this.engine = engine;
22713
22795
  this.scaledFontString = scaledFontString;
22714
22796
  this.glyphs = new Map();
@@ -22716,9 +22798,10 @@ var canvasPool = new CanvasPool();
22716
22798
  this.currentY = 0;
22717
22799
  this.full = false;
22718
22800
  this.dirty = true;
22801
+ this.resolution = resolution;
22719
22802
  this.canvas = document.createElement("canvas");
22720
- this.canvas.width = ATLAS_SIZE;
22721
- this.canvas.height = ATLAS_SIZE;
22803
+ this.canvas.width = Math.ceil(ATLAS_SIZE * resolution);
22804
+ this.canvas.height = Math.ceil(ATLAS_SIZE * resolution);
22722
22805
  var ctx = this.canvas.getContext("2d", {
22723
22806
  willReadFrequently: false
22724
22807
  });
@@ -22729,14 +22812,14 @@ var canvasPool = new CanvasPool();
22729
22812
  ctx.font = scaledFontString;
22730
22813
  ctx.textBaseline = "alphabetic";
22731
22814
  ctx.fillStyle = "#ffffff";
22732
- this.paddingPx = GLYPH_PADDING * FONT_SCALE;
22815
+ this.paddingPx = GLYPH_PADDING * resolution;
22733
22816
  this.italicScale = fontStyle === "italic" ? 2 : 1;
22734
22817
  // ascent/descent 由探针 '|ÉqÅM' 测得 actualBoundingBox(重音字已抬高 ink 顶),
22735
22818
  // 两者内部保持浮点,仅 cell 高做一次外层 ceil — 与 padding 共同保证 cell 内不裁切
22736
22819
  var fontHeightPx = ascentPx + descentPx;
22737
22820
  this.baselinePx = this.paddingPx + ascentPx;
22738
22821
  this.cellHPx = Math.ceil(fontHeightPx + this.paddingPx * 2);
22739
- this.lineHeight = this.cellHPx / FONT_SCALE;
22822
+ this.lineHeight = this.cellHPx / resolution;
22740
22823
  this.texture = Texture.create(engine, {
22741
22824
  sourceType: TextureSourceType.image,
22742
22825
  image: this.canvas,
@@ -22745,7 +22828,8 @@ var canvasPool = new CanvasPool();
22745
22828
  magFilter: glContext.LINEAR,
22746
22829
  minFilter: glContext.LINEAR,
22747
22830
  wrapS: glContext.CLAMP_TO_EDGE,
22748
- wrapT: glContext.CLAMP_TO_EDGE
22831
+ wrapT: glContext.CLAMP_TO_EDGE,
22832
+ premultiplyAlpha: true
22749
22833
  });
22750
22834
  this.texture.initialize();
22751
22835
  }
@@ -22763,19 +22847,19 @@ var canvasPool = new CanvasPool();
22763
22847
  var ctx = this.ctx;
22764
22848
  // 每次重设字体,防御外部潜在污染(虽然 ctx 私有)
22765
22849
  ctx.font = this.scaledFontString;
22766
- // measureText 用的是 scaledFontString,advance 已经是 scale 后的像素,不能再乘 FONT_SCALE
22850
+ // measureText 用的是 scaledFontString,advance 已经是 resolution 后的像素
22767
22851
  var advancePx = ctx.measureText(char).width;
22768
22852
  // italic 放大 cell 宽防斜体越界;ceil 对齐像素网格避免相邻字采样重叠
22769
22853
  var widthPx = Math.max(1, Math.ceil(advancePx * this.italicScale));
22770
22854
  var paddedWidthPx = widthPx + this.paddingPx * 2;
22771
22855
  var cellH = this.cellHPx;
22772
22856
  // 行尾换行
22773
- if (this.currentX + paddedWidthPx > ATLAS_SIZE) {
22857
+ if (this.currentX + paddedWidthPx > this.canvas.width) {
22774
22858
  this.currentX = 0;
22775
22859
  this.currentY += cellH;
22776
22860
  }
22777
22861
  // atlas 满,后续不再尝试
22778
- if (this.currentY + cellH > ATLAS_SIZE) {
22862
+ if (this.currentY + cellH > this.canvas.height) {
22779
22863
  this.full = true;
22780
22864
  console.warn('GlyphAtlas full, dropping char "' + char + '"');
22781
22865
  return null;
@@ -22791,8 +22875,8 @@ var canvasPool = new CanvasPool();
22791
22875
  py: py,
22792
22876
  pw: paddedWidthPx,
22793
22877
  ph: cellH,
22794
- advance: advancePx / FONT_SCALE,
22795
- paddingLeft: this.paddingPx / FONT_SCALE
22878
+ advance: advancePx / this.resolution,
22879
+ paddingLeft: this.paddingPx / this.resolution
22796
22880
  };
22797
22881
  this.glyphs.set(char, info);
22798
22882
  return info;
@@ -22811,7 +22895,8 @@ var canvasPool = new CanvasPool();
22811
22895
  magFilter: glContext.LINEAR,
22812
22896
  minFilter: glContext.LINEAR,
22813
22897
  wrapS: glContext.CLAMP_TO_EDGE,
22814
- wrapT: glContext.CLAMP_TO_EDGE
22898
+ wrapT: glContext.CLAMP_TO_EDGE,
22899
+ premultiplyAlpha: true
22815
22900
  });
22816
22901
  this.dirty = false;
22817
22902
  };
@@ -22834,26 +22919,33 @@ var canvasPool = new CanvasPool();
22834
22919
  function TextCache(engine) {
22835
22920
  this.engine = engine;
22836
22921
  this.atlases = new Map();
22922
+ this.resolution = engine.pixelRatio;
22837
22923
  }
22838
22924
  var _proto = TextCache.prototype;
22839
22925
  /**
22840
22926
  * 取(必要时新建)对应字体的字符 atlas
22841
22927
  */ _proto.getAtlas = function getAtlas(fontSize, fontFamily, fontWeight, fontStyle) {
22842
- var fontKey = fontStyle + "|" + fontWeight + "|" + fontSize + "|" + fontFamily;
22928
+ // Pixi CanvasText 默认跟随 renderer.resolution;这里对应 Engine.pixelRatio。
22929
+ var resolution = this.engine.pixelRatio;
22930
+ if (resolution !== this.resolution) {
22931
+ this.clear();
22932
+ this.resolution = resolution;
22933
+ }
22934
+ var fontKey = fontStyle + "|" + fontWeight + "|" + fontSize + "|" + fontFamily + "|" + resolution;
22843
22935
  var cached = this.atlases.get(fontKey);
22844
22936
  if (cached) {
22845
22937
  return cached;
22846
22938
  }
22847
- var scaledFontString = fontStyle + " " + fontWeight + " " + fontSize * FONT_SCALE + "px " + fontFamily;
22939
+ var scaledFontString = fontStyle + " " + fontWeight + " " + fontSize * resolution + "px " + fontFamily;
22848
22940
  // 探一次得到字体级 ascent/descent(整张 atlas 共享 cell 高与 baseline,各字对齐)。
22849
- // 直接在 scaledFontString 下测,得到的就是 scale 后像素,无需再乘 FONT_SCALE。
22941
+ // 直接在 scaledFontString 下测,得到的就是 resolution 后像素。
22850
22942
  // 探针用 '|ÉqÅ' + 'M':带重音符的 ÉÅ 把 ink 顶推到接近字体真实 ascent,
22851
22943
  // 单字 'M' 只有 cap height(~0.7em) 太矮,CJK / 带重音字顶部会越过 cell 上界被裁。
22852
22944
  // 取 actualBoundingBoxAscent/Descent 度量 ink 边界,跨平台语义稳定
22853
22945
  var probeCanvasAndContext = canvasPool.getCanvasAndContext(1, 1);
22854
22946
  var probeCtx = probeCanvasAndContext.context;
22855
- var ascentPx = fontSize * 0.8 * FONT_SCALE;
22856
- var descentPx = fontSize * 0.2 * FONT_SCALE;
22947
+ var ascentPx = fontSize * 0.8 * resolution;
22948
+ var descentPx = fontSize * 0.2 * resolution;
22857
22949
  try {
22858
22950
  probeCtx.font = scaledFontString;
22859
22951
  var m = probeCtx.measureText(METRICS_STRING + BASELINE_SYMBOL);
@@ -22862,7 +22954,7 @@ var canvasPool = new CanvasPool();
22862
22954
  } finally{
22863
22955
  canvasPool.releaseCanvasAndContext(probeCanvasAndContext);
22864
22956
  }
22865
- var atlas = new GlyphAtlas(this.engine, scaledFontString, ascentPx, descentPx, fontStyle);
22957
+ var atlas = new GlyphAtlas(this.engine, scaledFontString, ascentPx, descentPx, fontStyle, resolution);
22866
22958
  this.atlases.set(fontKey, atlas);
22867
22959
  return atlas;
22868
22960
  };
@@ -22879,6 +22971,9 @@ var canvasPool = new CanvasPool();
22879
22971
  /**
22880
22972
  * 清空所有 atlas 并 dispose 对应纹理。Engine dispose 时调用
22881
22973
  */ _proto.dispose = function dispose() {
22974
+ this.clear();
22975
+ };
22976
+ _proto.clear = function clear() {
22882
22977
  for(var _iterator = _create_for_of_iterator_helper_loose(this.atlases.values()), _step; !(_step = _iterator()).done;){
22883
22978
  var atlas = _step.value;
22884
22979
  atlas.dispose();
@@ -23001,6 +23096,17 @@ var Graphics = /*#__PURE__*/ function() {
23001
23096
  this.texturedMaterial.depthTest = false;
23002
23097
  this.texturedMaterial.depthMask = false;
23003
23098
  this.texturedMaterial.blending = true;
23099
+ // 文本 atlas 按 Pixi 的方式在上传时预乘 alpha,因此采样后只需应用顶点色和顶点 alpha。
23100
+ // 单独使用 material,避免改变 drawTexture 对普通非预乘纹理的处理。
23101
+ this.textMaterial = Material.create(this.engine, {
23102
+ shader: {
23103
+ 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 }",
23104
+ 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 }"
23105
+ }
23106
+ });
23107
+ this.textMaterial.depthTest = false;
23108
+ this.textMaterial.depthMask = false;
23109
+ this.textMaterial.blending = true;
23004
23110
  this.textCache = new TextCache(engine);
23005
23111
  }
23006
23112
  var _proto = Graphics.prototype;
@@ -23022,6 +23128,7 @@ var Graphics = /*#__PURE__*/ function() {
23022
23128
  );
23023
23129
  this.coloredMaterial.setMatrix("effects_MatrixVP", projectionMatrix);
23024
23130
  this.texturedMaterial.setMatrix("effects_MatrixVP", projectionMatrix);
23131
+ this.textMaterial.setMatrix("effects_MatrixVP", projectionMatrix);
23025
23132
  };
23026
23133
  /**
23027
23134
  * 将当前变换压入栈,并设置新的变换
@@ -23049,7 +23156,7 @@ var Graphics = /*#__PURE__*/ function() {
23049
23156
  * 切换到指定批次类型/纹理。若与当前批次不一致,先 flush 已累积顶点
23050
23157
  */ _proto.ensureBatch = function ensureBatch(type, texture) {
23051
23158
  if (texture === void 0) texture = null;
23052
- var sameBatch = this.currentBatchType === type && (type !== "textured" || this.currentBatchTexture === texture);
23159
+ var sameBatch = this.currentBatchType === type && (type === "colored" || this.currentBatchTexture === texture);
23053
23160
  if (!sameBatch && this.currentVertexCount > 0) {
23054
23161
  this.flushBatch();
23055
23162
  }
@@ -23075,8 +23182,8 @@ var Graphics = /*#__PURE__*/ function() {
23075
23182
  this.geometry.setIndexData(indicesArray);
23076
23183
  this.geometry.setDrawCount(this.currentIndexCount);
23077
23184
  var material;
23078
- if (this.currentBatchType === "textured") {
23079
- material = this.texturedMaterial;
23185
+ if (this.currentBatchType === "textured" || this.currentBatchType === "text") {
23186
+ material = this.currentBatchType === "text" ? this.textMaterial : this.texturedMaterial;
23080
23187
  var _this_currentBatchTexture;
23081
23188
  var tex = (_this_currentBatchTexture = this.currentBatchTexture) != null ? _this_currentBatchTexture : this.engine.whiteTexture;
23082
23189
  material.setTexture("uMainTexture", tex);
@@ -23291,7 +23398,7 @@ var Graphics = /*#__PURE__*/ function() {
23291
23398
  return;
23292
23399
  }
23293
23400
  var atlas = this.textCache.getAtlas(fontSize, fontFamily, fontWeight, fontStyle);
23294
- this.ensureBatch("textured", atlas.texture);
23401
+ this.ensureBatch("text", atlas.texture);
23295
23402
  var lineHeight = atlas.lineHeight;
23296
23403
  var cursorX = x;
23297
23404
  // ensureChar 可能往 atlas canvas 写新字并打 dirty 标;实际 upload 推迟到
@@ -23302,13 +23409,15 @@ var Graphics = /*#__PURE__*/ function() {
23302
23409
  continue;
23303
23410
  }
23304
23411
  // atlas 像素坐标 → UV(纹理 flipY 后,canvas 顶 → v=1,canvas 底 → v=0)
23305
- var u0 = info.px / ATLAS_SIZE;
23306
- var u1 = (info.px + info.pw) / ATLAS_SIZE;
23307
- var v0 = 1 - (info.py + info.ph) / ATLAS_SIZE;
23308
- var v1 = 1 - info.py / ATLAS_SIZE;
23412
+ var atlasWidth = atlas.canvas.width;
23413
+ var atlasHeight = atlas.canvas.height;
23414
+ var u0 = info.px / atlasWidth;
23415
+ var u1 = (info.px + info.pw) / atlasWidth;
23416
+ var v0 = 1 - (info.py + info.ph) / atlasHeight;
23417
+ var v1 = 1 - info.py / atlasHeight;
23309
23418
  // quad 宽与采样区都含四周 padding(cell 留白透明);但光标只按 advance 前进,
23310
23419
  // quad 起点左偏 paddingLeft 使字形 ink 落在 cursorX — padding 区重叠无妨
23311
- this.pushQuad(cursorX - info.paddingLeft, y, info.pw / FONT_SCALE, lineHeight, color, {
23420
+ this.pushQuad(cursorX - info.paddingLeft, y, info.pw / atlas.resolution, lineHeight, color, {
23312
23421
  u0: u0,
23313
23422
  v0: v0,
23314
23423
  u1: u1,
@@ -23321,6 +23430,7 @@ var Graphics = /*#__PURE__*/ function() {
23321
23430
  this.geometry.dispose();
23322
23431
  this.coloredMaterial.dispose();
23323
23432
  this.texturedMaterial.dispose();
23433
+ this.textMaterial.dispose();
23324
23434
  this.textCache.dispose();
23325
23435
  };
23326
23436
  _proto.buildShape = function buildShape(shape, color) {
@@ -24391,410 +24501,358 @@ FrameComponent = __decorate([
24391
24501
  // 第四列 (位移) 乘 1,无需修改
24392
24502
  }
24393
24503
 
24394
- /**
24395
- * 画布层组件
24396
- *
24397
- * 作为一组顶层 CanvasItem 的容器:本层内所有 parent 为 null 的 CanvasItem 都登记在 canvasItems 中。
24398
- * 嵌套关系下的子 CanvasItem 通过其父 CanvasItem 的 children 数组管理,由父节点在 draw 时递归绘制。
24399
- */ var CanvasLayer = /*#__PURE__*/ function(Component) {
24400
- _inherits(CanvasLayer, Component);
24401
- function CanvasLayer() {
24402
- var _this;
24403
- _this = Component.apply(this, arguments) || this;
24404
- /**
24405
- * 当前层中的顶层 CanvasItem 列表(按注册顺序)。
24406
- * 仅包含 parent 为 null 的 CanvasItem;嵌套的子 CanvasItem 不会出现在此列表
24407
- */ _this.canvasItems = [];
24408
- /**
24409
- * 绘制层级,数值越小越先绘制
24410
- */ _this.layer = 0;
24411
- return _this;
24412
- }
24413
- var _proto = CanvasLayer.prototype;
24414
- /**
24415
- * 注册一个顶层 CanvasItem 到当前层
24416
- * @internal
24417
- */ _proto.addCanvasItem = function addCanvasItem(canvasItem) {
24418
- if (this.canvasItems.includes(canvasItem)) {
24419
- return;
24420
- }
24421
- this.canvasItems.push(canvasItem);
24422
- };
24423
- /**
24424
- * 从当前层注销一个顶层 CanvasItem
24425
- * @internal
24426
- */ _proto.removeCanvasItem = function removeCanvasItem(canvasItem) {
24427
- removeItem(this.canvasItems, canvasItem);
24428
- };
24429
- _proto.onEnable = function onEnable() {
24430
- var _this_item_composition;
24431
- var canvasLayers = (_this_item_composition = this.item.composition) == null ? void 0 : _this_item_composition.canvasLayers;
24432
- if (canvasLayers && !canvasLayers.includes(this)) {
24433
- canvasLayers.push(this);
24434
- }
24435
- };
24436
- _proto.onDisable = function onDisable() {
24437
- this.removeFromComposition();
24438
- this.refreshCanvasItemsLayer();
24504
+ function _assert_this_initialized(self) {
24505
+ if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
24506
+ return self;
24507
+ }
24508
+
24509
+ var MouseFilter;
24510
+ (function(MouseFilter) {
24511
+ MouseFilter[MouseFilter["Stop"] = 0] = "Stop";
24512
+ MouseFilter[MouseFilter["Pass"] = 1] = "Pass";
24513
+ MouseFilter[MouseFilter["Ignore"] = 2] = "Ignore";
24514
+ })(MouseFilter || (MouseFilter = {}));
24515
+ var MouseBehaviorRecursive;
24516
+ (function(MouseBehaviorRecursive) {
24517
+ MouseBehaviorRecursive[MouseBehaviorRecursive["Inherited"] = 0] = "Inherited";
24518
+ MouseBehaviorRecursive[MouseBehaviorRecursive["Disabled"] = 1] = "Disabled";
24519
+ MouseBehaviorRecursive[MouseBehaviorRecursive["Enabled"] = 2] = "Enabled";
24520
+ })(MouseBehaviorRecursive || (MouseBehaviorRecursive = {}));
24521
+ var MouseButton;
24522
+ (function(MouseButton) {
24523
+ MouseButton[MouseButton["None"] = 0] = "None";
24524
+ MouseButton[MouseButton["Left"] = 1] = "Left";
24525
+ MouseButton[MouseButton["Right"] = 2] = "Right";
24526
+ MouseButton[MouseButton["Middle"] = 3] = "Middle";
24527
+ MouseButton[MouseButton["WheelUp"] = 4] = "WheelUp";
24528
+ MouseButton[MouseButton["WheelDown"] = 5] = "WheelDown";
24529
+ MouseButton[MouseButton["WheelLeft"] = 6] = "WheelLeft";
24530
+ MouseButton[MouseButton["WheelRight"] = 7] = "WheelRight";
24531
+ MouseButton[MouseButton["Xbutton1"] = 8] = "Xbutton1";
24532
+ MouseButton[MouseButton["Xbutton2"] = 9] = "Xbutton2";
24533
+ })(MouseButton || (MouseButton = {}));
24534
+ var MouseButtonMask;
24535
+ (function(MouseButtonMask) {
24536
+ MouseButtonMask[MouseButtonMask["None"] = 0] = "None";
24537
+ MouseButtonMask[MouseButtonMask["Left"] = 1] = "Left";
24538
+ MouseButtonMask[MouseButtonMask["Right"] = 2] = "Right";
24539
+ MouseButtonMask[MouseButtonMask["Middle"] = 4] = "Middle";
24540
+ MouseButtonMask[MouseButtonMask["Xbutton1"] = 128] = "Xbutton1";
24541
+ MouseButtonMask[MouseButtonMask["Xbutton2"] = 256] = "Xbutton2";
24542
+ })(MouseButtonMask || (MouseButtonMask = {}));
24543
+ var FocusMode;
24544
+ (function(FocusMode) {
24545
+ FocusMode[FocusMode["None"] = 0] = "None";
24546
+ FocusMode[FocusMode["Click"] = 1] = "Click";
24547
+ FocusMode[FocusMode["All"] = 2] = "All";
24548
+ FocusMode[FocusMode["Accessibility"] = 3] = "Accessibility";
24549
+ })(FocusMode || (FocusMode = {}));
24550
+ var FocusBehaviorRecursive;
24551
+ (function(FocusBehaviorRecursive) {
24552
+ FocusBehaviorRecursive[FocusBehaviorRecursive["Inherited"] = 0] = "Inherited";
24553
+ FocusBehaviorRecursive[FocusBehaviorRecursive["Disabled"] = 1] = "Disabled";
24554
+ FocusBehaviorRecursive[FocusBehaviorRecursive["Enabled"] = 2] = "Enabled";
24555
+ })(FocusBehaviorRecursive || (FocusBehaviorRecursive = {}));
24556
+ var KeyLocation;
24557
+ (function(KeyLocation) {
24558
+ KeyLocation[KeyLocation["Unspecified"] = 0] = "Unspecified";
24559
+ KeyLocation[KeyLocation["Left"] = 1] = "Left";
24560
+ KeyLocation[KeyLocation["Right"] = 2] = "Right";
24561
+ })(KeyLocation || (KeyLocation = {}));
24562
+ var CursorShape;
24563
+ (function(CursorShape) {
24564
+ CursorShape[CursorShape["Arrow"] = 0] = "Arrow";
24565
+ CursorShape[CursorShape["Ibeam"] = 1] = "Ibeam";
24566
+ CursorShape[CursorShape["PointingHand"] = 2] = "PointingHand";
24567
+ CursorShape[CursorShape["Cross"] = 3] = "Cross";
24568
+ CursorShape[CursorShape["Wait"] = 4] = "Wait";
24569
+ CursorShape[CursorShape["Busy"] = 5] = "Busy";
24570
+ CursorShape[CursorShape["Drag"] = 6] = "Drag";
24571
+ CursorShape[CursorShape["CanDrop"] = 7] = "CanDrop";
24572
+ CursorShape[CursorShape["Forbidden"] = 8] = "Forbidden";
24573
+ CursorShape[CursorShape["Vsize"] = 9] = "Vsize";
24574
+ CursorShape[CursorShape["Hsize"] = 10] = "Hsize";
24575
+ CursorShape[CursorShape["Bdiagsize"] = 11] = "Bdiagsize";
24576
+ CursorShape[CursorShape["Fdiagsize"] = 12] = "Fdiagsize";
24577
+ CursorShape[CursorShape["Move"] = 13] = "Move";
24578
+ CursorShape[CursorShape["Vsplit"] = 14] = "Vsplit";
24579
+ CursorShape[CursorShape["Hsplit"] = 15] = "Hsplit";
24580
+ CursorShape[CursorShape["Help"] = 16] = "Help";
24581
+ })(CursorShape || (CursorShape = {}));
24582
+
24583
+ function _get_prototype_of(o) {
24584
+ _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
24585
+ return o.__proto__ || Object.getPrototypeOf(o);
24439
24586
  };
24440
- _proto.removeFromComposition = function removeFromComposition() {
24441
- var _this_item_composition;
24442
- var canvasLayers = (_this_item_composition = this.item.composition) == null ? void 0 : _this_item_composition.canvasLayers;
24443
- if (canvasLayers) {
24444
- removeItem(canvasLayers, this);
24587
+ return _get_prototype_of(o);
24588
+ }
24589
+
24590
+ function _is_native_function(fn) {
24591
+ return Function.toString.call(fn).indexOf("[native code]") !== -1;
24592
+ }
24593
+
24594
+ function _wrap_native_super(Class) {
24595
+ var _cache = typeof Map === "function" ? new Map() : undefined;
24596
+ _wrap_native_super = function _wrap_native_super(Class) {
24597
+ if (Class === null || !_is_native_function(Class)) return Class;
24598
+ if (typeof Class !== "function") throw new TypeError("Super expression must either be null or a function");
24599
+ if (typeof _cache !== "undefined") {
24600
+ if (_cache.has(Class)) return _cache.get(Class);
24601
+ _cache.set(Class, Wrapper);
24445
24602
  }
24446
- };
24447
- _proto.refreshCanvasItemsLayer = function refreshCanvasItemsLayer() {
24448
- // CanvasLayer 失效时,让其下挂的 CanvasItem 重新查找归属层
24449
- // 拷贝一份避免迭代过程中数组被修改
24450
- var items = this.canvasItems.slice();
24451
- this.canvasItems.length = 0;
24452
- for(var _iterator = _create_for_of_iterator_helper_loose(items), _step; !(_step = _iterator()).done;){
24453
- var canvasItem = _step.value;
24454
- canvasItem.updateCanvasLayer();
24603
+ function Wrapper() {
24604
+ return _construct(Class, arguments, _get_prototype_of(this).constructor);
24455
24605
  }
24456
- };
24457
- /**
24458
- * 绘制当前层
24459
- *
24460
- * 遍历顶层 CanvasItem 进行绘制,由 CanvasItem.drawInternal 内部递归子节点。
24461
- * 整棵跳过看 `vfxItem.isActive`(item 级开关);self 自身是否画由 drawInternal 内的 `component.enabled` 决定。
24462
- *
24463
- * 注:画布尺寸到 RectTransform.size 的同步目前未在此处处理(由 RectTransform 自身按需 resolve);
24464
- * 后续若需要在每帧强制刷新顶层 size,可在此处补回写入与 sizeChanged 传播
24465
- *
24466
- * @internal
24467
- */ _proto.draw = function draw() {
24468
- for(var _iterator = _create_for_of_iterator_helper_loose(this.canvasItems), _step; !(_step = _iterator()).done;){
24469
- var canvasItem = _step.value;
24470
- if (!canvasItem.item.isActive) {
24471
- continue;
24606
+ Wrapper.prototype = Object.create(Class.prototype, {
24607
+ constructor: {
24608
+ value: Wrapper,
24609
+ enumerable: false,
24610
+ writable: true,
24611
+ configurable: true
24472
24612
  }
24473
- canvasItem.drawInternal();
24474
- }
24613
+ });
24614
+ return _set_prototype_of(Wrapper, Class);
24475
24615
  };
24476
- return CanvasLayer;
24477
- }(Component);
24616
+ return _wrap_native_super(Class);
24617
+ }
24478
24618
 
24479
- /**
24480
- * 画布元素组件
24481
- *
24482
- * 进入场景树时沿父链向上查找最近的 CanvasLayer 祖先并注册自己;
24483
- * 父级改变或自身销毁时,刷新 / 注销在所属 CanvasLayer 的登记。
24484
- *
24485
- * 注:拓扑(parent / children / 所属 layer)与 enabled/active 解耦
24486
- * `component.enabled=false` 仅让自身 draw 被跳过,**不**改父子关系,也**不**从 layer 注销;
24487
- * 整棵子树的隐藏由 `vfxItem.setActive(false)` 配合 drawInternal 中的 `isActive` 检查处理
24488
- */ var CanvasItem = /*#__PURE__*/ function(Component) {
24489
- _inherits(CanvasItem, Component);
24490
- function CanvasItem() {
24491
- var _this;
24492
- _this = Component.apply(this, arguments) || this;
24493
- /**
24494
- * 父 CanvasItem
24495
- * 沿 VFXItem 父链向上查找到的最近的 CanvasItem(只看类型,不看 active/enabled — 拓扑跟激活状态解耦)。
24496
- * 若不存在 CanvasItem 祖先(即直属于 CanvasLayer 或处于游离状态),该值为 null。
24497
- */ _this.parent = null;
24498
- /**
24499
- * 子 CanvasItem 列表(按注册顺序)
24500
- * 由子节点在维护自身 parent 时反向写入,draw 时按数组顺序递归绘制
24501
- */ _this.children = [];
24502
- /**
24503
- * 当前所属的 CanvasLayer,未注册到任何 CanvasLayer 时为 null
24504
- */ _this.canvasLayerNode = null;
24505
- return _this;
24619
+ function transformPoint(transform, value) {
24620
+ var elements = transform.elements;
24621
+ return new Vector2(elements[0] * value.x + elements[3] * value.y + elements[6], elements[1] * value.x + elements[4] * value.y + elements[7]);
24622
+ }
24623
+ function transformVector(transform, value) {
24624
+ var elements = transform.elements;
24625
+ return new Vector2(elements[0] * value.x + elements[3] * value.y, elements[1] * value.x + elements[4] * value.y);
24626
+ }
24627
+ var InputEvent = /*#__PURE__*/ function() {
24628
+ function InputEvent() {
24629
+ this.device = 0;
24630
+ this.pressed = false;
24631
+ this.canceled = false;
24506
24632
  }
24507
- var _proto = CanvasItem.prototype;
24508
- _proto.onEnable = function onEnable() {
24509
- // 首次接入 / 重新接入场景树时把自己挂上(若拓扑还没建立)。
24510
- // 注意 enable/disable 不再改变 CanvasItem 父子拓扑 — 拓扑由 VFXItem 父链(setParent / onParentChanged)维护,
24511
- // enable 在这里只是兜底首次入树
24512
- this.updateCanvasLayer();
24513
- this.updateParentItem();
24514
- };
24515
- _proto.onDisable = function onDisable() {
24516
- // 组件禁用 = 仅 self.draw 跳过,不应改父子拓扑(否则 enable 回来位置就乱了)。
24517
- // 整棵子树的隐藏由 `vfxItem.setActive(false)` 配合 drawInternal 中的 `item.isActive` 检查处理
24518
- };
24519
- _proto.onParentChanged = function onParentChanged() {
24520
- // VFXItem 的父级(或间接父级)发生变化时,CanvasLayer 与父 CanvasItem 都可能改变,需要联动刷新
24521
- this.updateCanvasLayer();
24522
- this.updateParentItem();
24523
- };
24524
- _proto.onDestroy = function onDestroy() {
24525
- this.removeFromParent();
24526
- this.removeFromCanvasLayer();
24527
- // 防止子 canvasItem updateParentItem 的时候继续找到当前已销毁的 canvasItem
24528
- this.enabled = false;
24529
- this.updateChildrenParentItems();
24530
- };
24531
- /**
24532
- * 重新计算并更新当前 CanvasItem 应归属的 CanvasLayer
24533
- * 在父级变化、所在 CanvasLayer 失效等场景中调用
24534
- *
24535
- * 仅当自身是顶层 CanvasItem(parent 为 null)时才会登记到 CanvasLayer.canvasItems;
24536
- * 嵌套的子 CanvasItem 仅记录 canvasLayerNode 引用,不进入 layer 的顶层列表。
24537
- * @internal
24538
- */ _proto.updateCanvasLayer = function updateCanvasLayer() {
24539
- // 拓扑跟 enabled/active 解耦,只看 item 是否还在
24540
- if (!this.item) {
24541
- this.removeFromCanvasLayer();
24542
- return;
24543
- }
24544
- var newLayer = this.getCanvasLayerNode();
24545
- if (newLayer === this.canvasLayerNode) {
24546
- return;
24547
- }
24548
- // 仅当自身是顶层 CanvasItem 时,才需要在 layer 的 canvasItems 中迁移
24549
- if (this.parent === null && this.canvasLayerNode) {
24550
- this.canvasLayerNode.removeCanvasItem(this);
24551
- }
24552
- this.canvasLayerNode = newLayer;
24553
- if (this.parent === null && newLayer) {
24554
- newLayer.addCanvasItem(this);
24555
- }
24556
- };
24557
- /**
24558
- * 重新计算并更新当前 CanvasItem 的父 CanvasItem
24559
- * 在 VFXItem 父级变化、自身启用/禁用、父 CanvasItem 失效等场景中调用
24560
- *
24561
- * parent 的变化会同步影响在 CanvasLayer.canvasItems 中的归属:
24562
- * - 由有 parent 变成无 parent 且仍归属某 layer:加入 layer.canvasItems
24563
- * - 由无 parent 变成有 parent:从 layer.canvasItems 中移除
24564
- * @internal
24565
- */ _proto.updateParentItem = function updateParentItem() {
24566
- // 拓扑跟 enabled/active 解耦,只看 item 是否还在
24567
- if (!this.item) {
24568
- this.removeFromParent();
24569
- return;
24570
- }
24571
- var newParent = this.getParentItem();
24572
- if (newParent === this.parent) {
24573
- return;
24574
- }
24575
- var wasTopLevel = this.parent === null;
24576
- this.removeFromParent();
24577
- if (newParent) {
24578
- this.parent = newParent;
24579
- newParent.children.push(this);
24580
- // 由顶层变成嵌套:从 layer 的顶层列表中移除
24581
- if (wasTopLevel && this.canvasLayerNode) {
24582
- this.canvasLayerNode.removeCanvasItem(this);
24583
- }
24584
- } else if (!wasTopLevel && this.canvasLayerNode) {
24585
- // 由嵌套变成顶层:加入 layer 的顶层列表
24586
- this.canvasLayerNode.addCanvasItem(this);
24587
- }
24588
- };
24589
- /**
24590
- * 绘制函数
24591
- * 子类重写此方法以输出实际的绘制内容;调用时 graphics 的变换栈顶已经累积了从根到当前节点的所有父变换,
24592
- * 子类直接使用 this.drawXxx / this.fillXxx 系列封装方法绘制即可,绘制坐标视为本地坐标。
24593
- */ _proto.draw = function draw() {
24594
- // OVERRIDE
24595
- };
24596
- /**
24597
- * 绘制单条线段
24598
- * @param x1 - 起点 x
24599
- * @param y1 - 起点 y
24600
- * @param x2 - 终点 x
24601
- * @param y2 - 终点 y
24602
- * @param color - 线条颜色
24603
- * @param thickness - 线宽
24604
- */ _proto.drawLine = function drawLine(x1, y1, x2, y2, color, thickness) {
24605
- this.engine.graphics.drawLine(x1, y1, x2, y2, color, thickness);
24633
+ var _proto = InputEvent.prototype;
24634
+ _proto.isPressed = function isPressed() {
24635
+ return this.pressed && !this.canceled;
24606
24636
  };
24607
- /**
24608
- * 按顺序连接所有点绘制折线(首尾相同则视为闭合)
24609
- * @param points - 点数组,格式 [x1,y1,x2,y2,...]
24610
- * @param color - 线条颜色
24611
- * @param thickness - 线宽
24612
- */ _proto.drawPolyline = function drawPolyline(points, color, thickness) {
24613
- this.engine.graphics.drawLines(points, color, thickness);
24637
+ _proto.isReleased = function isReleased() {
24638
+ return !this.pressed && !this.canceled;
24614
24639
  };
24615
- /**
24616
- * 绘制三次贝塞尔曲线
24617
- */ _proto.drawBezier = function drawBezier(x1, y1, x2, y2, x3, y3, x4, y4, color, thickness) {
24618
- this.engine.graphics.drawBezier(x1, y1, x2, y2, x3, y3, x4, y4, color, thickness);
24619
- };
24620
- /**
24621
- * 绘制三角形边框
24622
- */ _proto.drawTriangle = function drawTriangle(x1, y1, x2, y2, x3, y3, color, thickness) {
24623
- this.engine.graphics.drawTriangle(x1, y1, x2, y2, x3, y3, color, thickness);
24640
+ _proto.isCanceled = function isCanceled() {
24641
+ return this.canceled;
24624
24642
  };
24625
- /**
24626
- * 绘制矩形边框
24627
- * @param x - 矩形左下角 x 坐标
24628
- * @param y - 矩形左下角 y 坐标
24629
- */ _proto.drawRect = function drawRect(x, y, width, height, color, thickness) {
24630
- this.engine.graphics.drawRectangle(x, y, width, height, color, thickness);
24631
- };
24632
- /**
24633
- * 绘制圆形边框
24634
- */ _proto.drawCircle = function drawCircle(cx, cy, radius, color, thickness) {
24635
- this.engine.graphics.drawCircle(cx, cy, radius, color, thickness);
24636
- };
24637
- /**
24638
- * 绘制填充三角形
24639
- */ _proto.fillTriangle = function fillTriangle(x1, y1, x2, y2, x3, y3, color) {
24640
- this.engine.graphics.fillTriangle(x1, y1, x2, y2, x3, y3, color);
24641
- };
24642
- /**
24643
- * 绘制填充矩形
24644
- * @param x - 矩形左下角 x 坐标
24645
- * @param y - 矩形左下角 y 坐标
24646
- */ _proto.fillRect = function fillRect(x, y, width, height, color) {
24647
- this.engine.graphics.fillRectangle(x, y, width, height, color);
24648
- };
24649
- /**
24650
- * 绘制填充圆形
24651
- */ _proto.fillCircle = function fillCircle(cx, cy, radius, color) {
24652
- this.engine.graphics.fillCircle(cx, cy, radius, color);
24653
- };
24654
- /**
24655
- * 绘制纹理矩形(本地坐标,Y 向上,(x, y) 为左下角)
24656
- * @param region - 纹理 UV 子矩形,默认全图。Y 向上,(u0, v0) 为左下角 UV
24657
- * @param color - 乘色,默认白色
24658
- */ _proto.drawTexture = function drawTexture(x, y, width, height, texture, region, color) {
24659
- this.engine.graphics.drawTexture(x, y, width, height, texture, region, color);
24660
- };
24661
- /**
24662
- * 绘制文本(本地坐标,Y 向上,(x, y) 为文本左下角)。
24663
- *
24664
- * 同一段文本不同颜色不会重复 upload — 颜色由 `color` 参数透传作为乘色,纹理只缓存白色字形。
24665
- * 字体参数全部展开,避免调用方每帧创建临时 style 对象触发 GC
24666
- */ _proto.drawText = function drawText(x, y, text, fontSize, color, fontFamily, fontWeight, fontStyle) {
24667
- this.engine.graphics.drawText(x, y, text, fontSize, color, fontFamily, fontWeight, fontStyle);
24668
- };
24669
- /**
24670
- * 绘制自身并按 children 数组顺序递归绘制所有子 CanvasItem。
24671
- * @internal
24672
- */ _proto.drawInternal = function drawInternal() {
24673
- var graphics = this.engine.graphics;
24674
- var localMatrix2D = this.transform.getMatrix2D();
24675
- graphics.pushTransform(localMatrix2D);
24676
- // self 是否绘制只看 component.enabled — 其它都不影响。
24677
- // transform 始终被 push,children 始终被遍历,这样 component.enabled=false 时 self 隐藏
24678
- // 但 children 的位置不受影响
24679
- if (this.enabled) {
24680
- this.draw();
24681
- }
24682
- // 子是否参与绘制看 VFXItem.isActive(整棵跳过的语义)。
24683
- // 子自身的 component.enabled 在它自己的 drawInternal 里再判断
24684
- for(var _iterator = _create_for_of_iterator_helper_loose(this.children), _step; !(_step = _iterator()).done;){
24685
- var child = _step.value;
24686
- if (!child.item.isActive) {
24687
- continue;
24688
- }
24689
- child.drawInternal();
24690
- }
24691
- graphics.popTransform();
24692
- };
24693
- /**
24694
- * 从当前所属的 CanvasLayer 注销自身(如果有)
24695
- * 仅当自身是顶层 CanvasItem 时,才会触发 layer 顶层列表的移除
24696
- */ _proto.removeFromCanvasLayer = function removeFromCanvasLayer() {
24697
- if (!this.canvasLayerNode) {
24698
- return;
24699
- }
24700
- if (this.parent === null) {
24701
- this.canvasLayerNode.removeCanvasItem(this);
24702
- }
24703
- this.canvasLayerNode = null;
24704
- };
24705
- /**
24706
- * 从当前父 CanvasItem 的 children 中移除自身(如果有)
24707
- */ _proto.removeFromParent = function removeFromParent() {
24708
- if (!this.parent) {
24709
- return;
24710
- }
24711
- removeItem(this.parent.children, this);
24712
- this.parent = null;
24713
- };
24714
- /**
24715
- * 更新所有子 CanvasItem 的层级归属。
24716
- * 自身失效时调用,子节点会跳过自己向上找到新的父 CanvasItem(可能为 null)。
24717
- */ _proto.updateChildrenParentItems = function updateChildrenParentItems() {
24718
- if (this.children.length === 0) {
24719
- return;
24720
- }
24721
- // 拷贝避免迭代过程中数组被 removeFromParent 修改
24722
- var snapshot = this.children.slice();
24723
- for(var _iterator = _create_for_of_iterator_helper_loose(snapshot), _step; !(_step = _iterator()).done;){
24724
- var child = _step.value;
24725
- child.updateParentItem();
24726
- }
24727
- };
24728
- /**
24729
- * 沿父链向上查找最近的 CanvasLayer 祖先
24730
- * 注意:自身所在 VFXItem 上的 CanvasLayer 也参与查找(同节点上可能并存 CanvasLayer 与 CanvasItem)
24731
- */ _proto.getCanvasLayerNode = function getCanvasLayerNode() {
24732
- var current = this.item;
24733
- while(current){
24734
- var layer = getCanvasLayerFromItem(current);
24735
- if (layer) {
24736
- return layer;
24737
- }
24738
- var _current_parent;
24739
- current = (_current_parent = current.parent) != null ? _current_parent : null;
24740
- }
24741
- return null;
24643
+ _proto.isEcho = function isEcho() {
24644
+ return false;
24742
24645
  };
24743
- /**
24744
- * 沿 VFXItem 父链向上查找最近的 CanvasItem 祖先(不包含自身,只看类型不看 active/enabled)
24745
- */ _proto.getParentItem = function getParentItem() {
24746
- var _this_item;
24747
- var _this_item_parent;
24748
- var current = (_this_item_parent = (_this_item = this.item) == null ? void 0 : _this_item.parent) != null ? _this_item_parent : null;
24749
- while(current){
24750
- var canvasItem = getCanvasItemFromItem(current);
24751
- if (canvasItem) {
24752
- return canvasItem;
24753
- }
24754
- var _current_parent;
24755
- current = (_current_parent = current.parent) != null ? _current_parent : null;
24756
- }
24757
- return null;
24646
+ _proto.xformedBy = function xformedBy(transform) {
24647
+ var event = new InputEvent();
24648
+ event.device = this.device;
24649
+ event.pressed = this.pressed;
24650
+ event.canceled = this.canceled;
24651
+ return event;
24758
24652
  };
24759
- _create_class(CanvasItem, [
24760
- {
24761
- key: "canvasLayer",
24762
- get: /**
24763
- * 获取当前所属的 CanvasLayer
24764
- */ function get() {
24765
- return this.canvasLayerNode;
24766
- }
24767
- }
24768
- ]);
24769
- return CanvasItem;
24770
- }(Component);
24771
- /**
24772
- * 在指定 VFXItem 上查找一个激活的 CanvasLayer 组件
24773
- */ function getCanvasLayerFromItem(item) {
24774
- for(var _iterator = _create_for_of_iterator_helper_loose(item.components), _step; !(_step = _iterator()).done;){
24775
- var component = _step.value;
24776
- if (_instanceof1(component, CanvasLayer) && component.isActiveAndEnabled) {
24777
- return component;
24778
- }
24653
+ return InputEvent;
24654
+ }();
24655
+ InputEvent.deviceIdEmulation = -1;
24656
+ InputEvent.deviceIdInternal = -2;
24657
+ InputEvent.deviceIdKeyboard = 16;
24658
+ InputEvent.deviceIdMouse = 32;
24659
+ var InputEventWithModifiers = /*#__PURE__*/ function(InputEvent) {
24660
+ _inherits(InputEventWithModifiers, InputEvent);
24661
+ function InputEventWithModifiers() {
24662
+ var _this;
24663
+ _this = InputEvent.apply(this, arguments) || this;
24664
+ _this.commandOrControlAutoremap = false;
24665
+ _this.shiftPressed = false;
24666
+ _this.altPressed = false;
24667
+ _this.metaPressed = false;
24668
+ _this.ctrlPressed = false;
24669
+ return _this;
24779
24670
  }
24780
- return null;
24781
- }
24782
- /**
24783
- * 在指定 VFXItem 上查找 CanvasItem 组件(只看类型,不看 active/enabled — 拓扑跟激活状态解耦)
24784
- */ function getCanvasItemFromItem(item) {
24785
- for(var _iterator = _create_for_of_iterator_helper_loose(item.components), _step; !(_step = _iterator()).done;){
24786
- var component = _step.value;
24787
- if (_instanceof1(component, CanvasItem)) {
24788
- return component;
24789
- }
24671
+ var _proto = InputEventWithModifiers.prototype;
24672
+ _proto.copyModifiersTo = function copyModifiersTo(event) {
24673
+ event.device = this.device;
24674
+ event.pressed = this.pressed;
24675
+ event.canceled = this.canceled;
24676
+ event.commandOrControlAutoremap = this.commandOrControlAutoremap;
24677
+ event.shiftPressed = this.shiftPressed;
24678
+ event.altPressed = this.altPressed;
24679
+ event.metaPressed = this.metaPressed;
24680
+ event.ctrlPressed = this.ctrlPressed;
24681
+ };
24682
+ _proto.xformedBy = function xformedBy(transform) {
24683
+ var event = new InputEventWithModifiers();
24684
+ this.copyModifiersTo(event);
24685
+ return event;
24686
+ };
24687
+ return InputEventWithModifiers;
24688
+ }(_wrap_native_super(InputEvent));
24689
+ var InputEventKey = /*#__PURE__*/ function(InputEventWithModifiers) {
24690
+ _inherits(InputEventKey, InputEventWithModifiers);
24691
+ function InputEventKey() {
24692
+ var _this;
24693
+ _this = InputEventWithModifiers.apply(this, arguments) || this;
24694
+ _this.keycode = "";
24695
+ _this.physicalKeycode = "";
24696
+ _this.keyLabel = "";
24697
+ _this.unicode = 0;
24698
+ _this.location = KeyLocation.Unspecified;
24699
+ _this.echo = false;
24700
+ return _this;
24790
24701
  }
24791
- return null;
24792
- }
24793
-
24794
- /**
24795
- * 16 preset 对应的 anchorMin / anchorMax(Y 向上)
24796
- */ var ANCHOR_PRESET_TABLE = {
24797
- // [anchorMin.x, anchorMin.y, anchorMax.x, anchorMax.y]
24702
+ var _proto = InputEventKey.prototype;
24703
+ _proto.isEcho = function isEcho() {
24704
+ return this.echo;
24705
+ };
24706
+ _proto.xformedBy = function xformedBy(transform) {
24707
+ var event = new InputEventKey();
24708
+ this.copyModifiersTo(event);
24709
+ event.keycode = this.keycode;
24710
+ event.physicalKeycode = this.physicalKeycode;
24711
+ event.keyLabel = this.keyLabel;
24712
+ event.unicode = this.unicode;
24713
+ event.location = this.location;
24714
+ event.echo = this.echo;
24715
+ return event;
24716
+ };
24717
+ return InputEventKey;
24718
+ }(InputEventWithModifiers);
24719
+ var InputEventMouse = /*#__PURE__*/ function(InputEventWithModifiers) {
24720
+ _inherits(InputEventMouse, InputEventWithModifiers);
24721
+ function InputEventMouse() {
24722
+ var _this;
24723
+ _this = InputEventWithModifiers.apply(this, arguments) || this;
24724
+ _this.buttonMask = MouseButtonMask.None;
24725
+ _this.position = new Vector2();
24726
+ _this.globalPosition = new Vector2();
24727
+ return _this;
24728
+ }
24729
+ var _proto = InputEventMouse.prototype;
24730
+ _proto.copyMouseTo = function copyMouseTo(event) {
24731
+ this.copyModifiersTo(event);
24732
+ event.buttonMask = this.buttonMask;
24733
+ event.position.copyFrom(this.position);
24734
+ event.globalPosition.copyFrom(this.globalPosition);
24735
+ };
24736
+ _proto.xformedBy = function xformedBy(transform) {
24737
+ var event = new InputEventMouse();
24738
+ this.copyMouseTo(event);
24739
+ event.position.copyFrom(transformPoint(transform, this.position));
24740
+ return event;
24741
+ };
24742
+ return InputEventMouse;
24743
+ }(InputEventWithModifiers);
24744
+ var InputEventMouseButton = /*#__PURE__*/ function(InputEventMouse) {
24745
+ _inherits(InputEventMouseButton, InputEventMouse);
24746
+ function InputEventMouseButton() {
24747
+ var _this;
24748
+ _this = InputEventMouse.apply(this, arguments) || this;
24749
+ _this.factor = 1;
24750
+ _this.buttonIndex = MouseButton.None;
24751
+ _this.doubleClick = false;
24752
+ return _this;
24753
+ }
24754
+ var _proto = InputEventMouseButton.prototype;
24755
+ _proto.xformedBy = function xformedBy(transform) {
24756
+ var event = new InputEventMouseButton();
24757
+ this.copyMouseTo(event);
24758
+ event.position.copyFrom(transformPoint(transform, this.position));
24759
+ event.factor = this.factor;
24760
+ event.buttonIndex = this.buttonIndex;
24761
+ event.doubleClick = this.doubleClick;
24762
+ return event;
24763
+ };
24764
+ return InputEventMouseButton;
24765
+ }(InputEventMouse);
24766
+ var InputEventMouseMotion = /*#__PURE__*/ function(InputEventMouse) {
24767
+ _inherits(InputEventMouseMotion, InputEventMouse);
24768
+ function InputEventMouseMotion() {
24769
+ var _this;
24770
+ _this = InputEventMouse.apply(this, arguments) || this;
24771
+ _this.tilt = new Vector2();
24772
+ _this.pressure = 0;
24773
+ _this.relative = new Vector2();
24774
+ _this.screenRelative = new Vector2();
24775
+ _this.velocity = new Vector2();
24776
+ _this.screenVelocity = new Vector2();
24777
+ _this.penInverted = false;
24778
+ return _this;
24779
+ }
24780
+ var _proto = InputEventMouseMotion.prototype;
24781
+ _proto.xformedBy = function xformedBy(transform) {
24782
+ var event = new InputEventMouseMotion();
24783
+ this.copyMouseTo(event);
24784
+ event.position.copyFrom(transformPoint(transform, this.position));
24785
+ event.tilt.copyFrom(this.tilt);
24786
+ event.pressure = this.pressure;
24787
+ event.relative.copyFrom(transformVector(transform, this.relative));
24788
+ event.screenRelative.copyFrom(this.screenRelative);
24789
+ event.velocity.copyFrom(transformVector(transform, this.velocity));
24790
+ event.screenVelocity.copyFrom(this.screenVelocity);
24791
+ event.penInverted = this.penInverted;
24792
+ return event;
24793
+ };
24794
+ return InputEventMouseMotion;
24795
+ }(InputEventMouse);
24796
+ var InputEventScreenTouch = /*#__PURE__*/ function(InputEvent) {
24797
+ _inherits(InputEventScreenTouch, InputEvent);
24798
+ function InputEventScreenTouch() {
24799
+ var _this;
24800
+ _this = InputEvent.apply(this, arguments) || this;
24801
+ _this.index = 0;
24802
+ _this.position = new Vector2();
24803
+ _this.doubleTap = false;
24804
+ return _this;
24805
+ }
24806
+ var _proto = InputEventScreenTouch.prototype;
24807
+ _proto.xformedBy = function xformedBy(transform) {
24808
+ var event = new InputEventScreenTouch();
24809
+ event.device = this.device;
24810
+ event.pressed = this.pressed;
24811
+ event.canceled = this.canceled;
24812
+ event.index = this.index;
24813
+ event.position.copyFrom(transformPoint(transform, this.position));
24814
+ event.doubleTap = this.doubleTap;
24815
+ return event;
24816
+ };
24817
+ return InputEventScreenTouch;
24818
+ }(_wrap_native_super(InputEvent));
24819
+ var InputEventScreenDrag = /*#__PURE__*/ function(InputEvent) {
24820
+ _inherits(InputEventScreenDrag, InputEvent);
24821
+ function InputEventScreenDrag() {
24822
+ var _this;
24823
+ _this = InputEvent.apply(this, arguments) || this;
24824
+ _this.index = 0;
24825
+ _this.position = new Vector2();
24826
+ _this.relative = new Vector2();
24827
+ _this.screenRelative = new Vector2();
24828
+ _this.velocity = new Vector2();
24829
+ _this.screenVelocity = new Vector2();
24830
+ _this.pressure = 0;
24831
+ _this.tilt = new Vector2();
24832
+ _this.penInverted = false;
24833
+ return _this;
24834
+ }
24835
+ var _proto = InputEventScreenDrag.prototype;
24836
+ _proto.xformedBy = function xformedBy(transform) {
24837
+ var event = new InputEventScreenDrag();
24838
+ event.device = this.device;
24839
+ event.pressed = this.pressed;
24840
+ event.canceled = this.canceled;
24841
+ event.index = this.index;
24842
+ event.position.copyFrom(transformPoint(transform, this.position));
24843
+ event.relative.copyFrom(transformVector(transform, this.relative));
24844
+ event.screenRelative.copyFrom(this.screenRelative);
24845
+ event.velocity.copyFrom(transformVector(transform, this.velocity));
24846
+ event.screenVelocity.copyFrom(this.screenVelocity);
24847
+ event.pressure = this.pressure;
24848
+ event.tilt.copyFrom(this.tilt);
24849
+ event.penInverted = this.penInverted;
24850
+ return event;
24851
+ };
24852
+ return InputEventScreenDrag;
24853
+ }(_wrap_native_super(InputEvent));
24854
+
24855
+ var ANCHOR_PRESET_TABLE = {
24798
24856
  topLeft: [
24799
24857
  0,
24800
24858
  1,
@@ -24893,306 +24951,170 @@ FrameComponent = __decorate([
24893
24951
  ]
24894
24952
  };
24895
24953
  /**
24896
- * 锚点布局变换。`RectTransform extends Transform`,在 Transform position/rotation/scale/size/anchor(=pivot 偏移)
24897
- * 之上额外维护 4 边锚点 + 4 边像素偏移,提供 rect 解算与编辑 API。
24898
- *
24899
- * 解算公式(Y 向上,父 vertex 坐标原点 = 父 rect 左下角):
24900
- * ```
24901
- * left = offsetMin.x + anchorMin.x * parentSize.x
24902
- * bottom = offsetMin.y + anchorMin.y * parentSize.y
24903
- * right = offsetMax.x + anchorMax.x * parentSize.x
24904
- * top = offsetMax.y + anchorMax.y * parentSize.y
24905
- * ```
24906
- *
24907
- * 写回 Transform:
24908
- * - `position` ← `(left, bottom)`(rect 左下角,父 vertex 坐标)
24909
- * - `size` ← rect 尺寸
24910
- * - `anchor`(Vector3 像素 pivot 偏移)由用户独立设置,仅作旋转/缩放中心
24911
- *
24912
- * **解算入口** 是 `sizeChanged()` 方法:
24913
- * - 父是 RectTransform → 用 `parent.size` parentSize 解算自身,写回 `position` / `size`
24914
- * - 否则(顶层 / 没父):自身 size 视为权威值(由外部 通常是 CanvasLayer 直接写),不再自解算
24915
- * - 末尾遍历 `children` 中的 RectTransform,直接调它们的 `sizeChanged()`,链式向下传播
24916
- *
24917
- * **重写 `setPosition` / `setSize`** 让其语义变为"用户输入 rect 位置 / 尺寸":
24918
- * - 顶层(无 RectTransform 父):直接写 `super.setPosition / super.setSize`,然后 `sizeChanged` 传播给子节点
24919
- * - 否则:反推 offset 维持当前 anchor,然后 `sizeChanged` 重算并向下传
24920
- */ var RectTransform = /*#__PURE__*/ function(Transform) {
24921
- _inherits(RectTransform, Transform);
24922
- function RectTransform() {
24923
- var _this;
24924
- _this = Transform.apply(this, arguments) || this;
24925
- /**
24926
- * 父 rect 上的归一化最小角 `(anchorLeft, anchorBottom)`
24927
- */ _this.anchorMin = new Vector2(0, 0);
24928
- /**
24929
- * 父 rect 上的归一化最大角 `(anchorRight, anchorTop)`
24930
- */ _this.anchorMax = new Vector2(0, 0);
24931
- /**
24932
- * rect 左/下边相对 anchorMin 锚点的像素偏移 `(offsetLeft, offsetBottom)`
24933
- */ _this.offsetMin = new Vector2(0, 0);
24934
- /**
24935
- * rect 右/上边相对 anchorMax 锚点的像素偏移 `(offsetRight, offsetTop)`
24936
- */ _this.offsetMax = new Vector2(0, 0);
24937
- /**
24938
- * 自身 rect 上的归一化轴心 `(0..1)`,默认 `(0.5, 0.5)`(中心)。两层效果:
24939
- * 1. **Layout**:`setSize` 时 rect 围绕此点对称缩放(pivot=(0.5, 0.5) → 居中扩展;pivot=(0, 0) → 从左下扩展;pivot=(1, 1) → 向左下缩)
24940
- * 2. **矩阵**:`pivot` 自动同步到 `transform.anchor = pivot * size`(像素值,矩阵旋转/缩放中心),
24941
- * 所以旋转/缩放也围绕同一点。`setPivot` 和每次 `sizeChanged`(size 重算后)都会刷新 `transform.anchor`
24942
- */ _this.pivot = new Vector2(0.5, 0.5);
24943
- return _this;
24954
+ * A drawable GUI object. Controls form a tree independent from the VFXItem
24955
+ * scene tree. UIControl is the bridge between both trees.
24956
+ */ var Control = /*#__PURE__*/ function() {
24957
+ function Control(engine) {
24958
+ this.engine = engine;
24959
+ this._parent = null;
24960
+ this._visible = true;
24961
+ this._enabled = true;
24962
+ this._mouseFilter = MouseFilter.Stop;
24963
+ this._mouseBehaviorRecursive = MouseBehaviorRecursive.Inherited;
24964
+ this._focusMode = FocusMode.None;
24965
+ this._focusBehaviorRecursive = FocusBehaviorRecursive.Inherited;
24966
+ this._defaultCursorShape = CursorShape.Arrow;
24967
+ this._rotation = 0;
24968
+ this.transformDirty = true;
24969
+ this.cachedTransform = new Matrix3();
24970
+ this.eventEmitter = new EventEmitter();
24971
+ this.disposed = false;
24972
+ this./** Scene-tree bridge that owns this GUI object, if any. */ owner = null;
24973
+ this.position = new Vector2();
24974
+ this.size = new Vector2(1, 1);
24975
+ this.anchorMin = new Vector2();
24976
+ this.anchorMax = new Vector2();
24977
+ this.offsetMin = new Vector2();
24978
+ this.offsetMax = new Vector2(1, 1);
24979
+ this.pivot = new Vector2(0.5, 0.5);
24980
+ this.scale = new Vector2(1, 1);
24981
+ this.shear = new Vector2();
24982
+ this.mouseForcePassScrollEvents = true;
24983
+ this.clipContents = false;
24944
24984
  }
24945
- var _proto = RectTransform.prototype;
24946
- /**
24947
- * 反序列化:在 `Transform.fromData` 基础上还原 RectTransform 特有的 `pivot` /
24948
- * `anchorMin` / `anchorMax` / `offsetMin` / `offsetMax`。
24949
- *
24950
- * 顺序:
24951
- * 1. `super.fromData` 还原 `position` / `rotation` / `scale` / `size` / `anchor`
24952
- * 2. 若数据有 size,从 `anchor / size` 反推 `pivot`,保持 `anchor = pivot * size` 一致
24953
- * 3. 应用 `anchorMin/Max` / `offsetMin/Max`,每个 setter 末尾会触发 `sizeChanged`
24954
- * 重新解算 rect 与同步 `transform.anchor`
24955
- */ _proto.fromData = function fromData(data) {
24956
- Transform.prototype.fromData.call(this, data);
24957
- if (this.size.x !== 0 && this.size.y !== 0) {
24958
- this.pivot.set(this.anchor.x / this.size.x, this.anchor.y / this.size.y);
24985
+ var _proto = Control.prototype;
24986
+ _proto.on = function on(eventName, listener, options) {
24987
+ this.eventEmitter.on(eventName, listener, options);
24988
+ };
24989
+ _proto.off = function off(eventName, listener) {
24990
+ this.eventEmitter.off(eventName, listener);
24991
+ };
24992
+ _proto.setPosition = function setPosition(x, y, keepOffsets) {
24993
+ if (keepOffsets === void 0) keepOffsets = false;
24994
+ if (this.position.x === x && this.position.y === y) {
24995
+ return;
24959
24996
  }
24960
- // @ts-expect-error spec.TransformData 暂未声明 RectTransform 字段
24961
- if (data.anchorMin) {
24962
- // @ts-expect-error
24963
- this.setAnchorMin(data.anchorMin.x, data.anchorMin.y);
24997
+ var rect = {
24998
+ position: new Vector2(x, y),
24999
+ size: this.size.clone()
25000
+ };
25001
+ if (keepOffsets && this.parent) {
25002
+ this.computeAnchors(rect, this.getParentRect());
25003
+ } else {
25004
+ this.computeOffsets(rect, this.getParentRect());
24964
25005
  }
24965
- // @ts-expect-error
24966
- if (data.anchorMax) {
24967
- // @ts-expect-error
24968
- this.setAnchorMax(data.anchorMax.x, data.anchorMax.y);
25006
+ this.updateLayout();
25007
+ };
25008
+ _proto.setSize = function setSize(width, height) {
25009
+ if (this.size.x === width && this.size.y === height) {
25010
+ return;
24969
25011
  }
24970
- // @ts-expect-error
24971
- if (data.offsetMin) {
24972
- // @ts-expect-error
24973
- this.setOffsetMin(data.offsetMin.x, data.offsetMin.y);
25012
+ var rect = {
25013
+ position: this.position.clone(),
25014
+ size: new Vector2(width, height)
25015
+ };
25016
+ this.computeOffsets(rect, this.getParentRect());
25017
+ this.updateLayout();
25018
+ };
25019
+ _proto.setScale = function setScale(x, y) {
25020
+ if (this.scale.x !== x || this.scale.y !== y) {
25021
+ this.scale.set(x, y);
25022
+ this.markTransformDirty();
24974
25023
  }
24975
- // @ts-expect-error
24976
- if (data.offsetMax) {
24977
- // @ts-expect-error
24978
- this.setOffsetMax(data.offsetMax.x, data.offsetMax.y);
25024
+ };
25025
+ _proto.setRotation = function setRotation(degrees) {
25026
+ if (this._rotation !== degrees) {
25027
+ this._rotation = degrees;
25028
+ this.markTransformDirty();
25029
+ }
25030
+ };
25031
+ _proto.setShear = function setShear(x, y) {
25032
+ if (this.shear.x !== x || this.shear.y !== y) {
25033
+ this.shear.set(x, y);
25034
+ this.markTransformDirty();
25035
+ }
25036
+ };
25037
+ _proto.setPivot = function setPivot(x, y) {
25038
+ if (this.pivot.x !== x || this.pivot.y !== y) {
25039
+ this.pivot.set(x, y);
25040
+ this.markTransformDirty();
24979
25041
  }
24980
25042
  };
24981
- // ── layout-input setters(改完 → sizeChanged 重算)──────
24982
25043
  _proto.setAnchorMin = function setAnchorMin(x, y) {
24983
25044
  if (this.anchorMin.x !== x || this.anchorMin.y !== y) {
24984
- this.anchorMin.x = x;
24985
- this.anchorMin.y = y;
24986
- this.sizeChanged();
25045
+ this.anchorMin.set(x, y);
25046
+ this.updateLayout();
24987
25047
  }
24988
25048
  };
24989
25049
  _proto.setAnchorMax = function setAnchorMax(x, y) {
24990
25050
  if (this.anchorMax.x !== x || this.anchorMax.y !== y) {
24991
- this.anchorMax.x = x;
24992
- this.anchorMax.y = y;
24993
- this.sizeChanged();
25051
+ this.anchorMax.set(x, y);
25052
+ this.updateLayout();
24994
25053
  }
24995
25054
  };
24996
25055
  _proto.setOffsetMin = function setOffsetMin(x, y) {
24997
25056
  if (this.offsetMin.x !== x || this.offsetMin.y !== y) {
24998
- this.offsetMin.x = x;
24999
- this.offsetMin.y = y;
25000
- this.sizeChanged();
25057
+ this.offsetMin.set(x, y);
25058
+ this.updateLayout();
25001
25059
  }
25002
25060
  };
25003
25061
  _proto.setOffsetMax = function setOffsetMax(x, y) {
25004
25062
  if (this.offsetMax.x !== x || this.offsetMax.y !== y) {
25005
- this.offsetMax.x = x;
25006
- this.offsetMax.y = y;
25007
- this.sizeChanged();
25008
- }
25009
- };
25010
- /**
25011
- * 设置 rect 内的归一化轴心 `(0..1)`,同时把 `transform.anchor`(矩阵旋转/缩放中心)同步到 `pivot * size`。
25012
- * 不重算 rect(pivot 只决定 setSize 行为,不直接影响当前 rect 位置 / 尺寸)
25013
- */ _proto.setPivot = function setPivot(x, y) {
25014
- if (this.pivot.x !== x || this.pivot.y !== y) {
25015
- this.pivot.x = x;
25016
- this.pivot.y = y;
25017
- // 同步 transform.anchor(像素 pivot)= pivot * size,让旋转/缩放绕同一点
25018
- this.anchor.set(this.pivot.x * this.size.x, this.pivot.y * this.size.y, this.anchor.z);
25063
+ this.offsetMax.set(x, y);
25064
+ this.updateLayout();
25019
25065
  }
25020
25066
  };
25021
- /**
25022
- * 重写父类 `setPosition`:
25023
- * - 顶层(无 RectTransform 父):直接 `super.setPosition` 写位置,触发 `sizeChanged` 传播
25024
- * - 非顶层:语义为"设置 rect 左下角到 (x, y)",反推 offset 维持当前 anchor,然后 `sizeChanged` 重算
25025
- *
25026
- * @param keepOffsets - 默认 false。true 时反推 anchor 而非 offset(rect 在屏幕上不动,但 anchor 比例改变)
25027
- */ _proto.setPosition = function setPosition(x, y, z, keepOffsets) {
25028
- if (keepOffsets === void 0) keepOffsets = false;
25029
- if (!_instanceof1(this.parentTransform, RectTransform)) {
25030
- // 顶层:直接写,然后传播给子节点
25031
- Transform.prototype.setPosition.call(this, x, y, z);
25032
- this.sizeChanged();
25033
- return;
25034
- }
25035
- var parentRect = {
25036
- position: new Vector2(0, 0),
25037
- size: this.parentTransform.size.clone()
25038
- };
25039
- var newRect = {
25040
- position: new Vector2(x, y),
25041
- size: this.size.clone()
25042
- };
25043
- if (keepOffsets) {
25044
- this.computeAnchors(newRect, parentRect);
25045
- } else {
25046
- this.computeOffsets(newRect, parentRect);
25047
- }
25048
- this.sizeChanged();
25049
- if (this.position.z !== z) {
25050
- Transform.prototype.setPosition.call(this, this.position.x, this.position.y, z);
25051
- }
25052
- };
25053
- /**
25054
- * 重写父类 `setSize`:
25055
- * - 顶层:直接 `super.setSize`,触发 `sizeChanged` 传播
25056
- * - 非顶层:反推 offset 维持当前 anchor,然后 `sizeChanged` 重算
25057
- */ _proto.setSize = function setSize(x, y) {
25058
- if (this.size.x === x && this.size.y === y) {
25059
- return;
25060
- }
25061
- if (!_instanceof1(this.parentTransform, RectTransform)) {
25062
- Transform.prototype.setSize.call(this, x, y);
25063
- this.sizeChanged();
25064
- return;
25065
- }
25066
- // 围绕 pivot 对称缩放:Δsize 在 offsetMin / offsetMax 上按 pivot / (1-pivot) 比例分配。
25067
- // 例如 pivot=(0.5, 0.5) → 两边各 ±Δ/2,rect 居中扩展;pivot=(0, 0) → offsetMin 不动、offsetMax 全吃,rect 从左下扩展
25068
- var dw = x - this.size.x;
25069
- var dh = y - this.size.y;
25070
- this.offsetMin.set(this.offsetMin.x - this.pivot.x * dw, this.offsetMin.y - this.pivot.y * dh);
25071
- this.offsetMax.set(this.offsetMax.x + (1 - this.pivot.x) * dw, this.offsetMax.y + (1 - this.pivot.y) * dh);
25072
- this.sizeChanged();
25073
- };
25074
- // ── rect query ───────────────────────────────────────
25075
- /**
25076
- * 当前自身 rect(在父 vertex 坐标下,Y 向上)。`sizeChanged` 之后才有意义
25077
- */ _proto.getRect = function getRect() {
25067
+ _proto.getRect = function getRect() {
25078
25068
  return {
25079
- position: new Vector2(this.position.x, this.position.y),
25069
+ position: this.position.clone(),
25080
25070
  size: this.size.clone()
25081
25071
  };
25082
25072
  };
25083
- // ── parent linkage ───────────────────────────────────
25084
- /**
25085
- * transform 切换时重算自身布局。子节点链路通过 `Transform.children` 直接访问,无需事件订阅
25086
- * @internal
25087
- */ _proto.onParentTransformChanged = function onParentTransformChanged(_oldParent, _newParent) {
25088
- if (_instanceof1(_oldParent, RectTransform)) {
25089
- this.engine.off("resize", this.onCanvasResize.bind(this));
25090
- }
25091
- if (!_instanceof1(_newParent, RectTransform)) {
25092
- this.onCanvasResize();
25093
- this.engine.on("resize", this.onCanvasResize.bind(this));
25094
- }
25095
- this.sizeChanged();
25096
- };
25097
- _proto.onCanvasResize = function onCanvasResize() {
25098
- var rect = this.engine.canvas.getBoundingClientRect();
25099
- this.setSize(rect.width, rect.height);
25100
- };
25101
- // ── layout solver──────────────
25102
- /**
25103
- * 解算入口:
25104
- *
25105
- * 1. 父是 RectTransform → 从 `parent.size` 求自身 rect,通过 `super.setPosition / super.setSize` 写回
25106
- * (避免触发本类 setPosition / setSize 重写)
25107
- * 2. 顶层(无 RectTransform 父):自身 size 视为权威值(由 CanvasLayer 等外部直接写),不自解算
25108
- * 3. 遍历 `children` 中所有 RectTransform 子节点,直接调它们的 `sizeChanged()` 链式传播
25109
- */ _proto.sizeChanged = function sizeChanged() {
25110
- if (_instanceof1(this.parentTransform, RectTransform)) {
25111
- var parentSize = this.parentTransform.size;
25112
- var left = this.offsetMin.x + this.anchorMin.x * parentSize.x;
25113
- var bottom = this.offsetMin.y + this.anchorMin.y * parentSize.y;
25114
- var right = this.offsetMax.x + this.anchorMax.x * parentSize.x;
25115
- var top = this.offsetMax.y + this.anchorMax.y * parentSize.y;
25116
- Transform.prototype.setPosition.call(this, left, bottom, this.position.z);
25117
- Transform.prototype.setSize.call(this, right - left, top - bottom);
25118
- }
25119
- // size 更新后同步 transform.anchor(矩阵旋转/缩放中心)= pivot * size,跟 setPivot 保持统一
25120
- this.anchor.set(this.pivot.x * this.size.x, this.pivot.y * this.size.y, this.anchor.z);
25121
- for(var _iterator = _create_for_of_iterator_helper_loose(this.children), _step; !(_step = _iterator()).done;){
25122
- var child = _step.value;
25123
- if (_instanceof1(child, RectTransform)) {
25124
- child.sizeChanged();
25125
- }
25126
- }
25127
- };
25128
- /**
25129
- * 给定目标 rect 反推 offsetMin/Max,保持当前 anchor 不变
25130
- */ _proto.computeOffsets = function computeOffsets(rect, parentRect) {
25131
- 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);
25132
- 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);
25133
- };
25134
- /**
25135
- * 给定目标 rect 反推 anchorMin/Max,保持当前 offset 不变。父 size 为 0 的方向不修改
25136
- */ _proto.computeAnchors = function computeAnchors(rect, parentRect) {
25137
- if (parentRect.size.x !== 0) {
25138
- var aMinX = (rect.position.x - parentRect.position.x - this.offsetMin.x) / parentRect.size.x;
25139
- var aMaxX = (rect.position.x + rect.size.x - parentRect.position.x - this.offsetMax.x) / parentRect.size.x;
25140
- this.anchorMin.x = aMinX;
25141
- this.anchorMax.x = aMaxX;
25142
- }
25143
- if (parentRect.size.y !== 0) {
25144
- var aMinY = (rect.position.y - parentRect.position.y - this.offsetMin.y) / parentRect.size.y;
25145
- var aMaxY = (rect.position.y + rect.size.y - parentRect.position.y - this.offsetMax.y) / parentRect.size.y;
25146
- this.anchorMin.y = aMinY;
25147
- this.anchorMax.y = aMaxY;
25148
- }
25149
- };
25150
- // ── preset API ───────────────────────────────────────
25151
- /**
25152
- * 把 anchorMin/Max 设为内建预设。
25153
- * @param keepOffsets - 默认 true:offset 不动,rect 实际位置会跳到新 anchor 计算的位置(要求保留视觉位置请用 setAnchorsAndOffsetsPreset)
25154
- */ _proto.setAnchorsPreset = function setAnchorsPreset(preset, keepOffsets) {
25073
+ _proto.getTransform2D = function getTransform2D() {
25074
+ if (this.transformDirty) {
25075
+ var radians = this._rotation * Math.PI / 180;
25076
+ var sin = Math.sin(radians);
25077
+ var cos = Math.cos(radians);
25078
+ var shearX = Math.tan(Math.max(-89, Math.min(89, this.shear.x)) * Math.PI / 180);
25079
+ var shearY = Math.tan(Math.max(-89, Math.min(89, this.shear.y)) * Math.PI / 180);
25080
+ var a = this.scale.x * (cos - sin * shearY);
25081
+ var b = this.scale.x * (sin + cos * shearY);
25082
+ var c = this.scale.y * (cos * shearX - sin);
25083
+ var d = this.scale.y * (sin * shearX + cos);
25084
+ var pivotX = this.pivot.x * this.size.x;
25085
+ var pivotY = this.pivot.y * this.size.y;
25086
+ var tx = this.position.x + pivotX - a * pivotX - c * pivotY;
25087
+ var ty = this.position.y + pivotY - b * pivotX - d * pivotY;
25088
+ this.cachedTransform.set(a, b, 0, c, d, 0, tx, ty, 1);
25089
+ this.transformDirty = false;
25090
+ }
25091
+ return this.cachedTransform;
25092
+ };
25093
+ _proto.setAnchorsPreset = function setAnchorsPreset(preset, keepOffsets) {
25155
25094
  if (keepOffsets === void 0) keepOffsets = true;
25156
- 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];
25095
+ 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];
25157
25096
  if (keepOffsets) {
25158
- this.anchorMin.set(aMinX, aMinY);
25159
- this.anchorMax.set(aMaxX, aMaxY);
25160
- } else if (_instanceof1(this.parentTransform, RectTransform)) {
25161
- var parentRect = {
25162
- position: new Vector2(0, 0),
25163
- size: this.parentTransform.size.clone()
25164
- };
25165
- var rect = this.getRect();
25166
- this.anchorMin.set(aMinX, aMinY);
25167
- this.anchorMax.set(aMaxX, aMaxY);
25168
- this.computeOffsets(rect, parentRect);
25097
+ this.anchorMin.set(minX, minY);
25098
+ this.anchorMax.set(maxX, maxY);
25169
25099
  } else {
25170
- // 顶层无父 rect 可参考,降级为 keepOffsets
25171
- this.anchorMin.set(aMinX, aMinY);
25172
- this.anchorMax.set(aMaxX, aMaxY);
25100
+ var rect = this.getRect();
25101
+ this.anchorMin.set(minX, minY);
25102
+ this.anchorMax.set(maxX, maxY);
25103
+ this.computeOffsets(rect, this.getParentRect());
25173
25104
  }
25174
- this.sizeChanged();
25105
+ this.updateLayout();
25175
25106
  };
25176
- /**
25177
- * 把 offsetMin/Max 设为预设值,使 rect 在父 rect 内落在视觉上对应的位置(留 margin 像素边距)。
25178
- * 当 anchor 已经按相同 preset 设定时,等价于“贴边放置带 margin 的 rect”。
25179
- * 使用当前 size 作为 rect 尺寸。
25180
- */ _proto.setOffsetsPreset = function setOffsetsPreset(preset, margin) {
25107
+ _proto.setOffsetsPreset = function setOffsetsPreset(preset, margin) {
25181
25108
  if (margin === void 0) margin = 0;
25182
- if (!_instanceof1(this.parentTransform, RectTransform)) {
25109
+ if (!this.parent) {
25183
25110
  return;
25184
25111
  }
25185
- var newSizeX = this.size.x;
25186
- var newSizeY = this.size.y;
25112
+ var parentSize = this.parent.size;
25113
+ var width = this.size.x;
25114
+ var height = this.size.y;
25187
25115
  var a = this.anchorMin;
25188
25116
  var b = this.anchorMax;
25189
- var pw = this.parentTransform.size.x;
25190
- var ph = this.parentTransform.size.y;
25191
- var offMinX = 0;
25192
- var offMaxX = 0;
25193
- var offMinY = 0;
25194
- var offMaxY = 0;
25195
- // X 方向(left / right)
25117
+ var minX = 0, maxX = 0, minY = 0, maxY = 0;
25196
25118
  switch(preset){
25197
25119
  case "topLeft":
25198
25120
  case "bottomLeft":
@@ -25202,25 +25124,21 @@ FrameComponent = __decorate([
25202
25124
  case "leftWide":
25203
25125
  case "hcenterWide":
25204
25126
  case "fullRect":
25205
- offMinX = margin - a.x * pw;
25206
- offMaxX = margin + newSizeX - b.x * pw;
25127
+ minX = margin - a.x * parentSize.x;
25128
+ maxX = margin + width - b.x * parentSize.x;
25207
25129
  break;
25208
25130
  case "centerTop":
25209
25131
  case "centerBottom":
25210
25132
  case "center":
25211
25133
  case "vcenterWide":
25212
- offMinX = 0.5 * pw - newSizeX / 2 - a.x * pw;
25213
- offMaxX = 0.5 * pw + newSizeX / 2 - b.x * pw;
25134
+ minX = 0.5 * parentSize.x - width / 2 - a.x * parentSize.x;
25135
+ maxX = 0.5 * parentSize.x + width / 2 - b.x * parentSize.x;
25214
25136
  break;
25215
- case "topRight":
25216
- case "bottomRight":
25217
- case "centerRight":
25218
- case "rightWide":
25219
- offMinX = pw - margin - newSizeX - a.x * pw;
25220
- offMaxX = pw - margin - b.x * pw;
25137
+ default:
25138
+ minX = parentSize.x - margin - width - a.x * parentSize.x;
25139
+ maxX = parentSize.x - margin - b.x * parentSize.x;
25221
25140
  break;
25222
25141
  }
25223
- // Y 方向(bottom / top)— Y 向上
25224
25142
  switch(preset){
25225
25143
  case "bottomLeft":
25226
25144
  case "bottomRight":
@@ -25230,91 +25148,1438 @@ FrameComponent = __decorate([
25230
25148
  case "bottomWide":
25231
25149
  case "vcenterWide":
25232
25150
  case "fullRect":
25233
- offMinY = margin - a.y * ph;
25234
- offMaxY = margin + newSizeY - b.y * ph;
25151
+ minY = margin - a.y * parentSize.y;
25152
+ maxY = margin + height - b.y * parentSize.y;
25235
25153
  break;
25236
25154
  case "centerLeft":
25237
25155
  case "centerRight":
25238
25156
  case "center":
25239
25157
  case "hcenterWide":
25240
- offMinY = 0.5 * ph - newSizeY / 2 - a.y * ph;
25241
- offMaxY = 0.5 * ph + newSizeY / 2 - b.y * ph;
25158
+ minY = 0.5 * parentSize.y - height / 2 - a.y * parentSize.y;
25159
+ maxY = 0.5 * parentSize.y + height / 2 - b.y * parentSize.y;
25242
25160
  break;
25243
- case "topLeft":
25244
- case "topRight":
25245
- case "centerTop":
25246
- case "topWide":
25247
- offMinY = ph - margin - newSizeY - a.y * ph;
25248
- offMaxY = ph - margin - b.y * ph;
25161
+ default:
25162
+ minY = parentSize.y - margin - height - a.y * parentSize.y;
25163
+ maxY = parentSize.y - margin - b.y * parentSize.y;
25249
25164
  break;
25250
25165
  }
25251
- this.offsetMin.set(offMinX, offMinY);
25252
- this.offsetMax.set(offMaxX, offMaxY);
25253
- this.sizeChanged();
25166
+ this.offsetMin.set(minX, minY);
25167
+ this.offsetMax.set(maxX, maxY);
25168
+ this.updateLayout();
25254
25169
  };
25255
- /**
25256
- * 同时设置 anchor 和 offset,达到“按 preset 摆放并贴边带 margin”的效果。
25257
- *
25258
- * 注意第一步用 `keepOffsets=false`(反推 offset 维持 rect 视觉位置),不能用默认 `true`:
25259
- * 后者会让 rect 的 size 在中间步先跳到错值(因为 anchor 改了 offset 没改),
25260
- * 第二步 `setOffsetsPreset` 又用这个错 size 算 offset,最终 rect size 不对
25261
- */ _proto.setAnchorsAndOffsetsPreset = function setAnchorsAndOffsetsPreset(preset, margin) {
25170
+ _proto.setAnchorsAndOffsetsPreset = function setAnchorsAndOffsetsPreset(preset, margin) {
25262
25171
  if (margin === void 0) margin = 0;
25263
25172
  this.setAnchorsPreset(preset, false);
25264
25173
  this.setOffsetsPreset(preset, margin);
25265
25174
  };
25266
- /**
25267
- * 用既有 Transform 的状态创建 RectTransform。
25268
- * 用于 Control / CanvasLayer 接管 VFXItem 时,把 VFXItem 自带的 Transform 升级为 RectTransform 而不丢失 position/rotation/scale 等已设置好的状态。
25269
- */ RectTransform.fromTransform = function fromTransform(t) {
25270
- if (_instanceof1(t, RectTransform)) {
25271
- return t;
25175
+ _proto.getGlobalTransform2D = function getGlobalTransform2D() {
25176
+ var local = this.getTransform2D();
25177
+ return this.parent ? new Matrix3().multiplyMatrices(this.parent.getGlobalTransform2D(), local) : local.clone();
25178
+ };
25179
+ _proto.hasPoint = function hasPoint(point) {
25180
+ return point.x >= 0 && point.y >= 0 && point.x <= this.size.x && point.y <= this.size.y;
25181
+ };
25182
+ _proto.getEffectiveMouseFilter = function getEffectiveMouseFilter() {
25183
+ return this.enabledInHierarchy && this.isMouseRecursiveEnabled() ? this.mouseFilter : MouseFilter.Ignore;
25184
+ };
25185
+ _proto.getFocusModeWithOverride = function getFocusModeWithOverride() {
25186
+ return this.enabledInHierarchy && this.isFocusRecursiveEnabled() ? this.focusMode : FocusMode.None;
25187
+ };
25188
+ _proto.getCursorShape = function getCursorShape(position) {
25189
+ return this.defaultCursorShape;
25190
+ };
25191
+ _proto.acceptEvent = function acceptEvent() {
25192
+ var _this_root;
25193
+ (_this_root = this.root) == null ? void 0 : _this_root.acceptControlEvent(this);
25194
+ };
25195
+ _proto.focus = function focus() {
25196
+ var _this_root;
25197
+ (_this_root = this.root) == null ? void 0 : _this_root.grabControlFocus(this);
25198
+ };
25199
+ _proto.grabFocus = function grabFocus() {
25200
+ this.focus();
25201
+ };
25202
+ _proto.grabClickFocus = function grabClickFocus() {
25203
+ var _this_root;
25204
+ (_this_root = this.root) == null ? void 0 : _this_root.grabControlClickFocus(this);
25205
+ };
25206
+ _proto.releaseFocus = function releaseFocus() {
25207
+ var _this_root;
25208
+ (_this_root = this.root) == null ? void 0 : _this_root.releaseControlFocus(this);
25209
+ };
25210
+ _proto.warpMouse = function warpMouse(position) {
25211
+ var _this_root;
25212
+ var matrix = this.getGlobalTransform2D().elements;
25213
+ (_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]));
25214
+ };
25215
+ /** Converts a window-space position into this control's local coordinates. */ _proto.makePositionLocal = function makePositionLocal(position) {
25216
+ var transform = this.getGlobalTransform2D().clone();
25217
+ if (Math.abs(transform.determinant()) < 1e-12) {
25218
+ return new Vector2();
25219
+ }
25220
+ var elements = transform.invert().elements;
25221
+ return new Vector2(elements[0] * position.x + elements[3] * position.y + elements[6], elements[1] * position.x + elements[4] * position.y + elements[7]);
25222
+ };
25223
+ /** Gets the current mouse position transformed into this control's coordinates. */ _proto.getLocalMousePosition = function getLocalMousePosition() {
25224
+ var root = this.root;
25225
+ return root ? this.makePositionLocal(root.getMousePosition()) : new Vector2();
25226
+ };
25227
+ _proto.update = function update(deltaTime) {};
25228
+ _proto.draw = function draw() {
25229
+ // OVERRIDE
25230
+ };
25231
+ _proto.onDestroy = function onDestroy() {};
25232
+ /** @internal */ _proto.drawInternal = function drawInternal() {
25233
+ if (!this.visibleInHierarchy || this.disposed) {
25234
+ return;
25235
+ }
25236
+ var graphics = this.engine.graphics;
25237
+ graphics.pushTransform(this.getTransform2D());
25238
+ this.draw();
25239
+ graphics.popTransform();
25240
+ };
25241
+ _proto.drawLine = function drawLine(x1, y1, x2, y2, color, thickness) {
25242
+ this.engine.graphics.drawLine(x1, y1, x2, y2, color, thickness);
25243
+ };
25244
+ _proto.drawPolyline = function drawPolyline(points, color, thickness) {
25245
+ this.engine.graphics.drawLines(points, color, thickness);
25246
+ };
25247
+ _proto.drawBezier = function drawBezier(x1, y1, x2, y2, x3, y3, x4, y4, color, thickness) {
25248
+ this.engine.graphics.drawBezier(x1, y1, x2, y2, x3, y3, x4, y4, color, thickness);
25249
+ };
25250
+ _proto.drawTriangle = function drawTriangle(x1, y1, x2, y2, x3, y3, color, thickness) {
25251
+ this.engine.graphics.drawTriangle(x1, y1, x2, y2, x3, y3, color, thickness);
25252
+ };
25253
+ _proto.drawRect = function drawRect(x, y, width, height, color, thickness) {
25254
+ this.engine.graphics.drawRectangle(x, y, width, height, color, thickness);
25255
+ };
25256
+ _proto.drawCircle = function drawCircle(cx, cy, radius, color, thickness) {
25257
+ this.engine.graphics.drawCircle(cx, cy, radius, color, thickness);
25258
+ };
25259
+ _proto.fillTriangle = function fillTriangle(x1, y1, x2, y2, x3, y3, color) {
25260
+ this.engine.graphics.fillTriangle(x1, y1, x2, y2, x3, y3, color);
25261
+ };
25262
+ _proto.fillRect = function fillRect(x, y, width, height, color) {
25263
+ this.engine.graphics.fillRectangle(x, y, width, height, color);
25264
+ };
25265
+ _proto.fillCircle = function fillCircle(cx, cy, radius, color) {
25266
+ this.engine.graphics.fillCircle(cx, cy, radius, color);
25267
+ };
25268
+ _proto.drawTexture = function drawTexture(x, y, width, height, texture, region, color) {
25269
+ this.engine.graphics.drawTexture(x, y, width, height, texture, region, color);
25270
+ };
25271
+ _proto.drawText = function drawText(x, y, text, fontSize, color, fontFamily, fontWeight, fontStyle) {
25272
+ this.engine.graphics.drawText(x, y, text, fontSize, color, fontFamily, fontWeight, fontStyle);
25273
+ };
25274
+ _proto.onMouseEnter = function onMouseEnter(location) {};
25275
+ _proto.onMouseMove = function onMouseMove(location, event) {};
25276
+ _proto.onMouseLeave = function onMouseLeave() {};
25277
+ _proto.onMouseWheel = function onMouseWheel(location, delta, event) {};
25278
+ _proto.onMouseDown = function onMouseDown(location, button, event) {};
25279
+ _proto.onMouseUp = function onMouseUp(location, button, event) {};
25280
+ _proto.onTouchDown = function onTouchDown(location, pointerId, event) {};
25281
+ _proto.onTouchMove = function onTouchMove(location, pointerId, event) {};
25282
+ _proto.onTouchUp = function onTouchUp(location, pointerId, event) {};
25283
+ _proto.onKeyDown = function onKeyDown(event) {};
25284
+ _proto.onKeyUp = function onKeyUp(event) {};
25285
+ _proto.onGotFocus = function onGotFocus() {};
25286
+ _proto.onLostFocus = function onLostFocus() {};
25287
+ /** @internal */ _proto.invokeGetDragData = function invokeGetDragData(position) {
25288
+ return this.getDragData(position);
25289
+ };
25290
+ /** @internal */ _proto.invokeCanDropData = function invokeCanDropData(position, data) {
25291
+ return this.canDropData(position, data);
25292
+ };
25293
+ /** @internal */ _proto.invokeDropData = function invokeDropData(position, data) {
25294
+ this.dropData(position, data);
25295
+ };
25296
+ _proto.getDragData = function getDragData(position) {
25297
+ return null;
25298
+ };
25299
+ _proto.canDropData = function canDropData(position, data) {
25300
+ return false;
25301
+ };
25302
+ _proto.dropData = function dropData(position, data) {};
25303
+ _proto.dispose = function dispose() {
25304
+ if (this.disposed) {
25305
+ return;
25306
+ }
25307
+ this.disposed = true;
25308
+ this.onDestroy();
25309
+ this.parent = null;
25310
+ this.owner = null;
25311
+ };
25312
+ /** @internal */ _proto.updateLayout = function updateLayout() {
25313
+ var _this_parent;
25314
+ var _this_parent_size;
25315
+ var parentSize = (_this_parent_size = (_this_parent = this.parent) == null ? void 0 : _this_parent.size) != null ? _this_parent_size : new Vector2();
25316
+ var left = this.offsetMin.x + this.anchorMin.x * parentSize.x;
25317
+ var bottom = this.offsetMin.y + this.anchorMin.y * parentSize.y;
25318
+ var right = this.offsetMax.x + this.anchorMax.x * parentSize.x;
25319
+ var top = this.offsetMax.y + this.anchorMax.y * parentSize.y;
25320
+ this.applyBounds(left, bottom, right - left, top - bottom);
25321
+ };
25322
+ _proto.applyBounds = function applyBounds(x, y, width, height) {
25323
+ var locationChanged = this.position.x !== x || this.position.y !== y;
25324
+ var sizeChanged = this.size.x !== width || this.size.y !== height;
25325
+ if (!locationChanged && !sizeChanged) {
25326
+ return;
25327
+ }
25328
+ this.position.set(x, y);
25329
+ this.size.set(width, height);
25330
+ this.markTransformDirty();
25331
+ if (locationChanged) {
25332
+ this.eventEmitter.emit("locationChanged", this);
25333
+ }
25334
+ if (sizeChanged) {
25335
+ this.eventEmitter.emit("sizeChanged", this);
25336
+ if (_instanceof1(this, ContainerControl)) {
25337
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.children.slice()), _step; !(_step = _iterator()).done;){
25338
+ var child = _step.value;
25339
+ child.updateLayout();
25340
+ }
25341
+ }
25342
+ }
25343
+ };
25344
+ _proto.markTransformDirty = function markTransformDirty() {
25345
+ var _this_root;
25346
+ this.transformDirty = true;
25347
+ (_this_root = this.root) == null ? void 0 : _this_root.controlTreeChanged();
25348
+ };
25349
+ _proto.getParentRect = function getParentRect() {
25350
+ var _this_parent;
25351
+ var _this_parent_size_clone;
25352
+ return {
25353
+ position: new Vector2(),
25354
+ size: (_this_parent_size_clone = (_this_parent = this.parent) == null ? void 0 : _this_parent.size.clone()) != null ? _this_parent_size_clone : new Vector2()
25355
+ };
25356
+ };
25357
+ _proto.computeOffsets = function computeOffsets(rect, parentRect) {
25358
+ 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);
25359
+ 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);
25360
+ };
25361
+ _proto.computeAnchors = function computeAnchors(rect, parentRect) {
25362
+ if (parentRect.size.x !== 0) {
25363
+ this.anchorMin.x = (rect.position.x - parentRect.position.x - this.offsetMin.x) / parentRect.size.x;
25364
+ this.anchorMax.x = (rect.position.x + rect.size.x - parentRect.position.x - this.offsetMax.x) / parentRect.size.x;
25365
+ }
25366
+ if (parentRect.size.y !== 0) {
25367
+ this.anchorMin.y = (rect.position.y - parentRect.position.y - this.offsetMin.y) / parentRect.size.y;
25368
+ this.anchorMax.y = (rect.position.y + rect.size.y - parentRect.position.y - this.offsetMax.y) / parentRect.size.y;
25369
+ }
25370
+ };
25371
+ _proto.isMouseRecursiveEnabled = function isMouseRecursiveEnabled() {
25372
+ if (this.mouseBehaviorRecursive === MouseBehaviorRecursive.Inherited) {
25373
+ var _this_parent;
25374
+ var _this_parent_isMouseRecursiveEnabled;
25375
+ return (_this_parent_isMouseRecursiveEnabled = (_this_parent = this.parent) == null ? void 0 : _this_parent.isMouseRecursiveEnabled()) != null ? _this_parent_isMouseRecursiveEnabled : true;
25376
+ }
25377
+ return this.mouseBehaviorRecursive === MouseBehaviorRecursive.Enabled;
25378
+ };
25379
+ _proto.isFocusRecursiveEnabled = function isFocusRecursiveEnabled() {
25380
+ if (this.focusBehaviorRecursive === FocusBehaviorRecursive.Inherited) {
25381
+ var _this_parent;
25382
+ var _this_parent_isFocusRecursiveEnabled;
25383
+ return (_this_parent_isFocusRecursiveEnabled = (_this_parent = this.parent) == null ? void 0 : _this_parent.isFocusRecursiveEnabled()) != null ? _this_parent_isFocusRecursiveEnabled : true;
25384
+ }
25385
+ return this.focusBehaviorRecursive === FocusBehaviorRecursive.Enabled;
25386
+ };
25387
+ _create_class(Control, [
25388
+ {
25389
+ key: "parent",
25390
+ get: function get() {
25391
+ return this._parent;
25392
+ },
25393
+ set: function set(value) {
25394
+ var _this__parent;
25395
+ if (value === this._parent) {
25396
+ return;
25397
+ }
25398
+ var previousRoot = this.root;
25399
+ (_this__parent = this._parent) == null ? void 0 : _this__parent.removeChildInternal(this);
25400
+ this._parent = value;
25401
+ value == null ? void 0 : value.addChildInternal(this);
25402
+ this.updateLayout();
25403
+ var nextRoot = this.root;
25404
+ if (previousRoot && previousRoot !== nextRoot) {
25405
+ previousRoot.controlRemoved(this);
25406
+ }
25407
+ nextRoot == null ? void 0 : nextRoot.controlTreeChanged();
25408
+ this.eventEmitter.emit("parentChanged", this);
25409
+ }
25410
+ },
25411
+ {
25412
+ key: "item",
25413
+ get: /** Scene item exposed through the optional UIControl bridge. */ function get() {
25414
+ var _this_owner;
25415
+ var _this_owner_item;
25416
+ return (_this_owner_item = (_this_owner = this.owner) == null ? void 0 : _this_owner.item) != null ? _this_owner_item : null;
25417
+ }
25418
+ },
25419
+ {
25420
+ key: "indexInParent",
25421
+ get: function get() {
25422
+ var _this_parent;
25423
+ var _this_parent_getChildIndex;
25424
+ return (_this_parent_getChildIndex = (_this_parent = this.parent) == null ? void 0 : _this_parent.getChildIndex(this)) != null ? _this_parent_getChildIndex : -1;
25425
+ },
25426
+ set: function set(value) {
25427
+ var _this_parent;
25428
+ (_this_parent = this.parent) == null ? void 0 : _this_parent.changeChildIndex(this, value);
25429
+ }
25430
+ },
25431
+ {
25432
+ key: "visible",
25433
+ get: function get() {
25434
+ return this._visible;
25435
+ },
25436
+ set: function set(value) {
25437
+ if (this._visible !== value) {
25438
+ var _this_root;
25439
+ this._visible = value;
25440
+ (_this_root = this.root) == null ? void 0 : _this_root.controlStateChanged(this);
25441
+ }
25442
+ }
25443
+ },
25444
+ {
25445
+ key: "visibleInHierarchy",
25446
+ get: function get() {
25447
+ var _this_parent;
25448
+ var _this_parent_visibleInHierarchy;
25449
+ return this.visible && ((_this_parent_visibleInHierarchy = (_this_parent = this.parent) == null ? void 0 : _this_parent.visibleInHierarchy) != null ? _this_parent_visibleInHierarchy : true);
25450
+ }
25451
+ },
25452
+ {
25453
+ key: "enabled",
25454
+ get: function get() {
25455
+ return this._enabled;
25456
+ },
25457
+ set: function set(value) {
25458
+ if (this._enabled !== value) {
25459
+ var _this_root;
25460
+ this._enabled = value;
25461
+ (_this_root = this.root) == null ? void 0 : _this_root.controlStateChanged(this);
25462
+ }
25463
+ }
25464
+ },
25465
+ {
25466
+ key: "enabledInHierarchy",
25467
+ get: function get() {
25468
+ var _this_parent;
25469
+ var _this_parent_enabledInHierarchy;
25470
+ return this.enabled && ((_this_parent_enabledInHierarchy = (_this_parent = this.parent) == null ? void 0 : _this_parent.enabledInHierarchy) != null ? _this_parent_enabledInHierarchy : true);
25471
+ }
25472
+ },
25473
+ {
25474
+ key: "mouseFilter",
25475
+ get: function get() {
25476
+ return this._mouseFilter;
25477
+ },
25478
+ set: function set(value) {
25479
+ if (this._mouseFilter !== value) {
25480
+ var _this_root;
25481
+ this._mouseFilter = value;
25482
+ (_this_root = this.root) == null ? void 0 : _this_root.controlStateChanged(this);
25483
+ }
25484
+ }
25485
+ },
25486
+ {
25487
+ key: "mouseBehaviorRecursive",
25488
+ get: function get() {
25489
+ return this._mouseBehaviorRecursive;
25490
+ },
25491
+ set: function set(value) {
25492
+ if (this._mouseBehaviorRecursive !== value) {
25493
+ var _this_root;
25494
+ this._mouseBehaviorRecursive = value;
25495
+ (_this_root = this.root) == null ? void 0 : _this_root.controlStateChanged(this);
25496
+ }
25497
+ }
25498
+ },
25499
+ {
25500
+ key: "focusMode",
25501
+ get: function get() {
25502
+ return this._focusMode;
25503
+ },
25504
+ set: function set(value) {
25505
+ if (this._focusMode !== value) {
25506
+ var _this_root;
25507
+ this._focusMode = value;
25508
+ (_this_root = this.root) == null ? void 0 : _this_root.controlStateChanged(this);
25509
+ }
25510
+ }
25511
+ },
25512
+ {
25513
+ key: "focusBehaviorRecursive",
25514
+ get: function get() {
25515
+ return this._focusBehaviorRecursive;
25516
+ },
25517
+ set: function set(value) {
25518
+ if (this._focusBehaviorRecursive !== value) {
25519
+ var _this_root;
25520
+ this._focusBehaviorRecursive = value;
25521
+ (_this_root = this.root) == null ? void 0 : _this_root.controlStateChanged(this);
25522
+ }
25523
+ }
25524
+ },
25525
+ {
25526
+ key: "defaultCursorShape",
25527
+ get: function get() {
25528
+ return this._defaultCursorShape;
25529
+ },
25530
+ set: function set(value) {
25531
+ this._defaultCursorShape = value;
25532
+ }
25533
+ },
25534
+ {
25535
+ key: "location",
25536
+ get: function get() {
25537
+ return this.position;
25538
+ },
25539
+ set: function set(value) {
25540
+ this.setPosition(value.x, value.y);
25541
+ }
25542
+ },
25543
+ {
25544
+ key: "rotation",
25545
+ get: function get() {
25546
+ return this._rotation;
25547
+ }
25548
+ },
25549
+ {
25550
+ key: "x",
25551
+ get: function get() {
25552
+ return this.position.x;
25553
+ },
25554
+ set: function set(value) {
25555
+ this.setPosition(value, this.position.y);
25556
+ }
25557
+ },
25558
+ {
25559
+ key: "y",
25560
+ get: function get() {
25561
+ return this.position.y;
25562
+ },
25563
+ set: function set(value) {
25564
+ this.setPosition(this.position.x, value);
25565
+ }
25566
+ },
25567
+ {
25568
+ key: "width",
25569
+ get: function get() {
25570
+ return this.size.x;
25571
+ },
25572
+ set: function set(value) {
25573
+ this.setSize(value, this.size.y);
25574
+ }
25575
+ },
25576
+ {
25577
+ key: "height",
25578
+ get: function get() {
25579
+ return this.size.y;
25580
+ },
25581
+ set: function set(value) {
25582
+ this.setSize(this.size.x, value);
25583
+ }
25584
+ },
25585
+ {
25586
+ key: "root",
25587
+ get: function get() {
25588
+ var _this_parent;
25589
+ var _this_parent_root;
25590
+ return _instanceof1(this, RootControl) ? this : (_this_parent_root = (_this_parent = this.parent) == null ? void 0 : _this_parent.root) != null ? _this_parent_root : null;
25591
+ }
25592
+ },
25593
+ {
25594
+ key: "isDisposed",
25595
+ get: function get() {
25596
+ return this.disposed;
25597
+ }
25598
+ }
25599
+ ]);
25600
+ return Control;
25601
+ }();
25602
+ /** A Control that owns child Controls. */ var ContainerControl = /*#__PURE__*/ function(Control) {
25603
+ _inherits(ContainerControl, Control);
25604
+ function ContainerControl() {
25605
+ var _this;
25606
+ _this = Control.apply(this, arguments) || this;
25607
+ _this.children = [];
25608
+ return _this;
25609
+ }
25610
+ var _proto = ContainerControl.prototype;
25611
+ _proto.addChild = function addChild(child) {
25612
+ child.parent = this;
25613
+ return child;
25614
+ };
25615
+ _proto.removeChild = function removeChild(child) {
25616
+ if (child.parent === this) {
25617
+ child.parent = null;
25618
+ }
25619
+ };
25620
+ _proto.getChildIndex = function getChildIndex(child) {
25621
+ return this.children.indexOf(child);
25622
+ };
25623
+ /** @internal */ _proto.changeChildIndex = function changeChildIndex(child, newIndex) {
25624
+ var _this_root;
25625
+ var oldIndex = this.children.indexOf(child);
25626
+ if (oldIndex === newIndex || oldIndex === -1) {
25627
+ return;
25628
+ }
25629
+ this.children.splice(oldIndex, 1);
25630
+ if (newIndex < 0 || newIndex >= this.children.length) {
25631
+ this.children.push(child);
25632
+ } else {
25633
+ this.children.splice(newIndex, 0, child);
25634
+ }
25635
+ (_this_root = this.root) == null ? void 0 : _this_root.controlTreeChanged();
25636
+ };
25637
+ /** @internal */ _proto.addChildInternal = function addChildInternal(child) {
25638
+ if (!this.children.includes(child)) {
25639
+ this.children.push(child);
25640
+ }
25641
+ };
25642
+ /** @internal */ _proto.removeChildInternal = function removeChildInternal(child) {
25643
+ var index = this.children.indexOf(child);
25644
+ if (index !== -1) {
25645
+ this.children.splice(index, 1);
25646
+ }
25647
+ };
25648
+ _proto.drawSelf = function drawSelf() {
25649
+ Control.prototype.draw.call(this);
25650
+ };
25651
+ _proto.draw = function draw() {
25652
+ this.drawSelf();
25653
+ this.drawChildren();
25654
+ };
25655
+ _proto.drawChildren = function drawChildren() {
25656
+ var graphics = this.engine.graphics;
25657
+ if (this.clipContents) ;
25658
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.children), _step; !(_step = _iterator()).done;){
25659
+ var child = _step.value;
25660
+ if (!child.visible || child.isDisposed) {
25661
+ continue;
25662
+ }
25663
+ graphics.pushTransform(child.getTransform2D());
25664
+ child.draw();
25665
+ graphics.popTransform();
25666
+ }
25667
+ };
25668
+ _proto.update = function update(deltaTime) {
25669
+ Control.prototype.update.call(this, deltaTime);
25670
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.children.slice()), _step; !(_step = _iterator()).done;){
25671
+ var child = _step.value;
25672
+ if (child.enabled && !child.isDisposed) {
25673
+ child.update(deltaTime);
25674
+ }
25675
+ }
25676
+ };
25677
+ _proto.dispose = function dispose() {
25678
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.children.slice()), _step; !(_step = _iterator()).done;){
25679
+ var child = _step.value;
25680
+ child.dispose();
25681
+ }
25682
+ Control.prototype.dispose.call(this);
25683
+ };
25684
+ return ContainerControl;
25685
+ }(Control);
25686
+ /** Base class for GUI tree roots and input dispatchers. */ var RootControl = /*#__PURE__*/ function(ContainerControl) {
25687
+ _inherits(RootControl, ContainerControl);
25688
+ function RootControl() {
25689
+ return ContainerControl.apply(this, arguments);
25690
+ }
25691
+ return RootControl;
25692
+ }(ContainerControl);
25693
+
25694
+ var _obj$3;
25695
+ var cursorNames = (_obj$3 = {}, _obj$3[CursorShape.Arrow] = "default", _obj$3[CursorShape.Ibeam] = "text", _obj$3[CursorShape.PointingHand] = "pointer", _obj$3[CursorShape.Cross] = "crosshair", _obj$3[CursorShape.Wait] = "wait", _obj$3[CursorShape.Busy] = "progress", _obj$3[CursorShape.Drag] = "grab", _obj$3[CursorShape.CanDrop] = "copy", _obj$3[CursorShape.Forbidden] = "not-allowed", _obj$3[CursorShape.Vsize] = "ns-resize", _obj$3[CursorShape.Hsize] = "ew-resize", _obj$3[CursorShape.Bdiagsize] = "nesw-resize", _obj$3[CursorShape.Fdiagsize] = "nwse-resize", _obj$3[CursorShape.Move] = "move", _obj$3[CursorShape.Vsplit] = "row-resize", _obj$3[CursorShape.Hsplit] = "col-resize", _obj$3[CursorShape.Help] = "help", _obj$3);
25696
+ function getButtonMask(button) {
25697
+ switch(button){
25698
+ case MouseButton.Left:
25699
+ return MouseButtonMask.Left;
25700
+ case MouseButton.Right:
25701
+ return MouseButtonMask.Right;
25702
+ case MouseButton.Middle:
25703
+ return MouseButtonMask.Middle;
25704
+ case MouseButton.Xbutton1:
25705
+ return MouseButtonMask.Xbutton1;
25706
+ case MouseButton.Xbutton2:
25707
+ return MouseButtonMask.Xbutton2;
25708
+ default:
25709
+ return MouseButtonMask.None;
25710
+ }
25711
+ }
25712
+ function isWheelButton(button) {
25713
+ return button >= MouseButton.WheelUp && button <= MouseButton.WheelRight;
25714
+ }
25715
+ function getWheelDelta(event) {
25716
+ return event.buttonIndex === MouseButton.WheelUp || event.buttonIndex === MouseButton.WheelLeft ? event.factor : -event.factor;
25717
+ }
25718
+ /** CanvasLayer-like boundary for a single UICanvas GUI tree. */ var CanvasRootControl = /*#__PURE__*/ function(ContainerControl) {
25719
+ _inherits(CanvasRootControl, ContainerControl);
25720
+ function CanvasRootControl(engine, canvas) {
25721
+ var _this;
25722
+ _this = ContainerControl.call(this, engine) || this;
25723
+ _this.canvas = canvas;
25724
+ _this.mouseFilter = MouseFilter.Ignore;
25725
+ _this.setSize(engine.canvas.width, engine.canvas.height);
25726
+ return _this;
25727
+ }
25728
+ _create_class(CanvasRootControl, [
25729
+ {
25730
+ key: "inputDisabled",
25731
+ get: function get() {
25732
+ var _this_canvas_item;
25733
+ return !this.canvas.receivesEvents || !this.canvas.enabled || !((_this_canvas_item = this.canvas.item) == null ? void 0 : _this_canvas_item.isActive);
25734
+ }
25735
+ }
25736
+ ]);
25737
+ return CanvasRootControl;
25738
+ }(ContainerControl);
25739
+ /** Global ordered collection of UICanvas roots. */ var CanvasContainer = /*#__PURE__*/ function(ContainerControl) {
25740
+ _inherits(CanvasContainer, ContainerControl);
25741
+ function CanvasContainer(engine) {
25742
+ var _this;
25743
+ _this = ContainerControl.call(this, engine) || this;
25744
+ _this.mouseFilter = MouseFilter.Ignore;
25745
+ _this.setSize(engine.canvas.width, engine.canvas.height);
25746
+ return _this;
25747
+ }
25748
+ var _proto = CanvasContainer.prototype;
25749
+ _proto.sortCanvases = function sortCanvases() {
25750
+ this.children.sort(function(left, right) {
25751
+ return left.canvas.order - right.canvas.order;
25752
+ });
25753
+ };
25754
+ _proto.addChildInternal = function addChildInternal(child) {
25755
+ ContainerControl.prototype.addChildInternal.call(this, child);
25756
+ this.sortCanvases();
25757
+ };
25758
+ _proto.draw = function draw() {
25759
+ this.sortCanvases();
25760
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.children), _step; !(_step = _iterator()).done;){
25761
+ var child = _step.value;
25762
+ var root = child;
25763
+ if (root.canvas.isVisible) {
25764
+ root.draw();
25765
+ }
25766
+ }
25767
+ };
25768
+ return CanvasContainer;
25769
+ }(ContainerControl);
25770
+ /** Engine window GUI root. Routes events across all UICanvas roots. */ var WindowRootControl = /*#__PURE__*/ function(RootControl) {
25771
+ _inherits(WindowRootControl, RootControl);
25772
+ function WindowRootControl(engine) {
25773
+ var _this;
25774
+ _this = RootControl.call(this, engine) || this;
25775
+ _this.dragThreshold = 10;
25776
+ _this.inputHandled = false;
25777
+ _this.gui = {
25778
+ mouseFocus: null,
25779
+ mouseClickGrabber: null,
25780
+ mouseFocusMask: MouseButtonMask.None,
25781
+ mouseOver: null,
25782
+ mouseOverHierarchy: [],
25783
+ touchFocus: new Map(),
25784
+ keyFocus: null,
25785
+ dragAccum: new Vector2(),
25786
+ dragAttempted: false,
25787
+ dragging: false,
25788
+ dragData: null,
25789
+ dragMouseOver: null,
25790
+ dragSuccessful: false,
25791
+ lastMousePosition: new Vector2(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY),
25792
+ sendingMouseEnterExit: false,
25793
+ mouseOverUpdatePending: false
25794
+ };
25795
+ _this.mouseFilter = MouseFilter.Ignore;
25796
+ _this.setSize(engine.canvas.width, engine.canvas.height);
25797
+ _this.canvases = new CanvasContainer(engine);
25798
+ _this.canvases.parent = _assert_this_initialized(_this);
25799
+ return _this;
25800
+ }
25801
+ var _proto = WindowRootControl.prototype;
25802
+ _proto.pushInput = function pushInput(event) {
25803
+ this.inputHandled = false;
25804
+ this.cleanupInternalState();
25805
+ this.processGUIInput(event);
25806
+ this.postGrabClickFocus();
25807
+ };
25808
+ _proto.isInputHandled = function isInputHandled() {
25809
+ return this.inputHandled;
25810
+ };
25811
+ _proto.getMousePosition = function getMousePosition() {
25812
+ return this.gui.lastMousePosition.clone();
25813
+ };
25814
+ _proto.guiGetFocusOwner = function guiGetFocusOwner() {
25815
+ return this.isFocusTargetUsable(this.gui.keyFocus) ? this.gui.keyFocus : null;
25816
+ };
25817
+ _proto.guiReleaseFocus = function guiReleaseFocus() {
25818
+ this.releaseControlFocus();
25819
+ };
25820
+ _proto.guiIsDragging = function guiIsDragging() {
25821
+ return this.gui.dragging;
25822
+ };
25823
+ _proto.guiGetDragData = function guiGetDragData() {
25824
+ return this.gui.dragData;
25825
+ };
25826
+ _proto.guiIsDragSuccessful = function guiIsDragSuccessful() {
25827
+ return this.gui.dragSuccessful;
25828
+ };
25829
+ _proto.guiCancelDrag = function guiCancelDrag() {
25830
+ this.endDragging(false);
25831
+ };
25832
+ _proto.acceptControlEvent = function acceptControlEvent(control) {
25833
+ if (this.isControlUsable(control)) {
25834
+ this.inputHandled = true;
25835
+ }
25836
+ };
25837
+ _proto.grabControlFocus = function grabControlFocus(control) {
25838
+ if (!this.isFocusTargetUsable(control) || this.gui.keyFocus === control) {
25839
+ return;
25840
+ }
25841
+ var previous = this.gui.keyFocus;
25842
+ this.gui.keyFocus = control;
25843
+ if (previous && !previous.isDisposed) {
25844
+ previous.onLostFocus();
25845
+ }
25846
+ control.onGotFocus();
25847
+ };
25848
+ _proto.grabControlClickFocus = function grabControlClickFocus(control) {
25849
+ var _this = this;
25850
+ if (this.isControlValid(control)) {
25851
+ this.gui.mouseClickGrabber = control;
25852
+ queueMicrotask(function() {
25853
+ return _this.postGrabClickFocus();
25854
+ });
25855
+ }
25856
+ };
25857
+ _proto.releaseControlFocus = function releaseControlFocus(control) {
25858
+ var previous = this.gui.keyFocus;
25859
+ if (!previous || control && previous !== control) {
25860
+ return;
25861
+ }
25862
+ this.gui.keyFocus = null;
25863
+ if (!previous.isDisposed) {
25864
+ previous.onLostFocus();
25865
+ }
25866
+ };
25867
+ _proto.warpControlMouse = function warpControlMouse(position) {
25868
+ this.gui.lastMousePosition.copyFrom(position);
25869
+ this.updateMouseOver(position);
25870
+ };
25871
+ _proto.controlStateChanged = function controlStateChanged(control) {
25872
+ if (!this.isControlUsable(control)) {
25873
+ this.dropControlState(control);
25874
+ }
25875
+ this.requestMouseOverUpdate();
25876
+ };
25877
+ _proto.controlRemoved = function controlRemoved(control) {
25878
+ this.dropControlState(control);
25879
+ this.cleanupInternalState();
25880
+ this.requestMouseOverUpdate();
25881
+ };
25882
+ _proto.controlTreeChanged = function controlTreeChanged() {
25883
+ this.requestMouseOverUpdate();
25884
+ };
25885
+ _proto.cancelPointerInput = function cancelPointerInput() {
25886
+ this.dropMouseFocus();
25887
+ this.dropMouseOver();
25888
+ this.gui.touchFocus.clear();
25889
+ this.endDragging(false);
25890
+ this.releaseControlFocus();
25891
+ };
25892
+ _proto.resize = function resize(width, height) {
25893
+ this.setSize(width, height);
25894
+ this.canvases.setSize(width, height);
25895
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.canvases.children), _step; !(_step = _iterator()).done;){
25896
+ var root = _step.value;
25897
+ root.setSize(width, height);
25898
+ }
25899
+ };
25900
+ _proto.render = function render() {
25901
+ if (this.canvases.children.length === 0) {
25902
+ return;
25903
+ }
25904
+ this.engine.graphics.begin();
25905
+ this.draw();
25906
+ this.engine.graphics.end();
25907
+ };
25908
+ _proto.update = function update(deltaTime) {
25909
+ if (this.gui.mouseOverUpdatePending) {
25910
+ this.gui.mouseOverUpdatePending = false;
25911
+ this.updateMouseOver(this.gui.lastMousePosition);
25912
+ }
25913
+ RootControl.prototype.update.call(this, deltaTime);
25914
+ };
25915
+ _proto.dispose = function dispose() {
25916
+ this.cancelPointerInput();
25917
+ RootControl.prototype.dispose.call(this);
25918
+ };
25919
+ _proto.processGUIInput = function processGUIInput(event) {
25920
+ if (_instanceof1(event, InputEventKey)) {
25921
+ var target = this.guiGetFocusOwner();
25922
+ if (target) {
25923
+ this.callControlInput(target, event);
25924
+ }
25925
+ } else if (_instanceof1(event, InputEventMouse)) {
25926
+ this.gui.lastMousePosition.copyFrom(event.globalPosition);
25927
+ this.updateMouseOver(event.globalPosition);
25928
+ if (_instanceof1(event, InputEventMouseButton)) {
25929
+ this.processMouseButton(event);
25930
+ } else if (_instanceof1(event, InputEventMouseMotion)) {
25931
+ this.processMouseMotion(event);
25932
+ }
25933
+ } else if (_instanceof1(event, InputEventScreenTouch)) {
25934
+ this.processScreenTouch(event);
25935
+ } else if (_instanceof1(event, InputEventScreenDrag)) {
25936
+ this.processScreenDrag(event);
25937
+ }
25938
+ };
25939
+ _proto.processMouseButton = function processMouseButton(event) {
25940
+ if (isWheelButton(event.buttonIndex)) {
25941
+ var target = this.findInputControl(event.globalPosition);
25942
+ if (target) {
25943
+ this.callGUIInput(target, event);
25944
+ }
25945
+ return;
25946
+ }
25947
+ var mask = getButtonMask(event.buttonIndex);
25948
+ if (event.isPressed()) {
25949
+ var target1 = this.gui.mouseFocusMask !== 0 ? this.gui.mouseFocus : this.findInputControl(event.globalPosition);
25950
+ this.gui.mouseFocus = target1;
25951
+ if (!target1) {
25952
+ return;
25953
+ }
25954
+ this.gui.mouseFocusMask |= mask;
25955
+ if (event.buttonIndex === MouseButton.Left) {
25956
+ this.gui.dragAccum.setZero();
25957
+ this.gui.dragAttempted = false;
25958
+ this.findClickFocus(target1);
25959
+ }
25960
+ this.callGUIInput(target1, event);
25961
+ } else {
25962
+ if (event.buttonIndex === MouseButton.Left && this.gui.dragging) {
25963
+ this.finishDrop(event.globalPosition);
25964
+ }
25965
+ this.gui.mouseFocusMask &= ~mask;
25966
+ var target2 = this.gui.mouseFocus;
25967
+ if (this.gui.mouseFocusMask === 0) {
25968
+ this.gui.mouseFocus = null;
25969
+ }
25970
+ if (this.isControlUsable(target2)) {
25971
+ this.callGUIInput(target2, event);
25972
+ }
25973
+ }
25974
+ };
25975
+ _proto.processMouseMotion = function processMouseMotion(event) {
25976
+ if (!this.gui.dragging && !this.gui.dragAttempted && this.gui.mouseFocus && (this.gui.mouseFocusMask & MouseButtonMask.Left) !== 0) {
25977
+ this.gui.dragAccum.add(event.relative);
25978
+ if (this.gui.dragAccum.length() > this.dragThreshold) {
25979
+ var origin = event.globalPosition.clone().subtract(this.gui.dragAccum);
25980
+ this.beginDragging(this.gui.mouseFocus, origin);
25981
+ this.gui.dragAttempted = true;
25982
+ }
25983
+ }
25984
+ var target = this.isControlUsable(this.gui.mouseFocus) ? this.gui.mouseFocus : this.findInputControl(event.globalPosition);
25985
+ if (target) {
25986
+ this.callGUIInput(target, event);
25987
+ }
25988
+ if (this.gui.dragging) {
25989
+ this.gui.dragMouseOver = this.findDropTarget(this.findInputControl(event.globalPosition), event.globalPosition);
25990
+ }
25991
+ this.updateCursor(target, event.globalPosition);
25992
+ };
25993
+ _proto.processScreenTouch = function processScreenTouch(event) {
25994
+ var target;
25995
+ if (event.isPressed()) {
25996
+ target = this.findInputControl(event.position);
25997
+ if (target) {
25998
+ this.gui.touchFocus.set(event.index, target);
25999
+ }
26000
+ } else {
26001
+ var _this_gui_touchFocus_get;
26002
+ target = (_this_gui_touchFocus_get = this.gui.touchFocus.get(event.index)) != null ? _this_gui_touchFocus_get : null;
26003
+ this.gui.touchFocus.delete(event.index);
26004
+ }
26005
+ if (this.isControlUsable(target)) {
26006
+ this.callGUIInput(target, event);
26007
+ }
26008
+ };
26009
+ _proto.processScreenDrag = function processScreenDrag(event) {
26010
+ var _this_gui_touchFocus_get;
26011
+ var target = (_this_gui_touchFocus_get = this.gui.touchFocus.get(event.index)) != null ? _this_gui_touchFocus_get : this.findInputControl(event.position);
26012
+ if (this.isControlUsable(target)) {
26013
+ this.callGUIInput(target, event);
26014
+ }
26015
+ };
26016
+ _proto.callGUIInput = function callGUIInput(target, event) {
26017
+ var current = target;
26018
+ var pointerEvent = _instanceof1(event, InputEventMouse) || _instanceof1(event, InputEventScreenTouch) || _instanceof1(event, InputEventScreenDrag);
26019
+ while(current && current !== this && this.isControlUsable(current)){
26020
+ var filter = current.getEffectiveMouseFilter();
26021
+ if (filter !== MouseFilter.Ignore) {
26022
+ this.callControlInput(current, event.xformedBy(this.getGlobalInverse(current)));
26023
+ }
26024
+ var forcePassWheel = _instanceof1(event, InputEventMouseButton) && isWheelButton(event.buttonIndex) && current.mouseForcePassScrollEvents;
26025
+ if (this.inputHandled || filter === MouseFilter.Stop && pointerEvent && !forcePassWheel) {
26026
+ this.inputHandled = true;
26027
+ return;
26028
+ }
26029
+ current = current.parent;
26030
+ }
26031
+ };
26032
+ _proto.callControlInput = function callControlInput(control, event) {
26033
+ if (_instanceof1(event, InputEventMouseButton)) {
26034
+ if (isWheelButton(event.buttonIndex)) {
26035
+ control.onMouseWheel(event.position, getWheelDelta(event), event);
26036
+ } else if (event.isPressed()) {
26037
+ control.onMouseDown(event.position, event.buttonIndex, event);
26038
+ } else {
26039
+ control.onMouseUp(event.position, event.buttonIndex, event);
26040
+ }
26041
+ } else if (_instanceof1(event, InputEventMouseMotion)) {
26042
+ control.onMouseMove(event.position, event);
26043
+ } else if (_instanceof1(event, InputEventScreenTouch)) {
26044
+ if (event.isPressed()) {
26045
+ control.onTouchDown(event.position, event.index, event);
26046
+ } else {
26047
+ control.onTouchUp(event.position, event.index, event);
26048
+ }
26049
+ } else if (_instanceof1(event, InputEventScreenDrag)) {
26050
+ control.onTouchMove(event.position, event.index, event);
26051
+ } else if (_instanceof1(event, InputEventKey)) {
26052
+ if (event.isPressed()) {
26053
+ control.onKeyDown(event);
26054
+ } else if (event.isReleased()) {
26055
+ control.onKeyUp(event);
26056
+ }
26057
+ }
26058
+ };
26059
+ _proto.findInputControl = function findInputControl(position) {
26060
+ this.canvases.sortCanvases();
26061
+ for(var index = this.canvases.children.length - 1; index >= 0; index--){
26062
+ var root = this.canvases.children[index];
26063
+ if (!root.canvas.isVisible || root.inputDisabled) {
26064
+ continue;
26065
+ }
26066
+ var target = this.findControlAtPosition(root, position, true);
26067
+ if (target) {
26068
+ return target;
26069
+ }
26070
+ }
26071
+ return null;
26072
+ };
26073
+ _proto.findControlAtPosition = function findControlAtPosition(container, position, skipSelf) {
26074
+ if (skipSelf === void 0) skipSelf = false;
26075
+ if (!container.visibleInHierarchy || container.isDisposed) {
26076
+ return null;
26077
+ }
26078
+ var localPosition = this.toLocal(container, position);
26079
+ if (container.clipContents && !container.hasPoint(localPosition)) {
26080
+ return null;
26081
+ }
26082
+ for(var index = container.children.length - 1; index >= 0; index--){
26083
+ var child = container.children[index];
26084
+ if (!child.visibleInHierarchy || child.isDisposed) {
26085
+ continue;
26086
+ }
26087
+ if (_instanceof1(child, ContainerControl)) {
26088
+ var found = this.findControlAtPosition(child, position);
26089
+ if (found) {
26090
+ return found;
26091
+ }
26092
+ } else if (child.getEffectiveMouseFilter() !== MouseFilter.Ignore && child.hasPoint(this.toLocal(child, position))) {
26093
+ return child;
26094
+ }
25272
26095
  }
25273
- var rt = new RectTransform();
25274
- rt.engine = t.engine;
25275
- rt.name = t.name;
25276
- rt.position.copyFrom(t.position);
25277
- rt.quat.copyFrom(t.quat);
25278
- rt.rotation.copyFrom(t.rotation);
25279
- rt.scale.copyFrom(t.scale);
25280
- rt.size.copyFrom(t.size);
25281
- // 不拷贝源 anchor — 升级为 RectTransform 时使用默认 pivot=(0.5, 0.5),
25282
- // 把 anchor 同步成 pivot * size,获得“中心轴心”默认行为
25283
- rt.anchor.set(rt.pivot.x * rt.size.x, rt.pivot.y * rt.size.y, t.anchor.z);
25284
- if (t.parentTransform) {
25285
- rt.parentTransform = t.parentTransform;
26096
+ if (!skipSelf && container.getEffectiveMouseFilter() !== MouseFilter.Ignore && container.hasPoint(localPosition)) {
26097
+ return container;
26098
+ }
26099
+ return null;
26100
+ };
26101
+ _proto.updateMouseOver = function updateMouseOver(position) {
26102
+ if (this.gui.sendingMouseEnterExit) {
26103
+ this.gui.mouseOverUpdatePending = true;
26104
+ return;
26105
+ }
26106
+ this.gui.mouseOverUpdatePending = false;
26107
+ var target = this.findInputControl(position);
26108
+ var next = this.buildHoverHierarchy(target);
26109
+ var previous = this.gui.mouseOverHierarchy;
26110
+ var common = 0;
26111
+ while(common < previous.length && common < next.length && previous[common] === next[common]){
26112
+ common++;
26113
+ }
26114
+ this.gui.sendingMouseEnterExit = true;
26115
+ for(var index = previous.length - 1; index >= common; index--){
26116
+ if (!previous[index].isDisposed) {
26117
+ previous[index].onMouseLeave();
26118
+ }
26119
+ }
26120
+ for(var index1 = common; index1 < next.length; index1++){
26121
+ next[index1].onMouseEnter(this.toLocal(next[index1], position));
26122
+ }
26123
+ this.gui.sendingMouseEnterExit = false;
26124
+ this.gui.mouseOver = target;
26125
+ this.gui.mouseOverHierarchy = next;
26126
+ };
26127
+ _proto.buildHoverHierarchy = function buildHoverHierarchy(target) {
26128
+ var hierarchy = [];
26129
+ var current = target;
26130
+ while(current && current !== this){
26131
+ if (current.getEffectiveMouseFilter() !== MouseFilter.Ignore) {
26132
+ hierarchy.push(current);
26133
+ }
26134
+ if (current.getEffectiveMouseFilter() === MouseFilter.Stop) {
26135
+ break;
26136
+ }
26137
+ current = current.parent;
25286
26138
  }
25287
- return rt;
26139
+ hierarchy.reverse();
26140
+ return hierarchy;
25288
26141
  };
25289
- return RectTransform;
25290
- }(Transform);
26142
+ _proto.findClickFocus = function findClickFocus(target) {
26143
+ var current = target;
26144
+ while(current && current !== this){
26145
+ var mode = current.getFocusModeWithOverride();
26146
+ if (mode === FocusMode.Click || mode === FocusMode.All) {
26147
+ this.grabControlFocus(current);
26148
+ return;
26149
+ }
26150
+ if (current.getEffectiveMouseFilter() === MouseFilter.Stop) {
26151
+ return;
26152
+ }
26153
+ current = current.parent;
26154
+ }
26155
+ };
26156
+ _proto.beginDragging = function beginDragging(source, position) {
26157
+ var current = source;
26158
+ while(current && current !== this){
26159
+ var data = current.invokeGetDragData(this.toLocal(current, position));
26160
+ if (data !== null && data !== undefined) {
26161
+ this.gui.dragging = true;
26162
+ this.gui.dragData = data;
26163
+ this.gui.mouseFocus = null;
26164
+ this.gui.mouseFocusMask = MouseButtonMask.None;
26165
+ return;
26166
+ }
26167
+ if (current.getEffectiveMouseFilter() === MouseFilter.Stop) {
26168
+ return;
26169
+ }
26170
+ current = current.parent;
26171
+ }
26172
+ };
26173
+ _proto.finishDrop = function finishDrop(position) {
26174
+ var target = this.findDropTarget(this.findInputControl(position), position);
26175
+ if (target) {
26176
+ target.invokeDropData(this.toLocal(target, position), this.gui.dragData);
26177
+ }
26178
+ this.endDragging(!!target);
26179
+ };
26180
+ _proto.findDropTarget = function findDropTarget(target, position) {
26181
+ var current = target;
26182
+ while(current && current !== this){
26183
+ if (current.invokeCanDropData(this.toLocal(current, position), this.gui.dragData)) {
26184
+ return current;
26185
+ }
26186
+ if (current.getEffectiveMouseFilter() === MouseFilter.Stop) {
26187
+ return null;
26188
+ }
26189
+ current = current.parent;
26190
+ }
26191
+ return null;
26192
+ };
26193
+ _proto.endDragging = function endDragging(successful) {
26194
+ this.gui.dragSuccessful = successful;
26195
+ this.gui.dragging = false;
26196
+ this.gui.dragData = null;
26197
+ this.gui.dragMouseOver = null;
26198
+ };
26199
+ _proto.updateCursor = function updateCursor(target, position) {
26200
+ var current = target;
26201
+ var shape = CursorShape.Arrow;
26202
+ while(current && current !== this){
26203
+ var candidate = current.getCursorShape(this.toLocal(current, position));
26204
+ if (candidate !== CursorShape.Arrow) {
26205
+ shape = candidate;
26206
+ break;
26207
+ }
26208
+ if (current.getEffectiveMouseFilter() === MouseFilter.Stop) {
26209
+ break;
26210
+ }
26211
+ current = current.parent;
26212
+ }
26213
+ this.engine.canvas.style.cursor = cursorNames[shape];
26214
+ };
26215
+ _proto.postGrabClickFocus = function postGrabClickFocus() {
26216
+ var target = this.gui.mouseClickGrabber;
26217
+ this.gui.mouseClickGrabber = null;
26218
+ if (this.isControlUsable(target)) {
26219
+ this.gui.mouseFocus = target;
26220
+ }
26221
+ };
26222
+ _proto.cleanupInternalState = function cleanupInternalState() {
26223
+ if (!this.isControlUsable(this.gui.mouseFocus)) {
26224
+ this.dropMouseFocus();
26225
+ }
26226
+ if (this.gui.keyFocus && !this.isFocusTargetUsable(this.gui.keyFocus)) {
26227
+ this.releaseControlFocus(this.gui.keyFocus);
26228
+ }
26229
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.gui.touchFocus), _step; !(_step = _iterator()).done;){
26230
+ var _step_value = _step.value, index = _step_value[0], control = _step_value[1];
26231
+ if (!this.isControlUsable(control)) {
26232
+ this.gui.touchFocus.delete(index);
26233
+ }
26234
+ }
26235
+ };
26236
+ _proto.dropMouseFocus = function dropMouseFocus() {
26237
+ this.gui.mouseFocus = null;
26238
+ this.gui.mouseFocusMask = MouseButtonMask.None;
26239
+ };
26240
+ _proto.dropMouseOver = function dropMouseOver() {
26241
+ for(var index = this.gui.mouseOverHierarchy.length - 1; index >= 0; index--){
26242
+ var control = this.gui.mouseOverHierarchy[index];
26243
+ if (!control.isDisposed) {
26244
+ control.onMouseLeave();
26245
+ }
26246
+ }
26247
+ this.gui.mouseOver = null;
26248
+ this.gui.mouseOverHierarchy = [];
26249
+ };
26250
+ _proto.dropControlState = function dropControlState(control) {
26251
+ if (this.controlBelongsToSubtree(this.gui.mouseFocus, control)) {
26252
+ this.dropMouseFocus();
26253
+ }
26254
+ if (this.controlBelongsToSubtree(this.gui.mouseClickGrabber, control)) {
26255
+ this.gui.mouseClickGrabber = null;
26256
+ }
26257
+ if (this.controlBelongsToSubtree(this.gui.keyFocus, control)) {
26258
+ var _this_gui_keyFocus;
26259
+ this.releaseControlFocus((_this_gui_keyFocus = this.gui.keyFocus) != null ? _this_gui_keyFocus : undefined);
26260
+ }
26261
+ if (this.controlBelongsToSubtree(this.gui.mouseOver, control)) {
26262
+ this.dropMouseOver();
26263
+ }
26264
+ if (this.controlBelongsToSubtree(this.gui.dragMouseOver, control)) {
26265
+ this.gui.dragMouseOver = null;
26266
+ }
26267
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.gui.touchFocus), _step; !(_step = _iterator()).done;){
26268
+ var _step_value = _step.value, index = _step_value[0], target = _step_value[1];
26269
+ if (this.controlBelongsToSubtree(target, control)) {
26270
+ this.gui.touchFocus.delete(index);
26271
+ }
26272
+ }
26273
+ };
26274
+ _proto.requestMouseOverUpdate = function requestMouseOverUpdate() {
26275
+ if (Number.isFinite(this.gui.lastMousePosition.x)) {
26276
+ this.updateMouseOver(this.gui.lastMousePosition);
26277
+ }
26278
+ };
26279
+ _proto.getGlobalInverse = function getGlobalInverse(control) {
26280
+ var transform = control.getGlobalTransform2D().clone();
26281
+ return Math.abs(transform.determinant()) < 1e-12 ? new Matrix3() : transform.invert();
26282
+ };
26283
+ _proto.toLocal = function toLocal(control, position) {
26284
+ var elements = this.getGlobalInverse(control).elements;
26285
+ return new Vector2(elements[0] * position.x + elements[3] * position.y + elements[6], elements[1] * position.x + elements[4] * position.y + elements[7]);
26286
+ };
26287
+ _proto.controlBelongsToSubtree = function controlBelongsToSubtree(control, subtree) {
26288
+ var current = control;
26289
+ while(current){
26290
+ if (current === subtree) {
26291
+ return true;
26292
+ }
26293
+ current = current.parent;
26294
+ }
26295
+ return false;
26296
+ };
26297
+ _proto.isControlValid = function isControlValid(control) {
26298
+ return !!control && !control.isDisposed && control.root === this;
26299
+ };
26300
+ _proto.isControlUsable = function isControlUsable(control) {
26301
+ if (!this.isControlValid(control) || !control.visibleInHierarchy || !control.enabledInHierarchy) {
26302
+ return false;
26303
+ }
26304
+ var root = this.findCanvasRoot(control);
26305
+ return !root || !root.inputDisabled;
26306
+ };
26307
+ _proto.findCanvasRoot = function findCanvasRoot(control) {
26308
+ var current = control;
26309
+ while(current && current !== this){
26310
+ if (_instanceof1(current, CanvasRootControl)) {
26311
+ return current;
26312
+ }
26313
+ current = current.parent;
26314
+ }
26315
+ return null;
26316
+ };
26317
+ _proto.isFocusTargetUsable = function isFocusTargetUsable(control) {
26318
+ return this.isControlUsable(control) && control.getFocusModeWithOverride() !== FocusMode.None;
26319
+ };
26320
+ return WindowRootControl;
26321
+ }(RootControl);
26322
+
26323
+ var CanvasRenderMode;
26324
+ (function(CanvasRenderMode) {
26325
+ CanvasRenderMode[CanvasRenderMode["ScreenSpace"] = 0] = "ScreenSpace";
26326
+ CanvasRenderMode[CanvasRenderMode["CameraSpace"] = 1] = "CameraSpace";
26327
+ CanvasRenderMode[CanvasRenderMode["WorldSpace"] = 2] = "WorldSpace";
26328
+ CanvasRenderMode[CanvasRenderMode["WorldSpaceFaceCamera"] = 3] = "WorldSpaceFaceCamera";
26329
+ })(CanvasRenderMode || (CanvasRenderMode = {}));
26330
+ /** Canvas-layer boundary attached to a VFXItem. Input state remains owned by the window root. */ var UICanvas = /*#__PURE__*/ function(Component) {
26331
+ _inherits(UICanvas, Component);
26332
+ function UICanvas(engine) {
26333
+ var _this;
26334
+ _this = Component.call(this, engine) || this;
26335
+ _this.renderMode = 0;
26336
+ _this.receivesEvents = true;
26337
+ _this._order = 0;
26338
+ _this.registered = false;
26339
+ _this.rootControl = new CanvasRootControl(engine, _assert_this_initialized(_this));
26340
+ return _this;
26341
+ }
26342
+ var _proto = UICanvas.prototype;
26343
+ _proto.onEnable = function onEnable() {
26344
+ this.register();
26345
+ };
26346
+ _proto.onDisable = function onDisable() {
26347
+ this.unregister();
26348
+ };
26349
+ _proto.onDestroy = function onDestroy() {
26350
+ this.destroyCanvas();
26351
+ };
26352
+ _proto.dispose = function dispose() {
26353
+ this.destroyCanvas();
26354
+ Component.prototype.dispose.call(this);
26355
+ };
26356
+ _proto.register = function register() {
26357
+ if (!this.registered) {
26358
+ this.rootControl.parent = this.engine.windowRoot.canvases;
26359
+ this.registered = true;
26360
+ }
26361
+ };
26362
+ _proto.unregister = function unregister() {
26363
+ if (this.registered) {
26364
+ this.rootControl.parent = null;
26365
+ this.registered = false;
26366
+ }
26367
+ };
26368
+ _proto.destroyCanvas = function destroyCanvas() {
26369
+ this.unregister();
26370
+ if (!this.rootControl.isDisposed) {
26371
+ this.rootControl.dispose();
26372
+ }
26373
+ };
26374
+ _create_class(UICanvas, [
26375
+ {
26376
+ key: "order",
26377
+ get: function get() {
26378
+ return this._order;
26379
+ },
26380
+ set: function set(value) {
26381
+ if (this._order !== value) {
26382
+ this._order = value;
26383
+ this.engine.windowRoot.canvases.sortCanvases();
26384
+ }
26385
+ }
26386
+ },
26387
+ {
26388
+ key: "isVisible",
26389
+ get: function get() {
26390
+ var _this_item;
26391
+ return this.renderMode === 0 && this.enabled && !!((_this_item = this.item) == null ? void 0 : _this_item.isActive);
26392
+ }
26393
+ }
26394
+ ]);
26395
+ return UICanvas;
26396
+ }(Component);
25291
26397
 
25292
26398
  /**
25293
- * 锚点布局组件
25294
- *
25295
- * `Control extends CanvasItem`。CanvasItem 仅承担绘制与节点层级,Control 在挂到 VFXItem 时把
25296
- * `item.transform` 升级为 {@link RectTransform}。
25297
- *
25298
- * 布局完全由 RectTransform 自治:父子节点关系沿 `Transform.parentTransform / children` 走,
25299
- * 父节点 size 变化时通过 `RectTransform.sizeChanged()` 直接调用子节点 sizeChanged 链式传播。
25300
- * Control 本身不持有任何与布局相关的状态
25301
- */ var Control = /*#__PURE__*/ function(CanvasItem) {
25302
- _inherits(Control, CanvasItem);
25303
- function Control() {
25304
- return CanvasItem.apply(this, arguments);
26399
+ * Scene-tree bridge for a GUI Control. The VFXItem tree owns lifecycle and
26400
+ * serialization while the Control tree owns layout, drawing and input.
26401
+ */ var UIControl = /*#__PURE__*/ function(Component) {
26402
+ _inherits(UIControl, Component);
26403
+ function UIControl(engine) {
26404
+ var _this;
26405
+ _this = Component.call(this, engine) || this;
26406
+ _this.controlNode = null;
26407
+ _this.linkedItemTransform = null;
26408
+ _this.linkedControl = null;
26409
+ _this.syncingLocation = false;
26410
+ _this.itemTransformChanged = function() {
26411
+ return _this.syncItemLocationToControl();
26412
+ };
26413
+ _this.controlLocationChanged = function() {
26414
+ return _this.syncControlLocationToItem();
26415
+ };
26416
+ return _this;
25305
26417
  }
25306
- var _proto = Control.prototype;
25307
- /**
25308
- * 在挂到 VFXItem 时确保 `item.transform` 是 `RectTransform`。
25309
- * 既有 Transform 状态(position / rotation / scale / size / anchor 等)通过 `RectTransform.fromTransform` 复制
25310
- */ _proto.onAwake = function onAwake() {
25311
- var item = this.item;
25312
- if (!_instanceof1(item.transform, RectTransform)) {
25313
- item.transform = RectTransform.fromTransform(item.transform);
26418
+ var _proto = UIControl.prototype;
26419
+ _proto.onAwake = function onAwake() {
26420
+ this.syncControl();
26421
+ };
26422
+ _proto.onEnable = function onEnable() {
26423
+ if (this.controlNode) {
26424
+ this.controlNode.visible = this.item.isActive;
26425
+ this.controlNode.enabled = true;
25314
26426
  }
25315
26427
  };
25316
- return Control;
25317
- }(CanvasItem);
26428
+ _proto.onDisable = function onDisable() {
26429
+ if (this.controlNode) {
26430
+ this.controlNode.visible = this.item.isActive;
26431
+ this.controlNode.enabled = false;
26432
+ }
26433
+ };
26434
+ _proto.onParentChanged = function onParentChanged() {
26435
+ this.syncControl();
26436
+ };
26437
+ _proto.onOrderInParentChanged = function onOrderInParentChanged() {
26438
+ this.syncControlOrder();
26439
+ };
26440
+ _proto.onDestroy = function onDestroy() {
26441
+ this.disposeControl();
26442
+ };
26443
+ _proto.dispose = function dispose() {
26444
+ this.disposeControl();
26445
+ Component.prototype.dispose.call(this);
26446
+ };
26447
+ /** Unlinks the GUI object without disposing or modifying it. */ _proto.unlinkControl = function unlinkControl() {
26448
+ if (this.controlNode) {
26449
+ this.unbindLocationSync();
26450
+ this.controlNode = null;
26451
+ }
26452
+ };
26453
+ _proto.disposeControl = function disposeControl() {
26454
+ var control = this.controlNode;
26455
+ if (control) {
26456
+ this.unbindLocationSync();
26457
+ this.controlNode = null;
26458
+ control.dispose();
26459
+ }
26460
+ };
26461
+ _proto.syncControl = function syncControl() {
26462
+ var control = this.controlNode;
26463
+ if (!control || !this.item) {
26464
+ return;
26465
+ }
26466
+ this.syncingLocation = true;
26467
+ try {
26468
+ control.visible = this.item.isActive;
26469
+ control.enabled = this.enabled;
26470
+ control.parent = this.resolveParent();
26471
+ this.syncControlOrder();
26472
+ this.copyItemLocationToControl();
26473
+ } finally{
26474
+ this.syncingLocation = false;
26475
+ }
26476
+ this.bindLocationSync();
26477
+ };
26478
+ _proto.syncControlOrder = function syncControlOrder() {
26479
+ if (this.controlNode && this.item) {
26480
+ this.controlNode.indexInParent = this.item.orderInParent;
26481
+ }
26482
+ };
26483
+ _proto.resolveParent = function resolveParent() {
26484
+ var parentItem = this.item.parent;
26485
+ if (!parentItem) {
26486
+ var _UIControl_fallbackParentGetDelegate;
26487
+ return (_UIControl_fallbackParentGetDelegate = UIControl.fallbackParentGetDelegate == null ? void 0 : UIControl.fallbackParentGetDelegate.call(UIControl, this)) != null ? _UIControl_fallbackParentGetDelegate : null;
26488
+ }
26489
+ var uiControl = parentItem.getComponent(UIControl);
26490
+ if ((uiControl == null ? void 0 : uiControl.control) && "children" in uiControl.control) {
26491
+ return uiControl.control;
26492
+ }
26493
+ var canvas = parentItem.getComponent(UICanvas);
26494
+ var _canvas_rootControl, _ref;
26495
+ 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;
26496
+ };
26497
+ _proto.bindLocationSync = function bindLocationSync() {
26498
+ var itemTransform = this.item.transform;
26499
+ var control = this.controlNode;
26500
+ if (this.linkedItemTransform === itemTransform && this.linkedControl === control) {
26501
+ return;
26502
+ }
26503
+ this.unbindLocationSync();
26504
+ if (control) {
26505
+ this.linkedItemTransform = itemTransform;
26506
+ this.linkedControl = control;
26507
+ itemTransform.on("changed", this.itemTransformChanged);
26508
+ control.on("locationChanged", this.controlLocationChanged);
26509
+ }
26510
+ };
26511
+ _proto.unbindLocationSync = function unbindLocationSync() {
26512
+ var _this_linkedItemTransform, _this_linkedControl;
26513
+ (_this_linkedItemTransform = this.linkedItemTransform) == null ? void 0 : _this_linkedItemTransform.off("changed", this.itemTransformChanged);
26514
+ (_this_linkedControl = this.linkedControl) == null ? void 0 : _this_linkedControl.off("locationChanged", this.controlLocationChanged);
26515
+ this.linkedItemTransform = null;
26516
+ this.linkedControl = null;
26517
+ };
26518
+ _proto.syncItemLocationToControl = function syncItemLocationToControl() {
26519
+ if (!this.syncingLocation && this.controlNode) {
26520
+ this.syncingLocation = true;
26521
+ try {
26522
+ this.copyItemLocationToControl();
26523
+ } finally{
26524
+ this.syncingLocation = false;
26525
+ }
26526
+ }
26527
+ };
26528
+ _proto.syncControlLocationToItem = function syncControlLocationToItem() {
26529
+ var control = this.controlNode;
26530
+ if (!this.syncingLocation && control) {
26531
+ var source = control.location;
26532
+ var target = this.item.transform.position;
26533
+ if (source.x !== target.x || source.y !== target.y) {
26534
+ this.syncingLocation = true;
26535
+ try {
26536
+ this.item.transform.setPosition(source.x, source.y, target.z);
26537
+ } finally{
26538
+ this.syncingLocation = false;
26539
+ }
26540
+ }
26541
+ }
26542
+ };
26543
+ _proto.copyItemLocationToControl = function copyItemLocationToControl() {
26544
+ var control = this.controlNode;
26545
+ if (control) {
26546
+ var source = this.item.transform.position;
26547
+ var target = control.location;
26548
+ if (source.x !== target.x || source.y !== target.y) {
26549
+ control.setPosition(source.x, source.y);
26550
+ }
26551
+ }
26552
+ };
26553
+ _create_class(UIControl, [
26554
+ {
26555
+ key: "control",
26556
+ get: function get() {
26557
+ return this.controlNode;
26558
+ },
26559
+ set: function set(value) {
26560
+ if (value === this.controlNode) {
26561
+ return;
26562
+ }
26563
+ this.disposeControl();
26564
+ if (value) {
26565
+ if (value.owner && value.owner !== this && value.owner.control === value) {
26566
+ throw new Error("A Control can only be owned by one UIControl.");
26567
+ }
26568
+ this.controlNode = value;
26569
+ value.owner = this;
26570
+ this.syncControl();
26571
+ }
26572
+ }
26573
+ },
26574
+ {
26575
+ key: "hasControl",
26576
+ get: function get() {
26577
+ return this.controlNode !== null;
26578
+ }
26579
+ }
26580
+ ]);
26581
+ return UIControl;
26582
+ }(Component);
25318
26583
 
25319
26584
  var CameraController = /*#__PURE__*/ function(Component) {
25320
26585
  _inherits(CameraController, Component);
@@ -25350,42 +26615,6 @@ CameraController = __decorate([
25350
26615
  effectsClass(DataType.CameraController)
25351
26616
  ], CameraController);
25352
26617
 
25353
- function _get_prototype_of(o) {
25354
- _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
25355
- return o.__proto__ || Object.getPrototypeOf(o);
25356
- };
25357
- return _get_prototype_of(o);
25358
- }
25359
-
25360
- function _is_native_function(fn) {
25361
- return Function.toString.call(fn).indexOf("[native code]") !== -1;
25362
- }
25363
-
25364
- function _wrap_native_super(Class) {
25365
- var _cache = typeof Map === "function" ? new Map() : undefined;
25366
- _wrap_native_super = function _wrap_native_super(Class) {
25367
- if (Class === null || !_is_native_function(Class)) return Class;
25368
- if (typeof Class !== "function") throw new TypeError("Super expression must either be null or a function");
25369
- if (typeof _cache !== "undefined") {
25370
- if (_cache.has(Class)) return _cache.get(Class);
25371
- _cache.set(Class, Wrapper);
25372
- }
25373
- function Wrapper() {
25374
- return _construct(Class, arguments, _get_prototype_of(this).constructor);
25375
- }
25376
- Wrapper.prototype = Object.create(Class.prototype, {
25377
- constructor: {
25378
- value: Wrapper,
25379
- enumerable: false,
25380
- writable: true,
25381
- configurable: true
25382
- }
25383
- });
25384
- return _set_prototype_of(Wrapper, Class);
25385
- };
25386
- return _wrap_native_super(Class);
25387
- }
25388
-
25389
26618
  var CameraVFXItemLoader = /*#__PURE__*/ function(Plugin) {
25390
26619
  _inherits(CameraVFXItemLoader, Plugin);
25391
26620
  function CameraVFXItemLoader() {
@@ -25406,142 +26635,202 @@ var PointerEventType;
25406
26635
  })(PointerEventType || (PointerEventType = {}));
25407
26636
  var EventSystem = /*#__PURE__*/ function() {
25408
26637
  function EventSystem(engine, allowPropagation) {
26638
+ var _this = this;
25409
26639
  if (allowPropagation === void 0) allowPropagation = false;
25410
26640
  this.engine = engine;
25411
26641
  this.allowPropagation = allowPropagation;
25412
- this.enabled = true;
25413
26642
  this.skipPointerMovePicking = true;
26643
+ this.emulateMouseFromTouch = true;
26644
+ this.emulateTouchFromMouse = false;
26645
+ this._enabled = true;
25414
26646
  this.handlers = {};
25415
- this.nativeHandlers = {};
26647
+ this.nativeHandlers = [];
25416
26648
  this.target = null;
25417
- }
25418
- var _proto = EventSystem.prototype;
25419
- _proto.bindListeners = function bindListeners(target) {
25420
- var _this = this;
25421
- this.target = target;
25422
- var x;
25423
- var y;
25424
- var currentTouch;
25425
- var lastTouch;
25426
- var getTouch;
25427
- getTouch = function(event) {
25428
- return event;
26649
+ this.mouseState = null;
26650
+ this.touchStates = new Map();
26651
+ this.mouseFromTouchIndex = null;
26652
+ this.touchFromMousePressed = false;
26653
+ this.addedTabIndex = false;
26654
+ this.addedOutlineStyle = false;
26655
+ this.onNativeWheel = function(event) {
26656
+ if (!_this.enabled || !_this.target) {
26657
+ return;
26658
+ }
26659
+ var position = _this.getCanvasPosition(event.clientX, event.clientY);
26660
+ var handled = false;
26661
+ if (event.deltaY !== 0) {
26662
+ handled = _this.pushWheelButton(event.deltaY < 0 ? MouseButton.WheelUp : MouseButton.WheelDown, Math.abs(event.deltaY), position, event) || handled;
26663
+ }
26664
+ if (event.deltaX !== 0) {
26665
+ handled = _this.pushWheelButton(event.deltaX < 0 ? MouseButton.WheelLeft : MouseButton.WheelRight, Math.abs(event.deltaX), position, event) || handled;
26666
+ }
26667
+ _this.consumeNativeEvent(event, handled);
25429
26668
  };
25430
- var touchstart = "mousedown";
25431
- var touchmove = "mousemove";
25432
- var touchend = "mouseup";
25433
- var touchcancel = "mouseleave";
25434
- var getTouchEventValue = function(event, x, y, dx, dy) {
25435
- if (dx === void 0) dx = 0;
25436
- if (dy === void 0) dy = 0;
25437
- var vx = 0;
25438
- var vy = 0;
25439
- var ts = performance.now();
25440
- if (!_this.target) {
25441
- logger.warn("Trigger TouchEvent after EventSystem is disposed.");
25442
- return {
25443
- x: x,
25444
- y: y,
25445
- vx: 0,
25446
- vy: vy,
25447
- dx: dx,
25448
- dy: dy,
25449
- ts: ts,
25450
- width: 0,
25451
- height: 0,
25452
- origin: event
25453
- };
26669
+ this.onNativeKeyDown = function(event) {
26670
+ _this.handleNativeKey(event, true);
26671
+ };
26672
+ this.onNativeKeyUp = function(event) {
26673
+ _this.handleNativeKey(event, false);
26674
+ };
26675
+ this.onNativeMouseDown = function(event) {
26676
+ _this.handleNativeMouseDown(event);
26677
+ };
26678
+ this.onNativeMouseMove = function(event) {
26679
+ var _state;
26680
+ if (!_this.enabled || !_this.target) {
26681
+ return;
25454
26682
  }
25455
- var _this_target = _this.target, width = _this_target.width, height = _this_target.height;
25456
- if (lastTouch) {
25457
- var dt = ts - lastTouch.ts;
25458
- vx = (dx - lastTouch.dx) / dt || 0;
25459
- vy = (dy - lastTouch.dy) / dt || 0;
25460
- lastTouch = {
25461
- dx: dx,
25462
- dy: dy,
25463
- ts: ts
25464
- };
26683
+ var position = _this.getCanvasPosition(event.clientX, event.clientY);
26684
+ var _this_mouseState;
26685
+ var state = (_this_mouseState = _this.mouseState) != null ? _this_mouseState : _this.createPointerState(position);
26686
+ _this.mouseState = state;
26687
+ var relative = new Vector2(position.x - state.last.x, position.y - state.last.y);
26688
+ var velocity = _this.getVelocity(state, position);
26689
+ var handled = _this.pushNativeMouseMotion(event, position, relative, velocity);
26690
+ (_state = state).controlHandled || (_state.controlHandled = handled);
26691
+ if (!handled && (!state.pressed || !state.controlHandled)) {
26692
+ var pointerEvent = _this.createPointerEvent(event, position, state, velocity);
26693
+ _this.dispatchEvent(EVENT_TYPE_TOUCH_MOVE, pointerEvent);
26694
+ }
26695
+ _this.updatePointerState(state, position);
26696
+ _this.consumeNativeEvent(event, handled);
26697
+ };
26698
+ this.onNativeMouseUp = function(event) {
26699
+ if (!_this.enabled || !_this.target) {
26700
+ return;
25465
26701
  }
25466
- return {
25467
- x: x,
25468
- y: y,
25469
- vx: vx,
25470
- vy: vy,
25471
- dx: dx,
25472
- dy: dy,
25473
- ts: ts,
25474
- width: width,
25475
- height: height,
25476
- origin: event
25477
- };
26702
+ var position = _this.getCanvasPosition(event.clientX, event.clientY);
26703
+ var existingState = _this.mouseState;
26704
+ if (!(existingState == null ? void 0 : existingState.pressed)) {
26705
+ return;
26706
+ }
26707
+ var state = existingState;
26708
+ var handled = _this.pushNativeMouseButton(event, position, false);
26709
+ var pointerEvent = _this.createPointerEvent(event, position, state);
26710
+ if (!state.controlHandled && !handled && _this.isClick(state, position)) {
26711
+ _this.dispatchEvent(EVENT_TYPE_CLICK, pointerEvent);
26712
+ }
26713
+ if (!handled && !state.controlHandled) {
26714
+ _this.dispatchEvent(EVENT_TYPE_TOUCH_END, pointerEvent);
26715
+ }
26716
+ _this.mouseState = null;
26717
+ _this.consumeNativeEvent(event, handled || state.controlHandled || !_this.allowPropagation);
25478
26718
  };
25479
- if (isSimulatorCellPhone()) {
25480
- getTouch = function(event) {
25481
- var touches = event.touches, changedTouches = event.changedTouches;
25482
- return touches[0] || changedTouches[0];
25483
- };
25484
- touchstart = "touchstart";
25485
- touchmove = "touchmove";
25486
- touchend = "touchend";
25487
- touchcancel = "touchcancel";
25488
- }
25489
- var _obj;
25490
- this.nativeHandlers = (_obj = {}, _obj[touchstart] = function(event) {
25491
- if (_this.enabled) {
25492
- var touch = getTouch(event);
25493
- var cood = getCoord(touch);
25494
- x = cood.x;
25495
- y = cood.y;
25496
- lastTouch = currentTouch = {
25497
- clientX: touch.clientX,
25498
- clientY: touch.clientY,
25499
- ts: performance.now(),
25500
- x: x,
25501
- y: y
25502
- };
25503
- _this.dispatchEvent(EVENT_TYPE_TOUCH_START, getTouchEventValue(event, x, y));
25504
- }
25505
- }, _obj[touchmove] = function(event) {
25506
- if (currentTouch && _this.enabled) {
25507
- var cood = getCoord(getTouch(event));
25508
- x = cood.x;
25509
- y = cood.y;
25510
- _this.dispatchEvent(EVENT_TYPE_TOUCH_MOVE, getTouchEventValue(event, x, y, x - currentTouch.x, y - currentTouch.y));
25511
- }
25512
- }, _obj[touchend] = function(event) {
25513
- if (currentTouch && _this.enabled) {
25514
- if (!_this.allowPropagation && event.cancelable) {
25515
- event.preventDefault();
25516
- event.stopPropagation();
26719
+ this.onNativeTouchStart = function(event) {
26720
+ if (!_this.enabled) {
26721
+ return;
26722
+ }
26723
+ _this.focusTarget();
26724
+ for(var _iterator = _create_for_of_iterator_helper_loose(Array.from(event.changedTouches)), _step; !(_step = _iterator()).done;){
26725
+ var touch = _step.value;
26726
+ var position = _this.getCanvasPosition(touch.clientX, touch.clientY);
26727
+ var state = _this.createPointerState(position);
26728
+ _this.touchStates.set(touch.identifier, state);
26729
+ state.pressed = true;
26730
+ var handled = _this.pushNativeScreenTouch(touch.identifier, position, true, false, false);
26731
+ state.controlHandled = handled;
26732
+ if (!handled) {
26733
+ var pointerEvent = _this.createPointerEvent(event, position, state);
26734
+ _this.dispatchEvent(EVENT_TYPE_TOUCH_START, pointerEvent);
25517
26735
  }
25518
- var touch = getTouch(event);
25519
- var cood = getCoord(touch);
25520
- var dt = Math.abs(currentTouch.clientX - touch.clientX) + Math.abs(currentTouch.clientY - touch.clientY);
25521
- x = cood.x;
25522
- y = cood.y;
25523
- if (dt < 4) {
25524
- _this.dispatchEvent(EVENT_TYPE_CLICK, getTouchEventValue(event, x, y));
26736
+ _this.consumeNativeEvent(event, handled);
26737
+ }
26738
+ _this.preventTouchDefaults(event);
26739
+ };
26740
+ this.onNativeTouchMove = function(event) {
26741
+ if (!_this.enabled) {
26742
+ return;
26743
+ }
26744
+ for(var _iterator = _create_for_of_iterator_helper_loose(Array.from(event.changedTouches)), _step; !(_step = _iterator()).done;){
26745
+ var touch = _step.value;
26746
+ var _state;
26747
+ var position = _this.getCanvasPosition(touch.clientX, touch.clientY);
26748
+ var _this_touchStates_get;
26749
+ var state = (_this_touchStates_get = _this.touchStates.get(touch.identifier)) != null ? _this_touchStates_get : _this.createPointerState(position);
26750
+ _this.touchStates.set(touch.identifier, state);
26751
+ var relative = new Vector2(position.x - state.last.x, position.y - state.last.y);
26752
+ var velocity = _this.getVelocity(state, position);
26753
+ var handled = _this.pushNativeScreenDrag(touch.identifier, position, relative, velocity);
26754
+ (_state = state).controlHandled || (_state.controlHandled = handled);
26755
+ if (!handled && !state.controlHandled) {
26756
+ var pointerEvent = _this.createPointerEvent(event, position, state, velocity);
26757
+ _this.dispatchEvent(EVENT_TYPE_TOUCH_MOVE, pointerEvent);
25525
26758
  }
25526
- _this.dispatchEvent(EVENT_TYPE_TOUCH_END, getTouchEventValue(event, x, y, x - currentTouch.x, y - currentTouch.y));
25527
- }
25528
- currentTouch = 0;
25529
- }, _obj);
25530
- this.nativeHandlers[touchcancel] = this.nativeHandlers[touchend];
25531
- Object.keys(this.nativeHandlers).forEach(function(name) {
25532
- var _this_target;
25533
- (_this_target = _this.target) == null ? void 0 : _this_target.addEventListener(String(name), _this.nativeHandlers[name]);
26759
+ _this.updatePointerState(state, position);
26760
+ _this.consumeNativeEvent(event, handled);
26761
+ }
26762
+ _this.preventTouchDefaults(event);
26763
+ };
26764
+ this.onNativeTouchEnd = function(event) {
26765
+ _this.handleNativeTouchEnd(event, false);
26766
+ };
26767
+ this.onNativeTouchCancel = function(event) {
26768
+ _this.handleNativeTouchEnd(event, true);
26769
+ };
26770
+ this.onWindowBlur = function() {
26771
+ if (_this.enabled) {
26772
+ _this.mouseState = null;
26773
+ _this.touchStates.clear();
26774
+ _this.mouseFromTouchIndex = null;
26775
+ _this.touchFromMousePressed = false;
26776
+ _this.engine.windowRoot.cancelPointerInput();
26777
+ }
26778
+ };
26779
+ }
26780
+ var _proto = EventSystem.prototype;
26781
+ _proto.bindListeners = function bindListeners(target) {
26782
+ this.unbindListeners();
26783
+ this.target = target;
26784
+ if (!target || typeof window === "undefined") {
26785
+ return;
26786
+ }
26787
+ if (!target.hasAttribute("tabindex")) {
26788
+ target.tabIndex = 0;
26789
+ this.addedTabIndex = true;
26790
+ }
26791
+ if (!target.style.outline) {
26792
+ target.style.outline = "none";
26793
+ this.addedOutlineStyle = true;
26794
+ }
26795
+ this.addNativeHandler(target, "mousedown", this.onNativeMouseDown);
26796
+ // The Window listener runs after the event reaches the host container, so keep a
26797
+ // target listener to preserve notifyTouch/allowPropagation for in-canvas releases.
26798
+ this.addNativeHandler(target, "mouseup", this.onNativeMouseUp);
26799
+ this.addNativeHandler(window, "mouseup", this.onNativeMouseUp);
26800
+ this.addNativeHandler(window, "pointermove", this.onNativeMouseMove);
26801
+ this.addNativeHandler(target, "touchstart", this.onNativeTouchStart, {
26802
+ passive: false
25534
26803
  });
25535
- this.addEventListener(EVENT_TYPE_CLICK, this.onClick.bind(this));
25536
- this.addEventListener(EVENT_TYPE_TOUCH_START, this.onPointerDown.bind(this));
25537
- this.addEventListener(EVENT_TYPE_TOUCH_END, this.onPointerUp.bind(this));
25538
- this.addEventListener(EVENT_TYPE_TOUCH_MOVE, this.onPointerMove.bind(this));
26804
+ this.addNativeHandler(target, "touchmove", this.onNativeTouchMove, {
26805
+ passive: false
26806
+ });
26807
+ this.addNativeHandler(target, "touchend", this.onNativeTouchEnd, {
26808
+ passive: false
26809
+ });
26810
+ this.addNativeHandler(target, "touchcancel", this.onNativeTouchCancel, {
26811
+ passive: false
26812
+ });
26813
+ this.addNativeHandler(target, "wheel", this.onNativeWheel, {
26814
+ passive: false
26815
+ });
26816
+ this.addNativeHandler(target, "keydown", this.onNativeKeyDown);
26817
+ this.addNativeHandler(target, "keyup", this.onNativeKeyUp);
26818
+ this.addNativeHandler(window, "blur", this.onWindowBlur);
25539
26819
  };
25540
26820
  _proto.dispatchEvent = function dispatchEvent(type, event) {
25541
26821
  var handlers = this.handlers[type];
25542
- handlers == null ? void 0 : handlers.forEach(function(fn) {
26822
+ handlers == null ? void 0 : handlers.slice().forEach(function(fn) {
25543
26823
  return fn(event);
25544
26824
  });
26825
+ if (type === EVENT_TYPE_CLICK) {
26826
+ this.onClick(event);
26827
+ } else if (type === EVENT_TYPE_TOUCH_START) {
26828
+ this.onPointerDown(event);
26829
+ } else if (type === EVENT_TYPE_TOUCH_END) {
26830
+ this.onPointerUp(event);
26831
+ } else if (type === EVENT_TYPE_TOUCH_MOVE) {
26832
+ this.onPointerMove(event);
26833
+ }
25545
26834
  };
25546
26835
  _proto.addEventListener = function addEventListener(type, callback) {
25547
26836
  var handlers = this.handlers[type];
@@ -25559,14 +26848,229 @@ var EventSystem = /*#__PURE__*/ function() {
25559
26848
  removeItem(handlers, callback);
25560
26849
  }
25561
26850
  };
25562
- _proto.onClick = function onClick(e) {
25563
- var x = e.x, y = e.y;
26851
+ _proto.dispose = function dispose() {
26852
+ this.engine.windowRoot.cancelPointerInput();
26853
+ this.mouseState = null;
26854
+ this.touchStates.clear();
26855
+ this.mouseFromTouchIndex = null;
26856
+ this.touchFromMousePressed = false;
26857
+ this.handlers = {};
26858
+ this.unbindListeners();
26859
+ this.target = null;
26860
+ };
26861
+ _proto.handleNativeMouseDown = function handleNativeMouseDown(event) {
26862
+ if (!this.enabled || !this.target) {
26863
+ return;
26864
+ }
26865
+ this.focusTarget();
26866
+ var position = this.getCanvasPosition(event.clientX, event.clientY);
26867
+ var state = this.createPointerState(position);
26868
+ this.mouseState = state;
26869
+ state.pressed = true;
26870
+ var handled = this.pushNativeMouseButton(event, position, true);
26871
+ state.controlHandled = handled;
26872
+ if (!handled) {
26873
+ var pointerEvent = this.createPointerEvent(event, position, state);
26874
+ this.dispatchEvent(EVENT_TYPE_TOUCH_START, pointerEvent);
26875
+ }
26876
+ this.consumeNativeEvent(event, handled);
26877
+ };
26878
+ _proto.handleNativeKey = function handleNativeKey(event, pressed) {
26879
+ if (!this.enabled) {
26880
+ return;
26881
+ }
26882
+ var input = new InputEventKey();
26883
+ input.device = InputEvent.deviceIdKeyboard;
26884
+ input.pressed = pressed;
26885
+ input.echo = pressed && event.repeat;
26886
+ input.keycode = event.key;
26887
+ input.physicalKeycode = event.code;
26888
+ input.keyLabel = event.key;
26889
+ input.unicode = getUnicode(event.key);
26890
+ input.location = getKeyLocation(event.location);
26891
+ input.shiftPressed = event.shiftKey;
26892
+ input.altPressed = event.altKey;
26893
+ input.metaPressed = event.metaKey;
26894
+ input.ctrlPressed = event.ctrlKey;
26895
+ this.engine.windowRoot.pushInput(input);
26896
+ this.consumeNativeEvent(event, this.engine.windowRoot.isInputHandled());
26897
+ };
26898
+ _proto.handleNativeTouchEnd = function handleNativeTouchEnd(event, canceled) {
26899
+ if (!this.enabled) {
26900
+ return;
26901
+ }
26902
+ for(var _iterator = _create_for_of_iterator_helper_loose(Array.from(event.changedTouches)), _step; !(_step = _iterator()).done;){
26903
+ var touch = _step.value;
26904
+ var position = this.getCanvasPosition(touch.clientX, touch.clientY);
26905
+ var state = this.touchStates.get(touch.identifier);
26906
+ if (!(state == null ? void 0 : state.pressed)) {
26907
+ continue;
26908
+ }
26909
+ var handled = this.pushNativeScreenTouch(touch.identifier, position, false, canceled, false);
26910
+ var pointerEvent = this.createPointerEvent(event, position, state);
26911
+ if (!canceled && !state.controlHandled && !handled && this.isClick(state, position)) {
26912
+ this.dispatchEvent(EVENT_TYPE_CLICK, pointerEvent);
26913
+ }
26914
+ if (!handled && !canceled && !state.controlHandled) {
26915
+ this.dispatchEvent(EVENT_TYPE_TOUCH_END, pointerEvent);
26916
+ }
26917
+ this.touchStates.delete(touch.identifier);
26918
+ this.consumeNativeEvent(event, handled || state.controlHandled || !this.allowPropagation);
26919
+ }
26920
+ this.preventTouchDefaults(event);
26921
+ };
26922
+ _proto.pushNativeMouseButton = function pushNativeMouseButton(event, position, pressed) {
26923
+ var handled = false;
26924
+ var button = getMouseButton(event.button);
26925
+ if (pressed && this.emulateTouchFromMouse && button === MouseButton.Left) {
26926
+ this.touchFromMousePressed = true;
26927
+ }
26928
+ if (this.touchFromMousePressed && button === MouseButton.Left) {
26929
+ handled = this.pushScreenTouch(0, position, pressed, false, event.detail > 1, InputEvent.deviceIdEmulation);
26930
+ if (!pressed) {
26931
+ this.touchFromMousePressed = false;
26932
+ }
26933
+ }
26934
+ return this.pushMouseButton(event, position, pressed) || handled;
26935
+ };
26936
+ _proto.pushNativeMouseMotion = function pushNativeMouseMotion(event, position, relative, velocity) {
26937
+ var handled = false;
26938
+ if (this.touchFromMousePressed && (event.buttons & 1) !== 0) {
26939
+ handled = this.pushScreenDrag(0, position, relative, velocity, InputEvent.deviceIdEmulation);
26940
+ }
26941
+ return this.pushMouseMotion(event, position, relative, velocity) || handled;
26942
+ };
26943
+ _proto.pushNativeScreenTouch = function pushNativeScreenTouch(index, position, pressed, canceled, doubleTap) {
26944
+ var handled = false;
26945
+ var emulateMouse = false;
26946
+ if (pressed && this.emulateMouseFromTouch && this.mouseFromTouchIndex === null) {
26947
+ this.mouseFromTouchIndex = index;
26948
+ emulateMouse = true;
26949
+ } else if (!pressed && this.mouseFromTouchIndex === index) {
26950
+ emulateMouse = true;
26951
+ this.mouseFromTouchIndex = null;
26952
+ }
26953
+ if (emulateMouse) {
26954
+ handled = this.pushEmulatedMouseButton(position, pressed, canceled, doubleTap);
26955
+ }
26956
+ return this.pushScreenTouch(index, position, pressed, canceled, doubleTap, 0) || handled;
26957
+ };
26958
+ _proto.pushNativeScreenDrag = function pushNativeScreenDrag(index, position, relative, velocity) {
26959
+ var handled = false;
26960
+ if (this.emulateMouseFromTouch && this.mouseFromTouchIndex === index) {
26961
+ handled = this.pushEmulatedMouseMotion(position, relative, velocity);
26962
+ }
26963
+ return this.pushScreenDrag(index, position, relative, velocity, 0) || handled;
26964
+ };
26965
+ _proto.pushEmulatedMouseButton = function pushEmulatedMouseButton(position, pressed, canceled, doubleClick) {
26966
+ var input = new InputEventMouseButton();
26967
+ input.device = InputEvent.deviceIdEmulation;
26968
+ input.position.copyFrom(position);
26969
+ input.globalPosition.copyFrom(position);
26970
+ input.buttonIndex = MouseButton.Left;
26971
+ input.buttonMask = pressed ? MouseButtonMask.Left : MouseButtonMask.None;
26972
+ input.pressed = pressed;
26973
+ input.canceled = canceled;
26974
+ input.doubleClick = doubleClick;
26975
+ this.engine.windowRoot.pushInput(input);
26976
+ return this.engine.windowRoot.isInputHandled();
26977
+ };
26978
+ _proto.pushEmulatedMouseMotion = function pushEmulatedMouseMotion(position, relative, velocity) {
26979
+ var input = new InputEventMouseMotion();
26980
+ input.device = InputEvent.deviceIdEmulation;
26981
+ input.position.copyFrom(position);
26982
+ input.globalPosition.copyFrom(position);
26983
+ input.buttonMask = MouseButtonMask.Left;
26984
+ input.pressed = true;
26985
+ input.relative.copyFrom(relative);
26986
+ input.screenRelative.copyFrom(relative);
26987
+ input.velocity.copyFrom(velocity);
26988
+ input.screenVelocity.copyFrom(velocity);
26989
+ this.engine.windowRoot.pushInput(input);
26990
+ return this.engine.windowRoot.isInputHandled();
26991
+ };
26992
+ _proto.pushMouseButton = function pushMouseButton(event, position, pressed) {
26993
+ var input = new InputEventMouseButton();
26994
+ this.copyMouseFields(input, event, position);
26995
+ input.device = InputEvent.deviceIdMouse;
26996
+ input.buttonIndex = getMouseButton(event.button);
26997
+ input.buttonMask = getMouseButtonMask(event.buttons);
26998
+ if (pressed) {
26999
+ input.buttonMask |= getMouseButtonBit(input.buttonIndex);
27000
+ } else {
27001
+ input.buttonMask &= ~getMouseButtonBit(input.buttonIndex);
27002
+ }
27003
+ input.pressed = pressed;
27004
+ input.doubleClick = event.detail > 1;
27005
+ this.engine.windowRoot.pushInput(input);
27006
+ return this.engine.windowRoot.isInputHandled();
27007
+ };
27008
+ _proto.pushWheelButton = function pushWheelButton(button, factor, position, event) {
27009
+ var input = new InputEventMouseButton();
27010
+ this.copyMouseFields(input, event, position);
27011
+ input.device = InputEvent.deviceIdMouse;
27012
+ input.buttonIndex = button;
27013
+ input.buttonMask = getMouseButtonMask(event.buttons);
27014
+ input.factor = factor;
27015
+ input.pressed = true;
27016
+ this.engine.windowRoot.pushInput(input);
27017
+ return this.engine.windowRoot.isInputHandled();
27018
+ };
27019
+ _proto.pushMouseMotion = function pushMouseMotion(event, position, relative, velocity) {
27020
+ var input = new InputEventMouseMotion();
27021
+ this.copyMouseFields(input, event, position);
27022
+ input.device = InputEvent.deviceIdMouse;
27023
+ input.buttonMask = getMouseButtonMask(event.buttons);
27024
+ input.pressed = event.buttons !== 0;
27025
+ input.relative.copyFrom(relative);
27026
+ input.screenRelative.copyFrom(relative);
27027
+ input.velocity.copyFrom(velocity);
27028
+ input.screenVelocity.copyFrom(velocity);
27029
+ if ("pressure" in event) {
27030
+ input.pressure = event.pressure;
27031
+ input.tilt.set(event.tiltX, event.tiltY);
27032
+ }
27033
+ this.engine.windowRoot.pushInput(input);
27034
+ return this.engine.windowRoot.isInputHandled();
27035
+ };
27036
+ _proto.pushScreenTouch = function pushScreenTouch(index, position, pressed, canceled, doubleTap, device) {
27037
+ var input = new InputEventScreenTouch();
27038
+ input.index = index;
27039
+ input.device = device;
27040
+ input.position.copyFrom(position);
27041
+ input.pressed = pressed;
27042
+ input.canceled = canceled;
27043
+ input.doubleTap = doubleTap;
27044
+ this.engine.windowRoot.pushInput(input);
27045
+ return this.engine.windowRoot.isInputHandled();
27046
+ };
27047
+ _proto.pushScreenDrag = function pushScreenDrag(index, position, relative, velocity, device) {
27048
+ var input = new InputEventScreenDrag();
27049
+ input.index = index;
27050
+ input.device = device;
27051
+ input.position.copyFrom(position);
27052
+ input.relative.copyFrom(relative);
27053
+ input.screenRelative.copyFrom(relative);
27054
+ input.velocity.copyFrom(velocity);
27055
+ input.screenVelocity.copyFrom(velocity);
27056
+ input.pressed = true;
27057
+ this.engine.windowRoot.pushInput(input);
27058
+ return this.engine.windowRoot.isInputHandled();
27059
+ };
27060
+ _proto.copyMouseFields = function copyMouseFields(input, event, position) {
27061
+ input.position.copyFrom(position);
27062
+ input.globalPosition.copyFrom(position);
27063
+ input.shiftPressed = event.shiftKey;
27064
+ input.altPressed = event.altKey;
27065
+ input.metaPressed = event.metaKey;
27066
+ input.ctrlPressed = event.ctrlKey;
27067
+ };
27068
+ _proto.onClick = function onClick(event) {
25564
27069
  var hitResults = [];
25565
- // 收集所有的点击测试结果,click 回调执行可能会对 composition 点击结果有影响,放在点击测试执行完后再统一触发。
25566
27070
  for(var _iterator = _create_for_of_iterator_helper_loose(this.engine.compositions), _step; !(_step = _iterator()).done;){
25567
27071
  var composition = _step.value;
25568
27072
  var _hitResults;
25569
- (_hitResults = hitResults).push.apply(_hitResults, [].concat(composition.hitTest(x, y)));
27073
+ (_hitResults = hitResults).push.apply(_hitResults, [].concat(composition.hitTest(event.x, event.y)));
25570
27074
  }
25571
27075
  for(var _iterator1 = _create_for_of_iterator_helper_loose(hitResults), _step1; !(_step1 = _iterator1()).done;){
25572
27076
  var hitResult = _step1.value;
@@ -25583,49 +27087,36 @@ var EventSystem = /*#__PURE__*/ function() {
25583
27087
  this.engine.emit("click", clickInfo);
25584
27088
  }
25585
27089
  };
25586
- _proto.onPointerDown = function onPointerDown(e) {
25587
- this.handlePointerEvent(e, 0);
27090
+ _proto.onPointerDown = function onPointerDown(event) {
27091
+ this.handlePointerEvent(event, 0);
25588
27092
  };
25589
- _proto.onPointerUp = function onPointerUp(e) {
25590
- this.handlePointerEvent(e, 1);
27093
+ _proto.onPointerUp = function onPointerUp(event) {
27094
+ this.handlePointerEvent(event, 1);
25591
27095
  };
25592
- _proto.onPointerMove = function onPointerMove(e) {
25593
- this.handlePointerEvent(e, 2);
27096
+ _proto.onPointerMove = function onPointerMove(event) {
27097
+ this.handlePointerEvent(event, 2);
25594
27098
  };
25595
- _proto.handlePointerEvent = function handlePointerEvent(e, type) {
27099
+ _proto.handlePointerEvent = function handlePointerEvent(event, type) {
25596
27100
  var hitRegion = null;
25597
- var x = e.x, y = e.y, width = e.width, height = e.height;
25598
27101
  if (!(type === 2 && this.skipPointerMovePicking)) {
25599
27102
  for(var _iterator = _create_for_of_iterator_helper_loose(this.engine.compositions), _step; !(_step = _iterator()).done;){
25600
27103
  var composition = _step.value;
25601
- var regions = composition.hitTest(x, y);
27104
+ var regions = composition.hitTest(event.x, event.y);
25602
27105
  if (regions.length > 0) {
25603
27106
  hitRegion = regions[regions.length - 1];
25604
27107
  }
25605
27108
  }
25606
27109
  }
25607
27110
  var eventData = new PointerEventData();
25608
- eventData.position.x = (x + 1) / 2 * width;
25609
- eventData.position.y = (y + 1) / 2 * height;
25610
- eventData.delta.x = e.vx * width;
25611
- eventData.delta.y = e.vy * height;
25612
- var raycast = eventData.pointerCurrentRaycast;
27111
+ eventData.position.x = (event.x + 1) / 2 * event.width;
27112
+ eventData.position.y = (event.y + 1) / 2 * event.height;
27113
+ eventData.delta.x = event.vx * event.width;
27114
+ eventData.delta.y = event.vy * event.height;
25613
27115
  if (hitRegion) {
25614
- raycast.point = hitRegion.position;
25615
- raycast.item = hitRegion.item;
25616
- }
25617
- var eventName = "pointerdown";
25618
- switch(type){
25619
- case 0:
25620
- eventName = "pointerdown";
25621
- break;
25622
- case 1:
25623
- eventName = "pointerup";
25624
- break;
25625
- case 2:
25626
- eventName = "pointermove";
25627
- break;
27116
+ eventData.pointerCurrentRaycast.point = hitRegion.position;
27117
+ eventData.pointerCurrentRaycast.item = hitRegion.item;
25628
27118
  }
27119
+ var eventName = type === 0 ? "pointerdown" : type === 1 ? "pointerup" : "pointermove";
25629
27120
  if (hitRegion) {
25630
27121
  var hitItem = hitRegion.item;
25631
27122
  var hitComposition = hitItem.composition;
@@ -25634,29 +27125,184 @@ var EventSystem = /*#__PURE__*/ function() {
25634
27125
  this.engine.emit(eventName, eventData);
25635
27126
  }
25636
27127
  };
25637
- _proto.dispose = function dispose() {
25638
- var _this = this;
25639
- if (this.target) {
25640
- this.handlers = {};
25641
- Object.keys(this.nativeHandlers).forEach(function(name) {
25642
- var _this_target;
25643
- (_this_target = _this.target) == null ? void 0 : _this_target.removeEventListener(String(name), _this.nativeHandlers[name]);
25644
- });
25645
- this.nativeHandlers = {};
27128
+ _proto.createPointerState = function createPointerState(position) {
27129
+ var state = {
27130
+ start: position.clone(),
27131
+ last: position.clone(),
27132
+ lastTime: performance.now(),
27133
+ controlHandled: false,
27134
+ pressed: false
27135
+ };
27136
+ return state;
27137
+ };
27138
+ _proto.updatePointerState = function updatePointerState(state, position) {
27139
+ state.last.copyFrom(position);
27140
+ state.lastTime = performance.now();
27141
+ };
27142
+ _proto.getVelocity = function getVelocity(state, position) {
27143
+ var elapsed = Math.max(performance.now() - state.lastTime, 1);
27144
+ return new Vector2((position.x - state.last.x) / elapsed, (position.y - state.last.y) / elapsed);
27145
+ };
27146
+ _proto.isClick = function isClick(state, position) {
27147
+ return Math.abs(position.x - state.start.x) + Math.abs(position.y - state.start.y) < 4;
27148
+ };
27149
+ _proto.createPointerEvent = function createPointerEvent(origin, position, state, velocity) {
27150
+ if (velocity === void 0) velocity = new Vector2();
27151
+ var target = this.target;
27152
+ var rect = target == null ? void 0 : target.getBoundingClientRect();
27153
+ var cssWidth = (rect == null ? void 0 : rect.width) || 1;
27154
+ var cssHeight = (rect == null ? void 0 : rect.height) || 1;
27155
+ var _target_width, _target_height;
27156
+ return {
27157
+ x: position.x / cssWidth * 2 - 1,
27158
+ y: position.y / cssHeight * 2 - 1,
27159
+ vx: velocity.x / cssWidth * 2,
27160
+ vy: velocity.y / cssHeight * 2,
27161
+ ts: performance.now(),
27162
+ dx: (position.x - state.start.x) / cssWidth * 2,
27163
+ dy: (position.y - state.start.y) / cssHeight * 2,
27164
+ width: (_target_width = target == null ? void 0 : target.width) != null ? _target_width : 0,
27165
+ height: (_target_height = target == null ? void 0 : target.height) != null ? _target_height : 0,
27166
+ origin: origin
27167
+ };
27168
+ };
27169
+ _proto.getCanvasPosition = function getCanvasPosition(clientX, clientY) {
27170
+ var _this_target;
27171
+ var rect = (_this_target = this.target) == null ? void 0 : _this_target.getBoundingClientRect();
27172
+ if (!rect) {
27173
+ return new Vector2();
27174
+ }
27175
+ return new Vector2(clientX - rect.left, rect.bottom - clientY);
27176
+ };
27177
+ _proto.consumeNativeEvent = function consumeNativeEvent(event, handled) {
27178
+ if (handled && !this.allowPropagation) {
27179
+ if (event.cancelable) {
27180
+ event.preventDefault();
27181
+ }
27182
+ event.stopPropagation();
27183
+ }
27184
+ };
27185
+ _proto.preventTouchDefaults = function preventTouchDefaults(event) {
27186
+ if (event.cancelable) {
27187
+ event.preventDefault();
25646
27188
  }
25647
27189
  };
27190
+ _proto.focusTarget = function focusTarget() {
27191
+ if (this.target && document.activeElement !== this.target) {
27192
+ this.target.focus();
27193
+ }
27194
+ };
27195
+ _proto.addNativeHandler = function addNativeHandler(target, name, handler, options) {
27196
+ target.addEventListener(name, handler, options);
27197
+ this.nativeHandlers.push({
27198
+ target: target,
27199
+ name: name,
27200
+ handler: handler,
27201
+ options: options
27202
+ });
27203
+ };
27204
+ _proto.unbindListeners = function unbindListeners() {
27205
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.nativeHandlers), _step; !(_step = _iterator()).done;){
27206
+ var nativeHandler = _step.value;
27207
+ nativeHandler.target.removeEventListener(nativeHandler.name, nativeHandler.handler, nativeHandler.options);
27208
+ }
27209
+ this.nativeHandlers = [];
27210
+ if (this.addedTabIndex && this.target) {
27211
+ this.target.removeAttribute("tabindex");
27212
+ }
27213
+ if (this.addedOutlineStyle && this.target) {
27214
+ this.target.style.removeProperty("outline");
27215
+ }
27216
+ this.addedTabIndex = false;
27217
+ this.addedOutlineStyle = false;
27218
+ };
27219
+ _create_class(EventSystem, [
27220
+ {
27221
+ key: "enabled",
27222
+ get: function get() {
27223
+ return this._enabled;
27224
+ },
27225
+ set: function set(value) {
27226
+ if (this._enabled === value) {
27227
+ return;
27228
+ }
27229
+ this._enabled = value;
27230
+ if (!value) {
27231
+ this.mouseState = null;
27232
+ this.touchStates.clear();
27233
+ this.mouseFromTouchIndex = null;
27234
+ this.touchFromMousePressed = false;
27235
+ this.engine.windowRoot.cancelPointerInput();
27236
+ }
27237
+ }
27238
+ }
27239
+ ]);
25648
27240
  return EventSystem;
25649
27241
  }();
25650
- function getCoord(event) {
25651
- var ele = event.target;
25652
- var clientX = event.clientX, clientY = event.clientY;
25653
- var _ele_getBoundingClientRect = ele.getBoundingClientRect(), left = _ele_getBoundingClientRect.left, top = _ele_getBoundingClientRect.top, width = _ele_getBoundingClientRect.width, height = _ele_getBoundingClientRect.height;
25654
- var x = (clientX - left) / width * 2 - 1;
25655
- var y = 1 - (clientY - top) / height * 2;
25656
- return {
25657
- x: x,
25658
- y: y
25659
- };
27242
+ function getKeyLocation(location) {
27243
+ if (location === 1) {
27244
+ return KeyLocation.Left;
27245
+ }
27246
+ if (location === 2) {
27247
+ return KeyLocation.Right;
27248
+ }
27249
+ return KeyLocation.Unspecified;
27250
+ }
27251
+ function getUnicode(key) {
27252
+ var characters = Array.from(key);
27253
+ var _characters__codePointAt;
27254
+ return characters.length === 1 ? (_characters__codePointAt = characters[0].codePointAt(0)) != null ? _characters__codePointAt : 0 : 0;
27255
+ }
27256
+ function getMouseButton(button) {
27257
+ switch(button){
27258
+ case 0:
27259
+ return MouseButton.Left;
27260
+ case 1:
27261
+ return MouseButton.Middle;
27262
+ case 2:
27263
+ return MouseButton.Right;
27264
+ case 3:
27265
+ return MouseButton.Xbutton1;
27266
+ case 4:
27267
+ return MouseButton.Xbutton2;
27268
+ default:
27269
+ return MouseButton.None;
27270
+ }
27271
+ }
27272
+ function getMouseButtonMask(buttons) {
27273
+ var mask = MouseButtonMask.None;
27274
+ if ((buttons & 1) !== 0) {
27275
+ mask |= MouseButtonMask.Left;
27276
+ }
27277
+ if ((buttons & 2) !== 0) {
27278
+ mask |= MouseButtonMask.Right;
27279
+ }
27280
+ if ((buttons & 4) !== 0) {
27281
+ mask |= MouseButtonMask.Middle;
27282
+ }
27283
+ if ((buttons & 8) !== 0) {
27284
+ mask |= MouseButtonMask.Xbutton1;
27285
+ }
27286
+ if ((buttons & 16) !== 0) {
27287
+ mask |= MouseButtonMask.Xbutton2;
27288
+ }
27289
+ return mask;
27290
+ }
27291
+ function getMouseButtonBit(button) {
27292
+ switch(button){
27293
+ case MouseButton.Left:
27294
+ return MouseButtonMask.Left;
27295
+ case MouseButton.Right:
27296
+ return MouseButtonMask.Right;
27297
+ case MouseButton.Middle:
27298
+ return MouseButtonMask.Middle;
27299
+ case MouseButton.Xbutton1:
27300
+ return MouseButtonMask.Xbutton1;
27301
+ case MouseButton.Xbutton2:
27302
+ return MouseButtonMask.Xbutton2;
27303
+ default:
27304
+ return MouseButtonMask.None;
27305
+ }
25660
27306
  }
25661
27307
 
25662
27308
  var InteractLoader = /*#__PURE__*/ function(Plugin) {
@@ -27677,11 +29323,6 @@ SpritePropertyTrack = __decorate([
27677
29323
  effectsClass("SpritePropertyTrack")
27678
29324
  ], SpritePropertyTrack);
27679
29325
 
27680
- function _assert_this_initialized(self) {
27681
- if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
27682
- return self;
27683
- }
27684
-
27685
29326
  var Cone = /*#__PURE__*/ function() {
27686
29327
  function Cone(props) {
27687
29328
  var _this = this;
@@ -37686,7 +39327,7 @@ function getStandardSpriteContent(sprite, transform) {
37686
39327
  return ret;
37687
39328
  }
37688
39329
 
37689
- var version$1 = "2.10.0-alpha.2";
39330
+ var version$1 = "2.10.0-alpha.3";
37690
39331
  var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
37691
39332
  var standardVersion = /^(\d+)\.(\d+)$/;
37692
39333
  var reverseParticle = false;
@@ -39638,10 +41279,11 @@ var PreRenderTickData = /*#__PURE__*/ function(TickData) {
39638
41279
  _this./**
39639
41280
  * 是否开启后处理
39640
41281
  */ postProcessingEnabled = false;
39641
- _this.canvasLayers = [];
39642
41282
  _this.destroyed = false;
39643
41283
  _this.paused = true;
39644
41284
  _this.isEndCalled = false;
41285
+ _this._renderOrder = 0;
41286
+ _this._interactive = true;
39645
41287
  _this._textures = [];
39646
41288
  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;
39647
41289
  _this.engine.addComposition(_assert_this_initialized(_this));
@@ -39674,13 +41316,14 @@ var PreRenderTickData = /*#__PURE__*/ function(TickData) {
39674
41316
  _this.root = new VFXItem(_this.engine);
39675
41317
  _this.root.name = "root";
39676
41318
  _this.root.composition = _assert_this_initialized(_this);
41319
+ _this.root.setParent(_this.engine.root);
39677
41320
  _this.pluginRoot = new VFXItem(_this.engine);
39678
41321
  _this.pluginRoot.name = "pluginRoot";
39679
41322
  _this.pluginRoot.setParent(_this.root);
39680
- _this.pluginRoot.addComponent(CanvasLayer);
39681
41323
  // Instantiate composition rootItem
39682
41324
  _this.sceneRoot = new VFXItem(_this.engine);
39683
41325
  _this.sceneRoot.setParent(_this.root);
41326
+ _this.uiCanvas = _this.sceneRoot.addComponent(UICanvas);
39684
41327
  if (sourceContent) {
39685
41328
  _this.sceneRoot.setInstanceId(sourceContent.id);
39686
41329
  _this.sceneRoot.instantiatePreComposition(sourceContent, false);
@@ -39879,9 +41522,13 @@ var PreRenderTickData = /*#__PURE__*/ function(TickData) {
39879
41522
  this.isEndCalled = false;
39880
41523
  this.rootComposition.setTime(0);
39881
41524
  };
39882
- _proto.render = function render() {
41525
+ /** Renders this Composition content. Screen-space UI is rendered by Engine. */ _proto.render = function render() {
41526
+ this.renderContent();
41527
+ };
41528
+ /**
41529
+ * Renders only the Composition scene content.
41530
+ */ _proto.renderContent = function renderContent() {
39883
41531
  this.renderer.renderRenderFrame(this.renderFrame);
39884
- this.renderCanvasLayers();
39885
41532
  };
39886
41533
  /**
39887
41534
  * 合成更新,针对所有 item 的更新
@@ -39970,17 +41617,6 @@ var PreRenderTickData = /*#__PURE__*/ function(TickData) {
39970
41617
  }
39971
41618
  }
39972
41619
  };
39973
- _proto.renderCanvasLayers = function renderCanvasLayers() {
39974
- this.engine.graphics.begin();
39975
- this.canvasLayers.sort(function(leftLayer, rightLayer) {
39976
- return leftLayer.layer - rightLayer.layer;
39977
- });
39978
- for(var _iterator = _create_for_of_iterator_helper_loose(this.canvasLayers), _step; !(_step = _iterator()).done;){
39979
- var canvasLayer = _step.value;
39980
- canvasLayer.draw();
39981
- }
39982
- this.engine.graphics.end();
39983
- };
39984
41620
  /**
39985
41621
  * @internal
39986
41622
  */ _proto.createTexturesFromData = function createTexturesFromData(textureDataList) {
@@ -40249,6 +41885,35 @@ var PreRenderTickData = /*#__PURE__*/ function(TickData) {
40249
41885
  })();
40250
41886
  };
40251
41887
  _create_class(Composition, [
41888
+ {
41889
+ key: "renderOrder",
41890
+ get: /**
41891
+ * 合成渲染顺序,默认按升序渲染
41892
+ */ function get() {
41893
+ return this._renderOrder;
41894
+ },
41895
+ set: function set(value) {
41896
+ this._renderOrder = value;
41897
+ if (this.uiCanvas) {
41898
+ this.uiCanvas.order = value;
41899
+ }
41900
+ }
41901
+ },
41902
+ {
41903
+ key: "interactive",
41904
+ get: /**
41905
+ * 合成内的元素否允许点击、拖拽交互
41906
+ * @since 1.6.0
41907
+ */ function get() {
41908
+ return this._interactive;
41909
+ },
41910
+ set: function set(value) {
41911
+ this._interactive = !!value;
41912
+ if (this.uiCanvas) {
41913
+ this.uiCanvas.receivesEvents = this._interactive;
41914
+ }
41915
+ }
41916
+ },
40252
41917
  {
40253
41918
  key: "width",
40254
41919
  get: /**
@@ -42026,7 +43691,6 @@ var DEFAULT_FPS = 60;
42026
43691
  /**
42027
43692
  * 渲染过程中错误队列
42028
43693
  */ _this.renderErrors = new Set();
42029
- _this.compositions = [];
42030
43694
  _this.assetManagers = [];
42031
43695
  _this.env = "";
42032
43696
  /**
@@ -42048,6 +43712,7 @@ var DEFAULT_FPS = 60;
42048
43712
  _this.framebuffers = [];
42049
43713
  _this.renderbuffers = [];
42050
43714
  _this.particleSystems = [];
43715
+ _this._compositions = [];
42051
43716
  _this.clearAction = {
42052
43717
  stencilAction: TextureLoadAction.clear,
42053
43718
  clearStencil: 0,
@@ -42072,6 +43737,9 @@ var DEFAULT_FPS = 60;
42072
43737
  _this.pixelRatio = (_options_pixelRatio = options == null ? void 0 : options.pixelRatio) != null ? _options_pixelRatio : getPixelRatio();
42073
43738
  _this.jsonSceneData = {};
42074
43739
  _this.objectInstance = {};
43740
+ _this.root = new VFXItem(_assert_this_initialized(_this));
43741
+ _this.root.name = "root";
43742
+ _this.windowRoot = new WindowRootControl(_assert_this_initialized(_this));
42075
43743
  _this.whiteTexture = generateWhiteTexture(_assert_this_initialized(_this));
42076
43744
  _this.transparentTexture = generateEmptyTexture(_assert_this_initialized(_this));
42077
43745
  if (!(options == null ? void 0 : options.manualRender)) {
@@ -42206,9 +43874,6 @@ var DEFAULT_FPS = 60;
42206
43874
  // Sort compositions by index
42207
43875
  //-------------------------------------------------------------------------
42208
43876
  var compositions = this.compositions;
42209
- compositions.sort(function(a, b) {
42210
- return a.getIndex() - b.getIndex();
42211
- });
42212
43877
  var skipRender = false;
42213
43878
  // Update Compositions
42214
43879
  //-------------------------------------------------------------------------
@@ -42227,6 +43892,7 @@ var DEFAULT_FPS = 60;
42227
43892
  (_this_ticker1 = this.ticker) == null ? void 0 : _this_ticker1.pause();
42228
43893
  return;
42229
43894
  }
43895
+ this.windowRoot.update(dt);
42230
43896
  // Tick compositions onPreRender
42231
43897
  //-------------------------------------------------------------------------
42232
43898
  for(var _iterator1 = _create_for_of_iterator_helper_loose(compositions), _step1; !(_step1 = _iterator1()).done;){
@@ -42239,8 +43905,9 @@ var DEFAULT_FPS = 60;
42239
43905
  this.renderer.clear(this.clearAction);
42240
43906
  for(var _iterator2 = _create_for_of_iterator_helper_loose(compositions), _step2; !(_step2 = _iterator2()).done;){
42241
43907
  var composition2 = _step2.value;
42242
- composition2.render();
43908
+ composition2.renderContent();
42243
43909
  }
43910
+ this.windowRoot.render();
42244
43911
  this.renderTargetPool.flush();
42245
43912
  };
42246
43913
  /**
@@ -42282,6 +43949,7 @@ var DEFAULT_FPS = 60;
42282
43949
  this.canvas.style.height = containerHeight + "px";
42283
43950
  logger.info("Resize engine " + this.name + " [" + canvasWidth + "," + canvasHeight + "," + containerWidth + "," + containerHeight + "].");
42284
43951
  this.setSize(canvasWidth, canvasHeight);
43952
+ this.windowRoot.resize(canvasWidth, canvasHeight);
42285
43953
  }
42286
43954
  };
42287
43955
  _proto.setSize = function setSize(width, height) {
@@ -42289,7 +43957,7 @@ var DEFAULT_FPS = 60;
42289
43957
  if (this.getWidth() !== width || this.getHeight() !== height) {
42290
43958
  this.canvas.width = width;
42291
43959
  this.canvas.height = height;
42292
- this.viewport(0, 0, width, height);
43960
+ this.setViewport(0, 0, width, height);
42293
43961
  }
42294
43962
  (_this_compositions = this.compositions) == null ? void 0 : _this_compositions.forEach(function(comp) {
42295
43963
  comp.camera.aspect = width / height;
@@ -42318,6 +43986,26 @@ var DEFAULT_FPS = 60;
42318
43986
  /** @hide */ _proto.bindBuffers = function bindBuffers(vertexBuffers, indexBuffer, effect) {
42319
43987
  throw new Error("The active rendering backend cannot bind geometry buffers.");
42320
43988
  };
43989
+ /**
43990
+ * 使用当前绑定的顶点和索引缓冲区绘制图元。
43991
+ * @param mode - 图元类型
43992
+ * @param indexOffset - 索引缓冲区中的字节偏移
43993
+ * @param indexCount - 索引数量
43994
+ * @param instanceCount - 实例数量
43995
+ * @hide
43996
+ */ _proto.drawElementsType = function drawElementsType(mode, indexOffset, indexCount, instanceCount) {
43997
+ throw new Error("The active rendering backend cannot draw indexed primitives.");
43998
+ };
43999
+ /**
44000
+ * 使用当前绑定的顶点缓冲区绘制图元。
44001
+ * @param mode - 图元类型
44002
+ * @param vertexStart - 起始顶点
44003
+ * @param vertexCount - 顶点数量
44004
+ * @param instanceCount - 实例数量
44005
+ * @hide
44006
+ */ _proto.drawArraysType = function drawArraysType(mode, vertexStart, vertexCount, instanceCount) {
44007
+ throw new Error("The active rendering backend cannot draw primitives.");
44008
+ };
42321
44009
  _proto.addTexture = function addTexture(tex) {
42322
44010
  if (this.disposed) {
42323
44011
  return;
@@ -42449,15 +44137,12 @@ var DEFAULT_FPS = 60;
42449
44137
  * @param height
42450
44138
  * example:
42451
44139
  * gl.viewport(0, 0, width, height);
42452
- */ _proto.viewport = function viewport(x, y, width, height) {
44140
+ */ _proto.setViewport = function setViewport(x, y, width, height) {
42453
44141
  // OVERRIDE
42454
44142
  };
42455
44143
  _proto.clear = function clear(action) {
42456
44144
  // OVERRIDE
42457
44145
  };
42458
- _proto.drawGeometry = function drawGeometry(geometry, matrix, material, subMeshIndex) {
42459
- // OVERRIDE
42460
- };
42461
44146
  /*** 渲染状态控制 ***/ _proto.setSampleAlphaToCoverage = function setSampleAlphaToCoverage(enable) {
42462
44147
  // OVERRIDE
42463
44148
  };
@@ -42542,6 +44227,12 @@ var DEFAULT_FPS = 60;
42542
44227
  }
42543
44228
  (_this_ticker = this.ticker) == null ? void 0 : _this_ticker.stop();
42544
44229
  (_this_eventSystem = this.eventSystem) == null ? void 0 : _this_eventSystem.dispose();
44230
+ for(var _iterator = _create_for_of_iterator_helper_loose(this._compositions.slice()), _step; !(_step = _iterator()).done;){
44231
+ var composition = _step.value;
44232
+ composition.dispose();
44233
+ }
44234
+ this.root.dispose();
44235
+ this.windowRoot.dispose();
42545
44236
  (_this_assetService = this.assetService) == null ? void 0 : _this_assetService.dispose();
42546
44237
  (_this__graphics = this._graphics) == null ? void 0 : _this__graphics.dispose();
42547
44238
  this.renderPasses.forEach(function(pass) {
@@ -42562,16 +44253,13 @@ var DEFAULT_FPS = 60;
42562
44253
  this.assetManagers.forEach(function(assetManager) {
42563
44254
  return assetManager.dispose();
42564
44255
  });
42565
- this.compositions.forEach(function(comp) {
42566
- return comp.dispose();
42567
- });
42568
44256
  this.textures = [];
42569
44257
  this.materials = [];
42570
44258
  this.geometries = [];
42571
44259
  this.meshes = [];
42572
44260
  this.renderPasses = [];
42573
- this.compositions = [];
42574
44261
  this.particleSystems = [];
44262
+ this._compositions = [];
42575
44263
  };
42576
44264
  _proto.getTargetSize = function getTargetSize(parentEle) {
42577
44265
  if (parentEle === undefined || parentEle === null) {
@@ -42624,6 +44312,14 @@ var DEFAULT_FPS = 60;
42624
44312
  ];
42625
44313
  };
42626
44314
  _create_class(Engine, [
44315
+ {
44316
+ key: "compositions",
44317
+ get: function get() {
44318
+ return this._compositions.sort(function(a, b) {
44319
+ return a.getIndex() - b.getIndex();
44320
+ });
44321
+ }
44322
+ },
42627
44323
  {
42628
44324
  key: "graphics",
42629
44325
  get: function get() {
@@ -42861,8 +44557,8 @@ registerPlugin("text", TextLoader);
42861
44557
  registerPlugin("sprite", SpriteLoader);
42862
44558
  registerPlugin("particle", ParticleLoader);
42863
44559
  registerPlugin("interact", InteractLoader);
42864
- var version = "2.10.0-alpha.2";
44560
+ var version = "2.10.0-alpha.3";
42865
44561
  logger.info("Core version: " + version + ".");
42866
44562
 
42867
- 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, 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, TangentMode, TextCache, TextComponent, TextComponentBase, TextLayout, TextLoader, TextStyle, Texture, TextureFactory, TextureLoadAction, TexturePaintScaleMode, TextureSourceType, TextureStoreAction, 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, sortByOrder, index$1 as spec, textureLoaderRegistry, thresholdFrag, throwDestroyedError, toBufferView, trailVert, translatePoint, trianglesFromRect, unregisterPlugin, valIfUndefined, value, valueDefine, vecFill, vecMulCombine, version, vertexFormatType2GLType };
44563
+ 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, 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, TangentMode, TextCache, TextComponent, TextComponentBase, TextLayout, TextLoader, TextStyle, Texture, TextureFactory, TextureLoadAction, TexturePaintScaleMode, TextureSourceType, TextureStoreAction, 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, sortByOrder, index$1 as spec, textureLoaderRegistry, thresholdFrag, throwDestroyedError, toBufferView, trailVert, translatePoint, trianglesFromRect, unregisterPlugin, valIfUndefined, value, valueDefine, vecFill, vecMulCombine, version, vertexFormatType2GLType };
42868
44564
  //# sourceMappingURL=index.mjs.map