laymur 0.3.24 → 0.3.26

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
@@ -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
@@ -4781,6 +4781,13 @@ class UIElement extends UIAnchor {
4781
4781
  get height() {
4782
4782
  return this.solverWrapper.readVariableValue(this.hVariable);
4783
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
+ }
4784
4791
  /**
4785
4792
  * The right edge X coordinate of this element (x + width).
4786
4793
  */
@@ -4805,13 +4812,6 @@ class UIElement extends UIAnchor {
4805
4812
  get centerY() {
4806
4813
  return this.y + this.height / 2;
4807
4814
  }
4808
- /**
4809
- * Gets the current z-index (depth) value.
4810
- * @returns The current z-index value
4811
- */
4812
- get zIndex() {
4813
- return this.zIndexInternal;
4814
- }
4815
4815
  /**
4816
4816
  * Gets the current visibility and interaction mode.
4817
4817
  * @returns The current UIMode setting
@@ -4861,6 +4861,30 @@ class UIElement extends UIAnchor {
4861
4861
  this.layer["setListenerZIndex"](this.listener, value);
4862
4862
  }
4863
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
+ }
4864
4888
  /**
4865
4889
  * Sets the current visibility and interaction mode.
4866
4890
  * @param value - The new UIMode setting
@@ -6220,6 +6244,9 @@ function isUITextStyle(obj) {
6220
6244
  }
6221
6245
  const candidate = obj;
6222
6246
  return (typeof candidate.color === "string" &&
6247
+ (candidate.align === "left" ||
6248
+ candidate.align === "center" ||
6249
+ candidate.align === "right") &&
6223
6250
  typeof candidate.fontFamily === "string" &&
6224
6251
  typeof candidate.fontSize === "number" &&
6225
6252
  (candidate.fontStyle === "normal" ||
@@ -6242,6 +6269,7 @@ function isUITextStyle(obj) {
6242
6269
  }
6243
6270
  const DEFAULT_TEXT_STYLE = {
6244
6271
  color: "#000000",
6272
+ align: "left",
6245
6273
  fontFamily: "Arial",
6246
6274
  fontSize: 16,
6247
6275
  fontStyle: "normal",
@@ -6284,6 +6312,7 @@ function resolveTextStyle(style, commonStyle) {
6284
6312
  assertValidNonNegativeNumber(strokeWidth, "Stroke width");
6285
6313
  return {
6286
6314
  color: style?.color ?? commonStyle?.color ?? DEFAULT_TEXT_STYLE.color,
6315
+ align: style?.align ?? commonStyle?.align ?? DEFAULT_TEXT_STYLE.align,
6287
6316
  fontFamily: style?.fontFamily ??
6288
6317
  commonStyle?.fontFamily ??
6289
6318
  DEFAULT_TEXT_STYLE.fontFamily,
@@ -6420,6 +6449,7 @@ function renderText(x, y, text, style, context) {
6420
6449
  context.strokeText(text, x, y);
6421
6450
  }
6422
6451
  context.fillStyle = style.color;
6452
+ context.textAlign = style.align;
6423
6453
  context.fillText(text, x, y);
6424
6454
  }
6425
6455
  function renderTextLines(paddingTop, paddingLeft, lines, context) {