laymur 0.16.0 → 0.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +84 -208
- package/dist/core/constraints/UIAspectConstraint/UIAspectConstraint.js +41 -0
- package/dist/{constraints → core/constraints}/UIConstraint.d.ts +2 -2
- package/dist/core/constraints/UIConstraint.js +11 -0
- package/dist/core/constraints/UICustomConstraint.js +37 -0
- package/dist/core/constraints/UIHeightConstraint/UIHeightConstraint.js +34 -0
- package/dist/core/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.Internal.js +3 -0
- package/dist/core/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.js +100 -0
- package/dist/core/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.Internal.js +4 -0
- package/dist/core/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.js +136 -0
- package/dist/core/constraints/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.js +40 -0
- package/dist/core/constraints/UISingleParameterConstraint/UISingleParameterConstraint.js +71 -0
- package/dist/core/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.Internal.js +3 -0
- package/dist/core/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.js +100 -0
- package/dist/core/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.Internal.js +4 -0
- package/dist/core/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.js +136 -0
- package/dist/core/constraints/UIVerticalProportionConstraint/UIVerticalProportionConstraint.js +40 -0
- package/dist/core/constraints/UIWidthConstraint/UIWidthConstraint.js +34 -0
- package/dist/core/constraints/builders/UIConstraint2DBuilder.Internal.js +19 -0
- package/dist/core/constraints/builders/UIConstraint2DBuilder.js +138 -0
- package/dist/core/constraints/builders/UICoverConstraintBuilder.Internal.js +3 -0
- package/dist/core/constraints/builders/UICoverConstraintBuilder.js +63 -0
- package/dist/core/constraints/builders/UIFitConstraintBuilder.Internal.js +3 -0
- package/dist/core/constraints/builders/UIFitConstraintBuilder.js +63 -0
- package/dist/{elements → core/elements}/UIAnchor/UIAnchor.Internal.d.ts +3 -0
- package/dist/core/elements/UIAnchor/UIAnchor.Internal.js +5 -0
- package/dist/{elements → core/elements}/UIAnchor/UIAnchor.d.ts +3 -3
- package/dist/core/elements/UIAnchor/UIAnchor.js +49 -0
- package/dist/core/elements/UIAnimatedImage/UIAnimatedImage.Internal.js +15 -0
- package/dist/core/elements/UIAnimatedImage/UIAnimatedImage.js +259 -0
- package/dist/core/elements/UIDummy/UIDummy.Internal.js +8 -0
- package/dist/{elements → core/elements}/UIDummy/UIDummy.d.ts +2 -2
- package/dist/core/elements/UIDummy/UIDummy.js +173 -0
- package/dist/core/elements/UIElement/UIElement.Internal.js +5 -0
- package/dist/{elements → core/elements}/UIElement/UIElement.d.ts +2 -2
- package/dist/core/elements/UIElement/UIElement.js +74 -0
- package/dist/core/elements/UIGraphics/UIGraphics.Internal.js +7 -0
- package/dist/core/elements/UIGraphics/UIGraphics.js +126 -0
- package/dist/core/elements/UIImage/UIImage.js +85 -0
- package/dist/core/elements/UINineSlice/UINineSlice.Internal.js +12 -0
- package/dist/core/elements/UINineSlice/UINineSlice.js +188 -0
- package/dist/core/elements/UIProgress/UIProgress.Internal.js +3 -0
- package/dist/core/elements/UIProgress/UIProgress.js +165 -0
- package/dist/core/elements/UIScene/UIScene.Internal.js +27 -0
- package/dist/core/elements/UIScene/UIScene.js +157 -0
- package/dist/core/elements/UIText/UIText.Internal.js +12 -0
- package/dist/core/elements/UIText/UIText.Measuring.js +153 -0
- package/dist/core/elements/UIText/UIText.Rendering.js +61 -0
- package/dist/core/elements/UIText/UIText.js +265 -0
- package/dist/core/layers/UIFullscreenLayer/UIFullscreenLayer.Internal.js +5 -0
- package/dist/core/layers/UIFullscreenLayer/UIFullscreenLayer.js +147 -0
- package/dist/core/layers/UILayer/UILayer.Internal.js +7 -0
- package/dist/core/layers/UILayer/UILayer.js +113 -0
- package/dist/core/miscellaneous/UIExpression.js +128 -0
- package/dist/core/miscellaneous/UIMode.js +30 -0
- package/dist/core/miscellaneous/UIOrientation.js +20 -0
- package/dist/core/miscellaneous/UIPriority.js +63 -0
- package/dist/core/miscellaneous/UIRelation.js +40 -0
- package/dist/core/miscellaneous/UITransparencyMode.js +12 -0
- package/dist/core/miscellaneous/area/UIArea.js +5 -0
- package/dist/core/miscellaneous/area/UIAreaCircle.js +32 -0
- package/dist/core/miscellaneous/area/UIAreaPolygon.js +40 -0
- package/dist/core/miscellaneous/area/UIAreaRectangle.js +36 -0
- package/dist/core/miscellaneous/area/UIAreaRoundedRectangle.js +72 -0
- package/dist/core/miscellaneous/asserts.js +163 -0
- package/dist/core/miscellaneous/canvas.js +37 -0
- package/dist/core/miscellaneous/color/UIColor.Internal.js +42 -0
- package/dist/core/miscellaneous/color/UIColor.js +636 -0
- package/dist/core/miscellaneous/computeTransform.js +82 -0
- package/dist/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.Internal.js +168 -0
- package/dist/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.js +349 -0
- package/dist/core/miscellaneous/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.js +357 -0
- package/dist/core/miscellaneous/generic-plane/shared.js +228 -0
- package/dist/core/miscellaneous/insets/UIInsets.Internal.js +3 -0
- package/dist/core/miscellaneous/insets/UIInsets.js +224 -0
- package/dist/core/miscellaneous/mask-function/UIProgressMaskFunction.js +19 -0
- package/dist/core/miscellaneous/mask-function/UIProgressMaskFunctionCircular.js +51 -0
- package/dist/core/miscellaneous/mask-function/UIProgressMaskFunctionDirectional.js +48 -0
- package/dist/{miscellaneous → core/miscellaneous}/math.d.ts +2 -0
- package/dist/core/miscellaneous/math.js +11 -0
- package/dist/core/miscellaneous/micro/UIMicro.Internal.js +15 -0
- package/dist/core/miscellaneous/micro/UIMicro.js +181 -0
- package/dist/core/miscellaneous/resize-policy/UIResizePolicy.js +9 -0
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyCover.js +50 -0
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyCross.js +52 -0
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyCrossInverted.js +52 -0
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyFit.js +50 -0
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyFixedHeight.js +52 -0
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyFixedWidth.js +52 -0
- package/dist/core/miscellaneous/resize-policy/UIResizePolicyNone.js +13 -0
- package/dist/core/miscellaneous/shared.js +37 -0
- package/dist/core/miscellaneous/text-span/UITextSpan.js +36 -0
- package/dist/core/miscellaneous/text-style/UITextStyle.Internal.js +17 -0
- package/dist/core/miscellaneous/text-style/UITextStyle.js +372 -0
- package/dist/core/miscellaneous/texture/UITextureView.Internal.js +6 -0
- package/dist/core/miscellaneous/texture/UITextureView.js +234 -0
- package/dist/core/miscellaneous/webglCapabilities.js +103 -0
- package/dist/core/shaders/UIImage.glsl.js +3 -0
- package/dist/core/shaders/UINineSlice.glsl.js +3 -0
- package/dist/core/shaders/UIProgress.glsl.js +3 -0
- package/dist/core/shaders/UIProgressMaskFunctionCircular.glsl.js +3 -0
- package/dist/core/shaders/UIProgressMaskFunctionDirectional.glsl.js +3 -0
- package/dist/{wrappers → core/wrappers}/UIInputWrapper/UIInputWrapper.Internal.d.ts +1 -1
- package/dist/{wrappers → core/wrappers}/UIInputWrapper/UIInputWrapper.d.ts +2 -2
- package/dist/core/wrappers/UIInputWrapper/UIInputWrapper.js +108 -0
- package/dist/{wrappers → core/wrappers}/UISceneWrapper/UISceneWrapper.Internal.d.ts +1 -1
- package/dist/{wrappers → core/wrappers}/UISceneWrapper/UISceneWrapper.d.ts +2 -2
- package/dist/core/wrappers/UISceneWrapper/UISceneWrapper.js +75 -0
- package/dist/{wrappers → core/wrappers}/UISolverWrapper/UISolverWrapper.Internal.d.ts +1 -1
- package/dist/{wrappers → core/wrappers}/UISolverWrapper/UISolverWrapper.d.ts +2 -2
- package/dist/core/wrappers/UISolverWrapper/UISolverWrapper.js +505 -0
- package/dist/index.js +51 -9246
- package/dist/particles/behaviorModules/UIBehaviorDirectionalGravity.d.ts +21 -0
- package/dist/particles/behaviorModules/UIBehaviorDirectionalGravity.js +47 -0
- package/dist/particles/behaviorModules/UIBehaviorModule.d.ts +14 -0
- package/dist/particles/behaviorModules/UIBehaviorModule.js +9 -0
- package/dist/particles/behaviorModules/UIBehaviorPointGravity.d.ts +39 -0
- package/dist/particles/behaviorModules/UIBehaviorPointGravity.js +110 -0
- package/dist/particles/behaviorModules/UIBehaviorScaleOverLife.d.ts +22 -0
- package/dist/particles/behaviorModules/UIBehaviorScaleOverLife.js +66 -0
- package/dist/particles/behaviorModules/UIBehaviorTorqueDamping.d.ts +20 -0
- package/dist/particles/behaviorModules/UIBehaviorTorqueDamping.js +48 -0
- package/dist/particles/behaviorModules/UIBehaviorTorqueNoise.d.ts +26 -0
- package/dist/particles/behaviorModules/UIBehaviorTorqueNoise.js +66 -0
- package/dist/particles/behaviorModules/UIBehaviorVelocityDamping.d.ts +20 -0
- package/dist/particles/behaviorModules/UIBehaviorVelocityDamping.js +49 -0
- package/dist/particles/behaviorModules/UIBehaviorVelocityNoise.d.ts +26 -0
- package/dist/particles/behaviorModules/UIBehaviorVelocityNoise.js +70 -0
- package/dist/particles/elements/UIEmitter.Internal.d.ts +15 -0
- package/dist/particles/elements/UIEmitter.Internal.js +11 -0
- package/dist/particles/elements/UIEmitter.d.ts +68 -0
- package/dist/particles/elements/UIEmitter.js +203 -0
- package/dist/particles/index.d.ts +18 -0
- package/dist/particles/index.js +18 -0
- package/dist/particles/instancedParticle/UIInstancedParticle.Internal.d.ts +13 -0
- package/dist/particles/instancedParticle/UIInstancedParticle.Internal.js +211 -0
- package/dist/particles/instancedParticle/UIInstancedParticle.d.ts +17 -0
- package/dist/particles/instancedParticle/UIInstancedParticle.js +93 -0
- package/dist/particles/miscellaneous/miscellaneous.d.ts +32 -0
- package/dist/particles/miscellaneous/miscellaneous.js +67 -0
- package/dist/particles/renderingModules/UIRenderingColorOverLife.d.ts +14 -0
- package/dist/particles/renderingModules/UIRenderingColorOverLife.js +32 -0
- package/dist/particles/renderingModules/UIRenderingColorOverVelocity.d.ts +15 -0
- package/dist/particles/renderingModules/UIRenderingColorOverVelocity.js +37 -0
- package/dist/particles/renderingModules/UIRenderingModule.d.ts +8 -0
- package/dist/particles/renderingModules/UIRenderingModule.js +9 -0
- package/dist/particles/renderingModules/UIRenderingTexture.d.ts +14 -0
- package/dist/particles/renderingModules/UIRenderingTexture.js +26 -0
- package/dist/particles/shaders/UIRenderingColorOverLife.glsl.js +3 -0
- package/dist/particles/shaders/UIRenderingColorOverVelocity.glsl.js +3 -0
- package/dist/particles/shaders/UIRenderingTexture.glsl.js +3 -0
- package/dist/particles/spawnModules/UISpawnModule.d.ts +9 -0
- package/dist/particles/spawnModules/UISpawnModule.js +9 -0
- package/dist/particles/spawnModules/UISpawnOffset.d.ts +21 -0
- package/dist/particles/spawnModules/UISpawnOffset.js +46 -0
- package/dist/particles/spawnModules/UISpawnRandomLifetime.d.ts +20 -0
- package/dist/particles/spawnModules/UISpawnRandomLifetime.js +47 -0
- package/dist/particles/spawnModules/UISpawnRandomRotation.d.ts +20 -0
- package/dist/particles/spawnModules/UISpawnRandomRotation.js +45 -0
- package/dist/particles/spawnModules/UISpawnRandomScale.d.ts +26 -0
- package/dist/particles/spawnModules/UISpawnRandomScale.js +60 -0
- package/dist/particles/spawnModules/UISpawnRandomTorque.d.ts +20 -0
- package/dist/particles/spawnModules/UISpawnRandomTorque.js +45 -0
- package/dist/particles/spawnModules/UISpawnRandomVelocity.d.ts +26 -0
- package/dist/particles/spawnModules/UISpawnRandomVelocity.js +64 -0
- package/dist/particles/spawnModules/UISpawnRectangle.d.ts +27 -0
- package/dist/particles/spawnModules/UISpawnRectangle.js +62 -0
- package/package.json +27 -36
- package/dist/index.js.map +0 -1
- package/dist/index.min.js +0 -2
- package/dist/index.min.js.map +0 -1
- /package/dist/{constraints → core/constraints}/UIAspectConstraint/UIAspectConstraint.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIAspectConstraint/UIAspectConstraint.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UICustomConstraint.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIHeightConstraint/UIHeightConstraint.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIHeightConstraint/UIHeightConstraint.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UISingleParameterConstraint/UISingleParameterConstraint.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UISingleParameterConstraint/UISingleParameterConstraint.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIVerticalProportionConstraint/UIVerticalProportionConstraint.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIVerticalProportionConstraint/UIVerticalProportionConstraint.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIWidthConstraint/UIWidthConstraint.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/UIWidthConstraint/UIWidthConstraint.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/builders/UIConstraint2DBuilder.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/builders/UIConstraint2DBuilder.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/builders/UICoverConstraintBuilder.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/builders/UICoverConstraintBuilder.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/builders/UIFitConstraintBuilder.Internal.d.ts +0 -0
- /package/dist/{constraints → core/constraints}/builders/UIFitConstraintBuilder.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIAnimatedImage/UIAnimatedImage.Internal.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIAnimatedImage/UIAnimatedImage.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIDummy/UIDummy.Internal.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIElement/UIElement.Internal.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIGraphics/UIGraphics.Internal.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIGraphics/UIGraphics.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIImage/UIImage.Internal.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIImage/UIImage.d.ts +0 -0
- /package/dist/{elements → core/elements}/UINineSlice/UINineSlice.Internal.d.ts +0 -0
- /package/dist/{elements → core/elements}/UINineSlice/UINineSlice.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIProgress/UIProgress.Internal.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIProgress/UIProgress.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIScene/UIScene.Internal.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIScene/UIScene.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIText/UIText.Interfaces.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIText/UIText.Internal.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIText/UIText.Measuring.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIText/UIText.Rendering.d.ts +0 -0
- /package/dist/{elements → core/elements}/UIText/UIText.d.ts +0 -0
- /package/dist/{index.d.ts → core/index.d.ts} +0 -0
- /package/dist/{layers → core/layers}/UIFullscreenLayer/UIFullscreenLayer.Internal.d.ts +0 -0
- /package/dist/{layers → core/layers}/UIFullscreenLayer/UIFullscreenLayer.d.ts +0 -0
- /package/dist/{layers → core/layers}/UILayer/UILayer.Internal.d.ts +0 -0
- /package/dist/{layers → core/layers}/UILayer/UILayer.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/UIExpression.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/UIMode.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/UIOrientation.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/UIPriority.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/UIRelation.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/UITransparencyMode.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/area/UIArea.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/area/UIAreaCircle.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/area/UIAreaPolygon.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/area/UIAreaRectangle.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/area/UIAreaRoundedRectangle.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/asserts.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/canvas.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/color/UIColor.Internal.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/color/UIColor.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/computeTransform.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.Internal.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.Internal.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/generic-plane/shared.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/insets/UIInsets.Internal.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/insets/UIInsets.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/mask-function/UIProgressMaskFunction.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/mask-function/UIProgressMaskFunctionCircular.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/mask-function/UIProgressMaskFunctionDirectional.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/micro/UIMicro.Internal.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/micro/UIMicro.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/resize-policy/UIResizePolicy.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/resize-policy/UIResizePolicyCover.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/resize-policy/UIResizePolicyCross.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/resize-policy/UIResizePolicyCrossInverted.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/resize-policy/UIResizePolicyFit.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/resize-policy/UIResizePolicyFixedHeight.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/resize-policy/UIResizePolicyFixedWidth.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/resize-policy/UIResizePolicyNone.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/shared.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/text-span/UITextSpan.Internal.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/text-span/UITextSpan.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/text-style/UITextStyle.Internal.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/text-style/UITextStyle.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/texture/UITextureView.Internal.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/texture/UITextureView.d.ts +0 -0
- /package/dist/{miscellaneous → core/miscellaneous}/webglCapabilities.d.ts +0 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { UITextStyle } from '../../miscellaneous/text-style/UITextStyle.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Splits text into renderable chunks.
|
|
5
|
+
* @param text Text to split
|
|
6
|
+
* @returns Array of words, spaces, and newlines
|
|
7
|
+
*/
|
|
8
|
+
function splitTextIntoChunks(text) {
|
|
9
|
+
return text.match(/\S+|\s|\n/g) ?? [];
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Measures single text chunk.
|
|
13
|
+
* @param context Canvas context for measurement
|
|
14
|
+
* @param text Chunk text
|
|
15
|
+
* @param textStyle Resolved text style
|
|
16
|
+
* @returns Chunk metrics
|
|
17
|
+
*/
|
|
18
|
+
function measureTextChunk(context, text, textStyle) {
|
|
19
|
+
context.font = `${textStyle.fontStyle} ${textStyle.fontWeight} ${textStyle.fontSize}px "${textStyle.fontFamily}"`;
|
|
20
|
+
if (text === "\n") {
|
|
21
|
+
return {
|
|
22
|
+
width: Math.ceil(1),
|
|
23
|
+
height: textStyle.lineHeight,
|
|
24
|
+
baseline: 0,
|
|
25
|
+
lineHeight: textStyle.lineHeight,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
const metrics = context.measureText(text);
|
|
29
|
+
const width = Math.ceil(metrics.width);
|
|
30
|
+
const height = Math.ceil(metrics.actualBoundingBoxAscent + metrics.actualBoundingBoxDescent);
|
|
31
|
+
return {
|
|
32
|
+
width,
|
|
33
|
+
height,
|
|
34
|
+
baseline: metrics.actualBoundingBoxDescent,
|
|
35
|
+
lineHeight: textStyle.lineHeight,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Builds text lines with word wrapping.
|
|
40
|
+
* @param maxWidth Maximum line width in pixels
|
|
41
|
+
* @param textChunks Measured text chunks
|
|
42
|
+
* @returns Array of text lines
|
|
43
|
+
*/
|
|
44
|
+
function buildTextLines(maxWidth, textChunks) {
|
|
45
|
+
const lines = [];
|
|
46
|
+
let currentLine = [];
|
|
47
|
+
let currentWidth = 0;
|
|
48
|
+
let currentHeight = 0;
|
|
49
|
+
let currentBaseline = 0;
|
|
50
|
+
let currentLineHeight = 0;
|
|
51
|
+
for (const textChunk of textChunks) {
|
|
52
|
+
if (textChunk.text === "\n") {
|
|
53
|
+
if (currentLine.length > 0) {
|
|
54
|
+
lines.push({
|
|
55
|
+
chunks: currentLine,
|
|
56
|
+
width: currentWidth,
|
|
57
|
+
height: currentHeight,
|
|
58
|
+
baseline: currentBaseline,
|
|
59
|
+
lineHeight: currentLineHeight,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
currentLine = [];
|
|
63
|
+
currentWidth = 0;
|
|
64
|
+
currentHeight = 0;
|
|
65
|
+
currentBaseline = 0;
|
|
66
|
+
currentLineHeight = 0;
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
if (currentLine.length === 0 || currentWidth + textChunk.metrics.width <= maxWidth) {
|
|
70
|
+
currentLine.push(textChunk);
|
|
71
|
+
currentWidth += textChunk.metrics.width;
|
|
72
|
+
currentHeight = Math.max(currentHeight, textChunk.metrics.height);
|
|
73
|
+
currentBaseline = Math.max(currentBaseline, textChunk.metrics.baseline);
|
|
74
|
+
currentLineHeight = Math.max(currentLineHeight, textChunk.metrics.lineHeight);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
lines.push({
|
|
78
|
+
chunks: currentLine,
|
|
79
|
+
width: currentWidth,
|
|
80
|
+
height: currentHeight,
|
|
81
|
+
baseline: currentBaseline,
|
|
82
|
+
lineHeight: currentLineHeight,
|
|
83
|
+
});
|
|
84
|
+
currentLine = [textChunk];
|
|
85
|
+
currentWidth = textChunk.metrics.width;
|
|
86
|
+
currentHeight = textChunk.metrics.height;
|
|
87
|
+
currentBaseline = textChunk.metrics.baseline;
|
|
88
|
+
currentLineHeight = textChunk.metrics.lineHeight;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (currentLine.length > 0) {
|
|
92
|
+
lines.push({
|
|
93
|
+
chunks: currentLine,
|
|
94
|
+
width: currentWidth,
|
|
95
|
+
height: currentHeight,
|
|
96
|
+
baseline: currentBaseline,
|
|
97
|
+
lineHeight: currentLineHeight,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
return lines;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Calculates total text size from lines.
|
|
104
|
+
* @param lines Text lines
|
|
105
|
+
* @returns Total width and height
|
|
106
|
+
*/
|
|
107
|
+
function calculateTextSize(lines) {
|
|
108
|
+
if (lines.length === 0) {
|
|
109
|
+
return { width: 0, height: 0 };
|
|
110
|
+
}
|
|
111
|
+
const maxLineWidth = Math.max(...lines.map((line) => line.width));
|
|
112
|
+
let totalHeight = 0;
|
|
113
|
+
for (let i = 0; i < lines.length; i++) {
|
|
114
|
+
const line = lines[i];
|
|
115
|
+
totalHeight += i === 0 ? line.height : line.lineHeight;
|
|
116
|
+
}
|
|
117
|
+
return { width: maxLineWidth, height: totalHeight };
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Builds measured text chunks from spans.
|
|
121
|
+
* @param context Canvas context for measurement
|
|
122
|
+
* @param textSpans Text spans with styles
|
|
123
|
+
* @param commonStyle Fallback style
|
|
124
|
+
* @returns Measured text chunks
|
|
125
|
+
*/
|
|
126
|
+
function buildTextChunks(context, textSpans, commonStyle) {
|
|
127
|
+
const textChunks = [];
|
|
128
|
+
for (const textSpan of textSpans) {
|
|
129
|
+
const textStyle = UITextStyle.resolve(textSpan.style, commonStyle);
|
|
130
|
+
for (const textChunk of splitTextIntoChunks(textSpan.text)) {
|
|
131
|
+
const textChunkMetrics = measureTextChunk(context, textChunk, textStyle);
|
|
132
|
+
textChunks.push({
|
|
133
|
+
text: textChunk,
|
|
134
|
+
style: textStyle,
|
|
135
|
+
metrics: textChunkMetrics,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return textChunks;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Calculates text layout parameters.
|
|
143
|
+
* @param textChunks Measured text chunks
|
|
144
|
+
* @param maxLineWidth Maximum line width in pixels
|
|
145
|
+
* @returns Lines and total size
|
|
146
|
+
*/
|
|
147
|
+
function calculateTextContentParameters(textChunks, maxLineWidth) {
|
|
148
|
+
const lines = buildTextLines(maxLineWidth, textChunks);
|
|
149
|
+
const size = calculateTextSize(lines);
|
|
150
|
+
return { lines, size };
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export { buildTextChunks, buildTextLines, calculateTextContentParameters, calculateTextSize, measureTextChunk, splitTextIntoChunks };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { TEXT_STYLE_DEFAULT_ALIGN } from '../../miscellaneous/text-style/UITextStyle.Internal.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Renders single text chunk.
|
|
5
|
+
* @param x X coordinate in pixels
|
|
6
|
+
* @param y Y coordinate in pixels
|
|
7
|
+
* @param text Chunk text
|
|
8
|
+
* @param style Resolved text style
|
|
9
|
+
* @param context Canvas rendering context
|
|
10
|
+
*/
|
|
11
|
+
function renderTextChunk(x, y, text, style, context) {
|
|
12
|
+
context.font = `${style.fontStyle} ${style.fontWeight} ${style.fontSize}px "${style.fontFamily}"`;
|
|
13
|
+
if (style.enableShadow) {
|
|
14
|
+
context.shadowOffsetX = style.shadowOffsetX;
|
|
15
|
+
context.shadowOffsetY = style.shadowOffsetY;
|
|
16
|
+
context.shadowBlur = style.shadowBlur;
|
|
17
|
+
context.shadowColor = style.shadowColor;
|
|
18
|
+
}
|
|
19
|
+
if (style.enableStroke) {
|
|
20
|
+
context.strokeStyle = style.strokeColor;
|
|
21
|
+
context.lineWidth = style.strokeThickness;
|
|
22
|
+
context.strokeText(text, x, y);
|
|
23
|
+
}
|
|
24
|
+
context.fillStyle = style.color;
|
|
25
|
+
context.fillText(text, x, y);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Renders text lines to canvas.
|
|
29
|
+
* @param paddingTop Top padding in pixels
|
|
30
|
+
* @param paddingLeft Left padding in pixels
|
|
31
|
+
* @param lines Text lines to render
|
|
32
|
+
* @param context Canvas rendering context
|
|
33
|
+
*/
|
|
34
|
+
function renderTextLines(paddingTop, paddingLeft, lines, context) {
|
|
35
|
+
let currentY = paddingTop;
|
|
36
|
+
let textWidth = 0;
|
|
37
|
+
for (const line of lines) {
|
|
38
|
+
textWidth = Math.max(line.width, textWidth);
|
|
39
|
+
}
|
|
40
|
+
for (let i = 0; i < lines.length; i++) {
|
|
41
|
+
const line = lines[i];
|
|
42
|
+
const firstAlign = line.chunks[0]?.style.align ?? TEXT_STYLE_DEFAULT_ALIGN;
|
|
43
|
+
const isUniformAlign = line.chunks.every((c) => c.style.align === firstAlign);
|
|
44
|
+
const lineAlign = isUniformAlign ? firstAlign : TEXT_STYLE_DEFAULT_ALIGN;
|
|
45
|
+
let offsetX = 0;
|
|
46
|
+
if (lineAlign === "center") {
|
|
47
|
+
offsetX = (textWidth - line.width) / 2;
|
|
48
|
+
}
|
|
49
|
+
else if (lineAlign === "right") {
|
|
50
|
+
offsetX = textWidth - line.width;
|
|
51
|
+
}
|
|
52
|
+
let currentX = paddingLeft + offsetX;
|
|
53
|
+
currentY += i === 0 ? line.height : line.lineHeight;
|
|
54
|
+
for (const chunk of line.chunks) {
|
|
55
|
+
renderTextChunk(currentX, currentY, chunk.text, chunk.style, context);
|
|
56
|
+
currentX += chunk.metrics.width;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export { renderTextChunk, renderTextLines };
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { Matrix3 } from 'three';
|
|
2
|
+
import { UIColor } from '../../miscellaneous/color/UIColor.js';
|
|
3
|
+
import { UIInsets } from '../../miscellaneous/insets/UIInsets.js';
|
|
4
|
+
import { UITextSpan } from '../../miscellaneous/text-span/UITextSpan.js';
|
|
5
|
+
import { UITextStyle } from '../../miscellaneous/text-style/UITextStyle.js';
|
|
6
|
+
import source from '../../shaders/UIImage.glsl.js';
|
|
7
|
+
import { UIElement } from '../UIElement/UIElement.js';
|
|
8
|
+
import { createCanvas, createCanvasTexture } from '../../miscellaneous/canvas.js';
|
|
9
|
+
import { TEXT_DEFAULT_MAX_LINE_WIDTH, TEXT_DEFAULT_RESIZE_MODE, UITextResizeMode } from './UIText.Internal.js';
|
|
10
|
+
import { calculateTextContentParameters, buildTextChunks } from './UIText.Measuring.js';
|
|
11
|
+
import { renderTextLines } from './UIText.Rendering.js';
|
|
12
|
+
|
|
13
|
+
/** Canvas-based text rendering element */
|
|
14
|
+
class UIText extends UIElement {
|
|
15
|
+
/**
|
|
16
|
+
* Creates a new UIText instance.
|
|
17
|
+
*
|
|
18
|
+
* @param layer - Layer containing this element
|
|
19
|
+
* @param content - Text content as string or styled spans
|
|
20
|
+
* @param options - Configuration options
|
|
21
|
+
*/
|
|
22
|
+
constructor(layer, content, options = {}) {
|
|
23
|
+
const canvas = createCanvas(2, 2);
|
|
24
|
+
const context = canvas.getContext("2d");
|
|
25
|
+
if (!context) {
|
|
26
|
+
throw new Error("UIText.constructor: failed to create canvas context");
|
|
27
|
+
}
|
|
28
|
+
const texture = createCanvasTexture(canvas);
|
|
29
|
+
texture.needsUpdate = true;
|
|
30
|
+
const color = new UIColor(options.color);
|
|
31
|
+
super(layer, source, {
|
|
32
|
+
texture: texture,
|
|
33
|
+
textureTransform: new Matrix3(),
|
|
34
|
+
color,
|
|
35
|
+
});
|
|
36
|
+
this._private_contentInternal = [];
|
|
37
|
+
this._private_contentDirty = false;
|
|
38
|
+
this._private_maxLineWidthDirty = false;
|
|
39
|
+
this._private_resizeModeDirty = false;
|
|
40
|
+
this._private_textChunks = [];
|
|
41
|
+
this._private_textChunksDirty = false;
|
|
42
|
+
this._private_colorInternal = color;
|
|
43
|
+
this._private_paddingInternal = new UIInsets(options.padding);
|
|
44
|
+
this.commonStyle = new UITextStyle(options.commonStyle);
|
|
45
|
+
this._private_maxLineWidthInternal = options.maxLineWidth ?? TEXT_DEFAULT_MAX_LINE_WIDTH;
|
|
46
|
+
this._private_resizeModeInternal = options.resizeMode ?? TEXT_DEFAULT_RESIZE_MODE;
|
|
47
|
+
this._private_canvas = canvas;
|
|
48
|
+
this._private_context = context;
|
|
49
|
+
this._private_texture = texture;
|
|
50
|
+
this.content = content;
|
|
51
|
+
this._private_lastWidth = this.width;
|
|
52
|
+
this._private_lastHeight = this.height;
|
|
53
|
+
if (options.padding === undefined) {
|
|
54
|
+
this._private_paddingInternal.setUnified(this.content.reduce((a, b) => Math.max(a, b.style.calculatePadding()), this.commonStyle.calculatePadding()));
|
|
55
|
+
}
|
|
56
|
+
switch (this._private_resizeModeInternal) {
|
|
57
|
+
case UITextResizeMode.SCALE:
|
|
58
|
+
this._private_tryToRenderTextScaleMode();
|
|
59
|
+
break;
|
|
60
|
+
case UITextResizeMode.BREAK:
|
|
61
|
+
this._private_tryToRenderTextBreakMode();
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/** Multiplicative tint. Alpha channel controls opacity. */
|
|
66
|
+
get color() {
|
|
67
|
+
return this._private_colorInternal;
|
|
68
|
+
}
|
|
69
|
+
/** Text content as array of styled spans */
|
|
70
|
+
get content() {
|
|
71
|
+
return this._private_contentInternal;
|
|
72
|
+
}
|
|
73
|
+
/** Maximum line width before wrapping in pixels */
|
|
74
|
+
get maxLineWidth() {
|
|
75
|
+
return this._private_maxLineWidthInternal;
|
|
76
|
+
}
|
|
77
|
+
/** Text padding in world units */
|
|
78
|
+
get padding() {
|
|
79
|
+
return this._private_paddingInternal;
|
|
80
|
+
}
|
|
81
|
+
/** Controls how text adapts to element size */
|
|
82
|
+
get resizeMode() {
|
|
83
|
+
return this._private_resizeModeInternal;
|
|
84
|
+
}
|
|
85
|
+
/** Multiplicative tint. Alpha channel controls opacity. */
|
|
86
|
+
set color(value) {
|
|
87
|
+
this._private_colorInternal.set(value);
|
|
88
|
+
}
|
|
89
|
+
/** Text content as string, span config, or array */
|
|
90
|
+
set content(value) {
|
|
91
|
+
if (this._private_contentInternal !== value) {
|
|
92
|
+
if (typeof value === "string") {
|
|
93
|
+
this._private_contentInternal = [new UITextSpan({ text: value, style: new UITextStyle() })];
|
|
94
|
+
}
|
|
95
|
+
else if (Array.isArray(value)) {
|
|
96
|
+
this._private_contentInternal = value.map((span) => typeof span === "string"
|
|
97
|
+
? new UITextSpan({ text: span, style: new UITextStyle() })
|
|
98
|
+
: new UITextSpan({
|
|
99
|
+
text: span.text,
|
|
100
|
+
style: new UITextStyle(span.style),
|
|
101
|
+
}));
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
this._private_contentInternal = [
|
|
105
|
+
new UITextSpan({
|
|
106
|
+
text: value.text,
|
|
107
|
+
style: new UITextStyle(value.style),
|
|
108
|
+
}),
|
|
109
|
+
];
|
|
110
|
+
}
|
|
111
|
+
this._private_contentDirty = true;
|
|
112
|
+
this._private_textChunksDirty = true;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/** Maximum line width before wrapping in pixels */
|
|
116
|
+
set maxLineWidth(value) {
|
|
117
|
+
if (this._private_maxLineWidthInternal !== value) {
|
|
118
|
+
this._private_maxLineWidthInternal = value;
|
|
119
|
+
this._private_maxLineWidthDirty = true;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/** Text padding in world units */
|
|
123
|
+
set padding(value) {
|
|
124
|
+
this._private_paddingInternal.set(value);
|
|
125
|
+
}
|
|
126
|
+
/** Controls how text adapts to size constraints */
|
|
127
|
+
set resizeMode(value) {
|
|
128
|
+
if (this._private_resizeModeInternal !== value) {
|
|
129
|
+
this._private_resizeModeInternal = value;
|
|
130
|
+
this._private_resizeModeDirty = true;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/** Removes element and frees resources */
|
|
134
|
+
destroy() {
|
|
135
|
+
this._private_texture.dispose();
|
|
136
|
+
super.destroy();
|
|
137
|
+
}
|
|
138
|
+
onWillRender(renderer, deltaTime) {
|
|
139
|
+
switch (this._private_resizeModeInternal) {
|
|
140
|
+
case UITextResizeMode.SCALE:
|
|
141
|
+
this._private_tryToRenderTextScaleMode();
|
|
142
|
+
break;
|
|
143
|
+
case UITextResizeMode.BREAK:
|
|
144
|
+
this._private_tryToRenderTextBreakMode();
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
super.onWillRender(renderer, deltaTime);
|
|
148
|
+
}
|
|
149
|
+
_private_tryToRenderTextScaleMode() {
|
|
150
|
+
if (!this._private_colorInternal.dirty &&
|
|
151
|
+
!this._private_resizeModeDirty &&
|
|
152
|
+
!this._private_maxLineWidthDirty &&
|
|
153
|
+
!this._private_paddingInternal.dirty &&
|
|
154
|
+
!(this.solverWrapper.dirty &&
|
|
155
|
+
this._private_lastWidth / this._private_lastHeight !== Math.round(this.width) / Math.round(this.height)) &&
|
|
156
|
+
!this._private_checkContentDirty()) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
const textChunks = this._private_buildTextChunks();
|
|
160
|
+
const { lines, size } = calculateTextContentParameters(textChunks, this._private_maxLineWidthInternal);
|
|
161
|
+
const paddingV = this._private_paddingInternal.top + this._private_paddingInternal.bottom;
|
|
162
|
+
const paddingH = this._private_paddingInternal.left + this._private_paddingInternal.right;
|
|
163
|
+
const desiredHeight = size.height + paddingV;
|
|
164
|
+
const desiredWidth = size.width + paddingH;
|
|
165
|
+
// Two calculation passes are required to cover both cases -
|
|
166
|
+
// when the width is specified by a constraint and cannot be changed,
|
|
167
|
+
// or when the height is specified by a constraint and cannot be changed,
|
|
168
|
+
// but the width still has priority, because it is specified first and last.
|
|
169
|
+
this.width = desiredWidth;
|
|
170
|
+
this.height = (desiredHeight / desiredWidth) * Math.round(this.width);
|
|
171
|
+
this.width = (desiredWidth / desiredHeight) * Math.round(this.height);
|
|
172
|
+
const resolutionDirty = this._private_lastWidth !== desiredHeight || this._private_lastHeight !== desiredWidth;
|
|
173
|
+
if (resolutionDirty) {
|
|
174
|
+
this._private_canvas.height = desiredHeight;
|
|
175
|
+
this._private_canvas.width = desiredWidth;
|
|
176
|
+
}
|
|
177
|
+
renderTextLines(this._private_paddingInternal.top, this._private_paddingInternal.left, lines, this._private_context);
|
|
178
|
+
this._private_updateProperties(resolutionDirty);
|
|
179
|
+
this._private_resizeModeDirty = false;
|
|
180
|
+
this._private_maxLineWidthDirty = false;
|
|
181
|
+
this._private_paddingInternal.setDirtyFalse();
|
|
182
|
+
this._private_setDimensionsDirtyFalse();
|
|
183
|
+
this._private_setContentDirtyFalse();
|
|
184
|
+
}
|
|
185
|
+
_private_tryToRenderTextBreakMode() {
|
|
186
|
+
if (!this._private_colorInternal.dirty &&
|
|
187
|
+
!this._private_resizeModeDirty &&
|
|
188
|
+
!this._private_maxLineWidthDirty &&
|
|
189
|
+
!this._private_paddingInternal.dirty &&
|
|
190
|
+
!this._private_checkDimensionsDirty() &&
|
|
191
|
+
!this._private_checkContentDirty()) {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
const textChunks = this._private_buildTextChunks();
|
|
195
|
+
// Two passes of text size calculation are needed to first
|
|
196
|
+
// suggest the desired sizes to the solver, and then
|
|
197
|
+
// adjust our expectations based on the result obtained.
|
|
198
|
+
const { size: desiredTextSize } = calculateTextContentParameters(textChunks, this._private_maxLineWidthInternal);
|
|
199
|
+
const paddingV = this._private_paddingInternal.top + this._private_paddingInternal.bottom;
|
|
200
|
+
const paddingH = this._private_paddingInternal.left + this._private_paddingInternal.right;
|
|
201
|
+
this.height = desiredTextSize.height + paddingV;
|
|
202
|
+
this.width = desiredTextSize.width + paddingH; // Width should remain a priority, so it is set last.
|
|
203
|
+
const { lines: realTextLines, size: realTextSize } = calculateTextContentParameters(textChunks, Math.round(this.width) - paddingH);
|
|
204
|
+
this.height = realTextSize.height + paddingV;
|
|
205
|
+
this.width = realTextSize.width + paddingH;
|
|
206
|
+
const safeWidth = Math.max(Math.round(this.width), 2);
|
|
207
|
+
const safeHeight = Math.max(Math.round(this.height), 2);
|
|
208
|
+
const resolutionDirty = this._private_lastWidth !== safeWidth || this._private_lastHeight !== safeHeight;
|
|
209
|
+
if (resolutionDirty) {
|
|
210
|
+
this._private_canvas.width = safeWidth;
|
|
211
|
+
this._private_canvas.height = safeHeight;
|
|
212
|
+
}
|
|
213
|
+
renderTextLines(this._private_paddingInternal.top, this._private_paddingInternal.left, realTextLines, this._private_context);
|
|
214
|
+
this._private_updateProperties(resolutionDirty);
|
|
215
|
+
this._private_resizeModeDirty = false;
|
|
216
|
+
this._private_maxLineWidthDirty = false;
|
|
217
|
+
this._private_paddingInternal.setDirtyFalse();
|
|
218
|
+
this._private_setDimensionsDirtyFalse();
|
|
219
|
+
this._private_setContentDirtyFalse();
|
|
220
|
+
}
|
|
221
|
+
_private_updateProperties(resolutionDirty) {
|
|
222
|
+
let properties;
|
|
223
|
+
if (this._private_colorInternal.dirty) {
|
|
224
|
+
properties ?? (properties = {});
|
|
225
|
+
properties["color"] = this._private_colorInternal;
|
|
226
|
+
this._private_colorInternal.setDirtyFalse();
|
|
227
|
+
}
|
|
228
|
+
if (resolutionDirty) {
|
|
229
|
+
this._private_texture.dispose();
|
|
230
|
+
this._private_texture = createCanvasTexture(this._private_canvas);
|
|
231
|
+
this._private_texture.needsUpdate = true;
|
|
232
|
+
properties ?? (properties = {});
|
|
233
|
+
properties["texture"] = this._private_texture;
|
|
234
|
+
}
|
|
235
|
+
if (properties) {
|
|
236
|
+
this.sceneWrapper.setProperties(this.planeHandler, properties);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
_private_buildTextChunks() {
|
|
240
|
+
if (this._private_textChunksDirty) {
|
|
241
|
+
this._private_textChunks = buildTextChunks(this._private_context, this._private_contentInternal, this.commonStyle);
|
|
242
|
+
this._private_textChunksDirty = false;
|
|
243
|
+
}
|
|
244
|
+
return this._private_textChunks;
|
|
245
|
+
}
|
|
246
|
+
_private_checkDimensionsDirty() {
|
|
247
|
+
return (this.solverWrapper.dirty &&
|
|
248
|
+
(this._private_lastWidth !== Math.round(this.width) || this._private_lastHeight !== Math.round(this.height)));
|
|
249
|
+
}
|
|
250
|
+
_private_setDimensionsDirtyFalse() {
|
|
251
|
+
this._private_lastWidth = Math.round(this.width);
|
|
252
|
+
this._private_lastHeight = Math.round(this.height);
|
|
253
|
+
}
|
|
254
|
+
_private_checkContentDirty() {
|
|
255
|
+
return this._private_contentDirty || this.content.some((span) => span.dirty);
|
|
256
|
+
}
|
|
257
|
+
_private_setContentDirtyFalse() {
|
|
258
|
+
this._private_contentDirty = false;
|
|
259
|
+
for (const span of this.content) {
|
|
260
|
+
span.setDirtyFalse();
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export { UIText };
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { Ferrsign1 } from 'ferrsign';
|
|
2
|
+
import { Vector3, MathUtils, Ray } from 'three';
|
|
3
|
+
import { assertValidNumber } from '../../miscellaneous/asserts.js';
|
|
4
|
+
import { isUIModeInteractive } from '../../miscellaneous/UIMode.js';
|
|
5
|
+
import { UILayer } from '../UILayer/UILayer.js';
|
|
6
|
+
import { FULLSCREEN_LAYER_DEFAULT_RESIZE_POLICY } from './UIFullscreenLayer.Internal.js';
|
|
7
|
+
|
|
8
|
+
/** Layer that automatically handles browser window resizing and input events */
|
|
9
|
+
class UIFullscreenLayer extends UILayer {
|
|
10
|
+
constructor(options) {
|
|
11
|
+
const resizePolicy = options?.resizePolicy ?? FULLSCREEN_LAYER_DEFAULT_RESIZE_POLICY;
|
|
12
|
+
const scale = resizePolicy.calculateScale(window.innerWidth, window.innerHeight);
|
|
13
|
+
super({
|
|
14
|
+
width: window.innerWidth * scale,
|
|
15
|
+
height: window.innerHeight * scale,
|
|
16
|
+
...options,
|
|
17
|
+
});
|
|
18
|
+
this._private_resizePolicyDirty = false;
|
|
19
|
+
this._private_signalPointerPressedInternal = new Ferrsign1();
|
|
20
|
+
this._private_signalPointerMovedInternal = new Ferrsign1();
|
|
21
|
+
this._private_signalPointerReleasedInternal = new Ferrsign1();
|
|
22
|
+
this._private_onResize = () => {
|
|
23
|
+
const scale = this.resizePolicy.calculateScale(window.innerWidth, window.innerHeight);
|
|
24
|
+
this.resizePolicy.dirty = false;
|
|
25
|
+
this._private_resizePolicyDirty = false;
|
|
26
|
+
this.resizeInternal(window.innerWidth * scale, window.innerHeight * scale);
|
|
27
|
+
};
|
|
28
|
+
this._private_onPointerDown = (event) => {
|
|
29
|
+
this._private_handleWindowInput(event, "onPointerDown", this._private_signalPointerPressedInternal);
|
|
30
|
+
};
|
|
31
|
+
this._private_onPointerMove = (event) => {
|
|
32
|
+
this._private_handleWindowInput(event, "onPointerMove", this._private_signalPointerMovedInternal);
|
|
33
|
+
};
|
|
34
|
+
this._private_onPointerUp = (event) => {
|
|
35
|
+
this._private_handleWindowInput(event, "onPointerUp", this._private_signalPointerReleasedInternal);
|
|
36
|
+
};
|
|
37
|
+
this._private_resizePolicyInternal = resizePolicy;
|
|
38
|
+
window.addEventListener("resize", this._private_onResize);
|
|
39
|
+
window.addEventListener("pointerdown", this._private_onPointerDown);
|
|
40
|
+
window.addEventListener("pointermove", this._private_onPointerMove);
|
|
41
|
+
window.addEventListener("pointerup", this._private_onPointerUp);
|
|
42
|
+
}
|
|
43
|
+
/** Current resize policy */
|
|
44
|
+
get resizePolicy() {
|
|
45
|
+
return this._private_resizePolicyInternal;
|
|
46
|
+
}
|
|
47
|
+
/** Signal fired when pointer is pressed */
|
|
48
|
+
get signalPointerPressed() {
|
|
49
|
+
return this._private_signalPointerPressedInternal;
|
|
50
|
+
}
|
|
51
|
+
/** Signal fired when pointer is moved */
|
|
52
|
+
get signalPointerMoved() {
|
|
53
|
+
return this._private_signalPointerMovedInternal;
|
|
54
|
+
}
|
|
55
|
+
/** Signal fired when pointer is released */
|
|
56
|
+
get signalPointerReleased() {
|
|
57
|
+
return this._private_signalPointerReleasedInternal;
|
|
58
|
+
}
|
|
59
|
+
/** Updates resize policy */
|
|
60
|
+
set resizePolicy(value) {
|
|
61
|
+
if (this._private_resizePolicyInternal !== value) {
|
|
62
|
+
this._private_resizePolicyInternal = value;
|
|
63
|
+
this._private_resizePolicyDirty = true;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/** Removes event listeners and frees resources */
|
|
67
|
+
destroy() {
|
|
68
|
+
window.removeEventListener("resize", this._private_onResize);
|
|
69
|
+
window.removeEventListener("pointerdown", this._private_onPointerDown);
|
|
70
|
+
window.removeEventListener("pointermove", this._private_onPointerMove);
|
|
71
|
+
window.removeEventListener("pointerup", this._private_onPointerUp);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Renders layer and all visible elements
|
|
75
|
+
* @param renderer Three.js WebGL renderer
|
|
76
|
+
* @param deltaTime Time since last frame in seconds
|
|
77
|
+
*/
|
|
78
|
+
render(renderer, deltaTime) {
|
|
79
|
+
assertValidNumber(deltaTime, "UIFullscreenLayer.render.deltaTime");
|
|
80
|
+
if (this.resizePolicy.dirty || this._private_resizePolicyDirty) {
|
|
81
|
+
this._private_onResize();
|
|
82
|
+
}
|
|
83
|
+
super.renderInternal(renderer, deltaTime);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Projects 3D world position to 2D layer coordinates
|
|
87
|
+
* @param position World position
|
|
88
|
+
* @param camera Three.js camera
|
|
89
|
+
* @param result Reusable vector instance
|
|
90
|
+
* @returns Layer coordinates
|
|
91
|
+
*/
|
|
92
|
+
projectWorldPosition(position, camera, result = new Vector3()) {
|
|
93
|
+
result.copy(position).project(camera);
|
|
94
|
+
result.x = MathUtils.mapLinear(result.x, -1, 1, this.x, this.width);
|
|
95
|
+
result.y = MathUtils.mapLinear(result.y, -1, 1, this.y, this.height);
|
|
96
|
+
return result;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Projects 2D layer coordinates to 3D world position
|
|
100
|
+
* @param position Layer coordinates
|
|
101
|
+
* @param camera Three.js camera
|
|
102
|
+
* @param z Depth coordinate
|
|
103
|
+
* @param result Reusable vector instance
|
|
104
|
+
* @returns World position
|
|
105
|
+
*/
|
|
106
|
+
projectLayerPosition(position, camera, z = -1, result = new Vector3()) {
|
|
107
|
+
return result
|
|
108
|
+
.set(MathUtils.mapLinear(position.x, this.x, this.width, -1, 1), MathUtils.mapLinear(position.y, this.y, this.height, -1, 1), z)
|
|
109
|
+
.unproject(camera);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Builds ray from layer position through camera
|
|
113
|
+
* @param position Layer coordinates
|
|
114
|
+
* @param camera Three.js camera
|
|
115
|
+
* @param result Reusable ray instance
|
|
116
|
+
* @returns Ray from near to far plane
|
|
117
|
+
*/
|
|
118
|
+
buildRay(position, camera, result = new Ray()) {
|
|
119
|
+
const near = new Vector3(MathUtils.mapLinear(position.x, this.x, this.width, -1, 1), MathUtils.mapLinear(position.y, this.y, this.height, -1, 1), -1).unproject(camera);
|
|
120
|
+
const far = new Vector3(MathUtils.mapLinear(position.x, this.x, this.width, -1, 1), MathUtils.mapLinear(position.y, this.y, this.height, -1, 1), 1).unproject(camera);
|
|
121
|
+
const direction = far.sub(near).normalize();
|
|
122
|
+
return result.set(near, direction);
|
|
123
|
+
}
|
|
124
|
+
_private_handleWindowInput(event, pointerFunctionName, signal) {
|
|
125
|
+
const rect = event.target instanceof HTMLElement
|
|
126
|
+
? event.target.getBoundingClientRect()
|
|
127
|
+
: null;
|
|
128
|
+
const x = rect ? event.clientX - rect.left : event.clientX;
|
|
129
|
+
const y = rect
|
|
130
|
+
? rect.bottom - event.clientY
|
|
131
|
+
: window.innerHeight - event.clientY;
|
|
132
|
+
const scale = this.resizePolicy.calculateScale(window.innerWidth, window.innerHeight);
|
|
133
|
+
const scaledX = x * scale;
|
|
134
|
+
const scaledY = y * scale;
|
|
135
|
+
if (isUIModeInteractive(this.mode)) {
|
|
136
|
+
signal.emit({
|
|
137
|
+
x: scaledX,
|
|
138
|
+
y: scaledY,
|
|
139
|
+
identifier: event.pointerId,
|
|
140
|
+
layer: this,
|
|
141
|
+
});
|
|
142
|
+
this.inputWrapperInternal[pointerFunctionName](scaledX, scaledY, event.pointerId);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export { UIFullscreenLayer };
|