laymur 0.18.1 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/README.md +2 -2
  2. package/dist/core/constraints/UIAspectConstraint/UIAspectConstraint.d.ts +1 -1
  3. package/dist/core/constraints/UIAspectConstraint/UIAspectConstraint.js +6 -6
  4. package/dist/core/constraints/UIConstraint.d.ts +1 -0
  5. package/dist/core/constraints/UIConstraint.js +4 -0
  6. package/dist/core/constraints/UIHeightConstraint/UIHeightConstraint.d.ts +1 -1
  7. package/dist/core/constraints/UIHeightConstraint/UIHeightConstraint.js +5 -5
  8. package/dist/core/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.d.ts +2 -2
  9. package/dist/core/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.js +14 -14
  10. package/dist/core/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.d.ts +3 -3
  11. package/dist/core/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.js +20 -20
  12. package/dist/core/constraints/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.d.ts +2 -2
  13. package/dist/core/constraints/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.js +5 -5
  14. package/dist/core/constraints/UISingleParameterConstraint/UISingleParameterConstraint.js +1 -0
  15. package/dist/core/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.d.ts +2 -2
  16. package/dist/core/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.js +14 -14
  17. package/dist/core/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.d.ts +3 -3
  18. package/dist/core/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.js +20 -20
  19. package/dist/core/constraints/UIVerticalProportionConstraint/UIVerticalProportionConstraint.d.ts +2 -2
  20. package/dist/core/constraints/UIVerticalProportionConstraint/UIVerticalProportionConstraint.js +5 -5
  21. package/dist/core/constraints/UIWidthConstraint/UIWidthConstraint.d.ts +1 -1
  22. package/dist/core/constraints/UIWidthConstraint/UIWidthConstraint.js +5 -5
  23. package/dist/core/layers/UILayer/UILayer.d.ts +18 -0
  24. package/dist/core/layers/UILayer/UILayer.js +48 -0
  25. package/dist/core/miscellaneous/shared.d.ts +8 -0
  26. package/dist/debug/UIAspectDebug.d.ts +26 -0
  27. package/dist/debug/UIAspectDebug.js +118 -0
  28. package/dist/debug/UIConstraintDebug.d.ts +7 -0
  29. package/dist/debug/UIHeightDebug.d.ts +26 -0
  30. package/dist/debug/UIHeightDebug.js +111 -0
  31. package/dist/debug/UIHorizontalDistanceDebug.d.ts +29 -0
  32. package/dist/debug/UIHorizontalDistanceDebug.js +158 -0
  33. package/dist/debug/UIHorizontalInterpolationDebug.d.ts +29 -0
  34. package/dist/debug/UIHorizontalInterpolationDebug.js +145 -0
  35. package/dist/debug/UILayerDebug.d.ts +34 -0
  36. package/dist/debug/UILayerDebug.js +124 -0
  37. package/dist/debug/UIVerticalDistanceDebug.d.ts +29 -0
  38. package/dist/debug/UIVerticalDistanceDebug.js +158 -0
  39. package/dist/debug/UIVerticalInterpolationDebug.d.ts +29 -0
  40. package/dist/debug/UIVerticalInterpolationDebug.js +145 -0
  41. package/dist/debug/UIWidthDebug.d.ts +26 -0
  42. package/dist/debug/UIWidthDebug.js +111 -0
  43. package/dist/debug/index.d.ts +8 -0
  44. package/dist/debug/index.js +8 -0
  45. package/dist/debug/miscellaneous.d.ts +8 -0
  46. package/dist/debug/miscellaneous.js +11 -0
  47. package/dist/node_modules/three/examples/jsm/lines/Line2.js +56 -0
  48. package/dist/node_modules/three/examples/jsm/lines/LineGeometry.js +157 -0
  49. package/dist/node_modules/three/examples/jsm/lines/LineMaterial.js +691 -0
  50. package/dist/node_modules/three/examples/jsm/lines/LineSegments2.js +415 -0
  51. package/dist/node_modules/three/examples/jsm/lines/LineSegmentsGeometry.js +289 -0
  52. package/package.json +5 -1
package/README.md CHANGED
@@ -33,9 +33,9 @@ Peer Dependencies:
33
33
  * `@lume/kiwi` (^0.4.4)
34
34
  * `ferrsign` (^0.0.4)
35
35
 
36
- ## Live Examples
36
+ ## Visual Editor & Live Examples
37
37
 
