laymur 0.2.0 → 0.2.1

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 (64) hide show
  1. package/README.md +353 -2
  2. package/dist/builders/UIConstraint2DBuilder.d.ts +102 -14
  3. package/dist/composer/UIComposer.d.ts +0 -0
  4. package/dist/composer/UIFullscreenQuad.d.ts +0 -0
  5. package/dist/composer/UIPass.d.ts +0 -0
  6. package/dist/constraints/UIAspectConstraint.d.ts +40 -36
  7. package/dist/constraints/UIConstraint.d.ts +17 -20
  8. package/dist/constraints/UICoverConstraint.d.ts +0 -72
  9. package/dist/constraints/UICustomConstraint.d.ts +60 -0
  10. package/dist/constraints/UIFitConstraint.d.ts +0 -72
  11. package/dist/constraints/UIHeightConstraint.d.ts +32 -38
  12. package/dist/constraints/UIHorizontalDistanceConstraint.d.ts +77 -46
  13. package/dist/constraints/UIHorizontalProportionConstraint.d.ts +49 -40
  14. package/dist/constraints/UISingleParameterConstraint.d.ts +108 -0
  15. package/dist/constraints/UIVerticalDistanceConstraint.d.ts +77 -46
  16. package/dist/constraints/UIVerticalProportionConstraint.d.ts +49 -40
  17. package/dist/constraints/UIWidthConstraint.d.ts +32 -38
  18. package/dist/elements/UIAnchor.d.ts +58 -45
  19. package/dist/elements/UIDummy.d.ts +63 -12
  20. package/dist/elements/UIElement.d.ts +81 -93
  21. package/dist/elements/UIImage.d.ts +64 -33
  22. package/dist/elements/UINineSline.d.ts +0 -0
  23. package/dist/elements/UIProgress.d.ts +7 -95
  24. package/dist/elements/UIScene.d.ts +142 -84
  25. package/dist/elements/UIText.d.ts +124 -43
  26. package/dist/index.d.ts +10 -11
  27. package/dist/index.js +2867 -2718
  28. package/dist/index.js.map +1 -1
  29. package/dist/index.min.js +1 -1
  30. package/dist/index.min.js.map +1 -1
  31. package/dist/layers/UIFullscreenLayer.d.ts +112 -0
  32. package/dist/layers/UILayer.d.ts +134 -57
  33. package/dist/materials/UIInstancedMaterial.d.ts +0 -0
  34. package/dist/materials/UIMaterial.d.ts +6 -6
  35. package/dist/materials/UINineSliceMaterial.d.ts +0 -0
  36. package/dist/materials/UIProgressMaterial.d.ts +0 -4
  37. package/dist/miscellaneous/UIExpression.d.ts +117 -0
  38. package/dist/miscellaneous/UIMicro.d.ts +73 -119
  39. package/dist/miscellaneous/UIOrientation.d.ts +2 -9
  40. package/dist/miscellaneous/UIPriority.d.ts +56 -0
  41. package/dist/miscellaneous/UIRelation.d.ts +43 -0
  42. package/dist/miscellaneous/UITextPadding.d.ts +7 -0
  43. package/dist/miscellaneous/UITextSpan.d.ts +6 -0
  44. package/dist/miscellaneous/UITextStyle.d.ts +18 -0
  45. package/dist/miscellaneous/asserts.d.ts +111 -4
  46. package/dist/miscellaneous/textInterfaces.d.ts +19 -0
  47. package/dist/miscellaneous/textTools.d.ts +8 -5
  48. package/dist/scalable/UIScalableMesh.d.ts +16 -0
  49. package/dist/scalable/UIScalablePlaneMesh.d.ts +14 -0
  50. package/dist/wrappers/UISceneWrapper.d.ts +18 -0
  51. package/dist/wrappers/UISolverWrapper.d.ts +29 -0
  52. package/package.json +1 -1
  53. package/dist/Passes/UIComposer.d.ts +0 -114
  54. package/dist/Passes/UIFullScreenQuad.d.ts +0 -51
  55. package/dist/Passes/UIPass.d.ts +0 -43
  56. package/dist/builders/UIConstraintContainerBuilder.d.ts +0 -20
  57. package/dist/builders/UIConstraintStackBuilder.d.ts +0 -24
  58. package/dist/constraints/UIConstraintPower.d.ts +0 -57
  59. package/dist/constraints/UIConstraintRule.d.ts +0 -46
  60. package/dist/layers/UIFullScreenLayer.d.ts +0 -13
  61. package/dist/miscellaneous/UIBlending.d.ts +0 -7
  62. package/dist/miscellaneous/UITextInterfaces.d.ts +0 -49
  63. package/dist/miscellaneous/math.d.ts +0 -1
  64. package/dist/miscellaneous/microTransformationTools.d.ts +0 -3
