laymur 0.2.14 → 0.2.16

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,7 +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
+ <a href="https://www.npmjs.com/package/laymur"><img src="https://img.shields.io/npm/v/laymur.svg" alt="npm version"></a>
10
10
  <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT"></a>
11
11
  <a href="https://www.typescriptlang.org/"><img src="https://img.shields.io/badge/TypeScript-%5E5.8.0-blue" alt="TypeScript"></a>
12
12
  <a href="https://threejs.org/"><img src="https://img.shields.io/badge/Three.js-%5E0.175.0-green" alt="Three.js"></a>
@@ -62,6 +62,11 @@ export declare class UIProgress extends UIElement<Mesh> {
62
62
  * @returns The foreground texture
63
63
  */
64
64
  get foregroundTexture(): Texture;
65
+ /**
66
+ * Gets the color tint.
67
+ * @returns The color as a hex number (e.g., 0xFFFFFF)
68
+ */
69
+ get color(): number;
65
70
  /**
66
71
  * Gets the background color tint.
67
72
  * @returns The background color as a hex number (e.g., 0xFFFFFF)
@@ -72,6 +77,11 @@ export declare class UIProgress extends UIElement<Mesh> {
72
77
  * @returns The foreground color as a hex number (e.g., 0xFFFFFF)
73
78
  */
74
79
  get foregroundColor(): number;
80
+ /**
81
+ * Gets the opacity.
82
+ * @returns Opacity value between 0.0 (transparent) and 1.0 (opaque)
83
+ */
84
+ get opacity(): number;
75
85
  /**
76
86
  * Gets the background opacity.
77
87
  * @returns Opacity value between 0.0 (transparent) and 1.0 (opaque)
@@ -117,6 +127,11 @@ export declare class UIProgress extends UIElement<Mesh> {
117
127
  * @throws Will throw an error if the texture dimensions are not valid positive numbers
118
128
  */
119
129
  set foregroundTexture(value: Texture);
130
+ /**
131
+ * Sets the color tint.
132
+ * @param value - The color as a hex number (e.g., 0xFFFFFF)
133
+ */
134
+ set color(value: number);
120
135
  /**
121
136
  * Sets the background color tint.
122
137
  * @param value - The background color as a hex number (e.g., 0xFFFFFF)
@@ -127,6 +142,11 @@ export declare class UIProgress extends UIElement<Mesh> {
127
142
  * @param value - The foreground color as a hex number (e.g., 0xFFFFFF)
128
143
  */
129
144
  set foregroundColor(value: number);
145
+ /**
146
+ * Sets the opacity.
147
+ * @param value - Opacity value between 0.0 (transparent) and 1.0 (opaque)
148
+ */
149
+ set opacity(value: number);
130
150
  /**
131
151
  * Sets the background opacity.
132
152
  * @param value - Opacity value between 0.0 (transparent) and 1.0 (opaque)
package/dist/index.js CHANGED
@@ -4382,7 +4382,7 @@ var fragmentShader$1 = "uniform sampler2D map;\nuniform vec3 color;\nuniform flo
4382
4382
 
4383
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$1 = 0.025;
4385
+ const DEFAULT_ALPHA_TEST$1 = 0.25;
4386
4386
  class UINineSliceMaterial extends ShaderMaterial {
4387
4387
  constructor(texture) {
4388
4388
  super({
@@ -4734,11 +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";
4737
+ var fragmentShader = "uniform sampler2D background;\nuniform sampler2D foreground;\nuniform float progress;\nuniform vec3 color;\nuniform vec3 backgroundColor;\nuniform vec3 foregroundColor;\nuniform float opacity;\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 * color;\n vec3 finalForegroundColor = foregroundTexture.rgb * foregroundColor * color;\n float finalBackgroundOpacity = backgroundTexture.a * backgroundOpacity * opacity;\n float finalForegroundOpacity = foregroundTexture.a * foregroundOpacity * opacity;\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 = foregroundColor * progressMask\n + backgroundColor * (1.0 - foregroundColor.a * progressMask);\n\n if (mixedColor.a < alphaTest) {\n discard;\n }\n\n gl_FragColor = mixedColor;\n #include <colorspace_fragment>\n}\n";
4738
4738
 
4739
4739
  var vertexShader = "varying vec2 vUv;\nvoid main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n";
4740
4740
 
4741
- const DEFAULT_ALPHA_TEST = 0.025;
4741
+ const DEFAULT_ALPHA_TEST = 0.25;
4742
4742
  class UIProgressMaterial extends ShaderMaterial {
4743
4743
  constructor(foregroundTexture, backgroundTexture) {
4744
4744
  super({
@@ -4747,8 +4747,10 @@ class UIProgressMaterial extends ShaderMaterial {
4747
4747
  background: { value: backgroundTexture },
4748
4748
  foreground: { value: foregroundTexture },
4749
4749
  progress: { value: 1 },
4750
+ color: { value: new Color(1, 1, 1) },
4750
4751
  backgroundColor: { value: new Color(1, 1, 1) },
4751
4752
  foregroundColor: { value: new Color(1, 1, 1) },
4753
+ opacity: { value: 1 },
4752
4754
  backgroundOpacity: { value: 1 },
4753
4755
  foregroundOpacity: { value: 1 },
4754
4756
  alphaTest: { value: DEFAULT_ALPHA_TEST },
@@ -4774,12 +4776,18 @@ class UIProgressMaterial extends ShaderMaterial {
4774
4776
  getForegroundTexture() {
4775
4777
  return this.uniforms.foreground.value;
4776
4778
  }
4779
+ getColor() {
4780
+ return this.uniforms.color.value.getHex();
4781
+ }
4777
4782
  getBackgroundColor() {
4778
4783
  return this.uniforms.backgroundColor.value.getHex();
4779
4784
  }
4780
4785
  getForegroundColor() {
4781
4786
  return this.uniforms.foregroundColor.value.getHex();
4782
4787
  }
4788
+ getOpacity() {
4789
+ return this.uniforms.opacity.value;
4790
+ }
4783
4791
  getBackgroundOpacity() {
4784
4792
  return this.uniforms.backgroundOpacity.value;
4785
4793
  }
@@ -4807,6 +4815,10 @@ class UIProgressMaterial extends ShaderMaterial {
4807
4815
  this.uniforms.foreground.value = value;
4808
4816
  this.uniformsNeedUpdate = true;
4809
4817
  }
4818
+ setColor(value) {
4819
+ this.uniforms.color.value.setHex(value);
4820
+ this.uniformsNeedUpdate = true;
4821
+ }
4810
4822
  setBackgroundColor(value) {
4811
4823
  this.uniforms.backgroundColor.value.setHex(value);
4812
4824
  this.uniformsNeedUpdate = true;
@@ -4815,6 +4827,10 @@ class UIProgressMaterial extends ShaderMaterial {
4815
4827
  this.uniforms.foregroundColor.value.setHex(value);
4816
4828
  this.uniformsNeedUpdate = true;
4817
4829
  }
4830
+ setOpacity(value) {
4831
+ this.uniforms.opacity.value = value;
4832
+ this.uniformsNeedUpdate = true;
4833
+ }
4818
4834
  setBackgroundOpacity(value) {
4819
4835
  this.uniforms.backgroundOpacity.value = value;
4820
4836
  this.uniformsNeedUpdate = true;
@@ -4920,6 +4936,13 @@ class UIProgress extends UIElement {
4920
4936
  get foregroundTexture() {
4921
4937
  return this._private_material.getForegroundTexture();
4922
4938
  }
4939
+ /**
4940
+ * Gets the color tint.
4941
+ * @returns The color as a hex number (e.g., 0xFFFFFF)
4942
+ */
4943
+ get color() {
4944
+ return this._private_material.getColor();
4945
+ }
4923
4946
  /**
4924
4947
  * Gets the background color tint.
4925
4948
  * @returns The background color as a hex number (e.g., 0xFFFFFF)
@@ -4934,6 +4957,13 @@ class UIProgress extends UIElement {
4934
4957
  get foregroundColor() {
4935
4958
  return this._private_material.getForegroundColor();
4936
4959
  }
4960
+ /**
4961
+ * Gets the opacity.
4962
+ * @returns Opacity value between 0.0 (transparent) and 1.0 (opaque)
4963
+ */
4964
+ get opacity() {
4965
+ return this._private_material.getOpacity();
4966
+ }
4937
4967
  /**
4938
4968
  * Gets the background opacity.
4939
4969
  * @returns Opacity value between 0.0 (transparent) and 1.0 (opaque)
@@ -5007,6 +5037,13 @@ class UIProgress extends UIElement {
5007
5037
  this.solverWrapper.suggestVariableValue(this.wVariable, width);
5008
5038
  this.solverWrapper.suggestVariableValue(this.hVariable, height);
5009
5039
  }
5040
+ /**
5041
+ * Sets the color tint.
5042
+ * @param value - The color as a hex number (e.g., 0xFFFFFF)
5043
+ */
5044
+ set color(value) {
5045
+ this._private_material.setColor(value);
5046
+ }
5010
5047
  /**
5011
5048
  * Sets the background color tint.
5012
5049
  * @param value - The background color as a hex number (e.g., 0xFFFFFF)
@@ -5021,6 +5058,13 @@ class UIProgress extends UIElement {
5021
5058
  set foregroundColor(value) {
5022
5059
  this._private_material.setForegroundColor(value);
5023
5060
  }
5061
+ /**
5062
+ * Sets the opacity.
5063
+ * @param value - Opacity value between 0.0 (transparent) and 1.0 (opaque)
5064
+ */
5065
+ set opacity(value) {
5066
+ this._private_material.setOpacity(value);
5067
+ }
5024
5068
  /**
5025
5069
  * Sets the background opacity.
5026
5070
  * @param value - Opacity value between 0.0 (transparent) and 1.0 (opaque)