laymur 0.2.12 → 0.2.14

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
@@ -6,6 +6,7 @@
6
6
  </p>
7
7
 
8
8
  <p align="center">
9
+ <a href="https://www.npmjs.com/package/animouse"><img src="https://img.shields.io/npm/v/laymur.svg" alt="npm version"></a>
9
10
  <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT"></a>
10
11
  <a href="https://www.typescriptlang.org/"><img src="https://img.shields.io/badge/TypeScript-%5E5.8.0-blue" alt="TypeScript"></a>
11
12
  <a href="https://threejs.org/"><img src="https://img.shields.io/badge/Three.js-%5E0.175.0-green" alt="Three.js"></a>
@@ -2,38 +2,160 @@ import type { Texture } from "three";
2
2
  import { Mesh } from "three";
3
3
  import type { UILayer } from "../layers/UILayer";
4
4
  import { UIElement } from "./UIElement";
5
+ /**
6
+ * Configuration options for creating a UIProgress element.
7
+ */
5
8
  export interface UIProgressOptions {
9
+ /** X position of the element */
6
10
  x: number;
11
+ /** Y position of the element */
7
12
  y: number;
13
+ /** Optional background texture (if not provided, only foreground is shown) */
8
14
  textureBackground: Texture;
15
+ /** Progress value between 0.0 (empty) and 1.0 (full) */
9
16
  progress: number;
10
- isForegroundDirection: boolean;
17
+ /** Direction of progress fill (true = forward, false = reverse) */
18
+ isForwardDirection: boolean;
19
+ /** Angle of progress fill in degrees (0 = horizontal, 90 = vertical) */
11
20
  angle: number;
21
+ /** Background color tint as hex number (e.g., 0xFFFFFF) */
12
22
  backgroundColor: number;
23
+ /** Foreground color tint as hex number (e.g., 0xFFFFFF) */
13
24
  foregroundColor: number;
25
+ /** Background opacity between 0.0 (transparent) and 1.0 (opaque) */
14
26
  backgroundOpacity: number;
27
+ /** Foreground opacity between 0.0 (transparent) and 1.0 (opaque) */
15
28
  foregroundOpacity: number;
16
29
  }
