laymur 0.27.1 → 0.29.0
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 +99 -5
- package/dist/core/constraints/UIAspectConstraint/UIAspectConstraint.d.ts +14 -3
- package/dist/core/constraints/UIAspectConstraint/UIAspectConstraint.js +40 -6
- package/dist/core/constraints/UICustomConstraint.js +2 -2
- package/dist/core/constraints/UIHeightConstraint/UIHeightConstraint.js +3 -2
- package/dist/core/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.js +3 -2
- package/dist/core/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.js +3 -2
- package/dist/core/constraints/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.js +3 -2
- package/dist/core/constraints/UISingleParameterConstraint/UISingleParameterConstraint.d.ts +6 -0
- package/dist/core/constraints/UISingleParameterConstraint/UISingleParameterConstraint.js +8 -0
- package/dist/core/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.js +3 -2
- package/dist/core/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.js +3 -2
- package/dist/core/constraints/UIVerticalProportionConstraint/UIVerticalProportionConstraint.js +3 -2
- package/dist/core/constraints/UIWidthConstraint/UIWidthConstraint.js +3 -2
- package/dist/core/constraints/constraintAsserts.d.ts +41 -0
- package/dist/core/constraints/constraintAsserts.js +171 -0
- package/dist/core/elements/UICanvasElement/UICanvasElement.d.ts +54 -0
- package/dist/core/elements/UICanvasElement/UICanvasElement.js +70 -0
- package/dist/core/elements/UIDummy/UIDummy.Internal.d.ts +2 -0
- package/dist/core/elements/UIDummy/UIDummy.d.ts +8 -5
- package/dist/core/elements/UIDummy/UIDummy.js +24 -11
- package/dist/core/elements/UIElement/UIElement.Internal.d.ts +6 -5
- package/dist/core/elements/UIElement/UIElement.Internal.js +0 -4
- package/dist/core/elements/UIElement/UIElement.d.ts +12 -6
- package/dist/core/elements/UIElement/UIElement.js +14 -7
- package/dist/core/elements/UIGraphics/UIGraphics.Internal.d.ts +42 -2
- package/dist/core/elements/UIGraphics/UIGraphics.Internal.js +2 -2
- package/dist/core/elements/UIGraphics/UIGraphics.d.ts +48 -34
- package/dist/core/elements/UIGraphics/UIGraphics.js +196 -93
- package/dist/core/elements/UIImage/UIImage.d.ts +11 -1
- package/dist/core/elements/UIImage/UIImage.js +14 -0
- package/dist/core/elements/UIScene/UIScene.Internal.d.ts +10 -1
- package/dist/core/elements/UIScene/UIScene.Internal.js +1 -0
- package/dist/core/elements/UIScene/UIScene.d.ts +11 -1
- package/dist/core/elements/UIScene/UIScene.js +29 -5
- package/dist/core/elements/UIText/UIText.Interfaces.d.ts +2 -2
- package/dist/core/elements/UIText/UIText.Internal.d.ts +14 -1
- package/dist/core/elements/UIText/UIText.Internal.js +12 -0
- package/dist/core/elements/UIText/UIText.Measuring.d.ts +9 -4
- package/dist/core/elements/UIText/UIText.Measuring.js +17 -6
- package/dist/core/elements/UIText/UIText.Rendering.d.ts +7 -16
- package/dist/core/elements/UIText/UIText.Rendering.js +212 -46
- package/dist/core/elements/UIText/UIText.d.ts +64 -29
- package/dist/core/elements/UIText/UIText.js +134 -149
- package/dist/core/index.d.ts +10 -4
- package/dist/core/index.js +5 -1
- package/dist/core/layers/UILayer/UILayer.d.ts +17 -3
- package/dist/core/layers/UILayer/UILayer.js +35 -4
- package/dist/core/layers/UIViewportLayer/UIViewportLayer.d.ts +2 -0
- package/dist/core/layers/UIViewportLayer/UIViewportLayer.js +4 -1
- package/dist/core/miscellaneous/UIBlendMode.d.ts +5 -0
- package/dist/core/miscellaneous/UIBlendMode.js +7 -0
- package/dist/core/miscellaneous/asserts.d.ts +0 -41
- package/dist/core/miscellaneous/asserts.js +0 -170
- package/dist/core/miscellaneous/canvas-surface/UICanvasSurface.d.ts +46 -0
- package/dist/core/miscellaneous/canvas-surface/UICanvasSurface.js +86 -0
- package/dist/core/miscellaneous/color/UIColor.d.ts +17 -0
- package/dist/core/miscellaneous/color/UIColor.js +22 -0
- package/dist/core/miscellaneous/color/canvasColor.d.ts +9 -0
- package/dist/core/miscellaneous/color/canvasColor.js +15 -0
- package/dist/core/miscellaneous/insets/UIInsets.d.ts +3 -0
- package/dist/core/miscellaneous/insets/UIInsets.js +15 -0
- package/dist/core/miscellaneous/mask-function/UIProgressMaskFunctionCircular.d.ts +10 -7
- package/dist/core/miscellaneous/mask-function/UIProgressMaskFunctionCircular.js +11 -8
- package/dist/core/miscellaneous/paint/UIGradient.Internal.d.ts +37 -0
- package/dist/core/miscellaneous/paint/UIGradient.Internal.js +14 -0
- package/dist/core/miscellaneous/paint/UIGradient.d.ts +18 -0
- package/dist/core/miscellaneous/paint/UIGradient.js +35 -0
- package/dist/core/miscellaneous/paint/UILinearGradient.d.ts +14 -0
- package/dist/core/miscellaneous/paint/UILinearGradient.js +22 -0
- package/dist/core/miscellaneous/paint/UIPaint.Internal.d.ts +21 -0
- package/dist/core/miscellaneous/paint/UIPaint.Internal.js +1 -0
- package/dist/core/miscellaneous/paint/UIPaint.d.ts +17 -0
- package/dist/core/miscellaneous/paint/UIPaint.js +21 -0
- package/dist/core/miscellaneous/paint/UIRadialGradient.d.ts +18 -0
- package/dist/core/miscellaneous/paint/UIRadialGradient.js +33 -0
- package/dist/core/miscellaneous/shared.d.ts +14 -0
- package/dist/core/miscellaneous/shared.js +11 -0
- package/dist/core/miscellaneous/text-style/UITextStyle.Internal.d.ts +91 -30
- package/dist/core/miscellaneous/text-style/UITextStyle.Internal.js +12 -8
- package/dist/core/miscellaneous/text-style/UITextStyle.d.ts +41 -63
- package/dist/core/miscellaneous/text-style/UITextStyle.js +165 -291
- package/dist/core/miscellaneous/texture/UITextureView.Internal.d.ts +2 -1
- package/dist/core/miscellaneous/texture/UITextureView.Internal.js +12 -3
- package/dist/core/shaders/UIProgressMaskFunctionCircular.js +1 -2
- package/dist/core/wrappers/UIInputWrapper/UIInputWrapper.Internal.d.ts +7 -3
- package/dist/core/wrappers/UIInputWrapper/UIInputWrapper.d.ts +2 -1
- package/dist/core/wrappers/UIInputWrapper/UIInputWrapper.js +19 -10
- package/dist/core/wrappers/UISolverWrapper/UISolverWrapper.Internal.d.ts +6 -2
- package/dist/core/wrappers/UISolverWrapper/UISolverWrapper.d.ts +41 -9
- package/dist/core/wrappers/UISolverWrapper/UISolverWrapper.js +97 -35
- package/dist/particles/behaviorModules/UIBehaviorAlignToVelocity.d.ts +44 -0
- package/dist/particles/behaviorModules/UIBehaviorAlignToVelocity.js +75 -0
- package/dist/particles/behaviorModules/UIBehaviorBounce.d.ts +51 -0
- package/dist/particles/behaviorModules/UIBehaviorBounce.js +107 -0
- package/dist/particles/behaviorModules/UIBehaviorOrbit.d.ts +39 -0
- package/dist/particles/behaviorModules/UIBehaviorOrbit.js +73 -0
- package/dist/particles/behaviorModules/UIBehaviorScaleOverLife.d.ts +7 -2
- package/dist/particles/behaviorModules/UIBehaviorScaleOverLife.js +9 -5
- package/dist/particles/behaviorModules/UIBehaviorSeek.d.ts +38 -0
- package/dist/particles/behaviorModules/UIBehaviorSeek.js +75 -0
- package/dist/particles/elements/UIEmitter.Internal.d.ts +48 -1
- package/dist/particles/elements/UIEmitter.Internal.js +26 -1
- package/dist/particles/elements/UIEmitter.Schedule.d.ts +31 -0
- package/dist/particles/elements/UIEmitter.Schedule.js +81 -0
- package/dist/particles/elements/UIEmitter.d.ts +79 -9
- package/dist/particles/elements/UIEmitter.js +241 -83
- package/dist/particles/index.d.ts +13 -1
- package/dist/particles/index.js +11 -1
- package/dist/particles/instancedParticle/UIInstancedParticle.Internal.d.ts +6 -0
- package/dist/particles/instancedParticle/UIInstancedParticle.Internal.js +27 -0
- package/dist/particles/instancedParticle/UIInstancedParticle.d.ts +7 -1
- package/dist/particles/instancedParticle/UIInstancedParticle.js +12 -1
- package/dist/particles/miscellaneous/miscellaneous.d.ts +22 -0
- package/dist/particles/miscellaneous/miscellaneous.js +38 -0
- package/dist/particles/renderingModules/UIRenderingFlipbook.d.ts +41 -0
- package/dist/particles/renderingModules/UIRenderingFlipbook.js +70 -0
- package/dist/particles/renderingModules/UIRenderingModule.d.ts +2 -1
- package/dist/particles/renderingModules/UIRenderingModule.js +2 -1
- package/dist/particles/renderingModules/UIRenderingRandomColor.d.ts +19 -0
- package/dist/particles/renderingModules/UIRenderingRandomColor.js +28 -0
- package/dist/particles/renderingModules/UIRenderingShape.d.ts +31 -0
- package/dist/particles/renderingModules/UIRenderingShape.js +54 -0
- package/dist/particles/renderingModules/UIRenderingTexture.d.ts +1 -1
- package/dist/particles/renderingModules/UIRenderingTexture.js +4 -28
- package/dist/particles/shaders/UIRenderingFlipbook.d.ts +5 -0
- package/dist/particles/shaders/UIRenderingFlipbook.js +19 -0
- package/dist/particles/shaders/UIRenderingRandomColor.d.ts +2 -0
- package/dist/particles/shaders/UIRenderingRandomColor.js +10 -0
- package/dist/particles/shaders/UIRenderingShape.d.ts +6 -0
- package/dist/particles/shaders/UIRenderingShape.js +15 -0
- package/dist/particles/shaders/UIRenderingTexture.d.ts +4 -2
- package/dist/particles/shaders/UIRenderingTexture.js +27 -2
- package/dist/particles/spawnModules/UISpawnCircle.d.ts +44 -0
- package/dist/particles/spawnModules/UISpawnCircle.js +81 -0
- package/dist/particles/spawnModules/UISpawnRadialVelocity.d.ts +37 -0
- package/dist/particles/spawnModules/UISpawnRadialVelocity.js +75 -0
- package/package.json +1 -1
|
@@ -1,51 +1,65 @@
|
|
|
1
|
-
import type { WebGLRenderer } from "three";
|
|
2
1
|
import type { UILayer } from "../../layers/UILayer/UILayer.js";
|
|
3
|
-
import type {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
import type { UICanvasRenderingContext2D } from "../../miscellaneous/canvas.js";
|
|
3
|
+
import type { Vector2Like } from "../../miscellaneous/math.js";
|
|
4
|
+
import type { UIPaintConfig } from "../../miscellaneous/paint/UIPaint.Internal.js";
|
|
5
|
+
import { UICanvasElement } from "../UICanvasElement/UICanvasElement.js";
|
|
6
|
+
import type { UIGraphicsCornerRadius, UIGraphicsOptions, UIGraphicsStrokeConfig, UIGraphicsStyle } from "./UIGraphics.Internal.js";
|
|
7
|
+
/**
|
|
8
|
+
* 2D vector drawing element. Shapes are drawn in a drawing box as large as the width and height
|
|
9
|
+
* the element is created with, from its top left corner with y pointing down, and the box is
|
|
10
|
+
* stretched over the element. The shapes are kept until `clear`.
|
|
11
|
+
*/
|
|
12
|
+
export declare class UIGraphics extends UICanvasElement {
|
|
13
|
+
/** Width of the drawing box */
|
|
14
|
+
protected readonly contentWidth: number;
|
|
15
|
+
/** Height of the drawing box */
|
|
16
|
+
protected readonly contentHeight: number;
|
|
17
|
+
private readonly shapes;
|
|
18
|
+
private shapesDirty;
|
|
13
19
|
/**
|
|
14
20
|
* Creates a new UIGraphics instance.
|
|
15
21
|
*
|
|
16
22
|
* @param layer - Layer containing this element
|
|
17
|
-
* @param options - Configuration options
|
|
23
|
+
* @param options - Configuration options. The width and height also set the drawing box.
|
|
18
24
|
*/
|
|
19
25
|
constructor(layer: UILayer, options?: Partial<UIGraphicsOptions>);
|
|
20
|
-
/** Multiplicative tint. Alpha channel controls opacity. */
|
|
21
|
-
get color(): UIColor;
|
|
22
|
-
/** Multiplicative tint. Alpha channel controls opacity. */
|
|
23
|
-
set color(value: UIColorConfig);
|
|
24
26
|
/**
|
|
25
|
-
*
|
|
27
|
+
* Removes all shapes. Optionally fills the drawing box.
|
|
26
28
|
*
|
|
27
|
-
* @param
|
|
29
|
+
* @param fill - Color or gradient filling the box after clearing
|
|
28
30
|
*/
|
|
29
|
-
clear(
|
|
30
|
-
/** Draws
|
|
31
|
-
drawRect(x: number, y: number, width: number, height: number,
|
|
32
|
-
/** Draws filled circle */
|
|
33
|
-
drawCircle(x: number, y: number, radius: number, color: UIColorConfig): this;
|
|
31
|
+
clear(fill?: UIPaintConfig): this;
|
|
32
|
+
/** Draws a rectangle */
|
|
33
|
+
drawRect(x: number, y: number, width: number, height: number, style: UIGraphicsStyle): this;
|
|
34
34
|
/**
|
|
35
|
-
* Draws
|
|
35
|
+
* Draws a rectangle with rounded corners. Each radius is clamped to half of the shorter side.
|
|
36
36
|
*
|
|
37
|
-
* @param
|
|
38
|
-
* @param endAngle - End angle in radians
|
|
37
|
+
* @param radius - One radius for all corners, or four from the top left clockwise
|
|
39
38
|
*/
|
|
40
|
-
|
|
39
|
+
drawRoundedRect(x: number, y: number, width: number, height: number, radius: UIGraphicsCornerRadius, style: UIGraphicsStyle): this;
|
|
40
|
+
/** Draws a circle */
|
|
41
|
+
drawCircle(x: number, y: number, radius: number, style: UIGraphicsStyle): this;
|
|
41
42
|
/**
|
|
42
|
-
* Draws
|
|
43
|
+
* Draws an arc of a circle. A fill covers the part cut off by the chord between its ends.
|
|
44
|
+
* Gradients are laid over the bounds of the whole circle.
|
|
43
45
|
*
|
|
44
|
-
* @param
|
|
45
|
-
* @param
|
|
46
|
+
* @param startAngle - Start angle in radians, clockwise from the right
|
|
47
|
+
* @param endAngle - End angle in radians, clockwise from the right
|
|
46
48
|
*/
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
drawArc(x: number, y: number, radius: number, startAngle: number, endAngle: number, style: UIGraphicsStyle): this;
|
|
50
|
+
/**
|
|
51
|
+
* Draws a closed polygon. Needs at least three points.
|
|
52
|
+
*
|
|
53
|
+
* @param points - Corners in order
|
|
54
|
+
*/
|
|
55
|
+
drawPolygon(points: readonly Vector2Like[], style: UIGraphicsStyle): this;
|
|
56
|
+
/**
|
|
57
|
+
* Draws connected line segments. Needs at least two points.
|
|
58
|
+
*
|
|
59
|
+
* @param points - Points in order
|
|
60
|
+
*/
|
|
61
|
+
drawPolyline(points: readonly Vector2Like[], stroke: UIGraphicsStrokeConfig): this;
|
|
62
|
+
protected updateContent(): boolean;
|
|
63
|
+
protected drawContent(context: UICanvasRenderingContext2D): void;
|
|
64
|
+
private addShape;
|
|
51
65
|
}
|
|
@@ -1,123 +1,226 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { assertValidNonNegativeNumber, assertValidNumber } from "../../miscellaneous/asserts.js";
|
|
2
|
+
import { resolvePaint, toCanvasPaint } from "../../miscellaneous/paint/UIPaint.js";
|
|
3
|
+
import { UICanvasElement } from "../UICanvasElement/UICanvasElement.js";
|
|
4
|
+
import { GRAPHICS_DEFAULT_HEIGHT, GRAPHICS_DEFAULT_STROKE_CAP, GRAPHICS_DEFAULT_STROKE_JOIN, GRAPHICS_DEFAULT_WIDTH, } from "./UIGraphics.Internal.js";
|
|
5
|
+
/**
|
|
6
|
+
* Bounds of a list of points.
|
|
7
|
+
* @param points Points to bound
|
|
8
|
+
* @returns Box around the points
|
|
9
|
+
*/
|
|
10
|
+
function boundPoints(points) {
|
|
11
|
+
let minX = Infinity;
|
|
12
|
+
let minY = Infinity;
|
|
13
|
+
let maxX = -Infinity;
|
|
14
|
+
let maxY = -Infinity;
|
|
15
|
+
for (const point of points) {
|
|
16
|
+
minX = Math.min(minX, point.x);
|
|
17
|
+
minY = Math.min(minY, point.y);
|
|
18
|
+
maxX = Math.max(maxX, point.x);
|
|
19
|
+
maxY = Math.max(maxY, point.y);
|
|
20
|
+
}
|
|
21
|
+
return { x: minX, y: minY, width: maxX - minX, height: maxY - minY };
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Copies points, so later changes of the given objects do not change the shape.
|
|
25
|
+
* @param points Points to copy
|
|
26
|
+
* @param subject Name of the method, used in errors
|
|
27
|
+
* @returns Copied points
|
|
28
|
+
*/
|
|
29
|
+
function copyPoints(points, subject) {
|
|
30
|
+
return points.map((point) => {
|
|
31
|
+
assertValidNumber(point.x, `${subject}.points.x`);
|
|
32
|
+
assertValidNumber(point.y, `${subject}.points.y`);
|
|
33
|
+
return { x: point.x, y: point.y };
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Adds lines through points to the current path, from the first point on.
|
|
38
|
+
* @param context Path to add to
|
|
39
|
+
* @param points Points in order, at least one
|
|
40
|
+
*/
|
|
41
|
+
function tracePoints(context, points) {
|
|
42
|
+
context.moveTo(points[0].x, points[0].y);
|
|
43
|
+
for (let i = 1; i < points.length; i++) {
|
|
44
|
+
context.lineTo(points[i].x, points[i].y);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* 2D vector drawing element. Shapes are drawn in a drawing box as large as the width and height
|
|
49
|
+
* the element is created with, from its top left corner with y pointing down, and the box is
|
|
50
|
+
* stretched over the element. The shapes are kept until `clear`.
|
|
51
|
+
*/
|
|
52
|
+
export class UIGraphics extends UICanvasElement {
|
|
9
53
|
/**
|
|
10
54
|
* Creates a new UIGraphics instance.
|
|
11
55
|
*
|
|
12
56
|
* @param layer - Layer containing this element
|
|
13
|
-
* @param options - Configuration options
|
|
57
|
+
* @param options - Configuration options. The width and height also set the drawing box.
|
|
14
58
|
*/
|
|
15
59
|
constructor(layer, options) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (!context) {
|
|
22
|
-
throw new Error("UIGraphics.constructor: failed to get 2D context from canvas");
|
|
23
|
-
}
|
|
24
|
-
const texture = createCanvasTexture(canvas);
|
|
25
|
-
texture.needsUpdate = true;
|
|
26
|
-
super(layer, source, {
|
|
27
|
-
texture: texture,
|
|
28
|
-
textureTransform: new UIAffineMatrix3(),
|
|
29
|
-
color,
|
|
30
|
-
}, options);
|
|
31
|
-
this.canvas = canvas;
|
|
32
|
-
this.context = context;
|
|
33
|
-
this.texture = texture;
|
|
34
|
-
this.colorInternal = color;
|
|
35
|
-
}
|
|
36
|
-
/** Multiplicative tint. Alpha channel controls opacity. */
|
|
37
|
-
get color() {
|
|
38
|
-
return this.colorInternal;
|
|
39
|
-
}
|
|
40
|
-
/** Multiplicative tint. Alpha channel controls opacity. */
|
|
41
|
-
set color(value) {
|
|
42
|
-
this.colorInternal.set(value);
|
|
60
|
+
super(layer, "UIGraphics.constructor", options);
|
|
61
|
+
this.shapes = [];
|
|
62
|
+
this.shapesDirty = true;
|
|
63
|
+
this.contentWidth = options?.width ?? GRAPHICS_DEFAULT_WIDTH;
|
|
64
|
+
this.contentHeight = options?.height ?? GRAPHICS_DEFAULT_HEIGHT;
|
|
43
65
|
}
|
|
44
66
|
/**
|
|
45
|
-
*
|
|
67
|
+
* Removes all shapes. Optionally fills the drawing box.
|
|
46
68
|
*
|
|
47
|
-
* @param
|
|
69
|
+
* @param fill - Color or gradient filling the box after clearing
|
|
48
70
|
*/
|
|
49
|
-
clear(
|
|
50
|
-
this.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
this.
|
|
71
|
+
clear(fill) {
|
|
72
|
+
this.shapes.length = 0;
|
|
73
|
+
this.shapesDirty = true;
|
|
74
|
+
if (fill !== undefined) {
|
|
75
|
+
this.drawRect(0, 0, this.contentWidth, this.contentHeight, { fill });
|
|
54
76
|
}
|
|
55
|
-
this.texture.needsUpdate = true;
|
|
56
77
|
return this;
|
|
57
78
|
}
|
|
58
|
-
/** Draws
|
|
59
|
-
drawRect(x, y, width, height,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
79
|
+
/** Draws a rectangle */
|
|
80
|
+
drawRect(x, y, width, height, style) {
|
|
81
|
+
assertValidNumber(x, "UIGraphics.drawRect.x");
|
|
82
|
+
assertValidNumber(y, "UIGraphics.drawRect.y");
|
|
83
|
+
assertValidNonNegativeNumber(width, "UIGraphics.drawRect.width");
|
|
84
|
+
assertValidNonNegativeNumber(height, "UIGraphics.drawRect.height");
|
|
85
|
+
return this.addShape({ x, y, width, height }, style, (context) => {
|
|
86
|
+
context.rect(x, y, width, height);
|
|
87
|
+
});
|
|
64
88
|
}
|
|
65
|
-
/**
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
89
|
+
/**
|
|
90
|
+
* Draws a rectangle with rounded corners. Each radius is clamped to half of the shorter side.
|
|
91
|
+
*
|
|
92
|
+
* @param radius - One radius for all corners, or four from the top left clockwise
|
|
93
|
+
*/
|
|
94
|
+
drawRoundedRect(x, y, width, height, radius, style) {
|
|
95
|
+
assertValidNumber(x, "UIGraphics.drawRoundedRect.x");
|
|
96
|
+
assertValidNumber(y, "UIGraphics.drawRoundedRect.y");
|
|
97
|
+
assertValidNonNegativeNumber(width, "UIGraphics.drawRoundedRect.width");
|
|
98
|
+
assertValidNonNegativeNumber(height, "UIGraphics.drawRoundedRect.height");
|
|
99
|
+
const limit = Math.min(width, height) / 2;
|
|
100
|
+
const radii = (typeof radius === "number" ? [radius, radius, radius, radius] : radius).map((value) => {
|
|
101
|
+
assertValidNonNegativeNumber(value, "UIGraphics.drawRoundedRect.radius");
|
|
102
|
+
return Math.min(value, limit);
|
|
103
|
+
});
|
|
104
|
+
const [topLeft, topRight, bottomRight, bottomLeft] = radii;
|
|
105
|
+
const right = x + width;
|
|
106
|
+
const bottom = y + height;
|
|
107
|
+
return this.addShape({ x, y, width, height }, style, (context) => {
|
|
108
|
+
context.moveTo(x + topLeft, y);
|
|
109
|
+
context.arcTo(right, y, right, bottom, topRight);
|
|
110
|
+
context.arcTo(right, bottom, x, bottom, bottomRight);
|
|
111
|
+
context.arcTo(x, bottom, x, y, bottomLeft);
|
|
112
|
+
context.arcTo(x, y, right, y, topLeft);
|
|
113
|
+
context.closePath();
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
/** Draws a circle */
|
|
117
|
+
drawCircle(x, y, radius, style) {
|
|
118
|
+
assertValidNumber(x, "UIGraphics.drawCircle.x");
|
|
119
|
+
assertValidNumber(y, "UIGraphics.drawCircle.y");
|
|
120
|
+
assertValidNonNegativeNumber(radius, "UIGraphics.drawCircle.radius");
|
|
121
|
+
const box = { x: x - radius, y: y - radius, width: radius * 2, height: radius * 2 };
|
|
122
|
+
return this.addShape(box, style, (context) => {
|
|
123
|
+
context.arc(x, y, radius, 0, Math.PI * 2);
|
|
124
|
+
});
|
|
73
125
|
}
|
|
74
126
|
/**
|
|
75
|
-
* Draws
|
|
127
|
+
* Draws an arc of a circle. A fill covers the part cut off by the chord between its ends.
|
|
128
|
+
* Gradients are laid over the bounds of the whole circle.
|
|
76
129
|
*
|
|
77
|
-
* @param startAngle - Start angle in radians
|
|
78
|
-
* @param endAngle - End angle in radians
|
|
130
|
+
* @param startAngle - Start angle in radians, clockwise from the right
|
|
131
|
+
* @param endAngle - End angle in radians, clockwise from the right
|
|
79
132
|
*/
|
|
80
|
-
drawArc(x, y, radius, startAngle, endAngle,
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
133
|
+
drawArc(x, y, radius, startAngle, endAngle, style) {
|
|
134
|
+
assertValidNumber(x, "UIGraphics.drawArc.x");
|
|
135
|
+
assertValidNumber(y, "UIGraphics.drawArc.y");
|
|
136
|
+
assertValidNonNegativeNumber(radius, "UIGraphics.drawArc.radius");
|
|
137
|
+
assertValidNumber(startAngle, "UIGraphics.drawArc.startAngle");
|
|
138
|
+
assertValidNumber(endAngle, "UIGraphics.drawArc.endAngle");
|
|
139
|
+
const box = { x: x - radius, y: y - radius, width: radius * 2, height: radius * 2 };
|
|
140
|
+
return this.addShape(box, style, (context) => {
|
|
141
|
+
context.arc(x, y, radius, startAngle, endAngle);
|
|
142
|
+
});
|
|
87
143
|
}
|
|
88
144
|
/**
|
|
89
|
-
* Draws
|
|
145
|
+
* Draws a closed polygon. Needs at least three points.
|
|
90
146
|
*
|
|
91
|
-
* @param points -
|
|
92
|
-
* @param lineWidth - Line width in pixels
|
|
147
|
+
* @param points - Corners in order
|
|
93
148
|
*/
|
|
94
|
-
|
|
95
|
-
if (points.length <
|
|
149
|
+
drawPolygon(points, style) {
|
|
150
|
+
if (points.length < 3) {
|
|
96
151
|
return this;
|
|
97
152
|
}
|
|
98
|
-
|
|
99
|
-
this.context
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
153
|
+
const corners = copyPoints(points, "UIGraphics.drawPolygon");
|
|
154
|
+
return this.addShape(boundPoints(corners), style, (context) => {
|
|
155
|
+
tracePoints(context, corners);
|
|
156
|
+
context.closePath();
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Draws connected line segments. Needs at least two points.
|
|
161
|
+
*
|
|
162
|
+
* @param points - Points in order
|
|
163
|
+
*/
|
|
164
|
+
drawPolyline(points, stroke) {
|
|
165
|
+
if (points.length < 2) {
|
|
166
|
+
return this;
|
|
104
167
|
}
|
|
105
|
-
|
|
106
|
-
this.
|
|
107
|
-
|
|
168
|
+
const vertices = copyPoints(points, "UIGraphics.drawPolyline");
|
|
169
|
+
return this.addShape(boundPoints(vertices), { stroke }, (context) => {
|
|
170
|
+
tracePoints(context, vertices);
|
|
171
|
+
});
|
|
108
172
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
this.
|
|
112
|
-
|
|
173
|
+
updateContent() {
|
|
174
|
+
const changed = this.shapesDirty;
|
|
175
|
+
this.shapesDirty = false;
|
|
176
|
+
return changed;
|
|
177
|
+
}
|
|
178
|
+
drawContent(context) {
|
|
179
|
+
for (const shape of this.shapes) {
|
|
180
|
+
context.beginPath();
|
|
181
|
+
shape.buildPath(context);
|
|
182
|
+
if (shape.fill !== undefined) {
|
|
183
|
+
context.fillStyle = toCanvasPaint(context, shape.fill, shape.box);
|
|
184
|
+
context.fill();
|
|
185
|
+
}
|
|
186
|
+
if (shape.stroke !== undefined && shape.stroke.width > 0) {
|
|
187
|
+
const halfWidth = shape.stroke.width / 2;
|
|
188
|
+
const strokeBox = {
|
|
189
|
+
x: shape.box.x - halfWidth,
|
|
190
|
+
y: shape.box.y - halfWidth,
|
|
191
|
+
width: shape.box.width + shape.stroke.width,
|
|
192
|
+
height: shape.box.height + shape.stroke.width,
|
|
193
|
+
};
|
|
194
|
+
context.strokeStyle = toCanvasPaint(context, shape.stroke.paint, strokeBox);
|
|
195
|
+
context.lineWidth = shape.stroke.width;
|
|
196
|
+
context.lineJoin = shape.stroke.join;
|
|
197
|
+
context.lineCap = shape.stroke.cap;
|
|
198
|
+
context.stroke();
|
|
199
|
+
}
|
|
200
|
+
}
|
|
113
201
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
});
|
|
119
|
-
this.colorInternal.setDirtyFalse();
|
|
202
|
+
addShape(box, style, buildPath) {
|
|
203
|
+
const { fill, stroke } = style;
|
|
204
|
+
if (stroke !== undefined) {
|
|
205
|
+
assertValidNonNegativeNumber(stroke.width, "UIGraphics.style.stroke.width");
|
|
120
206
|
}
|
|
121
|
-
|
|
207
|
+
if (fill === undefined && stroke === undefined) {
|
|
208
|
+
return this;
|
|
209
|
+
}
|
|
210
|
+
this.shapes.push({
|
|
211
|
+
buildPath,
|
|
212
|
+
box,
|
|
213
|
+
fill: fill === undefined ? undefined : resolvePaint(fill),
|
|
214
|
+
stroke: stroke === undefined
|
|
215
|
+
? undefined
|
|
216
|
+
: {
|
|
217
|
+
paint: resolvePaint(stroke.paint),
|
|
218
|
+
width: stroke.width,
|
|
219
|
+
join: stroke.join ?? GRAPHICS_DEFAULT_STROKE_JOIN,
|
|
220
|
+
cap: stroke.cap ?? GRAPHICS_DEFAULT_STROKE_CAP,
|
|
221
|
+
},
|
|
222
|
+
});
|
|
223
|
+
this.shapesDirty = true;
|
|
224
|
+
return this;
|
|
122
225
|
}
|
|
123
226
|
}
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
+
import type { FerrsignView1 } from "ferrsign";
|
|
1
2
|
import type { UILayer } from "../../layers/UILayer/UILayer.js";
|
|
2
3
|
import type { UIColorConfig } from "../../miscellaneous/color/UIColor.Internal.js";
|
|
3
4
|
import { UIColor } from "../../miscellaneous/color/UIColor.js";
|
|
5
|
+
import type { UIContentAspectElement } from "../../miscellaneous/shared.js";
|
|
4
6
|
import type { UITextureConfig } from "../../miscellaneous/texture/UITextureView.Internal.js";
|
|
5
7
|
import { UITextureView } from "../../miscellaneous/texture/UITextureView.js";
|
|
6
8
|
import { UIElement } from "../UIElement/UIElement.js";
|
|
7
9
|
import type { UIImageOptions } from "./UIImage.Internal.js";
|
|
8
10
|
/** Textured image element */
|
|
9
|
-
export declare class UIImage extends UIElement {
|
|
11
|
+
export declare class UIImage extends UIElement implements UIContentAspectElement {
|
|
10
12
|
/** Texture displayed by this image */
|
|
11
13
|
readonly texture: UITextureView;
|
|
12
14
|
private readonly colorInternal;
|
|
13
15
|
private readonly textureTransform;
|
|
16
|
+
private readonly signalContentAspectChangedInternal;
|
|
14
17
|
/**
|
|
15
18
|
* Creates a new UIImage instance.
|
|
16
19
|
*
|
|
@@ -23,6 +26,13 @@ export declare class UIImage extends UIElement {
|
|
|
23
26
|
constructor(layer: UILayer, texture: UITextureConfig, options?: Partial<UIImageOptions>);
|
|
24
27
|
/** Multiplicative tint. Alpha channel controls opacity. */
|
|
25
28
|
get color(): UIColor;
|
|
29
|
+
/**
|
|
30
|
+
* Aspect of the texture. A `UIAspectConstraint` created without an aspect follows it when the
|
|
31
|
+
* texture changes size.
|
|
32
|
+
*/
|
|
33
|
+
get contentAspect(): number;
|
|
34
|
+
/** Signal fired with the new aspect when the texture changes size */
|
|
35
|
+
get signalContentAspectChanged(): FerrsignView1<number>;
|
|
26
36
|
/** Multiplicative tint. Alpha channel controls opacity. */
|
|
27
37
|
set color(value: UIColorConfig);
|
|
28
38
|
/** Frees resources of the image */
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Ferrsign1 } from "ferrsign";
|
|
1
2
|
import { UIColor } from "../../miscellaneous/color/UIColor.js";
|
|
2
3
|
import { computeTrimmedTransformMatrix, scaleTrim } from "../../miscellaneous/computeTransform.js";
|
|
3
4
|
import { UITextureView } from "../../miscellaneous/texture/UITextureView.js";
|
|
@@ -29,9 +30,11 @@ export class UIImage extends UIElement {
|
|
|
29
30
|
textureTransform: textureTransform,
|
|
30
31
|
color,
|
|
31
32
|
}, options);
|
|
33
|
+
this.signalContentAspectChangedInternal = new Ferrsign1();
|
|
32
34
|
this.onTextureDimensionsChanged = (width, height) => {
|
|
33
35
|
this.width = width;
|
|
34
36
|
this.height = height;
|
|
37
|
+
this.signalContentAspectChangedInternal.emit(width / height);
|
|
35
38
|
};
|
|
36
39
|
this.texture = textureView;
|
|
37
40
|
this.textureTransform = textureTransform;
|
|
@@ -42,6 +45,17 @@ export class UIImage extends UIElement {
|
|
|
42
45
|
get color() {
|
|
43
46
|
return this.colorInternal;
|
|
44
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Aspect of the texture. A `UIAspectConstraint` created without an aspect follows it when the
|
|
50
|
+
* texture changes size.
|
|
51
|
+
*/
|
|
52
|
+
get contentAspect() {
|
|
53
|
+
return this.texture.width / this.texture.height;
|
|
54
|
+
}
|
|
55
|
+
/** Signal fired with the new aspect when the texture changes size */
|
|
56
|
+
get signalContentAspectChanged() {
|
|
57
|
+
return this.signalContentAspectChangedInternal;
|
|
58
|
+
}
|
|
45
59
|
/** Multiplicative tint. Alpha channel controls opacity. */
|
|
46
60
|
set color(value) {
|
|
47
61
|
this.colorInternal.set(value);
|
|
@@ -25,12 +25,20 @@ export interface UISceneOptions extends UIElementOptions {
|
|
|
25
25
|
camera: Camera;
|
|
26
26
|
/** When to re-render */
|
|
27
27
|
updateMode: UISceneUpdateMode;
|
|
28
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* Render target resolution multiplier over the pixel density of the layer, so 1 renders as
|
|
30
|
+
* many pixels as the element covers on the screen. Range 0.1 to 2.0.
|
|
31
|
+
*/
|
|
29
32
|
resolutionFactor: number;
|
|
30
33
|
/** Background color */
|
|
31
34
|
clearColor: UIColorConfig;
|
|
32
35
|
/** Whether to use depth buffer */
|
|
33
36
|
enableDepthBuffer: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Multisample antialiasing samples of the render target, 0 for none. WebGL1 has no multisampled
|
|
39
|
+
* render targets and ignores it. three.js clamps it to the maximum the device supports.
|
|
40
|
+
*/
|
|
41
|
+
samples: number;
|
|
34
42
|
}
|
|
35
43
|
export declare const SCENE_DEFAULT_RESOLUTION_FACTOR = 0.5;
|
|
36
44
|
export declare const SCENE_MIN_RESOLUTION_FACTOR = 0.1;
|
|
@@ -41,3 +49,4 @@ export declare const SCENE_DEFAULT_CAMERA_FAR = 100;
|
|
|
41
49
|
export declare const SCENE_DEFAULT_UPDATE_MODE = UISceneUpdateMode.ON_PROPERTIES_CHANGE;
|
|
42
50
|
export declare const SCENE_DEFAULT_CLEAR_COLOR: UIColor;
|
|
43
51
|
export declare const SCENE_DEFAULT_USE_DEPTH = true;
|
|
52
|
+
export declare const SCENE_DEFAULT_SAMPLES = 0;
|
|
@@ -22,3 +22,4 @@ export const SCENE_DEFAULT_CAMERA_FAR = 100;
|
|
|
22
22
|
export const SCENE_DEFAULT_UPDATE_MODE = UISceneUpdateMode.ON_PROPERTIES_CHANGE;
|
|
23
23
|
export const SCENE_DEFAULT_CLEAR_COLOR = new UIColor(0, 0, 0, 1);
|
|
24
24
|
export const SCENE_DEFAULT_USE_DEPTH = true;
|
|
25
|
+
export const SCENE_DEFAULT_SAMPLES = 0;
|
|
@@ -32,8 +32,13 @@ export declare class UIScene extends UIElement {
|
|
|
32
32
|
get clearColor(): UIColor;
|
|
33
33
|
/** Multiplicative tint. Alpha channel controls opacity. */
|
|
34
34
|
get color(): UIColor;
|
|
35
|
-
/**
|
|
35
|
+
/**
|
|
36
|
+
* Render target resolution multiplier over the pixel density of the layer, so 1 renders as
|
|
37
|
+
* many pixels as the element covers on the screen. Range 0.1 to 2.0.
|
|
38
|
+
*/
|
|
36
39
|
get resolutionFactor(): number;
|
|
40
|
+
/** Multisample antialiasing samples of the render target, 0 for none. WebGL1 ignores it. */
|
|
41
|
+
get samples(): number;
|
|
37
42
|
/** Three.js scene to render */
|
|
38
43
|
get scene(): Scene;
|
|
39
44
|
/** Controls when scene re-renders */
|
|
@@ -46,6 +51,11 @@ export declare class UIScene extends UIElement {
|
|
|
46
51
|
set color(value: UIColorConfig);
|
|
47
52
|
/** Render target resolution multiplier. Range 0.1 to 2.0. */
|
|
48
53
|
set resolutionFactor(value: number);
|
|
54
|
+
/**
|
|
55
|
+
* Multisample antialiasing samples of the render target, 0 for none. WebGL1 ignores it. A change
|
|
56
|
+
* frees the render target, which is allocated again and rendered on the next frame.
|
|
57
|
+
*/
|
|
58
|
+
set samples(value: number);
|
|
49
59
|
/** Three.js scene to render */
|
|
50
60
|
set scene(value: Scene);
|
|
51
61
|
/** Controls when scene re-renders */
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Color, LinearFilter, MathUtils, PerspectiveCamera, RGBAFormat, Scene, UnsignedByteType, WebGLRenderTarget, } from "three";
|
|
2
|
-
import { assertValidPositiveNumber } from "../../miscellaneous/asserts.js";
|
|
2
|
+
import { assertValidNonNegativeInteger, assertValidPositiveNumber, } from "../../miscellaneous/asserts.js";
|
|
3
3
|
import { UIColor } from "../../miscellaneous/color/UIColor.js";
|
|
4
4
|
import { UIAffineMatrix3 } from "../../miscellaneous/UIAffineMatrix3.js";
|
|
5
5
|
import source from "../../shaders/UIImage.js";
|
|
6
6
|
import { DUMMY_DEFAULT_HEIGHT, DUMMY_DEFAULT_WIDTH } from "../UIDummy/UIDummy.Internal.js";
|
|
7
7
|
import { UIElement } from "../UIElement/UIElement.js";
|
|
8
|
-
import { SCENE_DEFAULT_CAMERA_FAR, SCENE_DEFAULT_CAMERA_FOV, SCENE_DEFAULT_CAMERA_NEAR, SCENE_DEFAULT_CLEAR_COLOR, SCENE_DEFAULT_RESOLUTION_FACTOR, SCENE_DEFAULT_UPDATE_MODE, SCENE_DEFAULT_USE_DEPTH, SCENE_MAX_RESOLUTION_FACTOR, SCENE_MIN_RESOLUTION_FACTOR, UISceneUpdateMode, } from "./UIScene.Internal.js";
|
|
8
|
+
import { SCENE_DEFAULT_CAMERA_FAR, SCENE_DEFAULT_CAMERA_FOV, SCENE_DEFAULT_CAMERA_NEAR, SCENE_DEFAULT_CLEAR_COLOR, SCENE_DEFAULT_RESOLUTION_FACTOR, SCENE_DEFAULT_SAMPLES, SCENE_DEFAULT_UPDATE_MODE, SCENE_DEFAULT_USE_DEPTH, SCENE_MAX_RESOLUTION_FACTOR, SCENE_MIN_RESOLUTION_FACTOR, UISceneUpdateMode, } from "./UIScene.Internal.js";
|
|
9
9
|
let previousClearColor = new Color();
|
|
10
10
|
let previousClearAlpha = 0;
|
|
11
11
|
/** Renders Three.js scene to texture */
|
|
@@ -22,6 +22,8 @@ export class UIScene extends UIElement {
|
|
|
22
22
|
assertValidPositiveNumber(options.resolutionFactor, "UIScene.constructor.resolutionFactor");
|
|
23
23
|
}
|
|
24
24
|
const resolutionFactor = MathUtils.clamp(options.resolutionFactor ?? SCENE_DEFAULT_RESOLUTION_FACTOR, SCENE_MIN_RESOLUTION_FACTOR, SCENE_MAX_RESOLUTION_FACTOR);
|
|
25
|
+
const samples = options.samples ?? SCENE_DEFAULT_SAMPLES;
|
|
26
|
+
assertValidNonNegativeInteger(samples, "UIScene.constructor.options.samples");
|
|
25
27
|
const w = options.width ?? DUMMY_DEFAULT_WIDTH;
|
|
26
28
|
const h = options.height ?? DUMMY_DEFAULT_HEIGHT;
|
|
27
29
|
const renderTarget = new WebGLRenderTarget(w * resolutionFactor, h * resolutionFactor, {
|
|
@@ -31,6 +33,7 @@ export class UIScene extends UIElement {
|
|
|
31
33
|
type: UnsignedByteType,
|
|
32
34
|
depthBuffer: options.enableDepthBuffer ?? SCENE_DEFAULT_USE_DEPTH,
|
|
33
35
|
stencilBuffer: false,
|
|
36
|
+
samples,
|
|
34
37
|
});
|
|
35
38
|
const color = new UIColor(options.color);
|
|
36
39
|
super(layer, source, {
|
|
@@ -69,10 +72,17 @@ export class UIScene extends UIElement {
|
|
|
69
72
|
get color() {
|
|
70
73
|
return this.colorInternal;
|
|
71
74
|
}
|
|
72
|
-
/**
|
|
75
|
+
/**
|
|
76
|
+
* Render target resolution multiplier over the pixel density of the layer, so 1 renders as
|
|
77
|
+
* many pixels as the element covers on the screen. Range 0.1 to 2.0.
|
|
78
|
+
*/
|
|
73
79
|
get resolutionFactor() {
|
|
74
80
|
return this.resolutionFactorInternal;
|
|
75
81
|
}
|
|
82
|
+
/** Multisample antialiasing samples of the render target, 0 for none. WebGL1 ignores it. */
|
|
83
|
+
get samples() {
|
|
84
|
+
return this.renderTarget.samples;
|
|
85
|
+
}
|
|
76
86
|
/** Three.js scene to render */
|
|
77
87
|
get scene() {
|
|
78
88
|
return this.sceneInternal;
|
|
@@ -104,6 +114,19 @@ export class UIScene extends UIElement {
|
|
|
104
114
|
this.resolutionFactorInternal = value;
|
|
105
115
|
}
|
|
106
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* Multisample antialiasing samples of the render target, 0 for none. WebGL1 ignores it. A change
|
|
119
|
+
* frees the render target, which is allocated again and rendered on the next frame.
|
|
120
|
+
*/
|
|
121
|
+
set samples(value) {
|
|
122
|
+
this.assertNotDestroyed("UIScene.samples");
|
|
123
|
+
assertValidNonNegativeInteger(value, "UIScene.samples");
|
|
124
|
+
if (this.renderTarget.samples !== value) {
|
|
125
|
+
this.renderTarget.samples = value;
|
|
126
|
+
this.renderTarget.dispose();
|
|
127
|
+
this.updateRequired = true;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
107
130
|
/** Three.js scene to render */
|
|
108
131
|
set scene(value) {
|
|
109
132
|
if (this.sceneInternal !== value) {
|
|
@@ -132,8 +155,9 @@ export class UIScene extends UIElement {
|
|
|
132
155
|
this.evenFrame = !this.evenFrame;
|
|
133
156
|
// Compared every frame rather than on layout changes, so a size change is kept until a frame
|
|
134
157
|
// that renders the scene applies it
|
|
135
|
-
const
|
|
136
|
-
const
|
|
158
|
+
const pixelsPerUnit = this.layer.pixelDensity * this.resolutionFactorInternal;
|
|
159
|
+
const targetWidth = Math.max(Math.round(this.width * pixelsPerUnit), 1);
|
|
160
|
+
const targetHeight = Math.max(Math.round(this.height * pixelsPerUnit), 1);
|
|
137
161
|
const isSizeDirty = this.renderTarget.width !== targetWidth || this.renderTarget.height !== targetHeight;
|
|
138
162
|
const isFramebufferDirty = this.updateRequired ||
|
|
139
163
|
this.updateModeInternal === UISceneUpdateMode.EVERY_FRAME ||
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { UITextSpanConfig } from "../../miscellaneous/text-span/UITextSpan.Internal.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { UIResolvedTextStyle } from "../../miscellaneous/text-style/UITextStyle.Internal.js";
|
|
3
3
|
/** Text content configuration */
|
|
4
4
|
export type UITextContent = (UITextSpanConfig | string)[] | UITextSpanConfig | string;
|
|
5
5
|
/** Text dimensions */
|
|
@@ -25,7 +25,7 @@ export interface UITextChunk {
|
|
|
25
25
|
/** Text content */
|
|
26
26
|
text: string;
|
|
27
27
|
/** Resolved style */
|
|
28
|
-
style:
|
|
28
|
+
style: UIResolvedTextStyle;
|
|
29
29
|
/** Chunk metrics */
|
|
30
30
|
metrics: UIChunkMetrics;
|
|
31
31
|
/** Resolved bidirectional class used for visual reordering */
|