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.
Files changed (248) hide show
  1. package/.claude/settings.local.json +9 -0
  2. package/.editorconfig +14 -0
  3. package/CLAUDE.md +181 -0
  4. package/README.md +84 -208
  5. package/assets/logotype.png +0 -0
  6. package/eslint.config.js +111 -0
  7. package/package.json +20 -36
  8. package/rollup.config.js +52 -0
  9. package/{dist/constraints/UIAspectConstraint/UIAspectConstraint.Internal.d.ts → src/core/constraints/UIAspectConstraint/UIAspectConstraint.Internal.ts} +3 -2
  10. package/src/core/constraints/UIAspectConstraint/UIAspectConstraint.ts +60 -0
  11. package/src/core/constraints/UIConstraint.ts +20 -0
  12. package/src/core/constraints/UICustomConstraint.ts +62 -0
  13. package/{dist/constraints/UIHeightConstraint/UIHeightConstraint.Internal.d.ts → src/core/constraints/UIHeightConstraint/UIHeightConstraint.Internal.ts} +3 -2
  14. package/src/core/constraints/UIHeightConstraint/UIHeightConstraint.ts +52 -0
  15. package/src/core/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.Internal.ts +13 -0
  16. package/src/core/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.ts +139 -0
  17. package/src/core/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.Internal.ts +16 -0
  18. package/src/core/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.ts +189 -0
  19. package/{dist/constraints/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.Internal.d.ts → src/core/constraints/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.Internal.ts} +3 -2
  20. package/src/core/constraints/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.ts +68 -0
  21. package/{dist/constraints/UISingleParameterConstraint/UISingleParameterConstraint.Internal.d.ts → src/core/constraints/UISingleParameterConstraint/UISingleParameterConstraint.Internal.ts} +9 -8
  22. package/src/core/constraints/UISingleParameterConstraint/UISingleParameterConstraint.ts +94 -0
  23. package/src/core/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.Internal.ts +13 -0
  24. package/src/core/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.ts +135 -0
  25. package/src/core/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.Internal.ts +16 -0
  26. package/src/core/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.ts +189 -0
  27. package/{dist/constraints/UIVerticalProportionConstraint/UIVerticalProportionConstraint.Internal.d.ts → src/core/constraints/UIVerticalProportionConstraint/UIVerticalProportionConstraint.Internal.ts} +3 -2
  28. package/src/core/constraints/UIVerticalProportionConstraint/UIVerticalProportionConstraint.ts +68 -0
  29. package/{dist/constraints/UIWidthConstraint/UIWidthConstraint.Internal.d.ts → src/core/constraints/UIWidthConstraint/UIWidthConstraint.Internal.ts} +3 -2
  30. package/src/core/constraints/UIWidthConstraint/UIWidthConstraint.ts +52 -0
  31. package/src/core/constraints/builders/UIConstraint2DBuilder.Internal.ts +84 -0
  32. package/src/core/constraints/builders/UIConstraint2DBuilder.ts +168 -0
  33. package/src/core/constraints/builders/UICoverConstraintBuilder.Internal.ts +15 -0
  34. package/src/core/constraints/builders/UICoverConstraintBuilder.ts +84 -0
  35. package/src/core/constraints/builders/UIFitConstraintBuilder.Internal.ts +15 -0
  36. package/src/core/constraints/builders/UIFitConstraintBuilder.ts +84 -0
  37. package/src/core/elements/UIAnchor/UIAnchor.Internal.ts +13 -0
  38. package/src/core/elements/UIAnchor/UIAnchor.ts +70 -0
  39. package/src/core/elements/UIAnimatedImage/UIAnimatedImage.Internal.ts +30 -0
  40. package/src/core/elements/UIAnimatedImage/UIAnimatedImage.ts +355 -0
  41. package/src/core/elements/UIDummy/UIDummy.Internal.ts +33 -0
  42. package/src/core/elements/UIDummy/UIDummy.ts +244 -0
  43. package/src/core/elements/UIElement/UIElement.Internal.ts +13 -0
  44. package/src/core/elements/UIElement/UIElement.ts +127 -0
  45. package/{dist/elements/UIGraphics/UIGraphics.Internal.d.ts → src/core/elements/UIGraphics/UIGraphics.Internal.ts} +7 -5
  46. package/src/core/elements/UIGraphics/UIGraphics.ts +168 -0
  47. package/{dist/elements/UIImage/UIImage.Internal.d.ts → src/core/elements/UIImage/UIImage.Internal.ts} +3 -2
  48. package/src/core/elements/UIImage/UIImage.ts +138 -0
  49. package/src/core/elements/UINineSlice/UINineSlice.Internal.ts +26 -0
  50. package/src/core/elements/UINineSlice/UINineSlice.ts +296 -0
  51. package/src/core/elements/UIProgress/UIProgress.Internal.ts +24 -0
  52. package/src/core/elements/UIProgress/UIProgress.ts +259 -0
  53. package/src/core/elements/UIScene/UIScene.Internal.ts +46 -0
  54. package/src/core/elements/UIScene/UIScene.ts +259 -0
  55. package/{dist/elements/UIText/UIText.Interfaces.d.ts → src/core/elements/UIText/UIText.Interfaces.ts} +21 -16
  56. package/src/core/elements/UIText/UIText.Internal.ts +29 -0
  57. package/src/core/elements/UIText/UIText.Measuring.ts +183 -0
  58. package/src/core/elements/UIText/UIText.Rendering.ts +83 -0
  59. package/src/core/elements/UIText/UIText.ts +376 -0
  60. package/{dist/index.d.ts → src/core/index.ts} +2 -1
  61. package/{dist/layers/UIFullscreenLayer/UIFullscreenLayer.Internal.d.ts → src/core/layers/UIFullscreenLayer/UIFullscreenLayer.Internal.ts} +14 -11
  62. package/src/core/layers/UIFullscreenLayer/UIFullscreenLayer.ts +233 -0
  63. package/{dist/layers/UILayer/UILayer.Internal.d.ts → src/core/layers/UILayer/UILayer.Internal.ts} +15 -11
  64. package/src/core/layers/UILayer/UILayer.ts +156 -0
  65. package/src/core/miscellaneous/UIExpression.ts +142 -0
  66. package/src/core/miscellaneous/UIMode.ts +29 -0
  67. package/src/core/miscellaneous/UIOrientation.ts +18 -0
  68. package/src/core/miscellaneous/UIPriority.ts +63 -0
  69. package/src/core/miscellaneous/UIRelation.ts +39 -0
  70. package/src/core/miscellaneous/UITransparencyMode.ts +9 -0
  71. package/src/core/miscellaneous/area/UIArea.ts +5 -0
  72. package/src/core/miscellaneous/area/UIAreaCircle.ts +32 -0
  73. package/src/core/miscellaneous/area/UIAreaPolygon.ts +50 -0
  74. package/src/core/miscellaneous/area/UIAreaRectangle.ts +38 -0
  75. package/src/core/miscellaneous/area/UIAreaRoundedRectangle.ts +78 -0
  76. package/src/core/miscellaneous/asserts.ts +187 -0
  77. package/src/core/miscellaneous/canvas.ts +73 -0
  78. package/src/core/miscellaneous/color/UIColor.Internal.ts +89 -0
  79. package/src/core/miscellaneous/color/UIColor.ts +844 -0
  80. package/src/core/miscellaneous/computeTransform.ts +127 -0
  81. package/src/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.Internal.ts +235 -0
  82. package/src/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.ts +524 -0
  83. package/{dist/miscellaneous/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.Internal.d.ts → src/core/miscellaneous/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.Internal.ts} +10 -8
  84. package/src/core/miscellaneous/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.ts +448 -0
  85. package/src/core/miscellaneous/generic-plane/shared.ts +323 -0
  86. package/src/core/miscellaneous/insets/UIInsets.Internal.ts +9 -0
  87. package/src/core/miscellaneous/insets/UIInsets.ts +248 -0
  88. package/src/core/miscellaneous/mask-function/UIProgressMaskFunction.ts +24 -0
  89. package/src/core/miscellaneous/mask-function/UIProgressMaskFunctionCircular.ts +58 -0
  90. package/src/core/miscellaneous/mask-function/UIProgressMaskFunctionDirectional.ts +52 -0
  91. package/src/core/miscellaneous/math.ts +16 -0
  92. package/src/core/miscellaneous/micro/UIMicro.Internal.ts +33 -0
  93. package/src/core/miscellaneous/micro/UIMicro.ts +222 -0
  94. package/src/core/miscellaneous/resize-policy/UIResizePolicy.ts +8 -0
  95. package/src/core/miscellaneous/resize-policy/UIResizePolicyCover.ts +57 -0
  96. package/src/core/miscellaneous/resize-policy/UIResizePolicyCross.ts +65 -0
  97. package/src/core/miscellaneous/resize-policy/UIResizePolicyCrossInverted.ts +65 -0
  98. package/src/core/miscellaneous/resize-policy/UIResizePolicyFit.ts +57 -0
  99. package/src/core/miscellaneous/resize-policy/UIResizePolicyFixedHeight.ts +65 -0
  100. package/src/core/miscellaneous/resize-policy/UIResizePolicyFixedWidth.ts +65 -0
  101. package/src/core/miscellaneous/resize-policy/UIResizePolicyNone.ts +11 -0
  102. package/src/core/miscellaneous/shared.ts +73 -0
  103. package/{dist/miscellaneous/text-span/UITextSpan.Internal.d.ts → src/core/miscellaneous/text-span/UITextSpan.Internal.ts} +5 -4
  104. package/src/core/miscellaneous/text-span/UITextSpan.ts +43 -0
  105. package/src/core/miscellaneous/text-style/UITextStyle.Internal.ts +52 -0
  106. package/src/core/miscellaneous/text-style/UITextStyle.ts +479 -0
  107. package/src/core/miscellaneous/texture/UITextureView.Internal.ts +55 -0
  108. package/src/core/miscellaneous/texture/UITextureView.ts +308 -0
  109. package/src/core/miscellaneous/webglCapabilities.ts +129 -0
  110. package/src/core/shaders/UIImage.glsl +10 -0
  111. package/src/core/shaders/UINineSlice.glsl +53 -0
  112. package/src/core/shaders/UIProgress.glsl +15 -0
  113. package/src/core/shaders/UIProgressMaskFunctionCircular.glsl +13 -0
  114. package/src/core/shaders/UIProgressMaskFunctionDirectional.glsl +12 -0
  115. package/src/core/shaders/glsl.d.ts +27 -0
  116. package/src/core/wrappers/UIInputWrapper/UIInputWrapper.Internal.ts +23 -0
  117. package/src/core/wrappers/UIInputWrapper/UIInputWrapper.ts +124 -0
  118. package/src/core/wrappers/UISceneWrapper/UISceneWrapper.Internal.ts +22 -0
  119. package/src/core/wrappers/UISceneWrapper/UISceneWrapper.ts +101 -0
  120. package/src/core/wrappers/UISolverWrapper/UISolverWrapper.Internal.ts +58 -0
  121. package/src/core/wrappers/UISolverWrapper/UISolverWrapper.ts +605 -0
  122. package/src/particles/behaviorModules/UIBehaviorDirectionalGravity.ts +70 -0
  123. package/src/particles/behaviorModules/UIBehaviorModule.ts +20 -0
  124. package/src/particles/behaviorModules/UIBehaviorPointGravity.ts +173 -0
  125. package/src/particles/behaviorModules/UIBehaviorScaleOverLife.ts +104 -0
  126. package/src/particles/behaviorModules/UIBehaviorTorqueDamping.ts +75 -0
  127. package/src/particles/behaviorModules/UIBehaviorTorqueNoise.ts +115 -0
  128. package/src/particles/behaviorModules/UIBehaviorVelocityDamping.ts +77 -0
  129. package/src/particles/behaviorModules/UIBehaviorVelocityNoise.ts +118 -0
  130. package/src/particles/elements/UIEmitter.Internal.ts +22 -0
  131. package/src/particles/elements/UIEmitter.ts +313 -0
  132. package/src/particles/index.ts +18 -0
  133. package/src/particles/instancedParticle/UIInstancedParticle.Internal.ts +263 -0
  134. package/src/particles/instancedParticle/UIInstancedParticle.ts +138 -0
  135. package/src/particles/miscellaneous/miscellaneous.ts +115 -0
  136. package/src/particles/renderingModules/UIRenderingColorOverLife.ts +39 -0
  137. package/src/particles/renderingModules/UIRenderingColorOverVelocity.ts +49 -0
  138. package/src/particles/renderingModules/UIRenderingModule.ts +17 -0
  139. package/src/particles/renderingModules/UIRenderingTexture.ts +30 -0
  140. package/src/particles/shaders/UIRenderingColorOverLife.glsl +4 -0
  141. package/src/particles/shaders/UIRenderingColorOverVelocity.glsl +6 -0
  142. package/src/particles/shaders/UIRenderingTexture.glsl +4 -0
  143. package/src/particles/spawnModules/UISpawnModule.ts +22 -0
  144. package/src/particles/spawnModules/UISpawnOffset.ts +62 -0
  145. package/src/particles/spawnModules/UISpawnRandomLifetime.ts +68 -0
  146. package/src/particles/spawnModules/UISpawnRandomRotation.ts +60 -0
  147. package/src/particles/spawnModules/UISpawnRandomScale.ts +81 -0
  148. package/src/particles/spawnModules/UISpawnRandomTorque.ts +62 -0
  149. package/src/particles/spawnModules/UISpawnRandomVelocity.ts +92 -0
  150. package/src/particles/spawnModules/UISpawnRectangle.ts +81 -0
  151. package/tsconfig.json +29 -0
  152. package/dist/constraints/UIAspectConstraint/UIAspectConstraint.d.ts +0 -22
  153. package/dist/constraints/UIConstraint.d.ts +0 -12
  154. package/dist/constraints/UICustomConstraint.d.ts +0 -28
  155. package/dist/constraints/UIHeightConstraint/UIHeightConstraint.d.ts +0 -20
  156. package/dist/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.Internal.d.ts +0 -11
  157. package/dist/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.d.ts +0 -36
  158. package/dist/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.Internal.d.ts +0 -14
  159. package/dist/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.d.ts +0 -44
  160. package/dist/constraints/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.d.ts +0 -22
  161. package/dist/constraints/UISingleParameterConstraint/UISingleParameterConstraint.d.ts +0 -43
  162. package/dist/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.Internal.d.ts +0 -11
  163. package/dist/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.d.ts +0 -32
  164. package/dist/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.Internal.d.ts +0 -14
  165. package/dist/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.d.ts +0 -44
  166. package/dist/constraints/UIVerticalProportionConstraint/UIVerticalProportionConstraint.d.ts +0 -22
  167. package/dist/constraints/UIWidthConstraint/UIWidthConstraint.d.ts +0 -20
  168. package/dist/constraints/builders/UIConstraint2DBuilder.Internal.d.ts +0 -64
  169. package/dist/constraints/builders/UIConstraint2DBuilder.d.ts +0 -46
  170. package/dist/constraints/builders/UICoverConstraintBuilder.Internal.d.ts +0 -13
  171. package/dist/constraints/builders/UICoverConstraintBuilder.d.ts +0 -29
  172. package/dist/constraints/builders/UIFitConstraintBuilder.Internal.d.ts +0 -13
  173. package/dist/constraints/builders/UIFitConstraintBuilder.d.ts +0 -29
  174. package/dist/elements/UIAnchor/UIAnchor.Internal.d.ts +0 -9
  175. package/dist/elements/UIAnchor/UIAnchor.d.ts +0 -32
  176. package/dist/elements/UIAnimatedImage/UIAnimatedImage.Internal.d.ts +0 -27
  177. package/dist/elements/UIAnimatedImage/UIAnimatedImage.d.ts +0 -77
  178. package/dist/elements/UIElement/UIElement.Internal.d.ts +0 -11
  179. package/dist/elements/UIElement/UIElement.d.ts +0 -38
  180. package/dist/elements/UIGraphics/UIGraphics.d.ts +0 -51
  181. package/dist/elements/UIImage/UIImage.d.ts +0 -32
  182. package/dist/elements/UIInputDummy/UIInputDummy.Internal.d.ts +0 -30
  183. package/dist/elements/UIInputDummy/UIInputDummy.d.ts +0 -82
  184. package/dist/elements/UINineSlice/UINineSlice.Internal.d.ts +0 -23
  185. package/dist/elements/UINineSlice/UINineSlice.d.ts +0 -60
  186. package/dist/elements/UIProgress/UIProgress.Internal.d.ts +0 -14
  187. package/dist/elements/UIProgress/UIProgress.d.ts +0 -45
  188. package/dist/elements/UIScene/UIScene.Internal.d.ts +0 -43
  189. package/dist/elements/UIScene/UIScene.d.ts +0 -59
  190. package/dist/elements/UIText/UIText.Internal.d.ts +0 -26
  191. package/dist/elements/UIText/UIText.Measuring.d.ts +0 -50
  192. package/dist/elements/UIText/UIText.Rendering.d.ts +0 -20
  193. package/dist/elements/UIText/UIText.d.ts +0 -71
  194. package/dist/index.js +0 -9236
  195. package/dist/index.js.map +0 -1
  196. package/dist/index.min.js +0 -2
  197. package/dist/index.min.js.map +0 -1
  198. package/dist/layers/UIFullscreenLayer/UIFullscreenLayer.d.ts +0 -63
  199. package/dist/layers/UILayer/UILayer.d.ts +0 -49
  200. package/dist/miscellaneous/UIExpression.d.ts +0 -69
  201. package/dist/miscellaneous/UIMode.d.ts +0 -23
  202. package/dist/miscellaneous/UIOrientation.d.ts +0 -15
  203. package/dist/miscellaneous/UIPriority.d.ts +0 -32
  204. package/dist/miscellaneous/UIRelation.d.ts +0 -23
  205. package/dist/miscellaneous/UITransparencyMode.d.ts +0 -9
  206. package/dist/miscellaneous/area/UIArea.d.ts +0 -3
  207. package/dist/miscellaneous/area/UIAreaCircle.d.ts +0 -15
  208. package/dist/miscellaneous/area/UIAreaPolygon.d.ts +0 -12
  209. package/dist/miscellaneous/area/UIAreaRectangle.d.ts +0 -17
  210. package/dist/miscellaneous/area/UIAreaRoundedRectangle.d.ts +0 -21
  211. package/dist/miscellaneous/asserts.d.ts +0 -43
  212. package/dist/miscellaneous/canvas.d.ts +0 -31
  213. package/dist/miscellaneous/color/UIColor.Internal.d.ts +0 -7
  214. package/dist/miscellaneous/color/UIColor.d.ts +0 -234
  215. package/dist/miscellaneous/computeTransform.d.ts +0 -18
  216. package/dist/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.Internal.d.ts +0 -19
  217. package/dist/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.d.ts +0 -1
  218. package/dist/miscellaneous/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.d.ts +0 -1
  219. package/dist/miscellaneous/generic-plane/shared.d.ts +0 -38
  220. package/dist/miscellaneous/insets/UIInsets.Internal.d.ts +0 -11
  221. package/dist/miscellaneous/insets/UIInsets.d.ts +0 -48
  222. package/dist/miscellaneous/mask-function/UIProgressMaskFunction.d.ts +0 -9
  223. package/dist/miscellaneous/mask-function/UIProgressMaskFunctionCircular.d.ts +0 -21
  224. package/dist/miscellaneous/mask-function/UIProgressMaskFunctionDirectional.d.ts +0 -16
  225. package/dist/miscellaneous/math.d.ts +0 -5
  226. package/dist/miscellaneous/micro/UIMicro.Internal.d.ts +0 -31
  227. package/dist/miscellaneous/micro/UIMicro.d.ts +0 -59
  228. package/dist/miscellaneous/resize-policy/UIResizePolicy.d.ts +0 -3
  229. package/dist/miscellaneous/resize-policy/UIResizePolicyCover.d.ts +0 -22
  230. package/dist/miscellaneous/resize-policy/UIResizePolicyCross.d.ts +0 -22
  231. package/dist/miscellaneous/resize-policy/UIResizePolicyCrossInverted.d.ts +0 -22
  232. package/dist/miscellaneous/resize-policy/UIResizePolicyFit.d.ts +0 -22
  233. package/dist/miscellaneous/resize-policy/UIResizePolicyFixedHeight.d.ts +0 -22
  234. package/dist/miscellaneous/resize-policy/UIResizePolicyFixedWidth.d.ts +0 -22
  235. package/dist/miscellaneous/resize-policy/UIResizePolicyNone.d.ts +0 -5
  236. package/dist/miscellaneous/shared.d.ts +0 -46
  237. package/dist/miscellaneous/text-span/UITextSpan.d.ts +0 -14
  238. package/dist/miscellaneous/text-style/UITextStyle.Internal.d.ts +0 -48
  239. package/dist/miscellaneous/text-style/UITextStyle.d.ts +0 -85
  240. package/dist/miscellaneous/texture/UITextureView.Internal.d.ts +0 -49
  241. package/dist/miscellaneous/texture/UITextureView.d.ts +0 -67
  242. package/dist/miscellaneous/webglCapabilities.d.ts +0 -2
  243. package/dist/wrappers/UIInputWrapper/UIInputWrapper.Internal.d.ts +0 -17
  244. package/dist/wrappers/UIInputWrapper/UIInputWrapper.d.ts +0 -13
  245. package/dist/wrappers/UISceneWrapper/UISceneWrapper.Internal.d.ts +0 -13
  246. package/dist/wrappers/UISceneWrapper/UISceneWrapper.d.ts +0 -20
  247. package/dist/wrappers/UISolverWrapper/UISolverWrapper.Internal.d.ts +0 -49
  248. package/dist/wrappers/UISolverWrapper/UISolverWrapper.d.ts +0 -215