30
+ /**
31
+ * Progress bar UI element with customizable fill direction and appearance.
32
+ *
33
+ * UIProgress displays a progress bar that can be filled in various directions
34
+ * (horizontal, vertical, or at custom angles). It supports separate background
35
+ * and foreground textures with independent color tinting and opacity control.
36
+ *
37
+ * The progress value ranges from 0.0 (empty) to 1.0 (completely filled).
38
+ * The fill direction can be controlled both by angle and forward/reverse direction.
39
+ */
17
40
  export declare class UIProgress extends UIElement<Mesh> {
18
41
  private readonly material;
42
+ /**
43
+ * Creates a new progress bar UI element.
44
+ *
45
+ * @param layer - The UI layer to add this element to
46
+ * @param textureForeground - The texture used for the progress fill
47
+ * @param options - Configuration options for the progress bar
48
+ */
19
49
  constructor(layer: UILayer, textureForeground: Texture, options?: Partial<UIProgressOptions>);
50
+ /**
51
+ * Gets the current progress value.
52
+ * @returns Progress value between 0.0 (empty) and 1.0 (full)
53
+ */
20
54
  get progress(): number;
55
+ /**
56
+ * Gets the background texture.
57
+ * @returns The background texture, or undefined if none is set
58
+ */
21
59
  get backgroundTexture(): Texture | undefined;
60
+ /**
61
+ * Gets the foreground (fill) texture.
62
+ * @returns The foreground texture
63
+ */
22
64
  get foregroundTexture(): Texture;
65
+ /**
66
+ * Gets the background color tint.
67
+ * @returns The background color as a hex number (e.g., 0xFFFFFF)
68
+ */
23
69
  get backgroundColor(): number;
70
+ /**
71
+ * Gets the foreground color tint.
72
+ * @returns The foreground color as a hex number (e.g., 0xFFFFFF)
73
+ */
24
74
  get foregroundColor(): number;
75
+ /**
76
+ * Gets the background opacity.
77
+ * @returns Opacity value between 0.0 (transparent) and 1.0 (opaque)
78
+ */
25
79
  get backgroundOpacity(): number;
80
+ /**
81
+ * Gets the foreground opacity.
82
+ * @returns Opacity value between 0.0 (transparent) and 1.0 (opaque)
83
+ */
26
84
  get foregroundOpacity(): number;
85
+ /**
86
+ * Gets whether transparency is enabled for the image.
87
+ * @returns True if transparency is enabled, false otherwise
88
+ */
89
+ get transparency(): boolean;
90
+ /**
91
+ * Gets the progress fill angle in degrees.
92
+ * @returns Angle in degrees (0 = horizontal, 90 = vertical)
93
+ */
27
94
  get angle(): number;
95
+ /**
96
+ * Gets whether the progress fills in forward direction.
97
+ * @returns True if filling forward, false if filling in reverse
98
+ */
28
99
  get isForwardDirection(): boolean;
100
+ /**
101
+ * Sets the progress value.
102
+ * @param value - Progress value between 0.0 (empty) and 1.0 (full)
103
+ */
29
104
  set progress(value: number);
105
+ /**
106
+ * Sets the background texture.
107
+ * @param value - The background texture, or undefined to remove background
108
+ */
30
109
  set backgroundTexture(value: Texture | undefined);
110
+ /**
111
+ * Sets the foreground (fill) texture.
112
+ *
113
+ * When setting a new texture, the progress bar will automatically resize
114
+ * to match the new texture's dimensions.
115
+ *
116
+ * @param value - The new foreground texture
117
+ * @throws Will throw an error if the texture dimensions are not valid positive numbers
118
+ */
31
119
  set foregroundTexture(value: Texture);
120
+ /**
121
+ * Sets the background color tint.
122
+ * @param value - The background color as a hex number (e.g., 0xFFFFFF)
123
+ */
32
124
  set backgroundColor(value: number);
125
+ /**
126
+ * Sets the foreground color tint.
127
+ * @param value - The foreground color as a hex number (e.g., 0xFFFFFF)
128
+ */
33
129
  set foregroundColor(value: number);
130
+ /**
131
+ * Sets the background opacity.
132
+ * @param value - Opacity value between 0.0 (transparent) and 1.0 (opaque)
133
+ */
34
134
  set backgroundOpacity(value: number);
135
+ /**
136
+ * Sets the foreground opacity.
137
+ * @param value - Opacity value between 0.0 (transparent) and 1.0 (opaque)
138
+ */
35
139
  set foregroundOpacity(value: number);
140
+ /**
141
+ * Sets whether transparency is enabled for the image.
142
+ * @param value - True to enable transparency, false to disable
143
+ */
144
+ set transparency(value: boolean);
145
+ /**
146
+ * Sets the progress fill angle.
147
+ * @param value - Angle in degrees (0 = horizontal, 90 = vertical)
148
+ */
36
149
  set angle(value: number);
150
+ /**
151
+ * Sets the progress fill direction.
152
+ * @param value - True for forward direction, false for reverse
153
+ */
37
154
  set isForwardDirection(value: boolean);
155
+ /**
156
+ * Destroys the progress bar element and cleans up resources.
157
+ *
158
+ * This method disposes of the material and calls the parent destroy method.
159
+ */
38
160
  destroy(): void;
39
161
  }
package/dist/index.js CHANGED
@@ -4198,11 +4198,11 @@ class UIElement extends UIAnchor {
4198
4198
  }
4199
4199
  }
4200
4200
 
