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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: Galacean Effects runtime core for the web
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
6
- * Version: v2.10.0-alpha.4
6
+ * Version: v2.10.0-alpha.5
7
7
  */
8
8
 
9
9
  'use strict';
@@ -2931,6 +2931,11 @@ var PluginSystem = /*#__PURE__*/ function() {
2931
2931
  PluginSystem.getPlugins = function getPlugins() {
2932
2932
  return plugins;
2933
2933
  };
2934
+ PluginSystem.notifyCompositionCreating = function notifyCompositionCreating(composition, scene) {
2935
+ plugins.forEach(function(plugin) {
2936
+ return plugin.onCompositionCreating(composition, scene);
2937
+ });
2938
+ };
2934
2939
  PluginSystem.notifyCompositionCreated = function notifyCompositionCreated(composition, scene) {
2935
2940
  plugins.forEach(function(plugin) {
2936
2941
  return plugin.onCompositionCreated(composition, scene);
@@ -3023,6 +3028,12 @@ function getPluginUsageInfo(name) {
3023
3028
  * @param engine - 引擎实例
3024
3029
  */ _proto.onAssetsLoadFinish = function onAssetsLoadFinish(scene, options, engine) {};
3025
3030
  /**
3031
+ * 合成内容开始创建前触发。
3032
+ * 此时 root、pluginRoot 和 sceneRoot 已创建,但场景内容尚未实例化。
3033
+ * @param composition - 正在创建的合成对象
3034
+ * @param scene - 场景对象
3035
+ */ _proto.onCompositionCreating = function onCompositionCreating(composition, scene) {};
3036
+ /**
3026
3037
  * 合成创建完成后触发。
3027
3038
  * @param composition - 合成对象
3028
3039
  * @param scene - 场景对象
@@ -15631,35 +15642,35 @@ function vecMulCombine(out, a, b) {
15631
15642
  }
15632
15643
  return out;
15633
15644
  }
15634
- var _obj$6;
15635
- var particleOriginTranslateMap$1 = (_obj$6 = {}, _obj$6[ParticleOrigin.PARTICLE_ORIGIN_CENTER] = [
15645
+ var _obj$5;
15646
+ var particleOriginTranslateMap$1 = (_obj$5 = {}, _obj$5[ParticleOrigin.PARTICLE_ORIGIN_CENTER] = [
15636
15647
  0,
15637
15648
  0
15638
- ], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_CENTER_BOTTOM] = [
15649
+ ], _obj$5[ParticleOrigin.PARTICLE_ORIGIN_CENTER_BOTTOM] = [
15639
15650
  0,
15640
15651
  -0.5
15641
- ], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_CENTER_TOP] = [
15652
+ ], _obj$5[ParticleOrigin.PARTICLE_ORIGIN_CENTER_TOP] = [
15642
15653
  0,
15643
15654
  0.5
15644
- ], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_LEFT_TOP] = [
15655
+ ], _obj$5[ParticleOrigin.PARTICLE_ORIGIN_LEFT_TOP] = [
15645
15656
  -0.5,
15646
15657
  0.5
15647
- ], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_LEFT_CENTER] = [
15658
+ ], _obj$5[ParticleOrigin.PARTICLE_ORIGIN_LEFT_CENTER] = [
15648
15659
  -0.5,
15649
15660
  0
15650
- ], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_LEFT_BOTTOM] = [
15661
+ ], _obj$5[ParticleOrigin.PARTICLE_ORIGIN_LEFT_BOTTOM] = [
15651
15662
  -0.5,
15652
15663
  -0.5
15653
- ], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_CENTER] = [
15664
+ ], _obj$5[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_CENTER] = [
15654
15665
  0.5,
15655
15666
  0
15656
- ], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_BOTTOM] = [
15667
+ ], _obj$5[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_BOTTOM] = [
15657
15668
  0.5,
15658
15669
  -0.5
15659
- ], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_TOP] = [
15670
+ ], _obj$5[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_TOP] = [
15660
15671
  0.5,
15661
15672
  0.5
15662
- ], _obj$6);
15673
+ ], _obj$5);
15663
15674
  function nearestPowerOfTwo(value) {
15664
15675
  return Math.pow(2, Math.round(Math.log(value) / Math.LN2));
15665
15676
  }
@@ -17397,27 +17408,27 @@ function oldBezierKeyFramesToNew(props) {
17397
17408
  * 对象引用阶梯曲线(spec ValueType.REFERENCE_CURVE)。
17398
17409
  * props 为 [[time, value], ...],value 为已解析的对象引用实例。
17399
17410
  */ var REFERENCE_CURVE = 28;
17400
- var _obj$5;
17401
- var map$1 = (_obj$5 = {}, _obj$5[ValueType.RANDOM] = function(props) {
17411
+ var _obj$4;
17412
+ var map$1 = (_obj$4 = {}, _obj$4[ValueType.RANDOM] = function(props) {
17402
17413
  if (_instanceof1(props[0], Array)) {
17403
17414
  return new RandomVectorValue(props);
17404
17415
  }
17405
17416
  return new RandomValue(props);
17406
- }, _obj$5[ValueType.CONSTANT] = function(props) {
17417
+ }, _obj$4[ValueType.CONSTANT] = function(props) {
17407
17418
  return new StaticValue(props);
17408
- }, _obj$5[ValueType.CONSTANT_VEC2] = function(props) {
17419
+ }, _obj$4[ValueType.CONSTANT_VEC2] = function(props) {
17409
17420
  return new StaticValue(props);
17410
- }, _obj$5[ValueType.CONSTANT_VEC3] = function(props) {
17421
+ }, _obj$4[ValueType.CONSTANT_VEC3] = function(props) {
17411
17422
  return new StaticValue(props);
17412
- }, _obj$5[ValueType.CONSTANT_VEC4] = function(props) {
17423
+ }, _obj$4[ValueType.CONSTANT_VEC4] = function(props) {
17413
17424
  return new StaticValue(props);
17414
- }, _obj$5[ValueType.RGBA_COLOR] = function(props) {
17425
+ }, _obj$4[ValueType.RGBA_COLOR] = function(props) {
17415
17426
  return new StaticValue(props);
17416
- }, _obj$5[ValueType.COLORS] = function(props) {
17427
+ }, _obj$4[ValueType.COLORS] = function(props) {
17417
17428
  return new RandomSetValue(props.map(function(c) {
17418
17429
  return colorToArr$1(c, false);
17419
17430
  }));
17420
- }, _obj$5[ValueType.LINE] = function(props) {
17431
+ }, _obj$4[ValueType.LINE] = function(props) {
17421
17432
  if (props.length === 2 && props[0][0] === 0 && props[1][0] === 1) {
17422
17433
  return new LinearValue([
17423
17434
  props[0][1],
@@ -17425,38 +17436,38 @@ var map$1 = (_obj$5 = {}, _obj$5[ValueType.RANDOM] = function(props) {
17425
17436
  ]);
17426
17437
  }
17427
17438
  return new LineSegments(props);
17428
- }, _obj$5[ValueType.GRADIENT_COLOR] = function(props) {
17439
+ }, _obj$4[ValueType.GRADIENT_COLOR] = function(props) {
17429
17440
  return new GradientValue(props);
17430
- }, _obj$5[ValueType.LINEAR_PATH] = function(pros) {
17441
+ }, _obj$4[ValueType.LINEAR_PATH] = function(pros) {
17431
17442
  return new PathSegments(pros);
17432
- }, _obj$5[ValueType.BEZIER_CURVE] = function(props) {
17443
+ }, _obj$4[ValueType.BEZIER_CURVE] = function(props) {
17433
17444
  if (props.length === 1) {
17434
17445
  return new StaticValue(props[0][1][1]);
17435
17446
  }
17436
17447
  return new BezierCurve(props);
17437
- }, _obj$5[ValueType.BEZIER_CURVE_PATH] = function(props) {
17448
+ }, _obj$4[ValueType.BEZIER_CURVE_PATH] = function(props) {
17438
17449
  if (props[0].length === 1) {
17439
17450
  return new StaticValue(_construct(Vector3, [].concat(props[1][0])));
17440
17451
  }
17441
17452
  return new BezierCurvePath(props);
17442
- }, _obj$5[ValueType.BEZIER_CURVE_QUAT] = function(props) {
17453
+ }, _obj$4[ValueType.BEZIER_CURVE_QUAT] = function(props) {
17443
17454
  if (props[0].length === 1) {
17444
17455
  return new StaticValue(_construct(Quaternion, [].concat(props[1][0])));
17445
17456
  }
17446
17457
  return new BezierCurveQuat(props);
17447
- }, _obj$5[ValueType.COLOR_CURVE] = function(props) {
17458
+ }, _obj$4[ValueType.COLOR_CURVE] = function(props) {
17448
17459
  return new ColorCurve(props);
17449
- }, _obj$5[ValueType.VECTOR4_CURVE] = function(props) {
17460
+ }, _obj$4[ValueType.VECTOR4_CURVE] = function(props) {
17450
17461
  return new Vector4Curve(props);
17451
- }, _obj$5[ValueType.VECTOR2_CURVE] = function(props) {
17462
+ }, _obj$4[ValueType.VECTOR2_CURVE] = function(props) {
17452
17463
  return new Vector2Curve(props);
17453
17464
  }, // TODO: add spec
17454
- _obj$5[VECTOR3_CURVE] = function(props) {
17465
+ _obj$4[VECTOR3_CURVE] = function(props) {
17455
17466
  return new Vector3Curve(props);
17456
17467
  }, // 对象引用阶梯曲线(不插值):props.data 为 [time, value][],value 已解析为 EffectsObject
17457
- _obj$5[REFERENCE_CURVE] = function(props) {
17468
+ _obj$4[REFERENCE_CURVE] = function(props) {
17458
17469
  return new ReferenceCurve(props);
17459
- }, _obj$5);
17470
+ }, _obj$4);
17460
17471
  function createValueGetter(args) {
17461
17472
  if (!args || !isNaN(+args)) {
17462
17473
  return new StaticValue(args || 0);
@@ -21397,8 +21408,8 @@ var vertexBufferSemanticMap = {
21397
21408
  TANGENT_BS2: "aTargetTangent2",
21398
21409
  TANGENT_BS3: "aTargetTangent3"
21399
21410
  };
21400
- var _obj$4;
21401
- var BYTES_TYPE_MAP = (_obj$4 = {}, _obj$4[exports.BufferDataType.Float] = 4, _obj$4[exports.BufferDataType.Int] = 4, _obj$4[exports.BufferDataType.UnsignedInt] = 4, _obj$4[exports.BufferDataType.Short] = 2, _obj$4[exports.BufferDataType.UnsignedShort] = 2, _obj$4[exports.BufferDataType.Byte] = 1, _obj$4[exports.BufferDataType.UnsignedByte] = 1, _obj$4);
21411
+ var _obj$3;
21412
+ var BYTES_TYPE_MAP = (_obj$3 = {}, _obj$3[exports.BufferDataType.Float] = 4, _obj$3[exports.BufferDataType.Int] = 4, _obj$3[exports.BufferDataType.UnsignedInt] = 4, _obj$3[exports.BufferDataType.Short] = 2, _obj$3[exports.BufferDataType.UnsignedShort] = 2, _obj$3[exports.BufferDataType.Byte] = 1, _obj$3[exports.BufferDataType.UnsignedByte] = 1, _obj$3);
21402
21413
  function generateEmptyTypedArray(type) {
21403
21414
  return createTypedArray(type, 0);
21404
21415
  }
@@ -22915,7 +22926,7 @@ var canvasPool = new CanvasPool();
22915
22926
  * `ATLAS_SIZE × ATLAS_SIZE` 的离屏 canvas atlas,字符按需逐个绘制并打包,
22916
22927
  * `Graphics.drawText` 通过逐字 quad 引用 atlas 子矩形渲染。
22917
22928
  *
22918
- * - 同一段文本不同颜色不会重复 upload(颜色由顶点 `vColor` 乘上字形 alpha)
22929
+ * - 同一段文本不同颜色不会重复 upload(颜色由顶点 `vColor` 与字形 RGBA 相乘)
22919
22930
  * - 同一字体/字号下重复字符只渲染一次,显著减少 canvas → texture 上传次数
22920
22931
  *
22921
22932
  * 入参全部展开(避免调用方每帧创建临时 style 对象触发 GC)
@@ -22929,7 +22940,7 @@ var canvasPool = new CanvasPool();
22929
22940
  /**
22930
22941
  * 取(必要时新建)对应字体的字符 atlas
22931
22942
  */ _proto.getAtlas = function getAtlas(fontSize, fontFamily, fontWeight, fontStyle) {
22932
- // Pixi CanvasText 默认跟随 renderer.resolution;这里对应 Engine.pixelRatio。
22943
+ // 字形 atlas 跟随 Engine.pixelRatio。
22933
22944
  var resolution = this.engine.pixelRatio;
22934
22945
  if (resolution !== this.resolution) {
22935
22946
  this.clear();
@@ -22950,14 +22961,11 @@ var canvasPool = new CanvasPool();
22950
22961
  var probeCtx = probeCanvasAndContext.context;
22951
22962
  var ascentPx = fontSize * 0.8 * resolution;
22952
22963
  var descentPx = fontSize * 0.2 * resolution;
22953
- try {
22954
- probeCtx.font = scaledFontString;
22955
- var m = probeCtx.measureText(METRICS_STRING + BASELINE_SYMBOL);
22956
- ascentPx = m.actualBoundingBoxAscent || ascentPx;
22957
- descentPx = m.actualBoundingBoxDescent || descentPx;
22958
- } finally{
22959
- canvasPool.releaseCanvasAndContext(probeCanvasAndContext);
22960
- }
22964
+ probeCtx.font = scaledFontString;
22965
+ var m = probeCtx.measureText(METRICS_STRING + BASELINE_SYMBOL);
22966
+ ascentPx = m.actualBoundingBoxAscent || ascentPx;
22967
+ descentPx = m.actualBoundingBoxDescent || descentPx;
22968
+ canvasPool.releaseCanvasAndContext(probeCanvasAndContext);
22961
22969
  var atlas = new GlyphAtlas(this.engine, scaledFontString, ascentPx, descentPx, fontStyle, resolution);
22962
22970
  this.atlases.set(fontKey, atlas);
22963
22971
  return atlas;
@@ -22993,6 +23001,10 @@ var FULL_REGION = {
22993
23001
  u1: 1,
22994
23002
  v1: 1
22995
23003
  };
23004
+ var NINE_PATCH_DRAW_SOURCE_SIZE = "aDrawSourceSize";
23005
+ var NINE_PATCH_SOURCE_RECT = "aSourceRect";
23006
+ var NINE_PATCH_MARGINS = "aMargins";
23007
+ var NINE_PATCH_OPTIONS = "aOptions";
22996
23008
  var Graphics = /*#__PURE__*/ function() {
22997
23009
  function Graphics(engine) {
22998
23010
  this.engine = engine;
@@ -23006,6 +23018,10 @@ var Graphics = /*#__PURE__*/ function() {
23006
23018
  this.colors = [];
23007
23019
  this.uvs = [];
23008
23020
  this.indices = [];
23021
+ this.ninePatchDrawSourceSizes = [];
23022
+ this.ninePatchSourceRects = [];
23023
+ this.ninePatchMargins = [];
23024
+ this.ninePatchOptions = [];
23009
23025
  this.lineStyle = {
23010
23026
  width: 1,
23011
23027
  alignment: 0.5,
@@ -23017,6 +23033,9 @@ var Graphics = /*#__PURE__*/ function() {
23017
23033
  this.currentBatchTexture = null;
23018
23034
  this.transformStack = [];
23019
23035
  this.currentTransform = Matrix3.fromIdentity();
23036
+ this.clipStack = [];
23037
+ this.logicalWidth = 1;
23038
+ this.logicalHeight = 1;
23020
23039
  var _obj;
23021
23040
  this.geometry = Geometry.create(this.engine, {
23022
23041
  attributes: (_obj = {}, _obj[VertexBuffer.PositionKind] = {
@@ -23082,6 +23101,51 @@ var Graphics = /*#__PURE__*/ function() {
23082
23101
  drawCount: 6,
23083
23102
  bufferUsage: glContext.DYNAMIC_DRAW
23084
23103
  });
23104
+ var _obj1;
23105
+ this.ninePatchGeometry = Geometry.create(this.engine, {
23106
+ attributes: (_obj1 = {}, _obj1[VertexBuffer.PositionKind] = {
23107
+ type: glContext.FLOAT,
23108
+ size: 2,
23109
+ data: new Float32Array(8)
23110
+ }, _obj1[VertexBuffer.ColorKind] = {
23111
+ type: glContext.FLOAT,
23112
+ size: 4,
23113
+ data: new Float32Array(16)
23114
+ }, _obj1[VertexBuffer.UVKind] = {
23115
+ type: glContext.FLOAT,
23116
+ size: 2,
23117
+ data: new Float32Array(8)
23118
+ }, _obj1[NINE_PATCH_DRAW_SOURCE_SIZE] = {
23119
+ type: glContext.FLOAT,
23120
+ size: 4,
23121
+ data: new Float32Array(16)
23122
+ }, _obj1[NINE_PATCH_SOURCE_RECT] = {
23123
+ type: glContext.FLOAT,
23124
+ size: 4,
23125
+ data: new Float32Array(16)
23126
+ }, _obj1[NINE_PATCH_MARGINS] = {
23127
+ type: glContext.FLOAT,
23128
+ size: 4,
23129
+ data: new Float32Array(16)
23130
+ }, _obj1[NINE_PATCH_OPTIONS] = {
23131
+ type: glContext.FLOAT,
23132
+ size: 4,
23133
+ data: new Float32Array(16)
23134
+ }, _obj1),
23135
+ indices: {
23136
+ data: new Uint16Array([
23137
+ 0,
23138
+ 1,
23139
+ 2,
23140
+ 2,
23141
+ 1,
23142
+ 3
23143
+ ])
23144
+ },
23145
+ mode: glContext.TRIANGLES,
23146
+ drawCount: 6,
23147
+ bufferUsage: glContext.DYNAMIC_DRAW
23148
+ });
23085
23149
  this.coloredMaterial = Material.create(this.engine, {
23086
23150
  shader: {
23087
23151
  vertex: "precision highp float;\n attribute vec2 aPos;\n attribute vec4 aColor;\n varying vec4 vColor;\n\n uniform mat4 effects_MatrixVP;\n void main() {\n vColor = aColor;\n gl_Position = effects_MatrixVP * vec4(aPos, 0.0, 1.0);\n }",
@@ -23100,12 +23164,21 @@ var Graphics = /*#__PURE__*/ function() {
23100
23164
  this.texturedMaterial.depthTest = false;
23101
23165
  this.texturedMaterial.depthMask = false;
23102
23166
  this.texturedMaterial.blending = true;
23103
- // 文本 atlas 按 Pixi 的方式在上传时预乘 alpha,因此采样后只需应用顶点色和顶点 alpha。
23167
+ this.ninePatchMaterial = Material.create(this.engine, {
23168
+ shader: {
23169
+ vertex: "precision highp float;\n attribute vec2 aPos;\n attribute vec4 aColor;\n attribute vec2 aUV;\n attribute vec4 aDrawSourceSize;\n attribute vec4 aSourceRect;\n attribute vec4 aMargins;\n attribute vec4 aOptions;\n varying vec4 vColor;\n varying vec2 vUV;\n varying vec4 vDrawSourceSize;\n varying vec4 vSourceRect;\n varying vec4 vMargins;\n varying vec4 vOptions;\n\n uniform mat4 effects_MatrixVP;\n void main() {\n vColor = aColor;\n vUV = aUV;\n vDrawSourceSize = aDrawSourceSize;\n vSourceRect = aSourceRect;\n vMargins = aMargins;\n vOptions = aOptions;\n gl_Position = effects_MatrixVP * vec4(aPos, 0.0, 1.0);\n }",
23170
+ fragment: "precision highp float;\n varying vec4 vColor;\n varying vec2 vUV;\n varying vec4 vDrawSourceSize;\n varying vec4 vSourceRect;\n varying vec4 vMargins;\n varying vec4 vOptions;\n uniform sampler2D uMainTexture;\n\n float mapNinePatchAxis(\n float pixel,\n float drawSize,\n float sourceSize,\n float marginBegin,\n float marginEnd,\n float repeatMode,\n inout float drawCenter\n ) {\n if (pixel < marginBegin) {\n return pixel / sourceSize;\n } else if (pixel >= drawSize - marginEnd) {\n return (sourceSize - (drawSize - pixel)) / sourceSize;\n } else {\n if (vOptions.z < 0.5) {\n drawCenter -= 1.0;\n }\n\n if (repeatMode < 0.5) {\n float ratio = (pixel - marginBegin) / (drawSize - marginBegin - marginEnd);\n return (marginBegin + ratio * (sourceSize - marginBegin - marginEnd)) / sourceSize;\n } else if (repeatMode < 1.5) {\n float offset = mod(pixel - marginBegin, sourceSize - marginBegin - marginEnd);\n return (marginBegin + offset) / sourceSize;\n } else {\n float drawArea = drawSize - marginBegin - marginEnd;\n float sourceArea = sourceSize - marginBegin - marginEnd;\n float scale = max(1.0, floor(drawArea / max(sourceArea, 0.0000001) + 0.5));\n float ratio = mod((pixel - marginBegin) / drawArea * scale, 1.0);\n return (marginBegin + ratio * sourceArea) / sourceSize;\n }\n }\n }\n\n void main() {\n vec2 pixel = vec2(vUV.x, 1.0 - vUV.y) * vDrawSourceSize.xy;\n float drawCenter = 2.0;\n vec2 sourceUV = vec2(\n mapNinePatchAxis(\n pixel.x, vDrawSourceSize.x, vDrawSourceSize.z,\n vMargins.x, vMargins.z, vOptions.x, drawCenter\n ),\n mapNinePatchAxis(\n pixel.y, vDrawSourceSize.y, vDrawSourceSize.w,\n vMargins.y, vMargins.w, vOptions.y, drawCenter\n )\n );\n\n if (drawCenter < 0.5) {\n discard;\n }\n\n vec2 uv = vec2(\n vSourceRect.x + sourceUV.x * vSourceRect.z,\n vSourceRect.y - sourceUV.y * vSourceRect.w\n );\n vec4 color = texture2D(uMainTexture, uv) * vColor;\n color.rgb *= color.a;\n gl_FragColor = color;\n }"
23171
+ }
23172
+ });
23173
+ this.ninePatchMaterial.depthTest = false;
23174
+ this.ninePatchMaterial.depthMask = false;
23175
+ this.ninePatchMaterial.blending = true;
23176
+ // 文本 atlas 在上传时预乘 alpha,因此纹理 RGB 只需乘顶点色和顶点 alpha。
23104
23177
  // 单独使用 material,避免改变 drawTexture 对普通非预乘纹理的处理。
23105
23178
  this.textMaterial = Material.create(this.engine, {
23106
23179
  shader: {
23107
23180
  vertex: "precision highp float;\n attribute vec2 aPos;\n attribute vec4 aColor;\n attribute vec2 aUV;\n varying vec4 vColor;\n varying vec2 vUV;\n\n uniform mat4 effects_MatrixVP;\n void main() {\n vColor = aColor;\n vUV = aUV;\n gl_Position = effects_MatrixVP * vec4(aPos, 0.0, 1.0);\n }",
23108
- fragment: "precision highp float;\n varying vec4 vColor;\n varying vec2 vUV;\n uniform sampler2D uMainTexture;\n void main() {\n float alpha = texture2D(uMainTexture, vUV).a * vColor.a;\n gl_FragColor = vec4(vColor.rgb * alpha, alpha);\n }"
23181
+ fragment: "precision highp float;\n varying vec4 vColor;\n varying vec2 vUV;\n uniform sampler2D uMainTexture;\n void main() {\n vec4 textureColor = texture2D(uMainTexture, vUV);\n float alpha = textureColor.a * vColor.a;\n vec3 rgb = textureColor.rgb * vColor.rgb * vColor.a;\n gl_FragColor = vec4(rgb, alpha);\n }"
23109
23182
  }
23110
23183
  });
23111
23184
  this.textMaterial.depthTest = false;
@@ -23121,25 +23194,36 @@ var Graphics = /*#__PURE__*/ function() {
23121
23194
  this.vertices.length = 0;
23122
23195
  this.colors.length = 0;
23123
23196
  this.uvs.length = 0;
23197
+ this.ninePatchDrawSourceSizes.length = 0;
23198
+ this.ninePatchSourceRects.length = 0;
23199
+ this.ninePatchMargins.length = 0;
23200
+ this.ninePatchOptions.length = 0;
23124
23201
  this.transformStack = [];
23125
23202
  this.currentTransform = Matrix3.fromIdentity();
23203
+ this.clipStack = [];
23126
23204
  this.currentBatchType = "colored";
23127
23205
  this.currentBatchTexture = null;
23206
+ this.engine.setScissorTest(false);
23128
23207
  // 创建从屏幕坐标到 NDC 的投影矩阵,屏幕坐标:(0, 0) 在左上角,(width, height) 在右下角,+Y 向下。
23129
- var _this_engine_canvas_getBoundingClientRect = this.engine.canvas.getBoundingClientRect(), width = _this_engine_canvas_getBoundingClientRect.width, height = _this_engine_canvas_getBoundingClientRect.height;
23208
+ var bounds = this.engine.canvas.getBoundingClientRect();
23209
+ var width = bounds.width || this.engine.canvas.width / this.engine.pixelRatio || 1;
23210
+ var height = bounds.height || this.engine.canvas.height / this.engine.pixelRatio || 1;
23211
+ this.logicalWidth = width;
23212
+ this.logicalHeight = height;
23130
23213
  // 正交投影矩阵:将屏幕坐标 [0, width] x [0, height] 映射到 NDC [-1, 1] x [-1, 1]
23131
23214
  var projectionMatrix = new Matrix4(2 / width, 0, 0, 0, 0, -2 / height, 0, 0, 0, 0, -1, 0, -1, 1, 0, 1 // 第四列
23132
23215
  );
23133
23216
  this.coloredMaterial.setMatrix("effects_MatrixVP", projectionMatrix);
23134
23217
  this.texturedMaterial.setMatrix("effects_MatrixVP", projectionMatrix);
23135
23218
  this.textMaterial.setMatrix("effects_MatrixVP", projectionMatrix);
23219
+ this.ninePatchMaterial.setMatrix("effects_MatrixVP", projectionMatrix);
23136
23220
  };
23137
23221
  /**
23138
23222
  * 将当前变换压入栈,并设置新的变换
23139
23223
  * @param transform - 新的变换矩阵(会与当前变换相乘)
23140
23224
  */ _proto.pushTransform = function pushTransform(transform) {
23141
23225
  this.transformStack.push(this.currentTransform.clone());
23142
- this.currentTransform = this.currentTransform.premultiply(transform);
23226
+ this.currentTransform = this.currentTransform.multiply(transform);
23143
23227
  };
23144
23228
  /**
23145
23229
  * 恢复上一个变换
@@ -23151,10 +23235,81 @@ var Graphics = /*#__PURE__*/ function() {
23151
23235
  }
23152
23236
  this.currentTransform = transform;
23153
23237
  };
23238
+ /** Pushes a local rectangular child clip using a screen-space AABB scissor. */ _proto.pushClipRect = function pushClipRect(x, y, width, height) {
23239
+ var elements = this.currentTransform.elements;
23240
+ var corners = [
23241
+ [
23242
+ x,
23243
+ y
23244
+ ],
23245
+ [
23246
+ x + width,
23247
+ y
23248
+ ],
23249
+ [
23250
+ x,
23251
+ y + height
23252
+ ],
23253
+ [
23254
+ x + width,
23255
+ y + height
23256
+ ]
23257
+ ];
23258
+ var left = Infinity;
23259
+ var top = Infinity;
23260
+ var right = -Infinity;
23261
+ var bottom = -Infinity;
23262
+ for(var _iterator = _create_for_of_iterator_helper_loose(corners), _step; !(_step = _iterator()).done;){
23263
+ var corner = _step.value;
23264
+ var transformedX = elements[0] * corner[0] + elements[3] * corner[1] + elements[6];
23265
+ var transformedY = elements[1] * corner[0] + elements[4] * corner[1] + elements[7];
23266
+ left = Math.min(left, transformedX);
23267
+ top = Math.min(top, transformedY);
23268
+ right = Math.max(right, transformedX);
23269
+ bottom = Math.max(bottom, transformedY);
23270
+ }
23271
+ var parent = this.clipStack[this.clipStack.length - 1];
23272
+ if (parent) {
23273
+ left = Math.max(left, parent.x);
23274
+ top = Math.max(top, parent.y);
23275
+ right = Math.min(right, parent.x + parent.width);
23276
+ bottom = Math.min(bottom, parent.y + parent.height);
23277
+ }
23278
+ var clip = {
23279
+ x: left,
23280
+ y: top,
23281
+ width: Math.max(0, right - left),
23282
+ height: Math.max(0, bottom - top)
23283
+ };
23284
+ var previous = parent;
23285
+ this.clipStack.push(clip);
23286
+ if (!this.clipRectsEqual(previous, clip)) {
23287
+ this.flushBatch();
23288
+ this.applyClipRect(clip);
23289
+ }
23290
+ };
23291
+ /** Restores the parent rectangular clip. */ _proto.popClipRect = function popClipRect() {
23292
+ var previous = this.clipStack.pop();
23293
+ if (!previous) {
23294
+ console.warn("Graphics: clip stack is empty.");
23295
+ return;
23296
+ }
23297
+ var clip = this.clipStack[this.clipStack.length - 1];
23298
+ if (!this.clipRectsEqual(previous, clip)) {
23299
+ this.flushBatch();
23300
+ if (clip) {
23301
+ this.applyClipRect(clip);
23302
+ } else {
23303
+ this.engine.setScissorTest(false);
23304
+ }
23305
+ }
23306
+ };
23154
23307
  /**
23155
23308
  * 刷新并渲染所有累积的绘制命令
23156
23309
  */ _proto.end = function end() {
23157
23310
  this.flushBatch();
23311
+ this.clipStack = [];
23312
+ this.engine.setScissorTest(false);
23158
23313
  };
23159
23314
  /**
23160
23315
  * 切换到指定批次类型/纹理。若与当前批次不一致,先 flush 已累积顶点
@@ -23167,6 +23322,24 @@ var Graphics = /*#__PURE__*/ function() {
23167
23322
  this.currentBatchType = type;
23168
23323
  this.currentBatchTexture = texture;
23169
23324
  };
23325
+ _proto.applyClipRect = function applyClipRect(clip) {
23326
+ var framebufferWidth = this.engine.canvas.width;
23327
+ var framebufferHeight = this.engine.canvas.height;
23328
+ var scaleX = framebufferWidth / this.logicalWidth;
23329
+ var scaleY = framebufferHeight / this.logicalHeight;
23330
+ var left = Math.max(0, Math.min(framebufferWidth, Math.floor(clip.x * scaleX)));
23331
+ var top = Math.max(0, Math.min(framebufferHeight, Math.floor(clip.y * scaleY)));
23332
+ var right = Math.max(left, Math.min(framebufferWidth, Math.ceil((clip.x + clip.width) * scaleX)));
23333
+ var bottom = Math.max(top, Math.min(framebufferHeight, Math.ceil((clip.y + clip.height) * scaleY)));
23334
+ this.engine.setScissorTest(true);
23335
+ this.engine.setScissor(left, framebufferHeight - bottom, right - left, bottom - top);
23336
+ };
23337
+ _proto.clipRectsEqual = function clipRectsEqual(left, right) {
23338
+ if (!left || !right) {
23339
+ return left === right;
23340
+ }
23341
+ return left.x === right.x && left.y === right.y && left.width === right.width && left.height === right.height;
23342
+ };
23170
23343
  /**
23171
23344
  * 提交当前累积的顶点到 renderer,清空缓冲(批次内部 flush 不重置 batchType)
23172
23345
  */ _proto.flushBatch = function flushBatch() {
@@ -23180,37 +23353,48 @@ var Graphics = /*#__PURE__*/ function() {
23180
23353
  var colorsArray = new Float32Array(this.colors);
23181
23354
  var uvsArray = new Float32Array(this.uvs);
23182
23355
  var indicesArray = new Uint16Array(this.indices);
23183
- this.updateAttributeData(VertexBuffer.PositionKind, verticesArray, 2);
23184
- this.updateAttributeData(VertexBuffer.ColorKind, colorsArray, 4);
23185
- this.updateAttributeData(VertexBuffer.UVKind, uvsArray, 2);
23186
- this.geometry.setIndexData(indicesArray);
23187
- this.geometry.setDrawCount(this.currentIndexCount);
23356
+ var geometry = this.currentBatchType === "ninePatch" ? this.ninePatchGeometry : this.geometry;
23357
+ this.updateAttributeData(geometry, VertexBuffer.PositionKind, verticesArray, 2);
23358
+ this.updateAttributeData(geometry, VertexBuffer.ColorKind, colorsArray, 4);
23359
+ this.updateAttributeData(geometry, VertexBuffer.UVKind, uvsArray, 2);
23360
+ if (this.currentBatchType === "ninePatch") {
23361
+ this.updateAttributeData(geometry, NINE_PATCH_DRAW_SOURCE_SIZE, new Float32Array(this.ninePatchDrawSourceSizes), 4);
23362
+ this.updateAttributeData(geometry, NINE_PATCH_SOURCE_RECT, new Float32Array(this.ninePatchSourceRects), 4);
23363
+ this.updateAttributeData(geometry, NINE_PATCH_MARGINS, new Float32Array(this.ninePatchMargins), 4);
23364
+ this.updateAttributeData(geometry, NINE_PATCH_OPTIONS, new Float32Array(this.ninePatchOptions), 4);
23365
+ }
23366
+ geometry.setIndexData(indicesArray);
23367
+ geometry.setDrawCount(this.currentIndexCount);
23188
23368
  var material;
23189
- if (this.currentBatchType === "textured" || this.currentBatchType === "text") {
23190
- material = this.currentBatchType === "text" ? this.textMaterial : this.texturedMaterial;
23369
+ if (this.currentBatchType === "textured" || this.currentBatchType === "text" || this.currentBatchType === "ninePatch") {
23370
+ material = this.currentBatchType === "text" ? this.textMaterial : this.currentBatchType === "ninePatch" ? this.ninePatchMaterial : this.texturedMaterial;
23191
23371
  var _this_currentBatchTexture;
23192
23372
  var tex = (_this_currentBatchTexture = this.currentBatchTexture) != null ? _this_currentBatchTexture : this.engine.whiteTexture;
23193
23373
  material.setTexture("uMainTexture", tex);
23194
23374
  } else {
23195
23375
  material = this.coloredMaterial;
23196
23376
  }
23197
- this.engine.renderer.drawGeometry(this.geometry, Matrix4.IDENTITY, material);
23377
+ this.engine.renderer.drawGeometry(geometry, Matrix4.IDENTITY, material);
23198
23378
  this.indices.length = 0;
23199
23379
  this.vertices.length = 0;
23200
23380
  this.colors.length = 0;
23201
23381
  this.uvs.length = 0;
23202
- };
23203
- _proto.updateAttributeData = function updateAttributeData(name, data, size) {
23204
- var _this_geometry_getVertexBuffer;
23205
- var dataBuffer = (_this_geometry_getVertexBuffer = this.geometry.getVertexBuffer(name)) == null ? void 0 : _this_geometry_getVertexBuffer.getBuffer();
23382
+ this.ninePatchDrawSourceSizes.length = 0;
23383
+ this.ninePatchSourceRects.length = 0;
23384
+ this.ninePatchMargins.length = 0;
23385
+ this.ninePatchOptions.length = 0;
23386
+ };
23387
+ _proto.updateAttributeData = function updateAttributeData(geometry, name, data, size) {
23388
+ var _geometry_getVertexBuffer;
23389
+ var dataBuffer = (_geometry_getVertexBuffer = geometry.getVertexBuffer(name)) == null ? void 0 : _geometry_getVertexBuffer.getBuffer();
23206
23390
  if (dataBuffer && data.byteLength > dataBuffer.capacity) {
23207
- this.geometry.setVerticesBuffer(new VertexBuffer(this.engine, data, name, {
23391
+ geometry.setVerticesBuffer(new VertexBuffer(this.engine, data, name, {
23208
23392
  updatable: true,
23209
23393
  size: size
23210
23394
  }));
23211
23395
  return;
23212
23396
  }
23213
- this.geometry.setAttributeData(name, data);
23397
+ geometry.setAttributeData(name, data);
23214
23398
  };
23215
23399
  /**
23216
23400
  * 线段顶点按顺序连接 (p0-p1, p1-p2, p2-p3, ...)
@@ -23379,10 +23563,37 @@ var Graphics = /*#__PURE__*/ function() {
23379
23563
  this.pushQuad(x, y, width, height, color, region);
23380
23564
  };
23381
23565
  /**
23566
+ * Draws a nine-patch as one quad. Stretching and repetition are resolved in the fragment shader,
23567
+ * so Tile and TileFit do not expand into CPU-side geometry.
23568
+ */ _proto.drawNinePatch = function drawNinePatch(x, y, width, height, texture, options, color) {
23569
+ if (color === void 0) color = Color.WHITE;
23570
+ if (width <= 0 || height <= 0 || options.sourceWidth <= 0 || options.sourceHeight <= 0) {
23571
+ return;
23572
+ }
23573
+ this.ensureBatch("ninePatch", texture);
23574
+ var sourceU = options.sourceX / texture.width;
23575
+ var sourceV = 1 - options.sourceY / texture.height;
23576
+ var sourceUSize = options.sourceWidth / texture.width;
23577
+ var sourceVSize = options.sourceHeight / texture.height;
23578
+ var _options_horizontalMode;
23579
+ var horizontalMode = (_options_horizontalMode = options.horizontalMode) != null ? _options_horizontalMode : 0;
23580
+ var _options_verticalMode;
23581
+ var verticalMode = (_options_verticalMode = options.verticalMode) != null ? _options_verticalMode : 0;
23582
+ var _options_drawCenter;
23583
+ var drawCenter = Number((_options_drawCenter = options.drawCenter) != null ? _options_drawCenter : true);
23584
+ this.pushQuad(x, y, width, height, color, FULL_REGION);
23585
+ for(var i = 0; i < 4; i++){
23586
+ this.ninePatchDrawSourceSizes.push(width, height, options.sourceWidth, options.sourceHeight);
23587
+ this.ninePatchSourceRects.push(sourceU, sourceV, sourceUSize, sourceVSize);
23588
+ this.ninePatchMargins.push(options.marginLeft, options.marginTop, options.marginRight, options.marginBottom);
23589
+ this.ninePatchOptions.push(horizontalMode, verticalMode, drawCenter, 0);
23590
+ }
23591
+ };
23592
+ /**
23382
23593
  * 绘制文本(本地坐标,Y 向下,(x, y) 为文本 cell 左上角)。
23383
23594
  *
23384
23595
  * 文本走字符级 bitmap atlas(同一字体下每个字只渲染一次,任意文本组合复用 atlas);
23385
- * `color` 作为乘色与白色字形 alpha 相乘,任意颜色都不会污染 atlas。
23596
+ * `color` atlas 字形 RGBA 相乘,任意颜色都不会污染 atlas。
23386
23597
  *
23387
23598
  * 字体参数全部展开,避免调用方每帧创建临时 style 对象触发 GC
23388
23599
  * @param x - 文本左上角 X 坐标(首字 ink 起始处,含 padding 的 quad 会向左延伸)
@@ -23405,10 +23616,11 @@ var Graphics = /*#__PURE__*/ function() {
23405
23616
  this.ensureBatch("text", atlas.texture);
23406
23617
  var lineHeight = atlas.lineHeight;
23407
23618
  var cursorX = x;
23619
+ var characters = Array.from(text);
23408
23620
  // ensureChar 可能往 atlas canvas 写新字并打 dirty 标;实际 upload 推迟到
23409
23621
  // flushBatch 统一处理,这样一帧多次 drawText 共写同一 atlas 只 upload 一次
23410
- for(var i = 0; i < text.length; i++){
23411
- var info = atlas.ensureChar(text[i]);
23622
+ for(var i = 0; i < characters.length; i++){
23623
+ var info = atlas.ensureChar(characters[i]);
23412
23624
  if (!info) {
23413
23625
  continue;
23414
23626
  }
@@ -23430,11 +23642,35 @@ var Graphics = /*#__PURE__*/ function() {
23430
23642
  cursorX += info.advance;
23431
23643
  }
23432
23644
  };
23645
+ /** Measures text with the same glyph metrics used by {@link drawText}. */ _proto.measureText = function measureText(text, fontSize, fontFamily, fontWeight, fontStyle) {
23646
+ if (fontFamily === void 0) fontFamily = "sans-serif";
23647
+ if (fontWeight === void 0) fontWeight = "normal";
23648
+ if (fontStyle === void 0) fontStyle = "normal";
23649
+ var atlas = this.textCache.getAtlas(fontSize, fontFamily, fontWeight, fontStyle);
23650
+ var characters = Array.from(text);
23651
+ var advances = [];
23652
+ var width = 0;
23653
+ for(var _iterator = _create_for_of_iterator_helper_loose(characters), _step; !(_step = _iterator()).done;){
23654
+ var character = _step.value;
23655
+ var _atlas_ensureChar;
23656
+ var _atlas_ensureChar_advance;
23657
+ var advance = (_atlas_ensureChar_advance = (_atlas_ensureChar = atlas.ensureChar(character)) == null ? void 0 : _atlas_ensureChar.advance) != null ? _atlas_ensureChar_advance : 0;
23658
+ advances.push(advance);
23659
+ width += advance;
23660
+ }
23661
+ return {
23662
+ width: width,
23663
+ lineHeight: atlas.lineHeight,
23664
+ advances: advances
23665
+ };
23666
+ };
23433
23667
  _proto.dispose = function dispose() {
23434
23668
  this.geometry.dispose();
23669
+ this.ninePatchGeometry.dispose();
23435
23670
  this.coloredMaterial.dispose();
23436
23671
  this.texturedMaterial.dispose();
23437
23672
  this.textMaterial.dispose();
23673
+ this.ninePatchMaterial.dispose();
23438
23674
  this.textCache.dispose();
23439
23675
  };
23440
23676
  _proto.buildShape = function buildShape(shape, color) {
@@ -23442,7 +23678,7 @@ var Graphics = /*#__PURE__*/ function() {
23442
23678
  var indexOffset = this.indices.length;
23443
23679
  var vertexOffset = this.vertices.length / 2;
23444
23680
  buildPoints.length = 0;
23445
- shape.build(buildPoints);
23681
+ shape.build(buildPoints, this.getScreenScale());
23446
23682
  shape.triangulate(buildPoints, this.vertices, vertexOffset, this.indices, indexOffset);
23447
23683
  this.applyTransformAndColor(vertexOffset, this.vertices.length / 2 - vertexOffset, color);
23448
23684
  };
@@ -23452,11 +23688,19 @@ var Graphics = /*#__PURE__*/ function() {
23452
23688
  this.indices.length;
23453
23689
  var vertexOffset = this.vertices.length / 2;
23454
23690
  buildPoints.length = 0;
23455
- shape.build(buildPoints);
23691
+ shape.build(buildPoints, this.getScreenScale());
23456
23692
  this.lineStyle.width = thickness;
23457
23693
  buildLine(buildPoints, this.lineStyle, false, closed, this.vertices, 2, vertexOffset, this.indices);
23458
23694
  this.applyTransformAndColor(vertexOffset, this.vertices.length / 2 - vertexOffset, color);
23459
23695
  };
23696
+ _proto.getScreenScale = function getScreenScale() {
23697
+ var transform = this.currentTransform.elements;
23698
+ var transformScaleX = Math.hypot(transform[0], transform[1]);
23699
+ var transformScaleY = Math.hypot(transform[3], transform[4]);
23700
+ var framebufferScaleX = this.engine.canvas.width / this.logicalWidth;
23701
+ var framebufferScaleY = this.engine.canvas.height / this.logicalHeight;
23702
+ return Math.max(transformScaleX * framebufferScaleX, transformScaleY * framebufferScaleY, 1);
23703
+ };
23460
23704
  _proto.setTriangleShape = function setTriangleShape(x1, y1, x2, y2, x3, y3) {
23461
23705
  this.triangleShape.x = x1;
23462
23706
  this.triangleShape.y = y1;
@@ -24505,2107 +24749,6 @@ exports.FrameComponent = __decorate([
24505
24749
  // 第四列 (位移) 乘 1,无需修改
24506
24750
  }
24507
24751
 
24508
- function _assert_this_initialized(self) {
24509
- if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
24510
- return self;
24511
- }
24512
-
24513
- exports.MouseFilter = void 0;
24514
- (function(MouseFilter) {
24515
- MouseFilter[MouseFilter["Stop"] = 0] = "Stop";
24516
- MouseFilter[MouseFilter["Pass"] = 1] = "Pass";
24517
- MouseFilter[MouseFilter["Ignore"] = 2] = "Ignore";
24518
- })(exports.MouseFilter || (exports.MouseFilter = {}));
24519
- exports.MouseBehaviorRecursive = void 0;
24520
- (function(MouseBehaviorRecursive) {
24521
- MouseBehaviorRecursive[MouseBehaviorRecursive["Inherited"] = 0] = "Inherited";
24522
- MouseBehaviorRecursive[MouseBehaviorRecursive["Disabled"] = 1] = "Disabled";
24523
- MouseBehaviorRecursive[MouseBehaviorRecursive["Enabled"] = 2] = "Enabled";
24524
- })(exports.MouseBehaviorRecursive || (exports.MouseBehaviorRecursive = {}));
24525
- exports.MouseButton = void 0;
24526
- (function(MouseButton) {
24527
- MouseButton[MouseButton["None"] = 0] = "None";
24528
- MouseButton[MouseButton["Left"] = 1] = "Left";
24529
- MouseButton[MouseButton["Right"] = 2] = "Right";
24530
- MouseButton[MouseButton["Middle"] = 3] = "Middle";
24531
- MouseButton[MouseButton["WheelUp"] = 4] = "WheelUp";
24532
- MouseButton[MouseButton["WheelDown"] = 5] = "WheelDown";
24533
- MouseButton[MouseButton["WheelLeft"] = 6] = "WheelLeft";
24534
- MouseButton[MouseButton["WheelRight"] = 7] = "WheelRight";
24535
- MouseButton[MouseButton["Xbutton1"] = 8] = "Xbutton1";
24536
- MouseButton[MouseButton["Xbutton2"] = 9] = "Xbutton2";
24537
- })(exports.MouseButton || (exports.MouseButton = {}));
24538
- exports.MouseButtonMask = void 0;
24539
- (function(MouseButtonMask) {
24540
- MouseButtonMask[MouseButtonMask["None"] = 0] = "None";
24541
- MouseButtonMask[MouseButtonMask["Left"] = 1] = "Left";
24542
- MouseButtonMask[MouseButtonMask["Right"] = 2] = "Right";
24543
- MouseButtonMask[MouseButtonMask["Middle"] = 4] = "Middle";
24544
- MouseButtonMask[MouseButtonMask["Xbutton1"] = 128] = "Xbutton1";
24545
- MouseButtonMask[MouseButtonMask["Xbutton2"] = 256] = "Xbutton2";
24546
- })(exports.MouseButtonMask || (exports.MouseButtonMask = {}));
24547
- exports.FocusMode = void 0;
24548
- (function(FocusMode) {
24549
- FocusMode[FocusMode["None"] = 0] = "None";
24550
- FocusMode[FocusMode["Click"] = 1] = "Click";
24551
- FocusMode[FocusMode["All"] = 2] = "All";
24552
- FocusMode[FocusMode["Accessibility"] = 3] = "Accessibility";
24553
- })(exports.FocusMode || (exports.FocusMode = {}));
24554
- exports.FocusBehaviorRecursive = void 0;
24555
- (function(FocusBehaviorRecursive) {
24556
- FocusBehaviorRecursive[FocusBehaviorRecursive["Inherited"] = 0] = "Inherited";
24557
- FocusBehaviorRecursive[FocusBehaviorRecursive["Disabled"] = 1] = "Disabled";
24558
- FocusBehaviorRecursive[FocusBehaviorRecursive["Enabled"] = 2] = "Enabled";
24559
- })(exports.FocusBehaviorRecursive || (exports.FocusBehaviorRecursive = {}));
24560
- exports.KeyLocation = void 0;
24561
- (function(KeyLocation) {
24562
- KeyLocation[KeyLocation["Unspecified"] = 0] = "Unspecified";
24563
- KeyLocation[KeyLocation["Left"] = 1] = "Left";
24564
- KeyLocation[KeyLocation["Right"] = 2] = "Right";
24565
- })(exports.KeyLocation || (exports.KeyLocation = {}));
24566
- exports.CursorShape = void 0;
24567
- (function(CursorShape) {
24568
- CursorShape[CursorShape["Arrow"] = 0] = "Arrow";
24569
- CursorShape[CursorShape["Ibeam"] = 1] = "Ibeam";
24570
- CursorShape[CursorShape["PointingHand"] = 2] = "PointingHand";
24571
- CursorShape[CursorShape["Cross"] = 3] = "Cross";
24572
- CursorShape[CursorShape["Wait"] = 4] = "Wait";
24573
- CursorShape[CursorShape["Busy"] = 5] = "Busy";
24574
- CursorShape[CursorShape["Drag"] = 6] = "Drag";
24575
- CursorShape[CursorShape["CanDrop"] = 7] = "CanDrop";
24576
- CursorShape[CursorShape["Forbidden"] = 8] = "Forbidden";
24577
- CursorShape[CursorShape["Vsize"] = 9] = "Vsize";
24578
- CursorShape[CursorShape["Hsize"] = 10] = "Hsize";
24579
- CursorShape[CursorShape["Bdiagsize"] = 11] = "Bdiagsize";
24580
- CursorShape[CursorShape["Fdiagsize"] = 12] = "Fdiagsize";
24581
- CursorShape[CursorShape["Move"] = 13] = "Move";
24582
- CursorShape[CursorShape["Vsplit"] = 14] = "Vsplit";
24583
- CursorShape[CursorShape["Hsplit"] = 15] = "Hsplit";
24584
- CursorShape[CursorShape["Help"] = 16] = "Help";
24585
- })(exports.CursorShape || (exports.CursorShape = {}));
24586
-
24587
- function _get_prototype_of(o) {
24588
- _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
24589
- return o.__proto__ || Object.getPrototypeOf(o);
24590
- };
24591
- return _get_prototype_of(o);
24592
- }
24593
-
24594
- function _is_native_function(fn) {
24595
- return Function.toString.call(fn).indexOf("[native code]") !== -1;
24596
- }
24597
-
24598
- function _wrap_native_super(Class) {
24599
- var _cache = typeof Map === "function" ? new Map() : undefined;
24600
- _wrap_native_super = function _wrap_native_super(Class) {
24601
- if (Class === null || !_is_native_function(Class)) return Class;
24602
- if (typeof Class !== "function") throw new TypeError("Super expression must either be null or a function");
24603
- if (typeof _cache !== "undefined") {
24604
- if (_cache.has(Class)) return _cache.get(Class);
24605
- _cache.set(Class, Wrapper);
24606
- }
24607
- function Wrapper() {
24608
- return _construct(Class, arguments, _get_prototype_of(this).constructor);
24609
- }
24610
- Wrapper.prototype = Object.create(Class.prototype, {
24611
- constructor: {
24612
- value: Wrapper,
24613
- enumerable: false,
24614
- writable: true,
24615
- configurable: true
24616
- }
24617
- });
24618
- return _set_prototype_of(Wrapper, Class);
24619
- };
24620
- return _wrap_native_super(Class);
24621
- }
24622
-
24623
- function transformPoint(transform, value) {
24624
- var elements = transform.elements;
24625
- return new Vector2(elements[0] * value.x + elements[3] * value.y + elements[6], elements[1] * value.x + elements[4] * value.y + elements[7]);
24626
- }
24627
- function transformVector(transform, value) {
24628
- var elements = transform.elements;
24629
- return new Vector2(elements[0] * value.x + elements[3] * value.y, elements[1] * value.x + elements[4] * value.y);
24630
- }
24631
- var InputEvent = /*#__PURE__*/ function() {
24632
- function InputEvent() {
24633
- this.device = 0;
24634
- this.pressed = false;
24635
- this.canceled = false;
24636
- this._accepted = false;
24637
- }
24638
- var _proto = InputEvent.prototype;
24639
- _proto.accept = function accept() {
24640
- this._accepted = true;
24641
- };
24642
- _proto.clearAccepted = function clearAccepted() {
24643
- this._accepted = false;
24644
- };
24645
- _proto.isAccepted = function isAccepted() {
24646
- return this._accepted;
24647
- };
24648
- _proto.isPressed = function isPressed() {
24649
- return this.pressed && !this.canceled;
24650
- };
24651
- _proto.isReleased = function isReleased() {
24652
- return !this.pressed && !this.canceled;
24653
- };
24654
- _proto.isCanceled = function isCanceled() {
24655
- return this.canceled;
24656
- };
24657
- _proto.isEcho = function isEcho() {
24658
- return false;
24659
- };
24660
- _proto.xformedBy = function xformedBy(transform) {
24661
- return this;
24662
- };
24663
- return InputEvent;
24664
- }();
24665
- InputEvent.deviceIdEmulation = -1;
24666
- InputEvent.deviceIdInternal = -2;
24667
- InputEvent.deviceIdKeyboard = 16;
24668
- InputEvent.deviceIdMouse = 32;
24669
- var InputEventWithModifiers = /*#__PURE__*/ function(InputEvent) {
24670
- _inherits(InputEventWithModifiers, InputEvent);
24671
- function InputEventWithModifiers() {
24672
- var _this;
24673
- _this = InputEvent.apply(this, arguments) || this;
24674
- _this.commandOrControlAutoremap = false;
24675
- _this.shiftPressed = false;
24676
- _this.altPressed = false;
24677
- _this.metaPressed = false;
24678
- _this.ctrlPressed = false;
24679
- return _this;
24680
- }
24681
- var _proto = InputEventWithModifiers.prototype;
24682
- _proto.copyModifiersTo = function copyModifiersTo(event) {
24683
- event.device = this.device;
24684
- event.pressed = this.pressed;
24685
- event.canceled = this.canceled;
24686
- event.commandOrControlAutoremap = this.commandOrControlAutoremap;
24687
- event.shiftPressed = this.shiftPressed;
24688
- event.altPressed = this.altPressed;
24689
- event.metaPressed = this.metaPressed;
24690
- event.ctrlPressed = this.ctrlPressed;
24691
- };
24692
- return InputEventWithModifiers;
24693
- }(_wrap_native_super(InputEvent));
24694
- var InputEventKey = /*#__PURE__*/ function(InputEventWithModifiers) {
24695
- _inherits(InputEventKey, InputEventWithModifiers);
24696
- function InputEventKey() {
24697
- var _this;
24698
- _this = InputEventWithModifiers.apply(this, arguments) || this;
24699
- _this.keycode = "";
24700
- _this.physicalKeycode = "";
24701
- _this.keyLabel = "";
24702
- _this.unicode = 0;
24703
- _this.location = exports.KeyLocation.Unspecified;
24704
- _this.echo = false;
24705
- return _this;
24706
- }
24707
- var _proto = InputEventKey.prototype;
24708
- _proto.isEcho = function isEcho() {
24709
- return this.echo;
24710
- };
24711
- return InputEventKey;
24712
- }(InputEventWithModifiers);
24713
- var InputEventMouse = /*#__PURE__*/ function(InputEventWithModifiers) {
24714
- _inherits(InputEventMouse, InputEventWithModifiers);
24715
- function InputEventMouse() {
24716
- var _this;
24717
- _this = InputEventWithModifiers.apply(this, arguments) || this;
24718
- _this.buttonMask = exports.MouseButtonMask.None;
24719
- _this.position = new Vector2();
24720
- _this.globalPosition = new Vector2();
24721
- return _this;
24722
- }
24723
- var _proto = InputEventMouse.prototype;
24724
- _proto.copyMouseTo = function copyMouseTo(event) {
24725
- this.copyModifiersTo(event);
24726
- event.buttonMask = this.buttonMask;
24727
- event.position.copyFrom(this.position);
24728
- event.globalPosition.copyFrom(this.globalPosition);
24729
- };
24730
- return InputEventMouse;
24731
- }(InputEventWithModifiers);
24732
- var InputEventMouseButton = /*#__PURE__*/ function(InputEventMouse) {
24733
- _inherits(InputEventMouseButton, InputEventMouse);
24734
- function InputEventMouseButton() {
24735
- var _this;
24736
- _this = InputEventMouse.apply(this, arguments) || this;
24737
- _this.factor = 1;
24738
- _this.buttonIndex = exports.MouseButton.None;
24739
- _this.doubleClick = false;
24740
- return _this;
24741
- }
24742
- var _proto = InputEventMouseButton.prototype;
24743
- _proto.xformedBy = function xformedBy(transform) {
24744
- var event = new InputEventMouseButton();
24745
- this.copyMouseTo(event);
24746
- event.position.copyFrom(transformPoint(transform, this.position));
24747
- event.factor = this.factor;
24748
- event.buttonIndex = this.buttonIndex;
24749
- event.doubleClick = this.doubleClick;
24750
- return event;
24751
- };
24752
- return InputEventMouseButton;
24753
- }(InputEventMouse);
24754
- var InputEventMouseMotion = /*#__PURE__*/ function(InputEventMouse) {
24755
- _inherits(InputEventMouseMotion, InputEventMouse);
24756
- function InputEventMouseMotion() {
24757
- var _this;
24758
- _this = InputEventMouse.apply(this, arguments) || this;
24759
- _this.tilt = new Vector2();
24760
- _this.pressure = 0;
24761
- _this.relative = new Vector2();
24762
- _this.screenRelative = new Vector2();
24763
- _this.velocity = new Vector2();
24764
- _this.screenVelocity = new Vector2();
24765
- _this.penInverted = false;
24766
- return _this;
24767
- }
24768
- var _proto = InputEventMouseMotion.prototype;
24769
- _proto.xformedBy = function xformedBy(transform) {
24770
- var event = new InputEventMouseMotion();
24771
- this.copyMouseTo(event);
24772
- event.position.copyFrom(transformPoint(transform, this.position));
24773
- event.tilt.copyFrom(this.tilt);
24774
- event.pressure = this.pressure;
24775
- event.relative.copyFrom(transformVector(transform, this.relative));
24776
- event.screenRelative.copyFrom(this.screenRelative);
24777
- event.velocity.copyFrom(transformVector(transform, this.velocity));
24778
- event.screenVelocity.copyFrom(this.screenVelocity);
24779
- event.penInverted = this.penInverted;
24780
- return event;
24781
- };
24782
- return InputEventMouseMotion;
24783
- }(InputEventMouse);
24784
- var InputEventScreenTouch = /*#__PURE__*/ function(InputEvent) {
24785
- _inherits(InputEventScreenTouch, InputEvent);
24786
- function InputEventScreenTouch() {
24787
- var _this;
24788
- _this = InputEvent.apply(this, arguments) || this;
24789
- _this.index = 0;
24790
- _this.position = new Vector2();
24791
- _this.doubleTap = false;
24792
- return _this;
24793
- }
24794
- var _proto = InputEventScreenTouch.prototype;
24795
- _proto.xformedBy = function xformedBy(transform) {
24796
- var event = new InputEventScreenTouch();
24797
- event.device = this.device;
24798
- event.pressed = this.pressed;
24799
- event.canceled = this.canceled;
24800
- event.index = this.index;
24801
- event.position.copyFrom(transformPoint(transform, this.position));
24802
- event.doubleTap = this.doubleTap;
24803
- return event;
24804
- };
24805
- return InputEventScreenTouch;
24806
- }(_wrap_native_super(InputEvent));
24807
- var InputEventScreenDrag = /*#__PURE__*/ function(InputEvent) {
24808
- _inherits(InputEventScreenDrag, InputEvent);
24809
- function InputEventScreenDrag() {
24810
- var _this;
24811
- _this = InputEvent.apply(this, arguments) || this;
24812
- _this.index = 0;
24813
- _this.position = new Vector2();
24814
- _this.relative = new Vector2();
24815
- _this.screenRelative = new Vector2();
24816
- _this.velocity = new Vector2();
24817
- _this.screenVelocity = new Vector2();
24818
- _this.pressure = 0;
24819
- _this.tilt = new Vector2();
24820
- _this.penInverted = false;
24821
- return _this;
24822
- }
24823
- var _proto = InputEventScreenDrag.prototype;
24824
- _proto.xformedBy = function xformedBy(transform) {
24825
- var event = new InputEventScreenDrag();
24826
- event.device = this.device;
24827
- event.pressed = this.pressed;
24828
- event.canceled = this.canceled;
24829
- event.index = this.index;
24830
- event.position.copyFrom(transformPoint(transform, this.position));
24831
- event.relative.copyFrom(transformVector(transform, this.relative));
24832
- event.screenRelative.copyFrom(this.screenRelative);
24833
- event.velocity.copyFrom(transformVector(transform, this.velocity));
24834
- event.screenVelocity.copyFrom(this.screenVelocity);
24835
- event.pressure = this.pressure;
24836
- event.tilt.copyFrom(this.tilt);
24837
- event.penInverted = this.penInverted;
24838
- return event;
24839
- };
24840
- return InputEventScreenDrag;
24841
- }(_wrap_native_super(InputEvent));
24842
-
24843
- var ANCHOR_PRESET_TABLE = {
24844
- topLeft: [
24845
- 0,
24846
- 0,
24847
- 0,
24848
- 0
24849
- ],
24850
- topRight: [
24851
- 1,
24852
- 0,
24853
- 1,
24854
- 0
24855
- ],
24856
- bottomLeft: [
24857
- 0,
24858
- 1,
24859
- 0,
24860
- 1
24861
- ],
24862
- bottomRight: [
24863
- 1,
24864
- 1,
24865
- 1,
24866
- 1
24867
- ],
24868
- centerLeft: [
24869
- 0,
24870
- 0.5,
24871
- 0,
24872
- 0.5
24873
- ],
24874
- centerTop: [
24875
- 0.5,
24876
- 0,
24877
- 0.5,
24878
- 0
24879
- ],
24880
- centerRight: [
24881
- 1,
24882
- 0.5,
24883
- 1,
24884
- 0.5
24885
- ],
24886
- centerBottom: [
24887
- 0.5,
24888
- 1,
24889
- 0.5,
24890
- 1
24891
- ],
24892
- center: [
24893
- 0.5,
24894
- 0.5,
24895
- 0.5,
24896
- 0.5
24897
- ],
24898
- leftWide: [
24899
- 0,
24900
- 0,
24901
- 0,
24902
- 1
24903
- ],
24904
- topWide: [
24905
- 0,
24906
- 0,
24907
- 1,
24908
- 0
24909
- ],
24910
- rightWide: [
24911
- 1,
24912
- 0,
24913
- 1,
24914
- 1
24915
- ],
24916
- bottomWide: [
24917
- 0,
24918
- 1,
24919
- 1,
24920
- 1
24921
- ],
24922
- vcenterWide: [
24923
- 0.5,
24924
- 0,
24925
- 0.5,
24926
- 1
24927
- ],
24928
- hcenterWide: [
24929
- 0,
24930
- 0.5,
24931
- 1,
24932
- 0.5
24933
- ],
24934
- fullRect: [
24935
- 0,
24936
- 0,
24937
- 1,
24938
- 1
24939
- ]
24940
- };
24941
- /**
24942
- * A drawable GUI object. Controls form a tree independent from the VFXItem
24943
- * scene tree. UIControl is the bridge between both trees.
24944
- */ var Control = /*#__PURE__*/ function() {
24945
- function Control(engine) {
24946
- this.engine = engine;
24947
- this._parent = null;
24948
- this._visible = true;
24949
- this._enabled = true;
24950
- this._mouseFilter = exports.MouseFilter.Stop;
24951
- this._mouseBehaviorRecursive = exports.MouseBehaviorRecursive.Inherited;
24952
- this._focusMode = exports.FocusMode.None;
24953
- this._focusBehaviorRecursive = exports.FocusBehaviorRecursive.Inherited;
24954
- this._defaultCursorShape = exports.CursorShape.Arrow;
24955
- this._rotation = 0;
24956
- this.transformDirty = true;
24957
- this.cachedTransform = new Matrix3();
24958
- this.eventEmitter = new EventEmitter();
24959
- this.disposed = false;
24960
- this./** Scene-tree bridge that owns this GUI object, if any. */ owner = null;
24961
- this.position = new Vector2();
24962
- this.size = new Vector2(1, 1);
24963
- this.anchorMin = new Vector2();
24964
- this.anchorMax = new Vector2();
24965
- this.offsetMin = new Vector2();
24966
- this.offsetMax = new Vector2(1, 1);
24967
- this.pivot = new Vector2(0.5, 0.5);
24968
- this.scale = new Vector2(1, 1);
24969
- this.shear = new Vector2();
24970
- this.mouseForcePassScrollEvents = true;
24971
- this.clipContents = false;
24972
- }
24973
- var _proto = Control.prototype;
24974
- _proto.on = function on(eventName, listener, options) {
24975
- this.eventEmitter.on(eventName, listener, options);
24976
- };
24977
- _proto.off = function off(eventName, listener) {
24978
- this.eventEmitter.off(eventName, listener);
24979
- };
24980
- _proto.setPosition = function setPosition(x, y, keepOffsets) {
24981
- if (keepOffsets === void 0) keepOffsets = false;
24982
- if (this.position.x === x && this.position.y === y) {
24983
- return;
24984
- }
24985
- var rect = {
24986
- position: new Vector2(x, y),
24987
- size: this.size.clone()
24988
- };
24989
- if (keepOffsets && this.parent) {
24990
- this.computeAnchors(rect, this.getParentRect());
24991
- } else {
24992
- this.computeOffsets(rect, this.getParentRect());
24993
- }
24994
- this.updateLayout();
24995
- };
24996
- _proto.setSize = function setSize(width, height) {
24997
- if (this.size.x === width && this.size.y === height) {
24998
- return;
24999
- }
25000
- var rect = {
25001
- position: this.position.clone(),
25002
- size: new Vector2(width, height)
25003
- };
25004
- this.computeOffsets(rect, this.getParentRect());
25005
- this.updateLayout();
25006
- };
25007
- _proto.setScale = function setScale(x, y) {
25008
- if (this.scale.x !== x || this.scale.y !== y) {
25009
- this.scale.set(x, y);
25010
- this.markTransformDirty();
25011
- }
25012
- };
25013
- _proto.setRotation = function setRotation(degrees) {
25014
- if (this._rotation !== degrees) {
25015
- this._rotation = degrees;
25016
- this.markTransformDirty();
25017
- }
25018
- };
25019
- _proto.setShear = function setShear(x, y) {
25020
- if (this.shear.x !== x || this.shear.y !== y) {
25021
- this.shear.set(x, y);
25022
- this.markTransformDirty();
25023
- }
25024
- };
25025
- _proto.setPivot = function setPivot(x, y) {
25026
- if (this.pivot.x !== x || this.pivot.y !== y) {
25027
- this.pivot.set(x, y);
25028
- this.markTransformDirty();
25029
- }
25030
- };
25031
- _proto.setAnchorMin = function setAnchorMin(x, y) {
25032
- if (this.anchorMin.x !== x || this.anchorMin.y !== y) {
25033
- this.anchorMin.set(x, y);
25034
- this.updateLayout();
25035
- }
25036
- };
25037
- _proto.setAnchorMax = function setAnchorMax(x, y) {
25038
- if (this.anchorMax.x !== x || this.anchorMax.y !== y) {
25039
- this.anchorMax.set(x, y);
25040
- this.updateLayout();
25041
- }
25042
- };
25043
- _proto.setOffsetMin = function setOffsetMin(x, y) {
25044
- if (this.offsetMin.x !== x || this.offsetMin.y !== y) {
25045
- this.offsetMin.set(x, y);
25046
- this.updateLayout();
25047
- }
25048
- };
25049
- _proto.setOffsetMax = function setOffsetMax(x, y) {
25050
- if (this.offsetMax.x !== x || this.offsetMax.y !== y) {
25051
- this.offsetMax.set(x, y);
25052
- this.updateLayout();
25053
- }
25054
- };
25055
- _proto.getRect = function getRect() {
25056
- return {
25057
- position: this.position.clone(),
25058
- size: this.size.clone()
25059
- };
25060
- };
25061
- _proto.getTransform2D = function getTransform2D() {
25062
- if (this.transformDirty) {
25063
- var radians = this._rotation * Math.PI / 180;
25064
- var sin = Math.sin(radians);
25065
- var cos = Math.cos(radians);
25066
- var shearX = Math.tan(Math.max(-89, Math.min(89, this.shear.x)) * Math.PI / 180);
25067
- var shearY = Math.tan(Math.max(-89, Math.min(89, this.shear.y)) * Math.PI / 180);
25068
- var a = this.scale.x * (cos - sin * shearY);
25069
- var b = this.scale.x * (sin + cos * shearY);
25070
- var c = this.scale.y * (cos * shearX - sin);
25071
- var d = this.scale.y * (sin * shearX + cos);
25072
- var pivotX = this.pivot.x * this.size.x;
25073
- var pivotY = this.pivot.y * this.size.y;
25074
- var tx = this.position.x + pivotX - a * pivotX - c * pivotY;
25075
- var ty = this.position.y + pivotY - b * pivotX - d * pivotY;
25076
- this.cachedTransform.set(a, b, 0, c, d, 0, tx, ty, 1);
25077
- this.transformDirty = false;
25078
- }
25079
- return this.cachedTransform;
25080
- };
25081
- _proto.setAnchorsPreset = function setAnchorsPreset(preset, keepOffsets) {
25082
- if (keepOffsets === void 0) keepOffsets = true;
25083
- var _ANCHOR_PRESET_TABLE_preset = ANCHOR_PRESET_TABLE[preset], minX = _ANCHOR_PRESET_TABLE_preset[0], minY = _ANCHOR_PRESET_TABLE_preset[1], maxX = _ANCHOR_PRESET_TABLE_preset[2], maxY = _ANCHOR_PRESET_TABLE_preset[3];
25084
- if (keepOffsets) {
25085
- this.anchorMin.set(minX, minY);
25086
- this.anchorMax.set(maxX, maxY);
25087
- } else {
25088
- var rect = this.getRect();
25089
- this.anchorMin.set(minX, minY);
25090
- this.anchorMax.set(maxX, maxY);
25091
- this.computeOffsets(rect, this.getParentRect());
25092
- }
25093
- this.updateLayout();
25094
- };
25095
- _proto.setOffsetsPreset = function setOffsetsPreset(preset, margin) {
25096
- if (margin === void 0) margin = 0;
25097
- if (!this.parent) {
25098
- return;
25099
- }
25100
- var parentSize = this.parent.size;
25101
- var width = this.size.x;
25102
- var height = this.size.y;
25103
- var a = this.anchorMin;
25104
- var b = this.anchorMax;
25105
- var minX = 0, maxX = 0, minY = 0, maxY = 0;
25106
- // Left edge.
25107
- switch(preset){
25108
- case "topLeft":
25109
- case "bottomLeft":
25110
- case "centerLeft":
25111
- case "topWide":
25112
- case "bottomWide":
25113
- case "leftWide":
25114
- case "hcenterWide":
25115
- case "fullRect":
25116
- minX = margin - a.x * parentSize.x;
25117
- break;
25118
- case "centerTop":
25119
- case "centerBottom":
25120
- case "center":
25121
- case "vcenterWide":
25122
- minX = 0.5 * parentSize.x - width / 2 - a.x * parentSize.x;
25123
- break;
25124
- default:
25125
- minX = parentSize.x - margin - width - a.x * parentSize.x;
25126
- break;
25127
- }
25128
- switch(preset){
25129
- case "topLeft":
25130
- case "bottomLeft":
25131
- case "centerLeft":
25132
- case "leftWide":
25133
- maxX = margin + width - b.x * parentSize.x;
25134
- break;
25135
- case "centerTop":
25136
- case "centerBottom":
25137
- case "center":
25138
- case "vcenterWide":
25139
- maxX = 0.5 * parentSize.x + width / 2 - b.x * parentSize.x;
25140
- break;
25141
- default:
25142
- maxX = parentSize.x - margin - b.x * parentSize.x;
25143
- break;
25144
- }
25145
- // Top edge.
25146
- switch(preset){
25147
- case "topLeft":
25148
- case "topRight":
25149
- case "centerTop":
25150
- case "leftWide":
25151
- case "rightWide":
25152
- case "topWide":
25153
- case "vcenterWide":
25154
- case "fullRect":
25155
- minY = margin - a.y * parentSize.y;
25156
- break;
25157
- case "centerLeft":
25158
- case "centerRight":
25159
- case "center":
25160
- case "hcenterWide":
25161
- minY = 0.5 * parentSize.y - height / 2 - a.y * parentSize.y;
25162
- break;
25163
- default:
25164
- minY = parentSize.y - margin - height - a.y * parentSize.y;
25165
- break;
25166
- }
25167
- // Bottom edge.
25168
- switch(preset){
25169
- case "topLeft":
25170
- case "topRight":
25171
- case "centerTop":
25172
- case "topWide":
25173
- maxY = margin + height - b.y * parentSize.y;
25174
- break;
25175
- case "centerLeft":
25176
- case "centerRight":
25177
- case "center":
25178
- case "hcenterWide":
25179
- maxY = 0.5 * parentSize.y + height / 2 - b.y * parentSize.y;
25180
- break;
25181
- default:
25182
- maxY = parentSize.y - margin - b.y * parentSize.y;
25183
- break;
25184
- }
25185
- this.offsetMin.set(minX, minY);
25186
- this.offsetMax.set(maxX, maxY);
25187
- this.updateLayout();
25188
- };
25189
- _proto.setAnchorsAndOffsetsPreset = function setAnchorsAndOffsetsPreset(preset, margin) {
25190
- if (margin === void 0) margin = 0;
25191
- this.setAnchorsPreset(preset, false);
25192
- this.setOffsetsPreset(preset, margin);
25193
- };
25194
- _proto.getGlobalTransform2D = function getGlobalTransform2D() {
25195
- var local = this.getTransform2D();
25196
- return this.parent ? new Matrix3().multiplyMatrices(this.parent.getGlobalTransform2D(), local) : local.clone();
25197
- };
25198
- _proto.hasPoint = function hasPoint(point) {
25199
- return point.x >= 0 && point.y >= 0 && point.x <= this.size.x && point.y <= this.size.y;
25200
- };
25201
- _proto.getEffectiveMouseFilter = function getEffectiveMouseFilter() {
25202
- return this.enabledInHierarchy && this.isMouseRecursiveEnabled() ? this.mouseFilter : exports.MouseFilter.Ignore;
25203
- };
25204
- _proto.getFocusModeWithOverride = function getFocusModeWithOverride() {
25205
- return this.enabledInHierarchy && this.isFocusRecursiveEnabled() ? this.focusMode : exports.FocusMode.None;
25206
- };
25207
- _proto.getCursorShape = function getCursorShape(position) {
25208
- return this.defaultCursorShape;
25209
- };
25210
- _proto.focus = function focus() {
25211
- var _this_root;
25212
- (_this_root = this.root) == null ? void 0 : _this_root.grabControlFocus(this);
25213
- };
25214
- _proto.grabFocus = function grabFocus() {
25215
- this.focus();
25216
- };
25217
- _proto.grabClickFocus = function grabClickFocus() {
25218
- var _this_root;
25219
- (_this_root = this.root) == null ? void 0 : _this_root.grabControlClickFocus(this);
25220
- };
25221
- _proto.releaseFocus = function releaseFocus() {
25222
- var _this_root;
25223
- (_this_root = this.root) == null ? void 0 : _this_root.releaseControlFocus(this);
25224
- };
25225
- _proto.warpMouse = function warpMouse(position) {
25226
- var _this_root;
25227
- var matrix = this.getGlobalTransform2D().elements;
25228
- (_this_root = this.root) == null ? void 0 : _this_root.warpControlMouse(new Vector2(matrix[0] * position.x + matrix[3] * position.y + matrix[6], matrix[1] * position.x + matrix[4] * position.y + matrix[7]));
25229
- };
25230
- /** Converts a window-space position into this control's local coordinates. */ _proto.makePositionLocal = function makePositionLocal(position) {
25231
- var transform = this.getGlobalTransform2D().clone();
25232
- if (Math.abs(transform.determinant()) < 1e-12) {
25233
- return new Vector2();
25234
- }
25235
- var elements = transform.invert().elements;
25236
- return new Vector2(elements[0] * position.x + elements[3] * position.y + elements[6], elements[1] * position.x + elements[4] * position.y + elements[7]);
25237
- };
25238
- /** Gets the current mouse position transformed into this control's coordinates. */ _proto.getLocalMousePosition = function getLocalMousePosition() {
25239
- var root = this.root;
25240
- return root ? this.makePositionLocal(root.getMousePosition()) : new Vector2();
25241
- };
25242
- _proto.update = function update(deltaTime) {};
25243
- _proto.draw = function draw() {
25244
- // OVERRIDE
25245
- };
25246
- _proto.onDestroy = function onDestroy() {};
25247
- /** @internal */ _proto.drawInternal = function drawInternal() {
25248
- if (!this.visibleInHierarchy || this.disposed) {
25249
- return;
25250
- }
25251
- var graphics = this.engine.graphics;
25252
- graphics.pushTransform(this.getTransform2D());
25253
- this.draw();
25254
- graphics.popTransform();
25255
- };
25256
- _proto.drawLine = function drawLine(x1, y1, x2, y2, color, thickness) {
25257
- this.engine.graphics.drawLine(x1, y1, x2, y2, color, thickness);
25258
- };
25259
- _proto.drawPolyline = function drawPolyline(points, color, thickness) {
25260
- this.engine.graphics.drawLines(points, color, thickness);
25261
- };
25262
- _proto.drawBezier = function drawBezier(x1, y1, x2, y2, x3, y3, x4, y4, color, thickness) {
25263
- this.engine.graphics.drawBezier(x1, y1, x2, y2, x3, y3, x4, y4, color, thickness);
25264
- };
25265
- _proto.drawTriangle = function drawTriangle(x1, y1, x2, y2, x3, y3, color, thickness) {
25266
- this.engine.graphics.drawTriangle(x1, y1, x2, y2, x3, y3, color, thickness);
25267
- };
25268
- _proto.drawRect = function drawRect(x, y, width, height, color, thickness) {
25269
- this.engine.graphics.drawRectangle(x, y, width, height, color, thickness);
25270
- };
25271
- _proto.drawCircle = function drawCircle(cx, cy, radius, color, thickness) {
25272
- this.engine.graphics.drawCircle(cx, cy, radius, color, thickness);
25273
- };
25274
- _proto.fillTriangle = function fillTriangle(x1, y1, x2, y2, x3, y3, color) {
25275
- this.engine.graphics.fillTriangle(x1, y1, x2, y2, x3, y3, color);
25276
- };
25277
- _proto.fillRect = function fillRect(x, y, width, height, color) {
25278
- this.engine.graphics.fillRectangle(x, y, width, height, color);
25279
- };
25280
- _proto.fillCircle = function fillCircle(cx, cy, radius, color) {
25281
- this.engine.graphics.fillCircle(cx, cy, radius, color);
25282
- };
25283
- _proto.drawTexture = function drawTexture(x, y, width, height, texture, region, color) {
25284
- this.engine.graphics.drawTexture(x, y, width, height, texture, region, color);
25285
- };
25286
- _proto.drawText = function drawText(x, y, text, fontSize, color, fontFamily, fontWeight, fontStyle) {
25287
- this.engine.graphics.drawText(x, y, text, fontSize, color, fontFamily, fontWeight, fontStyle);
25288
- };
25289
- _proto.onMouseEnter = function onMouseEnter(location) {};
25290
- _proto.onMouseMove = function onMouseMove(event) {};
25291
- _proto.onMouseLeave = function onMouseLeave() {};
25292
- _proto.onMouseWheel = function onMouseWheel(event) {};
25293
- _proto.onMouseDown = function onMouseDown(event) {};
25294
- _proto.onMouseUp = function onMouseUp(event) {};
25295
- _proto.onTouchDown = function onTouchDown(event) {};
25296
- _proto.onTouchMove = function onTouchMove(event) {};
25297
- _proto.onTouchUp = function onTouchUp(event) {};
25298
- _proto.onKeyDown = function onKeyDown(event) {};
25299
- _proto.onKeyUp = function onKeyUp(event) {};
25300
- _proto.onGotFocus = function onGotFocus() {};
25301
- _proto.onLostFocus = function onLostFocus() {};
25302
- /** @internal */ _proto.invokeGetDragData = function invokeGetDragData(position) {
25303
- return this.getDragData(position);
25304
- };
25305
- /** @internal */ _proto.invokeCanDropData = function invokeCanDropData(position, data) {
25306
- return this.canDropData(position, data);
25307
- };
25308
- /** @internal */ _proto.invokeDropData = function invokeDropData(position, data) {
25309
- this.dropData(position, data);
25310
- };
25311
- _proto.getDragData = function getDragData(position) {
25312
- return null;
25313
- };
25314
- _proto.canDropData = function canDropData(position, data) {
25315
- return false;
25316
- };
25317
- _proto.dropData = function dropData(position, data) {};
25318
- _proto.dispose = function dispose() {
25319
- if (this.disposed) {
25320
- return;
25321
- }
25322
- this.disposed = true;
25323
- this.onDestroy();
25324
- this.parent = null;
25325
- this.owner = null;
25326
- };
25327
- /** @internal */ _proto.updateLayout = function updateLayout() {
25328
- var _this_parent;
25329
- var _this_parent_size;
25330
- var parentSize = (_this_parent_size = (_this_parent = this.parent) == null ? void 0 : _this_parent.size) != null ? _this_parent_size : new Vector2();
25331
- var left = this.offsetMin.x + this.anchorMin.x * parentSize.x;
25332
- var top = this.offsetMin.y + this.anchorMin.y * parentSize.y;
25333
- var right = this.offsetMax.x + this.anchorMax.x * parentSize.x;
25334
- var bottom = this.offsetMax.y + this.anchorMax.y * parentSize.y;
25335
- this.applyBounds(left, top, right - left, bottom - top);
25336
- };
25337
- _proto.applyBounds = function applyBounds(x, y, width, height) {
25338
- var locationChanged = this.position.x !== x || this.position.y !== y;
25339
- var sizeChanged = this.size.x !== width || this.size.y !== height;
25340
- if (!locationChanged && !sizeChanged) {
25341
- return;
25342
- }
25343
- this.position.set(x, y);
25344
- this.size.set(width, height);
25345
- this.markTransformDirty();
25346
- if (locationChanged) {
25347
- this.eventEmitter.emit("locationChanged", this);
25348
- }
25349
- if (sizeChanged) {
25350
- this.eventEmitter.emit("sizeChanged", this);
25351
- if (_instanceof1(this, ContainerControl)) {
25352
- for(var _iterator = _create_for_of_iterator_helper_loose(this.children.slice()), _step; !(_step = _iterator()).done;){
25353
- var child = _step.value;
25354
- child.updateLayout();
25355
- }
25356
- }
25357
- }
25358
- };
25359
- _proto.markTransformDirty = function markTransformDirty() {
25360
- var _this_root;
25361
- this.transformDirty = true;
25362
- (_this_root = this.root) == null ? void 0 : _this_root.controlTreeChanged();
25363
- };
25364
- _proto.getParentRect = function getParentRect() {
25365
- var _this_parent;
25366
- var _this_parent_size_clone;
25367
- return {
25368
- position: new Vector2(),
25369
- size: (_this_parent_size_clone = (_this_parent = this.parent) == null ? void 0 : _this_parent.size.clone()) != null ? _this_parent_size_clone : new Vector2()
25370
- };
25371
- };
25372
- _proto.computeOffsets = function computeOffsets(rect, parentRect) {
25373
- this.offsetMin.set(rect.position.x - parentRect.position.x - this.anchorMin.x * parentRect.size.x, rect.position.y - parentRect.position.y - this.anchorMin.y * parentRect.size.y);
25374
- this.offsetMax.set(rect.position.x + rect.size.x - parentRect.position.x - this.anchorMax.x * parentRect.size.x, rect.position.y + rect.size.y - parentRect.position.y - this.anchorMax.y * parentRect.size.y);
25375
- };
25376
- _proto.computeAnchors = function computeAnchors(rect, parentRect) {
25377
- if (parentRect.size.x !== 0) {
25378
- this.anchorMin.x = (rect.position.x - parentRect.position.x - this.offsetMin.x) / parentRect.size.x;
25379
- this.anchorMax.x = (rect.position.x + rect.size.x - parentRect.position.x - this.offsetMax.x) / parentRect.size.x;
25380
- }
25381
- if (parentRect.size.y !== 0) {
25382
- this.anchorMin.y = (rect.position.y - parentRect.position.y - this.offsetMin.y) / parentRect.size.y;
25383
- this.anchorMax.y = (rect.position.y + rect.size.y - parentRect.position.y - this.offsetMax.y) / parentRect.size.y;
25384
- }
25385
- };
25386
- _proto.isMouseRecursiveEnabled = function isMouseRecursiveEnabled() {
25387
- if (this.mouseBehaviorRecursive === exports.MouseBehaviorRecursive.Inherited) {
25388
- var _this_parent;
25389
- var _this_parent_isMouseRecursiveEnabled;
25390
- return (_this_parent_isMouseRecursiveEnabled = (_this_parent = this.parent) == null ? void 0 : _this_parent.isMouseRecursiveEnabled()) != null ? _this_parent_isMouseRecursiveEnabled : true;
25391
- }
25392
- return this.mouseBehaviorRecursive === exports.MouseBehaviorRecursive.Enabled;
25393
- };
25394
- _proto.isFocusRecursiveEnabled = function isFocusRecursiveEnabled() {
25395
- if (this.focusBehaviorRecursive === exports.FocusBehaviorRecursive.Inherited) {
25396
- var _this_parent;
25397
- var _this_parent_isFocusRecursiveEnabled;
25398
- return (_this_parent_isFocusRecursiveEnabled = (_this_parent = this.parent) == null ? void 0 : _this_parent.isFocusRecursiveEnabled()) != null ? _this_parent_isFocusRecursiveEnabled : true;
25399
- }
25400
- return this.focusBehaviorRecursive === exports.FocusBehaviorRecursive.Enabled;
25401
- };
25402
- _create_class(Control, [
25403
- {
25404
- key: "parent",
25405
- get: function get() {
25406
- return this._parent;
25407
- },
25408
- set: function set(value) {
25409
- var _this__parent;
25410
- if (value === this._parent) {
25411
- return;
25412
- }
25413
- var previousRoot = this.root;
25414
- (_this__parent = this._parent) == null ? void 0 : _this__parent.removeChildInternal(this);
25415
- this._parent = value;
25416
- value == null ? void 0 : value.addChildInternal(this);
25417
- this.updateLayout();
25418
- var nextRoot = this.root;
25419
- if (previousRoot && previousRoot !== nextRoot) {
25420
- previousRoot.controlRemoved(this);
25421
- }
25422
- nextRoot == null ? void 0 : nextRoot.controlTreeChanged();
25423
- this.eventEmitter.emit("parentChanged", this);
25424
- }
25425
- },
25426
- {
25427
- key: "item",
25428
- get: /** Scene item exposed through the optional UIControl bridge. */ function get() {
25429
- var _this_owner;
25430
- var _this_owner_item;
25431
- return (_this_owner_item = (_this_owner = this.owner) == null ? void 0 : _this_owner.item) != null ? _this_owner_item : null;
25432
- }
25433
- },
25434
- {
25435
- key: "indexInParent",
25436
- get: function get() {
25437
- var _this_parent;
25438
- var _this_parent_getChildIndex;
25439
- return (_this_parent_getChildIndex = (_this_parent = this.parent) == null ? void 0 : _this_parent.getChildIndex(this)) != null ? _this_parent_getChildIndex : -1;
25440
- },
25441
- set: function set(value) {
25442
- var _this_parent;
25443
- (_this_parent = this.parent) == null ? void 0 : _this_parent.changeChildIndex(this, value);
25444
- }
25445
- },
25446
- {
25447
- key: "visible",
25448
- get: function get() {
25449
- return this._visible;
25450
- },
25451
- set: function set(value) {
25452
- if (this._visible !== value) {
25453
- var _this_root;
25454
- this._visible = value;
25455
- (_this_root = this.root) == null ? void 0 : _this_root.controlStateChanged(this);
25456
- }
25457
- }
25458
- },
25459
- {
25460
- key: "visibleInHierarchy",
25461
- get: function get() {
25462
- var _this_parent;
25463
- var _this_parent_visibleInHierarchy;
25464
- return this.visible && ((_this_parent_visibleInHierarchy = (_this_parent = this.parent) == null ? void 0 : _this_parent.visibleInHierarchy) != null ? _this_parent_visibleInHierarchy : true);
25465
- }
25466
- },
25467
- {
25468
- key: "enabled",
25469
- get: function get() {
25470
- return this._enabled;
25471
- },
25472
- set: function set(value) {
25473
- if (this._enabled !== value) {
25474
- var _this_root;
25475
- this._enabled = value;
25476
- (_this_root = this.root) == null ? void 0 : _this_root.controlStateChanged(this);
25477
- }
25478
- }
25479
- },
25480
- {
25481
- key: "enabledInHierarchy",
25482
- get: function get() {
25483
- var _this_parent;
25484
- var _this_parent_enabledInHierarchy;
25485
- return this.enabled && ((_this_parent_enabledInHierarchy = (_this_parent = this.parent) == null ? void 0 : _this_parent.enabledInHierarchy) != null ? _this_parent_enabledInHierarchy : true);
25486
- }
25487
- },
25488
- {
25489
- key: "mouseFilter",
25490
- get: function get() {
25491
- return this._mouseFilter;
25492
- },
25493
- set: function set(value) {
25494
- if (this._mouseFilter !== value) {
25495
- var _this_root;
25496
- this._mouseFilter = value;
25497
- (_this_root = this.root) == null ? void 0 : _this_root.controlStateChanged(this);
25498
- }
25499
- }
25500
- },
25501
- {
25502
- key: "mouseBehaviorRecursive",
25503
- get: function get() {
25504
- return this._mouseBehaviorRecursive;
25505
- },
25506
- set: function set(value) {
25507
- if (this._mouseBehaviorRecursive !== value) {
25508
- var _this_root;
25509
- this._mouseBehaviorRecursive = value;
25510
- (_this_root = this.root) == null ? void 0 : _this_root.controlStateChanged(this);
25511
- }
25512
- }
25513
- },
25514
- {
25515
- key: "focusMode",
25516
- get: function get() {
25517
- return this._focusMode;
25518
- },
25519
- set: function set(value) {
25520
- if (this._focusMode !== value) {
25521
- var _this_root;
25522
- this._focusMode = value;
25523
- (_this_root = this.root) == null ? void 0 : _this_root.controlStateChanged(this);
25524
- }
25525
- }
25526
- },
25527
- {
25528
- key: "focusBehaviorRecursive",
25529
- get: function get() {
25530
- return this._focusBehaviorRecursive;
25531
- },
25532
- set: function set(value) {
25533
- if (this._focusBehaviorRecursive !== value) {
25534
- var _this_root;
25535
- this._focusBehaviorRecursive = value;
25536
- (_this_root = this.root) == null ? void 0 : _this_root.controlStateChanged(this);
25537
- }
25538
- }
25539
- },
25540
- {
25541
- key: "defaultCursorShape",
25542
- get: function get() {
25543
- return this._defaultCursorShape;
25544
- },
25545
- set: function set(value) {
25546
- var _this_root;
25547
- if (this._defaultCursorShape === value) {
25548
- return;
25549
- }
25550
- this._defaultCursorShape = value;
25551
- (_this_root = this.root) == null ? void 0 : _this_root.updateMouseCursorState();
25552
- }
25553
- },
25554
- {
25555
- key: "location",
25556
- get: function get() {
25557
- return this.position;
25558
- },
25559
- set: function set(value) {
25560
- this.setPosition(value.x, value.y);
25561
- }
25562
- },
25563
- {
25564
- key: "rotation",
25565
- get: function get() {
25566
- return this._rotation;
25567
- }
25568
- },
25569
- {
25570
- key: "x",
25571
- get: function get() {
25572
- return this.position.x;
25573
- },
25574
- set: function set(value) {
25575
- this.setPosition(value, this.position.y);
25576
- }
25577
- },
25578
- {
25579
- key: "y",
25580
- get: function get() {
25581
- return this.position.y;
25582
- },
25583
- set: function set(value) {
25584
- this.setPosition(this.position.x, value);
25585
- }
25586
- },
25587
- {
25588
- key: "width",
25589
- get: function get() {
25590
- return this.size.x;
25591
- },
25592
- set: function set(value) {
25593
- this.setSize(value, this.size.y);
25594
- }
25595
- },
25596
- {
25597
- key: "height",
25598
- get: function get() {
25599
- return this.size.y;
25600
- },
25601
- set: function set(value) {
25602
- this.setSize(this.size.x, value);
25603
- }
25604
- },
25605
- {
25606
- key: "root",
25607
- get: function get() {
25608
- var _this_parent;
25609
- var _this_parent_root;
25610
- return _instanceof1(this, RootControl) ? this : (_this_parent_root = (_this_parent = this.parent) == null ? void 0 : _this_parent.root) != null ? _this_parent_root : null;
25611
- }
25612
- },
25613
- {
25614
- key: "isDisposed",
25615
- get: function get() {
25616
- return this.disposed;
25617
- }
25618
- }
25619
- ]);
25620
- return Control;
25621
- }();
25622
- /** A Control that owns child Controls. */ var ContainerControl = /*#__PURE__*/ function(Control) {
25623
- _inherits(ContainerControl, Control);
25624
- function ContainerControl() {
25625
- var _this;
25626
- _this = Control.apply(this, arguments) || this;
25627
- _this.children = [];
25628
- return _this;
25629
- }
25630
- var _proto = ContainerControl.prototype;
25631
- _proto.addChild = function addChild(child) {
25632
- child.parent = this;
25633
- return child;
25634
- };
25635
- _proto.removeChild = function removeChild(child) {
25636
- if (child.parent === this) {
25637
- child.parent = null;
25638
- }
25639
- };
25640
- _proto.getChildIndex = function getChildIndex(child) {
25641
- return this.children.indexOf(child);
25642
- };
25643
- /** @internal */ _proto.changeChildIndex = function changeChildIndex(child, newIndex) {
25644
- var _this_root;
25645
- var oldIndex = this.children.indexOf(child);
25646
- if (oldIndex === newIndex || oldIndex === -1) {
25647
- return;
25648
- }
25649
- this.children.splice(oldIndex, 1);
25650
- if (newIndex < 0 || newIndex >= this.children.length) {
25651
- this.children.push(child);
25652
- } else {
25653
- this.children.splice(newIndex, 0, child);
25654
- }
25655
- (_this_root = this.root) == null ? void 0 : _this_root.controlTreeChanged();
25656
- };
25657
- /** @internal */ _proto.addChildInternal = function addChildInternal(child) {
25658
- if (!this.children.includes(child)) {
25659
- this.children.push(child);
25660
- }
25661
- };
25662
- /** @internal */ _proto.removeChildInternal = function removeChildInternal(child) {
25663
- var index = this.children.indexOf(child);
25664
- if (index !== -1) {
25665
- this.children.splice(index, 1);
25666
- }
25667
- };
25668
- _proto.drawSelf = function drawSelf() {
25669
- Control.prototype.draw.call(this);
25670
- };
25671
- _proto.draw = function draw() {
25672
- this.drawSelf();
25673
- this.drawChildren();
25674
- };
25675
- _proto.drawChildren = function drawChildren() {
25676
- var graphics = this.engine.graphics;
25677
- if (this.clipContents) ;
25678
- for(var _iterator = _create_for_of_iterator_helper_loose(this.children), _step; !(_step = _iterator()).done;){
25679
- var child = _step.value;
25680
- if (!child.visible || child.isDisposed) {
25681
- continue;
25682
- }
25683
- graphics.pushTransform(child.getTransform2D());
25684
- child.draw();
25685
- graphics.popTransform();
25686
- }
25687
- };
25688
- _proto.update = function update(deltaTime) {
25689
- Control.prototype.update.call(this, deltaTime);
25690
- for(var _iterator = _create_for_of_iterator_helper_loose(this.children.slice()), _step; !(_step = _iterator()).done;){
25691
- var child = _step.value;
25692
- if (child.enabled && !child.isDisposed) {
25693
- child.update(deltaTime);
25694
- }
25695
- }
25696
- };
25697
- _proto.dispose = function dispose() {
25698
- for(var _iterator = _create_for_of_iterator_helper_loose(this.children.slice()), _step; !(_step = _iterator()).done;){
25699
- var child = _step.value;
25700
- child.dispose();
25701
- }
25702
- Control.prototype.dispose.call(this);
25703
- };
25704
- return ContainerControl;
25705
- }(Control);
25706
- /** Base class for GUI tree roots and input dispatchers. */ var RootControl = /*#__PURE__*/ function(ContainerControl) {
25707
- _inherits(RootControl, ContainerControl);
25708
- function RootControl() {
25709
- return ContainerControl.apply(this, arguments);
25710
- }
25711
- return RootControl;
25712
- }(ContainerControl);
25713
-
25714
- var _obj$3;
25715
- var cursorNames = (_obj$3 = {}, _obj$3[exports.CursorShape.Arrow] = "default", _obj$3[exports.CursorShape.Ibeam] = "text", _obj$3[exports.CursorShape.PointingHand] = "pointer", _obj$3[exports.CursorShape.Cross] = "crosshair", _obj$3[exports.CursorShape.Wait] = "wait", _obj$3[exports.CursorShape.Busy] = "progress", _obj$3[exports.CursorShape.Drag] = "grab", _obj$3[exports.CursorShape.CanDrop] = "copy", _obj$3[exports.CursorShape.Forbidden] = "not-allowed", _obj$3[exports.CursorShape.Vsize] = "ns-resize", _obj$3[exports.CursorShape.Hsize] = "ew-resize", _obj$3[exports.CursorShape.Bdiagsize] = "nesw-resize", _obj$3[exports.CursorShape.Fdiagsize] = "nwse-resize", _obj$3[exports.CursorShape.Move] = "move", _obj$3[exports.CursorShape.Vsplit] = "row-resize", _obj$3[exports.CursorShape.Hsplit] = "col-resize", _obj$3[exports.CursorShape.Help] = "help", _obj$3);
25716
- function getButtonMask(button) {
25717
- switch(button){
25718
- case exports.MouseButton.Left:
25719
- return exports.MouseButtonMask.Left;
25720
- case exports.MouseButton.Right:
25721
- return exports.MouseButtonMask.Right;
25722
- case exports.MouseButton.Middle:
25723
- return exports.MouseButtonMask.Middle;
25724
- case exports.MouseButton.Xbutton1:
25725
- return exports.MouseButtonMask.Xbutton1;
25726
- case exports.MouseButton.Xbutton2:
25727
- return exports.MouseButtonMask.Xbutton2;
25728
- default:
25729
- return exports.MouseButtonMask.None;
25730
- }
25731
- }
25732
- function isWheelButton(button) {
25733
- return button >= exports.MouseButton.WheelUp && button <= exports.MouseButton.WheelRight;
25734
- }
25735
- /** CanvasLayer-like boundary for a single UICanvas GUI tree. */ var CanvasRootControl = /*#__PURE__*/ function(ContainerControl) {
25736
- _inherits(CanvasRootControl, ContainerControl);
25737
- function CanvasRootControl(engine, canvas) {
25738
- var _this;
25739
- _this = ContainerControl.call(this, engine) || this;
25740
- _this.canvas = canvas;
25741
- _this.mouseFilter = exports.MouseFilter.Ignore;
25742
- _this.setSize(engine.canvas.width, engine.canvas.height);
25743
- return _this;
25744
- }
25745
- _create_class(CanvasRootControl, [
25746
- {
25747
- key: "inputDisabled",
25748
- get: function get() {
25749
- var _this_canvas_item;
25750
- return !this.canvas.receivesEvents || !this.canvas.enabled || !((_this_canvas_item = this.canvas.item) == null ? void 0 : _this_canvas_item.isActive);
25751
- }
25752
- }
25753
- ]);
25754
- return CanvasRootControl;
25755
- }(ContainerControl);
25756
- /** Global ordered collection of UICanvas roots. */ var CanvasContainer = /*#__PURE__*/ function(ContainerControl) {
25757
- _inherits(CanvasContainer, ContainerControl);
25758
- function CanvasContainer(engine) {
25759
- var _this;
25760
- _this = ContainerControl.call(this, engine) || this;
25761
- _this.mouseFilter = exports.MouseFilter.Ignore;
25762
- _this.setSize(engine.canvas.width, engine.canvas.height);
25763
- return _this;
25764
- }
25765
- var _proto = CanvasContainer.prototype;
25766
- _proto.sortCanvases = function sortCanvases() {
25767
- this.children.sort(function(left, right) {
25768
- return left.canvas.order - right.canvas.order;
25769
- });
25770
- };
25771
- _proto.addChildInternal = function addChildInternal(child) {
25772
- ContainerControl.prototype.addChildInternal.call(this, child);
25773
- this.sortCanvases();
25774
- };
25775
- _proto.draw = function draw() {
25776
- this.sortCanvases();
25777
- for(var _iterator = _create_for_of_iterator_helper_loose(this.children), _step; !(_step = _iterator()).done;){
25778
- var child = _step.value;
25779
- var root = child;
25780
- if (root.canvas.isVisible) {
25781
- root.draw();
25782
- }
25783
- }
25784
- };
25785
- return CanvasContainer;
25786
- }(ContainerControl);
25787
- /** Engine window GUI root. Routes events across all UICanvas roots. */ var WindowRootControl = /*#__PURE__*/ function(RootControl) {
25788
- _inherits(WindowRootControl, RootControl);
25789
- function WindowRootControl(engine) {
25790
- var _this;
25791
- _this = RootControl.call(this, engine) || this;
25792
- _this.dragThreshold = 10;
25793
- _this.lastInput = null;
25794
- _this.gui = {
25795
- mouseFocus: null,
25796
- mouseClickGrabber: null,
25797
- mouseFocusMask: exports.MouseButtonMask.None,
25798
- mouseOver: null,
25799
- mouseOverHierarchy: [],
25800
- touchFocus: new Map(),
25801
- keyFocus: null,
25802
- dragAccum: new Vector2(),
25803
- dragAttempted: false,
25804
- dragging: false,
25805
- dragData: null,
25806
- dragMouseOver: null,
25807
- dragSuccessful: false,
25808
- lastMousePosition: new Vector2(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY),
25809
- sendingMouseEnterExit: false,
25810
- mouseOverUpdatePending: false
25811
- };
25812
- _this.mouseFilter = exports.MouseFilter.Ignore;
25813
- _this.setSize(engine.canvas.width, engine.canvas.height);
25814
- _this.canvases = new CanvasContainer(engine);
25815
- _this.canvases.parent = _assert_this_initialized(_this);
25816
- return _this;
25817
- }
25818
- var _proto = WindowRootControl.prototype;
25819
- _proto.pushInput = function pushInput(event) {
25820
- event.clearAccepted();
25821
- this.lastInput = event;
25822
- this.cleanupInternalState();
25823
- this.processGUIInput(event);
25824
- this.postGrabClickFocus();
25825
- };
25826
- _proto.isInputHandled = function isInputHandled() {
25827
- var _this_lastInput;
25828
- var _this_lastInput_isAccepted;
25829
- return (_this_lastInput_isAccepted = (_this_lastInput = this.lastInput) == null ? void 0 : _this_lastInput.isAccepted()) != null ? _this_lastInput_isAccepted : false;
25830
- };
25831
- _proto.getMousePosition = function getMousePosition() {
25832
- return this.gui.lastMousePosition.clone();
25833
- };
25834
- _proto.guiGetFocusOwner = function guiGetFocusOwner() {
25835
- return this.isFocusTargetUsable(this.gui.keyFocus) ? this.gui.keyFocus : null;
25836
- };
25837
- _proto.guiReleaseFocus = function guiReleaseFocus() {
25838
- this.releaseControlFocus();
25839
- };
25840
- _proto.guiIsDragging = function guiIsDragging() {
25841
- return this.gui.dragging;
25842
- };
25843
- _proto.guiGetDragData = function guiGetDragData() {
25844
- return this.gui.dragData;
25845
- };
25846
- _proto.guiIsDragSuccessful = function guiIsDragSuccessful() {
25847
- return this.gui.dragSuccessful;
25848
- };
25849
- _proto.guiCancelDrag = function guiCancelDrag() {
25850
- this.endDragging(false);
25851
- };
25852
- _proto.grabControlFocus = function grabControlFocus(control) {
25853
- if (!this.isFocusTargetUsable(control) || this.gui.keyFocus === control) {
25854
- return;
25855
- }
25856
- var previous = this.gui.keyFocus;
25857
- this.gui.keyFocus = control;
25858
- if (previous && !previous.isDisposed) {
25859
- previous.onLostFocus();
25860
- }
25861
- control.onGotFocus();
25862
- };
25863
- _proto.grabControlClickFocus = function grabControlClickFocus(control) {
25864
- var _this = this;
25865
- if (this.isControlValid(control)) {
25866
- this.gui.mouseClickGrabber = control;
25867
- queueMicrotask(function() {
25868
- return _this.postGrabClickFocus();
25869
- });
25870
- }
25871
- };
25872
- _proto.releaseControlFocus = function releaseControlFocus(control) {
25873
- var previous = this.gui.keyFocus;
25874
- if (!previous || control && previous !== control) {
25875
- return;
25876
- }
25877
- this.gui.keyFocus = null;
25878
- if (!previous.isDisposed) {
25879
- previous.onLostFocus();
25880
- }
25881
- };
25882
- _proto.warpControlMouse = function warpControlMouse(position) {
25883
- this.gui.lastMousePosition.copyFrom(position);
25884
- this.updateMouseOver(position);
25885
- this.updateMouseCursorState();
25886
- };
25887
- _proto.updateMouseCursorState = function updateMouseCursorState() {
25888
- var position = this.gui.lastMousePosition;
25889
- var target = this.isControlUsable(this.gui.mouseFocus) ? this.gui.mouseFocus : this.isControlUsable(this.gui.mouseOver) ? this.gui.mouseOver : null;
25890
- this.updateCursor(target, position);
25891
- };
25892
- _proto.controlStateChanged = function controlStateChanged(control) {
25893
- if (!this.isControlUsable(control)) {
25894
- this.dropControlState(control);
25895
- }
25896
- this.requestMouseOverUpdate();
25897
- };
25898
- _proto.controlRemoved = function controlRemoved(control) {
25899
- this.dropControlState(control);
25900
- this.cleanupInternalState();
25901
- this.requestMouseOverUpdate();
25902
- };
25903
- _proto.controlTreeChanged = function controlTreeChanged() {
25904
- this.requestMouseOverUpdate();
25905
- };
25906
- _proto.cancelPointerInput = function cancelPointerInput() {
25907
- this.dropMouseFocus();
25908
- this.dropMouseOver();
25909
- this.gui.touchFocus.clear();
25910
- this.endDragging(false);
25911
- this.releaseControlFocus();
25912
- };
25913
- _proto.resize = function resize(width, height) {
25914
- this.setSize(width, height);
25915
- this.canvases.setSize(width, height);
25916
- for(var _iterator = _create_for_of_iterator_helper_loose(this.canvases.children), _step; !(_step = _iterator()).done;){
25917
- var root = _step.value;
25918
- root.setSize(width, height);
25919
- }
25920
- };
25921
- _proto.render = function render() {
25922
- if (this.canvases.children.length === 0) {
25923
- return;
25924
- }
25925
- this.engine.graphics.begin();
25926
- this.draw();
25927
- this.engine.graphics.end();
25928
- };
25929
- _proto.update = function update(deltaTime) {
25930
- if (this.gui.mouseOverUpdatePending) {
25931
- this.gui.mouseOverUpdatePending = false;
25932
- this.updateMouseOver(this.gui.lastMousePosition);
25933
- }
25934
- RootControl.prototype.update.call(this, deltaTime);
25935
- };
25936
- _proto.dispose = function dispose() {
25937
- this.cancelPointerInput();
25938
- RootControl.prototype.dispose.call(this);
25939
- };
25940
- _proto.processGUIInput = function processGUIInput(event) {
25941
- if (_instanceof1(event, InputEventKey)) {
25942
- var target = this.guiGetFocusOwner();
25943
- if (target) {
25944
- this.callControlInput(target, event);
25945
- }
25946
- } else if (_instanceof1(event, InputEventMouse)) {
25947
- this.gui.lastMousePosition.copyFrom(event.globalPosition);
25948
- this.updateMouseOver(event.globalPosition);
25949
- if (_instanceof1(event, InputEventMouseButton)) {
25950
- this.processMouseButton(event);
25951
- } else if (_instanceof1(event, InputEventMouseMotion)) {
25952
- this.processMouseMotion(event);
25953
- }
25954
- } else if (_instanceof1(event, InputEventScreenTouch)) {
25955
- this.processScreenTouch(event);
25956
- } else if (_instanceof1(event, InputEventScreenDrag)) {
25957
- this.processScreenDrag(event);
25958
- }
25959
- };
25960
- _proto.processMouseButton = function processMouseButton(event) {
25961
- if (isWheelButton(event.buttonIndex)) {
25962
- var target = this.findInputControl(event.globalPosition);
25963
- if (target) {
25964
- this.callGUIInput(target, event);
25965
- }
25966
- return;
25967
- }
25968
- var mask = getButtonMask(event.buttonIndex);
25969
- if (event.isPressed()) {
25970
- var target1 = this.gui.mouseFocusMask !== 0 ? this.gui.mouseFocus : this.findInputControl(event.globalPosition);
25971
- this.gui.mouseFocus = target1;
25972
- if (!target1) {
25973
- return;
25974
- }
25975
- this.gui.mouseFocusMask |= mask;
25976
- if (event.buttonIndex === exports.MouseButton.Left) {
25977
- this.gui.dragAccum.setZero();
25978
- this.gui.dragAttempted = false;
25979
- this.findClickFocus(target1);
25980
- }
25981
- this.callGUIInput(target1, event);
25982
- } else {
25983
- if (event.buttonIndex === exports.MouseButton.Left && this.gui.dragging) {
25984
- this.finishDrop(event.globalPosition);
25985
- }
25986
- this.gui.mouseFocusMask &= ~mask;
25987
- var target2 = this.gui.mouseFocus;
25988
- if (this.gui.mouseFocusMask === 0) {
25989
- this.gui.mouseFocus = null;
25990
- }
25991
- if (this.isControlUsable(target2)) {
25992
- this.callGUIInput(target2, event);
25993
- }
25994
- }
25995
- };
25996
- _proto.processMouseMotion = function processMouseMotion(event) {
25997
- if (!this.gui.dragging && !this.gui.dragAttempted && this.gui.mouseFocus && (this.gui.mouseFocusMask & exports.MouseButtonMask.Left) !== 0) {
25998
- this.gui.dragAccum.add(event.relative);
25999
- if (this.gui.dragAccum.length() > this.dragThreshold) {
26000
- var origin = event.globalPosition.clone().subtract(this.gui.dragAccum);
26001
- this.beginDragging(this.gui.mouseFocus, origin);
26002
- this.gui.dragAttempted = true;
26003
- }
26004
- }
26005
- var target = this.isControlUsable(this.gui.mouseFocus) ? this.gui.mouseFocus : this.findInputControl(event.globalPosition);
26006
- if (target) {
26007
- this.callGUIInput(target, event);
26008
- }
26009
- if (this.gui.dragging) {
26010
- this.gui.dragMouseOver = this.findDropTarget(this.findInputControl(event.globalPosition), event.globalPosition);
26011
- }
26012
- this.updateCursor(target, event.globalPosition);
26013
- };
26014
- _proto.processScreenTouch = function processScreenTouch(event) {
26015
- var target;
26016
- if (event.isPressed()) {
26017
- target = this.findInputControl(event.position);
26018
- if (target) {
26019
- this.gui.touchFocus.set(event.index, target);
26020
- }
26021
- } else {
26022
- var _this_gui_touchFocus_get;
26023
- target = (_this_gui_touchFocus_get = this.gui.touchFocus.get(event.index)) != null ? _this_gui_touchFocus_get : null;
26024
- this.gui.touchFocus.delete(event.index);
26025
- }
26026
- if (this.isControlUsable(target)) {
26027
- this.callGUIInput(target, event);
26028
- }
26029
- };
26030
- _proto.processScreenDrag = function processScreenDrag(event) {
26031
- var _this_gui_touchFocus_get;
26032
- var target = (_this_gui_touchFocus_get = this.gui.touchFocus.get(event.index)) != null ? _this_gui_touchFocus_get : this.findInputControl(event.position);
26033
- if (this.isControlUsable(target)) {
26034
- this.callGUIInput(target, event);
26035
- }
26036
- };
26037
- _proto.callGUIInput = function callGUIInput(target, event) {
26038
- var current = target;
26039
- var pointerEvent = _instanceof1(event, InputEventMouse) || _instanceof1(event, InputEventScreenTouch) || _instanceof1(event, InputEventScreenDrag);
26040
- while(current && current !== this && this.isControlUsable(current)){
26041
- var filter = current.getEffectiveMouseFilter();
26042
- if (filter !== exports.MouseFilter.Ignore) {
26043
- var localEvent = event.xformedBy(this.getGlobalInverse(current));
26044
- this.callControlInput(current, localEvent);
26045
- if (localEvent.isAccepted()) {
26046
- event.accept();
26047
- }
26048
- }
26049
- var forcePassWheel = _instanceof1(event, InputEventMouseButton) && isWheelButton(event.buttonIndex) && current.mouseForcePassScrollEvents;
26050
- if (event.isAccepted() || filter === exports.MouseFilter.Stop && pointerEvent && !forcePassWheel) {
26051
- event.accept();
26052
- return;
26053
- }
26054
- current = current.parent;
26055
- }
26056
- };
26057
- _proto.callControlInput = function callControlInput(control, event) {
26058
- if (_instanceof1(event, InputEventMouseButton)) {
26059
- if (isWheelButton(event.buttonIndex)) {
26060
- control.onMouseWheel(event);
26061
- } else if (event.isPressed()) {
26062
- control.onMouseDown(event);
26063
- } else {
26064
- control.onMouseUp(event);
26065
- }
26066
- } else if (_instanceof1(event, InputEventMouseMotion)) {
26067
- control.onMouseMove(event);
26068
- } else if (_instanceof1(event, InputEventScreenTouch)) {
26069
- if (event.isPressed()) {
26070
- control.onTouchDown(event);
26071
- } else {
26072
- control.onTouchUp(event);
26073
- }
26074
- } else if (_instanceof1(event, InputEventScreenDrag)) {
26075
- control.onTouchMove(event);
26076
- } else if (_instanceof1(event, InputEventKey)) {
26077
- if (event.isPressed()) {
26078
- control.onKeyDown(event);
26079
- } else if (event.isReleased()) {
26080
- control.onKeyUp(event);
26081
- }
26082
- }
26083
- };
26084
- _proto.findInputControl = function findInputControl(position) {
26085
- this.canvases.sortCanvases();
26086
- for(var index = this.canvases.children.length - 1; index >= 0; index--){
26087
- var root = this.canvases.children[index];
26088
- if (!root.canvas.isVisible || root.inputDisabled) {
26089
- continue;
26090
- }
26091
- var target = this.findControlAtPosition(root, position, true);
26092
- if (target) {
26093
- return target;
26094
- }
26095
- }
26096
- return null;
26097
- };
26098
- _proto.findControlAtPosition = function findControlAtPosition(container, position, skipSelf) {
26099
- if (skipSelf === void 0) skipSelf = false;
26100
- if (!container.visibleInHierarchy || container.isDisposed) {
26101
- return null;
26102
- }
26103
- var localPosition = this.toLocal(container, position);
26104
- if (container.clipContents && !container.hasPoint(localPosition)) {
26105
- return null;
26106
- }
26107
- for(var index = container.children.length - 1; index >= 0; index--){
26108
- var child = container.children[index];
26109
- if (!child.visibleInHierarchy || child.isDisposed) {
26110
- continue;
26111
- }
26112
- if (_instanceof1(child, ContainerControl)) {
26113
- var found = this.findControlAtPosition(child, position);
26114
- if (found) {
26115
- return found;
26116
- }
26117
- } else if (child.getEffectiveMouseFilter() !== exports.MouseFilter.Ignore && child.hasPoint(this.toLocal(child, position))) {
26118
- return child;
26119
- }
26120
- }
26121
- if (!skipSelf && container.getEffectiveMouseFilter() !== exports.MouseFilter.Ignore && container.hasPoint(localPosition)) {
26122
- return container;
26123
- }
26124
- return null;
26125
- };
26126
- _proto.updateMouseOver = function updateMouseOver(position) {
26127
- if (this.gui.sendingMouseEnterExit) {
26128
- this.gui.mouseOverUpdatePending = true;
26129
- return;
26130
- }
26131
- this.gui.mouseOverUpdatePending = false;
26132
- var target = this.findInputControl(position);
26133
- var next = this.buildHoverHierarchy(target);
26134
- var previous = this.gui.mouseOverHierarchy;
26135
- var common = 0;
26136
- while(common < previous.length && common < next.length && previous[common] === next[common]){
26137
- common++;
26138
- }
26139
- this.gui.sendingMouseEnterExit = true;
26140
- for(var index = previous.length - 1; index >= common; index--){
26141
- if (!previous[index].isDisposed) {
26142
- previous[index].onMouseLeave();
26143
- }
26144
- }
26145
- for(var index1 = common; index1 < next.length; index1++){
26146
- next[index1].onMouseEnter(this.toLocal(next[index1], position));
26147
- }
26148
- this.gui.sendingMouseEnterExit = false;
26149
- this.gui.mouseOver = target;
26150
- this.gui.mouseOverHierarchy = next;
26151
- };
26152
- _proto.buildHoverHierarchy = function buildHoverHierarchy(target) {
26153
- var hierarchy = [];
26154
- var current = target;
26155
- while(current && current !== this){
26156
- if (current.getEffectiveMouseFilter() !== exports.MouseFilter.Ignore) {
26157
- hierarchy.push(current);
26158
- }
26159
- if (current.getEffectiveMouseFilter() === exports.MouseFilter.Stop) {
26160
- break;
26161
- }
26162
- current = current.parent;
26163
- }
26164
- hierarchy.reverse();
26165
- return hierarchy;
26166
- };
26167
- _proto.findClickFocus = function findClickFocus(target) {
26168
- var current = target;
26169
- while(current && current !== this){
26170
- var mode = current.getFocusModeWithOverride();
26171
- if (mode === exports.FocusMode.Click || mode === exports.FocusMode.All) {
26172
- this.grabControlFocus(current);
26173
- return;
26174
- }
26175
- if (current.getEffectiveMouseFilter() === exports.MouseFilter.Stop) {
26176
- return;
26177
- }
26178
- current = current.parent;
26179
- }
26180
- };
26181
- _proto.beginDragging = function beginDragging(source, position) {
26182
- var current = source;
26183
- while(current && current !== this){
26184
- var data = current.invokeGetDragData(this.toLocal(current, position));
26185
- if (data !== null && data !== undefined) {
26186
- this.gui.dragging = true;
26187
- this.gui.dragData = data;
26188
- this.gui.mouseFocus = null;
26189
- this.gui.mouseFocusMask = exports.MouseButtonMask.None;
26190
- return;
26191
- }
26192
- if (current.getEffectiveMouseFilter() === exports.MouseFilter.Stop) {
26193
- return;
26194
- }
26195
- current = current.parent;
26196
- }
26197
- };
26198
- _proto.finishDrop = function finishDrop(position) {
26199
- var target = this.findDropTarget(this.findInputControl(position), position);
26200
- if (target) {
26201
- target.invokeDropData(this.toLocal(target, position), this.gui.dragData);
26202
- }
26203
- this.endDragging(!!target);
26204
- };
26205
- _proto.findDropTarget = function findDropTarget(target, position) {
26206
- var current = target;
26207
- while(current && current !== this){
26208
- if (current.invokeCanDropData(this.toLocal(current, position), this.gui.dragData)) {
26209
- return current;
26210
- }
26211
- if (current.getEffectiveMouseFilter() === exports.MouseFilter.Stop) {
26212
- return null;
26213
- }
26214
- current = current.parent;
26215
- }
26216
- return null;
26217
- };
26218
- _proto.endDragging = function endDragging(successful) {
26219
- this.gui.dragSuccessful = successful;
26220
- this.gui.dragging = false;
26221
- this.gui.dragData = null;
26222
- this.gui.dragMouseOver = null;
26223
- };
26224
- _proto.updateCursor = function updateCursor(target, position) {
26225
- var current = target;
26226
- var cursor = exports.CursorShape.Arrow;
26227
- while(current && current !== this){
26228
- var candidate = current.getCursorShape(this.toLocal(current, position));
26229
- if (candidate !== exports.CursorShape.Arrow) {
26230
- cursor = candidate;
26231
- break;
26232
- }
26233
- if (current.getEffectiveMouseFilter() === exports.MouseFilter.Stop) {
26234
- break;
26235
- }
26236
- current = current.parent;
26237
- }
26238
- this.engine.canvas.style.cursor = typeof cursor === "string" ? cursor : cursorNames[cursor];
26239
- };
26240
- _proto.postGrabClickFocus = function postGrabClickFocus() {
26241
- var target = this.gui.mouseClickGrabber;
26242
- this.gui.mouseClickGrabber = null;
26243
- if (this.isControlUsable(target)) {
26244
- this.gui.mouseFocus = target;
26245
- }
26246
- };
26247
- _proto.cleanupInternalState = function cleanupInternalState() {
26248
- if (!this.isControlUsable(this.gui.mouseFocus)) {
26249
- this.dropMouseFocus();
26250
- }
26251
- if (this.gui.keyFocus && !this.isFocusTargetUsable(this.gui.keyFocus)) {
26252
- this.releaseControlFocus(this.gui.keyFocus);
26253
- }
26254
- for(var _iterator = _create_for_of_iterator_helper_loose(this.gui.touchFocus), _step; !(_step = _iterator()).done;){
26255
- var _step_value = _step.value, index = _step_value[0], control = _step_value[1];
26256
- if (!this.isControlUsable(control)) {
26257
- this.gui.touchFocus.delete(index);
26258
- }
26259
- }
26260
- };
26261
- _proto.dropMouseFocus = function dropMouseFocus() {
26262
- this.gui.mouseFocus = null;
26263
- this.gui.mouseFocusMask = exports.MouseButtonMask.None;
26264
- };
26265
- _proto.dropMouseOver = function dropMouseOver() {
26266
- for(var index = this.gui.mouseOverHierarchy.length - 1; index >= 0; index--){
26267
- var control = this.gui.mouseOverHierarchy[index];
26268
- if (!control.isDisposed) {
26269
- control.onMouseLeave();
26270
- }
26271
- }
26272
- this.gui.mouseOver = null;
26273
- this.gui.mouseOverHierarchy = [];
26274
- };
26275
- _proto.dropControlState = function dropControlState(control) {
26276
- if (this.controlBelongsToSubtree(this.gui.mouseFocus, control)) {
26277
- this.dropMouseFocus();
26278
- }
26279
- if (this.controlBelongsToSubtree(this.gui.mouseClickGrabber, control)) {
26280
- this.gui.mouseClickGrabber = null;
26281
- }
26282
- if (this.controlBelongsToSubtree(this.gui.keyFocus, control)) {
26283
- var _this_gui_keyFocus;
26284
- this.releaseControlFocus((_this_gui_keyFocus = this.gui.keyFocus) != null ? _this_gui_keyFocus : undefined);
26285
- }
26286
- if (this.controlBelongsToSubtree(this.gui.mouseOver, control)) {
26287
- this.dropMouseOver();
26288
- }
26289
- if (this.controlBelongsToSubtree(this.gui.dragMouseOver, control)) {
26290
- this.gui.dragMouseOver = null;
26291
- }
26292
- for(var _iterator = _create_for_of_iterator_helper_loose(this.gui.touchFocus), _step; !(_step = _iterator()).done;){
26293
- var _step_value = _step.value, index = _step_value[0], target = _step_value[1];
26294
- if (this.controlBelongsToSubtree(target, control)) {
26295
- this.gui.touchFocus.delete(index);
26296
- }
26297
- }
26298
- };
26299
- _proto.requestMouseOverUpdate = function requestMouseOverUpdate() {
26300
- if (Number.isFinite(this.gui.lastMousePosition.x)) {
26301
- this.updateMouseOver(this.gui.lastMousePosition);
26302
- }
26303
- };
26304
- _proto.getGlobalInverse = function getGlobalInverse(control) {
26305
- var transform = control.getGlobalTransform2D().clone();
26306
- return Math.abs(transform.determinant()) < 1e-12 ? new Matrix3() : transform.invert();
26307
- };
26308
- _proto.toLocal = function toLocal(control, position) {
26309
- var elements = this.getGlobalInverse(control).elements;
26310
- return new Vector2(elements[0] * position.x + elements[3] * position.y + elements[6], elements[1] * position.x + elements[4] * position.y + elements[7]);
26311
- };
26312
- _proto.controlBelongsToSubtree = function controlBelongsToSubtree(control, subtree) {
26313
- var current = control;
26314
- while(current){
26315
- if (current === subtree) {
26316
- return true;
26317
- }
26318
- current = current.parent;
26319
- }
26320
- return false;
26321
- };
26322
- _proto.isControlValid = function isControlValid(control) {
26323
- return !!control && !control.isDisposed && control.root === this;
26324
- };
26325
- _proto.isControlUsable = function isControlUsable(control) {
26326
- if (!this.isControlValid(control) || !control.visibleInHierarchy || !control.enabledInHierarchy) {
26327
- return false;
26328
- }
26329
- var root = this.findCanvasRoot(control);
26330
- return !root || !root.inputDisabled;
26331
- };
26332
- _proto.findCanvasRoot = function findCanvasRoot(control) {
26333
- var current = control;
26334
- while(current && current !== this){
26335
- if (_instanceof1(current, CanvasRootControl)) {
26336
- return current;
26337
- }
26338
- current = current.parent;
26339
- }
26340
- return null;
26341
- };
26342
- _proto.isFocusTargetUsable = function isFocusTargetUsable(control) {
26343
- return this.isControlUsable(control) && control.getFocusModeWithOverride() !== exports.FocusMode.None;
26344
- };
26345
- return WindowRootControl;
26346
- }(RootControl);
26347
-
26348
- exports.CanvasRenderMode = void 0;
26349
- (function(CanvasRenderMode) {
26350
- CanvasRenderMode[CanvasRenderMode["ScreenSpace"] = 0] = "ScreenSpace";
26351
- CanvasRenderMode[CanvasRenderMode["CameraSpace"] = 1] = "CameraSpace";
26352
- CanvasRenderMode[CanvasRenderMode["WorldSpace"] = 2] = "WorldSpace";
26353
- CanvasRenderMode[CanvasRenderMode["WorldSpaceFaceCamera"] = 3] = "WorldSpaceFaceCamera";
26354
- })(exports.CanvasRenderMode || (exports.CanvasRenderMode = {}));
26355
- /** Canvas-layer boundary attached to a VFXItem. Input state remains owned by the window root. */ var UICanvas = /*#__PURE__*/ function(Component) {
26356
- _inherits(UICanvas, Component);
26357
- function UICanvas(engine) {
26358
- var _this;
26359
- _this = Component.call(this, engine) || this;
26360
- _this.renderMode = 0;
26361
- _this.receivesEvents = true;
26362
- _this._order = 0;
26363
- _this.registered = false;
26364
- _this.rootControl = new CanvasRootControl(engine, _assert_this_initialized(_this));
26365
- return _this;
26366
- }
26367
- var _proto = UICanvas.prototype;
26368
- _proto.onEnable = function onEnable() {
26369
- this.register();
26370
- };
26371
- _proto.onDisable = function onDisable() {
26372
- this.unregister();
26373
- };
26374
- _proto.onDestroy = function onDestroy() {
26375
- this.destroyCanvas();
26376
- };
26377
- _proto.dispose = function dispose() {
26378
- this.destroyCanvas();
26379
- Component.prototype.dispose.call(this);
26380
- };
26381
- _proto.register = function register() {
26382
- if (!this.registered) {
26383
- this.rootControl.parent = this.engine.windowRoot.canvases;
26384
- this.registered = true;
26385
- }
26386
- };
26387
- _proto.unregister = function unregister() {
26388
- if (this.registered) {
26389
- this.rootControl.parent = null;
26390
- this.registered = false;
26391
- }
26392
- };
26393
- _proto.destroyCanvas = function destroyCanvas() {
26394
- this.unregister();
26395
- if (!this.rootControl.isDisposed) {
26396
- this.rootControl.dispose();
26397
- }
26398
- };
26399
- _create_class(UICanvas, [
26400
- {
26401
- key: "order",
26402
- get: function get() {
26403
- return this._order;
26404
- },
26405
- set: function set(value) {
26406
- if (this._order !== value) {
26407
- this._order = value;
26408
- this.engine.windowRoot.canvases.sortCanvases();
26409
- }
26410
- }
26411
- },
26412
- {
26413
- key: "isVisible",
26414
- get: function get() {
26415
- var _this_item;
26416
- return this.renderMode === 0 && this.enabled && !!((_this_item = this.item) == null ? void 0 : _this_item.isActive);
26417
- }
26418
- }
26419
- ]);
26420
- return UICanvas;
26421
- }(Component);
26422
-
26423
- /**
26424
- * Scene-tree bridge for a GUI Control. The VFXItem tree owns lifecycle and
26425
- * serialization while the Control tree owns layout, drawing and input.
26426
- */ var UIControl = /*#__PURE__*/ function(Component) {
26427
- _inherits(UIControl, Component);
26428
- function UIControl(engine) {
26429
- var _this;
26430
- _this = Component.call(this, engine) || this;
26431
- _this.controlNode = null;
26432
- _this.linkedItemTransform = null;
26433
- _this.linkedControl = null;
26434
- _this.syncingLocation = false;
26435
- _this.itemTransformChanged = function() {
26436
- return _this.syncItemLocationToControl();
26437
- };
26438
- _this.controlLocationChanged = function() {
26439
- return _this.syncControlLocationToItem();
26440
- };
26441
- return _this;
26442
- }
26443
- var _proto = UIControl.prototype;
26444
- _proto.onAwake = function onAwake() {
26445
- this.syncControl();
26446
- };
26447
- _proto.onEnable = function onEnable() {
26448
- if (this.controlNode) {
26449
- this.controlNode.visible = this.item.isActive;
26450
- this.controlNode.enabled = true;
26451
- }
26452
- };
26453
- _proto.onDisable = function onDisable() {
26454
- if (this.controlNode) {
26455
- this.controlNode.visible = this.item.isActive;
26456
- this.controlNode.enabled = false;
26457
- }
26458
- };
26459
- _proto.onParentChanged = function onParentChanged() {
26460
- this.syncControl();
26461
- };
26462
- _proto.onOrderInParentChanged = function onOrderInParentChanged() {
26463
- this.syncControlOrder();
26464
- };
26465
- _proto.onDestroy = function onDestroy() {
26466
- this.disposeControl();
26467
- };
26468
- _proto.dispose = function dispose() {
26469
- this.disposeControl();
26470
- Component.prototype.dispose.call(this);
26471
- };
26472
- /** Unlinks the GUI object without disposing or modifying it. */ _proto.unlinkControl = function unlinkControl() {
26473
- if (this.controlNode) {
26474
- this.unbindLocationSync();
26475
- this.controlNode = null;
26476
- }
26477
- };
26478
- _proto.disposeControl = function disposeControl() {
26479
- var control = this.controlNode;
26480
- if (control) {
26481
- this.unbindLocationSync();
26482
- this.controlNode = null;
26483
- control.dispose();
26484
- }
26485
- };
26486
- _proto.syncControl = function syncControl() {
26487
- var control = this.controlNode;
26488
- if (!control || !this.item) {
26489
- return;
26490
- }
26491
- this.syncingLocation = true;
26492
- try {
26493
- control.visible = this.item.isActive;
26494
- control.enabled = this.enabled;
26495
- control.parent = this.resolveParent();
26496
- this.syncControlOrder();
26497
- this.copyItemLocationToControl();
26498
- } finally{
26499
- this.syncingLocation = false;
26500
- }
26501
- this.bindLocationSync();
26502
- };
26503
- _proto.syncControlOrder = function syncControlOrder() {
26504
- if (this.controlNode && this.item) {
26505
- this.controlNode.indexInParent = this.item.orderInParent;
26506
- }
26507
- };
26508
- _proto.resolveParent = function resolveParent() {
26509
- var parentItem = this.item.parent;
26510
- if (!parentItem) {
26511
- var _UIControl_fallbackParentGetDelegate;
26512
- return (_UIControl_fallbackParentGetDelegate = UIControl.fallbackParentGetDelegate == null ? void 0 : UIControl.fallbackParentGetDelegate.call(UIControl, this)) != null ? _UIControl_fallbackParentGetDelegate : null;
26513
- }
26514
- var uiControl = parentItem.getComponent(UIControl);
26515
- if ((uiControl == null ? void 0 : uiControl.control) && "children" in uiControl.control) {
26516
- return uiControl.control;
26517
- }
26518
- var canvas = parentItem.getComponent(UICanvas);
26519
- var _canvas_rootControl, _ref;
26520
- return (_ref = (_canvas_rootControl = canvas == null ? void 0 : canvas.rootControl) != null ? _canvas_rootControl : UIControl.fallbackParentGetDelegate == null ? void 0 : UIControl.fallbackParentGetDelegate.call(UIControl, this)) != null ? _ref : null;
26521
- };
26522
- _proto.bindLocationSync = function bindLocationSync() {
26523
- var itemTransform = this.item.transform;
26524
- var control = this.controlNode;
26525
- if (this.linkedItemTransform === itemTransform && this.linkedControl === control) {
26526
- return;
26527
- }
26528
- this.unbindLocationSync();
26529
- if (control) {
26530
- this.linkedItemTransform = itemTransform;
26531
- this.linkedControl = control;
26532
- itemTransform.on("changed", this.itemTransformChanged);
26533
- control.on("locationChanged", this.controlLocationChanged);
26534
- }
26535
- };
26536
- _proto.unbindLocationSync = function unbindLocationSync() {
26537
- var _this_linkedItemTransform, _this_linkedControl;
26538
- (_this_linkedItemTransform = this.linkedItemTransform) == null ? void 0 : _this_linkedItemTransform.off("changed", this.itemTransformChanged);
26539
- (_this_linkedControl = this.linkedControl) == null ? void 0 : _this_linkedControl.off("locationChanged", this.controlLocationChanged);
26540
- this.linkedItemTransform = null;
26541
- this.linkedControl = null;
26542
- };
26543
- _proto.syncItemLocationToControl = function syncItemLocationToControl() {
26544
- if (!this.syncingLocation && this.controlNode) {
26545
- this.syncingLocation = true;
26546
- try {
26547
- this.copyItemLocationToControl();
26548
- } finally{
26549
- this.syncingLocation = false;
26550
- }
26551
- }
26552
- };
26553
- _proto.syncControlLocationToItem = function syncControlLocationToItem() {
26554
- var control = this.controlNode;
26555
- if (!this.syncingLocation && control) {
26556
- var source = control.location;
26557
- var target = this.item.transform.position;
26558
- if (source.x !== target.x || source.y !== target.y) {
26559
- this.syncingLocation = true;
26560
- try {
26561
- this.item.transform.setPosition(source.x, source.y, target.z);
26562
- } finally{
26563
- this.syncingLocation = false;
26564
- }
26565
- }
26566
- }
26567
- };
26568
- _proto.copyItemLocationToControl = function copyItemLocationToControl() {
26569
- var control = this.controlNode;
26570
- if (control) {
26571
- var source = this.item.transform.position;
26572
- var target = control.location;
26573
- if (source.x !== target.x || source.y !== target.y) {
26574
- control.setPosition(source.x, source.y);
26575
- }
26576
- }
26577
- };
26578
- _create_class(UIControl, [
26579
- {
26580
- key: "control",
26581
- get: function get() {
26582
- return this.controlNode;
26583
- },
26584
- set: function set(value) {
26585
- if (value === this.controlNode) {
26586
- return;
26587
- }
26588
- this.disposeControl();
26589
- if (value) {
26590
- if (value.owner && value.owner !== this && value.owner.control === value) {
26591
- throw new Error("A Control can only be owned by one UIControl.");
26592
- }
26593
- this.controlNode = value;
26594
- value.owner = this;
26595
- this.syncControl();
26596
- }
26597
- }
26598
- },
26599
- {
26600
- key: "hasControl",
26601
- get: function get() {
26602
- return this.controlNode !== null;
26603
- }
26604
- }
26605
- ]);
26606
- return UIControl;
26607
- }(Component);
26608
-
26609
24752
  exports.CameraController = /*#__PURE__*/ function(Component) {
26610
24753
  _inherits(CameraController, Component);
26611
24754
  function CameraController(engine, props) {
@@ -26640,6 +24783,42 @@ exports.CameraController = __decorate([
26640
24783
  effectsClass(DataType.CameraController)
26641
24784
  ], exports.CameraController);
26642
24785
 
24786
+ function _get_prototype_of(o) {
24787
+ _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
24788
+ return o.__proto__ || Object.getPrototypeOf(o);
24789
+ };
24790
+ return _get_prototype_of(o);
24791
+ }
24792
+
24793
+ function _is_native_function(fn) {
24794
+ return Function.toString.call(fn).indexOf("[native code]") !== -1;
24795
+ }
24796
+
24797
+ function _wrap_native_super(Class) {
24798
+ var _cache = typeof Map === "function" ? new Map() : undefined;
24799
+ _wrap_native_super = function _wrap_native_super(Class) {
24800
+ if (Class === null || !_is_native_function(Class)) return Class;
24801
+ if (typeof Class !== "function") throw new TypeError("Super expression must either be null or a function");
24802
+ if (typeof _cache !== "undefined") {
24803
+ if (_cache.has(Class)) return _cache.get(Class);
24804
+ _cache.set(Class, Wrapper);
24805
+ }
24806
+ function Wrapper() {
24807
+ return _construct(Class, arguments, _get_prototype_of(this).constructor);
24808
+ }
24809
+ Wrapper.prototype = Object.create(Class.prototype, {
24810
+ constructor: {
24811
+ value: Wrapper,
24812
+ enumerable: false,
24813
+ writable: true,
24814
+ configurable: true
24815
+ }
24816
+ });
24817
+ return _set_prototype_of(Wrapper, Class);
24818
+ };
24819
+ return _wrap_native_super(Class);
24820
+ }
24821
+
26643
24822
  var CameraVFXItemLoader = /*#__PURE__*/ function(Plugin) {
26644
24823
  _inherits(CameraVFXItemLoader, Plugin);
26645
24824
  function CameraVFXItemLoader() {
@@ -26648,6 +24827,255 @@ var CameraVFXItemLoader = /*#__PURE__*/ function(Plugin) {
26648
24827
  return CameraVFXItemLoader;
26649
24828
  }(_wrap_native_super(Plugin));
26650
24829
 
24830
+ exports.MouseButton = void 0;
24831
+ (function(MouseButton) {
24832
+ MouseButton[MouseButton["None"] = 0] = "None";
24833
+ MouseButton[MouseButton["Left"] = 1] = "Left";
24834
+ MouseButton[MouseButton["Right"] = 2] = "Right";
24835
+ MouseButton[MouseButton["Middle"] = 3] = "Middle";
24836
+ MouseButton[MouseButton["WheelUp"] = 4] = "WheelUp";
24837
+ MouseButton[MouseButton["WheelDown"] = 5] = "WheelDown";
24838
+ MouseButton[MouseButton["WheelLeft"] = 6] = "WheelLeft";
24839
+ MouseButton[MouseButton["WheelRight"] = 7] = "WheelRight";
24840
+ MouseButton[MouseButton["Xbutton1"] = 8] = "Xbutton1";
24841
+ MouseButton[MouseButton["Xbutton2"] = 9] = "Xbutton2";
24842
+ })(exports.MouseButton || (exports.MouseButton = {}));
24843
+ exports.MouseButtonMask = void 0;
24844
+ (function(MouseButtonMask) {
24845
+ MouseButtonMask[MouseButtonMask["None"] = 0] = "None";
24846
+ MouseButtonMask[MouseButtonMask["Left"] = 1] = "Left";
24847
+ MouseButtonMask[MouseButtonMask["Right"] = 2] = "Right";
24848
+ MouseButtonMask[MouseButtonMask["Middle"] = 4] = "Middle";
24849
+ MouseButtonMask[MouseButtonMask["Xbutton1"] = 128] = "Xbutton1";
24850
+ MouseButtonMask[MouseButtonMask["Xbutton2"] = 256] = "Xbutton2";
24851
+ })(exports.MouseButtonMask || (exports.MouseButtonMask = {}));
24852
+ exports.KeyLocation = void 0;
24853
+ (function(KeyLocation) {
24854
+ KeyLocation[KeyLocation["Unspecified"] = 0] = "Unspecified";
24855
+ KeyLocation[KeyLocation["Left"] = 1] = "Left";
24856
+ KeyLocation[KeyLocation["Right"] = 2] = "Right";
24857
+ })(exports.KeyLocation || (exports.KeyLocation = {}));
24858
+
24859
+ function transformPoint(transform, value) {
24860
+ var elements = transform.elements;
24861
+ return new Vector2(elements[0] * value.x + elements[3] * value.y + elements[6], elements[1] * value.x + elements[4] * value.y + elements[7]);
24862
+ }
24863
+ function transformVector(transform, value) {
24864
+ var elements = transform.elements;
24865
+ return new Vector2(elements[0] * value.x + elements[3] * value.y, elements[1] * value.x + elements[4] * value.y);
24866
+ }
24867
+ var InputEvent = /*#__PURE__*/ function() {
24868
+ function InputEvent() {
24869
+ this.device = 0;
24870
+ this.pressed = false;
24871
+ this.canceled = false;
24872
+ this._accepted = false;
24873
+ }
24874
+ var _proto = InputEvent.prototype;
24875
+ _proto.accept = function accept() {
24876
+ this._accepted = true;
24877
+ };
24878
+ _proto.clearAccepted = function clearAccepted() {
24879
+ this._accepted = false;
24880
+ };
24881
+ _proto.isAccepted = function isAccepted() {
24882
+ return this._accepted;
24883
+ };
24884
+ _proto.isPressed = function isPressed() {
24885
+ return this.pressed && !this.canceled;
24886
+ };
24887
+ _proto.isReleased = function isReleased() {
24888
+ return !this.pressed && !this.canceled;
24889
+ };
24890
+ _proto.isCanceled = function isCanceled() {
24891
+ return this.canceled;
24892
+ };
24893
+ _proto.isEcho = function isEcho() {
24894
+ return false;
24895
+ };
24896
+ _proto.xformedBy = function xformedBy(transform) {
24897
+ return this;
24898
+ };
24899
+ return InputEvent;
24900
+ }();
24901
+ InputEvent.deviceIdEmulation = -1;
24902
+ InputEvent.deviceIdInternal = -2;
24903
+ InputEvent.deviceIdKeyboard = 16;
24904
+ InputEvent.deviceIdMouse = 32;
24905
+ var InputEventWithModifiers = /*#__PURE__*/ function(InputEvent) {
24906
+ _inherits(InputEventWithModifiers, InputEvent);
24907
+ function InputEventWithModifiers() {
24908
+ var _this;
24909
+ _this = InputEvent.apply(this, arguments) || this;
24910
+ _this.commandOrControlAutoremap = false;
24911
+ _this.shiftPressed = false;
24912
+ _this.altPressed = false;
24913
+ _this.metaPressed = false;
24914
+ _this.ctrlPressed = false;
24915
+ return _this;
24916
+ }
24917
+ var _proto = InputEventWithModifiers.prototype;
24918
+ _proto.copyModifiersTo = function copyModifiersTo(event) {
24919
+ event.device = this.device;
24920
+ event.pressed = this.pressed;
24921
+ event.canceled = this.canceled;
24922
+ event.commandOrControlAutoremap = this.commandOrControlAutoremap;
24923
+ event.shiftPressed = this.shiftPressed;
24924
+ event.altPressed = this.altPressed;
24925
+ event.metaPressed = this.metaPressed;
24926
+ event.ctrlPressed = this.ctrlPressed;
24927
+ };
24928
+ return InputEventWithModifiers;
24929
+ }(_wrap_native_super(InputEvent));
24930
+ var InputEventKey = /*#__PURE__*/ function(InputEventWithModifiers) {
24931
+ _inherits(InputEventKey, InputEventWithModifiers);
24932
+ function InputEventKey() {
24933
+ var _this;
24934
+ _this = InputEventWithModifiers.apply(this, arguments) || this;
24935
+ _this.keycode = "";
24936
+ _this.physicalKeycode = "";
24937
+ _this.keyLabel = "";
24938
+ _this.unicode = 0;
24939
+ _this.location = exports.KeyLocation.Unspecified;
24940
+ _this.echo = false;
24941
+ return _this;
24942
+ }
24943
+ var _proto = InputEventKey.prototype;
24944
+ _proto.isEcho = function isEcho() {
24945
+ return this.echo;
24946
+ };
24947
+ return InputEventKey;
24948
+ }(InputEventWithModifiers);
24949
+ var InputEventMouse = /*#__PURE__*/ function(InputEventWithModifiers) {
24950
+ _inherits(InputEventMouse, InputEventWithModifiers);
24951
+ function InputEventMouse() {
24952
+ var _this;
24953
+ _this = InputEventWithModifiers.apply(this, arguments) || this;
24954
+ _this.buttonMask = exports.MouseButtonMask.None;
24955
+ _this.position = new Vector2();
24956
+ _this.globalPosition = new Vector2();
24957
+ return _this;
24958
+ }
24959
+ var _proto = InputEventMouse.prototype;
24960
+ _proto.copyMouseTo = function copyMouseTo(event) {
24961
+ this.copyModifiersTo(event);
24962
+ event.buttonMask = this.buttonMask;
24963
+ event.position.copyFrom(this.position);
24964
+ event.globalPosition.copyFrom(this.globalPosition);
24965
+ };
24966
+ return InputEventMouse;
24967
+ }(InputEventWithModifiers);
24968
+ var InputEventMouseButton = /*#__PURE__*/ function(InputEventMouse) {
24969
+ _inherits(InputEventMouseButton, InputEventMouse);
24970
+ function InputEventMouseButton() {
24971
+ var _this;
24972
+ _this = InputEventMouse.apply(this, arguments) || this;
24973
+ _this.factor = 1;
24974
+ _this.buttonIndex = exports.MouseButton.None;
24975
+ _this.doubleClick = false;
24976
+ return _this;
24977
+ }
24978
+ var _proto = InputEventMouseButton.prototype;
24979
+ _proto.xformedBy = function xformedBy(transform) {
24980
+ var event = new InputEventMouseButton();
24981
+ this.copyMouseTo(event);
24982
+ event.position.copyFrom(transformPoint(transform, this.position));
24983
+ event.factor = this.factor;
24984
+ event.buttonIndex = this.buttonIndex;
24985
+ event.doubleClick = this.doubleClick;
24986
+ return event;
24987
+ };
24988
+ return InputEventMouseButton;
24989
+ }(InputEventMouse);
24990
+ var InputEventMouseMotion = /*#__PURE__*/ function(InputEventMouse) {
24991
+ _inherits(InputEventMouseMotion, InputEventMouse);
24992
+ function InputEventMouseMotion() {
24993
+ var _this;
24994
+ _this = InputEventMouse.apply(this, arguments) || this;
24995
+ _this.tilt = new Vector2();
24996
+ _this.pressure = 0;
24997
+ _this.relative = new Vector2();
24998
+ _this.screenRelative = new Vector2();
24999
+ _this.velocity = new Vector2();
25000
+ _this.screenVelocity = new Vector2();
25001
+ _this.penInverted = false;
25002
+ return _this;
25003
+ }
25004
+ var _proto = InputEventMouseMotion.prototype;
25005
+ _proto.xformedBy = function xformedBy(transform) {
25006
+ var event = new InputEventMouseMotion();
25007
+ this.copyMouseTo(event);
25008
+ event.position.copyFrom(transformPoint(transform, this.position));
25009
+ event.tilt.copyFrom(this.tilt);
25010
+ event.pressure = this.pressure;
25011
+ event.relative.copyFrom(transformVector(transform, this.relative));
25012
+ event.screenRelative.copyFrom(this.screenRelative);
25013
+ event.velocity.copyFrom(transformVector(transform, this.velocity));
25014
+ event.screenVelocity.copyFrom(this.screenVelocity);
25015
+ event.penInverted = this.penInverted;
25016
+ return event;
25017
+ };
25018
+ return InputEventMouseMotion;
25019
+ }(InputEventMouse);
25020
+ var InputEventScreenTouch = /*#__PURE__*/ function(InputEvent) {
25021
+ _inherits(InputEventScreenTouch, InputEvent);
25022
+ function InputEventScreenTouch() {
25023
+ var _this;
25024
+ _this = InputEvent.apply(this, arguments) || this;
25025
+ _this.index = 0;
25026
+ _this.position = new Vector2();
25027
+ _this.doubleTap = false;
25028
+ return _this;
25029
+ }
25030
+ var _proto = InputEventScreenTouch.prototype;
25031
+ _proto.xformedBy = function xformedBy(transform) {
25032
+ var event = new InputEventScreenTouch();
25033
+ event.device = this.device;
25034
+ event.pressed = this.pressed;
25035
+ event.canceled = this.canceled;
25036
+ event.index = this.index;
25037
+ event.position.copyFrom(transformPoint(transform, this.position));
25038
+ event.doubleTap = this.doubleTap;
25039
+ return event;
25040
+ };
25041
+ return InputEventScreenTouch;
25042
+ }(_wrap_native_super(InputEvent));
25043
+ var InputEventScreenDrag = /*#__PURE__*/ function(InputEvent) {
25044
+ _inherits(InputEventScreenDrag, InputEvent);
25045
+ function InputEventScreenDrag() {
25046
+ var _this;
25047
+ _this = InputEvent.apply(this, arguments) || this;
25048
+ _this.index = 0;
25049
+ _this.position = new Vector2();
25050
+ _this.relative = new Vector2();
25051
+ _this.screenRelative = new Vector2();
25052
+ _this.velocity = new Vector2();
25053
+ _this.screenVelocity = new Vector2();
25054
+ _this.pressure = 0;
25055
+ _this.tilt = new Vector2();
25056
+ _this.penInverted = false;
25057
+ return _this;
25058
+ }
25059
+ var _proto = InputEventScreenDrag.prototype;
25060
+ _proto.xformedBy = function xformedBy(transform) {
25061
+ var event = new InputEventScreenDrag();
25062
+ event.device = this.device;
25063
+ event.pressed = this.pressed;
25064
+ event.canceled = this.canceled;
25065
+ event.index = this.index;
25066
+ event.position.copyFrom(transformPoint(transform, this.position));
25067
+ event.relative.copyFrom(transformVector(transform, this.relative));
25068
+ event.screenRelative.copyFrom(this.screenRelative);
25069
+ event.velocity.copyFrom(transformVector(transform, this.velocity));
25070
+ event.screenVelocity.copyFrom(this.screenVelocity);
25071
+ event.pressure = this.pressure;
25072
+ event.tilt.copyFrom(this.tilt);
25073
+ event.penInverted = this.penInverted;
25074
+ return event;
25075
+ };
25076
+ return InputEventScreenDrag;
25077
+ }(_wrap_native_super(InputEvent));
25078
+
26651
25079
  var EVENT_TYPE_CLICK = "click";
26652
25080
  var EVENT_TYPE_TOUCH_START = "touchstart";
26653
25081
  var EVENT_TYPE_TOUCH_MOVE = "touchmove";
@@ -26658,49 +25086,52 @@ exports.PointerEventType = void 0;
26658
25086
  PointerEventType[PointerEventType["PointerUp"] = 1] = "PointerUp";
26659
25087
  PointerEventType[PointerEventType["PointerMove"] = 2] = "PointerMove";
26660
25088
  })(exports.PointerEventType || (exports.PointerEventType = {}));
26661
- var EventSystem = /*#__PURE__*/ function() {
25089
+ var EventSystem = /*#__PURE__*/ function(EventEmitter) {
25090
+ _inherits(EventSystem, EventEmitter);
26662
25091
  function EventSystem(engine, allowPropagation) {
26663
- var _this = this;
26664
25092
  if (allowPropagation === void 0) allowPropagation = false;
26665
- this.engine = engine;
26666
- this.allowPropagation = allowPropagation;
26667
- this.skipPointerMovePicking = true;
26668
- this.emulateMouseFromTouch = true;
26669
- this.emulateTouchFromMouse = false;
26670
- this._enabled = true;
26671
- this.handlers = {};
26672
- this.nativeHandlers = [];
26673
- this.target = null;
26674
- this.mouseState = null;
26675
- this.touchStates = new Map();
26676
- this.mouseFromTouchIndex = null;
26677
- this.touchFromMousePressed = false;
26678
- this.addedTabIndex = false;
26679
- this.addedOutlineStyle = false;
26680
- this.onNativeWheel = function(event) {
25093
+ var _this;
25094
+ _this = EventEmitter.call(this) || this;
25095
+ _this.engine = engine;
25096
+ _this.allowPropagation = allowPropagation;
25097
+ _this.skipPointerMovePicking = true;
25098
+ _this.emulateMouseFromTouch = true;
25099
+ _this.emulateTouchFromMouse = false;
25100
+ _this._enabled = true;
25101
+ _this.handlers = {};
25102
+ _this.nativeHandlers = [];
25103
+ _this.target = null;
25104
+ _this.mouseState = null;
25105
+ _this.mouseButtonMask = exports.MouseButtonMask.None;
25106
+ _this.touchStates = new Map();
25107
+ _this.mouseFromTouchIndex = null;
25108
+ _this.touchFromMousePressed = false;
25109
+ _this.addedTabIndex = false;
25110
+ _this.addedOutlineStyle = false;
25111
+ _this.onNativeWheel = function(event) {
26681
25112
  if (!_this.enabled || !_this.target) {
26682
25113
  return;
26683
25114
  }
26684
25115
  var position = _this.getCanvasPosition(event.clientX, event.clientY);
26685
25116
  var handled = false;
26686
25117
  if (event.deltaY !== 0) {
26687
- handled = _this.pushWheelButton(event.deltaY < 0 ? exports.MouseButton.WheelUp : exports.MouseButton.WheelDown, Math.abs(event.deltaY), position, event) || handled;
25118
+ handled = _this.pushWheelButton(event.deltaY < 0 ? exports.MouseButton.WheelUp : exports.MouseButton.WheelDown, normalizeWheelFactor(event.deltaY, event.deltaMode), position, event) || handled;
26688
25119
  }
26689
25120
  if (event.deltaX !== 0) {
26690
- handled = _this.pushWheelButton(event.deltaX < 0 ? exports.MouseButton.WheelLeft : exports.MouseButton.WheelRight, Math.abs(event.deltaX), position, event) || handled;
25121
+ handled = _this.pushWheelButton(event.deltaX < 0 ? exports.MouseButton.WheelLeft : exports.MouseButton.WheelRight, normalizeWheelFactor(event.deltaX, event.deltaMode), position, event) || handled;
26691
25122
  }
26692
25123
  _this.consumeNativeEvent(event, handled);
26693
25124
  };
26694
- this.onNativeKeyDown = function(event) {
25125
+ _this.onNativeKeyDown = function(event) {
26695
25126
  _this.handleNativeKey(event, true);
26696
25127
  };
26697
- this.onNativeKeyUp = function(event) {
25128
+ _this.onNativeKeyUp = function(event) {
26698
25129
  _this.handleNativeKey(event, false);
26699
25130
  };
26700
- this.onNativeMouseDown = function(event) {
25131
+ _this.onNativeMouseDown = function(event) {
26701
25132
  _this.handleNativeMouseDown(event);
26702
25133
  };
26703
- this.onNativeMouseMove = function(event) {
25134
+ _this.onNativeMouseMove = function(event) {
26704
25135
  var _state;
26705
25136
  if (!_this.enabled || !_this.target) {
26706
25137
  return;
@@ -26712,18 +25143,22 @@ var EventSystem = /*#__PURE__*/ function() {
26712
25143
  var relative = new Vector2(position.x - state.last.x, position.y - state.last.y);
26713
25144
  var velocity = _this.getVelocity(state, position);
26714
25145
  var handled = _this.pushNativeMouseMotion(event, position, relative, velocity);
26715
- (_state = state).controlHandled || (_state.controlHandled = handled);
26716
- if (!handled && (!state.pressed || !state.controlHandled)) {
25146
+ (_state = state).inputHandled || (_state.inputHandled = handled);
25147
+ if (!handled && (!state.pressed || !state.inputHandled)) {
26717
25148
  var pointerEvent = _this.createPointerEvent(event, position, state, velocity);
26718
25149
  _this.dispatchEvent(EVENT_TYPE_TOUCH_MOVE, pointerEvent);
26719
25150
  }
26720
25151
  _this.updatePointerState(state, position);
26721
25152
  _this.consumeNativeEvent(event, handled);
26722
25153
  };
26723
- this.onNativeMouseUp = function(event) {
25154
+ _this.onNativeMouseUp = function(event) {
26724
25155
  if (!_this.enabled || !_this.target) {
26725
25156
  return;
26726
25157
  }
25158
+ // Keep the canonical mask in sync even when mouseState already ended on a
25159
+ // previous button release. The target and Window listeners may see the
25160
+ // same mouseup, but clearing a bit twice is intentionally idempotent.
25161
+ _this.setMouseButtonPressed(event.button, false);
26727
25162
  var position = _this.getCanvasPosition(event.clientX, event.clientY);
26728
25163
  var existingState = _this.mouseState;
26729
25164
  if (!(existingState == null ? void 0 : existingState.pressed)) {
@@ -26732,16 +25167,16 @@ var EventSystem = /*#__PURE__*/ function() {
26732
25167
  var state = existingState;
26733
25168
  var handled = _this.pushNativeMouseButton(event, position, false);
26734
25169
  var pointerEvent = _this.createPointerEvent(event, position, state);
26735
- if (!state.controlHandled && !handled && _this.isClick(state, position)) {
25170
+ if (!state.inputHandled && !handled && _this.isClick(state, position)) {
26736
25171
  _this.dispatchEvent(EVENT_TYPE_CLICK, pointerEvent);
26737
25172
  }
26738
- if (!handled && !state.controlHandled) {
25173
+ if (!handled && !state.inputHandled) {
26739
25174
  _this.dispatchEvent(EVENT_TYPE_TOUCH_END, pointerEvent);
26740
25175
  }
26741
25176
  _this.mouseState = null;
26742
- _this.consumeNativeEvent(event, handled || state.controlHandled || !_this.allowPropagation);
25177
+ _this.consumeNativeEvent(event, handled || state.inputHandled || !_this.allowPropagation);
26743
25178
  };
26744
- this.onNativeTouchStart = function(event) {
25179
+ _this.onNativeTouchStart = function(event) {
26745
25180
  if (!_this.enabled) {
26746
25181
  return;
26747
25182
  }
@@ -26753,7 +25188,7 @@ var EventSystem = /*#__PURE__*/ function() {
26753
25188
  _this.touchStates.set(touch.identifier, state);
26754
25189
  state.pressed = true;
26755
25190
  var handled = _this.pushNativeScreenTouch(touch.identifier, position, true, false, false);
26756
- state.controlHandled = handled;
25191
+ state.inputHandled = handled;
26757
25192
  if (!handled) {
26758
25193
  var pointerEvent = _this.createPointerEvent(event, position, state);
26759
25194
  _this.dispatchEvent(EVENT_TYPE_TOUCH_START, pointerEvent);
@@ -26762,7 +25197,7 @@ var EventSystem = /*#__PURE__*/ function() {
26762
25197
  }
26763
25198
  _this.preventTouchDefaults(event);
26764
25199
  };
26765
- this.onNativeTouchMove = function(event) {
25200
+ _this.onNativeTouchMove = function(event) {
26766
25201
  if (!_this.enabled) {
26767
25202
  return;
26768
25203
  }
@@ -26776,8 +25211,8 @@ var EventSystem = /*#__PURE__*/ function() {
26776
25211
  var relative = new Vector2(position.x - state.last.x, position.y - state.last.y);
26777
25212
  var velocity = _this.getVelocity(state, position);
26778
25213
  var handled = _this.pushNativeScreenDrag(touch.identifier, position, relative, velocity);
26779
- (_state = state).controlHandled || (_state.controlHandled = handled);
26780
- if (!handled && !state.controlHandled) {
25214
+ (_state = state).inputHandled || (_state.inputHandled = handled);
25215
+ if (!handled && !state.inputHandled) {
26781
25216
  var pointerEvent = _this.createPointerEvent(event, position, state, velocity);
26782
25217
  _this.dispatchEvent(EVENT_TYPE_TOUCH_MOVE, pointerEvent);
26783
25218
  }
@@ -26786,24 +25221,26 @@ var EventSystem = /*#__PURE__*/ function() {
26786
25221
  }
26787
25222
  _this.preventTouchDefaults(event);
26788
25223
  };
26789
- this.onNativeTouchEnd = function(event) {
25224
+ _this.onNativeTouchEnd = function(event) {
26790
25225
  _this.handleNativeTouchEnd(event, false);
26791
25226
  };
26792
- this.onNativeTouchCancel = function(event) {
25227
+ _this.onNativeTouchCancel = function(event) {
26793
25228
  _this.handleNativeTouchEnd(event, true);
26794
25229
  };
26795
- this.onWindowBlur = function() {
26796
- if (_this.enabled) {
26797
- _this.mouseState = null;
26798
- _this.touchStates.clear();
26799
- _this.mouseFromTouchIndex = null;
26800
- _this.touchFromMousePressed = false;
26801
- _this.engine.windowRoot.cancelPointerInput();
26802
- }
25230
+ _this.onCanvasFocus = function() {
25231
+ _this.emit("canvasFocus");
26803
25232
  };
25233
+ _this.onCanvasBlur = function() {
25234
+ _this.emit("canvasBlur");
25235
+ };
25236
+ return _this;
26804
25237
  }
26805
25238
  var _proto = EventSystem.prototype;
26806
- _proto.bindListeners = function bindListeners(target) {
25239
+ /**
25240
+ * Rebinds native input listeners to a canvas.
25241
+ *
25242
+ * Rebind or unbind only while there are no active key, mouse, touch, or drag sessions.
25243
+ */ _proto.bindListeners = function bindListeners(target) {
26807
25244
  this.unbindListeners();
26808
25245
  this.target = target;
26809
25246
  if (!target || typeof window === "undefined") {
@@ -26840,7 +25277,8 @@ var EventSystem = /*#__PURE__*/ function() {
26840
25277
  });
26841
25278
  this.addNativeHandler(target, "keydown", this.onNativeKeyDown);
26842
25279
  this.addNativeHandler(target, "keyup", this.onNativeKeyUp);
26843
- this.addNativeHandler(window, "blur", this.onWindowBlur);
25280
+ this.addNativeHandler(target, "focus", this.onCanvasFocus);
25281
+ this.addNativeHandler(target, "blur", this.onCanvasBlur);
26844
25282
  };
26845
25283
  _proto.dispatchEvent = function dispatchEvent(type, event) {
26846
25284
  var handlers = this.handlers[type];
@@ -26874,11 +25312,7 @@ var EventSystem = /*#__PURE__*/ function() {
26874
25312
  }
26875
25313
  };
26876
25314
  _proto.dispose = function dispose() {
26877
- this.engine.windowRoot.cancelPointerInput();
26878
- this.mouseState = null;
26879
- this.touchStates.clear();
26880
- this.mouseFromTouchIndex = null;
26881
- this.touchFromMousePressed = false;
25315
+ this.resetInputState();
26882
25316
  this.handlers = {};
26883
25317
  this.unbindListeners();
26884
25318
  this.target = null;
@@ -26887,13 +25321,14 @@ var EventSystem = /*#__PURE__*/ function() {
26887
25321
  if (!this.enabled || !this.target) {
26888
25322
  return;
26889
25323
  }
25324
+ this.setMouseButtonPressed(event.button, true);
26890
25325
  var position = this.getCanvasPosition(event.clientX, event.clientY);
26891
25326
  this.focusTarget();
26892
25327
  var state = this.createPointerState(position);
26893
25328
  this.mouseState = state;
26894
25329
  state.pressed = true;
26895
25330
  var handled = this.pushNativeMouseButton(event, position, true);
26896
- state.controlHandled = handled;
25331
+ state.inputHandled = handled;
26897
25332
  if (!handled) {
26898
25333
  var pointerEvent = this.createPointerEvent(event, position, state);
26899
25334
  this.dispatchEvent(EVENT_TYPE_TOUCH_START, pointerEvent);
@@ -26917,8 +25352,7 @@ var EventSystem = /*#__PURE__*/ function() {
26917
25352
  input.altPressed = event.altKey;
26918
25353
  input.metaPressed = event.metaKey;
26919
25354
  input.ctrlPressed = event.ctrlKey;
26920
- this.engine.windowRoot.pushInput(input);
26921
- this.consumeNativeEvent(event, this.engine.windowRoot.isInputHandled());
25355
+ this.consumeNativeEvent(event, this.pushInput(input));
26922
25356
  };
26923
25357
  _proto.handleNativeTouchEnd = function handleNativeTouchEnd(event, canceled) {
26924
25358
  if (!this.enabled) {
@@ -26933,14 +25367,14 @@ var EventSystem = /*#__PURE__*/ function() {
26933
25367
  }
26934
25368
  var handled = this.pushNativeScreenTouch(touch.identifier, position, false, canceled, false);
26935
25369
  var pointerEvent = this.createPointerEvent(event, position, state);
26936
- if (!canceled && !state.controlHandled && !handled && this.isClick(state, position)) {
25370
+ if (!canceled && !state.inputHandled && !handled && this.isClick(state, position)) {
26937
25371
  this.dispatchEvent(EVENT_TYPE_CLICK, pointerEvent);
26938
25372
  }
26939
- if (!handled && !canceled && !state.controlHandled) {
25373
+ if (!handled && !canceled && !state.inputHandled) {
26940
25374
  this.dispatchEvent(EVENT_TYPE_TOUCH_END, pointerEvent);
26941
25375
  }
26942
25376
  this.touchStates.delete(touch.identifier);
26943
- this.consumeNativeEvent(event, handled || state.controlHandled || !this.allowPropagation);
25377
+ this.consumeNativeEvent(event, handled || state.inputHandled || !this.allowPropagation);
26944
25378
  }
26945
25379
  this.preventTouchDefaults(event);
26946
25380
  };
@@ -26960,7 +25394,7 @@ var EventSystem = /*#__PURE__*/ function() {
26960
25394
  };
26961
25395
  _proto.pushNativeMouseMotion = function pushNativeMouseMotion(event, position, relative, velocity) {
26962
25396
  var handled = false;
26963
- if (this.touchFromMousePressed && (event.buttons & 1) !== 0) {
25397
+ if (this.touchFromMousePressed && (this.mouseButtonMask & exports.MouseButtonMask.Left) !== 0) {
26964
25398
  handled = this.pushScreenDrag(0, position, relative, velocity, InputEvent.deviceIdEmulation);
26965
25399
  }
26966
25400
  return this.pushMouseMotion(event, position, relative, velocity) || handled;
@@ -26997,8 +25431,7 @@ var EventSystem = /*#__PURE__*/ function() {
26997
25431
  input.pressed = pressed;
26998
25432
  input.canceled = canceled;
26999
25433
  input.doubleClick = doubleClick;
27000
- this.engine.windowRoot.pushInput(input);
27001
- return this.engine.windowRoot.isInputHandled();
25434
+ return this.pushInput(input);
27002
25435
  };
27003
25436
  _proto.pushEmulatedMouseMotion = function pushEmulatedMouseMotion(position, relative, velocity) {
27004
25437
  var input = new InputEventMouseMotion();
@@ -27011,42 +25444,42 @@ var EventSystem = /*#__PURE__*/ function() {
27011
25444
  input.screenRelative.copyFrom(relative);
27012
25445
  input.velocity.copyFrom(velocity);
27013
25446
  input.screenVelocity.copyFrom(velocity);
27014
- this.engine.windowRoot.pushInput(input);
27015
- return this.engine.windowRoot.isInputHandled();
25447
+ return this.pushInput(input);
27016
25448
  };
27017
25449
  _proto.pushMouseButton = function pushMouseButton(event, position, pressed) {
27018
25450
  var input = new InputEventMouseButton();
27019
25451
  this.copyMouseFields(input, event, position);
27020
25452
  input.device = InputEvent.deviceIdMouse;
27021
25453
  input.buttonIndex = getMouseButton(event.button);
27022
- input.buttonMask = getMouseButtonMask(event.buttons);
25454
+ input.buttonMask = this.mouseButtonMask;
25455
+ input.pressed = pressed;
25456
+ input.doubleClick = event.detail > 1;
25457
+ return this.pushInput(input);
25458
+ };
25459
+ _proto.setMouseButtonPressed = function setMouseButtonPressed(button, pressed) {
25460
+ var buttonBit = getMouseButtonBit(getMouseButton(button));
27023
25461
  if (pressed) {
27024
- input.buttonMask |= getMouseButtonBit(input.buttonIndex);
25462
+ this.mouseButtonMask |= buttonBit;
27025
25463
  } else {
27026
- input.buttonMask &= ~getMouseButtonBit(input.buttonIndex);
25464
+ this.mouseButtonMask &= ~buttonBit;
27027
25465
  }
27028
- input.pressed = pressed;
27029
- input.doubleClick = event.detail > 1;
27030
- this.engine.windowRoot.pushInput(input);
27031
- return this.engine.windowRoot.isInputHandled();
27032
25466
  };
27033
25467
  _proto.pushWheelButton = function pushWheelButton(button, factor, position, event) {
27034
25468
  var input = new InputEventMouseButton();
27035
25469
  this.copyMouseFields(input, event, position);
27036
25470
  input.device = InputEvent.deviceIdMouse;
27037
25471
  input.buttonIndex = button;
27038
- input.buttonMask = getMouseButtonMask(event.buttons);
25472
+ input.buttonMask = this.mouseButtonMask;
27039
25473
  input.factor = factor;
27040
25474
  input.pressed = true;
27041
- this.engine.windowRoot.pushInput(input);
27042
- return this.engine.windowRoot.isInputHandled();
25475
+ return this.pushInput(input);
27043
25476
  };
27044
25477
  _proto.pushMouseMotion = function pushMouseMotion(event, position, relative, velocity) {
27045
25478
  var input = new InputEventMouseMotion();
27046
25479
  this.copyMouseFields(input, event, position);
27047
25480
  input.device = InputEvent.deviceIdMouse;
27048
- input.buttonMask = getMouseButtonMask(event.buttons);
27049
- input.pressed = event.buttons !== 0;
25481
+ input.buttonMask = this.mouseButtonMask;
25482
+ input.pressed = this.mouseButtonMask !== exports.MouseButtonMask.None;
27050
25483
  input.relative.copyFrom(relative);
27051
25484
  input.screenRelative.copyFrom(relative);
27052
25485
  input.velocity.copyFrom(velocity);
@@ -27055,8 +25488,7 @@ var EventSystem = /*#__PURE__*/ function() {
27055
25488
  input.pressure = event.pressure;
27056
25489
  input.tilt.set(event.tiltX, event.tiltY);
27057
25490
  }
27058
- this.engine.windowRoot.pushInput(input);
27059
- return this.engine.windowRoot.isInputHandled();
25491
+ return this.pushInput(input);
27060
25492
  };
27061
25493
  _proto.pushScreenTouch = function pushScreenTouch(index, position, pressed, canceled, doubleTap, device) {
27062
25494
  var input = new InputEventScreenTouch();
@@ -27066,8 +25498,7 @@ var EventSystem = /*#__PURE__*/ function() {
27066
25498
  input.pressed = pressed;
27067
25499
  input.canceled = canceled;
27068
25500
  input.doubleTap = doubleTap;
27069
- this.engine.windowRoot.pushInput(input);
27070
- return this.engine.windowRoot.isInputHandled();
25501
+ return this.pushInput(input);
27071
25502
  };
27072
25503
  _proto.pushScreenDrag = function pushScreenDrag(index, position, relative, velocity, device) {
27073
25504
  var input = new InputEventScreenDrag();
@@ -27079,8 +25510,7 @@ var EventSystem = /*#__PURE__*/ function() {
27079
25510
  input.velocity.copyFrom(velocity);
27080
25511
  input.screenVelocity.copyFrom(velocity);
27081
25512
  input.pressed = true;
27082
- this.engine.windowRoot.pushInput(input);
27083
- return this.engine.windowRoot.isInputHandled();
25513
+ return this.pushInput(input);
27084
25514
  };
27085
25515
  _proto.copyMouseFields = function copyMouseFields(input, event, position) {
27086
25516
  input.position.copyFrom(position);
@@ -27155,7 +25585,7 @@ var EventSystem = /*#__PURE__*/ function() {
27155
25585
  start: position.clone(),
27156
25586
  last: position.clone(),
27157
25587
  lastTime: performance.now(),
27158
- controlHandled: false,
25588
+ inputHandled: false,
27159
25589
  pressed: false
27160
25590
  };
27161
25591
  return state;
@@ -27180,8 +25610,8 @@ var EventSystem = /*#__PURE__*/ function() {
27180
25610
  var _target_width, _target_height;
27181
25611
  return {
27182
25612
  x: position.x / cssWidth * 2 - 1,
27183
- // Legacy composition picking uses bottom-left, Y-up NDC even though GUI
27184
- // input follows the DOM convention of top-left, Y-down pixels.
25613
+ // Legacy composition picking uses bottom-left, Y-up NDC even though
25614
+ // standardized input follows the DOM convention of top-left, Y-down pixels.
27185
25615
  y: 1 - position.y / cssHeight * 2,
27186
25616
  vx: velocity.x / cssWidth * 2,
27187
25617
  vy: -velocity.y / cssHeight * 2,
@@ -27209,6 +25639,11 @@ var EventSystem = /*#__PURE__*/ function() {
27209
25639
  event.stopPropagation();
27210
25640
  }
27211
25641
  };
25642
+ _proto.pushInput = function pushInput(input) {
25643
+ input.clearAccepted();
25644
+ this.emit("input", input);
25645
+ return input.isAccepted();
25646
+ };
27212
25647
  _proto.preventTouchDefaults = function preventTouchDefaults(event) {
27213
25648
  if (event.cancelable) {
27214
25649
  event.preventDefault();
@@ -27218,6 +25653,13 @@ var EventSystem = /*#__PURE__*/ function() {
27218
25653
  var _this_target;
27219
25654
  (_this_target = this.target) == null ? void 0 : _this_target.focus();
27220
25655
  };
25656
+ _proto.resetInputState = function resetInputState() {
25657
+ this.mouseState = null;
25658
+ this.mouseButtonMask = exports.MouseButtonMask.None;
25659
+ this.touchStates.clear();
25660
+ this.mouseFromTouchIndex = null;
25661
+ this.touchFromMousePressed = false;
25662
+ };
27221
25663
  _proto.addNativeHandler = function addNativeHandler(target, name, handler, options) {
27222
25664
  target.addEventListener(name, handler, options);
27223
25665
  this.nativeHandlers.push({
@@ -27248,23 +25690,20 @@ var EventSystem = /*#__PURE__*/ function() {
27248
25690
  get: function get() {
27249
25691
  return this._enabled;
27250
25692
  },
27251
- set: function set(value) {
25693
+ set: /**
25694
+ * Enables native input processing.
25695
+ *
25696
+ * Change this only while there are no active key, mouse, touch, or drag sessions.
25697
+ */ function set(value) {
27252
25698
  if (this._enabled === value) {
27253
25699
  return;
27254
25700
  }
27255
25701
  this._enabled = value;
27256
- if (!value) {
27257
- this.mouseState = null;
27258
- this.touchStates.clear();
27259
- this.mouseFromTouchIndex = null;
27260
- this.touchFromMousePressed = false;
27261
- this.engine.windowRoot.cancelPointerInput();
27262
- }
27263
25702
  }
27264
25703
  }
27265
25704
  ]);
27266
25705
  return EventSystem;
27267
- }();
25706
+ }(EventEmitter);
27268
25707
  function getKeyLocation(location) {
27269
25708
  if (location === 1) {
27270
25709
  return exports.KeyLocation.Left;
@@ -27295,25 +25734,6 @@ function getMouseButton(button) {
27295
25734
  return exports.MouseButton.None;
27296
25735
  }
27297
25736
  }
27298
- function getMouseButtonMask(buttons) {
27299
- var mask = exports.MouseButtonMask.None;
27300
- if ((buttons & 1) !== 0) {
27301
- mask |= exports.MouseButtonMask.Left;
27302
- }
27303
- if ((buttons & 2) !== 0) {
27304
- mask |= exports.MouseButtonMask.Right;
27305
- }
27306
- if ((buttons & 4) !== 0) {
27307
- mask |= exports.MouseButtonMask.Middle;
27308
- }
27309
- if ((buttons & 8) !== 0) {
27310
- mask |= exports.MouseButtonMask.Xbutton1;
27311
- }
27312
- if ((buttons & 16) !== 0) {
27313
- mask |= exports.MouseButtonMask.Xbutton2;
27314
- }
27315
- return mask;
27316
- }
27317
25737
  function getMouseButtonBit(button) {
27318
25738
  switch(button){
27319
25739
  case exports.MouseButton.Left:
@@ -27330,6 +25750,16 @@ function getMouseButtonBit(button) {
27330
25750
  return exports.MouseButtonMask.None;
27331
25751
  }
27332
25752
  }
25753
+ function normalizeWheelFactor(delta, mode) {
25754
+ var magnitude = Math.abs(delta);
25755
+ if (mode === 1) {
25756
+ return magnitude / 3;
25757
+ }
25758
+ if (mode === 2) {
25759
+ return magnitude;
25760
+ }
25761
+ return magnitude / 100;
25762
+ }
27333
25763
 
27334
25764
  var InteractLoader = /*#__PURE__*/ function(Plugin) {
27335
25765
  _inherits(InteractLoader, Plugin);
@@ -29349,6 +27779,11 @@ exports.SpritePropertyTrack = __decorate([
29349
27779
  effectsClass("SpritePropertyTrack")
29350
27780
  ], exports.SpritePropertyTrack);
29351
27781
 
27782
+ function _assert_this_initialized(self) {
27783
+ if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
27784
+ return self;
27785
+ }
27786
+
29352
27787
  var Cone = /*#__PURE__*/ function() {
29353
27788
  function Cone(props) {
29354
27789
  var _this = this;
@@ -39353,7 +37788,7 @@ function getStandardSpriteContent(sprite, transform) {
39353
37788
  return ret;
39354
37789
  }
39355
37790
 
39356
- var version$1 = "2.10.0-alpha.4";
37791
+ var version$1 = "2.10.0-alpha.5";
39357
37792
  var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
39358
37793
  var standardVersion = /^(\d+)\.(\d+)$/;
39359
37794
  var reverseParticle = false;
@@ -41349,9 +39784,11 @@ var PreRenderTickData = /*#__PURE__*/ function(TickData) {
41349
39784
  // Instantiate composition rootItem
41350
39785
  _this.sceneRoot = new exports.VFXItem(_this.engine);
41351
39786
  _this.sceneRoot.setParent(_this.root);
41352
- _this.uiCanvas = _this.sceneRoot.addComponent(UICanvas);
41353
39787
  if (sourceContent) {
41354
39788
  _this.sceneRoot.setInstanceId(sourceContent.id);
39789
+ }
39790
+ PluginSystem.notifyCompositionCreating(_assert_this_initialized(_this), scene);
39791
+ if (sourceContent) {
41355
39792
  _this.sceneRoot.instantiatePreComposition(sourceContent, false);
41356
39793
  }
41357
39794
  // 在 instantiatePreComposition 后设置 rootItem 的 name,避免 name 被覆盖
@@ -41920,9 +40357,6 @@ var PreRenderTickData = /*#__PURE__*/ function(TickData) {
41920
40357
  },
41921
40358
  set: function set(value) {
41922
40359
  this._renderOrder = value;
41923
- if (this.uiCanvas) {
41924
- this.uiCanvas.order = value;
41925
- }
41926
40360
  }
41927
40361
  },
41928
40362
  {
@@ -41935,9 +40369,6 @@ var PreRenderTickData = /*#__PURE__*/ function(TickData) {
41935
40369
  },
41936
40370
  set: function set(value) {
41937
40371
  this._interactive = !!value;
41938
- if (this.uiCanvas) {
41939
- this.uiCanvas.receivesEvents = this._interactive;
41940
- }
41941
40372
  }
41942
40373
  },
41943
40374
  {
@@ -43765,7 +42196,6 @@ var DEFAULT_FPS = 60;
43765
42196
  _this.objectInstance = {};
43766
42197
  _this.root = new exports.VFXItem(_assert_this_initialized(_this));
43767
42198
  _this.root.name = "root";
43768
- _this.windowRoot = new WindowRootControl(_assert_this_initialized(_this));
43769
42199
  _this.whiteTexture = generateWhiteTexture(_assert_this_initialized(_this));
43770
42200
  _this.transparentTexture = generateEmptyTexture(_assert_this_initialized(_this));
43771
42201
  if (!(options == null ? void 0 : options.manualRender)) {
@@ -43918,7 +42348,7 @@ var DEFAULT_FPS = 60;
43918
42348
  (_this_ticker1 = this.ticker) == null ? void 0 : _this_ticker1.pause();
43919
42349
  return;
43920
42350
  }
43921
- this.windowRoot.update(dt);
42351
+ this.emit("update", dt);
43922
42352
  // Tick compositions onPreRender
43923
42353
  //-------------------------------------------------------------------------
43924
42354
  for(var _iterator1 = _create_for_of_iterator_helper_loose(compositions), _step1; !(_step1 = _iterator1()).done;){
@@ -43933,7 +42363,7 @@ var DEFAULT_FPS = 60;
43933
42363
  var composition2 = _step2.value;
43934
42364
  composition2.renderContent();
43935
42365
  }
43936
- this.windowRoot.render();
42366
+ this.emit("postrender");
43937
42367
  this.renderTargetPool.flush();
43938
42368
  };
43939
42369
  /**
@@ -43975,7 +42405,6 @@ var DEFAULT_FPS = 60;
43975
42405
  this.canvas.style.height = containerHeight + "px";
43976
42406
  logger.info("Resize engine " + this.name + " [" + canvasWidth + "," + canvasHeight + "," + containerWidth + "," + containerHeight + "].");
43977
42407
  this.setSize(canvasWidth, canvasHeight);
43978
- this.windowRoot.resize(canvasWidth, canvasHeight);
43979
42408
  }
43980
42409
  };
43981
42410
  _proto.setSize = function setSize(width, height) {
@@ -44181,6 +42610,12 @@ var DEFAULT_FPS = 60;
44181
42610
  _proto.setStencilTest = function setStencilTest(enable) {
44182
42611
  // OVERRIDE
44183
42612
  };
42613
+ _proto.setScissorTest = function setScissorTest(enable) {
42614
+ // OVERRIDE
42615
+ };
42616
+ _proto.setScissor = function setScissor(x, y, width, height) {
42617
+ // OVERRIDE
42618
+ };
44184
42619
  _proto.setCulling = function setCulling(enable) {
44185
42620
  // OVERRIDE
44186
42621
  };
@@ -44258,7 +42693,6 @@ var DEFAULT_FPS = 60;
44258
42693
  composition.dispose();
44259
42694
  }
44260
42695
  this.root.dispose();
44261
- this.windowRoot.dispose();
44262
42696
  (_this_assetService = this.assetService) == null ? void 0 : _this_assetService.dispose();
44263
42697
  (_this__graphics = this._graphics) == null ? void 0 : _this__graphics.dispose();
44264
42698
  this.renderPasses.forEach(function(pass) {
@@ -44583,7 +43017,7 @@ registerPlugin("text", TextLoader);
44583
43017
  registerPlugin("sprite", SpriteLoader);
44584
43018
  registerPlugin("particle", ParticleLoader);
44585
43019
  registerPlugin("interact", InteractLoader);
44586
- var version = "2.10.0-alpha.4";
43020
+ var version = "2.10.0-alpha.5";
44587
43021
  logger.info("Core version: " + version + ".");
44588
43022
 
44589
43023
  exports.ATLAS_SIZE = ATLAS_SIZE;
@@ -44618,8 +43052,6 @@ exports.COPY_MESH_SHADER_ID = COPY_MESH_SHADER_ID;
44618
43052
  exports.COPY_VERTEX_SHADER = COPY_VERTEX_SHADER;
44619
43053
  exports.Camera = Camera;
44620
43054
  exports.CameraVFXItemLoader = CameraVFXItemLoader;
44621
- exports.CanvasContainer = CanvasContainer;
44622
- exports.CanvasRootControl = CanvasRootControl;
44623
43055
  exports.Circle = Circle$1;
44624
43056
  exports.ColorCurve = ColorCurve;
44625
43057
  exports.ColorPlayable = ColorPlayable;
@@ -44632,8 +43064,6 @@ exports.Composition = Composition;
44632
43064
  exports.ConstBoolNode = ConstBoolNode;
44633
43065
  exports.ConstFloatNode = ConstFloatNode;
44634
43066
  exports.ConstraintTarget = ConstraintTarget;
44635
- exports.ContainerControl = ContainerControl;
44636
- exports.Control = Control;
44637
43067
  exports.ControlParameterBoolNode = ControlParameterBoolNode;
44638
43068
  exports.ControlParameterFloatNode = ControlParameterFloatNode;
44639
43069
  exports.ControlParameterTriggerNode = ControlParameterTriggerNode;
@@ -44740,7 +43170,6 @@ exports.RenderTargetPool = RenderTargetPool;
44740
43170
  exports.Renderbuffer = Renderbuffer;
44741
43171
  exports.Renderer = Renderer;
44742
43172
  exports.RendererComponent = RendererComponent;
44743
- exports.RootControl = RootControl;
44744
43173
  exports.RuntimeClip = RuntimeClip;
44745
43174
  exports.SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0 = SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0;
44746
43175
  exports.SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0 = SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0;
@@ -44778,8 +43207,6 @@ exports.TransformPlayable = TransformPlayable;
44778
43207
  exports.TransitionNode = TransitionNode;
44779
43208
  exports.Triangle = Triangle;
44780
43209
  exports.TrimPath = TrimPath;
44781
- exports.UICanvas = UICanvas;
44782
- exports.UIControl = UIControl;
44783
43210
  exports.ValueGetter = ValueGetter;
44784
43211
  exports.ValueNode = ValueNode;
44785
43212
  exports.Vector2Curve = Vector2Curve;
@@ -44789,7 +43216,6 @@ exports.Vector3PropertyMixerPlayable = Vector3PropertyMixerPlayable;
44789
43216
  exports.Vector4Curve = Vector4Curve;
44790
43217
  exports.Vector4PropertyMixerPlayable = Vector4PropertyMixerPlayable;
44791
43218
  exports.VertexBuffer = VertexBuffer;
44792
- exports.WindowRootControl = WindowRootControl;
44793
43219
  exports.addByOrder = addByOrder;
44794
43220
  exports.addItem = addItem;
44795
43221
  exports.addItemWithOrder = addItemWithOrder;