laymur 0.2.10 → 0.2.11
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.
- package/dist/builders/UICoverConstraintBuilder.d.ts +54 -0
- package/dist/builders/UIFitConstraintBuilder.d.ts +54 -0
- package/dist/constraints/UIAspectConstraint.d.ts +3 -3
- package/dist/constraints/UIHeightConstraint.d.ts +3 -3
- package/dist/constraints/UIWidthConstraint.d.ts +3 -3
- package/dist/elements/UIElement.d.ts +25 -2
- package/dist/elements/UIScene.d.ts +11 -1
- package/dist/elements/UIText.d.ts +12 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +138 -18
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/layers/UILayer.d.ts +18 -0
- package/dist/miscellaneous/asserts.d.ts +8 -0
- package/package.json +1 -1
- package/dist/constraints/UICoverConstraint.d.ts +0 -0
- package/dist/constraints/UIFitConstraint.d.ts +0 -0
|
@@ -0,0 +1,54 @@
|
|
|
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 = bottom, 0.5 = center, 1.0 = top) */
|
|
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
|
+
export declare class UICoverConstraintBuilder {
|
|
34
|
+
/**
|
|
35
|
+
* Creates a set of constraints for cover layout behavior.
|
|
36
|
+
*
|
|
37
|
+
* @param passive - The container element (what gets covered)
|
|
38
|
+
* @param active - The content element (what does the covering)
|
|
39
|
+
* @param options - Configuration options for the cover layout
|
|
40
|
+
* @returns Object containing all created constraints
|
|
41
|
+
*/
|
|
42
|
+
static build(passive: UIPlaneElement, active: UIPlaneElement & UILayerElement, options?: Partial<UICoverConstraintBuilderOptions>): {
|
|
43
|
+
/** Aspect constraint for the active element (if keepActiveAspect is true) */
|
|
44
|
+
activeAspectConstraint?: UIAspectConstraint;
|
|
45
|
+
/** Horizontal positioning constraint */
|
|
46
|
+
xConstraint: UIHorizontalDistanceConstraint;
|
|
47
|
+
/** Vertical positioning constraint */
|
|
48
|
+
yConstraint: UIVerticalDistanceConstraint;
|
|
49
|
+
/** Width proportion constraint (ensures coverage) */
|
|
50
|
+
widthConstraint: UIHorizontalProportionConstraint;
|
|
51
|
+
/** Height proportion constraint (ensures coverage) */
|
|
52
|
+
heightConstraint: UIVerticalProportionConstraint;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
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 = bottom, 0.5 = center, 1.0 = top) */
|
|
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
|
+
export declare class UIFitConstraintBuilder {
|
|
34
|
+
/**
|
|
35
|
+
* Creates a set of constraints for fit layout behavior.
|
|
36
|
+
*
|
|
37
|
+
* @param passive - The container element (what contains the content)
|
|
38
|
+
* @param active - The content element (what gets fitted within the container)
|
|
39
|
+
* @param options - Configuration options for the fit layout
|
|
40
|
+
* @returns Object containing all created constraints
|
|
41
|
+
*/
|
|
42
|
+
static build(passive: UIPlaneElement, active: UIPlaneElement & UILayerElement, options?: Partial<UIFitConstraintBuilderOptions>): {
|
|
43
|
+
/** Aspect constraint for the active element (if keepActiveAspect is true) */
|
|
44
|
+
activeAspectConstraint?: UIAspectConstraint;
|
|
45
|
+
/** Horizontal positioning constraint */
|
|
46
|
+
xConstraint: UIHorizontalDistanceConstraint;
|
|
47
|
+
/** Vertical positioning constraint */
|
|
48
|
+
yConstraint: UIVerticalDistanceConstraint;
|
|
49
|
+
/** Width proportion constraint (ensures fitting) */
|
|
50
|
+
widthConstraint: UIHorizontalProportionConstraint;
|
|
51
|
+
/** Height proportion constraint (ensures fitting) */
|
|
52
|
+
heightConstraint: UIVerticalProportionConstraint;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { UILayerElement, UIPlaneElement } from "../miscellaneous/asserts";
|
|
2
2
|
import type { UISingleParameterConstraintOptions } from "./UISingleParameterConstraint";
|
|
3
3
|
import { UISingleParameterConstraint } from "./UISingleParameterConstraint";
|
|
4
4
|
/**
|
|
@@ -18,7 +18,7 @@ export interface UIAspectConstraintOptions extends UISingleParameterConstraintOp
|
|
|
18
18
|
* ratios like 16:9 for video content.
|
|
19
19
|
*
|
|
20
20
|
* @see {@link UISingleParameterConstraint} - Base class for single-parameter constraints
|
|
21
|
-
* @see {@link
|
|
21
|
+
* @see {@link UIPlaneElement} - Elements that can have aspect constraints applied
|
|
22
22
|
* @see {@link UIExpression} - Mathematical expressions for constraint equations
|
|
23
23
|
*/
|
|
24
24
|
export declare class UIAspectConstraint extends UISingleParameterConstraint {
|
|
@@ -36,7 +36,7 @@ export declare class UIAspectConstraint extends UISingleParameterConstraint {
|
|
|
36
36
|
* @param element - The UI element to apply the aspect constraint to
|
|
37
37
|
* @param options - Configuration options for the constraint
|
|
38
38
|
*/
|
|
39
|
-
constructor(element:
|
|
39
|
+
constructor(element: UIPlaneElement & UILayerElement, options?: Partial<UIAspectConstraintOptions>);
|
|
40
40
|
/**
|
|
41
41
|
* Gets the current aspect ratio being enforced.
|
|
42
42
|
* @returns The aspect ratio (width/height)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { UILayerElement, UIPlaneElement } from "../miscellaneous/asserts";
|
|
2
2
|
import type { UISingleParameterConstraintOptions } from "./UISingleParameterConstraint";
|
|
3
3
|
import { UISingleParameterConstraint } from "./UISingleParameterConstraint";
|
|
4
4
|
/**
|
|
@@ -17,7 +17,7 @@ export interface UIHeightConstraintOptions extends UISingleParameterConstraintOp
|
|
|
17
17
|
* other layout changes or for setting fixed dimensions in responsive layouts.
|
|
18
18
|
*
|
|
19
19
|
* @see {@link UISingleParameterConstraint} - Base class for single-parameter constraints
|
|
20
|
-
* @see {@link
|
|
20
|
+
* @see {@link UIPlaneElement} - Elements that can have height constraints applied
|
|
21
21
|
* @see {@link UIExpression} - Mathematical expressions for constraint equations
|
|
22
22
|
*/
|
|
23
23
|
export declare class UIHeightConstraint extends UISingleParameterConstraint {
|
|
@@ -35,7 +35,7 @@ export declare class UIHeightConstraint extends UISingleParameterConstraint {
|
|
|
35
35
|
* @param element - The UI element to apply the height constraint to
|
|
36
36
|
* @param options - Configuration options for the constraint
|
|
37
37
|
*/
|
|
38
|
-
constructor(element:
|
|
38
|
+
constructor(element: UIPlaneElement & UILayerElement, options?: Partial<UIHeightConstraintOptions>);
|
|
39
39
|
/**
|
|
40
40
|
* Gets the current height value being enforced.
|
|
41
41
|
* @returns The height value in pixels
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { UILayerElement, UIPlaneElement } from "../miscellaneous/asserts";
|
|
2
2
|
import type { UISingleParameterConstraintOptions } from "./UISingleParameterConstraint";
|
|
3
3
|
import { UISingleParameterConstraint } from "./UISingleParameterConstraint";
|
|
4
4
|
/**
|
|
@@ -17,7 +17,7 @@ export interface UIWidthConstraintOptions extends UISingleParameterConstraintOpt
|
|
|
17
17
|
* other layout changes or for setting fixed dimensions in responsive layouts.
|
|
18
18
|
*
|
|
19
19
|
* @see {@link UISingleParameterConstraint} - Base class for single-parameter constraints
|
|
20
|
-
* @see {@link
|
|
20
|
+
* @see {@link UIPlaneElement} - Elements that can have width constraints applied
|
|
21
21
|
* @see {@link UIExpression} - Mathematical expressions for constraint equations
|
|
22
22
|
*/
|
|
23
23
|
export declare class UIWidthConstraint extends UISingleParameterConstraint {
|
|
@@ -35,7 +35,7 @@ export declare class UIWidthConstraint extends UISingleParameterConstraint {
|
|
|
35
35
|
* @param element - The UI element to apply the width constraint to
|
|
36
36
|
* @param options - Configuration options for the constraint
|
|
37
37
|
*/
|
|
38
|
-
constructor(element:
|
|
38
|
+
constructor(element: UIPlaneElement & UILayerElement, options?: Partial<UIWidthConstraintOptions>);
|
|
39
39
|
/**
|
|
40
40
|
* Gets the current width value being enforced.
|
|
41
41
|
* @returns The width value in pixels
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { WebGLRenderer } from "three";
|
|
1
2
|
import { type Object3D } from "three";
|
|
2
3
|
import type { UILayer } from "../layers/UILayer";
|
|
3
|
-
import type { UIPlaneElement } from "../miscellaneous/asserts";
|
|
4
|
+
import type { UILayerElement, UIPlaneElement } from "../miscellaneous/asserts";
|
|
4
5
|
import { UIMicro } from "../miscellaneous/UIMicro";
|
|
5
6
|
import { UIMode } from "../miscellaneous/UIMode";
|
|
6
7
|
import type { UISceneWrapper } from "../wrappers/UISceneWrapper";
|
|
@@ -27,7 +28,7 @@ export declare enum UIElementEvent {
|
|
|
27
28
|
* @see {@link UISceneWrapper} - Scene management for rendering
|
|
28
29
|
* @see {@link UIMicro} - Micro-optimization utilities
|
|
29
30
|
*/
|
|
30
|
-
export declare abstract class UIElement<T extends Object3D = Object3D> extends UIAnchor implements UIPlaneElement {
|
|
31
|
+
export declare abstract class UIElement<T extends Object3D = Object3D> extends UIAnchor implements UIPlaneElement, UILayerElement {
|
|
31
32
|
protected readonly object: T;
|
|
32
33
|
/** Micro-transformation system for non-constraint based positioning, scaling, and rotation adjustments. */
|
|
33
34
|
readonly micro: UIMicro;
|
|
@@ -118,4 +119,26 @@ export declare abstract class UIElement<T extends Object3D = Object3D> extends U
|
|
|
118
119
|
* should not be used anymore.
|
|
119
120
|
*/
|
|
120
121
|
destroy(): void;
|
|
122
|
+
/**
|
|
123
|
+
* Internal method for handling click events.
|
|
124
|
+
*
|
|
125
|
+
* Determines if the click coordinates intersect with this element's bounds
|
|
126
|
+
* and emits a CLICK event if the element is in interactive mode.
|
|
127
|
+
*
|
|
128
|
+
* @param x - The x-coordinate of the click
|
|
129
|
+
* @param y - The y-coordinate of the click
|
|
130
|
+
* @returns True if the click was handled by this element
|
|
131
|
+
*/
|
|
132
|
+
protected ["onClickInternal"](x: number, y: number): boolean;
|
|
133
|
+
/**
|
|
134
|
+
* Internal method called before rendering each frame.
|
|
135
|
+
*
|
|
136
|
+
* This is a hook method that can be overridden by subclasses to perform
|
|
137
|
+
* pre-render operations such as updating animations, transforms, or
|
|
138
|
+
* other dynamic properties.
|
|
139
|
+
*
|
|
140
|
+
* @param renderer - The WebGL renderer instance
|
|
141
|
+
* @param deltaTime - Time elapsed since the last frame in seconds
|
|
142
|
+
*/
|
|
143
|
+
protected ["onBeforeRenderInternal"](renderer: WebGLRenderer, deltaTime: number): void;
|
|
121
144
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Camera } from "three";
|
|
1
|
+
import type { Camera, WebGLRenderer } from "three";
|
|
2
2
|
import { Mesh, Scene } from "three";
|
|
3
3
|
import type { UILayer } from "../layers/UILayer";
|
|
4
4
|
import { UIElement } from "./UIElement";
|
|
@@ -196,4 +196,14 @@ export declare class UIScene extends UIElement<Mesh> {
|
|
|
196
196
|
* want to trigger a scene re-render without changing any properties.
|
|
197
197
|
*/
|
|
198
198
|
requestRender(): void;
|
|
199
|
+
/**
|
|
200
|
+
* Internal method called before rendering each frame.
|
|
201
|
+
*
|
|
202
|
+
* This method handles the conditional rendering of the 3D scene based on
|
|
203
|
+
* the current update mode. It manages frame counting, property change detection,
|
|
204
|
+
* and manual render requests to optimize performance.
|
|
205
|
+
*
|
|
206
|
+
* @param renderer - The WebGL renderer instance
|
|
207
|
+
*/
|
|
208
|
+
protected ["onBeforeRenderInternal"](renderer: WebGLRenderer): void;
|
|
199
209
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { WebGLRenderer } from "three";
|
|
1
2
|
import { Mesh } from "three";
|
|
2
3
|
import type { UILayer } from "../layers/UILayer";
|
|
3
4
|
import type { UITextContent } from "../miscellaneous/textInterfaces";
|
|
@@ -144,6 +145,17 @@ export declare class UIText extends UIElement<Mesh> {
|
|
|
144
145
|
* the text element should not be used anymore.
|
|
145
146
|
*/
|
|
146
147
|
destroy(): void;
|
|
148
|
+
/**
|
|
149
|
+
* Internal method called before rendering each frame.
|
|
150
|
+
*
|
|
151
|
+
* Updates the element's height to maintain the correct aspect ratio
|
|
152
|
+
* based on the text content dimensions. This ensures the text is
|
|
153
|
+
* displayed without distortion.
|
|
154
|
+
*
|
|
155
|
+
* @param renderer - The WebGL renderer instance
|
|
156
|
+
* @param deltaTime - Time elapsed since the last frame in seconds
|
|
157
|
+
*/
|
|
158
|
+
protected ["onBeforeRenderInternal"](renderer: WebGLRenderer, deltaTime: number): void;
|
|
147
159
|
/**
|
|
148
160
|
* Rebuilds the text canvas and texture based on current content and settings.
|
|
149
161
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export * from "./builders/UIConstraint2DBuilder";
|
|
2
|
+
export * from "./builders/UICoverConstraintBuilder";
|
|
3
|
+
export * from "./builders/UIFitConstraintBuilder";
|
|
2
4
|
export * from "./constraints/UIAspectConstraint";
|
|
3
5
|
export * from "./constraints/UIConstraint";
|
|
4
6
|
export * from "./constraints/UICustomConstraint";
|
package/dist/index.js
CHANGED
|
@@ -2459,7 +2459,6 @@ class UILayer extends i {
|
|
|
2459
2459
|
* constraints that need to create variables or constraints.
|
|
2460
2460
|
*
|
|
2461
2461
|
* @returns The constraint solver wrapper instance
|
|
2462
|
-
* @internal
|
|
2463
2462
|
*/
|
|
2464
2463
|
["getSolverWrapperInternal"]() {
|
|
2465
2464
|
return this.solverWrapper;
|
|
@@ -2471,7 +2470,6 @@ class UILayer extends i {
|
|
|
2471
2470
|
* that need to be added to or removed from the 3D scene.
|
|
2472
2471
|
*
|
|
2473
2472
|
* @returns The scene wrapper instance
|
|
2474
|
-
* @internal
|
|
2475
2473
|
*/
|
|
2476
2474
|
["getSceneWrapperInternal"]() {
|
|
2477
2475
|
return this.sceneWrapper;
|
|
@@ -2632,7 +2630,7 @@ class UISingleParameterConstraint extends UIConstraint {
|
|
|
2632
2630
|
* other layout changes or for setting fixed dimensions in responsive layouts.
|
|
2633
2631
|
*
|
|
2634
2632
|
* @see {@link UISingleParameterConstraint} - Base class for single-parameter constraints
|
|
2635
|
-
* @see {@link
|
|
2633
|
+
* @see {@link UIPlaneElement} - Elements that can have height constraints applied
|
|
2636
2634
|
* @see {@link UIExpression} - Mathematical expressions for constraint equations
|
|
2637
2635
|
*/
|
|
2638
2636
|
class UIHeightConstraint extends UISingleParameterConstraint {
|
|
@@ -2696,7 +2694,11 @@ function isUIPointElement(obj) {
|
|
|
2696
2694
|
"xVariable" in obj &&
|
|
2697
2695
|
typeof obj.xVariable === "number" &&
|
|
2698
2696
|
"yVariable" in obj &&
|
|
2699
|
-
typeof obj.yVariable === "number"
|
|
2697
|
+
typeof obj.yVariable === "number" &&
|
|
2698
|
+
"width" in obj &&
|
|
2699
|
+
typeof obj.width === "number" &&
|
|
2700
|
+
"height" in obj &&
|
|
2701
|
+
typeof obj.height === "number");
|
|
2700
2702
|
}
|
|
2701
2703
|
/**
|
|
2702
2704
|
* Type guard to check if an object implements the UIPlaneElement interface.
|
|
@@ -2713,7 +2715,11 @@ function isUIPlaneElement(obj) {
|
|
|
2713
2715
|
"wVariable" in obj &&
|
|
2714
2716
|
typeof obj.wVariable === "number" &&
|
|
2715
2717
|
"hVariable" in obj &&
|
|
2716
|
-
typeof obj.hVariable === "number"
|
|
2718
|
+
typeof obj.hVariable === "number" &&
|
|
2719
|
+
"width" in obj &&
|
|
2720
|
+
typeof obj.width === "number" &&
|
|
2721
|
+
"height" in obj &&
|
|
2722
|
+
typeof obj.height === "number");
|
|
2717
2723
|
}
|
|
2718
2724
|
/**
|
|
2719
2725
|
* Validates that two objects are valid constraint subjects from the same layer.
|
|
@@ -2807,7 +2813,7 @@ function assertValidNonNegativeNumber(value, subject) {
|
|
|
2807
2813
|
}
|
|
2808
2814
|
|
|
2809
2815
|
/** Default anchor point (0.5 = center) for elements when not specified. */
|
|
2810
|
-
const DEFAULT_ANCHOR$
|
|
2816
|
+
const DEFAULT_ANCHOR$4 = 0.5;
|
|
2811
2817
|
/**
|
|
2812
2818
|
* Constraint that enforces horizontal distance between two UI elements.
|
|
2813
2819
|
*
|
|
@@ -2839,8 +2845,8 @@ class UIHorizontalDistanceConstraint extends UISingleParameterConstraint {
|
|
|
2839
2845
|
super(assertValidConstraintSubjects(_private_a, _private_b, "UIHorizontalDistanceConstraint"), options.priority, options.relation, options.orientation);
|
|
2840
2846
|
this._private_a = _private_a;
|
|
2841
2847
|
this._private_b = _private_b;
|
|
2842
|
-
this._private_anchorAInternal = options.anchorA ?? DEFAULT_ANCHOR$
|
|
2843
|
-
this._private_anchorBInternal = options.anchorB ?? DEFAULT_ANCHOR$
|
|
2848
|
+
this._private_anchorAInternal = options.anchorA ?? DEFAULT_ANCHOR$4;
|
|
2849
|
+
this._private_anchorBInternal = options.anchorB ?? DEFAULT_ANCHOR$4;
|
|
2844
2850
|
this._private_distanceInternal = options.distance ?? 0;
|
|
2845
2851
|
this.constraint = this.solverWrapper.createConstraint(this._private_buildLHS(), new UIExpression(this._private_distanceInternal), this.relationInternal, this.priorityInternal, this.isConstraintEnabled());
|
|
2846
2852
|
}
|
|
@@ -3004,7 +3010,7 @@ class UIHorizontalProportionConstraint extends UISingleParameterConstraint {
|
|
|
3004
3010
|
}
|
|
3005
3011
|
|
|
3006
3012
|
/** Default anchor point (0.5 = center) for elements when not specified. */
|
|
3007
|
-
const DEFAULT_ANCHOR$
|
|
3013
|
+
const DEFAULT_ANCHOR$3 = 0.5;
|
|
3008
3014
|
/**
|
|
3009
3015
|
* Constraint that enforces vertical distance between two UI elements.
|
|
3010
3016
|
*
|
|
@@ -3036,8 +3042,8 @@ class UIVerticalDistanceConstraint extends UISingleParameterConstraint {
|
|
|
3036
3042
|
super(assertValidConstraintSubjects(_private_a, _private_b, "UIVerticalDistanceConstraint"), options.priority, options.relation, options.orientation);
|
|
3037
3043
|
this._private_a = _private_a;
|
|
3038
3044
|
this._private_b = _private_b;
|
|
3039
|
-
this._private_anchorAInternal = options.anchorA ?? DEFAULT_ANCHOR$
|
|
3040
|
-
this._private_anchorBInternal = options.anchorB ?? DEFAULT_ANCHOR$
|
|
3045
|
+
this._private_anchorAInternal = options.anchorA ?? DEFAULT_ANCHOR$3;
|
|
3046
|
+
this._private_anchorBInternal = options.anchorB ?? DEFAULT_ANCHOR$3;
|
|
3041
3047
|
this._private_distanceInternal = options.distance ?? 0;
|
|
3042
3048
|
this.constraint = this.solverWrapper.createConstraint(this._private_buildLHS(), new UIExpression(this._private_distanceInternal), this.relationInternal, this.priorityInternal, this.isConstraintEnabled());
|
|
3043
3049
|
}
|
|
@@ -3209,7 +3215,7 @@ class UIVerticalProportionConstraint extends UISingleParameterConstraint {
|
|
|
3209
3215
|
* other layout changes or for setting fixed dimensions in responsive layouts.
|
|
3210
3216
|
*
|
|
3211
3217
|
* @see {@link UISingleParameterConstraint} - Base class for single-parameter constraints
|
|
3212
|
-
* @see {@link
|
|
3218
|
+
* @see {@link UIPlaneElement} - Elements that can have width constraints applied
|
|
3213
3219
|
* @see {@link UIExpression} - Mathematical expressions for constraint equations
|
|
3214
3220
|
*/
|
|
3215
3221
|
class UIWidthConstraint extends UISingleParameterConstraint {
|
|
@@ -3363,7 +3369,7 @@ class UIConstraint2DBuilder {
|
|
|
3363
3369
|
* ratios like 16:9 for video content.
|
|
3364
3370
|
*
|
|
3365
3371
|
* @see {@link UISingleParameterConstraint} - Base class for single-parameter constraints
|
|
3366
|
-
* @see {@link
|
|
3372
|
+
* @see {@link UIPlaneElement} - Elements that can have aspect constraints applied
|
|
3367
3373
|
* @see {@link UIExpression} - Mathematical expressions for constraint equations
|
|
3368
3374
|
*/
|
|
3369
3375
|
class UIAspectConstraint extends UISingleParameterConstraint {
|
|
@@ -3416,6 +3422,124 @@ class UIAspectConstraint extends UISingleParameterConstraint {
|
|
|
3416
3422
|
}
|
|
3417
3423
|
}
|
|
3418
3424
|
|
|
3425
|
+
const DEFAULT_ANCHOR$2 = 0.5;
|
|
3426
|
+
/**
|
|
3427
|
+
* Builder for creating "cover" layout constraints that make an element cover its container.
|
|
3428
|
+
*
|
|
3429
|
+
* Cover layout ensures the active element is large enough to completely cover the passive
|
|
3430
|
+
* element while maintaining proportions. This is similar to CSS `background-size: cover`
|
|
3431
|
+
* or `object-fit: cover` behavior.
|
|
3432
|
+
*
|
|
3433
|
+
* The active element will be:
|
|
3434
|
+
* - Positioned at the specified anchor point within the passive element
|
|
3435
|
+
* - Sized to be at least as large as the passive element in both dimensions
|
|
3436
|
+
* - Scaled proportionally to maintain aspect ratio (if enabled)
|
|
3437
|
+
*/
|
|
3438
|
+
class UICoverConstraintBuilder {
|
|
3439
|
+
/**
|
|
3440
|
+
* Creates a set of constraints for cover layout behavior.
|
|
3441
|
+
*
|
|
3442
|
+
* @param passive - The container element (what gets covered)
|
|
3443
|
+
* @param active - The content element (what does the covering)
|
|
3444
|
+
* @param options - Configuration options for the cover layout
|
|
3445
|
+
* @returns Object containing all created constraints
|
|
3446
|
+
*/
|
|
3447
|
+
static build(passive, active, options = {}) {
|
|
3448
|
+
let activeAspectConstraint;
|
|
3449
|
+
if (options.keepActiveAspect === true) {
|
|
3450
|
+
activeAspectConstraint = new UIAspectConstraint(active, {
|
|
3451
|
+
orientation: options.orientation,
|
|
3452
|
+
});
|
|
3453
|
+
}
|
|
3454
|
+
const xConstraint = new UIHorizontalDistanceConstraint(passive, active, {
|
|
3455
|
+
anchorA: options.anchorH ?? DEFAULT_ANCHOR$2,
|
|
3456
|
+
anchorB: options.anchorH ?? DEFAULT_ANCHOR$2,
|
|
3457
|
+
orientation: options.orientation,
|
|
3458
|
+
});
|
|
3459
|
+
const yConstraint = new UIVerticalDistanceConstraint(passive, active, {
|
|
3460
|
+
anchorA: options.anchorV ?? DEFAULT_ANCHOR$2,
|
|
3461
|
+
anchorB: options.anchorV ?? DEFAULT_ANCHOR$2,
|
|
3462
|
+
orientation: options.orientation,
|
|
3463
|
+
});
|
|
3464
|
+
const widthConstraint = new UIHorizontalProportionConstraint(passive, active, {
|
|
3465
|
+
proportion: 1,
|
|
3466
|
+
relation: UIRelation.GREATER_THAN,
|
|
3467
|
+
orientation: options.orientation,
|
|
3468
|
+
});
|
|
3469
|
+
const heightConstraint = new UIVerticalProportionConstraint(passive, active, {
|
|
3470
|
+
proportion: 1,
|
|
3471
|
+
priority: UIPriority.P1,
|
|
3472
|
+
orientation: options.orientation,
|
|
3473
|
+
});
|
|
3474
|
+
return {
|
|
3475
|
+
activeAspectConstraint,
|
|
3476
|
+
xConstraint,
|
|
3477
|
+
yConstraint,
|
|
3478
|
+
widthConstraint,
|
|
3479
|
+
heightConstraint,
|
|
3480
|
+
};
|
|
3481
|
+
}
|
|
3482
|
+
}
|
|
3483
|
+
|
|
3484
|
+
const DEFAULT_ANCHOR$1 = 0.5;
|
|
3485
|
+
/**
|
|
3486
|
+
* Builder for creating "fit" layout constraints that make an element fit within its container.
|
|
3487
|
+
*
|
|
3488
|
+
* Fit layout ensures the active element is sized to completely fit within the passive
|
|
3489
|
+
* element while maintaining proportions. This is similar to CSS `background-size: contain`
|
|
3490
|
+
* or `object-fit: contain` behavior.
|
|
3491
|
+
*
|
|
3492
|
+
* The active element will be:
|
|
3493
|
+
* - Positioned at the specified anchor point within the passive element
|
|
3494
|
+
* - Sized to fit entirely within the passive element in both dimensions
|
|
3495
|
+
* - Scaled proportionally to maintain aspect ratio (if enabled)
|
|
3496
|
+
*/
|
|
3497
|
+
class UIFitConstraintBuilder {
|
|
3498
|
+
/**
|
|
3499
|
+
* Creates a set of constraints for fit layout behavior.
|
|
3500
|
+
*
|
|
3501
|
+
* @param passive - The container element (what contains the content)
|
|
3502
|
+
* @param active - The content element (what gets fitted within the container)
|
|
3503
|
+
* @param options - Configuration options for the fit layout
|
|
3504
|
+
* @returns Object containing all created constraints
|
|
3505
|
+
*/
|
|
3506
|
+
static build(passive, active, options = {}) {
|
|
3507
|
+
let activeAspectConstraint;
|
|
3508
|
+
if (options.keepActiveAspect === true) {
|
|
3509
|
+
activeAspectConstraint = new UIAspectConstraint(active, {
|
|
3510
|
+
orientation: options.orientation,
|
|
3511
|
+
});
|
|
3512
|
+
}
|
|
3513
|
+
const xConstraint = new UIHorizontalDistanceConstraint(passive, active, {
|
|
3514
|
+
anchorA: options.anchorH ?? DEFAULT_ANCHOR$1,
|
|
3515
|
+
anchorB: options.anchorH ?? DEFAULT_ANCHOR$1,
|
|
3516
|
+
orientation: options.orientation,
|
|
3517
|
+
});
|
|
3518
|
+
const yConstraint = new UIVerticalDistanceConstraint(passive, active, {
|
|
3519
|
+
anchorA: options.anchorV ?? DEFAULT_ANCHOR$1,
|
|
3520
|
+
anchorB: options.anchorV ?? DEFAULT_ANCHOR$1,
|
|
3521
|
+
orientation: options.orientation,
|
|
3522
|
+
});
|
|
3523
|
+
const widthConstraint = new UIHorizontalProportionConstraint(passive, active, {
|
|
3524
|
+
proportion: 1,
|
|
3525
|
+
relation: UIRelation.LESS_THAN,
|
|
3526
|
+
orientation: options.orientation,
|
|
3527
|
+
});
|
|
3528
|
+
const heightConstraint = new UIVerticalProportionConstraint(passive, active, {
|
|
3529
|
+
proportion: 1,
|
|
3530
|
+
priority: UIPriority.P1,
|
|
3531
|
+
orientation: options.orientation,
|
|
3532
|
+
});
|
|
3533
|
+
return {
|
|
3534
|
+
activeAspectConstraint,
|
|
3535
|
+
xConstraint,
|
|
3536
|
+
yConstraint,
|
|
3537
|
+
widthConstraint,
|
|
3538
|
+
heightConstraint,
|
|
3539
|
+
};
|
|
3540
|
+
}
|
|
3541
|
+
}
|
|
3542
|
+
|
|
3419
3543
|
/**
|
|
3420
3544
|
* Constraint that allows custom mathematical relationships between UI elements.
|
|
3421
3545
|
*
|
|
@@ -4052,7 +4176,6 @@ class UIElement extends UIAnchor {
|
|
|
4052
4176
|
* @param x - The x-coordinate of the click
|
|
4053
4177
|
* @param y - The y-coordinate of the click
|
|
4054
4178
|
* @returns True if the click was handled by this element
|
|
4055
|
-
* @internal
|
|
4056
4179
|
*/
|
|
4057
4180
|
["onClickInternal"](x, y) {
|
|
4058
4181
|
const isClicked = this.modeInternal === UIMode.INTERACTIVE &&
|
|
@@ -4074,7 +4197,6 @@ class UIElement extends UIAnchor {
|
|
|
4074
4197
|
*
|
|
4075
4198
|
* @param renderer - The WebGL renderer instance
|
|
4076
4199
|
* @param deltaTime - Time elapsed since the last frame in seconds
|
|
4077
|
-
* @internal
|
|
4078
4200
|
*/
|
|
4079
4201
|
["onBeforeRenderInternal"](
|
|
4080
4202
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- empty basic method, parameters unused
|
|
@@ -4955,7 +5077,6 @@ class UIScene extends UIElement {
|
|
|
4955
5077
|
* and manual render requests to optimize performance.
|
|
4956
5078
|
*
|
|
4957
5079
|
* @param renderer - The WebGL renderer instance
|
|
4958
|
-
* @internal
|
|
4959
5080
|
*/
|
|
4960
5081
|
["onBeforeRenderInternal"](renderer) {
|
|
4961
5082
|
if (this._private_updateModeInternal === UISceneUpdateMode.EACH_FRAME ||
|
|
@@ -5414,7 +5535,6 @@ class UIText extends UIElement {
|
|
|
5414
5535
|
*
|
|
5415
5536
|
* @param renderer - The WebGL renderer instance
|
|
5416
5537
|
* @param deltaTime - Time elapsed since the last frame in seconds
|
|
5417
|
-
* @internal
|
|
5418
5538
|
*/
|
|
5419
5539
|
["onBeforeRenderInternal"](
|
|
5420
5540
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- parameter required by parent
|
|
@@ -5639,5 +5759,5 @@ function isUITextSpan(obj) {
|
|
|
5639
5759
|
(!("style" in obj) || isUITextStyle(obj.style)));
|
|
5640
5760
|
}
|
|
5641
5761
|
|
|
5642
|
-
export { UIAnchor, UIAnchorMode, UIAspectConstraint, UIConstraint, UIConstraint2DBuilder, UICustomConstraint, UIDummy, UIElement, UIElementEvent, UIExpression, UIFullscreenLayer, UIHeightConstraint, UIHorizontalDistanceConstraint, UIHorizontalProportionConstraint, UIImage, UILayer, UILayerEvent, UIMicro, UIMode, UINineSlice, UIOrientation, UIPriority, UIProgress, UIRelation, UIScene, UISceneUpdateMode, UISingleParameterConstraint, UIText, UIVerticalDistanceConstraint, UIVerticalProportionConstraint, UIWidthConstraint, convertPriority, convertRelation, isUITextSpan, isUITextStyle, resolveOrientation, resolvePadding, resolvePriority, resolveRelation, resolveTextStyle };
|
|
5762
|
+
export { UIAnchor, UIAnchorMode, UIAspectConstraint, UIConstraint, UIConstraint2DBuilder, UICoverConstraintBuilder, UICustomConstraint, UIDummy, UIElement, UIElementEvent, UIExpression, UIFitConstraintBuilder, UIFullscreenLayer, UIHeightConstraint, UIHorizontalDistanceConstraint, UIHorizontalProportionConstraint, UIImage, UILayer, UILayerEvent, UIMicro, UIMode, UINineSlice, UIOrientation, UIPriority, UIProgress, UIRelation, UIScene, UISceneUpdateMode, UISingleParameterConstraint, UIText, UIVerticalDistanceConstraint, UIVerticalProportionConstraint, UIWidthConstraint, convertPriority, convertRelation, isUITextSpan, isUITextStyle, resolveOrientation, resolvePadding, resolvePriority, resolveRelation, resolveTextStyle };
|
|
5643
5763
|
//# sourceMappingURL=index.js.map
|