laymur 0.15.0 → 0.16.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 CHANGED
@@ -39,19 +39,19 @@ Requires Three.js >=0.175.0 <0.180.0 as a peer dependency.
39
39
  ## Quick Example
40
40
 
41
41
  ```typescript
42
- import { UIFullscreenLayer, UIImage, UIText } from 'laymur';
43
- import { WebGLRenderer, TextureLoader, Clock } from 'three';
42
+ import { UIFullscreenLayer, UIImage, UIText } from "laymur";
43
+ import { WebGLRenderer, TextureLoader, Clock } from "three";
44
44
 
45
45
  const renderer = new WebGLRenderer();
46
46
  const layer = new UIFullscreenLayer();
47
47
  const clock = new Clock();
48
48
 
49
- const texture = new TextureLoader().load('background.jpg');
49
+ const texture = new TextureLoader().load("background.jpg");
50
50
  const background = new UIImage(layer, texture, { x: 0, y: 0 });
51
- const title = new UIText(layer, 'Mobile Ad Title', {
51
+ const title = new UIText(layer, "Mobile Ad Title", {
52
52
  x: 100,
53
53
  y: 100,
54
- maxLineWidth: 800
54
+ maxLineWidth: 800,
55
55
  });
56
56
 
57
57
  function animate() {
@@ -65,9 +65,11 @@ animate();
65
65
  ## Basic Components
66
66
 
67
67
  ### Layers
68
+
68
69
  - **UIFullscreenLayer** - Handles browser window scaling
69
70
 
70
71
  ### Elements
72
+
71
73
  - **UIImage** - Display textures
72
74
  - **UIAnimatedImage** - Animated texture sequences
73
75
  - **UIText** - Text rendering with word wrapping and styled spans
@@ -78,6 +80,7 @@ animate();
78
80
  - **UIAnchor** - Positioning points
79
81
 
80
82
  ### Constraints
83
+
81
84
  - **UIWidthConstraint** / **UIHeightConstraint** - Fixed sizes
82
85
  - **UIAspectConstraint** - Maintain aspect ratios
83
86
  - **UIHorizontalDistanceConstraint** / **UIVerticalDistanceConstraint** - Spacing between elements
@@ -92,7 +95,7 @@ animate();
92
95
  The constraint system automatically calculates positions and sizes based on relationships you define:
93
96
 
94
97
  ```typescript
95
- import { UIImage, UIHorizontalDistanceConstraint, UIWidthConstraint } from 'laymur';
98
+ import { UIImage, UIHorizontalDistanceConstraint, UIWidthConstraint } from "laymur";
96
99
 
97
100
  const sidebar = new UIImage(layer, sidebarTexture, { x: 0, y: 0 });
98
101
  const content = new UIImage(layer, contentTexture, { x: 0, y: 0 });
@@ -103,8 +106,8 @@ new UIWidthConstraint(sidebar, { width: 300 });
103
106
  // 20px spacing between sidebar and content
104
107
  new UIHorizontalDistanceConstraint(sidebar, content, {
105
108
  distance: 20,
106
- anchorA: 1.0, // Right edge of sidebar
107
- anchorB: 0.0 // Left edge of content
109
+ anchorA: 1.0, // Right edge of sidebar
110
+ anchorB: 0.0, // Left edge of content
108
111
  });
109
112
  ```
110
113
 
@@ -113,16 +116,20 @@ new UIHorizontalDistanceConstraint(sidebar, content, {
113
116
  Text supports styled spans with different fonts, sizes, and colors:
114
117
 
115
118
  ```typescript
116
- import { UIText } from 'laymur';
117
-
118
- const text = new UIText(layer, [
119
- { text: 'Download ', style: { fontSize: 24, color: '#333333' } },
120
- { text: 'Now!', style: { fontSize: 32, color: '#ff0000', fontWeight: 'bold' } }
121
- ], {
122
- x: 100,
123
- y: 100,
124
- maxLineWidth: 600
125
- });
119
+ import { UIText } from "laymur";
120
+
121
+ const text = new UIText(
122
+ layer,
123
+ [
124
+ { text: "Download ", style: { fontSize: 24, color: "#333333" } },
125
+ { text: "Now!", style: { fontSize: 32, color: "#ff0000", fontWeight: "bold" } },
126
+ ],
127
+ {
128
+ x: 100,
129
+ y: 100,
130
+ maxLineWidth: 600,
131
+ },
132
+ );
126
133
  ```
127
134
 
128
135
  ## Transformations
@@ -136,7 +143,7 @@ const element = new UIImage(layer, texture, { x: 0, y: 0 });
136
143
  element.micro.x = 10;
137
144
  element.micro.scaleX = 1.2;
138
145
  element.micro.rotation = 0.1;
139
- element.micro.anchorX = 0.5; // Transform origin (0 = left/bottom, 0.5 = center, 1 = right/top)
146
+ element.micro.anchorX = 0.5; // Transform origin (0 = left/bottom, 0.5 = center, 1 = right/top)
140
147
 
141
148
  // Reset all transformations
142
149
  element.micro.reset();
@@ -151,34 +158,34 @@ UI elements and layers use type-safe signals for event handling via [Ferrsign](h
151
158
  Elements with area (width and height) can emit input events:
152
159
 
153
160
  ```typescript