@@ -1,114 +0,0 @@
1
- import type { Material, WebGLRenderer } from "three";
2
- import type { UIPass } from "./UIPass";
3
- /**
4
- * UI composition system for applying post-processing effects to rendered UI
5
- * The system manages render targets and passes to create complex visual effects
6
- */
7
- /**
8
- * Internal implementation of the UI composition system
9
- * Handles the actual rendering and composition of passes
10
- */
11
- export declare class UIComposerInternal {
12
- /** Collection of all registered composition passes */
13
- readonly passes: UIPass[];
14
- /** Source render target used during ping-pong rendering */
15
- private fromRenderTarget;
16
- /** Destination render target used during ping-pong rendering */
17
- private toRenderTarget;
18
- /** Default material used to render the final result */
19
- private readonly defaultMaterial;
20
- /** Full-screen quad used for rendering */
21
- private readonly screen;
22
- /** Whether the composition needs to be updated */
23
- private needsUpdateInternal;
24
- /** Whether the padding has changed since last frame */
25
- private paddingHasChangedInternal;
26
- /** Current padding value in pixels */
27
- private paddingInternal;
28
- /**
29
- * Creates a new UI composer with initial render targets
30
- */
31
- constructor();
32
- /**
33
- * Whether the composition needs to be updated in the next frame
34
- * True when either the composer or any valuable passes need update
35
- */
36
- get needsUpdate(): boolean;
37
- /**
38
- * Whether the padding has changed since the last frame
39
- * Used to trigger layout updates when padding changes
40
- */
41
- get paddingHasChanged(): boolean;
42
- /**
43
- * Current padding in pixels used for the composition
44
- * Calculated as the maximum padding required by all passes
45
- */
46
- get padding(): number;
47
- /**
48
- * Requests an update for the next frame
49
- * Will trigger a re-composition of all passes
50
- */
51
- requestUpdate(): void;
52
- /**
53
- * Composes all registered passes to create the final result
54
- *
55
- * @param renderer - WebGL renderer to use for composition
56
- * @param width - Width of the render target in pixels
57
- * @param height - Height of the render target in pixels
58
- * @param material - Input material containing the initial texture
59
- * @param canOverrideBlending - Whether blending can be overridden on the input material
60
- * @returns Material to use for rendering the composed result
61
- */
62
- compose(renderer: WebGLRenderer, width: number, height: number, material: Material, canOverrideBlending?: boolean): Material;
63
- /**
64
- * Cleans up resources used by the composer
65
- * Should be called when the composer is no longer needed
66
- */
67
- destroy(): void;
68
- /**
69
- * Checks if any passes are valuable (contribute meaningful effects)
70
- * @returns True if at least one pass is valuable
71
- */
72
- private hasValuablePasses;
73
- /**
74
- * Checks if any passes need an update
75
- * @returns True if at least one pass needs update
76
- */
77
- private hasPassesNeedingUpdate;
78
- /**
79
- * Calculates the maximum padding required by all passes
80
- * @returns Maximum padding value in pixels
81
- */
82
- private calculatePadding;
83
- /**
84
- * Updates the screen quad's padding based on dimensions
85
- *
86
- * @param width - Width of the render target in pixels
87
- * @param height - Height of the render target in pixels
88
- * @param padding - Padding value in pixels
89
- */
90
- private setScreenPadding;
91
- /**
92
- * Swaps the from and to render targets
93
- * Used for ping-pong rendering between passes
94
- */
95
- private reverseRenderTargets;
96
- }
97
- /**
98
- * Public interface for the UI composition system
99
- * Provides a simplified API for managing UI passes
100
- */
101
- export declare class UIComposer {
102
- private readonly raw;
103
- /**
104
- * Creates a new UI composer
105
- *
106
- * @param raw - Internal implementation that handles actual rendering
107
- */
108
- constructor(raw: UIComposerInternal);
109
- /**
110
- * Collection of all registered composition passes
111
- * Add passes to this collection to apply effects to the UI
112
- */
113
- get passes(): UIPass[];
114
- }
@@ -1,51 +0,0 @@
1
- import type { Material, WebGLRenderer } from "three";
2
- /**
3
- * Utility class for rendering a full-screen quad with optional padding
4
- * Used by the UI composition system to render passes
5
- */
6
- export declare class UIFullScreenQuad {
7
- private paddingHorizontalInternal;
8
- private paddingVerticalInternal;
9
- /**
10
- * Orthographic camera configured for device coordinates
11
- * Adjusted when padding changes to ensure correct rendering with padding
12
- */
13
- private readonly camera;
14
- /**
15
- * Creates a new UIFullScreenQuad
16
- *
17
- * @param paddingHorizontalInternal - Initial horizontal padding
18
- * @param paddingVerticalInternal - Initial vertical padding
19
- */
20
- constructor(paddingHorizontalInternal?: number, paddingVerticalInternal?: number);
21
- /**
22
- * Gets the current horizontal padding
23
- */
24
- get paddingHorizontal(): number;
25
- /**
26
- * Gets the current vertical padding
27
- */
28
- get paddingVertical(): number;
29
- /**
30
- * Sets the horizontal padding
31
- * Updates the camera projection when changed
32
- */
33
- set paddingHorizontal(value: number);
34
- /**
35
- * Sets the vertical padding
36
- * Updates the camera projection when changed
37
- */
38
- set paddingVertical(value: number);
39
- /**
40
- * Renders the fullscreen quad with the provided material
41
- *
42
- * @param renderer - The WebGL renderer to use
43
- * @param material - The material to apply to the fullscreen quad
44
- */
45
- render(renderer: WebGLRenderer, material: Material): void;
46
- /**
47
- * Updates the camera projection matrix to account for padding
48
- * Expands the camera frustum to include the padded area
49
- */
50
- private updateCameraTransform;
51
- }
@@ -1,43 +0,0 @@
1
- import type { Texture, WebGLRenderer } from "three";
2
- /**
3
- * Options passed to a UIPass when rendering
4
- */
5
- export interface UIPassRenderOptions {
6
- /** Width of the render target in pixels (without padding) */
7
- width: number;
8
- /** Height of the render target in pixels (without padding) */
9
- height: number;
10
- /** Current padding used for the render target */
11
- padding: number;
12
- }
13
- /**
14
- * Abstract base class for all UI composition passes
15
- *
16
- * UI passes are used to apply post-processing effects to the rendered UI
17
- * Each pass can be chained together in a UIComposer to create complex effects
18
- */
19
- export declare abstract class UIPass {
20
- /**
21
- * The amount of padding in pixels this pass requires
22
- * The compositor will use the maximum padding value from all passes
23
- */
24
- abstract get padding(): number;
25
- /**
26
- * Whether this pass needs to be updated in the next frame
27
- * Set to true when properties change to trigger a re-render
28
- */
29
- abstract get needsUpdate(): boolean;
30
- /**
31
- * Whether this pass contributes a meaningful effect
32
- * Passes that are not valuable may be skipped during composition
33
- */
34
- abstract get isValuable(): boolean;
35
- /**
36
- * Renders this pass
37
- *
38
- * @param renderer - The WebGL renderer to use
39
- * @param texture - The input texture from the previous pass
40
- * @param options - Render options including dimensions and padding
41
- */
42
- abstract render(renderer: WebGLRenderer, texture: Texture, options: UIPassRenderOptions): void;
43
- }
@@ -1,20 +0,0 @@
1
- import type { UIConstraintPower } from "../constraints/UIConstraintPower";
2
- import { UIHorizontalDistanceConstraint } from "../constraints/UIHorizontalDistanceConstraint";
3
- import { UIVerticalDistanceConstraint } from "../constraints/UIVerticalDistanceConstraint";
4
- import type { UIElement } from "../elements/UIElement";
5
- import type { UIOrientation } from "../miscellaneous/UIOrientation";
6
- export declare enum UIConstraintContainerDirection {
7
- FROM_LEFT_TOP = 0,
8
- FROM_LEFT_BOTTOM = 1
9
- }
10
- export interface UIConstraintContainerBuilderOptions {
11
- direction: UIConstraintContainerDirection;
12
- power: UIConstraintPower;
13
- orientation: UIOrientation;
14
- }
15
- export declare class UIConstraintContainerBuilder {
16
- static build(container: UIElement, elementOne: UIElement, elementTwo: UIElement, options?: Partial<UIConstraintContainerBuilderOptions>): {
17
- horizontalDistances: UIHorizontalDistanceConstraint[];
18
- verticalDistances: UIVerticalDistanceConstraint[];
19
- };
20
- }
@@ -1,24 +0,0 @@
1
- import type { UIConstraintPower } from "../constraints/UIConstraintPower";
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 { UIElement } from "../elements/UIElement";
7
- import type { UIOrientation } from "../miscellaneous/UIOrientation";
8
- export interface UIConstraintStackBuilderOptions {
9
- distance: number;
10
- keepProportions: boolean;
11
- keepAlignment: boolean;
12
- power: UIConstraintPower;
13
- orientation: UIOrientation;
14
- }
15
- export interface UIConstraintStackBuilderResult<TDistance, TProportion, TCenter> {
16
- distanceConstraints: TDistance[];
17
- proportionConstraints: TProportion[];
18
- alignmentConstraints: TCenter[];
19
- }
20
- export declare class UIConstraintStackBuilder {
21
- static buildHorizontal(elements: UIElement[], options: Partial<UIConstraintStackBuilderOptions>): UIConstraintStackBuilderResult<UIHorizontalDistanceConstraint, UIHorizontalProportionConstraint, UIVerticalDistanceConstraint>;
22
- static buildVertical(elements: UIElement[], options: Partial<UIConstraintStackBuilderOptions>): UIConstraintStackBuilderResult<UIVerticalDistanceConstraint, UIVerticalProportionConstraint, UIHorizontalDistanceConstraint>;
23
- private static buildStack;
24
- }
@@ -1,57 +0,0 @@
1
- /**
2
- * Defines the strength/priority levels for UI constraints.
3
- *
4
- * Constraints with higher power (lower index) take precedence over
5
- * those with lower power when the constraint solver can't satisfy all constraints.
6
- *
7
- * The enum values map to different strength configurations in the Kiwi.js solver:
8
- * - P0: Highest priority, "required" constraint that must be satisfied
9
- * - P1-P7: Decreasing levels of priority
10
- */
11
- export declare enum UIConstraintPower {
12
- /** Highest priority - must be satisfied (required constraint) */
13
- P0 = 0,
14
- /** Very high priority */
15
- P1 = 1,
16
- /** High priority */
17
- P2 = 2,
18
- /** Medium-high priority */
19
- P3 = 3,
20
- /** Medium priority */
21
- P4 = 4,
22
- /** Medium-low priority */
23
- P5 = 5,
24
- /** Low priority */
25
- P6 = 6,
26
- /** Lowest priority */
27
- P7 = 7
28
- }
29
- /**
30
- * Type guard to check if a value is a valid UIConstraintPower.
31
- *
32
- * @param obj - The value to check
33
- * @returns True if the value is a valid UIConstraintPower enum value
34
- */
35
- export declare function isUIConstraintPower(obj: unknown): obj is UIConstraintPower;
36
- /**
37
- * Resolves an optional power level to a definite value.
38
- *
39
- * @param power - The constraint power to resolve, or undefined
40
- * @returns The provided power level, or P0 (highest) if none was provided
41
- */
42
- export declare function resolvePower(power?: UIConstraintPower): UIConstraintPower;
43
- /**
44
- * Converts a UIConstraintPower enum value to a Kiwi.js strength value.
45
- *
46
- * The Kiwi.js constraint solver uses a three-tiered strength system.
47
- * This function maps our power levels to appropriate strength values:
48
- *
49
- * - P0: Maximum strength in all tiers (required constraint)
50
- * - P1-P2: Varying strengths in the first tier
51
- * - P3-P4: Varying strengths in the second tier
52
- * - P5-P7: Varying strengths in the third tier
53
- *
54
- * @param power - The constraint power to convert, or undefined
55
- * @returns A Kiwi.js strength value corresponding to the power level
56
- */
57
- export declare function convertPowerToStrength(power?: UIConstraintPower): number;
@@ -1,46 +0,0 @@
1
- import { Operator } from "@lume/kiwi";
2
- /**
3
- * Defines the type of relationship between values in a constraint.
4
- *
5
- * Maps directly to Kiwi.js Operators for the constraint solver.
6
- * Used to specify whether values should be equal, less than, or greater than each other.
7
- */
8
- export declare enum UIConstraintRule {
9
- /**
10
- * Values must be equal (x = y).
11
- * Creates an equality constraint in the solver.
12
- */
13
- EQUAL = 2,
14
- /**
15
- * Left value must be less than or equal to right value (x ≤ y).
16
- * Creates an inequality constraint in the solver.
17
- */
18
- LESS = 0,
19
- /**
20
- * Left value must be greater than or equal to right value (x ≥ y).
21
- * Creates an inequality constraint in the solver.
22
- */
23
- GREATER = 1
24
- }
25
- /**
26
- * Type guard to check if a value is a valid UIConstraintRule.
27
- *
28
- * @param obj - The value to check
29
- * @returns True if the value is a valid UIConstraintRule enum value
30
- */
31
- export declare function isUIConstraintRule(obj: unknown): obj is UIConstraintRule;
32
- /**
33
- * Resolves an optional rule to a definite value.
34
- *
35
- * @param rule - The constraint rule to resolve, or undefined
36
- * @returns The provided rule, or EQUAL if none was provided
37
- */
38
- export declare function resolveRule(rule?: UIConstraintRule): UIConstraintRule;
39
- /**
40
- * Converts a UIConstraintRule to the corresponding Kiwi.js Operator.
41
- * This function provides a safe way to convert between our enum and Kiwi's enum.
42
- *
43
- * @param rule - The constraint rule to convert, or undefined
44
- * @returns The corresponding Kiwi.js Operator value
45
- */
46
- export declare function convertRuleToOperator(rule?: UIConstraintRule): Operator;
@@ -1,13 +0,0 @@
1
- import type { WebGLRenderer } from "three";
2
- import { UILayer } from "./UILayer";
3
- export declare class UIFullScreenLayer extends UILayer {
4
- private targetScreenHeight?;
5
- constructor();
6
- get tergetScreenHeight(): number | undefined;
7
- set tergetScreenHeight(value: number | undefined);
8
- destroy(): void;
9
- render(renderer: WebGLRenderer, deltaTime: number): void;
10
- private calculateScale;
11
- private readonly onResize;
12
- private readonly onClick;
13
- }
@@ -1,7 +0,0 @@
1
- export declare enum UIBlending {
2
- NORMAL = 0,
3
- ADDITIVE = 1,
4
- SUBTRACTIVE = 2,
5
- MULTIPLY = 3,
6
- SCREEN = 4
7
- }
@@ -1,49 +0,0 @@
1
- export interface UITextStyle {
2
- color: string;
3
- fontFamily: string;
4
- fontSize: number;
5
- fontStyle: "normal" | "italic" | "oblique";
6
- fontWeight: "normal" | "bold" | "bolder" | "lighter" | number;
7
- lineHeight: number;
8
- enableShadow: boolean;
9
- shadowOffsetX: number;
10
- shadowOffsetY: number;
11
- shadowBlur: number;
12
- shadowColor: string;
13
- enableStroke: boolean;
14
- strokeColor: string;
15
- strokeWidth: number;
16
- }
17
- export interface UITextPadding {
18
- left: number;
19
- right: number;
20
- top: number;
21
- bottom: number;
22
- }
23
- export interface UITextSize {
24
- width: number;
25
- height: number;
26
- }
27
- export interface UIChunkMetrics {
28
- width: number;
29
- height: number;
30
- baseline: number;
31
- lineHeight: number;
32
- }
33
- export interface UITextChunk {
34
- text: string;
35
- style: UITextStyle;
36
- metrics: UIChunkMetrics;
37
- }
38
- export interface UITextLine {
39
- chunks: UITextChunk[];
40
- width: number;
41
- height: number;
42
- baseline: number;
43
- lineHeight: number;
44
- }
45
- export interface UITextSpan {
46
- text: string;
47
- style?: Partial<UITextStyle>;
48
- }
49
- export declare function isUITextSpan(obj?: unknown): obj is UITextSpan;
@@ -1 +0,0 @@
1
- export declare function testElement(elementX: number, elementY: number, elementWidth: number, elementHeight: number, xClick: number, yClick: number): boolean;
@@ -1,3 +0,0 @@
1
- import { type Object3D } from "three";
2
- import type { UIMicroInternal } from "./UIMicro";
3
- export declare function applyMicroTransformations(object: Object3D, micro: UIMicroInternal, x: number, y: number, width: number, height: number, padding: number): void;