laymur 0.3.23 → 0.3.25

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.
@@ -69,6 +69,11 @@ export declare abstract class UIElement extends UIAnchor implements UIPlaneEleme
69
69
  * @returns The current height dimension
70
70
  */
71
71
  get height(): number;
72
+ /**
73
+ * Gets the current z-index (depth) value.
74
+ * @returns The current z-index value
75
+ */
76
+ get zIndex(): number;
72
77
  /**
73
78
  * The right edge X coordinate of this element (x + width).
74
79
  */
@@ -85,11 +90,6 @@ export declare abstract class UIElement extends UIAnchor implements UIPlaneEleme
85
90
  * The Y coordinate of the center of this element.
86
91
  */
87
92
  get centerY(): number;
88
- /**
89
- * Gets the current z-index (depth) value.
90
- * @returns The current z-index value
91
- */
92
- get zIndex(): number;
93
93
  /**
94
94
  * Gets the current visibility and interaction mode.
95
95
  * @returns The current UIMode setting
@@ -123,6 +123,22 @@ export declare abstract class UIElement extends UIAnchor implements UIPlaneEleme
123
123
  * @see {@link assertValidNumber}
124
124
  */
125
125
  set zIndex(value: number);
126
+ /**
127
+ * The right edge X coordinate of this element (x + width).
128
+ */
129
+ set oppositeX(value: number);
130
+ /**
131
+ * The bottom edge Y coordinate of this element (y + height).
132
+ */
133
+ set oppositeY(value: number);
134
+ /**
135
+ * The X coordinate of the center of this element.
136
+ */
137
+ set centerX(value: number);
138
+ /**
139
+ * The Y coordinate of the center of this element.
140
+ */
141
+ set centerY(value: number);
126
142
  /**
127
143
  * Sets the current visibility and interaction mode.
128
144
  * @param value - The new UIMode setting
@@ -39,14 +39,6 @@ export declare class UIGraphics extends UIElement {
39
39
  * @param options - Configuration options for the graphics element
40
40
  */
41
41
  constructor(layer: UILayer, options?: UIGraphicsOptions);
42
- /**
43
- * Gets the canvas width.
44
- */
45
- get canvasWidth(): number;
46
- /**
47
- * Gets the canvas height.
48
- */
49
- get canvasHeight(): number;
50
42
  /**
51
43
  * Gets the current color tint applied to the graphics.
52
44
  */
