laymur 0.10.2 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/README.md +20 -11
  2. package/dist/constraints/UIAspectConstraint.Internal.d.ts +6 -0
  3. package/dist/constraints/UIAspectConstraint.d.ts +9 -46
  4. package/dist/constraints/UIConstraint.d.ts +7 -27
  5. package/dist/constraints/UICustomConstraint.d.ts +13 -45
  6. package/dist/constraints/UIHeightConstraint.Internal.d.ts +6 -0
  7. package/dist/constraints/UIHeightConstraint.d.ts +8 -37
  8. package/dist/constraints/UIHorizontalDistanceConstraint.Internal.d.ts +11 -0
  9. package/dist/constraints/UIHorizontalDistanceConstraint.d.ts +16 -73
  10. package/dist/constraints/UIHorizontalProportionConstraint.Internal.d.ts +6 -0
  11. package/dist/constraints/UIHorizontalProportionConstraint.d.ts +8 -52
  12. package/dist/constraints/UISingleParameterConstraint.Internal.d.ts +12 -0
  13. package/dist/constraints/UISingleParameterConstraint.d.ts +24 -87
  14. package/dist/constraints/UIVerticalDistanceConstraint.Internal.d.ts +11 -0
  15. package/dist/constraints/UIVerticalDistanceConstraint.d.ts +12 -73
  16. package/dist/constraints/UIVerticalProportionConstraint.Internal.d.ts +6 -0
  17. package/dist/constraints/UIVerticalProportionConstraint.d.ts +8 -52
  18. package/dist/constraints/UIWidthConstraint.Internal.d.ts +6 -0
  19. package/dist/constraints/UIWidthConstraint.d.ts +8 -37
  20. package/dist/constraints/builders/UIConstraint2DBuilder.Internal.d.ts +45 -0
  21. package/dist/constraints/builders/UIConstraint2DBuilder.d.ts +35 -0
  22. package/dist/constraints/builders/UICoverConstraintBuilder.Internal.d.ts +13 -0
  23. package/dist/constraints/builders/UICoverConstraintBuilder.d.ts +29 -0
  24. package/dist/constraints/builders/UIFitConstraintBuilder.Internal.d.ts +13 -0
  25. package/dist/constraints/builders/UIFitConstraintBuilder.d.ts +29 -0
  26. package/dist/elements/UIAnchor.Internal.d.ts +9 -0
  27. package/dist/elements/UIAnchor.d.ts +17 -62
  28. package/dist/elements/UIAnimatedImage.Internal.d.ts +24 -0
  29. package/dist/elements/UIAnimatedImage.d.ts +38 -100
  30. package/dist/elements/UIDummy.Internal.d.ts +18 -0
  31. package/dist/elements/UIDummy.d.ts +51 -63
  32. package/dist/elements/UIElement.Internal.d.ts +11 -0
  33. package/dist/elements/UIElement.d.ts +28 -168
  34. package/dist/elements/UIGraphics.Internal.d.ts +7 -0
  35. package/dist/elements/UIGraphics.d.ts +29 -99
  36. package/dist/elements/UIImage.Internal.d.ts +7 -0
  37. package/dist/elements/UIImage.d.ts +18 -73
  38. package/dist/elements/UINineSlice.Internal.d.ts +23 -0
  39. package/dist/elements/UINineSlice.d.ts +45 -0
  40. package/dist/elements/UIProgress.Internal.d.ts +14 -0
  41. package/dist/elements/UIProgress.d.ts +26 -152
  42. package/dist/elements/UIScene.Internal.d.ts +43 -0
  43. package/dist/elements/UIScene.d.ts +29 -171
  44. package/dist/elements/UIText/UIText.Interfaces.d.ts +32 -0
  45. package/dist/elements/UIText/UIText.Internal.d.ts +26 -0
  46. package/dist/elements/UIText/UIText.Measuring.d.ts +49 -0
  47. package/dist/elements/UIText/UIText.Rendering.d.ts +19 -0
  48. package/dist/elements/UIText/UIText.d.ts +63 -0
  49. package/dist/index.d.ts +46 -46
  50. package/dist/index.js +4180 -4006
  51. package/dist/index.js.map +1 -1
  52. package/dist/index.min.js +1 -1
  53. package/dist/index.min.js.map +1 -1
  54. package/dist/layers/UIFullscreenLayer.d.ts +33 -43
  55. package/dist/layers/UILayer.Internal.d.ts +15 -0
  56. package/dist/layers/UILayer.d.ts +29 -184
  57. package/dist/miscellaneous/UIExpression.d.ts +35 -83
  58. package/dist/miscellaneous/UIInputEvent.d.ts +11 -8
  59. package/dist/miscellaneous/UIMode.d.ts +19 -21
  60. package/dist/miscellaneous/UIOrientation.d.ts +7 -22
  61. package/dist/miscellaneous/UIPriority.d.ts +16 -40
  62. package/dist/miscellaneous/UIRelation.d.ts +11 -31
  63. package/dist/miscellaneous/UITransparencyMode.d.ts +4 -21
  64. package/dist/miscellaneous/area/UIArea.d.ts +3 -0
  65. package/dist/miscellaneous/area/UIAreaCircle.d.ts +15 -0
  66. package/dist/miscellaneous/area/UIAreaPolygon.d.ts +12 -0
  67. package/dist/miscellaneous/area/UIAreaRectangle.d.ts +17 -0
  68. package/dist/miscellaneous/area/UIAreaRoundedRectangle.d.ts +21 -0
  69. package/dist/miscellaneous/asserts.d.ts +39 -82
  70. package/dist/miscellaneous/color/UIColor.Internal.d.ts +7 -0
  71. package/dist/miscellaneous/color/UIColor.d.ts +197 -0
  72. package/dist/miscellaneous/computeTransform.d.ts +18 -0
  73. package/dist/miscellaneous/generic-plane/UIGenericInstancedPlane.Internal.d.ts +10 -0
  74. package/dist/miscellaneous/generic-plane/UIGenericInstancedPlane.d.ts +36 -0
  75. package/dist/miscellaneous/generic-plane/UIGenericPlane.Internal.d.ts +5 -0
  76. package/dist/miscellaneous/generic-plane/UIGenericPlane.d.ts +23 -0
  77. package/dist/miscellaneous/generic-plane/UIGenericPlaneRegistry.Internal.d.ts +6 -0
  78. package/dist/miscellaneous/generic-plane/UIGenericPlaneRegistry.d.ts +27 -0
  79. package/dist/miscellaneous/generic-plane/shared.d.ts +22 -0
  80. package/dist/miscellaneous/mask-function/UIProgressMaskFunction.d.ts +9 -0
  81. package/dist/miscellaneous/mask-function/UIProgressMaskFunctionCircular.d.ts +21 -0
  82. package/dist/miscellaneous/mask-function/UIProgressMaskFunctionDirectional.d.ts +16 -0
  83. package/dist/miscellaneous/micro/UIMicro.Internal.d.ts +31 -0
  84. package/dist/miscellaneous/micro/UIMicro.d.ts +59 -0
  85. package/dist/miscellaneous/padding/UIPadding.Internal.d.ts +11 -0
  86. package/dist/miscellaneous/padding/UIPadding.d.ts +46 -0
  87. package/dist/miscellaneous/resize-policy/UIResizePolicy.d.ts +3 -0
  88. package/dist/miscellaneous/resize-policy/UIResizePolicyCross.d.ts +22 -0
  89. package/dist/miscellaneous/resize-policy/UIResizePolicyCrossInverted.d.ts +22 -0
  90. package/dist/miscellaneous/resize-policy/UIResizePolicyFixedHeight.d.ts +22 -0
  91. package/dist/miscellaneous/resize-policy/UIResizePolicyFixedWidth.d.ts +22 -0
  92. package/dist/miscellaneous/resize-policy/UIResizePolicyNone.d.ts +5 -0
  93. package/dist/miscellaneous/text-span/UITextSpan.Internal.d.ts +8 -0
  94. package/dist/miscellaneous/text-span/UITextSpan.d.ts +14 -0
  95. package/dist/miscellaneous/text-style/UITextStyle.Internal.d.ts +48 -0
  96. package/dist/miscellaneous/text-style/UITextStyle.d.ts +85 -0
  97. package/dist/miscellaneous/texture/UITextureView.Internal.d.ts +54 -0
  98. package/dist/miscellaneous/texture/UITextureView.d.ts +61 -0
  99. package/dist/wrappers/UIInputWrapper.Internal.d.ts +17 -0
  100. package/dist/wrappers/UIInputWrapper.d.ts +13 -0
  101. package/dist/wrappers/UISceneWrapper.Internal.d.ts +13 -0
  102. package/dist/wrappers/UISceneWrapper.d.ts +12 -19
  103. package/dist/wrappers/UISolverWrapper.Internal.d.ts +49 -0
  104. package/dist/wrappers/UISolverWrapper.d.ts +2 -1
  105. package/package.json +3 -1
  106. package/dist/builders/UIConstraint2DBuilder.d.ts +0 -130
  107. package/dist/builders/UICoverConstraintBuilder.d.ts +0 -56
  108. package/dist/builders/UIFitConstraintBuilder.d.ts +0 -56
  109. package/dist/composer/UIComposer.d.ts +0 -0
  110. package/dist/composer/UIFullscreenQuad.d.ts +0 -0
  111. package/dist/composer/UIPass.d.ts +0 -0
  112. package/dist/elements/UINineSline.d.ts +0 -139
  113. package/dist/elements/UISpine.d.ts +0 -54
  114. package/dist/elements/UIText.d.ts +0 -149
  115. package/dist/miscellaneous/UIColor.d.ts +0 -245
  116. package/dist/miscellaneous/UIGenericInstancedPlane.d.ts +0 -32
  117. package/dist/miscellaneous/UIMicro.d.ts +0 -148
  118. package/dist/miscellaneous/UIMicroAnchorMode.d.ts +0 -9
  119. package/dist/miscellaneous/UINineSliceBorder.d.ts +0 -21
  120. package/dist/miscellaneous/UIResizePolicy.d.ts +0 -21
  121. package/dist/miscellaneous/UIResizePolicyCross.d.ts +0 -14
  122. package/dist/miscellaneous/UIResizePolicyCrossInverted.d.ts +0 -14
  123. package/dist/miscellaneous/UIResizePolicyFixedHeight.d.ts +0 -24
  124. package/dist/miscellaneous/UIResizePolicyFixedWidth.d.ts +0 -27
  125. package/dist/miscellaneous/UIResizePolicyNone.d.ts +0 -7
  126. package/dist/miscellaneous/UISceneWrapperClientAPI.d.ts +0 -12
  127. package/dist/miscellaneous/UITextPadding.d.ts +0 -7
  128. package/dist/miscellaneous/UITextSpan.d.ts +0 -6
  129. package/dist/miscellaneous/UITextStyle.d.ts +0 -20
  130. package/dist/miscellaneous/textInterfaces.d.ts +0 -19
  131. package/dist/miscellaneous/textTools.d.ts +0 -12
