laymur 0.2.18 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/README.md +87 -274
  2. package/dist/builders/UIConstraint2DBuilder.d.ts +1 -1
  3. package/dist/builders/UICoverConstraintBuilder.d.ts +3 -1
  4. package/dist/builders/UIFitConstraintBuilder.d.ts +3 -1
  5. package/dist/constraints/UIAspectConstraint.d.ts +0 -1
  6. package/dist/constraints/UIConstraint.d.ts +3 -0
  7. package/dist/constraints/UIHorizontalDistanceConstraint.d.ts +0 -1
  8. package/dist/constraints/UIHorizontalProportionConstraint.d.ts +2 -3
  9. package/dist/constraints/UISingleParameterConstraint.d.ts +0 -2
  10. package/dist/constraints/UIVerticalDistanceConstraint.d.ts +0 -1
  11. package/dist/constraints/UIVerticalProportionConstraint.d.ts +2 -3
  12. package/dist/elements/UIDummy.d.ts +7 -1
  13. package/dist/elements/UIElement.d.ts +52 -38
  14. package/dist/elements/UIImage.d.ts +30 -42
  15. package/dist/elements/UINineSline.d.ts +61 -68
  16. package/dist/elements/UIProgress.d.ts +86 -110
  17. package/dist/elements/UIScene.d.ts +21 -30
  18. package/dist/elements/UIText.d.ts +27 -41
  19. package/dist/index.d.ts +6 -1
  20. package/dist/index.js +1663 -939
  21. package/dist/index.js.map +1 -1
  22. package/dist/index.min.js +1 -1
  23. package/dist/index.min.js.map +1 -1
  24. package/dist/layers/UIFullscreenLayer.d.ts +0 -4
  25. package/dist/layers/UILayer.d.ts +62 -4
  26. package/dist/miscellaneous/UIColor.d.ts +171 -0
  27. package/dist/miscellaneous/UIGenericInstancedPlane.d.ts +32 -0
  28. package/dist/miscellaneous/UIInputEvent.d.ts +7 -0
  29. package/dist/miscellaneous/UIMicro.d.ts +3 -3
  30. package/dist/miscellaneous/{UIAnchorMode.d.ts → UIMicroAnchorMode.d.ts} +1 -1
  31. package/dist/miscellaneous/UINineSliceBorder.d.ts +6 -6
  32. package/dist/miscellaneous/UISceneWrapperClientAPI.d.ts +12 -0
  33. package/dist/miscellaneous/UITextPadding.d.ts +1 -1
  34. package/dist/miscellaneous/UITransparencyMode.d.ts +26 -0
  35. package/dist/miscellaneous/asserts.d.ts +9 -9
  36. package/dist/miscellaneous/textTools.d.ts +4 -4
  37. package/dist/wrappers/UISceneWrapper.d.ts +21 -14
  38. package/dist/wrappers/UISolverWrapper.d.ts +185 -0
  39. package/package.json +7 -4
  40. package/dist/materials/UIMaterial.d.ts +0 -13
  41. package/dist/materials/UINineSliceMaterial.d.ts +0 -27
  42. package/dist/materials/UIProgressMaterial.d.ts +0 -29
  43. package/dist/miscellaneous/threeInstances.d.ts +0 -2
  44. package/dist/scalable/UIScalableMesh.d.ts +0 -16
  45. package/dist/scalable/UIScalablePlaneMesh.d.ts +0 -14
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Color, Scene, OrthographicCamera, MathUtils, ShaderMaterial, PlaneGeometry, Mesh, Vector2, Vector4, UniformsUtils, WebGLRenderTarget, UnsignedByteType, LinearFilter, RGBAFormat, PerspectiveCamera, CanvasTexture } from 'three';
1
+ import { PlaneGeometry, Color, Scene, OrthographicCamera, ShaderMaterial, Vector4, Mesh, Texture, Vector2, Vector3, Matrix2, Matrix3, Matrix4, MathUtils, Quaternion, WebGLRenderTarget, UnsignedByteType, LinearFilter, RGBAFormat, PerspectiveCamera, CanvasTexture, InstancedBufferGeometry, InstancedBufferAttribute } from 'three';
2
2
 
3
3
  /**
4
4
  * Mathematical expression builder for constraint equations in the UI layout system.
@@ -1816,16 +1816,380 @@ function resolvePriority(priority) {
1816
1816
  }
1817
1817
 
1818
1818
  /**
1819
- * Defines the anchor mode for UIMicro, determining which transformations are applied around the anchor point.
1819
+ * Database of predefined color names mapped to their hexadecimal RGB values.
1820
+ * Used for creating UIColor instances from named colors.
1820
1821
  */
1821
- var UIAnchorMode;
1822
- (function (UIAnchorMode) {
1823
- /** Rotation and scaling are applied around the anchor point */
1824
- UIAnchorMode[UIAnchorMode["ROTATION_SCALE"] = 0] = "ROTATION_SCALE";
1825
- /** Position, rotation, and scaling transformations are all applied around the anchor point */
1826
- UIAnchorMode[UIAnchorMode["POSITION_ROTATION_SCALE"] = 1] = "POSITION_ROTATION_SCALE";
1827
- })(UIAnchorMode || (UIAnchorMode = {}));
1822
+ const COLOR_NAMES = {
1823
+ // Basic colors
1824
+ black: 0x000000,
1825
+ white: 0xffffff,
1826
+ red: 0xff0000,
1827
+ green: 0x008000,
1828
+ blue: 0x0000ff,
1829
+ yellow: 0xffff00,
1830
+ cyan: 0x00ffff,
1831
+ magenta: 0xff00ff,
1832
+ // Extended colors
1833
+ gray: 0x808080,
1834
+ grey: 0x808080,
1835
+ silver: 0xc0c0c0,
1836
+ maroon: 0x800000,
1837
+ olive: 0x808000,
1838
+ lime: 0x00ff00,
1839
+ aqua: 0x00ffff,
1840
+ teal: 0x008080,
1841
+ navy: 0x000080,
1842
+ fuchsia: 0xff00ff,
1843
+ purple: 0x800080,
1844
+ // Additional common colors
1845
+ orange: 0xffa500,
1846
+ pink: 0xffc0cb,
1847
+ brown: 0xa52a2a,
1848
+ gold: 0xffd700,
1849
+ violet: 0xee82ee,
1850
+ indigo: 0x4b0082,
1851
+ coral: 0xff7f50,
1852
+ salmon: 0xfa8072,
1853
+ khaki: 0xf0e68c,
1854
+ plum: 0xdda0dd,
1855
+ orchid: 0xda70d6,
1856
+ tan: 0xd2b48c,
1857
+ beige: 0xf5f5dc,
1858
+ mint: 0x98fb98,
1859
+ lavender: 0xe6e6fa,
1860
+ crimson: 0xdc143c,
1861
+ azure: 0xf0ffff,
1862
+ ivory: 0xfffff0,
1863
+ snow: 0xfffafa,
1864
+ };
1865
+ /**
1866
+ * Events that can be emitted by UIColor instances.
1867
+ */
1868
+ var UIColorEvent;
1869
+ (function (UIColorEvent) {
1870
+ /** Emitted when any color property (r, g, b, a) changes. */
1871
+ UIColorEvent["CHANGE"] = "change";
1872
+ })(UIColorEvent || (UIColorEvent = {}));
1873
+ /**
1874
+ * Event-based RGBA color class with support for multiple color formats and named colors.
1875
+ *
1876
+ * UIColor provides a comprehensive color management system with support for RGB, HSL,
1877
+ * hexadecimal formats, and named colors. It extends Eventail to emit change events
1878
+ * when color properties are modified, enabling reactive color updates throughout
1879
+ * the UI system.
1880
+ *
1881
+ * Color components are stored as normalized values (0-1) for precision and
1882
+ * compatibility with graphics APIs.
1883
+ *
1884
+ * @see {@link UIColorEvent} - Events emitted by color instances
1885
+ * @see {@link UIColorName} - Supported named color values
1886
+ */
1887
+ class UIColor extends i {
1888
+ constructor(...args) {
1889
+ super();
1890
+ /** Internal storage for the red component (0-1). */
1891
+ this.rInternal = 1;
1892
+ /** Internal storage for the green component (0-1). */
1893
+ this.gInternal = 1;
1894
+ /** Internal storage for the blue component (0-1). */
1895
+ this.bInternal = 1;
1896
+ /** Internal storage for the alpha component (0-1). */
1897
+ this.aInternal = 1;
1898
+ if (args.length >= 3 && typeof args[0] === "number") {
1899
+ const [r, g, b, a = 1] = args;
1900
+ this.rInternal = r;
1901
+ this.gInternal = g;
1902
+ this.bInternal = b;
1903
+ this.aInternal = a;
1904
+ }
1905
+ else if (args.length >= 1) {
1906
+ const [first, a = 1] = args;
1907
+ if (typeof first === "string") {
1908
+ this.setName(first, a);
1909
+ }
1910
+ else {
1911
+ this.setHexRGB(first, a);
1912
+ }
1913
+ }
1914
+ }
1915
+ /**
1916
+ * Gets the red component value.
1917
+ * @returns The red component (0-1)
1918
+ */
1919
+ get r() {
1920
+ return this.rInternal;
1921
+ }
1922
+ /**
1923
+ * Gets the green component value.
1924
+ * @returns The green component (0-1)
1925
+ */
1926
+ get g() {
1927
+ return this.gInternal;
1928
+ }
1929
+ /**
1930
+ * Gets the blue component value.
1931
+ * @returns The blue component (0-1)
1932
+ */
1933
+ get b() {
1934
+ return this.bInternal;
1935
+ }
1936
+ /**
1937
+ * Gets the alpha component value.
1938
+ * @returns The alpha component (0-1)
1939
+ */
1940
+ get a() {
1941
+ return this.aInternal;
1942
+ }
1943
+ /**
1944
+ * Sets the red component value and emits change event.
1945
+ * @param value - The red component (0-1)
1946
+ */
1947
+ set r(value) {
1948
+ this.rInternal = value;
1949
+ this.emit(UIColorEvent.CHANGE, this);
1950
+ }
1951
+ /**
1952
+ * Sets the green component value and emits change event.
1953
+ * @param value - The green component (0-1)
1954
+ */
1955
+ set g(value) {
1956
+ this.gInternal = value;
1957
+ this.emit(UIColorEvent.CHANGE, this);
1958
+ }
1959
+ /**
1960
+ * Sets the blue component value and emits change event.
1961
+ * @param value - The blue component (0-1)
1962
+ */
1963
+ set b(value) {
1964
+ this.bInternal = value;
1965
+ this.emit(UIColorEvent.CHANGE, this);
1966
+ }
1967
+ /**
1968
+ * Sets the alpha component value and emits change event.
1969
+ * @param value - The alpha component (0-1)
1970
+ */
1971
+ set a(value) {
1972
+ this.aInternal = value;
1973
+ this.emit(UIColorEvent.CHANGE, this);
1974
+ }
1975
+ /**
1976
+ * Sets all color components at once and emits change event.
1977
+ * @param r - Red component (0-1)
1978
+ * @param g - Green component (0-1)
1979
+ * @param b - Blue component (0-1)
1980
+ * @param a - Alpha component (0-1), defaults to current alpha value
1981
+ * @returns This UIColor instance for method chaining
1982
+ */
1983
+ set(r, g, b, a = this.aInternal) {
1984
+ this.rInternal = r;
1985
+ this.gInternal = g;
1986
+ this.bInternal = b;
1987
+ this.aInternal = a;
1988
+ this.emit(UIColorEvent.CHANGE, this);
1989
+ return this;
1990
+ }
1991
+ /**
1992
+ * Converts the color to a 32-bit hexadecimal RGBA value.
1993
+ * @returns Hexadecimal RGBA value with alpha in the most significant byte
1994
+ */
1995
+ getHexRGBA() {
1996
+ return ((Math.round(this.rInternal * 255) << 24) |
1997
+ (Math.round(this.gInternal * 255) << 16) |
1998
+ (Math.round(this.bInternal * 255) << 8) |
1999
+ Math.round(this.aInternal * 255));
2000
+ }
2001
+ /**
2002
+ * Converts the color to a 24-bit hexadecimal RGB value (ignores alpha).
2003
+ * @returns Hexadecimal RGB value (e.g., 0xFF0000 for red)
2004
+ */
2005
+ getHexRGB() {
2006
+ return ((Math.round(this.rInternal * 255) << 16) |
2007
+ (Math.round(this.gInternal * 255) << 8) |
2008
+ Math.round(this.bInternal * 255));
2009
+ }
2010
+ /**
2011
+ * Converts the color to HSL (Hue, Saturation, Lightness) format.
2012
+ * @returns Object containing h (0-360), s (0-1), and l (0-1) values
2013
+ */
2014
+ getHSL() {
2015
+ const { rInternal: r, gInternal: g, bInternal: b } = this;
2016
+ const max = Math.max(r, g, b);
2017
+ const min = Math.min(r, g, b);
2018
+ const d = max - min;
2019
+ const l = (max + min) / 2;
2020
+ let h = 0;
2021
+ if (d !== 0) {
2022
+ if (max === r) {
2023
+ h = (g - b) / d + (g < b ? 6 : 0);
2024
+ }
2025
+ else if (max === g) {
2026
+ h = (b - r) / d + 2;
2027
+ }
2028
+ else {
2029
+ h = (r - g) / d + 4;
2030
+ }
2031
+ h *= 60;
2032
+ }
2033
+ const s = d === 0 ? 0 : d / (1 - Math.abs(2 * l - 1));
2034
+ return { h, s, l };
2035
+ }
2036
+ /**
2037
+ * Sets the color from a 32-bit hexadecimal RGBA value and emits change event.
2038
+ * @param hex - Hexadecimal RGBA value with alpha in the most significant byte
2039
+ * @returns This UIColor instance for method chaining
2040
+ */
2041
+ setHexRGBA(hex) {
2042
+ this.rInternal = ((hex >> 16) & 0xff) / 255;
2043
+ this.gInternal = ((hex >> 8) & 0xff) / 255;
2044
+ this.bInternal = (hex & 0xff) / 255;
2045
+ this.aInternal = ((hex >> 24) & 0xff) / 255;
2046
+ this.emit(UIColorEvent.CHANGE, this);
2047
+ return this;
2048
+ }
2049
+ /**
2050
+ * Sets the color from a 24-bit hexadecimal RGB value and emits change event.
2051
+ * @param hex - Hexadecimal RGB value (e.g., 0xFF0000 for red)
2052
+ * @param a - Alpha value (0-1), defaults to current alpha
2053
+ * @returns This UIColor instance for method chaining
2054
+ */
2055
+ setHexRGB(hex, a = this.aInternal) {
2056
+ this.rInternal = ((hex >> 16) & 0xff) / 255;
2057
+ this.gInternal = ((hex >> 8) & 0xff) / 255;
2058
+ this.bInternal = (hex & 0xff) / 255;
2059
+ this.aInternal = a;
2060
+ this.emit(UIColorEvent.CHANGE, this);
2061
+ return this;
2062
+ }
2063
+ /**
2064
+ * Sets the color from HSL (Hue, Saturation, Lightness) values and emits change event.
2065
+ * @param h - Hue value (0-360)
2066
+ * @param s - Saturation value (0-1)
2067
+ * @param l - Lightness value (0-1)
2068
+ * @param a - Alpha value (0-1), defaults to current alpha
2069
+ * @returns This UIColor instance for method chaining
2070
+ */
2071
+ setHSL(h, s, l, a = this.aInternal) {
2072
+ const c = (1 - Math.abs(2 * l - 1)) * s;
2073
+ const hp = h / 60;
2074
+ const x = c * (1 - Math.abs((hp % 2) - 1));
2075
+ let [r, g, b] = hp < 1
2076
+ ? [c, x, 0]
2077
+ : hp < 2
2078
+ ? [x, c, 0]
2079
+ : hp < 3
2080
+ ? [0, c, x]
2081
+ : hp < 4
2082
+ ? [0, x, c]
2083
+ : hp < 5
2084
+ ? [x, 0, c]
2085
+ : [c, 0, x];
2086
+ const m = l - c / 2;
2087
+ return this.set(r + m, g + m, b + m, a);
2088
+ }
2089
+ /**
2090
+ * Sets the color from a predefined color name and emits change event.
2091
+ * @param colorName - Name of the color from the predefined color database
2092
+ * @param a - Alpha value (0-1), defaults to current alpha
2093
+ * @returns This UIColor instance for method chaining
2094
+ * @throws Will throw an error if the color name is not recognized
2095
+ */
2096
+ setName(colorName, a = this.aInternal) {
2097
+ const normalizedName = colorName.toLowerCase().trim();
2098
+ const hex = COLOR_NAMES[normalizedName];
2099
+ if (hex === undefined) {
2100
+ throw new Error(`Unknown color name: "${colorName}".`);
2101
+ }
2102
+ return this.setHexRGB(hex, a);
2103
+ }
2104
+ /**
2105
+ * Copies color values from another UIColor or Three.js Color instance and emits change event.
2106
+ * @param color - The color to copy from (UIColor or Three.js Color)
2107
+ * @returns This UIColor instance for method chaining
2108
+ */
2109
+ copy(color) {
2110
+ if (color instanceof UIColor) {
2111
+ this.rInternal = color.rInternal;
2112
+ this.gInternal = color.gInternal;
2113
+ this.bInternal = color.bInternal;
2114
+ this.aInternal = color.aInternal;
2115
+ }
2116
+ else {
2117
+ this.rInternal = color.r;
2118
+ this.gInternal = color.g;
2119
+ this.bInternal = color.b;
2120
+ this.aInternal = 1;
2121
+ }
2122
+ this.emit(UIColorEvent.CHANGE, this);
2123
+ return this;
2124
+ }
2125
+ /**
2126
+ * Creates a new UIColor instance with identical color values.
2127
+ * @returns A new UIColor instance with the same RGBA values
2128
+ */
2129
+ clone() {
2130
+ return new UIColor(this.rInternal, this.gInternal, this.bInternal, this.aInternal);
2131
+ }
2132
+ }
2133
+
2134
+ /**
2135
+ * Transparency rendering modes for UI elements.
2136
+ *
2137
+ * Controls how transparent and semi-transparent pixels are handled during rendering.
2138
+ * Each mode offers different performance and visual quality trade-offs.
2139
+ */
2140
+ var UITransparencyMode;
2141
+ (function (UITransparencyMode) {
2142
+ /**
2143
+ * Clip mode - pixels are either fully opaque or fully transparent.
2144
+ * Uses alpha testing to discard pixels below a threshold.
2145
+ * Best performance but no smooth transparency gradients.
2146
+ */
2147
+ UITransparencyMode[UITransparencyMode["CLIP"] = 0] = "CLIP";
2148
+ /**
2149
+ * Hash mode - dithered transparency using screen-door transparency.
2150
+ * Creates transparency illusion through pixel patterns.
2151
+ * Good performance with better visual quality than CLIP.
2152
+ */
2153
+ UITransparencyMode[UITransparencyMode["HASH"] = 1] = "HASH";
2154
+ /**
2155
+ * Blend mode - true alpha blending with smooth transparency.
2156
+ * Supports full range of transparency values with smooth gradients.
2157
+ * Best visual quality but requires depth sorting and impacts performance.
2158
+ */
2159
+ UITransparencyMode[UITransparencyMode["BLEND"] = 2] = "BLEND";
2160
+ })(UITransparencyMode || (UITransparencyMode = {}));
2161
+
2162
+ var fragmentShader = "in vec2 io_UV;\n\nuniform float alphaTest;\n\n#include <common>\n#include <alphahash_pars_fragment>\n";
1828
2163
 
2164
+ var vertexShader = "out vec2 io_UV;\n#include <common>\n\nvoid main() {\n #include <begin_vertex>\n io_UV = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n";
2165
+
2166
+ const DEFAULT_ALPHA_TEST = 0.25;
2167
+ const UNIFROM_TYPE_MAP = new Map([
2168
+ [UIColor, "vec4"],
2169
+ [Color, "vec3"],
2170
+ [Texture, "sampler2D"],
2171
+ [Vector2, "vec2"],
2172
+ [Vector3, "vec3"],
2173
+ [Vector4, "vec4"],
2174
+ [Matrix2, "mat2"],
2175
+ [Matrix3, "mat3"],
2176
+ [Matrix4, "mat4"],
2177
+ ]);
2178
+ function buildUniformDeclaraction(name, value) {
2179
+ if (typeof value === "number") {
2180
+ return `uniform float ${name};`;
2181
+ }
2182
+ for (const [objectType, glslType] of UNIFROM_TYPE_MAP) {
2183
+ if (value instanceof objectType) {
2184
+ return `uniform ${glslType} ${name};`;
2185
+ }
2186
+ }
2187
+ throw new Error(`Unsupported uniform type for key "${name}"`);
2188
+ }
2189
+ const Z_LIMIT = 1024;
2190
+ const GEOMETRY_SIZE = 1;
2191
+ const GEOMETRY_OFFSET = GEOMETRY_SIZE / 2;
2192
+ const geometry = new PlaneGeometry(GEOMETRY_SIZE, GEOMETRY_SIZE).translate(GEOMETRY_OFFSET, GEOMETRY_OFFSET, 0);
1829
2193
  let originalClearColor = new Color();
1830
2194
  let originalClearAlpha = 0;
1831
2195
  let originalAutoClear = false;
