laymur 0.12.0 → 0.13.1

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 +840 -558
  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
@@ -1 +1 @@
1
- {"version":3,"file":"index.min.js","sources":["../node_modules/eventail/dist/index.min.js","../src/miscellaneous/UIMode.ts","../src/miscellaneous/UIOrientation.ts","../node_modules/@lume/kiwi/dist/maptype.js","../node_modules/@lume/kiwi/dist/variable.js","../node_modules/@lume/kiwi/dist/expression.js","../node_modules/@lume/kiwi/dist/strength.js","../node_modules/@lume/kiwi/dist/constraint.js","../node_modules/@lume/kiwi/dist/solver.js","../src/miscellaneous/UIPriority.ts","../src/miscellaneous/UITransparencyMode.ts","../src/wrappers/UIInputWrapper.ts","../node_modules/three/src/math/ColorManagement.js","../src/miscellaneous/color/UIColor.Internal.ts","../src/miscellaneous/color/UIColor.ts","../src/miscellaneous/generic-plane/shared.ts","../src/miscellaneous/generic-plane/UIGenericInstancedPlane.Internal.ts","../src/miscellaneous/generic-plane/UIGenericInstancedPlane.ts","../src/miscellaneous/generic-plane/UIGenericPlane.Internal.ts","../src/miscellaneous/generic-plane/UIGenericPlane.ts","../src/miscellaneous/generic-plane/UIGenericPlaneRegistry.ts","../src/wrappers/UISceneWrapper.ts","../src/miscellaneous/UIExpression.ts","../src/miscellaneous/UIRelation.ts","../src/layers/UILayer/UILayer.Internal.ts","../src/wrappers/UISolverWrapper.ts","../src/layers/UILayer/UILayer.ts","../src/miscellaneous/shared.ts","../src/miscellaneous/asserts.ts","../src/constraints/UIConstraint.ts","../src/constraints/UISingleParameterConstraint/UISingleParameterConstraint.ts","../src/constraints/UIHeightConstraint/UIHeightConstraint.ts","../src/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.ts","../src/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.Internal.ts","../src/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.ts","../src/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.Internal.ts","../src/constraints/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.ts","../src/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.ts","../src/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.Internal.ts","../src/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.ts","../src/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.Internal.ts","../src/constraints/UIVerticalProportionConstraint/UIVerticalProportionConstraint.ts","../src/constraints/UIWidthConstraint/UIWidthConstraint.ts","../src/constraints/builders/UIConstraint2DBuilder.Internal.ts","../src/constraints/builders/UIConstraint2DBuilder.ts","../src/constraints/UIAspectConstraint/UIAspectConstraint.ts","../src/constraints/builders/UICoverConstraintBuilder.Internal.ts","../src/constraints/builders/UICoverConstraintBuilder.ts","../src/constraints/builders/UIFitConstraintBuilder.Internal.ts","../src/constraints/builders/UIFitConstraintBuilder.ts","../src/constraints/UICustomConstraint.ts","../src/elements/UIAnchor/UIAnchor.ts","../src/elements/UIAnchor/UIAnchor.Internal.ts","../src/miscellaneous/micro/UIMicro.Internal.ts","../src/miscellaneous/computeTransform.ts","../src/miscellaneous/texture/UITextureView.Internal.ts","../src/miscellaneous/texture/UITextureView.ts","../src/miscellaneous/UIInputEvent.ts","../src/miscellaneous/micro/UIMicro.ts","../src/miscellaneous/area/UIArea.ts","../src/miscellaneous/area/UIAreaRectangle.ts","../src/elements/UIInputDummy/UIInputDummy.Internal.ts","../src/elements/UIInputDummy/UIInputDummy.ts","../src/elements/UIElement/UIElement.Internal.ts","../src/elements/UIElement/UIElement.ts","../src/elements/UIAnimatedImage/UIAnimatedImage.Internal.ts","../src/elements/UIAnimatedImage/UIAnimatedImage.ts","../src/elements/UIGraphics/UIGraphics.ts","../src/elements/UIImage/UIImage.ts","../src/miscellaneous/insets/UIInsets.ts","../src/miscellaneous/insets/UIInsets.Internal.ts","../src/elements/UINineSlice/UINineSlice.Internal.ts","../src/elements/UINineSlice/UINineSlice.ts","../src/miscellaneous/mask-function/UIProgressMaskFunction.ts","../src/miscellaneous/mask-function/UIProgressMaskFunctionDirectional.ts","../src/elements/UIProgress/UIProgress.ts","../src/elements/UIProgress/UIProgress.Internal.ts","../src/elements/UIScene/UIScene.Internal.ts","../src/elements/UIScene/UIScene.ts","../src/miscellaneous/text-style/UITextStyle.Internal.ts","../src/miscellaneous/text-style/UITextStyle.ts","../src/miscellaneous/text-span/UITextSpan.ts","../src/elements/UIText/UIText.Internal.ts","../src/elements/UIText/UIText.Measuring.ts","../src/elements/UIText/UIText.Rendering.ts","../src/elements/UIText/UIText.ts","../src/miscellaneous/resize-policy/UIResizePolicy.ts","../src/miscellaneous/resize-policy/UIResizePolicyNone.ts","../src/layers/UIFullscreenLayer/UIFullscreenLayer.Internal.ts","../src/layers/UIFullscreenLayer/UIFullscreenLayer.ts","../src/miscellaneous/area/UIAreaCircle.ts","../src/miscellaneous/area/UIAreaPolygon.ts","../src/miscellaneous/area/UIAreaRoundedRectangle.ts","../src/miscellaneous/mask-function/UIProgressMaskFunctionCircular.ts","../src/miscellaneous/resize-policy/UIResizePolicyCover.ts","../src/miscellaneous/resize-policy/UIResizePolicyCross.ts","../src/miscellaneous/resize-policy/UIResizePolicyCrossInverted.ts","../src/miscellaneous/resize-policy/UIResizePolicyFit.ts","../src/miscellaneous/resize-policy/UIResizePolicyFixedHeight.ts","../src/miscellaneous/resize-policy/UIResizePolicyFixedWidth.ts"],"sourcesContent":["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,!1,s,i,r),this}once(t,i,r,s=0){return this.h(t,!0,s,i,r),this}off(t,i,r){const s=this.o.get(t);if(void 0===s)return this;s.u&&(s.u=!1,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!1;if(0===r.v.length)return!1;r.u?r.v=r.v.slice():r.u=!0;const s=r.v;let o=!1;for(let t=0;s.length>t;t++){const r=s[t];r._.apply(r.p,i),r.k&&(o=!0,r.m=!0)}const e=this.o.get(t);if(void 0===e)return!0;e.v===s&&(e.u=!1);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!0}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:!1}],u:!1,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:!1};n.u&&(n.u=!1,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)}}}}export{i as Eventail};\n//# sourceMappingURL=index.min.js.map\n","/** Visibility and interactivity state */\nexport enum UIMode {\n /** Not rendered, no input */\n HIDDEN = 0,\n /** Rendered, no input */\n VISIBLE = 1,\n /** Rendered, receives input, blocks input to elements behind */\n INTERACTIVE = 2,\n /** Rendered, receives input, passes input to elements behind */\n INTERACTIVE_TRANSPARENT = 3,\n}\n\n/**\n * Checks if mode allows input events.\n * @param mode Mode to check\n * @returns True if interactive\n */\nexport function isUIModeInteractive(mode: UIMode): boolean {\n return mode === UIMode.INTERACTIVE || mode === UIMode.INTERACTIVE_TRANSPARENT;\n}\n\n/**\n * Checks if mode is rendered.\n * @param mode Mode to check\n * @returns True if visible\n */\nexport function isUIModeVisible(mode: UIMode): boolean {\n return mode !== UIMode.HIDDEN;\n}\n","/** Screen orientation for conditional constraints */\nexport enum UIOrientation {\n /** Landscape (width > height) */\n HORIZONTAL = 0,\n /** Portrait (height > width) */\n VERTICAL = 1,\n /** Active in any orientation */\n ALWAYS = 2,\n}\n\n/**\n * Resolves optional orientation.\n * @param orientation Orientation to resolve\n * @returns Orientation or ALWAYS if undefined\n */\nexport function resolveOrientation(orientation?: UIOrientation): UIOrientation {\n return orientation ?? UIOrientation.ALWAYS;\n}\n","export function createMap() {\n return new IndexedMap();\n}\nclass IndexedMap {\n index = {};\n array = [];\n /**\n * Returns the number of items in the array.\n */\n size() {\n return this.array.length;\n }\n /**\n * Returns true if the array is empty.\n */\n empty() {\n return this.array.length === 0;\n }\n /**\n * Returns the item at the given array index.\n *\n * @param index The integer index of the desired item.\n */\n itemAt(index) {\n return this.array[index];\n }\n /**\n * Returns true if the key is in the array, false otherwise.\n *\n * @param key The key to locate in the array.\n */\n contains(key) {\n return this.index[key.id()] !== undefined;\n }\n /**\n * Returns the pair associated with the given key, or undefined.\n *\n * @param key The key to locate in the array.\n */\n find(key) {\n const i = this.index[key.id()];\n return i === undefined ? undefined : this.array[i];\n }\n /**\n * Returns the pair associated with the key if it exists.\n *\n * If the key does not exist, a new pair will be created and\n * inserted using the value created by the given factory.\n *\n * @param key The key to locate in the array.\n * @param factory The function which creates the default value.\n */\n setDefault(key, factory) {\n const i = this.index[key.id()];\n if (i === undefined) {\n const pair = new Pair(key, factory());\n this.index[key.id()] = this.array.length;\n this.array.push(pair);\n return pair;\n }\n else {\n return this.array[i];\n }\n }\n /**\n * Insert the pair into the array and return the pair.\n *\n * This will overwrite any existing entry in the array.\n *\n * @param key The key portion of the pair.\n * @param value The value portion of the pair.\n */\n insert(key, value) {\n const pair = new Pair(key, value);\n const i = this.index[key.id()];\n if (i === undefined) {\n this.index[key.id()] = this.array.length;\n this.array.push(pair);\n }\n else {\n this.array[i] = pair;\n }\n return pair;\n }\n /**\n * Removes and returns the pair for the given key, or undefined.\n *\n * @param key The key to remove from the map.\n */\n erase(key) {\n const i = this.index[key.id()];\n if (i === undefined) {\n return undefined;\n }\n this.index[key.id()] = undefined;\n const pair = this.array[i];\n const last = this.array.pop();\n if (pair !== last) {\n this.array[i] = last;\n this.index[last.first.id()] = i;\n }\n return pair;\n }\n /**\n * Create a copy of this associative array.\n */\n copy() {\n const copy = new IndexedMap();\n for (let i = 0; i < this.array.length; i++) {\n const pair = this.array[i].copy();\n copy.array[i] = pair;\n copy.index[pair.first.id()] = i;\n }\n return copy;\n }\n}\n/**\n * A class which defines a generic pair object.\n * @private\n */\n// tslint:disable: max-classes-per-file\nclass Pair {\n first;\n second;\n /**\n * Construct a new Pair object.\n *\n * @param first The first item of the pair.\n * @param second The second item of the pair.\n */\n constructor(first, second) {\n this.first = first;\n this.second = second;\n }\n /**\n * Create a copy of the pair.\n */\n copy() {\n return new Pair(this.first, this.second);\n }\n}\n","import { Expression } from './expression.js';\n/**\n * The primary user constraint variable.\n *\n * @class\n * @param {String} [name=\"\"] The name to associated with the variable.\n */\nexport class Variable {\n constructor(name = '') {\n this._name = name;\n }\n /**\n * Returns the unique id number of the variable.\n * @private\n */\n id() {\n return this._id;\n }\n /**\n * Returns the name of the variable.\n *\n * @return {String} name of the variable\n */\n name() {\n return this._name;\n }\n /**\n * Set the name of the variable.\n *\n * @param {String} name Name of the variable\n */\n setName(name) {\n this._name = name;\n }\n /**\n * Returns the user context object of the variable.\n * @private\n */\n context() {\n return this._context;\n }\n /**\n * Set the user context object of the variable.\n * @private\n */\n setContext(context) {\n this._context = context;\n }\n /**\n * Returns the value of the variable.\n *\n * @return {Number} Calculated value\n */\n value() {\n return this._value;\n }\n /**\n * Set the value of the variable.\n * @private\n */\n setValue(value) {\n this._value = value;\n }\n /**\n * Creates a new Expression by adding a number, variable or expression\n * to the variable.\n *\n * @param {Number|Variable|Expression} value Value to add.\n * @return {Expression} expression\n */\n plus(value) {\n return new Expression(this, value);\n }\n /**\n * Creates a new Expression by substracting a number, variable or expression\n * from the variable.\n *\n * @param {Number|Variable|Expression} value Value to substract.\n * @return {Expression} expression\n */\n minus(value) {\n return new Expression(this, typeof value === 'number' ? -value : [-1, value]);\n }\n /**\n * Creates a new Expression by multiplying with a fixed number.\n *\n * @param {Number} coefficient Coefficient to multiply with.\n * @return {Expression} expression\n */\n multiply(coefficient) {\n return new Expression([coefficient, this]);\n }\n /**\n * Creates a new Expression by dividing with a fixed number.\n *\n * @param {Number} coefficient Coefficient to divide by.\n * @return {Expression} expression\n */\n divide(coefficient) {\n return new Expression([1 / coefficient, this]);\n }\n /**\n * Returns the JSON representation of the variable.\n * @private\n */\n toJSON() {\n return {\n name: this._name,\n value: this._value,\n };\n }\n toString() {\n return this._context + '[' + this._name + ':' + this._value + ']';\n }\n _name;\n _value = 0.0;\n _context = null;\n _id = VarId++;\n}\n/**\n * The internal variable id counter.\n * @private\n */\nlet VarId = 0;\n","import { createMap } from './maptype.js';\nimport { Variable } from './variable.js';\n/**\n * An expression of variable terms and a constant.\n *\n * The constructor accepts an arbitrary number of parameters,\n * each of which must be one of the following types:\n * - number\n * - Variable\n * - Expression\n * - 2-tuple of [number, Variable|Expression]\n *\n * The parameters are summed. The tuples are multiplied.\n *\n * @class\n * @param {...(number|Variable|Expression|Array)} args\n */\nexport class Expression {\n constructor() {\n let parsed = parseArgs(arguments);\n this._terms = parsed.terms;\n this._constant = parsed.constant;\n }\n /**\n * Returns the mapping of terms in the expression.\n *\n * This *must* be treated as const.\n * @private\n */\n terms() {\n return this._terms;\n }\n /**\n * Returns the constant of the expression.\n * @private\n */\n constant() {\n return this._constant;\n }\n /**\n * Returns the computed value of the expression.\n *\n * @private\n * @return {Number} computed value of the expression\n */\n value() {\n let result = this._constant;\n for (let i = 0, n = this._terms.size(); i < n; i++) {\n let pair = this._terms.itemAt(i);\n result += pair.first.value() * pair.second;\n }\n return result;\n }\n /**\n * Creates a new Expression by adding a number, variable or expression\n * to the expression.\n *\n * @param {Number|Variable|Expression} value Value to add.\n * @return {Expression} expression\n */\n plus(value) {\n return new Expression(this, value);\n }\n /**\n * Creates a new Expression by substracting a number, variable or expression\n * from the expression.\n *\n * @param {Number|Variable|Expression} value Value to substract.\n * @return {Expression} expression\n */\n minus(value) {\n return new Expression(this, typeof value === 'number' ? -value : [-1, value]);\n }\n /**\n * Creates a new Expression by multiplying with a fixed number.\n *\n * @param {Number} coefficient Coefficient to multiply with.\n * @return {Expression} expression\n */\n multiply(coefficient) {\n return new Expression([coefficient, this]);\n }\n /**\n * Creates a new Expression by dividing with a fixed number.\n *\n * @param {Number} coefficient Coefficient to divide by.\n * @return {Expression} expression\n */\n divide(coefficient) {\n return new Expression([1 / coefficient, this]);\n }\n isConstant() {\n return this._terms.size() == 0;\n }\n toString() {\n let result = this._terms.array\n .map(function (pair) {\n return pair.second + '*' + pair.first.toString();\n })\n .join(' + ');\n if (!this.isConstant() && this._constant !== 0) {\n result += ' + ';\n }\n result += this._constant;\n return result;\n }\n _terms;\n _constant;\n}\n/**\n * An internal argument parsing function.\n * @private\n */\nfunction parseArgs(args) {\n let constant = 0.0;\n let factory = () => 0.0;\n let terms = createMap();\n for (let i = 0, n = args.length; i < n; ++i) {\n let item = args[i];\n if (typeof item === 'number') {\n constant += item;\n }\n else if (item instanceof Variable) {\n terms.setDefault(item, factory).second += 1.0;\n }\n else if (item instanceof Expression) {\n constant += item.constant();\n let terms2 = item.terms();\n for (let j = 0, k = terms2.size(); j < k; j++) {\n let termPair = terms2.itemAt(j);\n terms.setDefault(termPair.first, factory).second += termPair.second;\n }\n }\n else if (item instanceof Array) {\n if (item.length !== 2) {\n throw new Error('array must have length 2');\n }\n let value = item[0];\n let value2 = item[1];\n if (typeof value !== 'number') {\n throw new Error('array item 0 must be a number');\n }\n if (value2 instanceof Variable) {\n terms.setDefault(value2, factory).second += value;\n }\n else if (value2 instanceof Expression) {\n constant += value2.constant() * value;\n let terms2 = value2.terms();\n for (let j = 0, k = terms2.size(); j < k; j++) {\n let termPair = terms2.itemAt(j);\n terms.setDefault(termPair.first, factory).second += termPair.second * value;\n }\n }\n else {\n throw new Error('array item 1 must be a variable or expression');\n }\n }\n else {\n throw new Error('invalid Expression argument: ' + item);\n }\n }\n return { terms, constant };\n}\n","/**\n * @class Strength\n */\nexport class Strength {\n /**\n * Create a new symbolic strength.\n *\n * @param a strong\n * @param b medium\n * @param c weak\n * @param [w] weight\n * @return strength\n */\n static create(a, b, c, w = 1.0) {\n let result = 0.0;\n result += Math.max(0.0, Math.min(1000.0, a * w)) * 1000000.0;\n result += Math.max(0.0, Math.min(1000.0, b * w)) * 1000.0;\n result += Math.max(0.0, Math.min(1000.0, c * w));\n return result;\n }\n /**\n * The 'required' symbolic strength.\n */\n static required = Strength.create(1000.0, 1000.0, 1000.0);\n /**\n * The 'strong' symbolic strength.\n */\n static strong = Strength.create(1.0, 0.0, 0.0);\n /**\n * The 'medium' symbolic strength.\n */\n static medium = Strength.create(0.0, 1.0, 0.0);\n /**\n * The 'weak' symbolic strength.\n */\n static weak = Strength.create(0.0, 0.0, 1.0);\n /**\n * Clip a symbolic strength to the allowed min and max.\n * @private\n */\n static clip(value) {\n return Math.max(0.0, Math.min(Strength.required, value));\n }\n}\n","import { Expression } from './expression.js';\nimport { Strength } from './strength.js';\n/**\n * An enum defining the linear constraint operators.\n *\n * |Value|Operator|Description|\n * |----|-----|-----|\n * |`Le`|<=|Less than equal|\n * |`Ge`|>=|Greater than equal|\n * |`Eq`|==|Equal|\n *\n * @enum {Number}\n */\nexport var Operator;\n(function (Operator) {\n Operator[Operator[\"Le\"] = 0] = \"Le\";\n Operator[Operator[\"Ge\"] = 1] = \"Ge\";\n Operator[Operator[\"Eq\"] = 2] = \"Eq\";\n})(Operator || (Operator = {}));\n/**\n * A linear constraint equation.\n *\n * A constraint equation is composed of an expression, an operator,\n * and a strength. The RHS of the equation is implicitly zero.\n *\n * @class\n * @param {Expression} expression The constraint expression (LHS).\n * @param {Operator} operator The equation operator.\n * @param {Expression} [rhs] Right hand side of the expression.\n * @param {Number} [strength=Strength.required] The strength of the constraint.\n */\nexport class Constraint {\n constructor(expression, operator, rhs, strength = Strength.required) {\n this._operator = operator;\n this._strength = Strength.clip(strength);\n if (rhs === undefined && expression instanceof Expression) {\n this._expression = expression;\n }\n else {\n this._expression = expression.minus(rhs);\n }\n }\n /**\n * Returns the unique id number of the constraint.\n * @private\n */\n id() {\n return this._id;\n }\n /**\n * Returns the expression of the constraint.\n *\n * @return {Expression} expression\n */\n expression() {\n return this._expression;\n }\n /**\n * Returns the relational operator of the constraint.\n *\n * @return {Operator} linear constraint operator\n */\n op() {\n return this._operator;\n }\n /**\n * Returns the strength of the constraint.\n *\n * @return {Number} strength\n */\n strength() {\n return this._strength;\n }\n toString() {\n return (this._expression.toString() + ' ' + ['<=', '>=', '='][this._operator] + ' 0 (' + this._strength.toString() + ')');\n }\n _expression;\n _operator;\n _strength;\n _id = CnId++;\n}\n/**\n * The internal constraint id counter.\n * @private\n */\nlet CnId = 0;\n","import { Constraint, Operator } from './constraint.js';\nimport { Expression } from './expression.js';\nimport { createMap } from './maptype.js';\nimport { Strength } from './strength.js';\n/**\n * The constraint solver class.\n *\n * @class\n */\nexport class Solver {\n /**\n * @type {number} - The max number of solver iterations before an error\n * is thrown, in order to prevent infinite iteration. Default: `10,000`.\n */\n maxIterations = 1000;\n /**\n * Construct a new Solver.\n */\n constructor() { }\n /**\n * Creates and add a constraint to the solver.\n *\n * @param {Expression|Variable} lhs Left hand side of the expression\n * @param {Operator} operator Operator\n * @param {Expression|Variable|Number} rhs Right hand side of the expression\n * @param {Number} [strength=Strength.required] Strength\n */\n createConstraint(lhs, operator, rhs, strength = Strength.required) {\n let cn = new Constraint(lhs, operator, rhs, strength);\n this.addConstraint(cn);\n return cn;\n }\n /**\n * Add a constraint to the solver.\n *\n * @param {Constraint} constraint Constraint to add to the solver\n */\n addConstraint(constraint) {\n let cnPair = this._cnMap.find(constraint);\n if (cnPair !== undefined) {\n throw new Error('duplicate constraint');\n }\n // Creating a row causes symbols to be reserved for the variables\n // in the constraint. If this method exits with an exception,\n // then its possible those variables will linger in the var map.\n // Since its likely that those variables will be used in other\n // constraints and since exceptional conditions are uncommon,\n // i'm not too worried about aggressive cleanup of the var map.\n let data = this._createRow(constraint);\n let row = data.row;\n let tag = data.tag;\n let subject = this._chooseSubject(row, tag);\n // If chooseSubject couldnt find a valid entering symbol, one\n // last option is available if the entire row is composed of\n // dummy variables. If the constant of the row is zero, then\n // this represents redundant constraints and the new dummy\n // marker can enter the basis. If the constant is non-zero,\n // then it represents an unsatisfiable constraint.\n if (subject.type() === SymbolType.Invalid && row.allDummies()) {\n if (!nearZero(row.constant())) {\n throw new Error('unsatisfiable constraint');\n }\n else {\n subject = tag.marker;\n }\n }\n // If an entering symbol still isn't found, then the row must\n // be added using an artificial variable. If that fails, then\n // the row represents an unsatisfiable constraint.\n if (subject.type() === SymbolType.Invalid) {\n if (!this._addWithArtificialVariable(row)) {\n throw new Error('unsatisfiable constraint');\n }\n }\n else {\n row.solveFor(subject);\n this._substitute(subject, row);\n this._rowMap.insert(subject, row);\n }\n this._cnMap.insert(constraint, tag);\n // Optimizing after each constraint is added performs less\n // aggregate work due to a smaller average system size. It\n // also ensures the solver remains in a consistent state.\n this._optimize(this._objective);\n }\n /**\n * Remove a constraint from the solver.\n *\n * @param {Constraint} constraint Constraint to remove from the solver\n */\n removeConstraint(constraint) {\n let cnPair = this._cnMap.erase(constraint);\n if (cnPair === undefined) {\n throw new Error('unknown constraint');\n }\n // Remove the error effects from the objective function\n // *before* pivoting, or substitutions into the objective\n // will lead to incorrect solver results.\n this._removeConstraintEffects(constraint, cnPair.second);\n // If the marker is basic, simply drop the row. Otherwise,\n // pivot the marker into the basis and then drop the row.\n let marker = cnPair.second.marker;\n let rowPair = this._rowMap.erase(marker);\n if (rowPair === undefined) {\n let leaving = this._getMarkerLeavingSymbol(marker);\n if (leaving.type() === SymbolType.Invalid) {\n throw new Error('failed to find leaving row');\n }\n rowPair = this._rowMap.erase(leaving);\n rowPair.second.solveForEx(leaving, marker);\n this._substitute(marker, rowPair.second);\n }\n // Optimizing after each constraint is removed ensures that the\n // solver remains consistent. It makes the solver api easier to\n // use at a small tradeoff for speed.\n this._optimize(this._objective);\n }\n /**\n * Test whether the solver contains the constraint.\n *\n * @param {Constraint} constraint Constraint to test for\n * @return {Bool} true or false\n */\n hasConstraint(constraint) {\n return this._cnMap.contains(constraint);\n }\n /**\n * Get an array of the current constraints.\n *\n * @return {Constraint[]}\n */\n getConstraints() {\n return this._cnMap.array.map(({ first }) => first);\n }\n /**\n * Add an edit variable to the solver.\n *\n * @param {Variable} variable Edit variable to add to the solver\n * @param {Number} strength Strength, should be less than `Strength.required`\n */\n addEditVariable(variable, strength) {\n let editPair = this._editMap.find(variable);\n if (editPair !== undefined) {\n throw new Error('duplicate edit variable');\n }\n strength = Strength.clip(strength);\n if (strength === Strength.required) {\n throw new Error('bad required strength');\n }\n let expr = new Expression(variable);\n let cn = new Constraint(expr, Operator.Eq, undefined, strength);\n this.addConstraint(cn);\n let tag = this._cnMap.find(cn).second;\n let info = { tag, constraint: cn, constant: 0.0 };\n this._editMap.insert(variable, info);\n }\n /**\n * Remove an edit variable from the solver.\n *\n * @param {Variable} variable Edit variable to remove from the solver\n */\n removeEditVariable(variable) {\n let editPair = this._editMap.erase(variable);\n if (editPair === undefined) {\n throw new Error('unknown edit variable');\n }\n this.removeConstraint(editPair.second.constraint);\n }\n /**\n * Test whether the solver contains the edit variable.\n *\n * @param {Variable} variable Edit variable to test for\n * @return {Bool} true or false\n */\n hasEditVariable(variable) {\n return this._editMap.contains(variable);\n }\n /**\n * Suggest the value of an edit variable.\n *\n * @param {Variable} variable Edit variable to suggest a value for\n * @param {Number} value Suggested value\n */\n suggestValue(variable, value) {\n let editPair = this._editMap.find(variable);\n if (editPair === undefined) {\n throw new Error('unknown edit variable');\n }\n let rows = this._rowMap;\n let info = editPair.second;\n let delta = value - info.constant;\n info.constant = value;\n // Check first if the positive error variable is basic.\n let marker = info.tag.marker;\n let rowPair = rows.find(marker);\n if (rowPair !== undefined) {\n if (rowPair.second.add(-delta) < 0.0) {\n this._infeasibleRows.push(marker);\n }\n this._dualOptimize();\n return;\n }\n // Check next if the negative error variable is basic.\n let other = info.tag.other;\n rowPair = rows.find(other);\n if (rowPair !== undefined) {\n if (rowPair.second.add(delta) < 0.0) {\n this._infeasibleRows.push(other);\n }\n this._dualOptimize();\n return;\n }\n // Otherwise update each row where the error variables exist.\n for (let i = 0, n = rows.size(); i < n; ++i) {\n let rowPair = rows.itemAt(i);\n let row = rowPair.second;\n let coeff = row.coefficientFor(marker);\n if (coeff !== 0.0 && row.add(delta * coeff) < 0.0 && rowPair.first.type() !== SymbolType.External) {\n this._infeasibleRows.push(rowPair.first);\n }\n }\n this._dualOptimize();\n }\n /**\n * Update the values of the variables.\n */\n updateVariables() {\n let vars = this._varMap;\n let rows = this._rowMap;\n for (let i = 0, n = vars.size(); i < n; ++i) {\n let pair = vars.itemAt(i);\n let rowPair = rows.find(pair.second);\n if (rowPair !== undefined) {\n pair.first.setValue(rowPair.second.constant());\n }\n else {\n pair.first.setValue(0.0);\n }\n }\n }\n /**\n * Get the symbol for the given variable.\n *\n * If a symbol does not exist for the variable, one will be created.\n * @private\n */\n _getVarSymbol(variable) {\n let factory = () => this._makeSymbol(SymbolType.External);\n return this._varMap.setDefault(variable, factory).second;\n }\n /**\n * Create a new Row object for the given constraint.\n *\n * The terms in the constraint will be converted to cells in the row.\n * Any term in the constraint with a coefficient of zero is ignored.\n * This method uses the `_getVarSymbol` method to get the symbol for\n * the variables added to the row. If the symbol for a given cell\n * variable is basic, the cell variable will be substituted with the\n * basic row.\n *\n * The necessary slack and error variables will be added to the row.\n * If the constant for the row is negative, the sign for the row\n * will be inverted so the constant becomes positive.\n *\n * Returns the created Row and the tag for tracking the constraint.\n * @private\n */\n _createRow(constraint) {\n let expr = constraint.expression();\n let row = new Row(expr.constant());\n // Substitute the current basic variables into the row.\n let terms = expr.terms();\n for (let i = 0, n = terms.size(); i < n; ++i) {\n let termPair = terms.itemAt(i);\n if (!nearZero(termPair.second)) {\n let symbol = this._getVarSymbol(termPair.first);\n let basicPair = this._rowMap.find(symbol);\n if (basicPair !== undefined) {\n row.insertRow(basicPair.second, termPair.second);\n }\n else {\n row.insertSymbol(symbol, termPair.second);\n }\n }\n }\n // Add the necessary slack, error, and dummy variables.\n let objective = this._objective;\n let strength = constraint.strength();\n let tag = { marker: INVALID_SYMBOL, other: INVALID_SYMBOL };\n switch (constraint.op()) {\n case Operator.Le:\n case Operator.Ge: {\n let coeff = constraint.op() === Operator.Le ? 1.0 : -1.0;\n let slack = this._makeSymbol(SymbolType.Slack);\n tag.marker = slack;\n row.insertSymbol(slack, coeff);\n if (strength < Strength.required) {\n let error = this._makeSymbol(SymbolType.Error);\n tag.other = error;\n row.insertSymbol(error, -coeff);\n objective.insertSymbol(error, strength);\n }\n break;\n }\n case Operator.Eq: {\n if (strength < Strength.required) {\n let errplus = this._makeSymbol(SymbolType.Error);\n let errminus = this._makeSymbol(SymbolType.Error);\n tag.marker = errplus;\n tag.other = errminus;\n row.insertSymbol(errplus, -1.0); // v = eplus - eminus\n row.insertSymbol(errminus, 1.0); // v - eplus + eminus = 0\n objective.insertSymbol(errplus, strength);\n objective.insertSymbol(errminus, strength);\n }\n else {\n let dummy = this._makeSymbol(SymbolType.Dummy);\n tag.marker = dummy;\n row.insertSymbol(dummy);\n }\n break;\n }\n }\n // Ensure the row has a positive constant.\n if (row.constant() < 0.0) {\n row.reverseSign();\n }\n return { row, tag };\n }\n /**\n * Choose the subject for solving for the row.\n *\n * This method will choose the best subject for using as the solve\n * target for the row. An invalid symbol will be returned if there\n * is no valid target.\n *\n * The symbols are chosen according to the following precedence:\n *\n * 1) The first symbol representing an external variable.\n * 2) A negative slack or error tag variable.\n *\n * If a subject cannot be found, an invalid symbol will be returned.\n *\n * @private\n */\n _chooseSubject(row, tag) {\n let cells = row.cells();\n for (let i = 0, n = cells.size(); i < n; ++i) {\n let pair = cells.itemAt(i);\n if (pair.first.type() === SymbolType.External) {\n return pair.first;\n }\n }\n let type = tag.marker.type();\n if (type === SymbolType.Slack || type === SymbolType.Error) {\n if (row.coefficientFor(tag.marker) < 0.0) {\n return tag.marker;\n }\n }\n type = tag.other.type();\n if (type === SymbolType.Slack || type === SymbolType.Error) {\n if (row.coefficientFor(tag.other) < 0.0) {\n return tag.other;\n }\n }\n return INVALID_SYMBOL;\n }\n /**\n * Add the row to the tableau using an artificial variable.\n *\n * This will return false if the constraint cannot be satisfied.\n *\n * @private\n */\n _addWithArtificialVariable(row) {\n // Create and add the artificial variable to the tableau.\n let art = this._makeSymbol(SymbolType.Slack);\n this._rowMap.insert(art, row.copy());\n this._artificial = row.copy();\n // Optimize the artificial objective. This is successful\n // only if the artificial objective is optimized to zero.\n this._optimize(this._artificial);\n let success = nearZero(this._artificial.constant());\n this._artificial = null;\n // If the artificial variable is basic, pivot the row so that\n // it becomes non-basic. If the row is constant, exit early.\n let pair = this._rowMap.erase(art);\n if (pair !== undefined) {\n let basicRow = pair.second;\n if (basicRow.isConstant()) {\n return success;\n }\n let entering = this._anyPivotableSymbol(basicRow);\n if (entering.type() === SymbolType.Invalid) {\n return false; // unsatisfiable (will this ever happen?)\n }\n basicRow.solveForEx(art, entering);\n this._substitute(entering, basicRow);\n this._rowMap.insert(entering, basicRow);\n }\n // Remove the artificial variable from the tableau.\n let rows = this._rowMap;\n for (let i = 0, n = rows.size(); i < n; ++i) {\n rows.itemAt(i).second.removeSymbol(art);\n }\n this._objective.removeSymbol(art);\n return success;\n }\n /**\n * Substitute the parametric symbol with the given row.\n *\n * This method will substitute all instances of the parametric symbol\n * in the tableau and the objective function with the given row.\n *\n * @private\n */\n _substitute(symbol, row) {\n let rows = this._rowMap;\n for (let i = 0, n = rows.size(); i < n; ++i) {\n let pair = rows.itemAt(i);\n pair.second.substitute(symbol, row);\n if (pair.second.constant() < 0.0 && pair.first.type() !== SymbolType.External) {\n this._infeasibleRows.push(pair.first);\n }\n }\n this._objective.substitute(symbol, row);\n if (this._artificial) {\n this._artificial.substitute(symbol, row);\n }\n }\n /**\n * Optimize the system for the given objective function.\n *\n * This method performs iterations of Phase 2 of the simplex method\n * until the objective function reaches a minimum.\n *\n * @private\n */\n _optimize(objective) {\n let iterations = 0;\n while (iterations < this.maxIterations) {\n let entering = this._getEnteringSymbol(objective);\n if (entering.type() === SymbolType.Invalid) {\n return;\n }\n let leaving = this._getLeavingSymbol(entering);\n if (leaving.type() === SymbolType.Invalid) {\n throw new Error('the objective is unbounded');\n }\n // pivot the entering symbol into the basis\n let row = this._rowMap.erase(leaving).second;\n row.solveForEx(leaving, entering);\n this._substitute(entering, row);\n this._rowMap.insert(entering, row);\n iterations++;\n }\n throw new Error('solver iterations exceeded');\n }\n /**\n * Optimize the system using the dual of the simplex method.\n *\n * The current state of the system should be such that the objective\n * function is optimal, but not feasible. This method will perform\n * an iteration of the dual simplex method to make the solution both\n * optimal and feasible.\n *\n * @private\n */\n _dualOptimize() {\n let rows = this._rowMap;\n let infeasible = this._infeasibleRows;\n while (infeasible.length !== 0) {\n let leaving = infeasible.pop();\n let pair = rows.find(leaving);\n if (pair !== undefined && pair.second.constant() < 0.0) {\n let entering = this._getDualEnteringSymbol(pair.second);\n if (entering.type() === SymbolType.Invalid) {\n throw new Error('dual optimize failed');\n }\n // pivot the entering symbol into the basis\n let row = pair.second;\n rows.erase(leaving);\n row.solveForEx(leaving, entering);\n this._substitute(entering, row);\n rows.insert(entering, row);\n }\n }\n }\n /**\n * Compute the entering variable for a pivot operation.\n *\n * This method will return first symbol in the objective function which\n * is non-dummy and has a coefficient less than zero. If no symbol meets\n * the criteria, it means the objective function is at a minimum, and an\n * invalid symbol is returned.\n *\n * @private\n */\n _getEnteringSymbol(objective) {\n let cells = objective.cells();\n for (let i = 0, n = cells.size(); i < n; ++i) {\n let pair = cells.itemAt(i);\n let symbol = pair.first;\n if (pair.second < 0.0 && symbol.type() !== SymbolType.Dummy) {\n return symbol;\n }\n }\n return INVALID_SYMBOL;\n }\n /**\n * Compute the entering symbol for the dual optimize operation.\n *\n * This method will return the symbol in the row which has a positive\n * coefficient and yields the minimum ratio for its respective symbol\n * in the objective function. The provided row *must* be infeasible.\n * If no symbol is found which meats the criteria, an invalid symbol\n * is returned.\n *\n * @private\n */\n _getDualEnteringSymbol(row) {\n let ratio = Number.MAX_VALUE;\n let entering = INVALID_SYMBOL;\n let cells = row.cells();\n for (let i = 0, n = cells.size(); i < n; ++i) {\n let pair = cells.itemAt(i);\n let symbol = pair.first;\n let c = pair.second;\n if (c > 0.0 && symbol.type() !== SymbolType.Dummy) {\n let coeff = this._objective.coefficientFor(symbol);\n let r = coeff / c;\n if (r < ratio) {\n ratio = r;\n entering = symbol;\n }\n }\n }\n return entering;\n }\n /**\n * Compute the symbol for pivot exit row.\n *\n * This method will return the symbol for the exit row in the row\n * map. If no appropriate exit symbol is found, an invalid symbol\n * will be returned. This indicates that the objective function is\n * unbounded.\n *\n * @private\n */\n _getLeavingSymbol(entering) {\n let ratio = Number.MAX_VALUE;\n let found = INVALID_SYMBOL;\n let rows = this._rowMap;\n for (let i = 0, n = rows.size(); i < n; ++i) {\n let pair = rows.itemAt(i);\n let symbol = pair.first;\n if (symbol.type() !== SymbolType.External) {\n let row = pair.second;\n let temp = row.coefficientFor(entering);\n if (temp < 0.0) {\n let temp_ratio = -row.constant() / temp;\n if (temp_ratio < ratio) {\n ratio = temp_ratio;\n found = symbol;\n }\n }\n }\n }\n return found;\n }\n /**\n * Compute the leaving symbol for a marker variable.\n *\n * This method will return a symbol corresponding to a basic row\n * which holds the given marker variable. The row will be chosen\n * according to the following precedence:\n *\n * 1) The row with a restricted basic varible and a negative coefficient\n * for the marker with the smallest ratio of -constant / coefficient.\n *\n * 2) The row with a restricted basic variable and the smallest ratio\n * of constant / coefficient.\n *\n * 3) The last unrestricted row which contains the marker.\n *\n * If the marker does not exist in any row, an invalid symbol will be\n * returned. This indicates an internal solver error since the marker\n * *should* exist somewhere in the tableau.\n *\n * @private\n */\n _getMarkerLeavingSymbol(marker) {\n let dmax = Number.MAX_VALUE;\n let r1 = dmax;\n let r2 = dmax;\n let invalid = INVALID_SYMBOL;\n let first = invalid;\n let second = invalid;\n let third = invalid;\n let rows = this._rowMap;\n for (let i = 0, n = rows.size(); i < n; ++i) {\n let pair = rows.itemAt(i);\n let row = pair.second;\n let c = row.coefficientFor(marker);\n if (c === 0.0) {\n continue;\n }\n let symbol = pair.first;\n if (symbol.type() === SymbolType.External) {\n third = symbol;\n }\n else if (c < 0.0) {\n let r = -row.constant() / c;\n if (r < r1) {\n r1 = r;\n first = symbol;\n }\n }\n else {\n let r = row.constant() / c;\n if (r < r2) {\n r2 = r;\n second = symbol;\n }\n }\n }\n if (first !== invalid) {\n return first;\n }\n if (second !== invalid) {\n return second;\n }\n return third;\n }\n /**\n * Remove the effects of a constraint on the objective function.\n *\n * @private\n */\n _removeConstraintEffects(cn, tag) {\n if (tag.marker.type() === SymbolType.Error) {\n this._removeMarkerEffects(tag.marker, cn.strength());\n }\n if (tag.other.type() === SymbolType.Error) {\n this._removeMarkerEffects(tag.other, cn.strength());\n }\n }\n /**\n * Remove the effects of an error marker on the objective function.\n *\n * @private\n */\n _removeMarkerEffects(marker, strength) {\n let pair = this._rowMap.find(marker);\n if (pair !== undefined) {\n this._objective.insertRow(pair.second, -strength);\n }\n else {\n this._objective.insertSymbol(marker, -strength);\n }\n }\n /**\n * Get the first Slack or Error symbol in the row.\n *\n * If no such symbol is present, an invalid symbol will be returned.\n *\n * @private\n */\n _anyPivotableSymbol(row) {\n let cells = row.cells();\n for (let i = 0, n = cells.size(); i < n; ++i) {\n let pair = cells.itemAt(i);\n let type = pair.first.type();\n if (type === SymbolType.Slack || type === SymbolType.Error) {\n return pair.first;\n }\n }\n return INVALID_SYMBOL;\n }\n /**\n * Returns a new Symbol of the given type.\n *\n * @private\n */\n _makeSymbol(type) {\n return new Symbol(type, this._idTick++);\n }\n _cnMap = createCnMap();\n _rowMap = createRowMap();\n _varMap = createVarMap();\n _editMap = createEditMap();\n _infeasibleRows = [];\n _objective = new Row();\n _artificial = null;\n _idTick = 0;\n}\n/**\n * Test whether a value is approximately zero.\n * @private\n */\nfunction nearZero(value) {\n let eps = 1.0e-8;\n return value < 0.0 ? -value < eps : value < eps;\n}\n/**\n * An internal function for creating a constraint map.\n * @private\n */\nfunction createCnMap() {\n return createMap();\n}\n/**\n * An internal function for creating a row map.\n * @private\n */\nfunction createRowMap() {\n return createMap();\n}\n/**\n * An internal function for creating a variable map.\n * @private\n */\nfunction createVarMap() {\n return createMap();\n}\n/**\n * An internal function for creating an edit map.\n * @private\n */\nfunction createEditMap() {\n return createMap();\n}\n/**\n * An enum defining the available symbol types.\n * @private\n */\nvar SymbolType;\n(function (SymbolType) {\n SymbolType[SymbolType[\"Invalid\"] = 0] = \"Invalid\";\n SymbolType[SymbolType[\"External\"] = 1] = \"External\";\n SymbolType[SymbolType[\"Slack\"] = 2] = \"Slack\";\n SymbolType[SymbolType[\"Error\"] = 3] = \"Error\";\n SymbolType[SymbolType[\"Dummy\"] = 4] = \"Dummy\";\n})(SymbolType || (SymbolType = {}));\n/**\n * An internal class representing a symbol in the solver.\n * @private\n */\nclass Symbol {\n /**\n * Construct a new Symbol\n *\n * @param [type] The type of the symbol.\n * @param [id] The unique id number of the symbol.\n */\n constructor(type, id) {\n this._id = id;\n this._type = type;\n }\n /**\n * Returns the unique id number of the symbol.\n */\n id() {\n return this._id;\n }\n /**\n * Returns the type of the symbol.\n */\n type() {\n return this._type;\n }\n _id;\n _type;\n}\n/**\n * A static invalid symbol\n * @private\n */\nlet INVALID_SYMBOL = new Symbol(SymbolType.Invalid, -1);\n/**\n * An internal row class used by the solver.\n * @private\n */\nclass Row {\n /**\n * Construct a new Row.\n */\n constructor(constant = 0.0) {\n this._constant = constant;\n }\n /**\n * Returns the mapping of symbols to coefficients.\n */\n cells() {\n return this._cellMap;\n }\n /**\n * Returns the constant for the row.\n */\n constant() {\n return this._constant;\n }\n /**\n * Returns true if the row is a constant value.\n */\n isConstant() {\n return this._cellMap.empty();\n }\n /**\n * Returns true if the Row has all dummy symbols.\n */\n allDummies() {\n let cells = this._cellMap;\n for (let i = 0, n = cells.size(); i < n; ++i) {\n let pair = cells.itemAt(i);\n if (pair.first.type() !== SymbolType.Dummy) {\n return false;\n }\n }\n return true;\n }\n /**\n * Create a copy of the row.\n */\n copy() {\n let theCopy = new Row(this._constant);\n theCopy._cellMap = this._cellMap.copy();\n return theCopy;\n }\n /**\n * Add a constant value to the row constant.\n *\n * Returns the new value of the constant.\n */\n add(value) {\n return (this._constant += value);\n }\n /**\n * Insert the symbol into the row with the given coefficient.\n *\n * If the symbol already exists in the row, the coefficient\n * will be added to the existing coefficient. If the resulting\n * coefficient is zero, the symbol will be removed from the row.\n */\n insertSymbol(symbol, coefficient = 1.0) {\n let pair = this._cellMap.setDefault(symbol, () => 0.0);\n if (nearZero((pair.second += coefficient))) {\n this._cellMap.erase(symbol);\n }\n }\n /**\n * Insert a row into this row with a given coefficient.\n *\n * The constant and the cells of the other row will be\n * multiplied by the coefficient and added to this row. Any\n * cell with a resulting coefficient of zero will be removed\n * from the row.\n */\n insertRow(other, coefficient = 1.0) {\n this._constant += other._constant * coefficient;\n let cells = other._cellMap;\n for (let i = 0, n = cells.size(); i < n; ++i) {\n let pair = cells.itemAt(i);\n this.insertSymbol(pair.first, pair.second * coefficient);\n }\n }\n /**\n * Remove a symbol from the row.\n */\n removeSymbol(symbol) {\n this._cellMap.erase(symbol);\n }\n /**\n * Reverse the sign of the constant and cells in the row.\n */\n reverseSign() {\n this._constant = -this._constant;\n let cells = this._cellMap;\n for (let i = 0, n = cells.size(); i < n; ++i) {\n let pair = cells.itemAt(i);\n pair.second = -pair.second;\n }\n }\n /**\n * Solve the row for the given symbol.\n *\n * This method assumes the row is of the form\n * a * x + b * y + c = 0 and (assuming solve for x) will modify\n * the row to represent the right hand side of\n * x = -b/a * y - c / a. The target symbol will be removed from\n * the row, and the constant and other cells will be multiplied\n * by the negative inverse of the target coefficient.\n *\n * The given symbol *must* exist in the row.\n */\n solveFor(symbol) {\n let cells = this._cellMap;\n let pair = cells.erase(symbol);\n let coeff = -1.0 / pair.second;\n this._constant *= coeff;\n for (let i = 0, n = cells.size(); i < n; ++i) {\n cells.itemAt(i).second *= coeff;\n }\n }\n /**\n * Solve the row for the given symbols.\n *\n * This method assumes the row is of the form\n * x = b * y + c and will solve the row such that\n * y = x / b - c / b. The rhs symbol will be removed from the\n * row, the lhs added, and the result divided by the negative\n * inverse of the rhs coefficient.\n *\n * The lhs symbol *must not* exist in the row, and the rhs\n * symbol must* exist in the row.\n */\n solveForEx(lhs, rhs) {\n this.insertSymbol(lhs, -1.0);\n this.solveFor(rhs);\n }\n /**\n * Returns the coefficient for the given symbol.\n */\n coefficientFor(symbol) {\n let pair = this._cellMap.find(symbol);\n return pair !== undefined ? pair.second : 0.0;\n }\n /**\n * Substitute a symbol with the data from another row.\n *\n * Given a row of the form a * x + b and a substitution of the\n * form x = 3 * y + c the row will be updated to reflect the\n * expression 3 * a * y + a * c + b.\n *\n * If the symbol does not exist in the row, this is a no-op.\n */\n substitute(symbol, row) {\n let pair = this._cellMap.erase(symbol);\n if (pair !== undefined) {\n this.insertRow(row, pair.second);\n }\n }\n _cellMap = createMap();\n _constant;\n}\n","import { Strength } from \"@lume/kiwi\";\n\nconst HIGH_PRIORITY = 1000;\nconst MEDIUM_PRIORITY = 100;\nconst LOW_PRIORITY = 10;\n\n/** Constraint solver priority levels */\nexport enum UIPriority {\n /** Highest priority */\n P0 = 0,\n /** High priority */\n P1 = 1,\n /** Medium-high priority */\n P2 = 2,\n /** Medium priority */\n P3 = 3,\n /** Medium-low priority */\n P4 = 4,\n /** Low priority */\n P5 = 5,\n /** Very low priority */\n P6 = 6,\n /** Lowest priority */\n P7 = 7,\n}\n\n/**\n * Converts priority to solver strength.\n * @param priority Priority level\n * @returns Solver strength value\n * @throws If priority is invalid\n */\nexport function convertPriority(priority: UIPriority): number {\n switch (priority) {\n case UIPriority.P0:\n return Strength.create(HIGH_PRIORITY, HIGH_PRIORITY, HIGH_PRIORITY);\n case UIPriority.P1:\n return Strength.create(MEDIUM_PRIORITY, 0, 0);\n case UIPriority.P2:\n return Strength.create(LOW_PRIORITY, 0, 0);\n case UIPriority.P3:\n return Strength.create(0, MEDIUM_PRIORITY, 0);\n case UIPriority.P4:\n return Strength.create(0, LOW_PRIORITY, 0);\n case UIPriority.P5:\n return Strength.create(0, 0, MEDIUM_PRIORITY);\n case UIPriority.P6:\n return Strength.create(0, 0, LOW_PRIORITY);\n case UIPriority.P7:\n return Strength.create(0, 0, 1);\n default:\n throw new Error(`convertPriority: invalid priority`);\n }\n}\n\n/**\n * Resolves optional priority.\n * @param priority Priority to resolve\n * @returns Priority or P0 if undefined\n */\nexport function resolvePriority(priority?: UIPriority): UIPriority {\n return priority ?? UIPriority.P0;\n}\n","/** Transparency rendering modes */\nexport enum UITransparencyMode {\n /** Binary transparency. Best performance. */\n CLIP = 0,\n /** Dithered transparency. Good performance. */\n HASH = 1,\n /** Alpha blending. Best quality, requires depth sorting. */\n BLEND = 2,\n}\n","import type {\n UIInputWrapperCatcher,\n UIInputWrapperInterface,\n} from \"./UIInputWrapper.Internal\";\n\nexport class UIInputWrapper implements UIInputWrapperInterface {\n /** @internal */\n public dirty = false;\n\n private zIndicesDirty = false;\n private readonly catchers: UIInputWrapperCatcher[] = [];\n private lastHandler = 0;\n\n public createInputCatcher(\n catchPointerDown: (x: number, y: number, identifier: number) => boolean,\n catchPointerMove: (x: number, y: number, identifier: number) => boolean,\n catchPointerUp: (x: number, y: number, identifier: number) => boolean,\n zIndex: number,\n ): number {\n const handler = this.lastHandler++;\n this.catchers.push({\n handler,\n catchPointerDown,\n catchPointerMove,\n catchPointerUp,\n zIndex,\n active: true,\n });\n this.zIndicesDirty = true;\n this.dirty = true;\n return handler;\n }\n\n public destroyInputCatcher(handler: number): void {\n const index = this.catchers.findIndex((item) => item.handler === handler);\n if (index === -1) {\n throw new Error(\"UIInputWrapper.destroyInputCatcher: handler not found\");\n }\n this.catchers.splice(index, 1);\n }\n\n public getZIndex(handler: number): number {\n this.ensureSorted();\n const found = this.catchers.find((item) => item.handler === handler);\n if (!found) {\n throw new Error(\"UIInputWrapper.getZIndex: handler not found\");\n }\n return found.zIndex;\n }\n\n public setZIndex(handler: number, zIndex: number): void {\n const found = this.catchers.find((item) => item.handler === handler);\n if (!found) {\n throw new Error(\"UIInputWrapper.setZIndex: handler not found\");\n }\n if (found.zIndex !== zIndex) {\n found.zIndex = zIndex;\n this.zIndicesDirty = true;\n this.dirty = true;\n }\n }\n\n public getActive(handler: number): boolean {\n const found = this.catchers.find((item) => item.handler === handler);\n if (!found) {\n throw new Error(\"UIInputWrapper.getActive: handler not found\");\n }\n return found.active;\n }\n\n public setActive(handler: number, active: boolean): void {\n const found = this.catchers.find((item) => item.handler === handler);\n if (!found) {\n throw new Error(\"UIInputWrapper.setActive: handler not found\");\n }\n if (found.active !== active) {\n found.active = active;\n }\n }\n\n /** @internal */\n public onPointerDown(x: number, y: number, identifier: number): void {\n this.ensureSorted();\n for (let index = this.catchers.length - 1; index >= 0; index--) {\n const item = this.catchers[index];\n if (item.active && item.catchPointerDown(x, y, identifier)) {\n break;\n }\n }\n }\n\n /** @internal */\n public onPointerMove(x: number, y: number, identifier: number): void {\n this.ensureSorted();\n for (let index = this.catchers.length - 1; index >= 0; index--) {\n const item = this.catchers[index];\n if (item.active && item.catchPointerMove(x, y, identifier)) {\n break;\n }\n }\n }\n\n /** @internal */\n public onPointerUp(x: number, y: number, identifier: number): void {\n this.ensureSorted();\n for (let index = this.catchers.length - 1; index >= 0; index--) {\n const item = this.catchers[index];\n if (item.active && item.catchPointerUp(x, y, identifier)) {\n break;\n }\n }\n }\n\n private ensureSorted(): void {\n if (this.zIndicesDirty) {\n this.catchers.sort((a, b) => a.zIndex - b.zIndex);\n\n const count = this.catchers.length;\n const step = count < 1024 ? 1 : 1024 / count;\n for (let index = 0; index < count; index++) {\n this.catchers[index].zIndex = index * step;\n }\n\n this.zIndicesDirty = false;\n }\n }\n}\n","import { SRGBColorSpace, LinearSRGBColorSpace, SRGBTransfer, LinearTransfer, NoColorSpace } from '../constants.js';\nimport { Matrix3 } from './Matrix3.js';\nimport { warnOnce } from '../utils.js';\n\nconst LINEAR_REC709_TO_XYZ = /*@__PURE__*/ new Matrix3().set(\n\t0.4123908, 0.3575843, 0.1804808,\n\t0.2126390, 0.7151687, 0.0721923,\n\t0.0193308, 0.1191948, 0.9505322\n);\n\nconst XYZ_TO_LINEAR_REC709 = /*@__PURE__*/ new Matrix3().set(\n\t3.2409699, - 1.5373832, - 0.4986108,\n\t- 0.9692436, 1.8759675, 0.0415551,\n\t0.0556301, - 0.2039770, 1.0569715\n);\n\nfunction createColorManagement() {\n\n\tconst ColorManagement = {\n\n\t\tenabled: true,\n\n\t\tworkingColorSpace: LinearSRGBColorSpace,\n\n\t\t/**\n\t\t * Implementations of supported color spaces.\n\t\t *\n\t\t * Required:\n\t\t *\t- primaries: chromaticity coordinates [ rx ry gx gy bx by ]\n\t\t *\t- whitePoint: reference white [ x y ]\n\t\t *\t- transfer: transfer function (pre-defined)\n\t\t *\t- toXYZ: Matrix3 RGB to XYZ transform\n\t\t *\t- fromXYZ: Matrix3 XYZ to RGB transform\n\t\t *\t- luminanceCoefficients: RGB luminance coefficients\n\t\t *\n\t\t * Optional:\n\t\t * - outputColorSpaceConfig: { drawingBufferColorSpace: ColorSpace }\n\t\t * - workingColorSpaceConfig: { unpackColorSpace: ColorSpace }\n\t\t *\n\t\t * Reference:\n\t\t * - https://www.russellcottrell.com/photo/matrixCalculator.htm\n\t\t */\n\t\tspaces: {},\n\n\t\tconvert: function ( color, sourceColorSpace, targetColorSpace ) {\n\n\t\t\tif ( this.enabled === false || sourceColorSpace === targetColorSpace || ! sourceColorSpace || ! targetColorSpace ) {\n\n\t\t\t\treturn color;\n\n\t\t\t}\n\n\t\t\tif ( this.spaces[ sourceColorSpace ].transfer === SRGBTransfer ) {\n\n\t\t\t\tcolor.r = SRGBToLinear( color.r );\n\t\t\t\tcolor.g = SRGBToLinear( color.g );\n\t\t\t\tcolor.b = SRGBToLinear( color.b );\n\n\t\t\t}\n\n\t\t\tif ( this.spaces[ sourceColorSpace ].primaries !== this.spaces[ targetColorSpace ].primaries ) {\n\n\t\t\t\tcolor.applyMatrix3( this.spaces[ sourceColorSpace ].toXYZ );\n\t\t\t\tcolor.applyMatrix3( this.spaces[ targetColorSpace ].fromXYZ );\n\n\t\t\t}\n\n\t\t\tif ( this.spaces[ targetColorSpace ].transfer === SRGBTransfer ) {\n\n\t\t\t\tcolor.r = LinearToSRGB( color.r );\n\t\t\t\tcolor.g = LinearToSRGB( color.g );\n\t\t\t\tcolor.b = LinearToSRGB( color.b );\n\n\t\t\t}\n\n\t\t\treturn color;\n\n\t\t},\n\n\t\tworkingToColorSpace: function ( color, targetColorSpace ) {\n\n\t\t\treturn this.convert( color, this.workingColorSpace, targetColorSpace );\n\n\t\t},\n\n\t\tcolorSpaceToWorking: function ( color, sourceColorSpace ) {\n\n\t\t\treturn this.convert( color, sourceColorSpace, this.workingColorSpace );\n\n\t\t},\n\n\t\tgetPrimaries: function ( colorSpace ) {\n\n\t\t\treturn this.spaces[ colorSpace ].primaries;\n\n\t\t},\n\n\t\tgetTransfer: function ( colorSpace ) {\n\n\t\t\tif ( colorSpace === NoColorSpace ) return LinearTransfer;\n\n\t\t\treturn this.spaces[ colorSpace ].transfer;\n\n\t\t},\n\n\t\tgetLuminanceCoefficients: function ( target, colorSpace = this.workingColorSpace ) {\n\n\t\t\treturn target.fromArray( this.spaces[ colorSpace ].luminanceCoefficients );\n\n\t\t},\n\n\t\tdefine: function ( colorSpaces ) {\n\n\t\t\tObject.assign( this.spaces, colorSpaces );\n\n\t\t},\n\n\t\t// Internal APIs\n\n\t\t_getMatrix: function ( targetMatrix, sourceColorSpace, targetColorSpace ) {\n\n\t\t\treturn targetMatrix\n\t\t\t\t.copy( this.spaces[ sourceColorSpace ].toXYZ )\n\t\t\t\t.multiply( this.spaces[ targetColorSpace ].fromXYZ );\n\n\t\t},\n\n\t\t_getDrawingBufferColorSpace: function ( colorSpace ) {\n\n\t\t\treturn this.spaces[ colorSpace ].outputColorSpaceConfig.drawingBufferColorSpace;\n\n\t\t},\n\n\t\t_getUnpackColorSpace: function ( colorSpace = this.workingColorSpace ) {\n\n\t\t\treturn this.spaces[ colorSpace ].workingColorSpaceConfig.unpackColorSpace;\n\n\t\t},\n\n\t\t// Deprecated\n\n\t\tfromWorkingColorSpace: function ( color, targetColorSpace ) {\n\n\t\t\twarnOnce( 'THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace().' ); // @deprecated, r177\n\n\t\t\treturn ColorManagement.workingToColorSpace( color, targetColorSpace );\n\n\t\t},\n\n\t\ttoWorkingColorSpace: function ( color, sourceColorSpace ) {\n\n\t\t\twarnOnce( 'THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking().' ); // @deprecated, r177\n\n\t\t\treturn ColorManagement.colorSpaceToWorking( color, sourceColorSpace );\n\n\t\t},\n\n\t};\n\n\t/******************************************************************************\n\t * sRGB definitions\n\t */\n\n\tconst REC709_PRIMARIES = [ 0.640, 0.330, 0.300, 0.600, 0.150, 0.060 ];\n\tconst REC709_LUMINANCE_COEFFICIENTS = [ 0.2126, 0.7152, 0.0722 ];\n\tconst D65 = [ 0.3127, 0.3290 ];\n\n\tColorManagement.define( {\n\n\t\t[ LinearSRGBColorSpace ]: {\n\t\t\tprimaries: REC709_PRIMARIES,\n\t\t\twhitePoint: D65,\n\t\t\ttransfer: LinearTransfer,\n\t\t\ttoXYZ: LINEAR_REC709_TO_XYZ,\n\t\t\tfromXYZ: XYZ_TO_LINEAR_REC709,\n\t\t\tluminanceCoefficients: REC709_LUMINANCE_COEFFICIENTS,\n\t\t\tworkingColorSpaceConfig: { unpackColorSpace: SRGBColorSpace },\n\t\t\toutputColorSpaceConfig: { drawingBufferColorSpace: SRGBColorSpace }\n\t\t},\n\n\t\t[ SRGBColorSpace ]: {\n\t\t\tprimaries: REC709_PRIMARIES,\n\t\t\twhitePoint: D65,\n\t\t\ttransfer: SRGBTransfer,\n\t\t\ttoXYZ: LINEAR_REC709_TO_XYZ,\n\t\t\tfromXYZ: XYZ_TO_LINEAR_REC709,\n\t\t\tluminanceCoefficients: REC709_LUMINANCE_COEFFICIENTS,\n\t\t\toutputColorSpaceConfig: { drawingBufferColorSpace: SRGBColorSpace }\n\t\t},\n\n\t} );\n\n\treturn ColorManagement;\n\n}\n\nexport const ColorManagement = /*@__PURE__*/ createColorManagement();\n\nexport function SRGBToLinear( c ) {\n\n\treturn ( c < 0.04045 ) ? c * 0.0773993808 : Math.pow( c * 0.9478672986 + 0.0521327014, 2.4 );\n\n}\n\nexport function LinearToSRGB( c ) {\n\n\treturn ( c < 0.0031308 ) ? c * 12.92 : 1.055 * ( Math.pow( c, 0.41666 ) ) - 0.055;\n\n}\n","import type { Color } from \"three\";\nimport type { UIColor } from \"./UIColor\";\n\n/** Color configuration as Three.js Color, hex number, hex string, or UIColor */\nexport type UIColorConfig = Color | number | string | UIColor;\n\n/** Predefined color names */\nexport type UIColorName =\n | \"black\"\n | \"white\"\n | \"red\"\n | \"green\"\n | \"blue\"\n | \"yellow\"\n | \"cyan\"\n | \"magenta\"\n | \"gray\"\n | \"grey\"\n | \"silver\"\n | \"maroon\"\n | \"olive\"\n | \"lime\"\n | \"aqua\"\n | \"teal\"\n | \"navy\"\n | \"fuchsia\"\n | \"purple\"\n | \"orange\"\n | \"pink\"\n | \"brown\"\n | \"gold\"\n | \"violet\"\n | \"indigo\"\n | \"coral\"\n | \"salmon\"\n | \"khaki\"\n | \"plum\"\n | \"orchid\"\n | \"tan\"\n | \"beige\"\n | \"mint\"\n | \"lavender\"\n | \"crimson\"\n | \"azure\"\n | \"ivory\"\n | \"snow\";\n\nexport const COLORS: Record<string, number | undefined> = {\n black: 0x000000,\n white: 0xffffff,\n red: 0xff0000,\n green: 0x008000,\n blue: 0x0000ff,\n yellow: 0xffff00,\n cyan: 0x00ffff,\n magenta: 0xff00ff,\n\n gray: 0x808080,\n grey: 0x808080,\n silver: 0xc0c0c0,\n maroon: 0x800000,\n olive: 0x808000,\n lime: 0x00ff00,\n aqua: 0x00ffff,\n teal: 0x008080,\n navy: 0x000080,\n fuchsia: 0xff00ff,\n purple: 0x800080,\n\n orange: 0xffa500,\n pink: 0xffc0cb,\n brown: 0xa52a2a,\n gold: 0xffd700,\n violet: 0xee82ee,\n indigo: 0x4b0082,\n coral: 0xff7f50,\n salmon: 0xfa8072,\n khaki: 0xf0e68c,\n plum: 0xdda0dd,\n orchid: 0xda70d6,\n tan: 0xd2b48c,\n beige: 0xf5f5dc,\n mint: 0x98fb98,\n lavender: 0xe6e6fa,\n crimson: 0xdc143c,\n azure: 0xf0ffff,\n ivory: 0xfffff0,\n snow: 0xfffafa,\n};\n","import { Color, MathUtils, Vector4 } from \"three\";\nimport { LinearToSRGB, SRGBToLinear } from \"three/src/math/ColorManagement.js\";\nimport { assertValidNumber } from \"../asserts\";\nimport type { UIColorConfig, UIColorName } from \"./UIColor.Internal\";\nimport { COLORS } from \"./UIColor.Internal\";\n\n/** RGBA color with RGB, HSL, hex, and named color support */\nexport class UIColor {\n private rInternal = 1;\n private gInternal = 1;\n private bInternal = 1;\n private aInternal = 1;\n\n private hInternal = 0;\n private sInternal = 0;\n private lInternal = 1;\n\n private dirtyInternal = false;\n private rgbDirty = false;\n private hslDirty = false;\n\n constructor();\n /**\n * @param r - Red (0-1)\n * @param g - Green (0-1)\n * @param b - Blue (0-1)\n * @param a - Alpha (0-1)\n */\n // eslint-disable-next-line @typescript-eslint/unified-signatures -- Separate overloads make the different constructor patterns more clear\n constructor(r: number, g: number, b: number, a?: number);\n /**\n * @param colorName - Named color\n * @param a - Alpha (0-1)\n */\n // eslint-disable-next-line @typescript-eslint/unified-signatures -- Separate overloads make the different constructor patterns more clear\n constructor(colorName: UIColorName, a?: number);\n /**\n * @param threeColor - Three.js Color object\n * @param a - Alpha (0-1)\n */\n // eslint-disable-next-line @typescript-eslint/unified-signatures -- Separate overloads make the different constructor patterns more clear\n constructor(threeColor: Color, a?: number);\n /**\n * @param hexRGB - Hex RGB value (e.g., 0xff0000)\n * @param a - Alpha (0-1)\n */\n // eslint-disable-next-line @typescript-eslint/unified-signatures -- Separate overloads make the different constructor patterns more clear\n constructor(hexRGB: number, a?: number);\n /**\n * @param hexString - Hex string (e.g., \"#ffffff\" or \"#ffffffff\")\n */\n // eslint-disable-next-line @typescript-eslint/unified-signatures -- Separate overloads make the different constructor patterns more clear\n constructor(hexString?: string);\n /**\n * @param uiColor - UIColor object to copy from\n */\n // eslint-disable-next-line @typescript-eslint/unified-signatures -- Separate overloads make the different constructor patterns more clear\n constructor(uiColor?: UIColor);\n /**\n * @param uiColorConfig - UIColorConfig object\n */\n // eslint-disable-next-line @typescript-eslint/unified-signatures -- Separate overloads make the different constructor patterns more clear\n constructor(uiColorConfig?: UIColorConfig);\n constructor(...args: unknown[]) {\n if (args.length >= 3 && typeof args[0] === \"number\") {\n const [r, g, b, a = 1] = args as number[];\n this.rInternal = r;\n this.gInternal = g;\n this.bInternal = b;\n this.aInternal = a;\n } else if (args.length >= 1 && args[0] !== undefined) {\n const [firstArgument, a = 1] = args;\n if (typeof firstArgument === \"string\") {\n if (firstArgument.startsWith(\"#\")) {\n this.setHexString(firstArgument);\n } else {\n this.setColorName(firstArgument as UIColorName, a as number);\n }\n } else if (firstArgument instanceof UIColor) {\n firstArgument.ensureRGBUpdatedFromHSL();\n this.rInternal = firstArgument.rInternal;\n this.gInternal = firstArgument.gInternal;\n this.bInternal = firstArgument.bInternal;\n this.aInternal = firstArgument.aInternal;\n } else if (firstArgument instanceof Color) {\n this.rInternal = firstArgument.r;\n this.gInternal = firstArgument.g;\n this.bInternal = firstArgument.b;\n this.aInternal = a as number;\n } else if (typeof firstArgument === \"number\") {\n this.setHexRGB(firstArgument, a as number);\n }\n }\n }\n\n /** Black (0x000000) */\n public static get black(): UIColor {\n return new UIColor(\"black\");\n }\n\n /** White (0xffffff) */\n public static get white(): UIColor {\n return new UIColor(\"white\");\n }\n\n /** Red (0xff0000) */\n public static get red(): UIColor {\n return new UIColor(\"red\");\n }\n\n /** Green (0x008000) */\n public static get green(): UIColor {\n return new UIColor(\"green\");\n }\n\n /** Blue (0x0000ff) */\n public static get blue(): UIColor {\n return new UIColor(\"blue\");\n }\n\n /** Yellow (0xffff00) */\n public static get yellow(): UIColor {\n return new UIColor(\"yellow\");\n }\n\n /** Cyan (0x00ffff) */\n public static get cyan(): UIColor {\n return new UIColor(\"cyan\");\n }\n\n /** Magenta (0xff00ff) */\n public static get magenta(): UIColor {\n return new UIColor(\"magenta\");\n }\n\n /** Gray (0x808080) */\n public static get gray(): UIColor {\n return new UIColor(\"gray\");\n }\n\n /** Grey (0x808080) */\n public static get grey(): UIColor {\n return new UIColor(\"grey\");\n }\n\n /** Silver (0xc0c0c0) */\n public static get silver(): UIColor {\n return new UIColor(\"silver\");\n }\n\n /** Maroon (0x800000) */\n public static get maroon(): UIColor {\n return new UIColor(\"maroon\");\n }\n\n /** Olive (0x808000) */\n public static get olive(): UIColor {\n return new UIColor(\"olive\");\n }\n\n /** Lime (0x00ff00) */\n public static get lime(): UIColor {\n return new UIColor(\"lime\");\n }\n\n /** Aqua (0x00ffff) */\n public static get aqua(): UIColor {\n return new UIColor(\"aqua\");\n }\n\n /** Teal (0x008080) */\n public static get teal(): UIColor {\n return new UIColor(\"teal\");\n }\n\n /** Navy (0x000080) */\n public static get navy(): UIColor {\n return new UIColor(\"navy\");\n }\n\n /** Fuchsia (0xff00ff) */\n public static get fuchsia(): UIColor {\n return new UIColor(\"fuchsia\");\n }\n\n /** Purple (0x800080) */\n public static get purple(): UIColor {\n return new UIColor(\"purple\");\n }\n\n /** Orange (0xffa500) */\n public static get orange(): UIColor {\n return new UIColor(\"orange\");\n }\n\n /** Pink (0xffc0cb) */\n public static get pink(): UIColor {\n return new UIColor(\"pink\");\n }\n\n /** Brown (0xa52a2a) */\n public static get brown(): UIColor {\n return new UIColor(\"brown\");\n }\n\n /** Gold (0xffd700) */\n public static get gold(): UIColor {\n return new UIColor(\"gold\");\n }\n\n /** Violet (0xee82ee) */\n public static get violet(): UIColor {\n return new UIColor(\"violet\");\n }\n\n /** Indigo (0x4b0082) */\n public static get indigo(): UIColor {\n return new UIColor(\"indigo\");\n }\n\n /** Coral (0xff7f50) */\n public static get coral(): UIColor {\n return new UIColor(\"coral\");\n }\n\n /** Salmon (0xfa8072) */\n public static get salmon(): UIColor {\n return new UIColor(\"salmon\");\n }\n\n /** Khaki (0xf0e68c) */\n public static get khaki(): UIColor {\n return new UIColor(\"khaki\");\n }\n\n /** Plum (0xdda0dd) */\n public static get plum(): UIColor {\n return new UIColor(\"plum\");\n }\n\n /** Orchid (0xda70d6) */\n public static get orchid(): UIColor {\n return new UIColor(\"orchid\");\n }\n\n /** Tan (0xd2b48c) */\n public static get tan(): UIColor {\n return new UIColor(\"tan\");\n }\n\n /** Beige (0xf5f5dc) */\n public static get beige(): UIColor {\n return new UIColor(\"beige\");\n }\n\n /** Mint (0x98fb98) */\n public static get mint(): UIColor {\n return new UIColor(\"mint\");\n }\n\n /** Lavender (0xe6e6fa) */\n public static get lavender(): UIColor {\n return new UIColor(\"lavender\");\n }\n\n /** Crimson (0xdc143c) */\n public static get crimson(): UIColor {\n return new UIColor(\"crimson\");\n }\n\n /** Azure (0xf0ffff) */\n public static get azure(): UIColor {\n return new UIColor(\"azure\");\n }\n\n /** Ivory (0xfffff0) */\n public static get ivory(): UIColor {\n return new UIColor(\"ivory\");\n }\n\n /** Snow (0xfffafa) */\n public static get snow(): UIColor {\n return new UIColor(\"snow\");\n }\n\n /** Red component (0 to 1) */\n public get r(): number {\n this.ensureRGBUpdatedFromHSL();\n return this.rInternal;\n }\n\n /** Green component (0 to 1) */\n public get g(): number {\n this.ensureRGBUpdatedFromHSL();\n return this.gInternal;\n }\n\n /** Blue component (0 to 1) */\n public get b(): number {\n this.ensureRGBUpdatedFromHSL();\n return this.bInternal;\n }\n\n /** Alpha component (0 to 1) */\n public get a(): number {\n return this.aInternal;\n }\n\n /** Hue component (0 to 360) */\n public get hue(): number {\n this.ensureHSLUpdatedFromRGB();\n return this.hInternal;\n }\n\n /** Saturation component (0 to 1) */\n public get saturation(): number {\n this.ensureHSLUpdatedFromRGB();\n return this.sInternal;\n }\n\n /** Lightness component (0 to 1) */\n public get lightness(): number {\n this.ensureHSLUpdatedFromRGB();\n return this.lInternal;\n }\n\n /** @internal */\n public get dirty(): boolean {\n return this.dirtyInternal;\n }\n\n /** Red component (0 to 1) */\n public set r(value: number) {\n assertValidNumber(value, \"UIColor.r\");\n value = MathUtils.clamp(value, 0, 1);\n this.ensureRGBUpdatedFromHSL();\n if (value !== this.rInternal) {\n this.rInternal = value;\n this.hslDirty = true;\n this.dirtyInternal = true;\n }\n }\n\n /** Green component (0 to 1) */\n public set g(value: number) {\n assertValidNumber(value, \"UIColor.g\");\n value = MathUtils.clamp(value, 0, 1);\n this.ensureRGBUpdatedFromHSL();\n if (value !== this.gInternal) {\n this.gInternal = value;\n this.hslDirty = true;\n this.dirtyInternal = true;\n }\n }\n\n /** Blue component (0 to 1) */\n public set b(value: number) {\n assertValidNumber(value, \"UIColor.b\");\n value = MathUtils.clamp(value, 0, 1);\n this.ensureRGBUpdatedFromHSL();\n if (value !== this.bInternal) {\n this.bInternal = value;\n this.hslDirty = true;\n this.dirtyInternal = true;\n }\n }\n\n /** Alpha component (0 to 1) */\n public set a(value: number) {\n assertValidNumber(value, \"UIColor.a\");\n value = MathUtils.clamp(value, 0, 1);\n if (value !== this.aInternal) {\n this.aInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n /** Hue component (0 to 360) */\n public set hue(value: number) {\n assertValidNumber(value, \"UIColor.hue\");\n value = MathUtils.clamp(value, 0, 360);\n this.ensureHSLUpdatedFromRGB();\n if (value !== this.hInternal) {\n this.hInternal = value;\n this.rgbDirty = true;\n this.dirtyInternal = true;\n }\n }\n\n /** Saturation component (0 to 1) */\n public set saturation(value: number) {\n assertValidNumber(value, \"UIColor.saturation\");\n value = MathUtils.clamp(value, 0, 1);\n this.ensureHSLUpdatedFromRGB();\n if (value !== this.sInternal) {\n this.sInternal = value;\n this.rgbDirty = true;\n this.dirtyInternal = true;\n }\n }\n\n /** Lightness component (0 to 1) */\n public set lightness(value: number) {\n assertValidNumber(value, \"UIColor.lightness\");\n value = MathUtils.clamp(value, 0, 1);\n this.ensureHSLUpdatedFromRGB();\n if (value !== this.lInternal) {\n this.lInternal = value;\n this.rgbDirty = true;\n this.dirtyInternal = true;\n }\n }\n\n /** @internal */\n public setDirtyFalse(): void {\n this.dirtyInternal = false;\n }\n\n /** Sets RGB(A) components */\n public set(\n r: number,\n g: number,\n b: number,\n a: number = this.aInternal,\n ): this {\n assertValidNumber(r, \"UIColor.set.r\");\n assertValidNumber(g, \"UIColor.set.g\");\n assertValidNumber(b, \"UIColor.set.b\");\n assertValidNumber(a, \"UIColor.set.a\");\n r = MathUtils.clamp(r, 0, 1);\n g = MathUtils.clamp(g, 0, 1);\n b = MathUtils.clamp(b, 0, 1);\n a = MathUtils.clamp(a, 0, 1);\n this.ensureRGBUpdatedFromHSL();\n if (\n r !== this.rInternal ||\n g !== this.gInternal ||\n b !== this.bInternal ||\n a !== this.aInternal\n ) {\n this.rInternal = r;\n this.gInternal = g;\n this.bInternal = b;\n this.aInternal = a;\n this.hslDirty = true;\n this.dirtyInternal = true;\n }\n return this;\n }\n\n /** Returns RGBA as 32-bit hex (RRGGBBAA) */\n public getHexRGBA(): number {\n this.ensureRGBUpdatedFromHSL();\n return (\n (Math.round(this.rInternal * 255) << 24) |\n (Math.round(this.gInternal * 255) << 16) |\n (Math.round(this.bInternal * 255) << 8) |\n Math.round(this.aInternal * 255)\n );\n }\n\n /** Returns RGB as 24-bit hex (RRGGBB) */\n public getHexRGB(): number {\n this.ensureRGBUpdatedFromHSL();\n return (\n (Math.round(this.rInternal * 255) << 16) |\n (Math.round(this.gInternal * 255) << 8) |\n Math.round(this.bInternal * 255)\n );\n }\n\n /** Returns RGB as hex string (\"#ffffff\") */\n public getHexStringRGB(): string {\n const hex = this.getHexRGB();\n return `#${hex.toString(16).padStart(6, \"0\")}`;\n }\n\n /** Returns RGBA as hex string (\"#ffffffff\") */\n public getHexStringRGBA(): string {\n const hex = this.getHexRGBA();\n return `#${hex.toString(16).padStart(8, \"0\")}`;\n }\n\n /** Sets from 32-bit hex RGBA (RRGGBBAA) */\n public setHexRGBA(hex: number): this {\n assertValidNumber(hex, \"UIColor.setHexRGBA.hex\");\n this.ensureRGBUpdatedFromHSL();\n const r = ((hex >> 16) & 0xff) / 255;\n const g = ((hex >> 8) & 0xff) / 255;\n const b = (hex & 0xff) / 255;\n const a = ((hex >> 24) & 0xff) / 255;\n if (\n r !== this.rInternal ||\n g !== this.gInternal ||\n b !== this.bInternal ||\n a !== this.aInternal\n ) {\n this.rInternal = r;\n this.gInternal = g;\n this.bInternal = b;\n this.aInternal = a;\n this.hslDirty = true;\n this.dirtyInternal = true;\n }\n return this;\n }\n\n /** Sets from 24-bit hex RGB (RRGGBB) */\n public setHexRGB(hex: number, a = this.aInternal): this {\n assertValidNumber(hex, \"UIColor.setHexRGB.hex\");\n assertValidNumber(a, \"UIColor.setHexRGB.a\");\n a = MathUtils.clamp(a, 0, 1);\n this.ensureRGBUpdatedFromHSL();\n const r = ((hex >> 16) & 0xff) / 255;\n const g = ((hex >> 8) & 0xff) / 255;\n const b = (hex & 0xff) / 255;\n if (\n r !== this.rInternal ||\n g !== this.gInternal ||\n b !== this.bInternal ||\n a !== this.aInternal\n ) {\n this.rInternal = r;\n this.gInternal = g;\n this.bInternal = b;\n this.aInternal = a;\n this.hslDirty = true;\n this.dirtyInternal = true;\n }\n return this;\n }\n\n /**\n * Sets from hex string.\n *\n * @param hexString - Format: \"#ffffff\" or \"#ffffffff\"\n * @throws If format invalid\n */\n public setHexString(hexString: string): this {\n if (!hexString.startsWith(\"#\")) {\n throw new Error(\n `UIColor.setHexString.hexString: invalid hex string format. expected format: \"#ffffff\" or \"#ffffffff\"`,\n );\n }\n\n const hex = hexString.slice(1);\n\n if (hex.length === 6) {\n const hexNumber = parseInt(hex, 16);\n if (isNaN(hexNumber)) {\n throw new Error(\n `UIColor.setHexString.hexString: invalid hex string format. expected format: \"#ffffff\" or \"#ffffffff\"`,\n );\n }\n return this.setHexRGB(hexNumber);\n } else if (hex.length === 8) {\n const hexNumber = parseInt(hex, 16);\n if (isNaN(hexNumber)) {\n throw new Error(\n `UIColor.setHexString.hexString: invalid hex string format. expected format: \"#ffffff\" or \"#ffffffff\"`,\n );\n }\n return this.setHexRGBA(hexNumber);\n } else {\n throw new Error(\n `UIColor.setHexString.hexString: invalid hex string format. expected format: \"#ffffff\" or \"#ffffffff\"`,\n );\n }\n }\n\n /** Sets from HSL values */\n public setHSL(h: number, s: number, l: number, a = this.aInternal): this {\n assertValidNumber(h, \"UIColor.setHSL.h\");\n assertValidNumber(s, \"UIColor.setHSL.s\");\n assertValidNumber(l, \"UIColor.setHSL.l\");\n assertValidNumber(a, \"UIColor.setHSL.a\");\n h = MathUtils.clamp(h, 0, 360);\n s = MathUtils.clamp(s, 0, 1);\n l = MathUtils.clamp(l, 0, 1);\n a = MathUtils.clamp(a, 0, 1);\n this.ensureHSLUpdatedFromRGB();\n if (\n h !== this.hInternal ||\n s !== this.sInternal ||\n l !== this.lInternal ||\n a !== this.aInternal\n ) {\n this.hInternal = h;\n this.sInternal = s;\n this.lInternal = l;\n this.aInternal = a;\n this.rgbDirty = true;\n this.dirtyInternal = true;\n }\n return this;\n }\n\n /**\n * Sets from predefined name.\n *\n * @throws If color name unknown\n */\n public setColorName(colorName: UIColorName, a = this.aInternal): this {\n assertValidNumber(a, \"UIColor.setColorName.a\");\n a = MathUtils.clamp(a, 0, 1);\n const normalizedName = colorName.toLowerCase().trim();\n const hex = COLORS[normalizedName];\n\n if (hex === undefined) {\n throw new Error(`UIColor.setColorName.colorName: unknown color name`);\n }\n\n return this.setHexRGB(hex, a);\n }\n\n /** Sets from linear (GLSL) color space */\n public setGLSLColor(\n r: number,\n g: number,\n b: number,\n a = this.aInternal,\n ): this {\n assertValidNumber(r, \"UIColor.setGLSLColor.r\");\n assertValidNumber(g, \"UIColor.setGLSLColor.g\");\n assertValidNumber(b, \"UIColor.setGLSLColor.b\");\n assertValidNumber(a, \"UIColor.setGLSLColor.a\");\n a = MathUtils.clamp(a, 0, 1);\n this.ensureRGBUpdatedFromHSL();\n\n const sRGBR = LinearToSRGB(r);\n const sRGBG = LinearToSRGB(g);\n const sRGBB = LinearToSRGB(b);\n\n if (\n sRGBR !== this.rInternal ||\n sRGBG !== this.gInternal ||\n sRGBB !== this.bInternal ||\n a !== this.aInternal\n ) {\n this.rInternal = sRGBR;\n this.gInternal = sRGBG;\n this.bInternal = sRGBB;\n this.aInternal = a;\n this.hslDirty = true;\n this.dirtyInternal = true;\n }\n\n return this;\n }\n\n /** Sets from Three.js Color */\n public setThreeColor(threeColor: Color, a = this.aInternal): this {\n assertValidNumber(a, \"UIColor.setThreeColor.a\");\n a = MathUtils.clamp(a, 0, 1);\n this.ensureRGBUpdatedFromHSL();\n if (\n threeColor.r !== this.rInternal ||\n threeColor.g !== this.gInternal ||\n threeColor.b !== this.bInternal ||\n a !== this.aInternal\n ) {\n this.rInternal = threeColor.r;\n this.gInternal = threeColor.g;\n this.bInternal = threeColor.b;\n this.aInternal = a;\n this.hslDirty = true;\n this.dirtyInternal = true;\n }\n return this;\n }\n\n /** Returns CSS color string (\"rgba(255, 0, 0, 1)\") */\n public toCSSColor(): string {\n this.ensureRGBUpdatedFromHSL();\n const r = Math.round(this.rInternal * 255);\n const g = Math.round(this.gInternal * 255);\n const b = Math.round(this.bInternal * 255);\n return `rgba(${r}, ${g}, ${b}, ${this.aInternal})`;\n }\n\n /** Converts to linear (GLSL) color space */\n public toGLSLColor(result: Vector4 = new Vector4()): Vector4 {\n this.ensureRGBUpdatedFromHSL();\n\n result.x = SRGBToLinear(this.rInternal);\n result.y = SRGBToLinear(this.gInternal);\n result.z = SRGBToLinear(this.bInternal);\n result.w = this.aInternal;\n\n return result;\n }\n\n /** Converts to Three.js Color (without alpha) */\n public toThreeColor(result: Color = new Color()): Color {\n this.ensureRGBUpdatedFromHSL();\n\n result.r = this.rInternal;\n result.g = this.gInternal;\n result.b = this.bInternal;\n\n return result;\n }\n\n /** Copies from another color */\n public copy(color: UIColor | Color): this {\n if (color instanceof UIColor) {\n this.ensureRGBUpdatedFromHSL();\n color.ensureRGBUpdatedFromHSL();\n\n if (\n this.rInternal !== color.rInternal ||\n this.gInternal !== color.gInternal ||\n this.bInternal !== color.bInternal ||\n this.aInternal !== color.aInternal\n ) {\n this.rInternal = color.rInternal;\n this.gInternal = color.gInternal;\n this.bInternal = color.bInternal;\n this.aInternal = color.aInternal;\n this.hslDirty = true;\n this.dirtyInternal = true;\n }\n } else {\n this.ensureRGBUpdatedFromHSL();\n if (\n this.rInternal !== color.r ||\n this.gInternal !== color.g ||\n this.bInternal !== color.b ||\n this.aInternal !== 1\n ) {\n this.rInternal = color.r;\n this.gInternal = color.g;\n this.bInternal = color.b;\n this.aInternal = 1;\n this.hslDirty = true;\n this.dirtyInternal = true;\n }\n }\n\n return this;\n }\n\n /** Returns copy of this color */\n public clone(): UIColor {\n this.ensureRGBUpdatedFromHSL();\n return new UIColor(\n this.rInternal,\n this.gInternal,\n this.bInternal,\n this.aInternal,\n );\n }\n\n /** @internal */\n private ensureRGBUpdatedFromHSL(): void {\n if (this.rgbDirty) {\n const { hInternal: h, sInternal: s, lInternal: l } = this;\n const c = (1 - Math.abs(2 * l - 1)) * s;\n const hp = h / 60;\n const x = c * (1 - Math.abs((hp % 2) - 1));\n let [r, g, b] =\n hp < 1\n ? [c, x, 0]\n : hp < 2\n ? [x, c, 0]\n : hp < 3\n ? [0, c, x]\n : hp < 4\n ? [0, x, c]\n : hp < 5\n ? [x, 0, c]\n : [c, 0, x];\n\n const m = l - c / 2;\n this.rInternal = r + m;\n this.gInternal = g + m;\n this.bInternal = b + m;\n this.rgbDirty = false;\n }\n }\n\n private ensureHSLUpdatedFromRGB(): void {\n if (this.hslDirty) {\n const { rInternal: r, gInternal: g, bInternal: b } = this;\n const max = Math.max(r, g, b);\n const min = Math.min(r, g, b);\n const d = max - min;\n const l = (max + min) / 2;\n\n let h = 0;\n if (d !== 0) {\n if (max === r) {\n h = (g - b) / d + (g < b ? 6 : 0);\n } else if (max === g) {\n h = (b - r) / d + 2;\n } else {\n h = (r - g) / d + 4;\n }\n h *= 60;\n }\n\n const s = d === 0 ? 0 : d / (1 - Math.abs(2 * l - 1));\n this.hInternal = h;\n this.sInternal = s;\n this.lInternal = l;\n this.hslDirty = false;\n }\n }\n}\n","import type { IUniform, ShaderMaterial } from \"three\";\nimport { Matrix3, Matrix4, Texture, Vector2, Vector3, Vector4 } from \"three\";\nimport type { UITransparencyMode } from \"../UITransparencyMode\";\nimport { UIColor } from \"../color/UIColor\";\n\nexport type UIPropertyType =\n | Texture\n | UIColor\n | Vector2\n | Vector3\n | Vector4\n | Matrix3\n | Matrix4\n | number;\n\nexport interface GLSLTypeInfo {\n instantiable: boolean;\n glslType: string;\n itemSize: number;\n}\n\nexport interface GenericPlaneData {\n source: string;\n properties: Record<string, UIPropertyType>;\n transparency: UITransparencyMode;\n transform: Matrix4;\n visibility: boolean;\n}\n\nexport const DEFAULT_ALPHA_TEST = 0.5;\n\nexport function resolveGLSLTypeInfo(value: UIPropertyType): GLSLTypeInfo {\n if (typeof value === \"number\") {\n return { glslType: \"float\", instantiable: true, itemSize: 1 };\n }\n if (value instanceof Texture) {\n return { glslType: \"sampler2D\", instantiable: false, itemSize: -1 };\n }\n if (value instanceof UIColor) {\n return { glslType: \"vec4\", instantiable: true, itemSize: 4 };\n }\n if (value instanceof Vector2) {\n return { glslType: \"vec2\", instantiable: true, itemSize: 2 };\n }\n if (value instanceof Vector3) {\n return { glslType: \"vec3\", instantiable: true, itemSize: 3 };\n }\n if (value instanceof Vector4) {\n return { glslType: \"vec4\", instantiable: true, itemSize: 4 };\n }\n if (value instanceof Matrix3) {\n return { glslType: \"mat3\", instantiable: true, itemSize: 9 };\n }\n if (value instanceof Matrix4) {\n return { glslType: \"mat4\", instantiable: true, itemSize: 16 };\n }\n throw new Error(`resolveGLSLTypeInfo.value: unsupported property type`);\n}\n\nexport function resolveUniform(\n name: string,\n material: ShaderMaterial,\n): IUniform<unknown> {\n const uniform = material.uniforms[`p_${name}`] as\n | IUniform<unknown>\n | undefined;\n if (uniform === undefined) {\n throw new Error(`resolveUniform.name: unknown uniform`);\n }\n return uniform;\n}\n\nexport function arePropertiesCompatible(\n currentProperties: Record<string, UIPropertyType>,\n newProperties: Record<string, UIPropertyType>,\n): boolean {\n const currentKeys = Object.keys(currentProperties);\n const newKeys = Object.keys(newProperties);\n\n if (currentKeys.length !== newKeys.length) {\n return false;\n }\n\n for (const newKey of newKeys) {\n if (!(newKey in currentProperties)) {\n return false;\n }\n\n const currentInfo = resolveGLSLTypeInfo(currentProperties[newKey]);\n const newInfo = resolveGLSLTypeInfo(newProperties[newKey]);\n\n if (currentInfo.glslType !== newInfo.glslType) {\n return false;\n }\n\n // Non-instantiable (textures) must match by reference\n if (\n !newInfo.instantiable &&\n newProperties[newKey] !== currentProperties[newKey]\n ) {\n return false;\n }\n }\n\n return true;\n}\n\nexport function buildGenericPlaneFragmentShader(\n uniformDeclarations: string[],\n varyingDeclarations: string[],\n source: string,\n): string {\n return `\n // Defines\n #define PI 3.14159265359\n\n // Uniforms\n ${uniformDeclarations.join(\"\\n\")}\n\n // Builtin varyings\n varying vec3 p_position;\n varying vec2 p_uv;\n\n // User varyings\n ${varyingDeclarations.join(\"\\n\")}\n\n #include <alphahash_pars_fragment>\n\n // Source must define vec4 draw() function\n ${source}\n\n void main() {\n vec4 diffuseColor = draw();\n\n #ifdef USE_ALPHATEST\n if (diffuseColor.a < ${DEFAULT_ALPHA_TEST.toFixed(2)}) {\n discard;\n }\n #endif\n\n #ifdef USE_ALPHAHASH\n if (diffuseColor.a < getAlphaHashThreshold(p_position)) {\n discard;\n }\n #endif\n\n gl_FragColor = linearToOutputTexel(diffuseColor);\n }\n `;\n}\n","import {\n InstancedBufferAttribute,\n InstancedBufferGeometry,\n Matrix3,\n Matrix4,\n PlaneGeometry,\n ShaderMaterial,\n Vector2,\n Vector3,\n Vector4,\n} from \"three\";\nimport { UIColor } from \"../color/UIColor\";\nimport { UITransparencyMode } from \"../UITransparencyMode\";\nimport type { UIPropertyType } from \"./shared\";\nimport {\n buildGenericPlaneFragmentShader,\n DEFAULT_ALPHA_TEST,\n resolveGLSLTypeInfo,\n} from \"./shared\";\n\nexport const INSTANCED_PLANE_GEOMETRY = ((): InstancedBufferGeometry => {\n const planeGeometry = new PlaneGeometry(1, 1);\n planeGeometry.translate(0.5, 0.5, 0);\n const geometry = new InstancedBufferGeometry();\n geometry.index = planeGeometry.index;\n geometry.setAttribute(\"position\", planeGeometry.attributes[\"position\"]);\n geometry.setAttribute(\"uv\", planeGeometry.attributes[\"uv\"]);\n planeGeometry.dispose();\n return geometry;\n})();\n\nexport const CAPACITY_STEP = 4;\n\nconst TEMP_COLOR_VECTOR = new Vector4();\nconst IDENTITY_MATRIX_ELEMENTS = [\n 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1,\n];\n\nexport function writePropertyToArray(\n value: UIPropertyType,\n array: Float32Array,\n offset: number,\n): void {\n if (value instanceof UIColor) {\n value.toGLSLColor(TEMP_COLOR_VECTOR);\n array[offset] = TEMP_COLOR_VECTOR.x;\n array[offset + 1] = TEMP_COLOR_VECTOR.y;\n array[offset + 2] = TEMP_COLOR_VECTOR.z;\n array[offset + 3] = TEMP_COLOR_VECTOR.w;\n } else if (value instanceof Vector2) {\n array[offset] = value.x;\n array[offset + 1] = value.y;\n } else if (value instanceof Vector3) {\n array[offset] = value.x;\n array[offset + 1] = value.y;\n array[offset + 2] = value.z;\n } else if (value instanceof Vector4) {\n array[offset] = value.x;\n array[offset + 1] = value.y;\n array[offset + 2] = value.z;\n array[offset + 3] = value.w;\n } else if (value instanceof Matrix3 || value instanceof Matrix4) {\n const elements = value.elements;\n for (let j = 0; j < elements.length; j++) {\n array[offset + j] = elements[j];\n }\n } else if (typeof value === \"number\") {\n array[offset] = value;\n }\n}\n\nexport function writeInstanceDefaults(\n visibilityArray: Float32Array,\n transformArray: Float32Array,\n index: number,\n): void {\n visibilityArray[index] = 1;\n\n const transformOffset = index * 16;\n for (let j = 0; j < 16; j++) {\n transformArray[transformOffset + j] = IDENTITY_MATRIX_ELEMENTS[j];\n }\n}\n\nexport function buildEmptyInstancedBufferAttribute(\n value: UIPropertyType,\n capacity: number,\n): InstancedBufferAttribute {\n const info = resolveGLSLTypeInfo(value);\n if (!info.instantiable) {\n throw new Error(\n `buildEmptyInstancedBufferAttribute.value: cannot create instanced attribute for non-instantiable type`,\n );\n }\n return new InstancedBufferAttribute(\n new Float32Array(capacity * info.itemSize),\n info.itemSize,\n );\n}\n\nexport function buildMaterial(\n source: string,\n uniformProperties: Record<string, UIPropertyType>,\n varyingProperties: Record<string, UIPropertyType>,\n transparency: UITransparencyMode,\n): ShaderMaterial {\n const uniforms: Record<string, { value: unknown }> = {};\n\n const uniformDeclarations: string[] = [];\n const attributeDeclarations: string[] = [];\n const varyingDeclarations: string[] = [];\n const vertexAssignments: string[] = [];\n\n for (const [name, value] of Object.entries(uniformProperties)) {\n const info = resolveGLSLTypeInfo(value);\n uniforms[`p_${name}`] = {\n value: value instanceof UIColor ? value.toGLSLColor() : value,\n };\n uniformDeclarations.push(`uniform ${info.glslType} p_${name};`);\n }\n\n for (const [name, value] of Object.entries(varyingProperties)) {\n const info = resolveGLSLTypeInfo(value);\n attributeDeclarations.push(`attribute ${info.glslType} a_${name};`);\n varyingDeclarations.push(`varying ${info.glslType} p_${name};`);\n vertexAssignments.push(`p_${name} = a_${name};`);\n }\n\n const vertexShader = `\n // User attributes\n ${attributeDeclarations.join(\"\\n\")}\n\n // Uniforms\n ${uniformDeclarations.join(\"\\n\")}\n\n // Builtin varyings\n varying vec3 p_position;\n varying vec2 p_uv;\n\n // User varyings\n ${varyingDeclarations.join(\"\\n\")}\n\n void main() {\n if (a_instanceVisibility < 0.5) {\n gl_Position = vec4(2.0, 2.0, 2.0, 1.0);\n return;\n }\n\n ${vertexAssignments.join(\"\\n\")}\n\n p_position = position;\n p_uv = uv;\n\n gl_Position = projectionMatrix * a_instanceTransform * vec4(position, 1.0);\n }\n `;\n\n const fragmentShader = buildGenericPlaneFragmentShader(\n uniformDeclarations,\n varyingDeclarations,\n source,\n );\n\n return new ShaderMaterial({\n uniforms,\n vertexShader,\n fragmentShader,\n transparent: transparency === UITransparencyMode.BLEND,\n alphaTest:\n transparency === UITransparencyMode.CLIP ? DEFAULT_ALPHA_TEST : 0.0,\n alphaHash: transparency === UITransparencyMode.HASH,\n depthWrite: transparency !== UITransparencyMode.BLEND,\n depthTest: true,\n });\n}\n\nexport function reconstructValue(\n referenceValue: UIPropertyType,\n array: Float32Array,\n offset: number,\n): UIPropertyType {\n if (typeof referenceValue === \"number\") {\n return array[offset];\n }\n if (referenceValue instanceof Vector2) {\n return new Vector2(array[offset], array[offset + 1]);\n }\n if (referenceValue instanceof Vector3) {\n return new Vector3(array[offset], array[offset + 1], array[offset + 2]);\n }\n if (referenceValue instanceof Vector4) {\n return new Vector4(\n array[offset],\n array[offset + 1],\n array[offset + 2],\n array[offset + 3],\n );\n }\n if (referenceValue instanceof UIColor) {\n return new UIColor().setGLSLColor(\n array[offset],\n array[offset + 1],\n array[offset + 2],\n array[offset + 3],\n );\n }\n if (referenceValue instanceof Matrix3) {\n const matrix = new Matrix3();\n matrix.fromArray(array, offset);\n return matrix;\n }\n if (referenceValue instanceof Matrix4) {\n const matrix = new Matrix4();\n matrix.fromArray(array, offset);\n return matrix;\n }\n throw new Error(\n `reconstructValue.referenceValue: cannot reconstruct value for type`,\n );\n}\n","import type { InstancedBufferGeometry, ShaderMaterial } from \"three\";\nimport { InstancedBufferAttribute, Matrix4, Mesh } from \"three\";\nimport { UITransparencyMode } from \"../UITransparencyMode\";\nimport type { GenericPlaneData, UIPropertyType } from \"./shared\";\nimport {\n arePropertiesCompatible,\n resolveGLSLTypeInfo,\n resolveUniform,\n} from \"./shared\";\nimport {\n buildEmptyInstancedBufferAttribute,\n buildMaterial,\n CAPACITY_STEP,\n INSTANCED_PLANE_GEOMETRY,\n reconstructValue,\n writeInstanceDefaults,\n writePropertyToArray,\n} from \"./UIGenericInstancedPlane.Internal\";\n\nexport class UIGenericInstancedPlane extends Mesh {\n private readonly handlerToIndex = new Map<number, number>();\n private readonly propertyBuffers = new Map<\n string,\n InstancedBufferAttribute\n >();\n private readonly instancedGeometry: InstancedBufferGeometry;\n private readonly shaderMaterial: ShaderMaterial;\n\n private readonly uniformProperties: Record<string, UIPropertyType>;\n private readonly varyingProperties: Record<string, UIPropertyType>;\n\n private lastHandler = 0;\n private capacity: number;\n\n constructor(\n public readonly source: string,\n properties: Record<string, UIPropertyType>,\n public readonly transparency: UITransparencyMode = UITransparencyMode.BLEND,\n initialCapacity: number = CAPACITY_STEP,\n ) {\n const uniformProperties: Record<string, UIPropertyType> = {};\n const varyingProperties: Record<string, UIPropertyType> = {\n instanceVisibility: 1,\n instanceTransform: new Matrix4().identity(),\n };\n\n for (const [name, value] of Object.entries(properties)) {\n const info = resolveGLSLTypeInfo(value);\n if (info.instantiable) {\n varyingProperties[name] = value;\n } else {\n uniformProperties[name] = value;\n }\n }\n\n const instancedGeometry = INSTANCED_PLANE_GEOMETRY.clone();\n const shaderMaterial = buildMaterial(\n source,\n uniformProperties,\n varyingProperties,\n transparency,\n );\n\n super(instancedGeometry, shaderMaterial);\n\n this.frustumCulled = false;\n this.matrixAutoUpdate = false;\n this.matrixWorldAutoUpdate = false;\n\n this.instancedGeometry = instancedGeometry;\n this.instancedGeometry.instanceCount = 0;\n this.shaderMaterial = shaderMaterial;\n this.uniformProperties = uniformProperties;\n this.varyingProperties = varyingProperties;\n this.capacity = Math.max(\n Math.ceil(initialCapacity / CAPACITY_STEP) * CAPACITY_STEP,\n CAPACITY_STEP,\n );\n\n {\n for (const [name, value] of Object.entries(this.varyingProperties)) {\n const attribute = buildEmptyInstancedBufferAttribute(\n value,\n this.capacity,\n );\n this.instancedGeometry.setAttribute(`a_${name}`, attribute);\n this.propertyBuffers.set(name, attribute);\n }\n }\n\n {\n for (const [name, value] of Object.entries(this.uniformProperties)) {\n const uniform = resolveUniform(name, this.shaderMaterial);\n uniform.value = value;\n }\n this.shaderMaterial.uniformsNeedUpdate = true;\n }\n }\n\n public get instanceCount(): number {\n return this.instancedGeometry.instanceCount;\n }\n\n public get properties(): Record<string, UIPropertyType> {\n return { ...this.uniformProperties, ...this.varyingProperties };\n }\n\n public createInstance(): number {\n const handler = this.lastHandler++;\n const index = this.instancedGeometry.instanceCount;\n\n this.ensureCapacity(index + 1);\n\n this.handlerToIndex.set(handler, index);\n this.instancedGeometry.instanceCount++;\n\n this.initializeInstanceDefaults(index);\n return handler;\n }\n\n public destroyInstance(handler: number): void {\n const index = this.resolveIndex(handler);\n\n this.handlerToIndex.delete(handler);\n\n const lastIndex = this.instancedGeometry.instanceCount - 1;\n\n if (index < lastIndex) {\n this.moveInstanceData(lastIndex, index);\n this.updateIndicesAfterMove(lastIndex, index);\n }\n\n this.instancedGeometry.instanceCount--;\n }\n\n public setProperties(\n handler: number,\n properties: Record<string, UIPropertyType>,\n ): void {\n const index = this.resolveIndex(handler);\n\n for (const [name, value] of Object.entries(properties)) {\n const typeInfo = resolveGLSLTypeInfo(value);\n\n if (typeInfo.instantiable) {\n const attribute = this.resolveAttribute(name);\n const offset = index * attribute.itemSize;\n writePropertyToArray(value, attribute.array as Float32Array, offset);\n attribute.needsUpdate = true;\n } else {\n const uniform = resolveUniform(name, this.shaderMaterial);\n uniform.value = value;\n this.shaderMaterial.uniformsNeedUpdate = true;\n }\n }\n }\n\n public setTransform(handler: number, transform: Matrix4): void {\n const index = this.resolveIndex(handler);\n\n const attribute = this.resolveAttribute(\"instanceTransform\");\n const array = attribute.array as Float32Array;\n const offset = index * 16;\n\n const elements = transform.elements;\n for (let j = 0; j < 16; j++) {\n array[offset + j] = elements[j];\n }\n\n attribute.needsUpdate = true;\n }\n\n public setVisibility(handler: number, visible: boolean): void {\n const index = this.resolveIndex(handler);\n\n const attribute = this.resolveAttribute(\"instanceVisibility\");\n const array = attribute.array as Float32Array;\n array[index] = visible ? 1 : 0;\n\n attribute.needsUpdate = true;\n }\n\n public isCompatible(\n source: string,\n properties: Record<string, UIPropertyType>,\n transparency: UITransparencyMode = UITransparencyMode.BLEND,\n ): boolean {\n if (this.source !== source || this.transparency !== transparency) {\n return false;\n }\n\n return arePropertiesCompatible(this.properties, properties);\n }\n\n public arePropertiesCompatible(\n properties: Record<string, UIPropertyType>,\n ): boolean {\n return arePropertiesCompatible(this.properties, properties);\n }\n\n public extractInstanceData(handler: number): GenericPlaneData {\n return {\n source: this.source,\n properties: this.extractProperties(handler),\n transparency: this.transparency,\n transform: this.extractTransform(handler),\n visibility: this.extractVisibility(handler),\n };\n }\n\n public extractProperties(handler: number): Record<string, UIPropertyType> {\n const index = this.resolveIndex(handler);\n const result: Record<string, UIPropertyType> = {};\n\n for (const [name, value] of Object.entries(this.uniformProperties)) {\n result[name] = value;\n }\n\n for (const [name, referenceValue] of Object.entries(\n this.varyingProperties,\n )) {\n const attribute = this.propertyBuffers.get(\n name,\n ) as InstancedBufferAttribute;\n const array = attribute.array as Float32Array;\n const offset = index * attribute.itemSize;\n result[name] = reconstructValue(referenceValue, array, offset);\n }\n\n return result;\n }\n\n public extractTransform(handler: number): Matrix4 {\n const index = this.resolveIndex(handler);\n const attribute = this.propertyBuffers.get(\n \"instanceTransform\",\n ) as InstancedBufferAttribute;\n const array = attribute.array as Float32Array;\n\n const matrix = new Matrix4();\n matrix.fromArray(array, index * 16);\n return matrix;\n }\n\n public extractVisibility(handler: number): boolean {\n const index = this.resolveIndex(handler);\n const attribute = this.propertyBuffers.get(\n \"instanceVisibility\",\n ) as InstancedBufferAttribute;\n const array = attribute.array as Float32Array;\n return array[index] >= 0.5;\n }\n\n public destroy(): void {\n this.instancedGeometry.dispose();\n this.shaderMaterial.dispose();\n this.propertyBuffers.clear();\n this.handlerToIndex.clear();\n }\n\n private initializeInstanceDefaults(index: number): void {\n const visibilityAttr = this.propertyBuffers.get(\n \"instanceVisibility\",\n ) as InstancedBufferAttribute;\n const transformAttr = this.propertyBuffers.get(\n \"instanceTransform\",\n ) as InstancedBufferAttribute;\n\n writeInstanceDefaults(\n visibilityAttr.array as Float32Array,\n transformAttr.array as Float32Array,\n index,\n );\n\n visibilityAttr.needsUpdate = true;\n transformAttr.needsUpdate = true;\n }\n\n private ensureCapacity(requiredCapacity: number): void {\n if (requiredCapacity <= this.capacity) {\n return;\n }\n\n const newCapacity =\n Math.ceil(requiredCapacity / CAPACITY_STEP) * CAPACITY_STEP;\n\n for (const [name, oldAttribute] of this.propertyBuffers.entries()) {\n const itemSize = oldAttribute.itemSize;\n const newArray = new Float32Array(newCapacity * itemSize);\n newArray.set(oldAttribute.array as Float32Array);\n\n const newAttribute = new InstancedBufferAttribute(newArray, itemSize);\n this.instancedGeometry.setAttribute(`a_${name}`, newAttribute);\n this.propertyBuffers.set(name, newAttribute);\n }\n\n this.capacity = newCapacity;\n }\n\n private moveInstanceData(sourceIndex: number, targetIndex: number): void {\n for (const attribute of this.propertyBuffers.values()) {\n const array = attribute.array as Float32Array;\n const itemSize = attribute.itemSize;\n\n const srcOffset = sourceIndex * itemSize;\n const dstOffset = targetIndex * itemSize;\n\n for (let i = 0; i < itemSize; i++) {\n array[dstOffset + i] = array[srcOffset + i];\n }\n\n attribute.needsUpdate = true;\n }\n }\n\n private updateIndicesAfterMove(oldIndex: number, newIndex: number): void {\n for (const [handler, index] of this.handlerToIndex) {\n if (index === oldIndex) {\n this.handlerToIndex.set(handler, newIndex);\n break;\n }\n }\n }\n\n private resolveIndex(handler: number): number {\n const index = this.handlerToIndex.get(handler);\n if (index === undefined) {\n throw new Error(\n `UIGenericInstancedPlane.resolveIndex.handler: invalid handler`,\n );\n }\n return index;\n }\n\n private resolveAttribute(name: string): InstancedBufferAttribute {\n const attribute = this.propertyBuffers.get(name);\n if (attribute === undefined) {\n throw new Error(\n `UIGenericInstancedPlane.resolveAttribute.name: unknown attribute`,\n );\n }\n return attribute;\n }\n}\n","import { Matrix4, PlaneGeometry, ShaderMaterial } from \"three\";\n\nimport { UIColor } from \"../color/UIColor\";\nimport { UITransparencyMode } from \"../UITransparencyMode\";\nimport type { UIPropertyType } from \"./shared\";\nimport {\n buildGenericPlaneFragmentShader,\n DEFAULT_ALPHA_TEST,\n resolveGLSLTypeInfo,\n} from \"./shared\";\n\nexport const PLANE_GEOMETRY = new PlaneGeometry(1, 1).translate(0.5, 0.5, 0);\n\nexport function buildGenericPlaneMaterial(\n source: string,\n properties: Record<string, UIPropertyType>,\n transparency: UITransparencyMode,\n): ShaderMaterial {\n const uniforms: Record<string, { value: unknown }> = {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n p_transform: { value: new Matrix4() },\n };\n\n const uniformDeclarations: string[] = [];\n\n for (const [name, value] of Object.entries(properties)) {\n const info = resolveGLSLTypeInfo(value);\n uniforms[`p_${name}`] = {\n value: value instanceof UIColor ? value.toGLSLColor() : value,\n };\n uniformDeclarations.push(`uniform ${info.glslType} p_${name};`);\n }\n\n const vertexShader = `\n // Default uniform declarations\n uniform mat4 p_transform;\n\n // Custom uniform declarations\n ${uniformDeclarations.join(\"\\n\")}\n\n // Default varying declarations\n varying vec3 p_position;\n varying vec2 p_uv;\n\n void main() {\n p_position = position;\n p_uv = uv;\n\n gl_Position = projectionMatrix * p_transform * vec4(position, 1.0);\n }\n `;\n\n const fragmentShader = buildGenericPlaneFragmentShader(\n uniformDeclarations,\n [],\n source,\n );\n\n const material = new ShaderMaterial({\n uniforms,\n vertexShader,\n fragmentShader,\n transparent: transparency === UITransparencyMode.BLEND,\n alphaTest:\n transparency === UITransparencyMode.CLIP ? DEFAULT_ALPHA_TEST : 0.0,\n alphaHash: transparency === UITransparencyMode.HASH,\n depthWrite: transparency !== UITransparencyMode.BLEND,\n depthTest: true,\n });\n\n return material;\n}\n","import type { ShaderMaterial, Vector4 } from \"three\";\nimport { Matrix4, Mesh } from \"three\";\n\nimport { UIColor } from \"../color/UIColor\";\nimport { UITransparencyMode } from \"../UITransparencyMode\";\nimport type { GenericPlaneData, UIPropertyType } from \"./shared\";\nimport {\n arePropertiesCompatible,\n DEFAULT_ALPHA_TEST,\n resolveUniform,\n} from \"./shared\";\nimport {\n buildGenericPlaneMaterial,\n PLANE_GEOMETRY,\n} from \"./UIGenericPlane.Internal\";\n\nexport class UIGenericPlane extends Mesh {\n private readonly shaderMaterial: ShaderMaterial;\n private readonly propertiesInternal: Record<string, UIPropertyType>;\n private readonly transformInternal = new Matrix4().identity();\n private transparencyInternal: UITransparencyMode;\n\n constructor(\n public readonly source: string,\n properties: Record<string, UIPropertyType>,\n transparency: UITransparencyMode,\n ) {\n const shaderMaterial = buildGenericPlaneMaterial(\n source,\n properties,\n transparency,\n );\n super(PLANE_GEOMETRY, shaderMaterial);\n\n this.frustumCulled = false;\n this.matrixAutoUpdate = false;\n this.matrixWorldAutoUpdate = false;\n\n this.shaderMaterial = shaderMaterial;\n this.propertiesInternal = { ...properties };\n this.transparencyInternal = transparency;\n }\n\n public get properties(): Record<string, UIPropertyType> {\n return { ...this.propertiesInternal };\n }\n\n public get transform(): Matrix4 {\n return this.transformInternal;\n }\n\n public get visibility(): boolean {\n return this.visible;\n }\n\n public get transparency(): UITransparencyMode {\n return this.transparencyInternal;\n }\n\n public setProperties(properties: Record<string, UIPropertyType>): void {\n for (const [name, value] of Object.entries(properties)) {\n const uniform = resolveUniform(name, this.shaderMaterial);\n if (value instanceof UIColor) {\n value.toGLSLColor(uniform.value as Vector4);\n } else {\n uniform.value = value;\n }\n this.propertiesInternal[name] = value;\n }\n this.shaderMaterial.uniformsNeedUpdate = true;\n }\n\n public setTransform(transform: Matrix4): void {\n const uniform = resolveUniform(\"transform\", this.shaderMaterial);\n (uniform.value as Matrix4).copy(transform);\n this.shaderMaterial.uniformsNeedUpdate = true;\n this.transformInternal.copy(transform);\n }\n\n public setVisibility(visibility: boolean): void {\n this.visible = visibility;\n }\n\n public setTransparency(transparency: UITransparencyMode): void {\n if (this.transparencyInternal !== transparency) {\n this.shaderMaterial.transparent =\n transparency === UITransparencyMode.BLEND;\n this.shaderMaterial.alphaTest =\n transparency === UITransparencyMode.CLIP ? DEFAULT_ALPHA_TEST : 0.0;\n this.shaderMaterial.alphaHash = transparency === UITransparencyMode.HASH;\n this.shaderMaterial.depthWrite =\n transparency !== UITransparencyMode.BLEND;\n this.shaderMaterial.needsUpdate = true;\n\n this.transparencyInternal = transparency;\n }\n }\n\n public extractInstanceData(): GenericPlaneData {\n return {\n source: this.source,\n properties: this.properties,\n transparency: this.transparencyInternal,\n transform: this.transformInternal.clone(),\n visibility: this.visible,\n };\n }\n\n public isCompatible(\n source: string,\n properties: Record<string, UIPropertyType>,\n transparency: UITransparencyMode,\n ): boolean {\n if (this.transparencyInternal !== transparency || this.source !== source) {\n return false;\n }\n\n return arePropertiesCompatible(this.propertiesInternal, properties);\n }\n\n public arePropertiesCompatible(\n properties: Record<string, UIPropertyType>,\n ): boolean {\n return arePropertiesCompatible(this.propertiesInternal, properties);\n }\n\n public destroy(): void {\n this.shaderMaterial.dispose();\n }\n}\n","import type { Matrix4, Scene } from \"three\";\nimport type { UITransparencyMode } from \"../UITransparencyMode\";\nimport type { GenericPlaneData, UIPropertyType } from \"./shared\";\nimport { UIGenericInstancedPlane } from \"./UIGenericInstancedPlane\";\nimport { UIGenericPlane } from \"./UIGenericPlane\";\nimport type { GenericPlaneDescriptor } from \"./UIGenericPlaneRegistry.Internal\";\n\nexport class UIPlaneRegistry {\n private readonly descriptors = new Map<number, GenericPlaneDescriptor>();\n private lastHandler = 0;\n\n constructor(private readonly scene: Scene) {}\n\n public create(\n source: string,\n properties: Record<string, UIPropertyType>,\n transparency: UITransparencyMode,\n ): number {\n const handler = this.lastHandler++;\n\n const descriptor: GenericPlaneDescriptor = {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n plane: undefined!,\n };\n this.descriptors.set(handler, descriptor);\n\n this.placeInstance(descriptor, {\n source,\n properties,\n transparency,\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n transform: undefined!,\n visibility: true,\n });\n\n return handler;\n }\n\n public destroy(handler: number): void {\n const descriptor = this.resolveDescriptor(handler);\n this.descriptors.delete(handler);\n this.removeFromCurrentPlane(descriptor);\n }\n\n public setTransform(handler: number, transform: Matrix4): void {\n const descriptor = this.resolveDescriptor(handler);\n\n if (\n descriptor.plane instanceof UIGenericInstancedPlane &&\n descriptor.instanceHandler !== undefined\n ) {\n descriptor.plane.setTransform(descriptor.instanceHandler, transform);\n } else if (descriptor.plane instanceof UIGenericPlane) {\n descriptor.plane.setTransform(transform);\n }\n }\n\n public setProperties(\n handler: number,\n properties: Record<string, UIPropertyType>,\n ): void {\n const descriptor = this.resolveDescriptor(handler);\n\n const currentData = this.extractInstanceData(descriptor);\n const newProperties = { ...currentData.properties, ...properties };\n\n const needsRelocation = this.checkNeedsRelocation(\n descriptor,\n currentData,\n newProperties,\n currentData.transparency,\n );\n\n if (needsRelocation) {\n this.removeFromCurrentPlane(descriptor);\n this.placeInstance(descriptor, {\n ...currentData,\n properties: newProperties,\n });\n } else {\n this.updatePropertiesInPlace(descriptor, properties);\n }\n }\n\n public setVisibility(handler: number, visible: boolean): void {\n const descriptor = this.resolveDescriptor(handler);\n\n if (\n descriptor.plane instanceof UIGenericInstancedPlane &&\n descriptor.instanceHandler !== undefined\n ) {\n descriptor.plane.setVisibility(descriptor.instanceHandler, visible);\n } else if (descriptor.plane instanceof UIGenericPlane) {\n descriptor.plane.setVisibility(visible);\n }\n }\n\n public setTransparency(\n handler: number,\n transparency: UITransparencyMode,\n ): void {\n const descriptor = this.resolveDescriptor(handler);\n const currentData = this.extractInstanceData(descriptor);\n\n if (currentData.transparency === transparency) {\n return;\n }\n\n const needsRelocation = this.checkNeedsRelocation(\n descriptor,\n currentData,\n currentData.properties,\n transparency,\n );\n\n if (needsRelocation) {\n this.removeFromCurrentPlane(descriptor);\n this.placeInstance(descriptor, {\n ...currentData,\n transparency,\n });\n } else if (descriptor.plane instanceof UIGenericPlane) {\n descriptor.plane.setTransparency(transparency);\n }\n }\n\n private placeInstance(\n descriptor: GenericPlaneDescriptor,\n data: GenericPlaneData,\n ): void {\n const { source, properties, transparency, transform, visibility } = data;\n\n const compatibleInstanced = this.findCompatibleInstancedPlane(\n source,\n properties,\n transparency,\n );\n\n if (compatibleInstanced) {\n this.attachToInstancedPlane(\n descriptor,\n compatibleInstanced,\n properties,\n transform,\n visibility,\n );\n return;\n }\n\n const promotable = this.findCompatibleSinglePlane(\n source,\n properties,\n transparency,\n descriptor,\n );\n\n if (promotable) {\n const instancedPlane = this.promoteToInstanced(promotable, properties);\n this.attachToInstancedPlane(\n descriptor,\n instancedPlane,\n properties,\n transform,\n visibility,\n );\n return;\n }\n\n this.createSinglePlane(\n descriptor,\n source,\n properties,\n transparency,\n transform,\n visibility,\n );\n }\n\n private extractInstanceData(\n descriptor: GenericPlaneDescriptor,\n ): GenericPlaneData {\n if (\n descriptor.plane instanceof UIGenericInstancedPlane &&\n descriptor.instanceHandler !== undefined\n ) {\n return descriptor.plane.extractInstanceData(descriptor.instanceHandler);\n }\n\n return (descriptor.plane as UIGenericPlane).extractInstanceData();\n }\n\n private removeFromCurrentPlane(descriptor: GenericPlaneDescriptor): void {\n if (\n descriptor.plane instanceof UIGenericInstancedPlane &&\n descriptor.instanceHandler !== undefined\n ) {\n const instancedPlane = descriptor.plane;\n instancedPlane.destroyInstance(descriptor.instanceHandler);\n\n if (instancedPlane.instanceCount === 0) {\n this.scene.remove(instancedPlane);\n instancedPlane.destroy();\n } else if (instancedPlane.instanceCount === 1) {\n this.demoteToSingle(instancedPlane, descriptor);\n }\n } else if (descriptor.plane instanceof UIGenericPlane) {\n this.scene.remove(descriptor.plane);\n descriptor.plane.destroy();\n }\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n descriptor.plane = undefined!;\n delete descriptor.instanceHandler;\n }\n\n private updatePropertiesInPlace(\n descriptor: GenericPlaneDescriptor,\n properties: Record<string, UIPropertyType>,\n ): void {\n if (\n descriptor.plane instanceof UIGenericInstancedPlane &&\n descriptor.instanceHandler !== undefined\n ) {\n descriptor.plane.setProperties(descriptor.instanceHandler, properties);\n } else if (descriptor.plane instanceof UIGenericPlane) {\n descriptor.plane.setProperties(properties);\n }\n }\n\n private checkNeedsRelocation(\n descriptor: GenericPlaneDescriptor,\n currentData: GenericPlaneData,\n newProperties: Record<string, UIPropertyType>,\n newTransparency: UITransparencyMode,\n ): boolean {\n const isInstanced = descriptor.plane instanceof UIGenericInstancedPlane;\n\n if (isInstanced) {\n if (currentData.transparency !== newTransparency) {\n return true;\n }\n\n return !descriptor.plane.arePropertiesCompatible(newProperties);\n }\n\n const compatibleInstanced = this.findCompatibleInstancedPlane(\n currentData.source,\n newProperties,\n newTransparency,\n );\n if (compatibleInstanced) {\n return true;\n }\n\n const promotable = this.findCompatibleSinglePlane(\n currentData.source,\n newProperties,\n newTransparency,\n descriptor,\n );\n if (promotable) {\n return true;\n }\n\n return false;\n }\n\n private attachToInstancedPlane(\n descriptor: GenericPlaneDescriptor,\n instancedPlane: UIGenericInstancedPlane,\n properties: Record<string, UIPropertyType>,\n transform: Matrix4 | undefined,\n visibility: boolean,\n ): void {\n const instanceHandler = instancedPlane.createInstance();\n instancedPlane.setProperties(instanceHandler, properties);\n if (transform) {\n instancedPlane.setTransform(instanceHandler, transform);\n }\n instancedPlane.setVisibility(instanceHandler, visibility);\n\n descriptor.plane = instancedPlane;\n descriptor.instanceHandler = instanceHandler;\n }\n\n private createSinglePlane(\n descriptor: GenericPlaneDescriptor,\n source: string,\n properties: Record<string, UIPropertyType>,\n transparency: UITransparencyMode,\n transform: Matrix4 | undefined,\n visibility: boolean,\n ): void {\n const singlePlane = new UIGenericPlane(source, properties, transparency);\n singlePlane.setProperties(properties);\n if (transform) {\n singlePlane.setTransform(transform);\n }\n singlePlane.setVisibility(visibility);\n this.scene.add(singlePlane);\n\n descriptor.plane = singlePlane;\n delete descriptor.instanceHandler;\n }\n\n private findCompatibleSinglePlane(\n source: string,\n properties: Record<string, UIPropertyType>,\n transparency: UITransparencyMode,\n excludeDescriptor?: GenericPlaneDescriptor,\n ): GenericPlaneDescriptor | undefined {\n for (const descriptor of this.descriptors.values()) {\n if (descriptor === excludeDescriptor) {\n continue;\n }\n\n if (\n descriptor.plane instanceof UIGenericPlane &&\n descriptor.plane.isCompatible(source, properties, transparency)\n ) {\n return descriptor;\n }\n }\n return undefined;\n }\n\n private findCompatibleInstancedPlane(\n source: string,\n properties: Record<string, UIPropertyType>,\n transparency: UITransparencyMode,\n ): UIGenericInstancedPlane | undefined {\n for (const descriptor of this.descriptors.values()) {\n if (\n descriptor.plane instanceof UIGenericInstancedPlane &&\n descriptor.plane.isCompatible(source, properties, transparency)\n ) {\n return descriptor.plane;\n }\n }\n return undefined;\n }\n\n private promoteToInstanced(\n promotableDescriptor: GenericPlaneDescriptor,\n templateProperties: Record<string, UIPropertyType>,\n ): UIGenericInstancedPlane {\n const oldPlane = promotableDescriptor.plane as UIGenericPlane;\n const oldData = oldPlane.extractInstanceData();\n\n const instancedPlane = new UIGenericInstancedPlane(\n oldData.source,\n templateProperties,\n oldData.transparency,\n );\n\n const oldInstanceHandler = instancedPlane.createInstance();\n instancedPlane.setProperties(oldInstanceHandler, oldData.properties);\n instancedPlane.setTransform(oldInstanceHandler, oldData.transform);\n instancedPlane.setVisibility(oldInstanceHandler, oldData.visibility);\n\n promotableDescriptor.plane = instancedPlane;\n promotableDescriptor.instanceHandler = oldInstanceHandler;\n\n this.scene.remove(oldPlane);\n oldPlane.destroy();\n this.scene.add(instancedPlane);\n\n return instancedPlane;\n }\n\n private demoteToSingle(\n instancedPlane: UIGenericInstancedPlane,\n removedDescriptor: GenericPlaneDescriptor,\n ): void {\n let remainingDescriptor: GenericPlaneDescriptor | undefined;\n\n for (const descriptor of this.descriptors.values()) {\n if (\n descriptor !== removedDescriptor &&\n descriptor.plane === instancedPlane &&\n descriptor.instanceHandler !== undefined\n ) {\n remainingDescriptor = descriptor;\n break;\n }\n }\n\n if (!remainingDescriptor) {\n return;\n }\n\n const data = instancedPlane.extractInstanceData(\n remainingDescriptor.instanceHandler as number,\n );\n\n const singlePlane = new UIGenericPlane(\n data.source,\n data.properties,\n data.transparency,\n );\n singlePlane.setProperties(data.properties);\n singlePlane.setTransform(data.transform);\n singlePlane.setVisibility(data.visibility);\n\n this.scene.remove(instancedPlane);\n instancedPlane.destroy();\n this.scene.add(singlePlane);\n\n remainingDescriptor.plane = singlePlane;\n delete remainingDescriptor.instanceHandler;\n }\n\n private resolveDescriptor(handler: number): GenericPlaneDescriptor {\n const descriptor = this.descriptors.get(handler);\n if (!descriptor) {\n throw new Error(\n `UIGenericPlaneRegistry.resolveDescriptor.handler: descriptor not found`,\n );\n }\n return descriptor;\n }\n}\n","import type { Matrix4, Object3D, WebGLRenderer } from \"three\";\nimport { Color, OrthographicCamera, Scene } from \"three\";\nimport type { UIPropertyType } from \"../miscellaneous/generic-plane/shared\";\nimport { UIPlaneRegistry } from \"../miscellaneous/generic-plane/UIGenericPlaneRegistry\";\nimport type { UITransparencyMode } from \"../miscellaneous/UITransparencyMode\";\n\nlet originalClearColor = new Color();\nlet originalClearAlpha = 0;\nlet originalAutoClear = false;\nlet originalAutoClearColor = false;\nlet originalAutoClearDepth = false;\nlet originalAutoClearStencil = false;\n\nexport class UISceneWrapper {\n private readonly scene = new Scene();\n private readonly camera: OrthographicCamera;\n private readonly registry = new UIPlaneRegistry(this.scene);\n\n constructor(width: number, height: number) {\n this.camera = new OrthographicCamera(0, width, height, 0, -1024, 1024);\n }\n\n public createPlane(\n source: string,\n properties: Record<string, UIPropertyType>,\n transparency: UITransparencyMode,\n ): number {\n return this.registry.create(source, properties, transparency);\n }\n\n public destroyPlane(handler: number): void {\n this.registry.destroy(handler);\n }\n\n public setTransform(handler: number, transform: Matrix4): void {\n this.registry.setTransform(handler, transform);\n }\n\n public setProperties(\n handler: number,\n properties: Record<string, UIPropertyType>,\n ): void {\n this.registry.setProperties(handler, properties);\n }\n\n public setVisibility(handler: number, visible: boolean): void {\n this.registry.setVisibility(handler, visible);\n }\n\n public setTransparency(\n handler: number,\n transparency: UITransparencyMode,\n ): void {\n this.registry.setTransparency(handler, transparency);\n }\n\n public insertCustomObject(object: Object3D): this {\n this.scene.add(object);\n return this;\n }\n\n public removeCustomObject(object: Object3D): this {\n this.scene.remove(object);\n return this;\n }\n\n public resize(width: number, height: number): this {\n this.camera.right = width;\n this.camera.top = height;\n this.camera.updateProjectionMatrix();\n return this;\n }\n\n public render(renderer: WebGLRenderer): this {\n originalClearColor = renderer.getClearColor(originalClearColor);\n originalClearAlpha = renderer.getClearAlpha();\n originalAutoClear = renderer.autoClear;\n originalAutoClearColor = renderer.autoClearColor;\n originalAutoClearDepth = renderer.autoClearDepth;\n originalAutoClearStencil = renderer.autoClearStencil;\n\n renderer.autoClear = false;\n renderer.autoClearColor = false;\n renderer.autoClearDepth = false;\n renderer.autoClearStencil = false;\n renderer.setClearColor(0x000000, 1);\n\n renderer.clear(false, true, true);\n renderer.render(this.scene, this.camera);\n\n renderer.setClearColor(originalClearColor);\n renderer.setClearAlpha(originalClearAlpha);\n renderer.autoClear = originalAutoClear;\n renderer.autoClearColor = originalAutoClearColor;\n renderer.autoClearDepth = originalAutoClearDepth;\n renderer.autoClearStencil = originalAutoClearStencil;\n\n return this;\n }\n}\n","import { assertValidNumber } from \"./asserts\";\n\n/** Linear expression for constraint equations */\nexport class UIExpression {\n /** Constant term */\n public constant: number;\n /** Variable coefficients */\n private readonly terms: Map<number, number>;\n\n /**\n * @param constant Constant term\n * @param terms Variable-coefficient pairs\n */\n constructor(constant = 0, terms?: [number, number][]) {\n assertValidNumber(constant, \"UIExpression.constructor.constant\");\n this.constant = constant;\n this.terms = terms ? new Map(terms) : new Map();\n\n if (terms) {\n for (let i = 0; i < terms.length; i++) {\n assertValidNumber(\n terms[i][1],\n `UIExpression.constructor.terms[${i}][1]`,\n );\n }\n }\n }\n\n /**\n * Creates expression representing a + b.\n * @param a First expression\n * @param b Second expression\n * @returns Sum of expressions\n */\n public static plus(a: UIExpression, b: UIExpression): UIExpression {\n const result = new UIExpression(\n a.constant + b.constant,\n Array.from(a.terms.entries()),\n );\n for (const [variableIndex, coefficient] of b.terms) {\n result.plus(variableIndex, coefficient);\n }\n return result;\n }\n\n /**\n * Creates expression representing a - b.\n * @param a First expression\n * @param b Second expression\n * @returns Difference of expressions\n */\n public static minus(a: UIExpression, b: UIExpression): UIExpression {\n const result = new UIExpression(\n a.constant - b.constant,\n Array.from(a.terms.entries()),\n );\n for (const [variableIndex, coefficient] of b.terms) {\n result.minus(variableIndex, coefficient);\n }\n return result;\n }\n\n /**\n * Adds variable term to expression.\n * @param variableIndex Variable descriptor\n * @param coefficient Coefficient to add\n * @returns This instance for chaining\n */\n public plus(variableIndex: number, coefficient: number): this {\n assertValidNumber(coefficient, \"UIExpression.plus.coefficient\");\n this.terms.set(\n variableIndex,\n (this.terms.get(variableIndex) ?? 0) + coefficient,\n );\n return this;\n }\n\n /**\n * Subtracts variable term from expression.\n * @param variableIndex Variable descriptor\n * @param coefficient Coefficient to subtract\n * @returns This instance for chaining\n */\n public minus(variableIndex: number, coefficient: number): this {\n return this.plus(variableIndex, -coefficient);\n }\n\n /**\n * Multiplies all terms by scalar.\n * @param value Scalar multiplier\n * @returns This instance for chaining\n */\n public multiply(value: number): this {\n assertValidNumber(value, \"UIExpression.multiply.value\");\n this.constant *= value;\n for (const [variableIndex, coefficient] of this.terms) {\n this.terms.set(variableIndex, coefficient * value);\n }\n return this;\n }\n\n /**\n * Divides all terms by scalar.\n * @param value Scalar divisor\n * @returns This instance for chaining\n */\n public divide(value: number): this {\n assertValidNumber(value, \"UIExpression.divide.value\");\n if (value === 0) {\n throw new Error(\"UIExpression.divide.value: cannot divide by zero\");\n }\n return this.multiply(1 / value);\n }\n\n /**\n * Checks if expression contains variable term.\n * @param variableIndex Variable descriptor\n * @returns True if variable has term\n */\n public hasTerm(variableIndex: number): boolean {\n return this.terms.has(variableIndex);\n }\n\n /**\n * Copies from another expression.\n * @param expression Source expression\n * @returns This instance for chaining\n */\n public copy(expression: UIExpression): this {\n this.constant = expression.constant;\n this.terms.clear();\n for (const [variableIndex, coefficient] of expression.terms) {\n this.terms.set(variableIndex, coefficient);\n }\n return this;\n }\n\n /**\n * Creates independent copy.\n * @returns New expression with same content\n */\n public clone(): UIExpression {\n return new UIExpression(this.constant, Array.from(this.terms.entries()));\n }\n\n /**\n * Prepares terms for solver.\n * @returns Variable-coefficient pairs\n * @internal\n */\n public prepareTerms(): [number, number][] {\n return Array.from(this.terms.entries());\n }\n}\n","import { Operator } from \"@lume/kiwi\";\n\n/** Relational operators for constraints */\nexport enum UIRelation {\n /** Equality: LHS = RHS */\n EQUAL = 0,\n /** Less than or equal: LHS ≤ RHS */\n LESS_THAN = 1,\n /** Greater than or equal: LHS ≥ RHS */\n GREATER_THAN = 2,\n}\n\n/**\n * Converts relation to solver operator.\n * @param relation Relation type\n * @returns Solver operator\n * @throws If relation is invalid\n */\nexport function convertRelation(relation: UIRelation): Operator {\n switch (relation) {\n case UIRelation.EQUAL:\n return Operator.Eq;\n case UIRelation.LESS_THAN:\n return Operator.Le;\n case UIRelation.GREATER_THAN:\n return Operator.Ge;\n default:\n throw new Error(`convertRelation: invalid relation`);\n }\n}\n\n/**\n * Resolves optional relation.\n * @param relation Relation to resolve\n * @returns Relation or EQUAL if undefined\n */\nexport function resolveRelation(relation?: UIRelation): UIRelation {\n return relation ?? UIRelation.EQUAL;\n}\n","import { UIMode } from \"../../miscellaneous/UIMode\";\nimport type { UIOrientation } from \"../../miscellaneous/UIOrientation\";\n\n/** Layer lifecycle and state events */\nexport enum UILayerEvent {\n /** Fired when orientation changes */\n ORIENTATION_CHANGED = \"orientation_changed\",\n /** Fired when mode changes */\n MODE_CHANGED = \"mode_changed\",\n /** Fired during rendering */\n RENDERING = \"rendering\",\n}\n\n/** Layer visibility and interactivity state */\nexport type UILayerMode = UIMode.HIDDEN | UIMode.VISIBLE | UIMode.INTERACTIVE;\n\n/** Layer orientation state */\nexport type UILayerOrientation =\n | UIOrientation.VERTICAL\n | UIOrientation.HORIZONTAL;\n\n/** Configuration options for UILayer */\nexport interface UILayerOptions {\n /** Initial width */\n width: number;\n /** Initial height */\n height: number;\n /** Optional layer name */\n name: string;\n /** Initial visibility and interactivity mode */\n mode: UILayerMode;\n}\n\nexport const LAYER_DEFAULT_SIZE = 1024;\nexport const LAYER_DEFAULT_NAME = \"\";\nexport const LAYER_DEFAULT_MODE: UILayerMode = UIMode.VISIBLE;\n","import { Constraint, Expression, Solver, Variable } from \"@lume/kiwi\";\nimport { UIExpression } from \"../miscellaneous/UIExpression\";\nimport { convertPriority, UIPriority } from \"../miscellaneous/UIPriority\";\nimport { convertRelation, UIRelation } from \"../miscellaneous/UIRelation\";\nimport type {\n ConstraintDescription,\n UISolverWrapperInterface,\n VariableDescription,\n} from \"./UISolverWrapper.Internal\";\n\n/**\n * Wrapper around the Kiwi constraint solver providing enhanced UI-specific functionality.\n *\n * UISolverWrapper abstracts the Kiwi (Cassowary) constraint solver to provide a more\n * UI-friendly interface with additional features like dynamic constraint modification,\n * required variables (P0 priority), partial constraint updates, and automatic solver\n * recovery. It manages variables and constraints through index-based references,\n * allowing for easy tracking and modification of layout constraints.\n *\n * Key features:\n * - Index-based variable and constraint management\n * - Required variables with P0 priority (always satisfied)\n * - Dynamic constraint modification without full rebuilds\n * - Automatic solver recovery on constraint conflicts\n * - Lazy evaluation with recalculation flags\n *\n * @see {@link UIExpression} - Expression system for constraint definitions\n * @see {@link UIPriority} - Priority levels for variables and constraints\n * @see {@link UIRelation} - Relational operators for constraints\n */\nexport class UISolverWrapper implements UISolverWrapperInterface {\n /** @internal */\n public dirty = false;\n\n /** The underlying Kiwi solver instance, undefined when solver needs rebuilding. */\n private solver? = new Solver();\n /** Flag indicating whether variable values need recalculation. */\n private recalculationRequired = false;\n\n /** Map of variable indices to their descriptions. */\n private readonly variables = new Map<number, VariableDescription>();\n /** Counter for generating unique variable indices. */\n private lastVariableIndex = 0;\n\n /** Map of constraint indices to their descriptions. */\n private readonly constraints = new Map<number, ConstraintDescription>();\n /** Counter for generating unique constraint indices. */\n private lastConstraintIndex = 0;\n\n /**\n * Creates a new solver variable with the specified value and priority.\n *\n * Variables with P0 priority are treated as required (must be satisfied exactly)\n * and are implemented using equality constraints. Other priorities use edit\n * variables that can be adjusted by the solver.\n *\n * @param value - Initial value for the variable\n * @param priority - Priority level for constraint solving\n * @returns Unique index identifier for the created variable\n */\n public createVariable(value: number, priority: UIPriority): number {\n const index = this.lastVariableIndex++;\n const variable = new Variable();\n\n if (priority === UIPriority.P0) {\n const description: VariableDescription = { variable, priority, value };\n this.variables.set(index, description);\n\n description.constraint = this.buildConstraint(\n new UIExpression(0, [[index, 1]]),\n new UIExpression(value),\n UIRelation.EQUAL,\n priority,\n );\n try {\n this.solver?.addConstraint(description.constraint);\n } catch {\n this.solver = undefined;\n }\n } else {\n this.variables.set(index, { variable, priority, value });\n\n try {\n this.solver?.addEditVariable(variable, convertPriority(priority));\n this.solver?.suggestValue(variable, value);\n } catch {\n this.solver = undefined;\n }\n }\n\n this.recalculationRequired = true;\n this.dirty = true;\n return index;\n }\n\n /**\n * Removes a variable from the solver system.\n *\n * The variable must not be referenced by any existing constraints.\n * Cleans up both the variable itself and any associated required constraint.\n *\n * @param index - Index of the variable to remove\n * @throws Will throw an error if the variable doesn't exist or is still in use\n */\n public removeVariable(index: number): void {\n const description = this.variables.get(index);\n if (description === undefined) {\n throw new Error(\n `UISolverWrapper.removeVariable.index: variable does not exist`,\n );\n }\n\n for (const cDescription of this.constraints.values()) {\n if (cDescription.lhs.hasTerm(index) || cDescription.rhs.hasTerm(index)) {\n throw new Error(\n `UISolverWrapper.removeVariable.index: variable is used in constraint`,\n );\n }\n }\n\n try {\n description.constraint\n ? this.solver?.removeConstraint(description.constraint)\n : this.solver?.removeEditVariable(description.variable);\n } catch {\n this.solver = undefined;\n }\n\n this.variables.delete(index);\n this.recalculationRequired = true;\n this.dirty = true;\n }\n\n /**\n * Suggests a new value for an existing variable.\n *\n * For P0 priority variables, rebuilds the associated constraint.\n * For other priorities, suggests the value to the solver's edit system.\n * Only triggers updates if the value actually changes.\n *\n * @param index - Index of the variable to update\n * @param value - New suggested value\n * @throws Will throw an error if the variable doesn't exist\n */\n public suggestVariableValue(index: number, value: number): void {\n const description = this.variables.get(index);\n if (description === undefined) {\n throw new Error(\n `UISolverWrapper.suggestVariableValue.index: variable does not exist`,\n );\n }\n\n if (description.value !== value) {\n description.value = value;\n\n if (description.constraint) {\n description.constraint = this.rebuildConstraint(\n description.constraint,\n new UIExpression().plus(index, 1),\n new UIExpression(description.value),\n UIRelation.EQUAL,\n description.priority,\n );\n } else {\n this.solver?.suggestValue(description.variable, value);\n }\n\n this.recalculationRequired = true;\n this.dirty = true;\n }\n }\n\n /**\n * Changes the priority of an existing variable.\n *\n * Switching to/from P0 priority changes how the variable is handled:\n * - P0: Creates required constraint (must be satisfied exactly)\n * - Other: Uses edit variable system (can be adjusted by solver)\n *\n * @param index - Index of the variable to modify\n * @param priority - New priority level\n * @throws Will throw an error if the variable doesn't exist\n */\n public setVariablePriority(index: number, priority: UIPriority): void {\n const description = this.variables.get(index);\n if (description === undefined) {\n throw new Error(\n `UISolverWrapper.setVariablePriority.index: variable does not exist`,\n );\n }\n\n if (priority !== description.priority) {\n description.priority = priority;\n\n if (description.priority === UIPriority.P0) {\n const lhs = new UIExpression().plus(index, 1);\n const rhs = new UIExpression(description.value);\n\n description.constraint = this.buildConstraint(\n lhs,\n rhs,\n UIRelation.EQUAL,\n description.priority,\n );\n\n try {\n this.solver?.addConstraint(description.constraint);\n } catch {\n this.solver = undefined;\n }\n } else {\n if (description.constraint) {\n try {\n this.solver?.removeConstraint(description.constraint);\n } catch {\n this.solver = undefined;\n }\n }\n\n description.constraint = undefined;\n this.rebuildVariable(index, description);\n }\n\n this.recalculationRequired = true;\n this.dirty = true;\n }\n }\n\n /**\n * Reads the current solved value of a variable.\n *\n * Triggers solver recalculation if needed and rebuilds the solver\n * if it was invalidated due to constraint conflicts.\n *\n * @param index - Index of the variable to read\n * @returns Current solved value of the variable\n * @throws Will throw an error if the variable doesn't exist\n */\n public readVariableValue(index: number): number {\n const description = this.variables.get(index);\n if (description === undefined) {\n throw new Error(\n `UISolverWrapper.readVariableValue.index: variable does not exist`,\n );\n }\n\n if (this.solver === undefined) {\n this.rebuildSolver();\n }\n\n if (this.recalculationRequired) {\n this.solver?.updateVariables();\n this.recalculationRequired = false;\n }\n\n return description.variable.value();\n }\n\n /**\n * Creates a new constraint between two expressions.\n *\n * Constraints can be enabled or disabled, and all properties can be\n * modified later without recreating the constraint.\n *\n * @param lhs - Left-hand side expression\n * @param rhs - Right-hand side expression\n * @param relation - Relational operator (equal, less than, greater than)\n * @param priority - Priority level for constraint solving\n * @param enabled - Whether the constraint is initially active\n * @returns Unique index identifier for the created constraint\n */\n public createConstraint(\n lhs: UIExpression,\n rhs: UIExpression,\n relation: UIRelation,\n priority: UIPriority,\n enabled: boolean,\n ): number {\n const index = this.lastConstraintIndex++;\n const constraint = this.buildConstraint(lhs, rhs, relation, priority);\n this.constraints.set(index, {\n constraint,\n lhs: lhs.clone(),\n rhs: rhs.clone(),\n priority,\n relation,\n enabled,\n });\n if (enabled) {\n try {\n this.solver?.addConstraint(constraint);\n } catch {\n this.solver = undefined;\n }\n this.recalculationRequired = true;\n this.dirty = true;\n }\n return index;\n }\n\n /**\n * Removes a constraint from the solver system.\n *\n * If the constraint is currently enabled, it will be removed from\n * the active solver before deletion.\n *\n * @param index - Index of the constraint to remove\n * @throws Will throw an error if the constraint doesn't exist\n */\n public removeConstraint(index: number): void {\n const description = this.constraints.get(index);\n if (description === undefined) {\n throw new Error(\n `UISolverWrapper.removeConstraint.index: constraint does not exist`,\n );\n }\n\n if (description.enabled) {\n try {\n this.solver?.removeConstraint(description.constraint);\n } catch {\n this.solver = undefined;\n }\n }\n\n this.constraints.delete(index);\n this.recalculationRequired = true;\n this.dirty = true;\n }\n\n /**\n * Updates the left-hand side expression of an existing constraint.\n *\n * Rebuilds the underlying constraint with the new expression while\n * preserving all other properties.\n *\n * @param index - Index of the constraint to modify\n * @param lhs - New left-hand side expression\n * @throws Will throw an error if the constraint doesn't exist\n */\n public setConstraintLHS(index: number, lhs: UIExpression): void {\n const description = this.constraints.get(index);\n if (description === undefined) {\n throw new Error(\n `UISolverWrapper.setConstraintLHS.index: constraint does not exist`,\n );\n }\n\n description.lhs.copy(lhs);\n this.rebuildConstraintByDescription(description);\n this.recalculationRequired = true;\n this.dirty = true;\n }\n\n /**\n * Updates the right-hand side expression of an existing constraint.\n *\n * Rebuilds the underlying constraint with the new expression while\n * preserving all other properties.\n *\n * @param index - Index of the constraint to modify\n * @param rhs - New right-hand side expression\n * @throws Will throw an error if the constraint doesn't exist\n */\n public setConstraintRHS(index: number, rhs: UIExpression): void {\n const description = this.constraints.get(index);\n if (description === undefined) {\n throw new Error(\n `UISolverWrapper.setConstraintRHS.index: constraint does not exist`,\n );\n }\n\n description.rhs.copy(rhs);\n this.rebuildConstraintByDescription(description);\n this.recalculationRequired = true;\n this.dirty = true;\n }\n\n /**\n * Updates the relational operator of an existing constraint.\n *\n * Changes how the left and right expressions are compared\n * (equal, less than, greater than).\n *\n * @param index - Index of the constraint to modify\n * @param relation - New relational operator\n * @throws Will throw an error if the constraint doesn't exist\n */\n public setConstraintRelation(index: number, relation: UIRelation): void {\n const description = this.constraints.get(index);\n if (description === undefined) {\n throw new Error(\n `UISolverWrapper.setConstraintRelation.index: constraint does not exist`,\n );\n }\n\n if (description.relation !== relation) {\n description.relation = relation;\n this.rebuildConstraintByDescription(description);\n this.recalculationRequired = true;\n this.dirty = true;\n }\n }\n\n /**\n * Updates the priority level of an existing constraint.\n *\n * Higher priority constraints are more likely to be satisfied\n * when conflicts arise.\n *\n * @param index - Index of the constraint to modify\n * @param priority - New priority level\n * @throws Will throw an error if the constraint doesn't exist\n */\n public setConstraintPriority(index: number, priority: UIPriority): void {\n const description = this.constraints.get(index);\n if (description === undefined) {\n throw new Error(\n `UISolverWrapper.setConstraintPriority.index: constraint does not exist`,\n );\n }\n\n if (description.priority !== priority) {\n description.priority = priority;\n this.rebuildConstraintByDescription(description);\n this.recalculationRequired = true;\n this.dirty = true;\n }\n }\n\n /**\n * Enables or disables an existing constraint.\n *\n * Disabled constraints are not considered during solving but\n * remain in the system for potential re-enabling.\n *\n * @param index - Index of the constraint to modify\n * @param enabled - Whether the constraint should be active\n * @throws Will throw an error if the constraint doesn't exist\n */\n public setConstraintEnabled(index: number, enabled: boolean): void {\n const description = this.constraints.get(index);\n if (description === undefined) {\n throw new Error(\n `UISolverWrapper.setConstraintEnabled.index: constraint does not exist`,\n );\n }\n\n if (enabled !== description.enabled) {\n description.enabled = enabled;\n try {\n description.enabled\n ? this.solver?.addConstraint(description.constraint)\n : this.solver?.removeConstraint(description.constraint);\n } catch {\n this.solver = undefined;\n }\n this.recalculationRequired = true;\n this.dirty = true;\n }\n }\n\n /**\n * Rebuilds a variable in the solver system with new properties.\n *\n * Temporarily removes all constraints that reference the variable,\n * updates the variable configuration, then rebuilds and re-adds\n * the dependent constraints.\n */\n private rebuildVariable(\n index: number,\n description: VariableDescription,\n ): void {\n const dependConstraints: ConstraintDescription[] = [];\n\n for (const cDescription of this.constraints.values()) {\n if (cDescription.lhs.hasTerm(index) || cDescription.rhs.hasTerm(index)) {\n try {\n this.solver?.removeConstraint(cDescription.constraint);\n } catch {\n this.solver = undefined;\n }\n dependConstraints.push(cDescription);\n }\n }\n\n this.solver?.removeEditVariable(description.variable);\n this.solver?.addEditVariable(\n description.variable,\n convertPriority(description.priority),\n );\n\n for (const cDescription of dependConstraints) {\n cDescription.constraint = this.buildConstraint(\n cDescription.lhs,\n cDescription.rhs,\n cDescription.relation,\n cDescription.priority,\n );\n }\n\n for (const cDescription of dependConstraints) {\n try {\n this.solver?.addConstraint(cDescription.constraint);\n } catch {\n this.solver = undefined;\n break;\n }\n }\n }\n\n /**\n * Rebuilds a constraint based on its current description.\n *\n * Uses different rebuild strategies depending on whether the\n * constraint is currently enabled.\n */\n private rebuildConstraintByDescription(\n description: ConstraintDescription,\n ): void {\n description.constraint = description.enabled\n ? this.rebuildConstraint(\n description.constraint,\n description.lhs,\n description.rhs,\n description.relation,\n description.priority,\n )\n : this.buildConstraint(\n description.lhs,\n description.rhs,\n description.relation,\n description.priority,\n );\n }\n\n /**\n * Rebuilds a constraint by removing the old one and creating a new one.\n *\n * Safely handles solver state transitions and constraint replacement.\n */\n private rebuildConstraint(\n oldConstraint: Constraint,\n lhs: UIExpression,\n rhs: UIExpression,\n relation: UIRelation,\n priority: UIPriority,\n ): Constraint {\n try {\n this.solver?.removeConstraint(oldConstraint);\n } catch {\n this.solver = undefined;\n }\n\n const constraint = this.buildConstraint(lhs, rhs, relation, priority);\n\n try {\n this.solver?.addConstraint(constraint);\n } catch {\n this.solver = undefined;\n }\n\n return constraint;\n }\n\n /**\n * Creates a new Kiwi constraint from UI expressions and parameters.\n *\n * Converts UI-level expressions and enums to Kiwi-compatible formats.\n */\n private buildConstraint(\n lhs: UIExpression,\n rhs: UIExpression,\n relation: UIRelation,\n priority: UIPriority,\n ): Constraint {\n return new Constraint(\n this.convertExpression(lhs),\n convertRelation(relation),\n this.convertExpression(rhs),\n convertPriority(priority),\n );\n }\n\n /**\n * Converts a UIExpression to a Kiwi Expression.\n *\n * Maps variable indices to their corresponding Kiwi Variable instances\n * and preserves coefficients and constants.\n */\n private convertExpression(expression: UIExpression): Expression {\n return new Expression(\n ...expression\n .prepareTerms()\n .map(([variableIndex, coefficient]): [number, Variable] => {\n const description = this.variables.get(variableIndex);\n if (description === undefined) {\n throw new Error(\n `UISolverWrapper.convertExpression: variable does not exist`,\n );\n }\n return [coefficient, description.variable];\n }),\n expression.constant,\n );\n }\n\n /**\n * Completely rebuilds the solver from scratch.\n *\n * Re-adds all variables and constraints to a fresh solver instance.\n * Used for recovery when the solver enters an invalid state.\n */\n private rebuildSolver(): void {\n if (this.solver) {\n throw new Error(\"UISolverWrapper.rebuildSolver: solver already exists\");\n }\n\n this.solver = new Solver();\n\n for (const description of this.variables.values()) {\n if (description.constraint) {\n this.solver.addConstraint(description.constraint);\n } else {\n this.solver.addEditVariable(\n description.variable,\n convertPriority(description.priority),\n );\n this.solver.suggestValue(description.variable, description.value);\n }\n }\n\n for (const description of this.constraints.values()) {\n if (description.enabled) {\n this.solver.addConstraint(description.constraint);\n }\n }\n\n this.recalculationRequired = true;\n this.dirty = true;\n }\n}\n","import { Eventail } from \"eventail\";\nimport type { WebGLRenderer } from \"three\";\nimport type { UIPlaneElement } from \"../../miscellaneous/shared\";\n\nimport { assertValidPositiveNumber } from \"../../miscellaneous/asserts\";\nimport { isUIModeVisible } from \"../../miscellaneous/UIMode\";\nimport { UIOrientation } from \"../../miscellaneous/UIOrientation\";\nimport { UIPriority } from \"../../miscellaneous/UIPriority\";\nimport { UIInputWrapper } from \"../../wrappers/UIInputWrapper\";\nimport type { UIInputWrapperInterface } from \"../../wrappers/UIInputWrapper.Internal\";\nimport { UISceneWrapper } from \"../../wrappers/UISceneWrapper\";\nimport type { UISceneWrapperInterface } from \"../../wrappers/UISceneWrapper.Internal\";\nimport { UISolverWrapper } from \"../../wrappers/UISolverWrapper\";\nimport type { UISolverWrapperInterface } from \"../../wrappers/UISolverWrapper.Internal\";\nimport type {\n UILayerMode,\n UILayerOptions,\n UILayerOrientation,\n} from \"./UILayer.Internal\";\nimport {\n LAYER_DEFAULT_MODE,\n LAYER_DEFAULT_NAME,\n LAYER_DEFAULT_SIZE,\n UILayerEvent,\n} from \"./UILayer.Internal\";\n\n/** Base layer for UI rendering and layout management */\nexport abstract class UILayer extends Eventail implements UIPlaneElement {\n /** Optional layer name */\n public name = \"\";\n /** Solver variable for x coordinate */\n public readonly xVariable: number;\n /** Solver variable for y coordinate */\n public readonly yVariable: number;\n /** Solver variable for width */\n public readonly wVariable: number;\n /** Solver variable for height */\n public readonly hVariable: number;\n\n protected readonly inputWrapperInternal = new UIInputWrapper();\n private readonly solverWrapperInternal = new UISolverWrapper();\n private readonly sceneWrapperInternal: UISceneWrapper;\n\n private modeInternal: UILayerMode;\n private orientationInternal: UILayerOrientation;\n\n constructor(options: Partial<UILayerOptions>) {\n super();\n\n if (options.width !== undefined) {\n assertValidPositiveNumber(\n options.width,\n \"UILayer.constructor.options.width\",\n );\n }\n\n if (options.height !== undefined) {\n assertValidPositiveNumber(\n options.height,\n \"UILayer.constructor.options.height\",\n );\n }\n\n const width = options.width ?? LAYER_DEFAULT_SIZE;\n const height = options.height ?? LAYER_DEFAULT_SIZE;\n\n this.sceneWrapperInternal = new UISceneWrapper(width, height);\n this.name = options.name ?? LAYER_DEFAULT_NAME;\n this.modeInternal = options.mode ?? LAYER_DEFAULT_MODE;\n this.orientationInternal =\n width > height ? UIOrientation.HORIZONTAL : UIOrientation.VERTICAL;\n\n this.xVariable = this.solverWrapperInternal.createVariable(\n 0,\n UIPriority.P0,\n );\n this.yVariable = this.solverWrapperInternal.createVariable(\n 0,\n UIPriority.P0,\n );\n this.wVariable = this.solverWrapperInternal.createVariable(\n width,\n UIPriority.P0,\n );\n this.hVariable = this.solverWrapperInternal.createVariable(\n height,\n UIPriority.P0,\n );\n }\n\n /** @internal */\n public get sceneWrapper(): UISceneWrapperInterface {\n return this.sceneWrapperInternal;\n }\n\n /** @internal */\n public get solverWrapper(): UISolverWrapperInterface {\n return this.solverWrapperInternal;\n }\n\n /** @internal */\n public get inputWrapper(): UIInputWrapperInterface {\n return this.inputWrapperInternal;\n }\n\n /** X coordinate in world units (always 0 for layers) */\n public get x(): number {\n return this.solverWrapperInternal.readVariableValue(this.xVariable);\n }\n\n /** Y coordinate in world units (always 0 for layers) */\n public get y(): number {\n return this.solverWrapperInternal.readVariableValue(this.yVariable);\n }\n\n /** Layer width in world units */\n public get width(): number {\n return this.solverWrapperInternal.readVariableValue(this.wVariable);\n }\n\n /** Layer height in world units */\n public get height(): number {\n return this.solverWrapperInternal.readVariableValue(this.hVariable);\n }\n\n /** Current visibility and interactivity mode */\n public get mode(): UILayerMode {\n return this.modeInternal;\n }\n\n /** Current orientation based on aspect ratio */\n public get orientation(): UILayerOrientation {\n return this.orientationInternal;\n }\n\n /** Updates visibility and interactivity mode */\n public set mode(value: UILayerMode) {\n if (value !== this.modeInternal) {\n this.modeInternal = value;\n this.emit(UILayerEvent.MODE_CHANGED, this.modeInternal, this);\n }\n }\n\n protected resizeInternal(width: number, height: number): void {\n this.solverWrapperInternal.suggestVariableValue(this.wVariable, width);\n this.solverWrapperInternal.suggestVariableValue(this.hVariable, height);\n this.sceneWrapperInternal.resize(width, height);\n\n const orientation =\n width > height ? UIOrientation.HORIZONTAL : UIOrientation.VERTICAL;\n\n if (orientation !== this.orientationInternal) {\n this.orientationInternal = orientation;\n this.emit(\n UILayerEvent.ORIENTATION_CHANGED,\n this.orientationInternal,\n this,\n );\n }\n }\n\n protected renderInternal(renderer: WebGLRenderer, deltaTime: number): void {\n if (isUIModeVisible(this.mode)) {\n this.emit(UILayerEvent.RENDERING, renderer, deltaTime, this);\n this.sceneWrapperInternal.render(renderer);\n }\n\n this.solverWrapperInternal.dirty = false;\n this.inputWrapperInternal.dirty = false;\n }\n}\n","import { UILayer } from \"../layers/UILayer/UILayer\";\n\n/** Objects that belong to a UI layer */\nexport interface UILayerElement {\n /** The UI layer containing this element */\n readonly layer: UILayer;\n}\n\n/** UI elements with position in 2D space */\nexport interface UIPointElement {\n /** Solver variable for x coordinate */\n readonly xVariable: number;\n /** Solver variable for y coordinate */\n readonly yVariable: number;\n\n /** X coordinate in world units */\n readonly x: number;\n /** Y coordinate in world units */\n readonly y: number;\n}\n\n/** UI elements with position and dimensions */\nexport interface UIPlaneElement extends UIPointElement {\n /** Solver variable for width */\n readonly wVariable: number;\n /** Solver variable for height */\n readonly hVariable: number;\n\n /** Width in world units */\n readonly width: number;\n /** Height in world units */\n readonly height: number;\n}\n\n/**\n * Checks if object implements UILayerElement.\n * @param obj Object to check\n * @returns True if object has valid layer property\n */\nexport function isUILayerElement(obj: unknown): obj is UILayerElement {\n return (\n typeof obj === \"object\" &&\n obj !== null &&\n \"layer\" in obj &&\n obj.layer instanceof UILayer\n );\n}\n\n/**\n * Checks if object implements UIPointElement.\n * @param obj Object to check\n * @returns True if object has valid position variables\n */\nexport function isUIPointElement(obj: unknown): obj is UIPointElement {\n return (\n typeof obj === \"object\" &&\n obj !== null &&\n \"xVariable\" in obj &&\n typeof obj.xVariable === \"number\" &&\n \"yVariable\" in obj &&\n typeof obj.yVariable === \"number\" &&\n \"width\" in obj &&\n typeof obj.width === \"number\" &&\n \"height\" in obj &&\n typeof obj.height === \"number\"\n );\n}\n\n/**\n * Checks if object implements UIPlaneElement.\n * @param obj Object to check\n * @returns True if object has valid dimension variables\n */\nexport function isUIPlaneElement(obj: unknown): obj is UIPlaneElement {\n return (\n typeof obj === \"object\" &&\n obj !== null &&\n \"wVariable\" in obj &&\n typeof obj.wVariable === \"number\" &&\n \"hVariable\" in obj &&\n typeof obj.hVariable === \"number\" &&\n \"width\" in obj &&\n typeof obj.width === \"number\" &&\n \"height\" in obj &&\n typeof obj.height === \"number\"\n );\n}\n","import { UILayer } from \"../layers/UILayer/UILayer\";\nimport { isUILayerElement } from \"./shared\";\n\nexport const EPSILON = 1e-6;\n\n/**\n * Validates value is finite number within safe range.\n * @param value Number to validate\n * @param subject Value name for error messages\n * @throws If value is not finite or exceeds safe range\n */\nexport function assertValidNumber(value: number, subject: string): void {\n if (process.env.NODE_ENV !== \"production\") {\n if (!Number.isFinite(value)) {\n throw new Error(`${subject}: value must be a finite number`);\n }\n\n if (Math.abs(value) > Number.MAX_SAFE_INTEGER) {\n throw new Error(`${subject}: value exceeds maximum safe integer range`);\n }\n }\n}\n\n/**\n * Validates value is positive (>= EPSILON).\n * @param value Number to validate\n * @param subject Value name for error messages\n * @throws If value is invalid or below EPSILON\n */\nexport function assertValidPositiveNumber(\n value: number,\n subject: string,\n): void {\n if (process.env.NODE_ENV !== \"production\") {\n assertValidNumber(value, subject);\n if (value < EPSILON) {\n throw new Error(\n `${subject}: value must be greater than or equal to ${EPSILON}`,\n );\n }\n }\n}\n\n/**\n * Validates value is non-negative (>= 0).\n * @param value Number to validate\n * @param subject Value name for error messages\n * @throws If value is invalid or negative\n */\nexport function assertValidNonNegativeNumber(\n value: number,\n subject: string,\n): void {\n if (process.env.NODE_ENV !== \"production\") {\n assertValidNumber(value, subject);\n if (value < 0) {\n throw new Error(`${subject}: value must be greater than or equal to 0`);\n }\n }\n}\n\n/**\n * Validates constraint arguments are from same layer.\n * @param a First constraint subject\n * @param b Second constraint subject\n * @param subject Constraint name for error messages\n * @returns Common layer for both subjects\n * @throws If subjects are invalid or from different layers\n */\nexport function assertValidConstraintArguments(\n a: unknown,\n b: unknown,\n subject: string,\n): UILayer {\n if (process.env.NODE_ENV !== \"production\") {\n if (a instanceof UILayer && b instanceof UILayer) {\n throw new Error(`${subject}: layer cannot be snapped to another layer`);\n }\n\n let layerA: UILayer;\n let layerB: UILayer;\n\n if (a instanceof UILayer) {\n layerA = a;\n } else if (isUILayerElement(a)) {\n layerA = a.layer;\n } else {\n throw new Error(`${subject}: A must be a UILayer or a UILayerElement`);\n }\n\n if (b instanceof UILayer) {\n layerB = b;\n } else if (isUILayerElement(b)) {\n layerB = b.layer;\n } else {\n throw new Error(`${subject}: B must be a UILayer or a UILayerElement`);\n }\n\n if (layerA !== layerB) {\n throw new Error(`${subject}: elements must be on the same layer`);\n }\n\n return layerA;\n }\n\n if (a instanceof UILayer) {\n return a;\n }\n if (isUILayerElement(a)) {\n return a.layer;\n }\n if (b instanceof UILayer) {\n return b;\n }\n if (isUILayerElement(b)) {\n return b.layer;\n }\n\n throw new Error(`${subject}: no valid subjects found`);\n}\n\n/**\n * Validates interpolation constraint subjects.\n * @param subject Constraint name for error messages\n * @param a First element\n * @param b Second element\n * @param c Element to interpolate\n * @param anchorA Anchor on element A\n * @param anchorB Anchor on element B\n * @returns Common layer for all subjects\n * @throws If subjects violate interpolation constraints\n */\nexport function assertValidInterpolationConstraintArguments(\n subject: string,\n a: unknown,\n b: unknown,\n c: unknown,\n anchorA: number,\n anchorB: number,\n): UILayer {\n if (process.env.NODE_ENV !== \"production\") {\n if (c instanceof UILayer) {\n throw new Error(`${subject}: C cannot be a layer`);\n }\n\n if (!isUILayerElement(c)) {\n throw new Error(`${subject}: C must be a UILayerElement`);\n }\n\n let layerA: UILayer;\n let layerB: UILayer;\n\n if (a instanceof UILayer || isUILayerElement(a)) {\n layerA = a instanceof UILayer ? a : a.layer;\n } else {\n throw new Error(`${subject}: A must be UILayer or UILayerElement`);\n }\n\n if (b instanceof UILayer || isUILayerElement(b)) {\n layerB = b instanceof UILayer ? b : b.layer;\n } else {\n throw new Error(`${subject}: B must be UILayer or UILayerElement`);\n }\n\n const layerC = c.layer;\n\n if (layerA !== layerB || layerA !== layerC) {\n throw new Error(`${subject}: all elements must be on the same layer`);\n }\n\n if (c === a || c === b) {\n throw new Error(`${subject}: C cannot be equal to A or B`);\n }\n\n if (a === b) {\n if (Math.abs(anchorA - anchorB) <= EPSILON) {\n throw new Error(\n `${subject}: when A and B are the same, anchorA and anchorB must differ by more than ${EPSILON}`,\n );\n }\n }\n\n return layerA;\n }\n\n if (a instanceof UILayer) {\n return a;\n }\n if (isUILayerElement(a)) {\n return a.layer;\n }\n if (b instanceof UILayer) {\n return b;\n }\n if (isUILayerElement(b)) {\n return b.layer;\n }\n\n throw new Error(`${subject}: no valid subjects found`);\n}\n","import type { UILayer } from \"../layers/UILayer/UILayer\";\nimport type { UISolverWrapperInterface } from \"../wrappers/UISolverWrapper.Internal\";\n\n/** Base class for layout constraints */\nexport abstract class UIConstraint {\n /** Optional constraint name */\n public name: string;\n\n /** Constraint solver wrapper */\n protected readonly solverWrapper: UISolverWrapperInterface;\n\n /** @param layer Layer containing this constraint */\n constructor(\n public readonly layer: UILayer,\n name?: string,\n ) {\n this.solverWrapper = this.layer.solverWrapper;\n this.name = name ?? \"\";\n }\n}\n","import type { UILayer } from \"../../layers/UILayer/UILayer\";\nimport { UILayerEvent } from \"../../layers/UILayer/UILayer.Internal\";\nimport {\n resolveOrientation,\n UIOrientation,\n} from \"../../miscellaneous/UIOrientation\";\nimport type { UIPriority } from \"../../miscellaneous/UIPriority\";\nimport { resolvePriority } from \"../../miscellaneous/UIPriority\";\nimport type { UIRelation } from \"../../miscellaneous/UIRelation\";\nimport { resolveRelation } from \"../../miscellaneous/UIRelation\";\nimport { UIConstraint } from \"../UIConstraint\";\nimport type { UISingleParameterConstraintOptions } from \"./UISingleParameterConstraint.Internal\";\n\n/** Base class for constraints with priority, relation, and orientation */\nexport abstract class UISingleParameterConstraint extends UIConstraint {\n /** Constraint priority */\n private priorityInternal: UIPriority;\n /** Constraint relation */\n private relationInternal: UIRelation;\n /** Constraint orientation */\n private orientationInternal: UIOrientation;\n\n /** Solver constraint descriptor */\n protected abstract readonly constraint: number;\n\n /**\n * @param layer Layer containing this constraint\n * @param options Constraint configuration\n */\n constructor(\n layer: UILayer,\n options?: Partial<UISingleParameterConstraintOptions>,\n ) {\n super(layer, options?.name);\n this.priorityInternal = resolvePriority(options?.priority);\n this.relationInternal = resolveRelation(options?.relation);\n this.orientationInternal = resolveOrientation(options?.orientation);\n this.layer.on(UILayerEvent.ORIENTATION_CHANGED, this.onOrientationChange);\n }\n\n /** Constraint priority */\n public get priority(): UIPriority {\n return this.priorityInternal;\n }\n\n /** Constraint relation */\n public get relation(): UIRelation {\n return this.relationInternal;\n }\n\n /** When constraint is active */\n public get orientation(): UIOrientation {\n return this.orientationInternal;\n }\n\n /** Updates constraint priority */\n public set priority(value: UIPriority) {\n if (value !== this.priorityInternal) {\n this.priorityInternal = value;\n this.solverWrapper.setConstraintPriority(\n this.constraint,\n this.priorityInternal,\n );\n }\n }\n\n /** Updates constraint relation */\n public set relation(value: UIRelation) {\n if (value !== this.relationInternal) {\n this.relationInternal = value;\n this.solverWrapper.setConstraintRelation(\n this.constraint,\n this.relationInternal,\n );\n }\n }\n\n /** Updates when constraint is active */\n public set orientation(value: UIOrientation) {\n if (value !== this.orientationInternal) {\n this.orientationInternal = value;\n this.onOrientationChange();\n }\n }\n\n /** Removes constraint from solver and cleans up listeners */\n public destroy(): void {\n this.layer.off(UILayerEvent.ORIENTATION_CHANGED, this.onOrientationChange);\n this.solverWrapper.removeConstraint(this.constraint);\n }\n\n /**\n * Checks if constraint should be active for current orientation.\n * @returns True if orientation is ALWAYS or matches layer orientation\n */\n protected isConstraintEnabled(): boolean {\n return (\n this.orientationInternal === UIOrientation.ALWAYS ||\n this.orientationInternal === this.layer.orientation\n );\n }\n\n /** Updates constraint enabled state when layer orientation changes */\n private readonly onOrientationChange = (): void => {\n this.solverWrapper.setConstraintEnabled(\n this.constraint,\n this.isConstraintEnabled(),\n );\n };\n}\n","import { assertValidPositiveNumber } from \"../../miscellaneous/asserts\";\nimport type {\n UILayerElement,\n UIPlaneElement,\n} from \"../../miscellaneous/shared\";\nimport { UIExpression } from \"../../miscellaneous/UIExpression\";\nimport { UISingleParameterConstraint } from \"../UISingleParameterConstraint/UISingleParameterConstraint\";\nimport type { UIHeightConstraintOptions } from \"./UIHeightConstraint.Internal\";\n\n/** Fixes element height to constant value */\nexport class UIHeightConstraint extends UISingleParameterConstraint {\n /** Solver constraint descriptor */\n protected override readonly constraint: number;\n\n /** Current height value */\n private heightInternal: number;\n\n /**\n * @param element Element to constrain\n * @param options Height configuration. Defaults to element's current height.\n */\n constructor(\n private readonly element: UIPlaneElement & UILayerElement,\n options: Partial<UIHeightConstraintOptions> = {},\n ) {\n if (options.height !== undefined) {\n assertValidPositiveNumber(\n options.height,\n \"UIHeightConstraint.constructor.options.height\",\n );\n }\n\n super(element.layer, options);\n\n this.heightInternal = options.height ?? element.height;\n this.constraint = this.solverWrapper.createConstraint(\n new UIExpression(0, [[this.element.hVariable, 1]]),\n new UIExpression(this.heightInternal),\n this.relation,\n this.priority,\n this.isConstraintEnabled(),\n );\n }\n\n /** Current height in world units */\n public get height(): number {\n return this.heightInternal;\n }\n\n /** Updates height */\n public set height(value: number) {\n assertValidPositiveNumber(value, \"UIHeightConstraint.height\");\n if (this.heightInternal !== value) {\n this.heightInternal = value;\n this.solverWrapper.setConstraintRHS(\n this.constraint,\n new UIExpression(value),\n );\n }\n }\n}\n","import {\n assertValidConstraintArguments,\n assertValidNumber,\n} from \"../../miscellaneous/asserts\";\nimport type {\n UIPlaneElement,\n UIPointElement,\n} from \"../../miscellaneous/shared\";\nimport { isUIPlaneElement, isUIPointElement } from \"../../miscellaneous/shared\";\nimport { UIExpression } from \"../../miscellaneous/UIExpression\";\nimport { UISingleParameterConstraint } from \"../UISingleParameterConstraint/UISingleParameterConstraint\";\nimport type { UIHorizontalDistanceConstraintOptions } from \"./UIHorizontalDistanceConstraint.Internal\";\nimport { DEFAULT_ANCHOR } from \"./UIHorizontalDistanceConstraint.Internal\";\n\n/** Maintains horizontal distance between elements with configurable anchors */\nexport class UIHorizontalDistanceConstraint extends UISingleParameterConstraint {\n /** Solver constraint descriptor */\n protected override readonly constraint: number;\n\n /** Anchor on element A */\n private anchorAInternal: number;\n /** Anchor on element B */\n private anchorBInternal: number;\n /** Current distance */\n private distanceInternal: number;\n\n /**\n * @param a First element\n * @param b Second element\n * @param options Distance configuration\n */\n constructor(\n private readonly a: UIPointElement | UIPlaneElement,\n private readonly b: UIPointElement | UIPlaneElement,\n options: Partial<UIHorizontalDistanceConstraintOptions> = {},\n ) {\n if (options.anchorA !== undefined) {\n assertValidNumber(\n options.anchorA,\n \"UIHorizontalDistanceConstraint.constructor.options.anchorA\",\n );\n }\n if (options.anchorB !== undefined) {\n assertValidNumber(\n options.anchorB,\n \"UIHorizontalDistanceConstraint.constructor.options.anchorB\",\n );\n }\n if (options.distance !== undefined) {\n assertValidNumber(\n options.distance,\n \"UIHorizontalDistanceConstraint.constructor.options.distance\",\n );\n }\n\n super(\n assertValidConstraintArguments(\n a,\n b,\n \"UIHorizontalDistanceConstraint.constructor\",\n ),\n options,\n );\n\n this.anchorAInternal = options.anchorA ?? DEFAULT_ANCHOR;\n this.anchorBInternal = options.anchorB ?? DEFAULT_ANCHOR;\n this.distanceInternal = options.distance ?? 0;\n\n this.constraint = this.solverWrapper.createConstraint(\n this.buildLHS(),\n new UIExpression(this.distanceInternal),\n this.relation,\n this.priority,\n this.isConstraintEnabled(),\n );\n }\n\n /** Current distance in world units */\n public get distance(): number {\n return this.distanceInternal;\n }\n\n /** Anchor on element A (0 = left, 0.5 = center, 1 = right) */\n public get anchorA(): number {\n return this.anchorAInternal;\n }\n\n /** Anchor on element B (0 = left, 0.5 = center, 1 = right) */\n public get anchorB(): number {\n return this.anchorBInternal;\n }\n\n /** Updates distance */\n public set distance(value: number) {\n assertValidNumber(value, \"UIHorizontalDistanceConstraint.distance\");\n if (this.distanceInternal !== value) {\n this.distanceInternal = value;\n this.solverWrapper.setConstraintRHS(\n this.constraint,\n new UIExpression(this.distanceInternal),\n );\n }\n }\n\n /** Updates anchor on element A */\n public set anchorA(value: number) {\n assertValidNumber(value, \"UIHorizontalDistanceConstraint.anchorA\");\n if (this.anchorAInternal !== value) {\n this.anchorAInternal = value;\n this.solverWrapper.setConstraintLHS(this.constraint, this.buildLHS());\n }\n }\n\n /** Updates anchor on element B */\n public set anchorB(value: number) {\n assertValidNumber(value, \"UIHorizontalDistanceConstraint.anchorB\");\n if (this.anchorBInternal !== value) {\n this.anchorBInternal = value;\n this.solverWrapper.setConstraintLHS(this.constraint, this.buildLHS());\n }\n }\n\n /** Builds constraint expression for distance between anchored positions */\n private buildLHS(): UIExpression {\n let aExpression: UIExpression;\n let bExpression: UIExpression;\n\n if (isUIPlaneElement(this.a)) {\n aExpression = new UIExpression(0, [\n [this.a.xVariable, 1],\n [this.a.wVariable, this.anchorAInternal],\n ]);\n } else if (isUIPointElement(this.a)) {\n aExpression = new UIExpression().plus(this.a.xVariable, 1);\n } else {\n throw new Error(\n \"UIHorizontalDistanceConstraint.buildLHS.a: invalid element type\",\n );\n }\n\n if (isUIPlaneElement(this.b)) {\n bExpression = new UIExpression(0, [\n [this.b.xVariable, 1],\n [this.b.wVariable, this.anchorBInternal],\n ]);\n } else if (isUIPointElement(this.b)) {\n bExpression = new UIExpression().plus(this.b.xVariable, 1);\n } else {\n throw new Error(\n \"UIHorizontalDistanceConstraint.buildLHS.b: invalid element type\",\n );\n }\n\n return UIExpression.minus(bExpression, aExpression);\n }\n}\n","import type { UISingleParameterConstraintOptions } from \"../UISingleParameterConstraint/UISingleParameterConstraint.Internal\";\n\nexport const DEFAULT_ANCHOR = 0.5;\n\n/** Horizontal distance constraint options */\nexport interface UIHorizontalDistanceConstraintOptions\n extends UISingleParameterConstraintOptions {\n /** Anchor on element A (0 = left, 0.5 = center, 1 = right) */\n anchorA: number;\n /** Anchor on element B (0 = left, 0.5 = center, 1 = right) */\n anchorB: number;\n /** Distance in world units */\n distance: number;\n}\n","import {\n assertValidInterpolationConstraintArguments,\n assertValidNumber,\n} from \"../../miscellaneous/asserts\";\nimport type {\n UIPlaneElement,\n UIPointElement,\n} from \"../../miscellaneous/shared\";\nimport { isUIPlaneElement, isUIPointElement } from \"../../miscellaneous/shared\";\nimport { UIExpression } from \"../../miscellaneous/UIExpression\";\nimport { UISingleParameterConstraint } from \"../UISingleParameterConstraint/UISingleParameterConstraint\";\nimport type { UIHorizontalInterpolationConstraintOptions } from \"./UIHorizontalInterpolationConstraint.Internal\";\nimport {\n DEFAULT_ANCHOR,\n DEFAULT_T,\n} from \"./UIHorizontalInterpolationConstraint.Internal\";\n\n/** Positions element C horizontally between A and B based on interpolation factor */\nexport class UIHorizontalInterpolationConstraint extends UISingleParameterConstraint {\n /** Solver constraint descriptor */\n protected override readonly constraint: number;\n\n /** Anchor on element A */\n private anchorAInternal: number;\n /** Anchor on element B */\n private anchorBInternal: number;\n /** Anchor on element C */\n private anchorCInternal: number;\n /** Interpolation factor */\n private tInternal: number;\n\n /**\n * @param a First element\n * @param b Second element\n * @param c Element to position between A and B\n * @param options Interpolation configuration\n */\n constructor(\n private readonly a: UIPointElement | UIPlaneElement,\n private readonly b: UIPointElement | UIPlaneElement,\n private readonly c: UIPointElement | UIPlaneElement,\n options: Partial<UIHorizontalInterpolationConstraintOptions> = {},\n ) {\n if (options.anchorA !== undefined) {\n assertValidNumber(\n options.anchorA,\n \"UIHorizontalInterpolationConstraint.constructor.options.anchorA\",\n );\n }\n if (options.anchorB !== undefined) {\n assertValidNumber(\n options.anchorB,\n \"UIHorizontalInterpolationConstraint.constructor.options.anchorB\",\n );\n }\n if (options.anchorC !== undefined) {\n assertValidNumber(\n options.anchorC,\n \"UIHorizontalInterpolationConstraint.constructor.options.anchorC\",\n );\n }\n if (options.t !== undefined) {\n assertValidNumber(\n options.t,\n \"UIHorizontalInterpolationConstraint.constructor.options.t\",\n );\n }\n\n const anchorA = options.anchorA ?? DEFAULT_ANCHOR;\n const anchorB = options.anchorB ?? DEFAULT_ANCHOR;\n\n super(\n assertValidInterpolationConstraintArguments(\n \"UIHorizontalInterpolationConstraint.constructor\",\n a,\n b,\n c,\n anchorA,\n anchorB,\n ),\n options,\n );\n\n this.anchorAInternal = anchorA;\n this.anchorBInternal = anchorA;\n this.anchorCInternal = options.anchorC ?? DEFAULT_ANCHOR;\n this.tInternal = options.t ?? DEFAULT_T;\n\n this.constraint = this.solverWrapper.createConstraint(\n this.buildLHS(),\n new UIExpression(0),\n this.relation,\n this.priority,\n this.isConstraintEnabled(),\n );\n }\n\n /** Interpolation factor (0 = A position, 1 = B position) */\n public get t(): number {\n return this.tInternal;\n }\n\n /** Anchor on element A (0 = left, 0.5 = center, 1 = right) */\n public get anchorA(): number {\n return this.anchorAInternal;\n }\n\n /** Anchor on element B (0 = left, 0.5 = center, 1 = right) */\n public get anchorB(): number {\n return this.anchorBInternal;\n }\n\n /** Anchor on element C (0 = left, 0.5 = center, 1 = right) */\n public get anchorC(): number {\n return this.anchorCInternal;\n }\n\n /** Updates interpolation factor */\n public set t(value: number) {\n assertValidNumber(value, \"UIHorizontalInterpolationConstraint.t\");\n if (this.tInternal !== value) {\n this.tInternal = value;\n this.solverWrapper.setConstraintLHS(this.constraint, this.buildLHS());\n }\n }\n\n /** Updates anchor on element A */\n public set anchorA(value: number) {\n assertValidNumber(value, \"UIHorizontalInterpolationConstraint.anchorA\");\n if (this.anchorAInternal !== value) {\n this.anchorAInternal = value;\n this.solverWrapper.setConstraintLHS(this.constraint, this.buildLHS());\n }\n }\n\n /** Updates anchor on element B */\n public set anchorB(value: number) {\n assertValidNumber(value, \"UIHorizontalInterpolationConstraint.anchorB\");\n if (this.anchorBInternal !== value) {\n this.anchorBInternal = value;\n this.solverWrapper.setConstraintLHS(this.constraint, this.buildLHS());\n }\n }\n\n /** Updates anchor on element C */\n public set anchorC(value: number) {\n assertValidNumber(value, \"UIHorizontalInterpolationConstraint.anchorC\");\n if (this.anchorCInternal !== value) {\n this.anchorCInternal = value;\n this.solverWrapper.setConstraintLHS(this.constraint, this.buildLHS());\n }\n }\n\n /** Builds constraint expression: C - A*(1-t) - B*t = 0 */\n private buildLHS(): UIExpression {\n let aExpression: UIExpression;\n let bExpression: UIExpression;\n let cExpression: UIExpression;\n\n if (isUIPlaneElement(this.a)) {\n aExpression = new UIExpression(0, [\n [this.a.xVariable, 1],\n [this.a.wVariable, this.anchorAInternal],\n ]);\n } else if (isUIPointElement(this.a)) {\n aExpression = new UIExpression().plus(this.a.xVariable, 1);\n } else {\n throw new Error(\n \"UIHorizontalInterpolationConstraint.buildLHS.a: invalid element type\",\n );\n }\n\n if (isUIPlaneElement(this.b)) {\n bExpression = new UIExpression(0, [\n [this.b.xVariable, 1],\n [this.b.wVariable, this.anchorBInternal],\n ]);\n } else if (isUIPointElement(this.b)) {\n bExpression = new UIExpression().plus(this.b.xVariable, 1);\n } else {\n throw new Error(\n \"UIHorizontalInterpolationConstraint.buildLHS.b: invalid element type\",\n );\n }\n\n if (isUIPlaneElement(this.c)) {\n cExpression = new UIExpression(0, [\n [this.c.xVariable, 1],\n [this.c.wVariable, this.anchorCInternal],\n ]);\n } else if (isUIPointElement(this.c)) {\n cExpression = new UIExpression().plus(this.c.xVariable, 1);\n } else {\n throw new Error(\n \"UIHorizontalInterpolationConstraint.buildLHS.c: invalid element type\",\n );\n }\n\n // C - A*(1-t) - B*t = 0\n const aScaled = aExpression.clone().multiply(1 - this.tInternal);\n const bScaled = bExpression.clone().multiply(this.tInternal);\n return UIExpression.minus(\n UIExpression.minus(cExpression, aScaled),\n bScaled,\n );\n }\n}\n","import type { UISingleParameterConstraintOptions } from \"../UISingleParameterConstraint/UISingleParameterConstraint.Internal\";\n\nexport const DEFAULT_ANCHOR = 0.5;\nexport const DEFAULT_T = 0.5;\n\n/** Horizontal interpolation constraint options */\nexport interface UIHorizontalInterpolationConstraintOptions\n extends UISingleParameterConstraintOptions {\n /** Anchor on element A (0 = left, 0.5 = center, 1 = right) */\n anchorA: number;\n /** Anchor on element B (0 = left, 0.5 = center, 1 = right) */\n anchorB: number;\n /** Anchor on element C (0 = left, 0.5 = center, 1 = right) */\n anchorC: number;\n /** Interpolation factor (0 = A position, 1 = B position) */\n t: number;\n}\n","import {\n assertValidConstraintArguments,\n assertValidPositiveNumber,\n} from \"../../miscellaneous/asserts\";\nimport type { UIPlaneElement } from \"../../miscellaneous/shared\";\nimport { UIExpression } from \"../../miscellaneous/UIExpression\";\nimport { UISingleParameterConstraint } from \"../UISingleParameterConstraint/UISingleParameterConstraint\";\nimport type { UIHorizontalProportionConstraintOptions } from \"./UIHorizontalProportionConstraint.Internal\";\n\n/** Maintains proportional width relationship (A.width * proportion = B.width) */\nexport class UIHorizontalProportionConstraint extends UISingleParameterConstraint {\n protected override readonly constraint: number;\n private proportionInternal: number;\n\n /**\n * @param a First element\n * @param b Second element\n * @param options Proportion configuration\n */\n constructor(\n private readonly a: UIPlaneElement,\n private readonly b: UIPlaneElement,\n options: Partial<UIHorizontalProportionConstraintOptions> = {},\n ) {\n if (options.proportion !== undefined) {\n assertValidPositiveNumber(\n options.proportion,\n \"UIHorizontalProportionConstraint.constructor.options.proportion\",\n );\n }\n\n super(\n assertValidConstraintArguments(\n a,\n b,\n \"UIHorizontalProportionConstraint.constructor\",\n ),\n options,\n );\n\n this.proportionInternal = options.proportion ?? 1;\n this.constraint = this.solverWrapper.createConstraint(\n new UIExpression(0),\n this.buildRHS(),\n this.relation,\n this.priority,\n this.isConstraintEnabled(),\n );\n }\n\n /** Current proportion multiplier */\n public get proportion(): number {\n return this.proportionInternal;\n }\n\n /** Updates proportion multiplier */\n public set proportion(value: number) {\n assertValidPositiveNumber(\n value,\n \"UIHorizontalProportionConstraint.proportion\",\n );\n if (this.proportionInternal !== value) {\n this.proportionInternal = value;\n this.solverWrapper.setConstraintRHS(this.constraint, this.buildRHS());\n }\n }\n\n /** Builds constraint expression for proportional relationship */\n private buildRHS(): UIExpression {\n return UIExpression.minus(\n new UIExpression(0, [[this.a.wVariable, this.proportionInternal]]),\n new UIExpression(0, [[this.b.wVariable, 1]]),\n );\n }\n}\n","import {\n assertValidConstraintArguments,\n assertValidNumber,\n} from \"../../miscellaneous/asserts\";\nimport type {\n UIPlaneElement,\n UIPointElement,\n} from \"../../miscellaneous/shared\";\nimport { isUIPlaneElement, isUIPointElement } from \"../../miscellaneous/shared\";\nimport { UIExpression } from \"../../miscellaneous/UIExpression\";\nimport { UISingleParameterConstraint } from \"../UISingleParameterConstraint/UISingleParameterConstraint\";\nimport type { UIVerticalDistanceConstraintOptions } from \"./UIVerticalDistanceConstraint.Internal\";\nimport { DEFAULT_ANCHOR } from \"./UIVerticalDistanceConstraint.Internal\";\n\n/** Maintains vertical distance between elements with configurable anchors */\nexport class UIVerticalDistanceConstraint extends UISingleParameterConstraint {\n protected override readonly constraint: number;\n\n private anchorAInternal: number;\n private anchorBInternal: number;\n private distanceInternal: number;\n\n /**\n * @param a First element\n * @param b Second element\n * @param options Distance configuration\n */\n constructor(\n private readonly a: UIPointElement | UIPlaneElement,\n private readonly b: UIPointElement | UIPlaneElement,\n options: Partial<UIVerticalDistanceConstraintOptions> = {},\n ) {\n if (options.anchorA !== undefined) {\n assertValidNumber(\n options.anchorA,\n \"UIVerticalDistanceConstraint.constructor.options.anchorA\",\n );\n }\n if (options.anchorB !== undefined) {\n assertValidNumber(\n options.anchorB,\n \"UIVerticalDistanceConstraint.constructor.options.anchorB\",\n );\n }\n if (options.distance !== undefined) {\n assertValidNumber(\n options.distance,\n \"UIVerticalDistanceConstraint.constructor.options.distance\",\n );\n }\n\n super(\n assertValidConstraintArguments(\n a,\n b,\n \"UIVerticalDistanceConstraint.constructor\",\n ),\n options,\n );\n\n this.anchorAInternal = options.anchorA ?? DEFAULT_ANCHOR;\n this.anchorBInternal = options.anchorB ?? DEFAULT_ANCHOR;\n this.distanceInternal = options.distance ?? 0;\n\n this.constraint = this.solverWrapper.createConstraint(\n this.buildLHS(),\n new UIExpression(this.distanceInternal),\n this.relation,\n this.priority,\n this.isConstraintEnabled(),\n );\n }\n\n /** Current distance in world units */\n public get distance(): number {\n return this.distanceInternal;\n }\n\n /** Anchor on element A (0 = bottom, 0.5 = center, 1 = top) */\n public get anchorA(): number {\n return this.anchorAInternal;\n }\n\n /** Anchor on element B (0 = bottom, 0.5 = center, 1 = top) */\n public get anchorB(): number {\n return this.anchorBInternal;\n }\n\n /** Updates distance */\n public set distance(value: number) {\n assertValidNumber(value, \"UIVerticalDistanceConstraint.distance\");\n if (this.distanceInternal !== value) {\n this.distanceInternal = value;\n this.solverWrapper.setConstraintRHS(\n this.constraint,\n new UIExpression(this.distanceInternal),\n );\n }\n }\n\n /** Updates anchor on element A */\n public set anchorA(value: number) {\n assertValidNumber(value, \"UIVerticalDistanceConstraint.anchorA\");\n if (this.anchorAInternal !== value) {\n this.anchorAInternal = value;\n this.solverWrapper.setConstraintLHS(this.constraint, this.buildLHS());\n }\n }\n\n /** Updates anchor on element B */\n public set anchorB(value: number) {\n assertValidNumber(value, \"UIVerticalDistanceConstraint.anchorB\");\n if (this.anchorBInternal !== value) {\n this.anchorBInternal = value;\n this.solverWrapper.setConstraintLHS(this.constraint, this.buildLHS());\n }\n }\n\n /** Builds constraint expression for distance between anchored positions */\n private buildLHS(): UIExpression {\n let aExpression: UIExpression;\n let bExpression: UIExpression;\n\n if (isUIPlaneElement(this.a)) {\n aExpression = new UIExpression(0, [\n [this.a.yVariable, 1],\n [this.a.hVariable, this.anchorAInternal],\n ]);\n } else if (isUIPointElement(this.a)) {\n aExpression = new UIExpression().plus(this.a.yVariable, 1);\n } else {\n throw new Error(\n \"UIVerticalDistanceConstraint.buildLHS.a: invalid element type\",\n );\n }\n\n if (isUIPlaneElement(this.b)) {\n bExpression = new UIExpression(0, [\n [this.b.yVariable, 1],\n [this.b.hVariable, this.anchorBInternal],\n ]);\n } else if (isUIPointElement(this.b)) {\n bExpression = new UIExpression().plus(this.b.yVariable, 1);\n } else {\n throw new Error(\n \"UIVerticalDistanceConstraint.buildLHS.b: invalid element type\",\n );\n }\n\n return UIExpression.minus(bExpression, aExpression);\n }\n}\n","import type { UISingleParameterConstraintOptions } from \"../UISingleParameterConstraint/UISingleParameterConstraint.Internal\";\n\nexport const DEFAULT_ANCHOR = 0.5;\n\n/** Vertical distance constraint options */\nexport interface UIVerticalDistanceConstraintOptions\n extends UISingleParameterConstraintOptions {\n /** Anchor on element A (0 = bottom, 0.5 = center, 1 = top) */\n anchorA: number;\n /** Anchor on element B (0 = bottom, 0.5 = center, 1 = top) */\n anchorB: number;\n /** Distance in world units */\n distance: number;\n}\n","import {\n assertValidInterpolationConstraintArguments,\n assertValidNumber,\n} from \"../../miscellaneous/asserts\";\nimport type {\n UIPlaneElement,\n UIPointElement,\n} from \"../../miscellaneous/shared\";\nimport { isUIPlaneElement, isUIPointElement } from \"../../miscellaneous/shared\";\nimport { UIExpression } from \"../../miscellaneous/UIExpression\";\nimport { UISingleParameterConstraint } from \"../UISingleParameterConstraint/UISingleParameterConstraint\";\nimport type { UIVerticalInterpolationConstraintOptions } from \"./UIVerticalInterpolationConstraint.Internal\";\nimport {\n DEFAULT_ANCHOR,\n DEFAULT_T,\n} from \"./UIVerticalInterpolationConstraint.Internal\";\n\n/** Positions element C vertically between A and B based on interpolation factor */\nexport class UIVerticalInterpolationConstraint extends UISingleParameterConstraint {\n /** Solver constraint descriptor */\n protected override readonly constraint: number;\n\n /** Anchor on element A */\n private anchorAInternal: number;\n /** Anchor on element B */\n private anchorBInternal: number;\n /** Anchor on element C */\n private anchorCInternal: number;\n /** Interpolation factor */\n private tInternal: number;\n\n /**\n * @param a First element\n * @param b Second element\n * @param c Element to position between A and B\n * @param options Interpolation configuration\n */\n constructor(\n private readonly a: UIPointElement | UIPlaneElement,\n private readonly b: UIPointElement | UIPlaneElement,\n private readonly c: UIPointElement | UIPlaneElement,\n options: Partial<UIVerticalInterpolationConstraintOptions> = {},\n ) {\n if (options.anchorA !== undefined) {\n assertValidNumber(\n options.anchorA,\n \"UIVerticalInterpolationConstraint.constructor.options.anchorA\",\n );\n }\n if (options.anchorB !== undefined) {\n assertValidNumber(\n options.anchorB,\n \"UIVerticalInterpolationConstraint.constructor.options.anchorB\",\n );\n }\n if (options.anchorC !== undefined) {\n assertValidNumber(\n options.anchorC,\n \"UIVerticalInterpolationConstraint.constructor.options.anchorC\",\n );\n }\n if (options.t !== undefined) {\n assertValidNumber(\n options.t,\n \"UIVerticalInterpolationConstraint.constructor.options.t\",\n );\n }\n\n const anchorA = options.anchorA ?? DEFAULT_ANCHOR;\n const anchorB = options.anchorB ?? DEFAULT_ANCHOR;\n\n super(\n assertValidInterpolationConstraintArguments(\n \"UIVerticalInterpolationConstraint.constructor\",\n a,\n b,\n c,\n anchorA,\n anchorB,\n ),\n options,\n );\n\n this.anchorAInternal = anchorA;\n this.anchorBInternal = anchorA;\n this.anchorCInternal = options.anchorC ?? DEFAULT_ANCHOR;\n this.tInternal = options.t ?? DEFAULT_T;\n\n this.constraint = this.solverWrapper.createConstraint(\n this.buildLHS(),\n new UIExpression(0),\n this.relation,\n this.priority,\n this.isConstraintEnabled(),\n );\n }\n\n /** Interpolation factor (0 = A position, 1 = B position) */\n public get t(): number {\n return this.tInternal;\n }\n\n /** Anchor on element A (0 = bottom, 0.5 = center, 1 = top) */\n public get anchorA(): number {\n return this.anchorAInternal;\n }\n\n /** Anchor on element B (0 = bottom, 0.5 = center, 1 = top) */\n public get anchorB(): number {\n return this.anchorBInternal;\n }\n\n /** Anchor on element C (0 = bottom, 0.5 = center, 1 = top) */\n public get anchorC(): number {\n return this.anchorCInternal;\n }\n\n /** Updates interpolation factor */\n public set t(value: number) {\n assertValidNumber(value, \"UIVerticalInterpolationConstraint.t\");\n if (this.tInternal !== value) {\n this.tInternal = value;\n this.solverWrapper.setConstraintLHS(this.constraint, this.buildLHS());\n }\n }\n\n /** Updates anchor on element A */\n public set anchorA(value: number) {\n assertValidNumber(value, \"UIVerticalInterpolationConstraint.anchorA\");\n if (this.anchorAInternal !== value) {\n this.anchorAInternal = value;\n this.solverWrapper.setConstraintLHS(this.constraint, this.buildLHS());\n }\n }\n\n /** Updates anchor on element B */\n public set anchorB(value: number) {\n assertValidNumber(value, \"UIVerticalInterpolationConstraint.anchorB\");\n if (this.anchorBInternal !== value) {\n this.anchorBInternal = value;\n this.solverWrapper.setConstraintLHS(this.constraint, this.buildLHS());\n }\n }\n\n /** Updates anchor on element C */\n public set anchorC(value: number) {\n assertValidNumber(value, \"UIVerticalInterpolationConstraint.anchorC\");\n if (this.anchorCInternal !== value) {\n this.anchorCInternal = value;\n this.solverWrapper.setConstraintLHS(this.constraint, this.buildLHS());\n }\n }\n\n /** Builds constraint expression: C - A*(1-t) - B*t = 0 */\n private buildLHS(): UIExpression {\n let aExpression: UIExpression;\n let bExpression: UIExpression;\n let cExpression: UIExpression;\n\n if (isUIPlaneElement(this.a)) {\n aExpression = new UIExpression(0, [\n [this.a.yVariable, 1],\n [this.a.hVariable, this.anchorAInternal],\n ]);\n } else if (isUIPointElement(this.a)) {\n aExpression = new UIExpression().plus(this.a.yVariable, 1);\n } else {\n throw new Error(\n \"UIVerticalInterpolationConstraint.buildLHS.a: invalid element type\",\n );\n }\n\n if (isUIPlaneElement(this.b)) {\n bExpression = new UIExpression(0, [\n [this.b.yVariable, 1],\n [this.b.hVariable, this.anchorBInternal],\n ]);\n } else if (isUIPointElement(this.b)) {\n bExpression = new UIExpression().plus(this.b.yVariable, 1);\n } else {\n throw new Error(\n \"UIVerticalInterpolationConstraint.buildLHS.b: invalid element type\",\n );\n }\n\n if (isUIPlaneElement(this.c)) {\n cExpression = new UIExpression(0, [\n [this.c.yVariable, 1],\n [this.c.hVariable, this.anchorCInternal],\n ]);\n } else if (isUIPointElement(this.c)) {\n cExpression = new UIExpression().plus(this.c.yVariable, 1);\n } else {\n throw new Error(\n \"UIVerticalInterpolationConstraint.buildLHS.c: invalid element type\",\n );\n }\n\n // C - A*(1-t) - B*t = 0\n const aScaled = aExpression.clone().multiply(1 - this.tInternal);\n const bScaled = bExpression.clone().multiply(this.tInternal);\n return UIExpression.minus(\n UIExpression.minus(cExpression, aScaled),\n bScaled,\n );\n }\n}\n","import type { UISingleParameterConstraintOptions } from \"../UISingleParameterConstraint/UISingleParameterConstraint.Internal\";\n\nexport const DEFAULT_ANCHOR = 0.5;\nexport const DEFAULT_T = 0.5;\n\n/** Vertical interpolation constraint options */\nexport interface UIVerticalInterpolationConstraintOptions\n extends UISingleParameterConstraintOptions {\n /** Anchor on element A (0 = bottom, 0.5 = center, 1 = top) */\n anchorA: number;\n /** Anchor on element B (0 = bottom, 0.5 = center, 1 = top) */\n anchorB: number;\n /** Anchor on element C (0 = bottom, 0.5 = center, 1 = top) */\n anchorC: number;\n /** Interpolation factor (0 = A position, 1 = B position) */\n t: number;\n}\n","import {\n assertValidConstraintArguments,\n assertValidPositiveNumber,\n} from \"../../miscellaneous/asserts\";\nimport type { UIPlaneElement } from \"../../miscellaneous/shared\";\nimport { UIExpression } from \"../../miscellaneous/UIExpression\";\nimport { UISingleParameterConstraint } from \"../UISingleParameterConstraint/UISingleParameterConstraint\";\nimport type { UIVerticalProportionConstraintOptions } from \"./UIVerticalProportionConstraint.Internal\";\n\n/** Maintains proportional height relationship (A.height * proportion = B.height) */\nexport class UIVerticalProportionConstraint extends UISingleParameterConstraint {\n protected override readonly constraint: number;\n private proportionInternal: number;\n\n /**\n * @param a First element\n * @param b Second element\n * @param options Proportion configuration\n */\n constructor(\n private readonly a: UIPlaneElement,\n private readonly b: UIPlaneElement,\n options: Partial<UIVerticalProportionConstraintOptions> = {},\n ) {\n if (options.proportion !== undefined) {\n assertValidPositiveNumber(\n options.proportion,\n \"UIVerticalProportionConstraint.constructor.options.proportion\",\n );\n }\n\n super(\n assertValidConstraintArguments(\n a,\n b,\n \"UIVerticalProportionConstraint.constructor\",\n ),\n options,\n );\n\n this.proportionInternal = options.proportion ?? 1;\n this.constraint = this.solverWrapper.createConstraint(\n new UIExpression(0),\n this.buildRHS(),\n this.relation,\n this.priority,\n this.isConstraintEnabled(),\n );\n }\n\n /** Current proportion multiplier */\n public get proportion(): number {\n return this.proportionInternal;\n }\n\n /** Updates proportion multiplier */\n public set proportion(value: number) {\n assertValidPositiveNumber(\n value,\n \"UIVerticalProportionConstraint.proportion\",\n );\n if (this.proportionInternal !== value) {\n this.proportionInternal = value;\n this.solverWrapper.setConstraintRHS(this.constraint, this.buildRHS());\n }\n }\n\n /** Builds constraint expression for proportional relationship */\n private buildRHS(): UIExpression {\n return UIExpression.minus(\n new UIExpression(0, [[this.a.hVariable, this.proportionInternal]]),\n new UIExpression(0, [[this.b.hVariable, 1]]),\n );\n }\n}\n","import { assertValidPositiveNumber } from \"../../miscellaneous/asserts\";\nimport type {\n UILayerElement,\n UIPlaneElement,\n} from \"../../miscellaneous/shared\";\nimport { UIExpression } from \"../../miscellaneous/UIExpression\";\nimport { UISingleParameterConstraint } from \"../UISingleParameterConstraint/UISingleParameterConstraint\";\nimport type { UIWidthConstraintOptions } from \"./UIWidthConstraint.Internal\";\n\n/** Fixes element width to constant value */\nexport class UIWidthConstraint extends UISingleParameterConstraint {\n /** Solver constraint descriptor */\n protected override readonly constraint: number;\n\n /** Current width value */\n private widthInternal: number;\n\n /**\n * @param element Element to constrain\n * @param options Width configuration. Defaults to element's current width.\n */\n constructor(\n private readonly element: UIPlaneElement & UILayerElement,\n options: Partial<UIWidthConstraintOptions> = {},\n ) {\n if (options.width !== undefined) {\n assertValidPositiveNumber(\n options.width,\n \"UIWidthConstraint.constructor.options.width\",\n );\n }\n\n super(element.layer, options);\n\n this.widthInternal = options.width ?? element.width;\n this.constraint = this.solverWrapper.createConstraint(\n new UIExpression(0, [[this.element.wVariable, 1]]),\n new UIExpression(this.widthInternal),\n this.relation,\n this.priority,\n this.isConstraintEnabled(),\n );\n }\n\n /** Current width in world units */\n public get width(): number {\n return this.widthInternal;\n }\n\n /** Updates width */\n public set width(value: number) {\n assertValidPositiveNumber(value, \"UIWidthConstraint.width\");\n if (this.widthInternal !== value) {\n this.widthInternal = value;\n this.solverWrapper.setConstraintRHS(\n this.constraint,\n new UIExpression(value),\n );\n }\n }\n}\n","import type { UIOrientation } from \"../../miscellaneous/UIOrientation\";\nimport type { UIPriority } from \"../../miscellaneous/UIPriority\";\nimport type { UIRelation } from \"../../miscellaneous/UIRelation\";\n\n/** Horizontal and vertical values object */\nexport interface UIType2DObject<T> {\n /** Horizontal value */\n h?: T;\n /** Vertical value */\n v?: T;\n}\n\n/** Horizontal and vertical values as object, tuple, or single value */\nexport type UIType2D<T> = UIType2DObject<T> | [T, T] | T;\n\n/**\n * Normalizes UIType2D input to object form.\n * @param value Object, tuple, or single value\n * @returns Normalized object with h and v properties\n */\nexport function normalizeUIType2D<T>(\n value: UIType2D<T> | undefined,\n): UIType2DObject<T> {\n if (value === undefined) {\n return {};\n }\n if (Array.isArray(value)) {\n return { h: value[0], v: value[1] };\n }\n if (\n typeof value === \"object\" &&\n value !== null &&\n (\"h\" in value || \"v\" in value)\n ) {\n return value;\n }\n return { h: value as T, v: value as T };\n}\n\n/** Base 2D constraint options */\nexport interface UIConstraint2DOptions {\n /** Priority for each axis */\n priority: UIType2D<UIPriority>;\n /** Relation for each axis */\n relation: UIType2D<UIRelation>;\n /** Orientation for each axis */\n orientation: UIType2D<UIOrientation>;\n}\n\n/** 2D size constraint options */\nexport interface UIConstraintSize2DOptions extends UIConstraint2DOptions {\n /** Width and height */\n size: UIType2D<number>;\n}\n\n/** 2D distance constraint options */\nexport interface UIConstraintDistance2DOptions extends UIConstraint2DOptions {\n /** Anchor on element A for each axis */\n anchorA: UIType2D<number>;\n /** Anchor on element B for each axis */\n anchorB: UIType2D<number>;\n /** Distance for each axis */\n distance: UIType2D<number>;\n}\n\n/** 2D proportion constraint options */\nexport interface UIConstraintProportion2DOptions extends UIConstraint2DOptions {\n /** Proportion for each axis */\n proportion: UIType2D<number>;\n}\n\n/** 2D interpolation constraint options */\nexport interface UIConstraintInterpolation2DOptions\n extends UIConstraint2DOptions {\n /** Anchor on element A for each axis */\n anchorA: UIType2D<number>;\n /** Anchor on element B for each axis */\n anchorB: UIType2D<number>;\n /** Anchor on element C for each axis */\n anchorC: UIType2D<number>;\n /** Interpolation factor for each axis */\n t: UIType2D<number>;\n}\n\n/** Horizontal and vertical constraint pair */\nexport interface UIConstraint2DResult<TH, TV> {\n /** Horizontal constraint */\n h: TH;\n /** Vertical constraint */\n v: TV;\n}\n","import type { UIElement } from \"../../elements/UIElement/UIElement\";\nimport type {\n UIPlaneElement,\n UIPointElement,\n} from \"../../miscellaneous/shared\";\nimport { UIHeightConstraint } from \"../UIHeightConstraint/UIHeightConstraint\";\nimport { UIHorizontalDistanceConstraint } from \"../UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint\";\nimport { UIHorizontalInterpolationConstraint } from \"../UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint\";\nimport { UIHorizontalProportionConstraint } from \"../UIHorizontalProportionConstraint/UIHorizontalProportionConstraint\";\nimport { UIVerticalDistanceConstraint } from \"../UIVerticalDistanceConstraint/UIVerticalDistanceConstraint\";\nimport { UIVerticalInterpolationConstraint } from \"../UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint\";\nimport { UIVerticalProportionConstraint } from \"../UIVerticalProportionConstraint/UIVerticalProportionConstraint\";\nimport { UIWidthConstraint } from \"../UIWidthConstraint/UIWidthConstraint\";\nimport type {\n UIConstraint2DResult,\n UIConstraintDistance2DOptions,\n UIConstraintInterpolation2DOptions,\n UIConstraintProportion2DOptions,\n UIConstraintSize2DOptions,\n} from \"./UIConstraint2DBuilder.Internal\";\nimport { normalizeUIType2D } from \"./UIConstraint2DBuilder.Internal\";\n\n/** Builder for paired horizontal and vertical constraints */\nexport class UIConstraint2DBuilder {\n /**\n * Creates width and height constraints.\n * @param element Element to constrain\n * @param options Size configuration for both axes\n * @returns Width and height constraints\n */\n public static size(\n element: UIElement,\n options: Partial<UIConstraintSize2DOptions> = {},\n ): UIConstraint2DResult<UIWidthConstraint, UIHeightConstraint> {\n const size = normalizeUIType2D(options.size);\n const priority = normalizeUIType2D(options.priority);\n const relation = normalizeUIType2D(options.relation);\n const orientation = normalizeUIType2D(options.orientation);\n\n return {\n h: new UIWidthConstraint(element, {\n width: size.h,\n priority: priority.h,\n relation: relation.h,\n orientation: orientation.h,\n }),\n v: new UIHeightConstraint(element, {\n height: size.v,\n priority: priority.v,\n relation: relation.v,\n orientation: orientation.v,\n }),\n };\n }\n\n /**\n * Creates horizontal and vertical distance constraints.\n * @param a First element\n * @param b Second element\n * @param options Distance configuration for both axes\n * @returns Horizontal and vertical distance constraints\n */\n public static distance(\n a: UIPointElement | UIPlaneElement,\n b: UIPointElement | UIPlaneElement,\n options: Partial<UIConstraintDistance2DOptions> = {},\n ): UIConstraint2DResult<\n UIHorizontalDistanceConstraint,\n UIVerticalDistanceConstraint\n > {\n const anchorA = normalizeUIType2D(options.anchorA);\n const anchorB = normalizeUIType2D(options.anchorB);\n const distance = normalizeUIType2D(options.distance);\n const priority = normalizeUIType2D(options.priority);\n const relation = normalizeUIType2D(options.relation);\n const orientation = normalizeUIType2D(options.orientation);\n\n return {\n h: new UIHorizontalDistanceConstraint(a, b, {\n anchorA: anchorA.h,\n anchorB: anchorB.h,\n distance: distance.h,\n priority: priority.h,\n relation: relation.h,\n orientation: orientation.h,\n }),\n v: new UIVerticalDistanceConstraint(a, b, {\n anchorA: anchorA.v,\n anchorB: anchorB.v,\n distance: distance.v,\n priority: priority.v,\n relation: relation.v,\n orientation: orientation.v,\n }),\n };\n }\n\n /**\n * Creates horizontal and vertical proportion constraints.\n * @param a Element with proportional dimensions\n * @param b Target element\n * @param options Proportion configuration for both axes\n * @returns Horizontal and vertical proportion constraints\n */\n public static proportion(\n a: UIPlaneElement,\n b: UIPlaneElement,\n options: Partial<UIConstraintProportion2DOptions> = {},\n ): UIConstraint2DResult<\n UIHorizontalProportionConstraint,\n UIVerticalProportionConstraint\n > {\n const proportion = normalizeUIType2D(options.proportion);\n const priority = normalizeUIType2D(options.priority);\n const relation = normalizeUIType2D(options.relation);\n const orientation = normalizeUIType2D(options.orientation);\n\n return {\n h: new UIHorizontalProportionConstraint(a, b, {\n proportion: proportion.h,\n priority: priority.h,\n relation: relation.h,\n orientation: orientation.h,\n }),\n v: new UIVerticalProportionConstraint(a, b, {\n proportion: proportion.v,\n priority: priority.v,\n relation: relation.v,\n orientation: orientation.v,\n }),\n };\n }\n\n /**\n * Creates horizontal and vertical interpolation constraints.\n * @param a First element\n * @param b Second element\n * @param c Element to position between A and B\n * @param options Interpolation configuration for both axes\n * @returns Horizontal and vertical interpolation constraints\n */\n public static interpolation(\n a: UIPointElement | UIPlaneElement,\n b: UIPointElement | UIPlaneElement,\n c: UIPointElement | UIPlaneElement,\n options: Partial<UIConstraintInterpolation2DOptions> = {},\n ): UIConstraint2DResult<\n UIHorizontalInterpolationConstraint,\n UIVerticalInterpolationConstraint\n > {\n const anchorA = normalizeUIType2D(options.anchorA);\n const anchorB = normalizeUIType2D(options.anchorB);\n const anchorC = normalizeUIType2D(options.anchorC);\n const t = normalizeUIType2D(options.t);\n const priority = normalizeUIType2D(options.priority);\n const relation = normalizeUIType2D(options.relation);\n const orientation = normalizeUIType2D(options.orientation);\n\n return {\n h: new UIHorizontalInterpolationConstraint(a, b, c, {\n anchorA: anchorA.h,\n anchorB: anchorB.h,\n anchorC: anchorC.h,\n t: t.h,\n priority: priority.h,\n relation: relation.h,\n orientation: orientation.h,\n }),\n v: new UIVerticalInterpolationConstraint(a, b, c, {\n anchorA: anchorA.v,\n anchorB: anchorB.v,\n anchorC: anchorC.v,\n t: t.v,\n priority: priority.v,\n relation: relation.v,\n orientation: orientation.v,\n }),\n };\n }\n}\n","import { assertValidPositiveNumber } from \"../../miscellaneous/asserts\";\nimport type {\n UILayerElement,\n UIPlaneElement,\n} from \"../../miscellaneous/shared\";\nimport { UIExpression } from \"../../miscellaneous/UIExpression\";\nimport { UISingleParameterConstraint } from \"../UISingleParameterConstraint/UISingleParameterConstraint\";\nimport type { UIAspectConstraintOptions } from \"./UIAspectConstraint.Internal\";\n\n/** Maintains element aspect ratio (width = height * aspect) */\nexport class UIAspectConstraint extends UISingleParameterConstraint {\n /** Solver constraint descriptor */\n protected override readonly constraint: number;\n\n /** Current aspect ratio */\n private aspectInternal: number;\n\n /**\n * @param element Element to constrain\n * @param options Aspect configuration. Defaults to element's current ratio.\n */\n constructor(\n private readonly element: UIPlaneElement & UILayerElement,\n options: Partial<UIAspectConstraintOptions> = {},\n ) {\n if (options.aspect !== undefined) {\n assertValidPositiveNumber(\n options.aspect,\n \"UIAspectConstraint.constructor.options.aspect\",\n );\n }\n\n super(element.layer, options);\n\n this.aspectInternal = options.aspect ?? element.width / element.height;\n this.constraint = this.solverWrapper.createConstraint(\n this.buildLHS(),\n new UIExpression(0),\n this.relation,\n this.priority,\n this.isConstraintEnabled(),\n );\n }\n\n /** Current aspect ratio (width/height) */\n public get aspect(): number {\n return this.aspectInternal;\n }\n\n /** Updates aspect ratio */\n public set aspect(value: number) {\n assertValidPositiveNumber(value, \"UIAspectConstraint.aspect\");\n if (this.aspectInternal !== value) {\n this.aspectInternal = value;\n this.solverWrapper.setConstraintLHS(this.constraint, this.buildLHS());\n }\n }\n\n /** Builds constraint expression: width - (height * aspect) = 0 */\n private buildLHS(): UIExpression {\n return new UIExpression(0, [\n [this.element.wVariable, 1],\n [this.element.hVariable, -this.aspectInternal],\n ]);\n }\n}\n","import type { UIOrientation } from \"../../miscellaneous/UIOrientation\";\n\nexport const COVER_CONSTRAINT_DEFAULT_ANCHOR = 0.5;\n\n/** Cover constraint builder options */\nexport interface UICoverConstraintBuilderOptions {\n /** Whether to maintain active element aspect ratio */\n keepActiveAspect: boolean;\n /** Horizontal anchor (0 = left, 0.5 = center, 1 = right) */\n anchorH: number;\n /** Vertical anchor (0 = bottom, 0.5 = center, 1 = top) */\n anchorV: number;\n /** Orientation for constraints */\n orientation: UIOrientation;\n}\n","import { assertValidNumber } from \"../../miscellaneous/asserts\";\nimport type {\n UILayerElement,\n UIPlaneElement,\n} from \"../../miscellaneous/shared\";\nimport { UIPriority } from \"../../miscellaneous/UIPriority\";\nimport { UIRelation } from \"../../miscellaneous/UIRelation\";\nimport { UIAspectConstraint } from \"../UIAspectConstraint/UIAspectConstraint\";\nimport { UIHorizontalDistanceConstraint } from \"../UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint\";\nimport { UIHorizontalProportionConstraint } from \"../UIHorizontalProportionConstraint/UIHorizontalProportionConstraint\";\nimport { UIVerticalDistanceConstraint } from \"../UIVerticalDistanceConstraint/UIVerticalDistanceConstraint\";\nimport { UIVerticalProportionConstraint } from \"../UIVerticalProportionConstraint/UIVerticalProportionConstraint\";\nimport type { UICoverConstraintBuilderOptions } from \"./UICoverConstraintBuilder.Internal\";\nimport { COVER_CONSTRAINT_DEFAULT_ANCHOR } from \"./UICoverConstraintBuilder.Internal\";\n\n/** Builder for cover layout (like CSS object-fit: cover) */\nexport class UICoverConstraintBuilder {\n /**\n * Creates cover layout constraints.\n * @param passive Container element\n * @param active Content element that covers container\n * @param options Cover configuration\n * @returns Created constraints\n */\n public static build(\n passive: UIPlaneElement,\n active: UIPlaneElement & UILayerElement,\n options: Partial<UICoverConstraintBuilderOptions> = {},\n ): {\n /** Aspect constraint if keepActiveAspect is true */\n activeAspectConstraint?: UIAspectConstraint;\n /** Horizontal position constraint */\n xConstraint: UIHorizontalDistanceConstraint;\n /** Vertical position constraint */\n yConstraint: UIVerticalDistanceConstraint;\n /** Width constraint (ensures coverage) */\n widthConstraint: UIHorizontalProportionConstraint;\n /** Height constraint (ensures coverage) */\n heightConstraint: UIVerticalProportionConstraint;\n } {\n if (options.anchorH !== undefined) {\n assertValidNumber(\n options.anchorH,\n \"UICoverConstraintBuilder.build.anchorH\",\n );\n }\n if (options.anchorV !== undefined) {\n assertValidNumber(\n options.anchorV,\n \"UICoverConstraintBuilder.build.anchorV\",\n );\n }\n\n let activeAspectConstraint: UIAspectConstraint | undefined;\n if (options.keepActiveAspect === true) {\n activeAspectConstraint = new UIAspectConstraint(active, {\n orientation: options.orientation,\n });\n }\n\n const xConstraint = new UIHorizontalDistanceConstraint(passive, active, {\n anchorA: options.anchorH ?? COVER_CONSTRAINT_DEFAULT_ANCHOR,\n anchorB: options.anchorH ?? COVER_CONSTRAINT_DEFAULT_ANCHOR,\n orientation: options.orientation,\n });\n\n const yConstraint = new UIVerticalDistanceConstraint(passive, active, {\n anchorA: options.anchorV ?? COVER_CONSTRAINT_DEFAULT_ANCHOR,\n anchorB: options.anchorV ?? COVER_CONSTRAINT_DEFAULT_ANCHOR,\n orientation: options.orientation,\n });\n\n const widthConstraint = new UIHorizontalProportionConstraint(\n passive,\n active,\n {\n proportion: 1,\n relation: UIRelation.GREATER_THAN,\n orientation: options.orientation,\n },\n );\n\n const heightConstraint = new UIVerticalProportionConstraint(\n passive,\n active,\n {\n proportion: 1,\n priority: UIPriority.P1,\n orientation: options.orientation,\n },\n );\n\n return {\n activeAspectConstraint,\n xConstraint,\n yConstraint,\n widthConstraint,\n heightConstraint,\n };\n }\n}\n","import type { UIOrientation } from \"../../miscellaneous/UIOrientation\";\n\nexport const DEFAULT_ANCHOR = 0.5;\n\n/** Fit constraint builder options */\nexport interface UIFitConstraintBuilderOptions {\n /** Whether to maintain active element aspect ratio */\n keepActiveAspect: boolean;\n /** Horizontal anchor (0 = left, 0.5 = center, 1 = right) */\n anchorH: number;\n /** Vertical anchor (0 = bottom, 0.5 = center, 1 = top) */\n anchorV: number;\n /** Orientation for constraints */\n orientation: UIOrientation;\n}\n","import { assertValidNumber } from \"../../miscellaneous/asserts\";\nimport type {\n UILayerElement,\n UIPlaneElement,\n} from \"../../miscellaneous/shared\";\nimport { UIPriority } from \"../../miscellaneous/UIPriority\";\nimport { UIRelation } from \"../../miscellaneous/UIRelation\";\nimport { UIAspectConstraint } from \"../UIAspectConstraint/UIAspectConstraint\";\nimport { UIHorizontalDistanceConstraint } from \"../UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint\";\nimport { UIHorizontalProportionConstraint } from \"../UIHorizontalProportionConstraint/UIHorizontalProportionConstraint\";\nimport { UIVerticalDistanceConstraint } from \"../UIVerticalDistanceConstraint/UIVerticalDistanceConstraint\";\nimport { UIVerticalProportionConstraint } from \"../UIVerticalProportionConstraint/UIVerticalProportionConstraint\";\nimport type { UIFitConstraintBuilderOptions } from \"./UIFitConstraintBuilder.Internal\";\nimport { DEFAULT_ANCHOR } from \"./UIFitConstraintBuilder.Internal\";\n\n/** Builder for fit layout (like CSS object-fit: contain) */\nexport class UIFitConstraintBuilder {\n /**\n * Creates fit layout constraints.\n * @param passive Container element\n * @param active Content element that fits within container\n * @param options Fit configuration\n * @returns Created constraints\n */\n public static build(\n passive: UIPlaneElement,\n active: UIPlaneElement & UILayerElement,\n options: Partial<UIFitConstraintBuilderOptions> = {},\n ): {\n /** Aspect constraint if keepActiveAspect is true */\n activeAspectConstraint?: UIAspectConstraint;\n /** Horizontal position constraint */\n xConstraint: UIHorizontalDistanceConstraint;\n /** Vertical position constraint */\n yConstraint: UIVerticalDistanceConstraint;\n /** Width constraint (ensures fitting) */\n widthConstraint: UIHorizontalProportionConstraint;\n /** Height constraint (ensures fitting) */\n heightConstraint: UIVerticalProportionConstraint;\n } {\n if (options.anchorH !== undefined) {\n assertValidNumber(\n options.anchorH,\n \"UIFitConstraintBuilder.build.anchorH\",\n );\n }\n if (options.anchorV !== undefined) {\n assertValidNumber(\n options.anchorV,\n \"UIFitConstraintBuilder.build.anchorV\",\n );\n }\n\n let activeAspectConstraint: UIAspectConstraint | undefined;\n if (options.keepActiveAspect === true) {\n activeAspectConstraint = new UIAspectConstraint(active, {\n orientation: options.orientation,\n });\n }\n\n const xConstraint = new UIHorizontalDistanceConstraint(passive, active, {\n anchorA: options.anchorH ?? DEFAULT_ANCHOR,\n anchorB: options.anchorH ?? DEFAULT_ANCHOR,\n orientation: options.orientation,\n });\n\n const yConstraint = new UIVerticalDistanceConstraint(passive, active, {\n anchorA: options.anchorV ?? DEFAULT_ANCHOR,\n anchorB: options.anchorV ?? DEFAULT_ANCHOR,\n orientation: options.orientation,\n });\n\n const widthConstraint = new UIHorizontalProportionConstraint(\n passive,\n active,\n {\n proportion: 1,\n relation: UIRelation.LESS_THAN,\n orientation: options.orientation,\n },\n );\n\n const heightConstraint = new UIVerticalProportionConstraint(\n passive,\n active,\n {\n proportion: 1,\n priority: UIPriority.P1,\n orientation: options.orientation,\n },\n );\n\n return {\n activeAspectConstraint,\n xConstraint,\n yConstraint,\n widthConstraint,\n heightConstraint,\n };\n }\n}\n","import type { UILayer } from \"../layers/UILayer/UILayer\";\nimport type { UIExpression } from \"../miscellaneous/UIExpression\";\nimport { UISingleParameterConstraint } from \"./UISingleParameterConstraint/UISingleParameterConstraint\";\nimport type { UISingleParameterConstraintOptions } from \"./UISingleParameterConstraint/UISingleParameterConstraint.Internal\";\n\n/** Constraint with custom LHS and RHS expressions */\nexport class UICustomConstraint extends UISingleParameterConstraint {\n /** Solver constraint descriptor */\n protected override readonly constraint: number;\n /** Left-hand side expression */\n private lhsInternal: UIExpression;\n /** Right-hand side expression */\n private rhsInternal: UIExpression;\n\n /**\n * @param layer Layer containing this constraint\n * @param lhs Left-hand side expression\n * @param rhs Right-hand side expression\n * @param options Constraint configuration\n */\n constructor(\n layer: UILayer,\n lhs: UIExpression,\n rhs: UIExpression,\n options: Partial<UISingleParameterConstraintOptions> = {},\n ) {\n super(layer, options);\n\n this.lhsInternal = lhs;\n this.rhsInternal = rhs;\n\n this.constraint = this.solverWrapper.createConstraint(\n this.lhsInternal,\n this.rhsInternal,\n this.relation,\n this.priority,\n this.isConstraintEnabled(),\n );\n }\n\n /** Left-hand side expression */\n public get lhs(): UIExpression {\n return this.lhsInternal;\n }\n\n /** Right-hand side expression */\n public get rhs(): UIExpression {\n return this.rhsInternal;\n }\n\n /** Updates left-hand side expression */\n public setLHS(value: UIExpression): void {\n this.lhsInternal = value;\n this.solverWrapper.setConstraintLHS(this.constraint, this.lhsInternal);\n }\n\n /** Updates right-hand side expression */\n public setRHS(value: UIExpression): void {\n this.rhsInternal = value;\n this.solverWrapper.setConstraintRHS(this.constraint, this.rhsInternal);\n }\n}\n","import { Eventail } from \"eventail\";\nimport type { UILayer } from \"../../layers/UILayer/UILayer\";\nimport { assertValidNumber } from \"../../miscellaneous/asserts\";\nimport type {\n UILayerElement,\n UIPointElement,\n} from \"../../miscellaneous/shared\";\nimport { UIPriority } from \"../../miscellaneous/UIPriority\";\nimport type { UISolverWrapperInterface } from \"../../wrappers/UISolverWrapper.Internal\";\nimport type { UIAnchorOptions } from \"./UIAnchor.Internal\";\nimport { ANCHOR_DEFAULT_X, ANCHOR_DEFAULT_Y } from \"./UIAnchor.Internal\";\n\n/** Point in 2D space with constraint-based positioning */\nexport class UIAnchor\n extends Eventail\n implements UILayerElement, UIPointElement\n{\n /** Optional identifier for debugging */\n public name = \"\";\n\n /** Solver variable for x coordinate */\n public readonly xVariable: number;\n\n /** Solver variable for y coordinate */\n public readonly yVariable: number;\n\n protected readonly solverWrapper: UISolverWrapperInterface;\n\n /**\n * Creates a new UIAnchor instance.\n *\n * @param layer - Layer containing this anchor\n * @param options - Configuration options\n */\n constructor(\n public readonly layer: UILayer,\n options?: Partial<UIAnchorOptions>,\n ) {\n const x = options?.x ?? ANCHOR_DEFAULT_X;\n const y = options?.y ?? ANCHOR_DEFAULT_Y;\n assertValidNumber(x, \"UIAnchor.constructor.options.x\");\n assertValidNumber(y, \"UIAnchor.constructor.options.y\");\n\n super();\n this.solverWrapper = this.layer.solverWrapper;\n this.xVariable = this.solverWrapper.createVariable(x, UIPriority.P7);\n this.yVariable = this.solverWrapper.createVariable(y, UIPriority.P7);\n }\n\n /** X coordinate relative to layer origin (bottom-left) */\n public get x(): number {\n return this.solverWrapper.readVariableValue(this.xVariable);\n }\n\n /** Y coordinate relative to layer origin (bottom-left) */\n public get y(): number {\n return this.solverWrapper.readVariableValue(this.yVariable);\n }\n\n /** X coordinate relative to layer origin (bottom-left) */\n public set x(value: number) {\n assertValidNumber(value, \"UIAnchor.x\");\n this.solverWrapper.suggestVariableValue(this.xVariable, value);\n }\n\n /** Y coordinate relative to layer origin (bottom-left) */\n public set y(value: number) {\n assertValidNumber(value, \"UIAnchor.y\");\n this.solverWrapper.suggestVariableValue(this.yVariable, value);\n }\n\n /** Removes anchor and frees resources */\n public destroy(): void {\n this.solverWrapper.removeVariable(this.yVariable);\n this.solverWrapper.removeVariable(this.xVariable);\n }\n}\n","/** Configuration options for UIAnchor */\nexport interface UIAnchorOptions {\n /** X coordinate in world units */\n x: number;\n /** Y coordinate in world units */\n y: number;\n}\n\nexport const ANCHOR_DEFAULT_X = 0;\nexport const ANCHOR_DEFAULT_Y = 0;\n","/** Controls which transforms apply relative to anchor */\nexport enum UIMicroAnchorMode {\n /** Apply rotation and scale around anchor point */\n ROTATION_SCALE = 0,\n /** Apply position, rotation, and scale around anchor point */\n POSITION_ROTATION_SCALE = 1,\n}\n\n/** Configuration options for UIMicro */\nexport interface UIMicroConfig {\n /** X offset in world units */\n x: number;\n /** Y offset in world units */\n y: number;\n /** X anchor in normalized coordinates (0 to 1) */\n anchorX: number;\n /** Y anchor in normalized coordinates (0 to 1) */\n anchorY: number;\n /** X scale multiplier */\n scaleX: number;\n /** Y scale multiplier */\n scaleY: number;\n /** Rotation in radians */\n rotation: number;\n /** Which transforms apply relative to anchor */\n anchorMode: UIMicroAnchorMode;\n}\n\nexport const MICRO_DEFAULT_POSITION = 0;\nexport const MICRO_DEFAULT_ANCHOR = 0.5;\nexport const MICRO_DEFAULT_SCALE = 1;\nexport const MICRO_DEFAULT_ROTATION = 0;\nexport const MICRO_DEFAULT_ANCHOR_MODE = UIMicroAnchorMode.ROTATION_SCALE;\n","import { Matrix4, Quaternion, Vector3 } from \"three\";\nimport { UIMicroAnchorMode } from \"../miscellaneous/micro/UIMicro.Internal\";\n\nconst TEMP_POSITION = new Vector3();\nconst TEMP_QUATERNION = new Quaternion();\nconst TEMP_SCALE = new Vector3();\nconst TEMP_MATRIX = new Matrix4();\nconst Z_AXIS = new Vector3(0, 0, 1);\n\n/**\n * Computes element transform matrix.\n * @returns Transform matrix (reused, do not store reference)\n */\nexport function computeTransformMatrix(\n x: number,\n y: number,\n width: number,\n height: number,\n zIndex: number,\n microX: number,\n microY: number,\n microAnchorX: number,\n microAnchorY: number,\n microScaleX: number,\n microScaleY: number,\n microRotation: number,\n microAnchorMode: UIMicroAnchorMode,\n): Matrix4 {\n const scaledWidth = width * microScaleX;\n const scaledHeight = height * microScaleY;\n\n const anchorOffsetX = microAnchorX * scaledWidth;\n const anchorOffsetY = microAnchorY * scaledHeight;\n\n const cos = Math.cos(microRotation);\n const sin = Math.sin(microRotation);\n\n const rotatedAnchorX = anchorOffsetX * cos - anchorOffsetY * sin;\n const rotatedAnchorY = anchorOffsetX * sin + anchorOffsetY * cos;\n\n if (microAnchorMode === UIMicroAnchorMode.POSITION_ROTATION_SCALE) {\n TEMP_POSITION.x = x + microX - rotatedAnchorX;\n TEMP_POSITION.y = y + microY - rotatedAnchorY;\n } else {\n const rawAnchorOffsetX = microAnchorX * width;\n const rawAnchorOffsetY = microAnchorY * height;\n TEMP_POSITION.x = x + rawAnchorOffsetX - rotatedAnchorX + microX;\n TEMP_POSITION.y = y + rawAnchorOffsetY - rotatedAnchorY + microY;\n }\n\n TEMP_POSITION.z = zIndex;\n TEMP_SCALE.x = scaledWidth;\n TEMP_SCALE.y = scaledHeight;\n TEMP_QUATERNION.setFromAxisAngle(Z_AXIS, microRotation);\n\n TEMP_MATRIX.compose(TEMP_POSITION, TEMP_QUATERNION, TEMP_SCALE);\n return TEMP_MATRIX;\n}\n\n/**\n * Computes transform matrix for trimmed sprite.\n * @param width Source width including trimmed areas\n * @param height Source height including trimmed areas\n * @param trimLeft Pixels trimmed from left\n * @param trimRight Pixels trimmed from right\n * @param trimTop Pixels trimmed from top\n * @param trimBottom Pixels trimmed from bottom\n * @returns Transform matrix (reused, do not store reference)\n */\nexport function computeTrimmedTransformMatrix(\n x: number,\n y: number,\n width: number,\n height: number,\n zIndex: number,\n microX: number,\n microY: number,\n microAnchorX: number,\n microAnchorY: number,\n microScaleX: number,\n microScaleY: number,\n microRotation: number,\n microAnchorMode: UIMicroAnchorMode,\n trimLeft: number,\n trimRight: number,\n trimTop: number,\n trimBottom: number,\n): Matrix4 {\n const trimmedWidth = width - trimLeft - trimRight;\n const trimmedHeight = height - trimTop - trimBottom;\n\n const scaledWidth = width * microScaleX;\n const scaledHeight = height * microScaleY;\n\n const anchorOffsetX = microAnchorX * scaledWidth;\n const anchorOffsetY = microAnchorY * scaledHeight;\n\n const cos = Math.cos(microRotation);\n const sin = Math.sin(microRotation);\n\n const rotatedAnchorX = anchorOffsetX * cos - anchorOffsetY * sin;\n const rotatedAnchorY = anchorOffsetX * sin + anchorOffsetY * cos;\n\n const trimOffsetX = trimLeft * microScaleX;\n const trimOffsetY = trimBottom * microScaleY;\n\n const rotatedTrimX = trimOffsetX * cos - trimOffsetY * sin;\n const rotatedTrimY = trimOffsetX * sin + trimOffsetY * cos;\n\n if (microAnchorMode === UIMicroAnchorMode.POSITION_ROTATION_SCALE) {\n TEMP_POSITION.x = x + microX - rotatedAnchorX + rotatedTrimX;\n TEMP_POSITION.y = y + microY - rotatedAnchorY + rotatedTrimY;\n } else {\n const rawAnchorOffsetX = microAnchorX * width;\n const rawAnchorOffsetY = microAnchorY * height;\n TEMP_POSITION.x =\n x + rawAnchorOffsetX - rotatedAnchorX + microX + rotatedTrimX;\n TEMP_POSITION.y =\n y + rawAnchorOffsetY - rotatedAnchorY + microY + rotatedTrimY;\n }\n\n TEMP_POSITION.z = zIndex;\n TEMP_SCALE.x = trimmedWidth * microScaleX;\n TEMP_SCALE.y = trimmedHeight * microScaleY;\n TEMP_QUATERNION.setFromAxisAngle(Z_AXIS, microRotation);\n\n TEMP_MATRIX.compose(TEMP_POSITION, TEMP_QUATERNION, TEMP_SCALE);\n return TEMP_MATRIX;\n}\n","import { Texture } from \"three\";\n\nexport const TEXTURE_DEFAULT_TEXTURE = new Texture();\nexport const TEXTURE_DEFAULT_SIZE = 2;\n\n/** Events emitted by UITexture */\nexport enum UITextureViewEvent {\n /** Emitted when width or height changes */\n DIMENSIONS_CHANGED = 0,\n}\n\n/** Rectangle coordinates and dimensions in atlas */\nexport interface UITextureRect {\n /** X coordinate in pixels */\n x: number;\n /** Y coordinate in pixels */\n y: number;\n /** Width in pixels */\n w: number;\n /** Height in pixels */\n h: number;\n}\n\n/** Size dimensions */\nexport interface UITextureSize {\n /** Width in pixels */\n w: number;\n /** Height in pixels */\n h: number;\n}\n\n/** Transparent padding around visible content */\nexport interface UITextureTrim {\n /** Left padding in world units */\n left: number;\n /** Right padding in world units */\n right: number;\n /** Top padding in world units */\n top: number;\n /** Bottom padding in world units */\n bottom: number;\n}\n\n/** Configuration for texture atlas sprite */\nexport interface UITextureAtlasConfig {\n /** Source texture atlas */\n texture: Texture;\n /** Rectangle in atlas containing sprite */\n frame: UITextureRect;\n /** Whether sprite is rotated 90 degrees clockwise */\n rotated?: boolean;\n /** Position and size within original image before trimming */\n spriteSourceSize: UITextureRect;\n /** Original image dimensions before trimming */\n sourceSize: UITextureSize;\n /** Scale factor for resolution independence */\n scale?: number;\n}\n\n/** Texture configuration from direct texture or atlas sprite */\nexport type UITextureConfig = Texture | UITextureAtlasConfig;\n","import { Eventail } from \"eventail\";\nimport { Matrix3, Texture, Vector2 } from \"three\";\nimport {\n assertValidNonNegativeNumber,\n assertValidPositiveNumber,\n} from \"../asserts\";\nimport type {\n UITextureAtlasConfig,\n UITextureConfig,\n UITextureTrim,\n} from \"./UITextureView.Internal\";\nimport {\n TEXTURE_DEFAULT_SIZE,\n TEXTURE_DEFAULT_TEXTURE,\n UITextureViewEvent,\n} from \"./UITextureView.Internal\";\n\n/** Wrapper for Three.js texture with atlas and trim support. Does not own the underlying texture; user must dispose it. */\nexport class UITextureView extends Eventail {\n private textureInternal: Texture = TEXTURE_DEFAULT_TEXTURE;\n\n private sourceWidth = TEXTURE_DEFAULT_SIZE;\n private sourceHeight = TEXTURE_DEFAULT_SIZE;\n\n private frameX = 0;\n private frameY = 0;\n private frameWidth = TEXTURE_DEFAULT_SIZE;\n private frameHeight = TEXTURE_DEFAULT_SIZE;\n\n private rotatedInternal = false;\n private scaleInternal = 1;\n\n private trimLeft = 0;\n private trimRight = 0;\n private trimTop = 0;\n private trimBottom = 0;\n\n private textureDirtyInternal = false;\n private uvTransformDirtyInternal = false;\n private trimDirtyInternal = false;\n\n /** @param config Texture or atlas configuration */\n constructor(config?: UITextureConfig) {\n super();\n if (config !== undefined) {\n this.set(config);\n }\n }\n\n /** Original width before trimming in world units */\n public get width(): number {\n return this.sourceWidth / this.scaleInternal;\n }\n\n /** Original height before trimming in world units */\n public get height(): number {\n return this.sourceHeight / this.scaleInternal;\n }\n\n /** Visible width after trimming in world units */\n public get trimmedWidth(): number {\n const frameSize = this.rotatedInternal ? this.frameHeight : this.frameWidth;\n return frameSize / this.scaleInternal;\n }\n\n /** Visible height after trimming in world units */\n public get trimmedHeight(): number {\n const frameSize = this.rotatedInternal ? this.frameWidth : this.frameHeight;\n return frameSize / this.scaleInternal;\n }\n\n /** Underlying Three.js texture */\n public get texture(): Texture {\n return this.textureInternal;\n }\n\n /** Whether sprite is rotated in atlas */\n public get rotated(): boolean {\n return this.rotatedInternal;\n }\n\n /** Scale factor for resolution independence */\n public get scale(): number {\n return this.scaleInternal;\n }\n\n /** Transparent padding around visible content */\n public get trim(): Readonly<UITextureTrim> {\n const scale = this.scaleInternal;\n return {\n left: this.trimLeft / scale,\n right: this.trimRight / scale,\n top: this.trimTop / scale,\n bottom: this.trimBottom / scale,\n };\n }\n\n public get textureDirty(): boolean {\n return this.textureDirtyInternal;\n }\n\n /** Whether UV transform inputs changed since last check */\n public get uvTransformDirty(): boolean {\n return this.uvTransformDirtyInternal;\n }\n\n /** Whether trim values changed since last check */\n public get trimDirty(): boolean {\n return this.trimDirtyInternal;\n }\n\n public setTextureDirtyFalse(): void {\n this.textureDirtyInternal = false;\n }\n\n /** Marks UV transform as clean. @internal */\n public setUVTransformDirtyFalse(): void {\n this.uvTransformDirtyInternal = false;\n }\n\n /** Marks trim as clean. @internal */\n public setTrimDirtyFalse(): void {\n this.trimDirtyInternal = false;\n }\n\n /**\n * Calculates UV transform matrix for shader sampling.\n * @param result Matrix to store result in\n * @returns UV transform matrix\n */\n public calculateUVTransform(result = new Matrix3()): Matrix3 {\n const atlasWidth =\n this.textureInternal.image?.naturalWidth ?? TEXTURE_DEFAULT_SIZE;\n const atlasHeight =\n this.textureInternal.image?.naturalHeight ?? TEXTURE_DEFAULT_SIZE;\n\n if (this.rotatedInternal) {\n const physicalWidth = this.frameHeight;\n const physicalHeight = this.frameWidth;\n\n const u0 = this.frameX / atlasWidth;\n const v0 = (atlasHeight - this.frameY - physicalHeight) / atlasHeight;\n const uSize = physicalWidth / atlasWidth;\n const vSize = physicalHeight / atlasHeight;\n\n result.set(0, uSize, u0, -vSize, 0, v0 + vSize, 0, 0, 1);\n } else {\n const u0 = this.frameX / atlasWidth;\n const v0 = (atlasHeight - this.frameY - this.frameHeight) / atlasHeight;\n const uSize = this.frameWidth / atlasWidth;\n const vSize = this.frameHeight / atlasHeight;\n\n result.set(uSize, 0, u0, 0, vSize, v0, 0, 0, 1);\n }\n\n return result;\n }\n\n /**\n * Gets original dimensions before trimming.\n * @param result Vector to store result in\n * @returns Width and height in world units\n */\n public getResolution(result = new Vector2()): Vector2 {\n return result.set(this.width, this.height);\n }\n\n /**\n * Replaces texture with new configuration.\n * @param config Texture or atlas configuration\n */\n public set(config: UITextureConfig): void {\n const lastWidth = this.width;\n const lastHeight = this.height;\n\n if (config instanceof Texture) {\n this.setFromTexture(config);\n } else {\n this.setFromAtlasConfig(config);\n }\n\n if (this.width !== lastWidth || this.height !== lastHeight) {\n this.emit(\n UITextureViewEvent.DIMENSIONS_CHANGED,\n this.width,\n this.height,\n this,\n );\n }\n }\n\n private setFromTexture(texture: Texture): void {\n const width = texture.image?.naturalWidth ?? TEXTURE_DEFAULT_SIZE;\n const height = texture.image?.naturalHeight ?? TEXTURE_DEFAULT_SIZE;\n\n this.sourceWidth = width;\n this.sourceHeight = height;\n\n if (this.texture !== texture) {\n this.textureInternal = texture;\n this.textureDirtyInternal = true;\n }\n\n if (\n this.frameX !== 0 ||\n this.frameY !== 0 ||\n this.frameWidth !== width ||\n this.frameHeight !== height ||\n this.scaleInternal !== 1 ||\n this.rotatedInternal\n ) {\n this.frameX = 0;\n this.frameY = 0;\n this.frameWidth = width;\n this.frameHeight = height;\n this.rotatedInternal = false;\n this.scaleInternal = 1;\n this.uvTransformDirtyInternal = true;\n }\n\n if (\n this.trimLeft !== 0 ||\n this.trimRight !== 0 ||\n this.trimTop !== 0 ||\n this.trimBottom !== 0\n ) {\n this.trimLeft = 0;\n this.trimRight = 0;\n this.trimTop = 0;\n this.trimBottom = 0;\n this.trimDirtyInternal = true;\n }\n }\n\n private setFromAtlasConfig(config: UITextureAtlasConfig): void {\n assertValidPositiveNumber(\n config.sourceSize.w,\n \"UITextureView.setFromAtlasConfig.config.sourceSize.w\",\n );\n assertValidPositiveNumber(\n config.sourceSize.h,\n \"UITextureView.setFromAtlasConfig.config.sourceSize.h\",\n );\n assertValidNonNegativeNumber(\n config.frame.x,\n \"UITextureView.setFromAtlasConfig.config.frame.x\",\n );\n assertValidNonNegativeNumber(\n config.frame.y,\n \"UITextureView.setFromAtlasConfig.config.frame.y\",\n );\n assertValidPositiveNumber(\n config.frame.w,\n \"UITextureView.setFromAtlasConfig.config.frame.w\",\n );\n assertValidPositiveNumber(\n config.frame.h,\n \"UITextureView.setFromAtlasConfig.config.frame.h\",\n );\n assertValidNonNegativeNumber(\n config.spriteSourceSize.x,\n \"UITextureView.setFromAtlasConfig.config.spriteSourceSize.x\",\n );\n assertValidNonNegativeNumber(\n config.spriteSourceSize.y,\n \"UITextureView.setFromAtlasConfig.config.spriteSourceSize.y\",\n );\n assertValidPositiveNumber(\n config.spriteSourceSize.w,\n \"UITextureView.setFromAtlasConfig.config.spriteSourceSize.w\",\n );\n assertValidPositiveNumber(\n config.spriteSourceSize.h,\n \"UITextureView.setFromAtlasConfig.config.spriteSourceSize.h\",\n );\n\n if (config.scale !== undefined) {\n assertValidPositiveNumber(\n config.scale,\n \"UITextureView.setFromAtlasConfig.config.scale\",\n );\n }\n\n this.sourceWidth = config.sourceSize.w;\n this.sourceHeight = config.sourceSize.h;\n\n if (this.texture !== config.texture) {\n this.textureInternal = config.texture;\n this.textureDirtyInternal = true;\n }\n\n const scale = config.scale ?? 1;\n const rotated = config.rotated ?? false;\n\n if (\n this.frameX !== 0 ||\n this.frameY !== 0 ||\n this.frameWidth !== config.frame.w ||\n this.frameHeight !== config.frame.h ||\n this.scaleInternal !== scale ||\n this.rotatedInternal !== rotated\n ) {\n this.frameX = config.frame.x;\n this.frameY = config.frame.y;\n this.frameWidth = config.frame.w;\n this.frameHeight = config.frame.h;\n this.scaleInternal = scale;\n this.rotatedInternal = rotated;\n this.uvTransformDirtyInternal = true;\n }\n\n const spriteSource = config.spriteSourceSize;\n const trimLeft = spriteSource.x;\n const trimTop = spriteSource.y;\n const trimRight = this.sourceWidth - spriteSource.x - spriteSource.w;\n const trimBottom = this.sourceHeight - spriteSource.y - spriteSource.h;\n\n if (\n this.trimLeft !== trimLeft ||\n this.trimRight !== trimRight ||\n this.trimTop !== trimTop ||\n this.trimBottom !== trimBottom\n ) {\n this.trimLeft = trimLeft;\n this.trimRight = trimRight;\n this.trimTop = trimTop;\n this.trimBottom = trimBottom;\n this.trimDirtyInternal = true;\n }\n }\n}\n","/** Input events emitted by UI elements */\nexport enum UIInputEvent {\n /** Pointer pressed */\n PRESSED = \"pointerdown\",\n /** Pointer moved */\n MOVED = \"pointermove\",\n /** Pointer released */\n RELEASED = \"pointerup\",\n /** Pointer entered element */\n ENTERED = \"pointerenter\",\n /** Pointer left element */\n LEFT = \"pointerleave\",\n}\n","import { MathUtils } from \"three\";\nimport { assertValidNumber } from \"../asserts\";\nimport type { UIMicroAnchorMode, UIMicroConfig } from \"./UIMicro.Internal\";\nimport {\n MICRO_DEFAULT_ANCHOR,\n MICRO_DEFAULT_ANCHOR_MODE,\n MICRO_DEFAULT_POSITION,\n MICRO_DEFAULT_ROTATION,\n MICRO_DEFAULT_SCALE,\n} from \"./UIMicro.Internal\";\n\n/** Transforms that don't affect constraints */\nexport class UIMicro {\n private xInternal: number;\n private yInternal: number;\n private anchorXInternal: number;\n private anchorYInternal: number;\n private scaleXInternal: number;\n private scaleYInternal: number;\n private rotationInternal: number;\n private anchorModeInternal: UIMicroAnchorMode;\n\n private dirtyInternal = true;\n\n /**\n * Creates UIMicro instance.\n *\n * @param config - Transform configuration\n */\n constructor(config?: Partial<UIMicroConfig>) {\n this.xInternal = config?.x ?? MICRO_DEFAULT_POSITION;\n this.yInternal = config?.y ?? MICRO_DEFAULT_POSITION;\n this.anchorXInternal = config?.anchorX ?? MICRO_DEFAULT_ANCHOR;\n this.anchorYInternal = config?.anchorY ?? MICRO_DEFAULT_ANCHOR;\n this.scaleXInternal = config?.scaleX ?? MICRO_DEFAULT_SCALE;\n this.scaleYInternal = config?.scaleY ?? MICRO_DEFAULT_SCALE;\n this.rotationInternal = config?.rotation ?? MICRO_DEFAULT_ROTATION;\n this.anchorModeInternal = config?.anchorMode ?? MICRO_DEFAULT_ANCHOR_MODE;\n }\n\n /** X offset in world units */\n public get x(): number {\n return this.xInternal;\n }\n\n /** Y offset in world units */\n public get y(): number {\n return this.yInternal;\n }\n\n /** X anchor in normalized coordinates (0 to 1) */\n public get anchorX(): number {\n return this.anchorXInternal;\n }\n\n /** Y anchor in normalized coordinates (0 to 1) */\n public get anchorY(): number {\n return this.anchorYInternal;\n }\n\n /** X scale multiplier */\n public get scaleX(): number {\n return this.scaleXInternal;\n }\n\n /** Y scale multiplier */\n public get scaleY(): number {\n return this.scaleYInternal;\n }\n\n /** Rotation in degrees */\n public get angle(): number {\n return MathUtils.radToDeg(this.rotationInternal);\n }\n\n /** Which transforms apply relative to anchor */\n public get anchorMode(): UIMicroAnchorMode {\n return this.anchorModeInternal;\n }\n\n /** Rotation in radians */\n public get rotation(): number {\n return this.rotationInternal;\n }\n\n /** @internal */\n public get dirty(): boolean {\n return this.dirtyInternal;\n }\n\n /** X offset in world units */\n public set x(value: number) {\n assertValidNumber(value, \"UIMicro.x\");\n if (value !== this.xInternal) {\n this.xInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n /** Y offset in world units */\n public set y(value: number) {\n assertValidNumber(value, \"UIMicro.y\");\n if (value !== this.yInternal) {\n this.yInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n /** X anchor in normalized coordinates (0 to 1) */\n public set anchorX(value: number) {\n assertValidNumber(value, \"UIMicro.anchorX\");\n if (value !== this.anchorXInternal) {\n this.anchorXInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n /** Y anchor in normalized coordinates (0 to 1) */\n public set anchorY(value: number) {\n assertValidNumber(value, \"UIMicro.anchorY\");\n if (value !== this.anchorYInternal) {\n this.anchorYInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n /** X scale multiplier */\n public set scaleX(value: number) {\n assertValidNumber(value, \"UIMicro.scaleX\");\n if (value !== this.scaleXInternal) {\n this.scaleXInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n /** Y scale multiplier */\n public set scaleY(value: number) {\n assertValidNumber(value, \"UIMicro.scaleY\");\n if (value !== this.scaleYInternal) {\n this.scaleYInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n /** Rotation in degrees */\n public set angle(value: number) {\n assertValidNumber(value, \"UIMicro.angle\");\n const rotation = MathUtils.degToRad(value);\n if (rotation !== this.rotationInternal) {\n this.rotationInternal = rotation;\n this.dirtyInternal = true;\n }\n }\n\n /** Rotation in radians */\n public set rotation(value: number) {\n assertValidNumber(value, \"UIMicro.rotation\");\n if (value !== this.rotationInternal) {\n this.rotationInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n /** Which transforms apply relative to anchor */\n public set anchorMode(value: UIMicroAnchorMode) {\n if (value !== this.anchorModeInternal) {\n this.anchorModeInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n /** @internal */\n public setDirtyFalse(): void {\n this.dirtyInternal = false;\n }\n\n /** Resets all transforms to defaults */\n public reset(): void {\n if (\n this.xInternal !== MICRO_DEFAULT_POSITION ||\n this.yInternal !== MICRO_DEFAULT_POSITION ||\n this.anchorXInternal !== MICRO_DEFAULT_ANCHOR ||\n this.anchorYInternal !== MICRO_DEFAULT_ANCHOR ||\n this.scaleXInternal !== MICRO_DEFAULT_SCALE ||\n this.scaleYInternal !== MICRO_DEFAULT_SCALE ||\n this.rotationInternal !== MICRO_DEFAULT_ROTATION\n ) {\n this.xInternal = MICRO_DEFAULT_POSITION;\n this.yInternal = MICRO_DEFAULT_POSITION;\n this.anchorXInternal = MICRO_DEFAULT_ANCHOR;\n this.anchorYInternal = MICRO_DEFAULT_ANCHOR;\n this.scaleXInternal = MICRO_DEFAULT_SCALE;\n this.scaleYInternal = MICRO_DEFAULT_SCALE;\n this.rotationInternal = MICRO_DEFAULT_ROTATION;\n this.dirtyInternal = true;\n }\n }\n\n /** Copies transforms from another instance */\n public copy(value: UIMicro): void {\n if (\n this.xInternal !== value.xInternal ||\n this.yInternal !== value.yInternal ||\n this.anchorXInternal !== value.anchorXInternal ||\n this.anchorYInternal !== value.anchorYInternal ||\n this.scaleXInternal !== value.scaleXInternal ||\n this.scaleYInternal !== value.scaleYInternal ||\n this.rotationInternal !== value.rotationInternal ||\n this.anchorModeInternal !== value.anchorModeInternal\n ) {\n this.xInternal = value.xInternal;\n this.yInternal = value.yInternal;\n this.anchorXInternal = value.anchorXInternal;\n this.anchorYInternal = value.anchorYInternal;\n this.scaleXInternal = value.scaleXInternal;\n this.scaleYInternal = value.scaleYInternal;\n this.rotationInternal = value.rotationInternal;\n this.anchorModeInternal = value.anchorModeInternal;\n this.dirtyInternal = true;\n }\n }\n}\n","/** Base class for interaction area shapes */\nexport abstract class UIArea {\n /** @internal */\n public abstract contains(pointX: number, pointY: number): boolean;\n}\n","import { assertValidNonNegativeNumber, assertValidNumber } from \"../asserts\";\nimport { UIArea } from \"./UIArea\";\n\n/** Rectangular interaction area */\nexport class UIAreaRectangle extends UIArea {\n /**\n * Creates rectangular area.\n *\n * @param x - X position in normalized coordinates (0 to 1)\n * @param y - Y position in normalized coordinates (0 to 1)\n * @param width - Width in normalized coordinates (0 to 1)\n * @param height - Height in normalized coordinates (0 to 1)\n */\n constructor(\n public x: number,\n public y: number,\n public width: number,\n public height: number,\n ) {\n super();\n assertValidNonNegativeNumber(x, \"UIAreaRectangle.constructor.x\");\n assertValidNonNegativeNumber(y, \"UIAreaRectangle.constructor.y\");\n assertValidNonNegativeNumber(width, \"UIAreaRectangle.constructor.width\");\n assertValidNonNegativeNumber(height, \"UIAreaRectangle.constructor.height\");\n }\n\n /** @internal */\n public contains(pointX: number, pointY: number): boolean {\n assertValidNumber(pointX, \"UIAreaRectangle.contains.pointX\");\n assertValidNumber(pointY, \"UIAreaRectangle.contains.pointY\");\n return (\n pointX >= this.x &&\n pointX <= this.x + this.width &&\n pointY >= this.y &&\n pointY <= this.y + this.height\n );\n }\n}\n","import type { UIArea } from \"../../miscellaneous/area/UIArea\";\nimport { UIMode } from \"../../miscellaneous/UIMode\";\nimport type { UIAnchorOptions } from \"../UIAnchor/UIAnchor.Internal\";\n\n/** Configuration options for UIInputDummy */\nexport interface UIInputDummyOptions extends UIAnchorOptions {\n /** Width in world units */\n width: number;\n /** Height in world units */\n height: number;\n /** Shape defining interactive region in normalized coordinates */\n interactionArea: UIArea;\n /** Controls visibility and interactivity */\n mode: UIMode;\n}\n\nexport const DUMMY_DEFAULT_WIDTH = 64;\nexport const DUMMY_DEFAULT_HEIGHT = 32;\nexport const DUMMY_DEFAULT_MODE = UIMode.VISIBLE;\nexport const DUMMY_DEFAULT_Z_INDEX = 0;\n","import { MathUtils } from \"three\";\nimport type { UILayer } from \"../../layers/UILayer/UILayer\";\nimport type { UIArea } from \"../../miscellaneous/area/UIArea\";\nimport { UIAreaRectangle } from \"../../miscellaneous/area/UIAreaRectangle\";\nimport {\n assertValidNumber,\n assertValidPositiveNumber,\n} from \"../../miscellaneous/asserts\";\nimport type { UIPlaneElement } from \"../../miscellaneous/shared\";\nimport { UIInputEvent } from \"../../miscellaneous/UIInputEvent\";\nimport { isUIModeInteractive, UIMode } from \"../../miscellaneous/UIMode\";\nimport { UIPriority } from \"../../miscellaneous/UIPriority\";\nimport type { UIInputWrapperInterface } from \"../../wrappers/UIInputWrapper.Internal\";\nimport { UIAnchor } from \"../UIAnchor/UIAnchor\";\nimport type { UIInputDummyOptions } from \"./UIInputDummy.Internal\";\nimport {\n DUMMY_DEFAULT_HEIGHT,\n DUMMY_DEFAULT_MODE,\n DUMMY_DEFAULT_WIDTH,\n DUMMY_DEFAULT_Z_INDEX,\n} from \"./UIInputDummy.Internal\";\n\n/** Rectangular area with dimensions but no rendering */\nexport class UIInputDummy extends UIAnchor implements UIPlaneElement {\n /** Shape defining interactive region in normalized coordinates */\n public interactionArea: UIArea;\n\n /** Solver variable for width */\n public readonly wVariable: number;\n\n /** Solver variable for height */\n public readonly hVariable: number;\n\n protected modeInternal: UIMode;\n protected readonly inputWrapper: UIInputWrapperInterface;\n private readonly catcherHandler: number;\n private lastPointerInside = false;\n\n /**\n * Creates a new UIInputDummy instance.\n *\n * @param layer - Layer containing this element\n * @param options - Configuration options\n */\n constructor(layer: UILayer, options?: Partial<UIInputDummyOptions>) {\n const w = options?.width ?? DUMMY_DEFAULT_WIDTH;\n const h = options?.height ?? DUMMY_DEFAULT_HEIGHT;\n\n assertValidPositiveNumber(w, \"UIInputDummy.constructor.width\");\n assertValidPositiveNumber(h, \"UIInputDummy.constructor.height\");\n\n super(layer, options);\n\n this.interactionArea =\n options?.interactionArea ?? new UIAreaRectangle(0, 0, 1, 1);\n this.modeInternal = options?.mode ?? DUMMY_DEFAULT_MODE;\n this.inputWrapper = this.layer.inputWrapper;\n\n this.wVariable = this.solverWrapper.createVariable(w, UIPriority.P6);\n this.hVariable = this.solverWrapper.createVariable(h, UIPriority.P6);\n\n this.catcherHandler = this.inputWrapper.createInputCatcher(\n this.catchPointerDown,\n this.catchPointerMove,\n this.catchPointerUp,\n DUMMY_DEFAULT_Z_INDEX,\n );\n\n this.inputWrapper.setActive(\n this.catcherHandler,\n isUIModeInteractive(this.modeInternal),\n );\n }\n\n /** Width in world units */\n public get width(): number {\n return this.solverWrapper.readVariableValue(this.wVariable);\n }\n\n /** Height in world units */\n public get height(): number {\n return this.solverWrapper.readVariableValue(this.hVariable);\n }\n\n /** X coordinate of right edge */\n public get oppositeX(): number {\n return this.x + this.width;\n }\n\n /** Y coordinate of top edge */\n public get oppositeY(): number {\n return this.y + this.height;\n }\n\n /** X coordinate of horizontal center */\n public get centerX(): number {\n return this.x + this.width / 2;\n }\n\n /** Y coordinate of vertical center */\n public get centerY(): number {\n return this.y + this.height / 2;\n }\n\n /** Controls visibility and interactivity */\n public get mode(): UIMode {\n return this.modeInternal;\n }\n\n /** Rendering and input priority. Higher values on top. */\n public get zIndex(): number {\n return this.inputWrapper.getZIndex(this.catcherHandler);\n }\n\n /** Width in world units */\n public set width(value: number) {\n assertValidPositiveNumber(value, \"UIInputDummy.width\");\n this.solverWrapper.suggestVariableValue(this.wVariable, value);\n }\n\n /** Height in world units */\n public set height(value: number) {\n assertValidPositiveNumber(value, \"UIInputDummy.height\");\n this.solverWrapper.suggestVariableValue(this.hVariable, value);\n }\n\n /** X coordinate of right edge */\n public set oppositeX(value: number) {\n assertValidNumber(value, \"UIInputDummy.oppositeX\");\n this.x = value - this.width;\n }\n\n /** Y coordinate of top edge */\n public set oppositeY(value: number) {\n assertValidNumber(value, \"UIInputDummy.oppositeY\");\n this.y = value - this.height;\n }\n\n /** X coordinate of horizontal center */\n public set centerX(value: number) {\n assertValidNumber(value, \"UIInputDummy.centerX\");\n this.x = value - this.width / 2;\n }\n\n /** Y coordinate of vertical center */\n public set centerY(value: number) {\n assertValidNumber(value, \"UIInputDummy.centerY\");\n this.y = value - this.height / 2;\n }\n\n /** Controls visibility and interactivity */\n public set mode(value: UIMode) {\n if (this.modeInternal !== value) {\n const newInteractivity = isUIModeInteractive(value);\n this.inputWrapper.setActive(this.catcherHandler, newInteractivity);\n this.modeInternal = value;\n }\n }\n\n /** Rendering and input priority. Higher values on top. */\n public set zIndex(value: number) {\n assertValidNumber(value, \"UIInputDummy.zIndex\");\n this.inputWrapper.setZIndex(this.catcherHandler, value);\n }\n\n /** Removes element and frees resources */\n public override destroy(): void {\n this.solverWrapper.removeVariable(this.hVariable);\n this.solverWrapper.removeVariable(this.wVariable);\n this.inputWrapper.destroyInputCatcher(this.catcherHandler);\n super.destroy();\n }\n\n protected readonly catchPointerDown = (\n x: number,\n y: number,\n identifier: number,\n ): boolean => {\n return this.handleInputEvent(x, y, identifier, UIInputEvent.PRESSED);\n };\n\n protected readonly catchPointerMove = (\n x: number,\n y: number,\n identifier: number,\n ): boolean => {\n return this.handleInputEvent(x, y, identifier, UIInputEvent.MOVED);\n };\n\n protected readonly catchPointerUp = (\n x: number,\n y: number,\n identifier: number,\n ): boolean => {\n return this.handleInputEvent(x, y, identifier, UIInputEvent.RELEASED);\n };\n\n protected handleInputEvent(\n x: number,\n y: number,\n identifier: number,\n inputEvent: UIInputEvent,\n ): boolean {\n assertValidNumber(x, \"UIInputDummy.handleInputEvent.x\");\n assertValidNumber(y, \"UIInputDummy.handleInputEvent.y\");\n assertValidNumber(identifier, \"UIInputDummy.handleInputEvent.identifier\");\n\n const isPointerInside = this.interactionArea.contains(\n MathUtils.mapLinear(x, this.x, this.oppositeX, 0, 1),\n MathUtils.mapLinear(y, this.y, this.oppositeY, 0, 1),\n );\n\n if (isPointerInside) {\n this.emit(inputEvent, x, y, identifier, this);\n }\n\n if (this.lastPointerInside && !isPointerInside) {\n this.emit(UIInputEvent.LEFT, x, y, identifier, this);\n } else if (!this.lastPointerInside && isPointerInside) {\n this.emit(UIInputEvent.ENTERED, x, y, identifier, this);\n }\n\n this.lastPointerInside = isPointerInside;\n return this.modeInternal === UIMode.INTERACTIVE_TRANSPARENT\n ? false\n : isPointerInside;\n }\n}\n","import type { UIMicroConfig } from \"../../miscellaneous/micro/UIMicro.Internal\";\nimport { UITransparencyMode } from \"../../miscellaneous/UITransparencyMode\";\nimport type { UIInputDummyOptions } from \"../UIInputDummy/UIInputDummy.Internal\";\n\n/** Configuration options for UIElement */\nexport interface UIElementOptions extends UIInputDummyOptions {\n /** Transforms that don't affect constraints */\n micro: UIMicroConfig;\n /** Alpha blending mode */\n transparencyMode: UITransparencyMode;\n}\n\nexport const ELEMENT_DEFAULT_TRANSPARENCY_MODE = UITransparencyMode.BLEND;\n","import type { WebGLRenderer } from \"three\";\nimport type { UILayer } from \"../../layers/UILayer/UILayer\";\nimport { UILayerEvent } from \"../../layers/UILayer/UILayer.Internal\";\nimport { computeTransformMatrix } from \"../../miscellaneous/computeTransform\";\nimport type { UIPropertyType } from \"../../miscellaneous/generic-plane/shared\";\nimport { UIMicro } from \"../../miscellaneous/micro/UIMicro\";\nimport type { UIMode } from \"../../miscellaneous/UIMode\";\nimport { isUIModeVisible } from \"../../miscellaneous/UIMode\";\nimport type { UITransparencyMode } from \"../../miscellaneous/UITransparencyMode\";\nimport type { UISceneWrapperInterface } from \"../../wrappers/UISceneWrapper.Internal\";\nimport { UIInputDummy } from \"../UIInputDummy/UIInputDummy\";\nimport type { UIElementOptions } from \"./UIElement.Internal\";\nimport { ELEMENT_DEFAULT_TRANSPARENCY_MODE } from \"./UIElement.Internal\";\n\n/** Base class for renderable UI elements */\nexport abstract class UIElement extends UIInputDummy {\n /** Transforms that don't affect constraints */\n public readonly micro: UIMicro;\n\n protected readonly sceneWrapper: UISceneWrapperInterface;\n protected readonly planeHandler: number;\n\n private transparencyModeInternal: UITransparencyMode;\n private transparencyModeDirty = false;\n\n private visibilityDirty = false;\n\n /**\n * Creates a new UIElement instance.\n *\n * @param layer - Layer containing this element\n * @param source - GLSL shader source code\n * @param properties - Shader uniform properties\n * @param options - Configuration options\n */\n constructor(\n layer: UILayer,\n source: string,\n properties: Record<string, UIPropertyType>,\n options?: Partial<UIElementOptions>,\n ) {\n super(layer, options);\n this.micro = new UIMicro(options?.micro);\n\n this.transparencyModeInternal =\n options?.transparencyMode ?? ELEMENT_DEFAULT_TRANSPARENCY_MODE;\n\n this.sceneWrapper = this.layer.sceneWrapper;\n this.planeHandler = this.sceneWrapper.createPlane(\n source,\n properties,\n this.transparencyModeInternal,\n );\n\n if (options?.mode !== undefined && !isUIModeVisible(options.mode)) {\n this.visibilityDirty = true;\n }\n\n this.layer.on(UILayerEvent.RENDERING, this.onWillRender, this);\n }\n\n /** Alpha blending mode */\n public get transparencyMode(): UITransparencyMode {\n return this.transparencyModeInternal;\n }\n\n /** Alpha blending mode */\n public set transparencyMode(value: UITransparencyMode) {\n if (this.transparencyModeInternal !== value) {\n this.transparencyModeInternal = value;\n this.transparencyModeDirty = true;\n }\n }\n\n public override set mode(value: UIMode) {\n if (this.modeInternal !== value) {\n this.visibilityDirty =\n isUIModeVisible(this.modeInternal) !== isUIModeVisible(value);\n super.mode = value;\n }\n }\n\n /** Removes element and frees resources */\n public override destroy(): void {\n this.layer.off(UILayerEvent.RENDERING, this.onWillRender, this);\n this.sceneWrapper.destroyPlane(this.planeHandler);\n super.destroy();\n }\n\n protected setPlaneTransform(): void {\n if (\n this.micro.dirty ||\n this.inputWrapper.dirty ||\n this.solverWrapper.dirty\n ) {\n this.sceneWrapper.setTransform(\n this.planeHandler,\n computeTransformMatrix(\n this.x,\n this.y,\n this.width,\n this.height,\n this.zIndex,\n this.micro.x,\n this.micro.y,\n this.micro.anchorX,\n this.micro.anchorY,\n this.micro.scaleX,\n this.micro.scaleY,\n this.micro.rotation,\n this.micro.anchorMode,\n ),\n );\n this.micro.setDirtyFalse();\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars -- Required by UILayer event interface but not used in base implementation\n protected onWillRender(renderer: WebGLRenderer, deltaTime: number): void {\n if (this.transparencyModeDirty) {\n this.sceneWrapper.setTransparency(\n this.planeHandler,\n this.transparencyModeInternal,\n );\n this.transparencyModeDirty = false;\n }\n\n if (this.visibilityDirty) {\n this.sceneWrapper.setVisibility(\n this.planeHandler,\n isUIModeVisible(this.modeInternal),\n );\n this.visibilityDirty = false;\n }\n\n this.setPlaneTransform();\n }\n}\n","import type { UIColorConfig } from \"../../miscellaneous/color/UIColor.Internal\";\nimport type { UIElementOptions } from \"../UIElement/UIElement.Internal\";\n\n/** Animation playback events */\nexport enum UIAnimatedImageEvent {\n /** Animation started or resumed */\n PLAYED = 0,\n /** Animation paused */\n PAUSED = 1,\n /** Animation stopped and reset */\n STOPPED = 2,\n}\n\n/** Animation loop behavior */\nexport enum UILoopMode {\n /** No looping, stops at boundary frame */\n NONE = 0,\n /** Loops back to opposite frame */\n LOOP = 1,\n /** Reverses direction at boundaries */\n PING_PONG = 2,\n}\n\n/** Configuration options for UIAnimatedImage */\nexport interface UIAnimatedImageOptions extends UIElementOptions {\n /** Multiplicative tint */\n color: UIColorConfig;\n /** Animation speed in frames per second */\n frameRate: number;\n /** Playback speed multiplier. Can be negative for reverse playback. */\n timeScale: number;\n /** Loop behavior */\n loopMode: UILoopMode;\n /** Whether to start playing immediately */\n playByDefault: boolean;\n}\n\nexport const ANIMATED_IMAGE_DEFAULT_FRAME_RATE = 24;\nexport const ANIMATED_IMAGE_DEFAULT_TIME_SCALE = 1;\nexport const ANIMATED_IMAGE_DEFAULT_LOOP_MODE = UILoopMode.LOOP;\n","import type { Matrix3, WebGLRenderer } from \"three\";\nimport type { UILayer } from \"../../layers/UILayer/UILayer\";\nimport {\n assertValidNumber,\n assertValidPositiveNumber,\n} from \"../../miscellaneous/asserts\";\nimport { UIColor } from \"../../miscellaneous/color/UIColor\";\nimport { computeTrimmedTransformMatrix } from \"../../miscellaneous/computeTransform\";\nimport type { UIPropertyType } from \"../../miscellaneous/generic-plane/shared\";\nimport { UITextureView } from \"../../miscellaneous/texture/UITextureView\";\nimport type { UITextureConfig } from \"../../miscellaneous/texture/UITextureView.Internal\";\nimport { UITextureViewEvent } from \"../../miscellaneous/texture/UITextureView.Internal\";\nimport source from \"../../shaders/UIImage.glsl\";\nimport { UIElement } from \"../UIElement/UIElement\";\nimport type { UIAnimatedImageOptions } from \"./UIAnimatedImage.Internal\";\nimport {\n ANIMATED_IMAGE_DEFAULT_FRAME_RATE,\n ANIMATED_IMAGE_DEFAULT_LOOP_MODE,\n ANIMATED_IMAGE_DEFAULT_TIME_SCALE,\n UIAnimatedImageEvent,\n UILoopMode,\n} from \"./UIAnimatedImage.Internal\";\n\n/** Frame-based texture animation element */\nexport class UIAnimatedImage extends UIElement {\n /** Multiplicative tint. Alpha channel controls opacity. */\n public readonly color: UIColor;\n\n private readonly sequenceInternal: UITextureView[];\n\n private frameRateInternal: number;\n private timeScaleInternal: number;\n private loopModeInternal: UILoopMode;\n private readonly textureTransform: Matrix3;\n\n private isPlaying = false;\n private sequenceFrameIndex = 0;\n private currentFrameIndexDirty = false;\n private accumulatedTime = 0;\n\n /**\n * Creates a new UIAnimatedImage instance.\n *\n * Defaults size to first frame dimensions if width and height not provided.\n *\n * @param layer - Layer containing this element\n * @param sequence - Array of textures forming animation\n * @param options - Configuration options\n */\n constructor(\n layer: UILayer,\n sequence: UITextureConfig[],\n options: Partial<UIAnimatedImageOptions> = {},\n ) {\n const color = new UIColor(options.color);\n const uiTextures = sequence.map(\n (textureConfig) => new UITextureView(textureConfig),\n );\n\n const frame = uiTextures[0];\n options.width = options.width ?? frame.width;\n options.height = options.height ?? frame.height;\n\n const textureTransform = frame.calculateUVTransform();\n\n super(\n layer,\n source,\n {\n texture: frame.texture,\n textureTransform: textureTransform,\n color,\n },\n options,\n );\n\n this.sequenceInternal = uiTextures;\n this.textureTransform = textureTransform;\n this.frameRateInternal =\n options.frameRate ?? ANIMATED_IMAGE_DEFAULT_FRAME_RATE;\n this.timeScaleInternal =\n options.timeScale ?? ANIMATED_IMAGE_DEFAULT_TIME_SCALE;\n this.loopModeInternal =\n options.loopMode ?? ANIMATED_IMAGE_DEFAULT_LOOP_MODE;\n this.color = color;\n\n this.subscribeSequenceEvents();\n\n if (options.playByDefault === true) {\n this.play();\n }\n }\n\n /** Animation frames as readonly array */\n public get sequence(): readonly UITextureView[] {\n return this.sequenceInternal;\n }\n\n /** Animation speed in frames per second */\n public get frameRate(): number {\n return this.frameRateInternal;\n }\n\n /** Playback speed multiplier. Can be negative for reverse playback. */\n public get timeScale(): number {\n return this.timeScaleInternal;\n }\n\n /** Loop behavior */\n public get loopMode(): UILoopMode {\n return this.loopModeInternal;\n }\n\n /** Total animation duration in seconds */\n public get duration(): number {\n return this.sequenceInternal.length / this.frameRateInternal;\n }\n\n /** Replaces animation frames. Stops playback. */\n public set sequence(sequence: UITextureConfig[]) {\n this.stop();\n this.unsubscribeSequenceEvents();\n\n const newLength = sequence.length;\n const currentLength = this.sequenceInternal.length;\n\n for (let i = 0; i < Math.min(newLength, currentLength); i++) {\n this.sequenceInternal[i].set(sequence[i]);\n }\n\n if (newLength < currentLength) {\n this.sequenceInternal.length = newLength;\n } else if (newLength > currentLength) {\n for (let i = currentLength; i < newLength; i++) {\n this.sequenceInternal.push(new UITextureView(sequence[i]));\n }\n }\n\n this.subscribeSequenceEvents();\n }\n\n /** Animation speed in frames per second */\n public set frameRate(value: number) {\n assertValidPositiveNumber(value, \"UIAnimatedImage.frameRate\");\n this.frameRateInternal = value;\n }\n\n /** Playback speed multiplier. Can be negative for reverse playback. */\n public set timeScale(value: number) {\n assertValidNumber(value, \"UIAnimatedImage.timeScale\");\n this.timeScaleInternal = value;\n }\n\n /** Loop behavior */\n public set loopMode(value: UILoopMode) {\n this.loopModeInternal = value;\n }\n\n /** Removes element and frees resources */\n public override destroy(): void {\n this.unsubscribeSequenceEvents();\n super.destroy();\n }\n\n /** Starts or resumes animation playback */\n public play(): void {\n if (!this.isPlaying) {\n this.isPlaying = true;\n this.emit(UIAnimatedImageEvent.PLAYED);\n }\n }\n\n /** Pauses animation at current frame */\n public pause(): void {\n if (this.isPlaying) {\n this.isPlaying = false;\n this.emit(UIAnimatedImageEvent.PAUSED);\n }\n }\n\n /** Stops animation and resets to first frame */\n public stop(): void {\n if (\n this.isPlaying ||\n this.accumulatedTime > 0 ||\n this.sequenceFrameIndex > 0\n ) {\n this.isPlaying = false;\n this.accumulatedTime = 0;\n this.sequenceFrameIndex = 0;\n this.currentFrameIndexDirty = true;\n this.emit(UIAnimatedImageEvent.STOPPED);\n }\n }\n\n protected override onWillRender(\n renderer: WebGLRenderer,\n deltaTime: number,\n ): void {\n if (this.isPlaying && this.timeScaleInternal !== 0) {\n this.accumulatedTime += deltaTime * this.timeScaleInternal;\n const frameDuration = 1 / this.frameRateInternal;\n const sequenceLength = this.sequenceInternal.length;\n const lastFrameIndex = sequenceLength - 1;\n\n if (this.timeScaleInternal > 0) {\n while (this.accumulatedTime >= frameDuration) {\n this.accumulatedTime -= frameDuration;\n this.sequenceFrameIndex += 1;\n\n if (this.sequenceFrameIndex >= sequenceLength) {\n if (this.loopModeInternal === UILoopMode.LOOP) {\n this.sequenceFrameIndex = 0;\n } else if (this.loopModeInternal === UILoopMode.PING_PONG) {\n this.sequenceFrameIndex = lastFrameIndex;\n this.timeScaleInternal = -this.timeScaleInternal;\n } else {\n this.sequenceFrameIndex = lastFrameIndex;\n this.isPlaying = false;\n this.emit(UIAnimatedImageEvent.PAUSED);\n break;\n }\n }\n\n this.currentFrameIndexDirty = true;\n }\n } else {\n while (this.accumulatedTime <= -frameDuration) {\n this.accumulatedTime += frameDuration;\n this.sequenceFrameIndex -= 1;\n\n if (this.sequenceFrameIndex < 0) {\n if (this.loopModeInternal === UILoopMode.LOOP) {\n this.sequenceFrameIndex = lastFrameIndex;\n } else if (this.loopModeInternal === UILoopMode.PING_PONG) {\n this.sequenceFrameIndex = 0;\n this.timeScaleInternal = -this.timeScaleInternal;\n } else {\n this.sequenceFrameIndex = 0;\n this.isPlaying = false;\n this.emit(UIAnimatedImageEvent.PAUSED);\n break;\n }\n }\n\n this.currentFrameIndexDirty = true;\n }\n }\n }\n\n super.onWillRender(renderer, deltaTime);\n }\n\n protected override setPlaneTransform(): void {\n let properties: Record<string, UIPropertyType> | undefined;\n\n if (this.color.dirty) {\n properties ??= {};\n properties[\"color\"] = this.color;\n this.color.setDirtyFalse();\n }\n\n const frame = this.sequenceInternal[this.sequenceFrameIndex];\n if (frame.textureDirty || this.currentFrameIndexDirty) {\n properties ??= {};\n properties[\"texture\"] = frame.texture;\n frame.setTextureDirtyFalse();\n }\n\n if (frame.uvTransformDirty || this.currentFrameIndexDirty) {\n properties ??= {};\n properties[\"textureTransform\"] = frame.calculateUVTransform(\n this.textureTransform,\n );\n frame.setUVTransformDirtyFalse();\n }\n\n if (properties) {\n this.sceneWrapper.setProperties(this.planeHandler, properties);\n }\n\n const isTransformDirty =\n this.currentFrameIndexDirty ||\n this.micro.dirty ||\n frame.trimDirty ||\n this.inputWrapper.dirty ||\n this.solverWrapper.dirty;\n\n if (isTransformDirty) {\n const micro = this.micro;\n const textureTrim = frame.trim;\n\n this.sceneWrapper.setTransform(\n this.planeHandler,\n computeTrimmedTransformMatrix(\n this.x,\n this.y,\n this.width,\n this.height,\n this.zIndex,\n micro.x,\n micro.y,\n micro.anchorX,\n micro.anchorY,\n micro.scaleX,\n micro.scaleY,\n micro.rotation,\n micro.anchorMode,\n textureTrim.left,\n textureTrim.right,\n textureTrim.top,\n textureTrim.bottom,\n ),\n );\n\n this.currentFrameIndexDirty = false;\n this.micro.setDirtyFalse();\n frame.setTrimDirtyFalse();\n }\n }\n\n private readonly onTextureDimensionsChanged = (\n width: number,\n height: number,\n texture: UITextureView,\n ): void => {\n if (this.sequenceInternal[this.sequenceFrameIndex] === texture) {\n this.width = width;\n this.height = height;\n }\n };\n\n private subscribeSequenceEvents(): void {\n for (const frame of this.sequenceInternal) {\n frame.on(\n UITextureViewEvent.DIMENSIONS_CHANGED,\n this.onTextureDimensionsChanged,\n );\n }\n }\n\n private unsubscribeSequenceEvents(): void {\n for (const frame of this.sequenceInternal) {\n frame.off(\n UITextureViewEvent.DIMENSIONS_CHANGED,\n this.onTextureDimensionsChanged,\n );\n }\n }\n}\n","import type { WebGLRenderer } from \"three\";\nimport { CanvasTexture, LinearFilter, SRGBColorSpace } from \"three\";\nimport type { UILayer } from \"../../layers/UILayer/UILayer\";\nimport { UIColor } from \"../../miscellaneous/color/UIColor\";\nimport source from \"../../shaders/UIImage.glsl\";\nimport { UIElement } from \"../UIElement/UIElement\";\nimport {\n DUMMY_DEFAULT_HEIGHT,\n DUMMY_DEFAULT_WIDTH,\n} from \"../UIInputDummy/UIInputDummy.Internal\";\nimport type { UIGraphicsOptions } from \"./UIGraphics.Internal\";\n\n/** Canvas-based 2D drawing element */\nexport class UIGraphics extends UIElement {\n /** Multiplicative tint. Alpha channel controls opacity. */\n public readonly color: UIColor;\n\n private readonly canvas: OffscreenCanvas;\n private readonly context: OffscreenCanvasRenderingContext2D;\n private readonly texture: CanvasTexture;\n\n /**\n * Creates a new UIGraphics instance.\n *\n * @param layer - Layer containing this element\n * @param options - Configuration options\n */\n constructor(layer: UILayer, options?: Partial<UIGraphicsOptions>) {\n const w = options?.width ?? DUMMY_DEFAULT_WIDTH;\n const h = options?.height ?? DUMMY_DEFAULT_HEIGHT;\n const color = new UIColor(options?.color);\n\n const canvas = new OffscreenCanvas(w, h);\n const context = canvas.getContext(\"2d\");\n\n if (!context) {\n throw new Error(\n \"UIGraphics.constructor: failed to get 2D context from OffscreenCanvas\",\n );\n }\n\n const texture = new CanvasTexture(canvas);\n texture.colorSpace = SRGBColorSpace;\n texture.minFilter = LinearFilter;\n texture.magFilter = LinearFilter;\n texture.needsUpdate = true;\n\n super(\n layer,\n source,\n {\n texture: texture,\n textureTransform: texture.matrix,\n color,\n },\n options,\n );\n\n this.canvas = canvas;\n this.context = context;\n this.texture = texture;\n this.color = color;\n }\n\n /**\n * Clears canvas. Optionally fills with color.\n *\n * @param color - Fill color after clearing\n */\n public clear(color?: UIColor): this {\n this.context.clearRect(0, 0, this.canvas.width, this.canvas.height);\n if (color !== undefined) {\n this.context.fillStyle = color.toCSSColor();\n this.context.fillRect(0, 0, this.canvas.width, this.canvas.height);\n }\n this.texture.needsUpdate = true;\n return this;\n }\n\n /** Draws filled rectangle */\n public drawRect(\n x: number,\n y: number,\n width: number,\n height: number,\n color: UIColor,\n ): this {\n this.context.fillStyle = color.toCSSColor();\n this.context.fillRect(x, y, width, height);\n this.texture.needsUpdate = true;\n return this;\n }\n\n /** Draws filled circle */\n public drawCircle(\n x: number,\n y: number,\n radius: number,\n color: UIColor,\n ): this {\n this.context.fillStyle = color.toCSSColor();\n this.context.beginPath();\n this.context.arc(x, y, radius, 0, Math.PI * 2);\n this.context.fill();\n this.texture.needsUpdate = true;\n return this;\n }\n\n /**\n * Draws filled arc.\n *\n * @param startAngle - Start angle in radians\n * @param endAngle - End angle in radians\n */\n public drawArc(\n x: number,\n y: number,\n radius: number,\n startAngle: number,\n endAngle: number,\n color: UIColor,\n ): this {\n this.context.fillStyle = color.toCSSColor();\n this.context.beginPath();\n this.context.arc(x, y, radius, startAngle, endAngle);\n this.context.fill();\n this.texture.needsUpdate = true;\n return this;\n }\n\n /**\n * Draws connected line segments.\n *\n * @param points - Array of [x, y] pairs\n * @param lineWidth - Line width in pixels\n */\n public drawPolyline(\n points: [number, number][],\n color: UIColor,\n lineWidth = 1,\n ): this {\n if (points.length < 2) {\n return this;\n }\n\n this.context.strokeStyle = color.toCSSColor();\n this.context.lineWidth = lineWidth;\n this.context.beginPath();\n this.context.moveTo(points[0][0], points[0][1]);\n\n for (let i = 1; i < points.length; i++) {\n this.context.lineTo(points[i][0], points[i][1]);\n }\n\n this.context.stroke();\n this.texture.needsUpdate = true;\n return this;\n }\n\n /** Removes element and frees resources */\n public override destroy(): void {\n this.texture.dispose();\n super.destroy();\n }\n\n protected override onWillRender(\n renderer: WebGLRenderer,\n deltaTime: number,\n ): void {\n if (this.color.dirty) {\n this.sceneWrapper.setProperties(this.planeHandler, { color: this.color });\n this.color.setDirtyFalse();\n }\n\n super.onWillRender(renderer, deltaTime);\n }\n}\n","import type { Matrix3 } from \"three\";\nimport type { UILayer } from \"../../layers/UILayer/UILayer\";\nimport { UIColor } from \"../../miscellaneous/color/UIColor\";\nimport { computeTrimmedTransformMatrix } from \"../../miscellaneous/computeTransform\";\nimport type { UIPropertyType } from \"../../miscellaneous/generic-plane/shared\";\nimport { UITextureView } from \"../../miscellaneous/texture/UITextureView\";\nimport type { UITextureConfig } from \"../../miscellaneous/texture/UITextureView.Internal\";\nimport { UITextureViewEvent } from \"../../miscellaneous/texture/UITextureView.Internal\";\nimport source from \"../../shaders/UIImage.glsl\";\nimport { UIElement } from \"../UIElement/UIElement\";\nimport type { UIImageOptions } from \"./UIImage.Internal\";\n\n/** Textured image element */\nexport class UIImage extends UIElement {\n /** Texture displayed by this image */\n public readonly texture: UITextureView;\n /** Multiplicative tint. Alpha channel controls opacity. */\n public readonly color: UIColor;\n\n private readonly textureTransform: Matrix3;\n\n /**\n * Creates a new UIImage instance.\n *\n * Defaults size to texture dimensions if width and height not provided.\n *\n * @param layer - Layer containing this image\n * @param texture - Texture to display\n * @param options - Configuration options\n */\n constructor(\n layer: UILayer,\n texture: UITextureConfig,\n options: Partial<UIImageOptions> = {},\n ) {\n const color = new UIColor(options.color);\n const textureView = new UITextureView(texture);\n const textureTransform = textureView.calculateUVTransform();\n\n options.width = options.width ?? textureView.width;\n options.height = options.height ?? textureView.height;\n\n super(\n layer,\n source,\n {\n texture: textureView.texture,\n textureTransform: textureTransform,\n color,\n },\n options,\n );\n\n this.texture = textureView;\n this.textureTransform = textureTransform;\n this.color = color;\n\n this.texture.on(\n UITextureViewEvent.DIMENSIONS_CHANGED,\n this.onTextureDimensionsChanged,\n );\n }\n\n /** Removes image and frees resources */\n public override destroy(): void {\n this.texture.off(\n UITextureViewEvent.DIMENSIONS_CHANGED,\n this.onTextureDimensionsChanged,\n );\n super.destroy();\n }\n\n protected override setPlaneTransform(): void {\n let properties: Record<string, UIPropertyType> | undefined;\n\n if (this.color.dirty) {\n properties ??= {};\n properties[\"color\"] = this.color;\n this.color.setDirtyFalse();\n }\n\n if (this.texture.textureDirty) {\n properties ??= {};\n properties[\"texture\"] = this.texture.texture;\n this.texture.setTextureDirtyFalse();\n }\n\n if (this.texture.uvTransformDirty) {\n properties ??= {};\n properties[\"textureTransform\"] = this.texture.calculateUVTransform(\n this.textureTransform,\n );\n this.texture.setUVTransformDirtyFalse();\n }\n\n if (properties) {\n this.sceneWrapper.setProperties(this.planeHandler, properties);\n }\n\n const isTransformDirty =\n this.micro.dirty ||\n this.texture.trimDirty ||\n this.inputWrapper.dirty ||\n this.solverWrapper.dirty;\n\n if (isTransformDirty) {\n const micro = this.micro;\n const textureTrim = this.texture.trim;\n\n this.sceneWrapper.setTransform(\n this.planeHandler,\n computeTrimmedTransformMatrix(\n this.x,\n this.y,\n this.width,\n this.height,\n this.zIndex,\n micro.x,\n micro.y,\n micro.anchorX,\n micro.anchorY,\n micro.scaleX,\n micro.scaleY,\n micro.rotation,\n micro.anchorMode,\n textureTrim.left,\n textureTrim.right,\n textureTrim.top,\n textureTrim.bottom,\n ),\n );\n this.micro.setDirtyFalse();\n this.texture.setTrimDirtyFalse();\n }\n }\n\n private readonly onTextureDimensionsChanged = (\n width: number,\n height: number,\n ): void => {\n this.width = width;\n this.height = height;\n };\n}\n","import { Vector4 } from \"three\";\nimport { assertValidNonNegativeNumber } from \"../asserts\";\nimport type { UIInsetsConfig } from \"./UIInsets.Internal\";\nimport { INSETS_DEFAULT_VALUE } from \"./UIInsets.Internal\";\n\n/** Insets values for four sides */\nexport class UIInsets {\n private lInternal: number;\n private rInternal: number;\n private tInternal: number;\n private bInternal: number;\n\n private dirtyInternal = false;\n\n /**\n * Creates UIInsets instance.\n *\n * @param config - Insets configuration\n */\n constructor(config?: UIInsetsConfig) {\n if (config === undefined) {\n this.lInternal = INSETS_DEFAULT_VALUE;\n this.rInternal = INSETS_DEFAULT_VALUE;\n this.tInternal = INSETS_DEFAULT_VALUE;\n this.bInternal = INSETS_DEFAULT_VALUE;\n } else if (typeof config === \"number\") {\n assertValidNonNegativeNumber(config, \"UIInsets.constructor.config\");\n this.lInternal = config;\n this.rInternal = config;\n this.tInternal = config;\n this.bInternal = config;\n } else if (\"left\" in config) {\n const left = config.left;\n const right = config.right;\n const top = config.top;\n const bottom = config.bottom;\n assertValidNonNegativeNumber(left, \"UIInsets.constructor.config.left\");\n assertValidNonNegativeNumber(right, \"UIInsets.constructor.config.right\");\n assertValidNonNegativeNumber(top, \"UIInsets.constructor.config.top\");\n assertValidNonNegativeNumber(\n bottom,\n \"UIInsets.constructor.config.bottom\",\n );\n this.lInternal = left;\n this.rInternal = right;\n this.tInternal = top;\n this.bInternal = bottom;\n } else {\n const horizontal = config.horizontal;\n const vertical = config.vertical;\n assertValidNonNegativeNumber(\n horizontal,\n \"UIInsets.constructor.config.horizontal\",\n );\n assertValidNonNegativeNumber(\n vertical,\n \"UIInsets.constructor.config.vertical\",\n );\n this.lInternal = horizontal;\n this.rInternal = horizontal;\n this.tInternal = vertical;\n this.bInternal = vertical;\n }\n }\n\n /** Left inset */\n public get left(): number {\n return this.lInternal;\n }\n\n /** Right inset */\n public get right(): number {\n return this.rInternal;\n }\n\n /** Top inset */\n public get top(): number {\n return this.tInternal;\n }\n\n /** Bottom inset */\n public get bottom(): number {\n return this.bInternal;\n }\n\n /** @internal */\n public get dirty(): boolean {\n return this.dirtyInternal;\n }\n\n /** Left inset */\n public set left(value: number) {\n assertValidNonNegativeNumber(value, \"UIInsets.left\");\n if (this.lInternal !== value) {\n this.lInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n /** Right inset */\n public set right(value: number) {\n assertValidNonNegativeNumber(value, \"UIInsets.right\");\n if (this.rInternal !== value) {\n this.rInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n /** Top inset */\n public set top(value: number) {\n assertValidNonNegativeNumber(value, \"UIInsets.top\");\n if (this.tInternal !== value) {\n this.tInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n /** Bottom inset */\n public set bottom(value: number) {\n assertValidNonNegativeNumber(value, \"UIInsets.bottom\");\n if (this.bInternal !== value) {\n this.bInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n /** Sets left and right to same value */\n public setHorizontal(value: number): void {\n assertValidNonNegativeNumber(value, \"UIInsets.setHorizontal.value\");\n if (this.lInternal !== value || this.rInternal !== value) {\n this.lInternal = value;\n this.rInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n /** Sets top and bottom to same value */\n public setVertical(value: number): void {\n assertValidNonNegativeNumber(value, \"UIInsets.setVertical.value\");\n if (this.tInternal !== value || this.bInternal !== value) {\n this.tInternal = value;\n this.bInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n /** Sets all sides to same value */\n public setUnified(value: number): void {\n assertValidNonNegativeNumber(value, \"UIInsets.setUnified.value\");\n if (\n this.lInternal !== value ||\n this.rInternal !== value ||\n this.tInternal !== value ||\n this.bInternal !== value\n ) {\n this.lInternal = value;\n this.rInternal = value;\n this.tInternal = value;\n this.bInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n /** Sets from Vector4 (x=left, y=right, z=top, w=bottom) */\n public setVector4(vector: Vector4): void {\n assertValidNonNegativeNumber(vector.x, \"UIInsets.setVector4.vector.x\");\n assertValidNonNegativeNumber(vector.y, \"UIInsets.setVector4.vector.y\");\n assertValidNonNegativeNumber(vector.z, \"UIInsets.setVector4.vector.z\");\n assertValidNonNegativeNumber(vector.w, \"UIInsets.setVector4.vector.w\");\n if (\n this.lInternal !== vector.x ||\n this.rInternal !== vector.y ||\n this.tInternal !== vector.z ||\n this.bInternal !== vector.w\n ) {\n this.lInternal = vector.x;\n this.rInternal = vector.y;\n this.tInternal = vector.z;\n this.bInternal = vector.w;\n this.dirtyInternal = true;\n }\n }\n\n /** Converts to Vector4 (left, right, top, bottom) */\n public toVector4(result = new Vector4()): Vector4 {\n return result.set(\n this.lInternal,\n this.rInternal,\n this.tInternal,\n this.bInternal,\n );\n }\n\n /** Resets all sides to 0 */\n public reset(): void {\n this.setUnified(0);\n }\n\n /** Copies from another instance */\n public copy(other: UIInsets): void {\n if (\n this.lInternal !== other.lInternal ||\n this.rInternal !== other.rInternal ||\n this.tInternal !== other.tInternal ||\n this.bInternal !== other.bInternal\n ) {\n this.lInternal = other.lInternal;\n this.rInternal = other.rInternal;\n this.tInternal = other.tInternal;\n this.bInternal = other.bInternal;\n this.dirtyInternal = true;\n }\n }\n\n /** @internal */\n public setDirtyFalse(): void {\n this.dirtyInternal = false;\n }\n}\n","/** Insets configuration as number, per-side, or per-axis */\nexport type UIInsetsConfig =\n | { horizontal: number; vertical: number }\n | { left: number; right: number; top: number; bottom: number }\n | number;\n\nexport const INSETS_DEFAULT_VALUE = 0;\n","import type { UIColorConfig } from \"../../miscellaneous/color/UIColor.Internal\";\nimport type { UIInsetsConfig } from \"../../miscellaneous/insets/UIInsets.Internal\";\nimport type { UIElementOptions } from \"../UIElement/UIElement.Internal\";\n\n/** Controls how sliceRegions values are interpreted */\nexport enum UINineSliceRegionMode {\n /** sliceRegions in normalized coordinates (0 to 1) */\n NORMALIZED = 0,\n /** sliceRegions in world units */\n WORLD = 1,\n}\n\n/** Configuration options for UINineSlice */\nexport interface UINineSliceOptions extends UIElementOptions {\n /** Multiplicative tint */\n color: UIColorConfig;\n /** Border size in normalized texture coordinates (0 to 1) */\n sliceBorders: UIInsetsConfig;\n /** Region size. Interpretation depends on regionMode. */\n sliceRegions: UIInsetsConfig;\n /** How sliceRegions values are interpreted */\n regionMode: UINineSliceRegionMode;\n}\n\nexport const NINE_SLICE_DEFAULT_BORDER = 0.1;\nexport const NINE_SLICE_DEFAULT_REGION_MODE = UINineSliceRegionMode.WORLD;\n","import type { Matrix3 } from \"three\";\nimport { Vector4 } from \"three\";\nimport type { UILayer } from \"../../layers/UILayer/UILayer\";\nimport { UIColor } from \"../../miscellaneous/color/UIColor\";\nimport { computeTrimmedTransformMatrix } from \"../../miscellaneous/computeTransform\";\nimport type { UIPropertyType } from \"../../miscellaneous/generic-plane/shared\";\nimport { UIInsets } from \"../../miscellaneous/insets/UIInsets\";\nimport { UITextureView } from \"../../miscellaneous/texture/UITextureView\";\nimport {\n UITextureViewEvent,\n type UITextureConfig,\n} from \"../../miscellaneous/texture/UITextureView.Internal\";\nimport source from \"../../shaders/UINineSlice.glsl\";\nimport { UIElement } from \"../UIElement/UIElement\";\nimport type { UINineSliceOptions } from \"./UINineSlice.Internal\";\nimport {\n NINE_SLICE_DEFAULT_BORDER,\n NINE_SLICE_DEFAULT_REGION_MODE,\n UINineSliceRegionMode,\n} from \"./UINineSlice.Internal\";\n\n/** Scalable textured image preserving border regions */\nexport class UINineSlice extends UIElement {\n /** Texture displayed by this element */\n public readonly texture: UITextureView;\n /** Multiplicative tint. Alpha channel controls opacity. */\n public readonly color: UIColor;\n /** Border size in normalized texture coordinates (0 to 1) */\n public readonly sliceBorders: UIInsets;\n /** Region size. Interpretation depends on regionMode. */\n public readonly sliceRegions: UIInsets;\n\n private regionModeInternal: UINineSliceRegionMode;\n private regionModeDirty = true;\n\n private readonly textureTransform: Matrix3;\n private readonly sliceBordersVector = new Vector4();\n private readonly sliceRegionsVector = new Vector4();\n\n private lastElementWidth: number;\n private lastElementHeight: number;\n\n private textureDimensionsDirty = true;\n\n /**\n * Creates a new UINineSlice instance.\n *\n * Defaults size to texture dimensions if width and height not provided.\n *\n * @param layer - Layer containing this element\n * @param texture - Texture to display\n * @param options - Configuration options\n */\n constructor(\n layer: UILayer,\n texture: UITextureConfig,\n options: Partial<UINineSliceOptions> = {},\n ) {\n const color = new UIColor(options.color);\n const textureView = new UITextureView(texture);\n const textureTransform = textureView.calculateUVTransform();\n\n options.width = options.width ?? textureView.width;\n options.height = options.height ?? textureView.height;\n\n const sliceBorders = new UIInsets(\n options.sliceBorders ?? NINE_SLICE_DEFAULT_BORDER,\n );\n const sliceRegions = new UIInsets(\n options.sliceRegions ?? NINE_SLICE_DEFAULT_BORDER,\n );\n\n const regionMode = options.regionMode ?? NINE_SLICE_DEFAULT_REGION_MODE;\n\n const sliceBordersVector = new Vector4();\n const sliceRegionsVector = new Vector4();\n\n super(\n layer,\n source,\n {\n texture: textureView.texture,\n textureTransform: textureTransform,\n color,\n sliceBorders: sliceBordersVector,\n sliceRegions: sliceRegionsVector,\n },\n options,\n );\n\n this.texture = textureView;\n this.textureTransform = textureTransform;\n this.color = color;\n this.sliceBorders = sliceBorders;\n this.sliceRegions = sliceRegions;\n this.regionModeInternal = regionMode;\n\n this.sliceBordersVector = sliceBordersVector;\n this.sliceRegionsVector = sliceRegionsVector;\n\n this.lastElementWidth = this.width;\n this.lastElementHeight = this.height;\n\n this.texture.on(\n UITextureViewEvent.DIMENSIONS_CHANGED,\n this.onTextureDimensionsChanged,\n );\n }\n\n /** Controls how sliceRegions values are interpreted */\n public get regionMode(): UINineSliceRegionMode {\n return this.regionModeInternal;\n }\n\n /** Controls how sliceRegions values are interpreted */\n public set regionMode(value: UINineSliceRegionMode) {\n if (this.regionModeInternal !== value) {\n this.regionModeInternal = value;\n this.regionModeDirty = true;\n }\n }\n\n /** Removes nine slice and frees resources */\n public override destroy(): void {\n this.texture.off(\n UITextureViewEvent.DIMENSIONS_CHANGED,\n this.onTextureDimensionsChanged,\n );\n super.destroy();\n }\n\n protected override setPlaneTransform(): void {\n let properties: Record<string, UIPropertyType> | undefined;\n\n const sliceBordersDirty =\n this.textureDimensionsDirty ||\n this.sliceBorders.dirty ||\n this.texture.trimDirty;\n\n if (sliceBordersDirty) {\n properties ??= {};\n properties[\"sliceBorders\"] = this.calculateSliceBordersForShader(\n this.sliceBordersVector,\n );\n this.sliceBorders.setDirtyFalse();\n this.textureDimensionsDirty = false;\n }\n\n const sliceRegionsDirty =\n this.sliceRegions.dirty ||\n this.regionModeDirty ||\n (this.regionModeInternal === UINineSliceRegionMode.WORLD &&\n this.checkElementDimensionsDirty());\n\n if (sliceRegionsDirty) {\n properties ??= {};\n properties[\"sliceRegions\"] = this.calculateSliceRegionsForShader(\n this.sliceRegionsVector,\n );\n this.sliceRegions.setDirtyFalse();\n this.regionModeDirty = false;\n this.setElementDimensionsDirtyFalse();\n }\n\n if (this.color.dirty) {\n properties ??= {};\n properties[\"color\"] = this.color;\n this.color.setDirtyFalse();\n }\n\n if (this.texture.textureDirty) {\n properties ??= {};\n properties[\"texture\"] = this.texture.texture;\n this.texture.setTextureDirtyFalse();\n }\n\n if (this.texture.uvTransformDirty) {\n properties ??= {};\n properties[\"textureTransform\"] = this.texture.calculateUVTransform(\n this.textureTransform,\n );\n this.texture.setUVTransformDirtyFalse();\n }\n\n if (properties) {\n this.sceneWrapper.setProperties(this.planeHandler, properties);\n }\n\n const isTransformDirty =\n this.micro.dirty ||\n this.texture.trimDirty ||\n this.inputWrapper.dirty ||\n this.solverWrapper.dirty;\n\n if (isTransformDirty) {\n const micro = this.micro;\n const textureTrim = this.texture.trim;\n\n this.sceneWrapper.setTransform(\n this.planeHandler,\n computeTrimmedTransformMatrix(\n this.x,\n this.y,\n this.width,\n this.height,\n this.zIndex,\n micro.x,\n micro.y,\n micro.anchorX,\n micro.anchorY,\n micro.scaleX,\n micro.scaleY,\n micro.rotation,\n micro.anchorMode,\n textureTrim.left,\n textureTrim.right,\n textureTrim.top,\n textureTrim.bottom,\n ),\n );\n this.micro.setDirtyFalse();\n this.texture.setTrimDirtyFalse();\n }\n }\n\n private calculateSliceBordersForShader(result: Vector4): Vector4 {\n const sourceWidth = this.texture.width;\n const sourceHeight = this.texture.height;\n const trim = this.texture.trim;\n\n const trimmedWidth = sourceWidth - trim.left - trim.right;\n const trimmedHeight = sourceHeight - trim.top - trim.bottom;\n\n const trimNLeft = trim.left / sourceWidth;\n const trimNRight = trim.right / sourceWidth;\n const trimNTop = trim.top / sourceHeight;\n const trimNBottom = trim.bottom / sourceHeight;\n\n const trimmedWidthNorm = trimmedWidth / sourceWidth;\n const trimmedHeightNorm = trimmedHeight / sourceHeight;\n\n const srcLeft = this.sliceBorders.left;\n const srcRight = this.sliceBorders.right;\n const srcTop = this.sliceBorders.top;\n const srcBottom = this.sliceBorders.bottom;\n\n const left = Math.max(0, srcLeft - trimNLeft) / trimmedWidthNorm;\n const right = Math.max(0, srcRight - trimNRight) / trimmedWidthNorm;\n const top = Math.max(0, srcTop - trimNTop) / trimmedHeightNorm;\n const bottom = Math.max(0, srcBottom - trimNBottom) / trimmedHeightNorm;\n\n return result.set(\n Math.min(1, left),\n Math.min(1, right),\n Math.min(1, top),\n Math.min(1, bottom),\n );\n }\n\n private calculateSliceRegionsForShader(result: Vector4): Vector4 {\n if (this.regionModeInternal === UINineSliceRegionMode.NORMALIZED) {\n return result.set(\n this.sliceRegions.left,\n this.sliceRegions.right,\n this.sliceRegions.top,\n this.sliceRegions.bottom,\n );\n }\n\n const width = this.width;\n const height = this.height;\n\n return result.set(\n this.sliceRegions.left / width,\n this.sliceRegions.right / width,\n this.sliceRegions.top / height,\n this.sliceRegions.bottom / height,\n );\n }\n\n private checkElementDimensionsDirty(): boolean {\n return (\n this.solverWrapper.dirty &&\n (this.lastElementWidth !== Math.round(this.width) ||\n this.lastElementHeight !== Math.round(this.height))\n );\n }\n\n private setElementDimensionsDirtyFalse(): void {\n this.lastElementWidth = Math.round(this.width);\n this.lastElementHeight = Math.round(this.height);\n }\n\n private readonly onTextureDimensionsChanged = (): void => {\n this.textureDimensionsDirty = true;\n };\n}\n","import type { UIPropertyType } from \"../generic-plane/shared\";\n\n/** Base class for progress bar fill functions */\nexport abstract class UIProgressMaskFunction {\n protected dirtyInternal = false;\n\n protected constructor(\n /** GLSL shader source code defining fill behavior */\n public readonly source: string,\n ) {}\n\n /** @internal */\n public get dirty(): boolean {\n return this.dirtyInternal;\n }\n\n /** @internal */\n public setDirtyFalse(): void {\n this.dirtyInternal = false;\n }\n\n /** @internal */\n public abstract enumerateProperties(): Record<string, UIPropertyType>;\n}\n","import type { Vector2Like } from \"three\";\nimport { Vector2 } from \"three\";\nimport source from \"../../shaders/UIProgressMaskFunctionDirectional.glsl\";\nimport { EPSILON } from \"../asserts\";\nimport type { UIPropertyType } from \"../generic-plane/shared\";\nimport { UIProgressMaskFunction } from \"./UIProgressMaskFunction\";\n\n/** Linear directional progress fill */\nexport class UIProgressMaskFunctionDirectional extends UIProgressMaskFunction {\n /** Fill direction as normalized vector */\n public readonly direction = new Vector2();\n private readonly cachedDirection = new Vector2();\n\n /**\n * Creates directional mask function.\n *\n * @param direction - Fill direction vector. Automatically normalized.\n */\n constructor(direction: Vector2Like = { x: 1, y: 0 }) {\n super(source);\n this.direction.copy(direction).normalize();\n this.cachedDirection.copy(this.direction);\n }\n\n /** @internal */\n public override get dirty(): boolean {\n this.ensureDirectionNormalized();\n return this.dirtyInternal || !this.cachedDirection.equals(this.direction);\n }\n\n /** @internal */\n public override setDirtyFalse(): void {\n this.ensureDirectionNormalized();\n this.cachedDirection.copy(this.direction);\n super.setDirtyFalse();\n }\n\n /** @internal */\n public enumerateProperties(): Record<string, UIPropertyType> {\n this.ensureDirectionNormalized();\n return { direction: this.direction };\n }\n\n private ensureDirectionNormalized(): void {\n const squaredLength = this.direction.lengthSq();\n if (Math.abs(squaredLength) <= EPSILON) {\n this.direction.set(1, 0);\n } else if (Math.abs(squaredLength - 1) > EPSILON) {\n this.direction.divideScalar(squaredLength);\n }\n }\n}\n","import { MathUtils, type Matrix3, type Texture, type Vector2 } from \"three\";\nimport type { UILayer } from \"../../layers/UILayer/UILayer\";\nimport { assertValidNumber } from \"../../miscellaneous/asserts\";\nimport { UIColor } from \"../../miscellaneous/color/UIColor\";\nimport { computeTrimmedTransformMatrix } from \"../../miscellaneous/computeTransform\";\nimport type { UIPropertyType } from \"../../miscellaneous/generic-plane/shared\";\nimport type { UIProgressMaskFunction } from \"../../miscellaneous/mask-function/UIProgressMaskFunction\";\nimport { UIProgressMaskFunctionDirectional } from \"../../miscellaneous/mask-function/UIProgressMaskFunctionDirectional\";\nimport { UITextureView } from \"../../miscellaneous/texture/UITextureView\";\nimport { UITextureViewEvent } from \"../../miscellaneous/texture/UITextureView.Internal\";\nimport source from \"../../shaders/UIProgress.glsl\";\nimport { UIElement } from \"../UIElement/UIElement\";\nimport type { UIProgressOptions } from \"./UIProgress.Internal\";\nimport { PROGRESS_DEFAULT_VALUE } from \"./UIProgress.Internal\";\n\n/** Progress bar with customizable fill direction */\nexport class UIProgress extends UIElement {\n /** Texture displayed by this element */\n public readonly texture: UITextureView;\n /** Multiplicative tint. Alpha channel controls opacity. */\n public readonly color: UIColor;\n /** Function controlling fill direction and shape */\n public readonly maskFunction: UIProgressMaskFunction;\n\n private readonly textureTransform: Matrix3;\n private readonly textureResolution: Vector2;\n\n private progressInternal: number;\n private progressDirty = false;\n private textureResolutionDirty = false;\n\n /**\n * Creates a new UIProgress instance.\n *\n * Defaults size to texture dimensions if width and height not provided.\n *\n * @param layer - Layer containing this element\n * @param texture - Texture to display\n * @param options - Configuration options\n */\n constructor(\n layer: UILayer,\n texture: Texture,\n options: Partial<UIProgressOptions> = {},\n ) {\n if (options.progress !== undefined) {\n assertValidNumber(\n options.progress,\n \"UIProgress.constructor.options.progress\",\n );\n }\n\n const color = new UIColor(options.color);\n const textureView = new UITextureView(texture);\n const textureTransform = textureView.calculateUVTransform();\n const textureResolution = textureView.getResolution();\n\n options.width = options.width ?? textureView.width;\n options.height = options.height ?? textureView.height;\n\n const progress = MathUtils.clamp(\n options.progress ?? PROGRESS_DEFAULT_VALUE,\n 0,\n 1,\n );\n\n const maskFunction =\n options.maskFunction ?? new UIProgressMaskFunctionDirectional();\n\n super(\n layer,\n maskFunction.source + source,\n {\n texture: textureView.texture,\n textureTransform,\n textureResolution,\n color,\n progress,\n ...maskFunction.enumerateProperties(),\n },\n options,\n );\n\n this.texture = textureView;\n this.textureTransform = textureTransform;\n this.textureResolution = textureResolution;\n this.color = color;\n this.progressInternal = progress;\n this.maskFunction = maskFunction;\n\n this.texture.on(\n UITextureViewEvent.DIMENSIONS_CHANGED,\n this.onTextureDimensionsChanged,\n );\n }\n\n /** Progress from 0 (empty) to 1 (full) */\n public get progress(): number {\n return this.progressInternal;\n }\n\n /** Progress from 0 (empty) to 1 (full). Clamped. */\n public set progress(value: number) {\n assertValidNumber(value, \"UIProgress.progress\");\n value = MathUtils.clamp(value, 0, 1);\n if (this.progressInternal !== value) {\n this.progressInternal = value;\n this.progressDirty = true;\n }\n }\n\n protected override setPlaneTransform(): void {\n let properties: Record<string, UIPropertyType> | undefined;\n\n if (this.color.dirty) {\n properties ??= {};\n properties[\"color\"] = this.color;\n this.color.setDirtyFalse();\n }\n\n if (this.texture.textureDirty) {\n properties ??= {};\n properties[\"texture\"] = this.texture.texture;\n this.texture.setTextureDirtyFalse();\n }\n\n if (this.texture.uvTransformDirty) {\n properties ??= {};\n properties[\"textureTransform\"] = this.texture.calculateUVTransform(\n this.textureTransform,\n );\n this.texture.setUVTransformDirtyFalse();\n }\n\n if (this.progressDirty) {\n properties ??= {};\n properties[\"progress\"] = this.progressInternal;\n this.progressDirty = false;\n }\n\n if (this.textureResolutionDirty) {\n properties ??= {};\n properties[\"textureResolution\"] = this.texture.getResolution(\n this.textureResolution,\n );\n this.textureResolutionDirty = false;\n }\n\n if (this.maskFunction.dirty) {\n properties ??= {};\n const maskProperties = this.maskFunction.enumerateProperties();\n for (const key in maskProperties) {\n properties[key] = maskProperties[key];\n }\n this.maskFunction.setDirtyFalse();\n }\n\n if (properties) {\n this.sceneWrapper.setProperties(this.planeHandler, properties);\n }\n\n const isTransformDirty =\n this.micro.dirty ||\n this.texture.trimDirty ||\n this.inputWrapper.dirty ||\n this.solverWrapper.dirty;\n\n if (isTransformDirty) {\n const micro = this.micro;\n const textureTrim = this.texture.trim;\n\n this.sceneWrapper.setTransform(\n this.planeHandler,\n computeTrimmedTransformMatrix(\n this.x,\n this.y,\n this.width,\n this.height,\n this.zIndex,\n micro.x,\n micro.y,\n micro.anchorX,\n micro.anchorY,\n micro.scaleX,\n micro.scaleY,\n micro.rotation,\n micro.anchorMode,\n textureTrim.left,\n textureTrim.right,\n textureTrim.top,\n textureTrim.bottom,\n ),\n );\n this.micro.setDirtyFalse();\n this.texture.setTrimDirtyFalse();\n }\n }\n\n private readonly onTextureDimensionsChanged = (\n width: number,\n height: number,\n ): void => {\n if (this.width !== width || this.height !== height) {\n this.width = width;\n this.height = height;\n this.textureResolutionDirty = true;\n }\n };\n}\n","import type { UIColorConfig } from \"../../miscellaneous/color/UIColor.Internal\";\nimport type { UIProgressMaskFunction } from \"../../miscellaneous/mask-function/UIProgressMaskFunction\";\nimport type { UIElementOptions } from \"../UIElement/UIElement.Internal\";\n\n/** Configuration options for UIProgress */\nexport interface UIProgressOptions extends UIElementOptions {\n /** Multiplicative tint */\n color: UIColorConfig;\n /** Function controlling fill direction and shape */\n maskFunction: UIProgressMaskFunction;\n /** Progress from 0 (empty) to 1 (full) */\n progress: number;\n}\n\nexport const PROGRESS_DEFAULT_VALUE = 1;\n\nexport function simplifyGLSLSource(source: string): string {\n return source\n .replace(/\\/\\*[\\s\\S]*?\\*\\//g, \"\")\n .replace(/\\/\\/[^\\n]*/g, \"\")\n .replace(/\\s*([{}(),=;+\\-*/<>])\\s*/g, \"$1\")\n .replace(/\\s+/g, \" \")\n .trim();\n}\n","import type { Camera, Scene } from \"three\";\nimport { UIColor } from \"../../miscellaneous/color/UIColor\";\nimport type { UIColorConfig } from \"../../miscellaneous/color/UIColor.Internal\";\nimport type { UIElementOptions } from \"../UIElement/UIElement.Internal\";\n\n/** Controls when scene re-renders */\nexport enum UISceneUpdateMode {\n /** Re-render every frame */\n EACH_FRAME = 1,\n /** Re-render every other frame */\n EVERY_SECOND_FRAME = 2,\n /** Re-render when scene, camera, or updateMode changes */\n ON_PROPERTIES_CHANGE = 3,\n /** Re-render when dimensions or resolutionFactor changes */\n ON_DIMENSIONS_CHANGE = 4,\n /** Re-render only via requestUpdate() */\n MANUAL = 5,\n}\n\n/** Configuration options for UIScene */\nexport interface UISceneOptions extends UIElementOptions {\n /** Multiplicative tint */\n color: UIColorConfig;\n /** Three.js scene to render */\n scene: Scene;\n /** Camera used for rendering */\n camera: Camera;\n /** When to re-render */\n updateMode: UISceneUpdateMode;\n /** Render target resolution multiplier. Range 0.1 to 2.0. */\n resolutionFactor: number;\n /** Background color */\n clearColor: UIColorConfig;\n /** Whether to use depth buffer */\n enableDepthBuffer: boolean;\n}\n\nexport const SCENE_DEFAULT_RESOLUTION_FACTOR = 0.5;\nexport const SCENE_MIN_RESOLUTION_FACTOR = 0.1;\nexport const SCENE_MAX_RESOLUTION_FACTOR = 2;\nexport const SCENE_DEFAULT_CAMERA_FOV = 60;\nexport const SCENE_DEFAULT_CAMERA_NEAR = 0.1;\nexport const SCENE_DEFAULT_CAMERA_FAR = 100;\nexport const SCENE_DEFAULT_UPDATE_MODE = UISceneUpdateMode.ON_PROPERTIES_CHANGE;\nexport const SCENE_DEFAULT_CLEAR_COLOR = new UIColor(0, 0, 0, 1);\nexport const SCENE_DEFAULT_USE_DEPTH = true;\n","import type { Camera, WebGLRenderer } from \"three\";\nimport {\n LinearFilter,\n MathUtils,\n Matrix3,\n PerspectiveCamera,\n RGBAFormat,\n Scene,\n UnsignedByteType,\n WebGLRenderTarget,\n} from \"three\";\nimport type { UILayer } from \"../../layers/UILayer/UILayer\";\nimport { assertValidPositiveNumber } from \"../../miscellaneous/asserts\";\nimport { UIColor } from \"../../miscellaneous/color/UIColor\";\nimport source from \"../../shaders/UIImage.glsl\";\nimport { UIElement } from \"../UIElement/UIElement\";\nimport {\n DUMMY_DEFAULT_HEIGHT,\n DUMMY_DEFAULT_WIDTH,\n} from \"../UIInputDummy/UIInputDummy.Internal\";\nimport type { UISceneOptions } from \"./UIScene.Internal\";\nimport {\n SCENE_DEFAULT_CAMERA_FAR,\n SCENE_DEFAULT_CAMERA_FOV,\n SCENE_DEFAULT_CAMERA_NEAR,\n SCENE_DEFAULT_CLEAR_COLOR,\n SCENE_DEFAULT_RESOLUTION_FACTOR,\n SCENE_DEFAULT_UPDATE_MODE,\n SCENE_DEFAULT_USE_DEPTH,\n SCENE_MAX_RESOLUTION_FACTOR,\n SCENE_MIN_RESOLUTION_FACTOR,\n UISceneUpdateMode,\n} from \"./UIScene.Internal\";\n\n/** Renders Three.js scene to texture */\nexport class UIScene extends UIElement {\n /** Multiplicative tint. Alpha channel controls opacity. */\n public readonly color: UIColor;\n /** Background color for render target */\n public readonly clearColor: UIColor;\n\n private readonly renderTarget: WebGLRenderTarget;\n private sceneInternal: Scene;\n private cameraInternal: Camera;\n private updateModeInternal: UISceneUpdateMode;\n private resolutionFactorInternal: number;\n private evenFrame = true;\n\n private updateRequired = false;\n private resolutionFactorDirty = false;\n private propertyDirty = false;\n\n /**\n * Creates a new UIScene instance.\n *\n * @param layer - Layer containing this element\n * @param options - Configuration options\n * @throws If resolutionFactor outside range 0.1 to 2.0\n */\n constructor(layer: UILayer, options: Partial<UISceneOptions> = {}) {\n if (options.resolutionFactor !== undefined) {\n assertValidPositiveNumber(\n options.resolutionFactor,\n \"UIScene.constructor.resolutionFactor\",\n );\n }\n\n const resolutionFactor = MathUtils.clamp(\n options.resolutionFactor ?? SCENE_DEFAULT_RESOLUTION_FACTOR,\n SCENE_MIN_RESOLUTION_FACTOR,\n SCENE_MAX_RESOLUTION_FACTOR,\n );\n\n const w = options.width ?? DUMMY_DEFAULT_WIDTH;\n const h = options.height ?? DUMMY_DEFAULT_HEIGHT;\n\n const renderTarget = new WebGLRenderTarget(\n w * resolutionFactor,\n h * resolutionFactor,\n {\n format: RGBAFormat,\n minFilter: LinearFilter,\n magFilter: LinearFilter,\n type: UnsignedByteType,\n depthBuffer: options.enableDepthBuffer ?? SCENE_DEFAULT_USE_DEPTH,\n stencilBuffer: false,\n },\n );\n\n const color = new UIColor(options.color);\n\n super(\n layer,\n source,\n {\n texture: renderTarget.texture,\n textureTransform: new Matrix3(),\n color,\n },\n options,\n );\n\n this.color = color;\n this.clearColor = new UIColor(\n options.clearColor ?? SCENE_DEFAULT_CLEAR_COLOR,\n );\n\n this.renderTarget = renderTarget;\n this.sceneInternal = options.scene ?? new Scene();\n\n this.cameraInternal =\n options.camera ??\n new PerspectiveCamera(\n SCENE_DEFAULT_CAMERA_FOV,\n w / h,\n SCENE_DEFAULT_CAMERA_NEAR,\n SCENE_DEFAULT_CAMERA_FAR,\n );\n\n this.resolutionFactorInternal = resolutionFactor;\n this.updateModeInternal = options.updateMode ?? SCENE_DEFAULT_UPDATE_MODE;\n this.propertyDirty = options.updateMode !== UISceneUpdateMode.MANUAL;\n }\n\n /** Three.js scene to render */\n public get scene(): Scene {\n return this.sceneInternal;\n }\n\n /** Camera used for rendering */\n public get camera(): Camera {\n return this.cameraInternal;\n }\n\n /** Controls when scene re-renders */\n public get updateMode(): UISceneUpdateMode {\n return this.updateModeInternal;\n }\n\n /** Render target resolution multiplier. Range 0.1 to 2.0. */\n public get resolutionFactor(): number {\n return this.resolutionFactorInternal;\n }\n\n /** Three.js scene to render */\n public set scene(value: Scene) {\n if (this.sceneInternal !== value) {\n this.sceneInternal = value;\n this.propertyDirty = true;\n }\n }\n\n /** Camera used for rendering */\n public set camera(value: Camera) {\n if (this.cameraInternal !== value) {\n this.cameraInternal = value;\n this.propertyDirty = true;\n }\n }\n\n /** Controls when scene re-renders */\n public set updateMode(value: UISceneUpdateMode) {\n if (this.updateModeInternal !== value) {\n this.updateModeInternal = value;\n this.propertyDirty = true;\n }\n }\n\n /** Render target resolution multiplier. Range 0.1 to 2.0. */\n public set resolutionFactor(value: number) {\n assertValidPositiveNumber(value, \"UIScene.resolutionFactor\");\n value = MathUtils.clamp(\n value,\n SCENE_MIN_RESOLUTION_FACTOR,\n SCENE_MAX_RESOLUTION_FACTOR,\n );\n if (this.resolutionFactorInternal !== value) {\n this.resolutionFactorInternal = value;\n this.resolutionFactorDirty = true;\n }\n }\n\n /** Removes element and frees resources */\n public override destroy(): void {\n this.renderTarget.dispose();\n super.destroy();\n }\n\n /** Triggers re-render on next frame. Useful in MANUAL mode. */\n public requestUpdate(): void {\n this.updateRequired = true;\n }\n\n protected override onWillRender(\n renderer: WebGLRenderer,\n deltaTime: number,\n ): void {\n this.evenFrame = !this.evenFrame;\n\n const isFramebufferDirty =\n this.updateRequired ||\n this.updateModeInternal === UISceneUpdateMode.EACH_FRAME ||\n (this.updateModeInternal === UISceneUpdateMode.EVERY_SECOND_FRAME &&\n this.evenFrame) ||\n (this.updateModeInternal === UISceneUpdateMode.ON_PROPERTIES_CHANGE &&\n this.propertyDirty) ||\n this.color.dirty ||\n this.clearColor.dirty ||\n (this.updateModeInternal === UISceneUpdateMode.ON_DIMENSIONS_CHANGE &&\n (this.resolutionFactorDirty || this.solverWrapper.dirty));\n\n if (isFramebufferDirty) {\n if (this.resolutionFactorDirty || this.solverWrapper.dirty) {\n this.renderTarget.setSize(\n this.width * this.resolutionFactorInternal,\n this.height * this.resolutionFactorInternal,\n );\n this.resolutionFactorDirty = false;\n }\n\n if (this.color.dirty) {\n this.sceneWrapper.setProperties(this.planeHandler, {\n color: this.color,\n });\n this.color.setDirtyFalse();\n }\n\n renderer.setClearColor(this.clearColor.getHexRGB(), this.clearColor.a);\n renderer.setRenderTarget(this.renderTarget);\n renderer.clear(true, true, false);\n renderer.render(this.sceneInternal, this.cameraInternal);\n\n this.propertyDirty = false;\n this.updateRequired = false;\n }\n super.onWillRender(renderer, deltaTime);\n }\n}\n","/** Complete text style configuration with all properties resolved */\nexport interface UITextStyleConfig {\n /** Text color */\n color: string;\n /** Text alignment */\n align: \"left\" | \"center\" | \"right\";\n\n /** Font family name */\n fontFamily: string;\n /** Font size in pixels */\n fontSize: number;\n /** Font style */\n fontStyle: \"normal\" | \"italic\" | \"oblique\";\n /** Font weight */\n fontWeight: \"normal\" | \"bold\" | \"bolder\" | \"lighter\" | number;\n /** Line height in pixels */\n lineHeight: number;\n\n /** Whether shadow is enabled */\n enableShadow: boolean;\n /** Shadow horizontal offset in pixels */\n shadowOffsetX: number;\n /** Shadow vertical offset in pixels */\n shadowOffsetY: number;\n /** Shadow blur radius in pixels */\n shadowBlur: number;\n /** Shadow color */\n shadowColor: string;\n\n /** Whether stroke is enabled */\n enableStroke: boolean;\n /** Stroke color */\n strokeColor: string;\n /** Stroke thickness in pixels */\n strokeThickness: number;\n}\n\nexport const TEXT_STYLE_DEFAULT_COLOR = \"#000000\";\nexport const TEXT_STYLE_DEFAULT_ALIGN = \"left\" as const;\nexport const TEXT_STYLE_DEFAULT_FONT_FAMILY = \"Arial\";\nexport const TEXT_STYLE_DEFAULT_FONT_SIZE = 16;\nexport const TEXT_STYLE_DEFAULT_FONT_STYLE = \"normal\" as const;\nexport const TEXT_STYLE_DEFAULT_FONT_WEIGHT = \"normal\" as const;\nexport const TEXT_STYLE_DEFAULT_LINE_HEIGHT = 1.2;\nexport const TEXT_STYLE_DEFAULT_ENABLE_SHADOW = false;\nexport const TEXT_STYLE_DEFAULT_SHADOW_OFFSET_X = 0;\nexport const TEXT_STYLE_DEFAULT_SHADOW_OFFSET_Y = 0;\nexport const TEXT_STYLE_DEFAULT_SHADOW_BLUR = 0;\nexport const TEXT_STYLE_DEFAULT_SHADOW_COLOR = \"transparent\";\nexport const TEXT_STYLE_DEFAULT_ENABLE_STROKE = false;\nexport const TEXT_STYLE_DEFAULT_STROKE_COLOR = \"#000000\";\nexport const TEXT_STYLE_DEFAULT_STROKE_THICKNESS = 0;\n","import {\n assertValidNonNegativeNumber,\n assertValidNumber,\n assertValidPositiveNumber,\n} from \"../asserts\";\nimport type { UITextStyleConfig } from \"./UITextStyle.Internal\";\nimport {\n TEXT_STYLE_DEFAULT_ALIGN,\n TEXT_STYLE_DEFAULT_COLOR,\n TEXT_STYLE_DEFAULT_ENABLE_SHADOW,\n TEXT_STYLE_DEFAULT_ENABLE_STROKE,\n TEXT_STYLE_DEFAULT_FONT_FAMILY,\n TEXT_STYLE_DEFAULT_FONT_SIZE,\n TEXT_STYLE_DEFAULT_FONT_STYLE,\n TEXT_STYLE_DEFAULT_FONT_WEIGHT,\n TEXT_STYLE_DEFAULT_LINE_HEIGHT,\n TEXT_STYLE_DEFAULT_SHADOW_BLUR,\n TEXT_STYLE_DEFAULT_SHADOW_COLOR,\n TEXT_STYLE_DEFAULT_SHADOW_OFFSET_X,\n TEXT_STYLE_DEFAULT_SHADOW_OFFSET_Y,\n TEXT_STYLE_DEFAULT_STROKE_COLOR,\n TEXT_STYLE_DEFAULT_STROKE_THICKNESS,\n} from \"./UITextStyle.Internal\";\n\n/** Text style configuration for UI text rendering */\nexport class UITextStyle {\n private colorInternal?: string;\n private alignInternal?: \"left\" | \"center\" | \"right\";\n private fontFamilyInternal?: string;\n private fontSizeInternal?: number;\n private fontStyleInternal?: \"normal\" | \"italic\" | \"oblique\";\n private fontWeightInternal?:\n | \"normal\"\n | \"bold\"\n | \"bolder\"\n | \"lighter\"\n | number;\n private lineHeightInternal?: number;\n private enableShadowInternal?: boolean;\n private shadowOffsetXInternal?: number;\n private shadowOffsetYInternal?: number;\n private shadowBlurInternal?: number;\n private shadowColorInternal?: string;\n private enableStrokeInternal?: boolean;\n private strokeColorInternal?: string;\n private strokeThicknessInternal?: number;\n\n private dirtyInternal = true;\n\n /** @param config Partial style configuration. Unspecified properties remain undefined. */\n constructor(config?: Partial<UITextStyleConfig>) {\n this.colorInternal = config?.color;\n this.alignInternal = config?.align;\n this.fontFamilyInternal = config?.fontFamily;\n this.fontSizeInternal = config?.fontSize;\n this.fontStyleInternal = config?.fontStyle;\n this.fontWeightInternal = config?.fontWeight;\n this.lineHeightInternal = config?.lineHeight;\n this.enableShadowInternal = config?.enableShadow;\n this.shadowOffsetXInternal = config?.shadowOffsetX;\n this.shadowOffsetYInternal = config?.shadowOffsetY;\n this.shadowBlurInternal = config?.shadowBlur;\n this.shadowColorInternal = config?.shadowColor;\n this.enableStrokeInternal = config?.enableStroke;\n this.strokeColorInternal = config?.strokeColor;\n this.strokeThicknessInternal = config?.strokeThickness;\n }\n\n /** Text color */\n public get color(): string | undefined {\n return this.colorInternal;\n }\n\n /** Text alignment */\n public get align(): \"left\" | \"center\" | \"right\" | undefined {\n return this.alignInternal;\n }\n\n /** Font family name */\n public get fontFamily(): string | undefined {\n return this.fontFamilyInternal;\n }\n\n /** Font size in pixels */\n public get fontSize(): number | undefined {\n return this.fontSizeInternal;\n }\n\n /** Font style */\n public get fontStyle(): \"normal\" | \"italic\" | \"oblique\" | undefined {\n return this.fontStyleInternal;\n }\n\n /** Font weight */\n public get fontWeight():\n | \"normal\"\n | \"bold\"\n | \"bolder\"\n | \"lighter\"\n | number\n | undefined {\n return this.fontWeightInternal;\n }\n\n /** Line height in pixels */\n public get lineHeight(): number | undefined {\n return this.lineHeightInternal;\n }\n\n /** Whether shadow is enabled */\n public get enableShadow(): boolean | undefined {\n return this.enableShadowInternal;\n }\n\n /** Shadow horizontal offset in pixels */\n public get shadowOffsetX(): number | undefined {\n return this.shadowOffsetXInternal;\n }\n\n /** Shadow vertical offset in pixels */\n public get shadowOffsetY(): number | undefined {\n return this.shadowOffsetYInternal;\n }\n\n /** Shadow blur radius in pixels */\n public get shadowBlur(): number | undefined {\n return this.shadowBlurInternal;\n }\n\n /** Shadow color */\n public get shadowColor(): string | undefined {\n return this.shadowColorInternal;\n }\n\n /** Whether stroke is enabled */\n public get enableStroke(): boolean | undefined {\n return this.enableStrokeInternal;\n }\n\n /** Stroke color */\n public get strokeColor(): string | undefined {\n return this.strokeColorInternal;\n }\n\n /** Stroke thickness in pixels */\n public get strokeThickness(): number | undefined {\n return this.strokeThicknessInternal;\n }\n\n /**\n * Indicates whether any property has been modified.\n * Must be reset to `false` externally by the owner.\n * @internal\n */\n public get dirty(): boolean {\n return this.dirtyInternal;\n }\n\n public set color(value: string | undefined) {\n if (value !== this.colorInternal) {\n this.colorInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n public set align(value: \"left\" | \"center\" | \"right\" | undefined) {\n if (value !== this.alignInternal) {\n this.alignInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n public set fontFamily(value: string | undefined) {\n if (value !== this.fontFamilyInternal) {\n this.fontFamilyInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n public set fontSize(value: number | undefined) {\n if (value !== undefined) {\n assertValidPositiveNumber(value, \"UITextStyle.fontSize\");\n }\n if (value !== this.fontSizeInternal) {\n this.fontSizeInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n public set fontStyle(value: \"normal\" | \"italic\" | \"oblique\" | undefined) {\n if (value !== this.fontStyleInternal) {\n this.fontStyleInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n public set fontWeight(\n value: \"normal\" | \"bold\" | \"bolder\" | \"lighter\" | number | undefined,\n ) {\n if (typeof value === \"number\") {\n assertValidPositiveNumber(value, \"UITextStyle.fontWeight\");\n }\n if (value !== this.fontWeightInternal) {\n this.fontWeightInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n public set lineHeight(value: number | undefined) {\n if (value !== undefined) {\n assertValidNumber(value, \"UITextStyle.lineHeight\");\n }\n if (value !== this.lineHeightInternal) {\n this.lineHeightInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n public set enableShadow(value: boolean | undefined) {\n if (value !== this.enableShadowInternal) {\n this.enableShadowInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n public set shadowOffsetX(value: number | undefined) {\n if (value !== undefined) {\n assertValidNonNegativeNumber(value, \"UITextStyle.shadowOffsetX\");\n }\n if (value !== this.shadowOffsetXInternal) {\n this.shadowOffsetXInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n public set shadowOffsetY(value: number | undefined) {\n if (value !== undefined) {\n assertValidNonNegativeNumber(value, \"UITextStyle.shadowOffsetY\");\n }\n if (value !== this.shadowOffsetYInternal) {\n this.shadowOffsetYInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n public set shadowBlur(value: number | undefined) {\n if (value !== undefined) {\n assertValidNonNegativeNumber(value, \"UITextStyle.shadowBlur\");\n }\n if (value !== this.shadowBlurInternal) {\n this.shadowBlurInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n public set shadowColor(value: string | undefined) {\n if (value !== this.shadowColorInternal) {\n this.shadowColorInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n public set enableStroke(value: boolean | undefined) {\n if (value !== this.enableStrokeInternal) {\n this.enableStrokeInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n public set strokeColor(value: string | undefined) {\n if (value !== this.strokeColorInternal) {\n this.strokeColorInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n public set strokeThickness(value: number | undefined) {\n if (value !== undefined) {\n assertValidNonNegativeNumber(value, \"UITextStyle.strokeThickness\");\n }\n if (value !== this.strokeThicknessInternal) {\n this.strokeThicknessInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n /**\n * Resolves complete style from primary and fallback sources.\n * @param primary First style to check for each property\n * @param fallback Second style to check if primary is undefined\n * @returns Complete style configuration with all defaults applied\n */\n public static resolve(\n primary?: UITextStyle,\n fallback?: UITextStyle,\n ): UITextStyleConfig {\n const fontSize =\n primary?.fontSizeInternal ??\n fallback?.fontSizeInternal ??\n TEXT_STYLE_DEFAULT_FONT_SIZE;\n\n return {\n color:\n primary?.colorInternal ??\n fallback?.colorInternal ??\n TEXT_STYLE_DEFAULT_COLOR,\n align:\n primary?.alignInternal ??\n fallback?.alignInternal ??\n TEXT_STYLE_DEFAULT_ALIGN,\n fontFamily:\n primary?.fontFamilyInternal ??\n fallback?.fontFamilyInternal ??\n TEXT_STYLE_DEFAULT_FONT_FAMILY,\n fontSize,\n fontStyle:\n primary?.fontStyleInternal ??\n fallback?.fontStyleInternal ??\n TEXT_STYLE_DEFAULT_FONT_STYLE,\n fontWeight:\n primary?.fontWeightInternal ??\n fallback?.fontWeightInternal ??\n TEXT_STYLE_DEFAULT_FONT_WEIGHT,\n lineHeight:\n primary?.lineHeightInternal ??\n fallback?.lineHeightInternal ??\n fontSize * TEXT_STYLE_DEFAULT_LINE_HEIGHT,\n enableShadow:\n primary?.enableShadowInternal ??\n fallback?.enableShadowInternal ??\n TEXT_STYLE_DEFAULT_ENABLE_SHADOW,\n shadowOffsetX:\n primary?.shadowOffsetXInternal ??\n fallback?.shadowOffsetXInternal ??\n TEXT_STYLE_DEFAULT_SHADOW_OFFSET_X,\n shadowOffsetY:\n primary?.shadowOffsetYInternal ??\n fallback?.shadowOffsetYInternal ??\n TEXT_STYLE_DEFAULT_SHADOW_OFFSET_Y,\n shadowBlur:\n primary?.shadowBlurInternal ??\n fallback?.shadowBlurInternal ??\n TEXT_STYLE_DEFAULT_SHADOW_BLUR,\n shadowColor:\n primary?.shadowColorInternal ??\n fallback?.shadowColorInternal ??\n TEXT_STYLE_DEFAULT_SHADOW_COLOR,\n enableStroke:\n primary?.enableStrokeInternal ??\n fallback?.enableStrokeInternal ??\n TEXT_STYLE_DEFAULT_ENABLE_STROKE,\n strokeColor:\n primary?.strokeColorInternal ??\n fallback?.strokeColorInternal ??\n TEXT_STYLE_DEFAULT_STROKE_COLOR,\n strokeThickness:\n primary?.strokeThicknessInternal ??\n fallback?.strokeThicknessInternal ??\n TEXT_STYLE_DEFAULT_STROKE_THICKNESS,\n };\n }\n\n /** @internal */\n public setDirtyFalse(): void {\n this.dirtyInternal = false;\n }\n\n /** Sets all properties to default values */\n public setDefaults(): void {\n if (\n this.colorInternal !== TEXT_STYLE_DEFAULT_COLOR ||\n this.alignInternal !== TEXT_STYLE_DEFAULT_ALIGN ||\n this.fontFamilyInternal !== TEXT_STYLE_DEFAULT_FONT_FAMILY ||\n this.fontSizeInternal !== TEXT_STYLE_DEFAULT_FONT_SIZE ||\n this.fontStyleInternal !== TEXT_STYLE_DEFAULT_FONT_STYLE ||\n this.fontWeightInternal !== TEXT_STYLE_DEFAULT_FONT_WEIGHT ||\n this.lineHeightInternal !==\n TEXT_STYLE_DEFAULT_FONT_SIZE * TEXT_STYLE_DEFAULT_LINE_HEIGHT ||\n this.enableShadowInternal !== TEXT_STYLE_DEFAULT_ENABLE_SHADOW ||\n this.shadowOffsetXInternal !== TEXT_STYLE_DEFAULT_SHADOW_OFFSET_X ||\n this.shadowOffsetYInternal !== TEXT_STYLE_DEFAULT_SHADOW_OFFSET_Y ||\n this.shadowBlurInternal !== TEXT_STYLE_DEFAULT_SHADOW_BLUR ||\n this.shadowColorInternal !== TEXT_STYLE_DEFAULT_SHADOW_COLOR ||\n this.enableStrokeInternal !== TEXT_STYLE_DEFAULT_ENABLE_STROKE ||\n this.strokeColorInternal !== TEXT_STYLE_DEFAULT_STROKE_COLOR ||\n this.strokeThicknessInternal !== TEXT_STYLE_DEFAULT_STROKE_THICKNESS\n ) {\n this.colorInternal = TEXT_STYLE_DEFAULT_COLOR;\n this.alignInternal = TEXT_STYLE_DEFAULT_ALIGN;\n this.fontFamilyInternal = TEXT_STYLE_DEFAULT_FONT_FAMILY;\n this.fontSizeInternal = TEXT_STYLE_DEFAULT_FONT_SIZE;\n this.fontStyleInternal = TEXT_STYLE_DEFAULT_FONT_STYLE;\n this.fontWeightInternal = TEXT_STYLE_DEFAULT_FONT_WEIGHT;\n this.lineHeightInternal =\n TEXT_STYLE_DEFAULT_FONT_SIZE * TEXT_STYLE_DEFAULT_LINE_HEIGHT;\n this.enableShadowInternal = TEXT_STYLE_DEFAULT_ENABLE_SHADOW;\n this.shadowOffsetXInternal = TEXT_STYLE_DEFAULT_SHADOW_OFFSET_X;\n this.shadowOffsetYInternal = TEXT_STYLE_DEFAULT_SHADOW_OFFSET_Y;\n this.shadowBlurInternal = TEXT_STYLE_DEFAULT_SHADOW_BLUR;\n this.shadowColorInternal = TEXT_STYLE_DEFAULT_SHADOW_COLOR;\n this.enableStrokeInternal = TEXT_STYLE_DEFAULT_ENABLE_STROKE;\n this.strokeColorInternal = TEXT_STYLE_DEFAULT_STROKE_COLOR;\n this.strokeThicknessInternal = TEXT_STYLE_DEFAULT_STROKE_THICKNESS;\n this.dirtyInternal = true;\n }\n }\n\n /** Sets all properties to undefined */\n public clear(): void {\n if (\n this.colorInternal !== undefined ||\n this.alignInternal !== undefined ||\n this.fontFamilyInternal !== undefined ||\n this.fontSizeInternal !== undefined ||\n this.fontStyleInternal !== undefined ||\n this.fontWeightInternal !== undefined ||\n this.lineHeightInternal !== undefined ||\n this.enableShadowInternal !== undefined ||\n this.shadowOffsetXInternal !== undefined ||\n this.shadowOffsetYInternal !== undefined ||\n this.shadowBlurInternal !== undefined ||\n this.shadowColorInternal !== undefined ||\n this.enableStrokeInternal !== undefined ||\n this.strokeColorInternal !== undefined ||\n this.strokeThicknessInternal !== undefined\n ) {\n this.colorInternal = undefined;\n this.alignInternal = undefined;\n this.fontFamilyInternal = undefined;\n this.fontSizeInternal = undefined;\n this.fontStyleInternal = undefined;\n this.fontWeightInternal = undefined;\n this.lineHeightInternal = undefined;\n this.enableShadowInternal = undefined;\n this.shadowOffsetXInternal = undefined;\n this.shadowOffsetYInternal = undefined;\n this.shadowBlurInternal = undefined;\n this.shadowColorInternal = undefined;\n this.enableStrokeInternal = undefined;\n this.strokeColorInternal = undefined;\n this.strokeThicknessInternal = undefined;\n this.dirtyInternal = true;\n }\n }\n\n /** Copies from another style instance */\n public copy(value: UITextStyle): void {\n if (\n this.colorInternal !== value.colorInternal ||\n this.alignInternal !== value.alignInternal ||\n this.fontFamilyInternal !== value.fontFamilyInternal ||\n this.fontSizeInternal !== value.fontSizeInternal ||\n this.fontStyleInternal !== value.fontStyleInternal ||\n this.fontWeightInternal !== value.fontWeightInternal ||\n this.lineHeightInternal !== value.lineHeightInternal ||\n this.enableShadowInternal !== value.enableShadowInternal ||\n this.shadowOffsetXInternal !== value.shadowOffsetXInternal ||\n this.shadowOffsetYInternal !== value.shadowOffsetYInternal ||\n this.shadowBlurInternal !== value.shadowBlurInternal ||\n this.shadowColorInternal !== value.shadowColorInternal ||\n this.enableStrokeInternal !== value.enableStrokeInternal ||\n this.strokeColorInternal !== value.strokeColorInternal ||\n this.strokeThicknessInternal !== value.strokeThicknessInternal\n ) {\n this.colorInternal = value.colorInternal;\n this.alignInternal = value.alignInternal;\n this.fontFamilyInternal = value.fontFamilyInternal;\n this.fontSizeInternal = value.fontSizeInternal;\n this.fontStyleInternal = value.fontStyleInternal;\n this.fontWeightInternal = value.fontWeightInternal;\n this.lineHeightInternal = value.lineHeightInternal;\n this.enableShadowInternal = value.enableShadowInternal;\n this.shadowOffsetXInternal = value.shadowOffsetXInternal;\n this.shadowOffsetYInternal = value.shadowOffsetYInternal;\n this.shadowBlurInternal = value.shadowBlurInternal;\n this.shadowColorInternal = value.shadowColorInternal;\n this.enableStrokeInternal = value.enableStrokeInternal;\n this.strokeColorInternal = value.strokeColorInternal;\n this.strokeThicknessInternal = value.strokeThicknessInternal;\n this.dirtyInternal = true;\n }\n }\n\n /**\n * Calculates maximum padding required for stroke and shadow.\n * @returns Padding in pixels needed on all sides\n */\n public calculatePadding(): number {\n let padding = 0;\n\n if (this.enableStrokeInternal !== undefined) {\n padding += this.strokeThicknessInternal ?? 0;\n }\n\n if (this.enableShadowInternal !== undefined) {\n const blur = this.shadowBlurInternal ?? 0;\n const offsetX = this.shadowOffsetXInternal ?? 0;\n const offsetY = this.shadowOffsetYInternal ?? 0;\n const shadowSpread = blur * 2;\n const shadowMaxX = Math.abs(offsetX) + shadowSpread;\n const shadowMaxY = Math.abs(offsetY) + shadowSpread;\n padding += Math.max(shadowMaxX, shadowMaxY);\n }\n\n return Math.ceil(padding);\n }\n}\n","import { UITextStyle } from \"../text-style/UITextStyle\";\nimport type { UITextSpanConfig } from \"./UITextSpan.Internal\";\n\n/** Text span with associated style */\nexport class UITextSpan {\n /** Text style */\n public style: UITextStyle;\n private textInternal: string;\n private dirtyInternal = true;\n\n /** @param config Text span configuration */\n constructor(config: UITextSpanConfig) {\n this.textInternal = config.text;\n this.style = new UITextStyle(config.style);\n }\n\n /** Text content */\n public get text(): string {\n return this.textInternal;\n }\n\n /**\n * Indicates whether text or style has been modified.\n * Must be reset to `false` externally by the owner.\n * @internal\n */\n public get dirty(): boolean {\n return this.dirtyInternal || this.style.dirty;\n }\n\n public set text(value: string) {\n if (value !== this.textInternal) {\n this.textInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n /** @internal */\n public setDirtyFalse(): void {\n this.dirtyInternal = false;\n this.style.setDirtyFalse();\n }\n}\n","import type { UIColorConfig } from \"../../miscellaneous/color/UIColor.Internal\";\nimport type { UIInsetsConfig } from \"../../miscellaneous/insets/UIInsets.Internal\";\nimport type { UITextStyleConfig } from \"../../miscellaneous/text-style/UITextStyle.Internal\";\nimport type { UIElementOptions } from \"../UIElement/UIElement.Internal\";\n\n/** Controls how text adapts to element size */\nexport enum UITextResizeMode {\n /** Break text into multiple lines when narrower than content*/\n BREAK = 0,\n /** Scale text to fit fixed element size */\n SCALE = 1,\n}\n\n/** Configuration options for UIText */\nexport interface UITextOptions extends UIElementOptions {\n /** Multiplicative tint */\n color: UIColorConfig;\n /** Text padding in world units */\n padding: UIInsetsConfig;\n /** Default style applied to all spans */\n commonStyle: Partial<UITextStyleConfig>;\n /** How text adapts to size constraints */\n resizeMode: UITextResizeMode;\n /** Maximum line width before wrapping in pixels */\n maxLineWidth: number;\n}\n\nexport const TEXT_DEFAULT_MAX_LINE_WIDTH = 1024;\nexport const TEXT_DEFAULT_RESIZE_MODE = UITextResizeMode.SCALE;\n","import type { UITextSpan } from \"../../miscellaneous/text-span/UITextSpan\";\nimport { UITextStyle } from \"../../miscellaneous/text-style/UITextStyle\";\nimport type { UITextStyleConfig } from \"../../miscellaneous/text-style/UITextStyle.Internal\";\nimport type {\n UIChunkMetrics,\n UITextChunk,\n UITextLine,\n UITextSize,\n} from \"./UIText.Interfaces\";\n\n/**\n * Splits text into renderable chunks.\n * @param text Text to split\n * @returns Array of words, spaces, and newlines\n */\nexport function splitTextIntoChunks(text: string): string[] {\n return text.match(/\\S+|\\s|\\n/g) ?? [];\n}\n\n/**\n * Measures single text chunk.\n * @param context Canvas context for measurement\n * @param text Chunk text\n * @param textStyle Resolved text style\n * @returns Chunk metrics\n */\nexport function measureTextChunk(\n context: OffscreenCanvasRenderingContext2D,\n text: string,\n textStyle: UITextStyleConfig,\n): UIChunkMetrics {\n context.font = `${textStyle.fontStyle} ${textStyle.fontWeight} ${textStyle.fontSize}px \"${textStyle.fontFamily}\"`;\n\n if (text === \"\\n\") {\n return {\n width: Math.ceil(1),\n height: textStyle.lineHeight,\n baseline: 0,\n lineHeight: textStyle.lineHeight,\n };\n }\n\n const metrics = context.measureText(text);\n const width = Math.ceil(metrics.width);\n const height = Math.ceil(\n metrics.actualBoundingBoxAscent + metrics.actualBoundingBoxDescent,\n );\n\n return {\n width,\n height,\n baseline: metrics.actualBoundingBoxDescent,\n lineHeight: textStyle.lineHeight,\n };\n}\n\n/**\n * Builds text lines with word wrapping.\n * @param maxWidth Maximum line width in pixels\n * @param textChunks Measured text chunks\n * @returns Array of text lines\n */\nexport function buildTextLines(\n maxWidth: number,\n textChunks: UITextChunk[],\n): UITextLine[] {\n const lines: UITextLine[] = [];\n let currentLine: UITextChunk[] = [];\n let currentWidth = 0;\n let currentHeight = 0;\n let currentBaseline = 0;\n let currentLineHeight = 0;\n\n for (const textChunk of textChunks) {\n if (textChunk.text === \"\\n\") {\n if (currentLine.length > 0) {\n lines.push({\n chunks: currentLine,\n width: currentWidth,\n height: currentHeight,\n baseline: currentBaseline,\n lineHeight: currentLineHeight,\n });\n }\n currentLine = [];\n currentWidth = 0;\n currentHeight = 0;\n currentBaseline = 0;\n currentLineHeight = 0;\n continue;\n }\n\n if (\n currentLine.length === 0 ||\n currentWidth + textChunk.metrics.width <= maxWidth\n ) {\n currentLine.push(textChunk);\n currentWidth += textChunk.metrics.width;\n currentHeight = Math.max(currentHeight, textChunk.metrics.height);\n currentBaseline = Math.max(currentBaseline, textChunk.metrics.baseline);\n currentLineHeight = Math.max(\n currentLineHeight,\n textChunk.metrics.lineHeight,\n );\n } else {\n lines.push({\n chunks: currentLine,\n width: currentWidth,\n height: currentHeight,\n baseline: currentBaseline,\n lineHeight: currentLineHeight,\n });\n currentLine = [textChunk];\n currentWidth = textChunk.metrics.width;\n currentHeight = textChunk.metrics.height;\n currentBaseline = textChunk.metrics.baseline;\n currentLineHeight = textChunk.metrics.lineHeight;\n }\n }\n\n if (currentLine.length > 0) {\n lines.push({\n chunks: currentLine,\n width: currentWidth,\n height: currentHeight,\n baseline: currentBaseline,\n lineHeight: currentLineHeight,\n });\n }\n\n return lines;\n}\n\n/**\n * Calculates total text size from lines.\n * @param lines Text lines\n * @returns Total width and height\n */\nexport function calculateTextSize(lines: UITextLine[]): UITextSize {\n if (lines.length === 0) {\n return { width: 0, height: 0 };\n }\n\n const maxLineWidth = Math.max(...lines.map((line) => line.width));\n let totalHeight = 0;\n\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i];\n totalHeight += i === 0 ? line.height : line.lineHeight;\n }\n\n return { width: maxLineWidth, height: totalHeight };\n}\n\n/**\n * Builds measured text chunks from spans.\n * @param context Canvas context for measurement\n * @param textSpans Text spans with styles\n * @param commonStyle Fallback style\n * @returns Measured text chunks\n */\nexport function buildTextChunks(\n context: OffscreenCanvasRenderingContext2D,\n textSpans: UITextSpan[],\n commonStyle: UITextStyle,\n): UITextChunk[] {\n const textChunks: UITextChunk[] = [];\n\n for (const textSpan of textSpans) {\n const textStyle = UITextStyle.resolve(textSpan.style, commonStyle);\n\n for (const textChunk of splitTextIntoChunks(textSpan.text)) {\n const textChunkMetrics = measureTextChunk(context, textChunk, textStyle);\n textChunks.push({\n text: textChunk,\n style: textStyle,\n metrics: textChunkMetrics,\n });\n }\n }\n\n return textChunks;\n}\n\n/**\n * Calculates text layout parameters.\n * @param textChunks Measured text chunks\n * @param maxLineWidth Maximum line width in pixels\n * @returns Lines and total size\n */\nexport function calculateTextContentParameters(\n textChunks: UITextChunk[],\n maxLineWidth: number,\n): { lines: UITextLine[]; size: UITextSize } {\n const lines = buildTextLines(maxLineWidth, textChunks);\n const size = calculateTextSize(lines);\n return { lines, size };\n}\n","import type { UITextStyleConfig } from \"../../miscellaneous/text-style/UITextStyle.Internal\";\nimport { TEXT_STYLE_DEFAULT_ALIGN } from \"../../miscellaneous/text-style/UITextStyle.Internal\";\nimport type { UITextLine } from \"./UIText.Interfaces\";\n\n/**\n * Renders single text chunk.\n * @param x X coordinate in pixels\n * @param y Y coordinate in pixels\n * @param text Chunk text\n * @param style Resolved text style\n * @param context Canvas rendering context\n */\nexport function renderTextChunk(\n x: number,\n y: number,\n text: string,\n style: UITextStyleConfig,\n context: OffscreenCanvasRenderingContext2D,\n): void {\n context.font = `${style.fontStyle} ${style.fontWeight} ${style.fontSize}px \"${style.fontFamily}\"`;\n\n if (style.enableShadow) {\n context.shadowOffsetX = style.shadowOffsetX;\n context.shadowOffsetY = style.shadowOffsetY;\n context.shadowBlur = style.shadowBlur;\n context.shadowColor = style.shadowColor;\n }\n\n if (style.enableStroke) {\n context.strokeStyle = style.strokeColor;\n context.lineWidth = style.strokeThickness;\n context.strokeText(text, x, y);\n }\n\n context.fillStyle = style.color;\n context.fillText(text, x, y);\n}\n\n/**\n * Renders text lines to canvas.\n * @param paddingTop Top padding in pixels\n * @param paddingLeft Left padding in pixels\n * @param lines Text lines to render\n * @param context Canvas rendering context\n */\nexport function renderTextLines(\n paddingTop: number,\n paddingLeft: number,\n lines: UITextLine[],\n context: OffscreenCanvasRenderingContext2D,\n): void {\n let currentY = paddingTop;\n\n let textWidth = 0;\n for (const line of lines) {\n textWidth = Math.max(line.width, textWidth);\n }\n\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i];\n\n const firstAlign = line.chunks[0]?.style.align ?? TEXT_STYLE_DEFAULT_ALIGN;\n const isUniformAlign = line.chunks.every(\n (c) => c.style.align === firstAlign,\n );\n const lineAlign = isUniformAlign ? firstAlign : TEXT_STYLE_DEFAULT_ALIGN;\n\n let offsetX = 0;\n\n if (lineAlign === \"center\") {\n offsetX = (textWidth - line.width) / 2;\n } else if (lineAlign === \"right\") {\n offsetX = textWidth - line.width;\n }\n\n let currentX = paddingLeft + offsetX;\n currentY += i === 0 ? line.height : line.lineHeight;\n\n for (const chunk of line.chunks) {\n renderTextChunk(currentX, currentY, chunk.text, chunk.style, context);\n currentX += chunk.metrics.width;\n }\n }\n}\n","import type { WebGLRenderer } from \"three\";\nimport { CanvasTexture, Matrix3, SRGBColorSpace } from \"three\";\nimport type { UILayer } from \"../../layers/UILayer/UILayer\";\nimport { UIColor } from \"../../miscellaneous/color/UIColor\";\nimport type { UIPropertyType } from \"../../miscellaneous/generic-plane/shared\";\nimport { UIInsets } from \"../../miscellaneous/insets/UIInsets\";\nimport { UITextSpan } from \"../../miscellaneous/text-span/UITextSpan\";\nimport { UITextStyle } from \"../../miscellaneous/text-style/UITextStyle\";\nimport source from \"../../shaders/UIImage.glsl\";\nimport { UIElement } from \"../UIElement/UIElement\";\nimport type { UITextChunk, UITextContent } from \"./UIText.Interfaces\";\nimport type { UITextOptions } from \"./UIText.Internal\";\nimport {\n TEXT_DEFAULT_MAX_LINE_WIDTH,\n TEXT_DEFAULT_RESIZE_MODE,\n UITextResizeMode,\n} from \"./UIText.Internal\";\nimport {\n buildTextChunks,\n calculateTextContentParameters,\n} from \"./UIText.Measuring\";\nimport { renderTextLines } from \"./UIText.Rendering\";\n\n/** Canvas-based text rendering element */\nexport class UIText extends UIElement {\n /** Multiplicative tint. Alpha channel controls opacity. */\n public readonly color: UIColor;\n /** Text padding in world units */\n public readonly padding: UIInsets;\n /** Default style applied to all text spans */\n public readonly commonStyle: UITextStyle;\n\n private readonly canvas: OffscreenCanvas;\n private readonly context: OffscreenCanvasRenderingContext2D;\n private texture: CanvasTexture;\n\n private contentInternal: UITextSpan[] = [];\n private contentDirty = false;\n\n private maxLineWidthInternal: number;\n private maxLineWidthDirty = false;\n\n private resizeModeInternal: UITextResizeMode;\n private resizeModeDirty = false;\n\n private lastWidth: number;\n private lastHeight: number;\n\n private textChunks: UITextChunk[] = [];\n private textChunksDirty = false;\n\n /**\n * Creates a new UIText instance.\n *\n * @param layer - Layer containing this element\n * @param content - Text content as string or styled spans\n * @param options - Configuration options\n */\n constructor(\n layer: UILayer,\n content: UITextContent,\n options: Partial<UITextOptions> = {},\n ) {\n const canvas = new OffscreenCanvas(2, 2);\n const context = canvas.getContext(\"2d\");\n\n if (!context) {\n throw new Error(\"UIText.constructor: failed to create canvas context\");\n }\n\n const texture = new CanvasTexture(canvas);\n texture.colorSpace = SRGBColorSpace;\n texture.needsUpdate = true;\n const color = new UIColor(options.color);\n\n super(layer, source, {\n texture: texture,\n textureTransform: new Matrix3(),\n color,\n });\n\n this.color = color;\n this.padding = new UIInsets(options.padding);\n this.commonStyle = new UITextStyle(options.commonStyle);\n this.maxLineWidthInternal =\n options.maxLineWidth ?? TEXT_DEFAULT_MAX_LINE_WIDTH;\n this.resizeModeInternal = options.resizeMode ?? TEXT_DEFAULT_RESIZE_MODE;\n\n this.canvas = canvas;\n this.context = context;\n this.texture = texture;\n this.content = content;\n\n this.lastWidth = this.width;\n this.lastHeight = this.height;\n\n if (options.padding === undefined) {\n this.padding.setUnified(\n this.content.reduce(\n (a, b) => Math.max(a, b.style.calculatePadding()),\n this.commonStyle.calculatePadding(),\n ),\n );\n }\n\n switch (this.resizeModeInternal) {\n case UITextResizeMode.SCALE:\n this.tryToRenderTextScaleMode();\n break;\n\n case UITextResizeMode.BREAK:\n this.tryToRenderTextBreakMode();\n break;\n }\n }\n\n /** Text content as array of styled spans */\n public get content(): UITextSpan[] {\n return this.contentInternal;\n }\n\n /** Maximum line width before wrapping in pixels */\n public get maxLineWidth(): number {\n return this.maxLineWidthInternal;\n }\n\n /** Controls how text adapts to element size */\n public get resizeMode(): UITextResizeMode {\n return this.resizeModeInternal;\n }\n\n /** Text content as string, span config, or array */\n public set content(value: UITextContent) {\n if (this.contentInternal !== value) {\n if (typeof value === \"string\") {\n this.contentInternal = [\n new UITextSpan({ text: value, style: new UITextStyle() }),\n ];\n } else if (Array.isArray(value)) {\n this.contentInternal = value.map((span) =>\n typeof span === \"string\"\n ? new UITextSpan({ text: span, style: new UITextStyle() })\n : new UITextSpan({\n text: span.text,\n style: new UITextStyle(span.style),\n }),\n );\n } else {\n this.contentInternal = [\n new UITextSpan({\n text: value.text,\n style: new UITextStyle(value.style),\n }),\n ];\n }\n this.contentDirty = true;\n this.textChunksDirty = true;\n }\n }\n\n /** Maximum line width before wrapping in pixels */\n public set maxLineWidth(value: number) {\n if (this.maxLineWidthInternal !== value) {\n this.maxLineWidthInternal = value;\n this.maxLineWidthDirty = true;\n }\n }\n\n /** Controls how text adapts to size constraints */\n public set resizeMode(value: UITextResizeMode) {\n if (this.resizeModeInternal !== value) {\n this.resizeModeInternal = value;\n this.resizeModeDirty = true;\n }\n }\n\n /** Removes element and frees resources */\n public override destroy(): void {\n this.texture.dispose();\n super.destroy();\n }\n\n protected override onWillRender(\n renderer: WebGLRenderer,\n deltaTime: number,\n ): void {\n switch (this.resizeModeInternal) {\n case UITextResizeMode.SCALE:\n this.tryToRenderTextScaleMode();\n break;\n\n case UITextResizeMode.BREAK:\n this.tryToRenderTextBreakMode();\n break;\n }\n\n super.onWillRender(renderer, deltaTime);\n }\n\n private tryToRenderTextScaleMode(): void {\n if (\n !this.resizeModeDirty &&\n !this.maxLineWidthDirty &&\n !this.padding.dirty &&\n !(\n this.solverWrapper.dirty &&\n this.lastWidth / this.lastHeight !==\n Math.round(this.width) / Math.round(this.height)\n ) &&\n !this.checkContentDirty()\n ) {\n return;\n }\n\n const textChunks = this.buildTextChunks();\n\n const { lines, size } = calculateTextContentParameters(\n textChunks,\n this.maxLineWidthInternal,\n );\n\n const paddingV = this.padding.top + this.padding.bottom;\n const paddingH = this.padding.left + this.padding.right;\n\n const desiredHeight = size.height + paddingV;\n const desiredWidth = size.width + paddingH;\n\n // Two calculation passes are required to cover both cases -\n // when the width is specified by a constraint and cannot be changed,\n // or when the height is specified by a constraint and cannot be changed,\n // but the width still has priority, because it is specified first and last.\n this.width = desiredWidth;\n this.height = (desiredHeight / desiredWidth) * Math.round(this.width);\n this.width = (desiredWidth / desiredHeight) * Math.round(this.height);\n\n const resolutionDirty =\n this.lastWidth !== desiredHeight || this.lastHeight !== desiredWidth;\n\n if (resolutionDirty) {\n this.canvas.height = desiredHeight;\n this.canvas.width = desiredWidth;\n }\n\n renderTextLines(this.padding.top, this.padding.left, lines, this.context);\n\n this.updateProperties(resolutionDirty);\n\n this.resizeModeDirty = false;\n this.maxLineWidthDirty = false;\n this.padding.setDirtyFalse();\n this.setDimensionsDirtyFalse();\n this.setContentDirtyFalse();\n }\n\n private tryToRenderTextBreakMode(): void {\n if (\n !this.resizeModeDirty &&\n !this.maxLineWidthDirty &&\n !this.padding.dirty &&\n !this.checkDimensionsDirty() &&\n !this.checkContentDirty()\n ) {\n return;\n }\n\n const textChunks = this.buildTextChunks();\n\n // Two passes of text size calculation are needed to first\n // suggest the desired sizes to the solver, and then\n // adjust our expectations based on the result obtained.\n\n const { size: desiredTextSize } = calculateTextContentParameters(\n textChunks,\n this.maxLineWidthInternal,\n );\n\n const paddingV = this.padding.top + this.padding.bottom;\n const paddingH = this.padding.left + this.padding.right;\n\n this.height = desiredTextSize.height + paddingV;\n this.width = desiredTextSize.width + paddingH; // Width should remain a priority, so it is set last.\n\n const { lines: realTextLines, size: realTextSize } =\n calculateTextContentParameters(\n textChunks,\n Math.round(this.width) - paddingH,\n );\n\n this.height = realTextSize.height + paddingV;\n this.width = realTextSize.width + paddingH;\n\n const safeWidth = Math.max(Math.round(this.width), 2);\n const safeHeight = Math.max(Math.round(this.height), 2);\n\n const resolutionDirty =\n this.lastWidth !== safeWidth || this.lastHeight !== safeHeight;\n\n if (resolutionDirty) {\n this.canvas.width = safeWidth;\n this.canvas.height = safeHeight;\n }\n\n renderTextLines(\n this.padding.top,\n this.padding.left,\n realTextLines,\n this.context,\n );\n\n this.updateProperties(resolutionDirty);\n\n this.resizeModeDirty = false;\n this.maxLineWidthDirty = false;\n this.padding.setDirtyFalse();\n this.setDimensionsDirtyFalse();\n this.setContentDirtyFalse();\n }\n\n private updateProperties(resolutionDirty: boolean): void {\n let properties: Record<string, UIPropertyType> | undefined;\n\n if (this.color.dirty) {\n properties ??= {};\n properties[\"color\"] = this.color;\n this.color.setDirtyFalse();\n }\n\n if (resolutionDirty) {\n this.texture.dispose();\n this.texture = new CanvasTexture(this.canvas);\n this.texture.colorSpace = SRGBColorSpace;\n this.texture.needsUpdate = true;\n\n properties ??= {};\n properties[\"texture\"] = this.texture;\n }\n\n if (properties) {\n this.sceneWrapper.setProperties(this.planeHandler, properties);\n }\n }\n\n private buildTextChunks(): UITextChunk[] {\n if (this.textChunksDirty) {\n this.textChunks = buildTextChunks(\n this.context,\n this.contentInternal,\n this.commonStyle,\n );\n this.textChunksDirty = false;\n }\n\n return this.textChunks;\n }\n\n private checkDimensionsDirty(): boolean {\n return (\n this.solverWrapper.dirty &&\n (this.lastWidth !== Math.round(this.width) ||\n this.lastHeight !== Math.round(this.height))\n );\n }\n\n private setDimensionsDirtyFalse(): void {\n this.lastWidth = Math.round(this.width);\n this.lastHeight = Math.round(this.height);\n }\n\n private checkContentDirty(): boolean {\n return (\n this.contentDirty || this.content.some((span): boolean => span.dirty)\n );\n }\n\n private setContentDirtyFalse(): void {\n this.contentDirty = false;\n for (const span of this.content) {\n span.setDirtyFalse();\n }\n }\n}\n","/** Base class for viewport resize policies */\nexport abstract class UIResizePolicy {\n /** @internal */\n public dirty = false;\n\n /** @internal */\n public abstract calculateScale(width: number, height: number): number;\n}\n","import { assertValidPositiveNumber } from \"../asserts\";\nimport { UIResizePolicy } from \"./UIResizePolicy\";\n\n/** No scaling. Always returns 1. */\nexport class UIResizePolicyNone extends UIResizePolicy {\n public calculateScale(width: number, height: number): number {\n assertValidPositiveNumber(width, \"UIResizePolicyNone.calculateScale.width\");\n assertValidPositiveNumber(\n height,\n \"UIResizePolicyNone.calculateScale.height\",\n );\n return 1;\n }\n}\n","import type { UIResizePolicy } from \"../../miscellaneous/resize-policy/UIResizePolicy\";\nimport { UIResizePolicyNone } from \"../../miscellaneous/resize-policy/UIResizePolicyNone\";\nimport type { UILayerOptions } from \"../UILayer/UILayer.Internal\";\n\n/** Configuration for fullscreen layer */\nexport interface UIFullscreenLayerOptions\n extends Omit<UILayerOptions, \"width\" | \"height\"> {\n /** Strategy for handling window resize */\n resizePolicy: UIResizePolicy;\n}\n\nexport const FULLSCREEN_LAYER_DEFAULT_RESIZE_POLICY = new UIResizePolicyNone();\n","import type { Camera, Vector2, WebGLRenderer } from \"three\";\nimport { MathUtils, Ray, Vector3 } from \"three\";\nimport { assertValidNumber } from \"../../miscellaneous/asserts\";\nimport type { UIResizePolicy } from \"../../miscellaneous/resize-policy/UIResizePolicy\";\nimport { UIInputEvent } from \"../../miscellaneous/UIInputEvent\";\nimport { isUIModeInteractive } from \"../../miscellaneous/UIMode\";\nimport { UILayer } from \"../UILayer/UILayer\";\nimport {\n FULLSCREEN_LAYER_DEFAULT_RESIZE_POLICY,\n type UIFullscreenLayerOptions,\n} from \"./UIFullscreenLayer.Internal\";\n\n/** Layer that automatically handles browser window resizing and input events */\nexport class UIFullscreenLayer extends UILayer {\n private resizePolicyInternal: UIResizePolicy;\n private resizePolicyDirty = false;\n\n constructor(options?: Partial<UIFullscreenLayerOptions>) {\n const resizePolicy =\n options?.resizePolicy ?? FULLSCREEN_LAYER_DEFAULT_RESIZE_POLICY;\n\n const scale = resizePolicy.calculateScale(\n window.innerWidth,\n window.innerHeight,\n );\n\n super({\n width: window.innerWidth * scale,\n height: window.innerHeight * scale,\n ...options,\n });\n\n this.resizePolicyInternal = resizePolicy;\n window.addEventListener(\"resize\", this.onResize);\n window.addEventListener(\"pointerdown\", this.onPointerDown);\n window.addEventListener(\"pointermove\", this.onPointerMove);\n window.addEventListener(\"pointerup\", this.onPointerUp);\n }\n\n /** Current resize policy */\n public get resizePolicy(): UIResizePolicy {\n return this.resizePolicyInternal;\n }\n\n /** Updates resize policy */\n public set resizePolicy(value: UIResizePolicy) {\n if (this.resizePolicyInternal !== value) {\n this.resizePolicyInternal = value;\n this.resizePolicyDirty = true;\n }\n }\n\n /** Removes event listeners and frees resources */\n public destroy(): void {\n window.removeEventListener(\"resize\", this.onResize);\n window.removeEventListener(\"pointerdown\", this.onPointerDown);\n window.removeEventListener(\"pointermove\", this.onPointerMove);\n window.removeEventListener(\"pointerup\", this.onPointerUp);\n }\n\n /**\n * Renders layer and all visible elements\n * @param renderer Three.js WebGL renderer\n * @param deltaTime Time since last frame in seconds\n */\n public render(renderer: WebGLRenderer, deltaTime: number): void {\n assertValidNumber(deltaTime, \"UIFullscreenLayer.render.deltaTime\");\n if (this.resizePolicy.dirty || this.resizePolicyDirty) {\n this.onResize();\n }\n super.renderInternal(renderer, deltaTime);\n }\n\n /**\n * Projects 3D world position to 2D layer coordinates\n * @param position World position\n * @param camera Three.js camera\n * @returns Layer coordinates\n */\n public projectWorldPosition(position: Vector3, camera: Camera): Vector3 {\n const projectedPosition = position.clone().project(camera);\n projectedPosition.x = MathUtils.mapLinear(\n projectedPosition.x,\n -1,\n 1,\n this.x,\n this.width,\n );\n projectedPosition.y = MathUtils.mapLinear(\n projectedPosition.y,\n -1,\n 1,\n this.y,\n this.height,\n );\n return projectedPosition;\n }\n\n /**\n * Projects 2D layer coordinates to 3D world position\n * @param position Layer coordinates\n * @param camera Three.js camera\n * @param z Depth coordinate\n * @returns World position\n */\n public projectLayerPosition(\n position: Vector2,\n camera: Camera,\n z = -1,\n ): Vector3 {\n return new Vector3(\n MathUtils.mapLinear(position.x, this.x, this.width, -1, 1),\n MathUtils.mapLinear(position.y, this.y, this.height, -1, 1),\n z,\n ).unproject(camera);\n }\n\n /**\n * Builds ray from layer position through camera\n * @param position Layer coordinates\n * @param camera Three.js camera\n * @param result Reusable ray instance\n * @returns Ray from near to far plane\n */\n public buildRay(position: Vector2, camera: Camera, result = new Ray()): Ray {\n const near = new Vector3(\n MathUtils.mapLinear(position.x, this.x, this.width, -1, 1),\n MathUtils.mapLinear(position.y, this.y, this.height, -1, 1),\n -1,\n ).unproject(camera);\n\n const far = new Vector3(\n MathUtils.mapLinear(position.x, this.x, this.width, -1, 1),\n MathUtils.mapLinear(position.y, this.y, this.height, -1, 1),\n 1,\n ).unproject(camera);\n\n const direction = far.sub(near).normalize();\n return result.set(near, direction);\n }\n\n private readonly onResize = (): void => {\n const scale = this.resizePolicy.calculateScale(\n window.innerWidth,\n window.innerHeight,\n );\n this.resizePolicy.dirty = false;\n this.resizePolicyDirty = false;\n this.resizeInternal(window.innerWidth * scale, window.innerHeight * scale);\n };\n\n private readonly onPointerDown = (event: PointerEvent): void => {\n this.handleWindowInput(event, \"onPointerDown\", UIInputEvent.PRESSED);\n };\n\n private readonly onPointerMove = (event: PointerEvent): void => {\n this.handleWindowInput(event, \"onPointerMove\", UIInputEvent.MOVED);\n };\n\n private readonly onPointerUp = (event: PointerEvent): void => {\n this.handleWindowInput(event, \"onPointerUp\", UIInputEvent.RELEASED);\n };\n\n private handleWindowInput(\n event: PointerEvent,\n pointerFunctionName: \"onPointerDown\" | \"onPointerMove\" | \"onPointerUp\",\n inputEvent: UIInputEvent,\n ): void {\n const rect =\n event.target instanceof HTMLElement\n ? event.target.getBoundingClientRect()\n : null;\n\n const x = rect ? event.clientX - rect.left : event.clientX;\n const y = rect\n ? rect.bottom - event.clientY\n : window.innerHeight - event.clientY;\n\n const scale = this.resizePolicy.calculateScale(\n window.innerWidth,\n window.innerHeight,\n );\n const scaledX = x * scale;\n const scaledY = y * scale;\n\n if (isUIModeInteractive(this.mode)) {\n this.emit(inputEvent, scaledX, scaledY, event.pointerId);\n this.inputWrapperInternal[pointerFunctionName](\n scaledX,\n scaledY,\n event.pointerId,\n );\n }\n }\n}\n","import { assertValidNonNegativeNumber, assertValidNumber } from \"../asserts\";\nimport { UIArea } from \"./UIArea\";\n\n/** Circular interaction area */\nexport class UIAreaCircle extends UIArea {\n /**\n * Creates circular area.\n *\n * @param centerX - Center X in normalized coordinates (0 to 1)\n * @param centerY - Center Y in normalized coordinates (0 to 1)\n * @param radius - Radius in normalized coordinates (0 to 1)\n */\n constructor(\n public centerX: number,\n public centerY: number,\n public radius: number,\n ) {\n super();\n assertValidNonNegativeNumber(centerX, \"UIAreaCircle.constructor.centerX\");\n assertValidNonNegativeNumber(centerY, \"UIAreaCircle.constructor.centerY\");\n assertValidNonNegativeNumber(radius, \"UIAreaCircle.constructor.radius\");\n }\n\n /** @internal */\n public contains(pointX: number, pointY: number): boolean {\n assertValidNumber(pointX, \"UIAreaCircle.contains.pointX\");\n assertValidNumber(pointY, \"UIAreaCircle.contains.pointY\");\n const deltaX = pointX - this.centerX;\n const deltaY = pointY - this.centerY;\n return deltaX * deltaX + deltaY * deltaY <= this.radius * this.radius;\n }\n}\n","import type { Vector2Like } from \"three\";\nimport { assertValidNumber } from \"../asserts\";\nimport { UIArea } from \"./UIArea\";\n\n/** Polygonal interaction area using ray casting */\nexport class UIAreaPolygon extends UIArea {\n /**\n * Creates polygonal area.\n *\n * @param vertices - Vertices in normalized coordinates (0 to 1)\n */\n constructor(public vertices: Vector2Like[]) {\n super();\n }\n\n /** @internal */\n public contains(pointX: number, pointY: number): boolean {\n assertValidNumber(pointX, \"UIAreaPolygon.contains.pointX\");\n assertValidNumber(pointY, \"UIAreaPolygon.contains.pointY\");\n const vertexCount = this.vertices.length;\n if (vertexCount < 3) {\n return false;\n }\n\n let inside = false;\n\n for (\n let index = 0, previousIndex = vertexCount - 1;\n index < vertexCount;\n previousIndex = index++\n ) {\n const currentVertex = this.vertices[index];\n const previousVertex = this.vertices[previousIndex];\n\n const currentX = currentVertex.x;\n const currentY = currentVertex.y;\n const previousX = previousVertex.x;\n const previousY = previousVertex.y;\n\n if (\n currentY > pointY !== previousY > pointY &&\n pointX <\n ((previousX - currentX) * (pointY - currentY)) /\n (previousY - currentY) +\n currentX\n ) {\n inside = !inside;\n }\n }\n\n return inside;\n }\n}\n","import { assertValidNonNegativeNumber, assertValidNumber } from \"../asserts\";\nimport { UIArea } from \"./UIArea\";\n\n/** Rectangular interaction area with rounded corners */\nexport class UIAreaRoundedRectangle extends UIArea {\n /**\n * Creates rounded rectangular area.\n *\n * Radius clamped to half of smallest dimension.\n *\n * @param x - X position in normalized coordinates (0 to 1)\n * @param y - Y position in normalized coordinates (0 to 1)\n * @param width - Width in normalized coordinates (0 to 1)\n * @param height - Height in normalized coordinates (0 to 1)\n * @param radius - Corner radius in normalized coordinates (0 to 1)\n */\n constructor(\n public x: number,\n public y: number,\n public width: number,\n public height: number,\n public radius: number,\n ) {\n super();\n assertValidNonNegativeNumber(x, \"UIAreaRoundedRectangle.constructor.x\");\n assertValidNonNegativeNumber(y, \"UIAreaRoundedRectangle.constructor.y\");\n assertValidNonNegativeNumber(\n width,\n \"UIAreaRoundedRectangle.constructor.width\",\n );\n assertValidNonNegativeNumber(\n height,\n \"UIAreaRoundedRectangle.constructor.height\",\n );\n assertValidNonNegativeNumber(\n radius,\n \"UIAreaRoundedRectangle.constructor.radius\",\n );\n this.radius = Math.min(radius, Math.min(width, height) / 2);\n }\n\n /** @internal */\n public contains(pointX: number, pointY: number): boolean {\n assertValidNumber(pointX, \"UIAreaRoundedRectangle.contains.pointX\");\n assertValidNumber(pointY, \"UIAreaRoundedRectangle.contains.pointY\");\n const left = this.x;\n const right = this.x + this.width;\n const top = this.y;\n const bottom = this.y + this.height;\n\n if (pointX < left || pointX > right || pointY < top || pointY > bottom) {\n return false;\n }\n\n const cornerLeft = left + this.radius;\n const cornerRight = right - this.radius;\n const cornerTop = top + this.radius;\n const cornerBottom = bottom - this.radius;\n\n if (pointX >= cornerLeft && pointX <= cornerRight) {\n return true;\n }\n\n if (pointY >= cornerTop && pointY <= cornerBottom) {\n return true;\n }\n\n let centerX: number;\n let centerY: number;\n\n if (pointX < cornerLeft) {\n centerX = cornerLeft;\n } else {\n centerX = cornerRight;\n }\n\n if (pointY < cornerTop) {\n centerY = cornerTop;\n } else {\n centerY = cornerBottom;\n }\n\n const deltaX = pointX - centerX;\n const deltaY = pointY - centerY;\n return deltaX * deltaX + deltaY * deltaY <= this.radius * this.radius;\n }\n}\n","import source from \"../../shaders/UIProgressMaskFunctionCircular.glsl\";\nimport { assertValidNumber } from \"../asserts\";\nimport type { UIPropertyType } from \"../generic-plane/shared\";\nimport { UIProgressMaskFunction } from \"./UIProgressMaskFunction\";\n\n/** Circular radial progress fill */\nexport class UIProgressMaskFunctionCircular extends UIProgressMaskFunction {\n private startAngleInternal: number;\n private inverseDirectionInternal: boolean;\n\n /**\n * Creates circular mask function.\n *\n * @param startAngle - Starting angle in radians\n * @param inverseDirection - Whether to fill counter-clockwise\n */\n constructor(startAngle = 0, inverseDirection = false) {\n assertValidNumber(\n startAngle,\n \"UIProgressMaskFunctionCircular.constructor.startAngle\",\n );\n super(source);\n this.startAngleInternal = startAngle;\n this.inverseDirectionInternal = inverseDirection;\n }\n\n /** Starting angle in radians */\n public get startAngle(): number {\n return this.startAngleInternal;\n }\n\n /** Whether fill is counter-clockwise */\n public get inverseDirection(): boolean {\n return this.inverseDirectionInternal;\n }\n\n /** Starting angle in radians */\n public set startAngle(value: number) {\n assertValidNumber(value, \"UIProgressMaskFunctionCircular.startAngle\");\n if (this.startAngleInternal !== value) {\n this.startAngleInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n /** Whether fill is counter-clockwise */\n public set inverseDirection(value: boolean) {\n if (this.inverseDirectionInternal !== value) {\n this.inverseDirectionInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n /** @internal */\n public enumerateProperties(): Record<string, UIPropertyType> {\n return {\n direction: this.inverseDirectionInternal ? -1 : 1,\n startAngle: this.startAngleInternal,\n };\n }\n}\n","import { assertValidPositiveNumber } from \"../asserts\";\nimport { UIResizePolicy } from \"./UIResizePolicy\";\n\n/** Scales area to cover rect preserving proportions */\nexport class UIResizePolicyCover extends UIResizePolicy {\n private rectWidthInternal: number;\n private rectHeightInternal: number;\n\n /**\n * Creates cover resize policy.\n *\n * @param rectWidth - Target rect width\n * @param rectHeight - Target rect height\n */\n constructor(rectWidth: number, rectHeight: number) {\n super();\n assertValidPositiveNumber(\n rectWidth,\n \"UIResizePolicyCover.constructor.rectWidth\",\n );\n assertValidPositiveNumber(\n rectHeight,\n \"UIResizePolicyCover.constructor.rectHeight\",\n );\n\n this.rectWidthInternal = rectWidth;\n this.rectHeightInternal = rectHeight;\n }\n\n /** Target rect width */\n public get rectWidth(): number {\n return this.rectWidthInternal;\n }\n\n /** Target rect height */\n public get rectHeight(): number {\n return this.rectHeightInternal;\n }\n\n /** Target rect width */\n public set rectWidth(value: number) {\n assertValidPositiveNumber(value, \"UIResizePolicyCover.rectWidth\");\n if (value !== this.rectWidthInternal) {\n this.rectWidthInternal = value;\n this.dirty = true;\n }\n }\n\n /** Target rect height */\n public set rectHeight(value: number) {\n assertValidPositiveNumber(value, \"UIResizePolicyCover.rectHeight\");\n if (value !== this.rectHeightInternal) {\n this.rectHeightInternal = value;\n this.dirty = true;\n }\n }\n\n public calculateScale(width: number, height: number): number {\n assertValidPositiveNumber(\n width,\n \"UIResizePolicyCover.calculateScale.width\",\n );\n assertValidPositiveNumber(\n height,\n \"UIResizePolicyCover.calculateScale.height\",\n );\n return Math.min(\n this.rectWidthInternal / width,\n this.rectHeightInternal / height,\n );\n }\n}\n","import { assertValidPositiveNumber } from \"../asserts\";\nimport { UIResizePolicy } from \"./UIResizePolicy\";\n\n/** Scales by width in landscape, by height in portrait */\nexport class UIResizePolicyCross extends UIResizePolicy {\n private fixedWidthLandscapeInternal: number;\n private fixedHeightPortraitInternal: number;\n\n /**\n * Creates cross resize policy.\n *\n * @param fixedWidthLandscape - Target width when landscape\n * @param fixedHeightPortrait - Target height when portrait\n */\n constructor(fixedWidthLandscape: number, fixedHeightPortrait: number) {\n super();\n assertValidPositiveNumber(\n fixedWidthLandscape,\n \"UIResizePolicyCross.constructor.fixedWidthLandscape\",\n );\n assertValidPositiveNumber(\n fixedHeightPortrait,\n \"UIResizePolicyCross.constructor.fixedHeightPortrait\",\n );\n\n this.fixedWidthLandscapeInternal = fixedWidthLandscape;\n this.fixedHeightPortraitInternal = fixedHeightPortrait;\n }\n\n /** Target width when landscape */\n public get fixedWidthLandscape(): number {\n return this.fixedWidthLandscapeInternal;\n }\n\n /** Target height when portrait */\n public get fixedHeightPortrait(): number {\n return this.fixedHeightPortraitInternal;\n }\n\n /** Target width when landscape */\n public set fixedWidthLandscape(value: number) {\n assertValidPositiveNumber(value, \"UIResizePolicyCross.fixedWidthLandscape\");\n if (value !== this.fixedWidthLandscapeInternal) {\n this.fixedWidthLandscapeInternal = value;\n this.dirty = true;\n }\n }\n\n /** Target height when portrait */\n public set fixedHeightPortrait(value: number) {\n assertValidPositiveNumber(value, \"UIResizePolicyCross.fixedHeightPortrait\");\n if (value !== this.fixedHeightPortraitInternal) {\n this.fixedHeightPortraitInternal = value;\n this.dirty = true;\n }\n }\n\n public calculateScale(width: number, height: number): number {\n assertValidPositiveNumber(\n width,\n \"UIResizePolicyCross.calculateScale.width\",\n );\n assertValidPositiveNumber(\n height,\n \"UIResizePolicyCross.calculateScale.height\",\n );\n return width > height\n ? this.fixedWidthLandscapeInternal / width\n : this.fixedHeightPortraitInternal / height;\n }\n}\n","import { assertValidPositiveNumber } from \"../asserts\";\nimport { UIResizePolicy } from \"./UIResizePolicy\";\n\n/** Scales by height in landscape, by width in portrait */\nexport class UIResizePolicyCrossInverted extends UIResizePolicy {\n private fixedHeightLandscapeInternal: number;\n private fixedWidthPortraitInternal: number;\n\n /**\n * Creates inverted cross resize policy.\n *\n * @param fixedHeightLandscape - Target height when landscape\n * @param fixedWidthPortrait - Target width when portrait\n */\n constructor(fixedHeightLandscape: number, fixedWidthPortrait: number) {\n super();\n assertValidPositiveNumber(\n fixedHeightLandscape,\n \"UIResizePolicyCrossInverted.constructor.fixedHeightLandscape\",\n );\n assertValidPositiveNumber(\n fixedWidthPortrait,\n \"UIResizePolicyCrossInverted.constructor.fixedWidthPortrait\",\n );\n\n this.fixedHeightLandscapeInternal = fixedHeightLandscape;\n this.fixedWidthPortraitInternal = fixedWidthPortrait;\n }\n\n /** Target height when landscape */\n public get fixedHeightLandscape(): number {\n return this.fixedHeightLandscapeInternal;\n }\n\n /** Target width when portrait */\n public get fixedWidthPortrait(): number {\n return this.fixedWidthPortraitInternal;\n }\n\n /** Target height when landscape */\n public set fixedHeightLandscape(value: number) {\n assertValidPositiveNumber(\n value,\n \"UIResizePolicyCrossInverted.fixedHeightLandscape\",\n );\n if (value !== this.fixedHeightLandscapeInternal) {\n this.fixedHeightLandscapeInternal = value;\n this.dirty = true;\n }\n }\n\n /** Target width when portrait */\n public set fixedWidthPortrait(value: number) {\n assertValidPositiveNumber(\n value,\n \"UIResizePolicyCrossInverted.fixedWidthPortrait\",\n );\n if (value !== this.fixedWidthPortraitInternal) {\n this.fixedWidthPortraitInternal = value;\n this.dirty = true;\n }\n }\n\n public calculateScale(width: number, height: number): number {\n assertValidPositiveNumber(\n width,\n \"UIResizePolicyCrossInverted.calculateScale.width\",\n );\n assertValidPositiveNumber(\n height,\n \"UIResizePolicyCrossInverted.calculateScale.height\",\n );\n return width > height\n ? this.fixedHeightLandscapeInternal / height\n : this.fixedWidthPortraitInternal / width;\n }\n}\n","import { assertValidPositiveNumber } from \"../asserts\";\nimport { UIResizePolicy } from \"./UIResizePolicy\";\n\n/** Scales area to fit around rect preserving proportions */\nexport class UIResizePolicyFit extends UIResizePolicy {\n private rectWidthInternal: number;\n private rectHeightInternal: number;\n\n /**\n * Creates fit resize policy.\n *\n * @param rectWidth - Target rect width\n * @param rectHeight - Target rect height\n */\n constructor(rectWidth: number, rectHeight: number) {\n super();\n assertValidPositiveNumber(\n rectWidth,\n \"UIResizePolicyFit.constructor.rectWidth\",\n );\n assertValidPositiveNumber(\n rectHeight,\n \"UIResizePolicyFit.constructor.rectHeight\",\n );\n\n this.rectWidthInternal = rectWidth;\n this.rectHeightInternal = rectHeight;\n }\n\n /** Target rect width */\n public get rectWidth(): number {\n return this.rectWidthInternal;\n }\n\n /** Target rect height */\n public get rectHeight(): number {\n return this.rectHeightInternal;\n }\n\n /** Target rect width */\n public set rectWidth(value: number) {\n assertValidPositiveNumber(value, \"UIResizePolicyFit.rectWidth\");\n if (value !== this.rectWidthInternal) {\n this.rectWidthInternal = value;\n this.dirty = true;\n }\n }\n\n /** Target rect height */\n public set rectHeight(value: number) {\n assertValidPositiveNumber(value, \"UIResizePolicyFit.rectHeight\");\n if (value !== this.rectHeightInternal) {\n this.rectHeightInternal = value;\n this.dirty = true;\n }\n }\n\n public calculateScale(width: number, height: number): number {\n assertValidPositiveNumber(width, \"UIResizePolicyFit.calculateScale.width\");\n assertValidPositiveNumber(\n height,\n \"UIResizePolicyFit.calculateScale.height\",\n );\n return Math.max(\n this.rectWidthInternal / width,\n this.rectHeightInternal / height,\n );\n }\n}\n","import { assertValidPositiveNumber } from \"../asserts\";\nimport { UIResizePolicy } from \"./UIResizePolicy\";\n\n/** Scales by height with orientation-specific targets */\nexport class UIResizePolicyFixedHeight extends UIResizePolicy {\n private fixedHeightLandscapeInternal: number;\n private fixedHeightPortraitInternal: number;\n\n /**\n * Creates fixed height resize policy.\n *\n * @param fixedHeightLandscape - Target height when landscape\n * @param fixedHeightPortrait - Target height when portrait\n */\n constructor(fixedHeightLandscape: number, fixedHeightPortrait: number) {\n super();\n assertValidPositiveNumber(\n fixedHeightLandscape,\n \"UIResizePolicyFixedHeight.constructor.fixedHeightLandscape\",\n );\n assertValidPositiveNumber(\n fixedHeightPortrait,\n \"UIResizePolicyFixedHeight.constructor.fixedHeightPortrait\",\n );\n\n this.fixedHeightLandscapeInternal = fixedHeightLandscape;\n this.fixedHeightPortraitInternal = fixedHeightPortrait;\n }\n\n /** Target height when landscape */\n public get fixedHeightLandscape(): number {\n return this.fixedHeightLandscapeInternal;\n }\n\n /** Target height when portrait */\n public get fixedHeightPortrait(): number {\n return this.fixedHeightPortraitInternal;\n }\n\n /** Target height when landscape */\n public set fixedHeightLandscape(value: number) {\n assertValidPositiveNumber(\n value,\n \"UIResizePolicyFixedHeight.fixedHeightLandscape\",\n );\n if (value !== this.fixedHeightLandscapeInternal) {\n this.fixedHeightLandscapeInternal = value;\n this.dirty = true;\n }\n }\n\n /** Target height when portrait */\n public set fixedHeightPortrait(value: number) {\n assertValidPositiveNumber(\n value,\n \"UIResizePolicyFixedHeight.fixedHeightPortrait\",\n );\n if (value !== this.fixedHeightPortraitInternal) {\n this.fixedHeightPortraitInternal = value;\n this.dirty = true;\n }\n }\n\n public calculateScale(width: number, height: number): number {\n assertValidPositiveNumber(\n width,\n \"UIResizePolicyFixedHeight.calculateScale.width\",\n );\n assertValidPositiveNumber(\n height,\n \"UIResizePolicyFixedHeight.calculateScale.height\",\n );\n return width > height\n ? this.fixedHeightLandscapeInternal / height\n : this.fixedHeightPortraitInternal / height;\n }\n}\n","import { assertValidPositiveNumber } from \"../asserts\";\nimport { UIResizePolicy } from \"./UIResizePolicy\";\n\n/** Scales by width with orientation-specific targets */\nexport class UIResizePolicyFixedWidth extends UIResizePolicy {\n private fixedWidthLandscapeInternal: number;\n private fixedWidthPortraitInternal: number;\n\n /**\n * Creates fixed width resize policy.\n *\n * @param fixedWidthLandscape - Target width when landscape\n * @param fixedWidthPortrait - Target width when portrait\n */\n constructor(fixedWidthLandscape: number, fixedWidthPortrait: number) {\n super();\n assertValidPositiveNumber(\n fixedWidthLandscape,\n \"UIResizePolicyFixedWidth.constructor.fixedWidthLandscape\",\n );\n assertValidPositiveNumber(\n fixedWidthPortrait,\n \"UIResizePolicyFixedWidth.constructor.fixedWidthPortrait\",\n );\n\n this.fixedWidthLandscapeInternal = fixedWidthLandscape;\n this.fixedWidthPortraitInternal = fixedWidthPortrait;\n }\n\n /** Target width when landscape */\n public get fixedWidthLandscape(): number {\n return this.fixedWidthLandscapeInternal;\n }\n\n /** Target width when portrait */\n public get fixedWidthPortrait(): number {\n return this.fixedWidthPortraitInternal;\n }\n\n /** Target width when landscape */\n public set fixedWidthLandscape(value: number) {\n assertValidPositiveNumber(\n value,\n \"UIResizePolicyFixedWidth.fixedWidthLandscape\",\n );\n if (value !== this.fixedWidthLandscapeInternal) {\n this.fixedWidthLandscapeInternal = value;\n this.dirty = true;\n }\n }\n\n /** Target width when portrait */\n public set fixedWidthPortrait(value: number) {\n assertValidPositiveNumber(\n value,\n \"UIResizePolicyFixedWidth.fixedWidthPortrait\",\n );\n if (value !== this.fixedWidthPortraitInternal) {\n this.fixedWidthPortraitInternal = value;\n this.dirty = true;\n }\n }\n\n public calculateScale(width: number, height: number): number {\n assertValidPositiveNumber(\n width,\n \"UIResizePolicyFixedWidth.calculateScale.width\",\n );\n assertValidPositiveNumber(\n height,\n \"UIResizePolicyFixedWidth.calculateScale.height\",\n );\n return width > height\n ? this.fixedWidthLandscapeInternal / width\n : this.fixedWidthPortraitInternal / width;\n }\n}\n"],"names":["t","constructor","i","r","this","WeakMap","Map","set","insert","has","s","get","remove","delete","size","getPriority","o","on","h","once","off","u","v","slice","length","l","_","p","e","shift","n","pop","M","splice","c","emit","apply","k","m","Error","push","unshift","UIMode","UIOrientation","isUIModeInteractive","mode","INTERACTIVE","INTERACTIVE_TRANSPARENT","isUIModeVisible","HIDDEN","createMap","IndexedMap","index","array","empty","itemAt","contains","key","undefined","id","find","setDefault","factory","pair","Pair","value","erase","last","first","copy","second","Variable","name","_name","_id","setName","context","_context","setContext","_value","setValue","plus","Expression","minus","multiply","coefficient","divide","toJSON","toString","VarId","parsed","args","constant","terms","item","terms2","j","termPair","Array","value2","parseArgs","arguments","_terms","_constant","result","isConstant","map","join","Strength","create","a","b","w","Math","max","min","static","clip","required","Operator","Constraint","expression","operator","rhs","strength","_operator","_strength","_expression","op","CnId","Solver","maxIterations","createConstraint","lhs","cn","addConstraint","constraint","_cnMap","data","_createRow","row","tag","subject","_chooseSubject","type","SymbolType","Invalid","allDummies","nearZero","marker","_addWithArtificialVariable","solveFor","_substitute","_rowMap","_optimize","_objective","removeConstraint","cnPair","_removeConstraintEffects","rowPair","leaving","_getMarkerLeavingSymbol","solveForEx","hasConstraint","getConstraints","addEditVariable","variable","_editMap","expr","Eq","removeEditVariable","editPair","hasEditVariable","suggestValue","rows","info","delta","add","_infeasibleRows","_dualOptimize","other","coeff","coefficientFor","External","updateVariables","vars","_varMap","_getVarSymbol","_makeSymbol","Row","symbol","basicPair","insertRow","insertSymbol","objective","INVALID_SYMBOL","Le","Ge","slack","Slack","error","errplus","errminus","dummy","Dummy","reverseSign","cells","art","_artificial","success","basicRow","entering","_anyPivotableSymbol","removeSymbol","substitute","iterations","_getEnteringSymbol","_getLeavingSymbol","infeasible","_getDualEnteringSymbol","ratio","Number","MAX_VALUE","found","temp","temp_ratio","dmax","r1","r2","invalid","third","_removeMarkerEffects","Symbol","_idTick","createCnMap","createRowMap","createVarMap","createEditMap","_type","_cellMap","theCopy","HIGH_PRIORITY","UIPriority","UITransparencyMode","convertPriority","priority","P0","P1","P2","P3","P4","P5","P6","P7","UIInputWrapper","dirty","_private_zIndicesDirty","_private_catchers","_private_lastHandler","createInputCatcher","catchPointerDown","catchPointerMove","catchPointerUp","zIndex","handler","active","destroyInputCatcher","findIndex","getZIndex","setZIndex","getActive","setActive","onPointerDown","x","y","identifier","onPointerMove","onPointerUp","_private_ensureSorted","sort","count","step","SRGBToLinear","pow","LinearToSRGB","COLORS","black","white","red","green","blue","yellow","cyan","magenta","gray","grey","silver","maroon","olive","lime","aqua","teal","navy","fuchsia","purple","orange","pink","brown","gold","violet","indigo","coral","salmon","khaki","plum","orchid","tan","beige","mint","lavender","crimson","azure","ivory","snow","UIColor","_private_rInternal","_private_gInternal","_private_bInternal","_private_aInternal","_private_hInternal","_private_sInternal","_private_lInternal","_private_dirtyInternal","_private_rgbDirty","_private_hslDirty","firstArgument","startsWith","setHexString","setColorName","Color","g","setHexRGB","hue","saturation","lightness","MathUtils","clamp","setDirtyFalse","getHexRGBA","round","getHexRGB","getHexStringRGB","padStart","getHexStringRGBA","setHexRGBA","hex","hexString","hexNumber","parseInt","isNaN","setHSL","colorName","normalizedName","toLowerCase","trim","setGLSLColor","sRGBR","sRGBG","sRGBB","setThreeColor","threeColor","toCSSColor","toGLSLColor","Vector4","z","toThreeColor","color","clone","_private_ensureRGBUpdatedFromHSL","abs","hp","_private_ensureHSLUpdatedFromRGB","d","resolveGLSLTypeInfo","glslType","instantiable","itemSize","Texture","Vector2","Vector3","Matrix3","Matrix4","resolveUniform","material","uniform","uniforms","arePropertiesCompatible","currentProperties","newProperties","currentKeys","Object","keys","newKeys","newKey","currentInfo","newInfo","buildGenericPlaneFragmentShader","uniformDeclarations","varyingDeclarations","source","INSTANCED_PLANE_GEOMETRY","planeGeometry","PlaneGeometry","translate","geometry","InstancedBufferGeometry","setAttribute","attributes","dispose","TEMP_COLOR_VECTOR","IDENTITY_MATRIX_ELEMENTS","writePropertyToArray","offset","elements","buildEmptyInstancedBufferAttribute","capacity","InstancedBufferAttribute","Float32Array","reconstructValue","referenceValue","matrix","fromArray","UIGenericInstancedPlane","Mesh","properties","transparency","BLEND","initialCapacity","uniformProperties","varyingProperties","instanceVisibility","instanceTransform","identity","entries","instancedGeometry","shaderMaterial","attributeDeclarations","vertexAssignments","vertexShader","fragmentShader","ShaderMaterial","transparent","alphaTest","CLIP","alphaHash","HASH","depthWrite","depthTest","buildMaterial","super","frustumCulled","matrixAutoUpdate","matrixWorldAutoUpdate","_private_instancedGeometry","instanceCount","_private_shaderMaterial","_private_uniformProperties","_private_varyingProperties","ceil","attribute","uniformsNeedUpdate","createInstance","_private_ensureCapacity","_private_initializeInstanceDefaults","destroyInstance","_private_resolveIndex","_private_handlerToIndex","lastIndex","_private_moveInstanceData","_private_updateIndicesAfterMove","setProperties","_private_resolveAttribute","needsUpdate","setTransform","transform","setVisibility","visible","isCompatible","extractInstanceData","extractProperties","extractTransform","visibility","extractVisibility","_private_propertyBuffers","destroy","clear","visibilityAttr","transformAttr","visibilityArray","transformArray","transformOffset","writeInstanceDefaults","requiredCapacity","_private_capacity","newCapacity","oldAttribute","newArray","newAttribute","sourceIndex","targetIndex","values","srcOffset","dstOffset","oldIndex","newIndex","PLANE_GEOMETRY","UIGenericPlane","p_transform","buildGenericPlaneMaterial","_private_transformInternal","_private_propertiesInternal","_private_transparencyInternal","setTransparency","UIPlaneRegistry","_private_scene","descriptor","plane","_private_placeInstance","_private_resolveDescriptor","_private_descriptors","_private_removeFromCurrentPlane","instanceHandler","currentData","_private_extractInstanceData","_private_checkNeedsRelocation","_private_updatePropertiesInPlace","compatibleInstanced","_private_findCompatibleInstancedPlane","_private_attachToInstancedPlane","promotable","_private_findCompatibleSinglePlane","instancedPlane","_private_promoteToInstanced","_private_createSinglePlane","_private_demoteToSingle","newTransparency","singlePlane","excludeDescriptor","promotableDescriptor","templateProperties","oldPlane","oldData","oldInstanceHandler","removedDescriptor","remainingDescriptor","originalClearColor","originalClearAlpha","originalAutoClear","originalAutoClearColor","originalAutoClearDepth","originalAutoClearStencil","UISceneWrapper","width","height","Scene","_private_registry","OrthographicCamera","createPlane","destroyPlane","insertCustomObject","object","removeCustomObject","resize","_private_camera","right","top","updateProjectionMatrix","render","renderer","getClearColor","getClearAlpha","autoClear","autoClearColor","autoClearDepth","autoClearStencil","setClearColor","setClearAlpha","UIExpression","assertValidNumber","from","variableIndex","_private_terms","hasTerm","prepareTerms","UIRelation","UILayerEvent","UISolverWrapper","_private_recalculationRequired","_private_lastVariableIndex","_private_lastConstraintIndex","createVariable","description","_private_buildConstraint","EQUAL","_private_solver","_private_variables","removeVariable","cDescription","suggestVariableValue","_private_rebuildConstraint","setVariablePriority","_private_rebuildVariable","readVariableValue","relation","enabled","_private_constraints","setConstraintLHS","_private_rebuildConstraintByDescription","setConstraintRHS","setConstraintRelation","setConstraintPriority","setConstraintEnabled","dependConstraints","oldConstraint","LESS_THAN","GREATER_THAN","convertRelation","_private_convertExpression","_private_rebuildSolver","LAYER_DEFAULT_MODE","VISIBLE","UILayer","Eventail","options","inputWrapperInternal","_private_sceneWrapperInternal","_private_orientationInternal","HORIZONTAL","VERTICAL","xVariable","_private_solverWrapperInternal","yVariable","wVariable","hVariable","sceneWrapper","solverWrapper","inputWrapper","_private_modeInternal","orientation","MODE_CHANGED","resizeInternal","ORIENTATION_CHANGED","renderInternal","deltaTime","RENDERING","isUILayerElement","obj","layer","isUIPointElement","isUIPlaneElement","EPSILON","assertValidConstraintArguments","assertValidInterpolationConstraintArguments","UIConstraint","UISingleParameterConstraint","_private_onOrientationChange","isConstraintEnabled","ALWAYS","_private_priorityInternal","_private_relationInternal","UIHeightConstraint","_private_element","_private_heightInternal","UIHorizontalDistanceConstraint","_private_a","_private_b","anchorA","anchorB","distance","_private_buildLHS","_private_distanceInternal","_private_anchorAInternal","_private_anchorBInternal","aExpression","bExpression","UIHorizontalInterpolationConstraint","_private_c","anchorC","_private_tInternal","_private_anchorCInternal","cExpression","aScaled","bScaled","UIHorizontalProportionConstraint","proportion","_private_buildRHS","_private_proportionInternal","UIVerticalDistanceConstraint","UIVerticalInterpolationConstraint","UIVerticalProportionConstraint","UIWidthConstraint","_private_widthInternal","normalizeUIType2D","isArray","UIConstraint2DBuilder","element","interpolation","UIAspectConstraint","_private_aspectInternal","aspect","COVER_CONSTRAINT_DEFAULT_ANCHOR","UICoverConstraintBuilder","build","passive","activeAspectConstraint","keepActiveAspect","xConstraint","anchorH","yConstraint","anchorV","widthConstraint","heightConstraint","DEFAULT_ANCHOR","UIFitConstraintBuilder","UICustomConstraint","_private_lhsInternal","_private_rhsInternal","setLHS","setRHS","UIAnchor","UIMicroAnchorMode","MICRO_DEFAULT_ANCHOR","MICRO_DEFAULT_ANCHOR_MODE","ROTATION_SCALE","TEMP_POSITION","TEMP_QUATERNION","Quaternion","TEMP_SCALE","TEMP_MATRIX","Z_AXIS","computeTrimmedTransformMatrix","microX","microY","microAnchorX","microAnchorY","microScaleX","microScaleY","microRotation","microAnchorMode","trimLeft","trimRight","trimTop","trimBottom","trimmedWidth","trimmedHeight","anchorOffsetX","anchorOffsetY","cos","sin","rotatedAnchorX","rotatedAnchorY","trimOffsetX","trimOffsetY","rotatedTrimX","rotatedTrimY","POSITION_ROTATION_SCALE","rawAnchorOffsetY","setFromAxisAngle","compose","TEXTURE_DEFAULT_TEXTURE","UITextureViewEvent","UITextureView","config","_private_textureInternal","_private_sourceWidth","_private_sourceHeight","_private_frameX","_private_frameY","_private_frameWidth","_private_frameHeight","_private_rotatedInternal","_private_scaleInternal","_private_trimLeft","_private_trimRight","_private_trimTop","_private_trimBottom","_private_textureDirtyInternal","_private_uvTransformDirtyInternal","_private_trimDirtyInternal","texture","rotated","scale","left","bottom","textureDirty","uvTransformDirty","trimDirty","setTextureDirtyFalse","setUVTransformDirtyFalse","setTrimDirtyFalse","calculateUVTransform","atlasWidth","image","naturalWidth","atlasHeight","naturalHeight","physicalHeight","vSize","getResolution","lastWidth","lastHeight","_private_setFromTexture","_private_setFromAtlasConfig","DIMENSIONS_CHANGED","sourceSize","frame","spriteSource","spriteSourceSize","UIInputEvent","UIMicro","anchorX","anchorY","scaleX","scaleY","rotation","anchorMode","_private_xInternal","_private_yInternal","_private_anchorXInternal","_private_anchorYInternal","_private_scaleXInternal","_private_scaleYInternal","angle","radToDeg","_private_anchorModeInternal","_private_rotationInternal","degToRad","reset","UIArea","UIAreaRectangle","pointX","pointY","DUMMY_DEFAULT_MODE","UIInputDummy","_private_lastPointerInside","handleInputEvent","PRESSED","MOVED","RELEASED","interactionArea","modeInternal","_private_catcherHandler","oppositeX","oppositeY","centerX","centerY","newInteractivity","inputEvent","isPointerInside","mapLinear","LEFT","ENTERED","ELEMENT_DEFAULT_TRANSPARENCY_MODE","UIElement","_private_transparencyModeDirty","_private_visibilityDirty","micro","_private_transparencyModeInternal","transparencyMode","planeHandler","onWillRender","setPlaneTransform","scaledWidth","scaledHeight","computeTransformMatrix","UIAnimatedImageEvent","UILoopMode","ANIMATED_IMAGE_DEFAULT_LOOP_MODE","LOOP","UIAnimatedImage","sequence","uiTextures","textureConfig","textureTransform","_private_isPlaying","_private_sequenceFrameIndex","_private_currentFrameIndexDirty","_private_accumulatedTime","_private_onTextureDimensionsChanged","_private_sequenceInternal","_private_textureTransform","_private_frameRateInternal","frameRate","_private_timeScaleInternal","timeScale","_private_loopModeInternal","loopMode","playByDefault","play","duration","stop","newLength","currentLength","PLAYED","pause","PAUSED","STOPPED","frameDuration","sequenceLength","lastFrameIndex","PING_PONG","textureTrim","_private_subscribeSequenceEvents","_private_unsubscribeSequenceEvents","UIGraphics","canvas","OffscreenCanvas","getContext","CanvasTexture","colorSpace","SRGBColorSpace","minFilter","LinearFilter","magFilter","_private_canvas","_private_context","_private_texture","clearRect","fillStyle","fillRect","drawRect","drawCircle","radius","beginPath","arc","PI","fill","drawArc","startAngle","endAngle","drawPolyline","points","lineWidth","strokeStyle","moveTo","lineTo","stroke","UIImage","textureView","UIInsets","horizontal","vertical","setHorizontal","setVertical","setUnified","setVector4","vector","toVector4","UINineSliceRegionMode","NINE_SLICE_DEFAULT_REGION_MODE","WORLD","UINineSlice","sliceBorders","sliceRegions","regionMode","sliceBordersVector","sliceRegionsVector","_private_regionModeDirty","_private_textureDimensionsDirty","_private_regionModeInternal","_private_sliceBordersVector","_private_sliceRegionsVector","_private_lastElementWidth","_private_lastElementHeight","_private_calculateSliceBordersForShader","_private_checkElementDimensionsDirty","_private_calculateSliceRegionsForShader","sourceWidth","sourceHeight","trimNRight","trimNTop","trimNBottom","trimmedWidthNorm","trimmedHeightNorm","srcRight","srcTop","srcBottom","NORMALIZED","_private_setElementDimensionsDirtyFalse","UIProgressMaskFunction","dirtyInternal","UIProgressMaskFunctionDirectional","direction","normalize","_private_cachedDirection","equals","enumerateProperties","_private_ensureDirectionNormalized","squaredLength","lengthSq","divideScalar","UIProgress","textureResolution","progress","maskFunction","_private_progressDirty","_private_textureResolutionDirty","_private_textureResolution","_private_progressInternal","maskProperties","UISceneUpdateMode","SCENE_DEFAULT_UPDATE_MODE","ON_PROPERTIES_CHANGE","SCENE_DEFAULT_CLEAR_COLOR","UIScene","resolutionFactor","renderTarget","WebGLRenderTarget","format","RGBAFormat","UnsignedByteType","depthBuffer","enableDepthBuffer","stencilBuffer","_private_evenFrame","_private_updateRequired","_private_resolutionFactorDirty","_private_propertyDirty","clearColor","_private_renderTarget","_private_sceneInternal","scene","_private_cameraInternal","camera","PerspectiveCamera","_private_resolutionFactorInternal","updateMode","MANUAL","_private_updateModeInternal","requestUpdate","EACH_FRAME","EVERY_SECOND_FRAME","ON_DIMENSIONS_CHANGE","setSize","setRenderTarget","TEXT_STYLE_DEFAULT_COLOR","TEXT_STYLE_DEFAULT_ALIGN","TEXT_STYLE_DEFAULT_FONT_FAMILY","TEXT_STYLE_DEFAULT_FONT_STYLE","TEXT_STYLE_DEFAULT_FONT_WEIGHT","TEXT_STYLE_DEFAULT_ENABLE_SHADOW","TEXT_STYLE_DEFAULT_SHADOW_COLOR","TEXT_STYLE_DEFAULT_ENABLE_STROKE","TEXT_STYLE_DEFAULT_STROKE_COLOR","UITextStyle","_private_colorInternal","_private_alignInternal","align","_private_fontFamilyInternal","fontFamily","_private_fontSizeInternal","fontSize","_private_fontStyleInternal","fontStyle","_private_fontWeightInternal","fontWeight","_private_lineHeightInternal","lineHeight","_private_enableShadowInternal","enableShadow","_private_shadowOffsetXInternal","shadowOffsetX","_private_shadowOffsetYInternal","shadowOffsetY","_private_shadowBlurInternal","shadowBlur","_private_shadowColorInternal","shadowColor","_private_enableStrokeInternal","enableStroke","_private_strokeColorInternal","strokeColor","_private_strokeThicknessInternal","strokeThickness","resolve","primary","fallback","setDefaults","TEXT_STYLE_DEFAULT_FONT_SIZE","calculatePadding","padding","offsetY","shadowSpread","UITextSpan","_private_textInternal","text","style","UITextResizeMode","TEXT_DEFAULT_RESIZE_MODE","SCALE","splitTextIntoChunks","match","measureTextChunk","textStyle","font","baseline","metrics","measureText","actualBoundingBoxAscent","actualBoundingBoxDescent","calculateTextContentParameters","textChunks","maxLineWidth","lines","maxWidth","currentLine","currentWidth","currentHeight","currentBaseline","currentLineHeight","textChunk","chunks","buildTextLines","line","totalHeight","calculateTextSize","renderTextChunk","strokeText","fillText","renderTextLines","paddingTop","paddingLeft","currentY","textWidth","firstAlign","lineAlign","every","offsetX","currentX","chunk","UIText","content","_private_contentInternal","_private_contentDirty","_private_maxLineWidthDirty","_private_resizeModeDirty","_private_textChunks","_private_textChunksDirty","commonStyle","_private_maxLineWidthInternal","resizeMode","_private_lastWidth","_private_lastHeight","reduce","BREAK","_private_resizeModeInternal","span","_private_tryToRenderTextScaleMode","_private_checkContentDirty","_private_buildTextChunks","desiredHeight","desiredWidth","resolutionDirty","_private_updateProperties","_private_tryToRenderTextBreakMode","_private_checkDimensionsDirty","desiredTextSize","paddingV","paddingH","realTextLines","realTextSize","safeWidth","safeHeight","textSpans","textSpan","textChunkMetrics","buildTextChunks","_private_setDimensionsDirtyFalse","some","_private_setContentDirtyFalse","UIResizePolicy","UIResizePolicyNone","calculateScale","FULLSCREEN_LAYER_DEFAULT_RESIZE_POLICY","UIFullscreenLayer","resizePolicy","window","innerWidth","innerHeight","_private_resizePolicyDirty","_private_onResize","event","_private_handleWindowInput","_private_resizePolicyInternal","addEventListener","removeEventListener","projectWorldPosition","position","projectedPosition","project","projectLayerPosition","unproject","buildRay","Ray","near","sub","pointerFunctionName","rect","target","HTMLElement","getBoundingClientRect","clientX","clientY","scaledX","scaledY","pointerId","UIAreaCircle","deltaX","deltaY","UIAreaPolygon","vertices","vertexCount","inside","previousIndex","currentVertex","previousVertex","previousY","UIAreaRoundedRectangle","cornerLeft","cornerRight","cornerTop","cornerBottom","UIProgressMaskFunctionCircular","inverseDirection","_private_startAngleInternal","_private_inverseDirectionInternal","UIResizePolicyCover","rectWidth","rectHeight","_private_rectWidthInternal","_private_rectHeightInternal","UIResizePolicyCross","fixedWidthLandscape","fixedHeightPortrait","_private_fixedWidthLandscapeInternal","_private_fixedHeightPortraitInternal","UIResizePolicyCrossInverted","fixedHeightLandscape","fixedWidthPortrait","_private_fixedHeightLandscapeInternal","_private_fixedWidthPortraitInternal","UIResizePolicyFit","UIResizePolicyFixedHeight","UIResizePolicyFixedWidth"],"mappings":"gbAAA,MAAMA,EAAE,WAAAC,CAAYD,EAAEE,EAAEC,EAAE,GAAGC,KAAKJ,EAAE,IAAIK,QAAQD,KAAKF,EAAE,IAAII,SAAI,IAASN,SAAI,IAASE,EAAEE,KAAKF,EAAEK,IAA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C,GAA+BF,CACrC,CAGA,wBAAWI,GACT,OAAO3tC,KAAI6tC,EACb,CAGA,uBAAWN,GACT,OAAOvtC,KAAIytC,EACb,CAGA,wBAAWE,CAAqB9pC,GAK1BA,IAAU7D,KAAI6tC,KAChB7tC,KAAI6tC,GAAgChqC,EACpC7D,KAAK2P,OAAQ,EAEjB,CAGA,uBAAW49B,CAAoB1pC,GAKzBA,IAAU7D,KAAIytC,KAChBztC,KAAIytC,GAA+B5pC,EACnC7D,KAAK2P,OAAQ,EAEjB,CAEO,cAAA+5B,CAAe5mB,EAAeC,GASnC,OAAOD,EAAQC,EACX/iB,KAAI6tC,GAAgC9qB,EACpC/iB,KAAIytC,GAA+B1qB,CACzC,ECvEI,MAAOkrB,WAAiCzE,GAU5C,WAAA3pC,CAAYytC,EAA6BM,GACvCrxB,QAUAvc,KAAIwtC,GAA+BF,EACnCttC,KAAI8tC,GAA8BF,CACpC,CAGA,uBAAWN,GACT,OAAOttC,KAAIwtC,EACb,CAGA,sBAAWI,GACT,OAAO5tC,KAAI8tC,EACb,CAGA,uBAAWR,CAAoBzpC,GAKzBA,IAAU7D,KAAIwtC,KAChBxtC,KAAIwtC,GAA+B3pC,EACnC7D,KAAK2P,OAAQ,EAEjB,CAGA,sBAAWi+B,CAAmB/pC,GAKxBA,IAAU7D,KAAI8tC,KAChB9tC,KAAI8tC,GAA8BjqC,EAClC7D,KAAK2P,OAAQ,EAEjB,CAEO,cAAA+5B,CAAe5mB,EAAeC,GASnC,OAAOD,EAAQC,EACX/iB,KAAIwtC,GAA+B1qB,EACnC9iB,KAAI8tC,GAA8BhrB,CACxC","x_google_ignoreList":[0,3,4,5,6,7,8,12]}
1
+ {"version":3,"file":"index.min.js","sources":["../node_modules/eventail/dist/index.min.js","../src/miscellaneous/UIMode.ts","../src/miscellaneous/UIOrientation.ts","../node_modules/@lume/kiwi/dist/maptype.js","../node_modules/@lume/kiwi/dist/variable.js","../node_modules/@lume/kiwi/dist/expression.js","../node_modules/@lume/kiwi/dist/strength.js","../node_modules/@lume/kiwi/dist/constraint.js","../node_modules/@lume/kiwi/dist/solver.js","../src/miscellaneous/UIPriority.ts","../src/wrappers/UIInputWrapper/UIInputWrapper.ts","../node_modules/three/src/math/ColorManagement.js","../src/miscellaneous/color/UIColor.Internal.ts","../src/miscellaneous/color/UIColor.ts","../src/miscellaneous/generic-plane/shared.ts","../src/miscellaneous/UITransparencyMode.ts","../src/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.Internal.ts","../src/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.ts","../src/miscellaneous/generic-plane/UIGenericPlane/UIGenericPlane.Internal.ts","../src/miscellaneous/generic-plane/UIGenericPlane/UIGenericPlane.ts","../src/miscellaneous/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.Internal.ts","../src/miscellaneous/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.ts","../src/wrappers/UISceneWrapper/UISceneWrapper.ts","../src/miscellaneous/UIExpression.ts","../src/miscellaneous/UIRelation.ts","../src/layers/UILayer/UILayer.Internal.ts","../src/wrappers/UISolverWrapper/UISolverWrapper.ts","../src/layers/UILayer/UILayer.ts","../src/miscellaneous/shared.ts","../src/miscellaneous/asserts.ts","../src/constraints/UIConstraint.ts","../src/constraints/UISingleParameterConstraint/UISingleParameterConstraint.ts","../src/constraints/UIHeightConstraint/UIHeightConstraint.ts","../src/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.ts","../src/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.Internal.ts","../src/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.ts","../src/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.Internal.ts","../src/constraints/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.ts","../src/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.ts","../src/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.Internal.ts","../src/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.ts","../src/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.Internal.ts","../src/constraints/UIVerticalProportionConstraint/UIVerticalProportionConstraint.ts","../src/constraints/UIWidthConstraint/UIWidthConstraint.ts","../src/constraints/builders/UIConstraint2DBuilder.Internal.ts","../src/constraints/builders/UIConstraint2DBuilder.ts","../src/constraints/UIAspectConstraint/UIAspectConstraint.ts","../src/constraints/builders/UICoverConstraintBuilder.Internal.ts","../src/constraints/builders/UICoverConstraintBuilder.ts","../src/constraints/builders/UIFitConstraintBuilder.Internal.ts","../src/constraints/builders/UIFitConstraintBuilder.ts","../src/constraints/UICustomConstraint.ts","../src/elements/UIAnchor/UIAnchor.ts","../src/elements/UIAnchor/UIAnchor.Internal.ts","../src/miscellaneous/micro/UIMicro.Internal.ts","../src/miscellaneous/computeTransform.ts","../src/miscellaneous/texture/UITextureView.Internal.ts","../src/miscellaneous/texture/UITextureView.ts","../src/miscellaneous/UIInputEvent.ts","../src/miscellaneous/micro/UIMicro.ts","../src/miscellaneous/area/UIArea.ts","../src/miscellaneous/area/UIAreaRectangle.ts","../src/elements/UIInputDummy/UIInputDummy.Internal.ts","../src/elements/UIInputDummy/UIInputDummy.ts","../src/elements/UIElement/UIElement.Internal.ts","../src/elements/UIElement/UIElement.ts","../src/elements/UIAnimatedImage/UIAnimatedImage.Internal.ts","../src/elements/UIAnimatedImage/UIAnimatedImage.ts","../src/elements/UIGraphics/UIGraphics.Internal.ts","../src/elements/UIGraphics/UIGraphics.ts","../src/elements/UIImage/UIImage.ts","../src/miscellaneous/insets/UIInsets.ts","../src/miscellaneous/insets/UIInsets.Internal.ts","../src/elements/UINineSlice/UINineSlice.Internal.ts","../src/elements/UINineSlice/UINineSlice.ts","../src/miscellaneous/mask-function/UIProgressMaskFunction.ts","../src/miscellaneous/mask-function/UIProgressMaskFunctionDirectional.ts","../src/elements/UIScene/UIScene.Internal.ts","../src/elements/UIProgress/UIProgress.ts","../src/elements/UIProgress/UIProgress.Internal.ts","../src/elements/UIScene/UIScene.ts","../src/miscellaneous/text-style/UITextStyle.Internal.ts","../src/miscellaneous/text-style/UITextStyle.ts","../src/miscellaneous/text-span/UITextSpan.ts","../src/elements/UIText/UIText.Internal.ts","../src/elements/UIText/UIText.Measuring.ts","../src/elements/UIText/UIText.Rendering.ts","../src/elements/UIText/UIText.ts","../src/miscellaneous/resize-policy/UIResizePolicy.ts","../src/miscellaneous/resize-policy/UIResizePolicyNone.ts","../src/layers/UIFullscreenLayer/UIFullscreenLayer.Internal.ts","../src/layers/UIFullscreenLayer/UIFullscreenLayer.ts","../src/miscellaneous/area/UIAreaCircle.ts","../src/miscellaneous/area/UIAreaPolygon.ts","../src/miscellaneous/area/UIAreaRoundedRectangle.ts","../src/miscellaneous/mask-function/UIProgressMaskFunctionCircular.ts","../src/miscellaneous/resize-policy/UIResizePolicyCover.ts","../src/miscellaneous/resize-policy/UIResizePolicyCross.ts","../src/miscellaneous/resize-policy/UIResizePolicyCrossInverted.ts","../src/miscellaneous/resize-policy/UIResizePolicyFit.ts","../src/miscellaneous/resize-policy/UIResizePolicyFixedHeight.ts","../src/miscellaneous/resize-policy/UIResizePolicyFixedWidth.ts"],"sourcesContent":["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,!1,s,i,r),this}once(t,i,r,s=0){return this.h(t,!0,s,i,r),this}off(t,i,r){const s=this.o.get(t);if(void 0===s)return this;s.u&&(s.u=!1,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!1;if(0===r.v.length)return!1;r.u?r.v=r.v.slice():r.u=!0;const s=r.v;let o=!1;for(let t=0;s.length>t;t++){const r=s[t];r._.apply(r.p,i),r.k&&(o=!0,r.m=!0)}const e=this.o.get(t);if(void 0===e)return!0;e.v===s&&(e.u=!1);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!0}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:!1}],u:!1,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:!1};n.u&&(n.u=!1,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)}}}}export{i as Eventail};\n//# sourceMappingURL=index.min.js.map\n","/** Visibility and interactivity state */\nexport enum UIMode {\n /** Not rendered, no input */\n HIDDEN = 0,\n /** Rendered, no input */\n VISIBLE = 1,\n /** Rendered, receives input, blocks input to elements behind */\n INTERACTIVE = 2,\n /** Rendered, receives input, passes input to elements behind */\n INTERACTIVE_TRANSPARENT = 3,\n}\n\n/**\n * Checks if mode allows input events.\n * @param mode Mode to check\n * @returns True if interactive\n */\nexport function isUIModeInteractive(mode: UIMode): boolean {\n return mode === UIMode.INTERACTIVE || mode === UIMode.INTERACTIVE_TRANSPARENT;\n}\n\n/**\n * Checks if mode is rendered.\n * @param mode Mode to check\n * @returns True if visible\n */\nexport function isUIModeVisible(mode: UIMode): boolean {\n return mode !== UIMode.HIDDEN;\n}\n","/** Screen orientation for conditional constraints */\nexport enum UIOrientation {\n /** Landscape (width > height) */\n HORIZONTAL = 0,\n /** Portrait (height > width) */\n VERTICAL = 1,\n /** Active in any orientation */\n ALWAYS = 2,\n}\n\n/**\n * Resolves optional orientation.\n * @param orientation Orientation to resolve\n * @returns Orientation or ALWAYS if undefined\n */\nexport function resolveOrientation(orientation?: UIOrientation): UIOrientation {\n return orientation ?? UIOrientation.ALWAYS;\n}\n","export function createMap() {\n return new IndexedMap();\n}\nclass IndexedMap {\n index = {};\n array = [];\n /**\n * Returns the number of items in the array.\n */\n size() {\n return this.array.length;\n }\n /**\n * Returns true if the array is empty.\n */\n empty() {\n return this.array.length === 0;\n }\n /**\n * Returns the item at the given array index.\n *\n * @param index The integer index of the desired item.\n */\n itemAt(index) {\n return this.array[index];\n }\n /**\n * Returns true if the key is in the array, false otherwise.\n *\n * @param key The key to locate in the array.\n */\n contains(key) {\n return this.index[key.id()] !== undefined;\n }\n /**\n * Returns the pair associated with the given key, or undefined.\n *\n * @param key The key to locate in the array.\n */\n find(key) {\n const i = this.index[key.id()];\n return i === undefined ? undefined : this.array[i];\n }\n /**\n * Returns the pair associated with the key if it exists.\n *\n * If the key does not exist, a new pair will be created and\n * inserted using the value created by the given factory.\n *\n * @param key The key to locate in the array.\n * @param factory The function which creates the default value.\n */\n setDefault(key, factory) {\n const i = this.index[key.id()];\n if (i === undefined) {\n const pair = new Pair(key, factory());\n this.index[key.id()] = this.array.length;\n this.array.push(pair);\n return pair;\n }\n else {\n return this.array[i];\n }\n }\n /**\n * Insert the pair into the array and return the pair.\n *\n * This will overwrite any existing entry in the array.\n *\n * @param key The key portion of the pair.\n * @param value The value portion of the pair.\n */\n insert(key, value) {\n const pair = new Pair(key, value);\n const i = this.index[key.id()];\n if (i === undefined) {\n this.index[key.id()] = this.array.length;\n this.array.push(pair);\n }\n else {\n this.array[i] = pair;\n }\n return pair;\n }\n /**\n * Removes and returns the pair for the given key, or undefined.\n *\n * @param key The key to remove from the map.\n */\n erase(key) {\n const i = this.index[key.id()];\n if (i === undefined) {\n return undefined;\n }\n this.index[key.id()] = undefined;\n const pair = this.array[i];\n const last = this.array.pop();\n if (pair !== last) {\n this.array[i] = last;\n this.index[last.first.id()] = i;\n }\n return pair;\n }\n /**\n * Create a copy of this associative array.\n */\n copy() {\n const copy = new IndexedMap();\n for (let i = 0; i < this.array.length; i++) {\n const pair = this.array[i].copy();\n copy.array[i] = pair;\n copy.index[pair.first.id()] = i;\n }\n return copy;\n }\n}\n/**\n * A class which defines a generic pair object.\n * @private\n */\n// tslint:disable: max-classes-per-file\nclass Pair {\n first;\n second;\n /**\n * Construct a new Pair object.\n *\n * @param first The first item of the pair.\n * @param second The second item of the pair.\n */\n constructor(first, second) {\n this.first = first;\n this.second = second;\n }\n /**\n * Create a copy of the pair.\n */\n copy() {\n return new Pair(this.first, this.second);\n }\n}\n","import { Expression } from './expression.js';\n/**\n * The primary user constraint variable.\n *\n * @class\n * @param {String} [name=\"\"] The name to associated with the variable.\n */\nexport class Variable {\n constructor(name = '') {\n this._name = name;\n }\n /**\n * Returns the unique id number of the variable.\n * @private\n */\n id() {\n return this._id;\n }\n /**\n * Returns the name of the variable.\n *\n * @return {String} name of the variable\n */\n name() {\n return this._name;\n }\n /**\n * Set the name of the variable.\n *\n * @param {String} name Name of the variable\n */\n setName(name) {\n this._name = name;\n }\n /**\n * Returns the user context object of the variable.\n * @private\n */\n context() {\n return this._context;\n }\n /**\n * Set the user context object of the variable.\n * @private\n */\n setContext(context) {\n this._context = context;\n }\n /**\n * Returns the value of the variable.\n *\n * @return {Number} Calculated value\n */\n value() {\n return this._value;\n }\n /**\n * Set the value of the variable.\n * @private\n */\n setValue(value) {\n this._value = value;\n }\n /**\n * Creates a new Expression by adding a number, variable or expression\n * to the variable.\n *\n * @param {Number|Variable|Expression} value Value to add.\n * @return {Expression} expression\n */\n plus(value) {\n return new Expression(this, value);\n }\n /**\n * Creates a new Expression by substracting a number, variable or expression\n * from the variable.\n *\n * @param {Number|Variable|Expression} value Value to substract.\n * @return {Expression} expression\n */\n minus(value) {\n return new Expression(this, typeof value === 'number' ? -value : [-1, value]);\n }\n /**\n * Creates a new Expression by multiplying with a fixed number.\n *\n * @param {Number} coefficient Coefficient to multiply with.\n * @return {Expression} expression\n */\n multiply(coefficient) {\n return new Expression([coefficient, this]);\n }\n /**\n * Creates a new Expression by dividing with a fixed number.\n *\n * @param {Number} coefficient Coefficient to divide by.\n * @return {Expression} expression\n */\n divide(coefficient) {\n return new Expression([1 / coefficient, this]);\n }\n /**\n * Returns the JSON representation of the variable.\n * @private\n */\n toJSON() {\n return {\n name: this._name,\n value: this._value,\n };\n }\n toString() {\n return this._context + '[' + this._name + ':' + this._value + ']';\n }\n _name;\n _value = 0.0;\n _context = null;\n _id = VarId++;\n}\n/**\n * The internal variable id counter.\n * @private\n */\nlet VarId = 0;\n","import { createMap } from './maptype.js';\nimport { Variable } from './variable.js';\n/**\n * An expression of variable terms and a constant.\n *\n * The constructor accepts an arbitrary number of parameters,\n * each of which must be one of the following types:\n * - number\n * - Variable\n * - Expression\n * - 2-tuple of [number, Variable|Expression]\n *\n * The parameters are summed. The tuples are multiplied.\n *\n * @class\n * @param {...(number|Variable|Expression|Array)} args\n */\nexport class Expression {\n constructor() {\n let parsed = parseArgs(arguments);\n this._terms = parsed.terms;\n this._constant = parsed.constant;\n }\n /**\n * Returns the mapping of terms in the expression.\n *\n * This *must* be treated as const.\n * @private\n */\n terms() {\n return this._terms;\n }\n /**\n * Returns the constant of the expression.\n * @private\n */\n constant() {\n return this._constant;\n }\n /**\n * Returns the computed value of the expression.\n *\n * @private\n * @return {Number} computed value of the expression\n */\n value() {\n let result = this._constant;\n for (let i = 0, n = this._terms.size(); i < n; i++) {\n let pair = this._terms.itemAt(i);\n result += pair.first.value() * pair.second;\n }\n return result;\n }\n /**\n * Creates a new Expression by adding a number, variable or expression\n * to the expression.\n *\n * @param {Number|Variable|Expression} value Value to add.\n * @return {Expression} expression\n */\n plus(value) {\n return new Expression(this, value);\n }\n /**\n * Creates a new Expression by substracting a number, variable or expression\n * from the expression.\n *\n * @param {Number|Variable|Expression} value Value to substract.\n * @return {Expression} expression\n */\n minus(value) {\n return new Expression(this, typeof value === 'number' ? -value : [-1, value]);\n }\n /**\n * Creates a new Expression by multiplying with a fixed number.\n *\n * @param {Number} coefficient Coefficient to multiply with.\n * @return {Expression} expression\n */\n multiply(coefficient) {\n return new Expression([coefficient, this]);\n }\n /**\n * Creates a new Expression by dividing with a fixed number.\n *\n * @param {Number} coefficient Coefficient to divide by.\n * @return {Expression} expression\n */\n divide(coefficient) {\n return new Expression([1 / coefficient, this]);\n }\n isConstant() {\n return this._terms.size() == 0;\n }\n toString() {\n let result = this._terms.array\n .map(function (pair) {\n return pair.second + '*' + pair.first.toString();\n })\n .join(' + ');\n if (!this.isConstant() && this._constant !== 0) {\n result += ' + ';\n }\n result += this._constant;\n return result;\n }\n _terms;\n _constant;\n}\n/**\n * An internal argument parsing function.\n * @private\n */\nfunction parseArgs(args) {\n let constant = 0.0;\n let factory = () => 0.0;\n let terms = createMap();\n for (let i = 0, n = args.length; i < n; ++i) {\n let item = args[i];\n if (typeof item === 'number') {\n constant += item;\n }\n else if (item instanceof Variable) {\n terms.setDefault(item, factory).second += 1.0;\n }\n else if (item instanceof Expression) {\n constant += item.constant();\n let terms2 = item.terms();\n for (let j = 0, k = terms2.size(); j < k; j++) {\n let termPair = terms2.itemAt(j);\n terms.setDefault(termPair.first, factory).second += termPair.second;\n }\n }\n else if (item instanceof Array) {\n if (item.length !== 2) {\n throw new Error('array must have length 2');\n }\n let value = item[0];\n let value2 = item[1];\n if (typeof value !== 'number') {\n throw new Error('array item 0 must be a number');\n }\n if (value2 instanceof Variable) {\n terms.setDefault(value2, factory).second += value;\n }\n else if (value2 instanceof Expression) {\n constant += value2.constant() * value;\n let terms2 = value2.terms();\n for (let j = 0, k = terms2.size(); j < k; j++) {\n let termPair = terms2.itemAt(j);\n terms.setDefault(termPair.first, factory).second += termPair.second * value;\n }\n }\n else {\n throw new Error('array item 1 must be a variable or expression');\n }\n }\n else {\n throw new Error('invalid Expression argument: ' + item);\n }\n }\n return { terms, constant };\n}\n","/**\n * @class Strength\n */\nexport class Strength {\n /**\n * Create a new symbolic strength.\n *\n * @param a strong\n * @param b medium\n * @param c weak\n * @param [w] weight\n * @return strength\n */\n static create(a, b, c, w = 1.0) {\n let result = 0.0;\n result += Math.max(0.0, Math.min(1000.0, a * w)) * 1000000.0;\n result += Math.max(0.0, Math.min(1000.0, b * w)) * 1000.0;\n result += Math.max(0.0, Math.min(1000.0, c * w));\n return result;\n }\n /**\n * The 'required' symbolic strength.\n */\n static required = Strength.create(1000.0, 1000.0, 1000.0);\n /**\n * The 'strong' symbolic strength.\n */\n static strong = Strength.create(1.0, 0.0, 0.0);\n /**\n * The 'medium' symbolic strength.\n */\n static medium = Strength.create(0.0, 1.0, 0.0);\n /**\n * The 'weak' symbolic strength.\n */\n static weak = Strength.create(0.0, 0.0, 1.0);\n /**\n * Clip a symbolic strength to the allowed min and max.\n * @private\n */\n static clip(value) {\n return Math.max(0.0, Math.min(Strength.required, value));\n }\n}\n","import { Expression } from './expression.js';\nimport { Strength } from './strength.js';\n/**\n * An enum defining the linear constraint operators.\n *\n * |Value|Operator|Description|\n * |----|-----|-----|\n * |`Le`|<=|Less than equal|\n * |`Ge`|>=|Greater than equal|\n * |`Eq`|==|Equal|\n *\n * @enum {Number}\n */\nexport var Operator;\n(function (Operator) {\n Operator[Operator[\"Le\"] = 0] = \"Le\";\n Operator[Operator[\"Ge\"] = 1] = \"Ge\";\n Operator[Operator[\"Eq\"] = 2] = \"Eq\";\n})(Operator || (Operator = {}));\n/**\n * A linear constraint equation.\n *\n * A constraint equation is composed of an expression, an operator,\n * and a strength. The RHS of the equation is implicitly zero.\n *\n * @class\n * @param {Expression} expression The constraint expression (LHS).\n * @param {Operator} operator The equation operator.\n * @param {Expression} [rhs] Right hand side of the expression.\n * @param {Number} [strength=Strength.required] The strength of the constraint.\n */\nexport class Constraint {\n constructor(expression, operator, rhs, strength = Strength.required) {\n this._operator = operator;\n this._strength = Strength.clip(strength);\n if (rhs === undefined && expression instanceof Expression) {\n this._expression = expression;\n }\n else {\n this._expression = expression.minus(rhs);\n }\n }\n /**\n * Returns the unique id number of the constraint.\n * @private\n */\n id() {\n return this._id;\n }\n /**\n * Returns the expression of the constraint.\n *\n * @return {Expression} expression\n */\n expression() {\n return this._expression;\n }\n /**\n * Returns the relational operator of the constraint.\n *\n * @return {Operator} linear constraint operator\n */\n op() {\n return this._operator;\n }\n /**\n * Returns the strength of the constraint.\n *\n * @return {Number} strength\n */\n strength() {\n return this._strength;\n }\n toString() {\n return (this._expression.toString() + ' ' + ['<=', '>=', '='][this._operator] + ' 0 (' + this._strength.toString() + ')');\n }\n _expression;\n _operator;\n _strength;\n _id = CnId++;\n}\n/**\n * The internal constraint id counter.\n * @private\n */\nlet CnId = 0;\n","import { Constraint, Operator } from './constraint.js';\nimport { Expression } from './expression.js';\nimport { createMap } from './maptype.js';\nimport { Strength } from './strength.js';\n/**\n * The constraint solver class.\n *\n * @class\n */\nexport class Solver {\n /**\n * @type {number} - The max number of solver iterations before an error\n * is thrown, in order to prevent infinite iteration. Default: `10,000`.\n */\n maxIterations = 1000;\n /**\n * Construct a new Solver.\n */\n constructor() { }\n /**\n * Creates and add a constraint to the solver.\n *\n * @param {Expression|Variable} lhs Left hand side of the expression\n * @param {Operator} operator Operator\n * @param {Expression|Variable|Number} rhs Right hand side of the expression\n * @param {Number} [strength=Strength.required] Strength\n */\n createConstraint(lhs, operator, rhs, strength = Strength.required) {\n let cn = new Constraint(lhs, operator, rhs, strength);\n this.addConstraint(cn);\n return cn;\n }\n /**\n * Add a constraint to the solver.\n *\n * @param {Constraint} constraint Constraint to add to the solver\n */\n addConstraint(constraint) {\n let cnPair = this._cnMap.find(constraint);\n if (cnPair !== undefined) {\n throw new Error('duplicate constraint');\n }\n // Creating a row causes symbols to be reserved for the variables\n // in the constraint. If this method exits with an exception,\n // then its possible those variables will linger in the var map.\n // Since its likely that those variables will be used in other\n // constraints and since exceptional conditions are uncommon,\n // i'm not too worried about aggressive cleanup of the var map.\n let data = this._createRow(constraint);\n let row = data.row;\n let tag = data.tag;\n let subject = this._chooseSubject(row, tag);\n // If chooseSubject couldnt find a valid entering symbol, one\n // last option is available if the entire row is composed of\n // dummy variables. If the constant of the row is zero, then\n // this represents redundant constraints and the new dummy\n // marker can enter the basis. If the constant is non-zero,\n // then it represents an unsatisfiable constraint.\n if (subject.type() === SymbolType.Invalid && row.allDummies()) {\n if (!nearZero(row.constant())) {\n throw new Error('unsatisfiable constraint');\n }\n else {\n subject = tag.marker;\n }\n }\n // If an entering symbol still isn't found, then the row must\n // be added using an artificial variable. If that fails, then\n // the row represents an unsatisfiable constraint.\n if (subject.type() === SymbolType.Invalid) {\n if (!this._addWithArtificialVariable(row)) {\n throw new Error('unsatisfiable constraint');\n }\n }\n else {\n row.solveFor(subject);\n this._substitute(subject, row);\n this._rowMap.insert(subject, row);\n }\n this._cnMap.insert(constraint, tag);\n // Optimizing after each constraint is added performs less\n // aggregate work due to a smaller average system size. It\n // also ensures the solver remains in a consistent state.\n this._optimize(this._objective);\n }\n /**\n * Remove a constraint from the solver.\n *\n * @param {Constraint} constraint Constraint to remove from the solver\n */\n removeConstraint(constraint) {\n let cnPair = this._cnMap.erase(constraint);\n if (cnPair === undefined) {\n throw new Error('unknown constraint');\n }\n // Remove the error effects from the objective function\n // *before* pivoting, or substitutions into the objective\n // will lead to incorrect solver results.\n this._removeConstraintEffects(constraint, cnPair.second);\n // If the marker is basic, simply drop the row. Otherwise,\n // pivot the marker into the basis and then drop the row.\n let marker = cnPair.second.marker;\n let rowPair = this._rowMap.erase(marker);\n if (rowPair === undefined) {\n let leaving = this._getMarkerLeavingSymbol(marker);\n if (leaving.type() === SymbolType.Invalid) {\n throw new Error('failed to find leaving row');\n }\n rowPair = this._rowMap.erase(leaving);\n rowPair.second.solveForEx(leaving, marker);\n this._substitute(marker, rowPair.second);\n }\n // Optimizing after each constraint is removed ensures that the\n // solver remains consistent. It makes the solver api easier to\n // use at a small tradeoff for speed.\n this._optimize(this._objective);\n }\n /**\n * Test whether the solver contains the constraint.\n *\n * @param {Constraint} constraint Constraint to test for\n * @return {Bool} true or false\n */\n hasConstraint(constraint) {\n return this._cnMap.contains(constraint);\n }\n /**\n * Get an array of the current constraints.\n *\n * @return {Constraint[]}\n */\n getConstraints() {\n return this._cnMap.array.map(({ first }) => first);\n }\n /**\n * Add an edit variable to the solver.\n *\n * @param {Variable} variable Edit variable to add to the solver\n * @param {Number} strength Strength, should be less than `Strength.required`\n */\n addEditVariable(variable, strength) {\n let editPair = this._editMap.find(variable);\n if (editPair !== undefined) {\n throw new Error('duplicate edit variable');\n }\n strength = Strength.clip(strength);\n if (strength === Strength.required) {\n throw new Error('bad required strength');\n }\n let expr = new Expression(variable);\n let cn = new Constraint(expr, Operator.Eq, undefined, strength);\n this.addConstraint(cn);\n let tag = this._cnMap.find(cn).second;\n let info = { tag, constraint: cn, constant: 0.0 };\n this._editMap.insert(variable, info);\n }\n /**\n * Remove an edit variable from the solver.\n *\n * @param {Variable} variable Edit variable to remove from the solver\n */\n removeEditVariable(variable) {\n let editPair = this._editMap.erase(variable);\n if (editPair === undefined) {\n throw new Error('unknown edit variable');\n }\n this.removeConstraint(editPair.second.constraint);\n }\n /**\n * Test whether the solver contains the edit variable.\n *\n * @param {Variable} variable Edit variable to test for\n * @return {Bool} true or false\n */\n hasEditVariable(variable) {\n return this._editMap.contains(variable);\n }\n /**\n * Suggest the value of an edit variable.\n *\n * @param {Variable} variable Edit variable to suggest a value for\n * @param {Number} value Suggested value\n */\n suggestValue(variable, value) {\n let editPair = this._editMap.find(variable);\n if (editPair === undefined) {\n throw new Error('unknown edit variable');\n }\n let rows = this._rowMap;\n let info = editPair.second;\n let delta = value - info.constant;\n info.constant = value;\n // Check first if the positive error variable is basic.\n let marker = info.tag.marker;\n let rowPair = rows.find(marker);\n if (rowPair !== undefined) {\n if (rowPair.second.add(-delta) < 0.0) {\n this._infeasibleRows.push(marker);\n }\n this._dualOptimize();\n return;\n }\n // Check next if the negative error variable is basic.\n let other = info.tag.other;\n rowPair = rows.find(other);\n if (rowPair !== undefined) {\n if (rowPair.second.add(delta) < 0.0) {\n this._infeasibleRows.push(other);\n }\n this._dualOptimize();\n return;\n }\n // Otherwise update each row where the error variables exist.\n for (let i = 0, n = rows.size(); i < n; ++i) {\n let rowPair = rows.itemAt(i);\n let row = rowPair.second;\n let coeff = row.coefficientFor(marker);\n if (coeff !== 0.0 && row.add(delta * coeff) < 0.0 && rowPair.first.type() !== SymbolType.External) {\n this._infeasibleRows.push(rowPair.first);\n }\n }\n this._dualOptimize();\n }\n /**\n * Update the values of the variables.\n */\n updateVariables() {\n let vars = this._varMap;\n let rows = this._rowMap;\n for (let i = 0, n = vars.size(); i < n; ++i) {\n let pair = vars.itemAt(i);\n let rowPair = rows.find(pair.second);\n if (rowPair !== undefined) {\n pair.first.setValue(rowPair.second.constant());\n }\n else {\n pair.first.setValue(0.0);\n }\n }\n }\n /**\n * Get the symbol for the given variable.\n *\n * If a symbol does not exist for the variable, one will be created.\n * @private\n */\n _getVarSymbol(variable) {\n let factory = () => this._makeSymbol(SymbolType.External);\n return this._varMap.setDefault(variable, factory).second;\n }\n /**\n * Create a new Row object for the given constraint.\n *\n * The terms in the constraint will be converted to cells in the row.\n * Any term in the constraint with a coefficient of zero is ignored.\n * This method uses the `_getVarSymbol` method to get the symbol for\n * the variables added to the row. If the symbol for a given cell\n * variable is basic, the cell variable will be substituted with the\n * basic row.\n *\n * The necessary slack and error variables will be added to the row.\n * If the constant for the row is negative, the sign for the row\n * will be inverted so the constant becomes positive.\n *\n * Returns the created Row and the tag for tracking the constraint.\n * @private\n */\n _createRow(constraint) {\n let expr = constraint.expression();\n let row = new Row(expr.constant());\n // Substitute the current basic variables into the row.\n let terms = expr.terms();\n for (let i = 0, n = terms.size(); i < n; ++i) {\n let termPair = terms.itemAt(i);\n if (!nearZero(termPair.second)) {\n let symbol = this._getVarSymbol(termPair.first);\n let basicPair = this._rowMap.find(symbol);\n if (basicPair !== undefined) {\n row.insertRow(basicPair.second, termPair.second);\n }\n else {\n row.insertSymbol(symbol, termPair.second);\n }\n }\n }\n // Add the necessary slack, error, and dummy variables.\n let objective = this._objective;\n let strength = constraint.strength();\n let tag = { marker: INVALID_SYMBOL, other: INVALID_SYMBOL };\n switch (constraint.op()) {\n case Operator.Le:\n case Operator.Ge: {\n let coeff = constraint.op() === Operator.Le ? 1.0 : -1.0;\n let slack = this._makeSymbol(SymbolType.Slack);\n tag.marker = slack;\n row.insertSymbol(slack, coeff);\n if (strength < Strength.required) {\n let error = this._makeSymbol(SymbolType.Error);\n tag.other = error;\n row.insertSymbol(error, -coeff);\n objective.insertSymbol(error, strength);\n }\n break;\n }\n case Operator.Eq: {\n if (strength < Strength.required) {\n let errplus = this._makeSymbol(SymbolType.Error);\n let errminus = this._makeSymbol(SymbolType.Error);\n tag.marker = errplus;\n tag.other = errminus;\n row.insertSymbol(errplus, -1.0); // v = eplus - eminus\n row.insertSymbol(errminus, 1.0); // v - eplus + eminus = 0\n objective.insertSymbol(errplus, strength);\n objective.insertSymbol(errminus, strength);\n }\n else {\n let dummy = this._makeSymbol(SymbolType.Dummy);\n tag.marker = dummy;\n row.insertSymbol(dummy);\n }\n break;\n }\n }\n // Ensure the row has a positive constant.\n if (row.constant() < 0.0) {\n row.reverseSign();\n }\n return { row, tag };\n }\n /**\n * Choose the subject for solving for the row.\n *\n * This method will choose the best subject for using as the solve\n * target for the row. An invalid symbol will be returned if there\n * is no valid target.\n *\n * The symbols are chosen according to the following precedence:\n *\n * 1) The first symbol representing an external variable.\n * 2) A negative slack or error tag variable.\n *\n * If a subject cannot be found, an invalid symbol will be returned.\n *\n * @private\n */\n _chooseSubject(row, tag) {\n let cells = row.cells();\n for (let i = 0, n = cells.size(); i < n; ++i) {\n let pair = cells.itemAt(i);\n if (pair.first.type() === SymbolType.External) {\n return pair.first;\n }\n }\n let type = tag.marker.type();\n if (type === SymbolType.Slack || type === SymbolType.Error) {\n if (row.coefficientFor(tag.marker) < 0.0) {\n return tag.marker;\n }\n }\n type = tag.other.type();\n if (type === SymbolType.Slack || type === SymbolType.Error) {\n if (row.coefficientFor(tag.other) < 0.0) {\n return tag.other;\n }\n }\n return INVALID_SYMBOL;\n }\n /**\n * Add the row to the tableau using an artificial variable.\n *\n * This will return false if the constraint cannot be satisfied.\n *\n * @private\n */\n _addWithArtificialVariable(row) {\n // Create and add the artificial variable to the tableau.\n let art = this._makeSymbol(SymbolType.Slack);\n this._rowMap.insert(art, row.copy());\n this._artificial = row.copy();\n // Optimize the artificial objective. This is successful\n // only if the artificial objective is optimized to zero.\n this._optimize(this._artificial);\n let success = nearZero(this._artificial.constant());\n this._artificial = null;\n // If the artificial variable is basic, pivot the row so that\n // it becomes non-basic. If the row is constant, exit early.\n let pair = this._rowMap.erase(art);\n if (pair !== undefined) {\n let basicRow = pair.second;\n if (basicRow.isConstant()) {\n return success;\n }\n let entering = this._anyPivotableSymbol(basicRow);\n if (entering.type() === SymbolType.Invalid) {\n return false; // unsatisfiable (will this ever happen?)\n }\n basicRow.solveForEx(art, entering);\n this._substitute(entering, basicRow);\n this._rowMap.insert(entering, basicRow);\n }\n // Remove the artificial variable from the tableau.\n let rows = this._rowMap;\n for (let i = 0, n = rows.size(); i < n; ++i) {\n rows.itemAt(i).second.removeSymbol(art);\n }\n this._objective.removeSymbol(art);\n return success;\n }\n /**\n * Substitute the parametric symbol with the given row.\n *\n * This method will substitute all instances of the parametric symbol\n * in the tableau and the objective function with the given row.\n *\n * @private\n */\n _substitute(symbol, row) {\n let rows = this._rowMap;\n for (let i = 0, n = rows.size(); i < n; ++i) {\n let pair = rows.itemAt(i);\n pair.second.substitute(symbol, row);\n if (pair.second.constant() < 0.0 && pair.first.type() !== SymbolType.External) {\n this._infeasibleRows.push(pair.first);\n }\n }\n this._objective.substitute(symbol, row);\n if (this._artificial) {\n this._artificial.substitute(symbol, row);\n }\n }\n /**\n * Optimize the system for the given objective function.\n *\n * This method performs iterations of Phase 2 of the simplex method\n * until the objective function reaches a minimum.\n *\n * @private\n */\n _optimize(objective) {\n let iterations = 0;\n while (iterations < this.maxIterations) {\n let entering = this._getEnteringSymbol(objective);\n if (entering.type() === SymbolType.Invalid) {\n return;\n }\n let leaving = this._getLeavingSymbol(entering);\n if (leaving.type() === SymbolType.Invalid) {\n throw new Error('the objective is unbounded');\n }\n // pivot the entering symbol into the basis\n let row = this._rowMap.erase(leaving).second;\n row.solveForEx(leaving, entering);\n this._substitute(entering, row);\n this._rowMap.insert(entering, row);\n iterations++;\n }\n throw new Error('solver iterations exceeded');\n }\n /**\n * Optimize the system using the dual of the simplex method.\n *\n * The current state of the system should be such that the objective\n * function is optimal, but not feasible. This method will perform\n * an iteration of the dual simplex method to make the solution both\n * optimal and feasible.\n *\n * @private\n */\n _dualOptimize() {\n let rows = this._rowMap;\n let infeasible = this._infeasibleRows;\n while (infeasible.length !== 0) {\n let leaving = infeasible.pop();\n let pair = rows.find(leaving);\n if (pair !== undefined && pair.second.constant() < 0.0) {\n let entering = this._getDualEnteringSymbol(pair.second);\n if (entering.type() === SymbolType.Invalid) {\n throw new Error('dual optimize failed');\n }\n // pivot the entering symbol into the basis\n let row = pair.second;\n rows.erase(leaving);\n row.solveForEx(leaving, entering);\n this._substitute(entering, row);\n rows.insert(entering, row);\n }\n }\n }\n /**\n * Compute the entering variable for a pivot operation.\n *\n * This method will return first symbol in the objective function which\n * is non-dummy and has a coefficient less than zero. If no symbol meets\n * the criteria, it means the objective function is at a minimum, and an\n * invalid symbol is returned.\n *\n * @private\n */\n _getEnteringSymbol(objective) {\n let cells = objective.cells();\n for (let i = 0, n = cells.size(); i < n; ++i) {\n let pair = cells.itemAt(i);\n let symbol = pair.first;\n if (pair.second < 0.0 && symbol.type() !== SymbolType.Dummy) {\n return symbol;\n }\n }\n return INVALID_SYMBOL;\n }\n /**\n * Compute the entering symbol for the dual optimize operation.\n *\n * This method will return the symbol in the row which has a positive\n * coefficient and yields the minimum ratio for its respective symbol\n * in the objective function. The provided row *must* be infeasible.\n * If no symbol is found which meats the criteria, an invalid symbol\n * is returned.\n *\n * @private\n */\n _getDualEnteringSymbol(row) {\n let ratio = Number.MAX_VALUE;\n let entering = INVALID_SYMBOL;\n let cells = row.cells();\n for (let i = 0, n = cells.size(); i < n; ++i) {\n let pair = cells.itemAt(i);\n let symbol = pair.first;\n let c = pair.second;\n if (c > 0.0 && symbol.type() !== SymbolType.Dummy) {\n let coeff = this._objective.coefficientFor(symbol);\n let r = coeff / c;\n if (r < ratio) {\n ratio = r;\n entering = symbol;\n }\n }\n }\n return entering;\n }\n /**\n * Compute the symbol for pivot exit row.\n *\n * This method will return the symbol for the exit row in the row\n * map. If no appropriate exit symbol is found, an invalid symbol\n * will be returned. This indicates that the objective function is\n * unbounded.\n *\n * @private\n */\n _getLeavingSymbol(entering) {\n let ratio = Number.MAX_VALUE;\n let found = INVALID_SYMBOL;\n let rows = this._rowMap;\n for (let i = 0, n = rows.size(); i < n; ++i) {\n let pair = rows.itemAt(i);\n let symbol = pair.first;\n if (symbol.type() !== SymbolType.External) {\n let row = pair.second;\n let temp = row.coefficientFor(entering);\n if (temp < 0.0) {\n let temp_ratio = -row.constant() / temp;\n if (temp_ratio < ratio) {\n ratio = temp_ratio;\n found = symbol;\n }\n }\n }\n }\n return found;\n }\n /**\n * Compute the leaving symbol for a marker variable.\n *\n * This method will return a symbol corresponding to a basic row\n * which holds the given marker variable. The row will be chosen\n * according to the following precedence:\n *\n * 1) The row with a restricted basic varible and a negative coefficient\n * for the marker with the smallest ratio of -constant / coefficient.\n *\n * 2) The row with a restricted basic variable and the smallest ratio\n * of constant / coefficient.\n *\n * 3) The last unrestricted row which contains the marker.\n *\n * If the marker does not exist in any row, an invalid symbol will be\n * returned. This indicates an internal solver error since the marker\n * *should* exist somewhere in the tableau.\n *\n * @private\n */\n _getMarkerLeavingSymbol(marker) {\n let dmax = Number.MAX_VALUE;\n let r1 = dmax;\n let r2 = dmax;\n let invalid = INVALID_SYMBOL;\n let first = invalid;\n let second = invalid;\n let third = invalid;\n let rows = this._rowMap;\n for (let i = 0, n = rows.size(); i < n; ++i) {\n let pair = rows.itemAt(i);\n let row = pair.second;\n let c = row.coefficientFor(marker);\n if (c === 0.0) {\n continue;\n }\n let symbol = pair.first;\n if (symbol.type() === SymbolType.External) {\n third = symbol;\n }\n else if (c < 0.0) {\n let r = -row.constant() / c;\n if (r < r1) {\n r1 = r;\n first = symbol;\n }\n }\n else {\n let r = row.constant() / c;\n if (r < r2) {\n r2 = r;\n second = symbol;\n }\n }\n }\n if (first !== invalid) {\n return first;\n }\n if (second !== invalid) {\n return second;\n }\n return third;\n }\n /**\n * Remove the effects of a constraint on the objective function.\n *\n * @private\n */\n _removeConstraintEffects(cn, tag) {\n if (tag.marker.type() === SymbolType.Error) {\n this._removeMarkerEffects(tag.marker, cn.strength());\n }\n if (tag.other.type() === SymbolType.Error) {\n this._removeMarkerEffects(tag.other, cn.strength());\n }\n }\n /**\n * Remove the effects of an error marker on the objective function.\n *\n * @private\n */\n _removeMarkerEffects(marker, strength) {\n let pair = this._rowMap.find(marker);\n if (pair !== undefined) {\n this._objective.insertRow(pair.second, -strength);\n }\n else {\n this._objective.insertSymbol(marker, -strength);\n }\n }\n /**\n * Get the first Slack or Error symbol in the row.\n *\n * If no such symbol is present, an invalid symbol will be returned.\n *\n * @private\n */\n _anyPivotableSymbol(row) {\n let cells = row.cells();\n for (let i = 0, n = cells.size(); i < n; ++i) {\n let pair = cells.itemAt(i);\n let type = pair.first.type();\n if (type === SymbolType.Slack || type === SymbolType.Error) {\n return pair.first;\n }\n }\n return INVALID_SYMBOL;\n }\n /**\n * Returns a new Symbol of the given type.\n *\n * @private\n */\n _makeSymbol(type) {\n return new Symbol(type, this._idTick++);\n }\n _cnMap = createCnMap();\n _rowMap = createRowMap();\n _varMap = createVarMap();\n _editMap = createEditMap();\n _infeasibleRows = [];\n _objective = new Row();\n _artificial = null;\n _idTick = 0;\n}\n/**\n * Test whether a value is approximately zero.\n * @private\n */\nfunction nearZero(value) {\n let eps = 1.0e-8;\n return value < 0.0 ? -value < eps : value < eps;\n}\n/**\n * An internal function for creating a constraint map.\n * @private\n */\nfunction createCnMap() {\n return createMap();\n}\n/**\n * An internal function for creating a row map.\n * @private\n */\nfunction createRowMap() {\n return createMap();\n}\n/**\n * An internal function for creating a variable map.\n * @private\n */\nfunction createVarMap() {\n return createMap();\n}\n/**\n * An internal function for creating an edit map.\n * @private\n */\nfunction createEditMap() {\n return createMap();\n}\n/**\n * An enum defining the available symbol types.\n * @private\n */\nvar SymbolType;\n(function (SymbolType) {\n SymbolType[SymbolType[\"Invalid\"] = 0] = \"Invalid\";\n SymbolType[SymbolType[\"External\"] = 1] = \"External\";\n SymbolType[SymbolType[\"Slack\"] = 2] = \"Slack\";\n SymbolType[SymbolType[\"Error\"] = 3] = \"Error\";\n SymbolType[SymbolType[\"Dummy\"] = 4] = \"Dummy\";\n})(SymbolType || (SymbolType = {}));\n/**\n * An internal class representing a symbol in the solver.\n * @private\n */\nclass Symbol {\n /**\n * Construct a new Symbol\n *\n * @param [type] The type of the symbol.\n * @param [id] The unique id number of the symbol.\n */\n constructor(type, id) {\n this._id = id;\n this._type = type;\n }\n /**\n * Returns the unique id number of the symbol.\n */\n id() {\n return this._id;\n }\n /**\n * Returns the type of the symbol.\n */\n type() {\n return this._type;\n }\n _id;\n _type;\n}\n/**\n * A static invalid symbol\n * @private\n */\nlet INVALID_SYMBOL = new Symbol(SymbolType.Invalid, -1);\n/**\n * An internal row class used by the solver.\n * @private\n */\nclass Row {\n /**\n * Construct a new Row.\n */\n constructor(constant = 0.0) {\n this._constant = constant;\n }\n /**\n * Returns the mapping of symbols to coefficients.\n */\n cells() {\n return this._cellMap;\n }\n /**\n * Returns the constant for the row.\n */\n constant() {\n return this._constant;\n }\n /**\n * Returns true if the row is a constant value.\n */\n isConstant() {\n return this._cellMap.empty();\n }\n /**\n * Returns true if the Row has all dummy symbols.\n */\n allDummies() {\n let cells = this._cellMap;\n for (let i = 0, n = cells.size(); i < n; ++i) {\n let pair = cells.itemAt(i);\n if (pair.first.type() !== SymbolType.Dummy) {\n return false;\n }\n }\n return true;\n }\n /**\n * Create a copy of the row.\n */\n copy() {\n let theCopy = new Row(this._constant);\n theCopy._cellMap = this._cellMap.copy();\n return theCopy;\n }\n /**\n * Add a constant value to the row constant.\n *\n * Returns the new value of the constant.\n */\n add(value) {\n return (this._constant += value);\n }\n /**\n * Insert the symbol into the row with the given coefficient.\n *\n * If the symbol already exists in the row, the coefficient\n * will be added to the existing coefficient. If the resulting\n * coefficient is zero, the symbol will be removed from the row.\n */\n insertSymbol(symbol, coefficient = 1.0) {\n let pair = this._cellMap.setDefault(symbol, () => 0.0);\n if (nearZero((pair.second += coefficient))) {\n this._cellMap.erase(symbol);\n }\n }\n /**\n * Insert a row into this row with a given coefficient.\n *\n * The constant and the cells of the other row will be\n * multiplied by the coefficient and added to this row. Any\n * cell with a resulting coefficient of zero will be removed\n * from the row.\n */\n insertRow(other, coefficient = 1.0) {\n this._constant += other._constant * coefficient;\n let cells = other._cellMap;\n for (let i = 0, n = cells.size(); i < n; ++i) {\n let pair = cells.itemAt(i);\n this.insertSymbol(pair.first, pair.second * coefficient);\n }\n }\n /**\n * Remove a symbol from the row.\n */\n removeSymbol(symbol) {\n this._cellMap.erase(symbol);\n }\n /**\n * Reverse the sign of the constant and cells in the row.\n */\n reverseSign() {\n this._constant = -this._constant;\n let cells = this._cellMap;\n for (let i = 0, n = cells.size(); i < n; ++i) {\n let pair = cells.itemAt(i);\n pair.second = -pair.second;\n }\n }\n /**\n * Solve the row for the given symbol.\n *\n * This method assumes the row is of the form\n * a * x + b * y + c = 0 and (assuming solve for x) will modify\n * the row to represent the right hand side of\n * x = -b/a * y - c / a. The target symbol will be removed from\n * the row, and the constant and other cells will be multiplied\n * by the negative inverse of the target coefficient.\n *\n * The given symbol *must* exist in the row.\n */\n solveFor(symbol) {\n let cells = this._cellMap;\n let pair = cells.erase(symbol);\n let coeff = -1.0 / pair.second;\n this._constant *= coeff;\n for (let i = 0, n = cells.size(); i < n; ++i) {\n cells.itemAt(i).second *= coeff;\n }\n }\n /**\n * Solve the row for the given symbols.\n *\n * This method assumes the row is of the form\n * x = b * y + c and will solve the row such that\n * y = x / b - c / b. The rhs symbol will be removed from the\n * row, the lhs added, and the result divided by the negative\n * inverse of the rhs coefficient.\n *\n * The lhs symbol *must not* exist in the row, and the rhs\n * symbol must* exist in the row.\n */\n solveForEx(lhs, rhs) {\n this.insertSymbol(lhs, -1.0);\n this.solveFor(rhs);\n }\n /**\n * Returns the coefficient for the given symbol.\n */\n coefficientFor(symbol) {\n let pair = this._cellMap.find(symbol);\n return pair !== undefined ? pair.second : 0.0;\n }\n /**\n * Substitute a symbol with the data from another row.\n *\n * Given a row of the form a * x + b and a substitution of the\n * form x = 3 * y + c the row will be updated to reflect the\n * expression 3 * a * y + a * c + b.\n *\n * If the symbol does not exist in the row, this is a no-op.\n */\n substitute(symbol, row) {\n let pair = this._cellMap.erase(symbol);\n if (pair !== undefined) {\n this.insertRow(row, pair.second);\n }\n }\n _cellMap = createMap();\n _constant;\n}\n","import { Strength } from \"@lume/kiwi\";\n\nconst HIGH_PRIORITY = 1000;\nconst MEDIUM_PRIORITY = 100;\nconst LOW_PRIORITY = 10;\n\n/** Constraint solver priority levels */\nexport enum UIPriority {\n /** Highest priority */\n P0 = 0,\n /** High priority */\n P1 = 1,\n /** Medium-high priority */\n P2 = 2,\n /** Medium priority */\n P3 = 3,\n /** Medium-low priority */\n P4 = 4,\n /** Low priority */\n P5 = 5,\n /** Very low priority */\n P6 = 6,\n /** Lowest priority */\n P7 = 7,\n}\n\n/**\n * Converts priority to solver strength.\n * @param priority Priority level\n * @returns Solver strength value\n * @throws If priority is invalid\n */\nexport function convertPriority(priority: UIPriority): number {\n switch (priority) {\n case UIPriority.P0:\n return Strength.create(HIGH_PRIORITY, HIGH_PRIORITY, HIGH_PRIORITY);\n case UIPriority.P1:\n return Strength.create(MEDIUM_PRIORITY, 0, 0);\n case UIPriority.P2:\n return Strength.create(LOW_PRIORITY, 0, 0);\n case UIPriority.P3:\n return Strength.create(0, MEDIUM_PRIORITY, 0);\n case UIPriority.P4:\n return Strength.create(0, LOW_PRIORITY, 0);\n case UIPriority.P5:\n return Strength.create(0, 0, MEDIUM_PRIORITY);\n case UIPriority.P6:\n return Strength.create(0, 0, LOW_PRIORITY);\n case UIPriority.P7:\n return Strength.create(0, 0, 1);\n default:\n throw new Error(`convertPriority.priority: invalid priority`);\n }\n}\n\n/**\n * Resolves optional priority.\n * @param priority Priority to resolve\n * @returns Priority or P0 if undefined\n */\nexport function resolvePriority(priority?: UIPriority): UIPriority {\n return priority ?? UIPriority.P0;\n}\n","import type {\n UIInputWrapperCatcher,\n UIInputWrapperInterface,\n} from \"./UIInputWrapper.Internal\";\n\nexport class UIInputWrapper implements UIInputWrapperInterface {\n /** @internal */\n public dirty = false;\n\n private zIndicesDirty = false;\n private readonly catchers: UIInputWrapperCatcher[] = [];\n private lastHandler = 0;\n\n public createInputCatcher(\n catchPointerDown: (x: number, y: number, identifier: number) => boolean,\n catchPointerMove: (x: number, y: number, identifier: number) => boolean,\n catchPointerUp: (x: number, y: number, identifier: number) => boolean,\n zIndex: number,\n ): number {\n const handler = this.lastHandler++;\n this.catchers.push({\n handler,\n catchPointerDown,\n catchPointerMove,\n catchPointerUp,\n zIndex,\n active: true,\n });\n this.zIndicesDirty = true;\n this.dirty = true;\n return handler;\n }\n\n public destroyInputCatcher(handler: number): void {\n const index = this.catchers.findIndex((item) => item.handler === handler);\n if (index === -1) {\n throw new Error(\n \"UIInputWrapper.destroyInputCatcher.handler: handler not found\",\n );\n }\n this.catchers.splice(index, 1);\n }\n\n public getZIndex(handler: number): number {\n this.ensureSorted();\n const found = this.catchers.find((item) => item.handler === handler);\n if (!found) {\n throw new Error(\"UIInputWrapper.getZIndex.handler: handler not found\");\n }\n return found.zIndex;\n }\n\n public setZIndex(handler: number, zIndex: number): void {\n const found = this.catchers.find((item) => item.handler === handler);\n if (!found) {\n throw new Error(\"UIInputWrapper.setZIndex.handler: handler not found\");\n }\n if (found.zIndex !== zIndex) {\n found.zIndex = zIndex;\n this.zIndicesDirty = true;\n this.dirty = true;\n }\n }\n\n public getActive(handler: number): boolean {\n const found = this.catchers.find((item) => item.handler === handler);\n if (!found) {\n throw new Error(\"UIInputWrapper.getActive.handler: handler not found\");\n }\n return found.active;\n }\n\n public setActive(handler: number, active: boolean): void {\n const found = this.catchers.find((item) => item.handler === handler);\n if (!found) {\n throw new Error(\"UIInputWrapper.setActive.handler: handler not found\");\n }\n if (found.active !== active) {\n found.active = active;\n }\n }\n\n /** @internal */\n public onPointerDown(x: number, y: number, identifier: number): void {\n this.ensureSorted();\n for (let index = this.catchers.length - 1; index >= 0; index--) {\n const item = this.catchers[index];\n if (item.active && item.catchPointerDown(x, y, identifier)) {\n break;\n }\n }\n }\n\n /** @internal */\n public onPointerMove(x: number, y: number, identifier: number): void {\n this.ensureSorted();\n for (let index = this.catchers.length - 1; index >= 0; index--) {\n const item = this.catchers[index];\n if (item.active && item.catchPointerMove(x, y, identifier)) {\n break;\n }\n }\n }\n\n /** @internal */\n public onPointerUp(x: number, y: number, identifier: number): void {\n this.ensureSorted();\n for (let index = this.catchers.length - 1; index >= 0; index--) {\n const item = this.catchers[index];\n if (item.active && item.catchPointerUp(x, y, identifier)) {\n break;\n }\n }\n }\n\n private ensureSorted(): void {\n if (this.zIndicesDirty) {\n this.catchers.sort((a, b) => a.zIndex - b.zIndex);\n\n const count = this.catchers.length;\n const step = count < 1024 ? 1 : 1024 / count;\n for (let index = 0; index < count; index++) {\n this.catchers[index].zIndex = index * step;\n }\n\n this.zIndicesDirty = false;\n }\n }\n}\n","import { SRGBColorSpace, LinearSRGBColorSpace, SRGBTransfer, LinearTransfer, NoColorSpace } from '../constants.js';\nimport { Matrix3 } from './Matrix3.js';\nimport { warnOnce } from '../utils.js';\n\nconst LINEAR_REC709_TO_XYZ = /*@__PURE__*/ new Matrix3().set(\n\t0.4123908, 0.3575843, 0.1804808,\n\t0.2126390, 0.7151687, 0.0721923,\n\t0.0193308, 0.1191948, 0.9505322\n);\n\nconst XYZ_TO_LINEAR_REC709 = /*@__PURE__*/ new Matrix3().set(\n\t3.2409699, - 1.5373832, - 0.4986108,\n\t- 0.9692436, 1.8759675, 0.0415551,\n\t0.0556301, - 0.2039770, 1.0569715\n);\n\nfunction createColorManagement() {\n\n\tconst ColorManagement = {\n\n\t\tenabled: true,\n\n\t\tworkingColorSpace: LinearSRGBColorSpace,\n\n\t\t/**\n\t\t * Implementations of supported color spaces.\n\t\t *\n\t\t * Required:\n\t\t *\t- primaries: chromaticity coordinates [ rx ry gx gy bx by ]\n\t\t *\t- whitePoint: reference white [ x y ]\n\t\t *\t- transfer: transfer function (pre-defined)\n\t\t *\t- toXYZ: Matrix3 RGB to XYZ transform\n\t\t *\t- fromXYZ: Matrix3 XYZ to RGB transform\n\t\t *\t- luminanceCoefficients: RGB luminance coefficients\n\t\t *\n\t\t * Optional:\n\t\t * - outputColorSpaceConfig: { drawingBufferColorSpace: ColorSpace }\n\t\t * - workingColorSpaceConfig: { unpackColorSpace: ColorSpace }\n\t\t *\n\t\t * Reference:\n\t\t * - https://www.russellcottrell.com/photo/matrixCalculator.htm\n\t\t */\n\t\tspaces: {},\n\n\t\tconvert: function ( color, sourceColorSpace, targetColorSpace ) {\n\n\t\t\tif ( this.enabled === false || sourceColorSpace === targetColorSpace || ! sourceColorSpace || ! targetColorSpace ) {\n\n\t\t\t\treturn color;\n\n\t\t\t}\n\n\t\t\tif ( this.spaces[ sourceColorSpace ].transfer === SRGBTransfer ) {\n\n\t\t\t\tcolor.r = SRGBToLinear( color.r );\n\t\t\t\tcolor.g = SRGBToLinear( color.g );\n\t\t\t\tcolor.b = SRGBToLinear( color.b );\n\n\t\t\t}\n\n\t\t\tif ( this.spaces[ sourceColorSpace ].primaries !== this.spaces[ targetColorSpace ].primaries ) {\n\n\t\t\t\tcolor.applyMatrix3( this.spaces[ sourceColorSpace ].toXYZ );\n\t\t\t\tcolor.applyMatrix3( this.spaces[ targetColorSpace ].fromXYZ );\n\n\t\t\t}\n\n\t\t\tif ( this.spaces[ targetColorSpace ].transfer === SRGBTransfer ) {\n\n\t\t\t\tcolor.r = LinearToSRGB( color.r );\n\t\t\t\tcolor.g = LinearToSRGB( color.g );\n\t\t\t\tcolor.b = LinearToSRGB( color.b );\n\n\t\t\t}\n\n\t\t\treturn color;\n\n\t\t},\n\n\t\tworkingToColorSpace: function ( color, targetColorSpace ) {\n\n\t\t\treturn this.convert( color, this.workingColorSpace, targetColorSpace );\n\n\t\t},\n\n\t\tcolorSpaceToWorking: function ( color, sourceColorSpace ) {\n\n\t\t\treturn this.convert( color, sourceColorSpace, this.workingColorSpace );\n\n\t\t},\n\n\t\tgetPrimaries: function ( colorSpace ) {\n\n\t\t\treturn this.spaces[ colorSpace ].primaries;\n\n\t\t},\n\n\t\tgetTransfer: function ( colorSpace ) {\n\n\t\t\tif ( colorSpace === NoColorSpace ) return LinearTransfer;\n\n\t\t\treturn this.spaces[ colorSpace ].transfer;\n\n\t\t},\n\n\t\tgetLuminanceCoefficients: function ( target, colorSpace = this.workingColorSpace ) {\n\n\t\t\treturn target.fromArray( this.spaces[ colorSpace ].luminanceCoefficients );\n\n\t\t},\n\n\t\tdefine: function ( colorSpaces ) {\n\n\t\t\tObject.assign( this.spaces, colorSpaces );\n\n\t\t},\n\n\t\t// Internal APIs\n\n\t\t_getMatrix: function ( targetMatrix, sourceColorSpace, targetColorSpace ) {\n\n\t\t\treturn targetMatrix\n\t\t\t\t.copy( this.spaces[ sourceColorSpace ].toXYZ )\n\t\t\t\t.multiply( this.spaces[ targetColorSpace ].fromXYZ );\n\n\t\t},\n\n\t\t_getDrawingBufferColorSpace: function ( colorSpace ) {\n\n\t\t\treturn this.spaces[ colorSpace ].outputColorSpaceConfig.drawingBufferColorSpace;\n\n\t\t},\n\n\t\t_getUnpackColorSpace: function ( colorSpace = this.workingColorSpace ) {\n\n\t\t\treturn this.spaces[ colorSpace ].workingColorSpaceConfig.unpackColorSpace;\n\n\t\t},\n\n\t\t// Deprecated\n\n\t\tfromWorkingColorSpace: function ( color, targetColorSpace ) {\n\n\t\t\twarnOnce( 'THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace().' ); // @deprecated, r177\n\n\t\t\treturn ColorManagement.workingToColorSpace( color, targetColorSpace );\n\n\t\t},\n\n\t\ttoWorkingColorSpace: function ( color, sourceColorSpace ) {\n\n\t\t\twarnOnce( 'THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking().' ); // @deprecated, r177\n\n\t\t\treturn ColorManagement.colorSpaceToWorking( color, sourceColorSpace );\n\n\t\t},\n\n\t};\n\n\t/******************************************************************************\n\t * sRGB definitions\n\t */\n\n\tconst REC709_PRIMARIES = [ 0.640, 0.330, 0.300, 0.600, 0.150, 0.060 ];\n\tconst REC709_LUMINANCE_COEFFICIENTS = [ 0.2126, 0.7152, 0.0722 ];\n\tconst D65 = [ 0.3127, 0.3290 ];\n\n\tColorManagement.define( {\n\n\t\t[ LinearSRGBColorSpace ]: {\n\t\t\tprimaries: REC709_PRIMARIES,\n\t\t\twhitePoint: D65,\n\t\t\ttransfer: LinearTransfer,\n\t\t\ttoXYZ: LINEAR_REC709_TO_XYZ,\n\t\t\tfromXYZ: XYZ_TO_LINEAR_REC709,\n\t\t\tluminanceCoefficients: REC709_LUMINANCE_COEFFICIENTS,\n\t\t\tworkingColorSpaceConfig: { unpackColorSpace: SRGBColorSpace },\n\t\t\toutputColorSpaceConfig: { drawingBufferColorSpace: SRGBColorSpace }\n\t\t},\n\n\t\t[ SRGBColorSpace ]: {\n\t\t\tprimaries: REC709_PRIMARIES,\n\t\t\twhitePoint: D65,\n\t\t\ttransfer: SRGBTransfer,\n\t\t\ttoXYZ: LINEAR_REC709_TO_XYZ,\n\t\t\tfromXYZ: XYZ_TO_LINEAR_REC709,\n\t\t\tluminanceCoefficients: REC709_LUMINANCE_COEFFICIENTS,\n\t\t\toutputColorSpaceConfig: { drawingBufferColorSpace: SRGBColorSpace }\n\t\t},\n\n\t} );\n\n\treturn ColorManagement;\n\n}\n\nexport const ColorManagement = /*@__PURE__*/ createColorManagement();\n\nexport function SRGBToLinear( c ) {\n\n\treturn ( c < 0.04045 ) ? c * 0.0773993808 : Math.pow( c * 0.9478672986 + 0.0521327014, 2.4 );\n\n}\n\nexport function LinearToSRGB( c ) {\n\n\treturn ( c < 0.0031308 ) ? c * 12.92 : 1.055 * ( Math.pow( c, 0.41666 ) ) - 0.055;\n\n}\n","import type { Color } from \"three\";\nimport type { UIColor } from \"./UIColor\";\n\n/** Color configuration as Three.js Color, hex number, hex string, or UIColor */\nexport type UIColorConfig = Color | number | string | UIColor;\n\n/** Predefined color names */\nexport type UIColorName =\n | \"black\"\n | \"white\"\n | \"red\"\n | \"green\"\n | \"blue\"\n | \"yellow\"\n | \"cyan\"\n | \"magenta\"\n | \"gray\"\n | \"grey\"\n | \"silver\"\n | \"maroon\"\n | \"olive\"\n | \"lime\"\n | \"aqua\"\n | \"teal\"\n | \"navy\"\n | \"fuchsia\"\n | \"purple\"\n | \"orange\"\n | \"pink\"\n | \"brown\"\n | \"gold\"\n | \"violet\"\n | \"indigo\"\n | \"coral\"\n | \"salmon\"\n | \"khaki\"\n | \"plum\"\n | \"orchid\"\n | \"tan\"\n | \"beige\"\n | \"mint\"\n | \"lavender\"\n | \"crimson\"\n | \"azure\"\n | \"ivory\"\n | \"snow\";\n\nexport const COLORS: Record<string, number | undefined> = {\n black: 0x000000,\n white: 0xffffff,\n red: 0xff0000,\n green: 0x008000,\n blue: 0x0000ff,\n yellow: 0xffff00,\n cyan: 0x00ffff,\n magenta: 0xff00ff,\n\n gray: 0x808080,\n grey: 0x808080,\n silver: 0xc0c0c0,\n maroon: 0x800000,\n olive: 0x808000,\n lime: 0x00ff00,\n aqua: 0x00ffff,\n teal: 0x008080,\n navy: 0x000080,\n fuchsia: 0xff00ff,\n purple: 0x800080,\n\n orange: 0xffa500,\n pink: 0xffc0cb,\n brown: 0xa52a2a,\n gold: 0xffd700,\n violet: 0xee82ee,\n indigo: 0x4b0082,\n coral: 0xff7f50,\n salmon: 0xfa8072,\n khaki: 0xf0e68c,\n plum: 0xdda0dd,\n orchid: 0xda70d6,\n tan: 0xd2b48c,\n beige: 0xf5f5dc,\n mint: 0x98fb98,\n lavender: 0xe6e6fa,\n crimson: 0xdc143c,\n azure: 0xf0ffff,\n ivory: 0xfffff0,\n snow: 0xfffafa,\n};\n","import { Color, MathUtils, Vector4 } from \"three\";\nimport { LinearToSRGB, SRGBToLinear } from \"three/src/math/ColorManagement.js\";\nimport { assertValidNumber } from \"../asserts\";\nimport type { UIColorConfig, UIColorName } from \"./UIColor.Internal\";\nimport { COLORS } from \"./UIColor.Internal\";\n\n/** RGBA color with RGB, HSL, hex, and named color support */\nexport class UIColor {\n private rInternal = 1;\n private gInternal = 1;\n private bInternal = 1;\n private aInternal = 1;\n\n private hInternal = 0;\n private sInternal = 0;\n private lInternal = 1;\n\n private dirtyInternal = false;\n private rgbDirty = false;\n private hslDirty = false;\n\n constructor();\n /**\n * @param r - Red (0-1)\n * @param g - Green (0-1)\n * @param b - Blue (0-1)\n * @param a - Alpha (0-1)\n */\n // eslint-disable-next-line @typescript-eslint/unified-signatures -- Separate overloads make the different constructor patterns more clear\n constructor(r: number, g: number, b: number, a?: number);\n /**\n * @param colorName - Named color\n * @param a - Alpha (0-1)\n */\n // eslint-disable-next-line @typescript-eslint/unified-signatures -- Separate overloads make the different constructor patterns more clear\n constructor(colorName: UIColorName, a?: number);\n /**\n * @param threeColor - Three.js Color object\n * @param a - Alpha (0-1)\n */\n // eslint-disable-next-line @typescript-eslint/unified-signatures -- Separate overloads make the different constructor patterns more clear\n constructor(threeColor: Color, a?: number);\n /**\n * @param hexRGB - Hex RGB value (e.g., 0xff0000)\n * @param a - Alpha (0-1)\n */\n // eslint-disable-next-line @typescript-eslint/unified-signatures -- Separate overloads make the different constructor patterns more clear\n constructor(hexRGB: number, a?: number);\n /**\n * @param hexString - Hex string (e.g., \"#ffffff\" or \"#ffffffff\")\n */\n // eslint-disable-next-line @typescript-eslint/unified-signatures -- Separate overloads make the different constructor patterns more clear\n constructor(hexString?: string);\n /**\n * @param uiColor - UIColor object to copy from\n */\n // eslint-disable-next-line @typescript-eslint/unified-signatures -- Separate overloads make the different constructor patterns more clear\n constructor(uiColor?: UIColor);\n /**\n * @param uiColorConfig - UIColorConfig object\n */\n // eslint-disable-next-line @typescript-eslint/unified-signatures -- Separate overloads make the different constructor patterns more clear\n constructor(uiColorConfig?: UIColorConfig);\n constructor(...args: unknown[]) {\n if (args.length > 0) {\n (this.set as (...a: unknown[]) => this)(...args);\n }\n }\n\n /** Black (0x000000) */\n public static get black(): UIColor {\n return new UIColor(\"black\");\n }\n\n /** White (0xffffff) */\n public static get white(): UIColor {\n return new UIColor(\"white\");\n }\n\n /** Red (0xff0000) */\n public static get red(): UIColor {\n return new UIColor(\"red\");\n }\n\n /** Green (0x008000) */\n public static get green(): UIColor {\n return new UIColor(\"green\");\n }\n\n /** Blue (0x0000ff) */\n public static get blue(): UIColor {\n return new UIColor(\"blue\");\n }\n\n /** Yellow (0xffff00) */\n public static get yellow(): UIColor {\n return new UIColor(\"yellow\");\n }\n\n /** Cyan (0x00ffff) */\n public static get cyan(): UIColor {\n return new UIColor(\"cyan\");\n }\n\n /** Magenta (0xff00ff) */\n public static get magenta(): UIColor {\n return new UIColor(\"magenta\");\n }\n\n /** Gray (0x808080) */\n public static get gray(): UIColor {\n return new UIColor(\"gray\");\n }\n\n /** Grey (0x808080) */\n public static get grey(): UIColor {\n return new UIColor(\"grey\");\n }\n\n /** Silver (0xc0c0c0) */\n public static get silver(): UIColor {\n return new UIColor(\"silver\");\n }\n\n /** Maroon (0x800000) */\n public static get maroon(): UIColor {\n return new UIColor(\"maroon\");\n }\n\n /** Olive (0x808000) */\n public static get olive(): UIColor {\n return new UIColor(\"olive\");\n }\n\n /** Lime (0x00ff00) */\n public static get lime(): UIColor {\n return new UIColor(\"lime\");\n }\n\n /** Aqua (0x00ffff) */\n public static get aqua(): UIColor {\n return new UIColor(\"aqua\");\n }\n\n /** Teal (0x008080) */\n public static get teal(): UIColor {\n return new UIColor(\"teal\");\n }\n\n /** Navy (0x000080) */\n public static get navy(): UIColor {\n return new UIColor(\"navy\");\n }\n\n /** Fuchsia (0xff00ff) */\n public static get fuchsia(): UIColor {\n return new UIColor(\"fuchsia\");\n }\n\n /** Purple (0x800080) */\n public static get purple(): UIColor {\n return new UIColor(\"purple\");\n }\n\n /** Orange (0xffa500) */\n public static get orange(): UIColor {\n return new UIColor(\"orange\");\n }\n\n /** Pink (0xffc0cb) */\n public static get pink(): UIColor {\n return new UIColor(\"pink\");\n }\n\n /** Brown (0xa52a2a) */\n public static get brown(): UIColor {\n return new UIColor(\"brown\");\n }\n\n /** Gold (0xffd700) */\n public static get gold(): UIColor {\n return new UIColor(\"gold\");\n }\n\n /** Violet (0xee82ee) */\n public static get violet(): UIColor {\n return new UIColor(\"violet\");\n }\n\n /** Indigo (0x4b0082) */\n public static get indigo(): UIColor {\n return new UIColor(\"indigo\");\n }\n\n /** Coral (0xff7f50) */\n public static get coral(): UIColor {\n return new UIColor(\"coral\");\n }\n\n /** Salmon (0xfa8072) */\n public static get salmon(): UIColor {\n return new UIColor(\"salmon\");\n }\n\n /** Khaki (0xf0e68c) */\n public static get khaki(): UIColor {\n return new UIColor(\"khaki\");\n }\n\n /** Plum (0xdda0dd) */\n public static get plum(): UIColor {\n return new UIColor(\"plum\");\n }\n\n /** Orchid (0xda70d6) */\n public static get orchid(): UIColor {\n return new UIColor(\"orchid\");\n }\n\n /** Tan (0xd2b48c) */\n public static get tan(): UIColor {\n return new UIColor(\"tan\");\n }\n\n /** Beige (0xf5f5dc) */\n public static get beige(): UIColor {\n return new UIColor(\"beige\");\n }\n\n /** Mint (0x98fb98) */\n public static get mint(): UIColor {\n return new UIColor(\"mint\");\n }\n\n /** Lavender (0xe6e6fa) */\n public static get lavender(): UIColor {\n return new UIColor(\"lavender\");\n }\n\n /** Crimson (0xdc143c) */\n public static get crimson(): UIColor {\n return new UIColor(\"crimson\");\n }\n\n /** Azure (0xf0ffff) */\n public static get azure(): UIColor {\n return new UIColor(\"azure\");\n }\n\n /** Ivory (0xfffff0) */\n public static get ivory(): UIColor {\n return new UIColor(\"ivory\");\n }\n\n /** Snow (0xfffafa) */\n public static get snow(): UIColor {\n return new UIColor(\"snow\");\n }\n\n /** Red component (0 to 1) */\n public get r(): number {\n this.ensureRGBUpdatedFromHSL();\n return this.rInternal;\n }\n\n /** Green component (0 to 1) */\n public get g(): number {\n this.ensureRGBUpdatedFromHSL();\n return this.gInternal;\n }\n\n /** Blue component (0 to 1) */\n public get b(): number {\n this.ensureRGBUpdatedFromHSL();\n return this.bInternal;\n }\n\n /** Alpha component (0 to 1) */\n public get a(): number {\n return this.aInternal;\n }\n\n /** Hue component (0 to 360) */\n public get hue(): number {\n this.ensureHSLUpdatedFromRGB();\n return this.hInternal;\n }\n\n /** Saturation component (0 to 1) */\n public get saturation(): number {\n this.ensureHSLUpdatedFromRGB();\n return this.sInternal;\n }\n\n /** Lightness component (0 to 1) */\n public get lightness(): number {\n this.ensureHSLUpdatedFromRGB();\n return this.lInternal;\n }\n\n /** @internal */\n public get dirty(): boolean {\n return this.dirtyInternal;\n }\n\n /** Red component (0 to 1) */\n public set r(value: number) {\n assertValidNumber(value, \"UIColor.r\");\n value = MathUtils.clamp(value, 0, 1);\n this.ensureRGBUpdatedFromHSL();\n if (value !== this.rInternal) {\n this.rInternal = value;\n this.hslDirty = true;\n this.dirtyInternal = true;\n }\n }\n\n /** Green component (0 to 1) */\n public set g(value: number) {\n assertValidNumber(value, \"UIColor.g\");\n value = MathUtils.clamp(value, 0, 1);\n this.ensureRGBUpdatedFromHSL();\n if (value !== this.gInternal) {\n this.gInternal = value;\n this.hslDirty = true;\n this.dirtyInternal = true;\n }\n }\n\n /** Blue component (0 to 1) */\n public set b(value: number) {\n assertValidNumber(value, \"UIColor.b\");\n value = MathUtils.clamp(value, 0, 1);\n this.ensureRGBUpdatedFromHSL();\n if (value !== this.bInternal) {\n this.bInternal = value;\n this.hslDirty = true;\n this.dirtyInternal = true;\n }\n }\n\n /** Alpha component (0 to 1) */\n public set a(value: number) {\n assertValidNumber(value, \"UIColor.a\");\n value = MathUtils.clamp(value, 0, 1);\n if (value !== this.aInternal) {\n this.aInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n /** Hue component (0 to 360) */\n public set hue(value: number) {\n assertValidNumber(value, \"UIColor.hue\");\n value = MathUtils.clamp(value, 0, 360);\n this.ensureHSLUpdatedFromRGB();\n if (value !== this.hInternal) {\n this.hInternal = value;\n this.rgbDirty = true;\n this.dirtyInternal = true;\n }\n }\n\n /** Saturation component (0 to 1) */\n public set saturation(value: number) {\n assertValidNumber(value, \"UIColor.saturation\");\n value = MathUtils.clamp(value, 0, 1);\n this.ensureHSLUpdatedFromRGB();\n if (value !== this.sInternal) {\n this.sInternal = value;\n this.rgbDirty = true;\n this.dirtyInternal = true;\n }\n }\n\n /** Lightness component (0 to 1) */\n public set lightness(value: number) {\n assertValidNumber(value, \"UIColor.lightness\");\n value = MathUtils.clamp(value, 0, 1);\n this.ensureHSLUpdatedFromRGB();\n if (value !== this.lInternal) {\n this.lInternal = value;\n this.rgbDirty = true;\n this.dirtyInternal = true;\n }\n }\n\n /** @internal */\n public setDirtyFalse(): void {\n this.dirtyInternal = false;\n }\n\n /** Sets to white (default) */\n public set(): this;\n /**\n * @param r - Red (0-1)\n * @param g - Green (0-1)\n * @param b - Blue (0-1)\n * @param a - Alpha (0-1)\n */\n // eslint-disable-next-line @typescript-eslint/unified-signatures -- Separate overloads make the different constructor patterns more clear\n public set(r: number, g: number, b: number, a?: number): this;\n /**\n * @param colorName - Named color\n * @param a - Alpha (0-1)\n */\n // eslint-disable-next-line @typescript-eslint/unified-signatures -- Separate overloads make the different constructor patterns more clear\n public set(colorName: UIColorName, a?: number): this;\n /**\n * @param threeColor - Three.js Color object\n * @param a - Alpha (0-1)\n */\n // eslint-disable-next-line @typescript-eslint/unified-signatures -- Separate overloads make the different constructor patterns more clear\n public set(threeColor: Color, a?: number): this;\n /**\n * @param hexRGB - Hex RGB value (e.g., 0xff0000)\n * @param a - Alpha (0-1)\n */\n // eslint-disable-next-line @typescript-eslint/unified-signatures -- Separate overloads make the different constructor patterns more clear\n public set(hexRGB: number, a?: number): this;\n /**\n * @param hexString - Hex string (e.g., \"#ffffff\" or \"#ffffffff\")\n */\n // eslint-disable-next-line @typescript-eslint/unified-signatures -- Separate overloads make the different constructor patterns more clear\n public set(hexString: string): this;\n /**\n * @param uiColor - UIColor object to copy from\n */\n // eslint-disable-next-line @typescript-eslint/unified-signatures -- Separate overloads make the different constructor patterns more clear\n public set(uiColor: UIColor): this;\n /**\n * @param uiColorConfig - UIColorConfig object\n */\n // eslint-disable-next-line @typescript-eslint/unified-signatures -- Separate overloads make the different constructor patterns more clear\n public set(uiColorConfig?: UIColorConfig): this;\n public set(...args: unknown[]): this {\n if (args.length === 0 || args[0] === undefined) {\n return this.setRGBA(1, 1, 1, 1);\n }\n\n if (args.length >= 3 && typeof args[0] === \"number\") {\n const [r, g, b, a = 1] = args as number[];\n return this.setRGBA(r, g, b, a);\n }\n\n const [firstArgument, a = 1] = args;\n\n if (typeof firstArgument === \"string\") {\n return firstArgument.startsWith(\"#\")\n ? this.setHexString(firstArgument)\n : this.setColorName(firstArgument as UIColorName, a as number);\n }\n\n if (firstArgument instanceof UIColor) {\n return this.copy(firstArgument);\n }\n\n if (firstArgument instanceof Color) {\n return this.setThreeColor(firstArgument, a as number);\n }\n\n if (typeof firstArgument === \"number\") {\n return this.setHexRGB(firstArgument, a as number);\n }\n\n throw new Error(\"UIColor.set: cannot create color from provided arguments\");\n }\n\n /** Sets RGBA components directly */\n public setRGBA(\n r: number,\n g: number,\n b: number,\n a: number = this.aInternal,\n ): this {\n assertValidNumber(r, \"UIColor.setRGBA.r\");\n assertValidNumber(g, \"UIColor.setRGBA.g\");\n assertValidNumber(b, \"UIColor.setRGBA.b\");\n assertValidNumber(a, \"UIColor.setRGBA.a\");\n r = MathUtils.clamp(r, 0, 1);\n g = MathUtils.clamp(g, 0, 1);\n b = MathUtils.clamp(b, 0, 1);\n a = MathUtils.clamp(a, 0, 1);\n this.ensureRGBUpdatedFromHSL();\n if (\n r !== this.rInternal ||\n g !== this.gInternal ||\n b !== this.bInternal ||\n a !== this.aInternal\n ) {\n this.rInternal = r;\n this.gInternal = g;\n this.bInternal = b;\n this.aInternal = a;\n this.hslDirty = true;\n this.dirtyInternal = true;\n }\n return this;\n }\n\n /** Returns RGBA as 32-bit hex (RRGGBBAA) */\n public getHexRGBA(): number {\n this.ensureRGBUpdatedFromHSL();\n return (\n (Math.round(this.rInternal * 255) << 24) |\n (Math.round(this.gInternal * 255) << 16) |\n (Math.round(this.bInternal * 255) << 8) |\n Math.round(this.aInternal * 255)\n );\n }\n\n /** Returns RGB as 24-bit hex (RRGGBB) */\n public getHexRGB(): number {\n this.ensureRGBUpdatedFromHSL();\n return (\n (Math.round(this.rInternal * 255) << 16) |\n (Math.round(this.gInternal * 255) << 8) |\n Math.round(this.bInternal * 255)\n );\n }\n\n /** Returns RGB as hex string (\"#ffffff\") */\n public getHexStringRGB(): string {\n const hex = this.getHexRGB();\n return `#${hex.toString(16).padStart(6, \"0\")}`;\n }\n\n /** Returns RGBA as hex string (\"#ffffffff\") */\n public getHexStringRGBA(): string {\n const hex = this.getHexRGBA();\n return `#${hex.toString(16).padStart(8, \"0\")}`;\n }\n\n /** Sets from 32-bit hex RGBA (RRGGBBAA) */\n public setHexRGBA(hex: number): this {\n assertValidNumber(hex, \"UIColor.setHexRGBA.hex\");\n this.ensureRGBUpdatedFromHSL();\n const r = ((hex >> 16) & 0xff) / 255;\n const g = ((hex >> 8) & 0xff) / 255;\n const b = (hex & 0xff) / 255;\n const a = ((hex >> 24) & 0xff) / 255;\n if (\n r !== this.rInternal ||\n g !== this.gInternal ||\n b !== this.bInternal ||\n a !== this.aInternal\n ) {\n this.rInternal = r;\n this.gInternal = g;\n this.bInternal = b;\n this.aInternal = a;\n this.hslDirty = true;\n this.dirtyInternal = true;\n }\n return this;\n }\n\n /** Sets from 24-bit hex RGB (RRGGBB) */\n public setHexRGB(hex: number, a = this.aInternal): this {\n assertValidNumber(hex, \"UIColor.setHexRGB.hex\");\n assertValidNumber(a, \"UIColor.setHexRGB.a\");\n a = MathUtils.clamp(a, 0, 1);\n this.ensureRGBUpdatedFromHSL();\n const r = ((hex >> 16) & 0xff) / 255;\n const g = ((hex >> 8) & 0xff) / 255;\n const b = (hex & 0xff) / 255;\n if (\n r !== this.rInternal ||\n g !== this.gInternal ||\n b !== this.bInternal ||\n a !== this.aInternal\n ) {\n this.rInternal = r;\n this.gInternal = g;\n this.bInternal = b;\n this.aInternal = a;\n this.hslDirty = true;\n this.dirtyInternal = true;\n }\n return this;\n }\n\n /**\n * Sets from hex string.\n *\n * @param hexString - Format: \"#ffffff\" or \"#ffffffff\"\n * @throws If format invalid\n */\n public setHexString(hexString: string): this {\n if (!hexString.startsWith(\"#\")) {\n throw new Error(\n `UIColor.setHexString.hexString: invalid hex string format. expected format: \"#ffffff\" or \"#ffffffff\"`,\n );\n }\n\n const hex = hexString.slice(1);\n\n if (hex.length === 6) {\n const hexNumber = parseInt(hex, 16);\n if (isNaN(hexNumber)) {\n throw new Error(\n `UIColor.setHexString.hexString: invalid hex string format. expected format: \"#ffffff\" or \"#ffffffff\"`,\n );\n }\n return this.setHexRGB(hexNumber);\n } else if (hex.length === 8) {\n const hexNumber = parseInt(hex, 16);\n if (isNaN(hexNumber)) {\n throw new Error(\n `UIColor.setHexString.hexString: invalid hex string format. expected format: \"#ffffff\" or \"#ffffffff\"`,\n );\n }\n return this.setHexRGBA(hexNumber);\n } else {\n throw new Error(\n `UIColor.setHexString.hexString: invalid hex string format. expected format: \"#ffffff\" or \"#ffffffff\"`,\n );\n }\n }\n\n /** Sets from HSL values */\n public setHSL(h: number, s: number, l: number, a = this.aInternal): this {\n assertValidNumber(h, \"UIColor.setHSL.h\");\n assertValidNumber(s, \"UIColor.setHSL.s\");\n assertValidNumber(l, \"UIColor.setHSL.l\");\n assertValidNumber(a, \"UIColor.setHSL.a\");\n h = MathUtils.clamp(h, 0, 360);\n s = MathUtils.clamp(s, 0, 1);\n l = MathUtils.clamp(l, 0, 1);\n a = MathUtils.clamp(a, 0, 1);\n this.ensureHSLUpdatedFromRGB();\n if (\n h !== this.hInternal ||\n s !== this.sInternal ||\n l !== this.lInternal ||\n a !== this.aInternal\n ) {\n this.hInternal = h;\n this.sInternal = s;\n this.lInternal = l;\n this.aInternal = a;\n this.rgbDirty = true;\n this.dirtyInternal = true;\n }\n return this;\n }\n\n /**\n * Sets from predefined name.\n *\n * @throws If color name unknown\n */\n public setColorName(colorName: UIColorName, a = this.aInternal): this {\n assertValidNumber(a, \"UIColor.setColorName.a\");\n a = MathUtils.clamp(a, 0, 1);\n const normalizedName = colorName.toLowerCase().trim();\n const hex = COLORS[normalizedName];\n\n if (hex === undefined) {\n throw new Error(`UIColor.setColorName.colorName: unknown color name`);\n }\n\n return this.setHexRGB(hex, a);\n }\n\n /** Sets from linear (GLSL) color space */\n public setGLSLColor(\n r: number,\n g: number,\n b: number,\n a = this.aInternal,\n ): this {\n assertValidNumber(r, \"UIColor.setGLSLColor.r\");\n assertValidNumber(g, \"UIColor.setGLSLColor.g\");\n assertValidNumber(b, \"UIColor.setGLSLColor.b\");\n assertValidNumber(a, \"UIColor.setGLSLColor.a\");\n a = MathUtils.clamp(a, 0, 1);\n this.ensureRGBUpdatedFromHSL();\n\n const sRGBR = LinearToSRGB(r);\n const sRGBG = LinearToSRGB(g);\n const sRGBB = LinearToSRGB(b);\n\n if (\n sRGBR !== this.rInternal ||\n sRGBG !== this.gInternal ||\n sRGBB !== this.bInternal ||\n a !== this.aInternal\n ) {\n this.rInternal = sRGBR;\n this.gInternal = sRGBG;\n this.bInternal = sRGBB;\n this.aInternal = a;\n this.hslDirty = true;\n this.dirtyInternal = true;\n }\n\n return this;\n }\n\n /** Sets from Three.js Color */\n public setThreeColor(threeColor: Color, a = this.aInternal): this {\n assertValidNumber(a, \"UIColor.setThreeColor.a\");\n a = MathUtils.clamp(a, 0, 1);\n this.ensureRGBUpdatedFromHSL();\n if (\n threeColor.r !== this.rInternal ||\n threeColor.g !== this.gInternal ||\n threeColor.b !== this.bInternal ||\n a !== this.aInternal\n ) {\n this.rInternal = threeColor.r;\n this.gInternal = threeColor.g;\n this.bInternal = threeColor.b;\n this.aInternal = a;\n this.hslDirty = true;\n this.dirtyInternal = true;\n }\n return this;\n }\n\n /** Returns CSS color string (\"rgba(255, 0, 0, 1)\") */\n public toCSSColor(): string {\n this.ensureRGBUpdatedFromHSL();\n const r = Math.round(this.rInternal * 255);\n const g = Math.round(this.gInternal * 255);\n const b = Math.round(this.bInternal * 255);\n return `rgba(${r}, ${g}, ${b}, ${this.aInternal})`;\n }\n\n /** Converts to linear (GLSL) color space */\n public toGLSLColor(result: Vector4 = new Vector4()): Vector4 {\n this.ensureRGBUpdatedFromHSL();\n\n result.x = SRGBToLinear(this.rInternal);\n result.y = SRGBToLinear(this.gInternal);\n result.z = SRGBToLinear(this.bInternal);\n result.w = this.aInternal;\n\n return result;\n }\n\n /** Converts to Three.js Color (without alpha) */\n public toThreeColor(result: Color = new Color()): Color {\n this.ensureRGBUpdatedFromHSL();\n\n result.r = this.rInternal;\n result.g = this.gInternal;\n result.b = this.bInternal;\n\n return result;\n }\n\n /** Copies from another color */\n public copy(color: UIColor | Color): this {\n if (color instanceof UIColor) {\n this.ensureRGBUpdatedFromHSL();\n color.ensureRGBUpdatedFromHSL();\n\n if (\n this.rInternal !== color.rInternal ||\n this.gInternal !== color.gInternal ||\n this.bInternal !== color.bInternal ||\n this.aInternal !== color.aInternal\n ) {\n this.rInternal = color.rInternal;\n this.gInternal = color.gInternal;\n this.bInternal = color.bInternal;\n this.aInternal = color.aInternal;\n this.hslDirty = true;\n this.dirtyInternal = true;\n }\n } else {\n this.ensureRGBUpdatedFromHSL();\n if (\n this.rInternal !== color.r ||\n this.gInternal !== color.g ||\n this.bInternal !== color.b ||\n this.aInternal !== 1\n ) {\n this.rInternal = color.r;\n this.gInternal = color.g;\n this.bInternal = color.b;\n this.aInternal = 1;\n this.hslDirty = true;\n this.dirtyInternal = true;\n }\n }\n\n return this;\n }\n\n /** Returns copy of this color */\n public clone(): UIColor {\n this.ensureRGBUpdatedFromHSL();\n return new UIColor(\n this.rInternal,\n this.gInternal,\n this.bInternal,\n this.aInternal,\n );\n }\n\n /** @internal */\n private ensureRGBUpdatedFromHSL(): void {\n if (this.rgbDirty) {\n const { hInternal: h, sInternal: s, lInternal: l } = this;\n const c = (1 - Math.abs(2 * l - 1)) * s;\n const hp = h / 60;\n const x = c * (1 - Math.abs((hp % 2) - 1));\n let [r, g, b] =\n hp < 1\n ? [c, x, 0]\n : hp < 2\n ? [x, c, 0]\n : hp < 3\n ? [0, c, x]\n : hp < 4\n ? [0, x, c]\n : hp < 5\n ? [x, 0, c]\n : [c, 0, x];\n\n const m = l - c / 2;\n this.rInternal = r + m;\n this.gInternal = g + m;\n this.bInternal = b + m;\n this.rgbDirty = false;\n }\n }\n\n private ensureHSLUpdatedFromRGB(): void {\n if (this.hslDirty) {\n const { rInternal: r, gInternal: g, bInternal: b } = this;\n const max = Math.max(r, g, b);\n const min = Math.min(r, g, b);\n const d = max - min;\n const l = (max + min) / 2;\n\n let h = 0;\n if (d !== 0) {\n if (max === r) {\n h = (g - b) / d + (g < b ? 6 : 0);\n } else if (max === g) {\n h = (b - r) / d + 2;\n } else {\n h = (r - g) / d + 4;\n }\n h *= 60;\n }\n\n const s = d === 0 ? 0 : d / (1 - Math.abs(2 * l - 1));\n this.hInternal = h;\n this.sInternal = s;\n this.lInternal = l;\n this.hslDirty = false;\n }\n }\n}\n","import type { IUniform, ShaderMaterial } from \"three\";\nimport { Matrix3, Matrix4, Texture, Vector2, Vector3, Vector4 } from \"three\";\nimport type { UITransparencyMode } from \"../UITransparencyMode\";\nimport { UIColor } from \"../color/UIColor\";\n\nexport type UIProperty =\n | Texture\n | UIColor\n | Vector2\n | Vector3\n | Vector4\n | Matrix3\n | Matrix4\n | number;\n\nexport type UIPropertyName =\n | \"Texture\"\n | \"UIColor\"\n | \"Vector2\"\n | \"Vector3\"\n | \"Vector4\"\n | \"Matrix3\"\n | \"Matrix4\"\n | \"number\";\n\nexport type UIPropertyConstructor =\n | typeof Texture\n | typeof UIColor\n | typeof Vector2\n | typeof Vector3\n | typeof Vector4\n | typeof Matrix3\n | typeof Matrix4\n | NumberConstructor;\n\nexport type UIPropertyCopyTo =\n | UIColor\n | Vector2\n | Vector3\n | Vector4\n | Matrix3\n | Matrix4;\n\nexport type UIPropertyCopyFrom = UIColor &\n Vector2 &\n Vector3 &\n Vector4 &\n Matrix3 &\n Matrix4;\n\nexport interface GLTypeInfo {\n glslTypeName: string;\n bufferSize: number;\n instantiable: boolean;\n}\n\nexport interface GLProperty {\n value: UIProperty;\n glslTypeInfo: GLTypeInfo;\n}\n\nexport interface PlaneData {\n source: string;\n properties: Record<string, GLProperty>;\n transform: Matrix4;\n visibility: boolean;\n transparency: UITransparencyMode;\n}\n\nexport const DEFAULT_ALPHA_TEST = 0.5;\n\nconst GLSL_TYPE_INFO_FLOAT: GLTypeInfo = Object.freeze({\n glslTypeName: \"float\",\n bufferSize: 1,\n instantiable: true,\n} as const);\n\nconst GLSL_TYPE_INFO_SAMPLER2D: GLTypeInfo = Object.freeze({\n glslTypeName: \"sampler2D\",\n bufferSize: -1,\n instantiable: false,\n} as const);\n\nconst GLSL_TYPE_INFO_VEC2: GLTypeInfo = Object.freeze({\n glslTypeName: \"vec2\",\n bufferSize: 2,\n instantiable: true,\n} as const);\n\nconst GLSL_TYPE_INFO_VEC3: GLTypeInfo = Object.freeze({\n glslTypeName: \"vec3\",\n bufferSize: 3,\n instantiable: true,\n} as const);\n\nconst GLSL_TYPE_INFO_VEC4: GLTypeInfo = Object.freeze({\n glslTypeName: \"vec4\",\n bufferSize: 4,\n instantiable: true,\n} as const);\n\nconst GLSL_TYPE_INFO_MAT3: GLTypeInfo = Object.freeze({\n glslTypeName: \"mat3\",\n bufferSize: 9,\n instantiable: true,\n} as const);\n\nconst GLSL_TYPE_INFO_MAT4: GLTypeInfo = Object.freeze({\n glslTypeName: \"mat4\",\n bufferSize: 16,\n instantiable: true,\n} as const);\n\nexport function resolveGLSLTypeInfo(\n value: UIProperty | UIPropertyName | UIPropertyConstructor,\n): GLTypeInfo {\n if (typeof value === \"string\") {\n switch (value) {\n case \"number\":\n return GLSL_TYPE_INFO_FLOAT;\n case \"Texture\":\n return GLSL_TYPE_INFO_SAMPLER2D;\n case \"UIColor\":\n return GLSL_TYPE_INFO_VEC4;\n case \"Vector2\":\n return GLSL_TYPE_INFO_VEC2;\n case \"Vector3\":\n return GLSL_TYPE_INFO_VEC3;\n case \"Vector4\":\n return GLSL_TYPE_INFO_VEC4;\n case \"Matrix3\":\n return GLSL_TYPE_INFO_MAT3;\n case \"Matrix4\":\n return GLSL_TYPE_INFO_MAT4;\n default:\n throw new Error(\n `resolveGLSLTypeInfo.value: unsupported property type name`,\n );\n }\n }\n if (typeof value === \"function\") {\n if (value === Number) {\n return GLSL_TYPE_INFO_FLOAT;\n }\n if (value === Texture) {\n return GLSL_TYPE_INFO_SAMPLER2D;\n }\n if (value === UIColor) {\n return GLSL_TYPE_INFO_VEC4;\n }\n if (value === Vector2) {\n return GLSL_TYPE_INFO_VEC2;\n }\n if (value === Vector3) {\n return GLSL_TYPE_INFO_VEC3;\n }\n if (value === Vector4) {\n return GLSL_TYPE_INFO_VEC4;\n }\n if (value === Matrix3) {\n return GLSL_TYPE_INFO_MAT3;\n }\n if (value === Matrix4) {\n return GLSL_TYPE_INFO_MAT4;\n }\n throw new Error(\n `resolveGLSLTypeInfo.value: unsupported property type constructor`,\n );\n }\n if (typeof value === \"number\") {\n return GLSL_TYPE_INFO_FLOAT;\n }\n if (value instanceof Texture) {\n return GLSL_TYPE_INFO_SAMPLER2D;\n }\n if (value instanceof UIColor) {\n return GLSL_TYPE_INFO_VEC4;\n }\n if (value instanceof Vector2) {\n return GLSL_TYPE_INFO_VEC2;\n }\n if (value instanceof Vector3) {\n return GLSL_TYPE_INFO_VEC3;\n }\n if (value instanceof Vector4) {\n return GLSL_TYPE_INFO_VEC4;\n }\n if (value instanceof Matrix3) {\n return GLSL_TYPE_INFO_MAT3;\n }\n if (value instanceof Matrix4) {\n return GLSL_TYPE_INFO_MAT4;\n }\n throw new Error(`resolveGLSLTypeInfo.value: unsupported property type`);\n}\n\nexport function resolvePropertyUniform(\n name: string,\n material: ShaderMaterial,\n): IUniform<UIProperty> {\n const uniform = material.uniforms[`p_${name}`] as\n | IUniform<UIProperty>\n | undefined;\n if (uniform === undefined) {\n throw new Error(`resolvePropertyUniform.name: unknown uniform`);\n }\n return uniform;\n}\n\nexport function arePropertiesPartiallyCompatible(\n full: Readonly<Record<string, Readonly<GLProperty>>>,\n partial: Readonly<Record<string, Readonly<GLProperty>>>,\n): boolean {\n for (const key in partial) {\n if (!(key in full)) {\n return false;\n }\n\n const infoFull = full[key].glslTypeInfo;\n const infoPartial = partial[key].glslTypeInfo;\n\n if (infoFull.glslTypeName !== infoPartial.glslTypeName) {\n return false;\n }\n\n // Non-instantiable (textures) must match by reference\n if (!infoFull.instantiable && full[key] !== partial[key]) {\n return false;\n }\n }\n\n return true;\n}\n\nexport function convertUIPropertiesToGLProperties(\n uiProperties: Record<string, UIProperty>,\n): Record<string, GLProperty> {\n const glProperties: Record<string, GLProperty> = {};\n\n for (const name in uiProperties) {\n const value = uiProperties[name];\n glProperties[name] = { value, glslTypeInfo: resolveGLSLTypeInfo(value) };\n }\n\n return glProperties;\n}\n\nexport function cloneProperty<T extends UIProperty>(property: T): T {\n if (typeof property === \"number\" || property instanceof Texture) {\n return property;\n }\n\n return property.clone() as T;\n}\n\nexport function cloneProperties(\n properties: Record<string, UIProperty>,\n): Record<string, UIProperty> {\n const result: Record<string, UIProperty> = {};\n for (const name in properties) {\n result[name] = cloneProperty(properties[name]);\n }\n return result;\n}\n\nexport function buildGenericPlaneFragmentShader(\n uniformDeclarations: string[],\n varyingDeclarations: string[],\n source: string,\n): string {\n return `\n // Defines\n #define PI 3.14159265359\n\n // Uniforms\n ${uniformDeclarations.join(\"\\n\")}\n\n // Builtin varyings\n varying vec3 p_position;\n varying vec2 p_uv;\n\n // User varyings\n ${varyingDeclarations.join(\"\\n\")}\n\n #include <alphahash_pars_fragment>\n\n // Source must define vec4 draw() function\n ${source}\n\n void main() {\n vec4 diffuseColor = draw();\n\n #ifdef USE_ALPHATEST\n if (diffuseColor.a < ${DEFAULT_ALPHA_TEST.toFixed(2)}) {\n discard;\n }\n #endif\n\n #ifdef USE_ALPHAHASH\n if (diffuseColor.a < getAlphaHashThreshold(p_position)) {\n discard;\n }\n #endif\n\n gl_FragColor = linearToOutputTexel(diffuseColor);\n }\n `;\n}\n","/** Transparency rendering modes */\nexport enum UITransparencyMode {\n /** Binary transparency. Best performance. */\n CLIP = 0,\n /** Dithered transparency. Good performance. */\n HASH = 1,\n /** Alpha blending. Best quality, requires depth sorting. */\n BLEND = 2,\n}\n","import {\n InstancedBufferAttribute,\n InstancedBufferGeometry,\n Matrix3,\n Matrix4,\n PlaneGeometry,\n ShaderMaterial,\n Vector2,\n Vector3,\n Vector4,\n} from \"three\";\nimport { UIColor } from \"../../color/UIColor\";\nimport { UITransparencyMode } from \"../../UITransparencyMode\";\nimport type { GLProperty, UIProperty } from \"../shared\";\nimport {\n buildGenericPlaneFragmentShader,\n DEFAULT_ALPHA_TEST,\n resolveGLSLTypeInfo,\n} from \"../shared\";\n\nexport const INSTANCED_PLANE_GEOMETRY = ((): InstancedBufferGeometry => {\n const planeGeometry = new PlaneGeometry(1, 1);\n planeGeometry.translate(0.5, 0.5, 0);\n const geometry = new InstancedBufferGeometry();\n geometry.index = planeGeometry.index;\n geometry.setAttribute(\"position\", planeGeometry.attributes[\"position\"]);\n geometry.setAttribute(\"uv\", planeGeometry.attributes[\"uv\"]);\n planeGeometry.dispose();\n return geometry;\n})();\n\nexport const CAPACITY_STEP = 4;\n\nconst TEMP_COLOR_VECTOR = new Vector4();\nconst IDENTITY_MATRIX_ELEMENTS = [\n 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1,\n];\n\nexport function writePropertyToArray(\n value: UIProperty,\n array: Float32Array,\n offset: number,\n): void {\n if (value instanceof UIColor) {\n value.toGLSLColor(TEMP_COLOR_VECTOR);\n array[offset] = TEMP_COLOR_VECTOR.x;\n array[offset + 1] = TEMP_COLOR_VECTOR.y;\n array[offset + 2] = TEMP_COLOR_VECTOR.z;\n array[offset + 3] = TEMP_COLOR_VECTOR.w;\n } else if (value instanceof Vector2) {\n array[offset] = value.x;\n array[offset + 1] = value.y;\n } else if (value instanceof Vector3) {\n array[offset] = value.x;\n array[offset + 1] = value.y;\n array[offset + 2] = value.z;\n } else if (value instanceof Vector4) {\n array[offset] = value.x;\n array[offset + 1] = value.y;\n array[offset + 2] = value.z;\n array[offset + 3] = value.w;\n } else if (value instanceof Matrix3 || value instanceof Matrix4) {\n const elements = value.elements;\n for (let j = 0; j < elements.length; j++) {\n array[offset + j] = elements[j];\n }\n } else if (typeof value === \"number\") {\n array[offset] = value;\n }\n}\n\nexport function writeInstanceDefaults(\n visibilityArray: Float32Array,\n transformArray: Float32Array,\n index: number,\n): void {\n visibilityArray[index] = 1;\n\n const transformOffset = index * 16;\n for (let j = 0; j < 16; j++) {\n transformArray[transformOffset + j] = IDENTITY_MATRIX_ELEMENTS[j];\n }\n}\n\nexport function buildEmptyInstancedBufferAttribute(\n value: UIProperty,\n capacity: number,\n): InstancedBufferAttribute {\n const info = resolveGLSLTypeInfo(value);\n if (!info.instantiable) {\n throw new Error(\n `buildEmptyInstancedBufferAttribute.value: cannot create instanced attribute for non-instantiable type`,\n );\n }\n return new InstancedBufferAttribute(\n new Float32Array(capacity * info.bufferSize),\n info.bufferSize,\n );\n}\n\nexport function buildMaterial(\n source: string,\n uniformProperties: Record<string, GLProperty>,\n varyingProperties: Record<string, GLProperty>,\n transparency: UITransparencyMode,\n): ShaderMaterial {\n const uniforms: Record<string, { value: unknown }> = {};\n\n const uniformDeclarations: string[] = [];\n const attributeDeclarations: string[] = [];\n const varyingDeclarations: string[] = [];\n const vertexAssignments: string[] = [];\n\n for (const name in uniformProperties) {\n const { value, glslTypeInfo } = uniformProperties[name];\n uniforms[`p_${name}`] = {\n value: value instanceof UIColor ? value.toGLSLColor() : value,\n };\n uniformDeclarations.push(`uniform ${glslTypeInfo.glslTypeName} p_${name};`);\n }\n\n for (const name in varyingProperties) {\n const { glslTypeInfo } = varyingProperties[name];\n attributeDeclarations.push(\n `attribute ${glslTypeInfo.glslTypeName} a_${name};`,\n );\n varyingDeclarations.push(`varying ${glslTypeInfo.glslTypeName} p_${name};`);\n vertexAssignments.push(`p_${name} = a_${name};`);\n }\n\n const vertexShader = `\n // User attributes\n ${attributeDeclarations.join(\"\\n\")}\n\n // Uniforms\n ${uniformDeclarations.join(\"\\n\")}\n\n // Builtin varyings\n varying vec3 p_position;\n varying vec2 p_uv;\n\n // User varyings\n ${varyingDeclarations.join(\"\\n\")}\n\n void main() {\n if (a_instanceVisibility < 0.5) {\n gl_Position = vec4(2.0, 2.0, 2.0, 1.0);\n return;\n }\n\n ${vertexAssignments.join(\"\\n\")}\n\n p_position = position;\n p_uv = uv;\n\n gl_Position = projectionMatrix * a_instanceTransform * vec4(position, 1.0);\n }\n `;\n\n const fragmentShader = buildGenericPlaneFragmentShader(\n uniformDeclarations,\n varyingDeclarations,\n source,\n );\n\n return new ShaderMaterial({\n uniforms,\n vertexShader,\n fragmentShader,\n transparent: transparency === UITransparencyMode.BLEND,\n alphaTest:\n transparency === UITransparencyMode.CLIP ? DEFAULT_ALPHA_TEST : 0.0,\n alphaHash: transparency === UITransparencyMode.HASH,\n depthWrite: transparency !== UITransparencyMode.BLEND,\n depthTest: true,\n });\n}\n\nexport function reconstructValue(\n referenceValue: UIProperty,\n array: Float32Array,\n offset: number,\n): UIProperty {\n if (typeof referenceValue === \"number\") {\n return array[offset];\n }\n if (referenceValue instanceof Vector2) {\n return new Vector2(array[offset], array[offset + 1]);\n }\n if (referenceValue instanceof Vector3) {\n return new Vector3(array[offset], array[offset + 1], array[offset + 2]);\n }\n if (referenceValue instanceof Vector4) {\n return new Vector4(\n array[offset],\n array[offset + 1],\n array[offset + 2],\n array[offset + 3],\n );\n }\n if (referenceValue instanceof UIColor) {\n return new UIColor().setGLSLColor(\n array[offset],\n array[offset + 1],\n array[offset + 2],\n array[offset + 3],\n );\n }\n if (referenceValue instanceof Matrix3) {\n const matrix = new Matrix3();\n matrix.fromArray(array, offset);\n return matrix;\n }\n if (referenceValue instanceof Matrix4) {\n const matrix = new Matrix4();\n matrix.fromArray(array, offset);\n return matrix;\n }\n throw new Error(\n `reconstructValue.referenceValue: cannot reconstruct value for type`,\n );\n}\n","import type { InstancedBufferGeometry, ShaderMaterial } from \"three\";\nimport { InstancedBufferAttribute, Matrix4, Mesh } from \"three\";\nimport { UITransparencyMode } from \"../../UITransparencyMode\";\nimport type { GLProperty, PlaneData } from \"../shared\";\nimport {\n arePropertiesPartiallyCompatible,\n resolveGLSLTypeInfo,\n resolvePropertyUniform,\n} from \"../shared\";\nimport {\n buildEmptyInstancedBufferAttribute,\n buildMaterial,\n CAPACITY_STEP,\n INSTANCED_PLANE_GEOMETRY,\n reconstructValue,\n writeInstanceDefaults,\n writePropertyToArray,\n} from \"./UIGenericInstancedPlane.Internal\";\n\n/**\n * Instanced shader plane mesh for batched rendering.\n *\n * Copies property values into internal buffers. No external references\n * are retained after method calls return.\n *\n * @internal\n */\nexport class UIGenericInstancedPlane extends Mesh {\n private readonly instancedGeometry: InstancedBufferGeometry;\n private readonly shaderMaterial: ShaderMaterial;\n\n private readonly handlerToIndex = new Map<number, number>();\n private readonly propertyBuffers = new Map<\n string,\n InstancedBufferAttribute\n >();\n\n private readonly uniformProperties: Record<string, GLProperty>;\n private readonly varyingProperties: Record<string, GLProperty>;\n\n private lastHandler = 0;\n private capacity: number;\n\n constructor(\n public readonly source: string,\n properties: Record<string, GLProperty>,\n public readonly transparency: UITransparencyMode,\n initialCapacity: number = CAPACITY_STEP,\n ) {\n const uniformProperties: Record<string, GLProperty> = {};\n const varyingProperties: Record<string, GLProperty> = {\n instanceVisibility: {\n value: 1,\n glslTypeInfo: resolveGLSLTypeInfo(\"number\"),\n },\n instanceTransform: {\n value: new Matrix4().identity(),\n glslTypeInfo: resolveGLSLTypeInfo(\"Matrix4\"),\n },\n };\n\n for (const name in properties) {\n const descriptor = properties[name];\n if (descriptor.glslTypeInfo.instantiable) {\n varyingProperties[name] = descriptor;\n } else {\n uniformProperties[name] = descriptor;\n }\n }\n\n const instancedGeometry = INSTANCED_PLANE_GEOMETRY.clone();\n const shaderMaterial = buildMaterial(\n source,\n uniformProperties,\n varyingProperties,\n transparency,\n );\n\n super(instancedGeometry, shaderMaterial);\n\n this.frustumCulled = false;\n this.matrixAutoUpdate = false;\n this.matrixWorldAutoUpdate = false;\n\n this.instancedGeometry = instancedGeometry;\n this.instancedGeometry.instanceCount = 0;\n this.shaderMaterial = shaderMaterial;\n this.uniformProperties = uniformProperties;\n this.varyingProperties = varyingProperties;\n this.capacity = Math.max(\n Math.ceil(initialCapacity / CAPACITY_STEP) * CAPACITY_STEP,\n CAPACITY_STEP,\n );\n\n {\n for (const name in this.varyingProperties) {\n const { value } = this.varyingProperties[name];\n const attribute = buildEmptyInstancedBufferAttribute(\n value,\n this.capacity,\n );\n this.instancedGeometry.setAttribute(`a_${name}`, attribute);\n this.propertyBuffers.set(name, attribute);\n }\n }\n\n {\n for (const name in this.uniformProperties) {\n const { value } = this.uniformProperties[name];\n const uniform = resolvePropertyUniform(name, this.shaderMaterial);\n uniform.value = value;\n }\n this.shaderMaterial.uniformsNeedUpdate = true;\n }\n }\n\n /** Current number of active instances */\n public get instanceCount(): number {\n return this.instancedGeometry.instanceCount;\n }\n\n /**\n * Creates new instance with default values.\n * @returns Instance handler for subsequent operations\n */\n public createInstance(): number {\n const handler = this.lastHandler++;\n const index = this.instancedGeometry.instanceCount;\n\n {\n this.ensureCapacity(index + 1);\n this.handlerToIndex.set(handler, index);\n this.instancedGeometry.instanceCount++;\n }\n\n {\n const visibilityBufferAttribute = this.propertyBuffers.get(\n \"instanceVisibility\",\n ) as InstancedBufferAttribute;\n const transformBufferAttribute = this.propertyBuffers.get(\n \"instanceTransform\",\n ) as InstancedBufferAttribute;\n\n writeInstanceDefaults(\n visibilityBufferAttribute.array as Float32Array,\n transformBufferAttribute.array as Float32Array,\n index,\n );\n\n visibilityBufferAttribute.needsUpdate = true;\n transformBufferAttribute.needsUpdate = true;\n }\n\n return handler;\n }\n\n /** Removes instance and compacts buffer */\n public destroyInstance(handler: number): void {\n const index = this.resolveIndex(handler);\n this.handlerToIndex.delete(handler);\n\n const lastIndex = this.instancedGeometry.instanceCount - 1;\n if (index < lastIndex) {\n this.moveInstanceData(lastIndex, index);\n this.updateIndicesAfterMove(lastIndex, index);\n }\n\n this.instancedGeometry.instanceCount--;\n }\n\n /** Updates instance properties. Values are copied into buffers. */\n public setProperties(\n handler: number,\n properties: Record<string, GLProperty>,\n ): void {\n const index = this.resolveIndex(handler);\n\n for (const name in properties) {\n const { value, glslTypeInfo } = properties[name];\n\n if (glslTypeInfo.instantiable) {\n const attribute = this.resolveAttribute(name);\n const offset = index * attribute.itemSize;\n writePropertyToArray(value, attribute.array as Float32Array, offset);\n attribute.needsUpdate = true;\n } else {\n const uniform = resolvePropertyUniform(name, this.shaderMaterial);\n uniform.value = value;\n this.shaderMaterial.uniformsNeedUpdate = true;\n }\n }\n }\n\n /** Updates instance transform. Matrix is copied into buffer. */\n public setTransform(handler: number, transform: Matrix4): void {\n const index = this.resolveIndex(handler);\n\n const attribute = this.resolveAttribute(\"instanceTransform\");\n const array = attribute.array as Float32Array;\n const offset = index * 16;\n\n const elements = transform.elements;\n for (let j = 0; j < 16; j++) {\n array[offset + j] = elements[j];\n }\n attribute.needsUpdate = true;\n }\n\n /** Updates instance visibility */\n public setVisibility(handler: number, visible: boolean): void {\n const index = this.resolveIndex(handler);\n\n const attribute = this.resolveAttribute(\"instanceVisibility\");\n const array = attribute.array as Float32Array;\n array[index] = visible ? 1 : 0;\n\n attribute.needsUpdate = true;\n }\n\n /** Checks if plane can accept given properties without reconstruction */\n public isPartiallyCompatible(\n source: string,\n properties: Record<string, GLProperty>,\n transparency: UITransparencyMode = UITransparencyMode.BLEND,\n ): boolean {\n if (this.transparency !== transparency || this.source !== source) {\n return false;\n }\n\n return arePropertiesPartiallyCompatible(\n { ...this.uniformProperties, ...this.varyingProperties },\n properties,\n );\n }\n\n /** Checks if properties are compatible with current plane configuration */\n public arePropertiesPartiallyCompatible(\n properties: Readonly<Record<string, Readonly<GLProperty>>>,\n ): boolean {\n return arePropertiesPartiallyCompatible(\n { ...this.uniformProperties, ...this.varyingProperties },\n properties,\n );\n }\n\n /** Returns reconstructed instance data with new object instances */\n public extractInstanceData(handler: number): PlaneData {\n return {\n source: this.source,\n properties: this.extractProperties(handler),\n transparency: this.transparency,\n transform: this.extractTransform(handler),\n visibility: this.extractVisibility(handler),\n };\n }\n\n /** Disposes geometry, material, and clears buffers */\n public destroy(): void {\n this.instancedGeometry.dispose();\n this.shaderMaterial.dispose();\n this.propertyBuffers.clear();\n this.handlerToIndex.clear();\n }\n\n private extractProperties(handler: number): Record<string, GLProperty> {\n const index = this.resolveIndex(handler);\n const result: Record<string, GLProperty> = {};\n\n for (const name in this.uniformProperties) {\n result[name] = this.uniformProperties[name];\n }\n\n for (const name in this.varyingProperties) {\n const { value, glslTypeInfo } = this.varyingProperties[name];\n const attribute = this.propertyBuffers.get(\n name,\n ) as InstancedBufferAttribute;\n const array = attribute.array as Float32Array;\n const offset = index * attribute.itemSize;\n result[name] = {\n value: reconstructValue(value, array, offset),\n glslTypeInfo,\n };\n }\n\n return result;\n }\n\n private extractTransform(handler: number): Matrix4 {\n const index = this.resolveIndex(handler);\n const attribute = this.propertyBuffers.get(\n \"instanceTransform\",\n ) as InstancedBufferAttribute;\n const array = attribute.array as Float32Array;\n\n const matrix = new Matrix4();\n matrix.fromArray(array, index * 16);\n return matrix;\n }\n\n private extractVisibility(handler: number): boolean {\n const index = this.resolveIndex(handler);\n const attribute = this.propertyBuffers.get(\n \"instanceVisibility\",\n ) as InstancedBufferAttribute;\n const array = attribute.array as Float32Array;\n return array[index] >= 0.5;\n }\n\n private ensureCapacity(requiredCapacity: number): void {\n if (requiredCapacity <= this.capacity) {\n return;\n }\n\n const newCapacity =\n Math.ceil(requiredCapacity / CAPACITY_STEP) * CAPACITY_STEP;\n\n for (const [name, oldAttribute] of this.propertyBuffers) {\n const itemSize = oldAttribute.itemSize;\n const newArray = new Float32Array(newCapacity * itemSize);\n newArray.set(oldAttribute.array as Float32Array);\n\n const newAttribute = new InstancedBufferAttribute(newArray, itemSize);\n this.instancedGeometry.setAttribute(`a_${name}`, newAttribute);\n this.propertyBuffers.set(name, newAttribute);\n }\n\n this.capacity = newCapacity;\n }\n\n private moveInstanceData(sourceIndex: number, targetIndex: number): void {\n for (const attribute of this.propertyBuffers.values()) {\n const array = attribute.array as Float32Array;\n const itemSize = attribute.itemSize;\n\n const srcOffset = sourceIndex * itemSize;\n const dstOffset = targetIndex * itemSize;\n\n for (let i = 0; i < itemSize; i++) {\n array[dstOffset + i] = array[srcOffset + i];\n }\n\n attribute.needsUpdate = true;\n }\n }\n\n private updateIndicesAfterMove(oldIndex: number, newIndex: number): void {\n for (const [handler, index] of this.handlerToIndex) {\n if (index === oldIndex) {\n this.handlerToIndex.set(handler, newIndex);\n break;\n }\n }\n }\n\n private resolveIndex(handler: number): number {\n const index = this.handlerToIndex.get(handler);\n if (index === undefined) {\n throw new Error(\n `UIGenericInstancedPlane.resolveIndex.handler: invalid handler`,\n );\n }\n return index;\n }\n\n private resolveAttribute(name: string): InstancedBufferAttribute {\n const attribute = this.propertyBuffers.get(name);\n if (attribute === undefined) {\n throw new Error(\n `UIGenericInstancedPlane.resolveAttribute.name: unknown attribute`,\n );\n }\n return attribute;\n }\n}\n","import type { Matrix4 } from \"three\";\nimport { PlaneGeometry, ShaderMaterial } from \"three\";\nimport { UIColor } from \"../../color/UIColor\";\nimport { UITransparencyMode } from \"../../UITransparencyMode\";\nimport type { GLProperty } from \"../shared\";\nimport { buildGenericPlaneFragmentShader, DEFAULT_ALPHA_TEST } from \"../shared\";\n\nexport const PLANE_GEOMETRY = new PlaneGeometry(1, 1).translate(0.5, 0.5, 0);\n\nexport function buildGenericPlaneMaterial(\n source: string,\n properties: Record<string, GLProperty>,\n transparency: UITransparencyMode,\n transform: Matrix4,\n): ShaderMaterial {\n const uniforms: Record<string, { value: unknown }> = {\n // eslint-disable-next-line @typescript-eslint/naming-convention -- unform name\n p_transform: { value: transform },\n };\n\n const uniformDeclarations: string[] = [];\n\n for (const name in properties) {\n const { value, glslTypeInfo } = properties[name];\n uniforms[`p_${name}`] = {\n value: value instanceof UIColor ? value.toGLSLColor() : value,\n };\n uniformDeclarations.push(`uniform ${glslTypeInfo.glslTypeName} p_${name};`);\n }\n\n const vertexShader = `\n // Default uniform declarations\n uniform mat4 p_transform;\n\n // Custom uniform declarations\n ${uniformDeclarations.join(\"\\n\")}\n\n // Default varying declarations\n varying vec3 p_position;\n varying vec2 p_uv;\n\n void main() {\n p_position = position;\n p_uv = uv;\n\n gl_Position = projectionMatrix * p_transform * vec4(position, 1.0);\n }\n `;\n\n const fragmentShader = buildGenericPlaneFragmentShader(\n uniformDeclarations,\n [],\n source,\n );\n\n const material = new ShaderMaterial({\n uniforms,\n vertexShader,\n fragmentShader,\n transparent: transparency === UITransparencyMode.BLEND,\n alphaTest:\n transparency === UITransparencyMode.CLIP ? DEFAULT_ALPHA_TEST : 0.0,\n alphaHash: transparency === UITransparencyMode.HASH,\n depthWrite: transparency !== UITransparencyMode.BLEND,\n depthTest: true,\n });\n\n return material;\n}\n","import type { Matrix4, ShaderMaterial, Vector4 } from \"three\";\nimport { Mesh, Texture } from \"three\";\nimport { UIColor } from \"../../color/UIColor\";\nimport { UITransparencyMode } from \"../../UITransparencyMode\";\nimport type {\n GLProperty,\n PlaneData,\n UIPropertyCopyFrom,\n UIPropertyCopyTo,\n} from \"../shared\";\nimport {\n arePropertiesPartiallyCompatible,\n DEFAULT_ALPHA_TEST,\n resolvePropertyUniform,\n} from \"../shared\";\nimport {\n buildGenericPlaneMaterial,\n PLANE_GEOMETRY,\n} from \"./UIGenericPlane.Internal\";\n\n/**\n * Single shader plane mesh.\n *\n * Does not clone inputs. Caller must ensure properties and transform\n * are not shared with external code.\n *\n * @internal\n */\nexport class UIGenericPlane extends Mesh {\n private readonly shaderMaterial: ShaderMaterial;\n private readonly properties: Record<string, GLProperty>;\n private readonly transform: Matrix4;\n private transparencyInternal: UITransparencyMode;\n\n constructor(\n private readonly source: string,\n properties: Record<string, GLProperty>,\n transform: Matrix4,\n visibility: boolean,\n transparency: UITransparencyMode,\n ) {\n const shaderMaterial = buildGenericPlaneMaterial(\n source,\n properties,\n transparency,\n transform,\n );\n super(PLANE_GEOMETRY, shaderMaterial);\n\n this.shaderMaterial = shaderMaterial;\n this.properties = properties;\n this.transparencyInternal = transparency;\n this.transform = transform;\n this.visible = visibility;\n\n this.frustumCulled = false;\n this.matrixAutoUpdate = false;\n this.matrixWorldAutoUpdate = false;\n }\n\n /** Current transparency mode */\n public get transparency(): UITransparencyMode {\n return this.transparencyInternal;\n }\n\n /** Updates properties. Values are copied via .copy() methods. */\n public setProperties(properties: Record<string, GLProperty>): void {\n for (const name in properties) {\n const descriptor = properties[name];\n const uniform = resolvePropertyUniform(name, this.shaderMaterial);\n const descriptorValue = descriptor.value;\n\n if (descriptor.value instanceof UIColor) {\n descriptor.value.toGLSLColor(uniform.value as Vector4);\n (this.properties[name].value as UIColor).copy(descriptor.value);\n } else if (\n typeof descriptorValue === \"number\" ||\n descriptorValue instanceof Texture\n ) {\n uniform.value = descriptor.value;\n this.properties[name].value = descriptor.value;\n } else {\n const value = descriptor.value as UIPropertyCopyFrom;\n (uniform.value as UIPropertyCopyTo).copy(value);\n (this.properties[name].value as UIPropertyCopyTo).copy(value);\n }\n }\n this.shaderMaterial.uniformsNeedUpdate = true;\n }\n\n /** Updates transform. Matrix is copied. */\n public setTransform(transform: Matrix4): void {\n const uniform = resolvePropertyUniform(\"transform\", this.shaderMaterial);\n (uniform.value as Matrix4).copy(transform);\n this.shaderMaterial.uniformsNeedUpdate = true;\n this.transform.copy(transform);\n }\n\n /** Updates visibility */\n public setVisibility(visibility: boolean): void {\n this.visible = visibility;\n }\n\n /** Updates transparency mode */\n public setTransparency(transparency: UITransparencyMode): void {\n if (this.transparencyInternal !== transparency) {\n this.shaderMaterial.transparent =\n transparency === UITransparencyMode.BLEND;\n this.shaderMaterial.alphaTest =\n transparency === UITransparencyMode.CLIP ? DEFAULT_ALPHA_TEST : 0.0;\n this.shaderMaterial.alphaHash = transparency === UITransparencyMode.HASH;\n this.shaderMaterial.depthWrite =\n transparency !== UITransparencyMode.BLEND;\n this.shaderMaterial.needsUpdate = true;\n\n this.transparencyInternal = transparency;\n }\n }\n\n /** Returns cloned plane data for reconstruction */\n public extractPlaneData(): PlaneData {\n return {\n source: this.source,\n properties: { ...this.properties },\n transform: this.transform.clone(),\n visibility: this.visible,\n transparency: this.transparencyInternal,\n };\n }\n\n /** Checks if plane can accept given properties without reconstruction */\n public isPartiallyCompatible(\n source: string,\n properties: Record<string, GLProperty>,\n transparency: UITransparencyMode,\n ): boolean {\n if (this.transparencyInternal !== transparency || this.source !== source) {\n return false;\n }\n\n return arePropertiesPartiallyCompatible(this.properties, properties);\n }\n\n /** Checks if properties are compatible with current plane configuration */\n public arePropertiesPartiallyCompatible(\n properties: Record<string, GLProperty>,\n ): boolean {\n return arePropertiesPartiallyCompatible(this.properties, properties);\n }\n\n /** Disposes shader material */\n public destroy(): void {\n this.shaderMaterial.dispose();\n }\n}\n","import type { UIGenericInstancedPlane } from \"../UIGenericInstancedPlane/UIGenericInstancedPlane\";\nimport type { UIGenericPlane } from \"../UIGenericPlane/UIGenericPlane\";\n\nexport type PlaneDescriptor = SinglePlaneDescriptor | InstancedPlaneDescriptor;\n\nexport interface SinglePlaneDescriptor {\n plane: UIGenericPlane;\n}\n\nexport interface InstancedPlaneDescriptor {\n plane: UIGenericInstancedPlane;\n instanceHandler: number;\n}\n\nexport function isSinglePlaneDescriptor(\n descriptor: PlaneDescriptor,\n): descriptor is SinglePlaneDescriptor {\n return !(\"instanceHandler\" in descriptor);\n}\n\nexport function isInstancedPlaneDescriptor(\n descriptor: PlaneDescriptor,\n): descriptor is InstancedPlaneDescriptor {\n return \"instanceHandler\" in descriptor;\n}\n","import type { Matrix4, Scene } from \"three\";\nimport type { UITransparencyMode } from \"../../UITransparencyMode\";\nimport type { GLProperty, PlaneData, UIProperty } from \"../shared\";\nimport {\n cloneProperties,\n cloneProperty,\n convertUIPropertiesToGLProperties,\n} from \"../shared\";\nimport { UIGenericInstancedPlane } from \"../UIGenericInstancedPlane/UIGenericInstancedPlane\";\nimport { UIGenericPlane } from \"../UIGenericPlane/UIGenericPlane\";\nimport type {\n InstancedPlaneDescriptor,\n PlaneDescriptor,\n SinglePlaneDescriptor,\n} from \"./UIGenericPlaneRegistry.Internal\";\nimport {\n isInstancedPlaneDescriptor,\n isSinglePlaneDescriptor,\n} from \"./UIGenericPlaneRegistry.Internal\";\n\n/**\n * Manages shader plane instances with automatic batching.\n *\n * Clones all incoming properties and transforms. No external references\n * are retained after method calls return.\n *\n * @internal\n */\nexport class UIPlaneRegistry {\n private lastHandler = 0;\n private readonly handlerToPlaneDescriptor = new Map<\n number,\n PlaneDescriptor\n >();\n\n constructor(private readonly scene: Scene) {}\n\n /**\n * Creates plane with given shader and properties.\n * Properties and transform are cloned; originals can be safely modified.\n * @returns Plane handler for subsequent operations\n */\n public createPlane(\n source: string,\n properties: Record<string, UIProperty>,\n transform: Matrix4,\n visibility: boolean,\n transparency: UITransparencyMode,\n ): number {\n const handler = this.lastHandler++;\n this.insertPlane(handler, {\n source,\n properties: convertUIPropertiesToGLProperties(\n cloneProperties(properties),\n ),\n transform: transform.clone(),\n visibility,\n transparency,\n });\n return handler;\n }\n\n /** Removes plane and frees resources */\n public destroyPlane(handler: number): void {\n const planeDescriptor = this.resolvePlaneDescriptor(handler);\n\n if (isSinglePlaneDescriptor(planeDescriptor)) {\n this.scene.remove(planeDescriptor.plane);\n planeDescriptor.plane.destroy();\n } else {\n const instancedPlane = planeDescriptor.plane;\n if (instancedPlane.instanceCount === 1) {\n this.scene.remove(instancedPlane);\n instancedPlane.destroy();\n } else if (instancedPlane.instanceCount === 2) {\n this.demoteInstancedPlaneToSinglePlane(instancedPlane, planeDescriptor);\n } else {\n instancedPlane.destroyInstance(planeDescriptor.instanceHandler);\n }\n }\n\n this.handlerToPlaneDescriptor.delete(handler);\n }\n\n /**\n * Updates plane properties.\n * Values are copied; originals can be safely modified.\n */\n public setProperties(\n handler: number,\n properties: Record<string, UIProperty>,\n ): void {\n const planeDescriptor = this.resolvePlaneDescriptor(handler);\n const glProperties = convertUIPropertiesToGLProperties(properties);\n\n if (isSinglePlaneDescriptor(planeDescriptor)) {\n planeDescriptor.plane.setProperties(glProperties);\n return;\n }\n\n const arePropertiesCompatible =\n planeDescriptor.plane.arePropertiesPartiallyCompatible(glProperties);\n\n if (arePropertiesCompatible) {\n planeDescriptor.plane.setProperties(\n planeDescriptor.instanceHandler,\n glProperties,\n );\n return;\n }\n\n const planeData = planeDescriptor.plane.extractInstanceData(\n planeDescriptor.instanceHandler,\n );\n\n for (const name in glProperties) {\n planeData.properties[name] = {\n value: cloneProperty(glProperties[name].value),\n glslTypeInfo: glProperties[name].glslTypeInfo,\n };\n }\n\n this.destroyPlane(handler);\n this.insertPlane(handler, planeData);\n }\n\n /**\n * Updates plane transform matrix.\n * Matrix is copied; original can be safely modified.\n */\n public setTransform(handler: number, transform: Matrix4): void {\n const planeDescriptor = this.resolvePlaneDescriptor(handler);\n\n if (isSinglePlaneDescriptor(planeDescriptor)) {\n planeDescriptor.plane.setTransform(transform);\n return;\n }\n\n planeDescriptor.plane.setTransform(\n planeDescriptor.instanceHandler,\n transform,\n );\n }\n\n /** Updates plane visibility */\n public setVisibility(handler: number, visibility: boolean): void {\n const planeDescriptor = this.resolvePlaneDescriptor(handler);\n\n if (isSinglePlaneDescriptor(planeDescriptor)) {\n planeDescriptor.plane.setVisibility(visibility);\n return;\n }\n\n planeDescriptor.plane.setVisibility(\n planeDescriptor.instanceHandler,\n visibility,\n );\n }\n\n /** Updates plane transparency mode */\n public setTransparency(\n handler: number,\n transparency: UITransparencyMode,\n ): void {\n const planeDescriptor = this.resolvePlaneDescriptor(handler);\n\n if (planeDescriptor.plane.transparency === transparency) {\n return;\n }\n\n if (isSinglePlaneDescriptor(planeDescriptor)) {\n planeDescriptor.plane.setTransparency(transparency);\n return;\n }\n\n const planeData = planeDescriptor.plane.extractInstanceData(\n planeDescriptor.instanceHandler,\n );\n this.destroyPlane(handler);\n this.insertPlane(handler, {\n ...planeData,\n transparency,\n });\n }\n\n private promoteSinglePlaneToInstancedPlane(\n handler: number,\n planeDescriptor: SinglePlaneDescriptor,\n ): UIGenericInstancedPlane {\n const { source, properties, transform, visibility, transparency } =\n planeDescriptor.plane.extractPlaneData();\n\n this.destroyPlane(handler);\n const plane = new UIGenericInstancedPlane(source, properties, transparency);\n\n const instanceHandler = plane.createInstance();\n plane.setProperties(instanceHandler, properties);\n plane.setTransform(instanceHandler, transform);\n plane.setVisibility(instanceHandler, visibility);\n\n this.scene.add(plane);\n this.handlerToPlaneDescriptor.set(handler, { plane, instanceHandler });\n return plane;\n }\n\n private demoteInstancedPlaneToSinglePlane(\n instancedPlane: UIGenericInstancedPlane,\n removedDescriptor: InstancedPlaneDescriptor,\n ): void {\n let remainingPair: [number, InstancedPlaneDescriptor] | undefined;\n\n for (const [handler, planeDescriptor] of this.handlerToPlaneDescriptor) {\n if (\n isInstancedPlaneDescriptor(planeDescriptor) &&\n planeDescriptor !== removedDescriptor &&\n planeDescriptor.plane === instancedPlane\n ) {\n remainingPair = [handler, planeDescriptor];\n break;\n }\n }\n\n if (!remainingPair) {\n throw new Error(\n \"UIGenericPlaneRegistry.demoteInstancedPlaneToSinglePlane.instancedPlane: remaining pair not found\",\n );\n }\n\n const { source, properties, transform, visibility, transparency } =\n instancedPlane.extractInstanceData(remainingPair[1].instanceHandler);\n\n this.scene.remove(instancedPlane);\n instancedPlane.destroy();\n\n const plane = new UIGenericPlane(\n source,\n properties,\n transform,\n visibility,\n transparency,\n );\n\n this.scene.add(plane);\n this.handlerToPlaneDescriptor.set(remainingPair[0], { plane });\n }\n\n private attachToInstancedPlane(\n handler: number,\n instancedPlane: UIGenericInstancedPlane,\n properties: Record<string, GLProperty>,\n transform: Matrix4,\n visibility: boolean,\n ): void {\n const instanceHandler = instancedPlane.createInstance();\n instancedPlane.setProperties(instanceHandler, properties);\n instancedPlane.setTransform(instanceHandler, transform);\n instancedPlane.setVisibility(instanceHandler, visibility);\n this.handlerToPlaneDescriptor.set(handler, {\n plane: instancedPlane,\n instanceHandler,\n });\n }\n\n private insertPlane(handler: number, planeData: PlaneData): void {\n const { source, properties, transparency, transform, visibility } =\n planeData;\n\n const compatibleInstancedPlane = this.findCompatibleInstancedPlane(\n source,\n properties,\n transparency,\n );\n\n if (compatibleInstancedPlane) {\n this.attachToInstancedPlane(\n handler,\n compatibleInstancedPlane,\n properties,\n transform,\n visibility,\n );\n return;\n }\n\n const compatibleSinglePlanePair = this.findCompatibleSinglePlane(\n source,\n properties,\n transparency,\n );\n\n if (compatibleSinglePlanePair) {\n const instancedPlane = this.promoteSinglePlaneToInstancedPlane(\n compatibleSinglePlanePair[0],\n compatibleSinglePlanePair[1],\n );\n this.attachToInstancedPlane(\n handler,\n instancedPlane,\n properties,\n transform,\n visibility,\n );\n return;\n }\n\n const plane = new UIGenericPlane(\n source,\n properties,\n transform,\n visibility,\n transparency,\n );\n this.scene.add(plane);\n this.handlerToPlaneDescriptor.set(handler, { plane });\n }\n\n private findCompatibleSinglePlane(\n source: string,\n properties: Record<string, GLProperty>,\n transparency: UITransparencyMode,\n ): [number, SinglePlaneDescriptor] | undefined {\n for (const handlerPlaneDescriptorPair of this.handlerToPlaneDescriptor) {\n const planeDescriptor = handlerPlaneDescriptorPair[1];\n if (\n isSinglePlaneDescriptor(planeDescriptor) &&\n planeDescriptor.plane.isPartiallyCompatible(\n source,\n properties,\n transparency,\n )\n ) {\n return [handlerPlaneDescriptorPair[0], planeDescriptor];\n }\n }\n return undefined;\n }\n\n private findCompatibleInstancedPlane(\n source: string,\n properties: Record<string, GLProperty>,\n transparency: UITransparencyMode,\n ): UIGenericInstancedPlane | undefined {\n for (const handlerPlaneDescriptorPair of this.handlerToPlaneDescriptor) {\n const planeDescriptor = handlerPlaneDescriptorPair[1];\n if (\n isInstancedPlaneDescriptor(planeDescriptor) &&\n planeDescriptor.plane.isPartiallyCompatible(\n source,\n properties,\n transparency,\n )\n ) {\n return planeDescriptor.plane;\n }\n }\n return undefined;\n }\n\n private resolvePlaneDescriptor(handler: number): PlaneDescriptor {\n const descriptor = this.handlerToPlaneDescriptor.get(handler);\n if (!descriptor) {\n throw new Error(\n `UIGenericPlaneRegistry.resolvePlaneDescriptor.handler: descriptor not found`,\n );\n }\n return descriptor;\n }\n}\n","import type { Matrix4, Object3D, WebGLRenderer } from \"three\";\nimport { Color, OrthographicCamera, Scene } from \"three\";\nimport type { UIProperty } from \"../../miscellaneous/generic-plane/shared\";\nimport { UIPlaneRegistry } from \"../../miscellaneous/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry\";\nimport type { UITransparencyMode } from \"../../miscellaneous/UITransparencyMode\";\nimport type { UISceneWrapperInterface } from \"./UISceneWrapper.Internal\";\n\nlet originalClearColor = new Color();\nlet originalClearAlpha = 0;\nlet originalAutoClear = false;\nlet originalAutoClearColor = false;\nlet originalAutoClearDepth = false;\nlet originalAutoClearStencil = false;\n\nexport class UISceneWrapper implements UISceneWrapperInterface {\n private readonly scene = new Scene();\n private readonly camera: OrthographicCamera;\n private readonly planeRegistry = new UIPlaneRegistry(this.scene);\n\n constructor(width: number, height: number) {\n this.camera = new OrthographicCamera(0, width, height, 0, -1024, 1024);\n }\n\n public createPlane(\n source: string,\n properties: Record<string, UIProperty>,\n transform: Matrix4,\n visibility: boolean,\n transparency: UITransparencyMode,\n ): number {\n return this.planeRegistry.createPlane(\n source,\n properties,\n transform,\n visibility,\n transparency,\n );\n }\n\n public destroyPlane(handler: number): void {\n this.planeRegistry.destroyPlane(handler);\n }\n\n public setTransform(handler: number, transform: Matrix4): void {\n this.planeRegistry.setTransform(handler, transform);\n }\n\n public setProperties(\n handler: number,\n properties: Record<string, UIProperty>,\n ): void {\n this.planeRegistry.setProperties(handler, properties);\n }\n\n public setVisibility(handler: number, visible: boolean): void {\n this.planeRegistry.setVisibility(handler, visible);\n }\n\n public setTransparency(\n handler: number,\n transparency: UITransparencyMode,\n ): void {\n this.planeRegistry.setTransparency(handler, transparency);\n }\n\n public insertCustomObject(object: Object3D): this {\n this.scene.add(object);\n return this;\n }\n\n public removeCustomObject(object: Object3D): this {\n this.scene.remove(object);\n return this;\n }\n\n public resize(width: number, height: number): this {\n this.camera.right = width;\n this.camera.top = height;\n this.camera.updateProjectionMatrix();\n return this;\n }\n\n public render(renderer: WebGLRenderer): this {\n originalClearColor = renderer.getClearColor(originalClearColor);\n originalClearAlpha = renderer.getClearAlpha();\n originalAutoClear = renderer.autoClear;\n originalAutoClearColor = renderer.autoClearColor;\n originalAutoClearDepth = renderer.autoClearDepth;\n originalAutoClearStencil = renderer.autoClearStencil;\n\n renderer.autoClear = false;\n renderer.autoClearColor = false;\n renderer.autoClearDepth = false;\n renderer.autoClearStencil = false;\n renderer.setClearColor(0x000000, 1);\n\n renderer.clear(false, true, true);\n renderer.render(this.scene, this.camera);\n\n renderer.setClearColor(originalClearColor);\n renderer.setClearAlpha(originalClearAlpha);\n renderer.autoClear = originalAutoClear;\n renderer.autoClearColor = originalAutoClearColor;\n renderer.autoClearDepth = originalAutoClearDepth;\n renderer.autoClearStencil = originalAutoClearStencil;\n\n return this;\n }\n}\n","import { assertValidNumber } from \"./asserts\";\n\n/** Linear expression for constraint equations */\nexport class UIExpression {\n /** Constant term */\n public constant: number;\n /** Variable coefficients */\n private readonly terms: Map<number, number>;\n\n /**\n * @param constant Constant term\n * @param terms Variable-coefficient pairs\n */\n constructor(constant = 0, terms?: [number, number][]) {\n assertValidNumber(constant, \"UIExpression.constructor.constant\");\n this.constant = constant;\n this.terms = terms ? new Map(terms) : new Map();\n\n if (terms) {\n for (let i = 0; i < terms.length; i++) {\n assertValidNumber(\n terms[i][1],\n `UIExpression.constructor.terms[${i}][1]`,\n );\n }\n }\n }\n\n /**\n * Creates expression representing a + b.\n * @param a First expression\n * @param b Second expression\n * @returns Sum of expressions\n */\n public static plus(a: UIExpression, b: UIExpression): UIExpression {\n const result = new UIExpression(\n a.constant + b.constant,\n Array.from(a.terms.entries()),\n );\n for (const [variableIndex, coefficient] of b.terms) {\n result.plus(variableIndex, coefficient);\n }\n return result;\n }\n\n /**\n * Creates expression representing a - b.\n * @param a First expression\n * @param b Second expression\n * @returns Difference of expressions\n */\n public static minus(a: UIExpression, b: UIExpression): UIExpression {\n const result = new UIExpression(\n a.constant - b.constant,\n Array.from(a.terms.entries()),\n );\n for (const [variableIndex, coefficient] of b.terms) {\n result.minus(variableIndex, coefficient);\n }\n return result;\n }\n\n /**\n * Adds variable term to expression.\n * @param variableIndex Variable descriptor\n * @param coefficient Coefficient to add\n * @returns This instance for chaining\n */\n public plus(variableIndex: number, coefficient: number): this {\n assertValidNumber(coefficient, \"UIExpression.plus.coefficient\");\n this.terms.set(\n variableIndex,\n (this.terms.get(variableIndex) ?? 0) + coefficient,\n );\n return this;\n }\n\n /**\n * Subtracts variable term from expression.\n * @param variableIndex Variable descriptor\n * @param coefficient Coefficient to subtract\n * @returns This instance for chaining\n */\n public minus(variableIndex: number, coefficient: number): this {\n return this.plus(variableIndex, -coefficient);\n }\n\n /**\n * Multiplies all terms by scalar.\n * @param value Scalar multiplier\n * @returns This instance for chaining\n */\n public multiply(value: number): this {\n assertValidNumber(value, \"UIExpression.multiply.value\");\n this.constant *= value;\n for (const [variableIndex, coefficient] of this.terms) {\n this.terms.set(variableIndex, coefficient * value);\n }\n return this;\n }\n\n /**\n * Divides all terms by scalar.\n * @param value Scalar divisor\n * @returns This instance for chaining\n */\n public divide(value: number): this {\n assertValidNumber(value, \"UIExpression.divide.value\");\n if (value === 0) {\n throw new Error(\"UIExpression.divide.value: cannot divide by zero\");\n }\n return this.multiply(1 / value);\n }\n\n /**\n * Checks if expression contains variable term.\n * @param variableIndex Variable descriptor\n * @returns True if variable has term\n */\n public hasTerm(variableIndex: number): boolean {\n return this.terms.has(variableIndex);\n }\n\n /**\n * Copies from another expression.\n * @param expression Source expression\n * @returns This instance for chaining\n */\n public copy(expression: UIExpression): this {\n this.constant = expression.constant;\n this.terms.clear();\n for (const [variableIndex, coefficient] of expression.terms) {\n this.terms.set(variableIndex, coefficient);\n }\n return this;\n }\n\n /**\n * Creates independent copy.\n * @returns New expression with same content\n */\n public clone(): UIExpression {\n return new UIExpression(this.constant, Array.from(this.terms.entries()));\n }\n\n /**\n * Prepares terms for solver.\n * @returns Variable-coefficient pairs\n * @internal\n */\n public prepareTerms(): [number, number][] {\n return Array.from(this.terms.entries());\n }\n}\n","import { Operator } from \"@lume/kiwi\";\n\n/** Relational operators for constraints */\nexport enum UIRelation {\n /** Equality: LHS = RHS */\n EQUAL = 0,\n /** Less than or equal: LHS ≤ RHS */\n LESS_THAN = 1,\n /** Greater than or equal: LHS ≥ RHS */\n GREATER_THAN = 2,\n}\n\n/**\n * Converts relation to solver operator.\n * @param relation Relation type\n * @returns Solver operator\n * @throws If relation is invalid\n */\nexport function convertRelation(relation: UIRelation): Operator {\n switch (relation) {\n case UIRelation.EQUAL:\n return Operator.Eq;\n case UIRelation.LESS_THAN:\n return Operator.Le;\n case UIRelation.GREATER_THAN:\n return Operator.Ge;\n default:\n throw new Error(`convertRelation.relation: invalid relation`);\n }\n}\n\n/**\n * Resolves optional relation.\n * @param relation Relation to resolve\n * @returns Relation or EQUAL if undefined\n */\nexport function resolveRelation(relation?: UIRelation): UIRelation {\n return relation ?? UIRelation.EQUAL;\n}\n","import { UIMode } from \"../../miscellaneous/UIMode\";\nimport type { UIOrientation } from \"../../miscellaneous/UIOrientation\";\n\n/** Layer lifecycle and state events */\nexport enum UILayerEvent {\n /** Fired when orientation changes */\n ORIENTATION_CHANGED = \"orientation_changed\",\n /** Fired when mode changes */\n MODE_CHANGED = \"mode_changed\",\n /** Fired during rendering */\n RENDERING = \"rendering\",\n}\n\n/** Layer visibility and interactivity state */\nexport type UILayerMode = UIMode.HIDDEN | UIMode.VISIBLE | UIMode.INTERACTIVE;\n\n/** Layer orientation state */\nexport type UILayerOrientation =\n | UIOrientation.VERTICAL\n | UIOrientation.HORIZONTAL;\n\n/** Configuration options for UILayer */\nexport interface UILayerOptions {\n /** Initial width */\n width: number;\n /** Initial height */\n height: number;\n /** Optional layer name */\n name: string;\n /** Initial visibility and interactivity mode */\n mode: UILayerMode;\n}\n\nexport const LAYER_DEFAULT_SIZE = 1024;\nexport const LAYER_DEFAULT_NAME = \"\";\nexport const LAYER_DEFAULT_MODE: UILayerMode = UIMode.VISIBLE;\n","import { Constraint, Expression, Solver, Variable } from \"@lume/kiwi\";\nimport { UIExpression } from \"../../miscellaneous/UIExpression\";\nimport { convertPriority, UIPriority } from \"../../miscellaneous/UIPriority\";\nimport { convertRelation, UIRelation } from \"../../miscellaneous/UIRelation\";\nimport type {\n ConstraintDescription,\n UISolverWrapperInterface,\n VariableDescription,\n} from \"./UISolverWrapper.Internal\";\n\n/**\n * Wrapper around the Kiwi constraint solver providing enhanced UI-specific functionality.\n *\n * UISolverWrapper abstracts the Kiwi (Cassowary) constraint solver to provide a more\n * UI-friendly interface with additional features like dynamic constraint modification,\n * required variables (P0 priority), partial constraint updates, and automatic solver\n * recovery. It manages variables and constraints through index-based references,\n * allowing for easy tracking and modification of layout constraints.\n *\n * Key features:\n * - Index-based variable and constraint management\n * - Required variables with P0 priority (always satisfied)\n * - Dynamic constraint modification without full rebuilds\n * - Automatic solver recovery on constraint conflicts\n * - Lazy evaluation with recalculation flags\n *\n * @see {@link UIExpression} - Expression system for constraint definitions\n * @see {@link UIPriority} - Priority levels for variables and constraints\n * @see {@link UIRelation} - Relational operators for constraints\n */\nexport class UISolverWrapper implements UISolverWrapperInterface {\n /** @internal */\n public dirty = false;\n\n /** The underlying Kiwi solver instance, undefined when solver needs rebuilding. */\n private solver? = new Solver();\n /** Flag indicating whether variable values need recalculation. */\n private recalculationRequired = false;\n\n /** Map of variable indices to their descriptions. */\n private readonly variables = new Map<number, VariableDescription>();\n /** Counter for generating unique variable indices. */\n private lastVariableIndex = 0;\n\n /** Map of constraint indices to their descriptions. */\n private readonly constraints = new Map<number, ConstraintDescription>();\n /** Counter for generating unique constraint indices. */\n private lastConstraintIndex = 0;\n\n /**\n * Creates a new solver variable with the specified value and priority.\n *\n * Variables with P0 priority are treated as required (must be satisfied exactly)\n * and are implemented using equality constraints. Other priorities use edit\n * variables that can be adjusted by the solver.\n *\n * @param value - Initial value for the variable\n * @param priority - Priority level for constraint solving\n * @returns Unique index identifier for the created variable\n */\n public createVariable(value: number, priority: UIPriority): number {\n const index = this.lastVariableIndex++;\n const variable = new Variable();\n\n if (priority === UIPriority.P0) {\n const description: VariableDescription = { variable, priority, value };\n this.variables.set(index, description);\n\n description.constraint = this.buildConstraint(\n new UIExpression(0, [[index, 1]]),\n new UIExpression(value),\n UIRelation.EQUAL,\n priority,\n );\n try {\n this.solver?.addConstraint(description.constraint);\n } catch {\n this.solver = undefined;\n }\n } else {\n this.variables.set(index, { variable, priority, value });\n\n try {\n this.solver?.addEditVariable(variable, convertPriority(priority));\n this.solver?.suggestValue(variable, value);\n } catch {\n this.solver = undefined;\n }\n }\n\n this.recalculationRequired = true;\n this.dirty = true;\n return index;\n }\n\n /**\n * Removes a variable from the solver system.\n *\n * The variable must not be referenced by any existing constraints.\n * Cleans up both the variable itself and any associated required constraint.\n *\n * @param index - Index of the variable to remove\n * @throws Will throw an error if the variable doesn't exist or is still in use\n */\n public removeVariable(index: number): void {\n const description = this.variables.get(index);\n if (description === undefined) {\n throw new Error(\n `UISolverWrapper.removeVariable.index: variable does not exist`,\n );\n }\n\n for (const cDescription of this.constraints.values()) {\n if (cDescription.lhs.hasTerm(index) || cDescription.rhs.hasTerm(index)) {\n throw new Error(\n `UISolverWrapper.removeVariable.index: variable is used in constraint`,\n );\n }\n }\n\n try {\n description.constraint\n ? this.solver?.removeConstraint(description.constraint)\n : this.solver?.removeEditVariable(description.variable);\n } catch {\n this.solver = undefined;\n }\n\n this.variables.delete(index);\n this.recalculationRequired = true;\n this.dirty = true;\n }\n\n /**\n * Suggests a new value for an existing variable.\n *\n * For P0 priority variables, rebuilds the associated constraint.\n * For other priorities, suggests the value to the solver's edit system.\n * Only triggers updates if the value actually changes.\n *\n * @param index - Index of the variable to update\n * @param value - New suggested value\n * @throws Will throw an error if the variable doesn't exist\n */\n public suggestVariableValue(index: number, value: number): void {\n const description = this.variables.get(index);\n if (description === undefined) {\n throw new Error(\n `UISolverWrapper.suggestVariableValue.index: variable does not exist`,\n );\n }\n\n if (description.value !== value) {\n description.value = value;\n\n if (description.constraint) {\n description.constraint = this.rebuildConstraint(\n description.constraint,\n new UIExpression().plus(index, 1),\n new UIExpression(description.value),\n UIRelation.EQUAL,\n description.priority,\n );\n } else {\n this.solver?.suggestValue(description.variable, value);\n }\n\n this.recalculationRequired = true;\n this.dirty = true;\n }\n }\n\n /**\n * Changes the priority of an existing variable.\n *\n * Switching to/from P0 priority changes how the variable is handled:\n * - P0: Creates required constraint (must be satisfied exactly)\n * - Other: Uses edit variable system (can be adjusted by solver)\n *\n * @param index - Index of the variable to modify\n * @param priority - New priority level\n * @throws Will throw an error if the variable doesn't exist\n */\n public setVariablePriority(index: number, priority: UIPriority): void {\n const description = this.variables.get(index);\n if (description === undefined) {\n throw new Error(\n `UISolverWrapper.setVariablePriority.index: variable does not exist`,\n );\n }\n\n if (priority !== description.priority) {\n description.priority = priority;\n\n if (description.priority === UIPriority.P0) {\n const lhs = new UIExpression().plus(index, 1);\n const rhs = new UIExpression(description.value);\n\n description.constraint = this.buildConstraint(\n lhs,\n rhs,\n UIRelation.EQUAL,\n description.priority,\n );\n\n try {\n this.solver?.addConstraint(description.constraint);\n } catch {\n this.solver = undefined;\n }\n } else {\n if (description.constraint) {\n try {\n this.solver?.removeConstraint(description.constraint);\n } catch {\n this.solver = undefined;\n }\n }\n\n description.constraint = undefined;\n this.rebuildVariable(index, description);\n }\n\n this.recalculationRequired = true;\n this.dirty = true;\n }\n }\n\n /**\n * Reads the current solved value of a variable.\n *\n * Triggers solver recalculation if needed and rebuilds the solver\n * if it was invalidated due to constraint conflicts.\n *\n * @param index - Index of the variable to read\n * @returns Current solved value of the variable\n * @throws Will throw an error if the variable doesn't exist\n */\n public readVariableValue(index: number): number {\n const description = this.variables.get(index);\n if (description === undefined) {\n throw new Error(\n `UISolverWrapper.readVariableValue.index: variable does not exist`,\n );\n }\n\n if (this.solver === undefined) {\n this.rebuildSolver();\n }\n\n if (this.recalculationRequired) {\n this.solver?.updateVariables();\n this.recalculationRequired = false;\n }\n\n return description.variable.value();\n }\n\n /**\n * Creates a new constraint between two expressions.\n *\n * Constraints can be enabled or disabled, and all properties can be\n * modified later without recreating the constraint.\n *\n * @param lhs - Left-hand side expression\n * @param rhs - Right-hand side expression\n * @param relation - Relational operator (equal, less than, greater than)\n * @param priority - Priority level for constraint solving\n * @param enabled - Whether the constraint is initially active\n * @returns Unique index identifier for the created constraint\n */\n public createConstraint(\n lhs: UIExpression,\n rhs: UIExpression,\n relation: UIRelation,\n priority: UIPriority,\n enabled: boolean,\n ): number {\n const index = this.lastConstraintIndex++;\n const constraint = this.buildConstraint(lhs, rhs, relation, priority);\n this.constraints.set(index, {\n constraint,\n lhs: lhs.clone(),\n rhs: rhs.clone(),\n priority,\n relation,\n enabled,\n });\n if (enabled) {\n try {\n this.solver?.addConstraint(constraint);\n } catch {\n this.solver = undefined;\n }\n this.recalculationRequired = true;\n this.dirty = true;\n }\n return index;\n }\n\n /**\n * Removes a constraint from the solver system.\n *\n * If the constraint is currently enabled, it will be removed from\n * the active solver before deletion.\n *\n * @param index - Index of the constraint to remove\n * @throws Will throw an error if the constraint doesn't exist\n */\n public removeConstraint(index: number): void {\n const description = this.constraints.get(index);\n if (description === undefined) {\n throw new Error(\n `UISolverWrapper.removeConstraint.index: constraint does not exist`,\n );\n }\n\n if (description.enabled) {\n try {\n this.solver?.removeConstraint(description.constraint);\n } catch {\n this.solver = undefined;\n }\n }\n\n this.constraints.delete(index);\n this.recalculationRequired = true;\n this.dirty = true;\n }\n\n /**\n * Updates the left-hand side expression of an existing constraint.\n *\n * Rebuilds the underlying constraint with the new expression while\n * preserving all other properties.\n *\n * @param index - Index of the constraint to modify\n * @param lhs - New left-hand side expression\n * @throws Will throw an error if the constraint doesn't exist\n */\n public setConstraintLHS(index: number, lhs: UIExpression): void {\n const description = this.constraints.get(index);\n if (description === undefined) {\n throw new Error(\n `UISolverWrapper.setConstraintLHS.index: constraint does not exist`,\n );\n }\n\n description.lhs.copy(lhs);\n this.rebuildConstraintByDescription(description);\n this.recalculationRequired = true;\n this.dirty = true;\n }\n\n /**\n * Updates the right-hand side expression of an existing constraint.\n *\n * Rebuilds the underlying constraint with the new expression while\n * preserving all other properties.\n *\n * @param index - Index of the constraint to modify\n * @param rhs - New right-hand side expression\n * @throws Will throw an error if the constraint doesn't exist\n */\n public setConstraintRHS(index: number, rhs: UIExpression): void {\n const description = this.constraints.get(index);\n if (description === undefined) {\n throw new Error(\n `UISolverWrapper.setConstraintRHS.index: constraint does not exist`,\n );\n }\n\n description.rhs.copy(rhs);\n this.rebuildConstraintByDescription(description);\n this.recalculationRequired = true;\n this.dirty = true;\n }\n\n /**\n * Updates the relational operator of an existing constraint.\n *\n * Changes how the left and right expressions are compared\n * (equal, less than, greater than).\n *\n * @param index - Index of the constraint to modify\n * @param relation - New relational operator\n * @throws Will throw an error if the constraint doesn't exist\n */\n public setConstraintRelation(index: number, relation: UIRelation): void {\n const description = this.constraints.get(index);\n if (description === undefined) {\n throw new Error(\n `UISolverWrapper.setConstraintRelation.index: constraint does not exist`,\n );\n }\n\n if (description.relation !== relation) {\n description.relation = relation;\n this.rebuildConstraintByDescription(description);\n this.recalculationRequired = true;\n this.dirty = true;\n }\n }\n\n /**\n * Updates the priority level of an existing constraint.\n *\n * Higher priority constraints are more likely to be satisfied\n * when conflicts arise.\n *\n * @param index - Index of the constraint to modify\n * @param priority - New priority level\n * @throws Will throw an error if the constraint doesn't exist\n */\n public setConstraintPriority(index: number, priority: UIPriority): void {\n const description = this.constraints.get(index);\n if (description === undefined) {\n throw new Error(\n `UISolverWrapper.setConstraintPriority.index: constraint does not exist`,\n );\n }\n\n if (description.priority !== priority) {\n description.priority = priority;\n this.rebuildConstraintByDescription(description);\n this.recalculationRequired = true;\n this.dirty = true;\n }\n }\n\n /**\n * Enables or disables an existing constraint.\n *\n * Disabled constraints are not considered during solving but\n * remain in the system for potential re-enabling.\n *\n * @param index - Index of the constraint to modify\n * @param enabled - Whether the constraint should be active\n * @throws Will throw an error if the constraint doesn't exist\n */\n public setConstraintEnabled(index: number, enabled: boolean): void {\n const description = this.constraints.get(index);\n if (description === undefined) {\n throw new Error(\n `UISolverWrapper.setConstraintEnabled.index: constraint does not exist`,\n );\n }\n\n if (enabled !== description.enabled) {\n description.enabled = enabled;\n try {\n description.enabled\n ? this.solver?.addConstraint(description.constraint)\n : this.solver?.removeConstraint(description.constraint);\n } catch {\n this.solver = undefined;\n }\n this.recalculationRequired = true;\n this.dirty = true;\n }\n }\n\n /**\n * Rebuilds a variable in the solver system with new properties.\n *\n * Temporarily removes all constraints that reference the variable,\n * updates the variable configuration, then rebuilds and re-adds\n * the dependent constraints.\n */\n private rebuildVariable(\n index: number,\n description: VariableDescription,\n ): void {\n const dependConstraints: ConstraintDescription[] = [];\n\n for (const cDescription of this.constraints.values()) {\n if (cDescription.lhs.hasTerm(index) || cDescription.rhs.hasTerm(index)) {\n try {\n this.solver?.removeConstraint(cDescription.constraint);\n } catch {\n this.solver = undefined;\n }\n dependConstraints.push(cDescription);\n }\n }\n\n this.solver?.removeEditVariable(description.variable);\n this.solver?.addEditVariable(\n description.variable,\n convertPriority(description.priority),\n );\n\n for (const cDescription of dependConstraints) {\n cDescription.constraint = this.buildConstraint(\n cDescription.lhs,\n cDescription.rhs,\n cDescription.relation,\n cDescription.priority,\n );\n }\n\n for (const cDescription of dependConstraints) {\n try {\n this.solver?.addConstraint(cDescription.constraint);\n } catch {\n this.solver = undefined;\n break;\n }\n }\n }\n\n /**\n * Rebuilds a constraint based on its current description.\n *\n * Uses different rebuild strategies depending on whether the\n * constraint is currently enabled.\n */\n private rebuildConstraintByDescription(\n description: ConstraintDescription,\n ): void {\n description.constraint = description.enabled\n ? this.rebuildConstraint(\n description.constraint,\n description.lhs,\n description.rhs,\n description.relation,\n description.priority,\n )\n : this.buildConstraint(\n description.lhs,\n description.rhs,\n description.relation,\n description.priority,\n );\n }\n\n /**\n * Rebuilds a constraint by removing the old one and creating a new one.\n *\n * Safely handles solver state transitions and constraint replacement.\n */\n private rebuildConstraint(\n oldConstraint: Constraint,\n lhs: UIExpression,\n rhs: UIExpression,\n relation: UIRelation,\n priority: UIPriority,\n ): Constraint {\n try {\n this.solver?.removeConstraint(oldConstraint);\n } catch {\n this.solver = undefined;\n }\n\n const constraint = this.buildConstraint(lhs, rhs, relation, priority);\n\n try {\n this.solver?.addConstraint(constraint);\n } catch {\n this.solver = undefined;\n }\n\n return constraint;\n }\n\n /**\n * Creates a new Kiwi constraint from UI expressions and parameters.\n *\n * Converts UI-level expressions and enums to Kiwi-compatible formats.\n */\n private buildConstraint(\n lhs: UIExpression,\n rhs: UIExpression,\n relation: UIRelation,\n priority: UIPriority,\n ): Constraint {\n return new Constraint(\n this.convertExpression(lhs),\n convertRelation(relation),\n this.convertExpression(rhs),\n convertPriority(priority),\n );\n }\n\n /**\n * Converts a UIExpression to a Kiwi Expression.\n *\n * Maps variable indices to their corresponding Kiwi Variable instances\n * and preserves coefficients and constants.\n */\n private convertExpression(expression: UIExpression): Expression {\n return new Expression(\n ...expression\n .prepareTerms()\n .map(([variableIndex, coefficient]): [number, Variable] => {\n const description = this.variables.get(variableIndex);\n if (description === undefined) {\n throw new Error(\n `UISolverWrapper.convertExpression.expression: variable does not exist`,\n );\n }\n return [coefficient, description.variable];\n }),\n expression.constant,\n );\n }\n\n /**\n * Completely rebuilds the solver from scratch.\n *\n * Re-adds all variables and constraints to a fresh solver instance.\n * Used for recovery when the solver enters an invalid state.\n */\n private rebuildSolver(): void {\n if (this.solver) {\n throw new Error(\"UISolverWrapper.rebuildSolver: solver already exists\");\n }\n\n this.solver = new Solver();\n\n for (const description of this.variables.values()) {\n if (description.constraint) {\n this.solver.addConstraint(description.constraint);\n } else {\n this.solver.addEditVariable(\n description.variable,\n convertPriority(description.priority),\n );\n this.solver.suggestValue(description.variable, description.value);\n }\n }\n\n for (const description of this.constraints.values()) {\n if (description.enabled) {\n this.solver.addConstraint(description.constraint);\n }\n }\n\n this.recalculationRequired = true;\n this.dirty = true;\n }\n}\n","import { Eventail } from \"eventail\";\nimport type { WebGLRenderer } from \"three\";\nimport type { UIPlaneElement } from \"../../miscellaneous/shared\";\n\nimport { assertValidPositiveNumber } from \"../../miscellaneous/asserts\";\nimport { isUIModeVisible } from \"../../miscellaneous/UIMode\";\nimport { UIOrientation } from \"../../miscellaneous/UIOrientation\";\nimport { UIPriority } from \"../../miscellaneous/UIPriority\";\nimport { UIInputWrapper } from \"../../wrappers/UIInputWrapper/UIInputWrapper\";\nimport type { UIInputWrapperInterface } from \"../../wrappers/UIInputWrapper/UIInputWrapper.Internal\";\nimport { UISceneWrapper } from \"../../wrappers/UISceneWrapper/UISceneWrapper\";\nimport type { UISceneWrapperInterface } from \"../../wrappers/UISceneWrapper/UISceneWrapper.Internal\";\nimport { UISolverWrapper } from \"../../wrappers/UISolverWrapper/UISolverWrapper\";\nimport type { UISolverWrapperInterface } from \"../../wrappers/UISolverWrapper/UISolverWrapper.Internal\";\nimport type {\n UILayerMode,\n UILayerOptions,\n UILayerOrientation,\n} from \"./UILayer.Internal\";\nimport {\n LAYER_DEFAULT_MODE,\n LAYER_DEFAULT_NAME,\n LAYER_DEFAULT_SIZE,\n UILayerEvent,\n} from \"./UILayer.Internal\";\n\n/** Base layer for UI rendering and layout management */\nexport abstract class UILayer extends Eventail implements UIPlaneElement {\n /** Optional layer name */\n public name = \"\";\n /** Solver variable for x coordinate */\n public readonly xVariable: number;\n /** Solver variable for y coordinate */\n public readonly yVariable: number;\n /** Solver variable for width */\n public readonly wVariable: number;\n /** Solver variable for height */\n public readonly hVariable: number;\n\n protected readonly inputWrapperInternal = new UIInputWrapper();\n private readonly solverWrapperInternal = new UISolverWrapper();\n private readonly sceneWrapperInternal: UISceneWrapper;\n\n private modeInternal: UILayerMode;\n private orientationInternal: UILayerOrientation;\n\n constructor(options: Partial<UILayerOptions>) {\n super();\n\n if (options.width !== undefined) {\n assertValidPositiveNumber(\n options.width,\n \"UILayer.constructor.options.width\",\n );\n }\n\n if (options.height !== undefined) {\n assertValidPositiveNumber(\n options.height,\n \"UILayer.constructor.options.height\",\n );\n }\n\n const width = options.width ?? LAYER_DEFAULT_SIZE;\n const height = options.height ?? LAYER_DEFAULT_SIZE;\n\n this.sceneWrapperInternal = new UISceneWrapper(width, height);\n this.name = options.name ?? LAYER_DEFAULT_NAME;\n this.modeInternal = options.mode ?? LAYER_DEFAULT_MODE;\n this.orientationInternal =\n width > height ? UIOrientation.HORIZONTAL : UIOrientation.VERTICAL;\n\n this.xVariable = this.solverWrapperInternal.createVariable(\n 0,\n UIPriority.P0,\n );\n this.yVariable = this.solverWrapperInternal.createVariable(\n 0,\n UIPriority.P0,\n );\n this.wVariable = this.solverWrapperInternal.createVariable(\n width,\n UIPriority.P0,\n );\n this.hVariable = this.solverWrapperInternal.createVariable(\n height,\n UIPriority.P0,\n );\n }\n\n /** @internal */\n public get sceneWrapper(): UISceneWrapperInterface {\n return this.sceneWrapperInternal;\n }\n\n /** @internal */\n public get solverWrapper(): UISolverWrapperInterface {\n return this.solverWrapperInternal;\n }\n\n /** @internal */\n public get inputWrapper(): UIInputWrapperInterface {\n return this.inputWrapperInternal;\n }\n\n /** X coordinate in world units (always 0 for layers) */\n public get x(): number {\n return this.solverWrapperInternal.readVariableValue(this.xVariable);\n }\n\n /** Y coordinate in world units (always 0 for layers) */\n public get y(): number {\n return this.solverWrapperInternal.readVariableValue(this.yVariable);\n }\n\n /** Layer width in world units */\n public get width(): number {\n return this.solverWrapperInternal.readVariableValue(this.wVariable);\n }\n\n /** Layer height in world units */\n public get height(): number {\n return this.solverWrapperInternal.readVariableValue(this.hVariable);\n }\n\n /** Current visibility and interactivity mode */\n public get mode(): UILayerMode {\n return this.modeInternal;\n }\n\n /** Current orientation based on aspect ratio */\n public get orientation(): UILayerOrientation {\n return this.orientationInternal;\n }\n\n /** Updates visibility and interactivity mode */\n public set mode(value: UILayerMode) {\n if (value !== this.modeInternal) {\n this.modeInternal = value;\n this.emit(UILayerEvent.MODE_CHANGED, this.modeInternal, this);\n }\n }\n\n protected resizeInternal(width: number, height: number): void {\n this.solverWrapperInternal.suggestVariableValue(this.wVariable, width);\n this.solverWrapperInternal.suggestVariableValue(this.hVariable, height);\n this.sceneWrapperInternal.resize(width, height);\n\n const orientation =\n width > height ? UIOrientation.HORIZONTAL : UIOrientation.VERTICAL;\n\n if (orientation !== this.orientationInternal) {\n this.orientationInternal = orientation;\n this.emit(\n UILayerEvent.ORIENTATION_CHANGED,\n this.orientationInternal,\n this,\n );\n }\n }\n\n protected renderInternal(renderer: WebGLRenderer, deltaTime: number): void {\n if (isUIModeVisible(this.mode)) {\n this.emit(UILayerEvent.RENDERING, renderer, deltaTime, this);\n this.sceneWrapperInternal.render(renderer);\n }\n\n this.solverWrapperInternal.dirty = false;\n this.inputWrapperInternal.dirty = false;\n }\n}\n","import { UILayer } from \"../layers/UILayer/UILayer\";\n\n/** Objects that belong to a UI layer */\nexport interface UILayerElement {\n /** The UI layer containing this element */\n readonly layer: UILayer;\n}\n\n/** UI elements with position in 2D space */\nexport interface UIPointElement {\n /** Solver variable for x coordinate */\n readonly xVariable: number;\n /** Solver variable for y coordinate */\n readonly yVariable: number;\n\n /** X coordinate in world units */\n readonly x: number;\n /** Y coordinate in world units */\n readonly y: number;\n}\n\n/** UI elements with position and dimensions */\nexport interface UIPlaneElement extends UIPointElement {\n /** Solver variable for width */\n readonly wVariable: number;\n /** Solver variable for height */\n readonly hVariable: number;\n\n /** Width in world units */\n readonly width: number;\n /** Height in world units */\n readonly height: number;\n}\n\n/**\n * Checks if object implements UILayerElement.\n * @param obj Object to check\n * @returns True if object has valid layer property\n */\nexport function isUILayerElement(obj: unknown): obj is UILayerElement {\n return (\n typeof obj === \"object\" &&\n obj !== null &&\n \"layer\" in obj &&\n obj.layer instanceof UILayer\n );\n}\n\n/**\n * Checks if object implements UIPointElement.\n * @param obj Object to check\n * @returns True if object has valid position variables\n */\nexport function isUIPointElement(obj: unknown): obj is UIPointElement {\n return (\n typeof obj === \"object\" &&\n obj !== null &&\n \"xVariable\" in obj &&\n typeof obj.xVariable === \"number\" &&\n \"yVariable\" in obj &&\n typeof obj.yVariable === \"number\" &&\n \"width\" in obj &&\n typeof obj.width === \"number\" &&\n \"height\" in obj &&\n typeof obj.height === \"number\"\n );\n}\n\n/**\n * Checks if object implements UIPlaneElement.\n * @param obj Object to check\n * @returns True if object has valid dimension variables\n */\nexport function isUIPlaneElement(obj: unknown): obj is UIPlaneElement {\n return (\n typeof obj === \"object\" &&\n obj !== null &&\n \"wVariable\" in obj &&\n typeof obj.wVariable === \"number\" &&\n \"hVariable\" in obj &&\n typeof obj.hVariable === \"number\" &&\n \"width\" in obj &&\n typeof obj.width === \"number\" &&\n \"height\" in obj &&\n typeof obj.height === \"number\"\n );\n}\n","import { UILayer } from \"../layers/UILayer/UILayer\";\nimport { isUILayerElement } from \"./shared\";\n\nexport const EPSILON = 1e-6;\n\n/**\n * Validates value is finite number within safe range.\n * @param value Number to validate\n * @param subject Value name for error messages\n * @throws If value is not finite or exceeds safe range\n */\nexport function assertValidNumber(value: number, subject: string): void {\n if (process.env.NODE_ENV !== \"production\") {\n if (!Number.isFinite(value)) {\n throw new Error(`${subject}: value must be a finite number`);\n }\n\n if (Math.abs(value) > Number.MAX_SAFE_INTEGER) {\n throw new Error(`${subject}: value exceeds maximum safe integer range`);\n }\n }\n}\n\n/**\n * Validates value is positive (>= EPSILON).\n * @param value Number to validate\n * @param subject Value name for error messages\n * @throws If value is invalid or below EPSILON\n */\nexport function assertValidPositiveNumber(\n value: number,\n subject: string,\n): void {\n if (process.env.NODE_ENV !== \"production\") {\n assertValidNumber(value, subject);\n if (value < EPSILON) {\n throw new Error(\n `${subject}: value must be greater than or equal to ${EPSILON}`,\n );\n }\n }\n}\n\n/**\n * Validates value is non-negative (>= 0).\n * @param value Number to validate\n * @param subject Value name for error messages\n * @throws If value is invalid or negative\n */\nexport function assertValidNonNegativeNumber(\n value: number,\n subject: string,\n): void {\n if (process.env.NODE_ENV !== \"production\") {\n assertValidNumber(value, subject);\n if (value < 0) {\n throw new Error(`${subject}: value must be greater than or equal to 0`);\n }\n }\n}\n\n/**\n * Validates constraint arguments are from same layer.\n * @param a First constraint subject\n * @param b Second constraint subject\n * @param subject Constraint name for error messages\n * @returns Common layer for both subjects\n * @throws If subjects are invalid or from different layers\n */\nexport function assertValidConstraintArguments(\n a: unknown,\n b: unknown,\n subject: string,\n): UILayer {\n if (process.env.NODE_ENV !== \"production\") {\n if (a instanceof UILayer && b instanceof UILayer) {\n throw new Error(`${subject}: layer cannot be snapped to another layer`);\n }\n\n let layerA: UILayer;\n let layerB: UILayer;\n\n if (a instanceof UILayer) {\n layerA = a;\n } else if (isUILayerElement(a)) {\n layerA = a.layer;\n } else {\n throw new Error(`${subject}: A must be a UILayer or a UILayerElement`);\n }\n\n if (b instanceof UILayer) {\n layerB = b;\n } else if (isUILayerElement(b)) {\n layerB = b.layer;\n } else {\n throw new Error(`${subject}: B must be a UILayer or a UILayerElement`);\n }\n\n if (layerA !== layerB) {\n throw new Error(`${subject}: elements must be on the same layer`);\n }\n\n return layerA;\n }\n\n if (a instanceof UILayer) {\n return a;\n }\n if (isUILayerElement(a)) {\n return a.layer;\n }\n if (b instanceof UILayer) {\n return b;\n }\n if (isUILayerElement(b)) {\n return b.layer;\n }\n\n throw new Error(`${subject}: no valid subjects found`);\n}\n\n/**\n * Validates interpolation constraint subjects.\n * @param subject Constraint name for error messages\n * @param a First element\n * @param b Second element\n * @param c Element to interpolate\n * @param anchorA Anchor on element A\n * @param anchorB Anchor on element B\n * @returns Common layer for all subjects\n * @throws If subjects violate interpolation constraints\n */\nexport function assertValidInterpolationConstraintArguments(\n subject: string,\n a: unknown,\n b: unknown,\n c: unknown,\n anchorA: number,\n anchorB: number,\n): UILayer {\n if (process.env.NODE_ENV !== \"production\") {\n if (c instanceof UILayer) {\n throw new Error(`${subject}: C cannot be a layer`);\n }\n\n if (!isUILayerElement(c)) {\n throw new Error(`${subject}: C must be a UILayerElement`);\n }\n\n let layerA: UILayer;\n let layerB: UILayer;\n\n if (a instanceof UILayer || isUILayerElement(a)) {\n layerA = a instanceof UILayer ? a : a.layer;\n } else {\n throw new Error(`${subject}: A must be UILayer or UILayerElement`);\n }\n\n if (b instanceof UILayer || isUILayerElement(b)) {\n layerB = b instanceof UILayer ? b : b.layer;\n } else {\n throw new Error(`${subject}: B must be UILayer or UILayerElement`);\n }\n\n const layerC = c.layer;\n\n if (layerA !== layerB || layerA !== layerC) {\n throw new Error(`${subject}: all elements must be on the same layer`);\n }\n\n if (c === a || c === b) {\n throw new Error(`${subject}: C cannot be equal to A or B`);\n }\n\n if (a === b) {\n if (Math.abs(anchorA - anchorB) <= EPSILON) {\n throw new Error(\n `${subject}: when A and B are the same, anchorA and anchorB must differ by more than ${EPSILON}`,\n );\n }\n }\n\n return layerA;\n }\n\n if (isUILayerElement(a)) {\n return a.layer;\n }\n if (isUILayerElement(b)) {\n return b.layer;\n }\n if (a instanceof UILayer) {\n return a;\n }\n if (b instanceof UILayer) {\n return b;\n }\n\n throw new Error(`${subject}: no valid subjects found`);\n}\n","import type { UILayer } from \"../layers/UILayer/UILayer\";\nimport type { UISolverWrapperInterface } from \"../wrappers/UISolverWrapper/UISolverWrapper.Internal\";\n\n/** Base class for layout constraints */\nexport abstract class UIConstraint {\n /** Optional constraint name */\n public name: string;\n\n /** Constraint solver wrapper */\n protected readonly solverWrapper: UISolverWrapperInterface;\n\n /** @param layer Layer containing this constraint */\n constructor(\n public readonly layer: UILayer,\n name?: string,\n ) {\n this.solverWrapper = this.layer.solverWrapper;\n this.name = name ?? \"\";\n }\n}\n","import type { UILayer } from \"../../layers/UILayer/UILayer\";\nimport { UILayerEvent } from \"../../layers/UILayer/UILayer.Internal\";\nimport {\n resolveOrientation,\n UIOrientation,\n} from \"../../miscellaneous/UIOrientation\";\nimport type { UIPriority } from \"../../miscellaneous/UIPriority\";\nimport { resolvePriority } from \"../../miscellaneous/UIPriority\";\nimport type { UIRelation } from \"../../miscellaneous/UIRelation\";\nimport { resolveRelation } from \"../../miscellaneous/UIRelation\";\nimport { UIConstraint } from \"../UIConstraint\";\nimport type { UISingleParameterConstraintOptions } from \"./UISingleParameterConstraint.Internal\";\n\n/** Base class for constraints with priority, relation, and orientation */\nexport abstract class UISingleParameterConstraint extends UIConstraint {\n /** Constraint priority */\n private priorityInternal: UIPriority;\n /** Constraint relation */\n private relationInternal: UIRelation;\n /** Constraint orientation */\n private orientationInternal: UIOrientation;\n\n /** Solver constraint descriptor */\n protected abstract readonly constraint: number;\n\n /**\n * @param layer Layer containing this constraint\n * @param options Constraint configuration\n */\n constructor(\n layer: UILayer,\n options?: Partial<UISingleParameterConstraintOptions>,\n ) {\n super(layer, options?.name);\n this.priorityInternal = resolvePriority(options?.priority);\n this.relationInternal = resolveRelation(options?.relation);\n this.orientationInternal = resolveOrientation(options?.orientation);\n this.layer.on(UILayerEvent.ORIENTATION_CHANGED, this.onOrientationChange);\n }\n\n /** Constraint priority */\n public get priority(): UIPriority {\n return this.priorityInternal;\n }\n\n /** Constraint relation */\n public get relation(): UIRelation {\n return this.relationInternal;\n }\n\n /** When constraint is active */\n public get orientation(): UIOrientation {\n return this.orientationInternal;\n }\n\n /** Updates constraint priority */\n public set priority(value: UIPriority) {\n if (value !== this.priorityInternal) {\n this.priorityInternal = value;\n this.solverWrapper.setConstraintPriority(\n this.constraint,\n this.priorityInternal,\n );\n }\n }\n\n /** Updates constraint relation */\n public set relation(value: UIRelation) {\n if (value !== this.relationInternal) {\n this.relationInternal = value;\n this.solverWrapper.setConstraintRelation(\n this.constraint,\n this.relationInternal,\n );\n }\n }\n\n /** Updates when constraint is active */\n public set orientation(value: UIOrientation) {\n if (value !== this.orientationInternal) {\n this.orientationInternal = value;\n this.onOrientationChange();\n }\n }\n\n /** Removes constraint from solver and cleans up listeners */\n public destroy(): void {\n this.layer.off(UILayerEvent.ORIENTATION_CHANGED, this.onOrientationChange);\n this.solverWrapper.removeConstraint(this.constraint);\n }\n\n /**\n * Checks if constraint should be active for current orientation.\n * @returns True if orientation is ALWAYS or matches layer orientation\n */\n protected isConstraintEnabled(): boolean {\n return (\n this.orientationInternal === UIOrientation.ALWAYS ||\n this.orientationInternal === this.layer.orientation\n );\n }\n\n /** Updates constraint enabled state when layer orientation changes */\n private readonly onOrientationChange = (): void => {\n this.solverWrapper.setConstraintEnabled(\n this.constraint,\n this.isConstraintEnabled(),\n );\n };\n}\n","import { assertValidPositiveNumber } from \"../../miscellaneous/asserts\";\nimport type {\n UILayerElement,\n UIPlaneElement,\n} from \"../../miscellaneous/shared\";\nimport { UIExpression } from \"../../miscellaneous/UIExpression\";\nimport { UISingleParameterConstraint } from \"../UISingleParameterConstraint/UISingleParameterConstraint\";\nimport type { UIHeightConstraintOptions } from \"./UIHeightConstraint.Internal\";\n\n/** Fixes element height to constant value */\nexport class UIHeightConstraint extends UISingleParameterConstraint {\n /** Solver constraint descriptor */\n protected override readonly constraint: number;\n\n /** Current height value */\n private heightInternal: number;\n\n /**\n * @param element Element to constrain\n * @param options Height configuration. Defaults to element's current height.\n */\n constructor(\n private readonly element: UIPlaneElement & UILayerElement,\n options: Partial<UIHeightConstraintOptions> = {},\n ) {\n if (options.height !== undefined) {\n assertValidPositiveNumber(\n options.height,\n \"UIHeightConstraint.constructor.options.height\",\n );\n }\n\n super(element.layer, options);\n\n this.heightInternal = options.height ?? element.height;\n this.constraint = this.solverWrapper.createConstraint(\n new UIExpression(0, [[this.element.hVariable, 1]]),\n new UIExpression(this.heightInternal),\n this.relation,\n this.priority,\n this.isConstraintEnabled(),\n );\n }\n\n /** Current height in world units */\n public get height(): number {\n return this.heightInternal;\n }\n\n /** Updates height */\n public set height(value: number) {\n assertValidPositiveNumber(value, \"UIHeightConstraint.height\");\n if (this.heightInternal !== value) {\n this.heightInternal = value;\n this.solverWrapper.setConstraintRHS(\n this.constraint,\n new UIExpression(value),\n );\n }\n }\n}\n","import {\n assertValidConstraintArguments,\n assertValidNumber,\n} from \"../../miscellaneous/asserts\";\nimport type {\n UIPlaneElement,\n UIPointElement,\n} from \"../../miscellaneous/shared\";\nimport { isUIPlaneElement, isUIPointElement } from \"../../miscellaneous/shared\";\nimport { UIExpression } from \"../../miscellaneous/UIExpression\";\nimport { UISingleParameterConstraint } from \"../UISingleParameterConstraint/UISingleParameterConstraint\";\nimport type { UIHorizontalDistanceConstraintOptions } from \"./UIHorizontalDistanceConstraint.Internal\";\nimport { DEFAULT_ANCHOR } from \"./UIHorizontalDistanceConstraint.Internal\";\n\n/** Maintains horizontal distance between elements with configurable anchors */\nexport class UIHorizontalDistanceConstraint extends UISingleParameterConstraint {\n /** Solver constraint descriptor */\n protected override readonly constraint: number;\n\n /** Anchor on element A */\n private anchorAInternal: number;\n /** Anchor on element B */\n private anchorBInternal: number;\n /** Current distance */\n private distanceInternal: number;\n\n /**\n * @param a First element\n * @param b Second element\n * @param options Distance configuration\n */\n constructor(\n private readonly a: UIPointElement | UIPlaneElement,\n private readonly b: UIPointElement | UIPlaneElement,\n options: Partial<UIHorizontalDistanceConstraintOptions> = {},\n ) {\n if (options.anchorA !== undefined) {\n assertValidNumber(\n options.anchorA,\n \"UIHorizontalDistanceConstraint.constructor.options.anchorA\",\n );\n }\n if (options.anchorB !== undefined) {\n assertValidNumber(\n options.anchorB,\n \"UIHorizontalDistanceConstraint.constructor.options.anchorB\",\n );\n }\n if (options.distance !== undefined) {\n assertValidNumber(\n options.distance,\n \"UIHorizontalDistanceConstraint.constructor.options.distance\",\n );\n }\n\n super(\n assertValidConstraintArguments(\n a,\n b,\n \"UIHorizontalDistanceConstraint.constructor\",\n ),\n options,\n );\n\n this.anchorAInternal = options.anchorA ?? DEFAULT_ANCHOR;\n this.anchorBInternal = options.anchorB ?? DEFAULT_ANCHOR;\n this.distanceInternal = options.distance ?? 0;\n\n this.constraint = this.solverWrapper.createConstraint(\n this.buildLHS(),\n new UIExpression(this.distanceInternal),\n this.relation,\n this.priority,\n this.isConstraintEnabled(),\n );\n }\n\n /** Current distance in world units */\n public get distance(): number {\n return this.distanceInternal;\n }\n\n /** Anchor on element A (0 = left, 0.5 = center, 1 = right) */\n public get anchorA(): number {\n return this.anchorAInternal;\n }\n\n /** Anchor on element B (0 = left, 0.5 = center, 1 = right) */\n public get anchorB(): number {\n return this.anchorBInternal;\n }\n\n /** Updates distance */\n public set distance(value: number) {\n assertValidNumber(value, \"UIHorizontalDistanceConstraint.distance\");\n if (this.distanceInternal !== value) {\n this.distanceInternal = value;\n this.solverWrapper.setConstraintRHS(\n this.constraint,\n new UIExpression(this.distanceInternal),\n );\n }\n }\n\n /** Updates anchor on element A */\n public set anchorA(value: number) {\n assertValidNumber(value, \"UIHorizontalDistanceConstraint.anchorA\");\n if (this.anchorAInternal !== value) {\n this.anchorAInternal = value;\n this.solverWrapper.setConstraintLHS(this.constraint, this.buildLHS());\n }\n }\n\n /** Updates anchor on element B */\n public set anchorB(value: number) {\n assertValidNumber(value, \"UIHorizontalDistanceConstraint.anchorB\");\n if (this.anchorBInternal !== value) {\n this.anchorBInternal = value;\n this.solverWrapper.setConstraintLHS(this.constraint, this.buildLHS());\n }\n }\n\n /** Builds constraint expression for distance between anchored positions */\n private buildLHS(): UIExpression {\n let aExpression: UIExpression;\n let bExpression: UIExpression;\n\n if (isUIPlaneElement(this.a)) {\n aExpression = new UIExpression(0, [\n [this.a.xVariable, 1],\n [this.a.wVariable, this.anchorAInternal],\n ]);\n } else if (isUIPointElement(this.a)) {\n aExpression = new UIExpression().plus(this.a.xVariable, 1);\n } else {\n throw new Error(\n \"UIHorizontalDistanceConstraint.buildLHS.a: invalid element type\",\n );\n }\n\n if (isUIPlaneElement(this.b)) {\n bExpression = new UIExpression(0, [\n [this.b.xVariable, 1],\n [this.b.wVariable, this.anchorBInternal],\n ]);\n } else if (isUIPointElement(this.b)) {\n bExpression = new UIExpression().plus(this.b.xVariable, 1);\n } else {\n throw new Error(\n \"UIHorizontalDistanceConstraint.buildLHS.b: invalid element type\",\n );\n }\n\n return UIExpression.minus(bExpression, aExpression);\n }\n}\n","import type { UISingleParameterConstraintOptions } from \"../UISingleParameterConstraint/UISingleParameterConstraint.Internal\";\n\nexport const DEFAULT_ANCHOR = 0.5;\n\n/** Horizontal distance constraint options */\nexport interface UIHorizontalDistanceConstraintOptions\n extends UISingleParameterConstraintOptions {\n /** Anchor on element A (0 = left, 0.5 = center, 1 = right) */\n anchorA: number;\n /** Anchor on element B (0 = left, 0.5 = center, 1 = right) */\n anchorB: number;\n /** Distance in world units */\n distance: number;\n}\n","import {\n assertValidInterpolationConstraintArguments,\n assertValidNumber,\n} from \"../../miscellaneous/asserts\";\nimport type {\n UIPlaneElement,\n UIPointElement,\n} from \"../../miscellaneous/shared\";\nimport { isUIPlaneElement, isUIPointElement } from \"../../miscellaneous/shared\";\nimport { UIExpression } from \"../../miscellaneous/UIExpression\";\nimport { UISingleParameterConstraint } from \"../UISingleParameterConstraint/UISingleParameterConstraint\";\nimport type { UIHorizontalInterpolationConstraintOptions } from \"./UIHorizontalInterpolationConstraint.Internal\";\nimport {\n DEFAULT_ANCHOR,\n DEFAULT_T,\n} from \"./UIHorizontalInterpolationConstraint.Internal\";\n\n/** Positions element C horizontally between A and B based on interpolation factor */\nexport class UIHorizontalInterpolationConstraint extends UISingleParameterConstraint {\n /** Solver constraint descriptor */\n protected override readonly constraint: number;\n\n /** Anchor on element A */\n private anchorAInternal: number;\n /** Anchor on element B */\n private anchorBInternal: number;\n /** Anchor on element C */\n private anchorCInternal: number;\n /** Interpolation factor */\n private tInternal: number;\n\n /**\n * @param a First element\n * @param b Second element\n * @param c Element to position between A and B\n * @param options Interpolation configuration\n */\n constructor(\n private readonly a: UIPointElement | UIPlaneElement,\n private readonly b: UIPointElement | UIPlaneElement,\n private readonly c: UIPointElement | UIPlaneElement,\n options: Partial<UIHorizontalInterpolationConstraintOptions> = {},\n ) {\n if (options.anchorA !== undefined) {\n assertValidNumber(\n options.anchorA,\n \"UIHorizontalInterpolationConstraint.constructor.options.anchorA\",\n );\n }\n if (options.anchorB !== undefined) {\n assertValidNumber(\n options.anchorB,\n \"UIHorizontalInterpolationConstraint.constructor.options.anchorB\",\n );\n }\n if (options.anchorC !== undefined) {\n assertValidNumber(\n options.anchorC,\n \"UIHorizontalInterpolationConstraint.constructor.options.anchorC\",\n );\n }\n if (options.t !== undefined) {\n assertValidNumber(\n options.t,\n \"UIHorizontalInterpolationConstraint.constructor.options.t\",\n );\n }\n\n const anchorA = options.anchorA ?? DEFAULT_ANCHOR;\n const anchorB = options.anchorB ?? DEFAULT_ANCHOR;\n\n super(\n assertValidInterpolationConstraintArguments(\n \"UIHorizontalInterpolationConstraint.constructor\",\n a,\n b,\n c,\n anchorA,\n anchorB,\n ),\n options,\n );\n\n this.anchorAInternal = anchorA;\n this.anchorBInternal = anchorA;\n this.anchorCInternal = options.anchorC ?? DEFAULT_ANCHOR;\n this.tInternal = options.t ?? DEFAULT_T;\n\n this.constraint = this.solverWrapper.createConstraint(\n this.buildLHS(),\n new UIExpression(0),\n this.relation,\n this.priority,\n this.isConstraintEnabled(),\n );\n }\n\n /** Interpolation factor (0 = A position, 1 = B position) */\n public get t(): number {\n return this.tInternal;\n }\n\n /** Anchor on element A (0 = left, 0.5 = center, 1 = right) */\n public get anchorA(): number {\n return this.anchorAInternal;\n }\n\n /** Anchor on element B (0 = left, 0.5 = center, 1 = right) */\n public get anchorB(): number {\n return this.anchorBInternal;\n }\n\n /** Anchor on element C (0 = left, 0.5 = center, 1 = right) */\n public get anchorC(): number {\n return this.anchorCInternal;\n }\n\n /** Updates interpolation factor */\n public set t(value: number) {\n assertValidNumber(value, \"UIHorizontalInterpolationConstraint.t\");\n if (this.tInternal !== value) {\n this.tInternal = value;\n this.solverWrapper.setConstraintLHS(this.constraint, this.buildLHS());\n }\n }\n\n /** Updates anchor on element A */\n public set anchorA(value: number) {\n assertValidNumber(value, \"UIHorizontalInterpolationConstraint.anchorA\");\n if (this.anchorAInternal !== value) {\n this.anchorAInternal = value;\n this.solverWrapper.setConstraintLHS(this.constraint, this.buildLHS());\n }\n }\n\n /** Updates anchor on element B */\n public set anchorB(value: number) {\n assertValidNumber(value, \"UIHorizontalInterpolationConstraint.anchorB\");\n if (this.anchorBInternal !== value) {\n this.anchorBInternal = value;\n this.solverWrapper.setConstraintLHS(this.constraint, this.buildLHS());\n }\n }\n\n /** Updates anchor on element C */\n public set anchorC(value: number) {\n assertValidNumber(value, \"UIHorizontalInterpolationConstraint.anchorC\");\n if (this.anchorCInternal !== value) {\n this.anchorCInternal = value;\n this.solverWrapper.setConstraintLHS(this.constraint, this.buildLHS());\n }\n }\n\n /** Builds constraint expression: C - A*(1-t) - B*t = 0 */\n private buildLHS(): UIExpression {\n let aExpression: UIExpression;\n let bExpression: UIExpression;\n let cExpression: UIExpression;\n\n if (isUIPlaneElement(this.a)) {\n aExpression = new UIExpression(0, [\n [this.a.xVariable, 1],\n [this.a.wVariable, this.anchorAInternal],\n ]);\n } else if (isUIPointElement(this.a)) {\n aExpression = new UIExpression().plus(this.a.xVariable, 1);\n } else {\n throw new Error(\n \"UIHorizontalInterpolationConstraint.buildLHS.a: invalid element type\",\n );\n }\n\n if (isUIPlaneElement(this.b)) {\n bExpression = new UIExpression(0, [\n [this.b.xVariable, 1],\n [this.b.wVariable, this.anchorBInternal],\n ]);\n } else if (isUIPointElement(this.b)) {\n bExpression = new UIExpression().plus(this.b.xVariable, 1);\n } else {\n throw new Error(\n \"UIHorizontalInterpolationConstraint.buildLHS.b: invalid element type\",\n );\n }\n\n if (isUIPlaneElement(this.c)) {\n cExpression = new UIExpression(0, [\n [this.c.xVariable, 1],\n [this.c.wVariable, this.anchorCInternal],\n ]);\n } else if (isUIPointElement(this.c)) {\n cExpression = new UIExpression().plus(this.c.xVariable, 1);\n } else {\n throw new Error(\n \"UIHorizontalInterpolationConstraint.buildLHS.c: invalid element type\",\n );\n }\n\n // C - A*(1-t) - B*t = 0\n const aScaled = aExpression.clone().multiply(1 - this.tInternal);\n const bScaled = bExpression.clone().multiply(this.tInternal);\n return UIExpression.minus(\n UIExpression.minus(cExpression, aScaled),\n bScaled,\n );\n }\n}\n","import type { UISingleParameterConstraintOptions } from \"../UISingleParameterConstraint/UISingleParameterConstraint.Internal\";\n\nexport const DEFAULT_ANCHOR = 0.5;\nexport const DEFAULT_T = 0.5;\n\n/** Horizontal interpolation constraint options */\nexport interface UIHorizontalInterpolationConstraintOptions\n extends UISingleParameterConstraintOptions {\n /** Anchor on element A (0 = left, 0.5 = center, 1 = right) */\n anchorA: number;\n /** Anchor on element B (0 = left, 0.5 = center, 1 = right) */\n anchorB: number;\n /** Anchor on element C (0 = left, 0.5 = center, 1 = right) */\n anchorC: number;\n /** Interpolation factor (0 = A position, 1 = B position) */\n t: number;\n}\n","import {\n assertValidConstraintArguments,\n assertValidPositiveNumber,\n} from \"../../miscellaneous/asserts\";\nimport type { UIPlaneElement } from \"../../miscellaneous/shared\";\nimport { UIExpression } from \"../../miscellaneous/UIExpression\";\nimport { UISingleParameterConstraint } from \"../UISingleParameterConstraint/UISingleParameterConstraint\";\nimport type { UIHorizontalProportionConstraintOptions } from \"./UIHorizontalProportionConstraint.Internal\";\n\n/** Maintains proportional width relationship (A.width * proportion = B.width) */\nexport class UIHorizontalProportionConstraint extends UISingleParameterConstraint {\n protected override readonly constraint: number;\n private proportionInternal: number;\n\n /**\n * @param a First element\n * @param b Second element\n * @param options Proportion configuration\n */\n constructor(\n private readonly a: UIPlaneElement,\n private readonly b: UIPlaneElement,\n options: Partial<UIHorizontalProportionConstraintOptions> = {},\n ) {\n if (options.proportion !== undefined) {\n assertValidPositiveNumber(\n options.proportion,\n \"UIHorizontalProportionConstraint.constructor.options.proportion\",\n );\n }\n\n super(\n assertValidConstraintArguments(\n a,\n b,\n \"UIHorizontalProportionConstraint.constructor\",\n ),\n options,\n );\n\n this.proportionInternal = options.proportion ?? 1;\n this.constraint = this.solverWrapper.createConstraint(\n new UIExpression(0),\n this.buildRHS(),\n this.relation,\n this.priority,\n this.isConstraintEnabled(),\n );\n }\n\n /** Current proportion multiplier */\n public get proportion(): number {\n return this.proportionInternal;\n }\n\n /** Updates proportion multiplier */\n public set proportion(value: number) {\n assertValidPositiveNumber(\n value,\n \"UIHorizontalProportionConstraint.proportion\",\n );\n if (this.proportionInternal !== value) {\n this.proportionInternal = value;\n this.solverWrapper.setConstraintRHS(this.constraint, this.buildRHS());\n }\n }\n\n /** Builds constraint expression for proportional relationship */\n private buildRHS(): UIExpression {\n return UIExpression.minus(\n new UIExpression(0, [[this.a.wVariable, this.proportionInternal]]),\n new UIExpression(0, [[this.b.wVariable, 1]]),\n );\n }\n}\n","import {\n assertValidConstraintArguments,\n assertValidNumber,\n} from \"../../miscellaneous/asserts\";\nimport type {\n UIPlaneElement,\n UIPointElement,\n} from \"../../miscellaneous/shared\";\nimport { isUIPlaneElement, isUIPointElement } from \"../../miscellaneous/shared\";\nimport { UIExpression } from \"../../miscellaneous/UIExpression\";\nimport { UISingleParameterConstraint } from \"../UISingleParameterConstraint/UISingleParameterConstraint\";\nimport type { UIVerticalDistanceConstraintOptions } from \"./UIVerticalDistanceConstraint.Internal\";\nimport { DEFAULT_ANCHOR } from \"./UIVerticalDistanceConstraint.Internal\";\n\n/** Maintains vertical distance between elements with configurable anchors */\nexport class UIVerticalDistanceConstraint extends UISingleParameterConstraint {\n protected override readonly constraint: number;\n\n private anchorAInternal: number;\n private anchorBInternal: number;\n private distanceInternal: number;\n\n /**\n * @param a First element\n * @param b Second element\n * @param options Distance configuration\n */\n constructor(\n private readonly a: UIPointElement | UIPlaneElement,\n private readonly b: UIPointElement | UIPlaneElement,\n options: Partial<UIVerticalDistanceConstraintOptions> = {},\n ) {\n if (options.anchorA !== undefined) {\n assertValidNumber(\n options.anchorA,\n \"UIVerticalDistanceConstraint.constructor.options.anchorA\",\n );\n }\n if (options.anchorB !== undefined) {\n assertValidNumber(\n options.anchorB,\n \"UIVerticalDistanceConstraint.constructor.options.anchorB\",\n );\n }\n if (options.distance !== undefined) {\n assertValidNumber(\n options.distance,\n \"UIVerticalDistanceConstraint.constructor.options.distance\",\n );\n }\n\n super(\n assertValidConstraintArguments(\n a,\n b,\n \"UIVerticalDistanceConstraint.constructor\",\n ),\n options,\n );\n\n this.anchorAInternal = options.anchorA ?? DEFAULT_ANCHOR;\n this.anchorBInternal = options.anchorB ?? DEFAULT_ANCHOR;\n this.distanceInternal = options.distance ?? 0;\n\n this.constraint = this.solverWrapper.createConstraint(\n this.buildLHS(),\n new UIExpression(this.distanceInternal),\n this.relation,\n this.priority,\n this.isConstraintEnabled(),\n );\n }\n\n /** Current distance in world units */\n public get distance(): number {\n return this.distanceInternal;\n }\n\n /** Anchor on element A (0 = bottom, 0.5 = center, 1 = top) */\n public get anchorA(): number {\n return this.anchorAInternal;\n }\n\n /** Anchor on element B (0 = bottom, 0.5 = center, 1 = top) */\n public get anchorB(): number {\n return this.anchorBInternal;\n }\n\n /** Updates distance */\n public set distance(value: number) {\n assertValidNumber(value, \"UIVerticalDistanceConstraint.distance\");\n if (this.distanceInternal !== value) {\n this.distanceInternal = value;\n this.solverWrapper.setConstraintRHS(\n this.constraint,\n new UIExpression(this.distanceInternal),\n );\n }\n }\n\n /** Updates anchor on element A */\n public set anchorA(value: number) {\n assertValidNumber(value, \"UIVerticalDistanceConstraint.anchorA\");\n if (this.anchorAInternal !== value) {\n this.anchorAInternal = value;\n this.solverWrapper.setConstraintLHS(this.constraint, this.buildLHS());\n }\n }\n\n /** Updates anchor on element B */\n public set anchorB(value: number) {\n assertValidNumber(value, \"UIVerticalDistanceConstraint.anchorB\");\n if (this.anchorBInternal !== value) {\n this.anchorBInternal = value;\n this.solverWrapper.setConstraintLHS(this.constraint, this.buildLHS());\n }\n }\n\n /** Builds constraint expression for distance between anchored positions */\n private buildLHS(): UIExpression {\n let aExpression: UIExpression;\n let bExpression: UIExpression;\n\n if (isUIPlaneElement(this.a)) {\n aExpression = new UIExpression(0, [\n [this.a.yVariable, 1],\n [this.a.hVariable, this.anchorAInternal],\n ]);\n } else if (isUIPointElement(this.a)) {\n aExpression = new UIExpression().plus(this.a.yVariable, 1);\n } else {\n throw new Error(\n \"UIVerticalDistanceConstraint.buildLHS.a: invalid element type\",\n );\n }\n\n if (isUIPlaneElement(this.b)) {\n bExpression = new UIExpression(0, [\n [this.b.yVariable, 1],\n [this.b.hVariable, this.anchorBInternal],\n ]);\n } else if (isUIPointElement(this.b)) {\n bExpression = new UIExpression().plus(this.b.yVariable, 1);\n } else {\n throw new Error(\n \"UIVerticalDistanceConstraint.buildLHS.b: invalid element type\",\n );\n }\n\n return UIExpression.minus(bExpression, aExpression);\n }\n}\n","import type { UISingleParameterConstraintOptions } from \"../UISingleParameterConstraint/UISingleParameterConstraint.Internal\";\n\nexport const DEFAULT_ANCHOR = 0.5;\n\n/** Vertical distance constraint options */\nexport interface UIVerticalDistanceConstraintOptions\n extends UISingleParameterConstraintOptions {\n /** Anchor on element A (0 = bottom, 0.5 = center, 1 = top) */\n anchorA: number;\n /** Anchor on element B (0 = bottom, 0.5 = center, 1 = top) */\n anchorB: number;\n /** Distance in world units */\n distance: number;\n}\n","import {\n assertValidInterpolationConstraintArguments,\n assertValidNumber,\n} from \"../../miscellaneous/asserts\";\nimport type {\n UIPlaneElement,\n UIPointElement,\n} from \"../../miscellaneous/shared\";\nimport { isUIPlaneElement, isUIPointElement } from \"../../miscellaneous/shared\";\nimport { UIExpression } from \"../../miscellaneous/UIExpression\";\nimport { UISingleParameterConstraint } from \"../UISingleParameterConstraint/UISingleParameterConstraint\";\nimport type { UIVerticalInterpolationConstraintOptions } from \"./UIVerticalInterpolationConstraint.Internal\";\nimport {\n DEFAULT_ANCHOR,\n DEFAULT_T,\n} from \"./UIVerticalInterpolationConstraint.Internal\";\n\n/** Positions element C vertically between A and B based on interpolation factor */\nexport class UIVerticalInterpolationConstraint extends UISingleParameterConstraint {\n /** Solver constraint descriptor */\n protected override readonly constraint: number;\n\n /** Anchor on element A */\n private anchorAInternal: number;\n /** Anchor on element B */\n private anchorBInternal: number;\n /** Anchor on element C */\n private anchorCInternal: number;\n /** Interpolation factor */\n private tInternal: number;\n\n /**\n * @param a First element\n * @param b Second element\n * @param c Element to position between A and B\n * @param options Interpolation configuration\n */\n constructor(\n private readonly a: UIPointElement | UIPlaneElement,\n private readonly b: UIPointElement | UIPlaneElement,\n private readonly c: UIPointElement | UIPlaneElement,\n options: Partial<UIVerticalInterpolationConstraintOptions> = {},\n ) {\n if (options.anchorA !== undefined) {\n assertValidNumber(\n options.anchorA,\n \"UIVerticalInterpolationConstraint.constructor.options.anchorA\",\n );\n }\n if (options.anchorB !== undefined) {\n assertValidNumber(\n options.anchorB,\n \"UIVerticalInterpolationConstraint.constructor.options.anchorB\",\n );\n }\n if (options.anchorC !== undefined) {\n assertValidNumber(\n options.anchorC,\n \"UIVerticalInterpolationConstraint.constructor.options.anchorC\",\n );\n }\n if (options.t !== undefined) {\n assertValidNumber(\n options.t,\n \"UIVerticalInterpolationConstraint.constructor.options.t\",\n );\n }\n\n const anchorA = options.anchorA ?? DEFAULT_ANCHOR;\n const anchorB = options.anchorB ?? DEFAULT_ANCHOR;\n\n super(\n assertValidInterpolationConstraintArguments(\n \"UIVerticalInterpolationConstraint.constructor\",\n a,\n b,\n c,\n anchorA,\n anchorB,\n ),\n options,\n );\n\n this.anchorAInternal = anchorA;\n this.anchorBInternal = anchorA;\n this.anchorCInternal = options.anchorC ?? DEFAULT_ANCHOR;\n this.tInternal = options.t ?? DEFAULT_T;\n\n this.constraint = this.solverWrapper.createConstraint(\n this.buildLHS(),\n new UIExpression(0),\n this.relation,\n this.priority,\n this.isConstraintEnabled(),\n );\n }\n\n /** Interpolation factor (0 = A position, 1 = B position) */\n public get t(): number {\n return this.tInternal;\n }\n\n /** Anchor on element A (0 = bottom, 0.5 = center, 1 = top) */\n public get anchorA(): number {\n return this.anchorAInternal;\n }\n\n /** Anchor on element B (0 = bottom, 0.5 = center, 1 = top) */\n public get anchorB(): number {\n return this.anchorBInternal;\n }\n\n /** Anchor on element C (0 = bottom, 0.5 = center, 1 = top) */\n public get anchorC(): number {\n return this.anchorCInternal;\n }\n\n /** Updates interpolation factor */\n public set t(value: number) {\n assertValidNumber(value, \"UIVerticalInterpolationConstraint.t\");\n if (this.tInternal !== value) {\n this.tInternal = value;\n this.solverWrapper.setConstraintLHS(this.constraint, this.buildLHS());\n }\n }\n\n /** Updates anchor on element A */\n public set anchorA(value: number) {\n assertValidNumber(value, \"UIVerticalInterpolationConstraint.anchorA\");\n if (this.anchorAInternal !== value) {\n this.anchorAInternal = value;\n this.solverWrapper.setConstraintLHS(this.constraint, this.buildLHS());\n }\n }\n\n /** Updates anchor on element B */\n public set anchorB(value: number) {\n assertValidNumber(value, \"UIVerticalInterpolationConstraint.anchorB\");\n if (this.anchorBInternal !== value) {\n this.anchorBInternal = value;\n this.solverWrapper.setConstraintLHS(this.constraint, this.buildLHS());\n }\n }\n\n /** Updates anchor on element C */\n public set anchorC(value: number) {\n assertValidNumber(value, \"UIVerticalInterpolationConstraint.anchorC\");\n if (this.anchorCInternal !== value) {\n this.anchorCInternal = value;\n this.solverWrapper.setConstraintLHS(this.constraint, this.buildLHS());\n }\n }\n\n /** Builds constraint expression: C - A*(1-t) - B*t = 0 */\n private buildLHS(): UIExpression {\n let aExpression: UIExpression;\n let bExpression: UIExpression;\n let cExpression: UIExpression;\n\n if (isUIPlaneElement(this.a)) {\n aExpression = new UIExpression(0, [\n [this.a.yVariable, 1],\n [this.a.hVariable, this.anchorAInternal],\n ]);\n } else if (isUIPointElement(this.a)) {\n aExpression = new UIExpression().plus(this.a.yVariable, 1);\n } else {\n throw new Error(\n \"UIVerticalInterpolationConstraint.buildLHS.a: invalid element type\",\n );\n }\n\n if (isUIPlaneElement(this.b)) {\n bExpression = new UIExpression(0, [\n [this.b.yVariable, 1],\n [this.b.hVariable, this.anchorBInternal],\n ]);\n } else if (isUIPointElement(this.b)) {\n bExpression = new UIExpression().plus(this.b.yVariable, 1);\n } else {\n throw new Error(\n \"UIVerticalInterpolationConstraint.buildLHS.b: invalid element type\",\n );\n }\n\n if (isUIPlaneElement(this.c)) {\n cExpression = new UIExpression(0, [\n [this.c.yVariable, 1],\n [this.c.hVariable, this.anchorCInternal],\n ]);\n } else if (isUIPointElement(this.c)) {\n cExpression = new UIExpression().plus(this.c.yVariable, 1);\n } else {\n throw new Error(\n \"UIVerticalInterpolationConstraint.buildLHS.c: invalid element type\",\n );\n }\n\n // C - A*(1-t) - B*t = 0\n const aScaled = aExpression.clone().multiply(1 - this.tInternal);\n const bScaled = bExpression.clone().multiply(this.tInternal);\n return UIExpression.minus(\n UIExpression.minus(cExpression, aScaled),\n bScaled,\n );\n }\n}\n","import type { UISingleParameterConstraintOptions } from \"../UISingleParameterConstraint/UISingleParameterConstraint.Internal\";\n\nexport const DEFAULT_ANCHOR = 0.5;\nexport const DEFAULT_T = 0.5;\n\n/** Vertical interpolation constraint options */\nexport interface UIVerticalInterpolationConstraintOptions\n extends UISingleParameterConstraintOptions {\n /** Anchor on element A (0 = bottom, 0.5 = center, 1 = top) */\n anchorA: number;\n /** Anchor on element B (0 = bottom, 0.5 = center, 1 = top) */\n anchorB: number;\n /** Anchor on element C (0 = bottom, 0.5 = center, 1 = top) */\n anchorC: number;\n /** Interpolation factor (0 = A position, 1 = B position) */\n t: number;\n}\n","import {\n assertValidConstraintArguments,\n assertValidPositiveNumber,\n} from \"../../miscellaneous/asserts\";\nimport type { UIPlaneElement } from \"../../miscellaneous/shared\";\nimport { UIExpression } from \"../../miscellaneous/UIExpression\";\nimport { UISingleParameterConstraint } from \"../UISingleParameterConstraint/UISingleParameterConstraint\";\nimport type { UIVerticalProportionConstraintOptions } from \"./UIVerticalProportionConstraint.Internal\";\n\n/** Maintains proportional height relationship (A.height * proportion = B.height) */\nexport class UIVerticalProportionConstraint extends UISingleParameterConstraint {\n protected override readonly constraint: number;\n private proportionInternal: number;\n\n /**\n * @param a First element\n * @param b Second element\n * @param options Proportion configuration\n */\n constructor(\n private readonly a: UIPlaneElement,\n private readonly b: UIPlaneElement,\n options: Partial<UIVerticalProportionConstraintOptions> = {},\n ) {\n if (options.proportion !== undefined) {\n assertValidPositiveNumber(\n options.proportion,\n \"UIVerticalProportionConstraint.constructor.options.proportion\",\n );\n }\n\n super(\n assertValidConstraintArguments(\n a,\n b,\n \"UIVerticalProportionConstraint.constructor\",\n ),\n options,\n );\n\n this.proportionInternal = options.proportion ?? 1;\n this.constraint = this.solverWrapper.createConstraint(\n new UIExpression(0),\n this.buildRHS(),\n this.relation,\n this.priority,\n this.isConstraintEnabled(),\n );\n }\n\n /** Current proportion multiplier */\n public get proportion(): number {\n return this.proportionInternal;\n }\n\n /** Updates proportion multiplier */\n public set proportion(value: number) {\n assertValidPositiveNumber(\n value,\n \"UIVerticalProportionConstraint.proportion\",\n );\n if (this.proportionInternal !== value) {\n this.proportionInternal = value;\n this.solverWrapper.setConstraintRHS(this.constraint, this.buildRHS());\n }\n }\n\n /** Builds constraint expression for proportional relationship */\n private buildRHS(): UIExpression {\n return UIExpression.minus(\n new UIExpression(0, [[this.a.hVariable, this.proportionInternal]]),\n new UIExpression(0, [[this.b.hVariable, 1]]),\n );\n }\n}\n","import { assertValidPositiveNumber } from \"../../miscellaneous/asserts\";\nimport type {\n UILayerElement,\n UIPlaneElement,\n} from \"../../miscellaneous/shared\";\nimport { UIExpression } from \"../../miscellaneous/UIExpression\";\nimport { UISingleParameterConstraint } from \"../UISingleParameterConstraint/UISingleParameterConstraint\";\nimport type { UIWidthConstraintOptions } from \"./UIWidthConstraint.Internal\";\n\n/** Fixes element width to constant value */\nexport class UIWidthConstraint extends UISingleParameterConstraint {\n /** Solver constraint descriptor */\n protected override readonly constraint: number;\n\n /** Current width value */\n private widthInternal: number;\n\n /**\n * @param element Element to constrain\n * @param options Width configuration. Defaults to element's current width.\n */\n constructor(\n private readonly element: UIPlaneElement & UILayerElement,\n options: Partial<UIWidthConstraintOptions> = {},\n ) {\n if (options.width !== undefined) {\n assertValidPositiveNumber(\n options.width,\n \"UIWidthConstraint.constructor.options.width\",\n );\n }\n\n super(element.layer, options);\n\n this.widthInternal = options.width ?? element.width;\n this.constraint = this.solverWrapper.createConstraint(\n new UIExpression(0, [[this.element.wVariable, 1]]),\n new UIExpression(this.widthInternal),\n this.relation,\n this.priority,\n this.isConstraintEnabled(),\n );\n }\n\n /** Current width in world units */\n public get width(): number {\n return this.widthInternal;\n }\n\n /** Updates width */\n public set width(value: number) {\n assertValidPositiveNumber(value, \"UIWidthConstraint.width\");\n if (this.widthInternal !== value) {\n this.widthInternal = value;\n this.solverWrapper.setConstraintRHS(\n this.constraint,\n new UIExpression(value),\n );\n }\n }\n}\n","import type { UIOrientation } from \"../../miscellaneous/UIOrientation\";\nimport type { UIPriority } from \"../../miscellaneous/UIPriority\";\nimport type { UIRelation } from \"../../miscellaneous/UIRelation\";\n\n/** Horizontal and vertical values object */\nexport interface UIType2DObject<T> {\n /** Horizontal value */\n h?: T;\n /** Vertical value */\n v?: T;\n}\n\n/** Horizontal and vertical values as object, tuple, or single value */\nexport type UIType2D<T> = UIType2DObject<T> | [T, T] | T;\n\n/**\n * Normalizes UIType2D input to object form.\n * @param value Object, tuple, or single value\n * @returns Normalized object with h and v properties\n */\nexport function normalizeUIType2D<T>(\n value: UIType2D<T> | undefined,\n): UIType2DObject<T> {\n if (value === undefined) {\n return {};\n }\n if (Array.isArray(value)) {\n return { h: value[0], v: value[1] };\n }\n if (\n typeof value === \"object\" &&\n value !== null &&\n (\"h\" in value || \"v\" in value)\n ) {\n return value;\n }\n return { h: value as T, v: value as T };\n}\n\n/** Base 2D constraint options */\nexport interface UIConstraint2DOptions {\n /** Priority for each axis */\n priority: UIType2D<UIPriority>;\n /** Relation for each axis */\n relation: UIType2D<UIRelation>;\n /** Orientation for each axis */\n orientation: UIType2D<UIOrientation>;\n}\n\n/** 2D size constraint options */\nexport interface UIConstraintSize2DOptions extends UIConstraint2DOptions {\n /** Width and height */\n size: UIType2D<number>;\n}\n\n/** 2D distance constraint options */\nexport interface UIConstraintDistance2DOptions extends UIConstraint2DOptions {\n /** Anchor on element A for each axis */\n anchorA: UIType2D<number>;\n /** Anchor on element B for each axis */\n anchorB: UIType2D<number>;\n /** Distance for each axis */\n distance: UIType2D<number>;\n}\n\n/** 2D proportion constraint options */\nexport interface UIConstraintProportion2DOptions extends UIConstraint2DOptions {\n /** Proportion for each axis */\n proportion: UIType2D<number>;\n}\n\n/** 2D interpolation constraint options */\nexport interface UIConstraintInterpolation2DOptions\n extends UIConstraint2DOptions {\n /** Anchor on element A for each axis */\n anchorA: UIType2D<number>;\n /** Anchor on element B for each axis */\n anchorB: UIType2D<number>;\n /** Anchor on element C for each axis */\n anchorC: UIType2D<number>;\n /** Interpolation factor for each axis */\n t: UIType2D<number>;\n}\n\n/** Horizontal and vertical constraint pair */\nexport interface UIConstraint2DResult<TH, TV> {\n /** Horizontal constraint */\n h: TH;\n /** Vertical constraint */\n v: TV;\n}\n","import type { UIElement } from \"../../elements/UIElement/UIElement\";\nimport type {\n UIPlaneElement,\n UIPointElement,\n} from \"../../miscellaneous/shared\";\nimport { UIHeightConstraint } from \"../UIHeightConstraint/UIHeightConstraint\";\nimport { UIHorizontalDistanceConstraint } from \"../UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint\";\nimport { UIHorizontalInterpolationConstraint } from \"../UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint\";\nimport { UIHorizontalProportionConstraint } from \"../UIHorizontalProportionConstraint/UIHorizontalProportionConstraint\";\nimport { UIVerticalDistanceConstraint } from \"../UIVerticalDistanceConstraint/UIVerticalDistanceConstraint\";\nimport { UIVerticalInterpolationConstraint } from \"../UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint\";\nimport { UIVerticalProportionConstraint } from \"../UIVerticalProportionConstraint/UIVerticalProportionConstraint\";\nimport { UIWidthConstraint } from \"../UIWidthConstraint/UIWidthConstraint\";\nimport type {\n UIConstraint2DResult,\n UIConstraintDistance2DOptions,\n UIConstraintInterpolation2DOptions,\n UIConstraintProportion2DOptions,\n UIConstraintSize2DOptions,\n} from \"./UIConstraint2DBuilder.Internal\";\nimport { normalizeUIType2D } from \"./UIConstraint2DBuilder.Internal\";\n\n/** Builder for paired horizontal and vertical constraints */\nexport class UIConstraint2DBuilder {\n /**\n * Creates width and height constraints.\n * @param element Element to constrain\n * @param options Size configuration for both axes\n * @returns Width and height constraints\n */\n public static size(\n element: UIElement,\n options: Partial<UIConstraintSize2DOptions> = {},\n ): UIConstraint2DResult<UIWidthConstraint, UIHeightConstraint> {\n const size = normalizeUIType2D(options.size);\n const priority = normalizeUIType2D(options.priority);\n const relation = normalizeUIType2D(options.relation);\n const orientation = normalizeUIType2D(options.orientation);\n\n return {\n h: new UIWidthConstraint(element, {\n width: size.h,\n priority: priority.h,\n relation: relation.h,\n orientation: orientation.h,\n }),\n v: new UIHeightConstraint(element, {\n height: size.v,\n priority: priority.v,\n relation: relation.v,\n orientation: orientation.v,\n }),\n };\n }\n\n /**\n * Creates horizontal and vertical distance constraints.\n * @param a First element\n * @param b Second element\n * @param options Distance configuration for both axes\n * @returns Horizontal and vertical distance constraints\n */\n public static distance(\n a: UIPointElement | UIPlaneElement,\n b: UIPointElement | UIPlaneElement,\n options: Partial<UIConstraintDistance2DOptions> = {},\n ): UIConstraint2DResult<\n UIHorizontalDistanceConstraint,\n UIVerticalDistanceConstraint\n > {\n const anchorA = normalizeUIType2D(options.anchorA);\n const anchorB = normalizeUIType2D(options.anchorB);\n const distance = normalizeUIType2D(options.distance);\n const priority = normalizeUIType2D(options.priority);\n const relation = normalizeUIType2D(options.relation);\n const orientation = normalizeUIType2D(options.orientation);\n\n return {\n h: new UIHorizontalDistanceConstraint(a, b, {\n anchorA: anchorA.h,\n anchorB: anchorB.h,\n distance: distance.h,\n priority: priority.h,\n relation: relation.h,\n orientation: orientation.h,\n }),\n v: new UIVerticalDistanceConstraint(a, b, {\n anchorA: anchorA.v,\n anchorB: anchorB.v,\n distance: distance.v,\n priority: priority.v,\n relation: relation.v,\n orientation: orientation.v,\n }),\n };\n }\n\n /**\n * Creates horizontal and vertical proportion constraints.\n * @param a Element with proportional dimensions\n * @param b Target element\n * @param options Proportion configuration for both axes\n * @returns Horizontal and vertical proportion constraints\n */\n public static proportion(\n a: UIPlaneElement,\n b: UIPlaneElement,\n options: Partial<UIConstraintProportion2DOptions> = {},\n ): UIConstraint2DResult<\n UIHorizontalProportionConstraint,\n UIVerticalProportionConstraint\n > {\n const proportion = normalizeUIType2D(options.proportion);\n const priority = normalizeUIType2D(options.priority);\n const relation = normalizeUIType2D(options.relation);\n const orientation = normalizeUIType2D(options.orientation);\n\n return {\n h: new UIHorizontalProportionConstraint(a, b, {\n proportion: proportion.h,\n priority: priority.h,\n relation: relation.h,\n orientation: orientation.h,\n }),\n v: new UIVerticalProportionConstraint(a, b, {\n proportion: proportion.v,\n priority: priority.v,\n relation: relation.v,\n orientation: orientation.v,\n }),\n };\n }\n\n /**\n * Creates horizontal and vertical interpolation constraints.\n * @param a First element\n * @param b Second element\n * @param c Element to position between A and B\n * @param options Interpolation configuration for both axes\n * @returns Horizontal and vertical interpolation constraints\n */\n public static interpolation(\n a: UIPointElement | UIPlaneElement,\n b: UIPointElement | UIPlaneElement,\n c: UIPointElement | UIPlaneElement,\n options: Partial<UIConstraintInterpolation2DOptions> = {},\n ): UIConstraint2DResult<\n UIHorizontalInterpolationConstraint,\n UIVerticalInterpolationConstraint\n > {\n const anchorA = normalizeUIType2D(options.anchorA);\n const anchorB = normalizeUIType2D(options.anchorB);\n const anchorC = normalizeUIType2D(options.anchorC);\n const t = normalizeUIType2D(options.t);\n const priority = normalizeUIType2D(options.priority);\n const relation = normalizeUIType2D(options.relation);\n const orientation = normalizeUIType2D(options.orientation);\n\n return {\n h: new UIHorizontalInterpolationConstraint(a, b, c, {\n anchorA: anchorA.h,\n anchorB: anchorB.h,\n anchorC: anchorC.h,\n t: t.h,\n priority: priority.h,\n relation: relation.h,\n orientation: orientation.h,\n }),\n v: new UIVerticalInterpolationConstraint(a, b, c, {\n anchorA: anchorA.v,\n anchorB: anchorB.v,\n anchorC: anchorC.v,\n t: t.v,\n priority: priority.v,\n relation: relation.v,\n orientation: orientation.v,\n }),\n };\n }\n}\n","import { assertValidPositiveNumber } from \"../../miscellaneous/asserts\";\nimport type {\n UILayerElement,\n UIPlaneElement,\n} from \"../../miscellaneous/shared\";\nimport { UIExpression } from \"../../miscellaneous/UIExpression\";\nimport { UISingleParameterConstraint } from \"../UISingleParameterConstraint/UISingleParameterConstraint\";\nimport type { UIAspectConstraintOptions } from \"./UIAspectConstraint.Internal\";\n\n/** Maintains element aspect ratio (width = height * aspect) */\nexport class UIAspectConstraint extends UISingleParameterConstraint {\n /** Solver constraint descriptor */\n protected override readonly constraint: number;\n\n /** Current aspect ratio */\n private aspectInternal: number;\n\n /**\n * @param element Element to constrain\n * @param options Aspect configuration. Defaults to element's current ratio.\n */\n constructor(\n private readonly element: UIPlaneElement & UILayerElement,\n options: Partial<UIAspectConstraintOptions> = {},\n ) {\n if (options.aspect !== undefined) {\n assertValidPositiveNumber(\n options.aspect,\n \"UIAspectConstraint.constructor.options.aspect\",\n );\n }\n\n super(element.layer, options);\n\n this.aspectInternal = options.aspect ?? element.width / element.height;\n this.constraint = this.solverWrapper.createConstraint(\n this.buildLHS(),\n new UIExpression(0),\n this.relation,\n this.priority,\n this.isConstraintEnabled(),\n );\n }\n\n /** Current aspect ratio (width/height) */\n public get aspect(): number {\n return this.aspectInternal;\n }\n\n /** Updates aspect ratio */\n public set aspect(value: number) {\n assertValidPositiveNumber(value, \"UIAspectConstraint.aspect\");\n if (this.aspectInternal !== value) {\n this.aspectInternal = value;\n this.solverWrapper.setConstraintLHS(this.constraint, this.buildLHS());\n }\n }\n\n /** Builds constraint expression: width - (height * aspect) = 0 */\n private buildLHS(): UIExpression {\n return new UIExpression(0, [\n [this.element.wVariable, 1],\n [this.element.hVariable, -this.aspectInternal],\n ]);\n }\n}\n","import type { UIOrientation } from \"../../miscellaneous/UIOrientation\";\n\nexport const COVER_CONSTRAINT_DEFAULT_ANCHOR = 0.5;\n\n/** Cover constraint builder options */\nexport interface UICoverConstraintBuilderOptions {\n /** Whether to maintain active element aspect ratio */\n keepActiveAspect: boolean;\n /** Horizontal anchor (0 = left, 0.5 = center, 1 = right) */\n anchorH: number;\n /** Vertical anchor (0 = bottom, 0.5 = center, 1 = top) */\n anchorV: number;\n /** Orientation for constraints */\n orientation: UIOrientation;\n}\n","import { assertValidNumber } from \"../../miscellaneous/asserts\";\nimport type {\n UILayerElement,\n UIPlaneElement,\n} from \"../../miscellaneous/shared\";\nimport { UIPriority } from \"../../miscellaneous/UIPriority\";\nimport { UIRelation } from \"../../miscellaneous/UIRelation\";\nimport { UIAspectConstraint } from \"../UIAspectConstraint/UIAspectConstraint\";\nimport { UIHorizontalDistanceConstraint } from \"../UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint\";\nimport { UIHorizontalProportionConstraint } from \"../UIHorizontalProportionConstraint/UIHorizontalProportionConstraint\";\nimport { UIVerticalDistanceConstraint } from \"../UIVerticalDistanceConstraint/UIVerticalDistanceConstraint\";\nimport { UIVerticalProportionConstraint } from \"../UIVerticalProportionConstraint/UIVerticalProportionConstraint\";\nimport type { UICoverConstraintBuilderOptions } from \"./UICoverConstraintBuilder.Internal\";\nimport { COVER_CONSTRAINT_DEFAULT_ANCHOR } from \"./UICoverConstraintBuilder.Internal\";\n\n/** Builder for cover layout (like CSS object-fit: cover) */\nexport class UICoverConstraintBuilder {\n /**\n * Creates cover layout constraints.\n * @param passive Container element\n * @param active Content element that covers container\n * @param options Cover configuration\n * @returns Created constraints\n */\n public static build(\n passive: UIPlaneElement,\n active: UIPlaneElement & UILayerElement,\n options: Partial<UICoverConstraintBuilderOptions> = {},\n ): {\n /** Aspect constraint if keepActiveAspect is true */\n activeAspectConstraint?: UIAspectConstraint;\n /** Horizontal position constraint */\n xConstraint: UIHorizontalDistanceConstraint;\n /** Vertical position constraint */\n yConstraint: UIVerticalDistanceConstraint;\n /** Width constraint (ensures coverage) */\n widthConstraint: UIHorizontalProportionConstraint;\n /** Height constraint (ensures coverage) */\n heightConstraint: UIVerticalProportionConstraint;\n } {\n if (options.anchorH !== undefined) {\n assertValidNumber(\n options.anchorH,\n \"UICoverConstraintBuilder.build.anchorH\",\n );\n }\n if (options.anchorV !== undefined) {\n assertValidNumber(\n options.anchorV,\n \"UICoverConstraintBuilder.build.anchorV\",\n );\n }\n\n let activeAspectConstraint: UIAspectConstraint | undefined;\n if (options.keepActiveAspect === true) {\n activeAspectConstraint = new UIAspectConstraint(active, {\n orientation: options.orientation,\n });\n }\n\n const xConstraint = new UIHorizontalDistanceConstraint(passive, active, {\n anchorA: options.anchorH ?? COVER_CONSTRAINT_DEFAULT_ANCHOR,\n anchorB: options.anchorH ?? COVER_CONSTRAINT_DEFAULT_ANCHOR,\n orientation: options.orientation,\n });\n\n const yConstraint = new UIVerticalDistanceConstraint(passive, active, {\n anchorA: options.anchorV ?? COVER_CONSTRAINT_DEFAULT_ANCHOR,\n anchorB: options.anchorV ?? COVER_CONSTRAINT_DEFAULT_ANCHOR,\n orientation: options.orientation,\n });\n\n const widthConstraint = new UIHorizontalProportionConstraint(\n passive,\n active,\n {\n proportion: 1,\n relation: UIRelation.GREATER_THAN,\n orientation: options.orientation,\n },\n );\n\n const heightConstraint = new UIVerticalProportionConstraint(\n passive,\n active,\n {\n proportion: 1,\n priority: UIPriority.P1,\n orientation: options.orientation,\n },\n );\n\n return {\n activeAspectConstraint,\n xConstraint,\n yConstraint,\n widthConstraint,\n heightConstraint,\n };\n }\n}\n","import type { UIOrientation } from \"../../miscellaneous/UIOrientation\";\n\nexport const DEFAULT_ANCHOR = 0.5;\n\n/** Fit constraint builder options */\nexport interface UIFitConstraintBuilderOptions {\n /** Whether to maintain active element aspect ratio */\n keepActiveAspect: boolean;\n /** Horizontal anchor (0 = left, 0.5 = center, 1 = right) */\n anchorH: number;\n /** Vertical anchor (0 = bottom, 0.5 = center, 1 = top) */\n anchorV: number;\n /** Orientation for constraints */\n orientation: UIOrientation;\n}\n","import { assertValidNumber } from \"../../miscellaneous/asserts\";\nimport type {\n UILayerElement,\n UIPlaneElement,\n} from \"../../miscellaneous/shared\";\nimport { UIPriority } from \"../../miscellaneous/UIPriority\";\nimport { UIRelation } from \"../../miscellaneous/UIRelation\";\nimport { UIAspectConstraint } from \"../UIAspectConstraint/UIAspectConstraint\";\nimport { UIHorizontalDistanceConstraint } from \"../UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint\";\nimport { UIHorizontalProportionConstraint } from \"../UIHorizontalProportionConstraint/UIHorizontalProportionConstraint\";\nimport { UIVerticalDistanceConstraint } from \"../UIVerticalDistanceConstraint/UIVerticalDistanceConstraint\";\nimport { UIVerticalProportionConstraint } from \"../UIVerticalProportionConstraint/UIVerticalProportionConstraint\";\nimport type { UIFitConstraintBuilderOptions } from \"./UIFitConstraintBuilder.Internal\";\nimport { DEFAULT_ANCHOR } from \"./UIFitConstraintBuilder.Internal\";\n\n/** Builder for fit layout (like CSS object-fit: contain) */\nexport class UIFitConstraintBuilder {\n /**\n * Creates fit layout constraints.\n * @param passive Container element\n * @param active Content element that fits within container\n * @param options Fit configuration\n * @returns Created constraints\n */\n public static build(\n passive: UIPlaneElement,\n active: UIPlaneElement & UILayerElement,\n options: Partial<UIFitConstraintBuilderOptions> = {},\n ): {\n /** Aspect constraint if keepActiveAspect is true */\n activeAspectConstraint?: UIAspectConstraint;\n /** Horizontal position constraint */\n xConstraint: UIHorizontalDistanceConstraint;\n /** Vertical position constraint */\n yConstraint: UIVerticalDistanceConstraint;\n /** Width constraint (ensures fitting) */\n widthConstraint: UIHorizontalProportionConstraint;\n /** Height constraint (ensures fitting) */\n heightConstraint: UIVerticalProportionConstraint;\n } {\n if (options.anchorH !== undefined) {\n assertValidNumber(\n options.anchorH,\n \"UIFitConstraintBuilder.build.anchorH\",\n );\n }\n if (options.anchorV !== undefined) {\n assertValidNumber(\n options.anchorV,\n \"UIFitConstraintBuilder.build.anchorV\",\n );\n }\n\n let activeAspectConstraint: UIAspectConstraint | undefined;\n if (options.keepActiveAspect === true) {\n activeAspectConstraint = new UIAspectConstraint(active, {\n orientation: options.orientation,\n });\n }\n\n const xConstraint = new UIHorizontalDistanceConstraint(passive, active, {\n anchorA: options.anchorH ?? DEFAULT_ANCHOR,\n anchorB: options.anchorH ?? DEFAULT_ANCHOR,\n orientation: options.orientation,\n });\n\n const yConstraint = new UIVerticalDistanceConstraint(passive, active, {\n anchorA: options.anchorV ?? DEFAULT_ANCHOR,\n anchorB: options.anchorV ?? DEFAULT_ANCHOR,\n orientation: options.orientation,\n });\n\n const widthConstraint = new UIHorizontalProportionConstraint(\n passive,\n active,\n {\n proportion: 1,\n relation: UIRelation.LESS_THAN,\n orientation: options.orientation,\n },\n );\n\n const heightConstraint = new UIVerticalProportionConstraint(\n passive,\n active,\n {\n proportion: 1,\n priority: UIPriority.P1,\n orientation: options.orientation,\n },\n );\n\n return {\n activeAspectConstraint,\n xConstraint,\n yConstraint,\n widthConstraint,\n heightConstraint,\n };\n }\n}\n","import type { UILayer } from \"../layers/UILayer/UILayer\";\nimport type { UIExpression } from \"../miscellaneous/UIExpression\";\nimport { UISingleParameterConstraint } from \"./UISingleParameterConstraint/UISingleParameterConstraint\";\nimport type { UISingleParameterConstraintOptions } from \"./UISingleParameterConstraint/UISingleParameterConstraint.Internal\";\n\n/** Constraint with custom LHS and RHS expressions */\nexport class UICustomConstraint extends UISingleParameterConstraint {\n /** Solver constraint descriptor */\n protected override readonly constraint: number;\n /** Left-hand side expression */\n private lhsInternal: UIExpression;\n /** Right-hand side expression */\n private rhsInternal: UIExpression;\n\n /**\n * @param layer Layer containing this constraint\n * @param lhs Left-hand side expression\n * @param rhs Right-hand side expression\n * @param options Constraint configuration\n */\n constructor(\n layer: UILayer,\n lhs: UIExpression,\n rhs: UIExpression,\n options: Partial<UISingleParameterConstraintOptions> = {},\n ) {\n super(layer, options);\n\n this.lhsInternal = lhs;\n this.rhsInternal = rhs;\n\n this.constraint = this.solverWrapper.createConstraint(\n this.lhsInternal,\n this.rhsInternal,\n this.relation,\n this.priority,\n this.isConstraintEnabled(),\n );\n }\n\n /** Left-hand side expression */\n public get lhs(): UIExpression {\n return this.lhsInternal;\n }\n\n /** Right-hand side expression */\n public get rhs(): UIExpression {\n return this.rhsInternal;\n }\n\n /** Updates left-hand side expression */\n public setLHS(value: UIExpression): void {\n this.lhsInternal = value;\n this.solverWrapper.setConstraintLHS(this.constraint, this.lhsInternal);\n }\n\n /** Updates right-hand side expression */\n public setRHS(value: UIExpression): void {\n this.rhsInternal = value;\n this.solverWrapper.setConstraintRHS(this.constraint, this.rhsInternal);\n }\n}\n","import { Eventail } from \"eventail\";\nimport type { UILayer } from \"../../layers/UILayer/UILayer\";\nimport { assertValidNumber } from \"../../miscellaneous/asserts\";\nimport type {\n UILayerElement,\n UIPointElement,\n} from \"../../miscellaneous/shared\";\nimport { UIPriority } from \"../../miscellaneous/UIPriority\";\nimport type { UISolverWrapperInterface } from \"../../wrappers/UISolverWrapper/UISolverWrapper.Internal\";\nimport type { UIAnchorOptions } from \"./UIAnchor.Internal\";\nimport { ANCHOR_DEFAULT_X, ANCHOR_DEFAULT_Y } from \"./UIAnchor.Internal\";\n\n/** Point in 2D space with constraint-based positioning */\nexport class UIAnchor\n extends Eventail\n implements UILayerElement, UIPointElement\n{\n /** Optional identifier for debugging */\n public name = \"\";\n\n /** Solver variable for x coordinate */\n public readonly xVariable: number;\n\n /** Solver variable for y coordinate */\n public readonly yVariable: number;\n\n protected readonly solverWrapper: UISolverWrapperInterface;\n\n /**\n * Creates a new UIAnchor instance.\n *\n * @param layer - Layer containing this anchor\n * @param options - Configuration options\n */\n constructor(\n public readonly layer: UILayer,\n options?: Partial<UIAnchorOptions>,\n ) {\n const x = options?.x ?? ANCHOR_DEFAULT_X;\n const y = options?.y ?? ANCHOR_DEFAULT_Y;\n assertValidNumber(x, \"UIAnchor.constructor.options.x\");\n assertValidNumber(y, \"UIAnchor.constructor.options.y\");\n\n super();\n this.solverWrapper = this.layer.solverWrapper;\n this.xVariable = this.solverWrapper.createVariable(x, UIPriority.P7);\n this.yVariable = this.solverWrapper.createVariable(y, UIPriority.P7);\n }\n\n /** X coordinate relative to layer origin (bottom-left) */\n public get x(): number {\n return this.solverWrapper.readVariableValue(this.xVariable);\n }\n\n /** Y coordinate relative to layer origin (bottom-left) */\n public get y(): number {\n return this.solverWrapper.readVariableValue(this.yVariable);\n }\n\n /** X coordinate relative to layer origin (bottom-left) */\n public set x(value: number) {\n assertValidNumber(value, \"UIAnchor.x\");\n this.solverWrapper.suggestVariableValue(this.xVariable, value);\n }\n\n /** Y coordinate relative to layer origin (bottom-left) */\n public set y(value: number) {\n assertValidNumber(value, \"UIAnchor.y\");\n this.solverWrapper.suggestVariableValue(this.yVariable, value);\n }\n\n /** Removes anchor and frees resources */\n public destroy(): void {\n this.solverWrapper.removeVariable(this.yVariable);\n this.solverWrapper.removeVariable(this.xVariable);\n }\n}\n","/** Configuration options for UIAnchor */\nexport interface UIAnchorOptions {\n /** X coordinate in world units */\n x: number;\n /** Y coordinate in world units */\n y: number;\n}\n\nexport const ANCHOR_DEFAULT_X = 0;\nexport const ANCHOR_DEFAULT_Y = 0;\n","/** Controls which transforms apply relative to anchor */\nexport enum UIMicroAnchorMode {\n /** Apply rotation and scale around anchor point */\n ROTATION_SCALE = 0,\n /** Apply position, rotation, and scale around anchor point */\n POSITION_ROTATION_SCALE = 1,\n}\n\n/** Configuration options for UIMicro */\nexport interface UIMicroConfig {\n /** X offset in world units */\n x: number;\n /** Y offset in world units */\n y: number;\n /** X anchor in normalized coordinates (0 to 1) */\n anchorX: number;\n /** Y anchor in normalized coordinates (0 to 1) */\n anchorY: number;\n /** X scale multiplier */\n scaleX: number;\n /** Y scale multiplier */\n scaleY: number;\n /** Rotation in radians */\n rotation: number;\n /** Which transforms apply relative to anchor */\n anchorMode: UIMicroAnchorMode;\n}\n\nexport const MICRO_DEFAULT_POSITION = 0;\nexport const MICRO_DEFAULT_ANCHOR = 0.5;\nexport const MICRO_DEFAULT_SCALE = 1;\nexport const MICRO_DEFAULT_ROTATION = 0;\nexport const MICRO_DEFAULT_ANCHOR_MODE = UIMicroAnchorMode.ROTATION_SCALE;\n","import { Matrix4, Quaternion, Vector3 } from \"three\";\nimport { UIMicroAnchorMode } from \"../miscellaneous/micro/UIMicro.Internal\";\n\nconst TEMP_POSITION = new Vector3();\nconst TEMP_QUATERNION = new Quaternion();\nconst TEMP_SCALE = new Vector3();\nconst TEMP_MATRIX = new Matrix4();\nconst Z_AXIS = new Vector3(0, 0, 1);\n\n/**\n * Computes element transform matrix.\n * @returns Transform matrix (reused, do not store reference)\n */\nexport function computeTransformMatrix(\n x: number,\n y: number,\n width: number,\n height: number,\n zIndex: number,\n microX: number,\n microY: number,\n microAnchorX: number,\n microAnchorY: number,\n microScaleX: number,\n microScaleY: number,\n microRotation: number,\n microAnchorMode: UIMicroAnchorMode,\n): Matrix4 {\n const scaledWidth = width * microScaleX;\n const scaledHeight = height * microScaleY;\n\n const anchorOffsetX = microAnchorX * scaledWidth;\n const anchorOffsetY = microAnchorY * scaledHeight;\n\n const cos = Math.cos(microRotation);\n const sin = Math.sin(microRotation);\n\n const rotatedAnchorX = anchorOffsetX * cos - anchorOffsetY * sin;\n const rotatedAnchorY = anchorOffsetX * sin + anchorOffsetY * cos;\n\n if (microAnchorMode === UIMicroAnchorMode.POSITION_ROTATION_SCALE) {\n TEMP_POSITION.x = x + microX - rotatedAnchorX;\n TEMP_POSITION.y = y + microY - rotatedAnchorY;\n } else {\n const rawAnchorOffsetX = microAnchorX * width;\n const rawAnchorOffsetY = microAnchorY * height;\n TEMP_POSITION.x = x + rawAnchorOffsetX - rotatedAnchorX + microX;\n TEMP_POSITION.y = y + rawAnchorOffsetY - rotatedAnchorY + microY;\n }\n\n TEMP_POSITION.z = zIndex;\n TEMP_SCALE.x = scaledWidth;\n TEMP_SCALE.y = scaledHeight;\n TEMP_QUATERNION.setFromAxisAngle(Z_AXIS, microRotation);\n\n TEMP_MATRIX.compose(TEMP_POSITION, TEMP_QUATERNION, TEMP_SCALE);\n return TEMP_MATRIX;\n}\n\n/**\n * Computes transform matrix for trimmed sprite.\n * @param width Source width including trimmed areas\n * @param height Source height including trimmed areas\n * @param trimLeft Pixels trimmed from left\n * @param trimRight Pixels trimmed from right\n * @param trimTop Pixels trimmed from top\n * @param trimBottom Pixels trimmed from bottom\n * @returns Transform matrix (reused, do not store reference)\n */\nexport function computeTrimmedTransformMatrix(\n x: number,\n y: number,\n width: number,\n height: number,\n zIndex: number,\n microX: number,\n microY: number,\n microAnchorX: number,\n microAnchorY: number,\n microScaleX: number,\n microScaleY: number,\n microRotation: number,\n microAnchorMode: UIMicroAnchorMode,\n trimLeft: number,\n trimRight: number,\n trimTop: number,\n trimBottom: number,\n): Matrix4 {\n const trimmedWidth = width - trimLeft - trimRight;\n const trimmedHeight = height - trimTop - trimBottom;\n\n const scaledWidth = width * microScaleX;\n const scaledHeight = height * microScaleY;\n\n const anchorOffsetX = microAnchorX * scaledWidth;\n const anchorOffsetY = microAnchorY * scaledHeight;\n\n const cos = Math.cos(microRotation);\n const sin = Math.sin(microRotation);\n\n const rotatedAnchorX = anchorOffsetX * cos - anchorOffsetY * sin;\n const rotatedAnchorY = anchorOffsetX * sin + anchorOffsetY * cos;\n\n const trimOffsetX = trimLeft * microScaleX;\n const trimOffsetY = trimBottom * microScaleY;\n\n const rotatedTrimX = trimOffsetX * cos - trimOffsetY * sin;\n const rotatedTrimY = trimOffsetX * sin + trimOffsetY * cos;\n\n if (microAnchorMode === UIMicroAnchorMode.POSITION_ROTATION_SCALE) {\n TEMP_POSITION.x = x + microX - rotatedAnchorX + rotatedTrimX;\n TEMP_POSITION.y = y + microY - rotatedAnchorY + rotatedTrimY;\n } else {\n const rawAnchorOffsetX = microAnchorX * width;\n const rawAnchorOffsetY = microAnchorY * height;\n TEMP_POSITION.x =\n x + rawAnchorOffsetX - rotatedAnchorX + microX + rotatedTrimX;\n TEMP_POSITION.y =\n y + rawAnchorOffsetY - rotatedAnchorY + microY + rotatedTrimY;\n }\n\n TEMP_POSITION.z = zIndex;\n TEMP_SCALE.x = trimmedWidth * microScaleX;\n TEMP_SCALE.y = trimmedHeight * microScaleY;\n TEMP_QUATERNION.setFromAxisAngle(Z_AXIS, microRotation);\n\n TEMP_MATRIX.compose(TEMP_POSITION, TEMP_QUATERNION, TEMP_SCALE);\n return TEMP_MATRIX;\n}\n","import { Texture } from \"three\";\n\nexport const TEXTURE_DEFAULT_TEXTURE = new Texture();\nexport const TEXTURE_DEFAULT_SIZE = 2;\n\n/** Events emitted by UITexture */\nexport enum UITextureViewEvent {\n /** Emitted when width or height changes */\n DIMENSIONS_CHANGED = 0,\n}\n\n/** Rectangle coordinates and dimensions in atlas */\nexport interface UITextureRect {\n /** X coordinate in pixels */\n x: number;\n /** Y coordinate in pixels */\n y: number;\n /** Width in pixels */\n w: number;\n /** Height in pixels */\n h: number;\n}\n\n/** Size dimensions */\nexport interface UITextureSize {\n /** Width in pixels */\n w: number;\n /** Height in pixels */\n h: number;\n}\n\n/** Transparent padding around visible content */\nexport interface UITextureTrim {\n /** Left padding in world units */\n left: number;\n /** Right padding in world units */\n right: number;\n /** Top padding in world units */\n top: number;\n /** Bottom padding in world units */\n bottom: number;\n}\n\n/** Configuration for texture atlas sprite */\nexport interface UITextureAtlasConfig {\n /** Source texture atlas */\n texture: Texture;\n /** Rectangle in atlas containing sprite */\n frame: UITextureRect;\n /** Whether sprite is rotated 90 degrees clockwise */\n rotated?: boolean;\n /** Position and size within original image before trimming */\n spriteSourceSize: UITextureRect;\n /** Original image dimensions before trimming */\n sourceSize: UITextureSize;\n /** Scale factor for resolution independence */\n scale?: number;\n}\n\n/** Texture configuration from direct texture or atlas sprite */\nexport type UITextureConfig = Texture | UITextureAtlasConfig;\n","import { Eventail } from \"eventail\";\nimport { Matrix3, Texture, Vector2 } from \"three\";\nimport {\n assertValidNonNegativeNumber,\n assertValidPositiveNumber,\n} from \"../asserts\";\nimport type {\n UITextureAtlasConfig,\n UITextureConfig,\n UITextureTrim,\n} from \"./UITextureView.Internal\";\nimport {\n TEXTURE_DEFAULT_SIZE,\n TEXTURE_DEFAULT_TEXTURE,\n UITextureViewEvent,\n} from \"./UITextureView.Internal\";\n\n/** Wrapper for Three.js texture with atlas and trim support. Does not own the underlying texture; user must dispose it. */\nexport class UITextureView extends Eventail {\n private textureInternal: Texture = TEXTURE_DEFAULT_TEXTURE;\n\n private sourceWidth = TEXTURE_DEFAULT_SIZE;\n private sourceHeight = TEXTURE_DEFAULT_SIZE;\n\n private frameX = 0;\n private frameY = 0;\n private frameWidth = TEXTURE_DEFAULT_SIZE;\n private frameHeight = TEXTURE_DEFAULT_SIZE;\n\n private rotatedInternal = false;\n private scaleInternal = 1;\n\n private trimLeft = 0;\n private trimRight = 0;\n private trimTop = 0;\n private trimBottom = 0;\n\n private textureDirtyInternal = false;\n private uvTransformDirtyInternal = false;\n private trimDirtyInternal = false;\n\n /** @param config Texture or atlas configuration */\n constructor(config?: UITextureConfig) {\n super();\n if (config !== undefined) {\n this.set(config);\n }\n }\n\n /** Original width before trimming in world units */\n public get width(): number {\n return this.sourceWidth / this.scaleInternal;\n }\n\n /** Original height before trimming in world units */\n public get height(): number {\n return this.sourceHeight / this.scaleInternal;\n }\n\n /** Visible width after trimming in world units */\n public get trimmedWidth(): number {\n const frameSize = this.rotatedInternal ? this.frameHeight : this.frameWidth;\n return frameSize / this.scaleInternal;\n }\n\n /** Visible height after trimming in world units */\n public get trimmedHeight(): number {\n const frameSize = this.rotatedInternal ? this.frameWidth : this.frameHeight;\n return frameSize / this.scaleInternal;\n }\n\n /** Underlying Three.js texture */\n public get texture(): Texture {\n return this.textureInternal;\n }\n\n /** Whether sprite is rotated in atlas */\n public get rotated(): boolean {\n return this.rotatedInternal;\n }\n\n /** Scale factor for resolution independence */\n public get scale(): number {\n return this.scaleInternal;\n }\n\n /** Transparent padding around visible content */\n public get trim(): Readonly<UITextureTrim> {\n const scale = this.scaleInternal;\n return {\n left: this.trimLeft / scale,\n right: this.trimRight / scale,\n top: this.trimTop / scale,\n bottom: this.trimBottom / scale,\n };\n }\n\n public get textureDirty(): boolean {\n return this.textureDirtyInternal;\n }\n\n /** Whether UV transform inputs changed since last check */\n public get uvTransformDirty(): boolean {\n return this.uvTransformDirtyInternal;\n }\n\n /** Whether trim values changed since last check */\n public get trimDirty(): boolean {\n return this.trimDirtyInternal;\n }\n\n public setTextureDirtyFalse(): void {\n this.textureDirtyInternal = false;\n }\n\n /** Marks UV transform as clean. @internal */\n public setUVTransformDirtyFalse(): void {\n this.uvTransformDirtyInternal = false;\n }\n\n /** Marks trim as clean. @internal */\n public setTrimDirtyFalse(): void {\n this.trimDirtyInternal = false;\n }\n\n /**\n * Calculates UV transform matrix for shader sampling.\n * @param result Matrix to store result in\n * @returns UV transform matrix\n */\n public calculateUVTransform(result = new Matrix3()): Matrix3 {\n const atlasWidth =\n this.textureInternal.image?.naturalWidth ?? TEXTURE_DEFAULT_SIZE;\n const atlasHeight =\n this.textureInternal.image?.naturalHeight ?? TEXTURE_DEFAULT_SIZE;\n\n if (this.rotatedInternal) {\n const physicalWidth = this.frameHeight;\n const physicalHeight = this.frameWidth;\n\n const u0 = this.frameX / atlasWidth;\n const v0 = (atlasHeight - this.frameY - physicalHeight) / atlasHeight;\n const uSize = physicalWidth / atlasWidth;\n const vSize = physicalHeight / atlasHeight;\n\n result.set(0, uSize, u0, -vSize, 0, v0 + vSize, 0, 0, 1);\n } else {\n const u0 = this.frameX / atlasWidth;\n const v0 = (atlasHeight - this.frameY - this.frameHeight) / atlasHeight;\n const uSize = this.frameWidth / atlasWidth;\n const vSize = this.frameHeight / atlasHeight;\n\n result.set(uSize, 0, u0, 0, vSize, v0, 0, 0, 1);\n }\n\n return result;\n }\n\n /**\n * Gets original dimensions before trimming.\n * @param result Vector to store result in\n * @returns Width and height in world units\n */\n public getResolution(result = new Vector2()): Vector2 {\n return result.set(this.width, this.height);\n }\n\n /**\n * Replaces texture with new configuration.\n * @param config Texture or atlas configuration\n */\n public set(config: UITextureConfig): void {\n const lastWidth = this.width;\n const lastHeight = this.height;\n\n if (config instanceof Texture) {\n this.setFromTexture(config);\n } else {\n this.setFromAtlasConfig(config);\n }\n\n if (this.width !== lastWidth || this.height !== lastHeight) {\n this.emit(\n UITextureViewEvent.DIMENSIONS_CHANGED,\n this.width,\n this.height,\n this,\n );\n }\n }\n\n private setFromTexture(texture: Texture): void {\n const width = texture.image?.naturalWidth ?? TEXTURE_DEFAULT_SIZE;\n const height = texture.image?.naturalHeight ?? TEXTURE_DEFAULT_SIZE;\n\n this.sourceWidth = width;\n this.sourceHeight = height;\n\n if (this.texture !== texture) {\n this.textureInternal = texture;\n this.textureDirtyInternal = true;\n }\n\n if (\n this.frameX !== 0 ||\n this.frameY !== 0 ||\n this.frameWidth !== width ||\n this.frameHeight !== height ||\n this.scaleInternal !== 1 ||\n this.rotatedInternal\n ) {\n this.frameX = 0;\n this.frameY = 0;\n this.frameWidth = width;\n this.frameHeight = height;\n this.rotatedInternal = false;\n this.scaleInternal = 1;\n this.uvTransformDirtyInternal = true;\n }\n\n if (\n this.trimLeft !== 0 ||\n this.trimRight !== 0 ||\n this.trimTop !== 0 ||\n this.trimBottom !== 0\n ) {\n this.trimLeft = 0;\n this.trimRight = 0;\n this.trimTop = 0;\n this.trimBottom = 0;\n this.trimDirtyInternal = true;\n }\n }\n\n private setFromAtlasConfig(config: UITextureAtlasConfig): void {\n assertValidPositiveNumber(\n config.sourceSize.w,\n \"UITextureView.setFromAtlasConfig.config.sourceSize.w\",\n );\n assertValidPositiveNumber(\n config.sourceSize.h,\n \"UITextureView.setFromAtlasConfig.config.sourceSize.h\",\n );\n assertValidNonNegativeNumber(\n config.frame.x,\n \"UITextureView.setFromAtlasConfig.config.frame.x\",\n );\n assertValidNonNegativeNumber(\n config.frame.y,\n \"UITextureView.setFromAtlasConfig.config.frame.y\",\n );\n assertValidPositiveNumber(\n config.frame.w,\n \"UITextureView.setFromAtlasConfig.config.frame.w\",\n );\n assertValidPositiveNumber(\n config.frame.h,\n \"UITextureView.setFromAtlasConfig.config.frame.h\",\n );\n assertValidNonNegativeNumber(\n config.spriteSourceSize.x,\n \"UITextureView.setFromAtlasConfig.config.spriteSourceSize.x\",\n );\n assertValidNonNegativeNumber(\n config.spriteSourceSize.y,\n \"UITextureView.setFromAtlasConfig.config.spriteSourceSize.y\",\n );\n assertValidPositiveNumber(\n config.spriteSourceSize.w,\n \"UITextureView.setFromAtlasConfig.config.spriteSourceSize.w\",\n );\n assertValidPositiveNumber(\n config.spriteSourceSize.h,\n \"UITextureView.setFromAtlasConfig.config.spriteSourceSize.h\",\n );\n\n if (config.scale !== undefined) {\n assertValidPositiveNumber(\n config.scale,\n \"UITextureView.setFromAtlasConfig.config.scale\",\n );\n }\n\n this.sourceWidth = config.sourceSize.w;\n this.sourceHeight = config.sourceSize.h;\n\n if (this.texture !== config.texture) {\n this.textureInternal = config.texture;\n this.textureDirtyInternal = true;\n }\n\n const scale = config.scale ?? 1;\n const rotated = config.rotated ?? false;\n\n if (\n this.frameX !== 0 ||\n this.frameY !== 0 ||\n this.frameWidth !== config.frame.w ||\n this.frameHeight !== config.frame.h ||\n this.scaleInternal !== scale ||\n this.rotatedInternal !== rotated\n ) {\n this.frameX = config.frame.x;\n this.frameY = config.frame.y;\n this.frameWidth = config.frame.w;\n this.frameHeight = config.frame.h;\n this.scaleInternal = scale;\n this.rotatedInternal = rotated;\n this.uvTransformDirtyInternal = true;\n }\n\n const spriteSource = config.spriteSourceSize;\n const trimLeft = spriteSource.x;\n const trimTop = spriteSource.y;\n const trimRight = this.sourceWidth - spriteSource.x - spriteSource.w;\n const trimBottom = this.sourceHeight - spriteSource.y - spriteSource.h;\n\n if (\n this.trimLeft !== trimLeft ||\n this.trimRight !== trimRight ||\n this.trimTop !== trimTop ||\n this.trimBottom !== trimBottom\n ) {\n this.trimLeft = trimLeft;\n this.trimRight = trimRight;\n this.trimTop = trimTop;\n this.trimBottom = trimBottom;\n this.trimDirtyInternal = true;\n }\n }\n}\n","/** Input events emitted by UI elements */\nexport enum UIInputEvent {\n /** Pointer pressed */\n PRESSED = \"pointerdown\",\n /** Pointer moved */\n MOVED = \"pointermove\",\n /** Pointer released */\n RELEASED = \"pointerup\",\n /** Pointer entered element */\n ENTERED = \"pointerenter\",\n /** Pointer left element */\n LEFT = \"pointerleave\",\n}\n","import { MathUtils } from \"three\";\nimport { assertValidNumber } from \"../asserts\";\nimport type { UIMicroAnchorMode, UIMicroConfig } from \"./UIMicro.Internal\";\nimport {\n MICRO_DEFAULT_ANCHOR,\n MICRO_DEFAULT_ANCHOR_MODE,\n MICRO_DEFAULT_POSITION,\n MICRO_DEFAULT_ROTATION,\n MICRO_DEFAULT_SCALE,\n} from \"./UIMicro.Internal\";\n\n/** Transforms that don't affect constraints */\nexport class UIMicro {\n private xInternal: number;\n private yInternal: number;\n private anchorXInternal: number;\n private anchorYInternal: number;\n private scaleXInternal: number;\n private scaleYInternal: number;\n private rotationInternal: number;\n private anchorModeInternal: UIMicroAnchorMode;\n\n private dirtyInternal = true;\n\n /**\n * Creates UIMicro instance.\n *\n * @param config - Transform configuration\n */\n constructor(config?: Partial<UIMicroConfig>) {\n this.xInternal = config?.x ?? MICRO_DEFAULT_POSITION;\n this.yInternal = config?.y ?? MICRO_DEFAULT_POSITION;\n this.anchorXInternal = config?.anchorX ?? MICRO_DEFAULT_ANCHOR;\n this.anchorYInternal = config?.anchorY ?? MICRO_DEFAULT_ANCHOR;\n this.scaleXInternal = config?.scaleX ?? MICRO_DEFAULT_SCALE;\n this.scaleYInternal = config?.scaleY ?? MICRO_DEFAULT_SCALE;\n this.rotationInternal = config?.rotation ?? MICRO_DEFAULT_ROTATION;\n this.anchorModeInternal = config?.anchorMode ?? MICRO_DEFAULT_ANCHOR_MODE;\n }\n\n /** X offset in world units */\n public get x(): number {\n return this.xInternal;\n }\n\n /** Y offset in world units */\n public get y(): number {\n return this.yInternal;\n }\n\n /** X anchor in normalized coordinates (0 to 1) */\n public get anchorX(): number {\n return this.anchorXInternal;\n }\n\n /** Y anchor in normalized coordinates (0 to 1) */\n public get anchorY(): number {\n return this.anchorYInternal;\n }\n\n /** X scale multiplier */\n public get scaleX(): number {\n return this.scaleXInternal;\n }\n\n /** Y scale multiplier */\n public get scaleY(): number {\n return this.scaleYInternal;\n }\n\n /** Rotation in degrees */\n public get angle(): number {\n return MathUtils.radToDeg(this.rotationInternal);\n }\n\n /** Which transforms apply relative to anchor */\n public get anchorMode(): UIMicroAnchorMode {\n return this.anchorModeInternal;\n }\n\n /** Rotation in radians */\n public get rotation(): number {\n return this.rotationInternal;\n }\n\n /** @internal */\n public get dirty(): boolean {\n return this.dirtyInternal;\n }\n\n /** X offset in world units */\n public set x(value: number) {\n assertValidNumber(value, \"UIMicro.x\");\n if (value !== this.xInternal) {\n this.xInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n /** Y offset in world units */\n public set y(value: number) {\n assertValidNumber(value, \"UIMicro.y\");\n if (value !== this.yInternal) {\n this.yInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n /** X anchor in normalized coordinates (0 to 1) */\n public set anchorX(value: number) {\n assertValidNumber(value, \"UIMicro.anchorX\");\n if (value !== this.anchorXInternal) {\n this.anchorXInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n /** Y anchor in normalized coordinates (0 to 1) */\n public set anchorY(value: number) {\n assertValidNumber(value, \"UIMicro.anchorY\");\n if (value !== this.anchorYInternal) {\n this.anchorYInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n /** X scale multiplier */\n public set scaleX(value: number) {\n assertValidNumber(value, \"UIMicro.scaleX\");\n if (value !== this.scaleXInternal) {\n this.scaleXInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n /** Y scale multiplier */\n public set scaleY(value: number) {\n assertValidNumber(value, \"UIMicro.scaleY\");\n if (value !== this.scaleYInternal) {\n this.scaleYInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n /** Rotation in degrees */\n public set angle(value: number) {\n assertValidNumber(value, \"UIMicro.angle\");\n const rotation = MathUtils.degToRad(value);\n if (rotation !== this.rotationInternal) {\n this.rotationInternal = rotation;\n this.dirtyInternal = true;\n }\n }\n\n /** Rotation in radians */\n public set rotation(value: number) {\n assertValidNumber(value, \"UIMicro.rotation\");\n if (value !== this.rotationInternal) {\n this.rotationInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n /** Which transforms apply relative to anchor */\n public set anchorMode(value: UIMicroAnchorMode) {\n if (value !== this.anchorModeInternal) {\n this.anchorModeInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n /** @internal */\n public setDirtyFalse(): void {\n this.dirtyInternal = false;\n }\n\n /** Resets all transforms to defaults */\n public reset(): void {\n if (\n this.xInternal !== MICRO_DEFAULT_POSITION ||\n this.yInternal !== MICRO_DEFAULT_POSITION ||\n this.anchorXInternal !== MICRO_DEFAULT_ANCHOR ||\n this.anchorYInternal !== MICRO_DEFAULT_ANCHOR ||\n this.scaleXInternal !== MICRO_DEFAULT_SCALE ||\n this.scaleYInternal !== MICRO_DEFAULT_SCALE ||\n this.rotationInternal !== MICRO_DEFAULT_ROTATION\n ) {\n this.xInternal = MICRO_DEFAULT_POSITION;\n this.yInternal = MICRO_DEFAULT_POSITION;\n this.anchorXInternal = MICRO_DEFAULT_ANCHOR;\n this.anchorYInternal = MICRO_DEFAULT_ANCHOR;\n this.scaleXInternal = MICRO_DEFAULT_SCALE;\n this.scaleYInternal = MICRO_DEFAULT_SCALE;\n this.rotationInternal = MICRO_DEFAULT_ROTATION;\n this.dirtyInternal = true;\n }\n }\n\n /** Copies transforms from another instance */\n public copy(value: UIMicro): void {\n if (\n this.xInternal !== value.xInternal ||\n this.yInternal !== value.yInternal ||\n this.anchorXInternal !== value.anchorXInternal ||\n this.anchorYInternal !== value.anchorYInternal ||\n this.scaleXInternal !== value.scaleXInternal ||\n this.scaleYInternal !== value.scaleYInternal ||\n this.rotationInternal !== value.rotationInternal ||\n this.anchorModeInternal !== value.anchorModeInternal\n ) {\n this.xInternal = value.xInternal;\n this.yInternal = value.yInternal;\n this.anchorXInternal = value.anchorXInternal;\n this.anchorYInternal = value.anchorYInternal;\n this.scaleXInternal = value.scaleXInternal;\n this.scaleYInternal = value.scaleYInternal;\n this.rotationInternal = value.rotationInternal;\n this.anchorModeInternal = value.anchorModeInternal;\n this.dirtyInternal = true;\n }\n }\n}\n","/** Base class for interaction area shapes */\nexport abstract class UIArea {\n /** @internal */\n public abstract contains(pointX: number, pointY: number): boolean;\n}\n","import { assertValidNonNegativeNumber, assertValidNumber } from \"../asserts\";\nimport { UIArea } from \"./UIArea\";\n\n/** Rectangular interaction area */\nexport class UIAreaRectangle extends UIArea {\n /**\n * Creates rectangular area.\n *\n * @param x - X position in normalized coordinates (0 to 1)\n * @param y - Y position in normalized coordinates (0 to 1)\n * @param width - Width in normalized coordinates (0 to 1)\n * @param height - Height in normalized coordinates (0 to 1)\n */\n constructor(\n public x: number,\n public y: number,\n public width: number,\n public height: number,\n ) {\n super();\n assertValidNonNegativeNumber(x, \"UIAreaRectangle.constructor.x\");\n assertValidNonNegativeNumber(y, \"UIAreaRectangle.constructor.y\");\n assertValidNonNegativeNumber(width, \"UIAreaRectangle.constructor.width\");\n assertValidNonNegativeNumber(height, \"UIAreaRectangle.constructor.height\");\n }\n\n /** @internal */\n public contains(pointX: number, pointY: number): boolean {\n assertValidNumber(pointX, \"UIAreaRectangle.contains.pointX\");\n assertValidNumber(pointY, \"UIAreaRectangle.contains.pointY\");\n return (\n pointX >= this.x &&\n pointX <= this.x + this.width &&\n pointY >= this.y &&\n pointY <= this.y + this.height\n );\n }\n}\n","import type { UIArea } from \"../../miscellaneous/area/UIArea\";\nimport { UIMode } from \"../../miscellaneous/UIMode\";\nimport type { UIAnchorOptions } from \"../UIAnchor/UIAnchor.Internal\";\n\n/** Configuration options for UIInputDummy */\nexport interface UIInputDummyOptions extends UIAnchorOptions {\n /** Width in world units */\n width: number;\n /** Height in world units */\n height: number;\n /** Shape defining interactive region in element-local space (0,0 = bottom-left, 1,1 = top-right) */\n interactionArea: UIArea;\n /** Controls visibility and interactivity */\n mode: UIMode;\n}\n\nexport const DUMMY_DEFAULT_WIDTH = 64;\nexport const DUMMY_DEFAULT_HEIGHT = 32;\nexport const DUMMY_DEFAULT_MODE = UIMode.VISIBLE;\nexport const DUMMY_DEFAULT_Z_INDEX = 0;\n","import { MathUtils } from \"three\";\nimport type { UILayer } from \"../../layers/UILayer/UILayer\";\nimport type { UIArea } from \"../../miscellaneous/area/UIArea\";\nimport { UIAreaRectangle } from \"../../miscellaneous/area/UIAreaRectangle\";\nimport {\n assertValidNumber,\n assertValidPositiveNumber,\n} from \"../../miscellaneous/asserts\";\nimport type { UIPlaneElement } from \"../../miscellaneous/shared\";\nimport { UIInputEvent } from \"../../miscellaneous/UIInputEvent\";\nimport { isUIModeInteractive, UIMode } from \"../../miscellaneous/UIMode\";\nimport { UIPriority } from \"../../miscellaneous/UIPriority\";\nimport type { UIInputWrapperInterface } from \"../../wrappers/UIInputWrapper/UIInputWrapper.Internal\";\nimport { UIAnchor } from \"../UIAnchor/UIAnchor\";\nimport type { UIInputDummyOptions } from \"./UIInputDummy.Internal\";\nimport {\n DUMMY_DEFAULT_HEIGHT,\n DUMMY_DEFAULT_MODE,\n DUMMY_DEFAULT_WIDTH,\n DUMMY_DEFAULT_Z_INDEX,\n} from \"./UIInputDummy.Internal\";\n\n/** Rectangular area with dimensions but no rendering */\nexport class UIInputDummy extends UIAnchor implements UIPlaneElement {\n /** Shape defining interactive region in element-local space (0,0 = bottom-left, 1,1 = top-right) */\n public interactionArea: UIArea;\n\n /** Solver variable for width */\n public readonly wVariable: number;\n\n /** Solver variable for height */\n public readonly hVariable: number;\n\n protected modeInternal: UIMode;\n protected readonly inputWrapper: UIInputWrapperInterface;\n private readonly catcherHandler: number;\n private wasPointerInside = false;\n\n /**\n * Creates a new UIInputDummy instance.\n *\n * @param layer - Layer containing this element\n * @param options - Configuration options\n */\n constructor(layer: UILayer, options?: Partial<UIInputDummyOptions>) {\n const w = options?.width ?? DUMMY_DEFAULT_WIDTH;\n const h = options?.height ?? DUMMY_DEFAULT_HEIGHT;\n\n assertValidPositiveNumber(w, \"UIInputDummy.constructor.width\");\n assertValidPositiveNumber(h, \"UIInputDummy.constructor.height\");\n\n super(layer, options);\n\n this.interactionArea =\n options?.interactionArea ?? new UIAreaRectangle(0, 0, 1, 1);\n this.modeInternal = options?.mode ?? DUMMY_DEFAULT_MODE;\n this.inputWrapper = this.layer.inputWrapper;\n\n this.wVariable = this.solverWrapper.createVariable(w, UIPriority.P6);\n this.hVariable = this.solverWrapper.createVariable(h, UIPriority.P6);\n\n this.catcherHandler = this.inputWrapper.createInputCatcher(\n this.catchPointerDown,\n this.catchPointerMove,\n this.catchPointerUp,\n DUMMY_DEFAULT_Z_INDEX,\n );\n\n this.inputWrapper.setActive(\n this.catcherHandler,\n isUIModeInteractive(this.modeInternal),\n );\n }\n\n /** Width in world units */\n public get width(): number {\n return this.solverWrapper.readVariableValue(this.wVariable);\n }\n\n /** Height in world units */\n public get height(): number {\n return this.solverWrapper.readVariableValue(this.hVariable);\n }\n\n /** X coordinate of right edge */\n public get oppositeX(): number {\n return this.x + this.width;\n }\n\n /** Y coordinate of top edge */\n public get oppositeY(): number {\n return this.y + this.height;\n }\n\n /** X coordinate of horizontal center */\n public get centerX(): number {\n return this.x + this.width / 2;\n }\n\n /** Y coordinate of vertical center */\n public get centerY(): number {\n return this.y + this.height / 2;\n }\n\n /** Controls visibility and interactivity */\n public get mode(): UIMode {\n return this.modeInternal;\n }\n\n /** Rendering and input priority. Higher values on top. */\n public get zIndex(): number {\n return this.inputWrapper.getZIndex(this.catcherHandler);\n }\n\n /** Width in world units */\n public set width(value: number) {\n assertValidPositiveNumber(value, \"UIInputDummy.width\");\n this.solverWrapper.suggestVariableValue(this.wVariable, value);\n }\n\n /** Height in world units */\n public set height(value: number) {\n assertValidPositiveNumber(value, \"UIInputDummy.height\");\n this.solverWrapper.suggestVariableValue(this.hVariable, value);\n }\n\n /** X coordinate of right edge */\n public set oppositeX(value: number) {\n assertValidNumber(value, \"UIInputDummy.oppositeX\");\n this.x = value - this.width;\n }\n\n /** Y coordinate of top edge */\n public set oppositeY(value: number) {\n assertValidNumber(value, \"UIInputDummy.oppositeY\");\n this.y = value - this.height;\n }\n\n /** X coordinate of horizontal center */\n public set centerX(value: number) {\n assertValidNumber(value, \"UIInputDummy.centerX\");\n this.x = value - this.width / 2;\n }\n\n /** Y coordinate of vertical center */\n public set centerY(value: number) {\n assertValidNumber(value, \"UIInputDummy.centerY\");\n this.y = value - this.height / 2;\n }\n\n /** Controls visibility and interactivity */\n public set mode(value: UIMode) {\n if (this.modeInternal !== value) {\n const newInteractivity = isUIModeInteractive(value);\n this.inputWrapper.setActive(this.catcherHandler, newInteractivity);\n this.modeInternal = value;\n }\n }\n\n /** Rendering and input priority. Higher values on top. */\n public set zIndex(value: number) {\n assertValidNumber(value, \"UIInputDummy.zIndex\");\n this.inputWrapper.setZIndex(this.catcherHandler, value);\n }\n\n /** Removes element and frees resources */\n public override destroy(): void {\n this.solverWrapper.removeVariable(this.hVariable);\n this.solverWrapper.removeVariable(this.wVariable);\n this.inputWrapper.destroyInputCatcher(this.catcherHandler);\n super.destroy();\n }\n\n protected readonly catchPointerDown = (\n x: number,\n y: number,\n identifier: number,\n ): boolean => {\n return this.handleInputEvent(x, y, identifier, UIInputEvent.PRESSED);\n };\n\n protected readonly catchPointerMove = (\n x: number,\n y: number,\n identifier: number,\n ): boolean => {\n return this.handleInputEvent(x, y, identifier, UIInputEvent.MOVED);\n };\n\n protected readonly catchPointerUp = (\n x: number,\n y: number,\n identifier: number,\n ): boolean => {\n return this.handleInputEvent(x, y, identifier, UIInputEvent.RELEASED);\n };\n\n protected handleInputEvent(\n x: number,\n y: number,\n identifier: number,\n inputEvent: UIInputEvent,\n ): boolean {\n assertValidNumber(x, \"UIInputDummy.handleInputEvent.x\");\n assertValidNumber(y, \"UIInputDummy.handleInputEvent.y\");\n assertValidNumber(identifier, \"UIInputDummy.handleInputEvent.identifier\");\n\n const isPointerInside = this.interactionArea.contains(\n MathUtils.mapLinear(x, this.x, this.oppositeX, 0, 1),\n MathUtils.mapLinear(y, this.y, this.oppositeY, 0, 1),\n );\n\n if (isPointerInside) {\n this.emit(inputEvent, x, y, identifier, this);\n }\n\n if (this.wasPointerInside && !isPointerInside) {\n this.emit(UIInputEvent.LEFT, x, y, identifier, this);\n } else if (!this.wasPointerInside && isPointerInside) {\n this.emit(UIInputEvent.ENTERED, x, y, identifier, this);\n }\n\n this.wasPointerInside = isPointerInside;\n return (\n this.modeInternal !== UIMode.INTERACTIVE_TRANSPARENT && isPointerInside\n );\n }\n}\n","import type { UIMicroConfig } from \"../../miscellaneous/micro/UIMicro.Internal\";\nimport { UITransparencyMode } from \"../../miscellaneous/UITransparencyMode\";\nimport type { UIInputDummyOptions } from \"../UIInputDummy/UIInputDummy.Internal\";\n\n/** Configuration options for UIElement */\nexport interface UIElementOptions extends UIInputDummyOptions {\n /** Transforms that don't affect constraints */\n micro: Partial<UIMicroConfig>;\n /** Alpha blending mode */\n transparencyMode: UITransparencyMode;\n}\n\nexport const ELEMENT_DEFAULT_TRANSPARENCY_MODE = UITransparencyMode.BLEND;\n","import type { WebGLRenderer } from \"three\";\nimport { Matrix4 } from \"three\";\nimport type { UILayer } from \"../../layers/UILayer/UILayer\";\nimport { UILayerEvent } from \"../../layers/UILayer/UILayer.Internal\";\nimport { computeTransformMatrix } from \"../../miscellaneous/computeTransform\";\nimport type { UIProperty } from \"../../miscellaneous/generic-plane/shared\";\nimport { UIMicro } from \"../../miscellaneous/micro/UIMicro\";\nimport type { UIMode } from \"../../miscellaneous/UIMode\";\nimport { isUIModeVisible } from \"../../miscellaneous/UIMode\";\nimport type { UITransparencyMode } from \"../../miscellaneous/UITransparencyMode\";\nimport type { UISceneWrapperInterface } from \"../../wrappers/UISceneWrapper/UISceneWrapper.Internal\";\nimport { UIInputDummy } from \"../UIInputDummy/UIInputDummy\";\nimport type { UIElementOptions } from \"./UIElement.Internal\";\nimport { ELEMENT_DEFAULT_TRANSPARENCY_MODE } from \"./UIElement.Internal\";\n\n/** Base class for renderable UI elements */\nexport abstract class UIElement extends UIInputDummy {\n /** Transforms that don't affect constraints */\n public readonly micro: UIMicro;\n\n protected readonly sceneWrapper: UISceneWrapperInterface;\n protected planeHandler: number;\n\n private transparencyModeInternal: UITransparencyMode;\n private transparencyModeDirty = false;\n private visibilityDirty = false;\n\n /**\n * Creates a new UIElement instance.\n *\n * @param layer - Layer containing this element\n * @param source - GLSL shader source code\n * @param properties - Shader uniform properties\n * @param options - Configuration options\n */\n constructor(\n layer: UILayer,\n source: string,\n properties: Record<string, UIProperty>,\n options?: Partial<UIElementOptions>,\n ) {\n super(layer, options);\n this.micro = new UIMicro(options?.micro);\n\n this.transparencyModeInternal =\n options?.transparencyMode ?? ELEMENT_DEFAULT_TRANSPARENCY_MODE;\n\n this.sceneWrapper = this.layer.sceneWrapper;\n this.planeHandler = this.sceneWrapper.createPlane(\n source,\n properties,\n new Matrix4().identity(),\n isUIModeVisible(options?.mode ?? this.mode),\n this.transparencyModeInternal,\n );\n\n this.layer.on(UILayerEvent.RENDERING, this.onWillRender, this);\n }\n\n /** Alpha blending mode */\n public get transparencyMode(): UITransparencyMode {\n return this.transparencyModeInternal;\n }\n\n /** Alpha blending mode */\n public set transparencyMode(value: UITransparencyMode) {\n if (this.transparencyModeInternal !== value) {\n this.transparencyModeInternal = value;\n this.transparencyModeDirty = true;\n }\n }\n\n public override set mode(value: UIMode) {\n if (this.modeInternal !== value) {\n this.visibilityDirty =\n isUIModeVisible(this.modeInternal) !== isUIModeVisible(value);\n super.mode = value;\n }\n }\n\n /** Removes element and frees resources */\n public override destroy(): void {\n this.layer.off(UILayerEvent.RENDERING, this.onWillRender, this);\n this.sceneWrapper.destroyPlane(this.planeHandler);\n super.destroy();\n }\n\n protected setPlaneTransform(): void {\n if (\n this.micro.dirty ||\n this.inputWrapper.dirty ||\n this.solverWrapper.dirty\n ) {\n this.sceneWrapper.setTransform(\n this.planeHandler,\n computeTransformMatrix(\n this.x,\n this.y,\n this.width,\n this.height,\n this.zIndex,\n this.micro.x,\n this.micro.y,\n this.micro.anchorX,\n this.micro.anchorY,\n this.micro.scaleX,\n this.micro.scaleY,\n this.micro.rotation,\n this.micro.anchorMode,\n ),\n );\n this.micro.setDirtyFalse();\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars -- Required by UILayer event interface but not used in base implementation\n protected onWillRender(renderer: WebGLRenderer, deltaTime: number): void {\n if (this.transparencyModeDirty) {\n this.sceneWrapper.setTransparency(\n this.planeHandler,\n this.transparencyModeInternal,\n );\n this.transparencyModeDirty = false;\n }\n\n if (this.visibilityDirty) {\n this.sceneWrapper.setVisibility(\n this.planeHandler,\n isUIModeVisible(this.modeInternal),\n );\n this.visibilityDirty = false;\n }\n\n this.setPlaneTransform();\n }\n}\n","import type { UIColorConfig } from \"../../miscellaneous/color/UIColor.Internal\";\nimport type { UIElementOptions } from \"../UIElement/UIElement.Internal\";\n\n/** Animation playback events */\nexport enum UIAnimatedImageEvent {\n /** Animation started or resumed */\n PLAYED = 0,\n /** Animation paused */\n PAUSED = 1,\n /** Animation stopped and reset */\n STOPPED = 2,\n}\n\n/** Animation loop behavior */\nexport enum UIAnimatedImageLoopMode {\n /** No looping, stops at boundary frame */\n NONE = 0,\n /** Loops back to opposite frame */\n LOOP = 1,\n /** Reverses direction at boundaries */\n PING_PONG = 2,\n}\n\n/** Configuration options for UIAnimatedImage */\nexport interface UIAnimatedImageOptions extends UIElementOptions {\n /** Multiplicative tint */\n color: UIColorConfig;\n /** Animation speed in frames per second */\n frameRate: number;\n /** Playback speed multiplier. Can be negative for reverse playback. */\n timeScale: number;\n /** Loop behavior */\n loopMode: UIAnimatedImageLoopMode;\n /** Whether to start playing immediately */\n playByDefault: boolean;\n}\n\nexport const ANIMATED_IMAGE_DEFAULT_FRAME_RATE = 24;\nexport const ANIMATED_IMAGE_DEFAULT_TIME_SCALE = 1;\nexport const ANIMATED_IMAGE_DEFAULT_LOOP_MODE = UIAnimatedImageLoopMode.LOOP;\n","import type { Matrix3, WebGLRenderer } from \"three\";\nimport type { UILayer } from \"../../layers/UILayer/UILayer\";\nimport {\n assertValidNumber,\n assertValidPositiveNumber,\n} from \"../../miscellaneous/asserts\";\nimport { UIColor } from \"../../miscellaneous/color/UIColor\";\nimport type { UIColorConfig } from \"../../miscellaneous/color/UIColor.Internal\";\nimport { computeTrimmedTransformMatrix } from \"../../miscellaneous/computeTransform\";\nimport type { UIProperty } from \"../../miscellaneous/generic-plane/shared\";\nimport { UITextureView } from \"../../miscellaneous/texture/UITextureView\";\nimport type { UITextureConfig } from \"../../miscellaneous/texture/UITextureView.Internal\";\nimport { UITextureViewEvent } from \"../../miscellaneous/texture/UITextureView.Internal\";\nimport source from \"../../shaders/UIImage.glsl\";\nimport { UIElement } from \"../UIElement/UIElement\";\nimport type { UIAnimatedImageOptions } from \"./UIAnimatedImage.Internal\";\nimport {\n ANIMATED_IMAGE_DEFAULT_FRAME_RATE,\n ANIMATED_IMAGE_DEFAULT_LOOP_MODE,\n ANIMATED_IMAGE_DEFAULT_TIME_SCALE,\n UIAnimatedImageEvent,\n UIAnimatedImageLoopMode,\n} from \"./UIAnimatedImage.Internal\";\n\n/** Frame-based texture animation element */\nexport class UIAnimatedImage extends UIElement {\n private readonly colorInternal: UIColor;\n private readonly sequenceInternal: UITextureView[];\n\n private frameRateInternal: number;\n private timeScaleInternal: number;\n private loopModeInternal: UIAnimatedImageLoopMode;\n private readonly textureTransform: Matrix3;\n\n private isPlaying = false;\n private sequenceFrameIndex = 0;\n private currentFrameIndexDirty = false;\n private accumulatedTime = 0;\n\n /**\n * Creates a new UIAnimatedImage instance.\n *\n * Defaults size to first frame dimensions if width and height not provided.\n *\n * @param layer - Layer containing this element\n * @param sequence - Array of textures forming animation\n * @param options - Configuration options\n */\n constructor(\n layer: UILayer,\n sequence: UITextureConfig[],\n options: Partial<UIAnimatedImageOptions> = {},\n ) {\n const color = new UIColor(options.color);\n const uiTextures = sequence.map(\n (textureConfig) => new UITextureView(textureConfig),\n );\n\n const frame = uiTextures[0];\n options.width = options.width ?? frame.width;\n options.height = options.height ?? frame.height;\n\n const textureTransform = frame.calculateUVTransform();\n\n super(\n layer,\n source,\n {\n texture: frame.texture,\n textureTransform: textureTransform,\n color,\n },\n options,\n );\n\n this.colorInternal = color;\n this.sequenceInternal = uiTextures;\n this.textureTransform = textureTransform;\n this.frameRateInternal =\n options.frameRate ?? ANIMATED_IMAGE_DEFAULT_FRAME_RATE;\n this.timeScaleInternal =\n options.timeScale ?? ANIMATED_IMAGE_DEFAULT_TIME_SCALE;\n this.loopModeInternal =\n options.loopMode ?? ANIMATED_IMAGE_DEFAULT_LOOP_MODE;\n\n this.subscribeSequenceEvents();\n\n if (options.playByDefault === true) {\n this.play();\n }\n }\n\n /** Multiplicative tint. Alpha channel controls opacity. */\n public get color(): UIColor {\n return this.colorInternal;\n }\n\n /** Total animation duration in seconds */\n public get duration(): number {\n return this.sequenceInternal.length / this.frameRateInternal;\n }\n\n /** Animation speed in frames per second */\n public get frameRate(): number {\n return this.frameRateInternal;\n }\n\n /** Loop behavior */\n public get loopMode(): UIAnimatedImageLoopMode {\n return this.loopModeInternal;\n }\n\n /** Animation frames as readonly array */\n public get sequence(): readonly UITextureView[] {\n return this.sequenceInternal;\n }\n\n /** Playback speed multiplier. Can be negative for reverse playback. */\n public get timeScale(): number {\n return this.timeScaleInternal;\n }\n\n /** Multiplicative tint. Alpha channel controls opacity. */\n public set color(value: UIColorConfig) {\n this.colorInternal.set(value);\n }\n\n /** Animation speed in frames per second */\n public set frameRate(value: number) {\n assertValidPositiveNumber(value, \"UIAnimatedImage.frameRate\");\n this.frameRateInternal = value;\n }\n\n /** Loop behavior */\n public set loopMode(value: UIAnimatedImageLoopMode) {\n this.loopModeInternal = value;\n }\n\n /** Replaces animation frames. Stops playback. */\n public set sequence(sequence: UITextureConfig[]) {\n this.stop();\n this.unsubscribeSequenceEvents();\n\n const newLength = sequence.length;\n const currentLength = this.sequenceInternal.length;\n\n for (let i = 0; i < Math.min(newLength, currentLength); i++) {\n this.sequenceInternal[i].set(sequence[i]);\n }\n\n if (newLength < currentLength) {\n this.sequenceInternal.length = newLength;\n } else if (newLength > currentLength) {\n for (let i = currentLength; i < newLength; i++) {\n this.sequenceInternal.push(new UITextureView(sequence[i]));\n }\n }\n\n this.subscribeSequenceEvents();\n }\n\n /** Playback speed multiplier. Can be negative for reverse playback. */\n public set timeScale(value: number) {\n assertValidNumber(value, \"UIAnimatedImage.timeScale\");\n this.timeScaleInternal = value;\n }\n\n /** Removes element and frees resources */\n public override destroy(): void {\n this.unsubscribeSequenceEvents();\n super.destroy();\n }\n\n /** Starts or resumes animation playback */\n public play(): void {\n if (!this.isPlaying) {\n this.isPlaying = true;\n this.emit(UIAnimatedImageEvent.PLAYED);\n }\n }\n\n /** Pauses animation at current frame */\n public pause(): void {\n if (this.isPlaying) {\n this.isPlaying = false;\n this.emit(UIAnimatedImageEvent.PAUSED);\n }\n }\n\n /** Stops animation and resets to first frame */\n public stop(): void {\n if (\n this.isPlaying ||\n this.accumulatedTime > 0 ||\n this.sequenceFrameIndex > 0\n ) {\n this.isPlaying = false;\n this.accumulatedTime = 0;\n this.sequenceFrameIndex = 0;\n this.currentFrameIndexDirty = true;\n this.emit(UIAnimatedImageEvent.STOPPED);\n }\n }\n\n protected override onWillRender(\n renderer: WebGLRenderer,\n deltaTime: number,\n ): void {\n if (this.isPlaying && this.timeScaleInternal !== 0) {\n this.accumulatedTime += deltaTime * this.timeScaleInternal;\n const frameDuration = 1 / this.frameRateInternal;\n const sequenceLength = this.sequenceInternal.length;\n const lastFrameIndex = sequenceLength - 1;\n\n if (this.timeScaleInternal > 0) {\n while (this.accumulatedTime >= frameDuration) {\n this.accumulatedTime -= frameDuration;\n this.sequenceFrameIndex += 1;\n\n if (this.sequenceFrameIndex >= sequenceLength) {\n if (this.loopModeInternal === UIAnimatedImageLoopMode.LOOP) {\n this.sequenceFrameIndex = 0;\n } else if (\n this.loopModeInternal === UIAnimatedImageLoopMode.PING_PONG\n ) {\n this.sequenceFrameIndex = lastFrameIndex;\n this.timeScaleInternal = -this.timeScaleInternal;\n } else {\n this.sequenceFrameIndex = lastFrameIndex;\n this.isPlaying = false;\n this.emit(UIAnimatedImageEvent.PAUSED);\n break;\n }\n }\n\n this.currentFrameIndexDirty = true;\n }\n } else {\n while (this.accumulatedTime <= -frameDuration) {\n this.accumulatedTime += frameDuration;\n this.sequenceFrameIndex -= 1;\n\n if (this.sequenceFrameIndex < 0) {\n if (this.loopModeInternal === UIAnimatedImageLoopMode.LOOP) {\n this.sequenceFrameIndex = lastFrameIndex;\n } else if (\n this.loopModeInternal === UIAnimatedImageLoopMode.PING_PONG\n ) {\n this.sequenceFrameIndex = 0;\n this.timeScaleInternal = -this.timeScaleInternal;\n } else {\n this.sequenceFrameIndex = 0;\n this.isPlaying = false;\n this.emit(UIAnimatedImageEvent.PAUSED);\n break;\n }\n }\n\n this.currentFrameIndexDirty = true;\n }\n }\n }\n\n super.onWillRender(renderer, deltaTime);\n }\n\n protected override setPlaneTransform(): void {\n let properties: Record<string, UIProperty> | undefined;\n\n if (this.colorInternal.dirty) {\n properties ??= {};\n properties[\"color\"] = this.colorInternal;\n this.colorInternal.setDirtyFalse();\n }\n\n const frame = this.sequenceInternal[this.sequenceFrameIndex];\n if (frame.textureDirty || this.currentFrameIndexDirty) {\n properties ??= {};\n properties[\"texture\"] = frame.texture;\n frame.setTextureDirtyFalse();\n }\n\n if (frame.uvTransformDirty || this.currentFrameIndexDirty) {\n properties ??= {};\n properties[\"textureTransform\"] = frame.calculateUVTransform(\n this.textureTransform,\n );\n frame.setUVTransformDirtyFalse();\n }\n\n if (properties) {\n this.sceneWrapper.setProperties(this.planeHandler, properties);\n }\n\n const isTransformDirty =\n this.currentFrameIndexDirty ||\n this.micro.dirty ||\n frame.trimDirty ||\n this.inputWrapper.dirty ||\n this.solverWrapper.dirty;\n\n if (isTransformDirty) {\n const micro = this.micro;\n const textureTrim = frame.trim;\n\n this.sceneWrapper.setTransform(\n this.planeHandler,\n computeTrimmedTransformMatrix(\n this.x,\n this.y,\n this.width,\n this.height,\n this.zIndex,\n micro.x,\n micro.y,\n micro.anchorX,\n micro.anchorY,\n micro.scaleX,\n micro.scaleY,\n micro.rotation,\n micro.anchorMode,\n textureTrim.left,\n textureTrim.right,\n textureTrim.top,\n textureTrim.bottom,\n ),\n );\n\n this.currentFrameIndexDirty = false;\n this.micro.setDirtyFalse();\n frame.setTrimDirtyFalse();\n }\n }\n\n private readonly onTextureDimensionsChanged = (\n width: number,\n height: number,\n texture: UITextureView,\n ): void => {\n if (this.sequenceInternal[this.sequenceFrameIndex] === texture) {\n this.width = width;\n this.height = height;\n }\n };\n\n private subscribeSequenceEvents(): void {\n for (const frame of this.sequenceInternal) {\n frame.on(\n UITextureViewEvent.DIMENSIONS_CHANGED,\n this.onTextureDimensionsChanged,\n );\n }\n }\n\n private unsubscribeSequenceEvents(): void {\n for (const frame of this.sequenceInternal) {\n frame.off(\n UITextureViewEvent.DIMENSIONS_CHANGED,\n this.onTextureDimensionsChanged,\n );\n }\n }\n}\n","import { UIColor } from \"../../miscellaneous/color/UIColor\";\nimport type { UIColorConfig } from \"../../miscellaneous/color/UIColor.Internal\";\nimport type { UIElementOptions } from \"../UIElement/UIElement.Internal\";\n\n/** Configuration options for UIGraphics */\nexport interface UIGraphicsOptions extends UIElementOptions {\n /** Multiplicative tint */\n color: UIColorConfig;\n}\n\nexport const GRAPHICS_DEFAULT_WIDTH = 2;\nexport const GRAPHICS_DEFAULT_HEIGHT = 2;\nexport const GRAPHICS_TEMP_COLOR = new UIColor();\n","import type { WebGLRenderer } from \"three\";\nimport { CanvasTexture, LinearFilter, Matrix4, SRGBColorSpace } from \"three\";\nimport type { UILayer } from \"../../layers/UILayer/UILayer\";\nimport { UIColor } from \"../../miscellaneous/color/UIColor\";\nimport type { UIColorConfig } from \"../../miscellaneous/color/UIColor.Internal\";\nimport source from \"../../shaders/UIImage.glsl\";\nimport { UIElement } from \"../UIElement/UIElement\";\nimport {\n GRAPHICS_DEFAULT_HEIGHT,\n GRAPHICS_DEFAULT_WIDTH,\n GRAPHICS_TEMP_COLOR,\n type UIGraphicsOptions,\n} from \"./UIGraphics.Internal\";\n\n/** Canvas-based 2D drawing element */\nexport class UIGraphics extends UIElement {\n private readonly colorInternal: UIColor;\n private readonly canvas: OffscreenCanvas;\n private readonly context: OffscreenCanvasRenderingContext2D;\n private readonly texture: CanvasTexture;\n\n /**\n * Creates a new UIGraphics instance.\n *\n * @param layer - Layer containing this element\n * @param options - Configuration options\n */\n constructor(layer: UILayer, options?: Partial<UIGraphicsOptions>) {\n const w = options?.width ?? GRAPHICS_DEFAULT_WIDTH;\n const h = options?.height ?? GRAPHICS_DEFAULT_HEIGHT;\n const color = new UIColor(options?.color);\n\n const canvas = new OffscreenCanvas(w, h);\n const context = canvas.getContext(\"2d\");\n\n if (!context) {\n throw new Error(\n \"UIGraphics.constructor: failed to get 2D context from OffscreenCanvas\",\n );\n }\n\n const texture = new CanvasTexture(canvas);\n texture.colorSpace = SRGBColorSpace;\n texture.minFilter = LinearFilter;\n texture.magFilter = LinearFilter;\n texture.needsUpdate = true;\n\n super(\n layer,\n source,\n {\n texture: texture,\n textureTransform: new Matrix4(),\n color,\n },\n options,\n );\n\n this.canvas = canvas;\n this.context = context;\n this.texture = texture;\n this.colorInternal = color;\n }\n\n /** Multiplicative tint. Alpha channel controls opacity. */\n public get color(): UIColor {\n return this.colorInternal;\n }\n\n /** Multiplicative tint. Alpha channel controls opacity. */\n public set color(value: UIColorConfig) {\n this.colorInternal.set(value);\n }\n\n /**\n * Clears canvas. Optionally fills with color.\n *\n * @param color - Fill color after clearing\n */\n public clear(color?: UIColorConfig): this {\n this.context.clearRect(0, 0, this.canvas.width, this.canvas.height);\n if (color !== undefined) {\n this.context.fillStyle = GRAPHICS_TEMP_COLOR.set(color).toCSSColor();\n this.context.fillRect(0, 0, this.canvas.width, this.canvas.height);\n }\n this.texture.needsUpdate = true;\n return this;\n }\n\n /** Draws filled rectangle */\n public drawRect(\n x: number,\n y: number,\n width: number,\n height: number,\n color: UIColorConfig,\n ): this {\n this.context.fillStyle = GRAPHICS_TEMP_COLOR.set(color).toCSSColor();\n this.context.fillRect(x, y, width, height);\n this.texture.needsUpdate = true;\n return this;\n }\n\n /** Draws filled circle */\n public drawCircle(\n x: number,\n y: number,\n radius: number,\n color: UIColorConfig,\n ): this {\n this.context.fillStyle = GRAPHICS_TEMP_COLOR.set(color).toCSSColor();\n this.context.beginPath();\n this.context.arc(x, y, radius, 0, Math.PI * 2);\n this.context.fill();\n this.texture.needsUpdate = true;\n return this;\n }\n\n /**\n * Draws filled arc.\n *\n * @param startAngle - Start angle in radians\n * @param endAngle - End angle in radians\n */\n public drawArc(\n x: number,\n y: number,\n radius: number,\n startAngle: number,\n endAngle: number,\n color: UIColorConfig,\n ): this {\n this.context.fillStyle = GRAPHICS_TEMP_COLOR.set(color).toCSSColor();\n this.context.beginPath();\n this.context.arc(x, y, radius, startAngle, endAngle);\n this.context.fill();\n this.texture.needsUpdate = true;\n return this;\n }\n\n /**\n * Draws connected line segments.\n *\n * @param points - Array of [x, y] pairs\n * @param lineWidth - Line width in pixels\n */\n public drawPolyline(\n points: [number, number][],\n color: UIColor,\n lineWidth = 1,\n ): this {\n if (points.length < 2) {\n return this;\n }\n\n this.context.strokeStyle = GRAPHICS_TEMP_COLOR.set(color).toCSSColor();\n this.context.lineWidth = lineWidth;\n this.context.beginPath();\n this.context.moveTo(points[0][0], points[0][1]);\n\n for (let i = 1; i < points.length; i++) {\n this.context.lineTo(points[i][0], points[i][1]);\n }\n\n this.context.stroke();\n this.texture.needsUpdate = true;\n return this;\n }\n\n /** Removes element and frees resources */\n public override destroy(): void {\n this.texture.dispose();\n super.destroy();\n }\n\n protected override onWillRender(\n renderer: WebGLRenderer,\n deltaTime: number,\n ): void {\n if (this.colorInternal.dirty) {\n this.sceneWrapper.setProperties(this.planeHandler, {\n color: this.colorInternal,\n });\n this.colorInternal.setDirtyFalse();\n }\n\n super.onWillRender(renderer, deltaTime);\n }\n}\n","import type { Matrix3 } from \"three\";\nimport type { UILayer } from \"../../layers/UILayer/UILayer\";\nimport { UIColor } from \"../../miscellaneous/color/UIColor\";\nimport type { UIColorConfig } from \"../../miscellaneous/color/UIColor.Internal\";\nimport { computeTrimmedTransformMatrix } from \"../../miscellaneous/computeTransform\";\nimport type { UIProperty } from \"../../miscellaneous/generic-plane/shared\";\nimport { UITextureView } from \"../../miscellaneous/texture/UITextureView\";\nimport type { UITextureConfig } from \"../../miscellaneous/texture/UITextureView.Internal\";\nimport { UITextureViewEvent } from \"../../miscellaneous/texture/UITextureView.Internal\";\nimport source from \"../../shaders/UIImage.glsl\";\nimport { UIElement } from \"../UIElement/UIElement\";\nimport type { UIImageOptions } from \"./UIImage.Internal\";\n\n/** Textured image element */\nexport class UIImage extends UIElement {\n /** Texture displayed by this image */\n public readonly texture: UITextureView;\n\n private readonly colorInternal: UIColor;\n private readonly textureTransform: Matrix3;\n\n /**\n * Creates a new UIImage instance.\n *\n * Defaults size to texture dimensions if width and height not provided.\n *\n * @param layer - Layer containing this image\n * @param texture - Texture to display\n * @param options - Configuration options\n */\n constructor(\n layer: UILayer,\n texture: UITextureConfig,\n options: Partial<UIImageOptions> = {},\n ) {\n const color = new UIColor(options.color);\n const textureView = new UITextureView(texture);\n const textureTransform = textureView.calculateUVTransform();\n\n options.width = options.width ?? textureView.width;\n options.height = options.height ?? textureView.height;\n\n super(\n layer,\n source,\n {\n texture: textureView.texture,\n textureTransform: textureTransform,\n color,\n },\n options,\n );\n\n this.texture = textureView;\n this.textureTransform = textureTransform;\n this.colorInternal = color;\n\n this.texture.on(\n UITextureViewEvent.DIMENSIONS_CHANGED,\n this.onTextureDimensionsChanged,\n );\n }\n\n /** Multiplicative tint. Alpha channel controls opacity. */\n public get color(): UIColor {\n return this.colorInternal;\n }\n\n /** Multiplicative tint. Alpha channel controls opacity. */\n public set color(value: UIColorConfig) {\n this.colorInternal.set(value);\n }\n\n /** Removes image and frees resources */\n public override destroy(): void {\n this.texture.off(\n UITextureViewEvent.DIMENSIONS_CHANGED,\n this.onTextureDimensionsChanged,\n );\n super.destroy();\n }\n\n protected override setPlaneTransform(): void {\n let properties: Record<string, UIProperty> | undefined;\n\n if (this.colorInternal.dirty) {\n properties ??= {};\n properties[\"color\"] = this.colorInternal;\n this.colorInternal.setDirtyFalse();\n }\n\n if (this.texture.textureDirty) {\n properties ??= {};\n properties[\"texture\"] = this.texture.texture;\n this.texture.setTextureDirtyFalse();\n }\n\n if (this.texture.uvTransformDirty) {\n properties ??= {};\n properties[\"textureTransform\"] = this.texture.calculateUVTransform(\n this.textureTransform,\n );\n this.texture.setUVTransformDirtyFalse();\n }\n\n if (properties) {\n this.sceneWrapper.setProperties(this.planeHandler, properties);\n }\n\n const isTransformDirty =\n this.micro.dirty ||\n this.texture.trimDirty ||\n this.inputWrapper.dirty ||\n this.solverWrapper.dirty;\n\n if (isTransformDirty) {\n const micro = this.micro;\n const textureTrim = this.texture.trim;\n\n this.sceneWrapper.setTransform(\n this.planeHandler,\n computeTrimmedTransformMatrix(\n this.x,\n this.y,\n this.width,\n this.height,\n this.zIndex,\n micro.x,\n micro.y,\n micro.anchorX,\n micro.anchorY,\n micro.scaleX,\n micro.scaleY,\n micro.rotation,\n micro.anchorMode,\n textureTrim.left,\n textureTrim.right,\n textureTrim.top,\n textureTrim.bottom,\n ),\n );\n this.micro.setDirtyFalse();\n this.texture.setTrimDirtyFalse();\n }\n }\n\n private readonly onTextureDimensionsChanged = (\n width: number,\n height: number,\n ): void => {\n this.width = width;\n this.height = height;\n };\n}\n","import { Vector4 } from \"three\";\nimport { assertValidNonNegativeNumber } from \"../asserts\";\nimport type { UIInsetsConfig } from \"./UIInsets.Internal\";\nimport { INSETS_DEFAULT_VALUE } from \"./UIInsets.Internal\";\n\n/** Insets values for four sides */\nexport class UIInsets {\n private lInternal = INSETS_DEFAULT_VALUE;\n private rInternal = INSETS_DEFAULT_VALUE;\n private tInternal = INSETS_DEFAULT_VALUE;\n private bInternal = INSETS_DEFAULT_VALUE;\n\n private dirtyInternal = false;\n\n /**\n * Creates UIInsets instance.\n *\n * @param config - Insets configuration\n */\n constructor(config?: UIInsetsConfig) {\n this.set(config);\n }\n\n /** Left inset */\n public get left(): number {\n return this.lInternal;\n }\n\n /** Right inset */\n public get right(): number {\n return this.rInternal;\n }\n\n /** Top inset */\n public get top(): number {\n return this.tInternal;\n }\n\n /** Bottom inset */\n public get bottom(): number {\n return this.bInternal;\n }\n\n /** @internal */\n public get dirty(): boolean {\n return this.dirtyInternal;\n }\n\n /** Left inset */\n public set left(value: number) {\n assertValidNonNegativeNumber(value, \"UIInsets.left\");\n if (this.lInternal !== value) {\n this.lInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n /** Right inset */\n public set right(value: number) {\n assertValidNonNegativeNumber(value, \"UIInsets.right\");\n if (this.rInternal !== value) {\n this.rInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n /** Top inset */\n public set top(value: number) {\n assertValidNonNegativeNumber(value, \"UIInsets.top\");\n if (this.tInternal !== value) {\n this.tInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n /** Bottom inset */\n public set bottom(value: number) {\n assertValidNonNegativeNumber(value, \"UIInsets.bottom\");\n if (this.bInternal !== value) {\n this.bInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n /** Sets left and right to same value */\n public setHorizontal(value: number): void {\n assertValidNonNegativeNumber(value, \"UIInsets.setHorizontal.value\");\n if (this.lInternal !== value || this.rInternal !== value) {\n this.lInternal = value;\n this.rInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n /** Sets top and bottom to same value */\n public setVertical(value: number): void {\n assertValidNonNegativeNumber(value, \"UIInsets.setVertical.value\");\n if (this.tInternal !== value || this.bInternal !== value) {\n this.tInternal = value;\n this.bInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n /** Sets all sides to same value */\n public setUnified(value: number): void {\n assertValidNonNegativeNumber(value, \"UIInsets.setUnified.value\");\n if (\n this.lInternal !== value ||\n this.rInternal !== value ||\n this.tInternal !== value ||\n this.bInternal !== value\n ) {\n this.lInternal = value;\n this.rInternal = value;\n this.tInternal = value;\n this.bInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n /** Sets insets */\n public set(config?: UIInsetsConfig): void {\n const lOld = this.lInternal;\n const rOld = this.rInternal;\n const tOld = this.tInternal;\n const bOld = this.bInternal;\n\n if (config === undefined) {\n this.lInternal = INSETS_DEFAULT_VALUE;\n this.rInternal = INSETS_DEFAULT_VALUE;\n this.tInternal = INSETS_DEFAULT_VALUE;\n this.bInternal = INSETS_DEFAULT_VALUE;\n } else if (typeof config === \"number\") {\n assertValidNonNegativeNumber(config, \"UIInsets.set.config\");\n this.lInternal = config;\n this.rInternal = config;\n this.tInternal = config;\n this.bInternal = config;\n } else if (Array.isArray(config)) {\n if (config.length === 2) {\n const horizontal = config[0];\n const vertical = config[1];\n assertValidNonNegativeNumber(horizontal, \"UIInsets.set.config[0]\");\n assertValidNonNegativeNumber(vertical, \"UIInsets.set.config[1]\");\n this.lInternal = horizontal;\n this.rInternal = horizontal;\n this.tInternal = vertical;\n this.bInternal = vertical;\n } else {\n const left = config[0];\n const right = config[1];\n const top = config[2];\n const bottom = config[3];\n assertValidNonNegativeNumber(left, \"UIInsets.set.config[0]\");\n assertValidNonNegativeNumber(right, \"UIInsets.set.config[1]\");\n assertValidNonNegativeNumber(top, \"UIInsets.set.config[2]\");\n assertValidNonNegativeNumber(bottom, \"UIInsets.set.config[3]\");\n this.lInternal = left;\n this.rInternal = right;\n this.tInternal = top;\n this.bInternal = bottom;\n }\n } else if (\"left\" in config) {\n const left = config.left;\n const right = config.right;\n const top = config.top;\n const bottom = config.bottom;\n assertValidNonNegativeNumber(left, \"UIInsets.set.config.left\");\n assertValidNonNegativeNumber(right, \"UIInsets.set.config.right\");\n assertValidNonNegativeNumber(top, \"UIInsets.set.config.top\");\n assertValidNonNegativeNumber(bottom, \"UIInsets.set.config.bottom\");\n this.lInternal = left;\n this.rInternal = right;\n this.tInternal = top;\n this.bInternal = bottom;\n } else {\n const horizontal = config.horizontal;\n const vertical = config.vertical;\n assertValidNonNegativeNumber(\n horizontal,\n \"UIInsets.set.config.horizontal\",\n );\n assertValidNonNegativeNumber(vertical, \"UIInsets.set.config.vertical\");\n this.lInternal = horizontal;\n this.rInternal = horizontal;\n this.tInternal = vertical;\n this.bInternal = vertical;\n }\n\n if (\n this.lInternal !== lOld ||\n this.rInternal !== rOld ||\n this.tInternal !== tOld ||\n this.bInternal !== bOld\n ) {\n this.dirtyInternal = true;\n }\n }\n\n /** Sets from Vector4 (x=left, y=right, z=top, w=bottom) */\n public setVector4(vector: Vector4): void {\n assertValidNonNegativeNumber(vector.x, \"UIInsets.setVector4.vector.x\");\n assertValidNonNegativeNumber(vector.y, \"UIInsets.setVector4.vector.y\");\n assertValidNonNegativeNumber(vector.z, \"UIInsets.setVector4.vector.z\");\n assertValidNonNegativeNumber(vector.w, \"UIInsets.setVector4.vector.w\");\n if (\n this.lInternal !== vector.x ||\n this.rInternal !== vector.y ||\n this.tInternal !== vector.z ||\n this.bInternal !== vector.w\n ) {\n this.lInternal = vector.x;\n this.rInternal = vector.y;\n this.tInternal = vector.z;\n this.bInternal = vector.w;\n this.dirtyInternal = true;\n }\n }\n\n /** Converts to Vector4 (left, right, top, bottom) */\n public toVector4(result = new Vector4()): Vector4 {\n return result.set(\n this.lInternal,\n this.rInternal,\n this.tInternal,\n this.bInternal,\n );\n }\n\n /** Resets all sides to 0 */\n public reset(): void {\n this.setUnified(0);\n }\n\n /** Copies from another instance */\n public copy(other: UIInsets): void {\n if (\n this.lInternal !== other.lInternal ||\n this.rInternal !== other.rInternal ||\n this.tInternal !== other.tInternal ||\n this.bInternal !== other.bInternal\n ) {\n this.lInternal = other.lInternal;\n this.rInternal = other.rInternal;\n this.tInternal = other.tInternal;\n this.bInternal = other.bInternal;\n this.dirtyInternal = true;\n }\n }\n\n /** @internal */\n public setDirtyFalse(): void {\n this.dirtyInternal = false;\n }\n}\n","/** Insets configuration as number, per-side, or per-axis */\nexport type UIInsetsConfig =\n | { horizontal: number; vertical: number }\n | { left: number; right: number; top: number; bottom: number }\n | [number, number, number, number]\n | [number, number]\n | number;\n\nexport const INSETS_DEFAULT_VALUE = 0;\n","import type { UIColorConfig } from \"../../miscellaneous/color/UIColor.Internal\";\nimport type { UIInsetsConfig } from \"../../miscellaneous/insets/UIInsets.Internal\";\nimport type { UIElementOptions } from \"../UIElement/UIElement.Internal\";\n\n/** Controls how sliceRegions values are interpreted */\nexport enum UINineSliceRegionMode {\n /** sliceRegions in normalized coordinates (0 to 1) */\n NORMALIZED = 0,\n /** sliceRegions in world units */\n WORLD = 1,\n}\n\n/** Configuration options for UINineSlice */\nexport interface UINineSliceOptions extends UIElementOptions {\n /** Multiplicative tint */\n color: UIColorConfig;\n /** Border size in normalized texture coordinates (0 to 1) */\n sliceBorders: UIInsetsConfig;\n /** Region size. Interpretation depends on regionMode. */\n sliceRegions: UIInsetsConfig;\n /** How sliceRegions values are interpreted */\n regionMode: UINineSliceRegionMode;\n}\n\nexport const NINE_SLICE_DEFAULT_BORDER = 0.1;\nexport const NINE_SLICE_DEFAULT_REGION_MODE = UINineSliceRegionMode.WORLD;\n","import type { Matrix3 } from \"three\";\nimport { Vector4 } from \"three\";\nimport type { UILayer } from \"../../layers/UILayer/UILayer\";\nimport { UIColor } from \"../../miscellaneous/color/UIColor\";\nimport type { UIColorConfig } from \"../../miscellaneous/color/UIColor.Internal\";\nimport { computeTrimmedTransformMatrix } from \"../../miscellaneous/computeTransform\";\nimport type { UIProperty } from \"../../miscellaneous/generic-plane/shared\";\nimport { UIInsets } from \"../../miscellaneous/insets/UIInsets\";\nimport type { UIInsetsConfig } from \"../../miscellaneous/insets/UIInsets.Internal\";\nimport { UITextureView } from \"../../miscellaneous/texture/UITextureView\";\nimport type { UITextureConfig } from \"../../miscellaneous/texture/UITextureView.Internal\";\nimport { UITextureViewEvent } from \"../../miscellaneous/texture/UITextureView.Internal\";\nimport source from \"../../shaders/UINineSlice.glsl\";\nimport { UIElement } from \"../UIElement/UIElement\";\nimport type { UINineSliceOptions } from \"./UINineSlice.Internal\";\nimport {\n NINE_SLICE_DEFAULT_BORDER,\n NINE_SLICE_DEFAULT_REGION_MODE,\n UINineSliceRegionMode,\n} from \"./UINineSlice.Internal\";\n\n/** Scalable textured image preserving border regions */\nexport class UINineSlice extends UIElement {\n /** Texture displayed by this element */\n public readonly texture: UITextureView;\n\n private readonly colorInternal: UIColor;\n private readonly sliceBordersInternal: UIInsets;\n private readonly sliceRegionsInternal: UIInsets;\n private regionModeInternal: UINineSliceRegionMode;\n private regionModeDirty = true;\n\n private readonly textureTransform: Matrix3;\n private readonly sliceBordersVector = new Vector4();\n private readonly sliceRegionsVector = new Vector4();\n\n private lastElementWidth: number;\n private lastElementHeight: number;\n\n private textureDimensionsDirty = true;\n\n /**\n * Creates a new UINineSlice instance.\n *\n * Defaults size to texture dimensions if width and height not provided.\n *\n * @param layer - Layer containing this element\n * @param texture - Texture to display\n * @param options - Configuration options\n */\n constructor(\n layer: UILayer,\n texture: UITextureConfig,\n options: Partial<UINineSliceOptions> = {},\n ) {\n const color = new UIColor(options.color);\n const textureView = new UITextureView(texture);\n const textureTransform = textureView.calculateUVTransform();\n\n options.width = options.width ?? textureView.width;\n options.height = options.height ?? textureView.height;\n\n const sliceBorders = new UIInsets(\n options.sliceBorders ?? NINE_SLICE_DEFAULT_BORDER,\n );\n const sliceRegions = new UIInsets(\n options.sliceRegions ?? NINE_SLICE_DEFAULT_BORDER,\n );\n\n const regionMode = options.regionMode ?? NINE_SLICE_DEFAULT_REGION_MODE;\n\n const sliceBordersVector = new Vector4();\n const sliceRegionsVector = new Vector4();\n\n super(\n layer,\n source,\n {\n texture: textureView.texture,\n textureTransform: textureTransform,\n color,\n sliceBorders: sliceBordersVector,\n sliceRegions: sliceRegionsVector,\n },\n options,\n );\n\n this.texture = textureView;\n this.textureTransform = textureTransform;\n this.colorInternal = color;\n this.sliceBordersInternal = sliceBorders;\n this.sliceRegionsInternal = sliceRegions;\n this.regionModeInternal = regionMode;\n\n this.sliceBordersVector = sliceBordersVector;\n this.sliceRegionsVector = sliceRegionsVector;\n\n this.lastElementWidth = this.width;\n this.lastElementHeight = this.height;\n\n this.texture.on(\n UITextureViewEvent.DIMENSIONS_CHANGED,\n this.onTextureDimensionsChanged,\n );\n }\n\n /** Multiplicative tint. Alpha channel controls opacity. */\n public get color(): UIColor {\n return this.colorInternal;\n }\n\n /** Controls how sliceRegions values are interpreted */\n public get regionMode(): UINineSliceRegionMode {\n return this.regionModeInternal;\n }\n\n /** Border size in normalized texture coordinates (0 to 1) */\n public get sliceBorders(): UIInsets {\n return this.sliceBordersInternal;\n }\n\n /** Region size. Interpretation depends on regionMode. */\n public get sliceRegions(): UIInsets {\n return this.sliceRegionsInternal;\n }\n\n /** Multiplicative tint. Alpha channel controls opacity. */\n public set color(value: UIColorConfig) {\n this.colorInternal.set(value);\n }\n\n /** Controls how sliceRegions values are interpreted */\n public set regionMode(value: UINineSliceRegionMode) {\n if (this.regionModeInternal !== value) {\n this.regionModeInternal = value;\n this.regionModeDirty = true;\n }\n }\n\n /** Border size in normalized texture coordinates (0 to 1) */\n public set sliceBorders(value: UIInsetsConfig) {\n this.sliceBordersInternal.set(value);\n }\n\n /** Region size. Interpretation depends on regionMode. */\n public set sliceRegions(value: UIInsetsConfig) {\n this.sliceRegionsInternal.set(value);\n }\n\n /** Removes nine slice and frees resources */\n public override destroy(): void {\n this.texture.off(\n UITextureViewEvent.DIMENSIONS_CHANGED,\n this.onTextureDimensionsChanged,\n );\n super.destroy();\n }\n\n protected override setPlaneTransform(): void {\n let properties: Record<string, UIProperty> | undefined;\n\n const sliceBordersDirty =\n this.textureDimensionsDirty ||\n this.sliceBordersInternal.dirty ||\n this.texture.trimDirty;\n\n if (sliceBordersDirty) {\n properties ??= {};\n properties[\"sliceBorders\"] = this.calculateSliceBordersForShader(\n this.sliceBordersVector,\n );\n this.sliceBordersInternal.setDirtyFalse();\n this.textureDimensionsDirty = false;\n }\n\n const sliceRegionsDirty =\n this.sliceRegionsInternal.dirty ||\n this.regionModeDirty ||\n (this.regionModeInternal === UINineSliceRegionMode.WORLD &&\n this.checkElementDimensionsDirty());\n\n if (sliceRegionsDirty) {\n properties ??= {};\n properties[\"sliceRegions\"] = this.calculateSliceRegionsForShader(\n this.sliceRegionsVector,\n );\n this.sliceRegionsInternal.setDirtyFalse();\n this.regionModeDirty = false;\n this.setElementDimensionsDirtyFalse();\n }\n\n if (this.colorInternal.dirty) {\n properties ??= {};\n properties[\"color\"] = this.colorInternal;\n this.colorInternal.setDirtyFalse();\n }\n\n if (this.texture.textureDirty) {\n properties ??= {};\n properties[\"texture\"] = this.texture.texture;\n this.texture.setTextureDirtyFalse();\n }\n\n if (this.texture.uvTransformDirty) {\n properties ??= {};\n properties[\"textureTransform\"] = this.texture.calculateUVTransform(\n this.textureTransform,\n );\n this.texture.setUVTransformDirtyFalse();\n }\n\n if (properties) {\n this.sceneWrapper.setProperties(this.planeHandler, properties);\n }\n\n const isTransformDirty =\n this.micro.dirty ||\n this.texture.trimDirty ||\n this.inputWrapper.dirty ||\n this.solverWrapper.dirty;\n\n if (isTransformDirty) {\n const micro = this.micro;\n const textureTrim = this.texture.trim;\n\n this.sceneWrapper.setTransform(\n this.planeHandler,\n computeTrimmedTransformMatrix(\n this.x,\n this.y,\n this.width,\n this.height,\n this.zIndex,\n micro.x,\n micro.y,\n micro.anchorX,\n micro.anchorY,\n micro.scaleX,\n micro.scaleY,\n micro.rotation,\n micro.anchorMode,\n textureTrim.left,\n textureTrim.right,\n textureTrim.top,\n textureTrim.bottom,\n ),\n );\n this.micro.setDirtyFalse();\n this.texture.setTrimDirtyFalse();\n }\n }\n\n private calculateSliceBordersForShader(result: Vector4): Vector4 {\n const sourceWidth = this.texture.width;\n const sourceHeight = this.texture.height;\n const trim = this.texture.trim;\n\n const trimmedWidth = sourceWidth - trim.left - trim.right;\n const trimmedHeight = sourceHeight - trim.top - trim.bottom;\n\n const trimNLeft = trim.left / sourceWidth;\n const trimNRight = trim.right / sourceWidth;\n const trimNTop = trim.top / sourceHeight;\n const trimNBottom = trim.bottom / sourceHeight;\n\n const trimmedWidthNorm = trimmedWidth / sourceWidth;\n const trimmedHeightNorm = trimmedHeight / sourceHeight;\n\n const srcLeft = this.sliceBordersInternal.left;\n const srcRight = this.sliceBordersInternal.right;\n const srcTop = this.sliceBordersInternal.top;\n const srcBottom = this.sliceBordersInternal.bottom;\n\n const left = Math.max(0, srcLeft - trimNLeft) / trimmedWidthNorm;\n const right = Math.max(0, srcRight - trimNRight) / trimmedWidthNorm;\n const top = Math.max(0, srcTop - trimNTop) / trimmedHeightNorm;\n const bottom = Math.max(0, srcBottom - trimNBottom) / trimmedHeightNorm;\n\n return result.set(\n Math.min(1, left),\n Math.min(1, right),\n Math.min(1, top),\n Math.min(1, bottom),\n );\n }\n\n private calculateSliceRegionsForShader(result: Vector4): Vector4 {\n if (this.regionModeInternal === UINineSliceRegionMode.NORMALIZED) {\n return result.set(\n this.sliceRegionsInternal.left,\n this.sliceRegionsInternal.right,\n this.sliceRegionsInternal.top,\n this.sliceRegionsInternal.bottom,\n );\n }\n\n const width = this.width;\n const height = this.height;\n\n return result.set(\n this.sliceRegionsInternal.left / width,\n this.sliceRegionsInternal.right / width,\n this.sliceRegionsInternal.top / height,\n this.sliceRegionsInternal.bottom / height,\n );\n }\n\n private checkElementDimensionsDirty(): boolean {\n return (\n this.solverWrapper.dirty &&\n (this.lastElementWidth !== Math.round(this.width) ||\n this.lastElementHeight !== Math.round(this.height))\n );\n }\n\n private setElementDimensionsDirtyFalse(): void {\n this.lastElementWidth = Math.round(this.width);\n this.lastElementHeight = Math.round(this.height);\n }\n\n private readonly onTextureDimensionsChanged = (): void => {\n this.textureDimensionsDirty = true;\n };\n}\n","import type { UIProperty } from \"../generic-plane/shared\";\n\n/** Base class for progress bar fill functions */\nexport abstract class UIProgressMaskFunction {\n protected dirtyInternal = false;\n\n protected constructor(\n /** GLSL shader source code defining fill behavior */\n public readonly source: string,\n ) {}\n\n /** @internal */\n public get dirty(): boolean {\n return this.dirtyInternal;\n }\n\n /** @internal */\n public setDirtyFalse(): void {\n this.dirtyInternal = false;\n }\n\n /** @internal */\n public abstract enumerateProperties(): Record<string, UIProperty>;\n}\n","import type { Vector2Like } from \"three\";\nimport { Vector2 } from \"three\";\nimport source from \"../../shaders/UIProgressMaskFunctionDirectional.glsl\";\nimport { EPSILON } from \"../asserts\";\nimport type { UIProperty } from \"../generic-plane/shared\";\nimport { UIProgressMaskFunction } from \"./UIProgressMaskFunction\";\n\n/** Linear directional progress fill */\nexport class UIProgressMaskFunctionDirectional extends UIProgressMaskFunction {\n /** Fill direction as normalized vector */\n public readonly direction = new Vector2();\n private readonly cachedDirection = new Vector2();\n\n /**\n * Creates directional mask function.\n *\n * @param direction - Fill direction vector. Automatically normalized.\n */\n constructor(direction: Vector2Like = { x: 1, y: 0 }) {\n super(source);\n this.direction.copy(direction).normalize();\n this.cachedDirection.copy(this.direction);\n }\n\n /** @internal */\n public override get dirty(): boolean {\n this.ensureDirectionNormalized();\n return this.dirtyInternal || !this.cachedDirection.equals(this.direction);\n }\n\n /** @internal */\n public override setDirtyFalse(): void {\n this.ensureDirectionNormalized();\n this.cachedDirection.copy(this.direction);\n super.setDirtyFalse();\n }\n\n /** @internal */\n public enumerateProperties(): Record<string, UIProperty> {\n this.ensureDirectionNormalized();\n return { direction: this.direction };\n }\n\n private ensureDirectionNormalized(): void {\n const squaredLength = this.direction.lengthSq();\n if (Math.abs(squaredLength) <= EPSILON) {\n this.direction.set(1, 0);\n } else if (Math.abs(squaredLength - 1) > EPSILON) {\n this.direction.divideScalar(squaredLength);\n }\n }\n}\n","import type { Camera, Scene } from \"three\";\nimport { UIColor } from \"../../miscellaneous/color/UIColor\";\nimport type { UIColorConfig } from \"../../miscellaneous/color/UIColor.Internal\";\nimport type { UIElementOptions } from \"../UIElement/UIElement.Internal\";\n\n/** Controls when scene re-renders */\nexport enum UISceneUpdateMode {\n /** Re-render every frame */\n EVERY_FRAME = 1,\n /** Re-render every other frame */\n EVERY_SECOND_FRAME = 2,\n /** Re-render when scene, camera, or updateMode changes */\n ON_PROPERTIES_CHANGE = 3,\n /** Re-render when dimensions or resolutionFactor changes */\n ON_DIMENSIONS_CHANGE = 4,\n /** Re-render only via requestUpdate() */\n MANUAL = 5,\n}\n\n/** Configuration options for UIScene */\nexport interface UISceneOptions extends UIElementOptions {\n /** Multiplicative tint */\n color: UIColorConfig;\n /** Three.js scene to render */\n scene: Scene;\n /** Camera used for rendering */\n camera: Camera;\n /** When to re-render */\n updateMode: UISceneUpdateMode;\n /** Render target resolution multiplier. Range 0.1 to 2.0. */\n resolutionFactor: number;\n /** Background color */\n clearColor: UIColorConfig;\n /** Whether to use depth buffer */\n enableDepthBuffer: boolean;\n}\n\nexport const SCENE_DEFAULT_RESOLUTION_FACTOR = 0.5;\nexport const SCENE_MIN_RESOLUTION_FACTOR = 0.1;\nexport const SCENE_MAX_RESOLUTION_FACTOR = 2;\nexport const SCENE_DEFAULT_CAMERA_FOV = 60;\nexport const SCENE_DEFAULT_CAMERA_NEAR = 0.1;\nexport const SCENE_DEFAULT_CAMERA_FAR = 100;\nexport const SCENE_DEFAULT_UPDATE_MODE = UISceneUpdateMode.ON_PROPERTIES_CHANGE;\nexport const SCENE_DEFAULT_CLEAR_COLOR = new UIColor(0, 0, 0, 1);\nexport const SCENE_DEFAULT_USE_DEPTH = true;\n","import type { Matrix3, Texture, Vector2 } from \"three\";\nimport { MathUtils } from \"three\";\nimport type { UILayer } from \"../../layers/UILayer/UILayer\";\nimport { assertValidNumber } from \"../../miscellaneous/asserts\";\nimport { UIColor } from \"../../miscellaneous/color/UIColor\";\nimport type { UIColorConfig } from \"../../miscellaneous/color/UIColor.Internal\";\nimport { computeTrimmedTransformMatrix } from \"../../miscellaneous/computeTransform\";\nimport type { UIProperty } from \"../../miscellaneous/generic-plane/shared\";\nimport type { UIProgressMaskFunction } from \"../../miscellaneous/mask-function/UIProgressMaskFunction\";\nimport { UIProgressMaskFunctionDirectional } from \"../../miscellaneous/mask-function/UIProgressMaskFunctionDirectional\";\nimport { UITextureView } from \"../../miscellaneous/texture/UITextureView\";\nimport { UITextureViewEvent } from \"../../miscellaneous/texture/UITextureView.Internal\";\nimport { isUIModeVisible } from \"../../miscellaneous/UIMode\";\nimport source from \"../../shaders/UIProgress.glsl\";\nimport { UIElement } from \"../UIElement/UIElement\";\nimport type { UIProgressOptions } from \"./UIProgress.Internal\";\nimport { PROGRESS_DEFAULT_VALUE } from \"./UIProgress.Internal\";\n\n/** Progress bar with customizable fill direction */\nexport class UIProgress extends UIElement {\n /** Texture displayed by this element */\n public readonly texture: UITextureView;\n\n private readonly colorInternal: UIColor;\n private readonly textureTransform: Matrix3;\n private readonly textureResolution: Vector2;\n\n private maskFunctionInternal: UIProgressMaskFunction;\n private progressInternal: number;\n private progressDirty = false;\n private textureResolutionDirty = false;\n\n /**\n * Creates a new UIProgress instance.\n *\n * Defaults size to texture dimensions if width and height not provided.\n *\n * @param layer - Layer containing this element\n * @param texture - Texture to display\n * @param options - Configuration options\n */\n constructor(\n layer: UILayer,\n texture: Texture,\n options: Partial<UIProgressOptions> = {},\n ) {\n if (options.progress !== undefined) {\n assertValidNumber(\n options.progress,\n \"UIProgress.constructor.options.progress\",\n );\n }\n\n const color = new UIColor(options.color);\n const textureView = new UITextureView(texture);\n const textureTransform = textureView.calculateUVTransform();\n const textureResolution = textureView.getResolution();\n\n options.width = options.width ?? textureView.width;\n options.height = options.height ?? textureView.height;\n\n const progress = MathUtils.clamp(\n options.progress ?? PROGRESS_DEFAULT_VALUE,\n 0,\n 1,\n );\n\n const maskFunction =\n options.maskFunction ?? new UIProgressMaskFunctionDirectional();\n\n super(\n layer,\n maskFunction.source + source,\n {\n texture: textureView.texture,\n textureTransform,\n textureResolution,\n color,\n progress,\n ...maskFunction.enumerateProperties(),\n },\n options,\n );\n\n this.texture = textureView;\n this.textureTransform = textureTransform;\n this.textureResolution = textureResolution;\n this.colorInternal = color;\n this.progressInternal = progress;\n this.maskFunctionInternal = maskFunction;\n\n this.texture.on(\n UITextureViewEvent.DIMENSIONS_CHANGED,\n this.onTextureDimensionsChanged,\n );\n }\n\n /** Multiplicative tint. Alpha channel controls opacity. */\n public get color(): UIColor {\n return this.colorInternal;\n }\n\n /** Function controlling fill direction and shape */\n public get maskFunction(): UIProgressMaskFunction {\n return this.maskFunctionInternal;\n }\n\n /** Progress from 0 (empty) to 1 (full) */\n public get progress(): number {\n return this.progressInternal;\n }\n\n /** Multiplicative tint. Alpha channel controls opacity. */\n public set color(value: UIColorConfig) {\n this.colorInternal.set(value);\n }\n\n /** Function controlling fill direction and shape */\n public set maskFunction(value: UIProgressMaskFunction) {\n if (this.maskFunctionInternal !== value) {\n this.maskFunctionInternal = value;\n this.rebuildPlane();\n }\n }\n\n /** Progress from 0 (empty) to 1 (full). Clamped. */\n public set progress(value: number) {\n assertValidNumber(value, \"UIProgress.progress\");\n value = MathUtils.clamp(value, 0, 1);\n if (this.progressInternal !== value) {\n this.progressInternal = value;\n this.progressDirty = true;\n }\n }\n\n protected override setPlaneTransform(): void {\n let properties: Record<string, UIProperty> | undefined;\n\n if (this.colorInternal.dirty) {\n properties ??= {};\n properties[\"color\"] = this.colorInternal;\n this.colorInternal.setDirtyFalse();\n }\n\n if (this.texture.textureDirty) {\n properties ??= {};\n properties[\"texture\"] = this.texture.texture;\n this.texture.setTextureDirtyFalse();\n }\n\n if (this.texture.uvTransformDirty) {\n properties ??= {};\n properties[\"textureTransform\"] = this.texture.calculateUVTransform(\n this.textureTransform,\n );\n this.texture.setUVTransformDirtyFalse();\n }\n\n if (this.progressDirty) {\n properties ??= {};\n properties[\"progress\"] = this.progressInternal;\n this.progressDirty = false;\n }\n\n if (this.textureResolutionDirty) {\n properties ??= {};\n properties[\"textureResolution\"] = this.texture.getResolution(\n this.textureResolution,\n );\n this.textureResolutionDirty = false;\n }\n\n if (this.maskFunction.dirty) {\n properties ??= {};\n const maskProperties = this.maskFunction.enumerateProperties();\n for (const key in maskProperties) {\n properties[key] = maskProperties[key];\n }\n this.maskFunction.setDirtyFalse();\n }\n\n if (properties) {\n this.sceneWrapper.setProperties(this.planeHandler, properties);\n }\n\n const isTransformDirty =\n this.micro.dirty ||\n this.texture.trimDirty ||\n this.inputWrapper.dirty ||\n this.solverWrapper.dirty;\n\n if (isTransformDirty) {\n const micro = this.micro;\n const textureTrim = this.texture.trim;\n\n this.sceneWrapper.setTransform(\n this.planeHandler,\n computeTrimmedTransformMatrix(\n this.x,\n this.y,\n this.width,\n this.height,\n this.zIndex,\n micro.x,\n micro.y,\n micro.anchorX,\n micro.anchorY,\n micro.scaleX,\n micro.scaleY,\n micro.rotation,\n micro.anchorMode,\n textureTrim.left,\n textureTrim.right,\n textureTrim.top,\n textureTrim.bottom,\n ),\n );\n this.micro.setDirtyFalse();\n this.texture.setTrimDirtyFalse();\n }\n }\n\n private readonly onTextureDimensionsChanged = (\n width: number,\n height: number,\n ): void => {\n if (this.width !== width || this.height !== height) {\n this.width = width;\n this.height = height;\n this.textureResolutionDirty = true;\n }\n };\n\n private rebuildPlane(): void {\n this.sceneWrapper.destroyPlane(this.planeHandler);\n\n const micro = this.micro;\n const textureTrim = this.texture.trim;\n\n this.planeHandler = this.sceneWrapper.createPlane(\n this.maskFunctionInternal.source + source,\n {\n texture: this.texture.texture,\n textureTransform: this.texture.calculateUVTransform(\n this.textureTransform,\n ),\n textureResolution: this.texture.getResolution(this.textureResolution),\n color: this.colorInternal,\n progress: this.progressInternal,\n ...this.maskFunctionInternal.enumerateProperties(),\n },\n computeTrimmedTransformMatrix(\n this.x,\n this.y,\n this.width,\n this.height,\n this.zIndex,\n micro.x,\n micro.y,\n micro.anchorX,\n micro.anchorY,\n micro.scaleX,\n micro.scaleY,\n micro.rotation,\n micro.anchorMode,\n textureTrim.left,\n textureTrim.right,\n textureTrim.top,\n textureTrim.bottom,\n ),\n isUIModeVisible(this.mode),\n this.transparencyMode,\n );\n\n this.colorInternal.setDirtyFalse();\n this.texture.setTextureDirtyFalse();\n this.texture.setUVTransformDirtyFalse();\n this.texture.setTrimDirtyFalse();\n this.progressDirty = false;\n this.textureResolutionDirty = false;\n this.maskFunctionInternal.setDirtyFalse();\n this.micro.setDirtyFalse();\n }\n}\n","import type { UIColorConfig } from \"../../miscellaneous/color/UIColor.Internal\";\nimport type { UIProgressMaskFunction } from \"../../miscellaneous/mask-function/UIProgressMaskFunction\";\nimport type { UIElementOptions } from \"../UIElement/UIElement.Internal\";\n\n/** Configuration options for UIProgress */\nexport interface UIProgressOptions extends UIElementOptions {\n /** Multiplicative tint */\n color: UIColorConfig;\n /** Function controlling fill direction and shape */\n maskFunction: UIProgressMaskFunction;\n /** Progress from 0 (empty) to 1 (full) */\n progress: number;\n}\n\nexport const PROGRESS_DEFAULT_VALUE = 1;\n\nexport function simplifyGLSLSource(source: string): string {\n return source\n .replace(/\\/\\*[\\s\\S]*?\\*\\//g, \"\")\n .replace(/\\/\\/[^\\n]*/g, \"\")\n .replace(/\\s*([{}(),=;+\\-*/<>])\\s*/g, \"$1\")\n .replace(/\\s+/g, \" \")\n .trim();\n}\n","import type { Camera, WebGLRenderer } from \"three\";\nimport {\n LinearFilter,\n MathUtils,\n Matrix3,\n PerspectiveCamera,\n RGBAFormat,\n Scene,\n UnsignedByteType,\n WebGLRenderTarget,\n} from \"three\";\nimport type { UILayer } from \"../../layers/UILayer/UILayer\";\nimport { assertValidPositiveNumber } from \"../../miscellaneous/asserts\";\nimport { UIColor } from \"../../miscellaneous/color/UIColor\";\nimport type { UIColorConfig } from \"../../miscellaneous/color/UIColor.Internal\";\nimport source from \"../../shaders/UIImage.glsl\";\nimport { UIElement } from \"../UIElement/UIElement\";\nimport {\n DUMMY_DEFAULT_HEIGHT,\n DUMMY_DEFAULT_WIDTH,\n} from \"../UIInputDummy/UIInputDummy.Internal\";\nimport type { UISceneOptions } from \"./UIScene.Internal\";\nimport {\n SCENE_DEFAULT_CAMERA_FAR,\n SCENE_DEFAULT_CAMERA_FOV,\n SCENE_DEFAULT_CAMERA_NEAR,\n SCENE_DEFAULT_CLEAR_COLOR,\n SCENE_DEFAULT_RESOLUTION_FACTOR,\n SCENE_DEFAULT_UPDATE_MODE,\n SCENE_DEFAULT_USE_DEPTH,\n SCENE_MAX_RESOLUTION_FACTOR,\n SCENE_MIN_RESOLUTION_FACTOR,\n UISceneUpdateMode,\n} from \"./UIScene.Internal\";\n\n/** Renders Three.js scene to texture */\nexport class UIScene extends UIElement {\n private readonly colorInternal: UIColor;\n private readonly clearColorInternal: UIColor;\n private readonly renderTarget: WebGLRenderTarget;\n private sceneInternal: Scene;\n private cameraInternal: Camera;\n private updateModeInternal: UISceneUpdateMode;\n private resolutionFactorInternal: number;\n private evenFrame = true;\n\n private updateRequired = false;\n private resolutionFactorDirty = false;\n private propertyDirty = false;\n\n /**\n * Creates a new UIScene instance.\n *\n * @param layer - Layer containing this element\n * @param options - Configuration options\n * @throws If resolutionFactor outside range 0.1 to 2.0\n */\n constructor(layer: UILayer, options: Partial<UISceneOptions> = {}) {\n if (options.resolutionFactor !== undefined) {\n assertValidPositiveNumber(\n options.resolutionFactor,\n \"UIScene.constructor.resolutionFactor\",\n );\n }\n\n const resolutionFactor = MathUtils.clamp(\n options.resolutionFactor ?? SCENE_DEFAULT_RESOLUTION_FACTOR,\n SCENE_MIN_RESOLUTION_FACTOR,\n SCENE_MAX_RESOLUTION_FACTOR,\n );\n\n const w = options.width ?? DUMMY_DEFAULT_WIDTH;\n const h = options.height ?? DUMMY_DEFAULT_HEIGHT;\n\n const renderTarget = new WebGLRenderTarget(\n w * resolutionFactor,\n h * resolutionFactor,\n {\n format: RGBAFormat,\n minFilter: LinearFilter,\n magFilter: LinearFilter,\n type: UnsignedByteType,\n depthBuffer: options.enableDepthBuffer ?? SCENE_DEFAULT_USE_DEPTH,\n stencilBuffer: false,\n },\n );\n\n const color = new UIColor(options.color);\n\n super(\n layer,\n source,\n {\n texture: renderTarget.texture,\n textureTransform: new Matrix3(),\n color,\n },\n options,\n );\n\n this.colorInternal = color;\n this.clearColorInternal = new UIColor(\n options.clearColor ?? SCENE_DEFAULT_CLEAR_COLOR,\n );\n\n this.renderTarget = renderTarget;\n this.sceneInternal = options.scene ?? new Scene();\n\n this.cameraInternal =\n options.camera ??\n new PerspectiveCamera(\n SCENE_DEFAULT_CAMERA_FOV,\n w / h,\n SCENE_DEFAULT_CAMERA_NEAR,\n SCENE_DEFAULT_CAMERA_FAR,\n );\n\n this.resolutionFactorInternal = resolutionFactor;\n this.updateModeInternal = options.updateMode ?? SCENE_DEFAULT_UPDATE_MODE;\n this.propertyDirty = options.updateMode !== UISceneUpdateMode.MANUAL;\n }\n\n /** Camera used for rendering */\n public get camera(): Camera {\n return this.cameraInternal;\n }\n\n /** Background color for render target */\n public get clearColor(): UIColor {\n return this.clearColorInternal;\n }\n\n /** Multiplicative tint. Alpha channel controls opacity. */\n public get color(): UIColor {\n return this.colorInternal;\n }\n\n /** Render target resolution multiplier. Range 0.1 to 2.0. */\n public get resolutionFactor(): number {\n return this.resolutionFactorInternal;\n }\n\n /** Three.js scene to render */\n public get scene(): Scene {\n return this.sceneInternal;\n }\n\n /** Controls when scene re-renders */\n public get updateMode(): UISceneUpdateMode {\n return this.updateModeInternal;\n }\n\n /** Camera used for rendering */\n public set camera(value: Camera) {\n if (this.cameraInternal !== value) {\n this.cameraInternal = value;\n this.propertyDirty = true;\n }\n }\n\n /** Background color for render target */\n public set clearColor(value: UIColorConfig) {\n this.clearColorInternal.set(value);\n }\n\n /** Multiplicative tint. Alpha channel controls opacity. */\n public set color(value: UIColorConfig) {\n this.colorInternal.set(value);\n }\n\n /** Render target resolution multiplier. Range 0.1 to 2.0. */\n public set resolutionFactor(value: number) {\n assertValidPositiveNumber(value, \"UIScene.resolutionFactor\");\n value = MathUtils.clamp(\n value,\n SCENE_MIN_RESOLUTION_FACTOR,\n SCENE_MAX_RESOLUTION_FACTOR,\n );\n if (this.resolutionFactorInternal !== value) {\n this.resolutionFactorInternal = value;\n this.resolutionFactorDirty = true;\n }\n }\n\n /** Three.js scene to render */\n public set scene(value: Scene) {\n if (this.sceneInternal !== value) {\n this.sceneInternal = value;\n this.propertyDirty = true;\n }\n }\n\n /** Controls when scene re-renders */\n public set updateMode(value: UISceneUpdateMode) {\n if (this.updateModeInternal !== value) {\n this.updateModeInternal = value;\n this.propertyDirty = true;\n }\n }\n\n /** Removes element and frees resources */\n public override destroy(): void {\n this.renderTarget.dispose();\n super.destroy();\n }\n\n /** Triggers re-render on next frame. Useful in MANUAL mode. */\n public requestUpdate(): void {\n this.updateRequired = true;\n }\n\n protected override onWillRender(\n renderer: WebGLRenderer,\n deltaTime: number,\n ): void {\n this.evenFrame = !this.evenFrame;\n\n const isFramebufferDirty =\n this.updateRequired ||\n this.updateModeInternal === UISceneUpdateMode.EVERY_FRAME ||\n (this.updateModeInternal === UISceneUpdateMode.EVERY_SECOND_FRAME &&\n this.evenFrame) ||\n (this.updateModeInternal === UISceneUpdateMode.ON_PROPERTIES_CHANGE &&\n this.propertyDirty) ||\n this.colorInternal.dirty ||\n this.clearColorInternal.dirty ||\n (this.updateModeInternal === UISceneUpdateMode.ON_DIMENSIONS_CHANGE &&\n (this.resolutionFactorDirty || this.solverWrapper.dirty));\n\n if (isFramebufferDirty) {\n if (this.resolutionFactorDirty || this.solverWrapper.dirty) {\n this.renderTarget.setSize(\n this.width * this.resolutionFactorInternal,\n this.height * this.resolutionFactorInternal,\n );\n this.resolutionFactorDirty = false;\n }\n\n if (this.colorInternal.dirty) {\n this.sceneWrapper.setProperties(this.planeHandler, {\n color: this.colorInternal,\n });\n this.colorInternal.setDirtyFalse();\n }\n\n renderer.setClearColor(\n this.clearColorInternal.getHexRGB(),\n this.clearColorInternal.a,\n );\n renderer.setRenderTarget(this.renderTarget);\n renderer.clear(true, true, false);\n renderer.render(this.sceneInternal, this.cameraInternal);\n\n this.propertyDirty = false;\n this.updateRequired = false;\n }\n super.onWillRender(renderer, deltaTime);\n }\n}\n","/** Complete text style configuration with all properties resolved */\nexport interface UITextStyleConfig {\n /** Text color */\n color: string;\n /** Text alignment */\n align: \"left\" | \"center\" | \"right\";\n\n /** Font family name */\n fontFamily: string;\n /** Font size in pixels */\n fontSize: number;\n /** Font style */\n fontStyle: \"normal\" | \"italic\" | \"oblique\";\n /** Font weight */\n fontWeight: \"normal\" | \"bold\" | \"bolder\" | \"lighter\" | number;\n /** Line height in pixels */\n lineHeight: number;\n\n /** Whether shadow is enabled */\n enableShadow: boolean;\n /** Shadow horizontal offset in pixels */\n shadowOffsetX: number;\n /** Shadow vertical offset in pixels */\n shadowOffsetY: number;\n /** Shadow blur radius in pixels */\n shadowBlur: number;\n /** Shadow color */\n shadowColor: string;\n\n /** Whether stroke is enabled */\n enableStroke: boolean;\n /** Stroke color */\n strokeColor: string;\n /** Stroke thickness in pixels */\n strokeThickness: number;\n}\n\nexport const TEXT_STYLE_DEFAULT_COLOR = \"#000000\";\nexport const TEXT_STYLE_DEFAULT_ALIGN = \"left\" as const;\nexport const TEXT_STYLE_DEFAULT_FONT_FAMILY = \"Arial\";\nexport const TEXT_STYLE_DEFAULT_FONT_SIZE = 16;\nexport const TEXT_STYLE_DEFAULT_FONT_STYLE = \"normal\" as const;\nexport const TEXT_STYLE_DEFAULT_FONT_WEIGHT = \"normal\" as const;\nexport const TEXT_STYLE_DEFAULT_LINE_HEIGHT = 1.2;\nexport const TEXT_STYLE_DEFAULT_ENABLE_SHADOW = false;\nexport const TEXT_STYLE_DEFAULT_SHADOW_OFFSET_X = 0;\nexport const TEXT_STYLE_DEFAULT_SHADOW_OFFSET_Y = 0;\nexport const TEXT_STYLE_DEFAULT_SHADOW_BLUR = 0;\nexport const TEXT_STYLE_DEFAULT_SHADOW_COLOR = \"transparent\";\nexport const TEXT_STYLE_DEFAULT_ENABLE_STROKE = false;\nexport const TEXT_STYLE_DEFAULT_STROKE_COLOR = \"#000000\";\nexport const TEXT_STYLE_DEFAULT_STROKE_THICKNESS = 0;\n","import {\n assertValidNonNegativeNumber,\n assertValidNumber,\n assertValidPositiveNumber,\n} from \"../asserts\";\nimport type { UITextStyleConfig } from \"./UITextStyle.Internal\";\nimport {\n TEXT_STYLE_DEFAULT_ALIGN,\n TEXT_STYLE_DEFAULT_COLOR,\n TEXT_STYLE_DEFAULT_ENABLE_SHADOW,\n TEXT_STYLE_DEFAULT_ENABLE_STROKE,\n TEXT_STYLE_DEFAULT_FONT_FAMILY,\n TEXT_STYLE_DEFAULT_FONT_SIZE,\n TEXT_STYLE_DEFAULT_FONT_STYLE,\n TEXT_STYLE_DEFAULT_FONT_WEIGHT,\n TEXT_STYLE_DEFAULT_LINE_HEIGHT,\n TEXT_STYLE_DEFAULT_SHADOW_BLUR,\n TEXT_STYLE_DEFAULT_SHADOW_COLOR,\n TEXT_STYLE_DEFAULT_SHADOW_OFFSET_X,\n TEXT_STYLE_DEFAULT_SHADOW_OFFSET_Y,\n TEXT_STYLE_DEFAULT_STROKE_COLOR,\n TEXT_STYLE_DEFAULT_STROKE_THICKNESS,\n} from \"./UITextStyle.Internal\";\n\n/** Text style configuration for UI text rendering */\nexport class UITextStyle {\n private colorInternal?: string;\n private alignInternal?: \"left\" | \"center\" | \"right\";\n private fontFamilyInternal?: string;\n private fontSizeInternal?: number;\n private fontStyleInternal?: \"normal\" | \"italic\" | \"oblique\";\n private fontWeightInternal?:\n | \"normal\"\n | \"bold\"\n | \"bolder\"\n | \"lighter\"\n | number;\n private lineHeightInternal?: number;\n private enableShadowInternal?: boolean;\n private shadowOffsetXInternal?: number;\n private shadowOffsetYInternal?: number;\n private shadowBlurInternal?: number;\n private shadowColorInternal?: string;\n private enableStrokeInternal?: boolean;\n private strokeColorInternal?: string;\n private strokeThicknessInternal?: number;\n\n private dirtyInternal = true;\n\n /** @param config Partial style configuration. Unspecified properties remain undefined. */\n constructor(config?: Partial<UITextStyleConfig>) {\n this.colorInternal = config?.color;\n this.alignInternal = config?.align;\n this.fontFamilyInternal = config?.fontFamily;\n this.fontSizeInternal = config?.fontSize;\n this.fontStyleInternal = config?.fontStyle;\n this.fontWeightInternal = config?.fontWeight;\n this.lineHeightInternal = config?.lineHeight;\n this.enableShadowInternal = config?.enableShadow;\n this.shadowOffsetXInternal = config?.shadowOffsetX;\n this.shadowOffsetYInternal = config?.shadowOffsetY;\n this.shadowBlurInternal = config?.shadowBlur;\n this.shadowColorInternal = config?.shadowColor;\n this.enableStrokeInternal = config?.enableStroke;\n this.strokeColorInternal = config?.strokeColor;\n this.strokeThicknessInternal = config?.strokeThickness;\n }\n\n /** Text color */\n public get color(): string | undefined {\n return this.colorInternal;\n }\n\n /** Text alignment */\n public get align(): \"left\" | \"center\" | \"right\" | undefined {\n return this.alignInternal;\n }\n\n /** Font family name */\n public get fontFamily(): string | undefined {\n return this.fontFamilyInternal;\n }\n\n /** Font size in pixels */\n public get fontSize(): number | undefined {\n return this.fontSizeInternal;\n }\n\n /** Font style */\n public get fontStyle(): \"normal\" | \"italic\" | \"oblique\" | undefined {\n return this.fontStyleInternal;\n }\n\n /** Font weight */\n public get fontWeight():\n | \"normal\"\n | \"bold\"\n | \"bolder\"\n | \"lighter\"\n | number\n | undefined {\n return this.fontWeightInternal;\n }\n\n /** Line height in pixels */\n public get lineHeight(): number | undefined {\n return this.lineHeightInternal;\n }\n\n /** Whether shadow is enabled */\n public get enableShadow(): boolean | undefined {\n return this.enableShadowInternal;\n }\n\n /** Shadow horizontal offset in pixels */\n public get shadowOffsetX(): number | undefined {\n return this.shadowOffsetXInternal;\n }\n\n /** Shadow vertical offset in pixels */\n public get shadowOffsetY(): number | undefined {\n return this.shadowOffsetYInternal;\n }\n\n /** Shadow blur radius in pixels */\n public get shadowBlur(): number | undefined {\n return this.shadowBlurInternal;\n }\n\n /** Shadow color */\n public get shadowColor(): string | undefined {\n return this.shadowColorInternal;\n }\n\n /** Whether stroke is enabled */\n public get enableStroke(): boolean | undefined {\n return this.enableStrokeInternal;\n }\n\n /** Stroke color */\n public get strokeColor(): string | undefined {\n return this.strokeColorInternal;\n }\n\n /** Stroke thickness in pixels */\n public get strokeThickness(): number | undefined {\n return this.strokeThicknessInternal;\n }\n\n /**\n * Indicates whether any property has been modified.\n * Must be reset to `false` externally by the owner.\n * @internal\n */\n public get dirty(): boolean {\n return this.dirtyInternal;\n }\n\n public set color(value: string | undefined) {\n if (value !== this.colorInternal) {\n this.colorInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n public set align(value: \"left\" | \"center\" | \"right\" | undefined) {\n if (value !== this.alignInternal) {\n this.alignInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n public set fontFamily(value: string | undefined) {\n if (value !== this.fontFamilyInternal) {\n this.fontFamilyInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n public set fontSize(value: number | undefined) {\n if (value !== undefined) {\n assertValidPositiveNumber(value, \"UITextStyle.fontSize\");\n }\n if (value !== this.fontSizeInternal) {\n this.fontSizeInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n public set fontStyle(value: \"normal\" | \"italic\" | \"oblique\" | undefined) {\n if (value !== this.fontStyleInternal) {\n this.fontStyleInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n public set fontWeight(\n value: \"normal\" | \"bold\" | \"bolder\" | \"lighter\" | number | undefined,\n ) {\n if (typeof value === \"number\") {\n assertValidPositiveNumber(value, \"UITextStyle.fontWeight\");\n }\n if (value !== this.fontWeightInternal) {\n this.fontWeightInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n public set lineHeight(value: number | undefined) {\n if (value !== undefined) {\n assertValidNumber(value, \"UITextStyle.lineHeight\");\n }\n if (value !== this.lineHeightInternal) {\n this.lineHeightInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n public set enableShadow(value: boolean | undefined) {\n if (value !== this.enableShadowInternal) {\n this.enableShadowInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n public set shadowOffsetX(value: number | undefined) {\n if (value !== undefined) {\n assertValidNonNegativeNumber(value, \"UITextStyle.shadowOffsetX\");\n }\n if (value !== this.shadowOffsetXInternal) {\n this.shadowOffsetXInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n public set shadowOffsetY(value: number | undefined) {\n if (value !== undefined) {\n assertValidNonNegativeNumber(value, \"UITextStyle.shadowOffsetY\");\n }\n if (value !== this.shadowOffsetYInternal) {\n this.shadowOffsetYInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n public set shadowBlur(value: number | undefined) {\n if (value !== undefined) {\n assertValidNonNegativeNumber(value, \"UITextStyle.shadowBlur\");\n }\n if (value !== this.shadowBlurInternal) {\n this.shadowBlurInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n public set shadowColor(value: string | undefined) {\n if (value !== this.shadowColorInternal) {\n this.shadowColorInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n public set enableStroke(value: boolean | undefined) {\n if (value !== this.enableStrokeInternal) {\n this.enableStrokeInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n public set strokeColor(value: string | undefined) {\n if (value !== this.strokeColorInternal) {\n this.strokeColorInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n public set strokeThickness(value: number | undefined) {\n if (value !== undefined) {\n assertValidNonNegativeNumber(value, \"UITextStyle.strokeThickness\");\n }\n if (value !== this.strokeThicknessInternal) {\n this.strokeThicknessInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n /**\n * Resolves complete style from primary and fallback sources.\n * @param primary First style to check for each property\n * @param fallback Second style to check if primary is undefined\n * @returns Complete style configuration with all defaults applied\n */\n public static resolve(\n primary?: UITextStyle,\n fallback?: UITextStyle,\n ): UITextStyleConfig {\n const fontSize =\n primary?.fontSizeInternal ??\n fallback?.fontSizeInternal ??\n TEXT_STYLE_DEFAULT_FONT_SIZE;\n\n return {\n color:\n primary?.colorInternal ??\n fallback?.colorInternal ??\n TEXT_STYLE_DEFAULT_COLOR,\n align:\n primary?.alignInternal ??\n fallback?.alignInternal ??\n TEXT_STYLE_DEFAULT_ALIGN,\n fontFamily:\n primary?.fontFamilyInternal ??\n fallback?.fontFamilyInternal ??\n TEXT_STYLE_DEFAULT_FONT_FAMILY,\n fontSize,\n fontStyle:\n primary?.fontStyleInternal ??\n fallback?.fontStyleInternal ??\n TEXT_STYLE_DEFAULT_FONT_STYLE,\n fontWeight:\n primary?.fontWeightInternal ??\n fallback?.fontWeightInternal ??\n TEXT_STYLE_DEFAULT_FONT_WEIGHT,\n lineHeight:\n primary?.lineHeightInternal ??\n fallback?.lineHeightInternal ??\n fontSize * TEXT_STYLE_DEFAULT_LINE_HEIGHT,\n enableShadow:\n primary?.enableShadowInternal ??\n fallback?.enableShadowInternal ??\n TEXT_STYLE_DEFAULT_ENABLE_SHADOW,\n shadowOffsetX:\n primary?.shadowOffsetXInternal ??\n fallback?.shadowOffsetXInternal ??\n TEXT_STYLE_DEFAULT_SHADOW_OFFSET_X,\n shadowOffsetY:\n primary?.shadowOffsetYInternal ??\n fallback?.shadowOffsetYInternal ??\n TEXT_STYLE_DEFAULT_SHADOW_OFFSET_Y,\n shadowBlur:\n primary?.shadowBlurInternal ??\n fallback?.shadowBlurInternal ??\n TEXT_STYLE_DEFAULT_SHADOW_BLUR,\n shadowColor:\n primary?.shadowColorInternal ??\n fallback?.shadowColorInternal ??\n TEXT_STYLE_DEFAULT_SHADOW_COLOR,\n enableStroke:\n primary?.enableStrokeInternal ??\n fallback?.enableStrokeInternal ??\n TEXT_STYLE_DEFAULT_ENABLE_STROKE,\n strokeColor:\n primary?.strokeColorInternal ??\n fallback?.strokeColorInternal ??\n TEXT_STYLE_DEFAULT_STROKE_COLOR,\n strokeThickness:\n primary?.strokeThicknessInternal ??\n fallback?.strokeThicknessInternal ??\n TEXT_STYLE_DEFAULT_STROKE_THICKNESS,\n };\n }\n\n /** @internal */\n public setDirtyFalse(): void {\n this.dirtyInternal = false;\n }\n\n /** Sets all properties to default values */\n public setDefaults(): void {\n if (\n this.colorInternal !== TEXT_STYLE_DEFAULT_COLOR ||\n this.alignInternal !== TEXT_STYLE_DEFAULT_ALIGN ||\n this.fontFamilyInternal !== TEXT_STYLE_DEFAULT_FONT_FAMILY ||\n this.fontSizeInternal !== TEXT_STYLE_DEFAULT_FONT_SIZE ||\n this.fontStyleInternal !== TEXT_STYLE_DEFAULT_FONT_STYLE ||\n this.fontWeightInternal !== TEXT_STYLE_DEFAULT_FONT_WEIGHT ||\n this.lineHeightInternal !==\n TEXT_STYLE_DEFAULT_FONT_SIZE * TEXT_STYLE_DEFAULT_LINE_HEIGHT ||\n this.enableShadowInternal !== TEXT_STYLE_DEFAULT_ENABLE_SHADOW ||\n this.shadowOffsetXInternal !== TEXT_STYLE_DEFAULT_SHADOW_OFFSET_X ||\n this.shadowOffsetYInternal !== TEXT_STYLE_DEFAULT_SHADOW_OFFSET_Y ||\n this.shadowBlurInternal !== TEXT_STYLE_DEFAULT_SHADOW_BLUR ||\n this.shadowColorInternal !== TEXT_STYLE_DEFAULT_SHADOW_COLOR ||\n this.enableStrokeInternal !== TEXT_STYLE_DEFAULT_ENABLE_STROKE ||\n this.strokeColorInternal !== TEXT_STYLE_DEFAULT_STROKE_COLOR ||\n this.strokeThicknessInternal !== TEXT_STYLE_DEFAULT_STROKE_THICKNESS\n ) {\n this.colorInternal = TEXT_STYLE_DEFAULT_COLOR;\n this.alignInternal = TEXT_STYLE_DEFAULT_ALIGN;\n this.fontFamilyInternal = TEXT_STYLE_DEFAULT_FONT_FAMILY;\n this.fontSizeInternal = TEXT_STYLE_DEFAULT_FONT_SIZE;\n this.fontStyleInternal = TEXT_STYLE_DEFAULT_FONT_STYLE;\n this.fontWeightInternal = TEXT_STYLE_DEFAULT_FONT_WEIGHT;\n this.lineHeightInternal =\n TEXT_STYLE_DEFAULT_FONT_SIZE * TEXT_STYLE_DEFAULT_LINE_HEIGHT;\n this.enableShadowInternal = TEXT_STYLE_DEFAULT_ENABLE_SHADOW;\n this.shadowOffsetXInternal = TEXT_STYLE_DEFAULT_SHADOW_OFFSET_X;\n this.shadowOffsetYInternal = TEXT_STYLE_DEFAULT_SHADOW_OFFSET_Y;\n this.shadowBlurInternal = TEXT_STYLE_DEFAULT_SHADOW_BLUR;\n this.shadowColorInternal = TEXT_STYLE_DEFAULT_SHADOW_COLOR;\n this.enableStrokeInternal = TEXT_STYLE_DEFAULT_ENABLE_STROKE;\n this.strokeColorInternal = TEXT_STYLE_DEFAULT_STROKE_COLOR;\n this.strokeThicknessInternal = TEXT_STYLE_DEFAULT_STROKE_THICKNESS;\n this.dirtyInternal = true;\n }\n }\n\n /** Sets all properties to undefined */\n public clear(): void {\n if (\n this.colorInternal !== undefined ||\n this.alignInternal !== undefined ||\n this.fontFamilyInternal !== undefined ||\n this.fontSizeInternal !== undefined ||\n this.fontStyleInternal !== undefined ||\n this.fontWeightInternal !== undefined ||\n this.lineHeightInternal !== undefined ||\n this.enableShadowInternal !== undefined ||\n this.shadowOffsetXInternal !== undefined ||\n this.shadowOffsetYInternal !== undefined ||\n this.shadowBlurInternal !== undefined ||\n this.shadowColorInternal !== undefined ||\n this.enableStrokeInternal !== undefined ||\n this.strokeColorInternal !== undefined ||\n this.strokeThicknessInternal !== undefined\n ) {\n this.colorInternal = undefined;\n this.alignInternal = undefined;\n this.fontFamilyInternal = undefined;\n this.fontSizeInternal = undefined;\n this.fontStyleInternal = undefined;\n this.fontWeightInternal = undefined;\n this.lineHeightInternal = undefined;\n this.enableShadowInternal = undefined;\n this.shadowOffsetXInternal = undefined;\n this.shadowOffsetYInternal = undefined;\n this.shadowBlurInternal = undefined;\n this.shadowColorInternal = undefined;\n this.enableStrokeInternal = undefined;\n this.strokeColorInternal = undefined;\n this.strokeThicknessInternal = undefined;\n this.dirtyInternal = true;\n }\n }\n\n /** Copies from another style instance */\n public copy(value: UITextStyle): void {\n if (\n this.colorInternal !== value.colorInternal ||\n this.alignInternal !== value.alignInternal ||\n this.fontFamilyInternal !== value.fontFamilyInternal ||\n this.fontSizeInternal !== value.fontSizeInternal ||\n this.fontStyleInternal !== value.fontStyleInternal ||\n this.fontWeightInternal !== value.fontWeightInternal ||\n this.lineHeightInternal !== value.lineHeightInternal ||\n this.enableShadowInternal !== value.enableShadowInternal ||\n this.shadowOffsetXInternal !== value.shadowOffsetXInternal ||\n this.shadowOffsetYInternal !== value.shadowOffsetYInternal ||\n this.shadowBlurInternal !== value.shadowBlurInternal ||\n this.shadowColorInternal !== value.shadowColorInternal ||\n this.enableStrokeInternal !== value.enableStrokeInternal ||\n this.strokeColorInternal !== value.strokeColorInternal ||\n this.strokeThicknessInternal !== value.strokeThicknessInternal\n ) {\n this.colorInternal = value.colorInternal;\n this.alignInternal = value.alignInternal;\n this.fontFamilyInternal = value.fontFamilyInternal;\n this.fontSizeInternal = value.fontSizeInternal;\n this.fontStyleInternal = value.fontStyleInternal;\n this.fontWeightInternal = value.fontWeightInternal;\n this.lineHeightInternal = value.lineHeightInternal;\n this.enableShadowInternal = value.enableShadowInternal;\n this.shadowOffsetXInternal = value.shadowOffsetXInternal;\n this.shadowOffsetYInternal = value.shadowOffsetYInternal;\n this.shadowBlurInternal = value.shadowBlurInternal;\n this.shadowColorInternal = value.shadowColorInternal;\n this.enableStrokeInternal = value.enableStrokeInternal;\n this.strokeColorInternal = value.strokeColorInternal;\n this.strokeThicknessInternal = value.strokeThicknessInternal;\n this.dirtyInternal = true;\n }\n }\n\n /**\n * Calculates maximum padding required for stroke and shadow.\n * @returns Padding in pixels needed on all sides\n */\n public calculatePadding(): number {\n let padding = 0;\n\n if (this.enableStrokeInternal !== undefined) {\n padding += this.strokeThicknessInternal ?? 0;\n }\n\n if (this.enableShadowInternal !== undefined) {\n const blur = this.shadowBlurInternal ?? 0;\n const offsetX = this.shadowOffsetXInternal ?? 0;\n const offsetY = this.shadowOffsetYInternal ?? 0;\n const shadowSpread = blur * 2;\n const shadowMaxX = Math.abs(offsetX) + shadowSpread;\n const shadowMaxY = Math.abs(offsetY) + shadowSpread;\n padding += Math.max(shadowMaxX, shadowMaxY);\n }\n\n return Math.ceil(padding);\n }\n}\n","import { UITextStyle } from \"../text-style/UITextStyle\";\nimport type { UITextSpanConfig } from \"./UITextSpan.Internal\";\n\n/** Text span with associated style */\nexport class UITextSpan {\n /** Text style */\n public style: UITextStyle;\n private textInternal: string;\n private dirtyInternal = true;\n\n /** @param config Text span configuration */\n constructor(config: UITextSpanConfig) {\n this.textInternal = config.text;\n this.style = new UITextStyle(config.style);\n }\n\n /** Text content */\n public get text(): string {\n return this.textInternal;\n }\n\n /**\n * Indicates whether text or style has been modified.\n * Must be reset to `false` externally by the owner.\n * @internal\n */\n public get dirty(): boolean {\n return this.dirtyInternal || this.style.dirty;\n }\n\n public set text(value: string) {\n if (value !== this.textInternal) {\n this.textInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n /** @internal */\n public setDirtyFalse(): void {\n this.dirtyInternal = false;\n this.style.setDirtyFalse();\n }\n}\n","import type { UIColorConfig } from \"../../miscellaneous/color/UIColor.Internal\";\nimport type { UIInsetsConfig } from \"../../miscellaneous/insets/UIInsets.Internal\";\nimport type { UITextStyleConfig } from \"../../miscellaneous/text-style/UITextStyle.Internal\";\nimport type { UIElementOptions } from \"../UIElement/UIElement.Internal\";\n\n/** Controls how text adapts to element size */\nexport enum UITextResizeMode {\n /** Break text into multiple lines when narrower than content*/\n BREAK = 0,\n /** Scale text to fit fixed element size */\n SCALE = 1,\n}\n\n/** Configuration options for UIText */\nexport interface UITextOptions extends UIElementOptions {\n /** Multiplicative tint */\n color: UIColorConfig;\n /** Text padding in world units */\n padding: UIInsetsConfig;\n /** Default style applied to all spans */\n commonStyle: Partial<UITextStyleConfig>;\n /** How text adapts to size constraints */\n resizeMode: UITextResizeMode;\n /** Maximum line width before wrapping in pixels */\n maxLineWidth: number;\n}\n\nexport const TEXT_DEFAULT_MAX_LINE_WIDTH = 1024;\nexport const TEXT_DEFAULT_RESIZE_MODE = UITextResizeMode.SCALE;\n","import type { UITextSpan } from \"../../miscellaneous/text-span/UITextSpan\";\nimport { UITextStyle } from \"../../miscellaneous/text-style/UITextStyle\";\nimport type { UITextStyleConfig } from \"../../miscellaneous/text-style/UITextStyle.Internal\";\nimport type {\n UIChunkMetrics,\n UITextChunk,\n UITextLine,\n UITextSize,\n} from \"./UIText.Interfaces\";\n\n/**\n * Splits text into renderable chunks.\n * @param text Text to split\n * @returns Array of words, spaces, and newlines\n */\nexport function splitTextIntoChunks(text: string): string[] {\n return text.match(/\\S+|\\s|\\n/g) ?? [];\n}\n\n/**\n * Measures single text chunk.\n * @param context Canvas context for measurement\n * @param text Chunk text\n * @param textStyle Resolved text style\n * @returns Chunk metrics\n */\nexport function measureTextChunk(\n context: OffscreenCanvasRenderingContext2D,\n text: string,\n textStyle: UITextStyleConfig,\n): UIChunkMetrics {\n context.font = `${textStyle.fontStyle} ${textStyle.fontWeight} ${textStyle.fontSize}px \"${textStyle.fontFamily}\"`;\n\n if (text === \"\\n\") {\n return {\n width: Math.ceil(1),\n height: textStyle.lineHeight,\n baseline: 0,\n lineHeight: textStyle.lineHeight,\n };\n }\n\n const metrics = context.measureText(text);\n const width = Math.ceil(metrics.width);\n const height = Math.ceil(\n metrics.actualBoundingBoxAscent + metrics.actualBoundingBoxDescent,\n );\n\n return {\n width,\n height,\n baseline: metrics.actualBoundingBoxDescent,\n lineHeight: textStyle.lineHeight,\n };\n}\n\n/**\n * Builds text lines with word wrapping.\n * @param maxWidth Maximum line width in pixels\n * @param textChunks Measured text chunks\n * @returns Array of text lines\n */\nexport function buildTextLines(\n maxWidth: number,\n textChunks: UITextChunk[],\n): UITextLine[] {\n const lines: UITextLine[] = [];\n let currentLine: UITextChunk[] = [];\n let currentWidth = 0;\n let currentHeight = 0;\n let currentBaseline = 0;\n let currentLineHeight = 0;\n\n for (const textChunk of textChunks) {\n if (textChunk.text === \"\\n\") {\n if (currentLine.length > 0) {\n lines.push({\n chunks: currentLine,\n width: currentWidth,\n height: currentHeight,\n baseline: currentBaseline,\n lineHeight: currentLineHeight,\n });\n }\n currentLine = [];\n currentWidth = 0;\n currentHeight = 0;\n currentBaseline = 0;\n currentLineHeight = 0;\n continue;\n }\n\n if (\n currentLine.length === 0 ||\n currentWidth + textChunk.metrics.width <= maxWidth\n ) {\n currentLine.push(textChunk);\n currentWidth += textChunk.metrics.width;\n currentHeight = Math.max(currentHeight, textChunk.metrics.height);\n currentBaseline = Math.max(currentBaseline, textChunk.metrics.baseline);\n currentLineHeight = Math.max(\n currentLineHeight,\n textChunk.metrics.lineHeight,\n );\n } else {\n lines.push({\n chunks: currentLine,\n width: currentWidth,\n height: currentHeight,\n baseline: currentBaseline,\n lineHeight: currentLineHeight,\n });\n currentLine = [textChunk];\n currentWidth = textChunk.metrics.width;\n currentHeight = textChunk.metrics.height;\n currentBaseline = textChunk.metrics.baseline;\n currentLineHeight = textChunk.metrics.lineHeight;\n }\n }\n\n if (currentLine.length > 0) {\n lines.push({\n chunks: currentLine,\n width: currentWidth,\n height: currentHeight,\n baseline: currentBaseline,\n lineHeight: currentLineHeight,\n });\n }\n\n return lines;\n}\n\n/**\n * Calculates total text size from lines.\n * @param lines Text lines\n * @returns Total width and height\n */\nexport function calculateTextSize(lines: UITextLine[]): UITextSize {\n if (lines.length === 0) {\n return { width: 0, height: 0 };\n }\n\n const maxLineWidth = Math.max(...lines.map((line) => line.width));\n let totalHeight = 0;\n\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i];\n totalHeight += i === 0 ? line.height : line.lineHeight;\n }\n\n return { width: maxLineWidth, height: totalHeight };\n}\n\n/**\n * Builds measured text chunks from spans.\n * @param context Canvas context for measurement\n * @param textSpans Text spans with styles\n * @param commonStyle Fallback style\n * @returns Measured text chunks\n */\nexport function buildTextChunks(\n context: OffscreenCanvasRenderingContext2D,\n textSpans: UITextSpan[],\n commonStyle: UITextStyle,\n): UITextChunk[] {\n const textChunks: UITextChunk[] = [];\n\n for (const textSpan of textSpans) {\n const textStyle = UITextStyle.resolve(textSpan.style, commonStyle);\n\n for (const textChunk of splitTextIntoChunks(textSpan.text)) {\n const textChunkMetrics = measureTextChunk(context, textChunk, textStyle);\n textChunks.push({\n text: textChunk,\n style: textStyle,\n metrics: textChunkMetrics,\n });\n }\n }\n\n return textChunks;\n}\n\n/**\n * Calculates text layout parameters.\n * @param textChunks Measured text chunks\n * @param maxLineWidth Maximum line width in pixels\n * @returns Lines and total size\n */\nexport function calculateTextContentParameters(\n textChunks: UITextChunk[],\n maxLineWidth: number,\n): { lines: UITextLine[]; size: UITextSize } {\n const lines = buildTextLines(maxLineWidth, textChunks);\n const size = calculateTextSize(lines);\n return { lines, size };\n}\n","import type { UITextStyleConfig } from \"../../miscellaneous/text-style/UITextStyle.Internal\";\nimport { TEXT_STYLE_DEFAULT_ALIGN } from \"../../miscellaneous/text-style/UITextStyle.Internal\";\nimport type { UITextLine } from \"./UIText.Interfaces\";\n\n/**\n * Renders single text chunk.\n * @param x X coordinate in pixels\n * @param y Y coordinate in pixels\n * @param text Chunk text\n * @param style Resolved text style\n * @param context Canvas rendering context\n */\nexport function renderTextChunk(\n x: number,\n y: number,\n text: string,\n style: UITextStyleConfig,\n context: OffscreenCanvasRenderingContext2D,\n): void {\n context.font = `${style.fontStyle} ${style.fontWeight} ${style.fontSize}px \"${style.fontFamily}\"`;\n\n if (style.enableShadow) {\n context.shadowOffsetX = style.shadowOffsetX;\n context.shadowOffsetY = style.shadowOffsetY;\n context.shadowBlur = style.shadowBlur;\n context.shadowColor = style.shadowColor;\n }\n\n if (style.enableStroke) {\n context.strokeStyle = style.strokeColor;\n context.lineWidth = style.strokeThickness;\n context.strokeText(text, x, y);\n }\n\n context.fillStyle = style.color;\n context.fillText(text, x, y);\n}\n\n/**\n * Renders text lines to canvas.\n * @param paddingTop Top padding in pixels\n * @param paddingLeft Left padding in pixels\n * @param lines Text lines to render\n * @param context Canvas rendering context\n */\nexport function renderTextLines(\n paddingTop: number,\n paddingLeft: number,\n lines: UITextLine[],\n context: OffscreenCanvasRenderingContext2D,\n): void {\n let currentY = paddingTop;\n\n let textWidth = 0;\n for (const line of lines) {\n textWidth = Math.max(line.width, textWidth);\n }\n\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i];\n\n const firstAlign = line.chunks[0]?.style.align ?? TEXT_STYLE_DEFAULT_ALIGN;\n const isUniformAlign = line.chunks.every(\n (c) => c.style.align === firstAlign,\n );\n const lineAlign = isUniformAlign ? firstAlign : TEXT_STYLE_DEFAULT_ALIGN;\n\n let offsetX = 0;\n\n if (lineAlign === \"center\") {\n offsetX = (textWidth - line.width) / 2;\n } else if (lineAlign === \"right\") {\n offsetX = textWidth - line.width;\n }\n\n let currentX = paddingLeft + offsetX;\n currentY += i === 0 ? line.height : line.lineHeight;\n\n for (const chunk of line.chunks) {\n renderTextChunk(currentX, currentY, chunk.text, chunk.style, context);\n currentX += chunk.metrics.width;\n }\n }\n}\n","import type { WebGLRenderer } from \"three\";\nimport { CanvasTexture, Matrix3, SRGBColorSpace } from \"three\";\nimport type { UILayer } from \"../../layers/UILayer/UILayer\";\nimport { UIColor } from \"../../miscellaneous/color/UIColor\";\nimport type { UIColorConfig } from \"../../miscellaneous/color/UIColor.Internal\";\nimport type { UIProperty } from \"../../miscellaneous/generic-plane/shared\";\nimport { UIInsets } from \"../../miscellaneous/insets/UIInsets\";\nimport type { UIInsetsConfig } from \"../../miscellaneous/insets/UIInsets.Internal\";\nimport { UITextSpan } from \"../../miscellaneous/text-span/UITextSpan\";\nimport { UITextStyle } from \"../../miscellaneous/text-style/UITextStyle\";\nimport source from \"../../shaders/UIImage.glsl\";\nimport { UIElement } from \"../UIElement/UIElement\";\nimport type { UITextChunk, UITextContent } from \"./UIText.Interfaces\";\nimport type { UITextOptions } from \"./UIText.Internal\";\nimport {\n TEXT_DEFAULT_MAX_LINE_WIDTH,\n TEXT_DEFAULT_RESIZE_MODE,\n UITextResizeMode,\n} from \"./UIText.Internal\";\nimport {\n buildTextChunks,\n calculateTextContentParameters,\n} from \"./UIText.Measuring\";\nimport { renderTextLines } from \"./UIText.Rendering\";\n\n/** Canvas-based text rendering element */\nexport class UIText extends UIElement {\n /** Default style applied to all text spans */\n public readonly commonStyle: UITextStyle;\n\n private readonly colorInternal: UIColor;\n private readonly paddingInternal: UIInsets;\n private readonly canvas: OffscreenCanvas;\n private readonly context: OffscreenCanvasRenderingContext2D;\n private texture: CanvasTexture;\n\n private contentInternal: UITextSpan[] = [];\n private contentDirty = false;\n\n private maxLineWidthInternal: number;\n private maxLineWidthDirty = false;\n\n private resizeModeInternal: UITextResizeMode;\n private resizeModeDirty = false;\n\n private lastWidth: number;\n private lastHeight: number;\n\n private textChunks: UITextChunk[] = [];\n private textChunksDirty = false;\n\n /**\n * Creates a new UIText instance.\n *\n * @param layer - Layer containing this element\n * @param content - Text content as string or styled spans\n * @param options - Configuration options\n */\n constructor(\n layer: UILayer,\n content: UITextContent,\n options: Partial<UITextOptions> = {},\n ) {\n const canvas = new OffscreenCanvas(2, 2);\n const context = canvas.getContext(\"2d\");\n\n if (!context) {\n throw new Error(\"UIText.constructor: failed to create canvas context\");\n }\n\n const texture = new CanvasTexture(canvas);\n texture.colorSpace = SRGBColorSpace;\n texture.needsUpdate = true;\n const color = new UIColor(options.color);\n\n super(layer, source, {\n texture: texture,\n textureTransform: new Matrix3(),\n color,\n });\n\n this.colorInternal = color;\n this.paddingInternal = new UIInsets(options.padding);\n this.commonStyle = new UITextStyle(options.commonStyle);\n this.maxLineWidthInternal =\n options.maxLineWidth ?? TEXT_DEFAULT_MAX_LINE_WIDTH;\n this.resizeModeInternal = options.resizeMode ?? TEXT_DEFAULT_RESIZE_MODE;\n\n this.canvas = canvas;\n this.context = context;\n this.texture = texture;\n this.content = content;\n\n this.lastWidth = this.width;\n this.lastHeight = this.height;\n\n if (options.padding === undefined) {\n this.paddingInternal.setUnified(\n this.content.reduce(\n (a, b) => Math.max(a, b.style.calculatePadding()),\n this.commonStyle.calculatePadding(),\n ),\n );\n }\n\n switch (this.resizeModeInternal) {\n case UITextResizeMode.SCALE:\n this.tryToRenderTextScaleMode();\n break;\n\n case UITextResizeMode.BREAK:\n this.tryToRenderTextBreakMode();\n break;\n }\n }\n\n /** Multiplicative tint. Alpha channel controls opacity. */\n public get color(): UIColor {\n return this.colorInternal;\n }\n\n /** Text content as array of styled spans */\n public get content(): UITextSpan[] {\n return this.contentInternal;\n }\n\n /** Maximum line width before wrapping in pixels */\n public get maxLineWidth(): number {\n return this.maxLineWidthInternal;\n }\n\n /** Text padding in world units */\n public get padding(): UIInsets {\n return this.paddingInternal;\n }\n\n /** Controls how text adapts to element size */\n public get resizeMode(): UITextResizeMode {\n return this.resizeModeInternal;\n }\n\n /** Multiplicative tint. Alpha channel controls opacity. */\n public set color(value: UIColorConfig) {\n this.colorInternal.set(value);\n }\n\n /** Text content as string, span config, or array */\n public set content(value: UITextContent) {\n if (this.contentInternal !== value) {\n if (typeof value === \"string\") {\n this.contentInternal = [\n new UITextSpan({ text: value, style: new UITextStyle() }),\n ];\n } else if (Array.isArray(value)) {\n this.contentInternal = value.map((span) =>\n typeof span === \"string\"\n ? new UITextSpan({ text: span, style: new UITextStyle() })\n : new UITextSpan({\n text: span.text,\n style: new UITextStyle(span.style),\n }),\n );\n } else {\n this.contentInternal = [\n new UITextSpan({\n text: value.text,\n style: new UITextStyle(value.style),\n }),\n ];\n }\n this.contentDirty = true;\n this.textChunksDirty = true;\n }\n }\n\n /** Maximum line width before wrapping in pixels */\n public set maxLineWidth(value: number) {\n if (this.maxLineWidthInternal !== value) {\n this.maxLineWidthInternal = value;\n this.maxLineWidthDirty = true;\n }\n }\n\n /** Text padding in world units */\n public set padding(value: UIInsetsConfig) {\n this.paddingInternal.set(value);\n }\n\n /** Controls how text adapts to size constraints */\n public set resizeMode(value: UITextResizeMode) {\n if (this.resizeModeInternal !== value) {\n this.resizeModeInternal = value;\n this.resizeModeDirty = true;\n }\n }\n\n /** Removes element and frees resources */\n public override destroy(): void {\n this.texture.dispose();\n super.destroy();\n }\n\n protected override onWillRender(\n renderer: WebGLRenderer,\n deltaTime: number,\n ): void {\n switch (this.resizeModeInternal) {\n case UITextResizeMode.SCALE:\n this.tryToRenderTextScaleMode();\n break;\n\n case UITextResizeMode.BREAK:\n this.tryToRenderTextBreakMode();\n break;\n }\n\n super.onWillRender(renderer, deltaTime);\n }\n\n private tryToRenderTextScaleMode(): void {\n if (\n !this.colorInternal.dirty &&\n !this.resizeModeDirty &&\n !this.maxLineWidthDirty &&\n !this.paddingInternal.dirty &&\n !(\n this.solverWrapper.dirty &&\n this.lastWidth / this.lastHeight !==\n Math.round(this.width) / Math.round(this.height)\n ) &&\n !this.checkContentDirty()\n ) {\n return;\n }\n\n const textChunks = this.buildTextChunks();\n\n const { lines, size } = calculateTextContentParameters(\n textChunks,\n this.maxLineWidthInternal,\n );\n\n const paddingV = this.paddingInternal.top + this.paddingInternal.bottom;\n const paddingH = this.paddingInternal.left + this.paddingInternal.right;\n\n const desiredHeight = size.height + paddingV;\n const desiredWidth = size.width + paddingH;\n\n // Two calculation passes are required to cover both cases -\n // when the width is specified by a constraint and cannot be changed,\n // or when the height is specified by a constraint and cannot be changed,\n // but the width still has priority, because it is specified first and last.\n this.width = desiredWidth;\n this.height = (desiredHeight / desiredWidth) * Math.round(this.width);\n this.width = (desiredWidth / desiredHeight) * Math.round(this.height);\n\n const resolutionDirty =\n this.lastWidth !== desiredHeight || this.lastHeight !== desiredWidth;\n\n if (resolutionDirty) {\n this.canvas.height = desiredHeight;\n this.canvas.width = desiredWidth;\n }\n\n renderTextLines(\n this.paddingInternal.top,\n this.paddingInternal.left,\n lines,\n this.context,\n );\n\n this.updateProperties(resolutionDirty);\n\n this.resizeModeDirty = false;\n this.maxLineWidthDirty = false;\n this.paddingInternal.setDirtyFalse();\n this.setDimensionsDirtyFalse();\n this.setContentDirtyFalse();\n }\n\n private tryToRenderTextBreakMode(): void {\n if (\n !this.colorInternal.dirty &&\n !this.resizeModeDirty &&\n !this.maxLineWidthDirty &&\n !this.paddingInternal.dirty &&\n !this.checkDimensionsDirty() &&\n !this.checkContentDirty()\n ) {\n return;\n }\n\n const textChunks = this.buildTextChunks();\n\n // Two passes of text size calculation are needed to first\n // suggest the desired sizes to the solver, and then\n // adjust our expectations based on the result obtained.\n\n const { size: desiredTextSize } = calculateTextContentParameters(\n textChunks,\n this.maxLineWidthInternal,\n );\n\n const paddingV = this.paddingInternal.top + this.paddingInternal.bottom;\n const paddingH = this.paddingInternal.left + this.paddingInternal.right;\n\n this.height = desiredTextSize.height + paddingV;\n this.width = desiredTextSize.width + paddingH; // Width should remain a priority, so it is set last.\n\n const { lines: realTextLines, size: realTextSize } =\n calculateTextContentParameters(\n textChunks,\n Math.round(this.width) - paddingH,\n );\n\n this.height = realTextSize.height + paddingV;\n this.width = realTextSize.width + paddingH;\n\n const safeWidth = Math.max(Math.round(this.width), 2);\n const safeHeight = Math.max(Math.round(this.height), 2);\n\n const resolutionDirty =\n this.lastWidth !== safeWidth || this.lastHeight !== safeHeight;\n\n if (resolutionDirty) {\n this.canvas.width = safeWidth;\n this.canvas.height = safeHeight;\n }\n\n renderTextLines(\n this.paddingInternal.top,\n this.paddingInternal.left,\n realTextLines,\n this.context,\n );\n\n this.updateProperties(resolutionDirty);\n\n this.resizeModeDirty = false;\n this.maxLineWidthDirty = false;\n this.paddingInternal.setDirtyFalse();\n this.setDimensionsDirtyFalse();\n this.setContentDirtyFalse();\n }\n\n private updateProperties(resolutionDirty: boolean): void {\n let properties: Record<string, UIProperty> | undefined;\n\n if (this.colorInternal.dirty) {\n properties ??= {};\n properties[\"color\"] = this.colorInternal;\n this.colorInternal.setDirtyFalse();\n }\n\n if (resolutionDirty) {\n this.texture.dispose();\n this.texture = new CanvasTexture(this.canvas);\n this.texture.colorSpace = SRGBColorSpace;\n this.texture.needsUpdate = true;\n\n properties ??= {};\n properties[\"texture\"] = this.texture;\n }\n\n if (properties) {\n this.sceneWrapper.setProperties(this.planeHandler, properties);\n }\n }\n\n private buildTextChunks(): UITextChunk[] {\n if (this.textChunksDirty) {\n this.textChunks = buildTextChunks(\n this.context,\n this.contentInternal,\n this.commonStyle,\n );\n this.textChunksDirty = false;\n }\n\n return this.textChunks;\n }\n\n private checkDimensionsDirty(): boolean {\n return (\n this.solverWrapper.dirty &&\n (this.lastWidth !== Math.round(this.width) ||\n this.lastHeight !== Math.round(this.height))\n );\n }\n\n private setDimensionsDirtyFalse(): void {\n this.lastWidth = Math.round(this.width);\n this.lastHeight = Math.round(this.height);\n }\n\n private checkContentDirty(): boolean {\n return (\n this.contentDirty || this.content.some((span): boolean => span.dirty)\n );\n }\n\n private setContentDirtyFalse(): void {\n this.contentDirty = false;\n for (const span of this.content) {\n span.setDirtyFalse();\n }\n }\n}\n","/** Base class for viewport resize policies */\nexport abstract class UIResizePolicy {\n /** @internal */\n public dirty = false;\n\n /** @internal */\n public abstract calculateScale(width: number, height: number): number;\n}\n","import { assertValidPositiveNumber } from \"../asserts\";\nimport { UIResizePolicy } from \"./UIResizePolicy\";\n\n/** No scaling. Always returns 1. */\nexport class UIResizePolicyNone extends UIResizePolicy {\n public calculateScale(width: number, height: number): number {\n assertValidPositiveNumber(width, \"UIResizePolicyNone.calculateScale.width\");\n assertValidPositiveNumber(\n height,\n \"UIResizePolicyNone.calculateScale.height\",\n );\n return 1;\n }\n}\n","import type { UIResizePolicy } from \"../../miscellaneous/resize-policy/UIResizePolicy\";\nimport { UIResizePolicyNone } from \"../../miscellaneous/resize-policy/UIResizePolicyNone\";\nimport type { UILayerOptions } from \"../UILayer/UILayer.Internal\";\n\n/** Configuration for fullscreen layer */\nexport interface UIFullscreenLayerOptions\n extends Omit<UILayerOptions, \"width\" | \"height\"> {\n /** Strategy for handling window resize */\n resizePolicy: UIResizePolicy;\n}\n\nexport const FULLSCREEN_LAYER_DEFAULT_RESIZE_POLICY = new UIResizePolicyNone();\n","import type { Camera, Vector2, WebGLRenderer } from \"three\";\nimport { MathUtils, Ray, Vector3 } from \"three\";\nimport { assertValidNumber } from \"../../miscellaneous/asserts\";\nimport type { UIResizePolicy } from \"../../miscellaneous/resize-policy/UIResizePolicy\";\nimport { UIInputEvent } from \"../../miscellaneous/UIInputEvent\";\nimport { isUIModeInteractive } from \"../../miscellaneous/UIMode\";\nimport { UILayer } from \"../UILayer/UILayer\";\nimport type { UIFullscreenLayerOptions } from \"./UIFullscreenLayer.Internal\";\nimport { FULLSCREEN_LAYER_DEFAULT_RESIZE_POLICY } from \"./UIFullscreenLayer.Internal\";\n\n/** Layer that automatically handles browser window resizing and input events */\nexport class UIFullscreenLayer extends UILayer {\n private resizePolicyInternal: UIResizePolicy;\n private resizePolicyDirty = false;\n\n constructor(options?: Partial<UIFullscreenLayerOptions>) {\n const resizePolicy =\n options?.resizePolicy ?? FULLSCREEN_LAYER_DEFAULT_RESIZE_POLICY;\n\n const scale = resizePolicy.calculateScale(\n window.innerWidth,\n window.innerHeight,\n );\n\n super({\n width: window.innerWidth * scale,\n height: window.innerHeight * scale,\n ...options,\n });\n\n this.resizePolicyInternal = resizePolicy;\n window.addEventListener(\"resize\", this.onResize);\n window.addEventListener(\"pointerdown\", this.onPointerDown);\n window.addEventListener(\"pointermove\", this.onPointerMove);\n window.addEventListener(\"pointerup\", this.onPointerUp);\n }\n\n /** Current resize policy */\n public get resizePolicy(): UIResizePolicy {\n return this.resizePolicyInternal;\n }\n\n /** Updates resize policy */\n public set resizePolicy(value: UIResizePolicy) {\n if (this.resizePolicyInternal !== value) {\n this.resizePolicyInternal = value;\n this.resizePolicyDirty = true;\n }\n }\n\n /** Removes event listeners and frees resources */\n public destroy(): void {\n window.removeEventListener(\"resize\", this.onResize);\n window.removeEventListener(\"pointerdown\", this.onPointerDown);\n window.removeEventListener(\"pointermove\", this.onPointerMove);\n window.removeEventListener(\"pointerup\", this.onPointerUp);\n }\n\n /**\n * Renders layer and all visible elements\n * @param renderer Three.js WebGL renderer\n * @param deltaTime Time since last frame in seconds\n */\n public render(renderer: WebGLRenderer, deltaTime: number): void {\n assertValidNumber(deltaTime, \"UIFullscreenLayer.render.deltaTime\");\n if (this.resizePolicy.dirty || this.resizePolicyDirty) {\n this.onResize();\n }\n super.renderInternal(renderer, deltaTime);\n }\n\n /**\n * Projects 3D world position to 2D layer coordinates\n * @param position World position\n * @param camera Three.js camera\n * @param result Reusable vector instance\n * @returns Layer coordinates\n */\n public projectWorldPosition(\n position: Vector3,\n camera: Camera,\n result = new Vector3(),\n ): Vector3 {\n result.copy(position).project(camera);\n result.x = MathUtils.mapLinear(result.x, -1, 1, this.x, this.width);\n result.y = MathUtils.mapLinear(result.y, -1, 1, this.y, this.height);\n return result;\n }\n\n /**\n * Projects 2D layer coordinates to 3D world position\n * @param position Layer coordinates\n * @param camera Three.js camera\n * @param z Depth coordinate\n * @param result Reusable vector instance\n * @returns World position\n */\n public projectLayerPosition(\n position: Vector2,\n camera: Camera,\n z = -1,\n result = new Vector3(),\n ): Vector3 {\n return result\n .set(\n MathUtils.mapLinear(position.x, this.x, this.width, -1, 1),\n MathUtils.mapLinear(position.y, this.y, this.height, -1, 1),\n z,\n )\n .unproject(camera);\n }\n\n /**\n * Builds ray from layer position through camera\n * @param position Layer coordinates\n * @param camera Three.js camera\n * @param result Reusable ray instance\n * @returns Ray from near to far plane\n */\n public buildRay(position: Vector2, camera: Camera, result = new Ray()): Ray {\n const near = new Vector3(\n MathUtils.mapLinear(position.x, this.x, this.width, -1, 1),\n MathUtils.mapLinear(position.y, this.y, this.height, -1, 1),\n -1,\n ).unproject(camera);\n\n const far = new Vector3(\n MathUtils.mapLinear(position.x, this.x, this.width, -1, 1),\n MathUtils.mapLinear(position.y, this.y, this.height, -1, 1),\n 1,\n ).unproject(camera);\n\n const direction = far.sub(near).normalize();\n return result.set(near, direction);\n }\n\n private readonly onResize = (): void => {\n const scale = this.resizePolicy.calculateScale(\n window.innerWidth,\n window.innerHeight,\n );\n this.resizePolicy.dirty = false;\n this.resizePolicyDirty = false;\n this.resizeInternal(window.innerWidth * scale, window.innerHeight * scale);\n };\n\n private readonly onPointerDown = (event: PointerEvent): void => {\n this.handleWindowInput(event, \"onPointerDown\", UIInputEvent.PRESSED);\n };\n\n private readonly onPointerMove = (event: PointerEvent): void => {\n this.handleWindowInput(event, \"onPointerMove\", UIInputEvent.MOVED);\n };\n\n private readonly onPointerUp = (event: PointerEvent): void => {\n this.handleWindowInput(event, \"onPointerUp\", UIInputEvent.RELEASED);\n };\n\n private handleWindowInput(\n event: PointerEvent,\n pointerFunctionName: \"onPointerDown\" | \"onPointerMove\" | \"onPointerUp\",\n inputEvent: UIInputEvent,\n ): void {\n const rect =\n event.target instanceof HTMLElement\n ? event.target.getBoundingClientRect()\n : null;\n\n const x = rect ? event.clientX - rect.left : event.clientX;\n const y = rect\n ? rect.bottom - event.clientY\n : window.innerHeight - event.clientY;\n\n const scale = this.resizePolicy.calculateScale(\n window.innerWidth,\n window.innerHeight,\n );\n const scaledX = x * scale;\n const scaledY = y * scale;\n\n if (isUIModeInteractive(this.mode)) {\n this.emit(inputEvent, scaledX, scaledY, event.pointerId);\n this.inputWrapperInternal[pointerFunctionName](\n scaledX,\n scaledY,\n event.pointerId,\n );\n }\n }\n}\n","import { assertValidNonNegativeNumber, assertValidNumber } from \"../asserts\";\nimport { UIArea } from \"./UIArea\";\n\n/** Circular interaction area */\nexport class UIAreaCircle extends UIArea {\n /**\n * Creates circular area.\n *\n * @param centerX - Center X in normalized coordinates (0 to 1)\n * @param centerY - Center Y in normalized coordinates (0 to 1)\n * @param radius - Radius in normalized coordinates (0 to 1)\n */\n constructor(\n public centerX: number,\n public centerY: number,\n public radius: number,\n ) {\n super();\n assertValidNonNegativeNumber(centerX, \"UIAreaCircle.constructor.centerX\");\n assertValidNonNegativeNumber(centerY, \"UIAreaCircle.constructor.centerY\");\n assertValidNonNegativeNumber(radius, \"UIAreaCircle.constructor.radius\");\n }\n\n /** @internal */\n public contains(pointX: number, pointY: number): boolean {\n assertValidNumber(pointX, \"UIAreaCircle.contains.pointX\");\n assertValidNumber(pointY, \"UIAreaCircle.contains.pointY\");\n const deltaX = pointX - this.centerX;\n const deltaY = pointY - this.centerY;\n return deltaX * deltaX + deltaY * deltaY <= this.radius * this.radius;\n }\n}\n","import type { Vector2Like } from \"three\";\nimport { assertValidNumber } from \"../asserts\";\nimport { UIArea } from \"./UIArea\";\n\n/** Polygonal interaction area using ray casting */\nexport class UIAreaPolygon extends UIArea {\n /**\n * Creates polygonal area.\n *\n * @param vertices - Vertices in normalized coordinates (0 to 1)\n */\n constructor(public vertices: Vector2Like[]) {\n super();\n }\n\n /** @internal */\n public contains(pointX: number, pointY: number): boolean {\n assertValidNumber(pointX, \"UIAreaPolygon.contains.pointX\");\n assertValidNumber(pointY, \"UIAreaPolygon.contains.pointY\");\n const vertexCount = this.vertices.length;\n if (vertexCount < 3) {\n return false;\n }\n\n let inside = false;\n\n for (\n let index = 0, previousIndex = vertexCount - 1;\n index < vertexCount;\n previousIndex = index++\n ) {\n const currentVertex = this.vertices[index];\n const previousVertex = this.vertices[previousIndex];\n\n const currentX = currentVertex.x;\n const currentY = currentVertex.y;\n const previousX = previousVertex.x;\n const previousY = previousVertex.y;\n\n if (\n currentY > pointY !== previousY > pointY &&\n pointX <\n ((previousX - currentX) * (pointY - currentY)) /\n (previousY - currentY) +\n currentX\n ) {\n inside = !inside;\n }\n }\n\n return inside;\n }\n}\n","import { assertValidNonNegativeNumber, assertValidNumber } from \"../asserts\";\nimport { UIArea } from \"./UIArea\";\n\n/** Rectangular interaction area with rounded corners */\nexport class UIAreaRoundedRectangle extends UIArea {\n /**\n * Creates rounded rectangular area.\n *\n * Radius clamped to half of smallest dimension.\n *\n * @param x - X position in normalized coordinates (0 to 1)\n * @param y - Y position in normalized coordinates (0 to 1)\n * @param width - Width in normalized coordinates (0 to 1)\n * @param height - Height in normalized coordinates (0 to 1)\n * @param radius - Corner radius in normalized coordinates (0 to 1)\n */\n constructor(\n public x: number,\n public y: number,\n public width: number,\n public height: number,\n public radius: number,\n ) {\n super();\n assertValidNonNegativeNumber(x, \"UIAreaRoundedRectangle.constructor.x\");\n assertValidNonNegativeNumber(y, \"UIAreaRoundedRectangle.constructor.y\");\n assertValidNonNegativeNumber(\n width,\n \"UIAreaRoundedRectangle.constructor.width\",\n );\n assertValidNonNegativeNumber(\n height,\n \"UIAreaRoundedRectangle.constructor.height\",\n );\n assertValidNonNegativeNumber(\n radius,\n \"UIAreaRoundedRectangle.constructor.radius\",\n );\n this.radius = Math.min(radius, Math.min(width, height) / 2);\n }\n\n /** @internal */\n public contains(pointX: number, pointY: number): boolean {\n assertValidNumber(pointX, \"UIAreaRoundedRectangle.contains.pointX\");\n assertValidNumber(pointY, \"UIAreaRoundedRectangle.contains.pointY\");\n const left = this.x;\n const right = this.x + this.width;\n const top = this.y;\n const bottom = this.y + this.height;\n\n if (pointX < left || pointX > right || pointY < top || pointY > bottom) {\n return false;\n }\n\n const cornerLeft = left + this.radius;\n const cornerRight = right - this.radius;\n const cornerTop = top + this.radius;\n const cornerBottom = bottom - this.radius;\n\n if (pointX >= cornerLeft && pointX <= cornerRight) {\n return true;\n }\n\n if (pointY >= cornerTop && pointY <= cornerBottom) {\n return true;\n }\n\n let centerX: number;\n let centerY: number;\n\n if (pointX < cornerLeft) {\n centerX = cornerLeft;\n } else {\n centerX = cornerRight;\n }\n\n if (pointY < cornerTop) {\n centerY = cornerTop;\n } else {\n centerY = cornerBottom;\n }\n\n const deltaX = pointX - centerX;\n const deltaY = pointY - centerY;\n return deltaX * deltaX + deltaY * deltaY <= this.radius * this.radius;\n }\n}\n","import source from \"../../shaders/UIProgressMaskFunctionCircular.glsl\";\nimport { assertValidNumber } from \"../asserts\";\nimport type { UIProperty } from \"../generic-plane/shared\";\nimport { UIProgressMaskFunction } from \"./UIProgressMaskFunction\";\n\n/** Circular radial progress fill */\nexport class UIProgressMaskFunctionCircular extends UIProgressMaskFunction {\n private startAngleInternal: number;\n private inverseDirectionInternal: boolean;\n\n /**\n * Creates circular mask function.\n *\n * @param startAngle - Starting angle in radians\n * @param inverseDirection - Whether to fill counter-clockwise\n */\n constructor(startAngle = 0, inverseDirection = false) {\n assertValidNumber(\n startAngle,\n \"UIProgressMaskFunctionCircular.constructor.startAngle\",\n );\n super(source);\n this.startAngleInternal = startAngle;\n this.inverseDirectionInternal = inverseDirection;\n }\n\n /** Starting angle in radians */\n public get startAngle(): number {\n return this.startAngleInternal;\n }\n\n /** Whether fill is counter-clockwise */\n public get inverseDirection(): boolean {\n return this.inverseDirectionInternal;\n }\n\n /** Starting angle in radians */\n public set startAngle(value: number) {\n assertValidNumber(value, \"UIProgressMaskFunctionCircular.startAngle\");\n if (this.startAngleInternal !== value) {\n this.startAngleInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n /** Whether fill is counter-clockwise */\n public set inverseDirection(value: boolean) {\n if (this.inverseDirectionInternal !== value) {\n this.inverseDirectionInternal = value;\n this.dirtyInternal = true;\n }\n }\n\n /** @internal */\n public enumerateProperties(): Record<string, UIProperty> {\n return {\n direction: this.inverseDirectionInternal ? -1 : 1,\n startAngle: this.startAngleInternal,\n };\n }\n}\n","import { assertValidPositiveNumber } from \"../asserts\";\nimport { UIResizePolicy } from \"./UIResizePolicy\";\n\n/** Scales area to cover rect preserving proportions */\nexport class UIResizePolicyCover extends UIResizePolicy {\n private rectWidthInternal: number;\n private rectHeightInternal: number;\n\n /**\n * Creates cover resize policy.\n *\n * @param rectWidth - Target rect width\n * @param rectHeight - Target rect height\n */\n constructor(rectWidth: number, rectHeight: number) {\n super();\n assertValidPositiveNumber(\n rectWidth,\n \"UIResizePolicyCover.constructor.rectWidth\",\n );\n assertValidPositiveNumber(\n rectHeight,\n \"UIResizePolicyCover.constructor.rectHeight\",\n );\n\n this.rectWidthInternal = rectWidth;\n this.rectHeightInternal = rectHeight;\n }\n\n /** Target rect width */\n public get rectWidth(): number {\n return this.rectWidthInternal;\n }\n\n /** Target rect height */\n public get rectHeight(): number {\n return this.rectHeightInternal;\n }\n\n /** Target rect width */\n public set rectWidth(value: number) {\n assertValidPositiveNumber(value, \"UIResizePolicyCover.rectWidth\");\n if (value !== this.rectWidthInternal) {\n this.rectWidthInternal = value;\n this.dirty = true;\n }\n }\n\n /** Target rect height */\n public set rectHeight(value: number) {\n assertValidPositiveNumber(value, \"UIResizePolicyCover.rectHeight\");\n if (value !== this.rectHeightInternal) {\n this.rectHeightInternal = value;\n this.dirty = true;\n }\n }\n\n public calculateScale(width: number, height: number): number {\n assertValidPositiveNumber(\n width,\n \"UIResizePolicyCover.calculateScale.width\",\n );\n assertValidPositiveNumber(\n height,\n \"UIResizePolicyCover.calculateScale.height\",\n );\n return Math.min(\n this.rectWidthInternal / width,\n this.rectHeightInternal / height,\n );\n }\n}\n","import { assertValidPositiveNumber } from \"../asserts\";\nimport { UIResizePolicy } from \"./UIResizePolicy\";\n\n/** Scales by width in landscape, by height in portrait */\nexport class UIResizePolicyCross extends UIResizePolicy {\n private fixedWidthLandscapeInternal: number;\n private fixedHeightPortraitInternal: number;\n\n /**\n * Creates cross resize policy.\n *\n * @param fixedWidthLandscape - Target width when landscape\n * @param fixedHeightPortrait - Target height when portrait\n */\n constructor(fixedWidthLandscape: number, fixedHeightPortrait: number) {\n super();\n assertValidPositiveNumber(\n fixedWidthLandscape,\n \"UIResizePolicyCross.constructor.fixedWidthLandscape\",\n );\n assertValidPositiveNumber(\n fixedHeightPortrait,\n \"UIResizePolicyCross.constructor.fixedHeightPortrait\",\n );\n\n this.fixedWidthLandscapeInternal = fixedWidthLandscape;\n this.fixedHeightPortraitInternal = fixedHeightPortrait;\n }\n\n /** Target width when landscape */\n public get fixedWidthLandscape(): number {\n return this.fixedWidthLandscapeInternal;\n }\n\n /** Target height when portrait */\n public get fixedHeightPortrait(): number {\n return this.fixedHeightPortraitInternal;\n }\n\n /** Target width when landscape */\n public set fixedWidthLandscape(value: number) {\n assertValidPositiveNumber(value, \"UIResizePolicyCross.fixedWidthLandscape\");\n if (value !== this.fixedWidthLandscapeInternal) {\n this.fixedWidthLandscapeInternal = value;\n this.dirty = true;\n }\n }\n\n /** Target height when portrait */\n public set fixedHeightPortrait(value: number) {\n assertValidPositiveNumber(value, \"UIResizePolicyCross.fixedHeightPortrait\");\n if (value !== this.fixedHeightPortraitInternal) {\n this.fixedHeightPortraitInternal = value;\n this.dirty = true;\n }\n }\n\n public calculateScale(width: number, height: number): number {\n assertValidPositiveNumber(\n width,\n \"UIResizePolicyCross.calculateScale.width\",\n );\n assertValidPositiveNumber(\n height,\n \"UIResizePolicyCross.calculateScale.height\",\n );\n return width > height\n ? this.fixedWidthLandscapeInternal / width\n : this.fixedHeightPortraitInternal / height;\n }\n}\n","import { assertValidPositiveNumber } from \"../asserts\";\nimport { UIResizePolicy } from \"./UIResizePolicy\";\n\n/** Scales by height in landscape, by width in portrait */\nexport class UIResizePolicyCrossInverted extends UIResizePolicy {\n private fixedHeightLandscapeInternal: number;\n private fixedWidthPortraitInternal: number;\n\n /**\n * Creates inverted cross resize policy.\n *\n * @param fixedHeightLandscape - Target height when landscape\n * @param fixedWidthPortrait - Target width when portrait\n */\n constructor(fixedHeightLandscape: number, fixedWidthPortrait: number) {\n super();\n assertValidPositiveNumber(\n fixedHeightLandscape,\n \"UIResizePolicyCrossInverted.constructor.fixedHeightLandscape\",\n );\n assertValidPositiveNumber(\n fixedWidthPortrait,\n \"UIResizePolicyCrossInverted.constructor.fixedWidthPortrait\",\n );\n\n this.fixedHeightLandscapeInternal = fixedHeightLandscape;\n this.fixedWidthPortraitInternal = fixedWidthPortrait;\n }\n\n /** Target height when landscape */\n public get fixedHeightLandscape(): number {\n return this.fixedHeightLandscapeInternal;\n }\n\n /** Target width when portrait */\n public get fixedWidthPortrait(): number {\n return this.fixedWidthPortraitInternal;\n }\n\n /** Target height when landscape */\n public set fixedHeightLandscape(value: number) {\n assertValidPositiveNumber(\n value,\n \"UIResizePolicyCrossInverted.fixedHeightLandscape\",\n );\n if (value !== this.fixedHeightLandscapeInternal) {\n this.fixedHeightLandscapeInternal = value;\n this.dirty = true;\n }\n }\n\n /** Target width when portrait */\n public set fixedWidthPortrait(value: number) {\n assertValidPositiveNumber(\n value,\n \"UIResizePolicyCrossInverted.fixedWidthPortrait\",\n );\n if (value !== this.fixedWidthPortraitInternal) {\n this.fixedWidthPortraitInternal = value;\n this.dirty = true;\n }\n }\n\n public calculateScale(width: number, height: number): number {\n assertValidPositiveNumber(\n width,\n \"UIResizePolicyCrossInverted.calculateScale.width\",\n );\n assertValidPositiveNumber(\n height,\n \"UIResizePolicyCrossInverted.calculateScale.height\",\n );\n return width > height\n ? this.fixedHeightLandscapeInternal / height\n : this.fixedWidthPortraitInternal / width;\n }\n}\n","import { assertValidPositiveNumber } from \"../asserts\";\nimport { UIResizePolicy } from \"./UIResizePolicy\";\n\n/** Scales area to fit around rect preserving proportions */\nexport class UIResizePolicyFit extends UIResizePolicy {\n private rectWidthInternal: number;\n private rectHeightInternal: number;\n\n /**\n * Creates fit resize policy.\n *\n * @param rectWidth - Target rect width\n * @param rectHeight - Target rect height\n */\n constructor(rectWidth: number, rectHeight: number) {\n super();\n assertValidPositiveNumber(\n rectWidth,\n \"UIResizePolicyFit.constructor.rectWidth\",\n );\n assertValidPositiveNumber(\n rectHeight,\n \"UIResizePolicyFit.constructor.rectHeight\",\n );\n\n this.rectWidthInternal = rectWidth;\n this.rectHeightInternal = rectHeight;\n }\n\n /** Target rect width */\n public get rectWidth(): number {\n return this.rectWidthInternal;\n }\n\n /** Target rect height */\n public get rectHeight(): number {\n return this.rectHeightInternal;\n }\n\n /** Target rect width */\n public set rectWidth(value: number) {\n assertValidPositiveNumber(value, \"UIResizePolicyFit.rectWidth\");\n if (value !== this.rectWidthInternal) {\n this.rectWidthInternal = value;\n this.dirty = true;\n }\n }\n\n /** Target rect height */\n public set rectHeight(value: number) {\n assertValidPositiveNumber(value, \"UIResizePolicyFit.rectHeight\");\n if (value !== this.rectHeightInternal) {\n this.rectHeightInternal = value;\n this.dirty = true;\n }\n }\n\n public calculateScale(width: number, height: number): number {\n assertValidPositiveNumber(width, \"UIResizePolicyFit.calculateScale.width\");\n assertValidPositiveNumber(\n height,\n \"UIResizePolicyFit.calculateScale.height\",\n );\n return Math.max(\n this.rectWidthInternal / width,\n this.rectHeightInternal / height,\n );\n }\n}\n","import { assertValidPositiveNumber } from \"../asserts\";\nimport { UIResizePolicy } from \"./UIResizePolicy\";\n\n/** Scales by height with orientation-specific targets */\nexport class UIResizePolicyFixedHeight extends UIResizePolicy {\n private fixedHeightLandscapeInternal: number;\n private fixedHeightPortraitInternal: number;\n\n /**\n * Creates fixed height resize policy.\n *\n * @param fixedHeightLandscape - Target height when landscape\n * @param fixedHeightPortrait - Target height when portrait\n */\n constructor(fixedHeightLandscape: number, fixedHeightPortrait: number) {\n super();\n assertValidPositiveNumber(\n fixedHeightLandscape,\n \"UIResizePolicyFixedHeight.constructor.fixedHeightLandscape\",\n );\n assertValidPositiveNumber(\n fixedHeightPortrait,\n \"UIResizePolicyFixedHeight.constructor.fixedHeightPortrait\",\n );\n\n this.fixedHeightLandscapeInternal = fixedHeightLandscape;\n this.fixedHeightPortraitInternal = fixedHeightPortrait;\n }\n\n /** Target height when landscape */\n public get fixedHeightLandscape(): number {\n return this.fixedHeightLandscapeInternal;\n }\n\n /** Target height when portrait */\n public get fixedHeightPortrait(): number {\n return this.fixedHeightPortraitInternal;\n }\n\n /** Target height when landscape */\n public set fixedHeightLandscape(value: number) {\n assertValidPositiveNumber(\n value,\n \"UIResizePolicyFixedHeight.fixedHeightLandscape\",\n );\n if (value !== this.fixedHeightLandscapeInternal) {\n this.fixedHeightLandscapeInternal = value;\n this.dirty = true;\n }\n }\n\n /** Target height when portrait */\n public set fixedHeightPortrait(value: number) {\n assertValidPositiveNumber(\n value,\n \"UIResizePolicyFixedHeight.fixedHeightPortrait\",\n );\n if (value !== this.fixedHeightPortraitInternal) {\n this.fixedHeightPortraitInternal = value;\n this.dirty = true;\n }\n }\n\n public calculateScale(width: number, height: number): number {\n assertValidPositiveNumber(\n width,\n \"UIResizePolicyFixedHeight.calculateScale.width\",\n );\n assertValidPositiveNumber(\n height,\n \"UIResizePolicyFixedHeight.calculateScale.height\",\n );\n return width > height\n ? this.fixedHeightLandscapeInternal / height\n : this.fixedHeightPortraitInternal / height;\n }\n}\n","import { assertValidPositiveNumber } from \"../asserts\";\nimport { UIResizePolicy } from \"./UIResizePolicy\";\n\n/** Scales by width with orientation-specific targets */\nexport class UIResizePolicyFixedWidth extends UIResizePolicy {\n private fixedWidthLandscapeInternal: number;\n private fixedWidthPortraitInternal: number;\n\n /**\n * Creates fixed width resize policy.\n *\n * @param fixedWidthLandscape - Target width when landscape\n * @param fixedWidthPortrait - Target width when portrait\n */\n constructor(fixedWidthLandscape: number, fixedWidthPortrait: number) {\n super();\n assertValidPositiveNumber(\n fixedWidthLandscape,\n \"UIResizePolicyFixedWidth.constructor.fixedWidthLandscape\",\n );\n assertValidPositiveNumber(\n fixedWidthPortrait,\n \"UIResizePolicyFixedWidth.constructor.fixedWidthPortrait\",\n );\n\n this.fixedWidthLandscapeInternal = fixedWidthLandscape;\n this.fixedWidthPortraitInternal = fixedWidthPortrait;\n }\n\n /** Target width when landscape */\n public get fixedWidthLandscape(): number {\n return this.fixedWidthLandscapeInternal;\n }\n\n /** Target width when portrait */\n public get fixedWidthPortrait(): number {\n return this.fixedWidthPortraitInternal;\n }\n\n /** Target width when landscape */\n public set fixedWidthLandscape(value: number) {\n assertValidPositiveNumber(\n value,\n \"UIResizePolicyFixedWidth.fixedWidthLandscape\",\n );\n if (value !== this.fixedWidthLandscapeInternal) {\n this.fixedWidthLandscapeInternal = value;\n this.dirty = true;\n }\n }\n\n /** Target width when portrait */\n public set fixedWidthPortrait(value: number) {\n assertValidPositiveNumber(\n value,\n \"UIResizePolicyFixedWidth.fixedWidthPortrait\",\n );\n if (value !== this.fixedWidthPortraitInternal) {\n this.fixedWidthPortraitInternal = value;\n this.dirty = true;\n }\n }\n\n public calculateScale(width: number, height: number): number {\n assertValidPositiveNumber(\n width,\n \"UIResizePolicyFixedWidth.calculateScale.width\",\n );\n assertValidPositiveNumber(\n height,\n \"UIResizePolicyFixedWidth.calculateScale.height\",\n );\n return width > height\n ? this.fixedWidthLandscapeInternal / width\n : this.fixedWidthPortraitInternal / width;\n }\n}\n"],"names":["t","constructor","i","r","this","WeakMap","Map","set","insert","has","s","get","remove","delete","size","getPriority","o","on","h","once","off","u","v","slice","length","l","_","p","e","shift","n","pop","M","splice","c","emit","apply","k","m","Error","push","unshift","UIMode","UIOrientation","isUIModeInteractive","mode","INTERACTIVE","INTERACTIVE_TRANSPARENT","isUIModeVisible","HIDDEN","createMap","IndexedMap","index","array","empty","itemAt","contains","key","undefined","id","find","setDefault","factory","pair","Pair","value","erase","last","first","copy","second","Variable","name","_name","_id","setName","context","_context","setContext","_value","setValue","plus","Expression","minus","multiply","coefficient","divide","toJSON","toString","VarId","parsed","args","constant","terms","item","terms2","j","termPair","Array","value2","parseArgs","arguments","_terms","_constant","result","isConstant","map","join","Strength","create","a","b","w","Math","max","min","static","clip","required","Operator","Constraint","expression","operator","rhs","strength","_operator","_strength","_expression","op","CnId","Solver","maxIterations","createConstraint","lhs","cn","addConstraint","constraint","_cnMap","data","_createRow","row","tag","subject","_chooseSubject","type","SymbolType","Invalid","allDummies","nearZero","marker","_addWithArtificialVariable","solveFor","_substitute","_rowMap","_optimize","_objective","removeConstraint","cnPair","_removeConstraintEffects","rowPair","leaving","_getMarkerLeavingSymbol","solveForEx","hasConstraint","getConstraints","addEditVariable","variable","_editMap","expr","Eq","removeEditVariable","editPair","hasEditVariable","suggestValue","rows","info","delta","add","_infeasibleRows","_dualOptimize","other","coeff","coefficientFor","External","updateVariables","vars","_varMap","_getVarSymbol","_makeSymbol","Row","symbol","basicPair","insertRow","insertSymbol","objective","INVALID_SYMBOL","Le","Ge","slack","Slack","error","errplus","errminus","dummy","Dummy","reverseSign","cells","art","_artificial","success","basicRow","entering","_anyPivotableSymbol","removeSymbol","substitute","iterations","_getEnteringSymbol","_getLeavingSymbol","infeasible","_getDualEnteringSymbol","ratio","Number","MAX_VALUE","found","temp","temp_ratio","dmax","r1","r2","invalid","third","_removeMarkerEffects","Symbol","_idTick","createCnMap","createRowMap","createVarMap","createEditMap","_type","_cellMap","theCopy","HIGH_PRIORITY","UIPriority","convertPriority","priority","P0","P1","P2","P3","P4","P5","P6","P7","UIInputWrapper","dirty","_private_zIndicesDirty","_private_catchers","_private_lastHandler","createInputCatcher","catchPointerDown","catchPointerMove","catchPointerUp","zIndex","handler","active","destroyInputCatcher","findIndex","getZIndex","setZIndex","getActive","setActive","onPointerDown","x","y","identifier","onPointerMove","onPointerUp","_private_ensureSorted","sort","count","step","SRGBToLinear","pow","LinearToSRGB","COLORS","black","white","red","green","blue","yellow","cyan","magenta","gray","grey","silver","maroon","olive","lime","aqua","teal","navy","fuchsia","purple","orange","pink","brown","gold","violet","indigo","coral","salmon","khaki","plum","orchid","tan","beige","mint","lavender","crimson","azure","ivory","snow","UIColor","_private_rInternal","_private_gInternal","_private_bInternal","_private_aInternal","_private_hInternal","_private_sInternal","_private_lInternal","_private_dirtyInternal","_private_rgbDirty","_private_hslDirty","g","hue","saturation","lightness","MathUtils","clamp","setDirtyFalse","setRGBA","firstArgument","startsWith","setHexString","setColorName","Color","setThreeColor","setHexRGB","getHexRGBA","round","getHexRGB","getHexStringRGB","padStart","getHexStringRGBA","setHexRGBA","hex","hexString","hexNumber","parseInt","isNaN","setHSL","colorName","normalizedName","toLowerCase","trim","setGLSLColor","sRGBR","sRGBG","sRGBB","threeColor","toCSSColor","toGLSLColor","Vector4","z","toThreeColor","color","clone","_private_ensureRGBUpdatedFromHSL","abs","hp","_private_ensureHSLUpdatedFromRGB","d","GLSL_TYPE_INFO_FLOAT","Object","freeze","glslTypeName","bufferSize","instantiable","GLSL_TYPE_INFO_SAMPLER2D","GLSL_TYPE_INFO_VEC2","GLSL_TYPE_INFO_VEC3","GLSL_TYPE_INFO_VEC4","GLSL_TYPE_INFO_MAT3","GLSL_TYPE_INFO_MAT4","resolveGLSLTypeInfo","Texture","Vector2","Vector3","Matrix3","Matrix4","resolvePropertyUniform","material","uniform","uniforms","arePropertiesPartiallyCompatible","full","partial","infoFull","glslTypeInfo","convertUIPropertiesToGLProperties","uiProperties","glProperties","cloneProperty","property","cloneProperties","properties","buildGenericPlaneFragmentShader","uniformDeclarations","varyingDeclarations","source","UITransparencyMode","INSTANCED_PLANE_GEOMETRY","planeGeometry","PlaneGeometry","translate","geometry","InstancedBufferGeometry","setAttribute","attributes","dispose","TEMP_COLOR_VECTOR","IDENTITY_MATRIX_ELEMENTS","writePropertyToArray","offset","elements","buildEmptyInstancedBufferAttribute","capacity","InstancedBufferAttribute","Float32Array","reconstructValue","referenceValue","matrix","fromArray","UIGenericInstancedPlane","Mesh","transparency","initialCapacity","uniformProperties","varyingProperties","instanceVisibility","instanceTransform","identity","descriptor","instancedGeometry","shaderMaterial","attributeDeclarations","vertexAssignments","vertexShader","fragmentShader","ShaderMaterial","transparent","BLEND","alphaTest","CLIP","alphaHash","HASH","depthWrite","depthTest","buildMaterial","super","frustumCulled","matrixAutoUpdate","matrixWorldAutoUpdate","_private_instancedGeometry","instanceCount","_private_shaderMaterial","_private_uniformProperties","_private_varyingProperties","ceil","attribute","uniformsNeedUpdate","createInstance","_private_ensureCapacity","visibilityBufferAttribute","_private_propertyBuffers","transformBufferAttribute","visibilityArray","transformArray","transformOffset","writeInstanceDefaults","needsUpdate","destroyInstance","_private_resolveIndex","_private_handlerToIndex","lastIndex","_private_moveInstanceData","_private_updateIndicesAfterMove","setProperties","_private_resolveAttribute","itemSize","setTransform","transform","setVisibility","visible","isPartiallyCompatible","extractInstanceData","_private_extractProperties","_private_extractTransform","visibility","_private_extractVisibility","destroy","clear","requiredCapacity","_private_capacity","newCapacity","oldAttribute","newArray","newAttribute","sourceIndex","targetIndex","values","srcOffset","dstOffset","oldIndex","newIndex","PLANE_GEOMETRY","UIGenericPlane","_private_source","p_transform","buildGenericPlaneMaterial","_private_properties","_private_transparencyInternal","_private_transform","descriptorValue","setTransparency","extractPlaneData","isSinglePlaneDescriptor","isInstancedPlaneDescriptor","UIPlaneRegistry","_private_scene","createPlane","_private_insertPlane","destroyPlane","planeDescriptor","_private_resolvePlaneDescriptor","plane","instancedPlane","_private_demoteInstancedPlaneToSinglePlane","instanceHandler","_private_handlerToPlaneDescriptor","planeData","_private_promoteSinglePlaneToInstancedPlane","removedDescriptor","remainingPair","_private_attachToInstancedPlane","compatibleInstancedPlane","_private_findCompatibleInstancedPlane","compatibleSinglePlanePair","_private_findCompatibleSinglePlane","handlerPlaneDescriptorPair","originalClearColor","originalClearAlpha","originalAutoClear","originalAutoClearColor","originalAutoClearDepth","originalAutoClearStencil","UISceneWrapper","width","height","Scene","_private_planeRegistry","OrthographicCamera","insertCustomObject","object","removeCustomObject","resize","_private_camera","right","top","updateProjectionMatrix","render","renderer","getClearColor","getClearAlpha","autoClear","autoClearColor","autoClearDepth","autoClearStencil","setClearColor","setClearAlpha","UIExpression","assertValidNumber","from","entries","variableIndex","_private_terms","hasTerm","prepareTerms","UIRelation","UILayerEvent","UISolverWrapper","_private_recalculationRequired","_private_lastVariableIndex","_private_lastConstraintIndex","createVariable","description","_private_buildConstraint","EQUAL","_private_solver","_private_variables","removeVariable","cDescription","suggestVariableValue","_private_rebuildConstraint","setVariablePriority","_private_rebuildVariable","readVariableValue","relation","enabled","_private_constraints","setConstraintLHS","_private_rebuildConstraintByDescription","setConstraintRHS","setConstraintRelation","setConstraintPriority","setConstraintEnabled","dependConstraints","oldConstraint","LESS_THAN","GREATER_THAN","convertRelation","_private_convertExpression","_private_rebuildSolver","LAYER_DEFAULT_MODE","VISIBLE","UILayer","Eventail","options","inputWrapperInternal","_private_sceneWrapperInternal","_private_orientationInternal","HORIZONTAL","VERTICAL","xVariable","_private_solverWrapperInternal","yVariable","wVariable","hVariable","sceneWrapper","solverWrapper","inputWrapper","_private_modeInternal","orientation","MODE_CHANGED","resizeInternal","ORIENTATION_CHANGED","renderInternal","deltaTime","RENDERING","isUILayerElement","obj","layer","isUIPointElement","isUIPlaneElement","EPSILON","assertValidConstraintArguments","assertValidInterpolationConstraintArguments","UIConstraint","UISingleParameterConstraint","_private_onOrientationChange","isConstraintEnabled","ALWAYS","_private_priorityInternal","_private_relationInternal","UIHeightConstraint","_private_element","_private_heightInternal","UIHorizontalDistanceConstraint","_private_a","_private_b","anchorA","anchorB","distance","_private_buildLHS","_private_distanceInternal","_private_anchorAInternal","_private_anchorBInternal","aExpression","bExpression","UIHorizontalInterpolationConstraint","_private_c","anchorC","_private_tInternal","_private_anchorCInternal","cExpression","aScaled","bScaled","UIHorizontalProportionConstraint","proportion","_private_buildRHS","_private_proportionInternal","UIVerticalDistanceConstraint","UIVerticalInterpolationConstraint","UIVerticalProportionConstraint","UIWidthConstraint","_private_widthInternal","normalizeUIType2D","isArray","UIConstraint2DBuilder","element","interpolation","UIAspectConstraint","_private_aspectInternal","aspect","COVER_CONSTRAINT_DEFAULT_ANCHOR","UICoverConstraintBuilder","build","passive","activeAspectConstraint","keepActiveAspect","xConstraint","anchorH","yConstraint","anchorV","widthConstraint","heightConstraint","DEFAULT_ANCHOR","UIFitConstraintBuilder","UICustomConstraint","_private_lhsInternal","_private_rhsInternal","setLHS","setRHS","UIAnchor","UIMicroAnchorMode","MICRO_DEFAULT_ANCHOR","MICRO_DEFAULT_ANCHOR_MODE","ROTATION_SCALE","TEMP_POSITION","TEMP_QUATERNION","Quaternion","TEMP_SCALE","TEMP_MATRIX","Z_AXIS","computeTrimmedTransformMatrix","microX","microY","microAnchorX","microAnchorY","microScaleX","microScaleY","microRotation","microAnchorMode","trimLeft","trimRight","trimTop","trimBottom","trimmedWidth","trimmedHeight","anchorOffsetX","anchorOffsetY","cos","sin","rotatedAnchorX","rotatedAnchorY","trimOffsetX","trimOffsetY","rotatedTrimX","rotatedTrimY","POSITION_ROTATION_SCALE","rawAnchorOffsetY","setFromAxisAngle","compose","TEXTURE_DEFAULT_TEXTURE","UITextureViewEvent","UITextureView","config","_private_textureInternal","_private_sourceWidth","_private_sourceHeight","_private_frameX","_private_frameY","_private_frameWidth","_private_frameHeight","_private_rotatedInternal","_private_scaleInternal","_private_trimLeft","_private_trimRight","_private_trimTop","_private_trimBottom","_private_textureDirtyInternal","_private_uvTransformDirtyInternal","_private_trimDirtyInternal","texture","rotated","scale","left","bottom","textureDirty","uvTransformDirty","trimDirty","setTextureDirtyFalse","setUVTransformDirtyFalse","setTrimDirtyFalse","calculateUVTransform","atlasWidth","image","naturalWidth","atlasHeight","naturalHeight","physicalHeight","vSize","getResolution","lastWidth","lastHeight","_private_setFromTexture","_private_setFromAtlasConfig","DIMENSIONS_CHANGED","sourceSize","frame","spriteSource","spriteSourceSize","UIInputEvent","UIMicro","anchorX","anchorY","scaleX","scaleY","rotation","anchorMode","_private_xInternal","_private_yInternal","_private_anchorXInternal","_private_anchorYInternal","_private_scaleXInternal","_private_scaleYInternal","angle","radToDeg","_private_anchorModeInternal","_private_rotationInternal","degToRad","reset","UIArea","UIAreaRectangle","pointX","pointY","DUMMY_DEFAULT_MODE","UIInputDummy","_private_wasPointerInside","handleInputEvent","PRESSED","MOVED","RELEASED","interactionArea","modeInternal","_private_catcherHandler","oppositeX","oppositeY","centerX","centerY","newInteractivity","inputEvent","isPointerInside","mapLinear","LEFT","ENTERED","ELEMENT_DEFAULT_TRANSPARENCY_MODE","UIElement","_private_transparencyModeDirty","_private_visibilityDirty","micro","_private_transparencyModeInternal","transparencyMode","planeHandler","onWillRender","setPlaneTransform","scaledWidth","scaledHeight","computeTransformMatrix","UIAnimatedImageEvent","UIAnimatedImageLoopMode","ANIMATED_IMAGE_DEFAULT_LOOP_MODE","LOOP","UIAnimatedImage","sequence","uiTextures","textureConfig","textureTransform","_private_isPlaying","_private_sequenceFrameIndex","_private_currentFrameIndexDirty","_private_accumulatedTime","_private_onTextureDimensionsChanged","_private_sequenceInternal","_private_colorInternal","_private_textureTransform","_private_frameRateInternal","frameRate","_private_timeScaleInternal","timeScale","_private_loopModeInternal","loopMode","playByDefault","play","duration","stop","newLength","currentLength","PLAYED","pause","PAUSED","STOPPED","frameDuration","sequenceLength","lastFrameIndex","PING_PONG","textureTrim","_private_subscribeSequenceEvents","_private_unsubscribeSequenceEvents","GRAPHICS_TEMP_COLOR","UIGraphics","canvas","OffscreenCanvas","getContext","CanvasTexture","colorSpace","SRGBColorSpace","minFilter","LinearFilter","magFilter","_private_canvas","_private_context","_private_texture","clearRect","fillStyle","fillRect","drawRect","drawCircle","radius","beginPath","arc","PI","fill","drawArc","startAngle","endAngle","drawPolyline","points","lineWidth","strokeStyle","moveTo","lineTo","stroke","UIImage","textureView","UIInsets","setHorizontal","setVertical","setUnified","lOld","rOld","tOld","bOld","horizontal","vertical","setVector4","vector","toVector4","UINineSliceRegionMode","NINE_SLICE_DEFAULT_REGION_MODE","WORLD","UINineSlice","sliceBorders","sliceRegions","regionMode","sliceBordersVector","sliceRegionsVector","_private_regionModeDirty","_private_textureDimensionsDirty","_private_sliceBordersInternal","_private_sliceRegionsInternal","_private_regionModeInternal","_private_sliceBordersVector","_private_sliceRegionsVector","_private_lastElementWidth","_private_lastElementHeight","_private_calculateSliceBordersForShader","_private_checkElementDimensionsDirty","_private_calculateSliceRegionsForShader","sourceWidth","sourceHeight","trimNRight","trimNTop","trimNBottom","trimmedWidthNorm","trimmedHeightNorm","srcRight","srcTop","srcBottom","NORMALIZED","_private_setElementDimensionsDirtyFalse","UIProgressMaskFunction","dirtyInternal","UIProgressMaskFunctionDirectional","direction","normalize","_private_cachedDirection","equals","enumerateProperties","_private_ensureDirectionNormalized","squaredLength","lengthSq","divideScalar","UISceneUpdateMode","UIProgress","textureResolution","progress","maskFunction","_private_progressDirty","_private_textureResolutionDirty","_private_textureResolution","_private_progressInternal","_private_maskFunctionInternal","maskProperties","_private_rebuildPlane","SCENE_DEFAULT_UPDATE_MODE","ON_PROPERTIES_CHANGE","SCENE_DEFAULT_CLEAR_COLOR","UIScene","resolutionFactor","renderTarget","WebGLRenderTarget","format","RGBAFormat","UnsignedByteType","depthBuffer","enableDepthBuffer","stencilBuffer","_private_evenFrame","_private_updateRequired","_private_resolutionFactorDirty","_private_propertyDirty","_private_clearColorInternal","clearColor","_private_renderTarget","_private_sceneInternal","scene","_private_cameraInternal","camera","PerspectiveCamera","_private_resolutionFactorInternal","updateMode","MANUAL","_private_updateModeInternal","requestUpdate","EVERY_FRAME","EVERY_SECOND_FRAME","ON_DIMENSIONS_CHANGE","setSize","setRenderTarget","TEXT_STYLE_DEFAULT_COLOR","TEXT_STYLE_DEFAULT_ALIGN","TEXT_STYLE_DEFAULT_FONT_FAMILY","TEXT_STYLE_DEFAULT_FONT_STYLE","TEXT_STYLE_DEFAULT_FONT_WEIGHT","TEXT_STYLE_DEFAULT_ENABLE_SHADOW","TEXT_STYLE_DEFAULT_SHADOW_COLOR","TEXT_STYLE_DEFAULT_ENABLE_STROKE","TEXT_STYLE_DEFAULT_STROKE_COLOR","UITextStyle","_private_alignInternal","align","_private_fontFamilyInternal","fontFamily","_private_fontSizeInternal","fontSize","_private_fontStyleInternal","fontStyle","_private_fontWeightInternal","fontWeight","_private_lineHeightInternal","lineHeight","_private_enableShadowInternal","enableShadow","_private_shadowOffsetXInternal","shadowOffsetX","_private_shadowOffsetYInternal","shadowOffsetY","_private_shadowBlurInternal","shadowBlur","_private_shadowColorInternal","shadowColor","_private_enableStrokeInternal","enableStroke","_private_strokeColorInternal","strokeColor","_private_strokeThicknessInternal","strokeThickness","resolve","primary","fallback","setDefaults","TEXT_STYLE_DEFAULT_FONT_SIZE","calculatePadding","padding","offsetY","shadowSpread","UITextSpan","_private_textInternal","text","style","UITextResizeMode","TEXT_DEFAULT_RESIZE_MODE","SCALE","splitTextIntoChunks","match","measureTextChunk","textStyle","font","baseline","metrics","measureText","actualBoundingBoxAscent","actualBoundingBoxDescent","calculateTextContentParameters","textChunks","maxLineWidth","lines","maxWidth","currentLine","currentWidth","currentHeight","currentBaseline","currentLineHeight","textChunk","chunks","buildTextLines","line","totalHeight","calculateTextSize","renderTextChunk","strokeText","fillText","renderTextLines","paddingTop","paddingLeft","currentY","textWidth","firstAlign","lineAlign","every","offsetX","currentX","chunk","UIText","content","_private_contentInternal","_private_contentDirty","_private_maxLineWidthDirty","_private_resizeModeDirty","_private_textChunks","_private_textChunksDirty","_private_paddingInternal","commonStyle","_private_maxLineWidthInternal","resizeMode","_private_lastWidth","_private_lastHeight","reduce","BREAK","_private_resizeModeInternal","span","_private_tryToRenderTextScaleMode","_private_checkContentDirty","_private_buildTextChunks","desiredHeight","desiredWidth","resolutionDirty","_private_updateProperties","_private_tryToRenderTextBreakMode","_private_checkDimensionsDirty","desiredTextSize","paddingV","paddingH","realTextLines","realTextSize","safeWidth","safeHeight","textSpans","textSpan","textChunkMetrics","buildTextChunks","_private_setDimensionsDirtyFalse","some","_private_setContentDirtyFalse","UIResizePolicy","UIResizePolicyNone","calculateScale","FULLSCREEN_LAYER_DEFAULT_RESIZE_POLICY","UIFullscreenLayer","resizePolicy","window","innerWidth","innerHeight","_private_resizePolicyDirty","_private_onResize","event","_private_handleWindowInput","_private_resizePolicyInternal","addEventListener","removeEventListener","projectWorldPosition","position","project","projectLayerPosition","unproject","buildRay","Ray","near","sub","pointerFunctionName","rect","target","HTMLElement","getBoundingClientRect","clientX","clientY","scaledX","scaledY","pointerId","UIAreaCircle","deltaX","deltaY","UIAreaPolygon","vertices","vertexCount","inside","previousIndex","currentVertex","previousVertex","previousY","UIAreaRoundedRectangle","cornerLeft","cornerRight","cornerTop","cornerBottom","UIProgressMaskFunctionCircular","inverseDirection","_private_startAngleInternal","_private_inverseDirectionInternal","UIResizePolicyCover","rectWidth","rectHeight","_private_rectWidthInternal","_private_rectHeightInternal","UIResizePolicyCross","fixedWidthLandscape","fixedHeightPortrait","_private_fixedWidthLandscapeInternal","_private_fixedHeightPortraitInternal","UIResizePolicyCrossInverted","fixedHeightLandscape","fixedWidthPortrait","_private_fixedHeightLandscapeInternal","_private_fixedWidthPortraitInternal","UIResizePolicyFit","UIResizePolicyFixedHeight","UIResizePolicyFixedWidth"],"mappings":"gbAAA,MAAMA,EAAE,WAAAC,CAAYD,EAAEE,EAAEC,EAAE,GAAGC,KAAKJ,EAAE,IAAIK,QAAQD,KAAKF,EAAE,IAAII,SAAI,IAASN,SAAI,IAASE,EAAEE,KAAKF,EAAEK,IAAIP,EAAEG,GAAGC,KAAKJ,EAAEO,IAAIL,EAAE,IAAII,IAAI,CAAC,CAACN,EAAEG,MAAM,CAAC,MAAAK,CAAOR,EAAEE,EAAEC,EAAE,GAAG,QAAG,IAASD,EAAE,CAAC,GAAGE,KAAKF,EAAEO,IAAIT,GAAG,OAAO,YAAYI,KAAKF,EAAEK,IAAIP,EAAEG,EAAE,CAAC,MAAMO,EAAEN,KAAKJ,EAAEW,IAAIT,QAAG,IAASQ,EAAEN,KAAKJ,EAAEO,IAAIL,EAAE,IAAII,IAAI,CAAC,CAACN,EAAEG,MAAMO,EAAED,IAAIT,IAAIU,EAAEH,IAAIP,EAAEG,EAAE,CAAC,MAAAS,CAAOZ,EAAEE,GAAG,QAAG,IAASA,EAAE,YAAYE,KAAKF,EAAEW,OAAOb,GAAG,MAAMG,EAAEC,KAAKJ,EAAEW,IAAIT,QAAG,IAASC,IAAIA,EAAEU,OAAOb,GAAG,IAAIG,EAAEW,MAAMV,KAAKJ,EAAEa,OAAOX,GAAG,CAAC,GAAAO,CAAIT,EAAEE,GAAG,QAAG,IAASA,EAAE,OAAOE,KAAKF,EAAEO,IAAIT,GA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