@@ -1,117 +1,47 @@
1
+ import type { WebGLRenderer } from "three";
1
2
  import type { UILayer } from "../layers/UILayer";
2
- import { UIColor } from "../miscellaneous/UIColor";
3
- import type { UIMode } from "../miscellaneous/UIMode";
3
+ import { UIColor } from "../miscellaneous/color/UIColor";
4
4
  import { UIElement } from "./UIElement";
5
- /**
6
- * Configuration options for creating a UIGraphics element.
7
- */
8
- export interface UIGraphicsOptions {
9
- /** X position of the element */
10
- x: number;
11
- /** Y position of the element */
12
- y: number;
13
- /** Width of the canvas (default: 512) */
14
- width: number;
15
- /** Height of the canvas (default: 512) */
16
- height: number;
17
- /** Color tint applied to the graphics */
18
- color: UIColor;
19
- /** Default UIMode */
20
- mode: UIMode;
21
- }
22
- /**
23
- * UI element for drawing graphics using 2D canvas API.
24
- *
25
- * UIGraphics uses an OffscreenCanvas for rendering 2D graphics and converts it
26
- * to a Three.js texture for display. It provides access to the canvas context
27
- * for custom drawing operations.
28
- */
5
+ import type { UIGraphicsOptions } from "./UIGraphics.Internal";
6
+ /** Canvas-based 2D drawing element */
29
7
  export declare class UIGraphics extends UIElement {
30
- /** OffscreenCanvas for rendering graphics */
8
+ /** Multiplicative tint. Alpha channel controls opacity. */
9
+ readonly color: UIColor;
31
10
  private readonly canvas;
32
- /** 2D rendering context */
33
- private readonly ctx;
34
- /** Three.js texture created from the canvas */
35
- private readonly canvasTexture;
36
- /** Internal storage for the color tint */
37
- private readonly colorInternal;
11
+ private readonly context;
12
+ private readonly texture;
38
13
  /**
39
14
  * Creates a new UIGraphics instance.
40
15
  *
41
- * @param layer - The UI layer that contains this graphics element
42
- * @param options - Configuration options for the graphics element
16
+ * @param layer - Layer containing this element
17
+ * @param options - Configuration options
43
18
  */
44
19
  constructor(layer: UILayer, options?: Partial<UIGraphicsOptions>);
45
20
  /**
46
- * Gets the current color tint applied to the graphics.
47
- */
48
- get color(): UIColor;
49
- /**
50
- * Sets the color tint applied to the graphics.
51
- */
52
- set color(value: UIColor);
53
- /**
54
- * Clears the canvas with optional fill color.
21
+ * Clears canvas. Optionally fills with color.
55
22
  *
56
- * @param fillColor - Optional color to fill after clearing
57
- */
58
- clear(fillColor?: UIColor): this;
59
- /**
60
- * Draws a rectangle on the canvas.
61
- */
62
- rect(x: number, y: number, width: number, height: number): this;
63
- /**
64
- * Draws a filled rectangle on the canvas.
65
- */
66
- fillRect(x: number, y: number, width: number, height: number): this;
67
- /**
68
- * Draws a stroked rectangle on the canvas.
69
- */
70
- strokeRect(x: number, y: number, width: number, height: number): this;
71
- /**
72
- * Draws a circle on the canvas.
73
- */
74
- circle(x: number, y: number, radius: number): this;
75
- /**
76
- * Begins a new path.
23
+ * @param color - Fill color after clearing
77
24
  */
78
- beginPath(): this;
25
+ clear(color?: UIColor): this;
26
+ /** Draws filled rectangle */
27
+ drawRect(x: number, y: number, width: number, height: number, color: UIColor): this;
28
+ /** Draws filled circle */
29
+ drawCircle(x: number, y: number, radius: number, color: UIColor): this;
79
30
  /**
80
- * Closes the current path.
81
- */
82
- closePath(): this;
83
- /**
84
- * Fills the current path.
85
- */
86
- fill(): this;
87
- /**
88
- * Strokes the current path.
89
- */
90
- stroke(): this;
91
- /**
92
- * Moves the path to a point.
93
- */
94
- moveTo(x: number, y: number): this;
95
- /**
96
- * Draws a line to a point.
97
- */
98
- lineTo(x: number, y: number): this;
99
- /**
100
- * Sets the fill style.
101
- */
102
- setFillStyle(style: UIColor | CanvasGradient | CanvasPattern): this;
103
- /**
104
- * Sets the stroke style.
105
- */
106
- setStrokeStyle(style: UIColor | CanvasGradient | CanvasPattern): this;
107
- /**
108
- * Sets the line width.
31
+ * Draws filled arc.
32
+ *
33
+ * @param startAngle - Start angle in radians
34
+ * @param endAngle - End angle in radians
109
35
  */
110
- setLineWidth(width: number): this;
36
+ drawArc(x: number, y: number, radius: number, startAngle: number, endAngle: number, color: UIColor): this;
111
37
  /**
112
- * Destroys the graphics element by cleaning up resources.
38
+ * Draws connected line segments.
39
+ *
40
+ * @param points - Array of [x, y] pairs
41
+ * @param lineWidth - Line width in pixels
113
42
  */
43
+ drawPolyline(points: [number, number][], color: UIColor, lineWidth?: number): this;
44
+ /** Removes element and frees resources */
114
45
  destroy(): void;
115
- /** Event handler for when the color changes */
116
- private readonly onColorChange;
46
+ protected onWillRender(renderer: WebGLRenderer, deltaTime: number): void;
117
47
  }
