@galacean/effects-threejs 2.10.0-alpha.4 → 2.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: Galacean Effects runtime threejs plugin 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
7
7
  */
8
8
 
9
9
  'use strict';
@@ -2259,10 +2259,10 @@ var Color = /*#__PURE__*/ function() {
2259
2259
  };
2260
2260
  _proto.toHexString = function toHexString(includeAlpha) {
2261
2261
  if (includeAlpha === void 0) includeAlpha = true;
2262
- var R = Color.ToHex(Math.round(this.r * 255));
2263
- var G = Color.ToHex(Math.round(this.g * 255));
2264
- var B = Color.ToHex(Math.round(this.b * 255));
2265
- var A = Color.ToHex(Math.round(this.a * 255));
2262
+ var R = Color.ToHex(Math.round(Math.min(Math.max(this.r, 0), 1) * 255));
2263
+ var G = Color.ToHex(Math.round(Math.min(Math.max(this.g, 0), 1) * 255));
2264
+ var B = Color.ToHex(Math.round(Math.min(Math.max(this.b, 0), 1) * 255));
2265
+ var A = Color.ToHex(Math.round(Math.min(Math.max(this.a, 0), 1) * 255));
2266
2266
  if (includeAlpha) {
2267
2267
  return "#" + R + G + B + A;
2268
2268
  } else {
@@ -2308,30 +2308,14 @@ var Color = /*#__PURE__*/ function() {
2308
2308
  * @param v - Gamma 空间颜色值
2309
2309
  * @returns 线性空间颜色值
2310
2310
  */ Color.gammaToLinear = function gammaToLinear(v) {
2311
- if (v <= 0.0) {
2312
- return 0.0;
2313
- } else if (v <= 0.04045) {
2314
- return v / 12.92;
2315
- } else if (v < 1.0) {
2316
- return Math.pow((v + 0.055) / 1.055, 2.4);
2317
- } else {
2318
- return Math.pow(v, 2.4);
2319
- }
2311
+ return v < 0.04045 ? v * 0.0773993808 : Math.pow(v * 0.9478672986 + 0.0521327014, 2.4);
2320
2312
  };
2321
2313
  /**
2322
2314
  * 颜色值从线性空间转到 Gamma 空间
2323
2315
  * @param value - 线性空间颜色值
2324
2316
  * @returns Gamma 空间颜色值
2325
2317
  */ Color.linearToGamma = function linearToGamma(value) {
2326
- if (value <= 0.0) {
2327
- return 0.0;
2328
- } else if (value < 0.0031308) {
2329
- return 12.92 * value;
2330
- } else if (value < 1.0) {
2331
- return 1.055 * Math.pow(value, 0.41666) - 0.055;
2332
- } else {
2333
- return Math.pow(value, 0.41666);
2334
- }
2318
+ return value < 0.0031308 ? value * 12.92 : 1.055 * Math.pow(value, 0.41666) - 0.055;
2335
2319
  };
2336
2320
  Color.ToHex = function ToHex(i) {
2337
2321
  var str = i.toString(16);
@@ -2958,6 +2942,11 @@ var PluginSystem = /*#__PURE__*/ function() {
2958
2942
  PluginSystem.getPlugins = function getPlugins() {
2959
2943
  return plugins;
2960
2944
  };
2945
+ PluginSystem.notifyCompositionCreating = function notifyCompositionCreating(composition, scene) {
2946
+ plugins.forEach(function(plugin) {
2947
+ return plugin.onCompositionCreating(composition, scene);
2948
+ });
2949
+ };
2961
2950
  PluginSystem.notifyCompositionCreated = function notifyCompositionCreated(composition, scene) {
2962
2951
  plugins.forEach(function(plugin) {
2963
2952
  return plugin.onCompositionCreated(composition, scene);
@@ -3050,6 +3039,12 @@ function getPluginUsageInfo(name) {
3050
3039
  * @param engine - 引擎实例
3051
3040
  */ _proto.onAssetsLoadFinish = function onAssetsLoadFinish(scene, options, engine) {};
3052
3041
  /**
3042
+ * 合成内容开始创建前触发。
3043
+ * 此时 root、pluginRoot 和 sceneRoot 已创建,但场景内容尚未实例化。
3044
+ * @param composition - 正在创建的合成对象
3045
+ * @param scene - 场景对象
3046
+ */ _proto.onCompositionCreating = function onCompositionCreating(composition, scene) {};
3047
+ /**
3053
3048
  * 合成创建完成后触发。
3054
3049
  * @param composition - 合成对象
3055
3050
  * @param scene - 场景对象
@@ -3118,7 +3113,8 @@ function _inherits(subClass, superClass) {
3118
3113
  JSONSceneVersion["3_5"] = "3.5";
3119
3114
  JSONSceneVersion["3_6"] = "3.6";
3120
3115
  JSONSceneVersion["3_7"] = "3.7";
3121
- JSONSceneVersion["LATEST"] = "3.7";
3116
+ JSONSceneVersion["3_8"] = "3.8";
3117
+ JSONSceneVersion["LATEST"] = "3.8";
3122
3118
  })(JSONSceneVersion || (JSONSceneVersion = {}));
3123
3119
 
3124
3120
  /*********************************************/ /* 元素属性参数类型 */ /*********************************************/ /**
@@ -3514,6 +3510,9 @@ var CameraClipMode;
3514
3510
  /**
3515
3511
  * Vector3 曲线
3516
3512
  */ ValueType[ValueType["VECTOR3_CURVE"] = 27] = "VECTOR3_CURVE";
3513
+ /**
3514
+ * 对象引用阶梯曲线(不插值)
3515
+ */ ValueType[ValueType["REFERENCE_CURVE"] = 28] = "REFERENCE_CURVE";
3517
3516
  })(ValueType || (ValueType = {}));
3518
3517
  /**
3519
3518
  * 关键帧类型
@@ -3757,6 +3756,15 @@ var BuiltinObjectGUID = {
3757
3756
  UnlitShader: "unlit000000000000000000000000000"
3758
3757
  };
3759
3758
 
3759
+ /**
3760
+ * Sprite UV 旋转方式。序列化为整数(兼容老 splits 的 flip 0/1)。
3761
+ * None 不旋转、Rotate90 将 UV 顺时针旋转 90°(width/height 互换)。
3762
+ */ var SpriteRotation;
3763
+ (function(SpriteRotation) {
3764
+ /** 不旋转 */ SpriteRotation[SpriteRotation["None"] = 0] = "None";
3765
+ /** UV 旋转 90°(对应老 splits flip=1) */ SpriteRotation[SpriteRotation["Rotate90"] = 1] = "Rotate90";
3766
+ })(SpriteRotation || (SpriteRotation = {}));
3767
+
3760
3768
  var FillType;
3761
3769
  (function(FillType) {
3762
3770
  FillType[FillType["Solid"] = 0] = "Solid";
@@ -3868,6 +3876,7 @@ var DataType;
3868
3876
  DataType["Image"] = "Image";
3869
3877
  DataType["AnimationClip"] = "AnimationClip";
3870
3878
  DataType["BinaryAsset"] = "BinaryAsset";
3879
+ DataType["Sprite"] = "Sprite";
3871
3880
  // Timeline
3872
3881
  DataType["TrackAsset"] = "TrackAsset";
3873
3882
  DataType["TimelineAsset"] = "TimelineAsset";
@@ -3881,6 +3890,7 @@ var DataType;
3881
3890
  DataType["Vector2PropertyTrack"] = "Vector2PropertyTrack";
3882
3891
  DataType["Vector3PropertyTrack"] = "Vector3PropertyTrack";
3883
3892
  DataType["Vector4PropertyTrack"] = "Vector4PropertyTrack";
3893
+ DataType["SpritePropertyTrack"] = "SpritePropertyTrack";
3884
3894
  DataType["TransformPlayableAsset"] = "TransformPlayableAsset";
3885
3895
  DataType["SpriteColorPlayableAsset"] = "SpriteColorPlayableAsset";
3886
3896
  DataType["ActivationPlayableAsset"] = "ActivationPlayableAsset";
@@ -3890,6 +3900,7 @@ var DataType;
3890
3900
  DataType["Vector2PropertyPlayableAsset"] = "Vector2PropertyPlayableAsset";
3891
3901
  DataType["Vector3PropertyPlayableAsset"] = "Vector3PropertyPlayableAsset";
3892
3902
  DataType["Vector4PropertyPlayableAsset"] = "Vector4PropertyPlayableAsset";
3903
+ DataType["SpritePropertyPlayableAsset"] = "SpritePropertyPlayableAsset";
3893
3904
  // Components
3894
3905
  DataType["MeshComponent"] = "MeshComponent";
3895
3906
  DataType["SkyboxComponent"] = "SkyboxComponent";
@@ -3916,6 +3927,42 @@ var DataType;
3916
3927
  DataType["FFDComponent"] = "FFDComponent";
3917
3928
  DataType["FrameComponent"] = "FrameComponent";
3918
3929
  DataType["Animator"] = "Animator";
3930
+ DataType["DomContentComponent"] = "DomContentComponent";
3931
+ DataType["UIControl"] = "UIControl";
3932
+ // GUI Controls
3933
+ DataType["Control"] = "Control";
3934
+ DataType["Container"] = "Container";
3935
+ DataType["HBoxContainer"] = "HBoxContainer";
3936
+ DataType["VBoxContainer"] = "VBoxContainer";
3937
+ DataType["GridContainer"] = "GridContainer";
3938
+ DataType["PanelContainer"] = "PanelContainer";
3939
+ DataType["MarginContainer"] = "MarginContainer";
3940
+ DataType["CenterContainer"] = "CenterContainer";
3941
+ DataType["AspectRatioContainer"] = "AspectRatioContainer";
3942
+ DataType["ScrollContainer"] = "ScrollContainer";
3943
+ DataType["HScrollBar"] = "HScrollBar";
3944
+ DataType["VScrollBar"] = "VScrollBar";
3945
+ DataType["HSeparator"] = "HSeparator";
3946
+ DataType["VSeparator"] = "VSeparator";
3947
+ DataType["Label"] = "Label";
3948
+ DataType["LineEdit"] = "LineEdit";
3949
+ DataType["TextEdit"] = "TextEdit";
3950
+ DataType["PopupPanel"] = "PopupPanel";
3951
+ DataType["PopupMenu"] = "PopupMenu";
3952
+ DataType["MenuButton"] = "MenuButton";
3953
+ DataType["OptionButton"] = "OptionButton";
3954
+ DataType["ColorPicker"] = "ColorPicker";
3955
+ DataType["ColorPickerButton"] = "ColorPickerButton";
3956
+ DataType["TextureRect"] = "TextureRect";
3957
+ DataType["NinePatchRect"] = "NinePatchRect";
3958
+ DataType["ColorRect"] = "ColorRect";
3959
+ DataType["Panel"] = "Panel";
3960
+ DataType["ProgressBar"] = "ProgressBar";
3961
+ DataType["Button"] = "Button";
3962
+ DataType["Checkbox"] = "Checkbox";
3963
+ DataType["CheckButton"] = "CheckButton";
3964
+ DataType["HSlider"] = "HSlider";
3965
+ DataType["VSlider"] = "VSlider";
3919
3966
  // Non-EffectObject
3920
3967
  DataType["TimelineClip"] = "TimelineClip";
3921
3968
  })(DataType || (DataType = {}));
@@ -4054,6 +4101,7 @@ var index$1 = /*#__PURE__*/Object.freeze({
4054
4101
  get TextWeight () { return TextWeight; },
4055
4102
  get FontStyle () { return FontStyle; },
4056
4103
  BuiltinObjectGUID: BuiltinObjectGUID,
4104
+ get SpriteRotation () { return SpriteRotation; },
4057
4105
  get FillType () { return FillType; },
4058
4106
  get TexturePaintScaleMode () { return TexturePaintScaleMode; },
4059
4107
  get ShapePrimitiveType () { return ShapePrimitiveType; },
@@ -9230,7 +9278,7 @@ function isUniformStructArray(value) {
9230
9278
  return v.set(this.elements[i * 4], this.elements[i * 4 + 1], this.elements[i * 4 + 2], this.elements[i * 4 + 3]);
9231
9279
  };
9232
9280
  /**
9233
- * 设置相机矩阵
9281
+ * 设置矩阵的朝向旋转部分
9234
9282
  * @param eye - 相机位置
9235
9283
  * @param target - 目标位置
9236
9284
  * @param up - 相机方向
@@ -9240,27 +9288,32 @@ function isUniformStructArray(value) {
9240
9288
  var vY = Matrix4.tempVec1;
9241
9289
  var vZ = Matrix4.tempVec2;
9242
9290
  vZ.subtractVectors(eye, target);
9291
+ if (vZ.lengthSquared() === 0) {
9292
+ vZ.z = 1;
9293
+ }
9243
9294
  vZ.normalize();
9244
9295
  vX.crossVectors(up, vZ);
9296
+ if (vX.lengthSquared() === 0) {
9297
+ if (Math.abs(up.z) === 1) {
9298
+ vZ.x += 0.0001;
9299
+ } else {
9300
+ vZ.z += 0.0001;
9301
+ }
9302
+ vZ.normalize();
9303
+ vX.crossVectors(up, vZ);
9304
+ }
9245
9305
  vX.normalize();
9246
9306
  vY.crossVectors(vZ, vX);
9247
9307
  var te = this.elements;
9248
9308
  te[0] = vX.x;
9249
- te[1] = vY.x;
9250
- te[2] = vZ.x;
9251
- te[3] = 0;
9252
- te[4] = vX.y;
9309
+ te[4] = vY.x;
9310
+ te[8] = vZ.x;
9311
+ te[1] = vX.y;
9253
9312
  te[5] = vY.y;
9254
- te[6] = vZ.y;
9255
- te[7] = 0;
9256
- te[8] = vX.z;
9257
- te[9] = vY.z;
9313
+ te[9] = vZ.y;
9314
+ te[2] = vX.z;
9315
+ te[6] = vY.z;
9258
9316
  te[10] = vZ.z;
9259
- te[11] = 0;
9260
- te[12] = -vX.dot(eye);
9261
- te[13] = -vY.dot(eye);
9262
- te[14] = -vZ.dot(eye);
9263
- te[15] = 1;
9264
9317
  return this;
9265
9318
  };
9266
9319
  /**
@@ -9486,6 +9539,7 @@ function isUniformStructArray(value) {
9486
9539
  te[12] = l * te[0] + m * te[4] + n * te[8] - l + translation.x;
9487
9540
  te[13] = l * te[1] + m * te[5] + n * te[9] - m + translation.y;
9488
9541
  te[14] = l * te[2] + m * te[6] + n * te[10] - n + translation.z;
9542
+ te[15] = 1;
9489
9543
  return this;
9490
9544
  };
9491
9545
  /**
@@ -9777,7 +9831,7 @@ function isUniformStructArray(value) {
9777
9831
  return new Matrix4(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
9778
9832
  };
9779
9833
  /**
9780
- * 创建相机矩阵
9834
+ * 创建朝向旋转矩阵
9781
9835
  * @param eye - 相机位置
9782
9836
  * @param target - 目标位置
9783
9837
  * @param up - 相机方向
@@ -10992,6 +11046,9 @@ Euler.tempMat0 = new Matrix4();
10992
11046
  * @param [out] - 交点
10993
11047
  * @returns
10994
11048
  */ _proto.intersectSphere = function intersectSphere(sphere, out) {
11049
+ if (sphere.radius < 0) {
11050
+ return;
11051
+ }
10995
11052
  var center = sphere.center;
10996
11053
  var vector = Ray.tempVec0.subtractVectors(center, this.origin);
10997
11054
  var tca = vector.dot(this.direction);
@@ -11318,7 +11375,7 @@ Ray.tempVec3 = new Vector3();
11318
11375
  * @returns
11319
11376
  */ _proto.intersectsSphere = function intersectsSphere(sphere) {
11320
11377
  // Find the point on the AABB closest to the sphere center.
11321
- var vector = new Vector3();
11378
+ var vector = Box3.tempVec0;
11322
11379
  this.clampPoint(sphere.center, vector);
11323
11380
  // If that point is inside the sphere, the AABB and sphere intersect.
11324
11381
  return vector.distanceSquared(sphere.center) <= sphere.radius * sphere.radius;
@@ -11404,9 +11461,11 @@ Ray.tempVec3 = new Vector3();
11404
11461
  * @param target
11405
11462
  * @returns
11406
11463
  */ _proto.getBoundingSphere = function getBoundingSphere(target) {
11464
+ if (this.isEmpty()) {
11465
+ return target.makeEmpty();
11466
+ }
11407
11467
  this.getCenter(target.center);
11408
- var vector = new Vector3();
11409
- target.radius = this.getSize(vector).length() * 0.5;
11468
+ target.radius = this.getSize(Box3.tempVec0).length() * 0.5;
11410
11469
  return target;
11411
11470
  };
11412
11471
  /**
@@ -11427,6 +11486,7 @@ Ray.tempVec3 = new Vector3();
11427
11486
  };
11428
11487
  return Box3;
11429
11488
  }();
11489
+ Box3.tempVec0 = new Vector3();
11430
11490
 
11431
11491
  /**
11432
11492
  * 球
@@ -11457,16 +11517,15 @@ Ray.tempVec3 = new Vector3();
11457
11517
  var center = this.center;
11458
11518
  if (optionalCenter !== undefined) {
11459
11519
  center.copyFrom(optionalCenter);
11460
- var maxRadiusSq = 0;
11461
- for(var i = 0; i < points.length; i++){
11462
- maxRadiusSq = Math.max(maxRadiusSq, center.distanceSquared(points[i]));
11463
- }
11464
- this.radius = Math.sqrt(maxRadiusSq);
11465
11520
  } else {
11466
- var box = new Box3().setFromPoints(points);
11521
+ var box = Sphere.tempBox.setFromPoints(points);
11467
11522
  box.getCenter(center);
11468
- this.radius = box.getSize().length() / 2;
11469
11523
  }
11524
+ var maxRadiusSq = 0;
11525
+ for(var i = 0; i < points.length; i++){
11526
+ maxRadiusSq = Math.max(maxRadiusSq, center.distanceSquared(points[i]));
11527
+ }
11528
+ this.radius = Math.sqrt(maxRadiusSq);
11470
11529
  return this;
11471
11530
  };
11472
11531
  /**
@@ -11583,7 +11642,10 @@ Ray.tempVec3 = new Vector3();
11583
11642
  * @param point - 扩展点
11584
11643
  * @returns 扩展结果
11585
11644
  */ _proto.expandByPoint = function expandByPoint(point) {
11586
- var vector = new Vector3().subtractVectors(point, this.center);
11645
+ if (this.isEmpty()) {
11646
+ return this.set(point, 0);
11647
+ }
11648
+ var vector = Sphere.tempVec0.subtractVectors(point, this.center);
11587
11649
  var lengthSquared = vector.lengthSquared();
11588
11650
  if (lengthSquared > this.radius * this.radius) {
11589
11651
  var length = Math.sqrt(lengthSquared);
@@ -11601,30 +11663,42 @@ Ray.tempVec3 = new Vector3();
11601
11663
  * @param sphere - 包围球
11602
11664
  * @returns 求并结果
11603
11665
  */ _proto.union = function union(sphere) {
11604
- // To enclose another sphere into this sphere, we only need to enclose two points:
11605
- // 1) Enclose the farthest point on the other sphere into this sphere.
11606
- // 2) Enclose the opposite point of the farthest point into this sphere.
11607
- var v1 = new Vector3();
11608
- var toFarthestPoint = new Vector3();
11609
- toFarthestPoint.subtractVectors(sphere.center, this.center).normalize().multiply(sphere.radius);
11610
- this.expandByPoint(v1.copyFrom(sphere.center).add(toFarthestPoint));
11611
- this.expandByPoint(v1.copyFrom(sphere.center).subtract(toFarthestPoint));
11666
+ if (sphere.isEmpty()) {
11667
+ return this;
11668
+ }
11669
+ if (this.isEmpty()) {
11670
+ return this.copyFrom(sphere);
11671
+ }
11672
+ if (this.center.equals(sphere.center)) {
11673
+ this.radius = Math.max(this.radius, sphere.radius);
11674
+ } else {
11675
+ var point = Sphere.tempVec0;
11676
+ var offset = Sphere.tempVec1.subtractVectors(sphere.center, this.center).setLength(sphere.radius);
11677
+ this.expandByPoint(point.copyFrom(sphere.center).add(offset));
11678
+ this.expandByPoint(point.copyFrom(sphere.center).subtract(offset));
11679
+ }
11612
11680
  return this;
11613
11681
  };
11614
11682
  /**
11615
- * 包围球求交集
11683
+ * 获取两个包围球交集的保守包围球。部分重叠时,真实交集为透镜形,
11684
+ * 因此结果取两个输入中较小的包围球,并不精确表示交集。
11616
11685
  * @param other - 其它包围球
11617
11686
  * @returns 求交结果
11618
11687
  */ _proto.intersect = function intersect(other) {
11619
- var vector = new Vector3().subtractVectors(this.center, other.center);
11620
- var distance = vector.length();
11621
- var radiusSum = this.radius + other.radius;
11622
- if (distance > radiusSum) {
11688
+ if (this.isEmpty() || other.isEmpty()) {
11623
11689
  return this.makeEmpty();
11624
11690
  }
11625
- this.center = this.center.add(vector.normalize().multiply(distance / 2));
11626
- this.radius = this.radius + other.radius - distance;
11627
- return this;
11691
+ var distance = this.center.distance(other.center);
11692
+ if (distance > this.radius + other.radius) {
11693
+ return this.makeEmpty();
11694
+ }
11695
+ if (this.radius >= distance + other.radius) {
11696
+ return this.copyFrom(other);
11697
+ }
11698
+ if (other.radius >= distance + this.radius) {
11699
+ return this;
11700
+ }
11701
+ return this.radius <= other.radius ? this : this.copyFrom(other);
11628
11702
  };
11629
11703
  /**
11630
11704
  * 包围球判等
@@ -11641,6 +11715,9 @@ Ray.tempVec3 = new Vector3();
11641
11715
  };
11642
11716
  return Sphere;
11643
11717
  }();
11718
+ Sphere$1.tempBox = new Box3();
11719
+ Sphere$1.tempVec0 = new Vector3();
11720
+ Sphere$1.tempVec1 = new Vector3();
11644
11721
 
11645
11722
  var index = /*#__PURE__*/Object.freeze({
11646
11723
  __proto__: null,
@@ -15658,35 +15735,35 @@ function vecMulCombine(out, a, b) {
15658
15735
  }
15659
15736
  return out;
15660
15737
  }
15661
- var _obj$7;
15662
- var particleOriginTranslateMap$1 = (_obj$7 = {}, _obj$7[ParticleOrigin.PARTICLE_ORIGIN_CENTER] = [
15738
+ var _obj$6;
15739
+ var particleOriginTranslateMap$1 = (_obj$6 = {}, _obj$6[ParticleOrigin.PARTICLE_ORIGIN_CENTER] = [
15663
15740
  0,
15664
15741
  0
15665
- ], _obj$7[ParticleOrigin.PARTICLE_ORIGIN_CENTER_BOTTOM] = [
15742
+ ], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_CENTER_BOTTOM] = [
15666
15743
  0,
15667
15744
  -0.5
15668
- ], _obj$7[ParticleOrigin.PARTICLE_ORIGIN_CENTER_TOP] = [
15745
+ ], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_CENTER_TOP] = [
15669
15746
  0,
15670
15747
  0.5
15671
- ], _obj$7[ParticleOrigin.PARTICLE_ORIGIN_LEFT_TOP] = [
15748
+ ], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_LEFT_TOP] = [
15672
15749
  -0.5,
15673
15750
  0.5
15674
- ], _obj$7[ParticleOrigin.PARTICLE_ORIGIN_LEFT_CENTER] = [
15751
+ ], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_LEFT_CENTER] = [
15675
15752
  -0.5,
15676
15753
  0
15677
- ], _obj$7[ParticleOrigin.PARTICLE_ORIGIN_LEFT_BOTTOM] = [
15754
+ ], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_LEFT_BOTTOM] = [
15678
15755
  -0.5,
15679
15756
  -0.5
15680
- ], _obj$7[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_CENTER] = [
15757
+ ], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_CENTER] = [
15681
15758
  0.5,
15682
15759
  0
15683
- ], _obj$7[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_BOTTOM] = [
15760
+ ], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_BOTTOM] = [
15684
15761
  0.5,
15685
15762
  -0.5
15686
- ], _obj$7[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_TOP] = [
15763
+ ], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_TOP] = [
15687
15764
  0.5,
15688
15765
  0.5
15689
- ], _obj$7);
15766
+ ], _obj$6);
15690
15767
  function nearestPowerOfTwo(value) {
15691
15768
  return Math.pow(2, Math.round(Math.log(value) / Math.LN2));
15692
15769
  }
@@ -17424,27 +17501,27 @@ function oldBezierKeyFramesToNew(props) {
17424
17501
  * 对象引用阶梯曲线(spec ValueType.REFERENCE_CURVE)。
17425
17502
  * props 为 [[time, value], ...],value 为已解析的对象引用实例。
17426
17503
  */ var REFERENCE_CURVE = 28;
17427
- var _obj$6;
17428
- var map$1 = (_obj$6 = {}, _obj$6[ValueType.RANDOM] = function(props) {
17504
+ var _obj$5;
17505
+ var map$1 = (_obj$5 = {}, _obj$5[ValueType.RANDOM] = function(props) {
17429
17506
  if (_instanceof1(props[0], Array)) {
17430
17507
  return new RandomVectorValue(props);
17431
17508
  }
17432
17509
  return new RandomValue(props);
17433
- }, _obj$6[ValueType.CONSTANT] = function(props) {
17510
+ }, _obj$5[ValueType.CONSTANT] = function(props) {
17434
17511
  return new StaticValue(props);
17435
- }, _obj$6[ValueType.CONSTANT_VEC2] = function(props) {
17512
+ }, _obj$5[ValueType.CONSTANT_VEC2] = function(props) {
17436
17513
  return new StaticValue(props);
17437
- }, _obj$6[ValueType.CONSTANT_VEC3] = function(props) {
17514
+ }, _obj$5[ValueType.CONSTANT_VEC3] = function(props) {
17438
17515
  return new StaticValue(props);
17439
- }, _obj$6[ValueType.CONSTANT_VEC4] = function(props) {
17516
+ }, _obj$5[ValueType.CONSTANT_VEC4] = function(props) {
17440
17517
  return new StaticValue(props);
17441
- }, _obj$6[ValueType.RGBA_COLOR] = function(props) {
17518
+ }, _obj$5[ValueType.RGBA_COLOR] = function(props) {
17442
17519
  return new StaticValue(props);
17443
- }, _obj$6[ValueType.COLORS] = function(props) {
17520
+ }, _obj$5[ValueType.COLORS] = function(props) {
17444
17521
  return new RandomSetValue(props.map(function(c) {
17445
17522
  return colorToArr$1(c, false);
17446
17523
  }));
17447
- }, _obj$6[ValueType.LINE] = function(props) {
17524
+ }, _obj$5[ValueType.LINE] = function(props) {
17448
17525
  if (props.length === 2 && props[0][0] === 0 && props[1][0] === 1) {
17449
17526
  return new LinearValue([
17450
17527
  props[0][1],
@@ -17452,38 +17529,38 @@ var map$1 = (_obj$6 = {}, _obj$6[ValueType.RANDOM] = function(props) {
17452
17529
  ]);
17453
17530
  }
17454
17531
  return new LineSegments(props);
17455
- }, _obj$6[ValueType.GRADIENT_COLOR] = function(props) {
17532
+ }, _obj$5[ValueType.GRADIENT_COLOR] = function(props) {
17456
17533
  return new GradientValue(props);
17457
- }, _obj$6[ValueType.LINEAR_PATH] = function(pros) {
17534
+ }, _obj$5[ValueType.LINEAR_PATH] = function(pros) {
17458
17535
  return new PathSegments(pros);
17459
- }, _obj$6[ValueType.BEZIER_CURVE] = function(props) {
17536
+ }, _obj$5[ValueType.BEZIER_CURVE] = function(props) {
17460
17537
  if (props.length === 1) {
17461
17538
  return new StaticValue(props[0][1][1]);
17462
17539
  }
17463
17540
  return new BezierCurve(props);
17464
- }, _obj$6[ValueType.BEZIER_CURVE_PATH] = function(props) {
17541
+ }, _obj$5[ValueType.BEZIER_CURVE_PATH] = function(props) {
17465
17542
  if (props[0].length === 1) {
17466
17543
  return new StaticValue(_construct(Vector3, [].concat(props[1][0])));
17467
17544
  }
17468
17545
  return new BezierCurvePath(props);
17469
- }, _obj$6[ValueType.BEZIER_CURVE_QUAT] = function(props) {
17546
+ }, _obj$5[ValueType.BEZIER_CURVE_QUAT] = function(props) {
17470
17547
  if (props[0].length === 1) {
17471
17548
  return new StaticValue(_construct(Quaternion, [].concat(props[1][0])));
17472
17549
  }
17473
17550
  return new BezierCurveQuat(props);
17474
- }, _obj$6[ValueType.COLOR_CURVE] = function(props) {
17551
+ }, _obj$5[ValueType.COLOR_CURVE] = function(props) {
17475
17552
  return new ColorCurve(props);
17476
- }, _obj$6[ValueType.VECTOR4_CURVE] = function(props) {
17553
+ }, _obj$5[ValueType.VECTOR4_CURVE] = function(props) {
17477
17554
  return new Vector4Curve(props);
17478
- }, _obj$6[ValueType.VECTOR2_CURVE] = function(props) {
17555
+ }, _obj$5[ValueType.VECTOR2_CURVE] = function(props) {
17479
17556
  return new Vector2Curve(props);
17480
17557
  }, // TODO: add spec
17481
- _obj$6[VECTOR3_CURVE] = function(props) {
17558
+ _obj$5[VECTOR3_CURVE] = function(props) {
17482
17559
  return new Vector3Curve(props);
17483
17560
  }, // 对象引用阶梯曲线(不插值):props.data 为 [time, value][],value 已解析为 EffectsObject
17484
- _obj$6[REFERENCE_CURVE] = function(props) {
17561
+ _obj$5[REFERENCE_CURVE] = function(props) {
17485
17562
  return new ReferenceCurve(props);
17486
- }, _obj$6);
17563
+ }, _obj$5);
17487
17564
  function createValueGetter(args) {
17488
17565
  if (!args || !isNaN(+args)) {
17489
17566
  return new StaticValue(args || 0);
@@ -21424,8 +21501,8 @@ var vertexBufferSemanticMap = {
21424
21501
  TANGENT_BS2: "aTargetTangent2",
21425
21502
  TANGENT_BS3: "aTargetTangent3"
21426
21503
  };
21427
- var _obj$5;
21428
- var BYTES_TYPE_MAP = (_obj$5 = {}, _obj$5[exports.BufferDataType.Float] = 4, _obj$5[exports.BufferDataType.Int] = 4, _obj$5[exports.BufferDataType.UnsignedInt] = 4, _obj$5[exports.BufferDataType.Short] = 2, _obj$5[exports.BufferDataType.UnsignedShort] = 2, _obj$5[exports.BufferDataType.Byte] = 1, _obj$5[exports.BufferDataType.UnsignedByte] = 1, _obj$5);
21504
+ var _obj$4;
21505
+ var BYTES_TYPE_MAP = (_obj$4 = {}, _obj$4[exports.BufferDataType.Float] = 4, _obj$4[exports.BufferDataType.Int] = 4, _obj$4[exports.BufferDataType.UnsignedInt] = 4, _obj$4[exports.BufferDataType.Short] = 2, _obj$4[exports.BufferDataType.UnsignedShort] = 2, _obj$4[exports.BufferDataType.Byte] = 1, _obj$4[exports.BufferDataType.UnsignedByte] = 1, _obj$4);
21429
21506
  function generateEmptyTypedArray(type) {
21430
21507
  return createTypedArray(type, 0);
21431
21508
  }
@@ -22844,7 +22921,7 @@ var canvasPool = new CanvasPool();
22844
22921
  ctx.textBaseline = "alphabetic";
22845
22922
  ctx.fillStyle = "#ffffff";
22846
22923
  this.paddingPx = GLYPH_PADDING * resolution;
22847
- this.italicScale = fontStyle === "italic" ? 2 : 1;
22924
+ this.italicScale = fontStyle === "italic" || fontStyle === "oblique" ? 2 : 1;
22848
22925
  // ascent/descent 由探针 '|ÉqÅM' 测得 actualBoundingBox(重音字已抬高 ink 顶),
22849
22926
  // 两者内部保持浮点,仅 cell 高做一次外层 ceil — 与 padding 共同保证 cell 内不裁切
22850
22927
  var fontHeightPx = ascentPx + descentPx;
@@ -22942,7 +23019,7 @@ var canvasPool = new CanvasPool();
22942
23019
  * `ATLAS_SIZE × ATLAS_SIZE` 的离屏 canvas atlas,字符按需逐个绘制并打包,
22943
23020
  * `Graphics.drawText` 通过逐字 quad 引用 atlas 子矩形渲染。
22944
23021
  *
22945
- * - 同一段文本不同颜色不会重复 upload(颜色由顶点 `vColor` 乘上字形 alpha)
23022
+ * - 同一段文本不同颜色不会重复 upload(颜色由顶点 `vColor` 与字形 RGBA 相乘)
22946
23023
  * - 同一字体/字号下重复字符只渲染一次,显著减少 canvas → texture 上传次数
22947
23024
  *
22948
23025
  * 入参全部展开(避免调用方每帧创建临时 style 对象触发 GC)
@@ -22956,7 +23033,7 @@ var canvasPool = new CanvasPool();
22956
23033
  /**
22957
23034
  * 取(必要时新建)对应字体的字符 atlas
22958
23035
  */ _proto.getAtlas = function getAtlas(fontSize, fontFamily, fontWeight, fontStyle) {
22959
- // Pixi CanvasText 默认跟随 renderer.resolution;这里对应 Engine.pixelRatio。
23036
+ // 字形 atlas 跟随 Engine.pixelRatio。
22960
23037
  var resolution = this.engine.pixelRatio;
22961
23038
  if (resolution !== this.resolution) {
22962
23039
  this.clear();
@@ -22977,14 +23054,11 @@ var canvasPool = new CanvasPool();
22977
23054
  var probeCtx = probeCanvasAndContext.context;
22978
23055
  var ascentPx = fontSize * 0.8 * resolution;
22979
23056
  var descentPx = fontSize * 0.2 * resolution;
22980
- try {
22981
- probeCtx.font = scaledFontString;
22982
- var m = probeCtx.measureText(METRICS_STRING + BASELINE_SYMBOL);
22983
- ascentPx = m.actualBoundingBoxAscent || ascentPx;
22984
- descentPx = m.actualBoundingBoxDescent || descentPx;
22985
- } finally{
22986
- canvasPool.releaseCanvasAndContext(probeCanvasAndContext);
22987
- }
23057
+ probeCtx.font = scaledFontString;
23058
+ var m = probeCtx.measureText(METRICS_STRING + BASELINE_SYMBOL);
23059
+ ascentPx = m.actualBoundingBoxAscent || ascentPx;
23060
+ descentPx = m.actualBoundingBoxDescent || descentPx;
23061
+ canvasPool.releaseCanvasAndContext(probeCanvasAndContext);
22988
23062
  var atlas = new GlyphAtlas(this.engine, scaledFontString, ascentPx, descentPx, fontStyle, resolution);
22989
23063
  this.atlases.set(fontKey, atlas);
22990
23064
  return atlas;
@@ -23020,6 +23094,10 @@ var FULL_REGION = {
23020
23094
  u1: 1,
23021
23095
  v1: 1
23022
23096
  };
23097
+ var NINE_PATCH_DRAW_SOURCE_SIZE = "aDrawSourceSize";
23098
+ var NINE_PATCH_SOURCE_RECT = "aSourceRect";
23099
+ var NINE_PATCH_MARGINS = "aMargins";
23100
+ var NINE_PATCH_OPTIONS = "aOptions";
23023
23101
  var Graphics = /*#__PURE__*/ function() {
23024
23102
  function Graphics(engine) {
23025
23103
  this.engine = engine;
@@ -23033,6 +23111,10 @@ var Graphics = /*#__PURE__*/ function() {
23033
23111
  this.colors = [];
23034
23112
  this.uvs = [];
23035
23113
  this.indices = [];
23114
+ this.ninePatchDrawSourceSizes = [];
23115
+ this.ninePatchSourceRects = [];
23116
+ this.ninePatchMargins = [];
23117
+ this.ninePatchOptions = [];
23036
23118
  this.lineStyle = {
23037
23119
  width: 1,
23038
23120
  alignment: 0.5,
@@ -23044,6 +23126,9 @@ var Graphics = /*#__PURE__*/ function() {
23044
23126
  this.currentBatchTexture = null;
23045
23127
  this.transformStack = [];
23046
23128
  this.currentTransform = Matrix3.fromIdentity();
23129
+ this.clipStack = [];
23130
+ this.logicalWidth = 1;
23131
+ this.logicalHeight = 1;
23047
23132
  var _obj;
23048
23133
  this.geometry = Geometry.create(this.engine, {
23049
23134
  attributes: (_obj = {}, _obj[VertexBuffer.PositionKind] = {
@@ -23109,6 +23194,51 @@ var Graphics = /*#__PURE__*/ function() {
23109
23194
  drawCount: 6,
23110
23195
  bufferUsage: glContext.DYNAMIC_DRAW
23111
23196
  });
23197
+ var _obj1;
23198
+ this.ninePatchGeometry = Geometry.create(this.engine, {
23199
+ attributes: (_obj1 = {}, _obj1[VertexBuffer.PositionKind] = {
23200
+ type: glContext.FLOAT,
23201
+ size: 2,
23202
+ data: new Float32Array(8)
23203
+ }, _obj1[VertexBuffer.ColorKind] = {
23204
+ type: glContext.FLOAT,
23205
+ size: 4,
23206
+ data: new Float32Array(16)
23207
+ }, _obj1[VertexBuffer.UVKind] = {
23208
+ type: glContext.FLOAT,
23209
+ size: 2,
23210
+ data: new Float32Array(8)
23211
+ }, _obj1[NINE_PATCH_DRAW_SOURCE_SIZE] = {
23212
+ type: glContext.FLOAT,
23213
+ size: 4,
23214
+ data: new Float32Array(16)
23215
+ }, _obj1[NINE_PATCH_SOURCE_RECT] = {
23216
+ type: glContext.FLOAT,
23217
+ size: 4,
23218
+ data: new Float32Array(16)
23219
+ }, _obj1[NINE_PATCH_MARGINS] = {
23220
+ type: glContext.FLOAT,
23221
+ size: 4,
23222
+ data: new Float32Array(16)
23223
+ }, _obj1[NINE_PATCH_OPTIONS] = {
23224
+ type: glContext.FLOAT,
23225
+ size: 4,
23226
+ data: new Float32Array(16)
23227
+ }, _obj1),
23228
+ indices: {
23229
+ data: new Uint16Array([
23230
+ 0,
23231
+ 1,
23232
+ 2,
23233
+ 2,
23234
+ 1,
23235
+ 3
23236
+ ])
23237
+ },
23238
+ mode: glContext.TRIANGLES,
23239
+ drawCount: 6,
23240
+ bufferUsage: glContext.DYNAMIC_DRAW
23241
+ });
23112
23242
  this.coloredMaterial = Material.create(this.engine, {
23113
23243
  shader: {
23114
23244
  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 }",
@@ -23127,12 +23257,21 @@ var Graphics = /*#__PURE__*/ function() {
23127
23257
  this.texturedMaterial.depthTest = false;
23128
23258
  this.texturedMaterial.depthMask = false;
23129
23259
  this.texturedMaterial.blending = true;
23130
- // 文本 atlas 按 Pixi 的方式在上传时预乘 alpha,因此采样后只需应用顶点色和顶点 alpha。
23260
+ this.ninePatchMaterial = Material.create(this.engine, {
23261
+ shader: {
23262
+ 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 }",
23263
+ 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 }"
23264
+ }
23265
+ });
23266
+ this.ninePatchMaterial.depthTest = false;
23267
+ this.ninePatchMaterial.depthMask = false;
23268
+ this.ninePatchMaterial.blending = true;
23269
+ // 文本 atlas 在上传时预乘 alpha,因此纹理 RGB 只需乘顶点色和顶点 alpha。
23131
23270
  // 单独使用 material,避免改变 drawTexture 对普通非预乘纹理的处理。
23132
23271
  this.textMaterial = Material.create(this.engine, {
23133
23272
  shader: {
23134
23273
  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 }",
23135
- 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 }"
23274
+ 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 }"
23136
23275
  }
23137
23276
  });
23138
23277
  this.textMaterial.depthTest = false;
@@ -23148,25 +23287,36 @@ var Graphics = /*#__PURE__*/ function() {
23148
23287
  this.vertices.length = 0;
23149
23288
  this.colors.length = 0;
23150
23289
  this.uvs.length = 0;
23290
+ this.ninePatchDrawSourceSizes.length = 0;
23291
+ this.ninePatchSourceRects.length = 0;
23292
+ this.ninePatchMargins.length = 0;
23293
+ this.ninePatchOptions.length = 0;
23151
23294
  this.transformStack = [];
23152
23295
  this.currentTransform = Matrix3.fromIdentity();
23296
+ this.clipStack = [];
23153
23297
  this.currentBatchType = "colored";
23154
23298
  this.currentBatchTexture = null;
23299
+ this.engine.setScissorTest(false);
23155
23300
  // 创建从屏幕坐标到 NDC 的投影矩阵,屏幕坐标:(0, 0) 在左上角,(width, height) 在右下角,+Y 向下。
23156
- var _this_engine_canvas_getBoundingClientRect = this.engine.canvas.getBoundingClientRect(), width = _this_engine_canvas_getBoundingClientRect.width, height = _this_engine_canvas_getBoundingClientRect.height;
23301
+ var bounds = this.engine.canvas.getBoundingClientRect();
23302
+ var width = bounds.width || this.engine.canvas.width / this.engine.pixelRatio || 1;
23303
+ var height = bounds.height || this.engine.canvas.height / this.engine.pixelRatio || 1;
23304
+ this.logicalWidth = width;
23305
+ this.logicalHeight = height;
23157
23306
  // 正交投影矩阵:将屏幕坐标 [0, width] x [0, height] 映射到 NDC [-1, 1] x [-1, 1]
23158
23307
  var projectionMatrix = new Matrix4(2 / width, 0, 0, 0, 0, -2 / height, 0, 0, 0, 0, -1, 0, -1, 1, 0, 1 // 第四列
23159
23308
  );
23160
23309
  this.coloredMaterial.setMatrix("effects_MatrixVP", projectionMatrix);
23161
23310
  this.texturedMaterial.setMatrix("effects_MatrixVP", projectionMatrix);
23162
23311
  this.textMaterial.setMatrix("effects_MatrixVP", projectionMatrix);
23312
+ this.ninePatchMaterial.setMatrix("effects_MatrixVP", projectionMatrix);
23163
23313
  };
23164
23314
  /**
23165
23315
  * 将当前变换压入栈,并设置新的变换
23166
23316
  * @param transform - 新的变换矩阵(会与当前变换相乘)
23167
23317
  */ _proto.pushTransform = function pushTransform(transform) {
23168
23318
  this.transformStack.push(this.currentTransform.clone());
23169
- this.currentTransform = this.currentTransform.premultiply(transform);
23319
+ this.currentTransform = this.currentTransform.multiply(transform);
23170
23320
  };
23171
23321
  /**
23172
23322
  * 恢复上一个变换
@@ -23178,10 +23328,81 @@ var Graphics = /*#__PURE__*/ function() {
23178
23328
  }
23179
23329
  this.currentTransform = transform;
23180
23330
  };
23331
+ /** Pushes a local rectangular child clip using a screen-space AABB scissor. */ _proto.pushClipRect = function pushClipRect(x, y, width, height) {
23332
+ var elements = this.currentTransform.elements;
23333
+ var corners = [
23334
+ [
23335
+ x,
23336
+ y
23337
+ ],
23338
+ [
23339
+ x + width,
23340
+ y
23341
+ ],
23342
+ [
23343
+ x,
23344
+ y + height
23345
+ ],
23346
+ [
23347
+ x + width,
23348
+ y + height
23349
+ ]
23350
+ ];
23351
+ var left = Infinity;
23352
+ var top = Infinity;
23353
+ var right = -Infinity;
23354
+ var bottom = -Infinity;
23355
+ for(var _iterator = _create_for_of_iterator_helper_loose(corners), _step; !(_step = _iterator()).done;){
23356
+ var corner = _step.value;
23357
+ var transformedX = elements[0] * corner[0] + elements[3] * corner[1] + elements[6];
23358
+ var transformedY = elements[1] * corner[0] + elements[4] * corner[1] + elements[7];
23359
+ left = Math.min(left, transformedX);
23360
+ top = Math.min(top, transformedY);
23361
+ right = Math.max(right, transformedX);
23362
+ bottom = Math.max(bottom, transformedY);
23363
+ }
23364
+ var parent = this.clipStack[this.clipStack.length - 1];
23365
+ if (parent) {
23366
+ left = Math.max(left, parent.x);
23367
+ top = Math.max(top, parent.y);
23368
+ right = Math.min(right, parent.x + parent.width);
23369
+ bottom = Math.min(bottom, parent.y + parent.height);
23370
+ }
23371
+ var clip = {
23372
+ x: left,
23373
+ y: top,
23374
+ width: Math.max(0, right - left),
23375
+ height: Math.max(0, bottom - top)
23376
+ };
23377
+ var previous = parent;
23378
+ this.clipStack.push(clip);
23379
+ if (!this.clipRectsEqual(previous, clip)) {
23380
+ this.flushBatch();
23381
+ this.applyClipRect(clip);
23382
+ }
23383
+ };
23384
+ /** Restores the parent rectangular clip. */ _proto.popClipRect = function popClipRect() {
23385
+ var previous = this.clipStack.pop();
23386
+ if (!previous) {
23387
+ console.warn("Graphics: clip stack is empty.");
23388
+ return;
23389
+ }
23390
+ var clip = this.clipStack[this.clipStack.length - 1];
23391
+ if (!this.clipRectsEqual(previous, clip)) {
23392
+ this.flushBatch();
23393
+ if (clip) {
23394
+ this.applyClipRect(clip);
23395
+ } else {
23396
+ this.engine.setScissorTest(false);
23397
+ }
23398
+ }
23399
+ };
23181
23400
  /**
23182
23401
  * 刷新并渲染所有累积的绘制命令
23183
23402
  */ _proto.end = function end() {
23184
23403
  this.flushBatch();
23404
+ this.clipStack = [];
23405
+ this.engine.setScissorTest(false);
23185
23406
  };
23186
23407
  /**
23187
23408
  * 切换到指定批次类型/纹理。若与当前批次不一致,先 flush 已累积顶点
@@ -23194,6 +23415,24 @@ var Graphics = /*#__PURE__*/ function() {
23194
23415
  this.currentBatchType = type;
23195
23416
  this.currentBatchTexture = texture;
23196
23417
  };
23418
+ _proto.applyClipRect = function applyClipRect(clip) {
23419
+ var framebufferWidth = this.engine.canvas.width;
23420
+ var framebufferHeight = this.engine.canvas.height;
23421
+ var scaleX = framebufferWidth / this.logicalWidth;
23422
+ var scaleY = framebufferHeight / this.logicalHeight;
23423
+ var left = Math.max(0, Math.min(framebufferWidth, Math.floor(clip.x * scaleX)));
23424
+ var top = Math.max(0, Math.min(framebufferHeight, Math.floor(clip.y * scaleY)));
23425
+ var right = Math.max(left, Math.min(framebufferWidth, Math.ceil((clip.x + clip.width) * scaleX)));
23426
+ var bottom = Math.max(top, Math.min(framebufferHeight, Math.ceil((clip.y + clip.height) * scaleY)));
23427
+ this.engine.setScissorTest(true);
23428
+ this.engine.setScissor(left, framebufferHeight - bottom, right - left, bottom - top);
23429
+ };
23430
+ _proto.clipRectsEqual = function clipRectsEqual(left, right) {
23431
+ if (!left || !right) {
23432
+ return left === right;
23433
+ }
23434
+ return left.x === right.x && left.y === right.y && left.width === right.width && left.height === right.height;
23435
+ };
23197
23436
  /**
23198
23437
  * 提交当前累积的顶点到 renderer,清空缓冲(批次内部 flush 不重置 batchType)
23199
23438
  */ _proto.flushBatch = function flushBatch() {
@@ -23207,37 +23446,48 @@ var Graphics = /*#__PURE__*/ function() {
23207
23446
  var colorsArray = new Float32Array(this.colors);
23208
23447
  var uvsArray = new Float32Array(this.uvs);
23209
23448
  var indicesArray = new Uint16Array(this.indices);
23210
- this.updateAttributeData(VertexBuffer.PositionKind, verticesArray, 2);
23211
- this.updateAttributeData(VertexBuffer.ColorKind, colorsArray, 4);
23212
- this.updateAttributeData(VertexBuffer.UVKind, uvsArray, 2);
23213
- this.geometry.setIndexData(indicesArray);
23214
- this.geometry.setDrawCount(this.currentIndexCount);
23449
+ var geometry = this.currentBatchType === "ninePatch" ? this.ninePatchGeometry : this.geometry;
23450
+ this.updateAttributeData(geometry, VertexBuffer.PositionKind, verticesArray, 2);
23451
+ this.updateAttributeData(geometry, VertexBuffer.ColorKind, colorsArray, 4);
23452
+ this.updateAttributeData(geometry, VertexBuffer.UVKind, uvsArray, 2);
23453
+ if (this.currentBatchType === "ninePatch") {
23454
+ this.updateAttributeData(geometry, NINE_PATCH_DRAW_SOURCE_SIZE, new Float32Array(this.ninePatchDrawSourceSizes), 4);
23455
+ this.updateAttributeData(geometry, NINE_PATCH_SOURCE_RECT, new Float32Array(this.ninePatchSourceRects), 4);
23456
+ this.updateAttributeData(geometry, NINE_PATCH_MARGINS, new Float32Array(this.ninePatchMargins), 4);
23457
+ this.updateAttributeData(geometry, NINE_PATCH_OPTIONS, new Float32Array(this.ninePatchOptions), 4);
23458
+ }
23459
+ geometry.setIndexData(indicesArray);
23460
+ geometry.setDrawCount(this.currentIndexCount);
23215
23461
  var material;
23216
- if (this.currentBatchType === "textured" || this.currentBatchType === "text") {
23217
- material = this.currentBatchType === "text" ? this.textMaterial : this.texturedMaterial;
23462
+ if (this.currentBatchType === "textured" || this.currentBatchType === "text" || this.currentBatchType === "ninePatch") {
23463
+ material = this.currentBatchType === "text" ? this.textMaterial : this.currentBatchType === "ninePatch" ? this.ninePatchMaterial : this.texturedMaterial;
23218
23464
  var _this_currentBatchTexture;
23219
23465
  var tex = (_this_currentBatchTexture = this.currentBatchTexture) != null ? _this_currentBatchTexture : this.engine.whiteTexture;
23220
23466
  material.setTexture("uMainTexture", tex);
23221
23467
  } else {
23222
23468
  material = this.coloredMaterial;
23223
23469
  }
23224
- this.engine.renderer.drawGeometry(this.geometry, Matrix4.IDENTITY, material);
23470
+ this.engine.renderer.drawGeometry(geometry, Matrix4.IDENTITY, material);
23225
23471
  this.indices.length = 0;
23226
23472
  this.vertices.length = 0;
23227
23473
  this.colors.length = 0;
23228
23474
  this.uvs.length = 0;
23229
- };
23230
- _proto.updateAttributeData = function updateAttributeData(name, data, size) {
23231
- var _this_geometry_getVertexBuffer;
23232
- var dataBuffer = (_this_geometry_getVertexBuffer = this.geometry.getVertexBuffer(name)) == null ? void 0 : _this_geometry_getVertexBuffer.getBuffer();
23475
+ this.ninePatchDrawSourceSizes.length = 0;
23476
+ this.ninePatchSourceRects.length = 0;
23477
+ this.ninePatchMargins.length = 0;
23478
+ this.ninePatchOptions.length = 0;
23479
+ };
23480
+ _proto.updateAttributeData = function updateAttributeData(geometry, name, data, size) {
23481
+ var _geometry_getVertexBuffer;
23482
+ var dataBuffer = (_geometry_getVertexBuffer = geometry.getVertexBuffer(name)) == null ? void 0 : _geometry_getVertexBuffer.getBuffer();
23233
23483
  if (dataBuffer && data.byteLength > dataBuffer.capacity) {
23234
- this.geometry.setVerticesBuffer(new VertexBuffer(this.engine, data, name, {
23484
+ geometry.setVerticesBuffer(new VertexBuffer(this.engine, data, name, {
23235
23485
  updatable: true,
23236
23486
  size: size
23237
23487
  }));
23238
23488
  return;
23239
23489
  }
23240
- this.geometry.setAttributeData(name, data);
23490
+ geometry.setAttributeData(name, data);
23241
23491
  };
23242
23492
  /**
23243
23493
  * 线段顶点按顺序连接 (p0-p1, p1-p2, p2-p3, ...)
@@ -23406,10 +23656,37 @@ var Graphics = /*#__PURE__*/ function() {
23406
23656
  this.pushQuad(x, y, width, height, color, region);
23407
23657
  };
23408
23658
  /**
23659
+ * Draws a nine-patch as one quad. Stretching and repetition are resolved in the fragment shader,
23660
+ * so Tile and TileFit do not expand into CPU-side geometry.
23661
+ */ _proto.drawNinePatch = function drawNinePatch(x, y, width, height, texture, options, color) {
23662
+ if (color === void 0) color = Color.WHITE;
23663
+ if (width <= 0 || height <= 0 || options.sourceWidth <= 0 || options.sourceHeight <= 0) {
23664
+ return;
23665
+ }
23666
+ this.ensureBatch("ninePatch", texture);
23667
+ var sourceU = options.sourceX / texture.width;
23668
+ var sourceV = 1 - options.sourceY / texture.height;
23669
+ var sourceUSize = options.sourceWidth / texture.width;
23670
+ var sourceVSize = options.sourceHeight / texture.height;
23671
+ var _options_horizontalMode;
23672
+ var horizontalMode = (_options_horizontalMode = options.horizontalMode) != null ? _options_horizontalMode : 0;
23673
+ var _options_verticalMode;
23674
+ var verticalMode = (_options_verticalMode = options.verticalMode) != null ? _options_verticalMode : 0;
23675
+ var _options_drawCenter;
23676
+ var drawCenter = Number((_options_drawCenter = options.drawCenter) != null ? _options_drawCenter : true);
23677
+ this.pushQuad(x, y, width, height, color, FULL_REGION);
23678
+ for(var i = 0; i < 4; i++){
23679
+ this.ninePatchDrawSourceSizes.push(width, height, options.sourceWidth, options.sourceHeight);
23680
+ this.ninePatchSourceRects.push(sourceU, sourceV, sourceUSize, sourceVSize);
23681
+ this.ninePatchMargins.push(options.marginLeft, options.marginTop, options.marginRight, options.marginBottom);
23682
+ this.ninePatchOptions.push(horizontalMode, verticalMode, drawCenter, 0);
23683
+ }
23684
+ };
23685
+ /**
23409
23686
  * 绘制文本(本地坐标,Y 向下,(x, y) 为文本 cell 左上角)。
23410
23687
  *
23411
23688
  * 文本走字符级 bitmap atlas(同一字体下每个字只渲染一次,任意文本组合复用 atlas);
23412
- * `color` 作为乘色与白色字形 alpha 相乘,任意颜色都不会污染 atlas。
23689
+ * `color` atlas 字形 RGBA 相乘,任意颜色都不会污染 atlas。
23413
23690
  *
23414
23691
  * 字体参数全部展开,避免调用方每帧创建临时 style 对象触发 GC
23415
23692
  * @param x - 文本左上角 X 坐标(首字 ink 起始处,含 padding 的 quad 会向左延伸)
@@ -23432,10 +23709,11 @@ var Graphics = /*#__PURE__*/ function() {
23432
23709
  this.ensureBatch("text", atlas.texture);
23433
23710
  var lineHeight = atlas.lineHeight;
23434
23711
  var cursorX = x;
23712
+ var characters = Array.from(text);
23435
23713
  // ensureChar 可能往 atlas canvas 写新字并打 dirty 标;实际 upload 推迟到
23436
23714
  // flushBatch 统一处理,这样一帧多次 drawText 共写同一 atlas 只 upload 一次
23437
- for(var i = 0; i < text.length; i++){
23438
- var info = atlas.ensureChar(text[i]);
23715
+ for(var i = 0; i < characters.length; i++){
23716
+ var info = atlas.ensureChar(characters[i]);
23439
23717
  if (!info) {
23440
23718
  continue;
23441
23719
  }
@@ -23457,11 +23735,35 @@ var Graphics = /*#__PURE__*/ function() {
23457
23735
  cursorX += info.advance;
23458
23736
  }
23459
23737
  };
23738
+ /** Measures text with the same glyph metrics used by {@link drawText}. */ _proto.measureText = function measureText(text, fontSize, fontFamily, fontWeight, fontStyle) {
23739
+ if (fontFamily === void 0) fontFamily = "sans-serif";
23740
+ if (fontWeight === void 0) fontWeight = "normal";
23741
+ if (fontStyle === void 0) fontStyle = "normal";
23742
+ var atlas = this.textCache.getAtlas(fontSize, fontFamily, fontWeight, fontStyle);
23743
+ var characters = Array.from(text);
23744
+ var advances = [];
23745
+ var width = 0;
23746
+ for(var _iterator = _create_for_of_iterator_helper_loose(characters), _step; !(_step = _iterator()).done;){
23747
+ var character = _step.value;
23748
+ var _atlas_ensureChar;
23749
+ var _atlas_ensureChar_advance;
23750
+ var advance = (_atlas_ensureChar_advance = (_atlas_ensureChar = atlas.ensureChar(character)) == null ? void 0 : _atlas_ensureChar.advance) != null ? _atlas_ensureChar_advance : 0;
23751
+ advances.push(advance);
23752
+ width += advance;
23753
+ }
23754
+ return {
23755
+ width: width,
23756
+ lineHeight: atlas.lineHeight,
23757
+ advances: advances
23758
+ };
23759
+ };
23460
23760
  _proto.dispose = function dispose() {
23461
23761
  this.geometry.dispose();
23762
+ this.ninePatchGeometry.dispose();
23462
23763
  this.coloredMaterial.dispose();
23463
23764
  this.texturedMaterial.dispose();
23464
23765
  this.textMaterial.dispose();
23766
+ this.ninePatchMaterial.dispose();
23465
23767
  this.textCache.dispose();
23466
23768
  };
23467
23769
  _proto.buildShape = function buildShape(shape, color) {
@@ -23469,7 +23771,7 @@ var Graphics = /*#__PURE__*/ function() {
23469
23771
  var indexOffset = this.indices.length;
23470
23772
  var vertexOffset = this.vertices.length / 2;
23471
23773
  buildPoints.length = 0;
23472
- shape.build(buildPoints);
23774
+ shape.build(buildPoints, this.getScreenScale());
23473
23775
  shape.triangulate(buildPoints, this.vertices, vertexOffset, this.indices, indexOffset);
23474
23776
  this.applyTransformAndColor(vertexOffset, this.vertices.length / 2 - vertexOffset, color);
23475
23777
  };
@@ -23479,11 +23781,19 @@ var Graphics = /*#__PURE__*/ function() {
23479
23781
  this.indices.length;
23480
23782
  var vertexOffset = this.vertices.length / 2;
23481
23783
  buildPoints.length = 0;
23482
- shape.build(buildPoints);
23784
+ shape.build(buildPoints, this.getScreenScale());
23483
23785
  this.lineStyle.width = thickness;
23484
23786
  buildLine(buildPoints, this.lineStyle, false, closed, this.vertices, 2, vertexOffset, this.indices);
23485
23787
  this.applyTransformAndColor(vertexOffset, this.vertices.length / 2 - vertexOffset, color);
23486
23788
  };
23789
+ _proto.getScreenScale = function getScreenScale() {
23790
+ var transform = this.currentTransform.elements;
23791
+ var transformScaleX = Math.hypot(transform[0], transform[1]);
23792
+ var transformScaleY = Math.hypot(transform[3], transform[4]);
23793
+ var framebufferScaleX = this.engine.canvas.width / this.logicalWidth;
23794
+ var framebufferScaleY = this.engine.canvas.height / this.logicalHeight;
23795
+ return Math.max(transformScaleX * framebufferScaleX, transformScaleY * framebufferScaleY, 1);
23796
+ };
23487
23797
  _proto.setTriangleShape = function setTriangleShape(x1, y1, x2, y2, x3, y3) {
23488
23798
  this.triangleShape.x = x1;
23489
23799
  this.triangleShape.y = y1;
@@ -24532,2107 +24842,6 @@ exports.FrameComponent = __decorate([
24532
24842
  // 第四列 (位移) 乘 1,无需修改
24533
24843
  }
24534
24844
 
24535
- function _assert_this_initialized(self) {
24536
- if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
24537
- return self;
24538
- }
24539
-
24540
- exports.MouseFilter = void 0;
24541
- (function(MouseFilter) {
24542
- MouseFilter[MouseFilter["Stop"] = 0] = "Stop";
24543
- MouseFilter[MouseFilter["Pass"] = 1] = "Pass";
24544
- MouseFilter[MouseFilter["Ignore"] = 2] = "Ignore";
24545
- })(exports.MouseFilter || (exports.MouseFilter = {}));
24546
- exports.MouseBehaviorRecursive = void 0;
24547
- (function(MouseBehaviorRecursive) {
24548
- MouseBehaviorRecursive[MouseBehaviorRecursive["Inherited"] = 0] = "Inherited";
24549
- MouseBehaviorRecursive[MouseBehaviorRecursive["Disabled"] = 1] = "Disabled";
24550
- MouseBehaviorRecursive[MouseBehaviorRecursive["Enabled"] = 2] = "Enabled";
24551
- })(exports.MouseBehaviorRecursive || (exports.MouseBehaviorRecursive = {}));
24552
- exports.MouseButton = void 0;
24553
- (function(MouseButton) {
24554
- MouseButton[MouseButton["None"] = 0] = "None";
24555
- MouseButton[MouseButton["Left"] = 1] = "Left";
24556
- MouseButton[MouseButton["Right"] = 2] = "Right";
24557
- MouseButton[MouseButton["Middle"] = 3] = "Middle";
24558
- MouseButton[MouseButton["WheelUp"] = 4] = "WheelUp";
24559
- MouseButton[MouseButton["WheelDown"] = 5] = "WheelDown";
24560
- MouseButton[MouseButton["WheelLeft"] = 6] = "WheelLeft";
24561
- MouseButton[MouseButton["WheelRight"] = 7] = "WheelRight";
24562
- MouseButton[MouseButton["Xbutton1"] = 8] = "Xbutton1";
24563
- MouseButton[MouseButton["Xbutton2"] = 9] = "Xbutton2";
24564
- })(exports.MouseButton || (exports.MouseButton = {}));
24565
- exports.MouseButtonMask = void 0;
24566
- (function(MouseButtonMask) {
24567
- MouseButtonMask[MouseButtonMask["None"] = 0] = "None";
24568
- MouseButtonMask[MouseButtonMask["Left"] = 1] = "Left";
24569
- MouseButtonMask[MouseButtonMask["Right"] = 2] = "Right";
24570
- MouseButtonMask[MouseButtonMask["Middle"] = 4] = "Middle";
24571
- MouseButtonMask[MouseButtonMask["Xbutton1"] = 128] = "Xbutton1";
24572
- MouseButtonMask[MouseButtonMask["Xbutton2"] = 256] = "Xbutton2";
24573
- })(exports.MouseButtonMask || (exports.MouseButtonMask = {}));
24574
- exports.FocusMode = void 0;
24575
- (function(FocusMode) {
24576
- FocusMode[FocusMode["None"] = 0] = "None";
24577
- FocusMode[FocusMode["Click"] = 1] = "Click";
24578
- FocusMode[FocusMode["All"] = 2] = "All";
24579
- FocusMode[FocusMode["Accessibility"] = 3] = "Accessibility";
24580
- })(exports.FocusMode || (exports.FocusMode = {}));
24581
- exports.FocusBehaviorRecursive = void 0;
24582
- (function(FocusBehaviorRecursive) {
24583
- FocusBehaviorRecursive[FocusBehaviorRecursive["Inherited"] = 0] = "Inherited";
24584
- FocusBehaviorRecursive[FocusBehaviorRecursive["Disabled"] = 1] = "Disabled";
24585
- FocusBehaviorRecursive[FocusBehaviorRecursive["Enabled"] = 2] = "Enabled";
24586
- })(exports.FocusBehaviorRecursive || (exports.FocusBehaviorRecursive = {}));
24587
- exports.KeyLocation = void 0;
24588
- (function(KeyLocation) {
24589
- KeyLocation[KeyLocation["Unspecified"] = 0] = "Unspecified";
24590
- KeyLocation[KeyLocation["Left"] = 1] = "Left";
24591
- KeyLocation[KeyLocation["Right"] = 2] = "Right";
24592
- })(exports.KeyLocation || (exports.KeyLocation = {}));
24593
- exports.CursorShape = void 0;
24594
- (function(CursorShape) {
24595
- CursorShape[CursorShape["Arrow"] = 0] = "Arrow";
24596
- CursorShape[CursorShape["Ibeam"] = 1] = "Ibeam";
24597
- CursorShape[CursorShape["PointingHand"] = 2] = "PointingHand";
24598
- CursorShape[CursorShape["Cross"] = 3] = "Cross";
24599
- CursorShape[CursorShape["Wait"] = 4] = "Wait";
24600
- CursorShape[CursorShape["Busy"] = 5] = "Busy";
24601
- CursorShape[CursorShape["Drag"] = 6] = "Drag";
24602
- CursorShape[CursorShape["CanDrop"] = 7] = "CanDrop";
24603
- CursorShape[CursorShape["Forbidden"] = 8] = "Forbidden";
24604
- CursorShape[CursorShape["Vsize"] = 9] = "Vsize";
24605
- CursorShape[CursorShape["Hsize"] = 10] = "Hsize";
24606
- CursorShape[CursorShape["Bdiagsize"] = 11] = "Bdiagsize";
24607
- CursorShape[CursorShape["Fdiagsize"] = 12] = "Fdiagsize";
24608
- CursorShape[CursorShape["Move"] = 13] = "Move";
24609
- CursorShape[CursorShape["Vsplit"] = 14] = "Vsplit";
24610
- CursorShape[CursorShape["Hsplit"] = 15] = "Hsplit";
24611
- CursorShape[CursorShape["Help"] = 16] = "Help";
24612
- })(exports.CursorShape || (exports.CursorShape = {}));
24613
-
24614
- function _get_prototype_of(o) {
24615
- _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
24616
- return o.__proto__ || Object.getPrototypeOf(o);
24617
- };
24618
- return _get_prototype_of(o);
24619
- }
24620
-
24621
- function _is_native_function(fn) {
24622
- return Function.toString.call(fn).indexOf("[native code]") !== -1;
24623
- }
24624
-
24625
- function _wrap_native_super(Class) {
24626
- var _cache = typeof Map === "function" ? new Map() : undefined;
24627
- _wrap_native_super = function _wrap_native_super(Class) {
24628
- if (Class === null || !_is_native_function(Class)) return Class;
24629
- if (typeof Class !== "function") throw new TypeError("Super expression must either be null or a function");
24630
- if (typeof _cache !== "undefined") {
24631
- if (_cache.has(Class)) return _cache.get(Class);
24632
- _cache.set(Class, Wrapper);
24633
- }
24634
- function Wrapper() {
24635
- return _construct(Class, arguments, _get_prototype_of(this).constructor);
24636
- }
24637
- Wrapper.prototype = Object.create(Class.prototype, {
24638
- constructor: {
24639
- value: Wrapper,
24640
- enumerable: false,
24641
- writable: true,
24642
- configurable: true
24643
- }
24644
- });
24645
- return _set_prototype_of(Wrapper, Class);
24646
- };
24647
- return _wrap_native_super(Class);
24648
- }
24649
-
24650
- function transformPoint(transform, value) {
24651
- var elements = transform.elements;
24652
- return new Vector2(elements[0] * value.x + elements[3] * value.y + elements[6], elements[1] * value.x + elements[4] * value.y + elements[7]);
24653
- }
24654
- function transformVector(transform, value) {
24655
- var elements = transform.elements;
24656
- return new Vector2(elements[0] * value.x + elements[3] * value.y, elements[1] * value.x + elements[4] * value.y);
24657
- }
24658
- var InputEvent = /*#__PURE__*/ function() {
24659
- function InputEvent() {
24660
- this.device = 0;
24661
- this.pressed = false;
24662
- this.canceled = false;
24663
- this._accepted = false;
24664
- }
24665
- var _proto = InputEvent.prototype;
24666
- _proto.accept = function accept() {
24667
- this._accepted = true;
24668
- };
24669
- _proto.clearAccepted = function clearAccepted() {
24670
- this._accepted = false;
24671
- };
24672
- _proto.isAccepted = function isAccepted() {
24673
- return this._accepted;
24674
- };
24675
- _proto.isPressed = function isPressed() {
24676
- return this.pressed && !this.canceled;
24677
- };
24678
- _proto.isReleased = function isReleased() {
24679
- return !this.pressed && !this.canceled;
24680
- };
24681
- _proto.isCanceled = function isCanceled() {
24682
- return this.canceled;
24683
- };
24684
- _proto.isEcho = function isEcho() {
24685
- return false;
24686
- };
24687
- _proto.xformedBy = function xformedBy(transform) {
24688
- return this;
24689
- };
24690
- return InputEvent;
24691
- }();
24692
- InputEvent.deviceIdEmulation = -1;
24693
- InputEvent.deviceIdInternal = -2;
24694
- InputEvent.deviceIdKeyboard = 16;
24695
- InputEvent.deviceIdMouse = 32;
24696
- var InputEventWithModifiers = /*#__PURE__*/ function(InputEvent) {
24697
- _inherits(InputEventWithModifiers, InputEvent);
24698
- function InputEventWithModifiers() {
24699
- var _this;
24700
- _this = InputEvent.apply(this, arguments) || this;
24701
- _this.commandOrControlAutoremap = false;
24702
- _this.shiftPressed = false;
24703
- _this.altPressed = false;
24704
- _this.metaPressed = false;
24705
- _this.ctrlPressed = false;
24706
- return _this;
24707
- }
24708
- var _proto = InputEventWithModifiers.prototype;
24709
- _proto.copyModifiersTo = function copyModifiersTo(event) {
24710
- event.device = this.device;
24711
- event.pressed = this.pressed;
24712
- event.canceled = this.canceled;
24713
- event.commandOrControlAutoremap = this.commandOrControlAutoremap;
24714
- event.shiftPressed = this.shiftPressed;
24715
- event.altPressed = this.altPressed;
24716
- event.metaPressed = this.metaPressed;
24717
- event.ctrlPressed = this.ctrlPressed;
24718
- };
24719
- return InputEventWithModifiers;
24720
- }(_wrap_native_super(InputEvent));
24721
- var InputEventKey = /*#__PURE__*/ function(InputEventWithModifiers) {
24722
- _inherits(InputEventKey, InputEventWithModifiers);
24723
- function InputEventKey() {
24724
- var _this;
24725
- _this = InputEventWithModifiers.apply(this, arguments) || this;
24726
- _this.keycode = "";
24727
- _this.physicalKeycode = "";
24728
- _this.keyLabel = "";
24729
- _this.unicode = 0;
24730
- _this.location = exports.KeyLocation.Unspecified;
24731
- _this.echo = false;
24732
- return _this;
24733
- }
24734
- var _proto = InputEventKey.prototype;
24735
- _proto.isEcho = function isEcho() {
24736
- return this.echo;
24737
- };
24738
- return InputEventKey;
24739
- }(InputEventWithModifiers);
24740
- var InputEventMouse = /*#__PURE__*/ function(InputEventWithModifiers) {
24741
- _inherits(InputEventMouse, InputEventWithModifiers);
24742
- function InputEventMouse() {
24743
- var _this;
24744
- _this = InputEventWithModifiers.apply(this, arguments) || this;
24745
- _this.buttonMask = exports.MouseButtonMask.None;
24746
- _this.position = new Vector2();
24747
- _this.globalPosition = new Vector2();
24748
- return _this;
24749
- }
24750
- var _proto = InputEventMouse.prototype;
24751
- _proto.copyMouseTo = function copyMouseTo(event) {
24752
- this.copyModifiersTo(event);
24753
- event.buttonMask = this.buttonMask;
24754
- event.position.copyFrom(this.position);
24755
- event.globalPosition.copyFrom(this.globalPosition);
24756
- };
24757
- return InputEventMouse;
24758
- }(InputEventWithModifiers);
24759
- var InputEventMouseButton = /*#__PURE__*/ function(InputEventMouse) {
24760
- _inherits(InputEventMouseButton, InputEventMouse);
24761
- function InputEventMouseButton() {
24762
- var _this;
24763
- _this = InputEventMouse.apply(this, arguments) || this;
24764
- _this.factor = 1;
24765
- _this.buttonIndex = exports.MouseButton.None;
24766
- _this.doubleClick = false;
24767
- return _this;
24768
- }
24769
- var _proto = InputEventMouseButton.prototype;
24770
- _proto.xformedBy = function xformedBy(transform) {
24771
- var event = new InputEventMouseButton();
24772
- this.copyMouseTo(event);
24773
- event.position.copyFrom(transformPoint(transform, this.position));
24774
- event.factor = this.factor;
24775
- event.buttonIndex = this.buttonIndex;
24776
- event.doubleClick = this.doubleClick;
24777
- return event;
24778
- };
24779
- return InputEventMouseButton;
24780
- }(InputEventMouse);
24781
- var InputEventMouseMotion = /*#__PURE__*/ function(InputEventMouse) {
24782
- _inherits(InputEventMouseMotion, InputEventMouse);
24783
- function InputEventMouseMotion() {
24784
- var _this;
24785
- _this = InputEventMouse.apply(this, arguments) || this;
24786
- _this.tilt = new Vector2();
24787
- _this.pressure = 0;
24788
- _this.relative = new Vector2();
24789
- _this.screenRelative = new Vector2();
24790
- _this.velocity = new Vector2();
24791
- _this.screenVelocity = new Vector2();
24792
- _this.penInverted = false;
24793
- return _this;
24794
- }
24795
- var _proto = InputEventMouseMotion.prototype;
24796
- _proto.xformedBy = function xformedBy(transform) {
24797
- var event = new InputEventMouseMotion();
24798
- this.copyMouseTo(event);
24799
- event.position.copyFrom(transformPoint(transform, this.position));
24800
- event.tilt.copyFrom(this.tilt);
24801
- event.pressure = this.pressure;
24802
- event.relative.copyFrom(transformVector(transform, this.relative));
24803
- event.screenRelative.copyFrom(this.screenRelative);
24804
- event.velocity.copyFrom(transformVector(transform, this.velocity));
24805
- event.screenVelocity.copyFrom(this.screenVelocity);
24806
- event.penInverted = this.penInverted;
24807
- return event;
24808
- };
24809
- return InputEventMouseMotion;
24810
- }(InputEventMouse);
24811
- var InputEventScreenTouch = /*#__PURE__*/ function(InputEvent) {
24812
- _inherits(InputEventScreenTouch, InputEvent);
24813
- function InputEventScreenTouch() {
24814
- var _this;
24815
- _this = InputEvent.apply(this, arguments) || this;
24816
- _this.index = 0;
24817
- _this.position = new Vector2();
24818
- _this.doubleTap = false;
24819
- return _this;
24820
- }
24821
- var _proto = InputEventScreenTouch.prototype;
24822
- _proto.xformedBy = function xformedBy(transform) {
24823
- var event = new InputEventScreenTouch();
24824
- event.device = this.device;
24825
- event.pressed = this.pressed;
24826
- event.canceled = this.canceled;
24827
- event.index = this.index;
24828
- event.position.copyFrom(transformPoint(transform, this.position));
24829
- event.doubleTap = this.doubleTap;
24830
- return event;
24831
- };
24832
- return InputEventScreenTouch;
24833
- }(_wrap_native_super(InputEvent));
24834
- var InputEventScreenDrag = /*#__PURE__*/ function(InputEvent) {
24835
- _inherits(InputEventScreenDrag, InputEvent);
24836
- function InputEventScreenDrag() {
24837
- var _this;
24838
- _this = InputEvent.apply(this, arguments) || this;
24839
- _this.index = 0;
24840
- _this.position = new Vector2();
24841
- _this.relative = new Vector2();
24842
- _this.screenRelative = new Vector2();
24843
- _this.velocity = new Vector2();
24844
- _this.screenVelocity = new Vector2();
24845
- _this.pressure = 0;
24846
- _this.tilt = new Vector2();
24847
- _this.penInverted = false;
24848
- return _this;
24849
- }
24850
- var _proto = InputEventScreenDrag.prototype;
24851
- _proto.xformedBy = function xformedBy(transform) {
24852
- var event = new InputEventScreenDrag();
24853
- event.device = this.device;
24854
- event.pressed = this.pressed;
24855
- event.canceled = this.canceled;
24856
- event.index = this.index;
24857
- event.position.copyFrom(transformPoint(transform, this.position));
24858
- event.relative.copyFrom(transformVector(transform, this.relative));
24859
- event.screenRelative.copyFrom(this.screenRelative);
24860
- event.velocity.copyFrom(transformVector(transform, this.velocity));
24861
- event.screenVelocity.copyFrom(this.screenVelocity);
24862
- event.pressure = this.pressure;
24863
- event.tilt.copyFrom(this.tilt);
24864
- event.penInverted = this.penInverted;
24865
- return event;
24866
- };
24867
- return InputEventScreenDrag;
24868
- }(_wrap_native_super(InputEvent));
24869
-
24870
- var ANCHOR_PRESET_TABLE = {
24871
- topLeft: [
24872
- 0,
24873
- 0,
24874
- 0,
24875
- 0
24876
- ],
24877
- topRight: [
24878
- 1,
24879
- 0,
24880
- 1,
24881
- 0
24882
- ],
24883
- bottomLeft: [
24884
- 0,
24885
- 1,
24886
- 0,
24887
- 1
24888
- ],
24889
- bottomRight: [
24890
- 1,
24891
- 1,
24892
- 1,
24893
- 1
24894
- ],
24895
- centerLeft: [
24896
- 0,
24897
- 0.5,
24898
- 0,
24899
- 0.5
24900
- ],
24901
- centerTop: [
24902
- 0.5,
24903
- 0,
24904
- 0.5,
24905
- 0
24906
- ],
24907
- centerRight: [
24908
- 1,
24909
- 0.5,
24910
- 1,
24911
- 0.5
24912
- ],
24913
- centerBottom: [
24914
- 0.5,
24915
- 1,
24916
- 0.5,
24917
- 1
24918
- ],
24919
- center: [
24920
- 0.5,
24921
- 0.5,
24922
- 0.5,
24923
- 0.5
24924
- ],
24925
- leftWide: [
24926
- 0,
24927
- 0,
24928
- 0,
24929
- 1
24930
- ],
24931
- topWide: [
24932
- 0,
24933
- 0,
24934
- 1,
24935
- 0
24936
- ],
24937
- rightWide: [
24938
- 1,
24939
- 0,
24940
- 1,
24941
- 1
24942
- ],
24943
- bottomWide: [
24944
- 0,
24945
- 1,
24946
- 1,
24947
- 1
24948
- ],
24949
- vcenterWide: [
24950
- 0.5,
24951
- 0,
24952
- 0.5,
24953
- 1
24954
- ],
24955
- hcenterWide: [
24956
- 0,
24957
- 0.5,
24958
- 1,
24959
- 0.5
24960
- ],
24961
- fullRect: [
24962
- 0,
24963
- 0,
24964
- 1,
24965
- 1
24966
- ]
24967
- };
24968
- /**
24969
- * A drawable GUI object. Controls form a tree independent from the VFXItem
24970
- * scene tree. UIControl is the bridge between both trees.
24971
- */ var Control = /*#__PURE__*/ function() {
24972
- function Control(engine) {
24973
- this.engine = engine;
24974
- this._parent = null;
24975
- this._visible = true;
24976
- this._enabled = true;
24977
- this._mouseFilter = exports.MouseFilter.Stop;
24978
- this._mouseBehaviorRecursive = exports.MouseBehaviorRecursive.Inherited;
24979
- this._focusMode = exports.FocusMode.None;
24980
- this._focusBehaviorRecursive = exports.FocusBehaviorRecursive.Inherited;
24981
- this._defaultCursorShape = exports.CursorShape.Arrow;
24982
- this._rotation = 0;
24983
- this.transformDirty = true;
24984
- this.cachedTransform = new Matrix3();
24985
- this.eventEmitter = new EventEmitter();
24986
- this.disposed = false;
24987
- this./** Scene-tree bridge that owns this GUI object, if any. */ owner = null;
24988
- this.position = new Vector2();
24989
- this.size = new Vector2(1, 1);
24990
- this.anchorMin = new Vector2();
24991
- this.anchorMax = new Vector2();
24992
- this.offsetMin = new Vector2();
24993
- this.offsetMax = new Vector2(1, 1);
24994
- this.pivot = new Vector2(0.5, 0.5);
24995
- this.scale = new Vector2(1, 1);
24996
- this.shear = new Vector2();
24997
- this.mouseForcePassScrollEvents = true;
24998
- this.clipContents = false;
24999
- }
25000
- var _proto = Control.prototype;
25001
- _proto.on = function on(eventName, listener, options) {
25002
- this.eventEmitter.on(eventName, listener, options);
25003
- };
25004
- _proto.off = function off(eventName, listener) {
25005
- this.eventEmitter.off(eventName, listener);
25006
- };
25007
- _proto.setPosition = function setPosition(x, y, keepOffsets) {
25008
- if (keepOffsets === void 0) keepOffsets = false;
25009
- if (this.position.x === x && this.position.y === y) {
25010
- return;
25011
- }
25012
- var rect = {
25013
- position: new Vector2(x, y),
25014
- size: this.size.clone()
25015
- };
25016
- if (keepOffsets && this.parent) {
25017
- this.computeAnchors(rect, this.getParentRect());
25018
- } else {
25019
- this.computeOffsets(rect, this.getParentRect());
25020
- }
25021
- this.updateLayout();
25022
- };
25023
- _proto.setSize = function setSize(width, height) {
25024
- if (this.size.x === width && this.size.y === height) {
25025
- return;
25026
- }
25027
- var rect = {
25028
- position: this.position.clone(),
25029
- size: new Vector2(width, height)
25030
- };
25031
- this.computeOffsets(rect, this.getParentRect());
25032
- this.updateLayout();
25033
- };
25034
- _proto.setScale = function setScale(x, y) {
25035
- if (this.scale.x !== x || this.scale.y !== y) {
25036
- this.scale.set(x, y);
25037
- this.markTransformDirty();
25038
- }
25039
- };
25040
- _proto.setRotation = function setRotation(degrees) {
25041
- if (this._rotation !== degrees) {
25042
- this._rotation = degrees;
25043
- this.markTransformDirty();
25044
- }
25045
- };
25046
- _proto.setShear = function setShear(x, y) {
25047
- if (this.shear.x !== x || this.shear.y !== y) {
25048
- this.shear.set(x, y);
25049
- this.markTransformDirty();
25050
- }
25051
- };
25052
- _proto.setPivot = function setPivot(x, y) {
25053
- if (this.pivot.x !== x || this.pivot.y !== y) {
25054
- this.pivot.set(x, y);
25055
- this.markTransformDirty();
25056
- }
25057
- };
25058
- _proto.setAnchorMin = function setAnchorMin(x, y) {
25059
- if (this.anchorMin.x !== x || this.anchorMin.y !== y) {
25060
- this.anchorMin.set(x, y);
25061
- this.updateLayout();
25062
- }
25063
- };
25064
- _proto.setAnchorMax = function setAnchorMax(x, y) {
25065
- if (this.anchorMax.x !== x || this.anchorMax.y !== y) {
25066
- this.anchorMax.set(x, y);
25067
- this.updateLayout();
25068
- }
25069
- };
25070
- _proto.setOffsetMin = function setOffsetMin(x, y) {
25071
- if (this.offsetMin.x !== x || this.offsetMin.y !== y) {
25072
- this.offsetMin.set(x, y);
25073
- this.updateLayout();
25074
- }
25075
- };
25076
- _proto.setOffsetMax = function setOffsetMax(x, y) {
25077
- if (this.offsetMax.x !== x || this.offsetMax.y !== y) {
25078
- this.offsetMax.set(x, y);
25079
- this.updateLayout();
25080
- }
25081
- };
25082
- _proto.getRect = function getRect() {
25083
- return {
25084
- position: this.position.clone(),
25085
- size: this.size.clone()
25086
- };
25087
- };
25088
- _proto.getTransform2D = function getTransform2D() {
25089
- if (this.transformDirty) {
25090
- var radians = this._rotation * Math.PI / 180;
25091
- var sin = Math.sin(radians);
25092
- var cos = Math.cos(radians);
25093
- var shearX = Math.tan(Math.max(-89, Math.min(89, this.shear.x)) * Math.PI / 180);
25094
- var shearY = Math.tan(Math.max(-89, Math.min(89, this.shear.y)) * Math.PI / 180);
25095
- var a = this.scale.x * (cos - sin * shearY);
25096
- var b = this.scale.x * (sin + cos * shearY);
25097
- var c = this.scale.y * (cos * shearX - sin);
25098
- var d = this.scale.y * (sin * shearX + cos);
25099
- var pivotX = this.pivot.x * this.size.x;
25100
- var pivotY = this.pivot.y * this.size.y;
25101
- var tx = this.position.x + pivotX - a * pivotX - c * pivotY;
25102
- var ty = this.position.y + pivotY - b * pivotX - d * pivotY;
25103
- this.cachedTransform.set(a, b, 0, c, d, 0, tx, ty, 1);
25104
- this.transformDirty = false;
25105
- }
25106
- return this.cachedTransform;
25107
- };
25108
- _proto.setAnchorsPreset = function setAnchorsPreset(preset, keepOffsets) {
25109
- if (keepOffsets === void 0) keepOffsets = true;
25110
- 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];
25111
- if (keepOffsets) {
25112
- this.anchorMin.set(minX, minY);
25113
- this.anchorMax.set(maxX, maxY);
25114
- } else {
25115
- var rect = this.getRect();
25116
- this.anchorMin.set(minX, minY);
25117
- this.anchorMax.set(maxX, maxY);
25118
- this.computeOffsets(rect, this.getParentRect());
25119
- }
25120
- this.updateLayout();
25121
- };
25122
- _proto.setOffsetsPreset = function setOffsetsPreset(preset, margin) {
25123
- if (margin === void 0) margin = 0;
25124
- if (!this.parent) {
25125
- return;
25126
- }
25127
- var parentSize = this.parent.size;
25128
- var width = this.size.x;
25129
- var height = this.size.y;
25130
- var a = this.anchorMin;
25131
- var b = this.anchorMax;
25132
- var minX = 0, maxX = 0, minY = 0, maxY = 0;
25133
- // Left edge.
25134
- switch(preset){
25135
- case "topLeft":
25136
- case "bottomLeft":
25137
- case "centerLeft":
25138
- case "topWide":
25139
- case "bottomWide":
25140
- case "leftWide":
25141
- case "hcenterWide":
25142
- case "fullRect":
25143
- minX = margin - a.x * parentSize.x;
25144
- break;
25145
- case "centerTop":
25146
- case "centerBottom":
25147
- case "center":
25148
- case "vcenterWide":
25149
- minX = 0.5 * parentSize.x - width / 2 - a.x * parentSize.x;
25150
- break;
25151
- default:
25152
- minX = parentSize.x - margin - width - a.x * parentSize.x;
25153
- break;
25154
- }
25155
- switch(preset){
25156
- case "topLeft":
25157
- case "bottomLeft":
25158
- case "centerLeft":
25159
- case "leftWide":
25160
- maxX = margin + width - b.x * parentSize.x;
25161
- break;
25162
- case "centerTop":
25163
- case "centerBottom":
25164
- case "center":
25165
- case "vcenterWide":
25166
- maxX = 0.5 * parentSize.x + width / 2 - b.x * parentSize.x;
25167
- break;
25168
- default:
25169
- maxX = parentSize.x - margin - b.x * parentSize.x;
25170
- break;
25171
- }
25172
- // Top edge.
25173
- switch(preset){
25174
- case "topLeft":
25175
- case "topRight":
25176
- case "centerTop":
25177
- case "leftWide":
25178
- case "rightWide":
25179
- case "topWide":
25180
- case "vcenterWide":
25181
- case "fullRect":
25182
- minY = margin - a.y * parentSize.y;
25183
- break;
25184
- case "centerLeft":
25185
- case "centerRight":
25186
- case "center":
25187
- case "hcenterWide":
25188
- minY = 0.5 * parentSize.y - height / 2 - a.y * parentSize.y;
25189
- break;
25190
- default:
25191
- minY = parentSize.y - margin - height - a.y * parentSize.y;
25192
- break;
25193
- }
25194
- // Bottom edge.
25195
- switch(preset){
25196
- case "topLeft":
25197
- case "topRight":
25198
- case "centerTop":
25199
- case "topWide":
25200
- maxY = margin + height - b.y * parentSize.y;
25201
- break;
25202
- case "centerLeft":
25203
- case "centerRight":
25204
- case "center":
25205
- case "hcenterWide":
25206
- maxY = 0.5 * parentSize.y + height / 2 - b.y * parentSize.y;
25207
- break;
25208
- default:
25209
- maxY = parentSize.y - margin - b.y * parentSize.y;
25210
- break;
25211
- }
25212
- this.offsetMin.set(minX, minY);
25213
- this.offsetMax.set(maxX, maxY);
25214
- this.updateLayout();
25215
- };
25216
- _proto.setAnchorsAndOffsetsPreset = function setAnchorsAndOffsetsPreset(preset, margin) {
25217
- if (margin === void 0) margin = 0;
25218
- this.setAnchorsPreset(preset, false);
25219
- this.setOffsetsPreset(preset, margin);
25220
- };
25221
- _proto.getGlobalTransform2D = function getGlobalTransform2D() {
25222
- var local = this.getTransform2D();
25223
- return this.parent ? new Matrix3().multiplyMatrices(this.parent.getGlobalTransform2D(), local) : local.clone();
25224
- };
25225
- _proto.hasPoint = function hasPoint(point) {
25226
- return point.x >= 0 && point.y >= 0 && point.x <= this.size.x && point.y <= this.size.y;
25227
- };
25228
- _proto.getEffectiveMouseFilter = function getEffectiveMouseFilter() {
25229
- return this.enabledInHierarchy && this.isMouseRecursiveEnabled() ? this.mouseFilter : exports.MouseFilter.Ignore;
25230
- };
25231
- _proto.getFocusModeWithOverride = function getFocusModeWithOverride() {
25232
- return this.enabledInHierarchy && this.isFocusRecursiveEnabled() ? this.focusMode : exports.FocusMode.None;
25233
- };
25234
- _proto.getCursorShape = function getCursorShape(position) {
25235
- return this.defaultCursorShape;
25236
- };
25237
- _proto.focus = function focus() {
25238
- var _this_root;
25239
- (_this_root = this.root) == null ? void 0 : _this_root.grabControlFocus(this);
25240
- };
25241
- _proto.grabFocus = function grabFocus() {
25242
- this.focus();
25243
- };
25244
- _proto.grabClickFocus = function grabClickFocus() {
25245
- var _this_root;
25246
- (_this_root = this.root) == null ? void 0 : _this_root.grabControlClickFocus(this);
25247
- };
25248
- _proto.releaseFocus = function releaseFocus() {
25249
- var _this_root;
25250
- (_this_root = this.root) == null ? void 0 : _this_root.releaseControlFocus(this);
25251
- };
25252
- _proto.warpMouse = function warpMouse(position) {
25253
- var _this_root;
25254
- var matrix = this.getGlobalTransform2D().elements;
25255
- (_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]));
25256
- };
25257
- /** Converts a window-space position into this control's local coordinates. */ _proto.makePositionLocal = function makePositionLocal(position) {
25258
- var transform = this.getGlobalTransform2D().clone();
25259
- if (Math.abs(transform.determinant()) < 1e-12) {
25260
- return new Vector2();
25261
- }
25262
- var elements = transform.invert().elements;
25263
- return new Vector2(elements[0] * position.x + elements[3] * position.y + elements[6], elements[1] * position.x + elements[4] * position.y + elements[7]);
25264
- };
25265
- /** Gets the current mouse position transformed into this control's coordinates. */ _proto.getLocalMousePosition = function getLocalMousePosition() {
25266
- var root = this.root;
25267
- return root ? this.makePositionLocal(root.getMousePosition()) : new Vector2();
25268
- };
25269
- _proto.update = function update(deltaTime) {};
25270
- _proto.draw = function draw() {
25271
- // OVERRIDE
25272
- };
25273
- _proto.onDestroy = function onDestroy() {};
25274
- /** @internal */ _proto.drawInternal = function drawInternal() {
25275
- if (!this.visibleInHierarchy || this.disposed) {
25276
- return;
25277
- }
25278
- var graphics = this.engine.graphics;
25279
- graphics.pushTransform(this.getTransform2D());
25280
- this.draw();
25281
- graphics.popTransform();
25282
- };
25283
- _proto.drawLine = function drawLine(x1, y1, x2, y2, color, thickness) {
25284
- this.engine.graphics.drawLine(x1, y1, x2, y2, color, thickness);
25285
- };
25286
- _proto.drawPolyline = function drawPolyline(points, color, thickness) {
25287
- this.engine.graphics.drawLines(points, color, thickness);
25288
- };
25289
- _proto.drawBezier = function drawBezier(x1, y1, x2, y2, x3, y3, x4, y4, color, thickness) {
25290
- this.engine.graphics.drawBezier(x1, y1, x2, y2, x3, y3, x4, y4, color, thickness);
25291
- };
25292
- _proto.drawTriangle = function drawTriangle(x1, y1, x2, y2, x3, y3, color, thickness) {
25293
- this.engine.graphics.drawTriangle(x1, y1, x2, y2, x3, y3, color, thickness);
25294
- };
25295
- _proto.drawRect = function drawRect(x, y, width, height, color, thickness) {
25296
- this.engine.graphics.drawRectangle(x, y, width, height, color, thickness);
25297
- };
25298
- _proto.drawCircle = function drawCircle(cx, cy, radius, color, thickness) {
25299
- this.engine.graphics.drawCircle(cx, cy, radius, color, thickness);
25300
- };
25301
- _proto.fillTriangle = function fillTriangle(x1, y1, x2, y2, x3, y3, color) {
25302
- this.engine.graphics.fillTriangle(x1, y1, x2, y2, x3, y3, color);
25303
- };
25304
- _proto.fillRect = function fillRect(x, y, width, height, color) {
25305
- this.engine.graphics.fillRectangle(x, y, width, height, color);
25306
- };
25307
- _proto.fillCircle = function fillCircle(cx, cy, radius, color) {
25308
- this.engine.graphics.fillCircle(cx, cy, radius, color);
25309
- };
25310
- _proto.drawTexture = function drawTexture(x, y, width, height, texture, region, color) {
25311
- this.engine.graphics.drawTexture(x, y, width, height, texture, region, color);
25312
- };
25313
- _proto.drawText = function drawText(x, y, text, fontSize, color, fontFamily, fontWeight, fontStyle) {
25314
- this.engine.graphics.drawText(x, y, text, fontSize, color, fontFamily, fontWeight, fontStyle);
25315
- };
25316
- _proto.onMouseEnter = function onMouseEnter(location) {};
25317
- _proto.onMouseMove = function onMouseMove(event) {};
25318
- _proto.onMouseLeave = function onMouseLeave() {};
25319
- _proto.onMouseWheel = function onMouseWheel(event) {};
25320
- _proto.onMouseDown = function onMouseDown(event) {};
25321
- _proto.onMouseUp = function onMouseUp(event) {};
25322
- _proto.onTouchDown = function onTouchDown(event) {};
25323
- _proto.onTouchMove = function onTouchMove(event) {};
25324
- _proto.onTouchUp = function onTouchUp(event) {};
25325
- _proto.onKeyDown = function onKeyDown(event) {};
25326
- _proto.onKeyUp = function onKeyUp(event) {};
25327
- _proto.onGotFocus = function onGotFocus() {};
25328
- _proto.onLostFocus = function onLostFocus() {};
25329
- /** @internal */ _proto.invokeGetDragData = function invokeGetDragData(position) {
25330
- return this.getDragData(position);
25331
- };
25332
- /** @internal */ _proto.invokeCanDropData = function invokeCanDropData(position, data) {
25333
- return this.canDropData(position, data);
25334
- };
25335
- /** @internal */ _proto.invokeDropData = function invokeDropData(position, data) {
25336
- this.dropData(position, data);
25337
- };
25338
- _proto.getDragData = function getDragData(position) {
25339
- return null;
25340
- };
25341
- _proto.canDropData = function canDropData(position, data) {
25342
- return false;
25343
- };
25344
- _proto.dropData = function dropData(position, data) {};
25345
- _proto.dispose = function dispose() {
25346
- if (this.disposed) {
25347
- return;
25348
- }
25349
- this.disposed = true;
25350
- this.onDestroy();
25351
- this.parent = null;
25352
- this.owner = null;
25353
- };
25354
- /** @internal */ _proto.updateLayout = function updateLayout() {
25355
- var _this_parent;
25356
- var _this_parent_size;
25357
- var parentSize = (_this_parent_size = (_this_parent = this.parent) == null ? void 0 : _this_parent.size) != null ? _this_parent_size : new Vector2();
25358
- var left = this.offsetMin.x + this.anchorMin.x * parentSize.x;
25359
- var top = this.offsetMin.y + this.anchorMin.y * parentSize.y;
25360
- var right = this.offsetMax.x + this.anchorMax.x * parentSize.x;
25361
- var bottom = this.offsetMax.y + this.anchorMax.y * parentSize.y;
25362
- this.applyBounds(left, top, right - left, bottom - top);
25363
- };
25364
- _proto.applyBounds = function applyBounds(x, y, width, height) {
25365
- var locationChanged = this.position.x !== x || this.position.y !== y;
25366
- var sizeChanged = this.size.x !== width || this.size.y !== height;
25367
- if (!locationChanged && !sizeChanged) {
25368
- return;
25369
- }
25370
- this.position.set(x, y);
25371
- this.size.set(width, height);
25372
- this.markTransformDirty();
25373
- if (locationChanged) {
25374
- this.eventEmitter.emit("locationChanged", this);
25375
- }
25376
- if (sizeChanged) {
25377
- this.eventEmitter.emit("sizeChanged", this);
25378
- if (_instanceof1(this, ContainerControl)) {
25379
- for(var _iterator = _create_for_of_iterator_helper_loose(this.children.slice()), _step; !(_step = _iterator()).done;){
25380
- var child = _step.value;
25381
- child.updateLayout();
25382
- }
25383
- }
25384
- }
25385
- };
25386
- _proto.markTransformDirty = function markTransformDirty() {
25387
- var _this_root;
25388
- this.transformDirty = true;
25389
- (_this_root = this.root) == null ? void 0 : _this_root.controlTreeChanged();
25390
- };
25391
- _proto.getParentRect = function getParentRect() {
25392
- var _this_parent;
25393
- var _this_parent_size_clone;
25394
- return {
25395
- position: new Vector2(),
25396
- size: (_this_parent_size_clone = (_this_parent = this.parent) == null ? void 0 : _this_parent.size.clone()) != null ? _this_parent_size_clone : new Vector2()
25397
- };
25398
- };
25399
- _proto.computeOffsets = function computeOffsets(rect, parentRect) {
25400
- 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);
25401
- 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);
25402
- };
25403
- _proto.computeAnchors = function computeAnchors(rect, parentRect) {
25404
- if (parentRect.size.x !== 0) {
25405
- this.anchorMin.x = (rect.position.x - parentRect.position.x - this.offsetMin.x) / parentRect.size.x;
25406
- this.anchorMax.x = (rect.position.x + rect.size.x - parentRect.position.x - this.offsetMax.x) / parentRect.size.x;
25407
- }
25408
- if (parentRect.size.y !== 0) {
25409
- this.anchorMin.y = (rect.position.y - parentRect.position.y - this.offsetMin.y) / parentRect.size.y;
25410
- this.anchorMax.y = (rect.position.y + rect.size.y - parentRect.position.y - this.offsetMax.y) / parentRect.size.y;
25411
- }
25412
- };
25413
- _proto.isMouseRecursiveEnabled = function isMouseRecursiveEnabled() {
25414
- if (this.mouseBehaviorRecursive === exports.MouseBehaviorRecursive.Inherited) {
25415
- var _this_parent;
25416
- var _this_parent_isMouseRecursiveEnabled;
25417
- return (_this_parent_isMouseRecursiveEnabled = (_this_parent = this.parent) == null ? void 0 : _this_parent.isMouseRecursiveEnabled()) != null ? _this_parent_isMouseRecursiveEnabled : true;
25418
- }
25419
- return this.mouseBehaviorRecursive === exports.MouseBehaviorRecursive.Enabled;
25420
- };
25421
- _proto.isFocusRecursiveEnabled = function isFocusRecursiveEnabled() {
25422
- if (this.focusBehaviorRecursive === exports.FocusBehaviorRecursive.Inherited) {
25423
- var _this_parent;
25424
- var _this_parent_isFocusRecursiveEnabled;
25425
- return (_this_parent_isFocusRecursiveEnabled = (_this_parent = this.parent) == null ? void 0 : _this_parent.isFocusRecursiveEnabled()) != null ? _this_parent_isFocusRecursiveEnabled : true;
25426
- }
25427
- return this.focusBehaviorRecursive === exports.FocusBehaviorRecursive.Enabled;
25428
- };
25429
- _create_class(Control, [
25430
- {
25431
- key: "parent",
25432
- get: function get() {
25433
- return this._parent;
25434
- },
25435
- set: function set(value) {
25436
- var _this__parent;
25437
- if (value === this._parent) {
25438
- return;
25439
- }
25440
- var previousRoot = this.root;
25441
- (_this__parent = this._parent) == null ? void 0 : _this__parent.removeChildInternal(this);
25442
- this._parent = value;
25443
- value == null ? void 0 : value.addChildInternal(this);
25444
- this.updateLayout();
25445
- var nextRoot = this.root;
25446
- if (previousRoot && previousRoot !== nextRoot) {
25447
- previousRoot.controlRemoved(this);
25448
- }
25449
- nextRoot == null ? void 0 : nextRoot.controlTreeChanged();
25450
- this.eventEmitter.emit("parentChanged", this);
25451
- }
25452
- },
25453
- {
25454
- key: "item",
25455
- get: /** Scene item exposed through the optional UIControl bridge. */ function get() {
25456
- var _this_owner;
25457
- var _this_owner_item;
25458
- return (_this_owner_item = (_this_owner = this.owner) == null ? void 0 : _this_owner.item) != null ? _this_owner_item : null;
25459
- }
25460
- },
25461
- {
25462
- key: "indexInParent",
25463
- get: function get() {
25464
- var _this_parent;
25465
- var _this_parent_getChildIndex;
25466
- return (_this_parent_getChildIndex = (_this_parent = this.parent) == null ? void 0 : _this_parent.getChildIndex(this)) != null ? _this_parent_getChildIndex : -1;
25467
- },
25468
- set: function set(value) {
25469
- var _this_parent;
25470
- (_this_parent = this.parent) == null ? void 0 : _this_parent.changeChildIndex(this, value);
25471
- }
25472
- },
25473
- {
25474
- key: "visible",
25475
- get: function get() {
25476
- return this._visible;
25477
- },
25478
- set: function set(value) {
25479
- if (this._visible !== value) {
25480
- var _this_root;
25481
- this._visible = value;
25482
- (_this_root = this.root) == null ? void 0 : _this_root.controlStateChanged(this);
25483
- }
25484
- }
25485
- },
25486
- {
25487
- key: "visibleInHierarchy",
25488
- get: function get() {
25489
- var _this_parent;
25490
- var _this_parent_visibleInHierarchy;
25491
- return this.visible && ((_this_parent_visibleInHierarchy = (_this_parent = this.parent) == null ? void 0 : _this_parent.visibleInHierarchy) != null ? _this_parent_visibleInHierarchy : true);
25492
- }
25493
- },
25494
- {
25495
- key: "enabled",
25496
- get: function get() {
25497
- return this._enabled;
25498
- },
25499
- set: function set(value) {
25500
- if (this._enabled !== value) {
25501
- var _this_root;
25502
- this._enabled = value;
25503
- (_this_root = this.root) == null ? void 0 : _this_root.controlStateChanged(this);
25504
- }
25505
- }
25506
- },
25507
- {
25508
- key: "enabledInHierarchy",
25509
- get: function get() {
25510
- var _this_parent;
25511
- var _this_parent_enabledInHierarchy;
25512
- return this.enabled && ((_this_parent_enabledInHierarchy = (_this_parent = this.parent) == null ? void 0 : _this_parent.enabledInHierarchy) != null ? _this_parent_enabledInHierarchy : true);
25513
- }
25514
- },
25515
- {
25516
- key: "mouseFilter",
25517
- get: function get() {
25518
- return this._mouseFilter;
25519
- },
25520
- set: function set(value) {
25521
- if (this._mouseFilter !== value) {
25522
- var _this_root;
25523
- this._mouseFilter = value;
25524
- (_this_root = this.root) == null ? void 0 : _this_root.controlStateChanged(this);
25525
- }
25526
- }
25527
- },
25528
- {
25529
- key: "mouseBehaviorRecursive",
25530
- get: function get() {
25531
- return this._mouseBehaviorRecursive;
25532
- },
25533
- set: function set(value) {
25534
- if (this._mouseBehaviorRecursive !== value) {
25535
- var _this_root;
25536
- this._mouseBehaviorRecursive = value;
25537
- (_this_root = this.root) == null ? void 0 : _this_root.controlStateChanged(this);
25538
- }
25539
- }
25540
- },
25541
- {
25542
- key: "focusMode",
25543
- get: function get() {
25544
- return this._focusMode;
25545
- },
25546
- set: function set(value) {
25547
- if (this._focusMode !== value) {
25548
- var _this_root;
25549
- this._focusMode = value;
25550
- (_this_root = this.root) == null ? void 0 : _this_root.controlStateChanged(this);
25551
- }
25552
- }
25553
- },
25554
- {
25555
- key: "focusBehaviorRecursive",
25556
- get: function get() {
25557
- return this._focusBehaviorRecursive;
25558
- },
25559
- set: function set(value) {
25560
- if (this._focusBehaviorRecursive !== value) {
25561
- var _this_root;
25562
- this._focusBehaviorRecursive = value;
25563
- (_this_root = this.root) == null ? void 0 : _this_root.controlStateChanged(this);
25564
- }
25565
- }
25566
- },
25567
- {
25568
- key: "defaultCursorShape",
25569
- get: function get() {
25570
- return this._defaultCursorShape;
25571
- },
25572
- set: function set(value) {
25573
- var _this_root;
25574
- if (this._defaultCursorShape === value) {
25575
- return;
25576
- }
25577
- this._defaultCursorShape = value;
25578
- (_this_root = this.root) == null ? void 0 : _this_root.updateMouseCursorState();
25579
- }
25580
- },
25581
- {
25582
- key: "location",
25583
- get: function get() {
25584
- return this.position;
25585
- },
25586
- set: function set(value) {
25587
- this.setPosition(value.x, value.y);
25588
- }
25589
- },
25590
- {
25591
- key: "rotation",
25592
- get: function get() {
25593
- return this._rotation;
25594
- }
25595
- },
25596
- {
25597
- key: "x",
25598
- get: function get() {
25599
- return this.position.x;
25600
- },
25601
- set: function set(value) {
25602
- this.setPosition(value, this.position.y);
25603
- }
25604
- },
25605
- {
25606
- key: "y",
25607
- get: function get() {
25608
- return this.position.y;
25609
- },
25610
- set: function set(value) {
25611
- this.setPosition(this.position.x, value);
25612
- }
25613
- },
25614
- {
25615
- key: "width",
25616
- get: function get() {
25617
- return this.size.x;
25618
- },
25619
- set: function set(value) {
25620
- this.setSize(value, this.size.y);
25621
- }
25622
- },
25623
- {
25624
- key: "height",
25625
- get: function get() {
25626
- return this.size.y;
25627
- },
25628
- set: function set(value) {
25629
- this.setSize(this.size.x, value);
25630
- }
25631
- },
25632
- {
25633
- key: "root",
25634
- get: function get() {
25635
- var _this_parent;
25636
- var _this_parent_root;
25637
- return _instanceof1(this, RootControl) ? this : (_this_parent_root = (_this_parent = this.parent) == null ? void 0 : _this_parent.root) != null ? _this_parent_root : null;
25638
- }
25639
- },
25640
- {
25641
- key: "isDisposed",
25642
- get: function get() {
25643
- return this.disposed;
25644
- }
25645
- }
25646
- ]);
25647
- return Control;
25648
- }();
25649
- /** A Control that owns child Controls. */ var ContainerControl = /*#__PURE__*/ function(Control) {
25650
- _inherits(ContainerControl, Control);
25651
- function ContainerControl() {
25652
- var _this;
25653
- _this = Control.apply(this, arguments) || this;
25654
- _this.children = [];
25655
- return _this;
25656
- }
25657
- var _proto = ContainerControl.prototype;
25658
- _proto.addChild = function addChild(child) {
25659
- child.parent = this;
25660
- return child;
25661
- };
25662
- _proto.removeChild = function removeChild(child) {
25663
- if (child.parent === this) {
25664
- child.parent = null;
25665
- }
25666
- };
25667
- _proto.getChildIndex = function getChildIndex(child) {
25668
- return this.children.indexOf(child);
25669
- };
25670
- /** @internal */ _proto.changeChildIndex = function changeChildIndex(child, newIndex) {
25671
- var _this_root;
25672
- var oldIndex = this.children.indexOf(child);
25673
- if (oldIndex === newIndex || oldIndex === -1) {
25674
- return;
25675
- }
25676
- this.children.splice(oldIndex, 1);
25677
- if (newIndex < 0 || newIndex >= this.children.length) {
25678
- this.children.push(child);
25679
- } else {
25680
- this.children.splice(newIndex, 0, child);
25681
- }
25682
- (_this_root = this.root) == null ? void 0 : _this_root.controlTreeChanged();
25683
- };
25684
- /** @internal */ _proto.addChildInternal = function addChildInternal(child) {
25685
- if (!this.children.includes(child)) {
25686
- this.children.push(child);
25687
- }
25688
- };
25689
- /** @internal */ _proto.removeChildInternal = function removeChildInternal(child) {
25690
- var index = this.children.indexOf(child);
25691
- if (index !== -1) {
25692
- this.children.splice(index, 1);
25693
- }
25694
- };
25695
- _proto.drawSelf = function drawSelf() {
25696
- Control.prototype.draw.call(this);
25697
- };
25698
- _proto.draw = function draw() {
25699
- this.drawSelf();
25700
- this.drawChildren();
25701
- };
25702
- _proto.drawChildren = function drawChildren() {
25703
- var graphics = this.engine.graphics;
25704
- if (this.clipContents) ;
25705
- for(var _iterator = _create_for_of_iterator_helper_loose(this.children), _step; !(_step = _iterator()).done;){
25706
- var child = _step.value;
25707
- if (!child.visible || child.isDisposed) {
25708
- continue;
25709
- }
25710
- graphics.pushTransform(child.getTransform2D());
25711
- child.draw();
25712
- graphics.popTransform();
25713
- }
25714
- };
25715
- _proto.update = function update(deltaTime) {
25716
- Control.prototype.update.call(this, deltaTime);
25717
- for(var _iterator = _create_for_of_iterator_helper_loose(this.children.slice()), _step; !(_step = _iterator()).done;){
25718
- var child = _step.value;
25719
- if (child.enabled && !child.isDisposed) {
25720
- child.update(deltaTime);
25721
- }
25722
- }
25723
- };
25724
- _proto.dispose = function dispose() {
25725
- for(var _iterator = _create_for_of_iterator_helper_loose(this.children.slice()), _step; !(_step = _iterator()).done;){
25726
- var child = _step.value;
25727
- child.dispose();
25728
- }
25729
- Control.prototype.dispose.call(this);
25730
- };
25731
- return ContainerControl;
25732
- }(Control);
25733
- /** Base class for GUI tree roots and input dispatchers. */ var RootControl = /*#__PURE__*/ function(ContainerControl) {
25734
- _inherits(RootControl, ContainerControl);
25735
- function RootControl() {
25736
- return ContainerControl.apply(this, arguments);
25737
- }
25738
- return RootControl;
25739
- }(ContainerControl);
25740
-
25741
- var _obj$4;
25742
- var cursorNames = (_obj$4 = {}, _obj$4[exports.CursorShape.Arrow] = "default", _obj$4[exports.CursorShape.Ibeam] = "text", _obj$4[exports.CursorShape.PointingHand] = "pointer", _obj$4[exports.CursorShape.Cross] = "crosshair", _obj$4[exports.CursorShape.Wait] = "wait", _obj$4[exports.CursorShape.Busy] = "progress", _obj$4[exports.CursorShape.Drag] = "grab", _obj$4[exports.CursorShape.CanDrop] = "copy", _obj$4[exports.CursorShape.Forbidden] = "not-allowed", _obj$4[exports.CursorShape.Vsize] = "ns-resize", _obj$4[exports.CursorShape.Hsize] = "ew-resize", _obj$4[exports.CursorShape.Bdiagsize] = "nesw-resize", _obj$4[exports.CursorShape.Fdiagsize] = "nwse-resize", _obj$4[exports.CursorShape.Move] = "move", _obj$4[exports.CursorShape.Vsplit] = "row-resize", _obj$4[exports.CursorShape.Hsplit] = "col-resize", _obj$4[exports.CursorShape.Help] = "help", _obj$4);
25743
- function getButtonMask(button) {
25744
- switch(button){
25745
- case exports.MouseButton.Left:
25746
- return exports.MouseButtonMask.Left;
25747
- case exports.MouseButton.Right:
25748
- return exports.MouseButtonMask.Right;
25749
- case exports.MouseButton.Middle:
25750
- return exports.MouseButtonMask.Middle;
25751
- case exports.MouseButton.Xbutton1:
25752
- return exports.MouseButtonMask.Xbutton1;
25753
- case exports.MouseButton.Xbutton2:
25754
- return exports.MouseButtonMask.Xbutton2;
25755
- default:
25756
- return exports.MouseButtonMask.None;
25757
- }
25758
- }
25759
- function isWheelButton(button) {
25760
- return button >= exports.MouseButton.WheelUp && button <= exports.MouseButton.WheelRight;
25761
- }
25762
- /** CanvasLayer-like boundary for a single UICanvas GUI tree. */ var CanvasRootControl = /*#__PURE__*/ function(ContainerControl) {
25763
- _inherits(CanvasRootControl, ContainerControl);
25764
- function CanvasRootControl(engine, canvas) {
25765
- var _this;
25766
- _this = ContainerControl.call(this, engine) || this;
25767
- _this.canvas = canvas;
25768
- _this.mouseFilter = exports.MouseFilter.Ignore;
25769
- _this.setSize(engine.canvas.width, engine.canvas.height);
25770
- return _this;
25771
- }
25772
- _create_class(CanvasRootControl, [
25773
- {
25774
- key: "inputDisabled",
25775
- get: function get() {
25776
- var _this_canvas_item;
25777
- return !this.canvas.receivesEvents || !this.canvas.enabled || !((_this_canvas_item = this.canvas.item) == null ? void 0 : _this_canvas_item.isActive);
25778
- }
25779
- }
25780
- ]);
25781
- return CanvasRootControl;
25782
- }(ContainerControl);
25783
- /** Global ordered collection of UICanvas roots. */ var CanvasContainer = /*#__PURE__*/ function(ContainerControl) {
25784
- _inherits(CanvasContainer, ContainerControl);
25785
- function CanvasContainer(engine) {
25786
- var _this;
25787
- _this = ContainerControl.call(this, engine) || this;
25788
- _this.mouseFilter = exports.MouseFilter.Ignore;
25789
- _this.setSize(engine.canvas.width, engine.canvas.height);
25790
- return _this;
25791
- }
25792
- var _proto = CanvasContainer.prototype;
25793
- _proto.sortCanvases = function sortCanvases() {
25794
- this.children.sort(function(left, right) {
25795
- return left.canvas.order - right.canvas.order;
25796
- });
25797
- };
25798
- _proto.addChildInternal = function addChildInternal(child) {
25799
- ContainerControl.prototype.addChildInternal.call(this, child);
25800
- this.sortCanvases();
25801
- };
25802
- _proto.draw = function draw() {
25803
- this.sortCanvases();
25804
- for(var _iterator = _create_for_of_iterator_helper_loose(this.children), _step; !(_step = _iterator()).done;){
25805
- var child = _step.value;
25806
- var root = child;
25807
- if (root.canvas.isVisible) {
25808
- root.draw();
25809
- }
25810
- }
25811
- };
25812
- return CanvasContainer;
25813
- }(ContainerControl);
25814
- /** Engine window GUI root. Routes events across all UICanvas roots. */ var WindowRootControl = /*#__PURE__*/ function(RootControl) {
25815
- _inherits(WindowRootControl, RootControl);
25816
- function WindowRootControl(engine) {
25817
- var _this;
25818
- _this = RootControl.call(this, engine) || this;
25819
- _this.dragThreshold = 10;
25820
- _this.lastInput = null;
25821
- _this.gui = {
25822
- mouseFocus: null,
25823
- mouseClickGrabber: null,
25824
- mouseFocusMask: exports.MouseButtonMask.None,
25825
- mouseOver: null,
25826
- mouseOverHierarchy: [],
25827
- touchFocus: new Map(),
25828
- keyFocus: null,
25829
- dragAccum: new Vector2(),
25830
- dragAttempted: false,
25831
- dragging: false,
25832
- dragData: null,
25833
- dragMouseOver: null,
25834
- dragSuccessful: false,
25835
- lastMousePosition: new Vector2(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY),
25836
- sendingMouseEnterExit: false,
25837
- mouseOverUpdatePending: false
25838
- };
25839
- _this.mouseFilter = exports.MouseFilter.Ignore;
25840
- _this.setSize(engine.canvas.width, engine.canvas.height);
25841
- _this.canvases = new CanvasContainer(engine);
25842
- _this.canvases.parent = _assert_this_initialized(_this);
25843
- return _this;
25844
- }
25845
- var _proto = WindowRootControl.prototype;
25846
- _proto.pushInput = function pushInput(event) {
25847
- event.clearAccepted();
25848
- this.lastInput = event;
25849
- this.cleanupInternalState();
25850
- this.processGUIInput(event);
25851
- this.postGrabClickFocus();
25852
- };
25853
- _proto.isInputHandled = function isInputHandled() {
25854
- var _this_lastInput;
25855
- var _this_lastInput_isAccepted;
25856
- return (_this_lastInput_isAccepted = (_this_lastInput = this.lastInput) == null ? void 0 : _this_lastInput.isAccepted()) != null ? _this_lastInput_isAccepted : false;
25857
- };
25858
- _proto.getMousePosition = function getMousePosition() {
25859
- return this.gui.lastMousePosition.clone();
25860
- };
25861
- _proto.guiGetFocusOwner = function guiGetFocusOwner() {
25862
- return this.isFocusTargetUsable(this.gui.keyFocus) ? this.gui.keyFocus : null;
25863
- };
25864
- _proto.guiReleaseFocus = function guiReleaseFocus() {
25865
- this.releaseControlFocus();
25866
- };
25867
- _proto.guiIsDragging = function guiIsDragging() {
25868
- return this.gui.dragging;
25869
- };
25870
- _proto.guiGetDragData = function guiGetDragData() {
25871
- return this.gui.dragData;
25872
- };
25873
- _proto.guiIsDragSuccessful = function guiIsDragSuccessful() {
25874
- return this.gui.dragSuccessful;
25875
- };
25876
- _proto.guiCancelDrag = function guiCancelDrag() {
25877
- this.endDragging(false);
25878
- };
25879
- _proto.grabControlFocus = function grabControlFocus(control) {
25880
- if (!this.isFocusTargetUsable(control) || this.gui.keyFocus === control) {
25881
- return;
25882
- }
25883
- var previous = this.gui.keyFocus;
25884
- this.gui.keyFocus = control;
25885
- if (previous && !previous.isDisposed) {
25886
- previous.onLostFocus();
25887
- }
25888
- control.onGotFocus();
25889
- };
25890
- _proto.grabControlClickFocus = function grabControlClickFocus(control) {
25891
- var _this = this;
25892
- if (this.isControlValid(control)) {
25893
- this.gui.mouseClickGrabber = control;
25894
- queueMicrotask(function() {
25895
- return _this.postGrabClickFocus();
25896
- });
25897
- }
25898
- };
25899
- _proto.releaseControlFocus = function releaseControlFocus(control) {
25900
- var previous = this.gui.keyFocus;
25901
- if (!previous || control && previous !== control) {
25902
- return;
25903
- }
25904
- this.gui.keyFocus = null;
25905
- if (!previous.isDisposed) {
25906
- previous.onLostFocus();
25907
- }
25908
- };
25909
- _proto.warpControlMouse = function warpControlMouse(position) {
25910
- this.gui.lastMousePosition.copyFrom(position);
25911
- this.updateMouseOver(position);
25912
- this.updateMouseCursorState();
25913
- };
25914
- _proto.updateMouseCursorState = function updateMouseCursorState() {
25915
- var position = this.gui.lastMousePosition;
25916
- var target = this.isControlUsable(this.gui.mouseFocus) ? this.gui.mouseFocus : this.isControlUsable(this.gui.mouseOver) ? this.gui.mouseOver : null;
25917
- this.updateCursor(target, position);
25918
- };
25919
- _proto.controlStateChanged = function controlStateChanged(control) {
25920
- if (!this.isControlUsable(control)) {
25921
- this.dropControlState(control);
25922
- }
25923
- this.requestMouseOverUpdate();
25924
- };
25925
- _proto.controlRemoved = function controlRemoved(control) {
25926
- this.dropControlState(control);
25927
- this.cleanupInternalState();
25928
- this.requestMouseOverUpdate();
25929
- };
25930
- _proto.controlTreeChanged = function controlTreeChanged() {
25931
- this.requestMouseOverUpdate();
25932
- };
25933
- _proto.cancelPointerInput = function cancelPointerInput() {
25934
- this.dropMouseFocus();
25935
- this.dropMouseOver();
25936
- this.gui.touchFocus.clear();
25937
- this.endDragging(false);
25938
- this.releaseControlFocus();
25939
- };
25940
- _proto.resize = function resize(width, height) {
25941
- this.setSize(width, height);
25942
- this.canvases.setSize(width, height);
25943
- for(var _iterator = _create_for_of_iterator_helper_loose(this.canvases.children), _step; !(_step = _iterator()).done;){
25944
- var root = _step.value;
25945
- root.setSize(width, height);
25946
- }
25947
- };
25948
- _proto.render = function render() {
25949
- if (this.canvases.children.length === 0) {
25950
- return;
25951
- }
25952
- this.engine.graphics.begin();
25953
- this.draw();
25954
- this.engine.graphics.end();
25955
- };
25956
- _proto.update = function update(deltaTime) {
25957
- if (this.gui.mouseOverUpdatePending) {
25958
- this.gui.mouseOverUpdatePending = false;
25959
- this.updateMouseOver(this.gui.lastMousePosition);
25960
- }
25961
- RootControl.prototype.update.call(this, deltaTime);
25962
- };
25963
- _proto.dispose = function dispose() {
25964
- this.cancelPointerInput();
25965
- RootControl.prototype.dispose.call(this);
25966
- };
25967
- _proto.processGUIInput = function processGUIInput(event) {
25968
- if (_instanceof1(event, InputEventKey)) {
25969
- var target = this.guiGetFocusOwner();
25970
- if (target) {
25971
- this.callControlInput(target, event);
25972
- }
25973
- } else if (_instanceof1(event, InputEventMouse)) {
25974
- this.gui.lastMousePosition.copyFrom(event.globalPosition);
25975
- this.updateMouseOver(event.globalPosition);
25976
- if (_instanceof1(event, InputEventMouseButton)) {
25977
- this.processMouseButton(event);
25978
- } else if (_instanceof1(event, InputEventMouseMotion)) {
25979
- this.processMouseMotion(event);
25980
- }
25981
- } else if (_instanceof1(event, InputEventScreenTouch)) {
25982
- this.processScreenTouch(event);
25983
- } else if (_instanceof1(event, InputEventScreenDrag)) {
25984
- this.processScreenDrag(event);
25985
- }
25986
- };
25987
- _proto.processMouseButton = function processMouseButton(event) {
25988
- if (isWheelButton(event.buttonIndex)) {
25989
- var target = this.findInputControl(event.globalPosition);
25990
- if (target) {
25991
- this.callGUIInput(target, event);
25992
- }
25993
- return;
25994
- }
25995
- var mask = getButtonMask(event.buttonIndex);
25996
- if (event.isPressed()) {
25997
- var target1 = this.gui.mouseFocusMask !== 0 ? this.gui.mouseFocus : this.findInputControl(event.globalPosition);
25998
- this.gui.mouseFocus = target1;
25999
- if (!target1) {
26000
- return;
26001
- }
26002
- this.gui.mouseFocusMask |= mask;
26003
- if (event.buttonIndex === exports.MouseButton.Left) {
26004
- this.gui.dragAccum.setZero();
26005
- this.gui.dragAttempted = false;
26006
- this.findClickFocus(target1);
26007
- }
26008
- this.callGUIInput(target1, event);
26009
- } else {
26010
- if (event.buttonIndex === exports.MouseButton.Left && this.gui.dragging) {
26011
- this.finishDrop(event.globalPosition);
26012
- }
26013
- this.gui.mouseFocusMask &= ~mask;
26014
- var target2 = this.gui.mouseFocus;
26015
- if (this.gui.mouseFocusMask === 0) {
26016
- this.gui.mouseFocus = null;
26017
- }
26018
- if (this.isControlUsable(target2)) {
26019
- this.callGUIInput(target2, event);
26020
- }
26021
- }
26022
- };
26023
- _proto.processMouseMotion = function processMouseMotion(event) {
26024
- if (!this.gui.dragging && !this.gui.dragAttempted && this.gui.mouseFocus && (this.gui.mouseFocusMask & exports.MouseButtonMask.Left) !== 0) {
26025
- this.gui.dragAccum.add(event.relative);
26026
- if (this.gui.dragAccum.length() > this.dragThreshold) {
26027
- var origin = event.globalPosition.clone().subtract(this.gui.dragAccum);
26028
- this.beginDragging(this.gui.mouseFocus, origin);
26029
- this.gui.dragAttempted = true;
26030
- }
26031
- }
26032
- var target = this.isControlUsable(this.gui.mouseFocus) ? this.gui.mouseFocus : this.findInputControl(event.globalPosition);
26033
- if (target) {
26034
- this.callGUIInput(target, event);
26035
- }
26036
- if (this.gui.dragging) {
26037
- this.gui.dragMouseOver = this.findDropTarget(this.findInputControl(event.globalPosition), event.globalPosition);
26038
- }
26039
- this.updateCursor(target, event.globalPosition);
26040
- };
26041
- _proto.processScreenTouch = function processScreenTouch(event) {
26042
- var target;
26043
- if (event.isPressed()) {
26044
- target = this.findInputControl(event.position);
26045
- if (target) {
26046
- this.gui.touchFocus.set(event.index, target);
26047
- }
26048
- } else {
26049
- var _this_gui_touchFocus_get;
26050
- target = (_this_gui_touchFocus_get = this.gui.touchFocus.get(event.index)) != null ? _this_gui_touchFocus_get : null;
26051
- this.gui.touchFocus.delete(event.index);
26052
- }
26053
- if (this.isControlUsable(target)) {
26054
- this.callGUIInput(target, event);
26055
- }
26056
- };
26057
- _proto.processScreenDrag = function processScreenDrag(event) {
26058
- var _this_gui_touchFocus_get;
26059
- var target = (_this_gui_touchFocus_get = this.gui.touchFocus.get(event.index)) != null ? _this_gui_touchFocus_get : this.findInputControl(event.position);
26060
- if (this.isControlUsable(target)) {
26061
- this.callGUIInput(target, event);
26062
- }
26063
- };
26064
- _proto.callGUIInput = function callGUIInput(target, event) {
26065
- var current = target;
26066
- var pointerEvent = _instanceof1(event, InputEventMouse) || _instanceof1(event, InputEventScreenTouch) || _instanceof1(event, InputEventScreenDrag);
26067
- while(current && current !== this && this.isControlUsable(current)){
26068
- var filter = current.getEffectiveMouseFilter();
26069
- if (filter !== exports.MouseFilter.Ignore) {
26070
- var localEvent = event.xformedBy(this.getGlobalInverse(current));
26071
- this.callControlInput(current, localEvent);
26072
- if (localEvent.isAccepted()) {
26073
- event.accept();
26074
- }
26075
- }
26076
- var forcePassWheel = _instanceof1(event, InputEventMouseButton) && isWheelButton(event.buttonIndex) && current.mouseForcePassScrollEvents;
26077
- if (event.isAccepted() || filter === exports.MouseFilter.Stop && pointerEvent && !forcePassWheel) {
26078
- event.accept();
26079
- return;
26080
- }
26081
- current = current.parent;
26082
- }
26083
- };
26084
- _proto.callControlInput = function callControlInput(control, event) {
26085
- if (_instanceof1(event, InputEventMouseButton)) {
26086
- if (isWheelButton(event.buttonIndex)) {
26087
- control.onMouseWheel(event);
26088
- } else if (event.isPressed()) {
26089
- control.onMouseDown(event);
26090
- } else {
26091
- control.onMouseUp(event);
26092
- }
26093
- } else if (_instanceof1(event, InputEventMouseMotion)) {
26094
- control.onMouseMove(event);
26095
- } else if (_instanceof1(event, InputEventScreenTouch)) {
26096
- if (event.isPressed()) {
26097
- control.onTouchDown(event);
26098
- } else {
26099
- control.onTouchUp(event);
26100
- }
26101
- } else if (_instanceof1(event, InputEventScreenDrag)) {
26102
- control.onTouchMove(event);
26103
- } else if (_instanceof1(event, InputEventKey)) {
26104
- if (event.isPressed()) {
26105
- control.onKeyDown(event);
26106
- } else if (event.isReleased()) {
26107
- control.onKeyUp(event);
26108
- }
26109
- }
26110
- };
26111
- _proto.findInputControl = function findInputControl(position) {
26112
- this.canvases.sortCanvases();
26113
- for(var index = this.canvases.children.length - 1; index >= 0; index--){
26114
- var root = this.canvases.children[index];
26115
- if (!root.canvas.isVisible || root.inputDisabled) {
26116
- continue;
26117
- }
26118
- var target = this.findControlAtPosition(root, position, true);
26119
- if (target) {
26120
- return target;
26121
- }
26122
- }
26123
- return null;
26124
- };
26125
- _proto.findControlAtPosition = function findControlAtPosition(container, position, skipSelf) {
26126
- if (skipSelf === void 0) skipSelf = false;
26127
- if (!container.visibleInHierarchy || container.isDisposed) {
26128
- return null;
26129
- }
26130
- var localPosition = this.toLocal(container, position);
26131
- if (container.clipContents && !container.hasPoint(localPosition)) {
26132
- return null;
26133
- }
26134
- for(var index = container.children.length - 1; index >= 0; index--){
26135
- var child = container.children[index];
26136
- if (!child.visibleInHierarchy || child.isDisposed) {
26137
- continue;
26138
- }
26139
- if (_instanceof1(child, ContainerControl)) {
26140
- var found = this.findControlAtPosition(child, position);
26141
- if (found) {
26142
- return found;
26143
- }
26144
- } else if (child.getEffectiveMouseFilter() !== exports.MouseFilter.Ignore && child.hasPoint(this.toLocal(child, position))) {
26145
- return child;
26146
- }
26147
- }
26148
- if (!skipSelf && container.getEffectiveMouseFilter() !== exports.MouseFilter.Ignore && container.hasPoint(localPosition)) {
26149
- return container;
26150
- }
26151
- return null;
26152
- };
26153
- _proto.updateMouseOver = function updateMouseOver(position) {
26154
- if (this.gui.sendingMouseEnterExit) {
26155
- this.gui.mouseOverUpdatePending = true;
26156
- return;
26157
- }
26158
- this.gui.mouseOverUpdatePending = false;
26159
- var target = this.findInputControl(position);
26160
- var next = this.buildHoverHierarchy(target);
26161
- var previous = this.gui.mouseOverHierarchy;
26162
- var common = 0;
26163
- while(common < previous.length && common < next.length && previous[common] === next[common]){
26164
- common++;
26165
- }
26166
- this.gui.sendingMouseEnterExit = true;
26167
- for(var index = previous.length - 1; index >= common; index--){
26168
- if (!previous[index].isDisposed) {
26169
- previous[index].onMouseLeave();
26170
- }
26171
- }
26172
- for(var index1 = common; index1 < next.length; index1++){
26173
- next[index1].onMouseEnter(this.toLocal(next[index1], position));
26174
- }
26175
- this.gui.sendingMouseEnterExit = false;
26176
- this.gui.mouseOver = target;
26177
- this.gui.mouseOverHierarchy = next;
26178
- };
26179
- _proto.buildHoverHierarchy = function buildHoverHierarchy(target) {
26180
- var hierarchy = [];
26181
- var current = target;
26182
- while(current && current !== this){
26183
- if (current.getEffectiveMouseFilter() !== exports.MouseFilter.Ignore) {
26184
- hierarchy.push(current);
26185
- }
26186
- if (current.getEffectiveMouseFilter() === exports.MouseFilter.Stop) {
26187
- break;
26188
- }
26189
- current = current.parent;
26190
- }
26191
- hierarchy.reverse();
26192
- return hierarchy;
26193
- };
26194
- _proto.findClickFocus = function findClickFocus(target) {
26195
- var current = target;
26196
- while(current && current !== this){
26197
- var mode = current.getFocusModeWithOverride();
26198
- if (mode === exports.FocusMode.Click || mode === exports.FocusMode.All) {
26199
- this.grabControlFocus(current);
26200
- return;
26201
- }
26202
- if (current.getEffectiveMouseFilter() === exports.MouseFilter.Stop) {
26203
- return;
26204
- }
26205
- current = current.parent;
26206
- }
26207
- };
26208
- _proto.beginDragging = function beginDragging(source, position) {
26209
- var current = source;
26210
- while(current && current !== this){
26211
- var data = current.invokeGetDragData(this.toLocal(current, position));
26212
- if (data !== null && data !== undefined) {
26213
- this.gui.dragging = true;
26214
- this.gui.dragData = data;
26215
- this.gui.mouseFocus = null;
26216
- this.gui.mouseFocusMask = exports.MouseButtonMask.None;
26217
- return;
26218
- }
26219
- if (current.getEffectiveMouseFilter() === exports.MouseFilter.Stop) {
26220
- return;
26221
- }
26222
- current = current.parent;
26223
- }
26224
- };
26225
- _proto.finishDrop = function finishDrop(position) {
26226
- var target = this.findDropTarget(this.findInputControl(position), position);
26227
- if (target) {
26228
- target.invokeDropData(this.toLocal(target, position), this.gui.dragData);
26229
- }
26230
- this.endDragging(!!target);
26231
- };
26232
- _proto.findDropTarget = function findDropTarget(target, position) {
26233
- var current = target;
26234
- while(current && current !== this){
26235
- if (current.invokeCanDropData(this.toLocal(current, position), this.gui.dragData)) {
26236
- return current;
26237
- }
26238
- if (current.getEffectiveMouseFilter() === exports.MouseFilter.Stop) {
26239
- return null;
26240
- }
26241
- current = current.parent;
26242
- }
26243
- return null;
26244
- };
26245
- _proto.endDragging = function endDragging(successful) {
26246
- this.gui.dragSuccessful = successful;
26247
- this.gui.dragging = false;
26248
- this.gui.dragData = null;
26249
- this.gui.dragMouseOver = null;
26250
- };
26251
- _proto.updateCursor = function updateCursor(target, position) {
26252
- var current = target;
26253
- var cursor = exports.CursorShape.Arrow;
26254
- while(current && current !== this){
26255
- var candidate = current.getCursorShape(this.toLocal(current, position));
26256
- if (candidate !== exports.CursorShape.Arrow) {
26257
- cursor = candidate;
26258
- break;
26259
- }
26260
- if (current.getEffectiveMouseFilter() === exports.MouseFilter.Stop) {
26261
- break;
26262
- }
26263
- current = current.parent;
26264
- }
26265
- this.engine.canvas.style.cursor = typeof cursor === "string" ? cursor : cursorNames[cursor];
26266
- };
26267
- _proto.postGrabClickFocus = function postGrabClickFocus() {
26268
- var target = this.gui.mouseClickGrabber;
26269
- this.gui.mouseClickGrabber = null;
26270
- if (this.isControlUsable(target)) {
26271
- this.gui.mouseFocus = target;
26272
- }
26273
- };
26274
- _proto.cleanupInternalState = function cleanupInternalState() {
26275
- if (!this.isControlUsable(this.gui.mouseFocus)) {
26276
- this.dropMouseFocus();
26277
- }
26278
- if (this.gui.keyFocus && !this.isFocusTargetUsable(this.gui.keyFocus)) {
26279
- this.releaseControlFocus(this.gui.keyFocus);
26280
- }
26281
- for(var _iterator = _create_for_of_iterator_helper_loose(this.gui.touchFocus), _step; !(_step = _iterator()).done;){
26282
- var _step_value = _step.value, index = _step_value[0], control = _step_value[1];
26283
- if (!this.isControlUsable(control)) {
26284
- this.gui.touchFocus.delete(index);
26285
- }
26286
- }
26287
- };
26288
- _proto.dropMouseFocus = function dropMouseFocus() {
26289
- this.gui.mouseFocus = null;
26290
- this.gui.mouseFocusMask = exports.MouseButtonMask.None;
26291
- };
26292
- _proto.dropMouseOver = function dropMouseOver() {
26293
- for(var index = this.gui.mouseOverHierarchy.length - 1; index >= 0; index--){
26294
- var control = this.gui.mouseOverHierarchy[index];
26295
- if (!control.isDisposed) {
26296
- control.onMouseLeave();
26297
- }
26298
- }
26299
- this.gui.mouseOver = null;
26300
- this.gui.mouseOverHierarchy = [];
26301
- };
26302
- _proto.dropControlState = function dropControlState(control) {
26303
- if (this.controlBelongsToSubtree(this.gui.mouseFocus, control)) {
26304
- this.dropMouseFocus();
26305
- }
26306
- if (this.controlBelongsToSubtree(this.gui.mouseClickGrabber, control)) {
26307
- this.gui.mouseClickGrabber = null;
26308
- }
26309
- if (this.controlBelongsToSubtree(this.gui.keyFocus, control)) {
26310
- var _this_gui_keyFocus;
26311
- this.releaseControlFocus((_this_gui_keyFocus = this.gui.keyFocus) != null ? _this_gui_keyFocus : undefined);
26312
- }
26313
- if (this.controlBelongsToSubtree(this.gui.mouseOver, control)) {
26314
- this.dropMouseOver();
26315
- }
26316
- if (this.controlBelongsToSubtree(this.gui.dragMouseOver, control)) {
26317
- this.gui.dragMouseOver = null;
26318
- }
26319
- for(var _iterator = _create_for_of_iterator_helper_loose(this.gui.touchFocus), _step; !(_step = _iterator()).done;){
26320
- var _step_value = _step.value, index = _step_value[0], target = _step_value[1];
26321
- if (this.controlBelongsToSubtree(target, control)) {
26322
- this.gui.touchFocus.delete(index);
26323
- }
26324
- }
26325
- };
26326
- _proto.requestMouseOverUpdate = function requestMouseOverUpdate() {
26327
- if (Number.isFinite(this.gui.lastMousePosition.x)) {
26328
- this.updateMouseOver(this.gui.lastMousePosition);
26329
- }
26330
- };
26331
- _proto.getGlobalInverse = function getGlobalInverse(control) {
26332
- var transform = control.getGlobalTransform2D().clone();
26333
- return Math.abs(transform.determinant()) < 1e-12 ? new Matrix3() : transform.invert();
26334
- };
26335
- _proto.toLocal = function toLocal(control, position) {
26336
- var elements = this.getGlobalInverse(control).elements;
26337
- return new Vector2(elements[0] * position.x + elements[3] * position.y + elements[6], elements[1] * position.x + elements[4] * position.y + elements[7]);
26338
- };
26339
- _proto.controlBelongsToSubtree = function controlBelongsToSubtree(control, subtree) {
26340
- var current = control;
26341
- while(current){
26342
- if (current === subtree) {
26343
- return true;
26344
- }
26345
- current = current.parent;
26346
- }
26347
- return false;
26348
- };
26349
- _proto.isControlValid = function isControlValid(control) {
26350
- return !!control && !control.isDisposed && control.root === this;
26351
- };
26352
- _proto.isControlUsable = function isControlUsable(control) {
26353
- if (!this.isControlValid(control) || !control.visibleInHierarchy || !control.enabledInHierarchy) {
26354
- return false;
26355
- }
26356
- var root = this.findCanvasRoot(control);
26357
- return !root || !root.inputDisabled;
26358
- };
26359
- _proto.findCanvasRoot = function findCanvasRoot(control) {
26360
- var current = control;
26361
- while(current && current !== this){
26362
- if (_instanceof1(current, CanvasRootControl)) {
26363
- return current;
26364
- }
26365
- current = current.parent;
26366
- }
26367
- return null;
26368
- };
26369
- _proto.isFocusTargetUsable = function isFocusTargetUsable(control) {
26370
- return this.isControlUsable(control) && control.getFocusModeWithOverride() !== exports.FocusMode.None;
26371
- };
26372
- return WindowRootControl;
26373
- }(RootControl);
26374
-
26375
- exports.CanvasRenderMode = void 0;
26376
- (function(CanvasRenderMode) {
26377
- CanvasRenderMode[CanvasRenderMode["ScreenSpace"] = 0] = "ScreenSpace";
26378
- CanvasRenderMode[CanvasRenderMode["CameraSpace"] = 1] = "CameraSpace";
26379
- CanvasRenderMode[CanvasRenderMode["WorldSpace"] = 2] = "WorldSpace";
26380
- CanvasRenderMode[CanvasRenderMode["WorldSpaceFaceCamera"] = 3] = "WorldSpaceFaceCamera";
26381
- })(exports.CanvasRenderMode || (exports.CanvasRenderMode = {}));
26382
- /** Canvas-layer boundary attached to a VFXItem. Input state remains owned by the window root. */ var UICanvas = /*#__PURE__*/ function(Component) {
26383
- _inherits(UICanvas, Component);
26384
- function UICanvas(engine) {
26385
- var _this;
26386
- _this = Component.call(this, engine) || this;
26387
- _this.renderMode = 0;
26388
- _this.receivesEvents = true;
26389
- _this._order = 0;
26390
- _this.registered = false;
26391
- _this.rootControl = new CanvasRootControl(engine, _assert_this_initialized(_this));
26392
- return _this;
26393
- }
26394
- var _proto = UICanvas.prototype;
26395
- _proto.onEnable = function onEnable() {
26396
- this.register();
26397
- };
26398
- _proto.onDisable = function onDisable() {
26399
- this.unregister();
26400
- };
26401
- _proto.onDestroy = function onDestroy() {
26402
- this.destroyCanvas();
26403
- };
26404
- _proto.dispose = function dispose() {
26405
- this.destroyCanvas();
26406
- Component.prototype.dispose.call(this);
26407
- };
26408
- _proto.register = function register() {
26409
- if (!this.registered) {
26410
- this.rootControl.parent = this.engine.windowRoot.canvases;
26411
- this.registered = true;
26412
- }
26413
- };
26414
- _proto.unregister = function unregister() {
26415
- if (this.registered) {
26416
- this.rootControl.parent = null;
26417
- this.registered = false;
26418
- }
26419
- };
26420
- _proto.destroyCanvas = function destroyCanvas() {
26421
- this.unregister();
26422
- if (!this.rootControl.isDisposed) {
26423
- this.rootControl.dispose();
26424
- }
26425
- };
26426
- _create_class(UICanvas, [
26427
- {
26428
- key: "order",
26429
- get: function get() {
26430
- return this._order;
26431
- },
26432
- set: function set(value) {
26433
- if (this._order !== value) {
26434
- this._order = value;
26435
- this.engine.windowRoot.canvases.sortCanvases();
26436
- }
26437
- }
26438
- },
26439
- {
26440
- key: "isVisible",
26441
- get: function get() {
26442
- var _this_item;
26443
- return this.renderMode === 0 && this.enabled && !!((_this_item = this.item) == null ? void 0 : _this_item.isActive);
26444
- }
26445
- }
26446
- ]);
26447
- return UICanvas;
26448
- }(Component);
26449
-
26450
- /**
26451
- * Scene-tree bridge for a GUI Control. The VFXItem tree owns lifecycle and
26452
- * serialization while the Control tree owns layout, drawing and input.
26453
- */ var UIControl = /*#__PURE__*/ function(Component) {
26454
- _inherits(UIControl, Component);
26455
- function UIControl(engine) {
26456
- var _this;
26457
- _this = Component.call(this, engine) || this;
26458
- _this.controlNode = null;
26459
- _this.linkedItemTransform = null;
26460
- _this.linkedControl = null;
26461
- _this.syncingLocation = false;
26462
- _this.itemTransformChanged = function() {
26463
- return _this.syncItemLocationToControl();
26464
- };
26465
- _this.controlLocationChanged = function() {
26466
- return _this.syncControlLocationToItem();
26467
- };
26468
- return _this;
26469
- }
26470
- var _proto = UIControl.prototype;
26471
- _proto.onAwake = function onAwake() {
26472
- this.syncControl();
26473
- };
26474
- _proto.onEnable = function onEnable() {
26475
- if (this.controlNode) {
26476
- this.controlNode.visible = this.item.isActive;
26477
- this.controlNode.enabled = true;
26478
- }
26479
- };
26480
- _proto.onDisable = function onDisable() {
26481
- if (this.controlNode) {
26482
- this.controlNode.visible = this.item.isActive;
26483
- this.controlNode.enabled = false;
26484
- }
26485
- };
26486
- _proto.onParentChanged = function onParentChanged() {
26487
- this.syncControl();
26488
- };
26489
- _proto.onOrderInParentChanged = function onOrderInParentChanged() {
26490
- this.syncControlOrder();
26491
- };
26492
- _proto.onDestroy = function onDestroy() {
26493
- this.disposeControl();
26494
- };
26495
- _proto.dispose = function dispose() {
26496
- this.disposeControl();
26497
- Component.prototype.dispose.call(this);
26498
- };
26499
- /** Unlinks the GUI object without disposing or modifying it. */ _proto.unlinkControl = function unlinkControl() {
26500
- if (this.controlNode) {
26501
- this.unbindLocationSync();
26502
- this.controlNode = null;
26503
- }
26504
- };
26505
- _proto.disposeControl = function disposeControl() {
26506
- var control = this.controlNode;
26507
- if (control) {
26508
- this.unbindLocationSync();
26509
- this.controlNode = null;
26510
- control.dispose();
26511
- }
26512
- };
26513
- _proto.syncControl = function syncControl() {
26514
- var control = this.controlNode;
26515
- if (!control || !this.item) {
26516
- return;
26517
- }
26518
- this.syncingLocation = true;
26519
- try {
26520
- control.visible = this.item.isActive;
26521
- control.enabled = this.enabled;
26522
- control.parent = this.resolveParent();
26523
- this.syncControlOrder();
26524
- this.copyItemLocationToControl();
26525
- } finally{
26526
- this.syncingLocation = false;
26527
- }
26528
- this.bindLocationSync();
26529
- };
26530
- _proto.syncControlOrder = function syncControlOrder() {
26531
- if (this.controlNode && this.item) {
26532
- this.controlNode.indexInParent = this.item.orderInParent;
26533
- }
26534
- };
26535
- _proto.resolveParent = function resolveParent() {
26536
- var parentItem = this.item.parent;
26537
- if (!parentItem) {
26538
- var _UIControl_fallbackParentGetDelegate;
26539
- return (_UIControl_fallbackParentGetDelegate = UIControl.fallbackParentGetDelegate == null ? void 0 : UIControl.fallbackParentGetDelegate.call(UIControl, this)) != null ? _UIControl_fallbackParentGetDelegate : null;
26540
- }
26541
- var uiControl = parentItem.getComponent(UIControl);
26542
- if ((uiControl == null ? void 0 : uiControl.control) && "children" in uiControl.control) {
26543
- return uiControl.control;
26544
- }
26545
- var canvas = parentItem.getComponent(UICanvas);
26546
- var _canvas_rootControl, _ref;
26547
- 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;
26548
- };
26549
- _proto.bindLocationSync = function bindLocationSync() {
26550
- var itemTransform = this.item.transform;
26551
- var control = this.controlNode;
26552
- if (this.linkedItemTransform === itemTransform && this.linkedControl === control) {
26553
- return;
26554
- }
26555
- this.unbindLocationSync();
26556
- if (control) {
26557
- this.linkedItemTransform = itemTransform;
26558
- this.linkedControl = control;
26559
- itemTransform.on("changed", this.itemTransformChanged);
26560
- control.on("locationChanged", this.controlLocationChanged);
26561
- }
26562
- };
26563
- _proto.unbindLocationSync = function unbindLocationSync() {
26564
- var _this_linkedItemTransform, _this_linkedControl;
26565
- (_this_linkedItemTransform = this.linkedItemTransform) == null ? void 0 : _this_linkedItemTransform.off("changed", this.itemTransformChanged);
26566
- (_this_linkedControl = this.linkedControl) == null ? void 0 : _this_linkedControl.off("locationChanged", this.controlLocationChanged);
26567
- this.linkedItemTransform = null;
26568
- this.linkedControl = null;
26569
- };
26570
- _proto.syncItemLocationToControl = function syncItemLocationToControl() {
26571
- if (!this.syncingLocation && this.controlNode) {
26572
- this.syncingLocation = true;
26573
- try {
26574
- this.copyItemLocationToControl();
26575
- } finally{
26576
- this.syncingLocation = false;
26577
- }
26578
- }
26579
- };
26580
- _proto.syncControlLocationToItem = function syncControlLocationToItem() {
26581
- var control = this.controlNode;
26582
- if (!this.syncingLocation && control) {
26583
- var source = control.location;
26584
- var target = this.item.transform.position;
26585
- if (source.x !== target.x || source.y !== target.y) {
26586
- this.syncingLocation = true;
26587
- try {
26588
- this.item.transform.setPosition(source.x, source.y, target.z);
26589
- } finally{
26590
- this.syncingLocation = false;
26591
- }
26592
- }
26593
- }
26594
- };
26595
- _proto.copyItemLocationToControl = function copyItemLocationToControl() {
26596
- var control = this.controlNode;
26597
- if (control) {
26598
- var source = this.item.transform.position;
26599
- var target = control.location;
26600
- if (source.x !== target.x || source.y !== target.y) {
26601
- control.setPosition(source.x, source.y);
26602
- }
26603
- }
26604
- };
26605
- _create_class(UIControl, [
26606
- {
26607
- key: "control",
26608
- get: function get() {
26609
- return this.controlNode;
26610
- },
26611
- set: function set(value) {
26612
- if (value === this.controlNode) {
26613
- return;
26614
- }
26615
- this.disposeControl();
26616
- if (value) {
26617
- if (value.owner && value.owner !== this && value.owner.control === value) {
26618
- throw new Error("A Control can only be owned by one UIControl.");
26619
- }
26620
- this.controlNode = value;
26621
- value.owner = this;
26622
- this.syncControl();
26623
- }
26624
- }
26625
- },
26626
- {
26627
- key: "hasControl",
26628
- get: function get() {
26629
- return this.controlNode !== null;
26630
- }
26631
- }
26632
- ]);
26633
- return UIControl;
26634
- }(Component);
26635
-
26636
24845
  exports.CameraController = /*#__PURE__*/ function(Component) {
26637
24846
  _inherits(CameraController, Component);
26638
24847
  function CameraController(engine, props) {
@@ -26667,6 +24876,42 @@ exports.CameraController = __decorate([
26667
24876
  effectsClass(DataType.CameraController)
26668
24877
  ], exports.CameraController);
26669
24878
 
24879
+ function _get_prototype_of(o) {
24880
+ _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
24881
+ return o.__proto__ || Object.getPrototypeOf(o);
24882
+ };
24883
+ return _get_prototype_of(o);
24884
+ }
24885
+
24886
+ function _is_native_function(fn) {
24887
+ return Function.toString.call(fn).indexOf("[native code]") !== -1;
24888
+ }
24889
+
24890
+ function _wrap_native_super(Class) {
24891
+ var _cache = typeof Map === "function" ? new Map() : undefined;
24892
+ _wrap_native_super = function _wrap_native_super(Class) {
24893
+ if (Class === null || !_is_native_function(Class)) return Class;
24894
+ if (typeof Class !== "function") throw new TypeError("Super expression must either be null or a function");
24895
+ if (typeof _cache !== "undefined") {
24896
+ if (_cache.has(Class)) return _cache.get(Class);
24897
+ _cache.set(Class, Wrapper);
24898
+ }
24899
+ function Wrapper() {
24900
+ return _construct(Class, arguments, _get_prototype_of(this).constructor);
24901
+ }
24902
+ Wrapper.prototype = Object.create(Class.prototype, {
24903
+ constructor: {
24904
+ value: Wrapper,
24905
+ enumerable: false,
24906
+ writable: true,
24907
+ configurable: true
24908
+ }
24909
+ });
24910
+ return _set_prototype_of(Wrapper, Class);
24911
+ };
24912
+ return _wrap_native_super(Class);
24913
+ }
24914
+
26670
24915
  var CameraVFXItemLoader = /*#__PURE__*/ function(Plugin) {
26671
24916
  _inherits(CameraVFXItemLoader, Plugin);
26672
24917
  function CameraVFXItemLoader() {
@@ -26675,6 +24920,255 @@ var CameraVFXItemLoader = /*#__PURE__*/ function(Plugin) {
26675
24920
  return CameraVFXItemLoader;
26676
24921
  }(_wrap_native_super(Plugin));
26677
24922
 
24923
+ exports.MouseButton = void 0;
24924
+ (function(MouseButton) {
24925
+ MouseButton[MouseButton["None"] = 0] = "None";
24926
+ MouseButton[MouseButton["Left"] = 1] = "Left";
24927
+ MouseButton[MouseButton["Right"] = 2] = "Right";
24928
+ MouseButton[MouseButton["Middle"] = 3] = "Middle";
24929
+ MouseButton[MouseButton["WheelUp"] = 4] = "WheelUp";
24930
+ MouseButton[MouseButton["WheelDown"] = 5] = "WheelDown";
24931
+ MouseButton[MouseButton["WheelLeft"] = 6] = "WheelLeft";
24932
+ MouseButton[MouseButton["WheelRight"] = 7] = "WheelRight";
24933
+ MouseButton[MouseButton["Xbutton1"] = 8] = "Xbutton1";
24934
+ MouseButton[MouseButton["Xbutton2"] = 9] = "Xbutton2";
24935
+ })(exports.MouseButton || (exports.MouseButton = {}));
24936
+ exports.MouseButtonMask = void 0;
24937
+ (function(MouseButtonMask) {
24938
+ MouseButtonMask[MouseButtonMask["None"] = 0] = "None";
24939
+ MouseButtonMask[MouseButtonMask["Left"] = 1] = "Left";
24940
+ MouseButtonMask[MouseButtonMask["Right"] = 2] = "Right";
24941
+ MouseButtonMask[MouseButtonMask["Middle"] = 4] = "Middle";
24942
+ MouseButtonMask[MouseButtonMask["Xbutton1"] = 128] = "Xbutton1";
24943
+ MouseButtonMask[MouseButtonMask["Xbutton2"] = 256] = "Xbutton2";
24944
+ })(exports.MouseButtonMask || (exports.MouseButtonMask = {}));
24945
+ exports.KeyLocation = void 0;
24946
+ (function(KeyLocation) {
24947
+ KeyLocation[KeyLocation["Unspecified"] = 0] = "Unspecified";
24948
+ KeyLocation[KeyLocation["Left"] = 1] = "Left";
24949
+ KeyLocation[KeyLocation["Right"] = 2] = "Right";
24950
+ })(exports.KeyLocation || (exports.KeyLocation = {}));
24951
+
24952
+ function transformPoint(transform, value) {
24953
+ var elements = transform.elements;
24954
+ return new Vector2(elements[0] * value.x + elements[3] * value.y + elements[6], elements[1] * value.x + elements[4] * value.y + elements[7]);
24955
+ }
24956
+ function transformVector(transform, value) {
24957
+ var elements = transform.elements;
24958
+ return new Vector2(elements[0] * value.x + elements[3] * value.y, elements[1] * value.x + elements[4] * value.y);
24959
+ }
24960
+ var InputEvent = /*#__PURE__*/ function() {
24961
+ function InputEvent() {
24962
+ this.device = 0;
24963
+ this.pressed = false;
24964
+ this.canceled = false;
24965
+ this._accepted = false;
24966
+ }
24967
+ var _proto = InputEvent.prototype;
24968
+ _proto.accept = function accept() {
24969
+ this._accepted = true;
24970
+ };
24971
+ _proto.clearAccepted = function clearAccepted() {
24972
+ this._accepted = false;
24973
+ };
24974
+ _proto.isAccepted = function isAccepted() {
24975
+ return this._accepted;
24976
+ };
24977
+ _proto.isPressed = function isPressed() {
24978
+ return this.pressed && !this.canceled;
24979
+ };
24980
+ _proto.isReleased = function isReleased() {
24981
+ return !this.pressed && !this.canceled;
24982
+ };
24983
+ _proto.isCanceled = function isCanceled() {
24984
+ return this.canceled;
24985
+ };
24986
+ _proto.isEcho = function isEcho() {
24987
+ return false;
24988
+ };
24989
+ _proto.xformedBy = function xformedBy(transform) {
24990
+ return this;
24991
+ };
24992
+ return InputEvent;
24993
+ }();
24994
+ InputEvent.deviceIdEmulation = -1;
24995
+ InputEvent.deviceIdInternal = -2;
24996
+ InputEvent.deviceIdKeyboard = 16;
24997
+ InputEvent.deviceIdMouse = 32;
24998
+ var InputEventWithModifiers = /*#__PURE__*/ function(InputEvent) {
24999
+ _inherits(InputEventWithModifiers, InputEvent);
25000
+ function InputEventWithModifiers() {
25001
+ var _this;
25002
+ _this = InputEvent.apply(this, arguments) || this;
25003
+ _this.commandOrControlAutoremap = false;
25004
+ _this.shiftPressed = false;
25005
+ _this.altPressed = false;
25006
+ _this.metaPressed = false;
25007
+ _this.ctrlPressed = false;
25008
+ return _this;
25009
+ }
25010
+ var _proto = InputEventWithModifiers.prototype;
25011
+ _proto.copyModifiersTo = function copyModifiersTo(event) {
25012
+ event.device = this.device;
25013
+ event.pressed = this.pressed;
25014
+ event.canceled = this.canceled;
25015
+ event.commandOrControlAutoremap = this.commandOrControlAutoremap;
25016
+ event.shiftPressed = this.shiftPressed;
25017
+ event.altPressed = this.altPressed;
25018
+ event.metaPressed = this.metaPressed;
25019
+ event.ctrlPressed = this.ctrlPressed;
25020
+ };
25021
+ return InputEventWithModifiers;
25022
+ }(_wrap_native_super(InputEvent));
25023
+ var InputEventKey = /*#__PURE__*/ function(InputEventWithModifiers) {
25024
+ _inherits(InputEventKey, InputEventWithModifiers);
25025
+ function InputEventKey() {
25026
+ var _this;
25027
+ _this = InputEventWithModifiers.apply(this, arguments) || this;
25028
+ _this.keycode = "";
25029
+ _this.physicalKeycode = "";
25030
+ _this.keyLabel = "";
25031
+ _this.unicode = 0;
25032
+ _this.location = exports.KeyLocation.Unspecified;
25033
+ _this.echo = false;
25034
+ return _this;
25035
+ }
25036
+ var _proto = InputEventKey.prototype;
25037
+ _proto.isEcho = function isEcho() {
25038
+ return this.echo;
25039
+ };
25040
+ return InputEventKey;
25041
+ }(InputEventWithModifiers);
25042
+ var InputEventMouse = /*#__PURE__*/ function(InputEventWithModifiers) {
25043
+ _inherits(InputEventMouse, InputEventWithModifiers);
25044
+ function InputEventMouse() {
25045
+ var _this;
25046
+ _this = InputEventWithModifiers.apply(this, arguments) || this;
25047
+ _this.buttonMask = exports.MouseButtonMask.None;
25048
+ _this.position = new Vector2();
25049
+ _this.globalPosition = new Vector2();
25050
+ return _this;
25051
+ }
25052
+ var _proto = InputEventMouse.prototype;
25053
+ _proto.copyMouseTo = function copyMouseTo(event) {
25054
+ this.copyModifiersTo(event);
25055
+ event.buttonMask = this.buttonMask;
25056
+ event.position.copyFrom(this.position);
25057
+ event.globalPosition.copyFrom(this.globalPosition);
25058
+ };
25059
+ return InputEventMouse;
25060
+ }(InputEventWithModifiers);
25061
+ var InputEventMouseButton = /*#__PURE__*/ function(InputEventMouse) {
25062
+ _inherits(InputEventMouseButton, InputEventMouse);
25063
+ function InputEventMouseButton() {
25064
+ var _this;
25065
+ _this = InputEventMouse.apply(this, arguments) || this;
25066
+ _this.factor = 1;
25067
+ _this.buttonIndex = exports.MouseButton.None;
25068
+ _this.doubleClick = false;
25069
+ return _this;
25070
+ }
25071
+ var _proto = InputEventMouseButton.prototype;
25072
+ _proto.xformedBy = function xformedBy(transform) {
25073
+ var event = new InputEventMouseButton();
25074
+ this.copyMouseTo(event);
25075
+ event.position.copyFrom(transformPoint(transform, this.position));
25076
+ event.factor = this.factor;
25077
+ event.buttonIndex = this.buttonIndex;
25078
+ event.doubleClick = this.doubleClick;
25079
+ return event;
25080
+ };
25081
+ return InputEventMouseButton;
25082
+ }(InputEventMouse);
25083
+ var InputEventMouseMotion = /*#__PURE__*/ function(InputEventMouse) {
25084
+ _inherits(InputEventMouseMotion, InputEventMouse);
25085
+ function InputEventMouseMotion() {
25086
+ var _this;
25087
+ _this = InputEventMouse.apply(this, arguments) || this;
25088
+ _this.tilt = new Vector2();
25089
+ _this.pressure = 0;
25090
+ _this.relative = new Vector2();
25091
+ _this.screenRelative = new Vector2();
25092
+ _this.velocity = new Vector2();
25093
+ _this.screenVelocity = new Vector2();
25094
+ _this.penInverted = false;
25095
+ return _this;
25096
+ }
25097
+ var _proto = InputEventMouseMotion.prototype;
25098
+ _proto.xformedBy = function xformedBy(transform) {
25099
+ var event = new InputEventMouseMotion();
25100
+ this.copyMouseTo(event);
25101
+ event.position.copyFrom(transformPoint(transform, this.position));
25102
+ event.tilt.copyFrom(this.tilt);
25103
+ event.pressure = this.pressure;
25104
+ event.relative.copyFrom(transformVector(transform, this.relative));
25105
+ event.screenRelative.copyFrom(this.screenRelative);
25106
+ event.velocity.copyFrom(transformVector(transform, this.velocity));
25107
+ event.screenVelocity.copyFrom(this.screenVelocity);
25108
+ event.penInverted = this.penInverted;
25109
+ return event;
25110
+ };
25111
+ return InputEventMouseMotion;
25112
+ }(InputEventMouse);
25113
+ var InputEventScreenTouch = /*#__PURE__*/ function(InputEvent) {
25114
+ _inherits(InputEventScreenTouch, InputEvent);
25115
+ function InputEventScreenTouch() {
25116
+ var _this;
25117
+ _this = InputEvent.apply(this, arguments) || this;
25118
+ _this.index = 0;
25119
+ _this.position = new Vector2();
25120
+ _this.doubleTap = false;
25121
+ return _this;
25122
+ }
25123
+ var _proto = InputEventScreenTouch.prototype;
25124
+ _proto.xformedBy = function xformedBy(transform) {
25125
+ var event = new InputEventScreenTouch();
25126
+ event.device = this.device;
25127
+ event.pressed = this.pressed;
25128
+ event.canceled = this.canceled;
25129
+ event.index = this.index;
25130
+ event.position.copyFrom(transformPoint(transform, this.position));
25131
+ event.doubleTap = this.doubleTap;
25132
+ return event;
25133
+ };
25134
+ return InputEventScreenTouch;
25135
+ }(_wrap_native_super(InputEvent));
25136
+ var InputEventScreenDrag = /*#__PURE__*/ function(InputEvent) {
25137
+ _inherits(InputEventScreenDrag, InputEvent);
25138
+ function InputEventScreenDrag() {
25139
+ var _this;
25140
+ _this = InputEvent.apply(this, arguments) || this;
25141
+ _this.index = 0;
25142
+ _this.position = new Vector2();
25143
+ _this.relative = new Vector2();
25144
+ _this.screenRelative = new Vector2();
25145
+ _this.velocity = new Vector2();
25146
+ _this.screenVelocity = new Vector2();
25147
+ _this.pressure = 0;
25148
+ _this.tilt = new Vector2();
25149
+ _this.penInverted = false;
25150
+ return _this;
25151
+ }
25152
+ var _proto = InputEventScreenDrag.prototype;
25153
+ _proto.xformedBy = function xformedBy(transform) {
25154
+ var event = new InputEventScreenDrag();
25155
+ event.device = this.device;
25156
+ event.pressed = this.pressed;
25157
+ event.canceled = this.canceled;
25158
+ event.index = this.index;
25159
+ event.position.copyFrom(transformPoint(transform, this.position));
25160
+ event.relative.copyFrom(transformVector(transform, this.relative));
25161
+ event.screenRelative.copyFrom(this.screenRelative);
25162
+ event.velocity.copyFrom(transformVector(transform, this.velocity));
25163
+ event.screenVelocity.copyFrom(this.screenVelocity);
25164
+ event.pressure = this.pressure;
25165
+ event.tilt.copyFrom(this.tilt);
25166
+ event.penInverted = this.penInverted;
25167
+ return event;
25168
+ };
25169
+ return InputEventScreenDrag;
25170
+ }(_wrap_native_super(InputEvent));
25171
+
26678
25172
  var EVENT_TYPE_CLICK = "click";
26679
25173
  var EVENT_TYPE_TOUCH_START = "touchstart";
26680
25174
  var EVENT_TYPE_TOUCH_MOVE = "touchmove";
@@ -26685,49 +25179,52 @@ exports.PointerEventType = void 0;
26685
25179
  PointerEventType[PointerEventType["PointerUp"] = 1] = "PointerUp";
26686
25180
  PointerEventType[PointerEventType["PointerMove"] = 2] = "PointerMove";
26687
25181
  })(exports.PointerEventType || (exports.PointerEventType = {}));
26688
- var EventSystem = /*#__PURE__*/ function() {
25182
+ var EventSystem = /*#__PURE__*/ function(EventEmitter) {
25183
+ _inherits(EventSystem, EventEmitter);
26689
25184
  function EventSystem(engine, allowPropagation) {
26690
- var _this = this;
26691
25185
  if (allowPropagation === void 0) allowPropagation = false;
26692
- this.engine = engine;
26693
- this.allowPropagation = allowPropagation;
26694
- this.skipPointerMovePicking = true;
26695
- this.emulateMouseFromTouch = true;
26696
- this.emulateTouchFromMouse = false;
26697
- this._enabled = true;
26698
- this.handlers = {};
26699
- this.nativeHandlers = [];
26700
- this.target = null;
26701
- this.mouseState = null;
26702
- this.touchStates = new Map();
26703
- this.mouseFromTouchIndex = null;
26704
- this.touchFromMousePressed = false;
26705
- this.addedTabIndex = false;
26706
- this.addedOutlineStyle = false;
26707
- this.onNativeWheel = function(event) {
25186
+ var _this;
25187
+ _this = EventEmitter.call(this) || this;
25188
+ _this.engine = engine;
25189
+ _this.allowPropagation = allowPropagation;
25190
+ _this.skipPointerMovePicking = true;
25191
+ _this.emulateMouseFromTouch = true;
25192
+ _this.emulateTouchFromMouse = false;
25193
+ _this._enabled = true;
25194
+ _this.handlers = {};
25195
+ _this.nativeHandlers = [];
25196
+ _this.target = null;
25197
+ _this.mouseState = null;
25198
+ _this.mouseButtonMask = exports.MouseButtonMask.None;
25199
+ _this.touchStates = new Map();
25200
+ _this.mouseFromTouchIndex = null;
25201
+ _this.touchFromMousePressed = false;
25202
+ _this.addedTabIndex = false;
25203
+ _this.addedOutlineStyle = false;
25204
+ _this.onNativeWheel = function(event) {
26708
25205
  if (!_this.enabled || !_this.target) {
26709
25206
  return;
26710
25207
  }
26711
25208
  var position = _this.getCanvasPosition(event.clientX, event.clientY);
26712
25209
  var handled = false;
26713
25210
  if (event.deltaY !== 0) {
26714
- handled = _this.pushWheelButton(event.deltaY < 0 ? exports.MouseButton.WheelUp : exports.MouseButton.WheelDown, Math.abs(event.deltaY), position, event) || handled;
25211
+ handled = _this.pushWheelButton(event.deltaY < 0 ? exports.MouseButton.WheelUp : exports.MouseButton.WheelDown, normalizeWheelFactor(event.deltaY, event.deltaMode), position, event) || handled;
26715
25212
  }
26716
25213
  if (event.deltaX !== 0) {
26717
- handled = _this.pushWheelButton(event.deltaX < 0 ? exports.MouseButton.WheelLeft : exports.MouseButton.WheelRight, Math.abs(event.deltaX), position, event) || handled;
25214
+ handled = _this.pushWheelButton(event.deltaX < 0 ? exports.MouseButton.WheelLeft : exports.MouseButton.WheelRight, normalizeWheelFactor(event.deltaX, event.deltaMode), position, event) || handled;
26718
25215
  }
26719
25216
  _this.consumeNativeEvent(event, handled);
26720
25217
  };
26721
- this.onNativeKeyDown = function(event) {
25218
+ _this.onNativeKeyDown = function(event) {
26722
25219
  _this.handleNativeKey(event, true);
26723
25220
  };
26724
- this.onNativeKeyUp = function(event) {
25221
+ _this.onNativeKeyUp = function(event) {
26725
25222
  _this.handleNativeKey(event, false);
26726
25223
  };
26727
- this.onNativeMouseDown = function(event) {
25224
+ _this.onNativeMouseDown = function(event) {
26728
25225
  _this.handleNativeMouseDown(event);
26729
25226
  };
26730
- this.onNativeMouseMove = function(event) {
25227
+ _this.onNativeMouseMove = function(event) {
26731
25228
  var _state;
26732
25229
  if (!_this.enabled || !_this.target) {
26733
25230
  return;
@@ -26739,18 +25236,22 @@ var EventSystem = /*#__PURE__*/ function() {
26739
25236
  var relative = new Vector2(position.x - state.last.x, position.y - state.last.y);
26740
25237
  var velocity = _this.getVelocity(state, position);
26741
25238
  var handled = _this.pushNativeMouseMotion(event, position, relative, velocity);
26742
- (_state = state).controlHandled || (_state.controlHandled = handled);
26743
- if (!handled && (!state.pressed || !state.controlHandled)) {
25239
+ (_state = state).inputHandled || (_state.inputHandled = handled);
25240
+ if (!handled && (!state.pressed || !state.inputHandled)) {
26744
25241
  var pointerEvent = _this.createPointerEvent(event, position, state, velocity);
26745
25242
  _this.dispatchEvent(EVENT_TYPE_TOUCH_MOVE, pointerEvent);
26746
25243
  }
26747
25244
  _this.updatePointerState(state, position);
26748
25245
  _this.consumeNativeEvent(event, handled);
26749
25246
  };
26750
- this.onNativeMouseUp = function(event) {
25247
+ _this.onNativeMouseUp = function(event) {
26751
25248
  if (!_this.enabled || !_this.target) {
26752
25249
  return;
26753
25250
  }
25251
+ // Keep the canonical mask in sync even when mouseState already ended on a
25252
+ // previous button release. The target and Window listeners may see the
25253
+ // same mouseup, but clearing a bit twice is intentionally idempotent.
25254
+ _this.setMouseButtonPressed(event.button, false);
26754
25255
  var position = _this.getCanvasPosition(event.clientX, event.clientY);
26755
25256
  var existingState = _this.mouseState;
26756
25257
  if (!(existingState == null ? void 0 : existingState.pressed)) {
@@ -26759,16 +25260,16 @@ var EventSystem = /*#__PURE__*/ function() {
26759
25260
  var state = existingState;
26760
25261
  var handled = _this.pushNativeMouseButton(event, position, false);
26761
25262
  var pointerEvent = _this.createPointerEvent(event, position, state);
26762
- if (!state.controlHandled && !handled && _this.isClick(state, position)) {
25263
+ if (!state.inputHandled && !handled && _this.isClick(state, position)) {
26763
25264
  _this.dispatchEvent(EVENT_TYPE_CLICK, pointerEvent);
26764
25265
  }
26765
- if (!handled && !state.controlHandled) {
25266
+ if (!handled && !state.inputHandled) {
26766
25267
  _this.dispatchEvent(EVENT_TYPE_TOUCH_END, pointerEvent);
26767
25268
  }
26768
25269
  _this.mouseState = null;
26769
- _this.consumeNativeEvent(event, handled || state.controlHandled || !_this.allowPropagation);
25270
+ _this.consumeNativeEvent(event, handled || state.inputHandled || !_this.allowPropagation);
26770
25271
  };
26771
- this.onNativeTouchStart = function(event) {
25272
+ _this.onNativeTouchStart = function(event) {
26772
25273
  if (!_this.enabled) {
26773
25274
  return;
26774
25275
  }
@@ -26780,7 +25281,7 @@ var EventSystem = /*#__PURE__*/ function() {
26780
25281
  _this.touchStates.set(touch.identifier, state);
26781
25282
  state.pressed = true;
26782
25283
  var handled = _this.pushNativeScreenTouch(touch.identifier, position, true, false, false);
26783
- state.controlHandled = handled;
25284
+ state.inputHandled = handled;
26784
25285
  if (!handled) {
26785
25286
  var pointerEvent = _this.createPointerEvent(event, position, state);
26786
25287
  _this.dispatchEvent(EVENT_TYPE_TOUCH_START, pointerEvent);
@@ -26789,7 +25290,7 @@ var EventSystem = /*#__PURE__*/ function() {
26789
25290
  }
26790
25291
  _this.preventTouchDefaults(event);
26791
25292
  };
26792
- this.onNativeTouchMove = function(event) {
25293
+ _this.onNativeTouchMove = function(event) {
26793
25294
  if (!_this.enabled) {
26794
25295
  return;
26795
25296
  }
@@ -26803,8 +25304,8 @@ var EventSystem = /*#__PURE__*/ function() {
26803
25304
  var relative = new Vector2(position.x - state.last.x, position.y - state.last.y);
26804
25305
  var velocity = _this.getVelocity(state, position);
26805
25306
  var handled = _this.pushNativeScreenDrag(touch.identifier, position, relative, velocity);
26806
- (_state = state).controlHandled || (_state.controlHandled = handled);
26807
- if (!handled && !state.controlHandled) {
25307
+ (_state = state).inputHandled || (_state.inputHandled = handled);
25308
+ if (!handled && !state.inputHandled) {
26808
25309
  var pointerEvent = _this.createPointerEvent(event, position, state, velocity);
26809
25310
  _this.dispatchEvent(EVENT_TYPE_TOUCH_MOVE, pointerEvent);
26810
25311
  }
@@ -26813,24 +25314,26 @@ var EventSystem = /*#__PURE__*/ function() {
26813
25314
  }
26814
25315
  _this.preventTouchDefaults(event);
26815
25316
  };
26816
- this.onNativeTouchEnd = function(event) {
25317
+ _this.onNativeTouchEnd = function(event) {
26817
25318
  _this.handleNativeTouchEnd(event, false);
26818
25319
  };
26819
- this.onNativeTouchCancel = function(event) {
25320
+ _this.onNativeTouchCancel = function(event) {
26820
25321
  _this.handleNativeTouchEnd(event, true);
26821
25322
  };
26822
- this.onWindowBlur = function() {
26823
- if (_this.enabled) {
26824
- _this.mouseState = null;
26825
- _this.touchStates.clear();
26826
- _this.mouseFromTouchIndex = null;
26827
- _this.touchFromMousePressed = false;
26828
- _this.engine.windowRoot.cancelPointerInput();
26829
- }
25323
+ _this.onCanvasFocus = function() {
25324
+ _this.emit("canvasFocus");
26830
25325
  };
25326
+ _this.onCanvasBlur = function() {
25327
+ _this.emit("canvasBlur");
25328
+ };
25329
+ return _this;
26831
25330
  }
26832
25331
  var _proto = EventSystem.prototype;
26833
- _proto.bindListeners = function bindListeners(target) {
25332
+ /**
25333
+ * Rebinds native input listeners to a canvas.
25334
+ *
25335
+ * Rebind or unbind only while there are no active key, mouse, touch, or drag sessions.
25336
+ */ _proto.bindListeners = function bindListeners(target) {
26834
25337
  this.unbindListeners();
26835
25338
  this.target = target;
26836
25339
  if (!target || typeof window === "undefined") {
@@ -26867,7 +25370,8 @@ var EventSystem = /*#__PURE__*/ function() {
26867
25370
  });
26868
25371
  this.addNativeHandler(target, "keydown", this.onNativeKeyDown);
26869
25372
  this.addNativeHandler(target, "keyup", this.onNativeKeyUp);
26870
- this.addNativeHandler(window, "blur", this.onWindowBlur);
25373
+ this.addNativeHandler(target, "focus", this.onCanvasFocus);
25374
+ this.addNativeHandler(target, "blur", this.onCanvasBlur);
26871
25375
  };
26872
25376
  _proto.dispatchEvent = function dispatchEvent(type, event) {
26873
25377
  var handlers = this.handlers[type];
@@ -26901,11 +25405,7 @@ var EventSystem = /*#__PURE__*/ function() {
26901
25405
  }
26902
25406
  };
26903
25407
  _proto.dispose = function dispose() {
26904
- this.engine.windowRoot.cancelPointerInput();
26905
- this.mouseState = null;
26906
- this.touchStates.clear();
26907
- this.mouseFromTouchIndex = null;
26908
- this.touchFromMousePressed = false;
25408
+ this.resetInputState();
26909
25409
  this.handlers = {};
26910
25410
  this.unbindListeners();
26911
25411
  this.target = null;
@@ -26914,13 +25414,14 @@ var EventSystem = /*#__PURE__*/ function() {
26914
25414
  if (!this.enabled || !this.target) {
26915
25415
  return;
26916
25416
  }
25417
+ this.setMouseButtonPressed(event.button, true);
26917
25418
  var position = this.getCanvasPosition(event.clientX, event.clientY);
26918
25419
  this.focusTarget();
26919
25420
  var state = this.createPointerState(position);
26920
25421
  this.mouseState = state;
26921
25422
  state.pressed = true;
26922
25423
  var handled = this.pushNativeMouseButton(event, position, true);
26923
- state.controlHandled = handled;
25424
+ state.inputHandled = handled;
26924
25425
  if (!handled) {
26925
25426
  var pointerEvent = this.createPointerEvent(event, position, state);
26926
25427
  this.dispatchEvent(EVENT_TYPE_TOUCH_START, pointerEvent);
@@ -26944,8 +25445,7 @@ var EventSystem = /*#__PURE__*/ function() {
26944
25445
  input.altPressed = event.altKey;
26945
25446
  input.metaPressed = event.metaKey;
26946
25447
  input.ctrlPressed = event.ctrlKey;
26947
- this.engine.windowRoot.pushInput(input);
26948
- this.consumeNativeEvent(event, this.engine.windowRoot.isInputHandled());
25448
+ this.consumeNativeEvent(event, this.pushInput(input));
26949
25449
  };
26950
25450
  _proto.handleNativeTouchEnd = function handleNativeTouchEnd(event, canceled) {
26951
25451
  if (!this.enabled) {
@@ -26960,14 +25460,14 @@ var EventSystem = /*#__PURE__*/ function() {
26960
25460
  }
26961
25461
  var handled = this.pushNativeScreenTouch(touch.identifier, position, false, canceled, false);
26962
25462
  var pointerEvent = this.createPointerEvent(event, position, state);
26963
- if (!canceled && !state.controlHandled && !handled && this.isClick(state, position)) {
25463
+ if (!canceled && !state.inputHandled && !handled && this.isClick(state, position)) {
26964
25464
  this.dispatchEvent(EVENT_TYPE_CLICK, pointerEvent);
26965
25465
  }
26966
- if (!handled && !canceled && !state.controlHandled) {
25466
+ if (!handled && !canceled && !state.inputHandled) {
26967
25467
  this.dispatchEvent(EVENT_TYPE_TOUCH_END, pointerEvent);
26968
25468
  }
26969
25469
  this.touchStates.delete(touch.identifier);
26970
- this.consumeNativeEvent(event, handled || state.controlHandled || !this.allowPropagation);
25470
+ this.consumeNativeEvent(event, handled || state.inputHandled || !this.allowPropagation);
26971
25471
  }
26972
25472
  this.preventTouchDefaults(event);
26973
25473
  };
@@ -26987,7 +25487,7 @@ var EventSystem = /*#__PURE__*/ function() {
26987
25487
  };
26988
25488
  _proto.pushNativeMouseMotion = function pushNativeMouseMotion(event, position, relative, velocity) {
26989
25489
  var handled = false;
26990
- if (this.touchFromMousePressed && (event.buttons & 1) !== 0) {
25490
+ if (this.touchFromMousePressed && (this.mouseButtonMask & exports.MouseButtonMask.Left) !== 0) {
26991
25491
  handled = this.pushScreenDrag(0, position, relative, velocity, InputEvent.deviceIdEmulation);
26992
25492
  }
26993
25493
  return this.pushMouseMotion(event, position, relative, velocity) || handled;
@@ -27024,8 +25524,7 @@ var EventSystem = /*#__PURE__*/ function() {
27024
25524
  input.pressed = pressed;
27025
25525
  input.canceled = canceled;
27026
25526
  input.doubleClick = doubleClick;
27027
- this.engine.windowRoot.pushInput(input);
27028
- return this.engine.windowRoot.isInputHandled();
25527
+ return this.pushInput(input);
27029
25528
  };
27030
25529
  _proto.pushEmulatedMouseMotion = function pushEmulatedMouseMotion(position, relative, velocity) {
27031
25530
  var input = new InputEventMouseMotion();
@@ -27038,42 +25537,42 @@ var EventSystem = /*#__PURE__*/ function() {
27038
25537
  input.screenRelative.copyFrom(relative);
27039
25538
  input.velocity.copyFrom(velocity);
27040
25539
  input.screenVelocity.copyFrom(velocity);
27041
- this.engine.windowRoot.pushInput(input);
27042
- return this.engine.windowRoot.isInputHandled();
25540
+ return this.pushInput(input);
27043
25541
  };
27044
25542
  _proto.pushMouseButton = function pushMouseButton(event, position, pressed) {
27045
25543
  var input = new InputEventMouseButton();
27046
25544
  this.copyMouseFields(input, event, position);
27047
25545
  input.device = InputEvent.deviceIdMouse;
27048
25546
  input.buttonIndex = getMouseButton(event.button);
27049
- input.buttonMask = getMouseButtonMask(event.buttons);
25547
+ input.buttonMask = this.mouseButtonMask;
25548
+ input.pressed = pressed;
25549
+ input.doubleClick = event.detail > 1;
25550
+ return this.pushInput(input);
25551
+ };
25552
+ _proto.setMouseButtonPressed = function setMouseButtonPressed(button, pressed) {
25553
+ var buttonBit = getMouseButtonBit(getMouseButton(button));
27050
25554
  if (pressed) {
27051
- input.buttonMask |= getMouseButtonBit(input.buttonIndex);
25555
+ this.mouseButtonMask |= buttonBit;
27052
25556
  } else {
27053
- input.buttonMask &= ~getMouseButtonBit(input.buttonIndex);
25557
+ this.mouseButtonMask &= ~buttonBit;
27054
25558
  }
27055
- input.pressed = pressed;
27056
- input.doubleClick = event.detail > 1;
27057
- this.engine.windowRoot.pushInput(input);
27058
- return this.engine.windowRoot.isInputHandled();
27059
25559
  };
27060
25560
  _proto.pushWheelButton = function pushWheelButton(button, factor, position, event) {
27061
25561
  var input = new InputEventMouseButton();
27062
25562
  this.copyMouseFields(input, event, position);
27063
25563
  input.device = InputEvent.deviceIdMouse;
27064
25564
  input.buttonIndex = button;
27065
- input.buttonMask = getMouseButtonMask(event.buttons);
25565
+ input.buttonMask = this.mouseButtonMask;
27066
25566
  input.factor = factor;
27067
25567
  input.pressed = true;
27068
- this.engine.windowRoot.pushInput(input);
27069
- return this.engine.windowRoot.isInputHandled();
25568
+ return this.pushInput(input);
27070
25569
  };
27071
25570
  _proto.pushMouseMotion = function pushMouseMotion(event, position, relative, velocity) {
27072
25571
  var input = new InputEventMouseMotion();
27073
25572
  this.copyMouseFields(input, event, position);
27074
25573
  input.device = InputEvent.deviceIdMouse;
27075
- input.buttonMask = getMouseButtonMask(event.buttons);
27076
- input.pressed = event.buttons !== 0;
25574
+ input.buttonMask = this.mouseButtonMask;
25575
+ input.pressed = this.mouseButtonMask !== exports.MouseButtonMask.None;
27077
25576
  input.relative.copyFrom(relative);
27078
25577
  input.screenRelative.copyFrom(relative);
27079
25578
  input.velocity.copyFrom(velocity);
@@ -27082,8 +25581,7 @@ var EventSystem = /*#__PURE__*/ function() {
27082
25581
  input.pressure = event.pressure;
27083
25582
  input.tilt.set(event.tiltX, event.tiltY);
27084
25583
  }
27085
- this.engine.windowRoot.pushInput(input);
27086
- return this.engine.windowRoot.isInputHandled();
25584
+ return this.pushInput(input);
27087
25585
  };
27088
25586
  _proto.pushScreenTouch = function pushScreenTouch(index, position, pressed, canceled, doubleTap, device) {
27089
25587
  var input = new InputEventScreenTouch();
@@ -27093,8 +25591,7 @@ var EventSystem = /*#__PURE__*/ function() {
27093
25591
  input.pressed = pressed;
27094
25592
  input.canceled = canceled;
27095
25593
  input.doubleTap = doubleTap;
27096
- this.engine.windowRoot.pushInput(input);
27097
- return this.engine.windowRoot.isInputHandled();
25594
+ return this.pushInput(input);
27098
25595
  };
27099
25596
  _proto.pushScreenDrag = function pushScreenDrag(index, position, relative, velocity, device) {
27100
25597
  var input = new InputEventScreenDrag();
@@ -27106,8 +25603,7 @@ var EventSystem = /*#__PURE__*/ function() {
27106
25603
  input.velocity.copyFrom(velocity);
27107
25604
  input.screenVelocity.copyFrom(velocity);
27108
25605
  input.pressed = true;
27109
- this.engine.windowRoot.pushInput(input);
27110
- return this.engine.windowRoot.isInputHandled();
25606
+ return this.pushInput(input);
27111
25607
  };
27112
25608
  _proto.copyMouseFields = function copyMouseFields(input, event, position) {
27113
25609
  input.position.copyFrom(position);
@@ -27182,7 +25678,7 @@ var EventSystem = /*#__PURE__*/ function() {
27182
25678
  start: position.clone(),
27183
25679
  last: position.clone(),
27184
25680
  lastTime: performance.now(),
27185
- controlHandled: false,
25681
+ inputHandled: false,
27186
25682
  pressed: false
27187
25683
  };
27188
25684
  return state;
@@ -27207,8 +25703,8 @@ var EventSystem = /*#__PURE__*/ function() {
27207
25703
  var _target_width, _target_height;
27208
25704
  return {
27209
25705
  x: position.x / cssWidth * 2 - 1,
27210
- // Legacy composition picking uses bottom-left, Y-up NDC even though GUI
27211
- // input follows the DOM convention of top-left, Y-down pixels.
25706
+ // Legacy composition picking uses bottom-left, Y-up NDC even though
25707
+ // standardized input follows the DOM convention of top-left, Y-down pixels.
27212
25708
  y: 1 - position.y / cssHeight * 2,
27213
25709
  vx: velocity.x / cssWidth * 2,
27214
25710
  vy: -velocity.y / cssHeight * 2,
@@ -27236,6 +25732,11 @@ var EventSystem = /*#__PURE__*/ function() {
27236
25732
  event.stopPropagation();
27237
25733
  }
27238
25734
  };
25735
+ _proto.pushInput = function pushInput(input) {
25736
+ input.clearAccepted();
25737
+ this.emit("input", input);
25738
+ return input.isAccepted();
25739
+ };
27239
25740
  _proto.preventTouchDefaults = function preventTouchDefaults(event) {
27240
25741
  if (event.cancelable) {
27241
25742
  event.preventDefault();
@@ -27245,6 +25746,13 @@ var EventSystem = /*#__PURE__*/ function() {
27245
25746
  var _this_target;
27246
25747
  (_this_target = this.target) == null ? void 0 : _this_target.focus();
27247
25748
  };
25749
+ _proto.resetInputState = function resetInputState() {
25750
+ this.mouseState = null;
25751
+ this.mouseButtonMask = exports.MouseButtonMask.None;
25752
+ this.touchStates.clear();
25753
+ this.mouseFromTouchIndex = null;
25754
+ this.touchFromMousePressed = false;
25755
+ };
27248
25756
  _proto.addNativeHandler = function addNativeHandler(target, name, handler, options) {
27249
25757
  target.addEventListener(name, handler, options);
27250
25758
  this.nativeHandlers.push({
@@ -27275,23 +25783,20 @@ var EventSystem = /*#__PURE__*/ function() {
27275
25783
  get: function get() {
27276
25784
  return this._enabled;
27277
25785
  },
27278
- set: function set(value) {
25786
+ set: /**
25787
+ * Enables native input processing.
25788
+ *
25789
+ * Change this only while there are no active key, mouse, touch, or drag sessions.
25790
+ */ function set(value) {
27279
25791
  if (this._enabled === value) {
27280
25792
  return;
27281
25793
  }
27282
25794
  this._enabled = value;
27283
- if (!value) {
27284
- this.mouseState = null;
27285
- this.touchStates.clear();
27286
- this.mouseFromTouchIndex = null;
27287
- this.touchFromMousePressed = false;
27288
- this.engine.windowRoot.cancelPointerInput();
27289
- }
27290
25795
  }
27291
25796
  }
27292
25797
  ]);
27293
25798
  return EventSystem;
27294
- }();
25799
+ }(EventEmitter);
27295
25800
  function getKeyLocation(location) {
27296
25801
  if (location === 1) {
27297
25802
  return exports.KeyLocation.Left;
@@ -27322,25 +25827,6 @@ function getMouseButton(button) {
27322
25827
  return exports.MouseButton.None;
27323
25828
  }
27324
25829
  }
27325
- function getMouseButtonMask(buttons) {
27326
- var mask = exports.MouseButtonMask.None;
27327
- if ((buttons & 1) !== 0) {
27328
- mask |= exports.MouseButtonMask.Left;
27329
- }
27330
- if ((buttons & 2) !== 0) {
27331
- mask |= exports.MouseButtonMask.Right;
27332
- }
27333
- if ((buttons & 4) !== 0) {
27334
- mask |= exports.MouseButtonMask.Middle;
27335
- }
27336
- if ((buttons & 8) !== 0) {
27337
- mask |= exports.MouseButtonMask.Xbutton1;
27338
- }
27339
- if ((buttons & 16) !== 0) {
27340
- mask |= exports.MouseButtonMask.Xbutton2;
27341
- }
27342
- return mask;
27343
- }
27344
25830
  function getMouseButtonBit(button) {
27345
25831
  switch(button){
27346
25832
  case exports.MouseButton.Left:
@@ -27357,6 +25843,16 @@ function getMouseButtonBit(button) {
27357
25843
  return exports.MouseButtonMask.None;
27358
25844
  }
27359
25845
  }
25846
+ function normalizeWheelFactor(delta, mode) {
25847
+ var magnitude = Math.abs(delta);
25848
+ if (mode === 1) {
25849
+ return magnitude / 3;
25850
+ }
25851
+ if (mode === 2) {
25852
+ return magnitude;
25853
+ }
25854
+ return magnitude / 100;
25855
+ }
27360
25856
 
27361
25857
  var InteractLoader = /*#__PURE__*/ function(Plugin) {
27362
25858
  _inherits(InteractLoader, Plugin);
@@ -29376,6 +27872,11 @@ exports.SpritePropertyTrack = __decorate([
29376
27872
  effectsClass("SpritePropertyTrack")
29377
27873
  ], exports.SpritePropertyTrack);
29378
27874
 
27875
+ function _assert_this_initialized(self) {
27876
+ if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
27877
+ return self;
27878
+ }
27879
+
29379
27880
  var Cone = /*#__PURE__*/ function() {
29380
27881
  function Cone(props) {
29381
27882
  var _this = this;
@@ -39380,7 +37881,7 @@ function getStandardSpriteContent(sprite, transform) {
39380
37881
  return ret;
39381
37882
  }
39382
37883
 
39383
- var version$2 = "2.10.0-alpha.4";
37884
+ var version$2 = "2.10.0";
39384
37885
  var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
39385
37886
  var standardVersion = /^(\d+)\.(\d+)$/;
39386
37887
  var reverseParticle = false;
@@ -41376,9 +39877,11 @@ var PreRenderTickData = /*#__PURE__*/ function(TickData) {
41376
39877
  // Instantiate composition rootItem
41377
39878
  _this.sceneRoot = new exports.VFXItem(_this.engine);
41378
39879
  _this.sceneRoot.setParent(_this.root);
41379
- _this.uiCanvas = _this.sceneRoot.addComponent(UICanvas);
41380
39880
  if (sourceContent) {
41381
39881
  _this.sceneRoot.setInstanceId(sourceContent.id);
39882
+ }
39883
+ PluginSystem.notifyCompositionCreating(_assert_this_initialized(_this), scene);
39884
+ if (sourceContent) {
41382
39885
  _this.sceneRoot.instantiatePreComposition(sourceContent, false);
41383
39886
  }
41384
39887
  // 在 instantiatePreComposition 后设置 rootItem 的 name,避免 name 被覆盖
@@ -41947,9 +40450,6 @@ var PreRenderTickData = /*#__PURE__*/ function(TickData) {
41947
40450
  },
41948
40451
  set: function set(value) {
41949
40452
  this._renderOrder = value;
41950
- if (this.uiCanvas) {
41951
- this.uiCanvas.order = value;
41952
- }
41953
40453
  }
41954
40454
  },
41955
40455
  {
@@ -41962,9 +40462,6 @@ var PreRenderTickData = /*#__PURE__*/ function(TickData) {
41962
40462
  },
41963
40463
  set: function set(value) {
41964
40464
  this._interactive = !!value;
41965
- if (this.uiCanvas) {
41966
- this.uiCanvas.receivesEvents = this._interactive;
41967
- }
41968
40465
  }
41969
40466
  },
41970
40467
  {
@@ -43792,7 +42289,6 @@ var DEFAULT_FPS = 60;
43792
42289
  _this.objectInstance = {};
43793
42290
  _this.root = new exports.VFXItem(_assert_this_initialized(_this));
43794
42291
  _this.root.name = "root";
43795
- _this.windowRoot = new WindowRootControl(_assert_this_initialized(_this));
43796
42292
  _this.whiteTexture = generateWhiteTexture(_assert_this_initialized(_this));
43797
42293
  _this.transparentTexture = generateEmptyTexture(_assert_this_initialized(_this));
43798
42294
  if (!(options == null ? void 0 : options.manualRender)) {
@@ -43945,7 +42441,7 @@ var DEFAULT_FPS = 60;
43945
42441
  (_this_ticker1 = this.ticker) == null ? void 0 : _this_ticker1.pause();
43946
42442
  return;
43947
42443
  }
43948
- this.windowRoot.update(dt);
42444
+ this.emit("update", dt);
43949
42445
  // Tick compositions onPreRender
43950
42446
  //-------------------------------------------------------------------------
43951
42447
  for(var _iterator1 = _create_for_of_iterator_helper_loose(compositions), _step1; !(_step1 = _iterator1()).done;){
@@ -43960,7 +42456,7 @@ var DEFAULT_FPS = 60;
43960
42456
  var composition2 = _step2.value;
43961
42457
  composition2.renderContent();
43962
42458
  }
43963
- this.windowRoot.render();
42459
+ this.emit("postrender");
43964
42460
  this.renderTargetPool.flush();
43965
42461
  };
43966
42462
  /**
@@ -44002,7 +42498,6 @@ var DEFAULT_FPS = 60;
44002
42498
  this.canvas.style.height = containerHeight + "px";
44003
42499
  logger.info("Resize engine " + this.name + " [" + canvasWidth + "," + canvasHeight + "," + containerWidth + "," + containerHeight + "].");
44004
42500
  this.setSize(canvasWidth, canvasHeight);
44005
- this.windowRoot.resize(canvasWidth, canvasHeight);
44006
42501
  }
44007
42502
  };
44008
42503
  _proto.setSize = function setSize(width, height) {
@@ -44208,6 +42703,12 @@ var DEFAULT_FPS = 60;
44208
42703
  _proto.setStencilTest = function setStencilTest(enable) {
44209
42704
  // OVERRIDE
44210
42705
  };
42706
+ _proto.setScissorTest = function setScissorTest(enable) {
42707
+ // OVERRIDE
42708
+ };
42709
+ _proto.setScissor = function setScissor(x, y, width, height) {
42710
+ // OVERRIDE
42711
+ };
44211
42712
  _proto.setCulling = function setCulling(enable) {
44212
42713
  // OVERRIDE
44213
42714
  };
@@ -44285,7 +42786,6 @@ var DEFAULT_FPS = 60;
44285
42786
  composition.dispose();
44286
42787
  }
44287
42788
  this.root.dispose();
44288
- this.windowRoot.dispose();
44289
42789
  (_this_assetService = this.assetService) == null ? void 0 : _this_assetService.dispose();
44290
42790
  (_this__graphics = this._graphics) == null ? void 0 : _this__graphics.dispose();
44291
42791
  this.renderPasses.forEach(function(pass) {
@@ -44610,7 +43110,7 @@ registerPlugin("text", TextLoader);
44610
43110
  registerPlugin("sprite", SpriteLoader);
44611
43111
  registerPlugin("particle", ParticleLoader);
44612
43112
  registerPlugin("interact", InteractLoader);
44613
- var version$1 = "2.10.0-alpha.4";
43113
+ var version$1 = "2.10.0";
44614
43114
  logger.info("Core version: " + version$1 + ".");
44615
43115
 
44616
43116
  var _obj;
@@ -46103,7 +44603,7 @@ applyMixins(exports.ThreeTextComponent, [
46103
44603
  */ Mesh.create = function(engine, props) {
46104
44604
  return new ThreeMesh(engine, props);
46105
44605
  };
46106
- var version = "2.10.0-alpha.4";
44606
+ var version = "2.10.0";
46107
44607
  logger.info("THREEJS plugin version: " + version + ".");
46108
44608
 
46109
44609
  exports.ATLAS_SIZE = ATLAS_SIZE;
@@ -46142,8 +44642,6 @@ exports.COPY_MESH_SHADER_ID = COPY_MESH_SHADER_ID;
46142
44642
  exports.COPY_VERTEX_SHADER = COPY_VERTEX_SHADER;
46143
44643
  exports.Camera = Camera;
46144
44644
  exports.CameraVFXItemLoader = CameraVFXItemLoader;
46145
- exports.CanvasContainer = CanvasContainer;
46146
- exports.CanvasRootControl = CanvasRootControl;
46147
44645
  exports.Circle = Circle$1;
46148
44646
  exports.ColorCurve = ColorCurve;
46149
44647
  exports.ColorPlayable = ColorPlayable;
@@ -46156,8 +44654,6 @@ exports.Composition = Composition;
46156
44654
  exports.ConstBoolNode = ConstBoolNode;
46157
44655
  exports.ConstFloatNode = ConstFloatNode;
46158
44656
  exports.ConstraintTarget = ConstraintTarget;
46159
- exports.ContainerControl = ContainerControl;
46160
- exports.Control = Control;
46161
44657
  exports.ControlParameterBoolNode = ControlParameterBoolNode;
46162
44658
  exports.ControlParameterFloatNode = ControlParameterFloatNode;
46163
44659
  exports.ControlParameterTriggerNode = ControlParameterTriggerNode;
@@ -46264,7 +44760,6 @@ exports.RenderTargetPool = RenderTargetPool;
46264
44760
  exports.Renderbuffer = Renderbuffer;
46265
44761
  exports.Renderer = Renderer;
46266
44762
  exports.RendererComponent = RendererComponent;
46267
- exports.RootControl = RootControl;
46268
44763
  exports.RuntimeClip = RuntimeClip;
46269
44764
  exports.SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0 = SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0;
46270
44765
  exports.SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0 = SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0;
@@ -46308,8 +44803,6 @@ exports.TransformPlayable = TransformPlayable;
46308
44803
  exports.TransitionNode = TransitionNode;
46309
44804
  exports.Triangle = Triangle;
46310
44805
  exports.TrimPath = TrimPath;
46311
- exports.UICanvas = UICanvas;
46312
- exports.UIControl = UIControl;
46313
44806
  exports.ValueGetter = ValueGetter;
46314
44807
  exports.ValueNode = ValueNode;
46315
44808
  exports.Vector2Curve = Vector2Curve;
@@ -46319,7 +44812,6 @@ exports.Vector3PropertyMixerPlayable = Vector3PropertyMixerPlayable;
46319
44812
  exports.Vector4Curve = Vector4Curve;
46320
44813
  exports.Vector4PropertyMixerPlayable = Vector4PropertyMixerPlayable;
46321
44814
  exports.VertexBuffer = VertexBuffer;
46322
- exports.WindowRootControl = WindowRootControl;
46323
44815
  exports.addByOrder = addByOrder;
46324
44816
  exports.addItem = addItem;
46325
44817
  exports.addItemWithOrder = addItemWithOrder;