laymur 0.2.9 → 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 +142 -20
- 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
|
@@ -1923,8 +1923,10 @@ class UISceneWrapper {
|
|
|
1923
1923
|
else {
|
|
1924
1924
|
const rawAnchorOffsetX = micro.anchorX * element.width;
|
|
1925
1925
|
const rawAnchorOffsetY = micro.anchorY * element.height;
|
|
1926
|
-
object.position.x =
|
|
1927
|
-
|
|
1926
|
+
object.position.x =
|
|
1927
|
+
element.x + rawAnchorOffsetX - rotatedAnchorX + micro.x;
|
|
1928
|
+
object.position.y =
|
|
1929
|
+
element.y + rawAnchorOffsetY - rotatedAnchorY + micro.y;
|
|
1928
1930
|
}
|
|
1929
1931
|
object.scale.x = width;
|
|
1930
1932
|
object.scale.y = height;
|
|
@@ -2457,7 +2459,6 @@ class UILayer extends i {
|
|
|
2457
2459
|
* constraints that need to create variables or constraints.
|
|
2458
2460
|
*
|
|
2459
2461
|
* @returns The constraint solver wrapper instance
|
|
2460
|
-
* @internal
|
|
2461
2462
|
*/
|
|
2462
2463
|
["getSolverWrapperInternal"]() {
|
|
2463
2464
|
return this.solverWrapper;
|
|
@@ -2469,7 +2470,6 @@ class UILayer extends i {
|
|
|
2469
2470
|
* that need to be added to or removed from the 3D scene.
|
|
2470
2471
|
*
|
|
2471
2472
|
* @returns The scene wrapper instance
|
|
2472
|
-
* @internal
|
|
2473
2473
|
*/
|
|
2474
2474
|
["getSceneWrapperInternal"]() {
|
|
2475
2475
|
return this.sceneWrapper;
|
|
@@ -2630,7 +2630,7 @@ class UISingleParameterConstraint extends UIConstraint {
|
|
|
2630
2630
|
* other layout changes or for setting fixed dimensions in responsive layouts.
|
|
2631
2631
|
*
|
|
2632
2632
|
* @see {@link UISingleParameterConstraint} - Base class for single-parameter constraints
|
|
2633
|
-
* @see {@link
|
|
2633
|
+
* @see {@link UIPlaneElement} - Elements that can have height constraints applied
|
|
2634
2634
|
* @see {@link UIExpression} - Mathematical expressions for constraint equations
|
|
2635
2635
|
*/
|
|
2636
2636
|
class UIHeightConstraint extends UISingleParameterConstraint {
|
|
@@ -2694,7 +2694,11 @@ function isUIPointElement(obj) {
|
|
|
2694
2694
|
"xVariable" in obj &&
|
|
2695
2695
|
typeof obj.xVariable === "number" &&
|
|
2696
2696
|
"yVariable" in obj &&
|
|
2697
|
-
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");
|
|
2698
2702
|
}
|
|
2699
2703
|
/**
|
|
2700
2704
|
* Type guard to check if an object implements the UIPlaneElement interface.
|
|
@@ -2711,7 +2715,11 @@ function isUIPlaneElement(obj) {
|
|
|
2711
2715
|
"wVariable" in obj &&
|
|
2712
2716
|
typeof obj.wVariable === "number" &&
|
|
2713
2717
|
"hVariable" in obj &&
|
|
2714
|
-
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");
|
|
2715
2723
|
}
|
|
2716
2724
|
/**
|
|
2717
2725
|
* Validates that two objects are valid constraint subjects from the same layer.
|
|
@@ -2805,7 +2813,7 @@ function assertValidNonNegativeNumber(value, subject) {
|
|
|
2805
2813
|
}
|
|
2806
2814
|
|
|
2807
2815
|
/** Default anchor point (0.5 = center) for elements when not specified. */
|
|
2808
|
-
const DEFAULT_ANCHOR$
|
|
2816
|
+
const DEFAULT_ANCHOR$4 = 0.5;
|
|
2809
2817
|
/**
|
|
2810
2818
|
* Constraint that enforces horizontal distance between two UI elements.
|
|
2811
2819
|
*
|
|
@@ -2837,8 +2845,8 @@ class UIHorizontalDistanceConstraint extends UISingleParameterConstraint {
|
|
|
2837
2845
|
super(assertValidConstraintSubjects(_private_a, _private_b, "UIHorizontalDistanceConstraint"), options.priority, options.relation, options.orientation);
|
|
2838
2846
|
this._private_a = _private_a;
|
|
2839
2847
|
this._private_b = _private_b;
|
|
2840
|
-
this._private_anchorAInternal = options.anchorA ?? DEFAULT_ANCHOR$
|
|
2841
|
-
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;
|
|
2842
2850
|
this._private_distanceInternal = options.distance ?? 0;
|
|
2843
2851
|
this.constraint = this.solverWrapper.createConstraint(this._private_buildLHS(), new UIExpression(this._private_distanceInternal), this.relationInternal, this.priorityInternal, this.isConstraintEnabled());
|
|
2844
2852
|
}
|
|
@@ -3002,7 +3010,7 @@ class UIHorizontalProportionConstraint extends UISingleParameterConstraint {
|
|
|
3002
3010
|
}
|
|
3003
3011
|
|
|
3004
3012
|
/** Default anchor point (0.5 = center) for elements when not specified. */
|
|
3005
|
-
const DEFAULT_ANCHOR$
|
|
3013
|
+
const DEFAULT_ANCHOR$3 = 0.5;
|
|
3006
3014
|
/**
|
|
3007
3015
|
* Constraint that enforces vertical distance between two UI elements.
|
|
3008
3016
|
*
|
|
@@ -3034,8 +3042,8 @@ class UIVerticalDistanceConstraint extends UISingleParameterConstraint {
|
|
|
3034
3042
|
super(assertValidConstraintSubjects(_private_a, _private_b, "UIVerticalDistanceConstraint"), options.priority, options.relation, options.orientation);
|
|
3035
3043
|
this._private_a = _private_a;
|
|
3036
3044
|
this._private_b = _private_b;
|
|
3037
|
-
this._private_anchorAInternal = options.anchorA ?? DEFAULT_ANCHOR$
|
|
3038
|
-
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;
|
|
3039
3047
|
this._private_distanceInternal = options.distance ?? 0;
|
|
3040
3048
|
this.constraint = this.solverWrapper.createConstraint(this._private_buildLHS(), new UIExpression(this._private_distanceInternal), this.relationInternal, this.priorityInternal, this.isConstraintEnabled());
|
|
3041
3049
|
}
|
|
@@ -3207,7 +3215,7 @@ class UIVerticalProportionConstraint extends UISingleParameterConstraint {
|
|
|
3207
3215
|
* other layout changes or for setting fixed dimensions in responsive layouts.
|
|
3208
3216
|
*
|
|
3209
3217
|
* @see {@link UISingleParameterConstraint} - Base class for single-parameter constraints
|
|
3210
|
-
* @see {@link
|
|
3218
|
+
* @see {@link UIPlaneElement} - Elements that can have width constraints applied
|
|
3211
3219
|
* @see {@link UIExpression} - Mathematical expressions for constraint equations
|
|
3212
3220
|
*/
|
|
3213
3221
|
class UIWidthConstraint extends UISingleParameterConstraint {
|
|
@@ -3361,7 +3369,7 @@ class UIConstraint2DBuilder {
|
|
|
3361
3369
|
* ratios like 16:9 for video content.
|
|
3362
3370
|
*
|
|
3363
3371
|
* @see {@link UISingleParameterConstraint} - Base class for single-parameter constraints
|
|
3364
|
-
* @see {@link
|
|
3372
|
+
* @see {@link UIPlaneElement} - Elements that can have aspect constraints applied
|
|
3365
3373
|
* @see {@link UIExpression} - Mathematical expressions for constraint equations
|
|
3366
3374
|
*/
|
|
3367
3375
|
class UIAspectConstraint extends UISingleParameterConstraint {
|
|
@@ -3414,6 +3422,124 @@ class UIAspectConstraint extends UISingleParameterConstraint {
|
|
|
3414
3422
|
}
|
|
3415
3423
|
}
|
|
3416
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
|
+
|
|
3417
3543
|
/**
|
|
3418
3544
|
* Constraint that allows custom mathematical relationships between UI elements.
|
|
3419
3545
|
*
|
|
@@ -4050,7 +4176,6 @@ class UIElement extends UIAnchor {
|
|
|
4050
4176
|
* @param x - The x-coordinate of the click
|
|
4051
4177
|
* @param y - The y-coordinate of the click
|
|
4052
4178
|
* @returns True if the click was handled by this element
|
|
4053
|
-
* @internal
|
|
4054
4179
|
*/
|
|
4055
4180
|
["onClickInternal"](x, y) {
|
|
4056
4181
|
const isClicked = this.modeInternal === UIMode.INTERACTIVE &&
|
|
@@ -4072,7 +4197,6 @@ class UIElement extends UIAnchor {
|
|
|
4072
4197
|
*
|
|
4073
4198
|
* @param renderer - The WebGL renderer instance
|
|
4074
4199
|
* @param deltaTime - Time elapsed since the last frame in seconds
|
|
4075
|
-
* @internal
|
|
4076
4200
|
*/
|
|
4077
4201
|
["onBeforeRenderInternal"](
|
|
4078
4202
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- empty basic method, parameters unused
|
|
@@ -4953,7 +5077,6 @@ class UIScene extends UIElement {
|
|
|
4953
5077
|
* and manual render requests to optimize performance.
|
|
4954
5078
|
*
|
|
4955
5079
|
* @param renderer - The WebGL renderer instance
|
|
4956
|
-
* @internal
|
|
4957
5080
|
*/
|
|
4958
5081
|
["onBeforeRenderInternal"](renderer) {
|
|
4959
5082
|
if (this._private_updateModeInternal === UISceneUpdateMode.EACH_FRAME ||
|
|
@@ -5412,7 +5535,6 @@ class UIText extends UIElement {
|
|
|
5412
5535
|
*
|
|
5413
5536
|
* @param renderer - The WebGL renderer instance
|
|
5414
5537
|
* @param deltaTime - Time elapsed since the last frame in seconds
|
|
5415
|
-
* @internal
|
|
5416
5538
|
*/
|
|
5417
5539
|
["onBeforeRenderInternal"](
|
|
5418
5540
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- parameter required by parent
|
|
@@ -5637,5 +5759,5 @@ function isUITextSpan(obj) {
|
|
|
5637
5759
|
(!("style" in obj) || isUITextStyle(obj.style)));
|
|
5638
5760
|
}
|
|
5639
5761
|
|
|
5640
|
-
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 };
|
|
5641
5763
|
//# sourceMappingURL=index.js.map
|