@@ -0,0 +1,7 @@
1
+ import type { UIColorConfig } from "../miscellaneous/color/UIColor.Internal";
2
+ import type { UIElementOptions } from "./UIElement.Internal";
3
+ /** Configuration options for UIImage */
4
+ export interface UIImageOptions extends UIElementOptions {
5
+ /** Multiplicative tint */
6
+ color: UIColorConfig;
7
+ }
@@ -1,83 +1,28 @@
1
- import type { Texture } from "three";
2
1
  import type { UILayer } from "../layers/UILayer";
3
- import { UIColor } from "../miscellaneous/UIColor";
4
- import type { UIMode } from "../miscellaneous/UIMode";
2
+ import { UIColor } from "../miscellaneous/color/UIColor";
3
+ import { UITextureView } from "../miscellaneous/texture/UITextureView";
4
+ import type { UITextureConfig } from "../miscellaneous/texture/UITextureView.Internal";
5
5
  import { UIElement } from "./UIElement";
6
- /**
7
- * Configuration options for creating a UIImage element.
8
- */
9
- export interface UIImageOptions {
10
- /** X position of the element */
11
- x: number;
12
- /** Y position of the element */
13
- y: number;
14
- /** Width of the element */
15
- width: number;
16
- /** Height of the element */
17
- height: number;
18
- /** Color tint applied to the image */
19
- color: UIColor;
20
- /** Default UIMode */
21
- mode: UIMode;
22
- }
23
- /**
24
- * UI element for displaying textured images.
25
- *
26
- * UIImage is a concrete implementation of UIElement that renders a textured
27
- * image using shader-based planes. It automatically sizes itself
28
- * to match the texture dimensions and provides control over visual properties
29
- * such as color tinting.
30
- *
31
- * @see {@link UIElement} - Base class providing UI element functionality
32
- * @see {@link Texture} - Three.js texture for image data
33
- */
6
+ import type { UIImageOptions } from "./UIImage.Internal";
7
+ /** Textured image element */
34
8
  export declare class UIImage extends UIElement {
35
- /** Internal storage for the current texture */
36
- private textureInternal;
37
- /** Internal storage for the color tint */
38
- private readonly colorInternal;
9
+ /** Texture displayed by this image */
10
+ readonly texture: UITextureView;
11
+ /** Multiplicative tint. Alpha channel controls opacity. */
12
+ readonly color: UIColor;
13
+ private readonly textureTransform;
39
14
  /**
40
15
  * Creates a new UIImage instance.
41
16
  *
42
- * The image will automatically size itself to match the texture's dimensions.
43
- * All options have default values if not specified.
17
+ * Defaults size to texture dimensions if width and height not provided.
44
18
  *
45
- * @param layer - The UI layer that contains this image
46
- * @param texture - The Three.js texture to display
47
- * @param options - Configuration options for the image
48
- * @throws Will throw an error if the texture dimensions are not valid positive numbers
49
- */
50
- constructor(layer: UILayer, texture: Texture, options?: Partial<UIImageOptions>);
51
- /**
52
- * Gets the current texture being displayed.
53
- * @returns The current Three.js texture
54
- */
55
- get texture(): Texture;
56
- /**
57
- * Gets the current color tint applied to the image.
58
- * @returns The UIColor instance
59
- */
60
- get color(): UIColor;
61
- /**
62
- * Sets a new texture for the image.
63
- *
64
- * When setting a new texture, the image will automatically resize to match
65
- * the new texture's dimensions.
66
- *
67
- * @param value - The new Three.js texture to display
68
- * @throws Will throw an error if the texture dimensions are not valid positive numbers
69
- * @see {@link assertValidPositiveNumber}
70
- */
71
- set texture(value: Texture);
72
- /**
73
- * Sets the color tint applied to the image.
74
- * @param value - The UIColor instance
75
- */
76
- set color(value: UIColor);
77
- /**
78
- * Destroys the UI image by cleaning up color event listeners and all associated resources.
19
+ * @param layer - Layer containing this image
20
+ * @param texture - Texture to display
21
+ * @param options - Configuration options
79
22
  */
23
+ constructor(layer: UILayer, texture: UITextureConfig, options?: Partial<UIImageOptions>);
24
+ /** Removes image and frees resources */
80
25
  destroy(): void;
81
- /** Event handler for when the color changes */
82
- private readonly onColorChange;
26
+ protected updatePlaneTransform(): void;
27
+ private readonly onTextureDimensionsChanged;
83
28
  }
