laymur 0.3.3 → 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 -19
- 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}`;
|
|
@@ -5994,8 +5990,7 @@ function calculateTextContentParameters(context, content, maxLineWidth, commonSt
|
|
|
5994
5990
|
}
|
|
5995
5991
|
}
|
|
5996
5992
|
const lines = buildLines(maxLineWidth, chunks);
|
|
5997
|
-
|
|
5998
|
-
return { lines, size: textSize };
|
|
5993
|
+
return { lines, size: calculateTextSize(lines) };
|
|
5999
5994
|
}
|
|
6000
5995
|
|
|
6001
5996
|
function resolveTextPadding(value) {
|
|
@@ -6059,8 +6054,6 @@ class UIText extends UIElement {
|
|
|
6059
6054
|
});
|
|
6060
6055
|
/** Target aspect ratio for the text element based on content. */
|
|
6061
6056
|
this._private_targetAspectRatio = 1;
|
|
6062
|
-
/** Last calculated aspect ratio for comparison during rendering. */
|
|
6063
|
-
this._private_lastAspectRatio = 1;
|
|
6064
6057
|
/** Event handler for when the color changes */
|
|
6065
6058
|
this._private_onColorChange = (color) => {
|
|
6066
6059
|
this.sceneWrapper.setUniform(this.planeHandler, "color", color);
|
|
@@ -6170,8 +6163,7 @@ class UIText extends UIElement {
|
|
|
6170
6163
|
*/
|
|
6171
6164
|
onWillRender(renderer, deltaTime) {
|
|
6172
6165
|
super.onWillRender(renderer, deltaTime);
|
|
6173
|
-
if (this.
|
|
6174
|
-
this._private_lastAspectRatio = this._private_targetAspectRatio;
|
|
6166
|
+
if (this._private_targetAspectRatio !== this.width / this.height) {
|
|
6175
6167
|
this.height = this.width / this._private_targetAspectRatio;
|
|
6176
6168
|
}
|
|
6177
6169
|
}
|
|
@@ -6190,9 +6182,7 @@ class UIText extends UIElement {
|
|
|
6190
6182
|
size.height + this._private_paddingInternal.top + this._private_paddingInternal.bottom;
|
|
6191
6183
|
this.width = this._private_canvas.width;
|
|
6192
6184
|
this.height = this._private_canvas.height;
|
|
6193
|
-
this._private_targetAspectRatio =
|
|
6194
|
-
(size.width + this._private_paddingInternal.left + this._private_paddingInternal.right) /
|
|
6195
|
-
(size.height + this._private_paddingInternal.top + this._private_paddingInternal.bottom);
|
|
6185
|
+
this._private_targetAspectRatio = this._private_canvas.width / this._private_canvas.height;
|
|
6196
6186
|
renderTextLines(this._private_paddingInternal.top, this._private_paddingInternal.left, lines, this._private_context);
|
|
6197
6187
|
this._private_texture.needsUpdate = true;
|
|
6198
6188
|
}
|