38
- Check out interactive examples and demos at:
38
+ Check out visual editor and interactive examples at:
39
39
  **[https://jango-git.github.io/laymur/](https://jango-git.github.io/laymur/)**
40
40
 
41
41
  ## Core Concepts
@@ -3,7 +3,7 @@ import { UISingleParameterConstraint } from "../UISingleParameterConstraint/UISi
3
3
  import type { UIAspectConstraintOptions } from "./UIAspectConstraint.Internal";
4
4
  /** Maintains element aspect ratio (width = height * aspect) */
5
5
  export declare class UIAspectConstraint extends UISingleParameterConstraint {
6
- private readonly element;
6
+ readonly element: UIPlaneElement & UILayerElement;
7
7
  /** Solver constraint descriptor */
8
8
  protected readonly constraint: number;
9
9
  /** Current aspect ratio */
@@ -8,13 +8,13 @@ class UIAspectConstraint extends UISingleParameterConstraint {
8
8
  * @param element Element to constrain
9
9
  * @param options Aspect configuration. Defaults to element's current ratio.
10
10
  */
11
- constructor(_private_element, options = {}) {
11
+ constructor(element, options = {}) {
12
12
  if (options.aspect !== undefined) {
13
13
  assertValidPositiveNumber(options.aspect, "UIAspectConstraint.constructor.options.aspect");
14
14
  }
15
- super(_private_element.layer, options);
16
- this._private_element = _private_element;
17
- this._private_aspectInternal = options.aspect ?? _private_element.width / _private_element.height;
15
+ super(element.layer, options);
16
+ this.element = element;
17
+ this._private_aspectInternal = options.aspect ?? element.width / element.height;
18
18
  this.constraint = this.solverWrapper.createConstraint(this._private_buildLHS(), new UIExpression(0), this.relation, this.priority, this.isConstraintEnabled());
19
19
  }
20
20
  /** Current aspect ratio (width/height) */
@@ -32,8 +32,8 @@ class UIAspectConstraint extends UISingleParameterConstraint {
32
32
  /** Builds constraint expression: width - (height * aspect) = 0 */
33
33
  _private_buildLHS() {
34
34
  return new UIExpression(0, [
35
- [this._private_element.wVariable, 1],
36
- [this._private_element.hVariable, -this._private_aspectInternal],
35
+ [this.element.wVariable, 1],
36
+ [this.element.hVariable, -this._private_aspectInternal],
37
37
  ]);
38
38
  }
39
39
  }
@@ -9,4 +9,5 @@ export declare abstract class UIConstraint {
9
9
  protected readonly solverWrapper: UISolverWrapperView;
10
10
  /** @param layer Layer containing this constraint */
11
11
  constructor(layer: UILayer, name?: string);
12
+ destroy(): void;
12
13
  }
@@ -5,6 +5,10 @@ class UIConstraint {
5
5
  this.layer = layer;
6
6
  this.solverWrapper = this.layer.solverWrapper;
7
7
  this.name = name ?? "";
8
+ this.layer.addConstraint(this);
9
+ }
10
+ destroy() {
11
+ this.layer.removeConstraint(this);
8
12
  }
9
13
  }
10
14
 
@@ -3,7 +3,7 @@ import { UISingleParameterConstraint } from "../UISingleParameterConstraint/UISi
3
3
  import type { UIHeightConstraintOptions } from "./UIHeightConstraint.Internal";
4
4
  /** Fixes element height to constant value */
5
5
  export declare class UIHeightConstraint extends UISingleParameterConstraint {
6
- private readonly element;
6
+ readonly element: UIPlaneElement & UILayerElement;
7
7
  /** Solver constraint descriptor */
8
8
  protected readonly constraint: number;
9
9
  /** Current height value */
@@ -8,14 +8,14 @@ class UIHeightConstraint extends UISingleParameterConstraint {
8
8
  * @param element Element to constrain
9
9
  * @param options Height configuration. Defaults to element's current height.
10
10
  */
11
- constructor(_private_element, options = {}) {
11
+ constructor(element, options = {}) {
12
12
  if (options.height !== undefined) {
13
13
  assertValidPositiveNumber(options.height, "UIHeightConstraint.constructor.options.height");
14
14
  }
15
- super(_private_element.layer, options);
16
- this._private_element = _private_element;
17
- this._private_heightInternal = options.height ?? _private_element.height;
18
- this.constraint = this.solverWrapper.createConstraint(new UIExpression(0, [[this._private_element.hVariable, 1]]), new UIExpression(this._private_heightInternal), this.relation, this.priority, this.isConstraintEnabled());
15
+ super(element.layer, options);
16
+ this.element = element;
17
+ this._private_heightInternal = options.height ?? element.height;
18
+ this.constraint = this.solverWrapper.createConstraint(new UIExpression(0, [[this.element.hVariable, 1]]), new UIExpression(this._private_heightInternal), this.relation, this.priority, this.isConstraintEnabled());
19
19
  }
20
20
  /** Current height in world units */
21
21
  get height() {
@@ -3,8 +3,8 @@ import { UISingleParameterConstraint } from "../UISingleParameterConstraint/UISi
3
3
  import type { UIHorizontalDistanceConstraintOptions } from "./UIHorizontalDistanceConstraint.Internal";
4
4
  /** Maintains horizontal distance between elements with configurable anchors */
5
5
  export declare class UIHorizontalDistanceConstraint extends UISingleParameterConstraint {
6
- private readonly a;
7
- private readonly b;
6
+ readonly a: UIPointElement | UIPlaneElement;
7
+ readonly b: UIPointElement | UIPlaneElement;
8
8
  /** Solver constraint descriptor */
9
9
  protected readonly constraint: number;
10
10
  /** Anchor on element A */
@@ -11,7 +11,7 @@ class UIHorizontalDistanceConstraint extends UISingleParameterConstraint {
11
11
  * @param b Second element
12
12
  * @param options Distance configuration
13
13
  */
14
- constructor(_private_a, _private_b, options = {}) {
14
+ constructor(a, b, options = {}) {
15
15
  if (options.anchorA !== undefined) {
16
16
  assertValidNumber(options.anchorA, "UIHorizontalDistanceConstraint.constructor.options.anchorA");
17
17
  }
@@ -21,9 +21,9 @@ class UIHorizontalDistanceConstraint extends UISingleParameterConstraint {
21
21
  if (options.distance !== undefined) {
22
22
  assertValidNumber(options.distance, "UIHorizontalDistanceConstraint.constructor.options.distance");
23
23
  }
24
- super(assertValidConstraintArguments(_private_a, _private_b, "UIHorizontalDistanceConstraint.constructor"), options);
25
- this._private_a = _private_a;
26
- this._private_b = _private_b;
24
+ super(assertValidConstraintArguments(a, b, "UIHorizontalDistanceConstraint.constructor"), options);
25
+ this.a = a;
26
+ this.b = b;
27
27
  this._private_anchorAInternal = options.anchorA ?? DEFAULT_ANCHOR;
28
28
  this._private_anchorBInternal = options.anchorB ?? DEFAULT_ANCHOR;
29
29
  this._private_distanceInternal = options.distance ?? 0;
@@ -69,26 +69,26 @@ class UIHorizontalDistanceConstraint extends UISingleParameterConstraint {
69
69
  _private_buildLHS() {
70
70
  let aExpression;
71
71
  let bExpression;
72
- if (isUIPlaneElement(this._private_a)) {
72
+ if (isUIPlaneElement(this.a)) {
73
73
  aExpression = new UIExpression(0, [
74
- [this._private_a.xVariable, 1],
75
- [this._private_a.wVariable, this._private_anchorAInternal],
74
+ [this.a.xVariable, 1],
75
+ [this.a.wVariable, this._private_anchorAInternal],
76
76
  ]);
77
77
  }
78
- else if (isUIPointElement(this._private_a)) {
79
- aExpression = new UIExpression().plus(this._private_a.xVariable, 1);
78
+ else if (isUIPointElement(this.a)) {
79
+ aExpression = new UIExpression().plus(this.a.xVariable, 1);
80
80
  }
81
81
  else {
82
82
  throw new Error("UIHorizontalDistanceConstraint.buildLHS.a: invalid element type");
83
83
  }
84
- if (isUIPlaneElement(this._private_b)) {
84
+ if (isUIPlaneElement(this.b)) {
85
85
  bExpression = new UIExpression(0, [
86
- [this._private_b.xVariable, 1],
87
- [this._private_b.wVariable, this._private_anchorBInternal],
86
+ [this.b.xVariable, 1],
87
+ [this.b.wVariable, this._private_anchorBInternal],
88
88
  ]);
89
89
  }
90
- else if (isUIPointElement(this._private_b)) {
91
- bExpression = new UIExpression().plus(this._private_b.xVariable, 1);
90
+ else if (isUIPointElement(this.b)) {
91
+ bExpression = new UIExpression().plus(this.b.xVariable, 1);
92
92
  }
93
93
  else {
94
94
  throw new Error("UIHorizontalDistanceConstraint.buildLHS.b: invalid element type");
@@ -3,9 +3,9 @@ import { UISingleParameterConstraint } from "../UISingleParameterConstraint/UISi
3
3
  import type { UIHorizontalInterpolationConstraintOptions } from "./UIHorizontalInterpolationConstraint.Internal";
4
4
  /** Positions element C horizontally between A and B based on interpolation factor */
5
5
  export declare class UIHorizontalInterpolationConstraint extends UISingleParameterConstraint {
6
- private readonly a;
7
- private readonly b;
8
- private readonly c;
6
+ readonly a: UIPointElement | UIPlaneElement;
7
+ readonly b: UIPointElement | UIPlaneElement;
8
+ readonly c: UIPointElement | UIPlaneElement;
9
9
  /** Solver constraint descriptor */
10
10
  protected readonly constraint: number;
11
11
  /** Anchor on element A */
@@ -12,7 +12,7 @@ class UIHorizontalInterpolationConstraint extends UISingleParameterConstraint {
12
12
  * @param c Element to position between A and B
13
13
  * @param options Interpolation configuration
14
14
  */
15
- constructor(_private_a, _private_b, _private_c, options = {}) {
15
+ constructor(a, b, c, options = {}) {
16
16
  if (options.anchorA !== undefined) {
17
17
  assertValidNumber(options.anchorA, "UIHorizontalInterpolationConstraint.constructor.options.anchorA");
18
18
  }
@@ -27,10 +27,10 @@ class UIHorizontalInterpolationConstraint extends UISingleParameterConstraint {
27
27
  }
28
28
  const anchorA = options.anchorA ?? DEFAULT_ANCHOR;
29
29
  const anchorB = options.anchorB ?? DEFAULT_ANCHOR;
30
- super(assertValidInterpolationConstraintArguments("UIHorizontalInterpolationConstraint.constructor", _private_a, _private_b, _private_c, anchorA, anchorB), options);
31
- this._private_a = _private_a;
32
- this._private_b = _private_b;
33
- this._private_c = _private_c;
30
+ super(assertValidInterpolationConstraintArguments("UIHorizontalInterpolationConstraint.constructor", a, b, c, anchorA, anchorB), options);
31
+ this.a = a;
32
+ this.b = b;
33
+ this.c = c;
34
34
  this._private_anchorAInternal = anchorA;
35
35
  this._private_anchorBInternal = anchorA;
36
36
  this._private_anchorCInternal = options.anchorC ?? DEFAULT_ANCHOR;
@@ -90,38 +90,38 @@ class UIHorizontalInterpolationConstraint extends UISingleParameterConstraint {
90
90
  let aExpression;
91
91
  let bExpression;
92
92
  let cExpression;
93
- if (isUIPlaneElement(this._private_a)) {
93
+ if (isUIPlaneElement(this.a)) {
94
94
  aExpression = new UIExpression(0, [
95
- [this._private_a.xVariable, 1],
96
- [this._private_a.wVariable, this._private_anchorAInternal],
95
+ [this.a.xVariable, 1],
96
+ [this.a.wVariable, this._private_anchorAInternal],
97
97
  ]);
98
98
  }
99
- else if (isUIPointElement(this._private_a)) {
100
- aExpression = new UIExpression().plus(this._private_a.xVariable, 1);
99
+ else if (isUIPointElement(this.a)) {
100
+ aExpression = new UIExpression().plus(this.a.xVariable, 1);
101
101
  }
102
102
  else {
103
103
  throw new Error("UIHorizontalInterpolationConstraint.buildLHS.a: invalid element type");
104
104
  }
105
- if (isUIPlaneElement(this._private_b)) {
105
+ if (isUIPlaneElement(this.b)) {
106
106
  bExpression = new UIExpression(0, [
107
- [this._private_b.xVariable, 1],
108
- [this._private_b.wVariable, this._private_anchorBInternal],
107
+ [this.b.xVariable, 1],
108
+ [this.b.wVariable, this._private_anchorBInternal],
109
109
  ]);
110
110
  }
111
- else if (isUIPointElement(this._private_b)) {
112
- bExpression = new UIExpression().plus(this._private_b.xVariable, 1);
111
+ else if (isUIPointElement(this.b)) {
112
+ bExpression = new UIExpression().plus(this.b.xVariable, 1);
113
113
  }
114
114
  else {
115
115
  throw new Error("UIHorizontalInterpolationConstraint.buildLHS.b: invalid element type");
116
116
  }
117
- if (isUIPlaneElement(this._private_c)) {
117
+ if (isUIPlaneElement(this.c)) {
118
118
  cExpression = new UIExpression(0, [
119
- [this._private_c.xVariable, 1],
120
- [this._private_c.wVariable, this._private_anchorCInternal],
119
+ [this.c.xVariable, 1],
120
+ [this.c.wVariable, this._private_anchorCInternal],
121
121
  ]);
122
122
  }
123
- else if (isUIPointElement(this._private_c)) {
124
- cExpression = new UIExpression().plus(this._private_c.xVariable, 1);
123
+ else if (isUIPointElement(this.c)) {
124
+ cExpression = new UIExpression().plus(this.c.xVariable, 1);
125
125
  }
126
126
  else {
127
127
  throw new Error("UIHorizontalInterpolationConstraint.buildLHS.c: invalid element type");
@@ -3,8 +3,8 @@ import { UISingleParameterConstraint } from "../UISingleParameterConstraint/UISi
3
3
  import type { UIHorizontalProportionConstraintOptions } from "./UIHorizontalProportionConstraint.Internal";
4
4
  /** Maintains proportional width relationship (A.width * proportion = B.width) */
5
5
  export declare class UIHorizontalProportionConstraint extends UISingleParameterConstraint {
6
- private readonly a;
7
- private readonly b;
6
+ readonly a: UIPlaneElement;
7
+ readonly b: UIPlaneElement;
8
8
  protected readonly constraint: number;
9
9
  private proportionInternal;
10
10
  /**
@@ -9,13 +9,13 @@ class UIHorizontalProportionConstraint extends UISingleParameterConstraint {
9
9
  * @param b Second element
10
10
  * @param options Proportion configuration
11
11
  */
12
- constructor(_private_a, _private_b, options = {}) {
12
+ constructor(a, b, options = {}) {
13
13
  if (options.proportion !== undefined) {
14
14
  assertValidPositiveNumber(options.proportion, "UIHorizontalProportionConstraint.constructor.options.proportion");
15
15
  }
16
- super(assertValidConstraintArguments(_private_a, _private_b, "UIHorizontalProportionConstraint.constructor"), options);
17
- this._private_a = _private_a;
18
- this._private_b = _private_b;
16
+ super(assertValidConstraintArguments(a, b, "UIHorizontalProportionConstraint.constructor"), options);
17
+ this.a = a;
18
+ this.b = b;
19
19
  this._private_proportionInternal = options.proportion ?? 1;
20
20
  this.constraint = this.solverWrapper.createConstraint(new UIExpression(0), this._private_buildRHS(), this.relation, this.priority, this.isConstraintEnabled());
21
21
  }
@@ -33,7 +33,7 @@ class UIHorizontalProportionConstraint extends UISingleParameterConstraint {
33
33
  }
34
34
  /** Builds constraint expression for proportional relationship */
35
35
  _private_buildRHS() {
36
- return UIExpression.minus(new UIExpression(0, [[this._private_a.wVariable, this._private_proportionInternal]]), new UIExpression(0, [[this._private_b.wVariable, 1]]));
36
+ return UIExpression.minus(new UIExpression(0, [[this.a.wVariable, this._private_proportionInternal]]), new UIExpression(0, [[this.b.wVariable, 1]]));
37
37
  }
38
38
  }
39
39
 
@@ -57,6 +57,7 @@ class UISingleParameterConstraint extends UIConstraint {
57
57
  destroy() {
58
58
  this.layer.signalOrientationChanged.off(this._private_onOrientationChange);
59
59
  this.solverWrapper.removeConstraint(this.constraint);
60
+ super.destroy();
60
61
  }
61
62
  /**
62
63
  * Checks if constraint should be active for current orientation.
@@ -3,8 +3,8 @@ import { UISingleParameterConstraint } from "../UISingleParameterConstraint/UISi
3
3
  import type { UIVerticalDistanceConstraintOptions } from "./UIVerticalDistanceConstraint.Internal";
4
4
  /** Maintains vertical distance between elements with configurable anchors */
5
5
  export declare class UIVerticalDistanceConstraint extends UISingleParameterConstraint {
6
- private readonly a;
7
- private readonly b;
6
+ readonly a: UIPointElement | UIPlaneElement;
7
+ readonly b: UIPointElement | UIPlaneElement;
8
8
  protected readonly constraint: number;
9
9
  private anchorAInternal;
10
10
  private anchorBInternal;
@@ -11,7 +11,7 @@ class UIVerticalDistanceConstraint extends UISingleParameterConstraint {
11
11
  * @param b Second element
12
12
  * @param options Distance configuration
13
13
  */
14
- constructor(_private_a, _private_b, options = {}) {
14
+ constructor(a, b, options = {}) {
15
15
  if (options.anchorA !== undefined) {
16
16
  assertValidNumber(options.anchorA, "UIVerticalDistanceConstraint.constructor.options.anchorA");
17
17
  }
@@ -21,9 +21,9 @@ class UIVerticalDistanceConstraint extends UISingleParameterConstraint {
21
21
  if (options.distance !== undefined) {
22
22
  assertValidNumber(options.distance, "UIVerticalDistanceConstraint.constructor.options.distance");
23
23
  }
24
- super(assertValidConstraintArguments(_private_a, _private_b, "UIVerticalDistanceConstraint.constructor"), options);
25
- this._private_a = _private_a;
26
- this._private_b = _private_b;
24
+ super(assertValidConstraintArguments(a, b, "UIVerticalDistanceConstraint.constructor"), options);
25
+ this.a = a;
26
+ this.b = b;
27
27
  this._private_anchorAInternal = options.anchorA ?? DEFAULT_ANCHOR;
28
28
  this._private_anchorBInternal = options.anchorB ?? DEFAULT_ANCHOR;
29
29
  this._private_distanceInternal = options.distance ?? 0;
@@ -69,26 +69,26 @@ class UIVerticalDistanceConstraint extends UISingleParameterConstraint {
69
69
  _private_buildLHS() {
70
70
  let aExpression;
71
71
  let bExpression;
72
- if (isUIPlaneElement(this._private_a)) {
72
+ if (isUIPlaneElement(this.a)) {
73
73
  aExpression = new UIExpression(0, [
74
- [this._private_a.yVariable, 1],
75
- [this._private_a.hVariable, this._private_anchorAInternal],
74
+ [this.a.yVariable, 1],
75
+ [this.a.hVariable, this._private_anchorAInternal],
76
76
  ]);
77
77
  }
78
- else if (isUIPointElement(this._private_a)) {
79
- aExpression = new UIExpression().plus(this._private_a.yVariable, 1);
78
+ else if (isUIPointElement(this.a)) {
79
+ aExpression = new UIExpression().plus(this.a.yVariable, 1);
80
80
  }
81
81
  else {
82
82
  throw new Error("UIVerticalDistanceConstraint.buildLHS.a: invalid element type");
83
83
  }
84
- if (isUIPlaneElement(this._private_b)) {
84
+ if (isUIPlaneElement(this.b)) {
85
85
  bExpression = new UIExpression(0, [
86
- [this._private_b.yVariable, 1],
87
- [this._private_b.hVariable, this._private_anchorBInternal],
86
+ [this.b.yVariable, 1],
87
+ [this.b.hVariable, this._private_anchorBInternal],
88
88
  ]);
89
89
  }
90
- else if (isUIPointElement(this._private_b)) {
91
- bExpression = new UIExpression().plus(this._private_b.yVariable, 1);
90
+ else if (isUIPointElement(this.b)) {
91
+ bExpression = new UIExpression().plus(this.b.yVariable, 1);
92
92
  }
93
93
  else {
94
94
  throw new Error("UIVerticalDistanceConstraint.buildLHS.b: invalid element type");
@@ -3,9 +3,9 @@ import { UISingleParameterConstraint } from "../UISingleParameterConstraint/UISi
3
3
  import type { UIVerticalInterpolationConstraintOptions } from "./UIVerticalInterpolationConstraint.Internal";
4
4
  /** Positions element C vertically between A and B based on interpolation factor */
5
5
  export declare class UIVerticalInterpolationConstraint extends UISingleParameterConstraint {
6
- private readonly a;
7
- private readonly b;
8
- private readonly c;
6
+ readonly a: UIPointElement | UIPlaneElement;
7
+ readonly b: UIPointElement | UIPlaneElement;
8
+ readonly c: UIPointElement | UIPlaneElement;
9
9
  /** Solver constraint descriptor */
10
10
  protected readonly constraint: number;
11
11
  /** Anchor on element A */
@@ -12,7 +12,7 @@ class UIVerticalInterpolationConstraint extends UISingleParameterConstraint {
12
12
  * @param c Element to position between A and B
13
13
  * @param options Interpolation configuration
14
14
  */
15
- constructor(_private_a, _private_b, _private_c, options = {}) {
15
+ constructor(a, b, c, options = {}) {
16
16
  if (options.anchorA !== undefined) {
17
17
  assertValidNumber(options.anchorA, "UIVerticalInterpolationConstraint.constructor.options.anchorA");
18
18
  }
@@ -27,10 +27,10 @@ class UIVerticalInterpolationConstraint extends UISingleParameterConstraint {
27
27
  }
28
28
  const anchorA = options.anchorA ?? DEFAULT_ANCHOR;
29
29
  const anchorB = options.anchorB ?? DEFAULT_ANCHOR;
30
- super(assertValidInterpolationConstraintArguments("UIVerticalInterpolationConstraint.constructor", _private_a, _private_b, _private_c, anchorA, anchorB), options);
31
- this._private_a = _private_a;
32
- this._private_b = _private_b;
33
- this._private_c = _private_c;
30
+ super(assertValidInterpolationConstraintArguments("UIVerticalInterpolationConstraint.constructor", a, b, c, anchorA, anchorB), options);
31
+ this.a = a;
32
+ this.b = b;
33
+ this.c = c;
34
34
  this._private_anchorAInternal = anchorA;
35
35
  this._private_anchorBInternal = anchorA;
36
36
  this._private_anchorCInternal = options.anchorC ?? DEFAULT_ANCHOR;
@@ -90,38 +90,38 @@ class UIVerticalInterpolationConstraint extends UISingleParameterConstraint {
90
90
  let aExpression;
91
91
  let bExpression;
92
92
  let cExpression;
93
- if (isUIPlaneElement(this._private_a)) {
93
+ if (isUIPlaneElement(this.a)) {
94
94
  aExpression = new UIExpression(0, [
95
- [this._private_a.yVariable, 1],
96
- [this._private_a.hVariable, this._private_anchorAInternal],
95
+ [this.a.yVariable, 1],
96
+ [this.a.hVariable, this._private_anchorAInternal],
97
97
  ]);
98
98
  }
99
- else if (isUIPointElement(this._private_a)) {
100
- aExpression = new UIExpression().plus(this._private_a.yVariable, 1);
99
+ else if (isUIPointElement(this.a)) {
100
+ aExpression = new UIExpression().plus(this.a.yVariable, 1);
101
101
  }
102
102
  else {
103
103
  throw new Error("UIVerticalInterpolationConstraint.buildLHS.a: invalid element type");
104
104
  }
105
- if (isUIPlaneElement(this._private_b)) {
105
+ if (isUIPlaneElement(this.b)) {
106
106
  bExpression = new UIExpression(0, [
107
- [this._private_b.yVariable, 1],
108
- [this._private_b.hVariable, this._private_anchorBInternal],
107
+ [this.b.yVariable, 1],
108
+ [this.b.hVariable, this._private_anchorBInternal],
109
109
  ]);
110
110
  }
111
- else if (isUIPointElement(this._private_b)) {
112
- bExpression = new UIExpression().plus(this._private_b.yVariable, 1);
111
+ else if (isUIPointElement(this.b)) {
112
+ bExpression = new UIExpression().plus(this.b.yVariable, 1);
113
113
  }
114
114
  else {
115
115
  throw new Error("UIVerticalInterpolationConstraint.buildLHS.b: invalid element type");
116
116
  }
117
- if (isUIPlaneElement(this._private_c)) {
117
+ if (isUIPlaneElement(this.c)) {
118
118
  cExpression = new UIExpression(0, [
119
- [this._private_c.yVariable, 1],
120
- [this._private_c.hVariable, this._private_anchorCInternal],
119
+ [this.c.yVariable, 1],
120
+ [this.c.hVariable, this._private_anchorCInternal],
121
121
  ]);
122
122
  }
123
- else if (isUIPointElement(this._private_c)) {
124
- cExpression = new UIExpression().plus(this._private_c.yVariable, 1);
123
+ else if (isUIPointElement(this.c)) {
124
+ cExpression = new UIExpression().plus(this.c.yVariable, 1);
125
125
  }
126
126
  else {
127
127
  throw new Error("UIVerticalInterpolationConstraint.buildLHS.c: invalid element type");
@@ -3,8 +3,8 @@ import { UISingleParameterConstraint } from "../UISingleParameterConstraint/UISi
3
3
  import type { UIVerticalProportionConstraintOptions } from "./UIVerticalProportionConstraint.Internal";
4
4
  /** Maintains proportional height relationship (A.height * proportion = B.height) */
5
5
  export declare class UIVerticalProportionConstraint extends UISingleParameterConstraint {
6
- private readonly a;
7
- private readonly b;
6
+ readonly a: UIPlaneElement;
7
+ readonly b: UIPlaneElement;
8
8
  protected readonly constraint: number;
9
9
  private proportionInternal;
10
10
  /**
@@ -9,13 +9,13 @@ class UIVerticalProportionConstraint extends UISingleParameterConstraint {
9
9
  * @param b Second element
10
10
  * @param options Proportion configuration
11
11
  */
12
- constructor(_private_a, _private_b, options = {}) {
12
+ constructor(a, b, options = {}) {
13
13
  if (options.proportion !== undefined) {
14
14
  assertValidPositiveNumber(options.proportion, "UIVerticalProportionConstraint.constructor.options.proportion");
15
15
  }
16
- super(assertValidConstraintArguments(_private_a, _private_b, "UIVerticalProportionConstraint.constructor"), options);
17
- this._private_a = _private_a;
18
- this._private_b = _private_b;
16
+ super(assertValidConstraintArguments(a, b, "UIVerticalProportionConstraint.constructor"), options);
17
+ this.a = a;
18
+ this.b = b;
19
19
  this._private_proportionInternal = options.proportion ?? 1;
20
20
  this.constraint = this.solverWrapper.createConstraint(new UIExpression(0), this._private_buildRHS(), this.relation, this.priority, this.isConstraintEnabled());
21
21
  }
@@ -33,7 +33,7 @@ class UIVerticalProportionConstraint extends UISingleParameterConstraint {
33
33
  }
34
34
  /** Builds constraint expression for proportional relationship */
35
35
  _private_buildRHS() {
36
- return UIExpression.minus(new UIExpression(0, [[this._private_a.hVariable, this._private_proportionInternal]]), new UIExpression(0, [[this._private_b.hVariable, 1]]));
36
+ return UIExpression.minus(new UIExpression(0, [[this.a.hVariable, this._private_proportionInternal]]), new UIExpression(0, [[this.b.hVariable, 1]]));
37
37
  }
38
38
  }
39
39
 
@@ -3,7 +3,7 @@ import { UISingleParameterConstraint } from "../UISingleParameterConstraint/UISi
3
3
  import type { UIWidthConstraintOptions } from "./UIWidthConstraint.Internal";
4
4
  /** Fixes element width to constant value */
5
5
  export declare class UIWidthConstraint extends UISingleParameterConstraint {
6
- private readonly element;
6
+ readonly element: UIPlaneElement & UILayerElement;
7
7
  /** Solver constraint descriptor */
8
8
  protected readonly constraint: number;
9
9
  /** Current width value */
@@ -8,14 +8,14 @@ class UIWidthConstraint extends UISingleParameterConstraint {
8
8
  * @param element Element to constrain
9
9
  * @param options Width configuration. Defaults to element's current width.
10
10
  */
11
- constructor(_private_element, options = {}) {
11
+ constructor(element, options = {}) {
12
12
  if (options.width !== undefined) {
13
13
  assertValidPositiveNumber(options.width, "UIWidthConstraint.constructor.options.width");
14
14
  }
15
- super(_private_element.layer, options);
16
- this._private_element = _private_element;
17
- this._private_widthInternal = options.width ?? _private_element.width;
18
- this.constraint = this.solverWrapper.createConstraint(new UIExpression(0, [[this._private_element.wVariable, 1]]), new UIExpression(this._private_widthInternal), this.relation, this.priority, this.isConstraintEnabled());
15
+ super(element.layer, options);
16
+ this.element = element;
17
+ this._private_widthInternal = options.width ?? element.width;
18
+ this.constraint = this.solverWrapper.createConstraint(new UIExpression(0, [[this.element.wVariable, 1]]), new UIExpression(this._private_widthInternal), this.relation, this.priority, this.isConstraintEnabled());
19
19
  }
20
20
  /** Current width in world units */
21
21
  get width() {
@@ -1,6 +1,7 @@
1
1
  import type { FerrsignView2, FerrsignView3 } from "ferrsign";
2
2
  import type { WebGLRenderer } from "three";
3
3
  import type { UIPlaneElement } from "../../miscellaneous/shared";
4
+ import type { UIConstraint } from "../../constraints/UIConstraint";
4
5
  import { UIInputWrapper } from "../../wrappers/UIInputWrapper/UIInputWrapper";
5
6
  import type { UILayerMode, UILayerOptions, UILayerOrientation } from "./UILayer.Internal";
6
7
  /** Base layer for UI rendering and layout management */
@@ -24,6 +25,9 @@ export declare abstract class UILayer implements UIPlaneElement {
24
25
  private readonly signalModeChangedInternal;
25
26
  private readonly signalRenderingInternal;
26
27
  private readonly signalResizedInternal;
28
+ private readonly signalConstraintAddedInternal;
29
+ private readonly signalConstraintRemovedInternal;
30
+ private readonly constraintRegistryInternal;
27
31
  constructor(options: Partial<UILayerOptions>);
28
32
  /** X coordinate in world units (always 0 for layers) */
29
33
  get x(): number;
@@ -33,6 +37,14 @@ export declare abstract class UILayer implements UIPlaneElement {
33
37
  get width(): number;
34
38
  /** Layer height in world units */
35
39
  get height(): number;
40
+ /** X coordinate of right edge */
41
+ get oppositeX(): number;
42
+ /** Y coordinate of top edge */
43
+ get oppositeY(): number;
44
+ /** X coordinate of horizontal center */
45
+ get centerX(): number;
46
+ /** Y coordinate of vertical center */
47
+ get centerY(): number;
36
48
  /** Current visibility and interactivity mode */
37
49
  get mode(): UILayerMode;
38
50
  /** Current orientation based on aspect ratio */
@@ -45,6 +57,12 @@ export declare abstract class UILayer implements UIPlaneElement {
45
57
  get signalRendering(): FerrsignView3<WebGLRenderer, number, UILayer>;
46
58
  /** Signal fired when layer resized */
47
59
  get signalResized(): FerrsignView3<number, number, UILayer>;
60
+ /** Signal fired when a constraint is added */
61
+ get signalConstraintAdded(): FerrsignView2<UILayer, UIConstraint>;
62
+ /** Signal fired when a constraint is removed */
63
+ get signalConstraintRemoved(): FerrsignView2<UILayer, UIConstraint>;
64
+ /** Constraint registry */
65
+ get constraintRegistry(): readonly UIConstraint[];
48
66
  /** Updates visibility and interactivity mode */
49
67
  set mode(value: UILayerMode);
50
68
  protected resizeInternal(width: number, height: number): void;