@galacean/effects-core 2.10.0-alpha.3 → 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/components/index.d.ts +0 -2
- package/dist/composition.d.ts +1 -3
- package/dist/engine.d.ts +5 -5
- package/dist/index.d.ts +0 -1
- package/dist/index.js +752 -2304
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +753 -2297
- package/dist/index.mjs.map +1 -1
- package/dist/input/enums.d.ts +0 -40
- package/dist/input/input-event.d.ts +4 -3
- package/dist/plugin-system.d.ts +1 -0
- package/dist/plugins/interact/event-system.d.ts +31 -2
- package/dist/plugins/plugin.d.ts +7 -0
- package/dist/render/graphics.d.ts +53 -11
- package/dist/render/text-cache.d.ts +2 -2
- package/package.json +1 -1
- package/dist/components/ui-canvas.d.ts +0 -28
- package/dist/components/ui-control.d.ts +0 -38
- package/dist/gui/control.d.ts +0 -189
- package/dist/gui/index.d.ts +0 -2
- package/dist/gui/roots.d.ts +0 -79
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Description: Galacean Effects runtime core for the web
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
|
|
6
|
-
* Version: v2.10.0-alpha.
|
|
6
|
+
* Version: v2.10.0-alpha.5
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
@@ -2931,6 +2931,11 @@ var PluginSystem = /*#__PURE__*/ function() {
|
|
|
2931
2931
|
PluginSystem.getPlugins = function getPlugins() {
|
|
2932
2932
|
return plugins;
|
|
2933
2933
|
};
|
|
2934
|
+
PluginSystem.notifyCompositionCreating = function notifyCompositionCreating(composition, scene) {
|
|
2935
|
+
plugins.forEach(function(plugin) {
|
|
2936
|
+
return plugin.onCompositionCreating(composition, scene);
|
|
2937
|
+
});
|
|
2938
|
+
};
|
|
2934
2939
|
PluginSystem.notifyCompositionCreated = function notifyCompositionCreated(composition, scene) {
|
|
2935
2940
|
plugins.forEach(function(plugin) {
|
|
2936
2941
|
return plugin.onCompositionCreated(composition, scene);
|
|
@@ -3023,6 +3028,12 @@ function getPluginUsageInfo(name) {
|
|
|
3023
3028
|
* @param engine - 引擎实例
|
|
3024
3029
|
*/ _proto.onAssetsLoadFinish = function onAssetsLoadFinish(scene, options, engine) {};
|
|
3025
3030
|
/**
|
|
3031
|
+
* 合成内容开始创建前触发。
|
|
3032
|
+
* 此时 root、pluginRoot 和 sceneRoot 已创建,但场景内容尚未实例化。
|
|
3033
|
+
* @param composition - 正在创建的合成对象
|
|
3034
|
+
* @param scene - 场景对象
|
|
3035
|
+
*/ _proto.onCompositionCreating = function onCompositionCreating(composition, scene) {};
|
|
3036
|
+
/**
|
|
3026
3037
|
* 合成创建完成后触发。
|
|
3027
3038
|
* @param composition - 合成对象
|
|
3028
3039
|
* @param scene - 场景对象
|
|
@@ -15631,35 +15642,35 @@ function vecMulCombine(out, a, b) {
|
|
|
15631
15642
|
}
|
|
15632
15643
|
return out;
|
|
15633
15644
|
}
|
|
15634
|
-
var _obj$
|
|
15635
|
-
var particleOriginTranslateMap$1 = (_obj$
|
|
15645
|
+
var _obj$5;
|
|
15646
|
+
var particleOriginTranslateMap$1 = (_obj$5 = {}, _obj$5[ParticleOrigin.PARTICLE_ORIGIN_CENTER] = [
|
|
15636
15647
|
0,
|
|
15637
15648
|
0
|
|
15638
|
-
], _obj$
|
|
15649
|
+
], _obj$5[ParticleOrigin.PARTICLE_ORIGIN_CENTER_BOTTOM] = [
|
|
15639
15650
|
0,
|
|
15640
15651
|
-0.5
|
|
15641
|
-
], _obj$
|
|
15652
|
+
], _obj$5[ParticleOrigin.PARTICLE_ORIGIN_CENTER_TOP] = [
|
|
15642
15653
|
0,
|
|
15643
15654
|
0.5
|
|
15644
|
-
], _obj$
|
|
15655
|
+
], _obj$5[ParticleOrigin.PARTICLE_ORIGIN_LEFT_TOP] = [
|
|
15645
15656
|
-0.5,
|
|
15646
15657
|
0.5
|
|
15647
|
-
], _obj$
|
|
15658
|
+
], _obj$5[ParticleOrigin.PARTICLE_ORIGIN_LEFT_CENTER] = [
|
|
15648
15659
|
-0.5,
|
|
15649
15660
|
0
|
|
15650
|
-
], _obj$
|
|
15661
|
+
], _obj$5[ParticleOrigin.PARTICLE_ORIGIN_LEFT_BOTTOM] = [
|
|
15651
15662
|
-0.5,
|
|
15652
15663
|
-0.5
|
|
15653
|
-
], _obj$
|
|
15664
|
+
], _obj$5[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_CENTER] = [
|
|
15654
15665
|
0.5,
|
|
15655
15666
|
0
|
|
15656
|
-
], _obj$
|
|
15667
|
+
], _obj$5[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_BOTTOM] = [
|
|
15657
15668
|
0.5,
|
|
15658
15669
|
-0.5
|
|
15659
|
-
], _obj$
|
|
15670
|
+
], _obj$5[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_TOP] = [
|
|
15660
15671
|
0.5,
|
|
15661
15672
|
0.5
|
|
15662
|
-
], _obj$
|
|
15673
|
+
], _obj$5);
|
|
15663
15674
|
function nearestPowerOfTwo(value) {
|
|
15664
15675
|
return Math.pow(2, Math.round(Math.log(value) / Math.LN2));
|
|
15665
15676
|
}
|
|
@@ -17397,27 +17408,27 @@ function oldBezierKeyFramesToNew(props) {
|
|
|
17397
17408
|
* 对象引用阶梯曲线(spec ValueType.REFERENCE_CURVE)。
|
|
17398
17409
|
* props 为 [[time, value], ...],value 为已解析的对象引用实例。
|
|
17399
17410
|
*/ var REFERENCE_CURVE = 28;
|
|
17400
|
-
var _obj$
|
|
17401
|
-
var map$1 = (_obj$
|
|
17411
|
+
var _obj$4;
|
|
17412
|
+
var map$1 = (_obj$4 = {}, _obj$4[ValueType.RANDOM] = function(props) {
|
|
17402
17413
|
if (_instanceof1(props[0], Array)) {
|
|
17403
17414
|
return new RandomVectorValue(props);
|
|
17404
17415
|
}
|
|
17405
17416
|
return new RandomValue(props);
|
|
17406
|
-
}, _obj$
|
|
17417
|
+
}, _obj$4[ValueType.CONSTANT] = function(props) {
|
|
17407
17418
|
return new StaticValue(props);
|
|
17408
|
-
}, _obj$
|
|
17419
|
+
}, _obj$4[ValueType.CONSTANT_VEC2] = function(props) {
|
|
17409
17420
|
return new StaticValue(props);
|
|
17410
|
-
}, _obj$
|
|
17421
|
+
}, _obj$4[ValueType.CONSTANT_VEC3] = function(props) {
|
|
17411
17422
|
return new StaticValue(props);
|
|
17412
|
-
}, _obj$
|
|
17423
|
+
}, _obj$4[ValueType.CONSTANT_VEC4] = function(props) {
|
|
17413
17424
|
return new StaticValue(props);
|
|
17414
|
-
}, _obj$
|
|
17425
|
+
}, _obj$4[ValueType.RGBA_COLOR] = function(props) {
|
|
17415
17426
|
return new StaticValue(props);
|
|
17416
|
-
}, _obj$
|
|
17427
|
+
}, _obj$4[ValueType.COLORS] = function(props) {
|
|
17417
17428
|
return new RandomSetValue(props.map(function(c) {
|
|
17418
17429
|
return colorToArr$1(c, false);
|
|
17419
17430
|
}));
|
|
17420
|
-
}, _obj$
|
|
17431
|
+
}, _obj$4[ValueType.LINE] = function(props) {
|
|
17421
17432
|
if (props.length === 2 && props[0][0] === 0 && props[1][0] === 1) {
|
|
17422
17433
|
return new LinearValue([
|
|
17423
17434
|
props[0][1],
|
|
@@ -17425,38 +17436,38 @@ var map$1 = (_obj$5 = {}, _obj$5[ValueType.RANDOM] = function(props) {
|
|
|
17425
17436
|
]);
|
|
17426
17437
|
}
|
|
17427
17438
|
return new LineSegments(props);
|
|
17428
|
-
}, _obj$
|
|
17439
|
+
}, _obj$4[ValueType.GRADIENT_COLOR] = function(props) {
|
|
17429
17440
|
return new GradientValue(props);
|
|
17430
|
-
}, _obj$
|
|
17441
|
+
}, _obj$4[ValueType.LINEAR_PATH] = function(pros) {
|
|
17431
17442
|
return new PathSegments(pros);
|
|
17432
|
-
}, _obj$
|
|
17443
|
+
}, _obj$4[ValueType.BEZIER_CURVE] = function(props) {
|
|
17433
17444
|
if (props.length === 1) {
|
|
17434
17445
|
return new StaticValue(props[0][1][1]);
|
|
17435
17446
|
}
|
|
17436
17447
|
return new BezierCurve(props);
|
|
17437
|
-
}, _obj$
|
|
17448
|
+
}, _obj$4[ValueType.BEZIER_CURVE_PATH] = function(props) {
|
|
17438
17449
|
if (props[0].length === 1) {
|
|
17439
17450
|
return new StaticValue(_construct(Vector3, [].concat(props[1][0])));
|
|
17440
17451
|
}
|
|
17441
17452
|
return new BezierCurvePath(props);
|
|
17442
|
-
}, _obj$
|
|
17453
|
+
}, _obj$4[ValueType.BEZIER_CURVE_QUAT] = function(props) {
|
|
17443
17454
|
if (props[0].length === 1) {
|
|
17444
17455
|
return new StaticValue(_construct(Quaternion, [].concat(props[1][0])));
|
|
17445
17456
|
}
|
|
17446
17457
|
return new BezierCurveQuat(props);
|
|
17447
|
-
}, _obj$
|
|
17458
|
+
}, _obj$4[ValueType.COLOR_CURVE] = function(props) {
|
|
17448
17459
|
return new ColorCurve(props);
|
|
17449
|
-
}, _obj$
|
|
17460
|
+
}, _obj$4[ValueType.VECTOR4_CURVE] = function(props) {
|
|
17450
17461
|
return new Vector4Curve(props);
|
|
17451
|
-
}, _obj$
|
|
17462
|
+
}, _obj$4[ValueType.VECTOR2_CURVE] = function(props) {
|
|
17452
17463
|
return new Vector2Curve(props);
|
|
17453
17464
|
}, // TODO: add spec
|
|
17454
|
-
_obj$
|
|
17465
|
+
_obj$4[VECTOR3_CURVE] = function(props) {
|
|
17455
17466
|
return new Vector3Curve(props);
|
|
17456
17467
|
}, // 对象引用阶梯曲线(不插值):props.data 为 [time, value][],value 已解析为 EffectsObject
|
|
17457
|
-
_obj$
|
|
17468
|
+
_obj$4[REFERENCE_CURVE] = function(props) {
|
|
17458
17469
|
return new ReferenceCurve(props);
|
|
17459
|
-
}, _obj$
|
|
17470
|
+
}, _obj$4);
|
|
17460
17471
|
function createValueGetter(args) {
|
|
17461
17472
|
if (!args || !isNaN(+args)) {
|
|
17462
17473
|
return new StaticValue(args || 0);
|
|
@@ -21397,8 +21408,8 @@ var vertexBufferSemanticMap = {
|
|
|
21397
21408
|
TANGENT_BS2: "aTargetTangent2",
|
|
21398
21409
|
TANGENT_BS3: "aTargetTangent3"
|
|
21399
21410
|
};
|
|
21400
|
-
var _obj$
|
|
21401
|
-
var BYTES_TYPE_MAP = (_obj$
|
|
21411
|
+
var _obj$3;
|
|
21412
|
+
var BYTES_TYPE_MAP = (_obj$3 = {}, _obj$3[exports.BufferDataType.Float] = 4, _obj$3[exports.BufferDataType.Int] = 4, _obj$3[exports.BufferDataType.UnsignedInt] = 4, _obj$3[exports.BufferDataType.Short] = 2, _obj$3[exports.BufferDataType.UnsignedShort] = 2, _obj$3[exports.BufferDataType.Byte] = 1, _obj$3[exports.BufferDataType.UnsignedByte] = 1, _obj$3);
|
|
21402
21413
|
function generateEmptyTypedArray(type) {
|
|
21403
21414
|
return createTypedArray(type, 0);
|
|
21404
21415
|
}
|
|
@@ -22915,7 +22926,7 @@ var canvasPool = new CanvasPool();
|
|
|
22915
22926
|
* `ATLAS_SIZE × ATLAS_SIZE` 的离屏 canvas atlas,字符按需逐个绘制并打包,
|
|
22916
22927
|
* `Graphics.drawText` 通过逐字 quad 引用 atlas 子矩形渲染。
|
|
22917
22928
|
*
|
|
22918
|
-
* - 同一段文本不同颜色不会重复 upload(颜色由顶点 `vColor`
|
|
22929
|
+
* - 同一段文本不同颜色不会重复 upload(颜色由顶点 `vColor` 与字形 RGBA 相乘)
|
|
22919
22930
|
* - 同一字体/字号下重复字符只渲染一次,显著减少 canvas → texture 上传次数
|
|
22920
22931
|
*
|
|
22921
22932
|
* 入参全部展开(避免调用方每帧创建临时 style 对象触发 GC)
|
|
@@ -22929,7 +22940,7 @@ var canvasPool = new CanvasPool();
|
|
|
22929
22940
|
/**
|
|
22930
22941
|
* 取(必要时新建)对应字体的字符 atlas
|
|
22931
22942
|
*/ _proto.getAtlas = function getAtlas(fontSize, fontFamily, fontWeight, fontStyle) {
|
|
22932
|
-
//
|
|
22943
|
+
// 字形 atlas 跟随 Engine.pixelRatio。
|
|
22933
22944
|
var resolution = this.engine.pixelRatio;
|
|
22934
22945
|
if (resolution !== this.resolution) {
|
|
22935
22946
|
this.clear();
|
|
@@ -22950,14 +22961,11 @@ var canvasPool = new CanvasPool();
|
|
|
22950
22961
|
var probeCtx = probeCanvasAndContext.context;
|
|
22951
22962
|
var ascentPx = fontSize * 0.8 * resolution;
|
|
22952
22963
|
var descentPx = fontSize * 0.2 * resolution;
|
|
22953
|
-
|
|
22954
|
-
|
|
22955
|
-
|
|
22956
|
-
|
|
22957
|
-
|
|
22958
|
-
} finally{
|
|
22959
|
-
canvasPool.releaseCanvasAndContext(probeCanvasAndContext);
|
|
22960
|
-
}
|
|
22964
|
+
probeCtx.font = scaledFontString;
|
|
22965
|
+
var m = probeCtx.measureText(METRICS_STRING + BASELINE_SYMBOL);
|
|
22966
|
+
ascentPx = m.actualBoundingBoxAscent || ascentPx;
|
|
22967
|
+
descentPx = m.actualBoundingBoxDescent || descentPx;
|
|
22968
|
+
canvasPool.releaseCanvasAndContext(probeCanvasAndContext);
|
|
22961
22969
|
var atlas = new GlyphAtlas(this.engine, scaledFontString, ascentPx, descentPx, fontStyle, resolution);
|
|
22962
22970
|
this.atlases.set(fontKey, atlas);
|
|
22963
22971
|
return atlas;
|
|
@@ -22993,6 +23001,10 @@ var FULL_REGION = {
|
|
|
22993
23001
|
u1: 1,
|
|
22994
23002
|
v1: 1
|
|
22995
23003
|
};
|
|
23004
|
+
var NINE_PATCH_DRAW_SOURCE_SIZE = "aDrawSourceSize";
|
|
23005
|
+
var NINE_PATCH_SOURCE_RECT = "aSourceRect";
|
|
23006
|
+
var NINE_PATCH_MARGINS = "aMargins";
|
|
23007
|
+
var NINE_PATCH_OPTIONS = "aOptions";
|
|
22996
23008
|
var Graphics = /*#__PURE__*/ function() {
|
|
22997
23009
|
function Graphics(engine) {
|
|
22998
23010
|
this.engine = engine;
|
|
@@ -23006,6 +23018,10 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
23006
23018
|
this.colors = [];
|
|
23007
23019
|
this.uvs = [];
|
|
23008
23020
|
this.indices = [];
|
|
23021
|
+
this.ninePatchDrawSourceSizes = [];
|
|
23022
|
+
this.ninePatchSourceRects = [];
|
|
23023
|
+
this.ninePatchMargins = [];
|
|
23024
|
+
this.ninePatchOptions = [];
|
|
23009
23025
|
this.lineStyle = {
|
|
23010
23026
|
width: 1,
|
|
23011
23027
|
alignment: 0.5,
|
|
@@ -23017,6 +23033,9 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
23017
23033
|
this.currentBatchTexture = null;
|
|
23018
23034
|
this.transformStack = [];
|
|
23019
23035
|
this.currentTransform = Matrix3.fromIdentity();
|
|
23036
|
+
this.clipStack = [];
|
|
23037
|
+
this.logicalWidth = 1;
|
|
23038
|
+
this.logicalHeight = 1;
|
|
23020
23039
|
var _obj;
|
|
23021
23040
|
this.geometry = Geometry.create(this.engine, {
|
|
23022
23041
|
attributes: (_obj = {}, _obj[VertexBuffer.PositionKind] = {
|
|
@@ -23082,6 +23101,51 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
23082
23101
|
drawCount: 6,
|
|
23083
23102
|
bufferUsage: glContext.DYNAMIC_DRAW
|
|
23084
23103
|
});
|
|
23104
|
+
var _obj1;
|
|
23105
|
+
this.ninePatchGeometry = Geometry.create(this.engine, {
|
|
23106
|
+
attributes: (_obj1 = {}, _obj1[VertexBuffer.PositionKind] = {
|
|
23107
|
+
type: glContext.FLOAT,
|
|
23108
|
+
size: 2,
|
|
23109
|
+
data: new Float32Array(8)
|
|
23110
|
+
}, _obj1[VertexBuffer.ColorKind] = {
|
|
23111
|
+
type: glContext.FLOAT,
|
|
23112
|
+
size: 4,
|
|
23113
|
+
data: new Float32Array(16)
|
|
23114
|
+
}, _obj1[VertexBuffer.UVKind] = {
|
|
23115
|
+
type: glContext.FLOAT,
|
|
23116
|
+
size: 2,
|
|
23117
|
+
data: new Float32Array(8)
|
|
23118
|
+
}, _obj1[NINE_PATCH_DRAW_SOURCE_SIZE] = {
|
|
23119
|
+
type: glContext.FLOAT,
|
|
23120
|
+
size: 4,
|
|
23121
|
+
data: new Float32Array(16)
|
|
23122
|
+
}, _obj1[NINE_PATCH_SOURCE_RECT] = {
|
|
23123
|
+
type: glContext.FLOAT,
|
|
23124
|
+
size: 4,
|
|
23125
|
+
data: new Float32Array(16)
|
|
23126
|
+
}, _obj1[NINE_PATCH_MARGINS] = {
|
|
23127
|
+
type: glContext.FLOAT,
|
|
23128
|
+
size: 4,
|
|
23129
|
+
data: new Float32Array(16)
|
|
23130
|
+
}, _obj1[NINE_PATCH_OPTIONS] = {
|
|
23131
|
+
type: glContext.FLOAT,
|
|
23132
|
+
size: 4,
|
|
23133
|
+
data: new Float32Array(16)
|
|
23134
|
+
}, _obj1),
|
|
23135
|
+
indices: {
|
|
23136
|
+
data: new Uint16Array([
|
|
23137
|
+
0,
|
|
23138
|
+
1,
|
|
23139
|
+
2,
|
|
23140
|
+
2,
|
|
23141
|
+
1,
|
|
23142
|
+
3
|
|
23143
|
+
])
|
|
23144
|
+
},
|
|
23145
|
+
mode: glContext.TRIANGLES,
|
|
23146
|
+
drawCount: 6,
|
|
23147
|
+
bufferUsage: glContext.DYNAMIC_DRAW
|
|
23148
|
+
});
|
|
23085
23149
|
this.coloredMaterial = Material.create(this.engine, {
|
|
23086
23150
|
shader: {
|
|
23087
23151
|
vertex: "precision highp float;\n attribute vec2 aPos;\n attribute vec4 aColor;\n varying vec4 vColor;\n\n uniform mat4 effects_MatrixVP;\n void main() {\n vColor = aColor;\n gl_Position = effects_MatrixVP * vec4(aPos, 0.0, 1.0);\n }",
|
|
@@ -23100,12 +23164,21 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
23100
23164
|
this.texturedMaterial.depthTest = false;
|
|
23101
23165
|
this.texturedMaterial.depthMask = false;
|
|
23102
23166
|
this.texturedMaterial.blending = true;
|
|
23103
|
-
|
|
23167
|
+
this.ninePatchMaterial = Material.create(this.engine, {
|
|
23168
|
+
shader: {
|
|
23169
|
+
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 }",
|
|
23170
|
+
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 }"
|
|
23171
|
+
}
|
|
23172
|
+
});
|
|
23173
|
+
this.ninePatchMaterial.depthTest = false;
|
|
23174
|
+
this.ninePatchMaterial.depthMask = false;
|
|
23175
|
+
this.ninePatchMaterial.blending = true;
|
|
23176
|
+
// 文本 atlas 在上传时预乘 alpha,因此纹理 RGB 只需乘顶点色和顶点 alpha。
|
|
23104
23177
|
// 单独使用 material,避免改变 drawTexture 对普通非预乘纹理的处理。
|
|
23105
23178
|
this.textMaterial = Material.create(this.engine, {
|
|
23106
23179
|
shader: {
|
|
23107
23180
|
vertex: "precision highp float;\n attribute vec2 aPos;\n attribute vec4 aColor;\n attribute vec2 aUV;\n varying vec4 vColor;\n varying vec2 vUV;\n\n uniform mat4 effects_MatrixVP;\n void main() {\n vColor = aColor;\n vUV = aUV;\n gl_Position = effects_MatrixVP * vec4(aPos, 0.0, 1.0);\n }",
|
|
23108
|
-
fragment: "precision highp float;\n varying vec4 vColor;\n varying vec2 vUV;\n uniform sampler2D uMainTexture;\n void main() {\n
|
|
23181
|
+
fragment: "precision highp float;\n varying vec4 vColor;\n varying vec2 vUV;\n uniform sampler2D uMainTexture;\n void main() {\n vec4 textureColor = texture2D(uMainTexture, vUV);\n float alpha = textureColor.a * vColor.a;\n vec3 rgb = textureColor.rgb * vColor.rgb * vColor.a;\n gl_FragColor = vec4(rgb, alpha);\n }"
|
|
23109
23182
|
}
|
|
23110
23183
|
});
|
|
23111
23184
|
this.textMaterial.depthTest = false;
|
|
@@ -23121,25 +23194,36 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
23121
23194
|
this.vertices.length = 0;
|
|
23122
23195
|
this.colors.length = 0;
|
|
23123
23196
|
this.uvs.length = 0;
|
|
23197
|
+
this.ninePatchDrawSourceSizes.length = 0;
|
|
23198
|
+
this.ninePatchSourceRects.length = 0;
|
|
23199
|
+
this.ninePatchMargins.length = 0;
|
|
23200
|
+
this.ninePatchOptions.length = 0;
|
|
23124
23201
|
this.transformStack = [];
|
|
23125
23202
|
this.currentTransform = Matrix3.fromIdentity();
|
|
23203
|
+
this.clipStack = [];
|
|
23126
23204
|
this.currentBatchType = "colored";
|
|
23127
23205
|
this.currentBatchTexture = null;
|
|
23128
|
-
|
|
23129
|
-
|
|
23206
|
+
this.engine.setScissorTest(false);
|
|
23207
|
+
// 创建从屏幕坐标到 NDC 的投影矩阵,屏幕坐标:(0, 0) 在左上角,(width, height) 在右下角,+Y 向下。
|
|
23208
|
+
var bounds = this.engine.canvas.getBoundingClientRect();
|
|
23209
|
+
var width = bounds.width || this.engine.canvas.width / this.engine.pixelRatio || 1;
|
|
23210
|
+
var height = bounds.height || this.engine.canvas.height / this.engine.pixelRatio || 1;
|
|
23211
|
+
this.logicalWidth = width;
|
|
23212
|
+
this.logicalHeight = height;
|
|
23130
23213
|
// 正交投影矩阵:将屏幕坐标 [0, width] x [0, height] 映射到 NDC [-1, 1] x [-1, 1]
|
|
23131
|
-
var projectionMatrix = new Matrix4(2 / width, 0, 0, 0, 0, 2 / height, 0, 0, 0, 0, -1, 0, -1,
|
|
23214
|
+
var projectionMatrix = new Matrix4(2 / width, 0, 0, 0, 0, -2 / height, 0, 0, 0, 0, -1, 0, -1, 1, 0, 1 // 第四列
|
|
23132
23215
|
);
|
|
23133
23216
|
this.coloredMaterial.setMatrix("effects_MatrixVP", projectionMatrix);
|
|
23134
23217
|
this.texturedMaterial.setMatrix("effects_MatrixVP", projectionMatrix);
|
|
23135
23218
|
this.textMaterial.setMatrix("effects_MatrixVP", projectionMatrix);
|
|
23219
|
+
this.ninePatchMaterial.setMatrix("effects_MatrixVP", projectionMatrix);
|
|
23136
23220
|
};
|
|
23137
23221
|
/**
|
|
23138
23222
|
* 将当前变换压入栈,并设置新的变换
|
|
23139
23223
|
* @param transform - 新的变换矩阵(会与当前变换相乘)
|
|
23140
23224
|
*/ _proto.pushTransform = function pushTransform(transform) {
|
|
23141
23225
|
this.transformStack.push(this.currentTransform.clone());
|
|
23142
|
-
this.currentTransform = this.currentTransform.
|
|
23226
|
+
this.currentTransform = this.currentTransform.multiply(transform);
|
|
23143
23227
|
};
|
|
23144
23228
|
/**
|
|
23145
23229
|
* 恢复上一个变换
|
|
@@ -23151,10 +23235,81 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
23151
23235
|
}
|
|
23152
23236
|
this.currentTransform = transform;
|
|
23153
23237
|
};
|
|
23238
|
+
/** Pushes a local rectangular child clip using a screen-space AABB scissor. */ _proto.pushClipRect = function pushClipRect(x, y, width, height) {
|
|
23239
|
+
var elements = this.currentTransform.elements;
|
|
23240
|
+
var corners = [
|
|
23241
|
+
[
|
|
23242
|
+
x,
|
|
23243
|
+
y
|
|
23244
|
+
],
|
|
23245
|
+
[
|
|
23246
|
+
x + width,
|
|
23247
|
+
y
|
|
23248
|
+
],
|
|
23249
|
+
[
|
|
23250
|
+
x,
|
|
23251
|
+
y + height
|
|
23252
|
+
],
|
|
23253
|
+
[
|
|
23254
|
+
x + width,
|
|
23255
|
+
y + height
|
|
23256
|
+
]
|
|
23257
|
+
];
|
|
23258
|
+
var left = Infinity;
|
|
23259
|
+
var top = Infinity;
|
|
23260
|
+
var right = -Infinity;
|
|
23261
|
+
var bottom = -Infinity;
|
|
23262
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(corners), _step; !(_step = _iterator()).done;){
|
|
23263
|
+
var corner = _step.value;
|
|
23264
|
+
var transformedX = elements[0] * corner[0] + elements[3] * corner[1] + elements[6];
|
|
23265
|
+
var transformedY = elements[1] * corner[0] + elements[4] * corner[1] + elements[7];
|
|
23266
|
+
left = Math.min(left, transformedX);
|
|
23267
|
+
top = Math.min(top, transformedY);
|
|
23268
|
+
right = Math.max(right, transformedX);
|
|
23269
|
+
bottom = Math.max(bottom, transformedY);
|
|
23270
|
+
}
|
|
23271
|
+
var parent = this.clipStack[this.clipStack.length - 1];
|
|
23272
|
+
if (parent) {
|
|
23273
|
+
left = Math.max(left, parent.x);
|
|
23274
|
+
top = Math.max(top, parent.y);
|
|
23275
|
+
right = Math.min(right, parent.x + parent.width);
|
|
23276
|
+
bottom = Math.min(bottom, parent.y + parent.height);
|
|
23277
|
+
}
|
|
23278
|
+
var clip = {
|
|
23279
|
+
x: left,
|
|
23280
|
+
y: top,
|
|
23281
|
+
width: Math.max(0, right - left),
|
|
23282
|
+
height: Math.max(0, bottom - top)
|
|
23283
|
+
};
|
|
23284
|
+
var previous = parent;
|
|
23285
|
+
this.clipStack.push(clip);
|
|
23286
|
+
if (!this.clipRectsEqual(previous, clip)) {
|
|
23287
|
+
this.flushBatch();
|
|
23288
|
+
this.applyClipRect(clip);
|
|
23289
|
+
}
|
|
23290
|
+
};
|
|
23291
|
+
/** Restores the parent rectangular clip. */ _proto.popClipRect = function popClipRect() {
|
|
23292
|
+
var previous = this.clipStack.pop();
|
|
23293
|
+
if (!previous) {
|
|
23294
|
+
console.warn("Graphics: clip stack is empty.");
|
|
23295
|
+
return;
|
|
23296
|
+
}
|
|
23297
|
+
var clip = this.clipStack[this.clipStack.length - 1];
|
|
23298
|
+
if (!this.clipRectsEqual(previous, clip)) {
|
|
23299
|
+
this.flushBatch();
|
|
23300
|
+
if (clip) {
|
|
23301
|
+
this.applyClipRect(clip);
|
|
23302
|
+
} else {
|
|
23303
|
+
this.engine.setScissorTest(false);
|
|
23304
|
+
}
|
|
23305
|
+
}
|
|
23306
|
+
};
|
|
23154
23307
|
/**
|
|
23155
23308
|
* 刷新并渲染所有累积的绘制命令
|
|
23156
23309
|
*/ _proto.end = function end() {
|
|
23157
23310
|
this.flushBatch();
|
|
23311
|
+
this.clipStack = [];
|
|
23312
|
+
this.engine.setScissorTest(false);
|
|
23158
23313
|
};
|
|
23159
23314
|
/**
|
|
23160
23315
|
* 切换到指定批次类型/纹理。若与当前批次不一致,先 flush 已累积顶点
|
|
@@ -23167,6 +23322,24 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
23167
23322
|
this.currentBatchType = type;
|
|
23168
23323
|
this.currentBatchTexture = texture;
|
|
23169
23324
|
};
|
|
23325
|
+
_proto.applyClipRect = function applyClipRect(clip) {
|
|
23326
|
+
var framebufferWidth = this.engine.canvas.width;
|
|
23327
|
+
var framebufferHeight = this.engine.canvas.height;
|
|
23328
|
+
var scaleX = framebufferWidth / this.logicalWidth;
|
|
23329
|
+
var scaleY = framebufferHeight / this.logicalHeight;
|
|
23330
|
+
var left = Math.max(0, Math.min(framebufferWidth, Math.floor(clip.x * scaleX)));
|
|
23331
|
+
var top = Math.max(0, Math.min(framebufferHeight, Math.floor(clip.y * scaleY)));
|
|
23332
|
+
var right = Math.max(left, Math.min(framebufferWidth, Math.ceil((clip.x + clip.width) * scaleX)));
|
|
23333
|
+
var bottom = Math.max(top, Math.min(framebufferHeight, Math.ceil((clip.y + clip.height) * scaleY)));
|
|
23334
|
+
this.engine.setScissorTest(true);
|
|
23335
|
+
this.engine.setScissor(left, framebufferHeight - bottom, right - left, bottom - top);
|
|
23336
|
+
};
|
|
23337
|
+
_proto.clipRectsEqual = function clipRectsEqual(left, right) {
|
|
23338
|
+
if (!left || !right) {
|
|
23339
|
+
return left === right;
|
|
23340
|
+
}
|
|
23341
|
+
return left.x === right.x && left.y === right.y && left.width === right.width && left.height === right.height;
|
|
23342
|
+
};
|
|
23170
23343
|
/**
|
|
23171
23344
|
* 提交当前累积的顶点到 renderer,清空缓冲(批次内部 flush 不重置 batchType)
|
|
23172
23345
|
*/ _proto.flushBatch = function flushBatch() {
|
|
@@ -23180,37 +23353,48 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
23180
23353
|
var colorsArray = new Float32Array(this.colors);
|
|
23181
23354
|
var uvsArray = new Float32Array(this.uvs);
|
|
23182
23355
|
var indicesArray = new Uint16Array(this.indices);
|
|
23183
|
-
this.
|
|
23184
|
-
this.updateAttributeData(VertexBuffer.
|
|
23185
|
-
this.updateAttributeData(VertexBuffer.
|
|
23186
|
-
this.geometry.
|
|
23187
|
-
|
|
23356
|
+
var geometry = this.currentBatchType === "ninePatch" ? this.ninePatchGeometry : this.geometry;
|
|
23357
|
+
this.updateAttributeData(geometry, VertexBuffer.PositionKind, verticesArray, 2);
|
|
23358
|
+
this.updateAttributeData(geometry, VertexBuffer.ColorKind, colorsArray, 4);
|
|
23359
|
+
this.updateAttributeData(geometry, VertexBuffer.UVKind, uvsArray, 2);
|
|
23360
|
+
if (this.currentBatchType === "ninePatch") {
|
|
23361
|
+
this.updateAttributeData(geometry, NINE_PATCH_DRAW_SOURCE_SIZE, new Float32Array(this.ninePatchDrawSourceSizes), 4);
|
|
23362
|
+
this.updateAttributeData(geometry, NINE_PATCH_SOURCE_RECT, new Float32Array(this.ninePatchSourceRects), 4);
|
|
23363
|
+
this.updateAttributeData(geometry, NINE_PATCH_MARGINS, new Float32Array(this.ninePatchMargins), 4);
|
|
23364
|
+
this.updateAttributeData(geometry, NINE_PATCH_OPTIONS, new Float32Array(this.ninePatchOptions), 4);
|
|
23365
|
+
}
|
|
23366
|
+
geometry.setIndexData(indicesArray);
|
|
23367
|
+
geometry.setDrawCount(this.currentIndexCount);
|
|
23188
23368
|
var material;
|
|
23189
|
-
if (this.currentBatchType === "textured" || this.currentBatchType === "text") {
|
|
23190
|
-
material = this.currentBatchType === "text" ? this.textMaterial : this.texturedMaterial;
|
|
23369
|
+
if (this.currentBatchType === "textured" || this.currentBatchType === "text" || this.currentBatchType === "ninePatch") {
|
|
23370
|
+
material = this.currentBatchType === "text" ? this.textMaterial : this.currentBatchType === "ninePatch" ? this.ninePatchMaterial : this.texturedMaterial;
|
|
23191
23371
|
var _this_currentBatchTexture;
|
|
23192
23372
|
var tex = (_this_currentBatchTexture = this.currentBatchTexture) != null ? _this_currentBatchTexture : this.engine.whiteTexture;
|
|
23193
23373
|
material.setTexture("uMainTexture", tex);
|
|
23194
23374
|
} else {
|
|
23195
23375
|
material = this.coloredMaterial;
|
|
23196
23376
|
}
|
|
23197
|
-
this.engine.renderer.drawGeometry(
|
|
23377
|
+
this.engine.renderer.drawGeometry(geometry, Matrix4.IDENTITY, material);
|
|
23198
23378
|
this.indices.length = 0;
|
|
23199
23379
|
this.vertices.length = 0;
|
|
23200
23380
|
this.colors.length = 0;
|
|
23201
23381
|
this.uvs.length = 0;
|
|
23202
|
-
|
|
23203
|
-
|
|
23204
|
-
|
|
23205
|
-
|
|
23382
|
+
this.ninePatchDrawSourceSizes.length = 0;
|
|
23383
|
+
this.ninePatchSourceRects.length = 0;
|
|
23384
|
+
this.ninePatchMargins.length = 0;
|
|
23385
|
+
this.ninePatchOptions.length = 0;
|
|
23386
|
+
};
|
|
23387
|
+
_proto.updateAttributeData = function updateAttributeData(geometry, name, data, size) {
|
|
23388
|
+
var _geometry_getVertexBuffer;
|
|
23389
|
+
var dataBuffer = (_geometry_getVertexBuffer = geometry.getVertexBuffer(name)) == null ? void 0 : _geometry_getVertexBuffer.getBuffer();
|
|
23206
23390
|
if (dataBuffer && data.byteLength > dataBuffer.capacity) {
|
|
23207
|
-
|
|
23391
|
+
geometry.setVerticesBuffer(new VertexBuffer(this.engine, data, name, {
|
|
23208
23392
|
updatable: true,
|
|
23209
23393
|
size: size
|
|
23210
23394
|
}));
|
|
23211
23395
|
return;
|
|
23212
23396
|
}
|
|
23213
|
-
|
|
23397
|
+
geometry.setAttributeData(name, data);
|
|
23214
23398
|
};
|
|
23215
23399
|
/**
|
|
23216
23400
|
* 线段顶点按顺序连接 (p0-p1, p1-p2, p2-p3, ...)
|
|
@@ -23293,8 +23477,8 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
23293
23477
|
};
|
|
23294
23478
|
/**
|
|
23295
23479
|
* 绘制矩形边框
|
|
23296
|
-
* @param x -
|
|
23297
|
-
* @param y -
|
|
23480
|
+
* @param x - 矩形左上角 X 坐标
|
|
23481
|
+
* @param y - 矩形左上角 Y 坐标
|
|
23298
23482
|
* @param width - 矩形宽度
|
|
23299
23483
|
* @param height - 矩形高度
|
|
23300
23484
|
* @param color - 边框颜色,默认白色,范围 0-1
|
|
@@ -23337,8 +23521,8 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
23337
23521
|
};
|
|
23338
23522
|
/**
|
|
23339
23523
|
* 绘制填充矩形
|
|
23340
|
-
* @param x -
|
|
23341
|
-
* @param y -
|
|
23524
|
+
* @param x - 矩形左上角 X 坐标
|
|
23525
|
+
* @param y - 矩形左上角 Y 坐标
|
|
23342
23526
|
* @param width - 矩形宽度
|
|
23343
23527
|
* @param height - 矩形高度
|
|
23344
23528
|
* @param color - 填充颜色,默认白色,范围 0-1
|
|
@@ -23364,9 +23548,9 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
23364
23548
|
this.buildShape(this.circleShape, color);
|
|
23365
23549
|
};
|
|
23366
23550
|
/**
|
|
23367
|
-
* 绘制纹理矩形(本地坐标,Y
|
|
23368
|
-
* @param x -
|
|
23369
|
-
* @param y -
|
|
23551
|
+
* 绘制纹理矩形(本地坐标,Y 向下,(x, y) 为左上角)
|
|
23552
|
+
* @param x - 矩形左上角 X 坐标
|
|
23553
|
+
* @param y - 矩形左上角 Y 坐标
|
|
23370
23554
|
* @param width - 矩形宽度
|
|
23371
23555
|
* @param height - 矩形高度
|
|
23372
23556
|
* @param texture - 要采样的纹理。同纹理连续绘制会合批,纹理切换会自动 flush 当前批次
|
|
@@ -23379,14 +23563,41 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
23379
23563
|
this.pushQuad(x, y, width, height, color, region);
|
|
23380
23564
|
};
|
|
23381
23565
|
/**
|
|
23382
|
-
*
|
|
23566
|
+
* Draws a nine-patch as one quad. Stretching and repetition are resolved in the fragment shader,
|
|
23567
|
+
* so Tile and TileFit do not expand into CPU-side geometry.
|
|
23568
|
+
*/ _proto.drawNinePatch = function drawNinePatch(x, y, width, height, texture, options, color) {
|
|
23569
|
+
if (color === void 0) color = Color.WHITE;
|
|
23570
|
+
if (width <= 0 || height <= 0 || options.sourceWidth <= 0 || options.sourceHeight <= 0) {
|
|
23571
|
+
return;
|
|
23572
|
+
}
|
|
23573
|
+
this.ensureBatch("ninePatch", texture);
|
|
23574
|
+
var sourceU = options.sourceX / texture.width;
|
|
23575
|
+
var sourceV = 1 - options.sourceY / texture.height;
|
|
23576
|
+
var sourceUSize = options.sourceWidth / texture.width;
|
|
23577
|
+
var sourceVSize = options.sourceHeight / texture.height;
|
|
23578
|
+
var _options_horizontalMode;
|
|
23579
|
+
var horizontalMode = (_options_horizontalMode = options.horizontalMode) != null ? _options_horizontalMode : 0;
|
|
23580
|
+
var _options_verticalMode;
|
|
23581
|
+
var verticalMode = (_options_verticalMode = options.verticalMode) != null ? _options_verticalMode : 0;
|
|
23582
|
+
var _options_drawCenter;
|
|
23583
|
+
var drawCenter = Number((_options_drawCenter = options.drawCenter) != null ? _options_drawCenter : true);
|
|
23584
|
+
this.pushQuad(x, y, width, height, color, FULL_REGION);
|
|
23585
|
+
for(var i = 0; i < 4; i++){
|
|
23586
|
+
this.ninePatchDrawSourceSizes.push(width, height, options.sourceWidth, options.sourceHeight);
|
|
23587
|
+
this.ninePatchSourceRects.push(sourceU, sourceV, sourceUSize, sourceVSize);
|
|
23588
|
+
this.ninePatchMargins.push(options.marginLeft, options.marginTop, options.marginRight, options.marginBottom);
|
|
23589
|
+
this.ninePatchOptions.push(horizontalMode, verticalMode, drawCenter, 0);
|
|
23590
|
+
}
|
|
23591
|
+
};
|
|
23592
|
+
/**
|
|
23593
|
+
* 绘制文本(本地坐标,Y 向下,(x, y) 为文本 cell 左上角)。
|
|
23383
23594
|
*
|
|
23384
23595
|
* 文本走字符级 bitmap atlas(同一字体下每个字只渲染一次,任意文本组合复用 atlas);
|
|
23385
|
-
* `color`
|
|
23596
|
+
* `color` 与 atlas 字形 RGBA 相乘,任意颜色都不会污染 atlas。
|
|
23386
23597
|
*
|
|
23387
23598
|
* 字体参数全部展开,避免调用方每帧创建临时 style 对象触发 GC
|
|
23388
|
-
* @param x -
|
|
23389
|
-
* @param y -
|
|
23599
|
+
* @param x - 文本左上角 X 坐标(首字 ink 起始处,含 padding 的 quad 会向左延伸)
|
|
23600
|
+
* @param y - 文本 cell 顶部 Y 坐标
|
|
23390
23601
|
* @param text - 要绘制的文本内容,空串直接 return
|
|
23391
23602
|
* @param fontSize - 字号(逻辑像素)
|
|
23392
23603
|
* @param color - 乘色,默认白色,范围 0-1
|
|
@@ -23405,10 +23616,11 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
23405
23616
|
this.ensureBatch("text", atlas.texture);
|
|
23406
23617
|
var lineHeight = atlas.lineHeight;
|
|
23407
23618
|
var cursorX = x;
|
|
23619
|
+
var characters = Array.from(text);
|
|
23408
23620
|
// ensureChar 可能往 atlas canvas 写新字并打 dirty 标;实际 upload 推迟到
|
|
23409
23621
|
// flushBatch 统一处理,这样一帧多次 drawText 共写同一 atlas 只 upload 一次
|
|
23410
|
-
for(var i = 0; i <
|
|
23411
|
-
var info = atlas.ensureChar(
|
|
23622
|
+
for(var i = 0; i < characters.length; i++){
|
|
23623
|
+
var info = atlas.ensureChar(characters[i]);
|
|
23412
23624
|
if (!info) {
|
|
23413
23625
|
continue;
|
|
23414
23626
|
}
|
|
@@ -23430,11 +23642,35 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
23430
23642
|
cursorX += info.advance;
|
|
23431
23643
|
}
|
|
23432
23644
|
};
|
|
23645
|
+
/** Measures text with the same glyph metrics used by {@link drawText}. */ _proto.measureText = function measureText(text, fontSize, fontFamily, fontWeight, fontStyle) {
|
|
23646
|
+
if (fontFamily === void 0) fontFamily = "sans-serif";
|
|
23647
|
+
if (fontWeight === void 0) fontWeight = "normal";
|
|
23648
|
+
if (fontStyle === void 0) fontStyle = "normal";
|
|
23649
|
+
var atlas = this.textCache.getAtlas(fontSize, fontFamily, fontWeight, fontStyle);
|
|
23650
|
+
var characters = Array.from(text);
|
|
23651
|
+
var advances = [];
|
|
23652
|
+
var width = 0;
|
|
23653
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(characters), _step; !(_step = _iterator()).done;){
|
|
23654
|
+
var character = _step.value;
|
|
23655
|
+
var _atlas_ensureChar;
|
|
23656
|
+
var _atlas_ensureChar_advance;
|
|
23657
|
+
var advance = (_atlas_ensureChar_advance = (_atlas_ensureChar = atlas.ensureChar(character)) == null ? void 0 : _atlas_ensureChar.advance) != null ? _atlas_ensureChar_advance : 0;
|
|
23658
|
+
advances.push(advance);
|
|
23659
|
+
width += advance;
|
|
23660
|
+
}
|
|
23661
|
+
return {
|
|
23662
|
+
width: width,
|
|
23663
|
+
lineHeight: atlas.lineHeight,
|
|
23664
|
+
advances: advances
|
|
23665
|
+
};
|
|
23666
|
+
};
|
|
23433
23667
|
_proto.dispose = function dispose() {
|
|
23434
23668
|
this.geometry.dispose();
|
|
23669
|
+
this.ninePatchGeometry.dispose();
|
|
23435
23670
|
this.coloredMaterial.dispose();
|
|
23436
23671
|
this.texturedMaterial.dispose();
|
|
23437
23672
|
this.textMaterial.dispose();
|
|
23673
|
+
this.ninePatchMaterial.dispose();
|
|
23438
23674
|
this.textCache.dispose();
|
|
23439
23675
|
};
|
|
23440
23676
|
_proto.buildShape = function buildShape(shape, color) {
|
|
@@ -23442,7 +23678,7 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
23442
23678
|
var indexOffset = this.indices.length;
|
|
23443
23679
|
var vertexOffset = this.vertices.length / 2;
|
|
23444
23680
|
buildPoints.length = 0;
|
|
23445
|
-
shape.build(buildPoints);
|
|
23681
|
+
shape.build(buildPoints, this.getScreenScale());
|
|
23446
23682
|
shape.triangulate(buildPoints, this.vertices, vertexOffset, this.indices, indexOffset);
|
|
23447
23683
|
this.applyTransformAndColor(vertexOffset, this.vertices.length / 2 - vertexOffset, color);
|
|
23448
23684
|
};
|
|
@@ -23452,11 +23688,19 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
23452
23688
|
this.indices.length;
|
|
23453
23689
|
var vertexOffset = this.vertices.length / 2;
|
|
23454
23690
|
buildPoints.length = 0;
|
|
23455
|
-
shape.build(buildPoints);
|
|
23691
|
+
shape.build(buildPoints, this.getScreenScale());
|
|
23456
23692
|
this.lineStyle.width = thickness;
|
|
23457
23693
|
buildLine(buildPoints, this.lineStyle, false, closed, this.vertices, 2, vertexOffset, this.indices);
|
|
23458
23694
|
this.applyTransformAndColor(vertexOffset, this.vertices.length / 2 - vertexOffset, color);
|
|
23459
23695
|
};
|
|
23696
|
+
_proto.getScreenScale = function getScreenScale() {
|
|
23697
|
+
var transform = this.currentTransform.elements;
|
|
23698
|
+
var transformScaleX = Math.hypot(transform[0], transform[1]);
|
|
23699
|
+
var transformScaleY = Math.hypot(transform[3], transform[4]);
|
|
23700
|
+
var framebufferScaleX = this.engine.canvas.width / this.logicalWidth;
|
|
23701
|
+
var framebufferScaleY = this.engine.canvas.height / this.logicalHeight;
|
|
23702
|
+
return Math.max(transformScaleX * framebufferScaleX, transformScaleY * framebufferScaleY, 1);
|
|
23703
|
+
};
|
|
23460
23704
|
_proto.setTriangleShape = function setTriangleShape(x1, y1, x2, y2, x3, y3) {
|
|
23461
23705
|
this.triangleShape.x = x1;
|
|
23462
23706
|
this.triangleShape.y = y1;
|
|
@@ -23501,7 +23745,7 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
23501
23745
|
* 在像素级亚像素精度下会暴露 1-2 像素缝隙,叠层时底层颜色透出形成可见的对角痕迹
|
|
23502
23746
|
*/ _proto.pushQuad = function pushQuad(x, y, width, height, color, region) {
|
|
23503
23747
|
var vertexOffset = this.vertices.length / 2;
|
|
23504
|
-
// 4
|
|
23748
|
+
// 4 顶点(本地坐标,左上/右上/左下/右下),应用当前变换写入 vertices
|
|
23505
23749
|
var corners = [
|
|
23506
23750
|
[
|
|
23507
23751
|
x,
|
|
@@ -23527,19 +23771,19 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
23527
23771
|
var cornerUVs = [
|
|
23528
23772
|
[
|
|
23529
23773
|
u0,
|
|
23530
|
-
|
|
23774
|
+
v1
|
|
23531
23775
|
],
|
|
23532
23776
|
[
|
|
23533
23777
|
u1,
|
|
23534
|
-
|
|
23778
|
+
v1
|
|
23535
23779
|
],
|
|
23536
23780
|
[
|
|
23537
23781
|
u0,
|
|
23538
|
-
|
|
23782
|
+
v0
|
|
23539
23783
|
],
|
|
23540
23784
|
[
|
|
23541
23785
|
u1,
|
|
23542
|
-
|
|
23786
|
+
v0
|
|
23543
23787
|
]
|
|
23544
23788
|
];
|
|
23545
23789
|
for(var i = 0; i < 4; i++){
|
|
@@ -24505,2086 +24749,6 @@ exports.FrameComponent = __decorate([
|
|
|
24505
24749
|
// 第四列 (位移) 乘 1,无需修改
|
|
24506
24750
|
}
|
|
24507
24751
|
|
|
24508
|
-
function _assert_this_initialized(self) {
|
|
24509
|
-
if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
24510
|
-
return self;
|
|
24511
|
-
}
|
|
24512
|
-
|
|
24513
|
-
exports.MouseFilter = void 0;
|
|
24514
|
-
(function(MouseFilter) {
|
|
24515
|
-
MouseFilter[MouseFilter["Stop"] = 0] = "Stop";
|
|
24516
|
-
MouseFilter[MouseFilter["Pass"] = 1] = "Pass";
|
|
24517
|
-
MouseFilter[MouseFilter["Ignore"] = 2] = "Ignore";
|
|
24518
|
-
})(exports.MouseFilter || (exports.MouseFilter = {}));
|
|
24519
|
-
exports.MouseBehaviorRecursive = void 0;
|
|
24520
|
-
(function(MouseBehaviorRecursive) {
|
|
24521
|
-
MouseBehaviorRecursive[MouseBehaviorRecursive["Inherited"] = 0] = "Inherited";
|
|
24522
|
-
MouseBehaviorRecursive[MouseBehaviorRecursive["Disabled"] = 1] = "Disabled";
|
|
24523
|
-
MouseBehaviorRecursive[MouseBehaviorRecursive["Enabled"] = 2] = "Enabled";
|
|
24524
|
-
})(exports.MouseBehaviorRecursive || (exports.MouseBehaviorRecursive = {}));
|
|
24525
|
-
exports.MouseButton = void 0;
|
|
24526
|
-
(function(MouseButton) {
|
|
24527
|
-
MouseButton[MouseButton["None"] = 0] = "None";
|
|
24528
|
-
MouseButton[MouseButton["Left"] = 1] = "Left";
|
|
24529
|
-
MouseButton[MouseButton["Right"] = 2] = "Right";
|
|
24530
|
-
MouseButton[MouseButton["Middle"] = 3] = "Middle";
|
|
24531
|
-
MouseButton[MouseButton["WheelUp"] = 4] = "WheelUp";
|
|
24532
|
-
MouseButton[MouseButton["WheelDown"] = 5] = "WheelDown";
|
|
24533
|
-
MouseButton[MouseButton["WheelLeft"] = 6] = "WheelLeft";
|
|
24534
|
-
MouseButton[MouseButton["WheelRight"] = 7] = "WheelRight";
|
|
24535
|
-
MouseButton[MouseButton["Xbutton1"] = 8] = "Xbutton1";
|
|
24536
|
-
MouseButton[MouseButton["Xbutton2"] = 9] = "Xbutton2";
|
|
24537
|
-
})(exports.MouseButton || (exports.MouseButton = {}));
|
|
24538
|
-
exports.MouseButtonMask = void 0;
|
|
24539
|
-
(function(MouseButtonMask) {
|
|
24540
|
-
MouseButtonMask[MouseButtonMask["None"] = 0] = "None";
|
|
24541
|
-
MouseButtonMask[MouseButtonMask["Left"] = 1] = "Left";
|
|
24542
|
-
MouseButtonMask[MouseButtonMask["Right"] = 2] = "Right";
|
|
24543
|
-
MouseButtonMask[MouseButtonMask["Middle"] = 4] = "Middle";
|
|
24544
|
-
MouseButtonMask[MouseButtonMask["Xbutton1"] = 128] = "Xbutton1";
|
|
24545
|
-
MouseButtonMask[MouseButtonMask["Xbutton2"] = 256] = "Xbutton2";
|
|
24546
|
-
})(exports.MouseButtonMask || (exports.MouseButtonMask = {}));
|
|
24547
|
-
exports.FocusMode = void 0;
|
|
24548
|
-
(function(FocusMode) {
|
|
24549
|
-
FocusMode[FocusMode["None"] = 0] = "None";
|
|
24550
|
-
FocusMode[FocusMode["Click"] = 1] = "Click";
|
|
24551
|
-
FocusMode[FocusMode["All"] = 2] = "All";
|
|
24552
|
-
FocusMode[FocusMode["Accessibility"] = 3] = "Accessibility";
|
|
24553
|
-
})(exports.FocusMode || (exports.FocusMode = {}));
|
|
24554
|
-
exports.FocusBehaviorRecursive = void 0;
|
|
24555
|
-
(function(FocusBehaviorRecursive) {
|
|
24556
|
-
FocusBehaviorRecursive[FocusBehaviorRecursive["Inherited"] = 0] = "Inherited";
|
|
24557
|
-
FocusBehaviorRecursive[FocusBehaviorRecursive["Disabled"] = 1] = "Disabled";
|
|
24558
|
-
FocusBehaviorRecursive[FocusBehaviorRecursive["Enabled"] = 2] = "Enabled";
|
|
24559
|
-
})(exports.FocusBehaviorRecursive || (exports.FocusBehaviorRecursive = {}));
|
|
24560
|
-
exports.KeyLocation = void 0;
|
|
24561
|
-
(function(KeyLocation) {
|
|
24562
|
-
KeyLocation[KeyLocation["Unspecified"] = 0] = "Unspecified";
|
|
24563
|
-
KeyLocation[KeyLocation["Left"] = 1] = "Left";
|
|
24564
|
-
KeyLocation[KeyLocation["Right"] = 2] = "Right";
|
|
24565
|
-
})(exports.KeyLocation || (exports.KeyLocation = {}));
|
|
24566
|
-
exports.CursorShape = void 0;
|
|
24567
|
-
(function(CursorShape) {
|
|
24568
|
-
CursorShape[CursorShape["Arrow"] = 0] = "Arrow";
|
|
24569
|
-
CursorShape[CursorShape["Ibeam"] = 1] = "Ibeam";
|
|
24570
|
-
CursorShape[CursorShape["PointingHand"] = 2] = "PointingHand";
|
|
24571
|
-
CursorShape[CursorShape["Cross"] = 3] = "Cross";
|
|
24572
|
-
CursorShape[CursorShape["Wait"] = 4] = "Wait";
|
|
24573
|
-
CursorShape[CursorShape["Busy"] = 5] = "Busy";
|
|
24574
|
-
CursorShape[CursorShape["Drag"] = 6] = "Drag";
|
|
24575
|
-
CursorShape[CursorShape["CanDrop"] = 7] = "CanDrop";
|
|
24576
|
-
CursorShape[CursorShape["Forbidden"] = 8] = "Forbidden";
|
|
24577
|
-
CursorShape[CursorShape["Vsize"] = 9] = "Vsize";
|
|
24578
|
-
CursorShape[CursorShape["Hsize"] = 10] = "Hsize";
|
|
24579
|
-
CursorShape[CursorShape["Bdiagsize"] = 11] = "Bdiagsize";
|
|
24580
|
-
CursorShape[CursorShape["Fdiagsize"] = 12] = "Fdiagsize";
|
|
24581
|
-
CursorShape[CursorShape["Move"] = 13] = "Move";
|
|
24582
|
-
CursorShape[CursorShape["Vsplit"] = 14] = "Vsplit";
|
|
24583
|
-
CursorShape[CursorShape["Hsplit"] = 15] = "Hsplit";
|
|
24584
|
-
CursorShape[CursorShape["Help"] = 16] = "Help";
|
|
24585
|
-
})(exports.CursorShape || (exports.CursorShape = {}));
|
|
24586
|
-
|
|
24587
|
-
function _get_prototype_of(o) {
|
|
24588
|
-
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
24589
|
-
return o.__proto__ || Object.getPrototypeOf(o);
|
|
24590
|
-
};
|
|
24591
|
-
return _get_prototype_of(o);
|
|
24592
|
-
}
|
|
24593
|
-
|
|
24594
|
-
function _is_native_function(fn) {
|
|
24595
|
-
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
24596
|
-
}
|
|
24597
|
-
|
|
24598
|
-
function _wrap_native_super(Class) {
|
|
24599
|
-
var _cache = typeof Map === "function" ? new Map() : undefined;
|
|
24600
|
-
_wrap_native_super = function _wrap_native_super(Class) {
|
|
24601
|
-
if (Class === null || !_is_native_function(Class)) return Class;
|
|
24602
|
-
if (typeof Class !== "function") throw new TypeError("Super expression must either be null or a function");
|
|
24603
|
-
if (typeof _cache !== "undefined") {
|
|
24604
|
-
if (_cache.has(Class)) return _cache.get(Class);
|
|
24605
|
-
_cache.set(Class, Wrapper);
|
|
24606
|
-
}
|
|
24607
|
-
function Wrapper() {
|
|
24608
|
-
return _construct(Class, arguments, _get_prototype_of(this).constructor);
|
|
24609
|
-
}
|
|
24610
|
-
Wrapper.prototype = Object.create(Class.prototype, {
|
|
24611
|
-
constructor: {
|
|
24612
|
-
value: Wrapper,
|
|
24613
|
-
enumerable: false,
|
|
24614
|
-
writable: true,
|
|
24615
|
-
configurable: true
|
|
24616
|
-
}
|
|
24617
|
-
});
|
|
24618
|
-
return _set_prototype_of(Wrapper, Class);
|
|
24619
|
-
};
|
|
24620
|
-
return _wrap_native_super(Class);
|
|
24621
|
-
}
|
|
24622
|
-
|
|
24623
|
-
function transformPoint(transform, value) {
|
|
24624
|
-
var elements = transform.elements;
|
|
24625
|
-
return new Vector2(elements[0] * value.x + elements[3] * value.y + elements[6], elements[1] * value.x + elements[4] * value.y + elements[7]);
|
|
24626
|
-
}
|
|
24627
|
-
function transformVector(transform, value) {
|
|
24628
|
-
var elements = transform.elements;
|
|
24629
|
-
return new Vector2(elements[0] * value.x + elements[3] * value.y, elements[1] * value.x + elements[4] * value.y);
|
|
24630
|
-
}
|
|
24631
|
-
var InputEvent = /*#__PURE__*/ function() {
|
|
24632
|
-
function InputEvent() {
|
|
24633
|
-
this.device = 0;
|
|
24634
|
-
this.pressed = false;
|
|
24635
|
-
this.canceled = false;
|
|
24636
|
-
}
|
|
24637
|
-
var _proto = InputEvent.prototype;
|
|
24638
|
-
_proto.isPressed = function isPressed() {
|
|
24639
|
-
return this.pressed && !this.canceled;
|
|
24640
|
-
};
|
|
24641
|
-
_proto.isReleased = function isReleased() {
|
|
24642
|
-
return !this.pressed && !this.canceled;
|
|
24643
|
-
};
|
|
24644
|
-
_proto.isCanceled = function isCanceled() {
|
|
24645
|
-
return this.canceled;
|
|
24646
|
-
};
|
|
24647
|
-
_proto.isEcho = function isEcho() {
|
|
24648
|
-
return false;
|
|
24649
|
-
};
|
|
24650
|
-
_proto.xformedBy = function xformedBy(transform) {
|
|
24651
|
-
var event = new InputEvent();
|
|
24652
|
-
event.device = this.device;
|
|
24653
|
-
event.pressed = this.pressed;
|
|
24654
|
-
event.canceled = this.canceled;
|
|
24655
|
-
return event;
|
|
24656
|
-
};
|
|
24657
|
-
return InputEvent;
|
|
24658
|
-
}();
|
|
24659
|
-
InputEvent.deviceIdEmulation = -1;
|
|
24660
|
-
InputEvent.deviceIdInternal = -2;
|
|
24661
|
-
InputEvent.deviceIdKeyboard = 16;
|
|
24662
|
-
InputEvent.deviceIdMouse = 32;
|
|
24663
|
-
var InputEventWithModifiers = /*#__PURE__*/ function(InputEvent) {
|
|
24664
|
-
_inherits(InputEventWithModifiers, InputEvent);
|
|
24665
|
-
function InputEventWithModifiers() {
|
|
24666
|
-
var _this;
|
|
24667
|
-
_this = InputEvent.apply(this, arguments) || this;
|
|
24668
|
-
_this.commandOrControlAutoremap = false;
|
|
24669
|
-
_this.shiftPressed = false;
|
|
24670
|
-
_this.altPressed = false;
|
|
24671
|
-
_this.metaPressed = false;
|
|
24672
|
-
_this.ctrlPressed = false;
|
|
24673
|
-
return _this;
|
|
24674
|
-
}
|
|
24675
|
-
var _proto = InputEventWithModifiers.prototype;
|
|
24676
|
-
_proto.copyModifiersTo = function copyModifiersTo(event) {
|
|
24677
|
-
event.device = this.device;
|
|
24678
|
-
event.pressed = this.pressed;
|
|
24679
|
-
event.canceled = this.canceled;
|
|
24680
|
-
event.commandOrControlAutoremap = this.commandOrControlAutoremap;
|
|
24681
|
-
event.shiftPressed = this.shiftPressed;
|
|
24682
|
-
event.altPressed = this.altPressed;
|
|
24683
|
-
event.metaPressed = this.metaPressed;
|
|
24684
|
-
event.ctrlPressed = this.ctrlPressed;
|
|
24685
|
-
};
|
|
24686
|
-
_proto.xformedBy = function xformedBy(transform) {
|
|
24687
|
-
var event = new InputEventWithModifiers();
|
|
24688
|
-
this.copyModifiersTo(event);
|
|
24689
|
-
return event;
|
|
24690
|
-
};
|
|
24691
|
-
return InputEventWithModifiers;
|
|
24692
|
-
}(_wrap_native_super(InputEvent));
|
|
24693
|
-
var InputEventKey = /*#__PURE__*/ function(InputEventWithModifiers) {
|
|
24694
|
-
_inherits(InputEventKey, InputEventWithModifiers);
|
|
24695
|
-
function InputEventKey() {
|
|
24696
|
-
var _this;
|
|
24697
|
-
_this = InputEventWithModifiers.apply(this, arguments) || this;
|
|
24698
|
-
_this.keycode = "";
|
|
24699
|
-
_this.physicalKeycode = "";
|
|
24700
|
-
_this.keyLabel = "";
|
|
24701
|
-
_this.unicode = 0;
|
|
24702
|
-
_this.location = exports.KeyLocation.Unspecified;
|
|
24703
|
-
_this.echo = false;
|
|
24704
|
-
return _this;
|
|
24705
|
-
}
|
|
24706
|
-
var _proto = InputEventKey.prototype;
|
|
24707
|
-
_proto.isEcho = function isEcho() {
|
|
24708
|
-
return this.echo;
|
|
24709
|
-
};
|
|
24710
|
-
_proto.xformedBy = function xformedBy(transform) {
|
|
24711
|
-
var event = new InputEventKey();
|
|
24712
|
-
this.copyModifiersTo(event);
|
|
24713
|
-
event.keycode = this.keycode;
|
|
24714
|
-
event.physicalKeycode = this.physicalKeycode;
|
|
24715
|
-
event.keyLabel = this.keyLabel;
|
|
24716
|
-
event.unicode = this.unicode;
|
|
24717
|
-
event.location = this.location;
|
|
24718
|
-
event.echo = this.echo;
|
|
24719
|
-
return event;
|
|
24720
|
-
};
|
|
24721
|
-
return InputEventKey;
|
|
24722
|
-
}(InputEventWithModifiers);
|
|
24723
|
-
var InputEventMouse = /*#__PURE__*/ function(InputEventWithModifiers) {
|
|
24724
|
-
_inherits(InputEventMouse, InputEventWithModifiers);
|
|
24725
|
-
function InputEventMouse() {
|
|
24726
|
-
var _this;
|
|
24727
|
-
_this = InputEventWithModifiers.apply(this, arguments) || this;
|
|
24728
|
-
_this.buttonMask = exports.MouseButtonMask.None;
|
|
24729
|
-
_this.position = new Vector2();
|
|
24730
|
-
_this.globalPosition = new Vector2();
|
|
24731
|
-
return _this;
|
|
24732
|
-
}
|
|
24733
|
-
var _proto = InputEventMouse.prototype;
|
|
24734
|
-
_proto.copyMouseTo = function copyMouseTo(event) {
|
|
24735
|
-
this.copyModifiersTo(event);
|
|
24736
|
-
event.buttonMask = this.buttonMask;
|
|
24737
|
-
event.position.copyFrom(this.position);
|
|
24738
|
-
event.globalPosition.copyFrom(this.globalPosition);
|
|
24739
|
-
};
|
|
24740
|
-
_proto.xformedBy = function xformedBy(transform) {
|
|
24741
|
-
var event = new InputEventMouse();
|
|
24742
|
-
this.copyMouseTo(event);
|
|
24743
|
-
event.position.copyFrom(transformPoint(transform, this.position));
|
|
24744
|
-
return event;
|
|
24745
|
-
};
|
|
24746
|
-
return InputEventMouse;
|
|
24747
|
-
}(InputEventWithModifiers);
|
|
24748
|
-
var InputEventMouseButton = /*#__PURE__*/ function(InputEventMouse) {
|
|
24749
|
-
_inherits(InputEventMouseButton, InputEventMouse);
|
|
24750
|
-
function InputEventMouseButton() {
|
|
24751
|
-
var _this;
|
|
24752
|
-
_this = InputEventMouse.apply(this, arguments) || this;
|
|
24753
|
-
_this.factor = 1;
|
|
24754
|
-
_this.buttonIndex = exports.MouseButton.None;
|
|
24755
|
-
_this.doubleClick = false;
|
|
24756
|
-
return _this;
|
|
24757
|
-
}
|
|
24758
|
-
var _proto = InputEventMouseButton.prototype;
|
|
24759
|
-
_proto.xformedBy = function xformedBy(transform) {
|
|
24760
|
-
var event = new InputEventMouseButton();
|
|
24761
|
-
this.copyMouseTo(event);
|
|
24762
|
-
event.position.copyFrom(transformPoint(transform, this.position));
|
|
24763
|
-
event.factor = this.factor;
|
|
24764
|
-
event.buttonIndex = this.buttonIndex;
|
|
24765
|
-
event.doubleClick = this.doubleClick;
|
|
24766
|
-
return event;
|
|
24767
|
-
};
|
|
24768
|
-
return InputEventMouseButton;
|
|
24769
|
-
}(InputEventMouse);
|
|
24770
|
-
var InputEventMouseMotion = /*#__PURE__*/ function(InputEventMouse) {
|
|
24771
|
-
_inherits(InputEventMouseMotion, InputEventMouse);
|
|
24772
|
-
function InputEventMouseMotion() {
|
|
24773
|
-
var _this;
|
|
24774
|
-
_this = InputEventMouse.apply(this, arguments) || this;
|
|
24775
|
-
_this.tilt = new Vector2();
|
|
24776
|
-
_this.pressure = 0;
|
|
24777
|
-
_this.relative = new Vector2();
|
|
24778
|
-
_this.screenRelative = new Vector2();
|
|
24779
|
-
_this.velocity = new Vector2();
|
|
24780
|
-
_this.screenVelocity = new Vector2();
|
|
24781
|
-
_this.penInverted = false;
|
|
24782
|
-
return _this;
|
|
24783
|
-
}
|
|
24784
|
-
var _proto = InputEventMouseMotion.prototype;
|
|
24785
|
-
_proto.xformedBy = function xformedBy(transform) {
|
|
24786
|
-
var event = new InputEventMouseMotion();
|
|
24787
|
-
this.copyMouseTo(event);
|
|
24788
|
-
event.position.copyFrom(transformPoint(transform, this.position));
|
|
24789
|
-
event.tilt.copyFrom(this.tilt);
|
|
24790
|
-
event.pressure = this.pressure;
|
|
24791
|
-
event.relative.copyFrom(transformVector(transform, this.relative));
|
|
24792
|
-
event.screenRelative.copyFrom(this.screenRelative);
|
|
24793
|
-
event.velocity.copyFrom(transformVector(transform, this.velocity));
|
|
24794
|
-
event.screenVelocity.copyFrom(this.screenVelocity);
|
|
24795
|
-
event.penInverted = this.penInverted;
|
|
24796
|
-
return event;
|
|
24797
|
-
};
|
|
24798
|
-
return InputEventMouseMotion;
|
|
24799
|
-
}(InputEventMouse);
|
|
24800
|
-
var InputEventScreenTouch = /*#__PURE__*/ function(InputEvent) {
|
|
24801
|
-
_inherits(InputEventScreenTouch, InputEvent);
|
|
24802
|
-
function InputEventScreenTouch() {
|
|
24803
|
-
var _this;
|
|
24804
|
-
_this = InputEvent.apply(this, arguments) || this;
|
|
24805
|
-
_this.index = 0;
|
|
24806
|
-
_this.position = new Vector2();
|
|
24807
|
-
_this.doubleTap = false;
|
|
24808
|
-
return _this;
|
|
24809
|
-
}
|
|
24810
|
-
var _proto = InputEventScreenTouch.prototype;
|
|
24811
|
-
_proto.xformedBy = function xformedBy(transform) {
|
|
24812
|
-
var event = new InputEventScreenTouch();
|
|
24813
|
-
event.device = this.device;
|
|
24814
|
-
event.pressed = this.pressed;
|
|
24815
|
-
event.canceled = this.canceled;
|
|
24816
|
-
event.index = this.index;
|
|
24817
|
-
event.position.copyFrom(transformPoint(transform, this.position));
|
|
24818
|
-
event.doubleTap = this.doubleTap;
|
|
24819
|
-
return event;
|
|
24820
|
-
};
|
|
24821
|
-
return InputEventScreenTouch;
|
|
24822
|
-
}(_wrap_native_super(InputEvent));
|
|
24823
|
-
var InputEventScreenDrag = /*#__PURE__*/ function(InputEvent) {
|
|
24824
|
-
_inherits(InputEventScreenDrag, InputEvent);
|
|
24825
|
-
function InputEventScreenDrag() {
|
|
24826
|
-
var _this;
|
|
24827
|
-
_this = InputEvent.apply(this, arguments) || this;
|
|
24828
|
-
_this.index = 0;
|
|
24829
|
-
_this.position = new Vector2();
|
|
24830
|
-
_this.relative = new Vector2();
|
|
24831
|
-
_this.screenRelative = new Vector2();
|
|
24832
|
-
_this.velocity = new Vector2();
|
|
24833
|
-
_this.screenVelocity = new Vector2();
|
|
24834
|
-
_this.pressure = 0;
|
|
24835
|
-
_this.tilt = new Vector2();
|
|
24836
|
-
_this.penInverted = false;
|
|
24837
|
-
return _this;
|
|
24838
|
-
}
|
|
24839
|
-
var _proto = InputEventScreenDrag.prototype;
|
|
24840
|
-
_proto.xformedBy = function xformedBy(transform) {
|
|
24841
|
-
var event = new InputEventScreenDrag();
|
|
24842
|
-
event.device = this.device;
|
|
24843
|
-
event.pressed = this.pressed;
|
|
24844
|
-
event.canceled = this.canceled;
|
|
24845
|
-
event.index = this.index;
|
|
24846
|
-
event.position.copyFrom(transformPoint(transform, this.position));
|
|
24847
|
-
event.relative.copyFrom(transformVector(transform, this.relative));
|
|
24848
|
-
event.screenRelative.copyFrom(this.screenRelative);
|
|
24849
|
-
event.velocity.copyFrom(transformVector(transform, this.velocity));
|
|
24850
|
-
event.screenVelocity.copyFrom(this.screenVelocity);
|
|
24851
|
-
event.pressure = this.pressure;
|
|
24852
|
-
event.tilt.copyFrom(this.tilt);
|
|
24853
|
-
event.penInverted = this.penInverted;
|
|
24854
|
-
return event;
|
|
24855
|
-
};
|
|
24856
|
-
return InputEventScreenDrag;
|
|
24857
|
-
}(_wrap_native_super(InputEvent));
|
|
24858
|
-
|
|
24859
|
-
var ANCHOR_PRESET_TABLE = {
|
|
24860
|
-
topLeft: [
|
|
24861
|
-
0,
|
|
24862
|
-
1,
|
|
24863
|
-
0,
|
|
24864
|
-
1
|
|
24865
|
-
],
|
|
24866
|
-
topRight: [
|
|
24867
|
-
1,
|
|
24868
|
-
1,
|
|
24869
|
-
1,
|
|
24870
|
-
1
|
|
24871
|
-
],
|
|
24872
|
-
bottomLeft: [
|
|
24873
|
-
0,
|
|
24874
|
-
0,
|
|
24875
|
-
0,
|
|
24876
|
-
0
|
|
24877
|
-
],
|
|
24878
|
-
bottomRight: [
|
|
24879
|
-
1,
|
|
24880
|
-
0,
|
|
24881
|
-
1,
|
|
24882
|
-
0
|
|
24883
|
-
],
|
|
24884
|
-
centerLeft: [
|
|
24885
|
-
0,
|
|
24886
|
-
0.5,
|
|
24887
|
-
0,
|
|
24888
|
-
0.5
|
|
24889
|
-
],
|
|
24890
|
-
centerTop: [
|
|
24891
|
-
0.5,
|
|
24892
|
-
1,
|
|
24893
|
-
0.5,
|
|
24894
|
-
1
|
|
24895
|
-
],
|
|
24896
|
-
centerRight: [
|
|
24897
|
-
1,
|
|
24898
|
-
0.5,
|
|
24899
|
-
1,
|
|
24900
|
-
0.5
|
|
24901
|
-
],
|
|
24902
|
-
centerBottom: [
|
|
24903
|
-
0.5,
|
|
24904
|
-
0,
|
|
24905
|
-
0.5,
|
|
24906
|
-
0
|
|
24907
|
-
],
|
|
24908
|
-
center: [
|
|
24909
|
-
0.5,
|
|
24910
|
-
0.5,
|
|
24911
|
-
0.5,
|
|
24912
|
-
0.5
|
|
24913
|
-
],
|
|
24914
|
-
leftWide: [
|
|
24915
|
-
0,
|
|
24916
|
-
0,
|
|
24917
|
-
0,
|
|
24918
|
-
1
|
|
24919
|
-
],
|
|
24920
|
-
topWide: [
|
|
24921
|
-
0,
|
|
24922
|
-
1,
|
|
24923
|
-
1,
|
|
24924
|
-
1
|
|
24925
|
-
],
|
|
24926
|
-
rightWide: [
|
|
24927
|
-
1,
|
|
24928
|
-
0,
|
|
24929
|
-
1,
|
|
24930
|
-
1
|
|
24931
|
-
],
|
|
24932
|
-
bottomWide: [
|
|
24933
|
-
0,
|
|
24934
|
-
0,
|
|
24935
|
-
1,
|
|
24936
|
-
0
|
|
24937
|
-
],
|
|
24938
|
-
vcenterWide: [
|
|
24939
|
-
0.5,
|
|
24940
|
-
0,
|
|
24941
|
-
0.5,
|
|
24942
|
-
1
|
|
24943
|
-
],
|
|
24944
|
-
hcenterWide: [
|
|
24945
|
-
0,
|
|
24946
|
-
0.5,
|
|
24947
|
-
1,
|
|
24948
|
-
0.5
|
|
24949
|
-
],
|
|
24950
|
-
fullRect: [
|
|
24951
|
-
0,
|
|
24952
|
-
0,
|
|
24953
|
-
1,
|
|
24954
|
-
1
|
|
24955
|
-
]
|
|
24956
|
-
};
|
|
24957
|
-
/**
|
|
24958
|
-
* A drawable GUI object. Controls form a tree independent from the VFXItem
|
|
24959
|
-
* scene tree. UIControl is the bridge between both trees.
|
|
24960
|
-
*/ var Control = /*#__PURE__*/ function() {
|
|
24961
|
-
function Control(engine) {
|
|
24962
|
-
this.engine = engine;
|
|
24963
|
-
this._parent = null;
|
|
24964
|
-
this._visible = true;
|
|
24965
|
-
this._enabled = true;
|
|
24966
|
-
this._mouseFilter = exports.MouseFilter.Stop;
|
|
24967
|
-
this._mouseBehaviorRecursive = exports.MouseBehaviorRecursive.Inherited;
|
|
24968
|
-
this._focusMode = exports.FocusMode.None;
|
|
24969
|
-
this._focusBehaviorRecursive = exports.FocusBehaviorRecursive.Inherited;
|
|
24970
|
-
this._defaultCursorShape = exports.CursorShape.Arrow;
|
|
24971
|
-
this._rotation = 0;
|
|
24972
|
-
this.transformDirty = true;
|
|
24973
|
-
this.cachedTransform = new Matrix3();
|
|
24974
|
-
this.eventEmitter = new EventEmitter();
|
|
24975
|
-
this.disposed = false;
|
|
24976
|
-
this./** Scene-tree bridge that owns this GUI object, if any. */ owner = null;
|
|
24977
|
-
this.position = new Vector2();
|
|
24978
|
-
this.size = new Vector2(1, 1);
|
|
24979
|
-
this.anchorMin = new Vector2();
|
|
24980
|
-
this.anchorMax = new Vector2();
|
|
24981
|
-
this.offsetMin = new Vector2();
|
|
24982
|
-
this.offsetMax = new Vector2(1, 1);
|
|
24983
|
-
this.pivot = new Vector2(0.5, 0.5);
|
|
24984
|
-
this.scale = new Vector2(1, 1);
|
|
24985
|
-
this.shear = new Vector2();
|
|
24986
|
-
this.mouseForcePassScrollEvents = true;
|
|
24987
|
-
this.clipContents = false;
|
|
24988
|
-
}
|
|
24989
|
-
var _proto = Control.prototype;
|
|
24990
|
-
_proto.on = function on(eventName, listener, options) {
|
|
24991
|
-
this.eventEmitter.on(eventName, listener, options);
|
|
24992
|
-
};
|
|
24993
|
-
_proto.off = function off(eventName, listener) {
|
|
24994
|
-
this.eventEmitter.off(eventName, listener);
|
|
24995
|
-
};
|
|
24996
|
-
_proto.setPosition = function setPosition(x, y, keepOffsets) {
|
|
24997
|
-
if (keepOffsets === void 0) keepOffsets = false;
|
|
24998
|
-
if (this.position.x === x && this.position.y === y) {
|
|
24999
|
-
return;
|
|
25000
|
-
}
|
|
25001
|
-
var rect = {
|
|
25002
|
-
position: new Vector2(x, y),
|
|
25003
|
-
size: this.size.clone()
|
|
25004
|
-
};
|
|
25005
|
-
if (keepOffsets && this.parent) {
|
|
25006
|
-
this.computeAnchors(rect, this.getParentRect());
|
|
25007
|
-
} else {
|
|
25008
|
-
this.computeOffsets(rect, this.getParentRect());
|
|
25009
|
-
}
|
|
25010
|
-
this.updateLayout();
|
|
25011
|
-
};
|
|
25012
|
-
_proto.setSize = function setSize(width, height) {
|
|
25013
|
-
if (this.size.x === width && this.size.y === height) {
|
|
25014
|
-
return;
|
|
25015
|
-
}
|
|
25016
|
-
var rect = {
|
|
25017
|
-
position: this.position.clone(),
|
|
25018
|
-
size: new Vector2(width, height)
|
|
25019
|
-
};
|
|
25020
|
-
this.computeOffsets(rect, this.getParentRect());
|
|
25021
|
-
this.updateLayout();
|
|
25022
|
-
};
|
|
25023
|
-
_proto.setScale = function setScale(x, y) {
|
|
25024
|
-
if (this.scale.x !== x || this.scale.y !== y) {
|
|
25025
|
-
this.scale.set(x, y);
|
|
25026
|
-
this.markTransformDirty();
|
|
25027
|
-
}
|
|
25028
|
-
};
|
|
25029
|
-
_proto.setRotation = function setRotation(degrees) {
|
|
25030
|
-
if (this._rotation !== degrees) {
|
|
25031
|
-
this._rotation = degrees;
|
|
25032
|
-
this.markTransformDirty();
|
|
25033
|
-
}
|
|
25034
|
-
};
|
|
25035
|
-
_proto.setShear = function setShear(x, y) {
|
|
25036
|
-
if (this.shear.x !== x || this.shear.y !== y) {
|
|
25037
|
-
this.shear.set(x, y);
|
|
25038
|
-
this.markTransformDirty();
|
|
25039
|
-
}
|
|
25040
|
-
};
|
|
25041
|
-
_proto.setPivot = function setPivot(x, y) {
|
|
25042
|
-
if (this.pivot.x !== x || this.pivot.y !== y) {
|
|
25043
|
-
this.pivot.set(x, y);
|
|
25044
|
-
this.markTransformDirty();
|
|
25045
|
-
}
|
|
25046
|
-
};
|
|
25047
|
-
_proto.setAnchorMin = function setAnchorMin(x, y) {
|
|
25048
|
-
if (this.anchorMin.x !== x || this.anchorMin.y !== y) {
|
|
25049
|
-
this.anchorMin.set(x, y);
|
|
25050
|
-
this.updateLayout();
|
|
25051
|
-
}
|
|
25052
|
-
};
|
|
25053
|
-
_proto.setAnchorMax = function setAnchorMax(x, y) {
|
|
25054
|
-
if (this.anchorMax.x !== x || this.anchorMax.y !== y) {
|
|
25055
|
-
this.anchorMax.set(x, y);
|
|
25056
|
-
this.updateLayout();
|
|
25057
|
-
}
|
|
25058
|
-
};
|
|
25059
|
-
_proto.setOffsetMin = function setOffsetMin(x, y) {
|
|
25060
|
-
if (this.offsetMin.x !== x || this.offsetMin.y !== y) {
|
|
25061
|
-
this.offsetMin.set(x, y);
|
|
25062
|
-
this.updateLayout();
|
|
25063
|
-
}
|
|
25064
|
-
};
|
|
25065
|
-
_proto.setOffsetMax = function setOffsetMax(x, y) {
|
|
25066
|
-
if (this.offsetMax.x !== x || this.offsetMax.y !== y) {
|
|
25067
|
-
this.offsetMax.set(x, y);
|
|
25068
|
-
this.updateLayout();
|
|
25069
|
-
}
|
|
25070
|
-
};
|
|
25071
|
-
_proto.getRect = function getRect() {
|
|
25072
|
-
return {
|
|
25073
|
-
position: this.position.clone(),
|
|
25074
|
-
size: this.size.clone()
|
|
25075
|
-
};
|
|
25076
|
-
};
|
|
25077
|
-
_proto.getTransform2D = function getTransform2D() {
|
|
25078
|
-
if (this.transformDirty) {
|
|
25079
|
-
var radians = this._rotation * Math.PI / 180;
|
|
25080
|
-
var sin = Math.sin(radians);
|
|
25081
|
-
var cos = Math.cos(radians);
|
|
25082
|
-
var shearX = Math.tan(Math.max(-89, Math.min(89, this.shear.x)) * Math.PI / 180);
|
|
25083
|
-
var shearY = Math.tan(Math.max(-89, Math.min(89, this.shear.y)) * Math.PI / 180);
|
|
25084
|
-
var a = this.scale.x * (cos - sin * shearY);
|
|
25085
|
-
var b = this.scale.x * (sin + cos * shearY);
|
|
25086
|
-
var c = this.scale.y * (cos * shearX - sin);
|
|
25087
|
-
var d = this.scale.y * (sin * shearX + cos);
|
|
25088
|
-
var pivotX = this.pivot.x * this.size.x;
|
|
25089
|
-
var pivotY = this.pivot.y * this.size.y;
|
|
25090
|
-
var tx = this.position.x + pivotX - a * pivotX - c * pivotY;
|
|
25091
|
-
var ty = this.position.y + pivotY - b * pivotX - d * pivotY;
|
|
25092
|
-
this.cachedTransform.set(a, b, 0, c, d, 0, tx, ty, 1);
|
|
25093
|
-
this.transformDirty = false;
|
|
25094
|
-
}
|
|
25095
|
-
return this.cachedTransform;
|
|
25096
|
-
};
|
|
25097
|
-
_proto.setAnchorsPreset = function setAnchorsPreset(preset, keepOffsets) {
|
|
25098
|
-
if (keepOffsets === void 0) keepOffsets = true;
|
|
25099
|
-
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];
|
|
25100
|
-
if (keepOffsets) {
|
|
25101
|
-
this.anchorMin.set(minX, minY);
|
|
25102
|
-
this.anchorMax.set(maxX, maxY);
|
|
25103
|
-
} else {
|
|
25104
|
-
var rect = this.getRect();
|
|
25105
|
-
this.anchorMin.set(minX, minY);
|
|
25106
|
-
this.anchorMax.set(maxX, maxY);
|
|
25107
|
-
this.computeOffsets(rect, this.getParentRect());
|
|
25108
|
-
}
|
|
25109
|
-
this.updateLayout();
|
|
25110
|
-
};
|
|
25111
|
-
_proto.setOffsetsPreset = function setOffsetsPreset(preset, margin) {
|
|
25112
|
-
if (margin === void 0) margin = 0;
|
|
25113
|
-
if (!this.parent) {
|
|
25114
|
-
return;
|
|
25115
|
-
}
|
|
25116
|
-
var parentSize = this.parent.size;
|
|
25117
|
-
var width = this.size.x;
|
|
25118
|
-
var height = this.size.y;
|
|
25119
|
-
var a = this.anchorMin;
|
|
25120
|
-
var b = this.anchorMax;
|
|
25121
|
-
var minX = 0, maxX = 0, minY = 0, maxY = 0;
|
|
25122
|
-
switch(preset){
|
|
25123
|
-
case "topLeft":
|
|
25124
|
-
case "bottomLeft":
|
|
25125
|
-
case "centerLeft":
|
|
25126
|
-
case "topWide":
|
|
25127
|
-
case "bottomWide":
|
|
25128
|
-
case "leftWide":
|
|
25129
|
-
case "hcenterWide":
|
|
25130
|
-
case "fullRect":
|
|
25131
|
-
minX = margin - a.x * parentSize.x;
|
|
25132
|
-
maxX = margin + width - b.x * parentSize.x;
|
|
25133
|
-
break;
|
|
25134
|
-
case "centerTop":
|
|
25135
|
-
case "centerBottom":
|
|
25136
|
-
case "center":
|
|
25137
|
-
case "vcenterWide":
|
|
25138
|
-
minX = 0.5 * parentSize.x - width / 2 - a.x * parentSize.x;
|
|
25139
|
-
maxX = 0.5 * parentSize.x + width / 2 - b.x * parentSize.x;
|
|
25140
|
-
break;
|
|
25141
|
-
default:
|
|
25142
|
-
minX = parentSize.x - margin - width - a.x * parentSize.x;
|
|
25143
|
-
maxX = parentSize.x - margin - b.x * parentSize.x;
|
|
25144
|
-
break;
|
|
25145
|
-
}
|
|
25146
|
-
switch(preset){
|
|
25147
|
-
case "bottomLeft":
|
|
25148
|
-
case "bottomRight":
|
|
25149
|
-
case "centerBottom":
|
|
25150
|
-
case "leftWide":
|
|
25151
|
-
case "rightWide":
|
|
25152
|
-
case "bottomWide":
|
|
25153
|
-
case "vcenterWide":
|
|
25154
|
-
case "fullRect":
|
|
25155
|
-
minY = margin - a.y * parentSize.y;
|
|
25156
|
-
maxY = margin + height - b.y * parentSize.y;
|
|
25157
|
-
break;
|
|
25158
|
-
case "centerLeft":
|
|
25159
|
-
case "centerRight":
|
|
25160
|
-
case "center":
|
|
25161
|
-
case "hcenterWide":
|
|
25162
|
-
minY = 0.5 * parentSize.y - height / 2 - a.y * parentSize.y;
|
|
25163
|
-
maxY = 0.5 * parentSize.y + height / 2 - b.y * parentSize.y;
|
|
25164
|
-
break;
|
|
25165
|
-
default:
|
|
25166
|
-
minY = parentSize.y - margin - height - a.y * parentSize.y;
|
|
25167
|
-
maxY = parentSize.y - margin - b.y * parentSize.y;
|
|
25168
|
-
break;
|
|
25169
|
-
}
|
|
25170
|
-
this.offsetMin.set(minX, minY);
|
|
25171
|
-
this.offsetMax.set(maxX, maxY);
|
|
25172
|
-
this.updateLayout();
|
|
25173
|
-
};
|
|
25174
|
-
_proto.setAnchorsAndOffsetsPreset = function setAnchorsAndOffsetsPreset(preset, margin) {
|
|
25175
|
-
if (margin === void 0) margin = 0;
|
|
25176
|
-
this.setAnchorsPreset(preset, false);
|
|
25177
|
-
this.setOffsetsPreset(preset, margin);
|
|
25178
|
-
};
|
|
25179
|
-
_proto.getGlobalTransform2D = function getGlobalTransform2D() {
|
|
25180
|
-
var local = this.getTransform2D();
|
|
25181
|
-
return this.parent ? new Matrix3().multiplyMatrices(this.parent.getGlobalTransform2D(), local) : local.clone();
|
|
25182
|
-
};
|
|
25183
|
-
_proto.hasPoint = function hasPoint(point) {
|
|
25184
|
-
return point.x >= 0 && point.y >= 0 && point.x <= this.size.x && point.y <= this.size.y;
|
|
25185
|
-
};
|
|
25186
|
-
_proto.getEffectiveMouseFilter = function getEffectiveMouseFilter() {
|
|
25187
|
-
return this.enabledInHierarchy && this.isMouseRecursiveEnabled() ? this.mouseFilter : exports.MouseFilter.Ignore;
|
|
25188
|
-
};
|
|
25189
|
-
_proto.getFocusModeWithOverride = function getFocusModeWithOverride() {
|
|
25190
|
-
return this.enabledInHierarchy && this.isFocusRecursiveEnabled() ? this.focusMode : exports.FocusMode.None;
|
|
25191
|
-
};
|
|
25192
|
-
_proto.getCursorShape = function getCursorShape(position) {
|
|
25193
|
-
return this.defaultCursorShape;
|
|
25194
|
-
};
|
|
25195
|
-
_proto.acceptEvent = function acceptEvent() {
|
|
25196
|
-
var _this_root;
|
|
25197
|
-
(_this_root = this.root) == null ? void 0 : _this_root.acceptControlEvent(this);
|
|
25198
|
-
};
|
|
25199
|
-
_proto.focus = function focus() {
|
|
25200
|
-
var _this_root;
|
|
25201
|
-
(_this_root = this.root) == null ? void 0 : _this_root.grabControlFocus(this);
|
|
25202
|
-
};
|
|
25203
|
-
_proto.grabFocus = function grabFocus() {
|
|
25204
|
-
this.focus();
|
|
25205
|
-
};
|
|
25206
|
-
_proto.grabClickFocus = function grabClickFocus() {
|
|
25207
|
-
var _this_root;
|
|
25208
|
-
(_this_root = this.root) == null ? void 0 : _this_root.grabControlClickFocus(this);
|
|
25209
|
-
};
|
|
25210
|
-
_proto.releaseFocus = function releaseFocus() {
|
|
25211
|
-
var _this_root;
|
|
25212
|
-
(_this_root = this.root) == null ? void 0 : _this_root.releaseControlFocus(this);
|
|
25213
|
-
};
|
|
25214
|
-
_proto.warpMouse = function warpMouse(position) {
|
|
25215
|
-
var _this_root;
|
|
25216
|
-
var matrix = this.getGlobalTransform2D().elements;
|
|
25217
|
-
(_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]));
|
|
25218
|
-
};
|
|
25219
|
-
/** Converts a window-space position into this control's local coordinates. */ _proto.makePositionLocal = function makePositionLocal(position) {
|
|
25220
|
-
var transform = this.getGlobalTransform2D().clone();
|
|
25221
|
-
if (Math.abs(transform.determinant()) < 1e-12) {
|
|
25222
|
-
return new Vector2();
|
|
25223
|
-
}
|
|
25224
|
-
var elements = transform.invert().elements;
|
|
25225
|
-
return new Vector2(elements[0] * position.x + elements[3] * position.y + elements[6], elements[1] * position.x + elements[4] * position.y + elements[7]);
|
|
25226
|
-
};
|
|
25227
|
-
/** Gets the current mouse position transformed into this control's coordinates. */ _proto.getLocalMousePosition = function getLocalMousePosition() {
|
|
25228
|
-
var root = this.root;
|
|
25229
|
-
return root ? this.makePositionLocal(root.getMousePosition()) : new Vector2();
|
|
25230
|
-
};
|
|
25231
|
-
_proto.update = function update(deltaTime) {};
|
|
25232
|
-
_proto.draw = function draw() {
|
|
25233
|
-
// OVERRIDE
|
|
25234
|
-
};
|
|
25235
|
-
_proto.onDestroy = function onDestroy() {};
|
|
25236
|
-
/** @internal */ _proto.drawInternal = function drawInternal() {
|
|
25237
|
-
if (!this.visibleInHierarchy || this.disposed) {
|
|
25238
|
-
return;
|
|
25239
|
-
}
|
|
25240
|
-
var graphics = this.engine.graphics;
|
|
25241
|
-
graphics.pushTransform(this.getTransform2D());
|
|
25242
|
-
this.draw();
|
|
25243
|
-
graphics.popTransform();
|
|
25244
|
-
};
|
|
25245
|
-
_proto.drawLine = function drawLine(x1, y1, x2, y2, color, thickness) {
|
|
25246
|
-
this.engine.graphics.drawLine(x1, y1, x2, y2, color, thickness);
|
|
25247
|
-
};
|
|
25248
|
-
_proto.drawPolyline = function drawPolyline(points, color, thickness) {
|
|
25249
|
-
this.engine.graphics.drawLines(points, color, thickness);
|
|
25250
|
-
};
|
|
25251
|
-
_proto.drawBezier = function drawBezier(x1, y1, x2, y2, x3, y3, x4, y4, color, thickness) {
|
|
25252
|
-
this.engine.graphics.drawBezier(x1, y1, x2, y2, x3, y3, x4, y4, color, thickness);
|
|
25253
|
-
};
|
|
25254
|
-
_proto.drawTriangle = function drawTriangle(x1, y1, x2, y2, x3, y3, color, thickness) {
|
|
25255
|
-
this.engine.graphics.drawTriangle(x1, y1, x2, y2, x3, y3, color, thickness);
|
|
25256
|
-
};
|
|
25257
|
-
_proto.drawRect = function drawRect(x, y, width, height, color, thickness) {
|
|
25258
|
-
this.engine.graphics.drawRectangle(x, y, width, height, color, thickness);
|
|
25259
|
-
};
|
|
25260
|
-
_proto.drawCircle = function drawCircle(cx, cy, radius, color, thickness) {
|
|
25261
|
-
this.engine.graphics.drawCircle(cx, cy, radius, color, thickness);
|
|
25262
|
-
};
|
|
25263
|
-
_proto.fillTriangle = function fillTriangle(x1, y1, x2, y2, x3, y3, color) {
|
|
25264
|
-
this.engine.graphics.fillTriangle(x1, y1, x2, y2, x3, y3, color);
|
|
25265
|
-
};
|
|
25266
|
-
_proto.fillRect = function fillRect(x, y, width, height, color) {
|
|
25267
|
-
this.engine.graphics.fillRectangle(x, y, width, height, color);
|
|
25268
|
-
};
|
|
25269
|
-
_proto.fillCircle = function fillCircle(cx, cy, radius, color) {
|
|
25270
|
-
this.engine.graphics.fillCircle(cx, cy, radius, color);
|
|
25271
|
-
};
|
|
25272
|
-
_proto.drawTexture = function drawTexture(x, y, width, height, texture, region, color) {
|
|
25273
|
-
this.engine.graphics.drawTexture(x, y, width, height, texture, region, color);
|
|
25274
|
-
};
|
|
25275
|
-
_proto.drawText = function drawText(x, y, text, fontSize, color, fontFamily, fontWeight, fontStyle) {
|
|
25276
|
-
this.engine.graphics.drawText(x, y, text, fontSize, color, fontFamily, fontWeight, fontStyle);
|
|
25277
|
-
};
|
|
25278
|
-
_proto.onMouseEnter = function onMouseEnter(location) {};
|
|
25279
|
-
_proto.onMouseMove = function onMouseMove(location, event) {};
|
|
25280
|
-
_proto.onMouseLeave = function onMouseLeave() {};
|
|
25281
|
-
_proto.onMouseWheel = function onMouseWheel(location, delta, event) {};
|
|
25282
|
-
_proto.onMouseDown = function onMouseDown(location, button, event) {};
|
|
25283
|
-
_proto.onMouseUp = function onMouseUp(location, button, event) {};
|
|
25284
|
-
_proto.onTouchDown = function onTouchDown(location, pointerId, event) {};
|
|
25285
|
-
_proto.onTouchMove = function onTouchMove(location, pointerId, event) {};
|
|
25286
|
-
_proto.onTouchUp = function onTouchUp(location, pointerId, event) {};
|
|
25287
|
-
_proto.onKeyDown = function onKeyDown(event) {};
|
|
25288
|
-
_proto.onKeyUp = function onKeyUp(event) {};
|
|
25289
|
-
_proto.onGotFocus = function onGotFocus() {};
|
|
25290
|
-
_proto.onLostFocus = function onLostFocus() {};
|
|
25291
|
-
/** @internal */ _proto.invokeGetDragData = function invokeGetDragData(position) {
|
|
25292
|
-
return this.getDragData(position);
|
|
25293
|
-
};
|
|
25294
|
-
/** @internal */ _proto.invokeCanDropData = function invokeCanDropData(position, data) {
|
|
25295
|
-
return this.canDropData(position, data);
|
|
25296
|
-
};
|
|
25297
|
-
/** @internal */ _proto.invokeDropData = function invokeDropData(position, data) {
|
|
25298
|
-
this.dropData(position, data);
|
|
25299
|
-
};
|
|
25300
|
-
_proto.getDragData = function getDragData(position) {
|
|
25301
|
-
return null;
|
|
25302
|
-
};
|
|
25303
|
-
_proto.canDropData = function canDropData(position, data) {
|
|
25304
|
-
return false;
|
|
25305
|
-
};
|
|
25306
|
-
_proto.dropData = function dropData(position, data) {};
|
|
25307
|
-
_proto.dispose = function dispose() {
|
|
25308
|
-
if (this.disposed) {
|
|
25309
|
-
return;
|
|
25310
|
-
}
|
|
25311
|
-
this.disposed = true;
|
|
25312
|
-
this.onDestroy();
|
|
25313
|
-
this.parent = null;
|
|
25314
|
-
this.owner = null;
|
|
25315
|
-
};
|
|
25316
|
-
/** @internal */ _proto.updateLayout = function updateLayout() {
|
|
25317
|
-
var _this_parent;
|
|
25318
|
-
var _this_parent_size;
|
|
25319
|
-
var parentSize = (_this_parent_size = (_this_parent = this.parent) == null ? void 0 : _this_parent.size) != null ? _this_parent_size : new Vector2();
|
|
25320
|
-
var left = this.offsetMin.x + this.anchorMin.x * parentSize.x;
|
|
25321
|
-
var bottom = this.offsetMin.y + this.anchorMin.y * parentSize.y;
|
|
25322
|
-
var right = this.offsetMax.x + this.anchorMax.x * parentSize.x;
|
|
25323
|
-
var top = this.offsetMax.y + this.anchorMax.y * parentSize.y;
|
|
25324
|
-
this.applyBounds(left, bottom, right - left, top - bottom);
|
|
25325
|
-
};
|
|
25326
|
-
_proto.applyBounds = function applyBounds(x, y, width, height) {
|
|
25327
|
-
var locationChanged = this.position.x !== x || this.position.y !== y;
|
|
25328
|
-
var sizeChanged = this.size.x !== width || this.size.y !== height;
|
|
25329
|
-
if (!locationChanged && !sizeChanged) {
|
|
25330
|
-
return;
|
|
25331
|
-
}
|
|
25332
|
-
this.position.set(x, y);
|
|
25333
|
-
this.size.set(width, height);
|
|
25334
|
-
this.markTransformDirty();
|
|
25335
|
-
if (locationChanged) {
|
|
25336
|
-
this.eventEmitter.emit("locationChanged", this);
|
|
25337
|
-
}
|
|
25338
|
-
if (sizeChanged) {
|
|
25339
|
-
this.eventEmitter.emit("sizeChanged", this);
|
|
25340
|
-
if (_instanceof1(this, ContainerControl)) {
|
|
25341
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(this.children.slice()), _step; !(_step = _iterator()).done;){
|
|
25342
|
-
var child = _step.value;
|
|
25343
|
-
child.updateLayout();
|
|
25344
|
-
}
|
|
25345
|
-
}
|
|
25346
|
-
}
|
|
25347
|
-
};
|
|
25348
|
-
_proto.markTransformDirty = function markTransformDirty() {
|
|
25349
|
-
var _this_root;
|
|
25350
|
-
this.transformDirty = true;
|
|
25351
|
-
(_this_root = this.root) == null ? void 0 : _this_root.controlTreeChanged();
|
|
25352
|
-
};
|
|
25353
|
-
_proto.getParentRect = function getParentRect() {
|
|
25354
|
-
var _this_parent;
|
|
25355
|
-
var _this_parent_size_clone;
|
|
25356
|
-
return {
|
|
25357
|
-
position: new Vector2(),
|
|
25358
|
-
size: (_this_parent_size_clone = (_this_parent = this.parent) == null ? void 0 : _this_parent.size.clone()) != null ? _this_parent_size_clone : new Vector2()
|
|
25359
|
-
};
|
|
25360
|
-
};
|
|
25361
|
-
_proto.computeOffsets = function computeOffsets(rect, parentRect) {
|
|
25362
|
-
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);
|
|
25363
|
-
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);
|
|
25364
|
-
};
|
|
25365
|
-
_proto.computeAnchors = function computeAnchors(rect, parentRect) {
|
|
25366
|
-
if (parentRect.size.x !== 0) {
|
|
25367
|
-
this.anchorMin.x = (rect.position.x - parentRect.position.x - this.offsetMin.x) / parentRect.size.x;
|
|
25368
|
-
this.anchorMax.x = (rect.position.x + rect.size.x - parentRect.position.x - this.offsetMax.x) / parentRect.size.x;
|
|
25369
|
-
}
|
|
25370
|
-
if (parentRect.size.y !== 0) {
|
|
25371
|
-
this.anchorMin.y = (rect.position.y - parentRect.position.y - this.offsetMin.y) / parentRect.size.y;
|
|
25372
|
-
this.anchorMax.y = (rect.position.y + rect.size.y - parentRect.position.y - this.offsetMax.y) / parentRect.size.y;
|
|
25373
|
-
}
|
|
25374
|
-
};
|
|
25375
|
-
_proto.isMouseRecursiveEnabled = function isMouseRecursiveEnabled() {
|
|
25376
|
-
if (this.mouseBehaviorRecursive === exports.MouseBehaviorRecursive.Inherited) {
|
|
25377
|
-
var _this_parent;
|
|
25378
|
-
var _this_parent_isMouseRecursiveEnabled;
|
|
25379
|
-
return (_this_parent_isMouseRecursiveEnabled = (_this_parent = this.parent) == null ? void 0 : _this_parent.isMouseRecursiveEnabled()) != null ? _this_parent_isMouseRecursiveEnabled : true;
|
|
25380
|
-
}
|
|
25381
|
-
return this.mouseBehaviorRecursive === exports.MouseBehaviorRecursive.Enabled;
|
|
25382
|
-
};
|
|
25383
|
-
_proto.isFocusRecursiveEnabled = function isFocusRecursiveEnabled() {
|
|
25384
|
-
if (this.focusBehaviorRecursive === exports.FocusBehaviorRecursive.Inherited) {
|
|
25385
|
-
var _this_parent;
|
|
25386
|
-
var _this_parent_isFocusRecursiveEnabled;
|
|
25387
|
-
return (_this_parent_isFocusRecursiveEnabled = (_this_parent = this.parent) == null ? void 0 : _this_parent.isFocusRecursiveEnabled()) != null ? _this_parent_isFocusRecursiveEnabled : true;
|
|
25388
|
-
}
|
|
25389
|
-
return this.focusBehaviorRecursive === exports.FocusBehaviorRecursive.Enabled;
|
|
25390
|
-
};
|
|
25391
|
-
_create_class(Control, [
|
|
25392
|
-
{
|
|
25393
|
-
key: "parent",
|
|
25394
|
-
get: function get() {
|
|
25395
|
-
return this._parent;
|
|
25396
|
-
},
|
|
25397
|
-
set: function set(value) {
|
|
25398
|
-
var _this__parent;
|
|
25399
|
-
if (value === this._parent) {
|
|
25400
|
-
return;
|
|
25401
|
-
}
|
|
25402
|
-
var previousRoot = this.root;
|
|
25403
|
-
(_this__parent = this._parent) == null ? void 0 : _this__parent.removeChildInternal(this);
|
|
25404
|
-
this._parent = value;
|
|
25405
|
-
value == null ? void 0 : value.addChildInternal(this);
|
|
25406
|
-
this.updateLayout();
|
|
25407
|
-
var nextRoot = this.root;
|
|
25408
|
-
if (previousRoot && previousRoot !== nextRoot) {
|
|
25409
|
-
previousRoot.controlRemoved(this);
|
|
25410
|
-
}
|
|
25411
|
-
nextRoot == null ? void 0 : nextRoot.controlTreeChanged();
|
|
25412
|
-
this.eventEmitter.emit("parentChanged", this);
|
|
25413
|
-
}
|
|
25414
|
-
},
|
|
25415
|
-
{
|
|
25416
|
-
key: "item",
|
|
25417
|
-
get: /** Scene item exposed through the optional UIControl bridge. */ function get() {
|
|
25418
|
-
var _this_owner;
|
|
25419
|
-
var _this_owner_item;
|
|
25420
|
-
return (_this_owner_item = (_this_owner = this.owner) == null ? void 0 : _this_owner.item) != null ? _this_owner_item : null;
|
|
25421
|
-
}
|
|
25422
|
-
},
|
|
25423
|
-
{
|
|
25424
|
-
key: "indexInParent",
|
|
25425
|
-
get: function get() {
|
|
25426
|
-
var _this_parent;
|
|
25427
|
-
var _this_parent_getChildIndex;
|
|
25428
|
-
return (_this_parent_getChildIndex = (_this_parent = this.parent) == null ? void 0 : _this_parent.getChildIndex(this)) != null ? _this_parent_getChildIndex : -1;
|
|
25429
|
-
},
|
|
25430
|
-
set: function set(value) {
|
|
25431
|
-
var _this_parent;
|
|
25432
|
-
(_this_parent = this.parent) == null ? void 0 : _this_parent.changeChildIndex(this, value);
|
|
25433
|
-
}
|
|
25434
|
-
},
|
|
25435
|
-
{
|
|
25436
|
-
key: "visible",
|
|
25437
|
-
get: function get() {
|
|
25438
|
-
return this._visible;
|
|
25439
|
-
},
|
|
25440
|
-
set: function set(value) {
|
|
25441
|
-
if (this._visible !== value) {
|
|
25442
|
-
var _this_root;
|
|
25443
|
-
this._visible = value;
|
|
25444
|
-
(_this_root = this.root) == null ? void 0 : _this_root.controlStateChanged(this);
|
|
25445
|
-
}
|
|
25446
|
-
}
|
|
25447
|
-
},
|
|
25448
|
-
{
|
|
25449
|
-
key: "visibleInHierarchy",
|
|
25450
|
-
get: function get() {
|
|
25451
|
-
var _this_parent;
|
|
25452
|
-
var _this_parent_visibleInHierarchy;
|
|
25453
|
-
return this.visible && ((_this_parent_visibleInHierarchy = (_this_parent = this.parent) == null ? void 0 : _this_parent.visibleInHierarchy) != null ? _this_parent_visibleInHierarchy : true);
|
|
25454
|
-
}
|
|
25455
|
-
},
|
|
25456
|
-
{
|
|
25457
|
-
key: "enabled",
|
|
25458
|
-
get: function get() {
|
|
25459
|
-
return this._enabled;
|
|
25460
|
-
},
|
|
25461
|
-
set: function set(value) {
|
|
25462
|
-
if (this._enabled !== value) {
|
|
25463
|
-
var _this_root;
|
|
25464
|
-
this._enabled = value;
|
|
25465
|
-
(_this_root = this.root) == null ? void 0 : _this_root.controlStateChanged(this);
|
|
25466
|
-
}
|
|
25467
|
-
}
|
|
25468
|
-
},
|
|
25469
|
-
{
|
|
25470
|
-
key: "enabledInHierarchy",
|
|
25471
|
-
get: function get() {
|
|
25472
|
-
var _this_parent;
|
|
25473
|
-
var _this_parent_enabledInHierarchy;
|
|
25474
|
-
return this.enabled && ((_this_parent_enabledInHierarchy = (_this_parent = this.parent) == null ? void 0 : _this_parent.enabledInHierarchy) != null ? _this_parent_enabledInHierarchy : true);
|
|
25475
|
-
}
|
|
25476
|
-
},
|
|
25477
|
-
{
|
|
25478
|
-
key: "mouseFilter",
|
|
25479
|
-
get: function get() {
|
|
25480
|
-
return this._mouseFilter;
|
|
25481
|
-
},
|
|
25482
|
-
set: function set(value) {
|
|
25483
|
-
if (this._mouseFilter !== value) {
|
|
25484
|
-
var _this_root;
|
|
25485
|
-
this._mouseFilter = value;
|
|
25486
|
-
(_this_root = this.root) == null ? void 0 : _this_root.controlStateChanged(this);
|
|
25487
|
-
}
|
|
25488
|
-
}
|
|
25489
|
-
},
|
|
25490
|
-
{
|
|
25491
|
-
key: "mouseBehaviorRecursive",
|
|
25492
|
-
get: function get() {
|
|
25493
|
-
return this._mouseBehaviorRecursive;
|
|
25494
|
-
},
|
|
25495
|
-
set: function set(value) {
|
|
25496
|
-
if (this._mouseBehaviorRecursive !== value) {
|
|
25497
|
-
var _this_root;
|
|
25498
|
-
this._mouseBehaviorRecursive = value;
|
|
25499
|
-
(_this_root = this.root) == null ? void 0 : _this_root.controlStateChanged(this);
|
|
25500
|
-
}
|
|
25501
|
-
}
|
|
25502
|
-
},
|
|
25503
|
-
{
|
|
25504
|
-
key: "focusMode",
|
|
25505
|
-
get: function get() {
|
|
25506
|
-
return this._focusMode;
|
|
25507
|
-
},
|
|
25508
|
-
set: function set(value) {
|
|
25509
|
-
if (this._focusMode !== value) {
|
|
25510
|
-
var _this_root;
|
|
25511
|
-
this._focusMode = value;
|
|
25512
|
-
(_this_root = this.root) == null ? void 0 : _this_root.controlStateChanged(this);
|
|
25513
|
-
}
|
|
25514
|
-
}
|
|
25515
|
-
},
|
|
25516
|
-
{
|
|
25517
|
-
key: "focusBehaviorRecursive",
|
|
25518
|
-
get: function get() {
|
|
25519
|
-
return this._focusBehaviorRecursive;
|
|
25520
|
-
},
|
|
25521
|
-
set: function set(value) {
|
|
25522
|
-
if (this._focusBehaviorRecursive !== value) {
|
|
25523
|
-
var _this_root;
|
|
25524
|
-
this._focusBehaviorRecursive = value;
|
|
25525
|
-
(_this_root = this.root) == null ? void 0 : _this_root.controlStateChanged(this);
|
|
25526
|
-
}
|
|
25527
|
-
}
|
|
25528
|
-
},
|
|
25529
|
-
{
|
|
25530
|
-
key: "defaultCursorShape",
|
|
25531
|
-
get: function get() {
|
|
25532
|
-
return this._defaultCursorShape;
|
|
25533
|
-
},
|
|
25534
|
-
set: function set(value) {
|
|
25535
|
-
this._defaultCursorShape = value;
|
|
25536
|
-
}
|
|
25537
|
-
},
|
|
25538
|
-
{
|
|
25539
|
-
key: "location",
|
|
25540
|
-
get: function get() {
|
|
25541
|
-
return this.position;
|
|
25542
|
-
},
|
|
25543
|
-
set: function set(value) {
|
|
25544
|
-
this.setPosition(value.x, value.y);
|
|
25545
|
-
}
|
|
25546
|
-
},
|
|
25547
|
-
{
|
|
25548
|
-
key: "rotation",
|
|
25549
|
-
get: function get() {
|
|
25550
|
-
return this._rotation;
|
|
25551
|
-
}
|
|
25552
|
-
},
|
|
25553
|
-
{
|
|
25554
|
-
key: "x",
|
|
25555
|
-
get: function get() {
|
|
25556
|
-
return this.position.x;
|
|
25557
|
-
},
|
|
25558
|
-
set: function set(value) {
|
|
25559
|
-
this.setPosition(value, this.position.y);
|
|
25560
|
-
}
|
|
25561
|
-
},
|
|
25562
|
-
{
|
|
25563
|
-
key: "y",
|
|
25564
|
-
get: function get() {
|
|
25565
|
-
return this.position.y;
|
|
25566
|
-
},
|
|
25567
|
-
set: function set(value) {
|
|
25568
|
-
this.setPosition(this.position.x, value);
|
|
25569
|
-
}
|
|
25570
|
-
},
|
|
25571
|
-
{
|
|
25572
|
-
key: "width",
|
|
25573
|
-
get: function get() {
|
|
25574
|
-
return this.size.x;
|
|
25575
|
-
},
|
|
25576
|
-
set: function set(value) {
|
|
25577
|
-
this.setSize(value, this.size.y);
|
|
25578
|
-
}
|
|
25579
|
-
},
|
|
25580
|
-
{
|
|
25581
|
-
key: "height",
|
|
25582
|
-
get: function get() {
|
|
25583
|
-
return this.size.y;
|
|
25584
|
-
},
|
|
25585
|
-
set: function set(value) {
|
|
25586
|
-
this.setSize(this.size.x, value);
|
|
25587
|
-
}
|
|
25588
|
-
},
|
|
25589
|
-
{
|
|
25590
|
-
key: "root",
|
|
25591
|
-
get: function get() {
|
|
25592
|
-
var _this_parent;
|
|
25593
|
-
var _this_parent_root;
|
|
25594
|
-
return _instanceof1(this, RootControl) ? this : (_this_parent_root = (_this_parent = this.parent) == null ? void 0 : _this_parent.root) != null ? _this_parent_root : null;
|
|
25595
|
-
}
|
|
25596
|
-
},
|
|
25597
|
-
{
|
|
25598
|
-
key: "isDisposed",
|
|
25599
|
-
get: function get() {
|
|
25600
|
-
return this.disposed;
|
|
25601
|
-
}
|
|
25602
|
-
}
|
|
25603
|
-
]);
|
|
25604
|
-
return Control;
|
|
25605
|
-
}();
|
|
25606
|
-
/** A Control that owns child Controls. */ var ContainerControl = /*#__PURE__*/ function(Control) {
|
|
25607
|
-
_inherits(ContainerControl, Control);
|
|
25608
|
-
function ContainerControl() {
|
|
25609
|
-
var _this;
|
|
25610
|
-
_this = Control.apply(this, arguments) || this;
|
|
25611
|
-
_this.children = [];
|
|
25612
|
-
return _this;
|
|
25613
|
-
}
|
|
25614
|
-
var _proto = ContainerControl.prototype;
|
|
25615
|
-
_proto.addChild = function addChild(child) {
|
|
25616
|
-
child.parent = this;
|
|
25617
|
-
return child;
|
|
25618
|
-
};
|
|
25619
|
-
_proto.removeChild = function removeChild(child) {
|
|
25620
|
-
if (child.parent === this) {
|
|
25621
|
-
child.parent = null;
|
|
25622
|
-
}
|
|
25623
|
-
};
|
|
25624
|
-
_proto.getChildIndex = function getChildIndex(child) {
|
|
25625
|
-
return this.children.indexOf(child);
|
|
25626
|
-
};
|
|
25627
|
-
/** @internal */ _proto.changeChildIndex = function changeChildIndex(child, newIndex) {
|
|
25628
|
-
var _this_root;
|
|
25629
|
-
var oldIndex = this.children.indexOf(child);
|
|
25630
|
-
if (oldIndex === newIndex || oldIndex === -1) {
|
|
25631
|
-
return;
|
|
25632
|
-
}
|
|
25633
|
-
this.children.splice(oldIndex, 1);
|
|
25634
|
-
if (newIndex < 0 || newIndex >= this.children.length) {
|
|
25635
|
-
this.children.push(child);
|
|
25636
|
-
} else {
|
|
25637
|
-
this.children.splice(newIndex, 0, child);
|
|
25638
|
-
}
|
|
25639
|
-
(_this_root = this.root) == null ? void 0 : _this_root.controlTreeChanged();
|
|
25640
|
-
};
|
|
25641
|
-
/** @internal */ _proto.addChildInternal = function addChildInternal(child) {
|
|
25642
|
-
if (!this.children.includes(child)) {
|
|
25643
|
-
this.children.push(child);
|
|
25644
|
-
}
|
|
25645
|
-
};
|
|
25646
|
-
/** @internal */ _proto.removeChildInternal = function removeChildInternal(child) {
|
|
25647
|
-
var index = this.children.indexOf(child);
|
|
25648
|
-
if (index !== -1) {
|
|
25649
|
-
this.children.splice(index, 1);
|
|
25650
|
-
}
|
|
25651
|
-
};
|
|
25652
|
-
_proto.drawSelf = function drawSelf() {
|
|
25653
|
-
Control.prototype.draw.call(this);
|
|
25654
|
-
};
|
|
25655
|
-
_proto.draw = function draw() {
|
|
25656
|
-
this.drawSelf();
|
|
25657
|
-
this.drawChildren();
|
|
25658
|
-
};
|
|
25659
|
-
_proto.drawChildren = function drawChildren() {
|
|
25660
|
-
var graphics = this.engine.graphics;
|
|
25661
|
-
if (this.clipContents) ;
|
|
25662
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(this.children), _step; !(_step = _iterator()).done;){
|
|
25663
|
-
var child = _step.value;
|
|
25664
|
-
if (!child.visible || child.isDisposed) {
|
|
25665
|
-
continue;
|
|
25666
|
-
}
|
|
25667
|
-
graphics.pushTransform(child.getTransform2D());
|
|
25668
|
-
child.draw();
|
|
25669
|
-
graphics.popTransform();
|
|
25670
|
-
}
|
|
25671
|
-
};
|
|
25672
|
-
_proto.update = function update(deltaTime) {
|
|
25673
|
-
Control.prototype.update.call(this, deltaTime);
|
|
25674
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(this.children.slice()), _step; !(_step = _iterator()).done;){
|
|
25675
|
-
var child = _step.value;
|
|
25676
|
-
if (child.enabled && !child.isDisposed) {
|
|
25677
|
-
child.update(deltaTime);
|
|
25678
|
-
}
|
|
25679
|
-
}
|
|
25680
|
-
};
|
|
25681
|
-
_proto.dispose = function dispose() {
|
|
25682
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(this.children.slice()), _step; !(_step = _iterator()).done;){
|
|
25683
|
-
var child = _step.value;
|
|
25684
|
-
child.dispose();
|
|
25685
|
-
}
|
|
25686
|
-
Control.prototype.dispose.call(this);
|
|
25687
|
-
};
|
|
25688
|
-
return ContainerControl;
|
|
25689
|
-
}(Control);
|
|
25690
|
-
/** Base class for GUI tree roots and input dispatchers. */ var RootControl = /*#__PURE__*/ function(ContainerControl) {
|
|
25691
|
-
_inherits(RootControl, ContainerControl);
|
|
25692
|
-
function RootControl() {
|
|
25693
|
-
return ContainerControl.apply(this, arguments);
|
|
25694
|
-
}
|
|
25695
|
-
return RootControl;
|
|
25696
|
-
}(ContainerControl);
|
|
25697
|
-
|
|
25698
|
-
var _obj$3;
|
|
25699
|
-
var cursorNames = (_obj$3 = {}, _obj$3[exports.CursorShape.Arrow] = "default", _obj$3[exports.CursorShape.Ibeam] = "text", _obj$3[exports.CursorShape.PointingHand] = "pointer", _obj$3[exports.CursorShape.Cross] = "crosshair", _obj$3[exports.CursorShape.Wait] = "wait", _obj$3[exports.CursorShape.Busy] = "progress", _obj$3[exports.CursorShape.Drag] = "grab", _obj$3[exports.CursorShape.CanDrop] = "copy", _obj$3[exports.CursorShape.Forbidden] = "not-allowed", _obj$3[exports.CursorShape.Vsize] = "ns-resize", _obj$3[exports.CursorShape.Hsize] = "ew-resize", _obj$3[exports.CursorShape.Bdiagsize] = "nesw-resize", _obj$3[exports.CursorShape.Fdiagsize] = "nwse-resize", _obj$3[exports.CursorShape.Move] = "move", _obj$3[exports.CursorShape.Vsplit] = "row-resize", _obj$3[exports.CursorShape.Hsplit] = "col-resize", _obj$3[exports.CursorShape.Help] = "help", _obj$3);
|
|
25700
|
-
function getButtonMask(button) {
|
|
25701
|
-
switch(button){
|
|
25702
|
-
case exports.MouseButton.Left:
|
|
25703
|
-
return exports.MouseButtonMask.Left;
|
|
25704
|
-
case exports.MouseButton.Right:
|
|
25705
|
-
return exports.MouseButtonMask.Right;
|
|
25706
|
-
case exports.MouseButton.Middle:
|
|
25707
|
-
return exports.MouseButtonMask.Middle;
|
|
25708
|
-
case exports.MouseButton.Xbutton1:
|
|
25709
|
-
return exports.MouseButtonMask.Xbutton1;
|
|
25710
|
-
case exports.MouseButton.Xbutton2:
|
|
25711
|
-
return exports.MouseButtonMask.Xbutton2;
|
|
25712
|
-
default:
|
|
25713
|
-
return exports.MouseButtonMask.None;
|
|
25714
|
-
}
|
|
25715
|
-
}
|
|
25716
|
-
function isWheelButton(button) {
|
|
25717
|
-
return button >= exports.MouseButton.WheelUp && button <= exports.MouseButton.WheelRight;
|
|
25718
|
-
}
|
|
25719
|
-
function getWheelDelta(event) {
|
|
25720
|
-
return event.buttonIndex === exports.MouseButton.WheelUp || event.buttonIndex === exports.MouseButton.WheelLeft ? event.factor : -event.factor;
|
|
25721
|
-
}
|
|
25722
|
-
/** CanvasLayer-like boundary for a single UICanvas GUI tree. */ var CanvasRootControl = /*#__PURE__*/ function(ContainerControl) {
|
|
25723
|
-
_inherits(CanvasRootControl, ContainerControl);
|
|
25724
|
-
function CanvasRootControl(engine, canvas) {
|
|
25725
|
-
var _this;
|
|
25726
|
-
_this = ContainerControl.call(this, engine) || this;
|
|
25727
|
-
_this.canvas = canvas;
|
|
25728
|
-
_this.mouseFilter = exports.MouseFilter.Ignore;
|
|
25729
|
-
_this.setSize(engine.canvas.width, engine.canvas.height);
|
|
25730
|
-
return _this;
|
|
25731
|
-
}
|
|
25732
|
-
_create_class(CanvasRootControl, [
|
|
25733
|
-
{
|
|
25734
|
-
key: "inputDisabled",
|
|
25735
|
-
get: function get() {
|
|
25736
|
-
var _this_canvas_item;
|
|
25737
|
-
return !this.canvas.receivesEvents || !this.canvas.enabled || !((_this_canvas_item = this.canvas.item) == null ? void 0 : _this_canvas_item.isActive);
|
|
25738
|
-
}
|
|
25739
|
-
}
|
|
25740
|
-
]);
|
|
25741
|
-
return CanvasRootControl;
|
|
25742
|
-
}(ContainerControl);
|
|
25743
|
-
/** Global ordered collection of UICanvas roots. */ var CanvasContainer = /*#__PURE__*/ function(ContainerControl) {
|
|
25744
|
-
_inherits(CanvasContainer, ContainerControl);
|
|
25745
|
-
function CanvasContainer(engine) {
|
|
25746
|
-
var _this;
|
|
25747
|
-
_this = ContainerControl.call(this, engine) || this;
|
|
25748
|
-
_this.mouseFilter = exports.MouseFilter.Ignore;
|
|
25749
|
-
_this.setSize(engine.canvas.width, engine.canvas.height);
|
|
25750
|
-
return _this;
|
|
25751
|
-
}
|
|
25752
|
-
var _proto = CanvasContainer.prototype;
|
|
25753
|
-
_proto.sortCanvases = function sortCanvases() {
|
|
25754
|
-
this.children.sort(function(left, right) {
|
|
25755
|
-
return left.canvas.order - right.canvas.order;
|
|
25756
|
-
});
|
|
25757
|
-
};
|
|
25758
|
-
_proto.addChildInternal = function addChildInternal(child) {
|
|
25759
|
-
ContainerControl.prototype.addChildInternal.call(this, child);
|
|
25760
|
-
this.sortCanvases();
|
|
25761
|
-
};
|
|
25762
|
-
_proto.draw = function draw() {
|
|
25763
|
-
this.sortCanvases();
|
|
25764
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(this.children), _step; !(_step = _iterator()).done;){
|
|
25765
|
-
var child = _step.value;
|
|
25766
|
-
var root = child;
|
|
25767
|
-
if (root.canvas.isVisible) {
|
|
25768
|
-
root.draw();
|
|
25769
|
-
}
|
|
25770
|
-
}
|
|
25771
|
-
};
|
|
25772
|
-
return CanvasContainer;
|
|
25773
|
-
}(ContainerControl);
|
|
25774
|
-
/** Engine window GUI root. Routes events across all UICanvas roots. */ var WindowRootControl = /*#__PURE__*/ function(RootControl) {
|
|
25775
|
-
_inherits(WindowRootControl, RootControl);
|
|
25776
|
-
function WindowRootControl(engine) {
|
|
25777
|
-
var _this;
|
|
25778
|
-
_this = RootControl.call(this, engine) || this;
|
|
25779
|
-
_this.dragThreshold = 10;
|
|
25780
|
-
_this.inputHandled = false;
|
|
25781
|
-
_this.gui = {
|
|
25782
|
-
mouseFocus: null,
|
|
25783
|
-
mouseClickGrabber: null,
|
|
25784
|
-
mouseFocusMask: exports.MouseButtonMask.None,
|
|
25785
|
-
mouseOver: null,
|
|
25786
|
-
mouseOverHierarchy: [],
|
|
25787
|
-
touchFocus: new Map(),
|
|
25788
|
-
keyFocus: null,
|
|
25789
|
-
dragAccum: new Vector2(),
|
|
25790
|
-
dragAttempted: false,
|
|
25791
|
-
dragging: false,
|
|
25792
|
-
dragData: null,
|
|
25793
|
-
dragMouseOver: null,
|
|
25794
|
-
dragSuccessful: false,
|
|
25795
|
-
lastMousePosition: new Vector2(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY),
|
|
25796
|
-
sendingMouseEnterExit: false,
|
|
25797
|
-
mouseOverUpdatePending: false
|
|
25798
|
-
};
|
|
25799
|
-
_this.mouseFilter = exports.MouseFilter.Ignore;
|
|
25800
|
-
_this.setSize(engine.canvas.width, engine.canvas.height);
|
|
25801
|
-
_this.canvases = new CanvasContainer(engine);
|
|
25802
|
-
_this.canvases.parent = _assert_this_initialized(_this);
|
|
25803
|
-
return _this;
|
|
25804
|
-
}
|
|
25805
|
-
var _proto = WindowRootControl.prototype;
|
|
25806
|
-
_proto.pushInput = function pushInput(event) {
|
|
25807
|
-
this.inputHandled = false;
|
|
25808
|
-
this.cleanupInternalState();
|
|
25809
|
-
this.processGUIInput(event);
|
|
25810
|
-
this.postGrabClickFocus();
|
|
25811
|
-
};
|
|
25812
|
-
_proto.isInputHandled = function isInputHandled() {
|
|
25813
|
-
return this.inputHandled;
|
|
25814
|
-
};
|
|
25815
|
-
_proto.getMousePosition = function getMousePosition() {
|
|
25816
|
-
return this.gui.lastMousePosition.clone();
|
|
25817
|
-
};
|
|
25818
|
-
_proto.guiGetFocusOwner = function guiGetFocusOwner() {
|
|
25819
|
-
return this.isFocusTargetUsable(this.gui.keyFocus) ? this.gui.keyFocus : null;
|
|
25820
|
-
};
|
|
25821
|
-
_proto.guiReleaseFocus = function guiReleaseFocus() {
|
|
25822
|
-
this.releaseControlFocus();
|
|
25823
|
-
};
|
|
25824
|
-
_proto.guiIsDragging = function guiIsDragging() {
|
|
25825
|
-
return this.gui.dragging;
|
|
25826
|
-
};
|
|
25827
|
-
_proto.guiGetDragData = function guiGetDragData() {
|
|
25828
|
-
return this.gui.dragData;
|
|
25829
|
-
};
|
|
25830
|
-
_proto.guiIsDragSuccessful = function guiIsDragSuccessful() {
|
|
25831
|
-
return this.gui.dragSuccessful;
|
|
25832
|
-
};
|
|
25833
|
-
_proto.guiCancelDrag = function guiCancelDrag() {
|
|
25834
|
-
this.endDragging(false);
|
|
25835
|
-
};
|
|
25836
|
-
_proto.acceptControlEvent = function acceptControlEvent(control) {
|
|
25837
|
-
if (this.isControlUsable(control)) {
|
|
25838
|
-
this.inputHandled = true;
|
|
25839
|
-
}
|
|
25840
|
-
};
|
|
25841
|
-
_proto.grabControlFocus = function grabControlFocus(control) {
|
|
25842
|
-
if (!this.isFocusTargetUsable(control) || this.gui.keyFocus === control) {
|
|
25843
|
-
return;
|
|
25844
|
-
}
|
|
25845
|
-
var previous = this.gui.keyFocus;
|
|
25846
|
-
this.gui.keyFocus = control;
|
|
25847
|
-
if (previous && !previous.isDisposed) {
|
|
25848
|
-
previous.onLostFocus();
|
|
25849
|
-
}
|
|
25850
|
-
control.onGotFocus();
|
|
25851
|
-
};
|
|
25852
|
-
_proto.grabControlClickFocus = function grabControlClickFocus(control) {
|
|
25853
|
-
var _this = this;
|
|
25854
|
-
if (this.isControlValid(control)) {
|
|
25855
|
-
this.gui.mouseClickGrabber = control;
|
|
25856
|
-
queueMicrotask(function() {
|
|
25857
|
-
return _this.postGrabClickFocus();
|
|
25858
|
-
});
|
|
25859
|
-
}
|
|
25860
|
-
};
|
|
25861
|
-
_proto.releaseControlFocus = function releaseControlFocus(control) {
|
|
25862
|
-
var previous = this.gui.keyFocus;
|
|
25863
|
-
if (!previous || control && previous !== control) {
|
|
25864
|
-
return;
|
|
25865
|
-
}
|
|
25866
|
-
this.gui.keyFocus = null;
|
|
25867
|
-
if (!previous.isDisposed) {
|
|
25868
|
-
previous.onLostFocus();
|
|
25869
|
-
}
|
|
25870
|
-
};
|
|
25871
|
-
_proto.warpControlMouse = function warpControlMouse(position) {
|
|
25872
|
-
this.gui.lastMousePosition.copyFrom(position);
|
|
25873
|
-
this.updateMouseOver(position);
|
|
25874
|
-
};
|
|
25875
|
-
_proto.controlStateChanged = function controlStateChanged(control) {
|
|
25876
|
-
if (!this.isControlUsable(control)) {
|
|
25877
|
-
this.dropControlState(control);
|
|
25878
|
-
}
|
|
25879
|
-
this.requestMouseOverUpdate();
|
|
25880
|
-
};
|
|
25881
|
-
_proto.controlRemoved = function controlRemoved(control) {
|
|
25882
|
-
this.dropControlState(control);
|
|
25883
|
-
this.cleanupInternalState();
|
|
25884
|
-
this.requestMouseOverUpdate();
|
|
25885
|
-
};
|
|
25886
|
-
_proto.controlTreeChanged = function controlTreeChanged() {
|
|
25887
|
-
this.requestMouseOverUpdate();
|
|
25888
|
-
};
|
|
25889
|
-
_proto.cancelPointerInput = function cancelPointerInput() {
|
|
25890
|
-
this.dropMouseFocus();
|
|
25891
|
-
this.dropMouseOver();
|
|
25892
|
-
this.gui.touchFocus.clear();
|
|
25893
|
-
this.endDragging(false);
|
|
25894
|
-
this.releaseControlFocus();
|
|
25895
|
-
};
|
|
25896
|
-
_proto.resize = function resize(width, height) {
|
|
25897
|
-
this.setSize(width, height);
|
|
25898
|
-
this.canvases.setSize(width, height);
|
|
25899
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(this.canvases.children), _step; !(_step = _iterator()).done;){
|
|
25900
|
-
var root = _step.value;
|
|
25901
|
-
root.setSize(width, height);
|
|
25902
|
-
}
|
|
25903
|
-
};
|
|
25904
|
-
_proto.render = function render() {
|
|
25905
|
-
if (this.canvases.children.length === 0) {
|
|
25906
|
-
return;
|
|
25907
|
-
}
|
|
25908
|
-
this.engine.graphics.begin();
|
|
25909
|
-
this.draw();
|
|
25910
|
-
this.engine.graphics.end();
|
|
25911
|
-
};
|
|
25912
|
-
_proto.update = function update(deltaTime) {
|
|
25913
|
-
if (this.gui.mouseOverUpdatePending) {
|
|
25914
|
-
this.gui.mouseOverUpdatePending = false;
|
|
25915
|
-
this.updateMouseOver(this.gui.lastMousePosition);
|
|
25916
|
-
}
|
|
25917
|
-
RootControl.prototype.update.call(this, deltaTime);
|
|
25918
|
-
};
|
|
25919
|
-
_proto.dispose = function dispose() {
|
|
25920
|
-
this.cancelPointerInput();
|
|
25921
|
-
RootControl.prototype.dispose.call(this);
|
|
25922
|
-
};
|
|
25923
|
-
_proto.processGUIInput = function processGUIInput(event) {
|
|
25924
|
-
if (_instanceof1(event, InputEventKey)) {
|
|
25925
|
-
var target = this.guiGetFocusOwner();
|
|
25926
|
-
if (target) {
|
|
25927
|
-
this.callControlInput(target, event);
|
|
25928
|
-
}
|
|
25929
|
-
} else if (_instanceof1(event, InputEventMouse)) {
|
|
25930
|
-
this.gui.lastMousePosition.copyFrom(event.globalPosition);
|
|
25931
|
-
this.updateMouseOver(event.globalPosition);
|
|
25932
|
-
if (_instanceof1(event, InputEventMouseButton)) {
|
|
25933
|
-
this.processMouseButton(event);
|
|
25934
|
-
} else if (_instanceof1(event, InputEventMouseMotion)) {
|
|
25935
|
-
this.processMouseMotion(event);
|
|
25936
|
-
}
|
|
25937
|
-
} else if (_instanceof1(event, InputEventScreenTouch)) {
|
|
25938
|
-
this.processScreenTouch(event);
|
|
25939
|
-
} else if (_instanceof1(event, InputEventScreenDrag)) {
|
|
25940
|
-
this.processScreenDrag(event);
|
|
25941
|
-
}
|
|
25942
|
-
};
|
|
25943
|
-
_proto.processMouseButton = function processMouseButton(event) {
|
|
25944
|
-
if (isWheelButton(event.buttonIndex)) {
|
|
25945
|
-
var target = this.findInputControl(event.globalPosition);
|
|
25946
|
-
if (target) {
|
|
25947
|
-
this.callGUIInput(target, event);
|
|
25948
|
-
}
|
|
25949
|
-
return;
|
|
25950
|
-
}
|
|
25951
|
-
var mask = getButtonMask(event.buttonIndex);
|
|
25952
|
-
if (event.isPressed()) {
|
|
25953
|
-
var target1 = this.gui.mouseFocusMask !== 0 ? this.gui.mouseFocus : this.findInputControl(event.globalPosition);
|
|
25954
|
-
this.gui.mouseFocus = target1;
|
|
25955
|
-
if (!target1) {
|
|
25956
|
-
return;
|
|
25957
|
-
}
|
|
25958
|
-
this.gui.mouseFocusMask |= mask;
|
|
25959
|
-
if (event.buttonIndex === exports.MouseButton.Left) {
|
|
25960
|
-
this.gui.dragAccum.setZero();
|
|
25961
|
-
this.gui.dragAttempted = false;
|
|
25962
|
-
this.findClickFocus(target1);
|
|
25963
|
-
}
|
|
25964
|
-
this.callGUIInput(target1, event);
|
|
25965
|
-
} else {
|
|
25966
|
-
if (event.buttonIndex === exports.MouseButton.Left && this.gui.dragging) {
|
|
25967
|
-
this.finishDrop(event.globalPosition);
|
|
25968
|
-
}
|
|
25969
|
-
this.gui.mouseFocusMask &= ~mask;
|
|
25970
|
-
var target2 = this.gui.mouseFocus;
|
|
25971
|
-
if (this.gui.mouseFocusMask === 0) {
|
|
25972
|
-
this.gui.mouseFocus = null;
|
|
25973
|
-
}
|
|
25974
|
-
if (this.isControlUsable(target2)) {
|
|
25975
|
-
this.callGUIInput(target2, event);
|
|
25976
|
-
}
|
|
25977
|
-
}
|
|
25978
|
-
};
|
|
25979
|
-
_proto.processMouseMotion = function processMouseMotion(event) {
|
|
25980
|
-
if (!this.gui.dragging && !this.gui.dragAttempted && this.gui.mouseFocus && (this.gui.mouseFocusMask & exports.MouseButtonMask.Left) !== 0) {
|
|
25981
|
-
this.gui.dragAccum.add(event.relative);
|
|
25982
|
-
if (this.gui.dragAccum.length() > this.dragThreshold) {
|
|
25983
|
-
var origin = event.globalPosition.clone().subtract(this.gui.dragAccum);
|
|
25984
|
-
this.beginDragging(this.gui.mouseFocus, origin);
|
|
25985
|
-
this.gui.dragAttempted = true;
|
|
25986
|
-
}
|
|
25987
|
-
}
|
|
25988
|
-
var target = this.isControlUsable(this.gui.mouseFocus) ? this.gui.mouseFocus : this.findInputControl(event.globalPosition);
|
|
25989
|
-
if (target) {
|
|
25990
|
-
this.callGUIInput(target, event);
|
|
25991
|
-
}
|
|
25992
|
-
if (this.gui.dragging) {
|
|
25993
|
-
this.gui.dragMouseOver = this.findDropTarget(this.findInputControl(event.globalPosition), event.globalPosition);
|
|
25994
|
-
}
|
|
25995
|
-
this.updateCursor(target, event.globalPosition);
|
|
25996
|
-
};
|
|
25997
|
-
_proto.processScreenTouch = function processScreenTouch(event) {
|
|
25998
|
-
var target;
|
|
25999
|
-
if (event.isPressed()) {
|
|
26000
|
-
target = this.findInputControl(event.position);
|
|
26001
|
-
if (target) {
|
|
26002
|
-
this.gui.touchFocus.set(event.index, target);
|
|
26003
|
-
}
|
|
26004
|
-
} else {
|
|
26005
|
-
var _this_gui_touchFocus_get;
|
|
26006
|
-
target = (_this_gui_touchFocus_get = this.gui.touchFocus.get(event.index)) != null ? _this_gui_touchFocus_get : null;
|
|
26007
|
-
this.gui.touchFocus.delete(event.index);
|
|
26008
|
-
}
|
|
26009
|
-
if (this.isControlUsable(target)) {
|
|
26010
|
-
this.callGUIInput(target, event);
|
|
26011
|
-
}
|
|
26012
|
-
};
|
|
26013
|
-
_proto.processScreenDrag = function processScreenDrag(event) {
|
|
26014
|
-
var _this_gui_touchFocus_get;
|
|
26015
|
-
var target = (_this_gui_touchFocus_get = this.gui.touchFocus.get(event.index)) != null ? _this_gui_touchFocus_get : this.findInputControl(event.position);
|
|
26016
|
-
if (this.isControlUsable(target)) {
|
|
26017
|
-
this.callGUIInput(target, event);
|
|
26018
|
-
}
|
|
26019
|
-
};
|
|
26020
|
-
_proto.callGUIInput = function callGUIInput(target, event) {
|
|
26021
|
-
var current = target;
|
|
26022
|
-
var pointerEvent = _instanceof1(event, InputEventMouse) || _instanceof1(event, InputEventScreenTouch) || _instanceof1(event, InputEventScreenDrag);
|
|
26023
|
-
while(current && current !== this && this.isControlUsable(current)){
|
|
26024
|
-
var filter = current.getEffectiveMouseFilter();
|
|
26025
|
-
if (filter !== exports.MouseFilter.Ignore) {
|
|
26026
|
-
this.callControlInput(current, event.xformedBy(this.getGlobalInverse(current)));
|
|
26027
|
-
}
|
|
26028
|
-
var forcePassWheel = _instanceof1(event, InputEventMouseButton) && isWheelButton(event.buttonIndex) && current.mouseForcePassScrollEvents;
|
|
26029
|
-
if (this.inputHandled || filter === exports.MouseFilter.Stop && pointerEvent && !forcePassWheel) {
|
|
26030
|
-
this.inputHandled = true;
|
|
26031
|
-
return;
|
|
26032
|
-
}
|
|
26033
|
-
current = current.parent;
|
|
26034
|
-
}
|
|
26035
|
-
};
|
|
26036
|
-
_proto.callControlInput = function callControlInput(control, event) {
|
|
26037
|
-
if (_instanceof1(event, InputEventMouseButton)) {
|
|
26038
|
-
if (isWheelButton(event.buttonIndex)) {
|
|
26039
|
-
control.onMouseWheel(event.position, getWheelDelta(event), event);
|
|
26040
|
-
} else if (event.isPressed()) {
|
|
26041
|
-
control.onMouseDown(event.position, event.buttonIndex, event);
|
|
26042
|
-
} else {
|
|
26043
|
-
control.onMouseUp(event.position, event.buttonIndex, event);
|
|
26044
|
-
}
|
|
26045
|
-
} else if (_instanceof1(event, InputEventMouseMotion)) {
|
|
26046
|
-
control.onMouseMove(event.position, event);
|
|
26047
|
-
} else if (_instanceof1(event, InputEventScreenTouch)) {
|
|
26048
|
-
if (event.isPressed()) {
|
|
26049
|
-
control.onTouchDown(event.position, event.index, event);
|
|
26050
|
-
} else {
|
|
26051
|
-
control.onTouchUp(event.position, event.index, event);
|
|
26052
|
-
}
|
|
26053
|
-
} else if (_instanceof1(event, InputEventScreenDrag)) {
|
|
26054
|
-
control.onTouchMove(event.position, event.index, event);
|
|
26055
|
-
} else if (_instanceof1(event, InputEventKey)) {
|
|
26056
|
-
if (event.isPressed()) {
|
|
26057
|
-
control.onKeyDown(event);
|
|
26058
|
-
} else if (event.isReleased()) {
|
|
26059
|
-
control.onKeyUp(event);
|
|
26060
|
-
}
|
|
26061
|
-
}
|
|
26062
|
-
};
|
|
26063
|
-
_proto.findInputControl = function findInputControl(position) {
|
|
26064
|
-
this.canvases.sortCanvases();
|
|
26065
|
-
for(var index = this.canvases.children.length - 1; index >= 0; index--){
|
|
26066
|
-
var root = this.canvases.children[index];
|
|
26067
|
-
if (!root.canvas.isVisible || root.inputDisabled) {
|
|
26068
|
-
continue;
|
|
26069
|
-
}
|
|
26070
|
-
var target = this.findControlAtPosition(root, position, true);
|
|
26071
|
-
if (target) {
|
|
26072
|
-
return target;
|
|
26073
|
-
}
|
|
26074
|
-
}
|
|
26075
|
-
return null;
|
|
26076
|
-
};
|
|
26077
|
-
_proto.findControlAtPosition = function findControlAtPosition(container, position, skipSelf) {
|
|
26078
|
-
if (skipSelf === void 0) skipSelf = false;
|
|
26079
|
-
if (!container.visibleInHierarchy || container.isDisposed) {
|
|
26080
|
-
return null;
|
|
26081
|
-
}
|
|
26082
|
-
var localPosition = this.toLocal(container, position);
|
|
26083
|
-
if (container.clipContents && !container.hasPoint(localPosition)) {
|
|
26084
|
-
return null;
|
|
26085
|
-
}
|
|
26086
|
-
for(var index = container.children.length - 1; index >= 0; index--){
|
|
26087
|
-
var child = container.children[index];
|
|
26088
|
-
if (!child.visibleInHierarchy || child.isDisposed) {
|
|
26089
|
-
continue;
|
|
26090
|
-
}
|
|
26091
|
-
if (_instanceof1(child, ContainerControl)) {
|
|
26092
|
-
var found = this.findControlAtPosition(child, position);
|
|
26093
|
-
if (found) {
|
|
26094
|
-
return found;
|
|
26095
|
-
}
|
|
26096
|
-
} else if (child.getEffectiveMouseFilter() !== exports.MouseFilter.Ignore && child.hasPoint(this.toLocal(child, position))) {
|
|
26097
|
-
return child;
|
|
26098
|
-
}
|
|
26099
|
-
}
|
|
26100
|
-
if (!skipSelf && container.getEffectiveMouseFilter() !== exports.MouseFilter.Ignore && container.hasPoint(localPosition)) {
|
|
26101
|
-
return container;
|
|
26102
|
-
}
|
|
26103
|
-
return null;
|
|
26104
|
-
};
|
|
26105
|
-
_proto.updateMouseOver = function updateMouseOver(position) {
|
|
26106
|
-
if (this.gui.sendingMouseEnterExit) {
|
|
26107
|
-
this.gui.mouseOverUpdatePending = true;
|
|
26108
|
-
return;
|
|
26109
|
-
}
|
|
26110
|
-
this.gui.mouseOverUpdatePending = false;
|
|
26111
|
-
var target = this.findInputControl(position);
|
|
26112
|
-
var next = this.buildHoverHierarchy(target);
|
|
26113
|
-
var previous = this.gui.mouseOverHierarchy;
|
|
26114
|
-
var common = 0;
|
|
26115
|
-
while(common < previous.length && common < next.length && previous[common] === next[common]){
|
|
26116
|
-
common++;
|
|
26117
|
-
}
|
|
26118
|
-
this.gui.sendingMouseEnterExit = true;
|
|
26119
|
-
for(var index = previous.length - 1; index >= common; index--){
|
|
26120
|
-
if (!previous[index].isDisposed) {
|
|
26121
|
-
previous[index].onMouseLeave();
|
|
26122
|
-
}
|
|
26123
|
-
}
|
|
26124
|
-
for(var index1 = common; index1 < next.length; index1++){
|
|
26125
|
-
next[index1].onMouseEnter(this.toLocal(next[index1], position));
|
|
26126
|
-
}
|
|
26127
|
-
this.gui.sendingMouseEnterExit = false;
|
|
26128
|
-
this.gui.mouseOver = target;
|
|
26129
|
-
this.gui.mouseOverHierarchy = next;
|
|
26130
|
-
};
|
|
26131
|
-
_proto.buildHoverHierarchy = function buildHoverHierarchy(target) {
|
|
26132
|
-
var hierarchy = [];
|
|
26133
|
-
var current = target;
|
|
26134
|
-
while(current && current !== this){
|
|
26135
|
-
if (current.getEffectiveMouseFilter() !== exports.MouseFilter.Ignore) {
|
|
26136
|
-
hierarchy.push(current);
|
|
26137
|
-
}
|
|
26138
|
-
if (current.getEffectiveMouseFilter() === exports.MouseFilter.Stop) {
|
|
26139
|
-
break;
|
|
26140
|
-
}
|
|
26141
|
-
current = current.parent;
|
|
26142
|
-
}
|
|
26143
|
-
hierarchy.reverse();
|
|
26144
|
-
return hierarchy;
|
|
26145
|
-
};
|
|
26146
|
-
_proto.findClickFocus = function findClickFocus(target) {
|
|
26147
|
-
var current = target;
|
|
26148
|
-
while(current && current !== this){
|
|
26149
|
-
var mode = current.getFocusModeWithOverride();
|
|
26150
|
-
if (mode === exports.FocusMode.Click || mode === exports.FocusMode.All) {
|
|
26151
|
-
this.grabControlFocus(current);
|
|
26152
|
-
return;
|
|
26153
|
-
}
|
|
26154
|
-
if (current.getEffectiveMouseFilter() === exports.MouseFilter.Stop) {
|
|
26155
|
-
return;
|
|
26156
|
-
}
|
|
26157
|
-
current = current.parent;
|
|
26158
|
-
}
|
|
26159
|
-
};
|
|
26160
|
-
_proto.beginDragging = function beginDragging(source, position) {
|
|
26161
|
-
var current = source;
|
|
26162
|
-
while(current && current !== this){
|
|
26163
|
-
var data = current.invokeGetDragData(this.toLocal(current, position));
|
|
26164
|
-
if (data !== null && data !== undefined) {
|
|
26165
|
-
this.gui.dragging = true;
|
|
26166
|
-
this.gui.dragData = data;
|
|
26167
|
-
this.gui.mouseFocus = null;
|
|
26168
|
-
this.gui.mouseFocusMask = exports.MouseButtonMask.None;
|
|
26169
|
-
return;
|
|
26170
|
-
}
|
|
26171
|
-
if (current.getEffectiveMouseFilter() === exports.MouseFilter.Stop) {
|
|
26172
|
-
return;
|
|
26173
|
-
}
|
|
26174
|
-
current = current.parent;
|
|
26175
|
-
}
|
|
26176
|
-
};
|
|
26177
|
-
_proto.finishDrop = function finishDrop(position) {
|
|
26178
|
-
var target = this.findDropTarget(this.findInputControl(position), position);
|
|
26179
|
-
if (target) {
|
|
26180
|
-
target.invokeDropData(this.toLocal(target, position), this.gui.dragData);
|
|
26181
|
-
}
|
|
26182
|
-
this.endDragging(!!target);
|
|
26183
|
-
};
|
|
26184
|
-
_proto.findDropTarget = function findDropTarget(target, position) {
|
|
26185
|
-
var current = target;
|
|
26186
|
-
while(current && current !== this){
|
|
26187
|
-
if (current.invokeCanDropData(this.toLocal(current, position), this.gui.dragData)) {
|
|
26188
|
-
return current;
|
|
26189
|
-
}
|
|
26190
|
-
if (current.getEffectiveMouseFilter() === exports.MouseFilter.Stop) {
|
|
26191
|
-
return null;
|
|
26192
|
-
}
|
|
26193
|
-
current = current.parent;
|
|
26194
|
-
}
|
|
26195
|
-
return null;
|
|
26196
|
-
};
|
|
26197
|
-
_proto.endDragging = function endDragging(successful) {
|
|
26198
|
-
this.gui.dragSuccessful = successful;
|
|
26199
|
-
this.gui.dragging = false;
|
|
26200
|
-
this.gui.dragData = null;
|
|
26201
|
-
this.gui.dragMouseOver = null;
|
|
26202
|
-
};
|
|
26203
|
-
_proto.updateCursor = function updateCursor(target, position) {
|
|
26204
|
-
var current = target;
|
|
26205
|
-
var shape = exports.CursorShape.Arrow;
|
|
26206
|
-
while(current && current !== this){
|
|
26207
|
-
var candidate = current.getCursorShape(this.toLocal(current, position));
|
|
26208
|
-
if (candidate !== exports.CursorShape.Arrow) {
|
|
26209
|
-
shape = candidate;
|
|
26210
|
-
break;
|
|
26211
|
-
}
|
|
26212
|
-
if (current.getEffectiveMouseFilter() === exports.MouseFilter.Stop) {
|
|
26213
|
-
break;
|
|
26214
|
-
}
|
|
26215
|
-
current = current.parent;
|
|
26216
|
-
}
|
|
26217
|
-
this.engine.canvas.style.cursor = cursorNames[shape];
|
|
26218
|
-
};
|
|
26219
|
-
_proto.postGrabClickFocus = function postGrabClickFocus() {
|
|
26220
|
-
var target = this.gui.mouseClickGrabber;
|
|
26221
|
-
this.gui.mouseClickGrabber = null;
|
|
26222
|
-
if (this.isControlUsable(target)) {
|
|
26223
|
-
this.gui.mouseFocus = target;
|
|
26224
|
-
}
|
|
26225
|
-
};
|
|
26226
|
-
_proto.cleanupInternalState = function cleanupInternalState() {
|
|
26227
|
-
if (!this.isControlUsable(this.gui.mouseFocus)) {
|
|
26228
|
-
this.dropMouseFocus();
|
|
26229
|
-
}
|
|
26230
|
-
if (this.gui.keyFocus && !this.isFocusTargetUsable(this.gui.keyFocus)) {
|
|
26231
|
-
this.releaseControlFocus(this.gui.keyFocus);
|
|
26232
|
-
}
|
|
26233
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(this.gui.touchFocus), _step; !(_step = _iterator()).done;){
|
|
26234
|
-
var _step_value = _step.value, index = _step_value[0], control = _step_value[1];
|
|
26235
|
-
if (!this.isControlUsable(control)) {
|
|
26236
|
-
this.gui.touchFocus.delete(index);
|
|
26237
|
-
}
|
|
26238
|
-
}
|
|
26239
|
-
};
|
|
26240
|
-
_proto.dropMouseFocus = function dropMouseFocus() {
|
|
26241
|
-
this.gui.mouseFocus = null;
|
|
26242
|
-
this.gui.mouseFocusMask = exports.MouseButtonMask.None;
|
|
26243
|
-
};
|
|
26244
|
-
_proto.dropMouseOver = function dropMouseOver() {
|
|
26245
|
-
for(var index = this.gui.mouseOverHierarchy.length - 1; index >= 0; index--){
|
|
26246
|
-
var control = this.gui.mouseOverHierarchy[index];
|
|
26247
|
-
if (!control.isDisposed) {
|
|
26248
|
-
control.onMouseLeave();
|
|
26249
|
-
}
|
|
26250
|
-
}
|
|
26251
|
-
this.gui.mouseOver = null;
|
|
26252
|
-
this.gui.mouseOverHierarchy = [];
|
|
26253
|
-
};
|
|
26254
|
-
_proto.dropControlState = function dropControlState(control) {
|
|
26255
|
-
if (this.controlBelongsToSubtree(this.gui.mouseFocus, control)) {
|
|
26256
|
-
this.dropMouseFocus();
|
|
26257
|
-
}
|
|
26258
|
-
if (this.controlBelongsToSubtree(this.gui.mouseClickGrabber, control)) {
|
|
26259
|
-
this.gui.mouseClickGrabber = null;
|
|
26260
|
-
}
|
|
26261
|
-
if (this.controlBelongsToSubtree(this.gui.keyFocus, control)) {
|
|
26262
|
-
var _this_gui_keyFocus;
|
|
26263
|
-
this.releaseControlFocus((_this_gui_keyFocus = this.gui.keyFocus) != null ? _this_gui_keyFocus : undefined);
|
|
26264
|
-
}
|
|
26265
|
-
if (this.controlBelongsToSubtree(this.gui.mouseOver, control)) {
|
|
26266
|
-
this.dropMouseOver();
|
|
26267
|
-
}
|
|
26268
|
-
if (this.controlBelongsToSubtree(this.gui.dragMouseOver, control)) {
|
|
26269
|
-
this.gui.dragMouseOver = null;
|
|
26270
|
-
}
|
|
26271
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(this.gui.touchFocus), _step; !(_step = _iterator()).done;){
|
|
26272
|
-
var _step_value = _step.value, index = _step_value[0], target = _step_value[1];
|
|
26273
|
-
if (this.controlBelongsToSubtree(target, control)) {
|
|
26274
|
-
this.gui.touchFocus.delete(index);
|
|
26275
|
-
}
|
|
26276
|
-
}
|
|
26277
|
-
};
|
|
26278
|
-
_proto.requestMouseOverUpdate = function requestMouseOverUpdate() {
|
|
26279
|
-
if (Number.isFinite(this.gui.lastMousePosition.x)) {
|
|
26280
|
-
this.updateMouseOver(this.gui.lastMousePosition);
|
|
26281
|
-
}
|
|
26282
|
-
};
|
|
26283
|
-
_proto.getGlobalInverse = function getGlobalInverse(control) {
|
|
26284
|
-
var transform = control.getGlobalTransform2D().clone();
|
|
26285
|
-
return Math.abs(transform.determinant()) < 1e-12 ? new Matrix3() : transform.invert();
|
|
26286
|
-
};
|
|
26287
|
-
_proto.toLocal = function toLocal(control, position) {
|
|
26288
|
-
var elements = this.getGlobalInverse(control).elements;
|
|
26289
|
-
return new Vector2(elements[0] * position.x + elements[3] * position.y + elements[6], elements[1] * position.x + elements[4] * position.y + elements[7]);
|
|
26290
|
-
};
|
|
26291
|
-
_proto.controlBelongsToSubtree = function controlBelongsToSubtree(control, subtree) {
|
|
26292
|
-
var current = control;
|
|
26293
|
-
while(current){
|
|
26294
|
-
if (current === subtree) {
|
|
26295
|
-
return true;
|
|
26296
|
-
}
|
|
26297
|
-
current = current.parent;
|
|
26298
|
-
}
|
|
26299
|
-
return false;
|
|
26300
|
-
};
|
|
26301
|
-
_proto.isControlValid = function isControlValid(control) {
|
|
26302
|
-
return !!control && !control.isDisposed && control.root === this;
|
|
26303
|
-
};
|
|
26304
|
-
_proto.isControlUsable = function isControlUsable(control) {
|
|
26305
|
-
if (!this.isControlValid(control) || !control.visibleInHierarchy || !control.enabledInHierarchy) {
|
|
26306
|
-
return false;
|
|
26307
|
-
}
|
|
26308
|
-
var root = this.findCanvasRoot(control);
|
|
26309
|
-
return !root || !root.inputDisabled;
|
|
26310
|
-
};
|
|
26311
|
-
_proto.findCanvasRoot = function findCanvasRoot(control) {
|
|
26312
|
-
var current = control;
|
|
26313
|
-
while(current && current !== this){
|
|
26314
|
-
if (_instanceof1(current, CanvasRootControl)) {
|
|
26315
|
-
return current;
|
|
26316
|
-
}
|
|
26317
|
-
current = current.parent;
|
|
26318
|
-
}
|
|
26319
|
-
return null;
|
|
26320
|
-
};
|
|
26321
|
-
_proto.isFocusTargetUsable = function isFocusTargetUsable(control) {
|
|
26322
|
-
return this.isControlUsable(control) && control.getFocusModeWithOverride() !== exports.FocusMode.None;
|
|
26323
|
-
};
|
|
26324
|
-
return WindowRootControl;
|
|
26325
|
-
}(RootControl);
|
|
26326
|
-
|
|
26327
|
-
exports.CanvasRenderMode = void 0;
|
|
26328
|
-
(function(CanvasRenderMode) {
|
|
26329
|
-
CanvasRenderMode[CanvasRenderMode["ScreenSpace"] = 0] = "ScreenSpace";
|
|
26330
|
-
CanvasRenderMode[CanvasRenderMode["CameraSpace"] = 1] = "CameraSpace";
|
|
26331
|
-
CanvasRenderMode[CanvasRenderMode["WorldSpace"] = 2] = "WorldSpace";
|
|
26332
|
-
CanvasRenderMode[CanvasRenderMode["WorldSpaceFaceCamera"] = 3] = "WorldSpaceFaceCamera";
|
|
26333
|
-
})(exports.CanvasRenderMode || (exports.CanvasRenderMode = {}));
|
|
26334
|
-
/** Canvas-layer boundary attached to a VFXItem. Input state remains owned by the window root. */ var UICanvas = /*#__PURE__*/ function(Component) {
|
|
26335
|
-
_inherits(UICanvas, Component);
|
|
26336
|
-
function UICanvas(engine) {
|
|
26337
|
-
var _this;
|
|
26338
|
-
_this = Component.call(this, engine) || this;
|
|
26339
|
-
_this.renderMode = 0;
|
|
26340
|
-
_this.receivesEvents = true;
|
|
26341
|
-
_this._order = 0;
|
|
26342
|
-
_this.registered = false;
|
|
26343
|
-
_this.rootControl = new CanvasRootControl(engine, _assert_this_initialized(_this));
|
|
26344
|
-
return _this;
|
|
26345
|
-
}
|
|
26346
|
-
var _proto = UICanvas.prototype;
|
|
26347
|
-
_proto.onEnable = function onEnable() {
|
|
26348
|
-
this.register();
|
|
26349
|
-
};
|
|
26350
|
-
_proto.onDisable = function onDisable() {
|
|
26351
|
-
this.unregister();
|
|
26352
|
-
};
|
|
26353
|
-
_proto.onDestroy = function onDestroy() {
|
|
26354
|
-
this.destroyCanvas();
|
|
26355
|
-
};
|
|
26356
|
-
_proto.dispose = function dispose() {
|
|
26357
|
-
this.destroyCanvas();
|
|
26358
|
-
Component.prototype.dispose.call(this);
|
|
26359
|
-
};
|
|
26360
|
-
_proto.register = function register() {
|
|
26361
|
-
if (!this.registered) {
|
|
26362
|
-
this.rootControl.parent = this.engine.windowRoot.canvases;
|
|
26363
|
-
this.registered = true;
|
|
26364
|
-
}
|
|
26365
|
-
};
|
|
26366
|
-
_proto.unregister = function unregister() {
|
|
26367
|
-
if (this.registered) {
|
|
26368
|
-
this.rootControl.parent = null;
|
|
26369
|
-
this.registered = false;
|
|
26370
|
-
}
|
|
26371
|
-
};
|
|
26372
|
-
_proto.destroyCanvas = function destroyCanvas() {
|
|
26373
|
-
this.unregister();
|
|
26374
|
-
if (!this.rootControl.isDisposed) {
|
|
26375
|
-
this.rootControl.dispose();
|
|
26376
|
-
}
|
|
26377
|
-
};
|
|
26378
|
-
_create_class(UICanvas, [
|
|
26379
|
-
{
|
|
26380
|
-
key: "order",
|
|
26381
|
-
get: function get() {
|
|
26382
|
-
return this._order;
|
|
26383
|
-
},
|
|
26384
|
-
set: function set(value) {
|
|
26385
|
-
if (this._order !== value) {
|
|
26386
|
-
this._order = value;
|
|
26387
|
-
this.engine.windowRoot.canvases.sortCanvases();
|
|
26388
|
-
}
|
|
26389
|
-
}
|
|
26390
|
-
},
|
|
26391
|
-
{
|
|
26392
|
-
key: "isVisible",
|
|
26393
|
-
get: function get() {
|
|
26394
|
-
var _this_item;
|
|
26395
|
-
return this.renderMode === 0 && this.enabled && !!((_this_item = this.item) == null ? void 0 : _this_item.isActive);
|
|
26396
|
-
}
|
|
26397
|
-
}
|
|
26398
|
-
]);
|
|
26399
|
-
return UICanvas;
|
|
26400
|
-
}(Component);
|
|
26401
|
-
|
|
26402
|
-
/**
|
|
26403
|
-
* Scene-tree bridge for a GUI Control. The VFXItem tree owns lifecycle and
|
|
26404
|
-
* serialization while the Control tree owns layout, drawing and input.
|
|
26405
|
-
*/ var UIControl = /*#__PURE__*/ function(Component) {
|
|
26406
|
-
_inherits(UIControl, Component);
|
|
26407
|
-
function UIControl(engine) {
|
|
26408
|
-
var _this;
|
|
26409
|
-
_this = Component.call(this, engine) || this;
|
|
26410
|
-
_this.controlNode = null;
|
|
26411
|
-
_this.linkedItemTransform = null;
|
|
26412
|
-
_this.linkedControl = null;
|
|
26413
|
-
_this.syncingLocation = false;
|
|
26414
|
-
_this.itemTransformChanged = function() {
|
|
26415
|
-
return _this.syncItemLocationToControl();
|
|
26416
|
-
};
|
|
26417
|
-
_this.controlLocationChanged = function() {
|
|
26418
|
-
return _this.syncControlLocationToItem();
|
|
26419
|
-
};
|
|
26420
|
-
return _this;
|
|
26421
|
-
}
|
|
26422
|
-
var _proto = UIControl.prototype;
|
|
26423
|
-
_proto.onAwake = function onAwake() {
|
|
26424
|
-
this.syncControl();
|
|
26425
|
-
};
|
|
26426
|
-
_proto.onEnable = function onEnable() {
|
|
26427
|
-
if (this.controlNode) {
|
|
26428
|
-
this.controlNode.visible = this.item.isActive;
|
|
26429
|
-
this.controlNode.enabled = true;
|
|
26430
|
-
}
|
|
26431
|
-
};
|
|
26432
|
-
_proto.onDisable = function onDisable() {
|
|
26433
|
-
if (this.controlNode) {
|
|
26434
|
-
this.controlNode.visible = this.item.isActive;
|
|
26435
|
-
this.controlNode.enabled = false;
|
|
26436
|
-
}
|
|
26437
|
-
};
|
|
26438
|
-
_proto.onParentChanged = function onParentChanged() {
|
|
26439
|
-
this.syncControl();
|
|
26440
|
-
};
|
|
26441
|
-
_proto.onOrderInParentChanged = function onOrderInParentChanged() {
|
|
26442
|
-
this.syncControlOrder();
|
|
26443
|
-
};
|
|
26444
|
-
_proto.onDestroy = function onDestroy() {
|
|
26445
|
-
this.disposeControl();
|
|
26446
|
-
};
|
|
26447
|
-
_proto.dispose = function dispose() {
|
|
26448
|
-
this.disposeControl();
|
|
26449
|
-
Component.prototype.dispose.call(this);
|
|
26450
|
-
};
|
|
26451
|
-
/** Unlinks the GUI object without disposing or modifying it. */ _proto.unlinkControl = function unlinkControl() {
|
|
26452
|
-
if (this.controlNode) {
|
|
26453
|
-
this.unbindLocationSync();
|
|
26454
|
-
this.controlNode = null;
|
|
26455
|
-
}
|
|
26456
|
-
};
|
|
26457
|
-
_proto.disposeControl = function disposeControl() {
|
|
26458
|
-
var control = this.controlNode;
|
|
26459
|
-
if (control) {
|
|
26460
|
-
this.unbindLocationSync();
|
|
26461
|
-
this.controlNode = null;
|
|
26462
|
-
control.dispose();
|
|
26463
|
-
}
|
|
26464
|
-
};
|
|
26465
|
-
_proto.syncControl = function syncControl() {
|
|
26466
|
-
var control = this.controlNode;
|
|
26467
|
-
if (!control || !this.item) {
|
|
26468
|
-
return;
|
|
26469
|
-
}
|
|
26470
|
-
this.syncingLocation = true;
|
|
26471
|
-
try {
|
|
26472
|
-
control.visible = this.item.isActive;
|
|
26473
|
-
control.enabled = this.enabled;
|
|
26474
|
-
control.parent = this.resolveParent();
|
|
26475
|
-
this.syncControlOrder();
|
|
26476
|
-
this.copyItemLocationToControl();
|
|
26477
|
-
} finally{
|
|
26478
|
-
this.syncingLocation = false;
|
|
26479
|
-
}
|
|
26480
|
-
this.bindLocationSync();
|
|
26481
|
-
};
|
|
26482
|
-
_proto.syncControlOrder = function syncControlOrder() {
|
|
26483
|
-
if (this.controlNode && this.item) {
|
|
26484
|
-
this.controlNode.indexInParent = this.item.orderInParent;
|
|
26485
|
-
}
|
|
26486
|
-
};
|
|
26487
|
-
_proto.resolveParent = function resolveParent() {
|
|
26488
|
-
var parentItem = this.item.parent;
|
|
26489
|
-
if (!parentItem) {
|
|
26490
|
-
var _UIControl_fallbackParentGetDelegate;
|
|
26491
|
-
return (_UIControl_fallbackParentGetDelegate = UIControl.fallbackParentGetDelegate == null ? void 0 : UIControl.fallbackParentGetDelegate.call(UIControl, this)) != null ? _UIControl_fallbackParentGetDelegate : null;
|
|
26492
|
-
}
|
|
26493
|
-
var uiControl = parentItem.getComponent(UIControl);
|
|
26494
|
-
if ((uiControl == null ? void 0 : uiControl.control) && "children" in uiControl.control) {
|
|
26495
|
-
return uiControl.control;
|
|
26496
|
-
}
|
|
26497
|
-
var canvas = parentItem.getComponent(UICanvas);
|
|
26498
|
-
var _canvas_rootControl, _ref;
|
|
26499
|
-
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;
|
|
26500
|
-
};
|
|
26501
|
-
_proto.bindLocationSync = function bindLocationSync() {
|
|
26502
|
-
var itemTransform = this.item.transform;
|
|
26503
|
-
var control = this.controlNode;
|
|
26504
|
-
if (this.linkedItemTransform === itemTransform && this.linkedControl === control) {
|
|
26505
|
-
return;
|
|
26506
|
-
}
|
|
26507
|
-
this.unbindLocationSync();
|
|
26508
|
-
if (control) {
|
|
26509
|
-
this.linkedItemTransform = itemTransform;
|
|
26510
|
-
this.linkedControl = control;
|
|
26511
|
-
itemTransform.on("changed", this.itemTransformChanged);
|
|
26512
|
-
control.on("locationChanged", this.controlLocationChanged);
|
|
26513
|
-
}
|
|
26514
|
-
};
|
|
26515
|
-
_proto.unbindLocationSync = function unbindLocationSync() {
|
|
26516
|
-
var _this_linkedItemTransform, _this_linkedControl;
|
|
26517
|
-
(_this_linkedItemTransform = this.linkedItemTransform) == null ? void 0 : _this_linkedItemTransform.off("changed", this.itemTransformChanged);
|
|
26518
|
-
(_this_linkedControl = this.linkedControl) == null ? void 0 : _this_linkedControl.off("locationChanged", this.controlLocationChanged);
|
|
26519
|
-
this.linkedItemTransform = null;
|
|
26520
|
-
this.linkedControl = null;
|
|
26521
|
-
};
|
|
26522
|
-
_proto.syncItemLocationToControl = function syncItemLocationToControl() {
|
|
26523
|
-
if (!this.syncingLocation && this.controlNode) {
|
|
26524
|
-
this.syncingLocation = true;
|
|
26525
|
-
try {
|
|
26526
|
-
this.copyItemLocationToControl();
|
|
26527
|
-
} finally{
|
|
26528
|
-
this.syncingLocation = false;
|
|
26529
|
-
}
|
|
26530
|
-
}
|
|
26531
|
-
};
|
|
26532
|
-
_proto.syncControlLocationToItem = function syncControlLocationToItem() {
|
|
26533
|
-
var control = this.controlNode;
|
|
26534
|
-
if (!this.syncingLocation && control) {
|
|
26535
|
-
var source = control.location;
|
|
26536
|
-
var target = this.item.transform.position;
|
|
26537
|
-
if (source.x !== target.x || source.y !== target.y) {
|
|
26538
|
-
this.syncingLocation = true;
|
|
26539
|
-
try {
|
|
26540
|
-
this.item.transform.setPosition(source.x, source.y, target.z);
|
|
26541
|
-
} finally{
|
|
26542
|
-
this.syncingLocation = false;
|
|
26543
|
-
}
|
|
26544
|
-
}
|
|
26545
|
-
}
|
|
26546
|
-
};
|
|
26547
|
-
_proto.copyItemLocationToControl = function copyItemLocationToControl() {
|
|
26548
|
-
var control = this.controlNode;
|
|
26549
|
-
if (control) {
|
|
26550
|
-
var source = this.item.transform.position;
|
|
26551
|
-
var target = control.location;
|
|
26552
|
-
if (source.x !== target.x || source.y !== target.y) {
|
|
26553
|
-
control.setPosition(source.x, source.y);
|
|
26554
|
-
}
|
|
26555
|
-
}
|
|
26556
|
-
};
|
|
26557
|
-
_create_class(UIControl, [
|
|
26558
|
-
{
|
|
26559
|
-
key: "control",
|
|
26560
|
-
get: function get() {
|
|
26561
|
-
return this.controlNode;
|
|
26562
|
-
},
|
|
26563
|
-
set: function set(value) {
|
|
26564
|
-
if (value === this.controlNode) {
|
|
26565
|
-
return;
|
|
26566
|
-
}
|
|
26567
|
-
this.disposeControl();
|
|
26568
|
-
if (value) {
|
|
26569
|
-
if (value.owner && value.owner !== this && value.owner.control === value) {
|
|
26570
|
-
throw new Error("A Control can only be owned by one UIControl.");
|
|
26571
|
-
}
|
|
26572
|
-
this.controlNode = value;
|
|
26573
|
-
value.owner = this;
|
|
26574
|
-
this.syncControl();
|
|
26575
|
-
}
|
|
26576
|
-
}
|
|
26577
|
-
},
|
|
26578
|
-
{
|
|
26579
|
-
key: "hasControl",
|
|
26580
|
-
get: function get() {
|
|
26581
|
-
return this.controlNode !== null;
|
|
26582
|
-
}
|
|
26583
|
-
}
|
|
26584
|
-
]);
|
|
26585
|
-
return UIControl;
|
|
26586
|
-
}(Component);
|
|
26587
|
-
|
|
26588
24752
|
exports.CameraController = /*#__PURE__*/ function(Component) {
|
|
26589
24753
|
_inherits(CameraController, Component);
|
|
26590
24754
|
function CameraController(engine, props) {
|
|
@@ -26619,6 +24783,42 @@ exports.CameraController = __decorate([
|
|
|
26619
24783
|
effectsClass(DataType.CameraController)
|
|
26620
24784
|
], exports.CameraController);
|
|
26621
24785
|
|
|
24786
|
+
function _get_prototype_of(o) {
|
|
24787
|
+
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
24788
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
24789
|
+
};
|
|
24790
|
+
return _get_prototype_of(o);
|
|
24791
|
+
}
|
|
24792
|
+
|
|
24793
|
+
function _is_native_function(fn) {
|
|
24794
|
+
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
24795
|
+
}
|
|
24796
|
+
|
|
24797
|
+
function _wrap_native_super(Class) {
|
|
24798
|
+
var _cache = typeof Map === "function" ? new Map() : undefined;
|
|
24799
|
+
_wrap_native_super = function _wrap_native_super(Class) {
|
|
24800
|
+
if (Class === null || !_is_native_function(Class)) return Class;
|
|
24801
|
+
if (typeof Class !== "function") throw new TypeError("Super expression must either be null or a function");
|
|
24802
|
+
if (typeof _cache !== "undefined") {
|
|
24803
|
+
if (_cache.has(Class)) return _cache.get(Class);
|
|
24804
|
+
_cache.set(Class, Wrapper);
|
|
24805
|
+
}
|
|
24806
|
+
function Wrapper() {
|
|
24807
|
+
return _construct(Class, arguments, _get_prototype_of(this).constructor);
|
|
24808
|
+
}
|
|
24809
|
+
Wrapper.prototype = Object.create(Class.prototype, {
|
|
24810
|
+
constructor: {
|
|
24811
|
+
value: Wrapper,
|
|
24812
|
+
enumerable: false,
|
|
24813
|
+
writable: true,
|
|
24814
|
+
configurable: true
|
|
24815
|
+
}
|
|
24816
|
+
});
|
|
24817
|
+
return _set_prototype_of(Wrapper, Class);
|
|
24818
|
+
};
|
|
24819
|
+
return _wrap_native_super(Class);
|
|
24820
|
+
}
|
|
24821
|
+
|
|
26622
24822
|
var CameraVFXItemLoader = /*#__PURE__*/ function(Plugin) {
|
|
26623
24823
|
_inherits(CameraVFXItemLoader, Plugin);
|
|
26624
24824
|
function CameraVFXItemLoader() {
|
|
@@ -26627,6 +24827,255 @@ var CameraVFXItemLoader = /*#__PURE__*/ function(Plugin) {
|
|
|
26627
24827
|
return CameraVFXItemLoader;
|
|
26628
24828
|
}(_wrap_native_super(Plugin));
|
|
26629
24829
|
|
|
24830
|
+
exports.MouseButton = void 0;
|
|
24831
|
+
(function(MouseButton) {
|
|
24832
|
+
MouseButton[MouseButton["None"] = 0] = "None";
|
|
24833
|
+
MouseButton[MouseButton["Left"] = 1] = "Left";
|
|
24834
|
+
MouseButton[MouseButton["Right"] = 2] = "Right";
|
|
24835
|
+
MouseButton[MouseButton["Middle"] = 3] = "Middle";
|
|
24836
|
+
MouseButton[MouseButton["WheelUp"] = 4] = "WheelUp";
|
|
24837
|
+
MouseButton[MouseButton["WheelDown"] = 5] = "WheelDown";
|
|
24838
|
+
MouseButton[MouseButton["WheelLeft"] = 6] = "WheelLeft";
|
|
24839
|
+
MouseButton[MouseButton["WheelRight"] = 7] = "WheelRight";
|
|
24840
|
+
MouseButton[MouseButton["Xbutton1"] = 8] = "Xbutton1";
|
|
24841
|
+
MouseButton[MouseButton["Xbutton2"] = 9] = "Xbutton2";
|
|
24842
|
+
})(exports.MouseButton || (exports.MouseButton = {}));
|
|
24843
|
+
exports.MouseButtonMask = void 0;
|
|
24844
|
+
(function(MouseButtonMask) {
|
|
24845
|
+
MouseButtonMask[MouseButtonMask["None"] = 0] = "None";
|
|
24846
|
+
MouseButtonMask[MouseButtonMask["Left"] = 1] = "Left";
|
|
24847
|
+
MouseButtonMask[MouseButtonMask["Right"] = 2] = "Right";
|
|
24848
|
+
MouseButtonMask[MouseButtonMask["Middle"] = 4] = "Middle";
|
|
24849
|
+
MouseButtonMask[MouseButtonMask["Xbutton1"] = 128] = "Xbutton1";
|
|
24850
|
+
MouseButtonMask[MouseButtonMask["Xbutton2"] = 256] = "Xbutton2";
|
|
24851
|
+
})(exports.MouseButtonMask || (exports.MouseButtonMask = {}));
|
|
24852
|
+
exports.KeyLocation = void 0;
|
|
24853
|
+
(function(KeyLocation) {
|
|
24854
|
+
KeyLocation[KeyLocation["Unspecified"] = 0] = "Unspecified";
|
|
24855
|
+
KeyLocation[KeyLocation["Left"] = 1] = "Left";
|
|
24856
|
+
KeyLocation[KeyLocation["Right"] = 2] = "Right";
|
|
24857
|
+
})(exports.KeyLocation || (exports.KeyLocation = {}));
|
|
24858
|
+
|
|
24859
|
+
function transformPoint(transform, value) {
|
|
24860
|
+
var elements = transform.elements;
|
|
24861
|
+
return new Vector2(elements[0] * value.x + elements[3] * value.y + elements[6], elements[1] * value.x + elements[4] * value.y + elements[7]);
|
|
24862
|
+
}
|
|
24863
|
+
function transformVector(transform, value) {
|
|
24864
|
+
var elements = transform.elements;
|
|
24865
|
+
return new Vector2(elements[0] * value.x + elements[3] * value.y, elements[1] * value.x + elements[4] * value.y);
|
|
24866
|
+
}
|
|
24867
|
+
var InputEvent = /*#__PURE__*/ function() {
|
|
24868
|
+
function InputEvent() {
|
|
24869
|
+
this.device = 0;
|
|
24870
|
+
this.pressed = false;
|
|
24871
|
+
this.canceled = false;
|
|
24872
|
+
this._accepted = false;
|
|
24873
|
+
}
|
|
24874
|
+
var _proto = InputEvent.prototype;
|
|
24875
|
+
_proto.accept = function accept() {
|
|
24876
|
+
this._accepted = true;
|
|
24877
|
+
};
|
|
24878
|
+
_proto.clearAccepted = function clearAccepted() {
|
|
24879
|
+
this._accepted = false;
|
|
24880
|
+
};
|
|
24881
|
+
_proto.isAccepted = function isAccepted() {
|
|
24882
|
+
return this._accepted;
|
|
24883
|
+
};
|
|
24884
|
+
_proto.isPressed = function isPressed() {
|
|
24885
|
+
return this.pressed && !this.canceled;
|
|
24886
|
+
};
|
|
24887
|
+
_proto.isReleased = function isReleased() {
|
|
24888
|
+
return !this.pressed && !this.canceled;
|
|
24889
|
+
};
|
|
24890
|
+
_proto.isCanceled = function isCanceled() {
|
|
24891
|
+
return this.canceled;
|
|
24892
|
+
};
|
|
24893
|
+
_proto.isEcho = function isEcho() {
|
|
24894
|
+
return false;
|
|
24895
|
+
};
|
|
24896
|
+
_proto.xformedBy = function xformedBy(transform) {
|
|
24897
|
+
return this;
|
|
24898
|
+
};
|
|
24899
|
+
return InputEvent;
|
|
24900
|
+
}();
|
|
24901
|
+
InputEvent.deviceIdEmulation = -1;
|
|
24902
|
+
InputEvent.deviceIdInternal = -2;
|
|
24903
|
+
InputEvent.deviceIdKeyboard = 16;
|
|
24904
|
+
InputEvent.deviceIdMouse = 32;
|
|
24905
|
+
var InputEventWithModifiers = /*#__PURE__*/ function(InputEvent) {
|
|
24906
|
+
_inherits(InputEventWithModifiers, InputEvent);
|
|
24907
|
+
function InputEventWithModifiers() {
|
|
24908
|
+
var _this;
|
|
24909
|
+
_this = InputEvent.apply(this, arguments) || this;
|
|
24910
|
+
_this.commandOrControlAutoremap = false;
|
|
24911
|
+
_this.shiftPressed = false;
|
|
24912
|
+
_this.altPressed = false;
|
|
24913
|
+
_this.metaPressed = false;
|
|
24914
|
+
_this.ctrlPressed = false;
|
|
24915
|
+
return _this;
|
|
24916
|
+
}
|
|
24917
|
+
var _proto = InputEventWithModifiers.prototype;
|
|
24918
|
+
_proto.copyModifiersTo = function copyModifiersTo(event) {
|
|
24919
|
+
event.device = this.device;
|
|
24920
|
+
event.pressed = this.pressed;
|
|
24921
|
+
event.canceled = this.canceled;
|
|
24922
|
+
event.commandOrControlAutoremap = this.commandOrControlAutoremap;
|
|
24923
|
+
event.shiftPressed = this.shiftPressed;
|
|
24924
|
+
event.altPressed = this.altPressed;
|
|
24925
|
+
event.metaPressed = this.metaPressed;
|
|
24926
|
+
event.ctrlPressed = this.ctrlPressed;
|
|
24927
|
+
};
|
|
24928
|
+
return InputEventWithModifiers;
|
|
24929
|
+
}(_wrap_native_super(InputEvent));
|
|
24930
|
+
var InputEventKey = /*#__PURE__*/ function(InputEventWithModifiers) {
|
|
24931
|
+
_inherits(InputEventKey, InputEventWithModifiers);
|
|
24932
|
+
function InputEventKey() {
|
|
24933
|
+
var _this;
|
|
24934
|
+
_this = InputEventWithModifiers.apply(this, arguments) || this;
|
|
24935
|
+
_this.keycode = "";
|
|
24936
|
+
_this.physicalKeycode = "";
|
|
24937
|
+
_this.keyLabel = "";
|
|
24938
|
+
_this.unicode = 0;
|
|
24939
|
+
_this.location = exports.KeyLocation.Unspecified;
|
|
24940
|
+
_this.echo = false;
|
|
24941
|
+
return _this;
|
|
24942
|
+
}
|
|
24943
|
+
var _proto = InputEventKey.prototype;
|
|
24944
|
+
_proto.isEcho = function isEcho() {
|
|
24945
|
+
return this.echo;
|
|
24946
|
+
};
|
|
24947
|
+
return InputEventKey;
|
|
24948
|
+
}(InputEventWithModifiers);
|
|
24949
|
+
var InputEventMouse = /*#__PURE__*/ function(InputEventWithModifiers) {
|
|
24950
|
+
_inherits(InputEventMouse, InputEventWithModifiers);
|
|
24951
|
+
function InputEventMouse() {
|
|
24952
|
+
var _this;
|
|
24953
|
+
_this = InputEventWithModifiers.apply(this, arguments) || this;
|
|
24954
|
+
_this.buttonMask = exports.MouseButtonMask.None;
|
|
24955
|
+
_this.position = new Vector2();
|
|
24956
|
+
_this.globalPosition = new Vector2();
|
|
24957
|
+
return _this;
|
|
24958
|
+
}
|
|
24959
|
+
var _proto = InputEventMouse.prototype;
|
|
24960
|
+
_proto.copyMouseTo = function copyMouseTo(event) {
|
|
24961
|
+
this.copyModifiersTo(event);
|
|
24962
|
+
event.buttonMask = this.buttonMask;
|
|
24963
|
+
event.position.copyFrom(this.position);
|
|
24964
|
+
event.globalPosition.copyFrom(this.globalPosition);
|
|
24965
|
+
};
|
|
24966
|
+
return InputEventMouse;
|
|
24967
|
+
}(InputEventWithModifiers);
|
|
24968
|
+
var InputEventMouseButton = /*#__PURE__*/ function(InputEventMouse) {
|
|
24969
|
+
_inherits(InputEventMouseButton, InputEventMouse);
|
|
24970
|
+
function InputEventMouseButton() {
|
|
24971
|
+
var _this;
|
|
24972
|
+
_this = InputEventMouse.apply(this, arguments) || this;
|
|
24973
|
+
_this.factor = 1;
|
|
24974
|
+
_this.buttonIndex = exports.MouseButton.None;
|
|
24975
|
+
_this.doubleClick = false;
|
|
24976
|
+
return _this;
|
|
24977
|
+
}
|
|
24978
|
+
var _proto = InputEventMouseButton.prototype;
|
|
24979
|
+
_proto.xformedBy = function xformedBy(transform) {
|
|
24980
|
+
var event = new InputEventMouseButton();
|
|
24981
|
+
this.copyMouseTo(event);
|
|
24982
|
+
event.position.copyFrom(transformPoint(transform, this.position));
|
|
24983
|
+
event.factor = this.factor;
|
|
24984
|
+
event.buttonIndex = this.buttonIndex;
|
|
24985
|
+
event.doubleClick = this.doubleClick;
|
|
24986
|
+
return event;
|
|
24987
|
+
};
|
|
24988
|
+
return InputEventMouseButton;
|
|
24989
|
+
}(InputEventMouse);
|
|
24990
|
+
var InputEventMouseMotion = /*#__PURE__*/ function(InputEventMouse) {
|
|
24991
|
+
_inherits(InputEventMouseMotion, InputEventMouse);
|
|
24992
|
+
function InputEventMouseMotion() {
|
|
24993
|
+
var _this;
|
|
24994
|
+
_this = InputEventMouse.apply(this, arguments) || this;
|
|
24995
|
+
_this.tilt = new Vector2();
|
|
24996
|
+
_this.pressure = 0;
|
|
24997
|
+
_this.relative = new Vector2();
|
|
24998
|
+
_this.screenRelative = new Vector2();
|
|
24999
|
+
_this.velocity = new Vector2();
|
|
25000
|
+
_this.screenVelocity = new Vector2();
|
|
25001
|
+
_this.penInverted = false;
|
|
25002
|
+
return _this;
|
|
25003
|
+
}
|
|
25004
|
+
var _proto = InputEventMouseMotion.prototype;
|
|
25005
|
+
_proto.xformedBy = function xformedBy(transform) {
|
|
25006
|
+
var event = new InputEventMouseMotion();
|
|
25007
|
+
this.copyMouseTo(event);
|
|
25008
|
+
event.position.copyFrom(transformPoint(transform, this.position));
|
|
25009
|
+
event.tilt.copyFrom(this.tilt);
|
|
25010
|
+
event.pressure = this.pressure;
|
|
25011
|
+
event.relative.copyFrom(transformVector(transform, this.relative));
|
|
25012
|
+
event.screenRelative.copyFrom(this.screenRelative);
|
|
25013
|
+
event.velocity.copyFrom(transformVector(transform, this.velocity));
|
|
25014
|
+
event.screenVelocity.copyFrom(this.screenVelocity);
|
|
25015
|
+
event.penInverted = this.penInverted;
|
|
25016
|
+
return event;
|
|
25017
|
+
};
|
|
25018
|
+
return InputEventMouseMotion;
|
|
25019
|
+
}(InputEventMouse);
|
|
25020
|
+
var InputEventScreenTouch = /*#__PURE__*/ function(InputEvent) {
|
|
25021
|
+
_inherits(InputEventScreenTouch, InputEvent);
|
|
25022
|
+
function InputEventScreenTouch() {
|
|
25023
|
+
var _this;
|
|
25024
|
+
_this = InputEvent.apply(this, arguments) || this;
|
|
25025
|
+
_this.index = 0;
|
|
25026
|
+
_this.position = new Vector2();
|
|
25027
|
+
_this.doubleTap = false;
|
|
25028
|
+
return _this;
|
|
25029
|
+
}
|
|
25030
|
+
var _proto = InputEventScreenTouch.prototype;
|
|
25031
|
+
_proto.xformedBy = function xformedBy(transform) {
|
|
25032
|
+
var event = new InputEventScreenTouch();
|
|
25033
|
+
event.device = this.device;
|
|
25034
|
+
event.pressed = this.pressed;
|
|
25035
|
+
event.canceled = this.canceled;
|
|
25036
|
+
event.index = this.index;
|
|
25037
|
+
event.position.copyFrom(transformPoint(transform, this.position));
|
|
25038
|
+
event.doubleTap = this.doubleTap;
|
|
25039
|
+
return event;
|
|
25040
|
+
};
|
|
25041
|
+
return InputEventScreenTouch;
|
|
25042
|
+
}(_wrap_native_super(InputEvent));
|
|
25043
|
+
var InputEventScreenDrag = /*#__PURE__*/ function(InputEvent) {
|
|
25044
|
+
_inherits(InputEventScreenDrag, InputEvent);
|
|
25045
|
+
function InputEventScreenDrag() {
|
|
25046
|
+
var _this;
|
|
25047
|
+
_this = InputEvent.apply(this, arguments) || this;
|
|
25048
|
+
_this.index = 0;
|
|
25049
|
+
_this.position = new Vector2();
|
|
25050
|
+
_this.relative = new Vector2();
|
|
25051
|
+
_this.screenRelative = new Vector2();
|
|
25052
|
+
_this.velocity = new Vector2();
|
|
25053
|
+
_this.screenVelocity = new Vector2();
|
|
25054
|
+
_this.pressure = 0;
|
|
25055
|
+
_this.tilt = new Vector2();
|
|
25056
|
+
_this.penInverted = false;
|
|
25057
|
+
return _this;
|
|
25058
|
+
}
|
|
25059
|
+
var _proto = InputEventScreenDrag.prototype;
|
|
25060
|
+
_proto.xformedBy = function xformedBy(transform) {
|
|
25061
|
+
var event = new InputEventScreenDrag();
|
|
25062
|
+
event.device = this.device;
|
|
25063
|
+
event.pressed = this.pressed;
|
|
25064
|
+
event.canceled = this.canceled;
|
|
25065
|
+
event.index = this.index;
|
|
25066
|
+
event.position.copyFrom(transformPoint(transform, this.position));
|
|
25067
|
+
event.relative.copyFrom(transformVector(transform, this.relative));
|
|
25068
|
+
event.screenRelative.copyFrom(this.screenRelative);
|
|
25069
|
+
event.velocity.copyFrom(transformVector(transform, this.velocity));
|
|
25070
|
+
event.screenVelocity.copyFrom(this.screenVelocity);
|
|
25071
|
+
event.pressure = this.pressure;
|
|
25072
|
+
event.tilt.copyFrom(this.tilt);
|
|
25073
|
+
event.penInverted = this.penInverted;
|
|
25074
|
+
return event;
|
|
25075
|
+
};
|
|
25076
|
+
return InputEventScreenDrag;
|
|
25077
|
+
}(_wrap_native_super(InputEvent));
|
|
25078
|
+
|
|
26630
25079
|
var EVENT_TYPE_CLICK = "click";
|
|
26631
25080
|
var EVENT_TYPE_TOUCH_START = "touchstart";
|
|
26632
25081
|
var EVENT_TYPE_TOUCH_MOVE = "touchmove";
|
|
@@ -26637,49 +25086,52 @@ exports.PointerEventType = void 0;
|
|
|
26637
25086
|
PointerEventType[PointerEventType["PointerUp"] = 1] = "PointerUp";
|
|
26638
25087
|
PointerEventType[PointerEventType["PointerMove"] = 2] = "PointerMove";
|
|
26639
25088
|
})(exports.PointerEventType || (exports.PointerEventType = {}));
|
|
26640
|
-
var EventSystem = /*#__PURE__*/ function() {
|
|
25089
|
+
var EventSystem = /*#__PURE__*/ function(EventEmitter) {
|
|
25090
|
+
_inherits(EventSystem, EventEmitter);
|
|
26641
25091
|
function EventSystem(engine, allowPropagation) {
|
|
26642
|
-
var _this = this;
|
|
26643
25092
|
if (allowPropagation === void 0) allowPropagation = false;
|
|
26644
|
-
|
|
26645
|
-
|
|
26646
|
-
|
|
26647
|
-
|
|
26648
|
-
|
|
26649
|
-
|
|
26650
|
-
|
|
26651
|
-
|
|
26652
|
-
|
|
26653
|
-
|
|
26654
|
-
|
|
26655
|
-
|
|
26656
|
-
|
|
26657
|
-
|
|
26658
|
-
|
|
26659
|
-
|
|
25093
|
+
var _this;
|
|
25094
|
+
_this = EventEmitter.call(this) || this;
|
|
25095
|
+
_this.engine = engine;
|
|
25096
|
+
_this.allowPropagation = allowPropagation;
|
|
25097
|
+
_this.skipPointerMovePicking = true;
|
|
25098
|
+
_this.emulateMouseFromTouch = true;
|
|
25099
|
+
_this.emulateTouchFromMouse = false;
|
|
25100
|
+
_this._enabled = true;
|
|
25101
|
+
_this.handlers = {};
|
|
25102
|
+
_this.nativeHandlers = [];
|
|
25103
|
+
_this.target = null;
|
|
25104
|
+
_this.mouseState = null;
|
|
25105
|
+
_this.mouseButtonMask = exports.MouseButtonMask.None;
|
|
25106
|
+
_this.touchStates = new Map();
|
|
25107
|
+
_this.mouseFromTouchIndex = null;
|
|
25108
|
+
_this.touchFromMousePressed = false;
|
|
25109
|
+
_this.addedTabIndex = false;
|
|
25110
|
+
_this.addedOutlineStyle = false;
|
|
25111
|
+
_this.onNativeWheel = function(event) {
|
|
26660
25112
|
if (!_this.enabled || !_this.target) {
|
|
26661
25113
|
return;
|
|
26662
25114
|
}
|
|
26663
25115
|
var position = _this.getCanvasPosition(event.clientX, event.clientY);
|
|
26664
25116
|
var handled = false;
|
|
26665
25117
|
if (event.deltaY !== 0) {
|
|
26666
|
-
handled = _this.pushWheelButton(event.deltaY < 0 ? exports.MouseButton.WheelUp : exports.MouseButton.WheelDown,
|
|
25118
|
+
handled = _this.pushWheelButton(event.deltaY < 0 ? exports.MouseButton.WheelUp : exports.MouseButton.WheelDown, normalizeWheelFactor(event.deltaY, event.deltaMode), position, event) || handled;
|
|
26667
25119
|
}
|
|
26668
25120
|
if (event.deltaX !== 0) {
|
|
26669
|
-
handled = _this.pushWheelButton(event.deltaX < 0 ? exports.MouseButton.WheelLeft : exports.MouseButton.WheelRight,
|
|
25121
|
+
handled = _this.pushWheelButton(event.deltaX < 0 ? exports.MouseButton.WheelLeft : exports.MouseButton.WheelRight, normalizeWheelFactor(event.deltaX, event.deltaMode), position, event) || handled;
|
|
26670
25122
|
}
|
|
26671
25123
|
_this.consumeNativeEvent(event, handled);
|
|
26672
25124
|
};
|
|
26673
|
-
|
|
25125
|
+
_this.onNativeKeyDown = function(event) {
|
|
26674
25126
|
_this.handleNativeKey(event, true);
|
|
26675
25127
|
};
|
|
26676
|
-
|
|
25128
|
+
_this.onNativeKeyUp = function(event) {
|
|
26677
25129
|
_this.handleNativeKey(event, false);
|
|
26678
25130
|
};
|
|
26679
|
-
|
|
25131
|
+
_this.onNativeMouseDown = function(event) {
|
|
26680
25132
|
_this.handleNativeMouseDown(event);
|
|
26681
25133
|
};
|
|
26682
|
-
|
|
25134
|
+
_this.onNativeMouseMove = function(event) {
|
|
26683
25135
|
var _state;
|
|
26684
25136
|
if (!_this.enabled || !_this.target) {
|
|
26685
25137
|
return;
|
|
@@ -26691,18 +25143,22 @@ var EventSystem = /*#__PURE__*/ function() {
|
|
|
26691
25143
|
var relative = new Vector2(position.x - state.last.x, position.y - state.last.y);
|
|
26692
25144
|
var velocity = _this.getVelocity(state, position);
|
|
26693
25145
|
var handled = _this.pushNativeMouseMotion(event, position, relative, velocity);
|
|
26694
|
-
(_state = state).
|
|
26695
|
-
if (!handled && (!state.pressed || !state.
|
|
25146
|
+
(_state = state).inputHandled || (_state.inputHandled = handled);
|
|
25147
|
+
if (!handled && (!state.pressed || !state.inputHandled)) {
|
|
26696
25148
|
var pointerEvent = _this.createPointerEvent(event, position, state, velocity);
|
|
26697
25149
|
_this.dispatchEvent(EVENT_TYPE_TOUCH_MOVE, pointerEvent);
|
|
26698
25150
|
}
|
|
26699
25151
|
_this.updatePointerState(state, position);
|
|
26700
25152
|
_this.consumeNativeEvent(event, handled);
|
|
26701
25153
|
};
|
|
26702
|
-
|
|
25154
|
+
_this.onNativeMouseUp = function(event) {
|
|
26703
25155
|
if (!_this.enabled || !_this.target) {
|
|
26704
25156
|
return;
|
|
26705
25157
|
}
|
|
25158
|
+
// Keep the canonical mask in sync even when mouseState already ended on a
|
|
25159
|
+
// previous button release. The target and Window listeners may see the
|
|
25160
|
+
// same mouseup, but clearing a bit twice is intentionally idempotent.
|
|
25161
|
+
_this.setMouseButtonPressed(event.button, false);
|
|
26706
25162
|
var position = _this.getCanvasPosition(event.clientX, event.clientY);
|
|
26707
25163
|
var existingState = _this.mouseState;
|
|
26708
25164
|
if (!(existingState == null ? void 0 : existingState.pressed)) {
|
|
@@ -26711,16 +25167,16 @@ var EventSystem = /*#__PURE__*/ function() {
|
|
|
26711
25167
|
var state = existingState;
|
|
26712
25168
|
var handled = _this.pushNativeMouseButton(event, position, false);
|
|
26713
25169
|
var pointerEvent = _this.createPointerEvent(event, position, state);
|
|
26714
|
-
if (!state.
|
|
25170
|
+
if (!state.inputHandled && !handled && _this.isClick(state, position)) {
|
|
26715
25171
|
_this.dispatchEvent(EVENT_TYPE_CLICK, pointerEvent);
|
|
26716
25172
|
}
|
|
26717
|
-
if (!handled && !state.
|
|
25173
|
+
if (!handled && !state.inputHandled) {
|
|
26718
25174
|
_this.dispatchEvent(EVENT_TYPE_TOUCH_END, pointerEvent);
|
|
26719
25175
|
}
|
|
26720
25176
|
_this.mouseState = null;
|
|
26721
|
-
_this.consumeNativeEvent(event, handled || state.
|
|
25177
|
+
_this.consumeNativeEvent(event, handled || state.inputHandled || !_this.allowPropagation);
|
|
26722
25178
|
};
|
|
26723
|
-
|
|
25179
|
+
_this.onNativeTouchStart = function(event) {
|
|
26724
25180
|
if (!_this.enabled) {
|
|
26725
25181
|
return;
|
|
26726
25182
|
}
|
|
@@ -26732,7 +25188,7 @@ var EventSystem = /*#__PURE__*/ function() {
|
|
|
26732
25188
|
_this.touchStates.set(touch.identifier, state);
|
|
26733
25189
|
state.pressed = true;
|
|
26734
25190
|
var handled = _this.pushNativeScreenTouch(touch.identifier, position, true, false, false);
|
|
26735
|
-
state.
|
|
25191
|
+
state.inputHandled = handled;
|
|
26736
25192
|
if (!handled) {
|
|
26737
25193
|
var pointerEvent = _this.createPointerEvent(event, position, state);
|
|
26738
25194
|
_this.dispatchEvent(EVENT_TYPE_TOUCH_START, pointerEvent);
|
|
@@ -26741,7 +25197,7 @@ var EventSystem = /*#__PURE__*/ function() {
|
|
|
26741
25197
|
}
|
|
26742
25198
|
_this.preventTouchDefaults(event);
|
|
26743
25199
|
};
|
|
26744
|
-
|
|
25200
|
+
_this.onNativeTouchMove = function(event) {
|
|
26745
25201
|
if (!_this.enabled) {
|
|
26746
25202
|
return;
|
|
26747
25203
|
}
|
|
@@ -26755,8 +25211,8 @@ var EventSystem = /*#__PURE__*/ function() {
|
|
|
26755
25211
|
var relative = new Vector2(position.x - state.last.x, position.y - state.last.y);
|
|
26756
25212
|
var velocity = _this.getVelocity(state, position);
|
|
26757
25213
|
var handled = _this.pushNativeScreenDrag(touch.identifier, position, relative, velocity);
|
|
26758
|
-
(_state = state).
|
|
26759
|
-
if (!handled && !state.
|
|
25214
|
+
(_state = state).inputHandled || (_state.inputHandled = handled);
|
|
25215
|
+
if (!handled && !state.inputHandled) {
|
|
26760
25216
|
var pointerEvent = _this.createPointerEvent(event, position, state, velocity);
|
|
26761
25217
|
_this.dispatchEvent(EVENT_TYPE_TOUCH_MOVE, pointerEvent);
|
|
26762
25218
|
}
|
|
@@ -26765,24 +25221,26 @@ var EventSystem = /*#__PURE__*/ function() {
|
|
|
26765
25221
|
}
|
|
26766
25222
|
_this.preventTouchDefaults(event);
|
|
26767
25223
|
};
|
|
26768
|
-
|
|
25224
|
+
_this.onNativeTouchEnd = function(event) {
|
|
26769
25225
|
_this.handleNativeTouchEnd(event, false);
|
|
26770
25226
|
};
|
|
26771
|
-
|
|
25227
|
+
_this.onNativeTouchCancel = function(event) {
|
|
26772
25228
|
_this.handleNativeTouchEnd(event, true);
|
|
26773
25229
|
};
|
|
26774
|
-
|
|
26775
|
-
|
|
26776
|
-
|
|
26777
|
-
|
|
26778
|
-
|
|
26779
|
-
_this.touchFromMousePressed = false;
|
|
26780
|
-
_this.engine.windowRoot.cancelPointerInput();
|
|
26781
|
-
}
|
|
25230
|
+
_this.onCanvasFocus = function() {
|
|
25231
|
+
_this.emit("canvasFocus");
|
|
25232
|
+
};
|
|
25233
|
+
_this.onCanvasBlur = function() {
|
|
25234
|
+
_this.emit("canvasBlur");
|
|
26782
25235
|
};
|
|
25236
|
+
return _this;
|
|
26783
25237
|
}
|
|
26784
25238
|
var _proto = EventSystem.prototype;
|
|
26785
|
-
|
|
25239
|
+
/**
|
|
25240
|
+
* Rebinds native input listeners to a canvas.
|
|
25241
|
+
*
|
|
25242
|
+
* Rebind or unbind only while there are no active key, mouse, touch, or drag sessions.
|
|
25243
|
+
*/ _proto.bindListeners = function bindListeners(target) {
|
|
26786
25244
|
this.unbindListeners();
|
|
26787
25245
|
this.target = target;
|
|
26788
25246
|
if (!target || typeof window === "undefined") {
|
|
@@ -26819,7 +25277,8 @@ var EventSystem = /*#__PURE__*/ function() {
|
|
|
26819
25277
|
});
|
|
26820
25278
|
this.addNativeHandler(target, "keydown", this.onNativeKeyDown);
|
|
26821
25279
|
this.addNativeHandler(target, "keyup", this.onNativeKeyUp);
|
|
26822
|
-
this.addNativeHandler(
|
|
25280
|
+
this.addNativeHandler(target, "focus", this.onCanvasFocus);
|
|
25281
|
+
this.addNativeHandler(target, "blur", this.onCanvasBlur);
|
|
26823
25282
|
};
|
|
26824
25283
|
_proto.dispatchEvent = function dispatchEvent(type, event) {
|
|
26825
25284
|
var handlers = this.handlers[type];
|
|
@@ -26853,11 +25312,7 @@ var EventSystem = /*#__PURE__*/ function() {
|
|
|
26853
25312
|
}
|
|
26854
25313
|
};
|
|
26855
25314
|
_proto.dispose = function dispose() {
|
|
26856
|
-
this.
|
|
26857
|
-
this.mouseState = null;
|
|
26858
|
-
this.touchStates.clear();
|
|
26859
|
-
this.mouseFromTouchIndex = null;
|
|
26860
|
-
this.touchFromMousePressed = false;
|
|
25315
|
+
this.resetInputState();
|
|
26861
25316
|
this.handlers = {};
|
|
26862
25317
|
this.unbindListeners();
|
|
26863
25318
|
this.target = null;
|
|
@@ -26866,13 +25321,14 @@ var EventSystem = /*#__PURE__*/ function() {
|
|
|
26866
25321
|
if (!this.enabled || !this.target) {
|
|
26867
25322
|
return;
|
|
26868
25323
|
}
|
|
26869
|
-
this.
|
|
25324
|
+
this.setMouseButtonPressed(event.button, true);
|
|
26870
25325
|
var position = this.getCanvasPosition(event.clientX, event.clientY);
|
|
25326
|
+
this.focusTarget();
|
|
26871
25327
|
var state = this.createPointerState(position);
|
|
26872
25328
|
this.mouseState = state;
|
|
26873
25329
|
state.pressed = true;
|
|
26874
25330
|
var handled = this.pushNativeMouseButton(event, position, true);
|
|
26875
|
-
state.
|
|
25331
|
+
state.inputHandled = handled;
|
|
26876
25332
|
if (!handled) {
|
|
26877
25333
|
var pointerEvent = this.createPointerEvent(event, position, state);
|
|
26878
25334
|
this.dispatchEvent(EVENT_TYPE_TOUCH_START, pointerEvent);
|
|
@@ -26896,8 +25352,7 @@ var EventSystem = /*#__PURE__*/ function() {
|
|
|
26896
25352
|
input.altPressed = event.altKey;
|
|
26897
25353
|
input.metaPressed = event.metaKey;
|
|
26898
25354
|
input.ctrlPressed = event.ctrlKey;
|
|
26899
|
-
this.
|
|
26900
|
-
this.consumeNativeEvent(event, this.engine.windowRoot.isInputHandled());
|
|
25355
|
+
this.consumeNativeEvent(event, this.pushInput(input));
|
|
26901
25356
|
};
|
|
26902
25357
|
_proto.handleNativeTouchEnd = function handleNativeTouchEnd(event, canceled) {
|
|
26903
25358
|
if (!this.enabled) {
|
|
@@ -26912,14 +25367,14 @@ var EventSystem = /*#__PURE__*/ function() {
|
|
|
26912
25367
|
}
|
|
26913
25368
|
var handled = this.pushNativeScreenTouch(touch.identifier, position, false, canceled, false);
|
|
26914
25369
|
var pointerEvent = this.createPointerEvent(event, position, state);
|
|
26915
|
-
if (!canceled && !state.
|
|
25370
|
+
if (!canceled && !state.inputHandled && !handled && this.isClick(state, position)) {
|
|
26916
25371
|
this.dispatchEvent(EVENT_TYPE_CLICK, pointerEvent);
|
|
26917
25372
|
}
|
|
26918
|
-
if (!handled && !canceled && !state.
|
|
25373
|
+
if (!handled && !canceled && !state.inputHandled) {
|
|
26919
25374
|
this.dispatchEvent(EVENT_TYPE_TOUCH_END, pointerEvent);
|
|
26920
25375
|
}
|
|
26921
25376
|
this.touchStates.delete(touch.identifier);
|
|
26922
|
-
this.consumeNativeEvent(event, handled || state.
|
|
25377
|
+
this.consumeNativeEvent(event, handled || state.inputHandled || !this.allowPropagation);
|
|
26923
25378
|
}
|
|
26924
25379
|
this.preventTouchDefaults(event);
|
|
26925
25380
|
};
|
|
@@ -26939,7 +25394,7 @@ var EventSystem = /*#__PURE__*/ function() {
|
|
|
26939
25394
|
};
|
|
26940
25395
|
_proto.pushNativeMouseMotion = function pushNativeMouseMotion(event, position, relative, velocity) {
|
|
26941
25396
|
var handled = false;
|
|
26942
|
-
if (this.touchFromMousePressed && (
|
|
25397
|
+
if (this.touchFromMousePressed && (this.mouseButtonMask & exports.MouseButtonMask.Left) !== 0) {
|
|
26943
25398
|
handled = this.pushScreenDrag(0, position, relative, velocity, InputEvent.deviceIdEmulation);
|
|
26944
25399
|
}
|
|
26945
25400
|
return this.pushMouseMotion(event, position, relative, velocity) || handled;
|
|
@@ -26976,8 +25431,7 @@ var EventSystem = /*#__PURE__*/ function() {
|
|
|
26976
25431
|
input.pressed = pressed;
|
|
26977
25432
|
input.canceled = canceled;
|
|
26978
25433
|
input.doubleClick = doubleClick;
|
|
26979
|
-
this.
|
|
26980
|
-
return this.engine.windowRoot.isInputHandled();
|
|
25434
|
+
return this.pushInput(input);
|
|
26981
25435
|
};
|
|
26982
25436
|
_proto.pushEmulatedMouseMotion = function pushEmulatedMouseMotion(position, relative, velocity) {
|
|
26983
25437
|
var input = new InputEventMouseMotion();
|
|
@@ -26990,42 +25444,42 @@ var EventSystem = /*#__PURE__*/ function() {
|
|
|
26990
25444
|
input.screenRelative.copyFrom(relative);
|
|
26991
25445
|
input.velocity.copyFrom(velocity);
|
|
26992
25446
|
input.screenVelocity.copyFrom(velocity);
|
|
26993
|
-
this.
|
|
26994
|
-
return this.engine.windowRoot.isInputHandled();
|
|
25447
|
+
return this.pushInput(input);
|
|
26995
25448
|
};
|
|
26996
25449
|
_proto.pushMouseButton = function pushMouseButton(event, position, pressed) {
|
|
26997
25450
|
var input = new InputEventMouseButton();
|
|
26998
25451
|
this.copyMouseFields(input, event, position);
|
|
26999
25452
|
input.device = InputEvent.deviceIdMouse;
|
|
27000
25453
|
input.buttonIndex = getMouseButton(event.button);
|
|
27001
|
-
input.buttonMask =
|
|
25454
|
+
input.buttonMask = this.mouseButtonMask;
|
|
25455
|
+
input.pressed = pressed;
|
|
25456
|
+
input.doubleClick = event.detail > 1;
|
|
25457
|
+
return this.pushInput(input);
|
|
25458
|
+
};
|
|
25459
|
+
_proto.setMouseButtonPressed = function setMouseButtonPressed(button, pressed) {
|
|
25460
|
+
var buttonBit = getMouseButtonBit(getMouseButton(button));
|
|
27002
25461
|
if (pressed) {
|
|
27003
|
-
|
|
25462
|
+
this.mouseButtonMask |= buttonBit;
|
|
27004
25463
|
} else {
|
|
27005
|
-
|
|
25464
|
+
this.mouseButtonMask &= ~buttonBit;
|
|
27006
25465
|
}
|
|
27007
|
-
input.pressed = pressed;
|
|
27008
|
-
input.doubleClick = event.detail > 1;
|
|
27009
|
-
this.engine.windowRoot.pushInput(input);
|
|
27010
|
-
return this.engine.windowRoot.isInputHandled();
|
|
27011
25466
|
};
|
|
27012
25467
|
_proto.pushWheelButton = function pushWheelButton(button, factor, position, event) {
|
|
27013
25468
|
var input = new InputEventMouseButton();
|
|
27014
25469
|
this.copyMouseFields(input, event, position);
|
|
27015
25470
|
input.device = InputEvent.deviceIdMouse;
|
|
27016
25471
|
input.buttonIndex = button;
|
|
27017
|
-
input.buttonMask =
|
|
25472
|
+
input.buttonMask = this.mouseButtonMask;
|
|
27018
25473
|
input.factor = factor;
|
|
27019
25474
|
input.pressed = true;
|
|
27020
|
-
this.
|
|
27021
|
-
return this.engine.windowRoot.isInputHandled();
|
|
25475
|
+
return this.pushInput(input);
|
|
27022
25476
|
};
|
|
27023
25477
|
_proto.pushMouseMotion = function pushMouseMotion(event, position, relative, velocity) {
|
|
27024
25478
|
var input = new InputEventMouseMotion();
|
|
27025
25479
|
this.copyMouseFields(input, event, position);
|
|
27026
25480
|
input.device = InputEvent.deviceIdMouse;
|
|
27027
|
-
input.buttonMask =
|
|
27028
|
-
input.pressed =
|
|
25481
|
+
input.buttonMask = this.mouseButtonMask;
|
|
25482
|
+
input.pressed = this.mouseButtonMask !== exports.MouseButtonMask.None;
|
|
27029
25483
|
input.relative.copyFrom(relative);
|
|
27030
25484
|
input.screenRelative.copyFrom(relative);
|
|
27031
25485
|
input.velocity.copyFrom(velocity);
|
|
@@ -27034,8 +25488,7 @@ var EventSystem = /*#__PURE__*/ function() {
|
|
|
27034
25488
|
input.pressure = event.pressure;
|
|
27035
25489
|
input.tilt.set(event.tiltX, event.tiltY);
|
|
27036
25490
|
}
|
|
27037
|
-
this.
|
|
27038
|
-
return this.engine.windowRoot.isInputHandled();
|
|
25491
|
+
return this.pushInput(input);
|
|
27039
25492
|
};
|
|
27040
25493
|
_proto.pushScreenTouch = function pushScreenTouch(index, position, pressed, canceled, doubleTap, device) {
|
|
27041
25494
|
var input = new InputEventScreenTouch();
|
|
@@ -27045,8 +25498,7 @@ var EventSystem = /*#__PURE__*/ function() {
|
|
|
27045
25498
|
input.pressed = pressed;
|
|
27046
25499
|
input.canceled = canceled;
|
|
27047
25500
|
input.doubleTap = doubleTap;
|
|
27048
|
-
this.
|
|
27049
|
-
return this.engine.windowRoot.isInputHandled();
|
|
25501
|
+
return this.pushInput(input);
|
|
27050
25502
|
};
|
|
27051
25503
|
_proto.pushScreenDrag = function pushScreenDrag(index, position, relative, velocity, device) {
|
|
27052
25504
|
var input = new InputEventScreenDrag();
|
|
@@ -27058,8 +25510,7 @@ var EventSystem = /*#__PURE__*/ function() {
|
|
|
27058
25510
|
input.velocity.copyFrom(velocity);
|
|
27059
25511
|
input.screenVelocity.copyFrom(velocity);
|
|
27060
25512
|
input.pressed = true;
|
|
27061
|
-
this.
|
|
27062
|
-
return this.engine.windowRoot.isInputHandled();
|
|
25513
|
+
return this.pushInput(input);
|
|
27063
25514
|
};
|
|
27064
25515
|
_proto.copyMouseFields = function copyMouseFields(input, event, position) {
|
|
27065
25516
|
input.position.copyFrom(position);
|
|
@@ -27134,7 +25585,7 @@ var EventSystem = /*#__PURE__*/ function() {
|
|
|
27134
25585
|
start: position.clone(),
|
|
27135
25586
|
last: position.clone(),
|
|
27136
25587
|
lastTime: performance.now(),
|
|
27137
|
-
|
|
25588
|
+
inputHandled: false,
|
|
27138
25589
|
pressed: false
|
|
27139
25590
|
};
|
|
27140
25591
|
return state;
|
|
@@ -27159,12 +25610,14 @@ var EventSystem = /*#__PURE__*/ function() {
|
|
|
27159
25610
|
var _target_width, _target_height;
|
|
27160
25611
|
return {
|
|
27161
25612
|
x: position.x / cssWidth * 2 - 1,
|
|
27162
|
-
|
|
25613
|
+
// Legacy composition picking uses bottom-left, Y-up NDC even though
|
|
25614
|
+
// standardized input follows the DOM convention of top-left, Y-down pixels.
|
|
25615
|
+
y: 1 - position.y / cssHeight * 2,
|
|
27163
25616
|
vx: velocity.x / cssWidth * 2,
|
|
27164
|
-
vy: velocity.y / cssHeight * 2,
|
|
25617
|
+
vy: -velocity.y / cssHeight * 2,
|
|
27165
25618
|
ts: performance.now(),
|
|
27166
25619
|
dx: (position.x - state.start.x) / cssWidth * 2,
|
|
27167
|
-
dy: (position.y - state.start.y) / cssHeight * 2,
|
|
25620
|
+
dy: -(position.y - state.start.y) / cssHeight * 2,
|
|
27168
25621
|
width: (_target_width = target == null ? void 0 : target.width) != null ? _target_width : 0,
|
|
27169
25622
|
height: (_target_height = target == null ? void 0 : target.height) != null ? _target_height : 0,
|
|
27170
25623
|
origin: origin
|
|
@@ -27176,7 +25629,7 @@ var EventSystem = /*#__PURE__*/ function() {
|
|
|
27176
25629
|
if (!rect) {
|
|
27177
25630
|
return new Vector2();
|
|
27178
25631
|
}
|
|
27179
|
-
return new Vector2(clientX - rect.left,
|
|
25632
|
+
return new Vector2(clientX - rect.left, clientY - rect.top);
|
|
27180
25633
|
};
|
|
27181
25634
|
_proto.consumeNativeEvent = function consumeNativeEvent(event, handled) {
|
|
27182
25635
|
if (handled && !this.allowPropagation) {
|
|
@@ -27186,15 +25639,26 @@ var EventSystem = /*#__PURE__*/ function() {
|
|
|
27186
25639
|
event.stopPropagation();
|
|
27187
25640
|
}
|
|
27188
25641
|
};
|
|
25642
|
+
_proto.pushInput = function pushInput(input) {
|
|
25643
|
+
input.clearAccepted();
|
|
25644
|
+
this.emit("input", input);
|
|
25645
|
+
return input.isAccepted();
|
|
25646
|
+
};
|
|
27189
25647
|
_proto.preventTouchDefaults = function preventTouchDefaults(event) {
|
|
27190
25648
|
if (event.cancelable) {
|
|
27191
25649
|
event.preventDefault();
|
|
27192
25650
|
}
|
|
27193
25651
|
};
|
|
27194
25652
|
_proto.focusTarget = function focusTarget() {
|
|
27195
|
-
|
|
27196
|
-
|
|
27197
|
-
|
|
25653
|
+
var _this_target;
|
|
25654
|
+
(_this_target = this.target) == null ? void 0 : _this_target.focus();
|
|
25655
|
+
};
|
|
25656
|
+
_proto.resetInputState = function resetInputState() {
|
|
25657
|
+
this.mouseState = null;
|
|
25658
|
+
this.mouseButtonMask = exports.MouseButtonMask.None;
|
|
25659
|
+
this.touchStates.clear();
|
|
25660
|
+
this.mouseFromTouchIndex = null;
|
|
25661
|
+
this.touchFromMousePressed = false;
|
|
27198
25662
|
};
|
|
27199
25663
|
_proto.addNativeHandler = function addNativeHandler(target, name, handler, options) {
|
|
27200
25664
|
target.addEventListener(name, handler, options);
|
|
@@ -27226,23 +25690,20 @@ var EventSystem = /*#__PURE__*/ function() {
|
|
|
27226
25690
|
get: function get() {
|
|
27227
25691
|
return this._enabled;
|
|
27228
25692
|
},
|
|
27229
|
-
set:
|
|
25693
|
+
set: /**
|
|
25694
|
+
* Enables native input processing.
|
|
25695
|
+
*
|
|
25696
|
+
* Change this only while there are no active key, mouse, touch, or drag sessions.
|
|
25697
|
+
*/ function set(value) {
|
|
27230
25698
|
if (this._enabled === value) {
|
|
27231
25699
|
return;
|
|
27232
25700
|
}
|
|
27233
25701
|
this._enabled = value;
|
|
27234
|
-
if (!value) {
|
|
27235
|
-
this.mouseState = null;
|
|
27236
|
-
this.touchStates.clear();
|
|
27237
|
-
this.mouseFromTouchIndex = null;
|
|
27238
|
-
this.touchFromMousePressed = false;
|
|
27239
|
-
this.engine.windowRoot.cancelPointerInput();
|
|
27240
|
-
}
|
|
27241
25702
|
}
|
|
27242
25703
|
}
|
|
27243
25704
|
]);
|
|
27244
25705
|
return EventSystem;
|
|
27245
|
-
}();
|
|
25706
|
+
}(EventEmitter);
|
|
27246
25707
|
function getKeyLocation(location) {
|
|
27247
25708
|
if (location === 1) {
|
|
27248
25709
|
return exports.KeyLocation.Left;
|
|
@@ -27273,25 +25734,6 @@ function getMouseButton(button) {
|
|
|
27273
25734
|
return exports.MouseButton.None;
|
|
27274
25735
|
}
|
|
27275
25736
|
}
|
|
27276
|
-
function getMouseButtonMask(buttons) {
|
|
27277
|
-
var mask = exports.MouseButtonMask.None;
|
|
27278
|
-
if ((buttons & 1) !== 0) {
|
|
27279
|
-
mask |= exports.MouseButtonMask.Left;
|
|
27280
|
-
}
|
|
27281
|
-
if ((buttons & 2) !== 0) {
|
|
27282
|
-
mask |= exports.MouseButtonMask.Right;
|
|
27283
|
-
}
|
|
27284
|
-
if ((buttons & 4) !== 0) {
|
|
27285
|
-
mask |= exports.MouseButtonMask.Middle;
|
|
27286
|
-
}
|
|
27287
|
-
if ((buttons & 8) !== 0) {
|
|
27288
|
-
mask |= exports.MouseButtonMask.Xbutton1;
|
|
27289
|
-
}
|
|
27290
|
-
if ((buttons & 16) !== 0) {
|
|
27291
|
-
mask |= exports.MouseButtonMask.Xbutton2;
|
|
27292
|
-
}
|
|
27293
|
-
return mask;
|
|
27294
|
-
}
|
|
27295
25737
|
function getMouseButtonBit(button) {
|
|
27296
25738
|
switch(button){
|
|
27297
25739
|
case exports.MouseButton.Left:
|
|
@@ -27308,6 +25750,16 @@ function getMouseButtonBit(button) {
|
|
|
27308
25750
|
return exports.MouseButtonMask.None;
|
|
27309
25751
|
}
|
|
27310
25752
|
}
|
|
25753
|
+
function normalizeWheelFactor(delta, mode) {
|
|
25754
|
+
var magnitude = Math.abs(delta);
|
|
25755
|
+
if (mode === 1) {
|
|
25756
|
+
return magnitude / 3;
|
|
25757
|
+
}
|
|
25758
|
+
if (mode === 2) {
|
|
25759
|
+
return magnitude;
|
|
25760
|
+
}
|
|
25761
|
+
return magnitude / 100;
|
|
25762
|
+
}
|
|
27311
25763
|
|
|
27312
25764
|
var InteractLoader = /*#__PURE__*/ function(Plugin) {
|
|
27313
25765
|
_inherits(InteractLoader, Plugin);
|
|
@@ -29327,6 +27779,11 @@ exports.SpritePropertyTrack = __decorate([
|
|
|
29327
27779
|
effectsClass("SpritePropertyTrack")
|
|
29328
27780
|
], exports.SpritePropertyTrack);
|
|
29329
27781
|
|
|
27782
|
+
function _assert_this_initialized(self) {
|
|
27783
|
+
if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
27784
|
+
return self;
|
|
27785
|
+
}
|
|
27786
|
+
|
|
29330
27787
|
var Cone = /*#__PURE__*/ function() {
|
|
29331
27788
|
function Cone(props) {
|
|
29332
27789
|
var _this = this;
|
|
@@ -39331,7 +37788,7 @@ function getStandardSpriteContent(sprite, transform) {
|
|
|
39331
37788
|
return ret;
|
|
39332
37789
|
}
|
|
39333
37790
|
|
|
39334
|
-
var version$1 = "2.10.0-alpha.
|
|
37791
|
+
var version$1 = "2.10.0-alpha.5";
|
|
39335
37792
|
var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
|
|
39336
37793
|
var standardVersion = /^(\d+)\.(\d+)$/;
|
|
39337
37794
|
var reverseParticle = false;
|
|
@@ -41327,9 +39784,11 @@ var PreRenderTickData = /*#__PURE__*/ function(TickData) {
|
|
|
41327
39784
|
// Instantiate composition rootItem
|
|
41328
39785
|
_this.sceneRoot = new exports.VFXItem(_this.engine);
|
|
41329
39786
|
_this.sceneRoot.setParent(_this.root);
|
|
41330
|
-
_this.uiCanvas = _this.sceneRoot.addComponent(UICanvas);
|
|
41331
39787
|
if (sourceContent) {
|
|
41332
39788
|
_this.sceneRoot.setInstanceId(sourceContent.id);
|
|
39789
|
+
}
|
|
39790
|
+
PluginSystem.notifyCompositionCreating(_assert_this_initialized(_this), scene);
|
|
39791
|
+
if (sourceContent) {
|
|
41333
39792
|
_this.sceneRoot.instantiatePreComposition(sourceContent, false);
|
|
41334
39793
|
}
|
|
41335
39794
|
// 在 instantiatePreComposition 后设置 rootItem 的 name,避免 name 被覆盖
|
|
@@ -41898,9 +40357,6 @@ var PreRenderTickData = /*#__PURE__*/ function(TickData) {
|
|
|
41898
40357
|
},
|
|
41899
40358
|
set: function set(value) {
|
|
41900
40359
|
this._renderOrder = value;
|
|
41901
|
-
if (this.uiCanvas) {
|
|
41902
|
-
this.uiCanvas.order = value;
|
|
41903
|
-
}
|
|
41904
40360
|
}
|
|
41905
40361
|
},
|
|
41906
40362
|
{
|
|
@@ -41913,9 +40369,6 @@ var PreRenderTickData = /*#__PURE__*/ function(TickData) {
|
|
|
41913
40369
|
},
|
|
41914
40370
|
set: function set(value) {
|
|
41915
40371
|
this._interactive = !!value;
|
|
41916
|
-
if (this.uiCanvas) {
|
|
41917
|
-
this.uiCanvas.receivesEvents = this._interactive;
|
|
41918
|
-
}
|
|
41919
40372
|
}
|
|
41920
40373
|
},
|
|
41921
40374
|
{
|
|
@@ -43743,7 +42196,6 @@ var DEFAULT_FPS = 60;
|
|
|
43743
42196
|
_this.objectInstance = {};
|
|
43744
42197
|
_this.root = new exports.VFXItem(_assert_this_initialized(_this));
|
|
43745
42198
|
_this.root.name = "root";
|
|
43746
|
-
_this.windowRoot = new WindowRootControl(_assert_this_initialized(_this));
|
|
43747
42199
|
_this.whiteTexture = generateWhiteTexture(_assert_this_initialized(_this));
|
|
43748
42200
|
_this.transparentTexture = generateEmptyTexture(_assert_this_initialized(_this));
|
|
43749
42201
|
if (!(options == null ? void 0 : options.manualRender)) {
|
|
@@ -43896,7 +42348,7 @@ var DEFAULT_FPS = 60;
|
|
|
43896
42348
|
(_this_ticker1 = this.ticker) == null ? void 0 : _this_ticker1.pause();
|
|
43897
42349
|
return;
|
|
43898
42350
|
}
|
|
43899
|
-
this.
|
|
42351
|
+
this.emit("update", dt);
|
|
43900
42352
|
// Tick compositions onPreRender
|
|
43901
42353
|
//-------------------------------------------------------------------------
|
|
43902
42354
|
for(var _iterator1 = _create_for_of_iterator_helper_loose(compositions), _step1; !(_step1 = _iterator1()).done;){
|
|
@@ -43911,7 +42363,7 @@ var DEFAULT_FPS = 60;
|
|
|
43911
42363
|
var composition2 = _step2.value;
|
|
43912
42364
|
composition2.renderContent();
|
|
43913
42365
|
}
|
|
43914
|
-
this.
|
|
42366
|
+
this.emit("postrender");
|
|
43915
42367
|
this.renderTargetPool.flush();
|
|
43916
42368
|
};
|
|
43917
42369
|
/**
|
|
@@ -43953,7 +42405,6 @@ var DEFAULT_FPS = 60;
|
|
|
43953
42405
|
this.canvas.style.height = containerHeight + "px";
|
|
43954
42406
|
logger.info("Resize engine " + this.name + " [" + canvasWidth + "," + canvasHeight + "," + containerWidth + "," + containerHeight + "].");
|
|
43955
42407
|
this.setSize(canvasWidth, canvasHeight);
|
|
43956
|
-
this.windowRoot.resize(canvasWidth, canvasHeight);
|
|
43957
42408
|
}
|
|
43958
42409
|
};
|
|
43959
42410
|
_proto.setSize = function setSize(width, height) {
|
|
@@ -44159,6 +42610,12 @@ var DEFAULT_FPS = 60;
|
|
|
44159
42610
|
_proto.setStencilTest = function setStencilTest(enable) {
|
|
44160
42611
|
// OVERRIDE
|
|
44161
42612
|
};
|
|
42613
|
+
_proto.setScissorTest = function setScissorTest(enable) {
|
|
42614
|
+
// OVERRIDE
|
|
42615
|
+
};
|
|
42616
|
+
_proto.setScissor = function setScissor(x, y, width, height) {
|
|
42617
|
+
// OVERRIDE
|
|
42618
|
+
};
|
|
44162
42619
|
_proto.setCulling = function setCulling(enable) {
|
|
44163
42620
|
// OVERRIDE
|
|
44164
42621
|
};
|
|
@@ -44236,7 +42693,6 @@ var DEFAULT_FPS = 60;
|
|
|
44236
42693
|
composition.dispose();
|
|
44237
42694
|
}
|
|
44238
42695
|
this.root.dispose();
|
|
44239
|
-
this.windowRoot.dispose();
|
|
44240
42696
|
(_this_assetService = this.assetService) == null ? void 0 : _this_assetService.dispose();
|
|
44241
42697
|
(_this__graphics = this._graphics) == null ? void 0 : _this__graphics.dispose();
|
|
44242
42698
|
this.renderPasses.forEach(function(pass) {
|
|
@@ -44561,7 +43017,7 @@ registerPlugin("text", TextLoader);
|
|
|
44561
43017
|
registerPlugin("sprite", SpriteLoader);
|
|
44562
43018
|
registerPlugin("particle", ParticleLoader);
|
|
44563
43019
|
registerPlugin("interact", InteractLoader);
|
|
44564
|
-
var version = "2.10.0-alpha.
|
|
43020
|
+
var version = "2.10.0-alpha.5";
|
|
44565
43021
|
logger.info("Core version: " + version + ".");
|
|
44566
43022
|
|
|
44567
43023
|
exports.ATLAS_SIZE = ATLAS_SIZE;
|
|
@@ -44596,8 +43052,6 @@ exports.COPY_MESH_SHADER_ID = COPY_MESH_SHADER_ID;
|
|
|
44596
43052
|
exports.COPY_VERTEX_SHADER = COPY_VERTEX_SHADER;
|
|
44597
43053
|
exports.Camera = Camera;
|
|
44598
43054
|
exports.CameraVFXItemLoader = CameraVFXItemLoader;
|
|
44599
|
-
exports.CanvasContainer = CanvasContainer;
|
|
44600
|
-
exports.CanvasRootControl = CanvasRootControl;
|
|
44601
43055
|
exports.Circle = Circle$1;
|
|
44602
43056
|
exports.ColorCurve = ColorCurve;
|
|
44603
43057
|
exports.ColorPlayable = ColorPlayable;
|
|
@@ -44610,8 +43064,6 @@ exports.Composition = Composition;
|
|
|
44610
43064
|
exports.ConstBoolNode = ConstBoolNode;
|
|
44611
43065
|
exports.ConstFloatNode = ConstFloatNode;
|
|
44612
43066
|
exports.ConstraintTarget = ConstraintTarget;
|
|
44613
|
-
exports.ContainerControl = ContainerControl;
|
|
44614
|
-
exports.Control = Control;
|
|
44615
43067
|
exports.ControlParameterBoolNode = ControlParameterBoolNode;
|
|
44616
43068
|
exports.ControlParameterFloatNode = ControlParameterFloatNode;
|
|
44617
43069
|
exports.ControlParameterTriggerNode = ControlParameterTriggerNode;
|
|
@@ -44718,7 +43170,6 @@ exports.RenderTargetPool = RenderTargetPool;
|
|
|
44718
43170
|
exports.Renderbuffer = Renderbuffer;
|
|
44719
43171
|
exports.Renderer = Renderer;
|
|
44720
43172
|
exports.RendererComponent = RendererComponent;
|
|
44721
|
-
exports.RootControl = RootControl;
|
|
44722
43173
|
exports.RuntimeClip = RuntimeClip;
|
|
44723
43174
|
exports.SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0 = SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0;
|
|
44724
43175
|
exports.SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0 = SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0;
|
|
@@ -44756,8 +43207,6 @@ exports.TransformPlayable = TransformPlayable;
|
|
|
44756
43207
|
exports.TransitionNode = TransitionNode;
|
|
44757
43208
|
exports.Triangle = Triangle;
|
|
44758
43209
|
exports.TrimPath = TrimPath;
|
|
44759
|
-
exports.UICanvas = UICanvas;
|
|
44760
|
-
exports.UIControl = UIControl;
|
|
44761
43210
|
exports.ValueGetter = ValueGetter;
|
|
44762
43211
|
exports.ValueNode = ValueNode;
|
|
44763
43212
|
exports.Vector2Curve = Vector2Curve;
|
|
@@ -44767,7 +43216,6 @@ exports.Vector3PropertyMixerPlayable = Vector3PropertyMixerPlayable;
|
|
|
44767
43216
|
exports.Vector4Curve = Vector4Curve;
|
|
44768
43217
|
exports.Vector4PropertyMixerPlayable = Vector4PropertyMixerPlayable;
|
|
44769
43218
|
exports.VertexBuffer = VertexBuffer;
|
|
44770
|
-
exports.WindowRootControl = WindowRootControl;
|
|
44771
43219
|
exports.addByOrder = addByOrder;
|
|
44772
43220
|
exports.addItem = addItem;
|
|
44773
43221
|
exports.addItemWithOrder = addItemWithOrder;
|