laymur 0.3.16 → 0.3.21
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/elements/UIAnimatedImage.d.ts +119 -0
- package/dist/elements/UIGraphics.d.ts +122 -0
- package/dist/elements/UIText.d.ts +5 -5
- package/dist/index.d.ts +3 -0
- package/dist/index.js +743 -229
- 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/UIFullscreenLayer.d.ts +25 -84
- package/dist/miscellaneous/UIMicro.d.ts +6 -1
- package/dist/miscellaneous/UITextPadding.d.ts +2 -2
- package/dist/miscellaneous/resizePolicies.d.ts +99 -0
- package/package.json +1 -1
|
@@ -1,116 +1,57 @@
|
|
|
1
1
|
import { type Camera, type Vector3, type WebGLRenderer } from "three";
|
|
2
|
+
import type { UIResizePolicy } from "../miscellaneous/resizePolicies";
|
|
2
3
|
import { UILayer } from "./UILayer";
|
|
3
4
|
/**
|
|
4
|
-
* UI layer that
|
|
5
|
+
* UI layer that covers the full browser window.
|
|
5
6
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* width or height constraints that enable responsive scaling while maintaining
|
|
9
|
-
* design proportions across different screen sizes.
|
|
7
|
+
* Handles window resize and pointer events automatically. Scaling is controlled
|
|
8
|
+
* by the assigned resize policy.
|
|
10
9
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* of the actual browser window size.
|
|
14
|
-
*
|
|
15
|
-
* @see {@link UILayer} - Base layer functionality
|
|
16
|
-
* @see {@link UIOrientation} - Orientation-based scaling behavior
|
|
10
|
+
* @see {@link UILayer}
|
|
11
|
+
* @see {@link UIResizePolicy}
|
|
17
12
|
*/
|
|
18
13
|
export declare class UIFullscreenLayer extends UILayer {
|
|
19
|
-
|
|
20
|
-
private fixedWidthInternal?;
|
|
21
|
-
/** Internal storage for the optional fixed height constraint. */
|
|
22
|
-
private fixedHeightInternal?;
|
|
23
|
-
/**
|
|
24
|
-
* Creates a new UIFullscreenLayer instance with optional fixed dimensions.
|
|
25
|
-
*
|
|
26
|
-
* The layer will automatically resize to match the browser window and set up
|
|
27
|
-
* event listeners for window resize and pointer events. Fixed dimensions
|
|
28
|
-
* enable proportional scaling while maintaining design aspect ratios.
|
|
29
|
-
*
|
|
30
|
-
* @param fixedWidth - Optional fixed width for proportional scaling
|
|
31
|
-
* @param fixedHeight - Optional fixed height for proportional scaling
|
|
32
|
-
* @throws Will throw an error if fixed dimensions are not valid positive numbers
|
|
33
|
-
* @see {@link assertValidPositiveNumber}
|
|
34
|
-
*/
|
|
35
|
-
constructor(fixedWidth: number | undefined, fixedHeight: number | undefined);
|
|
36
|
-
/**
|
|
37
|
-
* Gets the current fixed width constraint.
|
|
38
|
-
* @returns The fixed width in pixels, or undefined if not set
|
|
39
|
-
*/
|
|
40
|
-
get fixedWidth(): number | undefined;
|
|
14
|
+
private resizePolicyInternal;
|
|
41
15
|
/**
|
|
42
|
-
*
|
|
43
|
-
* @returns The fixed height in pixels, or undefined if not set
|
|
16
|
+
* Creates a fullscreen layer and sets up window event listeners.
|
|
44
17
|
*/
|
|
45
|
-
|
|
18
|
+
constructor(resizePolicy?: UIResizePolicy);
|
|
46
19
|
/**
|
|
47
|
-
*
|
|
48
|
-
* @param value - The new fixed width in pixels, or undefined to remove constraint
|
|
49
|
-
* @throws Will throw an error if value is not a valid positive number
|
|
50
|
-
* @see {@link assertValidPositiveNumber}
|
|
20
|
+
* Gets the current resize policy.
|
|
51
21
|
*/
|
|
52
|
-
|
|
22
|
+
get resizePolicy(): UIResizePolicy;
|
|
53
23
|
/**
|
|
54
|
-
* Sets a new
|
|
55
|
-
* @param value - The new fixed height in pixels, or undefined to remove constraint
|
|
56
|
-
* @throws Will throw an error if value is not a valid positive number
|
|
57
|
-
* @see {@link assertValidPositiveNumber}
|
|
24
|
+
* Sets a new resize policy. Unsubscribes from old policy and subscribes to new one.
|
|
58
25
|
*/
|
|
59
|
-
set
|
|
26
|
+
set resizePolicy(value: UIResizePolicy);
|
|
60
27
|
/**
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
* This method cleans up window event listeners for resize and pointer events.
|
|
64
|
-
* After calling this method, the layer will no longer respond to window
|
|
65
|
-
* changes and should not be used anymore.
|
|
28
|
+
* Removes window event listeners. The layer should not be used after this.
|
|
66
29
|
*/
|
|
67
30
|
destroy(): void;
|
|
68
31
|
/**
|
|
69
|
-
* Renders the
|
|
32
|
+
* Renders the layer.
|
|
70
33
|
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
* and buffer management for fullscreen interfaces.
|
|
74
|
-
*
|
|
75
|
-
* @param renderer - The WebGL renderer instance
|
|
76
|
-
* @param deltaTime - Time elapsed since the last frame in seconds
|
|
77
|
-
* @throws Will throw an error if deltaTime is not a valid number
|
|
78
|
-
* @see {@link assertValidNumber}
|
|
34
|
+
* @param renderer - WebGL renderer
|
|
35
|
+
* @param deltaTime - Time since last frame in seconds
|
|
79
36
|
*/
|
|
80
37
|
render(renderer: WebGLRenderer, deltaTime: number): void;
|
|
81
38
|
/**
|
|
82
|
-
* Projects
|
|
39
|
+
* Projects 3D world position to 2D layer coordinates.
|
|
83
40
|
*
|
|
84
|
-
* @param position -
|
|
85
|
-
* @param camera -
|
|
86
|
-
* @returns
|
|
41
|
+
* @param position - 3D world position
|
|
42
|
+
* @param camera - Camera for projection
|
|
43
|
+
* @returns 2D position in layer space
|
|
87
44
|
*/
|
|
88
45
|
projectWorldPosition(position: Vector3, camera: Camera): Vector3;
|
|
89
46
|
/**
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
* The scaling factor is determined by the current orientation and which
|
|
93
|
-
* fixed dimension constraint is active. In horizontal orientation, fixed
|
|
94
|
-
* width takes precedence; in vertical orientation, fixed height takes precedence.
|
|
95
|
-
*
|
|
96
|
-
* @returns The scaling factor to apply to window dimensions
|
|
97
|
-
*/
|
|
98
|
-
private calculateScale;
|
|
99
|
-
/**
|
|
100
|
-
* Event handler for window resize events.
|
|
101
|
-
*
|
|
102
|
-
* Recalculates the scaling factor and updates the layer dimensions
|
|
103
|
-
* based on the new window size and fixed dimension constraints.
|
|
47
|
+
* Handles window resize. Updates layer dimensions according to resize policy.
|
|
104
48
|
*/
|
|
105
49
|
private readonly onResize;
|
|
106
50
|
/**
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
* Converts browser pointer coordinates to layer coordinates by accounting
|
|
110
|
-
* for element positioning and applying the appropriate scaling factor.
|
|
111
|
-
* The y-coordinate is flipped to match the UI coordinate system.
|
|
51
|
+
* Handles pointer down. Converts browser coordinates to layer space.
|
|
52
|
+
* Y-coordinate is flipped to match UI coordinate system.
|
|
112
53
|
*
|
|
113
|
-
* @param event -
|
|
54
|
+
* @param event - Browser pointer event
|
|
114
55
|
*/
|
|
115
56
|
private readonly onClick;
|
|
116
57
|
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
import { Eventail } from "eventail";
|
|
1
2
|
import { UIMicroAnchorMode } from "./UIMicroAnchorMode";
|
|
3
|
+
export declare enum UIMicroEvent {
|
|
4
|
+
CHANGE = 0
|
|
5
|
+
}
|
|
2
6
|
/**
|
|
3
7
|
* Micro-transformation system for non-constraint based UI element adjustments.
|
|
4
8
|
*
|
|
@@ -13,7 +17,7 @@ import { UIMicroAnchorMode } from "./UIMicroAnchorMode";
|
|
|
13
17
|
*
|
|
14
18
|
* @see {@link UIElement} - Elements that use micro transformations
|
|
15
19
|
*/
|
|
16
|
-
export declare class UIMicro {
|
|
20
|
+
export declare class UIMicro extends Eventail {
|
|
17
21
|
/** Internal storage for x-coordinate offset. */
|
|
18
22
|
private xInternal;
|
|
19
23
|
/** Internal storage for y-coordinate offset. */
|
|
@@ -140,4 +144,5 @@ export declare class UIMicro {
|
|
|
140
144
|
* if any values actually change.
|
|
141
145
|
*/
|
|
142
146
|
reset(): void;
|
|
147
|
+
copy(value: UIMicro): void;
|
|
143
148
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export interface
|
|
1
|
+
export interface UIPadding {
|
|
2
2
|
left: number;
|
|
3
3
|
right: number;
|
|
4
4
|
top: number;
|
|
5
5
|
bottom: number;
|
|
6
6
|
}
|
|
7
|
-
export declare function resolveTextPadding(value: unknown):
|
|
7
|
+
export declare function resolveTextPadding(value: unknown): UIPadding;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { Eventail } from "eventail";
|
|
2
|
+
export declare enum UIResizePolicyEvent {
|
|
3
|
+
CHANGE = 0
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Base class for UI resize policies.
|
|
7
|
+
*
|
|
8
|
+
* Calculates scale factors based on viewport dimensions. Different policies
|
|
9
|
+
* implement different scaling strategies.
|
|
10
|
+
*/
|
|
11
|
+
export declare abstract class UIResizePolicy extends Eventail {
|
|
12
|
+
/**
|
|
13
|
+
* Calculates scale factor for given dimensions.
|
|
14
|
+
*
|
|
15
|
+
* @param width - Viewport width in pixels
|
|
16
|
+
* @param height - Viewport height in pixels
|
|
17
|
+
* @returns Scale factor to apply
|
|
18
|
+
* @protected
|
|
19
|
+
*/
|
|
20
|
+
abstract calculateScaleInternal(width: number, height: number): number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* No scaling applied, always returns 1:1 scale.
|
|
24
|
+
*/
|
|
25
|
+
export declare class UIResizePolicyNone extends UIResizePolicy {
|
|
26
|
+
calculateScaleInternal(width: number, height: number): number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Maintains fixed width, scales based on window width.
|
|
30
|
+
*
|
|
31
|
+
* Uses different widths for landscape vs portrait orientation.
|
|
32
|
+
*/
|
|
33
|
+
export declare class UIResizePolicyFixedWidth extends UIResizePolicy {
|
|
34
|
+
private fixedWidthLandscapeInternal;
|
|
35
|
+
private fixedWidthPortraitInternal;
|
|
36
|
+
/**
|
|
37
|
+
* @param fixedWidthLandscape - Target width for landscape (width > height)
|
|
38
|
+
* @param fixedWidthPortrait - Target width for portrait (width <= height)
|
|
39
|
+
*/
|
|
40
|
+
constructor(fixedWidthLandscape: number, fixedWidthPortrait: number);
|
|
41
|
+
get fixedWidthLandscape(): number;
|
|
42
|
+
get fixedWidthPortrait(): number;
|
|
43
|
+
set fixedWidthLandscape(value: number);
|
|
44
|
+
set fixedWidthPortrait(value: number);
|
|
45
|
+
calculateScaleInternal(width: number, height: number): number;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Maintains fixed height, scales based on window height.
|
|
49
|
+
*
|
|
50
|
+
* Uses different heights for landscape vs portrait orientation.
|
|
51
|
+
*/
|
|
52
|
+
export declare class UIResizePolicyFixedHeight extends UIResizePolicy {
|
|
53
|
+
private fixedHeightLandscapeInternal;
|
|
54
|
+
private fixedHeightPortraitInternal;
|
|
55
|
+
/**
|
|
56
|
+
* @param fixedHeightLandscape - Target height for landscape (width > height)
|
|
57
|
+
* @param fixedHeightPortrait - Target height for portrait (width <= height)
|
|
58
|
+
*/
|
|
59
|
+
constructor(fixedHeightLandscape: number, fixedHeightPortrait: number);
|
|
60
|
+
get fixedHeightLandscape(): number;
|
|
61
|
+
get fixedHeightPortrait(): number;
|
|
62
|
+
set fixedHeightLandscape(value: number);
|
|
63
|
+
set fixedHeightPortrait(value: number);
|
|
64
|
+
calculateScaleInternal(width: number, height: number): number;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Scales by width in landscape, by height in portrait.
|
|
68
|
+
*/
|
|
69
|
+
export declare class UIResizePolicyCross extends UIResizePolicy {
|
|
70
|
+
private fixedWidthLandscapeInternal;
|
|
71
|
+
private fixedHeightPortraitInternal;
|
|
72
|
+
/**
|
|
73
|
+
* @param fixedWidthLandscape - Target width for landscape
|
|
74
|
+
* @param fixedHeightPortrait - Target height for portrait
|
|
75
|
+
*/
|
|
76
|
+
constructor(fixedWidthLandscape: number, fixedHeightPortrait: number);
|
|
77
|
+
get fixedWidthLandscape(): number;
|
|
78
|
+
get fixedHeightPortrait(): number;
|
|
79
|
+
set fixedWidthLandscape(value: number);
|
|
80
|
+
set fixedHeightPortrait(value: number);
|
|
81
|
+
calculateScaleInternal(width: number, height: number): number;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Scales by height in landscape, by width in portrait.
|
|
85
|
+
*/
|
|
86
|
+
export declare class UIResizePolicyCrossInverted extends UIResizePolicy {
|
|
87
|
+
private fixedHeightLandscapeInternal;
|
|
88
|
+
private fixedWidthPortraitInternal;
|
|
89
|
+
/**
|
|
90
|
+
* @param fixedHeightLandscape - Target height for landscape
|
|
91
|
+
* @param fixedWidthPortrait - Target width for portrait
|
|
92
|
+
*/
|
|
93
|
+
constructor(fixedHeightLandscape: number, fixedWidthPortrait: number);
|
|
94
|
+
get fixedHeightLandscape(): number;
|
|
95
|
+
get fixedWidthPortrait(): number;
|
|
96
|
+
set fixedHeightLandscape(value: number);
|
|
97
|
+
set fixedWidthPortrait(value: number);
|
|
98
|
+
calculateScaleInternal(width: number, height: number): number;
|
|
99
|
+
}
|