@@ -58,9 +50,9 @@ export declare class UIGraphics extends UIElement {
58
50
  /**
59
51
  * Clears the canvas with optional fill color.
60
52
  *
61
- * @param fillColor - Optional color to fill after clearing (CSS color string)
53
+ * @param fillColor - Optional color to fill after clearing
62
54
  */
63
- clear(fillColor?: string): this;
55
+ clear(fillColor?: UIColor): this;
64
56
  /**
65
57
  * Draws a rectangle on the canvas.
66
58
  */
@@ -104,11 +96,11 @@ export declare class UIGraphics extends UIElement {
104
96
  /**
105
97
  * Sets the fill style.
106
98
  */
107
- setFillStyle(style: string | CanvasGradient | CanvasPattern): this;
99
+ setFillStyle(style: UIColor | CanvasGradient | CanvasPattern): this;
108
100
  /**
109
101
  * Sets the stroke style.
110
102
  */
111
- setStrokeStyle(style: string | CanvasGradient | CanvasPattern): this;
103
+ setStrokeStyle(style: UIColor | CanvasGradient | CanvasPattern): this;
112
104
  /**
113
105
  * Sets the line width.
114
106
  */
@@ -0,0 +1,51 @@
1
+ import type { SkeletonData } from "@esotericsoftware/spine-threejs";
2
+ import { SkeletonMesh } from "@esotericsoftware/spine-threejs";
3
+ import type { WebGLRenderer } from "three";
4
+ import type { UILayer } from "../layers/UILayer";
5
+ import { UIElement } from "./UIElement";
6
+ /**
7
+ * Configuration options for creating a UISpine element.
8
+ */
9
+ export interface UISpineOptions {
10
+ /** X position of the element */
11
+ x: number;
12
+ /** Y position of the element */
13
+ y: number;
14
+ /** Width of the element */
15
+ width: number;
16
+ /** Height of the element */
17
+ height: number;
18
+ }
19
+ /**
20
+ * UI element for displaying Spine skeletal animations.
21
+ *
22
+ * UISpine is a concrete implementation of UIElement that renders Spine
23
+ * animations. It exposes the underlying Spine API directly for full control
24
+ * over animations, bones, slots, and other Spine features.
25
+ *
26
+ * @see {@link UIElement} - Base class providing UI element functionality
27
+ * @see {@link AnimationState} - Spine animation state for controlling playback
28
+ * @see {@link Skeleton} - Spine skeleton for bone manipulation
29
+ */
30
+ export declare class UISpine extends UIElement {
31
+ /** Internal storage for the Spine SkeletonMesh (Three.js Object3D) */
32
+ private readonly skeletonMeshInternal;
33
+ /**
34
+ * Creates a new UISpine instance.
35
+ *
36
+ * @param layer - The UI layer that contains this spine animation
37
+ * @param skeletonData - The Spine skeleton data loaded from .json/.skel
38
+ * @param options - Configuration options for the spine element
39
+ */
40
+ constructor(layer: UILayer, skeletonData: SkeletonData, options?: Partial<UISpineOptions>);
41
+ /**
42
+ * Gets the Spine SkeletonMesh (Three.js Object3D).
43
+ * @returns The SkeletonMesh instance
44
+ */
45
+ get skeletonMesh(): SkeletonMesh;
46
+ /**
47
+ * Destroys the UI spine element by cleaning up color event listeners and all associated resources.
48
+ */
49
+ destroy(): void;
50
+ protected onWillRender(renderer: WebGLRenderer, deltaTime: number): void;
51
+ }
package/dist/index.js CHANGED
@@ -2133,6 +2133,16 @@ class UIColor extends i {
2133
2133
  }
2134
2134
  return this;
2135
2135
  }
2136
+ /**
2137
+ * Converts the color to a CSS rgba() string.
2138
+ * @returns CSS rgba string (e.g., "rgba(255, 0, 0, 1)")
2139
+ */
2140
+ toCSSColor() {
2141
+ const r = Math.round(this.rInternal * 255);
2142
+ const g = Math.round(this.gInternal * 255);
2143
+ const b = Math.round(this.bInternal * 255);
2144
+ return `rgba(${r}, ${g}, ${b}, ${this.aInternal})`;
2145
+ }
2136
2146
  /**
2137
2147
  * Creates a new UIColor instance with identical color values.
2138
2148
  * @returns A new UIColor instance with the same RGBA values
@@ -4771,6 +4781,13 @@ class UIElement extends UIAnchor {
4771
4781
  get height() {
4772
4782
  return this.solverWrapper.readVariableValue(this.hVariable);
4773
4783
  }
4784
+ /**
4785
+ * Gets the current z-index (depth) value.
4786
+ * @returns The current z-index value
4787
+ */
4788
+ get zIndex() {
4789
+ return this.zIndexInternal;
4790
+ }
4774
4791
  /**
4775
4792
  * The right edge X coordinate of this element (x + width).
4776
4793
  */
@@ -4795,13 +4812,6 @@ class UIElement extends UIAnchor {
4795
4812
  get centerY() {
4796
4813
  return this.y + this.height / 2;
4797
4814
  }
4798
- /**
4799
- * Gets the current z-index (depth) value.
4800
- * @returns The current z-index value
4801
- */
4802
- get zIndex() {
4803
- return this.zIndexInternal;
4804
- }
4805
4815
  /**
4806
4816
  * Gets the current visibility and interaction mode.
4807
4817
  * @returns The current UIMode setting
@@ -4851,6 +4861,30 @@ class UIElement extends UIAnchor {
4851
4861
  this.layer["setListenerZIndex"](this.listener, value);
4852
4862
  }
4853
4863
  }
4864
+ /**
4865
+ * The right edge X coordinate of this element (x + width).
4866
+ */
4867
+ set oppositeX(value) {
4868
+ this.x = value - this.width;
4869
+ }
4870
+ /**
4871
+ * The bottom edge Y coordinate of this element (y + height).
4872
+ */
4873
+ set oppositeY(value) {
4874
+ this.y = value - this.height;
4875
+ }
4876
+ /**
4877
+ * The X coordinate of the center of this element.
4878
+ */
4879
+ set centerX(value) {
4880
+ this.x = value - this.width / 2;
4881
+ }
4882
+ /**
4883
+ * The Y coordinate of the center of this element.
4884
+ */
4885
+ set centerY(value) {
4886
+ this.y = value - this.height / 2;
4887
+ }
4854
4888
  /**
4855
4889
  * Sets the current visibility and interaction mode.
4856
4890
  * @param value - The new UIMode setting
@@ -5254,18 +5288,6 @@ class UIGraphics extends UIElement {
5254
5288
  this._private_colorInternal = color;
5255
5289
  this._private_colorInternal.on(UIColorEvent.CHANGE, this._private_onColorChange);
5256
5290
  }
5257
- /**
5258
- * Gets the canvas width.
5259
- */
5260
- get canvasWidth() {
5261
- return this._private_canvas.width;
5262
- }
5263
- /**
5264
- * Gets the canvas height.
5265
- */
5266
- get canvasHeight() {
5267
- return this._private_canvas.height;
5268
- }
5269
5291
  /**
5270
5292
  * Gets the current color tint applied to the graphics.
5271
5293
  */
@@ -5281,12 +5303,12 @@ class UIGraphics extends UIElement {
5281
5303
  /**
5282
5304
  * Clears the canvas with optional fill color.
5283
5305
  *
5284
- * @param fillColor - Optional color to fill after clearing (CSS color string)
5306
+ * @param fillColor - Optional color to fill after clearing
5285
5307
  */
5286
5308
  clear(fillColor) {
5287
5309
  this._private_ctx.clearRect(0, 0, this._private_canvas.width, this._private_canvas.height);
5288
5310
  if (fillColor !== undefined) {
5289
- this._private_ctx.fillStyle = fillColor;
5311
+ this._private_ctx.fillStyle = fillColor.toCSSColor();
5290
5312
  this._private_ctx.fillRect(0, 0, this._private_canvas.width, this._private_canvas.height);
5291
5313
  }
5292
5314
  this._private_canvasTexture.needsUpdate = true;
@@ -5377,14 +5399,15 @@ class UIGraphics extends UIElement {
5377
5399
  * Sets the fill style.
5378
5400
  */
5379
5401
  setFillStyle(style) {
5380
- this._private_ctx.fillStyle = style;
5402
+ this._private_ctx.fillStyle = style instanceof UIColor ? style.toCSSColor() : style;
5381
5403
  return this;
5382
5404
  }
5383
5405
  /**
5384
5406
  * Sets the stroke style.
5385
5407
  */
5386
5408
  setStrokeStyle(style) {
5387
- this._private_ctx.strokeStyle = style;
5409
+ this._private_ctx.strokeStyle =
5410
+ style instanceof UIColor ? style.toCSSColor() : style;
5388
5411
  return this;
5389
5412
  }
5390
5413
  /**