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