laymur 0.6.1 → 0.8.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.
@@ -1,4 +1,4 @@
1
- import { type Camera, type Vector3, type WebGLRenderer } from "three";
1
+ import { Vector2, Vector3, type Camera, type WebGLRenderer } from "three";
2
2
  import { UIMode } from "../miscellaneous/UIMode";
3
3
  import type { UIResizePolicy } from "../miscellaneous/UIResizePolicy";
4
4
  import { UILayer } from "./UILayer";
@@ -43,7 +43,16 @@ export declare class UIFullscreenLayer extends UILayer {
43
43
  * @param camera - Camera for projection
44
44
  * @returns 2D position in layer space
45
45
  */
46
- projectWorldPosition(position: Vector3, camera: Camera): Vector3;
46
+ projectWorldPosition(position: Vector3, camera: Camera): Vector2;
47
+ /**
48
+ * Projects 2D layer position to 3D world coordinates.
49
+ *
50
+ * @param position - 2D position in layer space
51
+ * @param camera - Camera for unprojection
52
+ * @param z - Z depth in camera space (defaults to 1)
53
+ * @returns 3D position in world space
54
+ */
55
+ projectLayerPosition(position: Vector2, camera: Camera, z?: number): Vector3;
47
56
  /**
48
57
  * Handles window resize. Updates layer dimensions according to resize policy.
49
58
  */
@@ -1,126 +1,77 @@
1
1
  import { Eventail } from "eventail";
2
2
  import type { Color } from "three";
3
3
  /**
4
- * Union type of all supported color names that can be used with UIColor.
5
- * These names correspond to the predefined colors in the COLOR_NAMES database.
4
+ * Predefined color names supported by UIColor.
6
5
  */
7
6
  export type UIColorName = "black" | "white" | "red" | "green" | "blue" | "yellow" | "cyan" | "magenta" | "gray" | "grey" | "silver" | "maroon" | "olive" | "lime" | "aqua" | "teal" | "navy" | "fuchsia" | "purple" | "orange" | "pink" | "brown" | "gold" | "violet" | "indigo" | "coral" | "salmon" | "khaki" | "plum" | "orchid" | "tan" | "beige" | "mint" | "lavender" | "crimson" | "azure" | "ivory" | "snow";
8
7
  /**
9
- * Events that can be emitted by UIColor instances.
8
+ * Events emitted by UIColor.
10
9
  */
11
10
  export declare enum UIColorEvent {
12
- /** Emitted when any color property (r, g, b, a) changes. */
11
+ /** Emitted when color components change. */
13
12
  CHANGE = "change"
14
13
  }
15
14
  /**
16
- * Event-based RGBA color class with support for multiple color formats and named colors.
17
- *
18
- * UIColor provides a comprehensive color management system with support for RGB, HSL,
19
- * hexadecimal formats, and named colors. It extends Eventail to emit change events
20
- * when color properties are modified, enabling reactive color updates throughout
21
- * the UI system.
22
- *
23
- * Color components are stored as normalized values (0-1) for precision and
24
- * compatibility with graphics APIs.
25
- *
26
- * @see {@link UIColorEvent} - Events emitted by color instances
27
- * @see {@link UIColorName} - Supported named color values
15
+ * Event-based RGBA color with support for RGB, HSL, hex, and named colors.
16
+ * Color components are stored as normalized values (0-1).
28
17
  */
29
18
  export declare class UIColor extends Eventail {
30
- /** Internal storage for the red component (0-1). */
31
- rInternal: number;
32
- /** Internal storage for the green component (0-1). */
33
- gInternal: number;
34
- /** Internal storage for the blue component (0-1). */
35
- bInternal: number;
36
- /** Internal storage for the alpha component (0-1). */
37
- aInternal: number;
38
- /**
39
- * Creates a new UIColor instance with white color (1, 1, 1, 1).
40
- */
19
+ private rInternal;
20
+ private gInternal;
21
+ private bInternal;
22
+ private aInternal;
41
23
  constructor();
42
24
  /**
43
- * Creates a new UIColor instance from a named color.
44
- * @param colorName - The name of the color from the predefined color database
45
- * @param a - Optional alpha value (0-1), defaults to 1
25
+ * @param colorName - Named color
26
+ * @param a - Alpha (0-1)
46
27
  */
47
28
  constructor(colorName: UIColorName, a?: number);
48
29
  /**
49
- * Creates a new UIColor instance from RGB components.
50
- * @param r - Red component (0-1)
51
- * @param g - Green component (0-1)
52
- * @param b - Blue component (0-1)
53
- * @param a - Optional alpha value (0-1), defaults to 1
30
+ * @param r - Red (0-1)
31
+ * @param g - Green (0-1)
32
+ * @param b - Blue (0-1)
33
+ * @param a - Alpha (0-1)
54
34
  */
55
35
  constructor(r: number, g: number, b: number, a?: number);
56
36
  /**
57
- * Creates a new UIColor instance from a hexadecimal RGB value.
58
- * @param hexRGB - Hexadecimal RGB value (e.g., 0xFF0000 for red)
59
- * @param a - Optional alpha value (0-1), defaults to 1
37
+ * @param hexRGB - Hex RGB value (e.g., 0xFF0000)
38
+ * @param a - Alpha (0-1)
60
39
  */
61
40
  constructor(hexRGB: number, a?: number);
62
- /**
63
- * Gets the red component value.
64
- * @returns The red component (0-1)
65
- */
41
+ /** Red component (0-1). */
66
42
  get r(): number;
67
- /**
68
- * Gets the green component value.
69
- * @returns The green component (0-1)
70
- */
43
+ /** Green component (0-1). */
71
44
  get g(): number;
72
- /**
73
- * Gets the blue component value.
74
- * @returns The blue component (0-1)
75
- */
45
+ /** Blue component (0-1). */
76
46
  get b(): number;
77
- /**
78
- * Gets the alpha component value.
79
- * @returns The alpha component (0-1)
80
- */
47
+ /** Alpha component (0-1). */
81
48
  get a(): number;
82
- /**
83
- * Sets the red component value and emits change event.
84
- * @param value - The red component (0-1)
85
- */
86
49
  set r(value: number);
87
- /**
88
- * Sets the green component value and emits change event.
89
- * @param value - The green component (0-1)
90
- */
91
50
  set g(value: number);
92
- /**
93
- * Sets the blue component value and emits change event.
94
- * @param value - The blue component (0-1)
95
- */
96
51
  set b(value: number);
97
- /**
98
- * Sets the alpha component value and emits change event.
99
- * @param value - The alpha component (0-1)
100
- */
101
52
  set a(value: number);
102
53
  /**
103
- * Sets all color components at once and emits change event.
104
- * @param r - Red component (0-1)
105
- * @param g - Green component (0-1)
106
- * @param b - Blue component (0-1)
107
- * @param a - Alpha component (0-1), defaults to current alpha value
108
- * @returns This UIColor instance for method chaining
54
+ * Sets all color components.
55
+ *
56
+ * @param r - Red (0-1)
57
+ * @param g - Green (0-1)
58
+ * @param b - Blue (0-1)
59
+ * @param a - Alpha (0-1)
60
+ * @returns This instance
109
61
  */
110
62
  set(r: number, g: number, b: number, a?: number): this;
111
63
  /**
112
- * Converts the color to a 32-bit hexadecimal RGBA value.
113
- * @returns Hexadecimal RGBA value with alpha in the most significant byte
64
+ * Returns 32-bit hex RGBA value (alpha in MSB).
114
65
  */
115
66
  getHexRGBA(): number;
116
67
  /**
117
- * Converts the color to a 24-bit hexadecimal RGB value (ignores alpha).
118
- * @returns Hexadecimal RGB value (e.g., 0xFF0000 for red)
68
+ * Returns 24-bit hex RGB value.
119
69
  */
120
70
  getHexRGB(): number;
121
71
  /**
122
- * Converts the color to HSL (Hue, Saturation, Lightness) format.
123
- * @returns Object containing h (0-360), s (0-1), and l (0-1) values
72
+ * Converts to HSL format.
73
+ *
74
+ * @returns Object with h (0-360), s (0-1), l (0-1)
124
75
  */
125
76
  getHSL(): {
126
77
  h: number;
@@ -128,49 +79,52 @@ export declare class UIColor extends Eventail {
128
79
  l: number;
129
80
  };
130
81
  /**
131
- * Sets the color from a 32-bit hexadecimal RGBA value and emits change event.
132
- * @param hex - Hexadecimal RGBA value with alpha in the most significant byte
133
- * @returns This UIColor instance for method chaining
82
+ * Sets color from 32-bit hex RGBA value.
83
+ *
84
+ * @param hex - Hex RGBA (alpha in MSB)
85
+ * @returns This instance
134
86
  */
135
87
  setHexRGBA(hex: number): this;
136
88
  /**
137
- * Sets the color from a 24-bit hexadecimal RGB value and emits change event.
138
- * @param hex - Hexadecimal RGB value (e.g., 0xFF0000 for red)
139
- * @param a - Alpha value (0-1), defaults to current alpha
140
- * @returns This UIColor instance for method chaining
89
+ * Sets color from 24-bit hex RGB value.
90
+ *
91
+ * @param hex - Hex RGB (e.g., 0xFF0000)
92
+ * @param a - Alpha (0-1)
93
+ * @returns This instance
141
94
  */
142
95
  setHexRGB(hex: number, a?: number): this;
143
96
  /**
144
- * Sets the color from HSL (Hue, Saturation, Lightness) values and emits change event.
145
- * @param h - Hue value (0-360)
146
- * @param s - Saturation value (0-1)
147
- * @param l - Lightness value (0-1)
148
- * @param a - Alpha value (0-1), defaults to current alpha
149
- * @returns This UIColor instance for method chaining
97
+ * Sets color from HSL values.
98
+ *
99
+ * @param h - Hue (0-360)
100
+ * @param s - Saturation (0-1)
101
+ * @param l - Lightness (0-1)
102
+ * @param a - Alpha (0-1)
103
+ * @returns This instance
150
104
  */
151
105
  setHSL(h: number, s: number, l: number, a?: number): this;
152
106
  /**
153
- * Sets the color from a predefined color name and emits change event.
154
- * @param colorName - Name of the color from the predefined color database
155
- * @param a - Alpha value (0-1), defaults to current alpha
156
- * @returns This UIColor instance for method chaining
157
- * @throws Will throw an error if the color name is not recognized
107
+ * Sets color from predefined name.
108
+ *
109
+ * @param colorName - Color name
110
+ * @param a - Alpha (0-1)
111
+ * @returns This instance
112
+ * @throws Error if color name is unknown
158
113
  */
159
114
  setName(colorName: UIColorName, a?: number): this;
160
115
  /**
161
- * Copies color values from another UIColor or Three.js Color instance and emits change event.
162
- * @param color - The color to copy from (UIColor or Three.js Color)
163
- * @returns This UIColor instance for method chaining
116
+ * Returns CSS rgba() string.
164
117
  */
165
- copy(color: UIColor | Color): this;
118
+ toCSSColor(): string;
166
119
  /**
167
- * Converts the color to a CSS rgba() string.
168
- * @returns CSS rgba string (e.g., "rgba(255, 0, 0, 1)")
120
+ * Copies values from another color.
121
+ *
122
+ * @param color - UIColor or Three.js Color
123
+ * @returns This instance
169
124
  */
170
- toCSSColor(): string;
125
+ copy(color: UIColor | Color): this;
171
126
  /**
172
- * Creates a new UIColor instance with identical color values.
173
- * @returns A new UIColor instance with the same RGBA values
127
+ * Creates a copy of this color.
174
128
  */
175
129
  clone(): UIColor;
176
130
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "laymur",
3
- "version": "0.6.1",
3
+ "version": "0.8.0",
4
4
  "description": "Constraint-based UI library for Three.js mobile advertisements",
5
5
  "scripts": {
6
6
  "clean": "rm -rf dist",