@@ -0,0 +1,23 @@
1
+ import type { UIColorConfig } from "../miscellaneous/color/UIColor.Internal";
2
+ import type { UIPaddingConfig } from "../miscellaneous/padding/UIPadding.Internal";
3
+ import type { UIElementOptions } from "./UIElement.Internal";
4
+ /** Controls how sliceRegions values are interpreted */
5
+ export declare enum UINineSliceRegionMode {
6
+ /** sliceRegions in normalized coordinates (0 to 1) */
7
+ NORMALIZED = 0,
8
+ /** sliceRegions in world units */
9
+ WORLD = 1
10
+ }
11
+ /** Configuration options for UINineSlice */
12
+ export interface UINineSliceOptions extends UIElementOptions {
13
+ /** Multiplicative tint */
14
+ color: UIColorConfig;
15
+ /** Border size in normalized texture coordinates (0 to 1) */
16
+ sliceBorders: UIPaddingConfig;
17
+ /** Region size. Interpretation depends on regionMode. */
18
+ sliceRegions: UIPaddingConfig;
19
+ /** How sliceRegions values are interpreted */
20
+ regionMode: UINineSliceRegionMode;
21
+ }
22
+ export declare const NINE_SLICE_DEFAULT_BORDER = 0.1;
23
+ export declare const NINE_SLICE_DEFAULT_REGION_MODE = UINineSliceRegionMode.WORLD;
@@ -0,0 +1,45 @@
1
+ import type { UILayer } from "../layers/UILayer";
2
+ import { UIColor } from "../miscellaneous/color/UIColor";
3
+ import { UIPadding } from "../miscellaneous/padding/UIPadding";
4
+ import { UITextureView } from "../miscellaneous/texture/UITextureView";
5
+ import type { UITextureConfig } from "../miscellaneous/texture/UITextureView.Internal";
6
+ import { UIElement } from "./UIElement";
7
+ import type { UINineSliceOptions } from "./UINineSlice.Internal";
8
+ import { UINineSliceRegionMode } from "./UINineSlice.Internal";
9
+ /** Scalable textured image preserving border regions */
10
+ export declare class UINineSlice extends UIElement {
11
+ /** Texture displayed by this element */
12
+ readonly texture: UITextureView;
13
+ /** Multiplicative tint. Alpha channel controls opacity. */
14
+ readonly color: UIColor;
15
+ /** Border size in normalized texture coordinates (0 to 1) */
16
+ readonly sliceBorders: UIPadding;
17
+ /** Region size. Interpretation depends on regionMode. */
18
+ readonly sliceRegions: UIPadding;
19
+ private regionModeInternal;
20
+ private regionModeDirty;
21
+ private readonly textureTransform;
22
+ private readonly sliceBordersVector;
23
+ private readonly sliceRegionsVector;
24
+ private lastWidth;
25
+ private lastHeight;
26
+ /**
27
+ * Creates a new UINineSlice instance.
28
+ *
29
+ * Defaults size to texture dimensions if width and height not provided.
30
+ *
31
+ * @param layer - Layer containing this element
32
+ * @param texture - Texture to display
33
+ * @param options - Configuration options
34
+ */
35
+ constructor(layer: UILayer, texture: UITextureConfig, options?: Partial<UINineSliceOptions>);
36
+ /** Controls how sliceRegions values are interpreted */
37
+ get regionMode(): UINineSliceRegionMode;
38
+ /** Controls how sliceRegions values are interpreted */
39
+ set regionMode(value: UINineSliceRegionMode);
40
+ protected updatePlaneTransform(): void;
41
+ private calculateSliceBordersForShader;
42
+ private calculateSliceRegionsForShader;
43
+ private checkDimensionsDirty;
44
+ private setDimensionsDirtyFalse;
45
+ }
@@ -0,0 +1,14 @@
1
+ import type { UIColorConfig } from "../miscellaneous/color/UIColor.Internal";
2
+ import type { UIProgressMaskFunction } from "../miscellaneous/mask-function/UIProgressMaskFunction";
3
+ import type { UIElementOptions } from "./UIElement.Internal";
4
+ /** Configuration options for UIProgress */
5
+ export interface UIProgressOptions extends UIElementOptions {
6
+ /** Multiplicative tint */
7
+ color: UIColorConfig;
8
+ /** Function controlling fill direction and shape */
9
+ maskFunction: UIProgressMaskFunction;
10
+ /** Progress from 0 (empty) to 1 (full) */
11
+ progress: number;
12
+ }
13
+ export declare const PROGRESS_DEFAULT_VALUE = 1;
14
+ export declare function simplifyGLSLSource(source: string): string;
@@ -1,162 +1,36 @@
1
- import { Texture } from "three";
1
+ import type { Texture } from "three";
2
2
  import type { UILayer } from "../layers/UILayer";
