laymur 0.11.4 → 0.12.0
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/README.md +33 -29
- package/dist/constraints/{UIAspectConstraint.Internal.d.ts → UIAspectConstraint/UIAspectConstraint.Internal.d.ts} +1 -1
- package/dist/constraints/{UIAspectConstraint.d.ts → UIAspectConstraint/UIAspectConstraint.d.ts} +2 -2
- package/dist/constraints/UIConstraint.d.ts +2 -2
- package/dist/constraints/UICustomConstraint.d.ts +3 -3
- package/dist/constraints/{UIHeightConstraint.Internal.d.ts → UIHeightConstraint/UIHeightConstraint.Internal.d.ts} +1 -1
- package/dist/constraints/{UIHeightConstraint.d.ts → UIHeightConstraint/UIHeightConstraint.d.ts} +2 -2
- package/dist/constraints/{UIHorizontalDistanceConstraint.Internal.d.ts → UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.Internal.d.ts} +1 -1
- package/dist/constraints/{UIHorizontalDistanceConstraint.d.ts → UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.d.ts} +2 -2
- package/dist/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.Internal.d.ts +14 -0
- package/dist/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.d.ts +44 -0
- package/dist/constraints/{UIHorizontalProportionConstraint.Internal.d.ts → UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.Internal.d.ts} +1 -1
- package/dist/constraints/{UIHorizontalProportionConstraint.d.ts → UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.d.ts} +2 -2
- package/dist/constraints/{UISingleParameterConstraint.Internal.d.ts → UISingleParameterConstraint/UISingleParameterConstraint.Internal.d.ts} +5 -3
- package/dist/constraints/{UISingleParameterConstraint.d.ts → UISingleParameterConstraint/UISingleParameterConstraint.d.ts} +5 -5
- package/dist/constraints/{UIVerticalDistanceConstraint.Internal.d.ts → UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.Internal.d.ts} +1 -1
- package/dist/constraints/{UIVerticalDistanceConstraint.d.ts → UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.d.ts} +2 -2
- package/dist/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.Internal.d.ts +14 -0
- package/dist/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.d.ts +44 -0
- package/dist/constraints/{UIVerticalProportionConstraint.Internal.d.ts → UIVerticalProportionConstraint/UIVerticalProportionConstraint.Internal.d.ts} +1 -1
- package/dist/constraints/{UIVerticalProportionConstraint.d.ts → UIVerticalProportionConstraint/UIVerticalProportionConstraint.d.ts} +2 -2
- package/dist/constraints/{UIWidthConstraint.Internal.d.ts → UIWidthConstraint/UIWidthConstraint.Internal.d.ts} +1 -1
- package/dist/constraints/{UIWidthConstraint.d.ts → UIWidthConstraint/UIWidthConstraint.d.ts} +2 -2
- package/dist/constraints/builders/UIConstraint2DBuilder.Internal.d.ts +21 -2
- package/dist/constraints/builders/UIConstraint2DBuilder.d.ts +19 -8
- package/dist/constraints/builders/UICoverConstraintBuilder.d.ts +6 -6
- package/dist/constraints/builders/UIFitConstraintBuilder.d.ts +6 -6
- package/dist/elements/UIAnchor/UIAnchor.d.ts +2 -2
- package/dist/elements/UIAnimatedImage/UIAnimatedImage.Internal.d.ts +15 -3
- package/dist/elements/UIAnimatedImage/UIAnimatedImage.d.ts +12 -6
- package/dist/elements/UIElement/UIElement.d.ts +1 -1
- package/dist/elements/UIGraphics/UIGraphics.Internal.d.ts +0 -2
- package/dist/elements/UIGraphics/UIGraphics.d.ts +2 -2
- package/dist/elements/UIImage/UIImage.Internal.d.ts +0 -2
- package/dist/elements/UIImage/UIImage.d.ts +2 -2
- package/dist/elements/UIInputDummy/UIInputDummy.d.ts +2 -2
- package/dist/elements/UINineSlice/UINineSlice.d.ts +10 -6
- package/dist/elements/UIProgress/UIProgress.Internal.d.ts +0 -2
- package/dist/elements/UIProgress/UIProgress.d.ts +3 -3
- package/dist/elements/UIScene/UIScene.d.ts +1 -1
- package/dist/elements/UIText/UIText.d.ts +2 -2
- package/dist/index.d.ts +12 -9
- package/dist/index.js +851 -277
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/layers/UIFullscreenLayer/UIFullscreenLayer.Internal.d.ts +9 -0
- package/dist/layers/{UIFullscreenLayer.d.ts → UIFullscreenLayer/UIFullscreenLayer.d.ts} +4 -8
- package/dist/layers/UILayer/UILayer.Internal.d.ts +29 -0
- package/dist/layers/{UILayer.d.ts → UILayer/UILayer.d.ts} +4 -9
- package/dist/miscellaneous/asserts.d.ts +22 -55
- package/dist/miscellaneous/color/UIColor.d.ts +1 -0
- package/dist/miscellaneous/shared.d.ts +46 -0
- package/package.json +6 -3
- package/dist/layers/UILayer.Internal.d.ts +0 -15
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Color, Vector4, Texture, Vector2, Vector3, Matrix3, Matrix4, PlaneGeometry, InstancedBufferGeometry, ShaderMaterial, InstancedBufferAttribute, Mesh, Scene, OrthographicCamera, Quaternion,
|
|
1
|
+
import { Color, MathUtils, Vector4, Texture, Vector2, Vector3, Matrix3, Matrix4, PlaneGeometry, InstancedBufferGeometry, ShaderMaterial, InstancedBufferAttribute, Mesh, Scene, OrthographicCamera, Quaternion, CanvasTexture, SRGBColorSpace, LinearFilter, WebGLRenderTarget, UnsignedByteType, RGBAFormat, PerspectiveCamera, Ray } from 'three';
|
|
2
2
|
|
|
3
|
-
class t{constructor(t,i,r=0){this.t=new WeakMap,this.i=new Map,void 0!==t&&(void 0===i?this.i.set(t,r):this.t.set(i,new Map([[t,r]])));}insert(t,i,r=0){if(void 0===i){if(this.i.has(t))return;return void this.i.set(t,r)}const s=this.t.get(i);void 0===s?this.t.set(i,new Map([[t,r]])):s.has(t)||s.set(t,r);}remove(t,i){if(void 0===i)return void this.i.delete(t);const r=this.t.get(i);void 0!==r&&(r.delete(t),0===r.size&&this.t.delete(i));}has(t,i){if(void 0===i)return this.i.has(t);const r=this.t.get(i);return void 0!==r&&r.has(t)}getPriority(t,i){if(void 0===i)return this.i.get(t);const r=this.t.get(i);return void 0!==r?r.get(t):void 0}}class i{constructor(){this.o=new Map;}on(t,i,r,s=0){return this.h(t,false,s,i,r),this}once(t,i,r,s=0){return this.h(t,true,s,i,r),this}off(t,i,r){const s=this.o.get(t);if(void 0===s)return this;s.u&&(s.u=false,s.v=s.v.slice());const o=s.v;if(0===o.length)return this.o.delete(t),this;if(void 0===i){this.o.delete(t);for(let t=0;
|
|
3
|
+
class t{constructor(t,i,r=0){this.t=new WeakMap,this.i=new Map,void 0!==t&&(void 0===i?this.i.set(t,r):this.t.set(i,new Map([[t,r]])));}insert(t,i,r=0){if(void 0===i){if(this.i.has(t))return;return void this.i.set(t,r)}const s=this.t.get(i);void 0===s?this.t.set(i,new Map([[t,r]])):s.has(t)||s.set(t,r);}remove(t,i){if(void 0===i)return void this.i.delete(t);const r=this.t.get(i);void 0!==r&&(r.delete(t),0===r.size&&this.t.delete(i));}has(t,i){if(void 0===i)return this.i.has(t);const r=this.t.get(i);return void 0!==r&&r.has(t)}getPriority(t,i){if(void 0===i)return this.i.get(t);const r=this.t.get(i);return void 0!==r?r.get(t):void 0}}class i{constructor(){this.o=new Map;}on(t,i,r,s=0){return this.h(t,false,s,i,r),this}once(t,i,r,s=0){return this.h(t,true,s,i,r),this}off(t,i,r){const s=this.o.get(t);if(void 0===s)return this;s.u&&(s.u=false,s.v=s.v.slice());const o=s.v;if(0===o.length)return this.o.delete(t),this;if(void 0===i){this.o.delete(t);for(let t=0;o.length>t;t++){const i=o[t];s.l.remove(i._,i.p);}return this}{const e=o.length;if(o[0]._===i&&o[0].p===r)return 1===e?this.o.delete(t):o.shift(),this;const n=e-1;if(o[n]._===i&&o[n].p===r)return o.pop(),this;if(10>e||o[0].M===o[n].M)for(let t=1;n>t;t++){const s=o[t];if(s._===i&&s.p===r)return o.splice(t,1),this}else {const t=s.l.getPriority(i,r);if(void 0===t)return this;let e=0,n=o.length-1;for(;n>=e;){const i=e+n>>>1;t>o[i].M?e=i+1:n=i-1;}const c=e;for(n=o.length-1;n>=e;){const i=e+n>>>1;o[i].M>t?n=i-1:e=i+1;}const h=n;for(let t=c;h>=t;t++)if(o[t]._===i&&o[t].p===r)return o.splice(t,1),this}}return this}emit(t,...i){const r=this.o.get(t);if(void 0===r)return false;if(0===r.v.length)return false;r.u?r.v=r.v.slice():r.u=true;const s=r.v;let o=false;for(let t=0;s.length>t;t++){const r=s[t];r._.apply(r.p,i),r.k&&(o=true,r.m=true);}const e=this.o.get(t);if(void 0===e)return true;e.v===s&&(e.u=false);const n=e.v;if(o){let i=0;for(let t=0;n.length>t;t++){const r=n[t];r.m?e.l.remove(r._,r.p):n[i++]=r;}0===i?this.o.delete(t):n.length=i;}return true}h(i,r,s,o,e){let n=this.o.get(i);if(void 0===n)return void this.o.set(i,{v:[{_:o,p:e,M:s,k:r,m:false}],u:false,l:new t(o,e,s)});if(n.l.has(o,e))throw Error("Event listener already exists");n.l.insert(o,e,s);const c={_:o,p:e,M:s,k:r,m:false};n.u&&(n.u=false,n.v=n.v.slice());{const t=n.v,i=c.M;if(0===t.length||i>=t[t.length-1].M)return void t.push(c);if(t[0].M>=i)return void t.unshift(c);{let r=0,s=t.length;for(;s>r;){const o=r+s>>>1;i>t[o].M?r=o+1:s=o;}t.splice(r,0,c);}}}}
|
|
4
4
|
|
|
5
5
|
/** Visibility and interactivity state */
|
|
6
6
|
var UIMode;
|
|
@@ -2021,6 +2021,8 @@ class UIColor {
|
|
|
2021
2021
|
}
|
|
2022
2022
|
/** Red component (0 to 1) */
|
|
2023
2023
|
set r(value) {
|
|
2024
|
+
assertValidNumber(value, "UIColor.r");
|
|
2025
|
+
value = MathUtils.clamp(value, 0, 1);
|
|
2024
2026
|
this._private_ensureRGBUpdatedFromHSL();
|
|
2025
2027
|
if (value !== this._private_rInternal) {
|
|
2026
2028
|
this._private_rInternal = value;
|
|
@@ -2030,6 +2032,8 @@ class UIColor {
|
|
|
2030
2032
|
}
|
|
2031
2033
|
/** Green component (0 to 1) */
|
|
2032
2034
|
set g(value) {
|
|
2035
|
+
assertValidNumber(value, "UIColor.g");
|
|
2036
|
+
value = MathUtils.clamp(value, 0, 1);
|
|
2033
2037
|
this._private_ensureRGBUpdatedFromHSL();
|
|
2034
2038
|
if (value !== this._private_gInternal) {
|
|
2035
2039
|
this._private_gInternal = value;
|
|
@@ -2039,6 +2043,8 @@ class UIColor {
|
|
|
2039
2043
|
}
|
|
2040
2044
|
/** Blue component (0 to 1) */
|
|
2041
2045
|
set b(value) {
|
|
2046
|
+
assertValidNumber(value, "UIColor.b");
|
|
2047
|
+
value = MathUtils.clamp(value, 0, 1);
|
|
2042
2048
|
this._private_ensureRGBUpdatedFromHSL();
|
|
2043
2049
|
if (value !== this._private_bInternal) {
|
|
2044
2050
|
this._private_bInternal = value;
|
|
@@ -2048,6 +2054,8 @@ class UIColor {
|
|
|
2048
2054
|
}
|
|
2049
2055
|
/** Alpha component (0 to 1) */
|
|
2050
2056
|
set a(value) {
|
|
2057
|
+
assertValidNumber(value, "UIColor.a");
|
|
2058
|
+
value = MathUtils.clamp(value, 0, 1);
|
|
2051
2059
|
if (value !== this._private_aInternal) {
|
|
2052
2060
|
this._private_aInternal = value;
|
|
2053
2061
|
this._private_dirtyInternal = true;
|
|
@@ -2055,6 +2063,8 @@ class UIColor {
|
|
|
2055
2063
|
}
|
|
2056
2064
|
/** Hue component (0 to 360) */
|
|
2057
2065
|
set hue(value) {
|
|
2066
|
+
assertValidNumber(value, "UIColor.hue");
|
|
2067
|
+
value = MathUtils.clamp(value, 0, 360);
|
|
2058
2068
|
this._private_ensureHSLUpdatedFromRGB();
|
|
2059
2069
|
if (value !== this._private_hInternal) {
|
|
2060
2070
|
this._private_hInternal = value;
|
|
@@ -2064,6 +2074,8 @@ class UIColor {
|
|
|
2064
2074
|
}
|
|
2065
2075
|
/** Saturation component (0 to 1) */
|
|
2066
2076
|
set saturation(value) {
|
|
2077
|
+
assertValidNumber(value, "UIColor.saturation");
|
|
2078
|
+
value = MathUtils.clamp(value, 0, 1);
|
|
2067
2079
|
this._private_ensureHSLUpdatedFromRGB();
|
|
2068
2080
|
if (value !== this._private_sInternal) {
|
|
2069
2081
|
this._private_sInternal = value;
|
|
@@ -2073,6 +2085,8 @@ class UIColor {
|
|
|
2073
2085
|
}
|
|
2074
2086
|
/** Lightness component (0 to 1) */
|
|
2075
2087
|
set lightness(value) {
|
|
2088
|
+
assertValidNumber(value, "UIColor.lightness");
|
|
2089
|
+
value = MathUtils.clamp(value, 0, 1);
|
|
2076
2090
|
this._private_ensureHSLUpdatedFromRGB();
|
|
2077
2091
|
if (value !== this._private_lInternal) {
|
|
2078
2092
|
this._private_lInternal = value;
|
|
@@ -2086,6 +2100,14 @@ class UIColor {
|
|
|
2086
2100
|
}
|
|
2087
2101
|
/** Sets RGB(A) components */
|
|
2088
2102
|
set(r, g, b, a = this._private_aInternal) {
|
|
2103
|
+
assertValidNumber(r, "UIColor.set.r");
|
|
2104
|
+
assertValidNumber(g, "UIColor.set.g");
|
|
2105
|
+
assertValidNumber(b, "UIColor.set.b");
|
|
2106
|
+
assertValidNumber(a, "UIColor.set.a");
|
|
2107
|
+
r = MathUtils.clamp(r, 0, 1);
|
|
2108
|
+
g = MathUtils.clamp(g, 0, 1);
|
|
2109
|
+
b = MathUtils.clamp(b, 0, 1);
|
|
2110
|
+
a = MathUtils.clamp(a, 0, 1);
|
|
2089
2111
|
this._private_ensureRGBUpdatedFromHSL();
|
|
2090
2112
|
if (r !== this._private_rInternal ||
|
|
2091
2113
|
g !== this._private_gInternal ||
|
|
@@ -2127,6 +2149,7 @@ class UIColor {
|
|
|
2127
2149
|
}
|
|
2128
2150
|
/** Sets from 32-bit hex RGBA (RRGGBBAA) */
|
|
2129
2151
|
setHexRGBA(hex) {
|
|
2152
|
+
assertValidNumber(hex, "UIColor.setHexRGBA.hex");
|
|
2130
2153
|
this._private_ensureRGBUpdatedFromHSL();
|
|
2131
2154
|
const r = ((hex >> 16) & 0xff) / 255;
|
|
2132
2155
|
const g = ((hex >> 8) & 0xff) / 255;
|
|
@@ -2147,6 +2170,9 @@ class UIColor {
|
|
|
2147
2170
|
}
|
|
2148
2171
|
/** Sets from 24-bit hex RGB (RRGGBB) */
|
|
2149
2172
|
setHexRGB(hex, a = this._private_aInternal) {
|
|
2173
|
+
assertValidNumber(hex, "UIColor.setHexRGB.hex");
|
|
2174
|
+
assertValidNumber(a, "UIColor.setHexRGB.a");
|
|
2175
|
+
a = MathUtils.clamp(a, 0, 1);
|
|
2150
2176
|
this._private_ensureRGBUpdatedFromHSL();
|
|
2151
2177
|
const r = ((hex >> 16) & 0xff) / 255;
|
|
2152
2178
|
const g = ((hex >> 8) & 0xff) / 255;
|
|
@@ -2195,6 +2221,14 @@ class UIColor {
|
|
|
2195
2221
|
}
|
|
2196
2222
|
/** Sets from HSL values */
|
|
2197
2223
|
setHSL(h, s, l, a = this._private_aInternal) {
|
|
2224
|
+
assertValidNumber(h, "UIColor.setHSL.h");
|
|
2225
|
+
assertValidNumber(s, "UIColor.setHSL.s");
|
|
2226
|
+
assertValidNumber(l, "UIColor.setHSL.l");
|
|
2227
|
+
assertValidNumber(a, "UIColor.setHSL.a");
|
|
2228
|
+
h = MathUtils.clamp(h, 0, 360);
|
|
2229
|
+
s = MathUtils.clamp(s, 0, 1);
|
|
2230
|
+
l = MathUtils.clamp(l, 0, 1);
|
|
2231
|
+
a = MathUtils.clamp(a, 0, 1);
|
|
2198
2232
|
this._private_ensureHSLUpdatedFromRGB();
|
|
2199
2233
|
if (h !== this._private_hInternal ||
|
|
2200
2234
|
s !== this._private_sInternal ||
|
|
@@ -2215,6 +2249,8 @@ class UIColor {
|
|
|
2215
2249
|
* @throws If color name unknown
|
|
2216
2250
|
*/
|
|
2217
2251
|
setColorName(colorName, a = this._private_aInternal) {
|
|
2252
|
+
assertValidNumber(a, "UIColor.setColorName.a");
|
|
2253
|
+
a = MathUtils.clamp(a, 0, 1);
|
|
2218
2254
|
const normalizedName = colorName.toLowerCase().trim();
|
|
2219
2255
|
const hex = COLORS[normalizedName];
|
|
2220
2256
|
if (hex === undefined) {
|
|
@@ -2224,6 +2260,11 @@ class UIColor {
|
|
|
2224
2260
|
}
|
|
2225
2261
|
/** Sets from linear (GLSL) color space */
|
|
2226
2262
|
setGLSLColor(r, g, b, a = this._private_aInternal) {
|
|
2263
|
+
assertValidNumber(r, "UIColor.setGLSLColor.r");
|
|
2264
|
+
assertValidNumber(g, "UIColor.setGLSLColor.g");
|
|
2265
|
+
assertValidNumber(b, "UIColor.setGLSLColor.b");
|
|
2266
|
+
assertValidNumber(a, "UIColor.setGLSLColor.a");
|
|
2267
|
+
a = MathUtils.clamp(a, 0, 1);
|
|
2227
2268
|
this._private_ensureRGBUpdatedFromHSL();
|
|
2228
2269
|
const sRGBR = LinearToSRGB(r);
|
|
2229
2270
|
const sRGBG = LinearToSRGB(g);
|
|
@@ -2243,6 +2284,8 @@ class UIColor {
|
|
|
2243
2284
|
}
|
|
2244
2285
|
/** Sets from Three.js Color */
|
|
2245
2286
|
setThreeColor(threeColor, a = this._private_aInternal) {
|
|
2287
|
+
assertValidNumber(a, "UIColor.setThreeColor.a");
|
|
2288
|
+
a = MathUtils.clamp(a, 0, 1);
|
|
2246
2289
|
this._private_ensureRGBUpdatedFromHSL();
|
|
2247
2290
|
if (threeColor.r !== this._private_rInternal ||
|
|
2248
2291
|
threeColor.g !== this._private_gInternal ||
|
|
@@ -2345,7 +2388,6 @@ class UIColor {
|
|
|
2345
2388
|
this._private_rgbDirty = false;
|
|
2346
2389
|
}
|
|
2347
2390
|
}
|
|
2348
|
-
/** @internal */
|
|
2349
2391
|
_private_ensureHSLUpdatedFromRGB() {
|
|
2350
2392
|
if (this._private_hslDirty) {
|
|
2351
2393
|
const { _private_rInternal: r, _private_gInternal: g, _private_bInternal: b } = this;
|
|
@@ -3287,8 +3329,14 @@ class UIExpression {
|
|
|
3287
3329
|
* @param terms Variable-coefficient pairs
|
|
3288
3330
|
*/
|
|
3289
3331
|
constructor(constant = 0, terms) {
|
|
3332
|
+
assertValidNumber(constant, "UIExpression.constructor.constant");
|
|
3290
3333
|
this.constant = constant;
|
|
3291
3334
|
this._private_terms = terms ? new Map(terms) : new Map();
|
|
3335
|
+
if (terms) {
|
|
3336
|
+
for (let i = 0; i < terms.length; i++) {
|
|
3337
|
+
assertValidNumber(terms[i][1], `UIExpression.constructor.terms[${i}][1]`);
|
|
3338
|
+
}
|
|
3339
|
+
}
|
|
3292
3340
|
}
|
|
3293
3341
|
/**
|
|
3294
3342
|
* Creates expression representing a + b.
|
|
@@ -3323,6 +3371,7 @@ class UIExpression {
|
|
|
3323
3371
|
* @returns This instance for chaining
|
|
3324
3372
|
*/
|
|
3325
3373
|
plus(variableIndex, coefficient) {
|
|
3374
|
+
assertValidNumber(coefficient, "UIExpression.plus.coefficient");
|
|
3326
3375
|
this._private_terms.set(variableIndex, (this._private_terms.get(variableIndex) ?? 0) + coefficient);
|
|
3327
3376
|
return this;
|
|
3328
3377
|
}
|
|
@@ -3341,6 +3390,7 @@ class UIExpression {
|
|
|
3341
3390
|
* @returns This instance for chaining
|
|
3342
3391
|
*/
|
|
3343
3392
|
multiply(value) {
|
|
3393
|
+
assertValidNumber(value, "UIExpression.multiply.value");
|
|
3344
3394
|
this.constant *= value;
|
|
3345
3395
|
for (const [variableIndex, coefficient] of this._private_terms) {
|
|
3346
3396
|
this._private_terms.set(variableIndex, coefficient * value);
|
|
@@ -3353,6 +3403,10 @@ class UIExpression {
|
|
|
3353
3403
|
* @returns This instance for chaining
|
|
3354
3404
|
*/
|
|
3355
3405
|
divide(value) {
|
|
3406
|
+
assertValidNumber(value, "UIExpression.divide.value");
|
|
3407
|
+
if (value === 0) {
|
|
3408
|
+
throw new Error("UIExpression.divide.value: cannot divide by zero");
|
|
3409
|
+
}
|
|
3356
3410
|
return this.multiply(1 / value);
|
|
3357
3411
|
}
|
|
3358
3412
|
/**
|
|
@@ -3941,28 +3995,35 @@ var UILayerEvent;
|
|
|
3941
3995
|
/** Fired during rendering */
|
|
3942
3996
|
UILayerEvent["RENDERING"] = "rendering";
|
|
3943
3997
|
})(UILayerEvent || (UILayerEvent = {}));
|
|
3998
|
+
const LAYER_DEFAULT_SIZE = 1024;
|
|
3999
|
+
const LAYER_DEFAULT_NAME = "";
|
|
4000
|
+
const LAYER_DEFAULT_MODE = UIMode.VISIBLE;
|
|
3944
4001
|
|
|
3945
4002
|
/** Base layer for UI rendering and layout management */
|
|
3946
4003
|
class UILayer extends i {
|
|
3947
|
-
|
|
3948
|
-
* @param w Initial width in world units
|
|
3949
|
-
* @param h Initial height in world units
|
|
3950
|
-
* @param mode Initial visibility and interactivity mode
|
|
3951
|
-
*/
|
|
3952
|
-
constructor(w, h, mode) {
|
|
4004
|
+
constructor(options) {
|
|
3953
4005
|
super();
|
|
3954
4006
|
/** Optional layer name */
|
|
3955
4007
|
this.name = "";
|
|
3956
4008
|
this.inputWrapperInternal = new UIInputWrapper();
|
|
3957
4009
|
this._private_solverWrapperInternal = new UISolverWrapper();
|
|
3958
|
-
|
|
3959
|
-
|
|
4010
|
+
if (options.width !== undefined) {
|
|
4011
|
+
assertValidPositiveNumber(options.width, "UILayer.constructor.options.width");
|
|
4012
|
+
}
|
|
4013
|
+
if (options.height !== undefined) {
|
|
4014
|
+
assertValidPositiveNumber(options.height, "UILayer.constructor.options.height");
|
|
4015
|
+
}
|
|
4016
|
+
const width = options.width ?? LAYER_DEFAULT_SIZE;
|
|
4017
|
+
const height = options.height ?? LAYER_DEFAULT_SIZE;
|
|
4018
|
+
this._private_sceneWrapperInternal = new UISceneWrapper(width, height);
|
|
4019
|
+
this.name = options.name ?? LAYER_DEFAULT_NAME;
|
|
4020
|
+
this._private_modeInternal = options.mode ?? LAYER_DEFAULT_MODE;
|
|
3960
4021
|
this._private_orientationInternal =
|
|
3961
|
-
|
|
4022
|
+
width > height ? UIOrientation.HORIZONTAL : UIOrientation.VERTICAL;
|
|
3962
4023
|
this.xVariable = this._private_solverWrapperInternal.createVariable(0, UIPriority.P0);
|
|
3963
4024
|
this.yVariable = this._private_solverWrapperInternal.createVariable(0, UIPriority.P0);
|
|
3964
|
-
this.wVariable = this._private_solverWrapperInternal.createVariable(
|
|
3965
|
-
this.hVariable = this._private_solverWrapperInternal.createVariable(
|
|
4025
|
+
this.wVariable = this._private_solverWrapperInternal.createVariable(width, UIPriority.P0);
|
|
4026
|
+
this.hVariable = this._private_solverWrapperInternal.createVariable(height, UIPriority.P0);
|
|
3966
4027
|
}
|
|
3967
4028
|
/** @internal */
|
|
3968
4029
|
get sceneWrapper() {
|
|
@@ -4027,7 +4088,6 @@ class UILayer extends i {
|
|
|
4027
4088
|
}
|
|
4028
4089
|
}
|
|
4029
4090
|
|
|
4030
|
-
const EPSILON = 1e-6;
|
|
4031
4091
|
/**
|
|
4032
4092
|
* Checks if object implements UILayerElement.
|
|
4033
4093
|
* @param obj Object to check
|
|
@@ -4073,37 +4133,8 @@ function isUIPlaneElement(obj) {
|
|
|
4073
4133
|
"height" in obj &&
|
|
4074
4134
|
typeof obj.height === "number");
|
|
4075
4135
|
}
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
* @param a First constraint subject
|
|
4079
|
-
* @param b Second constraint subject
|
|
4080
|
-
* @param subject Constraint name for error messages
|
|
4081
|
-
* @returns Common layer for both subjects
|
|
4082
|
-
* @throws If subjects are invalid or from different layers
|
|
4083
|
-
*/
|
|
4084
|
-
function assertValidConstraintSubjects(a, b, subject) {
|
|
4085
|
-
if (a instanceof UILayer && b instanceof UILayer) {
|
|
4086
|
-
throw new Error(`${subject}: layer cannot be snapped to another layer`);
|
|
4087
|
-
}
|
|
4088
|
-
let layerA;
|
|
4089
|
-
let layerB;
|
|
4090
|
-
if (a instanceof UILayer || isUILayerElement(a)) {
|
|
4091
|
-
layerA = a instanceof UILayer ? a : a.layer;
|
|
4092
|
-
}
|
|
4093
|
-
else {
|
|
4094
|
-
throw new Error(`${subject}: A must be a UILayer or a UIPointElement`);
|
|
4095
|
-
}
|
|
4096
|
-
if (b instanceof UILayer || isUILayerElement(b)) {
|
|
4097
|
-
layerB = b instanceof UILayer ? b : b.layer;
|
|
4098
|
-
}
|
|
4099
|
-
else {
|
|
4100
|
-
throw new Error(`${subject}: B must be a UILayer or a UIPointElement`);
|
|
4101
|
-
}
|
|
4102
|
-
if (layerA !== layerB) {
|
|
4103
|
-
throw new Error(`${subject}: elements must be on the same layer`);
|
|
4104
|
-
}
|
|
4105
|
-
return layerA;
|
|
4106
|
-
}
|
|
4136
|
+
|
|
4137
|
+
const EPSILON = 1e-6;
|
|
4107
4138
|
/**
|
|
4108
4139
|
* Validates value is finite number within safe range.
|
|
4109
4140
|
* @param value Number to validate
|
|
@@ -4148,15 +4179,127 @@ function assertValidNonNegativeNumber(value, subject) {
|
|
|
4148
4179
|
}
|
|
4149
4180
|
}
|
|
4150
4181
|
}
|
|
4182
|
+
/**
|
|
4183
|
+
* Validates constraint arguments are from same layer.
|
|
4184
|
+
* @param a First constraint subject
|
|
4185
|
+
* @param b Second constraint subject
|
|
4186
|
+
* @param subject Constraint name for error messages
|
|
4187
|
+
* @returns Common layer for both subjects
|
|
4188
|
+
* @throws If subjects are invalid or from different layers
|
|
4189
|
+
*/
|
|
4190
|
+
function assertValidConstraintArguments(a, b, subject) {
|
|
4191
|
+
if ("development" !== "production") {
|
|
4192
|
+
if (a instanceof UILayer && b instanceof UILayer) {
|
|
4193
|
+
throw new Error(`${subject}: layer cannot be snapped to another layer`);
|
|
4194
|
+
}
|
|
4195
|
+
let layerA;
|
|
4196
|
+
let layerB;
|
|
4197
|
+
if (a instanceof UILayer) {
|
|
4198
|
+
layerA = a;
|
|
4199
|
+
}
|
|
4200
|
+
else if (isUILayerElement(a)) {
|
|
4201
|
+
layerA = a.layer;
|
|
4202
|
+
}
|
|
4203
|
+
else {
|
|
4204
|
+
throw new Error(`${subject}: A must be a UILayer or a UILayerElement`);
|
|
4205
|
+
}
|
|
4206
|
+
if (b instanceof UILayer) {
|
|
4207
|
+
layerB = b;
|
|
4208
|
+
}
|
|
4209
|
+
else if (isUILayerElement(b)) {
|
|
4210
|
+
layerB = b.layer;
|
|
4211
|
+
}
|
|
4212
|
+
else {
|
|
4213
|
+
throw new Error(`${subject}: B must be a UILayer or a UILayerElement`);
|
|
4214
|
+
}
|
|
4215
|
+
if (layerA !== layerB) {
|
|
4216
|
+
throw new Error(`${subject}: elements must be on the same layer`);
|
|
4217
|
+
}
|
|
4218
|
+
return layerA;
|
|
4219
|
+
}
|
|
4220
|
+
if (a instanceof UILayer) {
|
|
4221
|
+
return a;
|
|
4222
|
+
}
|
|
4223
|
+
if (isUILayerElement(a)) {
|
|
4224
|
+
return a.layer;
|
|
4225
|
+
}
|
|
4226
|
+
if (b instanceof UILayer) {
|
|
4227
|
+
return b;
|
|
4228
|
+
}
|
|
4229
|
+
if (isUILayerElement(b)) {
|
|
4230
|
+
return b.layer;
|
|
4231
|
+
}
|
|
4232
|
+
throw new Error(`${subject}: no valid subjects found`);
|
|
4233
|
+
}
|
|
4234
|
+
/**
|
|
4235
|
+
* Validates interpolation constraint subjects.
|
|
4236
|
+
* @param subject Constraint name for error messages
|
|
4237
|
+
* @param a First element
|
|
4238
|
+
* @param b Second element
|
|
4239
|
+
* @param c Element to interpolate
|
|
4240
|
+
* @param anchorA Anchor on element A
|
|
4241
|
+
* @param anchorB Anchor on element B
|
|
4242
|
+
* @returns Common layer for all subjects
|
|
4243
|
+
* @throws If subjects violate interpolation constraints
|
|
4244
|
+
*/
|
|
4245
|
+
function assertValidInterpolationConstraintArguments(subject, a, b, c, anchorA, anchorB) {
|
|
4246
|
+
if ("development" !== "production") {
|
|
4247
|
+
if (c instanceof UILayer) {
|
|
4248
|
+
throw new Error(`${subject}: C cannot be a layer`);
|
|
4249
|
+
}
|
|
4250
|
+
if (!isUILayerElement(c)) {
|
|
4251
|
+
throw new Error(`${subject}: C must be a UILayerElement`);
|
|
4252
|
+
}
|
|
4253
|
+
let layerA;
|
|
4254
|
+
let layerB;
|
|
4255
|
+
if (a instanceof UILayer || isUILayerElement(a)) {
|
|
4256
|
+
layerA = a instanceof UILayer ? a : a.layer;
|
|
4257
|
+
}
|
|
4258
|
+
else {
|
|
4259
|
+
throw new Error(`${subject}: A must be UILayer or UILayerElement`);
|
|
4260
|
+
}
|
|
4261
|
+
if (b instanceof UILayer || isUILayerElement(b)) {
|
|
4262
|
+
layerB = b instanceof UILayer ? b : b.layer;
|
|
4263
|
+
}
|
|
4264
|
+
else {
|
|
4265
|
+
throw new Error(`${subject}: B must be UILayer or UILayerElement`);
|
|
4266
|
+
}
|
|
4267
|
+
const layerC = c.layer;
|
|
4268
|
+
if (layerA !== layerB || layerA !== layerC) {
|
|
4269
|
+
throw new Error(`${subject}: all elements must be on the same layer`);
|
|
4270
|
+
}
|
|
4271
|
+
if (c === a || c === b) {
|
|
4272
|
+
throw new Error(`${subject}: C cannot be equal to A or B`);
|
|
4273
|
+
}
|
|
4274
|
+
if (a === b) {
|
|
4275
|
+
if (Math.abs(anchorA - anchorB) <= EPSILON) {
|
|
4276
|
+
throw new Error(`${subject}: when A and B are the same, anchorA and anchorB must differ by more than ${EPSILON}`);
|
|
4277
|
+
}
|
|
4278
|
+
}
|
|
4279
|
+
return layerA;
|
|
4280
|
+
}
|
|
4281
|
+
if (a instanceof UILayer) {
|
|
4282
|
+
return a;
|
|
4283
|
+
}
|
|
4284
|
+
if (isUILayerElement(a)) {
|
|
4285
|
+
return a.layer;
|
|
4286
|
+
}
|
|
4287
|
+
if (b instanceof UILayer) {
|
|
4288
|
+
return b;
|
|
4289
|
+
}
|
|
4290
|
+
if (isUILayerElement(b)) {
|
|
4291
|
+
return b.layer;
|
|
4292
|
+
}
|
|
4293
|
+
throw new Error(`${subject}: no valid subjects found`);
|
|
4294
|
+
}
|
|
4151
4295
|
|
|
4152
4296
|
/** Base class for layout constraints */
|
|
4153
4297
|
class UIConstraint {
|
|
4154
4298
|
/** @param layer Layer containing this constraint */
|
|
4155
|
-
constructor(layer) {
|
|
4299
|
+
constructor(layer, name) {
|
|
4156
4300
|
this.layer = layer;
|
|
4157
|
-
/** Optional constraint name */
|
|
4158
|
-
this.name = "";
|
|
4159
4301
|
this.solverWrapper = this.layer.solverWrapper;
|
|
4302
|
+
this.name = name ?? "";
|
|
4160
4303
|
}
|
|
4161
4304
|
}
|
|
4162
4305
|
|
|
@@ -4167,7 +4310,7 @@ class UISingleParameterConstraint extends UIConstraint {
|
|
|
4167
4310
|
* @param options Constraint configuration
|
|
4168
4311
|
*/
|
|
4169
4312
|
constructor(layer, options) {
|
|
4170
|
-
super(layer);
|
|
4313
|
+
super(layer, options?.name);
|
|
4171
4314
|
/** Updates constraint enabled state when layer orientation changes */
|
|
4172
4315
|
this._private_onOrientationChange = () => {
|
|
4173
4316
|
this.solverWrapper.setConstraintEnabled(this.constraint, this.isConstraintEnabled());
|
|
@@ -4232,11 +4375,11 @@ class UIHeightConstraint extends UISingleParameterConstraint {
|
|
|
4232
4375
|
* @param options Height configuration. Defaults to element's current height.
|
|
4233
4376
|
*/
|
|
4234
4377
|
constructor(_private_element, options = {}) {
|
|
4235
|
-
super(_private_element.layer, options);
|
|
4236
|
-
this._private_element = _private_element;
|
|
4237
4378
|
if (options.height !== undefined) {
|
|
4238
4379
|
assertValidPositiveNumber(options.height, "UIHeightConstraint.constructor.options.height");
|
|
4239
4380
|
}
|
|
4381
|
+
super(_private_element.layer, options);
|
|
4382
|
+
this._private_element = _private_element;
|
|
4240
4383
|
this._private_heightInternal = options.height ?? _private_element.height;
|
|
4241
4384
|
this.constraint = this.solverWrapper.createConstraint(new UIExpression(0, [[this._private_element.hVariable, 1]]), new UIExpression(this._private_heightInternal), this.relation, this.priority, this.isConstraintEnabled());
|
|
4242
4385
|
}
|
|
@@ -4254,7 +4397,7 @@ class UIHeightConstraint extends UISingleParameterConstraint {
|
|
|
4254
4397
|
}
|
|
4255
4398
|
}
|
|
4256
4399
|
|
|
4257
|
-
const DEFAULT_ANCHOR$
|
|
4400
|
+
const DEFAULT_ANCHOR$4 = 0.5;
|
|
4258
4401
|
|
|
4259
4402
|
/** Maintains horizontal distance between elements with configurable anchors */
|
|
4260
4403
|
class UIHorizontalDistanceConstraint extends UISingleParameterConstraint {
|
|
@@ -4264,9 +4407,6 @@ class UIHorizontalDistanceConstraint extends UISingleParameterConstraint {
|
|
|
4264
4407
|
* @param options Distance configuration
|
|
4265
4408
|
*/
|
|
4266
4409
|
constructor(_private_a, _private_b, options = {}) {
|
|
4267
|
-
super(assertValidConstraintSubjects(_private_a, _private_b, "UIHorizontalDistanceConstraint"), options);
|
|
4268
|
-
this._private_a = _private_a;
|
|
4269
|
-
this._private_b = _private_b;
|
|
4270
4410
|
if (options.anchorA !== undefined) {
|
|
4271
4411
|
assertValidNumber(options.anchorA, "UIHorizontalDistanceConstraint.constructor.options.anchorA");
|
|
4272
4412
|
}
|
|
@@ -4276,8 +4416,11 @@ class UIHorizontalDistanceConstraint extends UISingleParameterConstraint {
|
|
|
4276
4416
|
if (options.distance !== undefined) {
|
|
4277
4417
|
assertValidNumber(options.distance, "UIHorizontalDistanceConstraint.constructor.options.distance");
|
|
4278
4418
|
}
|
|
4279
|
-
|
|
4280
|
-
this.
|
|
4419
|
+
super(assertValidConstraintArguments(_private_a, _private_b, "UIHorizontalDistanceConstraint.constructor"), options);
|
|
4420
|
+
this._private_a = _private_a;
|
|
4421
|
+
this._private_b = _private_b;
|
|
4422
|
+
this._private_anchorAInternal = options.anchorA ?? DEFAULT_ANCHOR$4;
|
|
4423
|
+
this._private_anchorBInternal = options.anchorB ?? DEFAULT_ANCHOR$4;
|
|
4281
4424
|
this._private_distanceInternal = options.distance ?? 0;
|
|
4282
4425
|
this.constraint = this.solverWrapper.createConstraint(this._private_buildLHS(), new UIExpression(this._private_distanceInternal), this.relation, this.priority, this.isConstraintEnabled());
|
|
4283
4426
|
}
|
|
@@ -4349,6 +4492,138 @@ class UIHorizontalDistanceConstraint extends UISingleParameterConstraint {
|
|
|
4349
4492
|
}
|
|
4350
4493
|
}
|
|
4351
4494
|
|
|
4495
|
+
const DEFAULT_ANCHOR$3 = 0.5;
|
|
4496
|
+
const DEFAULT_T$1 = 0.5;
|
|
4497
|
+
|
|
4498
|
+
/** Positions element C horizontally between A and B based on interpolation factor */
|
|
4499
|
+
class UIHorizontalInterpolationConstraint extends UISingleParameterConstraint {
|
|
4500
|
+
/**
|
|
4501
|
+
* @param a First element
|
|
4502
|
+
* @param b Second element
|
|
4503
|
+
* @param c Element to position between A and B
|
|
4504
|
+
* @param options Interpolation configuration
|
|
4505
|
+
*/
|
|
4506
|
+
constructor(_private_a, _private_b, _private_c, options = {}) {
|
|
4507
|
+
if (options.anchorA !== undefined) {
|
|
4508
|
+
assertValidNumber(options.anchorA, "UIHorizontalInterpolationConstraint.constructor.options.anchorA");
|
|
4509
|
+
}
|
|
4510
|
+
if (options.anchorB !== undefined) {
|
|
4511
|
+
assertValidNumber(options.anchorB, "UIHorizontalInterpolationConstraint.constructor.options.anchorB");
|
|
4512
|
+
}
|
|
4513
|
+
if (options.anchorC !== undefined) {
|
|
4514
|
+
assertValidNumber(options.anchorC, "UIHorizontalInterpolationConstraint.constructor.options.anchorC");
|
|
4515
|
+
}
|
|
4516
|
+
if (options.t !== undefined) {
|
|
4517
|
+
assertValidNumber(options.t, "UIHorizontalInterpolationConstraint.constructor.options.t");
|
|
4518
|
+
}
|
|
4519
|
+
const anchorA = options.anchorA ?? DEFAULT_ANCHOR$3;
|
|
4520
|
+
const anchorB = options.anchorB ?? DEFAULT_ANCHOR$3;
|
|
4521
|
+
super(assertValidInterpolationConstraintArguments("UIHorizontalInterpolationConstraint.constructor", _private_a, _private_b, _private_c, anchorA, anchorB), options);
|
|
4522
|
+
this._private_a = _private_a;
|
|
4523
|
+
this._private_b = _private_b;
|
|
4524
|
+
this._private_c = _private_c;
|
|
4525
|
+
this._private_anchorAInternal = anchorA;
|
|
4526
|
+
this._private_anchorBInternal = anchorA;
|
|
4527
|
+
this._private_anchorCInternal = options.anchorC ?? DEFAULT_ANCHOR$3;
|
|
4528
|
+
this._private_tInternal = options.t ?? DEFAULT_T$1;
|
|
4529
|
+
this.constraint = this.solverWrapper.createConstraint(this._private_buildLHS(), new UIExpression(0), this.relation, this.priority, this.isConstraintEnabled());
|
|
4530
|
+
}
|
|
4531
|
+
/** Interpolation factor (0 = A position, 1 = B position) */
|
|
4532
|
+
get t() {
|
|
4533
|
+
return this._private_tInternal;
|
|
4534
|
+
}
|
|
4535
|
+
/** Anchor on element A (0 = left, 0.5 = center, 1 = right) */
|
|
4536
|
+
get anchorA() {
|
|
4537
|
+
return this._private_anchorAInternal;
|
|
4538
|
+
}
|
|
4539
|
+
/** Anchor on element B (0 = left, 0.5 = center, 1 = right) */
|
|
4540
|
+
get anchorB() {
|
|
4541
|
+
return this._private_anchorBInternal;
|
|
4542
|
+
}
|
|
4543
|
+
/** Anchor on element C (0 = left, 0.5 = center, 1 = right) */
|
|
4544
|
+
get anchorC() {
|
|
4545
|
+
return this._private_anchorCInternal;
|
|
4546
|
+
}
|
|
4547
|
+
/** Updates interpolation factor */
|
|
4548
|
+
set t(value) {
|
|
4549
|
+
assertValidNumber(value, "UIHorizontalInterpolationConstraint.t");
|
|
4550
|
+
if (this._private_tInternal !== value) {
|
|
4551
|
+
this._private_tInternal = value;
|
|
4552
|
+
this.solverWrapper.setConstraintLHS(this.constraint, this._private_buildLHS());
|
|
4553
|
+
}
|
|
4554
|
+
}
|
|
4555
|
+
/** Updates anchor on element A */
|
|
4556
|
+
set anchorA(value) {
|
|
4557
|
+
assertValidNumber(value, "UIHorizontalInterpolationConstraint.anchorA");
|
|
4558
|
+
if (this._private_anchorAInternal !== value) {
|
|
4559
|
+
this._private_anchorAInternal = value;
|
|
4560
|
+
this.solverWrapper.setConstraintLHS(this.constraint, this._private_buildLHS());
|
|
4561
|
+
}
|
|
4562
|
+
}
|
|
4563
|
+
/** Updates anchor on element B */
|
|
4564
|
+
set anchorB(value) {
|
|
4565
|
+
assertValidNumber(value, "UIHorizontalInterpolationConstraint.anchorB");
|
|
4566
|
+
if (this._private_anchorBInternal !== value) {
|
|
4567
|
+
this._private_anchorBInternal = value;
|
|
4568
|
+
this.solverWrapper.setConstraintLHS(this.constraint, this._private_buildLHS());
|
|
4569
|
+
}
|
|
4570
|
+
}
|
|
4571
|
+
/** Updates anchor on element C */
|
|
4572
|
+
set anchorC(value) {
|
|
4573
|
+
assertValidNumber(value, "UIHorizontalInterpolationConstraint.anchorC");
|
|
4574
|
+
if (this._private_anchorCInternal !== value) {
|
|
4575
|
+
this._private_anchorCInternal = value;
|
|
4576
|
+
this.solverWrapper.setConstraintLHS(this.constraint, this._private_buildLHS());
|
|
4577
|
+
}
|
|
4578
|
+
}
|
|
4579
|
+
/** Builds constraint expression: C - A*(1-t) - B*t = 0 */
|
|
4580
|
+
_private_buildLHS() {
|
|
4581
|
+
let aExpression;
|
|
4582
|
+
let bExpression;
|
|
4583
|
+
let cExpression;
|
|
4584
|
+
if (isUIPlaneElement(this._private_a)) {
|
|
4585
|
+
aExpression = new UIExpression(0, [
|
|
4586
|
+
[this._private_a.xVariable, 1],
|
|
4587
|
+
[this._private_a.wVariable, this._private_anchorAInternal],
|
|
4588
|
+
]);
|
|
4589
|
+
}
|
|
4590
|
+
else if (isUIPointElement(this._private_a)) {
|
|
4591
|
+
aExpression = new UIExpression().plus(this._private_a.xVariable, 1);
|
|
4592
|
+
}
|
|
4593
|
+
else {
|
|
4594
|
+
throw new Error("UIHorizontalInterpolationConstraint.buildLHS.a: invalid element type");
|
|
4595
|
+
}
|
|
4596
|
+
if (isUIPlaneElement(this._private_b)) {
|
|
4597
|
+
bExpression = new UIExpression(0, [
|
|
4598
|
+
[this._private_b.xVariable, 1],
|
|
4599
|
+
[this._private_b.wVariable, this._private_anchorBInternal],
|
|
4600
|
+
]);
|
|
4601
|
+
}
|
|
4602
|
+
else if (isUIPointElement(this._private_b)) {
|
|
4603
|
+
bExpression = new UIExpression().plus(this._private_b.xVariable, 1);
|
|
4604
|
+
}
|
|
4605
|
+
else {
|
|
4606
|
+
throw new Error("UIHorizontalInterpolationConstraint.buildLHS.b: invalid element type");
|
|
4607
|
+
}
|
|
4608
|
+
if (isUIPlaneElement(this._private_c)) {
|
|
4609
|
+
cExpression = new UIExpression(0, [
|
|
4610
|
+
[this._private_c.xVariable, 1],
|
|
4611
|
+
[this._private_c.wVariable, this._private_anchorCInternal],
|
|
4612
|
+
]);
|
|
4613
|
+
}
|
|
4614
|
+
else if (isUIPointElement(this._private_c)) {
|
|
4615
|
+
cExpression = new UIExpression().plus(this._private_c.xVariable, 1);
|
|
4616
|
+
}
|
|
4617
|
+
else {
|
|
4618
|
+
throw new Error("UIHorizontalInterpolationConstraint.buildLHS.c: invalid element type");
|
|
4619
|
+
}
|
|
4620
|
+
// C - A*(1-t) - B*t = 0
|
|
4621
|
+
const aScaled = aExpression.clone().multiply(1 - this._private_tInternal);
|
|
4622
|
+
const bScaled = bExpression.clone().multiply(this._private_tInternal);
|
|
4623
|
+
return UIExpression.minus(UIExpression.minus(cExpression, aScaled), bScaled);
|
|
4624
|
+
}
|
|
4625
|
+
}
|
|
4626
|
+
|
|
4352
4627
|
/** Maintains proportional width relationship (A.width * proportion = B.width) */
|
|
4353
4628
|
class UIHorizontalProportionConstraint extends UISingleParameterConstraint {
|
|
4354
4629
|
/**
|
|
@@ -4357,12 +4632,12 @@ class UIHorizontalProportionConstraint extends UISingleParameterConstraint {
|
|
|
4357
4632
|
* @param options Proportion configuration
|
|
4358
4633
|
*/
|
|
4359
4634
|
constructor(_private_a, _private_b, options = {}) {
|
|
4360
|
-
super(assertValidConstraintSubjects(_private_a, _private_b, "UIHorizontalProportionConstraint"), options);
|
|
4361
|
-
this._private_a = _private_a;
|
|
4362
|
-
this._private_b = _private_b;
|
|
4363
4635
|
if (options.proportion !== undefined) {
|
|
4364
4636
|
assertValidPositiveNumber(options.proportion, "UIHorizontalProportionConstraint.constructor.options.proportion");
|
|
4365
4637
|
}
|
|
4638
|
+
super(assertValidConstraintArguments(_private_a, _private_b, "UIHorizontalProportionConstraint.constructor"), options);
|
|
4639
|
+
this._private_a = _private_a;
|
|
4640
|
+
this._private_b = _private_b;
|
|
4366
4641
|
this._private_proportionInternal = options.proportion ?? 1;
|
|
4367
4642
|
this.constraint = this.solverWrapper.createConstraint(new UIExpression(0), this._private_buildRHS(), this.relation, this.priority, this.isConstraintEnabled());
|
|
4368
4643
|
}
|
|
@@ -4384,7 +4659,7 @@ class UIHorizontalProportionConstraint extends UISingleParameterConstraint {
|
|
|
4384
4659
|
}
|
|
4385
4660
|
}
|
|
4386
4661
|
|
|
4387
|
-
const DEFAULT_ANCHOR$
|
|
4662
|
+
const DEFAULT_ANCHOR$2 = 0.5;
|
|
4388
4663
|
|
|
4389
4664
|
/** Maintains vertical distance between elements with configurable anchors */
|
|
4390
4665
|
class UIVerticalDistanceConstraint extends UISingleParameterConstraint {
|
|
@@ -4394,9 +4669,6 @@ class UIVerticalDistanceConstraint extends UISingleParameterConstraint {
|
|
|
4394
4669
|
* @param options Distance configuration
|
|
4395
4670
|
*/
|
|
4396
4671
|
constructor(_private_a, _private_b, options = {}) {
|
|
4397
|
-
super(assertValidConstraintSubjects(_private_a, _private_b, "UIVerticalDistanceConstraint"), options);
|
|
4398
|
-
this._private_a = _private_a;
|
|
4399
|
-
this._private_b = _private_b;
|
|
4400
4672
|
if (options.anchorA !== undefined) {
|
|
4401
4673
|
assertValidNumber(options.anchorA, "UIVerticalDistanceConstraint.constructor.options.anchorA");
|
|
4402
4674
|
}
|
|
@@ -4406,8 +4678,11 @@ class UIVerticalDistanceConstraint extends UISingleParameterConstraint {
|
|
|
4406
4678
|
if (options.distance !== undefined) {
|
|
4407
4679
|
assertValidNumber(options.distance, "UIVerticalDistanceConstraint.constructor.options.distance");
|
|
4408
4680
|
}
|
|
4409
|
-
|
|
4410
|
-
this.
|
|
4681
|
+
super(assertValidConstraintArguments(_private_a, _private_b, "UIVerticalDistanceConstraint.constructor"), options);
|
|
4682
|
+
this._private_a = _private_a;
|
|
4683
|
+
this._private_b = _private_b;
|
|
4684
|
+
this._private_anchorAInternal = options.anchorA ?? DEFAULT_ANCHOR$2;
|
|
4685
|
+
this._private_anchorBInternal = options.anchorB ?? DEFAULT_ANCHOR$2;
|
|
4411
4686
|
this._private_distanceInternal = options.distance ?? 0;
|
|
4412
4687
|
this.constraint = this.solverWrapper.createConstraint(this._private_buildLHS(), new UIExpression(this._private_distanceInternal), this.relation, this.priority, this.isConstraintEnabled());
|
|
4413
4688
|
}
|
|
@@ -4479,6 +4754,138 @@ class UIVerticalDistanceConstraint extends UISingleParameterConstraint {
|
|
|
4479
4754
|
}
|
|
4480
4755
|
}
|
|
4481
4756
|
|
|
4757
|
+
const DEFAULT_ANCHOR$1 = 0.5;
|
|
4758
|
+
const DEFAULT_T = 0.5;
|
|
4759
|
+
|
|
4760
|
+
/** Positions element C vertically between A and B based on interpolation factor */
|
|
4761
|
+
class UIVerticalInterpolationConstraint extends UISingleParameterConstraint {
|
|
4762
|
+
/**
|
|
4763
|
+
* @param a First element
|
|
4764
|
+
* @param b Second element
|
|
4765
|
+
* @param c Element to position between A and B
|
|
4766
|
+
* @param options Interpolation configuration
|
|
4767
|
+
*/
|
|
4768
|
+
constructor(_private_a, _private_b, _private_c, options = {}) {
|
|
4769
|
+
if (options.anchorA !== undefined) {
|
|
4770
|
+
assertValidNumber(options.anchorA, "UIVerticalInterpolationConstraint.constructor.options.anchorA");
|
|
4771
|
+
}
|
|
4772
|
+
if (options.anchorB !== undefined) {
|
|
4773
|
+
assertValidNumber(options.anchorB, "UIVerticalInterpolationConstraint.constructor.options.anchorB");
|
|
4774
|
+
}
|
|
4775
|
+
if (options.anchorC !== undefined) {
|
|
4776
|
+
assertValidNumber(options.anchorC, "UIVerticalInterpolationConstraint.constructor.options.anchorC");
|
|
4777
|
+
}
|
|
4778
|
+
if (options.t !== undefined) {
|
|
4779
|
+
assertValidNumber(options.t, "UIVerticalInterpolationConstraint.constructor.options.t");
|
|
4780
|
+
}
|
|
4781
|
+
const anchorA = options.anchorA ?? DEFAULT_ANCHOR$1;
|
|
4782
|
+
const anchorB = options.anchorB ?? DEFAULT_ANCHOR$1;
|
|
4783
|
+
super(assertValidInterpolationConstraintArguments("UIVerticalInterpolationConstraint.constructor", _private_a, _private_b, _private_c, anchorA, anchorB), options);
|
|
4784
|
+
this._private_a = _private_a;
|
|
4785
|
+
this._private_b = _private_b;
|
|
4786
|
+
this._private_c = _private_c;
|
|
4787
|
+
this._private_anchorAInternal = anchorA;
|
|
4788
|
+
this._private_anchorBInternal = anchorA;
|
|
4789
|
+
this._private_anchorCInternal = options.anchorC ?? DEFAULT_ANCHOR$1;
|
|
4790
|
+
this._private_tInternal = options.t ?? DEFAULT_T;
|
|
4791
|
+
this.constraint = this.solverWrapper.createConstraint(this._private_buildLHS(), new UIExpression(0), this.relation, this.priority, this.isConstraintEnabled());
|
|
4792
|
+
}
|
|
4793
|
+
/** Interpolation factor (0 = A position, 1 = B position) */
|
|
4794
|
+
get t() {
|
|
4795
|
+
return this._private_tInternal;
|
|
4796
|
+
}
|
|
4797
|
+
/** Anchor on element A (0 = bottom, 0.5 = center, 1 = top) */
|
|
4798
|
+
get anchorA() {
|
|
4799
|
+
return this._private_anchorAInternal;
|
|
4800
|
+
}
|
|
4801
|
+
/** Anchor on element B (0 = bottom, 0.5 = center, 1 = top) */
|
|
4802
|
+
get anchorB() {
|
|
4803
|
+
return this._private_anchorBInternal;
|
|
4804
|
+
}
|
|
4805
|
+
/** Anchor on element C (0 = bottom, 0.5 = center, 1 = top) */
|
|
4806
|
+
get anchorC() {
|
|
4807
|
+
return this._private_anchorCInternal;
|
|
4808
|
+
}
|
|
4809
|
+
/** Updates interpolation factor */
|
|
4810
|
+
set t(value) {
|
|
4811
|
+
assertValidNumber(value, "UIVerticalInterpolationConstraint.t");
|
|
4812
|
+
if (this._private_tInternal !== value) {
|
|
4813
|
+
this._private_tInternal = value;
|
|
4814
|
+
this.solverWrapper.setConstraintLHS(this.constraint, this._private_buildLHS());
|
|
4815
|
+
}
|
|
4816
|
+
}
|
|
4817
|
+
/** Updates anchor on element A */
|
|
4818
|
+
set anchorA(value) {
|
|
4819
|
+
assertValidNumber(value, "UIVerticalInterpolationConstraint.anchorA");
|
|
4820
|
+
if (this._private_anchorAInternal !== value) {
|
|
4821
|
+
this._private_anchorAInternal = value;
|
|
4822
|
+
this.solverWrapper.setConstraintLHS(this.constraint, this._private_buildLHS());
|
|
4823
|
+
}
|
|
4824
|
+
}
|
|
4825
|
+
/** Updates anchor on element B */
|
|
4826
|
+
set anchorB(value) {
|
|
4827
|
+
assertValidNumber(value, "UIVerticalInterpolationConstraint.anchorB");
|
|
4828
|
+
if (this._private_anchorBInternal !== value) {
|
|
4829
|
+
this._private_anchorBInternal = value;
|
|
4830
|
+
this.solverWrapper.setConstraintLHS(this.constraint, this._private_buildLHS());
|
|
4831
|
+
}
|
|
4832
|
+
}
|
|
4833
|
+
/** Updates anchor on element C */
|
|
4834
|
+
set anchorC(value) {
|
|
4835
|
+
assertValidNumber(value, "UIVerticalInterpolationConstraint.anchorC");
|
|
4836
|
+
if (this._private_anchorCInternal !== value) {
|
|
4837
|
+
this._private_anchorCInternal = value;
|
|
4838
|
+
this.solverWrapper.setConstraintLHS(this.constraint, this._private_buildLHS());
|
|
4839
|
+
}
|
|
4840
|
+
}
|
|
4841
|
+
/** Builds constraint expression: C - A*(1-t) - B*t = 0 */
|
|
4842
|
+
_private_buildLHS() {
|
|
4843
|
+
let aExpression;
|
|
4844
|
+
let bExpression;
|
|
4845
|
+
let cExpression;
|
|
4846
|
+
if (isUIPlaneElement(this._private_a)) {
|
|
4847
|
+
aExpression = new UIExpression(0, [
|
|
4848
|
+
[this._private_a.yVariable, 1],
|
|
4849
|
+
[this._private_a.hVariable, this._private_anchorAInternal],
|
|
4850
|
+
]);
|
|
4851
|
+
}
|
|
4852
|
+
else if (isUIPointElement(this._private_a)) {
|
|
4853
|
+
aExpression = new UIExpression().plus(this._private_a.yVariable, 1);
|
|
4854
|
+
}
|
|
4855
|
+
else {
|
|
4856
|
+
throw new Error("UIVerticalInterpolationConstraint.buildLHS.a: invalid element type");
|
|
4857
|
+
}
|
|
4858
|
+
if (isUIPlaneElement(this._private_b)) {
|
|
4859
|
+
bExpression = new UIExpression(0, [
|
|
4860
|
+
[this._private_b.yVariable, 1],
|
|
4861
|
+
[this._private_b.hVariable, this._private_anchorBInternal],
|
|
4862
|
+
]);
|
|
4863
|
+
}
|
|
4864
|
+
else if (isUIPointElement(this._private_b)) {
|
|
4865
|
+
bExpression = new UIExpression().plus(this._private_b.yVariable, 1);
|
|
4866
|
+
}
|
|
4867
|
+
else {
|
|
4868
|
+
throw new Error("UIVerticalInterpolationConstraint.buildLHS.b: invalid element type");
|
|
4869
|
+
}
|
|
4870
|
+
if (isUIPlaneElement(this._private_c)) {
|
|
4871
|
+
cExpression = new UIExpression(0, [
|
|
4872
|
+
[this._private_c.yVariable, 1],
|
|
4873
|
+
[this._private_c.hVariable, this._private_anchorCInternal],
|
|
4874
|
+
]);
|
|
4875
|
+
}
|
|
4876
|
+
else if (isUIPointElement(this._private_c)) {
|
|
4877
|
+
cExpression = new UIExpression().plus(this._private_c.yVariable, 1);
|
|
4878
|
+
}
|
|
4879
|
+
else {
|
|
4880
|
+
throw new Error("UIVerticalInterpolationConstraint.buildLHS.c: invalid element type");
|
|
4881
|
+
}
|
|
4882
|
+
// C - A*(1-t) - B*t = 0
|
|
4883
|
+
const aScaled = aExpression.clone().multiply(1 - this._private_tInternal);
|
|
4884
|
+
const bScaled = bExpression.clone().multiply(this._private_tInternal);
|
|
4885
|
+
return UIExpression.minus(UIExpression.minus(cExpression, aScaled), bScaled);
|
|
4886
|
+
}
|
|
4887
|
+
}
|
|
4888
|
+
|
|
4482
4889
|
/** Maintains proportional height relationship (A.height * proportion = B.height) */
|
|
4483
4890
|
class UIVerticalProportionConstraint extends UISingleParameterConstraint {
|
|
4484
4891
|
/**
|
|
@@ -4487,12 +4894,12 @@ class UIVerticalProportionConstraint extends UISingleParameterConstraint {
|
|
|
4487
4894
|
* @param options Proportion configuration
|
|
4488
4895
|
*/
|
|
4489
4896
|
constructor(_private_a, _private_b, options = {}) {
|
|
4490
|
-
super(assertValidConstraintSubjects(_private_a, _private_b, "UIVerticalProportionConstraint"), options);
|
|
4491
|
-
this._private_a = _private_a;
|
|
4492
|
-
this._private_b = _private_b;
|
|
4493
4897
|
if (options.proportion !== undefined) {
|
|
4494
4898
|
assertValidPositiveNumber(options.proportion, "UIVerticalProportionConstraint.constructor.options.proportion");
|
|
4495
4899
|
}
|
|
4900
|
+
super(assertValidConstraintArguments(_private_a, _private_b, "UIVerticalProportionConstraint.constructor"), options);
|
|
4901
|
+
this._private_a = _private_a;
|
|
4902
|
+
this._private_b = _private_b;
|
|
4496
4903
|
this._private_proportionInternal = options.proportion ?? 1;
|
|
4497
4904
|
this.constraint = this.solverWrapper.createConstraint(new UIExpression(0), this._private_buildRHS(), this.relation, this.priority, this.isConstraintEnabled());
|
|
4498
4905
|
}
|
|
@@ -4521,11 +4928,11 @@ class UIWidthConstraint extends UISingleParameterConstraint {
|
|
|
4521
4928
|
* @param options Width configuration. Defaults to element's current width.
|
|
4522
4929
|
*/
|
|
4523
4930
|
constructor(_private_element, options = {}) {
|
|
4524
|
-
super(_private_element.layer, options);
|
|
4525
|
-
this._private_element = _private_element;
|
|
4526
4931
|
if (options.width !== undefined) {
|
|
4527
4932
|
assertValidPositiveNumber(options.width, "UIWidthConstraint.constructor.options.width");
|
|
4528
4933
|
}
|
|
4934
|
+
super(_private_element.layer, options);
|
|
4935
|
+
this._private_element = _private_element;
|
|
4529
4936
|
this._private_widthInternal = options.width ?? _private_element.width;
|
|
4530
4937
|
this.constraint = this.solverWrapper.createConstraint(new UIExpression(0, [[this._private_element.wVariable, 1]]), new UIExpression(this._private_widthInternal), this.relation, this.priority, this.isConstraintEnabled());
|
|
4531
4938
|
}
|
|
@@ -4543,6 +4950,26 @@ class UIWidthConstraint extends UISingleParameterConstraint {
|
|
|
4543
4950
|
}
|
|
4544
4951
|
}
|
|
4545
4952
|
|
|
4953
|
+
/**
|
|
4954
|
+
* Normalizes UIType2D input to object form.
|
|
4955
|
+
* @param value Object, tuple, or single value
|
|
4956
|
+
* @returns Normalized object with h and v properties
|
|
4957
|
+
*/
|
|
4958
|
+
function normalizeUIType2D(value) {
|
|
4959
|
+
if (value === undefined) {
|
|
4960
|
+
return {};
|
|
4961
|
+
}
|
|
4962
|
+
if (Array.isArray(value)) {
|
|
4963
|
+
return { h: value[0], v: value[1] };
|
|
4964
|
+
}
|
|
4965
|
+
if (typeof value === "object" &&
|
|
4966
|
+
value !== null &&
|
|
4967
|
+
("h" in value || "v" in value)) {
|
|
4968
|
+
return value;
|
|
4969
|
+
}
|
|
4970
|
+
return { h: value, v: value };
|
|
4971
|
+
}
|
|
4972
|
+
|
|
4546
4973
|
/** Builder for paired horizontal and vertical constraints */
|
|
4547
4974
|
class UIConstraint2DBuilder {
|
|
4548
4975
|
/**
|
|
@@ -4552,18 +4979,22 @@ class UIConstraint2DBuilder {
|
|
|
4552
4979
|
* @returns Width and height constraints
|
|
4553
4980
|
*/
|
|
4554
4981
|
static size(element, options = {}) {
|
|
4982
|
+
const size = normalizeUIType2D(options.size);
|
|
4983
|
+
const priority = normalizeUIType2D(options.priority);
|
|
4984
|
+
const relation = normalizeUIType2D(options.relation);
|
|
4985
|
+
const orientation = normalizeUIType2D(options.orientation);
|
|
4555
4986
|
return {
|
|
4556
4987
|
h: new UIWidthConstraint(element, {
|
|
4557
|
-
width:
|
|
4558
|
-
priority:
|
|
4559
|
-
relation:
|
|
4560
|
-
orientation:
|
|
4988
|
+
width: size.h,
|
|
4989
|
+
priority: priority.h,
|
|
4990
|
+
relation: relation.h,
|
|
4991
|
+
orientation: orientation.h,
|
|
4561
4992
|
}),
|
|
4562
4993
|
v: new UIHeightConstraint(element, {
|
|
4563
|
-
height:
|
|
4564
|
-
priority:
|
|
4565
|
-
relation:
|
|
4566
|
-
orientation:
|
|
4994
|
+
height: size.v,
|
|
4995
|
+
priority: priority.v,
|
|
4996
|
+
relation: relation.v,
|
|
4997
|
+
orientation: orientation.v,
|
|
4567
4998
|
}),
|
|
4568
4999
|
};
|
|
4569
5000
|
}
|
|
@@ -4575,22 +5006,28 @@ class UIConstraint2DBuilder {
|
|
|
4575
5006
|
* @returns Horizontal and vertical distance constraints
|
|
4576
5007
|
*/
|
|
4577
5008
|
static distance(a, b, options = {}) {
|
|
5009
|
+
const anchorA = normalizeUIType2D(options.anchorA);
|
|
5010
|
+
const anchorB = normalizeUIType2D(options.anchorB);
|
|
5011
|
+
const distance = normalizeUIType2D(options.distance);
|
|
5012
|
+
const priority = normalizeUIType2D(options.priority);
|
|
5013
|
+
const relation = normalizeUIType2D(options.relation);
|
|
5014
|
+
const orientation = normalizeUIType2D(options.orientation);
|
|
4578
5015
|
return {
|
|
4579
5016
|
h: new UIHorizontalDistanceConstraint(a, b, {
|
|
4580
|
-
anchorA:
|
|
4581
|
-
anchorB:
|
|
4582
|
-
distance:
|
|
4583
|
-
priority:
|
|
4584
|
-
relation:
|
|
4585
|
-
orientation:
|
|
5017
|
+
anchorA: anchorA.h,
|
|
5018
|
+
anchorB: anchorB.h,
|
|
5019
|
+
distance: distance.h,
|
|
5020
|
+
priority: priority.h,
|
|
5021
|
+
relation: relation.h,
|
|
5022
|
+
orientation: orientation.h,
|
|
4586
5023
|
}),
|
|
4587
5024
|
v: new UIVerticalDistanceConstraint(a, b, {
|
|
4588
|
-
anchorA:
|
|
4589
|
-
anchorB:
|
|
4590
|
-
distance:
|
|
4591
|
-
priority:
|
|
4592
|
-
relation:
|
|
4593
|
-
orientation:
|
|
5025
|
+
anchorA: anchorA.v,
|
|
5026
|
+
anchorB: anchorB.v,
|
|
5027
|
+
distance: distance.v,
|
|
5028
|
+
priority: priority.v,
|
|
5029
|
+
relation: relation.v,
|
|
5030
|
+
orientation: orientation.v,
|
|
4594
5031
|
}),
|
|
4595
5032
|
};
|
|
4596
5033
|
}
|
|
@@ -4602,18 +5039,59 @@ class UIConstraint2DBuilder {
|
|
|
4602
5039
|
* @returns Horizontal and vertical proportion constraints
|
|
4603
5040
|
*/
|
|
4604
5041
|
static proportion(a, b, options = {}) {
|
|
5042
|
+
const proportion = normalizeUIType2D(options.proportion);
|
|
5043
|
+
const priority = normalizeUIType2D(options.priority);
|
|
5044
|
+
const relation = normalizeUIType2D(options.relation);
|
|
5045
|
+
const orientation = normalizeUIType2D(options.orientation);
|
|
4605
5046
|
return {
|
|
4606
5047
|
h: new UIHorizontalProportionConstraint(a, b, {
|
|
4607
|
-
proportion:
|
|
4608
|
-
priority:
|
|
4609
|
-
relation:
|
|
4610
|
-
orientation:
|
|
5048
|
+
proportion: proportion.h,
|
|
5049
|
+
priority: priority.h,
|
|
5050
|
+
relation: relation.h,
|
|
5051
|
+
orientation: orientation.h,
|
|
4611
5052
|
}),
|
|
4612
5053
|
v: new UIVerticalProportionConstraint(a, b, {
|
|
4613
|
-
proportion:
|
|
4614
|
-
priority:
|
|
4615
|
-
relation:
|
|
4616
|
-
orientation:
|
|
5054
|
+
proportion: proportion.v,
|
|
5055
|
+
priority: priority.v,
|
|
5056
|
+
relation: relation.v,
|
|
5057
|
+
orientation: orientation.v,
|
|
5058
|
+
}),
|
|
5059
|
+
};
|
|
5060
|
+
}
|
|
5061
|
+
/**
|
|
5062
|
+
* Creates horizontal and vertical interpolation constraints.
|
|
5063
|
+
* @param a First element
|
|
5064
|
+
* @param b Second element
|
|
5065
|
+
* @param c Element to position between A and B
|
|
5066
|
+
* @param options Interpolation configuration for both axes
|
|
5067
|
+
* @returns Horizontal and vertical interpolation constraints
|
|
5068
|
+
*/
|
|
5069
|
+
static interpolation(a, b, c, options = {}) {
|
|
5070
|
+
const anchorA = normalizeUIType2D(options.anchorA);
|
|
5071
|
+
const anchorB = normalizeUIType2D(options.anchorB);
|
|
5072
|
+
const anchorC = normalizeUIType2D(options.anchorC);
|
|
5073
|
+
const t = normalizeUIType2D(options.t);
|
|
5074
|
+
const priority = normalizeUIType2D(options.priority);
|
|
5075
|
+
const relation = normalizeUIType2D(options.relation);
|
|
5076
|
+
const orientation = normalizeUIType2D(options.orientation);
|
|
5077
|
+
return {
|
|
5078
|
+
h: new UIHorizontalInterpolationConstraint(a, b, c, {
|
|
5079
|
+
anchorA: anchorA.h,
|
|
5080
|
+
anchorB: anchorB.h,
|
|
5081
|
+
anchorC: anchorC.h,
|
|
5082
|
+
t: t.h,
|
|
5083
|
+
priority: priority.h,
|
|
5084
|
+
relation: relation.h,
|
|
5085
|
+
orientation: orientation.h,
|
|
5086
|
+
}),
|
|
5087
|
+
v: new UIVerticalInterpolationConstraint(a, b, c, {
|
|
5088
|
+
anchorA: anchorA.v,
|
|
5089
|
+
anchorB: anchorB.v,
|
|
5090
|
+
anchorC: anchorC.v,
|
|
5091
|
+
t: t.v,
|
|
5092
|
+
priority: priority.v,
|
|
5093
|
+
relation: relation.v,
|
|
5094
|
+
orientation: orientation.v,
|
|
4617
5095
|
}),
|
|
4618
5096
|
};
|
|
4619
5097
|
}
|
|
@@ -4626,11 +5104,11 @@ class UIAspectConstraint extends UISingleParameterConstraint {
|
|
|
4626
5104
|
* @param options Aspect configuration. Defaults to element's current ratio.
|
|
4627
5105
|
*/
|
|
4628
5106
|
constructor(_private_element, options = {}) {
|
|
4629
|
-
super(_private_element.layer, options);
|
|
4630
|
-
this._private_element = _private_element;
|
|
4631
5107
|
if (options.aspect !== undefined) {
|
|
4632
5108
|
assertValidPositiveNumber(options.aspect, "UIAspectConstraint.constructor.options.aspect");
|
|
4633
5109
|
}
|
|
5110
|
+
super(_private_element.layer, options);
|
|
5111
|
+
this._private_element = _private_element;
|
|
4634
5112
|
this._private_aspectInternal = options.aspect ?? _private_element.width / _private_element.height;
|
|
4635
5113
|
this.constraint = this.solverWrapper.createConstraint(this._private_buildLHS(), new UIExpression(0), this.relation, this.priority, this.isConstraintEnabled());
|
|
4636
5114
|
}
|
|
@@ -5006,12 +5484,12 @@ class UITextureView extends i {
|
|
|
5006
5484
|
}
|
|
5007
5485
|
/** Transparent padding around visible content */
|
|
5008
5486
|
get trim() {
|
|
5009
|
-
const
|
|
5487
|
+
const scale = this._private_scaleInternal;
|
|
5010
5488
|
return {
|
|
5011
|
-
left: this._private_trimLeft /
|
|
5012
|
-
right: this._private_trimRight /
|
|
5013
|
-
top: this._private_trimTop /
|
|
5014
|
-
bottom: this._private_trimBottom /
|
|
5489
|
+
left: this._private_trimLeft / scale,
|
|
5490
|
+
right: this._private_trimRight / scale,
|
|
5491
|
+
top: this._private_trimTop / scale,
|
|
5492
|
+
bottom: this._private_trimBottom / scale,
|
|
5015
5493
|
};
|
|
5016
5494
|
}
|
|
5017
5495
|
get textureDirty() {
|
|
@@ -5121,6 +5599,19 @@ class UITextureView extends i {
|
|
|
5121
5599
|
}
|
|
5122
5600
|
}
|
|
5123
5601
|
_private_setFromAtlasConfig(config) {
|
|
5602
|
+
assertValidPositiveNumber(config.sourceSize.w, "UITextureView.setFromAtlasConfig.config.sourceSize.w");
|
|
5603
|
+
assertValidPositiveNumber(config.sourceSize.h, "UITextureView.setFromAtlasConfig.config.sourceSize.h");
|
|
5604
|
+
assertValidNonNegativeNumber(config.frame.x, "UITextureView.setFromAtlasConfig.config.frame.x");
|
|
5605
|
+
assertValidNonNegativeNumber(config.frame.y, "UITextureView.setFromAtlasConfig.config.frame.y");
|
|
5606
|
+
assertValidPositiveNumber(config.frame.w, "UITextureView.setFromAtlasConfig.config.frame.w");
|
|
5607
|
+
assertValidPositiveNumber(config.frame.h, "UITextureView.setFromAtlasConfig.config.frame.h");
|
|
5608
|
+
assertValidNonNegativeNumber(config.spriteSourceSize.x, "UITextureView.setFromAtlasConfig.config.spriteSourceSize.x");
|
|
5609
|
+
assertValidNonNegativeNumber(config.spriteSourceSize.y, "UITextureView.setFromAtlasConfig.config.spriteSourceSize.y");
|
|
5610
|
+
assertValidPositiveNumber(config.spriteSourceSize.w, "UITextureView.setFromAtlasConfig.config.spriteSourceSize.w");
|
|
5611
|
+
assertValidPositiveNumber(config.spriteSourceSize.h, "UITextureView.setFromAtlasConfig.config.spriteSourceSize.h");
|
|
5612
|
+
if (config.scale !== undefined) {
|
|
5613
|
+
assertValidPositiveNumber(config.scale, "UITextureView.setFromAtlasConfig.config.scale");
|
|
5614
|
+
}
|
|
5124
5615
|
this._private_sourceWidth = config.sourceSize.w;
|
|
5125
5616
|
this._private_sourceHeight = config.sourceSize.h;
|
|
5126
5617
|
if (this.texture !== config.texture) {
|
|
@@ -5359,9 +5850,15 @@ class UIAreaRectangle extends UIArea {
|
|
|
5359
5850
|
this.y = y;
|
|
5360
5851
|
this.width = width;
|
|
5361
5852
|
this.height = height;
|
|
5853
|
+
assertValidNonNegativeNumber(x, "UIAreaRectangle.constructor.x");
|
|
5854
|
+
assertValidNonNegativeNumber(y, "UIAreaRectangle.constructor.y");
|
|
5855
|
+
assertValidNonNegativeNumber(width, "UIAreaRectangle.constructor.width");
|
|
5856
|
+
assertValidNonNegativeNumber(height, "UIAreaRectangle.constructor.height");
|
|
5362
5857
|
}
|
|
5363
5858
|
/** @internal */
|
|
5364
5859
|
contains(pointX, pointY) {
|
|
5860
|
+
assertValidNumber(pointX, "UIAreaRectangle.contains.pointX");
|
|
5861
|
+
assertValidNumber(pointY, "UIAreaRectangle.contains.pointY");
|
|
5365
5862
|
return (pointX >= this.x &&
|
|
5366
5863
|
pointX <= this.x + this.width &&
|
|
5367
5864
|
pointY >= this.y &&
|
|
@@ -5607,8 +6104,19 @@ var UIAnimatedImageEvent;
|
|
|
5607
6104
|
/** Animation stopped and reset */
|
|
5608
6105
|
UIAnimatedImageEvent[UIAnimatedImageEvent["STOPPED"] = 2] = "STOPPED";
|
|
5609
6106
|
})(UIAnimatedImageEvent || (UIAnimatedImageEvent = {}));
|
|
6107
|
+
/** Animation loop behavior */
|
|
6108
|
+
var UILoopMode;
|
|
6109
|
+
(function (UILoopMode) {
|
|
6110
|
+
/** No looping, stops at boundary frame */
|
|
6111
|
+
UILoopMode[UILoopMode["NONE"] = 0] = "NONE";
|
|
6112
|
+
/** Loops back to opposite frame */
|
|
6113
|
+
UILoopMode[UILoopMode["LOOP"] = 1] = "LOOP";
|
|
6114
|
+
/** Reverses direction at boundaries */
|
|
6115
|
+
UILoopMode[UILoopMode["PING_PONG"] = 2] = "PING_PONG";
|
|
6116
|
+
})(UILoopMode || (UILoopMode = {}));
|
|
5610
6117
|
const ANIMATED_IMAGE_DEFAULT_FRAME_RATE = 24;
|
|
5611
|
-
const
|
|
6118
|
+
const ANIMATED_IMAGE_DEFAULT_TIME_SCALE = 1;
|
|
6119
|
+
const ANIMATED_IMAGE_DEFAULT_LOOP_MODE = UILoopMode.LOOP;
|
|
5612
6120
|
|
|
5613
6121
|
/** Frame-based texture animation element */
|
|
5614
6122
|
class UIAnimatedImage extends UIElement {
|
|
@@ -5647,7 +6155,10 @@ class UIAnimatedImage extends UIElement {
|
|
|
5647
6155
|
this._private_textureTransform = textureTransform;
|
|
5648
6156
|
this._private_frameRateInternal =
|
|
5649
6157
|
options.frameRate ?? ANIMATED_IMAGE_DEFAULT_FRAME_RATE;
|
|
5650
|
-
this.
|
|
6158
|
+
this._private_timeScaleInternal =
|
|
6159
|
+
options.timeScale ?? ANIMATED_IMAGE_DEFAULT_TIME_SCALE;
|
|
6160
|
+
this._private_loopModeInternal =
|
|
6161
|
+
options.loopMode ?? ANIMATED_IMAGE_DEFAULT_LOOP_MODE;
|
|
5651
6162
|
this.color = color;
|
|
5652
6163
|
this._private_subscribeSequenceEvents();
|
|
5653
6164
|
if (options.playByDefault === true) {
|
|
@@ -5662,9 +6173,13 @@ class UIAnimatedImage extends UIElement {
|
|
|
5662
6173
|
get frameRate() {
|
|
5663
6174
|
return this._private_frameRateInternal;
|
|
5664
6175
|
}
|
|
5665
|
-
/**
|
|
5666
|
-
get
|
|
5667
|
-
return this.
|
|
6176
|
+
/** Playback speed multiplier. Can be negative for reverse playback. */
|
|
6177
|
+
get timeScale() {
|
|
6178
|
+
return this._private_timeScaleInternal;
|
|
6179
|
+
}
|
|
6180
|
+
/** Loop behavior */
|
|
6181
|
+
get loopMode() {
|
|
6182
|
+
return this._private_loopModeInternal;
|
|
5668
6183
|
}
|
|
5669
6184
|
/** Total animation duration in seconds */
|
|
5670
6185
|
get duration() {
|
|
@@ -5694,9 +6209,14 @@ class UIAnimatedImage extends UIElement {
|
|
|
5694
6209
|
assertValidPositiveNumber(value, "UIAnimatedImage.frameRate");
|
|
5695
6210
|
this._private_frameRateInternal = value;
|
|
5696
6211
|
}
|
|
5697
|
-
/**
|
|
5698
|
-
set
|
|
5699
|
-
|
|
6212
|
+
/** Playback speed multiplier. Can be negative for reverse playback. */
|
|
6213
|
+
set timeScale(value) {
|
|
6214
|
+
assertValidNumber(value, "UIAnimatedImage.timeScale");
|
|
6215
|
+
this._private_timeScaleInternal = value;
|
|
6216
|
+
}
|
|
6217
|
+
/** Loop behavior */
|
|
6218
|
+
set loopMode(value) {
|
|
6219
|
+
this._private_loopModeInternal = value;
|
|
5700
6220
|
}
|
|
5701
6221
|
/** Removes element and frees resources */
|
|
5702
6222
|
destroy() {
|
|
@@ -5730,51 +6250,91 @@ class UIAnimatedImage extends UIElement {
|
|
|
5730
6250
|
}
|
|
5731
6251
|
}
|
|
5732
6252
|
onWillRender(renderer, deltaTime) {
|
|
5733
|
-
if (this._private_isPlaying) {
|
|
5734
|
-
this._private_accumulatedTime += deltaTime;
|
|
6253
|
+
if (this._private_isPlaying && this._private_timeScaleInternal !== 0) {
|
|
6254
|
+
this._private_accumulatedTime += deltaTime * this._private_timeScaleInternal;
|
|
5735
6255
|
const frameDuration = 1 / this._private_frameRateInternal;
|
|
5736
|
-
|
|
5737
|
-
|
|
5738
|
-
|
|
5739
|
-
|
|
5740
|
-
this.
|
|
6256
|
+
const sequenceLength = this._private_sequenceInternal.length;
|
|
6257
|
+
const lastFrameIndex = sequenceLength - 1;
|
|
6258
|
+
if (this._private_timeScaleInternal > 0) {
|
|
6259
|
+
while (this._private_accumulatedTime >= frameDuration) {
|
|
6260
|
+
this._private_accumulatedTime -= frameDuration;
|
|
6261
|
+
this._private_sequenceFrameIndex += 1;
|
|
6262
|
+
if (this._private_sequenceFrameIndex >= sequenceLength) {
|
|
6263
|
+
if (this._private_loopModeInternal === UILoopMode.LOOP) {
|
|
6264
|
+
this._private_sequenceFrameIndex = 0;
|
|
6265
|
+
}
|
|
6266
|
+
else if (this._private_loopModeInternal === UILoopMode.PING_PONG) {
|
|
6267
|
+
this._private_sequenceFrameIndex = lastFrameIndex;
|
|
6268
|
+
this._private_timeScaleInternal = -this._private_timeScaleInternal;
|
|
6269
|
+
}
|
|
6270
|
+
else {
|
|
6271
|
+
this._private_sequenceFrameIndex = lastFrameIndex;
|
|
6272
|
+
this._private_isPlaying = false;
|
|
6273
|
+
this.emit(UIAnimatedImageEvent.PAUSED);
|
|
6274
|
+
break;
|
|
6275
|
+
}
|
|
6276
|
+
}
|
|
6277
|
+
this._private_currentFrameIndexDirty = true;
|
|
5741
6278
|
}
|
|
5742
|
-
|
|
5743
|
-
|
|
5744
|
-
|
|
5745
|
-
this.
|
|
5746
|
-
|
|
6279
|
+
}
|
|
6280
|
+
else {
|
|
6281
|
+
while (this._private_accumulatedTime <= -frameDuration) {
|
|
6282
|
+
this._private_accumulatedTime += frameDuration;
|
|
6283
|
+
this._private_sequenceFrameIndex -= 1;
|
|
6284
|
+
if (this._private_sequenceFrameIndex < 0) {
|
|
6285
|
+
if (this._private_loopModeInternal === UILoopMode.LOOP) {
|
|
6286
|
+
this._private_sequenceFrameIndex = lastFrameIndex;
|
|
6287
|
+
}
|
|
6288
|
+
else if (this._private_loopModeInternal === UILoopMode.PING_PONG) {
|
|
6289
|
+
this._private_sequenceFrameIndex = 0;
|
|
6290
|
+
this._private_timeScaleInternal = -this._private_timeScaleInternal;
|
|
6291
|
+
}
|
|
6292
|
+
else {
|
|
6293
|
+
this._private_sequenceFrameIndex = 0;
|
|
6294
|
+
this._private_isPlaying = false;
|
|
6295
|
+
this.emit(UIAnimatedImageEvent.PAUSED);
|
|
6296
|
+
break;
|
|
6297
|
+
}
|
|
6298
|
+
}
|
|
6299
|
+
this._private_currentFrameIndexDirty = true;
|
|
5747
6300
|
}
|
|
5748
|
-
this._private_currentFrameIndexDirty = true;
|
|
5749
6301
|
}
|
|
5750
6302
|
}
|
|
5751
6303
|
super.onWillRender(renderer, deltaTime);
|
|
5752
6304
|
}
|
|
5753
6305
|
setPlaneTransform() {
|
|
5754
|
-
|
|
5755
|
-
if (this.color.dirty
|
|
5756
|
-
|
|
5757
|
-
|
|
5758
|
-
textureTransform: frame.calculateUVTransform(this._private_textureTransform),
|
|
5759
|
-
color: this.color,
|
|
5760
|
-
});
|
|
6306
|
+
let properties;
|
|
6307
|
+
if (this.color.dirty) {
|
|
6308
|
+
properties ?? (properties = {});
|
|
6309
|
+
properties["color"] = this.color;
|
|
5761
6310
|
this.color.setDirtyFalse();
|
|
5762
6311
|
}
|
|
5763
|
-
|
|
5764
|
-
|
|
5765
|
-
|
|
5766
|
-
frame.
|
|
6312
|
+
const frame = this._private_sequenceInternal[this._private_sequenceFrameIndex];
|
|
6313
|
+
if (frame.textureDirty || this._private_currentFrameIndexDirty) {
|
|
6314
|
+
properties ?? (properties = {});
|
|
6315
|
+
properties["texture"] = frame.texture;
|
|
6316
|
+
frame.setTextureDirtyFalse();
|
|
6317
|
+
}
|
|
6318
|
+
if (frame.uvTransformDirty || this._private_currentFrameIndexDirty) {
|
|
6319
|
+
properties ?? (properties = {});
|
|
6320
|
+
properties["textureTransform"] = frame.calculateUVTransform(this._private_textureTransform);
|
|
6321
|
+
frame.setUVTransformDirtyFalse();
|
|
6322
|
+
}
|
|
6323
|
+
if (properties) {
|
|
6324
|
+
this.sceneWrapper.setProperties(this.planeHandler, properties);
|
|
6325
|
+
}
|
|
6326
|
+
const isTransformDirty = this._private_currentFrameIndexDirty ||
|
|
5767
6327
|
this.micro.dirty ||
|
|
6328
|
+
frame.trimDirty ||
|
|
5768
6329
|
this.inputWrapper.dirty ||
|
|
5769
|
-
this.solverWrapper.dirty
|
|
6330
|
+
this.solverWrapper.dirty;
|
|
6331
|
+
if (isTransformDirty) {
|
|
5770
6332
|
const micro = this.micro;
|
|
5771
6333
|
const textureTrim = frame.trim;
|
|
5772
6334
|
this.sceneWrapper.setTransform(this.planeHandler, 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));
|
|
6335
|
+
this._private_currentFrameIndexDirty = false;
|
|
5773
6336
|
this.micro.setDirtyFalse();
|
|
5774
|
-
frame.setTextureDirtyFalse();
|
|
5775
|
-
frame.setUVTransformDirtyFalse();
|
|
5776
6337
|
frame.setTrimDirtyFalse();
|
|
5777
|
-
this._private_currentFrameIndexDirty = false;
|
|
5778
6338
|
}
|
|
5779
6339
|
}
|
|
5780
6340
|
_private_subscribeSequenceEvents() {
|
|
@@ -5789,8 +6349,6 @@ class UIAnimatedImage extends UIElement {
|
|
|
5789
6349
|
}
|
|
5790
6350
|
}
|
|
5791
6351
|
|
|
5792
|
-
const GRAPHICS_TEMP_PROPERTIES = {};
|
|
5793
|
-
|
|
5794
6352
|
/** Canvas-based 2D drawing element */
|
|
5795
6353
|
class UIGraphics extends UIElement {
|
|
5796
6354
|
/**
|
|
@@ -5895,19 +6453,13 @@ class UIGraphics extends UIElement {
|
|
|
5895
6453
|
}
|
|
5896
6454
|
onWillRender(renderer, deltaTime) {
|
|
5897
6455
|
if (this.color.dirty) {
|
|
5898
|
-
|
|
6456
|
+
this.sceneWrapper.setProperties(this.planeHandler, { color: this.color });
|
|
5899
6457
|
this.color.setDirtyFalse();
|
|
5900
6458
|
}
|
|
5901
|
-
else {
|
|
5902
|
-
delete GRAPHICS_TEMP_PROPERTIES["color"];
|
|
5903
|
-
}
|
|
5904
|
-
this.sceneWrapper.setProperties(this.planeHandler, GRAPHICS_TEMP_PROPERTIES);
|
|
5905
6459
|
super.onWillRender(renderer, deltaTime);
|
|
5906
6460
|
}
|
|
5907
6461
|
}
|
|
5908
6462
|
|
|
5909
|
-
const IMAGE_TEMP_PROPERTIES = {};
|
|
5910
|
-
|
|
5911
6463
|
/** Textured image element */
|
|
5912
6464
|
class UIImage extends UIElement {
|
|
5913
6465
|
/**
|
|
@@ -5945,29 +6497,25 @@ class UIImage extends UIElement {
|
|
|
5945
6497
|
super.destroy();
|
|
5946
6498
|
}
|
|
5947
6499
|
setPlaneTransform() {
|
|
6500
|
+
let properties;
|
|
5948
6501
|
if (this.color.dirty) {
|
|
5949
|
-
|
|
6502
|
+
properties ?? (properties = {});
|
|
6503
|
+
properties["color"] = this.color;
|
|
5950
6504
|
this.color.setDirtyFalse();
|
|
5951
6505
|
}
|
|
5952
|
-
else {
|
|
5953
|
-
delete IMAGE_TEMP_PROPERTIES["color"];
|
|
5954
|
-
}
|
|
5955
6506
|
if (this.texture.textureDirty) {
|
|
5956
|
-
|
|
6507
|
+
properties ?? (properties = {});
|
|
6508
|
+
properties["texture"] = this.texture.texture;
|
|
5957
6509
|
this.texture.setTextureDirtyFalse();
|
|
5958
6510
|
}
|
|
5959
|
-
else {
|
|
5960
|
-
delete IMAGE_TEMP_PROPERTIES["texture"];
|
|
5961
|
-
}
|
|
5962
6511
|
if (this.texture.uvTransformDirty) {
|
|
5963
|
-
|
|
5964
|
-
|
|
6512
|
+
properties ?? (properties = {});
|
|
6513
|
+
properties["textureTransform"] = this.texture.calculateUVTransform(this._private_textureTransform);
|
|
5965
6514
|
this.texture.setUVTransformDirtyFalse();
|
|
5966
6515
|
}
|
|
5967
|
-
|
|
5968
|
-
|
|
6516
|
+
if (properties) {
|
|
6517
|
+
this.sceneWrapper.setProperties(this.planeHandler, properties);
|
|
5969
6518
|
}
|
|
5970
|
-
this.sceneWrapper.setProperties(this.planeHandler, IMAGE_TEMP_PROPERTIES);
|
|
5971
6519
|
const isTransformDirty = this.micro.dirty ||
|
|
5972
6520
|
this.texture.trimDirty ||
|
|
5973
6521
|
this.inputWrapper.dirty ||
|
|
@@ -6201,9 +6749,13 @@ class UINineSlice extends UIElement {
|
|
|
6201
6749
|
sliceBorders: sliceBordersVector,
|
|
6202
6750
|
sliceRegions: sliceRegionsVector,
|
|
6203
6751
|
}, options);
|
|
6204
|
-
this._private_regionModeDirty =
|
|
6752
|
+
this._private_regionModeDirty = true;
|
|
6205
6753
|
this._private_sliceBordersVector = new Vector4();
|
|
6206
6754
|
this._private_sliceRegionsVector = new Vector4();
|
|
6755
|
+
this._private_textureDimensionsDirty = true;
|
|
6756
|
+
this._private_onTextureDimensionsChanged = () => {
|
|
6757
|
+
this._private_textureDimensionsDirty = true;
|
|
6758
|
+
};
|
|
6207
6759
|
this.texture = textureView;
|
|
6208
6760
|
this._private_textureTransform = textureTransform;
|
|
6209
6761
|
this.color = color;
|
|
@@ -6212,8 +6764,9 @@ class UINineSlice extends UIElement {
|
|
|
6212
6764
|
this._private_regionModeInternal = regionMode;
|
|
6213
6765
|
this._private_sliceBordersVector = sliceBordersVector;
|
|
6214
6766
|
this._private_sliceRegionsVector = sliceRegionsVector;
|
|
6215
|
-
this.
|
|
6216
|
-
this.
|
|
6767
|
+
this._private_lastElementWidth = this.width;
|
|
6768
|
+
this._private_lastElementHeight = this.height;
|
|
6769
|
+
this.texture.on(UITextureViewEvent.DIMENSIONS_CHANGED, this._private_onTextureDimensionsChanged);
|
|
6217
6770
|
}
|
|
6218
6771
|
/** Controls how sliceRegions values are interpreted */
|
|
6219
6772
|
get regionMode() {
|
|
@@ -6226,44 +6779,60 @@ class UINineSlice extends UIElement {
|
|
|
6226
6779
|
this._private_regionModeDirty = true;
|
|
6227
6780
|
}
|
|
6228
6781
|
}
|
|
6782
|
+
/** Removes nine slice and frees resources */
|
|
6783
|
+
destroy() {
|
|
6784
|
+
this.texture.off(UITextureViewEvent.DIMENSIONS_CHANGED, this._private_onTextureDimensionsChanged);
|
|
6785
|
+
super.destroy();
|
|
6786
|
+
}
|
|
6229
6787
|
setPlaneTransform() {
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
-
this.texture.uvTransformDirty ||
|
|
6233
|
-
this.texture.trimDirty ||
|
|
6234
|
-
this.color.dirty ||
|
|
6788
|
+
let properties;
|
|
6789
|
+
const sliceBordersDirty = this._private_textureDimensionsDirty ||
|
|
6235
6790
|
this.sliceBorders.dirty ||
|
|
6236
|
-
this.
|
|
6791
|
+
this.texture.trimDirty;
|
|
6792
|
+
if (sliceBordersDirty) {
|
|
6793
|
+
properties ?? (properties = {});
|
|
6794
|
+
properties["sliceBorders"] = this._private_calculateSliceBordersForShader(this._private_sliceBordersVector);
|
|
6795
|
+
this.sliceBorders.setDirtyFalse();
|
|
6796
|
+
this._private_textureDimensionsDirty = false;
|
|
6797
|
+
}
|
|
6798
|
+
const sliceRegionsDirty = this.sliceRegions.dirty || this._private_regionModeDirty ||
|
|
6237
6799
|
(this._private_regionModeInternal === UINineSliceRegionMode.WORLD &&
|
|
6238
|
-
this.
|
|
6239
|
-
|
|
6240
|
-
|
|
6241
|
-
this.
|
|
6242
|
-
|
|
6243
|
-
textureTransform: this.texture.calculateUVTransform(this._private_textureTransform),
|
|
6244
|
-
color: this.color,
|
|
6245
|
-
sliceBorders: this._private_sliceBordersVector,
|
|
6246
|
-
sliceRegions: this._private_sliceRegionsVector,
|
|
6247
|
-
});
|
|
6800
|
+
this._private_checkElementDimensionsDirty());
|
|
6801
|
+
if (sliceRegionsDirty) {
|
|
6802
|
+
properties ?? (properties = {});
|
|
6803
|
+
properties["sliceRegions"] = this._private_calculateSliceRegionsForShader(this._private_sliceRegionsVector);
|
|
6804
|
+
this.sliceRegions.setDirtyFalse();
|
|
6248
6805
|
this._private_regionModeDirty = false;
|
|
6806
|
+
this._private_setElementDimensionsDirtyFalse();
|
|
6807
|
+
}
|
|
6808
|
+
if (this.color.dirty) {
|
|
6809
|
+
properties ?? (properties = {});
|
|
6810
|
+
properties["color"] = this.color;
|
|
6249
6811
|
this.color.setDirtyFalse();
|
|
6250
|
-
this.sliceBorders.setDirtyFalse();
|
|
6251
|
-
this.sliceRegions.setDirtyFalse();
|
|
6252
|
-
this._private_setDimensionsDirtyFalse();
|
|
6253
6812
|
}
|
|
6254
|
-
if (this.texture.textureDirty
|
|
6255
|
-
|
|
6813
|
+
if (this.texture.textureDirty) {
|
|
6814
|
+
properties ?? (properties = {});
|
|
6815
|
+
properties["texture"] = this.texture.texture;
|
|
6816
|
+
this.texture.setTextureDirtyFalse();
|
|
6817
|
+
}
|
|
6818
|
+
if (this.texture.uvTransformDirty) {
|
|
6819
|
+
properties ?? (properties = {});
|
|
6820
|
+
properties["textureTransform"] = this.texture.calculateUVTransform(this._private_textureTransform);
|
|
6821
|
+
this.texture.setUVTransformDirtyFalse();
|
|
6822
|
+
}
|
|
6823
|
+
if (properties) {
|
|
6824
|
+
this.sceneWrapper.setProperties(this.planeHandler, properties);
|
|
6825
|
+
}
|
|
6826
|
+
const isTransformDirty = this.micro.dirty ||
|
|
6256
6827
|
this.texture.trimDirty ||
|
|
6257
|
-
this.micro.dirty ||
|
|
6258
6828
|
this.inputWrapper.dirty ||
|
|
6259
|
-
this.solverWrapper.dirty
|
|
6260
|
-
|
|
6829
|
+
this.solverWrapper.dirty;
|
|
6830
|
+
if (isTransformDirty) {
|
|
6261
6831
|
const micro = this.micro;
|
|
6262
|
-
|
|
6263
|
-
this.
|
|
6264
|
-
this.texture.setUVTransformDirtyFalse();
|
|
6265
|
-
this.texture.setTrimDirtyFalse();
|
|
6832
|
+
const textureTrim = this.texture.trim;
|
|
6833
|
+
this.sceneWrapper.setTransform(this.planeHandler, 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));
|
|
6266
6834
|
this.micro.setDirtyFalse();
|
|
6835
|
+
this.texture.setTrimDirtyFalse();
|
|
6267
6836
|
}
|
|
6268
6837
|
}
|
|
6269
6838
|
_private_calculateSliceBordersForShader(result) {
|
|
@@ -6296,14 +6865,14 @@ class UINineSlice extends UIElement {
|
|
|
6296
6865
|
const height = this.height;
|
|
6297
6866
|
return result.set(this.sliceRegions.left / width, this.sliceRegions.right / width, this.sliceRegions.top / height, this.sliceRegions.bottom / height);
|
|
6298
6867
|
}
|
|
6299
|
-
|
|
6868
|
+
_private_checkElementDimensionsDirty() {
|
|
6300
6869
|
return (this.solverWrapper.dirty &&
|
|
6301
|
-
(this.
|
|
6302
|
-
this.
|
|
6870
|
+
(this._private_lastElementWidth !== Math.round(this.width) ||
|
|
6871
|
+
this._private_lastElementHeight !== Math.round(this.height)));
|
|
6303
6872
|
}
|
|
6304
|
-
|
|
6305
|
-
this.
|
|
6306
|
-
this.
|
|
6873
|
+
_private_setElementDimensionsDirtyFalse() {
|
|
6874
|
+
this._private_lastElementWidth = Math.round(this.width);
|
|
6875
|
+
this._private_lastElementHeight = Math.round(this.height);
|
|
6307
6876
|
}
|
|
6308
6877
|
}
|
|
6309
6878
|
|
|
@@ -6372,15 +6941,6 @@ class UIProgressMaskFunctionDirectional extends UIProgressMaskFunction {
|
|
|
6372
6941
|
var source$1 = "vec4 draw(){vec2 transformedUV=(p_textureTransform*vec3(p_uv,1.0)).xy;vec4 diffuseColor=texture2D(p_texture,transformedUV)*p_color;diffuseColor.a*=calculateMask();return diffuseColor;}";
|
|
6373
6942
|
|
|
6374
6943
|
const PROGRESS_DEFAULT_VALUE = 1;
|
|
6375
|
-
const PROGRESS_TEMP_PROPERTIES = {};
|
|
6376
|
-
function simplifyGLSLSource(source) {
|
|
6377
|
-
return source
|
|
6378
|
-
.replace(/\/\*[\s\S]*?\*\//g, "")
|
|
6379
|
-
.replace(/\/\/[^\n]*/g, "")
|
|
6380
|
-
.replace(/\s*([{}(),=;+\-*/<>])\s*/g, "$1")
|
|
6381
|
-
.replace(/\s+/g, " ")
|
|
6382
|
-
.trim();
|
|
6383
|
-
}
|
|
6384
6944
|
|
|
6385
6945
|
/** Progress bar with customizable fill direction */
|
|
6386
6946
|
class UIProgress extends UIElement {
|
|
@@ -6394,16 +6954,18 @@ class UIProgress extends UIElement {
|
|
|
6394
6954
|
* @param options - Configuration options
|
|
6395
6955
|
*/
|
|
6396
6956
|
constructor(layer, texture, options = {}) {
|
|
6957
|
+
if (options.progress !== undefined) {
|
|
6958
|
+
assertValidNumber(options.progress, "UIProgress.constructor.options.progress");
|
|
6959
|
+
}
|
|
6397
6960
|
const color = new UIColor(options.color);
|
|
6398
6961
|
const textureView = new UITextureView(texture);
|
|
6399
6962
|
const textureTransform = textureView.calculateUVTransform();
|
|
6400
6963
|
const textureResolution = textureView.getResolution();
|
|
6401
6964
|
options.width = options.width ?? textureView.width;
|
|
6402
6965
|
options.height = options.height ?? textureView.height;
|
|
6403
|
-
const progress = options.progress ?? PROGRESS_DEFAULT_VALUE;
|
|
6966
|
+
const progress = MathUtils.clamp(options.progress ?? PROGRESS_DEFAULT_VALUE, 0, 1);
|
|
6404
6967
|
const maskFunction = options.maskFunction ?? new UIProgressMaskFunctionDirectional();
|
|
6405
|
-
|
|
6406
|
-
super(layer, simplifiedSource, {
|
|
6968
|
+
super(layer, maskFunction.source + source$1, {
|
|
6407
6969
|
texture: textureView.texture,
|
|
6408
6970
|
textureTransform,
|
|
6409
6971
|
textureResolution,
|
|
@@ -6432,64 +6994,53 @@ class UIProgress extends UIElement {
|
|
|
6432
6994
|
get progress() {
|
|
6433
6995
|
return this._private_progressInternal;
|
|
6434
6996
|
}
|
|
6435
|
-
/** Progress from 0 (empty) to 1 (full). Clamped
|
|
6997
|
+
/** Progress from 0 (empty) to 1 (full). Clamped. */
|
|
6436
6998
|
set progress(value) {
|
|
6999
|
+
assertValidNumber(value, "UIProgress.progress");
|
|
7000
|
+
value = MathUtils.clamp(value, 0, 1);
|
|
6437
7001
|
if (this._private_progressInternal !== value) {
|
|
6438
7002
|
this._private_progressInternal = value;
|
|
6439
7003
|
this._private_progressDirty = true;
|
|
6440
7004
|
}
|
|
6441
7005
|
}
|
|
6442
7006
|
setPlaneTransform() {
|
|
7007
|
+
let properties;
|
|
6443
7008
|
if (this.color.dirty) {
|
|
6444
|
-
|
|
7009
|
+
properties ?? (properties = {});
|
|
7010
|
+
properties["color"] = this.color;
|
|
6445
7011
|
this.color.setDirtyFalse();
|
|
6446
7012
|
}
|
|
6447
|
-
else {
|
|
6448
|
-
delete PROGRESS_TEMP_PROPERTIES["color"];
|
|
6449
|
-
}
|
|
6450
7013
|
if (this.texture.textureDirty) {
|
|
6451
|
-
|
|
7014
|
+
properties ?? (properties = {});
|
|
7015
|
+
properties["texture"] = this.texture.texture;
|
|
6452
7016
|
this.texture.setTextureDirtyFalse();
|
|
6453
7017
|
}
|
|
6454
|
-
else {
|
|
6455
|
-
delete PROGRESS_TEMP_PROPERTIES["texture"];
|
|
6456
|
-
}
|
|
6457
7018
|
if (this.texture.uvTransformDirty) {
|
|
6458
|
-
|
|
6459
|
-
|
|
7019
|
+
properties ?? (properties = {});
|
|
7020
|
+
properties["textureTransform"] = this.texture.calculateUVTransform(this._private_textureTransform);
|
|
6460
7021
|
this.texture.setUVTransformDirtyFalse();
|
|
6461
7022
|
}
|
|
6462
|
-
|
|
6463
|
-
|
|
6464
|
-
|
|
6465
|
-
if (this.texture.uvTransformDirty) {
|
|
6466
|
-
PROGRESS_TEMP_PROPERTIES["progress"] = this._private_progressInternal;
|
|
7023
|
+
if (this._private_progressDirty) {
|
|
7024
|
+
properties ?? (properties = {});
|
|
7025
|
+
properties["progress"] = this._private_progressInternal;
|
|
6467
7026
|
this._private_progressDirty = false;
|
|
6468
7027
|
}
|
|
6469
|
-
else {
|
|
6470
|
-
delete PROGRESS_TEMP_PROPERTIES["progress"];
|
|
6471
|
-
}
|
|
6472
7028
|
if (this._private_textureResolutionDirty) {
|
|
6473
|
-
|
|
6474
|
-
|
|
7029
|
+
properties ?? (properties = {});
|
|
7030
|
+
properties["textureResolution"] = this.texture.getResolution(this._private_textureResolution);
|
|
6475
7031
|
this._private_textureResolutionDirty = false;
|
|
6476
7032
|
}
|
|
6477
|
-
else {
|
|
6478
|
-
delete PROGRESS_TEMP_PROPERTIES["textureResolution"];
|
|
6479
|
-
}
|
|
6480
7033
|
if (this.maskFunction.dirty) {
|
|
6481
|
-
|
|
6482
|
-
|
|
6483
|
-
|
|
7034
|
+
properties ?? (properties = {});
|
|
7035
|
+
const maskProperties = this.maskFunction.enumerateProperties();
|
|
7036
|
+
for (const key in maskProperties) {
|
|
7037
|
+
properties[key] = maskProperties[key];
|
|
6484
7038
|
}
|
|
6485
7039
|
this.maskFunction.setDirtyFalse();
|
|
6486
7040
|
}
|
|
6487
|
-
|
|
6488
|
-
|
|
6489
|
-
delete PROGRESS_TEMP_PROPERTIES[key];
|
|
6490
|
-
}
|
|
7041
|
+
if (properties) {
|
|
7042
|
+
this.sceneWrapper.setProperties(this.planeHandler, properties);
|
|
6491
7043
|
}
|
|
6492
|
-
this.sceneWrapper.setProperties(this.planeHandler, PROGRESS_TEMP_PROPERTIES);
|
|
6493
7044
|
const isTransformDirty = this.micro.dirty ||
|
|
6494
7045
|
this.texture.trimDirty ||
|
|
6495
7046
|
this.inputWrapper.dirty ||
|
|
@@ -6538,11 +7089,10 @@ class UIScene extends UIElement {
|
|
|
6538
7089
|
* @throws If resolutionFactor outside range 0.1 to 2.0
|
|
6539
7090
|
*/
|
|
6540
7091
|
constructor(layer, options = {}) {
|
|
6541
|
-
|
|
6542
|
-
|
|
6543
|
-
resolutionFactor > SCENE_MAX_RESOLUTION_FACTOR) {
|
|
6544
|
-
throw new Error(`UIScene.constructor.resolutionFactor: must be between ${SCENE_MIN_RESOLUTION_FACTOR} and ${SCENE_MAX_RESOLUTION_FACTOR}.`);
|
|
7092
|
+
if (options.resolutionFactor !== undefined) {
|
|
7093
|
+
assertValidPositiveNumber(options.resolutionFactor, "UIScene.constructor.resolutionFactor");
|
|
6545
7094
|
}
|
|
7095
|
+
const resolutionFactor = MathUtils.clamp(options.resolutionFactor ?? SCENE_DEFAULT_RESOLUTION_FACTOR, SCENE_MIN_RESOLUTION_FACTOR, SCENE_MAX_RESOLUTION_FACTOR);
|
|
6546
7096
|
const w = options.width ?? DUMMY_DEFAULT_WIDTH;
|
|
6547
7097
|
const h = options.height ?? DUMMY_DEFAULT_HEIGHT;
|
|
6548
7098
|
const renderTarget = new WebGLRenderTarget(w * resolutionFactor, h * resolutionFactor, {
|
|
@@ -6613,6 +7163,8 @@ class UIScene extends UIElement {
|
|
|
6613
7163
|
}
|
|
6614
7164
|
/** Render target resolution multiplier. Range 0.1 to 2.0. */
|
|
6615
7165
|
set resolutionFactor(value) {
|
|
7166
|
+
assertValidPositiveNumber(value, "UIScene.resolutionFactor");
|
|
7167
|
+
value = MathUtils.clamp(value, SCENE_MIN_RESOLUTION_FACTOR, SCENE_MAX_RESOLUTION_FACTOR);
|
|
6616
7168
|
if (this._private_resolutionFactorInternal !== value) {
|
|
6617
7169
|
this._private_resolutionFactorInternal = value;
|
|
6618
7170
|
this._private_resolutionFactorDirty = true;
|
|
@@ -6629,14 +7181,15 @@ class UIScene extends UIElement {
|
|
|
6629
7181
|
}
|
|
6630
7182
|
onWillRender(renderer, deltaTime) {
|
|
6631
7183
|
this._private_evenFrame = !this._private_evenFrame;
|
|
6632
|
-
|
|
7184
|
+
const isFramebufferDirty = this._private_updateRequired ||
|
|
6633
7185
|
this._private_updateModeInternal === UISceneUpdateMode.EACH_FRAME ||
|
|
6634
7186
|
(this._private_updateModeInternal === UISceneUpdateMode.EVERY_SECOND_FRAME && this._private_evenFrame) ||
|
|
6635
7187
|
(this._private_updateModeInternal === UISceneUpdateMode.ON_PROPERTIES_CHANGE && this._private_propertyDirty) ||
|
|
6636
7188
|
this.color.dirty ||
|
|
6637
7189
|
this.clearColor.dirty ||
|
|
6638
7190
|
(this._private_updateModeInternal === UISceneUpdateMode.ON_DIMENSIONS_CHANGE &&
|
|
6639
|
-
(this._private_resolutionFactorDirty || this.solverWrapper.dirty))
|
|
7191
|
+
(this._private_resolutionFactorDirty || this.solverWrapper.dirty));
|
|
7192
|
+
if (isFramebufferDirty) {
|
|
6640
7193
|
if (this._private_resolutionFactorDirty || this.solverWrapper.dirty) {
|
|
6641
7194
|
this._private_renderTarget.setSize(this.width * this._private_resolutionFactorInternal, this.height * this._private_resolutionFactorInternal);
|
|
6642
7195
|
this._private_resolutionFactorDirty = false;
|
|
@@ -7415,10 +7968,6 @@ class UIText extends UIElement {
|
|
|
7415
7968
|
super.destroy();
|
|
7416
7969
|
}
|
|
7417
7970
|
onWillRender(renderer, deltaTime) {
|
|
7418
|
-
if (this.color.dirty) {
|
|
7419
|
-
this.sceneWrapper.setProperties(this.planeHandler, { color: this.color });
|
|
7420
|
-
this.color.setDirtyFalse();
|
|
7421
|
-
}
|
|
7422
7971
|
switch (this._private_resizeModeInternal) {
|
|
7423
7972
|
case UITextResizeMode.SCALE:
|
|
7424
7973
|
this._private_tryToRenderTextScaleMode();
|
|
@@ -7458,9 +8007,7 @@ class UIText extends UIElement {
|
|
|
7458
8007
|
this._private_canvas.width = desiredWidth;
|
|
7459
8008
|
}
|
|
7460
8009
|
renderTextLines(this.padding.top, this.padding.left, lines, this._private_context);
|
|
7461
|
-
|
|
7462
|
-
this._private_rebuildTexture();
|
|
7463
|
-
}
|
|
8010
|
+
this._private_updateProperties(resolutionDirty);
|
|
7464
8011
|
this._private_resizeModeDirty = false;
|
|
7465
8012
|
this._private_maxLineWidthDirty = false;
|
|
7466
8013
|
this.padding.setDirtyFalse();
|
|
@@ -7495,23 +8042,31 @@ class UIText extends UIElement {
|
|
|
7495
8042
|
this._private_canvas.height = safeHeight;
|
|
7496
8043
|
}
|
|
7497
8044
|
renderTextLines(this.padding.top, this.padding.left, realTextLines, this._private_context);
|
|
7498
|
-
|
|
7499
|
-
this._private_rebuildTexture();
|
|
7500
|
-
}
|
|
8045
|
+
this._private_updateProperties(resolutionDirty);
|
|
7501
8046
|
this._private_resizeModeDirty = false;
|
|
7502
8047
|
this._private_maxLineWidthDirty = false;
|
|
7503
8048
|
this.padding.setDirtyFalse();
|
|
7504
8049
|
this._private_setDimensionsDirtyFalse();
|
|
7505
8050
|
this._private_setContentDirtyFalse();
|
|
7506
8051
|
}
|
|
7507
|
-
|
|
7508
|
-
|
|
7509
|
-
|
|
7510
|
-
|
|
7511
|
-
|
|
7512
|
-
|
|
7513
|
-
|
|
7514
|
-
|
|
8052
|
+
_private_updateProperties(resolutionDirty) {
|
|
8053
|
+
let properties;
|
|
8054
|
+
if (this.color.dirty) {
|
|
8055
|
+
properties ?? (properties = {});
|
|
8056
|
+
properties["color"] = this.color;
|
|
8057
|
+
this.color.setDirtyFalse();
|
|
8058
|
+
}
|
|
8059
|
+
if (resolutionDirty) {
|
|
8060
|
+
this._private_texture.dispose();
|
|
8061
|
+
this._private_texture = new CanvasTexture(this._private_canvas);
|
|
8062
|
+
this._private_texture.colorSpace = SRGBColorSpace;
|
|
8063
|
+
this._private_texture.needsUpdate = true;
|
|
8064
|
+
properties ?? (properties = {});
|
|
8065
|
+
properties["texture"] = this._private_texture;
|
|
8066
|
+
}
|
|
8067
|
+
if (properties) {
|
|
8068
|
+
this.sceneWrapper.setProperties(this.planeHandler, properties);
|
|
8069
|
+
}
|
|
7515
8070
|
}
|
|
7516
8071
|
_private_buildTextChunks() {
|
|
7517
8072
|
if (this._private_textChunksDirty) {
|
|
@@ -7557,15 +8112,18 @@ class UIResizePolicyNone extends UIResizePolicy {
|
|
|
7557
8112
|
}
|
|
7558
8113
|
}
|
|
7559
8114
|
|
|
8115
|
+
const FULLSCREEN_LAYER_DEFAULT_RESIZE_POLICY = new UIResizePolicyNone();
|
|
8116
|
+
|
|
7560
8117
|
/** Layer that automatically handles browser window resizing and input events */
|
|
7561
8118
|
class UIFullscreenLayer extends UILayer {
|
|
7562
|
-
|
|
7563
|
-
|
|
7564
|
-
* @param mode Initial visibility and interactivity mode
|
|
7565
|
-
*/
|
|
7566
|
-
constructor(resizePolicy = new UIResizePolicyNone(), mode = UIMode.VISIBLE) {
|
|
8119
|
+
constructor(options) {
|
|
8120
|
+
const resizePolicy = options?.resizePolicy ?? FULLSCREEN_LAYER_DEFAULT_RESIZE_POLICY;
|
|
7567
8121
|
const scale = resizePolicy.calculateScale(window.innerWidth, window.innerHeight);
|
|
7568
|
-
super(
|
|
8122
|
+
super({
|
|
8123
|
+
width: window.innerWidth * scale,
|
|
8124
|
+
height: window.innerHeight * scale,
|
|
8125
|
+
...options,
|
|
8126
|
+
});
|
|
7569
8127
|
this._private_resizePolicyDirty = false;
|
|
7570
8128
|
this._private_onResize = () => {
|
|
7571
8129
|
const scale = this.resizePolicy.calculateScale(window.innerWidth, window.innerHeight);
|
|
@@ -7685,9 +8243,14 @@ class UIAreaCircle extends UIArea {
|
|
|
7685
8243
|
this.centerX = centerX;
|
|
7686
8244
|
this.centerY = centerY;
|
|
7687
8245
|
this.radius = radius;
|
|
8246
|
+
assertValidNonNegativeNumber(centerX, "UIAreaCircle.constructor.centerX");
|
|
8247
|
+
assertValidNonNegativeNumber(centerY, "UIAreaCircle.constructor.centerY");
|
|
8248
|
+
assertValidNonNegativeNumber(radius, "UIAreaCircle.constructor.radius");
|
|
7688
8249
|
}
|
|
7689
8250
|
/** @internal */
|
|
7690
8251
|
contains(pointX, pointY) {
|
|
8252
|
+
assertValidNumber(pointX, "UIAreaCircle.contains.pointX");
|
|
8253
|
+
assertValidNumber(pointY, "UIAreaCircle.contains.pointY");
|
|
7691
8254
|
const deltaX = pointX - this.centerX;
|
|
7692
8255
|
const deltaY = pointY - this.centerY;
|
|
7693
8256
|
return deltaX * deltaX + deltaY * deltaY <= this.radius * this.radius;
|
|
@@ -7707,6 +8270,8 @@ class UIAreaPolygon extends UIArea {
|
|
|
7707
8270
|
}
|
|
7708
8271
|
/** @internal */
|
|
7709
8272
|
contains(pointX, pointY) {
|
|
8273
|
+
assertValidNumber(pointX, "UIAreaPolygon.contains.pointX");
|
|
8274
|
+
assertValidNumber(pointY, "UIAreaPolygon.contains.pointY");
|
|
7710
8275
|
const vertexCount = this.vertices.length;
|
|
7711
8276
|
if (vertexCount < 3) {
|
|
7712
8277
|
return false;
|
|
@@ -7751,10 +8316,17 @@ class UIAreaRoundedRectangle extends UIArea {
|
|
|
7751
8316
|
this.width = width;
|
|
7752
8317
|
this.height = height;
|
|
7753
8318
|
this.radius = radius;
|
|
8319
|
+
assertValidNonNegativeNumber(x, "UIAreaRoundedRectangle.constructor.x");
|
|
8320
|
+
assertValidNonNegativeNumber(y, "UIAreaRoundedRectangle.constructor.y");
|
|
8321
|
+
assertValidNonNegativeNumber(width, "UIAreaRoundedRectangle.constructor.width");
|
|
8322
|
+
assertValidNonNegativeNumber(height, "UIAreaRoundedRectangle.constructor.height");
|
|
8323
|
+
assertValidNonNegativeNumber(radius, "UIAreaRoundedRectangle.constructor.radius");
|
|
7754
8324
|
this.radius = Math.min(radius, Math.min(width, height) / 2);
|
|
7755
8325
|
}
|
|
7756
8326
|
/** @internal */
|
|
7757
8327
|
contains(pointX, pointY) {
|
|
8328
|
+
assertValidNumber(pointX, "UIAreaRoundedRectangle.contains.pointX");
|
|
8329
|
+
assertValidNumber(pointY, "UIAreaRoundedRectangle.contains.pointY");
|
|
7758
8330
|
const left = this.x;
|
|
7759
8331
|
const right = this.x + this.width;
|
|
7760
8332
|
const top = this.y;
|
|
@@ -7803,6 +8375,7 @@ class UIProgressMaskFunctionCircular extends UIProgressMaskFunction {
|
|
|
7803
8375
|
* @param inverseDirection - Whether to fill counter-clockwise
|
|
7804
8376
|
*/
|
|
7805
8377
|
constructor(startAngle = 0, inverseDirection = false) {
|
|
8378
|
+
assertValidNumber(startAngle, "UIProgressMaskFunctionCircular.constructor.startAngle");
|
|
7806
8379
|
super(source);
|
|
7807
8380
|
this._private_startAngleInternal = startAngle;
|
|
7808
8381
|
this._private_inverseDirectionInternal = inverseDirection;
|
|
@@ -7817,6 +8390,7 @@ class UIProgressMaskFunctionCircular extends UIProgressMaskFunction {
|
|
|
7817
8390
|
}
|
|
7818
8391
|
/** Starting angle in radians */
|
|
7819
8392
|
set startAngle(value) {
|
|
8393
|
+
assertValidNumber(value, "UIProgressMaskFunctionCircular.startAngle");
|
|
7820
8394
|
if (this._private_startAngleInternal !== value) {
|
|
7821
8395
|
this._private_startAngleInternal = value;
|
|
7822
8396
|
this.dirtyInternal = true;
|
|
@@ -8122,5 +8696,5 @@ class UIResizePolicyFixedWidth extends UIResizePolicy {
|
|
|
8122
8696
|
}
|
|
8123
8697
|
}
|
|
8124
8698
|
|
|
8125
|
-
export { UIAnchor, UIAnimatedImage, UIAreaCircle, UIAreaPolygon, UIAreaRectangle, UIAreaRoundedRectangle, UIAspectConstraint, UIColor, UIConstraint2DBuilder, UICoverConstraintBuilder, UICustomConstraint, UIExpression, UIFitConstraintBuilder, UIFullscreenLayer, UIGraphics, UIHeightConstraint, UIHorizontalDistanceConstraint, UIHorizontalProportionConstraint, UIImage, UIInputDummy, UIInputEvent, UIMicro, UIMicroAnchorMode, UIMode, UINineSlice, UINineSliceRegionMode, UIOrientation, UIPriority, UIProgress, UIProgressMaskFunctionCircular, UIProgressMaskFunctionDirectional, UIRelation, UIResizePolicyCover, UIResizePolicyCross, UIResizePolicyCrossInverted, UIResizePolicyFit, UIResizePolicyFixedHeight, UIResizePolicyFixedWidth, UIResizePolicyNone, UIScene, UISceneUpdateMode, UISingleParameterConstraint, UIText, UITextResizeMode, UITransparencyMode, UIVerticalDistanceConstraint, UIVerticalProportionConstraint, UIWidthConstraint };
|
|
8699
|
+
export { UIAnchor, UIAnimatedImage, UIAreaCircle, UIAreaPolygon, UIAreaRectangle, UIAreaRoundedRectangle, UIAspectConstraint, UIColor, UIConstraint2DBuilder, UICoverConstraintBuilder, UICustomConstraint, UIExpression, UIFitConstraintBuilder, UIFullscreenLayer, UIGraphics, UIHeightConstraint, UIHorizontalDistanceConstraint, UIHorizontalInterpolationConstraint, UIHorizontalProportionConstraint, UIImage, UIInputDummy, UIInputEvent, UILoopMode, UIMicro, UIMicroAnchorMode, UIMode, UINineSlice, UINineSliceRegionMode, UIOrientation, UIPriority, UIProgress, UIProgressMaskFunctionCircular, UIProgressMaskFunctionDirectional, UIRelation, UIResizePolicyCover, UIResizePolicyCross, UIResizePolicyCrossInverted, UIResizePolicyFit, UIResizePolicyFixedHeight, UIResizePolicyFixedWidth, UIResizePolicyNone, UIScene, UISceneUpdateMode, UISingleParameterConstraint, UIText, UITextResizeMode, UITransparencyMode, UIVerticalDistanceConstraint, UIVerticalInterpolationConstraint, UIVerticalProportionConstraint, UIWidthConstraint };
|
|
8126
8700
|
//# sourceMappingURL=index.js.map
|