laymur 0.1.44 → 0.1.46
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/Constraints/UIAspectConstraint.d.ts +36 -3
- package/dist/Constraints/UIConstraint.d.ts +23 -4
- package/dist/Constraints/UIConstraintPower.d.ts +44 -0
- package/dist/Constraints/UIConstraintRule.d.ts +37 -0
- package/dist/Constraints/UICoverConstraint.d.ts +48 -3
- package/dist/Constraints/UIFitConstraint.d.ts +48 -3
- package/dist/Constraints/UIHeightConstraint.d.ts +35 -3
- package/dist/Constraints/UIHorizontalDistanceConstraint.d.ts +38 -3
- package/dist/Constraints/UIHorizontalProportionConstraint.d.ts +36 -3
- package/dist/Constraints/UIVerticalDistanceConstraint.d.ts +38 -3
- package/dist/Constraints/UIVerticalProportionConstraint.d.ts +36 -3
- package/dist/Constraints/UIWidthConstraint.d.ts +35 -3
- package/dist/Elements/UIDummy.d.ts +15 -0
- package/dist/Elements/UIElement.d.ts +90 -3
- package/dist/Elements/UIImage.d.ts +33 -0
- package/dist/Elements/UIProgress.d.ts +84 -0
- package/dist/Elements/UIScene.d.ts +90 -0
- package/dist/Elements/UIText.d.ts +51 -1
- package/dist/Miscellaneous/UIMicro.d.ts +142 -0
- package/dist/Miscellaneous/UIMode.d.ts +20 -0
- package/dist/Miscellaneous/UIOrientation.d.ts +30 -0
- package/dist/Miscellaneous/symbols.d.ts +1 -18
- package/dist/Miscellaneous/textTools.d.ts +1 -1
- package/dist/index.d.ts +1 -3
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/Builders/UICommonDoubleElementConstraintDescriptionInterfaces.d.ts +0 -55
- package/dist/Builders/UICommonSingleElementConstraintDescriptionInterfaces.d.ts +0 -27
- package/dist/Builders/UIConstraintBuilder.d.ts +0 -14
- package/dist/Builders/UIElementBuilder.d.ts +0 -7
- package/dist/Builders/UIElementBuilderInterfaces.d.ts +0 -27
- /package/dist/{Elements → Miscellaneous}/UITextInterfaces.d.ts +0 -0
|
@@ -1,23 +1,55 @@
|
|
|
1
1
|
import type { UIElement } from "../Elements/UIElement";
|
|
2
|
-
import { disableConstraintSymbol, enableConstraintSymbol } from "../Miscellaneous/symbols";
|
|
3
2
|
import { UIOrientation } from "../Miscellaneous/UIOrientation";
|
|
4
3
|
import { UIConstraint } from "./UIConstraint";
|
|
5
4
|
import type { UIConstraintPower } from "./UIConstraintPower";
|
|
6
5
|
import type { UIConstraintRule } from "./UIConstraintRule";
|
|
6
|
+
/**
|
|
7
|
+
* Configuration options for width constraints.
|
|
8
|
+
*/
|
|
7
9
|
export interface UIWidthOptions {
|
|
10
|
+
/** The fixed width value to constrain the element to */
|
|
8
11
|
width: number;
|
|
12
|
+
/** Priority level for this constraint */
|
|
9
13
|
power: UIConstraintPower;
|
|
14
|
+
/** Rule for the constraint relationship (equal, less than, greater than) */
|
|
10
15
|
rule: UIConstraintRule;
|
|
16
|
+
/** Screen orientation when this constraint should be active */
|
|
11
17
|
orientation: UIOrientation;
|
|
12
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Constraint that enforces a specific width for a UI element.
|
|
21
|
+
*
|
|
22
|
+
* This constraint can be configured to require an exact width
|
|
23
|
+
* or set minimum/maximum width limits using different rules.
|
|
24
|
+
*/
|
|
13
25
|
export declare class UIWidthConstraint extends UIConstraint {
|
|
14
26
|
private readonly element;
|
|
27
|
+
/** The configuration options for this constraint */
|
|
15
28
|
private readonly options;
|
|
29
|
+
/** The Kiwi.js constraint object */
|
|
16
30
|
private constraint?;
|
|
31
|
+
/**
|
|
32
|
+
* Creates a new width constraint.
|
|
33
|
+
*
|
|
34
|
+
* @param element - The UI element to constrain
|
|
35
|
+
* @param options - Configuration options
|
|
36
|
+
*/
|
|
17
37
|
constructor(element: UIElement, options?: Partial<UIWidthOptions>);
|
|
38
|
+
/**
|
|
39
|
+
* Destroys this constraint, removing it from the constraint system.
|
|
40
|
+
*/
|
|
18
41
|
destroy(): void;
|
|
19
|
-
|
|
20
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Builds and adds the width constraint to the constraint solver.
|
|
44
|
+
*
|
|
45
|
+
* Creates a constraint that enforces the element's width based
|
|
46
|
+
* on the specified rule (equal to, less than, or greater than).
|
|
47
|
+
*
|
|
48
|
+
*/
|
|
21
49
|
protected buildConstraints(): void;
|
|
50
|
+
/**
|
|
51
|
+
* Removes the width constraint from the constraint solver.
|
|
52
|
+
*
|
|
53
|
+
*/
|
|
22
54
|
protected destroyConstraints(): void;
|
|
23
55
|
}
|
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
import type { UILayer } from "../Layers/UILayer";
|
|
2
2
|
import { UIElement } from "./UIElement";
|
|
3
|
+
/**
|
|
4
|
+
* A minimal UI element with no visual representation.
|
|
5
|
+
* Used as a placeholder, spacer, or container for other elements.
|
|
6
|
+
*/
|
|
3
7
|
export declare class UIDummy extends UIElement {
|
|
8
|
+
/**
|
|
9
|
+
* Creates a new dummy UI element.
|
|
10
|
+
*
|
|
11
|
+
* @param layer - The UI layer that contains this element
|
|
12
|
+
* @param width - Width of the dummy element (defaults to DEFAULT_DUMMY_SIZE)
|
|
13
|
+
* @param height - Height of the dummy element (defaults to DEFAULT_DUMMY_SIZE)
|
|
14
|
+
*/
|
|
4
15
|
constructor(layer: UILayer, width?: number, height?: number);
|
|
16
|
+
/**
|
|
17
|
+
* Renders the dummy element.
|
|
18
|
+
* Since dummies have no visual representation, this only applies transformations.
|
|
19
|
+
*/
|
|
5
20
|
protected render(): void;
|
|
6
21
|
}
|
|
@@ -3,45 +3,132 @@ import { Variable } from "kiwi.js";
|
|
|
3
3
|
import type { WebGLRenderer } from "three";
|
|
4
4
|
import { type Object3D } from "three";
|
|
5
5
|
import type { UILayer } from "../Layers/UILayer";
|
|
6
|
-
import {
|
|
6
|
+
import { heightSymbol, needsRecalculation, widthSymbol, xSymbol, ySymbol } from "../Miscellaneous/symbols";
|
|
7
7
|
import { UIMicro, UIMicroInternal } from "../Miscellaneous/UIMicro";
|
|
8
8
|
import { UIMode } from "../Miscellaneous/UIMode";
|
|
9
9
|
import { UIComposer, UIComposerInternal } from "../Passes/UIComposer";
|
|
10
|
+
/**
|
|
11
|
+
* Events that can be emitted by UI elements.
|
|
12
|
+
*/
|
|
10
13
|
export declare enum UIElementEvent {
|
|
14
|
+
/** Triggered when an interactive element is clicked */
|
|
11
15
|
CLICK = "click"
|
|
12
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Abstract base class for all UI elements in the system.
|
|
19
|
+
* Provides core functionality for positioning, sizing, and rendering UI elements.
|
|
20
|
+
*
|
|
21
|
+
* Each UI element has:
|
|
22
|
+
* - Position (x, y) and size (width, height) variables
|
|
23
|
+
* - Layer management integration
|
|
24
|
+
* - Event handling capabilities
|
|
25
|
+
* - Micro transformations support
|
|
26
|
+
* - Rendering capabilities
|
|
27
|
+
*/
|
|
13
28
|
export declare abstract class UIElement extends Eventail {
|
|
14
29
|
readonly layer: UILayer;
|
|
15
30
|
protected readonly object: Object3D;
|
|
31
|
+
/** X position variable for constraint system */
|
|
16
32
|
[xSymbol]: Variable;
|
|
33
|
+
/** Y position variable for constraint system */
|
|
17
34
|
[ySymbol]: Variable;
|
|
35
|
+
/** Width variable for constraint system */
|
|
18
36
|
[widthSymbol]: Variable;
|
|
37
|
+
/** Height variable for constraint system */
|
|
19
38
|
[heightSymbol]: Variable;
|
|
39
|
+
/** Flag indicating whether the element needs recalculation */
|
|
20
40
|
[needsRecalculation]: boolean;
|
|
41
|
+
/** Unique identifier for the element */
|
|
21
42
|
name: string;
|
|
43
|
+
/** Micro transformation interface for the element */
|
|
22
44
|
readonly micro: UIMicro;
|
|
45
|
+
/** Composer interface for the element */
|
|
23
46
|
readonly composer: UIComposer;
|
|
47
|
+
/** Internal micro transformation implementation */
|
|
24
48
|
protected readonly microInternal: UIMicroInternal;
|
|
49
|
+
/** Internal composer implementation */
|
|
25
50
|
protected readonly composerInternal: UIComposerInternal;
|
|
51
|
+
/** Current visibility/interactivity mode */
|
|
26
52
|
protected modeInternal: UIMode;
|
|
53
|
+
/**
|
|
54
|
+
* Creates a new UI element.
|
|
55
|
+
*
|
|
56
|
+
* @param layer - The UI layer that contains this element
|
|
57
|
+
* @param object - The Three.js object that represents this element
|
|
58
|
+
* @param x - Initial x position
|
|
59
|
+
* @param y - Initial y position
|
|
60
|
+
* @param width - Initial width
|
|
61
|
+
* @param height - Initial height
|
|
62
|
+
*/
|
|
27
63
|
constructor(layer: UILayer, object: Object3D, x: number, y: number, width: number, height: number);
|
|
64
|
+
/** Gets the current x position of the element */
|
|
28
65
|
get x(): number;
|
|
66
|
+
/** Gets the current y position of the element */
|
|
29
67
|
get y(): number;
|
|
68
|
+
/** Gets the current width of the element */
|
|
30
69
|
get width(): number;
|
|
70
|
+
/** Gets the current height of the element */
|
|
31
71
|
get height(): number;
|
|
72
|
+
/** Gets the current z-index (depth) of the element */
|
|
32
73
|
get zIndex(): number;
|
|
74
|
+
/** Gets the current visibility/interactivity mode of the element */
|
|
33
75
|
get mode(): UIMode;
|
|
76
|
+
/** Gets whether the element needs recalculation */
|
|
34
77
|
protected get needsRecalculation(): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Sets the x position of the element
|
|
80
|
+
* @param value - New x position
|
|
81
|
+
*/
|
|
35
82
|
set x(value: number);
|
|
83
|
+
/**
|
|
84
|
+
* Sets the y position of the element
|
|
85
|
+
* @param value - New y position
|
|
86
|
+
*/
|
|
36
87
|
set y(value: number);
|
|
88
|
+
/**
|
|
89
|
+
* Sets the width of the element
|
|
90
|
+
* @param value - New width
|
|
91
|
+
*/
|
|
37
92
|
set width(value: number);
|
|
93
|
+
/**
|
|
94
|
+
* Sets the height of the element
|
|
95
|
+
* @param value - New height
|
|
96
|
+
*/
|
|
38
97
|
set height(value: number);
|
|
98
|
+
/**
|
|
99
|
+
* Sets the z-index (depth) of the element
|
|
100
|
+
* @param value - New z-index
|
|
101
|
+
*/
|
|
39
102
|
set zIndex(value: number);
|
|
103
|
+
/**
|
|
104
|
+
* Sets the visibility/interactivity mode of the element
|
|
105
|
+
* @param value - New UI mode
|
|
106
|
+
*/
|
|
40
107
|
set mode(value: UIMode);
|
|
108
|
+
/**
|
|
109
|
+
* Destroys the element, cleaning up all resources and removing it from the layer.
|
|
110
|
+
* This should be called when the element is no longer needed.
|
|
111
|
+
*/
|
|
41
112
|
destroy(): void;
|
|
42
|
-
|
|
43
|
-
|
|
113
|
+
/**
|
|
114
|
+
* Applies transformations to the underlying Three.js object.
|
|
115
|
+
* This is called when the element's position, size, or other properties change.
|
|
116
|
+
*/
|
|
44
117
|
protected applyTransformations(): void;
|
|
118
|
+
/**
|
|
119
|
+
* Handles click events on this element.
|
|
120
|
+
*
|
|
121
|
+
* @param x - X coordinate of the click
|
|
122
|
+
* @param y - Y coordinate of the click
|
|
123
|
+
* @returns Whether the click was handled by this element
|
|
124
|
+
*/
|
|
45
125
|
protected click(x: number, y: number): boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Renders the element.
|
|
128
|
+
* This must be implemented by concrete subclasses.
|
|
129
|
+
*
|
|
130
|
+
* @param renderer - The WebGL renderer
|
|
131
|
+
* @param deltaTime - Time elapsed since the last frame
|
|
132
|
+
*/
|
|
46
133
|
protected abstract render(renderer: WebGLRenderer, deltaTime: number): void;
|
|
47
134
|
}
|
|
@@ -1,15 +1,48 @@
|
|
|
1
1
|
import type { Texture, WebGLRenderer } from "three";
|
|
2
2
|
import type { UILayer } from "../Layers/UILayer";
|
|
3
3
|
import { UIElement } from "./UIElement";
|
|
4
|
+
/**
|
|
5
|
+
* A UI element that displays an image texture.
|
|
6
|
+
* Renders a textured mesh using the provided texture.
|
|
7
|
+
*/
|
|
4
8
|
export declare class UIImage extends UIElement {
|
|
9
|
+
/** Material used to render the image */
|
|
5
10
|
private readonly material;
|
|
11
|
+
/** The texture displayed by this image */
|
|
6
12
|
private readonly textureInternal;
|
|
13
|
+
/**
|
|
14
|
+
* Creates a new image UI element.
|
|
15
|
+
*
|
|
16
|
+
* @param layer - The UI layer that contains this element
|
|
17
|
+
* @param texture - The texture to display
|
|
18
|
+
* @throws Error if the texture has invalid dimensions
|
|
19
|
+
*/
|
|
7
20
|
constructor(layer: UILayer, texture: Texture);
|
|
21
|
+
/** Gets the texture displayed by this image */
|
|
8
22
|
get texture(): Texture;
|
|
23
|
+
/** Gets the color tint applied to the image */
|
|
9
24
|
get color(): number;
|
|
25
|
+
/** Gets the opacity of the image */
|
|
10
26
|
get opacity(): number;
|
|
27
|
+
/**
|
|
28
|
+
* Sets the color tint applied to the image
|
|
29
|
+
* @param value - Color in hexadecimal format
|
|
30
|
+
*/
|
|
11
31
|
set color(value: number);
|
|
32
|
+
/**
|
|
33
|
+
* Sets the opacity of the image
|
|
34
|
+
* @param value - Opacity value between 0 (transparent) and 1 (opaque)
|
|
35
|
+
*/
|
|
12
36
|
set opacity(value: number);
|
|
37
|
+
/**
|
|
38
|
+
* Destroys the image element, disposing of all resources and removing it from the layer.
|
|
39
|
+
* This should be called when the element is no longer needed.
|
|
40
|
+
*/
|
|
13
41
|
destroy(): void;
|
|
42
|
+
/**
|
|
43
|
+
* Renders the image element.
|
|
44
|
+
*
|
|
45
|
+
* @param renderer - The WebGL renderer
|
|
46
|
+
*/
|
|
14
47
|
protected render(renderer: WebGLRenderer): void;
|
|
15
48
|
}
|
|
@@ -1,43 +1,127 @@
|
|
|
1
1
|
import type { Texture, WebGLRenderer } from "three";
|
|
2
2
|
import type { UILayer } from "../Layers/UILayer";
|
|
3
3
|
import { UIElement } from "./UIElement";
|
|
4
|
+
/**
|
|
5
|
+
* Options for customizing the UIProgress element.
|
|
6
|
+
*/
|
|
4
7
|
export interface UIProgressOptions {
|
|
8
|
+
/** Optional background texture to display behind the progress indicator */
|
|
5
9
|
textureBackground: Texture;
|
|
10
|
+
/** Progress value from 0 to 1 */
|
|
6
11
|
progress: number;
|
|
12
|
+
/** Whether progress increases in the direction specified by angle (true) or opposite to it (false) */
|
|
7
13
|
isForegroundDirection: boolean;
|
|
14
|
+
/** Angle in degrees specifying the direction of progress */
|
|
8
15
|
angle: number;
|
|
16
|
+
/** Overall color tint applied to both textures */
|
|
9
17
|
color: number;
|
|
18
|
+
/** Overall opacity applied to both textures */
|
|
10
19
|
opacity: number;
|
|
20
|
+
/** Color tint applied to the background texture */
|
|
11
21
|
backgroundColor: number;
|
|
22
|
+
/** Color tint applied to the foreground texture */
|
|
12
23
|
foregroundColor: number;
|
|
24
|
+
/** Opacity of the background texture */
|
|
13
25
|
backgroundOpacity: number;
|
|
26
|
+
/** Opacity of the foreground texture */
|
|
14
27
|
foregroundOpacity: number;
|
|
15
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* A UI element that displays a progress indicator.
|
|
31
|
+
* Can be used for loading bars, health bars, sliders, etc.
|
|
32
|
+
*/
|
|
16
33
|
export declare class UIProgress extends UIElement {
|
|
34
|
+
/** Material used to render the progress indicator */
|
|
17
35
|
private readonly material;
|
|
36
|
+
/** Width of the underlying image texture */
|
|
18
37
|
private readonly imageWidth;
|
|
38
|
+
/** Height of the underlying image texture */
|
|
19
39
|
private readonly imageHeight;
|
|
40
|
+
/**
|
|
41
|
+
* Creates a new progress UI element.
|
|
42
|
+
*
|
|
43
|
+
* @param layer - The UI layer that contains this element
|
|
44
|
+
* @param textureForeground - The texture to use for the progress indicator
|
|
45
|
+
* @param options - Options to customize the progress indicator
|
|
46
|
+
* @throws Error if either texture has invalid dimensions
|
|
47
|
+
*/
|
|
20
48
|
constructor(layer: UILayer, textureForeground: Texture, options?: Partial<UIProgressOptions>);
|
|
49
|
+
/** Gets the current progress value (0 to 1) */
|
|
21
50
|
get progress(): number;
|
|
51
|
+
/** Gets the background texture if one was provided */
|
|
22
52
|
get backgroundTexture(): Texture | undefined;
|
|
53
|
+
/** Gets the foreground texture used for the progress indicator */
|
|
23
54
|
get foregroundTexture(): Texture;
|
|
55
|
+
/** Gets the color tint applied to the background texture */
|
|
24
56
|
get backgroundColor(): number;
|
|
57
|
+
/** Gets the color tint applied to the foreground texture */
|
|
25
58
|
get foregroundColor(): number;
|
|
59
|
+
/** Gets the overall color tint applied to both textures */
|
|
26
60
|
get color(): number;
|
|
61
|
+
/** Gets the opacity of the background texture */
|
|
27
62
|
get backgroundOpacity(): number;
|
|
63
|
+
/** Gets the opacity of the foreground texture */
|
|
28
64
|
get foregroundOpacity(): number;
|
|
65
|
+
/** Gets the overall opacity applied to both textures */
|
|
29
66
|
get opacity(): number;
|
|
67
|
+
/** Gets the angle in degrees specifying the direction of progress */
|
|
30
68
|
get angle(): number;
|
|
69
|
+
/** Gets whether progress increases in the direction specified by angle (true) or opposite to it (false) */
|
|
31
70
|
get isForwardDirection(): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Sets the progress value
|
|
73
|
+
* @param value - Progress value between 0 (empty) and 1 (full)
|
|
74
|
+
*/
|
|
32
75
|
set progress(value: number);
|
|
76
|
+
/**
|
|
77
|
+
* Sets the color tint applied to the background texture
|
|
78
|
+
* @param value - Color in hexadecimal format
|
|
79
|
+
*/
|
|
33
80
|
set backgroundColor(value: number);
|
|
81
|
+
/**
|
|
82
|
+
* Sets the color tint applied to the foreground texture
|
|
83
|
+
* @param value - Color in hexadecimal format
|
|
84
|
+
*/
|
|
34
85
|
set foregroundColor(value: number);
|
|
86
|
+
/**
|
|
87
|
+
* Sets the overall color tint applied to both textures
|
|
88
|
+
* @param value - Color in hexadecimal format
|
|
89
|
+
*/
|
|
35
90
|
set color(value: number);
|
|
91
|
+
/**
|
|
92
|
+
* Sets the opacity of the background texture
|
|
93
|
+
* @param value - Opacity value between 0 (transparent) and 1 (opaque)
|
|
94
|
+
*/
|
|
36
95
|
set backgroundOpacity(value: number);
|
|
96
|
+
/**
|
|
97
|
+
* Sets the opacity of the foreground texture
|
|
98
|
+
* @param value - Opacity value between 0 (transparent) and 1 (opaque)
|
|
99
|
+
*/
|
|
37
100
|
set foregroundOpacity(value: number);
|
|
101
|
+
/**
|
|
102
|
+
* Sets the overall opacity applied to both textures
|
|
103
|
+
* @param value - Opacity value between 0 (transparent) and 1 (opaque)
|
|
104
|
+
*/
|
|
38
105
|
set opacity(value: number);
|
|
106
|
+
/**
|
|
107
|
+
* Sets the angle specifying the direction of progress
|
|
108
|
+
* @param value - Angle in degrees
|
|
109
|
+
*/
|
|
39
110
|
set angle(value: number);
|
|
111
|
+
/**
|
|
112
|
+
* Sets whether progress increases in the direction specified by angle
|
|
113
|
+
* @param value - true to increase in the direction of angle, false for opposite
|
|
114
|
+
*/
|
|
40
115
|
set isForwardDirection(value: boolean);
|
|
116
|
+
/**
|
|
117
|
+
* Destroys the progress element, disposing of all resources and removing it from the layer.
|
|
118
|
+
* This should be called when the element is no longer needed.
|
|
119
|
+
*/
|
|
41
120
|
destroy(): void;
|
|
121
|
+
/**
|
|
122
|
+
* Renders the progress element.
|
|
123
|
+
*
|
|
124
|
+
* @param renderer - The WebGL renderer
|
|
125
|
+
*/
|
|
42
126
|
protected render(renderer: WebGLRenderer): void;
|
|
43
127
|
}
|
|
@@ -2,50 +2,140 @@ import type { Camera, WebGLRenderer } from "three";
|
|
|
2
2
|
import { Scene } from "three";
|
|
3
3
|
import type { UILayer } from "../Layers/UILayer";
|
|
4
4
|
import { UIElement } from "./UIElement";
|
|
5
|
+
/**
|
|
6
|
+
* Defines when a UIScene should be rendered/updated.
|
|
7
|
+
*/
|
|
5
8
|
export declare enum UISceneUpdateMode {
|
|
9
|
+
/** Scene is rendered on every frame */
|
|
6
10
|
ALWAYS = "always",
|
|
11
|
+
/** Scene is rendered when any property changes */
|
|
7
12
|
PROPERTY_CHANGED = "property_changed",
|
|
13
|
+
/** Scene is only rendered when explicitly requested */
|
|
8
14
|
MANUAL = "manual"
|
|
9
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Options for customizing the UIScene element.
|
|
18
|
+
*/
|
|
10
19
|
export interface UISceneOptions {
|
|
20
|
+
/** Three.js scene to render */
|
|
11
21
|
scene: Scene;
|
|
22
|
+
/** Camera to use for rendering the scene */
|
|
12
23
|
camera: Camera;
|
|
24
|
+
/** Width of the scene viewport in pixels */
|
|
13
25
|
width: number;
|
|
26
|
+
/** Height of the scene viewport in pixels */
|
|
14
27
|
height: number;
|
|
28
|
+
/** Resolution scaling factor for performance optimization */
|
|
15
29
|
resolutionFactor: number;
|
|
30
|
+
/** Whether the scene should be rendered immediately after creation */
|
|
16
31
|
renderedByDefault: boolean;
|
|
32
|
+
/** Whether to use a depth buffer for rendering */
|
|
17
33
|
useDepth: boolean;
|
|
34
|
+
/** Color to clear the scene with before rendering */
|
|
18
35
|
clearColor: number;
|
|
36
|
+
/** Alpha value for the clear color (0-1) */
|
|
19
37
|
clearAlpha: number;
|
|
38
|
+
/** When the scene should be automatically re-rendered */
|
|
20
39
|
updateBehavior: UISceneUpdateMode;
|
|
21
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* A UI element that renders a Three.js scene as a texture.
|
|
43
|
+
* This allows 3D content to be integrated into the 2D UI system.
|
|
44
|
+
*/
|
|
22
45
|
export declare class UIScene extends UIElement {
|
|
46
|
+
/** Material used to render the scene's render target */
|
|
23
47
|
private readonly material;
|
|
48
|
+
/** WebGL render target where the scene is rendered */
|
|
24
49
|
private readonly renderTarget;
|
|
50
|
+
/** Color to clear the scene with before rendering */
|
|
25
51
|
private clearColorInternal;
|
|
52
|
+
/** Alpha value for the clear color */
|
|
26
53
|
private clearAlphaInternal;
|
|
54
|
+
/** Whether the scene needs to be re-rendered on the next frame */
|
|
27
55
|
private needsRenderInternal;
|
|
56
|
+
/** When the scene should be automatically re-rendered */
|
|
28
57
|
private readonly updateModeInternal;
|
|
58
|
+
/** Resolution scaling factor for performance optimization */
|
|
29
59
|
private resolutionFactorInternal;
|
|
60
|
+
/** The Three.js scene being rendered */
|
|
30
61
|
private sceneInternal;
|
|
62
|
+
/** The camera used for rendering the scene */
|
|
31
63
|
private cameraInternal;
|
|
64
|
+
/**
|
|
65
|
+
* Creates a new scene UI element.
|
|
66
|
+
*
|
|
67
|
+
* @param layer - The UI layer that contains this element
|
|
68
|
+
* @param options - Options to customize the scene
|
|
69
|
+
* @throws Error if resolution factor is out of valid range or dimensions are invalid
|
|
70
|
+
*/
|
|
32
71
|
constructor(layer: UILayer, options?: Partial<UISceneOptions>);
|
|
72
|
+
/** Gets whether the scene needs to be re-rendered on the next frame */
|
|
33
73
|
get needsRender(): boolean;
|
|
74
|
+
/** Gets the color tint applied to the rendered scene */
|
|
34
75
|
get color(): number;
|
|
76
|
+
/** Gets the opacity of the rendered scene */
|
|
35
77
|
get opacity(): number;
|
|
78
|
+
/** Gets the Three.js scene being rendered */
|
|
36
79
|
get scene(): Scene;
|
|
80
|
+
/** Gets the camera used for rendering the scene */
|
|
37
81
|
get camera(): Camera;
|
|
82
|
+
/** Gets the color used to clear the scene before rendering */
|
|
38
83
|
get clearColor(): number;
|
|
84
|
+
/** Gets the alpha value for the clear color */
|
|
39
85
|
get clearAlpha(): number;
|
|
86
|
+
/** Gets the resolution scaling factor */
|
|
40
87
|
get resolutionFactor(): number;
|
|
88
|
+
/**
|
|
89
|
+
* Sets the color tint applied to the rendered scene
|
|
90
|
+
* @param value - Color in hexadecimal format
|
|
91
|
+
*/
|
|
41
92
|
set color(value: number);
|
|
93
|
+
/**
|
|
94
|
+
* Sets the opacity of the rendered scene
|
|
95
|
+
* @param value - Opacity value between 0 (transparent) and 1 (opaque)
|
|
96
|
+
*/
|
|
42
97
|
set opacity(value: number);
|
|
98
|
+
/**
|
|
99
|
+
* Sets the Three.js scene to be rendered
|
|
100
|
+
* @param value - Scene to render
|
|
101
|
+
*/
|
|
43
102
|
set scene(value: Scene);
|
|
103
|
+
/**
|
|
104
|
+
* Sets the camera used for rendering the scene
|
|
105
|
+
* @param value - Camera to use
|
|
106
|
+
*/
|
|
44
107
|
set camera(value: Camera);
|
|
108
|
+
/**
|
|
109
|
+
* Sets the color used to clear the scene before rendering
|
|
110
|
+
* @param value - Clear color in hexadecimal format
|
|
111
|
+
*/
|
|
45
112
|
set clearColor(value: number);
|
|
113
|
+
/**
|
|
114
|
+
* Sets the alpha value for the clear color
|
|
115
|
+
* @param value - Alpha value between 0 (transparent) and 1 (opaque)
|
|
116
|
+
*/
|
|
46
117
|
set clearAlpha(value: number);
|
|
118
|
+
/**
|
|
119
|
+
* Sets the resolution scaling factor
|
|
120
|
+
* @param value - Resolution factor (e.g., 0.5 for half resolution)
|
|
121
|
+
*/
|
|
47
122
|
set resolutionFactor(value: number);
|
|
123
|
+
/**
|
|
124
|
+
* Destroys the scene element, disposing of all resources and removing it from the layer.
|
|
125
|
+
* This should be called when the element is no longer needed.
|
|
126
|
+
*/
|
|
48
127
|
destroy(): void;
|
|
128
|
+
/**
|
|
129
|
+
* Requests that the scene be re-rendered on the next frame.
|
|
130
|
+
* This is used when the scene is in MANUAL update mode or when properties change.
|
|
131
|
+
*/
|
|
49
132
|
requestRender(): void;
|
|
133
|
+
/**
|
|
134
|
+
* Renders the scene element.
|
|
135
|
+
* This will render the Three.js scene to a texture if needed,
|
|
136
|
+
* then apply that texture to the mesh.
|
|
137
|
+
*
|
|
138
|
+
* @param renderer - The WebGL renderer
|
|
139
|
+
*/
|
|
50
140
|
protected render(renderer: WebGLRenderer): void;
|
|
51
141
|
}
|
|
@@ -1,26 +1,76 @@
|
|
|
1
1
|
import type { WebGLRenderer } from "three";
|
|
2
2
|
import type { UILayer } from "../Layers/UILayer";
|
|
3
|
+
import type { UITextPadding, UITextSpan, UITextStyle } from "../Miscellaneous/UITextInterfaces";
|
|
3
4
|
import { UIElement } from "./UIElement";
|
|
4
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Options for customizing the UIText element.
|
|
7
|
+
*/
|
|
5
8
|
export interface UITextOptions {
|
|
9
|
+
/** Maximum width of the text block before wrapping occurs */
|
|
6
10
|
maxWidth: number;
|
|
11
|
+
/** Padding around the text */
|
|
7
12
|
padding: Partial<UITextPadding>;
|
|
13
|
+
/** Default style to apply to text spans that don't specify their own style */
|
|
8
14
|
defaultStyle: Partial<UITextStyle>;
|
|
9
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* A UI element that displays formatted text.
|
|
18
|
+
* Renders text to a canvas and displays it as a texture on a mesh.
|
|
19
|
+
*/
|
|
10
20
|
export declare class UIText extends UIElement {
|
|
21
|
+
/** Material used to render the text */
|
|
11
22
|
private readonly material;
|
|
23
|
+
/** Texture containing the rendered text */
|
|
12
24
|
private readonly texture;
|
|
25
|
+
/** Canvas element used to render the text */
|
|
13
26
|
private readonly canvas;
|
|
27
|
+
/** 2D rendering context for the canvas */
|
|
14
28
|
private readonly context;
|
|
29
|
+
/** Size of the text block without padding */
|
|
15
30
|
private readonly textBlockSize;
|
|
31
|
+
/** Padding values applied around the text */
|
|
16
32
|
private readonly padding;
|
|
33
|
+
/** Cached aspect ratio for performance optimization */
|
|
17
34
|
private suggestedAspect;
|
|
35
|
+
/**
|
|
36
|
+
* Creates a new text UI element.
|
|
37
|
+
*
|
|
38
|
+
* @param layer - The UI layer that contains this element
|
|
39
|
+
* @param spans - Text content to display, either as a string, text span, or array of text spans/strings
|
|
40
|
+
* @param parameters - Options to customize the text rendering
|
|
41
|
+
* @throws Error if canvas context creation fails
|
|
42
|
+
*/
|
|
18
43
|
constructor(layer: UILayer, spans: (UITextSpan | string)[] | UITextSpan | string, parameters?: Partial<UITextOptions>);
|
|
44
|
+
/** Gets the color tint applied to the text */
|
|
19
45
|
get color(): number;
|
|
46
|
+
/** Gets the opacity of the text */
|
|
20
47
|
get opacity(): number;
|
|
48
|
+
/**
|
|
49
|
+
* Sets the color tint applied to the text
|
|
50
|
+
* @param value - Color in hexadecimal format
|
|
51
|
+
*/
|
|
21
52
|
set color(value: number);
|
|
53
|
+
/**
|
|
54
|
+
* Sets the opacity of the text
|
|
55
|
+
* @param value - Opacity value between 0 (transparent) and 1 (opaque)
|
|
56
|
+
*/
|
|
22
57
|
set opacity(value: number);
|
|
58
|
+
/**
|
|
59
|
+
* Destroys the text element, disposing of all resources and removing it from the layer.
|
|
60
|
+
* This should be called when the element is no longer needed.
|
|
61
|
+
*/
|
|
23
62
|
destroy(): void;
|
|
63
|
+
/**
|
|
64
|
+
* Applies transformations to the text element, ensuring the aspect ratio
|
|
65
|
+
* matches the rendered text to prevent distortion.
|
|
66
|
+
*
|
|
67
|
+
* This overrides the base implementation to maintain the correct aspect ratio.
|
|
68
|
+
*/
|
|
24
69
|
applyTransformations(): void;
|
|
70
|
+
/**
|
|
71
|
+
* Renders the text element.
|
|
72
|
+
*
|
|
73
|
+
* @param renderer - The WebGL renderer
|
|
74
|
+
*/
|
|
25
75
|
protected render(renderer: WebGLRenderer): void;
|
|
26
76
|
}
|