laymur 0.10.3 → 0.11.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.
- package/README.md +20 -11
- package/dist/constraints/UIAspectConstraint.Internal.d.ts +6 -0
- package/dist/constraints/UIAspectConstraint.d.ts +9 -46
- package/dist/constraints/UIConstraint.d.ts +7 -27
- package/dist/constraints/UICustomConstraint.d.ts +13 -45
- package/dist/constraints/UIHeightConstraint.Internal.d.ts +6 -0
- package/dist/constraints/UIHeightConstraint.d.ts +8 -37
- package/dist/constraints/UIHorizontalDistanceConstraint.Internal.d.ts +11 -0
- package/dist/constraints/UIHorizontalDistanceConstraint.d.ts +16 -73
- package/dist/constraints/UIHorizontalProportionConstraint.Internal.d.ts +6 -0
- package/dist/constraints/UIHorizontalProportionConstraint.d.ts +8 -52
- package/dist/constraints/UISingleParameterConstraint.Internal.d.ts +12 -0
- package/dist/constraints/UISingleParameterConstraint.d.ts +24 -87
- package/dist/constraints/UIVerticalDistanceConstraint.Internal.d.ts +11 -0
- package/dist/constraints/UIVerticalDistanceConstraint.d.ts +12 -73
- package/dist/constraints/UIVerticalProportionConstraint.Internal.d.ts +6 -0
- package/dist/constraints/UIVerticalProportionConstraint.d.ts +8 -52
- package/dist/constraints/UIWidthConstraint.Internal.d.ts +6 -0
- package/dist/constraints/UIWidthConstraint.d.ts +8 -37
- package/dist/constraints/builders/UIConstraint2DBuilder.Internal.d.ts +45 -0
- package/dist/constraints/builders/UIConstraint2DBuilder.d.ts +35 -0
- package/dist/constraints/builders/UICoverConstraintBuilder.Internal.d.ts +13 -0
- package/dist/constraints/builders/UICoverConstraintBuilder.d.ts +29 -0
- package/dist/constraints/builders/UIFitConstraintBuilder.Internal.d.ts +13 -0
- package/dist/constraints/builders/UIFitConstraintBuilder.d.ts +29 -0
- package/dist/elements/UIAnchor.Internal.d.ts +9 -0
- package/dist/elements/UIAnchor.d.ts +17 -62
- package/dist/elements/UIAnimatedImage.Internal.d.ts +24 -0
- package/dist/elements/UIAnimatedImage.d.ts +38 -100
- package/dist/elements/UIDummy.Internal.d.ts +18 -0
- package/dist/elements/UIDummy.d.ts +51 -63
- package/dist/elements/UIElement.Internal.d.ts +11 -0
- package/dist/elements/UIElement.d.ts +28 -168
- package/dist/elements/UIGraphics.Internal.d.ts +7 -0
- package/dist/elements/UIGraphics.d.ts +29 -99
- package/dist/elements/UIImage.Internal.d.ts +7 -0
- package/dist/elements/UIImage.d.ts +18 -73
- package/dist/elements/UINineSlice.Internal.d.ts +23 -0
- package/dist/elements/UINineSlice.d.ts +45 -0
- package/dist/elements/UIProgress.Internal.d.ts +14 -0
- package/dist/elements/UIProgress.d.ts +26 -152
- package/dist/elements/UIScene.Internal.d.ts +43 -0
- package/dist/elements/UIScene.d.ts +29 -171
- package/dist/elements/UIText/UIText.Interfaces.d.ts +32 -0
- package/dist/elements/UIText/UIText.Internal.d.ts +26 -0
- package/dist/elements/UIText/UIText.Measuring.d.ts +49 -0
- package/dist/elements/UIText/UIText.Rendering.d.ts +19 -0
- package/dist/elements/UIText/UIText.d.ts +63 -0
- package/dist/index.d.ts +46 -46
- package/dist/index.js +4176 -4002
- 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 +33 -43
- package/dist/layers/UILayer.Internal.d.ts +15 -0
- package/dist/layers/UILayer.d.ts +29 -184
- package/dist/miscellaneous/UIExpression.d.ts +35 -83
- package/dist/miscellaneous/UIInputEvent.d.ts +11 -8
- package/dist/miscellaneous/UIMode.d.ts +19 -21
- package/dist/miscellaneous/UIOrientation.d.ts +7 -22
- package/dist/miscellaneous/UIPriority.d.ts +16 -40
- package/dist/miscellaneous/UIRelation.d.ts +11 -31
- package/dist/miscellaneous/UITransparencyMode.d.ts +4 -21
- package/dist/miscellaneous/area/UIArea.d.ts +3 -0
- package/dist/miscellaneous/area/UIAreaCircle.d.ts +15 -0
- package/dist/miscellaneous/area/UIAreaPolygon.d.ts +12 -0
- package/dist/miscellaneous/area/UIAreaRectangle.d.ts +17 -0
- package/dist/miscellaneous/area/UIAreaRoundedRectangle.d.ts +21 -0
- package/dist/miscellaneous/asserts.d.ts +39 -82
- package/dist/miscellaneous/color/UIColor.Internal.d.ts +7 -0
- package/dist/miscellaneous/color/UIColor.d.ts +197 -0
- package/dist/miscellaneous/computeTransform.d.ts +18 -0
- package/dist/miscellaneous/generic-plane/UIGenericInstancedPlane.Internal.d.ts +10 -0
- package/dist/miscellaneous/generic-plane/UIGenericInstancedPlane.d.ts +36 -0
- package/dist/miscellaneous/generic-plane/UIGenericPlane.Internal.d.ts +5 -0
- package/dist/miscellaneous/generic-plane/UIGenericPlane.d.ts +23 -0
- package/dist/miscellaneous/generic-plane/UIGenericPlaneRegistry.Internal.d.ts +6 -0
- package/dist/miscellaneous/generic-plane/UIGenericPlaneRegistry.d.ts +27 -0
- package/dist/miscellaneous/generic-plane/shared.d.ts +22 -0
- package/dist/miscellaneous/mask-function/UIProgressMaskFunction.d.ts +9 -0
- package/dist/miscellaneous/mask-function/UIProgressMaskFunctionCircular.d.ts +21 -0
- package/dist/miscellaneous/mask-function/UIProgressMaskFunctionDirectional.d.ts +16 -0
- package/dist/miscellaneous/micro/UIMicro.Internal.d.ts +31 -0
- package/dist/miscellaneous/micro/UIMicro.d.ts +59 -0
- package/dist/miscellaneous/padding/UIPadding.Internal.d.ts +11 -0
- package/dist/miscellaneous/padding/UIPadding.d.ts +46 -0
- package/dist/miscellaneous/resize-policy/UIResizePolicy.d.ts +3 -0
- package/dist/miscellaneous/resize-policy/UIResizePolicyCross.d.ts +22 -0
- package/dist/miscellaneous/resize-policy/UIResizePolicyCrossInverted.d.ts +22 -0
- package/dist/miscellaneous/resize-policy/UIResizePolicyFixedHeight.d.ts +22 -0
- package/dist/miscellaneous/resize-policy/UIResizePolicyFixedWidth.d.ts +22 -0
- package/dist/miscellaneous/resize-policy/UIResizePolicyNone.d.ts +5 -0
- package/dist/miscellaneous/text-span/UITextSpan.Internal.d.ts +8 -0
- package/dist/miscellaneous/text-span/UITextSpan.d.ts +14 -0
- package/dist/miscellaneous/text-style/UITextStyle.Internal.d.ts +48 -0
- package/dist/miscellaneous/text-style/UITextStyle.d.ts +85 -0
- package/dist/miscellaneous/texture/UITextureView.Internal.d.ts +54 -0
- package/dist/miscellaneous/texture/UITextureView.d.ts +61 -0
- package/dist/wrappers/UIInputWrapper.Internal.d.ts +17 -0
- package/dist/wrappers/UIInputWrapper.d.ts +13 -0
- package/dist/wrappers/UISceneWrapper.Internal.d.ts +13 -0
- package/dist/wrappers/UISceneWrapper.d.ts +12 -19
- package/dist/wrappers/UISolverWrapper.Internal.d.ts +49 -0
- package/dist/wrappers/UISolverWrapper.d.ts +2 -1
- package/package.json +3 -1
- package/dist/builders/UIConstraint2DBuilder.d.ts +0 -130
- package/dist/builders/UICoverConstraintBuilder.d.ts +0 -56
- package/dist/builders/UIFitConstraintBuilder.d.ts +0 -56
- package/dist/composer/UIComposer.d.ts +0 -0
- package/dist/composer/UIFullscreenQuad.d.ts +0 -0
- package/dist/composer/UIPass.d.ts +0 -0
- package/dist/elements/UINineSline.d.ts +0 -139
- package/dist/elements/UISpine.d.ts +0 -54
- package/dist/elements/UIText.d.ts +0 -149
- package/dist/miscellaneous/UIColor.d.ts +0 -245
- package/dist/miscellaneous/UIGenericInstancedPlane.d.ts +0 -32
- package/dist/miscellaneous/UIMicro.d.ts +0 -148
- package/dist/miscellaneous/UIMicroAnchorMode.d.ts +0 -9
- package/dist/miscellaneous/UINineSliceBorder.d.ts +0 -21
- package/dist/miscellaneous/UIResizePolicy.d.ts +0 -21
- package/dist/miscellaneous/UIResizePolicyCross.d.ts +0 -14
- package/dist/miscellaneous/UIResizePolicyCrossInverted.d.ts +0 -14
- package/dist/miscellaneous/UIResizePolicyFixedHeight.d.ts +0 -24
- package/dist/miscellaneous/UIResizePolicyFixedWidth.d.ts +0 -27
- package/dist/miscellaneous/UIResizePolicyNone.d.ts +0 -7
- package/dist/miscellaneous/UISceneWrapperClientAPI.d.ts +0 -12
- package/dist/miscellaneous/UITextPadding.d.ts +0 -7
- package/dist/miscellaneous/UITextSpan.d.ts +0 -6
- package/dist/miscellaneous/UITextStyle.d.ts +0 -20
- package/dist/miscellaneous/textInterfaces.d.ts +0 -19
- package/dist/miscellaneous/textTools.d.ts +0 -12
|
@@ -1,194 +1,52 @@
|
|
|
1
1
|
import type { Camera, WebGLRenderer } from "three";
|
|
2
2
|
import { Scene } from "three";
|
|
3
|
-
import {
|
|
4
|
-
import { UIColor } from "../miscellaneous/UIColor";
|
|
5
|
-
import type { UIMode } from "../miscellaneous/UIMode";
|
|
3
|
+
import type { UILayer } from "../layers/UILayer";
|
|
4
|
+
import { UIColor } from "../miscellaneous/color/UIColor";
|
|
6
5
|
import { UIElement } from "./UIElement";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
*/
|
|
10
|
-
export declare enum UISceneUpdateMode {
|
|
11
|
-
/** Re-render the scene every frame. */
|
|
12
|
-
EACH_FRAME = 1,
|
|
13
|
-
/** Re-render the scene every second frame for performance. */
|
|
14
|
-
EACH_SECOND_FRAME = 2,
|
|
15
|
-
/** Re-render the scene only when properties change. */
|
|
16
|
-
PROPERTY_CHANGED = 3,
|
|
17
|
-
/** Re-render the scene only when manually requested. */
|
|
18
|
-
MANUAL = 4
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Configuration options for UIScene element creation.
|
|
22
|
-
*/
|
|
23
|
-
export interface UISceneOptions {
|
|
24
|
-
/** Initial x-coordinate position. */
|
|
25
|
-
x: number;
|
|
26
|
-
/** Initial y-coordinate position. */
|
|
27
|
-
y: number;
|
|
28
|
-
/** Width of the scene render target in pixels. */
|
|
29
|
-
width: number;
|
|
30
|
-
/** Height of the scene render target in pixels. */
|
|
31
|
-
height: number;
|
|
32
|
-
/** Color tint applied to the scene texture. */
|
|
33
|
-
color: UIColor;
|
|
34
|
-
/** Three.js scene to render. */
|
|
35
|
-
scene: Scene;
|
|
36
|
-
/** Camera to use for rendering the scene. */
|
|
37
|
-
camera: Camera;
|
|
38
|
-
/** Update mode controlling when the scene is re-rendered. */
|
|
39
|
-
updateMode: UISceneUpdateMode;
|
|
40
|
-
/** Resolution factor for render target sizing (0.1 to 2.0). */
|
|
41
|
-
resolutionFactor: number;
|
|
42
|
-
/** Clear color for the render target background. */
|
|
43
|
-
clearColor: number;
|
|
44
|
-
/** Clear alpha for the render target background. */
|
|
45
|
-
clearAlpha: number;
|
|
46
|
-
/** Whether to enable depth buffer for the render target. */
|
|
47
|
-
enableDepthBuffer: boolean;
|
|
48
|
-
/** Default UIMode */
|
|
49
|
-
mode: UIMode;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* UI element for rendering 3D scenes to texture within the UI system.
|
|
53
|
-
*
|
|
54
|
-
* UIScene is a concrete implementation of UIElement that renders a Three.js
|
|
55
|
-
* scene to a WebGL render target and displays it as a texture. It provides
|
|
56
|
-
* control over rendering frequency, resolution, and visual properties. This
|
|
57
|
-
* allows embedding complex 3D content within the 2D UI layout system with
|
|
58
|
-
* performance optimizations through configurable update modes.
|
|
59
|
-
*
|
|
60
|
-
* @see {@link UIElement} - Base class providing UI element functionality
|
|
61
|
-
* @see {@link UISceneUpdateMode} - Update mode configuration
|
|
62
|
-
* @see {@link Scene} - Three.js scene for 3D content
|
|
63
|
-
* @see {@link Camera} - Three.js camera for scene rendering
|
|
64
|
-
*/
|
|
6
|
+
import type { UISceneOptions } from "./UIScene.Internal";
|
|
7
|
+
import { UISceneUpdateMode } from "./UIScene.Internal";
|
|
8
|
+
/** Renders Three.js scene to texture */
|
|
65
9
|
export declare class UIScene extends UIElement {
|
|
66
|
-
/**
|
|
10
|
+
/** Multiplicative tint. Alpha channel controls opacity. */
|
|
11
|
+
readonly color: UIColor;
|
|
12
|
+
/** Background color for render target */
|
|
13
|
+
readonly clearColor: UIColor;
|
|
67
14
|
private readonly renderTarget;
|
|
68
|
-
/** Internal storage for the color tint. */
|
|
69
|
-
private readonly colorInternal;
|
|
70
|
-
/** Internal storage for the current Three.js scene. */
|
|
71
15
|
private sceneInternal;
|
|
72
|
-
/** Internal storage for the current camera. */
|
|
73
16
|
private cameraInternal;
|
|
74
|
-
/** Internal storage for the current update mode. */
|
|
75
17
|
private updateModeInternal;
|
|
76
|
-
/** Internal storage for the current resolution factor. */
|
|
77
18
|
private resolutionFactorInternal;
|
|
78
|
-
|
|
79
|
-
private
|
|
80
|
-
|
|
81
|
-
private
|
|
82
|
-
/** Frame alternation boolean for EACH_SECOND_FRAME update mode. */
|
|
83
|
-
private frameBoolean;
|
|
84
|
-
/** Flag indicating if properties have changed requiring a re-render. */
|
|
85
|
-
private propertyChanged;
|
|
86
|
-
/** Flag indicating if a manual render has been requested. */
|
|
87
|
-
private renderRequired;
|
|
19
|
+
private evenFrame;
|
|
20
|
+
private updateRequired;
|
|
21
|
+
private resolutionFactorDirty;
|
|
22
|
+
private propertyDirty;
|
|
88
23
|
/**
|
|
89
|
-
* Creates a new UIScene instance
|
|
90
|
-
*
|
|
91
|
-
* The scene element creates a WebGL render target for off-screen rendering
|
|
92
|
-
* and displays the result as a texture. A default perspective camera is
|
|
93
|
-
* created if none is provided.
|
|
24
|
+
* Creates a new UIScene instance.
|
|
94
25
|
*
|
|
95
|
-
* @param layer -
|
|
96
|
-
* @param options - Configuration options
|
|
97
|
-
* @throws
|
|
26
|
+
* @param layer - Layer containing this element
|
|
27
|
+
* @param options - Configuration options
|
|
28
|
+
* @throws If resolutionFactor outside range 0.1 to 2.0
|
|
98
29
|
*/
|
|
99
30
|
constructor(layer: UILayer, options?: Partial<UISceneOptions>);
|
|
100
|
-
/**
|
|
101
|
-
* Gets the current color tint applied to the scene texture.
|
|
102
|
-
* @returns The UIColor instance
|
|
103
|
-
*/
|
|
104
|
-
get color(): UIColor;
|
|
105
|
-
/**
|
|
106
|
-
* Gets the Three.js scene being rendered.
|
|
107
|
-
* @returns The current Three.js scene
|
|
108
|
-
*/
|
|
31
|
+
/** Three.js scene to render */
|
|
109
32
|
get scene(): Scene;
|
|
110
|
-
/**
|
|
111
|
-
* Gets the camera used for rendering the scene.
|
|
112
|
-
* @returns The current Three.js camera
|
|
113
|
-
*/
|
|
33
|
+
/** Camera used for rendering */
|
|
114
34
|
get camera(): Camera;
|
|
115
|
-
/**
|
|
116
|
-
* Gets the current update mode controlling render frequency.
|
|
117
|
-
* @returns The current update mode
|
|
118
|
-
*/
|
|
35
|
+
/** Controls when scene re-renders */
|
|
119
36
|
get updateMode(): UISceneUpdateMode;
|
|
120
|
-
/**
|
|
121
|
-
* Gets the resolution factor for render target sizing.
|
|
122
|
-
* @returns The resolution factor between 0.1 and 2.0
|
|
123
|
-
*/
|
|
37
|
+
/** Render target resolution multiplier. Range 0.1 to 2.0. */
|
|
124
38
|
get resolutionFactor(): number;
|
|
125
|
-
/**
|
|
126
|
-
* Gets the clear color used for the render target background.
|
|
127
|
-
* @returns The clear color as a number
|
|
128
|
-
*/
|
|
129
|
-
get clearColor(): number;
|
|
130
|
-
/**
|
|
131
|
-
* Gets the clear alpha used for the render target background.
|
|
132
|
-
* @returns The clear alpha value between 0.0 and 1.0
|
|
133
|
-
*/
|
|
134
|
-
get clearAlpha(): number;
|
|
135
|
-
/**
|
|
136
|
-
* Sets the color tint applied to the scene texture.
|
|
137
|
-
* @param value - The UIColor instance
|
|
138
|
-
*/
|
|
139
|
-
set color(value: UIColor);
|
|
140
|
-
/**
|
|
141
|
-
* Sets a new Three.js scene to render and marks for re-render.
|
|
142
|
-
* @param value - The new Three.js scene
|
|
143
|
-
*/
|
|
39
|
+
/** Three.js scene to render */
|
|
144
40
|
set scene(value: Scene);
|
|
145
|
-
/**
|
|
146
|
-
* Sets a new camera for rendering and marks for re-render.
|
|
147
|
-
* @param value - The new Three.js camera
|
|
148
|
-
*/
|
|
41
|
+
/** Camera used for rendering */
|
|
149
42
|
set camera(value: Camera);
|
|
150
|
-
/**
|
|
151
|
-
* Sets the update mode controlling render frequency and marks for re-render.
|
|
152
|
-
* @param value - The new update mode
|
|
153
|
-
*/
|
|
43
|
+
/** Controls when scene re-renders */
|
|
154
44
|
set updateMode(value: UISceneUpdateMode);
|
|
155
|
-
/**
|
|
156
|
-
* Sets the resolution factor and resizes the render target accordingly.
|
|
157
|
-
* @param value - The new resolution factor between 0.1 and 2.0
|
|
158
|
-
*/
|
|
45
|
+
/** Render target resolution multiplier. Range 0.1 to 2.0. */
|
|
159
46
|
set resolutionFactor(value: number);
|
|
160
|
-
/**
|
|
161
|
-
* Sets the clear color for the render target background and marks for re-render.
|
|
162
|
-
* @param value - The new clear color as a number
|
|
163
|
-
*/
|
|
164
|
-
set clearColor(value: number);
|
|
165
|
-
/**
|
|
166
|
-
* Sets the clear alpha for the render target background and marks for re-render.
|
|
167
|
-
* @param value - The new clear alpha value between 0.0 and 1.0
|
|
168
|
-
*/
|
|
169
|
-
set clearAlpha(value: number);
|
|
170
|
-
/**
|
|
171
|
-
* Destroys the scene element by cleaning up all associated resources.
|
|
172
|
-
*
|
|
173
|
-
* This method disposes of the material and render target resources,
|
|
174
|
-
* and calls the parent destroy method to clean up the underlying UI element.
|
|
175
|
-
* After calling this method, the scene element should not be used anymore.
|
|
176
|
-
*/
|
|
47
|
+
/** Removes element and frees resources */
|
|
177
48
|
destroy(): void;
|
|
178
|
-
/**
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
* This method is useful when the update mode is set to MANUAL and you
|
|
182
|
-
* want to trigger a scene re-render without changing any properties.
|
|
183
|
-
*/
|
|
184
|
-
requestRender(): void;
|
|
185
|
-
/**
|
|
186
|
-
* Called before each render frame to update the 3D scene rendering.
|
|
187
|
-
* Handles different update modes and renders the 3D scene to the render target
|
|
188
|
-
* based on the current update mode and property change state.
|
|
189
|
-
* @param renderer - The WebGL renderer used for scene rendering
|
|
190
|
-
*/
|
|
191
|
-
protected onWillRender(renderer: WebGLRenderer): void;
|
|
192
|
-
/** Event handler for when the color changes */
|
|
193
|
-
private readonly onColorChange;
|
|
49
|
+
/** Triggers re-render on next frame. Useful in MANUAL mode. */
|
|
50
|
+
requestUpdate(): void;
|
|
51
|
+
protected onWillRender(renderer: WebGLRenderer, deltaTime: number): void;
|
|
194
52
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { UITextSpanConfig } from "../../miscellaneous/text-span/UITextSpan.Internal";
|
|
2
|
+
import type { UITextStyleConfig } from "../../miscellaneous/text-style/UITextStyle.Internal";
|
|
3
|
+
/** Text content configuration */
|
|
4
|
+
export type UITextContent = (UITextSpanConfig | string)[] | UITextSpanConfig | string;
|
|
5
|
+
/** Text dimensions */
|
|
6
|
+
export interface UITextSize {
|
|
7
|
+
/** Width in pixels */
|
|
8
|
+
width: number;
|
|
9
|
+
/** Height in pixels */
|
|
10
|
+
height: number;
|
|
11
|
+
}
|
|
12
|
+
/** Text chunk metrics */
|
|
13
|
+
export interface UIChunkMetrics extends UITextSize {
|
|
14
|
+
/** Baseline offset from top in pixels */
|
|
15
|
+
baseline: number;
|
|
16
|
+
/** Line height in pixels */
|
|
17
|
+
lineHeight: number;
|
|
18
|
+
}
|
|
19
|
+
/** Styled text chunk */
|
|
20
|
+
export interface UITextChunk {
|
|
21
|
+
/** Text content */
|
|
22
|
+
text: string;
|
|
23
|
+
/** Resolved style */
|
|
24
|
+
style: UITextStyleConfig;
|
|
25
|
+
/** Chunk metrics */
|
|
26
|
+
metrics: UIChunkMetrics;
|
|
27
|
+
}
|
|
28
|
+
/** Line of text chunks */
|
|
29
|
+
export interface UITextLine extends UIChunkMetrics {
|
|
30
|
+
/** Chunks in this line */
|
|
31
|
+
chunks: UITextChunk[];
|
|
32
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { UIColorConfig } from "../../miscellaneous/color/UIColor.Internal";
|
|
2
|
+
import type { UIPaddingConfig } from "../../miscellaneous/padding/UIPadding.Internal";
|
|
3
|
+
import type { UITextStyleConfig } from "../../miscellaneous/text-style/UITextStyle.Internal";
|
|
4
|
+
import type { UIElementOptions } from "../UIElement.Internal";
|
|
5
|
+
/** Controls how text adapts to element size */
|
|
6
|
+
export declare enum UITextResizeMode {
|
|
7
|
+
/** Break text into multiple lines when narrower than content*/
|
|
8
|
+
BREAK = 0,
|
|
9
|
+
/** Scale text to fit fixed element size */
|
|
10
|
+
SCALE = 1
|
|
11
|
+
}
|
|
12
|
+
/** Configuration options for UIText */
|
|
13
|
+
export interface UITextOptions extends UIElementOptions {
|
|
14
|
+
/** Multiplicative tint */
|
|
15
|
+
color: UIColorConfig;
|
|
16
|
+
/** Text padding in world units */
|
|
17
|
+
padding: UIPaddingConfig;
|
|
18
|
+
/** Default style applied to all spans */
|
|
19
|
+
commonStyle: Partial<UITextStyleConfig>;
|
|
20
|
+
/** How text adapts to size constraints */
|
|
21
|
+
resizeMode: UITextResizeMode;
|
|
22
|
+
/** Maximum line width before wrapping in pixels */
|
|
23
|
+
maxLineWidth: number;
|
|
24
|
+
}
|
|
25
|
+
export declare const TEXT_DEFAULT_MAX_LINE_WIDTH = 1024;
|
|
26
|
+
export declare const TEXT_DEFAULT_RESIZE_MODE = UITextResizeMode.SCALE;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { UITextSpan } from "../../miscellaneous/text-span/UITextSpan";
|
|
2
|
+
import { UITextStyle } from "../../miscellaneous/text-style/UITextStyle";
|
|
3
|
+
import type { UITextStyleConfig } from "../../miscellaneous/text-style/UITextStyle.Internal";
|
|
4
|
+
import type { UIChunkMetrics, UITextChunk, UITextLine, UITextSize } from "./UIText.Interfaces";
|
|
5
|
+
/**
|
|
6
|
+
* Splits text into renderable chunks.
|
|
7
|
+
* @param text Text to split
|
|
8
|
+
* @returns Array of words, spaces, and newlines
|
|
9
|
+
*/
|
|
10
|
+
export declare function splitTextIntoChunks(text: string): string[];
|
|
11
|
+
/**
|
|
12
|
+
* Measures single text chunk.
|
|
13
|
+
* @param context Canvas context for measurement
|
|
14
|
+
* @param text Chunk text
|
|
15
|
+
* @param textStyle Resolved text style
|
|
16
|
+
* @returns Chunk metrics
|
|
17
|
+
*/
|
|
18
|
+
export declare function measureTextChunk(context: OffscreenCanvasRenderingContext2D, text: string, textStyle: UITextStyleConfig): UIChunkMetrics;
|
|
19
|
+
/**
|
|
20
|
+
* Builds text lines with word wrapping.
|
|
21
|
+
* @param maxWidth Maximum line width in pixels
|
|
22
|
+
* @param textChunks Measured text chunks
|
|
23
|
+
* @returns Array of text lines
|
|
24
|
+
*/
|
|
25
|
+
export declare function buildTextLines(maxWidth: number, textChunks: UITextChunk[]): UITextLine[];
|
|
26
|
+
/**
|
|
27
|
+
* Calculates total text size from lines.
|
|
28
|
+
* @param lines Text lines
|
|
29
|
+
* @returns Total width and height
|
|
30
|
+
*/
|
|
31
|
+
export declare function calculateTextSize(lines: UITextLine[]): UITextSize;
|
|
32
|
+
/**
|
|
33
|
+
* Builds measured text chunks from spans.
|
|
34
|
+
* @param context Canvas context for measurement
|
|
35
|
+
* @param textSpans Text spans with styles
|
|
36
|
+
* @param commonStyle Fallback style
|
|
37
|
+
* @returns Measured text chunks
|
|
38
|
+
*/
|
|
39
|
+
export declare function buildTextChunks(context: OffscreenCanvasRenderingContext2D, textSpans: UITextSpan[], commonStyle: UITextStyle): UITextChunk[];
|
|
40
|
+
/**
|
|
41
|
+
* Calculates text layout parameters.
|
|
42
|
+
* @param textChunks Measured text chunks
|
|
43
|
+
* @param maxLineWidth Maximum line width in pixels
|
|
44
|
+
* @returns Lines and total size
|
|
45
|
+
*/
|
|
46
|
+
export declare function calculateTextContentParameters(textChunks: UITextChunk[], maxLineWidth: number): {
|
|
47
|
+
lines: UITextLine[];
|
|
48
|
+
size: UITextSize;
|
|
49
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { UITextStyleConfig } from "../../miscellaneous/text-style/UITextStyle.Internal";
|
|
2
|
+
import type { UITextLine } from "./UIText.Interfaces";
|
|
3
|
+
/**
|
|
4
|
+
* Renders single text chunk.
|
|
5
|
+
* @param x X coordinate in pixels
|
|
6
|
+
* @param y Y coordinate in pixels
|
|
7
|
+
* @param text Chunk text
|
|
8
|
+
* @param style Resolved text style
|
|
9
|
+
* @param context Canvas rendering context
|
|
10
|
+
*/
|
|
11
|
+
export declare function renderTextChunk(x: number, y: number, text: string, style: UITextStyleConfig, context: OffscreenCanvasRenderingContext2D): void;
|
|
12
|
+
/**
|
|
13
|
+
* Renders text lines to canvas.
|
|
14
|
+
* @param paddingTop Top padding in pixels
|
|
15
|
+
* @param paddingLeft Left padding in pixels
|
|
16
|
+
* @param lines Text lines to render
|
|
17
|
+
* @param context Canvas rendering context
|
|
18
|
+
*/
|
|
19
|
+
export declare function renderTextLines(paddingTop: number, paddingLeft: number, lines: UITextLine[], context: OffscreenCanvasRenderingContext2D): void;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { WebGLRenderer } from "three";
|
|
2
|
+
import type { UILayer } from "../../layers/UILayer";
|
|
3
|
+
import { UIColor } from "../../miscellaneous/color/UIColor";
|
|
4
|
+
import { UIPadding } from "../../miscellaneous/padding/UIPadding";
|
|
5
|
+
import { UITextSpan } from "../../miscellaneous/text-span/UITextSpan";
|
|
6
|
+
import { UITextStyle } from "../../miscellaneous/text-style/UITextStyle";
|
|
7
|
+
import { UIElement } from "../UIElement";
|
|
8
|
+
import type { UITextContent } from "./UIText.Interfaces";
|
|
9
|
+
import type { UITextOptions } from "./UIText.Internal";
|
|
10
|
+
import { UITextResizeMode } from "./UIText.Internal";
|
|
11
|
+
/** Canvas-based text rendering element */
|
|
12
|
+
export declare class UIText extends UIElement {
|
|
13
|
+
/** Multiplicative tint. Alpha channel controls opacity. */
|
|
14
|
+
readonly color: UIColor;
|
|
15
|
+
/** Text padding in world units */
|
|
16
|
+
readonly padding: UIPadding;
|
|
17
|
+
/** Default style applied to all text spans */
|
|
18
|
+
readonly commonStyle: UITextStyle;
|
|
19
|
+
private readonly canvas;
|
|
20
|
+
private readonly context;
|
|
21
|
+
private texture;
|
|
22
|
+
private contentInternal;
|
|
23
|
+
private contentDirty;
|
|
24
|
+
private maxLineWidthInternal;
|
|
25
|
+
private maxLineWidthDirty;
|
|
26
|
+
private resizeModeInternal;
|
|
27
|
+
private resizeModeDirty;
|
|
28
|
+
private lastWidth;
|
|
29
|
+
private lastHeight;
|
|
30
|
+
private textChunks;
|
|
31
|
+
private textChunksDirty;
|
|
32
|
+
/**
|
|
33
|
+
* Creates a new UIText instance.
|
|
34
|
+
*
|
|
35
|
+
* @param layer - Layer containing this element
|
|
36
|
+
* @param content - Text content as string or styled spans
|
|
37
|
+
* @param options - Configuration options
|
|
38
|
+
*/
|
|
39
|
+
constructor(layer: UILayer, content: UITextContent, options?: Partial<UITextOptions>);
|
|
40
|
+
/** Text content as array of styled spans */
|
|
41
|
+
get content(): UITextSpan[];
|
|
42
|
+
/** Maximum line width before wrapping in pixels */
|
|
43
|
+
get maxLineWidth(): number;
|
|
44
|
+
/** Controls how text adapts to element size */
|
|
45
|
+
get resizeMode(): UITextResizeMode;
|
|
46
|
+
/** Text content as string, span config, or array */
|
|
47
|
+
set content(value: UITextContent);
|
|
48
|
+
/** Maximum line width before wrapping in pixels */
|
|
49
|
+
set maxLineWidth(value: number);
|
|
50
|
+
/** Controls how text adapts to size constraints */
|
|
51
|
+
set resizeMode(value: UITextResizeMode);
|
|
52
|
+
/** Removes element and frees resources */
|
|
53
|
+
destroy(): void;
|
|
54
|
+
protected onWillRender(renderer: WebGLRenderer, deltaTime: number): void;
|
|
55
|
+
private tryToRenderTextScaleMode;
|
|
56
|
+
private tryToRenderTextBreakMode;
|
|
57
|
+
private rebuildTexture;
|
|
58
|
+
private buildTextChunks;
|
|
59
|
+
private checkDimensionsDirty;
|
|
60
|
+
private setDimensionsDirtyFalse;
|
|
61
|
+
private checkContentDirty;
|
|
62
|
+
private setContentDirtyFalse;
|
|
63
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export
|
|
18
|
-
export
|
|
19
|
-
export
|
|
20
|
-
export
|
|
21
|
-
export
|
|
22
|
-
export
|
|
23
|
-
export
|
|
24
|
-
export
|
|
25
|
-
export
|
|
26
|
-
export
|
|
27
|
-
export
|
|
28
|
-
export
|
|
29
|
-
export
|
|
30
|
-
export
|
|
31
|
-
export
|
|
32
|
-
export
|
|
33
|
-
export
|
|
34
|
-
export
|
|
35
|
-
export
|
|
36
|
-
export
|
|
37
|
-
export
|
|
38
|
-
export
|
|
39
|
-
export
|
|
40
|
-
export
|
|
41
|
-
export
|
|
42
|
-
export
|
|
43
|
-
export
|
|
44
|
-
export
|
|
45
|
-
export
|
|
46
|
-
export
|
|
1
|
+
export { UIConstraint2DBuilder } from "./constraints/builders/UIConstraint2DBuilder";
|
|
2
|
+
export { UICoverConstraintBuilder } from "./constraints/builders/UICoverConstraintBuilder";
|
|
3
|
+
export { UIFitConstraintBuilder } from "./constraints/builders/UIFitConstraintBuilder";
|
|
4
|
+
export { UIAspectConstraint } from "./constraints/UIAspectConstraint";
|
|
5
|
+
export { UICustomConstraint } from "./constraints/UICustomConstraint";
|
|
6
|
+
export { UIHeightConstraint } from "./constraints/UIHeightConstraint";
|
|
7
|
+
export { UIHorizontalDistanceConstraint } from "./constraints/UIHorizontalDistanceConstraint";
|
|
8
|
+
export { UIHorizontalProportionConstraint } from "./constraints/UIHorizontalProportionConstraint";
|
|
9
|
+
export { UISingleParameterConstraint } from "./constraints/UISingleParameterConstraint";
|
|
10
|
+
export { UIVerticalDistanceConstraint } from "./constraints/UIVerticalDistanceConstraint";
|
|
11
|
+
export { UIVerticalProportionConstraint } from "./constraints/UIVerticalProportionConstraint";
|
|
12
|
+
export { UIWidthConstraint } from "./constraints/UIWidthConstraint";
|
|
13
|
+
export { UIAnchor } from "./elements/UIAnchor";
|
|
14
|
+
export { UIAnimatedImage } from "./elements/UIAnimatedImage";
|
|
15
|
+
export { UIDummy } from "./elements/UIDummy";
|
|
16
|
+
export { UIGraphics } from "./elements/UIGraphics";
|
|
17
|
+
export { UIImage } from "./elements/UIImage";
|
|
18
|
+
export { UINineSlice } from "./elements/UINineSlice";
|
|
19
|
+
export { UINineSliceRegionMode } from "./elements/UINineSlice.Internal";
|
|
20
|
+
export { UIProgress } from "./elements/UIProgress";
|
|
21
|
+
export { UIScene } from "./elements/UIScene";
|
|
22
|
+
export { UISceneUpdateMode } from "./elements/UIScene.Internal";
|
|
23
|
+
export { UIText } from "./elements/UIText/UIText";
|
|
24
|
+
export { UITextResizeMode } from "./elements/UIText/UIText.Internal";
|
|
25
|
+
export { UIFullscreenLayer } from "./layers/UIFullscreenLayer";
|
|
26
|
+
export { UIAreaCircle } from "./miscellaneous/area/UIAreaCircle";
|
|
27
|
+
export { UIAreaPolygon } from "./miscellaneous/area/UIAreaPolygon";
|
|
28
|
+
export { UIAreaRectangle } from "./miscellaneous/area/UIAreaRectangle";
|
|
29
|
+
export { UIAreaRoundedRectangle } from "./miscellaneous/area/UIAreaRoundedRectangle";
|
|
30
|
+
export { UIColor } from "./miscellaneous/color/UIColor";
|
|
31
|
+
export { UIProgressMaskFunctionCircular } from "./miscellaneous/mask-function/UIProgressMaskFunctionCircular";
|
|
32
|
+
export { UIProgressMaskFunctionDirectional } from "./miscellaneous/mask-function/UIProgressMaskFunctionDirectional";
|
|
33
|
+
export { UIMicro } from "./miscellaneous/micro/UIMicro";
|
|
34
|
+
export { UIMicroAnchorMode } from "./miscellaneous/micro/UIMicro.Internal";
|
|
35
|
+
export { UIResizePolicyCross } from "./miscellaneous/resize-policy/UIResizePolicyCross";
|
|
36
|
+
export { UIResizePolicyCrossInverted } from "./miscellaneous/resize-policy/UIResizePolicyCrossInverted";
|
|
37
|
+
export { UIResizePolicyFixedHeight } from "./miscellaneous/resize-policy/UIResizePolicyFixedHeight";
|
|
38
|
+
export { UIResizePolicyFixedWidth } from "./miscellaneous/resize-policy/UIResizePolicyFixedWidth";
|
|
39
|
+
export { UIResizePolicyNone } from "./miscellaneous/resize-policy/UIResizePolicyNone";
|
|
40
|
+
export { UIExpression } from "./miscellaneous/UIExpression";
|
|
41
|
+
export { UIInputEvent } from "./miscellaneous/UIInputEvent";
|
|
42
|
+
export { UIMode } from "./miscellaneous/UIMode";
|
|
43
|
+
export { UIOrientation } from "./miscellaneous/UIOrientation";
|
|
44
|
+
export { UIPriority } from "./miscellaneous/UIPriority";
|
|
45
|
+
export { UIRelation } from "./miscellaneous/UIRelation";
|
|
46
|
+
export { UITransparencyMode } from "./miscellaneous/UITransparencyMode";
|