laymur 0.13.2 → 0.13.4
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/elements/UIText/UIText.Measuring.d.ts +3 -2
- package/dist/elements/UIText/UIText.Rendering.d.ts +3 -2
- package/dist/index.js +250 -224
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/miscellaneous/canvas.d.ts +13 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -47,7 +47,7 @@ var UIOrientation;
|
|
|
47
47
|
* @returns Orientation or ALWAYS if undefined
|
|
48
48
|
*/
|
|
49
49
|
function resolveOrientation(orientation) {
|
|
50
|
-
return orientation
|
|
50
|
+
return orientation !== null && orientation !== void 0 ? orientation : UIOrientation.ALWAYS;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
function createMap() {
|
|
@@ -1607,7 +1607,7 @@ function convertPriority(priority) {
|
|
|
1607
1607
|
* @returns Priority or P0 if undefined
|
|
1608
1608
|
*/
|
|
1609
1609
|
function resolvePriority(priority) {
|
|
1610
|
-
return priority
|
|
1610
|
+
return priority !== null && priority !== void 0 ? priority : UIPriority.P0;
|
|
1611
1611
|
}
|
|
1612
1612
|
|
|
1613
1613
|
class UIInputWrapper {
|
|
@@ -2901,11 +2901,11 @@ class UIGenericInstancedPlane extends Mesh {
|
|
|
2901
2901
|
if (this.transparency !== transparency || this.source !== source) {
|
|
2902
2902
|
return false;
|
|
2903
2903
|
}
|
|
2904
|
-
return arePropertiesPartiallyCompatible({
|
|
2904
|
+
return arePropertiesPartiallyCompatible(Object.assign(Object.assign({}, this._private_uniformProperties), this._private_varyingProperties), properties);
|
|
2905
2905
|
}
|
|
2906
2906
|
/** Checks if properties are compatible with current plane configuration */
|
|
2907
2907
|
arePropertiesPartiallyCompatible(properties) {
|
|
2908
|
-
return arePropertiesPartiallyCompatible({
|
|
2908
|
+
return arePropertiesPartiallyCompatible(Object.assign(Object.assign({}, this._private_uniformProperties), this._private_varyingProperties), properties);
|
|
2909
2909
|
}
|
|
2910
2910
|
/** Returns reconstructed instance data with new object instances */
|
|
2911
2911
|
extractInstanceData(handler) {
|
|
@@ -3131,7 +3131,7 @@ class UIGenericPlane extends Mesh {
|
|
|
3131
3131
|
extractPlaneData() {
|
|
3132
3132
|
return {
|
|
3133
3133
|
source: this._private_source,
|
|
3134
|
-
properties: {
|
|
3134
|
+
properties: Object.assign({}, this._private_properties),
|
|
3135
3135
|
transform: this._private_transform.clone(),
|
|
3136
3136
|
visibility: this.visible,
|
|
3137
3137
|
transparency: this._private_transparencyInternal,
|
|
@@ -3272,10 +3272,7 @@ class UIPlaneRegistry {
|
|
|
3272
3272
|
}
|
|
3273
3273
|
const planeData = planeDescriptor.plane.extractInstanceData(planeDescriptor.instanceHandler);
|
|
3274
3274
|
this.destroyPlane(handler);
|
|
3275
|
-
this._private_insertPlane(handler, {
|
|
3276
|
-
...planeData,
|
|
3277
|
-
transparency,
|
|
3278
|
-
});
|
|
3275
|
+
this._private_insertPlane(handler, Object.assign(Object.assign({}, planeData), { transparency }));
|
|
3279
3276
|
}
|
|
3280
3277
|
_private_promoteSinglePlaneToInstancedPlane(handler, planeDescriptor) {
|
|
3281
3278
|
const { source, properties, transform, visibility, transparency } = planeDescriptor.plane.extractPlaneData();
|
|
@@ -3482,8 +3479,9 @@ class UIExpression {
|
|
|
3482
3479
|
* @returns This instance for chaining
|
|
3483
3480
|
*/
|
|
3484
3481
|
plus(variableIndex, coefficient) {
|
|
3482
|
+
var _a;
|
|
3485
3483
|
assertValidNumber(coefficient, "UIExpression.plus.coefficient");
|
|
3486
|
-
this._private_terms.set(variableIndex, (this._private_terms.get(variableIndex)
|
|
3484
|
+
this._private_terms.set(variableIndex, ((_a = this._private_terms.get(variableIndex)) !== null && _a !== void 0 ? _a : 0) + coefficient);
|
|
3487
3485
|
return this;
|
|
3488
3486
|
}
|
|
3489
3487
|
/**
|
|
@@ -3592,7 +3590,7 @@ function convertRelation(relation) {
|
|
|
3592
3590
|
* @returns Relation or EQUAL if undefined
|
|
3593
3591
|
*/
|
|
3594
3592
|
function resolveRelation(relation) {
|
|
3595
|
-
return relation
|
|
3593
|
+
return relation !== null && relation !== void 0 ? relation : UIRelation.EQUAL;
|
|
3596
3594
|
}
|
|
3597
3595
|
|
|
3598
3596
|
/**
|
|
@@ -3644,6 +3642,7 @@ class UISolverWrapper {
|
|
|
3644
3642
|
* @returns Unique index identifier for the created variable
|
|
3645
3643
|
*/
|
|
3646
3644
|
createVariable(value, priority) {
|
|
3645
|
+
var _a, _b, _c;
|
|
3647
3646
|
const index = this._private_lastVariableIndex++;
|
|
3648
3647
|
const variable = new Variable();
|
|
3649
3648
|
if (priority === UIPriority.P0) {
|
|
@@ -3651,19 +3650,19 @@ class UISolverWrapper {
|
|
|
3651
3650
|
this._private_variables.set(index, description);
|
|
3652
3651
|
description.constraint = this._private_buildConstraint(new UIExpression(0, [[index, 1]]), new UIExpression(value), UIRelation.EQUAL, priority);
|
|
3653
3652
|
try {
|
|
3654
|
-
this._private_solver
|
|
3653
|
+
(_a = this._private_solver) === null || _a === void 0 ? void 0 : _a.addConstraint(description.constraint);
|
|
3655
3654
|
}
|
|
3656
|
-
catch {
|
|
3655
|
+
catch (_d) {
|
|
3657
3656
|
this._private_solver = undefined;
|
|
3658
3657
|
}
|
|
3659
3658
|
}
|
|
3660
3659
|
else {
|
|
3661
3660
|
this._private_variables.set(index, { variable, priority, value });
|
|
3662
3661
|
try {
|
|
3663
|
-
this._private_solver
|
|
3664
|
-
this._private_solver
|
|
3662
|
+
(_b = this._private_solver) === null || _b === void 0 ? void 0 : _b.addEditVariable(variable, convertPriority(priority));
|
|
3663
|
+
(_c = this._private_solver) === null || _c === void 0 ? void 0 : _c.suggestValue(variable, value);
|
|
3665
3664
|
}
|
|
3666
|
-
catch {
|
|
3665
|
+
catch (_e) {
|
|
3667
3666
|
this._private_solver = undefined;
|
|
3668
3667
|
}
|
|
3669
3668
|
}
|
|
@@ -3681,6 +3680,7 @@ class UISolverWrapper {
|
|
|
3681
3680
|
* @throws Will throw an error if the variable doesn't exist or is still in use
|
|
3682
3681
|
*/
|
|
3683
3682
|
removeVariable(index) {
|
|
3683
|
+
var _a, _b;
|
|
3684
3684
|
const description = this._private_variables.get(index);
|
|
3685
3685
|
if (description === undefined) {
|
|
3686
3686
|
throw new Error(`UISolverWrapper.removeVariable.index: variable does not exist`);
|
|
@@ -3692,10 +3692,10 @@ class UISolverWrapper {
|
|
|
3692
3692
|
}
|
|
3693
3693
|
try {
|
|
3694
3694
|
description.constraint
|
|
3695
|
-
? this._private_solver
|
|
3696
|
-
: this._private_solver
|
|
3695
|
+
? (_a = this._private_solver) === null || _a === void 0 ? void 0 : _a.removeConstraint(description.constraint)
|
|
3696
|
+
: (_b = this._private_solver) === null || _b === void 0 ? void 0 : _b.removeEditVariable(description.variable);
|
|
3697
3697
|
}
|
|
3698
|
-
catch {
|
|
3698
|
+
catch (_c) {
|
|
3699
3699
|
this._private_solver = undefined;
|
|
3700
3700
|
}
|
|
3701
3701
|
this._private_variables.delete(index);
|
|
@@ -3714,6 +3714,7 @@ class UISolverWrapper {
|
|
|
3714
3714
|
* @throws Will throw an error if the variable doesn't exist
|
|
3715
3715
|
*/
|
|
3716
3716
|
suggestVariableValue(index, value) {
|
|
3717
|
+
var _a;
|
|
3717
3718
|
const description = this._private_variables.get(index);
|
|
3718
3719
|
if (description === undefined) {
|
|
3719
3720
|
throw new Error(`UISolverWrapper.suggestVariableValue.index: variable does not exist`);
|
|
@@ -3724,7 +3725,7 @@ class UISolverWrapper {
|
|
|
3724
3725
|
description.constraint = this._private_rebuildConstraint(description.constraint, new UIExpression().plus(index, 1), new UIExpression(description.value), UIRelation.EQUAL, description.priority);
|
|
3725
3726
|
}
|
|
3726
3727
|
else {
|
|
3727
|
-
this._private_solver
|
|
3728
|
+
(_a = this._private_solver) === null || _a === void 0 ? void 0 : _a.suggestValue(description.variable, value);
|
|
3728
3729
|
}
|
|
3729
3730
|
this._private_recalculationRequired = true;
|
|
3730
3731
|
this.dirty = true;
|
|
@@ -3742,6 +3743,7 @@ class UISolverWrapper {
|
|
|
3742
3743
|
* @throws Will throw an error if the variable doesn't exist
|
|
3743
3744
|
*/
|
|
3744
3745
|
setVariablePriority(index, priority) {
|
|
3746
|
+
var _a, _b;
|
|
3745
3747
|
const description = this._private_variables.get(index);
|
|
3746
3748
|
if (description === undefined) {
|
|
3747
3749
|
throw new Error(`UISolverWrapper.setVariablePriority.index: variable does not exist`);
|
|
@@ -3753,18 +3755,18 @@ class UISolverWrapper {
|
|
|
3753
3755
|
const rhs = new UIExpression(description.value);
|
|
3754
3756
|
description.constraint = this._private_buildConstraint(lhs, rhs, UIRelation.EQUAL, description.priority);
|
|
3755
3757
|
try {
|
|
3756
|
-
this._private_solver
|
|
3758
|
+
(_a = this._private_solver) === null || _a === void 0 ? void 0 : _a.addConstraint(description.constraint);
|
|
3757
3759
|
}
|
|
3758
|
-
catch {
|
|
3760
|
+
catch (_c) {
|
|
3759
3761
|
this._private_solver = undefined;
|
|
3760
3762
|
}
|
|
3761
3763
|
}
|
|
3762
3764
|
else {
|
|
3763
3765
|
if (description.constraint) {
|
|
3764
3766
|
try {
|
|
3765
|
-
this._private_solver
|
|
3767
|
+
(_b = this._private_solver) === null || _b === void 0 ? void 0 : _b.removeConstraint(description.constraint);
|
|
3766
3768
|
}
|
|
3767
|
-
catch {
|
|
3769
|
+
catch (_d) {
|
|
3768
3770
|
this._private_solver = undefined;
|
|
3769
3771
|
}
|
|
3770
3772
|
}
|
|
@@ -3786,6 +3788,7 @@ class UISolverWrapper {
|
|
|
3786
3788
|
* @throws Will throw an error if the variable doesn't exist
|
|
3787
3789
|
*/
|
|
3788
3790
|
readVariableValue(index) {
|
|
3791
|
+
var _a;
|
|
3789
3792
|
const description = this._private_variables.get(index);
|
|
3790
3793
|
if (description === undefined) {
|
|
3791
3794
|
throw new Error(`UISolverWrapper.readVariableValue.index: variable does not exist`);
|
|
@@ -3794,7 +3797,7 @@ class UISolverWrapper {
|
|
|
3794
3797
|
this._private_rebuildSolver();
|
|
3795
3798
|
}
|
|
3796
3799
|
if (this._private_recalculationRequired) {
|
|
3797
|
-
this._private_solver
|
|
3800
|
+
(_a = this._private_solver) === null || _a === void 0 ? void 0 : _a.updateVariables();
|
|
3798
3801
|
this._private_recalculationRequired = false;
|
|
3799
3802
|
}
|
|
3800
3803
|
return description.variable.value();
|
|
@@ -3813,6 +3816,7 @@ class UISolverWrapper {
|
|
|
3813
3816
|
* @returns Unique index identifier for the created constraint
|
|
3814
3817
|
*/
|
|
3815
3818
|
createConstraint(lhs, rhs, relation, priority, enabled) {
|
|
3819
|
+
var _a;
|
|
3816
3820
|
const index = this._private_lastConstraintIndex++;
|
|
3817
3821
|
const constraint = this._private_buildConstraint(lhs, rhs, relation, priority);
|
|
3818
3822
|
this._private_constraints.set(index, {
|
|
@@ -3825,9 +3829,9 @@ class UISolverWrapper {
|
|
|
3825
3829
|
});
|
|
3826
3830
|
if (enabled) {
|
|
3827
3831
|
try {
|
|
3828
|
-
this._private_solver
|
|
3832
|
+
(_a = this._private_solver) === null || _a === void 0 ? void 0 : _a.addConstraint(constraint);
|
|
3829
3833
|
}
|
|
3830
|
-
catch {
|
|
3834
|
+
catch (_b) {
|
|
3831
3835
|
this._private_solver = undefined;
|
|
3832
3836
|
}
|
|
3833
3837
|
this._private_recalculationRequired = true;
|
|
@@ -3845,15 +3849,16 @@ class UISolverWrapper {
|
|
|
3845
3849
|
* @throws Will throw an error if the constraint doesn't exist
|
|
3846
3850
|
*/
|
|
3847
3851
|
removeConstraint(index) {
|
|
3852
|
+
var _a;
|
|
3848
3853
|
const description = this._private_constraints.get(index);
|
|
3849
3854
|
if (description === undefined) {
|
|
3850
3855
|
throw new Error(`UISolverWrapper.removeConstraint.index: constraint does not exist`);
|
|
3851
3856
|
}
|
|
3852
3857
|
if (description.enabled) {
|
|
3853
3858
|
try {
|
|
3854
|
-
this._private_solver
|
|
3859
|
+
(_a = this._private_solver) === null || _a === void 0 ? void 0 : _a.removeConstraint(description.constraint);
|
|
3855
3860
|
}
|
|
3856
|
-
catch {
|
|
3861
|
+
catch (_b) {
|
|
3857
3862
|
this._private_solver = undefined;
|
|
3858
3863
|
}
|
|
3859
3864
|
}
|
|
@@ -3956,6 +3961,7 @@ class UISolverWrapper {
|
|
|
3956
3961
|
* @throws Will throw an error if the constraint doesn't exist
|
|
3957
3962
|
*/
|
|
3958
3963
|
setConstraintEnabled(index, enabled) {
|
|
3964
|
+
var _a, _b;
|
|
3959
3965
|
const description = this._private_constraints.get(index);
|
|
3960
3966
|
if (description === undefined) {
|
|
3961
3967
|
throw new Error(`UISolverWrapper.setConstraintEnabled.index: constraint does not exist`);
|
|
@@ -3964,10 +3970,10 @@ class UISolverWrapper {
|
|
|
3964
3970
|
description.enabled = enabled;
|
|
3965
3971
|
try {
|
|
3966
3972
|
description.enabled
|
|
3967
|
-
? this._private_solver
|
|
3968
|
-
: this._private_solver
|
|
3973
|
+
? (_a = this._private_solver) === null || _a === void 0 ? void 0 : _a.addConstraint(description.constraint)
|
|
3974
|
+
: (_b = this._private_solver) === null || _b === void 0 ? void 0 : _b.removeConstraint(description.constraint);
|
|
3969
3975
|
}
|
|
3970
|
-
catch {
|
|
3976
|
+
catch (_c) {
|
|
3971
3977
|
this._private_solver = undefined;
|
|
3972
3978
|
}
|
|
3973
3979
|
this._private_recalculationRequired = true;
|
|
@@ -3982,28 +3988,29 @@ class UISolverWrapper {
|
|
|
3982
3988
|
* the dependent constraints.
|
|
3983
3989
|
*/
|
|
3984
3990
|
_private_rebuildVariable(index, description) {
|
|
3991
|
+
var _a, _b, _c, _d;
|
|
3985
3992
|
const dependConstraints = [];
|
|
3986
3993
|
for (const cDescription of this._private_constraints.values()) {
|
|
3987
3994
|
if (cDescription.lhs.hasTerm(index) || cDescription.rhs.hasTerm(index)) {
|
|
3988
3995
|
try {
|
|
3989
|
-
this._private_solver
|
|
3996
|
+
(_a = this._private_solver) === null || _a === void 0 ? void 0 : _a.removeConstraint(cDescription.constraint);
|
|
3990
3997
|
}
|
|
3991
|
-
catch {
|
|
3998
|
+
catch (_e) {
|
|
3992
3999
|
this._private_solver = undefined;
|
|
3993
4000
|
}
|
|
3994
4001
|
dependConstraints.push(cDescription);
|
|
3995
4002
|
}
|
|
3996
4003
|
}
|
|
3997
|
-
this._private_solver
|
|
3998
|
-
this._private_solver
|
|
4004
|
+
(_b = this._private_solver) === null || _b === void 0 ? void 0 : _b.removeEditVariable(description.variable);
|
|
4005
|
+
(_c = this._private_solver) === null || _c === void 0 ? void 0 : _c.addEditVariable(description.variable, convertPriority(description.priority));
|
|
3999
4006
|
for (const cDescription of dependConstraints) {
|
|
4000
4007
|
cDescription.constraint = this._private_buildConstraint(cDescription.lhs, cDescription.rhs, cDescription.relation, cDescription.priority);
|
|
4001
4008
|
}
|
|
4002
4009
|
for (const cDescription of dependConstraints) {
|
|
4003
4010
|
try {
|
|
4004
|
-
this._private_solver
|
|
4011
|
+
(_d = this._private_solver) === null || _d === void 0 ? void 0 : _d.addConstraint(cDescription.constraint);
|
|
4005
4012
|
}
|
|
4006
|
-
catch {
|
|
4013
|
+
catch (_f) {
|
|
4007
4014
|
this._private_solver = undefined;
|
|
4008
4015
|
break;
|
|
4009
4016
|
}
|
|
@@ -4026,17 +4033,18 @@ class UISolverWrapper {
|
|
|
4026
4033
|
* Safely handles solver state transitions and constraint replacement.
|
|
4027
4034
|
*/
|
|
4028
4035
|
_private_rebuildConstraint(oldConstraint, lhs, rhs, relation, priority) {
|
|
4036
|
+
var _a, _b;
|
|
4029
4037
|
try {
|
|
4030
|
-
this._private_solver
|
|
4038
|
+
(_a = this._private_solver) === null || _a === void 0 ? void 0 : _a.removeConstraint(oldConstraint);
|
|
4031
4039
|
}
|
|
4032
|
-
catch {
|
|
4040
|
+
catch (_c) {
|
|
4033
4041
|
this._private_solver = undefined;
|
|
4034
4042
|
}
|
|
4035
4043
|
const constraint = this._private_buildConstraint(lhs, rhs, relation, priority);
|
|
4036
4044
|
try {
|
|
4037
|
-
this._private_solver
|
|
4045
|
+
(_b = this._private_solver) === null || _b === void 0 ? void 0 : _b.addConstraint(constraint);
|
|
4038
4046
|
}
|
|
4039
|
-
catch {
|
|
4047
|
+
catch (_d) {
|
|
4040
4048
|
this._private_solver = undefined;
|
|
4041
4049
|
}
|
|
4042
4050
|
return constraint;
|
|
@@ -4113,6 +4121,7 @@ const LAYER_DEFAULT_MODE = UIMode.VISIBLE;
|
|
|
4113
4121
|
/** Base layer for UI rendering and layout management */
|
|
4114
4122
|
class UILayer extends i {
|
|
4115
4123
|
constructor(options) {
|
|
4124
|
+
var _a, _b, _c, _d;
|
|
4116
4125
|
super();
|
|
4117
4126
|
/** Optional layer name */
|
|
4118
4127
|
this.name = "";
|
|
@@ -4124,11 +4133,11 @@ class UILayer extends i {
|
|
|
4124
4133
|
if (options.height !== undefined) {
|
|
4125
4134
|
assertValidPositiveNumber(options.height, "UILayer.constructor.options.height");
|
|
4126
4135
|
}
|
|
4127
|
-
const width = options.width
|
|
4128
|
-
const height = options.height
|
|
4136
|
+
const width = (_a = options.width) !== null && _a !== void 0 ? _a : LAYER_DEFAULT_SIZE;
|
|
4137
|
+
const height = (_b = options.height) !== null && _b !== void 0 ? _b : LAYER_DEFAULT_SIZE;
|
|
4129
4138
|
this._private_sceneWrapperInternal = new UISceneWrapper(width, height);
|
|
4130
|
-
this.name = options.name
|
|
4131
|
-
this._private_modeInternal = options.mode
|
|
4139
|
+
this.name = (_c = options.name) !== null && _c !== void 0 ? _c : LAYER_DEFAULT_NAME;
|
|
4140
|
+
this._private_modeInternal = (_d = options.mode) !== null && _d !== void 0 ? _d : LAYER_DEFAULT_MODE;
|
|
4132
4141
|
this._private_orientationInternal =
|
|
4133
4142
|
width > height ? UIOrientation.HORIZONTAL : UIOrientation.VERTICAL;
|
|
4134
4143
|
this.xVariable = this._private_solverWrapperInternal.createVariable(0, UIPriority.P0);
|
|
@@ -4410,7 +4419,7 @@ class UIConstraint {
|
|
|
4410
4419
|
constructor(layer, name) {
|
|
4411
4420
|
this.layer = layer;
|
|
4412
4421
|
this.solverWrapper = this.layer.solverWrapper;
|
|
4413
|
-
this.name = name
|
|
4422
|
+
this.name = name !== null && name !== void 0 ? name : "";
|
|
4414
4423
|
}
|
|
4415
4424
|
}
|
|
4416
4425
|
|
|
@@ -4421,14 +4430,14 @@ class UISingleParameterConstraint extends UIConstraint {
|
|
|
4421
4430
|
* @param options Constraint configuration
|
|
4422
4431
|
*/
|
|
4423
4432
|
constructor(layer, options) {
|
|
4424
|
-
super(layer, options
|
|
4433
|
+
super(layer, options === null || options === void 0 ? void 0 : options.name);
|
|
4425
4434
|
/** Updates constraint enabled state when layer orientation changes */
|
|
4426
4435
|
this._private_onOrientationChange = () => {
|
|
4427
4436
|
this.solverWrapper.setConstraintEnabled(this.constraint, this.isConstraintEnabled());
|
|
4428
4437
|
};
|
|
4429
|
-
this._private_priorityInternal = resolvePriority(options
|
|
4430
|
-
this._private_relationInternal = resolveRelation(options
|
|
4431
|
-
this._private_orientationInternal = resolveOrientation(options
|
|
4438
|
+
this._private_priorityInternal = resolvePriority(options === null || options === void 0 ? void 0 : options.priority);
|
|
4439
|
+
this._private_relationInternal = resolveRelation(options === null || options === void 0 ? void 0 : options.relation);
|
|
4440
|
+
this._private_orientationInternal = resolveOrientation(options === null || options === void 0 ? void 0 : options.orientation);
|
|
4432
4441
|
this.layer.on(UILayerEvent.ORIENTATION_CHANGED, this._private_onOrientationChange);
|
|
4433
4442
|
}
|
|
4434
4443
|
/** Constraint priority */
|
|
@@ -4486,12 +4495,13 @@ class UIHeightConstraint extends UISingleParameterConstraint {
|
|
|
4486
4495
|
* @param options Height configuration. Defaults to element's current height.
|
|
4487
4496
|
*/
|
|
4488
4497
|
constructor(_private_element, options = {}) {
|
|
4498
|
+
var _a;
|
|
4489
4499
|
if (options.height !== undefined) {
|
|
4490
4500
|
assertValidPositiveNumber(options.height, "UIHeightConstraint.constructor.options.height");
|
|
4491
4501
|
}
|
|
4492
4502
|
super(_private_element.layer, options);
|
|
4493
4503
|
this._private_element = _private_element;
|
|
4494
|
-
this._private_heightInternal = options.height
|
|
4504
|
+
this._private_heightInternal = (_a = options.height) !== null && _a !== void 0 ? _a : _private_element.height;
|
|
4495
4505
|
this.constraint = this.solverWrapper.createConstraint(new UIExpression(0, [[this._private_element.hVariable, 1]]), new UIExpression(this._private_heightInternal), this.relation, this.priority, this.isConstraintEnabled());
|
|
4496
4506
|
}
|
|
4497
4507
|
/** Current height in world units */
|
|
@@ -4518,6 +4528,7 @@ class UIHorizontalDistanceConstraint extends UISingleParameterConstraint {
|
|
|
4518
4528
|
* @param options Distance configuration
|
|
4519
4529
|
*/
|
|
4520
4530
|
constructor(_private_a, _private_b, options = {}) {
|
|
4531
|
+
var _a, _b, _c;
|
|
4521
4532
|
if (options.anchorA !== undefined) {
|
|
4522
4533
|
assertValidNumber(options.anchorA, "UIHorizontalDistanceConstraint.constructor.options.anchorA");
|
|
4523
4534
|
}
|
|
@@ -4530,9 +4541,9 @@ class UIHorizontalDistanceConstraint extends UISingleParameterConstraint {
|
|
|
4530
4541
|
super(assertValidConstraintArguments(_private_a, _private_b, "UIHorizontalDistanceConstraint.constructor"), options);
|
|
4531
4542
|
this._private_a = _private_a;
|
|
4532
4543
|
this._private_b = _private_b;
|
|
4533
|
-
this._private_anchorAInternal = options.anchorA
|
|
4534
|
-
this._private_anchorBInternal = options.anchorB
|
|
4535
|
-
this._private_distanceInternal = options.distance
|
|
4544
|
+
this._private_anchorAInternal = (_a = options.anchorA) !== null && _a !== void 0 ? _a : DEFAULT_ANCHOR$4;
|
|
4545
|
+
this._private_anchorBInternal = (_b = options.anchorB) !== null && _b !== void 0 ? _b : DEFAULT_ANCHOR$4;
|
|
4546
|
+
this._private_distanceInternal = (_c = options.distance) !== null && _c !== void 0 ? _c : 0;
|
|
4536
4547
|
this.constraint = this.solverWrapper.createConstraint(this._private_buildLHS(), new UIExpression(this._private_distanceInternal), this.relation, this.priority, this.isConstraintEnabled());
|
|
4537
4548
|
}
|
|
4538
4549
|
/** Current distance in world units */
|
|
@@ -4615,6 +4626,7 @@ class UIHorizontalInterpolationConstraint extends UISingleParameterConstraint {
|
|
|
4615
4626
|
* @param options Interpolation configuration
|
|
4616
4627
|
*/
|
|
4617
4628
|
constructor(_private_a, _private_b, _private_c, options = {}) {
|
|
4629
|
+
var _a, _b, _c, _d;
|
|
4618
4630
|
if (options.anchorA !== undefined) {
|
|
4619
4631
|
assertValidNumber(options.anchorA, "UIHorizontalInterpolationConstraint.constructor.options.anchorA");
|
|
4620
4632
|
}
|
|
@@ -4627,16 +4639,16 @@ class UIHorizontalInterpolationConstraint extends UISingleParameterConstraint {
|
|
|
4627
4639
|
if (options.t !== undefined) {
|
|
4628
4640
|
assertValidNumber(options.t, "UIHorizontalInterpolationConstraint.constructor.options.t");
|
|
4629
4641
|
}
|
|
4630
|
-
const anchorA = options.anchorA
|
|
4631
|
-
const anchorB = options.anchorB
|
|
4642
|
+
const anchorA = (_a = options.anchorA) !== null && _a !== void 0 ? _a : DEFAULT_ANCHOR$3;
|
|
4643
|
+
const anchorB = (_b = options.anchorB) !== null && _b !== void 0 ? _b : DEFAULT_ANCHOR$3;
|
|
4632
4644
|
super(assertValidInterpolationConstraintArguments("UIHorizontalInterpolationConstraint.constructor", _private_a, _private_b, _private_c, anchorA, anchorB), options);
|
|
4633
4645
|
this._private_a = _private_a;
|
|
4634
4646
|
this._private_b = _private_b;
|
|
4635
4647
|
this._private_c = _private_c;
|
|
4636
4648
|
this._private_anchorAInternal = anchorA;
|
|
4637
4649
|
this._private_anchorBInternal = anchorA;
|
|
4638
|
-
this._private_anchorCInternal = options.anchorC
|
|
4639
|
-
this._private_tInternal = options.t
|
|
4650
|
+
this._private_anchorCInternal = (_c = options.anchorC) !== null && _c !== void 0 ? _c : DEFAULT_ANCHOR$3;
|
|
4651
|
+
this._private_tInternal = (_d = options.t) !== null && _d !== void 0 ? _d : DEFAULT_T$1;
|
|
4640
4652
|
this.constraint = this.solverWrapper.createConstraint(this._private_buildLHS(), new UIExpression(0), this.relation, this.priority, this.isConstraintEnabled());
|
|
4641
4653
|
}
|
|
4642
4654
|
/** Interpolation factor (0 = A position, 1 = B position) */
|
|
@@ -4743,13 +4755,14 @@ class UIHorizontalProportionConstraint extends UISingleParameterConstraint {
|
|
|
4743
4755
|
* @param options Proportion configuration
|
|
4744
4756
|
*/
|
|
4745
4757
|
constructor(_private_a, _private_b, options = {}) {
|
|
4758
|
+
var _a;
|
|
4746
4759
|
if (options.proportion !== undefined) {
|
|
4747
4760
|
assertValidPositiveNumber(options.proportion, "UIHorizontalProportionConstraint.constructor.options.proportion");
|
|
4748
4761
|
}
|
|
4749
4762
|
super(assertValidConstraintArguments(_private_a, _private_b, "UIHorizontalProportionConstraint.constructor"), options);
|
|
4750
4763
|
this._private_a = _private_a;
|
|
4751
4764
|
this._private_b = _private_b;
|
|
4752
|
-
this._private_proportionInternal = options.proportion
|
|
4765
|
+
this._private_proportionInternal = (_a = options.proportion) !== null && _a !== void 0 ? _a : 1;
|
|
4753
4766
|
this.constraint = this.solverWrapper.createConstraint(new UIExpression(0), this._private_buildRHS(), this.relation, this.priority, this.isConstraintEnabled());
|
|
4754
4767
|
}
|
|
4755
4768
|
/** Current proportion multiplier */
|
|
@@ -4780,6 +4793,7 @@ class UIVerticalDistanceConstraint extends UISingleParameterConstraint {
|
|
|
4780
4793
|
* @param options Distance configuration
|
|
4781
4794
|
*/
|
|
4782
4795
|
constructor(_private_a, _private_b, options = {}) {
|
|
4796
|
+
var _a, _b, _c;
|
|
4783
4797
|
if (options.anchorA !== undefined) {
|
|
4784
4798
|
assertValidNumber(options.anchorA, "UIVerticalDistanceConstraint.constructor.options.anchorA");
|
|
4785
4799
|
}
|
|
@@ -4792,9 +4806,9 @@ class UIVerticalDistanceConstraint extends UISingleParameterConstraint {
|
|
|
4792
4806
|
super(assertValidConstraintArguments(_private_a, _private_b, "UIVerticalDistanceConstraint.constructor"), options);
|
|
4793
4807
|
this._private_a = _private_a;
|
|
4794
4808
|
this._private_b = _private_b;
|
|
4795
|
-
this._private_anchorAInternal = options.anchorA
|
|
4796
|
-
this._private_anchorBInternal = options.anchorB
|
|
4797
|
-
this._private_distanceInternal = options.distance
|
|
4809
|
+
this._private_anchorAInternal = (_a = options.anchorA) !== null && _a !== void 0 ? _a : DEFAULT_ANCHOR$2;
|
|
4810
|
+
this._private_anchorBInternal = (_b = options.anchorB) !== null && _b !== void 0 ? _b : DEFAULT_ANCHOR$2;
|
|
4811
|
+
this._private_distanceInternal = (_c = options.distance) !== null && _c !== void 0 ? _c : 0;
|
|
4798
4812
|
this.constraint = this.solverWrapper.createConstraint(this._private_buildLHS(), new UIExpression(this._private_distanceInternal), this.relation, this.priority, this.isConstraintEnabled());
|
|
4799
4813
|
}
|
|
4800
4814
|
/** Current distance in world units */
|
|
@@ -4877,6 +4891,7 @@ class UIVerticalInterpolationConstraint extends UISingleParameterConstraint {
|
|
|
4877
4891
|
* @param options Interpolation configuration
|
|
4878
4892
|
*/
|
|
4879
4893
|
constructor(_private_a, _private_b, _private_c, options = {}) {
|
|
4894
|
+
var _a, _b, _c, _d;
|
|
4880
4895
|
if (options.anchorA !== undefined) {
|
|
4881
4896
|
assertValidNumber(options.anchorA, "UIVerticalInterpolationConstraint.constructor.options.anchorA");
|
|
4882
4897
|
}
|
|
@@ -4889,16 +4904,16 @@ class UIVerticalInterpolationConstraint extends UISingleParameterConstraint {
|
|
|
4889
4904
|
if (options.t !== undefined) {
|
|
4890
4905
|
assertValidNumber(options.t, "UIVerticalInterpolationConstraint.constructor.options.t");
|
|
4891
4906
|
}
|
|
4892
|
-
const anchorA = options.anchorA
|
|
4893
|
-
const anchorB = options.anchorB
|
|
4907
|
+
const anchorA = (_a = options.anchorA) !== null && _a !== void 0 ? _a : DEFAULT_ANCHOR$1;
|
|
4908
|
+
const anchorB = (_b = options.anchorB) !== null && _b !== void 0 ? _b : DEFAULT_ANCHOR$1;
|
|
4894
4909
|
super(assertValidInterpolationConstraintArguments("UIVerticalInterpolationConstraint.constructor", _private_a, _private_b, _private_c, anchorA, anchorB), options);
|
|
4895
4910
|
this._private_a = _private_a;
|
|
4896
4911
|
this._private_b = _private_b;
|
|
4897
4912
|
this._private_c = _private_c;
|
|
4898
4913
|
this._private_anchorAInternal = anchorA;
|
|
4899
4914
|
this._private_anchorBInternal = anchorA;
|
|
4900
|
-
this._private_anchorCInternal = options.anchorC
|
|
4901
|
-
this._private_tInternal = options.t
|
|
4915
|
+
this._private_anchorCInternal = (_c = options.anchorC) !== null && _c !== void 0 ? _c : DEFAULT_ANCHOR$1;
|
|
4916
|
+
this._private_tInternal = (_d = options.t) !== null && _d !== void 0 ? _d : DEFAULT_T;
|
|
4902
4917
|
this.constraint = this.solverWrapper.createConstraint(this._private_buildLHS(), new UIExpression(0), this.relation, this.priority, this.isConstraintEnabled());
|
|
4903
4918
|
}
|
|
4904
4919
|
/** Interpolation factor (0 = A position, 1 = B position) */
|
|
@@ -5005,13 +5020,14 @@ class UIVerticalProportionConstraint extends UISingleParameterConstraint {
|
|
|
5005
5020
|
* @param options Proportion configuration
|
|
5006
5021
|
*/
|
|
5007
5022
|
constructor(_private_a, _private_b, options = {}) {
|
|
5023
|
+
var _a;
|
|
5008
5024
|
if (options.proportion !== undefined) {
|
|
5009
5025
|
assertValidPositiveNumber(options.proportion, "UIVerticalProportionConstraint.constructor.options.proportion");
|
|
5010
5026
|
}
|
|
5011
5027
|
super(assertValidConstraintArguments(_private_a, _private_b, "UIVerticalProportionConstraint.constructor"), options);
|
|
5012
5028
|
this._private_a = _private_a;
|
|
5013
5029
|
this._private_b = _private_b;
|
|
5014
|
-
this._private_proportionInternal = options.proportion
|
|
5030
|
+
this._private_proportionInternal = (_a = options.proportion) !== null && _a !== void 0 ? _a : 1;
|
|
5015
5031
|
this.constraint = this.solverWrapper.createConstraint(new UIExpression(0), this._private_buildRHS(), this.relation, this.priority, this.isConstraintEnabled());
|
|
5016
5032
|
}
|
|
5017
5033
|
/** Current proportion multiplier */
|
|
@@ -5039,12 +5055,13 @@ class UIWidthConstraint extends UISingleParameterConstraint {
|
|
|
5039
5055
|
* @param options Width configuration. Defaults to element's current width.
|
|
5040
5056
|
*/
|
|
5041
5057
|
constructor(_private_element, options = {}) {
|
|
5058
|
+
var _a;
|
|
5042
5059
|
if (options.width !== undefined) {
|
|
5043
5060
|
assertValidPositiveNumber(options.width, "UIWidthConstraint.constructor.options.width");
|
|
5044
5061
|
}
|
|
5045
5062
|
super(_private_element.layer, options);
|
|
5046
5063
|
this._private_element = _private_element;
|
|
5047
|
-
this._private_widthInternal = options.width
|
|
5064
|
+
this._private_widthInternal = (_a = options.width) !== null && _a !== void 0 ? _a : _private_element.width;
|
|
5048
5065
|
this.constraint = this.solverWrapper.createConstraint(new UIExpression(0, [[this._private_element.wVariable, 1]]), new UIExpression(this._private_widthInternal), this.relation, this.priority, this.isConstraintEnabled());
|
|
5049
5066
|
}
|
|
5050
5067
|
/** Current width in world units */
|
|
@@ -5215,12 +5232,13 @@ class UIAspectConstraint extends UISingleParameterConstraint {
|
|
|
5215
5232
|
* @param options Aspect configuration. Defaults to element's current ratio.
|
|
5216
5233
|
*/
|
|
5217
5234
|
constructor(_private_element, options = {}) {
|
|
5235
|
+
var _a;
|
|
5218
5236
|
if (options.aspect !== undefined) {
|
|
5219
5237
|
assertValidPositiveNumber(options.aspect, "UIAspectConstraint.constructor.options.aspect");
|
|
5220
5238
|
}
|
|
5221
5239
|
super(_private_element.layer, options);
|
|
5222
5240
|
this._private_element = _private_element;
|
|
5223
|
-
this._private_aspectInternal = options.aspect
|
|
5241
|
+
this._private_aspectInternal = (_a = options.aspect) !== null && _a !== void 0 ? _a : _private_element.width / _private_element.height;
|
|
5224
5242
|
this.constraint = this.solverWrapper.createConstraint(this._private_buildLHS(), new UIExpression(0), this.relation, this.priority, this.isConstraintEnabled());
|
|
5225
5243
|
}
|
|
5226
5244
|
/** Current aspect ratio (width/height) */
|
|
@@ -5256,6 +5274,7 @@ class UICoverConstraintBuilder {
|
|
|
5256
5274
|
* @returns Created constraints
|
|
5257
5275
|
*/
|
|
5258
5276
|
static build(passive, active, options = {}) {
|
|
5277
|
+
var _a, _b, _c, _d;
|
|
5259
5278
|
if (options.anchorH !== undefined) {
|
|
5260
5279
|
assertValidNumber(options.anchorH, "UICoverConstraintBuilder.build.anchorH");
|
|
5261
5280
|
}
|
|
@@ -5269,13 +5288,13 @@ class UICoverConstraintBuilder {
|
|
|
5269
5288
|
});
|
|
5270
5289
|
}
|
|
5271
5290
|
const xConstraint = new UIHorizontalDistanceConstraint(passive, active, {
|
|
5272
|
-
anchorA: options.anchorH
|
|
5273
|
-
anchorB: options.anchorH
|
|
5291
|
+
anchorA: (_a = options.anchorH) !== null && _a !== void 0 ? _a : COVER_CONSTRAINT_DEFAULT_ANCHOR,
|
|
5292
|
+
anchorB: (_b = options.anchorH) !== null && _b !== void 0 ? _b : COVER_CONSTRAINT_DEFAULT_ANCHOR,
|
|
5274
5293
|
orientation: options.orientation,
|
|
5275
5294
|
});
|
|
5276
5295
|
const yConstraint = new UIVerticalDistanceConstraint(passive, active, {
|
|
5277
|
-
anchorA: options.anchorV
|
|
5278
|
-
anchorB: options.anchorV
|
|
5296
|
+
anchorA: (_c = options.anchorV) !== null && _c !== void 0 ? _c : COVER_CONSTRAINT_DEFAULT_ANCHOR,
|
|
5297
|
+
anchorB: (_d = options.anchorV) !== null && _d !== void 0 ? _d : COVER_CONSTRAINT_DEFAULT_ANCHOR,
|
|
5279
5298
|
orientation: options.orientation,
|
|
5280
5299
|
});
|
|
5281
5300
|
const widthConstraint = new UIHorizontalProportionConstraint(passive, active, {
|
|
@@ -5310,6 +5329,7 @@ class UIFitConstraintBuilder {
|
|
|
5310
5329
|
* @returns Created constraints
|
|
5311
5330
|
*/
|
|
5312
5331
|
static build(passive, active, options = {}) {
|
|
5332
|
+
var _a, _b, _c, _d;
|
|
5313
5333
|
if (options.anchorH !== undefined) {
|
|
5314
5334
|
assertValidNumber(options.anchorH, "UIFitConstraintBuilder.build.anchorH");
|
|
5315
5335
|
}
|
|
@@ -5323,13 +5343,13 @@ class UIFitConstraintBuilder {
|
|
|
5323
5343
|
});
|
|
5324
5344
|
}
|
|
5325
5345
|
const xConstraint = new UIHorizontalDistanceConstraint(passive, active, {
|
|
5326
|
-
anchorA: options.anchorH
|
|
5327
|
-
anchorB: options.anchorH
|
|
5346
|
+
anchorA: (_a = options.anchorH) !== null && _a !== void 0 ? _a : DEFAULT_ANCHOR,
|
|
5347
|
+
anchorB: (_b = options.anchorH) !== null && _b !== void 0 ? _b : DEFAULT_ANCHOR,
|
|
5328
5348
|
orientation: options.orientation,
|
|
5329
5349
|
});
|
|
5330
5350
|
const yConstraint = new UIVerticalDistanceConstraint(passive, active, {
|
|
5331
|
-
anchorA: options.anchorV
|
|
5332
|
-
anchorB: options.anchorV
|
|
5351
|
+
anchorA: (_c = options.anchorV) !== null && _c !== void 0 ? _c : DEFAULT_ANCHOR,
|
|
5352
|
+
anchorB: (_d = options.anchorV) !== null && _d !== void 0 ? _d : DEFAULT_ANCHOR,
|
|
5333
5353
|
orientation: options.orientation,
|
|
5334
5354
|
});
|
|
5335
5355
|
const widthConstraint = new UIHorizontalProportionConstraint(passive, active, {
|
|
@@ -5398,8 +5418,9 @@ class UIAnchor extends i {
|
|
|
5398
5418
|
* @param options - Configuration options
|
|
5399
5419
|
*/
|
|
5400
5420
|
constructor(layer, options) {
|
|
5401
|
-
|
|
5402
|
-
const
|
|
5421
|
+
var _a, _b;
|
|
5422
|
+
const x = (_a = options === null || options === void 0 ? void 0 : options.x) !== null && _a !== void 0 ? _a : ANCHOR_DEFAULT_X;
|
|
5423
|
+
const y = (_b = options === null || options === void 0 ? void 0 : options.y) !== null && _b !== void 0 ? _b : ANCHOR_DEFAULT_Y;
|
|
5403
5424
|
assertValidNumber(x, "UIAnchor.constructor.options.x");
|
|
5404
5425
|
assertValidNumber(y, "UIAnchor.constructor.options.y");
|
|
5405
5426
|
super();
|
|
@@ -5631,8 +5652,9 @@ class UITextureView extends i {
|
|
|
5631
5652
|
* @returns UV transform matrix
|
|
5632
5653
|
*/
|
|
5633
5654
|
calculateUVTransform(result = new Matrix3()) {
|
|
5634
|
-
|
|
5635
|
-
const
|
|
5655
|
+
var _a, _b, _c, _d;
|
|
5656
|
+
const atlasWidth = (_b = (_a = this._private_textureInternal.image) === null || _a === void 0 ? void 0 : _a.naturalWidth) !== null && _b !== void 0 ? _b : TEXTURE_DEFAULT_SIZE;
|
|
5657
|
+
const atlasHeight = (_d = (_c = this._private_textureInternal.image) === null || _c === void 0 ? void 0 : _c.naturalHeight) !== null && _d !== void 0 ? _d : TEXTURE_DEFAULT_SIZE;
|
|
5636
5658
|
if (this._private_rotatedInternal) {
|
|
5637
5659
|
const physicalWidth = this._private_frameHeight;
|
|
5638
5660
|
const physicalHeight = this._private_frameWidth;
|
|
@@ -5677,8 +5699,9 @@ class UITextureView extends i {
|
|
|
5677
5699
|
}
|
|
5678
5700
|
}
|
|
5679
5701
|
_private_setFromTexture(texture) {
|
|
5680
|
-
|
|
5681
|
-
const
|
|
5702
|
+
var _a, _b, _c, _d;
|
|
5703
|
+
const width = (_b = (_a = texture.image) === null || _a === void 0 ? void 0 : _a.naturalWidth) !== null && _b !== void 0 ? _b : TEXTURE_DEFAULT_SIZE;
|
|
5704
|
+
const height = (_d = (_c = texture.image) === null || _c === void 0 ? void 0 : _c.naturalHeight) !== null && _d !== void 0 ? _d : TEXTURE_DEFAULT_SIZE;
|
|
5682
5705
|
this._private_sourceWidth = width;
|
|
5683
5706
|
this._private_sourceHeight = height;
|
|
5684
5707
|
if (this.texture !== texture) {
|
|
@@ -5710,6 +5733,7 @@ class UITextureView extends i {
|
|
|
5710
5733
|
}
|
|
5711
5734
|
}
|
|
5712
5735
|
_private_setFromAtlasConfig(config) {
|
|
5736
|
+
var _a, _b;
|
|
5713
5737
|
assertValidPositiveNumber(config.sourceSize.w, "UITextureView.setFromAtlasConfig.config.sourceSize.w");
|
|
5714
5738
|
assertValidPositiveNumber(config.sourceSize.h, "UITextureView.setFromAtlasConfig.config.sourceSize.h");
|
|
5715
5739
|
assertValidNonNegativeNumber(config.frame.x, "UITextureView.setFromAtlasConfig.config.frame.x");
|
|
@@ -5729,8 +5753,8 @@ class UITextureView extends i {
|
|
|
5729
5753
|
this._private_textureInternal = config.texture;
|
|
5730
5754
|
this._private_textureDirtyInternal = true;
|
|
5731
5755
|
}
|
|
5732
|
-
const scale = config.scale
|
|
5733
|
-
const rotated = config.rotated
|
|
5756
|
+
const scale = (_a = config.scale) !== null && _a !== void 0 ? _a : 1;
|
|
5757
|
+
const rotated = (_b = config.rotated) !== null && _b !== void 0 ? _b : false;
|
|
5734
5758
|
if (this._private_frameX !== 0 ||
|
|
5735
5759
|
this._private_frameY !== 0 ||
|
|
5736
5760
|
this._private_frameWidth !== config.frame.w ||
|
|
@@ -5773,15 +5797,16 @@ class UIMicro {
|
|
|
5773
5797
|
* @param config - Transform configuration
|
|
5774
5798
|
*/
|
|
5775
5799
|
constructor(config) {
|
|
5800
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
5776
5801
|
this._private_dirtyInternal = true;
|
|
5777
|
-
this._private_xInternal = config
|
|
5778
|
-
this._private_yInternal = config
|
|
5779
|
-
this._private_anchorXInternal = config
|
|
5780
|
-
this._private_anchorYInternal = config
|
|
5781
|
-
this._private_scaleXInternal = config
|
|
5782
|
-
this._private_scaleYInternal = config
|
|
5783
|
-
this._private_rotationInternal = config
|
|
5784
|
-
this._private_anchorModeInternal = config
|
|
5802
|
+
this._private_xInternal = (_a = config === null || config === void 0 ? void 0 : config.x) !== null && _a !== void 0 ? _a : MICRO_DEFAULT_POSITION;
|
|
5803
|
+
this._private_yInternal = (_b = config === null || config === void 0 ? void 0 : config.y) !== null && _b !== void 0 ? _b : MICRO_DEFAULT_POSITION;
|
|
5804
|
+
this._private_anchorXInternal = (_c = config === null || config === void 0 ? void 0 : config.anchorX) !== null && _c !== void 0 ? _c : MICRO_DEFAULT_ANCHOR;
|
|
5805
|
+
this._private_anchorYInternal = (_d = config === null || config === void 0 ? void 0 : config.anchorY) !== null && _d !== void 0 ? _d : MICRO_DEFAULT_ANCHOR;
|
|
5806
|
+
this._private_scaleXInternal = (_e = config === null || config === void 0 ? void 0 : config.scaleX) !== null && _e !== void 0 ? _e : MICRO_DEFAULT_SCALE;
|
|
5807
|
+
this._private_scaleYInternal = (_f = config === null || config === void 0 ? void 0 : config.scaleY) !== null && _f !== void 0 ? _f : MICRO_DEFAULT_SCALE;
|
|
5808
|
+
this._private_rotationInternal = (_g = config === null || config === void 0 ? void 0 : config.rotation) !== null && _g !== void 0 ? _g : MICRO_DEFAULT_ROTATION;
|
|
5809
|
+
this._private_anchorModeInternal = (_h = config === null || config === void 0 ? void 0 : config.anchorMode) !== null && _h !== void 0 ? _h : MICRO_DEFAULT_ANCHOR_MODE;
|
|
5785
5810
|
}
|
|
5786
5811
|
/** X offset in world units */
|
|
5787
5812
|
get x() {
|
|
@@ -6006,8 +6031,9 @@ class UIInputDummy extends UIAnchor {
|
|
|
6006
6031
|
* @param options - Configuration options
|
|
6007
6032
|
*/
|
|
6008
6033
|
constructor(layer, options) {
|
|
6009
|
-
|
|
6010
|
-
const
|
|
6034
|
+
var _a, _b, _c, _d;
|
|
6035
|
+
const w = (_a = options === null || options === void 0 ? void 0 : options.width) !== null && _a !== void 0 ? _a : DUMMY_DEFAULT_WIDTH;
|
|
6036
|
+
const h = (_b = options === null || options === void 0 ? void 0 : options.height) !== null && _b !== void 0 ? _b : DUMMY_DEFAULT_HEIGHT;
|
|
6011
6037
|
assertValidPositiveNumber(w, "UIInputDummy.constructor.width");
|
|
6012
6038
|
assertValidPositiveNumber(h, "UIInputDummy.constructor.height");
|
|
6013
6039
|
super(layer, options);
|
|
@@ -6022,8 +6048,8 @@ class UIInputDummy extends UIAnchor {
|
|
|
6022
6048
|
return this.handleInputEvent(x, y, identifier, UIInputEvent.RELEASED);
|
|
6023
6049
|
};
|
|
6024
6050
|
this.interactionArea =
|
|
6025
|
-
options
|
|
6026
|
-
this.modeInternal = options
|
|
6051
|
+
(_c = options === null || options === void 0 ? void 0 : options.interactionArea) !== null && _c !== void 0 ? _c : new UIAreaRectangle(0, 0, 1, 1);
|
|
6052
|
+
this.modeInternal = (_d = options === null || options === void 0 ? void 0 : options.mode) !== null && _d !== void 0 ? _d : DUMMY_DEFAULT_MODE;
|
|
6027
6053
|
this.inputWrapper = this.layer.inputWrapper;
|
|
6028
6054
|
this.wVariable = this.solverWrapper.createVariable(w, UIPriority.P6);
|
|
6029
6055
|
this.hVariable = this.solverWrapper.createVariable(h, UIPriority.P6);
|
|
@@ -6144,14 +6170,15 @@ class UIElement extends UIInputDummy {
|
|
|
6144
6170
|
* @param options - Configuration options
|
|
6145
6171
|
*/
|
|
6146
6172
|
constructor(layer, source, properties, options) {
|
|
6173
|
+
var _a, _b;
|
|
6147
6174
|
super(layer, options);
|
|
6148
6175
|
this._private_transparencyModeDirty = false;
|
|
6149
6176
|
this._private_visibilityDirty = false;
|
|
6150
|
-
this.micro = new UIMicro(options
|
|
6177
|
+
this.micro = new UIMicro(options === null || options === void 0 ? void 0 : options.micro);
|
|
6151
6178
|
this._private_transparencyModeInternal =
|
|
6152
|
-
options
|
|
6179
|
+
(_a = options === null || options === void 0 ? void 0 : options.transparencyMode) !== null && _a !== void 0 ? _a : ELEMENT_DEFAULT_TRANSPARENCY_MODE;
|
|
6153
6180
|
this.sceneWrapper = this.layer.sceneWrapper;
|
|
6154
|
-
this.planeHandler = this.sceneWrapper.createPlane(source, properties, new Matrix4().identity(), isUIModeVisible(options
|
|
6181
|
+
this.planeHandler = this.sceneWrapper.createPlane(source, properties, new Matrix4().identity(), isUIModeVisible((_b = options === null || options === void 0 ? void 0 : options.mode) !== null && _b !== void 0 ? _b : this.mode), this._private_transparencyModeInternal);
|
|
6155
6182
|
this.layer.on(UILayerEvent.RENDERING, this.onWillRender, this);
|
|
6156
6183
|
}
|
|
6157
6184
|
/** Alpha blending mode */
|
|
@@ -6236,11 +6263,12 @@ class UIAnimatedImage extends UIElement {
|
|
|
6236
6263
|
* @param options - Configuration options
|
|
6237
6264
|
*/
|
|
6238
6265
|
constructor(layer, sequence, options = {}) {
|
|
6266
|
+
var _a, _b, _c, _d, _e;
|
|
6239
6267
|
const color = new UIColor(options.color);
|
|
6240
6268
|
const uiTextures = sequence.map((textureConfig) => new UITextureView(textureConfig));
|
|
6241
6269
|
const frame = uiTextures[0];
|
|
6242
|
-
options.width = options.width
|
|
6243
|
-
options.height = options.height
|
|
6270
|
+
options.width = (_a = options.width) !== null && _a !== void 0 ? _a : frame.width;
|
|
6271
|
+
options.height = (_b = options.height) !== null && _b !== void 0 ? _b : frame.height;
|
|
6244
6272
|
const textureTransform = frame.calculateUVTransform();
|
|
6245
6273
|
super(layer, source$4, {
|
|
6246
6274
|
texture: frame.texture,
|
|
@@ -6261,11 +6289,11 @@ class UIAnimatedImage extends UIElement {
|
|
|
6261
6289
|
this._private_sequenceInternal = uiTextures;
|
|
6262
6290
|
this._private_textureTransform = textureTransform;
|
|
6263
6291
|
this._private_frameRateInternal =
|
|
6264
|
-
options.frameRate
|
|
6292
|
+
(_c = options.frameRate) !== null && _c !== void 0 ? _c : ANIMATED_IMAGE_DEFAULT_FRAME_RATE;
|
|
6265
6293
|
this._private_timeScaleInternal =
|
|
6266
|
-
options.timeScale
|
|
6294
|
+
(_d = options.timeScale) !== null && _d !== void 0 ? _d : ANIMATED_IMAGE_DEFAULT_TIME_SCALE;
|
|
6267
6295
|
this._private_loopModeInternal =
|
|
6268
|
-
options.loopMode
|
|
6296
|
+
(_e = options.loopMode) !== null && _e !== void 0 ? _e : ANIMATED_IMAGE_DEFAULT_LOOP_MODE;
|
|
6269
6297
|
this._private_subscribeSequenceEvents();
|
|
6270
6298
|
if (options.playByDefault === true) {
|
|
6271
6299
|
this.play();
|
|
@@ -6419,18 +6447,18 @@ class UIAnimatedImage extends UIElement {
|
|
|
6419
6447
|
setPlaneTransform() {
|
|
6420
6448
|
let properties;
|
|
6421
6449
|
if (this._private_colorInternal.dirty) {
|
|
6422
|
-
properties
|
|
6450
|
+
properties !== null && properties !== void 0 ? properties : (properties = {});
|
|
6423
6451
|
properties["color"] = this._private_colorInternal;
|
|
6424
6452
|
this._private_colorInternal.setDirtyFalse();
|
|
6425
6453
|
}
|
|
6426
6454
|
const frame = this._private_sequenceInternal[this._private_sequenceFrameIndex];
|
|
6427
6455
|
if (frame.textureDirty || this._private_currentFrameIndexDirty) {
|
|
6428
|
-
properties
|
|
6456
|
+
properties !== null && properties !== void 0 ? properties : (properties = {});
|
|
6429
6457
|
properties["texture"] = frame.texture;
|
|
6430
6458
|
frame.setTextureDirtyFalse();
|
|
6431
6459
|
}
|
|
6432
6460
|
if (frame.uvTransformDirty || this._private_currentFrameIndexDirty) {
|
|
6433
|
-
properties
|
|
6461
|
+
properties !== null && properties !== void 0 ? properties : (properties = {});
|
|
6434
6462
|
properties["textureTransform"] = frame.calculateUVTransform(this._private_textureTransform);
|
|
6435
6463
|
frame.setUVTransformDirtyFalse();
|
|
6436
6464
|
}
|
|
@@ -6463,6 +6491,24 @@ class UIAnimatedImage extends UIElement {
|
|
|
6463
6491
|
}
|
|
6464
6492
|
}
|
|
6465
6493
|
|
|
6494
|
+
/**
|
|
6495
|
+
* Creates a canvas with OffscreenCanvas fallback to HTMLCanvasElement.
|
|
6496
|
+
* Uses OffscreenCanvas when available, falls back to HTMLCanvasElement otherwise.
|
|
6497
|
+
*
|
|
6498
|
+
* @param width - Canvas width in pixels
|
|
6499
|
+
* @param height - Canvas height in pixels
|
|
6500
|
+
* @returns Canvas instance
|
|
6501
|
+
*/
|
|
6502
|
+
function createCanvas(width, height) {
|
|
6503
|
+
if (typeof OffscreenCanvas !== "undefined") {
|
|
6504
|
+
return new OffscreenCanvas(width, height);
|
|
6505
|
+
}
|
|
6506
|
+
const canvas = document.createElement("canvas");
|
|
6507
|
+
canvas.width = width;
|
|
6508
|
+
canvas.height = height;
|
|
6509
|
+
return canvas;
|
|
6510
|
+
}
|
|
6511
|
+
|
|
6466
6512
|
const GRAPHICS_DEFAULT_WIDTH = 2;
|
|
6467
6513
|
const GRAPHICS_DEFAULT_HEIGHT = 2;
|
|
6468
6514
|
const GRAPHICS_TEMP_COLOR = new UIColor();
|
|
@@ -6476,13 +6522,14 @@ class UIGraphics extends UIElement {
|
|
|
6476
6522
|
* @param options - Configuration options
|
|
6477
6523
|
*/
|
|
6478
6524
|
constructor(layer, options) {
|
|
6479
|
-
|
|
6480
|
-
const
|
|
6481
|
-
const
|
|
6482
|
-
const
|
|
6525
|
+
var _a, _b;
|
|
6526
|
+
const w = (_a = options === null || options === void 0 ? void 0 : options.width) !== null && _a !== void 0 ? _a : GRAPHICS_DEFAULT_WIDTH;
|
|
6527
|
+
const h = (_b = options === null || options === void 0 ? void 0 : options.height) !== null && _b !== void 0 ? _b : GRAPHICS_DEFAULT_HEIGHT;
|
|
6528
|
+
const color = new UIColor(options === null || options === void 0 ? void 0 : options.color);
|
|
6529
|
+
const canvas = createCanvas(w, h);
|
|
6483
6530
|
const context = canvas.getContext("2d");
|
|
6484
6531
|
if (!context) {
|
|
6485
|
-
throw new Error("UIGraphics.constructor: failed to get 2D context from
|
|
6532
|
+
throw new Error("UIGraphics.constructor: failed to get 2D context from canvas");
|
|
6486
6533
|
}
|
|
6487
6534
|
const texture = new CanvasTexture(canvas);
|
|
6488
6535
|
texture.colorSpace = SRGBColorSpace;
|
|
@@ -6600,11 +6647,12 @@ class UIImage extends UIElement {
|
|
|
6600
6647
|
* @param options - Configuration options
|
|
6601
6648
|
*/
|
|
6602
6649
|
constructor(layer, texture, options = {}) {
|
|
6650
|
+
var _a, _b;
|
|
6603
6651
|
const color = new UIColor(options.color);
|
|
6604
6652
|
const textureView = new UITextureView(texture);
|
|
6605
6653
|
const textureTransform = textureView.calculateUVTransform();
|
|
6606
|
-
options.width = options.width
|
|
6607
|
-
options.height = options.height
|
|
6654
|
+
options.width = (_a = options.width) !== null && _a !== void 0 ? _a : textureView.width;
|
|
6655
|
+
options.height = (_b = options.height) !== null && _b !== void 0 ? _b : textureView.height;
|
|
6608
6656
|
super(layer, source$4, {
|
|
6609
6657
|
texture: textureView.texture,
|
|
6610
6658
|
textureTransform: textureTransform,
|
|
@@ -6635,17 +6683,17 @@ class UIImage extends UIElement {
|
|
|
6635
6683
|
setPlaneTransform() {
|
|
6636
6684
|
let properties;
|
|
6637
6685
|
if (this._private_colorInternal.dirty) {
|
|
6638
|
-
properties
|
|
6686
|
+
properties !== null && properties !== void 0 ? properties : (properties = {});
|
|
6639
6687
|
properties["color"] = this._private_colorInternal;
|
|
6640
6688
|
this._private_colorInternal.setDirtyFalse();
|
|
6641
6689
|
}
|
|
6642
6690
|
if (this.texture.textureDirty) {
|
|
6643
|
-
properties
|
|
6691
|
+
properties !== null && properties !== void 0 ? properties : (properties = {});
|
|
6644
6692
|
properties["texture"] = this.texture.texture;
|
|
6645
6693
|
this.texture.setTextureDirtyFalse();
|
|
6646
6694
|
}
|
|
6647
6695
|
if (this.texture.uvTransformDirty) {
|
|
6648
|
-
properties
|
|
6696
|
+
properties !== null && properties !== void 0 ? properties : (properties = {});
|
|
6649
6697
|
properties["textureTransform"] = this.texture.calculateUVTransform(this._private_textureTransform);
|
|
6650
6698
|
this.texture.setUVTransformDirtyFalse();
|
|
6651
6699
|
}
|
|
@@ -6912,14 +6960,15 @@ class UINineSlice extends UIElement {
|
|
|
6912
6960
|
* @param options - Configuration options
|
|
6913
6961
|
*/
|
|
6914
6962
|
constructor(layer, texture, options = {}) {
|
|
6963
|
+
var _a, _b, _c, _d, _e;
|
|
6915
6964
|
const color = new UIColor(options.color);
|
|
6916
6965
|
const textureView = new UITextureView(texture);
|
|
6917
6966
|
const textureTransform = textureView.calculateUVTransform();
|
|
6918
|
-
options.width = options.width
|
|
6919
|
-
options.height = options.height
|
|
6920
|
-
const sliceBorders = new UIInsets(options.sliceBorders
|
|
6921
|
-
const sliceRegions = new UIInsets(options.sliceRegions
|
|
6922
|
-
const regionMode = options.regionMode
|
|
6967
|
+
options.width = (_a = options.width) !== null && _a !== void 0 ? _a : textureView.width;
|
|
6968
|
+
options.height = (_b = options.height) !== null && _b !== void 0 ? _b : textureView.height;
|
|
6969
|
+
const sliceBorders = new UIInsets((_c = options.sliceBorders) !== null && _c !== void 0 ? _c : NINE_SLICE_DEFAULT_BORDER);
|
|
6970
|
+
const sliceRegions = new UIInsets((_d = options.sliceRegions) !== null && _d !== void 0 ? _d : NINE_SLICE_DEFAULT_BORDER);
|
|
6971
|
+
const regionMode = (_e = options.regionMode) !== null && _e !== void 0 ? _e : NINE_SLICE_DEFAULT_REGION_MODE;
|
|
6923
6972
|
const sliceBordersVector = new Vector4();
|
|
6924
6973
|
const sliceRegionsVector = new Vector4();
|
|
6925
6974
|
super(layer, source$3, {
|
|
@@ -6994,7 +7043,7 @@ class UINineSlice extends UIElement {
|
|
|
6994
7043
|
this._private_sliceBordersInternal.dirty ||
|
|
6995
7044
|
this.texture.trimDirty;
|
|
6996
7045
|
if (sliceBordersDirty) {
|
|
6997
|
-
properties
|
|
7046
|
+
properties !== null && properties !== void 0 ? properties : (properties = {});
|
|
6998
7047
|
properties["sliceBorders"] = this._private_calculateSliceBordersForShader(this._private_sliceBordersVector);
|
|
6999
7048
|
this._private_sliceBordersInternal.setDirtyFalse();
|
|
7000
7049
|
this._private_textureDimensionsDirty = false;
|
|
@@ -7003,24 +7052,24 @@ class UINineSlice extends UIElement {
|
|
|
7003
7052
|
(this._private_regionModeInternal === UINineSliceRegionMode.WORLD &&
|
|
7004
7053
|
this._private_checkElementDimensionsDirty());
|
|
7005
7054
|
if (sliceRegionsDirty) {
|
|
7006
|
-
properties
|
|
7055
|
+
properties !== null && properties !== void 0 ? properties : (properties = {});
|
|
7007
7056
|
properties["sliceRegions"] = this._private_calculateSliceRegionsForShader(this._private_sliceRegionsVector);
|
|
7008
7057
|
this._private_sliceRegionsInternal.setDirtyFalse();
|
|
7009
7058
|
this._private_regionModeDirty = false;
|
|
7010
7059
|
this._private_setElementDimensionsDirtyFalse();
|
|
7011
7060
|
}
|
|
7012
7061
|
if (this._private_colorInternal.dirty) {
|
|
7013
|
-
properties
|
|
7062
|
+
properties !== null && properties !== void 0 ? properties : (properties = {});
|
|
7014
7063
|
properties["color"] = this._private_colorInternal;
|
|
7015
7064
|
this._private_colorInternal.setDirtyFalse();
|
|
7016
7065
|
}
|
|
7017
7066
|
if (this.texture.textureDirty) {
|
|
7018
|
-
properties
|
|
7067
|
+
properties !== null && properties !== void 0 ? properties : (properties = {});
|
|
7019
7068
|
properties["texture"] = this.texture.texture;
|
|
7020
7069
|
this.texture.setTextureDirtyFalse();
|
|
7021
7070
|
}
|
|
7022
7071
|
if (this.texture.uvTransformDirty) {
|
|
7023
|
-
properties
|
|
7072
|
+
properties !== null && properties !== void 0 ? properties : (properties = {});
|
|
7024
7073
|
properties["textureTransform"] = this.texture.calculateUVTransform(this._private_textureTransform);
|
|
7025
7074
|
this.texture.setUVTransformDirtyFalse();
|
|
7026
7075
|
}
|
|
@@ -7158,6 +7207,7 @@ class UIProgress extends UIElement {
|
|
|
7158
7207
|
* @param options - Configuration options
|
|
7159
7208
|
*/
|
|
7160
7209
|
constructor(layer, texture, options = {}) {
|
|
7210
|
+
var _a, _b, _c, _d;
|
|
7161
7211
|
if (options.progress !== undefined) {
|
|
7162
7212
|
assertValidNumber(options.progress, "UIProgress.constructor.options.progress");
|
|
7163
7213
|
}
|
|
@@ -7165,18 +7215,14 @@ class UIProgress extends UIElement {
|
|
|
7165
7215
|
const textureView = new UITextureView(texture);
|
|
7166
7216
|
const textureTransform = textureView.calculateUVTransform();
|
|
7167
7217
|
const textureResolution = textureView.getResolution();
|
|
7168
|
-
options.width = options.width
|
|
7169
|
-
options.height = options.height
|
|
7170
|
-
const progress = MathUtils.clamp(options.progress
|
|
7171
|
-
const maskFunction = options.maskFunction
|
|
7172
|
-
super(layer, maskFunction.source + source$1, {
|
|
7173
|
-
texture: textureView.texture,
|
|
7174
|
-
textureTransform,
|
|
7218
|
+
options.width = (_a = options.width) !== null && _a !== void 0 ? _a : textureView.width;
|
|
7219
|
+
options.height = (_b = options.height) !== null && _b !== void 0 ? _b : textureView.height;
|
|
7220
|
+
const progress = MathUtils.clamp((_c = options.progress) !== null && _c !== void 0 ? _c : PROGRESS_DEFAULT_VALUE, 0, 1);
|
|
7221
|
+
const maskFunction = (_d = options.maskFunction) !== null && _d !== void 0 ? _d : new UIProgressMaskFunctionDirectional();
|
|
7222
|
+
super(layer, maskFunction.source + source$1, Object.assign({ texture: textureView.texture, textureTransform,
|
|
7175
7223
|
textureResolution,
|
|
7176
7224
|
color,
|
|
7177
|
-
progress,
|
|
7178
|
-
...maskFunction.enumerateProperties(),
|
|
7179
|
-
}, options);
|
|
7225
|
+
progress }, maskFunction.enumerateProperties()), options);
|
|
7180
7226
|
this._private_progressDirty = false;
|
|
7181
7227
|
this._private_textureResolutionDirty = false;
|
|
7182
7228
|
this._private_onTextureDimensionsChanged = (width, height) => {
|
|
@@ -7229,32 +7275,32 @@ class UIProgress extends UIElement {
|
|
|
7229
7275
|
setPlaneTransform() {
|
|
7230
7276
|
let properties;
|
|
7231
7277
|
if (this._private_colorInternal.dirty) {
|
|
7232
|
-
properties
|
|
7278
|
+
properties !== null && properties !== void 0 ? properties : (properties = {});
|
|
7233
7279
|
properties["color"] = this._private_colorInternal;
|
|
7234
7280
|
this._private_colorInternal.setDirtyFalse();
|
|
7235
7281
|
}
|
|
7236
7282
|
if (this.texture.textureDirty) {
|
|
7237
|
-
properties
|
|
7283
|
+
properties !== null && properties !== void 0 ? properties : (properties = {});
|
|
7238
7284
|
properties["texture"] = this.texture.texture;
|
|
7239
7285
|
this.texture.setTextureDirtyFalse();
|
|
7240
7286
|
}
|
|
7241
7287
|
if (this.texture.uvTransformDirty) {
|
|
7242
|
-
properties
|
|
7288
|
+
properties !== null && properties !== void 0 ? properties : (properties = {});
|
|
7243
7289
|
properties["textureTransform"] = this.texture.calculateUVTransform(this._private_textureTransform);
|
|
7244
7290
|
this.texture.setUVTransformDirtyFalse();
|
|
7245
7291
|
}
|
|
7246
7292
|
if (this._private_progressDirty) {
|
|
7247
|
-
properties
|
|
7293
|
+
properties !== null && properties !== void 0 ? properties : (properties = {});
|
|
7248
7294
|
properties["progress"] = this._private_progressInternal;
|
|
7249
7295
|
this._private_progressDirty = false;
|
|
7250
7296
|
}
|
|
7251
7297
|
if (this._private_textureResolutionDirty) {
|
|
7252
|
-
properties
|
|
7298
|
+
properties !== null && properties !== void 0 ? properties : (properties = {});
|
|
7253
7299
|
properties["textureResolution"] = this.texture.getResolution(this._private_textureResolution);
|
|
7254
7300
|
this._private_textureResolutionDirty = false;
|
|
7255
7301
|
}
|
|
7256
7302
|
if (this.maskFunction.dirty) {
|
|
7257
|
-
properties
|
|
7303
|
+
properties !== null && properties !== void 0 ? properties : (properties = {});
|
|
7258
7304
|
const maskProperties = this.maskFunction.enumerateProperties();
|
|
7259
7305
|
for (const key in maskProperties) {
|
|
7260
7306
|
properties[key] = maskProperties[key];
|
|
@@ -7280,14 +7326,7 @@ class UIProgress extends UIElement {
|
|
|
7280
7326
|
this.sceneWrapper.destroyPlane(this.planeHandler);
|
|
7281
7327
|
const micro = this.micro;
|
|
7282
7328
|
const textureTrim = this.texture.trim;
|
|
7283
|
-
this.planeHandler = this.sceneWrapper.createPlane(this._private_maskFunctionInternal.source + source$1, {
|
|
7284
|
-
texture: this.texture.texture,
|
|
7285
|
-
textureTransform: this.texture.calculateUVTransform(this._private_textureTransform),
|
|
7286
|
-
textureResolution: this.texture.getResolution(this._private_textureResolution),
|
|
7287
|
-
color: this._private_colorInternal,
|
|
7288
|
-
progress: this._private_progressInternal,
|
|
7289
|
-
...this._private_maskFunctionInternal.enumerateProperties(),
|
|
7290
|
-
}, computeTrimmedTransformMatrix(this.x, this.y, this.width, this.height, this.zIndex, micro.x, micro.y, micro.anchorX, micro.anchorY, micro.scaleX, micro.scaleY, micro.rotation, micro.anchorMode, textureTrim.left, textureTrim.right, textureTrim.top, textureTrim.bottom), isUIModeVisible(this.mode), this.transparencyMode);
|
|
7329
|
+
this.planeHandler = this.sceneWrapper.createPlane(this._private_maskFunctionInternal.source + source$1, Object.assign({ texture: this.texture.texture, textureTransform: this.texture.calculateUVTransform(this._private_textureTransform), textureResolution: this.texture.getResolution(this._private_textureResolution), color: this._private_colorInternal, progress: this._private_progressInternal }, this._private_maskFunctionInternal.enumerateProperties()), computeTrimmedTransformMatrix(this.x, this.y, this.width, this.height, this.zIndex, micro.x, micro.y, micro.anchorX, micro.anchorY, micro.scaleX, micro.scaleY, micro.rotation, micro.anchorMode, textureTrim.left, textureTrim.right, textureTrim.top, textureTrim.bottom), isUIModeVisible(this.mode), this.transparencyMode);
|
|
7291
7330
|
this._private_colorInternal.setDirtyFalse();
|
|
7292
7331
|
this.texture.setTextureDirtyFalse();
|
|
7293
7332
|
this.texture.setUVTransformDirtyFalse();
|
|
@@ -7333,18 +7372,19 @@ class UIScene extends UIElement {
|
|
|
7333
7372
|
* @throws If resolutionFactor outside range 0.1 to 2.0
|
|
7334
7373
|
*/
|
|
7335
7374
|
constructor(layer, options = {}) {
|
|
7375
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
7336
7376
|
if (options.resolutionFactor !== undefined) {
|
|
7337
7377
|
assertValidPositiveNumber(options.resolutionFactor, "UIScene.constructor.resolutionFactor");
|
|
7338
7378
|
}
|
|
7339
|
-
const resolutionFactor = MathUtils.clamp(options.resolutionFactor
|
|
7340
|
-
const w = options.width
|
|
7341
|
-
const h = options.height
|
|
7379
|
+
const resolutionFactor = MathUtils.clamp((_a = options.resolutionFactor) !== null && _a !== void 0 ? _a : SCENE_DEFAULT_RESOLUTION_FACTOR, SCENE_MIN_RESOLUTION_FACTOR, SCENE_MAX_RESOLUTION_FACTOR);
|
|
7380
|
+
const w = (_b = options.width) !== null && _b !== void 0 ? _b : DUMMY_DEFAULT_WIDTH;
|
|
7381
|
+
const h = (_c = options.height) !== null && _c !== void 0 ? _c : DUMMY_DEFAULT_HEIGHT;
|
|
7342
7382
|
const renderTarget = new WebGLRenderTarget(w * resolutionFactor, h * resolutionFactor, {
|
|
7343
7383
|
format: RGBAFormat,
|
|
7344
7384
|
minFilter: LinearFilter,
|
|
7345
7385
|
magFilter: LinearFilter,
|
|
7346
7386
|
type: UnsignedByteType,
|
|
7347
|
-
depthBuffer: options.enableDepthBuffer
|
|
7387
|
+
depthBuffer: (_d = options.enableDepthBuffer) !== null && _d !== void 0 ? _d : SCENE_DEFAULT_USE_DEPTH,
|
|
7348
7388
|
stencilBuffer: false,
|
|
7349
7389
|
});
|
|
7350
7390
|
const color = new UIColor(options.color);
|
|
@@ -7358,14 +7398,13 @@ class UIScene extends UIElement {
|
|
|
7358
7398
|
this._private_resolutionFactorDirty = false;
|
|
7359
7399
|
this._private_propertyDirty = false;
|
|
7360
7400
|
this._private_colorInternal = color;
|
|
7361
|
-
this._private_clearColorInternal = new UIColor(options.clearColor
|
|
7401
|
+
this._private_clearColorInternal = new UIColor((_e = options.clearColor) !== null && _e !== void 0 ? _e : SCENE_DEFAULT_CLEAR_COLOR);
|
|
7362
7402
|
this._private_renderTarget = renderTarget;
|
|
7363
|
-
this._private_sceneInternal = options.scene
|
|
7403
|
+
this._private_sceneInternal = (_f = options.scene) !== null && _f !== void 0 ? _f : new Scene();
|
|
7364
7404
|
this._private_cameraInternal =
|
|
7365
|
-
options.camera
|
|
7366
|
-
new PerspectiveCamera(SCENE_DEFAULT_CAMERA_FOV, w / h, SCENE_DEFAULT_CAMERA_NEAR, SCENE_DEFAULT_CAMERA_FAR);
|
|
7405
|
+
(_g = options.camera) !== null && _g !== void 0 ? _g : new PerspectiveCamera(SCENE_DEFAULT_CAMERA_FOV, w / h, SCENE_DEFAULT_CAMERA_NEAR, SCENE_DEFAULT_CAMERA_FAR);
|
|
7367
7406
|
this._private_resolutionFactorInternal = resolutionFactor;
|
|
7368
|
-
this._private_updateModeInternal = options.updateMode
|
|
7407
|
+
this._private_updateModeInternal = (_h = options.updateMode) !== null && _h !== void 0 ? _h : SCENE_DEFAULT_UPDATE_MODE;
|
|
7369
7408
|
this._private_propertyDirty = options.updateMode !== UISceneUpdateMode.MANUAL;
|
|
7370
7409
|
}
|
|
7371
7410
|
/** Camera used for rendering */
|
|
@@ -7492,21 +7531,21 @@ class UITextStyle {
|
|
|
7492
7531
|
/** @param config Partial style configuration. Unspecified properties remain undefined. */
|
|
7493
7532
|
constructor(config) {
|
|
7494
7533
|
this._private_dirtyInternal = true;
|
|
7495
|
-
this._private_colorInternal = config
|
|
7496
|
-
this._private_alignInternal = config
|
|
7497
|
-
this._private_fontFamilyInternal = config
|
|
7498
|
-
this._private_fontSizeInternal = config
|
|
7499
|
-
this._private_fontStyleInternal = config
|
|
7500
|
-
this._private_fontWeightInternal = config
|
|
7501
|
-
this._private_lineHeightInternal = config
|
|
7502
|
-
this._private_enableShadowInternal = config
|
|
7503
|
-
this._private_shadowOffsetXInternal = config
|
|
7504
|
-
this._private_shadowOffsetYInternal = config
|
|
7505
|
-
this._private_shadowBlurInternal = config
|
|
7506
|
-
this._private_shadowColorInternal = config
|
|
7507
|
-
this._private_enableStrokeInternal = config
|
|
7508
|
-
this._private_strokeColorInternal = config
|
|
7509
|
-
this._private_strokeThicknessInternal = config
|
|
7534
|
+
this._private_colorInternal = config === null || config === void 0 ? void 0 : config.color;
|
|
7535
|
+
this._private_alignInternal = config === null || config === void 0 ? void 0 : config.align;
|
|
7536
|
+
this._private_fontFamilyInternal = config === null || config === void 0 ? void 0 : config.fontFamily;
|
|
7537
|
+
this._private_fontSizeInternal = config === null || config === void 0 ? void 0 : config.fontSize;
|
|
7538
|
+
this._private_fontStyleInternal = config === null || config === void 0 ? void 0 : config.fontStyle;
|
|
7539
|
+
this._private_fontWeightInternal = config === null || config === void 0 ? void 0 : config.fontWeight;
|
|
7540
|
+
this._private_lineHeightInternal = config === null || config === void 0 ? void 0 : config.lineHeight;
|
|
7541
|
+
this._private_enableShadowInternal = config === null || config === void 0 ? void 0 : config.enableShadow;
|
|
7542
|
+
this._private_shadowOffsetXInternal = config === null || config === void 0 ? void 0 : config.shadowOffsetX;
|
|
7543
|
+
this._private_shadowOffsetYInternal = config === null || config === void 0 ? void 0 : config.shadowOffsetY;
|
|
7544
|
+
this._private_shadowBlurInternal = config === null || config === void 0 ? void 0 : config.shadowBlur;
|
|
7545
|
+
this._private_shadowColorInternal = config === null || config === void 0 ? void 0 : config.shadowColor;
|
|
7546
|
+
this._private_enableStrokeInternal = config === null || config === void 0 ? void 0 : config.enableStroke;
|
|
7547
|
+
this._private_strokeColorInternal = config === null || config === void 0 ? void 0 : config.strokeColor;
|
|
7548
|
+
this._private_strokeThicknessInternal = config === null || config === void 0 ? void 0 : config.strokeThickness;
|
|
7510
7549
|
}
|
|
7511
7550
|
/** Text color */
|
|
7512
7551
|
get color() {
|
|
@@ -7694,38 +7733,24 @@ class UITextStyle {
|
|
|
7694
7733
|
* @returns Complete style configuration with all defaults applied
|
|
7695
7734
|
*/
|
|
7696
7735
|
static resolve(primary, fallback) {
|
|
7697
|
-
|
|
7698
|
-
|
|
7736
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5;
|
|
7737
|
+
const fontSize = (_b = (_a = primary._private_fontSizeInternal) !== null && _a !== void 0 ? _a : fallback._private_fontSizeInternal) !== null && _b !== void 0 ? _b : TEXT_STYLE_DEFAULT_FONT_SIZE;
|
|
7699
7738
|
return {
|
|
7700
|
-
color: primary._private_colorInternal
|
|
7701
|
-
|
|
7702
|
-
|
|
7703
|
-
TEXT_STYLE_DEFAULT_ALIGN,
|
|
7704
|
-
fontFamily: primary._private_fontFamilyInternal ?? fallback._private_fontFamilyInternal ??
|
|
7705
|
-
TEXT_STYLE_DEFAULT_FONT_FAMILY,
|
|
7739
|
+
color: (_d = (_c = primary._private_colorInternal) !== null && _c !== void 0 ? _c : fallback._private_colorInternal) !== null && _d !== void 0 ? _d : TEXT_STYLE_DEFAULT_COLOR,
|
|
7740
|
+
align: (_f = (_e = primary._private_alignInternal) !== null && _e !== void 0 ? _e : fallback._private_alignInternal) !== null && _f !== void 0 ? _f : TEXT_STYLE_DEFAULT_ALIGN,
|
|
7741
|
+
fontFamily: (_h = (_g = primary._private_fontFamilyInternal) !== null && _g !== void 0 ? _g : fallback._private_fontFamilyInternal) !== null && _h !== void 0 ? _h : TEXT_STYLE_DEFAULT_FONT_FAMILY,
|
|
7706
7742
|
fontSize,
|
|
7707
|
-
fontStyle: primary._private_fontStyleInternal
|
|
7708
|
-
|
|
7709
|
-
|
|
7710
|
-
|
|
7711
|
-
|
|
7712
|
-
|
|
7713
|
-
|
|
7714
|
-
|
|
7715
|
-
|
|
7716
|
-
|
|
7717
|
-
|
|
7718
|
-
TEXT_STYLE_DEFAULT_SHADOW_OFFSET_Y,
|
|
7719
|
-
shadowBlur: primary._private_shadowBlurInternal ?? fallback._private_shadowBlurInternal ??
|
|
7720
|
-
TEXT_STYLE_DEFAULT_SHADOW_BLUR,
|
|
7721
|
-
shadowColor: primary._private_shadowColorInternal ?? fallback._private_shadowColorInternal ??
|
|
7722
|
-
TEXT_STYLE_DEFAULT_SHADOW_COLOR,
|
|
7723
|
-
enableStroke: primary._private_enableStrokeInternal ?? fallback._private_enableStrokeInternal ??
|
|
7724
|
-
TEXT_STYLE_DEFAULT_ENABLE_STROKE,
|
|
7725
|
-
strokeColor: primary._private_strokeColorInternal ?? fallback._private_strokeColorInternal ??
|
|
7726
|
-
TEXT_STYLE_DEFAULT_STROKE_COLOR,
|
|
7727
|
-
strokeThickness: primary._private_strokeThicknessInternal ?? fallback._private_strokeThicknessInternal ??
|
|
7728
|
-
TEXT_STYLE_DEFAULT_STROKE_THICKNESS,
|
|
7743
|
+
fontStyle: (_k = (_j = primary._private_fontStyleInternal) !== null && _j !== void 0 ? _j : fallback._private_fontStyleInternal) !== null && _k !== void 0 ? _k : TEXT_STYLE_DEFAULT_FONT_STYLE,
|
|
7744
|
+
fontWeight: (_m = (_l = primary._private_fontWeightInternal) !== null && _l !== void 0 ? _l : fallback._private_fontWeightInternal) !== null && _m !== void 0 ? _m : TEXT_STYLE_DEFAULT_FONT_WEIGHT,
|
|
7745
|
+
lineHeight: (_p = (_o = primary._private_lineHeightInternal) !== null && _o !== void 0 ? _o : fallback._private_lineHeightInternal) !== null && _p !== void 0 ? _p : fontSize * TEXT_STYLE_DEFAULT_LINE_HEIGHT,
|
|
7746
|
+
enableShadow: (_r = (_q = primary._private_enableShadowInternal) !== null && _q !== void 0 ? _q : fallback._private_enableShadowInternal) !== null && _r !== void 0 ? _r : TEXT_STYLE_DEFAULT_ENABLE_SHADOW,
|
|
7747
|
+
shadowOffsetX: (_t = (_s = primary._private_shadowOffsetXInternal) !== null && _s !== void 0 ? _s : fallback._private_shadowOffsetXInternal) !== null && _t !== void 0 ? _t : TEXT_STYLE_DEFAULT_SHADOW_OFFSET_X,
|
|
7748
|
+
shadowOffsetY: (_v = (_u = primary._private_shadowOffsetYInternal) !== null && _u !== void 0 ? _u : fallback._private_shadowOffsetYInternal) !== null && _v !== void 0 ? _v : TEXT_STYLE_DEFAULT_SHADOW_OFFSET_Y,
|
|
7749
|
+
shadowBlur: (_x = (_w = primary._private_shadowBlurInternal) !== null && _w !== void 0 ? _w : fallback._private_shadowBlurInternal) !== null && _x !== void 0 ? _x : TEXT_STYLE_DEFAULT_SHADOW_BLUR,
|
|
7750
|
+
shadowColor: (_z = (_y = primary._private_shadowColorInternal) !== null && _y !== void 0 ? _y : fallback._private_shadowColorInternal) !== null && _z !== void 0 ? _z : TEXT_STYLE_DEFAULT_SHADOW_COLOR,
|
|
7751
|
+
enableStroke: (_1 = (_0 = primary._private_enableStrokeInternal) !== null && _0 !== void 0 ? _0 : fallback._private_enableStrokeInternal) !== null && _1 !== void 0 ? _1 : TEXT_STYLE_DEFAULT_ENABLE_STROKE,
|
|
7752
|
+
strokeColor: (_3 = (_2 = primary._private_strokeColorInternal) !== null && _2 !== void 0 ? _2 : fallback._private_strokeColorInternal) !== null && _3 !== void 0 ? _3 : TEXT_STYLE_DEFAULT_STROKE_COLOR,
|
|
7753
|
+
strokeThickness: (_5 = (_4 = primary._private_strokeThicknessInternal) !== null && _4 !== void 0 ? _4 : fallback._private_strokeThicknessInternal) !== null && _5 !== void 0 ? _5 : TEXT_STYLE_DEFAULT_STROKE_THICKNESS,
|
|
7729
7754
|
};
|
|
7730
7755
|
}
|
|
7731
7756
|
/** @internal */
|
|
@@ -7844,14 +7869,15 @@ class UITextStyle {
|
|
|
7844
7869
|
* @returns Padding in pixels needed on all sides
|
|
7845
7870
|
*/
|
|
7846
7871
|
calculatePadding() {
|
|
7872
|
+
var _a, _b, _c, _d;
|
|
7847
7873
|
let padding = 0;
|
|
7848
7874
|
if (this._private_enableStrokeInternal !== undefined) {
|
|
7849
|
-
padding += this._private_strokeThicknessInternal
|
|
7875
|
+
padding += (_a = this._private_strokeThicknessInternal) !== null && _a !== void 0 ? _a : 0;
|
|
7850
7876
|
}
|
|
7851
7877
|
if (this._private_enableShadowInternal !== undefined) {
|
|
7852
|
-
const blur = this._private_shadowBlurInternal
|
|
7853
|
-
const offsetX = this._private_shadowOffsetXInternal
|
|
7854
|
-
const offsetY = this._private_shadowOffsetYInternal
|
|
7878
|
+
const blur = (_b = this._private_shadowBlurInternal) !== null && _b !== void 0 ? _b : 0;
|
|
7879
|
+
const offsetX = (_c = this._private_shadowOffsetXInternal) !== null && _c !== void 0 ? _c : 0;
|
|
7880
|
+
const offsetY = (_d = this._private_shadowOffsetYInternal) !== null && _d !== void 0 ? _d : 0;
|
|
7855
7881
|
const shadowSpread = blur * 2;
|
|
7856
7882
|
const shadowMaxX = Math.abs(offsetX) + shadowSpread;
|
|
7857
7883
|
const shadowMaxY = Math.abs(offsetY) + shadowSpread;
|
|
@@ -7911,7 +7937,8 @@ const TEXT_DEFAULT_RESIZE_MODE = UITextResizeMode.SCALE;
|
|
|
7911
7937
|
* @returns Array of words, spaces, and newlines
|
|
7912
7938
|
*/
|
|
7913
7939
|
function splitTextIntoChunks(text) {
|
|
7914
|
-
|
|
7940
|
+
var _a;
|
|
7941
|
+
return (_a = text.match(/\S+|\s|\n/g)) !== null && _a !== void 0 ? _a : [];
|
|
7915
7942
|
}
|
|
7916
7943
|
/**
|
|
7917
7944
|
* Measures single text chunk.
|
|
@@ -8088,6 +8115,7 @@ function renderTextChunk(x, y, text, style, context) {
|
|
|
8088
8115
|
* @param context Canvas rendering context
|
|
8089
8116
|
*/
|
|
8090
8117
|
function renderTextLines(paddingTop, paddingLeft, lines, context) {
|
|
8118
|
+
var _a, _b;
|
|
8091
8119
|
let currentY = paddingTop;
|
|
8092
8120
|
let textWidth = 0;
|
|
8093
8121
|
for (const line of lines) {
|
|
@@ -8095,7 +8123,7 @@ function renderTextLines(paddingTop, paddingLeft, lines, context) {
|
|
|
8095
8123
|
}
|
|
8096
8124
|
for (let i = 0; i < lines.length; i++) {
|
|
8097
8125
|
const line = lines[i];
|
|
8098
|
-
const firstAlign = line.chunks[0]
|
|
8126
|
+
const firstAlign = (_b = (_a = line.chunks[0]) === null || _a === void 0 ? void 0 : _a.style.align) !== null && _b !== void 0 ? _b : TEXT_STYLE_DEFAULT_ALIGN;
|
|
8099
8127
|
const isUniformAlign = line.chunks.every((c) => c.style.align === firstAlign);
|
|
8100
8128
|
const lineAlign = isUniformAlign ? firstAlign : TEXT_STYLE_DEFAULT_ALIGN;
|
|
8101
8129
|
let offsetX = 0;
|
|
@@ -8124,7 +8152,8 @@ class UIText extends UIElement {
|
|
|
8124
8152
|
* @param options - Configuration options
|
|
8125
8153
|
*/
|
|
8126
8154
|
constructor(layer, content, options = {}) {
|
|
8127
|
-
|
|
8155
|
+
var _a, _b;
|
|
8156
|
+
const canvas = createCanvas(2, 2);
|
|
8128
8157
|
const context = canvas.getContext("2d");
|
|
8129
8158
|
if (!context) {
|
|
8130
8159
|
throw new Error("UIText.constructor: failed to create canvas context");
|
|
@@ -8148,8 +8177,8 @@ class UIText extends UIElement {
|
|
|
8148
8177
|
this._private_paddingInternal = new UIInsets(options.padding);
|
|
8149
8178
|
this.commonStyle = new UITextStyle(options.commonStyle);
|
|
8150
8179
|
this._private_maxLineWidthInternal =
|
|
8151
|
-
options.maxLineWidth
|
|
8152
|
-
this._private_resizeModeInternal = options.resizeMode
|
|
8180
|
+
(_a = options.maxLineWidth) !== null && _a !== void 0 ? _a : TEXT_DEFAULT_MAX_LINE_WIDTH;
|
|
8181
|
+
this._private_resizeModeInternal = (_b = options.resizeMode) !== null && _b !== void 0 ? _b : TEXT_DEFAULT_RESIZE_MODE;
|
|
8153
8182
|
this._private_canvas = canvas;
|
|
8154
8183
|
this._private_context = context;
|
|
8155
8184
|
this._private_texture = texture;
|
|
@@ -8330,7 +8359,7 @@ class UIText extends UIElement {
|
|
|
8330
8359
|
_private_updateProperties(resolutionDirty) {
|
|
8331
8360
|
let properties;
|
|
8332
8361
|
if (this._private_colorInternal.dirty) {
|
|
8333
|
-
properties
|
|
8362
|
+
properties !== null && properties !== void 0 ? properties : (properties = {});
|
|
8334
8363
|
properties["color"] = this._private_colorInternal;
|
|
8335
8364
|
this._private_colorInternal.setDirtyFalse();
|
|
8336
8365
|
}
|
|
@@ -8339,7 +8368,7 @@ class UIText extends UIElement {
|
|
|
8339
8368
|
this._private_texture = new CanvasTexture(this._private_canvas);
|
|
8340
8369
|
this._private_texture.colorSpace = SRGBColorSpace;
|
|
8341
8370
|
this._private_texture.needsUpdate = true;
|
|
8342
|
-
properties
|
|
8371
|
+
properties !== null && properties !== void 0 ? properties : (properties = {});
|
|
8343
8372
|
properties["texture"] = this._private_texture;
|
|
8344
8373
|
}
|
|
8345
8374
|
if (properties) {
|
|
@@ -8395,13 +8424,10 @@ const FULLSCREEN_LAYER_DEFAULT_RESIZE_POLICY = new UIResizePolicyNone();
|
|
|
8395
8424
|
/** Layer that automatically handles browser window resizing and input events */
|
|
8396
8425
|
class UIFullscreenLayer extends UILayer {
|
|
8397
8426
|
constructor(options) {
|
|
8398
|
-
|
|
8427
|
+
var _a;
|
|
8428
|
+
const resizePolicy = (_a = options === null || options === void 0 ? void 0 : options.resizePolicy) !== null && _a !== void 0 ? _a : FULLSCREEN_LAYER_DEFAULT_RESIZE_POLICY;
|
|
8399
8429
|
const scale = resizePolicy.calculateScale(window.innerWidth, window.innerHeight);
|
|
8400
|
-
super({
|
|
8401
|
-
width: window.innerWidth * scale,
|
|
8402
|
-
height: window.innerHeight * scale,
|
|
8403
|
-
...options,
|
|
8404
|
-
});
|
|
8430
|
+
super(Object.assign({ width: window.innerWidth * scale, height: window.innerHeight * scale }, options));
|
|
8405
8431
|
this._private_resizePolicyDirty = false;
|
|
8406
8432
|
this._private_onResize = () => {
|
|
8407
8433
|
const scale = this.resizePolicy.calculateScale(window.innerWidth, window.innerHeight);
|