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