@@ -0,0 +1,138 @@
1
+ import type { Matrix3 } from "three";
2
+ import type { UILayer } from "../../layers/UILayer/UILayer";
3
+ import { UIColor } from "../../miscellaneous/color/UIColor";
4
+ import type { UIColorConfig } from "../../miscellaneous/color/UIColor.Internal";
5
+ import { computeTrimmedTransformMatrix } from "../../miscellaneous/computeTransform";
6
+ import type { UIProperty } from "../../miscellaneous/generic-plane/shared";
7
+ import { UITextureView } from "../../miscellaneous/texture/UITextureView";
8
+ import type { UITextureConfig } from "../../miscellaneous/texture/UITextureView.Internal";
9
+ import source from "../../shaders/UIImage.glsl";
10
+ import { UIElement } from "../UIElement/UIElement";
11
+ import type { UIImageOptions } from "./UIImage.Internal";
12
+
13
+ /** Textured image element */
14
+ export class UIImage extends UIElement {
15
+ /** Texture displayed by this image */
16
+ public readonly texture: UITextureView;
17
+
18
+ private readonly colorInternal: UIColor;
19
+ private readonly textureTransform: Matrix3;
20
+
21
+ /**
22
+ * Creates a new UIImage instance.
23
+ *
24
+ * Defaults size to texture dimensions if width and height not provided.
25
+ *
26
+ * @param layer - Layer containing this image
27
+ * @param texture - Texture to display
28
+ * @param options - Configuration options
29
+ */
30
+ constructor(layer: UILayer, texture: UITextureConfig, options: Partial<UIImageOptions> = {}) {
31
+ const color = new UIColor(options.color);
32
+ const textureView = new UITextureView(texture);
33
+ const textureTransform = textureView.calculateUVTransform();
34
+
35
+ options.width = options.width ?? textureView.width;
36
+ options.height = options.height ?? textureView.height;
37
+
38
+ super(
39
+ layer,
40
+ source,
41
+ {
42
+ texture: textureView.texture,
43
+ textureTransform: textureTransform,
44
+ color,
45
+ },
46
+ options,
47
+ );
48
+
49
+ this.texture = textureView;
50
+ this.textureTransform = textureTransform;
51
+ this.colorInternal = color;
52
+
53
+ this.texture.signalDiminsionsChanged.on(this.onTextureDimensionsChanged);
54
+ }
55
+
56
+ /** Multiplicative tint. Alpha channel controls opacity. */
57
+ public get color(): UIColor {
58
+ return this.colorInternal;
59
+ }
60
+
61
+ /** Multiplicative tint. Alpha channel controls opacity. */
62
+ public set color(value: UIColorConfig) {
63
+ this.colorInternal.set(value);
64
+ }
65
+
66
+ /** Removes image and frees resources */
67
+ public override destroy(): void {
68
+ this.texture.signalDiminsionsChanged.off(this.onTextureDimensionsChanged);
69
+ super.destroy();
70
+ }
71
+
72
+ protected override setPlaneTransform(): void {
73
+ let properties: Record<string, UIProperty> | undefined;
74
+
75
+ if (this.colorInternal.dirty) {
76
+ properties ??= {};
77
+ properties["color"] = this.colorInternal;
78
+ this.colorInternal.setDirtyFalse();
79
+ }
80
+
81
+ if (this.texture.textureDirty) {
82
+ properties ??= {};
83
+ properties["texture"] = this.texture.texture;
84
+ this.texture.setTextureDirtyFalse();
85
+ }
86
+
87
+ if (this.texture.uvTransformDirty) {
88
+ properties ??= {};
89
+ properties["textureTransform"] = this.texture.calculateUVTransform(this.textureTransform);
90
+ this.texture.setUVTransformDirtyFalse();
91
+ }
92
+
93
+ if (properties) {
94
+ this.sceneWrapper.setProperties(this.planeHandler, properties);
95
+ }
96
+
97
+ const isTransformDirty =
98
+ this.micro.dirty ||
99
+ this.texture.trimDirty ||
100
+ this.inputWrapper.dirty ||
101
+ this.solverWrapper.dirty;
102
+
103
+ if (isTransformDirty) {
104
+ const micro = this.micro;
105
+ const textureTrim = this.texture.trim;
106
+
107
+ this.sceneWrapper.setTransform(
108
+ this.planeHandler,
109
+ computeTrimmedTransformMatrix(
110
+ this.x,
111
+ this.y,
112
+ this.width,
113
+ this.height,
114
+ this.zIndex,
115
+ micro.x,
116
+ micro.y,
117
+ micro.anchorX,
118
+ micro.anchorY,
119
+ micro.scaleX,
120
+ micro.scaleY,
121
+ micro.rotation,
122
+ micro.anchorMode,
123
+ textureTrim.left,
124
+ textureTrim.right,
125
+ textureTrim.top,
126
+ textureTrim.bottom,
127
+ ),
128
+ );
129
+ this.micro.setDirtyFalse();
130
+ this.texture.setTrimDirtyFalse();
131
+ }
132
+ }
133
+
134
+ private readonly onTextureDimensionsChanged = (width: number, height: number): void => {
135
+ this.width = width;
136
+ this.height = height;
137
+ };
138
+ }
@@ -0,0 +1,26 @@
1
+ import type { UIColorConfig } from "../../miscellaneous/color/UIColor.Internal";
2
+ import type { UIInsetsConfig } from "../../miscellaneous/insets/UIInsets.Internal";
3
+ import type { UIElementOptions } from "../UIElement/UIElement.Internal";
4
+
5
+ /** Controls how sliceRegions values are interpreted */
6
+ export enum UINineSliceRegionMode {
7
+ /** sliceRegions in normalized coordinates (0 to 1) */
8
+ NORMALIZED = 0,
9
+ /** sliceRegions in world units */
10
+ WORLD = 1,
11
+ }
12
+
13
+ /** Configuration options for UINineSlice */
14
+ export interface UINineSliceOptions extends UIElementOptions {
15
+ /** Multiplicative tint */
16
+ color: UIColorConfig;
17
+ /** Border size in normalized texture coordinates (0 to 1) */
18
+ sliceBorders: UIInsetsConfig;
19
+ /** Region size. Interpretation depends on regionMode. */
20
+ sliceRegions: UIInsetsConfig;
21
+ /** How sliceRegions values are interpreted */
22
+ regionMode: UINineSliceRegionMode;
23
+ }
24
+
25
+ export const NINE_SLICE_DEFAULT_BORDER = 0.1;
26
+ export const NINE_SLICE_DEFAULT_REGION_MODE = UINineSliceRegionMode.WORLD;
@@ -0,0 +1,296 @@
1
+ import type { Matrix3 } from "three";
2
+ import { Vector4 } from "three";
3
+ import type { UILayer } from "../../layers/UILayer/UILayer";
4
+ import { UIColor } from "../../miscellaneous/color/UIColor";
5
+ import type { UIColorConfig } from "../../miscellaneous/color/UIColor.Internal";
6
+ import { computeTrimmedTransformMatrix } from "../../miscellaneous/computeTransform";
7
+ import type { UIProperty } from "../../miscellaneous/generic-plane/shared";
8
+ import { UIInsets } from "../../miscellaneous/insets/UIInsets";
9
+ import type { UIInsetsConfig } from "../../miscellaneous/insets/UIInsets.Internal";
10
+ import { UITextureView } from "../../miscellaneous/texture/UITextureView";
11
+ import type { UITextureConfig } from "../../miscellaneous/texture/UITextureView.Internal";
12
+ import source from "../../shaders/UINineSlice.glsl";
13
+ import { UIElement } from "../UIElement/UIElement";
14
+ import type { UINineSliceOptions } from "./UINineSlice.Internal";
15
+ import {
16
+ NINE_SLICE_DEFAULT_BORDER,
17
+ NINE_SLICE_DEFAULT_REGION_MODE,
18
+ UINineSliceRegionMode,
19
+ } from "./UINineSlice.Internal";
20
+
21
+ /** Scalable textured image preserving border regions */
22
+ export class UINineSlice extends UIElement {
23
+ /** Texture displayed by this element */
24
+ public readonly texture: UITextureView;
25
+
26
+ private readonly colorInternal: UIColor;
27
+ private readonly sliceBordersInternal: UIInsets;
28
+ private readonly sliceRegionsInternal: UIInsets;
29
+ private regionModeInternal: UINineSliceRegionMode;
30
+ private regionModeDirty = true;
31
+
32
+ private readonly textureTransform: Matrix3;
33
+ private readonly sliceBordersVector = new Vector4();
34
+ private readonly sliceRegionsVector = new Vector4();
35
+
36
+ private lastElementWidth: number;
37
+ private lastElementHeight: number;
38
+
39
+ private textureDimensionsDirty = true;
40
+
41
+ /**
42
+ * Creates a new UINineSlice instance.
43
+ *
44
+ * Defaults size to texture dimensions if width and height not provided.
45
+ *
46
+ * @param layer - Layer containing this element
47
+ * @param texture - Texture to display
48
+ * @param options - Configuration options
49
+ */
50
+ constructor(layer: UILayer, texture: UITextureConfig, options: Partial<UINineSliceOptions> = {}) {
51
+ const color = new UIColor(options.color);
52
+ const textureView = new UITextureView(texture);
53
+ const textureTransform = textureView.calculateUVTransform();
54
+
55
+ options.width = options.width ?? textureView.width;
56
+ options.height = options.height ?? textureView.height;
57
+
58
+ const sliceBorders = new UIInsets(options.sliceBorders ?? NINE_SLICE_DEFAULT_BORDER);
59
+ const sliceRegions = new UIInsets(options.sliceRegions ?? NINE_SLICE_DEFAULT_BORDER);
60
+
61
+ const regionMode = options.regionMode ?? NINE_SLICE_DEFAULT_REGION_MODE;
62
+
63
+ const sliceBordersVector = new Vector4();
64
+ const sliceRegionsVector = new Vector4();
65
+
66
+ super(
67
+ layer,
68
+ source,
69
+ {
70
+ texture: textureView.texture,
71
+ textureTransform: textureTransform,
72
+ color,
73
+ sliceBorders: sliceBordersVector,
74
+ sliceRegions: sliceRegionsVector,
75
+ },
76
+ options,
77
+ );
78
+
79
+ this.texture = textureView;
80
+ this.textureTransform = textureTransform;
81
+ this.colorInternal = color;
82
+ this.sliceBordersInternal = sliceBorders;
83
+ this.sliceRegionsInternal = sliceRegions;
84
+ this.regionModeInternal = regionMode;
85
+
86
+ this.sliceBordersVector = sliceBordersVector;
87
+ this.sliceRegionsVector = sliceRegionsVector;
88
+
89
+ this.lastElementWidth = this.width;
90
+ this.lastElementHeight = this.height;
91
+
92
+ this.texture.signalDiminsionsChanged.on(this.onTextureDimensionsChanged);
93
+ }
94
+
95
+ /** Multiplicative tint. Alpha channel controls opacity. */
96
+ public get color(): UIColor {
97
+ return this.colorInternal;
98
+ }
99
+
100
+ /** Controls how sliceRegions values are interpreted */
101
+ public get regionMode(): UINineSliceRegionMode {
102
+ return this.regionModeInternal;
103
+ }
104
+
105
+ /** Border size in normalized texture coordinates (0 to 1) */
106
+ public get sliceBorders(): UIInsets {
107
+ return this.sliceBordersInternal;
108
+ }
109
+
110
+ /** Region size. Interpretation depends on regionMode. */
111
+ public get sliceRegions(): UIInsets {
112
+ return this.sliceRegionsInternal;
113
+ }
114
+
115
+ /** Multiplicative tint. Alpha channel controls opacity. */
116
+ public set color(value: UIColorConfig) {
117
+ this.colorInternal.set(value);
118
+ }
119
+
120
+ /** Controls how sliceRegions values are interpreted */
121
+ public set regionMode(value: UINineSliceRegionMode) {
122
+ if (this.regionModeInternal !== value) {
123
+ this.regionModeInternal = value;
124
+ this.regionModeDirty = true;
125
+ }
126
+ }
127
+
128
+ /** Border size in normalized texture coordinates (0 to 1) */
129
+ public set sliceBorders(value: UIInsetsConfig) {
130
+ this.sliceBordersInternal.set(value);
131
+ }
132
+
133
+ /** Region size. Interpretation depends on regionMode. */
134
+ public set sliceRegions(value: UIInsetsConfig) {
135
+ this.sliceRegionsInternal.set(value);
136
+ }
137
+
138
+ /** Removes nine slice and frees resources */
139
+ public override destroy(): void {
140
+ this.texture.signalDiminsionsChanged.off(this.onTextureDimensionsChanged);
141
+ super.destroy();
142
+ }
143
+
144
+ protected override setPlaneTransform(): void {
145
+ let properties: Record<string, UIProperty> | undefined;
146
+
147
+ const sliceBordersDirty =
148
+ this.textureDimensionsDirty || this.sliceBordersInternal.dirty || this.texture.trimDirty;
149
+
150
+ if (sliceBordersDirty) {
151
+ properties ??= {};
152
+ properties["sliceBorders"] = this.calculateSliceBordersForShader(this.sliceBordersVector);
153
+ this.sliceBordersInternal.setDirtyFalse();
154
+ this.textureDimensionsDirty = false;
155
+ }
156
+
157
+ const sliceRegionsDirty =
158
+ this.sliceRegionsInternal.dirty ||
159
+ this.regionModeDirty ||
160
+ (this.regionModeInternal === UINineSliceRegionMode.WORLD &&
161
+ this.checkElementDimensionsDirty());
162
+
163
+ if (sliceRegionsDirty) {
164
+ properties ??= {};
165
+ properties["sliceRegions"] = this.calculateSliceRegionsForShader(this.sliceRegionsVector);
166
+ this.sliceRegionsInternal.setDirtyFalse();
167
+ this.regionModeDirty = false;
168
+ this.setElementDimensionsDirtyFalse();
169
+ }
170
+
171
+ if (this.colorInternal.dirty) {
172
+ properties ??= {};
173
+ properties["color"] = this.colorInternal;
174
+ this.colorInternal.setDirtyFalse();
175
+ }
176
+
177
+ if (this.texture.textureDirty) {
178
+ properties ??= {};
179
+ properties["texture"] = this.texture.texture;
180
+ this.texture.setTextureDirtyFalse();
181
+ }
182
+
183
+ if (this.texture.uvTransformDirty) {
184
+ properties ??= {};
185
+ properties["textureTransform"] = this.texture.calculateUVTransform(this.textureTransform);
186
+ this.texture.setUVTransformDirtyFalse();
187
+ }
188
+
189
+ if (properties) {
190
+ this.sceneWrapper.setProperties(this.planeHandler, properties);
191
+ }
192
+
193
+ const isTransformDirty =
194
+ this.micro.dirty ||
195
+ this.texture.trimDirty ||
196
+ this.inputWrapper.dirty ||
197
+ this.solverWrapper.dirty;
198
+
199
+ if (isTransformDirty) {
200
+ const micro = this.micro;
201
+ const textureTrim = this.texture.trim;
202
+
203
+ this.sceneWrapper.setTransform(
204
+ this.planeHandler,
205
+ computeTrimmedTransformMatrix(
206
+ this.x,
207
+ this.y,
208
+ this.width,
209
+ this.height,
210
+ this.zIndex,
211
+ micro.x,
212
+ micro.y,
213
+ micro.anchorX,
214
+ micro.anchorY,
215
+ micro.scaleX,
216
+ micro.scaleY,
217
+ micro.rotation,
218
+ micro.anchorMode,
219
+ textureTrim.left,
220
+ textureTrim.right,
221
+ textureTrim.top,
222
+ textureTrim.bottom,
223
+ ),
224
+ );
225
+ this.micro.setDirtyFalse();
226
+ this.texture.setTrimDirtyFalse();
227
+ }
228
+ }
229
+
230
+ private calculateSliceBordersForShader(result: Vector4): Vector4 {
231
+ const sourceWidth = this.texture.width;
232
+ const sourceHeight = this.texture.height;
233
+ const trim = this.texture.trim;
234
+
235
+ const trimmedWidth = sourceWidth - trim.left - trim.right;
236
+ const trimmedHeight = sourceHeight - trim.top - trim.bottom;
237
+
238
+ const trimNLeft = trim.left / sourceWidth;
239
+ const trimNRight = trim.right / sourceWidth;
240
+ const trimNTop = trim.top / sourceHeight;
241
+ const trimNBottom = trim.bottom / sourceHeight;
242
+
243
+ const trimmedWidthNorm = trimmedWidth / sourceWidth;
244
+ const trimmedHeightNorm = trimmedHeight / sourceHeight;
245
+
246
+ const srcLeft = this.sliceBordersInternal.left;
247
+ const srcRight = this.sliceBordersInternal.right;
248
+ const srcTop = this.sliceBordersInternal.top;
249
+ const srcBottom = this.sliceBordersInternal.bottom;
250
+
251
+ const left = Math.max(0, srcLeft - trimNLeft) / trimmedWidthNorm;
252
+ const right = Math.max(0, srcRight - trimNRight) / trimmedWidthNorm;
253
+ const top = Math.max(0, srcTop - trimNTop) / trimmedHeightNorm;
254
+ const bottom = Math.max(0, srcBottom - trimNBottom) / trimmedHeightNorm;
255
+
256
+ return result.set(Math.min(1, left), Math.min(1, right), Math.min(1, top), Math.min(1, bottom));
257
+ }
258
+
259
+ private calculateSliceRegionsForShader(result: Vector4): Vector4 {
260
+ if (this.regionModeInternal === UINineSliceRegionMode.NORMALIZED) {
261
+ return result.set(
262
+ this.sliceRegionsInternal.left,
263
+ this.sliceRegionsInternal.right,
264
+ this.sliceRegionsInternal.top,
265
+ this.sliceRegionsInternal.bottom,
266
+ );
267
+ }
268
+
269
+ const width = this.width;
270
+ const height = this.height;
271
+
272
+ return result.set(
273
+ this.sliceRegionsInternal.left / width,
274
+ this.sliceRegionsInternal.right / width,
275
+ this.sliceRegionsInternal.top / height,
276
+ this.sliceRegionsInternal.bottom / height,
277
+ );
278
+ }
279
+
280
+ private checkElementDimensionsDirty(): boolean {
281
+ return (
282
+ this.solverWrapper.dirty &&
283
+ (this.lastElementWidth !== Math.round(this.width) ||
284
+ this.lastElementHeight !== Math.round(this.height))
285
+ );
286
+ }
287
+
288
+ private setElementDimensionsDirtyFalse(): void {
289
+ this.lastElementWidth = Math.round(this.width);
290
+ this.lastElementHeight = Math.round(this.height);
291
+ }
292
+
293
+ private readonly onTextureDimensionsChanged = (): void => {
294
+ this.textureDimensionsDirty = true;
295
+ };
296
+ }
@@ -0,0 +1,24 @@
1
+ import type { UIColorConfig } from "../../miscellaneous/color/UIColor.Internal";
2
+ import type { UIProgressMaskFunction } from "../../miscellaneous/mask-function/UIProgressMaskFunction";
3
+ import type { UIElementOptions } from "../UIElement/UIElement.Internal";
4
+
5
+ /** Configuration options for UIProgress */
6
+ export interface UIProgressOptions extends UIElementOptions {
7
+ /** Multiplicative tint */
8
+ color: UIColorConfig;
9
+ /** Function controlling fill direction and shape */
10
+ maskFunction: UIProgressMaskFunction;
11
+ /** Progress from 0 (empty) to 1 (full) */
12
+ progress: number;
13
+ }
14
+
15
+ export const PROGRESS_DEFAULT_VALUE = 1;
16
+
17
+ export function simplifyGLSLSource(source: string): string {
18
+ return source
19
+ .replace(/\/\*[\s\S]*?\*\//g, "")
20
+ .replace(/\/\/[^\n]*/g, "")
21
+ .replace(/\s*([{}(),=;+\-*/<>])\s*/g, "$1")
22
+ .replace(/\s+/g, " ")
23
+ .trim();
24
+ }