laymur 0.2.18 → 0.3.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.
- package/README.md +17 -18
- package/dist/builders/UIConstraint2DBuilder.d.ts +1 -1
- package/dist/builders/UICoverConstraintBuilder.d.ts +3 -1
- package/dist/builders/UIFitConstraintBuilder.d.ts +3 -1
- package/dist/constraints/UIAspectConstraint.d.ts +0 -1
- package/dist/constraints/UIConstraint.d.ts +3 -0
- package/dist/constraints/UIHorizontalDistanceConstraint.d.ts +0 -1
- package/dist/constraints/UIHorizontalProportionConstraint.d.ts +2 -3
- package/dist/constraints/UISingleParameterConstraint.d.ts +0 -2
- package/dist/constraints/UIVerticalDistanceConstraint.d.ts +0 -1
- package/dist/constraints/UIVerticalProportionConstraint.d.ts +2 -3
- package/dist/elements/UIDummy.d.ts +7 -1
- package/dist/elements/UIElement.d.ts +52 -38
- package/dist/elements/UIImage.d.ts +30 -42
- package/dist/elements/UINineSline.d.ts +61 -68
- package/dist/elements/UIProgress.d.ts +86 -110
- package/dist/elements/UIScene.d.ts +21 -30
- package/dist/elements/UIText.d.ts +27 -41
- package/dist/index.d.ts +4 -1
- package/dist/index.js +1236 -941
- 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 +0 -4
- package/dist/layers/UILayer.d.ts +50 -3
- package/dist/miscellaneous/UIColor.d.ts +171 -0
- package/dist/miscellaneous/UIInputEvent.d.ts +7 -0
- package/dist/miscellaneous/UIMicro.d.ts +3 -3
- package/dist/miscellaneous/{UIAnchorMode.d.ts → UIMicroAnchorMode.d.ts} +1 -1
- package/dist/miscellaneous/UINineSliceBorder.d.ts +6 -6
- package/dist/miscellaneous/UISceneWrapperClientAPI.d.ts +10 -0
- package/dist/miscellaneous/UITextPadding.d.ts +1 -1
- package/dist/miscellaneous/UITransparencyMode.d.ts +26 -0
- package/dist/miscellaneous/textTools.d.ts +4 -4
- package/dist/scalable/UIScalableMesh.d.ts +0 -16
- package/dist/scalable/UIScalablePlaneMesh.d.ts +0 -14
- package/dist/wrappers/UISceneWrapper.d.ts +17 -15
- package/dist/wrappers/UISolverWrapper.d.ts +185 -0
- package/package.json +1 -1
- package/dist/materials/UIMaterial.d.ts +0 -13
- package/dist/materials/UINineSliceMaterial.d.ts +0 -27
- package/dist/materials/UIProgressMaterial.d.ts +0 -29
- package/dist/miscellaneous/threeInstances.d.ts +0 -2
package/README.md
CHANGED
|
@@ -46,21 +46,24 @@ npm install laymur
|
|
|
46
46
|
|
|
47
47
|
```typescript
|
|
48
48
|
import { UIFullscreenLayer, UIImage, UIText, UIWidthConstraint } from 'laymur';
|
|
49
|
-
import { WebGLRenderer, TextureLoader } from 'three';
|
|
49
|
+
import { WebGLRenderer, TextureLoader, Clock } from 'three';
|
|
50
50
|
|
|
51
51
|
// Create renderer and fullscreen layer
|
|
52
52
|
const renderer = new WebGLRenderer();
|
|
53
|
-
const layer = new UIFullscreenLayer(1920,
|
|
53
|
+
const layer = new UIFullscreenLayer(1920, 1080); // Fixed design dimensions
|
|
54
|
+
const clock = new Clock();
|
|
54
55
|
|
|
55
56
|
// Load a texture
|
|
56
57
|
const texture = new TextureLoader().load('my-image.jpg');
|
|
57
58
|
|
|
58
59
|
// Create UI elements
|
|
59
|
-
const background = new UIImage(layer, texture, 0, 0);
|
|
60
|
+
const background = new UIImage(layer, texture, { x: 0, y: 0 });
|
|
60
61
|
const title = new UIText(layer, 'Welcome to Laymur!', {
|
|
62
|
+
x: 100,
|
|
63
|
+
y: 100,
|
|
61
64
|
maxWidth: 800,
|
|
62
65
|
commonStyle: { fontSize: 48, color: '#ffffff' }
|
|
63
|
-
}
|
|
66
|
+
});
|
|
64
67
|
|
|
65
68
|
// Add constraints for responsive layout
|
|
66
69
|
new UIWidthConstraint(background, { width: layer.width });
|
|
@@ -115,7 +118,7 @@ import { UIImage, UIText, UIHorizontalDistanceConstraint, UIWidthConstraint } fr
|
|
|
115
118
|
|
|
116
119
|
// Create elements
|
|
117
120
|
const sidebar = new UIImage(layer, sidebarTexture, 0, 0);
|
|
118
|
-
const content = new UIText(layer, 'Main content', {
|
|
121
|
+
const content = new UIText(layer, 'Main content', { x: 0, y: 0 });
|
|
119
122
|
|
|
120
123
|
// Define layout constraints
|
|
121
124
|
new UIWidthConstraint(sidebar, { width: 300 }); // Fixed sidebar width
|
|
@@ -163,12 +166,10 @@ import { UIImage } from 'laymur';
|
|
|
163
166
|
import { TextureLoader } from 'three';
|
|
164
167
|
|
|
165
168
|
const texture = new TextureLoader().load('hero-image.jpg');
|
|
166
|
-
const heroImage = new UIImage(layer, texture
|
|
169
|
+
const heroImage = new UIImage(layer, texture);
|
|
167
170
|
|
|
168
171
|
// Modify appearance
|
|
169
|
-
heroImage.color
|
|
170
|
-
heroImage.opacity = 0.8; // Semi-transparent
|
|
171
|
-
heroImage.transparency = true; // Enable alpha blending
|
|
172
|
+
heroImage.color.setHexRGB(0xff8844, 0.5); // Orange tint, semi-transparent
|
|
172
173
|
```
|
|
173
174
|
|
|
174
175
|
### UIText - Dynamic Text Rendering
|
|
@@ -178,13 +179,11 @@ Render text with automatic word wrapping and styling:
|
|
|
178
179
|
```typescript
|
|
179
180
|
import { UIText } from 'laymur';
|
|
180
181
|
|
|
181
|
-
const description = new UIText(layer,
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
]
|
|
187
|
-
}, {
|
|
182
|
+
const description = new UIText(layer, [
|
|
183
|
+
{ text: 'Welcome to ', style: { fontSize: 24, color: '#333333' } },
|
|
184
|
+
{ text: 'Laymur', style: { fontSize: 32, color: '#0066cc', fontWeight: 'bold' } },
|
|
185
|
+
{ text: '!', style: { fontSize: 24, color: '#333333' } }
|
|
186
|
+
], {
|
|
188
187
|
maxWidth: 600,
|
|
189
188
|
padding: { top: 20, left: 20, right: 20, bottom: 20 },
|
|
190
189
|
commonStyle: { fontFamily: 'Arial, sans-serif' }
|
|
@@ -246,12 +245,12 @@ element.micro.reset();
|
|
|
246
245
|
Listen for user interactions and lifecycle events:
|
|
247
246
|
|
|
248
247
|
```typescript
|
|
249
|
-
import {
|
|
248
|
+
import { UIInputEvent } from 'laymur';
|
|
250
249
|
|
|
251
250
|
const button = new UIImage(layer, buttonTexture);
|
|
252
251
|
button.mode = UIMode.INTERACTIVE; // Enable interaction
|
|
253
252
|
|
|
254
|
-
button.on(
|
|
253
|
+
button.on(UIInputEvent.CLICK, (x, y, element) => {
|
|
255
254
|
console.log(`Button clicked at ${x}, ${y}`);
|
|
256
255
|
// Handle button click
|
|
257
256
|
});
|
|
@@ -17,7 +17,7 @@ import type { UIRelation } from "../miscellaneous/UIRelation";
|
|
|
17
17
|
*
|
|
18
18
|
* @template T - The type of values for horizontal and vertical properties
|
|
19
19
|
*/
|
|
20
|
-
|
|
20
|
+
interface UIType2D<T> {
|
|
21
21
|
/** Horizontal (x-axis) value. */
|
|
22
22
|
h?: T;
|
|
23
23
|
/** Vertical (y-axis) value. */
|
|
@@ -13,7 +13,7 @@ export interface UICoverConstraintBuilderOptions {
|
|
|
13
13
|
keepActiveAspect: boolean;
|
|
14
14
|
/** Horizontal anchor point (0.0 = left, 0.5 = center, 1.0 = right) */
|
|
15
15
|
anchorH: number;
|
|
16
|
-
/** Vertical anchor point (0.0 =
|
|
16
|
+
/** Vertical anchor point (0.0 = top, 0.5 = center, 1.0 = bottom) */
|
|
17
17
|
anchorV: number;
|
|
18
18
|
/** Orientation context for constraint calculations */
|
|
19
19
|
orientation: UIOrientation;
|
|
@@ -29,6 +29,8 @@ export interface UICoverConstraintBuilderOptions {
|
|
|
29
29
|
* - Positioned at the specified anchor point within the passive element
|
|
30
30
|
* - Sized to be at least as large as the passive element in both dimensions
|
|
31
31
|
* - Scaled proportionally to maintain aspect ratio (if enabled)
|
|
32
|
+
*
|
|
33
|
+
* The constraints ensure: passive.dimension * 1 ≤ active.dimension (active covers passive)
|
|
32
34
|
*/
|
|
33
35
|
export declare class UICoverConstraintBuilder {
|
|
34
36
|
/**
|
|
@@ -13,7 +13,7 @@ export interface UIFitConstraintBuilderOptions {
|
|
|
13
13
|
keepActiveAspect: boolean;
|
|
14
14
|
/** Horizontal anchor point (0.0 = left, 0.5 = center, 1.0 = right) */
|
|
15
15
|
anchorH: number;
|
|
16
|
-
/** Vertical anchor point (0.0 =
|
|
16
|
+
/** Vertical anchor point (0.0 = top, 0.5 = center, 1.0 = bottom) */
|
|
17
17
|
anchorV: number;
|
|
18
18
|
/** Orientation context for constraint calculations */
|
|
19
19
|
orientation: UIOrientation;
|
|
@@ -29,6 +29,8 @@ export interface UIFitConstraintBuilderOptions {
|
|
|
29
29
|
* - Positioned at the specified anchor point within the passive element
|
|
30
30
|
* - Sized to fit entirely within the passive element in both dimensions
|
|
31
31
|
* - Scaled proportionally to maintain aspect ratio (if enabled)
|
|
32
|
+
*
|
|
33
|
+
* The constraints ensure: passive.dimension * 1 ≥ active.dimension (active fits within passive)
|
|
32
34
|
*/
|
|
33
35
|
export declare class UIFitConstraintBuilder {
|
|
34
36
|
/**
|
|
@@ -23,6 +23,9 @@ export declare abstract class UIConstraint {
|
|
|
23
23
|
/**
|
|
24
24
|
* Creates a new UIConstraint instance.
|
|
25
25
|
*
|
|
26
|
+
* Automatically connects to the layer's constraint solver for managing
|
|
27
|
+
* layout relationships and constraint operations.
|
|
28
|
+
*
|
|
26
29
|
* @param layer - The UI layer that contains this constraint
|
|
27
30
|
*/
|
|
28
31
|
constructor(layer: UILayer);
|
|
@@ -88,7 +88,6 @@ export declare class UIHorizontalDistanceConstraint extends UISingleParameterCon
|
|
|
88
88
|
* For plane elements, the anchor determines the reference point within the element's width.
|
|
89
89
|
*
|
|
90
90
|
* @returns The UIExpression representing the horizontal distance calculation
|
|
91
|
-
* @private
|
|
92
91
|
*/
|
|
93
92
|
private buildLHS;
|
|
94
93
|
}
|
|
@@ -5,7 +5,7 @@ import { UISingleParameterConstraint } from "./UISingleParameterConstraint";
|
|
|
5
5
|
* Configuration options for UIHorizontalProportionConstraint creation.
|
|
6
6
|
*/
|
|
7
7
|
export interface UIHorizontalProportionConstraintOptions extends UISingleParameterConstraintOptions {
|
|
8
|
-
/** The proportional relationship between element widths (elementA.width = elementB.width
|
|
8
|
+
/** The proportional relationship between element widths (elementA.width * proportion = elementB.width). */
|
|
9
9
|
proportion: number;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
@@ -46,7 +46,7 @@ export declare class UIHorizontalProportionConstraint extends UISingleParameterC
|
|
|
46
46
|
constructor(a: UIPlaneElement, b: UIPlaneElement, options?: Partial<UIHorizontalProportionConstraintOptions>);
|
|
47
47
|
/**
|
|
48
48
|
* Gets the current proportion value being enforced.
|
|
49
|
-
* @returns The proportion ratio (elementA.width = elementB.width
|
|
49
|
+
* @returns The proportion ratio (elementA.width * proportion = elementB.width)
|
|
50
50
|
*/
|
|
51
51
|
get proportion(): number;
|
|
52
52
|
/**
|
|
@@ -61,7 +61,6 @@ export declare class UIHorizontalProportionConstraint extends UISingleParameterC
|
|
|
61
61
|
* This enforces the relationship: elementA.width * proportion = elementB.width
|
|
62
62
|
*
|
|
63
63
|
* @returns The UIExpression representing the proportional width relationship
|
|
64
|
-
* @private
|
|
65
64
|
*/
|
|
66
65
|
private buildRHS;
|
|
67
66
|
}
|
|
@@ -101,8 +101,6 @@ export declare abstract class UISingleParameterConstraint extends UIConstraint {
|
|
|
101
101
|
*
|
|
102
102
|
* Updates the constraint's enabled state in the solver based on the
|
|
103
103
|
* current orientation and the constraint's orientation setting.
|
|
104
|
-
*
|
|
105
|
-
* @private
|
|
106
104
|
*/
|
|
107
105
|
private readonly onOrientationChange;
|
|
108
106
|
}
|
|
@@ -88,7 +88,6 @@ export declare class UIVerticalDistanceConstraint extends UISingleParameterConst
|
|
|
88
88
|
* For plane elements, the anchor determines the reference point within the element's height.
|
|
89
89
|
*
|
|
90
90
|
* @returns The UIExpression representing the vertical distance calculation
|
|
91
|
-
* @private
|
|
92
91
|
*/
|
|
93
92
|
private buildLHS;
|
|
94
93
|
}
|
|
@@ -5,7 +5,7 @@ import { UISingleParameterConstraint } from "./UISingleParameterConstraint";
|
|
|
5
5
|
* Configuration options for UIVerticalProportionConstraint creation.
|
|
6
6
|
*/
|
|
7
7
|
export interface UIVerticalProportionConstraintOptions extends UISingleParameterConstraintOptions {
|
|
8
|
-
/** The proportional relationship between element heights (elementA.height = elementB.height
|
|
8
|
+
/** The proportional relationship between element heights (elementA.height * proportion = elementB.height). */
|
|
9
9
|
proportion: number;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
@@ -46,7 +46,7 @@ export declare class UIVerticalProportionConstraint extends UISingleParameterCon
|
|
|
46
46
|
constructor(a: UIPlaneElement, b: UIPlaneElement, options?: Partial<UIVerticalProportionConstraintOptions>);
|
|
47
47
|
/**
|
|
48
48
|
* Gets the current proportion value being enforced.
|
|
49
|
-
* @returns The proportion ratio (elementA.height = elementB.height
|
|
49
|
+
* @returns The proportion ratio (elementA.height * proportion = elementB.height)
|
|
50
50
|
*/
|
|
51
51
|
get proportion(): number;
|
|
52
52
|
/**
|
|
@@ -61,7 +61,6 @@ export declare class UIVerticalProportionConstraint extends UISingleParameterCon
|
|
|
61
61
|
* This enforces the relationship: elementA.height * proportion = elementB.height
|
|
62
62
|
*
|
|
63
63
|
* @returns The UIExpression representing the proportional height relationship
|
|
64
|
-
* @private
|
|
65
64
|
*/
|
|
66
65
|
private buildRHS;
|
|
67
66
|
}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import type { UILayer } from "../layers/UILayer";
|
|
2
2
|
import { type UIPlaneElement } from "../miscellaneous/asserts";
|
|
3
3
|
import { UIAnchor } from "./UIAnchor";
|
|
4
|
+
export interface UIDummyOptions {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
}
|
|
4
10
|
/**
|
|
5
11
|
* Abstract UI element that extends UIAnchor with dimensions but without rendering.
|
|
6
12
|
*
|
|
@@ -35,7 +41,7 @@ export declare abstract class UIDummy extends UIAnchor implements UIPlaneElement
|
|
|
35
41
|
* @throws Will throw an error if width or height are not valid positive numbers
|
|
36
42
|
* @see {@link assertValidPositiveNumber}
|
|
37
43
|
*/
|
|
38
|
-
constructor(layer: UILayer,
|
|
44
|
+
constructor(layer: UILayer, options?: Partial<UIDummyOptions>);
|
|
39
45
|
/**
|
|
40
46
|
* Gets the current width value from the solver.
|
|
41
47
|
* @returns The current width dimension
|
|
@@ -1,34 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
1
|
+
import type { WebGLRenderer } from "three";
|
|
2
|
+
import type { UILayerInputListener } from "../layers/UILayer";
|
|
3
|
+
import { type UILayer } from "../layers/UILayer";
|
|
3
4
|
import type { UILayerElement, UIPlaneElement } from "../miscellaneous/asserts";
|
|
4
5
|
import { UIMicro } from "../miscellaneous/UIMicro";
|
|
5
6
|
import { UIMode } from "../miscellaneous/UIMode";
|
|
6
|
-
import type {
|
|
7
|
+
import type { UISceneWrapperClientAPI } from "../miscellaneous/UISceneWrapperClientAPI";
|
|
8
|
+
import { UITransparencyMode } from "../miscellaneous/UITransparencyMode";
|
|
7
9
|
import { UIAnchor } from "./UIAnchor";
|
|
8
|
-
/**
|
|
9
|
-
* Events that can be emitted by UI elements.
|
|
10
|
-
*/
|
|
11
|
-
export declare enum UIElementEvent {
|
|
12
|
-
/** Emitted when the element is clicked. */
|
|
13
|
-
CLICK = "click"
|
|
14
|
-
}
|
|
15
10
|
/**
|
|
16
11
|
* Abstract base class for all renderable UI elements with dimensions.
|
|
17
12
|
*
|
|
18
13
|
* UIElement serves as the fundamental building block for all other UI elements
|
|
19
14
|
* that need to be visually rendered. It extends UIAnchor with dimensional properties
|
|
20
|
-
* and integrates with the Three.js rendering system through
|
|
15
|
+
* and integrates with the Three.js rendering system through shader-based planes. This class
|
|
21
16
|
* provides essential functionality for positioning, sizing, rendering, visibility,
|
|
22
17
|
* z-index management, and user interaction.
|
|
23
18
|
*
|
|
24
|
-
* @template T - The type of Three.js Object3D used for rendering
|
|
25
19
|
* @see {@link UIAnchor} - Base class providing position functionality
|
|
26
20
|
* @see {@link UIPlaneElement} - Interface defining dimensional element behavior
|
|
27
|
-
* @see {@link UISceneWrapper} - Scene management for rendering
|
|
28
21
|
* @see {@link UIMicro} - Micro-optimization utilities
|
|
29
22
|
*/
|
|
30
|
-
export declare abstract class UIElement
|
|
31
|
-
protected readonly object: T;
|
|
23
|
+
export declare abstract class UIElement extends UIAnchor implements UIPlaneElement, UILayerElement {
|
|
32
24
|
/** Micro-transformation system for non-constraint based positioning, scaling, and rotation adjustments. */
|
|
33
25
|
readonly micro: UIMicro;
|
|
34
26
|
/**
|
|
@@ -41,13 +33,18 @@ export declare abstract class UIElement<T extends Object3D = Object3D> extends U
|
|
|
41
33
|
* This variable is managed by the constraint solver system.
|
|
42
34
|
*/
|
|
43
35
|
readonly hVariable: number;
|
|
44
|
-
/**
|
|
45
|
-
* Reference to the scene wrapper for rendering management.
|
|
46
|
-
* @see {@link UISceneWrapper}
|
|
47
|
-
*/
|
|
48
|
-
protected readonly sceneWrapper: UISceneWrapper;
|
|
49
36
|
/** Internal storage for the current visibility/interaction mode. */
|
|
50
37
|
protected modeInternal: UIMode;
|
|
38
|
+
/** Internal storage for the transparency rendering mode. */
|
|
39
|
+
protected transparencyInternal: UITransparencyMode;
|
|
40
|
+
/** Internal storage for the z-index (depth) value. */
|
|
41
|
+
protected zIndexInternal: number;
|
|
42
|
+
/** Optional input listener for handling user interactions when in interactive mode. */
|
|
43
|
+
protected listener?: UILayerInputListener;
|
|
44
|
+
/** Client API for interacting with the scene wrapper (rendering system). */
|
|
45
|
+
protected readonly sceneWrapper: UISceneWrapperClientAPI;
|
|
46
|
+
/** Handle to the plane object in the rendering system. */
|
|
47
|
+
protected readonly planeHandler: number;
|
|
51
48
|
/**
|
|
52
49
|
* Creates a new UIElement instance with rendering capabilities.
|
|
53
50
|
*
|
|
@@ -56,11 +53,12 @@ export declare abstract class UIElement<T extends Object3D = Object3D> extends U
|
|
|
56
53
|
* @param y - Initial y-coordinate position
|
|
57
54
|
* @param width - Initial width dimension (must be positive)
|
|
58
55
|
* @param height - Initial height dimension (must be positive)
|
|
59
|
-
* @param
|
|
56
|
+
* @param source - GLSL shader source code for rendering this element
|
|
57
|
+
* @param uniforms - Uniform values to pass to the shader
|
|
60
58
|
* @throws Will throw an error if width or height are not valid positive numbers
|
|
61
59
|
* @see {@link assertValidPositiveNumber}
|
|
62
60
|
*/
|
|
63
|
-
constructor(layer: UILayer, x: number, y: number, width: number, height: number,
|
|
61
|
+
constructor(layer: UILayer, x: number, y: number, width: number, height: number, source: string, uniforms: Record<string, unknown>);
|
|
64
62
|
/**
|
|
65
63
|
* Gets the current width value from the solver.
|
|
66
64
|
* @returns The current width dimension
|
|
@@ -72,8 +70,8 @@ export declare abstract class UIElement<T extends Object3D = Object3D> extends U
|
|
|
72
70
|
*/
|
|
73
71
|
get height(): number;
|
|
74
72
|
/**
|
|
75
|
-
* Gets the current z-index (depth) value
|
|
76
|
-
* @returns The current z-index
|
|
73
|
+
* Gets the current z-index (depth) value.
|
|
74
|
+
* @returns The current z-index value
|
|
77
75
|
*/
|
|
78
76
|
get zIndex(): number;
|
|
79
77
|
/**
|
|
@@ -82,6 +80,12 @@ export declare abstract class UIElement<T extends Object3D = Object3D> extends U
|
|
|
82
80
|
* @see {@link UIMode}
|
|
83
81
|
*/
|
|
84
82
|
get mode(): UIMode;
|
|
83
|
+
/**
|
|
84
|
+
* Gets the current transparency rendering mode.
|
|
85
|
+
* @returns The current transparency mode
|
|
86
|
+
* @see {@link UITransparencyMode}
|
|
87
|
+
*/
|
|
88
|
+
get transparency(): UITransparencyMode;
|
|
85
89
|
/**
|
|
86
90
|
* Sets the width value through the solver system.
|
|
87
91
|
* @param value - The new width dimension (must be positive)
|
|
@@ -97,36 +101,46 @@ export declare abstract class UIElement<T extends Object3D = Object3D> extends U
|
|
|
97
101
|
*/
|
|
98
102
|
set height(value: number);
|
|
99
103
|
/**
|
|
100
|
-
* Sets the z-index (depth) value for rendering order.
|
|
104
|
+
* Sets the z-index (depth) value for rendering order and input handling.
|
|
101
105
|
* @param value - The new z-index value
|
|
102
106
|
* @throws Will throw an error if value is not a valid number
|
|
103
107
|
* @see {@link assertValidNumber}
|
|
104
108
|
*/
|
|
105
109
|
set zIndex(value: number);
|
|
106
110
|
/**
|
|
107
|
-
* Sets the visibility and interaction mode.
|
|
111
|
+
* Sets the current visibility and interaction mode.
|
|
108
112
|
* @param value - The new UIMode setting
|
|
109
113
|
* @see {@link UIMode}
|
|
110
114
|
*/
|
|
111
115
|
set mode(value: UIMode);
|
|
116
|
+
/**
|
|
117
|
+
* Sets the transparency rendering mode.
|
|
118
|
+
* @param value - The new transparency mode
|
|
119
|
+
* @see {@link UITransparencyMode}
|
|
120
|
+
*/
|
|
121
|
+
set transparency(value: UITransparencyMode);
|
|
112
122
|
/**
|
|
113
123
|
* Destroys the UI element by cleaning up all associated resources.
|
|
114
124
|
*
|
|
115
125
|
* This method removes the element from the rendering scene, cleans up
|
|
116
|
-
* dimension solver variables, and calls the parent
|
|
117
|
-
* clean up position variables. After calling this method,
|
|
118
|
-
* should not be used anymore.
|
|
126
|
+
* dimension solver variables, removes input listeners, and calls the parent
|
|
127
|
+
* destroy method to clean up position variables. After calling this method,
|
|
128
|
+
* the element should not be used anymore.
|
|
119
129
|
*/
|
|
120
130
|
destroy(): void;
|
|
121
131
|
/**
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
*
|
|
132
|
+
* Handles click events when the element is in interactive mode.
|
|
133
|
+
* @param x - The x coordinate of the click
|
|
134
|
+
* @param y - The y coordinate of the click
|
|
135
|
+
* @returns True if the click was within this element's bounds
|
|
136
|
+
*/
|
|
137
|
+
protected readonly onClick: (x: number, y: number) => boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Called before each render frame to update the element's transform matrix.
|
|
140
|
+
* Applies micro-transformations (position, rotation, scale, anchor) and updates
|
|
141
|
+
* the rendering system with the final transformation matrix.
|
|
142
|
+
* @param renderer - The WebGL renderer (unused in base implementation)
|
|
143
|
+
* @param deltaTime - Time since last frame in seconds (unused in base implementation)
|
|
130
144
|
*/
|
|
131
|
-
protected
|
|
145
|
+
protected onWillRender(renderer: WebGLRenderer, deltaTime: number): void;
|
|
132
146
|
}
|
|
@@ -1,36 +1,46 @@
|
|
|
1
1
|
import type { Texture } from "three";
|
|
2
|
-
import { Mesh } from "three";
|
|
3
2
|
import type { UILayer } from "../layers/UILayer";
|
|
3
|
+
import { UIColor } from "../miscellaneous/UIColor";
|
|
4
4
|
import { UIElement } from "./UIElement";
|
|
5
|
+
/**
|
|
6
|
+
* Configuration options for creating a UIImage element.
|
|
7
|
+
*/
|
|
8
|
+
export interface UIImageOptions {
|
|
9
|
+
/** X position of the element */
|
|
10
|
+
x: number;
|
|
11
|
+
/** Y position of the element */
|
|
12
|
+
y: number;
|
|
13
|
+
/** Color tint applied to the image */
|
|
14
|
+
color: UIColor;
|
|
15
|
+
}
|
|
5
16
|
/**
|
|
6
17
|
* UI element for displaying textured images.
|
|
7
18
|
*
|
|
8
19
|
* UIImage is a concrete implementation of UIElement that renders a textured
|
|
9
|
-
* image using
|
|
20
|
+
* image using shader-based planes. It automatically sizes itself
|
|
10
21
|
* to match the texture dimensions and provides control over visual properties
|
|
11
|
-
* such as color tinting
|
|
22
|
+
* such as color tinting.
|
|
12
23
|
*
|
|
13
24
|
* @see {@link UIElement} - Base class providing UI element functionality
|
|
14
|
-
* @see {@link UIMaterial} - Material system for rendering
|
|
15
25
|
* @see {@link Texture} - Three.js texture for image data
|
|
16
26
|
*/
|
|
17
|
-
export declare class UIImage extends UIElement
|
|
18
|
-
/**
|
|
19
|
-
private
|
|
20
|
-
/** Internal storage for the
|
|
21
|
-
private readonly
|
|
27
|
+
export declare class UIImage extends UIElement {
|
|
28
|
+
/** Internal storage for the current texture */
|
|
29
|
+
private textureInternal;
|
|
30
|
+
/** Internal storage for the color tint */
|
|
31
|
+
private readonly colorInternal;
|
|
22
32
|
/**
|
|
23
33
|
* Creates a new UIImage instance.
|
|
24
34
|
*
|
|
25
35
|
* The image will automatically size itself to match the texture's dimensions.
|
|
26
|
-
*
|
|
36
|
+
* All options have default values if not specified.
|
|
27
37
|
*
|
|
28
38
|
* @param layer - The UI layer that contains this image
|
|
29
39
|
* @param texture - The Three.js texture to display
|
|
30
|
-
* @param
|
|
31
|
-
* @
|
|
40
|
+
* @param options - Configuration options for the image
|
|
41
|
+
* @throws Will throw an error if the texture dimensions are not valid positive numbers
|
|
32
42
|
*/
|
|
33
|
-
constructor(layer: UILayer, texture: Texture,
|
|
43
|
+
constructor(layer: UILayer, texture: Texture, options?: Partial<UIImageOptions>);
|
|
34
44
|
/**
|
|
35
45
|
* Gets the current texture being displayed.
|
|
36
46
|
* @returns The current Three.js texture
|
|
@@ -38,19 +48,9 @@ export declare class UIImage extends UIElement<Mesh> {
|
|
|
38
48
|
get texture(): Texture;
|
|
39
49
|
/**
|
|
40
50
|
* Gets the current color tint applied to the image.
|
|
41
|
-
* @returns The
|
|
51
|
+
* @returns The UIColor instance
|
|
42
52
|
*/
|
|
43
|
-
get color():
|
|
44
|
-
/**
|
|
45
|
-
* Gets the current opacity level of the image.
|
|
46
|
-
* @returns The opacity value between 0.0 (transparent) and 1.0 (opaque)
|
|
47
|
-
*/
|
|
48
|
-
get opacity(): number;
|
|
49
|
-
/**
|
|
50
|
-
* Gets whether transparency is enabled for the image.
|
|
51
|
-
* @returns True if transparency is enabled, false otherwise
|
|
52
|
-
*/
|
|
53
|
-
get transparency(): boolean;
|
|
53
|
+
get color(): UIColor;
|
|
54
54
|
/**
|
|
55
55
|
* Sets a new texture for the image.
|
|
56
56
|
*
|
|
@@ -64,25 +64,13 @@ export declare class UIImage extends UIElement<Mesh> {
|
|
|
64
64
|
set texture(value: Texture);
|
|
65
65
|
/**
|
|
66
66
|
* Sets the color tint applied to the image.
|
|
67
|
-
* @param value - The
|
|
68
|
-
*/
|
|
69
|
-
set color(value: number);
|
|
70
|
-
/**
|
|
71
|
-
* Sets the opacity level of the image.
|
|
72
|
-
* @param value - The opacity value between 0.0 (transparent) and 1.0 (opaque)
|
|
67
|
+
* @param value - The UIColor instance
|
|
73
68
|
*/
|
|
74
|
-
set
|
|
69
|
+
set color(value: UIColor);
|
|
75
70
|
/**
|
|
76
|
-
*
|
|
77
|
-
* @param value - True to enable transparency, false to disable
|
|
78
|
-
*/
|
|
79
|
-
set transparency(value: boolean);
|
|
80
|
-
/**
|
|
81
|
-
* Destroys the image by cleaning up all associated resources.
|
|
82
|
-
*
|
|
83
|
-
* This method disposes of the material resources and calls the parent
|
|
84
|
-
* destroy method to clean up the underlying UI element. After calling
|
|
85
|
-
* this method, the image should not be used anymore.
|
|
71
|
+
* Destroys the UI image by cleaning up color event listeners and all associated resources.
|
|
86
72
|
*/
|
|
87
73
|
destroy(): void;
|
|
74
|
+
/** Event handler for when the color changes */
|
|
75
|
+
private readonly onColorChange;
|
|
88
76
|
}
|