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,15 @@
|
|
|
1
|
+
import type { UIOrientation } from "../../miscellaneous/UIOrientation";
|
|
2
|
+
|
|
3
|
+
export const DEFAULT_ANCHOR = 0.5;
|
|
4
|
+
|
|
5
|
+
/** Fit constraint builder options */
|
|
6
|
+
export interface UIFitConstraintBuilderOptions {
|
|
7
|
+
/** Whether to maintain active element aspect ratio */
|
|
8
|
+
keepActiveAspect: boolean;
|
|
9
|
+
/** Horizontal anchor (0 = left, 0.5 = center, 1 = right) */
|
|
10
|
+
anchorH: number;
|
|
11
|
+
/** Vertical anchor (0 = bottom, 0.5 = center, 1 = top) */
|
|
12
|
+
anchorV: number;
|
|
13
|
+
/** Orientation for constraints */
|
|
14
|
+
orientation: UIOrientation;
|
|
15
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { assertValidNumber } from "../../miscellaneous/asserts";
|
|
2
|
+
import type { UILayerElement, UIPlaneElement } from "../../miscellaneous/shared";
|
|
3
|
+
import { UIPriority } from "../../miscellaneous/UIPriority";
|
|
4
|
+
import { UIRelation } from "../../miscellaneous/UIRelation";
|
|
5
|
+
import { UIAspectConstraint } from "../UIAspectConstraint/UIAspectConstraint";
|
|
6
|
+
import { UIHorizontalDistanceConstraint } from "../UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint";
|
|
7
|
+
import { UIHorizontalProportionConstraint } from "../UIHorizontalProportionConstraint/UIHorizontalProportionConstraint";
|
|
8
|
+
import { UIVerticalDistanceConstraint } from "../UIVerticalDistanceConstraint/UIVerticalDistanceConstraint";
|
|
9
|
+
import { UIVerticalProportionConstraint } from "../UIVerticalProportionConstraint/UIVerticalProportionConstraint";
|
|
10
|
+
import type { UIFitConstraintBuilderOptions } from "./UIFitConstraintBuilder.Internal";
|
|
11
|
+
import { DEFAULT_ANCHOR } from "./UIFitConstraintBuilder.Internal";
|
|
12
|
+
|
|
13
|
+
/** Builder for fit layout (like CSS object-fit: contain) */
|
|
14
|
+
export class UIFitConstraintBuilder {
|
|
15
|
+
/**
|
|
16
|
+
* Creates fit layout constraints.
|
|
17
|
+
* @param passive Container element
|
|
18
|
+
* @param active Content element that fits within container
|
|
19
|
+
* @param options Fit configuration
|
|
20
|
+
* @returns Created constraints
|
|
21
|
+
*/
|
|
22
|
+
public static build(
|
|
23
|
+
passive: UIPlaneElement,
|
|
24
|
+
active: UIPlaneElement & UILayerElement,
|
|
25
|
+
options: Partial<UIFitConstraintBuilderOptions> = {},
|
|
26
|
+
): {
|
|
27
|
+
/** Aspect constraint if keepActiveAspect is true */
|
|
28
|
+
activeAspectConstraint?: UIAspectConstraint;
|
|
29
|
+
/** Horizontal position constraint */
|
|
30
|
+
xConstraint: UIHorizontalDistanceConstraint;
|
|
31
|
+
/** Vertical position constraint */
|
|
32
|
+
yConstraint: UIVerticalDistanceConstraint;
|
|
33
|
+
/** Width constraint (ensures fitting) */
|
|
34
|
+
widthConstraint: UIHorizontalProportionConstraint;
|
|
35
|
+
/** Height constraint (ensures fitting) */
|
|
36
|
+
heightConstraint: UIVerticalProportionConstraint;
|
|
37
|
+
} {
|
|
38
|
+
if (options.anchorH !== undefined) {
|
|
39
|
+
assertValidNumber(options.anchorH, "UIFitConstraintBuilder.build.anchorH");
|
|
40
|
+
}
|
|
41
|
+
if (options.anchorV !== undefined) {
|
|
42
|
+
assertValidNumber(options.anchorV, "UIFitConstraintBuilder.build.anchorV");
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
let activeAspectConstraint: UIAspectConstraint | undefined;
|
|
46
|
+
if (options.keepActiveAspect === true) {
|
|
47
|
+
activeAspectConstraint = new UIAspectConstraint(active, {
|
|
48
|
+
orientation: options.orientation,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const xConstraint = new UIHorizontalDistanceConstraint(passive, active, {
|
|
53
|
+
anchorA: options.anchorH ?? DEFAULT_ANCHOR,
|
|
54
|
+
anchorB: options.anchorH ?? DEFAULT_ANCHOR,
|
|
55
|
+
orientation: options.orientation,
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const yConstraint = new UIVerticalDistanceConstraint(passive, active, {
|
|
59
|
+
anchorA: options.anchorV ?? DEFAULT_ANCHOR,
|
|
60
|
+
anchorB: options.anchorV ?? DEFAULT_ANCHOR,
|
|
61
|
+
orientation: options.orientation,
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const widthConstraint = new UIHorizontalProportionConstraint(passive, active, {
|
|
65
|
+
proportion: 1,
|
|
66
|
+
relation: UIRelation.LESS_THAN,
|
|
67
|
+
orientation: options.orientation,
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const heightConstraint = new UIVerticalProportionConstraint(passive, active, {
|
|
71
|
+
proportion: 1,
|
|
72
|
+
priority: UIPriority.P1,
|
|
73
|
+
orientation: options.orientation,
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
return {
|
|
77
|
+
activeAspectConstraint,
|
|
78
|
+
xConstraint,
|
|
79
|
+
yConstraint,
|
|
80
|
+
widthConstraint,
|
|
81
|
+
heightConstraint,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Configuration options for UIAnchor */
|
|
2
|
+
export interface UIAnchorOptions {
|
|
3
|
+
/** X coordinate in world units */
|
|
4
|
+
x: number;
|
|
5
|
+
/** Y coordinate in world units */
|
|
6
|
+
y: number;
|
|
7
|
+
/** Identifier for debugging */
|
|
8
|
+
name: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const ANCHOR_DEFAULT_X = 0;
|
|
12
|
+
export const ANCHOR_DEFAULT_Y = 0;
|
|
13
|
+
export const ANCHOR_DEFAULT_NAME = "";
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { UILayer } from "../../layers/UILayer/UILayer";
|
|
2
|
+
import { assertValidNumber } from "../../miscellaneous/asserts";
|
|
3
|
+
import type { UILayerElement, UIPointElement } from "../../miscellaneous/shared";
|
|
4
|
+
import { UIPriority } from "../../miscellaneous/UIPriority";
|
|
5
|
+
import type { UISolverWrapperView } from "../../wrappers/UISolverWrapper/UISolverWrapper.Internal";
|
|
6
|
+
import type { UIAnchorOptions } from "./UIAnchor.Internal";
|
|
7
|
+
import { ANCHOR_DEFAULT_NAME, ANCHOR_DEFAULT_X, ANCHOR_DEFAULT_Y } from "./UIAnchor.Internal";
|
|
8
|
+
|
|
9
|
+
/** Point in 2D space with constraint-based positioning */
|
|
10
|
+
export class UIAnchor implements UILayerElement, UIPointElement {
|
|
11
|
+
/** Identifier for debugging */
|
|
12
|
+
public name: string;
|
|
13
|
+
|
|
14
|
+
/** Solver variable for x coordinate */
|
|
15
|
+
public readonly xVariable: number;
|
|
16
|
+
|
|
17
|
+
/** Solver variable for y coordinate */
|
|
18
|
+
public readonly yVariable: number;
|
|
19
|
+
|
|
20
|
+
protected readonly solverWrapper: UISolverWrapperView;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Creates a new UIAnchor instance.
|
|
24
|
+
*
|
|
25
|
+
* @param layer - Layer containing this anchor
|
|
26
|
+
* @param options - Configuration options
|
|
27
|
+
*/
|
|
28
|
+
constructor(
|
|
29
|
+
public readonly layer: UILayer,
|
|
30
|
+
options?: Partial<UIAnchorOptions>,
|
|
31
|
+
) {
|
|
32
|
+
const x = options?.x ?? ANCHOR_DEFAULT_X;
|
|
33
|
+
const y = options?.y ?? ANCHOR_DEFAULT_Y;
|
|
34
|
+
assertValidNumber(x, "UIAnchor.constructor.options.x");
|
|
35
|
+
assertValidNumber(y, "UIAnchor.constructor.options.y");
|
|
36
|
+
|
|
37
|
+
this.solverWrapper = this.layer.solverWrapper;
|
|
38
|
+
this.xVariable = this.solverWrapper.createVariable(x, UIPriority.P7);
|
|
39
|
+
this.yVariable = this.solverWrapper.createVariable(y, UIPriority.P7);
|
|
40
|
+
this.name = options?.name ?? ANCHOR_DEFAULT_NAME;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** X coordinate relative to layer origin (bottom-left) */
|
|
44
|
+
public get x(): number {
|
|
45
|
+
return this.solverWrapper.readVariableValue(this.xVariable);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Y coordinate relative to layer origin (bottom-left) */
|
|
49
|
+
public get y(): number {
|
|
50
|
+
return this.solverWrapper.readVariableValue(this.yVariable);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** X coordinate relative to layer origin (bottom-left) */
|
|
54
|
+
public set x(value: number) {
|
|
55
|
+
assertValidNumber(value, "UIAnchor.x");
|
|
56
|
+
this.solverWrapper.suggestVariableValue(this.xVariable, value);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Y coordinate relative to layer origin (bottom-left) */
|
|
60
|
+
public set y(value: number) {
|
|
61
|
+
assertValidNumber(value, "UIAnchor.y");
|
|
62
|
+
this.solverWrapper.suggestVariableValue(this.yVariable, value);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Removes anchor and frees resources */
|
|
66
|
+
public destroy(): void {
|
|
67
|
+
this.solverWrapper.removeVariable(this.yVariable);
|
|
68
|
+
this.solverWrapper.removeVariable(this.xVariable);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { UIColorConfig } from "../../miscellaneous/color/UIColor.Internal";
|
|
2
|
+
import type { UIElementOptions } from "../UIElement/UIElement.Internal";
|
|
3
|
+
|
|
4
|
+
/** Animation loop behavior */
|
|
5
|
+
export enum UIAnimatedImageLoopMode {
|
|
6
|
+
/** No looping, stops at boundary frame */
|
|
7
|
+
NONE = 0,
|
|
8
|
+
/** Loops back to opposite frame */
|
|
9
|
+
LOOP = 1,
|
|
10
|
+
/** Reverses direction at boundaries */
|
|
11
|
+
PING_PONG = 2,
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Configuration options for UIAnimatedImage */
|
|
15
|
+
export interface UIAnimatedImageOptions extends UIElementOptions {
|
|
16
|
+
/** Multiplicative tint */
|
|
17
|
+
color: UIColorConfig;
|
|
18
|
+
/** Animation speed in frames per second */
|
|
19
|
+
frameRate: number;
|
|
20
|
+
/** Playback speed multiplier. Can be negative for reverse playback. */
|
|
21
|
+
timeScale: number;
|
|
22
|
+
/** Loop behavior */
|
|
23
|
+
loopMode: UIAnimatedImageLoopMode;
|
|
24
|
+
/** Whether to start playing immediately */
|
|
25
|
+
playByDefault: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const ANIMATED_IMAGE_DEFAULT_FRAME_RATE = 24;
|
|
29
|
+
export const ANIMATED_IMAGE_DEFAULT_TIME_SCALE = 1;
|
|
30
|
+
export const ANIMATED_IMAGE_DEFAULT_LOOP_MODE = UIAnimatedImageLoopMode.LOOP;
|
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
import type { FerrsignView0 } from "ferrsign";
|
|
2
|
+
import { Ferrsign0 } from "ferrsign";
|
|
3
|
+
import type { Matrix3, WebGLRenderer } from "three";
|
|
4
|
+
import type { UILayer } from "../../layers/UILayer/UILayer";
|
|
5
|
+
import { assertValidNumber, assertValidPositiveNumber } from "../../miscellaneous/asserts";
|
|
6
|
+
import { UIColor } from "../../miscellaneous/color/UIColor";
|
|
7
|
+
import type { UIColorConfig } from "../../miscellaneous/color/UIColor.Internal";
|
|
8
|
+
import { computeTrimmedTransformMatrix } from "../../miscellaneous/computeTransform";
|
|
9
|
+
import type { UIProperty } from "../../miscellaneous/generic-plane/shared";
|
|
10
|
+
import { UITextureView } from "../../miscellaneous/texture/UITextureView";
|
|
11
|
+
import type { UITextureConfig } from "../../miscellaneous/texture/UITextureView.Internal";
|
|
12
|
+
import source from "../../shaders/UIImage.glsl";
|
|
13
|
+
import { UIElement } from "../UIElement/UIElement";
|
|
14
|
+
import type { UIAnimatedImageOptions } from "./UIAnimatedImage.Internal";
|
|
15
|
+
import {
|
|
16
|
+
ANIMATED_IMAGE_DEFAULT_FRAME_RATE,
|
|
17
|
+
ANIMATED_IMAGE_DEFAULT_LOOP_MODE,
|
|
18
|
+
ANIMATED_IMAGE_DEFAULT_TIME_SCALE,
|
|
19
|
+
UIAnimatedImageLoopMode,
|
|
20
|
+
} from "./UIAnimatedImage.Internal";
|
|
21
|
+
|
|
22
|
+
/** Frame-based texture animation element */
|
|
23
|
+
export class UIAnimatedImage extends UIElement {
|
|
24
|
+
private readonly colorInternal: UIColor;
|
|
25
|
+
private readonly sequenceInternal: UITextureView[];
|
|
26
|
+
|
|
27
|
+
private frameRateInternal: number;
|
|
28
|
+
private timeScaleInternal: number;
|
|
29
|
+
private loopModeInternal: UIAnimatedImageLoopMode;
|
|
30
|
+
private readonly textureTransform: Matrix3;
|
|
31
|
+
|
|
32
|
+
private isPlaying = false;
|
|
33
|
+
private sequenceFrameIndex = 0;
|
|
34
|
+
private currentFrameIndexDirty = false;
|
|
35
|
+
private accumulatedTime = 0;
|
|
36
|
+
|
|
37
|
+
private readonly signalPlayedInternal = new Ferrsign0();
|
|
38
|
+
private readonly signalPausedInternal = new Ferrsign0();
|
|
39
|
+
private readonly signalStoppedInternal = new Ferrsign0();
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Creates a new UIAnimatedImage instance.
|
|
43
|
+
*
|
|
44
|
+
* Defaults size to first frame dimensions if width and height not provided.
|
|
45
|
+
*
|
|
46
|
+
* @param layer - Layer containing this element
|
|
47
|
+
* @param sequence - Array of textures forming animation
|
|
48
|
+
* @param options - Configuration options
|
|
49
|
+
*/
|
|
50
|
+
constructor(
|
|
51
|
+
layer: UILayer,
|
|
52
|
+
sequence: UITextureConfig[],
|
|
53
|
+
options: Partial<UIAnimatedImageOptions> = {},
|
|
54
|
+
) {
|
|
55
|
+
const color = new UIColor(options.color);
|
|
56
|
+
const uiTextures = sequence.map((textureConfig) => new UITextureView(textureConfig));
|
|
57
|
+
|
|
58
|
+
const frame = uiTextures[0];
|
|
59
|
+
options.width = options.width ?? frame.width;
|
|
60
|
+
options.height = options.height ?? frame.height;
|
|
61
|
+
|
|
62
|
+
const textureTransform = frame.calculateUVTransform();
|
|
63
|
+
|
|
64
|
+
super(
|
|
65
|
+
layer,
|
|
66
|
+
source,
|
|
67
|
+
{
|
|
68
|
+
texture: frame.texture,
|
|
69
|
+
textureTransform: textureTransform,
|
|
70
|
+
color,
|
|
71
|
+
},
|
|
72
|
+
options,
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
this.colorInternal = color;
|
|
76
|
+
this.sequenceInternal = uiTextures;
|
|
77
|
+
this.textureTransform = textureTransform;
|
|
78
|
+
this.frameRateInternal = options.frameRate ?? ANIMATED_IMAGE_DEFAULT_FRAME_RATE;
|
|
79
|
+
this.timeScaleInternal = options.timeScale ?? ANIMATED_IMAGE_DEFAULT_TIME_SCALE;
|
|
80
|
+
this.loopModeInternal = options.loopMode ?? ANIMATED_IMAGE_DEFAULT_LOOP_MODE;
|
|
81
|
+
|
|
82
|
+
this.subscribeSequenceEvents();
|
|
83
|
+
|
|
84
|
+
if (options.playByDefault === true) {
|
|
85
|
+
this.play();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** Multiplicative tint. Alpha channel controls opacity. */
|
|
90
|
+
public get color(): UIColor {
|
|
91
|
+
return this.colorInternal;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** Total animation duration in seconds */
|
|
95
|
+
public get duration(): number {
|
|
96
|
+
return this.sequenceInternal.length / this.frameRateInternal;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Animation speed in frames per second */
|
|
100
|
+
public get frameRate(): number {
|
|
101
|
+
return this.frameRateInternal;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Loop behavior */
|
|
105
|
+
public get loopMode(): UIAnimatedImageLoopMode {
|
|
106
|
+
return this.loopModeInternal;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** Animation frames as readonly array */
|
|
110
|
+
public get sequence(): readonly UITextureView[] {
|
|
111
|
+
return this.sequenceInternal;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** Playback speed multiplier. Can be negative for reverse playback. */
|
|
115
|
+
public get timeScale(): number {
|
|
116
|
+
return this.timeScaleInternal;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** Signal fired when animation starts or resumes */
|
|
120
|
+
public get signalPlayed(): FerrsignView0 {
|
|
121
|
+
return this.signalPlayedInternal;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** Signal fired when animation pauses */
|
|
125
|
+
public get signalPaused(): FerrsignView0 {
|
|
126
|
+
return this.signalPausedInternal;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** Signal fired when animation stops and resets */
|
|
130
|
+
public get signalStopped(): FerrsignView0 {
|
|
131
|
+
return this.signalStoppedInternal;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** Multiplicative tint. Alpha channel controls opacity. */
|
|
135
|
+
public set color(value: UIColorConfig) {
|
|
136
|
+
this.colorInternal.set(value);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** Animation speed in frames per second */
|
|
140
|
+
public set frameRate(value: number) {
|
|
141
|
+
assertValidPositiveNumber(value, "UIAnimatedImage.frameRate");
|
|
142
|
+
this.frameRateInternal = value;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** Loop behavior */
|
|
146
|
+
public set loopMode(value: UIAnimatedImageLoopMode) {
|
|
147
|
+
this.loopModeInternal = value;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** Replaces animation frames. Stops playback. */
|
|
151
|
+
public set sequence(sequence: UITextureConfig[]) {
|
|
152
|
+
this.stop();
|
|
153
|
+
this.unsubscribeSequenceEvents();
|
|
154
|
+
|
|
155
|
+
const newLength = sequence.length;
|
|
156
|
+
const currentLength = this.sequenceInternal.length;
|
|
157
|
+
|
|
158
|
+
for (let i = 0; i < Math.min(newLength, currentLength); i++) {
|
|
159
|
+
this.sequenceInternal[i].set(sequence[i]);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (newLength < currentLength) {
|
|
163
|
+
this.sequenceInternal.length = newLength;
|
|
164
|
+
} else if (newLength > currentLength) {
|
|
165
|
+
for (let i = currentLength; i < newLength; i++) {
|
|
166
|
+
this.sequenceInternal.push(new UITextureView(sequence[i]));
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
this.subscribeSequenceEvents();
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/** Playback speed multiplier. Can be negative for reverse playback. */
|
|
174
|
+
public set timeScale(value: number) {
|
|
175
|
+
assertValidNumber(value, "UIAnimatedImage.timeScale");
|
|
176
|
+
this.timeScaleInternal = value;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** Removes element and frees resources */
|
|
180
|
+
public override destroy(): void {
|
|
181
|
+
this.unsubscribeSequenceEvents();
|
|
182
|
+
super.destroy();
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** Starts or resumes animation playback */
|
|
186
|
+
public play(): void {
|
|
187
|
+
if (!this.isPlaying) {
|
|
188
|
+
this.isPlaying = true;
|
|
189
|
+
this.signalPlayedInternal.emit();
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/** Pauses animation at current frame */
|
|
194
|
+
public pause(): void {
|
|
195
|
+
if (this.isPlaying) {
|
|
196
|
+
this.isPlaying = false;
|
|
197
|
+
this.signalPausedInternal.emit();
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/** Stops animation and resets to first frame */
|
|
202
|
+
public stop(): void {
|
|
203
|
+
if (this.isPlaying || this.accumulatedTime > 0 || this.sequenceFrameIndex > 0) {
|
|
204
|
+
this.isPlaying = false;
|
|
205
|
+
this.accumulatedTime = 0;
|
|
206
|
+
this.sequenceFrameIndex = 0;
|
|
207
|
+
this.currentFrameIndexDirty = true;
|
|
208
|
+
this.signalStoppedInternal.emit();
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
protected override onWillRender(renderer: WebGLRenderer, deltaTime: number): void {
|
|
213
|
+
if (this.isPlaying && this.timeScaleInternal !== 0) {
|
|
214
|
+
this.accumulatedTime += deltaTime * this.timeScaleInternal;
|
|
215
|
+
const frameDuration = 1 / this.frameRateInternal;
|
|
216
|
+
const sequenceLength = this.sequenceInternal.length;
|
|
217
|
+
const lastFrameIndex = sequenceLength - 1;
|
|
218
|
+
|
|
219
|
+
if (this.timeScaleInternal > 0) {
|
|
220
|
+
while (this.accumulatedTime >= frameDuration) {
|
|
221
|
+
this.accumulatedTime -= frameDuration;
|
|
222
|
+
this.sequenceFrameIndex += 1;
|
|
223
|
+
|
|
224
|
+
if (this.sequenceFrameIndex >= sequenceLength) {
|
|
225
|
+
if (this.loopModeInternal === UIAnimatedImageLoopMode.LOOP) {
|
|
226
|
+
this.sequenceFrameIndex = 0;
|
|
227
|
+
} else if (this.loopModeInternal === UIAnimatedImageLoopMode.PING_PONG) {
|
|
228
|
+
this.sequenceFrameIndex = lastFrameIndex;
|
|
229
|
+
this.timeScaleInternal = -this.timeScaleInternal;
|
|
230
|
+
} else {
|
|
231
|
+
this.sequenceFrameIndex = lastFrameIndex;
|
|
232
|
+
this.isPlaying = false;
|
|
233
|
+
this.signalPausedInternal.emit();
|
|
234
|
+
break;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
this.currentFrameIndexDirty = true;
|
|
239
|
+
}
|
|
240
|
+
} else {
|
|
241
|
+
while (this.accumulatedTime <= -frameDuration) {
|
|
242
|
+
this.accumulatedTime += frameDuration;
|
|
243
|
+
this.sequenceFrameIndex -= 1;
|
|
244
|
+
|
|
245
|
+
if (this.sequenceFrameIndex < 0) {
|
|
246
|
+
if (this.loopModeInternal === UIAnimatedImageLoopMode.LOOP) {
|
|
247
|
+
this.sequenceFrameIndex = lastFrameIndex;
|
|
248
|
+
} else if (this.loopModeInternal === UIAnimatedImageLoopMode.PING_PONG) {
|
|
249
|
+
this.sequenceFrameIndex = 0;
|
|
250
|
+
this.timeScaleInternal = -this.timeScaleInternal;
|
|
251
|
+
} else {
|
|
252
|
+
this.sequenceFrameIndex = 0;
|
|
253
|
+
this.isPlaying = false;
|
|
254
|
+
this.signalPausedInternal.emit();
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
this.currentFrameIndexDirty = true;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
super.onWillRender(renderer, deltaTime);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
protected override setPlaneTransform(): void {
|
|
268
|
+
let properties: Record<string, UIProperty> | undefined;
|
|
269
|
+
|
|
270
|
+
if (this.colorInternal.dirty) {
|
|
271
|
+
properties ??= {};
|
|
272
|
+
properties["color"] = this.colorInternal;
|
|
273
|
+
this.colorInternal.setDirtyFalse();
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
const frame = this.sequenceInternal[this.sequenceFrameIndex];
|
|
277
|
+
if (frame.textureDirty || this.currentFrameIndexDirty) {
|
|
278
|
+
properties ??= {};
|
|
279
|
+
properties["texture"] = frame.texture;
|
|
280
|
+
frame.setTextureDirtyFalse();
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
if (frame.uvTransformDirty || this.currentFrameIndexDirty) {
|
|
284
|
+
properties ??= {};
|
|
285
|
+
properties["textureTransform"] = frame.calculateUVTransform(this.textureTransform);
|
|
286
|
+
frame.setUVTransformDirtyFalse();
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
if (properties) {
|
|
290
|
+
this.sceneWrapper.setProperties(this.planeHandler, properties);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
const isTransformDirty =
|
|
294
|
+
this.currentFrameIndexDirty ||
|
|
295
|
+
this.micro.dirty ||
|
|
296
|
+
frame.trimDirty ||
|
|
297
|
+
this.inputWrapper.dirty ||
|
|
298
|
+
this.solverWrapper.dirty;
|
|
299
|
+
|
|
300
|
+
if (isTransformDirty) {
|
|
301
|
+
const micro = this.micro;
|
|
302
|
+
const textureTrim = frame.trim;
|
|
303
|
+
|
|
304
|
+
this.sceneWrapper.setTransform(
|
|
305
|
+
this.planeHandler,
|
|
306
|
+
computeTrimmedTransformMatrix(
|
|
307
|
+
this.x,
|
|
308
|
+
this.y,
|
|
309
|
+
this.width,
|
|
310
|
+
this.height,
|
|
311
|
+
this.zIndex,
|
|
312
|
+
micro.x,
|
|
313
|
+
micro.y,
|
|
314
|
+
micro.anchorX,
|
|
315
|
+
micro.anchorY,
|
|
316
|
+
micro.scaleX,
|
|
317
|
+
micro.scaleY,
|
|
318
|
+
micro.rotation,
|
|
319
|
+
micro.anchorMode,
|
|
320
|
+
textureTrim.left,
|
|
321
|
+
textureTrim.right,
|
|
322
|
+
textureTrim.top,
|
|
323
|
+
textureTrim.bottom,
|
|
324
|
+
),
|
|
325
|
+
);
|
|
326
|
+
|
|
327
|
+
this.currentFrameIndexDirty = false;
|
|
328
|
+
this.micro.setDirtyFalse();
|
|
329
|
+
frame.setTrimDirtyFalse();
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
private readonly onTextureDimensionsChanged = (
|
|
334
|
+
width: number,
|
|
335
|
+
height: number,
|
|
336
|
+
texture: UITextureView,
|
|
337
|
+
): void => {
|
|
338
|
+
if (this.sequenceInternal[this.sequenceFrameIndex] === texture) {
|
|
339
|
+
this.width = width;
|
|
340
|
+
this.height = height;
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
private subscribeSequenceEvents(): void {
|
|
345
|
+
for (const frame of this.sequenceInternal) {
|
|
346
|
+
frame.signalDiminsionsChanged.on(this.onTextureDimensionsChanged);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
private unsubscribeSequenceEvents(): void {
|
|
351
|
+
for (const frame of this.sequenceInternal) {
|
|
352
|
+
frame.signalDiminsionsChanged.off(this.onTextureDimensionsChanged);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { UIArea } from "../../miscellaneous/area/UIArea";
|
|
2
|
+
import { UIMode } from "../../miscellaneous/UIMode";
|
|
3
|
+
import type { UIAnchorOptions } from "../UIAnchor/UIAnchor.Internal";
|
|
4
|
+
import type { UIDummy } from "./UIDummy";
|
|
5
|
+
|
|
6
|
+
/** Input event data */
|
|
7
|
+
export interface UIInputEventData {
|
|
8
|
+
/** X coordinate */
|
|
9
|
+
x: number;
|
|
10
|
+
/** Y coordinate */
|
|
11
|
+
y: number;
|
|
12
|
+
/** Pointer identifier */
|
|
13
|
+
identifier: number;
|
|
14
|
+
/** Element that emitted the event */
|
|
15
|
+
element: UIDummy;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Configuration options for UIDummy */
|
|
19
|
+
export interface UIDummyOptions extends UIAnchorOptions {
|
|
20
|
+
/** Width in world units */
|
|
21
|
+
width: number;
|
|
22
|
+
/** Height in world units */
|
|
23
|
+
height: number;
|
|
24
|
+
/** Shape defining interactive region in element-local space (0,0 = bottom-left, 1,1 = top-right) */
|
|
25
|
+
interactionArea: UIArea;
|
|
26
|
+
/** Controls visibility and interactivity */
|
|
27
|
+
mode: UIMode;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const DUMMY_DEFAULT_WIDTH = 64;
|
|
31
|
+
export const DUMMY_DEFAULT_HEIGHT = 32;
|
|
32
|
+
export const DUMMY_DEFAULT_MODE = UIMode.VISIBLE;
|
|
33
|
+
export const DUMMY_DEFAULT_Z_INDEX = 0;
|