laymur 0.12.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/constraints/UIConstraint.d.ts +1 -1
  2. package/dist/elements/UIAnchor/UIAnchor.d.ts +1 -1
  3. package/dist/elements/UIAnimatedImage/UIAnimatedImage.Internal.d.ts +3 -3
  4. package/dist/elements/UIAnimatedImage/UIAnimatedImage.d.ts +16 -12
  5. package/dist/elements/UIElement/UIElement.Internal.d.ts +1 -1
  6. package/dist/elements/UIElement/UIElement.d.ts +4 -4
  7. package/dist/elements/UIGraphics/UIGraphics.Internal.d.ts +4 -0
  8. package/dist/elements/UIGraphics/UIGraphics.d.ts +11 -7
  9. package/dist/elements/UIImage/UIImage.d.ts +6 -2
  10. package/dist/elements/UIInputDummy/UIInputDummy.Internal.d.ts +1 -1
  11. package/dist/elements/UIInputDummy/UIInputDummy.d.ts +3 -3
  12. package/dist/elements/UINineSlice/UINineSlice.d.ts +18 -7
  13. package/dist/elements/UIProgress/UIProgress.d.ts +13 -5
  14. package/dist/elements/UIScene/UIScene.Internal.d.ts +1 -1
  15. package/dist/elements/UIScene/UIScene.d.ts +18 -11
  16. package/dist/elements/UIText/UIText.d.ts +12 -4
  17. package/dist/index.d.ts +1 -1
  18. package/dist/index.js +836 -556
  19. package/dist/index.js.map +1 -1
  20. package/dist/index.min.js +1 -1
  21. package/dist/index.min.js.map +1 -1
  22. package/dist/layers/UIFullscreenLayer/UIFullscreenLayer.d.ts +5 -3
  23. package/dist/layers/UILayer/UILayer.d.ts +1 -1
  24. package/dist/miscellaneous/color/UIColor.d.ts +37 -1
  25. package/dist/miscellaneous/generic-plane/{UIGenericInstancedPlane.Internal.d.ts → UIGenericInstancedPlane/UIGenericInstancedPlane.Internal.d.ts} +6 -6
  26. package/dist/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.d.ts +1 -0
  27. package/dist/miscellaneous/generic-plane/UIGenericPlane/UIGenericPlane.Internal.d.ts +6 -0
  28. package/dist/miscellaneous/generic-plane/UIGenericPlane/UIGenericPlane.d.ts +1 -0
  29. package/dist/miscellaneous/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.Internal.d.ts +12 -0
  30. package/dist/miscellaneous/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.d.ts +1 -0
  31. package/dist/miscellaneous/generic-plane/shared.d.ts +21 -10
  32. package/dist/miscellaneous/insets/UIInsets.Internal.d.ts +1 -1
  33. package/dist/miscellaneous/insets/UIInsets.d.ts +2 -0
  34. package/dist/wrappers/{UISceneWrapper.Internal.d.ts → UISceneWrapper/UISceneWrapper.Internal.d.ts} +4 -4
  35. package/dist/wrappers/{UISceneWrapper.d.ts → UISceneWrapper/UISceneWrapper.d.ts} +7 -6
  36. package/dist/wrappers/{UISolverWrapper.Internal.d.ts → UISolverWrapper/UISolverWrapper.Internal.d.ts} +3 -3
  37. package/dist/wrappers/{UISolverWrapper.d.ts → UISolverWrapper/UISolverWrapper.d.ts} +3 -3
  38. package/package.json +1 -1
  39. package/dist/miscellaneous/generic-plane/UIGenericInstancedPlane.d.ts +0 -36
  40. package/dist/miscellaneous/generic-plane/UIGenericPlane.Internal.d.ts +0 -5
  41. package/dist/miscellaneous/generic-plane/UIGenericPlane.d.ts +0 -23
  42. package/dist/miscellaneous/generic-plane/UIGenericPlaneRegistry.Internal.d.ts +0 -6
  43. package/dist/miscellaneous/generic-plane/UIGenericPlaneRegistry.d.ts +0 -27
  44. /package/dist/wrappers/{UIInputWrapper.Internal.d.ts → UIInputWrapper/UIInputWrapper.Internal.d.ts} +0 -0
  45. /package/dist/wrappers/{UIInputWrapper.d.ts → UIInputWrapper/UIInputWrapper.d.ts} +0 -0
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Color, MathUtils, Vector4, Texture, Vector2, Vector3, Matrix3, Matrix4, PlaneGeometry, InstancedBufferGeometry, ShaderMaterial, InstancedBufferAttribute, Mesh, Scene, OrthographicCamera, Quaternion, CanvasTexture, SRGBColorSpace, LinearFilter, WebGLRenderTarget, UnsignedByteType, RGBAFormat, PerspectiveCamera, Ray } from 'three';
1
+ import { MathUtils, Color, Vector4, Texture, Vector2, Vector3, Matrix3, Matrix4, PlaneGeometry, InstancedBufferGeometry, ShaderMaterial, InstancedBufferAttribute, Mesh, Scene, OrthographicCamera, Quaternion, CanvasTexture, SRGBColorSpace, LinearFilter, WebGLRenderTarget, UnsignedByteType, RGBAFormat, PerspectiveCamera, Ray } from 'three';
2
2
 
3
3
  class t{constructor(t,i,r=0){this.t=new WeakMap,this.i=new Map,void 0!==t&&(void 0===i?this.i.set(t,r):this.t.set(i,new Map([[t,r]])));}insert(t,i,r=0){if(void 0===i){if(this.i.has(t))return;return void this.i.set(t,r)}const s=this.t.get(i);void 0===s?this.t.set(i,new Map([[t,r]])):s.has(t)||s.set(t,r);}remove(t,i){if(void 0===i)return void this.i.delete(t);const r=this.t.get(i);void 0!==r&&(r.delete(t),0===r.size&&this.t.delete(i));}has(t,i){if(void 0===i)return this.i.has(t);const r=this.t.get(i);return void 0!==r&&r.has(t)}getPriority(t,i){if(void 0===i)return this.i.get(t);const r=this.t.get(i);return void 0!==r?r.get(t):void 0}}class i{constructor(){this.o=new Map;}on(t,i,r,s=0){return this.h(t,false,s,i,r),this}once(t,i,r,s=0){return this.h(t,true,s,i,r),this}off(t,i,r){const s=this.o.get(t);if(void 0===s)return this;s.u&&(s.u=false,s.v=s.v.slice());const o=s.v;if(0===o.length)return this.o.delete(t),this;if(void 0===i){this.o.delete(t);for(let t=0;o.length>t;t++){const i=o[t];s.l.remove(i._,i.p);}return this}{const e=o.length;if(o[0]._===i&&o[0].p===r)return 1===e?this.o.delete(t):o.shift(),this;const n=e-1;if(o[n]._===i&&o[n].p===r)return o.pop(),this;if(10>e||o[0].M===o[n].M)for(let t=1;n>t;t++){const s=o[t];if(s._===i&&s.p===r)return o.splice(t,1),this}else {const t=s.l.getPriority(i,r);if(void 0===t)return this;let e=0,n=o.length-1;for(;n>=e;){const i=e+n>>>1;t>o[i].M?e=i+1:n=i-1;}const c=e;for(n=o.length-1;n>=e;){const i=e+n>>>1;o[i].M>t?n=i-1:e=i+1;}const h=n;for(let t=c;h>=t;t++)if(o[t]._===i&&o[t].p===r)return o.splice(t,1),this}}return this}emit(t,...i){const r=this.o.get(t);if(void 0===r)return false;if(0===r.v.length)return false;r.u?r.v=r.v.slice():r.u=true;const s=r.v;let o=false;for(let t=0;s.length>t;t++){const r=s[t];r._.apply(r.p,i),r.k&&(o=true,r.m=true);}const e=this.o.get(t);if(void 0===e)return true;e.v===s&&(e.u=false);const n=e.v;if(o){let i=0;for(let t=0;n.length>t;t++){const r=n[t];r.m?e.l.remove(r._,r.p):n[i++]=r;}0===i?this.o.delete(t):n.length=i;}return true}h(i,r,s,o,e){let n=this.o.get(i);if(void 0===n)return void this.o.set(i,{v:[{_:o,p:e,M:s,k:r,m:false}],u:false,l:new t(o,e,s)});if(n.l.has(o,e))throw Error("Event listener already exists");n.l.insert(o,e,s);const c={_:o,p:e,M:s,k:r,m:false};n.u&&(n.u=false,n.v=n.v.slice());{const t=n.v,i=c.M;if(0===t.length||i>=t[t.length-1].M)return void t.push(c);if(t[0].M>=i)return void t.unshift(c);{let r=0,s=t.length;for(;s>r;){const o=r+s>>>1;i>t[o].M?r=o+1:s=o;}t.splice(r,0,c);}}}}
4
4
 
@@ -1598,7 +1598,7 @@ function convertPriority(priority) {
1598
1598
  case UIPriority.P7:
1599
1599
  return Strength.create(0, 0, 1);
1600
1600
  default:
1601
- throw new Error(`convertPriority: invalid priority`);
1601
+ throw new Error(`convertPriority.priority: invalid priority`);
1602
1602
  }
1603
1603
  }