3
- import { UIColor } from "../miscellaneous/UIColor";
4
- import type { UIMode } from "../miscellaneous/UIMode";
3
+ import { UIColor } from "../miscellaneous/color/UIColor";
4
+ import type { UIProgressMaskFunction } from "../miscellaneous/mask-function/UIProgressMaskFunction";
5
+ import { UITextureView } from "../miscellaneous/texture/UITextureView";
5
6
  import { UIElement } from "./UIElement";
6
- /**
7
- * Predefined mask functions that control how the progress bar fills.
8
- * Each function defines a different fill pattern using GLSL shader code.
9
- */
10
- export declare enum UIProgressMaskFunction {
11
- /** Fill horizontally from left to right (or right to left if inverse) */
12
- HORIZONTAL = "float calculateMask() {\n return step((direction * io_UV.x + (1.0 - direction) * 0.5), progress);\n }",
13
- /** Fill vertically from bottom to top (or top to bottom if inverse) */
14
- VERTICAL = "float calculateMask() {\n return step((direction * io_UV.y + (1.0 - direction) * 0.5), progress);\n }",
15
- /** Fill diagonally from bottom-left to top-right */
16
- DIAGONAL = "float calculateMask() {\n float d = (io_UV.x + io_UV.y) * (0.1);\n return step((direction * d + (1.0 - direction) * 0.5), progress);\n }",
17
- /** Fill in a circular pattern around the center, starting from the left */
18
- CIRCLE_LEFT = "float calculateMask() {\n vec2 p = io_UV - 0.5;\n float angle = atan(p.y, p.x);\n angle = (angle + 3.14159265) / 3.14159265;\n angle *= 0.5;\n return step((direction * angle + (1.0 - direction) * 0.5), progress);\n }",
19
- /** Fill in a circular pattern around the center, starting from the top */
20
- CIRCLE_TOP = "float calculateMask() {\n vec2 p = io_UV - 0.5;\n float angle = atan(p.y, p.x);\n angle = (angle + 3.14159265) / (2.0 * 3.14159265);\n angle = mod(angle + 0.25, 1.0);\n return step((direction * angle + (1.0 - direction) * 0.5), progress);\n }"
21
- }
22
- /**
23
- * Configuration options for creating a UIProgress element.
24
- */
25
- export interface UIProgressOptions {
26
- /** X position of the element */
27
- x: number;
28
- /** Y position of the element */
29
- y: number;
30
- /** Optional background texture (if not provided, default texture is used) */
31
- backgroundTexture: Texture;
32
- /** Overall color tint applied to the entire progress bar */
33
- color: UIColor;
34
- /** Foreground color tint applied to the filled portion */
35
- foregroundColor: UIColor;
36
- /** Background color tint applied to the unfilled portion */
37
- backgroundColor: UIColor;
38
- /** Mask function that defines how the progress bar fills (predefined enum or custom GLSL code) */
39
- maskFunction: UIProgressMaskFunction | string;
40
- /** Progress value between 0.0 (empty) and 1.0 (full) */
41
- progress: number;
42
- /** Whether to fill in reverse direction (true for reverse, false for normal) */
43
- inverseDirection: boolean;
44
- /** Default UIMode */
45
- mode: UIMode;
46
- }
47
- /**
48
- * Progress bar UI element with customizable fill direction and appearance.
49
- *
50
- * UIProgress displays a progress bar that can be filled in various directions
51
- * (horizontal, vertical, or at custom angles). It supports separate background
52
- * and foreground textures with independent color tinting and opacity control.
53
- *
54
- * The progress value ranges from 0.0 (empty) to 1.0 (completely filled).
55
- * The fill direction can be controlled both by angle and forward/reverse direction.
56
- */
7
+ import type { UIProgressOptions } from "./UIProgress.Internal";
8
+ /** Progress bar with customizable fill direction */
57
9
  export declare class UIProgress extends UIElement {
58
- /** Internal storage for the foreground texture */
59
- private foregroundTextureInternal;
60
- /** Internal storage for the optional background texture */
61
- private backgroundTextureInternal?;
62
- /** Internal storage for the overall color tint */
63
- private readonly colorInternal;
64
- /** Internal storage for the foreground color tint */
65
- private readonly foregroundColorInternal;
66
- /** Internal storage for the background color tint */
67
- private readonly backgroundColorInternal;
68
- /** Internal storage for the current progress value */
10
+ /** Texture displayed by this element */
11
+ readonly texture: UITextureView;
12
+ /** Multiplicative tint. Alpha channel controls opacity. */
13
+ readonly color: UIColor;
14
+ /** Function controlling fill direction and shape */
15
+ readonly maskFunction: UIProgressMaskFunction;
16
+ private readonly textureTransform;
17
+ private readonly textureResolution;
69
18
  private progressInternal;
70
- /** Internal storage for the fill direction flag */
71
- private inverseDirectionInternal;
19
+ private dirty;
72
20
  /**
73
- * Creates a new progress bar UI element.
21
+ * Creates a new UIProgress instance.
74
22
  *
75
- * @param layer - The UI layer to add this element to
76
- * @param foregroundTexture - The texture used for the progress fill
77
- * @param options - Configuration options for the progress bar
78
- */
79
- constructor(layer: UILayer, foregroundTexture: Texture, options?: Partial<UIProgressOptions>);
80
- /**
81
- * Gets the foreground (fill) texture.
82
- * @returns The foreground texture
83
- */
84
- get foregroundTexture(): Texture;
85
- /**
86
- * Gets the background texture.
87
- * @returns The background texture, or undefined if none is set
88
- */
89
- get backgroundTexture(): Texture | undefined;
90
- /**
91
- * Gets the color tint.
92
- * @returns The UIColor instance
93
- */
94
- get color(): UIColor;
95
- /**
96
- * Gets the foreground color tint.
97
- * @returns The foreground color UIColor instance
98
- */
99
- get foregroundColor(): UIColor;
100
- /**
101
- * Gets the background color tint.
102
- * @returns The background color UIColor instance
103
- */
104
- get backgroundColor(): UIColor;
105
- /**
106
- * Gets the current progress value.
107
- * @returns Progress value between 0.0 (empty) and 1.0 (full)
108
- */
109
- get progress(): number;
110
- /**
111
- * Gets whether the progress fills in reverse direction.
112
- * @returns True if filling in reverse, false if filling forward
113
- */
114
- get inverseDirection(): boolean;
115
- /**
116
- * Sets the foreground (fill) texture.
23
+ * Defaults size to texture dimensions if width and height not provided.
117
24
  *
118
- * When setting a new texture, the progress bar will automatically resize
119
- * to match the new texture's dimensions.
120
- *
121
- * @param value - The new foreground texture
122
- * @throws Will throw an error if the texture dimensions are not valid positive numbers
123
- */
124
- set foregroundTexture(value: Texture);
125
- /**
126
- * Sets the background texture.
127
- * @param value - The background texture, or undefined to remove background
128
- */
129
- set backgroundTexture(value: Texture | undefined);
130
- /**
131
- * Sets the color tint.
132
- * @param value - The UIColor instance
133
- */
134
- set color(value: UIColor);
135
- /**
136
- * Sets the foreground color tint.
137
- * @param value - The foreground color UIColor instance
138
- */
139
- set foregroundColor(value: UIColor);
140
- /**
141
- * Sets the background color tint.
142
- * @param value - The background color UIColor instance
143
- */
144
- set backgroundColor(value: UIColor);
145
- /**
146
- * Sets the progress fill direction.
147
- * @param value - True for reverse direction, false for forward
148
- */
149
- set inverseDirection(value: boolean);
150
- /**
151
- * Sets the progress value.
152
- * @param value - Progress value between 0.0 (empty) and 1.0 (full)
25
+ * @param layer - Layer containing this element
26
+ * @param texture - Texture to display
27
+ * @param options - Configuration options
153
28
  */
29
+ constructor(layer: UILayer, texture: Texture, options?: Partial<UIProgressOptions>);
30
+ /** Progress from 0 (empty) to 1 (full) */
31
+ get progress(): number;
32
+ /** Progress from 0 (empty) to 1 (full). Clamped by shader. */
154
33
  set progress(value: number);
155
- destroy(): void;
156
- /** Event handler for when the overall color changes */
157
- private readonly onColorChange;
158
- /** Event handler for when the foreground color changes */
159
- private readonly onForegroundColorChange;
160
- /** Event handler for when the background color changes */
161
- private readonly onBackgroundColorChange;
34
+ protected updatePlaneTransform(): void;
35
+ private readonly onTextureDimensionsChanged;
162
36
  }