154
- import { UIMode } from 'laymur';
155
- import type { UIInputEventData } from 'laymur';
161
+ import { UIMode } from "laymur";
162
+ import type { UIInputEventData } from "laymur";
156
163
 
157
164
  const button = new UIImage(layer, buttonTexture, {
158
165
  x: 0,
159
166
  y: 0,
160
- mode: UIMode.INTERACTIVE
167
+ mode: UIMode.INTERACTIVE,
161
168
  });
162
169
 
163
170
  button.signalPressed.on((data: UIInputEventData) => {
164
- console.log('Button pressed at', data.x, data.y);
165
- console.log('Element:', data.element);
171
+ console.log("Button pressed at", data.x, data.y);
172
+ console.log("Element:", data.element);
166
173
  });
167
174
 
168
175
  button.signalReleased.on((data: UIInputEventData) => {
169
- console.log('Button released');
176
+ console.log("Button released");
170
177
  });
171
178
 
172
179
  button.signalEntered.on((data: UIInputEventData) => {
173
- console.log('Pointer entered button');
180
+ console.log("Pointer entered button");
174
181
  });
175
182
 
176
183
  button.signalLeft.on((data: UIInputEventData) => {
177
- console.log('Pointer left button');
184
+ console.log("Pointer left button");
178
185
  });
179
186
 
180
187
  button.signalMoved.on((data: UIInputEventData) => {
181
- console.log('Pointer moved inside button');
188
+ console.log("Pointer moved inside button");
182
189
  });
183
190
  ```
184
191
 
@@ -187,19 +194,19 @@ button.signalMoved.on((data: UIInputEventData) => {
187
194
  Fullscreen layers emit input events:
188
195
 
189
196
  ```typescript
190
- import type { UIFullscreenLayerInputEventData } from 'laymur';
197
+ import type { UIFullscreenLayerInputEventData } from "laymur";
191
198
 
