laymur 0.10.3 → 0.11.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 (131) hide show
  1. package/README.md +20 -11
  2. package/dist/constraints/UIAspectConstraint.Internal.d.ts +6 -0
  3. package/dist/constraints/UIAspectConstraint.d.ts +9 -46
  4. package/dist/constraints/UIConstraint.d.ts +7 -27
  5. package/dist/constraints/UICustomConstraint.d.ts +13 -45
  6. package/dist/constraints/UIHeightConstraint.Internal.d.ts +6 -0
  7. package/dist/constraints/UIHeightConstraint.d.ts +8 -37
  8. package/dist/constraints/UIHorizontalDistanceConstraint.Internal.d.ts +11 -0
  9. package/dist/constraints/UIHorizontalDistanceConstraint.d.ts +16 -73
  10. package/dist/constraints/UIHorizontalProportionConstraint.Internal.d.ts +6 -0
  11. package/dist/constraints/UIHorizontalProportionConstraint.d.ts +8 -52
  12. package/dist/constraints/UISingleParameterConstraint.Internal.d.ts +12 -0
  13. package/dist/constraints/UISingleParameterConstraint.d.ts +24 -87
  14. package/dist/constraints/UIVerticalDistanceConstraint.Internal.d.ts +11 -0
  15. package/dist/constraints/UIVerticalDistanceConstraint.d.ts +12 -73
  16. package/dist/constraints/UIVerticalProportionConstraint.Internal.d.ts +6 -0
  17. package/dist/constraints/UIVerticalProportionConstraint.d.ts +8 -52
  18. package/dist/constraints/UIWidthConstraint.Internal.d.ts +6 -0
  19. package/dist/constraints/UIWidthConstraint.d.ts +8 -37
  20. package/dist/constraints/builders/UIConstraint2DBuilder.Internal.d.ts +45 -0
  21. package/dist/constraints/builders/UIConstraint2DBuilder.d.ts +35 -0
  22. package/dist/constraints/builders/UICoverConstraintBuilder.Internal.d.ts +13 -0
  23. package/dist/constraints/builders/UICoverConstraintBuilder.d.ts +29 -0
  24. package/dist/constraints/builders/UIFitConstraintBuilder.Internal.d.ts +13 -0
  25. package/dist/constraints/builders/UIFitConstraintBuilder.d.ts +29 -0
  26. package/dist/elements/UIAnchor.Internal.d.ts +9 -0
  27. package/dist/elements/UIAnchor.d.ts +17 -62
  28. package/dist/elements/UIAnimatedImage.Internal.d.ts +24 -0
  29. package/dist/elements/UIAnimatedImage.d.ts +38 -100
  30. package/dist/elements/UIDummy.Internal.d.ts +18 -0
  31. package/dist/elements/UIDummy.d.ts +51 -63
  32. package/dist/elements/UIElement.Internal.d.ts +11 -0
  33. package/dist/elements/UIElement.d.ts +28 -168
  34. package/dist/elements/UIGraphics.Internal.d.ts +7 -0
  35. package/dist/elements/UIGraphics.d.ts +29 -99
  36. package/dist/elements/UIImage.Internal.d.ts +7 -0
  37. package/dist/elements/UIImage.d.ts +18 -73
  38. package/dist/elements/UINineSlice.Internal.d.ts +23 -0
  39. package/dist/elements/UINineSlice.d.ts +45 -0
  40. package/dist/elements/UIProgress.Internal.d.ts +14 -0
  41. package/dist/elements/UIProgress.d.ts +26 -152
  42. package/dist/elements/UIScene.Internal.d.ts +43 -0
  43. package/dist/elements/UIScene.d.ts +29 -171
  44. package/dist/elements/UIText/UIText.Interfaces.d.ts +32 -0
  45. package/dist/elements/UIText/UIText.Internal.d.ts +26 -0
  46. package/dist/elements/UIText/UIText.Measuring.d.ts +49 -0
  47. package/dist/elements/UIText/UIText.Rendering.d.ts +19 -0
  48. package/dist/elements/UIText/UIText.d.ts +63 -0
  49. package/dist/index.d.ts +46 -46
  50. package/dist/index.js +4176 -4002
  51. package/dist/index.js.map +1 -1
  52. package/dist/index.min.js +1 -1
  53. package/dist/index.min.js.map +1 -1
  54. package/dist/layers/UIFullscreenLayer.d.ts +33 -43
  55. package/dist/layers/UILayer.Internal.d.ts +15 -0
  56. package/dist/layers/UILayer.d.ts +29 -184
  57. package/dist/miscellaneous/UIExpression.d.ts +35 -83
  58. package/dist/miscellaneous/UIInputEvent.d.ts +11 -8
  59. package/dist/miscellaneous/UIMode.d.ts +19 -21
  60. package/dist/miscellaneous/UIOrientation.d.ts +7 -22
  61. package/dist/miscellaneous/UIPriority.d.ts +16 -40
  62. package/dist/miscellaneous/UIRelation.d.ts +11 -31
  63. package/dist/miscellaneous/UITransparencyMode.d.ts +4 -21
  64. package/dist/miscellaneous/area/UIArea.d.ts +3 -0
  65. package/dist/miscellaneous/area/UIAreaCircle.d.ts +15 -0
  66. package/dist/miscellaneous/area/UIAreaPolygon.d.ts +12 -0
  67. package/dist/miscellaneous/area/UIAreaRectangle.d.ts +17 -0
  68. package/dist/miscellaneous/area/UIAreaRoundedRectangle.d.ts +21 -0
  69. package/dist/miscellaneous/asserts.d.ts +39 -82
  70. package/dist/miscellaneous/color/UIColor.Internal.d.ts +7 -0
  71. package/dist/miscellaneous/color/UIColor.d.ts +197 -0
  72. package/dist/miscellaneous/computeTransform.d.ts +18 -0
  73. package/dist/miscellaneous/generic-plane/UIGenericInstancedPlane.Internal.d.ts +10 -0
  74. package/dist/miscellaneous/generic-plane/UIGenericInstancedPlane.d.ts +36 -0
  75. package/dist/miscellaneous/generic-plane/UIGenericPlane.Internal.d.ts +5 -0
  76. package/dist/miscellaneous/generic-plane/UIGenericPlane.d.ts +23 -0
  77. package/dist/miscellaneous/generic-plane/UIGenericPlaneRegistry.Internal.d.ts +6 -0
  78. package/dist/miscellaneous/generic-plane/UIGenericPlaneRegistry.d.ts +27 -0
  79. package/dist/miscellaneous/generic-plane/shared.d.ts +22 -0
  80. package/dist/miscellaneous/mask-function/UIProgressMaskFunction.d.ts +9 -0
  81. package/dist/miscellaneous/mask-function/UIProgressMaskFunctionCircular.d.ts +21 -0
  82. package/dist/miscellaneous/mask-function/UIProgressMaskFunctionDirectional.d.ts +16 -0
  83. package/dist/miscellaneous/micro/UIMicro.Internal.d.ts +31 -0
  84. package/dist/miscellaneous/micro/UIMicro.d.ts +59 -0
  85. package/dist/miscellaneous/padding/UIPadding.Internal.d.ts +11 -0
  86. package/dist/miscellaneous/padding/UIPadding.d.ts +46 -0
  87. package/dist/miscellaneous/resize-policy/UIResizePolicy.d.ts +3 -0
  88. package/dist/miscellaneous/resize-policy/UIResizePolicyCross.d.ts +22 -0
  89. package/dist/miscellaneous/resize-policy/UIResizePolicyCrossInverted.d.ts +22 -0
  90. package/dist/miscellaneous/resize-policy/UIResizePolicyFixedHeight.d.ts +22 -0
  91. package/dist/miscellaneous/resize-policy/UIResizePolicyFixedWidth.d.ts +22 -0
  92. package/dist/miscellaneous/resize-policy/UIResizePolicyNone.d.ts +5 -0
  93. package/dist/miscellaneous/text-span/UITextSpan.Internal.d.ts +8 -0
  94. package/dist/miscellaneous/text-span/UITextSpan.d.ts +14 -0
  95. package/dist/miscellaneous/text-style/UITextStyle.Internal.d.ts +48 -0
  96. package/dist/miscellaneous/text-style/UITextStyle.d.ts +85 -0
  97. package/dist/miscellaneous/texture/UITextureView.Internal.d.ts +54 -0
  98. package/dist/miscellaneous/texture/UITextureView.d.ts +61 -0
  99. package/dist/wrappers/UIInputWrapper.Internal.d.ts +17 -0
  100. package/dist/wrappers/UIInputWrapper.d.ts +13 -0
  101. package/dist/wrappers/UISceneWrapper.Internal.d.ts +13 -0
  102. package/dist/wrappers/UISceneWrapper.d.ts +12 -19
  103. package/dist/wrappers/UISolverWrapper.Internal.d.ts +49 -0
  104. package/dist/wrappers/UISolverWrapper.d.ts +2 -1
  105. package/package.json +3 -1
  106. package/dist/builders/UIConstraint2DBuilder.d.ts +0 -130
  107. package/dist/builders/UICoverConstraintBuilder.d.ts +0 -56
  108. package/dist/builders/UIFitConstraintBuilder.d.ts +0 -56
  109. package/dist/composer/UIComposer.d.ts +0 -0
  110. package/dist/composer/UIFullscreenQuad.d.ts +0 -0
  111. package/dist/composer/UIPass.d.ts +0 -0
  112. package/dist/elements/UINineSline.d.ts +0 -139
  113. package/dist/elements/UISpine.d.ts +0 -54
  114. package/dist/elements/UIText.d.ts +0 -149
  115. package/dist/miscellaneous/UIColor.d.ts +0 -245
  116. package/dist/miscellaneous/UIGenericInstancedPlane.d.ts +0 -32
  117. package/dist/miscellaneous/UIMicro.d.ts +0 -148
  118. package/dist/miscellaneous/UIMicroAnchorMode.d.ts +0 -9
  119. package/dist/miscellaneous/UINineSliceBorder.d.ts +0 -21
  120. package/dist/miscellaneous/UIResizePolicy.d.ts +0 -21
  121. package/dist/miscellaneous/UIResizePolicyCross.d.ts +0 -14
  122. package/dist/miscellaneous/UIResizePolicyCrossInverted.d.ts +0 -14
  123. package/dist/miscellaneous/UIResizePolicyFixedHeight.d.ts +0 -24
  124. package/dist/miscellaneous/UIResizePolicyFixedWidth.d.ts +0 -27
  125. package/dist/miscellaneous/UIResizePolicyNone.d.ts +0 -7
  126. package/dist/miscellaneous/UISceneWrapperClientAPI.d.ts +0 -12
  127. package/dist/miscellaneous/UITextPadding.d.ts +0 -7
  128. package/dist/miscellaneous/UITextSpan.d.ts +0 -6
  129. package/dist/miscellaneous/UITextStyle.d.ts +0 -20
  130. package/dist/miscellaneous/textInterfaces.d.ts +0 -19
  131. package/dist/miscellaneous/textTools.d.ts +0 -12