@@ -0,0 +1,43 @@
1
+ import type { Camera, Scene } from "three";
2
+ import { UIColor } from "../miscellaneous/color/UIColor";
3
+ import type { UIColorConfig } from "../miscellaneous/color/UIColor.Internal";
4
+ import type { UIElementOptions } from "./UIElement.Internal";
5
+ /** Controls when scene re-renders */
6
+ export declare enum UISceneUpdateMode {
7
+ /** Re-render every frame */
8
+ EACH_FRAME = 1,
9
+ /** Re-render every other frame */
10
+ EVERY_SECOND_FRAME = 2,
11
+ /** Re-render when scene, camera, or updateMode changes */
12
+ ON_PROPERTIES_CHANGE = 3,
13
+ /** Re-render when dimensions or resolutionFactor changes */
14
+ ON_DIMENSIONS_CHANGE = 4,
15
+ /** Re-render only via requestUpdate() */
16
+ MANUAL = 5
17
+ }
18
+ /** Configuration options for UIScene */
19
+ export interface UISceneOptions extends UIElementOptions {
20
+ /** Multiplicative tint */
21
+ color: UIColorConfig;
22
+ /** Three.js scene to render */
23
+ scene: Scene;
24
+ /** Camera used for rendering */
25
+ camera: Camera;
26
+ /** When to re-render */
27
+ updateMode: UISceneUpdateMode;
28
+ /** Render target resolution multiplier. Range 0.1 to 2.0. */
29
+ resolutionFactor: number;
30
+ /** Background color */
31
+ clearColor: UIColorConfig;
32
+ /** Whether to use depth buffer */
33
+ enableDepthBuffer: boolean;
34
+ }
35
+ export declare const SCENE_DEFAULT_RESOLUTION_FACTOR = 0.5;
36
+ export declare const SCENE_MIN_RESOLUTION_FACTOR = 0.1;
37
+ export declare const SCENE_MAX_RESOLUTION_FACTOR = 2;
38
+ export declare const SCENE_DEFAULT_CAMERA_FOV = 60;
39
+ export declare const SCENE_DEFAULT_CAMERA_NEAR = 0.1;
40
+ export declare const SCENE_DEFAULT_CAMERA_FAR = 100;
41
+ export declare const SCENE_DEFAULT_UPDATE_MODE = UISceneUpdateMode.ON_PROPERTIES_CHANGE;
42
+ export declare const SCENE_DEFAULT_CLEAR_COLOR: UIColor;
43
+ export declare const SCENE_DEFAULT_USE_DEPTH = true;