laymur 0.15.1 → 0.17.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/.claude/settings.local.json +9 -0
- package/.editorconfig +14 -0
- package/CLAUDE.md +181 -0
- package/README.md +84 -208
- package/assets/logotype.png +0 -0
- package/eslint.config.js +111 -0
- package/package.json +20 -36
- package/rollup.config.js +52 -0
- package/{dist/constraints/UIAspectConstraint/UIAspectConstraint.Internal.d.ts → src/core/constraints/UIAspectConstraint/UIAspectConstraint.Internal.ts} +3 -2
- package/src/core/constraints/UIAspectConstraint/UIAspectConstraint.ts +60 -0
- package/src/core/constraints/UIConstraint.ts +20 -0
- package/src/core/constraints/UICustomConstraint.ts +62 -0
- package/{dist/constraints/UIHeightConstraint/UIHeightConstraint.Internal.d.ts → src/core/constraints/UIHeightConstraint/UIHeightConstraint.Internal.ts} +3 -2
- package/src/core/constraints/UIHeightConstraint/UIHeightConstraint.ts +52 -0
- package/src/core/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.Internal.ts +13 -0
- package/src/core/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.ts +139 -0
- package/src/core/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.Internal.ts +16 -0
- package/src/core/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.ts +189 -0
- package/{dist/constraints/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.Internal.d.ts → src/core/constraints/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.Internal.ts} +3 -2
- package/src/core/constraints/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.ts +68 -0
- package/{dist/constraints/UISingleParameterConstraint/UISingleParameterConstraint.Internal.d.ts → src/core/constraints/UISingleParameterConstraint/UISingleParameterConstraint.Internal.ts} +9 -8
- package/src/core/constraints/UISingleParameterConstraint/UISingleParameterConstraint.ts +94 -0
- package/src/core/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.Internal.ts +13 -0
- package/src/core/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.ts +135 -0
- package/src/core/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.Internal.ts +16 -0
- package/src/core/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.ts +189 -0
- package/{dist/constraints/UIVerticalProportionConstraint/UIVerticalProportionConstraint.Internal.d.ts → src/core/constraints/UIVerticalProportionConstraint/UIVerticalProportionConstraint.Internal.ts} +3 -2
- package/src/core/constraints/UIVerticalProportionConstraint/UIVerticalProportionConstraint.ts +68 -0
- package/{dist/constraints/UIWidthConstraint/UIWidthConstraint.Internal.d.ts → src/core/constraints/UIWidthConstraint/UIWidthConstraint.Internal.ts} +3 -2
- package/src/core/constraints/UIWidthConstraint/UIWidthConstraint.ts +52 -0
- package/src/core/constraints/builders/UIConstraint2DBuilder.Internal.ts +84 -0
- package/src/core/constraints/builders/UIConstraint2DBuilder.ts +168 -0
- package/src/core/constraints/builders/UICoverConstraintBuilder.Internal.ts +15 -0
- package/src/core/constraints/builders/UICoverConstraintBuilder.ts +84 -0
- package/src/core/constraints/builders/UIFitConstraintBuilder.Internal.ts +15 -0
- package/src/core/constraints/builders/UIFitConstraintBuilder.ts +84 -0
- package/src/core/elements/UIAnchor/UIAnchor.Internal.ts +13 -0
- package/src/core/elements/UIAnchor/UIAnchor.ts +70 -0
- package/src/core/elements/UIAnimatedImage/UIAnimatedImage.Internal.ts +30 -0
- package/src/core/elements/UIAnimatedImage/UIAnimatedImage.ts +355 -0
- package/src/core/elements/UIDummy/UIDummy.Internal.ts +33 -0
- package/src/core/elements/UIDummy/UIDummy.ts +244 -0
- package/src/core/elements/UIElement/UIElement.Internal.ts +13 -0
- package/src/core/elements/UIElement/UIElement.ts +127 -0
- package/{dist/elements/UIGraphics/UIGraphics.Internal.d.ts → src/core/elements/UIGraphics/UIGraphics.Internal.ts} +7 -5
- package/src/core/elements/UIGraphics/UIGraphics.ts +168 -0
- package/{dist/elements/UIImage/UIImage.Internal.d.ts → src/core/elements/UIImage/UIImage.Internal.ts} +3 -2
- package/src/core/elements/UIImage/UIImage.ts +138 -0
- package/src/core/elements/UINineSlice/UINineSlice.Internal.ts +26 -0
- package/src/core/elements/UINineSlice/UINineSlice.ts +296 -0
- package/src/core/elements/UIProgress/UIProgress.Internal.ts +24 -0
- package/src/core/elements/UIProgress/UIProgress.ts +259 -0
- package/src/core/elements/UIScene/UIScene.Internal.ts +46 -0
- package/src/core/elements/UIScene/UIScene.ts +259 -0
- package/{dist/elements/UIText/UIText.Interfaces.d.ts → src/core/elements/UIText/UIText.Interfaces.ts} +21 -16
- package/src/core/elements/UIText/UIText.Internal.ts +29 -0
- package/src/core/elements/UIText/UIText.Measuring.ts +183 -0
- package/src/core/elements/UIText/UIText.Rendering.ts +83 -0
- package/src/core/elements/UIText/UIText.ts +376 -0
- package/{dist/index.d.ts → src/core/index.ts} +2 -1
- package/{dist/layers/UIFullscreenLayer/UIFullscreenLayer.Internal.d.ts → src/core/layers/UIFullscreenLayer/UIFullscreenLayer.Internal.ts} +14 -11
- package/src/core/layers/UIFullscreenLayer/UIFullscreenLayer.ts +233 -0
- package/{dist/layers/UILayer/UILayer.Internal.d.ts → src/core/layers/UILayer/UILayer.Internal.ts} +15 -11
- package/src/core/layers/UILayer/UILayer.ts +156 -0
- package/src/core/miscellaneous/UIExpression.ts +142 -0
- package/src/core/miscellaneous/UIMode.ts +29 -0
- package/src/core/miscellaneous/UIOrientation.ts +18 -0
- package/src/core/miscellaneous/UIPriority.ts +63 -0
- package/src/core/miscellaneous/UIRelation.ts +39 -0
- package/src/core/miscellaneous/UITransparencyMode.ts +9 -0
- package/src/core/miscellaneous/area/UIArea.ts +5 -0
- package/src/core/miscellaneous/area/UIAreaCircle.ts +32 -0
- package/src/core/miscellaneous/area/UIAreaPolygon.ts +50 -0
- package/src/core/miscellaneous/area/UIAreaRectangle.ts +38 -0
- package/src/core/miscellaneous/area/UIAreaRoundedRectangle.ts +78 -0
- package/src/core/miscellaneous/asserts.ts +187 -0
- package/src/core/miscellaneous/canvas.ts +73 -0
- package/src/core/miscellaneous/color/UIColor.Internal.ts +89 -0
- package/src/core/miscellaneous/color/UIColor.ts +844 -0
- package/src/core/miscellaneous/computeTransform.ts +127 -0
- package/src/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.Internal.ts +235 -0
- package/src/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.ts +524 -0
- package/{dist/miscellaneous/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.Internal.d.ts → src/core/miscellaneous/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.Internal.ts} +10 -8
- package/src/core/miscellaneous/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.ts +448 -0
- package/src/core/miscellaneous/generic-plane/shared.ts +323 -0
- package/src/core/miscellaneous/insets/UIInsets.Internal.ts +9 -0
- package/src/core/miscellaneous/insets/UIInsets.ts +248 -0
- package/src/core/miscellaneous/mask-function/UIProgressMaskFunction.ts +24 -0
- package/src/core/miscellaneous/mask-function/UIProgressMaskFunctionCircular.ts +58 -0
- package/src/core/miscellaneous/mask-function/UIProgressMaskFunctionDirectional.ts +52 -0
- package/src/core/miscellaneous/math.ts +16 -0
- package/src/core/miscellaneous/micro/UIMicro.Internal.ts +33 -0
- package/src/core/miscellaneous/micro/UIMicro.ts +222 -0
- package/src/core/miscellaneous/resize-policy/UIResizePolicy.ts +8 -0
- package/src/core/miscellaneous/resize-policy/UIResizePolicyCover.ts +57 -0
- package/src/core/miscellaneous/resize-policy/UIResizePolicyCross.ts +65 -0
- package/src/core/miscellaneous/resize-policy/UIResizePolicyCrossInverted.ts +65 -0
- package/src/core/miscellaneous/resize-policy/UIResizePolicyFit.ts +57 -0
- package/src/core/miscellaneous/resize-policy/UIResizePolicyFixedHeight.ts +65 -0
- package/src/core/miscellaneous/resize-policy/UIResizePolicyFixedWidth.ts +65 -0
- package/src/core/miscellaneous/resize-policy/UIResizePolicyNone.ts +11 -0
- package/src/core/miscellaneous/shared.ts +73 -0
- package/{dist/miscellaneous/text-span/UITextSpan.Internal.d.ts → src/core/miscellaneous/text-span/UITextSpan.Internal.ts} +5 -4
- package/src/core/miscellaneous/text-span/UITextSpan.ts +43 -0
- package/src/core/miscellaneous/text-style/UITextStyle.Internal.ts +52 -0
- package/src/core/miscellaneous/text-style/UITextStyle.ts +479 -0
- package/src/core/miscellaneous/texture/UITextureView.Internal.ts +55 -0
- package/src/core/miscellaneous/texture/UITextureView.ts +308 -0
- package/src/core/miscellaneous/webglCapabilities.ts +129 -0
- package/src/core/shaders/UIImage.glsl +10 -0
- package/src/core/shaders/UINineSlice.glsl +53 -0
- package/src/core/shaders/UIProgress.glsl +15 -0
- package/src/core/shaders/UIProgressMaskFunctionCircular.glsl +13 -0
- package/src/core/shaders/UIProgressMaskFunctionDirectional.glsl +12 -0
- package/src/core/shaders/glsl.d.ts +27 -0
- package/src/core/wrappers/UIInputWrapper/UIInputWrapper.Internal.ts +23 -0
- package/src/core/wrappers/UIInputWrapper/UIInputWrapper.ts +124 -0
- package/src/core/wrappers/UISceneWrapper/UISceneWrapper.Internal.ts +22 -0
- package/src/core/wrappers/UISceneWrapper/UISceneWrapper.ts +101 -0
- package/src/core/wrappers/UISolverWrapper/UISolverWrapper.Internal.ts +58 -0
- package/src/core/wrappers/UISolverWrapper/UISolverWrapper.ts +605 -0
- package/src/particles/behaviorModules/UIBehaviorDirectionalGravity.ts +70 -0
- package/src/particles/behaviorModules/UIBehaviorModule.ts +20 -0
- package/src/particles/behaviorModules/UIBehaviorPointGravity.ts +173 -0
- package/src/particles/behaviorModules/UIBehaviorScaleOverLife.ts +104 -0
- package/src/particles/behaviorModules/UIBehaviorTorqueDamping.ts +75 -0
- package/src/particles/behaviorModules/UIBehaviorTorqueNoise.ts +115 -0
- package/src/particles/behaviorModules/UIBehaviorVelocityDamping.ts +77 -0
- package/src/particles/behaviorModules/UIBehaviorVelocityNoise.ts +118 -0
- package/src/particles/elements/UIEmitter.Internal.ts +22 -0
- package/src/particles/elements/UIEmitter.ts +313 -0
- package/src/particles/index.ts +18 -0
- package/src/particles/instancedParticle/UIInstancedParticle.Internal.ts +263 -0
- package/src/particles/instancedParticle/UIInstancedParticle.ts +138 -0
- package/src/particles/miscellaneous/miscellaneous.ts +115 -0
- package/src/particles/renderingModules/UIRenderingColorOverLife.ts +39 -0
- package/src/particles/renderingModules/UIRenderingColorOverVelocity.ts +49 -0
- package/src/particles/renderingModules/UIRenderingModule.ts +17 -0
- package/src/particles/renderingModules/UIRenderingTexture.ts +30 -0
- package/src/particles/shaders/UIRenderingColorOverLife.glsl +4 -0
- package/src/particles/shaders/UIRenderingColorOverVelocity.glsl +6 -0
- package/src/particles/shaders/UIRenderingTexture.glsl +4 -0
- package/src/particles/spawnModules/UISpawnModule.ts +22 -0
- package/src/particles/spawnModules/UISpawnOffset.ts +62 -0
- package/src/particles/spawnModules/UISpawnRandomLifetime.ts +68 -0
- package/src/particles/spawnModules/UISpawnRandomRotation.ts +60 -0
- package/src/particles/spawnModules/UISpawnRandomScale.ts +81 -0
- package/src/particles/spawnModules/UISpawnRandomTorque.ts +62 -0
- package/src/particles/spawnModules/UISpawnRandomVelocity.ts +92 -0
- package/src/particles/spawnModules/UISpawnRectangle.ts +81 -0
- package/tsconfig.json +29 -0
- package/dist/constraints/UIAspectConstraint/UIAspectConstraint.d.ts +0 -22
- package/dist/constraints/UIConstraint.d.ts +0 -12
- package/dist/constraints/UICustomConstraint.d.ts +0 -28
- package/dist/constraints/UIHeightConstraint/UIHeightConstraint.d.ts +0 -20
- package/dist/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.Internal.d.ts +0 -11
- package/dist/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.d.ts +0 -36
- package/dist/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.Internal.d.ts +0 -14
- package/dist/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.d.ts +0 -44
- package/dist/constraints/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.d.ts +0 -22
- package/dist/constraints/UISingleParameterConstraint/UISingleParameterConstraint.d.ts +0 -43
- package/dist/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.Internal.d.ts +0 -11
- package/dist/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.d.ts +0 -32
- package/dist/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.Internal.d.ts +0 -14
- package/dist/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.d.ts +0 -44
- package/dist/constraints/UIVerticalProportionConstraint/UIVerticalProportionConstraint.d.ts +0 -22
- package/dist/constraints/UIWidthConstraint/UIWidthConstraint.d.ts +0 -20
- package/dist/constraints/builders/UIConstraint2DBuilder.Internal.d.ts +0 -64
- package/dist/constraints/builders/UIConstraint2DBuilder.d.ts +0 -46
- package/dist/constraints/builders/UICoverConstraintBuilder.Internal.d.ts +0 -13
- package/dist/constraints/builders/UICoverConstraintBuilder.d.ts +0 -29
- package/dist/constraints/builders/UIFitConstraintBuilder.Internal.d.ts +0 -13
- package/dist/constraints/builders/UIFitConstraintBuilder.d.ts +0 -29
- package/dist/elements/UIAnchor/UIAnchor.Internal.d.ts +0 -9
- package/dist/elements/UIAnchor/UIAnchor.d.ts +0 -32
- package/dist/elements/UIAnimatedImage/UIAnimatedImage.Internal.d.ts +0 -27
- package/dist/elements/UIAnimatedImage/UIAnimatedImage.d.ts +0 -77
- package/dist/elements/UIElement/UIElement.Internal.d.ts +0 -11
- package/dist/elements/UIElement/UIElement.d.ts +0 -38
- package/dist/elements/UIGraphics/UIGraphics.d.ts +0 -51
- package/dist/elements/UIImage/UIImage.d.ts +0 -32
- package/dist/elements/UIInputDummy/UIInputDummy.Internal.d.ts +0 -30
- package/dist/elements/UIInputDummy/UIInputDummy.d.ts +0 -82
- package/dist/elements/UINineSlice/UINineSlice.Internal.d.ts +0 -23
- package/dist/elements/UINineSlice/UINineSlice.d.ts +0 -60
- package/dist/elements/UIProgress/UIProgress.Internal.d.ts +0 -14
- package/dist/elements/UIProgress/UIProgress.d.ts +0 -45
- package/dist/elements/UIScene/UIScene.Internal.d.ts +0 -43
- package/dist/elements/UIScene/UIScene.d.ts +0 -59
- package/dist/elements/UIText/UIText.Internal.d.ts +0 -26
- package/dist/elements/UIText/UIText.Measuring.d.ts +0 -50
- package/dist/elements/UIText/UIText.Rendering.d.ts +0 -20
- package/dist/elements/UIText/UIText.d.ts +0 -71
- package/dist/index.js +0 -9236
- package/dist/index.js.map +0 -1
- package/dist/index.min.js +0 -2
- package/dist/index.min.js.map +0 -1
- package/dist/layers/UIFullscreenLayer/UIFullscreenLayer.d.ts +0 -63
- package/dist/layers/UILayer/UILayer.d.ts +0 -49
- package/dist/miscellaneous/UIExpression.d.ts +0 -69
- package/dist/miscellaneous/UIMode.d.ts +0 -23
- package/dist/miscellaneous/UIOrientation.d.ts +0 -15
- package/dist/miscellaneous/UIPriority.d.ts +0 -32
- package/dist/miscellaneous/UIRelation.d.ts +0 -23
- package/dist/miscellaneous/UITransparencyMode.d.ts +0 -9
- package/dist/miscellaneous/area/UIArea.d.ts +0 -3
- package/dist/miscellaneous/area/UIAreaCircle.d.ts +0 -15
- package/dist/miscellaneous/area/UIAreaPolygon.d.ts +0 -12
- package/dist/miscellaneous/area/UIAreaRectangle.d.ts +0 -17
- package/dist/miscellaneous/area/UIAreaRoundedRectangle.d.ts +0 -21
- package/dist/miscellaneous/asserts.d.ts +0 -43
- package/dist/miscellaneous/canvas.d.ts +0 -31
- package/dist/miscellaneous/color/UIColor.Internal.d.ts +0 -7
- package/dist/miscellaneous/color/UIColor.d.ts +0 -234
- package/dist/miscellaneous/computeTransform.d.ts +0 -18
- package/dist/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.Internal.d.ts +0 -19
- package/dist/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.d.ts +0 -1
- package/dist/miscellaneous/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.d.ts +0 -1
- package/dist/miscellaneous/generic-plane/shared.d.ts +0 -38
- package/dist/miscellaneous/insets/UIInsets.Internal.d.ts +0 -11
- package/dist/miscellaneous/insets/UIInsets.d.ts +0 -48
- package/dist/miscellaneous/mask-function/UIProgressMaskFunction.d.ts +0 -9
- package/dist/miscellaneous/mask-function/UIProgressMaskFunctionCircular.d.ts +0 -21
- package/dist/miscellaneous/mask-function/UIProgressMaskFunctionDirectional.d.ts +0 -16
- package/dist/miscellaneous/math.d.ts +0 -5
- package/dist/miscellaneous/micro/UIMicro.Internal.d.ts +0 -31
- package/dist/miscellaneous/micro/UIMicro.d.ts +0 -59
- package/dist/miscellaneous/resize-policy/UIResizePolicy.d.ts +0 -3
- package/dist/miscellaneous/resize-policy/UIResizePolicyCover.d.ts +0 -22
- package/dist/miscellaneous/resize-policy/UIResizePolicyCross.d.ts +0 -22
- package/dist/miscellaneous/resize-policy/UIResizePolicyCrossInverted.d.ts +0 -22
- package/dist/miscellaneous/resize-policy/UIResizePolicyFit.d.ts +0 -22
- package/dist/miscellaneous/resize-policy/UIResizePolicyFixedHeight.d.ts +0 -22
- package/dist/miscellaneous/resize-policy/UIResizePolicyFixedWidth.d.ts +0 -22
- package/dist/miscellaneous/resize-policy/UIResizePolicyNone.d.ts +0 -5
- package/dist/miscellaneous/shared.d.ts +0 -46
- package/dist/miscellaneous/text-span/UITextSpan.d.ts +0 -14
- package/dist/miscellaneous/text-style/UITextStyle.Internal.d.ts +0 -48
- package/dist/miscellaneous/text-style/UITextStyle.d.ts +0 -85
- package/dist/miscellaneous/texture/UITextureView.Internal.d.ts +0 -49
- package/dist/miscellaneous/texture/UITextureView.d.ts +0 -67
- package/dist/miscellaneous/webglCapabilities.d.ts +0 -2
- package/dist/wrappers/UIInputWrapper/UIInputWrapper.Internal.d.ts +0 -17
- package/dist/wrappers/UIInputWrapper/UIInputWrapper.d.ts +0 -13
- package/dist/wrappers/UISceneWrapper/UISceneWrapper.Internal.d.ts +0 -13
- package/dist/wrappers/UISceneWrapper/UISceneWrapper.d.ts +0 -20
- package/dist/wrappers/UISolverWrapper/UISolverWrapper.Internal.d.ts +0 -49
- package/dist/wrappers/UISolverWrapper/UISolverWrapper.d.ts +0 -215
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import type { FerrsignView1 } from "ferrsign";
|
|
2
|
+
import { Ferrsign1 } from "ferrsign";
|
|
3
|
+
import { MathUtils } from "three";
|
|
4
|
+
import type { UILayer } from "../../layers/UILayer/UILayer";
|
|
5
|
+
import type { UIArea } from "../../miscellaneous/area/UIArea";
|
|
6
|
+
import { UIAreaRectangle } from "../../miscellaneous/area/UIAreaRectangle";
|
|
7
|
+
import { assertValidNumber, assertValidPositiveNumber } from "../../miscellaneous/asserts";
|
|
8
|
+
import type { UIPlaneElement } from "../../miscellaneous/shared";
|
|
9
|
+
import { isUIModeInteractive, UIMode } from "../../miscellaneous/UIMode";
|
|
10
|
+
import { UIPriority } from "../../miscellaneous/UIPriority";
|
|
11
|
+
import type { UIInputWrapperView } from "../../wrappers/UIInputWrapper/UIInputWrapper.Internal";
|
|
12
|
+
import { UIAnchor } from "../UIAnchor/UIAnchor";
|
|
13
|
+
import type { UIDummyOptions, UIInputEventData } from "./UIDummy.Internal";
|
|
14
|
+
import {
|
|
15
|
+
DUMMY_DEFAULT_HEIGHT,
|
|
16
|
+
DUMMY_DEFAULT_MODE,
|
|
17
|
+
DUMMY_DEFAULT_WIDTH,
|
|
18
|
+
DUMMY_DEFAULT_Z_INDEX,
|
|
19
|
+
} from "./UIDummy.Internal";
|
|
20
|
+
|
|
21
|
+
/** Rectangular area with dimensions but no rendering */
|
|
22
|
+
export class UIDummy extends UIAnchor implements UIPlaneElement {
|
|
23
|
+
/** Shape defining interactive region in element-local space (0,0 = bottom-left, 1,1 = top-right) */
|
|
24
|
+
public interactionArea: UIArea;
|
|
25
|
+
|
|
26
|
+
/** Solver variable for width */
|
|
27
|
+
public readonly wVariable: number;
|
|
28
|
+
|
|
29
|
+
/** Solver variable for height */
|
|
30
|
+
public readonly hVariable: number;
|
|
31
|
+
|
|
32
|
+
protected modeInternal: UIMode;
|
|
33
|
+
protected readonly inputWrapper: UIInputWrapperView;
|
|
34
|
+
private readonly catcherHandler: number;
|
|
35
|
+
private wasPointerInside = false;
|
|
36
|
+
|
|
37
|
+
private readonly signalPointerPressedInternal = new Ferrsign1<UIInputEventData>();
|
|
38
|
+
private readonly signalPointerMovedInternal = new Ferrsign1<UIInputEventData>();
|
|
39
|
+
private readonly signalPointerReleasedInternal = new Ferrsign1<UIInputEventData>();
|
|
40
|
+
private readonly signalPointerEnteredInternal = new Ferrsign1<UIInputEventData>();
|
|
41
|
+
private readonly signalPointerLeftInternal = new Ferrsign1<UIInputEventData>();
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Creates a new UIDummy instance.
|
|
45
|
+
*
|
|
46
|
+
* @param layer - Layer containing this element
|
|
47
|
+
* @param options - Configuration options
|
|
48
|
+
*/
|
|
49
|
+
constructor(layer: UILayer, options?: Partial<UIDummyOptions>) {
|
|
50
|
+
const w = options?.width ?? DUMMY_DEFAULT_WIDTH;
|
|
51
|
+
const h = options?.height ?? DUMMY_DEFAULT_HEIGHT;
|
|
52
|
+
|
|
53
|
+
assertValidPositiveNumber(w, "UIDummy.constructor.width");
|
|
54
|
+
assertValidPositiveNumber(h, "UIDummy.constructor.height");
|
|
55
|
+
|
|
56
|
+
super(layer, options);
|
|
57
|
+
|
|
58
|
+
this.interactionArea = options?.interactionArea ?? new UIAreaRectangle(0, 0, 1, 1);
|
|
59
|
+
this.modeInternal = options?.mode ?? DUMMY_DEFAULT_MODE;
|
|
60
|
+
this.inputWrapper = this.layer.inputWrapper;
|
|
61
|
+
|
|
62
|
+
this.wVariable = this.solverWrapper.createVariable(w, UIPriority.P6);
|
|
63
|
+
this.hVariable = this.solverWrapper.createVariable(h, UIPriority.P6);
|
|
64
|
+
|
|
65
|
+
this.catcherHandler = this.inputWrapper.createInputCatcher(
|
|
66
|
+
this.catchPointerDown,
|
|
67
|
+
this.catchPointerMove,
|
|
68
|
+
this.catchPointerUp,
|
|
69
|
+
DUMMY_DEFAULT_Z_INDEX,
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
this.inputWrapper.setActive(this.catcherHandler, isUIModeInteractive(this.modeInternal));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Width in world units */
|
|
76
|
+
public get width(): number {
|
|
77
|
+
return this.solverWrapper.readVariableValue(this.wVariable);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Height in world units */
|
|
81
|
+
public get height(): number {
|
|
82
|
+
return this.solverWrapper.readVariableValue(this.hVariable);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** X coordinate of right edge */
|
|
86
|
+
public get oppositeX(): number {
|
|
87
|
+
return this.x + this.width;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** Y coordinate of top edge */
|
|
91
|
+
public get oppositeY(): number {
|
|
92
|
+
return this.y + this.height;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** X coordinate of horizontal center */
|
|
96
|
+
public get centerX(): number {
|
|
97
|
+
return this.x + this.width / 2;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** Y coordinate of vertical center */
|
|
101
|
+
public get centerY(): number {
|
|
102
|
+
return this.y + this.height / 2;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** Controls visibility and interactivity */
|
|
106
|
+
public get mode(): UIMode {
|
|
107
|
+
return this.modeInternal;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Rendering and input priority. Higher values on top. */
|
|
111
|
+
public get zIndex(): number {
|
|
112
|
+
return this.inputWrapper.getZIndex(this.catcherHandler);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** Signal fired when pointer is pressed */
|
|
116
|
+
public get signalPointerPressed(): FerrsignView1<UIInputEventData> {
|
|
117
|
+
return this.signalPointerPressedInternal;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** Signal fired when pointer is moved */
|
|
121
|
+
public get signalPointerMoved(): FerrsignView1<UIInputEventData> {
|
|
122
|
+
return this.signalPointerMovedInternal;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** Signal fired when pointer is released */
|
|
126
|
+
public get signalPointerReleased(): FerrsignView1<UIInputEventData> {
|
|
127
|
+
return this.signalPointerReleasedInternal;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** Signal fired when pointer enters element */
|
|
131
|
+
public get signalPointerEntered(): FerrsignView1<UIInputEventData> {
|
|
132
|
+
return this.signalPointerEnteredInternal;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** Signal fired when pointer leaves element */
|
|
136
|
+
public get signalPointerLeft(): FerrsignView1<UIInputEventData> {
|
|
137
|
+
return this.signalPointerLeftInternal;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** Width in world units */
|
|
141
|
+
public set width(value: number) {
|
|
142
|
+
assertValidPositiveNumber(value, "UIDummy.width");
|
|
143
|
+
this.solverWrapper.suggestVariableValue(this.wVariable, value);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** Height in world units */
|
|
147
|
+
public set height(value: number) {
|
|
148
|
+
assertValidPositiveNumber(value, "UIDummy.height");
|
|
149
|
+
this.solverWrapper.suggestVariableValue(this.hVariable, value);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** X coordinate of right edge */
|
|
153
|
+
public set oppositeX(value: number) {
|
|
154
|
+
assertValidNumber(value, "UIDummy.oppositeX");
|
|
155
|
+
this.x = value - this.width;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/** Y coordinate of top edge */
|
|
159
|
+
public set oppositeY(value: number) {
|
|
160
|
+
assertValidNumber(value, "UIDummy.oppositeY");
|
|
161
|
+
this.y = value - this.height;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/** X coordinate of horizontal center */
|
|
165
|
+
public set centerX(value: number) {
|
|
166
|
+
assertValidNumber(value, "UIDummy.centerX");
|
|
167
|
+
this.x = value - this.width / 2;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** Y coordinate of vertical center */
|
|
171
|
+
public set centerY(value: number) {
|
|
172
|
+
assertValidNumber(value, "UIDummy.centerY");
|
|
173
|
+
this.y = value - this.height / 2;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/** Controls visibility and interactivity */
|
|
177
|
+
public set mode(value: UIMode) {
|
|
178
|
+
if (this.modeInternal !== value) {
|
|
179
|
+
const newInteractivity = isUIModeInteractive(value);
|
|
180
|
+
this.inputWrapper.setActive(this.catcherHandler, newInteractivity);
|
|
181
|
+
this.modeInternal = value;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** Rendering and input priority. Higher values on top. */
|
|
186
|
+
public set zIndex(value: number) {
|
|
187
|
+
assertValidNumber(value, "UIDummy.zIndex");
|
|
188
|
+
this.inputWrapper.setZIndex(this.catcherHandler, value);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/** Removes element and frees resources */
|
|
192
|
+
public override destroy(): void {
|
|
193
|
+
this.solverWrapper.removeVariable(this.hVariable);
|
|
194
|
+
this.solverWrapper.removeVariable(this.wVariable);
|
|
195
|
+
this.inputWrapper.destroyInputCatcher(this.catcherHandler);
|
|
196
|
+
super.destroy();
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
protected readonly catchPointerDown = (x: number, y: number, identifier: number): boolean => {
|
|
200
|
+
return this.handleInputEvent(x, y, identifier, this.signalPointerPressedInternal);
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
protected readonly catchPointerMove = (x: number, y: number, identifier: number): boolean => {
|
|
204
|
+
return this.handleInputEvent(x, y, identifier, this.signalPointerMovedInternal);
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
protected readonly catchPointerUp = (x: number, y: number, identifier: number): boolean => {
|
|
208
|
+
return this.handleInputEvent(x, y, identifier, this.signalPointerReleasedInternal);
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
protected handleInputEvent(
|
|
212
|
+
x: number,
|
|
213
|
+
y: number,
|
|
214
|
+
identifier: number,
|
|
215
|
+
signal: Ferrsign1<UIInputEventData>,
|
|
216
|
+
): boolean {
|
|
217
|
+
assertValidNumber(x, "UIDummy.handleInputEvent.x");
|
|
218
|
+
assertValidNumber(y, "UIDummy.handleInputEvent.y");
|
|
219
|
+
assertValidNumber(identifier, "UIDummy.handleInputEvent.identifier");
|
|
220
|
+
|
|
221
|
+
const isPointerInside = this.interactionArea.contains(
|
|
222
|
+
MathUtils.mapLinear(x, this.x, this.oppositeX, 0, 1),
|
|
223
|
+
MathUtils.mapLinear(y, this.y, this.oppositeY, 0, 1),
|
|
224
|
+
);
|
|
225
|
+
|
|
226
|
+
if (isPointerInside) {
|
|
227
|
+
signal.emit({ x, y, identifier, element: this });
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
if (this.wasPointerInside && !isPointerInside) {
|
|
231
|
+
this.signalPointerLeftInternal.emit({ x, y, identifier, element: this });
|
|
232
|
+
} else if (!this.wasPointerInside && isPointerInside) {
|
|
233
|
+
this.signalPointerEnteredInternal.emit({
|
|
234
|
+
x,
|
|
235
|
+
y,
|
|
236
|
+
identifier,
|
|
237
|
+
element: this,
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
this.wasPointerInside = isPointerInside;
|
|
242
|
+
return this.modeInternal !== UIMode.INTERACTIVE_TRANSPARENT && isPointerInside;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { UIMicroConfig } from "../../miscellaneous/micro/UIMicro.Internal";
|
|
2
|
+
import { UITransparencyMode } from "../../miscellaneous/UITransparencyMode";
|
|
3
|
+
import type { UIDummyOptions } from "../UIDummy/UIDummy.Internal";
|
|
4
|
+
|
|
5
|
+
/** Configuration options for UIElement */
|
|
6
|
+
export interface UIElementOptions extends UIDummyOptions {
|
|
7
|
+
/** Transforms that don't affect constraints */
|
|
8
|
+
micro: Partial<UIMicroConfig>;
|
|
9
|
+
/** Alpha blending mode */
|
|
10
|
+
transparencyMode: UITransparencyMode;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const ELEMENT_DEFAULT_TRANSPARENCY_MODE = UITransparencyMode.BLEND;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import type { WebGLRenderer } from "three";
|
|
2
|
+
import { Matrix4 } from "three";
|
|
3
|
+
import type { UILayer } from "../../layers/UILayer/UILayer";
|
|
4
|
+
import { computeTransformMatrix } from "../../miscellaneous/computeTransform";
|
|
5
|
+
import type { UIProperty } from "../../miscellaneous/generic-plane/shared";
|
|
6
|
+
import { UIMicro } from "../../miscellaneous/micro/UIMicro";
|
|
7
|
+
import type { UIMode } from "../../miscellaneous/UIMode";
|
|
8
|
+
import { isUIModeVisible } from "../../miscellaneous/UIMode";
|
|
9
|
+
import type { UITransparencyMode } from "../../miscellaneous/UITransparencyMode";
|
|
10
|
+
import type { UISceneWrapperView } from "../../wrappers/UISceneWrapper/UISceneWrapper.Internal";
|
|
11
|
+
import { UIDummy } from "../UIDummy/UIDummy";
|
|
12
|
+
import type { UIElementOptions } from "./UIElement.Internal";
|
|
13
|
+
import { ELEMENT_DEFAULT_TRANSPARENCY_MODE } from "./UIElement.Internal";
|
|
14
|
+
|
|
15
|
+
/** Base class for renderable UI elements */
|
|
16
|
+
export abstract class UIElement extends UIDummy {
|
|
17
|
+
/** Transforms that don't affect constraints */
|
|
18
|
+
public readonly micro: UIMicro;
|
|
19
|
+
|
|
20
|
+
protected readonly sceneWrapper: UISceneWrapperView;
|
|
21
|
+
protected planeHandler: number;
|
|
22
|
+
|
|
23
|
+
private transparencyModeInternal: UITransparencyMode;
|
|
24
|
+
private transparencyModeDirty = false;
|
|
25
|
+
private visibilityDirty = false;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Creates a new UIElement instance.
|
|
29
|
+
*
|
|
30
|
+
* @param layer - Layer containing this element
|
|
31
|
+
* @param source - GLSL shader source code
|
|
32
|
+
* @param properties - Shader uniform properties
|
|
33
|
+
* @param options - Configuration options
|
|
34
|
+
*/
|
|
35
|
+
constructor(
|
|
36
|
+
layer: UILayer,
|
|
37
|
+
source: string,
|
|
38
|
+
properties: Record<string, UIProperty>,
|
|
39
|
+
options?: Partial<UIElementOptions>,
|
|
40
|
+
) {
|
|
41
|
+
super(layer, options);
|
|
42
|
+
this.micro = new UIMicro(options?.micro);
|
|
43
|
+
|
|
44
|
+
this.transparencyModeInternal = options?.transparencyMode ?? ELEMENT_DEFAULT_TRANSPARENCY_MODE;
|
|
45
|
+
|
|
46
|
+
this.sceneWrapper = this.layer.sceneWrapper;
|
|
47
|
+
this.planeHandler = this.sceneWrapper.createPlane(
|
|
48
|
+
source,
|
|
49
|
+
properties,
|
|
50
|
+
new Matrix4().identity(),
|
|
51
|
+
isUIModeVisible(options?.mode ?? this.mode),
|
|
52
|
+
this.transparencyModeInternal,
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
this.layer.signalRendering.on(this.handleWillRender);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Alpha blending mode */
|
|
59
|
+
public get transparencyMode(): UITransparencyMode {
|
|
60
|
+
return this.transparencyModeInternal;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Alpha blending mode */
|
|
64
|
+
public set transparencyMode(value: UITransparencyMode) {
|
|
65
|
+
if (this.transparencyModeInternal !== value) {
|
|
66
|
+
this.transparencyModeInternal = value;
|
|
67
|
+
this.transparencyModeDirty = true;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
public override set mode(value: UIMode) {
|
|
72
|
+
if (this.modeInternal !== value) {
|
|
73
|
+
this.visibilityDirty = isUIModeVisible(this.modeInternal) !== isUIModeVisible(value);
|
|
74
|
+
super.mode = value;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Removes element and frees resources */
|
|
79
|
+
public override destroy(): void {
|
|
80
|
+
this.layer.signalRendering.off(this.handleWillRender);
|
|
81
|
+
this.sceneWrapper.destroyPlane(this.planeHandler);
|
|
82
|
+
super.destroy();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
protected setPlaneTransform(): void {
|
|
86
|
+
if (this.micro.dirty || this.inputWrapper.dirty || this.solverWrapper.dirty) {
|
|
87
|
+
this.sceneWrapper.setTransform(
|
|
88
|
+
this.planeHandler,
|
|
89
|
+
computeTransformMatrix(
|
|
90
|
+
this.x,
|
|
91
|
+
this.y,
|
|
92
|
+
this.width,
|
|
93
|
+
this.height,
|
|
94
|
+
this.zIndex,
|
|
95
|
+
this.micro.x,
|
|
96
|
+
this.micro.y,
|
|
97
|
+
this.micro.anchorX,
|
|
98
|
+
this.micro.anchorY,
|
|
99
|
+
this.micro.scaleX,
|
|
100
|
+
this.micro.scaleY,
|
|
101
|
+
this.micro.rotation,
|
|
102
|
+
this.micro.anchorMode,
|
|
103
|
+
),
|
|
104
|
+
);
|
|
105
|
+
this.micro.setDirtyFalse();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- Required by UILayer event interface but not used in base implementation
|
|
110
|
+
protected onWillRender(renderer: WebGLRenderer, deltaTime: number): void {
|
|
111
|
+
if (this.transparencyModeDirty) {
|
|
112
|
+
this.sceneWrapper.setTransparency(this.planeHandler, this.transparencyModeInternal);
|
|
113
|
+
this.transparencyModeDirty = false;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (this.visibilityDirty) {
|
|
117
|
+
this.sceneWrapper.setVisibility(this.planeHandler, isUIModeVisible(this.modeInternal));
|
|
118
|
+
this.visibilityDirty = false;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
this.setPlaneTransform();
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
private readonly handleWillRender = (renderer: WebGLRenderer, deltaTime: number): void => {
|
|
125
|
+
this.onWillRender(renderer, deltaTime);
|
|
126
|
+
};
|
|
127
|
+
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { UIColor } from "../../miscellaneous/color/UIColor";
|
|
2
2
|
import type { UIColorConfig } from "../../miscellaneous/color/UIColor.Internal";
|
|
3
3
|
import type { UIElementOptions } from "../UIElement/UIElement.Internal";
|
|
4
|
+
|
|
4
5
|
/** Configuration options for UIGraphics */
|
|
5
6
|
export interface UIGraphicsOptions extends UIElementOptions {
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
/** Multiplicative tint */
|
|
8
|
+
color: UIColorConfig;
|
|
8
9
|
}
|
|
9
|
-
|
|
10
|
-
export
|
|
11
|
-
export
|
|
10
|
+
|
|
11
|
+
export const GRAPHICS_DEFAULT_WIDTH = 2;
|
|
12
|
+
export const GRAPHICS_DEFAULT_HEIGHT = 2;
|
|
13
|
+
export const GRAPHICS_TEMP_COLOR = new UIColor();
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import type { CanvasTexture, WebGLRenderer } from "three";
|
|
2
|
+
import { Matrix3 } from "three";
|
|
3
|
+
import type { UILayer } from "../../layers/UILayer/UILayer";
|
|
4
|
+
import type { UICanvas, UICanvasRenderingContext2D } from "../../miscellaneous/canvas";
|
|
5
|
+
import { createCanvas, createCanvasTexture } from "../../miscellaneous/canvas";
|
|
6
|
+
import { UIColor } from "../../miscellaneous/color/UIColor";
|
|
7
|
+
import type { UIColorConfig } from "../../miscellaneous/color/UIColor.Internal";
|
|
8
|
+
import source from "../../shaders/UIImage.glsl";
|
|
9
|
+
import { UIElement } from "../UIElement/UIElement";
|
|
10
|
+
import type { UIGraphicsOptions } from "./UIGraphics.Internal";
|
|
11
|
+
import {
|
|
12
|
+
GRAPHICS_DEFAULT_HEIGHT,
|
|
13
|
+
GRAPHICS_DEFAULT_WIDTH,
|
|
14
|
+
GRAPHICS_TEMP_COLOR,
|
|
15
|
+
} from "./UIGraphics.Internal";
|
|
16
|
+
|
|
17
|
+
/** Canvas-based 2D drawing element */
|
|
18
|
+
export class UIGraphics extends UIElement {
|
|
19
|
+
private readonly colorInternal: UIColor;
|
|
20
|
+
private readonly canvas: UICanvas;
|
|
21
|
+
private readonly context: UICanvasRenderingContext2D;
|
|
22
|
+
private readonly texture: CanvasTexture;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Creates a new UIGraphics instance.
|
|
26
|
+
*
|
|
27
|
+
* @param layer - Layer containing this element
|
|
28
|
+
* @param options - Configuration options
|
|
29
|
+
*/
|
|
30
|
+
constructor(layer: UILayer, options?: Partial<UIGraphicsOptions>) {
|
|
31
|
+
const w = options?.width ?? GRAPHICS_DEFAULT_WIDTH;
|
|
32
|
+
const h = options?.height ?? GRAPHICS_DEFAULT_HEIGHT;
|
|
33
|
+
const color = new UIColor(options?.color);
|
|
34
|
+
|
|
35
|
+
const canvas = createCanvas(w, h);
|
|
36
|
+
const context = canvas.getContext("2d") as UICanvasRenderingContext2D | null;
|
|
37
|
+
|
|
38
|
+
if (!context) {
|
|
39
|
+
throw new Error("UIGraphics.constructor: failed to get 2D context from canvas");
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const texture = createCanvasTexture(canvas);
|
|
43
|
+
texture.needsUpdate = true;
|
|
44
|
+
|
|
45
|
+
super(
|
|
46
|
+
layer,
|
|
47
|
+
source,
|
|
48
|
+
{
|
|
49
|
+
texture: texture,
|
|
50
|
+
textureTransform: new Matrix3(),
|
|
51
|
+
color,
|
|
52
|
+
},
|
|
53
|
+
options,
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
this.canvas = canvas;
|
|
57
|
+
this.context = context;
|
|
58
|
+
this.texture = texture;
|
|
59
|
+
this.colorInternal = color;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Multiplicative tint. Alpha channel controls opacity. */
|
|
63
|
+
public get color(): UIColor {
|
|
64
|
+
return this.colorInternal;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Multiplicative tint. Alpha channel controls opacity. */
|
|
68
|
+
public set color(value: UIColorConfig) {
|
|
69
|
+
this.colorInternal.set(value);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Clears canvas. Optionally fills with color.
|
|
74
|
+
*
|
|
75
|
+
* @param color - Fill color after clearing
|
|
76
|
+
*/
|
|
77
|
+
public clear(color?: UIColorConfig): this {
|
|
78
|
+
this.context.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
|
79
|
+
if (color !== undefined) {
|
|
80
|
+
this.context.fillStyle = GRAPHICS_TEMP_COLOR.set(color).toCSSColor();
|
|
81
|
+
this.context.fillRect(0, 0, this.canvas.width, this.canvas.height);
|
|
82
|
+
}
|
|
83
|
+
this.texture.needsUpdate = true;
|
|
84
|
+
return this;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** Draws filled rectangle */
|
|
88
|
+
public drawRect(x: number, y: number, width: number, height: number, color: UIColorConfig): this {
|
|
89
|
+
this.context.fillStyle = GRAPHICS_TEMP_COLOR.set(color).toCSSColor();
|
|
90
|
+
this.context.fillRect(x, y, width, height);
|
|
91
|
+
this.texture.needsUpdate = true;
|
|
92
|
+
return this;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** Draws filled circle */
|
|
96
|
+
public drawCircle(x: number, y: number, radius: number, color: UIColorConfig): this {
|
|
97
|
+
this.context.fillStyle = GRAPHICS_TEMP_COLOR.set(color).toCSSColor();
|
|
98
|
+
this.context.beginPath();
|
|
99
|
+
this.context.arc(x, y, radius, 0, Math.PI * 2);
|
|
100
|
+
this.context.fill();
|
|
101
|
+
this.texture.needsUpdate = true;
|
|
102
|
+
return this;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Draws filled arc.
|
|
107
|
+
*
|
|
108
|
+
* @param startAngle - Start angle in radians
|
|
109
|
+
* @param endAngle - End angle in radians
|
|
110
|
+
*/
|
|
111
|
+
public drawArc(
|
|
112
|
+
x: number,
|
|
113
|
+
y: number,
|
|
114
|
+
radius: number,
|
|
115
|
+
startAngle: number,
|
|
116
|
+
endAngle: number,
|
|
117
|
+
color: UIColorConfig,
|
|
118
|
+
): this {
|
|
119
|
+
this.context.fillStyle = GRAPHICS_TEMP_COLOR.set(color).toCSSColor();
|
|
120
|
+
this.context.beginPath();
|
|
121
|
+
this.context.arc(x, y, radius, startAngle, endAngle);
|
|
122
|
+
this.context.fill();
|
|
123
|
+
this.texture.needsUpdate = true;
|
|
124
|
+
return this;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Draws connected line segments.
|
|
129
|
+
*
|
|
130
|
+
* @param points - Array of [x, y] pairs
|
|
131
|
+
* @param lineWidth - Line width in pixels
|
|
132
|
+
*/
|
|
133
|
+
public drawPolyline(points: [number, number][], color: UIColor, lineWidth = 1): this {
|
|
134
|
+
if (points.length < 2) {
|
|
135
|
+
return this;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
this.context.strokeStyle = GRAPHICS_TEMP_COLOR.set(color).toCSSColor();
|
|
139
|
+
this.context.lineWidth = lineWidth;
|
|
140
|
+
this.context.beginPath();
|
|
141
|
+
this.context.moveTo(points[0][0], points[0][1]);
|
|
142
|
+
|
|
143
|
+
for (let i = 1; i < points.length; i++) {
|
|
144
|
+
this.context.lineTo(points[i][0], points[i][1]);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
this.context.stroke();
|
|
148
|
+
this.texture.needsUpdate = true;
|
|
149
|
+
return this;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** Removes element and frees resources */
|
|
153
|
+
public override destroy(): void {
|
|
154
|
+
this.texture.dispose();
|
|
155
|
+
super.destroy();
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
protected override onWillRender(renderer: WebGLRenderer, deltaTime: number): void {
|
|
159
|
+
if (this.colorInternal.dirty) {
|
|
160
|
+
this.sceneWrapper.setProperties(this.planeHandler, {
|
|
161
|
+
color: this.colorInternal,
|
|
162
|
+
});
|
|
163
|
+
this.colorInternal.setDirtyFalse();
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
super.onWillRender(renderer, deltaTime);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { UIColorConfig } from "../../miscellaneous/color/UIColor.Internal";
|
|
2
2
|
import type { UIElementOptions } from "../UIElement/UIElement.Internal";
|
|
3
|
+
|
|
3
4
|
/** Configuration options for UIImage */
|
|
4
5
|
export interface UIImageOptions extends UIElementOptions {
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
/** Multiplicative tint */
|
|
7
|
+
color: UIColorConfig;
|
|
7
8
|
}
|