laymur 0.11.3 → 0.11.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -1
- 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/{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/{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 +20 -9
- package/dist/constraints/builders/UICoverConstraintBuilder.d.ts +6 -6
- package/dist/constraints/builders/UIFitConstraintBuilder.d.ts +6 -6
- package/dist/elements/{UIAnchor.d.ts → UIAnchor/UIAnchor.d.ts} +3 -3
- package/dist/elements/{UIAnimatedImage.Internal.d.ts → UIAnimatedImage/UIAnimatedImage.Internal.d.ts} +2 -2
- package/dist/elements/{UIAnimatedImage.d.ts → UIAnimatedImage/UIAnimatedImage.d.ts} +6 -6
- package/dist/elements/UIElement/UIElement.Internal.d.ts +11 -0
- package/dist/elements/{UIElement.d.ts → UIElement/UIElement.d.ts} +9 -9
- package/dist/elements/{UIGraphics.Internal.d.ts → UIGraphics/UIGraphics.Internal.d.ts} +2 -2
- package/dist/elements/{UIGraphics.d.ts → UIGraphics/UIGraphics.d.ts} +3 -3
- package/dist/elements/{UIImage.Internal.d.ts → UIImage/UIImage.Internal.d.ts} +2 -2
- package/dist/elements/{UIImage.d.ts → UIImage/UIImage.d.ts} +6 -6
- package/dist/elements/{UIDummy.Internal.d.ts → UIInputDummy/UIInputDummy.Internal.d.ts} +5 -5
- package/dist/elements/{UIDummy.d.ts → UIInputDummy/UIInputDummy.d.ts} +11 -11
- package/dist/elements/{UINineSlice.Internal.d.ts → UINineSlice/UINineSlice.Internal.d.ts} +5 -5
- package/dist/elements/{UINineSlice.d.ts → UINineSlice/UINineSlice.d.ts} +9 -9
- package/dist/elements/{UIProgress.Internal.d.ts → UIProgress/UIProgress.Internal.d.ts} +3 -3
- package/dist/elements/{UIProgress.d.ts → UIProgress/UIProgress.d.ts} +10 -9
- package/dist/elements/{UIScene.Internal.d.ts → UIScene/UIScene.Internal.d.ts} +3 -3
- package/dist/elements/{UIScene.d.ts → UIScene/UIScene.d.ts} +3 -3
- package/dist/elements/UIText/UIText.Internal.d.ts +3 -3
- package/dist/elements/UIText/UIText.d.ts +3 -3
- package/dist/index.d.ts +19 -17
- package/dist/index.js +893 -295
- 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/UILayer.d.ts +1 -1
- package/dist/miscellaneous/asserts.d.ts +21 -54
- package/dist/miscellaneous/color/UIColor.d.ts +1 -0
- package/dist/miscellaneous/insets/UIInsets.Internal.d.ts +11 -0
- package/dist/miscellaneous/{padding/UIPadding.d.ts → insets/UIInsets.d.ts} +15 -15
- package/dist/miscellaneous/shared.d.ts +46 -0
- package/dist/miscellaneous/texture/UITextureView.d.ts +13 -9
- package/package.json +6 -3
- package/dist/elements/UIElement.Internal.d.ts +0 -11
- package/dist/miscellaneous/padding/UIPadding.Internal.d.ts +0 -11
- /package/dist/elements/{UIAnchor.Internal.d.ts → UIAnchor/UIAnchor.Internal.d.ts} +0 -0
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
|
/**
|
|
@@ -4027,7 +4081,6 @@ class UILayer extends i {
|
|
|
4027
4081
|
}
|
|
4028
4082
|
}
|
|
4029
4083
|
|
|
4030
|
-
const EPSILON = 1e-6;
|
|
4031
4084
|
/**
|
|
4032
4085
|
* Checks if object implements UILayerElement.
|
|
4033
4086
|
* @param obj Object to check
|
|
@@ -4073,37 +4126,8 @@ function isUIPlaneElement(obj) {
|
|
|
4073
4126
|
"height" in obj &&
|
|
4074
4127
|
typeof obj.height === "number");
|
|
4075
4128
|
}
|
|
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
|
-
}
|
|
4129
|
+
|
|
4130
|
+
const EPSILON = 1e-6;
|
|
4107
4131
|
/**
|
|
4108
4132
|
* Validates value is finite number within safe range.
|
|
4109
4133
|
* @param value Number to validate
|
|
@@ -4148,6 +4172,119 @@ function assertValidNonNegativeNumber(value, subject) {
|
|
|
4148
4172
|
}
|
|
4149
4173
|
}
|
|
4150
4174
|
}
|
|
4175
|
+
/**
|
|
4176
|
+
* Validates constraint arguments are from same layer.
|
|
4177
|
+
* @param a First constraint subject
|
|
4178
|
+
* @param b Second constraint subject
|
|
4179
|
+
* @param subject Constraint name for error messages
|
|
4180
|
+
* @returns Common layer for both subjects
|
|
4181
|
+
* @throws If subjects are invalid or from different layers
|
|
4182
|
+
*/
|
|
4183
|
+
function assertValidConstraintArguments(a, b, subject) {
|
|
4184
|
+
if ("development" !== "production") {
|
|
4185
|
+
if (a instanceof UILayer && b instanceof UILayer) {
|
|
4186
|
+
throw new Error(`${subject}: layer cannot be snapped to another layer`);
|
|
4187
|
+
}
|
|
4188
|
+
let layerA;
|
|
4189
|
+
let layerB;
|
|
4190
|
+
if (a instanceof UILayer) {
|
|
4191
|
+
layerA = a;
|
|
4192
|
+
}
|
|
4193
|
+
else if (isUILayerElement(a)) {
|
|
4194
|
+
layerA = a.layer;
|
|
4195
|
+
}
|
|
4196
|
+
else {
|
|
4197
|
+
throw new Error(`${subject}: A must be a UILayer or a UILayerElement`);
|
|
4198
|
+
}
|
|
4199
|
+
if (b instanceof UILayer) {
|
|
4200
|
+
layerB = b;
|
|
4201
|
+
}
|
|
4202
|
+
else if (isUILayerElement(b)) {
|
|
4203
|
+
layerB = b.layer;
|
|
4204
|
+
}
|
|
4205
|
+
else {
|
|
4206
|
+
throw new Error(`${subject}: B must be a UILayer or a UILayerElement`);
|
|
4207
|
+
}
|
|
4208
|
+
if (layerA !== layerB) {
|
|
4209
|
+
throw new Error(`${subject}: elements must be on the same layer`);
|
|
4210
|
+
}
|
|
4211
|
+
return layerA;
|
|
4212
|
+
}
|
|
4213
|
+
if (a instanceof UILayer) {
|
|
4214
|
+
return a;
|
|
4215
|
+
}
|
|
4216
|
+
if (isUILayerElement(a)) {
|
|
4217
|
+
return a.layer;
|
|
4218
|
+
}
|
|
4219
|
+
if (b instanceof UILayer) {
|
|
4220
|
+
return b;
|
|
4221
|
+
}
|
|
4222
|
+
if (isUILayerElement(b)) {
|
|
4223
|
+
return b.layer;
|
|
4224
|
+
}
|
|
4225
|
+
throw new Error(`${subject}: no valid subjects found`);
|
|
4226
|
+
}
|
|
4227
|
+
/**
|
|
4228
|
+
* Validates interpolation constraint subjects.
|
|
4229
|
+
* @param subject Constraint name for error messages
|
|
4230
|
+
* @param a First element
|
|
4231
|
+
* @param b Second element
|
|
4232
|
+
* @param c Element to interpolate
|
|
4233
|
+
* @param anchorA Anchor on element A
|
|
4234
|
+
* @param anchorB Anchor on element B
|
|
4235
|
+
* @returns Common layer for all subjects
|
|
4236
|
+
* @throws If subjects violate interpolation constraints
|
|
4237
|
+
*/
|
|
4238
|
+
function assertValidInterpolationConstraintArguments(subject, a, b, c, anchorA, anchorB) {
|
|
4239
|
+
if ("development" !== "production") {
|
|
4240
|
+
if (c instanceof UILayer) {
|
|
4241
|
+
throw new Error(`${subject}: C cannot be a layer`);
|
|
4242
|
+
}
|
|
4243
|
+
if (!isUILayerElement(c)) {
|
|
4244
|
+
throw new Error(`${subject}: C must be a UILayerElement`);
|
|
4245
|
+
}
|
|
4246
|
+
let layerA;
|
|
4247
|
+
let layerB;
|
|
4248
|
+
if (a instanceof UILayer || isUILayerElement(a)) {
|
|
4249
|
+
layerA = a instanceof UILayer ? a : a.layer;
|
|
4250
|
+
}
|
|
4251
|
+
else {
|
|
4252
|
+
throw new Error(`${subject}: A must be UILayer or UILayerElement`);
|
|
4253
|
+
}
|
|
4254
|
+
if (b instanceof UILayer || isUILayerElement(b)) {
|
|
4255
|
+
layerB = b instanceof UILayer ? b : b.layer;
|
|
4256
|
+
}
|
|
4257
|
+
else {
|
|
4258
|
+
throw new Error(`${subject}: B must be UILayer or UILayerElement`);
|
|
4259
|
+
}
|
|
4260
|
+
const layerC = c.layer;
|
|
4261
|
+
if (layerA !== layerB || layerA !== layerC) {
|
|
4262
|
+
throw new Error(`${subject}: all elements must be on the same layer`);
|
|
4263
|
+
}
|
|
4264
|
+
if (c === a || c === b) {
|
|
4265
|
+
throw new Error(`${subject}: C cannot be equal to A or B`);
|
|
4266
|
+
}
|
|
4267
|
+
if (a === b) {
|
|
4268
|
+
if (Math.abs(anchorA - anchorB) <= EPSILON) {
|
|
4269
|
+
throw new Error(`${subject}: when A and B are the same, anchorA and anchorB must differ by more than ${EPSILON}`);
|
|
4270
|
+
}
|
|
4271
|
+
}
|
|
4272
|
+
return layerA;
|
|
4273
|
+
}
|
|
4274
|
+
if (a instanceof UILayer) {
|
|
4275
|
+
return a;
|
|
4276
|
+
}
|
|
4277
|
+
if (isUILayerElement(a)) {
|
|
4278
|
+
return a.layer;
|
|
4279
|
+
}
|
|
4280
|
+
if (b instanceof UILayer) {
|
|
4281
|
+
return b;
|
|
4282
|
+
}
|
|
4283
|
+
if (isUILayerElement(b)) {
|
|
4284
|
+
return b.layer;
|
|
4285
|
+
}
|
|
4286
|
+
throw new Error(`${subject}: no valid subjects found`);
|
|
4287
|
+
}
|
|
4151
4288
|
|
|
4152
4289
|
/** Base class for layout constraints */
|
|
4153
4290
|
class UIConstraint {
|
|
@@ -4232,11 +4369,11 @@ class UIHeightConstraint extends UISingleParameterConstraint {
|
|
|
4232
4369
|
* @param options Height configuration. Defaults to element's current height.
|
|
4233
4370
|
*/
|
|
4234
4371
|
constructor(_private_element, options = {}) {
|
|
4235
|
-
super(_private_element.layer, options);
|
|
4236
|
-
this._private_element = _private_element;
|
|
4237
4372
|
if (options.height !== undefined) {
|
|
4238
4373
|
assertValidPositiveNumber(options.height, "UIHeightConstraint.constructor.options.height");
|
|
4239
4374
|
}
|
|
4375
|
+
super(_private_element.layer, options);
|
|
4376
|
+
this._private_element = _private_element;
|
|
4240
4377
|
this._private_heightInternal = options.height ?? _private_element.height;
|
|
4241
4378
|
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
4379
|
}
|
|
@@ -4254,7 +4391,7 @@ class UIHeightConstraint extends UISingleParameterConstraint {
|
|
|
4254
4391
|
}
|
|
4255
4392
|
}
|
|
4256
4393
|
|
|
4257
|
-
const DEFAULT_ANCHOR$
|
|
4394
|
+
const DEFAULT_ANCHOR$4 = 0.5;
|
|
4258
4395
|
|
|
4259
4396
|
/** Maintains horizontal distance between elements with configurable anchors */
|
|
4260
4397
|
class UIHorizontalDistanceConstraint extends UISingleParameterConstraint {
|
|
@@ -4264,9 +4401,6 @@ class UIHorizontalDistanceConstraint extends UISingleParameterConstraint {
|
|
|
4264
4401
|
* @param options Distance configuration
|
|
4265
4402
|
*/
|
|
4266
4403
|
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
4404
|
if (options.anchorA !== undefined) {
|
|
4271
4405
|
assertValidNumber(options.anchorA, "UIHorizontalDistanceConstraint.constructor.options.anchorA");
|
|
4272
4406
|
}
|
|
@@ -4276,8 +4410,11 @@ class UIHorizontalDistanceConstraint extends UISingleParameterConstraint {
|
|
|
4276
4410
|
if (options.distance !== undefined) {
|
|
4277
4411
|
assertValidNumber(options.distance, "UIHorizontalDistanceConstraint.constructor.options.distance");
|
|
4278
4412
|
}
|
|
4279
|
-
|
|
4280
|
-
this.
|
|
4413
|
+
super(assertValidConstraintArguments(_private_a, _private_b, "UIHorizontalDistanceConstraint.constructor"), options);
|
|
4414
|
+
this._private_a = _private_a;
|
|
4415
|
+
this._private_b = _private_b;
|
|
4416
|
+
this._private_anchorAInternal = options.anchorA ?? DEFAULT_ANCHOR$4;
|
|
4417
|
+
this._private_anchorBInternal = options.anchorB ?? DEFAULT_ANCHOR$4;
|
|
4281
4418
|
this._private_distanceInternal = options.distance ?? 0;
|
|
4282
4419
|
this.constraint = this.solverWrapper.createConstraint(this._private_buildLHS(), new UIExpression(this._private_distanceInternal), this.relation, this.priority, this.isConstraintEnabled());
|
|
4283
4420
|
}
|
|
@@ -4349,6 +4486,138 @@ class UIHorizontalDistanceConstraint extends UISingleParameterConstraint {
|
|
|
4349
4486
|
}
|
|
4350
4487
|
}
|
|
4351
4488
|
|
|
4489
|
+
const DEFAULT_ANCHOR$3 = 0.5;
|
|
4490
|
+
const DEFAULT_T$1 = 0.5;
|
|
4491
|
+
|
|
4492
|
+
/** Positions element C horizontally between A and B based on interpolation factor */
|
|
4493
|
+
class UIHorizontalInterpolationConstraint extends UISingleParameterConstraint {
|
|
4494
|
+
/**
|
|
4495
|
+
* @param a First element
|
|
4496
|
+
* @param b Second element
|
|
4497
|
+
* @param c Element to position between A and B
|
|
4498
|
+
* @param options Interpolation configuration
|
|
4499
|
+
*/
|
|
4500
|
+
constructor(_private_a, _private_b, _private_c, options = {}) {
|
|
4501
|
+
if (options.anchorA !== undefined) {
|
|
4502
|
+
assertValidNumber(options.anchorA, "UIHorizontalInterpolationConstraint.constructor.options.anchorA");
|
|
4503
|
+
}
|
|
4504
|
+
if (options.anchorB !== undefined) {
|
|
4505
|
+
assertValidNumber(options.anchorB, "UIHorizontalInterpolationConstraint.constructor.options.anchorB");
|
|
4506
|
+
}
|
|
4507
|
+
if (options.anchorC !== undefined) {
|
|
4508
|
+
assertValidNumber(options.anchorC, "UIHorizontalInterpolationConstraint.constructor.options.anchorC");
|
|
4509
|
+
}
|
|
4510
|
+
if (options.t !== undefined) {
|
|
4511
|
+
assertValidNumber(options.t, "UIHorizontalInterpolationConstraint.constructor.options.t");
|
|
4512
|
+
}
|
|
4513
|
+
const anchorA = options.anchorA ?? DEFAULT_ANCHOR$3;
|
|
4514
|
+
const anchorB = options.anchorB ?? DEFAULT_ANCHOR$3;
|
|
4515
|
+
super(assertValidInterpolationConstraintArguments("UIHorizontalInterpolationConstraint.constructor", _private_a, _private_b, _private_c, anchorA, anchorB), options);
|
|
4516
|
+
this._private_a = _private_a;
|
|
4517
|
+
this._private_b = _private_b;
|
|
4518
|
+
this._private_c = _private_c;
|
|
4519
|
+
this._private_anchorAInternal = anchorA;
|
|
4520
|
+
this._private_anchorBInternal = anchorA;
|
|
4521
|
+
this._private_anchorCInternal = options.anchorC ?? DEFAULT_ANCHOR$3;
|
|
4522
|
+
this._private_tInternal = options.t ?? DEFAULT_T$1;
|
|
4523
|
+
this.constraint = this.solverWrapper.createConstraint(this._private_buildLHS(), new UIExpression(0), this.relation, this.priority, this.isConstraintEnabled());
|
|
4524
|
+
}
|
|
4525
|
+
/** Interpolation factor (0 = A position, 1 = B position) */
|
|
4526
|
+
get t() {
|
|
4527
|
+
return this._private_tInternal;
|
|
4528
|
+
}
|
|
4529
|
+
/** Anchor on element A (0 = left, 0.5 = center, 1 = right) */
|
|
4530
|
+
get anchorA() {
|
|
4531
|
+
return this._private_anchorAInternal;
|
|
4532
|
+
}
|
|
4533
|
+
/** Anchor on element B (0 = left, 0.5 = center, 1 = right) */
|
|
4534
|
+
get anchorB() {
|
|
4535
|
+
return this._private_anchorBInternal;
|
|
4536
|
+
}
|
|
4537
|
+
/** Anchor on element C (0 = left, 0.5 = center, 1 = right) */
|
|
4538
|
+
get anchorC() {
|
|
4539
|
+
return this._private_anchorCInternal;
|
|
4540
|
+
}
|
|
4541
|
+
/** Updates interpolation factor */
|
|
4542
|
+
set t(value) {
|
|
4543
|
+
assertValidNumber(value, "UIHorizontalInterpolationConstraint.t");
|
|
4544
|
+
if (this._private_tInternal !== value) {
|
|
4545
|
+
this._private_tInternal = value;
|
|
4546
|
+
this.solverWrapper.setConstraintLHS(this.constraint, this._private_buildLHS());
|
|
4547
|
+
}
|
|
4548
|
+
}
|
|
4549
|
+
/** Updates anchor on element A */
|
|
4550
|
+
set anchorA(value) {
|
|
4551
|
+
assertValidNumber(value, "UIHorizontalInterpolationConstraint.anchorA");
|
|
4552
|
+
if (this._private_anchorAInternal !== value) {
|
|
4553
|
+
this._private_anchorAInternal = value;
|
|
4554
|
+
this.solverWrapper.setConstraintLHS(this.constraint, this._private_buildLHS());
|
|
4555
|
+
}
|
|
4556
|
+
}
|
|
4557
|
+
/** Updates anchor on element B */
|
|
4558
|
+
set anchorB(value) {
|
|
4559
|
+
assertValidNumber(value, "UIHorizontalInterpolationConstraint.anchorB");
|
|
4560
|
+
if (this._private_anchorBInternal !== value) {
|
|
4561
|
+
this._private_anchorBInternal = value;
|
|
4562
|
+
this.solverWrapper.setConstraintLHS(this.constraint, this._private_buildLHS());
|
|
4563
|
+
}
|
|
4564
|
+
}
|
|
4565
|
+
/** Updates anchor on element C */
|
|
4566
|
+
set anchorC(value) {
|
|
4567
|
+
assertValidNumber(value, "UIHorizontalInterpolationConstraint.anchorC");
|
|
4568
|
+
if (this._private_anchorCInternal !== value) {
|
|
4569
|
+
this._private_anchorCInternal = value;
|
|
4570
|
+
this.solverWrapper.setConstraintLHS(this.constraint, this._private_buildLHS());
|
|
4571
|
+
}
|
|
4572
|
+
}
|
|
4573
|
+
/** Builds constraint expression: C - A*(1-t) - B*t = 0 */
|
|
4574
|
+
_private_buildLHS() {
|
|
4575
|
+
let aExpression;
|
|
4576
|
+
let bExpression;
|
|
4577
|
+
let cExpression;
|
|
4578
|
+
if (isUIPlaneElement(this._private_a)) {
|
|
4579
|
+
aExpression = new UIExpression(0, [
|
|
4580
|
+
[this._private_a.xVariable, 1],
|
|
4581
|
+
[this._private_a.wVariable, this._private_anchorAInternal],
|
|
4582
|
+
]);
|
|
4583
|
+
}
|
|
4584
|
+
else if (isUIPointElement(this._private_a)) {
|
|
4585
|
+
aExpression = new UIExpression().plus(this._private_a.xVariable, 1);
|
|
4586
|
+
}
|
|
4587
|
+
else {
|
|
4588
|
+
throw new Error("UIHorizontalInterpolationConstraint.buildLHS.a: invalid element type");
|
|
4589
|
+
}
|
|
4590
|
+
if (isUIPlaneElement(this._private_b)) {
|
|
4591
|
+
bExpression = new UIExpression(0, [
|
|
4592
|
+
[this._private_b.xVariable, 1],
|
|
4593
|
+
[this._private_b.wVariable, this._private_anchorBInternal],
|
|
4594
|
+
]);
|
|
4595
|
+
}
|
|
4596
|
+
else if (isUIPointElement(this._private_b)) {
|
|
4597
|
+
bExpression = new UIExpression().plus(this._private_b.xVariable, 1);
|
|
4598
|
+
}
|
|
4599
|
+
else {
|
|
4600
|
+
throw new Error("UIHorizontalInterpolationConstraint.buildLHS.b: invalid element type");
|
|
4601
|
+
}
|
|
4602
|
+
if (isUIPlaneElement(this._private_c)) {
|
|
4603
|
+
cExpression = new UIExpression(0, [
|
|
4604
|
+
[this._private_c.xVariable, 1],
|
|
4605
|
+
[this._private_c.wVariable, this._private_anchorCInternal],
|
|
4606
|
+
]);
|
|
4607
|
+
}
|
|
4608
|
+
else if (isUIPointElement(this._private_c)) {
|
|
4609
|
+
cExpression = new UIExpression().plus(this._private_c.xVariable, 1);
|
|
4610
|
+
}
|
|
4611
|
+
else {
|
|
4612
|
+
throw new Error("UIHorizontalInterpolationConstraint.buildLHS.c: invalid element type");
|
|
4613
|
+
}
|
|
4614
|
+
// C - A*(1-t) - B*t = 0
|
|
4615
|
+
const aScaled = aExpression.clone().multiply(1 - this._private_tInternal);
|
|
4616
|
+
const bScaled = bExpression.clone().multiply(this._private_tInternal);
|
|
4617
|
+
return UIExpression.minus(UIExpression.minus(cExpression, aScaled), bScaled);
|
|
4618
|
+
}
|
|
4619
|
+
}
|
|
4620
|
+
|
|
4352
4621
|
/** Maintains proportional width relationship (A.width * proportion = B.width) */
|
|
4353
4622
|
class UIHorizontalProportionConstraint extends UISingleParameterConstraint {
|
|
4354
4623
|
/**
|
|
@@ -4357,12 +4626,12 @@ class UIHorizontalProportionConstraint extends UISingleParameterConstraint {
|
|
|
4357
4626
|
* @param options Proportion configuration
|
|
4358
4627
|
*/
|
|
4359
4628
|
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
4629
|
if (options.proportion !== undefined) {
|
|
4364
4630
|
assertValidPositiveNumber(options.proportion, "UIHorizontalProportionConstraint.constructor.options.proportion");
|
|
4365
4631
|
}
|
|
4632
|
+
super(assertValidConstraintArguments(_private_a, _private_b, "UIHorizontalProportionConstraint.constructor"), options);
|
|
4633
|
+
this._private_a = _private_a;
|
|
4634
|
+
this._private_b = _private_b;
|
|
4366
4635
|
this._private_proportionInternal = options.proportion ?? 1;
|
|
4367
4636
|
this.constraint = this.solverWrapper.createConstraint(new UIExpression(0), this._private_buildRHS(), this.relation, this.priority, this.isConstraintEnabled());
|
|
4368
4637
|
}
|
|
@@ -4384,7 +4653,7 @@ class UIHorizontalProportionConstraint extends UISingleParameterConstraint {
|
|
|
4384
4653
|
}
|
|
4385
4654
|
}
|
|
4386
4655
|
|
|
4387
|
-
const DEFAULT_ANCHOR$
|
|
4656
|
+
const DEFAULT_ANCHOR$2 = 0.5;
|
|
4388
4657
|
|
|
4389
4658
|
/** Maintains vertical distance between elements with configurable anchors */
|
|
4390
4659
|
class UIVerticalDistanceConstraint extends UISingleParameterConstraint {
|
|
@@ -4394,9 +4663,6 @@ class UIVerticalDistanceConstraint extends UISingleParameterConstraint {
|
|
|
4394
4663
|
* @param options Distance configuration
|
|
4395
4664
|
*/
|
|
4396
4665
|
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
4666
|
if (options.anchorA !== undefined) {
|
|
4401
4667
|
assertValidNumber(options.anchorA, "UIVerticalDistanceConstraint.constructor.options.anchorA");
|
|
4402
4668
|
}
|
|
@@ -4406,8 +4672,11 @@ class UIVerticalDistanceConstraint extends UISingleParameterConstraint {
|
|
|
4406
4672
|
if (options.distance !== undefined) {
|
|
4407
4673
|
assertValidNumber(options.distance, "UIVerticalDistanceConstraint.constructor.options.distance");
|
|
4408
4674
|
}
|
|
4409
|
-
|
|
4410
|
-
this.
|
|
4675
|
+
super(assertValidConstraintArguments(_private_a, _private_b, "UIVerticalDistanceConstraint.constructor"), options);
|
|
4676
|
+
this._private_a = _private_a;
|
|
4677
|
+
this._private_b = _private_b;
|
|
4678
|
+
this._private_anchorAInternal = options.anchorA ?? DEFAULT_ANCHOR$2;
|
|
4679
|
+
this._private_anchorBInternal = options.anchorB ?? DEFAULT_ANCHOR$2;
|
|
4411
4680
|
this._private_distanceInternal = options.distance ?? 0;
|
|
4412
4681
|
this.constraint = this.solverWrapper.createConstraint(this._private_buildLHS(), new UIExpression(this._private_distanceInternal), this.relation, this.priority, this.isConstraintEnabled());
|
|
4413
4682
|
}
|
|
@@ -4479,6 +4748,138 @@ class UIVerticalDistanceConstraint extends UISingleParameterConstraint {
|
|
|
4479
4748
|
}
|
|
4480
4749
|
}
|
|
4481
4750
|
|
|
4751
|
+
const DEFAULT_ANCHOR$1 = 0.5;
|
|
4752
|
+
const DEFAULT_T = 0.5;
|
|
4753
|
+
|
|
4754
|
+
/** Positions element C vertically between A and B based on interpolation factor */
|
|
4755
|
+
class UIVerticalInterpolationConstraint extends UISingleParameterConstraint {
|
|
4756
|
+
/**
|
|
4757
|
+
* @param a First element
|
|
4758
|
+
* @param b Second element
|
|
4759
|
+
* @param c Element to position between A and B
|
|
4760
|
+
* @param options Interpolation configuration
|
|
4761
|
+
*/
|
|
4762
|
+
constructor(_private_a, _private_b, _private_c, options = {}) {
|
|
4763
|
+
if (options.anchorA !== undefined) {
|
|
4764
|
+
assertValidNumber(options.anchorA, "UIVerticalInterpolationConstraint.constructor.options.anchorA");
|
|
4765
|
+
}
|
|
4766
|
+
if (options.anchorB !== undefined) {
|
|
4767
|
+
assertValidNumber(options.anchorB, "UIVerticalInterpolationConstraint.constructor.options.anchorB");
|
|
4768
|
+
}
|
|
4769
|
+
if (options.anchorC !== undefined) {
|
|
4770
|
+
assertValidNumber(options.anchorC, "UIVerticalInterpolationConstraint.constructor.options.anchorC");
|
|
4771
|
+
}
|
|
4772
|
+
if (options.t !== undefined) {
|
|
4773
|
+
assertValidNumber(options.t, "UIVerticalInterpolationConstraint.constructor.options.t");
|
|
4774
|
+
}
|
|
4775
|
+
const anchorA = options.anchorA ?? DEFAULT_ANCHOR$1;
|
|
4776
|
+
const anchorB = options.anchorB ?? DEFAULT_ANCHOR$1;
|
|
4777
|
+
super(assertValidInterpolationConstraintArguments("UIVerticalInterpolationConstraint.constructor", _private_a, _private_b, _private_c, anchorA, anchorB), options);
|
|
4778
|
+
this._private_a = _private_a;
|
|
4779
|
+
this._private_b = _private_b;
|
|
4780
|
+
this._private_c = _private_c;
|
|
4781
|
+
this._private_anchorAInternal = anchorA;
|
|
4782
|
+
this._private_anchorBInternal = anchorA;
|
|
4783
|
+
this._private_anchorCInternal = options.anchorC ?? DEFAULT_ANCHOR$1;
|
|
4784
|
+
this._private_tInternal = options.t ?? DEFAULT_T;
|
|
4785
|
+
this.constraint = this.solverWrapper.createConstraint(this._private_buildLHS(), new UIExpression(0), this.relation, this.priority, this.isConstraintEnabled());
|
|
4786
|
+
}
|
|
4787
|
+
/** Interpolation factor (0 = A position, 1 = B position) */
|
|
4788
|
+
get t() {
|
|
4789
|
+
return this._private_tInternal;
|
|
4790
|
+
}
|
|
4791
|
+
/** Anchor on element A (0 = bottom, 0.5 = center, 1 = top) */
|
|
4792
|
+
get anchorA() {
|
|
4793
|
+
return this._private_anchorAInternal;
|
|
4794
|
+
}
|
|
4795
|
+
/** Anchor on element B (0 = bottom, 0.5 = center, 1 = top) */
|
|
4796
|
+
get anchorB() {
|
|
4797
|
+
return this._private_anchorBInternal;
|
|
4798
|
+
}
|
|
4799
|
+
/** Anchor on element C (0 = bottom, 0.5 = center, 1 = top) */
|
|
4800
|
+
get anchorC() {
|
|
4801
|
+
return this._private_anchorCInternal;
|
|
4802
|
+
}
|
|
4803
|
+
/** Updates interpolation factor */
|
|
4804
|
+
set t(value) {
|
|
4805
|
+
assertValidNumber(value, "UIVerticalInterpolationConstraint.t");
|
|
4806
|
+
if (this._private_tInternal !== value) {
|
|
4807
|
+
this._private_tInternal = value;
|
|
4808
|
+
this.solverWrapper.setConstraintLHS(this.constraint, this._private_buildLHS());
|
|
4809
|
+
}
|
|
4810
|
+
}
|
|
4811
|
+
/** Updates anchor on element A */
|
|
4812
|
+
set anchorA(value) {
|
|
4813
|
+
assertValidNumber(value, "UIVerticalInterpolationConstraint.anchorA");
|
|
4814
|
+
if (this._private_anchorAInternal !== value) {
|
|
4815
|
+
this._private_anchorAInternal = value;
|
|
4816
|
+
this.solverWrapper.setConstraintLHS(this.constraint, this._private_buildLHS());
|
|
4817
|
+
}
|
|
4818
|
+
}
|
|
4819
|
+
/** Updates anchor on element B */
|
|
4820
|
+
set anchorB(value) {
|
|
4821
|
+
assertValidNumber(value, "UIVerticalInterpolationConstraint.anchorB");
|
|
4822
|
+
if (this._private_anchorBInternal !== value) {
|
|
4823
|
+
this._private_anchorBInternal = value;
|
|
4824
|
+
this.solverWrapper.setConstraintLHS(this.constraint, this._private_buildLHS());
|
|
4825
|
+
}
|
|
4826
|
+
}
|
|
4827
|
+
/** Updates anchor on element C */
|
|
4828
|
+
set anchorC(value) {
|
|
4829
|
+
assertValidNumber(value, "UIVerticalInterpolationConstraint.anchorC");
|
|
4830
|
+
if (this._private_anchorCInternal !== value) {
|
|
4831
|
+
this._private_anchorCInternal = value;
|
|
4832
|
+
this.solverWrapper.setConstraintLHS(this.constraint, this._private_buildLHS());
|
|
4833
|
+
}
|
|
4834
|
+
}
|
|
4835
|
+
/** Builds constraint expression: C - A*(1-t) - B*t = 0 */
|
|
4836
|
+
_private_buildLHS() {
|
|
4837
|
+
let aExpression;
|
|
4838
|
+
let bExpression;
|
|
4839
|
+
let cExpression;
|
|
4840
|
+
if (isUIPlaneElement(this._private_a)) {
|
|
4841
|
+
aExpression = new UIExpression(0, [
|
|
4842
|
+
[this._private_a.yVariable, 1],
|
|
4843
|
+
[this._private_a.hVariable, this._private_anchorAInternal],
|
|
4844
|
+
]);
|
|
4845
|
+
}
|
|
4846
|
+
else if (isUIPointElement(this._private_a)) {
|
|
4847
|
+
aExpression = new UIExpression().plus(this._private_a.yVariable, 1);
|
|
4848
|
+
}
|
|
4849
|
+
else {
|
|
4850
|
+
throw new Error("UIVerticalInterpolationConstraint.buildLHS.a: invalid element type");
|
|
4851
|
+
}
|
|
4852
|
+
if (isUIPlaneElement(this._private_b)) {
|
|
4853
|
+
bExpression = new UIExpression(0, [
|
|
4854
|
+
[this._private_b.yVariable, 1],
|
|
4855
|
+
[this._private_b.hVariable, this._private_anchorBInternal],
|
|
4856
|
+
]);
|
|
4857
|
+
}
|
|
4858
|
+
else if (isUIPointElement(this._private_b)) {
|
|
4859
|
+
bExpression = new UIExpression().plus(this._private_b.yVariable, 1);
|
|
4860
|
+
}
|
|
4861
|
+
else {
|
|
4862
|
+
throw new Error("UIVerticalInterpolationConstraint.buildLHS.b: invalid element type");
|
|
4863
|
+
}
|
|
4864
|
+
if (isUIPlaneElement(this._private_c)) {
|
|
4865
|
+
cExpression = new UIExpression(0, [
|
|
4866
|
+
[this._private_c.yVariable, 1],
|
|
4867
|
+
[this._private_c.hVariable, this._private_anchorCInternal],
|
|
4868
|
+
]);
|
|
4869
|
+
}
|
|
4870
|
+
else if (isUIPointElement(this._private_c)) {
|
|
4871
|
+
cExpression = new UIExpression().plus(this._private_c.yVariable, 1);
|
|
4872
|
+
}
|
|
4873
|
+
else {
|
|
4874
|
+
throw new Error("UIVerticalInterpolationConstraint.buildLHS.c: invalid element type");
|
|
4875
|
+
}
|
|
4876
|
+
// C - A*(1-t) - B*t = 0
|
|
4877
|
+
const aScaled = aExpression.clone().multiply(1 - this._private_tInternal);
|
|
4878
|
+
const bScaled = bExpression.clone().multiply(this._private_tInternal);
|
|
4879
|
+
return UIExpression.minus(UIExpression.minus(cExpression, aScaled), bScaled);
|
|
4880
|
+
}
|
|
4881
|
+
}
|
|
4882
|
+
|
|
4482
4883
|
/** Maintains proportional height relationship (A.height * proportion = B.height) */
|
|
4483
4884
|
class UIVerticalProportionConstraint extends UISingleParameterConstraint {
|
|
4484
4885
|
/**
|
|
@@ -4487,12 +4888,12 @@ class UIVerticalProportionConstraint extends UISingleParameterConstraint {
|
|
|
4487
4888
|
* @param options Proportion configuration
|
|
4488
4889
|
*/
|
|
4489
4890
|
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
4891
|
if (options.proportion !== undefined) {
|
|
4494
4892
|
assertValidPositiveNumber(options.proportion, "UIVerticalProportionConstraint.constructor.options.proportion");
|
|
4495
4893
|
}
|
|
4894
|
+
super(assertValidConstraintArguments(_private_a, _private_b, "UIVerticalProportionConstraint.constructor"), options);
|
|
4895
|
+
this._private_a = _private_a;
|
|
4896
|
+
this._private_b = _private_b;
|
|
4496
4897
|
this._private_proportionInternal = options.proportion ?? 1;
|
|
4497
4898
|
this.constraint = this.solverWrapper.createConstraint(new UIExpression(0), this._private_buildRHS(), this.relation, this.priority, this.isConstraintEnabled());
|
|
4498
4899
|
}
|
|
@@ -4521,11 +4922,11 @@ class UIWidthConstraint extends UISingleParameterConstraint {
|
|
|
4521
4922
|
* @param options Width configuration. Defaults to element's current width.
|
|
4522
4923
|
*/
|
|
4523
4924
|
constructor(_private_element, options = {}) {
|
|
4524
|
-
super(_private_element.layer, options);
|
|
4525
|
-
this._private_element = _private_element;
|
|
4526
4925
|
if (options.width !== undefined) {
|
|
4527
4926
|
assertValidPositiveNumber(options.width, "UIWidthConstraint.constructor.options.width");
|
|
4528
4927
|
}
|
|
4928
|
+
super(_private_element.layer, options);
|
|
4929
|
+
this._private_element = _private_element;
|
|
4529
4930
|
this._private_widthInternal = options.width ?? _private_element.width;
|
|
4530
4931
|
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
4932
|
}
|
|
@@ -4543,6 +4944,26 @@ class UIWidthConstraint extends UISingleParameterConstraint {
|
|
|
4543
4944
|
}
|
|
4544
4945
|
}
|
|
4545
4946
|
|
|
4947
|
+
/**
|
|
4948
|
+
* Normalizes UIType2D input to object form.
|
|
4949
|
+
* @param value Object, tuple, or single value
|
|
4950
|
+
* @returns Normalized object with h and v properties
|
|
4951
|
+
*/
|
|
4952
|
+
function normalizeUIType2D(value) {
|
|
4953
|
+
if (value === undefined) {
|
|
4954
|
+
return {};
|
|
4955
|
+
}
|
|
4956
|
+
if (Array.isArray(value)) {
|
|
4957
|
+
return { h: value[0], v: value[1] };
|
|
4958
|
+
}
|
|
4959
|
+
if (typeof value === "object" &&
|
|
4960
|
+
value !== null &&
|
|
4961
|
+
("h" in value || "v" in value)) {
|
|
4962
|
+
return value;
|
|
4963
|
+
}
|
|
4964
|
+
return { h: value, v: value };
|
|
4965
|
+
}
|
|
4966
|
+
|
|
4546
4967
|
/** Builder for paired horizontal and vertical constraints */
|
|
4547
4968
|
class UIConstraint2DBuilder {
|
|
4548
4969
|
/**
|
|
@@ -4552,18 +4973,22 @@ class UIConstraint2DBuilder {
|
|
|
4552
4973
|
* @returns Width and height constraints
|
|
4553
4974
|
*/
|
|
4554
4975
|
static size(element, options = {}) {
|
|
4976
|
+
const size = normalizeUIType2D(options.size);
|
|
4977
|
+
const priority = normalizeUIType2D(options.priority);
|
|
4978
|
+
const relation = normalizeUIType2D(options.relation);
|
|
4979
|
+
const orientation = normalizeUIType2D(options.orientation);
|
|
4555
4980
|
return {
|
|
4556
4981
|
h: new UIWidthConstraint(element, {
|
|
4557
|
-
width:
|
|
4558
|
-
priority:
|
|
4559
|
-
relation:
|
|
4560
|
-
orientation:
|
|
4982
|
+
width: size.h,
|
|
4983
|
+
priority: priority.h,
|
|
4984
|
+
relation: relation.h,
|
|
4985
|
+
orientation: orientation.h,
|
|
4561
4986
|
}),
|
|
4562
4987
|
v: new UIHeightConstraint(element, {
|
|
4563
|
-
height:
|
|
4564
|
-
priority:
|
|
4565
|
-
relation:
|
|
4566
|
-
orientation:
|
|
4988
|
+
height: size.v,
|
|
4989
|
+
priority: priority.v,
|
|
4990
|
+
relation: relation.v,
|
|
4991
|
+
orientation: orientation.v,
|
|
4567
4992
|
}),
|
|
4568
4993
|
};
|
|
4569
4994
|
}
|
|
@@ -4575,22 +5000,28 @@ class UIConstraint2DBuilder {
|
|
|
4575
5000
|
* @returns Horizontal and vertical distance constraints
|
|
4576
5001
|
*/
|
|
4577
5002
|
static distance(a, b, options = {}) {
|
|
5003
|
+
const anchorA = normalizeUIType2D(options.anchorA);
|
|
5004
|
+
const anchorB = normalizeUIType2D(options.anchorB);
|
|
5005
|
+
const distance = normalizeUIType2D(options.distance);
|
|
5006
|
+
const priority = normalizeUIType2D(options.priority);
|
|
5007
|
+
const relation = normalizeUIType2D(options.relation);
|
|
5008
|
+
const orientation = normalizeUIType2D(options.orientation);
|
|
4578
5009
|
return {
|
|
4579
5010
|
h: new UIHorizontalDistanceConstraint(a, b, {
|
|
4580
|
-
anchorA:
|
|
4581
|
-
anchorB:
|
|
4582
|
-
distance:
|
|
4583
|
-
priority:
|
|
4584
|
-
relation:
|
|
4585
|
-
orientation:
|
|
5011
|
+
anchorA: anchorA.h,
|
|
5012
|
+
anchorB: anchorB.h,
|
|
5013
|
+
distance: distance.h,
|
|
5014
|
+
priority: priority.h,
|
|
5015
|
+
relation: relation.h,
|
|
5016
|
+
orientation: orientation.h,
|
|
4586
5017
|
}),
|
|
4587
5018
|
v: new UIVerticalDistanceConstraint(a, b, {
|
|
4588
|
-
anchorA:
|
|
4589
|
-
anchorB:
|
|
4590
|
-
distance:
|
|
4591
|
-
priority:
|
|
4592
|
-
relation:
|
|
4593
|
-
orientation:
|
|
5019
|
+
anchorA: anchorA.v,
|
|
5020
|
+
anchorB: anchorB.v,
|
|
5021
|
+
distance: distance.v,
|
|
5022
|
+
priority: priority.v,
|
|
5023
|
+
relation: relation.v,
|
|
5024
|
+
orientation: orientation.v,
|
|
4594
5025
|
}),
|
|
4595
5026
|
};
|
|
4596
5027
|
}
|
|
@@ -4602,18 +5033,59 @@ class UIConstraint2DBuilder {
|
|
|
4602
5033
|
* @returns Horizontal and vertical proportion constraints
|
|
4603
5034
|
*/
|
|
4604
5035
|
static proportion(a, b, options = {}) {
|
|
5036
|
+
const proportion = normalizeUIType2D(options.proportion);
|
|
5037
|
+
const priority = normalizeUIType2D(options.priority);
|
|
5038
|
+
const relation = normalizeUIType2D(options.relation);
|
|
5039
|
+
const orientation = normalizeUIType2D(options.orientation);
|
|
4605
5040
|
return {
|
|
4606
5041
|
h: new UIHorizontalProportionConstraint(a, b, {
|
|
4607
|
-
proportion:
|
|
4608
|
-
priority:
|
|
4609
|
-
relation:
|
|
4610
|
-
orientation:
|
|
5042
|
+
proportion: proportion.h,
|
|
5043
|
+
priority: priority.h,
|
|
5044
|
+
relation: relation.h,
|
|
5045
|
+
orientation: orientation.h,
|
|
4611
5046
|
}),
|
|
4612
5047
|
v: new UIVerticalProportionConstraint(a, b, {
|
|
4613
|
-
proportion:
|
|
4614
|
-
priority:
|
|
4615
|
-
relation:
|
|
4616
|
-
orientation:
|
|
5048
|
+
proportion: proportion.v,
|
|
5049
|
+
priority: priority.v,
|
|
5050
|
+
relation: relation.v,
|
|
5051
|
+
orientation: orientation.v,
|
|
5052
|
+
}),
|
|
5053
|
+
};
|
|
5054
|
+
}
|
|
5055
|
+
/**
|
|
5056
|
+
* Creates horizontal and vertical interpolation constraints.
|
|
5057
|
+
* @param a First element
|
|
5058
|
+
* @param b Second element
|
|
5059
|
+
* @param c Element to position between A and B
|
|
5060
|
+
* @param options Interpolation configuration for both axes
|
|
5061
|
+
* @returns Horizontal and vertical interpolation constraints
|
|
5062
|
+
*/
|
|
5063
|
+
static interpolation(a, b, c, options = {}) {
|
|
5064
|
+
const anchorA = normalizeUIType2D(options.anchorA);
|
|
5065
|
+
const anchorB = normalizeUIType2D(options.anchorB);
|
|
5066
|
+
const anchorC = normalizeUIType2D(options.anchorC);
|
|
5067
|
+
const t = normalizeUIType2D(options.t);
|
|
5068
|
+
const priority = normalizeUIType2D(options.priority);
|
|
5069
|
+
const relation = normalizeUIType2D(options.relation);
|
|
5070
|
+
const orientation = normalizeUIType2D(options.orientation);
|
|
5071
|
+
return {
|
|
5072
|
+
h: new UIHorizontalInterpolationConstraint(a, b, c, {
|
|
5073
|
+
anchorA: anchorA.h,
|
|
5074
|
+
anchorB: anchorB.h,
|
|
5075
|
+
anchorC: anchorC.h,
|
|
5076
|
+
t: t.h,
|
|
5077
|
+
priority: priority.h,
|
|
5078
|
+
relation: relation.h,
|
|
5079
|
+
orientation: orientation.h,
|
|
5080
|
+
}),
|
|
5081
|
+
v: new UIVerticalInterpolationConstraint(a, b, c, {
|
|
5082
|
+
anchorA: anchorA.v,
|
|
5083
|
+
anchorB: anchorB.v,
|
|
5084
|
+
anchorC: anchorC.v,
|
|
5085
|
+
t: t.v,
|
|
5086
|
+
priority: priority.v,
|
|
5087
|
+
relation: relation.v,
|
|
5088
|
+
orientation: orientation.v,
|
|
4617
5089
|
}),
|
|
4618
5090
|
};
|
|
4619
5091
|
}
|
|
@@ -4626,11 +5098,11 @@ class UIAspectConstraint extends UISingleParameterConstraint {
|
|
|
4626
5098
|
* @param options Aspect configuration. Defaults to element's current ratio.
|
|
4627
5099
|
*/
|
|
4628
5100
|
constructor(_private_element, options = {}) {
|
|
4629
|
-
super(_private_element.layer, options);
|
|
4630
|
-
this._private_element = _private_element;
|
|
4631
5101
|
if (options.aspect !== undefined) {
|
|
4632
5102
|
assertValidPositiveNumber(options.aspect, "UIAspectConstraint.constructor.options.aspect");
|
|
4633
5103
|
}
|
|
5104
|
+
super(_private_element.layer, options);
|
|
5105
|
+
this._private_element = _private_element;
|
|
4634
5106
|
this._private_aspectInternal = options.aspect ?? _private_element.width / _private_element.height;
|
|
4635
5107
|
this.constraint = this.solverWrapper.createConstraint(this._private_buildLHS(), new UIExpression(0), this.relation, this.priority, this.isConstraintEnabled());
|
|
4636
5108
|
}
|
|
@@ -4955,19 +5427,21 @@ class UITextureView extends i {
|
|
|
4955
5427
|
constructor(config) {
|
|
4956
5428
|
super();
|
|
4957
5429
|
this._private_textureInternal = TEXTURE_DEFAULT_TEXTURE;
|
|
4958
|
-
this.
|
|
5430
|
+
this._private_sourceWidth = TEXTURE_DEFAULT_SIZE;
|
|
5431
|
+
this._private_sourceHeight = TEXTURE_DEFAULT_SIZE;
|
|
4959
5432
|
this._private_frameX = 0;
|
|
4960
5433
|
this._private_frameY = 0;
|
|
4961
5434
|
this._private_frameWidth = TEXTURE_DEFAULT_SIZE;
|
|
4962
5435
|
this._private_frameHeight = TEXTURE_DEFAULT_SIZE;
|
|
4963
|
-
this.
|
|
4964
|
-
this.
|
|
5436
|
+
this._private_rotatedInternal = false;
|
|
5437
|
+
this._private_scaleInternal = 1;
|
|
4965
5438
|
this._private_trimLeft = 0;
|
|
4966
5439
|
this._private_trimRight = 0;
|
|
4967
5440
|
this._private_trimTop = 0;
|
|
4968
5441
|
this._private_trimBottom = 0;
|
|
4969
|
-
this.
|
|
4970
|
-
this.
|
|
5442
|
+
this._private_textureDirtyInternal = false;
|
|
5443
|
+
this._private_uvTransformDirtyInternal = false;
|
|
5444
|
+
this._private_trimDirtyInternal = false;
|
|
4971
5445
|
if (config !== undefined) {
|
|
4972
5446
|
this.set(config);
|
|
4973
5447
|
}
|
|
@@ -5004,21 +5478,35 @@ class UITextureView extends i {
|
|
|
5004
5478
|
}
|
|
5005
5479
|
/** Transparent padding around visible content */
|
|
5006
5480
|
get trim() {
|
|
5007
|
-
const
|
|
5481
|
+
const scale = this._private_scaleInternal;
|
|
5008
5482
|
return {
|
|
5009
|
-
left: this._private_trimLeft /
|
|
5010
|
-
right: this._private_trimRight /
|
|
5011
|
-
top: this._private_trimTop /
|
|
5012
|
-
bottom: this._private_trimBottom /
|
|
5483
|
+
left: this._private_trimLeft / scale,
|
|
5484
|
+
right: this._private_trimRight / scale,
|
|
5485
|
+
top: this._private_trimTop / scale,
|
|
5486
|
+
bottom: this._private_trimBottom / scale,
|
|
5013
5487
|
};
|
|
5014
5488
|
}
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
return this._private_dirtyInternal;
|
|
5489
|
+
get textureDirty() {
|
|
5490
|
+
return this._private_textureDirtyInternal;
|
|
5018
5491
|
}
|
|
5019
|
-
/**
|
|
5020
|
-
|
|
5021
|
-
this.
|
|
5492
|
+
/** Whether UV transform inputs changed since last check */
|
|
5493
|
+
get uvTransformDirty() {
|
|
5494
|
+
return this._private_uvTransformDirtyInternal;
|
|
5495
|
+
}
|
|
5496
|
+
/** Whether trim values changed since last check */
|
|
5497
|
+
get trimDirty() {
|
|
5498
|
+
return this._private_trimDirtyInternal;
|
|
5499
|
+
}
|
|
5500
|
+
setTextureDirtyFalse() {
|
|
5501
|
+
this._private_textureDirtyInternal = false;
|
|
5502
|
+
}
|
|
5503
|
+
/** Marks UV transform as clean. @internal */
|
|
5504
|
+
setUVTransformDirtyFalse() {
|
|
5505
|
+
this._private_uvTransformDirtyInternal = false;
|
|
5506
|
+
}
|
|
5507
|
+
/** Marks trim as clean. @internal */
|
|
5508
|
+
setTrimDirtyFalse() {
|
|
5509
|
+
this._private_trimDirtyInternal = false;
|
|
5022
5510
|
}
|
|
5023
5511
|
/**
|
|
5024
5512
|
* Calculates UV transform matrix for shader sampling.
|
|
@@ -5059,91 +5547,107 @@ class UITextureView extends i {
|
|
|
5059
5547
|
* @param config Texture or atlas configuration
|
|
5060
5548
|
*/
|
|
5061
5549
|
set(config) {
|
|
5062
|
-
const
|
|
5063
|
-
const
|
|
5550
|
+
const lastWidth = this.width;
|
|
5551
|
+
const lastHeight = this.height;
|
|
5064
5552
|
if (config instanceof Texture) {
|
|
5065
5553
|
this._private_setFromTexture(config);
|
|
5066
5554
|
}
|
|
5067
5555
|
else {
|
|
5068
5556
|
this._private_setFromAtlasConfig(config);
|
|
5069
5557
|
}
|
|
5070
|
-
this.
|
|
5071
|
-
if (this.width !== previousWidth || this.height !== previousHeight) {
|
|
5558
|
+
if (this.width !== lastWidth || this.height !== lastHeight) {
|
|
5072
5559
|
this.emit(UITextureViewEvent.DIMENSIONS_CHANGED, this.width, this.height, this);
|
|
5073
5560
|
}
|
|
5074
5561
|
}
|
|
5075
|
-
/** Resets to default empty texture */
|
|
5076
|
-
reset() {
|
|
5077
|
-
const previousWidth = this.width;
|
|
5078
|
-
const previousHeight = this.height;
|
|
5079
|
-
this._private_textureInternal = new Texture();
|
|
5080
|
-
this._private_frameX = 0;
|
|
5081
|
-
this._private_frameY = 0;
|
|
5082
|
-
this._private_frameWidth = TEXTURE_DEFAULT_SIZE;
|
|
5083
|
-
this._private_frameHeight = TEXTURE_DEFAULT_SIZE;
|
|
5084
|
-
this._private_rotatedInternal = false;
|
|
5085
|
-
this._private_sourceWidth = TEXTURE_DEFAULT_SIZE;
|
|
5086
|
-
this._private_sourceHeight = TEXTURE_DEFAULT_SIZE;
|
|
5087
|
-
this._private_trimLeft = 0;
|
|
5088
|
-
this._private_trimRight = 0;
|
|
5089
|
-
this._private_trimTop = 0;
|
|
5090
|
-
this._private_trimBottom = 0;
|
|
5091
|
-
this._private_scaleInternal = 1;
|
|
5092
|
-
this._private_dirtyInternal = true;
|
|
5093
|
-
if (this.width !== previousWidth || this.height !== previousHeight) {
|
|
5094
|
-
this.emit(UITextureViewEvent.DIMENSIONS_CHANGED, this.width, this.height);
|
|
5095
|
-
}
|
|
5096
|
-
}
|
|
5097
5562
|
_private_setFromTexture(texture) {
|
|
5098
5563
|
const width = texture.image?.naturalWidth ?? TEXTURE_DEFAULT_SIZE;
|
|
5099
5564
|
const height = texture.image?.naturalHeight ?? TEXTURE_DEFAULT_SIZE;
|
|
5100
|
-
this._private_textureInternal = texture;
|
|
5101
|
-
this._private_frameX = 0;
|
|
5102
|
-
this._private_frameY = 0;
|
|
5103
|
-
this._private_frameWidth = width;
|
|
5104
|
-
this._private_frameHeight = height;
|
|
5105
|
-
this._private_rotatedInternal = false;
|
|
5106
5565
|
this._private_sourceWidth = width;
|
|
5107
5566
|
this._private_sourceHeight = height;
|
|
5108
|
-
this.
|
|
5109
|
-
|
|
5110
|
-
|
|
5111
|
-
|
|
5112
|
-
this.
|
|
5567
|
+
if (this.texture !== texture) {
|
|
5568
|
+
this._private_textureInternal = texture;
|
|
5569
|
+
this._private_textureDirtyInternal = true;
|
|
5570
|
+
}
|
|
5571
|
+
if (this._private_frameX !== 0 ||
|
|
5572
|
+
this._private_frameY !== 0 ||
|
|
5573
|
+
this._private_frameWidth !== width ||
|
|
5574
|
+
this._private_frameHeight !== height ||
|
|
5575
|
+
this._private_scaleInternal !== 1 || this._private_rotatedInternal) {
|
|
5576
|
+
this._private_frameX = 0;
|
|
5577
|
+
this._private_frameY = 0;
|
|
5578
|
+
this._private_frameWidth = width;
|
|
5579
|
+
this._private_frameHeight = height;
|
|
5580
|
+
this._private_rotatedInternal = false;
|
|
5581
|
+
this._private_scaleInternal = 1;
|
|
5582
|
+
this._private_uvTransformDirtyInternal = true;
|
|
5583
|
+
}
|
|
5584
|
+
if (this._private_trimLeft !== 0 ||
|
|
5585
|
+
this._private_trimRight !== 0 ||
|
|
5586
|
+
this._private_trimTop !== 0 ||
|
|
5587
|
+
this._private_trimBottom !== 0) {
|
|
5588
|
+
this._private_trimLeft = 0;
|
|
5589
|
+
this._private_trimRight = 0;
|
|
5590
|
+
this._private_trimTop = 0;
|
|
5591
|
+
this._private_trimBottom = 0;
|
|
5592
|
+
this._private_trimDirtyInternal = true;
|
|
5593
|
+
}
|
|
5113
5594
|
}
|
|
5114
5595
|
_private_setFromAtlasConfig(config) {
|
|
5115
|
-
|
|
5116
|
-
|
|
5117
|
-
|
|
5118
|
-
|
|
5119
|
-
|
|
5120
|
-
|
|
5596
|
+
assertValidPositiveNumber(config.sourceSize.w, "UITextureView.setFromAtlasConfig.config.sourceSize.w");
|
|
5597
|
+
assertValidPositiveNumber(config.sourceSize.h, "UITextureView.setFromAtlasConfig.config.sourceSize.h");
|
|
5598
|
+
assertValidNonNegativeNumber(config.frame.x, "UITextureView.setFromAtlasConfig.config.frame.x");
|
|
5599
|
+
assertValidNonNegativeNumber(config.frame.y, "UITextureView.setFromAtlasConfig.config.frame.y");
|
|
5600
|
+
assertValidPositiveNumber(config.frame.w, "UITextureView.setFromAtlasConfig.config.frame.w");
|
|
5601
|
+
assertValidPositiveNumber(config.frame.h, "UITextureView.setFromAtlasConfig.config.frame.h");
|
|
5602
|
+
assertValidNonNegativeNumber(config.spriteSourceSize.x, "UITextureView.setFromAtlasConfig.config.spriteSourceSize.x");
|
|
5603
|
+
assertValidNonNegativeNumber(config.spriteSourceSize.y, "UITextureView.setFromAtlasConfig.config.spriteSourceSize.y");
|
|
5604
|
+
assertValidPositiveNumber(config.spriteSourceSize.w, "UITextureView.setFromAtlasConfig.config.spriteSourceSize.w");
|
|
5605
|
+
assertValidPositiveNumber(config.spriteSourceSize.h, "UITextureView.setFromAtlasConfig.config.spriteSourceSize.h");
|
|
5606
|
+
if (config.scale !== undefined) {
|
|
5607
|
+
assertValidPositiveNumber(config.scale, "UITextureView.setFromAtlasConfig.config.scale");
|
|
5608
|
+
}
|
|
5121
5609
|
this._private_sourceWidth = config.sourceSize.w;
|
|
5122
5610
|
this._private_sourceHeight = config.sourceSize.h;
|
|
5123
|
-
this.
|
|
5611
|
+
if (this.texture !== config.texture) {
|
|
5612
|
+
this._private_textureInternal = config.texture;
|
|
5613
|
+
this._private_textureDirtyInternal = true;
|
|
5614
|
+
}
|
|
5615
|
+
const scale = config.scale ?? 1;
|
|
5616
|
+
const rotated = config.rotated ?? false;
|
|
5617
|
+
if (this._private_frameX !== 0 ||
|
|
5618
|
+
this._private_frameY !== 0 ||
|
|
5619
|
+
this._private_frameWidth !== config.frame.w ||
|
|
5620
|
+
this._private_frameHeight !== config.frame.h ||
|
|
5621
|
+
this._private_scaleInternal !== scale ||
|
|
5622
|
+
this._private_rotatedInternal !== rotated) {
|
|
5623
|
+
this._private_frameX = config.frame.x;
|
|
5624
|
+
this._private_frameY = config.frame.y;
|
|
5625
|
+
this._private_frameWidth = config.frame.w;
|
|
5626
|
+
this._private_frameHeight = config.frame.h;
|
|
5627
|
+
this._private_scaleInternal = scale;
|
|
5628
|
+
this._private_rotatedInternal = rotated;
|
|
5629
|
+
this._private_uvTransformDirtyInternal = true;
|
|
5630
|
+
}
|
|
5124
5631
|
const spriteSource = config.spriteSourceSize;
|
|
5125
|
-
|
|
5126
|
-
|
|
5127
|
-
|
|
5128
|
-
|
|
5632
|
+
const trimLeft = spriteSource.x;
|
|
5633
|
+
const trimTop = spriteSource.y;
|
|
5634
|
+
const trimRight = this._private_sourceWidth - spriteSource.x - spriteSource.w;
|
|
5635
|
+
const trimBottom = this._private_sourceHeight - spriteSource.y - spriteSource.h;
|
|
5636
|
+
if (this._private_trimLeft !== trimLeft ||
|
|
5637
|
+
this._private_trimRight !== trimRight ||
|
|
5638
|
+
this._private_trimTop !== trimTop ||
|
|
5639
|
+
this._private_trimBottom !== trimBottom) {
|
|
5640
|
+
this._private_trimLeft = trimLeft;
|
|
5641
|
+
this._private_trimRight = trimRight;
|
|
5642
|
+
this._private_trimTop = trimTop;
|
|
5643
|
+
this._private_trimBottom = trimBottom;
|
|
5644
|
+
this._private_trimDirtyInternal = true;
|
|
5645
|
+
}
|
|
5129
5646
|
}
|
|
5130
5647
|
}
|
|
5131
5648
|
|
|
5132
5649
|
var source$4 = "vec4 draw(){vec2 transformedUV=(p_textureTransform*vec3(p_uv,1.0)).xy;return texture2D(p_texture,transformedUV)*p_color;}";
|
|
5133
5650
|
|
|
5134
|
-
/** Animation playback events */
|
|
5135
|
-
var UIAnimatedImageEvent;
|
|
5136
|
-
(function (UIAnimatedImageEvent) {
|
|
5137
|
-
/** Animation started or resumed */
|
|
5138
|
-
UIAnimatedImageEvent[UIAnimatedImageEvent["PLAYED"] = 0] = "PLAYED";
|
|
5139
|
-
/** Animation paused */
|
|
5140
|
-
UIAnimatedImageEvent[UIAnimatedImageEvent["PAUSED"] = 1] = "PAUSED";
|
|
5141
|
-
/** Animation stopped and reset */
|
|
5142
|
-
UIAnimatedImageEvent[UIAnimatedImageEvent["STOPPED"] = 2] = "STOPPED";
|
|
5143
|
-
})(UIAnimatedImageEvent || (UIAnimatedImageEvent = {}));
|
|
5144
|
-
const ANIMATED_IMAGE_DEFAULT_FRAME_RATE = 24;
|
|
5145
|
-
const ANIMATED_IMAGE_DEFAULT_LOOP = true;
|
|
5146
|
-
|
|
5147
5651
|
/** Transforms that don't affect constraints */
|
|
5148
5652
|
class UIMicro {
|
|
5149
5653
|
/**
|
|
@@ -5340,9 +5844,15 @@ class UIAreaRectangle extends UIArea {
|
|
|
5340
5844
|
this.y = y;
|
|
5341
5845
|
this.width = width;
|
|
5342
5846
|
this.height = height;
|
|
5847
|
+
assertValidNonNegativeNumber(x, "UIAreaRectangle.constructor.x");
|
|
5848
|
+
assertValidNonNegativeNumber(y, "UIAreaRectangle.constructor.y");
|
|
5849
|
+
assertValidNonNegativeNumber(width, "UIAreaRectangle.constructor.width");
|
|
5850
|
+
assertValidNonNegativeNumber(height, "UIAreaRectangle.constructor.height");
|
|
5343
5851
|
}
|
|
5344
5852
|
/** @internal */
|
|
5345
5853
|
contains(pointX, pointY) {
|
|
5854
|
+
assertValidNumber(pointX, "UIAreaRectangle.contains.pointX");
|
|
5855
|
+
assertValidNumber(pointY, "UIAreaRectangle.contains.pointY");
|
|
5346
5856
|
return (pointX >= this.x &&
|
|
5347
5857
|
pointX <= this.x + this.width &&
|
|
5348
5858
|
pointY >= this.y &&
|
|
@@ -5371,9 +5881,9 @@ const DUMMY_DEFAULT_MODE = UIMode.VISIBLE;
|
|
|
5371
5881
|
const DUMMY_DEFAULT_Z_INDEX = 0;
|
|
5372
5882
|
|
|
5373
5883
|
/** Rectangular area with dimensions but no rendering */
|
|
5374
|
-
class
|
|
5884
|
+
class UIInputDummy extends UIAnchor {
|
|
5375
5885
|
/**
|
|
5376
|
-
* Creates a new
|
|
5886
|
+
* Creates a new UIInputDummy instance.
|
|
5377
5887
|
*
|
|
5378
5888
|
* @param layer - Layer containing this element
|
|
5379
5889
|
* @param options - Configuration options
|
|
@@ -5381,8 +5891,8 @@ class UIDummy extends UIAnchor {
|
|
|
5381
5891
|
constructor(layer, options) {
|
|
5382
5892
|
const w = options?.width ?? DUMMY_DEFAULT_WIDTH;
|
|
5383
5893
|
const h = options?.height ?? DUMMY_DEFAULT_HEIGHT;
|
|
5384
|
-
assertValidPositiveNumber(w, "
|
|
5385
|
-
assertValidPositiveNumber(h, "
|
|
5894
|
+
assertValidPositiveNumber(w, "UIInputDummy.constructor.width");
|
|
5895
|
+
assertValidPositiveNumber(h, "UIInputDummy.constructor.height");
|
|
5386
5896
|
super(layer, options);
|
|
5387
5897
|
this._private_lastPointerInside = false;
|
|
5388
5898
|
this.catchPointerDown = (x, y, identifier) => {
|
|
@@ -5437,32 +5947,32 @@ class UIDummy extends UIAnchor {
|
|
|
5437
5947
|
}
|
|
5438
5948
|
/** Width in world units */
|
|
5439
5949
|
set width(value) {
|
|
5440
|
-
assertValidPositiveNumber(value, "
|
|
5950
|
+
assertValidPositiveNumber(value, "UIInputDummy.width");
|
|
5441
5951
|
this.solverWrapper.suggestVariableValue(this.wVariable, value);
|
|
5442
5952
|
}
|
|
5443
5953
|
/** Height in world units */
|
|
5444
5954
|
set height(value) {
|
|
5445
|
-
assertValidPositiveNumber(value, "
|
|
5955
|
+
assertValidPositiveNumber(value, "UIInputDummy.height");
|
|
5446
5956
|
this.solverWrapper.suggestVariableValue(this.hVariable, value);
|
|
5447
5957
|
}
|
|
5448
5958
|
/** X coordinate of right edge */
|
|
5449
5959
|
set oppositeX(value) {
|
|
5450
|
-
assertValidNumber(value, "
|
|
5960
|
+
assertValidNumber(value, "UIInputDummy.oppositeX");
|
|
5451
5961
|
this.x = value - this.width;
|
|
5452
5962
|
}
|
|
5453
5963
|
/** Y coordinate of top edge */
|
|
5454
5964
|
set oppositeY(value) {
|
|
5455
|
-
assertValidNumber(value, "
|
|
5965
|
+
assertValidNumber(value, "UIInputDummy.oppositeY");
|
|
5456
5966
|
this.y = value - this.height;
|
|
5457
5967
|
}
|
|
5458
5968
|
/** X coordinate of horizontal center */
|
|
5459
5969
|
set centerX(value) {
|
|
5460
|
-
assertValidNumber(value, "
|
|
5970
|
+
assertValidNumber(value, "UIInputDummy.centerX");
|
|
5461
5971
|
this.x = value - this.width / 2;
|
|
5462
5972
|
}
|
|
5463
5973
|
/** Y coordinate of vertical center */
|
|
5464
5974
|
set centerY(value) {
|
|
5465
|
-
assertValidNumber(value, "
|
|
5975
|
+
assertValidNumber(value, "UIInputDummy.centerY");
|
|
5466
5976
|
this.y = value - this.height / 2;
|
|
5467
5977
|
}
|
|
5468
5978
|
/** Controls visibility and interactivity */
|
|
@@ -5475,7 +5985,7 @@ class UIDummy extends UIAnchor {
|
|
|
5475
5985
|
}
|
|
5476
5986
|
/** Rendering and input priority. Higher values on top. */
|
|
5477
5987
|
set zIndex(value) {
|
|
5478
|
-
assertValidNumber(value, "
|
|
5988
|
+
assertValidNumber(value, "UIInputDummy.zIndex");
|
|
5479
5989
|
this.inputWrapper.setZIndex(this._private_catcherHandler, value);
|
|
5480
5990
|
}
|
|
5481
5991
|
/** Removes element and frees resources */
|
|
@@ -5486,9 +5996,9 @@ class UIDummy extends UIAnchor {
|
|
|
5486
5996
|
super.destroy();
|
|
5487
5997
|
}
|
|
5488
5998
|
handleInputEvent(x, y, identifier, inputEvent) {
|
|
5489
|
-
assertValidNumber(x, "
|
|
5490
|
-
assertValidNumber(y, "
|
|
5491
|
-
assertValidNumber(identifier, "
|
|
5999
|
+
assertValidNumber(x, "UIInputDummy.handleInputEvent.x");
|
|
6000
|
+
assertValidNumber(y, "UIInputDummy.handleInputEvent.y");
|
|
6001
|
+
assertValidNumber(identifier, "UIInputDummy.handleInputEvent.identifier");
|
|
5492
6002
|
const isPointerInside = this.interactionArea.contains(MathUtils.mapLinear(x, this.x, this.oppositeX, 0, 1), MathUtils.mapLinear(y, this.y, this.oppositeY, 0, 1));
|
|
5493
6003
|
if (isPointerInside) {
|
|
5494
6004
|
this.emit(inputEvent, x, y, identifier, this);
|
|
@@ -5509,7 +6019,7 @@ class UIDummy extends UIAnchor {
|
|
|
5509
6019
|
const ELEMENT_DEFAULT_TRANSPARENCY_MODE = UITransparencyMode.BLEND;
|
|
5510
6020
|
|
|
5511
6021
|
/** Base class for renderable UI elements */
|
|
5512
|
-
class UIElement extends
|
|
6022
|
+
class UIElement extends UIInputDummy {
|
|
5513
6023
|
/**
|
|
5514
6024
|
* Creates a new UIElement instance.
|
|
5515
6025
|
*
|
|
@@ -5556,7 +6066,7 @@ class UIElement extends UIDummy {
|
|
|
5556
6066
|
this.sceneWrapper.destroyPlane(this.planeHandler);
|
|
5557
6067
|
super.destroy();
|
|
5558
6068
|
}
|
|
5559
|
-
|
|
6069
|
+
setPlaneTransform() {
|
|
5560
6070
|
if (this.micro.dirty ||
|
|
5561
6071
|
this.inputWrapper.dirty ||
|
|
5562
6072
|
this.solverWrapper.dirty) {
|
|
@@ -5564,11 +6074,8 @@ class UIElement extends UIDummy {
|
|
|
5564
6074
|
this.micro.setDirtyFalse();
|
|
5565
6075
|
}
|
|
5566
6076
|
}
|
|
5567
|
-
onWillRender(
|
|
5568
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- Required by UILayer event interface but not used in base implementation
|
|
5569
|
-
renderer,
|
|
5570
6077
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- Required by UILayer event interface but not used in base implementation
|
|
5571
|
-
deltaTime) {
|
|
6078
|
+
onWillRender(renderer, deltaTime) {
|
|
5572
6079
|
if (this._private_transparencyModeDirty) {
|
|
5573
6080
|
this.sceneWrapper.setTransparency(this.planeHandler, this._private_transparencyModeInternal);
|
|
5574
6081
|
this._private_transparencyModeDirty = false;
|
|
@@ -5577,10 +6084,23 @@ class UIElement extends UIDummy {
|
|
|
5577
6084
|
this.sceneWrapper.setVisibility(this.planeHandler, isUIModeVisible(this.modeInternal));
|
|
5578
6085
|
this._private_visibilityDirty = false;
|
|
5579
6086
|
}
|
|
5580
|
-
this.
|
|
6087
|
+
this.setPlaneTransform();
|
|
5581
6088
|
}
|
|
5582
6089
|
}
|
|
5583
6090
|
|
|
6091
|
+
/** Animation playback events */
|
|
6092
|
+
var UIAnimatedImageEvent;
|
|
6093
|
+
(function (UIAnimatedImageEvent) {
|
|
6094
|
+
/** Animation started or resumed */
|
|
6095
|
+
UIAnimatedImageEvent[UIAnimatedImageEvent["PLAYED"] = 0] = "PLAYED";
|
|
6096
|
+
/** Animation paused */
|
|
6097
|
+
UIAnimatedImageEvent[UIAnimatedImageEvent["PAUSED"] = 1] = "PAUSED";
|
|
6098
|
+
/** Animation stopped and reset */
|
|
6099
|
+
UIAnimatedImageEvent[UIAnimatedImageEvent["STOPPED"] = 2] = "STOPPED";
|
|
6100
|
+
})(UIAnimatedImageEvent || (UIAnimatedImageEvent = {}));
|
|
6101
|
+
const ANIMATED_IMAGE_DEFAULT_FRAME_RATE = 24;
|
|
6102
|
+
const ANIMATED_IMAGE_DEFAULT_LOOP = true;
|
|
6103
|
+
|
|
5584
6104
|
/** Frame-based texture animation element */
|
|
5585
6105
|
class UIAnimatedImage extends UIElement {
|
|
5586
6106
|
/**
|
|
@@ -5721,27 +6241,39 @@ class UIAnimatedImage extends UIElement {
|
|
|
5721
6241
|
}
|
|
5722
6242
|
super.onWillRender(renderer, deltaTime);
|
|
5723
6243
|
}
|
|
5724
|
-
|
|
5725
|
-
|
|
5726
|
-
if (this.color.dirty
|
|
5727
|
-
|
|
5728
|
-
|
|
5729
|
-
textureTransform: frame.calculateUVTransform(this._private_textureTransform),
|
|
5730
|
-
color: this.color,
|
|
5731
|
-
});
|
|
6244
|
+
setPlaneTransform() {
|
|
6245
|
+
let properties;
|
|
6246
|
+
if (this.color.dirty) {
|
|
6247
|
+
properties ?? (properties = {});
|
|
6248
|
+
properties["color"] = this.color;
|
|
5732
6249
|
this.color.setDirtyFalse();
|
|
5733
6250
|
}
|
|
5734
|
-
|
|
5735
|
-
|
|
6251
|
+
const frame = this._private_sequenceInternal[this._private_sequenceFrameIndex];
|
|
6252
|
+
if (frame.textureDirty || this._private_currentFrameIndexDirty) {
|
|
6253
|
+
properties ?? (properties = {});
|
|
6254
|
+
properties["texture"] = frame.texture;
|
|
6255
|
+
frame.setTextureDirtyFalse();
|
|
6256
|
+
}
|
|
6257
|
+
if (frame.uvTransformDirty || this._private_currentFrameIndexDirty) {
|
|
6258
|
+
properties ?? (properties = {});
|
|
6259
|
+
properties["textureTransform"] = frame.calculateUVTransform(this._private_textureTransform);
|
|
6260
|
+
frame.setUVTransformDirtyFalse();
|
|
6261
|
+
}
|
|
6262
|
+
if (properties) {
|
|
6263
|
+
this.sceneWrapper.setProperties(this.planeHandler, properties);
|
|
6264
|
+
}
|
|
6265
|
+
const isTransformDirty = this._private_currentFrameIndexDirty ||
|
|
5736
6266
|
this.micro.dirty ||
|
|
6267
|
+
frame.trimDirty ||
|
|
5737
6268
|
this.inputWrapper.dirty ||
|
|
5738
|
-
this.solverWrapper.dirty
|
|
5739
|
-
|
|
6269
|
+
this.solverWrapper.dirty;
|
|
6270
|
+
if (isTransformDirty) {
|
|
5740
6271
|
const micro = this.micro;
|
|
5741
|
-
|
|
5742
|
-
|
|
6272
|
+
const textureTrim = frame.trim;
|
|
6273
|
+
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));
|
|
5743
6274
|
this._private_currentFrameIndexDirty = false;
|
|
5744
6275
|
this.micro.setDirtyFalse();
|
|
6276
|
+
frame.setTrimDirtyFalse();
|
|
5745
6277
|
}
|
|
5746
6278
|
}
|
|
5747
6279
|
_private_subscribeSequenceEvents() {
|
|
@@ -5774,8 +6306,10 @@ class UIGraphics extends UIElement {
|
|
|
5774
6306
|
throw new Error("UIGraphics.constructor: failed to get 2D context from OffscreenCanvas");
|
|
5775
6307
|
}
|
|
5776
6308
|
const texture = new CanvasTexture(canvas);
|
|
6309
|
+
texture.colorSpace = SRGBColorSpace;
|
|
5777
6310
|
texture.minFilter = LinearFilter;
|
|
5778
6311
|
texture.magFilter = LinearFilter;
|
|
6312
|
+
texture.needsUpdate = true;
|
|
5779
6313
|
super(layer, source$4, {
|
|
5780
6314
|
texture: texture,
|
|
5781
6315
|
textureTransform: texture.matrix,
|
|
@@ -5901,47 +6435,59 @@ class UIImage extends UIElement {
|
|
|
5901
6435
|
this.texture.off(UITextureViewEvent.DIMENSIONS_CHANGED, this._private_onTextureDimensionsChanged);
|
|
5902
6436
|
super.destroy();
|
|
5903
6437
|
}
|
|
5904
|
-
|
|
5905
|
-
|
|
5906
|
-
|
|
5907
|
-
|
|
5908
|
-
|
|
5909
|
-
color: this.color,
|
|
5910
|
-
});
|
|
6438
|
+
setPlaneTransform() {
|
|
6439
|
+
let properties;
|
|
6440
|
+
if (this.color.dirty) {
|
|
6441
|
+
properties ?? (properties = {});
|
|
6442
|
+
properties["color"] = this.color;
|
|
5911
6443
|
this.color.setDirtyFalse();
|
|
5912
6444
|
}
|
|
5913
|
-
if (this.texture.
|
|
5914
|
-
|
|
6445
|
+
if (this.texture.textureDirty) {
|
|
6446
|
+
properties ?? (properties = {});
|
|
6447
|
+
properties["texture"] = this.texture.texture;
|
|
6448
|
+
this.texture.setTextureDirtyFalse();
|
|
6449
|
+
}
|
|
6450
|
+
if (this.texture.uvTransformDirty) {
|
|
6451
|
+
properties ?? (properties = {});
|
|
6452
|
+
properties["textureTransform"] = this.texture.calculateUVTransform(this._private_textureTransform);
|
|
6453
|
+
this.texture.setUVTransformDirtyFalse();
|
|
6454
|
+
}
|
|
6455
|
+
if (properties) {
|
|
6456
|
+
this.sceneWrapper.setProperties(this.planeHandler, properties);
|
|
6457
|
+
}
|
|
6458
|
+
const isTransformDirty = this.micro.dirty ||
|
|
6459
|
+
this.texture.trimDirty ||
|
|
5915
6460
|
this.inputWrapper.dirty ||
|
|
5916
|
-
this.solverWrapper.dirty
|
|
5917
|
-
|
|
6461
|
+
this.solverWrapper.dirty;
|
|
6462
|
+
if (isTransformDirty) {
|
|
5918
6463
|
const micro = this.micro;
|
|
5919
|
-
|
|
5920
|
-
this.
|
|
6464
|
+
const textureTrim = this.texture.trim;
|
|
6465
|
+
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));
|
|
5921
6466
|
this.micro.setDirtyFalse();
|
|
6467
|
+
this.texture.setTrimDirtyFalse();
|
|
5922
6468
|
}
|
|
5923
6469
|
}
|
|
5924
6470
|
}
|
|
5925
6471
|
|
|
5926
|
-
const
|
|
6472
|
+
const INSETS_DEFAULT_VALUE = 0;
|
|
5927
6473
|
|
|
5928
|
-
/**
|
|
5929
|
-
class
|
|
6474
|
+
/** Insets values for four sides */
|
|
6475
|
+
class UIInsets {
|
|
5930
6476
|
/**
|
|
5931
|
-
* Creates
|
|
6477
|
+
* Creates UIInsets instance.
|
|
5932
6478
|
*
|
|
5933
|
-
* @param config -
|
|
6479
|
+
* @param config - Insets configuration
|
|
5934
6480
|
*/
|
|
5935
6481
|
constructor(config) {
|
|
5936
6482
|
this._private_dirtyInternal = false;
|
|
5937
6483
|
if (config === undefined) {
|
|
5938
|
-
this._private_lInternal =
|
|
5939
|
-
this._private_rInternal =
|
|
5940
|
-
this._private_tInternal =
|
|
5941
|
-
this._private_bInternal =
|
|
6484
|
+
this._private_lInternal = INSETS_DEFAULT_VALUE;
|
|
6485
|
+
this._private_rInternal = INSETS_DEFAULT_VALUE;
|
|
6486
|
+
this._private_tInternal = INSETS_DEFAULT_VALUE;
|
|
6487
|
+
this._private_bInternal = INSETS_DEFAULT_VALUE;
|
|
5942
6488
|
}
|
|
5943
6489
|
else if (typeof config === "number") {
|
|
5944
|
-
assertValidNonNegativeNumber(config, "
|
|
6490
|
+
assertValidNonNegativeNumber(config, "UIInsets.constructor.config");
|
|
5945
6491
|
this._private_lInternal = config;
|
|
5946
6492
|
this._private_rInternal = config;
|
|
5947
6493
|
this._private_tInternal = config;
|
|
@@ -5952,10 +6498,10 @@ class UIPadding {
|
|
|
5952
6498
|
const right = config.right;
|
|
5953
6499
|
const top = config.top;
|
|
5954
6500
|
const bottom = config.bottom;
|
|
5955
|
-
assertValidNonNegativeNumber(left, "
|
|
5956
|
-
assertValidNonNegativeNumber(right, "
|
|
5957
|
-
assertValidNonNegativeNumber(top, "
|
|
5958
|
-
assertValidNonNegativeNumber(bottom, "
|
|
6501
|
+
assertValidNonNegativeNumber(left, "UIInsets.constructor.config.left");
|
|
6502
|
+
assertValidNonNegativeNumber(right, "UIInsets.constructor.config.right");
|
|
6503
|
+
assertValidNonNegativeNumber(top, "UIInsets.constructor.config.top");
|
|
6504
|
+
assertValidNonNegativeNumber(bottom, "UIInsets.constructor.config.bottom");
|
|
5959
6505
|
this._private_lInternal = left;
|
|
5960
6506
|
this._private_rInternal = right;
|
|
5961
6507
|
this._private_tInternal = top;
|
|
@@ -5964,27 +6510,27 @@ class UIPadding {
|
|
|
5964
6510
|
else {
|
|
5965
6511
|
const horizontal = config.horizontal;
|
|
5966
6512
|
const vertical = config.vertical;
|
|
5967
|
-
assertValidNonNegativeNumber(horizontal, "
|
|
5968
|
-
assertValidNonNegativeNumber(vertical, "
|
|
6513
|
+
assertValidNonNegativeNumber(horizontal, "UIInsets.constructor.config.horizontal");
|
|
6514
|
+
assertValidNonNegativeNumber(vertical, "UIInsets.constructor.config.vertical");
|
|
5969
6515
|
this._private_lInternal = horizontal;
|
|
5970
6516
|
this._private_rInternal = horizontal;
|
|
5971
6517
|
this._private_tInternal = vertical;
|
|
5972
6518
|
this._private_bInternal = vertical;
|
|
5973
6519
|
}
|
|
5974
6520
|
}
|
|
5975
|
-
/** Left
|
|
6521
|
+
/** Left inset */
|
|
5976
6522
|
get left() {
|
|
5977
6523
|
return this._private_lInternal;
|
|
5978
6524
|
}
|
|
5979
|
-
/** Right
|
|
6525
|
+
/** Right inset */
|
|
5980
6526
|
get right() {
|
|
5981
6527
|
return this._private_rInternal;
|
|
5982
6528
|
}
|
|
5983
|
-
/** Top
|
|
6529
|
+
/** Top inset */
|
|
5984
6530
|
get top() {
|
|
5985
6531
|
return this._private_tInternal;
|
|
5986
6532
|
}
|
|
5987
|
-
/** Bottom
|
|
6533
|
+
/** Bottom inset */
|
|
5988
6534
|
get bottom() {
|
|
5989
6535
|
return this._private_bInternal;
|
|
5990
6536
|
}
|
|
@@ -5992,33 +6538,33 @@ class UIPadding {
|
|
|
5992
6538
|
get dirty() {
|
|
5993
6539
|
return this._private_dirtyInternal;
|
|
5994
6540
|
}
|
|
5995
|
-
/** Left
|
|
6541
|
+
/** Left inset */
|
|
5996
6542
|
set left(value) {
|
|
5997
|
-
assertValidNonNegativeNumber(value, "
|
|
6543
|
+
assertValidNonNegativeNumber(value, "UIInsets.left");
|
|
5998
6544
|
if (this._private_lInternal !== value) {
|
|
5999
6545
|
this._private_lInternal = value;
|
|
6000
6546
|
this._private_dirtyInternal = true;
|
|
6001
6547
|
}
|
|
6002
6548
|
}
|
|
6003
|
-
/** Right
|
|
6549
|
+
/** Right inset */
|
|
6004
6550
|
set right(value) {
|
|
6005
|
-
assertValidNonNegativeNumber(value, "
|
|
6551
|
+
assertValidNonNegativeNumber(value, "UIInsets.right");
|
|
6006
6552
|
if (this._private_rInternal !== value) {
|
|
6007
6553
|
this._private_rInternal = value;
|
|
6008
6554
|
this._private_dirtyInternal = true;
|
|
6009
6555
|
}
|
|
6010
6556
|
}
|
|
6011
|
-
/** Top
|
|
6557
|
+
/** Top inset */
|
|
6012
6558
|
set top(value) {
|
|
6013
|
-
assertValidNonNegativeNumber(value, "
|
|
6559
|
+
assertValidNonNegativeNumber(value, "UIInsets.top");
|
|
6014
6560
|
if (this._private_tInternal !== value) {
|
|
6015
6561
|
this._private_tInternal = value;
|
|
6016
6562
|
this._private_dirtyInternal = true;
|
|
6017
6563
|
}
|
|
6018
6564
|
}
|
|
6019
|
-
/** Bottom
|
|
6565
|
+
/** Bottom inset */
|
|
6020
6566
|
set bottom(value) {
|
|
6021
|
-
assertValidNonNegativeNumber(value, "
|
|
6567
|
+
assertValidNonNegativeNumber(value, "UIInsets.bottom");
|
|
6022
6568
|
if (this._private_bInternal !== value) {
|
|
6023
6569
|
this._private_bInternal = value;
|
|
6024
6570
|
this._private_dirtyInternal = true;
|
|
@@ -6026,7 +6572,7 @@ class UIPadding {
|
|
|
6026
6572
|
}
|
|
6027
6573
|
/** Sets left and right to same value */
|
|
6028
6574
|
setHorizontal(value) {
|
|
6029
|
-
assertValidNonNegativeNumber(value, "
|
|
6575
|
+
assertValidNonNegativeNumber(value, "UIInsets.setHorizontal.value");
|
|
6030
6576
|
if (this._private_lInternal !== value || this._private_rInternal !== value) {
|
|
6031
6577
|
this._private_lInternal = value;
|
|
6032
6578
|
this._private_rInternal = value;
|
|
@@ -6035,7 +6581,7 @@ class UIPadding {
|
|
|
6035
6581
|
}
|
|
6036
6582
|
/** Sets top and bottom to same value */
|
|
6037
6583
|
setVertical(value) {
|
|
6038
|
-
assertValidNonNegativeNumber(value, "
|
|
6584
|
+
assertValidNonNegativeNumber(value, "UIInsets.setVertical.value");
|
|
6039
6585
|
if (this._private_tInternal !== value || this._private_bInternal !== value) {
|
|
6040
6586
|
this._private_tInternal = value;
|
|
6041
6587
|
this._private_bInternal = value;
|
|
@@ -6044,7 +6590,7 @@ class UIPadding {
|
|
|
6044
6590
|
}
|
|
6045
6591
|
/** Sets all sides to same value */
|
|
6046
6592
|
setUnified(value) {
|
|
6047
|
-
assertValidNonNegativeNumber(value, "
|
|
6593
|
+
assertValidNonNegativeNumber(value, "UIInsets.setUnified.value");
|
|
6048
6594
|
if (this._private_lInternal !== value ||
|
|
6049
6595
|
this._private_rInternal !== value ||
|
|
6050
6596
|
this._private_tInternal !== value ||
|
|
@@ -6058,10 +6604,10 @@ class UIPadding {
|
|
|
6058
6604
|
}
|
|
6059
6605
|
/** Sets from Vector4 (x=left, y=right, z=top, w=bottom) */
|
|
6060
6606
|
setVector4(vector) {
|
|
6061
|
-
assertValidNonNegativeNumber(vector.x, "
|
|
6062
|
-
assertValidNonNegativeNumber(vector.y, "
|
|
6063
|
-
assertValidNonNegativeNumber(vector.z, "
|
|
6064
|
-
assertValidNonNegativeNumber(vector.w, "
|
|
6607
|
+
assertValidNonNegativeNumber(vector.x, "UIInsets.setVector4.vector.x");
|
|
6608
|
+
assertValidNonNegativeNumber(vector.y, "UIInsets.setVector4.vector.y");
|
|
6609
|
+
assertValidNonNegativeNumber(vector.z, "UIInsets.setVector4.vector.z");
|
|
6610
|
+
assertValidNonNegativeNumber(vector.w, "UIInsets.setVector4.vector.w");
|
|
6065
6611
|
if (this._private_lInternal !== vector.x ||
|
|
6066
6612
|
this._private_rInternal !== vector.y ||
|
|
6067
6613
|
this._private_tInternal !== vector.z ||
|
|
@@ -6130,8 +6676,8 @@ class UINineSlice extends UIElement {
|
|
|
6130
6676
|
const textureTransform = textureView.calculateUVTransform();
|
|
6131
6677
|
options.width = options.width ?? textureView.width;
|
|
6132
6678
|
options.height = options.height ?? textureView.height;
|
|
6133
|
-
const sliceBorders = new
|
|
6134
|
-
const sliceRegions = new
|
|
6679
|
+
const sliceBorders = new UIInsets(options.sliceBorders ?? NINE_SLICE_DEFAULT_BORDER);
|
|
6680
|
+
const sliceRegions = new UIInsets(options.sliceRegions ?? NINE_SLICE_DEFAULT_BORDER);
|
|
6135
6681
|
const regionMode = options.regionMode ?? NINE_SLICE_DEFAULT_REGION_MODE;
|
|
6136
6682
|
const sliceBordersVector = new Vector4();
|
|
6137
6683
|
const sliceRegionsVector = new Vector4();
|
|
@@ -6167,9 +6713,11 @@ class UINineSlice extends UIElement {
|
|
|
6167
6713
|
this._private_regionModeDirty = true;
|
|
6168
6714
|
}
|
|
6169
6715
|
}
|
|
6170
|
-
|
|
6716
|
+
setPlaneTransform() {
|
|
6171
6717
|
if (this._private_regionModeDirty ||
|
|
6172
|
-
this.texture.
|
|
6718
|
+
this.texture.textureDirty ||
|
|
6719
|
+
this.texture.uvTransformDirty ||
|
|
6720
|
+
this.texture.trimDirty ||
|
|
6173
6721
|
this.color.dirty ||
|
|
6174
6722
|
this.sliceBorders.dirty ||
|
|
6175
6723
|
this.sliceRegions.dirty ||
|
|
@@ -6190,14 +6738,18 @@ class UINineSlice extends UIElement {
|
|
|
6190
6738
|
this.sliceRegions.setDirtyFalse();
|
|
6191
6739
|
this._private_setDimensionsDirtyFalse();
|
|
6192
6740
|
}
|
|
6193
|
-
if (this.texture.
|
|
6741
|
+
if (this.texture.textureDirty ||
|
|
6742
|
+
this.texture.uvTransformDirty ||
|
|
6743
|
+
this.texture.trimDirty ||
|
|
6194
6744
|
this.micro.dirty ||
|
|
6195
6745
|
this.inputWrapper.dirty ||
|
|
6196
6746
|
this.solverWrapper.dirty) {
|
|
6197
6747
|
const trim = this.texture.trim;
|
|
6198
6748
|
const micro = this.micro;
|
|
6199
6749
|
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, trim.left, trim.right, trim.top, trim.bottom));
|
|
6200
|
-
this.texture.
|
|
6750
|
+
this.texture.setTextureDirtyFalse();
|
|
6751
|
+
this.texture.setUVTransformDirtyFalse();
|
|
6752
|
+
this.texture.setTrimDirtyFalse();
|
|
6201
6753
|
this.micro.setDirtyFalse();
|
|
6202
6754
|
}
|
|
6203
6755
|
}
|
|
@@ -6307,14 +6859,6 @@ class UIProgressMaskFunctionDirectional extends UIProgressMaskFunction {
|
|
|
6307
6859
|
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;}";
|
|
6308
6860
|
|
|
6309
6861
|
const PROGRESS_DEFAULT_VALUE = 1;
|
|
6310
|
-
function simplifyGLSLSource(source) {
|
|
6311
|
-
return source
|
|
6312
|
-
.replace(/\/\*[\s\S]*?\*\//g, "")
|
|
6313
|
-
.replace(/\/\/[^\n]*/g, "")
|
|
6314
|
-
.replace(/\s*([{}(),=;+\-*/<>])\s*/g, "$1")
|
|
6315
|
-
.replace(/\s+/g, " ")
|
|
6316
|
-
.trim();
|
|
6317
|
-
}
|
|
6318
6862
|
|
|
6319
6863
|
/** Progress bar with customizable fill direction */
|
|
6320
6864
|
class UIProgress extends UIElement {
|
|
@@ -6328,16 +6872,18 @@ class UIProgress extends UIElement {
|
|
|
6328
6872
|
* @param options - Configuration options
|
|
6329
6873
|
*/
|
|
6330
6874
|
constructor(layer, texture, options = {}) {
|
|
6875
|
+
if (options.progress !== undefined) {
|
|
6876
|
+
assertValidNumber(options.progress, "UIProgress.constructor.options.progress");
|
|
6877
|
+
}
|
|
6331
6878
|
const color = new UIColor(options.color);
|
|
6332
6879
|
const textureView = new UITextureView(texture);
|
|
6333
6880
|
const textureTransform = textureView.calculateUVTransform();
|
|
6334
6881
|
const textureResolution = textureView.getResolution();
|
|
6335
6882
|
options.width = options.width ?? textureView.width;
|
|
6336
6883
|
options.height = options.height ?? textureView.height;
|
|
6337
|
-
const progress = options.progress ?? PROGRESS_DEFAULT_VALUE;
|
|
6884
|
+
const progress = MathUtils.clamp(options.progress ?? PROGRESS_DEFAULT_VALUE, 0, 1);
|
|
6338
6885
|
const maskFunction = options.maskFunction ?? new UIProgressMaskFunctionDirectional();
|
|
6339
|
-
|
|
6340
|
-
super(layer, simplifiedSource, {
|
|
6886
|
+
super(layer, maskFunction.source + source$1, {
|
|
6341
6887
|
texture: textureView.texture,
|
|
6342
6888
|
textureTransform,
|
|
6343
6889
|
textureResolution,
|
|
@@ -6345,10 +6891,14 @@ class UIProgress extends UIElement {
|
|
|
6345
6891
|
progress,
|
|
6346
6892
|
...maskFunction.enumerateProperties(),
|
|
6347
6893
|
}, options);
|
|
6348
|
-
this.
|
|
6894
|
+
this._private_progressDirty = false;
|
|
6895
|
+
this._private_textureResolutionDirty = false;
|
|
6349
6896
|
this._private_onTextureDimensionsChanged = (width, height) => {
|
|
6350
|
-
this.width
|
|
6351
|
-
|
|
6897
|
+
if (this.width !== width || this.height !== height) {
|
|
6898
|
+
this.width = width;
|
|
6899
|
+
this.height = height;
|
|
6900
|
+
this._private_textureResolutionDirty = true;
|
|
6901
|
+
}
|
|
6352
6902
|
};
|
|
6353
6903
|
this.texture = textureView;
|
|
6354
6904
|
this._private_textureTransform = textureTransform;
|
|
@@ -6362,36 +6912,63 @@ class UIProgress extends UIElement {
|
|
|
6362
6912
|
get progress() {
|
|
6363
6913
|
return this._private_progressInternal;
|
|
6364
6914
|
}
|
|
6365
|
-
/** Progress from 0 (empty) to 1 (full). Clamped
|
|
6915
|
+
/** Progress from 0 (empty) to 1 (full). Clamped. */
|
|
6366
6916
|
set progress(value) {
|
|
6917
|
+
assertValidNumber(value, "UIProgress.progress");
|
|
6918
|
+
value = MathUtils.clamp(value, 0, 1);
|
|
6367
6919
|
if (this._private_progressInternal !== value) {
|
|
6368
6920
|
this._private_progressInternal = value;
|
|
6369
|
-
this.
|
|
6921
|
+
this._private_progressDirty = true;
|
|
6370
6922
|
}
|
|
6371
6923
|
}
|
|
6372
|
-
|
|
6373
|
-
|
|
6374
|
-
|
|
6375
|
-
|
|
6376
|
-
this.
|
|
6377
|
-
this.sceneWrapper.setProperties(this.planeHandler, {
|
|
6378
|
-
texture: this.texture.texture,
|
|
6379
|
-
textureTransform: this.texture.calculateUVTransform(this._private_textureTransform),
|
|
6380
|
-
textureResolution: this.texture.getResolution(this._private_textureResolution),
|
|
6381
|
-
color: this.color,
|
|
6382
|
-
progress: this._private_progressInternal,
|
|
6383
|
-
});
|
|
6384
|
-
this._private_dirty = false;
|
|
6924
|
+
setPlaneTransform() {
|
|
6925
|
+
let properties;
|
|
6926
|
+
if (this.color.dirty) {
|
|
6927
|
+
properties ?? (properties = {});
|
|
6928
|
+
properties["color"] = this.color;
|
|
6385
6929
|
this.color.setDirtyFalse();
|
|
6930
|
+
}
|
|
6931
|
+
if (this.texture.textureDirty) {
|
|
6932
|
+
properties ?? (properties = {});
|
|
6933
|
+
properties["texture"] = this.texture.texture;
|
|
6934
|
+
this.texture.setTextureDirtyFalse();
|
|
6935
|
+
}
|
|
6936
|
+
if (this.texture.uvTransformDirty) {
|
|
6937
|
+
properties ?? (properties = {});
|
|
6938
|
+
properties["textureTransform"] = this.texture.calculateUVTransform(this._private_textureTransform);
|
|
6939
|
+
this.texture.setUVTransformDirtyFalse();
|
|
6940
|
+
}
|
|
6941
|
+
if (this._private_progressDirty) {
|
|
6942
|
+
properties ?? (properties = {});
|
|
6943
|
+
properties["progress"] = this._private_progressInternal;
|
|
6944
|
+
this._private_progressDirty = false;
|
|
6945
|
+
}
|
|
6946
|
+
if (this._private_textureResolutionDirty) {
|
|
6947
|
+
properties ?? (properties = {});
|
|
6948
|
+
properties["textureResolution"] = this.texture.getResolution(this._private_textureResolution);
|
|
6949
|
+
this._private_textureResolutionDirty = false;
|
|
6950
|
+
}
|
|
6951
|
+
if (this.maskFunction.dirty) {
|
|
6952
|
+
properties ?? (properties = {});
|
|
6953
|
+
const maskProperties = this.maskFunction.enumerateProperties();
|
|
6954
|
+
for (const key in maskProperties) {
|
|
6955
|
+
properties[key] = maskProperties[key];
|
|
6956
|
+
}
|
|
6386
6957
|
this.maskFunction.setDirtyFalse();
|
|
6387
6958
|
}
|
|
6388
|
-
if (
|
|
6959
|
+
if (properties) {
|
|
6960
|
+
this.sceneWrapper.setProperties(this.planeHandler, properties);
|
|
6961
|
+
}
|
|
6962
|
+
const isTransformDirty = this.micro.dirty ||
|
|
6963
|
+
this.texture.trimDirty ||
|
|
6389
6964
|
this.inputWrapper.dirty ||
|
|
6390
|
-
this.
|
|
6391
|
-
|
|
6392
|
-
|
|
6393
|
-
this.texture.
|
|
6965
|
+
this.solverWrapper.dirty;
|
|
6966
|
+
if (isTransformDirty) {
|
|
6967
|
+
const micro = this.micro;
|
|
6968
|
+
const textureTrim = this.texture.trim;
|
|
6969
|
+
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));
|
|
6394
6970
|
this.micro.setDirtyFalse();
|
|
6971
|
+
this.texture.setTrimDirtyFalse();
|
|
6395
6972
|
}
|
|
6396
6973
|
}
|
|
6397
6974
|
}
|
|
@@ -6430,11 +7007,10 @@ class UIScene extends UIElement {
|
|
|
6430
7007
|
* @throws If resolutionFactor outside range 0.1 to 2.0
|
|
6431
7008
|
*/
|
|
6432
7009
|
constructor(layer, options = {}) {
|
|
6433
|
-
|
|
6434
|
-
|
|
6435
|
-
resolutionFactor > SCENE_MAX_RESOLUTION_FACTOR) {
|
|
6436
|
-
throw new Error(`UIScene.constructor.resolutionFactor: must be between ${SCENE_MIN_RESOLUTION_FACTOR} and ${SCENE_MAX_RESOLUTION_FACTOR}.`);
|
|
7010
|
+
if (options.resolutionFactor !== undefined) {
|
|
7011
|
+
assertValidPositiveNumber(options.resolutionFactor, "UIScene.constructor.resolutionFactor");
|
|
6437
7012
|
}
|
|
7013
|
+
const resolutionFactor = MathUtils.clamp(options.resolutionFactor ?? SCENE_DEFAULT_RESOLUTION_FACTOR, SCENE_MIN_RESOLUTION_FACTOR, SCENE_MAX_RESOLUTION_FACTOR);
|
|
6438
7014
|
const w = options.width ?? DUMMY_DEFAULT_WIDTH;
|
|
6439
7015
|
const h = options.height ?? DUMMY_DEFAULT_HEIGHT;
|
|
6440
7016
|
const renderTarget = new WebGLRenderTarget(w * resolutionFactor, h * resolutionFactor, {
|
|
@@ -6505,6 +7081,8 @@ class UIScene extends UIElement {
|
|
|
6505
7081
|
}
|
|
6506
7082
|
/** Render target resolution multiplier. Range 0.1 to 2.0. */
|
|
6507
7083
|
set resolutionFactor(value) {
|
|
7084
|
+
assertValidPositiveNumber(value, "UIScene.resolutionFactor");
|
|
7085
|
+
value = MathUtils.clamp(value, SCENE_MIN_RESOLUTION_FACTOR, SCENE_MAX_RESOLUTION_FACTOR);
|
|
6508
7086
|
if (this._private_resolutionFactorInternal !== value) {
|
|
6509
7087
|
this._private_resolutionFactorInternal = value;
|
|
6510
7088
|
this._private_resolutionFactorDirty = true;
|
|
@@ -6521,14 +7099,15 @@ class UIScene extends UIElement {
|
|
|
6521
7099
|
}
|
|
6522
7100
|
onWillRender(renderer, deltaTime) {
|
|
6523
7101
|
this._private_evenFrame = !this._private_evenFrame;
|
|
6524
|
-
|
|
7102
|
+
const isFramebufferDirty = this._private_updateRequired ||
|
|
6525
7103
|
this._private_updateModeInternal === UISceneUpdateMode.EACH_FRAME ||
|
|
6526
7104
|
(this._private_updateModeInternal === UISceneUpdateMode.EVERY_SECOND_FRAME && this._private_evenFrame) ||
|
|
6527
7105
|
(this._private_updateModeInternal === UISceneUpdateMode.ON_PROPERTIES_CHANGE && this._private_propertyDirty) ||
|
|
6528
7106
|
this.color.dirty ||
|
|
6529
7107
|
this.clearColor.dirty ||
|
|
6530
7108
|
(this._private_updateModeInternal === UISceneUpdateMode.ON_DIMENSIONS_CHANGE &&
|
|
6531
|
-
(this._private_resolutionFactorDirty || this.solverWrapper.dirty))
|
|
7109
|
+
(this._private_resolutionFactorDirty || this.solverWrapper.dirty));
|
|
7110
|
+
if (isFramebufferDirty) {
|
|
6532
7111
|
if (this._private_resolutionFactorDirty || this.solverWrapper.dirty) {
|
|
6533
7112
|
this._private_renderTarget.setSize(this.width * this._private_resolutionFactorInternal, this.height * this._private_resolutionFactorInternal);
|
|
6534
7113
|
this._private_resolutionFactorDirty = false;
|
|
@@ -7209,6 +7788,8 @@ class UIText extends UIElement {
|
|
|
7209
7788
|
throw new Error("UIText.constructor: failed to create canvas context");
|
|
7210
7789
|
}
|
|
7211
7790
|
const texture = new CanvasTexture(canvas);
|
|
7791
|
+
texture.colorSpace = SRGBColorSpace;
|
|
7792
|
+
texture.needsUpdate = true;
|
|
7212
7793
|
const color = new UIColor(options.color);
|
|
7213
7794
|
super(layer, source$4, {
|
|
7214
7795
|
texture: texture,
|
|
@@ -7222,7 +7803,7 @@ class UIText extends UIElement {
|
|
|
7222
7803
|
this._private_textChunks = [];
|
|
7223
7804
|
this._private_textChunksDirty = false;
|
|
7224
7805
|
this.color = color;
|
|
7225
|
-
this.padding = new
|
|
7806
|
+
this.padding = new UIInsets(options.padding);
|
|
7226
7807
|
this.commonStyle = new UITextStyle(options.commonStyle);
|
|
7227
7808
|
this._private_maxLineWidthInternal =
|
|
7228
7809
|
options.maxLineWidth ?? TEXT_DEFAULT_MAX_LINE_WIDTH;
|
|
@@ -7397,6 +7978,7 @@ class UIText extends UIElement {
|
|
|
7397
7978
|
_private_rebuildTexture() {
|
|
7398
7979
|
this._private_texture.dispose();
|
|
7399
7980
|
this._private_texture = new CanvasTexture(this._private_canvas);
|
|
7981
|
+
this._private_texture.colorSpace = SRGBColorSpace;
|
|
7400
7982
|
this._private_texture.needsUpdate = true;
|
|
7401
7983
|
this.sceneWrapper.setProperties(this.planeHandler, {
|
|
7402
7984
|
texture: this._private_texture,
|
|
@@ -7574,9 +8156,14 @@ class UIAreaCircle extends UIArea {
|
|
|
7574
8156
|
this.centerX = centerX;
|
|
7575
8157
|
this.centerY = centerY;
|
|
7576
8158
|
this.radius = radius;
|
|
8159
|
+
assertValidNonNegativeNumber(centerX, "UIAreaCircle.constructor.centerX");
|
|
8160
|
+
assertValidNonNegativeNumber(centerY, "UIAreaCircle.constructor.centerY");
|
|
8161
|
+
assertValidNonNegativeNumber(radius, "UIAreaCircle.constructor.radius");
|
|
7577
8162
|
}
|
|
7578
8163
|
/** @internal */
|
|
7579
8164
|
contains(pointX, pointY) {
|
|
8165
|
+
assertValidNumber(pointX, "UIAreaCircle.contains.pointX");
|
|
8166
|
+
assertValidNumber(pointY, "UIAreaCircle.contains.pointY");
|
|
7580
8167
|
const deltaX = pointX - this.centerX;
|
|
7581
8168
|
const deltaY = pointY - this.centerY;
|
|
7582
8169
|
return deltaX * deltaX + deltaY * deltaY <= this.radius * this.radius;
|
|
@@ -7596,6 +8183,8 @@ class UIAreaPolygon extends UIArea {
|
|
|
7596
8183
|
}
|
|
7597
8184
|
/** @internal */
|
|
7598
8185
|
contains(pointX, pointY) {
|
|
8186
|
+
assertValidNumber(pointX, "UIAreaPolygon.contains.pointX");
|
|
8187
|
+
assertValidNumber(pointY, "UIAreaPolygon.contains.pointY");
|
|
7599
8188
|
const vertexCount = this.vertices.length;
|
|
7600
8189
|
if (vertexCount < 3) {
|
|
7601
8190
|
return false;
|
|
@@ -7640,10 +8229,17 @@ class UIAreaRoundedRectangle extends UIArea {
|
|
|
7640
8229
|
this.width = width;
|
|
7641
8230
|
this.height = height;
|
|
7642
8231
|
this.radius = radius;
|
|
8232
|
+
assertValidNonNegativeNumber(x, "UIAreaRoundedRectangle.constructor.x");
|
|
8233
|
+
assertValidNonNegativeNumber(y, "UIAreaRoundedRectangle.constructor.y");
|
|
8234
|
+
assertValidNonNegativeNumber(width, "UIAreaRoundedRectangle.constructor.width");
|
|
8235
|
+
assertValidNonNegativeNumber(height, "UIAreaRoundedRectangle.constructor.height");
|
|
8236
|
+
assertValidNonNegativeNumber(radius, "UIAreaRoundedRectangle.constructor.radius");
|
|
7643
8237
|
this.radius = Math.min(radius, Math.min(width, height) / 2);
|
|
7644
8238
|
}
|
|
7645
8239
|
/** @internal */
|
|
7646
8240
|
contains(pointX, pointY) {
|
|
8241
|
+
assertValidNumber(pointX, "UIAreaRoundedRectangle.contains.pointX");
|
|
8242
|
+
assertValidNumber(pointY, "UIAreaRoundedRectangle.contains.pointY");
|
|
7647
8243
|
const left = this.x;
|
|
7648
8244
|
const right = this.x + this.width;
|
|
7649
8245
|
const top = this.y;
|
|
@@ -7692,6 +8288,7 @@ class UIProgressMaskFunctionCircular extends UIProgressMaskFunction {
|
|
|
7692
8288
|
* @param inverseDirection - Whether to fill counter-clockwise
|
|
7693
8289
|
*/
|
|
7694
8290
|
constructor(startAngle = 0, inverseDirection = false) {
|
|
8291
|
+
assertValidNumber(startAngle, "UIProgressMaskFunctionCircular.constructor.startAngle");
|
|
7695
8292
|
super(source);
|
|
7696
8293
|
this._private_startAngleInternal = startAngle;
|
|
7697
8294
|
this._private_inverseDirectionInternal = inverseDirection;
|
|
@@ -7706,6 +8303,7 @@ class UIProgressMaskFunctionCircular extends UIProgressMaskFunction {
|
|
|
7706
8303
|
}
|
|
7707
8304
|
/** Starting angle in radians */
|
|
7708
8305
|
set startAngle(value) {
|
|
8306
|
+
assertValidNumber(value, "UIProgressMaskFunctionCircular.startAngle");
|
|
7709
8307
|
if (this._private_startAngleInternal !== value) {
|
|
7710
8308
|
this._private_startAngleInternal = value;
|
|
7711
8309
|
this.dirtyInternal = true;
|
|
@@ -8011,5 +8609,5 @@ class UIResizePolicyFixedWidth extends UIResizePolicy {
|
|
|
8011
8609
|
}
|
|
8012
8610
|
}
|
|
8013
8611
|
|
|
8014
|
-
export { UIAnchor, UIAnimatedImage, UIAreaCircle, UIAreaPolygon, UIAreaRectangle, UIAreaRoundedRectangle, UIAspectConstraint, UIColor, UIConstraint2DBuilder, UICoverConstraintBuilder, UICustomConstraint,
|
|
8612
|
+
export { UIAnchor, UIAnimatedImage, UIAreaCircle, UIAreaPolygon, UIAreaRectangle, UIAreaRoundedRectangle, UIAspectConstraint, UIColor, UIConstraint2DBuilder, UICoverConstraintBuilder, UICustomConstraint, UIExpression, UIFitConstraintBuilder, UIFullscreenLayer, UIGraphics, UIHeightConstraint, UIHorizontalDistanceConstraint, UIHorizontalInterpolationConstraint, 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, UIVerticalInterpolationConstraint, UIVerticalProportionConstraint, UIWidthConstraint };
|
|
8015
8613
|
//# sourceMappingURL=index.js.map
|