laymur 0.5.0 → 0.6.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/dist/elements/UIElement.d.ts +4 -4
- package/dist/elements/UIGraphics.d.ts +9 -6
- package/dist/elements/UIImage.d.ts +3 -0
- package/dist/elements/UINineSline.d.ts +3 -0
- package/dist/elements/UIProgress.d.ts +12 -9
- package/dist/elements/UIScene.d.ts +3 -0
- package/dist/elements/UISpine.d.ts +3 -0
- package/dist/elements/UIText.d.ts +3 -0
- package/dist/index.js +41 -26
- 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/UILayer.d.ts +6 -6
- package/package.json +1 -1
|
@@ -162,10 +162,10 @@ export declare abstract class UIElement extends UIAnchor implements UIPlaneEleme
|
|
|
162
162
|
* the element should not be used anymore.
|
|
163
163
|
*/
|
|
164
164
|
destroy(): void;
|
|
165
|
-
protected readonly catchPointerDown: (x: number, y: number) => boolean;
|
|
166
|
-
protected readonly catchPointerMove: (x: number, y: number) => boolean;
|
|
167
|
-
protected readonly catchPointerUp: (x: number, y: number) => boolean;
|
|
168
|
-
protected handleInputEvent(x: number, y: number, inputEvent: UIInputEvent): boolean;
|
|
165
|
+
protected readonly catchPointerDown: (x: number, y: number, identifier: number) => boolean;
|
|
166
|
+
protected readonly catchPointerMove: (x: number, y: number, identifier: number) => boolean;
|
|
167
|
+
protected readonly catchPointerUp: (x: number, y: number, identifier: number) => boolean;
|
|
168
|
+
protected handleInputEvent(x: number, y: number, identifier: number, inputEvent: UIInputEvent): boolean;
|
|
169
169
|
/**
|
|
170
170
|
* Called before each render frame to update the element's transform matrix.
|
|
171
171
|
* Applies micro-transformations (position, rotation, scale, anchor) and updates
|
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import type { UILayer } from "../layers/UILayer";
|
|
2
2
|
import { UIColor } from "../miscellaneous/UIColor";
|
|
3
|
+
import type { UIMode } from "../miscellaneous/UIMode";
|
|
3
4
|
import { UIElement } from "./UIElement";
|
|
4
5
|
/**
|
|
5
6
|
* Configuration options for creating a UIGraphics element.
|
|
6
7
|
*/
|
|
7
8
|
export interface UIGraphicsOptions {
|
|
8
9
|
/** X position of the element */
|
|
9
|
-
x
|
|
10
|
+
x: number;
|
|
10
11
|
/** Y position of the element */
|
|
11
|
-
y
|
|
12
|
+
y: number;
|
|
12
13
|
/** Width of the canvas (default: 512) */
|
|
13
|
-
width
|
|
14
|
+
width: number;
|
|
14
15
|
/** Height of the canvas (default: 512) */
|
|
15
|
-
height
|
|
16
|
+
height: number;
|
|
16
17
|
/** Color tint applied to the graphics */
|
|
17
|
-
color
|
|
18
|
+
color: UIColor;
|
|
19
|
+
/** Default UIMode */
|
|
20
|
+
mode: UIMode;
|
|
18
21
|
}
|
|
19
22
|
/**
|
|
20
23
|
* UI element for drawing graphics using 2D canvas API.
|
|
@@ -38,7 +41,7 @@ export declare class UIGraphics extends UIElement {
|
|
|
38
41
|
* @param layer - The UI layer that contains this graphics element
|
|
39
42
|
* @param options - Configuration options for the graphics element
|
|
40
43
|
*/
|
|
41
|
-
constructor(layer: UILayer, options?: UIGraphicsOptions);
|
|
44
|
+
constructor(layer: UILayer, options?: Partial<UIGraphicsOptions>);
|
|
42
45
|
/**
|
|
43
46
|
* Gets the current color tint applied to the graphics.
|
|
44
47
|
*/
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Texture } from "three";
|
|
2
2
|
import type { UILayer } from "../layers/UILayer";
|
|
3
3
|
import { UIColor } from "../miscellaneous/UIColor";
|
|
4
|
+
import type { UIMode } from "../miscellaneous/UIMode";
|
|
4
5
|
import { UIElement } from "./UIElement";
|
|
5
6
|
/**
|
|
6
7
|
* Configuration options for creating a UIImage element.
|
|
@@ -16,6 +17,8 @@ export interface UIImageOptions {
|
|
|
16
17
|
height: number;
|
|
17
18
|
/** Color tint applied to the image */
|
|
18
19
|
color: UIColor;
|
|
20
|
+
/** Default UIMode */
|
|
21
|
+
mode: UIMode;
|
|
19
22
|
}
|
|
20
23
|
/**
|
|
21
24
|
* UI element for displaying textured images.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Texture, WebGLRenderer } from "three";
|
|
2
2
|
import { type UILayer } from "../layers/UILayer";
|
|
3
3
|
import { UIColor } from "../miscellaneous/UIColor";
|
|
4
|
+
import type { UIMode } from "../miscellaneous/UIMode";
|
|
4
5
|
import { type UINineSliceBorders } from "../miscellaneous/UINineSliceBorder";
|
|
5
6
|
import { UIElement } from "./UIElement";
|
|
6
7
|
/**
|
|
@@ -15,6 +16,8 @@ export interface UINineSliceOptions {
|
|
|
15
16
|
color: UIColor;
|
|
16
17
|
/** Nine-slice border configuration (can be number, object with horizontal/vertical, or full border object) */
|
|
17
18
|
sliceBorders: UINineSliceBorders;
|
|
19
|
+
/** Default UIMode */
|
|
20
|
+
mode: UIMode;
|
|
18
21
|
}
|
|
19
22
|
/**
|
|
20
23
|
* Nine-slice UI element for scalable images with preserved border regions.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Texture } from "three";
|
|
2
2
|
import type { UILayer } from "../layers/UILayer";
|
|
3
3
|
import { UIColor } from "../miscellaneous/UIColor";
|
|
4
|
+
import type { UIMode } from "../miscellaneous/UIMode";
|
|
4
5
|
import { UIElement } from "./UIElement";
|
|
5
6
|
/**
|
|
6
7
|
* Predefined mask functions that control how the progress bar fills.
|
|
@@ -23,23 +24,25 @@ export declare enum UIProgressMaskFunction {
|
|
|
23
24
|
*/
|
|
24
25
|
export interface UIProgressOptions {
|
|
25
26
|
/** X position of the element */
|
|
26
|
-
x
|
|
27
|
+
x: number;
|
|
27
28
|
/** Y position of the element */
|
|
28
|
-
y
|
|
29
|
+
y: number;
|
|
29
30
|
/** Optional background texture (if not provided, default texture is used) */
|
|
30
|
-
backgroundTexture
|
|
31
|
+
backgroundTexture: Texture;
|
|
31
32
|
/** Overall color tint applied to the entire progress bar */
|
|
32
|
-
color
|
|
33
|
+
color: UIColor;
|
|
33
34
|
/** Foreground color tint applied to the filled portion */
|
|
34
|
-
foregroundColor
|
|
35
|
+
foregroundColor: UIColor;
|
|
35
36
|
/** Background color tint applied to the unfilled portion */
|
|
36
|
-
backgroundColor
|
|
37
|
+
backgroundColor: UIColor;
|
|
37
38
|
/** Mask function that defines how the progress bar fills (predefined enum or custom GLSL code) */
|
|
38
|
-
maskFunction
|
|
39
|
+
maskFunction: UIProgressMaskFunction | string;
|
|
39
40
|
/** Progress value between 0.0 (empty) and 1.0 (full) */
|
|
40
|
-
progress
|
|
41
|
+
progress: number;
|
|
41
42
|
/** Whether to fill in reverse direction (true for reverse, false for normal) */
|
|
42
|
-
inverseDirection
|
|
43
|
+
inverseDirection: boolean;
|
|
44
|
+
/** Default UIMode */
|
|
45
|
+
mode: UIMode;
|
|
43
46
|
}
|
|
44
47
|
/**
|
|
45
48
|
* Progress bar UI element with customizable fill direction and appearance.
|
|
@@ -2,6 +2,7 @@ import type { Camera, WebGLRenderer } from "three";
|
|
|
2
2
|
import { Scene } from "three";
|
|
3
3
|
import { type UILayer } from "../layers/UILayer";
|
|
4
4
|
import { UIColor } from "../miscellaneous/UIColor";
|
|
5
|
+
import type { UIMode } from "../miscellaneous/UIMode";
|
|
5
6
|
import { UIElement } from "./UIElement";
|
|
6
7
|
/**
|
|
7
8
|
* Update modes for controlling when the 3D scene should be re-rendered.
|
|
@@ -44,6 +45,8 @@ export interface UISceneOptions {
|
|
|
44
45
|
clearAlpha: number;
|
|
45
46
|
/** Whether to enable depth buffer for the render target. */
|
|
46
47
|
enableDepthBuffer: boolean;
|
|
48
|
+
/** Default UIMode */
|
|
49
|
+
mode: UIMode;
|
|
47
50
|
}
|
|
48
51
|
/**
|
|
49
52
|
* UI element for rendering 3D scenes to texture within the UI system.
|
|
@@ -2,6 +2,7 @@ import type { SkeletonData } from "@esotericsoftware/spine-threejs";
|
|
|
2
2
|
import { SkeletonMesh } from "@esotericsoftware/spine-threejs";
|
|
3
3
|
import type { WebGLRenderer } from "three";
|
|
4
4
|
import type { UILayer } from "../layers/UILayer";
|
|
5
|
+
import type { UIMode } from "../miscellaneous/UIMode";
|
|
5
6
|
import { UIElement } from "./UIElement";
|
|
6
7
|
/**
|
|
7
8
|
* Configuration options for creating a UISpine element.
|
|
@@ -15,6 +16,8 @@ export interface UISpineOptions {
|
|
|
15
16
|
width: number;
|
|
16
17
|
/** Height of the element */
|
|
17
18
|
height: number;
|
|
19
|
+
/** Default UIMode */
|
|
20
|
+
mode: UIMode;
|
|
18
21
|
}
|
|
19
22
|
/**
|
|
20
23
|
* UI element for displaying Spine skeletal animations.
|
|
@@ -2,6 +2,7 @@ import type { WebGLRenderer } from "three";
|
|
|
2
2
|
import { type UILayer } from "../layers/UILayer";
|
|
3
3
|
import type { UITextContent } from "../miscellaneous/textInterfaces";
|
|
4
4
|
import { UIColor } from "../miscellaneous/UIColor";
|
|
5
|
+
import type { UIMode } from "../miscellaneous/UIMode";
|
|
5
6
|
import { type UIPadding } from "../miscellaneous/UITextPadding";
|
|
6
7
|
import { type UITextStyle } from "../miscellaneous/UITextStyle";
|
|
7
8
|
import { UIElement } from "./UIElement";
|
|
@@ -21,6 +22,8 @@ export interface UITextOptions {
|
|
|
21
22
|
padding: Partial<UIPadding>;
|
|
22
23
|
/** Common style properties applied to all text content. */
|
|
23
24
|
commonStyle: Partial<UITextStyle>;
|
|
25
|
+
/** Default UIMode */
|
|
26
|
+
mode: UIMode;
|
|
24
27
|
}
|
|
25
28
|
/**
|
|
26
29
|
* UI element for rendering dynamic text with canvas-based rendering.
|
package/dist/index.js
CHANGED
|
@@ -3050,14 +3050,14 @@ class UILayer extends i {
|
|
|
3050
3050
|
this.sceneWrapper.render(renderer);
|
|
3051
3051
|
}
|
|
3052
3052
|
}
|
|
3053
|
-
onPointerDownInternal(x, y) {
|
|
3054
|
-
this._private_handleInputEvent(x, y, "catchPointerDown");
|
|
3053
|
+
onPointerDownInternal(x, y, identifier) {
|
|
3054
|
+
this._private_handleInputEvent(x, y, "catchPointerDown", identifier);
|
|
3055
3055
|
}
|
|
3056
|
-
onPointerMoveInternal(x, y) {
|
|
3057
|
-
this._private_handleInputEvent(x, y, "catchPointerMove");
|
|
3056
|
+
onPointerMoveInternal(x, y, identifier) {
|
|
3057
|
+
this._private_handleInputEvent(x, y, "catchPointerMove", identifier);
|
|
3058
3058
|
}
|
|
3059
|
-
onPointerUpInternal(x, y) {
|
|
3060
|
-
this._private_handleInputEvent(x, y, "catchPointerUp");
|
|
3059
|
+
onPointerUpInternal(x, y, identifier) {
|
|
3060
|
+
this._private_handleInputEvent(x, y, "catchPointerUp", identifier);
|
|
3061
3061
|
}
|
|
3062
3062
|
/**
|
|
3063
3063
|
* Internal method for accessing the constraint solver wrapper.
|
|
@@ -3113,11 +3113,11 @@ class UILayer extends i {
|
|
|
3113
3113
|
}
|
|
3114
3114
|
this._private_inputListeners.splice(index, 1);
|
|
3115
3115
|
}
|
|
3116
|
-
_private_handleInputEvent(x, y, catchFunctionName) {
|
|
3116
|
+
_private_handleInputEvent(x, y, catchFunctionName, identifier) {
|
|
3117
3117
|
if (this.mode === UIMode.INTERACTIVE) {
|
|
3118
3118
|
this._private_inputListeners.sort((a, b) => b.zIndex - a.zIndex);
|
|
3119
3119
|
for (const listener of this._private_inputListeners) {
|
|
3120
|
-
if (listener[catchFunctionName](x, y)) {
|
|
3120
|
+
if (listener[catchFunctionName](x, y, identifier)) {
|
|
3121
3121
|
return;
|
|
3122
3122
|
}
|
|
3123
3123
|
}
|
|
@@ -4707,14 +4707,14 @@ class UIElement extends UIAnchor {
|
|
|
4707
4707
|
/** Internal storage for the z-index (depth) value. */
|
|
4708
4708
|
this.zIndexInternal = 0;
|
|
4709
4709
|
this.isPointerInside = false;
|
|
4710
|
-
this.catchPointerDown = (x, y) => {
|
|
4711
|
-
return this.handleInputEvent(x, y, UIInputEvent.DOWN);
|
|
4710
|
+
this.catchPointerDown = (x, y, identifier) => {
|
|
4711
|
+
return this.handleInputEvent(x, y, identifier, UIInputEvent.DOWN);
|
|
4712
4712
|
};
|
|
4713
|
-
this.catchPointerMove = (x, y) => {
|
|
4714
|
-
return this.handleInputEvent(x, y, UIInputEvent.MOVE);
|
|
4713
|
+
this.catchPointerMove = (x, y, identifier) => {
|
|
4714
|
+
return this.handleInputEvent(x, y, identifier, UIInputEvent.MOVE);
|
|
4715
4715
|
};
|
|
4716
|
-
this.catchPointerUp = (x, y) => {
|
|
4717
|
-
return this.handleInputEvent(x, y, UIInputEvent.UP);
|
|
4716
|
+
this.catchPointerUp = (x, y, identifier) => {
|
|
4717
|
+
return this.handleInputEvent(x, y, identifier, UIInputEvent.UP);
|
|
4718
4718
|
};
|
|
4719
4719
|
this.layer.on(UILayerEvent.WILL_RENDER, this.onWillRender, this);
|
|
4720
4720
|
this.wVariable = this.solverWrapper.createVariable(width, UIPriority.P6);
|
|
@@ -4892,19 +4892,16 @@ class UIElement extends UIAnchor {
|
|
|
4892
4892
|
this.sceneWrapper.destroyPlane(this.planeHandler);
|
|
4893
4893
|
super.destroy();
|
|
4894
4894
|
}
|
|
4895
|
-
handleInputEvent(x, y, inputEvent) {
|
|
4896
|
-
const isPointerInside = x > this.x &&
|
|
4897
|
-
x < this.x + this.width &&
|
|
4898
|
-
y > this.y &&
|
|
4899
|
-
y < this.y + this.height;
|
|
4895
|
+
handleInputEvent(x, y, identifier, inputEvent) {
|
|
4896
|
+
const isPointerInside = x > this.x && x < this.oppositeX && y > this.y && y < this.oppositeY;
|
|
4900
4897
|
if (isPointerInside) {
|
|
4901
|
-
this.emit(inputEvent, x, y, this);
|
|
4898
|
+
this.emit(inputEvent, x, y, identifier, this);
|
|
4902
4899
|
}
|
|
4903
4900
|
if (this.isPointerInside && !isPointerInside) {
|
|
4904
|
-
this.emit(UIInputEvent.LEAVE, x, y, this);
|
|
4901
|
+
this.emit(UIInputEvent.LEAVE, x, y, identifier, this);
|
|
4905
4902
|
}
|
|
4906
4903
|
else if (!this.isPointerInside && isPointerInside) {
|
|
4907
|
-
this.emit(UIInputEvent.ENTER, x, y, this);
|
|
4904
|
+
this.emit(UIInputEvent.ENTER, x, y, identifier, this);
|
|
4908
4905
|
}
|
|
4909
4906
|
this.isPointerInside = isPointerInside;
|
|
4910
4907
|
return isPointerInside;
|
|
@@ -5265,6 +5262,9 @@ class UIGraphics extends UIElement {
|
|
|
5265
5262
|
this._private_canvasTexture = canvasTexture;
|
|
5266
5263
|
this._private_colorInternal = color;
|
|
5267
5264
|
this._private_colorInternal.on(UIColorEvent.CHANGE, this._private_onColorChange);
|
|
5265
|
+
if (options.mode !== undefined) {
|
|
5266
|
+
this.mode = options.mode;
|
|
5267
|
+
}
|
|
5268
5268
|
}
|
|
5269
5269
|
/**
|
|
5270
5270
|
* Gets the current color tint applied to the graphics.
|
|
@@ -5444,6 +5444,9 @@ class UIImage extends UIElement {
|
|
|
5444
5444
|
this._private_textureInternal = texture;
|
|
5445
5445
|
this._private_colorInternal = color;
|
|
5446
5446
|
this._private_colorInternal.on(UIColorEvent.CHANGE, this._private_onColorChange);
|
|
5447
|
+
if (options.mode !== undefined) {
|
|
5448
|
+
this.mode = options.mode;
|
|
5449
|
+
}
|
|
5447
5450
|
}
|
|
5448
5451
|
/**
|
|
5449
5452
|
* Gets the current texture being displayed.
|
|
@@ -5594,10 +5597,13 @@ class UINineSlice extends UIElement {
|
|
|
5594
5597
|
this.sceneWrapper.setUniform(this.planeHandler, "color", color);
|
|
5595
5598
|
};
|
|
5596
5599
|
this._private_textureInternal = texture;
|
|
5597
|
-
this._private_colorInternal = color;
|
|
5598
5600
|
this._private_sliceBordersInternal = sliceBorders;
|
|
5599
5601
|
this._private_dimensions = dimensions;
|
|
5602
|
+
this._private_colorInternal = color;
|
|
5600
5603
|
this._private_colorInternal.on(UIColorEvent.CHANGE, this._private_onColorChange);
|
|
5604
|
+
if (options.mode !== undefined) {
|
|
5605
|
+
this.mode = options.mode;
|
|
5606
|
+
}
|
|
5601
5607
|
}
|
|
5602
5608
|
/**
|
|
5603
5609
|
* Gets the current texture being displayed.
|
|
@@ -5818,6 +5824,9 @@ class UIProgress extends UIElement {
|
|
|
5818
5824
|
this._private_colorInternal.on(UIColorEvent.CHANGE, this._private_onColorChange);
|
|
5819
5825
|
this._private_foregroundColorInternal.on(UIColorEvent.CHANGE, this._private_onForegroundColorChange);
|
|
5820
5826
|
this._private_backgroundColorInternal.on(UIColorEvent.CHANGE, this._private_onBackgroundColorChange);
|
|
5827
|
+
if (options.mode !== undefined) {
|
|
5828
|
+
this.mode = options.mode;
|
|
5829
|
+
}
|
|
5821
5830
|
}
|
|
5822
5831
|
/**
|
|
5823
5832
|
* Gets the foreground (fill) texture.
|
|
@@ -6041,7 +6050,6 @@ class UIScene extends UIElement {
|
|
|
6041
6050
|
this.sceneWrapper.setUniform(this.planeHandler, "color", color);
|
|
6042
6051
|
};
|
|
6043
6052
|
this._private_renderTarget = renderTarget;
|
|
6044
|
-
this._private_colorInternal = color;
|
|
6045
6053
|
this._private_sceneInternal = options.scene ?? new Scene();
|
|
6046
6054
|
this._private_cameraInternal =
|
|
6047
6055
|
options.camera ??
|
|
@@ -6053,7 +6061,11 @@ class UIScene extends UIElement {
|
|
|
6053
6061
|
if (options.updateMode === UISceneUpdateMode.PROPERTY_CHANGED) {
|
|
6054
6062
|
this._private_renderRequired = true;
|
|
6055
6063
|
}
|
|
6064
|
+
this._private_colorInternal = color;
|
|
6056
6065
|
this._private_colorInternal.on(UIColorEvent.CHANGE, this._private_onColorChange);
|
|
6066
|
+
if (options.mode !== undefined) {
|
|
6067
|
+
this.mode = options.mode;
|
|
6068
|
+
}
|
|
6057
6069
|
}
|
|
6058
6070
|
/**
|
|
6059
6071
|
* Gets the current color tint applied to the scene texture.
|
|
@@ -6540,13 +6552,16 @@ class UIText extends UIElement {
|
|
|
6540
6552
|
this._private_canvas = canvas;
|
|
6541
6553
|
this._private_context = context;
|
|
6542
6554
|
this._private_texture = texture;
|
|
6543
|
-
this._private_colorInternal = color;
|
|
6544
6555
|
this._private_contentInternal = content;
|
|
6545
6556
|
this._private_maxWidthInternal = options.maxWidth ?? DEFAULT_MAX_WIDTH;
|
|
6546
6557
|
this._private_paddingInternal = resolveTextPadding(options.padding);
|
|
6547
6558
|
this._private_commonStyleInternal = options.commonStyle ?? {};
|
|
6559
|
+
this._private_colorInternal = color;
|
|
6548
6560
|
this._private_colorInternal.on(UIColorEvent.CHANGE, this._private_onColorChange);
|
|
6549
6561
|
this._private_rebuildText();
|
|
6562
|
+
if (options.mode !== undefined) {
|
|
6563
|
+
this.mode = options.mode;
|
|
6564
|
+
}
|
|
6550
6565
|
}
|
|
6551
6566
|
/**
|
|
6552
6567
|
* Gets the current color tint applied to the text.
|
|
@@ -6791,7 +6806,7 @@ class UIFullscreenLayer extends UILayer {
|
|
|
6791
6806
|
? rect.bottom - event.clientY
|
|
6792
6807
|
: window.innerHeight - event.clientY;
|
|
6793
6808
|
const scale = this._private_resizePolicyInternal["calculateScaleInternal"](window.innerWidth, window.innerHeight);
|
|
6794
|
-
this[pointerFunctionName](x * scale, y * scale);
|
|
6809
|
+
this[pointerFunctionName](x * scale, y * scale, event.pointerId);
|
|
6795
6810
|
}
|
|
6796
6811
|
}
|
|
6797
6812
|
|