1604
1604
  /**
@@ -1635,7 +1635,7 @@ class UIInputWrapper {
1635
1635
  destroyInputCatcher(handler) {
1636
1636
  const index = this._private_catchers.findIndex((item) => item.handler === handler);
1637
1637
  if (index === -1) {
1638
- throw new Error("UIInputWrapper.destroyInputCatcher: handler not found");
1638
+ throw new Error("UIInputWrapper.destroyInputCatcher.handler: handler not found");
1639
1639
  }
1640
1640
  this._private_catchers.splice(index, 1);
1641
1641
  }
@@ -1643,14 +1643,14 @@ class UIInputWrapper {
1643
1643
  this._private_ensureSorted();
1644
1644
  const found = this._private_catchers.find((item) => item.handler === handler);
1645
1645
  if (!found) {
1646
- throw new Error("UIInputWrapper.getZIndex: handler not found");
1646
+ throw new Error("UIInputWrapper.getZIndex.handler: handler not found");
1647
1647
  }
1648
1648
  return found.zIndex;
1649
1649
  }
1650
1650
  setZIndex(handler, zIndex) {
1651
1651
  const found = this._private_catchers.find((item) => item.handler === handler);
1652
1652
  if (!found) {
1653
- throw new Error("UIInputWrapper.setZIndex: handler not found");
1653
+ throw new Error("UIInputWrapper.setZIndex.handler: handler not found");
1654
1654
  }
1655
1655
  if (found.zIndex !== zIndex) {
1656
1656
  found.zIndex = zIndex;
@@ -1661,14 +1661,14 @@ class UIInputWrapper {
1661
1661
  getActive(handler) {
1662
1662
  const found = this._private_catchers.find((item) => item.handler === handler);
1663
1663
  if (!found) {
1664
- throw new Error("UIInputWrapper.getActive: handler not found");
1664
+ throw new Error("UIInputWrapper.getActive.handler: handler not found");
1665
1665
  }
1666
1666
  return found.active;
1667
1667
  }
1668
1668
  setActive(handler, active) {
1669
1669
  const found = this._private_catchers.find((item) => item.handler === handler);
1670
1670
  if (!found) {
1671
- throw new Error("UIInputWrapper.setActive: handler not found");
1671
+ throw new Error("UIInputWrapper.setActive.handler: handler not found");
1672
1672
  }
1673
1673
  if (found.active !== active) {
1674
1674
  found.active = active;
@@ -1717,17 +1717,6 @@ class UIInputWrapper {
1717
1717
  }
1718
1718
  }
1719
1719
 
1720
- /** Transparency rendering modes */
1721
- var UITransparencyMode;
1722
- (function (UITransparencyMode) {
1723
- /** Binary transparency. Best performance. */
1724
- UITransparencyMode[UITransparencyMode["CLIP"] = 0] = "CLIP";
1725
- /** Dithered transparency. Good performance. */
1726
- UITransparencyMode[UITransparencyMode["HASH"] = 1] = "HASH";
1727
- /** Alpha blending. Best quality, requires depth sorting. */
1728
- UITransparencyMode[UITransparencyMode["BLEND"] = 2] = "BLEND";
1729
- })(UITransparencyMode || (UITransparencyMode = {}));
1730
-
1731
1720
  function SRGBToLinear( c ) {
1732
1721
 
1733
1722
  return ( c < 0.04045 ) ? c * 0.0773993808 : Math.pow( c * 0.9478672986 + 0.0521327014, 2.4 );
@@ -1794,39 +1783,8 @@ class UIColor {
1794
1783
  this._private_dirtyInternal = false;
1795
1784
  this._private_rgbDirty = false;
1796
1785
  this._private_hslDirty = false;
1797
- if (args.length >= 3 && typeof args[0] === "number") {
1798
- const [r, g, b, a = 1] = args;
1799
- this._private_rInternal = r;
1800
- this._private_gInternal = g;
1801
- this._private_bInternal = b;
1802
- this._private_aInternal = a;
1803
- }
1804
- else if (args.length >= 1 && args[0] !== undefined) {
1805
- const [firstArgument, a = 1] = args;
1806
- if (typeof firstArgument === "string") {
1807
- if (firstArgument.startsWith("#")) {
1808
- this.setHexString(firstArgument);
1809
- }
1810
- else {
1811
- this.setColorName(firstArgument, a);
1812
- }
1813
- }
1814
- else if (firstArgument instanceof UIColor) {
1815
- firstArgument._private_ensureRGBUpdatedFromHSL();
1816
- this._private_rInternal = firstArgument._private_rInternal;
1817
- this._private_gInternal = firstArgument._private_gInternal;
1818
- this._private_bInternal = firstArgument._private_bInternal;
1819
- this._private_aInternal = firstArgument._private_aInternal;
1820
- }
1821
- else if (firstArgument instanceof Color) {
1822
- this._private_rInternal = firstArgument.r;
1823
- this._private_gInternal = firstArgument.g;
1824
- this._private_bInternal = firstArgument.b;
1825
- this._private_aInternal = a;
1826
- }
1827
- else if (typeof firstArgument === "number") {
1828
- this.setHexRGB(firstArgument, a);
1829
- }
1786
+ if (args.length > 0) {
1787
+ this.set(...args);
1830
1788
  }
1831
1789
  }
1832
1790
  /** Black (0x000000) */
@@ -2098,12 +2056,37 @@ class UIColor {
2098
2056
  setDirtyFalse() {
2099
2057
  this._private_dirtyInternal = false;
2100
2058
  }
2101
- /** Sets RGB(A) components */
2102
- set(r, g, b, a = this._private_aInternal) {
2103
- assertValidNumber(r, "UIColor.set.r");
2104
- assertValidNumber(g, "UIColor.set.g");
2105
- assertValidNumber(b, "UIColor.set.b");
2106
- assertValidNumber(a, "UIColor.set.a");
2059
+ set(...args) {
2060
+ if (args.length === 0 || args[0] === undefined) {
2061
+ return this.setRGBA(1, 1, 1, 1);
2062
+ }
2063
+ if (args.length >= 3 && typeof args[0] === "number") {
2064
+ const [r, g, b, a = 1] = args;
2065
+ return this.setRGBA(r, g, b, a);
2066
+ }
2067
+ const [firstArgument, a = 1] = args;
2068
+ if (typeof firstArgument === "string") {
2069
+ return firstArgument.startsWith("#")
2070
+ ? this.setHexString(firstArgument)
2071
+ : this.setColorName(firstArgument, a);
2072
+ }
2073
+ if (firstArgument instanceof UIColor) {
2074
+ return this.copy(firstArgument);
2075
+ }
2076
+ if (firstArgument instanceof Color) {
2077
+ return this.setThreeColor(firstArgument, a);
2078
+ }
2079
+ if (typeof firstArgument === "number") {
2080
+ return this.setHexRGB(firstArgument, a);
2081
+ }
2082
+ throw new Error("UIColor.set: cannot create color from provided arguments");
2083
+ }
2084
+ /** Sets RGBA components directly */
2085
+ setRGBA(r, g, b, a = this._private_aInternal) {
2086
+ assertValidNumber(r, "UIColor.setRGBA.r");
2087
+ assertValidNumber(g, "UIColor.setRGBA.g");
2088
+ assertValidNumber(b, "UIColor.setRGBA.b");
2089
+ assertValidNumber(a, "UIColor.setRGBA.a");
2107
2090
  r = MathUtils.clamp(r, 0, 1);
2108
2091
  g = MathUtils.clamp(g, 0, 1);
2109
2092
  b = MathUtils.clamp(b, 0, 1);
@@ -2418,63 +2401,162 @@ class UIColor {
2418
2401
  }
2419
2402
 
2420
2403
  const DEFAULT_ALPHA_TEST = 0.5;
2404
+ const GLSL_TYPE_INFO_FLOAT = Object.freeze({
2405
+ glslTypeName: "float",
2406
+ bufferSize: 1,
2407
+ instantiable: true,
2408
+ });
2409
+ const GLSL_TYPE_INFO_SAMPLER2D = Object.freeze({
2410
+ glslTypeName: "sampler2D",
2411
+ bufferSize: -1,
2412
+ instantiable: false,
2413
+ });
2414
+ const GLSL_TYPE_INFO_VEC2 = Object.freeze({
2415
+ glslTypeName: "vec2",
2416
+ bufferSize: 2,
2417
+ instantiable: true,
2418
+ });
2419
+ const GLSL_TYPE_INFO_VEC3 = Object.freeze({
2420
+ glslTypeName: "vec3",
2421
+ bufferSize: 3,
2422
+ instantiable: true,
2423
+ });
2424
+ const GLSL_TYPE_INFO_VEC4 = Object.freeze({
2425
+ glslTypeName: "vec4",
2426
+ bufferSize: 4,
2427
+ instantiable: true,
2428
+ });
2429
+ const GLSL_TYPE_INFO_MAT3 = Object.freeze({
2430
+ glslTypeName: "mat3",
2431
+ bufferSize: 9,
2432
+ instantiable: true,
2433
+ });
2434
+ const GLSL_TYPE_INFO_MAT4 = Object.freeze({
2435
+ glslTypeName: "mat4",
2436
+ bufferSize: 16,
2437
+ instantiable: true,
2438
+ });
2421
2439
  function resolveGLSLTypeInfo(value) {
2440
+ if (typeof value === "string") {
2441
+ switch (value) {
2442
+ case "number":
2443
+ return GLSL_TYPE_INFO_FLOAT;
2444
+ case "Texture":
2445
+ return GLSL_TYPE_INFO_SAMPLER2D;
2446
+ case "UIColor":
2447
+ return GLSL_TYPE_INFO_VEC4;
2448
+ case "Vector2":
2449
+ return GLSL_TYPE_INFO_VEC2;
2450
+ case "Vector3":
2451
+ return GLSL_TYPE_INFO_VEC3;
2452
+ case "Vector4":
2453
+ return GLSL_TYPE_INFO_VEC4;
2454
+ case "Matrix3":
2455
+ return GLSL_TYPE_INFO_MAT3;
2456
+ case "Matrix4":
2457
+ return GLSL_TYPE_INFO_MAT4;
2458
+ default:
2459
+ throw new Error(`resolveGLSLTypeInfo.value: unsupported property type name`);
2460
+ }
2461
+ }
2462
+ if (typeof value === "function") {
2463
+ if (value === Number) {
2464
+ return GLSL_TYPE_INFO_FLOAT;
2465
+ }
2466
+ if (value === Texture) {
2467
+ return GLSL_TYPE_INFO_SAMPLER2D;
2468
+ }
2469
+ if (value === UIColor) {
2470
+ return GLSL_TYPE_INFO_VEC4;
2471
+ }
2472
+ if (value === Vector2) {
2473
+ return GLSL_TYPE_INFO_VEC2;
2474
+ }
2475
+ if (value === Vector3) {
2476
+ return GLSL_TYPE_INFO_VEC3;
2477
+ }
2478
+ if (value === Vector4) {
2479
+ return GLSL_TYPE_INFO_VEC4;
2480
+ }
2481
+ if (value === Matrix3) {
2482
+ return GLSL_TYPE_INFO_MAT3;
2483
+ }
2484
+ if (value === Matrix4) {
2485
+ return GLSL_TYPE_INFO_MAT4;
2486
+ }
2487
+ throw new Error(`resolveGLSLTypeInfo.value: unsupported property type constructor`);
2488
+ }
2422
2489
  if (typeof value === "number") {
2423
- return { glslType: "float", instantiable: true, itemSize: 1 };
2490
+ return GLSL_TYPE_INFO_FLOAT;
2424
2491
  }
2425
2492
  if (value instanceof Texture) {
2426
- return { glslType: "sampler2D", instantiable: false, itemSize: -1 };
2493
+ return GLSL_TYPE_INFO_SAMPLER2D;
2427
2494
  }
2428
2495
  if (value instanceof UIColor) {
2429
- return { glslType: "vec4", instantiable: true, itemSize: 4 };
2496
+ return GLSL_TYPE_INFO_VEC4;
2430
2497
  }
2431
2498
  if (value instanceof Vector2) {
2432
- return { glslType: "vec2", instantiable: true, itemSize: 2 };
2499
+ return GLSL_TYPE_INFO_VEC2;
2433
2500
  }
2434
2501
  if (value instanceof Vector3) {
2435
- return { glslType: "vec3", instantiable: true, itemSize: 3 };
2502
+ return GLSL_TYPE_INFO_VEC3;
2436
2503
  }
2437
2504
  if (value instanceof Vector4) {
2438
- return { glslType: "vec4", instantiable: true, itemSize: 4 };
2505
+ return GLSL_TYPE_INFO_VEC4;
2439
2506
  }
2440
2507
  if (value instanceof Matrix3) {
2441
- return { glslType: "mat3", instantiable: true, itemSize: 9 };
2508
+ return GLSL_TYPE_INFO_MAT3;
2442
2509
  }
2443
2510
  if (value instanceof Matrix4) {
2444
- return { glslType: "mat4", instantiable: true, itemSize: 16 };
2511
+ return GLSL_TYPE_INFO_MAT4;
2445
2512
  }
2446
2513
  throw new Error(`resolveGLSLTypeInfo.value: unsupported property type`);
2447
2514
  }
2448
- function resolveUniform(name, material) {
2515
+ function resolvePropertyUniform(name, material) {
2449
2516
  const uniform = material.uniforms[`p_${name}`];
2450
2517
  if (uniform === undefined) {
2451
- throw new Error(`resolveUniform.name: unknown uniform`);
2518
+ throw new Error(`resolvePropertyUniform.name: unknown uniform`);
2452
2519
  }
2453
2520
  return uniform;
2454
2521
  }
2455
- function arePropertiesCompatible(currentProperties, newProperties) {
2456
- const currentKeys = Object.keys(currentProperties);
2457
- const newKeys = Object.keys(newProperties);
2458
- if (currentKeys.length !== newKeys.length) {
2459
- return false;
2460
- }
2461
- for (const newKey of newKeys) {
2462
- if (!(newKey in currentProperties)) {
2522
+ function arePropertiesPartiallyCompatible(full, partial) {
2523
+ for (const key in partial) {
2524
+ if (!(key in full)) {
2463
2525
  return false;
2464
2526
  }
2465
- const currentInfo = resolveGLSLTypeInfo(currentProperties[newKey]);
2466
- const newInfo = resolveGLSLTypeInfo(newProperties[newKey]);
2467
- if (currentInfo.glslType !== newInfo.glslType) {
2527
+ const infoFull = full[key].glslTypeInfo;
2528
+ const infoPartial = partial[key].glslTypeInfo;
2529
+ if (infoFull.glslTypeName !== infoPartial.glslTypeName) {
2468
2530
  return false;
2469
2531
  }
2470
2532
  // Non-instantiable (textures) must match by reference
2471
- if (!newInfo.instantiable &&
2472
- newProperties[newKey] !== currentProperties[newKey]) {
2533
+ if (!infoFull.instantiable && full[key] !== partial[key]) {
2473
2534
  return false;
2474
2535
  }
2475
2536
  }
2476
2537
  return true;
2477
2538
  }
2539
+ function convertUIPropertiesToGLProperties(uiProperties) {
2540
+ const glProperties = {};
2541
+ for (const name in uiProperties) {
2542
+ const value = uiProperties[name];
2543
+ glProperties[name] = { value, glslTypeInfo: resolveGLSLTypeInfo(value) };
2544
+ }
2545
+ return glProperties;
2546
+ }
2547
+ function cloneProperty(property) {
2548
+ if (typeof property === "number" || property instanceof Texture) {
2549
+ return property;
2550
+ }
2551
+ return property.clone();
2552
+ }
2553
+ function cloneProperties(properties) {
2554
+ const result = {};
2555
+ for (const name in properties) {
2556
+ result[name] = cloneProperty(properties[name]);
2557
+ }
2558
+ return result;
2559
+ }
2478
2560
  function buildGenericPlaneFragmentShader(uniformDeclarations, varyingDeclarations, source) {
2479
2561
  return `
2480
2562
  // Defines
@@ -2515,6 +2597,17 @@ function buildGenericPlaneFragmentShader(uniformDeclarations, varyingDeclaration
2515
2597
  `;
2516
2598
  }
2517
2599
 
2600
+ /** Transparency rendering modes */
2601
+ var UITransparencyMode;
2602
+ (function (UITransparencyMode) {
2603
+ /** Binary transparency. Best performance. */
2604
+ UITransparencyMode[UITransparencyMode["CLIP"] = 0] = "CLIP";
2605
+ /** Dithered transparency. Good performance. */
2606
+ UITransparencyMode[UITransparencyMode["HASH"] = 1] = "HASH";
2607
+ /** Alpha blending. Best quality, requires depth sorting. */
2608
+ UITransparencyMode[UITransparencyMode["BLEND"] = 2] = "BLEND";
2609
+ })(UITransparencyMode || (UITransparencyMode = {}));
2610
+
2518
2611
  const INSTANCED_PLANE_GEOMETRY = (() => {
2519
2612
  const planeGeometry = new PlaneGeometry(1, 1);
2520
2613
  planeGeometry.translate(0.5, 0.5, 0);
@@ -2575,7 +2668,7 @@ function buildEmptyInstancedBufferAttribute(value, capacity) {
2575
2668
  if (!info.instantiable) {
2576
2669
  throw new Error(`buildEmptyInstancedBufferAttribute.value: cannot create instanced attribute for non-instantiable type`);
2577
2670
  }
2578
- return new InstancedBufferAttribute(new Float32Array(capacity * info.itemSize), info.itemSize);
2671
+ return new InstancedBufferAttribute(new Float32Array(capacity * info.bufferSize), info.bufferSize);
2579
2672
  }
2580
2673
  function buildMaterial(source, uniformProperties, varyingProperties, transparency) {
2581
2674
  const uniforms = {};
@@ -2583,17 +2676,17 @@ function buildMaterial(source, uniformProperties, varyingProperties, transparenc
2583
2676
  const attributeDeclarations = [];
2584
2677
  const varyingDeclarations = [];
2585
2678
  const vertexAssignments = [];
2586
- for (const [name, value] of Object.entries(uniformProperties)) {
2587
- const info = resolveGLSLTypeInfo(value);
2679
+ for (const name in uniformProperties) {
2680
+ const { value, glslTypeInfo } = uniformProperties[name];
2588
2681
  uniforms[`p_${name}`] = {
2589
2682
  value: value instanceof UIColor ? value.toGLSLColor() : value,
2590
2683
  };
2591
- uniformDeclarations.push(`uniform ${info.glslType} p_${name};`);
2684
+ uniformDeclarations.push(`uniform ${glslTypeInfo.glslTypeName} p_${name};`);
2592
2685
  }
2593
- for (const [name, value] of Object.entries(varyingProperties)) {
2594
- const info = resolveGLSLTypeInfo(value);
2595
- attributeDeclarations.push(`attribute ${info.glslType} a_${name};`);
2596
- varyingDeclarations.push(`varying ${info.glslType} p_${name};`);
2686
+ for (const name in varyingProperties) {
2687
+ const { glslTypeInfo } = varyingProperties[name];
2688
+ attributeDeclarations.push(`attribute ${glslTypeInfo.glslTypeName} a_${name};`);
2689
+ varyingDeclarations.push(`varying ${glslTypeInfo.glslTypeName} p_${name};`);
2597
2690
  vertexAssignments.push(`p_${name} = a_${name};`);
2598
2691
  }
2599
2692
  const vertexShader = `
@@ -2665,20 +2758,34 @@ function reconstructValue(referenceValue, array, offset) {
2665
2758
  throw new Error(`reconstructValue.referenceValue: cannot reconstruct value for type`);
2666
2759
  }
2667
2760
 
2761
+ /**
2762
+ * Instanced shader plane mesh for batched rendering.
2763
+ *
2764
+ * Copies property values into internal buffers. No external references
2765
+ * are retained after method calls return.
2766
+ *
2767
+ * @internal
2768
+ */
2668
2769
  class UIGenericInstancedPlane extends Mesh {
2669
- constructor(source, properties, transparency = UITransparencyMode.BLEND, initialCapacity = CAPACITY_STEP) {
2770
+ constructor(source, properties, transparency, initialCapacity = CAPACITY_STEP) {
2670
2771
  const uniformProperties = {};
2671
2772
  const varyingProperties = {
2672
- instanceVisibility: 1,
2673
- instanceTransform: new Matrix4().identity(),
2773
+ instanceVisibility: {
2774
+ value: 1,
2775
+ glslTypeInfo: resolveGLSLTypeInfo("number"),
2776
+ },
2777
+ instanceTransform: {
2778
+ value: new Matrix4().identity(),
2779
+ glslTypeInfo: resolveGLSLTypeInfo("Matrix4"),
2780
+ },
2674
2781
  };
2675
- for (const [name, value] of Object.entries(properties)) {
2676
- const info = resolveGLSLTypeInfo(value);
2677
- if (info.instantiable) {
2678
- varyingProperties[name] = value;
2782
+ for (const name in properties) {
2783
+ const descriptor = properties[name];
2784
+ if (descriptor.glslTypeInfo.instantiable) {
2785
+ varyingProperties[name] = descriptor;
2679
2786
  }
2680
2787
  else {
2681
- uniformProperties[name] = value;
2788
+ uniformProperties[name] = descriptor;
2682
2789
  }
2683
2790
  }
2684
2791
  const instancedGeometry = INSTANCED_PLANE_GEOMETRY.clone();
@@ -2699,35 +2806,48 @@ class UIGenericInstancedPlane extends Mesh {
2699
2806
  this._private_varyingProperties = varyingProperties;
2700
2807
  this._private_capacity = Math.max(Math.ceil(initialCapacity / CAPACITY_STEP) * CAPACITY_STEP, CAPACITY_STEP);
2701
2808
  {
2702
- for (const [name, value] of Object.entries(this._private_varyingProperties)) {
2809
+ for (const name in this._private_varyingProperties) {
2810
+ const { value } = this._private_varyingProperties[name];
2703
2811
  const attribute = buildEmptyInstancedBufferAttribute(value, this._private_capacity);
2704
2812
  this._private_instancedGeometry.setAttribute(`a_${name}`, attribute);
2705
2813
  this._private_propertyBuffers.set(name, attribute);
2706
2814
  }
2707
2815
  }
2708
2816
  {
2709
- for (const [name, value] of Object.entries(this._private_uniformProperties)) {
2710
- const uniform = resolveUniform(name, this._private_shaderMaterial);
2817
+ for (const name in this._private_uniformProperties) {
2818
+ const { value } = this._private_uniformProperties[name];
2819
+ const uniform = resolvePropertyUniform(name, this._private_shaderMaterial);
2711
2820
  uniform.value = value;
2712
2821
  }
2713
2822
  this._private_shaderMaterial.uniformsNeedUpdate = true;
2714
2823
  }
2715
2824
  }
2825
+ /** Current number of active instances */
2716
2826
  get instanceCount() {
2717
2827
  return this._private_instancedGeometry.instanceCount;
2718
2828
  }
2719
- get properties() {
2720
- return { ...this._private_uniformProperties, ...this._private_varyingProperties };
2721
- }
2829
+ /**
2830
+ * Creates new instance with default values.
2831
+ * @returns Instance handler for subsequent operations
2832
+ */
2722
2833
  createInstance() {
2723
2834
  const handler = this._private_lastHandler++;
2724
2835
  const index = this._private_instancedGeometry.instanceCount;
2725
- this._private_ensureCapacity(index + 1);
2726
- this._private_handlerToIndex.set(handler, index);
2727
- this._private_instancedGeometry.instanceCount++;
2728
- this._private_initializeInstanceDefaults(index);
2836
+ {
2837
+ this._private_ensureCapacity(index + 1);
2838
+ this._private_handlerToIndex.set(handler, index);
2839
+ this._private_instancedGeometry.instanceCount++;
2840
+ }
2841
+ {
2842
+ const visibilityBufferAttribute = this._private_propertyBuffers.get("instanceVisibility");
2843
+ const transformBufferAttribute = this._private_propertyBuffers.get("instanceTransform");
2844
+ writeInstanceDefaults(visibilityBufferAttribute.array, transformBufferAttribute.array, index);
2845
+ visibilityBufferAttribute.needsUpdate = true;
2846
+ transformBufferAttribute.needsUpdate = true;
2847
+ }
2729
2848
  return handler;
2730
2849
  }
2850
+ /** Removes instance and compacts buffer */
2731
2851
  destroyInstance(handler) {
2732
2852
  const index = this._private_resolveIndex(handler);
2733
2853
  this._private_handlerToIndex.delete(handler);
@@ -2738,23 +2858,25 @@ class UIGenericInstancedPlane extends Mesh {
2738
2858
  }
2739
2859
  this._private_instancedGeometry.instanceCount--;
2740
2860
  }
2861
+ /** Updates instance properties. Values are copied into buffers. */
2741
2862
  setProperties(handler, properties) {
2742
2863
  const index = this._private_resolveIndex(handler);
2743
- for (const [name, value] of Object.entries(properties)) {
2744
- const typeInfo = resolveGLSLTypeInfo(value);
2745
- if (typeInfo.instantiable) {
2864
+ for (const name in properties) {
2865
+ const { value, glslTypeInfo } = properties[name];
2866
+ if (glslTypeInfo.instantiable) {
2746
2867
  const attribute = this._private_resolveAttribute(name);
2747
2868
  const offset = index * attribute.itemSize;
2748
2869
  writePropertyToArray(value, attribute.array, offset);
2749
2870
  attribute.needsUpdate = true;
2750
2871
  }
2751
2872
  else {
2752
- const uniform = resolveUniform(name, this._private_shaderMaterial);
2873
+ const uniform = resolvePropertyUniform(name, this._private_shaderMaterial);
2753
2874
  uniform.value = value;
2754
2875
  this._private_shaderMaterial.uniformsNeedUpdate = true;
2755
2876
  }
2756
2877
  }
2757
2878
  }
2879
+ /** Updates instance transform. Matrix is copied into buffer. */
2758
2880
  setTransform(handler, transform) {
2759
2881
  const index = this._private_resolveIndex(handler);
2760
2882
  const attribute = this._private_resolveAttribute("instanceTransform");
@@ -2766,6 +2888,7 @@ class UIGenericInstancedPlane extends Mesh {
2766
2888
  }
2767
2889
  attribute.needsUpdate = true;
2768
2890
  }
2891
+ /** Updates instance visibility */
2769
2892
  setVisibility(handler, visible) {
2770
2893
  const index = this._private_resolveIndex(handler);
2771
2894
  const attribute = this._private_resolveAttribute("instanceVisibility");
@@ -2773,39 +2896,53 @@ class UIGenericInstancedPlane extends Mesh {
2773
2896
  array[index] = visible ? 1 : 0;
2774
2897
  attribute.needsUpdate = true;
2775
2898
  }
2776
- isCompatible(source, properties, transparency = UITransparencyMode.BLEND) {
2777
- if (this.source !== source || this.transparency !== transparency) {
2899
+ /** Checks if plane can accept given properties without reconstruction */
2900
+ isPartiallyCompatible(source, properties, transparency = UITransparencyMode.BLEND) {
2901
+ if (this.transparency !== transparency || this.source !== source) {
2778
2902
  return false;
2779
2903
  }
2780
- return arePropertiesCompatible(this.properties, properties);
2904
+ return arePropertiesPartiallyCompatible({ ...this._private_uniformProperties, ...this._private_varyingProperties }, properties);
2781
2905
  }
2782
- arePropertiesCompatible(properties) {
2783
- return arePropertiesCompatible(this.properties, properties);
2906
+ /** Checks if properties are compatible with current plane configuration */
2907
+ arePropertiesPartiallyCompatible(properties) {
2908
+ return arePropertiesPartiallyCompatible({ ...this._private_uniformProperties, ...this._private_varyingProperties }, properties);
2784
2909
  }
2910
+ /** Returns reconstructed instance data with new object instances */
2785
2911
  extractInstanceData(handler) {
2786
2912
  return {
2787
2913
  source: this.source,
2788
- properties: this.extractProperties(handler),
2914
+ properties: this._private_extractProperties(handler),
2789
2915
  transparency: this.transparency,
2790
- transform: this.extractTransform(handler),
2791
- visibility: this.extractVisibility(handler),
2916
+ transform: this._private_extractTransform(handler),
2917
+ visibility: this._private_extractVisibility(handler),
2792
2918
  };
2793
2919
  }
2794
- extractProperties(handler) {
2920
+ /** Disposes geometry, material, and clears buffers */
2921
+ destroy() {
2922
+ this._private_instancedGeometry.dispose();
2923
+ this._private_shaderMaterial.dispose();
2924
+ this._private_propertyBuffers.clear();
2925
+ this._private_handlerToIndex.clear();
2926
+ }
2927
+ _private_extractProperties(handler) {
2795
2928
  const index = this._private_resolveIndex(handler);
2796
2929
  const result = {};
2797
- for (const [name, value] of Object.entries(this._private_uniformProperties)) {
2798
- result[name] = value;
2930
+ for (const name in this._private_uniformProperties) {
2931
+ result[name] = this._private_uniformProperties[name];
2799
2932
  }
2800
- for (const [name, referenceValue] of Object.entries(this._private_varyingProperties)) {
2933
+ for (const name in this._private_varyingProperties) {
2934
+ const { value, glslTypeInfo } = this._private_varyingProperties[name];
2801
2935
  const attribute = this._private_propertyBuffers.get(name);
2802
2936
  const array = attribute.array;
2803
2937
  const offset = index * attribute.itemSize;
2804
- result[name] = reconstructValue(referenceValue, array, offset);
2938
+ result[name] = {
2939
+ value: reconstructValue(value, array, offset),
2940
+ glslTypeInfo,
2941
+ };
2805
2942
  }
2806
2943
  return result;
2807
2944
  }
2808
- extractTransform(handler) {
2945
+ _private_extractTransform(handler) {
2809
2946
  const index = this._private_resolveIndex(handler);
2810
2947
  const attribute = this._private_propertyBuffers.get("instanceTransform");
2811
2948
  const array = attribute.array;
@@ -2813,31 +2950,18 @@ class UIGenericInstancedPlane extends Mesh {
2813
2950
  matrix.fromArray(array, index * 16);
2814
2951
  return matrix;
2815
2952
  }
2816
- extractVisibility(handler) {
2953
+ _private_extractVisibility(handler) {
2817
2954
  const index = this._private_resolveIndex(handler);
2818
2955
  const attribute = this._private_propertyBuffers.get("instanceVisibility");
2819
2956
  const array = attribute.array;
2820
2957
  return array[index] >= 0.5;
2821
2958
  }
2822
- destroy() {
2823
- this._private_instancedGeometry.dispose();
2824
- this._private_shaderMaterial.dispose();
2825
- this._private_propertyBuffers.clear();
2826
- this._private_handlerToIndex.clear();
2827
- }
2828
- _private_initializeInstanceDefaults(index) {
2829
- const visibilityAttr = this._private_propertyBuffers.get("instanceVisibility");
2830
- const transformAttr = this._private_propertyBuffers.get("instanceTransform");
2831
- writeInstanceDefaults(visibilityAttr.array, transformAttr.array, index);
2832
- visibilityAttr.needsUpdate = true;
2833
- transformAttr.needsUpdate = true;
2834
- }
2835
2959
  _private_ensureCapacity(requiredCapacity) {
2836
2960
  if (requiredCapacity <= this._private_capacity) {
2837
2961
  return;
2838
2962
  }
2839
2963
  const newCapacity = Math.ceil(requiredCapacity / CAPACITY_STEP) * CAPACITY_STEP;
2840
- for (const [name, oldAttribute] of this._private_propertyBuffers.entries()) {
2964
+ for (const [name, oldAttribute] of this._private_propertyBuffers) {
2841
2965
  const itemSize = oldAttribute.itemSize;
2842
2966
  const newArray = new Float32Array(newCapacity * itemSize);
2843
2967
  newArray.set(oldAttribute.array);
@@ -2884,18 +3008,18 @@ class UIGenericInstancedPlane extends Mesh {
2884
3008
  }
2885
3009
 
2886
3010
  const PLANE_GEOMETRY = new PlaneGeometry(1, 1).translate(0.5, 0.5, 0);
2887
- function buildGenericPlaneMaterial(source, properties, transparency) {
3011
+ function buildGenericPlaneMaterial(source, properties, transparency, transform) {
2888
3012
  const uniforms = {
2889
- // eslint-disable-next-line @typescript-eslint/naming-convention
2890
- p_transform: { value: new Matrix4() },
3013
+ // eslint-disable-next-line @typescript-eslint/naming-convention -- unform name
3014
+ p_transform: { value: transform },
2891
3015
  };
2892
3016
  const uniformDeclarations = [];
2893
- for (const [name, value] of Object.entries(properties)) {
2894
- const info = resolveGLSLTypeInfo(value);
3017
+ for (const name in properties) {
3018
+ const { value, glslTypeInfo } = properties[name];
2895
3019
  uniforms[`p_${name}`] = {
2896
3020
  value: value instanceof UIColor ? value.toGLSLColor() : value,
2897
3021
  };
2898
- uniformDeclarations.push(`uniform ${info.glslType} p_${name};`);
3022
+ uniformDeclarations.push(`uniform ${glslTypeInfo.glslTypeName} p_${name};`);
2899
3023
  }
2900
3024
  const vertexShader = `
2901
3025
  // Default uniform declarations
@@ -2929,53 +3053,67 @@ function buildGenericPlaneMaterial(source, properties, transparency) {
2929
3053
  return material;
2930
3054
  }
2931
3055
 
3056
+ /**
3057
+ * Single shader plane mesh.
3058
+ *
3059
+ * Does not clone inputs. Caller must ensure properties and transform
3060
+ * are not shared with external code.
3061
+ *
3062
+ * @internal
3063
+ */
2932
3064
  class UIGenericPlane extends Mesh {
2933
- constructor(source, properties, transparency) {
2934
- const shaderMaterial = buildGenericPlaneMaterial(source, properties, transparency);
3065
+ constructor(_private_source, properties, transform, visibility, transparency) {
3066
+ const shaderMaterial = buildGenericPlaneMaterial(_private_source, properties, transparency, transform);
2935
3067
  super(PLANE_GEOMETRY, shaderMaterial);
2936
- this.source = source;
2937
- this._private_transformInternal = new Matrix4().identity();
3068
+ this._private_source = _private_source;
3069
+ this._private_shaderMaterial = shaderMaterial;
3070
+ this._private_properties = properties;
3071
+ this._private_transparencyInternal = transparency;
3072
+ this._private_transform = transform;
3073
+ this.visible = visibility;
2938
3074
  this.frustumCulled = false;
2939
3075
  this.matrixAutoUpdate = false;
2940
3076
  this.matrixWorldAutoUpdate = false;
2941
- this._private_shaderMaterial = shaderMaterial;
2942
- this._private_propertiesInternal = { ...properties };
2943
- this._private_transparencyInternal = transparency;
2944
- }
2945
- get properties() {
2946
- return { ...this._private_propertiesInternal };
2947
- }
2948
- get transform() {
2949
- return this._private_transformInternal;
2950
- }
2951
- get visibility() {
2952
- return this.visible;
2953
3077
  }
3078
+ /** Current transparency mode */
2954
3079
  get transparency() {
2955
3080
  return this._private_transparencyInternal;
2956
3081
  }
3082
+ /** Updates properties. Values are copied via .copy() methods. */
2957
3083
  setProperties(properties) {
2958
- for (const [name, value] of Object.entries(properties)) {
2959
- const uniform = resolveUniform(name, this._private_shaderMaterial);
2960
- if (value instanceof UIColor) {
2961
- value.toGLSLColor(uniform.value);
3084
+ for (const name in properties) {
3085
+ const descriptor = properties[name];
3086
+ const uniform = resolvePropertyUniform(name, this._private_shaderMaterial);
3087
+ const descriptorValue = descriptor.value;
3088
+ if (descriptor.value instanceof UIColor) {
3089
+ descriptor.value.toGLSLColor(uniform.value);
3090
+ this._private_properties[name].value.copy(descriptor.value);
3091
+ }
3092
+ else if (typeof descriptorValue === "number" ||
3093
+ descriptorValue instanceof Texture) {
3094
+ uniform.value = descriptor.value;
3095
+ this._private_properties[name].value = descriptor.value;
2962
3096
  }
2963
3097
  else {
2964
- uniform.value = value;
3098
+ const value = descriptor.value;
3099
+ uniform.value.copy(value);
3100
+ this._private_properties[name].value.copy(value);
2965
3101
  }
2966
- this._private_propertiesInternal[name] = value;
2967
3102
  }
2968
3103
  this._private_shaderMaterial.uniformsNeedUpdate = true;
2969
3104
  }
3105
+ /** Updates transform. Matrix is copied. */
2970
3106
  setTransform(transform) {
2971
- const uniform = resolveUniform("transform", this._private_shaderMaterial);
3107
+ const uniform = resolvePropertyUniform("transform", this._private_shaderMaterial);
2972
3108
  uniform.value.copy(transform);
2973
3109
  this._private_shaderMaterial.uniformsNeedUpdate = true;
2974
- this._private_transformInternal.copy(transform);
3110
+ this._private_transform.copy(transform);
2975
3111
  }
3112
+ /** Updates visibility */
2976
3113
  setVisibility(visibility) {
2977
3114
  this.visible = visibility;
2978
3115
  }
3116
+ /** Updates transparency mode */
2979
3117
  setTransparency(transparency) {
2980
3118
  if (this._private_transparencyInternal !== transparency) {
2981
3119
  this._private_shaderMaterial.transparent =
@@ -2989,266 +3127,239 @@ class UIGenericPlane extends Mesh {
2989
3127
  this._private_transparencyInternal = transparency;
2990
3128
  }
2991
3129
  }
2992
- extractInstanceData() {
3130
+ /** Returns cloned plane data for reconstruction */
3131
+ extractPlaneData() {
2993
3132
  return {
2994
- source: this.source,
2995
- properties: this.properties,
2996
- transparency: this._private_transparencyInternal,
2997
- transform: this._private_transformInternal.clone(),
3133
+ source: this._private_source,
3134
+ properties: { ...this._private_properties },
3135
+ transform: this._private_transform.clone(),
2998
3136
  visibility: this.visible,
3137
+ transparency: this._private_transparencyInternal,
2999
3138
  };
3000
3139
  }
3001
- isCompatible(source, properties, transparency) {
3002
- if (this._private_transparencyInternal !== transparency || this.source !== source) {
3140
+ /** Checks if plane can accept given properties without reconstruction */
3141
+ isPartiallyCompatible(source, properties, transparency) {
3142
+ if (this._private_transparencyInternal !== transparency || this._private_source !== source) {
3003
3143
  return false;
3004
3144
  }
3005
- return arePropertiesCompatible(this._private_propertiesInternal, properties);
3145
+ return arePropertiesPartiallyCompatible(this._private_properties, properties);
3006
3146
  }
3007
- arePropertiesCompatible(properties) {
3008
- return arePropertiesCompatible(this._private_propertiesInternal, properties);
3147
+ /** Checks if properties are compatible with current plane configuration */
3148
+ arePropertiesPartiallyCompatible(properties) {
3149
+ return arePropertiesPartiallyCompatible(this._private_properties, properties);
3009
3150
  }
3151
+ /** Disposes shader material */
3010
3152
  destroy() {
3011
3153
  this._private_shaderMaterial.dispose();
3012
3154
  }
3013
3155
  }
3014
3156
 
3157
+ function isSinglePlaneDescriptor(descriptor) {
3158
+ return !("instanceHandler" in descriptor);
3159
+ }
3160
+ function isInstancedPlaneDescriptor(descriptor) {
3161
+ return "instanceHandler" in descriptor;
3162
+ }
3163
+
3164
+ /**
3165
+ * Manages shader plane instances with automatic batching.
3166
+ *
3167
+ * Clones all incoming properties and transforms. No external references
3168
+ * are retained after method calls return.
3169
+ *
3170
+ * @internal
3171
+ */
3015
3172
  class UIPlaneRegistry {
3016
3173
  constructor(_private_scene) {
3017
3174
  this._private_scene = _private_scene;
3018
- this._private_descriptors = new Map();
3019
3175
  this._private_lastHandler = 0;
3176
+ this._private_handlerToPlaneDescriptor = new Map();
3020
3177
  }
3021
- create(source, properties, transparency) {
3178
+ /**
3179
+ * Creates plane with given shader and properties.
3180
+ * Properties and transform are cloned; originals can be safely modified.
3181
+ * @returns Plane handler for subsequent operations
3182
+ */
3183
+ createPlane(source, properties, transform, visibility, transparency) {
3022
3184
  const handler = this._private_lastHandler++;
3023
- const descriptor = {
3024
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
3025
- plane: undefined,
3026
- };
3027
- this._private_descriptors.set(handler, descriptor);
3028
- this._private_placeInstance(descriptor, {
3185
+ this._private_insertPlane(handler, {
3029
3186
  source,
3030
- properties,
3187
+ properties: convertUIPropertiesToGLProperties(cloneProperties(properties)),
3188
+ transform: transform.clone(),
3189
+ visibility,
3031
3190
  transparency,
3032
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
3033
- transform: undefined,
3034
- visibility: true,
3035
3191
  });
3036
3192
  return handler;
3037
3193
  }
3038
- destroy(handler) {
3039
- const descriptor = this._private_resolveDescriptor(handler);
3040
- this._private_descriptors.delete(handler);
3041
- this._private_removeFromCurrentPlane(descriptor);
3042
- }
3043
- setTransform(handler, transform) {
3044
- const descriptor = this._private_resolveDescriptor(handler);
3045
- if (descriptor.plane instanceof UIGenericInstancedPlane &&
3046
- descriptor.instanceHandler !== undefined) {
3047
- descriptor.plane.setTransform(descriptor.instanceHandler, transform);
3194
+ /** Removes plane and frees resources */
3195
+ destroyPlane(handler) {
3196
+ const planeDescriptor = this._private_resolvePlaneDescriptor(handler);
3197
+ if (isSinglePlaneDescriptor(planeDescriptor)) {
3198
+ this._private_scene.remove(planeDescriptor.plane);
3199
+ planeDescriptor.plane.destroy();
3048
3200
  }
3049
- else if (descriptor.plane instanceof UIGenericPlane) {
3050
- descriptor.plane.setTransform(transform);
3201
+ else {
3202
+ const instancedPlane = planeDescriptor.plane;
3203
+ if (instancedPlane.instanceCount === 1) {
3204
+ this._private_scene.remove(instancedPlane);
3205
+ instancedPlane.destroy();
3206
+ }
3207
+ else if (instancedPlane.instanceCount === 2) {
3208
+ this._private_demoteInstancedPlaneToSinglePlane(instancedPlane, planeDescriptor);
3209
+ }
3210
+ else {
3211
+ instancedPlane.destroyInstance(planeDescriptor.instanceHandler);
3212
+ }
3051
3213
  }
3214
+ this._private_handlerToPlaneDescriptor.delete(handler);
3052
3215
  }
3216
+ /**
3217
+ * Updates plane properties.
3218
+ * Values are copied; originals can be safely modified.
3219
+ */
3053
3220
  setProperties(handler, properties) {
3054
- const descriptor = this._private_resolveDescriptor(handler);
3055
- const currentData = this._private_extractInstanceData(descriptor);
3056
- const newProperties = { ...currentData.properties, ...properties };
3057
- const needsRelocation = this._private_checkNeedsRelocation(descriptor, currentData, newProperties, currentData.transparency);
3058
- if (needsRelocation) {
3059
- this._private_removeFromCurrentPlane(descriptor);
3060
- this._private_placeInstance(descriptor, {
3061
- ...currentData,
3062
- properties: newProperties,
3063
- });
3064
- }
3065
- else {
3066
- this._private_updatePropertiesInPlace(descriptor, properties);
3221
+ const planeDescriptor = this._private_resolvePlaneDescriptor(handler);
3222
+ const glProperties = convertUIPropertiesToGLProperties(properties);
3223
+ if (isSinglePlaneDescriptor(planeDescriptor)) {
3224
+ planeDescriptor.plane.setProperties(glProperties);
3225
+ return;
3067
3226
  }
3068
- }
3069
- setVisibility(handler, visible) {
3070
- const descriptor = this._private_resolveDescriptor(handler);
3071
- if (descriptor.plane instanceof UIGenericInstancedPlane &&
3072
- descriptor.instanceHandler !== undefined) {
3073
- descriptor.plane.setVisibility(descriptor.instanceHandler, visible);
3227
+ const arePropertiesCompatible = planeDescriptor.plane.arePropertiesPartiallyCompatible(glProperties);
3228
+ if (arePropertiesCompatible) {
3229
+ planeDescriptor.plane.setProperties(planeDescriptor.instanceHandler, glProperties);
3230
+ return;
3074
3231
  }
3075
- else if (descriptor.plane instanceof UIGenericPlane) {
3076
- descriptor.plane.setVisibility(visible);
3232
+ const planeData = planeDescriptor.plane.extractInstanceData(planeDescriptor.instanceHandler);
3233
+ for (const name in glProperties) {
3234
+ planeData.properties[name] = {
3235
+ value: cloneProperty(glProperties[name].value),
3236
+ glslTypeInfo: glProperties[name].glslTypeInfo,
3237
+ };
3077
3238
  }
3239
+ this.destroyPlane(handler);
3240
+ this._private_insertPlane(handler, planeData);
3078
3241
  }
3079
- setTransparency(handler, transparency) {
3080
- const descriptor = this._private_resolveDescriptor(handler);
3081
- const currentData = this._private_extractInstanceData(descriptor);
3082
- if (currentData.transparency === transparency) {
3242
+ /**
3243
+ * Updates plane transform matrix.
3244
+ * Matrix is copied; original can be safely modified.
3245
+ */
3246
+ setTransform(handler, transform) {
3247
+ const planeDescriptor = this._private_resolvePlaneDescriptor(handler);
3248
+ if (isSinglePlaneDescriptor(planeDescriptor)) {
3249
+ planeDescriptor.plane.setTransform(transform);
3083
3250
  return;
3084
3251
  }
3085
- const needsRelocation = this._private_checkNeedsRelocation(descriptor, currentData, currentData.properties, transparency);
3086
- if (needsRelocation) {
3087
- this._private_removeFromCurrentPlane(descriptor);
3088
- this._private_placeInstance(descriptor, {
3089
- ...currentData,
3090
- transparency,
3091
- });
3092
- }
3093
- else if (descriptor.plane instanceof UIGenericPlane) {
3094
- descriptor.plane.setTransparency(transparency);
3095
- }
3252
+ planeDescriptor.plane.setTransform(planeDescriptor.instanceHandler, transform);
3096
3253
  }
3097
- _private_placeInstance(descriptor, data) {
3098
- const { source, properties, transparency, transform, visibility } = data;
3099
- const compatibleInstanced = this._private_findCompatibleInstancedPlane(source, properties, transparency);
3100
- if (compatibleInstanced) {
3101
- this._private_attachToInstancedPlane(descriptor, compatibleInstanced, properties, transform, visibility);
3254
+ /** Updates plane visibility */
3255
+ setVisibility(handler, visibility) {
3256
+ const planeDescriptor = this._private_resolvePlaneDescriptor(handler);
3257
+ if (isSinglePlaneDescriptor(planeDescriptor)) {
3258
+ planeDescriptor.plane.setVisibility(visibility);
3102
3259
  return;
3103
3260
  }
3104
- const promotable = this._private_findCompatibleSinglePlane(source, properties, transparency, descriptor);
3105
- if (promotable) {
3106
- const instancedPlane = this._private_promoteToInstanced(promotable, properties);
3107
- this._private_attachToInstancedPlane(descriptor, instancedPlane, properties, transform, visibility);
3261
+ planeDescriptor.plane.setVisibility(planeDescriptor.instanceHandler, visibility);
3262
+ }
3263
+ /** Updates plane transparency mode */
3264
+ setTransparency(handler, transparency) {
3265
+ const planeDescriptor = this._private_resolvePlaneDescriptor(handler);
3266
+ if (planeDescriptor.plane.transparency === transparency) {
3108
3267
  return;
3109
3268
  }
3110
- this._private_createSinglePlane(descriptor, source, properties, transparency, transform, visibility);
3111
- }
3112
- _private_extractInstanceData(descriptor) {
3113
- if (descriptor.plane instanceof UIGenericInstancedPlane &&
3114
- descriptor.instanceHandler !== undefined) {
3115
- return descriptor.plane.extractInstanceData(descriptor.instanceHandler);
3269
+ if (isSinglePlaneDescriptor(planeDescriptor)) {
3270
+ planeDescriptor.plane.setTransparency(transparency);
3271
+ return;
3116
3272
  }
3117
- return descriptor.plane.extractInstanceData();
3273
+ const planeData = planeDescriptor.plane.extractInstanceData(planeDescriptor.instanceHandler);
3274
+ this.destroyPlane(handler);
3275
+ this._private_insertPlane(handler, {
3276
+ ...planeData,
3277
+ transparency,
3278
+ });
3118
3279
  }
3119
- _private_removeFromCurrentPlane(descriptor) {
3120
- if (descriptor.plane instanceof UIGenericInstancedPlane &&
3121
- descriptor.instanceHandler !== undefined) {
3122
- const instancedPlane = descriptor.plane;
3123
- instancedPlane.destroyInstance(descriptor.instanceHandler);
3124
- if (instancedPlane.instanceCount === 0) {
3125
- this._private_scene.remove(instancedPlane);
3126
- instancedPlane.destroy();
3127
- }
3128
- else if (instancedPlane.instanceCount === 1) {
3129
- this._private_demoteToSingle(instancedPlane, descriptor);
3280
+ _private_promoteSinglePlaneToInstancedPlane(handler, planeDescriptor) {
3281
+ const { source, properties, transform, visibility, transparency } = planeDescriptor.plane.extractPlaneData();
3282
+ this.destroyPlane(handler);
3283
+ const plane = new UIGenericInstancedPlane(source, properties, transparency);
3284
+ const instanceHandler = plane.createInstance();
3285
+ plane.setProperties(instanceHandler, properties);
3286
+ plane.setTransform(instanceHandler, transform);
3287
+ plane.setVisibility(instanceHandler, visibility);
3288
+ this._private_scene.add(plane);
3289
+ this._private_handlerToPlaneDescriptor.set(handler, { plane, instanceHandler });
3290
+ return plane;
3291
+ }
3292
+ _private_demoteInstancedPlaneToSinglePlane(instancedPlane, removedDescriptor) {
3293
+ let remainingPair;
3294
+ for (const [handler, planeDescriptor] of this._private_handlerToPlaneDescriptor) {
3295
+ if (isInstancedPlaneDescriptor(planeDescriptor) &&
3296
+ planeDescriptor !== removedDescriptor &&
3297
+ planeDescriptor.plane === instancedPlane) {
3298
+ remainingPair = [handler, planeDescriptor];
3299
+ break;
3130
3300
  }
3131
3301
  }
3132
- else if (descriptor.plane instanceof UIGenericPlane) {
3133
- this._private_scene.remove(descriptor.plane);
3134
- descriptor.plane.destroy();
3302
+ if (!remainingPair) {
3303
+ throw new Error("UIGenericPlaneRegistry.demoteInstancedPlaneToSinglePlane.instancedPlane: remaining pair not found");
3135
3304
  }
3136
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
3137
- descriptor.plane = undefined;
3138
- delete descriptor.instanceHandler;
3305
+ const { source, properties, transform, visibility, transparency } = instancedPlane.extractInstanceData(remainingPair[1].instanceHandler);
3306
+ this._private_scene.remove(instancedPlane);
3307
+ instancedPlane.destroy();
3308
+ const plane = new UIGenericPlane(source, properties, transform, visibility, transparency);
3309
+ this._private_scene.add(plane);
3310
+ this._private_handlerToPlaneDescriptor.set(remainingPair[0], { plane });
3139
3311
  }
3140
- _private_updatePropertiesInPlace(descriptor, properties) {
3141
- if (descriptor.plane instanceof UIGenericInstancedPlane &&
3142
- descriptor.instanceHandler !== undefined) {
3143
- descriptor.plane.setProperties(descriptor.instanceHandler, properties);
3144
- }
3145
- else if (descriptor.plane instanceof UIGenericPlane) {
3146
- descriptor.plane.setProperties(properties);
3147
- }
3312
+ _private_attachToInstancedPlane(handler, instancedPlane, properties, transform, visibility) {
3313
+ const instanceHandler = instancedPlane.createInstance();
3314
+ instancedPlane.setProperties(instanceHandler, properties);
3315
+ instancedPlane.setTransform(instanceHandler, transform);
3316
+ instancedPlane.setVisibility(instanceHandler, visibility);
3317
+ this._private_handlerToPlaneDescriptor.set(handler, {
3318
+ plane: instancedPlane,
3319
+ instanceHandler,
3320
+ });
3148
3321
  }
3149
- _private_checkNeedsRelocation(descriptor, currentData, newProperties, newTransparency) {
3150
- const isInstanced = descriptor.plane instanceof UIGenericInstancedPlane;
3151
- if (isInstanced) {
3152
- if (currentData.transparency !== newTransparency) {
3153
- return true;
3154
- }
3155
- return !descriptor.plane.arePropertiesCompatible(newProperties);
3156
- }
3157
- const compatibleInstanced = this._private_findCompatibleInstancedPlane(currentData.source, newProperties, newTransparency);
3158
- if (compatibleInstanced) {
3159
- return true;
3322
+ _private_insertPlane(handler, planeData) {
3323
+ const { source, properties, transparency, transform, visibility } = planeData;
3324
+ const compatibleInstancedPlane = this._private_findCompatibleInstancedPlane(source, properties, transparency);
3325
+ if (compatibleInstancedPlane) {
3326
+ this._private_attachToInstancedPlane(handler, compatibleInstancedPlane, properties, transform, visibility);
3327
+ return;
3160
3328
  }
3161
- const promotable = this._private_findCompatibleSinglePlane(currentData.source, newProperties, newTransparency, descriptor);
3162
- if (promotable) {
3163
- return true;
3329
+ const compatibleSinglePlanePair = this._private_findCompatibleSinglePlane(source, properties, transparency);
3330
+ if (compatibleSinglePlanePair) {
3331
+ const instancedPlane = this._private_promoteSinglePlaneToInstancedPlane(compatibleSinglePlanePair[0], compatibleSinglePlanePair[1]);
3332
+ this._private_attachToInstancedPlane(handler, instancedPlane, properties, transform, visibility);
3333
+ return;
3164
3334
  }
3165
- return false;
3335
+ const plane = new UIGenericPlane(source, properties, transform, visibility, transparency);
3336
+ this._private_scene.add(plane);
3337
+ this._private_handlerToPlaneDescriptor.set(handler, { plane });
3166
3338
  }
3167
- _private_attachToInstancedPlane(descriptor, instancedPlane, properties, transform, visibility) {
3168
- const instanceHandler = instancedPlane.createInstance();
3169
- instancedPlane.setProperties(instanceHandler, properties);
3170
- if (transform) {
3171
- instancedPlane.setTransform(instanceHandler, transform);
3172
- }
3173
- instancedPlane.setVisibility(instanceHandler, visibility);
3174
- descriptor.plane = instancedPlane;
3175
- descriptor.instanceHandler = instanceHandler;
3176
- }
3177
- _private_createSinglePlane(descriptor, source, properties, transparency, transform, visibility) {
3178
- const singlePlane = new UIGenericPlane(source, properties, transparency);
3179
- singlePlane.setProperties(properties);
3180
- if (transform) {
3181
- singlePlane.setTransform(transform);
3182
- }
3183
- singlePlane.setVisibility(visibility);
3184
- this._private_scene.add(singlePlane);
3185
- descriptor.plane = singlePlane;
3186
- delete descriptor.instanceHandler;
3187
- }
3188
- _private_findCompatibleSinglePlane(source, properties, transparency, excludeDescriptor) {
3189
- for (const descriptor of this._private_descriptors.values()) {
3190
- if (descriptor === excludeDescriptor) {
3191
- continue;
3192
- }
3193
- if (descriptor.plane instanceof UIGenericPlane &&
3194
- descriptor.plane.isCompatible(source, properties, transparency)) {
3195
- return descriptor;
3339
+ _private_findCompatibleSinglePlane(source, properties, transparency) {
3340
+ for (const handlerPlaneDescriptorPair of this._private_handlerToPlaneDescriptor) {
3341
+ const planeDescriptor = handlerPlaneDescriptorPair[1];
3342
+ if (isSinglePlaneDescriptor(planeDescriptor) &&
3343
+ planeDescriptor.plane.isPartiallyCompatible(source, properties, transparency)) {
3344
+ return [handlerPlaneDescriptorPair[0], planeDescriptor];
3196
3345
  }
3197
3346
  }
3198
3347
  return undefined;
3199
3348
  }
3200
3349
  _private_findCompatibleInstancedPlane(source, properties, transparency) {
3201
- for (const descriptor of this._private_descriptors.values()) {
3202
- if (descriptor.plane instanceof UIGenericInstancedPlane &&
3203
- descriptor.plane.isCompatible(source, properties, transparency)) {
3204
- return descriptor.plane;
3350
+ for (const handlerPlaneDescriptorPair of this._private_handlerToPlaneDescriptor) {
3351
+ const planeDescriptor = handlerPlaneDescriptorPair[1];
3352
+ if (isInstancedPlaneDescriptor(planeDescriptor) &&
3353
+ planeDescriptor.plane.isPartiallyCompatible(source, properties, transparency)) {
3354
+ return planeDescriptor.plane;
3205
3355
  }
3206
3356
  }
3207
3357
  return undefined;
3208
3358
  }
3209
- _private_promoteToInstanced(promotableDescriptor, templateProperties) {
3210
- const oldPlane = promotableDescriptor.plane;
3211
- const oldData = oldPlane.extractInstanceData();
3212
- const instancedPlane = new UIGenericInstancedPlane(oldData.source, templateProperties, oldData.transparency);
3213
- const oldInstanceHandler = instancedPlane.createInstance();
3214
- instancedPlane.setProperties(oldInstanceHandler, oldData.properties);
3215
- instancedPlane.setTransform(oldInstanceHandler, oldData.transform);
3216
- instancedPlane.setVisibility(oldInstanceHandler, oldData.visibility);
3217
- promotableDescriptor.plane = instancedPlane;
3218
- promotableDescriptor.instanceHandler = oldInstanceHandler;
3219
- this._private_scene.remove(oldPlane);
3220
- oldPlane.destroy();
3221
- this._private_scene.add(instancedPlane);
3222
- return instancedPlane;
3223
- }
3224
- _private_demoteToSingle(instancedPlane, removedDescriptor) {
3225
- let remainingDescriptor;
3226
- for (const descriptor of this._private_descriptors.values()) {
3227
- if (descriptor !== removedDescriptor &&
3228
- descriptor.plane === instancedPlane &&
3229
- descriptor.instanceHandler !== undefined) {
3230
- remainingDescriptor = descriptor;
3231
- break;
3232
- }
3233
- }
3234
- if (!remainingDescriptor) {
3235
- return;
3236
- }
3237
- const data = instancedPlane.extractInstanceData(remainingDescriptor.instanceHandler);
3238
- const singlePlane = new UIGenericPlane(data.source, data.properties, data.transparency);
3239
- singlePlane.setProperties(data.properties);
3240
- singlePlane.setTransform(data.transform);
3241
- singlePlane.setVisibility(data.visibility);
3242
- this._private_scene.remove(instancedPlane);
3243
- instancedPlane.destroy();
3244
- this._private_scene.add(singlePlane);
3245
- remainingDescriptor.plane = singlePlane;
3246
- delete remainingDescriptor.instanceHandler;
3247
- }
3248
- _private_resolveDescriptor(handler) {
3249
- const descriptor = this._private_descriptors.get(handler);
3359
+ _private_resolvePlaneDescriptor(handler) {
3360
+ const descriptor = this._private_handlerToPlaneDescriptor.get(handler);
3250
3361
  if (!descriptor) {
3251
- throw new Error(`UIGenericPlaneRegistry.resolveDescriptor.handler: descriptor not found`);
3362
+ throw new Error(`UIGenericPlaneRegistry.resolvePlaneDescriptor.handler: descriptor not found`);
3252
3363
  }
3253
3364
  return descriptor;
3254
3365
  }
@@ -3263,26 +3374,26 @@ let originalAutoClearStencil = false;
3263
3374
  class UISceneWrapper {
3264
3375
  constructor(width, height) {
3265
3376
  this._private_scene = new Scene();
3266
- this._private_registry = new UIPlaneRegistry(this._private_scene);
3377
+ this._private_planeRegistry = new UIPlaneRegistry(this._private_scene);
3267
3378
  this._private_camera = new OrthographicCamera(0, width, height, 0, -1024, 1024);
3268
3379
  }
3269
- createPlane(source, properties, transparency) {
3270
- return this._private_registry.create(source, properties, transparency);
3380
+ createPlane(source, properties, transform, visibility, transparency) {
3381
+ return this._private_planeRegistry.createPlane(source, properties, transform, visibility, transparency);
3271
3382
  }
3272
3383
  destroyPlane(handler) {
3273
- this._private_registry.destroy(handler);
3384
+ this._private_planeRegistry.destroyPlane(handler);
3274
3385
  }
3275
3386
  setTransform(handler, transform) {
3276
- this._private_registry.setTransform(handler, transform);
3387
+ this._private_planeRegistry.setTransform(handler, transform);
3277
3388
  }
3278
3389
  setProperties(handler, properties) {
3279
- this._private_registry.setProperties(handler, properties);
3390
+ this._private_planeRegistry.setProperties(handler, properties);
3280
3391
  }
3281
3392
  setVisibility(handler, visible) {
3282
- this._private_registry.setVisibility(handler, visible);
3393
+ this._private_planeRegistry.setVisibility(handler, visible);
3283
3394
  }
3284
3395
  setTransparency(handler, transparency) {
3285
- this._private_registry.setTransparency(handler, transparency);
3396
+ this._private_planeRegistry.setTransparency(handler, transparency);
3286
3397
  }
3287
3398
  insertCustomObject(object) {
3288
3399
  this._private_scene.add(object);
@@ -3472,7 +3583,7 @@ function convertRelation(relation) {
3472
3583
  case UIRelation.GREATER_THAN:
3473
3584
  return Operator.Ge;
3474
3585
  default:
3475
- throw new Error(`convertRelation: invalid relation`);
3586
+ throw new Error(`convertRelation.relation: invalid relation`);
3476
3587
  }
3477
3588
  }
3478
3589
  /**
@@ -3950,7 +4061,7 @@ class UISolverWrapper {
3950
4061
  .map(([variableIndex, coefficient]) => {
3951
4062
  const description = this._private_variables.get(variableIndex);
3952
4063
  if (description === undefined) {
3953
- throw new Error(`UISolverWrapper.convertExpression: variable does not exist`);
4064
+ throw new Error(`UISolverWrapper.convertExpression.expression: variable does not exist`);
3954
4065
  }
3955
4066
  return [coefficient, description.variable];
3956
4067
  }), expression.constant);
@@ -4278,18 +4389,18 @@ function assertValidInterpolationConstraintArguments(subject, a, b, c, anchorA,
4278
4389
  }
4279
4390
  return layerA;
4280
4391
  }
4281
- if (a instanceof UILayer) {
4282
- return a;
4283
- }
4284
4392
  if (isUILayerElement(a)) {
4285
4393
  return a.layer;
4286
4394
  }
4287
- if (b instanceof UILayer) {
4288
- return b;
4289
- }
4290
4395
  if (isUILayerElement(b)) {
4291
4396
  return b.layer;
4292
4397
  }
4398
+ if (a instanceof UILayer) {
4399
+ return a;
4400
+ }
4401
+ if (b instanceof UILayer) {
4402
+ return b;
4403
+ }
4293
4404
  throw new Error(`${subject}: no valid subjects found`);
4294
4405
  }
4295
4406
 
@@ -5900,7 +6011,7 @@ class UIInputDummy extends UIAnchor {
5900
6011
  assertValidPositiveNumber(w, "UIInputDummy.constructor.width");
5901
6012
  assertValidPositiveNumber(h, "UIInputDummy.constructor.height");
5902
6013
  super(layer, options);
5903
- this._private_lastPointerInside = false;
6014
+ this._private_wasPointerInside = false;
5904
6015
  this.catchPointerDown = (x, y, identifier) => {
5905
6016
  return this.handleInputEvent(x, y, identifier, UIInputEvent.PRESSED);
5906
6017
  };
@@ -6009,16 +6120,14 @@ class UIInputDummy extends UIAnchor {
6009
6120
  if (isPointerInside) {
6010
6121
  this.emit(inputEvent, x, y, identifier, this);
6011
6122
  }
6012
- if (this._private_lastPointerInside && !isPointerInside) {
6123
+ if (this._private_wasPointerInside && !isPointerInside) {
6013
6124
  this.emit(UIInputEvent.LEFT, x, y, identifier, this);
6014
6125
  }
6015
- else if (!this._private_lastPointerInside && isPointerInside) {
6126
+ else if (!this._private_wasPointerInside && isPointerInside) {
6016
6127
  this.emit(UIInputEvent.ENTERED, x, y, identifier, this);
6017
6128
  }
6018
- this._private_lastPointerInside = isPointerInside;
6019
- return this.modeInternal === UIMode.INTERACTIVE_TRANSPARENT
6020
- ? false
6021
- : isPointerInside;
6129
+ this._private_wasPointerInside = isPointerInside;
6130
+ return (this.modeInternal !== UIMode.INTERACTIVE_TRANSPARENT && isPointerInside);
6022
6131
  }
6023
6132
  }
6024
6133
 
@@ -6042,10 +6151,7 @@ class UIElement extends UIInputDummy {
6042
6151
  this._private_transparencyModeInternal =
6043
6152
  options?.transparencyMode ?? ELEMENT_DEFAULT_TRANSPARENCY_MODE;
6044
6153
  this.sceneWrapper = this.layer.sceneWrapper;
6045
- this.planeHandler = this.sceneWrapper.createPlane(source, properties, this._private_transparencyModeInternal);
6046
- if (options?.mode !== undefined && !isUIModeVisible(options.mode)) {
6047
- this._private_visibilityDirty = true;
6048
- }
6154
+ this.planeHandler = this.sceneWrapper.createPlane(source, properties, new Matrix4().identity(), isUIModeVisible(options?.mode ?? this.mode), this._private_transparencyModeInternal);
6049
6155
  this.layer.on(UILayerEvent.RENDERING, this.onWillRender, this);
6050
6156
  }
6051
6157
  /** Alpha blending mode */
@@ -6105,18 +6211,18 @@ var UIAnimatedImageEvent;
6105
6211
  UIAnimatedImageEvent[UIAnimatedImageEvent["STOPPED"] = 2] = "STOPPED";
6106
6212
  })(UIAnimatedImageEvent || (UIAnimatedImageEvent = {}));
6107
6213
  /** Animation loop behavior */
6108
- var UILoopMode;
6109
- (function (UILoopMode) {
6214
+ var UIAnimatedImageLoopMode;
6215
+ (function (UIAnimatedImageLoopMode) {
6110
6216
  /** No looping, stops at boundary frame */
6111
- UILoopMode[UILoopMode["NONE"] = 0] = "NONE";
6217
+ UIAnimatedImageLoopMode[UIAnimatedImageLoopMode["NONE"] = 0] = "NONE";
6112
6218
  /** Loops back to opposite frame */
6113
- UILoopMode[UILoopMode["LOOP"] = 1] = "LOOP";
6219
+ UIAnimatedImageLoopMode[UIAnimatedImageLoopMode["LOOP"] = 1] = "LOOP";
6114
6220
  /** Reverses direction at boundaries */
6115
- UILoopMode[UILoopMode["PING_PONG"] = 2] = "PING_PONG";
6116
- })(UILoopMode || (UILoopMode = {}));
6221
+ UIAnimatedImageLoopMode[UIAnimatedImageLoopMode["PING_PONG"] = 2] = "PING_PONG";
6222
+ })(UIAnimatedImageLoopMode || (UIAnimatedImageLoopMode = {}));
6117
6223
  const ANIMATED_IMAGE_DEFAULT_FRAME_RATE = 24;
6118
6224
  const ANIMATED_IMAGE_DEFAULT_TIME_SCALE = 1;
6119
- const ANIMATED_IMAGE_DEFAULT_LOOP_MODE = UILoopMode.LOOP;
6225
+ const ANIMATED_IMAGE_DEFAULT_LOOP_MODE = UIAnimatedImageLoopMode.LOOP;
6120
6226
 
6121
6227
  /** Frame-based texture animation element */
6122
6228
  class UIAnimatedImage extends UIElement {
@@ -6151,6 +6257,7 @@ class UIAnimatedImage extends UIElement {
6151
6257
  this.height = height;
6152
6258
  }
6153
6259
  };
6260
+ this._private_colorInternal = color;
6154
6261
  this._private_sequenceInternal = uiTextures;
6155
6262
  this._private_textureTransform = textureTransform;
6156
6263
  this._private_frameRateInternal =
@@ -6159,31 +6266,47 @@ class UIAnimatedImage extends UIElement {
6159
6266
  options.timeScale ?? ANIMATED_IMAGE_DEFAULT_TIME_SCALE;
6160
6267
  this._private_loopModeInternal =
6161
6268
  options.loopMode ?? ANIMATED_IMAGE_DEFAULT_LOOP_MODE;
6162
- this.color = color;
6163
6269
  this._private_subscribeSequenceEvents();
6164
6270
  if (options.playByDefault === true) {
6165
6271
  this.play();
6166
6272
  }
6167
6273
  }
6168
- /** Animation frames as readonly array */
6169
- get sequence() {
6170
- return this._private_sequenceInternal;
6274
+ /** Multiplicative tint. Alpha channel controls opacity. */
6275
+ get color() {
6276
+ return this._private_colorInternal;
6277
+ }
6278
+ /** Total animation duration in seconds */
6279
+ get duration() {
6280
+ return this._private_sequenceInternal.length / this._private_frameRateInternal;
6171
6281
  }
6172
6282
  /** Animation speed in frames per second */
6173
6283
  get frameRate() {
6174
6284
  return this._private_frameRateInternal;
6175
6285
  }
6286
+ /** Loop behavior */
6287
+ get loopMode() {
6288
+ return this._private_loopModeInternal;
6289
+ }
6290
+ /** Animation frames as readonly array */
6291
+ get sequence() {
6292
+ return this._private_sequenceInternal;
6293
+ }
6176
6294
  /** Playback speed multiplier. Can be negative for reverse playback. */
6177
6295
  get timeScale() {
6178
6296
  return this._private_timeScaleInternal;
6179
6297
  }
6180
- /** Loop behavior */
6181
- get loopMode() {
6182
- return this._private_loopModeInternal;
6298
+ /** Multiplicative tint. Alpha channel controls opacity. */
6299
+ set color(value) {
6300
+ this._private_colorInternal.set(value);
6183
6301
  }
6184
- /** Total animation duration in seconds */
6185
- get duration() {
6186
- return this._private_sequenceInternal.length / this._private_frameRateInternal;
6302
+ /** Animation speed in frames per second */
6303
+ set frameRate(value) {
6304
+ assertValidPositiveNumber(value, "UIAnimatedImage.frameRate");
6305
+ this._private_frameRateInternal = value;
6306
+ }
6307
+ /** Loop behavior */
6308
+ set loopMode(value) {
6309
+ this._private_loopModeInternal = value;
6187
6310
  }
6188
6311
  /** Replaces animation frames. Stops playback. */
6189
6312
  set sequence(sequence) {
@@ -6204,20 +6327,11 @@ class UIAnimatedImage extends UIElement {
6204
6327
  }
6205
6328
  this._private_subscribeSequenceEvents();
6206
6329
  }
6207
- /** Animation speed in frames per second */
6208
- set frameRate(value) {
6209
- assertValidPositiveNumber(value, "UIAnimatedImage.frameRate");
6210
- this._private_frameRateInternal = value;
6211
- }
6212
6330
  /** Playback speed multiplier. Can be negative for reverse playback. */
6213
6331
  set timeScale(value) {
6214
6332
  assertValidNumber(value, "UIAnimatedImage.timeScale");
6215
6333
  this._private_timeScaleInternal = value;
6216
6334
  }
6217
- /** Loop behavior */
6218
- set loopMode(value) {
6219
- this._private_loopModeInternal = value;
6220
- }
6221
6335
  /** Removes element and frees resources */
6222
6336
  destroy() {
6223
6337
  this._private_unsubscribeSequenceEvents();
@@ -6260,10 +6374,10 @@ class UIAnimatedImage extends UIElement {
6260
6374
  this._private_accumulatedTime -= frameDuration;
6261
6375
  this._private_sequenceFrameIndex += 1;
6262
6376
  if (this._private_sequenceFrameIndex >= sequenceLength) {
6263
- if (this._private_loopModeInternal === UILoopMode.LOOP) {
6377
+ if (this._private_loopModeInternal === UIAnimatedImageLoopMode.LOOP) {
6264
6378
  this._private_sequenceFrameIndex = 0;
6265
6379
  }
6266
- else if (this._private_loopModeInternal === UILoopMode.PING_PONG) {
6380
+ else if (this._private_loopModeInternal === UIAnimatedImageLoopMode.PING_PONG) {
6267
6381
  this._private_sequenceFrameIndex = lastFrameIndex;
6268
6382
  this._private_timeScaleInternal = -this._private_timeScaleInternal;
6269
6383
  }
@@ -6282,10 +6396,10 @@ class UIAnimatedImage extends UIElement {
6282
6396
  this._private_accumulatedTime += frameDuration;
6283
6397
  this._private_sequenceFrameIndex -= 1;
6284
6398
  if (this._private_sequenceFrameIndex < 0) {
6285
- if (this._private_loopModeInternal === UILoopMode.LOOP) {
6399
+ if (this._private_loopModeInternal === UIAnimatedImageLoopMode.LOOP) {
6286
6400
  this._private_sequenceFrameIndex = lastFrameIndex;
6287
6401
  }
6288
- else if (this._private_loopModeInternal === UILoopMode.PING_PONG) {
6402
+ else if (this._private_loopModeInternal === UIAnimatedImageLoopMode.PING_PONG) {
6289
6403
  this._private_sequenceFrameIndex = 0;
6290
6404
  this._private_timeScaleInternal = -this._private_timeScaleInternal;
6291
6405
  }
@@ -6304,10 +6418,10 @@ class UIAnimatedImage extends UIElement {
6304
6418
  }
6305
6419
  setPlaneTransform() {
6306
6420
  let properties;
6307
- if (this.color.dirty) {
6421
+ if (this._private_colorInternal.dirty) {
6308
6422
  properties ?? (properties = {});
6309
- properties["color"] = this.color;
6310
- this.color.setDirtyFalse();
6423
+ properties["color"] = this._private_colorInternal;
6424
+ this._private_colorInternal.setDirtyFalse();
6311
6425
  }
6312
6426
  const frame = this._private_sequenceInternal[this._private_sequenceFrameIndex];
6313
6427
  if (frame.textureDirty || this._private_currentFrameIndexDirty) {
@@ -6349,6 +6463,10 @@ class UIAnimatedImage extends UIElement {
6349
6463
  }
6350
6464
  }
6351
6465
 
6466
+ const GRAPHICS_DEFAULT_WIDTH = 2;
6467
+ const GRAPHICS_DEFAULT_HEIGHT = 2;
6468
+ const GRAPHICS_TEMP_COLOR = new UIColor();
6469
+
6352
6470
  /** Canvas-based 2D drawing element */
6353
6471
  class UIGraphics extends UIElement {
6354
6472
  /**
@@ -6358,8 +6476,8 @@ class UIGraphics extends UIElement {
6358
6476
  * @param options - Configuration options
6359
6477
  */
6360
6478
  constructor(layer, options) {
6361
- const w = options?.width ?? DUMMY_DEFAULT_WIDTH;
6362
- const h = options?.height ?? DUMMY_DEFAULT_HEIGHT;
6479
+ const w = options?.width ?? GRAPHICS_DEFAULT_WIDTH;
6480
+ const h = options?.height ?? GRAPHICS_DEFAULT_HEIGHT;
6363
6481
  const color = new UIColor(options?.color);
6364
6482
  const canvas = new OffscreenCanvas(w, h);
6365
6483
  const context = canvas.getContext("2d");
@@ -6373,13 +6491,21 @@ class UIGraphics extends UIElement {
6373
6491
  texture.needsUpdate = true;
6374
6492
  super(layer, source$4, {
6375
6493
  texture: texture,
6376
- textureTransform: texture.matrix,
6494
+ textureTransform: new Matrix4(),
6377
6495
  color,
6378
6496
  }, options);
6379
6497
  this._private_canvas = canvas;
6380
6498
  this._private_context = context;
6381
6499
  this._private_texture = texture;
6382
- this.color = color;
6500
+ this._private_colorInternal = color;
6501
+ }
6502
+ /** Multiplicative tint. Alpha channel controls opacity. */
6503
+ get color() {
6504
+ return this._private_colorInternal;
6505
+ }
6506
+ /** Multiplicative tint. Alpha channel controls opacity. */
6507
+ set color(value) {
6508
+ this._private_colorInternal.set(value);
6383
6509
  }
6384
6510
  /**
6385
6511
  * Clears canvas. Optionally fills with color.
@@ -6389,7 +6515,7 @@ class UIGraphics extends UIElement {
6389
6515
  clear(color) {
6390
6516
  this._private_context.clearRect(0, 0, this._private_canvas.width, this._private_canvas.height);
6391
6517
  if (color !== undefined) {
6392
- this._private_context.fillStyle = color.toCSSColor();
6518
+ this._private_context.fillStyle = GRAPHICS_TEMP_COLOR.set(color).toCSSColor();
6393
6519
  this._private_context.fillRect(0, 0, this._private_canvas.width, this._private_canvas.height);
6394
6520
  }
6395
6521
  this._private_texture.needsUpdate = true;
@@ -6397,14 +6523,14 @@ class UIGraphics extends UIElement {
6397
6523
  }
6398
6524
  /** Draws filled rectangle */
6399
6525
  drawRect(x, y, width, height, color) {
6400
- this._private_context.fillStyle = color.toCSSColor();
6526
+ this._private_context.fillStyle = GRAPHICS_TEMP_COLOR.set(color).toCSSColor();
6401
6527
  this._private_context.fillRect(x, y, width, height);
6402
6528
  this._private_texture.needsUpdate = true;
6403
6529
  return this;
6404
6530
  }
6405
6531
  /** Draws filled circle */
6406
6532
  drawCircle(x, y, radius, color) {
6407
- this._private_context.fillStyle = color.toCSSColor();
6533
+ this._private_context.fillStyle = GRAPHICS_TEMP_COLOR.set(color).toCSSColor();
6408
6534
  this._private_context.beginPath();
6409
6535
  this._private_context.arc(x, y, radius, 0, Math.PI * 2);
6410
6536
  this._private_context.fill();
@@ -6418,7 +6544,7 @@ class UIGraphics extends UIElement {
6418
6544
  * @param endAngle - End angle in radians
6419
6545
  */
6420
6546
  drawArc(x, y, radius, startAngle, endAngle, color) {
6421
- this._private_context.fillStyle = color.toCSSColor();
6547
+ this._private_context.fillStyle = GRAPHICS_TEMP_COLOR.set(color).toCSSColor();
6422
6548
  this._private_context.beginPath();
6423
6549
  this._private_context.arc(x, y, radius, startAngle, endAngle);
6424
6550
  this._private_context.fill();
@@ -6435,7 +6561,7 @@ class UIGraphics extends UIElement {
6435
6561
  if (points.length < 2) {
6436
6562
  return this;
6437
6563
  }
6438
- this._private_context.strokeStyle = color.toCSSColor();
6564
+ this._private_context.strokeStyle = GRAPHICS_TEMP_COLOR.set(color).toCSSColor();
6439
6565
  this._private_context.lineWidth = lineWidth;
6440
6566
  this._private_context.beginPath();
6441
6567
  this._private_context.moveTo(points[0][0], points[0][1]);
@@ -6452,9 +6578,11 @@ class UIGraphics extends UIElement {
6452
6578
  super.destroy();
6453
6579
  }
6454
6580
  onWillRender(renderer, deltaTime) {
6455
- if (this.color.dirty) {
6456
- this.sceneWrapper.setProperties(this.planeHandler, { color: this.color });
6457
- this.color.setDirtyFalse();
6581
+ if (this._private_colorInternal.dirty) {
6582
+ this.sceneWrapper.setProperties(this.planeHandler, {
6583
+ color: this._private_colorInternal,
6584
+ });
6585
+ this._private_colorInternal.setDirtyFalse();
6458
6586
  }
6459
6587
  super.onWillRender(renderer, deltaTime);
6460
6588
  }
@@ -6488,9 +6616,17 @@ class UIImage extends UIElement {
6488
6616
  };
6489
6617
  this.texture = textureView;
6490
6618
  this._private_textureTransform = textureTransform;
6491
- this.color = color;
6619
+ this._private_colorInternal = color;
6492
6620
  this.texture.on(UITextureViewEvent.DIMENSIONS_CHANGED, this._private_onTextureDimensionsChanged);
6493
6621
  }
6622
+ /** Multiplicative tint. Alpha channel controls opacity. */
6623
+ get color() {
6624
+ return this._private_colorInternal;
6625
+ }
6626
+ /** Multiplicative tint. Alpha channel controls opacity. */
6627
+ set color(value) {
6628
+ this._private_colorInternal.set(value);
6629
+ }
6494
6630
  /** Removes image and frees resources */
6495
6631
  destroy() {
6496
6632
  this.texture.off(UITextureViewEvent.DIMENSIONS_CHANGED, this._private_onTextureDimensionsChanged);
@@ -6498,10 +6634,10 @@ class UIImage extends UIElement {
6498
6634
  }
6499
6635
  setPlaneTransform() {
6500
6636
  let properties;
6501
- if (this.color.dirty) {
6637
+ if (this._private_colorInternal.dirty) {
6502
6638
  properties ?? (properties = {});
6503
- properties["color"] = this.color;
6504
- this.color.setDirtyFalse();
6639
+ properties["color"] = this._private_colorInternal;
6640
+ this._private_colorInternal.setDirtyFalse();
6505
6641
  }
6506
6642
  if (this.texture.textureDirty) {
6507
6643
  properties ?? (properties = {});
@@ -6540,44 +6676,12 @@ class UIInsets {
6540
6676
  * @param config - Insets configuration
6541
6677
  */
6542
6678
  constructor(config) {
6679
+ this._private_lInternal = INSETS_DEFAULT_VALUE;
6680
+ this._private_rInternal = INSETS_DEFAULT_VALUE;
6681
+ this._private_tInternal = INSETS_DEFAULT_VALUE;
6682
+ this._private_bInternal = INSETS_DEFAULT_VALUE;
6543
6683
  this._private_dirtyInternal = false;
6544
- if (config === undefined) {
6545
- this._private_lInternal = INSETS_DEFAULT_VALUE;
6546
- this._private_rInternal = INSETS_DEFAULT_VALUE;
6547
- this._private_tInternal = INSETS_DEFAULT_VALUE;
6548
- this._private_bInternal = INSETS_DEFAULT_VALUE;
6549
- }
6550
- else if (typeof config === "number") {
6551
- assertValidNonNegativeNumber(config, "UIInsets.constructor.config");
6552
- this._private_lInternal = config;
6553
- this._private_rInternal = config;
6554
- this._private_tInternal = config;
6555
- this._private_bInternal = config;
6556
- }
6557
- else if ("left" in config) {
6558
- const left = config.left;
6559
- const right = config.right;
6560
- const top = config.top;
6561
- const bottom = config.bottom;
6562
- assertValidNonNegativeNumber(left, "UIInsets.constructor.config.left");
6563
- assertValidNonNegativeNumber(right, "UIInsets.constructor.config.right");
6564
- assertValidNonNegativeNumber(top, "UIInsets.constructor.config.top");
6565
- assertValidNonNegativeNumber(bottom, "UIInsets.constructor.config.bottom");
6566
- this._private_lInternal = left;
6567
- this._private_rInternal = right;
6568
- this._private_tInternal = top;
6569
- this._private_bInternal = bottom;
6570
- }
6571
- else {
6572
- const horizontal = config.horizontal;
6573
- const vertical = config.vertical;
6574
- assertValidNonNegativeNumber(horizontal, "UIInsets.constructor.config.horizontal");
6575
- assertValidNonNegativeNumber(vertical, "UIInsets.constructor.config.vertical");
6576
- this._private_lInternal = horizontal;
6577
- this._private_rInternal = horizontal;
6578
- this._private_tInternal = vertical;
6579
- this._private_bInternal = vertical;
6580
- }
6684
+ this.set(config);
6581
6685
  }
6582
6686
  /** Left inset */
6583
6687
  get left() {
@@ -6663,6 +6767,82 @@ class UIInsets {
6663
6767
  this._private_dirtyInternal = true;
6664
6768
  }
6665
6769
  }
6770
+ /** Sets insets */
6771
+ set(config) {
6772
+ const lOld = this._private_lInternal;
6773
+ const rOld = this._private_rInternal;
6774
+ const tOld = this._private_tInternal;
6775
+ const bOld = this._private_bInternal;
6776
+ if (config === undefined) {
6777
+ this._private_lInternal = INSETS_DEFAULT_VALUE;
6778
+ this._private_rInternal = INSETS_DEFAULT_VALUE;
6779
+ this._private_tInternal = INSETS_DEFAULT_VALUE;
6780
+ this._private_bInternal = INSETS_DEFAULT_VALUE;
6781
+ }
6782
+ else if (typeof config === "number") {
6783
+ assertValidNonNegativeNumber(config, "UIInsets.set.config");
6784
+ this._private_lInternal = config;
6785
+ this._private_rInternal = config;
6786
+ this._private_tInternal = config;
6787
+ this._private_bInternal = config;
6788
+ }
6789
+ else if (Array.isArray(config)) {
6790
+ if (config.length === 2) {
6791
+ const horizontal = config[0];
6792
+ const vertical = config[1];
6793
+ assertValidNonNegativeNumber(horizontal, "UIInsets.set.config[0]");
6794
+ assertValidNonNegativeNumber(vertical, "UIInsets.set.config[1]");
6795
+ this._private_lInternal = horizontal;
6796
+ this._private_rInternal = horizontal;
6797
+ this._private_tInternal = vertical;
6798
+ this._private_bInternal = vertical;
6799
+ }
6800
+ else {
6801
+ const left = config[0];
6802
+ const right = config[1];
6803
+ const top = config[2];
6804
+ const bottom = config[3];
6805
+ assertValidNonNegativeNumber(left, "UIInsets.set.config[0]");
6806
+ assertValidNonNegativeNumber(right, "UIInsets.set.config[1]");
6807
+ assertValidNonNegativeNumber(top, "UIInsets.set.config[2]");
6808
+ assertValidNonNegativeNumber(bottom, "UIInsets.set.config[3]");
6809
+ this._private_lInternal = left;
6810
+ this._private_rInternal = right;
6811
+ this._private_tInternal = top;
6812
+ this._private_bInternal = bottom;
6813
+ }
6814
+ }
6815
+ else if ("left" in config) {
6816
+ const left = config.left;
6817
+ const right = config.right;
6818
+ const top = config.top;
6819
+ const bottom = config.bottom;
6820
+ assertValidNonNegativeNumber(left, "UIInsets.set.config.left");
6821
+ assertValidNonNegativeNumber(right, "UIInsets.set.config.right");
6822
+ assertValidNonNegativeNumber(top, "UIInsets.set.config.top");
6823
+ assertValidNonNegativeNumber(bottom, "UIInsets.set.config.bottom");
6824
+ this._private_lInternal = left;
6825
+ this._private_rInternal = right;
6826
+ this._private_tInternal = top;
6827
+ this._private_bInternal = bottom;
6828
+ }
6829
+ else {
6830
+ const horizontal = config.horizontal;
6831
+ const vertical = config.vertical;
6832
+ assertValidNonNegativeNumber(horizontal, "UIInsets.set.config.horizontal");
6833
+ assertValidNonNegativeNumber(vertical, "UIInsets.set.config.vertical");
6834
+ this._private_lInternal = horizontal;
6835
+ this._private_rInternal = horizontal;
6836
+ this._private_tInternal = vertical;
6837
+ this._private_bInternal = vertical;
6838
+ }
6839
+ if (this._private_lInternal !== lOld ||
6840
+ this._private_rInternal !== rOld ||
6841
+ this._private_tInternal !== tOld ||
6842
+ this._private_bInternal !== bOld) {
6843
+ this._private_dirtyInternal = true;
6844
+ }
6845
+ }
6666
6846
  /** Sets from Vector4 (x=left, y=right, z=top, w=bottom) */
6667
6847
  setVector4(vector) {
6668
6848
  assertValidNonNegativeNumber(vector.x, "UIInsets.setVector4.vector.x");
@@ -6758,9 +6938,9 @@ class UINineSlice extends UIElement {
6758
6938
  };
6759
6939
  this.texture = textureView;
6760
6940
  this._private_textureTransform = textureTransform;
6761
- this.color = color;
6762
- this.sliceBorders = sliceBorders;
6763
- this.sliceRegions = sliceRegions;
6941
+ this._private_colorInternal = color;
6942
+ this._private_sliceBordersInternal = sliceBorders;
6943
+ this._private_sliceRegionsInternal = sliceRegions;
6764
6944
  this._private_regionModeInternal = regionMode;
6765
6945
  this._private_sliceBordersVector = sliceBordersVector;
6766
6946
  this._private_sliceRegionsVector = sliceRegionsVector;
@@ -6768,10 +6948,26 @@ class UINineSlice extends UIElement {
6768
6948
  this._private_lastElementHeight = this.height;
6769
6949
  this.texture.on(UITextureViewEvent.DIMENSIONS_CHANGED, this._private_onTextureDimensionsChanged);
6770
6950
  }
6951
+ /** Multiplicative tint. Alpha channel controls opacity. */
6952
+ get color() {
6953
+ return this._private_colorInternal;
6954
+ }
6771
6955
  /** Controls how sliceRegions values are interpreted */
6772
6956
  get regionMode() {
6773
6957
  return this._private_regionModeInternal;
6774
6958
  }
6959
+ /** Border size in normalized texture coordinates (0 to 1) */
6960
+ get sliceBorders() {
6961
+ return this._private_sliceBordersInternal;
6962
+ }
6963
+ /** Region size. Interpretation depends on regionMode. */
6964
+ get sliceRegions() {
6965
+ return this._private_sliceRegionsInternal;
6966
+ }
6967
+ /** Multiplicative tint. Alpha channel controls opacity. */
6968
+ set color(value) {
6969
+ this._private_colorInternal.set(value);
6970
+ }
6775
6971
  /** Controls how sliceRegions values are interpreted */
6776
6972
  set regionMode(value) {
6777
6973
  if (this._private_regionModeInternal !== value) {
@@ -6779,6 +6975,14 @@ class UINineSlice extends UIElement {
6779
6975
  this._private_regionModeDirty = true;
6780
6976
  }
6781
6977
  }
6978
+ /** Border size in normalized texture coordinates (0 to 1) */
6979
+ set sliceBorders(value) {
6980
+ this._private_sliceBordersInternal.set(value);
6981
+ }
6982
+ /** Region size. Interpretation depends on regionMode. */
6983
+ set sliceRegions(value) {
6984
+ this._private_sliceRegionsInternal.set(value);
6985
+ }
6782
6986
  /** Removes nine slice and frees resources */
6783
6987
  destroy() {
6784
6988
  this.texture.off(UITextureViewEvent.DIMENSIONS_CHANGED, this._private_onTextureDimensionsChanged);
@@ -6787,28 +6991,28 @@ class UINineSlice extends UIElement {
6787
6991
  setPlaneTransform() {
6788
6992
  let properties;
6789
6993
  const sliceBordersDirty = this._private_textureDimensionsDirty ||
6790
- this.sliceBorders.dirty ||
6994
+ this._private_sliceBordersInternal.dirty ||
6791
6995
  this.texture.trimDirty;
6792
6996
  if (sliceBordersDirty) {
6793
6997
  properties ?? (properties = {});
6794
6998
  properties["sliceBorders"] = this._private_calculateSliceBordersForShader(this._private_sliceBordersVector);
6795
- this.sliceBorders.setDirtyFalse();
6999
+ this._private_sliceBordersInternal.setDirtyFalse();
6796
7000
  this._private_textureDimensionsDirty = false;
6797
7001
  }
6798
- const sliceRegionsDirty = this.sliceRegions.dirty || this._private_regionModeDirty ||
7002
+ const sliceRegionsDirty = this._private_sliceRegionsInternal.dirty || this._private_regionModeDirty ||
6799
7003
  (this._private_regionModeInternal === UINineSliceRegionMode.WORLD &&
6800
7004
  this._private_checkElementDimensionsDirty());
6801
7005
  if (sliceRegionsDirty) {
6802
7006
  properties ?? (properties = {});
6803
7007
  properties["sliceRegions"] = this._private_calculateSliceRegionsForShader(this._private_sliceRegionsVector);
6804
- this.sliceRegions.setDirtyFalse();
7008
+ this._private_sliceRegionsInternal.setDirtyFalse();
6805
7009
  this._private_regionModeDirty = false;
6806
7010
  this._private_setElementDimensionsDirtyFalse();
6807
7011
  }
6808
- if (this.color.dirty) {
7012
+ if (this._private_colorInternal.dirty) {
6809
7013
  properties ?? (properties = {});
6810
- properties["color"] = this.color;
6811
- this.color.setDirtyFalse();
7014
+ properties["color"] = this._private_colorInternal;
7015
+ this._private_colorInternal.setDirtyFalse();
6812
7016
  }
6813
7017
  if (this.texture.textureDirty) {
6814
7018
  properties ?? (properties = {});
@@ -6847,10 +7051,10 @@ class UINineSlice extends UIElement {
6847
7051
  const trimNBottom = trim.bottom / sourceHeight;
6848
7052
  const trimmedWidthNorm = trimmedWidth / sourceWidth;
6849
7053
  const trimmedHeightNorm = trimmedHeight / sourceHeight;
6850
- const srcLeft = this.sliceBorders.left;
6851
- const srcRight = this.sliceBorders.right;
6852
- const srcTop = this.sliceBorders.top;
6853
- const srcBottom = this.sliceBorders.bottom;
7054
+ const srcLeft = this._private_sliceBordersInternal.left;
7055
+ const srcRight = this._private_sliceBordersInternal.right;
7056
+ const srcTop = this._private_sliceBordersInternal.top;
7057
+ const srcBottom = this._private_sliceBordersInternal.bottom;
6854
7058
  const left = Math.max(0, srcLeft - trimNLeft) / trimmedWidthNorm;
6855
7059
  const right = Math.max(0, srcRight - trimNRight) / trimmedWidthNorm;
6856
7060
  const top = Math.max(0, srcTop - trimNTop) / trimmedHeightNorm;
@@ -6859,11 +7063,11 @@ class UINineSlice extends UIElement {
6859
7063
  }
6860
7064
  _private_calculateSliceRegionsForShader(result) {
6861
7065
  if (this._private_regionModeInternal === UINineSliceRegionMode.NORMALIZED) {
6862
- return result.set(this.sliceRegions.left, this.sliceRegions.right, this.sliceRegions.top, this.sliceRegions.bottom);
7066
+ return result.set(this._private_sliceRegionsInternal.left, this._private_sliceRegionsInternal.right, this._private_sliceRegionsInternal.top, this._private_sliceRegionsInternal.bottom);
6863
7067
  }
6864
7068
  const width = this.width;
6865
7069
  const height = this.height;
6866
- return result.set(this.sliceRegions.left / width, this.sliceRegions.right / width, this.sliceRegions.top / height, this.sliceRegions.bottom / height);
7070
+ return result.set(this._private_sliceRegionsInternal.left / width, this._private_sliceRegionsInternal.right / width, this._private_sliceRegionsInternal.top / height, this._private_sliceRegionsInternal.bottom / height);
6867
7071
  }
6868
7072
  _private_checkElementDimensionsDirty() {
6869
7073
  return (this.solverWrapper.dirty &&
@@ -6985,15 +7189,34 @@ class UIProgress extends UIElement {
6985
7189
  this.texture = textureView;
6986
7190
  this._private_textureTransform = textureTransform;
6987
7191
  this._private_textureResolution = textureResolution;
6988
- this.color = color;
7192
+ this._private_colorInternal = color;
6989
7193
  this._private_progressInternal = progress;
6990
- this.maskFunction = maskFunction;
7194
+ this._private_maskFunctionInternal = maskFunction;
6991
7195
  this.texture.on(UITextureViewEvent.DIMENSIONS_CHANGED, this._private_onTextureDimensionsChanged);
6992
7196
  }
7197
+ /** Multiplicative tint. Alpha channel controls opacity. */
7198
+ get color() {
7199
+ return this._private_colorInternal;
7200
+ }
7201
+ /** Function controlling fill direction and shape */
7202
+ get maskFunction() {
7203
+ return this._private_maskFunctionInternal;
7204
+ }
6993
7205
  /** Progress from 0 (empty) to 1 (full) */
6994
7206
  get progress() {
6995
7207
  return this._private_progressInternal;
6996
7208
  }
7209
+ /** Multiplicative tint. Alpha channel controls opacity. */
7210
+ set color(value) {
7211
+ this._private_colorInternal.set(value);
7212
+ }
7213
+ /** Function controlling fill direction and shape */
7214
+ set maskFunction(value) {
7215
+ if (this._private_maskFunctionInternal !== value) {
7216
+ this._private_maskFunctionInternal = value;
7217
+ this._private_rebuildPlane();
7218
+ }
7219
+ }
6997
7220
  /** Progress from 0 (empty) to 1 (full). Clamped. */
6998
7221
  set progress(value) {
6999
7222
  assertValidNumber(value, "UIProgress.progress");
@@ -7005,10 +7228,10 @@ class UIProgress extends UIElement {
7005
7228
  }
7006
7229
  setPlaneTransform() {
7007
7230
  let properties;
7008
- if (this.color.dirty) {
7231
+ if (this._private_colorInternal.dirty) {
7009
7232
  properties ?? (properties = {});
7010
- properties["color"] = this.color;
7011
- this.color.setDirtyFalse();
7233
+ properties["color"] = this._private_colorInternal;
7234
+ this._private_colorInternal.setDirtyFalse();
7012
7235
  }
7013
7236
  if (this.texture.textureDirty) {
7014
7237
  properties ?? (properties = {});
@@ -7053,13 +7276,34 @@ class UIProgress extends UIElement {
7053
7276
  this.texture.setTrimDirtyFalse();
7054
7277
  }
7055
7278
  }
7279
+ _private_rebuildPlane() {
7280
+ this.sceneWrapper.destroyPlane(this.planeHandler);
7281
+ const micro = this.micro;
7282
+ const textureTrim = this.texture.trim;
7283
+ this.planeHandler = this.sceneWrapper.createPlane(this._private_maskFunctionInternal.source + source$1, {
7284
+ texture: this.texture.texture,
7285
+ textureTransform: this.texture.calculateUVTransform(this._private_textureTransform),
7286
+ textureResolution: this.texture.getResolution(this._private_textureResolution),
7287
+ color: this._private_colorInternal,
7288
+ progress: this._private_progressInternal,
7289
+ ...this._private_maskFunctionInternal.enumerateProperties(),
7290
+ }, computeTrimmedTransformMatrix(this.x, this.y, this.width, this.height, this.zIndex, micro.x, micro.y, micro.anchorX, micro.anchorY, micro.scaleX, micro.scaleY, micro.rotation, micro.anchorMode, textureTrim.left, textureTrim.right, textureTrim.top, textureTrim.bottom), isUIModeVisible(this.mode), this.transparencyMode);
7291
+ this._private_colorInternal.setDirtyFalse();
7292
+ this.texture.setTextureDirtyFalse();
7293
+ this.texture.setUVTransformDirtyFalse();
7294
+ this.texture.setTrimDirtyFalse();
7295
+ this._private_progressDirty = false;
7296
+ this._private_textureResolutionDirty = false;
7297
+ this._private_maskFunctionInternal.setDirtyFalse();
7298
+ this.micro.setDirtyFalse();
7299
+ }
7056
7300
  }
7057
7301
 
7058
7302
  /** Controls when scene re-renders */
7059
7303
  var UISceneUpdateMode;
7060
7304
  (function (UISceneUpdateMode) {
7061
7305
  /** Re-render every frame */
7062
- UISceneUpdateMode[UISceneUpdateMode["EACH_FRAME"] = 1] = "EACH_FRAME";
7306
+ UISceneUpdateMode[UISceneUpdateMode["EVERY_FRAME"] = 1] = "EVERY_FRAME";
7063
7307
  /** Re-render every other frame */
7064
7308
  UISceneUpdateMode[UISceneUpdateMode["EVERY_SECOND_FRAME"] = 2] = "EVERY_SECOND_FRAME";
7065
7309
  /** Re-render when scene, camera, or updateMode changes */
@@ -7113,8 +7357,8 @@ class UIScene extends UIElement {
7113
7357
  this._private_updateRequired = false;
7114
7358
  this._private_resolutionFactorDirty = false;
7115
7359
  this._private_propertyDirty = false;
7116
- this.color = color;
7117
- this.clearColor = new UIColor(options.clearColor ?? SCENE_DEFAULT_CLEAR_COLOR);
7360
+ this._private_colorInternal = color;
7361
+ this._private_clearColorInternal = new UIColor(options.clearColor ?? SCENE_DEFAULT_CLEAR_COLOR);
7118
7362
  this._private_renderTarget = renderTarget;
7119
7363
  this._private_sceneInternal = options.scene ?? new Scene();
7120
7364
  this._private_cameraInternal =
@@ -7124,28 +7368,29 @@ class UIScene extends UIElement {
7124
7368
  this._private_updateModeInternal = options.updateMode ?? SCENE_DEFAULT_UPDATE_MODE;
7125
7369
  this._private_propertyDirty = options.updateMode !== UISceneUpdateMode.MANUAL;
7126
7370
  }
7127
- /** Three.js scene to render */
7128
- get scene() {
7129
- return this._private_sceneInternal;
7130
- }
7131
7371
  /** Camera used for rendering */
7132
7372
  get camera() {
7133
7373
  return this._private_cameraInternal;
7134
7374
  }
7135
- /** Controls when scene re-renders */
7136
- get updateMode() {
7137
- return this._private_updateModeInternal;
7375
+ /** Background color for render target */
7376
+ get clearColor() {
7377
+ return this._private_clearColorInternal;
7378
+ }
7379
+ /** Multiplicative tint. Alpha channel controls opacity. */
7380
+ get color() {
7381
+ return this._private_colorInternal;
7138
7382
  }
7139
7383
  /** Render target resolution multiplier. Range 0.1 to 2.0. */
7140
7384
  get resolutionFactor() {
7141
7385
  return this._private_resolutionFactorInternal;
7142
7386
  }
7143
7387
  /** Three.js scene to render */
7144
- set scene(value) {
7145
- if (this._private_sceneInternal !== value) {
7146
- this._private_sceneInternal = value;
7147
- this._private_propertyDirty = true;
7148
- }
7388
+ get scene() {
7389
+ return this._private_sceneInternal;
7390
+ }
7391
+ /** Controls when scene re-renders */
7392
+ get updateMode() {
7393
+ return this._private_updateModeInternal;
7149
7394
  }
7150
7395
  /** Camera used for rendering */
7151
7396
  set camera(value) {
@@ -7154,12 +7399,13 @@ class UIScene extends UIElement {
7154
7399
  this._private_propertyDirty = true;
7155
7400
  }
7156
7401
  }
7157
- /** Controls when scene re-renders */
7158
- set updateMode(value) {
7159
- if (this._private_updateModeInternal !== value) {
7160
- this._private_updateModeInternal = value;
7161
- this._private_propertyDirty = true;
7162
- }
7402
+ /** Background color for render target */
7403
+ set clearColor(value) {
7404
+ this._private_clearColorInternal.set(value);
7405
+ }
7406
+ /** Multiplicative tint. Alpha channel controls opacity. */
7407
+ set color(value) {
7408
+ this._private_colorInternal.set(value);
7163
7409
  }
7164
7410
  /** Render target resolution multiplier. Range 0.1 to 2.0. */
7165
7411
  set resolutionFactor(value) {
@@ -7170,6 +7416,20 @@ class UIScene extends UIElement {
7170
7416
  this._private_resolutionFactorDirty = true;
7171
7417
  }
7172
7418
  }
7419
+ /** Three.js scene to render */
7420
+ set scene(value) {
7421
+ if (this._private_sceneInternal !== value) {
7422
+ this._private_sceneInternal = value;
7423
+ this._private_propertyDirty = true;
7424
+ }
7425
+ }
7426
+ /** Controls when scene re-renders */
7427
+ set updateMode(value) {
7428
+ if (this._private_updateModeInternal !== value) {
7429
+ this._private_updateModeInternal = value;
7430
+ this._private_propertyDirty = true;
7431
+ }
7432
+ }
7173
7433
  /** Removes element and frees resources */
7174
7434
  destroy() {
7175
7435
  this._private_renderTarget.dispose();
@@ -7182,11 +7442,11 @@ class UIScene extends UIElement {
7182
7442
  onWillRender(renderer, deltaTime) {
7183
7443
  this._private_evenFrame = !this._private_evenFrame;
7184
7444
  const isFramebufferDirty = this._private_updateRequired ||
7185
- this._private_updateModeInternal === UISceneUpdateMode.EACH_FRAME ||
7445
+ this._private_updateModeInternal === UISceneUpdateMode.EVERY_FRAME ||
7186
7446
  (this._private_updateModeInternal === UISceneUpdateMode.EVERY_SECOND_FRAME && this._private_evenFrame) ||
7187
7447
  (this._private_updateModeInternal === UISceneUpdateMode.ON_PROPERTIES_CHANGE && this._private_propertyDirty) ||
7188
- this.color.dirty ||
7189
- this.clearColor.dirty ||
7448
+ this._private_colorInternal.dirty ||
7449
+ this._private_clearColorInternal.dirty ||
7190
7450
  (this._private_updateModeInternal === UISceneUpdateMode.ON_DIMENSIONS_CHANGE &&
7191
7451
  (this._private_resolutionFactorDirty || this.solverWrapper.dirty));
7192
7452
  if (isFramebufferDirty) {
@@ -7194,13 +7454,13 @@ class UIScene extends UIElement {
7194
7454
  this._private_renderTarget.setSize(this.width * this._private_resolutionFactorInternal, this.height * this._private_resolutionFactorInternal);
7195
7455
  this._private_resolutionFactorDirty = false;
7196
7456
  }
7197
- if (this.color.dirty) {
7457
+ if (this._private_colorInternal.dirty) {
7198
7458
  this.sceneWrapper.setProperties(this.planeHandler, {
7199
- color: this.color,
7459
+ color: this._private_colorInternal,
7200
7460
  });
7201
- this.color.setDirtyFalse();
7461
+ this._private_colorInternal.setDirtyFalse();
7202
7462
  }
7203
- renderer.setClearColor(this.clearColor.getHexRGB(), this.clearColor.a);
7463
+ renderer.setClearColor(this._private_clearColorInternal.getHexRGB(), this._private_clearColorInternal.a);
7204
7464
  renderer.setRenderTarget(this._private_renderTarget);
7205
7465
  renderer.clear(true, true, false);
7206
7466
  renderer.render(this._private_sceneInternal, this._private_cameraInternal);
@@ -7884,8 +8144,8 @@ class UIText extends UIElement {
7884
8144
  this._private_resizeModeDirty = false;
7885
8145
  this._private_textChunks = [];
7886
8146
  this._private_textChunksDirty = false;
7887
- this.color = color;
7888
- this.padding = new UIInsets(options.padding);
8147
+ this._private_colorInternal = color;
8148
+ this._private_paddingInternal = new UIInsets(options.padding);
7889
8149
  this.commonStyle = new UITextStyle(options.commonStyle);
7890
8150
  this._private_maxLineWidthInternal =
7891
8151
  options.maxLineWidth ?? TEXT_DEFAULT_MAX_LINE_WIDTH;
@@ -7897,7 +8157,7 @@ class UIText extends UIElement {
7897
8157
  this._private_lastWidth = this.width;
7898
8158
  this._private_lastHeight = this.height;
7899
8159
  if (options.padding === undefined) {
7900
- this.padding.setUnified(this.content.reduce((a, b) => Math.max(a, b.style.calculatePadding()), this.commonStyle.calculatePadding()));
8160
+ this._private_paddingInternal.setUnified(this.content.reduce((a, b) => Math.max(a, b.style.calculatePadding()), this.commonStyle.calculatePadding()));
7901
8161
  }
7902
8162
  switch (this._private_resizeModeInternal) {
7903
8163
  case UITextResizeMode.SCALE:
@@ -7908,6 +8168,10 @@ class UIText extends UIElement {
7908
8168
  break;
7909
8169
  }
7910
8170
  }
8171
+ /** Multiplicative tint. Alpha channel controls opacity. */
8172
+ get color() {
8173
+ return this._private_colorInternal;
8174
+ }
7911
8175
  /** Text content as array of styled spans */
7912
8176
  get content() {
7913
8177
  return this._private_contentInternal;
@@ -7916,10 +8180,18 @@ class UIText extends UIElement {
7916
8180
  get maxLineWidth() {
7917
8181
  return this._private_maxLineWidthInternal;
7918
8182
  }
8183
+ /** Text padding in world units */
8184
+ get padding() {
8185
+ return this._private_paddingInternal;
8186
+ }
7919
8187
  /** Controls how text adapts to element size */
7920
8188
  get resizeMode() {
7921
8189
  return this._private_resizeModeInternal;
7922
8190
  }
8191
+ /** Multiplicative tint. Alpha channel controls opacity. */
8192
+ set color(value) {
8193
+ this._private_colorInternal.set(value);
8194
+ }
7923
8195
  /** Text content as string, span config, or array */
7924
8196
  set content(value) {
7925
8197
  if (this._private_contentInternal !== value) {
@@ -7955,6 +8227,10 @@ class UIText extends UIElement {
7955
8227
  this._private_maxLineWidthDirty = true;
7956
8228
  }
7957
8229
  }
8230
+ /** Text padding in world units */
8231
+ set padding(value) {
8232
+ this._private_paddingInternal.set(value);
8233
+ }
7958
8234
  /** Controls how text adapts to size constraints */
7959
8235
  set resizeMode(value) {
7960
8236
  if (this._private_resizeModeInternal !== value) {
@@ -7981,7 +8257,7 @@ class UIText extends UIElement {
7981
8257
  _private_tryToRenderTextScaleMode() {
7982
8258
  if (!this._private_resizeModeDirty &&
7983
8259
  !this._private_maxLineWidthDirty &&
7984
- !this.padding.dirty &&
8260
+ !this._private_paddingInternal.dirty &&
7985
8261
  !(this.solverWrapper.dirty &&
7986
8262
  this._private_lastWidth / this._private_lastHeight !==
7987
8263
  Math.round(this.width) / Math.round(this.height)) &&
@@ -7990,8 +8266,8 @@ class UIText extends UIElement {
7990
8266
  }
7991
8267
  const textChunks = this._private_buildTextChunks();
7992
8268
  const { lines, size } = calculateTextContentParameters(textChunks, this._private_maxLineWidthInternal);
7993
- const paddingV = this.padding.top + this.padding.bottom;
7994
- const paddingH = this.padding.left + this.padding.right;
8269
+ const paddingV = this._private_paddingInternal.top + this._private_paddingInternal.bottom;
8270
+ const paddingH = this._private_paddingInternal.left + this._private_paddingInternal.right;
7995
8271
  const desiredHeight = size.height + paddingV;
7996
8272
  const desiredWidth = size.width + paddingH;
7997
8273
  // Two calculation passes are required to cover both cases -
@@ -8006,18 +8282,18 @@ class UIText extends UIElement {
8006
8282
  this._private_canvas.height = desiredHeight;
8007
8283
  this._private_canvas.width = desiredWidth;
8008
8284
  }
8009
- renderTextLines(this.padding.top, this.padding.left, lines, this._private_context);
8285
+ renderTextLines(this._private_paddingInternal.top, this._private_paddingInternal.left, lines, this._private_context);
8010
8286
  this._private_updateProperties(resolutionDirty);
8011
8287
  this._private_resizeModeDirty = false;
8012
8288
  this._private_maxLineWidthDirty = false;
8013
- this.padding.setDirtyFalse();
8289
+ this._private_paddingInternal.setDirtyFalse();
8014
8290
  this._private_setDimensionsDirtyFalse();
8015
8291
  this._private_setContentDirtyFalse();
8016
8292
  }
8017
8293
  _private_tryToRenderTextBreakMode() {
8018
8294
  if (!this._private_resizeModeDirty &&
8019
8295
  !this._private_maxLineWidthDirty &&
8020
- !this.padding.dirty &&
8296
+ !this._private_paddingInternal.dirty &&
8021
8297
  !this._private_checkDimensionsDirty() &&
8022
8298
  !this._private_checkContentDirty()) {
8023
8299
  return;
@@ -8027,8 +8303,8 @@ class UIText extends UIElement {
8027
8303
  // suggest the desired sizes to the solver, and then
8028
8304
  // adjust our expectations based on the result obtained.
8029
8305
  const { size: desiredTextSize } = calculateTextContentParameters(textChunks, this._private_maxLineWidthInternal);
8030
- const paddingV = this.padding.top + this.padding.bottom;
8031
- const paddingH = this.padding.left + this.padding.right;
8306
+ const paddingV = this._private_paddingInternal.top + this._private_paddingInternal.bottom;
8307
+ const paddingH = this._private_paddingInternal.left + this._private_paddingInternal.right;
8032
8308
  this.height = desiredTextSize.height + paddingV;
8033
8309
  this.width = desiredTextSize.width + paddingH; // Width should remain a priority, so it is set last.
8034
8310
  const { lines: realTextLines, size: realTextSize } = calculateTextContentParameters(textChunks, Math.round(this.width) - paddingH);
@@ -8041,20 +8317,20 @@ class UIText extends UIElement {
8041
8317
  this._private_canvas.width = safeWidth;
8042
8318
  this._private_canvas.height = safeHeight;
8043
8319
  }
8044
- renderTextLines(this.padding.top, this.padding.left, realTextLines, this._private_context);
8320
+ renderTextLines(this._private_paddingInternal.top, this._private_paddingInternal.left, realTextLines, this._private_context);
8045
8321
  this._private_updateProperties(resolutionDirty);
8046
8322
  this._private_resizeModeDirty = false;
8047
8323
  this._private_maxLineWidthDirty = false;
8048
- this.padding.setDirtyFalse();
8324
+ this._private_paddingInternal.setDirtyFalse();
8049
8325
  this._private_setDimensionsDirtyFalse();
8050
8326
  this._private_setContentDirtyFalse();
8051
8327
  }
8052
8328
  _private_updateProperties(resolutionDirty) {
8053
8329
  let properties;
8054
- if (this.color.dirty) {
8330
+ if (this._private_colorInternal.dirty) {
8055
8331
  properties ?? (properties = {});
8056
- properties["color"] = this.color;
8057
- this.color.setDirtyFalse();
8332
+ properties["color"] = this._private_colorInternal;
8333
+ this._private_colorInternal.setDirtyFalse();
8058
8334
  }
8059
8335
  if (resolutionDirty) {
8060
8336
  this._private_texture.dispose();
@@ -8180,23 +8456,27 @@ class UIFullscreenLayer extends UILayer {
8180
8456
  * Projects 3D world position to 2D layer coordinates
8181
8457
  * @param position World position
8182
8458
  * @param camera Three.js camera
8459
+ * @param result Reusable vector instance
8183
8460
  * @returns Layer coordinates
8184
8461
  */
8185
- projectWorldPosition(position, camera) {
8186
- const projectedPosition = position.clone().project(camera);
8187
- projectedPosition.x = MathUtils.mapLinear(projectedPosition.x, -1, 1, this.x, this.width);
8188
- projectedPosition.y = MathUtils.mapLinear(projectedPosition.y, -1, 1, this.y, this.height);
8189
- return projectedPosition;
8462
+ projectWorldPosition(position, camera, result = new Vector3()) {
8463
+ result.copy(position).project(camera);
8464
+ result.x = MathUtils.mapLinear(result.x, -1, 1, this.x, this.width);
8465
+ result.y = MathUtils.mapLinear(result.y, -1, 1, this.y, this.height);
8466
+ return result;
8190
8467
  }
8191
8468
  /**
8192
8469
  * Projects 2D layer coordinates to 3D world position
8193
8470
  * @param position Layer coordinates
8194
8471
  * @param camera Three.js camera
8195
8472
  * @param z Depth coordinate
8473
+ * @param result Reusable vector instance
8196
8474
  * @returns World position
8197
8475
  */
8198
- projectLayerPosition(position, camera, z = -1) {
8199
- return new Vector3(MathUtils.mapLinear(position.x, this.x, this.width, -1, 1), MathUtils.mapLinear(position.y, this.y, this.height, -1, 1), z).unproject(camera);
8476
+ projectLayerPosition(position, camera, z = -1, result = new Vector3()) {
8477
+ return result
8478
+ .set(MathUtils.mapLinear(position.x, this.x, this.width, -1, 1), MathUtils.mapLinear(position.y, this.y, this.height, -1, 1), z)
8479
+ .unproject(camera);
8200
8480
  }
8201
8481
  /**
8202
8482
  * Builds ray from layer position through camera
@@ -8696,5 +8976,5 @@ class UIResizePolicyFixedWidth extends UIResizePolicy {
8696
8976
  }
8697
8977
  }
8698
8978
 
8699
- export { UIAnchor, UIAnimatedImage, UIAreaCircle, UIAreaPolygon, UIAreaRectangle, UIAreaRoundedRectangle, UIAspectConstraint, UIColor, UIConstraint2DBuilder, UICoverConstraintBuilder, UICustomConstraint, UIExpression, UIFitConstraintBuilder, UIFullscreenLayer, UIGraphics, UIHeightConstraint, UIHorizontalDistanceConstraint, UIHorizontalInterpolationConstraint, UIHorizontalProportionConstraint, UIImage, UIInputDummy, UIInputEvent, UILoopMode, UIMicro, UIMicroAnchorMode, UIMode, UINineSlice, UINineSliceRegionMode, UIOrientation, UIPriority, UIProgress, UIProgressMaskFunctionCircular, UIProgressMaskFunctionDirectional, UIRelation, UIResizePolicyCover, UIResizePolicyCross, UIResizePolicyCrossInverted, UIResizePolicyFit, UIResizePolicyFixedHeight, UIResizePolicyFixedWidth, UIResizePolicyNone, UIScene, UISceneUpdateMode, UISingleParameterConstraint, UIText, UITextResizeMode, UITransparencyMode, UIVerticalDistanceConstraint, UIVerticalInterpolationConstraint, UIVerticalProportionConstraint, UIWidthConstraint };
8979
+ export { UIAnchor, UIAnimatedImage, UIAnimatedImageLoopMode, UIAreaCircle, UIAreaPolygon, UIAreaRectangle, UIAreaRoundedRectangle, UIAspectConstraint, UIColor, UIConstraint2DBuilder, UICoverConstraintBuilder, UICustomConstraint, UIExpression, UIFitConstraintBuilder, UIFullscreenLayer, UIGraphics, UIHeightConstraint, UIHorizontalDistanceConstraint, UIHorizontalInterpolationConstraint, UIHorizontalProportionConstraint, UIImage, UIInputDummy, UIInputEvent, UIMicro, UIMicroAnchorMode, UIMode, UINineSlice, UINineSliceRegionMode, UIOrientation, UIPriority, UIProgress, UIProgressMaskFunctionCircular, UIProgressMaskFunctionDirectional, UIRelation, UIResizePolicyCover, UIResizePolicyCross, UIResizePolicyCrossInverted, UIResizePolicyFit, UIResizePolicyFixedHeight, UIResizePolicyFixedWidth, UIResizePolicyNone, UIScene, UISceneUpdateMode, UISingleParameterConstraint, UIText, UITextResizeMode, UITransparencyMode, UIVerticalDistanceConstraint, UIVerticalInterpolationConstraint, UIVerticalProportionConstraint, UIWidthConstraint };
8700
8980
  //# sourceMappingURL=index.js.map