192
- layer.signalPressed.on((data: UIFullscreenLayerInputEventData) => {
193
- console.log('Layer pressed at', data.x, data.y);
194
- console.log('Layer:', data.layer);
199
+ layer.signalPointerPressed.on((data: UIFullscreenLayerInputEventData) => {
200
+ console.log("Layer pressed at", data.x, data.y);
201
+ console.log("Layer:", data.layer);
195
202
  });
196
203
 
197
- layer.signalMoved.on((data: UIFullscreenLayerInputEventData) => {
198
- console.log('Pointer moved to', data.x, data.y);
204
+ layer.signalPointerMoved.on((data: UIFullscreenLayerInputEventData) => {
205
+ console.log("Pointer moved to", data.x, data.y);
199
206
  });
200
207
 
201
- layer.signalReleased.on((data: UIFullscreenLayerInputEventData) => {
202
- console.log('Pointer released');
208
+ layer.signalPointerReleased.on((data: UIFullscreenLayerInputEventData) => {
209
+ console.log("Pointer released");
203
210
  });
204
211
  ```
205
212
 
@@ -211,15 +218,15 @@ Animated images emit playback events:
211
218
  const animation = new UIAnimatedImage(layer, frames);
212
219
 
213
220
  animation.signalPlayed.on(() => {
214
- console.log('Animation started or resumed');
221
+ console.log("Animation started or resumed");
215
222
  });
216
223
 
217
224
  animation.signalPaused.on(() => {
218
- console.log('Animation paused');
225
+ console.log("Animation paused");
219
226
  });
220
227
 
221
228
  animation.signalStopped.on(() => {
222
- console.log('Animation stopped and reset');
229
+ console.log("Animation stopped and reset");
223
230
  });
224
231
  ```
225
232
 
@@ -227,7 +234,7 @@ animation.signalStopped.on(() => {
227
234
 
228
235
  ```typescript
229
236
  const handler = (data: UIInputEventData) => {
230
- console.log('Pressed!');
237
+ console.log("Pressed!");
231
238
  };
232
239
 
233
240
  button.signalPressed.on(handler);
@@ -1,7 +1,7 @@
1
1
  import type { UIArea } from "../../miscellaneous/area/UIArea";
2
2
  import { UIMode } from "../../miscellaneous/UIMode";
3
3
  import type { UIAnchorOptions } from "../UIAnchor/UIAnchor.Internal";
4
- import type { UIInputDummy } from "./UIInputDummy";
4
+ import type { UIDummy } from "./UIDummy";
5
5
  /** Input event data */
6
6
  export interface UIInputEventData {
7
7
  /** X coordinate */
@@ -11,10 +11,10 @@ export interface UIInputEventData {
11
11
  /** Pointer identifier */
12
12
  identifier: number;
13
13
  /** Element that emitted the event */
14
- element: UIInputDummy;
14
+ element: UIDummy;
15
15
  }
16
- /** Configuration options for UIInputDummy */
17
- export interface UIInputDummyOptions extends UIAnchorOptions {
16
+ /** Configuration options for UIDummy */
17
+ export interface UIDummyOptions extends UIAnchorOptions {
18
18
  /** Width in world units */
19
19
  width: number;
20
20
  /** Height in world units */
@@ -6,9 +6,9 @@ import type { UIPlaneElement } from "../../miscellaneous/shared";
6
6
  import { UIMode } from "../../miscellaneous/UIMode";
7
7
  import type { UIInputWrapperInterface } from "../../wrappers/UIInputWrapper/UIInputWrapper.Internal";
8
8
  import { UIAnchor } from "../UIAnchor/UIAnchor";
9
- import type { UIInputDummyOptions, UIInputEventData } from "./UIInputDummy.Internal";
9
+ import type { UIDummyOptions, UIInputEventData } from "./UIDummy.Internal";
10
10
  /** Rectangular area with dimensions but no rendering */
11
- export declare class UIInputDummy extends UIAnchor implements UIPlaneElement {
11
+ export declare class UIDummy extends UIAnchor implements UIPlaneElement {
12
12
  /** Shape defining interactive region in element-local space (0,0 = bottom-left, 1,1 = top-right) */
13
13
  interactionArea: UIArea;
14
14
  /** Solver variable for width */
@@ -19,18 +19,18 @@ export declare class UIInputDummy extends UIAnchor implements UIPlaneElement {
19
19
  protected readonly inputWrapper: UIInputWrapperInterface;
20
20
  private readonly catcherHandler;
21
21
  private wasPointerInside;
22
- private readonly signalPressedInternal;
23
- private readonly signalMovedInternal;
24
- private readonly signalReleasedInternal;
25
- private readonly signalEnteredInternal;
26
- private readonly signalLeftInternal;
22
+ private readonly signalPointerPressedInternal;
23
+ private readonly signalPointerMovedInternal;
24
+ private readonly signalPointerReleasedInternal;
25
+ private readonly signalPointerEnteredInternal;
26
+ private readonly signalPointerLeftInternal;
27
27
  /**
28
- * Creates a new UIInputDummy instance.
28
+ * Creates a new UIDummy instance.
29
29
  *
30
30
  * @param layer - Layer containing this element
31
31
  * @param options - Configuration options
32
32
  */
33
- constructor(layer: UILayer, options?: Partial<UIInputDummyOptions>);
33
+ constructor(layer: UILayer, options?: Partial<UIDummyOptions>);
34
34
  /** Width in world units */
35
35
  get width(): number;
36
36
  /** Height in world units */
@@ -48,15 +48,15 @@ export declare class UIInputDummy extends UIAnchor implements UIPlaneElement {
48
48
  /** Rendering and input priority. Higher values on top. */
49
49
  get zIndex(): number;
50
50
  /** Signal fired when pointer is pressed */
51
- get signalPressed(): FerrsignView1<UIInputEventData>;
51
+ get signalPointerPressed(): FerrsignView1<UIInputEventData>;
52
52
  /** Signal fired when pointer is moved */
53
- get signalMoved(): FerrsignView1<UIInputEventData>;
53
+ get signalPointerMoved(): FerrsignView1<UIInputEventData>;
54
54
  /** Signal fired when pointer is released */
55
- get signalReleased(): FerrsignView1<UIInputEventData>;
55
+ get signalPointerReleased(): FerrsignView1<UIInputEventData>;
56
56
  /** Signal fired when pointer enters element */
57
- get signalEntered(): FerrsignView1<UIInputEventData>;
57
+ get signalPointerEntered(): FerrsignView1<UIInputEventData>;
58
58
  /** Signal fired when pointer leaves element */
59
- get signalLeft(): FerrsignView1<UIInputEventData>;
59
+ get signalPointerLeft(): FerrsignView1<UIInputEventData>;
60
60
  /** Width in world units */
61
61
  set width(value: number);
62
62
  /** Height in world units */
@@ -1,8 +1,8 @@
1
1
  import type { UIMicroConfig } from "../../miscellaneous/micro/UIMicro.Internal";
2
2
  import { UITransparencyMode } from "../../miscellaneous/UITransparencyMode";
3
- import type { UIInputDummyOptions } from "../UIInputDummy/UIInputDummy.Internal";
3
+ import type { UIDummyOptions } from "../UIDummy/UIDummy.Internal";
4
4
  /** Configuration options for UIElement */
5
- export interface UIElementOptions extends UIInputDummyOptions {
5
+ export interface UIElementOptions extends UIDummyOptions {
6
6
  /** Transforms that don't affect constraints */
7
7
  micro: Partial<UIMicroConfig>;
8
8
  /** Alpha blending mode */
@@ -5,10 +5,10 @@ import { UIMicro } from "../../miscellaneous/micro/UIMicro";
5
5
  import type { UIMode } from "../../miscellaneous/UIMode";
6
6
  import type { UITransparencyMode } from "../../miscellaneous/UITransparencyMode";
7
7
  import type { UISceneWrapperInterface } from "../../wrappers/UISceneWrapper/UISceneWrapper.Internal";
8
- import { UIInputDummy } from "../UIInputDummy/UIInputDummy";
8
+ import { UIDummy } from "../UIDummy/UIDummy";
9
9
  import type { UIElementOptions } from "./UIElement.Internal";
10
10
  /** Base class for renderable UI elements */
11
- export declare abstract class UIElement extends UIInputDummy {
11
+ export declare abstract class UIElement extends UIDummy {
12
12
  /** Transforms that don't affect constraints */
13
13
  readonly micro: UIMicro;
14
14
  protected readonly sceneWrapper: UISceneWrapperInterface;
@@ -34,4 +34,5 @@ export declare abstract class UIElement extends UIInputDummy {
34
34
  destroy(): void;
35
35
  protected setPlaneTransform(): void;
36
36
  protected onWillRender(renderer: WebGLRenderer, deltaTime: number): void;
37
+ private readonly handleWillRender;
37
38
  }
package/dist/index.d.ts CHANGED
@@ -15,9 +15,9 @@ export { UIWidthConstraint } from "./constraints/UIWidthConstraint/UIWidthConstr
15
15
  export { UIAnchor } from "./elements/UIAnchor/UIAnchor";
16
16
  export { UIAnimatedImage } from "./elements/UIAnimatedImage/UIAnimatedImage";
17
17
  export { UIAnimatedImageLoopMode } from "./elements/UIAnimatedImage/UIAnimatedImage.Internal";
18
+ export { UIDummy } from "./elements/UIDummy/UIDummy";
18
19
  export { UIGraphics } from "./elements/UIGraphics/UIGraphics";
19
20
  export { UIImage } from "./elements/UIImage/UIImage";
20
- export { UIInputDummy } from "./elements/UIInputDummy/UIInputDummy";
21
21
  export { UINineSlice } from "./elements/UINineSlice/UINineSlice";
22
22
  export { UINineSliceRegionMode } from "./elements/UINineSlice/UINineSlice.Internal";
23
23
  export { UIProgress } from "./elements/UIProgress/UIProgress";
@@ -26,6 +26,7 @@ export { UISceneUpdateMode } from "./elements/UIScene/UIScene.Internal";
26
26
  export { UIText } from "./elements/UIText/UIText";
27
27
  export { UITextResizeMode } from "./elements/UIText/UIText.Internal";
28
28
  export { UIFullscreenLayer } from "./layers/UIFullscreenLayer/UIFullscreenLayer";
29
+ export { UILayer } from "./layers/UILayer/UILayer";
29
30
  export { UIAreaCircle } from "./miscellaneous/area/UIAreaCircle";
30
31
  export { UIAreaPolygon } from "./miscellaneous/area/UIAreaPolygon";
31
32
  export { UIAreaRectangle } from "./miscellaneous/area/UIAreaRectangle";