4201
- var fragmentShader$1 = "uniform sampler2D map;\nuniform float opacity;\nuniform vec3 color;\nuniform float alphaTest;\nvarying vec2 vUv;\n\nvoid main() {\n vec4 diffuseColor = texture2D(map, vUv);\n #include <alphatest_fragment>\n gl_FragColor = vec4(diffuseColor.rgb * color, diffuseColor.a * opacity);\n #include <colorspace_fragment>\n}\n";
4201
+ var fragmentShader$2 = "uniform sampler2D map;\nuniform float opacity;\nuniform vec3 color;\nuniform float alphaTest;\nvarying vec2 vUv;\n\nvoid main() {\n vec4 diffuseColor = texture2D(map, vUv);\n #include <alphatest_fragment>\n gl_FragColor = vec4(diffuseColor.rgb * color, diffuseColor.a * opacity);\n #include <colorspace_fragment>\n}\n";
4202
4202
 
4203
- var vertexShader$1 = "varying vec2 vUv;\nvoid main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n";
4203
+ var vertexShader$2 = "varying vec2 vUv;\nvoid main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n";
4204
4204
 
4205
- const DEFAULT_ALPHA_TEST$1 = 0.25;
4205
+ const DEFAULT_ALPHA_TEST$2 = 0.25;
4206
4206
  class UIMaterial extends ShaderMaterial {
4207
4207
  constructor(map) {
4208
4208
  super({
@@ -4210,12 +4210,12 @@ class UIMaterial extends ShaderMaterial {
4210
4210
  map: { value: map },
4211
4211
  opacity: { value: 1.0 },
4212
4212
  color: { value: new Color(1.0, 1.0, 1.0) },
4213
- alphaTest: { value: DEFAULT_ALPHA_TEST$1 },
4213
+ alphaTest: { value: DEFAULT_ALPHA_TEST$2 },
4214
4214
  },
4215
- vertexShader: vertexShader$1,
4216
- fragmentShader: fragmentShader$1,
4215
+ vertexShader: vertexShader$2,
4216
+ fragmentShader: fragmentShader$2,
4217
4217
  transparent: false,
4218
- alphaTest: DEFAULT_ALPHA_TEST$1,
4218
+ alphaTest: DEFAULT_ALPHA_TEST$2,
4219
4219
  lights: false,
4220
4220
  fog: false,
4221
4221
  depthWrite: false,
@@ -4252,7 +4252,7 @@ class UIMaterial extends ShaderMaterial {
4252
4252
  setTransparency(value) {
4253
4253
  if (this.transparent !== value) {
4254
4254
  this.transparent = value;
4255
- this.uniforms.alphaTest.value = !value ? DEFAULT_ALPHA_TEST$1 : 0;
4255
+ this.uniforms.alphaTest.value = !value ? DEFAULT_ALPHA_TEST$2 : 0;
4256
4256
  this.needsUpdate = true;
4257
4257
  this.uniformsNeedUpdate = true;
4258
4258
  }
@@ -4378,11 +4378,11 @@ class UIImage extends UIElement {
4378
4378
  }
4379
4379
  }
4380
4380
 
4381
- var fragmentShader = "uniform sampler2D map;\nuniform vec3 color;\nuniform float opacity;\nuniform float alphaTest;\nuniform vec4 sliceBorders;\nuniform vec2 quadSize;\nuniform vec2 textureSize;\nvarying vec2 vUv;\n\nvec2 calculateNineSliceUV(vec2 uv) {\n vec2 localUV = uv;\n\n float left = sliceBorders.x;\n float right = sliceBorders.y;\n float top = sliceBorders.z;\n float bottom = sliceBorders.w;\n\n float leftPx = left * textureSize.x;\n float rightPx = right * textureSize.x;\n float topPx = top * textureSize.y;\n float bottomPx = bottom * textureSize.y;\n\n float lB = leftPx / quadSize.x;\n float rB = 1.0 - (rightPx / quadSize.x);\n float tB = topPx / quadSize.y;\n float bB = 1.0 - (bottomPx / quadSize.y);\n\n {\n float regionL = step(uv.x, lB);\n float regionR = step(rB, uv.x);\n float regionM = 1.0 - regionL - regionR;\n\n float xL = uv.x * (left / lB);\n float xR = 1.0 - right + ((uv.x - rB) / (1.0 - rB)) * right;\n float xM = left + ((uv.x - lB) / (rB - lB)) * (1.0 - left - right);\n\n localUV.x = regionL * xL + regionM * xM + regionR * xR;\n }\n\n {\n float regionT = step(uv.y, tB);\n float regionB = step(bB, uv.y);\n float regionC = 1.0 - regionT - regionB;\n\n float yT = uv.y * (top / tB);\n float yB = 1.0 - bottom + ((uv.y - bB) / (1.0 - bB)) * bottom;\n float yC = top + ((uv.y - tB) / (bB - tB)) * (1.0 - top - bottom);\n\n localUV.y = regionT * yT + regionC * yC + regionB * yB;\n }\n\n return localUV;\n}\n\nvoid main() {\n vec4 textureColor = texture2D(map, calculateNineSliceUV(vUv));\n if (textureColor.a < alphaTest) {\n discard;\n }\n gl_FragColor = vec4(textureColor.rgb * color, textureColor.a * opacity);\n #include <colorspace_fragment>\n}\n";
4381
+ var fragmentShader$1 = "uniform sampler2D map;\nuniform vec3 color;\nuniform float opacity;\nuniform float alphaTest;\nuniform vec4 sliceBorders;\nuniform vec2 quadSize;\nuniform vec2 textureSize;\nvarying vec2 vUv;\n\nvec2 calculateNineSliceUV(vec2 uv) {\n vec2 localUV = uv;\n\n float left = sliceBorders.x;\n float right = sliceBorders.y;\n float top = sliceBorders.z;\n float bottom = sliceBorders.w;\n\n float leftPx = left * textureSize.x;\n float rightPx = right * textureSize.x;\n float topPx = top * textureSize.y;\n float bottomPx = bottom * textureSize.y;\n\n float lB = leftPx / quadSize.x;\n float rB = 1.0 - (rightPx / quadSize.x);\n float tB = topPx / quadSize.y;\n float bB = 1.0 - (bottomPx / quadSize.y);\n\n {\n float regionL = step(uv.x, lB);\n float regionR = step(rB, uv.x);\n float regionM = 1.0 - regionL - regionR;\n\n float xL = uv.x * (left / lB);\n float xR = 1.0 - right + ((uv.x - rB) / (1.0 - rB)) * right;\n float xM = left + ((uv.x - lB) / (rB - lB)) * (1.0 - left - right);\n\n localUV.x = regionL * xL + regionM * xM + regionR * xR;\n }\n\n {\n float regionT = step(uv.y, tB);\n float regionB = step(bB, uv.y);\n float regionC = 1.0 - regionT - regionB;\n\n float yT = uv.y * (top / tB);\n float yB = 1.0 - bottom + ((uv.y - bB) / (1.0 - bB)) * bottom;\n float yC = top + ((uv.y - tB) / (bB - tB)) * (1.0 - top - bottom);\n\n localUV.y = regionT * yT + regionC * yC + regionB * yB;\n }\n\n return localUV;\n}\n\nvoid main() {\n vec4 textureColor = texture2D(map, calculateNineSliceUV(vUv));\n if (textureColor.a < alphaTest) {\n discard;\n }\n gl_FragColor = vec4(textureColor.rgb * color, textureColor.a * opacity);\n #include <colorspace_fragment>\n}\n";
4382
4382
 
4383
- var vertexShader = "varying vec2 vUv;\nvoid main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n";
4383
+ var vertexShader$1 = "varying vec2 vUv;\nvoid main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n";
4384
4384
 
4385
- const DEFAULT_ALPHA_TEST = 0.025;
4385
+ const DEFAULT_ALPHA_TEST$1 = 0.025;
4386
4386
  class UINineSliceMaterial extends ShaderMaterial {
4387
4387
  constructor(texture) {
4388
4388
  super({
@@ -4390,7 +4390,7 @@ class UINineSliceMaterial extends ShaderMaterial {
4390
4390
  map: { value: texture },
4391
4391
  color: { value: new Color(0xffffff) },
4392
4392
  opacity: { value: 1.0 },
4393
- alphaTest: { value: DEFAULT_ALPHA_TEST },
4393
+ alphaTest: { value: DEFAULT_ALPHA_TEST$1 },
4394
4394
  sliceBorders: {
4395
4395
  value: new Vector4(0, 0, 0, 0),
4396
4396
  }, // left, right, top, bottom (in UV)
@@ -4399,10 +4399,10 @@ class UINineSliceMaterial extends ShaderMaterial {
4399
4399
  value: new Vector2(texture.image.width, texture.image.height),
4400
4400
  },
4401
4401
  },
4402
- vertexShader,
4403
- fragmentShader,
4402
+ vertexShader: vertexShader$1,
4403
+ fragmentShader: fragmentShader$1,
4404
4404
  transparent: false,
4405
- alphaTest: DEFAULT_ALPHA_TEST,
4405
+ alphaTest: DEFAULT_ALPHA_TEST$1,
4406
4406
  lights: false,
4407
4407
  fog: false,
4408
4408
  depthWrite: true,
@@ -4485,7 +4485,7 @@ class UINineSliceMaterial extends ShaderMaterial {
4485
4485
  setTransparency(value) {
4486
4486
  if (this.transparent !== value) {
4487
4487
  this.transparent = value;
4488
- this.uniforms.alphaTest.value = !value ? DEFAULT_ALPHA_TEST : 0;
4488
+ this.uniforms.alphaTest.value = !value ? DEFAULT_ALPHA_TEST$1 : 0;
4489
4489
  this.needsUpdate = true;
4490
4490
  this.uniformsNeedUpdate = true;
4491
4491
  }
@@ -4734,6 +4734,11 @@ class UINineSlice extends UIElement {
4734
4734
  }
4735
4735
  }
4736
4736
 
4737
+ var fragmentShader = "uniform sampler2D background;\nuniform sampler2D foreground;\nuniform float progress;\nuniform vec3 backgroundColor;\nuniform vec3 foregroundColor;\nuniform float backgroundOpacity;\nuniform float foregroundOpacity;\nuniform float alphaTest;\nuniform float angle;\nuniform float direction;\nvarying vec2 vUv;\n\nvoid main() {\n vec4 backgroundTexture = texture2D(background, vUv);\n vec4 foregroundTexture = texture2D(foreground, vUv);\n\n // Apply common color and opacity\n vec3 finalBackgroundColor = backgroundTexture.rgb * backgroundColor;\n vec3 finalForegroundColor = foregroundTexture.rgb * foregroundColor;\n float finalBackgroundOpacity = backgroundTexture.a * backgroundOpacity;\n float finalForegroundOpacity = foregroundTexture.a * foregroundOpacity;\n\n vec4 backgroundColor = vec4(finalBackgroundColor, finalBackgroundOpacity);\n vec4 foregroundColor = vec4(finalForegroundColor, finalForegroundOpacity);\n\n // Calculate progress threshold with angle and direction\n float adjustedX = mix(vUv.x, 1.0 - vUv.x, step(0.0, -direction));\n float tanAngle = tan(angle);\n float threshold = adjustedX - (vUv.y - 0.5) * tanAngle * sign(direction);\n float progressMask = step(threshold, progress);\n\n vec4 mixedColor = backgroundColor * (1.0 - foregroundColor.a * progressMask)\n + foregroundColor * (foregroundColor.a * progressMask);\n\n if (mixedColor.a < alphaTest) {\n discard;\n }\n\n gl_FragColor = mixedColor;\n #include <colorspace_fragment>\n}\n";
4738
+
4739
+ var vertexShader = "varying vec2 vUv;\nvoid main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n";
4740
+
4741
+ const DEFAULT_ALPHA_TEST = 0.025;
4737
4742
  class UIProgressMaterial extends ShaderMaterial {
4738
4743
  constructor(foregroundTexture, backgroundTexture) {
4739
4744
  super({
@@ -4746,6 +4751,7 @@ class UIProgressMaterial extends ShaderMaterial {
4746
4751
  foregroundColor: { value: new Color(1, 1, 1) },
4747
4752
  backgroundOpacity: { value: 1 },
4748
4753
  foregroundOpacity: { value: 1 },
4754
+ alphaTest: { value: DEFAULT_ALPHA_TEST },
4749
4755
  angle: { value: 0 },
4750
4756
  direction: { value: 1 },
4751
4757
  },
@@ -4769,10 +4775,10 @@ class UIProgressMaterial extends ShaderMaterial {
4769
4775
  return this.uniforms.foreground.value;
4770
4776
  }
4771
4777
  getBackgroundColor() {
4772
- return this.uniforms.color.value.getHex();
4778
+ return this.uniforms.backgroundColor.value.getHex();
4773
4779
  }
4774
4780
  getForegroundColor() {
4775
- return this.uniforms.color.value.getHex();
4781
+ return this.uniforms.foregroundColor.value.getHex();
4776
4782
  }
4777
4783
  getBackgroundOpacity() {
4778
4784
  return this.uniforms.backgroundOpacity.value;
@@ -4780,6 +4786,9 @@ class UIProgressMaterial extends ShaderMaterial {
4780
4786
  getForegroundOpacity() {
4781
4787
  return this.uniforms.foregroundOpacity.value;
4782
4788
  }
4789
+ getTransparency() {
4790
+ return this.transparent;
4791
+ }
4783
4792
  getAngle() {
4784
4793
  return this.uniforms.angle.value;
4785
4794
  }
@@ -4799,11 +4808,11 @@ class UIProgressMaterial extends ShaderMaterial {
4799
4808
  this.uniformsNeedUpdate = true;
4800
4809
  }
4801
4810
  setBackgroundColor(value) {
4802
- this.uniforms.color.value.setHex(value);
4811
+ this.uniforms.backgroundColor.value.setHex(value);
4803
4812
  this.uniformsNeedUpdate = true;
4804
4813
  }
4805
4814
  setForegroundColor(value) {
4806
- this.uniforms.color.value.setHex(value);
4815
+ this.uniforms.foregroundColor.value.setHex(value);
4807
4816
  this.uniformsNeedUpdate = true;
4808
4817
  }
4809
4818
  setBackgroundOpacity(value) {
@@ -4814,6 +4823,15 @@ class UIProgressMaterial extends ShaderMaterial {
4814
4823
  this.uniforms.foregroundOpacity.value = value;
4815
4824
  this.uniformsNeedUpdate = true;
4816
4825
  }
4826
+ setTransparency(value) {
4827
+ if (this.transparent !== value) {
4828
+ this.transparent = value;
4829
+ this.uniforms.alphaTest.value = !value ? DEFAULT_ALPHA_TEST : 0;
4830
+ this.needsUpdate = true;
4831
+ this.uniformsNeedUpdate = true;
4832
+ }
4833
+ return this;
4834
+ }
4817
4835
  setAngle(value) {
4818
4836
  this.uniforms.angle.value = value;
4819
4837
  this.uniformsNeedUpdate = true;
@@ -4824,7 +4842,24 @@ class UIProgressMaterial extends ShaderMaterial {
4824
4842
  }
4825
4843
  }
4826
4844
 
4845
+ /**
4846
+ * Progress bar UI element with customizable fill direction and appearance.
4847
+ *
4848
+ * UIProgress displays a progress bar that can be filled in various directions
4849
+ * (horizontal, vertical, or at custom angles). It supports separate background
4850
+ * and foreground textures with independent color tinting and opacity control.
4851
+ *
4852
+ * The progress value ranges from 0.0 (empty) to 1.0 (completely filled).
4853
+ * The fill direction can be controlled both by angle and forward/reverse direction.
4854
+ */
4827
4855
  class UIProgress extends UIElement {
4856
+ /**
4857
+ * Creates a new progress bar UI element.
4858
+ *
4859
+ * @param layer - The UI layer to add this element to
4860
+ * @param textureForeground - The texture used for the progress fill
4861
+ * @param options - Configuration options for the progress bar
4862
+ */
4828
4863
  constructor(layer, textureForeground, options = {}) {
4829
4864
  const foregroundWidth = textureForeground.image?.width;
4830
4865
  const foregroundHeight = textureForeground.image?.height;
@@ -4841,8 +4876,8 @@ class UIProgress extends UIElement {
4841
4876
  if (options.progress !== undefined) {
4842
4877
  material.setProgress(options.progress);
4843
4878
  }
4844
- if (options.isForegroundDirection !== undefined) {
4845
- material.setIsForwardDirection(options.isForegroundDirection);
4879
+ if (options.isForwardDirection !== undefined) {
4880
+ material.setIsForwardDirection(options.isForwardDirection);
4846
4881
  }
4847
4882
  if (options.angle !== undefined) {
4848
4883
  material.setAngle(MathUtils.degToRad(options.angle));
@@ -4864,72 +4899,168 @@ class UIProgress extends UIElement {
4864
4899
  super(layer, options.x ?? 0, options.y ?? 0, imageWidth, imageHeight, object);
4865
4900
  this._private_material = material;
4866
4901
  }
4902
+ /**
4903
+ * Gets the current progress value.
4904
+ * @returns Progress value between 0.0 (empty) and 1.0 (full)
4905
+ */
4867
4906
  get progress() {
4868
4907
  return this._private_material.getProgress();
4869
4908
  }
4909
+ /**
4910
+ * Gets the background texture.
4911
+ * @returns The background texture, or undefined if none is set
4912
+ */
4870
4913
  get backgroundTexture() {
4871
4914
  return this._private_material.getBackgroundTexture();
4872
4915
  }
4916
+ /**
4917
+ * Gets the foreground (fill) texture.
4918
+ * @returns The foreground texture
4919
+ */
4873
4920
  get foregroundTexture() {
4874
4921
  return this._private_material.getForegroundTexture();
4875
4922
  }
4923
+ /**
4924
+ * Gets the background color tint.
4925
+ * @returns The background color as a hex number (e.g., 0xFFFFFF)
4926
+ */
4876
4927
  get backgroundColor() {
4877
4928
  return this._private_material.getBackgroundColor();
4878
4929
  }
4930
+ /**
4931
+ * Gets the foreground color tint.
4932
+ * @returns The foreground color as a hex number (e.g., 0xFFFFFF)
4933
+ */
4879
4934
  get foregroundColor() {
4880
4935
  return this._private_material.getForegroundColor();
4881
4936
  }
4937
+ /**
4938
+ * Gets the background opacity.
4939
+ * @returns Opacity value between 0.0 (transparent) and 1.0 (opaque)
4940
+ */
4882
4941
  get backgroundOpacity() {
4883
4942
  return this._private_material.getBackgroundOpacity();
4884
4943
  }
4944
+ /**
4945
+ * Gets the foreground opacity.
4946
+ * @returns Opacity value between 0.0 (transparent) and 1.0 (opaque)
4947
+ */
4885
4948
  get foregroundOpacity() {
4886
4949
  return this._private_material.getForegroundOpacity();
4887
4950
  }
4951
+ /**
4952
+ * Gets whether transparency is enabled for the image.
4953
+ * @returns True if transparency is enabled, false otherwise
4954
+ */
4955
+ get transparency() {
4956
+ return this._private_material.getTransparency();
4957
+ }
4958
+ /**
4959
+ * Gets the progress fill angle in degrees.
4960
+ * @returns Angle in degrees (0 = horizontal, 90 = vertical)
4961
+ */
4888
4962
  get angle() {
4889
4963
  return MathUtils.radToDeg(this._private_material.getAngle());
4890
4964
  }
4965
+ /**
4966
+ * Gets whether the progress fills in forward direction.
4967
+ * @returns True if filling forward, false if filling in reverse
4968
+ */
4891
4969
  get isForwardDirection() {
4892
4970
  return this._private_material.getIsForwardDirection();
4893
4971
  }
4972
+ /**
4973
+ * Sets the progress value.
4974
+ * @param value - Progress value between 0.0 (empty) and 1.0 (full)
4975
+ */
4894
4976
  set progress(value) {
4895
4977
  this._private_material.setProgress(value);
4896
4978
  }
4979
+ /**
4980
+ * Sets the background texture.
4981
+ * @param value - The background texture, or undefined to remove background
4982
+ */
4897
4983
  set backgroundTexture(value) {
4898
4984
  if (value) {
4899
4985
  const width = value.image.width;
4900
4986
  const height = value.image.height;
4901
- assertValidPositiveNumber(width, "UIElement background texture width");
4902
- assertValidPositiveNumber(height, "UIElement background texture height");
4987
+ assertValidPositiveNumber(width, "UIProgress background texture width");
4988
+ assertValidPositiveNumber(height, "UIProgress background texture height");
4903
4989
  }
4904
4990
  this._private_material.setBackgroundTexture(value);
4905
4991
  }
4992
+ /**
4993
+ * Sets the foreground (fill) texture.
4994
+ *
4995
+ * When setting a new texture, the progress bar will automatically resize
4996
+ * to match the new texture's dimensions.
4997
+ *
4998
+ * @param value - The new foreground texture
4999
+ * @throws Will throw an error if the texture dimensions are not valid positive numbers
5000
+ */
4906
5001
  set foregroundTexture(value) {
4907
5002
  const width = value.image.width;
4908
5003
  const height = value.image.height;
4909
- assertValidPositiveNumber(width, "UIImage texture width");
4910
- assertValidPositiveNumber(height, "UIImage texture height");
5004
+ assertValidPositiveNumber(width, "UIProgress foreground texture width");
5005
+ assertValidPositiveNumber(height, "UIProgress foreground texture height");
4911
5006
  this._private_material.setForegroundTexture(value);
4912
5007
  this.solverWrapper.suggestVariableValue(this.wVariable, width);
4913
5008
  this.solverWrapper.suggestVariableValue(this.hVariable, height);
4914
5009
  }
5010
+ /**
5011
+ * Sets the background color tint.
5012
+ * @param value - The background color as a hex number (e.g., 0xFFFFFF)
5013
+ */
4915
5014
  set backgroundColor(value) {
4916
5015
  this._private_material.setBackgroundColor(value);
4917
5016
  }
5017
+ /**
5018
+ * Sets the foreground color tint.
5019
+ * @param value - The foreground color as a hex number (e.g., 0xFFFFFF)
5020
+ */
4918
5021
  set foregroundColor(value) {
4919
5022
  this._private_material.setForegroundColor(value);
4920
5023
  }
5024
+ /**
5025
+ * Sets the background opacity.
5026
+ * @param value - Opacity value between 0.0 (transparent) and 1.0 (opaque)
5027
+ */
4921
5028
  set backgroundOpacity(value) {
4922
5029
  this._private_material.setBackgroundOpacity(value);
4923
5030
  }
5031
+ /**
5032
+ * Sets the foreground opacity.
5033
+ * @param value - Opacity value between 0.0 (transparent) and 1.0 (opaque)
5034
+ */
4924
5035
  set foregroundOpacity(value) {
4925
5036
  this._private_material.setForegroundOpacity(value);
4926
5037
  }
5038
+ /**
5039
+ * Sets whether transparency is enabled for the image.
5040
+ * @param value - True to enable transparency, false to disable
5041
+ */
5042
+ set transparency(value) {
5043
+ this._private_material.setTransparency(value);
5044
+ }
5045
+ /**
5046
+ * Sets the progress fill angle.
5047
+ * @param value - Angle in degrees (0 = horizontal, 90 = vertical)
5048
+ */
4927
5049
  set angle(value) {
4928
5050
  this._private_material.setAngle(MathUtils.degToRad(value));
4929
5051
  }
5052
+ /**
5053
+ * Sets the progress fill direction.
5054
+ * @param value - True for forward direction, false for reverse
5055
+ */
4930
5056
  set isForwardDirection(value) {
4931
5057
  this._private_material.setIsForwardDirection(value);
4932
5058
  }
5059
+ /**
5060
+ * Destroys the progress bar element and cleans up resources.
5061
+ *
5062
+ * This method disposes of the material and calls the parent destroy method.
5063
+ */
4933
5064
  destroy() {
4934
5065
  this._private_material.dispose();
4935
5066
  super.destroy();