@@ -0,0 +1,61 @@
1
+ import { Eventail } from "eventail";
2
+ import { Matrix3, Texture, Vector2 } from "three";
3
+ import type { UITextureConfig, UITextureTrim } from "./UITextureView.Internal";
4
+ /** Wrapper for Three.js texture with atlas and trim support. Does not own the underlying texture; user must dispose it. */
5
+ export declare class UITextureView extends Eventail {
6
+ private textureInternal;
7
+ private rotatedInternal;
8
+ private frameX;
9
+ private frameY;
10
+ private frameWidth;
11
+ private frameHeight;
12
+ private sourceWidth;
13
+ private sourceHeight;
14
+ private trimLeft;
15
+ private trimRight;
16
+ private trimTop;
17
+ private trimBottom;
18
+ private scaleInternal;
19
+ private dirtyInternal;
20
+ /** @param config Texture or atlas configuration */
21
+ constructor(config?: UITextureConfig);
22
+ /** Original width before trimming in world units */
23
+ get width(): number;
24
+ /** Original height before trimming in world units */
25
+ get height(): number;
26
+ /** Visible width after trimming in world units */
27
+ get trimmedWidth(): number;
28
+ /** Visible height after trimming in world units */
29
+ get trimmedHeight(): number;
30
+ /** Underlying Three.js texture */
31
+ get texture(): Texture;
32
+ /** Whether sprite is rotated in atlas */
33
+ get rotated(): boolean;
34
+ /** Scale factor for resolution independence */
35
+ get scale(): number;
36
+ /** Transparent padding around visible content */
37
+ get trim(): Readonly<UITextureTrim>;
38
+ /** Whether texture has been modified since last check */
39
+ get dirty(): boolean;
40
+ /**
41
+ * Calculates UV transform matrix for shader sampling.
42
+ * @param result Matrix to store result in
43
+ * @returns UV transform matrix
44
+ */
45
+ calculateUVTransform(result?: Matrix3): Matrix3;
46
+ /**
47
+ * Gets original dimensions before trimming.
48
+ * @param result Vector to store result in
49
+ * @returns Width and height in world units
50
+ */
51
+ getResolution(result?: Vector2): Vector2;
52
+ /**
53
+ * Replaces texture with new configuration.
54
+ * @param config Texture or atlas configuration
55
+ */
56
+ set(config: UITextureConfig): void;
57
+ /** Resets to default empty texture */
58
+ reset(): void;
59
+ private setFromTexture;
60
+ private setFromAtlasConfig;
61
+ }
@@ -0,0 +1,17 @@
1
+ export interface UIInputWrapperInterface {
2
+ get dirty(): boolean;
3
+ createInputCatcher(catchPointerDown: (x: number, y: number, identifier: number) => boolean, catchPointerMove: (x: number, y: number, identifier: number) => boolean, catchPointerUp: (x: number, y: number, identifier: number) => boolean, zIndex: number): number;
4
+ destroyInputCatcher(handler: number): void;
5
+ getZIndex(handler: number): number;
6
+ setZIndex(handler: number, zIndex: number): void;
7
+ getActive(handler: number): boolean;
8
+ setActive(handler: number, active: boolean): void;
9
+ }
10
+ export interface UIInputWrapperCatcher {
11
+ handler: number;
12
+ catchPointerDown: (x: number, y: number, identifier: number) => boolean;
13
+ catchPointerMove: (x: number, y: number, identifier: number) => boolean;
14
+ catchPointerUp: (x: number, y: number, identifier: number) => boolean;
15
+ zIndex: number;
16
+ active: boolean;
17
+ }
@@ -0,0 +1,13 @@
1
+ import type { UIInputWrapperInterface } from "./UIInputWrapper.Internal";
2
+ export declare class UIInputWrapper implements UIInputWrapperInterface {
3
+ private zIndicesDirty;
4
+ private readonly catchers;
5
+ private lastHandler;
6
+ createInputCatcher(catchPointerDown: (x: number, y: number, identifier: number) => boolean, catchPointerMove: (x: number, y: number, identifier: number) => boolean, catchPointerUp: (x: number, y: number, identifier: number) => boolean, zIndex: number): number;
7
+ destroyInputCatcher(handler: number): void;
8
+ getZIndex(handler: number): number;
9
+ setZIndex(handler: number, zIndex: number): void;
10
+ getActive(handler: number): boolean;
11
+ setActive(handler: number, active: boolean): void;
12
+ private ensureSorted;
13
+ }
@@ -0,0 +1,13 @@
1
+ import type { Matrix4, Object3D } from "three";
2
+ import type { UITransparencyMode } from "../miscellaneous/UITransparencyMode";
3
+ import type { UIPropertyType } from "../miscellaneous/generic-plane/shared";
4
+ export interface UISceneWrapperInterface {
5
+ createPlane(source: string, properties: Record<string, UIPropertyType>, transparency: UITransparencyMode): number;
6
+ destroyPlane(handler: number): void;
7
+ setTransform(handler: number, transform: Matrix4): void;
8
+ setProperties(handler: number, properties: Record<string, UIPropertyType>): void;
9
+ setVisibility(handler: number, visible: boolean): void;
10
+ setTransparency(handler: number, transparency: UITransparencyMode): void;
11
+ insertCustomObject(object: Object3D): void;
12
+ removeCustomObject(object: Object3D): void;
13
+ }
@@ -1,26 +1,19 @@
1
- import type { Object3D, WebGLRenderer } from "three";
2
- import { Color, Matrix2, Matrix3, Matrix4, PlaneGeometry, Texture, Vector2, Vector3, Vector4 } from "three";
3
- import { UIColor } from "../miscellaneous/UIColor";
4
- import type { UISceneWrapperClientAPI } from "../miscellaneous/UISceneWrapperClientAPI";
5
- import { UITransparencyMode } from "../miscellaneous/UITransparencyMode";
6
- type UIPropertyType = UIColor | Color | Texture | Vector2 | Vector3 | Vector4 | Matrix2 | Matrix3 | Matrix4;
7
- export declare const geometry: PlaneGeometry;
8
- export declare class UISceneWrapper implements UISceneWrapperClientAPI {
1
+ import type { Matrix4, Object3D, WebGLRenderer } from "three";
2
+ import type { UIPropertyType } from "../miscellaneous/generic-plane/shared";
3
+ import type { UITransparencyMode } from "../miscellaneous/UITransparencyMode";
4
+ export declare class UISceneWrapper {
9
5
  private readonly scene;
10
6
  private readonly camera;
11
- private readonly descriptors;
12
- private lastPlaneIndex;
13
- constructor(w: number, h: number);
14
- createPlane(source: string, uniforms: Record<string, UIPropertyType>): number;
15
- destroyPlane(handler: number): this;
16
- setTransform(handler: number, value: Matrix4): this;
17
- setUniform(handler: number, uniform: string, value: UIPropertyType): this;
18
- setTransparency(handler: number, mode: UITransparencyMode): this;
19
- setVisibility(handler: number, visible: boolean): this;
7
+ private readonly registry;
8
+ constructor(width: number, height: number);
9
+ createPlane(source: string, properties: Record<string, UIPropertyType>, transparency: UITransparencyMode): number;
10
+ destroyPlane(handler: number): void;
11
+ setTransform(handler: number, transform: Matrix4): void;
12
+ setProperties(handler: number, properties: Record<string, UIPropertyType>): void;
13
+ setVisibility(handler: number, visible: boolean): void;
14
+ setTransparency(handler: number, transparency: UITransparencyMode): void;
20
15
  insertCustomObject(object: Object3D): this;
21
16
  removeCustomObject(object: Object3D): this;
22
17
  resize(width: number, height: number): this;
23
18
  render(renderer: WebGLRenderer): this;
24
- private resolveDescriptor;
25
19
  }
26
- export {};
@@ -0,0 +1,49 @@
1
+ import type { Constraint, Variable } from "@lume/kiwi";
2
+ import type { UIExpression } from "../miscellaneous/UIExpression";
3
+ import type { UIPriority } from "../miscellaneous/UIPriority";
4
+ import type { UIRelation } from "../miscellaneous/UIRelation";
5
+ export interface UISolverWrapperInterface {
6
+ get dirty(): boolean;
7
+ createVariable(value: number, priority: UIPriority): number;
8
+ removeVariable(index: number): void;
9
+ suggestVariableValue(index: number, value: number): void;
10
+ setVariablePriority(index: number, priority: UIPriority): void;
11
+ readVariableValue(index: number): number;
12
+ createConstraint(lhs: UIExpression, rhs: UIExpression, relation: UIRelation, priority: UIPriority, enabled: boolean): number;
13
+ removeConstraint(index: number): void;
14
+ setConstraintLHS(index: number, lhs: UIExpression): void;
15
+ setConstraintRHS(index: number, rhs: UIExpression): void;
16
+ setConstraintRelation(index: number, relation: UIRelation): void;
17
+ setConstraintPriority(index: number, priority: UIPriority): void;
18
+ setConstraintEnabled(index: number, enabled: boolean): void;
19
+ }
20
+ /**
21
+ * Internal description of a solver variable with its associated properties.
22
+ */
23
+ export interface VariableDescription {
24
+ /** The underlying Kiwi variable instance. */
25
+ variable: Variable;
26
+ /** Priority level for constraint solving. */
27
+ priority: UIPriority;
28
+ /** Current suggested value for the variable. */
29
+ value: number;
30
+ /** Optional constraint for P0 priority variables (required variables). */
31
+ constraint?: Constraint;
32
+ }
33
+ /**
34
+ * Internal description of a solver constraint with its configuration.
35
+ */
36
+ export interface ConstraintDescription {
37
+ /** The underlying Kiwi constraint instance. */
38
+ constraint: Constraint;
39
+ /** Left-hand side expression of the constraint. */
40
+ lhs: UIExpression;
41
+ /** Right-hand side expression of the constraint. */
42
+ rhs: UIExpression;
43
+ /** Priority level for constraint solving. */
44
+ priority: UIPriority;
45
+ /** Relational operator (equal, less than, greater than). */
46
+ relation: UIRelation;
47
+ /** Whether the constraint is currently active. */
48
+ enabled: boolean;
49
+ }
@@ -1,6 +1,7 @@
1
1
  import { UIExpression } from "../miscellaneous/UIExpression";
2
2
  import { UIPriority } from "../miscellaneous/UIPriority";
3
3
  import { UIRelation } from "../miscellaneous/UIRelation";
4
+ import type { UISolverWrapperInterface } from "./UISolverWrapper.Internal";
4
5
  /**
5
6
  * Wrapper around the Kiwi constraint solver providing enhanced UI-specific functionality.
6
7
  *
@@ -21,7 +22,7 @@ import { UIRelation } from "../miscellaneous/UIRelation";
21
22
  * @see {@link UIPriority} - Priority levels for variables and constraints
22
23
  * @see {@link UIRelation} - Relational operators for constraints
23
24
  */
24
- export declare class UISolverWrapper {
25
+ export declare class UISolverWrapper implements UISolverWrapperInterface {
25
26
  /** The underlying Kiwi solver instance, undefined when solver needs rebuilding. */
26
27
  private solver?;
27
28
  /** Flag indicating whether variable values need recalculation. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "laymur",
3
- "version": "0.10.3",
3
+ "version": "0.11.0",
4
4
  "description": "Constraint-based UI library for Three.js mobile advertisements",
5
5
  "scripts": {
6
6
  "clean": "rm -rf dist",
@@ -48,7 +48,9 @@
48
48
  },
49
49
  "devDependencies": {
50
50
  "@rollup/plugin-node-resolve": "^16.0.1",
51
+ "@rollup/plugin-replace": "^6.0.3",
51
52
  "@rollup/plugin-terser": "^0.4.4",
53
+ "@types/node": "^25.0.2",
52
54
  "@types/three": "^0.175.0",
53
55
  "@typescript-eslint/eslint-plugin": "^8.32.0",
54
56
  "@typescript-eslint/parser": "^8.32.0",
@@ -1,130 +0,0 @@
1
- import { UIHeightConstraint } from "../constraints/UIHeightConstraint";
2
- import { UIHorizontalDistanceConstraint } from "../constraints/UIHorizontalDistanceConstraint";
3
- import { UIHorizontalProportionConstraint } from "../constraints/UIHorizontalProportionConstraint";
4
- import { UIVerticalDistanceConstraint } from "../constraints/UIVerticalDistanceConstraint";
5
- import { UIVerticalProportionConstraint } from "../constraints/UIVerticalProportionConstraint";
6
- import { UIWidthConstraint } from "../constraints/UIWidthConstraint";
7
- import type { UIElement } from "../elements/UIElement";
8
- import type { UIPlaneElement, UIPointElement } from "../miscellaneous/asserts";
9
- import type { UIOrientation } from "../miscellaneous/UIOrientation";
10
- import type { UIPriority } from "../miscellaneous/UIPriority";
11
- import type { UIRelation } from "../miscellaneous/UIRelation";
12
- /**
13
- * Generic 2D type for specifying horizontal and vertical values.
14
- *
15
- * This interface allows configuration of properties that can have
16
- * different values for horizontal and vertical directions.
17
- *
18
- * @template T - The type of values for horizontal and vertical properties
19
- */
20
- interface UIType2D<T> {
21
- /** Horizontal (x-axis) value. */
22
- h?: T;
23
- /** Vertical (y-axis) value. */
24
- v?: T;
25
- }
26
- /**
27
- * Base options for 2D constraint configuration.
28
- */
29
- interface UIConstraint2DOptions {
30
- /** Priority levels for horizontal and vertical constraints. */
31
- priority: UIType2D<UIPriority>;
32
- /** Mathematical relations for horizontal and vertical constraints. */
33
- relation: UIType2D<UIRelation>;
34
- /** Orientation settings for horizontal and vertical constraints. */
35
- orientation: UIType2D<UIOrientation>;
36
- }
37
- /**
38
- * Configuration options for 2D size constraints.
39
- */
40
- export interface UIConstraintSize2DOptions extends UIConstraint2DOptions {
41
- /** Size values for horizontal (width) and vertical (height) dimensions. */
42
- size: UIType2D<number>;
43
- }
44
- /**
45
- * Configuration options for 2D distance constraints.
46
- */
47
- export interface UIConstraintDistance2DOptions extends UIConstraint2DOptions {
48
- /** Anchor points for element A in horizontal and vertical directions. */
49
- anchorA: UIType2D<number>;
50
- /** Anchor points for element B in horizontal and vertical directions. */
51
- anchorB: UIType2D<number>;
52
- /** Distance values for horizontal and vertical spacing. */
53
- distance: UIType2D<number>;
54
- }
55
- /**
56
- * Configuration options for 2D proportion constraints.
57
- */
58
- export interface UIConstraintProportion2DOptions extends UIConstraint2DOptions {
59
- /** Proportion ratios for horizontal and vertical relationships. */
60
- proportion: UIType2D<number>;
61
- }
62
- /**
63
- * Result object containing horizontal and vertical constraint instances.
64
- *
65
- * @template TH - The type of the horizontal constraint
66
- * @template TV - The type of the vertical constraint
67
- */
68
- export interface UIConstraint2DResult<TH, TV> {
69
- /** The horizontal constraint instance. */
70
- h: TH;
71
- /** The vertical constraint instance. */
72
- v: TV;
73
- }
74
- /**
75
- * Builder utility for creating paired horizontal and vertical constraints.
76
- *
77
- * UIConstraint2DBuilder simplifies the creation of constraint pairs that work
78
- * together to define 2D relationships between UI elements. Instead of manually
79
- * creating separate horizontal and vertical constraints, this builder allows
80
- * you to specify both dimensions at once with a unified interface.
81
- *
82
- * This is particularly useful for creating consistent spacing, sizing, and
83
- * proportional relationships across both axes simultaneously.
84
- *
85
- * @see {@link UIWidthConstraint} - Horizontal size constraints
86
- * @see {@link UIHeightConstraint} - Vertical size constraints
87
- * @see {@link UIHorizontalDistanceConstraint} - Horizontal spacing constraints
88
- * @see {@link UIVerticalDistanceConstraint} - Vertical spacing constraints
89
- */
90
- export declare class UIConstraint2DBuilder {
91
- /**
92
- * Creates paired width and height constraints for an element.
93
- *
94
- * This method generates both horizontal (width) and vertical (height)
95
- * size constraints simultaneously, allowing you to set fixed dimensions
96
- * for both axes with a single call.
97
- *
98
- * @param element - The UI element to apply size constraints to
99
- * @param options - Configuration options for both width and height constraints
100
- * @returns Object containing the created width and height constraint instances
101
- */
102
- static size(element: UIElement, options?: Partial<UIConstraintSize2DOptions>): UIConstraint2DResult<UIWidthConstraint, UIHeightConstraint>;
103
- /**
104
- * Creates paired horizontal and vertical distance constraints between two elements.
105
- *
106
- * This method generates both horizontal and vertical spacing constraints
107
- * simultaneously, allowing you to define 2D spacing relationships with
108
- * configurable anchor points for both axes.
109
- *
110
- * @param a - The first UI element (point or plane element)
111
- * @param b - The second UI element (point or plane element)
112
- * @param options - Configuration options for both horizontal and vertical distance constraints
113
- * @returns Object containing the created horizontal and vertical distance constraint instances
114
- */
115
- static distance(a: UIPointElement | UIPlaneElement, b: UIPointElement | UIPlaneElement, options?: Partial<UIConstraintDistance2DOptions>): UIConstraint2DResult<UIHorizontalDistanceConstraint, UIVerticalDistanceConstraint>;
116
- /**
117
- * Creates paired horizontal and vertical proportion constraints between two elements.
118
- *
119
- * This method generates both horizontal (width) and vertical (height)
120
- * proportion constraints simultaneously, allowing you to define proportional
121
- * relationships for both dimensions with a single call.
122
- *
123
- * @param a - The first UI plane element (whose dimensions will be multiplied by proportion)
124
- * @param b - The second UI plane element (target dimensions for the proportion)
125
- * @param options - Configuration options for both horizontal and vertical proportion constraints
126
- * @returns Object containing the created horizontal and vertical proportion constraint instances
127
- */
128
- static proportion(a: UIPlaneElement, b: UIPlaneElement, options?: Partial<UIConstraintProportion2DOptions>): UIConstraint2DResult<UIHorizontalProportionConstraint, UIVerticalProportionConstraint>;
129
- }
130
- export {};
@@ -1,56 +0,0 @@
1
- import { UIAspectConstraint } from "../constraints/UIAspectConstraint";
2
- import { UIHorizontalDistanceConstraint } from "../constraints/UIHorizontalDistanceConstraint";
3
- import { UIHorizontalProportionConstraint } from "../constraints/UIHorizontalProportionConstraint";
4
- import { UIVerticalDistanceConstraint } from "../constraints/UIVerticalDistanceConstraint";
5
- import { UIVerticalProportionConstraint } from "../constraints/UIVerticalProportionConstraint";
6
- import type { UILayerElement, UIPlaneElement } from "../miscellaneous/asserts";
7
- import { type UIOrientation } from "../miscellaneous/UIOrientation";
8
- /**
9
- * Configuration options for the UICoverConstraintBuilder.
10
- */
11
- export interface UICoverConstraintBuilderOptions {
12
- /** Whether to maintain the aspect ratio of the active (content) element */
13
- keepActiveAspect: boolean;
14
- /** Horizontal anchor point (0.0 = left, 0.5 = center, 1.0 = right) */
15
- anchorH: number;
16
- /** Vertical anchor point (0.0 = top, 0.5 = center, 1.0 = bottom) */
17
- anchorV: number;
18
- /** Orientation context for constraint calculations */
19
- orientation: UIOrientation;
20
- }
21
- /**
22
- * Builder for creating "cover" layout constraints that make an element cover its container.
23
- *
24
- * Cover layout ensures the active element is large enough to completely cover the passive
25
- * element while maintaining proportions. This is similar to CSS `background-size: cover`
26
- * or `object-fit: cover` behavior.
27
- *
28
- * The active element will be:
29
- * - Positioned at the specified anchor point within the passive element
30
- * - Sized to be at least as large as the passive element in both dimensions
31
- * - Scaled proportionally to maintain aspect ratio (if enabled)
32
- *
33
- * The constraints ensure: passive.dimension * 1 ≤ active.dimension (active covers passive)
34
- */
35
- export declare class UICoverConstraintBuilder {
36
- /**
37
- * Creates a set of constraints for cover layout behavior.
38
- *
39
- * @param passive - The container element (what gets covered)
40
- * @param active - The content element (what does the covering)
41
- * @param options - Configuration options for the cover layout
42
- * @returns Object containing all created constraints
43
- */
44
- static build(passive: UIPlaneElement, active: UIPlaneElement & UILayerElement, options?: Partial<UICoverConstraintBuilderOptions>): {
45
- /** Aspect constraint for the active element (if keepActiveAspect is true) */
46
- activeAspectConstraint?: UIAspectConstraint;
47
- /** Horizontal positioning constraint */
48
- xConstraint: UIHorizontalDistanceConstraint;
49
- /** Vertical positioning constraint */
50
- yConstraint: UIVerticalDistanceConstraint;
51
- /** Width proportion constraint (ensures coverage) */
52
- widthConstraint: UIHorizontalProportionConstraint;
53
- /** Height proportion constraint (ensures coverage) */
54
- heightConstraint: UIVerticalProportionConstraint;
55
- };
56
- }
@@ -1,56 +0,0 @@
1
- import { UIAspectConstraint } from "../constraints/UIAspectConstraint";
2
- import { UIHorizontalDistanceConstraint } from "../constraints/UIHorizontalDistanceConstraint";
3
- import { UIHorizontalProportionConstraint } from "../constraints/UIHorizontalProportionConstraint";
4
- import { UIVerticalDistanceConstraint } from "../constraints/UIVerticalDistanceConstraint";
5
- import { UIVerticalProportionConstraint } from "../constraints/UIVerticalProportionConstraint";
6
- import type { UILayerElement, UIPlaneElement } from "../miscellaneous/asserts";
7
- import { type UIOrientation } from "../miscellaneous/UIOrientation";
8
- /**
9
- * Configuration options for the UIFitConstraintBuilder.
10
- */
11
- export interface UIFitConstraintBuilderOptions {
12
- /** Whether to maintain the aspect ratio of the active (content) element */
13
- keepActiveAspect: boolean;
14
- /** Horizontal anchor point (0.0 = left, 0.5 = center, 1.0 = right) */
15
- anchorH: number;
16
- /** Vertical anchor point (0.0 = top, 0.5 = center, 1.0 = bottom) */
17
- anchorV: number;
18
- /** Orientation context for constraint calculations */
19
- orientation: UIOrientation;
20
- }
21
- /**
22
- * Builder for creating "fit" layout constraints that make an element fit within its container.
23
- *
24
- * Fit layout ensures the active element is sized to completely fit within the passive
25
- * element while maintaining proportions. This is similar to CSS `background-size: contain`
26
- * or `object-fit: contain` behavior.
27
- *
28
- * The active element will be:
29
- * - Positioned at the specified anchor point within the passive element
30
- * - Sized to fit entirely within the passive element in both dimensions
31
- * - Scaled proportionally to maintain aspect ratio (if enabled)
32
- *
33
- * The constraints ensure: passive.dimension * 1 ≥ active.dimension (active fits within passive)
34
- */
35
- export declare class UIFitConstraintBuilder {
36
- /**
37
- * Creates a set of constraints for fit layout behavior.
38
- *
39
- * @param passive - The container element (what contains the content)
40
- * @param active - The content element (what gets fitted within the container)
41
- * @param options - Configuration options for the fit layout
42
- * @returns Object containing all created constraints
43
- */
44
- static build(passive: UIPlaneElement, active: UIPlaneElement & UILayerElement, options?: Partial<UIFitConstraintBuilderOptions>): {
45
- /** Aspect constraint for the active element (if keepActiveAspect is true) */
46
- activeAspectConstraint?: UIAspectConstraint;
47
- /** Horizontal positioning constraint */
48
- xConstraint: UIHorizontalDistanceConstraint;
49
- /** Vertical positioning constraint */
50
- yConstraint: UIVerticalDistanceConstraint;
51
- /** Width proportion constraint (ensures fitting) */
52
- widthConstraint: UIHorizontalProportionConstraint;
53
- /** Height proportion constraint (ensures fitting) */
54
- heightConstraint: UIVerticalProportionConstraint;
55
- };
56
- }
File without changes
File without changes
File without changes
@@ -1,139 +0,0 @@
1
- import type { Texture, WebGLRenderer } from "three";
2
- import { type UILayer } from "../layers/UILayer";
3
- import { UIColor } from "../miscellaneous/UIColor";
4
- import type { UIMode } from "../miscellaneous/UIMode";
5
- import { type UINineSliceBorders } from "../miscellaneous/UINineSliceBorder";
6
- import { UIElement } from "./UIElement";
7
- /**
8
- * Configuration options for creating a UINineSlice element.
9
- */
10
- export interface UINineSliceOptions {
11
- /** X position of the element */
12
- x: number;
13
- /** Y position of the element */
14
- y: number;
15
- /** Color tint applied to the nine-slice element */
16
- color: UIColor;
17
- /** Nine-slice border configuration (can be number, object with horizontal/vertical, or full border object) */
18
- sliceBorders: UINineSliceBorders;
19
- /** Default UIMode */
20
- mode: UIMode;
21
- }
22
- /**
23
- * Nine-slice UI element for scalable images with preserved border regions.
24
- *
25
- * Nine-slice scaling divides an image into 9 regions: 4 corners, 4 edges, and 1 center.
26
- * The corners maintain their original size, edges scale in one dimension, and the center
27
- * scales in both dimensions. This technique is commonly used for creating scalable UI
28
- * panels, buttons, and borders that maintain visual quality at any size.
29
- */
30
- export declare class UINineSlice extends UIElement {
31
- /** Internal storage for the current texture */
32
- private readonly textureInternal;
33
- /** Internal storage for the color tint */
34
- private readonly colorInternal;
35
- /** Internal storage for the nine-slice border values (left, right, top, bottom) */
36
- private readonly sliceBordersInternal;
37
- /** Internal storage for texture and world dimensions (texture width, texture height, world width, world height) */
38
- private readonly dimensions;
39
- /**
40
- * Creates a new nine-slice UI element.
41
- *
42
- * The element initially sizes itself to match the texture's dimensions.
43
- * Border regions are defined by the slice borders configuration.
44
- *
45
- * @param layer - The UI layer to add this element to
46
- * @param texture - The texture to use for nine-slice rendering
47
- * @param options - Configuration options for the nine-slice element
48
- * @throws Will throw an error if the texture dimensions are not valid positive numbers
49
- */
50
- constructor(layer: UILayer, texture: Texture, options?: Partial<UINineSliceOptions>);
51
- /**
52
- * Gets the current texture being displayed.
53
- * @returns The current Three.js texture
54
- */
55
- get texture(): Texture;
56
- /**
57
- * Gets the current color tint applied to the nine-slice element.
58
- * @returns The UIColor instance
59
- */
60
- get color(): UIColor;
61
- /**
62
- * Gets the left border size for nine-slice scaling.
63
- * @returns The left border size as a percentage (0-1) of texture width
64
- */
65
- get sliceBorderLeft(): number;
66
- /**
67
- * Gets the right border size for nine-slice scaling.
68
- * @returns The right border size as a percentage (0-1) of texture width
69
- */
70
- get sliceBorderRight(): number;
71
- /**
72
- * Gets the top border size for nine-slice scaling.
73
- * @returns The top border size as a percentage (0-1) of texture height
74
- */
75
- get sliceBorderTop(): number;
76
- /**
77
- * Gets the bottom border size for nine-slice scaling.
78
- * @returns The bottom border size as a percentage (0-1) of texture height
79
- */
80
- get sliceBorderBottom(): number;
81
- /**
82
- * Sets a new texture for the nine-slice element.
83
- *
84
- * When setting a new texture, the element will update its internal dimensions
85
- * but maintain the current world size. The nine-slice borders remain unchanged.
86
- *
87
- * @param value - The new Three.js texture to display
88
- * @throws Will throw an error if the texture dimensions are not valid positive numbers
89
- * @see {@link assertValidPositiveNumber}
90
- */
91
- set texture(value: Texture);
92
- /**
93
- * Sets the color tint applied to the nine-slice element.
94
- * @param value - The UIColor instance
95
- */
96
- set color(value: UIColor);
97
- /**
98
- * Sets the left border size for nine-slice scaling.
99
- * @param value - The left border size as a percentage (0-1) of texture width
100
- */
101
- set sliceBorderLeft(value: number);
102
- /**
103
- * Sets the right border size for nine-slice scaling.
104
- * @param value - The right border size as a percentage (0-1) of texture width
105
- */
106
- set sliceBorderRight(value: number);
107
- /**
108
- * Sets the top border size for nine-slice scaling.
109
- * @param value - The top border size as a percentage (0-1) of texture height
110
- */
111
- set sliceBorderTop(value: number);
112
- /**
113
- * Sets the bottom border size for nine-slice scaling.
114
- * @param value - The bottom border size as a percentage (0-1) of texture height
115
- */
116
- set sliceBorderBottom(value: number);
117
- /**
118
- * Sets all four border sizes for nine-slice scaling at once.
119
- *
120
- * @param left - The left border size as a percentage (0-1) of texture width
121
- * @param right - The right border size as a percentage (0-1) of texture width
122
- * @param top - The top border size as a percentage (0-1) of texture height
123
- * @param bottom - The bottom border size as a percentage (0-1) of texture height
124
- */
125
- setSliceBorders(left: number, right: number, top: number, bottom: number): void;
126
- /**
127
- * Destroys the nine-slice UI element by cleaning up color event listeners and all associated resources.
128
- */
129
- destroy(): void;
130
- /**
131
- * Called before each render frame to update the element's dimensions for nine-slice scaling.
132
- * Updates the world dimensions (z, w components) based on current width, height, and micro scaling.
133
- * @param renderer - The WebGL renderer
134
- * @param deltaTime - Time since last frame in seconds
135
- */
136
- protected onWillRender(renderer: WebGLRenderer, deltaTime: number): void;
137
- /** Event handler for when the color changes */
138
- private readonly onColorChange;
139
- }