laymur 0.15.0 → 0.15.1
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 +44 -37
- package/dist/elements/UIElement/UIElement.d.ts +1 -0
- package/dist/index.js +33 -67
- 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
package/README.md
CHANGED
|
@@ -39,19 +39,19 @@ Requires Three.js >=0.175.0 <0.180.0 as a peer dependency.
|
|
|
39
39
|
## Quick Example
|
|
40
40
|
|
|
41
41
|
```typescript
|
|
42
|
-
import { UIFullscreenLayer, UIImage, UIText } from
|
|
43
|
-
import { WebGLRenderer, TextureLoader, Clock } from
|
|
42
|
+
import { UIFullscreenLayer, UIImage, UIText } from "laymur";
|
|
43
|
+
import { WebGLRenderer, TextureLoader, Clock } from "three";
|
|
44
44
|
|
|
45
45
|
const renderer = new WebGLRenderer();
|
|
46
46
|
const layer = new UIFullscreenLayer();
|
|
47
47
|
const clock = new Clock();
|
|
48
48
|
|
|
49
|
-
const texture = new TextureLoader().load(
|
|
49
|
+
const texture = new TextureLoader().load("background.jpg");
|
|
50
50
|
const background = new UIImage(layer, texture, { x: 0, y: 0 });
|
|
51
|
-
const title = new UIText(layer,
|
|
51
|
+
const title = new UIText(layer, "Mobile Ad Title", {
|
|
52
52
|
x: 100,
|
|
53
53
|
y: 100,
|
|
54
|
-
maxLineWidth: 800
|
|
54
|
+
maxLineWidth: 800,
|
|
55
55
|
});
|
|
56
56
|
|
|
57
57
|
function animate() {
|
|
@@ -65,9 +65,11 @@ animate();
|
|
|
65
65
|
## Basic Components
|
|
66
66
|
|
|
67
67
|
### Layers
|
|
68
|
+
|
|
68
69
|
- **UIFullscreenLayer** - Handles browser window scaling
|
|
69
70
|
|
|
70
71
|
### Elements
|
|
72
|
+
|
|
71
73
|
- **UIImage** - Display textures
|
|
72
74
|
- **UIAnimatedImage** - Animated texture sequences
|
|
73
75
|
- **UIText** - Text rendering with word wrapping and styled spans
|
|
@@ -78,6 +80,7 @@ animate();
|
|
|
78
80
|
- **UIAnchor** - Positioning points
|
|
79
81
|
|
|
80
82
|
### Constraints
|
|
83
|
+
|
|
81
84
|
- **UIWidthConstraint** / **UIHeightConstraint** - Fixed sizes
|
|
82
85
|
- **UIAspectConstraint** - Maintain aspect ratios
|
|
83
86
|
- **UIHorizontalDistanceConstraint** / **UIVerticalDistanceConstraint** - Spacing between elements
|
|
@@ -92,7 +95,7 @@ animate();
|
|
|
92
95
|
The constraint system automatically calculates positions and sizes based on relationships you define:
|
|
93
96
|
|
|
94
97
|
```typescript
|
|
95
|
-
import { UIImage, UIHorizontalDistanceConstraint, UIWidthConstraint } from
|
|
98
|
+
import { UIImage, UIHorizontalDistanceConstraint, UIWidthConstraint } from "laymur";
|
|
96
99
|
|
|
97
100
|
const sidebar = new UIImage(layer, sidebarTexture, { x: 0, y: 0 });
|
|
98
101
|
const content = new UIImage(layer, contentTexture, { x: 0, y: 0 });
|
|
@@ -103,8 +106,8 @@ new UIWidthConstraint(sidebar, { width: 300 });
|
|
|
103
106
|
// 20px spacing between sidebar and content
|
|
104
107
|
new UIHorizontalDistanceConstraint(sidebar, content, {
|
|
105
108
|
distance: 20,
|
|
106
|
-
anchorA: 1.0,
|
|
107
|
-
anchorB: 0.0
|
|
109
|
+
anchorA: 1.0, // Right edge of sidebar
|
|
110
|
+
anchorB: 0.0, // Left edge of content
|
|
108
111
|
});
|
|
109
112
|
```
|
|
110
113
|
|
|
@@ -113,16 +116,20 @@ new UIHorizontalDistanceConstraint(sidebar, content, {
|
|
|
113
116
|
Text supports styled spans with different fonts, sizes, and colors:
|
|
114
117
|
|
|
115
118
|
```typescript
|
|
116
|
-
import { UIText } from
|
|
117
|
-
|
|
118
|
-
const text = new UIText(
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
119
|
+
import { UIText } from "laymur";
|
|
120
|
+
|
|
121
|
+
const text = new UIText(
|
|
122
|
+
layer,
|
|
123
|
+
[
|
|
124
|
+
{ text: "Download ", style: { fontSize: 24, color: "#333333" } },
|
|
125
|
+
{ text: "Now!", style: { fontSize: 32, color: "#ff0000", fontWeight: "bold" } },
|
|
126
|
+
],
|
|
127
|
+
{
|
|
128
|
+
x: 100,
|
|
129
|
+
y: 100,
|
|
130
|
+
maxLineWidth: 600,
|
|
131
|
+
},
|
|
132
|
+
);
|
|
126
133
|
```
|
|
127
134
|
|
|
128
135
|
## Transformations
|
|
@@ -136,7 +143,7 @@ const element = new UIImage(layer, texture, { x: 0, y: 0 });
|
|
|
136
143
|
element.micro.x = 10;
|
|
137
144
|
element.micro.scaleX = 1.2;
|
|
138
145
|
element.micro.rotation = 0.1;
|
|
139
|
-
element.micro.anchorX = 0.5;
|
|
146
|
+
element.micro.anchorX = 0.5; // Transform origin (0 = left/bottom, 0.5 = center, 1 = right/top)
|
|
140
147
|
|
|
141
148
|
// Reset all transformations
|
|
142
149
|
element.micro.reset();
|
|
@@ -151,34 +158,34 @@ UI elements and layers use type-safe signals for event handling via [Ferrsign](h
|
|
|
151
158
|
Elements with area (width and height) can emit input events:
|
|
152
159
|
|
|
153
160
|
```typescript
|
|
154
|
-
import { UIMode } from
|
|
155
|
-
import type { UIInputEventData } from
|
|
161
|
+
import { UIMode } from "laymur";
|
|
162
|
+
import type { UIInputEventData } from "laymur";
|
|
156
163
|
|
|
157
164
|
const button = new UIImage(layer, buttonTexture, {
|
|
158
165
|
x: 0,
|
|
159
166
|
y: 0,
|
|
160
|
-
mode: UIMode.INTERACTIVE
|
|
167
|
+
mode: UIMode.INTERACTIVE,
|
|
161
168
|
});
|
|
162
169
|
|
|
163
170
|
button.signalPressed.on((data: UIInputEventData) => {
|
|
164
|
-
console.log(
|
|
165
|
-
console.log(
|
|
171
|
+
console.log("Button pressed at", data.x, data.y);
|
|
172
|
+
console.log("Element:", data.element);
|
|
166
173
|
});
|
|
167
174
|
|
|
168
175
|
button.signalReleased.on((data: UIInputEventData) => {
|
|
169
|
-
console.log(
|
|
176
|
+
console.log("Button released");
|
|
170
177
|
});
|
|
171
178
|
|
|
172
179
|
button.signalEntered.on((data: UIInputEventData) => {
|
|
173
|
-
console.log(
|
|
180
|
+
console.log("Pointer entered button");
|
|
174
181
|
});
|
|
175
182
|
|
|
176
183
|
button.signalLeft.on((data: UIInputEventData) => {
|
|
177
|
-
console.log(
|
|
184
|
+
console.log("Pointer left button");
|
|
178
185
|
});
|
|
179
186
|
|
|
180
187
|
button.signalMoved.on((data: UIInputEventData) => {
|
|
181
|
-
console.log(
|
|
188
|
+
console.log("Pointer moved inside button");
|
|
182
189
|
});
|
|
183
190
|
```
|
|
184
191
|
|
|
@@ -187,19 +194,19 @@ button.signalMoved.on((data: UIInputEventData) => {
|
|
|
187
194
|
Fullscreen layers emit input events:
|
|
188
195
|
|
|
189
196
|
```typescript
|
|
190
|
-
import type { UIFullscreenLayerInputEventData } from
|
|
197
|
+
import type { UIFullscreenLayerInputEventData } from "laymur";
|
|
191
198
|
|
|
192
199
|
layer.signalPressed.on((data: UIFullscreenLayerInputEventData) => {
|
|
193
|
-
console.log(
|
|
194
|
-
console.log(
|
|
200
|
+
console.log("Layer pressed at", data.x, data.y);
|
|
201
|
+
console.log("Layer:", data.layer);
|
|
195
202
|
});
|
|
196
203
|
|
|
197
204
|
layer.signalMoved.on((data: UIFullscreenLayerInputEventData) => {
|
|
198
|
-
console.log(
|
|
205
|
+
console.log("Pointer moved to", data.x, data.y);
|
|
199
206
|
});
|
|
200
207
|
|
|
201
208
|
layer.signalReleased.on((data: UIFullscreenLayerInputEventData) => {
|
|
202
|
-
console.log(
|
|
209
|
+
console.log("Pointer released");
|
|
203
210
|
});
|
|
204
211
|
```
|
|
205
212
|
|
|
@@ -211,15 +218,15 @@ Animated images emit playback events:
|
|
|
211
218
|
const animation = new UIAnimatedImage(layer, frames);
|
|
212
219
|
|
|
213
220
|
animation.signalPlayed.on(() => {
|
|
214
|
-
console.log(
|
|
221
|
+
console.log("Animation started or resumed");
|
|
215
222
|
});
|
|
216
223
|
|
|
217
224
|
animation.signalPaused.on(() => {
|
|
218
|
-
console.log(
|
|
225
|
+
console.log("Animation paused");
|
|
219
226
|
});
|
|
220
227
|
|
|
221
228
|
animation.signalStopped.on(() => {
|
|
222
|
-
console.log(
|
|
229
|
+
console.log("Animation stopped and reset");
|
|
223
230
|
});
|
|
224
231
|
```
|
|
225
232
|
|
|
@@ -227,7 +234,7 @@ animation.signalStopped.on(() => {
|
|
|
227
234
|
|
|
228
235
|
```typescript
|
|
229
236
|
const handler = (data: UIInputEventData) => {
|
|
230
|
-
console.log(
|
|
237
|
+
console.log("Pressed!");
|
|
231
238
|
};
|
|
232
239
|
|
|
233
240
|
button.signalPressed.on(handler);
|
package/dist/index.js
CHANGED
|
@@ -4289,9 +4289,7 @@ class UISolverWrapper {
|
|
|
4289
4289
|
* and preserves coefficients and constants.
|
|
4290
4290
|
*/
|
|
4291
4291
|
_private_convertExpression(expression) {
|
|
4292
|
-
return new Expression(...expression
|
|
4293
|
-
.prepareTerms()
|
|
4294
|
-
.map(([variableIndex, coefficient]) => {
|
|
4292
|
+
return new Expression(...expression.prepareTerms().map(([variableIndex, coefficient]) => {
|
|
4295
4293
|
const description = this._private_variables.get(variableIndex);
|
|
4296
4294
|
if (description === undefined) {
|
|
4297
4295
|
throw new Error(`UISolverWrapper.convertExpression.expression: variable does not exist`);
|
|
@@ -4354,8 +4352,7 @@ class UILayer {
|
|
|
4354
4352
|
this._private_sceneWrapperInternal = new UISceneWrapper(width, height);
|
|
4355
4353
|
this.name = options.name ?? LAYER_DEFAULT_NAME;
|
|
4356
4354
|
this._private_modeInternal = options.mode ?? LAYER_DEFAULT_MODE;
|
|
4357
|
-
this._private_orientationInternal =
|
|
4358
|
-
width > height ? UIOrientation.HORIZONTAL : UIOrientation.VERTICAL;
|
|
4355
|
+
this._private_orientationInternal = width > height ? UIOrientation.HORIZONTAL : UIOrientation.VERTICAL;
|
|
4359
4356
|
this.xVariable = this._private_solverWrapperInternal.createVariable(0, UIPriority.P0);
|
|
4360
4357
|
this.yVariable = this._private_solverWrapperInternal.createVariable(0, UIPriority.P0);
|
|
4361
4358
|
this.wVariable = this._private_solverWrapperInternal.createVariable(width, UIPriority.P0);
|
|
@@ -4444,10 +4441,7 @@ const EPSILON = 1e-6;
|
|
|
4444
4441
|
* @returns True if object has valid layer property
|
|
4445
4442
|
*/
|
|
4446
4443
|
function isUILayerElement(obj) {
|
|
4447
|
-
return
|
|
4448
|
-
obj !== null &&
|
|
4449
|
-
"layer" in obj &&
|
|
4450
|
-
obj.layer instanceof UILayer);
|
|
4444
|
+
return typeof obj === "object" && obj !== null && "layer" in obj && obj.layer instanceof UILayer;
|
|
4451
4445
|
}
|
|
4452
4446
|
/**
|
|
4453
4447
|
* Checks if object implements UIPointElement.
|
|
@@ -5302,9 +5296,7 @@ function normalizeUIType2D(value) {
|
|
|
5302
5296
|
if (Array.isArray(value)) {
|
|
5303
5297
|
return { h: value[0], v: value[1] };
|
|
5304
5298
|
}
|
|
5305
|
-
if (typeof value === "object" &&
|
|
5306
|
-
value !== null &&
|
|
5307
|
-
("h" in value || "v" in value)) {
|
|
5299
|
+
if (typeof value === "object" && value !== null && ("h" in value || "v" in value)) {
|
|
5308
5300
|
return value;
|
|
5309
5301
|
}
|
|
5310
5302
|
return { h: value, v: value };
|
|
@@ -5744,10 +5736,8 @@ function computeTrimmedTransformMatrix(x, y, width, height, zIndex, microX, micr
|
|
|
5744
5736
|
else {
|
|
5745
5737
|
const rawAnchorOffsetX = microAnchorX * width;
|
|
5746
5738
|
const rawAnchorOffsetY = microAnchorY * height;
|
|
5747
|
-
TEMP_POSITION.x =
|
|
5748
|
-
|
|
5749
|
-
TEMP_POSITION.y =
|
|
5750
|
-
y + rawAnchorOffsetY - rotatedAnchorY + microY + rotatedTrimY;
|
|
5739
|
+
TEMP_POSITION.x = x + rawAnchorOffsetX - rotatedAnchorX + microX + rotatedTrimX;
|
|
5740
|
+
TEMP_POSITION.y = y + rawAnchorOffsetY - rotatedAnchorY + microY + rotatedTrimY;
|
|
5751
5741
|
}
|
|
5752
5742
|
TEMP_POSITION.z = zIndex;
|
|
5753
5743
|
TEMP_SCALE.x = trimmedWidth * microScaleX;
|
|
@@ -6236,8 +6226,7 @@ class UIInputDummy extends UIAnchor {
|
|
|
6236
6226
|
this.catchPointerUp = (x, y, identifier) => {
|
|
6237
6227
|
return this.handleInputEvent(x, y, identifier, this._private_signalReleasedInternal);
|
|
6238
6228
|
};
|
|
6239
|
-
this.interactionArea =
|
|
6240
|
-
options?.interactionArea ?? new UIAreaRectangle(0, 0, 1, 1);
|
|
6229
|
+
this.interactionArea = options?.interactionArea ?? new UIAreaRectangle(0, 0, 1, 1);
|
|
6241
6230
|
this.modeInternal = options?.mode ?? DUMMY_DEFAULT_MODE;
|
|
6242
6231
|
this.inputWrapper = this.layer.inputWrapper;
|
|
6243
6232
|
this.wVariable = this.solverWrapper.createVariable(w, UIPriority.P6);
|
|
@@ -6362,7 +6351,7 @@ class UIInputDummy extends UIAnchor {
|
|
|
6362
6351
|
this._private_signalEnteredInternal.emit({ x, y, identifier, element: this });
|
|
6363
6352
|
}
|
|
6364
6353
|
this._private_wasPointerInside = isPointerInside;
|
|
6365
|
-
return
|
|
6354
|
+
return this.modeInternal !== UIMode.INTERACTIVE_TRANSPARENT && isPointerInside;
|
|
6366
6355
|
}
|
|
6367
6356
|
}
|
|
6368
6357
|
|
|
@@ -6382,12 +6371,15 @@ class UIElement extends UIInputDummy {
|
|
|
6382
6371
|
super(layer, options);
|
|
6383
6372
|
this._private_transparencyModeDirty = false;
|
|
6384
6373
|
this._private_visibilityDirty = false;
|
|
6374
|
+
this._private_handleWillRender = (renderer, deltaTime) => {
|
|
6375
|
+
this.onWillRender(renderer, deltaTime);
|
|
6376
|
+
};
|
|
6385
6377
|
this.micro = new UIMicro(options?.micro);
|
|
6386
6378
|
this._private_transparencyModeInternal =
|
|
6387
6379
|
options?.transparencyMode ?? ELEMENT_DEFAULT_TRANSPARENCY_MODE;
|
|
6388
6380
|
this.sceneWrapper = this.layer.sceneWrapper;
|
|
6389
6381
|
this.planeHandler = this.sceneWrapper.createPlane(source, properties, new Matrix4().identity(), isUIModeVisible(options?.mode ?? this.mode), this._private_transparencyModeInternal);
|
|
6390
|
-
this.layer.signalRendering.on(this.
|
|
6382
|
+
this.layer.signalRendering.on(this._private_handleWillRender);
|
|
6391
6383
|
}
|
|
6392
6384
|
/** Alpha blending mode */
|
|
6393
6385
|
get transparencyMode() {
|
|
@@ -6409,7 +6401,7 @@ class UIElement extends UIInputDummy {
|
|
|
6409
6401
|
}
|
|
6410
6402
|
/** Removes element and frees resources */
|
|
6411
6403
|
destroy() {
|
|
6412
|
-
this.layer.signalRendering.off(this.
|
|
6404
|
+
this.layer.signalRendering.off(this._private_handleWillRender);
|
|
6413
6405
|
this.sceneWrapper.destroyPlane(this.planeHandler);
|
|
6414
6406
|
super.destroy();
|
|
6415
6407
|
}
|
|
@@ -6488,12 +6480,9 @@ class UIAnimatedImage extends UIElement {
|
|
|
6488
6480
|
this._private_colorInternal = color;
|
|
6489
6481
|
this._private_sequenceInternal = uiTextures;
|
|
6490
6482
|
this._private_textureTransform = textureTransform;
|
|
6491
|
-
this._private_frameRateInternal =
|
|
6492
|
-
|
|
6493
|
-
this.
|
|
6494
|
-
options.timeScale ?? ANIMATED_IMAGE_DEFAULT_TIME_SCALE;
|
|
6495
|
-
this._private_loopModeInternal =
|
|
6496
|
-
options.loopMode ?? ANIMATED_IMAGE_DEFAULT_LOOP_MODE;
|
|
6483
|
+
this._private_frameRateInternal = options.frameRate ?? ANIMATED_IMAGE_DEFAULT_FRAME_RATE;
|
|
6484
|
+
this._private_timeScaleInternal = options.timeScale ?? ANIMATED_IMAGE_DEFAULT_TIME_SCALE;
|
|
6485
|
+
this._private_loopModeInternal = options.loopMode ?? ANIMATED_IMAGE_DEFAULT_LOOP_MODE;
|
|
6497
6486
|
this._private_subscribeSequenceEvents();
|
|
6498
6487
|
if (options.playByDefault === true) {
|
|
6499
6488
|
this.play();
|
|
@@ -6593,9 +6582,7 @@ class UIAnimatedImage extends UIElement {
|
|
|
6593
6582
|
}
|
|
6594
6583
|
/** Stops animation and resets to first frame */
|
|
6595
6584
|
stop() {
|
|
6596
|
-
if (this._private_isPlaying ||
|
|
6597
|
-
this._private_accumulatedTime > 0 ||
|
|
6598
|
-
this._private_sequenceFrameIndex > 0) {
|
|
6585
|
+
if (this._private_isPlaying || this._private_accumulatedTime > 0 || this._private_sequenceFrameIndex > 0) {
|
|
6599
6586
|
this._private_isPlaying = false;
|
|
6600
6587
|
this._private_accumulatedTime = 0;
|
|
6601
6588
|
this._private_sequenceFrameIndex = 0;
|
|
@@ -7260,9 +7247,7 @@ class UINineSlice extends UIElement {
|
|
|
7260
7247
|
}
|
|
7261
7248
|
setPlaneTransform() {
|
|
7262
7249
|
let properties;
|
|
7263
|
-
const sliceBordersDirty = this._private_textureDimensionsDirty ||
|
|
7264
|
-
this._private_sliceBordersInternal.dirty ||
|
|
7265
|
-
this.texture.trimDirty;
|
|
7250
|
+
const sliceBordersDirty = this._private_textureDimensionsDirty || this._private_sliceBordersInternal.dirty || this.texture.trimDirty;
|
|
7266
7251
|
if (sliceBordersDirty) {
|
|
7267
7252
|
properties ?? (properties = {});
|
|
7268
7253
|
properties["sliceBorders"] = this._private_calculateSliceBordersForShader(this._private_sliceBordersVector);
|
|
@@ -7964,18 +7949,14 @@ class UITextStyle {
|
|
|
7964
7949
|
* @returns Complete style configuration with all defaults applied
|
|
7965
7950
|
*/
|
|
7966
7951
|
static resolve(primary, fallback) {
|
|
7967
|
-
const fontSize = primary._private_fontSizeInternal ?? fallback._private_fontSizeInternal ??
|
|
7968
|
-
TEXT_STYLE_DEFAULT_FONT_SIZE;
|
|
7952
|
+
const fontSize = primary._private_fontSizeInternal ?? fallback._private_fontSizeInternal ?? TEXT_STYLE_DEFAULT_FONT_SIZE;
|
|
7969
7953
|
return {
|
|
7970
|
-
color: primary._private_colorInternal ?? fallback._private_colorInternal ??
|
|
7971
|
-
|
|
7972
|
-
align: primary._private_alignInternal ?? fallback._private_alignInternal ??
|
|
7973
|
-
TEXT_STYLE_DEFAULT_ALIGN,
|
|
7954
|
+
color: primary._private_colorInternal ?? fallback._private_colorInternal ?? TEXT_STYLE_DEFAULT_COLOR,
|
|
7955
|
+
align: primary._private_alignInternal ?? fallback._private_alignInternal ?? TEXT_STYLE_DEFAULT_ALIGN,
|
|
7974
7956
|
fontFamily: primary._private_fontFamilyInternal ?? fallback._private_fontFamilyInternal ??
|
|
7975
7957
|
TEXT_STYLE_DEFAULT_FONT_FAMILY,
|
|
7976
7958
|
fontSize,
|
|
7977
|
-
fontStyle: primary._private_fontStyleInternal ?? fallback._private_fontStyleInternal ??
|
|
7978
|
-
TEXT_STYLE_DEFAULT_FONT_STYLE,
|
|
7959
|
+
fontStyle: primary._private_fontStyleInternal ?? fallback._private_fontStyleInternal ?? TEXT_STYLE_DEFAULT_FONT_STYLE,
|
|
7979
7960
|
fontWeight: primary._private_fontWeightInternal ?? fallback._private_fontWeightInternal ??
|
|
7980
7961
|
TEXT_STYLE_DEFAULT_FONT_WEIGHT,
|
|
7981
7962
|
lineHeight: primary._private_lineHeightInternal ?? fallback._private_lineHeightInternal ??
|
|
@@ -8010,8 +7991,7 @@ class UITextStyle {
|
|
|
8010
7991
|
this._private_fontSizeInternal !== TEXT_STYLE_DEFAULT_FONT_SIZE ||
|
|
8011
7992
|
this._private_fontStyleInternal !== TEXT_STYLE_DEFAULT_FONT_STYLE ||
|
|
8012
7993
|
this._private_fontWeightInternal !== TEXT_STYLE_DEFAULT_FONT_WEIGHT ||
|
|
8013
|
-
this._private_lineHeightInternal !==
|
|
8014
|
-
TEXT_STYLE_DEFAULT_FONT_SIZE * TEXT_STYLE_DEFAULT_LINE_HEIGHT ||
|
|
7994
|
+
this._private_lineHeightInternal !== TEXT_STYLE_DEFAULT_FONT_SIZE * TEXT_STYLE_DEFAULT_LINE_HEIGHT ||
|
|
8015
7995
|
this._private_enableShadowInternal !== TEXT_STYLE_DEFAULT_ENABLE_SHADOW ||
|
|
8016
7996
|
this._private_shadowOffsetXInternal !== TEXT_STYLE_DEFAULT_SHADOW_OFFSET_X ||
|
|
8017
7997
|
this._private_shadowOffsetYInternal !== TEXT_STYLE_DEFAULT_SHADOW_OFFSET_Y ||
|
|
@@ -8026,8 +8006,7 @@ class UITextStyle {
|
|
|
8026
8006
|
this._private_fontSizeInternal = TEXT_STYLE_DEFAULT_FONT_SIZE;
|
|
8027
8007
|
this._private_fontStyleInternal = TEXT_STYLE_DEFAULT_FONT_STYLE;
|
|
8028
8008
|
this._private_fontWeightInternal = TEXT_STYLE_DEFAULT_FONT_WEIGHT;
|
|
8029
|
-
this._private_lineHeightInternal =
|
|
8030
|
-
TEXT_STYLE_DEFAULT_FONT_SIZE * TEXT_STYLE_DEFAULT_LINE_HEIGHT;
|
|
8009
|
+
this._private_lineHeightInternal = TEXT_STYLE_DEFAULT_FONT_SIZE * TEXT_STYLE_DEFAULT_LINE_HEIGHT;
|
|
8031
8010
|
this._private_enableShadowInternal = TEXT_STYLE_DEFAULT_ENABLE_SHADOW;
|
|
8032
8011
|
this._private_shadowOffsetXInternal = TEXT_STYLE_DEFAULT_SHADOW_OFFSET_X;
|
|
8033
8012
|
this._private_shadowOffsetYInternal = TEXT_STYLE_DEFAULT_SHADOW_OFFSET_Y;
|
|
@@ -8241,8 +8220,7 @@ function buildTextLines(maxWidth, textChunks) {
|
|
|
8241
8220
|
currentLineHeight = 0;
|
|
8242
8221
|
continue;
|
|
8243
8222
|
}
|
|
8244
|
-
if (currentLine.length === 0 ||
|
|
8245
|
-
currentWidth + textChunk.metrics.width <= maxWidth) {
|
|
8223
|
+
if (currentLine.length === 0 || currentWidth + textChunk.metrics.width <= maxWidth) {
|
|
8246
8224
|
currentLine.push(textChunk);
|
|
8247
8225
|
currentWidth += textChunk.metrics.width;
|
|
8248
8226
|
currentHeight = Math.max(currentHeight, textChunk.metrics.height);
|
|
@@ -8416,8 +8394,7 @@ class UIText extends UIElement {
|
|
|
8416
8394
|
this._private_colorInternal = color;
|
|
8417
8395
|
this._private_paddingInternal = new UIInsets(options.padding);
|
|
8418
8396
|
this.commonStyle = new UITextStyle(options.commonStyle);
|
|
8419
|
-
this._private_maxLineWidthInternal =
|
|
8420
|
-
options.maxLineWidth ?? TEXT_DEFAULT_MAX_LINE_WIDTH;
|
|
8397
|
+
this._private_maxLineWidthInternal = options.maxLineWidth ?? TEXT_DEFAULT_MAX_LINE_WIDTH;
|
|
8421
8398
|
this._private_resizeModeInternal = options.resizeMode ?? TEXT_DEFAULT_RESIZE_MODE;
|
|
8422
8399
|
this._private_canvas = canvas;
|
|
8423
8400
|
this._private_context = context;
|
|
@@ -8465,9 +8442,7 @@ class UIText extends UIElement {
|
|
|
8465
8442
|
set content(value) {
|
|
8466
8443
|
if (this._private_contentInternal !== value) {
|
|
8467
8444
|
if (typeof value === "string") {
|
|
8468
|
-
this._private_contentInternal = [
|
|
8469
|
-
new UITextSpan({ text: value, style: new UITextStyle() }),
|
|
8470
|
-
];
|
|
8445
|
+
this._private_contentInternal = [new UITextSpan({ text: value, style: new UITextStyle() })];
|
|
8471
8446
|
}
|
|
8472
8447
|
else if (Array.isArray(value)) {
|
|
8473
8448
|
this._private_contentInternal = value.map((span) => typeof span === "string"
|
|
@@ -8529,8 +8504,7 @@ class UIText extends UIElement {
|
|
|
8529
8504
|
!this._private_maxLineWidthDirty &&
|
|
8530
8505
|
!this._private_paddingInternal.dirty &&
|
|
8531
8506
|
!(this.solverWrapper.dirty &&
|
|
8532
|
-
this._private_lastWidth / this._private_lastHeight !==
|
|
8533
|
-
Math.round(this.width) / Math.round(this.height)) &&
|
|
8507
|
+
this._private_lastWidth / this._private_lastHeight !== Math.round(this.width) / Math.round(this.height)) &&
|
|
8534
8508
|
!this._private_checkContentDirty()) {
|
|
8535
8509
|
return;
|
|
8536
8510
|
}
|
|
@@ -8623,15 +8597,14 @@ class UIText extends UIElement {
|
|
|
8623
8597
|
}
|
|
8624
8598
|
_private_checkDimensionsDirty() {
|
|
8625
8599
|
return (this.solverWrapper.dirty &&
|
|
8626
|
-
(this._private_lastWidth !== Math.round(this.width) ||
|
|
8627
|
-
this._private_lastHeight !== Math.round(this.height)));
|
|
8600
|
+
(this._private_lastWidth !== Math.round(this.width) || this._private_lastHeight !== Math.round(this.height)));
|
|
8628
8601
|
}
|
|
8629
8602
|
_private_setDimensionsDirtyFalse() {
|
|
8630
8603
|
this._private_lastWidth = Math.round(this.width);
|
|
8631
8604
|
this._private_lastHeight = Math.round(this.height);
|
|
8632
8605
|
}
|
|
8633
8606
|
_private_checkContentDirty() {
|
|
8634
|
-
return
|
|
8607
|
+
return this._private_contentDirty || this.content.some((span) => span.dirty);
|
|
8635
8608
|
}
|
|
8636
8609
|
_private_setContentDirtyFalse() {
|
|
8637
8610
|
this._private_contentDirty = false;
|
|
@@ -8777,13 +8750,9 @@ class UIFullscreenLayer extends UILayer {
|
|
|
8777
8750
|
return result.set(near, direction);
|
|
8778
8751
|
}
|
|
8779
8752
|
_private_handleWindowInput(event, pointerFunctionName, signal) {
|
|
8780
|
-
const rect = event.target instanceof HTMLElement
|
|
8781
|
-
? event.target.getBoundingClientRect()
|
|
8782
|
-
: null;
|
|
8753
|
+
const rect = event.target instanceof HTMLElement ? event.target.getBoundingClientRect() : null;
|
|
8783
8754
|
const x = rect ? event.clientX - rect.left : event.clientX;
|
|
8784
|
-
const y = rect
|
|
8785
|
-
? rect.bottom - event.clientY
|
|
8786
|
-
: window.innerHeight - event.clientY;
|
|
8755
|
+
const y = rect ? rect.bottom - event.clientY : window.innerHeight - event.clientY;
|
|
8787
8756
|
const scale = this.resizePolicy.calculateScale(window.innerWidth, window.innerHeight);
|
|
8788
8757
|
const scaledX = x * scale;
|
|
8789
8758
|
const scaledY = y * scale;
|
|
@@ -8855,10 +8824,7 @@ class UIAreaPolygon extends UIArea {
|
|
|
8855
8824
|
const previousX = previousVertex.x;
|
|
8856
8825
|
const previousY = previousVertex.y;
|
|
8857
8826
|
if (currentY > pointY !== previousY > pointY &&
|
|
8858
|
-
pointX <
|
|
8859
|
-
((previousX - currentX) * (pointY - currentY)) /
|
|
8860
|
-
(previousY - currentY) +
|
|
8861
|
-
currentX) {
|
|
8827
|
+
pointX < ((previousX - currentX) * (pointY - currentY)) / (previousY - currentY) + currentX) {
|
|
8862
8828
|
inside = !inside;
|
|
8863
8829
|
}
|
|
8864
8830
|
}
|