@galacean/effects-threejs 2.10.0-alpha.4 → 2.10.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +729 -2303
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +2 -2
- package/dist/index.min.js.map +1 -1
- package/dist/index.mjs +730 -2296
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Description: Galacean Effects runtime threejs plugin for the web
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
|
|
6
|
-
* Version: v2.10.0-alpha.
|
|
6
|
+
* Version: v2.10.0-alpha.5
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
@@ -2958,6 +2958,11 @@ var PluginSystem = /*#__PURE__*/ function() {
|
|
|
2958
2958
|
PluginSystem.getPlugins = function getPlugins() {
|
|
2959
2959
|
return plugins;
|
|
2960
2960
|
};
|
|
2961
|
+
PluginSystem.notifyCompositionCreating = function notifyCompositionCreating(composition, scene) {
|
|
2962
|
+
plugins.forEach(function(plugin) {
|
|
2963
|
+
return plugin.onCompositionCreating(composition, scene);
|
|
2964
|
+
});
|
|
2965
|
+
};
|
|
2961
2966
|
PluginSystem.notifyCompositionCreated = function notifyCompositionCreated(composition, scene) {
|
|
2962
2967
|
plugins.forEach(function(plugin) {
|
|
2963
2968
|
return plugin.onCompositionCreated(composition, scene);
|
|
@@ -3050,6 +3055,12 @@ function getPluginUsageInfo(name) {
|
|
|
3050
3055
|
* @param engine - 引擎实例
|
|
3051
3056
|
*/ _proto.onAssetsLoadFinish = function onAssetsLoadFinish(scene, options, engine) {};
|
|
3052
3057
|
/**
|
|
3058
|
+
* 合成内容开始创建前触发。
|
|
3059
|
+
* 此时 root、pluginRoot 和 sceneRoot 已创建,但场景内容尚未实例化。
|
|
3060
|
+
* @param composition - 正在创建的合成对象
|
|
3061
|
+
* @param scene - 场景对象
|
|
3062
|
+
*/ _proto.onCompositionCreating = function onCompositionCreating(composition, scene) {};
|
|
3063
|
+
/**
|
|
3053
3064
|
* 合成创建完成后触发。
|
|
3054
3065
|
* @param composition - 合成对象
|
|
3055
3066
|
* @param scene - 场景对象
|
|
@@ -15658,35 +15669,35 @@ function vecMulCombine(out, a, b) {
|
|
|
15658
15669
|
}
|
|
15659
15670
|
return out;
|
|
15660
15671
|
}
|
|
15661
|
-
var _obj$
|
|
15662
|
-
var particleOriginTranslateMap$1 = (_obj$
|
|
15672
|
+
var _obj$6;
|
|
15673
|
+
var particleOriginTranslateMap$1 = (_obj$6 = {}, _obj$6[ParticleOrigin.PARTICLE_ORIGIN_CENTER] = [
|
|
15663
15674
|
0,
|
|
15664
15675
|
0
|
|
15665
|
-
], _obj$
|
|
15676
|
+
], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_CENTER_BOTTOM] = [
|
|
15666
15677
|
0,
|
|
15667
15678
|
-0.5
|
|
15668
|
-
], _obj$
|
|
15679
|
+
], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_CENTER_TOP] = [
|
|
15669
15680
|
0,
|
|
15670
15681
|
0.5
|
|
15671
|
-
], _obj$
|
|
15682
|
+
], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_LEFT_TOP] = [
|
|
15672
15683
|
-0.5,
|
|
15673
15684
|
0.5
|
|
15674
|
-
], _obj$
|
|
15685
|
+
], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_LEFT_CENTER] = [
|
|
15675
15686
|
-0.5,
|
|
15676
15687
|
0
|
|
15677
|
-
], _obj$
|
|
15688
|
+
], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_LEFT_BOTTOM] = [
|
|
15678
15689
|
-0.5,
|
|
15679
15690
|
-0.5
|
|
15680
|
-
], _obj$
|
|
15691
|
+
], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_CENTER] = [
|
|
15681
15692
|
0.5,
|
|
15682
15693
|
0
|
|
15683
|
-
], _obj$
|
|
15694
|
+
], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_BOTTOM] = [
|
|
15684
15695
|
0.5,
|
|
15685
15696
|
-0.5
|
|
15686
|
-
], _obj$
|
|
15697
|
+
], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_TOP] = [
|
|
15687
15698
|
0.5,
|
|
15688
15699
|
0.5
|
|
15689
|
-
], _obj$
|
|
15700
|
+
], _obj$6);
|
|
15690
15701
|
function nearestPowerOfTwo(value) {
|
|
15691
15702
|
return Math.pow(2, Math.round(Math.log(value) / Math.LN2));
|
|
15692
15703
|
}
|
|
@@ -17424,27 +17435,27 @@ function oldBezierKeyFramesToNew(props) {
|
|
|
17424
17435
|
* 对象引用阶梯曲线(spec ValueType.REFERENCE_CURVE)。
|
|
17425
17436
|
* props 为 [[time, value], ...],value 为已解析的对象引用实例。
|
|
17426
17437
|
*/ var REFERENCE_CURVE = 28;
|
|
17427
|
-
var _obj$
|
|
17428
|
-
var map$1 = (_obj$
|
|
17438
|
+
var _obj$5;
|
|
17439
|
+
var map$1 = (_obj$5 = {}, _obj$5[ValueType.RANDOM] = function(props) {
|
|
17429
17440
|
if (_instanceof1(props[0], Array)) {
|
|
17430
17441
|
return new RandomVectorValue(props);
|
|
17431
17442
|
}
|
|
17432
17443
|
return new RandomValue(props);
|
|
17433
|
-
}, _obj$
|
|
17444
|
+
}, _obj$5[ValueType.CONSTANT] = function(props) {
|
|
17434
17445
|
return new StaticValue(props);
|
|
17435
|
-
}, _obj$
|
|
17446
|
+
}, _obj$5[ValueType.CONSTANT_VEC2] = function(props) {
|
|
17436
17447
|
return new StaticValue(props);
|
|
17437
|
-
}, _obj$
|
|
17448
|
+
}, _obj$5[ValueType.CONSTANT_VEC3] = function(props) {
|
|
17438
17449
|
return new StaticValue(props);
|
|
17439
|
-
}, _obj$
|
|
17450
|
+
}, _obj$5[ValueType.CONSTANT_VEC4] = function(props) {
|
|
17440
17451
|
return new StaticValue(props);
|
|
17441
|
-
}, _obj$
|
|
17452
|
+
}, _obj$5[ValueType.RGBA_COLOR] = function(props) {
|
|
17442
17453
|
return new StaticValue(props);
|
|
17443
|
-
}, _obj$
|
|
17454
|
+
}, _obj$5[ValueType.COLORS] = function(props) {
|
|
17444
17455
|
return new RandomSetValue(props.map(function(c) {
|
|
17445
17456
|
return colorToArr$1(c, false);
|
|
17446
17457
|
}));
|
|
17447
|
-
}, _obj$
|
|
17458
|
+
}, _obj$5[ValueType.LINE] = function(props) {
|
|
17448
17459
|
if (props.length === 2 && props[0][0] === 0 && props[1][0] === 1) {
|
|
17449
17460
|
return new LinearValue([
|
|
17450
17461
|
props[0][1],
|
|
@@ -17452,38 +17463,38 @@ var map$1 = (_obj$6 = {}, _obj$6[ValueType.RANDOM] = function(props) {
|
|
|
17452
17463
|
]);
|
|
17453
17464
|
}
|
|
17454
17465
|
return new LineSegments(props);
|
|
17455
|
-
}, _obj$
|
|
17466
|
+
}, _obj$5[ValueType.GRADIENT_COLOR] = function(props) {
|
|
17456
17467
|
return new GradientValue(props);
|
|
17457
|
-
}, _obj$
|
|
17468
|
+
}, _obj$5[ValueType.LINEAR_PATH] = function(pros) {
|
|
17458
17469
|
return new PathSegments(pros);
|
|
17459
|
-
}, _obj$
|
|
17470
|
+
}, _obj$5[ValueType.BEZIER_CURVE] = function(props) {
|
|
17460
17471
|
if (props.length === 1) {
|
|
17461
17472
|
return new StaticValue(props[0][1][1]);
|
|
17462
17473
|
}
|
|
17463
17474
|
return new BezierCurve(props);
|
|
17464
|
-
}, _obj$
|
|
17475
|
+
}, _obj$5[ValueType.BEZIER_CURVE_PATH] = function(props) {
|
|
17465
17476
|
if (props[0].length === 1) {
|
|
17466
17477
|
return new StaticValue(_construct(Vector3, [].concat(props[1][0])));
|
|
17467
17478
|
}
|
|
17468
17479
|
return new BezierCurvePath(props);
|
|
17469
|
-
}, _obj$
|
|
17480
|
+
}, _obj$5[ValueType.BEZIER_CURVE_QUAT] = function(props) {
|
|
17470
17481
|
if (props[0].length === 1) {
|
|
17471
17482
|
return new StaticValue(_construct(Quaternion, [].concat(props[1][0])));
|
|
17472
17483
|
}
|
|
17473
17484
|
return new BezierCurveQuat(props);
|
|
17474
|
-
}, _obj$
|
|
17485
|
+
}, _obj$5[ValueType.COLOR_CURVE] = function(props) {
|
|
17475
17486
|
return new ColorCurve(props);
|
|
17476
|
-
}, _obj$
|
|
17487
|
+
}, _obj$5[ValueType.VECTOR4_CURVE] = function(props) {
|
|
17477
17488
|
return new Vector4Curve(props);
|
|
17478
|
-
}, _obj$
|
|
17489
|
+
}, _obj$5[ValueType.VECTOR2_CURVE] = function(props) {
|
|
17479
17490
|
return new Vector2Curve(props);
|
|
17480
17491
|
}, // TODO: add spec
|
|
17481
|
-
_obj$
|
|
17492
|
+
_obj$5[VECTOR3_CURVE] = function(props) {
|
|
17482
17493
|
return new Vector3Curve(props);
|
|
17483
17494
|
}, // 对象引用阶梯曲线(不插值):props.data 为 [time, value][],value 已解析为 EffectsObject
|
|
17484
|
-
_obj$
|
|
17495
|
+
_obj$5[REFERENCE_CURVE] = function(props) {
|
|
17485
17496
|
return new ReferenceCurve(props);
|
|
17486
|
-
}, _obj$
|
|
17497
|
+
}, _obj$5);
|
|
17487
17498
|
function createValueGetter(args) {
|
|
17488
17499
|
if (!args || !isNaN(+args)) {
|
|
17489
17500
|
return new StaticValue(args || 0);
|
|
@@ -21424,8 +21435,8 @@ var vertexBufferSemanticMap = {
|
|
|
21424
21435
|
TANGENT_BS2: "aTargetTangent2",
|
|
21425
21436
|
TANGENT_BS3: "aTargetTangent3"
|
|
21426
21437
|
};
|
|
21427
|
-
var _obj$
|
|
21428
|
-
var BYTES_TYPE_MAP = (_obj$
|
|
21438
|
+
var _obj$4;
|
|
21439
|
+
var BYTES_TYPE_MAP = (_obj$4 = {}, _obj$4[exports.BufferDataType.Float] = 4, _obj$4[exports.BufferDataType.Int] = 4, _obj$4[exports.BufferDataType.UnsignedInt] = 4, _obj$4[exports.BufferDataType.Short] = 2, _obj$4[exports.BufferDataType.UnsignedShort] = 2, _obj$4[exports.BufferDataType.Byte] = 1, _obj$4[exports.BufferDataType.UnsignedByte] = 1, _obj$4);
|
|
21429
21440
|
function generateEmptyTypedArray(type) {
|
|
21430
21441
|
return createTypedArray(type, 0);
|
|
21431
21442
|
}
|
|
@@ -22942,7 +22953,7 @@ var canvasPool = new CanvasPool();
|
|
|
22942
22953
|
* `ATLAS_SIZE × ATLAS_SIZE` 的离屏 canvas atlas,字符按需逐个绘制并打包,
|
|
22943
22954
|
* `Graphics.drawText` 通过逐字 quad 引用 atlas 子矩形渲染。
|
|
22944
22955
|
*
|
|
22945
|
-
* - 同一段文本不同颜色不会重复 upload(颜色由顶点 `vColor`
|
|
22956
|
+
* - 同一段文本不同颜色不会重复 upload(颜色由顶点 `vColor` 与字形 RGBA 相乘)
|
|
22946
22957
|
* - 同一字体/字号下重复字符只渲染一次,显著减少 canvas → texture 上传次数
|
|
22947
22958
|
*
|
|
22948
22959
|
* 入参全部展开(避免调用方每帧创建临时 style 对象触发 GC)
|
|
@@ -22956,7 +22967,7 @@ var canvasPool = new CanvasPool();
|
|
|
22956
22967
|
/**
|
|
22957
22968
|
* 取(必要时新建)对应字体的字符 atlas
|
|
22958
22969
|
*/ _proto.getAtlas = function getAtlas(fontSize, fontFamily, fontWeight, fontStyle) {
|
|
22959
|
-
//
|
|
22970
|
+
// 字形 atlas 跟随 Engine.pixelRatio。
|
|
22960
22971
|
var resolution = this.engine.pixelRatio;
|
|
22961
22972
|
if (resolution !== this.resolution) {
|
|
22962
22973
|
this.clear();
|
|
@@ -22977,14 +22988,11 @@ var canvasPool = new CanvasPool();
|
|
|
22977
22988
|
var probeCtx = probeCanvasAndContext.context;
|
|
22978
22989
|
var ascentPx = fontSize * 0.8 * resolution;
|
|
22979
22990
|
var descentPx = fontSize * 0.2 * resolution;
|
|
22980
|
-
|
|
22981
|
-
|
|
22982
|
-
|
|
22983
|
-
|
|
22984
|
-
|
|
22985
|
-
} finally{
|
|
22986
|
-
canvasPool.releaseCanvasAndContext(probeCanvasAndContext);
|
|
22987
|
-
}
|
|
22991
|
+
probeCtx.font = scaledFontString;
|
|
22992
|
+
var m = probeCtx.measureText(METRICS_STRING + BASELINE_SYMBOL);
|
|
22993
|
+
ascentPx = m.actualBoundingBoxAscent || ascentPx;
|
|
22994
|
+
descentPx = m.actualBoundingBoxDescent || descentPx;
|
|
22995
|
+
canvasPool.releaseCanvasAndContext(probeCanvasAndContext);
|
|
22988
22996
|
var atlas = new GlyphAtlas(this.engine, scaledFontString, ascentPx, descentPx, fontStyle, resolution);
|
|
22989
22997
|
this.atlases.set(fontKey, atlas);
|
|
22990
22998
|
return atlas;
|
|
@@ -23020,6 +23028,10 @@ var FULL_REGION = {
|
|
|
23020
23028
|
u1: 1,
|
|
23021
23029
|
v1: 1
|
|
23022
23030
|
};
|
|
23031
|
+
var NINE_PATCH_DRAW_SOURCE_SIZE = "aDrawSourceSize";
|
|
23032
|
+
var NINE_PATCH_SOURCE_RECT = "aSourceRect";
|
|
23033
|
+
var NINE_PATCH_MARGINS = "aMargins";
|
|
23034
|
+
var NINE_PATCH_OPTIONS = "aOptions";
|
|
23023
23035
|
var Graphics = /*#__PURE__*/ function() {
|
|
23024
23036
|
function Graphics(engine) {
|
|
23025
23037
|
this.engine = engine;
|
|
@@ -23033,6 +23045,10 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
23033
23045
|
this.colors = [];
|
|
23034
23046
|
this.uvs = [];
|
|
23035
23047
|
this.indices = [];
|
|
23048
|
+
this.ninePatchDrawSourceSizes = [];
|
|
23049
|
+
this.ninePatchSourceRects = [];
|
|
23050
|
+
this.ninePatchMargins = [];
|
|
23051
|
+
this.ninePatchOptions = [];
|
|
23036
23052
|
this.lineStyle = {
|
|
23037
23053
|
width: 1,
|
|
23038
23054
|
alignment: 0.5,
|
|
@@ -23044,6 +23060,9 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
23044
23060
|
this.currentBatchTexture = null;
|
|
23045
23061
|
this.transformStack = [];
|
|
23046
23062
|
this.currentTransform = Matrix3.fromIdentity();
|
|
23063
|
+
this.clipStack = [];
|
|
23064
|
+
this.logicalWidth = 1;
|
|
23065
|
+
this.logicalHeight = 1;
|
|
23047
23066
|
var _obj;
|
|
23048
23067
|
this.geometry = Geometry.create(this.engine, {
|
|
23049
23068
|
attributes: (_obj = {}, _obj[VertexBuffer.PositionKind] = {
|
|
@@ -23109,6 +23128,51 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
23109
23128
|
drawCount: 6,
|
|
23110
23129
|
bufferUsage: glContext.DYNAMIC_DRAW
|
|
23111
23130
|
});
|
|
23131
|
+
var _obj1;
|
|
23132
|
+
this.ninePatchGeometry = Geometry.create(this.engine, {
|
|
23133
|
+
attributes: (_obj1 = {}, _obj1[VertexBuffer.PositionKind] = {
|
|
23134
|
+
type: glContext.FLOAT,
|
|
23135
|
+
size: 2,
|
|
23136
|
+
data: new Float32Array(8)
|
|
23137
|
+
}, _obj1[VertexBuffer.ColorKind] = {
|
|
23138
|
+
type: glContext.FLOAT,
|
|
23139
|
+
size: 4,
|
|
23140
|
+
data: new Float32Array(16)
|
|
23141
|
+
}, _obj1[VertexBuffer.UVKind] = {
|
|
23142
|
+
type: glContext.FLOAT,
|
|
23143
|
+
size: 2,
|
|
23144
|
+
data: new Float32Array(8)
|
|
23145
|
+
}, _obj1[NINE_PATCH_DRAW_SOURCE_SIZE] = {
|
|
23146
|
+
type: glContext.FLOAT,
|
|
23147
|
+
size: 4,
|
|
23148
|
+
data: new Float32Array(16)
|
|
23149
|
+
}, _obj1[NINE_PATCH_SOURCE_RECT] = {
|
|
23150
|
+
type: glContext.FLOAT,
|
|
23151
|
+
size: 4,
|
|
23152
|
+
data: new Float32Array(16)
|
|
23153
|
+
}, _obj1[NINE_PATCH_MARGINS] = {
|
|
23154
|
+
type: glContext.FLOAT,
|
|
23155
|
+
size: 4,
|
|
23156
|
+
data: new Float32Array(16)
|
|
23157
|
+
}, _obj1[NINE_PATCH_OPTIONS] = {
|
|
23158
|
+
type: glContext.FLOAT,
|
|
23159
|
+
size: 4,
|
|
23160
|
+
data: new Float32Array(16)
|
|
23161
|
+
}, _obj1),
|
|
23162
|
+
indices: {
|
|
23163
|
+
data: new Uint16Array([
|
|
23164
|
+
0,
|
|
23165
|
+
1,
|
|
23166
|
+
2,
|
|
23167
|
+
2,
|
|
23168
|
+
1,
|
|
23169
|
+
3
|
|
23170
|
+
])
|
|
23171
|
+
},
|
|
23172
|
+
mode: glContext.TRIANGLES,
|
|
23173
|
+
drawCount: 6,
|
|
23174
|
+
bufferUsage: glContext.DYNAMIC_DRAW
|
|
23175
|
+
});
|
|
23112
23176
|
this.coloredMaterial = Material.create(this.engine, {
|
|
23113
23177
|
shader: {
|
|
23114
23178
|
vertex: "precision highp float;\n attribute vec2 aPos;\n attribute vec4 aColor;\n varying vec4 vColor;\n\n uniform mat4 effects_MatrixVP;\n void main() {\n vColor = aColor;\n gl_Position = effects_MatrixVP * vec4(aPos, 0.0, 1.0);\n }",
|
|
@@ -23127,12 +23191,21 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
23127
23191
|
this.texturedMaterial.depthTest = false;
|
|
23128
23192
|
this.texturedMaterial.depthMask = false;
|
|
23129
23193
|
this.texturedMaterial.blending = true;
|
|
23130
|
-
|
|
23194
|
+
this.ninePatchMaterial = Material.create(this.engine, {
|
|
23195
|
+
shader: {
|
|
23196
|
+
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 }",
|
|
23197
|
+
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 }"
|
|
23198
|
+
}
|
|
23199
|
+
});
|
|
23200
|
+
this.ninePatchMaterial.depthTest = false;
|
|
23201
|
+
this.ninePatchMaterial.depthMask = false;
|
|
23202
|
+
this.ninePatchMaterial.blending = true;
|
|
23203
|
+
// 文本 atlas 在上传时预乘 alpha,因此纹理 RGB 只需乘顶点色和顶点 alpha。
|
|
23131
23204
|
// 单独使用 material,避免改变 drawTexture 对普通非预乘纹理的处理。
|
|
23132
23205
|
this.textMaterial = Material.create(this.engine, {
|
|
23133
23206
|
shader: {
|
|
23134
23207
|
vertex: "precision highp float;\n attribute vec2 aPos;\n attribute vec4 aColor;\n attribute vec2 aUV;\n varying vec4 vColor;\n varying vec2 vUV;\n\n uniform mat4 effects_MatrixVP;\n void main() {\n vColor = aColor;\n vUV = aUV;\n gl_Position = effects_MatrixVP * vec4(aPos, 0.0, 1.0);\n }",
|
|
23135
|
-
fragment: "precision highp float;\n varying vec4 vColor;\n varying vec2 vUV;\n uniform sampler2D uMainTexture;\n void main() {\n
|
|
23208
|
+
fragment: "precision highp float;\n varying vec4 vColor;\n varying vec2 vUV;\n uniform sampler2D uMainTexture;\n void main() {\n vec4 textureColor = texture2D(uMainTexture, vUV);\n float alpha = textureColor.a * vColor.a;\n vec3 rgb = textureColor.rgb * vColor.rgb * vColor.a;\n gl_FragColor = vec4(rgb, alpha);\n }"
|
|
23136
23209
|
}
|
|
23137
23210
|
});
|
|
23138
23211
|
this.textMaterial.depthTest = false;
|
|
@@ -23148,25 +23221,36 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
23148
23221
|
this.vertices.length = 0;
|
|
23149
23222
|
this.colors.length = 0;
|
|
23150
23223
|
this.uvs.length = 0;
|
|
23224
|
+
this.ninePatchDrawSourceSizes.length = 0;
|
|
23225
|
+
this.ninePatchSourceRects.length = 0;
|
|
23226
|
+
this.ninePatchMargins.length = 0;
|
|
23227
|
+
this.ninePatchOptions.length = 0;
|
|
23151
23228
|
this.transformStack = [];
|
|
23152
23229
|
this.currentTransform = Matrix3.fromIdentity();
|
|
23230
|
+
this.clipStack = [];
|
|
23153
23231
|
this.currentBatchType = "colored";
|
|
23154
23232
|
this.currentBatchTexture = null;
|
|
23233
|
+
this.engine.setScissorTest(false);
|
|
23155
23234
|
// 创建从屏幕坐标到 NDC 的投影矩阵,屏幕坐标:(0, 0) 在左上角,(width, height) 在右下角,+Y 向下。
|
|
23156
|
-
var
|
|
23235
|
+
var bounds = this.engine.canvas.getBoundingClientRect();
|
|
23236
|
+
var width = bounds.width || this.engine.canvas.width / this.engine.pixelRatio || 1;
|
|
23237
|
+
var height = bounds.height || this.engine.canvas.height / this.engine.pixelRatio || 1;
|
|
23238
|
+
this.logicalWidth = width;
|
|
23239
|
+
this.logicalHeight = height;
|
|
23157
23240
|
// 正交投影矩阵:将屏幕坐标 [0, width] x [0, height] 映射到 NDC [-1, 1] x [-1, 1]
|
|
23158
23241
|
var projectionMatrix = new Matrix4(2 / width, 0, 0, 0, 0, -2 / height, 0, 0, 0, 0, -1, 0, -1, 1, 0, 1 // 第四列
|
|
23159
23242
|
);
|
|
23160
23243
|
this.coloredMaterial.setMatrix("effects_MatrixVP", projectionMatrix);
|
|
23161
23244
|
this.texturedMaterial.setMatrix("effects_MatrixVP", projectionMatrix);
|
|
23162
23245
|
this.textMaterial.setMatrix("effects_MatrixVP", projectionMatrix);
|
|
23246
|
+
this.ninePatchMaterial.setMatrix("effects_MatrixVP", projectionMatrix);
|
|
23163
23247
|
};
|
|
23164
23248
|
/**
|
|
23165
23249
|
* 将当前变换压入栈,并设置新的变换
|
|
23166
23250
|
* @param transform - 新的变换矩阵(会与当前变换相乘)
|
|
23167
23251
|
*/ _proto.pushTransform = function pushTransform(transform) {
|
|
23168
23252
|
this.transformStack.push(this.currentTransform.clone());
|
|
23169
|
-
this.currentTransform = this.currentTransform.
|
|
23253
|
+
this.currentTransform = this.currentTransform.multiply(transform);
|
|
23170
23254
|
};
|
|
23171
23255
|
/**
|
|
23172
23256
|
* 恢复上一个变换
|
|
@@ -23178,10 +23262,81 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
23178
23262
|
}
|
|
23179
23263
|
this.currentTransform = transform;
|
|
23180
23264
|
};
|
|
23265
|
+
/** Pushes a local rectangular child clip using a screen-space AABB scissor. */ _proto.pushClipRect = function pushClipRect(x, y, width, height) {
|
|
23266
|
+
var elements = this.currentTransform.elements;
|
|
23267
|
+
var corners = [
|
|
23268
|
+
[
|
|
23269
|
+
x,
|
|
23270
|
+
y
|
|
23271
|
+
],
|
|
23272
|
+
[
|
|
23273
|
+
x + width,
|
|
23274
|
+
y
|
|
23275
|
+
],
|
|
23276
|
+
[
|
|
23277
|
+
x,
|
|
23278
|
+
y + height
|
|
23279
|
+
],
|
|
23280
|
+
[
|
|
23281
|
+
x + width,
|
|
23282
|
+
y + height
|
|
23283
|
+
]
|
|
23284
|
+
];
|
|
23285
|
+
var left = Infinity;
|
|
23286
|
+
var top = Infinity;
|
|
23287
|
+
var right = -Infinity;
|
|
23288
|
+
var bottom = -Infinity;
|
|
23289
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(corners), _step; !(_step = _iterator()).done;){
|
|
23290
|
+
var corner = _step.value;
|
|
23291
|
+
var transformedX = elements[0] * corner[0] + elements[3] * corner[1] + elements[6];
|
|
23292
|
+
var transformedY = elements[1] * corner[0] + elements[4] * corner[1] + elements[7];
|
|
23293
|
+
left = Math.min(left, transformedX);
|
|
23294
|
+
top = Math.min(top, transformedY);
|
|
23295
|
+
right = Math.max(right, transformedX);
|
|
23296
|
+
bottom = Math.max(bottom, transformedY);
|
|
23297
|
+
}
|
|
23298
|
+
var parent = this.clipStack[this.clipStack.length - 1];
|
|
23299
|
+
if (parent) {
|
|
23300
|
+
left = Math.max(left, parent.x);
|
|
23301
|
+
top = Math.max(top, parent.y);
|
|
23302
|
+
right = Math.min(right, parent.x + parent.width);
|
|
23303
|
+
bottom = Math.min(bottom, parent.y + parent.height);
|
|
23304
|
+
}
|
|
23305
|
+
var clip = {
|
|
23306
|
+
x: left,
|
|
23307
|
+
y: top,
|
|
23308
|
+
width: Math.max(0, right - left),
|
|
23309
|
+
height: Math.max(0, bottom - top)
|
|
23310
|
+
};
|
|
23311
|
+
var previous = parent;
|
|
23312
|
+
this.clipStack.push(clip);
|
|
23313
|
+
if (!this.clipRectsEqual(previous, clip)) {
|
|
23314
|
+
this.flushBatch();
|
|
23315
|
+
this.applyClipRect(clip);
|
|
23316
|
+
}
|
|
23317
|
+
};
|
|
23318
|
+
/** Restores the parent rectangular clip. */ _proto.popClipRect = function popClipRect() {
|
|
23319
|
+
var previous = this.clipStack.pop();
|
|
23320
|
+
if (!previous) {
|
|
23321
|
+
console.warn("Graphics: clip stack is empty.");
|
|
23322
|
+
return;
|
|
23323
|
+
}
|
|
23324
|
+
var clip = this.clipStack[this.clipStack.length - 1];
|
|
23325
|
+
if (!this.clipRectsEqual(previous, clip)) {
|
|
23326
|
+
this.flushBatch();
|
|
23327
|
+
if (clip) {
|
|
23328
|
+
this.applyClipRect(clip);
|
|
23329
|
+
} else {
|
|
23330
|
+
this.engine.setScissorTest(false);
|
|
23331
|
+
}
|
|
23332
|
+
}
|
|
23333
|
+
};
|
|
23181
23334
|
/**
|
|
23182
23335
|
* 刷新并渲染所有累积的绘制命令
|
|
23183
23336
|
*/ _proto.end = function end() {
|
|
23184
23337
|
this.flushBatch();
|
|
23338
|
+
this.clipStack = [];
|
|
23339
|
+
this.engine.setScissorTest(false);
|
|
23185
23340
|
};
|
|
23186
23341
|
/**
|
|
23187
23342
|
* 切换到指定批次类型/纹理。若与当前批次不一致,先 flush 已累积顶点
|
|
@@ -23194,6 +23349,24 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
23194
23349
|
this.currentBatchType = type;
|
|
23195
23350
|
this.currentBatchTexture = texture;
|
|
23196
23351
|
};
|
|
23352
|
+
_proto.applyClipRect = function applyClipRect(clip) {
|
|
23353
|
+
var framebufferWidth = this.engine.canvas.width;
|
|
23354
|
+
var framebufferHeight = this.engine.canvas.height;
|
|
23355
|
+
var scaleX = framebufferWidth / this.logicalWidth;
|
|
23356
|
+
var scaleY = framebufferHeight / this.logicalHeight;
|
|
23357
|
+
var left = Math.max(0, Math.min(framebufferWidth, Math.floor(clip.x * scaleX)));
|
|
23358
|
+
var top = Math.max(0, Math.min(framebufferHeight, Math.floor(clip.y * scaleY)));
|
|
23359
|
+
var right = Math.max(left, Math.min(framebufferWidth, Math.ceil((clip.x + clip.width) * scaleX)));
|
|
23360
|
+
var bottom = Math.max(top, Math.min(framebufferHeight, Math.ceil((clip.y + clip.height) * scaleY)));
|
|
23361
|
+
this.engine.setScissorTest(true);
|
|
23362
|
+
this.engine.setScissor(left, framebufferHeight - bottom, right - left, bottom - top);
|
|
23363
|
+
};
|
|
23364
|
+
_proto.clipRectsEqual = function clipRectsEqual(left, right) {
|
|
23365
|
+
if (!left || !right) {
|
|
23366
|
+
return left === right;
|
|
23367
|
+
}
|
|
23368
|
+
return left.x === right.x && left.y === right.y && left.width === right.width && left.height === right.height;
|
|
23369
|
+
};
|
|
23197
23370
|
/**
|
|
23198
23371
|
* 提交当前累积的顶点到 renderer,清空缓冲(批次内部 flush 不重置 batchType)
|
|
23199
23372
|
*/ _proto.flushBatch = function flushBatch() {
|
|
@@ -23207,37 +23380,48 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
23207
23380
|
var colorsArray = new Float32Array(this.colors);
|
|
23208
23381
|
var uvsArray = new Float32Array(this.uvs);
|
|
23209
23382
|
var indicesArray = new Uint16Array(this.indices);
|
|
23210
|
-
this.
|
|
23211
|
-
this.updateAttributeData(VertexBuffer.
|
|
23212
|
-
this.updateAttributeData(VertexBuffer.
|
|
23213
|
-
this.geometry.
|
|
23214
|
-
|
|
23383
|
+
var geometry = this.currentBatchType === "ninePatch" ? this.ninePatchGeometry : this.geometry;
|
|
23384
|
+
this.updateAttributeData(geometry, VertexBuffer.PositionKind, verticesArray, 2);
|
|
23385
|
+
this.updateAttributeData(geometry, VertexBuffer.ColorKind, colorsArray, 4);
|
|
23386
|
+
this.updateAttributeData(geometry, VertexBuffer.UVKind, uvsArray, 2);
|
|
23387
|
+
if (this.currentBatchType === "ninePatch") {
|
|
23388
|
+
this.updateAttributeData(geometry, NINE_PATCH_DRAW_SOURCE_SIZE, new Float32Array(this.ninePatchDrawSourceSizes), 4);
|
|
23389
|
+
this.updateAttributeData(geometry, NINE_PATCH_SOURCE_RECT, new Float32Array(this.ninePatchSourceRects), 4);
|
|
23390
|
+
this.updateAttributeData(geometry, NINE_PATCH_MARGINS, new Float32Array(this.ninePatchMargins), 4);
|
|
23391
|
+
this.updateAttributeData(geometry, NINE_PATCH_OPTIONS, new Float32Array(this.ninePatchOptions), 4);
|
|
23392
|
+
}
|
|
23393
|
+
geometry.setIndexData(indicesArray);
|
|
23394
|
+
geometry.setDrawCount(this.currentIndexCount);
|
|
23215
23395
|
var material;
|
|
23216
|
-
if (this.currentBatchType === "textured" || this.currentBatchType === "text") {
|
|
23217
|
-
material = this.currentBatchType === "text" ? this.textMaterial : this.texturedMaterial;
|
|
23396
|
+
if (this.currentBatchType === "textured" || this.currentBatchType === "text" || this.currentBatchType === "ninePatch") {
|
|
23397
|
+
material = this.currentBatchType === "text" ? this.textMaterial : this.currentBatchType === "ninePatch" ? this.ninePatchMaterial : this.texturedMaterial;
|
|
23218
23398
|
var _this_currentBatchTexture;
|
|
23219
23399
|
var tex = (_this_currentBatchTexture = this.currentBatchTexture) != null ? _this_currentBatchTexture : this.engine.whiteTexture;
|
|
23220
23400
|
material.setTexture("uMainTexture", tex);
|
|
23221
23401
|
} else {
|
|
23222
23402
|
material = this.coloredMaterial;
|
|
23223
23403
|
}
|
|
23224
|
-
this.engine.renderer.drawGeometry(
|
|
23404
|
+
this.engine.renderer.drawGeometry(geometry, Matrix4.IDENTITY, material);
|
|
23225
23405
|
this.indices.length = 0;
|
|
23226
23406
|
this.vertices.length = 0;
|
|
23227
23407
|
this.colors.length = 0;
|
|
23228
23408
|
this.uvs.length = 0;
|
|
23229
|
-
|
|
23230
|
-
|
|
23231
|
-
|
|
23232
|
-
|
|
23409
|
+
this.ninePatchDrawSourceSizes.length = 0;
|
|
23410
|
+
this.ninePatchSourceRects.length = 0;
|
|
23411
|
+
this.ninePatchMargins.length = 0;
|
|
23412
|
+
this.ninePatchOptions.length = 0;
|
|
23413
|
+
};
|
|
23414
|
+
_proto.updateAttributeData = function updateAttributeData(geometry, name, data, size) {
|
|
23415
|
+
var _geometry_getVertexBuffer;
|
|
23416
|
+
var dataBuffer = (_geometry_getVertexBuffer = geometry.getVertexBuffer(name)) == null ? void 0 : _geometry_getVertexBuffer.getBuffer();
|
|
23233
23417
|
if (dataBuffer && data.byteLength > dataBuffer.capacity) {
|
|
23234
|
-
|
|
23418
|
+
geometry.setVerticesBuffer(new VertexBuffer(this.engine, data, name, {
|
|
23235
23419
|
updatable: true,
|
|
23236
23420
|
size: size
|
|
23237
23421
|
}));
|
|
23238
23422
|
return;
|
|
23239
23423
|
}
|
|
23240
|
-
|
|
23424
|
+
geometry.setAttributeData(name, data);
|
|
23241
23425
|
};
|
|
23242
23426
|
/**
|
|
23243
23427
|
* 线段顶点按顺序连接 (p0-p1, p1-p2, p2-p3, ...)
|
|
@@ -23406,10 +23590,37 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
23406
23590
|
this.pushQuad(x, y, width, height, color, region);
|
|
23407
23591
|
};
|
|
23408
23592
|
/**
|
|
23593
|
+
* Draws a nine-patch as one quad. Stretching and repetition are resolved in the fragment shader,
|
|
23594
|
+
* so Tile and TileFit do not expand into CPU-side geometry.
|
|
23595
|
+
*/ _proto.drawNinePatch = function drawNinePatch(x, y, width, height, texture, options, color) {
|
|
23596
|
+
if (color === void 0) color = Color.WHITE;
|
|
23597
|
+
if (width <= 0 || height <= 0 || options.sourceWidth <= 0 || options.sourceHeight <= 0) {
|
|
23598
|
+
return;
|
|
23599
|
+
}
|
|
23600
|
+
this.ensureBatch("ninePatch", texture);
|
|
23601
|
+
var sourceU = options.sourceX / texture.width;
|
|
23602
|
+
var sourceV = 1 - options.sourceY / texture.height;
|
|
23603
|
+
var sourceUSize = options.sourceWidth / texture.width;
|
|
23604
|
+
var sourceVSize = options.sourceHeight / texture.height;
|
|
23605
|
+
var _options_horizontalMode;
|
|
23606
|
+
var horizontalMode = (_options_horizontalMode = options.horizontalMode) != null ? _options_horizontalMode : 0;
|
|
23607
|
+
var _options_verticalMode;
|
|
23608
|
+
var verticalMode = (_options_verticalMode = options.verticalMode) != null ? _options_verticalMode : 0;
|
|
23609
|
+
var _options_drawCenter;
|
|
23610
|
+
var drawCenter = Number((_options_drawCenter = options.drawCenter) != null ? _options_drawCenter : true);
|
|
23611
|
+
this.pushQuad(x, y, width, height, color, FULL_REGION);
|
|
23612
|
+
for(var i = 0; i < 4; i++){
|
|
23613
|
+
this.ninePatchDrawSourceSizes.push(width, height, options.sourceWidth, options.sourceHeight);
|
|
23614
|
+
this.ninePatchSourceRects.push(sourceU, sourceV, sourceUSize, sourceVSize);
|
|
23615
|
+
this.ninePatchMargins.push(options.marginLeft, options.marginTop, options.marginRight, options.marginBottom);
|
|
23616
|
+
this.ninePatchOptions.push(horizontalMode, verticalMode, drawCenter, 0);
|
|
23617
|
+
}
|
|
23618
|
+
};
|
|
23619
|
+
/**
|
|
23409
23620
|
* 绘制文本(本地坐标,Y 向下,(x, y) 为文本 cell 左上角)。
|
|
23410
23621
|
*
|
|
23411
23622
|
* 文本走字符级 bitmap atlas(同一字体下每个字只渲染一次,任意文本组合复用 atlas);
|
|
23412
|
-
* `color`
|
|
23623
|
+
* `color` 与 atlas 字形 RGBA 相乘,任意颜色都不会污染 atlas。
|
|
23413
23624
|
*
|
|
23414
23625
|
* 字体参数全部展开,避免调用方每帧创建临时 style 对象触发 GC
|
|
23415
23626
|
* @param x - 文本左上角 X 坐标(首字 ink 起始处,含 padding 的 quad 会向左延伸)
|
|
@@ -23432,10 +23643,11 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
23432
23643
|
this.ensureBatch("text", atlas.texture);
|
|
23433
23644
|
var lineHeight = atlas.lineHeight;
|
|
23434
23645
|
var cursorX = x;
|
|
23646
|
+
var characters = Array.from(text);
|
|
23435
23647
|
// ensureChar 可能往 atlas canvas 写新字并打 dirty 标;实际 upload 推迟到
|
|
23436
23648
|
// flushBatch 统一处理,这样一帧多次 drawText 共写同一 atlas 只 upload 一次
|
|
23437
|
-
for(var i = 0; i <
|
|
23438
|
-
var info = atlas.ensureChar(
|
|
23649
|
+
for(var i = 0; i < characters.length; i++){
|
|
23650
|
+
var info = atlas.ensureChar(characters[i]);
|
|
23439
23651
|
if (!info) {
|
|
23440
23652
|
continue;
|
|
23441
23653
|
}
|
|
@@ -23457,11 +23669,35 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
23457
23669
|
cursorX += info.advance;
|
|
23458
23670
|
}
|
|
23459
23671
|
};
|
|
23672
|
+
/** Measures text with the same glyph metrics used by {@link drawText}. */ _proto.measureText = function measureText(text, fontSize, fontFamily, fontWeight, fontStyle) {
|
|
23673
|
+
if (fontFamily === void 0) fontFamily = "sans-serif";
|
|
23674
|
+
if (fontWeight === void 0) fontWeight = "normal";
|
|
23675
|
+
if (fontStyle === void 0) fontStyle = "normal";
|
|
23676
|
+
var atlas = this.textCache.getAtlas(fontSize, fontFamily, fontWeight, fontStyle);
|
|
23677
|
+
var characters = Array.from(text);
|
|
23678
|
+
var advances = [];
|
|
23679
|
+
var width = 0;
|
|
23680
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(characters), _step; !(_step = _iterator()).done;){
|
|
23681
|
+
var character = _step.value;
|
|
23682
|
+
var _atlas_ensureChar;
|
|
23683
|
+
var _atlas_ensureChar_advance;
|
|
23684
|
+
var advance = (_atlas_ensureChar_advance = (_atlas_ensureChar = atlas.ensureChar(character)) == null ? void 0 : _atlas_ensureChar.advance) != null ? _atlas_ensureChar_advance : 0;
|
|
23685
|
+
advances.push(advance);
|
|
23686
|
+
width += advance;
|
|
23687
|
+
}
|
|
23688
|
+
return {
|
|
23689
|
+
width: width,
|
|
23690
|
+
lineHeight: atlas.lineHeight,
|
|
23691
|
+
advances: advances
|
|
23692
|
+
};
|
|
23693
|
+
};
|
|
23460
23694
|
_proto.dispose = function dispose() {
|
|
23461
23695
|
this.geometry.dispose();
|
|
23696
|
+
this.ninePatchGeometry.dispose();
|
|
23462
23697
|
this.coloredMaterial.dispose();
|
|
23463
23698
|
this.texturedMaterial.dispose();
|
|
23464
23699
|
this.textMaterial.dispose();
|
|
23700
|
+
this.ninePatchMaterial.dispose();
|
|
23465
23701
|
this.textCache.dispose();
|
|
23466
23702
|
};
|
|
23467
23703
|
_proto.buildShape = function buildShape(shape, color) {
|
|
@@ -23469,7 +23705,7 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
23469
23705
|
var indexOffset = this.indices.length;
|
|
23470
23706
|
var vertexOffset = this.vertices.length / 2;
|
|
23471
23707
|
buildPoints.length = 0;
|
|
23472
|
-
shape.build(buildPoints);
|
|
23708
|
+
shape.build(buildPoints, this.getScreenScale());
|
|
23473
23709
|
shape.triangulate(buildPoints, this.vertices, vertexOffset, this.indices, indexOffset);
|
|
23474
23710
|
this.applyTransformAndColor(vertexOffset, this.vertices.length / 2 - vertexOffset, color);
|
|
23475
23711
|
};
|
|
@@ -23479,11 +23715,19 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
23479
23715
|
this.indices.length;
|
|
23480
23716
|
var vertexOffset = this.vertices.length / 2;
|
|
23481
23717
|
buildPoints.length = 0;
|
|
23482
|
-
shape.build(buildPoints);
|
|
23718
|
+
shape.build(buildPoints, this.getScreenScale());
|
|
23483
23719
|
this.lineStyle.width = thickness;
|
|
23484
23720
|
buildLine(buildPoints, this.lineStyle, false, closed, this.vertices, 2, vertexOffset, this.indices);
|
|
23485
23721
|
this.applyTransformAndColor(vertexOffset, this.vertices.length / 2 - vertexOffset, color);
|
|
23486
23722
|
};
|
|
23723
|
+
_proto.getScreenScale = function getScreenScale() {
|
|
23724
|
+
var transform = this.currentTransform.elements;
|
|
23725
|
+
var transformScaleX = Math.hypot(transform[0], transform[1]);
|
|
23726
|
+
var transformScaleY = Math.hypot(transform[3], transform[4]);
|
|
23727
|
+
var framebufferScaleX = this.engine.canvas.width / this.logicalWidth;
|
|
23728
|
+
var framebufferScaleY = this.engine.canvas.height / this.logicalHeight;
|
|
23729
|
+
return Math.max(transformScaleX * framebufferScaleX, transformScaleY * framebufferScaleY, 1);
|
|
23730
|
+
};
|
|
23487
23731
|
_proto.setTriangleShape = function setTriangleShape(x1, y1, x2, y2, x3, y3) {
|
|
23488
23732
|
this.triangleShape.x = x1;
|
|
23489
23733
|
this.triangleShape.y = y1;
|
|
@@ -24532,2107 +24776,6 @@ exports.FrameComponent = __decorate([
|
|
|
24532
24776
|
// 第四列 (位移) 乘 1,无需修改
|
|
24533
24777
|
}
|
|
24534
24778
|
|
|
24535
|
-
function _assert_this_initialized(self) {
|
|
24536
|
-
if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
24537
|
-
return self;
|
|
24538
|
-
}
|
|
24539
|
-
|
|
24540
|
-
exports.MouseFilter = void 0;
|
|
24541
|
-
(function(MouseFilter) {
|
|
24542
|
-
MouseFilter[MouseFilter["Stop"] = 0] = "Stop";
|
|
24543
|
-
MouseFilter[MouseFilter["Pass"] = 1] = "Pass";
|
|
24544
|
-
MouseFilter[MouseFilter["Ignore"] = 2] = "Ignore";
|
|
24545
|
-
})(exports.MouseFilter || (exports.MouseFilter = {}));
|
|
24546
|
-
exports.MouseBehaviorRecursive = void 0;
|
|
24547
|
-
(function(MouseBehaviorRecursive) {
|
|
24548
|
-
MouseBehaviorRecursive[MouseBehaviorRecursive["Inherited"] = 0] = "Inherited";
|
|
24549
|
-
MouseBehaviorRecursive[MouseBehaviorRecursive["Disabled"] = 1] = "Disabled";
|
|
24550
|
-
MouseBehaviorRecursive[MouseBehaviorRecursive["Enabled"] = 2] = "Enabled";
|
|
24551
|
-
})(exports.MouseBehaviorRecursive || (exports.MouseBehaviorRecursive = {}));
|
|
24552
|
-
exports.MouseButton = void 0;
|
|
24553
|
-
(function(MouseButton) {
|
|
24554
|
-
MouseButton[MouseButton["None"] = 0] = "None";
|
|
24555
|
-
MouseButton[MouseButton["Left"] = 1] = "Left";
|
|
24556
|
-
MouseButton[MouseButton["Right"] = 2] = "Right";
|
|
24557
|
-
MouseButton[MouseButton["Middle"] = 3] = "Middle";
|
|
24558
|
-
MouseButton[MouseButton["WheelUp"] = 4] = "WheelUp";
|
|
24559
|
-
MouseButton[MouseButton["WheelDown"] = 5] = "WheelDown";
|
|
24560
|
-
MouseButton[MouseButton["WheelLeft"] = 6] = "WheelLeft";
|
|
24561
|
-
MouseButton[MouseButton["WheelRight"] = 7] = "WheelRight";
|
|
24562
|
-
MouseButton[MouseButton["Xbutton1"] = 8] = "Xbutton1";
|
|
24563
|
-
MouseButton[MouseButton["Xbutton2"] = 9] = "Xbutton2";
|
|
24564
|
-
})(exports.MouseButton || (exports.MouseButton = {}));
|
|
24565
|
-
exports.MouseButtonMask = void 0;
|
|
24566
|
-
(function(MouseButtonMask) {
|
|
24567
|
-
MouseButtonMask[MouseButtonMask["None"] = 0] = "None";
|
|
24568
|
-
MouseButtonMask[MouseButtonMask["Left"] = 1] = "Left";
|
|
24569
|
-
MouseButtonMask[MouseButtonMask["Right"] = 2] = "Right";
|
|
24570
|
-
MouseButtonMask[MouseButtonMask["Middle"] = 4] = "Middle";
|
|
24571
|
-
MouseButtonMask[MouseButtonMask["Xbutton1"] = 128] = "Xbutton1";
|
|
24572
|
-
MouseButtonMask[MouseButtonMask["Xbutton2"] = 256] = "Xbutton2";
|
|
24573
|
-
})(exports.MouseButtonMask || (exports.MouseButtonMask = {}));
|
|
24574
|
-
exports.FocusMode = void 0;
|
|
24575
|
-
(function(FocusMode) {
|
|
24576
|
-
FocusMode[FocusMode["None"] = 0] = "None";
|
|
24577
|
-
FocusMode[FocusMode["Click"] = 1] = "Click";
|
|
24578
|
-
FocusMode[FocusMode["All"] = 2] = "All";
|
|
24579
|
-
FocusMode[FocusMode["Accessibility"] = 3] = "Accessibility";
|
|
24580
|
-
})(exports.FocusMode || (exports.FocusMode = {}));
|
|
24581
|
-
exports.FocusBehaviorRecursive = void 0;
|
|
24582
|
-
(function(FocusBehaviorRecursive) {
|
|
24583
|
-
FocusBehaviorRecursive[FocusBehaviorRecursive["Inherited"] = 0] = "Inherited";
|
|
24584
|
-
FocusBehaviorRecursive[FocusBehaviorRecursive["Disabled"] = 1] = "Disabled";
|
|
24585
|
-
FocusBehaviorRecursive[FocusBehaviorRecursive["Enabled"] = 2] = "Enabled";
|
|
24586
|
-
})(exports.FocusBehaviorRecursive || (exports.FocusBehaviorRecursive = {}));
|
|
24587
|
-
exports.KeyLocation = void 0;
|
|
24588
|
-
(function(KeyLocation) {
|
|
24589
|
-
KeyLocation[KeyLocation["Unspecified"] = 0] = "Unspecified";
|
|
24590
|
-
KeyLocation[KeyLocation["Left"] = 1] = "Left";
|
|
24591
|
-
KeyLocation[KeyLocation["Right"] = 2] = "Right";
|
|
24592
|
-
})(exports.KeyLocation || (exports.KeyLocation = {}));
|
|
24593
|
-
exports.CursorShape = void 0;
|
|
24594
|
-
(function(CursorShape) {
|
|
24595
|
-
CursorShape[CursorShape["Arrow"] = 0] = "Arrow";
|
|
24596
|
-
CursorShape[CursorShape["Ibeam"] = 1] = "Ibeam";
|
|
24597
|
-
CursorShape[CursorShape["PointingHand"] = 2] = "PointingHand";
|
|
24598
|
-
CursorShape[CursorShape["Cross"] = 3] = "Cross";
|
|
24599
|
-
CursorShape[CursorShape["Wait"] = 4] = "Wait";
|
|
24600
|
-
CursorShape[CursorShape["Busy"] = 5] = "Busy";
|
|
24601
|
-
CursorShape[CursorShape["Drag"] = 6] = "Drag";
|
|
24602
|
-
CursorShape[CursorShape["CanDrop"] = 7] = "CanDrop";
|
|
24603
|
-
CursorShape[CursorShape["Forbidden"] = 8] = "Forbidden";
|
|
24604
|
-
CursorShape[CursorShape["Vsize"] = 9] = "Vsize";
|
|
24605
|
-
CursorShape[CursorShape["Hsize"] = 10] = "Hsize";
|
|
24606
|
-
CursorShape[CursorShape["Bdiagsize"] = 11] = "Bdiagsize";
|
|
24607
|
-
CursorShape[CursorShape["Fdiagsize"] = 12] = "Fdiagsize";
|
|
24608
|
-
CursorShape[CursorShape["Move"] = 13] = "Move";
|
|
24609
|
-
CursorShape[CursorShape["Vsplit"] = 14] = "Vsplit";
|
|
24610
|
-
CursorShape[CursorShape["Hsplit"] = 15] = "Hsplit";
|
|
24611
|
-
CursorShape[CursorShape["Help"] = 16] = "Help";
|
|
24612
|
-
})(exports.CursorShape || (exports.CursorShape = {}));
|
|
24613
|
-
|
|
24614
|
-
function _get_prototype_of(o) {
|
|
24615
|
-
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
24616
|
-
return o.__proto__ || Object.getPrototypeOf(o);
|
|
24617
|
-
};
|
|
24618
|
-
return _get_prototype_of(o);
|
|
24619
|
-
}
|
|
24620
|
-
|
|
24621
|
-
function _is_native_function(fn) {
|
|
24622
|
-
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
24623
|
-
}
|
|
24624
|
-
|
|
24625
|
-
function _wrap_native_super(Class) {
|
|
24626
|
-
var _cache = typeof Map === "function" ? new Map() : undefined;
|
|
24627
|
-
_wrap_native_super = function _wrap_native_super(Class) {
|
|
24628
|
-
if (Class === null || !_is_native_function(Class)) return Class;
|
|
24629
|
-
if (typeof Class !== "function") throw new TypeError("Super expression must either be null or a function");
|
|
24630
|
-
if (typeof _cache !== "undefined") {
|
|
24631
|
-
if (_cache.has(Class)) return _cache.get(Class);
|
|
24632
|
-
_cache.set(Class, Wrapper);
|
|
24633
|
-
}
|
|
24634
|
-
function Wrapper() {
|
|
24635
|
-
return _construct(Class, arguments, _get_prototype_of(this).constructor);
|
|
24636
|
-
}
|
|
24637
|
-
Wrapper.prototype = Object.create(Class.prototype, {
|
|
24638
|
-
constructor: {
|
|
24639
|
-
value: Wrapper,
|
|
24640
|
-
enumerable: false,
|
|
24641
|
-
writable: true,
|
|
24642
|
-
configurable: true
|
|
24643
|
-
}
|
|
24644
|
-
});
|
|
24645
|
-
return _set_prototype_of(Wrapper, Class);
|
|
24646
|
-
};
|
|
24647
|
-
return _wrap_native_super(Class);
|
|
24648
|
-
}
|
|
24649
|
-
|
|
24650
|
-
function transformPoint(transform, value) {
|
|
24651
|
-
var elements = transform.elements;
|
|
24652
|
-
return new Vector2(elements[0] * value.x + elements[3] * value.y + elements[6], elements[1] * value.x + elements[4] * value.y + elements[7]);
|
|
24653
|
-
}
|
|
24654
|
-
function transformVector(transform, value) {
|
|
24655
|
-
var elements = transform.elements;
|
|
24656
|
-
return new Vector2(elements[0] * value.x + elements[3] * value.y, elements[1] * value.x + elements[4] * value.y);
|
|
24657
|
-
}
|
|
24658
|
-
var InputEvent = /*#__PURE__*/ function() {
|
|
24659
|
-
function InputEvent() {
|
|
24660
|
-
this.device = 0;
|
|
24661
|
-
this.pressed = false;
|
|
24662
|
-
this.canceled = false;
|
|
24663
|
-
this._accepted = false;
|
|
24664
|
-
}
|
|
24665
|
-
var _proto = InputEvent.prototype;
|
|
24666
|
-
_proto.accept = function accept() {
|
|
24667
|
-
this._accepted = true;
|
|
24668
|
-
};
|
|
24669
|
-
_proto.clearAccepted = function clearAccepted() {
|
|
24670
|
-
this._accepted = false;
|
|
24671
|
-
};
|
|
24672
|
-
_proto.isAccepted = function isAccepted() {
|
|
24673
|
-
return this._accepted;
|
|
24674
|
-
};
|
|
24675
|
-
_proto.isPressed = function isPressed() {
|
|
24676
|
-
return this.pressed && !this.canceled;
|
|
24677
|
-
};
|
|
24678
|
-
_proto.isReleased = function isReleased() {
|
|
24679
|
-
return !this.pressed && !this.canceled;
|
|
24680
|
-
};
|
|
24681
|
-
_proto.isCanceled = function isCanceled() {
|
|
24682
|
-
return this.canceled;
|
|
24683
|
-
};
|
|
24684
|
-
_proto.isEcho = function isEcho() {
|
|
24685
|
-
return false;
|
|
24686
|
-
};
|
|
24687
|
-
_proto.xformedBy = function xformedBy(transform) {
|
|
24688
|
-
return this;
|
|
24689
|
-
};
|
|
24690
|
-
return InputEvent;
|
|
24691
|
-
}();
|
|
24692
|
-
InputEvent.deviceIdEmulation = -1;
|
|
24693
|
-
InputEvent.deviceIdInternal = -2;
|
|
24694
|
-
InputEvent.deviceIdKeyboard = 16;
|
|
24695
|
-
InputEvent.deviceIdMouse = 32;
|
|
24696
|
-
var InputEventWithModifiers = /*#__PURE__*/ function(InputEvent) {
|
|
24697
|
-
_inherits(InputEventWithModifiers, InputEvent);
|
|
24698
|
-
function InputEventWithModifiers() {
|
|
24699
|
-
var _this;
|
|
24700
|
-
_this = InputEvent.apply(this, arguments) || this;
|
|
24701
|
-
_this.commandOrControlAutoremap = false;
|
|
24702
|
-
_this.shiftPressed = false;
|
|
24703
|
-
_this.altPressed = false;
|
|
24704
|
-
_this.metaPressed = false;
|
|
24705
|
-
_this.ctrlPressed = false;
|
|
24706
|
-
return _this;
|
|
24707
|
-
}
|
|
24708
|
-
var _proto = InputEventWithModifiers.prototype;
|
|
24709
|
-
_proto.copyModifiersTo = function copyModifiersTo(event) {
|
|
24710
|
-
event.device = this.device;
|
|
24711
|
-
event.pressed = this.pressed;
|
|
24712
|
-
event.canceled = this.canceled;
|
|
24713
|
-
event.commandOrControlAutoremap = this.commandOrControlAutoremap;
|
|
24714
|
-
event.shiftPressed = this.shiftPressed;
|
|
24715
|
-
event.altPressed = this.altPressed;
|
|
24716
|
-
event.metaPressed = this.metaPressed;
|
|
24717
|
-
event.ctrlPressed = this.ctrlPressed;
|
|
24718
|
-
};
|
|
24719
|
-
return InputEventWithModifiers;
|
|
24720
|
-
}(_wrap_native_super(InputEvent));
|
|
24721
|
-
var InputEventKey = /*#__PURE__*/ function(InputEventWithModifiers) {
|
|
24722
|
-
_inherits(InputEventKey, InputEventWithModifiers);
|
|
24723
|
-
function InputEventKey() {
|
|
24724
|
-
var _this;
|
|
24725
|
-
_this = InputEventWithModifiers.apply(this, arguments) || this;
|
|
24726
|
-
_this.keycode = "";
|
|
24727
|
-
_this.physicalKeycode = "";
|
|
24728
|
-
_this.keyLabel = "";
|
|
24729
|
-
_this.unicode = 0;
|
|
24730
|
-
_this.location = exports.KeyLocation.Unspecified;
|
|
24731
|
-
_this.echo = false;
|
|
24732
|
-
return _this;
|
|
24733
|
-
}
|
|
24734
|
-
var _proto = InputEventKey.prototype;
|
|
24735
|
-
_proto.isEcho = function isEcho() {
|
|
24736
|
-
return this.echo;
|
|
24737
|
-
};
|
|
24738
|
-
return InputEventKey;
|
|
24739
|
-
}(InputEventWithModifiers);
|
|
24740
|
-
var InputEventMouse = /*#__PURE__*/ function(InputEventWithModifiers) {
|
|
24741
|
-
_inherits(InputEventMouse, InputEventWithModifiers);
|
|
24742
|
-
function InputEventMouse() {
|
|
24743
|
-
var _this;
|
|
24744
|
-
_this = InputEventWithModifiers.apply(this, arguments) || this;
|
|
24745
|
-
_this.buttonMask = exports.MouseButtonMask.None;
|
|
24746
|
-
_this.position = new Vector2();
|
|
24747
|
-
_this.globalPosition = new Vector2();
|
|
24748
|
-
return _this;
|
|
24749
|
-
}
|
|
24750
|
-
var _proto = InputEventMouse.prototype;
|
|
24751
|
-
_proto.copyMouseTo = function copyMouseTo(event) {
|
|
24752
|
-
this.copyModifiersTo(event);
|
|
24753
|
-
event.buttonMask = this.buttonMask;
|
|
24754
|
-
event.position.copyFrom(this.position);
|
|
24755
|
-
event.globalPosition.copyFrom(this.globalPosition);
|
|
24756
|
-
};
|
|
24757
|
-
return InputEventMouse;
|
|
24758
|
-
}(InputEventWithModifiers);
|
|
24759
|
-
var InputEventMouseButton = /*#__PURE__*/ function(InputEventMouse) {
|
|
24760
|
-
_inherits(InputEventMouseButton, InputEventMouse);
|
|
24761
|
-
function InputEventMouseButton() {
|
|
24762
|
-
var _this;
|
|
24763
|
-
_this = InputEventMouse.apply(this, arguments) || this;
|
|
24764
|
-
_this.factor = 1;
|
|
24765
|
-
_this.buttonIndex = exports.MouseButton.None;
|
|
24766
|
-
_this.doubleClick = false;
|
|
24767
|
-
return _this;
|
|
24768
|
-
}
|
|
24769
|
-
var _proto = InputEventMouseButton.prototype;
|
|
24770
|
-
_proto.xformedBy = function xformedBy(transform) {
|
|
24771
|
-
var event = new InputEventMouseButton();
|
|
24772
|
-
this.copyMouseTo(event);
|
|
24773
|
-
event.position.copyFrom(transformPoint(transform, this.position));
|
|
24774
|
-
event.factor = this.factor;
|
|
24775
|
-
event.buttonIndex = this.buttonIndex;
|
|
24776
|
-
event.doubleClick = this.doubleClick;
|
|
24777
|
-
return event;
|
|
24778
|
-
};
|
|
24779
|
-
return InputEventMouseButton;
|
|
24780
|
-
}(InputEventMouse);
|
|
24781
|
-
var InputEventMouseMotion = /*#__PURE__*/ function(InputEventMouse) {
|
|
24782
|
-
_inherits(InputEventMouseMotion, InputEventMouse);
|
|
24783
|
-
function InputEventMouseMotion() {
|
|
24784
|
-
var _this;
|
|
24785
|
-
_this = InputEventMouse.apply(this, arguments) || this;
|
|
24786
|
-
_this.tilt = new Vector2();
|
|
24787
|
-
_this.pressure = 0;
|
|
24788
|
-
_this.relative = new Vector2();
|
|
24789
|
-
_this.screenRelative = new Vector2();
|
|
24790
|
-
_this.velocity = new Vector2();
|
|
24791
|
-
_this.screenVelocity = new Vector2();
|
|
24792
|
-
_this.penInverted = false;
|
|
24793
|
-
return _this;
|
|
24794
|
-
}
|
|
24795
|
-
var _proto = InputEventMouseMotion.prototype;
|
|
24796
|
-
_proto.xformedBy = function xformedBy(transform) {
|
|
24797
|
-
var event = new InputEventMouseMotion();
|
|
24798
|
-
this.copyMouseTo(event);
|
|
24799
|
-
event.position.copyFrom(transformPoint(transform, this.position));
|
|
24800
|
-
event.tilt.copyFrom(this.tilt);
|
|
24801
|
-
event.pressure = this.pressure;
|
|
24802
|
-
event.relative.copyFrom(transformVector(transform, this.relative));
|
|
24803
|
-
event.screenRelative.copyFrom(this.screenRelative);
|
|
24804
|
-
event.velocity.copyFrom(transformVector(transform, this.velocity));
|
|
24805
|
-
event.screenVelocity.copyFrom(this.screenVelocity);
|
|
24806
|
-
event.penInverted = this.penInverted;
|
|
24807
|
-
return event;
|
|
24808
|
-
};
|
|
24809
|
-
return InputEventMouseMotion;
|
|
24810
|
-
}(InputEventMouse);
|
|
24811
|
-
var InputEventScreenTouch = /*#__PURE__*/ function(InputEvent) {
|
|
24812
|
-
_inherits(InputEventScreenTouch, InputEvent);
|
|
24813
|
-
function InputEventScreenTouch() {
|
|
24814
|
-
var _this;
|
|
24815
|
-
_this = InputEvent.apply(this, arguments) || this;
|
|
24816
|
-
_this.index = 0;
|
|
24817
|
-
_this.position = new Vector2();
|
|
24818
|
-
_this.doubleTap = false;
|
|
24819
|
-
return _this;
|
|
24820
|
-
}
|
|
24821
|
-
var _proto = InputEventScreenTouch.prototype;
|
|
24822
|
-
_proto.xformedBy = function xformedBy(transform) {
|
|
24823
|
-
var event = new InputEventScreenTouch();
|
|
24824
|
-
event.device = this.device;
|
|
24825
|
-
event.pressed = this.pressed;
|
|
24826
|
-
event.canceled = this.canceled;
|
|
24827
|
-
event.index = this.index;
|
|
24828
|
-
event.position.copyFrom(transformPoint(transform, this.position));
|
|
24829
|
-
event.doubleTap = this.doubleTap;
|
|
24830
|
-
return event;
|
|
24831
|
-
};
|
|
24832
|
-
return InputEventScreenTouch;
|
|
24833
|
-
}(_wrap_native_super(InputEvent));
|
|
24834
|
-
var InputEventScreenDrag = /*#__PURE__*/ function(InputEvent) {
|
|
24835
|
-
_inherits(InputEventScreenDrag, InputEvent);
|
|
24836
|
-
function InputEventScreenDrag() {
|
|
24837
|
-
var _this;
|
|
24838
|
-
_this = InputEvent.apply(this, arguments) || this;
|
|
24839
|
-
_this.index = 0;
|
|
24840
|
-
_this.position = new Vector2();
|
|
24841
|
-
_this.relative = new Vector2();
|
|
24842
|
-
_this.screenRelative = new Vector2();
|
|
24843
|
-
_this.velocity = new Vector2();
|
|
24844
|
-
_this.screenVelocity = new Vector2();
|
|
24845
|
-
_this.pressure = 0;
|
|
24846
|
-
_this.tilt = new Vector2();
|
|
24847
|
-
_this.penInverted = false;
|
|
24848
|
-
return _this;
|
|
24849
|
-
}
|
|
24850
|
-
var _proto = InputEventScreenDrag.prototype;
|
|
24851
|
-
_proto.xformedBy = function xformedBy(transform) {
|
|
24852
|
-
var event = new InputEventScreenDrag();
|
|
24853
|
-
event.device = this.device;
|
|
24854
|
-
event.pressed = this.pressed;
|
|
24855
|
-
event.canceled = this.canceled;
|
|
24856
|
-
event.index = this.index;
|
|
24857
|
-
event.position.copyFrom(transformPoint(transform, this.position));
|
|
24858
|
-
event.relative.copyFrom(transformVector(transform, this.relative));
|
|
24859
|
-
event.screenRelative.copyFrom(this.screenRelative);
|
|
24860
|
-
event.velocity.copyFrom(transformVector(transform, this.velocity));
|
|
24861
|
-
event.screenVelocity.copyFrom(this.screenVelocity);
|
|
24862
|
-
event.pressure = this.pressure;
|
|
24863
|
-
event.tilt.copyFrom(this.tilt);
|
|
24864
|
-
event.penInverted = this.penInverted;
|
|
24865
|
-
return event;
|
|
24866
|
-
};
|
|
24867
|
-
return InputEventScreenDrag;
|
|
24868
|
-
}(_wrap_native_super(InputEvent));
|
|
24869
|
-
|
|
24870
|
-
var ANCHOR_PRESET_TABLE = {
|
|
24871
|
-
topLeft: [
|
|
24872
|
-
0,
|
|
24873
|
-
0,
|
|
24874
|
-
0,
|
|
24875
|
-
0
|
|
24876
|
-
],
|
|
24877
|
-
topRight: [
|
|
24878
|
-
1,
|
|
24879
|
-
0,
|
|
24880
|
-
1,
|
|
24881
|
-
0
|
|
24882
|
-
],
|
|
24883
|
-
bottomLeft: [
|
|
24884
|
-
0,
|
|
24885
|
-
1,
|
|
24886
|
-
0,
|
|
24887
|
-
1
|
|
24888
|
-
],
|
|
24889
|
-
bottomRight: [
|
|
24890
|
-
1,
|
|
24891
|
-
1,
|
|
24892
|
-
1,
|
|
24893
|
-
1
|
|
24894
|
-
],
|
|
24895
|
-
centerLeft: [
|
|
24896
|
-
0,
|
|
24897
|
-
0.5,
|
|
24898
|
-
0,
|
|
24899
|
-
0.5
|
|
24900
|
-
],
|
|
24901
|
-
centerTop: [
|
|
24902
|
-
0.5,
|
|
24903
|
-
0,
|
|
24904
|
-
0.5,
|
|
24905
|
-
0
|
|
24906
|
-
],
|
|
24907
|
-
centerRight: [
|
|
24908
|
-
1,
|
|
24909
|
-
0.5,
|
|
24910
|
-
1,
|
|
24911
|
-
0.5
|
|
24912
|
-
],
|
|
24913
|
-
centerBottom: [
|
|
24914
|
-
0.5,
|
|
24915
|
-
1,
|
|
24916
|
-
0.5,
|
|
24917
|
-
1
|
|
24918
|
-
],
|
|
24919
|
-
center: [
|
|
24920
|
-
0.5,
|
|
24921
|
-
0.5,
|
|
24922
|
-
0.5,
|
|
24923
|
-
0.5
|
|
24924
|
-
],
|
|
24925
|
-
leftWide: [
|
|
24926
|
-
0,
|
|
24927
|
-
0,
|
|
24928
|
-
0,
|
|
24929
|
-
1
|
|
24930
|
-
],
|
|
24931
|
-
topWide: [
|
|
24932
|
-
0,
|
|
24933
|
-
0,
|
|
24934
|
-
1,
|
|
24935
|
-
0
|
|
24936
|
-
],
|
|
24937
|
-
rightWide: [
|
|
24938
|
-
1,
|
|
24939
|
-
0,
|
|
24940
|
-
1,
|
|
24941
|
-
1
|
|
24942
|
-
],
|
|
24943
|
-
bottomWide: [
|
|
24944
|
-
0,
|
|
24945
|
-
1,
|
|
24946
|
-
1,
|
|
24947
|
-
1
|
|
24948
|
-
],
|
|
24949
|
-
vcenterWide: [
|
|
24950
|
-
0.5,
|
|
24951
|
-
0,
|
|
24952
|
-
0.5,
|
|
24953
|
-
1
|
|
24954
|
-
],
|
|
24955
|
-
hcenterWide: [
|
|
24956
|
-
0,
|
|
24957
|
-
0.5,
|
|
24958
|
-
1,
|
|
24959
|
-
0.5
|
|
24960
|
-
],
|
|
24961
|
-
fullRect: [
|
|
24962
|
-
0,
|
|
24963
|
-
0,
|
|
24964
|
-
1,
|
|
24965
|
-
1
|
|
24966
|
-
]
|
|
24967
|
-
};
|
|
24968
|
-
/**
|
|
24969
|
-
* A drawable GUI object. Controls form a tree independent from the VFXItem
|
|
24970
|
-
* scene tree. UIControl is the bridge between both trees.
|
|
24971
|
-
*/ var Control = /*#__PURE__*/ function() {
|
|
24972
|
-
function Control(engine) {
|
|
24973
|
-
this.engine = engine;
|
|
24974
|
-
this._parent = null;
|
|
24975
|
-
this._visible = true;
|
|
24976
|
-
this._enabled = true;
|
|
24977
|
-
this._mouseFilter = exports.MouseFilter.Stop;
|
|
24978
|
-
this._mouseBehaviorRecursive = exports.MouseBehaviorRecursive.Inherited;
|
|
24979
|
-
this._focusMode = exports.FocusMode.None;
|
|
24980
|
-
this._focusBehaviorRecursive = exports.FocusBehaviorRecursive.Inherited;
|
|
24981
|
-
this._defaultCursorShape = exports.CursorShape.Arrow;
|
|
24982
|
-
this._rotation = 0;
|
|
24983
|
-
this.transformDirty = true;
|
|
24984
|
-
this.cachedTransform = new Matrix3();
|
|
24985
|
-
this.eventEmitter = new EventEmitter();
|
|
24986
|
-
this.disposed = false;
|
|
24987
|
-
this./** Scene-tree bridge that owns this GUI object, if any. */ owner = null;
|
|
24988
|
-
this.position = new Vector2();
|
|
24989
|
-
this.size = new Vector2(1, 1);
|
|
24990
|
-
this.anchorMin = new Vector2();
|
|
24991
|
-
this.anchorMax = new Vector2();
|
|
24992
|
-
this.offsetMin = new Vector2();
|
|
24993
|
-
this.offsetMax = new Vector2(1, 1);
|
|
24994
|
-
this.pivot = new Vector2(0.5, 0.5);
|
|
24995
|
-
this.scale = new Vector2(1, 1);
|
|
24996
|
-
this.shear = new Vector2();
|
|
24997
|
-
this.mouseForcePassScrollEvents = true;
|
|
24998
|
-
this.clipContents = false;
|
|
24999
|
-
}
|
|
25000
|
-
var _proto = Control.prototype;
|
|
25001
|
-
_proto.on = function on(eventName, listener, options) {
|
|
25002
|
-
this.eventEmitter.on(eventName, listener, options);
|
|
25003
|
-
};
|
|
25004
|
-
_proto.off = function off(eventName, listener) {
|
|
25005
|
-
this.eventEmitter.off(eventName, listener);
|
|
25006
|
-
};
|
|
25007
|
-
_proto.setPosition = function setPosition(x, y, keepOffsets) {
|
|
25008
|
-
if (keepOffsets === void 0) keepOffsets = false;
|
|
25009
|
-
if (this.position.x === x && this.position.y === y) {
|
|
25010
|
-
return;
|
|
25011
|
-
}
|
|
25012
|
-
var rect = {
|
|
25013
|
-
position: new Vector2(x, y),
|
|
25014
|
-
size: this.size.clone()
|
|
25015
|
-
};
|
|
25016
|
-
if (keepOffsets && this.parent) {
|
|
25017
|
-
this.computeAnchors(rect, this.getParentRect());
|
|
25018
|
-
} else {
|
|
25019
|
-
this.computeOffsets(rect, this.getParentRect());
|
|
25020
|
-
}
|
|
25021
|
-
this.updateLayout();
|
|
25022
|
-
};
|
|
25023
|
-
_proto.setSize = function setSize(width, height) {
|
|
25024
|
-
if (this.size.x === width && this.size.y === height) {
|
|
25025
|
-
return;
|
|
25026
|
-
}
|
|
25027
|
-
var rect = {
|
|
25028
|
-
position: this.position.clone(),
|
|
25029
|
-
size: new Vector2(width, height)
|
|
25030
|
-
};
|
|
25031
|
-
this.computeOffsets(rect, this.getParentRect());
|
|
25032
|
-
this.updateLayout();
|
|
25033
|
-
};
|
|
25034
|
-
_proto.setScale = function setScale(x, y) {
|
|
25035
|
-
if (this.scale.x !== x || this.scale.y !== y) {
|
|
25036
|
-
this.scale.set(x, y);
|
|
25037
|
-
this.markTransformDirty();
|
|
25038
|
-
}
|
|
25039
|
-
};
|
|
25040
|
-
_proto.setRotation = function setRotation(degrees) {
|
|
25041
|
-
if (this._rotation !== degrees) {
|
|
25042
|
-
this._rotation = degrees;
|
|
25043
|
-
this.markTransformDirty();
|
|
25044
|
-
}
|
|
25045
|
-
};
|
|
25046
|
-
_proto.setShear = function setShear(x, y) {
|
|
25047
|
-
if (this.shear.x !== x || this.shear.y !== y) {
|
|
25048
|
-
this.shear.set(x, y);
|
|
25049
|
-
this.markTransformDirty();
|
|
25050
|
-
}
|
|
25051
|
-
};
|
|
25052
|
-
_proto.setPivot = function setPivot(x, y) {
|
|
25053
|
-
if (this.pivot.x !== x || this.pivot.y !== y) {
|
|
25054
|
-
this.pivot.set(x, y);
|
|
25055
|
-
this.markTransformDirty();
|
|
25056
|
-
}
|
|
25057
|
-
};
|
|
25058
|
-
_proto.setAnchorMin = function setAnchorMin(x, y) {
|
|
25059
|
-
if (this.anchorMin.x !== x || this.anchorMin.y !== y) {
|
|
25060
|
-
this.anchorMin.set(x, y);
|
|
25061
|
-
this.updateLayout();
|
|
25062
|
-
}
|
|
25063
|
-
};
|
|
25064
|
-
_proto.setAnchorMax = function setAnchorMax(x, y) {
|
|
25065
|
-
if (this.anchorMax.x !== x || this.anchorMax.y !== y) {
|
|
25066
|
-
this.anchorMax.set(x, y);
|
|
25067
|
-
this.updateLayout();
|
|
25068
|
-
}
|
|
25069
|
-
};
|
|
25070
|
-
_proto.setOffsetMin = function setOffsetMin(x, y) {
|
|
25071
|
-
if (this.offsetMin.x !== x || this.offsetMin.y !== y) {
|
|
25072
|
-
this.offsetMin.set(x, y);
|
|
25073
|
-
this.updateLayout();
|
|
25074
|
-
}
|
|
25075
|
-
};
|
|
25076
|
-
_proto.setOffsetMax = function setOffsetMax(x, y) {
|
|
25077
|
-
if (this.offsetMax.x !== x || this.offsetMax.y !== y) {
|
|
25078
|
-
this.offsetMax.set(x, y);
|
|
25079
|
-
this.updateLayout();
|
|
25080
|
-
}
|
|
25081
|
-
};
|
|
25082
|
-
_proto.getRect = function getRect() {
|
|
25083
|
-
return {
|
|
25084
|
-
position: this.position.clone(),
|
|
25085
|
-
size: this.size.clone()
|
|
25086
|
-
};
|
|
25087
|
-
};
|
|
25088
|
-
_proto.getTransform2D = function getTransform2D() {
|
|
25089
|
-
if (this.transformDirty) {
|
|
25090
|
-
var radians = this._rotation * Math.PI / 180;
|
|
25091
|
-
var sin = Math.sin(radians);
|
|
25092
|
-
var cos = Math.cos(radians);
|
|
25093
|
-
var shearX = Math.tan(Math.max(-89, Math.min(89, this.shear.x)) * Math.PI / 180);
|
|
25094
|
-
var shearY = Math.tan(Math.max(-89, Math.min(89, this.shear.y)) * Math.PI / 180);
|
|
25095
|
-
var a = this.scale.x * (cos - sin * shearY);
|
|
25096
|
-
var b = this.scale.x * (sin + cos * shearY);
|
|
25097
|
-
var c = this.scale.y * (cos * shearX - sin);
|
|
25098
|
-
var d = this.scale.y * (sin * shearX + cos);
|
|
25099
|
-
var pivotX = this.pivot.x * this.size.x;
|
|
25100
|
-
var pivotY = this.pivot.y * this.size.y;
|
|
25101
|
-
var tx = this.position.x + pivotX - a * pivotX - c * pivotY;
|
|
25102
|
-
var ty = this.position.y + pivotY - b * pivotX - d * pivotY;
|
|
25103
|
-
this.cachedTransform.set(a, b, 0, c, d, 0, tx, ty, 1);
|
|
25104
|
-
this.transformDirty = false;
|
|
25105
|
-
}
|
|
25106
|
-
return this.cachedTransform;
|
|
25107
|
-
};
|
|
25108
|
-
_proto.setAnchorsPreset = function setAnchorsPreset(preset, keepOffsets) {
|
|
25109
|
-
if (keepOffsets === void 0) keepOffsets = true;
|
|
25110
|
-
var _ANCHOR_PRESET_TABLE_preset = ANCHOR_PRESET_TABLE[preset], minX = _ANCHOR_PRESET_TABLE_preset[0], minY = _ANCHOR_PRESET_TABLE_preset[1], maxX = _ANCHOR_PRESET_TABLE_preset[2], maxY = _ANCHOR_PRESET_TABLE_preset[3];
|
|
25111
|
-
if (keepOffsets) {
|
|
25112
|
-
this.anchorMin.set(minX, minY);
|
|
25113
|
-
this.anchorMax.set(maxX, maxY);
|
|
25114
|
-
} else {
|
|
25115
|
-
var rect = this.getRect();
|
|
25116
|
-
this.anchorMin.set(minX, minY);
|
|
25117
|
-
this.anchorMax.set(maxX, maxY);
|
|
25118
|
-
this.computeOffsets(rect, this.getParentRect());
|
|
25119
|
-
}
|
|
25120
|
-
this.updateLayout();
|
|
25121
|
-
};
|
|
25122
|
-
_proto.setOffsetsPreset = function setOffsetsPreset(preset, margin) {
|
|
25123
|
-
if (margin === void 0) margin = 0;
|
|
25124
|
-
if (!this.parent) {
|
|
25125
|
-
return;
|
|
25126
|
-
}
|
|
25127
|
-
var parentSize = this.parent.size;
|
|
25128
|
-
var width = this.size.x;
|
|
25129
|
-
var height = this.size.y;
|
|
25130
|
-
var a = this.anchorMin;
|
|
25131
|
-
var b = this.anchorMax;
|
|
25132
|
-
var minX = 0, maxX = 0, minY = 0, maxY = 0;
|
|
25133
|
-
// Left edge.
|
|
25134
|
-
switch(preset){
|
|
25135
|
-
case "topLeft":
|
|
25136
|
-
case "bottomLeft":
|
|
25137
|
-
case "centerLeft":
|
|
25138
|
-
case "topWide":
|
|
25139
|
-
case "bottomWide":
|
|
25140
|
-
case "leftWide":
|
|
25141
|
-
case "hcenterWide":
|
|
25142
|
-
case "fullRect":
|
|
25143
|
-
minX = margin - a.x * parentSize.x;
|
|
25144
|
-
break;
|
|
25145
|
-
case "centerTop":
|
|
25146
|
-
case "centerBottom":
|
|
25147
|
-
case "center":
|
|
25148
|
-
case "vcenterWide":
|
|
25149
|
-
minX = 0.5 * parentSize.x - width / 2 - a.x * parentSize.x;
|
|
25150
|
-
break;
|
|
25151
|
-
default:
|
|
25152
|
-
minX = parentSize.x - margin - width - a.x * parentSize.x;
|
|
25153
|
-
break;
|
|
25154
|
-
}
|
|
25155
|
-
switch(preset){
|
|
25156
|
-
case "topLeft":
|
|
25157
|
-
case "bottomLeft":
|
|
25158
|
-
case "centerLeft":
|
|
25159
|
-
case "leftWide":
|
|
25160
|
-
maxX = margin + width - b.x * parentSize.x;
|
|
25161
|
-
break;
|
|
25162
|
-
case "centerTop":
|
|
25163
|
-
case "centerBottom":
|
|
25164
|
-
case "center":
|
|
25165
|
-
case "vcenterWide":
|
|
25166
|
-
maxX = 0.5 * parentSize.x + width / 2 - b.x * parentSize.x;
|
|
25167
|
-
break;
|
|
25168
|
-
default:
|
|
25169
|
-
maxX = parentSize.x - margin - b.x * parentSize.x;
|
|
25170
|
-
break;
|
|
25171
|
-
}
|
|
25172
|
-
// Top edge.
|
|
25173
|
-
switch(preset){
|
|
25174
|
-
case "topLeft":
|
|
25175
|
-
case "topRight":
|
|
25176
|
-
case "centerTop":
|
|
25177
|
-
case "leftWide":
|
|
25178
|
-
case "rightWide":
|
|
25179
|
-
case "topWide":
|
|
25180
|
-
case "vcenterWide":
|
|
25181
|
-
case "fullRect":
|
|
25182
|
-
minY = margin - a.y * parentSize.y;
|
|
25183
|
-
break;
|
|
25184
|
-
case "centerLeft":
|
|
25185
|
-
case "centerRight":
|
|
25186
|
-
case "center":
|
|
25187
|
-
case "hcenterWide":
|
|
25188
|
-
minY = 0.5 * parentSize.y - height / 2 - a.y * parentSize.y;
|
|
25189
|
-
break;
|
|
25190
|
-
default:
|
|
25191
|
-
minY = parentSize.y - margin - height - a.y * parentSize.y;
|
|
25192
|
-
break;
|
|
25193
|
-
}
|
|
25194
|
-
// Bottom edge.
|
|
25195
|
-
switch(preset){
|
|
25196
|
-
case "topLeft":
|
|
25197
|
-
case "topRight":
|
|
25198
|
-
case "centerTop":
|
|
25199
|
-
case "topWide":
|
|
25200
|
-
maxY = margin + height - b.y * parentSize.y;
|
|
25201
|
-
break;
|
|
25202
|
-
case "centerLeft":
|
|
25203
|
-
case "centerRight":
|
|
25204
|
-
case "center":
|
|
25205
|
-
case "hcenterWide":
|
|
25206
|
-
maxY = 0.5 * parentSize.y + height / 2 - b.y * parentSize.y;
|
|
25207
|
-
break;
|
|
25208
|
-
default:
|
|
25209
|
-
maxY = parentSize.y - margin - b.y * parentSize.y;
|
|
25210
|
-
break;
|
|
25211
|
-
}
|
|
25212
|
-
this.offsetMin.set(minX, minY);
|
|
25213
|
-
this.offsetMax.set(maxX, maxY);
|
|
25214
|
-
this.updateLayout();
|
|
25215
|
-
};
|
|
25216
|
-
_proto.setAnchorsAndOffsetsPreset = function setAnchorsAndOffsetsPreset(preset, margin) {
|
|
25217
|
-
if (margin === void 0) margin = 0;
|
|
25218
|
-
this.setAnchorsPreset(preset, false);
|
|
25219
|
-
this.setOffsetsPreset(preset, margin);
|
|
25220
|
-
};
|
|
25221
|
-
_proto.getGlobalTransform2D = function getGlobalTransform2D() {
|
|
25222
|
-
var local = this.getTransform2D();
|
|
25223
|
-
return this.parent ? new Matrix3().multiplyMatrices(this.parent.getGlobalTransform2D(), local) : local.clone();
|
|
25224
|
-
};
|
|
25225
|
-
_proto.hasPoint = function hasPoint(point) {
|
|
25226
|
-
return point.x >= 0 && point.y >= 0 && point.x <= this.size.x && point.y <= this.size.y;
|
|
25227
|
-
};
|
|
25228
|
-
_proto.getEffectiveMouseFilter = function getEffectiveMouseFilter() {
|
|
25229
|
-
return this.enabledInHierarchy && this.isMouseRecursiveEnabled() ? this.mouseFilter : exports.MouseFilter.Ignore;
|
|
25230
|
-
};
|
|
25231
|
-
_proto.getFocusModeWithOverride = function getFocusModeWithOverride() {
|
|
25232
|
-
return this.enabledInHierarchy && this.isFocusRecursiveEnabled() ? this.focusMode : exports.FocusMode.None;
|
|
25233
|
-
};
|
|
25234
|
-
_proto.getCursorShape = function getCursorShape(position) {
|
|
25235
|
-
return this.defaultCursorShape;
|
|
25236
|
-
};
|
|
25237
|
-
_proto.focus = function focus() {
|
|
25238
|
-
var _this_root;
|
|
25239
|
-
(_this_root = this.root) == null ? void 0 : _this_root.grabControlFocus(this);
|
|
25240
|
-
};
|
|
25241
|
-
_proto.grabFocus = function grabFocus() {
|
|
25242
|
-
this.focus();
|
|
25243
|
-
};
|
|
25244
|
-
_proto.grabClickFocus = function grabClickFocus() {
|
|
25245
|
-
var _this_root;
|
|
25246
|
-
(_this_root = this.root) == null ? void 0 : _this_root.grabControlClickFocus(this);
|
|
25247
|
-
};
|
|
25248
|
-
_proto.releaseFocus = function releaseFocus() {
|
|
25249
|
-
var _this_root;
|
|
25250
|
-
(_this_root = this.root) == null ? void 0 : _this_root.releaseControlFocus(this);
|
|
25251
|
-
};
|
|
25252
|
-
_proto.warpMouse = function warpMouse(position) {
|
|
25253
|
-
var _this_root;
|
|
25254
|
-
var matrix = this.getGlobalTransform2D().elements;
|
|
25255
|
-
(_this_root = this.root) == null ? void 0 : _this_root.warpControlMouse(new Vector2(matrix[0] * position.x + matrix[3] * position.y + matrix[6], matrix[1] * position.x + matrix[4] * position.y + matrix[7]));
|
|
25256
|
-
};
|
|
25257
|
-
/** Converts a window-space position into this control's local coordinates. */ _proto.makePositionLocal = function makePositionLocal(position) {
|
|
25258
|
-
var transform = this.getGlobalTransform2D().clone();
|
|
25259
|
-
if (Math.abs(transform.determinant()) < 1e-12) {
|
|
25260
|
-
return new Vector2();
|
|
25261
|
-
}
|
|
25262
|
-
var elements = transform.invert().elements;
|
|
25263
|
-
return new Vector2(elements[0] * position.x + elements[3] * position.y + elements[6], elements[1] * position.x + elements[4] * position.y + elements[7]);
|
|
25264
|
-
};
|
|
25265
|
-
/** Gets the current mouse position transformed into this control's coordinates. */ _proto.getLocalMousePosition = function getLocalMousePosition() {
|
|
25266
|
-
var root = this.root;
|
|
25267
|
-
return root ? this.makePositionLocal(root.getMousePosition()) : new Vector2();
|
|
25268
|
-
};
|
|
25269
|
-
_proto.update = function update(deltaTime) {};
|
|
25270
|
-
_proto.draw = function draw() {
|
|
25271
|
-
// OVERRIDE
|
|
25272
|
-
};
|
|
25273
|
-
_proto.onDestroy = function onDestroy() {};
|
|
25274
|
-
/** @internal */ _proto.drawInternal = function drawInternal() {
|
|
25275
|
-
if (!this.visibleInHierarchy || this.disposed) {
|
|
25276
|
-
return;
|
|
25277
|
-
}
|
|
25278
|
-
var graphics = this.engine.graphics;
|
|
25279
|
-
graphics.pushTransform(this.getTransform2D());
|
|
25280
|
-
this.draw();
|
|
25281
|
-
graphics.popTransform();
|
|
25282
|
-
};
|
|
25283
|
-
_proto.drawLine = function drawLine(x1, y1, x2, y2, color, thickness) {
|
|
25284
|
-
this.engine.graphics.drawLine(x1, y1, x2, y2, color, thickness);
|
|
25285
|
-
};
|
|
25286
|
-
_proto.drawPolyline = function drawPolyline(points, color, thickness) {
|
|
25287
|
-
this.engine.graphics.drawLines(points, color, thickness);
|
|
25288
|
-
};
|
|
25289
|
-
_proto.drawBezier = function drawBezier(x1, y1, x2, y2, x3, y3, x4, y4, color, thickness) {
|
|
25290
|
-
this.engine.graphics.drawBezier(x1, y1, x2, y2, x3, y3, x4, y4, color, thickness);
|
|
25291
|
-
};
|
|
25292
|
-
_proto.drawTriangle = function drawTriangle(x1, y1, x2, y2, x3, y3, color, thickness) {
|
|
25293
|
-
this.engine.graphics.drawTriangle(x1, y1, x2, y2, x3, y3, color, thickness);
|
|
25294
|
-
};
|
|
25295
|
-
_proto.drawRect = function drawRect(x, y, width, height, color, thickness) {
|
|
25296
|
-
this.engine.graphics.drawRectangle(x, y, width, height, color, thickness);
|
|
25297
|
-
};
|
|
25298
|
-
_proto.drawCircle = function drawCircle(cx, cy, radius, color, thickness) {
|
|
25299
|
-
this.engine.graphics.drawCircle(cx, cy, radius, color, thickness);
|
|
25300
|
-
};
|
|
25301
|
-
_proto.fillTriangle = function fillTriangle(x1, y1, x2, y2, x3, y3, color) {
|
|
25302
|
-
this.engine.graphics.fillTriangle(x1, y1, x2, y2, x3, y3, color);
|
|
25303
|
-
};
|
|
25304
|
-
_proto.fillRect = function fillRect(x, y, width, height, color) {
|
|
25305
|
-
this.engine.graphics.fillRectangle(x, y, width, height, color);
|
|
25306
|
-
};
|
|
25307
|
-
_proto.fillCircle = function fillCircle(cx, cy, radius, color) {
|
|
25308
|
-
this.engine.graphics.fillCircle(cx, cy, radius, color);
|
|
25309
|
-
};
|
|
25310
|
-
_proto.drawTexture = function drawTexture(x, y, width, height, texture, region, color) {
|
|
25311
|
-
this.engine.graphics.drawTexture(x, y, width, height, texture, region, color);
|
|
25312
|
-
};
|
|
25313
|
-
_proto.drawText = function drawText(x, y, text, fontSize, color, fontFamily, fontWeight, fontStyle) {
|
|
25314
|
-
this.engine.graphics.drawText(x, y, text, fontSize, color, fontFamily, fontWeight, fontStyle);
|
|
25315
|
-
};
|
|
25316
|
-
_proto.onMouseEnter = function onMouseEnter(location) {};
|
|
25317
|
-
_proto.onMouseMove = function onMouseMove(event) {};
|
|
25318
|
-
_proto.onMouseLeave = function onMouseLeave() {};
|
|
25319
|
-
_proto.onMouseWheel = function onMouseWheel(event) {};
|
|
25320
|
-
_proto.onMouseDown = function onMouseDown(event) {};
|
|
25321
|
-
_proto.onMouseUp = function onMouseUp(event) {};
|
|
25322
|
-
_proto.onTouchDown = function onTouchDown(event) {};
|
|
25323
|
-
_proto.onTouchMove = function onTouchMove(event) {};
|
|
25324
|
-
_proto.onTouchUp = function onTouchUp(event) {};
|
|
25325
|
-
_proto.onKeyDown = function onKeyDown(event) {};
|
|
25326
|
-
_proto.onKeyUp = function onKeyUp(event) {};
|
|
25327
|
-
_proto.onGotFocus = function onGotFocus() {};
|
|
25328
|
-
_proto.onLostFocus = function onLostFocus() {};
|
|
25329
|
-
/** @internal */ _proto.invokeGetDragData = function invokeGetDragData(position) {
|
|
25330
|
-
return this.getDragData(position);
|
|
25331
|
-
};
|
|
25332
|
-
/** @internal */ _proto.invokeCanDropData = function invokeCanDropData(position, data) {
|
|
25333
|
-
return this.canDropData(position, data);
|
|
25334
|
-
};
|
|
25335
|
-
/** @internal */ _proto.invokeDropData = function invokeDropData(position, data) {
|
|
25336
|
-
this.dropData(position, data);
|
|
25337
|
-
};
|
|
25338
|
-
_proto.getDragData = function getDragData(position) {
|
|
25339
|
-
return null;
|
|
25340
|
-
};
|
|
25341
|
-
_proto.canDropData = function canDropData(position, data) {
|
|
25342
|
-
return false;
|
|
25343
|
-
};
|
|
25344
|
-
_proto.dropData = function dropData(position, data) {};
|
|
25345
|
-
_proto.dispose = function dispose() {
|
|
25346
|
-
if (this.disposed) {
|
|
25347
|
-
return;
|
|
25348
|
-
}
|
|
25349
|
-
this.disposed = true;
|
|
25350
|
-
this.onDestroy();
|
|
25351
|
-
this.parent = null;
|
|
25352
|
-
this.owner = null;
|
|
25353
|
-
};
|
|
25354
|
-
/** @internal */ _proto.updateLayout = function updateLayout() {
|
|
25355
|
-
var _this_parent;
|
|
25356
|
-
var _this_parent_size;
|
|
25357
|
-
var parentSize = (_this_parent_size = (_this_parent = this.parent) == null ? void 0 : _this_parent.size) != null ? _this_parent_size : new Vector2();
|
|
25358
|
-
var left = this.offsetMin.x + this.anchorMin.x * parentSize.x;
|
|
25359
|
-
var top = this.offsetMin.y + this.anchorMin.y * parentSize.y;
|
|
25360
|
-
var right = this.offsetMax.x + this.anchorMax.x * parentSize.x;
|
|
25361
|
-
var bottom = this.offsetMax.y + this.anchorMax.y * parentSize.y;
|
|
25362
|
-
this.applyBounds(left, top, right - left, bottom - top);
|
|
25363
|
-
};
|
|
25364
|
-
_proto.applyBounds = function applyBounds(x, y, width, height) {
|
|
25365
|
-
var locationChanged = this.position.x !== x || this.position.y !== y;
|
|
25366
|
-
var sizeChanged = this.size.x !== width || this.size.y !== height;
|
|
25367
|
-
if (!locationChanged && !sizeChanged) {
|
|
25368
|
-
return;
|
|
25369
|
-
}
|
|
25370
|
-
this.position.set(x, y);
|
|
25371
|
-
this.size.set(width, height);
|
|
25372
|
-
this.markTransformDirty();
|
|
25373
|
-
if (locationChanged) {
|
|
25374
|
-
this.eventEmitter.emit("locationChanged", this);
|
|
25375
|
-
}
|
|
25376
|
-
if (sizeChanged) {
|
|
25377
|
-
this.eventEmitter.emit("sizeChanged", this);
|
|
25378
|
-
if (_instanceof1(this, ContainerControl)) {
|
|
25379
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(this.children.slice()), _step; !(_step = _iterator()).done;){
|
|
25380
|
-
var child = _step.value;
|
|
25381
|
-
child.updateLayout();
|
|
25382
|
-
}
|
|
25383
|
-
}
|
|
25384
|
-
}
|
|
25385
|
-
};
|
|
25386
|
-
_proto.markTransformDirty = function markTransformDirty() {
|
|
25387
|
-
var _this_root;
|
|
25388
|
-
this.transformDirty = true;
|
|
25389
|
-
(_this_root = this.root) == null ? void 0 : _this_root.controlTreeChanged();
|
|
25390
|
-
};
|
|
25391
|
-
_proto.getParentRect = function getParentRect() {
|
|
25392
|
-
var _this_parent;
|
|
25393
|
-
var _this_parent_size_clone;
|
|
25394
|
-
return {
|
|
25395
|
-
position: new Vector2(),
|
|
25396
|
-
size: (_this_parent_size_clone = (_this_parent = this.parent) == null ? void 0 : _this_parent.size.clone()) != null ? _this_parent_size_clone : new Vector2()
|
|
25397
|
-
};
|
|
25398
|
-
};
|
|
25399
|
-
_proto.computeOffsets = function computeOffsets(rect, parentRect) {
|
|
25400
|
-
this.offsetMin.set(rect.position.x - parentRect.position.x - this.anchorMin.x * parentRect.size.x, rect.position.y - parentRect.position.y - this.anchorMin.y * parentRect.size.y);
|
|
25401
|
-
this.offsetMax.set(rect.position.x + rect.size.x - parentRect.position.x - this.anchorMax.x * parentRect.size.x, rect.position.y + rect.size.y - parentRect.position.y - this.anchorMax.y * parentRect.size.y);
|
|
25402
|
-
};
|
|
25403
|
-
_proto.computeAnchors = function computeAnchors(rect, parentRect) {
|
|
25404
|
-
if (parentRect.size.x !== 0) {
|
|
25405
|
-
this.anchorMin.x = (rect.position.x - parentRect.position.x - this.offsetMin.x) / parentRect.size.x;
|
|
25406
|
-
this.anchorMax.x = (rect.position.x + rect.size.x - parentRect.position.x - this.offsetMax.x) / parentRect.size.x;
|
|
25407
|
-
}
|
|
25408
|
-
if (parentRect.size.y !== 0) {
|
|
25409
|
-
this.anchorMin.y = (rect.position.y - parentRect.position.y - this.offsetMin.y) / parentRect.size.y;
|
|
25410
|
-
this.anchorMax.y = (rect.position.y + rect.size.y - parentRect.position.y - this.offsetMax.y) / parentRect.size.y;
|
|
25411
|
-
}
|
|
25412
|
-
};
|
|
25413
|
-
_proto.isMouseRecursiveEnabled = function isMouseRecursiveEnabled() {
|
|
25414
|
-
if (this.mouseBehaviorRecursive === exports.MouseBehaviorRecursive.Inherited) {
|
|
25415
|
-
var _this_parent;
|
|
25416
|
-
var _this_parent_isMouseRecursiveEnabled;
|
|
25417
|
-
return (_this_parent_isMouseRecursiveEnabled = (_this_parent = this.parent) == null ? void 0 : _this_parent.isMouseRecursiveEnabled()) != null ? _this_parent_isMouseRecursiveEnabled : true;
|
|
25418
|
-
}
|
|
25419
|
-
return this.mouseBehaviorRecursive === exports.MouseBehaviorRecursive.Enabled;
|
|
25420
|
-
};
|
|
25421
|
-
_proto.isFocusRecursiveEnabled = function isFocusRecursiveEnabled() {
|
|
25422
|
-
if (this.focusBehaviorRecursive === exports.FocusBehaviorRecursive.Inherited) {
|
|
25423
|
-
var _this_parent;
|
|
25424
|
-
var _this_parent_isFocusRecursiveEnabled;
|
|
25425
|
-
return (_this_parent_isFocusRecursiveEnabled = (_this_parent = this.parent) == null ? void 0 : _this_parent.isFocusRecursiveEnabled()) != null ? _this_parent_isFocusRecursiveEnabled : true;
|
|
25426
|
-
}
|
|
25427
|
-
return this.focusBehaviorRecursive === exports.FocusBehaviorRecursive.Enabled;
|
|
25428
|
-
};
|
|
25429
|
-
_create_class(Control, [
|
|
25430
|
-
{
|
|
25431
|
-
key: "parent",
|
|
25432
|
-
get: function get() {
|
|
25433
|
-
return this._parent;
|
|
25434
|
-
},
|
|
25435
|
-
set: function set(value) {
|
|
25436
|
-
var _this__parent;
|
|
25437
|
-
if (value === this._parent) {
|
|
25438
|
-
return;
|
|
25439
|
-
}
|
|
25440
|
-
var previousRoot = this.root;
|
|
25441
|
-
(_this__parent = this._parent) == null ? void 0 : _this__parent.removeChildInternal(this);
|
|
25442
|
-
this._parent = value;
|
|
25443
|
-
value == null ? void 0 : value.addChildInternal(this);
|
|
25444
|
-
this.updateLayout();
|
|
25445
|
-
var nextRoot = this.root;
|
|
25446
|
-
if (previousRoot && previousRoot !== nextRoot) {
|
|
25447
|
-
previousRoot.controlRemoved(this);
|
|
25448
|
-
}
|
|
25449
|
-
nextRoot == null ? void 0 : nextRoot.controlTreeChanged();
|
|
25450
|
-
this.eventEmitter.emit("parentChanged", this);
|
|
25451
|
-
}
|
|
25452
|
-
},
|
|
25453
|
-
{
|
|
25454
|
-
key: "item",
|
|
25455
|
-
get: /** Scene item exposed through the optional UIControl bridge. */ function get() {
|
|
25456
|
-
var _this_owner;
|
|
25457
|
-
var _this_owner_item;
|
|
25458
|
-
return (_this_owner_item = (_this_owner = this.owner) == null ? void 0 : _this_owner.item) != null ? _this_owner_item : null;
|
|
25459
|
-
}
|
|
25460
|
-
},
|
|
25461
|
-
{
|
|
25462
|
-
key: "indexInParent",
|
|
25463
|
-
get: function get() {
|
|
25464
|
-
var _this_parent;
|
|
25465
|
-
var _this_parent_getChildIndex;
|
|
25466
|
-
return (_this_parent_getChildIndex = (_this_parent = this.parent) == null ? void 0 : _this_parent.getChildIndex(this)) != null ? _this_parent_getChildIndex : -1;
|
|
25467
|
-
},
|
|
25468
|
-
set: function set(value) {
|
|
25469
|
-
var _this_parent;
|
|
25470
|
-
(_this_parent = this.parent) == null ? void 0 : _this_parent.changeChildIndex(this, value);
|
|
25471
|
-
}
|
|
25472
|
-
},
|
|
25473
|
-
{
|
|
25474
|
-
key: "visible",
|
|
25475
|
-
get: function get() {
|
|
25476
|
-
return this._visible;
|
|
25477
|
-
},
|
|
25478
|
-
set: function set(value) {
|
|
25479
|
-
if (this._visible !== value) {
|
|
25480
|
-
var _this_root;
|
|
25481
|
-
this._visible = value;
|
|
25482
|
-
(_this_root = this.root) == null ? void 0 : _this_root.controlStateChanged(this);
|
|
25483
|
-
}
|
|
25484
|
-
}
|
|
25485
|
-
},
|
|
25486
|
-
{
|
|
25487
|
-
key: "visibleInHierarchy",
|
|
25488
|
-
get: function get() {
|
|
25489
|
-
var _this_parent;
|
|
25490
|
-
var _this_parent_visibleInHierarchy;
|
|
25491
|
-
return this.visible && ((_this_parent_visibleInHierarchy = (_this_parent = this.parent) == null ? void 0 : _this_parent.visibleInHierarchy) != null ? _this_parent_visibleInHierarchy : true);
|
|
25492
|
-
}
|
|
25493
|
-
},
|
|
25494
|
-
{
|
|
25495
|
-
key: "enabled",
|
|
25496
|
-
get: function get() {
|
|
25497
|
-
return this._enabled;
|
|
25498
|
-
},
|
|
25499
|
-
set: function set(value) {
|
|
25500
|
-
if (this._enabled !== value) {
|
|
25501
|
-
var _this_root;
|
|
25502
|
-
this._enabled = value;
|
|
25503
|
-
(_this_root = this.root) == null ? void 0 : _this_root.controlStateChanged(this);
|
|
25504
|
-
}
|
|
25505
|
-
}
|
|
25506
|
-
},
|
|
25507
|
-
{
|
|
25508
|
-
key: "enabledInHierarchy",
|
|
25509
|
-
get: function get() {
|
|
25510
|
-
var _this_parent;
|
|
25511
|
-
var _this_parent_enabledInHierarchy;
|
|
25512
|
-
return this.enabled && ((_this_parent_enabledInHierarchy = (_this_parent = this.parent) == null ? void 0 : _this_parent.enabledInHierarchy) != null ? _this_parent_enabledInHierarchy : true);
|
|
25513
|
-
}
|
|
25514
|
-
},
|
|
25515
|
-
{
|
|
25516
|
-
key: "mouseFilter",
|
|
25517
|
-
get: function get() {
|
|
25518
|
-
return this._mouseFilter;
|
|
25519
|
-
},
|
|
25520
|
-
set: function set(value) {
|
|
25521
|
-
if (this._mouseFilter !== value) {
|
|
25522
|
-
var _this_root;
|
|
25523
|
-
this._mouseFilter = value;
|
|
25524
|
-
(_this_root = this.root) == null ? void 0 : _this_root.controlStateChanged(this);
|
|
25525
|
-
}
|
|
25526
|
-
}
|
|
25527
|
-
},
|
|
25528
|
-
{
|
|
25529
|
-
key: "mouseBehaviorRecursive",
|
|
25530
|
-
get: function get() {
|
|
25531
|
-
return this._mouseBehaviorRecursive;
|
|
25532
|
-
},
|
|
25533
|
-
set: function set(value) {
|
|
25534
|
-
if (this._mouseBehaviorRecursive !== value) {
|
|
25535
|
-
var _this_root;
|
|
25536
|
-
this._mouseBehaviorRecursive = value;
|
|
25537
|
-
(_this_root = this.root) == null ? void 0 : _this_root.controlStateChanged(this);
|
|
25538
|
-
}
|
|
25539
|
-
}
|
|
25540
|
-
},
|
|
25541
|
-
{
|
|
25542
|
-
key: "focusMode",
|
|
25543
|
-
get: function get() {
|
|
25544
|
-
return this._focusMode;
|
|
25545
|
-
},
|
|
25546
|
-
set: function set(value) {
|
|
25547
|
-
if (this._focusMode !== value) {
|
|
25548
|
-
var _this_root;
|
|
25549
|
-
this._focusMode = value;
|
|
25550
|
-
(_this_root = this.root) == null ? void 0 : _this_root.controlStateChanged(this);
|
|
25551
|
-
}
|
|
25552
|
-
}
|
|
25553
|
-
},
|
|
25554
|
-
{
|
|
25555
|
-
key: "focusBehaviorRecursive",
|
|
25556
|
-
get: function get() {
|
|
25557
|
-
return this._focusBehaviorRecursive;
|
|
25558
|
-
},
|
|
25559
|
-
set: function set(value) {
|
|
25560
|
-
if (this._focusBehaviorRecursive !== value) {
|
|
25561
|
-
var _this_root;
|
|
25562
|
-
this._focusBehaviorRecursive = value;
|
|
25563
|
-
(_this_root = this.root) == null ? void 0 : _this_root.controlStateChanged(this);
|
|
25564
|
-
}
|
|
25565
|
-
}
|
|
25566
|
-
},
|
|
25567
|
-
{
|
|
25568
|
-
key: "defaultCursorShape",
|
|
25569
|
-
get: function get() {
|
|
25570
|
-
return this._defaultCursorShape;
|
|
25571
|
-
},
|
|
25572
|
-
set: function set(value) {
|
|
25573
|
-
var _this_root;
|
|
25574
|
-
if (this._defaultCursorShape === value) {
|
|
25575
|
-
return;
|
|
25576
|
-
}
|
|
25577
|
-
this._defaultCursorShape = value;
|
|
25578
|
-
(_this_root = this.root) == null ? void 0 : _this_root.updateMouseCursorState();
|
|
25579
|
-
}
|
|
25580
|
-
},
|
|
25581
|
-
{
|
|
25582
|
-
key: "location",
|
|
25583
|
-
get: function get() {
|
|
25584
|
-
return this.position;
|
|
25585
|
-
},
|
|
25586
|
-
set: function set(value) {
|
|
25587
|
-
this.setPosition(value.x, value.y);
|
|
25588
|
-
}
|
|
25589
|
-
},
|
|
25590
|
-
{
|
|
25591
|
-
key: "rotation",
|
|
25592
|
-
get: function get() {
|
|
25593
|
-
return this._rotation;
|
|
25594
|
-
}
|
|
25595
|
-
},
|
|
25596
|
-
{
|
|
25597
|
-
key: "x",
|
|
25598
|
-
get: function get() {
|
|
25599
|
-
return this.position.x;
|
|
25600
|
-
},
|
|
25601
|
-
set: function set(value) {
|
|
25602
|
-
this.setPosition(value, this.position.y);
|
|
25603
|
-
}
|
|
25604
|
-
},
|
|
25605
|
-
{
|
|
25606
|
-
key: "y",
|
|
25607
|
-
get: function get() {
|
|
25608
|
-
return this.position.y;
|
|
25609
|
-
},
|
|
25610
|
-
set: function set(value) {
|
|
25611
|
-
this.setPosition(this.position.x, value);
|
|
25612
|
-
}
|
|
25613
|
-
},
|
|
25614
|
-
{
|
|
25615
|
-
key: "width",
|
|
25616
|
-
get: function get() {
|
|
25617
|
-
return this.size.x;
|
|
25618
|
-
},
|
|
25619
|
-
set: function set(value) {
|
|
25620
|
-
this.setSize(value, this.size.y);
|
|
25621
|
-
}
|
|
25622
|
-
},
|
|
25623
|
-
{
|
|
25624
|
-
key: "height",
|
|
25625
|
-
get: function get() {
|
|
25626
|
-
return this.size.y;
|
|
25627
|
-
},
|
|
25628
|
-
set: function set(value) {
|
|
25629
|
-
this.setSize(this.size.x, value);
|
|
25630
|
-
}
|
|
25631
|
-
},
|
|
25632
|
-
{
|
|
25633
|
-
key: "root",
|
|
25634
|
-
get: function get() {
|
|
25635
|
-
var _this_parent;
|
|
25636
|
-
var _this_parent_root;
|
|
25637
|
-
return _instanceof1(this, RootControl) ? this : (_this_parent_root = (_this_parent = this.parent) == null ? void 0 : _this_parent.root) != null ? _this_parent_root : null;
|
|
25638
|
-
}
|
|
25639
|
-
},
|
|
25640
|
-
{
|
|
25641
|
-
key: "isDisposed",
|
|
25642
|
-
get: function get() {
|
|
25643
|
-
return this.disposed;
|
|
25644
|
-
}
|
|
25645
|
-
}
|
|
25646
|
-
]);
|
|
25647
|
-
return Control;
|
|
25648
|
-
}();
|
|
25649
|
-
/** A Control that owns child Controls. */ var ContainerControl = /*#__PURE__*/ function(Control) {
|
|
25650
|
-
_inherits(ContainerControl, Control);
|
|
25651
|
-
function ContainerControl() {
|
|
25652
|
-
var _this;
|
|
25653
|
-
_this = Control.apply(this, arguments) || this;
|
|
25654
|
-
_this.children = [];
|
|
25655
|
-
return _this;
|
|
25656
|
-
}
|
|
25657
|
-
var _proto = ContainerControl.prototype;
|
|
25658
|
-
_proto.addChild = function addChild(child) {
|
|
25659
|
-
child.parent = this;
|
|
25660
|
-
return child;
|
|
25661
|
-
};
|
|
25662
|
-
_proto.removeChild = function removeChild(child) {
|
|
25663
|
-
if (child.parent === this) {
|
|
25664
|
-
child.parent = null;
|
|
25665
|
-
}
|
|
25666
|
-
};
|
|
25667
|
-
_proto.getChildIndex = function getChildIndex(child) {
|
|
25668
|
-
return this.children.indexOf(child);
|
|
25669
|
-
};
|
|
25670
|
-
/** @internal */ _proto.changeChildIndex = function changeChildIndex(child, newIndex) {
|
|
25671
|
-
var _this_root;
|
|
25672
|
-
var oldIndex = this.children.indexOf(child);
|
|
25673
|
-
if (oldIndex === newIndex || oldIndex === -1) {
|
|
25674
|
-
return;
|
|
25675
|
-
}
|
|
25676
|
-
this.children.splice(oldIndex, 1);
|
|
25677
|
-
if (newIndex < 0 || newIndex >= this.children.length) {
|
|
25678
|
-
this.children.push(child);
|
|
25679
|
-
} else {
|
|
25680
|
-
this.children.splice(newIndex, 0, child);
|
|
25681
|
-
}
|
|
25682
|
-
(_this_root = this.root) == null ? void 0 : _this_root.controlTreeChanged();
|
|
25683
|
-
};
|
|
25684
|
-
/** @internal */ _proto.addChildInternal = function addChildInternal(child) {
|
|
25685
|
-
if (!this.children.includes(child)) {
|
|
25686
|
-
this.children.push(child);
|
|
25687
|
-
}
|
|
25688
|
-
};
|
|
25689
|
-
/** @internal */ _proto.removeChildInternal = function removeChildInternal(child) {
|
|
25690
|
-
var index = this.children.indexOf(child);
|
|
25691
|
-
if (index !== -1) {
|
|
25692
|
-
this.children.splice(index, 1);
|
|
25693
|
-
}
|
|
25694
|
-
};
|
|
25695
|
-
_proto.drawSelf = function drawSelf() {
|
|
25696
|
-
Control.prototype.draw.call(this);
|
|
25697
|
-
};
|
|
25698
|
-
_proto.draw = function draw() {
|
|
25699
|
-
this.drawSelf();
|
|
25700
|
-
this.drawChildren();
|
|
25701
|
-
};
|
|
25702
|
-
_proto.drawChildren = function drawChildren() {
|
|
25703
|
-
var graphics = this.engine.graphics;
|
|
25704
|
-
if (this.clipContents) ;
|
|
25705
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(this.children), _step; !(_step = _iterator()).done;){
|
|
25706
|
-
var child = _step.value;
|
|
25707
|
-
if (!child.visible || child.isDisposed) {
|
|
25708
|
-
continue;
|
|
25709
|
-
}
|
|
25710
|
-
graphics.pushTransform(child.getTransform2D());
|
|
25711
|
-
child.draw();
|
|
25712
|
-
graphics.popTransform();
|
|
25713
|
-
}
|
|
25714
|
-
};
|
|
25715
|
-
_proto.update = function update(deltaTime) {
|
|
25716
|
-
Control.prototype.update.call(this, deltaTime);
|
|
25717
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(this.children.slice()), _step; !(_step = _iterator()).done;){
|
|
25718
|
-
var child = _step.value;
|
|
25719
|
-
if (child.enabled && !child.isDisposed) {
|
|
25720
|
-
child.update(deltaTime);
|
|
25721
|
-
}
|
|
25722
|
-
}
|
|
25723
|
-
};
|
|
25724
|
-
_proto.dispose = function dispose() {
|
|
25725
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(this.children.slice()), _step; !(_step = _iterator()).done;){
|
|
25726
|
-
var child = _step.value;
|
|
25727
|
-
child.dispose();
|
|
25728
|
-
}
|
|
25729
|
-
Control.prototype.dispose.call(this);
|
|
25730
|
-
};
|
|
25731
|
-
return ContainerControl;
|
|
25732
|
-
}(Control);
|
|
25733
|
-
/** Base class for GUI tree roots and input dispatchers. */ var RootControl = /*#__PURE__*/ function(ContainerControl) {
|
|
25734
|
-
_inherits(RootControl, ContainerControl);
|
|
25735
|
-
function RootControl() {
|
|
25736
|
-
return ContainerControl.apply(this, arguments);
|
|
25737
|
-
}
|
|
25738
|
-
return RootControl;
|
|
25739
|
-
}(ContainerControl);
|
|
25740
|
-
|
|
25741
|
-
var _obj$4;
|
|
25742
|
-
var cursorNames = (_obj$4 = {}, _obj$4[exports.CursorShape.Arrow] = "default", _obj$4[exports.CursorShape.Ibeam] = "text", _obj$4[exports.CursorShape.PointingHand] = "pointer", _obj$4[exports.CursorShape.Cross] = "crosshair", _obj$4[exports.CursorShape.Wait] = "wait", _obj$4[exports.CursorShape.Busy] = "progress", _obj$4[exports.CursorShape.Drag] = "grab", _obj$4[exports.CursorShape.CanDrop] = "copy", _obj$4[exports.CursorShape.Forbidden] = "not-allowed", _obj$4[exports.CursorShape.Vsize] = "ns-resize", _obj$4[exports.CursorShape.Hsize] = "ew-resize", _obj$4[exports.CursorShape.Bdiagsize] = "nesw-resize", _obj$4[exports.CursorShape.Fdiagsize] = "nwse-resize", _obj$4[exports.CursorShape.Move] = "move", _obj$4[exports.CursorShape.Vsplit] = "row-resize", _obj$4[exports.CursorShape.Hsplit] = "col-resize", _obj$4[exports.CursorShape.Help] = "help", _obj$4);
|
|
25743
|
-
function getButtonMask(button) {
|
|
25744
|
-
switch(button){
|
|
25745
|
-
case exports.MouseButton.Left:
|
|
25746
|
-
return exports.MouseButtonMask.Left;
|
|
25747
|
-
case exports.MouseButton.Right:
|
|
25748
|
-
return exports.MouseButtonMask.Right;
|
|
25749
|
-
case exports.MouseButton.Middle:
|
|
25750
|
-
return exports.MouseButtonMask.Middle;
|
|
25751
|
-
case exports.MouseButton.Xbutton1:
|
|
25752
|
-
return exports.MouseButtonMask.Xbutton1;
|
|
25753
|
-
case exports.MouseButton.Xbutton2:
|
|
25754
|
-
return exports.MouseButtonMask.Xbutton2;
|
|
25755
|
-
default:
|
|
25756
|
-
return exports.MouseButtonMask.None;
|
|
25757
|
-
}
|
|
25758
|
-
}
|
|
25759
|
-
function isWheelButton(button) {
|
|
25760
|
-
return button >= exports.MouseButton.WheelUp && button <= exports.MouseButton.WheelRight;
|
|
25761
|
-
}
|
|
25762
|
-
/** CanvasLayer-like boundary for a single UICanvas GUI tree. */ var CanvasRootControl = /*#__PURE__*/ function(ContainerControl) {
|
|
25763
|
-
_inherits(CanvasRootControl, ContainerControl);
|
|
25764
|
-
function CanvasRootControl(engine, canvas) {
|
|
25765
|
-
var _this;
|
|
25766
|
-
_this = ContainerControl.call(this, engine) || this;
|
|
25767
|
-
_this.canvas = canvas;
|
|
25768
|
-
_this.mouseFilter = exports.MouseFilter.Ignore;
|
|
25769
|
-
_this.setSize(engine.canvas.width, engine.canvas.height);
|
|
25770
|
-
return _this;
|
|
25771
|
-
}
|
|
25772
|
-
_create_class(CanvasRootControl, [
|
|
25773
|
-
{
|
|
25774
|
-
key: "inputDisabled",
|
|
25775
|
-
get: function get() {
|
|
25776
|
-
var _this_canvas_item;
|
|
25777
|
-
return !this.canvas.receivesEvents || !this.canvas.enabled || !((_this_canvas_item = this.canvas.item) == null ? void 0 : _this_canvas_item.isActive);
|
|
25778
|
-
}
|
|
25779
|
-
}
|
|
25780
|
-
]);
|
|
25781
|
-
return CanvasRootControl;
|
|
25782
|
-
}(ContainerControl);
|
|
25783
|
-
/** Global ordered collection of UICanvas roots. */ var CanvasContainer = /*#__PURE__*/ function(ContainerControl) {
|
|
25784
|
-
_inherits(CanvasContainer, ContainerControl);
|
|
25785
|
-
function CanvasContainer(engine) {
|
|
25786
|
-
var _this;
|
|
25787
|
-
_this = ContainerControl.call(this, engine) || this;
|
|
25788
|
-
_this.mouseFilter = exports.MouseFilter.Ignore;
|
|
25789
|
-
_this.setSize(engine.canvas.width, engine.canvas.height);
|
|
25790
|
-
return _this;
|
|
25791
|
-
}
|
|
25792
|
-
var _proto = CanvasContainer.prototype;
|
|
25793
|
-
_proto.sortCanvases = function sortCanvases() {
|
|
25794
|
-
this.children.sort(function(left, right) {
|
|
25795
|
-
return left.canvas.order - right.canvas.order;
|
|
25796
|
-
});
|
|
25797
|
-
};
|
|
25798
|
-
_proto.addChildInternal = function addChildInternal(child) {
|
|
25799
|
-
ContainerControl.prototype.addChildInternal.call(this, child);
|
|
25800
|
-
this.sortCanvases();
|
|
25801
|
-
};
|
|
25802
|
-
_proto.draw = function draw() {
|
|
25803
|
-
this.sortCanvases();
|
|
25804
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(this.children), _step; !(_step = _iterator()).done;){
|
|
25805
|
-
var child = _step.value;
|
|
25806
|
-
var root = child;
|
|
25807
|
-
if (root.canvas.isVisible) {
|
|
25808
|
-
root.draw();
|
|
25809
|
-
}
|
|
25810
|
-
}
|
|
25811
|
-
};
|
|
25812
|
-
return CanvasContainer;
|
|
25813
|
-
}(ContainerControl);
|
|
25814
|
-
/** Engine window GUI root. Routes events across all UICanvas roots. */ var WindowRootControl = /*#__PURE__*/ function(RootControl) {
|
|
25815
|
-
_inherits(WindowRootControl, RootControl);
|
|
25816
|
-
function WindowRootControl(engine) {
|
|
25817
|
-
var _this;
|
|
25818
|
-
_this = RootControl.call(this, engine) || this;
|
|
25819
|
-
_this.dragThreshold = 10;
|
|
25820
|
-
_this.lastInput = null;
|
|
25821
|
-
_this.gui = {
|
|
25822
|
-
mouseFocus: null,
|
|
25823
|
-
mouseClickGrabber: null,
|
|
25824
|
-
mouseFocusMask: exports.MouseButtonMask.None,
|
|
25825
|
-
mouseOver: null,
|
|
25826
|
-
mouseOverHierarchy: [],
|
|
25827
|
-
touchFocus: new Map(),
|
|
25828
|
-
keyFocus: null,
|
|
25829
|
-
dragAccum: new Vector2(),
|
|
25830
|
-
dragAttempted: false,
|
|
25831
|
-
dragging: false,
|
|
25832
|
-
dragData: null,
|
|
25833
|
-
dragMouseOver: null,
|
|
25834
|
-
dragSuccessful: false,
|
|
25835
|
-
lastMousePosition: new Vector2(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY),
|
|
25836
|
-
sendingMouseEnterExit: false,
|
|
25837
|
-
mouseOverUpdatePending: false
|
|
25838
|
-
};
|
|
25839
|
-
_this.mouseFilter = exports.MouseFilter.Ignore;
|
|
25840
|
-
_this.setSize(engine.canvas.width, engine.canvas.height);
|
|
25841
|
-
_this.canvases = new CanvasContainer(engine);
|
|
25842
|
-
_this.canvases.parent = _assert_this_initialized(_this);
|
|
25843
|
-
return _this;
|
|
25844
|
-
}
|
|
25845
|
-
var _proto = WindowRootControl.prototype;
|
|
25846
|
-
_proto.pushInput = function pushInput(event) {
|
|
25847
|
-
event.clearAccepted();
|
|
25848
|
-
this.lastInput = event;
|
|
25849
|
-
this.cleanupInternalState();
|
|
25850
|
-
this.processGUIInput(event);
|
|
25851
|
-
this.postGrabClickFocus();
|
|
25852
|
-
};
|
|
25853
|
-
_proto.isInputHandled = function isInputHandled() {
|
|
25854
|
-
var _this_lastInput;
|
|
25855
|
-
var _this_lastInput_isAccepted;
|
|
25856
|
-
return (_this_lastInput_isAccepted = (_this_lastInput = this.lastInput) == null ? void 0 : _this_lastInput.isAccepted()) != null ? _this_lastInput_isAccepted : false;
|
|
25857
|
-
};
|
|
25858
|
-
_proto.getMousePosition = function getMousePosition() {
|
|
25859
|
-
return this.gui.lastMousePosition.clone();
|
|
25860
|
-
};
|
|
25861
|
-
_proto.guiGetFocusOwner = function guiGetFocusOwner() {
|
|
25862
|
-
return this.isFocusTargetUsable(this.gui.keyFocus) ? this.gui.keyFocus : null;
|
|
25863
|
-
};
|
|
25864
|
-
_proto.guiReleaseFocus = function guiReleaseFocus() {
|
|
25865
|
-
this.releaseControlFocus();
|
|
25866
|
-
};
|
|
25867
|
-
_proto.guiIsDragging = function guiIsDragging() {
|
|
25868
|
-
return this.gui.dragging;
|
|
25869
|
-
};
|
|
25870
|
-
_proto.guiGetDragData = function guiGetDragData() {
|
|
25871
|
-
return this.gui.dragData;
|
|
25872
|
-
};
|
|
25873
|
-
_proto.guiIsDragSuccessful = function guiIsDragSuccessful() {
|
|
25874
|
-
return this.gui.dragSuccessful;
|
|
25875
|
-
};
|
|
25876
|
-
_proto.guiCancelDrag = function guiCancelDrag() {
|
|
25877
|
-
this.endDragging(false);
|
|
25878
|
-
};
|
|
25879
|
-
_proto.grabControlFocus = function grabControlFocus(control) {
|
|
25880
|
-
if (!this.isFocusTargetUsable(control) || this.gui.keyFocus === control) {
|
|
25881
|
-
return;
|
|
25882
|
-
}
|
|
25883
|
-
var previous = this.gui.keyFocus;
|
|
25884
|
-
this.gui.keyFocus = control;
|
|
25885
|
-
if (previous && !previous.isDisposed) {
|
|
25886
|
-
previous.onLostFocus();
|
|
25887
|
-
}
|
|
25888
|
-
control.onGotFocus();
|
|
25889
|
-
};
|
|
25890
|
-
_proto.grabControlClickFocus = function grabControlClickFocus(control) {
|
|
25891
|
-
var _this = this;
|
|
25892
|
-
if (this.isControlValid(control)) {
|
|
25893
|
-
this.gui.mouseClickGrabber = control;
|
|
25894
|
-
queueMicrotask(function() {
|
|
25895
|
-
return _this.postGrabClickFocus();
|
|
25896
|
-
});
|
|
25897
|
-
}
|
|
25898
|
-
};
|
|
25899
|
-
_proto.releaseControlFocus = function releaseControlFocus(control) {
|
|
25900
|
-
var previous = this.gui.keyFocus;
|
|
25901
|
-
if (!previous || control && previous !== control) {
|
|
25902
|
-
return;
|
|
25903
|
-
}
|
|
25904
|
-
this.gui.keyFocus = null;
|
|
25905
|
-
if (!previous.isDisposed) {
|
|
25906
|
-
previous.onLostFocus();
|
|
25907
|
-
}
|
|
25908
|
-
};
|
|
25909
|
-
_proto.warpControlMouse = function warpControlMouse(position) {
|
|
25910
|
-
this.gui.lastMousePosition.copyFrom(position);
|
|
25911
|
-
this.updateMouseOver(position);
|
|
25912
|
-
this.updateMouseCursorState();
|
|
25913
|
-
};
|
|
25914
|
-
_proto.updateMouseCursorState = function updateMouseCursorState() {
|
|
25915
|
-
var position = this.gui.lastMousePosition;
|
|
25916
|
-
var target = this.isControlUsable(this.gui.mouseFocus) ? this.gui.mouseFocus : this.isControlUsable(this.gui.mouseOver) ? this.gui.mouseOver : null;
|
|
25917
|
-
this.updateCursor(target, position);
|
|
25918
|
-
};
|
|
25919
|
-
_proto.controlStateChanged = function controlStateChanged(control) {
|
|
25920
|
-
if (!this.isControlUsable(control)) {
|
|
25921
|
-
this.dropControlState(control);
|
|
25922
|
-
}
|
|
25923
|
-
this.requestMouseOverUpdate();
|
|
25924
|
-
};
|
|
25925
|
-
_proto.controlRemoved = function controlRemoved(control) {
|
|
25926
|
-
this.dropControlState(control);
|
|
25927
|
-
this.cleanupInternalState();
|
|
25928
|
-
this.requestMouseOverUpdate();
|
|
25929
|
-
};
|
|
25930
|
-
_proto.controlTreeChanged = function controlTreeChanged() {
|
|
25931
|
-
this.requestMouseOverUpdate();
|
|
25932
|
-
};
|
|
25933
|
-
_proto.cancelPointerInput = function cancelPointerInput() {
|
|
25934
|
-
this.dropMouseFocus();
|
|
25935
|
-
this.dropMouseOver();
|
|
25936
|
-
this.gui.touchFocus.clear();
|
|
25937
|
-
this.endDragging(false);
|
|
25938
|
-
this.releaseControlFocus();
|
|
25939
|
-
};
|
|
25940
|
-
_proto.resize = function resize(width, height) {
|
|
25941
|
-
this.setSize(width, height);
|
|
25942
|
-
this.canvases.setSize(width, height);
|
|
25943
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(this.canvases.children), _step; !(_step = _iterator()).done;){
|
|
25944
|
-
var root = _step.value;
|
|
25945
|
-
root.setSize(width, height);
|
|
25946
|
-
}
|
|
25947
|
-
};
|
|
25948
|
-
_proto.render = function render() {
|
|
25949
|
-
if (this.canvases.children.length === 0) {
|
|
25950
|
-
return;
|
|
25951
|
-
}
|
|
25952
|
-
this.engine.graphics.begin();
|
|
25953
|
-
this.draw();
|
|
25954
|
-
this.engine.graphics.end();
|
|
25955
|
-
};
|
|
25956
|
-
_proto.update = function update(deltaTime) {
|
|
25957
|
-
if (this.gui.mouseOverUpdatePending) {
|
|
25958
|
-
this.gui.mouseOverUpdatePending = false;
|
|
25959
|
-
this.updateMouseOver(this.gui.lastMousePosition);
|
|
25960
|
-
}
|
|
25961
|
-
RootControl.prototype.update.call(this, deltaTime);
|
|
25962
|
-
};
|
|
25963
|
-
_proto.dispose = function dispose() {
|
|
25964
|
-
this.cancelPointerInput();
|
|
25965
|
-
RootControl.prototype.dispose.call(this);
|
|
25966
|
-
};
|
|
25967
|
-
_proto.processGUIInput = function processGUIInput(event) {
|
|
25968
|
-
if (_instanceof1(event, InputEventKey)) {
|
|
25969
|
-
var target = this.guiGetFocusOwner();
|
|
25970
|
-
if (target) {
|
|
25971
|
-
this.callControlInput(target, event);
|
|
25972
|
-
}
|
|
25973
|
-
} else if (_instanceof1(event, InputEventMouse)) {
|
|
25974
|
-
this.gui.lastMousePosition.copyFrom(event.globalPosition);
|
|
25975
|
-
this.updateMouseOver(event.globalPosition);
|
|
25976
|
-
if (_instanceof1(event, InputEventMouseButton)) {
|
|
25977
|
-
this.processMouseButton(event);
|
|
25978
|
-
} else if (_instanceof1(event, InputEventMouseMotion)) {
|
|
25979
|
-
this.processMouseMotion(event);
|
|
25980
|
-
}
|
|
25981
|
-
} else if (_instanceof1(event, InputEventScreenTouch)) {
|
|
25982
|
-
this.processScreenTouch(event);
|
|
25983
|
-
} else if (_instanceof1(event, InputEventScreenDrag)) {
|
|
25984
|
-
this.processScreenDrag(event);
|
|
25985
|
-
}
|
|
25986
|
-
};
|
|
25987
|
-
_proto.processMouseButton = function processMouseButton(event) {
|
|
25988
|
-
if (isWheelButton(event.buttonIndex)) {
|
|
25989
|
-
var target = this.findInputControl(event.globalPosition);
|
|
25990
|
-
if (target) {
|
|
25991
|
-
this.callGUIInput(target, event);
|
|
25992
|
-
}
|
|
25993
|
-
return;
|
|
25994
|
-
}
|
|
25995
|
-
var mask = getButtonMask(event.buttonIndex);
|
|
25996
|
-
if (event.isPressed()) {
|
|
25997
|
-
var target1 = this.gui.mouseFocusMask !== 0 ? this.gui.mouseFocus : this.findInputControl(event.globalPosition);
|
|
25998
|
-
this.gui.mouseFocus = target1;
|
|
25999
|
-
if (!target1) {
|
|
26000
|
-
return;
|
|
26001
|
-
}
|
|
26002
|
-
this.gui.mouseFocusMask |= mask;
|
|
26003
|
-
if (event.buttonIndex === exports.MouseButton.Left) {
|
|
26004
|
-
this.gui.dragAccum.setZero();
|
|
26005
|
-
this.gui.dragAttempted = false;
|
|
26006
|
-
this.findClickFocus(target1);
|
|
26007
|
-
}
|
|
26008
|
-
this.callGUIInput(target1, event);
|
|
26009
|
-
} else {
|
|
26010
|
-
if (event.buttonIndex === exports.MouseButton.Left && this.gui.dragging) {
|
|
26011
|
-
this.finishDrop(event.globalPosition);
|
|
26012
|
-
}
|
|
26013
|
-
this.gui.mouseFocusMask &= ~mask;
|
|
26014
|
-
var target2 = this.gui.mouseFocus;
|
|
26015
|
-
if (this.gui.mouseFocusMask === 0) {
|
|
26016
|
-
this.gui.mouseFocus = null;
|
|
26017
|
-
}
|
|
26018
|
-
if (this.isControlUsable(target2)) {
|
|
26019
|
-
this.callGUIInput(target2, event);
|
|
26020
|
-
}
|
|
26021
|
-
}
|
|
26022
|
-
};
|
|
26023
|
-
_proto.processMouseMotion = function processMouseMotion(event) {
|
|
26024
|
-
if (!this.gui.dragging && !this.gui.dragAttempted && this.gui.mouseFocus && (this.gui.mouseFocusMask & exports.MouseButtonMask.Left) !== 0) {
|
|
26025
|
-
this.gui.dragAccum.add(event.relative);
|
|
26026
|
-
if (this.gui.dragAccum.length() > this.dragThreshold) {
|
|
26027
|
-
var origin = event.globalPosition.clone().subtract(this.gui.dragAccum);
|
|
26028
|
-
this.beginDragging(this.gui.mouseFocus, origin);
|
|
26029
|
-
this.gui.dragAttempted = true;
|
|
26030
|
-
}
|
|
26031
|
-
}
|
|
26032
|
-
var target = this.isControlUsable(this.gui.mouseFocus) ? this.gui.mouseFocus : this.findInputControl(event.globalPosition);
|
|
26033
|
-
if (target) {
|
|
26034
|
-
this.callGUIInput(target, event);
|
|
26035
|
-
}
|
|
26036
|
-
if (this.gui.dragging) {
|
|
26037
|
-
this.gui.dragMouseOver = this.findDropTarget(this.findInputControl(event.globalPosition), event.globalPosition);
|
|
26038
|
-
}
|
|
26039
|
-
this.updateCursor(target, event.globalPosition);
|
|
26040
|
-
};
|
|
26041
|
-
_proto.processScreenTouch = function processScreenTouch(event) {
|
|
26042
|
-
var target;
|
|
26043
|
-
if (event.isPressed()) {
|
|
26044
|
-
target = this.findInputControl(event.position);
|
|
26045
|
-
if (target) {
|
|
26046
|
-
this.gui.touchFocus.set(event.index, target);
|
|
26047
|
-
}
|
|
26048
|
-
} else {
|
|
26049
|
-
var _this_gui_touchFocus_get;
|
|
26050
|
-
target = (_this_gui_touchFocus_get = this.gui.touchFocus.get(event.index)) != null ? _this_gui_touchFocus_get : null;
|
|
26051
|
-
this.gui.touchFocus.delete(event.index);
|
|
26052
|
-
}
|
|
26053
|
-
if (this.isControlUsable(target)) {
|
|
26054
|
-
this.callGUIInput(target, event);
|
|
26055
|
-
}
|
|
26056
|
-
};
|
|
26057
|
-
_proto.processScreenDrag = function processScreenDrag(event) {
|
|
26058
|
-
var _this_gui_touchFocus_get;
|
|
26059
|
-
var target = (_this_gui_touchFocus_get = this.gui.touchFocus.get(event.index)) != null ? _this_gui_touchFocus_get : this.findInputControl(event.position);
|
|
26060
|
-
if (this.isControlUsable(target)) {
|
|
26061
|
-
this.callGUIInput(target, event);
|
|
26062
|
-
}
|
|
26063
|
-
};
|
|
26064
|
-
_proto.callGUIInput = function callGUIInput(target, event) {
|
|
26065
|
-
var current = target;
|
|
26066
|
-
var pointerEvent = _instanceof1(event, InputEventMouse) || _instanceof1(event, InputEventScreenTouch) || _instanceof1(event, InputEventScreenDrag);
|
|
26067
|
-
while(current && current !== this && this.isControlUsable(current)){
|
|
26068
|
-
var filter = current.getEffectiveMouseFilter();
|
|
26069
|
-
if (filter !== exports.MouseFilter.Ignore) {
|
|
26070
|
-
var localEvent = event.xformedBy(this.getGlobalInverse(current));
|
|
26071
|
-
this.callControlInput(current, localEvent);
|
|
26072
|
-
if (localEvent.isAccepted()) {
|
|
26073
|
-
event.accept();
|
|
26074
|
-
}
|
|
26075
|
-
}
|
|
26076
|
-
var forcePassWheel = _instanceof1(event, InputEventMouseButton) && isWheelButton(event.buttonIndex) && current.mouseForcePassScrollEvents;
|
|
26077
|
-
if (event.isAccepted() || filter === exports.MouseFilter.Stop && pointerEvent && !forcePassWheel) {
|
|
26078
|
-
event.accept();
|
|
26079
|
-
return;
|
|
26080
|
-
}
|
|
26081
|
-
current = current.parent;
|
|
26082
|
-
}
|
|
26083
|
-
};
|
|
26084
|
-
_proto.callControlInput = function callControlInput(control, event) {
|
|
26085
|
-
if (_instanceof1(event, InputEventMouseButton)) {
|
|
26086
|
-
if (isWheelButton(event.buttonIndex)) {
|
|
26087
|
-
control.onMouseWheel(event);
|
|
26088
|
-
} else if (event.isPressed()) {
|
|
26089
|
-
control.onMouseDown(event);
|
|
26090
|
-
} else {
|
|
26091
|
-
control.onMouseUp(event);
|
|
26092
|
-
}
|
|
26093
|
-
} else if (_instanceof1(event, InputEventMouseMotion)) {
|
|
26094
|
-
control.onMouseMove(event);
|
|
26095
|
-
} else if (_instanceof1(event, InputEventScreenTouch)) {
|
|
26096
|
-
if (event.isPressed()) {
|
|
26097
|
-
control.onTouchDown(event);
|
|
26098
|
-
} else {
|
|
26099
|
-
control.onTouchUp(event);
|
|
26100
|
-
}
|
|
26101
|
-
} else if (_instanceof1(event, InputEventScreenDrag)) {
|
|
26102
|
-
control.onTouchMove(event);
|
|
26103
|
-
} else if (_instanceof1(event, InputEventKey)) {
|
|
26104
|
-
if (event.isPressed()) {
|
|
26105
|
-
control.onKeyDown(event);
|
|
26106
|
-
} else if (event.isReleased()) {
|
|
26107
|
-
control.onKeyUp(event);
|
|
26108
|
-
}
|
|
26109
|
-
}
|
|
26110
|
-
};
|
|
26111
|
-
_proto.findInputControl = function findInputControl(position) {
|
|
26112
|
-
this.canvases.sortCanvases();
|
|
26113
|
-
for(var index = this.canvases.children.length - 1; index >= 0; index--){
|
|
26114
|
-
var root = this.canvases.children[index];
|
|
26115
|
-
if (!root.canvas.isVisible || root.inputDisabled) {
|
|
26116
|
-
continue;
|
|
26117
|
-
}
|
|
26118
|
-
var target = this.findControlAtPosition(root, position, true);
|
|
26119
|
-
if (target) {
|
|
26120
|
-
return target;
|
|
26121
|
-
}
|
|
26122
|
-
}
|
|
26123
|
-
return null;
|
|
26124
|
-
};
|
|
26125
|
-
_proto.findControlAtPosition = function findControlAtPosition(container, position, skipSelf) {
|
|
26126
|
-
if (skipSelf === void 0) skipSelf = false;
|
|
26127
|
-
if (!container.visibleInHierarchy || container.isDisposed) {
|
|
26128
|
-
return null;
|
|
26129
|
-
}
|
|
26130
|
-
var localPosition = this.toLocal(container, position);
|
|
26131
|
-
if (container.clipContents && !container.hasPoint(localPosition)) {
|
|
26132
|
-
return null;
|
|
26133
|
-
}
|
|
26134
|
-
for(var index = container.children.length - 1; index >= 0; index--){
|
|
26135
|
-
var child = container.children[index];
|
|
26136
|
-
if (!child.visibleInHierarchy || child.isDisposed) {
|
|
26137
|
-
continue;
|
|
26138
|
-
}
|
|
26139
|
-
if (_instanceof1(child, ContainerControl)) {
|
|
26140
|
-
var found = this.findControlAtPosition(child, position);
|
|
26141
|
-
if (found) {
|
|
26142
|
-
return found;
|
|
26143
|
-
}
|
|
26144
|
-
} else if (child.getEffectiveMouseFilter() !== exports.MouseFilter.Ignore && child.hasPoint(this.toLocal(child, position))) {
|
|
26145
|
-
return child;
|
|
26146
|
-
}
|
|
26147
|
-
}
|
|
26148
|
-
if (!skipSelf && container.getEffectiveMouseFilter() !== exports.MouseFilter.Ignore && container.hasPoint(localPosition)) {
|
|
26149
|
-
return container;
|
|
26150
|
-
}
|
|
26151
|
-
return null;
|
|
26152
|
-
};
|
|
26153
|
-
_proto.updateMouseOver = function updateMouseOver(position) {
|
|
26154
|
-
if (this.gui.sendingMouseEnterExit) {
|
|
26155
|
-
this.gui.mouseOverUpdatePending = true;
|
|
26156
|
-
return;
|
|
26157
|
-
}
|
|
26158
|
-
this.gui.mouseOverUpdatePending = false;
|
|
26159
|
-
var target = this.findInputControl(position);
|
|
26160
|
-
var next = this.buildHoverHierarchy(target);
|
|
26161
|
-
var previous = this.gui.mouseOverHierarchy;
|
|
26162
|
-
var common = 0;
|
|
26163
|
-
while(common < previous.length && common < next.length && previous[common] === next[common]){
|
|
26164
|
-
common++;
|
|
26165
|
-
}
|
|
26166
|
-
this.gui.sendingMouseEnterExit = true;
|
|
26167
|
-
for(var index = previous.length - 1; index >= common; index--){
|
|
26168
|
-
if (!previous[index].isDisposed) {
|
|
26169
|
-
previous[index].onMouseLeave();
|
|
26170
|
-
}
|
|
26171
|
-
}
|
|
26172
|
-
for(var index1 = common; index1 < next.length; index1++){
|
|
26173
|
-
next[index1].onMouseEnter(this.toLocal(next[index1], position));
|
|
26174
|
-
}
|
|
26175
|
-
this.gui.sendingMouseEnterExit = false;
|
|
26176
|
-
this.gui.mouseOver = target;
|
|
26177
|
-
this.gui.mouseOverHierarchy = next;
|
|
26178
|
-
};
|
|
26179
|
-
_proto.buildHoverHierarchy = function buildHoverHierarchy(target) {
|
|
26180
|
-
var hierarchy = [];
|
|
26181
|
-
var current = target;
|
|
26182
|
-
while(current && current !== this){
|
|
26183
|
-
if (current.getEffectiveMouseFilter() !== exports.MouseFilter.Ignore) {
|
|
26184
|
-
hierarchy.push(current);
|
|
26185
|
-
}
|
|
26186
|
-
if (current.getEffectiveMouseFilter() === exports.MouseFilter.Stop) {
|
|
26187
|
-
break;
|
|
26188
|
-
}
|
|
26189
|
-
current = current.parent;
|
|
26190
|
-
}
|
|
26191
|
-
hierarchy.reverse();
|
|
26192
|
-
return hierarchy;
|
|
26193
|
-
};
|
|
26194
|
-
_proto.findClickFocus = function findClickFocus(target) {
|
|
26195
|
-
var current = target;
|
|
26196
|
-
while(current && current !== this){
|
|
26197
|
-
var mode = current.getFocusModeWithOverride();
|
|
26198
|
-
if (mode === exports.FocusMode.Click || mode === exports.FocusMode.All) {
|
|
26199
|
-
this.grabControlFocus(current);
|
|
26200
|
-
return;
|
|
26201
|
-
}
|
|
26202
|
-
if (current.getEffectiveMouseFilter() === exports.MouseFilter.Stop) {
|
|
26203
|
-
return;
|
|
26204
|
-
}
|
|
26205
|
-
current = current.parent;
|
|
26206
|
-
}
|
|
26207
|
-
};
|
|
26208
|
-
_proto.beginDragging = function beginDragging(source, position) {
|
|
26209
|
-
var current = source;
|
|
26210
|
-
while(current && current !== this){
|
|
26211
|
-
var data = current.invokeGetDragData(this.toLocal(current, position));
|
|
26212
|
-
if (data !== null && data !== undefined) {
|
|
26213
|
-
this.gui.dragging = true;
|
|
26214
|
-
this.gui.dragData = data;
|
|
26215
|
-
this.gui.mouseFocus = null;
|
|
26216
|
-
this.gui.mouseFocusMask = exports.MouseButtonMask.None;
|
|
26217
|
-
return;
|
|
26218
|
-
}
|
|
26219
|
-
if (current.getEffectiveMouseFilter() === exports.MouseFilter.Stop) {
|
|
26220
|
-
return;
|
|
26221
|
-
}
|
|
26222
|
-
current = current.parent;
|
|
26223
|
-
}
|
|
26224
|
-
};
|
|
26225
|
-
_proto.finishDrop = function finishDrop(position) {
|
|
26226
|
-
var target = this.findDropTarget(this.findInputControl(position), position);
|
|
26227
|
-
if (target) {
|
|
26228
|
-
target.invokeDropData(this.toLocal(target, position), this.gui.dragData);
|
|
26229
|
-
}
|
|
26230
|
-
this.endDragging(!!target);
|
|
26231
|
-
};
|
|
26232
|
-
_proto.findDropTarget = function findDropTarget(target, position) {
|
|
26233
|
-
var current = target;
|
|
26234
|
-
while(current && current !== this){
|
|
26235
|
-
if (current.invokeCanDropData(this.toLocal(current, position), this.gui.dragData)) {
|
|
26236
|
-
return current;
|
|
26237
|
-
}
|
|
26238
|
-
if (current.getEffectiveMouseFilter() === exports.MouseFilter.Stop) {
|
|
26239
|
-
return null;
|
|
26240
|
-
}
|
|
26241
|
-
current = current.parent;
|
|
26242
|
-
}
|
|
26243
|
-
return null;
|
|
26244
|
-
};
|
|
26245
|
-
_proto.endDragging = function endDragging(successful) {
|
|
26246
|
-
this.gui.dragSuccessful = successful;
|
|
26247
|
-
this.gui.dragging = false;
|
|
26248
|
-
this.gui.dragData = null;
|
|
26249
|
-
this.gui.dragMouseOver = null;
|
|
26250
|
-
};
|
|
26251
|
-
_proto.updateCursor = function updateCursor(target, position) {
|
|
26252
|
-
var current = target;
|
|
26253
|
-
var cursor = exports.CursorShape.Arrow;
|
|
26254
|
-
while(current && current !== this){
|
|
26255
|
-
var candidate = current.getCursorShape(this.toLocal(current, position));
|
|
26256
|
-
if (candidate !== exports.CursorShape.Arrow) {
|
|
26257
|
-
cursor = candidate;
|
|
26258
|
-
break;
|
|
26259
|
-
}
|
|
26260
|
-
if (current.getEffectiveMouseFilter() === exports.MouseFilter.Stop) {
|
|
26261
|
-
break;
|
|
26262
|
-
}
|
|
26263
|
-
current = current.parent;
|
|
26264
|
-
}
|
|
26265
|
-
this.engine.canvas.style.cursor = typeof cursor === "string" ? cursor : cursorNames[cursor];
|
|
26266
|
-
};
|
|
26267
|
-
_proto.postGrabClickFocus = function postGrabClickFocus() {
|
|
26268
|
-
var target = this.gui.mouseClickGrabber;
|
|
26269
|
-
this.gui.mouseClickGrabber = null;
|
|
26270
|
-
if (this.isControlUsable(target)) {
|
|
26271
|
-
this.gui.mouseFocus = target;
|
|
26272
|
-
}
|
|
26273
|
-
};
|
|
26274
|
-
_proto.cleanupInternalState = function cleanupInternalState() {
|
|
26275
|
-
if (!this.isControlUsable(this.gui.mouseFocus)) {
|
|
26276
|
-
this.dropMouseFocus();
|
|
26277
|
-
}
|
|
26278
|
-
if (this.gui.keyFocus && !this.isFocusTargetUsable(this.gui.keyFocus)) {
|
|
26279
|
-
this.releaseControlFocus(this.gui.keyFocus);
|
|
26280
|
-
}
|
|
26281
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(this.gui.touchFocus), _step; !(_step = _iterator()).done;){
|
|
26282
|
-
var _step_value = _step.value, index = _step_value[0], control = _step_value[1];
|
|
26283
|
-
if (!this.isControlUsable(control)) {
|
|
26284
|
-
this.gui.touchFocus.delete(index);
|
|
26285
|
-
}
|
|
26286
|
-
}
|
|
26287
|
-
};
|
|
26288
|
-
_proto.dropMouseFocus = function dropMouseFocus() {
|
|
26289
|
-
this.gui.mouseFocus = null;
|
|
26290
|
-
this.gui.mouseFocusMask = exports.MouseButtonMask.None;
|
|
26291
|
-
};
|
|
26292
|
-
_proto.dropMouseOver = function dropMouseOver() {
|
|
26293
|
-
for(var index = this.gui.mouseOverHierarchy.length - 1; index >= 0; index--){
|
|
26294
|
-
var control = this.gui.mouseOverHierarchy[index];
|
|
26295
|
-
if (!control.isDisposed) {
|
|
26296
|
-
control.onMouseLeave();
|
|
26297
|
-
}
|
|
26298
|
-
}
|
|
26299
|
-
this.gui.mouseOver = null;
|
|
26300
|
-
this.gui.mouseOverHierarchy = [];
|
|
26301
|
-
};
|
|
26302
|
-
_proto.dropControlState = function dropControlState(control) {
|
|
26303
|
-
if (this.controlBelongsToSubtree(this.gui.mouseFocus, control)) {
|
|
26304
|
-
this.dropMouseFocus();
|
|
26305
|
-
}
|
|
26306
|
-
if (this.controlBelongsToSubtree(this.gui.mouseClickGrabber, control)) {
|
|
26307
|
-
this.gui.mouseClickGrabber = null;
|
|
26308
|
-
}
|
|
26309
|
-
if (this.controlBelongsToSubtree(this.gui.keyFocus, control)) {
|
|
26310
|
-
var _this_gui_keyFocus;
|
|
26311
|
-
this.releaseControlFocus((_this_gui_keyFocus = this.gui.keyFocus) != null ? _this_gui_keyFocus : undefined);
|
|
26312
|
-
}
|
|
26313
|
-
if (this.controlBelongsToSubtree(this.gui.mouseOver, control)) {
|
|
26314
|
-
this.dropMouseOver();
|
|
26315
|
-
}
|
|
26316
|
-
if (this.controlBelongsToSubtree(this.gui.dragMouseOver, control)) {
|
|
26317
|
-
this.gui.dragMouseOver = null;
|
|
26318
|
-
}
|
|
26319
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(this.gui.touchFocus), _step; !(_step = _iterator()).done;){
|
|
26320
|
-
var _step_value = _step.value, index = _step_value[0], target = _step_value[1];
|
|
26321
|
-
if (this.controlBelongsToSubtree(target, control)) {
|
|
26322
|
-
this.gui.touchFocus.delete(index);
|
|
26323
|
-
}
|
|
26324
|
-
}
|
|
26325
|
-
};
|
|
26326
|
-
_proto.requestMouseOverUpdate = function requestMouseOverUpdate() {
|
|
26327
|
-
if (Number.isFinite(this.gui.lastMousePosition.x)) {
|
|
26328
|
-
this.updateMouseOver(this.gui.lastMousePosition);
|
|
26329
|
-
}
|
|
26330
|
-
};
|
|
26331
|
-
_proto.getGlobalInverse = function getGlobalInverse(control) {
|
|
26332
|
-
var transform = control.getGlobalTransform2D().clone();
|
|
26333
|
-
return Math.abs(transform.determinant()) < 1e-12 ? new Matrix3() : transform.invert();
|
|
26334
|
-
};
|
|
26335
|
-
_proto.toLocal = function toLocal(control, position) {
|
|
26336
|
-
var elements = this.getGlobalInverse(control).elements;
|
|
26337
|
-
return new Vector2(elements[0] * position.x + elements[3] * position.y + elements[6], elements[1] * position.x + elements[4] * position.y + elements[7]);
|
|
26338
|
-
};
|
|
26339
|
-
_proto.controlBelongsToSubtree = function controlBelongsToSubtree(control, subtree) {
|
|
26340
|
-
var current = control;
|
|
26341
|
-
while(current){
|
|
26342
|
-
if (current === subtree) {
|
|
26343
|
-
return true;
|
|
26344
|
-
}
|
|
26345
|
-
current = current.parent;
|
|
26346
|
-
}
|
|
26347
|
-
return false;
|
|
26348
|
-
};
|
|
26349
|
-
_proto.isControlValid = function isControlValid(control) {
|
|
26350
|
-
return !!control && !control.isDisposed && control.root === this;
|
|
26351
|
-
};
|
|
26352
|
-
_proto.isControlUsable = function isControlUsable(control) {
|
|
26353
|
-
if (!this.isControlValid(control) || !control.visibleInHierarchy || !control.enabledInHierarchy) {
|
|
26354
|
-
return false;
|
|
26355
|
-
}
|
|
26356
|
-
var root = this.findCanvasRoot(control);
|
|
26357
|
-
return !root || !root.inputDisabled;
|
|
26358
|
-
};
|
|
26359
|
-
_proto.findCanvasRoot = function findCanvasRoot(control) {
|
|
26360
|
-
var current = control;
|
|
26361
|
-
while(current && current !== this){
|
|
26362
|
-
if (_instanceof1(current, CanvasRootControl)) {
|
|
26363
|
-
return current;
|
|
26364
|
-
}
|
|
26365
|
-
current = current.parent;
|
|
26366
|
-
}
|
|
26367
|
-
return null;
|
|
26368
|
-
};
|
|
26369
|
-
_proto.isFocusTargetUsable = function isFocusTargetUsable(control) {
|
|
26370
|
-
return this.isControlUsable(control) && control.getFocusModeWithOverride() !== exports.FocusMode.None;
|
|
26371
|
-
};
|
|
26372
|
-
return WindowRootControl;
|
|
26373
|
-
}(RootControl);
|
|
26374
|
-
|
|
26375
|
-
exports.CanvasRenderMode = void 0;
|
|
26376
|
-
(function(CanvasRenderMode) {
|
|
26377
|
-
CanvasRenderMode[CanvasRenderMode["ScreenSpace"] = 0] = "ScreenSpace";
|
|
26378
|
-
CanvasRenderMode[CanvasRenderMode["CameraSpace"] = 1] = "CameraSpace";
|
|
26379
|
-
CanvasRenderMode[CanvasRenderMode["WorldSpace"] = 2] = "WorldSpace";
|
|
26380
|
-
CanvasRenderMode[CanvasRenderMode["WorldSpaceFaceCamera"] = 3] = "WorldSpaceFaceCamera";
|
|
26381
|
-
})(exports.CanvasRenderMode || (exports.CanvasRenderMode = {}));
|
|
26382
|
-
/** Canvas-layer boundary attached to a VFXItem. Input state remains owned by the window root. */ var UICanvas = /*#__PURE__*/ function(Component) {
|
|
26383
|
-
_inherits(UICanvas, Component);
|
|
26384
|
-
function UICanvas(engine) {
|
|
26385
|
-
var _this;
|
|
26386
|
-
_this = Component.call(this, engine) || this;
|
|
26387
|
-
_this.renderMode = 0;
|
|
26388
|
-
_this.receivesEvents = true;
|
|
26389
|
-
_this._order = 0;
|
|
26390
|
-
_this.registered = false;
|
|
26391
|
-
_this.rootControl = new CanvasRootControl(engine, _assert_this_initialized(_this));
|
|
26392
|
-
return _this;
|
|
26393
|
-
}
|
|
26394
|
-
var _proto = UICanvas.prototype;
|
|
26395
|
-
_proto.onEnable = function onEnable() {
|
|
26396
|
-
this.register();
|
|
26397
|
-
};
|
|
26398
|
-
_proto.onDisable = function onDisable() {
|
|
26399
|
-
this.unregister();
|
|
26400
|
-
};
|
|
26401
|
-
_proto.onDestroy = function onDestroy() {
|
|
26402
|
-
this.destroyCanvas();
|
|
26403
|
-
};
|
|
26404
|
-
_proto.dispose = function dispose() {
|
|
26405
|
-
this.destroyCanvas();
|
|
26406
|
-
Component.prototype.dispose.call(this);
|
|
26407
|
-
};
|
|
26408
|
-
_proto.register = function register() {
|
|
26409
|
-
if (!this.registered) {
|
|
26410
|
-
this.rootControl.parent = this.engine.windowRoot.canvases;
|
|
26411
|
-
this.registered = true;
|
|
26412
|
-
}
|
|
26413
|
-
};
|
|
26414
|
-
_proto.unregister = function unregister() {
|
|
26415
|
-
if (this.registered) {
|
|
26416
|
-
this.rootControl.parent = null;
|
|
26417
|
-
this.registered = false;
|
|
26418
|
-
}
|
|
26419
|
-
};
|
|
26420
|
-
_proto.destroyCanvas = function destroyCanvas() {
|
|
26421
|
-
this.unregister();
|
|
26422
|
-
if (!this.rootControl.isDisposed) {
|
|
26423
|
-
this.rootControl.dispose();
|
|
26424
|
-
}
|
|
26425
|
-
};
|
|
26426
|
-
_create_class(UICanvas, [
|
|
26427
|
-
{
|
|
26428
|
-
key: "order",
|
|
26429
|
-
get: function get() {
|
|
26430
|
-
return this._order;
|
|
26431
|
-
},
|
|
26432
|
-
set: function set(value) {
|
|
26433
|
-
if (this._order !== value) {
|
|
26434
|
-
this._order = value;
|
|
26435
|
-
this.engine.windowRoot.canvases.sortCanvases();
|
|
26436
|
-
}
|
|
26437
|
-
}
|
|
26438
|
-
},
|
|
26439
|
-
{
|
|
26440
|
-
key: "isVisible",
|
|
26441
|
-
get: function get() {
|
|
26442
|
-
var _this_item;
|
|
26443
|
-
return this.renderMode === 0 && this.enabled && !!((_this_item = this.item) == null ? void 0 : _this_item.isActive);
|
|
26444
|
-
}
|
|
26445
|
-
}
|
|
26446
|
-
]);
|
|
26447
|
-
return UICanvas;
|
|
26448
|
-
}(Component);
|
|
26449
|
-
|
|
26450
|
-
/**
|
|
26451
|
-
* Scene-tree bridge for a GUI Control. The VFXItem tree owns lifecycle and
|
|
26452
|
-
* serialization while the Control tree owns layout, drawing and input.
|
|
26453
|
-
*/ var UIControl = /*#__PURE__*/ function(Component) {
|
|
26454
|
-
_inherits(UIControl, Component);
|
|
26455
|
-
function UIControl(engine) {
|
|
26456
|
-
var _this;
|
|
26457
|
-
_this = Component.call(this, engine) || this;
|
|
26458
|
-
_this.controlNode = null;
|
|
26459
|
-
_this.linkedItemTransform = null;
|
|
26460
|
-
_this.linkedControl = null;
|
|
26461
|
-
_this.syncingLocation = false;
|
|
26462
|
-
_this.itemTransformChanged = function() {
|
|
26463
|
-
return _this.syncItemLocationToControl();
|
|
26464
|
-
};
|
|
26465
|
-
_this.controlLocationChanged = function() {
|
|
26466
|
-
return _this.syncControlLocationToItem();
|
|
26467
|
-
};
|
|
26468
|
-
return _this;
|
|
26469
|
-
}
|
|
26470
|
-
var _proto = UIControl.prototype;
|
|
26471
|
-
_proto.onAwake = function onAwake() {
|
|
26472
|
-
this.syncControl();
|
|
26473
|
-
};
|
|
26474
|
-
_proto.onEnable = function onEnable() {
|
|
26475
|
-
if (this.controlNode) {
|
|
26476
|
-
this.controlNode.visible = this.item.isActive;
|
|
26477
|
-
this.controlNode.enabled = true;
|
|
26478
|
-
}
|
|
26479
|
-
};
|
|
26480
|
-
_proto.onDisable = function onDisable() {
|
|
26481
|
-
if (this.controlNode) {
|
|
26482
|
-
this.controlNode.visible = this.item.isActive;
|
|
26483
|
-
this.controlNode.enabled = false;
|
|
26484
|
-
}
|
|
26485
|
-
};
|
|
26486
|
-
_proto.onParentChanged = function onParentChanged() {
|
|
26487
|
-
this.syncControl();
|
|
26488
|
-
};
|
|
26489
|
-
_proto.onOrderInParentChanged = function onOrderInParentChanged() {
|
|
26490
|
-
this.syncControlOrder();
|
|
26491
|
-
};
|
|
26492
|
-
_proto.onDestroy = function onDestroy() {
|
|
26493
|
-
this.disposeControl();
|
|
26494
|
-
};
|
|
26495
|
-
_proto.dispose = function dispose() {
|
|
26496
|
-
this.disposeControl();
|
|
26497
|
-
Component.prototype.dispose.call(this);
|
|
26498
|
-
};
|
|
26499
|
-
/** Unlinks the GUI object without disposing or modifying it. */ _proto.unlinkControl = function unlinkControl() {
|
|
26500
|
-
if (this.controlNode) {
|
|
26501
|
-
this.unbindLocationSync();
|
|
26502
|
-
this.controlNode = null;
|
|
26503
|
-
}
|
|
26504
|
-
};
|
|
26505
|
-
_proto.disposeControl = function disposeControl() {
|
|
26506
|
-
var control = this.controlNode;
|
|
26507
|
-
if (control) {
|
|
26508
|
-
this.unbindLocationSync();
|
|
26509
|
-
this.controlNode = null;
|
|
26510
|
-
control.dispose();
|
|
26511
|
-
}
|
|
26512
|
-
};
|
|
26513
|
-
_proto.syncControl = function syncControl() {
|
|
26514
|
-
var control = this.controlNode;
|
|
26515
|
-
if (!control || !this.item) {
|
|
26516
|
-
return;
|
|
26517
|
-
}
|
|
26518
|
-
this.syncingLocation = true;
|
|
26519
|
-
try {
|
|
26520
|
-
control.visible = this.item.isActive;
|
|
26521
|
-
control.enabled = this.enabled;
|
|
26522
|
-
control.parent = this.resolveParent();
|
|
26523
|
-
this.syncControlOrder();
|
|
26524
|
-
this.copyItemLocationToControl();
|
|
26525
|
-
} finally{
|
|
26526
|
-
this.syncingLocation = false;
|
|
26527
|
-
}
|
|
26528
|
-
this.bindLocationSync();
|
|
26529
|
-
};
|
|
26530
|
-
_proto.syncControlOrder = function syncControlOrder() {
|
|
26531
|
-
if (this.controlNode && this.item) {
|
|
26532
|
-
this.controlNode.indexInParent = this.item.orderInParent;
|
|
26533
|
-
}
|
|
26534
|
-
};
|
|
26535
|
-
_proto.resolveParent = function resolveParent() {
|
|
26536
|
-
var parentItem = this.item.parent;
|
|
26537
|
-
if (!parentItem) {
|
|
26538
|
-
var _UIControl_fallbackParentGetDelegate;
|
|
26539
|
-
return (_UIControl_fallbackParentGetDelegate = UIControl.fallbackParentGetDelegate == null ? void 0 : UIControl.fallbackParentGetDelegate.call(UIControl, this)) != null ? _UIControl_fallbackParentGetDelegate : null;
|
|
26540
|
-
}
|
|
26541
|
-
var uiControl = parentItem.getComponent(UIControl);
|
|
26542
|
-
if ((uiControl == null ? void 0 : uiControl.control) && "children" in uiControl.control) {
|
|
26543
|
-
return uiControl.control;
|
|
26544
|
-
}
|
|
26545
|
-
var canvas = parentItem.getComponent(UICanvas);
|
|
26546
|
-
var _canvas_rootControl, _ref;
|
|
26547
|
-
return (_ref = (_canvas_rootControl = canvas == null ? void 0 : canvas.rootControl) != null ? _canvas_rootControl : UIControl.fallbackParentGetDelegate == null ? void 0 : UIControl.fallbackParentGetDelegate.call(UIControl, this)) != null ? _ref : null;
|
|
26548
|
-
};
|
|
26549
|
-
_proto.bindLocationSync = function bindLocationSync() {
|
|
26550
|
-
var itemTransform = this.item.transform;
|
|
26551
|
-
var control = this.controlNode;
|
|
26552
|
-
if (this.linkedItemTransform === itemTransform && this.linkedControl === control) {
|
|
26553
|
-
return;
|
|
26554
|
-
}
|
|
26555
|
-
this.unbindLocationSync();
|
|
26556
|
-
if (control) {
|
|
26557
|
-
this.linkedItemTransform = itemTransform;
|
|
26558
|
-
this.linkedControl = control;
|
|
26559
|
-
itemTransform.on("changed", this.itemTransformChanged);
|
|
26560
|
-
control.on("locationChanged", this.controlLocationChanged);
|
|
26561
|
-
}
|
|
26562
|
-
};
|
|
26563
|
-
_proto.unbindLocationSync = function unbindLocationSync() {
|
|
26564
|
-
var _this_linkedItemTransform, _this_linkedControl;
|
|
26565
|
-
(_this_linkedItemTransform = this.linkedItemTransform) == null ? void 0 : _this_linkedItemTransform.off("changed", this.itemTransformChanged);
|
|
26566
|
-
(_this_linkedControl = this.linkedControl) == null ? void 0 : _this_linkedControl.off("locationChanged", this.controlLocationChanged);
|
|
26567
|
-
this.linkedItemTransform = null;
|
|
26568
|
-
this.linkedControl = null;
|
|
26569
|
-
};
|
|
26570
|
-
_proto.syncItemLocationToControl = function syncItemLocationToControl() {
|
|
26571
|
-
if (!this.syncingLocation && this.controlNode) {
|
|
26572
|
-
this.syncingLocation = true;
|
|
26573
|
-
try {
|
|
26574
|
-
this.copyItemLocationToControl();
|
|
26575
|
-
} finally{
|
|
26576
|
-
this.syncingLocation = false;
|
|
26577
|
-
}
|
|
26578
|
-
}
|
|
26579
|
-
};
|
|
26580
|
-
_proto.syncControlLocationToItem = function syncControlLocationToItem() {
|
|
26581
|
-
var control = this.controlNode;
|
|
26582
|
-
if (!this.syncingLocation && control) {
|
|
26583
|
-
var source = control.location;
|
|
26584
|
-
var target = this.item.transform.position;
|
|
26585
|
-
if (source.x !== target.x || source.y !== target.y) {
|
|
26586
|
-
this.syncingLocation = true;
|
|
26587
|
-
try {
|
|
26588
|
-
this.item.transform.setPosition(source.x, source.y, target.z);
|
|
26589
|
-
} finally{
|
|
26590
|
-
this.syncingLocation = false;
|
|
26591
|
-
}
|
|
26592
|
-
}
|
|
26593
|
-
}
|
|
26594
|
-
};
|
|
26595
|
-
_proto.copyItemLocationToControl = function copyItemLocationToControl() {
|
|
26596
|
-
var control = this.controlNode;
|
|
26597
|
-
if (control) {
|
|
26598
|
-
var source = this.item.transform.position;
|
|
26599
|
-
var target = control.location;
|
|
26600
|
-
if (source.x !== target.x || source.y !== target.y) {
|
|
26601
|
-
control.setPosition(source.x, source.y);
|
|
26602
|
-
}
|
|
26603
|
-
}
|
|
26604
|
-
};
|
|
26605
|
-
_create_class(UIControl, [
|
|
26606
|
-
{
|
|
26607
|
-
key: "control",
|
|
26608
|
-
get: function get() {
|
|
26609
|
-
return this.controlNode;
|
|
26610
|
-
},
|
|
26611
|
-
set: function set(value) {
|
|
26612
|
-
if (value === this.controlNode) {
|
|
26613
|
-
return;
|
|
26614
|
-
}
|
|
26615
|
-
this.disposeControl();
|
|
26616
|
-
if (value) {
|
|
26617
|
-
if (value.owner && value.owner !== this && value.owner.control === value) {
|
|
26618
|
-
throw new Error("A Control can only be owned by one UIControl.");
|
|
26619
|
-
}
|
|
26620
|
-
this.controlNode = value;
|
|
26621
|
-
value.owner = this;
|
|
26622
|
-
this.syncControl();
|
|
26623
|
-
}
|
|
26624
|
-
}
|
|
26625
|
-
},
|
|
26626
|
-
{
|
|
26627
|
-
key: "hasControl",
|
|
26628
|
-
get: function get() {
|
|
26629
|
-
return this.controlNode !== null;
|
|
26630
|
-
}
|
|
26631
|
-
}
|
|
26632
|
-
]);
|
|
26633
|
-
return UIControl;
|
|
26634
|
-
}(Component);
|
|
26635
|
-
|
|
26636
24779
|
exports.CameraController = /*#__PURE__*/ function(Component) {
|
|
26637
24780
|
_inherits(CameraController, Component);
|
|
26638
24781
|
function CameraController(engine, props) {
|
|
@@ -26667,6 +24810,42 @@ exports.CameraController = __decorate([
|
|
|
26667
24810
|
effectsClass(DataType.CameraController)
|
|
26668
24811
|
], exports.CameraController);
|
|
26669
24812
|
|
|
24813
|
+
function _get_prototype_of(o) {
|
|
24814
|
+
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
24815
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
24816
|
+
};
|
|
24817
|
+
return _get_prototype_of(o);
|
|
24818
|
+
}
|
|
24819
|
+
|
|
24820
|
+
function _is_native_function(fn) {
|
|
24821
|
+
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
24822
|
+
}
|
|
24823
|
+
|
|
24824
|
+
function _wrap_native_super(Class) {
|
|
24825
|
+
var _cache = typeof Map === "function" ? new Map() : undefined;
|
|
24826
|
+
_wrap_native_super = function _wrap_native_super(Class) {
|
|
24827
|
+
if (Class === null || !_is_native_function(Class)) return Class;
|
|
24828
|
+
if (typeof Class !== "function") throw new TypeError("Super expression must either be null or a function");
|
|
24829
|
+
if (typeof _cache !== "undefined") {
|
|
24830
|
+
if (_cache.has(Class)) return _cache.get(Class);
|
|
24831
|
+
_cache.set(Class, Wrapper);
|
|
24832
|
+
}
|
|
24833
|
+
function Wrapper() {
|
|
24834
|
+
return _construct(Class, arguments, _get_prototype_of(this).constructor);
|
|
24835
|
+
}
|
|
24836
|
+
Wrapper.prototype = Object.create(Class.prototype, {
|
|
24837
|
+
constructor: {
|
|
24838
|
+
value: Wrapper,
|
|
24839
|
+
enumerable: false,
|
|
24840
|
+
writable: true,
|
|
24841
|
+
configurable: true
|
|
24842
|
+
}
|
|
24843
|
+
});
|
|
24844
|
+
return _set_prototype_of(Wrapper, Class);
|
|
24845
|
+
};
|
|
24846
|
+
return _wrap_native_super(Class);
|
|
24847
|
+
}
|
|
24848
|
+
|
|
26670
24849
|
var CameraVFXItemLoader = /*#__PURE__*/ function(Plugin) {
|
|
26671
24850
|
_inherits(CameraVFXItemLoader, Plugin);
|
|
26672
24851
|
function CameraVFXItemLoader() {
|
|
@@ -26675,6 +24854,255 @@ var CameraVFXItemLoader = /*#__PURE__*/ function(Plugin) {
|
|
|
26675
24854
|
return CameraVFXItemLoader;
|
|
26676
24855
|
}(_wrap_native_super(Plugin));
|
|
26677
24856
|
|
|
24857
|
+
exports.MouseButton = void 0;
|
|
24858
|
+
(function(MouseButton) {
|
|
24859
|
+
MouseButton[MouseButton["None"] = 0] = "None";
|
|
24860
|
+
MouseButton[MouseButton["Left"] = 1] = "Left";
|
|
24861
|
+
MouseButton[MouseButton["Right"] = 2] = "Right";
|
|
24862
|
+
MouseButton[MouseButton["Middle"] = 3] = "Middle";
|
|
24863
|
+
MouseButton[MouseButton["WheelUp"] = 4] = "WheelUp";
|
|
24864
|
+
MouseButton[MouseButton["WheelDown"] = 5] = "WheelDown";
|
|
24865
|
+
MouseButton[MouseButton["WheelLeft"] = 6] = "WheelLeft";
|
|
24866
|
+
MouseButton[MouseButton["WheelRight"] = 7] = "WheelRight";
|
|
24867
|
+
MouseButton[MouseButton["Xbutton1"] = 8] = "Xbutton1";
|
|
24868
|
+
MouseButton[MouseButton["Xbutton2"] = 9] = "Xbutton2";
|
|
24869
|
+
})(exports.MouseButton || (exports.MouseButton = {}));
|
|
24870
|
+
exports.MouseButtonMask = void 0;
|
|
24871
|
+
(function(MouseButtonMask) {
|
|
24872
|
+
MouseButtonMask[MouseButtonMask["None"] = 0] = "None";
|
|
24873
|
+
MouseButtonMask[MouseButtonMask["Left"] = 1] = "Left";
|
|
24874
|
+
MouseButtonMask[MouseButtonMask["Right"] = 2] = "Right";
|
|
24875
|
+
MouseButtonMask[MouseButtonMask["Middle"] = 4] = "Middle";
|
|
24876
|
+
MouseButtonMask[MouseButtonMask["Xbutton1"] = 128] = "Xbutton1";
|
|
24877
|
+
MouseButtonMask[MouseButtonMask["Xbutton2"] = 256] = "Xbutton2";
|
|
24878
|
+
})(exports.MouseButtonMask || (exports.MouseButtonMask = {}));
|
|
24879
|
+
exports.KeyLocation = void 0;
|
|
24880
|
+
(function(KeyLocation) {
|
|
24881
|
+
KeyLocation[KeyLocation["Unspecified"] = 0] = "Unspecified";
|
|
24882
|
+
KeyLocation[KeyLocation["Left"] = 1] = "Left";
|
|
24883
|
+
KeyLocation[KeyLocation["Right"] = 2] = "Right";
|
|
24884
|
+
})(exports.KeyLocation || (exports.KeyLocation = {}));
|
|
24885
|
+
|
|
24886
|
+
function transformPoint(transform, value) {
|
|
24887
|
+
var elements = transform.elements;
|
|
24888
|
+
return new Vector2(elements[0] * value.x + elements[3] * value.y + elements[6], elements[1] * value.x + elements[4] * value.y + elements[7]);
|
|
24889
|
+
}
|
|
24890
|
+
function transformVector(transform, value) {
|
|
24891
|
+
var elements = transform.elements;
|
|
24892
|
+
return new Vector2(elements[0] * value.x + elements[3] * value.y, elements[1] * value.x + elements[4] * value.y);
|
|
24893
|
+
}
|
|
24894
|
+
var InputEvent = /*#__PURE__*/ function() {
|
|
24895
|
+
function InputEvent() {
|
|
24896
|
+
this.device = 0;
|
|
24897
|
+
this.pressed = false;
|
|
24898
|
+
this.canceled = false;
|
|
24899
|
+
this._accepted = false;
|
|
24900
|
+
}
|
|
24901
|
+
var _proto = InputEvent.prototype;
|
|
24902
|
+
_proto.accept = function accept() {
|
|
24903
|
+
this._accepted = true;
|
|
24904
|
+
};
|
|
24905
|
+
_proto.clearAccepted = function clearAccepted() {
|
|
24906
|
+
this._accepted = false;
|
|
24907
|
+
};
|
|
24908
|
+
_proto.isAccepted = function isAccepted() {
|
|
24909
|
+
return this._accepted;
|
|
24910
|
+
};
|
|
24911
|
+
_proto.isPressed = function isPressed() {
|
|
24912
|
+
return this.pressed && !this.canceled;
|
|
24913
|
+
};
|
|
24914
|
+
_proto.isReleased = function isReleased() {
|
|
24915
|
+
return !this.pressed && !this.canceled;
|
|
24916
|
+
};
|
|
24917
|
+
_proto.isCanceled = function isCanceled() {
|
|
24918
|
+
return this.canceled;
|
|
24919
|
+
};
|
|
24920
|
+
_proto.isEcho = function isEcho() {
|
|
24921
|
+
return false;
|
|
24922
|
+
};
|
|
24923
|
+
_proto.xformedBy = function xformedBy(transform) {
|
|
24924
|
+
return this;
|
|
24925
|
+
};
|
|
24926
|
+
return InputEvent;
|
|
24927
|
+
}();
|
|
24928
|
+
InputEvent.deviceIdEmulation = -1;
|
|
24929
|
+
InputEvent.deviceIdInternal = -2;
|
|
24930
|
+
InputEvent.deviceIdKeyboard = 16;
|
|
24931
|
+
InputEvent.deviceIdMouse = 32;
|
|
24932
|
+
var InputEventWithModifiers = /*#__PURE__*/ function(InputEvent) {
|
|
24933
|
+
_inherits(InputEventWithModifiers, InputEvent);
|
|
24934
|
+
function InputEventWithModifiers() {
|
|
24935
|
+
var _this;
|
|
24936
|
+
_this = InputEvent.apply(this, arguments) || this;
|
|
24937
|
+
_this.commandOrControlAutoremap = false;
|
|
24938
|
+
_this.shiftPressed = false;
|
|
24939
|
+
_this.altPressed = false;
|
|
24940
|
+
_this.metaPressed = false;
|
|
24941
|
+
_this.ctrlPressed = false;
|
|
24942
|
+
return _this;
|
|
24943
|
+
}
|
|
24944
|
+
var _proto = InputEventWithModifiers.prototype;
|
|
24945
|
+
_proto.copyModifiersTo = function copyModifiersTo(event) {
|
|
24946
|
+
event.device = this.device;
|
|
24947
|
+
event.pressed = this.pressed;
|
|
24948
|
+
event.canceled = this.canceled;
|
|
24949
|
+
event.commandOrControlAutoremap = this.commandOrControlAutoremap;
|
|
24950
|
+
event.shiftPressed = this.shiftPressed;
|
|
24951
|
+
event.altPressed = this.altPressed;
|
|
24952
|
+
event.metaPressed = this.metaPressed;
|
|
24953
|
+
event.ctrlPressed = this.ctrlPressed;
|
|
24954
|
+
};
|
|
24955
|
+
return InputEventWithModifiers;
|
|
24956
|
+
}(_wrap_native_super(InputEvent));
|
|
24957
|
+
var InputEventKey = /*#__PURE__*/ function(InputEventWithModifiers) {
|
|
24958
|
+
_inherits(InputEventKey, InputEventWithModifiers);
|
|
24959
|
+
function InputEventKey() {
|
|
24960
|
+
var _this;
|
|
24961
|
+
_this = InputEventWithModifiers.apply(this, arguments) || this;
|
|
24962
|
+
_this.keycode = "";
|
|
24963
|
+
_this.physicalKeycode = "";
|
|
24964
|
+
_this.keyLabel = "";
|
|
24965
|
+
_this.unicode = 0;
|
|
24966
|
+
_this.location = exports.KeyLocation.Unspecified;
|
|
24967
|
+
_this.echo = false;
|
|
24968
|
+
return _this;
|
|
24969
|
+
}
|
|
24970
|
+
var _proto = InputEventKey.prototype;
|
|
24971
|
+
_proto.isEcho = function isEcho() {
|
|
24972
|
+
return this.echo;
|
|
24973
|
+
};
|
|
24974
|
+
return InputEventKey;
|
|
24975
|
+
}(InputEventWithModifiers);
|
|
24976
|
+
var InputEventMouse = /*#__PURE__*/ function(InputEventWithModifiers) {
|
|
24977
|
+
_inherits(InputEventMouse, InputEventWithModifiers);
|
|
24978
|
+
function InputEventMouse() {
|
|
24979
|
+
var _this;
|
|
24980
|
+
_this = InputEventWithModifiers.apply(this, arguments) || this;
|
|
24981
|
+
_this.buttonMask = exports.MouseButtonMask.None;
|
|
24982
|
+
_this.position = new Vector2();
|
|
24983
|
+
_this.globalPosition = new Vector2();
|
|
24984
|
+
return _this;
|
|
24985
|
+
}
|
|
24986
|
+
var _proto = InputEventMouse.prototype;
|
|
24987
|
+
_proto.copyMouseTo = function copyMouseTo(event) {
|
|
24988
|
+
this.copyModifiersTo(event);
|
|
24989
|
+
event.buttonMask = this.buttonMask;
|
|
24990
|
+
event.position.copyFrom(this.position);
|
|
24991
|
+
event.globalPosition.copyFrom(this.globalPosition);
|
|
24992
|
+
};
|
|
24993
|
+
return InputEventMouse;
|
|
24994
|
+
}(InputEventWithModifiers);
|
|
24995
|
+
var InputEventMouseButton = /*#__PURE__*/ function(InputEventMouse) {
|
|
24996
|
+
_inherits(InputEventMouseButton, InputEventMouse);
|
|
24997
|
+
function InputEventMouseButton() {
|
|
24998
|
+
var _this;
|
|
24999
|
+
_this = InputEventMouse.apply(this, arguments) || this;
|
|
25000
|
+
_this.factor = 1;
|
|
25001
|
+
_this.buttonIndex = exports.MouseButton.None;
|
|
25002
|
+
_this.doubleClick = false;
|
|
25003
|
+
return _this;
|
|
25004
|
+
}
|
|
25005
|
+
var _proto = InputEventMouseButton.prototype;
|
|
25006
|
+
_proto.xformedBy = function xformedBy(transform) {
|
|
25007
|
+
var event = new InputEventMouseButton();
|
|
25008
|
+
this.copyMouseTo(event);
|
|
25009
|
+
event.position.copyFrom(transformPoint(transform, this.position));
|
|
25010
|
+
event.factor = this.factor;
|
|
25011
|
+
event.buttonIndex = this.buttonIndex;
|
|
25012
|
+
event.doubleClick = this.doubleClick;
|
|
25013
|
+
return event;
|
|
25014
|
+
};
|
|
25015
|
+
return InputEventMouseButton;
|
|
25016
|
+
}(InputEventMouse);
|
|
25017
|
+
var InputEventMouseMotion = /*#__PURE__*/ function(InputEventMouse) {
|
|
25018
|
+
_inherits(InputEventMouseMotion, InputEventMouse);
|
|
25019
|
+
function InputEventMouseMotion() {
|
|
25020
|
+
var _this;
|
|
25021
|
+
_this = InputEventMouse.apply(this, arguments) || this;
|
|
25022
|
+
_this.tilt = new Vector2();
|
|
25023
|
+
_this.pressure = 0;
|
|
25024
|
+
_this.relative = new Vector2();
|
|
25025
|
+
_this.screenRelative = new Vector2();
|
|
25026
|
+
_this.velocity = new Vector2();
|
|
25027
|
+
_this.screenVelocity = new Vector2();
|
|
25028
|
+
_this.penInverted = false;
|
|
25029
|
+
return _this;
|
|
25030
|
+
}
|
|
25031
|
+
var _proto = InputEventMouseMotion.prototype;
|
|
25032
|
+
_proto.xformedBy = function xformedBy(transform) {
|
|
25033
|
+
var event = new InputEventMouseMotion();
|
|
25034
|
+
this.copyMouseTo(event);
|
|
25035
|
+
event.position.copyFrom(transformPoint(transform, this.position));
|
|
25036
|
+
event.tilt.copyFrom(this.tilt);
|
|
25037
|
+
event.pressure = this.pressure;
|
|
25038
|
+
event.relative.copyFrom(transformVector(transform, this.relative));
|
|
25039
|
+
event.screenRelative.copyFrom(this.screenRelative);
|
|
25040
|
+
event.velocity.copyFrom(transformVector(transform, this.velocity));
|
|
25041
|
+
event.screenVelocity.copyFrom(this.screenVelocity);
|
|
25042
|
+
event.penInverted = this.penInverted;
|
|
25043
|
+
return event;
|
|
25044
|
+
};
|
|
25045
|
+
return InputEventMouseMotion;
|
|
25046
|
+
}(InputEventMouse);
|
|
25047
|
+
var InputEventScreenTouch = /*#__PURE__*/ function(InputEvent) {
|
|
25048
|
+
_inherits(InputEventScreenTouch, InputEvent);
|
|
25049
|
+
function InputEventScreenTouch() {
|
|
25050
|
+
var _this;
|
|
25051
|
+
_this = InputEvent.apply(this, arguments) || this;
|
|
25052
|
+
_this.index = 0;
|
|
25053
|
+
_this.position = new Vector2();
|
|
25054
|
+
_this.doubleTap = false;
|
|
25055
|
+
return _this;
|
|
25056
|
+
}
|
|
25057
|
+
var _proto = InputEventScreenTouch.prototype;
|
|
25058
|
+
_proto.xformedBy = function xformedBy(transform) {
|
|
25059
|
+
var event = new InputEventScreenTouch();
|
|
25060
|
+
event.device = this.device;
|
|
25061
|
+
event.pressed = this.pressed;
|
|
25062
|
+
event.canceled = this.canceled;
|
|
25063
|
+
event.index = this.index;
|
|
25064
|
+
event.position.copyFrom(transformPoint(transform, this.position));
|
|
25065
|
+
event.doubleTap = this.doubleTap;
|
|
25066
|
+
return event;
|
|
25067
|
+
};
|
|
25068
|
+
return InputEventScreenTouch;
|
|
25069
|
+
}(_wrap_native_super(InputEvent));
|
|
25070
|
+
var InputEventScreenDrag = /*#__PURE__*/ function(InputEvent) {
|
|
25071
|
+
_inherits(InputEventScreenDrag, InputEvent);
|
|
25072
|
+
function InputEventScreenDrag() {
|
|
25073
|
+
var _this;
|
|
25074
|
+
_this = InputEvent.apply(this, arguments) || this;
|
|
25075
|
+
_this.index = 0;
|
|
25076
|
+
_this.position = new Vector2();
|
|
25077
|
+
_this.relative = new Vector2();
|
|
25078
|
+
_this.screenRelative = new Vector2();
|
|
25079
|
+
_this.velocity = new Vector2();
|
|
25080
|
+
_this.screenVelocity = new Vector2();
|
|
25081
|
+
_this.pressure = 0;
|
|
25082
|
+
_this.tilt = new Vector2();
|
|
25083
|
+
_this.penInverted = false;
|
|
25084
|
+
return _this;
|
|
25085
|
+
}
|
|
25086
|
+
var _proto = InputEventScreenDrag.prototype;
|
|
25087
|
+
_proto.xformedBy = function xformedBy(transform) {
|
|
25088
|
+
var event = new InputEventScreenDrag();
|
|
25089
|
+
event.device = this.device;
|
|
25090
|
+
event.pressed = this.pressed;
|
|
25091
|
+
event.canceled = this.canceled;
|
|
25092
|
+
event.index = this.index;
|
|
25093
|
+
event.position.copyFrom(transformPoint(transform, this.position));
|
|
25094
|
+
event.relative.copyFrom(transformVector(transform, this.relative));
|
|
25095
|
+
event.screenRelative.copyFrom(this.screenRelative);
|
|
25096
|
+
event.velocity.copyFrom(transformVector(transform, this.velocity));
|
|
25097
|
+
event.screenVelocity.copyFrom(this.screenVelocity);
|
|
25098
|
+
event.pressure = this.pressure;
|
|
25099
|
+
event.tilt.copyFrom(this.tilt);
|
|
25100
|
+
event.penInverted = this.penInverted;
|
|
25101
|
+
return event;
|
|
25102
|
+
};
|
|
25103
|
+
return InputEventScreenDrag;
|
|
25104
|
+
}(_wrap_native_super(InputEvent));
|
|
25105
|
+
|
|
26678
25106
|
var EVENT_TYPE_CLICK = "click";
|
|
26679
25107
|
var EVENT_TYPE_TOUCH_START = "touchstart";
|
|
26680
25108
|
var EVENT_TYPE_TOUCH_MOVE = "touchmove";
|
|
@@ -26685,49 +25113,52 @@ exports.PointerEventType = void 0;
|
|
|
26685
25113
|
PointerEventType[PointerEventType["PointerUp"] = 1] = "PointerUp";
|
|
26686
25114
|
PointerEventType[PointerEventType["PointerMove"] = 2] = "PointerMove";
|
|
26687
25115
|
})(exports.PointerEventType || (exports.PointerEventType = {}));
|
|
26688
|
-
var EventSystem = /*#__PURE__*/ function() {
|
|
25116
|
+
var EventSystem = /*#__PURE__*/ function(EventEmitter) {
|
|
25117
|
+
_inherits(EventSystem, EventEmitter);
|
|
26689
25118
|
function EventSystem(engine, allowPropagation) {
|
|
26690
|
-
var _this = this;
|
|
26691
25119
|
if (allowPropagation === void 0) allowPropagation = false;
|
|
26692
|
-
|
|
26693
|
-
|
|
26694
|
-
|
|
26695
|
-
|
|
26696
|
-
|
|
26697
|
-
|
|
26698
|
-
|
|
26699
|
-
|
|
26700
|
-
|
|
26701
|
-
|
|
26702
|
-
|
|
26703
|
-
|
|
26704
|
-
|
|
26705
|
-
|
|
26706
|
-
|
|
26707
|
-
|
|
25120
|
+
var _this;
|
|
25121
|
+
_this = EventEmitter.call(this) || this;
|
|
25122
|
+
_this.engine = engine;
|
|
25123
|
+
_this.allowPropagation = allowPropagation;
|
|
25124
|
+
_this.skipPointerMovePicking = true;
|
|
25125
|
+
_this.emulateMouseFromTouch = true;
|
|
25126
|
+
_this.emulateTouchFromMouse = false;
|
|
25127
|
+
_this._enabled = true;
|
|
25128
|
+
_this.handlers = {};
|
|
25129
|
+
_this.nativeHandlers = [];
|
|
25130
|
+
_this.target = null;
|
|
25131
|
+
_this.mouseState = null;
|
|
25132
|
+
_this.mouseButtonMask = exports.MouseButtonMask.None;
|
|
25133
|
+
_this.touchStates = new Map();
|
|
25134
|
+
_this.mouseFromTouchIndex = null;
|
|
25135
|
+
_this.touchFromMousePressed = false;
|
|
25136
|
+
_this.addedTabIndex = false;
|
|
25137
|
+
_this.addedOutlineStyle = false;
|
|
25138
|
+
_this.onNativeWheel = function(event) {
|
|
26708
25139
|
if (!_this.enabled || !_this.target) {
|
|
26709
25140
|
return;
|
|
26710
25141
|
}
|
|
26711
25142
|
var position = _this.getCanvasPosition(event.clientX, event.clientY);
|
|
26712
25143
|
var handled = false;
|
|
26713
25144
|
if (event.deltaY !== 0) {
|
|
26714
|
-
handled = _this.pushWheelButton(event.deltaY < 0 ? exports.MouseButton.WheelUp : exports.MouseButton.WheelDown,
|
|
25145
|
+
handled = _this.pushWheelButton(event.deltaY < 0 ? exports.MouseButton.WheelUp : exports.MouseButton.WheelDown, normalizeWheelFactor(event.deltaY, event.deltaMode), position, event) || handled;
|
|
26715
25146
|
}
|
|
26716
25147
|
if (event.deltaX !== 0) {
|
|
26717
|
-
handled = _this.pushWheelButton(event.deltaX < 0 ? exports.MouseButton.WheelLeft : exports.MouseButton.WheelRight,
|
|
25148
|
+
handled = _this.pushWheelButton(event.deltaX < 0 ? exports.MouseButton.WheelLeft : exports.MouseButton.WheelRight, normalizeWheelFactor(event.deltaX, event.deltaMode), position, event) || handled;
|
|
26718
25149
|
}
|
|
26719
25150
|
_this.consumeNativeEvent(event, handled);
|
|
26720
25151
|
};
|
|
26721
|
-
|
|
25152
|
+
_this.onNativeKeyDown = function(event) {
|
|
26722
25153
|
_this.handleNativeKey(event, true);
|
|
26723
25154
|
};
|
|
26724
|
-
|
|
25155
|
+
_this.onNativeKeyUp = function(event) {
|
|
26725
25156
|
_this.handleNativeKey(event, false);
|
|
26726
25157
|
};
|
|
26727
|
-
|
|
25158
|
+
_this.onNativeMouseDown = function(event) {
|
|
26728
25159
|
_this.handleNativeMouseDown(event);
|
|
26729
25160
|
};
|
|
26730
|
-
|
|
25161
|
+
_this.onNativeMouseMove = function(event) {
|
|
26731
25162
|
var _state;
|
|
26732
25163
|
if (!_this.enabled || !_this.target) {
|
|
26733
25164
|
return;
|
|
@@ -26739,18 +25170,22 @@ var EventSystem = /*#__PURE__*/ function() {
|
|
|
26739
25170
|
var relative = new Vector2(position.x - state.last.x, position.y - state.last.y);
|
|
26740
25171
|
var velocity = _this.getVelocity(state, position);
|
|
26741
25172
|
var handled = _this.pushNativeMouseMotion(event, position, relative, velocity);
|
|
26742
|
-
(_state = state).
|
|
26743
|
-
if (!handled && (!state.pressed || !state.
|
|
25173
|
+
(_state = state).inputHandled || (_state.inputHandled = handled);
|
|
25174
|
+
if (!handled && (!state.pressed || !state.inputHandled)) {
|
|
26744
25175
|
var pointerEvent = _this.createPointerEvent(event, position, state, velocity);
|
|
26745
25176
|
_this.dispatchEvent(EVENT_TYPE_TOUCH_MOVE, pointerEvent);
|
|
26746
25177
|
}
|
|
26747
25178
|
_this.updatePointerState(state, position);
|
|
26748
25179
|
_this.consumeNativeEvent(event, handled);
|
|
26749
25180
|
};
|
|
26750
|
-
|
|
25181
|
+
_this.onNativeMouseUp = function(event) {
|
|
26751
25182
|
if (!_this.enabled || !_this.target) {
|
|
26752
25183
|
return;
|
|
26753
25184
|
}
|
|
25185
|
+
// Keep the canonical mask in sync even when mouseState already ended on a
|
|
25186
|
+
// previous button release. The target and Window listeners may see the
|
|
25187
|
+
// same mouseup, but clearing a bit twice is intentionally idempotent.
|
|
25188
|
+
_this.setMouseButtonPressed(event.button, false);
|
|
26754
25189
|
var position = _this.getCanvasPosition(event.clientX, event.clientY);
|
|
26755
25190
|
var existingState = _this.mouseState;
|
|
26756
25191
|
if (!(existingState == null ? void 0 : existingState.pressed)) {
|
|
@@ -26759,16 +25194,16 @@ var EventSystem = /*#__PURE__*/ function() {
|
|
|
26759
25194
|
var state = existingState;
|
|
26760
25195
|
var handled = _this.pushNativeMouseButton(event, position, false);
|
|
26761
25196
|
var pointerEvent = _this.createPointerEvent(event, position, state);
|
|
26762
|
-
if (!state.
|
|
25197
|
+
if (!state.inputHandled && !handled && _this.isClick(state, position)) {
|
|
26763
25198
|
_this.dispatchEvent(EVENT_TYPE_CLICK, pointerEvent);
|
|
26764
25199
|
}
|
|
26765
|
-
if (!handled && !state.
|
|
25200
|
+
if (!handled && !state.inputHandled) {
|
|
26766
25201
|
_this.dispatchEvent(EVENT_TYPE_TOUCH_END, pointerEvent);
|
|
26767
25202
|
}
|
|
26768
25203
|
_this.mouseState = null;
|
|
26769
|
-
_this.consumeNativeEvent(event, handled || state.
|
|
25204
|
+
_this.consumeNativeEvent(event, handled || state.inputHandled || !_this.allowPropagation);
|
|
26770
25205
|
};
|
|
26771
|
-
|
|
25206
|
+
_this.onNativeTouchStart = function(event) {
|
|
26772
25207
|
if (!_this.enabled) {
|
|
26773
25208
|
return;
|
|
26774
25209
|
}
|
|
@@ -26780,7 +25215,7 @@ var EventSystem = /*#__PURE__*/ function() {
|
|
|
26780
25215
|
_this.touchStates.set(touch.identifier, state);
|
|
26781
25216
|
state.pressed = true;
|
|
26782
25217
|
var handled = _this.pushNativeScreenTouch(touch.identifier, position, true, false, false);
|
|
26783
|
-
state.
|
|
25218
|
+
state.inputHandled = handled;
|
|
26784
25219
|
if (!handled) {
|
|
26785
25220
|
var pointerEvent = _this.createPointerEvent(event, position, state);
|
|
26786
25221
|
_this.dispatchEvent(EVENT_TYPE_TOUCH_START, pointerEvent);
|
|
@@ -26789,7 +25224,7 @@ var EventSystem = /*#__PURE__*/ function() {
|
|
|
26789
25224
|
}
|
|
26790
25225
|
_this.preventTouchDefaults(event);
|
|
26791
25226
|
};
|
|
26792
|
-
|
|
25227
|
+
_this.onNativeTouchMove = function(event) {
|
|
26793
25228
|
if (!_this.enabled) {
|
|
26794
25229
|
return;
|
|
26795
25230
|
}
|
|
@@ -26803,8 +25238,8 @@ var EventSystem = /*#__PURE__*/ function() {
|
|
|
26803
25238
|
var relative = new Vector2(position.x - state.last.x, position.y - state.last.y);
|
|
26804
25239
|
var velocity = _this.getVelocity(state, position);
|
|
26805
25240
|
var handled = _this.pushNativeScreenDrag(touch.identifier, position, relative, velocity);
|
|
26806
|
-
(_state = state).
|
|
26807
|
-
if (!handled && !state.
|
|
25241
|
+
(_state = state).inputHandled || (_state.inputHandled = handled);
|
|
25242
|
+
if (!handled && !state.inputHandled) {
|
|
26808
25243
|
var pointerEvent = _this.createPointerEvent(event, position, state, velocity);
|
|
26809
25244
|
_this.dispatchEvent(EVENT_TYPE_TOUCH_MOVE, pointerEvent);
|
|
26810
25245
|
}
|
|
@@ -26813,24 +25248,26 @@ var EventSystem = /*#__PURE__*/ function() {
|
|
|
26813
25248
|
}
|
|
26814
25249
|
_this.preventTouchDefaults(event);
|
|
26815
25250
|
};
|
|
26816
|
-
|
|
25251
|
+
_this.onNativeTouchEnd = function(event) {
|
|
26817
25252
|
_this.handleNativeTouchEnd(event, false);
|
|
26818
25253
|
};
|
|
26819
|
-
|
|
25254
|
+
_this.onNativeTouchCancel = function(event) {
|
|
26820
25255
|
_this.handleNativeTouchEnd(event, true);
|
|
26821
25256
|
};
|
|
26822
|
-
|
|
26823
|
-
|
|
26824
|
-
_this.mouseState = null;
|
|
26825
|
-
_this.touchStates.clear();
|
|
26826
|
-
_this.mouseFromTouchIndex = null;
|
|
26827
|
-
_this.touchFromMousePressed = false;
|
|
26828
|
-
_this.engine.windowRoot.cancelPointerInput();
|
|
26829
|
-
}
|
|
25257
|
+
_this.onCanvasFocus = function() {
|
|
25258
|
+
_this.emit("canvasFocus");
|
|
26830
25259
|
};
|
|
25260
|
+
_this.onCanvasBlur = function() {
|
|
25261
|
+
_this.emit("canvasBlur");
|
|
25262
|
+
};
|
|
25263
|
+
return _this;
|
|
26831
25264
|
}
|
|
26832
25265
|
var _proto = EventSystem.prototype;
|
|
26833
|
-
|
|
25266
|
+
/**
|
|
25267
|
+
* Rebinds native input listeners to a canvas.
|
|
25268
|
+
*
|
|
25269
|
+
* Rebind or unbind only while there are no active key, mouse, touch, or drag sessions.
|
|
25270
|
+
*/ _proto.bindListeners = function bindListeners(target) {
|
|
26834
25271
|
this.unbindListeners();
|
|
26835
25272
|
this.target = target;
|
|
26836
25273
|
if (!target || typeof window === "undefined") {
|
|
@@ -26867,7 +25304,8 @@ var EventSystem = /*#__PURE__*/ function() {
|
|
|
26867
25304
|
});
|
|
26868
25305
|
this.addNativeHandler(target, "keydown", this.onNativeKeyDown);
|
|
26869
25306
|
this.addNativeHandler(target, "keyup", this.onNativeKeyUp);
|
|
26870
|
-
this.addNativeHandler(
|
|
25307
|
+
this.addNativeHandler(target, "focus", this.onCanvasFocus);
|
|
25308
|
+
this.addNativeHandler(target, "blur", this.onCanvasBlur);
|
|
26871
25309
|
};
|
|
26872
25310
|
_proto.dispatchEvent = function dispatchEvent(type, event) {
|
|
26873
25311
|
var handlers = this.handlers[type];
|
|
@@ -26901,11 +25339,7 @@ var EventSystem = /*#__PURE__*/ function() {
|
|
|
26901
25339
|
}
|
|
26902
25340
|
};
|
|
26903
25341
|
_proto.dispose = function dispose() {
|
|
26904
|
-
this.
|
|
26905
|
-
this.mouseState = null;
|
|
26906
|
-
this.touchStates.clear();
|
|
26907
|
-
this.mouseFromTouchIndex = null;
|
|
26908
|
-
this.touchFromMousePressed = false;
|
|
25342
|
+
this.resetInputState();
|
|
26909
25343
|
this.handlers = {};
|
|
26910
25344
|
this.unbindListeners();
|
|
26911
25345
|
this.target = null;
|
|
@@ -26914,13 +25348,14 @@ var EventSystem = /*#__PURE__*/ function() {
|
|
|
26914
25348
|
if (!this.enabled || !this.target) {
|
|
26915
25349
|
return;
|
|
26916
25350
|
}
|
|
25351
|
+
this.setMouseButtonPressed(event.button, true);
|
|
26917
25352
|
var position = this.getCanvasPosition(event.clientX, event.clientY);
|
|
26918
25353
|
this.focusTarget();
|
|
26919
25354
|
var state = this.createPointerState(position);
|
|
26920
25355
|
this.mouseState = state;
|
|
26921
25356
|
state.pressed = true;
|
|
26922
25357
|
var handled = this.pushNativeMouseButton(event, position, true);
|
|
26923
|
-
state.
|
|
25358
|
+
state.inputHandled = handled;
|
|
26924
25359
|
if (!handled) {
|
|
26925
25360
|
var pointerEvent = this.createPointerEvent(event, position, state);
|
|
26926
25361
|
this.dispatchEvent(EVENT_TYPE_TOUCH_START, pointerEvent);
|
|
@@ -26944,8 +25379,7 @@ var EventSystem = /*#__PURE__*/ function() {
|
|
|
26944
25379
|
input.altPressed = event.altKey;
|
|
26945
25380
|
input.metaPressed = event.metaKey;
|
|
26946
25381
|
input.ctrlPressed = event.ctrlKey;
|
|
26947
|
-
this.
|
|
26948
|
-
this.consumeNativeEvent(event, this.engine.windowRoot.isInputHandled());
|
|
25382
|
+
this.consumeNativeEvent(event, this.pushInput(input));
|
|
26949
25383
|
};
|
|
26950
25384
|
_proto.handleNativeTouchEnd = function handleNativeTouchEnd(event, canceled) {
|
|
26951
25385
|
if (!this.enabled) {
|
|
@@ -26960,14 +25394,14 @@ var EventSystem = /*#__PURE__*/ function() {
|
|
|
26960
25394
|
}
|
|
26961
25395
|
var handled = this.pushNativeScreenTouch(touch.identifier, position, false, canceled, false);
|
|
26962
25396
|
var pointerEvent = this.createPointerEvent(event, position, state);
|
|
26963
|
-
if (!canceled && !state.
|
|
25397
|
+
if (!canceled && !state.inputHandled && !handled && this.isClick(state, position)) {
|
|
26964
25398
|
this.dispatchEvent(EVENT_TYPE_CLICK, pointerEvent);
|
|
26965
25399
|
}
|
|
26966
|
-
if (!handled && !canceled && !state.
|
|
25400
|
+
if (!handled && !canceled && !state.inputHandled) {
|
|
26967
25401
|
this.dispatchEvent(EVENT_TYPE_TOUCH_END, pointerEvent);
|
|
26968
25402
|
}
|
|
26969
25403
|
this.touchStates.delete(touch.identifier);
|
|
26970
|
-
this.consumeNativeEvent(event, handled || state.
|
|
25404
|
+
this.consumeNativeEvent(event, handled || state.inputHandled || !this.allowPropagation);
|
|
26971
25405
|
}
|
|
26972
25406
|
this.preventTouchDefaults(event);
|
|
26973
25407
|
};
|
|
@@ -26987,7 +25421,7 @@ var EventSystem = /*#__PURE__*/ function() {
|
|
|
26987
25421
|
};
|
|
26988
25422
|
_proto.pushNativeMouseMotion = function pushNativeMouseMotion(event, position, relative, velocity) {
|
|
26989
25423
|
var handled = false;
|
|
26990
|
-
if (this.touchFromMousePressed && (
|
|
25424
|
+
if (this.touchFromMousePressed && (this.mouseButtonMask & exports.MouseButtonMask.Left) !== 0) {
|
|
26991
25425
|
handled = this.pushScreenDrag(0, position, relative, velocity, InputEvent.deviceIdEmulation);
|
|
26992
25426
|
}
|
|
26993
25427
|
return this.pushMouseMotion(event, position, relative, velocity) || handled;
|
|
@@ -27024,8 +25458,7 @@ var EventSystem = /*#__PURE__*/ function() {
|
|
|
27024
25458
|
input.pressed = pressed;
|
|
27025
25459
|
input.canceled = canceled;
|
|
27026
25460
|
input.doubleClick = doubleClick;
|
|
27027
|
-
this.
|
|
27028
|
-
return this.engine.windowRoot.isInputHandled();
|
|
25461
|
+
return this.pushInput(input);
|
|
27029
25462
|
};
|
|
27030
25463
|
_proto.pushEmulatedMouseMotion = function pushEmulatedMouseMotion(position, relative, velocity) {
|
|
27031
25464
|
var input = new InputEventMouseMotion();
|
|
@@ -27038,42 +25471,42 @@ var EventSystem = /*#__PURE__*/ function() {
|
|
|
27038
25471
|
input.screenRelative.copyFrom(relative);
|
|
27039
25472
|
input.velocity.copyFrom(velocity);
|
|
27040
25473
|
input.screenVelocity.copyFrom(velocity);
|
|
27041
|
-
this.
|
|
27042
|
-
return this.engine.windowRoot.isInputHandled();
|
|
25474
|
+
return this.pushInput(input);
|
|
27043
25475
|
};
|
|
27044
25476
|
_proto.pushMouseButton = function pushMouseButton(event, position, pressed) {
|
|
27045
25477
|
var input = new InputEventMouseButton();
|
|
27046
25478
|
this.copyMouseFields(input, event, position);
|
|
27047
25479
|
input.device = InputEvent.deviceIdMouse;
|
|
27048
25480
|
input.buttonIndex = getMouseButton(event.button);
|
|
27049
|
-
input.buttonMask =
|
|
25481
|
+
input.buttonMask = this.mouseButtonMask;
|
|
25482
|
+
input.pressed = pressed;
|
|
25483
|
+
input.doubleClick = event.detail > 1;
|
|
25484
|
+
return this.pushInput(input);
|
|
25485
|
+
};
|
|
25486
|
+
_proto.setMouseButtonPressed = function setMouseButtonPressed(button, pressed) {
|
|
25487
|
+
var buttonBit = getMouseButtonBit(getMouseButton(button));
|
|
27050
25488
|
if (pressed) {
|
|
27051
|
-
|
|
25489
|
+
this.mouseButtonMask |= buttonBit;
|
|
27052
25490
|
} else {
|
|
27053
|
-
|
|
25491
|
+
this.mouseButtonMask &= ~buttonBit;
|
|
27054
25492
|
}
|
|
27055
|
-
input.pressed = pressed;
|
|
27056
|
-
input.doubleClick = event.detail > 1;
|
|
27057
|
-
this.engine.windowRoot.pushInput(input);
|
|
27058
|
-
return this.engine.windowRoot.isInputHandled();
|
|
27059
25493
|
};
|
|
27060
25494
|
_proto.pushWheelButton = function pushWheelButton(button, factor, position, event) {
|
|
27061
25495
|
var input = new InputEventMouseButton();
|
|
27062
25496
|
this.copyMouseFields(input, event, position);
|
|
27063
25497
|
input.device = InputEvent.deviceIdMouse;
|
|
27064
25498
|
input.buttonIndex = button;
|
|
27065
|
-
input.buttonMask =
|
|
25499
|
+
input.buttonMask = this.mouseButtonMask;
|
|
27066
25500
|
input.factor = factor;
|
|
27067
25501
|
input.pressed = true;
|
|
27068
|
-
this.
|
|
27069
|
-
return this.engine.windowRoot.isInputHandled();
|
|
25502
|
+
return this.pushInput(input);
|
|
27070
25503
|
};
|
|
27071
25504
|
_proto.pushMouseMotion = function pushMouseMotion(event, position, relative, velocity) {
|
|
27072
25505
|
var input = new InputEventMouseMotion();
|
|
27073
25506
|
this.copyMouseFields(input, event, position);
|
|
27074
25507
|
input.device = InputEvent.deviceIdMouse;
|
|
27075
|
-
input.buttonMask =
|
|
27076
|
-
input.pressed =
|
|
25508
|
+
input.buttonMask = this.mouseButtonMask;
|
|
25509
|
+
input.pressed = this.mouseButtonMask !== exports.MouseButtonMask.None;
|
|
27077
25510
|
input.relative.copyFrom(relative);
|
|
27078
25511
|
input.screenRelative.copyFrom(relative);
|
|
27079
25512
|
input.velocity.copyFrom(velocity);
|
|
@@ -27082,8 +25515,7 @@ var EventSystem = /*#__PURE__*/ function() {
|
|
|
27082
25515
|
input.pressure = event.pressure;
|
|
27083
25516
|
input.tilt.set(event.tiltX, event.tiltY);
|
|
27084
25517
|
}
|
|
27085
|
-
this.
|
|
27086
|
-
return this.engine.windowRoot.isInputHandled();
|
|
25518
|
+
return this.pushInput(input);
|
|
27087
25519
|
};
|
|
27088
25520
|
_proto.pushScreenTouch = function pushScreenTouch(index, position, pressed, canceled, doubleTap, device) {
|
|
27089
25521
|
var input = new InputEventScreenTouch();
|
|
@@ -27093,8 +25525,7 @@ var EventSystem = /*#__PURE__*/ function() {
|
|
|
27093
25525
|
input.pressed = pressed;
|
|
27094
25526
|
input.canceled = canceled;
|
|
27095
25527
|
input.doubleTap = doubleTap;
|
|
27096
|
-
this.
|
|
27097
|
-
return this.engine.windowRoot.isInputHandled();
|
|
25528
|
+
return this.pushInput(input);
|
|
27098
25529
|
};
|
|
27099
25530
|
_proto.pushScreenDrag = function pushScreenDrag(index, position, relative, velocity, device) {
|
|
27100
25531
|
var input = new InputEventScreenDrag();
|
|
@@ -27106,8 +25537,7 @@ var EventSystem = /*#__PURE__*/ function() {
|
|
|
27106
25537
|
input.velocity.copyFrom(velocity);
|
|
27107
25538
|
input.screenVelocity.copyFrom(velocity);
|
|
27108
25539
|
input.pressed = true;
|
|
27109
|
-
this.
|
|
27110
|
-
return this.engine.windowRoot.isInputHandled();
|
|
25540
|
+
return this.pushInput(input);
|
|
27111
25541
|
};
|
|
27112
25542
|
_proto.copyMouseFields = function copyMouseFields(input, event, position) {
|
|
27113
25543
|
input.position.copyFrom(position);
|
|
@@ -27182,7 +25612,7 @@ var EventSystem = /*#__PURE__*/ function() {
|
|
|
27182
25612
|
start: position.clone(),
|
|
27183
25613
|
last: position.clone(),
|
|
27184
25614
|
lastTime: performance.now(),
|
|
27185
|
-
|
|
25615
|
+
inputHandled: false,
|
|
27186
25616
|
pressed: false
|
|
27187
25617
|
};
|
|
27188
25618
|
return state;
|
|
@@ -27207,8 +25637,8 @@ var EventSystem = /*#__PURE__*/ function() {
|
|
|
27207
25637
|
var _target_width, _target_height;
|
|
27208
25638
|
return {
|
|
27209
25639
|
x: position.x / cssWidth * 2 - 1,
|
|
27210
|
-
// Legacy composition picking uses bottom-left, Y-up NDC even though
|
|
27211
|
-
// input follows the DOM convention of top-left, Y-down pixels.
|
|
25640
|
+
// Legacy composition picking uses bottom-left, Y-up NDC even though
|
|
25641
|
+
// standardized input follows the DOM convention of top-left, Y-down pixels.
|
|
27212
25642
|
y: 1 - position.y / cssHeight * 2,
|
|
27213
25643
|
vx: velocity.x / cssWidth * 2,
|
|
27214
25644
|
vy: -velocity.y / cssHeight * 2,
|
|
@@ -27236,6 +25666,11 @@ var EventSystem = /*#__PURE__*/ function() {
|
|
|
27236
25666
|
event.stopPropagation();
|
|
27237
25667
|
}
|
|
27238
25668
|
};
|
|
25669
|
+
_proto.pushInput = function pushInput(input) {
|
|
25670
|
+
input.clearAccepted();
|
|
25671
|
+
this.emit("input", input);
|
|
25672
|
+
return input.isAccepted();
|
|
25673
|
+
};
|
|
27239
25674
|
_proto.preventTouchDefaults = function preventTouchDefaults(event) {
|
|
27240
25675
|
if (event.cancelable) {
|
|
27241
25676
|
event.preventDefault();
|
|
@@ -27245,6 +25680,13 @@ var EventSystem = /*#__PURE__*/ function() {
|
|
|
27245
25680
|
var _this_target;
|
|
27246
25681
|
(_this_target = this.target) == null ? void 0 : _this_target.focus();
|
|
27247
25682
|
};
|
|
25683
|
+
_proto.resetInputState = function resetInputState() {
|
|
25684
|
+
this.mouseState = null;
|
|
25685
|
+
this.mouseButtonMask = exports.MouseButtonMask.None;
|
|
25686
|
+
this.touchStates.clear();
|
|
25687
|
+
this.mouseFromTouchIndex = null;
|
|
25688
|
+
this.touchFromMousePressed = false;
|
|
25689
|
+
};
|
|
27248
25690
|
_proto.addNativeHandler = function addNativeHandler(target, name, handler, options) {
|
|
27249
25691
|
target.addEventListener(name, handler, options);
|
|
27250
25692
|
this.nativeHandlers.push({
|
|
@@ -27275,23 +25717,20 @@ var EventSystem = /*#__PURE__*/ function() {
|
|
|
27275
25717
|
get: function get() {
|
|
27276
25718
|
return this._enabled;
|
|
27277
25719
|
},
|
|
27278
|
-
set:
|
|
25720
|
+
set: /**
|
|
25721
|
+
* Enables native input processing.
|
|
25722
|
+
*
|
|
25723
|
+
* Change this only while there are no active key, mouse, touch, or drag sessions.
|
|
25724
|
+
*/ function set(value) {
|
|
27279
25725
|
if (this._enabled === value) {
|
|
27280
25726
|
return;
|
|
27281
25727
|
}
|
|
27282
25728
|
this._enabled = value;
|
|
27283
|
-
if (!value) {
|
|
27284
|
-
this.mouseState = null;
|
|
27285
|
-
this.touchStates.clear();
|
|
27286
|
-
this.mouseFromTouchIndex = null;
|
|
27287
|
-
this.touchFromMousePressed = false;
|
|
27288
|
-
this.engine.windowRoot.cancelPointerInput();
|
|
27289
|
-
}
|
|
27290
25729
|
}
|
|
27291
25730
|
}
|
|
27292
25731
|
]);
|
|
27293
25732
|
return EventSystem;
|
|
27294
|
-
}();
|
|
25733
|
+
}(EventEmitter);
|
|
27295
25734
|
function getKeyLocation(location) {
|
|
27296
25735
|
if (location === 1) {
|
|
27297
25736
|
return exports.KeyLocation.Left;
|
|
@@ -27322,25 +25761,6 @@ function getMouseButton(button) {
|
|
|
27322
25761
|
return exports.MouseButton.None;
|
|
27323
25762
|
}
|
|
27324
25763
|
}
|
|
27325
|
-
function getMouseButtonMask(buttons) {
|
|
27326
|
-
var mask = exports.MouseButtonMask.None;
|
|
27327
|
-
if ((buttons & 1) !== 0) {
|
|
27328
|
-
mask |= exports.MouseButtonMask.Left;
|
|
27329
|
-
}
|
|
27330
|
-
if ((buttons & 2) !== 0) {
|
|
27331
|
-
mask |= exports.MouseButtonMask.Right;
|
|
27332
|
-
}
|
|
27333
|
-
if ((buttons & 4) !== 0) {
|
|
27334
|
-
mask |= exports.MouseButtonMask.Middle;
|
|
27335
|
-
}
|
|
27336
|
-
if ((buttons & 8) !== 0) {
|
|
27337
|
-
mask |= exports.MouseButtonMask.Xbutton1;
|
|
27338
|
-
}
|
|
27339
|
-
if ((buttons & 16) !== 0) {
|
|
27340
|
-
mask |= exports.MouseButtonMask.Xbutton2;
|
|
27341
|
-
}
|
|
27342
|
-
return mask;
|
|
27343
|
-
}
|
|
27344
25764
|
function getMouseButtonBit(button) {
|
|
27345
25765
|
switch(button){
|
|
27346
25766
|
case exports.MouseButton.Left:
|
|
@@ -27357,6 +25777,16 @@ function getMouseButtonBit(button) {
|
|
|
27357
25777
|
return exports.MouseButtonMask.None;
|
|
27358
25778
|
}
|
|
27359
25779
|
}
|
|
25780
|
+
function normalizeWheelFactor(delta, mode) {
|
|
25781
|
+
var magnitude = Math.abs(delta);
|
|
25782
|
+
if (mode === 1) {
|
|
25783
|
+
return magnitude / 3;
|
|
25784
|
+
}
|
|
25785
|
+
if (mode === 2) {
|
|
25786
|
+
return magnitude;
|
|
25787
|
+
}
|
|
25788
|
+
return magnitude / 100;
|
|
25789
|
+
}
|
|
27360
25790
|
|
|
27361
25791
|
var InteractLoader = /*#__PURE__*/ function(Plugin) {
|
|
27362
25792
|
_inherits(InteractLoader, Plugin);
|
|
@@ -29376,6 +27806,11 @@ exports.SpritePropertyTrack = __decorate([
|
|
|
29376
27806
|
effectsClass("SpritePropertyTrack")
|
|
29377
27807
|
], exports.SpritePropertyTrack);
|
|
29378
27808
|
|
|
27809
|
+
function _assert_this_initialized(self) {
|
|
27810
|
+
if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
27811
|
+
return self;
|
|
27812
|
+
}
|
|
27813
|
+
|
|
29379
27814
|
var Cone = /*#__PURE__*/ function() {
|
|
29380
27815
|
function Cone(props) {
|
|
29381
27816
|
var _this = this;
|
|
@@ -39380,7 +37815,7 @@ function getStandardSpriteContent(sprite, transform) {
|
|
|
39380
37815
|
return ret;
|
|
39381
37816
|
}
|
|
39382
37817
|
|
|
39383
|
-
var version$2 = "2.10.0-alpha.
|
|
37818
|
+
var version$2 = "2.10.0-alpha.5";
|
|
39384
37819
|
var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
|
|
39385
37820
|
var standardVersion = /^(\d+)\.(\d+)$/;
|
|
39386
37821
|
var reverseParticle = false;
|
|
@@ -41376,9 +39811,11 @@ var PreRenderTickData = /*#__PURE__*/ function(TickData) {
|
|
|
41376
39811
|
// Instantiate composition rootItem
|
|
41377
39812
|
_this.sceneRoot = new exports.VFXItem(_this.engine);
|
|
41378
39813
|
_this.sceneRoot.setParent(_this.root);
|
|
41379
|
-
_this.uiCanvas = _this.sceneRoot.addComponent(UICanvas);
|
|
41380
39814
|
if (sourceContent) {
|
|
41381
39815
|
_this.sceneRoot.setInstanceId(sourceContent.id);
|
|
39816
|
+
}
|
|
39817
|
+
PluginSystem.notifyCompositionCreating(_assert_this_initialized(_this), scene);
|
|
39818
|
+
if (sourceContent) {
|
|
41382
39819
|
_this.sceneRoot.instantiatePreComposition(sourceContent, false);
|
|
41383
39820
|
}
|
|
41384
39821
|
// 在 instantiatePreComposition 后设置 rootItem 的 name,避免 name 被覆盖
|
|
@@ -41947,9 +40384,6 @@ var PreRenderTickData = /*#__PURE__*/ function(TickData) {
|
|
|
41947
40384
|
},
|
|
41948
40385
|
set: function set(value) {
|
|
41949
40386
|
this._renderOrder = value;
|
|
41950
|
-
if (this.uiCanvas) {
|
|
41951
|
-
this.uiCanvas.order = value;
|
|
41952
|
-
}
|
|
41953
40387
|
}
|
|
41954
40388
|
},
|
|
41955
40389
|
{
|
|
@@ -41962,9 +40396,6 @@ var PreRenderTickData = /*#__PURE__*/ function(TickData) {
|
|
|
41962
40396
|
},
|
|
41963
40397
|
set: function set(value) {
|
|
41964
40398
|
this._interactive = !!value;
|
|
41965
|
-
if (this.uiCanvas) {
|
|
41966
|
-
this.uiCanvas.receivesEvents = this._interactive;
|
|
41967
|
-
}
|
|
41968
40399
|
}
|
|
41969
40400
|
},
|
|
41970
40401
|
{
|
|
@@ -43792,7 +42223,6 @@ var DEFAULT_FPS = 60;
|
|
|
43792
42223
|
_this.objectInstance = {};
|
|
43793
42224
|
_this.root = new exports.VFXItem(_assert_this_initialized(_this));
|
|
43794
42225
|
_this.root.name = "root";
|
|
43795
|
-
_this.windowRoot = new WindowRootControl(_assert_this_initialized(_this));
|
|
43796
42226
|
_this.whiteTexture = generateWhiteTexture(_assert_this_initialized(_this));
|
|
43797
42227
|
_this.transparentTexture = generateEmptyTexture(_assert_this_initialized(_this));
|
|
43798
42228
|
if (!(options == null ? void 0 : options.manualRender)) {
|
|
@@ -43945,7 +42375,7 @@ var DEFAULT_FPS = 60;
|
|
|
43945
42375
|
(_this_ticker1 = this.ticker) == null ? void 0 : _this_ticker1.pause();
|
|
43946
42376
|
return;
|
|
43947
42377
|
}
|
|
43948
|
-
this.
|
|
42378
|
+
this.emit("update", dt);
|
|
43949
42379
|
// Tick compositions onPreRender
|
|
43950
42380
|
//-------------------------------------------------------------------------
|
|
43951
42381
|
for(var _iterator1 = _create_for_of_iterator_helper_loose(compositions), _step1; !(_step1 = _iterator1()).done;){
|
|
@@ -43960,7 +42390,7 @@ var DEFAULT_FPS = 60;
|
|
|
43960
42390
|
var composition2 = _step2.value;
|
|
43961
42391
|
composition2.renderContent();
|
|
43962
42392
|
}
|
|
43963
|
-
this.
|
|
42393
|
+
this.emit("postrender");
|
|
43964
42394
|
this.renderTargetPool.flush();
|
|
43965
42395
|
};
|
|
43966
42396
|
/**
|
|
@@ -44002,7 +42432,6 @@ var DEFAULT_FPS = 60;
|
|
|
44002
42432
|
this.canvas.style.height = containerHeight + "px";
|
|
44003
42433
|
logger.info("Resize engine " + this.name + " [" + canvasWidth + "," + canvasHeight + "," + containerWidth + "," + containerHeight + "].");
|
|
44004
42434
|
this.setSize(canvasWidth, canvasHeight);
|
|
44005
|
-
this.windowRoot.resize(canvasWidth, canvasHeight);
|
|
44006
42435
|
}
|
|
44007
42436
|
};
|
|
44008
42437
|
_proto.setSize = function setSize(width, height) {
|
|
@@ -44208,6 +42637,12 @@ var DEFAULT_FPS = 60;
|
|
|
44208
42637
|
_proto.setStencilTest = function setStencilTest(enable) {
|
|
44209
42638
|
// OVERRIDE
|
|
44210
42639
|
};
|
|
42640
|
+
_proto.setScissorTest = function setScissorTest(enable) {
|
|
42641
|
+
// OVERRIDE
|
|
42642
|
+
};
|
|
42643
|
+
_proto.setScissor = function setScissor(x, y, width, height) {
|
|
42644
|
+
// OVERRIDE
|
|
42645
|
+
};
|
|
44211
42646
|
_proto.setCulling = function setCulling(enable) {
|
|
44212
42647
|
// OVERRIDE
|
|
44213
42648
|
};
|
|
@@ -44285,7 +42720,6 @@ var DEFAULT_FPS = 60;
|
|
|
44285
42720
|
composition.dispose();
|
|
44286
42721
|
}
|
|
44287
42722
|
this.root.dispose();
|
|
44288
|
-
this.windowRoot.dispose();
|
|
44289
42723
|
(_this_assetService = this.assetService) == null ? void 0 : _this_assetService.dispose();
|
|
44290
42724
|
(_this__graphics = this._graphics) == null ? void 0 : _this__graphics.dispose();
|
|
44291
42725
|
this.renderPasses.forEach(function(pass) {
|
|
@@ -44610,7 +43044,7 @@ registerPlugin("text", TextLoader);
|
|
|
44610
43044
|
registerPlugin("sprite", SpriteLoader);
|
|
44611
43045
|
registerPlugin("particle", ParticleLoader);
|
|
44612
43046
|
registerPlugin("interact", InteractLoader);
|
|
44613
|
-
var version$1 = "2.10.0-alpha.
|
|
43047
|
+
var version$1 = "2.10.0-alpha.5";
|
|
44614
43048
|
logger.info("Core version: " + version$1 + ".");
|
|
44615
43049
|
|
|
44616
43050
|
var _obj;
|
|
@@ -46103,7 +44537,7 @@ applyMixins(exports.ThreeTextComponent, [
|
|
|
46103
44537
|
*/ Mesh.create = function(engine, props) {
|
|
46104
44538
|
return new ThreeMesh(engine, props);
|
|
46105
44539
|
};
|
|
46106
|
-
var version = "2.10.0-alpha.
|
|
44540
|
+
var version = "2.10.0-alpha.5";
|
|
46107
44541
|
logger.info("THREEJS plugin version: " + version + ".");
|
|
46108
44542
|
|
|
46109
44543
|
exports.ATLAS_SIZE = ATLAS_SIZE;
|
|
@@ -46142,8 +44576,6 @@ exports.COPY_MESH_SHADER_ID = COPY_MESH_SHADER_ID;
|
|
|
46142
44576
|
exports.COPY_VERTEX_SHADER = COPY_VERTEX_SHADER;
|
|
46143
44577
|
exports.Camera = Camera;
|
|
46144
44578
|
exports.CameraVFXItemLoader = CameraVFXItemLoader;
|
|
46145
|
-
exports.CanvasContainer = CanvasContainer;
|
|
46146
|
-
exports.CanvasRootControl = CanvasRootControl;
|
|
46147
44579
|
exports.Circle = Circle$1;
|
|
46148
44580
|
exports.ColorCurve = ColorCurve;
|
|
46149
44581
|
exports.ColorPlayable = ColorPlayable;
|
|
@@ -46156,8 +44588,6 @@ exports.Composition = Composition;
|
|
|
46156
44588
|
exports.ConstBoolNode = ConstBoolNode;
|
|
46157
44589
|
exports.ConstFloatNode = ConstFloatNode;
|
|
46158
44590
|
exports.ConstraintTarget = ConstraintTarget;
|
|
46159
|
-
exports.ContainerControl = ContainerControl;
|
|
46160
|
-
exports.Control = Control;
|
|
46161
44591
|
exports.ControlParameterBoolNode = ControlParameterBoolNode;
|
|
46162
44592
|
exports.ControlParameterFloatNode = ControlParameterFloatNode;
|
|
46163
44593
|
exports.ControlParameterTriggerNode = ControlParameterTriggerNode;
|
|
@@ -46264,7 +44694,6 @@ exports.RenderTargetPool = RenderTargetPool;
|
|
|
46264
44694
|
exports.Renderbuffer = Renderbuffer;
|
|
46265
44695
|
exports.Renderer = Renderer;
|
|
46266
44696
|
exports.RendererComponent = RendererComponent;
|
|
46267
|
-
exports.RootControl = RootControl;
|
|
46268
44697
|
exports.RuntimeClip = RuntimeClip;
|
|
46269
44698
|
exports.SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0 = SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0;
|
|
46270
44699
|
exports.SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0 = SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0;
|
|
@@ -46308,8 +44737,6 @@ exports.TransformPlayable = TransformPlayable;
|
|
|
46308
44737
|
exports.TransitionNode = TransitionNode;
|
|
46309
44738
|
exports.Triangle = Triangle;
|
|
46310
44739
|
exports.TrimPath = TrimPath;
|
|
46311
|
-
exports.UICanvas = UICanvas;
|
|
46312
|
-
exports.UIControl = UIControl;
|
|
46313
44740
|
exports.ValueGetter = ValueGetter;
|
|
46314
44741
|
exports.ValueNode = ValueNode;
|
|
46315
44742
|
exports.Vector2Curve = Vector2Curve;
|
|
@@ -46319,7 +44746,6 @@ exports.Vector3PropertyMixerPlayable = Vector3PropertyMixerPlayable;
|
|
|
46319
44746
|
exports.Vector4Curve = Vector4Curve;
|
|
46320
44747
|
exports.Vector4PropertyMixerPlayable = Vector4PropertyMixerPlayable;
|
|
46321
44748
|
exports.VertexBuffer = VertexBuffer;
|
|
46322
|
-
exports.WindowRootControl = WindowRootControl;
|
|
46323
44749
|
exports.addByOrder = addByOrder;
|
|
46324
44750
|
exports.addItem = addItem;
|
|
46325
44751
|
exports.addItemWithOrder = addItemWithOrder;
|