laymur 0.3.4 → 0.3.5
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/UIProgress.d.ts +4 -2
- package/dist/elements/UIText.d.ts +0 -2
- package/dist/index.js +9 -20
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -13,8 +13,10 @@ export declare enum UIProgressMaskFunction {
|
|
|
13
13
|
VERTICAL = "float calculateMask() {\n return step((direction * io_UV.y + (1.0 - direction) * 0.5), progress);\n }",
|
|
14
14
|
/** Fill diagonally from bottom-left to top-right */
|
|
15
15
|
DIAGONAL = "float calculateMask() {\n float d = (io_UV.x + io_UV.y) * (0.1);\n return step((direction * d + (1.0 - direction) * 0.5), progress);\n }",
|
|
16
|
-
/** Fill in a circular pattern around the center */
|
|
17
|
-
|
|
16
|
+
/** Fill in a circular pattern around the center, starting from the left */
|
|
17
|
+
CIRCLE_LEFT = "float calculateMask() {\n vec2 p = io_UV - 0.5;\n float angle = atan(p.y, p.x);\n angle = (angle + 3.14159265) / 3.14159265;\n angle *= 0.5;\n return step((direction * angle + (1.0 - direction) * 0.5), progress);\n }",
|
|
18
|
+
/** Fill in a circular pattern around the center, starting from the top */
|
|
19
|
+
CIRCLE_TOP = "float calculateMask() {\n vec2 p = io_UV - 0.5;\n float angle = atan(p.y, p.x);\n angle = (angle + 3.14159265) / (2.0 * 3.14159265);\n angle = mod(angle + 0.25, 1.0);\n return step((direction * angle + (1.0 - direction) * 0.5), progress);\n }"
|
|
18
20
|
}
|
|
19
21
|
/**
|
|
20
22
|
* Configuration options for creating a UIProgress element.
|
|
@@ -55,8 +55,6 @@ export declare class UIText extends UIElement {
|
|
|
55
55
|
private commonStyleInternal;
|
|
56
56
|
/** Target aspect ratio for the text element based on content. */
|
|
57
57
|
private targetAspectRatio;
|
|
58
|
-
/** Last calculated aspect ratio for comparison during rendering. */
|
|
59
|
-
private lastAspectRatio;
|
|
60
58
|
/**
|
|
61
59
|
* Creates a new UIText instance with dynamic text rendering.
|
|
62
60
|
*
|
package/dist/index.js
CHANGED
|
@@ -5293,8 +5293,10 @@ var UIProgressMaskFunction;
|
|
|
5293
5293
|
UIProgressMaskFunction["VERTICAL"] = "float calculateMask() {\n return step((direction * io_UV.y + (1.0 - direction) * 0.5), progress);\n }";
|
|
5294
5294
|
/** Fill diagonally from bottom-left to top-right */
|
|
5295
5295
|
UIProgressMaskFunction["DIAGONAL"] = "float calculateMask() {\n float d = (io_UV.x + io_UV.y) * (0.1);\n return step((direction * d + (1.0 - direction) * 0.5), progress);\n }";
|
|
5296
|
-
/** Fill in a circular pattern around the center */
|
|
5297
|
-
UIProgressMaskFunction["
|
|
5296
|
+
/** Fill in a circular pattern around the center, starting from the left */
|
|
5297
|
+
UIProgressMaskFunction["CIRCLE_LEFT"] = "float calculateMask() {\n vec2 p = io_UV - 0.5;\n float angle = atan(p.y, p.x);\n angle = (angle + 3.14159265) / 3.14159265;\n angle *= 0.5;\n return step((direction * angle + (1.0 - direction) * 0.5), progress);\n }";
|
|
5298
|
+
/** Fill in a circular pattern around the center, starting from the top */
|
|
5299
|
+
UIProgressMaskFunction["CIRCLE_TOP"] = "float calculateMask() {\n vec2 p = io_UV - 0.5;\n float angle = atan(p.y, p.x);\n angle = (angle + 3.14159265) / (2.0 * 3.14159265);\n angle = mod(angle + 0.25, 1.0);\n return step((direction * angle + (1.0 - direction) * 0.5), progress);\n }";
|
|
5298
5300
|
})(UIProgressMaskFunction || (UIProgressMaskFunction = {}));
|
|
5299
5301
|
/**
|
|
5300
5302
|
* Progress bar UI element with customizable fill direction and appearance.
|
|
@@ -5861,7 +5863,7 @@ function measureTextChunk(context, chunk, style) {
|
|
|
5861
5863
|
context.font = `${style.fontStyle} ${style.fontWeight} ${style.fontSize}px ${style.fontFamily}`;
|
|
5862
5864
|
if (chunk === "\n") {
|
|
5863
5865
|
return {
|
|
5864
|
-
width: Math.ceil(
|
|
5866
|
+
width: Math.ceil(1),
|
|
5865
5867
|
height: style.lineHeight,
|
|
5866
5868
|
baseline: 0,
|
|
5867
5869
|
lineHeight: style.lineHeight,
|
|
@@ -5945,14 +5947,8 @@ function calculateTextSize(lines) {
|
|
|
5945
5947
|
for (let i = 0; i < lines.length; i++) {
|
|
5946
5948
|
const line = lines[i];
|
|
5947
5949
|
totalHeight += i === 0 ? line.height : line.lineHeight;
|
|
5948
|
-
if (i === lines.length - 1) {
|
|
5949
|
-
totalHeight += line.baseline;
|
|
5950
|
-
}
|
|
5951
5950
|
}
|
|
5952
|
-
return {
|
|
5953
|
-
width: maxLineWidth,
|
|
5954
|
-
height: totalHeight,
|
|
5955
|
-
};
|
|
5951
|
+
return { width: maxLineWidth, height: totalHeight };
|
|
5956
5952
|
}
|
|
5957
5953
|
function renderText(x, y, text, style, context) {
|
|
5958
5954
|
context.font = `${style.fontStyle} ${style.fontWeight} ${style.fontSize}px ${style.fontFamily}`;
|
|
@@ -5971,7 +5967,6 @@ function renderText(x, y, text, style, context) {
|
|
|
5971
5967
|
context.fillText(text, x, y);
|
|
5972
5968
|
}
|
|
5973
5969
|
function renderTextLines(paddingTop, paddingLeft, lines, context) {
|
|
5974
|
-
context.clearRect(0, 0, context.canvas.width, context.canvas.height);
|
|
5975
5970
|
let currentY = paddingTop;
|
|
5976
5971
|
for (let i = 0; i < lines.length; i++) {
|
|
5977
5972
|
const line = lines[i];
|
|
@@ -5995,8 +5990,7 @@ function calculateTextContentParameters(context, content, maxLineWidth, commonSt
|
|
|
5995
5990
|
}
|
|
5996
5991
|
}
|
|
5997
5992
|
const lines = buildLines(maxLineWidth, chunks);
|
|
5998
|
-
|
|
5999
|
-
return { lines, size: textSize };
|
|
5993
|
+
return { lines, size: calculateTextSize(lines) };
|
|
6000
5994
|
}
|
|
6001
5995
|
|
|
6002
5996
|
function resolveTextPadding(value) {
|
|
@@ -6060,8 +6054,6 @@ class UIText extends UIElement {
|
|
|
6060
6054
|
});
|
|
6061
6055
|
/** Target aspect ratio for the text element based on content. */
|
|
6062
6056
|
this._private_targetAspectRatio = 1;
|
|
6063
|
-
/** Last calculated aspect ratio for comparison during rendering. */
|
|
6064
|
-
this._private_lastAspectRatio = 1;
|
|
6065
6057
|
/** Event handler for when the color changes */
|
|
6066
6058
|
this._private_onColorChange = (color) => {
|
|
6067
6059
|
this.sceneWrapper.setUniform(this.planeHandler, "color", color);
|
|
@@ -6171,8 +6163,7 @@ class UIText extends UIElement {
|
|
|
6171
6163
|
*/
|
|
6172
6164
|
onWillRender(renderer, deltaTime) {
|
|
6173
6165
|
super.onWillRender(renderer, deltaTime);
|
|
6174
|
-
if (this.
|
|
6175
|
-
this._private_lastAspectRatio = this._private_targetAspectRatio;
|
|
6166
|
+
if (this._private_targetAspectRatio !== this.width / this.height) {
|
|
6176
6167
|
this.height = this.width / this._private_targetAspectRatio;
|
|
6177
6168
|
}
|
|
6178
6169
|
}
|
|
@@ -6191,9 +6182,7 @@ class UIText extends UIElement {
|
|
|
6191
6182
|
size.height + this._private_paddingInternal.top + this._private_paddingInternal.bottom;
|
|
6192
6183
|
this.width = this._private_canvas.width;
|
|
6193
6184
|
this.height = this._private_canvas.height;
|
|
6194
|
-
this._private_targetAspectRatio =
|
|
6195
|
-
(size.width + this._private_paddingInternal.left + this._private_paddingInternal.right) /
|
|
6196
|
-
(size.height + this._private_paddingInternal.top + this._private_paddingInternal.bottom);
|
|
6185
|
+
this._private_targetAspectRatio = this._private_canvas.width / this._private_canvas.height;
|
|
6197
6186
|
renderTextLines(this._private_paddingInternal.top, this._private_paddingInternal.left, lines, this._private_context);
|
|
6198
6187
|
this._private_texture.needsUpdate = true;
|
|
6199
6188
|
}
|