@@ -1835,70 +2199,111 @@ let originalAutoClearStencil = false;
1835
2199
  class UISceneWrapper {
1836
2200
  constructor(w, h) {
1837
2201
  this._private_scene = new Scene();
1838
- this._private_elements = new Map();
1839
- this._private_camera = new OrthographicCamera(0, w, h, 0, -1, 1);
2202
+ this._private_descriptors = new Map();
2203
+ this._private_lastPlaneIndex = 0;
2204
+ this._private_camera = new OrthographicCamera(0, w, h, 0, -Z_LIMIT, Z_LIMIT);
1840
2205
  }
1841
- insertObject(element, object) {
1842
- if (this._private_elements.has(element)) {
1843
- throw new Error("Element already exists");
1844
- }
1845
- this._private_elements.set(element, object);
1846
- this._private_scene.add(object);
1847
- }
1848
- replaceObject(element, object) {
1849
- const oldObject = this._private_elements.get(element);
1850
- if (oldObject === undefined) {
1851
- throw new Error("Element not found");
1852
- }
1853
- this._private_scene.remove(oldObject);
1854
- this._private_scene.add(object);
1855
- this._private_elements.set(element, object);
2206
+ createPlane(source, uniforms) {
2207
+ const entries = Object.entries(uniforms);
2208
+ const material = new ShaderMaterial({
2209
+ uniforms: {
2210
+ alphaTest: { value: DEFAULT_ALPHA_TEST },
2211
+ ...Object.fromEntries(entries.map(([k, v]) => [
2212
+ k,
2213
+ {
2214
+ value: v instanceof UIColor ? new Vector4(v.r, v.g, v.b, v.a) : v,
2215
+ },
2216
+ ])),
2217
+ },
2218
+ vertexShader,
2219
+ fragmentShader: fragmentShader +
2220
+ entries.map(([k, v]) => buildUniformDeclaraction(k, v)).join("\n") +
2221
+ source,
2222
+ transparent: false,
2223
+ alphaTest: DEFAULT_ALPHA_TEST,
2224
+ alphaHash: false,
2225
+ lights: false,
2226
+ fog: false,
2227
+ depthWrite: false,
2228
+ depthTest: true,
2229
+ });
2230
+ const plane = new Mesh(geometry, material);
2231
+ plane.frustumCulled = false;
2232
+ plane.matrixAutoUpdate = false;
2233
+ this._private_scene.add(plane);
2234
+ const index = this._private_lastPlaneIndex++;
2235
+ this._private_descriptors.set(index, { plane, material });
2236
+ return index;
1856
2237
  }
1857
- removeObject(element) {
1858
- const object = this._private_elements.get(element);
1859
- if (object === undefined) {
1860
- throw new Error("Element not found");
1861
- }
1862
- this._private_scene.remove(object);
1863
- this._private_elements.delete(element);
2238
+ destroyPlane(handler) {
2239
+ const descriptor = this._private_resolveDescriptor(handler);
2240
+ this._private_scene.remove(descriptor.plane);
2241
+ this._private_descriptors.delete(handler);
2242
+ return this;
1864
2243
  }
1865
- resize(w, h) {
1866
- this._private_camera.right = w;
1867
- this._private_camera.top = h;
1868
- this._private_camera.updateProjectionMatrix();
2244
+ setTransform(handler, value) {
2245
+ const descriptor = this._private_resolveDescriptor(handler);
2246
+ descriptor.plane.matrix.copy(value);
2247
+ descriptor.plane.matrixWorldNeedsUpdate = true;
2248
+ return this;
1869
2249
  }
1870
- getVisibility(element) {
1871
- const object = this._private_elements.get(element);
1872
- if (object === undefined) {
1873
- throw new Error("Element not found");
2250
+ setUniform(handler, uniform, value) {
2251
+ const descriptor = this._private_resolveDescriptor(handler);
2252
+ if (!(uniform in descriptor.material.uniforms)) {
2253
+ throw new Error(`Uniform ${uniform} not found in material`);
1874
2254
  }
1875
- return object.visible;
1876
- }
1877
- getZIndex(element) {
1878
- const object = this._private_elements.get(element);
1879
- if (object === undefined) {
1880
- throw new Error("Element not found");
2255
+ if (value instanceof UIColor) {
2256
+ descriptor.material.uniforms[uniform].value.set(value.r, value.g, value.b, value.a);
1881
2257
  }
1882
- return object.renderOrder;
1883
- }
1884
- setZIndex(element, zIndex) {
1885
- const object = this._private_elements.get(element);
1886
- if (object === undefined) {
1887
- throw new Error("Element not found");
2258
+ else {
2259
+ descriptor.material.uniforms[uniform].value = value;
1888
2260
  }
1889
- object.renderOrder = zIndex;
2261
+ return this;
1890
2262
  }
1891
- setVisibility(element, visible) {
1892
- const object = this._private_elements.get(element);
1893
- if (object === undefined) {
1894
- throw new Error("Element not found");
2263
+ setTransparency(handler, mode) {
2264
+ const descriptor = this._private_resolveDescriptor(handler);
2265
+ if (mode === UITransparencyMode.BLEND) {
2266
+ descriptor.material.transparent = true;
2267
+ descriptor.material.alphaTest = 0;
2268
+ descriptor.material.uniforms["alphaTest"].value = 0;
2269
+ descriptor.material.alphaHash = false;
2270
+ }
2271
+ else if (mode === UITransparencyMode.CLIP) {
2272
+ descriptor.material.transparent = false;
2273
+ descriptor.material.alphaTest = DEFAULT_ALPHA_TEST;
2274
+ descriptor.material.uniforms["alphaTest"].value = DEFAULT_ALPHA_TEST;
2275
+ descriptor.material.alphaHash = false;
2276
+ }
2277
+ else {
2278
+ descriptor.material.transparent = false;
2279
+ descriptor.material.alphaTest = 0;
2280
+ descriptor.material.uniforms["alphaTest"].value = 0;
2281
+ descriptor.material.alphaHash = true;
1895
2282
  }
1896
- object.visible = visible;
2283
+ descriptor.material.uniformsNeedUpdate = true;
2284
+ descriptor.material.needsUpdate = true;
2285
+ return this;
2286
+ }
2287
+ setVisibility(handler, visible) {
2288
+ const descriptor = this._private_resolveDescriptor(handler);
2289
+ descriptor.plane.visible = visible;
2290
+ return this;
2291
+ }
2292
+ insertCustomObject(object) {
2293
+ this._private_scene.add(object);
2294
+ return this;
2295
+ }
2296
+ removeCustomObject(object) {
2297
+ this._private_scene.remove(object);
2298
+ return this;
1897
2299
  }
1898
- getSortedVisibleElements() {
1899
- return Array.from(this._private_elements.keys()).sort((a, b) => this.getZIndex(a) - this.getZIndex(b));
2300
+ resize(width, height) {
2301
+ this._private_camera.right = width;
2302
+ this._private_camera.top = height;
2303
+ this._private_camera.updateProjectionMatrix();
2304
+ return this;
1900
2305
  }
1901
- prepareRender(renderer) {
2306
+ render(renderer) {
1902
2307
  originalClearColor = renderer.getClearColor(originalClearColor);
1903
2308
  originalClearAlpha = renderer.getClearAlpha();
1904
2309
  originalAutoClear = renderer.autoClear;
@@ -1910,34 +2315,6 @@ class UISceneWrapper {
1910
2315
  renderer.autoClearDepth = false;
1911
2316
  renderer.autoClearStencil = false;
1912
2317
  renderer.setClearColor(0x000000, 1);
1913
- for (const [element, object] of this._private_elements) {
1914
- const micro = element.micro;
1915
- const width = element.width * micro.scaleX;
1916
- const height = element.height * micro.scaleY;
1917
- const anchorOffsetX = micro.anchorX * width;
1918
- const anchorOffsetY = micro.anchorY * height;
1919
- const cos = Math.cos(micro.rotation);
1920
- const sin = Math.sin(micro.rotation);
1921
- const rotatedAnchorX = anchorOffsetX * cos - anchorOffsetY * sin;
1922
- const rotatedAnchorY = anchorOffsetX * sin + anchorOffsetY * cos;
1923
- if (micro.anchorMode === UIAnchorMode.POSITION_ROTATION_SCALE) {
1924
- object.position.x = element.x + micro.x - rotatedAnchorX;
1925
- object.position.y = element.y + micro.y - rotatedAnchorY;
1926
- }
1927
- else {
1928
- const rawAnchorOffsetX = micro.anchorX * element.width;
1929
- const rawAnchorOffsetY = micro.anchorY * element.height;
1930
- object.position.x =
1931
- element.x + rawAnchorOffsetX - rotatedAnchorX + micro.x;
1932
- object.position.y =
1933
- element.y + rawAnchorOffsetY - rotatedAnchorY + micro.y;
1934
- }
1935
- object.scale.x = width;
1936
- object.scale.y = height;
1937
- object.rotation.z = micro.rotation;
1938
- }
1939
- }
1940
- render(renderer) {
1941
2318
  renderer.clear(false, true, true);
1942
2319
  renderer.render(this._private_scene, this._private_camera);
1943
2320
  renderer.setClearColor(originalClearColor);
@@ -1946,6 +2323,14 @@ class UISceneWrapper {
1946
2323
  renderer.autoClearColor = originalAutoClearColor;
1947
2324
  renderer.autoClearDepth = originalAutoClearDepth;
1948
2325
  renderer.autoClearStencil = originalAutoClearStencil;
2326
+ return this;
2327
+ }
2328
+ _private_resolveDescriptor(handler) {
2329
+ const descriptor = this._private_descriptors.get(handler);
2330
+ if (!descriptor) {
2331
+ throw new Error(`No descriptor found for handler ${handler}`);
2332
+ }
2333
+ return descriptor;
1949
2334
  }
1950
2335
  }
1951
2336
 
@@ -2006,15 +2391,52 @@ function resolveRelation(relation) {
2006
2391
  return relation ?? UIRelation.EQUAL;
2007
2392
  }
2008
2393
 
2394
+ /**
2395
+ * Wrapper around the Kiwi constraint solver providing enhanced UI-specific functionality.
2396
+ *
2397
+ * UISolverWrapper abstracts the Kiwi (Cassowary) constraint solver to provide a more
2398
+ * UI-friendly interface with additional features like dynamic constraint modification,
2399
+ * required variables (P0 priority), partial constraint updates, and automatic solver
2400
+ * recovery. It manages variables and constraints through index-based references,
2401
+ * allowing for easy tracking and modification of layout constraints.
2402
+ *
2403
+ * Key features:
2404
+ * - Index-based variable and constraint management
2405
+ * - Required variables with P0 priority (always satisfied)
2406
+ * - Dynamic constraint modification without full rebuilds
2407
+ * - Automatic solver recovery on constraint conflicts
2408
+ * - Lazy evaluation with recalculation flags
2409
+ *
2410
+ * @see {@link UIExpression} - Expression system for constraint definitions
2411
+ * @see {@link UIPriority} - Priority levels for variables and constraints
2412
+ * @see {@link UIRelation} - Relational operators for constraints
2413
+ */
2009
2414
  class UISolverWrapper {
2010
2415
  constructor() {
2416
+ /** The underlying Kiwi solver instance, undefined when solver needs rebuilding. */
2011
2417
  this._private_solver = new Solver();
2418
+ /** Flag indicating whether variable values need recalculation. */
2012
2419
  this._private_recalculationRequired = false;
2420
+ /** Map of variable indices to their descriptions. */
2013
2421
  this._private_variables = new Map();
2422
+ /** Counter for generating unique variable indices. */
2014
2423
  this._private_lastVariableIndex = 0;
2424
+ /** Map of constraint indices to their descriptions. */
2015
2425
  this._private_constraints = new Map();
2426
+ /** Counter for generating unique constraint indices. */
2016
2427
  this._private_lastConstraintIndex = 0;
2017
2428
  }
2429
+ /**
2430
+ * Creates a new solver variable with the specified value and priority.
2431
+ *
2432
+ * Variables with P0 priority are treated as required (must be satisfied exactly)
2433
+ * and are implemented using equality constraints. Other priorities use edit
2434
+ * variables that can be adjusted by the solver.
2435
+ *
2436
+ * @param value - Initial value for the variable
2437
+ * @param priority - Priority level for constraint solving
2438
+ * @returns Unique index identifier for the created variable
2439
+ */
2018
2440
  createVariable(value, priority) {
2019
2441
  const index = this._private_lastVariableIndex++;
2020
2442
  const variable = new Variable();
@@ -2042,6 +2464,15 @@ class UISolverWrapper {
2042
2464
  this._private_recalculationRequired = true;
2043
2465
  return index;
2044
2466
  }
2467
+ /**
2468
+ * Removes a variable from the solver system.
2469
+ *
2470
+ * The variable must not be referenced by any existing constraints.
2471
+ * Cleans up both the variable itself and any associated required constraint.
2472
+ *
2473
+ * @param index - Index of the variable to remove
2474
+ * @throws Will throw an error if the variable doesn't exist or is still in use
2475
+ */
2045
2476
  removeVariable(index) {
2046
2477
  const description = this._private_variables.get(index);
2047
2478
  if (description === undefined) {
@@ -2063,6 +2494,17 @@ class UISolverWrapper {
2063
2494
  this._private_variables.delete(index);
2064
2495
  this._private_recalculationRequired = true;
2065
2496
  }
2497
+ /**
2498
+ * Suggests a new value for an existing variable.
2499
+ *
2500
+ * For P0 priority variables, rebuilds the associated constraint.
2501
+ * For other priorities, suggests the value to the solver's edit system.
2502
+ * Only triggers updates if the value actually changes.
2503
+ *
2504
+ * @param index - Index of the variable to update
2505
+ * @param value - New suggested value
2506
+ * @throws Will throw an error if the variable doesn't exist
2507
+ */
2066
2508
  suggestVariableValue(index, value) {
2067
2509
  const description = this._private_variables.get(index);
2068
2510
  if (description === undefined) {
@@ -2079,6 +2521,17 @@ class UISolverWrapper {
2079
2521
  this._private_recalculationRequired = true;
2080
2522
  }
2081
2523
  }
2524
+ /**
2525
+ * Changes the priority of an existing variable.
2526
+ *
2527
+ * Switching to/from P0 priority changes how the variable is handled:
2528
+ * - P0: Creates required constraint (must be satisfied exactly)
2529
+ * - Other: Uses edit variable system (can be adjusted by solver)
2530
+ *
2531
+ * @param index - Index of the variable to modify
2532
+ * @param priority - New priority level
2533
+ * @throws Will throw an error if the variable doesn't exist
2534
+ */
2082
2535
  setVariablePriority(index, priority) {
2083
2536
  const description = this._private_variables.get(index);
2084
2537
  if (description === undefined) {
@@ -2112,6 +2565,16 @@ class UISolverWrapper {
2112
2565
  this._private_recalculationRequired = true;
2113
2566
  }
2114
2567
  }
2568
+ /**
2569
+ * Reads the current solved value of a variable.
2570
+ *
2571
+ * Triggers solver recalculation if needed and rebuilds the solver
2572
+ * if it was invalidated due to constraint conflicts.
2573
+ *
2574
+ * @param index - Index of the variable to read
2575
+ * @returns Current solved value of the variable
2576
+ * @throws Will throw an error if the variable doesn't exist
2577
+ */
2115
2578
  readVariableValue(index) {
2116
2579
  const description = this._private_variables.get(index);
2117
2580
  if (description === undefined) {
@@ -2126,6 +2589,19 @@ class UISolverWrapper {
2126
2589
  }
2127
2590
  return description.variable.value();
2128
2591
  }
2592
+ /**
2593
+ * Creates a new constraint between two expressions.
2594
+ *
2595
+ * Constraints can be enabled or disabled, and all properties can be
2596
+ * modified later without recreating the constraint.
2597
+ *
2598
+ * @param lhs - Left-hand side expression
2599
+ * @param rhs - Right-hand side expression
2600
+ * @param relation - Relational operator (equal, less than, greater than)
2601
+ * @param priority - Priority level for constraint solving
2602
+ * @param enabled - Whether the constraint is initially active
2603
+ * @returns Unique index identifier for the created constraint
2604
+ */
2129
2605
  createConstraint(lhs, rhs, relation, priority, enabled) {
2130
2606
  const index = this._private_lastConstraintIndex++;
2131
2607
  const constraint = this._private_buildConstraint(lhs, rhs, relation, priority);
@@ -2148,6 +2624,15 @@ class UISolverWrapper {
2148
2624
  }
2149
2625
  return index;
2150
2626
  }
2627
+ /**
2628
+ * Removes a constraint from the solver system.
2629
+ *
2630
+ * If the constraint is currently enabled, it will be removed from
2631
+ * the active solver before deletion.
2632
+ *
2633
+ * @param index - Index of the constraint to remove
2634
+ * @throws Will throw an error if the constraint doesn't exist
2635
+ */
2151
2636
  removeConstraint(index) {
2152
2637
  const description = this._private_constraints.get(index);
2153
2638
  if (description === undefined) {
@@ -2164,6 +2649,16 @@ class UISolverWrapper {
2164
2649
  this._private_constraints.delete(index);
2165
2650
  this._private_recalculationRequired = true;
2166
2651
  }
2652
+ /**
2653
+ * Updates the left-hand side expression of an existing constraint.
2654
+ *
2655
+ * Rebuilds the underlying constraint with the new expression while
2656
+ * preserving all other properties.
2657
+ *
2658
+ * @param index - Index of the constraint to modify
2659
+ * @param lhs - New left-hand side expression
2660
+ * @throws Will throw an error if the constraint doesn't exist
2661
+ */
2167
2662
  setConstraintLHS(index, lhs) {
2168
2663
  const description = this._private_constraints.get(index);
2169
2664
  if (description === undefined) {
@@ -2173,6 +2668,16 @@ class UISolverWrapper {
2173
2668
  this._private_rebuildConstraintByDescription(description);
2174
2669
  this._private_recalculationRequired = true;
2175
2670
  }
2671
+ /**
2672
+ * Updates the right-hand side expression of an existing constraint.
2673
+ *
2674
+ * Rebuilds the underlying constraint with the new expression while
2675
+ * preserving all other properties.
2676
+ *
2677
+ * @param index - Index of the constraint to modify
2678
+ * @param rhs - New right-hand side expression
2679
+ * @throws Will throw an error if the constraint doesn't exist
2680
+ */
2176
2681
  setConstraintRHS(index, rhs) {
2177
2682
  const description = this._private_constraints.get(index);
2178
2683
  if (description === undefined) {
@@ -2182,24 +2687,58 @@ class UISolverWrapper {
2182
2687
  this._private_rebuildConstraintByDescription(description);
2183
2688
  this._private_recalculationRequired = true;
2184
2689
  }
2690
+ /**
2691
+ * Updates the relational operator of an existing constraint.
2692
+ *
2693
+ * Changes how the left and right expressions are compared
2694
+ * (equal, less than, greater than).
2695
+ *
2696
+ * @param index - Index of the constraint to modify
2697
+ * @param relation - New relational operator
2698
+ * @throws Will throw an error if the constraint doesn't exist
2699
+ */
2185
2700
  setConstraintRelation(index, relation) {
2186
2701
  const description = this._private_constraints.get(index);
2187
2702
  if (description === undefined) {
2188
2703
  throw new Error(`Constraint ${index} does not exist`);
2189
2704
  }
2190
- description.relation = relation;
2191
- this._private_rebuildConstraintByDescription(description);
2192
- this._private_recalculationRequired = true;
2705
+ if (description.relation !== relation) {
2706
+ description.relation = relation;
2707
+ this._private_rebuildConstraintByDescription(description);
2708
+ this._private_recalculationRequired = true;
2709
+ }
2193
2710
  }
2711
+ /**
2712
+ * Updates the priority level of an existing constraint.
2713
+ *
2714
+ * Higher priority constraints are more likely to be satisfied
2715
+ * when conflicts arise.
2716
+ *
2717
+ * @param index - Index of the constraint to modify
2718
+ * @param priority - New priority level
2719
+ * @throws Will throw an error if the constraint doesn't exist
2720
+ */
2194
2721
  setConstraintPriority(index, priority) {
2195
2722
  const description = this._private_constraints.get(index);
2196
2723
  if (description === undefined) {
2197
2724
  throw new Error(`Constraint ${index} does not exist`);
2198
2725
  }
2199
- description.priority = priority;
2200
- this._private_rebuildConstraintByDescription(description);
2201
- this._private_recalculationRequired = true;
2726
+ if (description.priority !== priority) {
2727
+ description.priority = priority;
2728
+ this._private_rebuildConstraintByDescription(description);
2729
+ this._private_recalculationRequired = true;
2730
+ }
2202
2731
  }
2732
+ /**
2733
+ * Enables or disables an existing constraint.
2734
+ *
2735
+ * Disabled constraints are not considered during solving but
2736
+ * remain in the system for potential re-enabling.
2737
+ *
2738
+ * @param index - Index of the constraint to modify
2739
+ * @param enabled - Whether the constraint should be active
2740
+ * @throws Will throw an error if the constraint doesn't exist
2741
+ */
2203
2742
  setConstraintEnabled(index, enabled) {
2204
2743
  const description = this._private_constraints.get(index);
2205
2744
  if (description === undefined) {
@@ -2218,6 +2757,13 @@ class UISolverWrapper {
2218
2757
  this._private_recalculationRequired = true;
2219
2758
  }
2220
2759
  }
2760
+ /**
2761
+ * Rebuilds a variable in the solver system with new properties.
2762
+ *
2763
+ * Temporarily removes all constraints that reference the variable,
2764
+ * updates the variable configuration, then rebuilds and re-adds
2765
+ * the dependent constraints.
2766
+ */
2221
2767
  _private_rebuildVariable(index, description) {
2222
2768
  const dependConstraints = [];
2223
2769
  for (const cDescription of this._private_constraints.values()) {
@@ -2246,11 +2792,22 @@ class UISolverWrapper {
2246
2792
  }
2247
2793
  }
2248
2794
  }
2795
+ /**
2796
+ * Rebuilds a constraint based on its current description.
2797
+ *
2798
+ * Uses different rebuild strategies depending on whether the
2799
+ * constraint is currently enabled.
2800
+ */
2249
2801
  _private_rebuildConstraintByDescription(description) {
2250
2802
  description.constraint = description.enabled
2251
2803
  ? this._private_rebuildConstraint(description.constraint, description.lhs, description.rhs, description.relation, description.priority)
2252
2804
  : this._private_buildConstraint(description.lhs, description.rhs, description.relation, description.priority);
2253
2805
  }
2806
+ /**
2807
+ * Rebuilds a constraint by removing the old one and creating a new one.
2808
+ *
2809
+ * Safely handles solver state transitions and constraint replacement.
2810
+ */
2254
2811
  _private_rebuildConstraint(oldConstraint, lhs, rhs, relation, priority) {
2255
2812
  try {
2256
2813
  this._private_solver?.removeConstraint(oldConstraint);
@@ -2267,9 +2824,20 @@ class UISolverWrapper {
2267
2824
  }
2268
2825
  return constraint;
2269
2826
  }
2827
+ /**
2828
+ * Creates a new Kiwi constraint from UI expressions and parameters.
2829
+ *
2830
+ * Converts UI-level expressions and enums to Kiwi-compatible formats.
2831
+ */
2270
2832
  _private_buildConstraint(lhs, rhs, relation, priority) {
2271
2833
  return new Constraint(this._private_convertExpression(lhs), convertRelation(relation), this._private_convertExpression(rhs), convertPriority(priority));
2272
2834
  }
2835
+ /**
2836
+ * Converts a UIExpression to a Kiwi Expression.
2837
+ *
2838
+ * Maps variable indices to their corresponding Kiwi Variable instances
2839
+ * and preserves coefficients and constants.
2840
+ */
2273
2841
  _private_convertExpression(expression) {
2274
2842
  return new Expression(...expression["prepareTermsInternal"]().map(([variableIndex, coefficient]) => {
2275
2843
  const description = this._private_variables.get(variableIndex);
@@ -2279,6 +2847,12 @@ class UISolverWrapper {
2279
2847
  return [coefficient, description.variable];
2280
2848
  }), expression.constant);
2281
2849
  }
2850
+ /**
2851
+ * Completely rebuilds the solver from scratch.
2852
+ *
2853
+ * Re-adds all variables and constraints to a fresh solver instance.
2854
+ * Used for recovery when the solver enters an invalid state.
2855
+ */
2282
2856
  _private_rebuildSolver() {
2283
2857
  if (this._private_solver) {
2284
2858
  throw new Error("Solver already exists");
@@ -2352,6 +2926,8 @@ class UILayer extends i {
2352
2926
  this.solverWrapper = new UISolverWrapper();
2353
2927
  /** Internal storage for the current visibility/interaction mode. */
2354
2928
  this.modeInternal = UIMode.VISIBLE;
2929
+ /** Collection of input listeners for handling user interactions, sorted by z-index. */
2930
+ this._private_inputListeners = [];
2355
2931
  this.sceneWrapper = new UISceneWrapper(w, h);
2356
2932
  this.xVariable = this.solverWrapper.createVariable(0, UIPriority.P0);
2357
2933
  this.yVariable = this.solverWrapper.createVariable(0, UIPriority.P0);
@@ -2360,6 +2936,20 @@ class UILayer extends i {
2360
2936
  this.orientationInternal =
2361
2937
  w > h ? UIOrientation.HORIZONTAL : UIOrientation.VERTICAL;
2362
2938
  }
2939
+ /**
2940
+ * Gets the current x position value from the constraint solver.
2941
+ * @returns The current x position in pixels
2942
+ */
2943
+ get x() {
2944
+ return this.solverWrapper.readVariableValue(this.xVariable);
2945
+ }
2946
+ /**
2947
+ * Gets the current y position value from the constraint solver.
2948
+ * @returns The current y position in pixels
2949
+ */
2950
+ get y() {
2951
+ return this.solverWrapper.readVariableValue(this.yVariable);
2952
+ }
2363
2953
  /**
2364
2954
  * Gets the current width value from the constraint solver.
2365
2955
  * @returns The current layer width in pixels
@@ -2390,6 +2980,18 @@ class UILayer extends i {
2390
2980
  get orientation() {
2391
2981
  return this.orientationInternal;
2392
2982
  }
2983
+ // public set x(value: number) {
2984
+ // throw new Error("You cannot set the x position of a UI layer.");
2985
+ // }
2986
+ // public set y(value: number) {
2987
+ // throw new Error("You cannot set the y position of a UI layer.");
2988
+ // }
2989
+ // public set width(value: number) {
2990
+ // throw new Error("You cannot set the width of a UI layer.");
2991
+ // }
2992
+ // public set height(value: number) {
2993
+ // throw new Error("You cannot set the height of a UI layer.");
2994
+ // }
2393
2995
  /**
2394
2996
  * Sets the visibility and interaction mode and emits change event.
2395
2997
  * @param value - The new UIMode setting
@@ -2435,7 +3037,6 @@ class UILayer extends i {
2435
3037
  */
2436
3038
  renderInternal(renderer, deltaTime) {
2437
3039
  if (this.mode !== UIMode.HIDDEN) {
2438
- this.sceneWrapper.prepareRender(renderer);
2439
3040
  this.emit(UILayerEvent.WILL_RENDER, renderer, deltaTime, this);
2440
3041
  this.sceneWrapper.render(renderer);
2441
3042
  }
@@ -2451,10 +3052,11 @@ class UILayer extends i {
2451
3052
  * @param y - The y-coordinate of the click
2452
3053
  * @protected
2453
3054
  */
2454
- clickInternal(x, y) {
3055
+ pointerClickInternal(x, y) {
2455
3056
  if (this.mode === UIMode.INTERACTIVE) {
2456
- for (const element of this.sceneWrapper.getSortedVisibleElements()) {
2457
- if (element["onClickInternal"](x, y)) {
3057
+ this._private_inputListeners.sort((a, b) => b.zIndex - a.zIndex);
3058
+ for (const listener of this._private_inputListeners) {
3059
+ if (listener.listener.catchClick(x, y)) {
2458
3060
  return;
2459
3061
  }
2460
3062
  }
@@ -2479,9 +3081,58 @@ class UILayer extends i {
2479
3081
  *
2480
3082
  * @returns The scene wrapper instance
2481
3083
  */
2482
- ["getSceneWrapperInternal"]() {
3084
+ ["getSceneWrapperClientAPI"]() {
2483
3085
  return this.sceneWrapper;
2484
3086
  }
3087
+ /**
3088
+ * Internal method for registering an input listener for pointer events.
3089
+ *
3090
+ * Adds a listener to handle click events with the specified z-index priority.
3091
+ * Higher z-index listeners are processed first during event handling.
3092
+ *
3093
+ * @param listener - The input listener to register
3094
+ * @param zIndex - The z-index priority for event handling order
3095
+ * @throws Will throw an error if the listener is already registered
3096
+ */
3097
+ ["listenPointerInput"](listener, zIndex) {
3098
+ if (this._private_inputListeners.find((l) => l.listener === listener)) {
3099
+ throw new Error("Listener already exists");
3100
+ }
3101
+ this._private_inputListeners.push({ zIndex, listener });
3102
+ }
3103
+ /**
3104
+ * Internal method for updating the z-index of an existing input listener.
3105
+ *
3106
+ * Changes the priority order for event handling of an already registered listener.
3107
+ * The listener must already exist in the system.
3108
+ *
3109
+ * @param listener - The input listener to update
3110
+ * @param zIndex - The new z-index priority
3111
+ * @throws Will throw an error if the listener is not found
3112
+ */
3113
+ ["setListenerZIndex"](listener, zIndex) {
3114
+ const index = this._private_inputListeners.findIndex((l) => l.listener === listener);
3115
+ if (index === -1) {
3116
+ throw new Error("Listener not found");
3117
+ }
3118
+ this._private_inputListeners[index].zIndex = zIndex;
3119
+ }
3120
+ /**
3121
+ * Internal method for unregistering an input listener.
3122
+ *
3123
+ * Removes the specified listener from the event handling system.
3124
+ * The listener will no longer receive click events.
3125
+ *
3126
+ * @param listener - The input listener to remove
3127
+ * @throws Will throw an error if the listener is not found
3128
+ */
3129
+ ["unlistenPointerInput"](listener) {
3130
+ const index = this._private_inputListeners.findIndex((l) => l.listener === listener);
3131
+ if (index === -1) {
3132
+ throw new Error("Listener not found");
3133
+ }
3134
+ this._private_inputListeners.splice(index, 1);
3135
+ }
2485
3136
  }
2486
3137
 
2487
3138
  /**
@@ -2499,6 +3150,9 @@ class UIConstraint {
2499
3150
  /**
2500
3151
  * Creates a new UIConstraint instance.
2501
3152
  *
3153
+ * Automatically connects to the layer's constraint solver for managing
3154
+ * layout relationships and constraint operations.
3155
+ *
2502
3156
  * @param layer - The UI layer that contains this constraint
2503
3157
  */
2504
3158
  constructor(layer) {
@@ -2541,8 +3195,6 @@ class UISingleParameterConstraint extends UIConstraint {
2541
3195
  *
2542
3196
  * Updates the constraint's enabled state in the solver based on the
2543
3197
  * current orientation and the constraint's orientation setting.
2544
- *
2545
- * @private
2546
3198
  */
2547
3199
  this._private_onOrientationChange = () => {
2548
3200
  this.solverWrapper.setConstraintEnabled(this.constraint, this.isConstraintEnabled());
@@ -2917,7 +3569,6 @@ class UIHorizontalDistanceConstraint extends UISingleParameterConstraint {
2917
3569
  * For plane elements, the anchor determines the reference point within the element's width.
2918
3570
  *
2919
3571
  * @returns The UIExpression representing the horizontal distance calculation
2920
- * @private
2921
3572
  */
2922
3573
  _private_buildLHS() {
2923
3574
  let aExpression;
@@ -2988,7 +3639,7 @@ class UIHorizontalProportionConstraint extends UISingleParameterConstraint {
2988
3639
  }
2989
3640
  /**
2990
3641
  * Gets the current proportion value being enforced.
2991
- * @returns The proportion ratio (elementA.width = elementB.width * proportion)
3642
+ * @returns The proportion ratio (elementA.width * proportion = elementB.width)
2992
3643
  */
2993
3644
  get proportion() {
2994
3645
  return this._private_proportionInternal;
@@ -3010,7 +3661,6 @@ class UIHorizontalProportionConstraint extends UISingleParameterConstraint {
3010
3661
  * This enforces the relationship: elementA.width * proportion = elementB.width
3011
3662
  *
3012
3663
  * @returns The UIExpression representing the proportional width relationship
3013
- * @private
3014
3664
  */
3015
3665
  _private_buildRHS() {
3016
3666
  return UIExpression.minus(new UIExpression(0, [[this._private_a.wVariable, this._private_proportionInternal]]), new UIExpression(0, [[this._private_b.wVariable, 1]]));
@@ -3114,7 +3764,6 @@ class UIVerticalDistanceConstraint extends UISingleParameterConstraint {
3114
3764
  * For plane elements, the anchor determines the reference point within the element's height.
3115
3765
  *
3116
3766
  * @returns The UIExpression representing the vertical distance calculation
3117
- * @private
3118
3767
  */
3119
3768
  _private_buildLHS() {
3120
3769
  let aExpression;
@@ -3185,7 +3834,7 @@ class UIVerticalProportionConstraint extends UISingleParameterConstraint {
3185
3834
  }
3186
3835
  /**
3187
3836
  * Gets the current proportion value being enforced.
3188
- * @returns The proportion ratio (elementA.height = elementB.height * proportion)
3837
+ * @returns The proportion ratio (elementA.height * proportion = elementB.height)
3189
3838
  */
3190
3839
  get proportion() {
3191
3840
  return this._private_proportionInternal;
@@ -3207,7 +3856,6 @@ class UIVerticalProportionConstraint extends UISingleParameterConstraint {
3207
3856
  * This enforces the relationship: elementA.height * proportion = elementB.height
3208
3857
  *
3209
3858
  * @returns The UIExpression representing the proportional height relationship
3210
- * @private
3211
3859
  */
3212
3860
  _private_buildRHS() {
3213
3861
  return UIExpression.minus(new UIExpression(0, [[this._private_a.hVariable, this._private_proportionInternal]]), new UIExpression(0, [[this._private_b.hVariable, 1]]));
@@ -3420,7 +4068,6 @@ class UIAspectConstraint extends UISingleParameterConstraint {
3420
4068
  * This enforces the relationship: width = height * aspect
3421
4069
  *
3422
4070
  * @returns The UIExpression representing the constraint equation
3423
- * @private
3424
4071
  */
3425
4072
  _private_buildLHS() {
3426
4073
  return new UIExpression(0, [
@@ -3442,6 +4089,8 @@ const DEFAULT_ANCHOR$2 = 0.5;
3442
4089
  * - Positioned at the specified anchor point within the passive element
3443
4090
  * - Sized to be at least as large as the passive element in both dimensions
3444
4091
  * - Scaled proportionally to maintain aspect ratio (if enabled)
4092
+ *
4093
+ * The constraints ensure: passive.dimension * 1 ≤ active.dimension (active covers passive)
3445
4094
  */
3446
4095
  class UICoverConstraintBuilder {
3447
4096
  /**
@@ -3501,6 +4150,8 @@ const DEFAULT_ANCHOR$1 = 0.5;
3501
4150
  * - Positioned at the specified anchor point within the passive element
3502
4151
  * - Sized to fit entirely within the passive element in both dimensions
3503
4152
  * - Scaled proportionally to maintain aspect ratio (if enabled)
4153
+ *
4154
+ * The constraints ensure: passive.dimension * 1 ≥ active.dimension (active fits within passive)
3504
4155
  */
3505
4156
  class UIFitConstraintBuilder {
3506
4157
  /**
@@ -3720,12 +4371,16 @@ class UIDummy extends UIAnchor {
3720
4371
  * @throws Will throw an error if width or height are not valid positive numbers
3721
4372
  * @see {@link assertValidPositiveNumber}
3722
4373
  */
3723
- constructor(layer, x, y, width = DEFAULT_SIZE, height = DEFAULT_SIZE) {
3724
- assertValidPositiveNumber(width, "UIDummy width");
3725
- assertValidPositiveNumber(height, "UIDummy height");
4374
+ constructor(layer, options = {}) {
4375
+ const x = options.x ?? 0;
4376
+ const y = options.y ?? 0;
4377
+ const w = options.width ?? DEFAULT_SIZE;
4378
+ const h = options.height ?? DEFAULT_SIZE;
4379
+ assertValidPositiveNumber(w, "UIDummy width");
4380
+ assertValidPositiveNumber(h, "UIDummy height");
3726
4381
  super(layer, x, y);
3727
- this.wVariable = this.solverWrapper.createVariable(width, UIPriority.P6);
3728
- this.hVariable = this.solverWrapper.createVariable(height, UIPriority.P6);
4382
+ this.wVariable = this.solverWrapper.createVariable(w, UIPriority.P6);
4383
+ this.hVariable = this.solverWrapper.createVariable(h, UIPriority.P6);
3729
4384
  }
3730
4385
  /**
3731
4386
  * Gets the current width value from the solver.
@@ -3776,6 +4431,26 @@ class UIDummy extends UIAnchor {
3776
4431
  }
3777
4432
  }
3778
4433
 
4434
+ /**
4435
+ * Events that can be emitted by UI elements.
4436
+ */
4437
+ var UIInputEvent;
4438
+ (function (UIInputEvent) {
4439
+ /** Emitted when the element is clicked. */
4440
+ UIInputEvent["CLICK"] = "click";
4441
+ })(UIInputEvent || (UIInputEvent = {}));
4442
+
4443
+ /**
4444
+ * Defines the anchor mode for UIMicro, determining which transformations are applied around the anchor point.
4445
+ */
4446
+ var UIMicroAnchorMode;
4447
+ (function (UIMicroAnchorMode) {
4448
+ /** Rotation and scaling are applied around the anchor point */
4449
+ UIMicroAnchorMode[UIMicroAnchorMode["ROTATION_SCALE"] = 0] = "ROTATION_SCALE";
4450
+ /** Position, rotation, and scaling transformations are all applied around the anchor point */
4451
+ UIMicroAnchorMode[UIMicroAnchorMode["POSITION_ROTATION_SCALE"] = 1] = "POSITION_ROTATION_SCALE";
4452
+ })(UIMicroAnchorMode || (UIMicroAnchorMode = {}));
4453
+
3779
4454
  /** Default position value for x and y coordinates. */
3780
4455
  const DEFAULT_POSITION = 0;
3781
4456
  /** Default anchor point value for anchorX and anchorY. */
@@ -3815,7 +4490,7 @@ class UIMicro {
3815
4490
  /** Internal storage for rotation in radians. */
3816
4491
  this._private_rotationInternal = DEFAULT_ROTATION;
3817
4492
  /** Internal storage for anchor mode determining which transformations are applied around the anchor point. */
3818
- this._private_anchorModeInternal = UIAnchorMode.ROTATION_SCALE;
4493
+ this._private_anchorModeInternal = UIMicroAnchorMode.ROTATION_SCALE;
3819
4494
  /** Flag indicating if any transformation properties have changed. */
3820
4495
  this._private_recalculationRequired = false;
3821
4496
  }
@@ -4041,27 +4716,35 @@ class UIMicro {
4041
4716
  }
4042
4717
  }
4043
4718
 
4719
+ const position = new Vector3();
4720
+ const quaternion = new Quaternion();
4721
+ const scale = new Vector3();
4722
+ const matrix = new Matrix4();
4723
+ const axis = new Vector3(0, 0, 1);
4044
4724
  /**
4045
- * Events that can be emitted by UI elements.
4725
+ * Checks if a point (x, y) is within the bounds of a UI element.
4726
+ * @param x - The x coordinate to test
4727
+ * @param y - The y coordinate to test
4728
+ * @param element - The UI element to test against
4729
+ * @returns True if the point is within the element's bounds
4046
4730
  */
4047
- var UIElementEvent;
4048
- (function (UIElementEvent) {
4049
- /** Emitted when the element is clicked. */
4050
- UIElementEvent["CLICK"] = "click";
4051
- })(UIElementEvent || (UIElementEvent = {}));
4731
+ function isElementClicked(x, y, element) {
4732
+ return (x > element.x &&
4733
+ x < element.x + element.width &&
4734
+ y > element.y &&
4735
+ y < element.y + element.height);
4736
+ }
4052
4737
  /**
4053
4738
  * Abstract base class for all renderable UI elements with dimensions.
4054
4739
  *
4055
4740
  * UIElement serves as the fundamental building block for all other UI elements
4056
4741
  * that need to be visually rendered. It extends UIAnchor with dimensional properties
4057
- * and integrates with the Three.js rendering system through Object3D. This class
4742
+ * and integrates with the Three.js rendering system through shader-based planes. This class
4058
4743
  * provides essential functionality for positioning, sizing, rendering, visibility,
4059
4744
  * z-index management, and user interaction.
4060
4745
  *
4061
- * @template T - The type of Three.js Object3D used for rendering
4062
4746
  * @see {@link UIAnchor} - Base class providing position functionality
4063
4747
  * @see {@link UIPlaneElement} - Interface defining dimensional element behavior
4064
- * @see {@link UISceneWrapper} - Scene management for rendering
4065
4748
  * @see {@link UIMicro} - Micro-optimization utilities
4066
4749
  */
4067
4750
  class UIElement extends UIAnchor {
@@ -4073,23 +4756,41 @@ class UIElement extends UIAnchor {
4073
4756
  * @param y - Initial y-coordinate position
4074
4757
  * @param width - Initial width dimension (must be positive)
4075
4758
  * @param height - Initial height dimension (must be positive)
4076
- * @param object - The Three.js Object3D used for rendering this element
4759
+ * @param source - GLSL shader source code for rendering this element
4760
+ * @param uniforms - Uniform values to pass to the shader
4077
4761
  * @throws Will throw an error if width or height are not valid positive numbers
4078
4762
  * @see {@link assertValidPositiveNumber}
4079
4763
  */
4080
- constructor(layer, x, y, width, height, object) {
4764
+ constructor(layer, x, y, width, height, source, uniforms) {
4081
4765
  assertValidPositiveNumber(width, "UIElement width");
4082
4766
  assertValidPositiveNumber(height, "UIElement height");
4083
4767
  super(layer, x, y);
4084
- this.object = object;
4085
4768
  /** Micro-transformation system for non-constraint based positioning, scaling, and rotation adjustments. */
4086
4769
  this.micro = new UIMicro();
4087
4770
  /** Internal storage for the current visibility/interaction mode. */
4088
4771
  this.modeInternal = UIMode.VISIBLE;
4089
- this.sceneWrapper = this.layer["getSceneWrapperInternal"]();
4090
- this.sceneWrapper.insertObject(this, this.object);
4772
+ /** Internal storage for the transparency rendering mode. */
4773
+ this.transparencyInternal = UITransparencyMode.CLIP;
4774
+ /** Internal storage for the z-index (depth) value. */
4775
+ this.zIndexInternal = 0;
4776
+ /**
4777
+ * Handles click events when the element is in interactive mode.
4778
+ * @param x - The x coordinate of the click
4779
+ * @param y - The y coordinate of the click
4780
+ * @returns True if the click was within this element's bounds
4781
+ */
4782
+ this.onClick = (x, y) => {
4783
+ const clicked = isElementClicked(x, y, this);
4784
+ if (clicked) {
4785
+ this.emit(UIInputEvent.CLICK, x, y, this);
4786
+ }
4787
+ return clicked;
4788
+ };
4789
+ this.layer.on(UILayerEvent.WILL_RENDER, this.onWillRender, this);
4091
4790
  this.wVariable = this.solverWrapper.createVariable(width, UIPriority.P6);
4092
4791
  this.hVariable = this.solverWrapper.createVariable(height, UIPriority.P6);
4792
+ this.sceneWrapper = layer["getSceneWrapperClientAPI"]();
4793
+ this.planeHandler = this.sceneWrapper.createPlane(source, uniforms);
4093
4794
  }
4094
4795
  /**
4095
4796
  * Gets the current width value from the solver.
@@ -4106,11 +4807,11 @@ class UIElement extends UIAnchor {
4106
4807
  return this.solverWrapper.readVariableValue(this.hVariable);
4107
4808
  }
4108
4809
  /**
4109
- * Gets the current z-index (depth) value from the scene.
4110
- * @returns The current z-index for rendering order
4810
+ * Gets the current z-index (depth) value.
4811
+ * @returns The current z-index value
4111
4812
  */
4112
4813
  get zIndex() {
4113
- return this.sceneWrapper.getZIndex(this);
4814
+ return this.zIndexInternal;
4114
4815
  }
4115
4816
  /**
4116
4817
  * Gets the current visibility and interaction mode.
@@ -4120,6 +4821,14 @@ class UIElement extends UIAnchor {
4120
4821
  get mode() {
4121
4822
  return this.modeInternal;
4122
4823
  }
4824
+ /**
4825
+ * Gets the current transparency rendering mode.
4826
+ * @returns The current transparency mode
4827
+ * @see {@link UITransparencyMode}
4828
+ */
4829
+ get transparency() {
4830
+ return this.transparencyInternal;
4831
+ }
4123
4832
  /**
4124
4833
  * Sets the width value through the solver system.
4125
4834
  * @param value - The new width dimension (must be positive)
@@ -4141,139 +4850,115 @@ class UIElement extends UIAnchor {
4141
4850
  this.solverWrapper.suggestVariableValue(this.hVariable, value);
4142
4851
  }
4143
4852
  /**
4144
- * Sets the z-index (depth) value for rendering order.
4853
+ * Sets the z-index (depth) value for rendering order and input handling.
4145
4854
  * @param value - The new z-index value
4146
4855
  * @throws Will throw an error if value is not a valid number
4147
4856
  * @see {@link assertValidNumber}
4148
4857
  */
4149
4858
  set zIndex(value) {
4150
4859
  assertValidNumber(value, "UIElement zIndex");
4151
- this.sceneWrapper.setZIndex(this, value);
4860
+ this.zIndexInternal = value;
4861
+ if (this.listener) {
4862
+ this.layer["setListenerZIndex"](this.listener, value);
4863
+ }
4152
4864
  }
4153
4865
  /**
4154
- * Sets the visibility and interaction mode.
4866
+ * Sets the current visibility and interaction mode.
4155
4867
  * @param value - The new UIMode setting
4156
4868
  * @see {@link UIMode}
4157
4869
  */
4158
4870
  set mode(value) {
4159
- if (value !== this.modeInternal) {
4871
+ if (this.modeInternal !== value) {
4872
+ if (value === UIMode.INTERACTIVE) {
4873
+ this.listener = { catchClick: this.onClick };
4874
+ this.layer["listenPointerInput"](this.listener, this.zIndexInternal);
4875
+ }
4876
+ else if (this.modeInternal === UIMode.INTERACTIVE && this.listener) {
4877
+ this.layer["unlistenPointerInput"](this.listener);
4878
+ this.listener = undefined;
4879
+ }
4160
4880
  this.modeInternal = value;
4161
- this.sceneWrapper.setVisibility(this, value !== UIMode.HIDDEN);
4881
+ this.sceneWrapper.setVisibility(this.planeHandler, value !== UIMode.HIDDEN);
4162
4882
  }
4163
4883
  }
4884
+ /**
4885
+ * Sets the transparency rendering mode.
4886
+ * @param value - The new transparency mode
4887
+ * @see {@link UITransparencyMode}
4888
+ */
4889
+ set transparency(value) {
4890
+ this.transparencyInternal = value;
4891
+ this.sceneWrapper.setTransparency(this.planeHandler, value);
4892
+ }
4164
4893
  /**
4165
4894
  * Destroys the UI element by cleaning up all associated resources.
4166
4895
  *
4167
4896
  * This method removes the element from the rendering scene, cleans up
4168
- * dimension solver variables, and calls the parent destroy method to
4169
- * clean up position variables. After calling this method, the element
4170
- * should not be used anymore.
4897
+ * dimension solver variables, removes input listeners, and calls the parent
4898
+ * destroy method to clean up position variables. After calling this method,
4899
+ * the element should not be used anymore.
4171
4900
  */
4172
4901
  destroy() {
4902
+ this.layer.off(UILayerEvent.WILL_RENDER, this.onWillRender, this);
4903
+ if (this.listener) {
4904
+ this.layer["unlistenPointerInput"](this.listener);
4905
+ }
4173
4906
  this.solverWrapper.removeVariable(this.hVariable);
4174
4907
  this.solverWrapper.removeVariable(this.wVariable);
4175
- this.sceneWrapper.removeObject(this);
4908
+ this.sceneWrapper.destroyPlane(this.planeHandler);
4176
4909
  super.destroy();
4177
4910
  }
4178
4911
  /**
4179
- * Internal method for handling click events.
4180
- *
4181
- * Determines if the click coordinates intersect with this element's bounds
4182
- * and emits a CLICK event if the element is in interactive mode.
4183
- *
4184
- * @param x - The x-coordinate of the click
4185
- * @param y - The y-coordinate of the click
4186
- * @returns True if the click was handled by this element
4187
- */
4188
- ["onClickInternal"](x, y) {
4189
- const isClicked = this.modeInternal === UIMode.INTERACTIVE &&
4190
- x > this.x &&
4191
- x < this.x + this.width &&
4192
- y > this.y &&
4193
- y < this.y + this.height;
4194
- if (isClicked) {
4195
- this.emit(UIElementEvent.CLICK, x, y, this);
4912
+ * Called before each render frame to update the element's transform matrix.
4913
+ * Applies micro-transformations (position, rotation, scale, anchor) and updates
4914
+ * the rendering system with the final transformation matrix.
4915
+ * @param renderer - The WebGL renderer (unused in base implementation)
4916
+ * @param deltaTime - Time since last frame in seconds (unused in base implementation)
4917
+ */
4918
+ onWillRender(
4919
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars -- Required by UILayer event interface but not used in base implementation
4920
+ renderer,
4921
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars -- Required by UILayer event interface but not used in base implementation
4922
+ deltaTime) {
4923
+ const micro = this.micro;
4924
+ const width = this.width * micro.scaleX;
4925
+ const height = this.height * micro.scaleY;
4926
+ const anchorOffsetX = micro.anchorX * width;
4927
+ const anchorOffsetY = micro.anchorY * height;
4928
+ const cos = Math.cos(micro.rotation);
4929
+ const sin = Math.sin(micro.rotation);
4930
+ const rotatedAnchorX = anchorOffsetX * cos - anchorOffsetY * sin;
4931
+ const rotatedAnchorY = anchorOffsetX * sin + anchorOffsetY * cos;
4932
+ if (micro.anchorMode === UIMicroAnchorMode.POSITION_ROTATION_SCALE) {
4933
+ position.x = this.x + micro.x - rotatedAnchorX;
4934
+ position.y = this.y + micro.y - rotatedAnchorY;
4196
4935
  }
4197
- return isClicked;
4198
- }
4199
- }
4200
-
4201
- var fragmentShader$2 = "uniform sampler2D map;\nuniform float opacity;\nuniform vec3 color;\nuniform float alphaTest;\nvarying vec2 vUv;\n\nvoid main() {\n vec4 diffuseColor = texture2D(map, vUv);\n #include <alphatest_fragment>\n gl_FragColor = vec4(diffuseColor.rgb * color, diffuseColor.a * opacity);\n #include <colorspace_fragment>\n}\n";
4202
-
4203
- var vertexShader$2 = "varying vec2 vUv;\nvoid main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n";
4204
-
4205
- const DEFAULT_ALPHA_TEST$2 = 0.25;
4206
- class UIMaterial extends ShaderMaterial {
4207
- constructor(map) {
4208
- super({
4209
- uniforms: {
4210
- map: { value: map },
4211
- opacity: { value: 1.0 },
4212
- color: { value: new Color(1.0, 1.0, 1.0) },
4213
- alphaTest: { value: DEFAULT_ALPHA_TEST$2 },
4214
- },
4215
- vertexShader: vertexShader$2,
4216
- fragmentShader: fragmentShader$2,
4217
- transparent: false,
4218
- alphaTest: DEFAULT_ALPHA_TEST$2,
4219
- lights: false,
4220
- fog: false,
4221
- depthWrite: false,
4222
- depthTest: false,
4223
- });
4224
- }
4225
- getTexture() {
4226
- return this.uniforms.map.value;
4227
- }
4228
- getColor() {
4229
- return this.uniforms.color.value.getHex();
4230
- }
4231
- getOpacity() {
4232
- return this.uniforms.opacity.value;
4233
- }
4234
- getTransparency() {
4235
- return this.transparent;
4236
- }
4237
- setTexture(value) {
4238
- this.uniforms.map.value = value;
4239
- this.uniformsNeedUpdate = true;
4240
- return this;
4241
- }
4242
- setColor(value) {
4243
- this.uniforms.color.value.setHex(value);
4244
- this.uniformsNeedUpdate = true;
4245
- return this;
4246
- }
4247
- setOpacity(value) {
4248
- this.uniforms.opacity.value = value;
4249
- this.uniformsNeedUpdate = true;
4250
- return this;
4251
- }
4252
- setTransparency(value) {
4253
- if (this.transparent !== value) {
4254
- this.transparent = value;
4255
- this.uniforms.alphaTest.value = !value ? DEFAULT_ALPHA_TEST$2 : 0;
4256
- this.needsUpdate = true;
4257
- this.uniformsNeedUpdate = true;
4258
- }
4259
- return this;
4936
+ else {
4937
+ const rawAnchorOffsetX = micro.anchorX * this.width;
4938
+ const rawAnchorOffsetY = micro.anchorY * this.height;
4939
+ position.x = this.x + rawAnchorOffsetX - rotatedAnchorX + micro.x;
4940
+ position.y = this.y + rawAnchorOffsetY - rotatedAnchorY + micro.y;
4941
+ }
4942
+ position.z = this.zIndexInternal;
4943
+ scale.x = width;
4944
+ scale.y = height;
4945
+ quaternion.setFromAxisAngle(axis, micro.rotation);
4946
+ matrix.compose(position, quaternion, scale);
4947
+ this.sceneWrapper.setTransform(this.planeHandler, matrix);
4260
4948
  }
4261
4949
  }
4262
4950
 
4263
- const GEOMETRY_SIZE = 1;
4264
- const GEOMETRY_OFFSET = GEOMETRY_SIZE / 2;
4265
- const geometry = new PlaneGeometry(GEOMETRY_SIZE, GEOMETRY_SIZE).translate(GEOMETRY_OFFSET, GEOMETRY_OFFSET, 0);
4951
+ var source$2 = "void main() {\n vec4 diffuseColor = texture(map, io_UV) * color;\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n gl_FragColor = diffuseColor;\n #include <colorspace_fragment>\n}\n";
4266
4952
 
4267
4953
  /**
4268
4954
  * UI element for displaying textured images.
4269
4955
  *
4270
4956
  * UIImage is a concrete implementation of UIElement that renders a textured
4271
- * image using Three.js Mesh and UIMaterial. It automatically sizes itself
4957
+ * image using shader-based planes. It automatically sizes itself
4272
4958
  * to match the texture dimensions and provides control over visual properties
4273
- * such as color tinting, opacity, and transparency.
4959
+ * such as color tinting.
4274
4960
  *
4275
4961
  * @see {@link UIElement} - Base class providing UI element functionality
4276
- * @see {@link UIMaterial} - Material system for rendering
4277
4962
  * @see {@link Texture} - Three.js texture for image data
4278
4963
  */
4279
4964
  class UIImage extends UIElement {
@@ -4281,21 +4966,28 @@ class UIImage extends UIElement {
4281
4966
  * Creates a new UIImage instance.
4282
4967
  *
4283
4968
  * The image will automatically size itself to match the texture's dimensions.
4284
- * The position defaults to (0, 0) if not specified.
4969
+ * All options have default values if not specified.
4285
4970
  *
4286
4971
  * @param layer - The UI layer that contains this image
4287
4972
  * @param texture - The Three.js texture to display
4288
- * @param x - Initial x-coordinate position (defaults to 0)
4289
- * @param y - Initial y-coordinate position (defaults to 0)
4973
+ * @param options - Configuration options for the image
4974
+ * @throws Will throw an error if the texture dimensions are not valid positive numbers
4290
4975
  */
4291
- constructor(layer, texture, x = 0, y = 0) {
4292
- const width = texture.image.width;
4293
- const height = texture.image.height;
4294
- const material = new UIMaterial(texture);
4295
- const object = new Mesh(geometry, material);
4296
- super(layer, x, y, width, height, object);
4297
- this._private_material = material;
4976
+ constructor(layer, texture, options = {}) {
4977
+ const w = texture.image.width;
4978
+ const h = texture.image.height;
4979
+ const color = options.color ?? new UIColor();
4980
+ super(layer, options.x ?? 0, options.y ?? 0, w, h, source$2, {
4981
+ map: texture,
4982
+ color,
4983
+ });
4984
+ /** Event handler for when the color changes */
4985
+ this._private_onColorChange = (color) => {
4986
+ this.sceneWrapper.setUniform(this.planeHandler, "color", color);
4987
+ };
4298
4988
  this._private_textureInternal = texture;
4989
+ this._private_colorInternal = color;
4990
+ this._private_colorInternal.on(UIColorEvent.CHANGE, this._private_onColorChange);
4299
4991
  }
4300
4992
  /**
4301
4993
  * Gets the current texture being displayed.
@@ -4306,24 +4998,10 @@ class UIImage extends UIElement {
4306
4998
  }
4307
4999
  /**
4308
5000
  * Gets the current color tint applied to the image.
4309
- * @returns The color value as a number (e.g., 0xFFFFFF for white)
5001
+ * @returns The UIColor instance
4310
5002
  */
4311
5003
  get color() {
4312
- return this._private_material.getColor();
4313
- }
4314
- /**
4315
- * Gets the current opacity level of the image.
4316
- * @returns The opacity value between 0.0 (transparent) and 1.0 (opaque)
4317
- */
4318
- get opacity() {
4319
- return this._private_material.getOpacity();
4320
- }
4321
- /**
4322
- * Gets whether transparency is enabled for the image.
4323
- * @returns True if transparency is enabled, false otherwise
4324
- */
4325
- get transparency() {
4326
- return this._private_material.getTransparency();
5004
+ return this._private_colorInternal;
4327
5005
  }
4328
5006
  /**
4329
5007
  * Sets a new texture for the image.
@@ -4336,163 +5014,31 @@ class UIImage extends UIElement {
4336
5014
  * @see {@link assertValidPositiveNumber}
4337
5015
  */
4338
5016
  set texture(value) {
4339
- const width = value.image.width;
4340
- const height = value.image.height;
4341
- assertValidPositiveNumber(width, "UIImage texture width");
4342
- assertValidPositiveNumber(height, "UIImage texture height");
4343
- this._private_material.setTexture(value);
4344
- this.solverWrapper.suggestVariableValue(this.wVariable, width);
4345
- this.solverWrapper.suggestVariableValue(this.hVariable, height);
5017
+ const w = value.image.width;
5018
+ const h = value.image.height;
5019
+ assertValidPositiveNumber(w, "UIImage texture width");
5020
+ assertValidPositiveNumber(h, "UIImage texture height");
5021
+ this.solverWrapper.suggestVariableValue(this.wVariable, w);
5022
+ this.solverWrapper.suggestVariableValue(this.hVariable, h);
5023
+ this._private_textureInternal = value;
5024
+ this.sceneWrapper.setUniform(this.planeHandler, "map", value);
4346
5025
  }
4347
5026
  /**
4348
5027
  * Sets the color tint applied to the image.
4349
- * @param value - The color value as a number (e.g., 0xFFFFFF for white)
5028
+ * @param value - The UIColor instance
4350
5029
  */
4351
5030
  set color(value) {
4352
- this._private_material.setColor(value);
5031
+ this._private_colorInternal.copy(value);
4353
5032
  }
4354
5033
  /**
4355
- * Sets the opacity level of the image.
4356
- * @param value - The opacity value between 0.0 (transparent) and 1.0 (opaque)
4357
- */
4358
- set opacity(value) {
4359
- this._private_material.setOpacity(value);
4360
- }
4361
- /**
4362
- * Sets whether transparency is enabled for the image.
4363
- * @param value - True to enable transparency, false to disable
4364
- */
4365
- set transparency(value) {
4366
- this._private_material.setTransparency(value);
4367
- }
4368
- /**
4369
- * Destroys the image by cleaning up all associated resources.
4370
- *
4371
- * This method disposes of the material resources and calls the parent
4372
- * destroy method to clean up the underlying UI element. After calling
4373
- * this method, the image should not be used anymore.
5034
+ * Destroys the UI image by cleaning up color event listeners and all associated resources.
4374
5035
  */
4375
5036
  destroy() {
4376
- this._private_material.dispose();
5037
+ this._private_colorInternal.off(UIColorEvent.CHANGE, this._private_onColorChange);
4377
5038
  super.destroy();
4378
5039
  }
4379
5040
  }
4380
5041
 
4381
- var fragmentShader$1 = "uniform sampler2D map;\nuniform vec3 color;\nuniform float opacity;\nuniform float alphaTest;\nuniform vec4 sliceBorders;\nuniform vec2 quadSize;\nuniform vec2 textureSize;\nvarying vec2 vUv;\n\nvec2 calculateNineSliceUV(vec2 uv) {\n vec2 localUV = uv;\n\n float left = sliceBorders.x;\n float right = sliceBorders.y;\n float top = sliceBorders.z;\n float bottom = sliceBorders.w;\n\n float leftPx = left * textureSize.x;\n float rightPx = right * textureSize.x;\n float topPx = top * textureSize.y;\n float bottomPx = bottom * textureSize.y;\n\n float lB = leftPx / quadSize.x;\n float rB = 1.0 - (rightPx / quadSize.x);\n float tB = topPx / quadSize.y;\n float bB = 1.0 - (bottomPx / quadSize.y);\n\n {\n float regionL = step(uv.x, lB);\n float regionR = step(rB, uv.x);\n float regionM = 1.0 - regionL - regionR;\n\n float xL = uv.x * (left / lB);\n float xR = 1.0 - right + ((uv.x - rB) / (1.0 - rB)) * right;\n float xM = left + ((uv.x - lB) / (rB - lB)) * (1.0 - left - right);\n\n localUV.x = regionL * xL + regionM * xM + regionR * xR;\n }\n\n {\n float regionT = step(uv.y, tB);\n float regionB = step(bB, uv.y);\n float regionC = 1.0 - regionT - regionB;\n\n float yT = uv.y * (top / tB);\n float yB = 1.0 - bottom + ((uv.y - bB) / (1.0 - bB)) * bottom;\n float yC = top + ((uv.y - tB) / (bB - tB)) * (1.0 - top - bottom);\n\n localUV.y = regionT * yT + regionC * yC + regionB * yB;\n }\n\n return localUV;\n}\n\nvoid main() {\n vec4 textureColor = texture2D(map, calculateNineSliceUV(vUv));\n if (textureColor.a < alphaTest) {\n discard;\n }\n gl_FragColor = vec4(textureColor.rgb * color, textureColor.a * opacity);\n #include <colorspace_fragment>\n}\n";
4382
-
4383
- var vertexShader$1 = "varying vec2 vUv;\nvoid main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n";
4384
-
4385
- const DEFAULT_ALPHA_TEST$1 = 0.25;
4386
- class UINineSliceMaterial extends ShaderMaterial {
4387
- constructor(texture) {
4388
- super({
4389
- uniforms: {
4390
- map: { value: texture },
4391
- color: { value: new Color(0xffffff) },
4392
- opacity: { value: 1.0 },
4393
- alphaTest: { value: DEFAULT_ALPHA_TEST$1 },
4394
- sliceBorders: {
4395
- value: new Vector4(0, 0, 0, 0),
4396
- }, // left, right, top, bottom (in UV)
4397
- quadSize: { value: new Vector2(1, 1) }, // width, height (in World)
4398
- textureSize: {
4399
- value: new Vector2(texture.image.width, texture.image.height),
4400
- },
4401
- },
4402
- vertexShader: vertexShader$1,
4403
- fragmentShader: fragmentShader$1,
4404
- transparent: false,
4405
- alphaTest: DEFAULT_ALPHA_TEST$1,
4406
- lights: false,
4407
- fog: false,
4408
- depthWrite: false,
4409
- depthTest: false,
4410
- });
4411
- }
4412
- getSliceBorderLeft() {
4413
- return this.uniforms.sliceBorders.value.x;
4414
- }
4415
- getSliceBorderRight() {
4416
- return this.uniforms.sliceBorders.value.y;
4417
- }
4418
- getSliceBorderTop() {
4419
- return this.uniforms.sliceBorders.value.z;
4420
- }
4421
- getSliceBorderBottom() {
4422
- return this.uniforms.sliceBorders.value.w;
4423
- }
4424
- getQuadSize() {
4425
- const quadSize = this.uniforms.quadSize.value;
4426
- return { w: quadSize.x, h: quadSize.y };
4427
- }
4428
- getTexture() {
4429
- return this.uniforms.map.value;
4430
- }
4431
- getColor() {
4432
- return this.uniforms.color.value.getHex();
4433
- }
4434
- getOpacity() {
4435
- return this.uniforms.opacity.value;
4436
- }
4437
- getTransparency() {
4438
- return this.transparent;
4439
- }
4440
- setSliceBorderLeft(l) {
4441
- this.uniforms.sliceBorders.value.x = l;
4442
- this.uniformsNeedUpdate = true;
4443
- return this;
4444
- }
4445
- setSliceBorderRight(r) {
4446
- this.uniforms.sliceBorders.value.y = r;
4447
- this.uniformsNeedUpdate = true;
4448
- return this;
4449
- }
4450
- setSliceBorderTop(t) {
4451
- this.uniforms.sliceBorders.value.z = t;
4452
- this.uniformsNeedUpdate = true;
4453
- return this;
4454
- }
4455
- setSliceBorderBottom(b) {
4456
- this.uniforms.sliceBorders.value.w = b;
4457
- this.uniformsNeedUpdate = true;
4458
- return this;
4459
- }
4460
- setSliceBorder(l, r, t, b) {
4461
- this.uniforms.sliceBorders.value.set(l, r, t, b);
4462
- this.uniformsNeedUpdate = true;
4463
- return this;
4464
- }
4465
- setQuadSize(w, h) {
4466
- this.uniforms.quadSize.value.set(w, h);
4467
- this.uniformsNeedUpdate = true;
4468
- return this;
4469
- }
4470
- setTexture(value) {
4471
- this.uniforms.map.value = value;
4472
- this.uniformsNeedUpdate = true;
4473
- return this;
4474
- }
4475
- setColor(color) {
4476
- this.uniforms.color.value.setHex(color);
4477
- this.uniformsNeedUpdate = true;
4478
- return this;
4479
- }
4480
- setOpacity(opacity) {
4481
- this.uniforms.opacity.value = opacity;
4482
- this.uniformsNeedUpdate = true;
4483
- return this;
4484
- }
4485
- setTransparency(value) {
4486
- if (this.transparent !== value) {
4487
- this.transparent = value;
4488
- this.uniforms.alphaTest.value = !value ? DEFAULT_ALPHA_TEST$1 : 0;
4489
- this.needsUpdate = true;
4490
- this.uniformsNeedUpdate = true;
4491
- }
4492
- return this;
4493
- }
4494
- }
4495
-
4496
5042
  const DEFAULT_SLICE_BORDER = 0.25;
4497
5043
  /**
4498
5044
  * Resolves various nine-slice border inputs into a normalized border object.
@@ -4500,23 +5046,23 @@ const DEFAULT_SLICE_BORDER = 0.25;
4500
5046
  * @param value - The border value to resolve (can be number, partial object, or full object)
4501
5047
  * @returns Normalized border object with left, right, top, bottom properties
4502
5048
  */
4503
- function resolveNineSliceBorder(value) {
5049
+ function resolveNineSliceBorders(value) {
4504
5050
  // Handle null/undefined
4505
5051
  if (value === null || value === undefined) {
4506
5052
  return {
4507
- left: DEFAULT_SLICE_BORDER,
4508
- right: DEFAULT_SLICE_BORDER,
4509
- top: DEFAULT_SLICE_BORDER,
4510
- bottom: DEFAULT_SLICE_BORDER,
5053
+ l: DEFAULT_SLICE_BORDER,
5054
+ r: DEFAULT_SLICE_BORDER,
5055
+ t: DEFAULT_SLICE_BORDER,
5056
+ b: DEFAULT_SLICE_BORDER,
4511
5057
  };
4512
5058
  }
4513
5059
  // Handle number
4514
5060
  if (typeof value === "number") {
4515
5061
  return {
4516
- left: value,
4517
- right: value,
4518
- top: value,
4519
- bottom: value,
5062
+ l: value,
5063
+ r: value,
5064
+ t: value,
5065
+ b: value,
4520
5066
  };
4521
5067
  }
4522
5068
  // Handle object
@@ -4529,10 +5075,10 @@ function resolveNineSliceBorder(value) {
4529
5075
  : DEFAULT_SLICE_BORDER;
4530
5076
  const vertical = typeof obj.vertical === "number" ? obj.vertical : DEFAULT_SLICE_BORDER;
4531
5077
  return {
4532
- left: horizontal,
4533
- right: horizontal,
4534
- top: vertical,
4535
- bottom: vertical,
5078
+ l: horizontal,
5079
+ r: horizontal,
5080
+ t: vertical,
5081
+ b: vertical,
4536
5082
  };
4537
5083
  }
4538
5084
  // Handle { left, right, top, bottom } format
@@ -4540,17 +5086,19 @@ function resolveNineSliceBorder(value) {
4540
5086
  const right = typeof obj.right === "number" ? obj.right : DEFAULT_SLICE_BORDER;
4541
5087
  const top = typeof obj.top === "number" ? obj.top : DEFAULT_SLICE_BORDER;
4542
5088
  const bottom = typeof obj.bottom === "number" ? obj.bottom : DEFAULT_SLICE_BORDER;
4543
- return { left, right, top, bottom };
5089
+ return { l: left, r: right, t: top, b: bottom };
4544
5090
  }
4545
5091
  // Fallback to default
4546
5092
  return {
4547
- left: DEFAULT_SLICE_BORDER,
4548
- right: DEFAULT_SLICE_BORDER,
4549
- top: DEFAULT_SLICE_BORDER,
4550
- bottom: DEFAULT_SLICE_BORDER,
5093
+ l: DEFAULT_SLICE_BORDER,
5094
+ r: DEFAULT_SLICE_BORDER,
5095
+ t: DEFAULT_SLICE_BORDER,
5096
+ b: DEFAULT_SLICE_BORDER,
4551
5097
  };
4552
5098
  }
4553
5099
 
5100
+ var source$1 = "vec2 calculateNineSliceUV() {\n vec2 localUV = io_UV;\n\n float left = sliceBorders.x;\n float right = sliceBorders.y;\n float top = sliceBorders.z;\n float bottom = sliceBorders.w;\n\n float leftPx = left * dimensions.x;\n float rightPx = right * dimensions.x;\n float topPx = top * dimensions.y;\n float bottomPx = bottom * dimensions.y;\n\n float lB = leftPx / dimensions.z;\n float rB = 1.0 - (rightPx / dimensions.z);\n float tB = topPx / dimensions.w;\n float bB = 1.0 - (bottomPx / dimensions.w);\n\n {\n float regionL = step(io_UV.x, lB);\n float regionR = step(rB, io_UV.x);\n float regionM = 1.0 - regionL - regionR;\n\n float xL = io_UV.x * (left / lB);\n float xR = 1.0 - right + ((io_UV.x - rB) / (1.0 - rB)) * right;\n float xM = left + ((io_UV.x - lB) / (rB - lB)) * (1.0 - left - right);\n\n localUV.x = regionL * xL + regionM * xM + regionR * xR;\n }\n\n {\n float regionT = step(io_UV.y, tB);\n float regionB = step(bB, io_UV.y);\n float regionC = 1.0 - regionT - regionB;\n\n float yT = io_UV.y * (top / tB);\n float yB = 1.0 - bottom + ((io_UV.y - bB) / (1.0 - bB)) * bottom;\n float yC = top + ((io_UV.y - tB) / (bB - tB)) * (1.0 - top - bottom);\n\n localUV.y = regionT * yT + regionC * yC + regionB * yB;\n }\n\n return localUV;\n}\n\nvoid main() {\n vec4 diffuseColor = texture(map, calculateNineSliceUV()) * color;\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n gl_FragColor = diffuseColor;\n #include <colorspace_fragment>\n}\n";
5101
+
4554
5102
  /**
4555
5103
  * Nine-slice UI element for scalable images with preserved border regions.
4556
5104
  *
@@ -4563,56 +5111,36 @@ class UINineSlice extends UIElement {
4563
5111
  /**
4564
5112
  * Creates a new nine-slice UI element.
4565
5113
  *
5114
+ * The element initially sizes itself to match the texture's dimensions.
5115
+ * Border regions are defined by the slice borders configuration.
5116
+ *
4566
5117
  * @param layer - The UI layer to add this element to
4567
5118
  * @param texture - The texture to use for nine-slice rendering
4568
5119
  * @param options - Configuration options for the nine-slice element
5120
+ * @throws Will throw an error if the texture dimensions are not valid positive numbers
4569
5121
  */
4570
5122
  constructor(layer, texture, options = {}) {
4571
- const w = texture.image.width;
4572
- const h = texture.image.height;
4573
- const material = new UINineSliceMaterial(texture);
4574
- const object = new Mesh(geometry, material);
4575
- super(layer, options.x ?? 0, options.y ?? 0, w, h, object);
4576
- /**
4577
- * Internal render callback that updates the material's quad size.
4578
- * This ensures the nine-slice scaling works correctly with micro transformations.
4579
- */
4580
- this._private_onWillRenderInternal = () => {
4581
- this._private_material.setQuadSize(this.width * this.micro.scaleX, this.height * this.micro.scaleY);
5123
+ const width = texture.image.width;
5124
+ const height = texture.image.height;
5125
+ const color = options.color ?? new UIColor();
5126
+ const resolvedSliceBorders = resolveNineSliceBorders(options.sliceBorders);
5127
+ const sliceBorders = new Vector4(resolvedSliceBorders.l, resolvedSliceBorders.r, resolvedSliceBorders.t, resolvedSliceBorders.b);
5128
+ const dimensions = new Vector4(width, height, width, height);
5129
+ super(layer, options.x ?? 0, options.y ?? 0, width, height, source$1, {
5130
+ map: texture,
5131
+ color,
5132
+ sliceBorders,
5133
+ dimensions,
5134
+ });
5135
+ /** Event handler for when the color changes */
5136
+ this._private_onColorChange = (color) => {
5137
+ this.sceneWrapper.setUniform(this.planeHandler, "color", color);
4582
5138
  };
4583
- this.layer.on(UILayerEvent.WILL_RENDER, this._private_onWillRenderInternal);
4584
- this._private_material = material;
4585
5139
  this._private_textureInternal = texture;
4586
- const sliceBorder = resolveNineSliceBorder(options.sliceBorder);
4587
- this._private_material.setSliceBorder(sliceBorder.left, sliceBorder.right, sliceBorder.top, sliceBorder.bottom);
4588
- }
4589
- /**
4590
- * Gets the left border size for nine-slice scaling.
4591
- * @returns The left border size in texture UV coordinates
4592
- */
4593
- get sliceBorderLeft() {
4594
- return this._private_material.getSliceBorderLeft();
4595
- }
4596
- /**
4597
- * Gets the right border size for nine-slice scaling.
4598
- * @returns The right border size in texture UV coordinates
4599
- */
4600
- get sliceBorderRight() {
4601
- return this._private_material.getSliceBorderRight();
4602
- }
4603
- /**
4604
- * Gets the top border size for nine-slice scaling.
4605
- * @returns The top border size in texture UV coordinates
4606
- */
4607
- get sliceBorderTop() {
4608
- return this._private_material.getSliceBorderTop();
4609
- }
4610
- /**
4611
- * Gets the bottom border size for nine-slice scaling.
4612
- * @returns The bottom border size in texture UV coordinates
4613
- */
4614
- get sliceBorderBottom() {
4615
- return this._private_material.getSliceBorderBottom();
5140
+ this._private_colorInternal = color;
5141
+ this._private_sliceBordersInternal = sliceBorders;
5142
+ this._private_dimensions = dimensions;
5143
+ this._private_colorInternal.on(UIColorEvent.CHANGE, this._private_onColorChange);
4616
5144
  }
4617
5145
  /**
4618
5146
  * Gets the current texture being displayed.
@@ -4622,243 +5150,152 @@ class UINineSlice extends UIElement {
4622
5150
  return this._private_textureInternal;
4623
5151
  }
4624
5152
  /**
4625
- * Gets the current color tint applied to the image.
4626
- * @returns The color value as a number (e.g., 0xFFFFFF for white)
5153
+ * Gets the current color tint applied to the nine-slice element.
5154
+ * @returns The UIColor instance
4627
5155
  */
4628
5156
  get color() {
4629
- return this._private_material.getColor();
4630
- }
4631
- /**
4632
- * Gets the current opacity level of the image.
4633
- * @returns The opacity value between 0.0 (transparent) and 1.0 (opaque)
4634
- */
4635
- get opacity() {
4636
- return this._private_material.getOpacity();
5157
+ return this._private_colorInternal;
4637
5158
  }
4638
5159
  /**
4639
- * Gets whether transparency is enabled for the image.
4640
- * @returns True if transparency is enabled, false otherwise
4641
- */
4642
- get transparency() {
4643
- return this._private_material.getTransparency();
4644
- }
4645
- /**
4646
- * Sets the left border size for nine-slice scaling.
4647
- * @param value - The left border size in texture UV coordinates
5160
+ * Gets the left border size for nine-slice scaling.
5161
+ * @returns The left border size as a percentage (0-1) of texture width
4648
5162
  */
4649
- set sliceBorderLeft(value) {
4650
- this._private_material.setSliceBorderLeft(value);
5163
+ get sliceBorderLeft() {
5164
+ return this._private_sliceBordersInternal.x;
4651
5165
  }
4652
5166
  /**
4653
- * Sets the right border size for nine-slice scaling.
4654
- * @param value - The right border size in texture UV coordinates
5167
+ * Gets the right border size for nine-slice scaling.
5168
+ * @returns The right border size as a percentage (0-1) of texture width
4655
5169
  */
4656
- set sliceBorderRight(value) {
4657
- this._private_material.setSliceBorderRight(value);
5170
+ get sliceBorderRight() {
5171
+ return this._private_sliceBordersInternal.y;
4658
5172
  }
4659
5173
  /**
4660
- * Sets the top border size for nine-slice scaling.
4661
- * @param value - The top border size in texture UV coordinates
5174
+ * Gets the top border size for nine-slice scaling.
5175
+ * @returns The top border size as a percentage (0-1) of texture height
4662
5176
  */
4663
- set sliceBorderTop(value) {
4664
- this._private_material.setSliceBorderTop(value);
5177
+ get sliceBorderTop() {
5178
+ return this._private_sliceBordersInternal.z;
4665
5179
  }
4666
5180
  /**
4667
- * Sets the bottom border size for nine-slice scaling.
4668
- * @param value - The bottom border size in texture UV coordinates
5181
+ * Gets the bottom border size for nine-slice scaling.
5182
+ * @returns The bottom border size as a percentage (0-1) of texture height
4669
5183
  */
4670
- set sliceBorderBottom(value) {
4671
- this._private_material.setSliceBorderBottom(value);
5184
+ get sliceBorderBottom() {
5185
+ return this._private_sliceBordersInternal.w;
4672
5186
  }
4673
5187
  /**
4674
- * Sets a new texture for the image.
5188
+ * Sets a new texture for the nine-slice element.
4675
5189
  *
4676
- * When setting a new texture, the image will automatically resize to match
4677
- * the new texture's dimensions.
5190
+ * When setting a new texture, the element will update its internal dimensions
5191
+ * but maintain the current world size. The nine-slice borders remain unchanged.
4678
5192
  *
4679
5193
  * @param value - The new Three.js texture to display
4680
5194
  * @throws Will throw an error if the texture dimensions are not valid positive numbers
4681
5195
  * @see {@link assertValidPositiveNumber}
4682
5196
  */
4683
5197
  set texture(value) {
4684
- const width = value.image.width;
4685
- const height = value.image.height;
4686
- assertValidPositiveNumber(width, "UINineSlice texture width");
4687
- assertValidPositiveNumber(height, "UINineSlice texture height");
4688
- this._private_material.setTexture(value);
4689
- this.solverWrapper.suggestVariableValue(this.wVariable, width);
4690
- this.solverWrapper.suggestVariableValue(this.hVariable, height);
5198
+ const w = value.image.width;
5199
+ const h = value.image.height;
5200
+ assertValidPositiveNumber(w, "UINineSlice texture width");
5201
+ assertValidPositiveNumber(h, "UINineSlice texture height");
5202
+ this.solverWrapper.suggestVariableValue(this.wVariable, w);
5203
+ this.solverWrapper.suggestVariableValue(this.hVariable, h);
5204
+ this._private_dimensions.x = w;
5205
+ this._private_dimensions.y = h;
5206
+ this.sceneWrapper.setUniform(this.planeHandler, "dimensions", this._private_dimensions);
5207
+ this.sceneWrapper.setUniform(this.planeHandler, "map", value);
4691
5208
  }
4692
5209
  /**
4693
- * Sets the color tint applied to the image.
4694
- * @param value - The color value as a number (e.g., 0xFFFFFF for white)
5210
+ * Sets the color tint applied to the nine-slice element.
5211
+ * @param value - The UIColor instance
5212
+ */
5213
+ set color(value) {
5214
+ this._private_colorInternal.copy(value);
5215
+ }
5216
+ /**
5217
+ * Sets the left border size for nine-slice scaling.
5218
+ * @param value - The left border size as a percentage (0-1) of texture width
5219
+ */
5220
+ set sliceBorderLeft(value) {
5221
+ this._private_sliceBordersInternal.x = value;
5222
+ this.sceneWrapper.setUniform(this.planeHandler, "sliceBorders", this._private_sliceBordersInternal);
5223
+ }
5224
+ /**
5225
+ * Sets the right border size for nine-slice scaling.
5226
+ * @param value - The right border size as a percentage (0-1) of texture width
4695
5227
  */
4696
- set color(value) {
4697
- this._private_material.setColor(value);
5228
+ set sliceBorderRight(value) {
5229
+ this._private_sliceBordersInternal.y = value;
5230
+ this.sceneWrapper.setUniform(this.planeHandler, "sliceBorders", this._private_sliceBordersInternal);
4698
5231
  }
4699
5232
  /**
4700
- * Sets the opacity level of the image.
4701
- * @param value - The opacity value between 0.0 (transparent) and 1.0 (opaque)
5233
+ * Sets the top border size for nine-slice scaling.
5234
+ * @param value - The top border size as a percentage (0-1) of texture height
4702
5235
  */
4703
- set opacity(value) {
4704
- this._private_material.setOpacity(value);
5236
+ set sliceBorderTop(value) {
5237
+ this._private_sliceBordersInternal.z = value;
5238
+ this.sceneWrapper.setUniform(this.planeHandler, "sliceBorders", this._private_sliceBordersInternal);
4705
5239
  }
4706
5240
  /**
4707
- * Sets whether transparency is enabled for the image.
4708
- * @param value - True to enable transparency, false to disable
5241
+ * Sets the bottom border size for nine-slice scaling.
5242
+ * @param value - The bottom border size as a percentage (0-1) of texture height
4709
5243
  */
4710
- set transparency(value) {
4711
- this._private_material.setTransparency(value);
5244
+ set sliceBorderBottom(value) {
5245
+ this._private_sliceBordersInternal.w = value;
5246
+ this.sceneWrapper.setUniform(this.planeHandler, "sliceBorders", this._private_sliceBordersInternal);
4712
5247
  }
4713
5248
  /**
4714
5249
  * Sets all four border sizes for nine-slice scaling at once.
4715
5250
  *
4716
- * @param left - The left border size in texture UV coordinates
4717
- * @param right - The right border size in texture UV coordinates
4718
- * @param top - The top border size in texture UV coordinates
4719
- * @param bottom - The bottom border size in texture UV coordinates
5251
+ * @param left - The left border size as a percentage (0-1) of texture width
5252
+ * @param right - The right border size as a percentage (0-1) of texture width
5253
+ * @param top - The top border size as a percentage (0-1) of texture height
5254
+ * @param bottom - The bottom border size as a percentage (0-1) of texture height
4720
5255
  */
4721
5256
  setSliceBorders(left, right, top, bottom) {
4722
- this._private_material.setSliceBorder(left, right, top, bottom);
5257
+ this._private_sliceBordersInternal.set(left, right, top, bottom);
5258
+ this.sceneWrapper.setUniform(this.planeHandler, "sliceBorders", this._private_sliceBordersInternal);
4723
5259
  }
4724
5260
  /**
4725
- * Destroys the nine-slice element and cleans up resources.
4726
- *
4727
- * This method removes event listeners, disposes of the material,
4728
- * and calls the parent destroy method.
5261
+ * Destroys the nine-slice UI element by cleaning up color event listeners and all associated resources.
4729
5262
  */
4730
5263
  destroy() {
4731
- this.layer.off(UILayerEvent.WILL_RENDER, this._private_onWillRenderInternal);
4732
- this._private_material.dispose();
5264
+ this._private_colorInternal.off(UIColorEvent.CHANGE, this._private_onColorChange);
4733
5265
  super.destroy();
4734
5266
  }
4735
- }
4736
-
4737
- var fragmentShader = "uniform sampler2D background;\nuniform sampler2D foreground;\nuniform float progress;\nuniform vec3 color;\nuniform vec3 backgroundColor;\nuniform vec3 foregroundColor;\nuniform float opacity;\nuniform float backgroundOpacity;\nuniform float foregroundOpacity;\nuniform float alphaTest;\nuniform float angle;\nuniform float direction;\nvarying vec2 vUv;\n\nvoid main() {\n vec4 backgroundTexture = texture2D(background, vUv);\n vec4 foregroundTexture = texture2D(foreground, vUv);\n\n // Apply common color and opacity\n vec3 finalBackgroundColor = backgroundTexture.rgb * backgroundColor * color;\n vec3 finalForegroundColor = foregroundTexture.rgb * foregroundColor * color;\n float finalBackgroundOpacity = backgroundTexture.a * backgroundOpacity * opacity;\n float finalForegroundOpacity = foregroundTexture.a * foregroundOpacity * opacity;\n\n vec4 backgroundColor = vec4(finalBackgroundColor, finalBackgroundOpacity);\n vec4 foregroundColor = vec4(finalForegroundColor, finalForegroundOpacity);\n\n // Calculate progress threshold with angle and direction\n float adjustedX = mix(vUv.x, 1.0 - vUv.x, step(0.0, -direction));\n float tanAngle = tan(angle);\n float threshold = adjustedX - (vUv.y - 0.5) * tanAngle * sign(direction);\n float progressMask = step(threshold, progress);\n\n vec4 mixedColor = foregroundColor * progressMask\n + backgroundColor * (1.0 - foregroundColor.a * progressMask);\n\n if (mixedColor.a < alphaTest) {\n discard;\n }\n\n gl_FragColor = mixedColor;\n #include <colorspace_fragment>\n}\n";
4738
-
4739
- var vertexShader = "varying vec2 vUv;\nvoid main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n";
4740
-
4741
- const DEFAULT_ALPHA_TEST = 0.25;
4742
- class UIProgressMaterial extends ShaderMaterial {
4743
- constructor(foregroundTexture, backgroundTexture) {
4744
- super({
4745
- uniforms: UniformsUtils.merge([
4746
- {
4747
- background: { value: backgroundTexture },
4748
- foreground: { value: foregroundTexture },
4749
- progress: { value: 1 },
4750
- color: { value: new Color(1, 1, 1) },
4751
- backgroundColor: { value: new Color(1, 1, 1) },
4752
- foregroundColor: { value: new Color(1, 1, 1) },
4753
- opacity: { value: 1 },
4754
- backgroundOpacity: { value: 1 },
4755
- foregroundOpacity: { value: 1 },
4756
- alphaTest: { value: DEFAULT_ALPHA_TEST },
4757
- angle: { value: 0 },
4758
- direction: { value: 1 },
4759
- },
4760
- ]),
4761
- vertexShader,
4762
- fragmentShader,
4763
- transparent: false,
4764
- alphaTest: DEFAULT_ALPHA_TEST,
4765
- lights: false,
4766
- fog: false,
4767
- depthWrite: false,
4768
- depthTest: false,
4769
- });
4770
- }
4771
- getProgress() {
4772
- return this.uniforms.progress.value;
4773
- }
4774
- getBackgroundTexture() {
4775
- return this.uniforms.background.value;
4776
- }
4777
- getForegroundTexture() {
4778
- return this.uniforms.foreground.value;
4779
- }
4780
- getColor() {
4781
- return this.uniforms.color.value.getHex();
4782
- }
4783
- getBackgroundColor() {
4784
- return this.uniforms.backgroundColor.value.getHex();
4785
- }
4786
- getForegroundColor() {
4787
- return this.uniforms.foregroundColor.value.getHex();
4788
- }
4789
- getOpacity() {
4790
- return this.uniforms.opacity.value;
4791
- }
4792
- getBackgroundOpacity() {
4793
- return this.uniforms.backgroundOpacity.value;
4794
- }
4795
- getForegroundOpacity() {
4796
- return this.uniforms.foregroundOpacity.value;
4797
- }
4798
- getTransparency() {
4799
- return this.transparent;
4800
- }
4801
- getAngle() {
4802
- return this.uniforms.angle.value;
4803
- }
4804
- getIsForwardDirection() {
4805
- return this.uniforms.direction.value === 1;
4806
- }
4807
- setProgress(value) {
4808
- this.uniforms.progress.value = value;
4809
- this.uniformsNeedUpdate = true;
4810
- }
4811
- setBackgroundTexture(value) {
4812
- this.uniforms.background.value = value;
4813
- this.uniformsNeedUpdate = true;
4814
- }
4815
- setForegroundTexture(value) {
4816
- this.uniforms.foreground.value = value;
4817
- this.uniformsNeedUpdate = true;
4818
- }
4819
- setColor(value) {
4820
- this.uniforms.color.value.setHex(value);
4821
- this.uniformsNeedUpdate = true;
4822
- }
4823
- setBackgroundColor(value) {
4824
- this.uniforms.backgroundColor.value.setHex(value);
4825
- this.uniformsNeedUpdate = true;
4826
- }
4827
- setForegroundColor(value) {
4828
- this.uniforms.foregroundColor.value.setHex(value);
4829
- this.uniformsNeedUpdate = true;
4830
- }
4831
- setOpacity(value) {
4832
- this.uniforms.opacity.value = value;
4833
- this.uniformsNeedUpdate = true;
4834
- }
4835
- setBackgroundOpacity(value) {
4836
- this.uniforms.backgroundOpacity.value = value;
4837
- this.uniformsNeedUpdate = true;
4838
- }
4839
- setForegroundOpacity(value) {
4840
- this.uniforms.foregroundOpacity.value = value;
4841
- this.uniformsNeedUpdate = true;
4842
- }
4843
- setTransparency(value) {
4844
- if (this.transparent !== value) {
4845
- this.transparent = value;
4846
- this.uniforms.alphaTest.value = !value ? DEFAULT_ALPHA_TEST : 0;
4847
- this.needsUpdate = true;
4848
- this.uniformsNeedUpdate = true;
4849
- }
4850
- return this;
4851
- }
4852
- setAngle(value) {
4853
- this.uniforms.angle.value = value;
4854
- this.uniformsNeedUpdate = true;
4855
- }
4856
- setIsForwardDirection(value) {
4857
- this.uniforms.direction.value = value ? 1 : -1;
4858
- this.uniformsNeedUpdate = true;
5267
+ /**
5268
+ * Called before each render frame to update the element's dimensions for nine-slice scaling.
5269
+ * Updates the world dimensions (z, w components) based on current width, height, and micro scaling.
5270
+ * @param renderer - The WebGL renderer
5271
+ * @param deltaTime - Time since last frame in seconds
5272
+ */
5273
+ onWillRender(renderer, deltaTime) {
5274
+ super.onWillRender(renderer, deltaTime);
5275
+ this._private_dimensions.z = this.width * this.micro.scaleX;
5276
+ this._private_dimensions.w = this.height * this.micro.scaleY;
5277
+ this.sceneWrapper.setUniform(this.planeHandler, "dimensions", this._private_dimensions);
4859
5278
  }
4860
5279
  }
4861
5280
 
5281
+ var source = "void main() {\n vec4 foregroundDiffuseColor = texture(foregroundTexture, io_UV) * foregroundColor * color;\n vec4 backgroundDiffuseColor = texture(backgroundTexture, io_UV) * backgroundColor * color;\n\n float mask = calculateMask();\n vec4 diffuseColor = foregroundDiffuseColor * mask\n + backgroundDiffuseColor * (1.0 - foregroundDiffuseColor.a * mask);\n\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n gl_FragColor = diffuseColor;\n #include <colorspace_fragment>\n}\n";
5282
+
5283
+ const DEFAULT_TEXTURE = new Texture();
5284
+ /**
5285
+ * Predefined mask functions that control how the progress bar fills.
5286
+ * Each function defines a different fill pattern using GLSL shader code.
5287
+ */
5288
+ var UIProgressMaskFunction;
5289
+ (function (UIProgressMaskFunction) {
5290
+ /** Fill horizontally from left to right (or right to left if inverse) */
5291
+ UIProgressMaskFunction["HORIZONTAL"] = "float calculateMask() {\n return step((direction * io_UV.x + (1.0 - direction) * 0.5), progress);\n }";
5292
+ /** Fill vertically from bottom to top (or top to bottom if inverse) */
5293
+ UIProgressMaskFunction["VERTICAL"] = "float calculateMask() {\n return step((direction * io_UV.y + (1.0 - direction) * 0.5), progress);\n }";
5294
+ /** Fill diagonally from bottom-left to top-right */
5295
+ UIProgressMaskFunction["DIAGONAL"] = "float calculateMask() {\n float d = (io_UV.x + io_UV.y) * (0.1);\n return step((direction * d + (1.0 - direction) * 0.5), progress);\n }";
5296
+ /** Fill in a circular pattern around the center */
5297
+ UIProgressMaskFunction["CIRCLE"] = "float calculateMask() {\n vec2 p = io_UV - 0.5;\n float angle = atan(p.y, p.x);\n angle = (angle + 3.14159265) / 3.14159265;\n angle *= 0.5;\n return step((direction * angle + (1.0 - direction) * 0.5), progress);\n }";
5298
+ })(UIProgressMaskFunction || (UIProgressMaskFunction = {}));
4862
5299
  /**
4863
5300
  * Progress bar UI element with customizable fill direction and appearance.
4864
5301
  *
@@ -4874,151 +5311,103 @@ class UIProgress extends UIElement {
4874
5311
  * Creates a new progress bar UI element.
4875
5312
  *
4876
5313
  * @param layer - The UI layer to add this element to
4877
- * @param textureForeground - The texture used for the progress fill
5314
+ * @param foregroundTexture - The texture used for the progress fill
4878
5315
  * @param options - Configuration options for the progress bar
4879
5316
  */
4880
- constructor(layer, textureForeground, options = {}) {
4881
- const foregroundWidth = textureForeground.image?.width;
4882
- const foregroundHeight = textureForeground.image?.height;
4883
- assertValidPositiveNumber(foregroundWidth, "UIProgress foreground texture width");
4884
- assertValidPositiveNumber(foregroundHeight, "UIProgress foreground texture height");
4885
- const backgroundWidth = options.textureBackground?.image?.width;
4886
- const backgroundHeight = options.textureBackground?.image?.height;
4887
- if (options.textureBackground) {
4888
- assertValidPositiveNumber(backgroundWidth, "UIProgress background texture width");
4889
- assertValidPositiveNumber(backgroundHeight, "UIProgress background texture height");
4890
- }
4891
- const material = new UIProgressMaterial(textureForeground, options.textureBackground);
4892
- const object = new Mesh(geometry, material);
4893
- if (options.progress !== undefined) {
4894
- material.setProgress(options.progress);
4895
- }
4896
- if (options.isForwardDirection !== undefined) {
4897
- material.setIsForwardDirection(options.isForwardDirection);
4898
- }
4899
- if (options.angle !== undefined) {
4900
- material.setAngle(MathUtils.degToRad(options.angle));
4901
- }
4902
- if (options.backgroundColor !== undefined) {
4903
- material.setBackgroundColor(options.backgroundColor);
4904
- }
4905
- if (options.foregroundColor !== undefined) {
4906
- material.setForegroundColor(options.foregroundColor);
4907
- }
4908
- if (options.backgroundOpacity !== undefined) {
4909
- material.setBackgroundOpacity(options.backgroundOpacity);
4910
- }
4911
- if (options.foregroundOpacity !== undefined) {
4912
- material.setForegroundOpacity(options.foregroundOpacity);
4913
- }
4914
- const imageWidth = backgroundWidth ?? foregroundWidth;
4915
- const imageHeight = foregroundHeight ?? backgroundHeight;
4916
- super(layer, options.x ?? 0, options.y ?? 0, imageWidth, imageHeight, object);
4917
- this._private_material = material;
5317
+ constructor(layer, foregroundTexture, options = {}) {
5318
+ const w = foregroundTexture.image?.width;
5319
+ const h = foregroundTexture.image?.height;
5320
+ assertValidPositiveNumber(w, "UIProgress foreground texture width");
5321
+ assertValidPositiveNumber(h, "UIProgress foreground texture height");
5322
+ if (options.backgroundTexture) {
5323
+ assertValidPositiveNumber(options.backgroundTexture.image.width, "UIProgress background texture width");
5324
+ assertValidPositiveNumber(options.backgroundTexture.image.height, "UIProgress background texture height");
5325
+ }
5326
+ const color = options.color ?? new UIColor();
5327
+ const foregroundColor = options.foregroundColor ?? new UIColor();
5328
+ const backgroundColor = options.backgroundColor ?? new UIColor();
5329
+ const progress = options.progress ?? 1;
5330
+ const inverseDirection = options.inverseDirection ?? false;
5331
+ super(layer, options.x ?? 0, options.y ?? 0, w, h, (options.maskFunction ?? UIProgressMaskFunction.HORIZONTAL) + source, {
5332
+ foregroundTexture,
5333
+ backgroundTexture: options.backgroundTexture ?? DEFAULT_TEXTURE,
5334
+ color,
5335
+ foregroundColor,
5336
+ backgroundColor,
5337
+ progress,
5338
+ direction: inverseDirection ? -1 : 1,
5339
+ });
5340
+ /** Event handler for when the overall color changes */
5341
+ this._private_onColorChange = (color) => {
5342
+ this.sceneWrapper.setUniform(this.planeHandler, "color", color);
5343
+ };
5344
+ /** Event handler for when the foreground color changes */
5345
+ this._private_onForegroundColorChange = (color) => {
5346
+ this.sceneWrapper.setUniform(this.planeHandler, "foregroundColor", color);
5347
+ };
5348
+ /** Event handler for when the background color changes */
5349
+ this._private_onBackgroundColorChange = (color) => {
5350
+ this.sceneWrapper.setUniform(this.planeHandler, "backgroundColor", color);
5351
+ };
5352
+ this._private_foregroundTextureInternal = foregroundTexture;
5353
+ this._private_backgroundTextureInternal = options.backgroundTexture;
5354
+ this._private_colorInternal = color;
5355
+ this._private_foregroundColorInternal = foregroundColor;
5356
+ this._private_backgroundColorInternal = backgroundColor;
5357
+ this._private_progressInternal = progress;
5358
+ this._private_inverseDirectionInternal = inverseDirection;
5359
+ this._private_colorInternal.on(UIColorEvent.CHANGE, this._private_onColorChange);
5360
+ this._private_foregroundColorInternal.on(UIColorEvent.CHANGE, this._private_onForegroundColorChange);
5361
+ this._private_backgroundColorInternal.on(UIColorEvent.CHANGE, this._private_onBackgroundColorChange);
4918
5362
  }
4919
5363
  /**
4920
- * Gets the current progress value.
4921
- * @returns Progress value between 0.0 (empty) and 1.0 (full)
5364
+ * Gets the foreground (fill) texture.
5365
+ * @returns The foreground texture
4922
5366
  */
4923
- get progress() {
4924
- return this._private_material.getProgress();
5367
+ get foregroundTexture() {
5368
+ return this._private_foregroundTextureInternal;
4925
5369
  }
4926
5370
  /**
4927
5371
  * Gets the background texture.
4928
5372
  * @returns The background texture, or undefined if none is set
4929
5373
  */
4930
5374
  get backgroundTexture() {
4931
- return this._private_material.getBackgroundTexture();
4932
- }
4933
- /**
4934
- * Gets the foreground (fill) texture.
4935
- * @returns The foreground texture
4936
- */
4937
- get foregroundTexture() {
4938
- return this._private_material.getForegroundTexture();
5375
+ return this._private_backgroundTextureInternal;
4939
5376
  }
4940
5377
  /**
4941
5378
  * Gets the color tint.
4942
- * @returns The color as a hex number (e.g., 0xFFFFFF)
5379
+ * @returns The UIColor instance
4943
5380
  */
4944
5381
  get color() {
4945
- return this._private_material.getColor();
4946
- }
4947
- /**
4948
- * Gets the background color tint.
4949
- * @returns The background color as a hex number (e.g., 0xFFFFFF)
4950
- */
4951
- get backgroundColor() {
4952
- return this._private_material.getBackgroundColor();
5382
+ return this._private_colorInternal;
4953
5383
  }
4954
5384
  /**
4955
5385
  * Gets the foreground color tint.
4956
- * @returns The foreground color as a hex number (e.g., 0xFFFFFF)
5386
+ * @returns The foreground color UIColor instance
4957
5387
  */
4958
5388
  get foregroundColor() {
4959
- return this._private_material.getForegroundColor();
4960
- }
4961
- /**
4962
- * Gets the opacity.
4963
- * @returns Opacity value between 0.0 (transparent) and 1.0 (opaque)
4964
- */
4965
- get opacity() {
4966
- return this._private_material.getOpacity();
4967
- }
4968
- /**
4969
- * Gets the background opacity.
4970
- * @returns Opacity value between 0.0 (transparent) and 1.0 (opaque)
4971
- */
4972
- get backgroundOpacity() {
4973
- return this._private_material.getBackgroundOpacity();
4974
- }
4975
- /**
4976
- * Gets the foreground opacity.
4977
- * @returns Opacity value between 0.0 (transparent) and 1.0 (opaque)
4978
- */
4979
- get foregroundOpacity() {
4980
- return this._private_material.getForegroundOpacity();
4981
- }
4982
- /**
4983
- * Gets whether transparency is enabled for the image.
4984
- * @returns True if transparency is enabled, false otherwise
4985
- */
4986
- get transparency() {
4987
- return this._private_material.getTransparency();
4988
- }
4989
- /**
4990
- * Gets the progress fill angle in degrees.
4991
- * @returns Angle in degrees (0 = horizontal, 90 = vertical)
4992
- */
4993
- get angle() {
4994
- return MathUtils.radToDeg(this._private_material.getAngle());
5389
+ return this._private_foregroundColorInternal;
4995
5390
  }
4996
5391
  /**
4997
- * Gets whether the progress fills in forward direction.
4998
- * @returns True if filling forward, false if filling in reverse
5392
+ * Gets the background color tint.
5393
+ * @returns The background color UIColor instance
4999
5394
  */
5000
- get isForwardDirection() {
5001
- return this._private_material.getIsForwardDirection();
5395
+ get backgroundColor() {
5396
+ return this._private_backgroundColorInternal;
5002
5397
  }
5003
5398
  /**
5004
- * Sets the progress value.
5005
- * @param value - Progress value between 0.0 (empty) and 1.0 (full)
5399
+ * Gets the current progress value.
5400
+ * @returns Progress value between 0.0 (empty) and 1.0 (full)
5006
5401
  */
5007
- set progress(value) {
5008
- this._private_material.setProgress(value);
5402
+ get progress() {
5403
+ return this._private_progressInternal;
5009
5404
  }
5010
5405
  /**
5011
- * Sets the background texture.
5012
- * @param value - The background texture, or undefined to remove background
5406
+ * Gets whether the progress fills in reverse direction.
5407
+ * @returns True if filling in reverse, false if filling forward
5013
5408
  */
5014
- set backgroundTexture(value) {
5015
- if (value) {
5016
- const width = value.image.width;
5017
- const height = value.image.height;
5018
- assertValidPositiveNumber(width, "UIProgress background texture width");
5019
- assertValidPositiveNumber(height, "UIProgress background texture height");
5020
- }
5021
- this._private_material.setBackgroundTexture(value);
5409
+ get inverseDirection() {
5410
+ return this._private_inverseDirectionInternal;
5022
5411
  }
5023
5412
  /**
5024
5413
  * Sets the foreground (fill) texture.
@@ -5030,84 +5419,68 @@ class UIProgress extends UIElement {
5030
5419
  * @throws Will throw an error if the texture dimensions are not valid positive numbers
5031
5420
  */
5032
5421
  set foregroundTexture(value) {
5033
- const width = value.image.width;
5034
- const height = value.image.height;
5035
- assertValidPositiveNumber(width, "UIProgress foreground texture width");
5036
- assertValidPositiveNumber(height, "UIProgress foreground texture height");
5037
- this._private_material.setForegroundTexture(value);
5038
- this.solverWrapper.suggestVariableValue(this.wVariable, width);
5039
- this.solverWrapper.suggestVariableValue(this.hVariable, height);
5422
+ const w = value.image.width;
5423
+ const h = value.image.height;
5424
+ assertValidPositiveNumber(w, "UIProgress foreground texture width");
5425
+ assertValidPositiveNumber(h, "UIProgress foreground texture height");
5426
+ this.solverWrapper.suggestVariableValue(this.wVariable, w);
5427
+ this.solverWrapper.suggestVariableValue(this.hVariable, h);
5428
+ this._private_foregroundTextureInternal = value;
5429
+ this.sceneWrapper.setUniform(this.planeHandler, "foregroundTexture", value);
5040
5430
  }
5041
5431
  /**
5042
- * Sets the color tint.
5043
- * @param value - The color as a hex number (e.g., 0xFFFFFF)
5432
+ * Sets the background texture.
5433
+ * @param value - The background texture, or undefined to remove background
5044
5434
  */
5045
- set color(value) {
5046
- this._private_material.setColor(value);
5435
+ set backgroundTexture(value) {
5436
+ if (value !== undefined) {
5437
+ assertValidPositiveNumber(value.image.width, "UIProgress background texture width");
5438
+ assertValidPositiveNumber(value.image.height, "UIProgress background texture height");
5439
+ }
5440
+ this._private_backgroundTextureInternal = value;
5441
+ this.sceneWrapper.setUniform(this.planeHandler, "backgroundTexture", value);
5047
5442
  }
5048
5443
  /**
5049
- * Sets the background color tint.
5050
- * @param value - The background color as a hex number (e.g., 0xFFFFFF)
5444
+ * Sets the color tint.
5445
+ * @param value - The UIColor instance
5051
5446
  */
5052
- set backgroundColor(value) {
5053
- this._private_material.setBackgroundColor(value);
5447
+ set color(value) {
5448
+ this._private_colorInternal.copy(value);
5054
5449
  }
5055
5450
  /**
5056
5451
  * Sets the foreground color tint.
5057
- * @param value - The foreground color as a hex number (e.g., 0xFFFFFF)
5452
+ * @param value - The foreground color UIColor instance
5058
5453
  */
5059
5454
  set foregroundColor(value) {
5060
- this._private_material.setForegroundColor(value);
5061
- }
5062
- /**
5063
- * Sets the opacity.
5064
- * @param value - Opacity value between 0.0 (transparent) and 1.0 (opaque)
5065
- */
5066
- set opacity(value) {
5067
- this._private_material.setOpacity(value);
5068
- }
5069
- /**
5070
- * Sets the background opacity.
5071
- * @param value - Opacity value between 0.0 (transparent) and 1.0 (opaque)
5072
- */
5073
- set backgroundOpacity(value) {
5074
- this._private_material.setBackgroundOpacity(value);
5455
+ this._private_foregroundColorInternal.copy(value);
5075
5456
  }
5076
5457
  /**
5077
- * Sets the foreground opacity.
5078
- * @param value - Opacity value between 0.0 (transparent) and 1.0 (opaque)
5079
- */
5080
- set foregroundOpacity(value) {
5081
- this._private_material.setForegroundOpacity(value);
5082
- }
5083
- /**
5084
- * Sets whether transparency is enabled for the image.
5085
- * @param value - True to enable transparency, false to disable
5086
- */
5087
- set transparency(value) {
5088
- this._private_material.setTransparency(value);
5089
- }
5090
- /**
5091
- * Sets the progress fill angle.
5092
- * @param value - Angle in degrees (0 = horizontal, 90 = vertical)
5458
+ * Sets the background color tint.
5459
+ * @param value - The background color UIColor instance
5093
5460
  */
5094
- set angle(value) {
5095
- this._private_material.setAngle(MathUtils.degToRad(value));
5461
+ set backgroundColor(value) {
5462
+ this._private_backgroundColorInternal.copy(value);
5096
5463
  }
5097
5464
  /**
5098
5465
  * Sets the progress fill direction.
5099
- * @param value - True for forward direction, false for reverse
5466
+ * @param value - True for reverse direction, false for forward
5100
5467
  */
5101
- set isForwardDirection(value) {
5102
- this._private_material.setIsForwardDirection(value);
5468
+ set inverseDirection(value) {
5469
+ this._private_inverseDirectionInternal = value;
5470
+ this.sceneWrapper.setUniform(this.planeHandler, "direction", value ? -1 : 1);
5103
5471
  }
5104
5472
  /**
5105
- * Destroys the progress bar element and cleans up resources.
5106
- *
5107
- * This method disposes of the material and calls the parent destroy method.
5473
+ * Sets the progress value.
5474
+ * @param value - Progress value between 0.0 (empty) and 1.0 (full)
5108
5475
  */
5476
+ set progress(value) {
5477
+ this._private_progressInternal = value;
5478
+ this.sceneWrapper.setUniform(this.planeHandler, "progress", value);
5479
+ }
5109
5480
  destroy() {
5110
- this._private_material.dispose();
5481
+ this._private_colorInternal.off(UIColorEvent.CHANGE, this._private_onColorChange);
5482
+ this._private_foregroundColorInternal.off(UIColorEvent.CHANGE, this._private_onForegroundColorChange);
5483
+ this._private_backgroundColorInternal.off(UIColorEvent.CHANGE, this._private_onBackgroundColorChange);
5111
5484
  super.destroy();
5112
5485
  }
5113
5486
  }
@@ -5182,9 +5555,9 @@ class UIScene extends UIElement {
5182
5555
  resolutionFactor > MAX_RESOLUTION_FACTOR) {
5183
5556
  throw new Error(`Invalid resolution factor: ${resolutionFactor}. Must be between ${MIN_RESOLUTION_FACTOR} and ${MAX_RESOLUTION_FACTOR}.`);
5184
5557
  }
5185
- const width = options.width ?? DEFAULT_WIDTH;
5186
- const height = options.height ?? DEFAULT_HEIGHT;
5187
- const renderTarget = new WebGLRenderTarget(width * resolutionFactor, height * resolutionFactor, {
5558
+ const w = options.width ?? DEFAULT_WIDTH;
5559
+ const h = options.height ?? DEFAULT_HEIGHT;
5560
+ const renderTarget = new WebGLRenderTarget(w * resolutionFactor, h * resolutionFactor, {
5188
5561
  format: RGBAFormat,
5189
5562
  minFilter: LinearFilter,
5190
5563
  magFilter: LinearFilter,
@@ -5192,37 +5565,27 @@ class UIScene extends UIElement {
5192
5565
  depthBuffer: options.enableDepthBuffer ?? DEFAULT_USE_DEPTH,
5193
5566
  stencilBuffer: false,
5194
5567
  });
5195
- const material = new UIMaterial(renderTarget.texture);
5196
- const object = new Mesh(geometry, material);
5197
- super(layer, 0, 0, width, height, object);
5568
+ const color = options.color ?? new UIColor();
5569
+ super(layer, 0, 0, w, h, source$2, {
5570
+ map: renderTarget.texture,
5571
+ color,
5572
+ });
5198
5573
  /** Frame alternation boolean for EACH_SECOND_FRAME update mode. */
5199
5574
  this._private_frameBoolean = true;
5200
5575
  /** Flag indicating if properties have changed requiring a re-render. */
5201
5576
  this._private_propertyChanged = false;
5202
5577
  /** Flag indicating if a manual render has been requested. */
5203
5578
  this._private_renderRequired = false;
5204
- this._private_onWillRenderInternal = (renderer) => {
5205
- if (this._private_updateModeInternal === UISceneUpdateMode.EACH_FRAME ||
5206
- (this._private_updateModeInternal === UISceneUpdateMode.EACH_SECOND_FRAME && this._private_frameBoolean) ||
5207
- (this._private_updateModeInternal === UISceneUpdateMode.PROPERTY_CHANGED && this._private_propertyChanged) ||
5208
- (this._private_updateModeInternal === UISceneUpdateMode.MANUAL && this._private_renderRequired)) {
5209
- this._private_renderRequired = false;
5210
- this._private_propertyChanged = false;
5211
- this._private_frameBoolean = !this._private_frameBoolean;
5212
- this._private_renderTarget.setSize(this.width * this._private_resolutionFactorInternal, this.height * this._private_resolutionFactorInternal);
5213
- renderer.setClearColor(this._private_clearColorInternal, this.clearAlpha);
5214
- renderer.setRenderTarget(this._private_renderTarget);
5215
- renderer.clear(true, true, false);
5216
- renderer.render(this._private_sceneInternal, this._private_cameraInternal);
5217
- }
5579
+ /** Event handler for when the color changes */
5580
+ this._private_onColorChange = (color) => {
5581
+ this.sceneWrapper.setUniform(this.planeHandler, "color", color);
5218
5582
  };
5219
- this.layer.on(UILayerEvent.WILL_RENDER, this._private_onWillRenderInternal);
5220
- this._private_material = material;
5221
5583
  this._private_renderTarget = renderTarget;
5584
+ this._private_colorInternal = color;
5222
5585
  this._private_sceneInternal = options.scene ?? new Scene();
5223
5586
  this._private_cameraInternal =
5224
5587
  options.camera ??
5225
- new PerspectiveCamera(DEFAULT_CAMERA_FOV, width / height, DEFAULT_CAMERA_NEAR, DEFAULT_CAMERA_FAR);
5588
+ new PerspectiveCamera(DEFAULT_CAMERA_FOV, w / h, DEFAULT_CAMERA_NEAR, DEFAULT_CAMERA_FAR);
5226
5589
  this._private_resolutionFactorInternal = resolutionFactor;
5227
5590
  this._private_updateModeInternal = options.updateMode ?? DEFAULT_UPDATE_MODE;
5228
5591
  this._private_clearColorInternal = options.clearColor ?? DEFAULT_CLEAR_COLOR;
@@ -5230,27 +5593,14 @@ class UIScene extends UIElement {
5230
5593
  if (options.updateMode === UISceneUpdateMode.PROPERTY_CHANGED) {
5231
5594
  this._private_renderRequired = true;
5232
5595
  }
5596
+ this._private_colorInternal.on(UIColorEvent.CHANGE, this._private_onColorChange);
5233
5597
  }
5234
5598
  /**
5235
5599
  * Gets the current color tint applied to the scene texture.
5236
- * @returns The color value as a number (e.g., 0xFFFFFF for white)
5600
+ * @returns The UIColor instance
5237
5601
  */
5238
5602
  get color() {
5239
- return this._private_material.getColor();
5240
- }
5241
- /**
5242
- * Gets the current opacity level of the scene texture.
5243
- * @returns The opacity value between 0.0 (transparent) and 1.0 (opaque)
5244
- */
5245
- get opacity() {
5246
- return this._private_material.getOpacity();
5247
- }
5248
- /**
5249
- * Gets whether transparency is enabled for the scene texture.
5250
- * @returns True if transparency is enabled, false otherwise
5251
- */
5252
- get transparency() {
5253
- return this._private_material.getTransparency();
5603
+ return this._private_colorInternal;
5254
5604
  }
5255
5605
  /**
5256
5606
  * Gets the Three.js scene being rendered.
@@ -5296,24 +5646,10 @@ class UIScene extends UIElement {
5296
5646
  }
5297
5647
  /**
5298
5648
  * Sets the color tint applied to the scene texture.
5299
- * @param value - The color value as a number (e.g., 0xFFFFFF for white)
5649
+ * @param value - The UIColor instance
5300
5650
  */
5301
5651
  set color(value) {
5302
- this._private_material.setColor(value);
5303
- }
5304
- /**
5305
- * Sets the opacity level of the scene texture.
5306
- * @param value - The opacity value between 0.0 (transparent) and 1.0 (opaque)
5307
- */
5308
- set opacity(value) {
5309
- this._private_material.setOpacity(value);
5310
- }
5311
- /**
5312
- * Sets whether transparency is enabled for the scene texture.
5313
- * @param value - True to enable transparency, false to disable
5314
- */
5315
- set transparency(value) {
5316
- this._private_material.setTransparency(value);
5652
+ this._private_colorInternal.copy(value);
5317
5653
  }
5318
5654
  /**
5319
5655
  * Sets a new Three.js scene to render and marks for re-render.
@@ -5384,8 +5720,7 @@ class UIScene extends UIElement {
5384
5720
  * After calling this method, the scene element should not be used anymore.
5385
5721
  */
5386
5722
  destroy() {
5387
- this.layer.off(UILayerEvent.WILL_RENDER, this._private_onWillRenderInternal);
5388
- this._private_material.dispose();
5723
+ this._private_colorInternal.off(UIColorEvent.CHANGE, this._private_onColorChange);
5389
5724
  this._private_renderTarget.dispose();
5390
5725
  super.destroy();
5391
5726
  }
@@ -5398,6 +5733,27 @@ class UIScene extends UIElement {
5398
5733
  requestRender() {
5399
5734
  this._private_renderRequired = true;
5400
5735
  }
5736
+ /**
5737
+ * Called before each render frame to update the 3D scene rendering.
5738
+ * Handles different update modes and renders the 3D scene to the render target
5739
+ * based on the current update mode and property change state.
5740
+ * @param renderer - The WebGL renderer used for scene rendering
5741
+ */
5742
+ onWillRender(renderer) {
5743
+ if (this._private_updateModeInternal === UISceneUpdateMode.EACH_FRAME ||
5744
+ (this._private_updateModeInternal === UISceneUpdateMode.EACH_SECOND_FRAME && this._private_frameBoolean) ||
5745
+ (this._private_updateModeInternal === UISceneUpdateMode.PROPERTY_CHANGED && this._private_propertyChanged) ||
5746
+ (this._private_updateModeInternal === UISceneUpdateMode.MANUAL && this._private_renderRequired)) {
5747
+ this._private_renderRequired = false;
5748
+ this._private_propertyChanged = false;
5749
+ this._private_frameBoolean = !this._private_frameBoolean;
5750
+ this._private_renderTarget.setSize(this.width * this._private_resolutionFactorInternal, this.height * this._private_resolutionFactorInternal);
5751
+ renderer.setClearColor(this._private_clearColorInternal, this.clearAlpha);
5752
+ renderer.setRenderTarget(this._private_renderTarget);
5753
+ renderer.clear(true, true, false);
5754
+ renderer.render(this._private_sceneInternal, this._private_cameraInternal);
5755
+ }
5756
+ }
5401
5757
  }
5402
5758
 
5403
5759
  function isUITextStyle(obj) {
@@ -5642,7 +5998,7 @@ function calculateTextContentParameters(context, content, maxLineWidth, commonSt
5642
5998
  return { lines, size: textSize };
5643
5999
  }
5644
6000
 
5645
- function resolvePadding(value) {
6001
+ function resolveTextPadding(value) {
5646
6002
  if (typeof value === "number") {
5647
6003
  return { left: value, right: value, top: value, bottom: value };
5648
6004
  }
@@ -5687,61 +6043,45 @@ class UIText extends UIElement {
5687
6043
  * @param layer - The UI layer that contains this text element
5688
6044
  * @param content - The text content to display
5689
6045
  * @param options - Configuration options for text rendering
5690
- * @param x - Initial x-coordinate position (defaults to 0)
5691
- * @param y - Initial y-coordinate position (defaults to 0)
5692
6046
  * @throws Will throw an error if canvas context creation fails
5693
6047
  */
5694
6048
  constructor(layer, content, options = {}) {
5695
- const canvas = document.createElement("canvas");
6049
+ const canvas = new OffscreenCanvas(2, 2);
5696
6050
  const context = canvas.getContext("2d");
5697
6051
  if (!context) {
5698
- throw new Error("Failed to create canvas context");
6052
+ throw new Error("UIText failed to create canvas context");
5699
6053
  }
5700
6054
  const texture = new CanvasTexture(canvas);
5701
- const material = new UIMaterial(texture);
5702
- const object = new Mesh(geometry, material);
5703
- super(layer, options.x ?? 0, options.y ?? 0, 2, 2, object);
6055
+ const color = options.color ?? new UIColor();
6056
+ super(layer, options.x ?? 0, options.y ?? 0, 2, 2, source$2, {
6057
+ map: texture,
6058
+ color,
6059
+ });
5704
6060
  /** Target aspect ratio for the text element based on content. */
5705
6061
  this._private_targetAspectRatio = 1;
5706
6062
  /** Last calculated aspect ratio for comparison during rendering. */
5707
6063
  this._private_lastAspectRatio = 1;
5708
- this._private_onWillRenderInternal = () => {
5709
- if (this._private_lastAspectRatio !== this.width / this.height) {
5710
- this._private_lastAspectRatio = this._private_targetAspectRatio;
5711
- this.height = this.width / this._private_targetAspectRatio;
5712
- }
6064
+ /** Event handler for when the color changes */
6065
+ this._private_onColorChange = (color) => {
6066
+ this.sceneWrapper.setUniform(this.planeHandler, "color", color);
5713
6067
  };
5714
- this.layer.on(UILayerEvent.WILL_RENDER, this._private_onWillRenderInternal);
5715
- this._private_material = material;
5716
- this._private_texture = texture;
5717
6068
  this._private_canvas = canvas;
5718
6069
  this._private_context = context;
6070
+ this._private_texture = texture;
6071
+ this._private_colorInternal = color;
5719
6072
  this._private_contentInternal = content;
5720
6073
  this._private_maxWidthInternal = options.maxWidth ?? DEFAULT_MAX_WIDTH;
5721
- this._private_paddingInternal = resolvePadding(options.padding);
6074
+ this._private_paddingInternal = resolveTextPadding(options.padding);
5722
6075
  this._private_commonStyleInternal = options.commonStyle ?? {};
6076
+ this._private_colorInternal.on(UIColorEvent.CHANGE, this._private_onColorChange);
5723
6077
  this._private_rebuildText();
5724
6078
  }
5725
6079
  /**
5726
6080
  * Gets the current color tint applied to the text.
5727
- * @returns The color value as a number (e.g., 0xFFFFFF for white)
6081
+ * @returns The UIColor instance
5728
6082
  */
5729
6083
  get color() {
5730
- return this._private_material.getColor();
5731
- }
5732
- /**
5733
- * Gets the current opacity level of the text.
5734
- * @returns The opacity value between 0.0 (transparent) and 1.0 (opaque)
5735
- */
5736
- get opacity() {
5737
- return this._private_material.getOpacity();
5738
- }
5739
- /**
5740
- * Gets whether transparency is enabled for the text.
5741
- * @returns True if transparency is enabled, false otherwise
5742
- */
5743
- get transparency() {
5744
- return this._private_material.getTransparency();
6084
+ return this._private_colorInternal;
5745
6085
  }
5746
6086
  /**
5747
6087
  * Gets the current text content being displayed.
@@ -5773,24 +6113,10 @@ class UIText extends UIElement {
5773
6113
  }
5774
6114
  /**
5775
6115
  * Sets the color tint applied to the text.
5776
- * @param value - The color value as a number (e.g., 0xFFFFFF for white)
6116
+ * @param value - The UIColor instance
5777
6117
  */
5778
6118
  set color(value) {
5779
- this._private_material.setColor(value);
5780
- }
5781
- /**
5782
- * Sets the opacity level of the text.
5783
- * @param value - The opacity value between 0.0 (transparent) and 1.0 (opaque)
5784
- */
5785
- set opacity(value) {
5786
- this._private_material.setOpacity(value);
5787
- }
5788
- /**
5789
- * Sets whether transparency is enabled for the text.
5790
- * @param value - True to enable transparency, false to disable
5791
- */
5792
- set transparency(value) {
5793
- this._private_material.setTransparency(value);
6119
+ this._private_colorInternal.copy(value);
5794
6120
  }
5795
6121
  /**
5796
6122
  * Sets new text content and triggers a rebuild.
@@ -5827,26 +6153,34 @@ class UIText extends UIElement {
5827
6153
  /**
5828
6154
  * Destroys the text element by cleaning up all associated resources.
5829
6155
  *
5830
- * This method disposes of the material and texture resources, removes
5831
- * the canvas element from the DOM, and calls the parent destroy method
6156
+ * This method disposes of the texture resources and calls the parent destroy method
5832
6157
  * to clean up the underlying UI element. After calling this method,
5833
6158
  * the text element should not be used anymore.
5834
6159
  */
5835
6160
  destroy() {
5836
- this.layer.off(UILayerEvent.WILL_RENDER, this._private_onWillRenderInternal);
5837
- this._private_material.dispose();
6161
+ this._private_colorInternal.off(UIColorEvent.CHANGE, this._private_onColorChange);
5838
6162
  this._private_texture.dispose();
5839
- this._private_canvas.remove();
5840
6163
  super.destroy();
5841
6164
  }
6165
+ /**
6166
+ * Called before each render frame to maintain proper text aspect ratio.
6167
+ * Adjusts the height based on the target aspect ratio calculated from text content.
6168
+ * @param renderer - The WebGL renderer
6169
+ * @param deltaTime - Time since last frame in seconds
6170
+ */
6171
+ onWillRender(renderer, deltaTime) {
6172
+ super.onWillRender(renderer, deltaTime);
6173
+ if (this._private_lastAspectRatio !== this.width / this.height) {
6174
+ this._private_lastAspectRatio = this._private_targetAspectRatio;
6175
+ this.height = this.width / this._private_targetAspectRatio;
6176
+ }
6177
+ }
5842
6178
  /**
5843
6179
  * Rebuilds the text canvas and texture based on current content and settings.
5844
6180
  *
5845
6181
  * This method calculates the text layout, resizes the canvas to fit the content
5846
6182
  * with padding, renders the text lines to the canvas, and updates the texture.
5847
6183
  * It also calculates and sets the target aspect ratio for proper display.
5848
- *
5849
- * @private
5850
6184
  */
5851
6185
  _private_rebuildText() {
5852
6186
  const { lines, size } = calculateTextContentParameters(this._private_context, this.content, this._private_maxWidthInternal, this._private_commonStyleInternal);
@@ -5905,8 +6239,6 @@ class UIFullscreenLayer extends UILayer {
5905
6239
  *
5906
6240
  * Recalculates the scaling factor and updates the layer dimensions
5907
6241
  * based on the new window size and fixed dimension constraints.
5908
- *
5909
- * @private
5910
6242
  */
5911
6243
  this._private_onResize = () => {
5912
6244
  const scale = this._private_calculateScale();
@@ -5920,7 +6252,6 @@ class UIFullscreenLayer extends UILayer {
5920
6252
  * The y-coordinate is flipped to match the UI coordinate system.
5921
6253
  *
5922
6254
  * @param event - The pointer event from the browser
5923
- * @private
5924
6255
  */
5925
6256
  this._private_onClick = (event) => {
5926
6257
  const r = event.target instanceof HTMLElement
@@ -5929,7 +6260,7 @@ class UIFullscreenLayer extends UILayer {
5929
6260
  const x = r ? event.clientX - r.left : event.clientX;
5930
6261
  const y = r ? r.bottom - event.clientY : window.innerHeight - event.clientY;
5931
6262
  const scale = this._private_calculateScale();
5932
- this.clickInternal(x * scale, y * scale);
6263
+ this.pointerClickInternal(x * scale, y * scale);
5933
6264
  };
5934
6265
  this._private_fixedWidthInternal = fixedWidth;
5935
6266
  this._private_fixedHeightInternal = fixedHeight;
@@ -6016,7 +6347,6 @@ class UIFullscreenLayer extends UILayer {
6016
6347
  * width takes precedence; in vertical orientation, fixed height takes precedence.
6017
6348
  *
6018
6349
  * @returns The scaling factor to apply to window dimensions
6019
- * @private
6020
6350
  */
6021
6351
  _private_calculateScale() {
6022
6352
  if (this.orientation === UIOrientation.HORIZONTAL) {
@@ -6044,6 +6374,400 @@ class UIFullscreenLayer extends UILayer {
6044
6374
  }
6045
6375
  }
6046
6376
 
6377
+ const INSTANCED_GEOMETRY = (() => {
6378
+ const planeGeometry = new PlaneGeometry(1, 1);
6379
+ const geometry = new InstancedBufferGeometry();
6380
+ geometry.index = planeGeometry.index;
6381
+ geometry.setAttribute("position", planeGeometry.attributes["position"]);
6382
+ geometry.setAttribute("uv", planeGeometry.attributes["uv"]);
6383
+ planeGeometry.dispose();
6384
+ return geometry;
6385
+ })();
6386
+ const ITEM_1_OFFSET = 1;
6387
+ const ITEM_2_OFFSET = 2;
6388
+ const ITEM_3_OFFSET = 3;
6389
+ const CAPACITY_STEP = 16;
6390
+ const ALPHA_TEST = 0.5;
6391
+ function resolveTypeInfo(property) {
6392
+ if (property === "Texture" || property instanceof Texture) {
6393
+ return { glslType: "sampler2D", instantiable: false, itemSize: -1 };
6394
+ }
6395
+ else if (property === "UIColor" || property instanceof UIColor) {
6396
+ return { glslType: "vec4", instantiable: true, itemSize: 4 };
6397
+ }
6398
+ else if (property === "Vector2" || property instanceof Vector2) {
6399
+ return { glslType: "vec2", instantiable: true, itemSize: 2 };
6400
+ }
6401
+ else if (property === "Vector3" || property instanceof Vector3) {
6402
+ return { glslType: "vec3", instantiable: true, itemSize: 3 };
6403
+ }
6404
+ else if (property === "Vector4" || property instanceof Vector4) {
6405
+ return { glslType: "vec4", instantiable: true, itemSize: 4 };
6406
+ }
6407
+ else if (property === "Matrix2" || property instanceof Matrix2) {
6408
+ return { glslType: "mat2", instantiable: true, itemSize: 4 };
6409
+ }
6410
+ else if (property === "Matrix3" || property instanceof Matrix3) {
6411
+ return { glslType: "mat3", instantiable: true, itemSize: 9 };
6412
+ }
6413
+ else if (property === "Matrix4" || property instanceof Matrix4) {
6414
+ return { glslType: "mat4", instantiable: true, itemSize: 16 };
6415
+ }
6416
+ else if (property === "number" || typeof property === "number") {
6417
+ return { glslType: "float", instantiable: true, itemSize: 1 };
6418
+ }
6419
+ else {
6420
+ throw new Error(`Unsupported property type: ${property}`);
6421
+ }
6422
+ }
6423
+ function udpateProperty(value, attribute, itemOffset) {
6424
+ const array = attribute.array;
6425
+ if (value instanceof UIColor) {
6426
+ array[itemOffset] = value.r;
6427
+ array[itemOffset + ITEM_1_OFFSET] = value.g;
6428
+ array[itemOffset + ITEM_2_OFFSET] = value.b;
6429
+ array[itemOffset + ITEM_3_OFFSET] = value.a;
6430
+ }
6431
+ else if (value instanceof Vector2) {
6432
+ array[itemOffset] = value.x;
6433
+ array[itemOffset + ITEM_1_OFFSET] = value.y;
6434
+ }
6435
+ else if (value instanceof Vector3) {
6436
+ array[itemOffset] = value.x;
6437
+ array[itemOffset + ITEM_1_OFFSET] = value.y;
6438
+ array[itemOffset + ITEM_2_OFFSET] = value.z;
6439
+ }
6440
+ else if (value instanceof Vector4) {
6441
+ array[itemOffset] = value.x;
6442
+ array[itemOffset + ITEM_1_OFFSET] = value.y;
6443
+ array[itemOffset + ITEM_2_OFFSET] = value.z;
6444
+ array[itemOffset + ITEM_3_OFFSET] = value.w;
6445
+ }
6446
+ else if (value instanceof Matrix2) {
6447
+ const elements = value.elements;
6448
+ for (let j = 0; j < elements.length; j++) {
6449
+ array[itemOffset + j] = elements[j];
6450
+ }
6451
+ }
6452
+ else if (value instanceof Matrix3) {
6453
+ const elements = value.elements;
6454
+ for (let j = 0; j < elements.length; j++) {
6455
+ array[itemOffset + j] = elements[j];
6456
+ }
6457
+ }
6458
+ else if (value instanceof Matrix4) {
6459
+ const elements = value.elements;
6460
+ for (let j = 0; j < elements.length; j++) {
6461
+ array[itemOffset + j] = elements[j];
6462
+ }
6463
+ }
6464
+ else if (typeof value === "number") {
6465
+ array[itemOffset] = value;
6466
+ }
6467
+ attribute.needsUpdate = true;
6468
+ }
6469
+ function buildEmptyInstancedBufferAttribute(property, capacity) {
6470
+ const info = resolveTypeInfo(property);
6471
+ if (!info.instantiable) {
6472
+ throw new Error(`Invalid property type: ${property}`);
6473
+ }
6474
+ return new InstancedBufferAttribute(new Float32Array(capacity * info.itemSize), info.itemSize);
6475
+ }
6476
+ function buildMaterial(source, uniformLayout, varyingLayout, transparency) {
6477
+ const uniforms = {};
6478
+ const uniformDeclarations = [];
6479
+ const attributeDeclarations = [];
6480
+ const varyingDeclarations = [];
6481
+ const vertexAssignments = [];
6482
+ for (const [name, propertyTypeName] of Object.entries(uniformLayout)) {
6483
+ const glslType = resolveTypeInfo(propertyTypeName).glslType;
6484
+ uniforms[`u_${name}`] = { value: null };
6485
+ uniformDeclarations.push(`uniform ${glslType} u_${name};`);
6486
+ }
6487
+ for (const [name, propertyTypeName] of Object.entries(varyingLayout)) {
6488
+ const glslType = resolveTypeInfo(propertyTypeName).glslType;
6489
+ attributeDeclarations.push(`attribute ${glslType} a_${name};`);
6490
+ varyingDeclarations.push(`varying ${glslType} v_${name};`);
6491
+ vertexAssignments.push(`v_${name} = a_${name};`);
6492
+ }
6493
+ const vertexShader = `
6494
+ ${attributeDeclarations.join("\n")}
6495
+
6496
+ ${uniformDeclarations.join("\n")}
6497
+
6498
+ ${varyingDeclarations.join("\n")}
6499
+ varying vec3 v_position;
6500
+ varying vec2 v_uv;
6501
+
6502
+ void main() {
6503
+ if (a_visibility < 0.5) {
6504
+ gl_Position = vec4(2.0, 2.0, 2.0, 2.0);
6505
+ return;
6506
+ }
6507
+
6508
+ ${vertexAssignments.join("\n")}
6509
+
6510
+ v_position = position;
6511
+ v_uv = (a_uvTransform * vec3(uv, 1.0)).xy;
6512
+
6513
+ gl_Position = projectionMatrix * modelViewMatrix * a_instanceTransform * vec4(position, 1.0);
6514
+ }
6515
+ `;
6516
+ const fragmentShader = `
6517
+ ${uniformDeclarations.join("\n")}
6518
+
6519
+ ${varyingDeclarations.join("\n")}
6520
+ varying vec3 v_position;
6521
+ varying vec2 v_uv;
6522
+
6523
+ #include <alphahash_pars_fragment>
6524
+
6525
+ // Source have to define 'draw' function
6526
+ ${source}
6527
+
6528
+ void main() {
6529
+ vec4 diffuseColor = draw();
6530
+
6531
+ #ifdef USE_ALPHATEST
6532
+ if (diffuseColor.a < v_alphaTest) {
6533
+ discard;
6534
+ }
6535
+ #endif
6536
+
6537
+ #ifdef USE_ALPHAHASH
6538
+ if (diffuseColor.a < getAlphaHashThreshold(v_position)) {
6539
+ discard;
6540
+ }
6541
+ #endif
6542
+
6543
+ gl_FragColor = linearToOutputTexel(diffuseColor);
6544
+ }
6545
+ `;
6546
+ console.log(vertexShader);
6547
+ console.log(fragmentShader);
6548
+ console.log(uniforms);
6549
+ return new ShaderMaterial({
6550
+ uniforms,
6551
+ vertexShader,
6552
+ fragmentShader,
6553
+ transparent: transparency === UITransparencyMode.BLEND,
6554
+ alphaTest: transparency === UITransparencyMode.CLIP ? ALPHA_TEST : 0.0,
6555
+ alphaHash: transparency === UITransparencyMode.HASH,
6556
+ });
6557
+ }
6558
+ class UIGenericInstancedPlane extends Mesh {
6559
+ constructor(source, layout, transparency = UITransparencyMode.CLIP, capacity = CAPACITY_STEP) {
6560
+ const uniformLayout = {};
6561
+ const varyingLayout = {
6562
+ instanceTransform: "Matrix4",
6563
+ uvTransform: "Matrix3",
6564
+ ...(transparency === UITransparencyMode.CLIP
6565
+ ? { alphaTest: "number" }
6566
+ : {}),
6567
+ };
6568
+ for (const [name, propertyTypeName] of Object.entries(layout)) {
6569
+ (resolveTypeInfo(propertyTypeName).instantiable
6570
+ ? varyingLayout
6571
+ : uniformLayout)[name] = propertyTypeName;
6572
+ }
6573
+ const instancedGeometry = INSTANCED_GEOMETRY.clone();
6574
+ const shaderMaterial = buildMaterial(source, uniformLayout, varyingLayout, transparency);
6575
+ super(instancedGeometry, shaderMaterial);
6576
+ this.handlerToDescriptor = new Map();
6577
+ this.lastHandler = 0;
6578
+ this.capacity = 0;
6579
+ this.propertyBuffers = new Map();
6580
+ this._private_instancedGeometry = instancedGeometry;
6581
+ this._private_instancedGeometry.instanceCount = 0;
6582
+ this._private_shaderMaterial = shaderMaterial;
6583
+ this.capacity = Math.max(capacity, CAPACITY_STEP);
6584
+ for (const [name, propertyTypeName] of Object.entries(varyingLayout)) {
6585
+ const attribute = buildEmptyInstancedBufferAttribute(propertyTypeName, this.capacity);
6586
+ this._private_instancedGeometry.setAttribute(`a_${name}`, attribute);
6587
+ this.propertyBuffers.set(`a_${name}`, attribute);
6588
+ }
6589
+ }
6590
+ createInstances(count) {
6591
+ const handler = this.lastHandler++;
6592
+ if (this._private_instancedGeometry.instanceCount + count > this.capacity) {
6593
+ this._private_resizeGeometry(Math.ceil((this.capacity + count) / CAPACITY_STEP) * CAPACITY_STEP);
6594
+ }
6595
+ this.handlerToDescriptor.set(handler, {
6596
+ firstIndex: this._private_instancedGeometry.instanceCount,
6597
+ count,
6598
+ });
6599
+ this._private_instancedGeometry.instanceCount += count;
6600
+ return handler;
6601
+ }
6602
+ destroyInstances(handler) {
6603
+ const releasedDescriptor = this.handlerToDescriptor.get(handler);
6604
+ if (releasedDescriptor === undefined) {
6605
+ throw new Error(`No range found for userIndex: ${handler}`);
6606
+ }
6607
+ this.handlerToDescriptor.delete(handler);
6608
+ const values = Array.from(this.handlerToDescriptor.values());
6609
+ const edge = releasedDescriptor.firstIndex + releasedDescriptor.count;
6610
+ let replacementDescriptor;
6611
+ for (let i = values.length - 1; i > edge; i--) {
6612
+ const descriptor = values[i];
6613
+ if (descriptor.count === releasedDescriptor.count) {
6614
+ replacementDescriptor = descriptor;
6615
+ break;
6616
+ }
6617
+ }
6618
+ if (replacementDescriptor) {
6619
+ this._private_copyRangeData(replacementDescriptor, releasedDescriptor);
6620
+ replacementDescriptor.firstIndex = releasedDescriptor.firstIndex;
6621
+ this._private_shiftRangesDown(replacementDescriptor.firstIndex + replacementDescriptor.count, replacementDescriptor.count);
6622
+ }
6623
+ else {
6624
+ this._private_shiftRangesDown(releasedDescriptor.firstIndex + releasedDescriptor.count, releasedDescriptor.count);
6625
+ }
6626
+ this._private_instancedGeometry.instanceCount -= releasedDescriptor.count;
6627
+ }
6628
+ updateProperties(handler, offset, instancesProperties) {
6629
+ assertValidNonNegativeNumber(offset, "UIGenericInstancedPlane updateProperties offset");
6630
+ const descriptor = this._private_resolveDescriptor(handler);
6631
+ if (instancesProperties.length + offset > descriptor.count) {
6632
+ throw new Error(`Too many instances for handler: ${handler}, offset: ${offset}, and count: ${instancesProperties.length}`);
6633
+ }
6634
+ for (let i = 0; i < instancesProperties.length; i++) {
6635
+ const instanceProperties = instancesProperties[i];
6636
+ const instanceOffset = descriptor.firstIndex + offset + i;
6637
+ for (const [name, value] of Object.entries(instanceProperties)) {
6638
+ if (resolveTypeInfo(value).instantiable) {
6639
+ const attribute = this._private_resolveBufferAttribute(name);
6640
+ const itemOffset = instanceOffset * attribute.itemSize;
6641
+ udpateProperty(value, attribute, itemOffset);
6642
+ }
6643
+ else {
6644
+ const uniform = this._private_resolveUniform(name);
6645
+ uniform.value = value;
6646
+ this._private_shaderMaterial.uniformsNeedUpdate = true;
6647
+ }
6648
+ }
6649
+ }
6650
+ }
6651
+ updateTransforms(handler, offset, instancesTransforms) {
6652
+ assertValidNonNegativeNumber(offset, "UIGenericInstancedPlane updateTransforms offset");
6653
+ const descriptor = this._private_resolveDescriptor(handler);
6654
+ if (instancesTransforms.length + offset > descriptor.count) {
6655
+ throw new Error(`Too many instances for handler: ${handler}, offset: ${offset}, and count: ${instancesTransforms.length}`);
6656
+ }
6657
+ for (let i = 0; i < instancesTransforms.length; i++) {
6658
+ const attribute = this._private_resolveBufferAttribute("instanceTransform");
6659
+ const instanceOffset = descriptor.firstIndex + offset + i;
6660
+ const array = attribute.array;
6661
+ const itemOffset = instanceOffset * attribute.itemSize;
6662
+ const elements = instancesTransforms[i].elements;
6663
+ for (let j = 0; j < elements.length; j++) {
6664
+ array[itemOffset + j] = elements[j];
6665
+ }
6666
+ attribute.needsUpdate = true;
6667
+ }
6668
+ }
6669
+ updateUVTransforms(handler, offset, uvTransforms) {
6670
+ assertValidNonNegativeNumber(offset, "UIGenericInstancedPlane updateUVTransforms offset");
6671
+ const descriptor = this._private_resolveDescriptor(handler);
6672
+ if (uvTransforms.length + offset > descriptor.count) {
6673
+ throw new Error(`Too many instances for handler: ${handler}, offset: ${offset}, and count: ${uvTransforms.length}`);
6674
+ }
6675
+ for (let i = 0; i < uvTransforms.length; i++) {
6676
+ const attribute = this._private_resolveBufferAttribute("uvTransform");
6677
+ const instanceOffset = descriptor.firstIndex + offset + i;
6678
+ const array = attribute.array;
6679
+ const itemOffset = instanceOffset * attribute.itemSize;
6680
+ const elements = uvTransforms[i].elements;
6681
+ for (let j = 0; j < elements.length; j++) {
6682
+ array[itemOffset + j] = elements[j];
6683
+ }
6684
+ attribute.needsUpdate = true;
6685
+ }
6686
+ }
6687
+ updateVisibility(handler, offset, instancesVisibility) {
6688
+ assertValidNonNegativeNumber(offset, "UIGenericInstancedPlane updateVisibility offset");
6689
+ const descriptor = this._private_resolveDescriptor(handler);
6690
+ if (instancesVisibility.length + offset > descriptor.count) {
6691
+ throw new Error(`Too many instances for handler: ${handler}, offset: ${offset}, and count: ${instancesVisibility.length}`);
6692
+ }
6693
+ for (let i = 0; i < instancesVisibility.length; i++) {
6694
+ const attribute = this._private_resolveBufferAttribute("visibility");
6695
+ const instanceOffset = descriptor.firstIndex + offset + i;
6696
+ const array = attribute.array;
6697
+ const itemOffset = instanceOffset * attribute.itemSize;
6698
+ array[itemOffset] = instancesVisibility[i] ? 1 : 0;
6699
+ attribute.needsUpdate = true;
6700
+ }
6701
+ }
6702
+ destroy() {
6703
+ this._private_instancedGeometry.dispose();
6704
+ this._private_shaderMaterial.dispose();
6705
+ }
6706
+ _private_resolveDescriptor(handler) {
6707
+ const descriptor = this.handlerToDescriptor.get(handler);
6708
+ if (descriptor === undefined) {
6709
+ throw new Error(`No active range found for handler: ${handler}`);
6710
+ }
6711
+ return descriptor;
6712
+ }
6713
+ _private_resolveBufferAttribute(name) {
6714
+ const attribute = this.propertyBuffers.get(`a_${name}`);
6715
+ if (attribute === undefined) {
6716
+ throw new Error(`No attribute found for property: ${name} (a_${name})`);
6717
+ }
6718
+ return attribute;
6719
+ }
6720
+ _private_resolveUniform(name) {
6721
+ const uniform = this._private_shaderMaterial.uniforms[`u_${name}`];
6722
+ if (uniform === undefined) {
6723
+ throw new Error(`No uniform found for handler: ${name}`);
6724
+ }
6725
+ return uniform;
6726
+ }
6727
+ _private_resizeGeometry(newCapacity) {
6728
+ for (const [name, oldAttribute] of this.propertyBuffers.entries()) {
6729
+ const itemSize = oldAttribute.itemSize;
6730
+ const newArray = new Float32Array(newCapacity * itemSize);
6731
+ newArray.set(oldAttribute.array);
6732
+ const newAttribute = new InstancedBufferAttribute(newArray, itemSize);
6733
+ this._private_instancedGeometry.setAttribute(`a_${name}`, newAttribute);
6734
+ this.propertyBuffers.set(`a_${name}`, newAttribute);
6735
+ }
6736
+ this.capacity = newCapacity;
6737
+ }
6738
+ _private_copyRangeData(sourceRange, targetRange) {
6739
+ for (const attribute of this.propertyBuffers.values()) {
6740
+ const array = attribute.array;
6741
+ const itemSize = attribute.itemSize;
6742
+ const sourceStart = sourceRange.firstIndex * itemSize;
6743
+ const targetStart = targetRange.firstIndex * itemSize;
6744
+ const dataLength = sourceRange.count * itemSize;
6745
+ for (let i = 0; i < dataLength; i++) {
6746
+ array[targetStart + i] = array[sourceStart + i];
6747
+ }
6748
+ attribute.needsUpdate = true;
6749
+ }
6750
+ }
6751
+ _private_shiftRangesDown(startIndex, shiftAmount) {
6752
+ for (const descriptor of this.handlerToDescriptor.values()) {
6753
+ if (descriptor.firstIndex >= startIndex) {
6754
+ descriptor.firstIndex -= shiftAmount;
6755
+ }
6756
+ }
6757
+ for (const attribute of this.propertyBuffers.values()) {
6758
+ const array = attribute.array;
6759
+ const itemSize = attribute.itemSize;
6760
+ const startByteIndex = startIndex * itemSize;
6761
+ const endByteIndex = this._private_instancedGeometry.instanceCount * itemSize;
6762
+ const shiftByteAmount = shiftAmount * itemSize;
6763
+ for (let i = startByteIndex; i < endByteIndex - shiftByteAmount; i++) {
6764
+ array[i] = array[i + shiftByteAmount];
6765
+ }
6766
+ attribute.needsUpdate = true;
6767
+ }
6768
+ }
6769
+ }
6770
+
6047
6771
  function isUITextSpan(obj) {
6048
6772
  return (obj !== null &&
6049
6773
  typeof obj === "object" &&
@@ -6052,5 +6776,5 @@ function isUITextSpan(obj) {
6052
6776
  (!("style" in obj) || isUITextStyle(obj.style)));
6053
6777
  }
6054
6778
 
6055
- export { UIAnchor, UIAnchorMode, UIAspectConstraint, UIConstraint, UIConstraint2DBuilder, UICoverConstraintBuilder, UICustomConstraint, UIDummy, UIElement, UIElementEvent, UIExpression, UIFitConstraintBuilder, UIFullscreenLayer, UIHeightConstraint, UIHorizontalDistanceConstraint, UIHorizontalProportionConstraint, UIImage, UILayer, UILayerEvent, UIMicro, UIMode, UINineSlice, UIOrientation, UIPriority, UIProgress, UIRelation, UIScene, UISceneUpdateMode, UISingleParameterConstraint, UIText, UIVerticalDistanceConstraint, UIVerticalProportionConstraint, UIWidthConstraint, convertPriority, convertRelation, isUITextSpan, isUITextStyle, resolveOrientation, resolvePadding, resolvePriority, resolveRelation, resolveTextStyle };
6779
+ export { UIAnchor, UIAspectConstraint, UIColor, UIColorEvent, UIConstraint, UIConstraint2DBuilder, UICoverConstraintBuilder, UICustomConstraint, UIDummy, UIElement, UIExpression, UIFitConstraintBuilder, UIFullscreenLayer, UIGenericInstancedPlane, UIHeightConstraint, UIHorizontalDistanceConstraint, UIHorizontalProportionConstraint, UIImage, UIInputEvent, UILayer, UILayerEvent, UIMicro, UIMicroAnchorMode, UIMode, UINineSlice, UIOrientation, UIPriority, UIProgress, UIProgressMaskFunction, UIRelation, UIScene, UISceneUpdateMode, UISingleParameterConstraint, UIText, UITransparencyMode, UIVerticalDistanceConstraint, UIVerticalProportionConstraint, UIWidthConstraint, convertPriority, convertRelation, isUITextSpan, isUITextStyle, resolveOrientation, resolvePriority, resolveRelation, resolveTextPadding, resolveTextStyle };
6056
6780
  //# sourceMappingURL=index.js.map