@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.mjs CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: Galacean Effects runtime threejs plugin for the web
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
6
- * Version: v2.10.0-alpha.4
6
+ * Version: v2.10.0
7
7
  */
8
8
 
9
9
  import * as THREE from 'three';
@@ -2235,10 +2235,10 @@ var Color = /*#__PURE__*/ function() {
2235
2235
  };
2236
2236
  _proto.toHexString = function toHexString(includeAlpha) {
2237
2237
  if (includeAlpha === void 0) includeAlpha = true;
2238
- var R = Color.ToHex(Math.round(this.r * 255));
2239
- var G = Color.ToHex(Math.round(this.g * 255));
2240
- var B = Color.ToHex(Math.round(this.b * 255));
2241
- var A = Color.ToHex(Math.round(this.a * 255));
2238
+ var R = Color.ToHex(Math.round(Math.min(Math.max(this.r, 0), 1) * 255));
2239
+ var G = Color.ToHex(Math.round(Math.min(Math.max(this.g, 0), 1) * 255));
2240
+ var B = Color.ToHex(Math.round(Math.min(Math.max(this.b, 0), 1) * 255));
2241
+ var A = Color.ToHex(Math.round(Math.min(Math.max(this.a, 0), 1) * 255));
2242
2242
  if (includeAlpha) {
2243
2243
  return "#" + R + G + B + A;
2244
2244
  } else {
@@ -2284,30 +2284,14 @@ var Color = /*#__PURE__*/ function() {
2284
2284
  * @param v - Gamma 空间颜色值
2285
2285
  * @returns 线性空间颜色值
2286
2286
  */ Color.gammaToLinear = function gammaToLinear(v) {
2287
- if (v <= 0.0) {
2288
- return 0.0;
2289
- } else if (v <= 0.04045) {
2290
- return v / 12.92;
2291
- } else if (v < 1.0) {
2292
- return Math.pow((v + 0.055) / 1.055, 2.4);
2293
- } else {
2294
- return Math.pow(v, 2.4);
2295
- }
2287
+ return v < 0.04045 ? v * 0.0773993808 : Math.pow(v * 0.9478672986 + 0.0521327014, 2.4);
2296
2288
  };
2297
2289
  /**
2298
2290
  * 颜色值从线性空间转到 Gamma 空间
2299
2291
  * @param value - 线性空间颜色值
2300
2292
  * @returns Gamma 空间颜色值
2301
2293
  */ Color.linearToGamma = function linearToGamma(value) {
2302
- if (value <= 0.0) {
2303
- return 0.0;
2304
- } else if (value < 0.0031308) {
2305
- return 12.92 * value;
2306
- } else if (value < 1.0) {
2307
- return 1.055 * Math.pow(value, 0.41666) - 0.055;
2308
- } else {
2309
- return Math.pow(value, 0.41666);
2310
- }
2294
+ return value < 0.0031308 ? value * 12.92 : 1.055 * Math.pow(value, 0.41666) - 0.055;
2311
2295
  };
2312
2296
  Color.ToHex = function ToHex(i) {
2313
2297
  var str = i.toString(16);
@@ -2934,6 +2918,11 @@ var PluginSystem = /*#__PURE__*/ function() {
2934
2918
  PluginSystem.getPlugins = function getPlugins() {
2935
2919
  return plugins;
2936
2920
  };
2921
+ PluginSystem.notifyCompositionCreating = function notifyCompositionCreating(composition, scene) {
2922
+ plugins.forEach(function(plugin) {
2923
+ return plugin.onCompositionCreating(composition, scene);
2924
+ });
2925
+ };
2937
2926
  PluginSystem.notifyCompositionCreated = function notifyCompositionCreated(composition, scene) {
2938
2927
  plugins.forEach(function(plugin) {
2939
2928
  return plugin.onCompositionCreated(composition, scene);
@@ -3026,6 +3015,12 @@ function getPluginUsageInfo(name) {
3026
3015
  * @param engine - 引擎实例
3027
3016
  */ _proto.onAssetsLoadFinish = function onAssetsLoadFinish(scene, options, engine) {};
3028
3017
  /**
3018
+ * 合成内容开始创建前触发。
3019
+ * 此时 root、pluginRoot 和 sceneRoot 已创建,但场景内容尚未实例化。
3020
+ * @param composition - 正在创建的合成对象
3021
+ * @param scene - 场景对象
3022
+ */ _proto.onCompositionCreating = function onCompositionCreating(composition, scene) {};
3023
+ /**
3029
3024
  * 合成创建完成后触发。
3030
3025
  * @param composition - 合成对象
3031
3026
  * @param scene - 场景对象
@@ -3094,7 +3089,8 @@ function _inherits(subClass, superClass) {
3094
3089
  JSONSceneVersion["3_5"] = "3.5";
3095
3090
  JSONSceneVersion["3_6"] = "3.6";
3096
3091
  JSONSceneVersion["3_7"] = "3.7";
3097
- JSONSceneVersion["LATEST"] = "3.7";
3092
+ JSONSceneVersion["3_8"] = "3.8";
3093
+ JSONSceneVersion["LATEST"] = "3.8";
3098
3094
  })(JSONSceneVersion || (JSONSceneVersion = {}));
3099
3095
 
3100
3096
  /*********************************************/ /* 元素属性参数类型 */ /*********************************************/ /**
@@ -3490,6 +3486,9 @@ var CameraClipMode;
3490
3486
  /**
3491
3487
  * Vector3 曲线
3492
3488
  */ ValueType[ValueType["VECTOR3_CURVE"] = 27] = "VECTOR3_CURVE";
3489
+ /**
3490
+ * 对象引用阶梯曲线(不插值)
3491
+ */ ValueType[ValueType["REFERENCE_CURVE"] = 28] = "REFERENCE_CURVE";
3493
3492
  })(ValueType || (ValueType = {}));
3494
3493
  /**
3495
3494
  * 关键帧类型
@@ -3733,6 +3732,15 @@ var BuiltinObjectGUID = {
3733
3732
  UnlitShader: "unlit000000000000000000000000000"
3734
3733
  };
3735
3734
 
3735
+ /**
3736
+ * Sprite UV 旋转方式。序列化为整数(兼容老 splits 的 flip 0/1)。
3737
+ * None 不旋转、Rotate90 将 UV 顺时针旋转 90°(width/height 互换)。
3738
+ */ var SpriteRotation$1;
3739
+ (function(SpriteRotation) {
3740
+ /** 不旋转 */ SpriteRotation[SpriteRotation["None"] = 0] = "None";
3741
+ /** UV 旋转 90°(对应老 splits flip=1) */ SpriteRotation[SpriteRotation["Rotate90"] = 1] = "Rotate90";
3742
+ })(SpriteRotation$1 || (SpriteRotation$1 = {}));
3743
+
3736
3744
  var FillType;
3737
3745
  (function(FillType) {
3738
3746
  FillType[FillType["Solid"] = 0] = "Solid";
@@ -3844,6 +3852,7 @@ var DataType;
3844
3852
  DataType["Image"] = "Image";
3845
3853
  DataType["AnimationClip"] = "AnimationClip";
3846
3854
  DataType["BinaryAsset"] = "BinaryAsset";
3855
+ DataType["Sprite"] = "Sprite";
3847
3856
  // Timeline
3848
3857
  DataType["TrackAsset"] = "TrackAsset";
3849
3858
  DataType["TimelineAsset"] = "TimelineAsset";
@@ -3857,6 +3866,7 @@ var DataType;
3857
3866
  DataType["Vector2PropertyTrack"] = "Vector2PropertyTrack";
3858
3867
  DataType["Vector3PropertyTrack"] = "Vector3PropertyTrack";
3859
3868
  DataType["Vector4PropertyTrack"] = "Vector4PropertyTrack";
3869
+ DataType["SpritePropertyTrack"] = "SpritePropertyTrack";
3860
3870
  DataType["TransformPlayableAsset"] = "TransformPlayableAsset";
3861
3871
  DataType["SpriteColorPlayableAsset"] = "SpriteColorPlayableAsset";
3862
3872
  DataType["ActivationPlayableAsset"] = "ActivationPlayableAsset";
@@ -3866,6 +3876,7 @@ var DataType;
3866
3876
  DataType["Vector2PropertyPlayableAsset"] = "Vector2PropertyPlayableAsset";
3867
3877
  DataType["Vector3PropertyPlayableAsset"] = "Vector3PropertyPlayableAsset";
3868
3878
  DataType["Vector4PropertyPlayableAsset"] = "Vector4PropertyPlayableAsset";
3879
+ DataType["SpritePropertyPlayableAsset"] = "SpritePropertyPlayableAsset";
3869
3880
  // Components
3870
3881
  DataType["MeshComponent"] = "MeshComponent";
3871
3882
  DataType["SkyboxComponent"] = "SkyboxComponent";
@@ -3892,6 +3903,42 @@ var DataType;
3892
3903
  DataType["FFDComponent"] = "FFDComponent";
3893
3904
  DataType["FrameComponent"] = "FrameComponent";
3894
3905
  DataType["Animator"] = "Animator";
3906
+ DataType["DomContentComponent"] = "DomContentComponent";
3907
+ DataType["UIControl"] = "UIControl";
3908
+ // GUI Controls
3909
+ DataType["Control"] = "Control";
3910
+ DataType["Container"] = "Container";
3911
+ DataType["HBoxContainer"] = "HBoxContainer";
3912
+ DataType["VBoxContainer"] = "VBoxContainer";
3913
+ DataType["GridContainer"] = "GridContainer";
3914
+ DataType["PanelContainer"] = "PanelContainer";
3915
+ DataType["MarginContainer"] = "MarginContainer";
3916
+ DataType["CenterContainer"] = "CenterContainer";
3917
+ DataType["AspectRatioContainer"] = "AspectRatioContainer";
3918
+ DataType["ScrollContainer"] = "ScrollContainer";
3919
+ DataType["HScrollBar"] = "HScrollBar";
3920
+ DataType["VScrollBar"] = "VScrollBar";
3921
+ DataType["HSeparator"] = "HSeparator";
3922
+ DataType["VSeparator"] = "VSeparator";
3923
+ DataType["Label"] = "Label";
3924
+ DataType["LineEdit"] = "LineEdit";
3925
+ DataType["TextEdit"] = "TextEdit";
3926
+ DataType["PopupPanel"] = "PopupPanel";
3927
+ DataType["PopupMenu"] = "PopupMenu";
3928
+ DataType["MenuButton"] = "MenuButton";
3929
+ DataType["OptionButton"] = "OptionButton";
3930
+ DataType["ColorPicker"] = "ColorPicker";
3931
+ DataType["ColorPickerButton"] = "ColorPickerButton";
3932
+ DataType["TextureRect"] = "TextureRect";
3933
+ DataType["NinePatchRect"] = "NinePatchRect";
3934
+ DataType["ColorRect"] = "ColorRect";
3935
+ DataType["Panel"] = "Panel";
3936
+ DataType["ProgressBar"] = "ProgressBar";
3937
+ DataType["Button"] = "Button";
3938
+ DataType["Checkbox"] = "Checkbox";
3939
+ DataType["CheckButton"] = "CheckButton";
3940
+ DataType["HSlider"] = "HSlider";
3941
+ DataType["VSlider"] = "VSlider";
3895
3942
  // Non-EffectObject
3896
3943
  DataType["TimelineClip"] = "TimelineClip";
3897
3944
  })(DataType || (DataType = {}));
@@ -4030,6 +4077,7 @@ var index$1 = /*#__PURE__*/Object.freeze({
4030
4077
  get TextWeight () { return TextWeight; },
4031
4078
  get FontStyle () { return FontStyle; },
4032
4079
  BuiltinObjectGUID: BuiltinObjectGUID,
4080
+ get SpriteRotation () { return SpriteRotation$1; },
4033
4081
  get FillType () { return FillType; },
4034
4082
  get TexturePaintScaleMode () { return TexturePaintScaleMode$1; },
4035
4083
  get ShapePrimitiveType () { return ShapePrimitiveType; },
@@ -9206,7 +9254,7 @@ function isUniformStructArray(value) {
9206
9254
  return v.set(this.elements[i * 4], this.elements[i * 4 + 1], this.elements[i * 4 + 2], this.elements[i * 4 + 3]);
9207
9255
  };
9208
9256
  /**
9209
- * 设置相机矩阵
9257
+ * 设置矩阵的朝向旋转部分
9210
9258
  * @param eye - 相机位置
9211
9259
  * @param target - 目标位置
9212
9260
  * @param up - 相机方向
@@ -9216,27 +9264,32 @@ function isUniformStructArray(value) {
9216
9264
  var vY = Matrix4.tempVec1;
9217
9265
  var vZ = Matrix4.tempVec2;
9218
9266
  vZ.subtractVectors(eye, target);
9267
+ if (vZ.lengthSquared() === 0) {
9268
+ vZ.z = 1;
9269
+ }
9219
9270
  vZ.normalize();
9220
9271
  vX.crossVectors(up, vZ);
9272
+ if (vX.lengthSquared() === 0) {
9273
+ if (Math.abs(up.z) === 1) {
9274
+ vZ.x += 0.0001;
9275
+ } else {
9276
+ vZ.z += 0.0001;
9277
+ }
9278
+ vZ.normalize();
9279
+ vX.crossVectors(up, vZ);
9280
+ }
9221
9281
  vX.normalize();
9222
9282
  vY.crossVectors(vZ, vX);
9223
9283
  var te = this.elements;
9224
9284
  te[0] = vX.x;
9225
- te[1] = vY.x;
9226
- te[2] = vZ.x;
9227
- te[3] = 0;
9228
- te[4] = vX.y;
9285
+ te[4] = vY.x;
9286
+ te[8] = vZ.x;
9287
+ te[1] = vX.y;
9229
9288
  te[5] = vY.y;
9230
- te[6] = vZ.y;
9231
- te[7] = 0;
9232
- te[8] = vX.z;
9233
- te[9] = vY.z;
9289
+ te[9] = vZ.y;
9290
+ te[2] = vX.z;
9291
+ te[6] = vY.z;
9234
9292
  te[10] = vZ.z;
9235
- te[11] = 0;
9236
- te[12] = -vX.dot(eye);
9237
- te[13] = -vY.dot(eye);
9238
- te[14] = -vZ.dot(eye);
9239
- te[15] = 1;
9240
9293
  return this;
9241
9294
  };
9242
9295
  /**
@@ -9462,6 +9515,7 @@ function isUniformStructArray(value) {
9462
9515
  te[12] = l * te[0] + m * te[4] + n * te[8] - l + translation.x;
9463
9516
  te[13] = l * te[1] + m * te[5] + n * te[9] - m + translation.y;
9464
9517
  te[14] = l * te[2] + m * te[6] + n * te[10] - n + translation.z;
9518
+ te[15] = 1;
9465
9519
  return this;
9466
9520
  };
9467
9521
  /**
@@ -9753,7 +9807,7 @@ function isUniformStructArray(value) {
9753
9807
  return new Matrix4(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
9754
9808
  };
9755
9809
  /**
9756
- * 创建相机矩阵
9810
+ * 创建朝向旋转矩阵
9757
9811
  * @param eye - 相机位置
9758
9812
  * @param target - 目标位置
9759
9813
  * @param up - 相机方向
@@ -10968,6 +11022,9 @@ Euler.tempMat0 = new Matrix4();
10968
11022
  * @param [out] - 交点
10969
11023
  * @returns
10970
11024
  */ _proto.intersectSphere = function intersectSphere(sphere, out) {
11025
+ if (sphere.radius < 0) {
11026
+ return;
11027
+ }
10971
11028
  var center = sphere.center;
10972
11029
  var vector = Ray.tempVec0.subtractVectors(center, this.origin);
10973
11030
  var tca = vector.dot(this.direction);
@@ -11294,7 +11351,7 @@ Ray.tempVec3 = new Vector3();
11294
11351
  * @returns
11295
11352
  */ _proto.intersectsSphere = function intersectsSphere(sphere) {
11296
11353
  // Find the point on the AABB closest to the sphere center.
11297
- var vector = new Vector3();
11354
+ var vector = Box3.tempVec0;
11298
11355
  this.clampPoint(sphere.center, vector);
11299
11356
  // If that point is inside the sphere, the AABB and sphere intersect.
11300
11357
  return vector.distanceSquared(sphere.center) <= sphere.radius * sphere.radius;
@@ -11380,9 +11437,11 @@ Ray.tempVec3 = new Vector3();
11380
11437
  * @param target
11381
11438
  * @returns
11382
11439
  */ _proto.getBoundingSphere = function getBoundingSphere(target) {
11440
+ if (this.isEmpty()) {
11441
+ return target.makeEmpty();
11442
+ }
11383
11443
  this.getCenter(target.center);
11384
- var vector = new Vector3();
11385
- target.radius = this.getSize(vector).length() * 0.5;
11444
+ target.radius = this.getSize(Box3.tempVec0).length() * 0.5;
11386
11445
  return target;
11387
11446
  };
11388
11447
  /**
@@ -11403,6 +11462,7 @@ Ray.tempVec3 = new Vector3();
11403
11462
  };
11404
11463
  return Box3;
11405
11464
  }();
11465
+ Box3.tempVec0 = new Vector3();
11406
11466
 
11407
11467
  /**
11408
11468
  * 球
@@ -11433,16 +11493,15 @@ Ray.tempVec3 = new Vector3();
11433
11493
  var center = this.center;
11434
11494
  if (optionalCenter !== undefined) {
11435
11495
  center.copyFrom(optionalCenter);
11436
- var maxRadiusSq = 0;
11437
- for(var i = 0; i < points.length; i++){
11438
- maxRadiusSq = Math.max(maxRadiusSq, center.distanceSquared(points[i]));
11439
- }
11440
- this.radius = Math.sqrt(maxRadiusSq);
11441
11496
  } else {
11442
- var box = new Box3().setFromPoints(points);
11497
+ var box = Sphere.tempBox.setFromPoints(points);
11443
11498
  box.getCenter(center);
11444
- this.radius = box.getSize().length() / 2;
11445
11499
  }
11500
+ var maxRadiusSq = 0;
11501
+ for(var i = 0; i < points.length; i++){
11502
+ maxRadiusSq = Math.max(maxRadiusSq, center.distanceSquared(points[i]));
11503
+ }
11504
+ this.radius = Math.sqrt(maxRadiusSq);
11446
11505
  return this;
11447
11506
  };
11448
11507
  /**
@@ -11559,7 +11618,10 @@ Ray.tempVec3 = new Vector3();
11559
11618
  * @param point - 扩展点
11560
11619
  * @returns 扩展结果
11561
11620
  */ _proto.expandByPoint = function expandByPoint(point) {
11562
- var vector = new Vector3().subtractVectors(point, this.center);
11621
+ if (this.isEmpty()) {
11622
+ return this.set(point, 0);
11623
+ }
11624
+ var vector = Sphere.tempVec0.subtractVectors(point, this.center);
11563
11625
  var lengthSquared = vector.lengthSquared();
11564
11626
  if (lengthSquared > this.radius * this.radius) {
11565
11627
  var length = Math.sqrt(lengthSquared);
@@ -11577,30 +11639,42 @@ Ray.tempVec3 = new Vector3();
11577
11639
  * @param sphere - 包围球
11578
11640
  * @returns 求并结果
11579
11641
  */ _proto.union = function union(sphere) {
11580
- // To enclose another sphere into this sphere, we only need to enclose two points:
11581
- // 1) Enclose the farthest point on the other sphere into this sphere.
11582
- // 2) Enclose the opposite point of the farthest point into this sphere.
11583
- var v1 = new Vector3();
11584
- var toFarthestPoint = new Vector3();
11585
- toFarthestPoint.subtractVectors(sphere.center, this.center).normalize().multiply(sphere.radius);
11586
- this.expandByPoint(v1.copyFrom(sphere.center).add(toFarthestPoint));
11587
- this.expandByPoint(v1.copyFrom(sphere.center).subtract(toFarthestPoint));
11642
+ if (sphere.isEmpty()) {
11643
+ return this;
11644
+ }
11645
+ if (this.isEmpty()) {
11646
+ return this.copyFrom(sphere);
11647
+ }
11648
+ if (this.center.equals(sphere.center)) {
11649
+ this.radius = Math.max(this.radius, sphere.radius);
11650
+ } else {
11651
+ var point = Sphere.tempVec0;
11652
+ var offset = Sphere.tempVec1.subtractVectors(sphere.center, this.center).setLength(sphere.radius);
11653
+ this.expandByPoint(point.copyFrom(sphere.center).add(offset));
11654
+ this.expandByPoint(point.copyFrom(sphere.center).subtract(offset));
11655
+ }
11588
11656
  return this;
11589
11657
  };
11590
11658
  /**
11591
- * 包围球求交集
11659
+ * 获取两个包围球交集的保守包围球。部分重叠时,真实交集为透镜形,
11660
+ * 因此结果取两个输入中较小的包围球,并不精确表示交集。
11592
11661
  * @param other - 其它包围球
11593
11662
  * @returns 求交结果
11594
11663
  */ _proto.intersect = function intersect(other) {
11595
- var vector = new Vector3().subtractVectors(this.center, other.center);
11596
- var distance = vector.length();
11597
- var radiusSum = this.radius + other.radius;
11598
- if (distance > radiusSum) {
11664
+ if (this.isEmpty() || other.isEmpty()) {
11599
11665
  return this.makeEmpty();
11600
11666
  }
11601
- this.center = this.center.add(vector.normalize().multiply(distance / 2));
11602
- this.radius = this.radius + other.radius - distance;
11603
- return this;
11667
+ var distance = this.center.distance(other.center);
11668
+ if (distance > this.radius + other.radius) {
11669
+ return this.makeEmpty();
11670
+ }
11671
+ if (this.radius >= distance + other.radius) {
11672
+ return this.copyFrom(other);
11673
+ }
11674
+ if (other.radius >= distance + this.radius) {
11675
+ return this;
11676
+ }
11677
+ return this.radius <= other.radius ? this : this.copyFrom(other);
11604
11678
  };
11605
11679
  /**
11606
11680
  * 包围球判等
@@ -11617,6 +11691,9 @@ Ray.tempVec3 = new Vector3();
11617
11691
  };
11618
11692
  return Sphere;
11619
11693
  }();
11694
+ Sphere$1.tempBox = new Box3();
11695
+ Sphere$1.tempVec0 = new Vector3();
11696
+ Sphere$1.tempVec1 = new Vector3();
11620
11697
 
11621
11698
  var index = /*#__PURE__*/Object.freeze({
11622
11699
  __proto__: null,
@@ -15634,35 +15711,35 @@ function vecMulCombine(out, a, b) {
15634
15711
  }
15635
15712
  return out;
15636
15713
  }
15637
- var _obj$7;
15638
- var particleOriginTranslateMap$1 = (_obj$7 = {}, _obj$7[ParticleOrigin.PARTICLE_ORIGIN_CENTER] = [
15714
+ var _obj$6;
15715
+ var particleOriginTranslateMap$1 = (_obj$6 = {}, _obj$6[ParticleOrigin.PARTICLE_ORIGIN_CENTER] = [
15639
15716
  0,
15640
15717
  0
15641
- ], _obj$7[ParticleOrigin.PARTICLE_ORIGIN_CENTER_BOTTOM] = [
15718
+ ], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_CENTER_BOTTOM] = [
15642
15719
  0,
15643
15720
  -0.5
15644
- ], _obj$7[ParticleOrigin.PARTICLE_ORIGIN_CENTER_TOP] = [
15721
+ ], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_CENTER_TOP] = [
15645
15722
  0,
15646
15723
  0.5
15647
- ], _obj$7[ParticleOrigin.PARTICLE_ORIGIN_LEFT_TOP] = [
15724
+ ], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_LEFT_TOP] = [
15648
15725
  -0.5,
15649
15726
  0.5
15650
- ], _obj$7[ParticleOrigin.PARTICLE_ORIGIN_LEFT_CENTER] = [
15727
+ ], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_LEFT_CENTER] = [
15651
15728
  -0.5,
15652
15729
  0
15653
- ], _obj$7[ParticleOrigin.PARTICLE_ORIGIN_LEFT_BOTTOM] = [
15730
+ ], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_LEFT_BOTTOM] = [
15654
15731
  -0.5,
15655
15732
  -0.5
15656
- ], _obj$7[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_CENTER] = [
15733
+ ], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_CENTER] = [
15657
15734
  0.5,
15658
15735
  0
15659
- ], _obj$7[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_BOTTOM] = [
15736
+ ], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_BOTTOM] = [
15660
15737
  0.5,
15661
15738
  -0.5
15662
- ], _obj$7[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_TOP] = [
15739
+ ], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_TOP] = [
15663
15740
  0.5,
15664
15741
  0.5
15665
- ], _obj$7);
15742
+ ], _obj$6);
15666
15743
  function nearestPowerOfTwo(value) {
15667
15744
  return Math.pow(2, Math.round(Math.log(value) / Math.LN2));
15668
15745
  }
@@ -17400,27 +17477,27 @@ function oldBezierKeyFramesToNew(props) {
17400
17477
  * 对象引用阶梯曲线(spec ValueType.REFERENCE_CURVE)。
17401
17478
  * props 为 [[time, value], ...],value 为已解析的对象引用实例。
17402
17479
  */ var REFERENCE_CURVE = 28;
17403
- var _obj$6;
17404
- var map$1 = (_obj$6 = {}, _obj$6[ValueType.RANDOM] = function(props) {
17480
+ var _obj$5;
17481
+ var map$1 = (_obj$5 = {}, _obj$5[ValueType.RANDOM] = function(props) {
17405
17482
  if (_instanceof1(props[0], Array)) {
17406
17483
  return new RandomVectorValue(props);
17407
17484
  }
17408
17485
  return new RandomValue(props);
17409
- }, _obj$6[ValueType.CONSTANT] = function(props) {
17486
+ }, _obj$5[ValueType.CONSTANT] = function(props) {
17410
17487
  return new StaticValue(props);
17411
- }, _obj$6[ValueType.CONSTANT_VEC2] = function(props) {
17488
+ }, _obj$5[ValueType.CONSTANT_VEC2] = function(props) {
17412
17489
  return new StaticValue(props);
17413
- }, _obj$6[ValueType.CONSTANT_VEC3] = function(props) {
17490
+ }, _obj$5[ValueType.CONSTANT_VEC3] = function(props) {
17414
17491
  return new StaticValue(props);
17415
- }, _obj$6[ValueType.CONSTANT_VEC4] = function(props) {
17492
+ }, _obj$5[ValueType.CONSTANT_VEC4] = function(props) {
17416
17493
  return new StaticValue(props);
17417
- }, _obj$6[ValueType.RGBA_COLOR] = function(props) {
17494
+ }, _obj$5[ValueType.RGBA_COLOR] = function(props) {
17418
17495
  return new StaticValue(props);
17419
- }, _obj$6[ValueType.COLORS] = function(props) {
17496
+ }, _obj$5[ValueType.COLORS] = function(props) {
17420
17497
  return new RandomSetValue(props.map(function(c) {
17421
17498
  return colorToArr$1(c, false);
17422
17499
  }));
17423
- }, _obj$6[ValueType.LINE] = function(props) {
17500
+ }, _obj$5[ValueType.LINE] = function(props) {
17424
17501
  if (props.length === 2 && props[0][0] === 0 && props[1][0] === 1) {
17425
17502
  return new LinearValue([
17426
17503
  props[0][1],
@@ -17428,38 +17505,38 @@ var map$1 = (_obj$6 = {}, _obj$6[ValueType.RANDOM] = function(props) {
17428
17505
  ]);
17429
17506
  }
17430
17507
  return new LineSegments(props);
17431
- }, _obj$6[ValueType.GRADIENT_COLOR] = function(props) {
17508
+ }, _obj$5[ValueType.GRADIENT_COLOR] = function(props) {
17432
17509
  return new GradientValue(props);
17433
- }, _obj$6[ValueType.LINEAR_PATH] = function(pros) {
17510
+ }, _obj$5[ValueType.LINEAR_PATH] = function(pros) {
17434
17511
  return new PathSegments(pros);
17435
- }, _obj$6[ValueType.BEZIER_CURVE] = function(props) {
17512
+ }, _obj$5[ValueType.BEZIER_CURVE] = function(props) {
17436
17513
  if (props.length === 1) {
17437
17514
  return new StaticValue(props[0][1][1]);
17438
17515
  }
17439
17516
  return new BezierCurve(props);
17440
- }, _obj$6[ValueType.BEZIER_CURVE_PATH] = function(props) {
17517
+ }, _obj$5[ValueType.BEZIER_CURVE_PATH] = function(props) {
17441
17518
  if (props[0].length === 1) {
17442
17519
  return new StaticValue(_construct(Vector3, [].concat(props[1][0])));
17443
17520
  }
17444
17521
  return new BezierCurvePath(props);
17445
- }, _obj$6[ValueType.BEZIER_CURVE_QUAT] = function(props) {
17522
+ }, _obj$5[ValueType.BEZIER_CURVE_QUAT] = function(props) {
17446
17523
  if (props[0].length === 1) {
17447
17524
  return new StaticValue(_construct(Quaternion, [].concat(props[1][0])));
17448
17525
  }
17449
17526
  return new BezierCurveQuat(props);
17450
- }, _obj$6[ValueType.COLOR_CURVE] = function(props) {
17527
+ }, _obj$5[ValueType.COLOR_CURVE] = function(props) {
17451
17528
  return new ColorCurve(props);
17452
- }, _obj$6[ValueType.VECTOR4_CURVE] = function(props) {
17529
+ }, _obj$5[ValueType.VECTOR4_CURVE] = function(props) {
17453
17530
  return new Vector4Curve(props);
17454
- }, _obj$6[ValueType.VECTOR2_CURVE] = function(props) {
17531
+ }, _obj$5[ValueType.VECTOR2_CURVE] = function(props) {
17455
17532
  return new Vector2Curve(props);
17456
17533
  }, // TODO: add spec
17457
- _obj$6[VECTOR3_CURVE] = function(props) {
17534
+ _obj$5[VECTOR3_CURVE] = function(props) {
17458
17535
  return new Vector3Curve(props);
17459
17536
  }, // 对象引用阶梯曲线(不插值):props.data 为 [time, value][],value 已解析为 EffectsObject
17460
- _obj$6[REFERENCE_CURVE] = function(props) {
17537
+ _obj$5[REFERENCE_CURVE] = function(props) {
17461
17538
  return new ReferenceCurve(props);
17462
- }, _obj$6);
17539
+ }, _obj$5);
17463
17540
  function createValueGetter(args) {
17464
17541
  if (!args || !isNaN(+args)) {
17465
17542
  return new StaticValue(args || 0);
@@ -21400,8 +21477,8 @@ var vertexBufferSemanticMap = {
21400
21477
  TANGENT_BS2: "aTargetTangent2",
21401
21478
  TANGENT_BS3: "aTargetTangent3"
21402
21479
  };
21403
- var _obj$5;
21404
- var BYTES_TYPE_MAP = (_obj$5 = {}, _obj$5[BufferDataType.Float] = 4, _obj$5[BufferDataType.Int] = 4, _obj$5[BufferDataType.UnsignedInt] = 4, _obj$5[BufferDataType.Short] = 2, _obj$5[BufferDataType.UnsignedShort] = 2, _obj$5[BufferDataType.Byte] = 1, _obj$5[BufferDataType.UnsignedByte] = 1, _obj$5);
21480
+ var _obj$4;
21481
+ var BYTES_TYPE_MAP = (_obj$4 = {}, _obj$4[BufferDataType.Float] = 4, _obj$4[BufferDataType.Int] = 4, _obj$4[BufferDataType.UnsignedInt] = 4, _obj$4[BufferDataType.Short] = 2, _obj$4[BufferDataType.UnsignedShort] = 2, _obj$4[BufferDataType.Byte] = 1, _obj$4[BufferDataType.UnsignedByte] = 1, _obj$4);
21405
21482
  function generateEmptyTypedArray(type) {
21406
21483
  return createTypedArray(type, 0);
21407
21484
  }
@@ -22820,7 +22897,7 @@ var canvasPool = new CanvasPool();
22820
22897
  ctx.textBaseline = "alphabetic";
22821
22898
  ctx.fillStyle = "#ffffff";
22822
22899
  this.paddingPx = GLYPH_PADDING * resolution;
22823
- this.italicScale = fontStyle === "italic" ? 2 : 1;
22900
+ this.italicScale = fontStyle === "italic" || fontStyle === "oblique" ? 2 : 1;
22824
22901
  // ascent/descent 由探针 '|ÉqÅM' 测得 actualBoundingBox(重音字已抬高 ink 顶),
22825
22902
  // 两者内部保持浮点,仅 cell 高做一次外层 ceil — 与 padding 共同保证 cell 内不裁切
22826
22903
  var fontHeightPx = ascentPx + descentPx;
@@ -22918,7 +22995,7 @@ var canvasPool = new CanvasPool();
22918
22995
  * `ATLAS_SIZE × ATLAS_SIZE` 的离屏 canvas atlas,字符按需逐个绘制并打包,
22919
22996
  * `Graphics.drawText` 通过逐字 quad 引用 atlas 子矩形渲染。
22920
22997
  *
22921
- * - 同一段文本不同颜色不会重复 upload(颜色由顶点 `vColor` 乘上字形 alpha)
22998
+ * - 同一段文本不同颜色不会重复 upload(颜色由顶点 `vColor` 与字形 RGBA 相乘)
22922
22999
  * - 同一字体/字号下重复字符只渲染一次,显著减少 canvas → texture 上传次数
22923
23000
  *
22924
23001
  * 入参全部展开(避免调用方每帧创建临时 style 对象触发 GC)
@@ -22932,7 +23009,7 @@ var canvasPool = new CanvasPool();
22932
23009
  /**
22933
23010
  * 取(必要时新建)对应字体的字符 atlas
22934
23011
  */ _proto.getAtlas = function getAtlas(fontSize, fontFamily, fontWeight, fontStyle) {
22935
- // Pixi CanvasText 默认跟随 renderer.resolution;这里对应 Engine.pixelRatio。
23012
+ // 字形 atlas 跟随 Engine.pixelRatio。
22936
23013
  var resolution = this.engine.pixelRatio;
22937
23014
  if (resolution !== this.resolution) {
22938
23015
  this.clear();
@@ -22953,14 +23030,11 @@ var canvasPool = new CanvasPool();
22953
23030
  var probeCtx = probeCanvasAndContext.context;
22954
23031
  var ascentPx = fontSize * 0.8 * resolution;
22955
23032
  var descentPx = fontSize * 0.2 * resolution;
22956
- try {
22957
- probeCtx.font = scaledFontString;
22958
- var m = probeCtx.measureText(METRICS_STRING + BASELINE_SYMBOL);
22959
- ascentPx = m.actualBoundingBoxAscent || ascentPx;
22960
- descentPx = m.actualBoundingBoxDescent || descentPx;
22961
- } finally{
22962
- canvasPool.releaseCanvasAndContext(probeCanvasAndContext);
22963
- }
23033
+ probeCtx.font = scaledFontString;
23034
+ var m = probeCtx.measureText(METRICS_STRING + BASELINE_SYMBOL);
23035
+ ascentPx = m.actualBoundingBoxAscent || ascentPx;
23036
+ descentPx = m.actualBoundingBoxDescent || descentPx;
23037
+ canvasPool.releaseCanvasAndContext(probeCanvasAndContext);
22964
23038
  var atlas = new GlyphAtlas(this.engine, scaledFontString, ascentPx, descentPx, fontStyle, resolution);
22965
23039
  this.atlases.set(fontKey, atlas);
22966
23040
  return atlas;
@@ -22996,6 +23070,10 @@ var FULL_REGION = {
22996
23070
  u1: 1,
22997
23071
  v1: 1
22998
23072
  };
23073
+ var NINE_PATCH_DRAW_SOURCE_SIZE = "aDrawSourceSize";
23074
+ var NINE_PATCH_SOURCE_RECT = "aSourceRect";
23075
+ var NINE_PATCH_MARGINS = "aMargins";
23076
+ var NINE_PATCH_OPTIONS = "aOptions";
22999
23077
  var Graphics = /*#__PURE__*/ function() {
23000
23078
  function Graphics(engine) {
23001
23079
  this.engine = engine;
@@ -23009,6 +23087,10 @@ var Graphics = /*#__PURE__*/ function() {
23009
23087
  this.colors = [];
23010
23088
  this.uvs = [];
23011
23089
  this.indices = [];
23090
+ this.ninePatchDrawSourceSizes = [];
23091
+ this.ninePatchSourceRects = [];
23092
+ this.ninePatchMargins = [];
23093
+ this.ninePatchOptions = [];
23012
23094
  this.lineStyle = {
23013
23095
  width: 1,
23014
23096
  alignment: 0.5,
@@ -23020,6 +23102,9 @@ var Graphics = /*#__PURE__*/ function() {
23020
23102
  this.currentBatchTexture = null;
23021
23103
  this.transformStack = [];
23022
23104
  this.currentTransform = Matrix3.fromIdentity();
23105
+ this.clipStack = [];
23106
+ this.logicalWidth = 1;
23107
+ this.logicalHeight = 1;
23023
23108
  var _obj;
23024
23109
  this.geometry = Geometry.create(this.engine, {
23025
23110
  attributes: (_obj = {}, _obj[VertexBuffer.PositionKind] = {
@@ -23085,6 +23170,51 @@ var Graphics = /*#__PURE__*/ function() {
23085
23170
  drawCount: 6,
23086
23171
  bufferUsage: glContext.DYNAMIC_DRAW
23087
23172
  });
23173
+ var _obj1;
23174
+ this.ninePatchGeometry = Geometry.create(this.engine, {
23175
+ attributes: (_obj1 = {}, _obj1[VertexBuffer.PositionKind] = {
23176
+ type: glContext.FLOAT,
23177
+ size: 2,
23178
+ data: new Float32Array(8)
23179
+ }, _obj1[VertexBuffer.ColorKind] = {
23180
+ type: glContext.FLOAT,
23181
+ size: 4,
23182
+ data: new Float32Array(16)
23183
+ }, _obj1[VertexBuffer.UVKind] = {
23184
+ type: glContext.FLOAT,
23185
+ size: 2,
23186
+ data: new Float32Array(8)
23187
+ }, _obj1[NINE_PATCH_DRAW_SOURCE_SIZE] = {
23188
+ type: glContext.FLOAT,
23189
+ size: 4,
23190
+ data: new Float32Array(16)
23191
+ }, _obj1[NINE_PATCH_SOURCE_RECT] = {
23192
+ type: glContext.FLOAT,
23193
+ size: 4,
23194
+ data: new Float32Array(16)
23195
+ }, _obj1[NINE_PATCH_MARGINS] = {
23196
+ type: glContext.FLOAT,
23197
+ size: 4,
23198
+ data: new Float32Array(16)
23199
+ }, _obj1[NINE_PATCH_OPTIONS] = {
23200
+ type: glContext.FLOAT,
23201
+ size: 4,
23202
+ data: new Float32Array(16)
23203
+ }, _obj1),
23204
+ indices: {
23205
+ data: new Uint16Array([
23206
+ 0,
23207
+ 1,
23208
+ 2,
23209
+ 2,
23210
+ 1,
23211
+ 3
23212
+ ])
23213
+ },
23214
+ mode: glContext.TRIANGLES,
23215
+ drawCount: 6,
23216
+ bufferUsage: glContext.DYNAMIC_DRAW
23217
+ });
23088
23218
  this.coloredMaterial = Material.create(this.engine, {
23089
23219
  shader: {
23090
23220
  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 }",
@@ -23103,12 +23233,21 @@ var Graphics = /*#__PURE__*/ function() {
23103
23233
  this.texturedMaterial.depthTest = false;
23104
23234
  this.texturedMaterial.depthMask = false;
23105
23235
  this.texturedMaterial.blending = true;
23106
- // 文本 atlas 按 Pixi 的方式在上传时预乘 alpha,因此采样后只需应用顶点色和顶点 alpha。
23236
+ this.ninePatchMaterial = Material.create(this.engine, {
23237
+ shader: {
23238
+ 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 }",
23239
+ 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 }"
23240
+ }
23241
+ });
23242
+ this.ninePatchMaterial.depthTest = false;
23243
+ this.ninePatchMaterial.depthMask = false;
23244
+ this.ninePatchMaterial.blending = true;
23245
+ // 文本 atlas 在上传时预乘 alpha,因此纹理 RGB 只需乘顶点色和顶点 alpha。
23107
23246
  // 单独使用 material,避免改变 drawTexture 对普通非预乘纹理的处理。
23108
23247
  this.textMaterial = Material.create(this.engine, {
23109
23248
  shader: {
23110
23249
  vertex: "precision highp float;\n attribute vec2 aPos;\n attribute vec4 aColor;\n attribute vec2 aUV;\n varying vec4 vColor;\n varying vec2 vUV;\n\n uniform mat4 effects_MatrixVP;\n void main() {\n vColor = aColor;\n vUV = aUV;\n gl_Position = effects_MatrixVP * vec4(aPos, 0.0, 1.0);\n }",
23111
- fragment: "precision highp float;\n varying vec4 vColor;\n varying vec2 vUV;\n uniform sampler2D uMainTexture;\n void main() {\n float alpha = texture2D(uMainTexture, vUV).a * vColor.a;\n gl_FragColor = vec4(vColor.rgb * alpha, alpha);\n }"
23250
+ 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 }"
23112
23251
  }
23113
23252
  });
23114
23253
  this.textMaterial.depthTest = false;
@@ -23124,25 +23263,36 @@ var Graphics = /*#__PURE__*/ function() {
23124
23263
  this.vertices.length = 0;
23125
23264
  this.colors.length = 0;
23126
23265
  this.uvs.length = 0;
23266
+ this.ninePatchDrawSourceSizes.length = 0;
23267
+ this.ninePatchSourceRects.length = 0;
23268
+ this.ninePatchMargins.length = 0;
23269
+ this.ninePatchOptions.length = 0;
23127
23270
  this.transformStack = [];
23128
23271
  this.currentTransform = Matrix3.fromIdentity();
23272
+ this.clipStack = [];
23129
23273
  this.currentBatchType = "colored";
23130
23274
  this.currentBatchTexture = null;
23275
+ this.engine.setScissorTest(false);
23131
23276
  // 创建从屏幕坐标到 NDC 的投影矩阵,屏幕坐标:(0, 0) 在左上角,(width, height) 在右下角,+Y 向下。
23132
- var _this_engine_canvas_getBoundingClientRect = this.engine.canvas.getBoundingClientRect(), width = _this_engine_canvas_getBoundingClientRect.width, height = _this_engine_canvas_getBoundingClientRect.height;
23277
+ var bounds = this.engine.canvas.getBoundingClientRect();
23278
+ var width = bounds.width || this.engine.canvas.width / this.engine.pixelRatio || 1;
23279
+ var height = bounds.height || this.engine.canvas.height / this.engine.pixelRatio || 1;
23280
+ this.logicalWidth = width;
23281
+ this.logicalHeight = height;
23133
23282
  // 正交投影矩阵:将屏幕坐标 [0, width] x [0, height] 映射到 NDC [-1, 1] x [-1, 1]
23134
23283
  var projectionMatrix = new Matrix4(2 / width, 0, 0, 0, 0, -2 / height, 0, 0, 0, 0, -1, 0, -1, 1, 0, 1 // 第四列
23135
23284
  );
23136
23285
  this.coloredMaterial.setMatrix("effects_MatrixVP", projectionMatrix);
23137
23286
  this.texturedMaterial.setMatrix("effects_MatrixVP", projectionMatrix);
23138
23287
  this.textMaterial.setMatrix("effects_MatrixVP", projectionMatrix);
23288
+ this.ninePatchMaterial.setMatrix("effects_MatrixVP", projectionMatrix);
23139
23289
  };
23140
23290
  /**
23141
23291
  * 将当前变换压入栈,并设置新的变换
23142
23292
  * @param transform - 新的变换矩阵(会与当前变换相乘)
23143
23293
  */ _proto.pushTransform = function pushTransform(transform) {
23144
23294
  this.transformStack.push(this.currentTransform.clone());
23145
- this.currentTransform = this.currentTransform.premultiply(transform);
23295
+ this.currentTransform = this.currentTransform.multiply(transform);
23146
23296
  };
23147
23297
  /**
23148
23298
  * 恢复上一个变换
@@ -23154,10 +23304,81 @@ var Graphics = /*#__PURE__*/ function() {
23154
23304
  }
23155
23305
  this.currentTransform = transform;
23156
23306
  };
23307
+ /** Pushes a local rectangular child clip using a screen-space AABB scissor. */ _proto.pushClipRect = function pushClipRect(x, y, width, height) {
23308
+ var elements = this.currentTransform.elements;
23309
+ var corners = [
23310
+ [
23311
+ x,
23312
+ y
23313
+ ],
23314
+ [
23315
+ x + width,
23316
+ y
23317
+ ],
23318
+ [
23319
+ x,
23320
+ y + height
23321
+ ],
23322
+ [
23323
+ x + width,
23324
+ y + height
23325
+ ]
23326
+ ];
23327
+ var left = Infinity;
23328
+ var top = Infinity;
23329
+ var right = -Infinity;
23330
+ var bottom = -Infinity;
23331
+ for(var _iterator = _create_for_of_iterator_helper_loose(corners), _step; !(_step = _iterator()).done;){
23332
+ var corner = _step.value;
23333
+ var transformedX = elements[0] * corner[0] + elements[3] * corner[1] + elements[6];
23334
+ var transformedY = elements[1] * corner[0] + elements[4] * corner[1] + elements[7];
23335
+ left = Math.min(left, transformedX);
23336
+ top = Math.min(top, transformedY);
23337
+ right = Math.max(right, transformedX);
23338
+ bottom = Math.max(bottom, transformedY);
23339
+ }
23340
+ var parent = this.clipStack[this.clipStack.length - 1];
23341
+ if (parent) {
23342
+ left = Math.max(left, parent.x);
23343
+ top = Math.max(top, parent.y);
23344
+ right = Math.min(right, parent.x + parent.width);
23345
+ bottom = Math.min(bottom, parent.y + parent.height);
23346
+ }
23347
+ var clip = {
23348
+ x: left,
23349
+ y: top,
23350
+ width: Math.max(0, right - left),
23351
+ height: Math.max(0, bottom - top)
23352
+ };
23353
+ var previous = parent;
23354
+ this.clipStack.push(clip);
23355
+ if (!this.clipRectsEqual(previous, clip)) {
23356
+ this.flushBatch();
23357
+ this.applyClipRect(clip);
23358
+ }
23359
+ };
23360
+ /** Restores the parent rectangular clip. */ _proto.popClipRect = function popClipRect() {
23361
+ var previous = this.clipStack.pop();
23362
+ if (!previous) {
23363
+ console.warn("Graphics: clip stack is empty.");
23364
+ return;
23365
+ }
23366
+ var clip = this.clipStack[this.clipStack.length - 1];
23367
+ if (!this.clipRectsEqual(previous, clip)) {
23368
+ this.flushBatch();
23369
+ if (clip) {
23370
+ this.applyClipRect(clip);
23371
+ } else {
23372
+ this.engine.setScissorTest(false);
23373
+ }
23374
+ }
23375
+ };
23157
23376
  /**
23158
23377
  * 刷新并渲染所有累积的绘制命令
23159
23378
  */ _proto.end = function end() {
23160
23379
  this.flushBatch();
23380
+ this.clipStack = [];
23381
+ this.engine.setScissorTest(false);
23161
23382
  };
23162
23383
  /**
23163
23384
  * 切换到指定批次类型/纹理。若与当前批次不一致,先 flush 已累积顶点
@@ -23170,6 +23391,24 @@ var Graphics = /*#__PURE__*/ function() {
23170
23391
  this.currentBatchType = type;
23171
23392
  this.currentBatchTexture = texture;
23172
23393
  };
23394
+ _proto.applyClipRect = function applyClipRect(clip) {
23395
+ var framebufferWidth = this.engine.canvas.width;
23396
+ var framebufferHeight = this.engine.canvas.height;
23397
+ var scaleX = framebufferWidth / this.logicalWidth;
23398
+ var scaleY = framebufferHeight / this.logicalHeight;
23399
+ var left = Math.max(0, Math.min(framebufferWidth, Math.floor(clip.x * scaleX)));
23400
+ var top = Math.max(0, Math.min(framebufferHeight, Math.floor(clip.y * scaleY)));
23401
+ var right = Math.max(left, Math.min(framebufferWidth, Math.ceil((clip.x + clip.width) * scaleX)));
23402
+ var bottom = Math.max(top, Math.min(framebufferHeight, Math.ceil((clip.y + clip.height) * scaleY)));
23403
+ this.engine.setScissorTest(true);
23404
+ this.engine.setScissor(left, framebufferHeight - bottom, right - left, bottom - top);
23405
+ };
23406
+ _proto.clipRectsEqual = function clipRectsEqual(left, right) {
23407
+ if (!left || !right) {
23408
+ return left === right;
23409
+ }
23410
+ return left.x === right.x && left.y === right.y && left.width === right.width && left.height === right.height;
23411
+ };
23173
23412
  /**
23174
23413
  * 提交当前累积的顶点到 renderer,清空缓冲(批次内部 flush 不重置 batchType)
23175
23414
  */ _proto.flushBatch = function flushBatch() {
@@ -23183,37 +23422,48 @@ var Graphics = /*#__PURE__*/ function() {
23183
23422
  var colorsArray = new Float32Array(this.colors);
23184
23423
  var uvsArray = new Float32Array(this.uvs);
23185
23424
  var indicesArray = new Uint16Array(this.indices);
23186
- this.updateAttributeData(VertexBuffer.PositionKind, verticesArray, 2);
23187
- this.updateAttributeData(VertexBuffer.ColorKind, colorsArray, 4);
23188
- this.updateAttributeData(VertexBuffer.UVKind, uvsArray, 2);
23189
- this.geometry.setIndexData(indicesArray);
23190
- this.geometry.setDrawCount(this.currentIndexCount);
23425
+ var geometry = this.currentBatchType === "ninePatch" ? this.ninePatchGeometry : this.geometry;
23426
+ this.updateAttributeData(geometry, VertexBuffer.PositionKind, verticesArray, 2);
23427
+ this.updateAttributeData(geometry, VertexBuffer.ColorKind, colorsArray, 4);
23428
+ this.updateAttributeData(geometry, VertexBuffer.UVKind, uvsArray, 2);
23429
+ if (this.currentBatchType === "ninePatch") {
23430
+ this.updateAttributeData(geometry, NINE_PATCH_DRAW_SOURCE_SIZE, new Float32Array(this.ninePatchDrawSourceSizes), 4);
23431
+ this.updateAttributeData(geometry, NINE_PATCH_SOURCE_RECT, new Float32Array(this.ninePatchSourceRects), 4);
23432
+ this.updateAttributeData(geometry, NINE_PATCH_MARGINS, new Float32Array(this.ninePatchMargins), 4);
23433
+ this.updateAttributeData(geometry, NINE_PATCH_OPTIONS, new Float32Array(this.ninePatchOptions), 4);
23434
+ }
23435
+ geometry.setIndexData(indicesArray);
23436
+ geometry.setDrawCount(this.currentIndexCount);
23191
23437
  var material;
23192
- if (this.currentBatchType === "textured" || this.currentBatchType === "text") {
23193
- material = this.currentBatchType === "text" ? this.textMaterial : this.texturedMaterial;
23438
+ if (this.currentBatchType === "textured" || this.currentBatchType === "text" || this.currentBatchType === "ninePatch") {
23439
+ material = this.currentBatchType === "text" ? this.textMaterial : this.currentBatchType === "ninePatch" ? this.ninePatchMaterial : this.texturedMaterial;
23194
23440
  var _this_currentBatchTexture;
23195
23441
  var tex = (_this_currentBatchTexture = this.currentBatchTexture) != null ? _this_currentBatchTexture : this.engine.whiteTexture;
23196
23442
  material.setTexture("uMainTexture", tex);
23197
23443
  } else {
23198
23444
  material = this.coloredMaterial;
23199
23445
  }
23200
- this.engine.renderer.drawGeometry(this.geometry, Matrix4.IDENTITY, material);
23446
+ this.engine.renderer.drawGeometry(geometry, Matrix4.IDENTITY, material);
23201
23447
  this.indices.length = 0;
23202
23448
  this.vertices.length = 0;
23203
23449
  this.colors.length = 0;
23204
23450
  this.uvs.length = 0;
23205
- };
23206
- _proto.updateAttributeData = function updateAttributeData(name, data, size) {
23207
- var _this_geometry_getVertexBuffer;
23208
- var dataBuffer = (_this_geometry_getVertexBuffer = this.geometry.getVertexBuffer(name)) == null ? void 0 : _this_geometry_getVertexBuffer.getBuffer();
23451
+ this.ninePatchDrawSourceSizes.length = 0;
23452
+ this.ninePatchSourceRects.length = 0;
23453
+ this.ninePatchMargins.length = 0;
23454
+ this.ninePatchOptions.length = 0;
23455
+ };
23456
+ _proto.updateAttributeData = function updateAttributeData(geometry, name, data, size) {
23457
+ var _geometry_getVertexBuffer;
23458
+ var dataBuffer = (_geometry_getVertexBuffer = geometry.getVertexBuffer(name)) == null ? void 0 : _geometry_getVertexBuffer.getBuffer();
23209
23459
  if (dataBuffer && data.byteLength > dataBuffer.capacity) {
23210
- this.geometry.setVerticesBuffer(new VertexBuffer(this.engine, data, name, {
23460
+ geometry.setVerticesBuffer(new VertexBuffer(this.engine, data, name, {
23211
23461
  updatable: true,
23212
23462
  size: size
23213
23463
  }));
23214
23464
  return;
23215
23465
  }
23216
- this.geometry.setAttributeData(name, data);
23466
+ geometry.setAttributeData(name, data);
23217
23467
  };
23218
23468
  /**
23219
23469
  * 线段顶点按顺序连接 (p0-p1, p1-p2, p2-p3, ...)
@@ -23382,10 +23632,37 @@ var Graphics = /*#__PURE__*/ function() {
23382
23632
  this.pushQuad(x, y, width, height, color, region);
23383
23633
  };
23384
23634
  /**
23635
+ * Draws a nine-patch as one quad. Stretching and repetition are resolved in the fragment shader,
23636
+ * so Tile and TileFit do not expand into CPU-side geometry.
23637
+ */ _proto.drawNinePatch = function drawNinePatch(x, y, width, height, texture, options, color) {
23638
+ if (color === void 0) color = Color.WHITE;
23639
+ if (width <= 0 || height <= 0 || options.sourceWidth <= 0 || options.sourceHeight <= 0) {
23640
+ return;
23641
+ }
23642
+ this.ensureBatch("ninePatch", texture);
23643
+ var sourceU = options.sourceX / texture.width;
23644
+ var sourceV = 1 - options.sourceY / texture.height;
23645
+ var sourceUSize = options.sourceWidth / texture.width;
23646
+ var sourceVSize = options.sourceHeight / texture.height;
23647
+ var _options_horizontalMode;
23648
+ var horizontalMode = (_options_horizontalMode = options.horizontalMode) != null ? _options_horizontalMode : 0;
23649
+ var _options_verticalMode;
23650
+ var verticalMode = (_options_verticalMode = options.verticalMode) != null ? _options_verticalMode : 0;
23651
+ var _options_drawCenter;
23652
+ var drawCenter = Number((_options_drawCenter = options.drawCenter) != null ? _options_drawCenter : true);
23653
+ this.pushQuad(x, y, width, height, color, FULL_REGION);
23654
+ for(var i = 0; i < 4; i++){
23655
+ this.ninePatchDrawSourceSizes.push(width, height, options.sourceWidth, options.sourceHeight);
23656
+ this.ninePatchSourceRects.push(sourceU, sourceV, sourceUSize, sourceVSize);
23657
+ this.ninePatchMargins.push(options.marginLeft, options.marginTop, options.marginRight, options.marginBottom);
23658
+ this.ninePatchOptions.push(horizontalMode, verticalMode, drawCenter, 0);
23659
+ }
23660
+ };
23661
+ /**
23385
23662
  * 绘制文本(本地坐标,Y 向下,(x, y) 为文本 cell 左上角)。
23386
23663
  *
23387
23664
  * 文本走字符级 bitmap atlas(同一字体下每个字只渲染一次,任意文本组合复用 atlas);
23388
- * `color` 作为乘色与白色字形 alpha 相乘,任意颜色都不会污染 atlas。
23665
+ * `color` atlas 字形 RGBA 相乘,任意颜色都不会污染 atlas。
23389
23666
  *
23390
23667
  * 字体参数全部展开,避免调用方每帧创建临时 style 对象触发 GC
23391
23668
  * @param x - 文本左上角 X 坐标(首字 ink 起始处,含 padding 的 quad 会向左延伸)
@@ -23408,10 +23685,11 @@ var Graphics = /*#__PURE__*/ function() {
23408
23685
  this.ensureBatch("text", atlas.texture);
23409
23686
  var lineHeight = atlas.lineHeight;
23410
23687
  var cursorX = x;
23688
+ var characters = Array.from(text);
23411
23689
  // ensureChar 可能往 atlas canvas 写新字并打 dirty 标;实际 upload 推迟到
23412
23690
  // flushBatch 统一处理,这样一帧多次 drawText 共写同一 atlas 只 upload 一次
23413
- for(var i = 0; i < text.length; i++){
23414
- var info = atlas.ensureChar(text[i]);
23691
+ for(var i = 0; i < characters.length; i++){
23692
+ var info = atlas.ensureChar(characters[i]);
23415
23693
  if (!info) {
23416
23694
  continue;
23417
23695
  }
@@ -23433,11 +23711,35 @@ var Graphics = /*#__PURE__*/ function() {
23433
23711
  cursorX += info.advance;
23434
23712
  }
23435
23713
  };
23714
+ /** Measures text with the same glyph metrics used by {@link drawText}. */ _proto.measureText = function measureText(text, fontSize, fontFamily, fontWeight, fontStyle) {
23715
+ if (fontFamily === void 0) fontFamily = "sans-serif";
23716
+ if (fontWeight === void 0) fontWeight = "normal";
23717
+ if (fontStyle === void 0) fontStyle = "normal";
23718
+ var atlas = this.textCache.getAtlas(fontSize, fontFamily, fontWeight, fontStyle);
23719
+ var characters = Array.from(text);
23720
+ var advances = [];
23721
+ var width = 0;
23722
+ for(var _iterator = _create_for_of_iterator_helper_loose(characters), _step; !(_step = _iterator()).done;){
23723
+ var character = _step.value;
23724
+ var _atlas_ensureChar;
23725
+ var _atlas_ensureChar_advance;
23726
+ var advance = (_atlas_ensureChar_advance = (_atlas_ensureChar = atlas.ensureChar(character)) == null ? void 0 : _atlas_ensureChar.advance) != null ? _atlas_ensureChar_advance : 0;
23727
+ advances.push(advance);
23728
+ width += advance;
23729
+ }
23730
+ return {
23731
+ width: width,
23732
+ lineHeight: atlas.lineHeight,
23733
+ advances: advances
23734
+ };
23735
+ };
23436
23736
  _proto.dispose = function dispose() {
23437
23737
  this.geometry.dispose();
23738
+ this.ninePatchGeometry.dispose();
23438
23739
  this.coloredMaterial.dispose();
23439
23740
  this.texturedMaterial.dispose();
23440
23741
  this.textMaterial.dispose();
23742
+ this.ninePatchMaterial.dispose();
23441
23743
  this.textCache.dispose();
23442
23744
  };
23443
23745
  _proto.buildShape = function buildShape(shape, color) {
@@ -23445,7 +23747,7 @@ var Graphics = /*#__PURE__*/ function() {
23445
23747
  var indexOffset = this.indices.length;
23446
23748
  var vertexOffset = this.vertices.length / 2;
23447
23749
  buildPoints.length = 0;
23448
- shape.build(buildPoints);
23750
+ shape.build(buildPoints, this.getScreenScale());
23449
23751
  shape.triangulate(buildPoints, this.vertices, vertexOffset, this.indices, indexOffset);
23450
23752
  this.applyTransformAndColor(vertexOffset, this.vertices.length / 2 - vertexOffset, color);
23451
23753
  };
@@ -23455,11 +23757,19 @@ var Graphics = /*#__PURE__*/ function() {
23455
23757
  this.indices.length;
23456
23758
  var vertexOffset = this.vertices.length / 2;
23457
23759
  buildPoints.length = 0;
23458
- shape.build(buildPoints);
23760
+ shape.build(buildPoints, this.getScreenScale());
23459
23761
  this.lineStyle.width = thickness;
23460
23762
  buildLine(buildPoints, this.lineStyle, false, closed, this.vertices, 2, vertexOffset, this.indices);
23461
23763
  this.applyTransformAndColor(vertexOffset, this.vertices.length / 2 - vertexOffset, color);
23462
23764
  };
23765
+ _proto.getScreenScale = function getScreenScale() {
23766
+ var transform = this.currentTransform.elements;
23767
+ var transformScaleX = Math.hypot(transform[0], transform[1]);
23768
+ var transformScaleY = Math.hypot(transform[3], transform[4]);
23769
+ var framebufferScaleX = this.engine.canvas.width / this.logicalWidth;
23770
+ var framebufferScaleY = this.engine.canvas.height / this.logicalHeight;
23771
+ return Math.max(transformScaleX * framebufferScaleX, transformScaleY * framebufferScaleY, 1);
23772
+ };
23463
23773
  _proto.setTriangleShape = function setTriangleShape(x1, y1, x2, y2, x3, y3) {
23464
23774
  this.triangleShape.x = x1;
23465
23775
  this.triangleShape.y = y1;
@@ -24508,2107 +24818,6 @@ FrameComponent = __decorate([
24508
24818
  // 第四列 (位移) 乘 1,无需修改
24509
24819
  }
24510
24820
 
24511
- function _assert_this_initialized(self) {
24512
- if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
24513
- return self;
24514
- }
24515
-
24516
- var MouseFilter;
24517
- (function(MouseFilter) {
24518
- MouseFilter[MouseFilter["Stop"] = 0] = "Stop";
24519
- MouseFilter[MouseFilter["Pass"] = 1] = "Pass";
24520
- MouseFilter[MouseFilter["Ignore"] = 2] = "Ignore";
24521
- })(MouseFilter || (MouseFilter = {}));
24522
- var MouseBehaviorRecursive;
24523
- (function(MouseBehaviorRecursive) {
24524
- MouseBehaviorRecursive[MouseBehaviorRecursive["Inherited"] = 0] = "Inherited";
24525
- MouseBehaviorRecursive[MouseBehaviorRecursive["Disabled"] = 1] = "Disabled";
24526
- MouseBehaviorRecursive[MouseBehaviorRecursive["Enabled"] = 2] = "Enabled";
24527
- })(MouseBehaviorRecursive || (MouseBehaviorRecursive = {}));
24528
- var MouseButton;
24529
- (function(MouseButton) {
24530
- MouseButton[MouseButton["None"] = 0] = "None";
24531
- MouseButton[MouseButton["Left"] = 1] = "Left";
24532
- MouseButton[MouseButton["Right"] = 2] = "Right";
24533
- MouseButton[MouseButton["Middle"] = 3] = "Middle";
24534
- MouseButton[MouseButton["WheelUp"] = 4] = "WheelUp";
24535
- MouseButton[MouseButton["WheelDown"] = 5] = "WheelDown";
24536
- MouseButton[MouseButton["WheelLeft"] = 6] = "WheelLeft";
24537
- MouseButton[MouseButton["WheelRight"] = 7] = "WheelRight";
24538
- MouseButton[MouseButton["Xbutton1"] = 8] = "Xbutton1";
24539
- MouseButton[MouseButton["Xbutton2"] = 9] = "Xbutton2";
24540
- })(MouseButton || (MouseButton = {}));
24541
- var MouseButtonMask;
24542
- (function(MouseButtonMask) {
24543
- MouseButtonMask[MouseButtonMask["None"] = 0] = "None";
24544
- MouseButtonMask[MouseButtonMask["Left"] = 1] = "Left";
24545
- MouseButtonMask[MouseButtonMask["Right"] = 2] = "Right";
24546
- MouseButtonMask[MouseButtonMask["Middle"] = 4] = "Middle";
24547
- MouseButtonMask[MouseButtonMask["Xbutton1"] = 128] = "Xbutton1";
24548
- MouseButtonMask[MouseButtonMask["Xbutton2"] = 256] = "Xbutton2";
24549
- })(MouseButtonMask || (MouseButtonMask = {}));
24550
- var FocusMode;
24551
- (function(FocusMode) {
24552
- FocusMode[FocusMode["None"] = 0] = "None";
24553
- FocusMode[FocusMode["Click"] = 1] = "Click";
24554
- FocusMode[FocusMode["All"] = 2] = "All";
24555
- FocusMode[FocusMode["Accessibility"] = 3] = "Accessibility";
24556
- })(FocusMode || (FocusMode = {}));
24557
- var FocusBehaviorRecursive;
24558
- (function(FocusBehaviorRecursive) {
24559
- FocusBehaviorRecursive[FocusBehaviorRecursive["Inherited"] = 0] = "Inherited";
24560
- FocusBehaviorRecursive[FocusBehaviorRecursive["Disabled"] = 1] = "Disabled";
24561
- FocusBehaviorRecursive[FocusBehaviorRecursive["Enabled"] = 2] = "Enabled";
24562
- })(FocusBehaviorRecursive || (FocusBehaviorRecursive = {}));
24563
- var KeyLocation;
24564
- (function(KeyLocation) {
24565
- KeyLocation[KeyLocation["Unspecified"] = 0] = "Unspecified";
24566
- KeyLocation[KeyLocation["Left"] = 1] = "Left";
24567
- KeyLocation[KeyLocation["Right"] = 2] = "Right";
24568
- })(KeyLocation || (KeyLocation = {}));
24569
- var CursorShape;
24570
- (function(CursorShape) {
24571
- CursorShape[CursorShape["Arrow"] = 0] = "Arrow";
24572
- CursorShape[CursorShape["Ibeam"] = 1] = "Ibeam";
24573
- CursorShape[CursorShape["PointingHand"] = 2] = "PointingHand";
24574
- CursorShape[CursorShape["Cross"] = 3] = "Cross";
24575
- CursorShape[CursorShape["Wait"] = 4] = "Wait";
24576
- CursorShape[CursorShape["Busy"] = 5] = "Busy";
24577
- CursorShape[CursorShape["Drag"] = 6] = "Drag";
24578
- CursorShape[CursorShape["CanDrop"] = 7] = "CanDrop";
24579
- CursorShape[CursorShape["Forbidden"] = 8] = "Forbidden";
24580
- CursorShape[CursorShape["Vsize"] = 9] = "Vsize";
24581
- CursorShape[CursorShape["Hsize"] = 10] = "Hsize";
24582
- CursorShape[CursorShape["Bdiagsize"] = 11] = "Bdiagsize";
24583
- CursorShape[CursorShape["Fdiagsize"] = 12] = "Fdiagsize";
24584
- CursorShape[CursorShape["Move"] = 13] = "Move";
24585
- CursorShape[CursorShape["Vsplit"] = 14] = "Vsplit";
24586
- CursorShape[CursorShape["Hsplit"] = 15] = "Hsplit";
24587
- CursorShape[CursorShape["Help"] = 16] = "Help";
24588
- })(CursorShape || (CursorShape = {}));
24589
-
24590
- function _get_prototype_of(o) {
24591
- _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
24592
- return o.__proto__ || Object.getPrototypeOf(o);
24593
- };
24594
- return _get_prototype_of(o);
24595
- }
24596
-
24597
- function _is_native_function(fn) {
24598
- return Function.toString.call(fn).indexOf("[native code]") !== -1;
24599
- }
24600
-
24601
- function _wrap_native_super(Class) {
24602
- var _cache = typeof Map === "function" ? new Map() : undefined;
24603
- _wrap_native_super = function _wrap_native_super(Class) {
24604
- if (Class === null || !_is_native_function(Class)) return Class;
24605
- if (typeof Class !== "function") throw new TypeError("Super expression must either be null or a function");
24606
- if (typeof _cache !== "undefined") {
24607
- if (_cache.has(Class)) return _cache.get(Class);
24608
- _cache.set(Class, Wrapper);
24609
- }
24610
- function Wrapper() {
24611
- return _construct(Class, arguments, _get_prototype_of(this).constructor);
24612
- }
24613
- Wrapper.prototype = Object.create(Class.prototype, {
24614
- constructor: {
24615
- value: Wrapper,
24616
- enumerable: false,
24617
- writable: true,
24618
- configurable: true
24619
- }
24620
- });
24621
- return _set_prototype_of(Wrapper, Class);
24622
- };
24623
- return _wrap_native_super(Class);
24624
- }
24625
-
24626
- function transformPoint(transform, value) {
24627
- var elements = transform.elements;
24628
- return new Vector2(elements[0] * value.x + elements[3] * value.y + elements[6], elements[1] * value.x + elements[4] * value.y + elements[7]);
24629
- }
24630
- function transformVector(transform, value) {
24631
- var elements = transform.elements;
24632
- return new Vector2(elements[0] * value.x + elements[3] * value.y, elements[1] * value.x + elements[4] * value.y);
24633
- }
24634
- var InputEvent = /*#__PURE__*/ function() {
24635
- function InputEvent() {
24636
- this.device = 0;
24637
- this.pressed = false;
24638
- this.canceled = false;
24639
- this._accepted = false;
24640
- }
24641
- var _proto = InputEvent.prototype;
24642
- _proto.accept = function accept() {
24643
- this._accepted = true;
24644
- };
24645
- _proto.clearAccepted = function clearAccepted() {
24646
- this._accepted = false;
24647
- };
24648
- _proto.isAccepted = function isAccepted() {
24649
- return this._accepted;
24650
- };
24651
- _proto.isPressed = function isPressed() {
24652
- return this.pressed && !this.canceled;
24653
- };
24654
- _proto.isReleased = function isReleased() {
24655
- return !this.pressed && !this.canceled;
24656
- };
24657
- _proto.isCanceled = function isCanceled() {
24658
- return this.canceled;
24659
- };
24660
- _proto.isEcho = function isEcho() {
24661
- return false;
24662
- };
24663
- _proto.xformedBy = function xformedBy(transform) {
24664
- return this;
24665
- };
24666
- return InputEvent;
24667
- }();
24668
- InputEvent.deviceIdEmulation = -1;
24669
- InputEvent.deviceIdInternal = -2;
24670
- InputEvent.deviceIdKeyboard = 16;
24671
- InputEvent.deviceIdMouse = 32;
24672
- var InputEventWithModifiers = /*#__PURE__*/ function(InputEvent) {
24673
- _inherits(InputEventWithModifiers, InputEvent);
24674
- function InputEventWithModifiers() {
24675
- var _this;
24676
- _this = InputEvent.apply(this, arguments) || this;
24677
- _this.commandOrControlAutoremap = false;
24678
- _this.shiftPressed = false;
24679
- _this.altPressed = false;
24680
- _this.metaPressed = false;
24681
- _this.ctrlPressed = false;
24682
- return _this;
24683
- }
24684
- var _proto = InputEventWithModifiers.prototype;
24685
- _proto.copyModifiersTo = function copyModifiersTo(event) {
24686
- event.device = this.device;
24687
- event.pressed = this.pressed;
24688
- event.canceled = this.canceled;
24689
- event.commandOrControlAutoremap = this.commandOrControlAutoremap;
24690
- event.shiftPressed = this.shiftPressed;
24691
- event.altPressed = this.altPressed;
24692
- event.metaPressed = this.metaPressed;
24693
- event.ctrlPressed = this.ctrlPressed;
24694
- };
24695
- return InputEventWithModifiers;
24696
- }(_wrap_native_super(InputEvent));
24697
- var InputEventKey = /*#__PURE__*/ function(InputEventWithModifiers) {
24698
- _inherits(InputEventKey, InputEventWithModifiers);
24699
- function InputEventKey() {
24700
- var _this;
24701
- _this = InputEventWithModifiers.apply(this, arguments) || this;
24702
- _this.keycode = "";
24703
- _this.physicalKeycode = "";
24704
- _this.keyLabel = "";
24705
- _this.unicode = 0;
24706
- _this.location = KeyLocation.Unspecified;
24707
- _this.echo = false;
24708
- return _this;
24709
- }
24710
- var _proto = InputEventKey.prototype;
24711
- _proto.isEcho = function isEcho() {
24712
- return this.echo;
24713
- };
24714
- return InputEventKey;
24715
- }(InputEventWithModifiers);
24716
- var InputEventMouse = /*#__PURE__*/ function(InputEventWithModifiers) {
24717
- _inherits(InputEventMouse, InputEventWithModifiers);
24718
- function InputEventMouse() {
24719
- var _this;
24720
- _this = InputEventWithModifiers.apply(this, arguments) || this;
24721
- _this.buttonMask = MouseButtonMask.None;
24722
- _this.position = new Vector2();
24723
- _this.globalPosition = new Vector2();
24724
- return _this;
24725
- }
24726
- var _proto = InputEventMouse.prototype;
24727
- _proto.copyMouseTo = function copyMouseTo(event) {
24728
- this.copyModifiersTo(event);
24729
- event.buttonMask = this.buttonMask;
24730
- event.position.copyFrom(this.position);
24731
- event.globalPosition.copyFrom(this.globalPosition);
24732
- };
24733
- return InputEventMouse;
24734
- }(InputEventWithModifiers);
24735
- var InputEventMouseButton = /*#__PURE__*/ function(InputEventMouse) {
24736
- _inherits(InputEventMouseButton, InputEventMouse);
24737
- function InputEventMouseButton() {
24738
- var _this;
24739
- _this = InputEventMouse.apply(this, arguments) || this;
24740
- _this.factor = 1;
24741
- _this.buttonIndex = MouseButton.None;
24742
- _this.doubleClick = false;
24743
- return _this;
24744
- }
24745
- var _proto = InputEventMouseButton.prototype;
24746
- _proto.xformedBy = function xformedBy(transform) {
24747
- var event = new InputEventMouseButton();
24748
- this.copyMouseTo(event);
24749
- event.position.copyFrom(transformPoint(transform, this.position));
24750
- event.factor = this.factor;
24751
- event.buttonIndex = this.buttonIndex;
24752
- event.doubleClick = this.doubleClick;
24753
- return event;
24754
- };
24755
- return InputEventMouseButton;
24756
- }(InputEventMouse);
24757
- var InputEventMouseMotion = /*#__PURE__*/ function(InputEventMouse) {
24758
- _inherits(InputEventMouseMotion, InputEventMouse);
24759
- function InputEventMouseMotion() {
24760
- var _this;
24761
- _this = InputEventMouse.apply(this, arguments) || this;
24762
- _this.tilt = new Vector2();
24763
- _this.pressure = 0;
24764
- _this.relative = new Vector2();
24765
- _this.screenRelative = new Vector2();
24766
- _this.velocity = new Vector2();
24767
- _this.screenVelocity = new Vector2();
24768
- _this.penInverted = false;
24769
- return _this;
24770
- }
24771
- var _proto = InputEventMouseMotion.prototype;
24772
- _proto.xformedBy = function xformedBy(transform) {
24773
- var event = new InputEventMouseMotion();
24774
- this.copyMouseTo(event);
24775
- event.position.copyFrom(transformPoint(transform, this.position));
24776
- event.tilt.copyFrom(this.tilt);
24777
- event.pressure = this.pressure;
24778
- event.relative.copyFrom(transformVector(transform, this.relative));
24779
- event.screenRelative.copyFrom(this.screenRelative);
24780
- event.velocity.copyFrom(transformVector(transform, this.velocity));
24781
- event.screenVelocity.copyFrom(this.screenVelocity);
24782
- event.penInverted = this.penInverted;
24783
- return event;
24784
- };
24785
- return InputEventMouseMotion;
24786
- }(InputEventMouse);
24787
- var InputEventScreenTouch = /*#__PURE__*/ function(InputEvent) {
24788
- _inherits(InputEventScreenTouch, InputEvent);
24789
- function InputEventScreenTouch() {
24790
- var _this;
24791
- _this = InputEvent.apply(this, arguments) || this;
24792
- _this.index = 0;
24793
- _this.position = new Vector2();
24794
- _this.doubleTap = false;
24795
- return _this;
24796
- }
24797
- var _proto = InputEventScreenTouch.prototype;
24798
- _proto.xformedBy = function xformedBy(transform) {
24799
- var event = new InputEventScreenTouch();
24800
- event.device = this.device;
24801
- event.pressed = this.pressed;
24802
- event.canceled = this.canceled;
24803
- event.index = this.index;
24804
- event.position.copyFrom(transformPoint(transform, this.position));
24805
- event.doubleTap = this.doubleTap;
24806
- return event;
24807
- };
24808
- return InputEventScreenTouch;
24809
- }(_wrap_native_super(InputEvent));
24810
- var InputEventScreenDrag = /*#__PURE__*/ function(InputEvent) {
24811
- _inherits(InputEventScreenDrag, InputEvent);
24812
- function InputEventScreenDrag() {
24813
- var _this;
24814
- _this = InputEvent.apply(this, arguments) || this;
24815
- _this.index = 0;
24816
- _this.position = new Vector2();
24817
- _this.relative = new Vector2();
24818
- _this.screenRelative = new Vector2();
24819
- _this.velocity = new Vector2();
24820
- _this.screenVelocity = new Vector2();
24821
- _this.pressure = 0;
24822
- _this.tilt = new Vector2();
24823
- _this.penInverted = false;
24824
- return _this;
24825
- }
24826
- var _proto = InputEventScreenDrag.prototype;
24827
- _proto.xformedBy = function xformedBy(transform) {
24828
- var event = new InputEventScreenDrag();
24829
- event.device = this.device;
24830
- event.pressed = this.pressed;
24831
- event.canceled = this.canceled;
24832
- event.index = this.index;
24833
- event.position.copyFrom(transformPoint(transform, this.position));
24834
- event.relative.copyFrom(transformVector(transform, this.relative));
24835
- event.screenRelative.copyFrom(this.screenRelative);
24836
- event.velocity.copyFrom(transformVector(transform, this.velocity));
24837
- event.screenVelocity.copyFrom(this.screenVelocity);
24838
- event.pressure = this.pressure;
24839
- event.tilt.copyFrom(this.tilt);
24840
- event.penInverted = this.penInverted;
24841
- return event;
24842
- };
24843
- return InputEventScreenDrag;
24844
- }(_wrap_native_super(InputEvent));
24845
-
24846
- var ANCHOR_PRESET_TABLE = {
24847
- topLeft: [
24848
- 0,
24849
- 0,
24850
- 0,
24851
- 0
24852
- ],
24853
- topRight: [
24854
- 1,
24855
- 0,
24856
- 1,
24857
- 0
24858
- ],
24859
- bottomLeft: [
24860
- 0,
24861
- 1,
24862
- 0,
24863
- 1
24864
- ],
24865
- bottomRight: [
24866
- 1,
24867
- 1,
24868
- 1,
24869
- 1
24870
- ],
24871
- centerLeft: [
24872
- 0,
24873
- 0.5,
24874
- 0,
24875
- 0.5
24876
- ],
24877
- centerTop: [
24878
- 0.5,
24879
- 0,
24880
- 0.5,
24881
- 0
24882
- ],
24883
- centerRight: [
24884
- 1,
24885
- 0.5,
24886
- 1,
24887
- 0.5
24888
- ],
24889
- centerBottom: [
24890
- 0.5,
24891
- 1,
24892
- 0.5,
24893
- 1
24894
- ],
24895
- center: [
24896
- 0.5,
24897
- 0.5,
24898
- 0.5,
24899
- 0.5
24900
- ],
24901
- leftWide: [
24902
- 0,
24903
- 0,
24904
- 0,
24905
- 1
24906
- ],
24907
- topWide: [
24908
- 0,
24909
- 0,
24910
- 1,
24911
- 0
24912
- ],
24913
- rightWide: [
24914
- 1,
24915
- 0,
24916
- 1,
24917
- 1
24918
- ],
24919
- bottomWide: [
24920
- 0,
24921
- 1,
24922
- 1,
24923
- 1
24924
- ],
24925
- vcenterWide: [
24926
- 0.5,
24927
- 0,
24928
- 0.5,
24929
- 1
24930
- ],
24931
- hcenterWide: [
24932
- 0,
24933
- 0.5,
24934
- 1,
24935
- 0.5
24936
- ],
24937
- fullRect: [
24938
- 0,
24939
- 0,
24940
- 1,
24941
- 1
24942
- ]
24943
- };
24944
- /**
24945
- * A drawable GUI object. Controls form a tree independent from the VFXItem
24946
- * scene tree. UIControl is the bridge between both trees.
24947
- */ var Control = /*#__PURE__*/ function() {
24948
- function Control(engine) {
24949
- this.engine = engine;
24950
- this._parent = null;
24951
- this._visible = true;
24952
- this._enabled = true;
24953
- this._mouseFilter = MouseFilter.Stop;
24954
- this._mouseBehaviorRecursive = MouseBehaviorRecursive.Inherited;
24955
- this._focusMode = FocusMode.None;
24956
- this._focusBehaviorRecursive = FocusBehaviorRecursive.Inherited;
24957
- this._defaultCursorShape = CursorShape.Arrow;
24958
- this._rotation = 0;
24959
- this.transformDirty = true;
24960
- this.cachedTransform = new Matrix3();
24961
- this.eventEmitter = new EventEmitter();
24962
- this.disposed = false;
24963
- this./** Scene-tree bridge that owns this GUI object, if any. */ owner = null;
24964
- this.position = new Vector2();
24965
- this.size = new Vector2(1, 1);
24966
- this.anchorMin = new Vector2();
24967
- this.anchorMax = new Vector2();
24968
- this.offsetMin = new Vector2();
24969
- this.offsetMax = new Vector2(1, 1);
24970
- this.pivot = new Vector2(0.5, 0.5);
24971
- this.scale = new Vector2(1, 1);
24972
- this.shear = new Vector2();
24973
- this.mouseForcePassScrollEvents = true;
24974
- this.clipContents = false;
24975
- }
24976
- var _proto = Control.prototype;
24977
- _proto.on = function on(eventName, listener, options) {
24978
- this.eventEmitter.on(eventName, listener, options);
24979
- };
24980
- _proto.off = function off(eventName, listener) {
24981
- this.eventEmitter.off(eventName, listener);
24982
- };
24983
- _proto.setPosition = function setPosition(x, y, keepOffsets) {
24984
- if (keepOffsets === void 0) keepOffsets = false;
24985
- if (this.position.x === x && this.position.y === y) {
24986
- return;
24987
- }
24988
- var rect = {
24989
- position: new Vector2(x, y),
24990
- size: this.size.clone()
24991
- };
24992
- if (keepOffsets && this.parent) {
24993
- this.computeAnchors(rect, this.getParentRect());
24994
- } else {
24995
- this.computeOffsets(rect, this.getParentRect());
24996
- }
24997
- this.updateLayout();
24998
- };
24999
- _proto.setSize = function setSize(width, height) {
25000
- if (this.size.x === width && this.size.y === height) {
25001
- return;
25002
- }
25003
- var rect = {
25004
- position: this.position.clone(),
25005
- size: new Vector2(width, height)
25006
- };
25007
- this.computeOffsets(rect, this.getParentRect());
25008
- this.updateLayout();
25009
- };
25010
- _proto.setScale = function setScale(x, y) {
25011
- if (this.scale.x !== x || this.scale.y !== y) {
25012
- this.scale.set(x, y);
25013
- this.markTransformDirty();
25014
- }
25015
- };
25016
- _proto.setRotation = function setRotation(degrees) {
25017
- if (this._rotation !== degrees) {
25018
- this._rotation = degrees;
25019
- this.markTransformDirty();
25020
- }
25021
- };
25022
- _proto.setShear = function setShear(x, y) {
25023
- if (this.shear.x !== x || this.shear.y !== y) {
25024
- this.shear.set(x, y);
25025
- this.markTransformDirty();
25026
- }
25027
- };
25028
- _proto.setPivot = function setPivot(x, y) {
25029
- if (this.pivot.x !== x || this.pivot.y !== y) {
25030
- this.pivot.set(x, y);
25031
- this.markTransformDirty();
25032
- }
25033
- };
25034
- _proto.setAnchorMin = function setAnchorMin(x, y) {
25035
- if (this.anchorMin.x !== x || this.anchorMin.y !== y) {
25036
- this.anchorMin.set(x, y);
25037
- this.updateLayout();
25038
- }
25039
- };
25040
- _proto.setAnchorMax = function setAnchorMax(x, y) {
25041
- if (this.anchorMax.x !== x || this.anchorMax.y !== y) {
25042
- this.anchorMax.set(x, y);
25043
- this.updateLayout();
25044
- }
25045
- };
25046
- _proto.setOffsetMin = function setOffsetMin(x, y) {
25047
- if (this.offsetMin.x !== x || this.offsetMin.y !== y) {
25048
- this.offsetMin.set(x, y);
25049
- this.updateLayout();
25050
- }
25051
- };
25052
- _proto.setOffsetMax = function setOffsetMax(x, y) {
25053
- if (this.offsetMax.x !== x || this.offsetMax.y !== y) {
25054
- this.offsetMax.set(x, y);
25055
- this.updateLayout();
25056
- }
25057
- };
25058
- _proto.getRect = function getRect() {
25059
- return {
25060
- position: this.position.clone(),
25061
- size: this.size.clone()
25062
- };
25063
- };
25064
- _proto.getTransform2D = function getTransform2D() {
25065
- if (this.transformDirty) {
25066
- var radians = this._rotation * Math.PI / 180;
25067
- var sin = Math.sin(radians);
25068
- var cos = Math.cos(radians);
25069
- var shearX = Math.tan(Math.max(-89, Math.min(89, this.shear.x)) * Math.PI / 180);
25070
- var shearY = Math.tan(Math.max(-89, Math.min(89, this.shear.y)) * Math.PI / 180);
25071
- var a = this.scale.x * (cos - sin * shearY);
25072
- var b = this.scale.x * (sin + cos * shearY);
25073
- var c = this.scale.y * (cos * shearX - sin);
25074
- var d = this.scale.y * (sin * shearX + cos);
25075
- var pivotX = this.pivot.x * this.size.x;
25076
- var pivotY = this.pivot.y * this.size.y;
25077
- var tx = this.position.x + pivotX - a * pivotX - c * pivotY;
25078
- var ty = this.position.y + pivotY - b * pivotX - d * pivotY;
25079
- this.cachedTransform.set(a, b, 0, c, d, 0, tx, ty, 1);
25080
- this.transformDirty = false;
25081
- }
25082
- return this.cachedTransform;
25083
- };
25084
- _proto.setAnchorsPreset = function setAnchorsPreset(preset, keepOffsets) {
25085
- if (keepOffsets === void 0) keepOffsets = true;
25086
- 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];
25087
- if (keepOffsets) {
25088
- this.anchorMin.set(minX, minY);
25089
- this.anchorMax.set(maxX, maxY);
25090
- } else {
25091
- var rect = this.getRect();
25092
- this.anchorMin.set(minX, minY);
25093
- this.anchorMax.set(maxX, maxY);
25094
- this.computeOffsets(rect, this.getParentRect());
25095
- }
25096
- this.updateLayout();
25097
- };
25098
- _proto.setOffsetsPreset = function setOffsetsPreset(preset, margin) {
25099
- if (margin === void 0) margin = 0;
25100
- if (!this.parent) {
25101
- return;
25102
- }
25103
- var parentSize = this.parent.size;
25104
- var width = this.size.x;
25105
- var height = this.size.y;
25106
- var a = this.anchorMin;
25107
- var b = this.anchorMax;
25108
- var minX = 0, maxX = 0, minY = 0, maxY = 0;
25109
- // Left edge.
25110
- switch(preset){
25111
- case "topLeft":
25112
- case "bottomLeft":
25113
- case "centerLeft":
25114
- case "topWide":
25115
- case "bottomWide":
25116
- case "leftWide":
25117
- case "hcenterWide":
25118
- case "fullRect":
25119
- minX = margin - a.x * parentSize.x;
25120
- break;
25121
- case "centerTop":
25122
- case "centerBottom":
25123
- case "center":
25124
- case "vcenterWide":
25125
- minX = 0.5 * parentSize.x - width / 2 - a.x * parentSize.x;
25126
- break;
25127
- default:
25128
- minX = parentSize.x - margin - width - a.x * parentSize.x;
25129
- break;
25130
- }
25131
- switch(preset){
25132
- case "topLeft":
25133
- case "bottomLeft":
25134
- case "centerLeft":
25135
- case "leftWide":
25136
- maxX = margin + width - b.x * parentSize.x;
25137
- break;
25138
- case "centerTop":
25139
- case "centerBottom":
25140
- case "center":
25141
- case "vcenterWide":
25142
- maxX = 0.5 * parentSize.x + width / 2 - b.x * parentSize.x;
25143
- break;
25144
- default:
25145
- maxX = parentSize.x - margin - b.x * parentSize.x;
25146
- break;
25147
- }
25148
- // Top edge.
25149
- switch(preset){
25150
- case "topLeft":
25151
- case "topRight":
25152
- case "centerTop":
25153
- case "leftWide":
25154
- case "rightWide":
25155
- case "topWide":
25156
- case "vcenterWide":
25157
- case "fullRect":
25158
- minY = margin - a.y * parentSize.y;
25159
- break;
25160
- case "centerLeft":
25161
- case "centerRight":
25162
- case "center":
25163
- case "hcenterWide":
25164
- minY = 0.5 * parentSize.y - height / 2 - a.y * parentSize.y;
25165
- break;
25166
- default:
25167
- minY = parentSize.y - margin - height - a.y * parentSize.y;
25168
- break;
25169
- }
25170
- // Bottom edge.
25171
- switch(preset){
25172
- case "topLeft":
25173
- case "topRight":
25174
- case "centerTop":
25175
- case "topWide":
25176
- maxY = margin + height - b.y * parentSize.y;
25177
- break;
25178
- case "centerLeft":
25179
- case "centerRight":
25180
- case "center":
25181
- case "hcenterWide":
25182
- maxY = 0.5 * parentSize.y + height / 2 - b.y * parentSize.y;
25183
- break;
25184
- default:
25185
- maxY = parentSize.y - margin - b.y * parentSize.y;
25186
- break;
25187
- }
25188
- this.offsetMin.set(minX, minY);
25189
- this.offsetMax.set(maxX, maxY);
25190
- this.updateLayout();
25191
- };
25192
- _proto.setAnchorsAndOffsetsPreset = function setAnchorsAndOffsetsPreset(preset, margin) {
25193
- if (margin === void 0) margin = 0;
25194
- this.setAnchorsPreset(preset, false);
25195
- this.setOffsetsPreset(preset, margin);
25196
- };
25197
- _proto.getGlobalTransform2D = function getGlobalTransform2D() {
25198
- var local = this.getTransform2D();
25199
- return this.parent ? new Matrix3().multiplyMatrices(this.parent.getGlobalTransform2D(), local) : local.clone();
25200
- };
25201
- _proto.hasPoint = function hasPoint(point) {
25202
- return point.x >= 0 && point.y >= 0 && point.x <= this.size.x && point.y <= this.size.y;
25203
- };
25204
- _proto.getEffectiveMouseFilter = function getEffectiveMouseFilter() {
25205
- return this.enabledInHierarchy && this.isMouseRecursiveEnabled() ? this.mouseFilter : MouseFilter.Ignore;
25206
- };
25207
- _proto.getFocusModeWithOverride = function getFocusModeWithOverride() {
25208
- return this.enabledInHierarchy && this.isFocusRecursiveEnabled() ? this.focusMode : FocusMode.None;
25209
- };
25210
- _proto.getCursorShape = function getCursorShape(position) {
25211
- return this.defaultCursorShape;
25212
- };
25213
- _proto.focus = function focus() {
25214
- var _this_root;
25215
- (_this_root = this.root) == null ? void 0 : _this_root.grabControlFocus(this);
25216
- };
25217
- _proto.grabFocus = function grabFocus() {
25218
- this.focus();
25219
- };
25220
- _proto.grabClickFocus = function grabClickFocus() {
25221
- var _this_root;
25222
- (_this_root = this.root) == null ? void 0 : _this_root.grabControlClickFocus(this);
25223
- };
25224
- _proto.releaseFocus = function releaseFocus() {
25225
- var _this_root;
25226
- (_this_root = this.root) == null ? void 0 : _this_root.releaseControlFocus(this);
25227
- };
25228
- _proto.warpMouse = function warpMouse(position) {
25229
- var _this_root;
25230
- var matrix = this.getGlobalTransform2D().elements;
25231
- (_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]));
25232
- };
25233
- /** Converts a window-space position into this control's local coordinates. */ _proto.makePositionLocal = function makePositionLocal(position) {
25234
- var transform = this.getGlobalTransform2D().clone();
25235
- if (Math.abs(transform.determinant()) < 1e-12) {
25236
- return new Vector2();
25237
- }
25238
- var elements = transform.invert().elements;
25239
- return new Vector2(elements[0] * position.x + elements[3] * position.y + elements[6], elements[1] * position.x + elements[4] * position.y + elements[7]);
25240
- };
25241
- /** Gets the current mouse position transformed into this control's coordinates. */ _proto.getLocalMousePosition = function getLocalMousePosition() {
25242
- var root = this.root;
25243
- return root ? this.makePositionLocal(root.getMousePosition()) : new Vector2();
25244
- };
25245
- _proto.update = function update(deltaTime) {};
25246
- _proto.draw = function draw() {
25247
- // OVERRIDE
25248
- };
25249
- _proto.onDestroy = function onDestroy() {};
25250
- /** @internal */ _proto.drawInternal = function drawInternal() {
25251
- if (!this.visibleInHierarchy || this.disposed) {
25252
- return;
25253
- }
25254
- var graphics = this.engine.graphics;
25255
- graphics.pushTransform(this.getTransform2D());
25256
- this.draw();
25257
- graphics.popTransform();
25258
- };
25259
- _proto.drawLine = function drawLine(x1, y1, x2, y2, color, thickness) {
25260
- this.engine.graphics.drawLine(x1, y1, x2, y2, color, thickness);
25261
- };
25262
- _proto.drawPolyline = function drawPolyline(points, color, thickness) {
25263
- this.engine.graphics.drawLines(points, color, thickness);
25264
- };
25265
- _proto.drawBezier = function drawBezier(x1, y1, x2, y2, x3, y3, x4, y4, color, thickness) {
25266
- this.engine.graphics.drawBezier(x1, y1, x2, y2, x3, y3, x4, y4, color, thickness);
25267
- };
25268
- _proto.drawTriangle = function drawTriangle(x1, y1, x2, y2, x3, y3, color, thickness) {
25269
- this.engine.graphics.drawTriangle(x1, y1, x2, y2, x3, y3, color, thickness);
25270
- };
25271
- _proto.drawRect = function drawRect(x, y, width, height, color, thickness) {
25272
- this.engine.graphics.drawRectangle(x, y, width, height, color, thickness);
25273
- };
25274
- _proto.drawCircle = function drawCircle(cx, cy, radius, color, thickness) {
25275
- this.engine.graphics.drawCircle(cx, cy, radius, color, thickness);
25276
- };
25277
- _proto.fillTriangle = function fillTriangle(x1, y1, x2, y2, x3, y3, color) {
25278
- this.engine.graphics.fillTriangle(x1, y1, x2, y2, x3, y3, color);
25279
- };
25280
- _proto.fillRect = function fillRect(x, y, width, height, color) {
25281
- this.engine.graphics.fillRectangle(x, y, width, height, color);
25282
- };
25283
- _proto.fillCircle = function fillCircle(cx, cy, radius, color) {
25284
- this.engine.graphics.fillCircle(cx, cy, radius, color);
25285
- };
25286
- _proto.drawTexture = function drawTexture(x, y, width, height, texture, region, color) {
25287
- this.engine.graphics.drawTexture(x, y, width, height, texture, region, color);
25288
- };
25289
- _proto.drawText = function drawText(x, y, text, fontSize, color, fontFamily, fontWeight, fontStyle) {
25290
- this.engine.graphics.drawText(x, y, text, fontSize, color, fontFamily, fontWeight, fontStyle);
25291
- };
25292
- _proto.onMouseEnter = function onMouseEnter(location) {};
25293
- _proto.onMouseMove = function onMouseMove(event) {};
25294
- _proto.onMouseLeave = function onMouseLeave() {};
25295
- _proto.onMouseWheel = function onMouseWheel(event) {};
25296
- _proto.onMouseDown = function onMouseDown(event) {};
25297
- _proto.onMouseUp = function onMouseUp(event) {};
25298
- _proto.onTouchDown = function onTouchDown(event) {};
25299
- _proto.onTouchMove = function onTouchMove(event) {};
25300
- _proto.onTouchUp = function onTouchUp(event) {};
25301
- _proto.onKeyDown = function onKeyDown(event) {};
25302
- _proto.onKeyUp = function onKeyUp(event) {};
25303
- _proto.onGotFocus = function onGotFocus() {};
25304
- _proto.onLostFocus = function onLostFocus() {};
25305
- /** @internal */ _proto.invokeGetDragData = function invokeGetDragData(position) {
25306
- return this.getDragData(position);
25307
- };
25308
- /** @internal */ _proto.invokeCanDropData = function invokeCanDropData(position, data) {
25309
- return this.canDropData(position, data);
25310
- };
25311
- /** @internal */ _proto.invokeDropData = function invokeDropData(position, data) {
25312
- this.dropData(position, data);
25313
- };
25314
- _proto.getDragData = function getDragData(position) {
25315
- return null;
25316
- };
25317
- _proto.canDropData = function canDropData(position, data) {
25318
- return false;
25319
- };
25320
- _proto.dropData = function dropData(position, data) {};
25321
- _proto.dispose = function dispose() {
25322
- if (this.disposed) {
25323
- return;
25324
- }
25325
- this.disposed = true;
25326
- this.onDestroy();
25327
- this.parent = null;
25328
- this.owner = null;
25329
- };
25330
- /** @internal */ _proto.updateLayout = function updateLayout() {
25331
- var _this_parent;
25332
- var _this_parent_size;
25333
- var parentSize = (_this_parent_size = (_this_parent = this.parent) == null ? void 0 : _this_parent.size) != null ? _this_parent_size : new Vector2();
25334
- var left = this.offsetMin.x + this.anchorMin.x * parentSize.x;
25335
- var top = this.offsetMin.y + this.anchorMin.y * parentSize.y;
25336
- var right = this.offsetMax.x + this.anchorMax.x * parentSize.x;
25337
- var bottom = this.offsetMax.y + this.anchorMax.y * parentSize.y;
25338
- this.applyBounds(left, top, right - left, bottom - top);
25339
- };
25340
- _proto.applyBounds = function applyBounds(x, y, width, height) {
25341
- var locationChanged = this.position.x !== x || this.position.y !== y;
25342
- var sizeChanged = this.size.x !== width || this.size.y !== height;
25343
- if (!locationChanged && !sizeChanged) {
25344
- return;
25345
- }
25346
- this.position.set(x, y);
25347
- this.size.set(width, height);
25348
- this.markTransformDirty();
25349
- if (locationChanged) {
25350
- this.eventEmitter.emit("locationChanged", this);
25351
- }
25352
- if (sizeChanged) {
25353
- this.eventEmitter.emit("sizeChanged", this);
25354
- if (_instanceof1(this, ContainerControl)) {
25355
- for(var _iterator = _create_for_of_iterator_helper_loose(this.children.slice()), _step; !(_step = _iterator()).done;){
25356
- var child = _step.value;
25357
- child.updateLayout();
25358
- }
25359
- }
25360
- }
25361
- };
25362
- _proto.markTransformDirty = function markTransformDirty() {
25363
- var _this_root;
25364
- this.transformDirty = true;
25365
- (_this_root = this.root) == null ? void 0 : _this_root.controlTreeChanged();
25366
- };
25367
- _proto.getParentRect = function getParentRect() {
25368
- var _this_parent;
25369
- var _this_parent_size_clone;
25370
- return {
25371
- position: new Vector2(),
25372
- size: (_this_parent_size_clone = (_this_parent = this.parent) == null ? void 0 : _this_parent.size.clone()) != null ? _this_parent_size_clone : new Vector2()
25373
- };
25374
- };
25375
- _proto.computeOffsets = function computeOffsets(rect, parentRect) {
25376
- 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);
25377
- 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);
25378
- };
25379
- _proto.computeAnchors = function computeAnchors(rect, parentRect) {
25380
- if (parentRect.size.x !== 0) {
25381
- this.anchorMin.x = (rect.position.x - parentRect.position.x - this.offsetMin.x) / parentRect.size.x;
25382
- this.anchorMax.x = (rect.position.x + rect.size.x - parentRect.position.x - this.offsetMax.x) / parentRect.size.x;
25383
- }
25384
- if (parentRect.size.y !== 0) {
25385
- this.anchorMin.y = (rect.position.y - parentRect.position.y - this.offsetMin.y) / parentRect.size.y;
25386
- this.anchorMax.y = (rect.position.y + rect.size.y - parentRect.position.y - this.offsetMax.y) / parentRect.size.y;
25387
- }
25388
- };
25389
- _proto.isMouseRecursiveEnabled = function isMouseRecursiveEnabled() {
25390
- if (this.mouseBehaviorRecursive === MouseBehaviorRecursive.Inherited) {
25391
- var _this_parent;
25392
- var _this_parent_isMouseRecursiveEnabled;
25393
- return (_this_parent_isMouseRecursiveEnabled = (_this_parent = this.parent) == null ? void 0 : _this_parent.isMouseRecursiveEnabled()) != null ? _this_parent_isMouseRecursiveEnabled : true;
25394
- }
25395
- return this.mouseBehaviorRecursive === MouseBehaviorRecursive.Enabled;
25396
- };
25397
- _proto.isFocusRecursiveEnabled = function isFocusRecursiveEnabled() {
25398
- if (this.focusBehaviorRecursive === FocusBehaviorRecursive.Inherited) {
25399
- var _this_parent;
25400
- var _this_parent_isFocusRecursiveEnabled;
25401
- return (_this_parent_isFocusRecursiveEnabled = (_this_parent = this.parent) == null ? void 0 : _this_parent.isFocusRecursiveEnabled()) != null ? _this_parent_isFocusRecursiveEnabled : true;
25402
- }
25403
- return this.focusBehaviorRecursive === FocusBehaviorRecursive.Enabled;
25404
- };
25405
- _create_class(Control, [
25406
- {
25407
- key: "parent",
25408
- get: function get() {
25409
- return this._parent;
25410
- },
25411
- set: function set(value) {
25412
- var _this__parent;
25413
- if (value === this._parent) {
25414
- return;
25415
- }
25416
- var previousRoot = this.root;
25417
- (_this__parent = this._parent) == null ? void 0 : _this__parent.removeChildInternal(this);
25418
- this._parent = value;
25419
- value == null ? void 0 : value.addChildInternal(this);
25420
- this.updateLayout();
25421
- var nextRoot = this.root;
25422
- if (previousRoot && previousRoot !== nextRoot) {
25423
- previousRoot.controlRemoved(this);
25424
- }
25425
- nextRoot == null ? void 0 : nextRoot.controlTreeChanged();
25426
- this.eventEmitter.emit("parentChanged", this);
25427
- }
25428
- },
25429
- {
25430
- key: "item",
25431
- get: /** Scene item exposed through the optional UIControl bridge. */ function get() {
25432
- var _this_owner;
25433
- var _this_owner_item;
25434
- return (_this_owner_item = (_this_owner = this.owner) == null ? void 0 : _this_owner.item) != null ? _this_owner_item : null;
25435
- }
25436
- },
25437
- {
25438
- key: "indexInParent",
25439
- get: function get() {
25440
- var _this_parent;
25441
- var _this_parent_getChildIndex;
25442
- return (_this_parent_getChildIndex = (_this_parent = this.parent) == null ? void 0 : _this_parent.getChildIndex(this)) != null ? _this_parent_getChildIndex : -1;
25443
- },
25444
- set: function set(value) {
25445
- var _this_parent;
25446
- (_this_parent = this.parent) == null ? void 0 : _this_parent.changeChildIndex(this, value);
25447
- }
25448
- },
25449
- {
25450
- key: "visible",
25451
- get: function get() {
25452
- return this._visible;
25453
- },
25454
- set: function set(value) {
25455
- if (this._visible !== value) {
25456
- var _this_root;
25457
- this._visible = value;
25458
- (_this_root = this.root) == null ? void 0 : _this_root.controlStateChanged(this);
25459
- }
25460
- }
25461
- },
25462
- {
25463
- key: "visibleInHierarchy",
25464
- get: function get() {
25465
- var _this_parent;
25466
- var _this_parent_visibleInHierarchy;
25467
- return this.visible && ((_this_parent_visibleInHierarchy = (_this_parent = this.parent) == null ? void 0 : _this_parent.visibleInHierarchy) != null ? _this_parent_visibleInHierarchy : true);
25468
- }
25469
- },
25470
- {
25471
- key: "enabled",
25472
- get: function get() {
25473
- return this._enabled;
25474
- },
25475
- set: function set(value) {
25476
- if (this._enabled !== value) {
25477
- var _this_root;
25478
- this._enabled = value;
25479
- (_this_root = this.root) == null ? void 0 : _this_root.controlStateChanged(this);
25480
- }
25481
- }
25482
- },
25483
- {
25484
- key: "enabledInHierarchy",
25485
- get: function get() {
25486
- var _this_parent;
25487
- var _this_parent_enabledInHierarchy;
25488
- return this.enabled && ((_this_parent_enabledInHierarchy = (_this_parent = this.parent) == null ? void 0 : _this_parent.enabledInHierarchy) != null ? _this_parent_enabledInHierarchy : true);
25489
- }
25490
- },
25491
- {
25492
- key: "mouseFilter",
25493
- get: function get() {
25494
- return this._mouseFilter;
25495
- },
25496
- set: function set(value) {
25497
- if (this._mouseFilter !== value) {
25498
- var _this_root;
25499
- this._mouseFilter = value;
25500
- (_this_root = this.root) == null ? void 0 : _this_root.controlStateChanged(this);
25501
- }
25502
- }
25503
- },
25504
- {
25505
- key: "mouseBehaviorRecursive",
25506
- get: function get() {
25507
- return this._mouseBehaviorRecursive;
25508
- },
25509
- set: function set(value) {
25510
- if (this._mouseBehaviorRecursive !== value) {
25511
- var _this_root;
25512
- this._mouseBehaviorRecursive = value;
25513
- (_this_root = this.root) == null ? void 0 : _this_root.controlStateChanged(this);
25514
- }
25515
- }
25516
- },
25517
- {
25518
- key: "focusMode",
25519
- get: function get() {
25520
- return this._focusMode;
25521
- },
25522
- set: function set(value) {
25523
- if (this._focusMode !== value) {
25524
- var _this_root;
25525
- this._focusMode = value;
25526
- (_this_root = this.root) == null ? void 0 : _this_root.controlStateChanged(this);
25527
- }
25528
- }
25529
- },
25530
- {
25531
- key: "focusBehaviorRecursive",
25532
- get: function get() {
25533
- return this._focusBehaviorRecursive;
25534
- },
25535
- set: function set(value) {
25536
- if (this._focusBehaviorRecursive !== value) {
25537
- var _this_root;
25538
- this._focusBehaviorRecursive = value;
25539
- (_this_root = this.root) == null ? void 0 : _this_root.controlStateChanged(this);
25540
- }
25541
- }
25542
- },
25543
- {
25544
- key: "defaultCursorShape",
25545
- get: function get() {
25546
- return this._defaultCursorShape;
25547
- },
25548
- set: function set(value) {
25549
- var _this_root;
25550
- if (this._defaultCursorShape === value) {
25551
- return;
25552
- }
25553
- this._defaultCursorShape = value;
25554
- (_this_root = this.root) == null ? void 0 : _this_root.updateMouseCursorState();
25555
- }
25556
- },
25557
- {
25558
- key: "location",
25559
- get: function get() {
25560
- return this.position;
25561
- },
25562
- set: function set(value) {
25563
- this.setPosition(value.x, value.y);
25564
- }
25565
- },
25566
- {
25567
- key: "rotation",
25568
- get: function get() {
25569
- return this._rotation;
25570
- }
25571
- },
25572
- {
25573
- key: "x",
25574
- get: function get() {
25575
- return this.position.x;
25576
- },
25577
- set: function set(value) {
25578
- this.setPosition(value, this.position.y);
25579
- }
25580
- },
25581
- {
25582
- key: "y",
25583
- get: function get() {
25584
- return this.position.y;
25585
- },
25586
- set: function set(value) {
25587
- this.setPosition(this.position.x, value);
25588
- }
25589
- },
25590
- {
25591
- key: "width",
25592
- get: function get() {
25593
- return this.size.x;
25594
- },
25595
- set: function set(value) {
25596
- this.setSize(value, this.size.y);
25597
- }
25598
- },
25599
- {
25600
- key: "height",
25601
- get: function get() {
25602
- return this.size.y;
25603
- },
25604
- set: function set(value) {
25605
- this.setSize(this.size.x, value);
25606
- }
25607
- },
25608
- {
25609
- key: "root",
25610
- get: function get() {
25611
- var _this_parent;
25612
- var _this_parent_root;
25613
- return _instanceof1(this, RootControl) ? this : (_this_parent_root = (_this_parent = this.parent) == null ? void 0 : _this_parent.root) != null ? _this_parent_root : null;
25614
- }
25615
- },
25616
- {
25617
- key: "isDisposed",
25618
- get: function get() {
25619
- return this.disposed;
25620
- }
25621
- }
25622
- ]);
25623
- return Control;
25624
- }();
25625
- /** A Control that owns child Controls. */ var ContainerControl = /*#__PURE__*/ function(Control) {
25626
- _inherits(ContainerControl, Control);
25627
- function ContainerControl() {
25628
- var _this;
25629
- _this = Control.apply(this, arguments) || this;
25630
- _this.children = [];
25631
- return _this;
25632
- }
25633
- var _proto = ContainerControl.prototype;
25634
- _proto.addChild = function addChild(child) {
25635
- child.parent = this;
25636
- return child;
25637
- };
25638
- _proto.removeChild = function removeChild(child) {
25639
- if (child.parent === this) {
25640
- child.parent = null;
25641
- }
25642
- };
25643
- _proto.getChildIndex = function getChildIndex(child) {
25644
- return this.children.indexOf(child);
25645
- };
25646
- /** @internal */ _proto.changeChildIndex = function changeChildIndex(child, newIndex) {
25647
- var _this_root;
25648
- var oldIndex = this.children.indexOf(child);
25649
- if (oldIndex === newIndex || oldIndex === -1) {
25650
- return;
25651
- }
25652
- this.children.splice(oldIndex, 1);
25653
- if (newIndex < 0 || newIndex >= this.children.length) {
25654
- this.children.push(child);
25655
- } else {
25656
- this.children.splice(newIndex, 0, child);
25657
- }
25658
- (_this_root = this.root) == null ? void 0 : _this_root.controlTreeChanged();
25659
- };
25660
- /** @internal */ _proto.addChildInternal = function addChildInternal(child) {
25661
- if (!this.children.includes(child)) {
25662
- this.children.push(child);
25663
- }
25664
- };
25665
- /** @internal */ _proto.removeChildInternal = function removeChildInternal(child) {
25666
- var index = this.children.indexOf(child);
25667
- if (index !== -1) {
25668
- this.children.splice(index, 1);
25669
- }
25670
- };
25671
- _proto.drawSelf = function drawSelf() {
25672
- Control.prototype.draw.call(this);
25673
- };
25674
- _proto.draw = function draw() {
25675
- this.drawSelf();
25676
- this.drawChildren();
25677
- };
25678
- _proto.drawChildren = function drawChildren() {
25679
- var graphics = this.engine.graphics;
25680
- if (this.clipContents) ;
25681
- for(var _iterator = _create_for_of_iterator_helper_loose(this.children), _step; !(_step = _iterator()).done;){
25682
- var child = _step.value;
25683
- if (!child.visible || child.isDisposed) {
25684
- continue;
25685
- }
25686
- graphics.pushTransform(child.getTransform2D());
25687
- child.draw();
25688
- graphics.popTransform();
25689
- }
25690
- };
25691
- _proto.update = function update(deltaTime) {
25692
- Control.prototype.update.call(this, deltaTime);
25693
- for(var _iterator = _create_for_of_iterator_helper_loose(this.children.slice()), _step; !(_step = _iterator()).done;){
25694
- var child = _step.value;
25695
- if (child.enabled && !child.isDisposed) {
25696
- child.update(deltaTime);
25697
- }
25698
- }
25699
- };
25700
- _proto.dispose = function dispose() {
25701
- for(var _iterator = _create_for_of_iterator_helper_loose(this.children.slice()), _step; !(_step = _iterator()).done;){
25702
- var child = _step.value;
25703
- child.dispose();
25704
- }
25705
- Control.prototype.dispose.call(this);
25706
- };
25707
- return ContainerControl;
25708
- }(Control);
25709
- /** Base class for GUI tree roots and input dispatchers. */ var RootControl = /*#__PURE__*/ function(ContainerControl) {
25710
- _inherits(RootControl, ContainerControl);
25711
- function RootControl() {
25712
- return ContainerControl.apply(this, arguments);
25713
- }
25714
- return RootControl;
25715
- }(ContainerControl);
25716
-
25717
- var _obj$4;
25718
- var cursorNames = (_obj$4 = {}, _obj$4[CursorShape.Arrow] = "default", _obj$4[CursorShape.Ibeam] = "text", _obj$4[CursorShape.PointingHand] = "pointer", _obj$4[CursorShape.Cross] = "crosshair", _obj$4[CursorShape.Wait] = "wait", _obj$4[CursorShape.Busy] = "progress", _obj$4[CursorShape.Drag] = "grab", _obj$4[CursorShape.CanDrop] = "copy", _obj$4[CursorShape.Forbidden] = "not-allowed", _obj$4[CursorShape.Vsize] = "ns-resize", _obj$4[CursorShape.Hsize] = "ew-resize", _obj$4[CursorShape.Bdiagsize] = "nesw-resize", _obj$4[CursorShape.Fdiagsize] = "nwse-resize", _obj$4[CursorShape.Move] = "move", _obj$4[CursorShape.Vsplit] = "row-resize", _obj$4[CursorShape.Hsplit] = "col-resize", _obj$4[CursorShape.Help] = "help", _obj$4);
25719
- function getButtonMask(button) {
25720
- switch(button){
25721
- case MouseButton.Left:
25722
- return MouseButtonMask.Left;
25723
- case MouseButton.Right:
25724
- return MouseButtonMask.Right;
25725
- case MouseButton.Middle:
25726
- return MouseButtonMask.Middle;
25727
- case MouseButton.Xbutton1:
25728
- return MouseButtonMask.Xbutton1;
25729
- case MouseButton.Xbutton2:
25730
- return MouseButtonMask.Xbutton2;
25731
- default:
25732
- return MouseButtonMask.None;
25733
- }
25734
- }
25735
- function isWheelButton(button) {
25736
- return button >= MouseButton.WheelUp && button <= MouseButton.WheelRight;
25737
- }
25738
- /** CanvasLayer-like boundary for a single UICanvas GUI tree. */ var CanvasRootControl = /*#__PURE__*/ function(ContainerControl) {
25739
- _inherits(CanvasRootControl, ContainerControl);
25740
- function CanvasRootControl(engine, canvas) {
25741
- var _this;
25742
- _this = ContainerControl.call(this, engine) || this;
25743
- _this.canvas = canvas;
25744
- _this.mouseFilter = MouseFilter.Ignore;
25745
- _this.setSize(engine.canvas.width, engine.canvas.height);
25746
- return _this;
25747
- }
25748
- _create_class(CanvasRootControl, [
25749
- {
25750
- key: "inputDisabled",
25751
- get: function get() {
25752
- var _this_canvas_item;
25753
- return !this.canvas.receivesEvents || !this.canvas.enabled || !((_this_canvas_item = this.canvas.item) == null ? void 0 : _this_canvas_item.isActive);
25754
- }
25755
- }
25756
- ]);
25757
- return CanvasRootControl;
25758
- }(ContainerControl);
25759
- /** Global ordered collection of UICanvas roots. */ var CanvasContainer = /*#__PURE__*/ function(ContainerControl) {
25760
- _inherits(CanvasContainer, ContainerControl);
25761
- function CanvasContainer(engine) {
25762
- var _this;
25763
- _this = ContainerControl.call(this, engine) || this;
25764
- _this.mouseFilter = MouseFilter.Ignore;
25765
- _this.setSize(engine.canvas.width, engine.canvas.height);
25766
- return _this;
25767
- }
25768
- var _proto = CanvasContainer.prototype;
25769
- _proto.sortCanvases = function sortCanvases() {
25770
- this.children.sort(function(left, right) {
25771
- return left.canvas.order - right.canvas.order;
25772
- });
25773
- };
25774
- _proto.addChildInternal = function addChildInternal(child) {
25775
- ContainerControl.prototype.addChildInternal.call(this, child);
25776
- this.sortCanvases();
25777
- };
25778
- _proto.draw = function draw() {
25779
- this.sortCanvases();
25780
- for(var _iterator = _create_for_of_iterator_helper_loose(this.children), _step; !(_step = _iterator()).done;){
25781
- var child = _step.value;
25782
- var root = child;
25783
- if (root.canvas.isVisible) {
25784
- root.draw();
25785
- }
25786
- }
25787
- };
25788
- return CanvasContainer;
25789
- }(ContainerControl);
25790
- /** Engine window GUI root. Routes events across all UICanvas roots. */ var WindowRootControl = /*#__PURE__*/ function(RootControl) {
25791
- _inherits(WindowRootControl, RootControl);
25792
- function WindowRootControl(engine) {
25793
- var _this;
25794
- _this = RootControl.call(this, engine) || this;
25795
- _this.dragThreshold = 10;
25796
- _this.lastInput = null;
25797
- _this.gui = {
25798
- mouseFocus: null,
25799
- mouseClickGrabber: null,
25800
- mouseFocusMask: MouseButtonMask.None,
25801
- mouseOver: null,
25802
- mouseOverHierarchy: [],
25803
- touchFocus: new Map(),
25804
- keyFocus: null,
25805
- dragAccum: new Vector2(),
25806
- dragAttempted: false,
25807
- dragging: false,
25808
- dragData: null,
25809
- dragMouseOver: null,
25810
- dragSuccessful: false,
25811
- lastMousePosition: new Vector2(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY),
25812
- sendingMouseEnterExit: false,
25813
- mouseOverUpdatePending: false
25814
- };
25815
- _this.mouseFilter = MouseFilter.Ignore;
25816
- _this.setSize(engine.canvas.width, engine.canvas.height);
25817
- _this.canvases = new CanvasContainer(engine);
25818
- _this.canvases.parent = _assert_this_initialized(_this);
25819
- return _this;
25820
- }
25821
- var _proto = WindowRootControl.prototype;
25822
- _proto.pushInput = function pushInput(event) {
25823
- event.clearAccepted();
25824
- this.lastInput = event;
25825
- this.cleanupInternalState();
25826
- this.processGUIInput(event);
25827
- this.postGrabClickFocus();
25828
- };
25829
- _proto.isInputHandled = function isInputHandled() {
25830
- var _this_lastInput;
25831
- var _this_lastInput_isAccepted;
25832
- return (_this_lastInput_isAccepted = (_this_lastInput = this.lastInput) == null ? void 0 : _this_lastInput.isAccepted()) != null ? _this_lastInput_isAccepted : false;
25833
- };
25834
- _proto.getMousePosition = function getMousePosition() {
25835
- return this.gui.lastMousePosition.clone();
25836
- };
25837
- _proto.guiGetFocusOwner = function guiGetFocusOwner() {
25838
- return this.isFocusTargetUsable(this.gui.keyFocus) ? this.gui.keyFocus : null;
25839
- };
25840
- _proto.guiReleaseFocus = function guiReleaseFocus() {
25841
- this.releaseControlFocus();
25842
- };
25843
- _proto.guiIsDragging = function guiIsDragging() {
25844
- return this.gui.dragging;
25845
- };
25846
- _proto.guiGetDragData = function guiGetDragData() {
25847
- return this.gui.dragData;
25848
- };
25849
- _proto.guiIsDragSuccessful = function guiIsDragSuccessful() {
25850
- return this.gui.dragSuccessful;
25851
- };
25852
- _proto.guiCancelDrag = function guiCancelDrag() {
25853
- this.endDragging(false);
25854
- };
25855
- _proto.grabControlFocus = function grabControlFocus(control) {
25856
- if (!this.isFocusTargetUsable(control) || this.gui.keyFocus === control) {
25857
- return;
25858
- }
25859
- var previous = this.gui.keyFocus;
25860
- this.gui.keyFocus = control;
25861
- if (previous && !previous.isDisposed) {
25862
- previous.onLostFocus();
25863
- }
25864
- control.onGotFocus();
25865
- };
25866
- _proto.grabControlClickFocus = function grabControlClickFocus(control) {
25867
- var _this = this;
25868
- if (this.isControlValid(control)) {
25869
- this.gui.mouseClickGrabber = control;
25870
- queueMicrotask(function() {
25871
- return _this.postGrabClickFocus();
25872
- });
25873
- }
25874
- };
25875
- _proto.releaseControlFocus = function releaseControlFocus(control) {
25876
- var previous = this.gui.keyFocus;
25877
- if (!previous || control && previous !== control) {
25878
- return;
25879
- }
25880
- this.gui.keyFocus = null;
25881
- if (!previous.isDisposed) {
25882
- previous.onLostFocus();
25883
- }
25884
- };
25885
- _proto.warpControlMouse = function warpControlMouse(position) {
25886
- this.gui.lastMousePosition.copyFrom(position);
25887
- this.updateMouseOver(position);
25888
- this.updateMouseCursorState();
25889
- };
25890
- _proto.updateMouseCursorState = function updateMouseCursorState() {
25891
- var position = this.gui.lastMousePosition;
25892
- var target = this.isControlUsable(this.gui.mouseFocus) ? this.gui.mouseFocus : this.isControlUsable(this.gui.mouseOver) ? this.gui.mouseOver : null;
25893
- this.updateCursor(target, position);
25894
- };
25895
- _proto.controlStateChanged = function controlStateChanged(control) {
25896
- if (!this.isControlUsable(control)) {
25897
- this.dropControlState(control);
25898
- }
25899
- this.requestMouseOverUpdate();
25900
- };
25901
- _proto.controlRemoved = function controlRemoved(control) {
25902
- this.dropControlState(control);
25903
- this.cleanupInternalState();
25904
- this.requestMouseOverUpdate();
25905
- };
25906
- _proto.controlTreeChanged = function controlTreeChanged() {
25907
- this.requestMouseOverUpdate();
25908
- };
25909
- _proto.cancelPointerInput = function cancelPointerInput() {
25910
- this.dropMouseFocus();
25911
- this.dropMouseOver();
25912
- this.gui.touchFocus.clear();
25913
- this.endDragging(false);
25914
- this.releaseControlFocus();
25915
- };
25916
- _proto.resize = function resize(width, height) {
25917
- this.setSize(width, height);
25918
- this.canvases.setSize(width, height);
25919
- for(var _iterator = _create_for_of_iterator_helper_loose(this.canvases.children), _step; !(_step = _iterator()).done;){
25920
- var root = _step.value;
25921
- root.setSize(width, height);
25922
- }
25923
- };
25924
- _proto.render = function render() {
25925
- if (this.canvases.children.length === 0) {
25926
- return;
25927
- }
25928
- this.engine.graphics.begin();
25929
- this.draw();
25930
- this.engine.graphics.end();
25931
- };
25932
- _proto.update = function update(deltaTime) {
25933
- if (this.gui.mouseOverUpdatePending) {
25934
- this.gui.mouseOverUpdatePending = false;
25935
- this.updateMouseOver(this.gui.lastMousePosition);
25936
- }
25937
- RootControl.prototype.update.call(this, deltaTime);
25938
- };
25939
- _proto.dispose = function dispose() {
25940
- this.cancelPointerInput();
25941
- RootControl.prototype.dispose.call(this);
25942
- };
25943
- _proto.processGUIInput = function processGUIInput(event) {
25944
- if (_instanceof1(event, InputEventKey)) {
25945
- var target = this.guiGetFocusOwner();
25946
- if (target) {
25947
- this.callControlInput(target, event);
25948
- }
25949
- } else if (_instanceof1(event, InputEventMouse)) {
25950
- this.gui.lastMousePosition.copyFrom(event.globalPosition);
25951
- this.updateMouseOver(event.globalPosition);
25952
- if (_instanceof1(event, InputEventMouseButton)) {
25953
- this.processMouseButton(event);
25954
- } else if (_instanceof1(event, InputEventMouseMotion)) {
25955
- this.processMouseMotion(event);
25956
- }
25957
- } else if (_instanceof1(event, InputEventScreenTouch)) {
25958
- this.processScreenTouch(event);
25959
- } else if (_instanceof1(event, InputEventScreenDrag)) {
25960
- this.processScreenDrag(event);
25961
- }
25962
- };
25963
- _proto.processMouseButton = function processMouseButton(event) {
25964
- if (isWheelButton(event.buttonIndex)) {
25965
- var target = this.findInputControl(event.globalPosition);
25966
- if (target) {
25967
- this.callGUIInput(target, event);
25968
- }
25969
- return;
25970
- }
25971
- var mask = getButtonMask(event.buttonIndex);
25972
- if (event.isPressed()) {
25973
- var target1 = this.gui.mouseFocusMask !== 0 ? this.gui.mouseFocus : this.findInputControl(event.globalPosition);
25974
- this.gui.mouseFocus = target1;
25975
- if (!target1) {
25976
- return;
25977
- }
25978
- this.gui.mouseFocusMask |= mask;
25979
- if (event.buttonIndex === MouseButton.Left) {
25980
- this.gui.dragAccum.setZero();
25981
- this.gui.dragAttempted = false;
25982
- this.findClickFocus(target1);
25983
- }
25984
- this.callGUIInput(target1, event);
25985
- } else {
25986
- if (event.buttonIndex === MouseButton.Left && this.gui.dragging) {
25987
- this.finishDrop(event.globalPosition);
25988
- }
25989
- this.gui.mouseFocusMask &= ~mask;
25990
- var target2 = this.gui.mouseFocus;
25991
- if (this.gui.mouseFocusMask === 0) {
25992
- this.gui.mouseFocus = null;
25993
- }
25994
- if (this.isControlUsable(target2)) {
25995
- this.callGUIInput(target2, event);
25996
- }
25997
- }
25998
- };
25999
- _proto.processMouseMotion = function processMouseMotion(event) {
26000
- if (!this.gui.dragging && !this.gui.dragAttempted && this.gui.mouseFocus && (this.gui.mouseFocusMask & MouseButtonMask.Left) !== 0) {
26001
- this.gui.dragAccum.add(event.relative);
26002
- if (this.gui.dragAccum.length() > this.dragThreshold) {
26003
- var origin = event.globalPosition.clone().subtract(this.gui.dragAccum);
26004
- this.beginDragging(this.gui.mouseFocus, origin);
26005
- this.gui.dragAttempted = true;
26006
- }
26007
- }
26008
- var target = this.isControlUsable(this.gui.mouseFocus) ? this.gui.mouseFocus : this.findInputControl(event.globalPosition);
26009
- if (target) {
26010
- this.callGUIInput(target, event);
26011
- }
26012
- if (this.gui.dragging) {
26013
- this.gui.dragMouseOver = this.findDropTarget(this.findInputControl(event.globalPosition), event.globalPosition);
26014
- }
26015
- this.updateCursor(target, event.globalPosition);
26016
- };
26017
- _proto.processScreenTouch = function processScreenTouch(event) {
26018
- var target;
26019
- if (event.isPressed()) {
26020
- target = this.findInputControl(event.position);
26021
- if (target) {
26022
- this.gui.touchFocus.set(event.index, target);
26023
- }
26024
- } else {
26025
- var _this_gui_touchFocus_get;
26026
- target = (_this_gui_touchFocus_get = this.gui.touchFocus.get(event.index)) != null ? _this_gui_touchFocus_get : null;
26027
- this.gui.touchFocus.delete(event.index);
26028
- }
26029
- if (this.isControlUsable(target)) {
26030
- this.callGUIInput(target, event);
26031
- }
26032
- };
26033
- _proto.processScreenDrag = function processScreenDrag(event) {
26034
- var _this_gui_touchFocus_get;
26035
- var target = (_this_gui_touchFocus_get = this.gui.touchFocus.get(event.index)) != null ? _this_gui_touchFocus_get : this.findInputControl(event.position);
26036
- if (this.isControlUsable(target)) {
26037
- this.callGUIInput(target, event);
26038
- }
26039
- };
26040
- _proto.callGUIInput = function callGUIInput(target, event) {
26041
- var current = target;
26042
- var pointerEvent = _instanceof1(event, InputEventMouse) || _instanceof1(event, InputEventScreenTouch) || _instanceof1(event, InputEventScreenDrag);
26043
- while(current && current !== this && this.isControlUsable(current)){
26044
- var filter = current.getEffectiveMouseFilter();
26045
- if (filter !== MouseFilter.Ignore) {
26046
- var localEvent = event.xformedBy(this.getGlobalInverse(current));
26047
- this.callControlInput(current, localEvent);
26048
- if (localEvent.isAccepted()) {
26049
- event.accept();
26050
- }
26051
- }
26052
- var forcePassWheel = _instanceof1(event, InputEventMouseButton) && isWheelButton(event.buttonIndex) && current.mouseForcePassScrollEvents;
26053
- if (event.isAccepted() || filter === MouseFilter.Stop && pointerEvent && !forcePassWheel) {
26054
- event.accept();
26055
- return;
26056
- }
26057
- current = current.parent;
26058
- }
26059
- };
26060
- _proto.callControlInput = function callControlInput(control, event) {
26061
- if (_instanceof1(event, InputEventMouseButton)) {
26062
- if (isWheelButton(event.buttonIndex)) {
26063
- control.onMouseWheel(event);
26064
- } else if (event.isPressed()) {
26065
- control.onMouseDown(event);
26066
- } else {
26067
- control.onMouseUp(event);
26068
- }
26069
- } else if (_instanceof1(event, InputEventMouseMotion)) {
26070
- control.onMouseMove(event);
26071
- } else if (_instanceof1(event, InputEventScreenTouch)) {
26072
- if (event.isPressed()) {
26073
- control.onTouchDown(event);
26074
- } else {
26075
- control.onTouchUp(event);
26076
- }
26077
- } else if (_instanceof1(event, InputEventScreenDrag)) {
26078
- control.onTouchMove(event);
26079
- } else if (_instanceof1(event, InputEventKey)) {
26080
- if (event.isPressed()) {
26081
- control.onKeyDown(event);
26082
- } else if (event.isReleased()) {
26083
- control.onKeyUp(event);
26084
- }
26085
- }
26086
- };
26087
- _proto.findInputControl = function findInputControl(position) {
26088
- this.canvases.sortCanvases();
26089
- for(var index = this.canvases.children.length - 1; index >= 0; index--){
26090
- var root = this.canvases.children[index];
26091
- if (!root.canvas.isVisible || root.inputDisabled) {
26092
- continue;
26093
- }
26094
- var target = this.findControlAtPosition(root, position, true);
26095
- if (target) {
26096
- return target;
26097
- }
26098
- }
26099
- return null;
26100
- };
26101
- _proto.findControlAtPosition = function findControlAtPosition(container, position, skipSelf) {
26102
- if (skipSelf === void 0) skipSelf = false;
26103
- if (!container.visibleInHierarchy || container.isDisposed) {
26104
- return null;
26105
- }
26106
- var localPosition = this.toLocal(container, position);
26107
- if (container.clipContents && !container.hasPoint(localPosition)) {
26108
- return null;
26109
- }
26110
- for(var index = container.children.length - 1; index >= 0; index--){
26111
- var child = container.children[index];
26112
- if (!child.visibleInHierarchy || child.isDisposed) {
26113
- continue;
26114
- }
26115
- if (_instanceof1(child, ContainerControl)) {
26116
- var found = this.findControlAtPosition(child, position);
26117
- if (found) {
26118
- return found;
26119
- }
26120
- } else if (child.getEffectiveMouseFilter() !== MouseFilter.Ignore && child.hasPoint(this.toLocal(child, position))) {
26121
- return child;
26122
- }
26123
- }
26124
- if (!skipSelf && container.getEffectiveMouseFilter() !== MouseFilter.Ignore && container.hasPoint(localPosition)) {
26125
- return container;
26126
- }
26127
- return null;
26128
- };
26129
- _proto.updateMouseOver = function updateMouseOver(position) {
26130
- if (this.gui.sendingMouseEnterExit) {
26131
- this.gui.mouseOverUpdatePending = true;
26132
- return;
26133
- }
26134
- this.gui.mouseOverUpdatePending = false;
26135
- var target = this.findInputControl(position);
26136
- var next = this.buildHoverHierarchy(target);
26137
- var previous = this.gui.mouseOverHierarchy;
26138
- var common = 0;
26139
- while(common < previous.length && common < next.length && previous[common] === next[common]){
26140
- common++;
26141
- }
26142
- this.gui.sendingMouseEnterExit = true;
26143
- for(var index = previous.length - 1; index >= common; index--){
26144
- if (!previous[index].isDisposed) {
26145
- previous[index].onMouseLeave();
26146
- }
26147
- }
26148
- for(var index1 = common; index1 < next.length; index1++){
26149
- next[index1].onMouseEnter(this.toLocal(next[index1], position));
26150
- }
26151
- this.gui.sendingMouseEnterExit = false;
26152
- this.gui.mouseOver = target;
26153
- this.gui.mouseOverHierarchy = next;
26154
- };
26155
- _proto.buildHoverHierarchy = function buildHoverHierarchy(target) {
26156
- var hierarchy = [];
26157
- var current = target;
26158
- while(current && current !== this){
26159
- if (current.getEffectiveMouseFilter() !== MouseFilter.Ignore) {
26160
- hierarchy.push(current);
26161
- }
26162
- if (current.getEffectiveMouseFilter() === MouseFilter.Stop) {
26163
- break;
26164
- }
26165
- current = current.parent;
26166
- }
26167
- hierarchy.reverse();
26168
- return hierarchy;
26169
- };
26170
- _proto.findClickFocus = function findClickFocus(target) {
26171
- var current = target;
26172
- while(current && current !== this){
26173
- var mode = current.getFocusModeWithOverride();
26174
- if (mode === FocusMode.Click || mode === FocusMode.All) {
26175
- this.grabControlFocus(current);
26176
- return;
26177
- }
26178
- if (current.getEffectiveMouseFilter() === MouseFilter.Stop) {
26179
- return;
26180
- }
26181
- current = current.parent;
26182
- }
26183
- };
26184
- _proto.beginDragging = function beginDragging(source, position) {
26185
- var current = source;
26186
- while(current && current !== this){
26187
- var data = current.invokeGetDragData(this.toLocal(current, position));
26188
- if (data !== null && data !== undefined) {
26189
- this.gui.dragging = true;
26190
- this.gui.dragData = data;
26191
- this.gui.mouseFocus = null;
26192
- this.gui.mouseFocusMask = MouseButtonMask.None;
26193
- return;
26194
- }
26195
- if (current.getEffectiveMouseFilter() === MouseFilter.Stop) {
26196
- return;
26197
- }
26198
- current = current.parent;
26199
- }
26200
- };
26201
- _proto.finishDrop = function finishDrop(position) {
26202
- var target = this.findDropTarget(this.findInputControl(position), position);
26203
- if (target) {
26204
- target.invokeDropData(this.toLocal(target, position), this.gui.dragData);
26205
- }
26206
- this.endDragging(!!target);
26207
- };
26208
- _proto.findDropTarget = function findDropTarget(target, position) {
26209
- var current = target;
26210
- while(current && current !== this){
26211
- if (current.invokeCanDropData(this.toLocal(current, position), this.gui.dragData)) {
26212
- return current;
26213
- }
26214
- if (current.getEffectiveMouseFilter() === MouseFilter.Stop) {
26215
- return null;
26216
- }
26217
- current = current.parent;
26218
- }
26219
- return null;
26220
- };
26221
- _proto.endDragging = function endDragging(successful) {
26222
- this.gui.dragSuccessful = successful;
26223
- this.gui.dragging = false;
26224
- this.gui.dragData = null;
26225
- this.gui.dragMouseOver = null;
26226
- };
26227
- _proto.updateCursor = function updateCursor(target, position) {
26228
- var current = target;
26229
- var cursor = CursorShape.Arrow;
26230
- while(current && current !== this){
26231
- var candidate = current.getCursorShape(this.toLocal(current, position));
26232
- if (candidate !== CursorShape.Arrow) {
26233
- cursor = candidate;
26234
- break;
26235
- }
26236
- if (current.getEffectiveMouseFilter() === MouseFilter.Stop) {
26237
- break;
26238
- }
26239
- current = current.parent;
26240
- }
26241
- this.engine.canvas.style.cursor = typeof cursor === "string" ? cursor : cursorNames[cursor];
26242
- };
26243
- _proto.postGrabClickFocus = function postGrabClickFocus() {
26244
- var target = this.gui.mouseClickGrabber;
26245
- this.gui.mouseClickGrabber = null;
26246
- if (this.isControlUsable(target)) {
26247
- this.gui.mouseFocus = target;
26248
- }
26249
- };
26250
- _proto.cleanupInternalState = function cleanupInternalState() {
26251
- if (!this.isControlUsable(this.gui.mouseFocus)) {
26252
- this.dropMouseFocus();
26253
- }
26254
- if (this.gui.keyFocus && !this.isFocusTargetUsable(this.gui.keyFocus)) {
26255
- this.releaseControlFocus(this.gui.keyFocus);
26256
- }
26257
- for(var _iterator = _create_for_of_iterator_helper_loose(this.gui.touchFocus), _step; !(_step = _iterator()).done;){
26258
- var _step_value = _step.value, index = _step_value[0], control = _step_value[1];
26259
- if (!this.isControlUsable(control)) {
26260
- this.gui.touchFocus.delete(index);
26261
- }
26262
- }
26263
- };
26264
- _proto.dropMouseFocus = function dropMouseFocus() {
26265
- this.gui.mouseFocus = null;
26266
- this.gui.mouseFocusMask = MouseButtonMask.None;
26267
- };
26268
- _proto.dropMouseOver = function dropMouseOver() {
26269
- for(var index = this.gui.mouseOverHierarchy.length - 1; index >= 0; index--){
26270
- var control = this.gui.mouseOverHierarchy[index];
26271
- if (!control.isDisposed) {
26272
- control.onMouseLeave();
26273
- }
26274
- }
26275
- this.gui.mouseOver = null;
26276
- this.gui.mouseOverHierarchy = [];
26277
- };
26278
- _proto.dropControlState = function dropControlState(control) {
26279
- if (this.controlBelongsToSubtree(this.gui.mouseFocus, control)) {
26280
- this.dropMouseFocus();
26281
- }
26282
- if (this.controlBelongsToSubtree(this.gui.mouseClickGrabber, control)) {
26283
- this.gui.mouseClickGrabber = null;
26284
- }
26285
- if (this.controlBelongsToSubtree(this.gui.keyFocus, control)) {
26286
- var _this_gui_keyFocus;
26287
- this.releaseControlFocus((_this_gui_keyFocus = this.gui.keyFocus) != null ? _this_gui_keyFocus : undefined);
26288
- }
26289
- if (this.controlBelongsToSubtree(this.gui.mouseOver, control)) {
26290
- this.dropMouseOver();
26291
- }
26292
- if (this.controlBelongsToSubtree(this.gui.dragMouseOver, control)) {
26293
- this.gui.dragMouseOver = null;
26294
- }
26295
- for(var _iterator = _create_for_of_iterator_helper_loose(this.gui.touchFocus), _step; !(_step = _iterator()).done;){
26296
- var _step_value = _step.value, index = _step_value[0], target = _step_value[1];
26297
- if (this.controlBelongsToSubtree(target, control)) {
26298
- this.gui.touchFocus.delete(index);
26299
- }
26300
- }
26301
- };
26302
- _proto.requestMouseOverUpdate = function requestMouseOverUpdate() {
26303
- if (Number.isFinite(this.gui.lastMousePosition.x)) {
26304
- this.updateMouseOver(this.gui.lastMousePosition);
26305
- }
26306
- };
26307
- _proto.getGlobalInverse = function getGlobalInverse(control) {
26308
- var transform = control.getGlobalTransform2D().clone();
26309
- return Math.abs(transform.determinant()) < 1e-12 ? new Matrix3() : transform.invert();
26310
- };
26311
- _proto.toLocal = function toLocal(control, position) {
26312
- var elements = this.getGlobalInverse(control).elements;
26313
- return new Vector2(elements[0] * position.x + elements[3] * position.y + elements[6], elements[1] * position.x + elements[4] * position.y + elements[7]);
26314
- };
26315
- _proto.controlBelongsToSubtree = function controlBelongsToSubtree(control, subtree) {
26316
- var current = control;
26317
- while(current){
26318
- if (current === subtree) {
26319
- return true;
26320
- }
26321
- current = current.parent;
26322
- }
26323
- return false;
26324
- };
26325
- _proto.isControlValid = function isControlValid(control) {
26326
- return !!control && !control.isDisposed && control.root === this;
26327
- };
26328
- _proto.isControlUsable = function isControlUsable(control) {
26329
- if (!this.isControlValid(control) || !control.visibleInHierarchy || !control.enabledInHierarchy) {
26330
- return false;
26331
- }
26332
- var root = this.findCanvasRoot(control);
26333
- return !root || !root.inputDisabled;
26334
- };
26335
- _proto.findCanvasRoot = function findCanvasRoot(control) {
26336
- var current = control;
26337
- while(current && current !== this){
26338
- if (_instanceof1(current, CanvasRootControl)) {
26339
- return current;
26340
- }
26341
- current = current.parent;
26342
- }
26343
- return null;
26344
- };
26345
- _proto.isFocusTargetUsable = function isFocusTargetUsable(control) {
26346
- return this.isControlUsable(control) && control.getFocusModeWithOverride() !== FocusMode.None;
26347
- };
26348
- return WindowRootControl;
26349
- }(RootControl);
26350
-
26351
- var CanvasRenderMode;
26352
- (function(CanvasRenderMode) {
26353
- CanvasRenderMode[CanvasRenderMode["ScreenSpace"] = 0] = "ScreenSpace";
26354
- CanvasRenderMode[CanvasRenderMode["CameraSpace"] = 1] = "CameraSpace";
26355
- CanvasRenderMode[CanvasRenderMode["WorldSpace"] = 2] = "WorldSpace";
26356
- CanvasRenderMode[CanvasRenderMode["WorldSpaceFaceCamera"] = 3] = "WorldSpaceFaceCamera";
26357
- })(CanvasRenderMode || (CanvasRenderMode = {}));
26358
- /** Canvas-layer boundary attached to a VFXItem. Input state remains owned by the window root. */ var UICanvas = /*#__PURE__*/ function(Component) {
26359
- _inherits(UICanvas, Component);
26360
- function UICanvas(engine) {
26361
- var _this;
26362
- _this = Component.call(this, engine) || this;
26363
- _this.renderMode = 0;
26364
- _this.receivesEvents = true;
26365
- _this._order = 0;
26366
- _this.registered = false;
26367
- _this.rootControl = new CanvasRootControl(engine, _assert_this_initialized(_this));
26368
- return _this;
26369
- }
26370
- var _proto = UICanvas.prototype;
26371
- _proto.onEnable = function onEnable() {
26372
- this.register();
26373
- };
26374
- _proto.onDisable = function onDisable() {
26375
- this.unregister();
26376
- };
26377
- _proto.onDestroy = function onDestroy() {
26378
- this.destroyCanvas();
26379
- };
26380
- _proto.dispose = function dispose() {
26381
- this.destroyCanvas();
26382
- Component.prototype.dispose.call(this);
26383
- };
26384
- _proto.register = function register() {
26385
- if (!this.registered) {
26386
- this.rootControl.parent = this.engine.windowRoot.canvases;
26387
- this.registered = true;
26388
- }
26389
- };
26390
- _proto.unregister = function unregister() {
26391
- if (this.registered) {
26392
- this.rootControl.parent = null;
26393
- this.registered = false;
26394
- }
26395
- };
26396
- _proto.destroyCanvas = function destroyCanvas() {
26397
- this.unregister();
26398
- if (!this.rootControl.isDisposed) {
26399
- this.rootControl.dispose();
26400
- }
26401
- };
26402
- _create_class(UICanvas, [
26403
- {
26404
- key: "order",
26405
- get: function get() {
26406
- return this._order;
26407
- },
26408
- set: function set(value) {
26409
- if (this._order !== value) {
26410
- this._order = value;
26411
- this.engine.windowRoot.canvases.sortCanvases();
26412
- }
26413
- }
26414
- },
26415
- {
26416
- key: "isVisible",
26417
- get: function get() {
26418
- var _this_item;
26419
- return this.renderMode === 0 && this.enabled && !!((_this_item = this.item) == null ? void 0 : _this_item.isActive);
26420
- }
26421
- }
26422
- ]);
26423
- return UICanvas;
26424
- }(Component);
26425
-
26426
- /**
26427
- * Scene-tree bridge for a GUI Control. The VFXItem tree owns lifecycle and
26428
- * serialization while the Control tree owns layout, drawing and input.
26429
- */ var UIControl = /*#__PURE__*/ function(Component) {
26430
- _inherits(UIControl, Component);
26431
- function UIControl(engine) {
26432
- var _this;
26433
- _this = Component.call(this, engine) || this;
26434
- _this.controlNode = null;
26435
- _this.linkedItemTransform = null;
26436
- _this.linkedControl = null;
26437
- _this.syncingLocation = false;
26438
- _this.itemTransformChanged = function() {
26439
- return _this.syncItemLocationToControl();
26440
- };
26441
- _this.controlLocationChanged = function() {
26442
- return _this.syncControlLocationToItem();
26443
- };
26444
- return _this;
26445
- }
26446
- var _proto = UIControl.prototype;
26447
- _proto.onAwake = function onAwake() {
26448
- this.syncControl();
26449
- };
26450
- _proto.onEnable = function onEnable() {
26451
- if (this.controlNode) {
26452
- this.controlNode.visible = this.item.isActive;
26453
- this.controlNode.enabled = true;
26454
- }
26455
- };
26456
- _proto.onDisable = function onDisable() {
26457
- if (this.controlNode) {
26458
- this.controlNode.visible = this.item.isActive;
26459
- this.controlNode.enabled = false;
26460
- }
26461
- };
26462
- _proto.onParentChanged = function onParentChanged() {
26463
- this.syncControl();
26464
- };
26465
- _proto.onOrderInParentChanged = function onOrderInParentChanged() {
26466
- this.syncControlOrder();
26467
- };
26468
- _proto.onDestroy = function onDestroy() {
26469
- this.disposeControl();
26470
- };
26471
- _proto.dispose = function dispose() {
26472
- this.disposeControl();
26473
- Component.prototype.dispose.call(this);
26474
- };
26475
- /** Unlinks the GUI object without disposing or modifying it. */ _proto.unlinkControl = function unlinkControl() {
26476
- if (this.controlNode) {
26477
- this.unbindLocationSync();
26478
- this.controlNode = null;
26479
- }
26480
- };
26481
- _proto.disposeControl = function disposeControl() {
26482
- var control = this.controlNode;
26483
- if (control) {
26484
- this.unbindLocationSync();
26485
- this.controlNode = null;
26486
- control.dispose();
26487
- }
26488
- };
26489
- _proto.syncControl = function syncControl() {
26490
- var control = this.controlNode;
26491
- if (!control || !this.item) {
26492
- return;
26493
- }
26494
- this.syncingLocation = true;
26495
- try {
26496
- control.visible = this.item.isActive;
26497
- control.enabled = this.enabled;
26498
- control.parent = this.resolveParent();
26499
- this.syncControlOrder();
26500
- this.copyItemLocationToControl();
26501
- } finally{
26502
- this.syncingLocation = false;
26503
- }
26504
- this.bindLocationSync();
26505
- };
26506
- _proto.syncControlOrder = function syncControlOrder() {
26507
- if (this.controlNode && this.item) {
26508
- this.controlNode.indexInParent = this.item.orderInParent;
26509
- }
26510
- };
26511
- _proto.resolveParent = function resolveParent() {
26512
- var parentItem = this.item.parent;
26513
- if (!parentItem) {
26514
- var _UIControl_fallbackParentGetDelegate;
26515
- return (_UIControl_fallbackParentGetDelegate = UIControl.fallbackParentGetDelegate == null ? void 0 : UIControl.fallbackParentGetDelegate.call(UIControl, this)) != null ? _UIControl_fallbackParentGetDelegate : null;
26516
- }
26517
- var uiControl = parentItem.getComponent(UIControl);
26518
- if ((uiControl == null ? void 0 : uiControl.control) && "children" in uiControl.control) {
26519
- return uiControl.control;
26520
- }
26521
- var canvas = parentItem.getComponent(UICanvas);
26522
- var _canvas_rootControl, _ref;
26523
- 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;
26524
- };
26525
- _proto.bindLocationSync = function bindLocationSync() {
26526
- var itemTransform = this.item.transform;
26527
- var control = this.controlNode;
26528
- if (this.linkedItemTransform === itemTransform && this.linkedControl === control) {
26529
- return;
26530
- }
26531
- this.unbindLocationSync();
26532
- if (control) {
26533
- this.linkedItemTransform = itemTransform;
26534
- this.linkedControl = control;
26535
- itemTransform.on("changed", this.itemTransformChanged);
26536
- control.on("locationChanged", this.controlLocationChanged);
26537
- }
26538
- };
26539
- _proto.unbindLocationSync = function unbindLocationSync() {
26540
- var _this_linkedItemTransform, _this_linkedControl;
26541
- (_this_linkedItemTransform = this.linkedItemTransform) == null ? void 0 : _this_linkedItemTransform.off("changed", this.itemTransformChanged);
26542
- (_this_linkedControl = this.linkedControl) == null ? void 0 : _this_linkedControl.off("locationChanged", this.controlLocationChanged);
26543
- this.linkedItemTransform = null;
26544
- this.linkedControl = null;
26545
- };
26546
- _proto.syncItemLocationToControl = function syncItemLocationToControl() {
26547
- if (!this.syncingLocation && this.controlNode) {
26548
- this.syncingLocation = true;
26549
- try {
26550
- this.copyItemLocationToControl();
26551
- } finally{
26552
- this.syncingLocation = false;
26553
- }
26554
- }
26555
- };
26556
- _proto.syncControlLocationToItem = function syncControlLocationToItem() {
26557
- var control = this.controlNode;
26558
- if (!this.syncingLocation && control) {
26559
- var source = control.location;
26560
- var target = this.item.transform.position;
26561
- if (source.x !== target.x || source.y !== target.y) {
26562
- this.syncingLocation = true;
26563
- try {
26564
- this.item.transform.setPosition(source.x, source.y, target.z);
26565
- } finally{
26566
- this.syncingLocation = false;
26567
- }
26568
- }
26569
- }
26570
- };
26571
- _proto.copyItemLocationToControl = function copyItemLocationToControl() {
26572
- var control = this.controlNode;
26573
- if (control) {
26574
- var source = this.item.transform.position;
26575
- var target = control.location;
26576
- if (source.x !== target.x || source.y !== target.y) {
26577
- control.setPosition(source.x, source.y);
26578
- }
26579
- }
26580
- };
26581
- _create_class(UIControl, [
26582
- {
26583
- key: "control",
26584
- get: function get() {
26585
- return this.controlNode;
26586
- },
26587
- set: function set(value) {
26588
- if (value === this.controlNode) {
26589
- return;
26590
- }
26591
- this.disposeControl();
26592
- if (value) {
26593
- if (value.owner && value.owner !== this && value.owner.control === value) {
26594
- throw new Error("A Control can only be owned by one UIControl.");
26595
- }
26596
- this.controlNode = value;
26597
- value.owner = this;
26598
- this.syncControl();
26599
- }
26600
- }
26601
- },
26602
- {
26603
- key: "hasControl",
26604
- get: function get() {
26605
- return this.controlNode !== null;
26606
- }
26607
- }
26608
- ]);
26609
- return UIControl;
26610
- }(Component);
26611
-
26612
24821
  var CameraController = /*#__PURE__*/ function(Component) {
26613
24822
  _inherits(CameraController, Component);
26614
24823
  function CameraController(engine, props) {
@@ -26643,6 +24852,42 @@ CameraController = __decorate([
26643
24852
  effectsClass(DataType.CameraController)
26644
24853
  ], CameraController);
26645
24854
 
24855
+ function _get_prototype_of(o) {
24856
+ _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
24857
+ return o.__proto__ || Object.getPrototypeOf(o);
24858
+ };
24859
+ return _get_prototype_of(o);
24860
+ }
24861
+
24862
+ function _is_native_function(fn) {
24863
+ return Function.toString.call(fn).indexOf("[native code]") !== -1;
24864
+ }
24865
+
24866
+ function _wrap_native_super(Class) {
24867
+ var _cache = typeof Map === "function" ? new Map() : undefined;
24868
+ _wrap_native_super = function _wrap_native_super(Class) {
24869
+ if (Class === null || !_is_native_function(Class)) return Class;
24870
+ if (typeof Class !== "function") throw new TypeError("Super expression must either be null or a function");
24871
+ if (typeof _cache !== "undefined") {
24872
+ if (_cache.has(Class)) return _cache.get(Class);
24873
+ _cache.set(Class, Wrapper);
24874
+ }
24875
+ function Wrapper() {
24876
+ return _construct(Class, arguments, _get_prototype_of(this).constructor);
24877
+ }
24878
+ Wrapper.prototype = Object.create(Class.prototype, {
24879
+ constructor: {
24880
+ value: Wrapper,
24881
+ enumerable: false,
24882
+ writable: true,
24883
+ configurable: true
24884
+ }
24885
+ });
24886
+ return _set_prototype_of(Wrapper, Class);
24887
+ };
24888
+ return _wrap_native_super(Class);
24889
+ }
24890
+
26646
24891
  var CameraVFXItemLoader = /*#__PURE__*/ function(Plugin) {
26647
24892
  _inherits(CameraVFXItemLoader, Plugin);
26648
24893
  function CameraVFXItemLoader() {
@@ -26651,6 +24896,255 @@ var CameraVFXItemLoader = /*#__PURE__*/ function(Plugin) {
26651
24896
  return CameraVFXItemLoader;
26652
24897
  }(_wrap_native_super(Plugin));
26653
24898
 
24899
+ var MouseButton;
24900
+ (function(MouseButton) {
24901
+ MouseButton[MouseButton["None"] = 0] = "None";
24902
+ MouseButton[MouseButton["Left"] = 1] = "Left";
24903
+ MouseButton[MouseButton["Right"] = 2] = "Right";
24904
+ MouseButton[MouseButton["Middle"] = 3] = "Middle";
24905
+ MouseButton[MouseButton["WheelUp"] = 4] = "WheelUp";
24906
+ MouseButton[MouseButton["WheelDown"] = 5] = "WheelDown";
24907
+ MouseButton[MouseButton["WheelLeft"] = 6] = "WheelLeft";
24908
+ MouseButton[MouseButton["WheelRight"] = 7] = "WheelRight";
24909
+ MouseButton[MouseButton["Xbutton1"] = 8] = "Xbutton1";
24910
+ MouseButton[MouseButton["Xbutton2"] = 9] = "Xbutton2";
24911
+ })(MouseButton || (MouseButton = {}));
24912
+ var MouseButtonMask;
24913
+ (function(MouseButtonMask) {
24914
+ MouseButtonMask[MouseButtonMask["None"] = 0] = "None";
24915
+ MouseButtonMask[MouseButtonMask["Left"] = 1] = "Left";
24916
+ MouseButtonMask[MouseButtonMask["Right"] = 2] = "Right";
24917
+ MouseButtonMask[MouseButtonMask["Middle"] = 4] = "Middle";
24918
+ MouseButtonMask[MouseButtonMask["Xbutton1"] = 128] = "Xbutton1";
24919
+ MouseButtonMask[MouseButtonMask["Xbutton2"] = 256] = "Xbutton2";
24920
+ })(MouseButtonMask || (MouseButtonMask = {}));
24921
+ var KeyLocation;
24922
+ (function(KeyLocation) {
24923
+ KeyLocation[KeyLocation["Unspecified"] = 0] = "Unspecified";
24924
+ KeyLocation[KeyLocation["Left"] = 1] = "Left";
24925
+ KeyLocation[KeyLocation["Right"] = 2] = "Right";
24926
+ })(KeyLocation || (KeyLocation = {}));
24927
+
24928
+ function transformPoint(transform, value) {
24929
+ var elements = transform.elements;
24930
+ return new Vector2(elements[0] * value.x + elements[3] * value.y + elements[6], elements[1] * value.x + elements[4] * value.y + elements[7]);
24931
+ }
24932
+ function transformVector(transform, value) {
24933
+ var elements = transform.elements;
24934
+ return new Vector2(elements[0] * value.x + elements[3] * value.y, elements[1] * value.x + elements[4] * value.y);
24935
+ }
24936
+ var InputEvent = /*#__PURE__*/ function() {
24937
+ function InputEvent() {
24938
+ this.device = 0;
24939
+ this.pressed = false;
24940
+ this.canceled = false;
24941
+ this._accepted = false;
24942
+ }
24943
+ var _proto = InputEvent.prototype;
24944
+ _proto.accept = function accept() {
24945
+ this._accepted = true;
24946
+ };
24947
+ _proto.clearAccepted = function clearAccepted() {
24948
+ this._accepted = false;
24949
+ };
24950
+ _proto.isAccepted = function isAccepted() {
24951
+ return this._accepted;
24952
+ };
24953
+ _proto.isPressed = function isPressed() {
24954
+ return this.pressed && !this.canceled;
24955
+ };
24956
+ _proto.isReleased = function isReleased() {
24957
+ return !this.pressed && !this.canceled;
24958
+ };
24959
+ _proto.isCanceled = function isCanceled() {
24960
+ return this.canceled;
24961
+ };
24962
+ _proto.isEcho = function isEcho() {
24963
+ return false;
24964
+ };
24965
+ _proto.xformedBy = function xformedBy(transform) {
24966
+ return this;
24967
+ };
24968
+ return InputEvent;
24969
+ }();
24970
+ InputEvent.deviceIdEmulation = -1;
24971
+ InputEvent.deviceIdInternal = -2;
24972
+ InputEvent.deviceIdKeyboard = 16;
24973
+ InputEvent.deviceIdMouse = 32;
24974
+ var InputEventWithModifiers = /*#__PURE__*/ function(InputEvent) {
24975
+ _inherits(InputEventWithModifiers, InputEvent);
24976
+ function InputEventWithModifiers() {
24977
+ var _this;
24978
+ _this = InputEvent.apply(this, arguments) || this;
24979
+ _this.commandOrControlAutoremap = false;
24980
+ _this.shiftPressed = false;
24981
+ _this.altPressed = false;
24982
+ _this.metaPressed = false;
24983
+ _this.ctrlPressed = false;
24984
+ return _this;
24985
+ }
24986
+ var _proto = InputEventWithModifiers.prototype;
24987
+ _proto.copyModifiersTo = function copyModifiersTo(event) {
24988
+ event.device = this.device;
24989
+ event.pressed = this.pressed;
24990
+ event.canceled = this.canceled;
24991
+ event.commandOrControlAutoremap = this.commandOrControlAutoremap;
24992
+ event.shiftPressed = this.shiftPressed;
24993
+ event.altPressed = this.altPressed;
24994
+ event.metaPressed = this.metaPressed;
24995
+ event.ctrlPressed = this.ctrlPressed;
24996
+ };
24997
+ return InputEventWithModifiers;
24998
+ }(_wrap_native_super(InputEvent));
24999
+ var InputEventKey = /*#__PURE__*/ function(InputEventWithModifiers) {
25000
+ _inherits(InputEventKey, InputEventWithModifiers);
25001
+ function InputEventKey() {
25002
+ var _this;
25003
+ _this = InputEventWithModifiers.apply(this, arguments) || this;
25004
+ _this.keycode = "";
25005
+ _this.physicalKeycode = "";
25006
+ _this.keyLabel = "";
25007
+ _this.unicode = 0;
25008
+ _this.location = KeyLocation.Unspecified;
25009
+ _this.echo = false;
25010
+ return _this;
25011
+ }
25012
+ var _proto = InputEventKey.prototype;
25013
+ _proto.isEcho = function isEcho() {
25014
+ return this.echo;
25015
+ };
25016
+ return InputEventKey;
25017
+ }(InputEventWithModifiers);
25018
+ var InputEventMouse = /*#__PURE__*/ function(InputEventWithModifiers) {
25019
+ _inherits(InputEventMouse, InputEventWithModifiers);
25020
+ function InputEventMouse() {
25021
+ var _this;
25022
+ _this = InputEventWithModifiers.apply(this, arguments) || this;
25023
+ _this.buttonMask = MouseButtonMask.None;
25024
+ _this.position = new Vector2();
25025
+ _this.globalPosition = new Vector2();
25026
+ return _this;
25027
+ }
25028
+ var _proto = InputEventMouse.prototype;
25029
+ _proto.copyMouseTo = function copyMouseTo(event) {
25030
+ this.copyModifiersTo(event);
25031
+ event.buttonMask = this.buttonMask;
25032
+ event.position.copyFrom(this.position);
25033
+ event.globalPosition.copyFrom(this.globalPosition);
25034
+ };
25035
+ return InputEventMouse;
25036
+ }(InputEventWithModifiers);
25037
+ var InputEventMouseButton = /*#__PURE__*/ function(InputEventMouse) {
25038
+ _inherits(InputEventMouseButton, InputEventMouse);
25039
+ function InputEventMouseButton() {
25040
+ var _this;
25041
+ _this = InputEventMouse.apply(this, arguments) || this;
25042
+ _this.factor = 1;
25043
+ _this.buttonIndex = MouseButton.None;
25044
+ _this.doubleClick = false;
25045
+ return _this;
25046
+ }
25047
+ var _proto = InputEventMouseButton.prototype;
25048
+ _proto.xformedBy = function xformedBy(transform) {
25049
+ var event = new InputEventMouseButton();
25050
+ this.copyMouseTo(event);
25051
+ event.position.copyFrom(transformPoint(transform, this.position));
25052
+ event.factor = this.factor;
25053
+ event.buttonIndex = this.buttonIndex;
25054
+ event.doubleClick = this.doubleClick;
25055
+ return event;
25056
+ };
25057
+ return InputEventMouseButton;
25058
+ }(InputEventMouse);
25059
+ var InputEventMouseMotion = /*#__PURE__*/ function(InputEventMouse) {
25060
+ _inherits(InputEventMouseMotion, InputEventMouse);
25061
+ function InputEventMouseMotion() {
25062
+ var _this;
25063
+ _this = InputEventMouse.apply(this, arguments) || this;
25064
+ _this.tilt = new Vector2();
25065
+ _this.pressure = 0;
25066
+ _this.relative = new Vector2();
25067
+ _this.screenRelative = new Vector2();
25068
+ _this.velocity = new Vector2();
25069
+ _this.screenVelocity = new Vector2();
25070
+ _this.penInverted = false;
25071
+ return _this;
25072
+ }
25073
+ var _proto = InputEventMouseMotion.prototype;
25074
+ _proto.xformedBy = function xformedBy(transform) {
25075
+ var event = new InputEventMouseMotion();
25076
+ this.copyMouseTo(event);
25077
+ event.position.copyFrom(transformPoint(transform, this.position));
25078
+ event.tilt.copyFrom(this.tilt);
25079
+ event.pressure = this.pressure;
25080
+ event.relative.copyFrom(transformVector(transform, this.relative));
25081
+ event.screenRelative.copyFrom(this.screenRelative);
25082
+ event.velocity.copyFrom(transformVector(transform, this.velocity));
25083
+ event.screenVelocity.copyFrom(this.screenVelocity);
25084
+ event.penInverted = this.penInverted;
25085
+ return event;
25086
+ };
25087
+ return InputEventMouseMotion;
25088
+ }(InputEventMouse);
25089
+ var InputEventScreenTouch = /*#__PURE__*/ function(InputEvent) {
25090
+ _inherits(InputEventScreenTouch, InputEvent);
25091
+ function InputEventScreenTouch() {
25092
+ var _this;
25093
+ _this = InputEvent.apply(this, arguments) || this;
25094
+ _this.index = 0;
25095
+ _this.position = new Vector2();
25096
+ _this.doubleTap = false;
25097
+ return _this;
25098
+ }
25099
+ var _proto = InputEventScreenTouch.prototype;
25100
+ _proto.xformedBy = function xformedBy(transform) {
25101
+ var event = new InputEventScreenTouch();
25102
+ event.device = this.device;
25103
+ event.pressed = this.pressed;
25104
+ event.canceled = this.canceled;
25105
+ event.index = this.index;
25106
+ event.position.copyFrom(transformPoint(transform, this.position));
25107
+ event.doubleTap = this.doubleTap;
25108
+ return event;
25109
+ };
25110
+ return InputEventScreenTouch;
25111
+ }(_wrap_native_super(InputEvent));
25112
+ var InputEventScreenDrag = /*#__PURE__*/ function(InputEvent) {
25113
+ _inherits(InputEventScreenDrag, InputEvent);
25114
+ function InputEventScreenDrag() {
25115
+ var _this;
25116
+ _this = InputEvent.apply(this, arguments) || this;
25117
+ _this.index = 0;
25118
+ _this.position = new Vector2();
25119
+ _this.relative = new Vector2();
25120
+ _this.screenRelative = new Vector2();
25121
+ _this.velocity = new Vector2();
25122
+ _this.screenVelocity = new Vector2();
25123
+ _this.pressure = 0;
25124
+ _this.tilt = new Vector2();
25125
+ _this.penInverted = false;
25126
+ return _this;
25127
+ }
25128
+ var _proto = InputEventScreenDrag.prototype;
25129
+ _proto.xformedBy = function xformedBy(transform) {
25130
+ var event = new InputEventScreenDrag();
25131
+ event.device = this.device;
25132
+ event.pressed = this.pressed;
25133
+ event.canceled = this.canceled;
25134
+ event.index = this.index;
25135
+ event.position.copyFrom(transformPoint(transform, this.position));
25136
+ event.relative.copyFrom(transformVector(transform, this.relative));
25137
+ event.screenRelative.copyFrom(this.screenRelative);
25138
+ event.velocity.copyFrom(transformVector(transform, this.velocity));
25139
+ event.screenVelocity.copyFrom(this.screenVelocity);
25140
+ event.pressure = this.pressure;
25141
+ event.tilt.copyFrom(this.tilt);
25142
+ event.penInverted = this.penInverted;
25143
+ return event;
25144
+ };
25145
+ return InputEventScreenDrag;
25146
+ }(_wrap_native_super(InputEvent));
25147
+
26654
25148
  var EVENT_TYPE_CLICK = "click";
26655
25149
  var EVENT_TYPE_TOUCH_START = "touchstart";
26656
25150
  var EVENT_TYPE_TOUCH_MOVE = "touchmove";
@@ -26661,49 +25155,52 @@ var PointerEventType;
26661
25155
  PointerEventType[PointerEventType["PointerUp"] = 1] = "PointerUp";
26662
25156
  PointerEventType[PointerEventType["PointerMove"] = 2] = "PointerMove";
26663
25157
  })(PointerEventType || (PointerEventType = {}));
26664
- var EventSystem = /*#__PURE__*/ function() {
25158
+ var EventSystem = /*#__PURE__*/ function(EventEmitter) {
25159
+ _inherits(EventSystem, EventEmitter);
26665
25160
  function EventSystem(engine, allowPropagation) {
26666
- var _this = this;
26667
25161
  if (allowPropagation === void 0) allowPropagation = false;
26668
- this.engine = engine;
26669
- this.allowPropagation = allowPropagation;
26670
- this.skipPointerMovePicking = true;
26671
- this.emulateMouseFromTouch = true;
26672
- this.emulateTouchFromMouse = false;
26673
- this._enabled = true;
26674
- this.handlers = {};
26675
- this.nativeHandlers = [];
26676
- this.target = null;
26677
- this.mouseState = null;
26678
- this.touchStates = new Map();
26679
- this.mouseFromTouchIndex = null;
26680
- this.touchFromMousePressed = false;
26681
- this.addedTabIndex = false;
26682
- this.addedOutlineStyle = false;
26683
- this.onNativeWheel = function(event) {
25162
+ var _this;
25163
+ _this = EventEmitter.call(this) || this;
25164
+ _this.engine = engine;
25165
+ _this.allowPropagation = allowPropagation;
25166
+ _this.skipPointerMovePicking = true;
25167
+ _this.emulateMouseFromTouch = true;
25168
+ _this.emulateTouchFromMouse = false;
25169
+ _this._enabled = true;
25170
+ _this.handlers = {};
25171
+ _this.nativeHandlers = [];
25172
+ _this.target = null;
25173
+ _this.mouseState = null;
25174
+ _this.mouseButtonMask = MouseButtonMask.None;
25175
+ _this.touchStates = new Map();
25176
+ _this.mouseFromTouchIndex = null;
25177
+ _this.touchFromMousePressed = false;
25178
+ _this.addedTabIndex = false;
25179
+ _this.addedOutlineStyle = false;
25180
+ _this.onNativeWheel = function(event) {
26684
25181
  if (!_this.enabled || !_this.target) {
26685
25182
  return;
26686
25183
  }
26687
25184
  var position = _this.getCanvasPosition(event.clientX, event.clientY);
26688
25185
  var handled = false;
26689
25186
  if (event.deltaY !== 0) {
26690
- handled = _this.pushWheelButton(event.deltaY < 0 ? MouseButton.WheelUp : MouseButton.WheelDown, Math.abs(event.deltaY), position, event) || handled;
25187
+ handled = _this.pushWheelButton(event.deltaY < 0 ? MouseButton.WheelUp : MouseButton.WheelDown, normalizeWheelFactor(event.deltaY, event.deltaMode), position, event) || handled;
26691
25188
  }
26692
25189
  if (event.deltaX !== 0) {
26693
- handled = _this.pushWheelButton(event.deltaX < 0 ? MouseButton.WheelLeft : MouseButton.WheelRight, Math.abs(event.deltaX), position, event) || handled;
25190
+ handled = _this.pushWheelButton(event.deltaX < 0 ? MouseButton.WheelLeft : MouseButton.WheelRight, normalizeWheelFactor(event.deltaX, event.deltaMode), position, event) || handled;
26694
25191
  }
26695
25192
  _this.consumeNativeEvent(event, handled);
26696
25193
  };
26697
- this.onNativeKeyDown = function(event) {
25194
+ _this.onNativeKeyDown = function(event) {
26698
25195
  _this.handleNativeKey(event, true);
26699
25196
  };
26700
- this.onNativeKeyUp = function(event) {
25197
+ _this.onNativeKeyUp = function(event) {
26701
25198
  _this.handleNativeKey(event, false);
26702
25199
  };
26703
- this.onNativeMouseDown = function(event) {
25200
+ _this.onNativeMouseDown = function(event) {
26704
25201
  _this.handleNativeMouseDown(event);
26705
25202
  };
26706
- this.onNativeMouseMove = function(event) {
25203
+ _this.onNativeMouseMove = function(event) {
26707
25204
  var _state;
26708
25205
  if (!_this.enabled || !_this.target) {
26709
25206
  return;
@@ -26715,18 +25212,22 @@ var EventSystem = /*#__PURE__*/ function() {
26715
25212
  var relative = new Vector2(position.x - state.last.x, position.y - state.last.y);
26716
25213
  var velocity = _this.getVelocity(state, position);
26717
25214
  var handled = _this.pushNativeMouseMotion(event, position, relative, velocity);
26718
- (_state = state).controlHandled || (_state.controlHandled = handled);
26719
- if (!handled && (!state.pressed || !state.controlHandled)) {
25215
+ (_state = state).inputHandled || (_state.inputHandled = handled);
25216
+ if (!handled && (!state.pressed || !state.inputHandled)) {
26720
25217
  var pointerEvent = _this.createPointerEvent(event, position, state, velocity);
26721
25218
  _this.dispatchEvent(EVENT_TYPE_TOUCH_MOVE, pointerEvent);
26722
25219
  }
26723
25220
  _this.updatePointerState(state, position);
26724
25221
  _this.consumeNativeEvent(event, handled);
26725
25222
  };
26726
- this.onNativeMouseUp = function(event) {
25223
+ _this.onNativeMouseUp = function(event) {
26727
25224
  if (!_this.enabled || !_this.target) {
26728
25225
  return;
26729
25226
  }
25227
+ // Keep the canonical mask in sync even when mouseState already ended on a
25228
+ // previous button release. The target and Window listeners may see the
25229
+ // same mouseup, but clearing a bit twice is intentionally idempotent.
25230
+ _this.setMouseButtonPressed(event.button, false);
26730
25231
  var position = _this.getCanvasPosition(event.clientX, event.clientY);
26731
25232
  var existingState = _this.mouseState;
26732
25233
  if (!(existingState == null ? void 0 : existingState.pressed)) {
@@ -26735,16 +25236,16 @@ var EventSystem = /*#__PURE__*/ function() {
26735
25236
  var state = existingState;
26736
25237
  var handled = _this.pushNativeMouseButton(event, position, false);
26737
25238
  var pointerEvent = _this.createPointerEvent(event, position, state);
26738
- if (!state.controlHandled && !handled && _this.isClick(state, position)) {
25239
+ if (!state.inputHandled && !handled && _this.isClick(state, position)) {
26739
25240
  _this.dispatchEvent(EVENT_TYPE_CLICK, pointerEvent);
26740
25241
  }
26741
- if (!handled && !state.controlHandled) {
25242
+ if (!handled && !state.inputHandled) {
26742
25243
  _this.dispatchEvent(EVENT_TYPE_TOUCH_END, pointerEvent);
26743
25244
  }
26744
25245
  _this.mouseState = null;
26745
- _this.consumeNativeEvent(event, handled || state.controlHandled || !_this.allowPropagation);
25246
+ _this.consumeNativeEvent(event, handled || state.inputHandled || !_this.allowPropagation);
26746
25247
  };
26747
- this.onNativeTouchStart = function(event) {
25248
+ _this.onNativeTouchStart = function(event) {
26748
25249
  if (!_this.enabled) {
26749
25250
  return;
26750
25251
  }
@@ -26756,7 +25257,7 @@ var EventSystem = /*#__PURE__*/ function() {
26756
25257
  _this.touchStates.set(touch.identifier, state);
26757
25258
  state.pressed = true;
26758
25259
  var handled = _this.pushNativeScreenTouch(touch.identifier, position, true, false, false);
26759
- state.controlHandled = handled;
25260
+ state.inputHandled = handled;
26760
25261
  if (!handled) {
26761
25262
  var pointerEvent = _this.createPointerEvent(event, position, state);
26762
25263
  _this.dispatchEvent(EVENT_TYPE_TOUCH_START, pointerEvent);
@@ -26765,7 +25266,7 @@ var EventSystem = /*#__PURE__*/ function() {
26765
25266
  }
26766
25267
  _this.preventTouchDefaults(event);
26767
25268
  };
26768
- this.onNativeTouchMove = function(event) {
25269
+ _this.onNativeTouchMove = function(event) {
26769
25270
  if (!_this.enabled) {
26770
25271
  return;
26771
25272
  }
@@ -26779,8 +25280,8 @@ var EventSystem = /*#__PURE__*/ function() {
26779
25280
  var relative = new Vector2(position.x - state.last.x, position.y - state.last.y);
26780
25281
  var velocity = _this.getVelocity(state, position);
26781
25282
  var handled = _this.pushNativeScreenDrag(touch.identifier, position, relative, velocity);
26782
- (_state = state).controlHandled || (_state.controlHandled = handled);
26783
- if (!handled && !state.controlHandled) {
25283
+ (_state = state).inputHandled || (_state.inputHandled = handled);
25284
+ if (!handled && !state.inputHandled) {
26784
25285
  var pointerEvent = _this.createPointerEvent(event, position, state, velocity);
26785
25286
  _this.dispatchEvent(EVENT_TYPE_TOUCH_MOVE, pointerEvent);
26786
25287
  }
@@ -26789,24 +25290,26 @@ var EventSystem = /*#__PURE__*/ function() {
26789
25290
  }
26790
25291
  _this.preventTouchDefaults(event);
26791
25292
  };
26792
- this.onNativeTouchEnd = function(event) {
25293
+ _this.onNativeTouchEnd = function(event) {
26793
25294
  _this.handleNativeTouchEnd(event, false);
26794
25295
  };
26795
- this.onNativeTouchCancel = function(event) {
25296
+ _this.onNativeTouchCancel = function(event) {
26796
25297
  _this.handleNativeTouchEnd(event, true);
26797
25298
  };
26798
- this.onWindowBlur = function() {
26799
- if (_this.enabled) {
26800
- _this.mouseState = null;
26801
- _this.touchStates.clear();
26802
- _this.mouseFromTouchIndex = null;
26803
- _this.touchFromMousePressed = false;
26804
- _this.engine.windowRoot.cancelPointerInput();
26805
- }
25299
+ _this.onCanvasFocus = function() {
25300
+ _this.emit("canvasFocus");
26806
25301
  };
25302
+ _this.onCanvasBlur = function() {
25303
+ _this.emit("canvasBlur");
25304
+ };
25305
+ return _this;
26807
25306
  }
26808
25307
  var _proto = EventSystem.prototype;
26809
- _proto.bindListeners = function bindListeners(target) {
25308
+ /**
25309
+ * Rebinds native input listeners to a canvas.
25310
+ *
25311
+ * Rebind or unbind only while there are no active key, mouse, touch, or drag sessions.
25312
+ */ _proto.bindListeners = function bindListeners(target) {
26810
25313
  this.unbindListeners();
26811
25314
  this.target = target;
26812
25315
  if (!target || typeof window === "undefined") {
@@ -26843,7 +25346,8 @@ var EventSystem = /*#__PURE__*/ function() {
26843
25346
  });
26844
25347
  this.addNativeHandler(target, "keydown", this.onNativeKeyDown);
26845
25348
  this.addNativeHandler(target, "keyup", this.onNativeKeyUp);
26846
- this.addNativeHandler(window, "blur", this.onWindowBlur);
25349
+ this.addNativeHandler(target, "focus", this.onCanvasFocus);
25350
+ this.addNativeHandler(target, "blur", this.onCanvasBlur);
26847
25351
  };
26848
25352
  _proto.dispatchEvent = function dispatchEvent(type, event) {
26849
25353
  var handlers = this.handlers[type];
@@ -26877,11 +25381,7 @@ var EventSystem = /*#__PURE__*/ function() {
26877
25381
  }
26878
25382
  };
26879
25383
  _proto.dispose = function dispose() {
26880
- this.engine.windowRoot.cancelPointerInput();
26881
- this.mouseState = null;
26882
- this.touchStates.clear();
26883
- this.mouseFromTouchIndex = null;
26884
- this.touchFromMousePressed = false;
25384
+ this.resetInputState();
26885
25385
  this.handlers = {};
26886
25386
  this.unbindListeners();
26887
25387
  this.target = null;
@@ -26890,13 +25390,14 @@ var EventSystem = /*#__PURE__*/ function() {
26890
25390
  if (!this.enabled || !this.target) {
26891
25391
  return;
26892
25392
  }
25393
+ this.setMouseButtonPressed(event.button, true);
26893
25394
  var position = this.getCanvasPosition(event.clientX, event.clientY);
26894
25395
  this.focusTarget();
26895
25396
  var state = this.createPointerState(position);
26896
25397
  this.mouseState = state;
26897
25398
  state.pressed = true;
26898
25399
  var handled = this.pushNativeMouseButton(event, position, true);
26899
- state.controlHandled = handled;
25400
+ state.inputHandled = handled;
26900
25401
  if (!handled) {
26901
25402
  var pointerEvent = this.createPointerEvent(event, position, state);
26902
25403
  this.dispatchEvent(EVENT_TYPE_TOUCH_START, pointerEvent);
@@ -26920,8 +25421,7 @@ var EventSystem = /*#__PURE__*/ function() {
26920
25421
  input.altPressed = event.altKey;
26921
25422
  input.metaPressed = event.metaKey;
26922
25423
  input.ctrlPressed = event.ctrlKey;
26923
- this.engine.windowRoot.pushInput(input);
26924
- this.consumeNativeEvent(event, this.engine.windowRoot.isInputHandled());
25424
+ this.consumeNativeEvent(event, this.pushInput(input));
26925
25425
  };
26926
25426
  _proto.handleNativeTouchEnd = function handleNativeTouchEnd(event, canceled) {
26927
25427
  if (!this.enabled) {
@@ -26936,14 +25436,14 @@ var EventSystem = /*#__PURE__*/ function() {
26936
25436
  }
26937
25437
  var handled = this.pushNativeScreenTouch(touch.identifier, position, false, canceled, false);
26938
25438
  var pointerEvent = this.createPointerEvent(event, position, state);
26939
- if (!canceled && !state.controlHandled && !handled && this.isClick(state, position)) {
25439
+ if (!canceled && !state.inputHandled && !handled && this.isClick(state, position)) {
26940
25440
  this.dispatchEvent(EVENT_TYPE_CLICK, pointerEvent);
26941
25441
  }
26942
- if (!handled && !canceled && !state.controlHandled) {
25442
+ if (!handled && !canceled && !state.inputHandled) {
26943
25443
  this.dispatchEvent(EVENT_TYPE_TOUCH_END, pointerEvent);
26944
25444
  }
26945
25445
  this.touchStates.delete(touch.identifier);
26946
- this.consumeNativeEvent(event, handled || state.controlHandled || !this.allowPropagation);
25446
+ this.consumeNativeEvent(event, handled || state.inputHandled || !this.allowPropagation);
26947
25447
  }
26948
25448
  this.preventTouchDefaults(event);
26949
25449
  };
@@ -26963,7 +25463,7 @@ var EventSystem = /*#__PURE__*/ function() {
26963
25463
  };
26964
25464
  _proto.pushNativeMouseMotion = function pushNativeMouseMotion(event, position, relative, velocity) {
26965
25465
  var handled = false;
26966
- if (this.touchFromMousePressed && (event.buttons & 1) !== 0) {
25466
+ if (this.touchFromMousePressed && (this.mouseButtonMask & MouseButtonMask.Left) !== 0) {
26967
25467
  handled = this.pushScreenDrag(0, position, relative, velocity, InputEvent.deviceIdEmulation);
26968
25468
  }
26969
25469
  return this.pushMouseMotion(event, position, relative, velocity) || handled;
@@ -27000,8 +25500,7 @@ var EventSystem = /*#__PURE__*/ function() {
27000
25500
  input.pressed = pressed;
27001
25501
  input.canceled = canceled;
27002
25502
  input.doubleClick = doubleClick;
27003
- this.engine.windowRoot.pushInput(input);
27004
- return this.engine.windowRoot.isInputHandled();
25503
+ return this.pushInput(input);
27005
25504
  };
27006
25505
  _proto.pushEmulatedMouseMotion = function pushEmulatedMouseMotion(position, relative, velocity) {
27007
25506
  var input = new InputEventMouseMotion();
@@ -27014,42 +25513,42 @@ var EventSystem = /*#__PURE__*/ function() {
27014
25513
  input.screenRelative.copyFrom(relative);
27015
25514
  input.velocity.copyFrom(velocity);
27016
25515
  input.screenVelocity.copyFrom(velocity);
27017
- this.engine.windowRoot.pushInput(input);
27018
- return this.engine.windowRoot.isInputHandled();
25516
+ return this.pushInput(input);
27019
25517
  };
27020
25518
  _proto.pushMouseButton = function pushMouseButton(event, position, pressed) {
27021
25519
  var input = new InputEventMouseButton();
27022
25520
  this.copyMouseFields(input, event, position);
27023
25521
  input.device = InputEvent.deviceIdMouse;
27024
25522
  input.buttonIndex = getMouseButton(event.button);
27025
- input.buttonMask = getMouseButtonMask(event.buttons);
25523
+ input.buttonMask = this.mouseButtonMask;
25524
+ input.pressed = pressed;
25525
+ input.doubleClick = event.detail > 1;
25526
+ return this.pushInput(input);
25527
+ };
25528
+ _proto.setMouseButtonPressed = function setMouseButtonPressed(button, pressed) {
25529
+ var buttonBit = getMouseButtonBit(getMouseButton(button));
27026
25530
  if (pressed) {
27027
- input.buttonMask |= getMouseButtonBit(input.buttonIndex);
25531
+ this.mouseButtonMask |= buttonBit;
27028
25532
  } else {
27029
- input.buttonMask &= ~getMouseButtonBit(input.buttonIndex);
25533
+ this.mouseButtonMask &= ~buttonBit;
27030
25534
  }
27031
- input.pressed = pressed;
27032
- input.doubleClick = event.detail > 1;
27033
- this.engine.windowRoot.pushInput(input);
27034
- return this.engine.windowRoot.isInputHandled();
27035
25535
  };
27036
25536
  _proto.pushWheelButton = function pushWheelButton(button, factor, position, event) {
27037
25537
  var input = new InputEventMouseButton();
27038
25538
  this.copyMouseFields(input, event, position);
27039
25539
  input.device = InputEvent.deviceIdMouse;
27040
25540
  input.buttonIndex = button;
27041
- input.buttonMask = getMouseButtonMask(event.buttons);
25541
+ input.buttonMask = this.mouseButtonMask;
27042
25542
  input.factor = factor;
27043
25543
  input.pressed = true;
27044
- this.engine.windowRoot.pushInput(input);
27045
- return this.engine.windowRoot.isInputHandled();
25544
+ return this.pushInput(input);
27046
25545
  };
27047
25546
  _proto.pushMouseMotion = function pushMouseMotion(event, position, relative, velocity) {
27048
25547
  var input = new InputEventMouseMotion();
27049
25548
  this.copyMouseFields(input, event, position);
27050
25549
  input.device = InputEvent.deviceIdMouse;
27051
- input.buttonMask = getMouseButtonMask(event.buttons);
27052
- input.pressed = event.buttons !== 0;
25550
+ input.buttonMask = this.mouseButtonMask;
25551
+ input.pressed = this.mouseButtonMask !== MouseButtonMask.None;
27053
25552
  input.relative.copyFrom(relative);
27054
25553
  input.screenRelative.copyFrom(relative);
27055
25554
  input.velocity.copyFrom(velocity);
@@ -27058,8 +25557,7 @@ var EventSystem = /*#__PURE__*/ function() {
27058
25557
  input.pressure = event.pressure;
27059
25558
  input.tilt.set(event.tiltX, event.tiltY);
27060
25559
  }
27061
- this.engine.windowRoot.pushInput(input);
27062
- return this.engine.windowRoot.isInputHandled();
25560
+ return this.pushInput(input);
27063
25561
  };
27064
25562
  _proto.pushScreenTouch = function pushScreenTouch(index, position, pressed, canceled, doubleTap, device) {
27065
25563
  var input = new InputEventScreenTouch();
@@ -27069,8 +25567,7 @@ var EventSystem = /*#__PURE__*/ function() {
27069
25567
  input.pressed = pressed;
27070
25568
  input.canceled = canceled;
27071
25569
  input.doubleTap = doubleTap;
27072
- this.engine.windowRoot.pushInput(input);
27073
- return this.engine.windowRoot.isInputHandled();
25570
+ return this.pushInput(input);
27074
25571
  };
27075
25572
  _proto.pushScreenDrag = function pushScreenDrag(index, position, relative, velocity, device) {
27076
25573
  var input = new InputEventScreenDrag();
@@ -27082,8 +25579,7 @@ var EventSystem = /*#__PURE__*/ function() {
27082
25579
  input.velocity.copyFrom(velocity);
27083
25580
  input.screenVelocity.copyFrom(velocity);
27084
25581
  input.pressed = true;
27085
- this.engine.windowRoot.pushInput(input);
27086
- return this.engine.windowRoot.isInputHandled();
25582
+ return this.pushInput(input);
27087
25583
  };
27088
25584
  _proto.copyMouseFields = function copyMouseFields(input, event, position) {
27089
25585
  input.position.copyFrom(position);
@@ -27158,7 +25654,7 @@ var EventSystem = /*#__PURE__*/ function() {
27158
25654
  start: position.clone(),
27159
25655
  last: position.clone(),
27160
25656
  lastTime: performance.now(),
27161
- controlHandled: false,
25657
+ inputHandled: false,
27162
25658
  pressed: false
27163
25659
  };
27164
25660
  return state;
@@ -27183,8 +25679,8 @@ var EventSystem = /*#__PURE__*/ function() {
27183
25679
  var _target_width, _target_height;
27184
25680
  return {
27185
25681
  x: position.x / cssWidth * 2 - 1,
27186
- // Legacy composition picking uses bottom-left, Y-up NDC even though GUI
27187
- // input follows the DOM convention of top-left, Y-down pixels.
25682
+ // Legacy composition picking uses bottom-left, Y-up NDC even though
25683
+ // standardized input follows the DOM convention of top-left, Y-down pixels.
27188
25684
  y: 1 - position.y / cssHeight * 2,
27189
25685
  vx: velocity.x / cssWidth * 2,
27190
25686
  vy: -velocity.y / cssHeight * 2,
@@ -27212,6 +25708,11 @@ var EventSystem = /*#__PURE__*/ function() {
27212
25708
  event.stopPropagation();
27213
25709
  }
27214
25710
  };
25711
+ _proto.pushInput = function pushInput(input) {
25712
+ input.clearAccepted();
25713
+ this.emit("input", input);
25714
+ return input.isAccepted();
25715
+ };
27215
25716
  _proto.preventTouchDefaults = function preventTouchDefaults(event) {
27216
25717
  if (event.cancelable) {
27217
25718
  event.preventDefault();
@@ -27221,6 +25722,13 @@ var EventSystem = /*#__PURE__*/ function() {
27221
25722
  var _this_target;
27222
25723
  (_this_target = this.target) == null ? void 0 : _this_target.focus();
27223
25724
  };
25725
+ _proto.resetInputState = function resetInputState() {
25726
+ this.mouseState = null;
25727
+ this.mouseButtonMask = MouseButtonMask.None;
25728
+ this.touchStates.clear();
25729
+ this.mouseFromTouchIndex = null;
25730
+ this.touchFromMousePressed = false;
25731
+ };
27224
25732
  _proto.addNativeHandler = function addNativeHandler(target, name, handler, options) {
27225
25733
  target.addEventListener(name, handler, options);
27226
25734
  this.nativeHandlers.push({
@@ -27251,23 +25759,20 @@ var EventSystem = /*#__PURE__*/ function() {
27251
25759
  get: function get() {
27252
25760
  return this._enabled;
27253
25761
  },
27254
- set: function set(value) {
25762
+ set: /**
25763
+ * Enables native input processing.
25764
+ *
25765
+ * Change this only while there are no active key, mouse, touch, or drag sessions.
25766
+ */ function set(value) {
27255
25767
  if (this._enabled === value) {
27256
25768
  return;
27257
25769
  }
27258
25770
  this._enabled = value;
27259
- if (!value) {
27260
- this.mouseState = null;
27261
- this.touchStates.clear();
27262
- this.mouseFromTouchIndex = null;
27263
- this.touchFromMousePressed = false;
27264
- this.engine.windowRoot.cancelPointerInput();
27265
- }
27266
25771
  }
27267
25772
  }
27268
25773
  ]);
27269
25774
  return EventSystem;
27270
- }();
25775
+ }(EventEmitter);
27271
25776
  function getKeyLocation(location) {
27272
25777
  if (location === 1) {
27273
25778
  return KeyLocation.Left;
@@ -27298,25 +25803,6 @@ function getMouseButton(button) {
27298
25803
  return MouseButton.None;
27299
25804
  }
27300
25805
  }
27301
- function getMouseButtonMask(buttons) {
27302
- var mask = MouseButtonMask.None;
27303
- if ((buttons & 1) !== 0) {
27304
- mask |= MouseButtonMask.Left;
27305
- }
27306
- if ((buttons & 2) !== 0) {
27307
- mask |= MouseButtonMask.Right;
27308
- }
27309
- if ((buttons & 4) !== 0) {
27310
- mask |= MouseButtonMask.Middle;
27311
- }
27312
- if ((buttons & 8) !== 0) {
27313
- mask |= MouseButtonMask.Xbutton1;
27314
- }
27315
- if ((buttons & 16) !== 0) {
27316
- mask |= MouseButtonMask.Xbutton2;
27317
- }
27318
- return mask;
27319
- }
27320
25806
  function getMouseButtonBit(button) {
27321
25807
  switch(button){
27322
25808
  case MouseButton.Left:
@@ -27333,6 +25819,16 @@ function getMouseButtonBit(button) {
27333
25819
  return MouseButtonMask.None;
27334
25820
  }
27335
25821
  }
25822
+ function normalizeWheelFactor(delta, mode) {
25823
+ var magnitude = Math.abs(delta);
25824
+ if (mode === 1) {
25825
+ return magnitude / 3;
25826
+ }
25827
+ if (mode === 2) {
25828
+ return magnitude;
25829
+ }
25830
+ return magnitude / 100;
25831
+ }
27336
25832
 
27337
25833
  var InteractLoader = /*#__PURE__*/ function(Plugin) {
27338
25834
  _inherits(InteractLoader, Plugin);
@@ -29352,6 +27848,11 @@ SpritePropertyTrack = __decorate([
29352
27848
  effectsClass("SpritePropertyTrack")
29353
27849
  ], SpritePropertyTrack);
29354
27850
 
27851
+ function _assert_this_initialized(self) {
27852
+ if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
27853
+ return self;
27854
+ }
27855
+
29355
27856
  var Cone = /*#__PURE__*/ function() {
29356
27857
  function Cone(props) {
29357
27858
  var _this = this;
@@ -39356,7 +37857,7 @@ function getStandardSpriteContent(sprite, transform) {
39356
37857
  return ret;
39357
37858
  }
39358
37859
 
39359
- var version$2 = "2.10.0-alpha.4";
37860
+ var version$2 = "2.10.0";
39360
37861
  var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
39361
37862
  var standardVersion = /^(\d+)\.(\d+)$/;
39362
37863
  var reverseParticle = false;
@@ -41352,9 +39853,11 @@ var PreRenderTickData = /*#__PURE__*/ function(TickData) {
41352
39853
  // Instantiate composition rootItem
41353
39854
  _this.sceneRoot = new VFXItem(_this.engine);
41354
39855
  _this.sceneRoot.setParent(_this.root);
41355
- _this.uiCanvas = _this.sceneRoot.addComponent(UICanvas);
41356
39856
  if (sourceContent) {
41357
39857
  _this.sceneRoot.setInstanceId(sourceContent.id);
39858
+ }
39859
+ PluginSystem.notifyCompositionCreating(_assert_this_initialized(_this), scene);
39860
+ if (sourceContent) {
41358
39861
  _this.sceneRoot.instantiatePreComposition(sourceContent, false);
41359
39862
  }
41360
39863
  // 在 instantiatePreComposition 后设置 rootItem 的 name,避免 name 被覆盖
@@ -41923,9 +40426,6 @@ var PreRenderTickData = /*#__PURE__*/ function(TickData) {
41923
40426
  },
41924
40427
  set: function set(value) {
41925
40428
  this._renderOrder = value;
41926
- if (this.uiCanvas) {
41927
- this.uiCanvas.order = value;
41928
- }
41929
40429
  }
41930
40430
  },
41931
40431
  {
@@ -41938,9 +40438,6 @@ var PreRenderTickData = /*#__PURE__*/ function(TickData) {
41938
40438
  },
41939
40439
  set: function set(value) {
41940
40440
  this._interactive = !!value;
41941
- if (this.uiCanvas) {
41942
- this.uiCanvas.receivesEvents = this._interactive;
41943
- }
41944
40441
  }
41945
40442
  },
41946
40443
  {
@@ -43768,7 +42265,6 @@ var DEFAULT_FPS = 60;
43768
42265
  _this.objectInstance = {};
43769
42266
  _this.root = new VFXItem(_assert_this_initialized(_this));
43770
42267
  _this.root.name = "root";
43771
- _this.windowRoot = new WindowRootControl(_assert_this_initialized(_this));
43772
42268
  _this.whiteTexture = generateWhiteTexture(_assert_this_initialized(_this));
43773
42269
  _this.transparentTexture = generateEmptyTexture(_assert_this_initialized(_this));
43774
42270
  if (!(options == null ? void 0 : options.manualRender)) {
@@ -43921,7 +42417,7 @@ var DEFAULT_FPS = 60;
43921
42417
  (_this_ticker1 = this.ticker) == null ? void 0 : _this_ticker1.pause();
43922
42418
  return;
43923
42419
  }
43924
- this.windowRoot.update(dt);
42420
+ this.emit("update", dt);
43925
42421
  // Tick compositions onPreRender
43926
42422
  //-------------------------------------------------------------------------
43927
42423
  for(var _iterator1 = _create_for_of_iterator_helper_loose(compositions), _step1; !(_step1 = _iterator1()).done;){
@@ -43936,7 +42432,7 @@ var DEFAULT_FPS = 60;
43936
42432
  var composition2 = _step2.value;
43937
42433
  composition2.renderContent();
43938
42434
  }
43939
- this.windowRoot.render();
42435
+ this.emit("postrender");
43940
42436
  this.renderTargetPool.flush();
43941
42437
  };
43942
42438
  /**
@@ -43978,7 +42474,6 @@ var DEFAULT_FPS = 60;
43978
42474
  this.canvas.style.height = containerHeight + "px";
43979
42475
  logger.info("Resize engine " + this.name + " [" + canvasWidth + "," + canvasHeight + "," + containerWidth + "," + containerHeight + "].");
43980
42476
  this.setSize(canvasWidth, canvasHeight);
43981
- this.windowRoot.resize(canvasWidth, canvasHeight);
43982
42477
  }
43983
42478
  };
43984
42479
  _proto.setSize = function setSize(width, height) {
@@ -44184,6 +42679,12 @@ var DEFAULT_FPS = 60;
44184
42679
  _proto.setStencilTest = function setStencilTest(enable) {
44185
42680
  // OVERRIDE
44186
42681
  };
42682
+ _proto.setScissorTest = function setScissorTest(enable) {
42683
+ // OVERRIDE
42684
+ };
42685
+ _proto.setScissor = function setScissor(x, y, width, height) {
42686
+ // OVERRIDE
42687
+ };
44187
42688
  _proto.setCulling = function setCulling(enable) {
44188
42689
  // OVERRIDE
44189
42690
  };
@@ -44261,7 +42762,6 @@ var DEFAULT_FPS = 60;
44261
42762
  composition.dispose();
44262
42763
  }
44263
42764
  this.root.dispose();
44264
- this.windowRoot.dispose();
44265
42765
  (_this_assetService = this.assetService) == null ? void 0 : _this_assetService.dispose();
44266
42766
  (_this__graphics = this._graphics) == null ? void 0 : _this__graphics.dispose();
44267
42767
  this.renderPasses.forEach(function(pass) {
@@ -44586,7 +43086,7 @@ registerPlugin("text", TextLoader);
44586
43086
  registerPlugin("sprite", SpriteLoader);
44587
43087
  registerPlugin("particle", ParticleLoader);
44588
43088
  registerPlugin("interact", InteractLoader);
44589
- var version$1 = "2.10.0-alpha.4";
43089
+ var version$1 = "2.10.0";
44590
43090
  logger.info("Core version: " + version$1 + ".");
44591
43091
 
44592
43092
  var _obj;
@@ -46079,8 +44579,8 @@ applyMixins(ThreeTextComponent, [
46079
44579
  */ Mesh.create = function(engine, props) {
46080
44580
  return new ThreeMesh(engine, props);
46081
44581
  };
46082
- var version = "2.10.0-alpha.4";
44582
+ var version = "2.10.0";
46083
44583
  logger.info("THREEJS plugin version: " + version + ".");
46084
44584
 
46085
- export { ATLAS_SIZE, ActivationMixerPlayable, ActivationPlayable, ActivationPlayableAsset, ActivationTrack, AndNode, AndNodeData, Animatable, AnimationClip, AnimationClipNode, AnimationClipNodeData, AnimationEvent, AnimationGraphAsset, Animator, ApplyAdditiveNode, ApplyAdditiveNodeData, Asset, AssetLoader, AssetManager, AssetService, BYTES_TYPE_MAP, Behaviour, BezierCurve, BezierCurvePath, BezierCurveQuat, BezierDataMap, BezierEasing, BezierLengthData, BezierMap, BezierPath, BezierQuat, BinaryAsset, BlendNode, BlendNodeData, BoolValueNode, BoundingBoxInfo, Buffer, BufferDataType, BufferUsage, CONSTANT_MAP_BLEND, CONSTANT_MAP_DEPTH, CONSTANT_MAP_STENCIL_FUNC, CONSTANT_MAP_STENCIL_OP, COPY_FRAGMENT_SHADER, COPY_MESH_SHADER_ID, COPY_VERTEX_SHADER, Camera, CameraController, CameraVFXItemLoader, CanvasContainer, CanvasRenderMode, CanvasRootControl, Circle$1 as Circle, ColorCurve, ColorPlayable, ColorPropertyMixerPlayable, ColorPropertyPlayableAsset, ColorPropertyTrack, Component, ComponentTimePlayable, ComponentTimePlayableAsset, ComponentTimeTrack, Composition, CompositionComponent, CompressTextureCapabilityType, ConstBoolNode, ConstBoolNodeData, ConstFloatNode, ConstFloatNodeData, ConstraintTarget, ContainerControl, Control, ControlParameterBoolNode, ControlParameterBoolNodeData, ControlParameterFloatNode, ControlParameterFloatNodeData, ControlParameterTriggerNode, ControlParameterTriggerNodeData, CursorShape, DEFAULT_FONTS, DEFAULT_FPS, DataBuffer, Database, Deferred, DestroyOptions, Downloader, DrawObjectPass, EFFECTS_COPY_MESH_NAME, EVENT_TYPE_CLICK, EVENT_TYPE_TOUCH_END, EVENT_TYPE_TOUCH_MOVE, EVENT_TYPE_TOUCH_START, EffectComponent, EffectComponentTimeTrack, EffectsObject, EffectsPackage, Ellipse, Engine, EqualNodeData, EventEmitter, EventSystem, Fake3DAnimationMode, Fake3DComponent, FilterMode, Float16ArrayWrapper, FloatComparisonNode, FloatComparisonNodeData, FloatPropertyMixerPlayable, FloatPropertyPlayableAsset, FloatPropertyTrack, FloatValueNode, FocusBehaviorRecursive, FocusMode, FrameComponent, Framebuffer, GLSLVersion, GPUCapability, Geometry, GlobalUniforms, GlyphAtlas, GradientValue, GraphInstance, GraphNode, GraphNodeData, Graphics, GreaterNodeData, HELP_LINK, HitTestType, InputEvent, InputEventKey, InputEventMouse, InputEventMouseButton, InputEventMouseMotion, InputEventScreenDrag, InputEventScreenTouch, InputEventWithModifiers, InteractComponent, InteractLoader, InteractMesh, InvalidIndex, Item, KeyLocation, LayerBlendNode, LayerBlendNodeData, LessNodeData, LineSegments, LinearValue, MaskMode, MaskProcessor, MaskableGraphic, Material, MaterialDataBlock, MaterialRenderType, MaterialState, MaterialTrack, Mesh, MouseBehaviorRecursive, MouseButton, MouseButtonMask, MouseFilter, NodeTransform, NotNode, NotNodeData, NotifyEvent, ObjectBindingTrack, OrNode, OrNodeData, OrderType, PLAYER_OPTIONS_ENV_EDITOR, POST_PROCESS_SETTINGS, ParticleBehaviourPlayable, ParticleBehaviourPlayableAsset, ParticleLoader, ParticleMesh, ParticleMixerPlayable, ParticleSystem, ParticleSystemRenderer, ParticleTrack, PassTextureCache, PathSegments, PlayState, Playable, PlayableAsset, PlayableOutput, Plugin, PluginSystem, PointerEventData, PointerEventType, PolyStar, Polygon, Pose, PoseNode, PositionConstraint, PostProcessVolume, Precomposition, PrecompositionManager, PropertyClipPlayable, PropertyTrack, REFERENCE_CURVE, RENDER_PREFER_LOOKUP_TEXTURE, RUNTIME_ENV, RandomSetValue, RandomValue, RandomVectorValue, RaycastResult, Rectangle$1 as Rectangle, ReferenceCurve, RenderFrame, RenderPass, RenderPassAttachmentStorageType, RenderPassDestroyAttachmentType, RenderPassPriorityNormal, RenderPassPriorityPostprocess, RenderPassPriorityPrepare, RenderTargetHandle, RenderTargetPool, RenderTextureFormat, Renderbuffer, Renderer, RendererComponent, RootControl, RuntimeClip, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0, SEMANTIC_PRE_COLOR_ATTACHMENT_0, SEMANTIC_PRE_COLOR_ATTACHMENT_SIZE_0, SPRITE_VERTEX_STRIDE, Scene, SceneLoader, SerializationHelper, Shader, ShaderCompileResultStatus, ShaderFactory, ShaderType, ShaderVariant, ShapeComponent, SourceType, Sprite, SpriteColorMixerPlayable, SpriteColorPlayableAsset, SpriteColorTrack, SpriteComponent, SpriteComponentTimeTrack, SpriteLoader, SpritePropertyMixerPlayable, SpritePropertyPlayableAsset, SpritePropertyTrack, SpriteRotation, StarType, StateMachineNode, StateMachineNodeData, StateNode, StateNodeData, StaticValue, SubCompositionClipPlayable, SubCompositionMixerPlayable, SubCompositionPlayableAsset, SubCompositionTrack, TEMPLATE_USE_OFFSCREEN_CANVAS, TEXTURE_UNIFORM_MAP, TangentMode, TextCache, TextComponent, TextComponentBase, TextLayout, TextLoader, TextStyle, Texture, TextureFactory, TextureLoadAction, TexturePaintScaleMode, TextureSourceType, TextureStoreAction, ThreeComposition, ThreeDisplayObject, ThreeEngine, ThreeMaterial, ThreeSpriteComponent, ThreeTextComponent, ThreeTexture, Ticker, TimelineAsset, TimelineClip, TimelineInstance, TrackAsset, TrackMixerPlayable, TrackType, Transform, TransformMixerPlayable, TransformPlayable, TransformPlayableAsset, TransformTrack, TransitionNode, TransitionNodeData, TransitionState, Triangle, TrimPath, TrimPathMode, UICanvas, UIControl, UpdateModes, VFXItem, ValueGetter, ValueNode, Vector2Curve, Vector2PropertyMixerPlayable, Vector2PropertyPlayableAsset, Vector2PropertyTrack, Vector3Curve, Vector3PropertyMixerPlayable, Vector3PropertyTrack, Vector3ropertyPlayableAsset, Vector4Curve, Vector4PropertyMixerPlayable, Vector4PropertyPlayableAsset, Vector4PropertyTrack, VertexBuffer, WeightedMode, WindowRootControl, addByOrder, addItem, addItemWithOrder, applyMixins, assertExist, asserts, base64ToFile, breakOpportunityAfter, buildBezierData, buildEasingCurve, buildLine, calculateTranslation, canUseBOM, canvasPool, closePointEps, colorGradingFrag, colorStopsFromGradient, colorToArr$1 as colorToArr, combineImageTemplate, createGLContext, createKeyFrameMeta, createShape, createTypedArray, createValueGetter, curveEps, decimalEqual, deserializeMipmapTexture, earcut, effectsClass, effectsClassStore, enlargeBuffer, ensureFixedNumber, ensureVec3, extractMinAndMax, gaussianDownHFrag, gaussianDownVFrag, gaussianUpFrag, generateEmptyTexture, generateEmptyTypedArray, generateGUID, generateHalfFloatTexture, generateWhiteTexture, getBackgroundImage, getBytesPerElement, getClass, getColorFromGradientStops, getConfig, getControlPoints, getDataByteLength, getDataType, getDefaultTextureFactory, getGeometryByShape, getGeometryTriangles, getKeyFrameMetaByRawValue, getMergedStore, getNodeDataClass, getParticleMeshShader, getPixelRatio, getPluginUsageInfo, getPreMultiAlpha, getStandardComposition, getStandardImage, getStandardItem, getStandardJSON, getTextureSize, glContext, glType2VertexFormatType, gpuTimer, imageDataFromColor, imageDataFromGradient, initErrors, initGLContext, integrate, interpolateColor, isAlipayMiniApp, isAndroid, isArray, isBreakChar, isCJKLike, isCanvas, isFunction, isIOS, isIOSByUA, isMiniProgram, isObject, isOpenHarmony, isPlainObject, isPowerOfTwo, isSafeFontFamily, isSimulatorCellPhone, isString, isUniformStruct, isUniformStructArray, isValidFontFamily, isWebGL2, isWechatMiniApp, itemFrag, itemVert, loadAVIFOptional, loadBinary, loadBlob, loadImage, loadMedia, loadVideo, loadWebPOptional, logger, index as math, modifyMaxKeyframeShader, nearestPowerOfTwo, nodeDataClass, noop, normalizeColor, numberToFix, oldBezierKeyFramesToNew, parsePercent$1 as parsePercent, particleFrag, particleOriginTranslateMap$1 as particleOriginTranslateMap, particleUniformTypeMap, particleVert, passRenderLevel, pluginLoaderMap, randomInRange, registerPlugin, removeItem, rotateVec2, screenMeshVert, serialize, setBlendMode, setConfig, setDefaultTextureFactory, setMaskMode, setRayFromCamera, setSideMode, setUniformValue, sortByOrder, index$1 as spec, textureLoaderRegistry, thresholdFrag, throwDestroyedError, toBufferView, trailVert, translatePoint, trianglesFromRect, unregisterPlugin, valIfUndefined, value, valueDefine, vecFill, vecMulCombine, version, vertexFormatType2GLType };
44585
+ export { ATLAS_SIZE, ActivationMixerPlayable, ActivationPlayable, ActivationPlayableAsset, ActivationTrack, AndNode, AndNodeData, Animatable, AnimationClip, AnimationClipNode, AnimationClipNodeData, AnimationEvent, AnimationGraphAsset, Animator, ApplyAdditiveNode, ApplyAdditiveNodeData, Asset, AssetLoader, AssetManager, AssetService, BYTES_TYPE_MAP, Behaviour, BezierCurve, BezierCurvePath, BezierCurveQuat, BezierDataMap, BezierEasing, BezierLengthData, BezierMap, BezierPath, BezierQuat, BinaryAsset, BlendNode, BlendNodeData, BoolValueNode, BoundingBoxInfo, Buffer, BufferDataType, BufferUsage, CONSTANT_MAP_BLEND, CONSTANT_MAP_DEPTH, CONSTANT_MAP_STENCIL_FUNC, CONSTANT_MAP_STENCIL_OP, COPY_FRAGMENT_SHADER, COPY_MESH_SHADER_ID, COPY_VERTEX_SHADER, Camera, CameraController, CameraVFXItemLoader, Circle$1 as Circle, ColorCurve, ColorPlayable, ColorPropertyMixerPlayable, ColorPropertyPlayableAsset, ColorPropertyTrack, Component, ComponentTimePlayable, ComponentTimePlayableAsset, ComponentTimeTrack, Composition, CompositionComponent, CompressTextureCapabilityType, ConstBoolNode, ConstBoolNodeData, ConstFloatNode, ConstFloatNodeData, ConstraintTarget, ControlParameterBoolNode, ControlParameterBoolNodeData, ControlParameterFloatNode, ControlParameterFloatNodeData, ControlParameterTriggerNode, ControlParameterTriggerNodeData, DEFAULT_FONTS, DEFAULT_FPS, DataBuffer, Database, Deferred, DestroyOptions, Downloader, DrawObjectPass, EFFECTS_COPY_MESH_NAME, EVENT_TYPE_CLICK, EVENT_TYPE_TOUCH_END, EVENT_TYPE_TOUCH_MOVE, EVENT_TYPE_TOUCH_START, EffectComponent, EffectComponentTimeTrack, EffectsObject, EffectsPackage, Ellipse, Engine, EqualNodeData, EventEmitter, EventSystem, Fake3DAnimationMode, Fake3DComponent, FilterMode, Float16ArrayWrapper, FloatComparisonNode, FloatComparisonNodeData, FloatPropertyMixerPlayable, FloatPropertyPlayableAsset, FloatPropertyTrack, FloatValueNode, FrameComponent, Framebuffer, GLSLVersion, GPUCapability, Geometry, GlobalUniforms, GlyphAtlas, GradientValue, GraphInstance, GraphNode, GraphNodeData, Graphics, GreaterNodeData, HELP_LINK, HitTestType, InputEvent, InputEventKey, InputEventMouse, InputEventMouseButton, InputEventMouseMotion, InputEventScreenDrag, InputEventScreenTouch, InputEventWithModifiers, InteractComponent, InteractLoader, InteractMesh, InvalidIndex, Item, KeyLocation, LayerBlendNode, LayerBlendNodeData, LessNodeData, LineSegments, LinearValue, MaskMode, MaskProcessor, MaskableGraphic, Material, MaterialDataBlock, MaterialRenderType, MaterialState, MaterialTrack, Mesh, MouseButton, MouseButtonMask, NodeTransform, NotNode, NotNodeData, NotifyEvent, ObjectBindingTrack, OrNode, OrNodeData, OrderType, PLAYER_OPTIONS_ENV_EDITOR, POST_PROCESS_SETTINGS, ParticleBehaviourPlayable, ParticleBehaviourPlayableAsset, ParticleLoader, ParticleMesh, ParticleMixerPlayable, ParticleSystem, ParticleSystemRenderer, ParticleTrack, PassTextureCache, PathSegments, PlayState, Playable, PlayableAsset, PlayableOutput, Plugin, PluginSystem, PointerEventData, PointerEventType, PolyStar, Polygon, Pose, PoseNode, PositionConstraint, PostProcessVolume, Precomposition, PrecompositionManager, PropertyClipPlayable, PropertyTrack, REFERENCE_CURVE, RENDER_PREFER_LOOKUP_TEXTURE, RUNTIME_ENV, RandomSetValue, RandomValue, RandomVectorValue, RaycastResult, Rectangle$1 as Rectangle, ReferenceCurve, RenderFrame, RenderPass, RenderPassAttachmentStorageType, RenderPassDestroyAttachmentType, RenderPassPriorityNormal, RenderPassPriorityPostprocess, RenderPassPriorityPrepare, RenderTargetHandle, RenderTargetPool, RenderTextureFormat, Renderbuffer, Renderer, RendererComponent, RuntimeClip, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0, SEMANTIC_PRE_COLOR_ATTACHMENT_0, SEMANTIC_PRE_COLOR_ATTACHMENT_SIZE_0, SPRITE_VERTEX_STRIDE, Scene, SceneLoader, SerializationHelper, Shader, ShaderCompileResultStatus, ShaderFactory, ShaderType, ShaderVariant, ShapeComponent, SourceType, Sprite, SpriteColorMixerPlayable, SpriteColorPlayableAsset, SpriteColorTrack, SpriteComponent, SpriteComponentTimeTrack, SpriteLoader, SpritePropertyMixerPlayable, SpritePropertyPlayableAsset, SpritePropertyTrack, SpriteRotation, StarType, StateMachineNode, StateMachineNodeData, StateNode, StateNodeData, StaticValue, SubCompositionClipPlayable, SubCompositionMixerPlayable, SubCompositionPlayableAsset, SubCompositionTrack, TEMPLATE_USE_OFFSCREEN_CANVAS, TEXTURE_UNIFORM_MAP, TangentMode, TextCache, TextComponent, TextComponentBase, TextLayout, TextLoader, TextStyle, Texture, TextureFactory, TextureLoadAction, TexturePaintScaleMode, TextureSourceType, TextureStoreAction, ThreeComposition, ThreeDisplayObject, ThreeEngine, ThreeMaterial, ThreeSpriteComponent, ThreeTextComponent, ThreeTexture, Ticker, TimelineAsset, TimelineClip, TimelineInstance, TrackAsset, TrackMixerPlayable, TrackType, Transform, TransformMixerPlayable, TransformPlayable, TransformPlayableAsset, TransformTrack, TransitionNode, TransitionNodeData, TransitionState, Triangle, TrimPath, TrimPathMode, UpdateModes, VFXItem, ValueGetter, ValueNode, Vector2Curve, Vector2PropertyMixerPlayable, Vector2PropertyPlayableAsset, Vector2PropertyTrack, Vector3Curve, Vector3PropertyMixerPlayable, Vector3PropertyTrack, Vector3ropertyPlayableAsset, Vector4Curve, Vector4PropertyMixerPlayable, Vector4PropertyPlayableAsset, Vector4PropertyTrack, VertexBuffer, WeightedMode, addByOrder, addItem, addItemWithOrder, applyMixins, assertExist, asserts, base64ToFile, breakOpportunityAfter, buildBezierData, buildEasingCurve, buildLine, calculateTranslation, canUseBOM, canvasPool, closePointEps, colorGradingFrag, colorStopsFromGradient, colorToArr$1 as colorToArr, combineImageTemplate, createGLContext, createKeyFrameMeta, createShape, createTypedArray, createValueGetter, curveEps, decimalEqual, deserializeMipmapTexture, earcut, effectsClass, effectsClassStore, enlargeBuffer, ensureFixedNumber, ensureVec3, extractMinAndMax, gaussianDownHFrag, gaussianDownVFrag, gaussianUpFrag, generateEmptyTexture, generateEmptyTypedArray, generateGUID, generateHalfFloatTexture, generateWhiteTexture, getBackgroundImage, getBytesPerElement, getClass, getColorFromGradientStops, getConfig, getControlPoints, getDataByteLength, getDataType, getDefaultTextureFactory, getGeometryByShape, getGeometryTriangles, getKeyFrameMetaByRawValue, getMergedStore, getNodeDataClass, getParticleMeshShader, getPixelRatio, getPluginUsageInfo, getPreMultiAlpha, getStandardComposition, getStandardImage, getStandardItem, getStandardJSON, getTextureSize, glContext, glType2VertexFormatType, gpuTimer, imageDataFromColor, imageDataFromGradient, initErrors, initGLContext, integrate, interpolateColor, isAlipayMiniApp, isAndroid, isArray, isBreakChar, isCJKLike, isCanvas, isFunction, isIOS, isIOSByUA, isMiniProgram, isObject, isOpenHarmony, isPlainObject, isPowerOfTwo, isSafeFontFamily, isSimulatorCellPhone, isString, isUniformStruct, isUniformStructArray, isValidFontFamily, isWebGL2, isWechatMiniApp, itemFrag, itemVert, loadAVIFOptional, loadBinary, loadBlob, loadImage, loadMedia, loadVideo, loadWebPOptional, logger, index as math, modifyMaxKeyframeShader, nearestPowerOfTwo, nodeDataClass, noop, normalizeColor, numberToFix, oldBezierKeyFramesToNew, parsePercent$1 as parsePercent, particleFrag, particleOriginTranslateMap$1 as particleOriginTranslateMap, particleUniformTypeMap, particleVert, passRenderLevel, pluginLoaderMap, randomInRange, registerPlugin, removeItem, rotateVec2, screenMeshVert, serialize, setBlendMode, setConfig, setDefaultTextureFactory, setMaskMode, setRayFromCamera, setSideMode, setUniformValue, sortByOrder, index$1 as spec, textureLoaderRegistry, thresholdFrag, throwDestroyedError, toBufferView, trailVert, translatePoint, trianglesFromRect, unregisterPlugin, valIfUndefined, value, valueDefine, vecFill, vecMulCombine, version, vertexFormatType2GLType };
46086
44586
  //# sourceMappingURL=index.mjs.map