@galacean/effects-core 2.10.0-alpha.2 → 2.10.0-alpha.3
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/component.d.ts +4 -0
- package/dist/components/index.d.ts +2 -3
- package/dist/components/ui-canvas.d.ts +28 -0
- package/dist/components/ui-control.d.ts +38 -0
- package/dist/composition.d.ts +15 -5
- package/dist/engine.d.ts +30 -5
- package/dist/gui/control.d.ts +189 -0
- package/dist/gui/index.d.ts +2 -0
- package/dist/gui/roots.d.ts +79 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2763 -1056
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2749 -1053
- package/dist/index.mjs.map +1 -1
- package/dist/input/enums.d.ts +65 -0
- package/dist/input/index.d.ts +2 -0
- package/dist/input/input-event.d.ts +77 -0
- package/dist/plugins/interact/event-system.d.ts +49 -2
- package/dist/render/graphics.d.ts +1 -0
- package/dist/render/text-cache.d.ts +8 -9
- package/dist/transform.d.ts +7 -0
- package/dist/vfx-item.d.ts +4 -0
- package/package.json +1 -1
- package/dist/components/canvas-item.d.ts +0 -131
- package/dist/components/canvas-layer.d.ts +0 -23
- package/dist/components/control.d.ts +0 -18
- package/dist/rect-transform.d.ts +0 -145
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.3
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
@@ -7056,6 +7056,11 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
7056
7056
|
// OVERRIDE
|
|
7057
7057
|
};
|
|
7058
7058
|
/**
|
|
7059
|
+
* Called when the owning item's sibling order changes.
|
|
7060
|
+
*/ _proto.onOrderInParentChanged = function onOrderInParentChanged() {
|
|
7061
|
+
// OVERRIDE
|
|
7062
|
+
};
|
|
7063
|
+
/**
|
|
7059
7064
|
* @internal
|
|
7060
7065
|
*/ _proto.enable = function enable() {
|
|
7061
7066
|
if (this.item.composition) {
|
|
@@ -14013,6 +14018,7 @@ var seed$7 = 1;
|
|
|
14013
14018
|
quat: new Quaternion(0, 0, 0, 1),
|
|
14014
14019
|
scale: new Vector3(1, 1, 1)
|
|
14015
14020
|
};
|
|
14021
|
+
this.eventEmitter = new EventEmitter();
|
|
14016
14022
|
this.name = "transform_" + seed$7++;
|
|
14017
14023
|
if (props) {
|
|
14018
14024
|
this.setTransform(props);
|
|
@@ -14025,6 +14031,12 @@ var seed$7 = 1;
|
|
|
14025
14031
|
}
|
|
14026
14032
|
}
|
|
14027
14033
|
var _proto = Transform.prototype;
|
|
14034
|
+
_proto.on = function on(eventName, listener, options) {
|
|
14035
|
+
this.eventEmitter.on(eventName, listener, options);
|
|
14036
|
+
};
|
|
14037
|
+
_proto.off = function off(eventName, listener) {
|
|
14038
|
+
this.eventEmitter.off(eventName, listener);
|
|
14039
|
+
};
|
|
14028
14040
|
/**
|
|
14029
14041
|
* 父 transform 切换时的 hook。子类可重写以接管订阅 / 解算等逻辑
|
|
14030
14042
|
* @param oldParent - 切换前的父 transform(若没有则为 null)
|
|
@@ -14443,6 +14455,7 @@ var seed$7 = 1;
|
|
|
14443
14455
|
this.children.forEach(function(c) {
|
|
14444
14456
|
c.worldMatrixDirty = true;
|
|
14445
14457
|
});
|
|
14458
|
+
this.eventEmitter.emit("changed", this);
|
|
14446
14459
|
};
|
|
14447
14460
|
/**
|
|
14448
14461
|
* 转换右手坐标系左手螺旋对应的四元数到对应的旋转角
|
|
@@ -14461,14 +14474,16 @@ var seed$7 = 1;
|
|
|
14461
14474
|
return this.parent;
|
|
14462
14475
|
},
|
|
14463
14476
|
set: function set(transform) {
|
|
14464
|
-
if (
|
|
14477
|
+
if (this.parent === transform || this === transform) {
|
|
14465
14478
|
return;
|
|
14466
14479
|
}
|
|
14467
14480
|
var oldParent = this.parent;
|
|
14468
14481
|
if (this.parent) {
|
|
14469
14482
|
this.parent.removeChild(this);
|
|
14470
14483
|
}
|
|
14471
|
-
transform
|
|
14484
|
+
if (transform) {
|
|
14485
|
+
transform.addChild(this);
|
|
14486
|
+
}
|
|
14472
14487
|
this.parent = transform;
|
|
14473
14488
|
this.worldMatrixDirty = true;
|
|
14474
14489
|
this.onParentTransformChanged(oldParent, transform);
|
|
@@ -14651,7 +14666,7 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
|
|
|
14651
14666
|
return results;
|
|
14652
14667
|
};
|
|
14653
14668
|
_proto.setParent = function setParent(vfxItem) {
|
|
14654
|
-
if (vfxItem === this
|
|
14669
|
+
if (vfxItem === this || this.parent === vfxItem) {
|
|
14655
14670
|
return;
|
|
14656
14671
|
}
|
|
14657
14672
|
if (this.parent) {
|
|
@@ -15038,6 +15053,12 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
|
|
|
15038
15053
|
child.onParentChanged();
|
|
15039
15054
|
}
|
|
15040
15055
|
};
|
|
15056
|
+
_proto.onOrderInParentChanged = function onOrderInParentChanged() {
|
|
15057
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(this.components), _step; !(_step = _iterator()).done;){
|
|
15058
|
+
var component = _step.value;
|
|
15059
|
+
component.onOrderInParentChanged();
|
|
15060
|
+
}
|
|
15061
|
+
};
|
|
15041
15062
|
/**
|
|
15042
15063
|
* @internal
|
|
15043
15064
|
*/ _proto.setRendererComponentOrder = function setRendererComponentOrder(renderOrder) {
|
|
@@ -15122,15 +15143,16 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
|
|
|
15122
15143
|
*/ _proto.dispose = function dispose() {
|
|
15123
15144
|
if (this.composition) {
|
|
15124
15145
|
this.composition.destroyItem(this);
|
|
15125
|
-
// component 调用 dispose() 会将自身从 this.components 数组删除,slice() 避免迭代错误
|
|
15126
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(this.components.slice()), _step; !(_step = _iterator()).done;){
|
|
15127
|
-
var component = _step.value;
|
|
15128
|
-
component.dispose();
|
|
15129
|
-
}
|
|
15130
|
-
this.components = [];
|
|
15131
|
-
this._composition = null;
|
|
15132
|
-
this.transform.setValid(false);
|
|
15133
15146
|
}
|
|
15147
|
+
// component.dispose() removes itself from this.components. Use a snapshot
|
|
15148
|
+
// so Engine.root components are also disposed even without a Composition.
|
|
15149
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(this.components.slice()), _step; !(_step = _iterator()).done;){
|
|
15150
|
+
var component = _step.value;
|
|
15151
|
+
component.dispose();
|
|
15152
|
+
}
|
|
15153
|
+
this.components = [];
|
|
15154
|
+
this._composition = null;
|
|
15155
|
+
this.transform.setValid(false);
|
|
15134
15156
|
this.resetChildrenParent();
|
|
15135
15157
|
EffectsObject.prototype.dispose.call(this);
|
|
15136
15158
|
};
|
|
@@ -15326,6 +15348,33 @@ exports.VFXItem = /*#__PURE__*/ function(EffectsObject) {
|
|
|
15326
15348
|
this.setRendererComponentOrder(value);
|
|
15327
15349
|
}
|
|
15328
15350
|
},
|
|
15351
|
+
{
|
|
15352
|
+
key: "orderInParent",
|
|
15353
|
+
get: /** Zero-based sibling order within the parent item. */ function get() {
|
|
15354
|
+
var _this_parent;
|
|
15355
|
+
var _this_parent_children_indexOf;
|
|
15356
|
+
return (_this_parent_children_indexOf = (_this_parent = this.parent) == null ? void 0 : _this_parent.children.indexOf(this)) != null ? _this_parent_children_indexOf : -1;
|
|
15357
|
+
},
|
|
15358
|
+
set: function set(value) {
|
|
15359
|
+
var _this_parent;
|
|
15360
|
+
var siblings = (_this_parent = this.parent) == null ? void 0 : _this_parent.children;
|
|
15361
|
+
var _siblings_indexOf;
|
|
15362
|
+
var oldIndex = (_siblings_indexOf = siblings == null ? void 0 : siblings.indexOf(this)) != null ? _siblings_indexOf : -1;
|
|
15363
|
+
if (!siblings || oldIndex === -1) {
|
|
15364
|
+
return;
|
|
15365
|
+
}
|
|
15366
|
+
var newIndex = Math.max(0, Math.min(Math.trunc(value), siblings.length - 1));
|
|
15367
|
+
if (oldIndex === newIndex) {
|
|
15368
|
+
return;
|
|
15369
|
+
}
|
|
15370
|
+
siblings.splice(oldIndex, 1);
|
|
15371
|
+
siblings.splice(newIndex, 0, this);
|
|
15372
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(siblings), _step; !(_step = _iterator()).done;){
|
|
15373
|
+
var sibling = _step.value;
|
|
15374
|
+
sibling.onOrderInParentChanged();
|
|
15375
|
+
}
|
|
15376
|
+
}
|
|
15377
|
+
},
|
|
15329
15378
|
{
|
|
15330
15379
|
key: "isActive",
|
|
15331
15380
|
get: /**
|
|
@@ -15582,35 +15631,35 @@ function vecMulCombine(out, a, b) {
|
|
|
15582
15631
|
}
|
|
15583
15632
|
return out;
|
|
15584
15633
|
}
|
|
15585
|
-
var _obj$
|
|
15586
|
-
var particleOriginTranslateMap$1 = (_obj$
|
|
15634
|
+
var _obj$6;
|
|
15635
|
+
var particleOriginTranslateMap$1 = (_obj$6 = {}, _obj$6[ParticleOrigin.PARTICLE_ORIGIN_CENTER] = [
|
|
15587
15636
|
0,
|
|
15588
15637
|
0
|
|
15589
|
-
], _obj$
|
|
15638
|
+
], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_CENTER_BOTTOM] = [
|
|
15590
15639
|
0,
|
|
15591
15640
|
-0.5
|
|
15592
|
-
], _obj$
|
|
15641
|
+
], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_CENTER_TOP] = [
|
|
15593
15642
|
0,
|
|
15594
15643
|
0.5
|
|
15595
|
-
], _obj$
|
|
15644
|
+
], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_LEFT_TOP] = [
|
|
15596
15645
|
-0.5,
|
|
15597
15646
|
0.5
|
|
15598
|
-
], _obj$
|
|
15647
|
+
], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_LEFT_CENTER] = [
|
|
15599
15648
|
-0.5,
|
|
15600
15649
|
0
|
|
15601
|
-
], _obj$
|
|
15650
|
+
], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_LEFT_BOTTOM] = [
|
|
15602
15651
|
-0.5,
|
|
15603
15652
|
-0.5
|
|
15604
|
-
], _obj$
|
|
15653
|
+
], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_CENTER] = [
|
|
15605
15654
|
0.5,
|
|
15606
15655
|
0
|
|
15607
|
-
], _obj$
|
|
15656
|
+
], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_BOTTOM] = [
|
|
15608
15657
|
0.5,
|
|
15609
15658
|
-0.5
|
|
15610
|
-
], _obj$
|
|
15659
|
+
], _obj$6[ParticleOrigin.PARTICLE_ORIGIN_RIGHT_TOP] = [
|
|
15611
15660
|
0.5,
|
|
15612
15661
|
0.5
|
|
15613
|
-
], _obj$
|
|
15662
|
+
], _obj$6);
|
|
15614
15663
|
function nearestPowerOfTwo(value) {
|
|
15615
15664
|
return Math.pow(2, Math.round(Math.log(value) / Math.LN2));
|
|
15616
15665
|
}
|
|
@@ -17348,27 +17397,27 @@ function oldBezierKeyFramesToNew(props) {
|
|
|
17348
17397
|
* 对象引用阶梯曲线(spec ValueType.REFERENCE_CURVE)。
|
|
17349
17398
|
* props 为 [[time, value], ...],value 为已解析的对象引用实例。
|
|
17350
17399
|
*/ var REFERENCE_CURVE = 28;
|
|
17351
|
-
var _obj$
|
|
17352
|
-
var map$1 = (_obj$
|
|
17400
|
+
var _obj$5;
|
|
17401
|
+
var map$1 = (_obj$5 = {}, _obj$5[ValueType.RANDOM] = function(props) {
|
|
17353
17402
|
if (_instanceof1(props[0], Array)) {
|
|
17354
17403
|
return new RandomVectorValue(props);
|
|
17355
17404
|
}
|
|
17356
17405
|
return new RandomValue(props);
|
|
17357
|
-
}, _obj$
|
|
17406
|
+
}, _obj$5[ValueType.CONSTANT] = function(props) {
|
|
17358
17407
|
return new StaticValue(props);
|
|
17359
|
-
}, _obj$
|
|
17408
|
+
}, _obj$5[ValueType.CONSTANT_VEC2] = function(props) {
|
|
17360
17409
|
return new StaticValue(props);
|
|
17361
|
-
}, _obj$
|
|
17410
|
+
}, _obj$5[ValueType.CONSTANT_VEC3] = function(props) {
|
|
17362
17411
|
return new StaticValue(props);
|
|
17363
|
-
}, _obj$
|
|
17412
|
+
}, _obj$5[ValueType.CONSTANT_VEC4] = function(props) {
|
|
17364
17413
|
return new StaticValue(props);
|
|
17365
|
-
}, _obj$
|
|
17414
|
+
}, _obj$5[ValueType.RGBA_COLOR] = function(props) {
|
|
17366
17415
|
return new StaticValue(props);
|
|
17367
|
-
}, _obj$
|
|
17416
|
+
}, _obj$5[ValueType.COLORS] = function(props) {
|
|
17368
17417
|
return new RandomSetValue(props.map(function(c) {
|
|
17369
17418
|
return colorToArr$1(c, false);
|
|
17370
17419
|
}));
|
|
17371
|
-
}, _obj$
|
|
17420
|
+
}, _obj$5[ValueType.LINE] = function(props) {
|
|
17372
17421
|
if (props.length === 2 && props[0][0] === 0 && props[1][0] === 1) {
|
|
17373
17422
|
return new LinearValue([
|
|
17374
17423
|
props[0][1],
|
|
@@ -17376,38 +17425,38 @@ var map$1 = (_obj$4 = {}, _obj$4[ValueType.RANDOM] = function(props) {
|
|
|
17376
17425
|
]);
|
|
17377
17426
|
}
|
|
17378
17427
|
return new LineSegments(props);
|
|
17379
|
-
}, _obj$
|
|
17428
|
+
}, _obj$5[ValueType.GRADIENT_COLOR] = function(props) {
|
|
17380
17429
|
return new GradientValue(props);
|
|
17381
|
-
}, _obj$
|
|
17430
|
+
}, _obj$5[ValueType.LINEAR_PATH] = function(pros) {
|
|
17382
17431
|
return new PathSegments(pros);
|
|
17383
|
-
}, _obj$
|
|
17432
|
+
}, _obj$5[ValueType.BEZIER_CURVE] = function(props) {
|
|
17384
17433
|
if (props.length === 1) {
|
|
17385
17434
|
return new StaticValue(props[0][1][1]);
|
|
17386
17435
|
}
|
|
17387
17436
|
return new BezierCurve(props);
|
|
17388
|
-
}, _obj$
|
|
17437
|
+
}, _obj$5[ValueType.BEZIER_CURVE_PATH] = function(props) {
|
|
17389
17438
|
if (props[0].length === 1) {
|
|
17390
17439
|
return new StaticValue(_construct(Vector3, [].concat(props[1][0])));
|
|
17391
17440
|
}
|
|
17392
17441
|
return new BezierCurvePath(props);
|
|
17393
|
-
}, _obj$
|
|
17442
|
+
}, _obj$5[ValueType.BEZIER_CURVE_QUAT] = function(props) {
|
|
17394
17443
|
if (props[0].length === 1) {
|
|
17395
17444
|
return new StaticValue(_construct(Quaternion, [].concat(props[1][0])));
|
|
17396
17445
|
}
|
|
17397
17446
|
return new BezierCurveQuat(props);
|
|
17398
|
-
}, _obj$
|
|
17447
|
+
}, _obj$5[ValueType.COLOR_CURVE] = function(props) {
|
|
17399
17448
|
return new ColorCurve(props);
|
|
17400
|
-
}, _obj$
|
|
17449
|
+
}, _obj$5[ValueType.VECTOR4_CURVE] = function(props) {
|
|
17401
17450
|
return new Vector4Curve(props);
|
|
17402
|
-
}, _obj$
|
|
17451
|
+
}, _obj$5[ValueType.VECTOR2_CURVE] = function(props) {
|
|
17403
17452
|
return new Vector2Curve(props);
|
|
17404
17453
|
}, // TODO: add spec
|
|
17405
|
-
_obj$
|
|
17454
|
+
_obj$5[VECTOR3_CURVE] = function(props) {
|
|
17406
17455
|
return new Vector3Curve(props);
|
|
17407
17456
|
}, // 对象引用阶梯曲线(不插值):props.data 为 [time, value][],value 已解析为 EffectsObject
|
|
17408
|
-
_obj$
|
|
17457
|
+
_obj$5[REFERENCE_CURVE] = function(props) {
|
|
17409
17458
|
return new ReferenceCurve(props);
|
|
17410
|
-
}, _obj$
|
|
17459
|
+
}, _obj$5);
|
|
17411
17460
|
function createValueGetter(args) {
|
|
17412
17461
|
if (!args || !isNaN(+args)) {
|
|
17413
17462
|
return new StaticValue(args || 0);
|
|
@@ -20924,20 +20973,24 @@ var geometryId = 1;
|
|
|
20924
20973
|
var vertexArrayObjects = this.vertexArrayObjects;
|
|
20925
20974
|
var engine = this.engine;
|
|
20926
20975
|
if (!vertexArrayObjects || !supportsVertexArrayObjects(engine)) {
|
|
20927
|
-
|
|
20976
|
+
var _this_indexBuffer;
|
|
20977
|
+
engine.bindBuffers(this.vertexBuffers, (_this_indexBuffer = this.indexBuffer) != null ? _this_indexBuffer : null, shader);
|
|
20928
20978
|
return;
|
|
20929
20979
|
}
|
|
20930
20980
|
var vertexArrayObject = vertexArrayObjects[shader.key];
|
|
20931
20981
|
if (!vertexArrayObject) {
|
|
20932
|
-
|
|
20982
|
+
var _this_indexBuffer1;
|
|
20983
|
+
vertexArrayObject = engine.recordVertexArrayObject(this.vertexBuffers, (_this_indexBuffer1 = this.indexBuffer) != null ? _this_indexBuffer1 : null, shader);
|
|
20933
20984
|
if (vertexArrayObject) {
|
|
20934
20985
|
vertexArrayObjects[shader.key] = vertexArrayObject;
|
|
20935
20986
|
}
|
|
20936
20987
|
}
|
|
20937
20988
|
if (vertexArrayObject) {
|
|
20938
|
-
|
|
20989
|
+
var _this_indexBuffer2;
|
|
20990
|
+
engine.bindVertexArrayObject(vertexArrayObject, (_this_indexBuffer2 = this.indexBuffer) != null ? _this_indexBuffer2 : null);
|
|
20939
20991
|
} else {
|
|
20940
|
-
|
|
20992
|
+
var _this_indexBuffer3;
|
|
20993
|
+
engine.bindBuffers(this.vertexBuffers, (_this_indexBuffer3 = this.indexBuffer) != null ? _this_indexBuffer3 : null, shader);
|
|
20941
20994
|
}
|
|
20942
20995
|
};
|
|
20943
20996
|
_proto.releaseVertexArrayObject = function releaseVertexArrayObject(key) {
|
|
@@ -21344,8 +21397,8 @@ var vertexBufferSemanticMap = {
|
|
|
21344
21397
|
TANGENT_BS2: "aTargetTangent2",
|
|
21345
21398
|
TANGENT_BS3: "aTargetTangent3"
|
|
21346
21399
|
};
|
|
21347
|
-
var _obj$
|
|
21348
|
-
var BYTES_TYPE_MAP = (_obj$
|
|
21400
|
+
var _obj$4;
|
|
21401
|
+
var BYTES_TYPE_MAP = (_obj$4 = {}, _obj$4[exports.BufferDataType.Float] = 4, _obj$4[exports.BufferDataType.Int] = 4, _obj$4[exports.BufferDataType.UnsignedInt] = 4, _obj$4[exports.BufferDataType.Short] = 2, _obj$4[exports.BufferDataType.UnsignedShort] = 2, _obj$4[exports.BufferDataType.Byte] = 1, _obj$4[exports.BufferDataType.UnsignedByte] = 1, _obj$4);
|
|
21349
21402
|
function generateEmptyTypedArray(type) {
|
|
21350
21403
|
return createTypedArray(type, 0);
|
|
21351
21404
|
}
|
|
@@ -22355,7 +22408,7 @@ var Renderer = /*#__PURE__*/ function() {
|
|
|
22355
22408
|
}
|
|
22356
22409
|
};
|
|
22357
22410
|
_proto.setViewport = function setViewport(x, y, width, height) {
|
|
22358
|
-
this.engine.
|
|
22411
|
+
this.engine.setViewport(x, y, width, height);
|
|
22359
22412
|
};
|
|
22360
22413
|
_proto.clear = function clear(action) {
|
|
22361
22414
|
this.engine.clear(action);
|
|
@@ -22418,7 +22471,40 @@ var Renderer = /*#__PURE__*/ function() {
|
|
|
22418
22471
|
};
|
|
22419
22472
|
_proto.drawGeometry = function drawGeometry(geometry, matrix, material, subMeshIndex) {
|
|
22420
22473
|
if (subMeshIndex === void 0) subMeshIndex = 0;
|
|
22421
|
-
|
|
22474
|
+
if (!geometry || !material) {
|
|
22475
|
+
return;
|
|
22476
|
+
}
|
|
22477
|
+
material.initialize();
|
|
22478
|
+
geometry.initialize();
|
|
22479
|
+
geometry.flush();
|
|
22480
|
+
material.setMatrix("effects_ObjectToWorld", matrix);
|
|
22481
|
+
try {
|
|
22482
|
+
material.use(this, this.renderingData.currentFrame.globalUniforms);
|
|
22483
|
+
} catch (e) {
|
|
22484
|
+
console.error(e);
|
|
22485
|
+
this.engine.renderErrors.add(e);
|
|
22486
|
+
return;
|
|
22487
|
+
}
|
|
22488
|
+
var indexBuffer = geometry.getIndexBuffer();
|
|
22489
|
+
var offset = geometry.getDrawStart();
|
|
22490
|
+
var count = geometry.getDrawCount();
|
|
22491
|
+
var subMeshes = geometry.subMeshes;
|
|
22492
|
+
if (subMeshes.length > 0) {
|
|
22493
|
+
var subMesh = subMeshes[subMeshIndex];
|
|
22494
|
+
offset = subMesh.offset;
|
|
22495
|
+
var _subMesh_indexCount;
|
|
22496
|
+
count = indexBuffer ? (_subMesh_indexCount = subMesh.indexCount) != null ? _subMesh_indexCount : 0 : subMesh.vertexCount;
|
|
22497
|
+
}
|
|
22498
|
+
if (count <= 0) {
|
|
22499
|
+
return;
|
|
22500
|
+
}
|
|
22501
|
+
geometry.bind(material.shaderVariant);
|
|
22502
|
+
var instanceCount = geometry.instanceCount || undefined;
|
|
22503
|
+
if (indexBuffer) {
|
|
22504
|
+
this.engine.drawElementsType(geometry.mode, offset, count, instanceCount);
|
|
22505
|
+
} else {
|
|
22506
|
+
this.engine.drawArraysType(geometry.mode, offset, count, instanceCount);
|
|
22507
|
+
}
|
|
22422
22508
|
};
|
|
22423
22509
|
_proto.getTemporaryRT = function getTemporaryRT(name, width, height, depthBuffer, filter, format) {
|
|
22424
22510
|
return this.engine.renderTargetPool.get(name, width, height, depthBuffer, filter, format);
|
|
@@ -22686,11 +22772,7 @@ var CanvasPool = /*#__PURE__*/ function() {
|
|
|
22686
22772
|
var canvasPool = new CanvasPool();
|
|
22687
22773
|
|
|
22688
22774
|
/**
|
|
22689
|
-
*
|
|
22690
|
-
* 但 quad 仍按 1x 逻辑尺寸绘制 — 双线性 downsample 后比原 1x 渲染清晰得多
|
|
22691
|
-
*/ var FONT_SCALE = 2;
|
|
22692
|
-
/**
|
|
22693
|
-
* 单张字符 atlas 的边长(像素,scale 后的实际像素,非逻辑尺寸)。
|
|
22775
|
+
* 单张字符 atlas 的逻辑边长。实际 canvas 像素尺寸会乘以渲染 resolution。
|
|
22694
22776
|
* 512×512 在 24px 字号下约可容纳 250+ 字形,常见 demo 文本足够
|
|
22695
22777
|
*/ var ATLAS_SIZE = 512;
|
|
22696
22778
|
/**
|
|
@@ -22712,7 +22794,7 @@ var canvasPool = new CanvasPool();
|
|
|
22712
22794
|
* canvas 内容变更后需要 `uploadIfDirty` 重新上传到纹理 — 由调用方在使用纹理前主动触发,
|
|
22713
22795
|
* 避免每加一字都 upload 一次造成的 GL 开销
|
|
22714
22796
|
*/ var GlyphAtlas = /*#__PURE__*/ function() {
|
|
22715
|
-
function GlyphAtlas(engine, scaledFontString, /** baseline 距 cell 顶距离(像素,scale 后,仅 ascent 部分,不含 padding) */ ascentPx, /** baseline 距 cell 底距离(像素,scale 后,仅 descent 部分) */ descentPx, fontStyle) {
|
|
22797
|
+
function GlyphAtlas(engine, scaledFontString, /** baseline 距 cell 顶距离(像素,scale 后,仅 ascent 部分,不含 padding) */ ascentPx, /** baseline 距 cell 底距离(像素,scale 后,仅 descent 部分) */ descentPx, fontStyle, resolution) {
|
|
22716
22798
|
this.engine = engine;
|
|
22717
22799
|
this.scaledFontString = scaledFontString;
|
|
22718
22800
|
this.glyphs = new Map();
|
|
@@ -22720,9 +22802,10 @@ var canvasPool = new CanvasPool();
|
|
|
22720
22802
|
this.currentY = 0;
|
|
22721
22803
|
this.full = false;
|
|
22722
22804
|
this.dirty = true;
|
|
22805
|
+
this.resolution = resolution;
|
|
22723
22806
|
this.canvas = document.createElement("canvas");
|
|
22724
|
-
this.canvas.width = ATLAS_SIZE;
|
|
22725
|
-
this.canvas.height = ATLAS_SIZE;
|
|
22807
|
+
this.canvas.width = Math.ceil(ATLAS_SIZE * resolution);
|
|
22808
|
+
this.canvas.height = Math.ceil(ATLAS_SIZE * resolution);
|
|
22726
22809
|
var ctx = this.canvas.getContext("2d", {
|
|
22727
22810
|
willReadFrequently: false
|
|
22728
22811
|
});
|
|
@@ -22733,14 +22816,14 @@ var canvasPool = new CanvasPool();
|
|
|
22733
22816
|
ctx.font = scaledFontString;
|
|
22734
22817
|
ctx.textBaseline = "alphabetic";
|
|
22735
22818
|
ctx.fillStyle = "#ffffff";
|
|
22736
|
-
this.paddingPx = GLYPH_PADDING *
|
|
22819
|
+
this.paddingPx = GLYPH_PADDING * resolution;
|
|
22737
22820
|
this.italicScale = fontStyle === "italic" ? 2 : 1;
|
|
22738
22821
|
// ascent/descent 由探针 '|ÉqÅM' 测得 actualBoundingBox(重音字已抬高 ink 顶),
|
|
22739
22822
|
// 两者内部保持浮点,仅 cell 高做一次外层 ceil — 与 padding 共同保证 cell 内不裁切
|
|
22740
22823
|
var fontHeightPx = ascentPx + descentPx;
|
|
22741
22824
|
this.baselinePx = this.paddingPx + ascentPx;
|
|
22742
22825
|
this.cellHPx = Math.ceil(fontHeightPx + this.paddingPx * 2);
|
|
22743
|
-
this.lineHeight = this.cellHPx /
|
|
22826
|
+
this.lineHeight = this.cellHPx / resolution;
|
|
22744
22827
|
this.texture = Texture.create(engine, {
|
|
22745
22828
|
sourceType: exports.TextureSourceType.image,
|
|
22746
22829
|
image: this.canvas,
|
|
@@ -22749,7 +22832,8 @@ var canvasPool = new CanvasPool();
|
|
|
22749
22832
|
magFilter: glContext.LINEAR,
|
|
22750
22833
|
minFilter: glContext.LINEAR,
|
|
22751
22834
|
wrapS: glContext.CLAMP_TO_EDGE,
|
|
22752
|
-
wrapT: glContext.CLAMP_TO_EDGE
|
|
22835
|
+
wrapT: glContext.CLAMP_TO_EDGE,
|
|
22836
|
+
premultiplyAlpha: true
|
|
22753
22837
|
});
|
|
22754
22838
|
this.texture.initialize();
|
|
22755
22839
|
}
|
|
@@ -22767,19 +22851,19 @@ var canvasPool = new CanvasPool();
|
|
|
22767
22851
|
var ctx = this.ctx;
|
|
22768
22852
|
// 每次重设字体,防御外部潜在污染(虽然 ctx 私有)
|
|
22769
22853
|
ctx.font = this.scaledFontString;
|
|
22770
|
-
// measureText 用的是 scaledFontString,advance 已经是
|
|
22854
|
+
// measureText 用的是 scaledFontString,advance 已经是 resolution 后的像素
|
|
22771
22855
|
var advancePx = ctx.measureText(char).width;
|
|
22772
22856
|
// italic 放大 cell 宽防斜体越界;ceil 对齐像素网格避免相邻字采样重叠
|
|
22773
22857
|
var widthPx = Math.max(1, Math.ceil(advancePx * this.italicScale));
|
|
22774
22858
|
var paddedWidthPx = widthPx + this.paddingPx * 2;
|
|
22775
22859
|
var cellH = this.cellHPx;
|
|
22776
22860
|
// 行尾换行
|
|
22777
|
-
if (this.currentX + paddedWidthPx >
|
|
22861
|
+
if (this.currentX + paddedWidthPx > this.canvas.width) {
|
|
22778
22862
|
this.currentX = 0;
|
|
22779
22863
|
this.currentY += cellH;
|
|
22780
22864
|
}
|
|
22781
22865
|
// atlas 满,后续不再尝试
|
|
22782
|
-
if (this.currentY + cellH >
|
|
22866
|
+
if (this.currentY + cellH > this.canvas.height) {
|
|
22783
22867
|
this.full = true;
|
|
22784
22868
|
console.warn('GlyphAtlas full, dropping char "' + char + '"');
|
|
22785
22869
|
return null;
|
|
@@ -22795,8 +22879,8 @@ var canvasPool = new CanvasPool();
|
|
|
22795
22879
|
py: py,
|
|
22796
22880
|
pw: paddedWidthPx,
|
|
22797
22881
|
ph: cellH,
|
|
22798
|
-
advance: advancePx /
|
|
22799
|
-
paddingLeft: this.paddingPx /
|
|
22882
|
+
advance: advancePx / this.resolution,
|
|
22883
|
+
paddingLeft: this.paddingPx / this.resolution
|
|
22800
22884
|
};
|
|
22801
22885
|
this.glyphs.set(char, info);
|
|
22802
22886
|
return info;
|
|
@@ -22815,7 +22899,8 @@ var canvasPool = new CanvasPool();
|
|
|
22815
22899
|
magFilter: glContext.LINEAR,
|
|
22816
22900
|
minFilter: glContext.LINEAR,
|
|
22817
22901
|
wrapS: glContext.CLAMP_TO_EDGE,
|
|
22818
|
-
wrapT: glContext.CLAMP_TO_EDGE
|
|
22902
|
+
wrapT: glContext.CLAMP_TO_EDGE,
|
|
22903
|
+
premultiplyAlpha: true
|
|
22819
22904
|
});
|
|
22820
22905
|
this.dirty = false;
|
|
22821
22906
|
};
|
|
@@ -22838,26 +22923,33 @@ var canvasPool = new CanvasPool();
|
|
|
22838
22923
|
function TextCache(engine) {
|
|
22839
22924
|
this.engine = engine;
|
|
22840
22925
|
this.atlases = new Map();
|
|
22926
|
+
this.resolution = engine.pixelRatio;
|
|
22841
22927
|
}
|
|
22842
22928
|
var _proto = TextCache.prototype;
|
|
22843
22929
|
/**
|
|
22844
22930
|
* 取(必要时新建)对应字体的字符 atlas
|
|
22845
22931
|
*/ _proto.getAtlas = function getAtlas(fontSize, fontFamily, fontWeight, fontStyle) {
|
|
22846
|
-
|
|
22932
|
+
// Pixi CanvasText 默认跟随 renderer.resolution;这里对应 Engine.pixelRatio。
|
|
22933
|
+
var resolution = this.engine.pixelRatio;
|
|
22934
|
+
if (resolution !== this.resolution) {
|
|
22935
|
+
this.clear();
|
|
22936
|
+
this.resolution = resolution;
|
|
22937
|
+
}
|
|
22938
|
+
var fontKey = fontStyle + "|" + fontWeight + "|" + fontSize + "|" + fontFamily + "|" + resolution;
|
|
22847
22939
|
var cached = this.atlases.get(fontKey);
|
|
22848
22940
|
if (cached) {
|
|
22849
22941
|
return cached;
|
|
22850
22942
|
}
|
|
22851
|
-
var scaledFontString = fontStyle + " " + fontWeight + " " + fontSize *
|
|
22943
|
+
var scaledFontString = fontStyle + " " + fontWeight + " " + fontSize * resolution + "px " + fontFamily;
|
|
22852
22944
|
// 探一次得到字体级 ascent/descent(整张 atlas 共享 cell 高与 baseline,各字对齐)。
|
|
22853
|
-
// 直接在 scaledFontString 下测,得到的就是
|
|
22945
|
+
// 直接在 scaledFontString 下测,得到的就是 resolution 后像素。
|
|
22854
22946
|
// 探针用 '|ÉqÅ' + 'M':带重音符的 ÉÅ 把 ink 顶推到接近字体真实 ascent,
|
|
22855
22947
|
// 单字 'M' 只有 cap height(~0.7em) 太矮,CJK / 带重音字顶部会越过 cell 上界被裁。
|
|
22856
22948
|
// 取 actualBoundingBoxAscent/Descent 度量 ink 边界,跨平台语义稳定
|
|
22857
22949
|
var probeCanvasAndContext = canvasPool.getCanvasAndContext(1, 1);
|
|
22858
22950
|
var probeCtx = probeCanvasAndContext.context;
|
|
22859
|
-
var ascentPx = fontSize * 0.8 *
|
|
22860
|
-
var descentPx = fontSize * 0.2 *
|
|
22951
|
+
var ascentPx = fontSize * 0.8 * resolution;
|
|
22952
|
+
var descentPx = fontSize * 0.2 * resolution;
|
|
22861
22953
|
try {
|
|
22862
22954
|
probeCtx.font = scaledFontString;
|
|
22863
22955
|
var m = probeCtx.measureText(METRICS_STRING + BASELINE_SYMBOL);
|
|
@@ -22866,7 +22958,7 @@ var canvasPool = new CanvasPool();
|
|
|
22866
22958
|
} finally{
|
|
22867
22959
|
canvasPool.releaseCanvasAndContext(probeCanvasAndContext);
|
|
22868
22960
|
}
|
|
22869
|
-
var atlas = new GlyphAtlas(this.engine, scaledFontString, ascentPx, descentPx, fontStyle);
|
|
22961
|
+
var atlas = new GlyphAtlas(this.engine, scaledFontString, ascentPx, descentPx, fontStyle, resolution);
|
|
22870
22962
|
this.atlases.set(fontKey, atlas);
|
|
22871
22963
|
return atlas;
|
|
22872
22964
|
};
|
|
@@ -22883,6 +22975,9 @@ var canvasPool = new CanvasPool();
|
|
|
22883
22975
|
/**
|
|
22884
22976
|
* 清空所有 atlas 并 dispose 对应纹理。Engine dispose 时调用
|
|
22885
22977
|
*/ _proto.dispose = function dispose() {
|
|
22978
|
+
this.clear();
|
|
22979
|
+
};
|
|
22980
|
+
_proto.clear = function clear() {
|
|
22886
22981
|
for(var _iterator = _create_for_of_iterator_helper_loose(this.atlases.values()), _step; !(_step = _iterator()).done;){
|
|
22887
22982
|
var atlas = _step.value;
|
|
22888
22983
|
atlas.dispose();
|
|
@@ -23005,6 +23100,17 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
23005
23100
|
this.texturedMaterial.depthTest = false;
|
|
23006
23101
|
this.texturedMaterial.depthMask = false;
|
|
23007
23102
|
this.texturedMaterial.blending = true;
|
|
23103
|
+
// 文本 atlas 按 Pixi 的方式在上传时预乘 alpha,因此采样后只需应用顶点色和顶点 alpha。
|
|
23104
|
+
// 单独使用 material,避免改变 drawTexture 对普通非预乘纹理的处理。
|
|
23105
|
+
this.textMaterial = Material.create(this.engine, {
|
|
23106
|
+
shader: {
|
|
23107
|
+
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 float alpha = texture2D(uMainTexture, vUV).a * vColor.a;\n gl_FragColor = vec4(vColor.rgb * alpha, alpha);\n }"
|
|
23109
|
+
}
|
|
23110
|
+
});
|
|
23111
|
+
this.textMaterial.depthTest = false;
|
|
23112
|
+
this.textMaterial.depthMask = false;
|
|
23113
|
+
this.textMaterial.blending = true;
|
|
23008
23114
|
this.textCache = new TextCache(engine);
|
|
23009
23115
|
}
|
|
23010
23116
|
var _proto = Graphics.prototype;
|
|
@@ -23026,6 +23132,7 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
23026
23132
|
);
|
|
23027
23133
|
this.coloredMaterial.setMatrix("effects_MatrixVP", projectionMatrix);
|
|
23028
23134
|
this.texturedMaterial.setMatrix("effects_MatrixVP", projectionMatrix);
|
|
23135
|
+
this.textMaterial.setMatrix("effects_MatrixVP", projectionMatrix);
|
|
23029
23136
|
};
|
|
23030
23137
|
/**
|
|
23031
23138
|
* 将当前变换压入栈,并设置新的变换
|
|
@@ -23053,7 +23160,7 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
23053
23160
|
* 切换到指定批次类型/纹理。若与当前批次不一致,先 flush 已累积顶点
|
|
23054
23161
|
*/ _proto.ensureBatch = function ensureBatch(type, texture) {
|
|
23055
23162
|
if (texture === void 0) texture = null;
|
|
23056
|
-
var sameBatch = this.currentBatchType === type && (type
|
|
23163
|
+
var sameBatch = this.currentBatchType === type && (type === "colored" || this.currentBatchTexture === texture);
|
|
23057
23164
|
if (!sameBatch && this.currentVertexCount > 0) {
|
|
23058
23165
|
this.flushBatch();
|
|
23059
23166
|
}
|
|
@@ -23079,8 +23186,8 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
23079
23186
|
this.geometry.setIndexData(indicesArray);
|
|
23080
23187
|
this.geometry.setDrawCount(this.currentIndexCount);
|
|
23081
23188
|
var material;
|
|
23082
|
-
if (this.currentBatchType === "textured") {
|
|
23083
|
-
material = this.texturedMaterial;
|
|
23189
|
+
if (this.currentBatchType === "textured" || this.currentBatchType === "text") {
|
|
23190
|
+
material = this.currentBatchType === "text" ? this.textMaterial : this.texturedMaterial;
|
|
23084
23191
|
var _this_currentBatchTexture;
|
|
23085
23192
|
var tex = (_this_currentBatchTexture = this.currentBatchTexture) != null ? _this_currentBatchTexture : this.engine.whiteTexture;
|
|
23086
23193
|
material.setTexture("uMainTexture", tex);
|
|
@@ -23295,7 +23402,7 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
23295
23402
|
return;
|
|
23296
23403
|
}
|
|
23297
23404
|
var atlas = this.textCache.getAtlas(fontSize, fontFamily, fontWeight, fontStyle);
|
|
23298
|
-
this.ensureBatch("
|
|
23405
|
+
this.ensureBatch("text", atlas.texture);
|
|
23299
23406
|
var lineHeight = atlas.lineHeight;
|
|
23300
23407
|
var cursorX = x;
|
|
23301
23408
|
// ensureChar 可能往 atlas canvas 写新字并打 dirty 标;实际 upload 推迟到
|
|
@@ -23306,13 +23413,15 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
23306
23413
|
continue;
|
|
23307
23414
|
}
|
|
23308
23415
|
// atlas 像素坐标 → UV(纹理 flipY 后,canvas 顶 → v=1,canvas 底 → v=0)
|
|
23309
|
-
var
|
|
23310
|
-
var
|
|
23311
|
-
var
|
|
23312
|
-
var
|
|
23416
|
+
var atlasWidth = atlas.canvas.width;
|
|
23417
|
+
var atlasHeight = atlas.canvas.height;
|
|
23418
|
+
var u0 = info.px / atlasWidth;
|
|
23419
|
+
var u1 = (info.px + info.pw) / atlasWidth;
|
|
23420
|
+
var v0 = 1 - (info.py + info.ph) / atlasHeight;
|
|
23421
|
+
var v1 = 1 - info.py / atlasHeight;
|
|
23313
23422
|
// quad 宽与采样区都含四周 padding(cell 留白透明);但光标只按 advance 前进,
|
|
23314
23423
|
// quad 起点左偏 paddingLeft 使字形 ink 落在 cursorX — padding 区重叠无妨
|
|
23315
|
-
this.pushQuad(cursorX - info.paddingLeft, y, info.pw /
|
|
23424
|
+
this.pushQuad(cursorX - info.paddingLeft, y, info.pw / atlas.resolution, lineHeight, color, {
|
|
23316
23425
|
u0: u0,
|
|
23317
23426
|
v0: v0,
|
|
23318
23427
|
u1: u1,
|
|
@@ -23325,6 +23434,7 @@ var Graphics = /*#__PURE__*/ function() {
|
|
|
23325
23434
|
this.geometry.dispose();
|
|
23326
23435
|
this.coloredMaterial.dispose();
|
|
23327
23436
|
this.texturedMaterial.dispose();
|
|
23437
|
+
this.textMaterial.dispose();
|
|
23328
23438
|
this.textCache.dispose();
|
|
23329
23439
|
};
|
|
23330
23440
|
_proto.buildShape = function buildShape(shape, color) {
|
|
@@ -24395,410 +24505,358 @@ exports.FrameComponent = __decorate([
|
|
|
24395
24505
|
// 第四列 (位移) 乘 1,无需修改
|
|
24396
24506
|
}
|
|
24397
24507
|
|
|
24398
|
-
|
|
24399
|
-
|
|
24400
|
-
|
|
24401
|
-
|
|
24402
|
-
|
|
24403
|
-
|
|
24404
|
-
|
|
24405
|
-
|
|
24406
|
-
|
|
24407
|
-
|
|
24408
|
-
|
|
24409
|
-
|
|
24410
|
-
|
|
24411
|
-
|
|
24412
|
-
|
|
24413
|
-
|
|
24414
|
-
|
|
24415
|
-
|
|
24416
|
-
|
|
24417
|
-
|
|
24418
|
-
|
|
24419
|
-
|
|
24420
|
-
|
|
24421
|
-
|
|
24422
|
-
|
|
24423
|
-
|
|
24424
|
-
|
|
24425
|
-
|
|
24426
|
-
|
|
24427
|
-
|
|
24428
|
-
|
|
24429
|
-
|
|
24430
|
-
|
|
24431
|
-
|
|
24432
|
-
|
|
24433
|
-
|
|
24434
|
-
|
|
24435
|
-
|
|
24436
|
-
|
|
24437
|
-
|
|
24438
|
-
|
|
24439
|
-
|
|
24440
|
-
|
|
24441
|
-
|
|
24442
|
-
|
|
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);
|
|
24443
24590
|
};
|
|
24444
|
-
|
|
24445
|
-
|
|
24446
|
-
|
|
24447
|
-
|
|
24448
|
-
|
|
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);
|
|
24449
24606
|
}
|
|
24450
|
-
|
|
24451
|
-
|
|
24452
|
-
// CanvasLayer 失效时,让其下挂的 CanvasItem 重新查找归属层
|
|
24453
|
-
// 拷贝一份避免迭代过程中数组被修改
|
|
24454
|
-
var items = this.canvasItems.slice();
|
|
24455
|
-
this.canvasItems.length = 0;
|
|
24456
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(items), _step; !(_step = _iterator()).done;){
|
|
24457
|
-
var canvasItem = _step.value;
|
|
24458
|
-
canvasItem.updateCanvasLayer();
|
|
24607
|
+
function Wrapper() {
|
|
24608
|
+
return _construct(Class, arguments, _get_prototype_of(this).constructor);
|
|
24459
24609
|
}
|
|
24460
|
-
|
|
24461
|
-
|
|
24462
|
-
|
|
24463
|
-
|
|
24464
|
-
|
|
24465
|
-
|
|
24466
|
-
*
|
|
24467
|
-
* 注:画布尺寸到 RectTransform.size 的同步目前未在此处处理(由 RectTransform 自身按需 resolve);
|
|
24468
|
-
* 后续若需要在每帧强制刷新顶层 size,可在此处补回写入与 sizeChanged 传播
|
|
24469
|
-
*
|
|
24470
|
-
* @internal
|
|
24471
|
-
*/ _proto.draw = function draw() {
|
|
24472
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(this.canvasItems), _step; !(_step = _iterator()).done;){
|
|
24473
|
-
var canvasItem = _step.value;
|
|
24474
|
-
if (!canvasItem.item.isActive) {
|
|
24475
|
-
continue;
|
|
24610
|
+
Wrapper.prototype = Object.create(Class.prototype, {
|
|
24611
|
+
constructor: {
|
|
24612
|
+
value: Wrapper,
|
|
24613
|
+
enumerable: false,
|
|
24614
|
+
writable: true,
|
|
24615
|
+
configurable: true
|
|
24476
24616
|
}
|
|
24477
|
-
|
|
24478
|
-
|
|
24617
|
+
});
|
|
24618
|
+
return _set_prototype_of(Wrapper, Class);
|
|
24479
24619
|
};
|
|
24480
|
-
return
|
|
24481
|
-
}
|
|
24620
|
+
return _wrap_native_super(Class);
|
|
24621
|
+
}
|
|
24482
24622
|
|
|
24483
|
-
|
|
24484
|
-
|
|
24485
|
-
*
|
|
24486
|
-
|
|
24487
|
-
|
|
24488
|
-
|
|
24489
|
-
|
|
24490
|
-
|
|
24491
|
-
|
|
24492
|
-
|
|
24493
|
-
|
|
24494
|
-
|
|
24495
|
-
|
|
24496
|
-
_this = Component.apply(this, arguments) || this;
|
|
24497
|
-
/**
|
|
24498
|
-
* 父 CanvasItem
|
|
24499
|
-
* 沿 VFXItem 父链向上查找到的最近的 CanvasItem(只看类型,不看 active/enabled — 拓扑跟激活状态解耦)。
|
|
24500
|
-
* 若不存在 CanvasItem 祖先(即直属于 CanvasLayer 或处于游离状态),该值为 null。
|
|
24501
|
-
*/ _this.parent = null;
|
|
24502
|
-
/**
|
|
24503
|
-
* 子 CanvasItem 列表(按注册顺序)
|
|
24504
|
-
* 由子节点在维护自身 parent 时反向写入,draw 时按数组顺序递归绘制
|
|
24505
|
-
*/ _this.children = [];
|
|
24506
|
-
/**
|
|
24507
|
-
* 当前所属的 CanvasLayer,未注册到任何 CanvasLayer 时为 null
|
|
24508
|
-
*/ _this.canvasLayerNode = null;
|
|
24509
|
-
return _this;
|
|
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;
|
|
24510
24636
|
}
|
|
24511
|
-
var _proto =
|
|
24512
|
-
_proto.
|
|
24513
|
-
|
|
24514
|
-
// 注意 enable/disable 不再改变 CanvasItem 父子拓扑 — 拓扑由 VFXItem 父链(setParent / onParentChanged)维护,
|
|
24515
|
-
// enable 在这里只是兜底首次入树
|
|
24516
|
-
this.updateCanvasLayer();
|
|
24517
|
-
this.updateParentItem();
|
|
24518
|
-
};
|
|
24519
|
-
_proto.onDisable = function onDisable() {
|
|
24520
|
-
// 组件禁用 = 仅 self.draw 跳过,不应改父子拓扑(否则 enable 回来位置就乱了)。
|
|
24521
|
-
// 整棵子树的隐藏由 `vfxItem.setActive(false)` 配合 drawInternal 中的 `item.isActive` 检查处理
|
|
24522
|
-
};
|
|
24523
|
-
_proto.onParentChanged = function onParentChanged() {
|
|
24524
|
-
// VFXItem 的父级(或间接父级)发生变化时,CanvasLayer 与父 CanvasItem 都可能改变,需要联动刷新
|
|
24525
|
-
this.updateCanvasLayer();
|
|
24526
|
-
this.updateParentItem();
|
|
24527
|
-
};
|
|
24528
|
-
_proto.onDestroy = function onDestroy() {
|
|
24529
|
-
this.removeFromParent();
|
|
24530
|
-
this.removeFromCanvasLayer();
|
|
24531
|
-
// 防止子 canvasItem updateParentItem 的时候继续找到当前已销毁的 canvasItem
|
|
24532
|
-
this.enabled = false;
|
|
24533
|
-
this.updateChildrenParentItems();
|
|
24534
|
-
};
|
|
24535
|
-
/**
|
|
24536
|
-
* 重新计算并更新当前 CanvasItem 应归属的 CanvasLayer
|
|
24537
|
-
* 在父级变化、所在 CanvasLayer 失效等场景中调用
|
|
24538
|
-
*
|
|
24539
|
-
* 仅当自身是顶层 CanvasItem(parent 为 null)时才会登记到 CanvasLayer.canvasItems;
|
|
24540
|
-
* 嵌套的子 CanvasItem 仅记录 canvasLayerNode 引用,不进入 layer 的顶层列表。
|
|
24541
|
-
* @internal
|
|
24542
|
-
*/ _proto.updateCanvasLayer = function updateCanvasLayer() {
|
|
24543
|
-
// 拓扑跟 enabled/active 解耦,只看 item 是否还在
|
|
24544
|
-
if (!this.item) {
|
|
24545
|
-
this.removeFromCanvasLayer();
|
|
24546
|
-
return;
|
|
24547
|
-
}
|
|
24548
|
-
var newLayer = this.getCanvasLayerNode();
|
|
24549
|
-
if (newLayer === this.canvasLayerNode) {
|
|
24550
|
-
return;
|
|
24551
|
-
}
|
|
24552
|
-
// 仅当自身是顶层 CanvasItem 时,才需要在 layer 的 canvasItems 中迁移
|
|
24553
|
-
if (this.parent === null && this.canvasLayerNode) {
|
|
24554
|
-
this.canvasLayerNode.removeCanvasItem(this);
|
|
24555
|
-
}
|
|
24556
|
-
this.canvasLayerNode = newLayer;
|
|
24557
|
-
if (this.parent === null && newLayer) {
|
|
24558
|
-
newLayer.addCanvasItem(this);
|
|
24559
|
-
}
|
|
24560
|
-
};
|
|
24561
|
-
/**
|
|
24562
|
-
* 重新计算并更新当前 CanvasItem 的父 CanvasItem
|
|
24563
|
-
* 在 VFXItem 父级变化、自身启用/禁用、父 CanvasItem 失效等场景中调用
|
|
24564
|
-
*
|
|
24565
|
-
* parent 的变化会同步影响在 CanvasLayer.canvasItems 中的归属:
|
|
24566
|
-
* - 由有 parent 变成无 parent 且仍归属某 layer:加入 layer.canvasItems
|
|
24567
|
-
* - 由无 parent 变成有 parent:从 layer.canvasItems 中移除
|
|
24568
|
-
* @internal
|
|
24569
|
-
*/ _proto.updateParentItem = function updateParentItem() {
|
|
24570
|
-
// 拓扑跟 enabled/active 解耦,只看 item 是否还在
|
|
24571
|
-
if (!this.item) {
|
|
24572
|
-
this.removeFromParent();
|
|
24573
|
-
return;
|
|
24574
|
-
}
|
|
24575
|
-
var newParent = this.getParentItem();
|
|
24576
|
-
if (newParent === this.parent) {
|
|
24577
|
-
return;
|
|
24578
|
-
}
|
|
24579
|
-
var wasTopLevel = this.parent === null;
|
|
24580
|
-
this.removeFromParent();
|
|
24581
|
-
if (newParent) {
|
|
24582
|
-
this.parent = newParent;
|
|
24583
|
-
newParent.children.push(this);
|
|
24584
|
-
// 由顶层变成嵌套:从 layer 的顶层列表中移除
|
|
24585
|
-
if (wasTopLevel && this.canvasLayerNode) {
|
|
24586
|
-
this.canvasLayerNode.removeCanvasItem(this);
|
|
24587
|
-
}
|
|
24588
|
-
} else if (!wasTopLevel && this.canvasLayerNode) {
|
|
24589
|
-
// 由嵌套变成顶层:加入 layer 的顶层列表
|
|
24590
|
-
this.canvasLayerNode.addCanvasItem(this);
|
|
24591
|
-
}
|
|
24592
|
-
};
|
|
24593
|
-
/**
|
|
24594
|
-
* 绘制函数
|
|
24595
|
-
* 子类重写此方法以输出实际的绘制内容;调用时 graphics 的变换栈顶已经累积了从根到当前节点的所有父变换,
|
|
24596
|
-
* 子类直接使用 this.drawXxx / this.fillXxx 系列封装方法绘制即可,绘制坐标视为本地坐标。
|
|
24597
|
-
*/ _proto.draw = function draw() {
|
|
24598
|
-
// OVERRIDE
|
|
24599
|
-
};
|
|
24600
|
-
/**
|
|
24601
|
-
* 绘制单条线段
|
|
24602
|
-
* @param x1 - 起点 x
|
|
24603
|
-
* @param y1 - 起点 y
|
|
24604
|
-
* @param x2 - 终点 x
|
|
24605
|
-
* @param y2 - 终点 y
|
|
24606
|
-
* @param color - 线条颜色
|
|
24607
|
-
* @param thickness - 线宽
|
|
24608
|
-
*/ _proto.drawLine = function drawLine(x1, y1, x2, y2, color, thickness) {
|
|
24609
|
-
this.engine.graphics.drawLine(x1, y1, x2, y2, color, thickness);
|
|
24637
|
+
var _proto = InputEvent.prototype;
|
|
24638
|
+
_proto.isPressed = function isPressed() {
|
|
24639
|
+
return this.pressed && !this.canceled;
|
|
24610
24640
|
};
|
|
24611
|
-
|
|
24612
|
-
|
|
24613
|
-
* @param points - 点数组,格式 [x1,y1,x2,y2,...]
|
|
24614
|
-
* @param color - 线条颜色
|
|
24615
|
-
* @param thickness - 线宽
|
|
24616
|
-
*/ _proto.drawPolyline = function drawPolyline(points, color, thickness) {
|
|
24617
|
-
this.engine.graphics.drawLines(points, color, thickness);
|
|
24641
|
+
_proto.isReleased = function isReleased() {
|
|
24642
|
+
return !this.pressed && !this.canceled;
|
|
24618
24643
|
};
|
|
24619
|
-
|
|
24620
|
-
|
|
24621
|
-
*/ _proto.drawBezier = function drawBezier(x1, y1, x2, y2, x3, y3, x4, y4, color, thickness) {
|
|
24622
|
-
this.engine.graphics.drawBezier(x1, y1, x2, y2, x3, y3, x4, y4, color, thickness);
|
|
24623
|
-
};
|
|
24624
|
-
/**
|
|
24625
|
-
* 绘制三角形边框
|
|
24626
|
-
*/ _proto.drawTriangle = function drawTriangle(x1, y1, x2, y2, x3, y3, color, thickness) {
|
|
24627
|
-
this.engine.graphics.drawTriangle(x1, y1, x2, y2, x3, y3, color, thickness);
|
|
24644
|
+
_proto.isCanceled = function isCanceled() {
|
|
24645
|
+
return this.canceled;
|
|
24628
24646
|
};
|
|
24629
|
-
|
|
24630
|
-
|
|
24631
|
-
* @param x - 矩形左下角 x 坐标
|
|
24632
|
-
* @param y - 矩形左下角 y 坐标
|
|
24633
|
-
*/ _proto.drawRect = function drawRect(x, y, width, height, color, thickness) {
|
|
24634
|
-
this.engine.graphics.drawRectangle(x, y, width, height, color, thickness);
|
|
24635
|
-
};
|
|
24636
|
-
/**
|
|
24637
|
-
* 绘制圆形边框
|
|
24638
|
-
*/ _proto.drawCircle = function drawCircle(cx, cy, radius, color, thickness) {
|
|
24639
|
-
this.engine.graphics.drawCircle(cx, cy, radius, color, thickness);
|
|
24640
|
-
};
|
|
24641
|
-
/**
|
|
24642
|
-
* 绘制填充三角形
|
|
24643
|
-
*/ _proto.fillTriangle = function fillTriangle(x1, y1, x2, y2, x3, y3, color) {
|
|
24644
|
-
this.engine.graphics.fillTriangle(x1, y1, x2, y2, x3, y3, color);
|
|
24645
|
-
};
|
|
24646
|
-
/**
|
|
24647
|
-
* 绘制填充矩形
|
|
24648
|
-
* @param x - 矩形左下角 x 坐标
|
|
24649
|
-
* @param y - 矩形左下角 y 坐标
|
|
24650
|
-
*/ _proto.fillRect = function fillRect(x, y, width, height, color) {
|
|
24651
|
-
this.engine.graphics.fillRectangle(x, y, width, height, color);
|
|
24652
|
-
};
|
|
24653
|
-
/**
|
|
24654
|
-
* 绘制填充圆形
|
|
24655
|
-
*/ _proto.fillCircle = function fillCircle(cx, cy, radius, color) {
|
|
24656
|
-
this.engine.graphics.fillCircle(cx, cy, radius, color);
|
|
24657
|
-
};
|
|
24658
|
-
/**
|
|
24659
|
-
* 绘制纹理矩形(本地坐标,Y 向上,(x, y) 为左下角)
|
|
24660
|
-
* @param region - 纹理 UV 子矩形,默认全图。Y 向上,(u0, v0) 为左下角 UV
|
|
24661
|
-
* @param color - 乘色,默认白色
|
|
24662
|
-
*/ _proto.drawTexture = function drawTexture(x, y, width, height, texture, region, color) {
|
|
24663
|
-
this.engine.graphics.drawTexture(x, y, width, height, texture, region, color);
|
|
24664
|
-
};
|
|
24665
|
-
/**
|
|
24666
|
-
* 绘制文本(本地坐标,Y 向上,(x, y) 为文本左下角)。
|
|
24667
|
-
*
|
|
24668
|
-
* 同一段文本不同颜色不会重复 upload — 颜色由 `color` 参数透传作为乘色,纹理只缓存白色字形。
|
|
24669
|
-
* 字体参数全部展开,避免调用方每帧创建临时 style 对象触发 GC
|
|
24670
|
-
*/ _proto.drawText = function drawText(x, y, text, fontSize, color, fontFamily, fontWeight, fontStyle) {
|
|
24671
|
-
this.engine.graphics.drawText(x, y, text, fontSize, color, fontFamily, fontWeight, fontStyle);
|
|
24672
|
-
};
|
|
24673
|
-
/**
|
|
24674
|
-
* 绘制自身并按 children 数组顺序递归绘制所有子 CanvasItem。
|
|
24675
|
-
* @internal
|
|
24676
|
-
*/ _proto.drawInternal = function drawInternal() {
|
|
24677
|
-
var graphics = this.engine.graphics;
|
|
24678
|
-
var localMatrix2D = this.transform.getMatrix2D();
|
|
24679
|
-
graphics.pushTransform(localMatrix2D);
|
|
24680
|
-
// self 是否绘制只看 component.enabled — 其它都不影响。
|
|
24681
|
-
// transform 始终被 push,children 始终被遍历,这样 component.enabled=false 时 self 隐藏
|
|
24682
|
-
// 但 children 的位置不受影响
|
|
24683
|
-
if (this.enabled) {
|
|
24684
|
-
this.draw();
|
|
24685
|
-
}
|
|
24686
|
-
// 子是否参与绘制看 VFXItem.isActive(整棵跳过的语义)。
|
|
24687
|
-
// 子自身的 component.enabled 在它自己的 drawInternal 里再判断
|
|
24688
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(this.children), _step; !(_step = _iterator()).done;){
|
|
24689
|
-
var child = _step.value;
|
|
24690
|
-
if (!child.item.isActive) {
|
|
24691
|
-
continue;
|
|
24692
|
-
}
|
|
24693
|
-
child.drawInternal();
|
|
24694
|
-
}
|
|
24695
|
-
graphics.popTransform();
|
|
24696
|
-
};
|
|
24697
|
-
/**
|
|
24698
|
-
* 从当前所属的 CanvasLayer 注销自身(如果有)
|
|
24699
|
-
* 仅当自身是顶层 CanvasItem 时,才会触发 layer 顶层列表的移除
|
|
24700
|
-
*/ _proto.removeFromCanvasLayer = function removeFromCanvasLayer() {
|
|
24701
|
-
if (!this.canvasLayerNode) {
|
|
24702
|
-
return;
|
|
24703
|
-
}
|
|
24704
|
-
if (this.parent === null) {
|
|
24705
|
-
this.canvasLayerNode.removeCanvasItem(this);
|
|
24706
|
-
}
|
|
24707
|
-
this.canvasLayerNode = null;
|
|
24708
|
-
};
|
|
24709
|
-
/**
|
|
24710
|
-
* 从当前父 CanvasItem 的 children 中移除自身(如果有)
|
|
24711
|
-
*/ _proto.removeFromParent = function removeFromParent() {
|
|
24712
|
-
if (!this.parent) {
|
|
24713
|
-
return;
|
|
24714
|
-
}
|
|
24715
|
-
removeItem(this.parent.children, this);
|
|
24716
|
-
this.parent = null;
|
|
24717
|
-
};
|
|
24718
|
-
/**
|
|
24719
|
-
* 更新所有子 CanvasItem 的层级归属。
|
|
24720
|
-
* 自身失效时调用,子节点会跳过自己向上找到新的父 CanvasItem(可能为 null)。
|
|
24721
|
-
*/ _proto.updateChildrenParentItems = function updateChildrenParentItems() {
|
|
24722
|
-
if (this.children.length === 0) {
|
|
24723
|
-
return;
|
|
24724
|
-
}
|
|
24725
|
-
// 拷贝避免迭代过程中数组被 removeFromParent 修改
|
|
24726
|
-
var snapshot = this.children.slice();
|
|
24727
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(snapshot), _step; !(_step = _iterator()).done;){
|
|
24728
|
-
var child = _step.value;
|
|
24729
|
-
child.updateParentItem();
|
|
24730
|
-
}
|
|
24731
|
-
};
|
|
24732
|
-
/**
|
|
24733
|
-
* 沿父链向上查找最近的 CanvasLayer 祖先
|
|
24734
|
-
* 注意:自身所在 VFXItem 上的 CanvasLayer 也参与查找(同节点上可能并存 CanvasLayer 与 CanvasItem)
|
|
24735
|
-
*/ _proto.getCanvasLayerNode = function getCanvasLayerNode() {
|
|
24736
|
-
var current = this.item;
|
|
24737
|
-
while(current){
|
|
24738
|
-
var layer = getCanvasLayerFromItem(current);
|
|
24739
|
-
if (layer) {
|
|
24740
|
-
return layer;
|
|
24741
|
-
}
|
|
24742
|
-
var _current_parent;
|
|
24743
|
-
current = (_current_parent = current.parent) != null ? _current_parent : null;
|
|
24744
|
-
}
|
|
24745
|
-
return null;
|
|
24647
|
+
_proto.isEcho = function isEcho() {
|
|
24648
|
+
return false;
|
|
24746
24649
|
};
|
|
24747
|
-
|
|
24748
|
-
|
|
24749
|
-
|
|
24750
|
-
|
|
24751
|
-
|
|
24752
|
-
|
|
24753
|
-
while(current){
|
|
24754
|
-
var canvasItem = getCanvasItemFromItem(current);
|
|
24755
|
-
if (canvasItem) {
|
|
24756
|
-
return canvasItem;
|
|
24757
|
-
}
|
|
24758
|
-
var _current_parent;
|
|
24759
|
-
current = (_current_parent = current.parent) != null ? _current_parent : null;
|
|
24760
|
-
}
|
|
24761
|
-
return null;
|
|
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;
|
|
24762
24656
|
};
|
|
24763
|
-
|
|
24764
|
-
|
|
24765
|
-
|
|
24766
|
-
|
|
24767
|
-
|
|
24768
|
-
|
|
24769
|
-
|
|
24770
|
-
|
|
24771
|
-
|
|
24772
|
-
|
|
24773
|
-
|
|
24774
|
-
|
|
24775
|
-
|
|
24776
|
-
|
|
24777
|
-
|
|
24778
|
-
|
|
24779
|
-
|
|
24780
|
-
if (_instanceof1(component, CanvasLayer) && component.isActiveAndEnabled) {
|
|
24781
|
-
return component;
|
|
24782
|
-
}
|
|
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;
|
|
24783
24674
|
}
|
|
24784
|
-
|
|
24785
|
-
|
|
24786
|
-
|
|
24787
|
-
|
|
24788
|
-
|
|
24789
|
-
|
|
24790
|
-
|
|
24791
|
-
|
|
24792
|
-
|
|
24793
|
-
|
|
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;
|
|
24794
24705
|
}
|
|
24795
|
-
|
|
24796
|
-
|
|
24797
|
-
|
|
24798
|
-
|
|
24799
|
-
|
|
24800
|
-
|
|
24801
|
-
|
|
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 = {
|
|
24802
24860
|
topLeft: [
|
|
24803
24861
|
0,
|
|
24804
24862
|
1,
|
|
@@ -24897,306 +24955,170 @@ exports.FrameComponent = __decorate([
|
|
|
24897
24955
|
]
|
|
24898
24956
|
};
|
|
24899
24957
|
/**
|
|
24900
|
-
*
|
|
24901
|
-
*
|
|
24902
|
-
|
|
24903
|
-
|
|
24904
|
-
|
|
24905
|
-
|
|
24906
|
-
|
|
24907
|
-
|
|
24908
|
-
|
|
24909
|
-
|
|
24910
|
-
|
|
24911
|
-
|
|
24912
|
-
|
|
24913
|
-
|
|
24914
|
-
|
|
24915
|
-
|
|
24916
|
-
|
|
24917
|
-
|
|
24918
|
-
|
|
24919
|
-
|
|
24920
|
-
|
|
24921
|
-
|
|
24922
|
-
|
|
24923
|
-
|
|
24924
|
-
|
|
24925
|
-
|
|
24926
|
-
|
|
24927
|
-
|
|
24928
|
-
|
|
24929
|
-
|
|
24930
|
-
* 父 rect 上的归一化最小角 `(anchorLeft, anchorBottom)`
|
|
24931
|
-
*/ _this.anchorMin = new Vector2(0, 0);
|
|
24932
|
-
/**
|
|
24933
|
-
* 父 rect 上的归一化最大角 `(anchorRight, anchorTop)`
|
|
24934
|
-
*/ _this.anchorMax = new Vector2(0, 0);
|
|
24935
|
-
/**
|
|
24936
|
-
* rect 左/下边相对 anchorMin 锚点的像素偏移 `(offsetLeft, offsetBottom)`
|
|
24937
|
-
*/ _this.offsetMin = new Vector2(0, 0);
|
|
24938
|
-
/**
|
|
24939
|
-
* rect 右/上边相对 anchorMax 锚点的像素偏移 `(offsetRight, offsetTop)`
|
|
24940
|
-
*/ _this.offsetMax = new Vector2(0, 0);
|
|
24941
|
-
/**
|
|
24942
|
-
* 自身 rect 上的归一化轴心 `(0..1)`,默认 `(0.5, 0.5)`(中心)。两层效果:
|
|
24943
|
-
* 1. **Layout**:`setSize` 时 rect 围绕此点对称缩放(pivot=(0.5, 0.5) → 居中扩展;pivot=(0, 0) → 从左下扩展;pivot=(1, 1) → 向左下缩)
|
|
24944
|
-
* 2. **矩阵**:`pivot` 自动同步到 `transform.anchor = pivot * size`(像素值,矩阵旋转/缩放中心),
|
|
24945
|
-
* 所以旋转/缩放也围绕同一点。`setPivot` 和每次 `sizeChanged`(size 重算后)都会刷新 `transform.anchor`
|
|
24946
|
-
*/ _this.pivot = new Vector2(0.5, 0.5);
|
|
24947
|
-
return _this;
|
|
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;
|
|
24948
24988
|
}
|
|
24949
|
-
var _proto =
|
|
24950
|
-
|
|
24951
|
-
|
|
24952
|
-
|
|
24953
|
-
|
|
24954
|
-
|
|
24955
|
-
|
|
24956
|
-
|
|
24957
|
-
|
|
24958
|
-
|
|
24959
|
-
|
|
24960
|
-
Transform.prototype.fromData.call(this, data);
|
|
24961
|
-
if (this.size.x !== 0 && this.size.y !== 0) {
|
|
24962
|
-
this.pivot.set(this.anchor.x / this.size.x, this.anchor.y / this.size.y);
|
|
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;
|
|
24963
25000
|
}
|
|
24964
|
-
|
|
24965
|
-
|
|
24966
|
-
|
|
24967
|
-
|
|
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());
|
|
24968
25009
|
}
|
|
24969
|
-
|
|
24970
|
-
|
|
24971
|
-
|
|
24972
|
-
|
|
25010
|
+
this.updateLayout();
|
|
25011
|
+
};
|
|
25012
|
+
_proto.setSize = function setSize(width, height) {
|
|
25013
|
+
if (this.size.x === width && this.size.y === height) {
|
|
25014
|
+
return;
|
|
24973
25015
|
}
|
|
24974
|
-
|
|
24975
|
-
|
|
24976
|
-
|
|
24977
|
-
|
|
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();
|
|
24978
25027
|
}
|
|
24979
|
-
|
|
24980
|
-
|
|
24981
|
-
|
|
24982
|
-
this.
|
|
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();
|
|
24983
25045
|
}
|
|
24984
25046
|
};
|
|
24985
|
-
// ── layout-input setters(改完 → sizeChanged 重算)──────
|
|
24986
25047
|
_proto.setAnchorMin = function setAnchorMin(x, y) {
|
|
24987
25048
|
if (this.anchorMin.x !== x || this.anchorMin.y !== y) {
|
|
24988
|
-
this.anchorMin.x
|
|
24989
|
-
this.
|
|
24990
|
-
this.sizeChanged();
|
|
25049
|
+
this.anchorMin.set(x, y);
|
|
25050
|
+
this.updateLayout();
|
|
24991
25051
|
}
|
|
24992
25052
|
};
|
|
24993
25053
|
_proto.setAnchorMax = function setAnchorMax(x, y) {
|
|
24994
25054
|
if (this.anchorMax.x !== x || this.anchorMax.y !== y) {
|
|
24995
|
-
this.anchorMax.x
|
|
24996
|
-
this.
|
|
24997
|
-
this.sizeChanged();
|
|
25055
|
+
this.anchorMax.set(x, y);
|
|
25056
|
+
this.updateLayout();
|
|
24998
25057
|
}
|
|
24999
25058
|
};
|
|
25000
25059
|
_proto.setOffsetMin = function setOffsetMin(x, y) {
|
|
25001
25060
|
if (this.offsetMin.x !== x || this.offsetMin.y !== y) {
|
|
25002
|
-
this.offsetMin.x
|
|
25003
|
-
this.
|
|
25004
|
-
this.sizeChanged();
|
|
25061
|
+
this.offsetMin.set(x, y);
|
|
25062
|
+
this.updateLayout();
|
|
25005
25063
|
}
|
|
25006
25064
|
};
|
|
25007
25065
|
_proto.setOffsetMax = function setOffsetMax(x, y) {
|
|
25008
25066
|
if (this.offsetMax.x !== x || this.offsetMax.y !== y) {
|
|
25009
|
-
this.offsetMax.x
|
|
25010
|
-
this.
|
|
25011
|
-
this.sizeChanged();
|
|
25012
|
-
}
|
|
25013
|
-
};
|
|
25014
|
-
/**
|
|
25015
|
-
* 设置 rect 内的归一化轴心 `(0..1)`,同时把 `transform.anchor`(矩阵旋转/缩放中心)同步到 `pivot * size`。
|
|
25016
|
-
* 不重算 rect(pivot 只决定 setSize 行为,不直接影响当前 rect 位置 / 尺寸)
|
|
25017
|
-
*/ _proto.setPivot = function setPivot(x, y) {
|
|
25018
|
-
if (this.pivot.x !== x || this.pivot.y !== y) {
|
|
25019
|
-
this.pivot.x = x;
|
|
25020
|
-
this.pivot.y = y;
|
|
25021
|
-
// 同步 transform.anchor(像素 pivot)= pivot * size,让旋转/缩放绕同一点
|
|
25022
|
-
this.anchor.set(this.pivot.x * this.size.x, this.pivot.y * this.size.y, this.anchor.z);
|
|
25067
|
+
this.offsetMax.set(x, y);
|
|
25068
|
+
this.updateLayout();
|
|
25023
25069
|
}
|
|
25024
25070
|
};
|
|
25025
|
-
|
|
25026
|
-
* 重写父类 `setPosition`:
|
|
25027
|
-
* - 顶层(无 RectTransform 父):直接 `super.setPosition` 写位置,触发 `sizeChanged` 传播
|
|
25028
|
-
* - 非顶层:语义为"设置 rect 左下角到 (x, y)",反推 offset 维持当前 anchor,然后 `sizeChanged` 重算
|
|
25029
|
-
*
|
|
25030
|
-
* @param keepOffsets - 默认 false。true 时反推 anchor 而非 offset(rect 在屏幕上不动,但 anchor 比例改变)
|
|
25031
|
-
*/ _proto.setPosition = function setPosition(x, y, z, keepOffsets) {
|
|
25032
|
-
if (keepOffsets === void 0) keepOffsets = false;
|
|
25033
|
-
if (!_instanceof1(this.parentTransform, RectTransform)) {
|
|
25034
|
-
// 顶层:直接写,然后传播给子节点
|
|
25035
|
-
Transform.prototype.setPosition.call(this, x, y, z);
|
|
25036
|
-
this.sizeChanged();
|
|
25037
|
-
return;
|
|
25038
|
-
}
|
|
25039
|
-
var parentRect = {
|
|
25040
|
-
position: new Vector2(0, 0),
|
|
25041
|
-
size: this.parentTransform.size.clone()
|
|
25042
|
-
};
|
|
25043
|
-
var newRect = {
|
|
25044
|
-
position: new Vector2(x, y),
|
|
25045
|
-
size: this.size.clone()
|
|
25046
|
-
};
|
|
25047
|
-
if (keepOffsets) {
|
|
25048
|
-
this.computeAnchors(newRect, parentRect);
|
|
25049
|
-
} else {
|
|
25050
|
-
this.computeOffsets(newRect, parentRect);
|
|
25051
|
-
}
|
|
25052
|
-
this.sizeChanged();
|
|
25053
|
-
if (this.position.z !== z) {
|
|
25054
|
-
Transform.prototype.setPosition.call(this, this.position.x, this.position.y, z);
|
|
25055
|
-
}
|
|
25056
|
-
};
|
|
25057
|
-
/**
|
|
25058
|
-
* 重写父类 `setSize`:
|
|
25059
|
-
* - 顶层:直接 `super.setSize`,触发 `sizeChanged` 传播
|
|
25060
|
-
* - 非顶层:反推 offset 维持当前 anchor,然后 `sizeChanged` 重算
|
|
25061
|
-
*/ _proto.setSize = function setSize(x, y) {
|
|
25062
|
-
if (this.size.x === x && this.size.y === y) {
|
|
25063
|
-
return;
|
|
25064
|
-
}
|
|
25065
|
-
if (!_instanceof1(this.parentTransform, RectTransform)) {
|
|
25066
|
-
Transform.prototype.setSize.call(this, x, y);
|
|
25067
|
-
this.sizeChanged();
|
|
25068
|
-
return;
|
|
25069
|
-
}
|
|
25070
|
-
// 围绕 pivot 对称缩放:Δsize 在 offsetMin / offsetMax 上按 pivot / (1-pivot) 比例分配。
|
|
25071
|
-
// 例如 pivot=(0.5, 0.5) → 两边各 ±Δ/2,rect 居中扩展;pivot=(0, 0) → offsetMin 不动、offsetMax 全吃,rect 从左下扩展
|
|
25072
|
-
var dw = x - this.size.x;
|
|
25073
|
-
var dh = y - this.size.y;
|
|
25074
|
-
this.offsetMin.set(this.offsetMin.x - this.pivot.x * dw, this.offsetMin.y - this.pivot.y * dh);
|
|
25075
|
-
this.offsetMax.set(this.offsetMax.x + (1 - this.pivot.x) * dw, this.offsetMax.y + (1 - this.pivot.y) * dh);
|
|
25076
|
-
this.sizeChanged();
|
|
25077
|
-
};
|
|
25078
|
-
// ── rect query ───────────────────────────────────────
|
|
25079
|
-
/**
|
|
25080
|
-
* 当前自身 rect(在父 vertex 坐标下,Y 向上)。`sizeChanged` 之后才有意义
|
|
25081
|
-
*/ _proto.getRect = function getRect() {
|
|
25071
|
+
_proto.getRect = function getRect() {
|
|
25082
25072
|
return {
|
|
25083
|
-
position:
|
|
25073
|
+
position: this.position.clone(),
|
|
25084
25074
|
size: this.size.clone()
|
|
25085
25075
|
};
|
|
25086
25076
|
};
|
|
25087
|
-
|
|
25088
|
-
|
|
25089
|
-
|
|
25090
|
-
|
|
25091
|
-
|
|
25092
|
-
|
|
25093
|
-
|
|
25094
|
-
|
|
25095
|
-
|
|
25096
|
-
this.
|
|
25097
|
-
this.
|
|
25098
|
-
|
|
25099
|
-
|
|
25100
|
-
|
|
25101
|
-
|
|
25102
|
-
|
|
25103
|
-
|
|
25104
|
-
|
|
25105
|
-
|
|
25106
|
-
|
|
25107
|
-
|
|
25108
|
-
*
|
|
25109
|
-
* 1. 父是 RectTransform → 从 `parent.size` 求自身 rect,通过 `super.setPosition / super.setSize` 写回
|
|
25110
|
-
* (避免触发本类 setPosition / setSize 重写)
|
|
25111
|
-
* 2. 顶层(无 RectTransform 父):自身 size 视为权威值(由 CanvasLayer 等外部直接写),不自解算
|
|
25112
|
-
* 3. 遍历 `children` 中所有 RectTransform 子节点,直接调它们的 `sizeChanged()` 链式传播
|
|
25113
|
-
*/ _proto.sizeChanged = function sizeChanged() {
|
|
25114
|
-
if (_instanceof1(this.parentTransform, RectTransform)) {
|
|
25115
|
-
var parentSize = this.parentTransform.size;
|
|
25116
|
-
var left = this.offsetMin.x + this.anchorMin.x * parentSize.x;
|
|
25117
|
-
var bottom = this.offsetMin.y + this.anchorMin.y * parentSize.y;
|
|
25118
|
-
var right = this.offsetMax.x + this.anchorMax.x * parentSize.x;
|
|
25119
|
-
var top = this.offsetMax.y + this.anchorMax.y * parentSize.y;
|
|
25120
|
-
Transform.prototype.setPosition.call(this, left, bottom, this.position.z);
|
|
25121
|
-
Transform.prototype.setSize.call(this, right - left, top - bottom);
|
|
25122
|
-
}
|
|
25123
|
-
// size 更新后同步 transform.anchor(矩阵旋转/缩放中心)= pivot * size,跟 setPivot 保持统一
|
|
25124
|
-
this.anchor.set(this.pivot.x * this.size.x, this.pivot.y * this.size.y, this.anchor.z);
|
|
25125
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(this.children), _step; !(_step = _iterator()).done;){
|
|
25126
|
-
var child = _step.value;
|
|
25127
|
-
if (_instanceof1(child, RectTransform)) {
|
|
25128
|
-
child.sizeChanged();
|
|
25129
|
-
}
|
|
25130
|
-
}
|
|
25131
|
-
};
|
|
25132
|
-
/**
|
|
25133
|
-
* 给定目标 rect 反推 offsetMin/Max,保持当前 anchor 不变
|
|
25134
|
-
*/ _proto.computeOffsets = function computeOffsets(rect, parentRect) {
|
|
25135
|
-
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);
|
|
25136
|
-
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);
|
|
25137
|
-
};
|
|
25138
|
-
/**
|
|
25139
|
-
* 给定目标 rect 反推 anchorMin/Max,保持当前 offset 不变。父 size 为 0 的方向不修改
|
|
25140
|
-
*/ _proto.computeAnchors = function computeAnchors(rect, parentRect) {
|
|
25141
|
-
if (parentRect.size.x !== 0) {
|
|
25142
|
-
var aMinX = (rect.position.x - parentRect.position.x - this.offsetMin.x) / parentRect.size.x;
|
|
25143
|
-
var aMaxX = (rect.position.x + rect.size.x - parentRect.position.x - this.offsetMax.x) / parentRect.size.x;
|
|
25144
|
-
this.anchorMin.x = aMinX;
|
|
25145
|
-
this.anchorMax.x = aMaxX;
|
|
25146
|
-
}
|
|
25147
|
-
if (parentRect.size.y !== 0) {
|
|
25148
|
-
var aMinY = (rect.position.y - parentRect.position.y - this.offsetMin.y) / parentRect.size.y;
|
|
25149
|
-
var aMaxY = (rect.position.y + rect.size.y - parentRect.position.y - this.offsetMax.y) / parentRect.size.y;
|
|
25150
|
-
this.anchorMin.y = aMinY;
|
|
25151
|
-
this.anchorMax.y = aMaxY;
|
|
25152
|
-
}
|
|
25153
|
-
};
|
|
25154
|
-
// ── preset API ───────────────────────────────────────
|
|
25155
|
-
/**
|
|
25156
|
-
* 把 anchorMin/Max 设为内建预设。
|
|
25157
|
-
* @param keepOffsets - 默认 true:offset 不动,rect 实际位置会跳到新 anchor 计算的位置(要求保留视觉位置请用 setAnchorsAndOffsetsPreset)
|
|
25158
|
-
*/ _proto.setAnchorsPreset = function setAnchorsPreset(preset, keepOffsets) {
|
|
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) {
|
|
25159
25098
|
if (keepOffsets === void 0) keepOffsets = true;
|
|
25160
|
-
var _ANCHOR_PRESET_TABLE_preset = ANCHOR_PRESET_TABLE[preset],
|
|
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];
|
|
25161
25100
|
if (keepOffsets) {
|
|
25162
|
-
this.anchorMin.set(
|
|
25163
|
-
this.anchorMax.set(
|
|
25164
|
-
} else if (_instanceof1(this.parentTransform, RectTransform)) {
|
|
25165
|
-
var parentRect = {
|
|
25166
|
-
position: new Vector2(0, 0),
|
|
25167
|
-
size: this.parentTransform.size.clone()
|
|
25168
|
-
};
|
|
25169
|
-
var rect = this.getRect();
|
|
25170
|
-
this.anchorMin.set(aMinX, aMinY);
|
|
25171
|
-
this.anchorMax.set(aMaxX, aMaxY);
|
|
25172
|
-
this.computeOffsets(rect, parentRect);
|
|
25101
|
+
this.anchorMin.set(minX, minY);
|
|
25102
|
+
this.anchorMax.set(maxX, maxY);
|
|
25173
25103
|
} else {
|
|
25174
|
-
|
|
25175
|
-
this.anchorMin.set(
|
|
25176
|
-
this.anchorMax.set(
|
|
25104
|
+
var rect = this.getRect();
|
|
25105
|
+
this.anchorMin.set(minX, minY);
|
|
25106
|
+
this.anchorMax.set(maxX, maxY);
|
|
25107
|
+
this.computeOffsets(rect, this.getParentRect());
|
|
25177
25108
|
}
|
|
25178
|
-
this.
|
|
25109
|
+
this.updateLayout();
|
|
25179
25110
|
};
|
|
25180
|
-
|
|
25181
|
-
* 把 offsetMin/Max 设为预设值,使 rect 在父 rect 内落在视觉上对应的位置(留 margin 像素边距)。
|
|
25182
|
-
* 当 anchor 已经按相同 preset 设定时,等价于“贴边放置带 margin 的 rect”。
|
|
25183
|
-
* 使用当前 size 作为 rect 尺寸。
|
|
25184
|
-
*/ _proto.setOffsetsPreset = function setOffsetsPreset(preset, margin) {
|
|
25111
|
+
_proto.setOffsetsPreset = function setOffsetsPreset(preset, margin) {
|
|
25185
25112
|
if (margin === void 0) margin = 0;
|
|
25186
|
-
if (!
|
|
25113
|
+
if (!this.parent) {
|
|
25187
25114
|
return;
|
|
25188
25115
|
}
|
|
25189
|
-
var
|
|
25190
|
-
var
|
|
25116
|
+
var parentSize = this.parent.size;
|
|
25117
|
+
var width = this.size.x;
|
|
25118
|
+
var height = this.size.y;
|
|
25191
25119
|
var a = this.anchorMin;
|
|
25192
25120
|
var b = this.anchorMax;
|
|
25193
|
-
var
|
|
25194
|
-
var ph = this.parentTransform.size.y;
|
|
25195
|
-
var offMinX = 0;
|
|
25196
|
-
var offMaxX = 0;
|
|
25197
|
-
var offMinY = 0;
|
|
25198
|
-
var offMaxY = 0;
|
|
25199
|
-
// X 方向(left / right)
|
|
25121
|
+
var minX = 0, maxX = 0, minY = 0, maxY = 0;
|
|
25200
25122
|
switch(preset){
|
|
25201
25123
|
case "topLeft":
|
|
25202
25124
|
case "bottomLeft":
|
|
@@ -25206,25 +25128,21 @@ exports.FrameComponent = __decorate([
|
|
|
25206
25128
|
case "leftWide":
|
|
25207
25129
|
case "hcenterWide":
|
|
25208
25130
|
case "fullRect":
|
|
25209
|
-
|
|
25210
|
-
|
|
25131
|
+
minX = margin - a.x * parentSize.x;
|
|
25132
|
+
maxX = margin + width - b.x * parentSize.x;
|
|
25211
25133
|
break;
|
|
25212
25134
|
case "centerTop":
|
|
25213
25135
|
case "centerBottom":
|
|
25214
25136
|
case "center":
|
|
25215
25137
|
case "vcenterWide":
|
|
25216
|
-
|
|
25217
|
-
|
|
25138
|
+
minX = 0.5 * parentSize.x - width / 2 - a.x * parentSize.x;
|
|
25139
|
+
maxX = 0.5 * parentSize.x + width / 2 - b.x * parentSize.x;
|
|
25218
25140
|
break;
|
|
25219
|
-
|
|
25220
|
-
|
|
25221
|
-
|
|
25222
|
-
case "rightWide":
|
|
25223
|
-
offMinX = pw - margin - newSizeX - a.x * pw;
|
|
25224
|
-
offMaxX = pw - margin - b.x * pw;
|
|
25141
|
+
default:
|
|
25142
|
+
minX = parentSize.x - margin - width - a.x * parentSize.x;
|
|
25143
|
+
maxX = parentSize.x - margin - b.x * parentSize.x;
|
|
25225
25144
|
break;
|
|
25226
25145
|
}
|
|
25227
|
-
// Y 方向(bottom / top)— Y 向上
|
|
25228
25146
|
switch(preset){
|
|
25229
25147
|
case "bottomLeft":
|
|
25230
25148
|
case "bottomRight":
|
|
@@ -25234,91 +25152,1438 @@ exports.FrameComponent = __decorate([
|
|
|
25234
25152
|
case "bottomWide":
|
|
25235
25153
|
case "vcenterWide":
|
|
25236
25154
|
case "fullRect":
|
|
25237
|
-
|
|
25238
|
-
|
|
25155
|
+
minY = margin - a.y * parentSize.y;
|
|
25156
|
+
maxY = margin + height - b.y * parentSize.y;
|
|
25239
25157
|
break;
|
|
25240
25158
|
case "centerLeft":
|
|
25241
25159
|
case "centerRight":
|
|
25242
25160
|
case "center":
|
|
25243
25161
|
case "hcenterWide":
|
|
25244
|
-
|
|
25245
|
-
|
|
25162
|
+
minY = 0.5 * parentSize.y - height / 2 - a.y * parentSize.y;
|
|
25163
|
+
maxY = 0.5 * parentSize.y + height / 2 - b.y * parentSize.y;
|
|
25246
25164
|
break;
|
|
25247
|
-
|
|
25248
|
-
|
|
25249
|
-
|
|
25250
|
-
case "topWide":
|
|
25251
|
-
offMinY = ph - margin - newSizeY - a.y * ph;
|
|
25252
|
-
offMaxY = ph - margin - b.y * ph;
|
|
25165
|
+
default:
|
|
25166
|
+
minY = parentSize.y - margin - height - a.y * parentSize.y;
|
|
25167
|
+
maxY = parentSize.y - margin - b.y * parentSize.y;
|
|
25253
25168
|
break;
|
|
25254
25169
|
}
|
|
25255
|
-
this.offsetMin.set(
|
|
25256
|
-
this.offsetMax.set(
|
|
25257
|
-
this.
|
|
25170
|
+
this.offsetMin.set(minX, minY);
|
|
25171
|
+
this.offsetMax.set(maxX, maxY);
|
|
25172
|
+
this.updateLayout();
|
|
25258
25173
|
};
|
|
25259
|
-
|
|
25260
|
-
* 同时设置 anchor 和 offset,达到“按 preset 摆放并贴边带 margin”的效果。
|
|
25261
|
-
*
|
|
25262
|
-
* 注意第一步用 `keepOffsets=false`(反推 offset 维持 rect 视觉位置),不能用默认 `true`:
|
|
25263
|
-
* 后者会让 rect 的 size 在中间步先跳到错值(因为 anchor 改了 offset 没改),
|
|
25264
|
-
* 第二步 `setOffsetsPreset` 又用这个错 size 算 offset,最终 rect size 不对
|
|
25265
|
-
*/ _proto.setAnchorsAndOffsetsPreset = function setAnchorsAndOffsetsPreset(preset, margin) {
|
|
25174
|
+
_proto.setAnchorsAndOffsetsPreset = function setAnchorsAndOffsetsPreset(preset, margin) {
|
|
25266
25175
|
if (margin === void 0) margin = 0;
|
|
25267
25176
|
this.setAnchorsPreset(preset, false);
|
|
25268
25177
|
this.setOffsetsPreset(preset, margin);
|
|
25269
25178
|
};
|
|
25270
|
-
|
|
25271
|
-
|
|
25272
|
-
|
|
25273
|
-
|
|
25274
|
-
|
|
25275
|
-
|
|
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
|
+
}
|
|
25276
26099
|
}
|
|
25277
|
-
|
|
25278
|
-
|
|
25279
|
-
|
|
25280
|
-
|
|
25281
|
-
|
|
25282
|
-
|
|
25283
|
-
|
|
25284
|
-
|
|
25285
|
-
|
|
25286
|
-
|
|
25287
|
-
|
|
25288
|
-
|
|
25289
|
-
|
|
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;
|
|
25290
26142
|
}
|
|
25291
|
-
|
|
26143
|
+
hierarchy.reverse();
|
|
26144
|
+
return hierarchy;
|
|
25292
26145
|
};
|
|
25293
|
-
|
|
25294
|
-
|
|
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);
|
|
25295
26401
|
|
|
25296
26402
|
/**
|
|
25297
|
-
*
|
|
25298
|
-
*
|
|
25299
|
-
|
|
25300
|
-
|
|
25301
|
-
|
|
25302
|
-
|
|
25303
|
-
|
|
25304
|
-
|
|
25305
|
-
|
|
25306
|
-
|
|
25307
|
-
|
|
25308
|
-
|
|
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;
|
|
25309
26421
|
}
|
|
25310
|
-
var _proto =
|
|
25311
|
-
|
|
25312
|
-
|
|
25313
|
-
|
|
25314
|
-
|
|
25315
|
-
|
|
25316
|
-
|
|
25317
|
-
|
|
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;
|
|
25318
26430
|
}
|
|
25319
26431
|
};
|
|
25320
|
-
|
|
25321
|
-
|
|
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);
|
|
25322
26587
|
|
|
25323
26588
|
exports.CameraController = /*#__PURE__*/ function(Component) {
|
|
25324
26589
|
_inherits(CameraController, Component);
|
|
@@ -25354,42 +26619,6 @@ exports.CameraController = __decorate([
|
|
|
25354
26619
|
effectsClass(DataType.CameraController)
|
|
25355
26620
|
], exports.CameraController);
|
|
25356
26621
|
|
|
25357
|
-
function _get_prototype_of(o) {
|
|
25358
|
-
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
25359
|
-
return o.__proto__ || Object.getPrototypeOf(o);
|
|
25360
|
-
};
|
|
25361
|
-
return _get_prototype_of(o);
|
|
25362
|
-
}
|
|
25363
|
-
|
|
25364
|
-
function _is_native_function(fn) {
|
|
25365
|
-
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
25366
|
-
}
|
|
25367
|
-
|
|
25368
|
-
function _wrap_native_super(Class) {
|
|
25369
|
-
var _cache = typeof Map === "function" ? new Map() : undefined;
|
|
25370
|
-
_wrap_native_super = function _wrap_native_super(Class) {
|
|
25371
|
-
if (Class === null || !_is_native_function(Class)) return Class;
|
|
25372
|
-
if (typeof Class !== "function") throw new TypeError("Super expression must either be null or a function");
|
|
25373
|
-
if (typeof _cache !== "undefined") {
|
|
25374
|
-
if (_cache.has(Class)) return _cache.get(Class);
|
|
25375
|
-
_cache.set(Class, Wrapper);
|
|
25376
|
-
}
|
|
25377
|
-
function Wrapper() {
|
|
25378
|
-
return _construct(Class, arguments, _get_prototype_of(this).constructor);
|
|
25379
|
-
}
|
|
25380
|
-
Wrapper.prototype = Object.create(Class.prototype, {
|
|
25381
|
-
constructor: {
|
|
25382
|
-
value: Wrapper,
|
|
25383
|
-
enumerable: false,
|
|
25384
|
-
writable: true,
|
|
25385
|
-
configurable: true
|
|
25386
|
-
}
|
|
25387
|
-
});
|
|
25388
|
-
return _set_prototype_of(Wrapper, Class);
|
|
25389
|
-
};
|
|
25390
|
-
return _wrap_native_super(Class);
|
|
25391
|
-
}
|
|
25392
|
-
|
|
25393
26622
|
var CameraVFXItemLoader = /*#__PURE__*/ function(Plugin) {
|
|
25394
26623
|
_inherits(CameraVFXItemLoader, Plugin);
|
|
25395
26624
|
function CameraVFXItemLoader() {
|
|
@@ -25410,142 +26639,202 @@ exports.PointerEventType = void 0;
|
|
|
25410
26639
|
})(exports.PointerEventType || (exports.PointerEventType = {}));
|
|
25411
26640
|
var EventSystem = /*#__PURE__*/ function() {
|
|
25412
26641
|
function EventSystem(engine, allowPropagation) {
|
|
26642
|
+
var _this = this;
|
|
25413
26643
|
if (allowPropagation === void 0) allowPropagation = false;
|
|
25414
26644
|
this.engine = engine;
|
|
25415
26645
|
this.allowPropagation = allowPropagation;
|
|
25416
|
-
this.enabled = true;
|
|
25417
26646
|
this.skipPointerMovePicking = true;
|
|
26647
|
+
this.emulateMouseFromTouch = true;
|
|
26648
|
+
this.emulateTouchFromMouse = false;
|
|
26649
|
+
this._enabled = true;
|
|
25418
26650
|
this.handlers = {};
|
|
25419
|
-
this.nativeHandlers =
|
|
26651
|
+
this.nativeHandlers = [];
|
|
25420
26652
|
this.target = null;
|
|
25421
|
-
|
|
25422
|
-
|
|
25423
|
-
|
|
25424
|
-
|
|
25425
|
-
this.
|
|
25426
|
-
|
|
25427
|
-
|
|
25428
|
-
|
|
25429
|
-
|
|
25430
|
-
|
|
25431
|
-
|
|
25432
|
-
|
|
26653
|
+
this.mouseState = null;
|
|
26654
|
+
this.touchStates = new Map();
|
|
26655
|
+
this.mouseFromTouchIndex = null;
|
|
26656
|
+
this.touchFromMousePressed = false;
|
|
26657
|
+
this.addedTabIndex = false;
|
|
26658
|
+
this.addedOutlineStyle = false;
|
|
26659
|
+
this.onNativeWheel = function(event) {
|
|
26660
|
+
if (!_this.enabled || !_this.target) {
|
|
26661
|
+
return;
|
|
26662
|
+
}
|
|
26663
|
+
var position = _this.getCanvasPosition(event.clientX, event.clientY);
|
|
26664
|
+
var handled = false;
|
|
26665
|
+
if (event.deltaY !== 0) {
|
|
26666
|
+
handled = _this.pushWheelButton(event.deltaY < 0 ? exports.MouseButton.WheelUp : exports.MouseButton.WheelDown, Math.abs(event.deltaY), position, event) || handled;
|
|
26667
|
+
}
|
|
26668
|
+
if (event.deltaX !== 0) {
|
|
26669
|
+
handled = _this.pushWheelButton(event.deltaX < 0 ? exports.MouseButton.WheelLeft : exports.MouseButton.WheelRight, Math.abs(event.deltaX), position, event) || handled;
|
|
26670
|
+
}
|
|
26671
|
+
_this.consumeNativeEvent(event, handled);
|
|
25433
26672
|
};
|
|
25434
|
-
|
|
25435
|
-
|
|
25436
|
-
|
|
25437
|
-
|
|
25438
|
-
|
|
25439
|
-
|
|
25440
|
-
|
|
25441
|
-
|
|
25442
|
-
|
|
25443
|
-
|
|
25444
|
-
|
|
25445
|
-
|
|
25446
|
-
return
|
|
25447
|
-
x: x,
|
|
25448
|
-
y: y,
|
|
25449
|
-
vx: 0,
|
|
25450
|
-
vy: vy,
|
|
25451
|
-
dx: dx,
|
|
25452
|
-
dy: dy,
|
|
25453
|
-
ts: ts,
|
|
25454
|
-
width: 0,
|
|
25455
|
-
height: 0,
|
|
25456
|
-
origin: event
|
|
25457
|
-
};
|
|
26673
|
+
this.onNativeKeyDown = function(event) {
|
|
26674
|
+
_this.handleNativeKey(event, true);
|
|
26675
|
+
};
|
|
26676
|
+
this.onNativeKeyUp = function(event) {
|
|
26677
|
+
_this.handleNativeKey(event, false);
|
|
26678
|
+
};
|
|
26679
|
+
this.onNativeMouseDown = function(event) {
|
|
26680
|
+
_this.handleNativeMouseDown(event);
|
|
26681
|
+
};
|
|
26682
|
+
this.onNativeMouseMove = function(event) {
|
|
26683
|
+
var _state;
|
|
26684
|
+
if (!_this.enabled || !_this.target) {
|
|
26685
|
+
return;
|
|
25458
26686
|
}
|
|
25459
|
-
var
|
|
25460
|
-
|
|
25461
|
-
|
|
25462
|
-
|
|
25463
|
-
|
|
25464
|
-
|
|
25465
|
-
|
|
25466
|
-
|
|
25467
|
-
|
|
25468
|
-
|
|
26687
|
+
var position = _this.getCanvasPosition(event.clientX, event.clientY);
|
|
26688
|
+
var _this_mouseState;
|
|
26689
|
+
var state = (_this_mouseState = _this.mouseState) != null ? _this_mouseState : _this.createPointerState(position);
|
|
26690
|
+
_this.mouseState = state;
|
|
26691
|
+
var relative = new Vector2(position.x - state.last.x, position.y - state.last.y);
|
|
26692
|
+
var velocity = _this.getVelocity(state, position);
|
|
26693
|
+
var handled = _this.pushNativeMouseMotion(event, position, relative, velocity);
|
|
26694
|
+
(_state = state).controlHandled || (_state.controlHandled = handled);
|
|
26695
|
+
if (!handled && (!state.pressed || !state.controlHandled)) {
|
|
26696
|
+
var pointerEvent = _this.createPointerEvent(event, position, state, velocity);
|
|
26697
|
+
_this.dispatchEvent(EVENT_TYPE_TOUCH_MOVE, pointerEvent);
|
|
26698
|
+
}
|
|
26699
|
+
_this.updatePointerState(state, position);
|
|
26700
|
+
_this.consumeNativeEvent(event, handled);
|
|
26701
|
+
};
|
|
26702
|
+
this.onNativeMouseUp = function(event) {
|
|
26703
|
+
if (!_this.enabled || !_this.target) {
|
|
26704
|
+
return;
|
|
25469
26705
|
}
|
|
25470
|
-
|
|
25471
|
-
|
|
25472
|
-
|
|
25473
|
-
|
|
25474
|
-
|
|
25475
|
-
|
|
25476
|
-
|
|
25477
|
-
|
|
25478
|
-
|
|
25479
|
-
|
|
25480
|
-
|
|
25481
|
-
|
|
26706
|
+
var position = _this.getCanvasPosition(event.clientX, event.clientY);
|
|
26707
|
+
var existingState = _this.mouseState;
|
|
26708
|
+
if (!(existingState == null ? void 0 : existingState.pressed)) {
|
|
26709
|
+
return;
|
|
26710
|
+
}
|
|
26711
|
+
var state = existingState;
|
|
26712
|
+
var handled = _this.pushNativeMouseButton(event, position, false);
|
|
26713
|
+
var pointerEvent = _this.createPointerEvent(event, position, state);
|
|
26714
|
+
if (!state.controlHandled && !handled && _this.isClick(state, position)) {
|
|
26715
|
+
_this.dispatchEvent(EVENT_TYPE_CLICK, pointerEvent);
|
|
26716
|
+
}
|
|
26717
|
+
if (!handled && !state.controlHandled) {
|
|
26718
|
+
_this.dispatchEvent(EVENT_TYPE_TOUCH_END, pointerEvent);
|
|
26719
|
+
}
|
|
26720
|
+
_this.mouseState = null;
|
|
26721
|
+
_this.consumeNativeEvent(event, handled || state.controlHandled || !_this.allowPropagation);
|
|
25482
26722
|
};
|
|
25483
|
-
|
|
25484
|
-
|
|
25485
|
-
|
|
25486
|
-
|
|
25487
|
-
|
|
25488
|
-
|
|
25489
|
-
|
|
25490
|
-
|
|
25491
|
-
|
|
25492
|
-
|
|
25493
|
-
|
|
25494
|
-
|
|
25495
|
-
|
|
25496
|
-
|
|
25497
|
-
|
|
25498
|
-
|
|
25499
|
-
y = cood.y;
|
|
25500
|
-
lastTouch = currentTouch = {
|
|
25501
|
-
clientX: touch.clientX,
|
|
25502
|
-
clientY: touch.clientY,
|
|
25503
|
-
ts: performance.now(),
|
|
25504
|
-
x: x,
|
|
25505
|
-
y: y
|
|
25506
|
-
};
|
|
25507
|
-
_this.dispatchEvent(EVENT_TYPE_TOUCH_START, getTouchEventValue(event, x, y));
|
|
25508
|
-
}
|
|
25509
|
-
}, _obj[touchmove] = function(event) {
|
|
25510
|
-
if (currentTouch && _this.enabled) {
|
|
25511
|
-
var cood = getCoord(getTouch(event));
|
|
25512
|
-
x = cood.x;
|
|
25513
|
-
y = cood.y;
|
|
25514
|
-
_this.dispatchEvent(EVENT_TYPE_TOUCH_MOVE, getTouchEventValue(event, x, y, x - currentTouch.x, y - currentTouch.y));
|
|
25515
|
-
}
|
|
25516
|
-
}, _obj[touchend] = function(event) {
|
|
25517
|
-
if (currentTouch && _this.enabled) {
|
|
25518
|
-
if (!_this.allowPropagation && event.cancelable) {
|
|
25519
|
-
event.preventDefault();
|
|
25520
|
-
event.stopPropagation();
|
|
26723
|
+
this.onNativeTouchStart = function(event) {
|
|
26724
|
+
if (!_this.enabled) {
|
|
26725
|
+
return;
|
|
26726
|
+
}
|
|
26727
|
+
_this.focusTarget();
|
|
26728
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(Array.from(event.changedTouches)), _step; !(_step = _iterator()).done;){
|
|
26729
|
+
var touch = _step.value;
|
|
26730
|
+
var position = _this.getCanvasPosition(touch.clientX, touch.clientY);
|
|
26731
|
+
var state = _this.createPointerState(position);
|
|
26732
|
+
_this.touchStates.set(touch.identifier, state);
|
|
26733
|
+
state.pressed = true;
|
|
26734
|
+
var handled = _this.pushNativeScreenTouch(touch.identifier, position, true, false, false);
|
|
26735
|
+
state.controlHandled = handled;
|
|
26736
|
+
if (!handled) {
|
|
26737
|
+
var pointerEvent = _this.createPointerEvent(event, position, state);
|
|
26738
|
+
_this.dispatchEvent(EVENT_TYPE_TOUCH_START, pointerEvent);
|
|
25521
26739
|
}
|
|
25522
|
-
|
|
25523
|
-
|
|
25524
|
-
|
|
25525
|
-
|
|
25526
|
-
|
|
25527
|
-
|
|
25528
|
-
|
|
26740
|
+
_this.consumeNativeEvent(event, handled);
|
|
26741
|
+
}
|
|
26742
|
+
_this.preventTouchDefaults(event);
|
|
26743
|
+
};
|
|
26744
|
+
this.onNativeTouchMove = function(event) {
|
|
26745
|
+
if (!_this.enabled) {
|
|
26746
|
+
return;
|
|
26747
|
+
}
|
|
26748
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(Array.from(event.changedTouches)), _step; !(_step = _iterator()).done;){
|
|
26749
|
+
var touch = _step.value;
|
|
26750
|
+
var _state;
|
|
26751
|
+
var position = _this.getCanvasPosition(touch.clientX, touch.clientY);
|
|
26752
|
+
var _this_touchStates_get;
|
|
26753
|
+
var state = (_this_touchStates_get = _this.touchStates.get(touch.identifier)) != null ? _this_touchStates_get : _this.createPointerState(position);
|
|
26754
|
+
_this.touchStates.set(touch.identifier, state);
|
|
26755
|
+
var relative = new Vector2(position.x - state.last.x, position.y - state.last.y);
|
|
26756
|
+
var velocity = _this.getVelocity(state, position);
|
|
26757
|
+
var handled = _this.pushNativeScreenDrag(touch.identifier, position, relative, velocity);
|
|
26758
|
+
(_state = state).controlHandled || (_state.controlHandled = handled);
|
|
26759
|
+
if (!handled && !state.controlHandled) {
|
|
26760
|
+
var pointerEvent = _this.createPointerEvent(event, position, state, velocity);
|
|
26761
|
+
_this.dispatchEvent(EVENT_TYPE_TOUCH_MOVE, pointerEvent);
|
|
25529
26762
|
}
|
|
25530
|
-
_this.
|
|
25531
|
-
|
|
25532
|
-
|
|
25533
|
-
|
|
25534
|
-
|
|
25535
|
-
|
|
25536
|
-
|
|
25537
|
-
|
|
26763
|
+
_this.updatePointerState(state, position);
|
|
26764
|
+
_this.consumeNativeEvent(event, handled);
|
|
26765
|
+
}
|
|
26766
|
+
_this.preventTouchDefaults(event);
|
|
26767
|
+
};
|
|
26768
|
+
this.onNativeTouchEnd = function(event) {
|
|
26769
|
+
_this.handleNativeTouchEnd(event, false);
|
|
26770
|
+
};
|
|
26771
|
+
this.onNativeTouchCancel = function(event) {
|
|
26772
|
+
_this.handleNativeTouchEnd(event, true);
|
|
26773
|
+
};
|
|
26774
|
+
this.onWindowBlur = function() {
|
|
26775
|
+
if (_this.enabled) {
|
|
26776
|
+
_this.mouseState = null;
|
|
26777
|
+
_this.touchStates.clear();
|
|
26778
|
+
_this.mouseFromTouchIndex = null;
|
|
26779
|
+
_this.touchFromMousePressed = false;
|
|
26780
|
+
_this.engine.windowRoot.cancelPointerInput();
|
|
26781
|
+
}
|
|
26782
|
+
};
|
|
26783
|
+
}
|
|
26784
|
+
var _proto = EventSystem.prototype;
|
|
26785
|
+
_proto.bindListeners = function bindListeners(target) {
|
|
26786
|
+
this.unbindListeners();
|
|
26787
|
+
this.target = target;
|
|
26788
|
+
if (!target || typeof window === "undefined") {
|
|
26789
|
+
return;
|
|
26790
|
+
}
|
|
26791
|
+
if (!target.hasAttribute("tabindex")) {
|
|
26792
|
+
target.tabIndex = 0;
|
|
26793
|
+
this.addedTabIndex = true;
|
|
26794
|
+
}
|
|
26795
|
+
if (!target.style.outline) {
|
|
26796
|
+
target.style.outline = "none";
|
|
26797
|
+
this.addedOutlineStyle = true;
|
|
26798
|
+
}
|
|
26799
|
+
this.addNativeHandler(target, "mousedown", this.onNativeMouseDown);
|
|
26800
|
+
// The Window listener runs after the event reaches the host container, so keep a
|
|
26801
|
+
// target listener to preserve notifyTouch/allowPropagation for in-canvas releases.
|
|
26802
|
+
this.addNativeHandler(target, "mouseup", this.onNativeMouseUp);
|
|
26803
|
+
this.addNativeHandler(window, "mouseup", this.onNativeMouseUp);
|
|
26804
|
+
this.addNativeHandler(window, "pointermove", this.onNativeMouseMove);
|
|
26805
|
+
this.addNativeHandler(target, "touchstart", this.onNativeTouchStart, {
|
|
26806
|
+
passive: false
|
|
25538
26807
|
});
|
|
25539
|
-
this.
|
|
25540
|
-
|
|
25541
|
-
|
|
25542
|
-
this.
|
|
26808
|
+
this.addNativeHandler(target, "touchmove", this.onNativeTouchMove, {
|
|
26809
|
+
passive: false
|
|
26810
|
+
});
|
|
26811
|
+
this.addNativeHandler(target, "touchend", this.onNativeTouchEnd, {
|
|
26812
|
+
passive: false
|
|
26813
|
+
});
|
|
26814
|
+
this.addNativeHandler(target, "touchcancel", this.onNativeTouchCancel, {
|
|
26815
|
+
passive: false
|
|
26816
|
+
});
|
|
26817
|
+
this.addNativeHandler(target, "wheel", this.onNativeWheel, {
|
|
26818
|
+
passive: false
|
|
26819
|
+
});
|
|
26820
|
+
this.addNativeHandler(target, "keydown", this.onNativeKeyDown);
|
|
26821
|
+
this.addNativeHandler(target, "keyup", this.onNativeKeyUp);
|
|
26822
|
+
this.addNativeHandler(window, "blur", this.onWindowBlur);
|
|
25543
26823
|
};
|
|
25544
26824
|
_proto.dispatchEvent = function dispatchEvent(type, event) {
|
|
25545
26825
|
var handlers = this.handlers[type];
|
|
25546
|
-
handlers == null ? void 0 : handlers.forEach(function(fn) {
|
|
26826
|
+
handlers == null ? void 0 : handlers.slice().forEach(function(fn) {
|
|
25547
26827
|
return fn(event);
|
|
25548
26828
|
});
|
|
26829
|
+
if (type === EVENT_TYPE_CLICK) {
|
|
26830
|
+
this.onClick(event);
|
|
26831
|
+
} else if (type === EVENT_TYPE_TOUCH_START) {
|
|
26832
|
+
this.onPointerDown(event);
|
|
26833
|
+
} else if (type === EVENT_TYPE_TOUCH_END) {
|
|
26834
|
+
this.onPointerUp(event);
|
|
26835
|
+
} else if (type === EVENT_TYPE_TOUCH_MOVE) {
|
|
26836
|
+
this.onPointerMove(event);
|
|
26837
|
+
}
|
|
25549
26838
|
};
|
|
25550
26839
|
_proto.addEventListener = function addEventListener(type, callback) {
|
|
25551
26840
|
var handlers = this.handlers[type];
|
|
@@ -25563,14 +26852,229 @@ var EventSystem = /*#__PURE__*/ function() {
|
|
|
25563
26852
|
removeItem(handlers, callback);
|
|
25564
26853
|
}
|
|
25565
26854
|
};
|
|
25566
|
-
_proto.
|
|
25567
|
-
|
|
26855
|
+
_proto.dispose = function dispose() {
|
|
26856
|
+
this.engine.windowRoot.cancelPointerInput();
|
|
26857
|
+
this.mouseState = null;
|
|
26858
|
+
this.touchStates.clear();
|
|
26859
|
+
this.mouseFromTouchIndex = null;
|
|
26860
|
+
this.touchFromMousePressed = false;
|
|
26861
|
+
this.handlers = {};
|
|
26862
|
+
this.unbindListeners();
|
|
26863
|
+
this.target = null;
|
|
26864
|
+
};
|
|
26865
|
+
_proto.handleNativeMouseDown = function handleNativeMouseDown(event) {
|
|
26866
|
+
if (!this.enabled || !this.target) {
|
|
26867
|
+
return;
|
|
26868
|
+
}
|
|
26869
|
+
this.focusTarget();
|
|
26870
|
+
var position = this.getCanvasPosition(event.clientX, event.clientY);
|
|
26871
|
+
var state = this.createPointerState(position);
|
|
26872
|
+
this.mouseState = state;
|
|
26873
|
+
state.pressed = true;
|
|
26874
|
+
var handled = this.pushNativeMouseButton(event, position, true);
|
|
26875
|
+
state.controlHandled = handled;
|
|
26876
|
+
if (!handled) {
|
|
26877
|
+
var pointerEvent = this.createPointerEvent(event, position, state);
|
|
26878
|
+
this.dispatchEvent(EVENT_TYPE_TOUCH_START, pointerEvent);
|
|
26879
|
+
}
|
|
26880
|
+
this.consumeNativeEvent(event, handled);
|
|
26881
|
+
};
|
|
26882
|
+
_proto.handleNativeKey = function handleNativeKey(event, pressed) {
|
|
26883
|
+
if (!this.enabled) {
|
|
26884
|
+
return;
|
|
26885
|
+
}
|
|
26886
|
+
var input = new InputEventKey();
|
|
26887
|
+
input.device = InputEvent.deviceIdKeyboard;
|
|
26888
|
+
input.pressed = pressed;
|
|
26889
|
+
input.echo = pressed && event.repeat;
|
|
26890
|
+
input.keycode = event.key;
|
|
26891
|
+
input.physicalKeycode = event.code;
|
|
26892
|
+
input.keyLabel = event.key;
|
|
26893
|
+
input.unicode = getUnicode(event.key);
|
|
26894
|
+
input.location = getKeyLocation(event.location);
|
|
26895
|
+
input.shiftPressed = event.shiftKey;
|
|
26896
|
+
input.altPressed = event.altKey;
|
|
26897
|
+
input.metaPressed = event.metaKey;
|
|
26898
|
+
input.ctrlPressed = event.ctrlKey;
|
|
26899
|
+
this.engine.windowRoot.pushInput(input);
|
|
26900
|
+
this.consumeNativeEvent(event, this.engine.windowRoot.isInputHandled());
|
|
26901
|
+
};
|
|
26902
|
+
_proto.handleNativeTouchEnd = function handleNativeTouchEnd(event, canceled) {
|
|
26903
|
+
if (!this.enabled) {
|
|
26904
|
+
return;
|
|
26905
|
+
}
|
|
26906
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(Array.from(event.changedTouches)), _step; !(_step = _iterator()).done;){
|
|
26907
|
+
var touch = _step.value;
|
|
26908
|
+
var position = this.getCanvasPosition(touch.clientX, touch.clientY);
|
|
26909
|
+
var state = this.touchStates.get(touch.identifier);
|
|
26910
|
+
if (!(state == null ? void 0 : state.pressed)) {
|
|
26911
|
+
continue;
|
|
26912
|
+
}
|
|
26913
|
+
var handled = this.pushNativeScreenTouch(touch.identifier, position, false, canceled, false);
|
|
26914
|
+
var pointerEvent = this.createPointerEvent(event, position, state);
|
|
26915
|
+
if (!canceled && !state.controlHandled && !handled && this.isClick(state, position)) {
|
|
26916
|
+
this.dispatchEvent(EVENT_TYPE_CLICK, pointerEvent);
|
|
26917
|
+
}
|
|
26918
|
+
if (!handled && !canceled && !state.controlHandled) {
|
|
26919
|
+
this.dispatchEvent(EVENT_TYPE_TOUCH_END, pointerEvent);
|
|
26920
|
+
}
|
|
26921
|
+
this.touchStates.delete(touch.identifier);
|
|
26922
|
+
this.consumeNativeEvent(event, handled || state.controlHandled || !this.allowPropagation);
|
|
26923
|
+
}
|
|
26924
|
+
this.preventTouchDefaults(event);
|
|
26925
|
+
};
|
|
26926
|
+
_proto.pushNativeMouseButton = function pushNativeMouseButton(event, position, pressed) {
|
|
26927
|
+
var handled = false;
|
|
26928
|
+
var button = getMouseButton(event.button);
|
|
26929
|
+
if (pressed && this.emulateTouchFromMouse && button === exports.MouseButton.Left) {
|
|
26930
|
+
this.touchFromMousePressed = true;
|
|
26931
|
+
}
|
|
26932
|
+
if (this.touchFromMousePressed && button === exports.MouseButton.Left) {
|
|
26933
|
+
handled = this.pushScreenTouch(0, position, pressed, false, event.detail > 1, InputEvent.deviceIdEmulation);
|
|
26934
|
+
if (!pressed) {
|
|
26935
|
+
this.touchFromMousePressed = false;
|
|
26936
|
+
}
|
|
26937
|
+
}
|
|
26938
|
+
return this.pushMouseButton(event, position, pressed) || handled;
|
|
26939
|
+
};
|
|
26940
|
+
_proto.pushNativeMouseMotion = function pushNativeMouseMotion(event, position, relative, velocity) {
|
|
26941
|
+
var handled = false;
|
|
26942
|
+
if (this.touchFromMousePressed && (event.buttons & 1) !== 0) {
|
|
26943
|
+
handled = this.pushScreenDrag(0, position, relative, velocity, InputEvent.deviceIdEmulation);
|
|
26944
|
+
}
|
|
26945
|
+
return this.pushMouseMotion(event, position, relative, velocity) || handled;
|
|
26946
|
+
};
|
|
26947
|
+
_proto.pushNativeScreenTouch = function pushNativeScreenTouch(index, position, pressed, canceled, doubleTap) {
|
|
26948
|
+
var handled = false;
|
|
26949
|
+
var emulateMouse = false;
|
|
26950
|
+
if (pressed && this.emulateMouseFromTouch && this.mouseFromTouchIndex === null) {
|
|
26951
|
+
this.mouseFromTouchIndex = index;
|
|
26952
|
+
emulateMouse = true;
|
|
26953
|
+
} else if (!pressed && this.mouseFromTouchIndex === index) {
|
|
26954
|
+
emulateMouse = true;
|
|
26955
|
+
this.mouseFromTouchIndex = null;
|
|
26956
|
+
}
|
|
26957
|
+
if (emulateMouse) {
|
|
26958
|
+
handled = this.pushEmulatedMouseButton(position, pressed, canceled, doubleTap);
|
|
26959
|
+
}
|
|
26960
|
+
return this.pushScreenTouch(index, position, pressed, canceled, doubleTap, 0) || handled;
|
|
26961
|
+
};
|
|
26962
|
+
_proto.pushNativeScreenDrag = function pushNativeScreenDrag(index, position, relative, velocity) {
|
|
26963
|
+
var handled = false;
|
|
26964
|
+
if (this.emulateMouseFromTouch && this.mouseFromTouchIndex === index) {
|
|
26965
|
+
handled = this.pushEmulatedMouseMotion(position, relative, velocity);
|
|
26966
|
+
}
|
|
26967
|
+
return this.pushScreenDrag(index, position, relative, velocity, 0) || handled;
|
|
26968
|
+
};
|
|
26969
|
+
_proto.pushEmulatedMouseButton = function pushEmulatedMouseButton(position, pressed, canceled, doubleClick) {
|
|
26970
|
+
var input = new InputEventMouseButton();
|
|
26971
|
+
input.device = InputEvent.deviceIdEmulation;
|
|
26972
|
+
input.position.copyFrom(position);
|
|
26973
|
+
input.globalPosition.copyFrom(position);
|
|
26974
|
+
input.buttonIndex = exports.MouseButton.Left;
|
|
26975
|
+
input.buttonMask = pressed ? exports.MouseButtonMask.Left : exports.MouseButtonMask.None;
|
|
26976
|
+
input.pressed = pressed;
|
|
26977
|
+
input.canceled = canceled;
|
|
26978
|
+
input.doubleClick = doubleClick;
|
|
26979
|
+
this.engine.windowRoot.pushInput(input);
|
|
26980
|
+
return this.engine.windowRoot.isInputHandled();
|
|
26981
|
+
};
|
|
26982
|
+
_proto.pushEmulatedMouseMotion = function pushEmulatedMouseMotion(position, relative, velocity) {
|
|
26983
|
+
var input = new InputEventMouseMotion();
|
|
26984
|
+
input.device = InputEvent.deviceIdEmulation;
|
|
26985
|
+
input.position.copyFrom(position);
|
|
26986
|
+
input.globalPosition.copyFrom(position);
|
|
26987
|
+
input.buttonMask = exports.MouseButtonMask.Left;
|
|
26988
|
+
input.pressed = true;
|
|
26989
|
+
input.relative.copyFrom(relative);
|
|
26990
|
+
input.screenRelative.copyFrom(relative);
|
|
26991
|
+
input.velocity.copyFrom(velocity);
|
|
26992
|
+
input.screenVelocity.copyFrom(velocity);
|
|
26993
|
+
this.engine.windowRoot.pushInput(input);
|
|
26994
|
+
return this.engine.windowRoot.isInputHandled();
|
|
26995
|
+
};
|
|
26996
|
+
_proto.pushMouseButton = function pushMouseButton(event, position, pressed) {
|
|
26997
|
+
var input = new InputEventMouseButton();
|
|
26998
|
+
this.copyMouseFields(input, event, position);
|
|
26999
|
+
input.device = InputEvent.deviceIdMouse;
|
|
27000
|
+
input.buttonIndex = getMouseButton(event.button);
|
|
27001
|
+
input.buttonMask = getMouseButtonMask(event.buttons);
|
|
27002
|
+
if (pressed) {
|
|
27003
|
+
input.buttonMask |= getMouseButtonBit(input.buttonIndex);
|
|
27004
|
+
} else {
|
|
27005
|
+
input.buttonMask &= ~getMouseButtonBit(input.buttonIndex);
|
|
27006
|
+
}
|
|
27007
|
+
input.pressed = pressed;
|
|
27008
|
+
input.doubleClick = event.detail > 1;
|
|
27009
|
+
this.engine.windowRoot.pushInput(input);
|
|
27010
|
+
return this.engine.windowRoot.isInputHandled();
|
|
27011
|
+
};
|
|
27012
|
+
_proto.pushWheelButton = function pushWheelButton(button, factor, position, event) {
|
|
27013
|
+
var input = new InputEventMouseButton();
|
|
27014
|
+
this.copyMouseFields(input, event, position);
|
|
27015
|
+
input.device = InputEvent.deviceIdMouse;
|
|
27016
|
+
input.buttonIndex = button;
|
|
27017
|
+
input.buttonMask = getMouseButtonMask(event.buttons);
|
|
27018
|
+
input.factor = factor;
|
|
27019
|
+
input.pressed = true;
|
|
27020
|
+
this.engine.windowRoot.pushInput(input);
|
|
27021
|
+
return this.engine.windowRoot.isInputHandled();
|
|
27022
|
+
};
|
|
27023
|
+
_proto.pushMouseMotion = function pushMouseMotion(event, position, relative, velocity) {
|
|
27024
|
+
var input = new InputEventMouseMotion();
|
|
27025
|
+
this.copyMouseFields(input, event, position);
|
|
27026
|
+
input.device = InputEvent.deviceIdMouse;
|
|
27027
|
+
input.buttonMask = getMouseButtonMask(event.buttons);
|
|
27028
|
+
input.pressed = event.buttons !== 0;
|
|
27029
|
+
input.relative.copyFrom(relative);
|
|
27030
|
+
input.screenRelative.copyFrom(relative);
|
|
27031
|
+
input.velocity.copyFrom(velocity);
|
|
27032
|
+
input.screenVelocity.copyFrom(velocity);
|
|
27033
|
+
if ("pressure" in event) {
|
|
27034
|
+
input.pressure = event.pressure;
|
|
27035
|
+
input.tilt.set(event.tiltX, event.tiltY);
|
|
27036
|
+
}
|
|
27037
|
+
this.engine.windowRoot.pushInput(input);
|
|
27038
|
+
return this.engine.windowRoot.isInputHandled();
|
|
27039
|
+
};
|
|
27040
|
+
_proto.pushScreenTouch = function pushScreenTouch(index, position, pressed, canceled, doubleTap, device) {
|
|
27041
|
+
var input = new InputEventScreenTouch();
|
|
27042
|
+
input.index = index;
|
|
27043
|
+
input.device = device;
|
|
27044
|
+
input.position.copyFrom(position);
|
|
27045
|
+
input.pressed = pressed;
|
|
27046
|
+
input.canceled = canceled;
|
|
27047
|
+
input.doubleTap = doubleTap;
|
|
27048
|
+
this.engine.windowRoot.pushInput(input);
|
|
27049
|
+
return this.engine.windowRoot.isInputHandled();
|
|
27050
|
+
};
|
|
27051
|
+
_proto.pushScreenDrag = function pushScreenDrag(index, position, relative, velocity, device) {
|
|
27052
|
+
var input = new InputEventScreenDrag();
|
|
27053
|
+
input.index = index;
|
|
27054
|
+
input.device = device;
|
|
27055
|
+
input.position.copyFrom(position);
|
|
27056
|
+
input.relative.copyFrom(relative);
|
|
27057
|
+
input.screenRelative.copyFrom(relative);
|
|
27058
|
+
input.velocity.copyFrom(velocity);
|
|
27059
|
+
input.screenVelocity.copyFrom(velocity);
|
|
27060
|
+
input.pressed = true;
|
|
27061
|
+
this.engine.windowRoot.pushInput(input);
|
|
27062
|
+
return this.engine.windowRoot.isInputHandled();
|
|
27063
|
+
};
|
|
27064
|
+
_proto.copyMouseFields = function copyMouseFields(input, event, position) {
|
|
27065
|
+
input.position.copyFrom(position);
|
|
27066
|
+
input.globalPosition.copyFrom(position);
|
|
27067
|
+
input.shiftPressed = event.shiftKey;
|
|
27068
|
+
input.altPressed = event.altKey;
|
|
27069
|
+
input.metaPressed = event.metaKey;
|
|
27070
|
+
input.ctrlPressed = event.ctrlKey;
|
|
27071
|
+
};
|
|
27072
|
+
_proto.onClick = function onClick(event) {
|
|
25568
27073
|
var hitResults = [];
|
|
25569
|
-
// 收集所有的点击测试结果,click 回调执行可能会对 composition 点击结果有影响,放在点击测试执行完后再统一触发。
|
|
25570
27074
|
for(var _iterator = _create_for_of_iterator_helper_loose(this.engine.compositions), _step; !(_step = _iterator()).done;){
|
|
25571
27075
|
var composition = _step.value;
|
|
25572
27076
|
var _hitResults;
|
|
25573
|
-
(_hitResults = hitResults).push.apply(_hitResults, [].concat(composition.hitTest(x, y)));
|
|
27077
|
+
(_hitResults = hitResults).push.apply(_hitResults, [].concat(composition.hitTest(event.x, event.y)));
|
|
25574
27078
|
}
|
|
25575
27079
|
for(var _iterator1 = _create_for_of_iterator_helper_loose(hitResults), _step1; !(_step1 = _iterator1()).done;){
|
|
25576
27080
|
var hitResult = _step1.value;
|
|
@@ -25587,49 +27091,36 @@ var EventSystem = /*#__PURE__*/ function() {
|
|
|
25587
27091
|
this.engine.emit("click", clickInfo);
|
|
25588
27092
|
}
|
|
25589
27093
|
};
|
|
25590
|
-
_proto.onPointerDown = function onPointerDown(
|
|
25591
|
-
this.handlePointerEvent(
|
|
27094
|
+
_proto.onPointerDown = function onPointerDown(event) {
|
|
27095
|
+
this.handlePointerEvent(event, 0);
|
|
25592
27096
|
};
|
|
25593
|
-
_proto.onPointerUp = function onPointerUp(
|
|
25594
|
-
this.handlePointerEvent(
|
|
27097
|
+
_proto.onPointerUp = function onPointerUp(event) {
|
|
27098
|
+
this.handlePointerEvent(event, 1);
|
|
25595
27099
|
};
|
|
25596
|
-
_proto.onPointerMove = function onPointerMove(
|
|
25597
|
-
this.handlePointerEvent(
|
|
27100
|
+
_proto.onPointerMove = function onPointerMove(event) {
|
|
27101
|
+
this.handlePointerEvent(event, 2);
|
|
25598
27102
|
};
|
|
25599
|
-
_proto.handlePointerEvent = function handlePointerEvent(
|
|
27103
|
+
_proto.handlePointerEvent = function handlePointerEvent(event, type) {
|
|
25600
27104
|
var hitRegion = null;
|
|
25601
|
-
var x = e.x, y = e.y, width = e.width, height = e.height;
|
|
25602
27105
|
if (!(type === 2 && this.skipPointerMovePicking)) {
|
|
25603
27106
|
for(var _iterator = _create_for_of_iterator_helper_loose(this.engine.compositions), _step; !(_step = _iterator()).done;){
|
|
25604
27107
|
var composition = _step.value;
|
|
25605
|
-
var regions = composition.hitTest(x, y);
|
|
27108
|
+
var regions = composition.hitTest(event.x, event.y);
|
|
25606
27109
|
if (regions.length > 0) {
|
|
25607
27110
|
hitRegion = regions[regions.length - 1];
|
|
25608
27111
|
}
|
|
25609
27112
|
}
|
|
25610
27113
|
}
|
|
25611
27114
|
var eventData = new PointerEventData();
|
|
25612
|
-
eventData.position.x = (x + 1) / 2 * width;
|
|
25613
|
-
eventData.position.y = (y + 1) / 2 * height;
|
|
25614
|
-
eventData.delta.x =
|
|
25615
|
-
eventData.delta.y =
|
|
25616
|
-
var raycast = eventData.pointerCurrentRaycast;
|
|
27115
|
+
eventData.position.x = (event.x + 1) / 2 * event.width;
|
|
27116
|
+
eventData.position.y = (event.y + 1) / 2 * event.height;
|
|
27117
|
+
eventData.delta.x = event.vx * event.width;
|
|
27118
|
+
eventData.delta.y = event.vy * event.height;
|
|
25617
27119
|
if (hitRegion) {
|
|
25618
|
-
|
|
25619
|
-
|
|
25620
|
-
}
|
|
25621
|
-
var eventName = "pointerdown";
|
|
25622
|
-
switch(type){
|
|
25623
|
-
case 0:
|
|
25624
|
-
eventName = "pointerdown";
|
|
25625
|
-
break;
|
|
25626
|
-
case 1:
|
|
25627
|
-
eventName = "pointerup";
|
|
25628
|
-
break;
|
|
25629
|
-
case 2:
|
|
25630
|
-
eventName = "pointermove";
|
|
25631
|
-
break;
|
|
27120
|
+
eventData.pointerCurrentRaycast.point = hitRegion.position;
|
|
27121
|
+
eventData.pointerCurrentRaycast.item = hitRegion.item;
|
|
25632
27122
|
}
|
|
27123
|
+
var eventName = type === 0 ? "pointerdown" : type === 1 ? "pointerup" : "pointermove";
|
|
25633
27124
|
if (hitRegion) {
|
|
25634
27125
|
var hitItem = hitRegion.item;
|
|
25635
27126
|
var hitComposition = hitItem.composition;
|
|
@@ -25638,29 +27129,184 @@ var EventSystem = /*#__PURE__*/ function() {
|
|
|
25638
27129
|
this.engine.emit(eventName, eventData);
|
|
25639
27130
|
}
|
|
25640
27131
|
};
|
|
25641
|
-
_proto.
|
|
25642
|
-
var
|
|
25643
|
-
|
|
25644
|
-
|
|
25645
|
-
|
|
25646
|
-
|
|
25647
|
-
|
|
25648
|
-
|
|
25649
|
-
|
|
27132
|
+
_proto.createPointerState = function createPointerState(position) {
|
|
27133
|
+
var state = {
|
|
27134
|
+
start: position.clone(),
|
|
27135
|
+
last: position.clone(),
|
|
27136
|
+
lastTime: performance.now(),
|
|
27137
|
+
controlHandled: false,
|
|
27138
|
+
pressed: false
|
|
27139
|
+
};
|
|
27140
|
+
return state;
|
|
27141
|
+
};
|
|
27142
|
+
_proto.updatePointerState = function updatePointerState(state, position) {
|
|
27143
|
+
state.last.copyFrom(position);
|
|
27144
|
+
state.lastTime = performance.now();
|
|
27145
|
+
};
|
|
27146
|
+
_proto.getVelocity = function getVelocity(state, position) {
|
|
27147
|
+
var elapsed = Math.max(performance.now() - state.lastTime, 1);
|
|
27148
|
+
return new Vector2((position.x - state.last.x) / elapsed, (position.y - state.last.y) / elapsed);
|
|
27149
|
+
};
|
|
27150
|
+
_proto.isClick = function isClick(state, position) {
|
|
27151
|
+
return Math.abs(position.x - state.start.x) + Math.abs(position.y - state.start.y) < 4;
|
|
27152
|
+
};
|
|
27153
|
+
_proto.createPointerEvent = function createPointerEvent(origin, position, state, velocity) {
|
|
27154
|
+
if (velocity === void 0) velocity = new Vector2();
|
|
27155
|
+
var target = this.target;
|
|
27156
|
+
var rect = target == null ? void 0 : target.getBoundingClientRect();
|
|
27157
|
+
var cssWidth = (rect == null ? void 0 : rect.width) || 1;
|
|
27158
|
+
var cssHeight = (rect == null ? void 0 : rect.height) || 1;
|
|
27159
|
+
var _target_width, _target_height;
|
|
27160
|
+
return {
|
|
27161
|
+
x: position.x / cssWidth * 2 - 1,
|
|
27162
|
+
y: position.y / cssHeight * 2 - 1,
|
|
27163
|
+
vx: velocity.x / cssWidth * 2,
|
|
27164
|
+
vy: velocity.y / cssHeight * 2,
|
|
27165
|
+
ts: performance.now(),
|
|
27166
|
+
dx: (position.x - state.start.x) / cssWidth * 2,
|
|
27167
|
+
dy: (position.y - state.start.y) / cssHeight * 2,
|
|
27168
|
+
width: (_target_width = target == null ? void 0 : target.width) != null ? _target_width : 0,
|
|
27169
|
+
height: (_target_height = target == null ? void 0 : target.height) != null ? _target_height : 0,
|
|
27170
|
+
origin: origin
|
|
27171
|
+
};
|
|
27172
|
+
};
|
|
27173
|
+
_proto.getCanvasPosition = function getCanvasPosition(clientX, clientY) {
|
|
27174
|
+
var _this_target;
|
|
27175
|
+
var rect = (_this_target = this.target) == null ? void 0 : _this_target.getBoundingClientRect();
|
|
27176
|
+
if (!rect) {
|
|
27177
|
+
return new Vector2();
|
|
27178
|
+
}
|
|
27179
|
+
return new Vector2(clientX - rect.left, rect.bottom - clientY);
|
|
27180
|
+
};
|
|
27181
|
+
_proto.consumeNativeEvent = function consumeNativeEvent(event, handled) {
|
|
27182
|
+
if (handled && !this.allowPropagation) {
|
|
27183
|
+
if (event.cancelable) {
|
|
27184
|
+
event.preventDefault();
|
|
27185
|
+
}
|
|
27186
|
+
event.stopPropagation();
|
|
27187
|
+
}
|
|
27188
|
+
};
|
|
27189
|
+
_proto.preventTouchDefaults = function preventTouchDefaults(event) {
|
|
27190
|
+
if (event.cancelable) {
|
|
27191
|
+
event.preventDefault();
|
|
25650
27192
|
}
|
|
25651
27193
|
};
|
|
27194
|
+
_proto.focusTarget = function focusTarget() {
|
|
27195
|
+
if (this.target && document.activeElement !== this.target) {
|
|
27196
|
+
this.target.focus();
|
|
27197
|
+
}
|
|
27198
|
+
};
|
|
27199
|
+
_proto.addNativeHandler = function addNativeHandler(target, name, handler, options) {
|
|
27200
|
+
target.addEventListener(name, handler, options);
|
|
27201
|
+
this.nativeHandlers.push({
|
|
27202
|
+
target: target,
|
|
27203
|
+
name: name,
|
|
27204
|
+
handler: handler,
|
|
27205
|
+
options: options
|
|
27206
|
+
});
|
|
27207
|
+
};
|
|
27208
|
+
_proto.unbindListeners = function unbindListeners() {
|
|
27209
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(this.nativeHandlers), _step; !(_step = _iterator()).done;){
|
|
27210
|
+
var nativeHandler = _step.value;
|
|
27211
|
+
nativeHandler.target.removeEventListener(nativeHandler.name, nativeHandler.handler, nativeHandler.options);
|
|
27212
|
+
}
|
|
27213
|
+
this.nativeHandlers = [];
|
|
27214
|
+
if (this.addedTabIndex && this.target) {
|
|
27215
|
+
this.target.removeAttribute("tabindex");
|
|
27216
|
+
}
|
|
27217
|
+
if (this.addedOutlineStyle && this.target) {
|
|
27218
|
+
this.target.style.removeProperty("outline");
|
|
27219
|
+
}
|
|
27220
|
+
this.addedTabIndex = false;
|
|
27221
|
+
this.addedOutlineStyle = false;
|
|
27222
|
+
};
|
|
27223
|
+
_create_class(EventSystem, [
|
|
27224
|
+
{
|
|
27225
|
+
key: "enabled",
|
|
27226
|
+
get: function get() {
|
|
27227
|
+
return this._enabled;
|
|
27228
|
+
},
|
|
27229
|
+
set: function set(value) {
|
|
27230
|
+
if (this._enabled === value) {
|
|
27231
|
+
return;
|
|
27232
|
+
}
|
|
27233
|
+
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
|
+
}
|
|
27242
|
+
}
|
|
27243
|
+
]);
|
|
25652
27244
|
return EventSystem;
|
|
25653
27245
|
}();
|
|
25654
|
-
function
|
|
25655
|
-
|
|
25656
|
-
|
|
25657
|
-
|
|
25658
|
-
|
|
25659
|
-
|
|
25660
|
-
|
|
25661
|
-
|
|
25662
|
-
|
|
25663
|
-
|
|
27246
|
+
function getKeyLocation(location) {
|
|
27247
|
+
if (location === 1) {
|
|
27248
|
+
return exports.KeyLocation.Left;
|
|
27249
|
+
}
|
|
27250
|
+
if (location === 2) {
|
|
27251
|
+
return exports.KeyLocation.Right;
|
|
27252
|
+
}
|
|
27253
|
+
return exports.KeyLocation.Unspecified;
|
|
27254
|
+
}
|
|
27255
|
+
function getUnicode(key) {
|
|
27256
|
+
var characters = Array.from(key);
|
|
27257
|
+
var _characters__codePointAt;
|
|
27258
|
+
return characters.length === 1 ? (_characters__codePointAt = characters[0].codePointAt(0)) != null ? _characters__codePointAt : 0 : 0;
|
|
27259
|
+
}
|
|
27260
|
+
function getMouseButton(button) {
|
|
27261
|
+
switch(button){
|
|
27262
|
+
case 0:
|
|
27263
|
+
return exports.MouseButton.Left;
|
|
27264
|
+
case 1:
|
|
27265
|
+
return exports.MouseButton.Middle;
|
|
27266
|
+
case 2:
|
|
27267
|
+
return exports.MouseButton.Right;
|
|
27268
|
+
case 3:
|
|
27269
|
+
return exports.MouseButton.Xbutton1;
|
|
27270
|
+
case 4:
|
|
27271
|
+
return exports.MouseButton.Xbutton2;
|
|
27272
|
+
default:
|
|
27273
|
+
return exports.MouseButton.None;
|
|
27274
|
+
}
|
|
27275
|
+
}
|
|
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
|
+
function getMouseButtonBit(button) {
|
|
27296
|
+
switch(button){
|
|
27297
|
+
case exports.MouseButton.Left:
|
|
27298
|
+
return exports.MouseButtonMask.Left;
|
|
27299
|
+
case exports.MouseButton.Right:
|
|
27300
|
+
return exports.MouseButtonMask.Right;
|
|
27301
|
+
case exports.MouseButton.Middle:
|
|
27302
|
+
return exports.MouseButtonMask.Middle;
|
|
27303
|
+
case exports.MouseButton.Xbutton1:
|
|
27304
|
+
return exports.MouseButtonMask.Xbutton1;
|
|
27305
|
+
case exports.MouseButton.Xbutton2:
|
|
27306
|
+
return exports.MouseButtonMask.Xbutton2;
|
|
27307
|
+
default:
|
|
27308
|
+
return exports.MouseButtonMask.None;
|
|
27309
|
+
}
|
|
25664
27310
|
}
|
|
25665
27311
|
|
|
25666
27312
|
var InteractLoader = /*#__PURE__*/ function(Plugin) {
|
|
@@ -27681,11 +29327,6 @@ exports.SpritePropertyTrack = __decorate([
|
|
|
27681
29327
|
effectsClass("SpritePropertyTrack")
|
|
27682
29328
|
], exports.SpritePropertyTrack);
|
|
27683
29329
|
|
|
27684
|
-
function _assert_this_initialized(self) {
|
|
27685
|
-
if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
27686
|
-
return self;
|
|
27687
|
-
}
|
|
27688
|
-
|
|
27689
29330
|
var Cone = /*#__PURE__*/ function() {
|
|
27690
29331
|
function Cone(props) {
|
|
27691
29332
|
var _this = this;
|
|
@@ -37690,7 +39331,7 @@ function getStandardSpriteContent(sprite, transform) {
|
|
|
37690
39331
|
return ret;
|
|
37691
39332
|
}
|
|
37692
39333
|
|
|
37693
|
-
var version$1 = "2.10.0-alpha.
|
|
39334
|
+
var version$1 = "2.10.0-alpha.3";
|
|
37694
39335
|
var v0 = /^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/;
|
|
37695
39336
|
var standardVersion = /^(\d+)\.(\d+)$/;
|
|
37696
39337
|
var reverseParticle = false;
|
|
@@ -39642,10 +41283,11 @@ var PreRenderTickData = /*#__PURE__*/ function(TickData) {
|
|
|
39642
41283
|
_this./**
|
|
39643
41284
|
* 是否开启后处理
|
|
39644
41285
|
*/ postProcessingEnabled = false;
|
|
39645
|
-
_this.canvasLayers = [];
|
|
39646
41286
|
_this.destroyed = false;
|
|
39647
41287
|
_this.paused = true;
|
|
39648
41288
|
_this.isEndCalled = false;
|
|
41289
|
+
_this._renderOrder = 0;
|
|
41290
|
+
_this._interactive = true;
|
|
39649
41291
|
_this._textures = [];
|
|
39650
41292
|
var _ref = props != null ? props : {}, _ref_reusable = _ref.reusable, reusable = _ref_reusable === void 0 ? false : _ref_reusable, _ref_speed = _ref.speed, speed = _ref_speed === void 0 ? 1 : _ref_speed, _ref_baseRenderOrder = _ref.baseRenderOrder, baseRenderOrder = _ref_baseRenderOrder === void 0 ? 0 : _ref_baseRenderOrder, onItemMessage = _ref.onItemMessage;
|
|
39651
41293
|
_this.engine.addComposition(_assert_this_initialized(_this));
|
|
@@ -39678,13 +41320,14 @@ var PreRenderTickData = /*#__PURE__*/ function(TickData) {
|
|
|
39678
41320
|
_this.root = new exports.VFXItem(_this.engine);
|
|
39679
41321
|
_this.root.name = "root";
|
|
39680
41322
|
_this.root.composition = _assert_this_initialized(_this);
|
|
41323
|
+
_this.root.setParent(_this.engine.root);
|
|
39681
41324
|
_this.pluginRoot = new exports.VFXItem(_this.engine);
|
|
39682
41325
|
_this.pluginRoot.name = "pluginRoot";
|
|
39683
41326
|
_this.pluginRoot.setParent(_this.root);
|
|
39684
|
-
_this.pluginRoot.addComponent(CanvasLayer);
|
|
39685
41327
|
// Instantiate composition rootItem
|
|
39686
41328
|
_this.sceneRoot = new exports.VFXItem(_this.engine);
|
|
39687
41329
|
_this.sceneRoot.setParent(_this.root);
|
|
41330
|
+
_this.uiCanvas = _this.sceneRoot.addComponent(UICanvas);
|
|
39688
41331
|
if (sourceContent) {
|
|
39689
41332
|
_this.sceneRoot.setInstanceId(sourceContent.id);
|
|
39690
41333
|
_this.sceneRoot.instantiatePreComposition(sourceContent, false);
|
|
@@ -39883,9 +41526,13 @@ var PreRenderTickData = /*#__PURE__*/ function(TickData) {
|
|
|
39883
41526
|
this.isEndCalled = false;
|
|
39884
41527
|
this.rootComposition.setTime(0);
|
|
39885
41528
|
};
|
|
39886
|
-
_proto.render = function render() {
|
|
41529
|
+
/** Renders this Composition content. Screen-space UI is rendered by Engine. */ _proto.render = function render() {
|
|
41530
|
+
this.renderContent();
|
|
41531
|
+
};
|
|
41532
|
+
/**
|
|
41533
|
+
* Renders only the Composition scene content.
|
|
41534
|
+
*/ _proto.renderContent = function renderContent() {
|
|
39887
41535
|
this.renderer.renderRenderFrame(this.renderFrame);
|
|
39888
|
-
this.renderCanvasLayers();
|
|
39889
41536
|
};
|
|
39890
41537
|
/**
|
|
39891
41538
|
* 合成更新,针对所有 item 的更新
|
|
@@ -39974,17 +41621,6 @@ var PreRenderTickData = /*#__PURE__*/ function(TickData) {
|
|
|
39974
41621
|
}
|
|
39975
41622
|
}
|
|
39976
41623
|
};
|
|
39977
|
-
_proto.renderCanvasLayers = function renderCanvasLayers() {
|
|
39978
|
-
this.engine.graphics.begin();
|
|
39979
|
-
this.canvasLayers.sort(function(leftLayer, rightLayer) {
|
|
39980
|
-
return leftLayer.layer - rightLayer.layer;
|
|
39981
|
-
});
|
|
39982
|
-
for(var _iterator = _create_for_of_iterator_helper_loose(this.canvasLayers), _step; !(_step = _iterator()).done;){
|
|
39983
|
-
var canvasLayer = _step.value;
|
|
39984
|
-
canvasLayer.draw();
|
|
39985
|
-
}
|
|
39986
|
-
this.engine.graphics.end();
|
|
39987
|
-
};
|
|
39988
41624
|
/**
|
|
39989
41625
|
* @internal
|
|
39990
41626
|
*/ _proto.createTexturesFromData = function createTexturesFromData(textureDataList) {
|
|
@@ -40253,6 +41889,35 @@ var PreRenderTickData = /*#__PURE__*/ function(TickData) {
|
|
|
40253
41889
|
})();
|
|
40254
41890
|
};
|
|
40255
41891
|
_create_class(Composition, [
|
|
41892
|
+
{
|
|
41893
|
+
key: "renderOrder",
|
|
41894
|
+
get: /**
|
|
41895
|
+
* 合成渲染顺序,默认按升序渲染
|
|
41896
|
+
*/ function get() {
|
|
41897
|
+
return this._renderOrder;
|
|
41898
|
+
},
|
|
41899
|
+
set: function set(value) {
|
|
41900
|
+
this._renderOrder = value;
|
|
41901
|
+
if (this.uiCanvas) {
|
|
41902
|
+
this.uiCanvas.order = value;
|
|
41903
|
+
}
|
|
41904
|
+
}
|
|
41905
|
+
},
|
|
41906
|
+
{
|
|
41907
|
+
key: "interactive",
|
|
41908
|
+
get: /**
|
|
41909
|
+
* 合成内的元素否允许点击、拖拽交互
|
|
41910
|
+
* @since 1.6.0
|
|
41911
|
+
*/ function get() {
|
|
41912
|
+
return this._interactive;
|
|
41913
|
+
},
|
|
41914
|
+
set: function set(value) {
|
|
41915
|
+
this._interactive = !!value;
|
|
41916
|
+
if (this.uiCanvas) {
|
|
41917
|
+
this.uiCanvas.receivesEvents = this._interactive;
|
|
41918
|
+
}
|
|
41919
|
+
}
|
|
41920
|
+
},
|
|
40256
41921
|
{
|
|
40257
41922
|
key: "width",
|
|
40258
41923
|
get: /**
|
|
@@ -42030,7 +43695,6 @@ var DEFAULT_FPS = 60;
|
|
|
42030
43695
|
/**
|
|
42031
43696
|
* 渲染过程中错误队列
|
|
42032
43697
|
*/ _this.renderErrors = new Set();
|
|
42033
|
-
_this.compositions = [];
|
|
42034
43698
|
_this.assetManagers = [];
|
|
42035
43699
|
_this.env = "";
|
|
42036
43700
|
/**
|
|
@@ -42052,6 +43716,7 @@ var DEFAULT_FPS = 60;
|
|
|
42052
43716
|
_this.framebuffers = [];
|
|
42053
43717
|
_this.renderbuffers = [];
|
|
42054
43718
|
_this.particleSystems = [];
|
|
43719
|
+
_this._compositions = [];
|
|
42055
43720
|
_this.clearAction = {
|
|
42056
43721
|
stencilAction: exports.TextureLoadAction.clear,
|
|
42057
43722
|
clearStencil: 0,
|
|
@@ -42076,6 +43741,9 @@ var DEFAULT_FPS = 60;
|
|
|
42076
43741
|
_this.pixelRatio = (_options_pixelRatio = options == null ? void 0 : options.pixelRatio) != null ? _options_pixelRatio : getPixelRatio();
|
|
42077
43742
|
_this.jsonSceneData = {};
|
|
42078
43743
|
_this.objectInstance = {};
|
|
43744
|
+
_this.root = new exports.VFXItem(_assert_this_initialized(_this));
|
|
43745
|
+
_this.root.name = "root";
|
|
43746
|
+
_this.windowRoot = new WindowRootControl(_assert_this_initialized(_this));
|
|
42079
43747
|
_this.whiteTexture = generateWhiteTexture(_assert_this_initialized(_this));
|
|
42080
43748
|
_this.transparentTexture = generateEmptyTexture(_assert_this_initialized(_this));
|
|
42081
43749
|
if (!(options == null ? void 0 : options.manualRender)) {
|
|
@@ -42210,9 +43878,6 @@ var DEFAULT_FPS = 60;
|
|
|
42210
43878
|
// Sort compositions by index
|
|
42211
43879
|
//-------------------------------------------------------------------------
|
|
42212
43880
|
var compositions = this.compositions;
|
|
42213
|
-
compositions.sort(function(a, b) {
|
|
42214
|
-
return a.getIndex() - b.getIndex();
|
|
42215
|
-
});
|
|
42216
43881
|
var skipRender = false;
|
|
42217
43882
|
// Update Compositions
|
|
42218
43883
|
//-------------------------------------------------------------------------
|
|
@@ -42231,6 +43896,7 @@ var DEFAULT_FPS = 60;
|
|
|
42231
43896
|
(_this_ticker1 = this.ticker) == null ? void 0 : _this_ticker1.pause();
|
|
42232
43897
|
return;
|
|
42233
43898
|
}
|
|
43899
|
+
this.windowRoot.update(dt);
|
|
42234
43900
|
// Tick compositions onPreRender
|
|
42235
43901
|
//-------------------------------------------------------------------------
|
|
42236
43902
|
for(var _iterator1 = _create_for_of_iterator_helper_loose(compositions), _step1; !(_step1 = _iterator1()).done;){
|
|
@@ -42243,8 +43909,9 @@ var DEFAULT_FPS = 60;
|
|
|
42243
43909
|
this.renderer.clear(this.clearAction);
|
|
42244
43910
|
for(var _iterator2 = _create_for_of_iterator_helper_loose(compositions), _step2; !(_step2 = _iterator2()).done;){
|
|
42245
43911
|
var composition2 = _step2.value;
|
|
42246
|
-
composition2.
|
|
43912
|
+
composition2.renderContent();
|
|
42247
43913
|
}
|
|
43914
|
+
this.windowRoot.render();
|
|
42248
43915
|
this.renderTargetPool.flush();
|
|
42249
43916
|
};
|
|
42250
43917
|
/**
|
|
@@ -42286,6 +43953,7 @@ var DEFAULT_FPS = 60;
|
|
|
42286
43953
|
this.canvas.style.height = containerHeight + "px";
|
|
42287
43954
|
logger.info("Resize engine " + this.name + " [" + canvasWidth + "," + canvasHeight + "," + containerWidth + "," + containerHeight + "].");
|
|
42288
43955
|
this.setSize(canvasWidth, canvasHeight);
|
|
43956
|
+
this.windowRoot.resize(canvasWidth, canvasHeight);
|
|
42289
43957
|
}
|
|
42290
43958
|
};
|
|
42291
43959
|
_proto.setSize = function setSize(width, height) {
|
|
@@ -42293,7 +43961,7 @@ var DEFAULT_FPS = 60;
|
|
|
42293
43961
|
if (this.getWidth() !== width || this.getHeight() !== height) {
|
|
42294
43962
|
this.canvas.width = width;
|
|
42295
43963
|
this.canvas.height = height;
|
|
42296
|
-
this.
|
|
43964
|
+
this.setViewport(0, 0, width, height);
|
|
42297
43965
|
}
|
|
42298
43966
|
(_this_compositions = this.compositions) == null ? void 0 : _this_compositions.forEach(function(comp) {
|
|
42299
43967
|
comp.camera.aspect = width / height;
|
|
@@ -42322,6 +43990,26 @@ var DEFAULT_FPS = 60;
|
|
|
42322
43990
|
/** @hide */ _proto.bindBuffers = function bindBuffers(vertexBuffers, indexBuffer, effect) {
|
|
42323
43991
|
throw new Error("The active rendering backend cannot bind geometry buffers.");
|
|
42324
43992
|
};
|
|
43993
|
+
/**
|
|
43994
|
+
* 使用当前绑定的顶点和索引缓冲区绘制图元。
|
|
43995
|
+
* @param mode - 图元类型
|
|
43996
|
+
* @param indexOffset - 索引缓冲区中的字节偏移
|
|
43997
|
+
* @param indexCount - 索引数量
|
|
43998
|
+
* @param instanceCount - 实例数量
|
|
43999
|
+
* @hide
|
|
44000
|
+
*/ _proto.drawElementsType = function drawElementsType(mode, indexOffset, indexCount, instanceCount) {
|
|
44001
|
+
throw new Error("The active rendering backend cannot draw indexed primitives.");
|
|
44002
|
+
};
|
|
44003
|
+
/**
|
|
44004
|
+
* 使用当前绑定的顶点缓冲区绘制图元。
|
|
44005
|
+
* @param mode - 图元类型
|
|
44006
|
+
* @param vertexStart - 起始顶点
|
|
44007
|
+
* @param vertexCount - 顶点数量
|
|
44008
|
+
* @param instanceCount - 实例数量
|
|
44009
|
+
* @hide
|
|
44010
|
+
*/ _proto.drawArraysType = function drawArraysType(mode, vertexStart, vertexCount, instanceCount) {
|
|
44011
|
+
throw new Error("The active rendering backend cannot draw primitives.");
|
|
44012
|
+
};
|
|
42325
44013
|
_proto.addTexture = function addTexture(tex) {
|
|
42326
44014
|
if (this.disposed) {
|
|
42327
44015
|
return;
|
|
@@ -42453,15 +44141,12 @@ var DEFAULT_FPS = 60;
|
|
|
42453
44141
|
* @param height
|
|
42454
44142
|
* example:
|
|
42455
44143
|
* gl.viewport(0, 0, width, height);
|
|
42456
|
-
*/ _proto.
|
|
44144
|
+
*/ _proto.setViewport = function setViewport(x, y, width, height) {
|
|
42457
44145
|
// OVERRIDE
|
|
42458
44146
|
};
|
|
42459
44147
|
_proto.clear = function clear(action) {
|
|
42460
44148
|
// OVERRIDE
|
|
42461
44149
|
};
|
|
42462
|
-
_proto.drawGeometry = function drawGeometry(geometry, matrix, material, subMeshIndex) {
|
|
42463
|
-
// OVERRIDE
|
|
42464
|
-
};
|
|
42465
44150
|
/*** 渲染状态控制 ***/ _proto.setSampleAlphaToCoverage = function setSampleAlphaToCoverage(enable) {
|
|
42466
44151
|
// OVERRIDE
|
|
42467
44152
|
};
|
|
@@ -42546,6 +44231,12 @@ var DEFAULT_FPS = 60;
|
|
|
42546
44231
|
}
|
|
42547
44232
|
(_this_ticker = this.ticker) == null ? void 0 : _this_ticker.stop();
|
|
42548
44233
|
(_this_eventSystem = this.eventSystem) == null ? void 0 : _this_eventSystem.dispose();
|
|
44234
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(this._compositions.slice()), _step; !(_step = _iterator()).done;){
|
|
44235
|
+
var composition = _step.value;
|
|
44236
|
+
composition.dispose();
|
|
44237
|
+
}
|
|
44238
|
+
this.root.dispose();
|
|
44239
|
+
this.windowRoot.dispose();
|
|
42549
44240
|
(_this_assetService = this.assetService) == null ? void 0 : _this_assetService.dispose();
|
|
42550
44241
|
(_this__graphics = this._graphics) == null ? void 0 : _this__graphics.dispose();
|
|
42551
44242
|
this.renderPasses.forEach(function(pass) {
|
|
@@ -42566,16 +44257,13 @@ var DEFAULT_FPS = 60;
|
|
|
42566
44257
|
this.assetManagers.forEach(function(assetManager) {
|
|
42567
44258
|
return assetManager.dispose();
|
|
42568
44259
|
});
|
|
42569
|
-
this.compositions.forEach(function(comp) {
|
|
42570
|
-
return comp.dispose();
|
|
42571
|
-
});
|
|
42572
44260
|
this.textures = [];
|
|
42573
44261
|
this.materials = [];
|
|
42574
44262
|
this.geometries = [];
|
|
42575
44263
|
this.meshes = [];
|
|
42576
44264
|
this.renderPasses = [];
|
|
42577
|
-
this.compositions = [];
|
|
42578
44265
|
this.particleSystems = [];
|
|
44266
|
+
this._compositions = [];
|
|
42579
44267
|
};
|
|
42580
44268
|
_proto.getTargetSize = function getTargetSize(parentEle) {
|
|
42581
44269
|
if (parentEle === undefined || parentEle === null) {
|
|
@@ -42628,6 +44316,14 @@ var DEFAULT_FPS = 60;
|
|
|
42628
44316
|
];
|
|
42629
44317
|
};
|
|
42630
44318
|
_create_class(Engine, [
|
|
44319
|
+
{
|
|
44320
|
+
key: "compositions",
|
|
44321
|
+
get: function get() {
|
|
44322
|
+
return this._compositions.sort(function(a, b) {
|
|
44323
|
+
return a.getIndex() - b.getIndex();
|
|
44324
|
+
});
|
|
44325
|
+
}
|
|
44326
|
+
},
|
|
42631
44327
|
{
|
|
42632
44328
|
key: "graphics",
|
|
42633
44329
|
get: function get() {
|
|
@@ -42865,7 +44561,7 @@ registerPlugin("text", TextLoader);
|
|
|
42865
44561
|
registerPlugin("sprite", SpriteLoader);
|
|
42866
44562
|
registerPlugin("particle", ParticleLoader);
|
|
42867
44563
|
registerPlugin("interact", InteractLoader);
|
|
42868
|
-
var version = "2.10.0-alpha.
|
|
44564
|
+
var version = "2.10.0-alpha.3";
|
|
42869
44565
|
logger.info("Core version: " + version + ".");
|
|
42870
44566
|
|
|
42871
44567
|
exports.ATLAS_SIZE = ATLAS_SIZE;
|
|
@@ -42900,8 +44596,8 @@ exports.COPY_MESH_SHADER_ID = COPY_MESH_SHADER_ID;
|
|
|
42900
44596
|
exports.COPY_VERTEX_SHADER = COPY_VERTEX_SHADER;
|
|
42901
44597
|
exports.Camera = Camera;
|
|
42902
44598
|
exports.CameraVFXItemLoader = CameraVFXItemLoader;
|
|
42903
|
-
exports.
|
|
42904
|
-
exports.
|
|
44599
|
+
exports.CanvasContainer = CanvasContainer;
|
|
44600
|
+
exports.CanvasRootControl = CanvasRootControl;
|
|
42905
44601
|
exports.Circle = Circle$1;
|
|
42906
44602
|
exports.ColorCurve = ColorCurve;
|
|
42907
44603
|
exports.ColorPlayable = ColorPlayable;
|
|
@@ -42914,6 +44610,7 @@ exports.Composition = Composition;
|
|
|
42914
44610
|
exports.ConstBoolNode = ConstBoolNode;
|
|
42915
44611
|
exports.ConstFloatNode = ConstFloatNode;
|
|
42916
44612
|
exports.ConstraintTarget = ConstraintTarget;
|
|
44613
|
+
exports.ContainerControl = ContainerControl;
|
|
42917
44614
|
exports.Control = Control;
|
|
42918
44615
|
exports.ControlParameterBoolNode = ControlParameterBoolNode;
|
|
42919
44616
|
exports.ControlParameterFloatNode = ControlParameterFloatNode;
|
|
@@ -42937,7 +44634,6 @@ exports.Ellipse = Ellipse;
|
|
|
42937
44634
|
exports.Engine = Engine;
|
|
42938
44635
|
exports.EventEmitter = EventEmitter;
|
|
42939
44636
|
exports.EventSystem = EventSystem;
|
|
42940
|
-
exports.FONT_SCALE = FONT_SCALE;
|
|
42941
44637
|
exports.Float16ArrayWrapper = Float16ArrayWrapper;
|
|
42942
44638
|
exports.FloatComparisonNode = FloatComparisonNode;
|
|
42943
44639
|
exports.FloatComparisonNodeData = FloatComparisonNodeData;
|
|
@@ -42954,6 +44650,14 @@ exports.GraphNode = GraphNode;
|
|
|
42954
44650
|
exports.GraphNodeData = GraphNodeData;
|
|
42955
44651
|
exports.Graphics = Graphics;
|
|
42956
44652
|
exports.HELP_LINK = HELP_LINK;
|
|
44653
|
+
exports.InputEvent = InputEvent;
|
|
44654
|
+
exports.InputEventKey = InputEventKey;
|
|
44655
|
+
exports.InputEventMouse = InputEventMouse;
|
|
44656
|
+
exports.InputEventMouseButton = InputEventMouseButton;
|
|
44657
|
+
exports.InputEventMouseMotion = InputEventMouseMotion;
|
|
44658
|
+
exports.InputEventScreenDrag = InputEventScreenDrag;
|
|
44659
|
+
exports.InputEventScreenTouch = InputEventScreenTouch;
|
|
44660
|
+
exports.InputEventWithModifiers = InputEventWithModifiers;
|
|
42957
44661
|
exports.InteractLoader = InteractLoader;
|
|
42958
44662
|
exports.InteractMesh = InteractMesh;
|
|
42959
44663
|
exports.InvalidIndex = InvalidIndex;
|
|
@@ -43002,7 +44706,6 @@ exports.RandomSetValue = RandomSetValue;
|
|
|
43002
44706
|
exports.RandomValue = RandomValue;
|
|
43003
44707
|
exports.RandomVectorValue = RandomVectorValue;
|
|
43004
44708
|
exports.RaycastResult = RaycastResult;
|
|
43005
|
-
exports.RectTransform = RectTransform;
|
|
43006
44709
|
exports.Rectangle = Rectangle$1;
|
|
43007
44710
|
exports.ReferenceCurve = ReferenceCurve;
|
|
43008
44711
|
exports.RenderFrame = RenderFrame;
|
|
@@ -43015,6 +44718,7 @@ exports.RenderTargetPool = RenderTargetPool;
|
|
|
43015
44718
|
exports.Renderbuffer = Renderbuffer;
|
|
43016
44719
|
exports.Renderer = Renderer;
|
|
43017
44720
|
exports.RendererComponent = RendererComponent;
|
|
44721
|
+
exports.RootControl = RootControl;
|
|
43018
44722
|
exports.RuntimeClip = RuntimeClip;
|
|
43019
44723
|
exports.SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0 = SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0;
|
|
43020
44724
|
exports.SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0 = SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0;
|
|
@@ -43052,6 +44756,8 @@ exports.TransformPlayable = TransformPlayable;
|
|
|
43052
44756
|
exports.TransitionNode = TransitionNode;
|
|
43053
44757
|
exports.Triangle = Triangle;
|
|
43054
44758
|
exports.TrimPath = TrimPath;
|
|
44759
|
+
exports.UICanvas = UICanvas;
|
|
44760
|
+
exports.UIControl = UIControl;
|
|
43055
44761
|
exports.ValueGetter = ValueGetter;
|
|
43056
44762
|
exports.ValueNode = ValueNode;
|
|
43057
44763
|
exports.Vector2Curve = Vector2Curve;
|
|
@@ -43061,6 +44767,7 @@ exports.Vector3PropertyMixerPlayable = Vector3PropertyMixerPlayable;
|
|
|
43061
44767
|
exports.Vector4Curve = Vector4Curve;
|
|
43062
44768
|
exports.Vector4PropertyMixerPlayable = Vector4PropertyMixerPlayable;
|
|
43063
44769
|
exports.VertexBuffer = VertexBuffer;
|
|
44770
|
+
exports.WindowRootControl = WindowRootControl;
|
|
43064
44771
|
exports.addByOrder = addByOrder;
|
|
43065
44772
|
exports.addItem = addItem;
|
|
43066
44773
|
exports.addItemWithOrder = addItemWithOrder;
|