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,323 @@
|
|
|
1
|
+
import type { IUniform, ShaderMaterial } from "three";
|
|
2
|
+
import { Matrix3, Matrix4, Texture, Vector2, Vector3, Vector4 } from "three";
|
|
3
|
+
import type { UITransparencyMode } from "../UITransparencyMode";
|
|
4
|
+
import { UIColor } from "../color/UIColor";
|
|
5
|
+
import { checkSRGBSupport } from "../webglCapabilities";
|
|
6
|
+
|
|
7
|
+
export type UIProperty =
|
|
8
|
+
| Texture
|
|
9
|
+
| UIColor
|
|
10
|
+
| Vector2
|
|
11
|
+
| Vector3
|
|
12
|
+
| Vector4
|
|
13
|
+
| Matrix3
|
|
14
|
+
| Matrix4
|
|
15
|
+
| number;
|
|
16
|
+
|
|
17
|
+
export type UIPropertyName =
|
|
18
|
+
| "Texture"
|
|
19
|
+
| "UIColor"
|
|
20
|
+
| "Vector2"
|
|
21
|
+
| "Vector3"
|
|
22
|
+
| "Vector4"
|
|
23
|
+
| "Matrix3"
|
|
24
|
+
| "Matrix4"
|
|
25
|
+
| "number";
|
|
26
|
+
|
|
27
|
+
export type UIPropertyConstructor =
|
|
28
|
+
| typeof Texture
|
|
29
|
+
| typeof UIColor
|
|
30
|
+
| typeof Vector2
|
|
31
|
+
| typeof Vector3
|
|
32
|
+
| typeof Vector4
|
|
33
|
+
| typeof Matrix3
|
|
34
|
+
| typeof Matrix4
|
|
35
|
+
| NumberConstructor;
|
|
36
|
+
|
|
37
|
+
export type UIPropertyCopyTo = UIColor | Vector2 | Vector3 | Vector4 | Matrix3 | Matrix4;
|
|
38
|
+
|
|
39
|
+
export type UIPropertyCopyFrom = UIColor & Vector2 & Vector3 & Vector4 & Matrix3 & Matrix4;
|
|
40
|
+
|
|
41
|
+
export interface GLTypeInfo {
|
|
42
|
+
glslTypeName: string;
|
|
43
|
+
bufferSize: number;
|
|
44
|
+
instantiable: boolean;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface GLProperty {
|
|
48
|
+
value: UIProperty;
|
|
49
|
+
glslTypeInfo: GLTypeInfo;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface PlaneData {
|
|
53
|
+
source: string;
|
|
54
|
+
properties: Record<string, GLProperty>;
|
|
55
|
+
transform: Matrix4;
|
|
56
|
+
visibility: boolean;
|
|
57
|
+
transparency: UITransparencyMode;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export const DEFAULT_ALPHA_TEST = 0.5;
|
|
61
|
+
|
|
62
|
+
const GLSL_TYPE_INFO_FLOAT: GLTypeInfo = Object.freeze({
|
|
63
|
+
glslTypeName: "float",
|
|
64
|
+
bufferSize: 1,
|
|
65
|
+
instantiable: true,
|
|
66
|
+
} as const);
|
|
67
|
+
|
|
68
|
+
const GLSL_TYPE_INFO_SAMPLER2D: GLTypeInfo = Object.freeze({
|
|
69
|
+
glslTypeName: "sampler2D",
|
|
70
|
+
bufferSize: -1,
|
|
71
|
+
instantiable: false,
|
|
72
|
+
} as const);
|
|
73
|
+
|
|
74
|
+
const GLSL_TYPE_INFO_VEC2: GLTypeInfo = Object.freeze({
|
|
75
|
+
glslTypeName: "vec2",
|
|
76
|
+
bufferSize: 2,
|
|
77
|
+
instantiable: true,
|
|
78
|
+
} as const);
|
|
79
|
+
|
|
80
|
+
const GLSL_TYPE_INFO_VEC3: GLTypeInfo = Object.freeze({
|
|
81
|
+
glslTypeName: "vec3",
|
|
82
|
+
bufferSize: 3,
|
|
83
|
+
instantiable: true,
|
|
84
|
+
} as const);
|
|
85
|
+
|
|
86
|
+
const GLSL_TYPE_INFO_VEC4: GLTypeInfo = Object.freeze({
|
|
87
|
+
glslTypeName: "vec4",
|
|
88
|
+
bufferSize: 4,
|
|
89
|
+
instantiable: true,
|
|
90
|
+
} as const);
|
|
91
|
+
|
|
92
|
+
const GLSL_TYPE_INFO_MAT3: GLTypeInfo = Object.freeze({
|
|
93
|
+
glslTypeName: "mat3",
|
|
94
|
+
bufferSize: 9,
|
|
95
|
+
instantiable: true,
|
|
96
|
+
} as const);
|
|
97
|
+
|
|
98
|
+
const GLSL_TYPE_INFO_MAT4: GLTypeInfo = Object.freeze({
|
|
99
|
+
glslTypeName: "mat4",
|
|
100
|
+
bufferSize: 16,
|
|
101
|
+
instantiable: true,
|
|
102
|
+
} as const);
|
|
103
|
+
|
|
104
|
+
export function resolveGLSLTypeInfo(
|
|
105
|
+
value: UIProperty | UIPropertyName | UIPropertyConstructor,
|
|
106
|
+
): GLTypeInfo {
|
|
107
|
+
if (typeof value === "string") {
|
|
108
|
+
switch (value) {
|
|
109
|
+
case "number":
|
|
110
|
+
return GLSL_TYPE_INFO_FLOAT;
|
|
111
|
+
case "Texture":
|
|
112
|
+
return GLSL_TYPE_INFO_SAMPLER2D;
|
|
113
|
+
case "UIColor":
|
|
114
|
+
return GLSL_TYPE_INFO_VEC4;
|
|
115
|
+
case "Vector2":
|
|
116
|
+
return GLSL_TYPE_INFO_VEC2;
|
|
117
|
+
case "Vector3":
|
|
118
|
+
return GLSL_TYPE_INFO_VEC3;
|
|
119
|
+
case "Vector4":
|
|
120
|
+
return GLSL_TYPE_INFO_VEC4;
|
|
121
|
+
case "Matrix3":
|
|
122
|
+
return GLSL_TYPE_INFO_MAT3;
|
|
123
|
+
case "Matrix4":
|
|
124
|
+
return GLSL_TYPE_INFO_MAT4;
|
|
125
|
+
default:
|
|
126
|
+
throw new Error(`resolveGLSLTypeInfo.value: unsupported property type name`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (typeof value === "function") {
|
|
130
|
+
if (value === Number) {
|
|
131
|
+
return GLSL_TYPE_INFO_FLOAT;
|
|
132
|
+
}
|
|
133
|
+
if (value === Texture) {
|
|
134
|
+
return GLSL_TYPE_INFO_SAMPLER2D;
|
|
135
|
+
}
|
|
136
|
+
if (value === UIColor) {
|
|
137
|
+
return GLSL_TYPE_INFO_VEC4;
|
|
138
|
+
}
|
|
139
|
+
if (value === Vector2) {
|
|
140
|
+
return GLSL_TYPE_INFO_VEC2;
|
|
141
|
+
}
|
|
142
|
+
if (value === Vector3) {
|
|
143
|
+
return GLSL_TYPE_INFO_VEC3;
|
|
144
|
+
}
|
|
145
|
+
if (value === Vector4) {
|
|
146
|
+
return GLSL_TYPE_INFO_VEC4;
|
|
147
|
+
}
|
|
148
|
+
if (value === Matrix3) {
|
|
149
|
+
return GLSL_TYPE_INFO_MAT3;
|
|
150
|
+
}
|
|
151
|
+
if (value === Matrix4) {
|
|
152
|
+
return GLSL_TYPE_INFO_MAT4;
|
|
153
|
+
}
|
|
154
|
+
throw new Error(`resolveGLSLTypeInfo.value: unsupported property type constructor`);
|
|
155
|
+
}
|
|
156
|
+
if (typeof value === "number") {
|
|
157
|
+
return GLSL_TYPE_INFO_FLOAT;
|
|
158
|
+
}
|
|
159
|
+
if (value instanceof Texture) {
|
|
160
|
+
return GLSL_TYPE_INFO_SAMPLER2D;
|
|
161
|
+
}
|
|
162
|
+
if (value instanceof UIColor) {
|
|
163
|
+
return GLSL_TYPE_INFO_VEC4;
|
|
164
|
+
}
|
|
165
|
+
if (value instanceof Vector2) {
|
|
166
|
+
return GLSL_TYPE_INFO_VEC2;
|
|
167
|
+
}
|
|
168
|
+
if (value instanceof Vector3) {
|
|
169
|
+
return GLSL_TYPE_INFO_VEC3;
|
|
170
|
+
}
|
|
171
|
+
if (value instanceof Vector4) {
|
|
172
|
+
return GLSL_TYPE_INFO_VEC4;
|
|
173
|
+
}
|
|
174
|
+
if (value instanceof Matrix3) {
|
|
175
|
+
return GLSL_TYPE_INFO_MAT3;
|
|
176
|
+
}
|
|
177
|
+
if (value instanceof Matrix4) {
|
|
178
|
+
return GLSL_TYPE_INFO_MAT4;
|
|
179
|
+
}
|
|
180
|
+
throw new Error(`resolveGLSLTypeInfo.value: unsupported property type`);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export function resolvePropertyUniform(
|
|
184
|
+
name: string,
|
|
185
|
+
material: ShaderMaterial,
|
|
186
|
+
): IUniform<UIProperty> {
|
|
187
|
+
const uniform = material.uniforms[`p_${name}`] as IUniform<UIProperty> | undefined;
|
|
188
|
+
if (uniform === undefined) {
|
|
189
|
+
throw new Error(`resolvePropertyUniform.name: unknown uniform`);
|
|
190
|
+
}
|
|
191
|
+
return uniform;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export function arePropertiesPartiallyCompatible(
|
|
195
|
+
full: Readonly<Record<string, Readonly<GLProperty>>>,
|
|
196
|
+
partial: Readonly<Record<string, Readonly<GLProperty>>>,
|
|
197
|
+
): boolean {
|
|
198
|
+
for (const key in partial) {
|
|
199
|
+
if (!(key in full)) {
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const infoFull = full[key].glslTypeInfo;
|
|
204
|
+
const infoPartial = partial[key].glslTypeInfo;
|
|
205
|
+
|
|
206
|
+
if (infoFull.glslTypeName !== infoPartial.glslTypeName) {
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// Non-instantiable (textures) must match by reference
|
|
211
|
+
if (!infoFull.instantiable && full[key].value !== partial[key].value) {
|
|
212
|
+
return false;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
return true;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export function convertUIPropertiesToGLProperties(
|
|
220
|
+
uiProperties: Record<string, UIProperty>,
|
|
221
|
+
): Record<string, GLProperty> {
|
|
222
|
+
const glProperties: Record<string, GLProperty> = {};
|
|
223
|
+
|
|
224
|
+
for (const name in uiProperties) {
|
|
225
|
+
const value = uiProperties[name];
|
|
226
|
+
glProperties[name] = { value, glslTypeInfo: resolveGLSLTypeInfo(value) };
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return glProperties;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export function cloneProperty<T extends UIProperty>(property: T): T {
|
|
233
|
+
if (typeof property === "number" || property instanceof Texture) {
|
|
234
|
+
return property;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
return property.clone() as T;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export function cloneProperties(
|
|
241
|
+
properties: Record<string, UIProperty>,
|
|
242
|
+
): Record<string, UIProperty> {
|
|
243
|
+
const result: Record<string, UIProperty> = {};
|
|
244
|
+
for (const name in properties) {
|
|
245
|
+
result[name] = cloneProperty(properties[name]);
|
|
246
|
+
}
|
|
247
|
+
return result;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export function cloneGLProperties(
|
|
251
|
+
properties: Record<string, GLProperty>,
|
|
252
|
+
): Record<string, GLProperty> {
|
|
253
|
+
const result: Record<string, GLProperty> = {};
|
|
254
|
+
for (const name in properties) {
|
|
255
|
+
const prop = properties[name];
|
|
256
|
+
result[name] = {
|
|
257
|
+
value: cloneProperty(prop.value),
|
|
258
|
+
glslTypeInfo: prop.glslTypeInfo,
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
return result;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/** Extracts zIndex from transform matrix (translation.z component) */
|
|
265
|
+
export function extractZIndex(transform: Matrix4): number {
|
|
266
|
+
return transform.elements[14];
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/** Extracts zIndex from transform buffer at given instance index */
|
|
270
|
+
export function extractZIndexFromBuffer(buffer: Float32Array, instanceIndex: number): number {
|
|
271
|
+
return buffer[instanceIndex * 16 + 14];
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
export function buildGenericPlaneFragmentShader(
|
|
275
|
+
uniformDeclarations: string[],
|
|
276
|
+
varyingDeclarations: string[],
|
|
277
|
+
source: string,
|
|
278
|
+
): string {
|
|
279
|
+
return `
|
|
280
|
+
// Defines
|
|
281
|
+
#define PI 3.14159265359
|
|
282
|
+
#define SRGB_SUPPORTED ${checkSRGBSupport() ? "1" : "0"}
|
|
283
|
+
|
|
284
|
+
// Uniforms
|
|
285
|
+
${uniformDeclarations.join("\n")}
|
|
286
|
+
|
|
287
|
+
// Builtin varyings
|
|
288
|
+
varying vec3 p_position;
|
|
289
|
+
varying vec2 p_uv;
|
|
290
|
+
|
|
291
|
+
// User varyings
|
|
292
|
+
${varyingDeclarations.join("\n")}
|
|
293
|
+
|
|
294
|
+
#include <alphahash_pars_fragment>
|
|
295
|
+
|
|
296
|
+
// sRGB decode helper
|
|
297
|
+
vec4 srgbTexture2D(sampler2D textureSampler, vec2 uv) {
|
|
298
|
+
#if SRGB_SUPPORTED
|
|
299
|
+
return texture2D(textureSampler, uv);
|
|
300
|
+
#else
|
|
301
|
+
vec4 textureValue = texture2D(textureSampler, uv);
|
|
302
|
+
return vec4(pow(textureValue.rgb, vec3(2.2)), textureValue.a);
|
|
303
|
+
#endif
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// Source must define vec4 draw() function
|
|
307
|
+
${source}
|
|
308
|
+
void main() {
|
|
309
|
+
vec4 diffuseColor = draw();
|
|
310
|
+
#ifdef USE_ALPHATEST
|
|
311
|
+
if (diffuseColor.a < ${DEFAULT_ALPHA_TEST.toFixed(2)}) {
|
|
312
|
+
discard;
|
|
313
|
+
}
|
|
314
|
+
#endif
|
|
315
|
+
#ifdef USE_ALPHAHASH
|
|
316
|
+
if (diffuseColor.a < getAlphaHashThreshold(p_position)) {
|
|
317
|
+
discard;
|
|
318
|
+
}
|
|
319
|
+
#endif
|
|
320
|
+
gl_FragColor = linearToOutputTexel(diffuseColor);
|
|
321
|
+
}
|
|
322
|
+
`;
|
|
323
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Insets configuration as number, per-side, or per-axis */
|
|
2
|
+
export type UIInsetsConfig =
|
|
3
|
+
| { horizontal: number; vertical: number }
|
|
4
|
+
| { left: number; right: number; top: number; bottom: number }
|
|
5
|
+
| [number, number, number, number]
|
|
6
|
+
| [number, number]
|
|
7
|
+
| number;
|
|
8
|
+
|
|
9
|
+
export const INSETS_DEFAULT_VALUE = 0;
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { Vector4 } from "three";
|
|
2
|
+
import { assertValidNonNegativeNumber } from "../asserts";
|
|
3
|
+
import type { UIInsetsConfig } from "./UIInsets.Internal";
|
|
4
|
+
import { INSETS_DEFAULT_VALUE } from "./UIInsets.Internal";
|
|
5
|
+
|
|
6
|
+
/** Insets values for four sides */
|
|
7
|
+
export class UIInsets {
|
|
8
|
+
private lInternal = INSETS_DEFAULT_VALUE;
|
|
9
|
+
private rInternal = INSETS_DEFAULT_VALUE;
|
|
10
|
+
private tInternal = INSETS_DEFAULT_VALUE;
|
|
11
|
+
private bInternal = INSETS_DEFAULT_VALUE;
|
|
12
|
+
|
|
13
|
+
private dirtyInternal = false;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Creates UIInsets instance.
|
|
17
|
+
*
|
|
18
|
+
* @param config - Insets configuration
|
|
19
|
+
*/
|
|
20
|
+
constructor(config?: UIInsetsConfig) {
|
|
21
|
+
this.set(config);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Left inset */
|
|
25
|
+
public get left(): number {
|
|
26
|
+
return this.lInternal;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Right inset */
|
|
30
|
+
public get right(): number {
|
|
31
|
+
return this.rInternal;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Top inset */
|
|
35
|
+
public get top(): number {
|
|
36
|
+
return this.tInternal;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Bottom inset */
|
|
40
|
+
public get bottom(): number {
|
|
41
|
+
return this.bInternal;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** @internal */
|
|
45
|
+
public get dirty(): boolean {
|
|
46
|
+
return this.dirtyInternal;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Left inset */
|
|
50
|
+
public set left(value: number) {
|
|
51
|
+
assertValidNonNegativeNumber(value, "UIInsets.left");
|
|
52
|
+
if (this.lInternal !== value) {
|
|
53
|
+
this.lInternal = value;
|
|
54
|
+
this.dirtyInternal = true;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Right inset */
|
|
59
|
+
public set right(value: number) {
|
|
60
|
+
assertValidNonNegativeNumber(value, "UIInsets.right");
|
|
61
|
+
if (this.rInternal !== value) {
|
|
62
|
+
this.rInternal = value;
|
|
63
|
+
this.dirtyInternal = true;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Top inset */
|
|
68
|
+
public set top(value: number) {
|
|
69
|
+
assertValidNonNegativeNumber(value, "UIInsets.top");
|
|
70
|
+
if (this.tInternal !== value) {
|
|
71
|
+
this.tInternal = value;
|
|
72
|
+
this.dirtyInternal = true;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** Bottom inset */
|
|
77
|
+
public set bottom(value: number) {
|
|
78
|
+
assertValidNonNegativeNumber(value, "UIInsets.bottom");
|
|
79
|
+
if (this.bInternal !== value) {
|
|
80
|
+
this.bInternal = value;
|
|
81
|
+
this.dirtyInternal = true;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Sets left and right to same value */
|
|
86
|
+
public setHorizontal(value: number): void {
|
|
87
|
+
assertValidNonNegativeNumber(value, "UIInsets.setHorizontal.value");
|
|
88
|
+
if (this.lInternal !== value || this.rInternal !== value) {
|
|
89
|
+
this.lInternal = value;
|
|
90
|
+
this.rInternal = value;
|
|
91
|
+
this.dirtyInternal = true;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** Sets top and bottom to same value */
|
|
96
|
+
public setVertical(value: number): void {
|
|
97
|
+
assertValidNonNegativeNumber(value, "UIInsets.setVertical.value");
|
|
98
|
+
if (this.tInternal !== value || this.bInternal !== value) {
|
|
99
|
+
this.tInternal = value;
|
|
100
|
+
this.bInternal = value;
|
|
101
|
+
this.dirtyInternal = true;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** Sets all sides to same value */
|
|
106
|
+
public setUnified(value: number): void {
|
|
107
|
+
assertValidNonNegativeNumber(value, "UIInsets.setUnified.value");
|
|
108
|
+
if (
|
|
109
|
+
this.lInternal !== value ||
|
|
110
|
+
this.rInternal !== value ||
|
|
111
|
+
this.tInternal !== value ||
|
|
112
|
+
this.bInternal !== value
|
|
113
|
+
) {
|
|
114
|
+
this.lInternal = value;
|
|
115
|
+
this.rInternal = value;
|
|
116
|
+
this.tInternal = value;
|
|
117
|
+
this.bInternal = value;
|
|
118
|
+
this.dirtyInternal = true;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** Sets insets */
|
|
123
|
+
public set(config?: UIInsetsConfig): void {
|
|
124
|
+
const lOld = this.lInternal;
|
|
125
|
+
const rOld = this.rInternal;
|
|
126
|
+
const tOld = this.tInternal;
|
|
127
|
+
const bOld = this.bInternal;
|
|
128
|
+
|
|
129
|
+
if (config === undefined) {
|
|
130
|
+
this.lInternal = INSETS_DEFAULT_VALUE;
|
|
131
|
+
this.rInternal = INSETS_DEFAULT_VALUE;
|
|
132
|
+
this.tInternal = INSETS_DEFAULT_VALUE;
|
|
133
|
+
this.bInternal = INSETS_DEFAULT_VALUE;
|
|
134
|
+
} else if (typeof config === "number") {
|
|
135
|
+
assertValidNonNegativeNumber(config, "UIInsets.set.config");
|
|
136
|
+
this.lInternal = config;
|
|
137
|
+
this.rInternal = config;
|
|
138
|
+
this.tInternal = config;
|
|
139
|
+
this.bInternal = config;
|
|
140
|
+
} else if (Array.isArray(config)) {
|
|
141
|
+
if (config.length === 2) {
|
|
142
|
+
const horizontal = config[0];
|
|
143
|
+
const vertical = config[1];
|
|
144
|
+
assertValidNonNegativeNumber(horizontal, "UIInsets.set.config[0]");
|
|
145
|
+
assertValidNonNegativeNumber(vertical, "UIInsets.set.config[1]");
|
|
146
|
+
this.lInternal = horizontal;
|
|
147
|
+
this.rInternal = horizontal;
|
|
148
|
+
this.tInternal = vertical;
|
|
149
|
+
this.bInternal = vertical;
|
|
150
|
+
} else {
|
|
151
|
+
const left = config[0];
|
|
152
|
+
const right = config[1];
|
|
153
|
+
const top = config[2];
|
|
154
|
+
const bottom = config[3];
|
|
155
|
+
assertValidNonNegativeNumber(left, "UIInsets.set.config[0]");
|
|
156
|
+
assertValidNonNegativeNumber(right, "UIInsets.set.config[1]");
|
|
157
|
+
assertValidNonNegativeNumber(top, "UIInsets.set.config[2]");
|
|
158
|
+
assertValidNonNegativeNumber(bottom, "UIInsets.set.config[3]");
|
|
159
|
+
this.lInternal = left;
|
|
160
|
+
this.rInternal = right;
|
|
161
|
+
this.tInternal = top;
|
|
162
|
+
this.bInternal = bottom;
|
|
163
|
+
}
|
|
164
|
+
} else if ("left" in config) {
|
|
165
|
+
const left = config.left;
|
|
166
|
+
const right = config.right;
|
|
167
|
+
const top = config.top;
|
|
168
|
+
const bottom = config.bottom;
|
|
169
|
+
assertValidNonNegativeNumber(left, "UIInsets.set.config.left");
|
|
170
|
+
assertValidNonNegativeNumber(right, "UIInsets.set.config.right");
|
|
171
|
+
assertValidNonNegativeNumber(top, "UIInsets.set.config.top");
|
|
172
|
+
assertValidNonNegativeNumber(bottom, "UIInsets.set.config.bottom");
|
|
173
|
+
this.lInternal = left;
|
|
174
|
+
this.rInternal = right;
|
|
175
|
+
this.tInternal = top;
|
|
176
|
+
this.bInternal = bottom;
|
|
177
|
+
} else {
|
|
178
|
+
const horizontal = config.horizontal;
|
|
179
|
+
const vertical = config.vertical;
|
|
180
|
+
assertValidNonNegativeNumber(horizontal, "UIInsets.set.config.horizontal");
|
|
181
|
+
assertValidNonNegativeNumber(vertical, "UIInsets.set.config.vertical");
|
|
182
|
+
this.lInternal = horizontal;
|
|
183
|
+
this.rInternal = horizontal;
|
|
184
|
+
this.tInternal = vertical;
|
|
185
|
+
this.bInternal = vertical;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if (
|
|
189
|
+
this.lInternal !== lOld ||
|
|
190
|
+
this.rInternal !== rOld ||
|
|
191
|
+
this.tInternal !== tOld ||
|
|
192
|
+
this.bInternal !== bOld
|
|
193
|
+
) {
|
|
194
|
+
this.dirtyInternal = true;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/** Sets from Vector4 (x=left, y=right, z=top, w=bottom) */
|
|
199
|
+
public setVector4(vector: Vector4): void {
|
|
200
|
+
assertValidNonNegativeNumber(vector.x, "UIInsets.setVector4.vector.x");
|
|
201
|
+
assertValidNonNegativeNumber(vector.y, "UIInsets.setVector4.vector.y");
|
|
202
|
+
assertValidNonNegativeNumber(vector.z, "UIInsets.setVector4.vector.z");
|
|
203
|
+
assertValidNonNegativeNumber(vector.w, "UIInsets.setVector4.vector.w");
|
|
204
|
+
if (
|
|
205
|
+
this.lInternal !== vector.x ||
|
|
206
|
+
this.rInternal !== vector.y ||
|
|
207
|
+
this.tInternal !== vector.z ||
|
|
208
|
+
this.bInternal !== vector.w
|
|
209
|
+
) {
|
|
210
|
+
this.lInternal = vector.x;
|
|
211
|
+
this.rInternal = vector.y;
|
|
212
|
+
this.tInternal = vector.z;
|
|
213
|
+
this.bInternal = vector.w;
|
|
214
|
+
this.dirtyInternal = true;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/** Converts to Vector4 (left, right, top, bottom) */
|
|
219
|
+
public toVector4(result = new Vector4()): Vector4 {
|
|
220
|
+
return result.set(this.lInternal, this.rInternal, this.tInternal, this.bInternal);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/** Resets all sides to 0 */
|
|
224
|
+
public reset(): void {
|
|
225
|
+
this.setUnified(0);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/** Copies from another instance */
|
|
229
|
+
public copy(other: UIInsets): void {
|
|
230
|
+
if (
|
|
231
|
+
this.lInternal !== other.lInternal ||
|
|
232
|
+
this.rInternal !== other.rInternal ||
|
|
233
|
+
this.tInternal !== other.tInternal ||
|
|
234
|
+
this.bInternal !== other.bInternal
|
|
235
|
+
) {
|
|
236
|
+
this.lInternal = other.lInternal;
|
|
237
|
+
this.rInternal = other.rInternal;
|
|
238
|
+
this.tInternal = other.tInternal;
|
|
239
|
+
this.bInternal = other.bInternal;
|
|
240
|
+
this.dirtyInternal = true;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/** @internal */
|
|
245
|
+
public setDirtyFalse(): void {
|
|
246
|
+
this.dirtyInternal = false;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { UIProperty } from "../generic-plane/shared";
|
|
2
|
+
|
|
3
|
+
/** Base class for progress bar fill functions */
|
|
4
|
+
export abstract class UIProgressMaskFunction {
|
|
5
|
+
protected dirtyInternal = false;
|
|
6
|
+
|
|
7
|
+
protected constructor(
|
|
8
|
+
/** GLSL shader source code defining fill behavior */
|
|
9
|
+
public readonly source: string,
|
|
10
|
+
) {}
|
|
11
|
+
|
|
12
|
+
/** @internal */
|
|
13
|
+
public get dirty(): boolean {
|
|
14
|
+
return this.dirtyInternal;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** @internal */
|
|
18
|
+
public setDirtyFalse(): void {
|
|
19
|
+
this.dirtyInternal = false;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** @internal */
|
|
23
|
+
public abstract enumerateProperties(): Record<string, UIProperty>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import source from "../../shaders/UIProgressMaskFunctionCircular.glsl";
|
|
2
|
+
import { assertValidNumber } from "../asserts";
|
|
3
|
+
import type { UIProperty } from "../generic-plane/shared";
|
|
4
|
+
import { UIProgressMaskFunction } from "./UIProgressMaskFunction";
|
|
5
|
+
|
|
6
|
+
/** Circular radial progress fill */
|
|
7
|
+
export class UIProgressMaskFunctionCircular extends UIProgressMaskFunction {
|
|
8
|
+
private startAngleInternal: number;
|
|
9
|
+
private inverseDirectionInternal: boolean;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Creates circular mask function.
|
|
13
|
+
*
|
|
14
|
+
* @param startAngle - Starting angle in radians
|
|
15
|
+
* @param inverseDirection - Whether to fill counter-clockwise
|
|
16
|
+
*/
|
|
17
|
+
constructor(startAngle = 0, inverseDirection = false) {
|
|
18
|
+
assertValidNumber(startAngle, "UIProgressMaskFunctionCircular.constructor.startAngle");
|
|
19
|
+
super(source);
|
|
20
|
+
this.startAngleInternal = startAngle;
|
|
21
|
+
this.inverseDirectionInternal = inverseDirection;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Starting angle in radians */
|
|
25
|
+
public get startAngle(): number {
|
|
26
|
+
return this.startAngleInternal;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Whether fill is counter-clockwise */
|
|
30
|
+
public get inverseDirection(): boolean {
|
|
31
|
+
return this.inverseDirectionInternal;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Starting angle in radians */
|
|
35
|
+
public set startAngle(value: number) {
|
|
36
|
+
assertValidNumber(value, "UIProgressMaskFunctionCircular.startAngle");
|
|
37
|
+
if (this.startAngleInternal !== value) {
|
|
38
|
+
this.startAngleInternal = value;
|
|
39
|
+
this.dirtyInternal = true;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Whether fill is counter-clockwise */
|
|
44
|
+
public set inverseDirection(value: boolean) {
|
|
45
|
+
if (this.inverseDirectionInternal !== value) {
|
|
46
|
+
this.inverseDirectionInternal = value;
|
|
47
|
+
this.dirtyInternal = true;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** @internal */
|
|
52
|
+
public enumerateProperties(): Record<string, UIProperty> {
|
|
53
|
+
return {
|
|
54
|
+
direction: this.inverseDirectionInternal ? -1 : 1,
|
|
55
|
+
startAngle: this.startAngleInternal,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|