laymur 0.13.3 → 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/index.js +229 -221
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- 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
|
}
|
|
@@ -6494,9 +6522,10 @@ class UIGraphics extends UIElement {
|
|
|
6494
6522
|
* @param options - Configuration options
|
|
6495
6523
|
*/
|
|
6496
6524
|
constructor(layer, options) {
|
|
6497
|
-
|
|
6498
|
-
const
|
|
6499
|
-
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);
|
|
6500
6529
|
const canvas = createCanvas(w, h);
|
|
6501
6530
|
const context = canvas.getContext("2d");
|
|
6502
6531
|
if (!context) {
|
|
@@ -6618,11 +6647,12 @@ class UIImage extends UIElement {
|
|
|
6618
6647
|
* @param options - Configuration options
|
|
6619
6648
|
*/
|
|
6620
6649
|
constructor(layer, texture, options = {}) {
|
|
6650
|
+
var _a, _b;
|
|
6621
6651
|
const color = new UIColor(options.color);
|
|
6622
6652
|
const textureView = new UITextureView(texture);
|
|
6623
6653
|
const textureTransform = textureView.calculateUVTransform();
|
|
6624
|
-
options.width = options.width
|
|
6625
|
-
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;
|
|
6626
6656
|
super(layer, source$4, {
|
|
6627
6657
|
texture: textureView.texture,
|
|
6628
6658
|
textureTransform: textureTransform,
|
|
@@ -6653,17 +6683,17 @@ class UIImage extends UIElement {
|
|
|
6653
6683
|
setPlaneTransform() {
|
|
6654
6684
|
let properties;
|
|
6655
6685
|
if (this._private_colorInternal.dirty) {
|
|
6656
|
-
properties
|
|
6686
|
+
properties !== null && properties !== void 0 ? properties : (properties = {});
|
|
6657
6687
|
properties["color"] = this._private_colorInternal;
|
|
6658
6688
|
this._private_colorInternal.setDirtyFalse();
|
|
6659
6689
|
}
|
|
6660
6690
|
if (this.texture.textureDirty) {
|
|
6661
|
-
properties
|
|
6691
|
+
properties !== null && properties !== void 0 ? properties : (properties = {});
|
|
6662
6692
|
properties["texture"] = this.texture.texture;
|
|
6663
6693
|
this.texture.setTextureDirtyFalse();
|
|
6664
6694
|
}
|
|
6665
6695
|
if (this.texture.uvTransformDirty) {
|
|
6666
|
-
properties
|
|
6696
|
+
properties !== null && properties !== void 0 ? properties : (properties = {});
|
|
6667
6697
|
properties["textureTransform"] = this.texture.calculateUVTransform(this._private_textureTransform);
|
|
6668
6698
|
this.texture.setUVTransformDirtyFalse();
|
|
6669
6699
|
}
|
|
@@ -6930,14 +6960,15 @@ class UINineSlice extends UIElement {
|
|
|
6930
6960
|
* @param options - Configuration options
|
|
6931
6961
|
*/
|
|
6932
6962
|
constructor(layer, texture, options = {}) {
|
|
6963
|
+
var _a, _b, _c, _d, _e;
|
|
6933
6964
|
const color = new UIColor(options.color);
|
|
6934
6965
|
const textureView = new UITextureView(texture);
|
|
6935
6966
|
const textureTransform = textureView.calculateUVTransform();
|
|
6936
|
-
options.width = options.width
|
|
6937
|
-
options.height = options.height
|
|
6938
|
-
const sliceBorders = new UIInsets(options.sliceBorders
|
|
6939
|
-
const sliceRegions = new UIInsets(options.sliceRegions
|
|
6940
|
-
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;
|
|
6941
6972
|
const sliceBordersVector = new Vector4();
|
|
6942
6973
|
const sliceRegionsVector = new Vector4();
|
|
6943
6974
|
super(layer, source$3, {
|
|
@@ -7012,7 +7043,7 @@ class UINineSlice extends UIElement {
|
|
|
7012
7043
|
this._private_sliceBordersInternal.dirty ||
|
|
7013
7044
|
this.texture.trimDirty;
|
|
7014
7045
|
if (sliceBordersDirty) {
|
|
7015
|
-
properties
|
|
7046
|
+
properties !== null && properties !== void 0 ? properties : (properties = {});
|
|
7016
7047
|
properties["sliceBorders"] = this._private_calculateSliceBordersForShader(this._private_sliceBordersVector);
|
|
7017
7048
|
this._private_sliceBordersInternal.setDirtyFalse();
|
|
7018
7049
|
this._private_textureDimensionsDirty = false;
|
|
@@ -7021,24 +7052,24 @@ class UINineSlice extends UIElement {
|
|
|
7021
7052
|
(this._private_regionModeInternal === UINineSliceRegionMode.WORLD &&
|
|
7022
7053
|
this._private_checkElementDimensionsDirty());
|
|
7023
7054
|
if (sliceRegionsDirty) {
|
|
7024
|
-
properties
|
|
7055
|
+
properties !== null && properties !== void 0 ? properties : (properties = {});
|
|
7025
7056
|
properties["sliceRegions"] = this._private_calculateSliceRegionsForShader(this._private_sliceRegionsVector);
|
|
7026
7057
|
this._private_sliceRegionsInternal.setDirtyFalse();
|
|
7027
7058
|
this._private_regionModeDirty = false;
|
|
7028
7059
|
this._private_setElementDimensionsDirtyFalse();
|
|
7029
7060
|
}
|
|
7030
7061
|
if (this._private_colorInternal.dirty) {
|
|
7031
|
-
properties
|
|
7062
|
+
properties !== null && properties !== void 0 ? properties : (properties = {});
|
|
7032
7063
|
properties["color"] = this._private_colorInternal;
|
|
7033
7064
|
this._private_colorInternal.setDirtyFalse();
|
|
7034
7065
|
}
|
|
7035
7066
|
if (this.texture.textureDirty) {
|
|
7036
|
-
properties
|
|
7067
|
+
properties !== null && properties !== void 0 ? properties : (properties = {});
|
|
7037
7068
|
properties["texture"] = this.texture.texture;
|
|
7038
7069
|
this.texture.setTextureDirtyFalse();
|
|
7039
7070
|
}
|
|
7040
7071
|
if (this.texture.uvTransformDirty) {
|
|
7041
|
-
properties
|
|
7072
|
+
properties !== null && properties !== void 0 ? properties : (properties = {});
|
|
7042
7073
|
properties["textureTransform"] = this.texture.calculateUVTransform(this._private_textureTransform);
|
|
7043
7074
|
this.texture.setUVTransformDirtyFalse();
|
|
7044
7075
|
}
|
|
@@ -7176,6 +7207,7 @@ class UIProgress extends UIElement {
|
|
|
7176
7207
|
* @param options - Configuration options
|
|
7177
7208
|
*/
|
|
7178
7209
|
constructor(layer, texture, options = {}) {
|
|
7210
|
+
var _a, _b, _c, _d;
|
|
7179
7211
|
if (options.progress !== undefined) {
|
|
7180
7212
|
assertValidNumber(options.progress, "UIProgress.constructor.options.progress");
|
|
7181
7213
|
}
|
|
@@ -7183,18 +7215,14 @@ class UIProgress extends UIElement {
|
|
|
7183
7215
|
const textureView = new UITextureView(texture);
|
|
7184
7216
|
const textureTransform = textureView.calculateUVTransform();
|
|
7185
7217
|
const textureResolution = textureView.getResolution();
|
|
7186
|
-
options.width = options.width
|
|
7187
|
-
options.height = options.height
|
|
7188
|
-
const progress = MathUtils.clamp(options.progress
|
|
7189
|
-
const maskFunction = options.maskFunction
|
|
7190
|
-
super(layer, maskFunction.source + source$1, {
|
|
7191
|
-
texture: textureView.texture,
|
|
7192
|
-
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,
|
|
7193
7223
|
textureResolution,
|
|
7194
7224
|
color,
|
|
7195
|
-
progress,
|
|
7196
|
-
...maskFunction.enumerateProperties(),
|
|
7197
|
-
}, options);
|
|
7225
|
+
progress }, maskFunction.enumerateProperties()), options);
|
|
7198
7226
|
this._private_progressDirty = false;
|
|
7199
7227
|
this._private_textureResolutionDirty = false;
|
|
7200
7228
|
this._private_onTextureDimensionsChanged = (width, height) => {
|
|
@@ -7247,32 +7275,32 @@ class UIProgress extends UIElement {
|
|
|
7247
7275
|
setPlaneTransform() {
|
|
7248
7276
|
let properties;
|
|
7249
7277
|
if (this._private_colorInternal.dirty) {
|
|
7250
|
-
properties
|
|
7278
|
+
properties !== null && properties !== void 0 ? properties : (properties = {});
|
|
7251
7279
|
properties["color"] = this._private_colorInternal;
|
|
7252
7280
|
this._private_colorInternal.setDirtyFalse();
|
|
7253
7281
|
}
|
|
7254
7282
|
if (this.texture.textureDirty) {
|
|
7255
|
-
properties
|
|
7283
|
+
properties !== null && properties !== void 0 ? properties : (properties = {});
|
|
7256
7284
|
properties["texture"] = this.texture.texture;
|
|
7257
7285
|
this.texture.setTextureDirtyFalse();
|
|
7258
7286
|
}
|
|
7259
7287
|
if (this.texture.uvTransformDirty) {
|
|
7260
|
-
properties
|
|
7288
|
+
properties !== null && properties !== void 0 ? properties : (properties = {});
|
|
7261
7289
|
properties["textureTransform"] = this.texture.calculateUVTransform(this._private_textureTransform);
|
|
7262
7290
|
this.texture.setUVTransformDirtyFalse();
|
|
7263
7291
|
}
|
|
7264
7292
|
if (this._private_progressDirty) {
|
|
7265
|
-
properties
|
|
7293
|
+
properties !== null && properties !== void 0 ? properties : (properties = {});
|
|
7266
7294
|
properties["progress"] = this._private_progressInternal;
|
|
7267
7295
|
this._private_progressDirty = false;
|
|
7268
7296
|
}
|
|
7269
7297
|
if (this._private_textureResolutionDirty) {
|
|
7270
|
-
properties
|
|
7298
|
+
properties !== null && properties !== void 0 ? properties : (properties = {});
|
|
7271
7299
|
properties["textureResolution"] = this.texture.getResolution(this._private_textureResolution);
|
|
7272
7300
|
this._private_textureResolutionDirty = false;
|
|
7273
7301
|
}
|
|
7274
7302
|
if (this.maskFunction.dirty) {
|
|
7275
|
-
properties
|
|
7303
|
+
properties !== null && properties !== void 0 ? properties : (properties = {});
|
|
7276
7304
|
const maskProperties = this.maskFunction.enumerateProperties();
|
|
7277
7305
|
for (const key in maskProperties) {
|
|
7278
7306
|
properties[key] = maskProperties[key];
|
|
@@ -7298,14 +7326,7 @@ class UIProgress extends UIElement {
|
|
|
7298
7326
|
this.sceneWrapper.destroyPlane(this.planeHandler);
|
|
7299
7327
|
const micro = this.micro;
|
|
7300
7328
|
const textureTrim = this.texture.trim;
|
|
7301
|
-
this.planeHandler = this.sceneWrapper.createPlane(this._private_maskFunctionInternal.source + source$1, {
|
|
7302
|
-
texture: this.texture.texture,
|
|
7303
|
-
textureTransform: this.texture.calculateUVTransform(this._private_textureTransform),
|
|
7304
|
-
textureResolution: this.texture.getResolution(this._private_textureResolution),
|
|
7305
|
-
color: this._private_colorInternal,
|
|
7306
|
-
progress: this._private_progressInternal,
|
|
7307
|
-
...this._private_maskFunctionInternal.enumerateProperties(),
|
|
7308
|
-
}, 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);
|
|
7309
7330
|
this._private_colorInternal.setDirtyFalse();
|
|
7310
7331
|
this.texture.setTextureDirtyFalse();
|
|
7311
7332
|
this.texture.setUVTransformDirtyFalse();
|
|
@@ -7351,18 +7372,19 @@ class UIScene extends UIElement {
|
|
|
7351
7372
|
* @throws If resolutionFactor outside range 0.1 to 2.0
|
|
7352
7373
|
*/
|
|
7353
7374
|
constructor(layer, options = {}) {
|
|
7375
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
7354
7376
|
if (options.resolutionFactor !== undefined) {
|
|
7355
7377
|
assertValidPositiveNumber(options.resolutionFactor, "UIScene.constructor.resolutionFactor");
|
|
7356
7378
|
}
|
|
7357
|
-
const resolutionFactor = MathUtils.clamp(options.resolutionFactor
|
|
7358
|
-
const w = options.width
|
|
7359
|
-
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;
|
|
7360
7382
|
const renderTarget = new WebGLRenderTarget(w * resolutionFactor, h * resolutionFactor, {
|
|
7361
7383
|
format: RGBAFormat,
|
|
7362
7384
|
minFilter: LinearFilter,
|
|
7363
7385
|
magFilter: LinearFilter,
|
|
7364
7386
|
type: UnsignedByteType,
|
|
7365
|
-
depthBuffer: options.enableDepthBuffer
|
|
7387
|
+
depthBuffer: (_d = options.enableDepthBuffer) !== null && _d !== void 0 ? _d : SCENE_DEFAULT_USE_DEPTH,
|
|
7366
7388
|
stencilBuffer: false,
|
|
7367
7389
|
});
|
|
7368
7390
|
const color = new UIColor(options.color);
|
|
@@ -7376,14 +7398,13 @@ class UIScene extends UIElement {
|
|
|
7376
7398
|
this._private_resolutionFactorDirty = false;
|
|
7377
7399
|
this._private_propertyDirty = false;
|
|
7378
7400
|
this._private_colorInternal = color;
|
|
7379
|
-
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);
|
|
7380
7402
|
this._private_renderTarget = renderTarget;
|
|
7381
|
-
this._private_sceneInternal = options.scene
|
|
7403
|
+
this._private_sceneInternal = (_f = options.scene) !== null && _f !== void 0 ? _f : new Scene();
|
|
7382
7404
|
this._private_cameraInternal =
|
|
7383
|
-
options.camera
|
|
7384
|
-
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);
|
|
7385
7406
|
this._private_resolutionFactorInternal = resolutionFactor;
|
|
7386
|
-
this._private_updateModeInternal = options.updateMode
|
|
7407
|
+
this._private_updateModeInternal = (_h = options.updateMode) !== null && _h !== void 0 ? _h : SCENE_DEFAULT_UPDATE_MODE;
|
|
7387
7408
|
this._private_propertyDirty = options.updateMode !== UISceneUpdateMode.MANUAL;
|
|
7388
7409
|
}
|
|
7389
7410
|
/** Camera used for rendering */
|
|
@@ -7510,21 +7531,21 @@ class UITextStyle {
|
|
|
7510
7531
|
/** @param config Partial style configuration. Unspecified properties remain undefined. */
|
|
7511
7532
|
constructor(config) {
|
|
7512
7533
|
this._private_dirtyInternal = true;
|
|
7513
|
-
this._private_colorInternal = config
|
|
7514
|
-
this._private_alignInternal = config
|
|
7515
|
-
this._private_fontFamilyInternal = config
|
|
7516
|
-
this._private_fontSizeInternal = config
|
|
7517
|
-
this._private_fontStyleInternal = config
|
|
7518
|
-
this._private_fontWeightInternal = config
|
|
7519
|
-
this._private_lineHeightInternal = config
|
|
7520
|
-
this._private_enableShadowInternal = config
|
|
7521
|
-
this._private_shadowOffsetXInternal = config
|
|
7522
|
-
this._private_shadowOffsetYInternal = config
|
|
7523
|
-
this._private_shadowBlurInternal = config
|
|
7524
|
-
this._private_shadowColorInternal = config
|
|
7525
|
-
this._private_enableStrokeInternal = config
|
|
7526
|
-
this._private_strokeColorInternal = config
|
|
7527
|
-
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;
|
|
7528
7549
|
}
|
|
7529
7550
|
/** Text color */
|
|
7530
7551
|
get color() {
|
|
@@ -7712,38 +7733,24 @@ class UITextStyle {
|
|
|
7712
7733
|
* @returns Complete style configuration with all defaults applied
|
|
7713
7734
|
*/
|
|
7714
7735
|
static resolve(primary, fallback) {
|
|
7715
|
-
|
|
7716
|
-
|
|
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;
|
|
7717
7738
|
return {
|
|
7718
|
-
color: primary._private_colorInternal
|
|
7719
|
-
|
|
7720
|
-
|
|
7721
|
-
TEXT_STYLE_DEFAULT_ALIGN,
|
|
7722
|
-
fontFamily: primary._private_fontFamilyInternal ?? fallback._private_fontFamilyInternal ??
|
|
7723
|
-
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,
|
|
7724
7742
|
fontSize,
|
|
7725
|
-
fontStyle: primary._private_fontStyleInternal
|
|
7726
|
-
|
|
7727
|
-
|
|
7728
|
-
|
|
7729
|
-
|
|
7730
|
-
|
|
7731
|
-
|
|
7732
|
-
|
|
7733
|
-
|
|
7734
|
-
|
|
7735
|
-
|
|
7736
|
-
TEXT_STYLE_DEFAULT_SHADOW_OFFSET_Y,
|
|
7737
|
-
shadowBlur: primary._private_shadowBlurInternal ?? fallback._private_shadowBlurInternal ??
|
|
7738
|
-
TEXT_STYLE_DEFAULT_SHADOW_BLUR,
|
|
7739
|
-
shadowColor: primary._private_shadowColorInternal ?? fallback._private_shadowColorInternal ??
|
|
7740
|
-
TEXT_STYLE_DEFAULT_SHADOW_COLOR,
|
|
7741
|
-
enableStroke: primary._private_enableStrokeInternal ?? fallback._private_enableStrokeInternal ??
|
|
7742
|
-
TEXT_STYLE_DEFAULT_ENABLE_STROKE,
|
|
7743
|
-
strokeColor: primary._private_strokeColorInternal ?? fallback._private_strokeColorInternal ??
|
|
7744
|
-
TEXT_STYLE_DEFAULT_STROKE_COLOR,
|
|
7745
|
-
strokeThickness: primary._private_strokeThicknessInternal ?? fallback._private_strokeThicknessInternal ??
|
|
7746
|
-
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,
|
|
7747
7754
|
};
|
|
7748
7755
|
}
|
|
7749
7756
|
/** @internal */
|
|
@@ -7862,14 +7869,15 @@ class UITextStyle {
|
|
|
7862
7869
|
* @returns Padding in pixels needed on all sides
|
|
7863
7870
|
*/
|
|
7864
7871
|
calculatePadding() {
|
|
7872
|
+
var _a, _b, _c, _d;
|
|
7865
7873
|
let padding = 0;
|
|
7866
7874
|
if (this._private_enableStrokeInternal !== undefined) {
|
|
7867
|
-
padding += this._private_strokeThicknessInternal
|
|
7875
|
+
padding += (_a = this._private_strokeThicknessInternal) !== null && _a !== void 0 ? _a : 0;
|
|
7868
7876
|
}
|
|
7869
7877
|
if (this._private_enableShadowInternal !== undefined) {
|
|
7870
|
-
const blur = this._private_shadowBlurInternal
|
|
7871
|
-
const offsetX = this._private_shadowOffsetXInternal
|
|
7872
|
-
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;
|
|
7873
7881
|
const shadowSpread = blur * 2;
|
|
7874
7882
|
const shadowMaxX = Math.abs(offsetX) + shadowSpread;
|
|
7875
7883
|
const shadowMaxY = Math.abs(offsetY) + shadowSpread;
|
|
@@ -7929,7 +7937,8 @@ const TEXT_DEFAULT_RESIZE_MODE = UITextResizeMode.SCALE;
|
|
|
7929
7937
|
* @returns Array of words, spaces, and newlines
|
|
7930
7938
|
*/
|
|
7931
7939
|
function splitTextIntoChunks(text) {
|
|
7932
|
-
|
|
7940
|
+
var _a;
|
|
7941
|
+
return (_a = text.match(/\S+|\s|\n/g)) !== null && _a !== void 0 ? _a : [];
|
|
7933
7942
|
}
|
|
7934
7943
|
/**
|
|
7935
7944
|
* Measures single text chunk.
|
|
@@ -8106,6 +8115,7 @@ function renderTextChunk(x, y, text, style, context) {
|
|
|
8106
8115
|
* @param context Canvas rendering context
|
|
8107
8116
|
*/
|
|
8108
8117
|
function renderTextLines(paddingTop, paddingLeft, lines, context) {
|
|
8118
|
+
var _a, _b;
|
|
8109
8119
|
let currentY = paddingTop;
|
|
8110
8120
|
let textWidth = 0;
|
|
8111
8121
|
for (const line of lines) {
|
|
@@ -8113,7 +8123,7 @@ function renderTextLines(paddingTop, paddingLeft, lines, context) {
|
|
|
8113
8123
|
}
|
|
8114
8124
|
for (let i = 0; i < lines.length; i++) {
|
|
8115
8125
|
const line = lines[i];
|
|
8116
|
-
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;
|
|
8117
8127
|
const isUniformAlign = line.chunks.every((c) => c.style.align === firstAlign);
|
|
8118
8128
|
const lineAlign = isUniformAlign ? firstAlign : TEXT_STYLE_DEFAULT_ALIGN;
|
|
8119
8129
|
let offsetX = 0;
|
|
@@ -8142,6 +8152,7 @@ class UIText extends UIElement {
|
|
|
8142
8152
|
* @param options - Configuration options
|
|
8143
8153
|
*/
|
|
8144
8154
|
constructor(layer, content, options = {}) {
|
|
8155
|
+
var _a, _b;
|
|
8145
8156
|
const canvas = createCanvas(2, 2);
|
|
8146
8157
|
const context = canvas.getContext("2d");
|
|
8147
8158
|
if (!context) {
|
|
@@ -8166,8 +8177,8 @@ class UIText extends UIElement {
|
|
|
8166
8177
|
this._private_paddingInternal = new UIInsets(options.padding);
|
|
8167
8178
|
this.commonStyle = new UITextStyle(options.commonStyle);
|
|
8168
8179
|
this._private_maxLineWidthInternal =
|
|
8169
|
-
options.maxLineWidth
|
|
8170
|
-
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;
|
|
8171
8182
|
this._private_canvas = canvas;
|
|
8172
8183
|
this._private_context = context;
|
|
8173
8184
|
this._private_texture = texture;
|
|
@@ -8348,7 +8359,7 @@ class UIText extends UIElement {
|
|
|
8348
8359
|
_private_updateProperties(resolutionDirty) {
|
|
8349
8360
|
let properties;
|
|
8350
8361
|
if (this._private_colorInternal.dirty) {
|
|
8351
|
-
properties
|
|
8362
|
+
properties !== null && properties !== void 0 ? properties : (properties = {});
|
|
8352
8363
|
properties["color"] = this._private_colorInternal;
|
|
8353
8364
|
this._private_colorInternal.setDirtyFalse();
|
|
8354
8365
|
}
|
|
@@ -8357,7 +8368,7 @@ class UIText extends UIElement {
|
|
|
8357
8368
|
this._private_texture = new CanvasTexture(this._private_canvas);
|
|
8358
8369
|
this._private_texture.colorSpace = SRGBColorSpace;
|
|
8359
8370
|
this._private_texture.needsUpdate = true;
|
|
8360
|
-
properties
|
|
8371
|
+
properties !== null && properties !== void 0 ? properties : (properties = {});
|
|
8361
8372
|
properties["texture"] = this._private_texture;
|
|
8362
8373
|
}
|
|
8363
8374
|
if (properties) {
|
|
@@ -8413,13 +8424,10 @@ const FULLSCREEN_LAYER_DEFAULT_RESIZE_POLICY = new UIResizePolicyNone();
|
|
|
8413
8424
|
/** Layer that automatically handles browser window resizing and input events */
|
|
8414
8425
|
class UIFullscreenLayer extends UILayer {
|
|
8415
8426
|
constructor(options) {
|
|
8416
|
-
|
|
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;
|
|
8417
8429
|
const scale = resizePolicy.calculateScale(window.innerWidth, window.innerHeight);
|
|
8418
|
-
super({
|
|
8419
|
-
width: window.innerWidth * scale,
|
|
8420
|
-
height: window.innerHeight * scale,
|
|
8421
|
-
...options,
|
|
8422
|
-
});
|
|
8430
|
+
super(Object.assign({ width: window.innerWidth * scale, height: window.innerHeight * scale }, options));
|
|
8423
8431
|
this._private_resizePolicyDirty = false;
|
|
8424
8432
|
this._private_onResize = () => {
|
|
8425
8433
|
const scale = this.resizePolicy.calculateScale(window.innerWidth, window.innerHeight);
|