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.
Files changed (266) hide show
  1. package/README.md +84 -208
  2. package/dist/core/constraints/UIAspectConstraint/UIAspectConstraint.js +41 -0
  3. package/dist/{constraints → core/constraints}/UIConstraint.d.ts +2 -2
  4. package/dist/core/constraints/UIConstraint.js +11 -0
  5. package/dist/core/constraints/UICustomConstraint.js +37 -0
  6. package/dist/core/constraints/UIHeightConstraint/UIHeightConstraint.js +34 -0
  7. package/dist/core/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.Internal.js +3 -0
  8. package/dist/core/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.js +100 -0
  9. package/dist/core/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.Internal.js +4 -0
  10. package/dist/core/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.js +136 -0
  11. package/dist/core/constraints/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.js +40 -0
  12. package/dist/core/constraints/UISingleParameterConstraint/UISingleParameterConstraint.js +71 -0
  13. package/dist/core/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.Internal.js +3 -0
  14. package/dist/core/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.js +100 -0
  15. package/dist/core/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.Internal.js +4 -0
  16. package/dist/core/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.js +136 -0
  17. package/dist/core/constraints/UIVerticalProportionConstraint/UIVerticalProportionConstraint.js +40 -0
  18. package/dist/core/constraints/UIWidthConstraint/UIWidthConstraint.js +34 -0
  19. package/dist/core/constraints/builders/UIConstraint2DBuilder.Internal.js +19 -0
  20. package/dist/core/constraints/builders/UIConstraint2DBuilder.js +138 -0
  21. package/dist/core/constraints/builders/UICoverConstraintBuilder.Internal.js +3 -0
  22. package/dist/core/constraints/builders/UICoverConstraintBuilder.js +63 -0
  23. package/dist/core/constraints/builders/UIFitConstraintBuilder.Internal.js +3 -0
  24. package/dist/core/constraints/builders/UIFitConstraintBuilder.js +63 -0
  25. package/dist/{elements → core/elements}/UIAnchor/UIAnchor.Internal.d.ts +3 -0
  26. package/dist/core/elements/UIAnchor/UIAnchor.Internal.js +5 -0
  27. package/dist/{elements → core/elements}/UIAnchor/UIAnchor.d.ts +3 -3
  28. package/dist/core/elements/UIAnchor/UIAnchor.js +49 -0
  29. package/dist/core/elements/UIAnimatedImage/UIAnimatedImage.Internal.js +15 -0
  30. package/dist/core/elements/UIAnimatedImage/UIAnimatedImage.js +259 -0
  31. package/dist/core/elements/UIDummy/UIDummy.Internal.js +8 -0
  32. package/dist/{elements → core/elements}/UIDummy/UIDummy.d.ts +2 -2
  33. package/dist/core/elements/UIDummy/UIDummy.js +173 -0
  34. package/dist/core/elements/UIElement/UIElement.Internal.js +5 -0
  35. package/dist/{elements → core/elements}/UIElement/UIElement.d.ts +2 -2
  36. package/dist/core/elements/UIElement/UIElement.js +74 -0
  37. package/dist/core/elements/UIGraphics/UIGraphics.Internal.js +7 -0
  38. package/dist/core/elements/UIGraphics/UIGraphics.js +126 -0
  39. package/dist/core/elements/UIImage/UIImage.js +85 -0
  40. package/dist/core/elements/UINineSlice/UINineSlice.Internal.js +12 -0
  41. package/dist/core/elements/UINineSlice/UINineSlice.js +188 -0
  42. package/dist/core/elements/UIProgress/UIProgress.Internal.js +3 -0
  43. package/dist/core/elements/UIProgress/UIProgress.js +165 -0
  44. package/dist/core/elements/UIScene/UIScene.Internal.js +27 -0
  45. package/dist/core/elements/UIScene/UIScene.js +157 -0
  46. package/dist/core/elements/UIText/UIText.Internal.js +12 -0
  47. package/dist/core/elements/UIText/UIText.Measuring.js +153 -0
  48. package/dist/core/elements/UIText/UIText.Rendering.js +61 -0
  49. package/dist/core/elements/UIText/UIText.js +265 -0
  50. package/dist/core/layers/UIFullscreenLayer/UIFullscreenLayer.Internal.js +5 -0
  51. package/dist/core/layers/UIFullscreenLayer/UIFullscreenLayer.js +147 -0
  52. package/dist/core/layers/UILayer/UILayer.Internal.js +7 -0
  53. package/dist/core/layers/UILayer/UILayer.js +113 -0
  54. package/dist/core/miscellaneous/UIExpression.js +128 -0
  55. package/dist/core/miscellaneous/UIMode.js +30 -0
  56. package/dist/core/miscellaneous/UIOrientation.js +20 -0
  57. package/dist/core/miscellaneous/UIPriority.js +63 -0
  58. package/dist/core/miscellaneous/UIRelation.js +40 -0
  59. package/dist/core/miscellaneous/UITransparencyMode.js +12 -0
  60. package/dist/core/miscellaneous/area/UIArea.js +5 -0
  61. package/dist/core/miscellaneous/area/UIAreaCircle.js +32 -0
  62. package/dist/core/miscellaneous/area/UIAreaPolygon.js +40 -0
  63. package/dist/core/miscellaneous/area/UIAreaRectangle.js +36 -0
  64. package/dist/core/miscellaneous/area/UIAreaRoundedRectangle.js +72 -0
  65. package/dist/core/miscellaneous/asserts.js +163 -0
  66. package/dist/core/miscellaneous/canvas.js +37 -0
  67. package/dist/core/miscellaneous/color/UIColor.Internal.js +42 -0
  68. package/dist/core/miscellaneous/color/UIColor.js +636 -0
  69. package/dist/core/miscellaneous/computeTransform.js +82 -0
  70. package/dist/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.Internal.js +168 -0
  71. package/dist/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.js +349 -0
  72. package/dist/core/miscellaneous/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.js +357 -0
  73. package/dist/core/miscellaneous/generic-plane/shared.js +228 -0
  74. package/dist/core/miscellaneous/insets/UIInsets.Internal.js +3 -0
  75. package/dist/core/miscellaneous/insets/UIInsets.js +224 -0
  76. package/dist/core/miscellaneous/mask-function/UIProgressMaskFunction.js +19 -0
  77. package/dist/core/miscellaneous/mask-function/UIProgressMaskFunctionCircular.js +51 -0
  78. package/dist/core/miscellaneous/mask-function/UIProgressMaskFunctionDirectional.js +48 -0
  79. package/dist/{miscellaneous → core/miscellaneous}/math.d.ts +2 -0
  80. package/dist/core/miscellaneous/math.js +11 -0
  81. package/dist/core/miscellaneous/micro/UIMicro.Internal.js +15 -0
  82. package/dist/core/miscellaneous/micro/UIMicro.js +181 -0
  83. package/dist/core/miscellaneous/resize-policy/UIResizePolicy.js +9 -0
  84. package/dist/core/miscellaneous/resize-policy/UIResizePolicyCover.js +50 -0
  85. package/dist/core/miscellaneous/resize-policy/UIResizePolicyCross.js +52 -0
  86. package/dist/core/miscellaneous/resize-policy/UIResizePolicyCrossInverted.js +52 -0
  87. package/dist/core/miscellaneous/resize-policy/UIResizePolicyFit.js +50 -0
  88. package/dist/core/miscellaneous/resize-policy/UIResizePolicyFixedHeight.js +52 -0
  89. package/dist/core/miscellaneous/resize-policy/UIResizePolicyFixedWidth.js +52 -0
  90. package/dist/core/miscellaneous/resize-policy/UIResizePolicyNone.js +13 -0
  91. package/dist/core/miscellaneous/shared.js +37 -0
  92. package/dist/core/miscellaneous/text-span/UITextSpan.js +36 -0
  93. package/dist/core/miscellaneous/text-style/UITextStyle.Internal.js +17 -0
  94. package/dist/core/miscellaneous/text-style/UITextStyle.js +372 -0
  95. package/dist/core/miscellaneous/texture/UITextureView.Internal.js +6 -0
  96. package/dist/core/miscellaneous/texture/UITextureView.js +234 -0
  97. package/dist/core/miscellaneous/webglCapabilities.js +103 -0
  98. package/dist/core/shaders/UIImage.glsl.js +3 -0
  99. package/dist/core/shaders/UINineSlice.glsl.js +3 -0
  100. package/dist/core/shaders/UIProgress.glsl.js +3 -0
  101. package/dist/core/shaders/UIProgressMaskFunctionCircular.glsl.js +3 -0
  102. package/dist/core/shaders/UIProgressMaskFunctionDirectional.glsl.js +3 -0
  103. package/dist/{wrappers → core/wrappers}/UIInputWrapper/UIInputWrapper.Internal.d.ts +1 -1
  104. package/dist/{wrappers → core/wrappers}/UIInputWrapper/UIInputWrapper.d.ts +2 -2
  105. package/dist/core/wrappers/UIInputWrapper/UIInputWrapper.js +108 -0
  106. package/dist/{wrappers → core/wrappers}/UISceneWrapper/UISceneWrapper.Internal.d.ts +1 -1
  107. package/dist/{wrappers → core/wrappers}/UISceneWrapper/UISceneWrapper.d.ts +2 -2
  108. package/dist/core/wrappers/UISceneWrapper/UISceneWrapper.js +75 -0
  109. package/dist/{wrappers → core/wrappers}/UISolverWrapper/UISolverWrapper.Internal.d.ts +1 -1
  110. package/dist/{wrappers → core/wrappers}/UISolverWrapper/UISolverWrapper.d.ts +2 -2
  111. package/dist/core/wrappers/UISolverWrapper/UISolverWrapper.js +505 -0
  112. package/dist/index.js +51 -9246
  113. package/dist/particles/behaviorModules/UIBehaviorDirectionalGravity.d.ts +21 -0
  114. package/dist/particles/behaviorModules/UIBehaviorDirectionalGravity.js +47 -0
  115. package/dist/particles/behaviorModules/UIBehaviorModule.d.ts +14 -0
  116. package/dist/particles/behaviorModules/UIBehaviorModule.js +9 -0
  117. package/dist/particles/behaviorModules/UIBehaviorPointGravity.d.ts +39 -0
  118. package/dist/particles/behaviorModules/UIBehaviorPointGravity.js +110 -0
  119. package/dist/particles/behaviorModules/UIBehaviorScaleOverLife.d.ts +22 -0
  120. package/dist/particles/behaviorModules/UIBehaviorScaleOverLife.js +66 -0
  121. package/dist/particles/behaviorModules/UIBehaviorTorqueDamping.d.ts +20 -0
  122. package/dist/particles/behaviorModules/UIBehaviorTorqueDamping.js +48 -0
  123. package/dist/particles/behaviorModules/UIBehaviorTorqueNoise.d.ts +26 -0
  124. package/dist/particles/behaviorModules/UIBehaviorTorqueNoise.js +66 -0
  125. package/dist/particles/behaviorModules/UIBehaviorVelocityDamping.d.ts +20 -0
  126. package/dist/particles/behaviorModules/UIBehaviorVelocityDamping.js +49 -0
  127. package/dist/particles/behaviorModules/UIBehaviorVelocityNoise.d.ts +26 -0
  128. package/dist/particles/behaviorModules/UIBehaviorVelocityNoise.js +70 -0
  129. package/dist/particles/elements/UIEmitter.Internal.d.ts +15 -0
  130. package/dist/particles/elements/UIEmitter.Internal.js +11 -0
  131. package/dist/particles/elements/UIEmitter.d.ts +68 -0
  132. package/dist/particles/elements/UIEmitter.js +203 -0
  133. package/dist/particles/index.d.ts +18 -0
  134. package/dist/particles/index.js +18 -0
  135. package/dist/particles/instancedParticle/UIInstancedParticle.Internal.d.ts +13 -0
  136. package/dist/particles/instancedParticle/UIInstancedParticle.Internal.js +211 -0
  137. package/dist/particles/instancedParticle/UIInstancedParticle.d.ts +17 -0
  138. package/dist/particles/instancedParticle/UIInstancedParticle.js +93 -0
  139. package/dist/particles/miscellaneous/miscellaneous.d.ts +32 -0
  140. package/dist/particles/miscellaneous/miscellaneous.js +67 -0
  141. package/dist/particles/renderingModules/UIRenderingColorOverLife.d.ts +14 -0
  142. package/dist/particles/renderingModules/UIRenderingColorOverLife.js +32 -0
  143. package/dist/particles/renderingModules/UIRenderingColorOverVelocity.d.ts +15 -0
  144. package/dist/particles/renderingModules/UIRenderingColorOverVelocity.js +37 -0
  145. package/dist/particles/renderingModules/UIRenderingModule.d.ts +8 -0
  146. package/dist/particles/renderingModules/UIRenderingModule.js +9 -0
  147. package/dist/particles/renderingModules/UIRenderingTexture.d.ts +14 -0
  148. package/dist/particles/renderingModules/UIRenderingTexture.js +26 -0
  149. package/dist/particles/shaders/UIRenderingColorOverLife.glsl.js +3 -0
  150. package/dist/particles/shaders/UIRenderingColorOverVelocity.glsl.js +3 -0
  151. package/dist/particles/shaders/UIRenderingTexture.glsl.js +3 -0
  152. package/dist/particles/spawnModules/UISpawnModule.d.ts +9 -0
  153. package/dist/particles/spawnModules/UISpawnModule.js +9 -0
  154. package/dist/particles/spawnModules/UISpawnOffset.d.ts +21 -0
  155. package/dist/particles/spawnModules/UISpawnOffset.js +46 -0
  156. package/dist/particles/spawnModules/UISpawnRandomLifetime.d.ts +20 -0
  157. package/dist/particles/spawnModules/UISpawnRandomLifetime.js +47 -0
  158. package/dist/particles/spawnModules/UISpawnRandomRotation.d.ts +20 -0
  159. package/dist/particles/spawnModules/UISpawnRandomRotation.js +45 -0
  160. package/dist/particles/spawnModules/UISpawnRandomScale.d.ts +26 -0
  161. package/dist/particles/spawnModules/UISpawnRandomScale.js +60 -0
  162. package/dist/particles/spawnModules/UISpawnRandomTorque.d.ts +20 -0
  163. package/dist/particles/spawnModules/UISpawnRandomTorque.js +45 -0
  164. package/dist/particles/spawnModules/UISpawnRandomVelocity.d.ts +26 -0
  165. package/dist/particles/spawnModules/UISpawnRandomVelocity.js +64 -0
  166. package/dist/particles/spawnModules/UISpawnRectangle.d.ts +27 -0
  167. package/dist/particles/spawnModules/UISpawnRectangle.js +62 -0
  168. package/package.json +27 -36
  169. package/dist/index.js.map +0 -1
  170. package/dist/index.min.js +0 -2
  171. package/dist/index.min.js.map +0 -1
  172. /package/dist/{constraints → core/constraints}/UIAspectConstraint/UIAspectConstraint.Internal.d.ts +0 -0
  173. /package/dist/{constraints → core/constraints}/UIAspectConstraint/UIAspectConstraint.d.ts +0 -0
  174. /package/dist/{constraints → core/constraints}/UICustomConstraint.d.ts +0 -0
  175. /package/dist/{constraints → core/constraints}/UIHeightConstraint/UIHeightConstraint.Internal.d.ts +0 -0
  176. /package/dist/{constraints → core/constraints}/UIHeightConstraint/UIHeightConstraint.d.ts +0 -0
  177. /package/dist/{constraints → core/constraints}/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.Internal.d.ts +0 -0
  178. /package/dist/{constraints → core/constraints}/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.d.ts +0 -0
  179. /package/dist/{constraints → core/constraints}/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.Internal.d.ts +0 -0
  180. /package/dist/{constraints → core/constraints}/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.d.ts +0 -0
  181. /package/dist/{constraints → core/constraints}/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.Internal.d.ts +0 -0
  182. /package/dist/{constraints → core/constraints}/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.d.ts +0 -0
  183. /package/dist/{constraints → core/constraints}/UISingleParameterConstraint/UISingleParameterConstraint.Internal.d.ts +0 -0
  184. /package/dist/{constraints → core/constraints}/UISingleParameterConstraint/UISingleParameterConstraint.d.ts +0 -0
  185. /package/dist/{constraints → core/constraints}/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.Internal.d.ts +0 -0
  186. /package/dist/{constraints → core/constraints}/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.d.ts +0 -0
  187. /package/dist/{constraints → core/constraints}/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.Internal.d.ts +0 -0
  188. /package/dist/{constraints → core/constraints}/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.d.ts +0 -0
  189. /package/dist/{constraints → core/constraints}/UIVerticalProportionConstraint/UIVerticalProportionConstraint.Internal.d.ts +0 -0
  190. /package/dist/{constraints → core/constraints}/UIVerticalProportionConstraint/UIVerticalProportionConstraint.d.ts +0 -0
  191. /package/dist/{constraints → core/constraints}/UIWidthConstraint/UIWidthConstraint.Internal.d.ts +0 -0
  192. /package/dist/{constraints → core/constraints}/UIWidthConstraint/UIWidthConstraint.d.ts +0 -0
  193. /package/dist/{constraints → core/constraints}/builders/UIConstraint2DBuilder.Internal.d.ts +0 -0
  194. /package/dist/{constraints → core/constraints}/builders/UIConstraint2DBuilder.d.ts +0 -0
  195. /package/dist/{constraints → core/constraints}/builders/UICoverConstraintBuilder.Internal.d.ts +0 -0
  196. /package/dist/{constraints → core/constraints}/builders/UICoverConstraintBuilder.d.ts +0 -0
  197. /package/dist/{constraints → core/constraints}/builders/UIFitConstraintBuilder.Internal.d.ts +0 -0
  198. /package/dist/{constraints → core/constraints}/builders/UIFitConstraintBuilder.d.ts +0 -0
  199. /package/dist/{elements → core/elements}/UIAnimatedImage/UIAnimatedImage.Internal.d.ts +0 -0
  200. /package/dist/{elements → core/elements}/UIAnimatedImage/UIAnimatedImage.d.ts +0 -0
  201. /package/dist/{elements → core/elements}/UIDummy/UIDummy.Internal.d.ts +0 -0
  202. /package/dist/{elements → core/elements}/UIElement/UIElement.Internal.d.ts +0 -0
  203. /package/dist/{elements → core/elements}/UIGraphics/UIGraphics.Internal.d.ts +0 -0
  204. /package/dist/{elements → core/elements}/UIGraphics/UIGraphics.d.ts +0 -0
  205. /package/dist/{elements → core/elements}/UIImage/UIImage.Internal.d.ts +0 -0
  206. /package/dist/{elements → core/elements}/UIImage/UIImage.d.ts +0 -0
  207. /package/dist/{elements → core/elements}/UINineSlice/UINineSlice.Internal.d.ts +0 -0
  208. /package/dist/{elements → core/elements}/UINineSlice/UINineSlice.d.ts +0 -0
  209. /package/dist/{elements → core/elements}/UIProgress/UIProgress.Internal.d.ts +0 -0
  210. /package/dist/{elements → core/elements}/UIProgress/UIProgress.d.ts +0 -0
  211. /package/dist/{elements → core/elements}/UIScene/UIScene.Internal.d.ts +0 -0
  212. /package/dist/{elements → core/elements}/UIScene/UIScene.d.ts +0 -0
  213. /package/dist/{elements → core/elements}/UIText/UIText.Interfaces.d.ts +0 -0
  214. /package/dist/{elements → core/elements}/UIText/UIText.Internal.d.ts +0 -0
  215. /package/dist/{elements → core/elements}/UIText/UIText.Measuring.d.ts +0 -0
  216. /package/dist/{elements → core/elements}/UIText/UIText.Rendering.d.ts +0 -0
  217. /package/dist/{elements → core/elements}/UIText/UIText.d.ts +0 -0
  218. /package/dist/{index.d.ts → core/index.d.ts} +0 -0
  219. /package/dist/{layers → core/layers}/UIFullscreenLayer/UIFullscreenLayer.Internal.d.ts +0 -0
  220. /package/dist/{layers → core/layers}/UIFullscreenLayer/UIFullscreenLayer.d.ts +0 -0
  221. /package/dist/{layers → core/layers}/UILayer/UILayer.Internal.d.ts +0 -0
  222. /package/dist/{layers → core/layers}/UILayer/UILayer.d.ts +0 -0
  223. /package/dist/{miscellaneous → core/miscellaneous}/UIExpression.d.ts +0 -0
  224. /package/dist/{miscellaneous → core/miscellaneous}/UIMode.d.ts +0 -0
  225. /package/dist/{miscellaneous → core/miscellaneous}/UIOrientation.d.ts +0 -0
  226. /package/dist/{miscellaneous → core/miscellaneous}/UIPriority.d.ts +0 -0
  227. /package/dist/{miscellaneous → core/miscellaneous}/UIRelation.d.ts +0 -0
  228. /package/dist/{miscellaneous → core/miscellaneous}/UITransparencyMode.d.ts +0 -0
  229. /package/dist/{miscellaneous → core/miscellaneous}/area/UIArea.d.ts +0 -0
  230. /package/dist/{miscellaneous → core/miscellaneous}/area/UIAreaCircle.d.ts +0 -0
  231. /package/dist/{miscellaneous → core/miscellaneous}/area/UIAreaPolygon.d.ts +0 -0
  232. /package/dist/{miscellaneous → core/miscellaneous}/area/UIAreaRectangle.d.ts +0 -0
  233. /package/dist/{miscellaneous → core/miscellaneous}/area/UIAreaRoundedRectangle.d.ts +0 -0
  234. /package/dist/{miscellaneous → core/miscellaneous}/asserts.d.ts +0 -0
  235. /package/dist/{miscellaneous → core/miscellaneous}/canvas.d.ts +0 -0
  236. /package/dist/{miscellaneous → core/miscellaneous}/color/UIColor.Internal.d.ts +0 -0
  237. /package/dist/{miscellaneous → core/miscellaneous}/color/UIColor.d.ts +0 -0
  238. /package/dist/{miscellaneous → core/miscellaneous}/computeTransform.d.ts +0 -0
  239. /package/dist/{miscellaneous → core/miscellaneous}/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.Internal.d.ts +0 -0
  240. /package/dist/{miscellaneous → core/miscellaneous}/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.d.ts +0 -0
  241. /package/dist/{miscellaneous → core/miscellaneous}/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.Internal.d.ts +0 -0
  242. /package/dist/{miscellaneous → core/miscellaneous}/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.d.ts +0 -0
  243. /package/dist/{miscellaneous → core/miscellaneous}/generic-plane/shared.d.ts +0 -0
  244. /package/dist/{miscellaneous → core/miscellaneous}/insets/UIInsets.Internal.d.ts +0 -0
  245. /package/dist/{miscellaneous → core/miscellaneous}/insets/UIInsets.d.ts +0 -0
  246. /package/dist/{miscellaneous → core/miscellaneous}/mask-function/UIProgressMaskFunction.d.ts +0 -0
  247. /package/dist/{miscellaneous → core/miscellaneous}/mask-function/UIProgressMaskFunctionCircular.d.ts +0 -0
  248. /package/dist/{miscellaneous → core/miscellaneous}/mask-function/UIProgressMaskFunctionDirectional.d.ts +0 -0
  249. /package/dist/{miscellaneous → core/miscellaneous}/micro/UIMicro.Internal.d.ts +0 -0
  250. /package/dist/{miscellaneous → core/miscellaneous}/micro/UIMicro.d.ts +0 -0
  251. /package/dist/{miscellaneous → core/miscellaneous}/resize-policy/UIResizePolicy.d.ts +0 -0
  252. /package/dist/{miscellaneous → core/miscellaneous}/resize-policy/UIResizePolicyCover.d.ts +0 -0
  253. /package/dist/{miscellaneous → core/miscellaneous}/resize-policy/UIResizePolicyCross.d.ts +0 -0
  254. /package/dist/{miscellaneous → core/miscellaneous}/resize-policy/UIResizePolicyCrossInverted.d.ts +0 -0
  255. /package/dist/{miscellaneous → core/miscellaneous}/resize-policy/UIResizePolicyFit.d.ts +0 -0
  256. /package/dist/{miscellaneous → core/miscellaneous}/resize-policy/UIResizePolicyFixedHeight.d.ts +0 -0
  257. /package/dist/{miscellaneous → core/miscellaneous}/resize-policy/UIResizePolicyFixedWidth.d.ts +0 -0
  258. /package/dist/{miscellaneous → core/miscellaneous}/resize-policy/UIResizePolicyNone.d.ts +0 -0
  259. /package/dist/{miscellaneous → core/miscellaneous}/shared.d.ts +0 -0
  260. /package/dist/{miscellaneous → core/miscellaneous}/text-span/UITextSpan.Internal.d.ts +0 -0
  261. /package/dist/{miscellaneous → core/miscellaneous}/text-span/UITextSpan.d.ts +0 -0
  262. /package/dist/{miscellaneous → core/miscellaneous}/text-style/UITextStyle.Internal.d.ts +0 -0
  263. /package/dist/{miscellaneous → core/miscellaneous}/text-style/UITextStyle.d.ts +0 -0
  264. /package/dist/{miscellaneous → core/miscellaneous}/texture/UITextureView.Internal.d.ts +0 -0
  265. /package/dist/{miscellaneous → core/miscellaneous}/texture/UITextureView.d.ts +0 -0
  266. /package/dist/{miscellaneous → core/miscellaneous}/webglCapabilities.d.ts +0 -0
package/README.md CHANGED
@@ -1,32 +1,25 @@
1
1
  <p align="center">
2
+ <img src="./assets/logotype.png" width="200" alt="Laymur logo"><br/>
2
3
  <h1 align="center">Laymur</h1>
3
4
  <p align="center">
4
- A constraint-based UI library for Three.js mobile advertisements
5
+ Constraint-based UI library for Three.js.<br/>
6
+ Primarily built for mobile advertisements (playable ads).
5
7
  </p>
6
8
  </p>
7
-
8
9
  <p align="center">
9
- <a href="https://www.npmjs.com/package/laymur"><img src="https://img.shields.io/npm/v/laymur.svg" alt="npm version"></a>
10
- <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT"></a>
11
- <a href="https://www.typescriptlang.org/"><img src="https://img.shields.io/badge/TypeScript-%5E5.8.0-blue" alt="TypeScript"></a>
12
- <a href="https://threejs.org/"><img src="https://img.shields.io/badge/Three.js-0.157.0--0.180.0-green" alt="Three.js"></a>
10
+ <a href="https://www.npmjs.com/package/laymur"><img src="https://img.shields.io/npm/v/laymur.svg" alt="npm version"></a>
11
+ <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT"></a>
12
+ <a href="https://www.typescriptlang.org/"><img src="https://img.shields.io/badge/TypeScript-%5E5.8.0-blue" alt="TypeScript"></a>
13
+ <a href="https://threejs.org/"><img src="https://img.shields.io/badge/Three.js-0.157.0--0.180.0-green" alt="Three.js"></a>
13
14
  </p>
14
15
 
15
- ⚠️ **Early Alpha / Work in Progress** ⚠️
16
-
17
- This library is in early development. APIs may change.
18
-
19
- ## What it does
20
-
21
- A compact UI library designed for Three.js mobile advertisements where bundle size matters. Uses constraint-based positioning to handle responsive layouts across different screen sizes and orientations.
16
+ ## Features
22
17
 
23
- - 📱 Constraint-based layout system
24
- - 🖼️ Basic UI elements (images, text, progress bars)
25
- - 📐 Responsive design for mobile ads
26
- - 🎯 Lightweight animations
27
- - 📦 TypeScript support
28
-
29
- Originally built for mobile ad development scenarios where you need to keep the bundle small while supporting various screen configurations.
18
+ * **Cassowary solver** — constraint-based layouts via `@lume/kiwi`
19
+ * **Orientation-aware** — define portrait and landscape rules in one layout, solver toggles automatically
20
+ * **Micro-transforms** — visual-only transforms (scale, rotation, offset) that bypass the solver
21
+ * **Resize policies** — Cover, Fit, FixedHeight, FixedWidth, Cross strategies
22
+ * **Modular particles** — separate `laymur/particles` entry point, import only if needed
30
23
 
31
24
  ## Installation
32
25
 
@@ -34,235 +27,118 @@ Originally built for mobile ad development scenarios where you need to keep the
34
27
  npm install laymur
35
28
  ```
36
29
 
37
- Requires Three.js >=0.175.0 <0.180.0 as a peer dependency.
38
-
39
- ## Quick Example
40
-
41
- ```typescript
42
- import { UIFullscreenLayer, UIImage, UIText } from "laymur";
43
- import { WebGLRenderer, TextureLoader, Clock } from "three";
44
-
45
- const renderer = new WebGLRenderer();
46
- const layer = new UIFullscreenLayer();
47
- const clock = new Clock();
48
-
49
- const texture = new TextureLoader().load("background.jpg");
50
- const background = new UIImage(layer, texture, { x: 0, y: 0 });
51
- const title = new UIText(layer, "Mobile Ad Title", {
52
- x: 100,
53
- y: 100,
54
- maxLineWidth: 800,
55
- });
56
-
57
- function animate() {
58
- layer.render(renderer, clock.getDelta());
59
- requestAnimationFrame(animate);
60
- }
61
-
62
- animate();
63
- ```
64
-
65
- ## Basic Components
66
-
67
- ### Layers
68
-
69
- - **UIFullscreenLayer** - Handles browser window scaling
30
+ Peer Dependencies:
70
31
 
71
- ### Elements
32
+ * `three` (>=0.157.0 <0.180.0)
33
+ * `@lume/kiwi` (^0.4.4)
34
+ * `ferrsign` (^0.0.4)
72
35
 
73
- - **UIImage** - Display textures
74
- - **UIAnimatedImage** - Animated texture sequences
75
- - **UIText** - Text rendering with word wrapping and styled spans
76
- - **UIGraphics** - Vector graphics and shapes
77
- - **UIScene** - Embed 3D scenes
78
- - **UIProgress** - Progress bars
79
- - **UINineSlice** - Scalable UI panels with border preservation
80
- - **UIAnchor** - Positioning points
36
+ ## Core Concepts
81
37
 
82
- ### Constraints
83
-
84
- - **UIWidthConstraint** / **UIHeightConstraint** - Fixed sizes
85
- - **UIAspectConstraint** - Maintain aspect ratios
86
- - **UIHorizontalDistanceConstraint** / **UIVerticalDistanceConstraint** - Spacing between elements
87
- - **UIHorizontalProportionConstraint** / **UIVerticalProportionConstraint** - Proportional sizing
88
- - **UIHorizontalInterpolationConstraint** / **UIVerticalInterpolationConstraint** - Position element between two anchors
89
- - **UICustomConstraint** - Custom constraint expressions
90
- - **UIFitConstraintBuilder** - Fit element inside container (like CSS object-fit: contain)
91
- - **UICoverConstraintBuilder** - Cover container with element (like CSS object-fit: cover)
38
+ ### 1. Layers & Elements
92
39
 
93
- ## Constraint Layout
94
-
95
- The constraint system automatically calculates positions and sizes based on relationships you define:
40
+ `UIFullscreenLayer` manages coordinate system, canvas scaling, and input. All UI elements attach to a layer.
96
41
 
97
42
  ```typescript
98
- import { UIImage, UIHorizontalDistanceConstraint, UIWidthConstraint } from "laymur";
99
-
100
- const sidebar = new UIImage(layer, sidebarTexture, { x: 0, y: 0 });
101
- const content = new UIImage(layer, contentTexture, { x: 0, y: 0 });
43
+ import { UIFullscreenLayer, UIImage, UIMode, UIResizePolicyFixedHeight } from 'laymur';
102
44
 
103
- // Fixed sidebar width
104
- new UIWidthConstraint(sidebar, { width: 300 });
105
-
106
- // 20px spacing between sidebar and content
107
- new UIHorizontalDistanceConstraint(sidebar, content, {
108
- distance: 20,
109
- anchorA: 1.0, // Right edge of sidebar
110
- anchorB: 0.0, // Left edge of content
45
+ const layer = new UIFullscreenLayer({
46
+ name: "MainHUD",
47
+ mode: UIMode.VISIBLE,
48
+ resizePolicy: new UIResizePolicyFixedHeight(1080, 1920)
111
49
  });
112
50
  ```
113
51
 
114
- ## Text Rendering
115
-
116
- Text supports styled spans with different fonts, sizes, and colors:
117
-
118
- ```typescript
119
- import { UIText } from "laymur";
120
-
121
- const text = new UIText(
122
- layer,
123
- [
124
- { text: "Download ", style: { fontSize: 24, color: "#333333" } },
125
- { text: "Now!", style: { fontSize: 32, color: "#ff0000", fontWeight: "bold" } },
126
- ],
127
- {
128
- x: 100,
129
- y: 100,
130
- maxLineWidth: 600,
131
- },
132
- );
133
- ```
134
-
135
- ## Transformations
136
-
137
- Apply visual transformations without affecting the constraint layout:
138
-
139
- ```typescript
140
- const element = new UIImage(layer, texture, { x: 0, y: 0 });
141
-
142
- // Apply transformations for animations
143
- element.micro.x = 10;
144
- element.micro.scaleX = 1.2;
145
- element.micro.rotation = 0.1;
146
- element.micro.anchorX = 0.5; // Transform origin (0 = left/bottom, 0.5 = center, 1 = right/top)
147
-
148
- // Reset all transformations
149
- element.micro.reset();
150
- ```
151
-
152
- ## Event Handling
52
+ ### 2. Constraint System
153
53
 
154
- UI elements and layers use type-safe signals for event handling via [Ferrsign](https://github.com/jango-git/ferrsign).
155
-
156
- ### Element Input Events
157
-
158
- Elements with area (width and height) can emit input events:
54
+ Cassowary-based constraint solver. Supports priorities, element relationships, orientation-specific rules, and inequality relations.
159
55
 
160
56
  ```typescript
161
- import { UIMode } from "laymur";
162
- import type { UIInputEventData } from "laymur";
163
-
164
- const button = new UIImage(layer, buttonTexture, {
165
- x: 0,
166
- y: 0,
167
- mode: UIMode.INTERACTIVE,
168
- });
169
-
170
- button.signalPressed.on((data: UIInputEventData) => {
171
- console.log("Button pressed at", data.x, data.y);
172
- console.log("Element:", data.element);
173
- });
174
-
175
- button.signalReleased.on((data: UIInputEventData) => {
176
- console.log("Button released");
177
- });
178
-
179
- button.signalEntered.on((data: UIInputEventData) => {
180
- console.log("Pointer entered button");
57
+ import {
58
+ UIHorizontalDistanceConstraint,
59
+ UIVerticalProportionConstraint,
60
+ UIAspectConstraint,
61
+ UIOrientation,
62
+ UIPriority,
63
+ UIRelation
64
+ } from 'laymur';
65
+
66
+ // Lock aspect ratio
67
+ new UIAspectConstraint(element);
68
+
69
+ // Position relative to layer center
70
+ new UIHorizontalDistanceConstraint(layer, element, {
71
+ anchorA: 0.5,
72
+ anchorB: 0.5,
181
73
  });
182
74
 
183
- button.signalLeft.on((data: UIInputEventData) => {
184
- console.log("Pointer left button");
75
+ // Size as proportion of layer, landscape only
76
+ new UIVerticalProportionConstraint(layer, element, {
77
+ proportion: 0.4,
78
+ orientation: UIOrientation.HORIZONTAL,
79
+ priority: UIPriority.P1,
185
80
  });
186
81
 
187
- button.signalMoved.on((data: UIInputEventData) => {
188
- console.log("Pointer moved inside button");
82
+ // Max width constraint
83
+ new UIHorizontalProportionConstraint(layer, element, {
84
+ proportion: 0.8,
85
+ relation: UIRelation.LESS_THAN,
189
86
  });
190
87
  ```
191
88
 
192
- ### Layer Events
89
+ ### 3. Micro-transforms
193
90
 
194
- Fullscreen layers emit input events:
91
+ For animations, use `.micro` — updates visual matrix without triggering the solver.
195
92
 
196
93
  ```typescript
197
- import type { UIFullscreenLayerInputEventData } from "laymur";
198
-
199
- layer.signalPointerPressed.on((data: UIFullscreenLayerInputEventData) => {
200
- console.log("Layer pressed at", data.x, data.y);
201
- console.log("Layer:", data.layer);
202
- });
203
-
204
- layer.signalPointerMoved.on((data: UIFullscreenLayerInputEventData) => {
205
- console.log("Pointer moved to", data.x, data.y);
206
- });
207
-
208
- layer.signalPointerReleased.on((data: UIFullscreenLayerInputEventData) => {
209
- console.log("Pointer released");
210
- });
94
+ element.micro.scaleX = Math.sin(Date.now() * 0.001) + 1;
95
+ element.micro.rotation += 0.01;
211
96
  ```
212
97
 
213
- ### Animation Events
98
+ ### 4. Particle System
214
99
 
215
- Animated images emit playback events:
100
+ Modular pipeline: Spawn → Behavior → Rendering.
216
101
 
217
102
  ```typescript
218
- const animation = new UIAnimatedImage(layer, frames);
219
-
220
- animation.signalPlayed.on(() => {
221
- console.log("Animation started or resumed");
222
- });
103
+ import { UIEmitter, UISpawnRectangle, UIBehaviorDirectionalGravity, UIRenderingTexture } from 'laymur/particles';
223
104
 
224
- animation.signalPaused.on(() => {
225
- console.log("Animation paused");
226
- });
105
+ const emitter = new UIEmitter(
106
+ layer,
107
+ [new UISpawnRectangle([-500, 0], [500, 0])],
108
+ [new UIBehaviorDirectionalGravity({ x: 0, y: 100 })],
109
+ [new UIRenderingTexture(particleTexture)],
110
+ { expectedCapacity: 1024 } // Pre-allocation hint, not a hard limit
111
+ );
227
112
 
228
- animation.signalStopped.on(() => {
229
- console.log("Animation stopped and reset");
230
- });
113
+ emitter.play(60); // particles/sec
231
114
  ```
232
115
 
233
- ### Unsubscribing from Events
234
-
235
- ```typescript
236
- const handler = (data: UIInputEventData) => {
237
- console.log("Pressed!");
238
- };
116
+ ## API Overview
239
117
 
240
- button.signalPressed.on(handler);
241
- button.signalPressed.off(handler); // Unsubscribe
242
- ```
118
+ Most commonly used exports (not exhaustive):
243
119
 
244
- ## Live Examples
120
+ ### Core
245
121
 
246
- 🎮 **[Live Examples](https://jango-git.github.io/laymur/)** - See constraint-based layouts and responsive components in action.
122
+ UIFullscreenLayer, UIImage, UIAnimatedImage, UIText, UINineSlice, UIProgress
247
123
 
248
- ## Addons
124
+ ### Constraints
249
125
 
250
- ### laymur-animations
126
+ UIAspectConstraint, UIHorizontalDistanceConstraint, UIVerticalDistanceConstraint, UIHorizontalProportionConstraint, UIVerticalProportionConstraint, UICoverConstraintBuilder, UIFitConstraintBuilder
251
127
 
252
- Animation library built on GSAP for common UI effects:
128
+ ### Particles (laymur/particles)
253
129
 
254
- - **GitHub**: [https://github.com/jango-git/laymur-animations](https://github.com/jango-git/laymur-animations)
255
- - **NPM**: [https://www.npmjs.com/package/laymur-animations](https://www.npmjs.com/package/laymur-animations)
130
+ UIEmitter, UISpawnRectangle, UISpawnRandomLifetime, UIBehaviorDirectionalGravity, UIBehaviorVelocityDamping, UIRenderingTexture, UIRenderingColorOverLife
256
131
 
257
- ## Notes
132
+ ## Entry Points
258
133
 
259
- - This was built specifically for mobile ad development where bundle size is important
260
- - The constraint solver is based on Cassowary algorithm via Kiwi.js
261
- - Currently in alpha - expect API changes
262
- - Works best for relatively simple UI layouts
134
+ ```json
135
+ // package.json
136
+ "exports": {
137
+ ".": "./dist/index.js",
138
+ "./particles": "./dist/particles/index.js"
139
+ }
140
+ ```
263
141
 
264
142
  ## License
265
143
 
266
- MIT © [jango](https://github.com/jango-git)
267
-
268
- Uses [Kiwi.js](https://github.com/lume/kiwi) (BSD-3-Clause) for constraint solving and [Three.js](https://threejs.org/) (MIT) for 3D rendering.
144
+ MIT © jango
@@ -0,0 +1,41 @@
1
+ import { assertValidPositiveNumber } from '../../miscellaneous/asserts.js';
2
+ import { UIExpression } from '../../miscellaneous/UIExpression.js';
3
+ import { UISingleParameterConstraint } from '../UISingleParameterConstraint/UISingleParameterConstraint.js';
4
+
5
+ /** Maintains element aspect ratio (width = height * aspect) */
6
+ class UIAspectConstraint extends UISingleParameterConstraint {
7
+ /**
8
+ * @param element Element to constrain
9
+ * @param options Aspect configuration. Defaults to element's current ratio.
10
+ */
11
+ constructor(_private_element, options = {}) {
12
+ if (options.aspect !== undefined) {
13
+ assertValidPositiveNumber(options.aspect, "UIAspectConstraint.constructor.options.aspect");
14
+ }
15
+ super(_private_element.layer, options);
16
+ this._private_element = _private_element;
17
+ this._private_aspectInternal = options.aspect ?? _private_element.width / _private_element.height;
18
+ this.constraint = this.solverWrapper.createConstraint(this._private_buildLHS(), new UIExpression(0), this.relation, this.priority, this.isConstraintEnabled());
19
+ }
20
+ /** Current aspect ratio (width/height) */
21
+ get aspect() {
22
+ return this._private_aspectInternal;
23
+ }
24
+ /** Updates aspect ratio */
25
+ set aspect(value) {
26
+ assertValidPositiveNumber(value, "UIAspectConstraint.aspect");
27
+ if (this._private_aspectInternal !== value) {
28
+ this._private_aspectInternal = value;
29
+ this.solverWrapper.setConstraintLHS(this.constraint, this._private_buildLHS());
30
+ }
31
+ }
32
+ /** Builds constraint expression: width - (height * aspect) = 0 */
33
+ _private_buildLHS() {
34
+ return new UIExpression(0, [
35
+ [this._private_element.wVariable, 1],
36
+ [this._private_element.hVariable, -this._private_aspectInternal],
37
+ ]);
38
+ }
39
+ }
40
+
41
+ export { UIAspectConstraint };
@@ -1,12 +1,12 @@
1
1
  import type { UILayer } from "../layers/UILayer/UILayer";
2
- import type { UISolverWrapperInterface } from "../wrappers/UISolverWrapper/UISolverWrapper.Internal";
2
+ import type { UISolverWrapperView } from "../wrappers/UISolverWrapper/UISolverWrapper.Internal";
3
3
  /** Base class for layout constraints */
4
4
  export declare abstract class UIConstraint {
5
5
  readonly layer: UILayer;
6
6
  /** Optional constraint name */
7
7
  name: string;
8
8
  /** Constraint solver wrapper */
9
- protected readonly solverWrapper: UISolverWrapperInterface;
9
+ protected readonly solverWrapper: UISolverWrapperView;
10
10
  /** @param layer Layer containing this constraint */
11
11
  constructor(layer: UILayer, name?: string);
12
12
  }
@@ -0,0 +1,11 @@
1
+ /** Base class for layout constraints */
2
+ class UIConstraint {
3
+ /** @param layer Layer containing this constraint */
4
+ constructor(layer, name) {
5
+ this.layer = layer;
6
+ this.solverWrapper = this.layer.solverWrapper;
7
+ this.name = name ?? "";
8
+ }
9
+ }
10
+
11
+ export { UIConstraint };
@@ -0,0 +1,37 @@
1
+ import { UISingleParameterConstraint } from './UISingleParameterConstraint/UISingleParameterConstraint.js';
2
+
3
+ /** Constraint with custom LHS and RHS expressions */
4
+ class UICustomConstraint extends UISingleParameterConstraint {
5
+ /**
6
+ * @param layer Layer containing this constraint
7
+ * @param lhs Left-hand side expression
8
+ * @param rhs Right-hand side expression
9
+ * @param options Constraint configuration
10
+ */
11
+ constructor(layer, lhs, rhs, options = {}) {
12
+ super(layer, options);
13
+ this._private_lhsInternal = lhs;
14
+ this._private_rhsInternal = rhs;
15
+ this.constraint = this.solverWrapper.createConstraint(this._private_lhsInternal, this._private_rhsInternal, this.relation, this.priority, this.isConstraintEnabled());
16
+ }
17
+ /** Left-hand side expression */
18
+ get lhs() {
19
+ return this._private_lhsInternal;
20
+ }
21
+ /** Right-hand side expression */
22
+ get rhs() {
23
+ return this._private_rhsInternal;
24
+ }
25
+ /** Updates left-hand side expression */
26
+ setLHS(value) {
27
+ this._private_lhsInternal = value;
28
+ this.solverWrapper.setConstraintLHS(this.constraint, this._private_lhsInternal);
29
+ }
30
+ /** Updates right-hand side expression */
31
+ setRHS(value) {
32
+ this._private_rhsInternal = value;
33
+ this.solverWrapper.setConstraintRHS(this.constraint, this._private_rhsInternal);
34
+ }
35
+ }
36
+
37
+ export { UICustomConstraint };
@@ -0,0 +1,34 @@
1
+ import { assertValidPositiveNumber } from '../../miscellaneous/asserts.js';
2
+ import { UIExpression } from '../../miscellaneous/UIExpression.js';
3
+ import { UISingleParameterConstraint } from '../UISingleParameterConstraint/UISingleParameterConstraint.js';
4
+
5
+ /** Fixes element height to constant value */
6
+ class UIHeightConstraint extends UISingleParameterConstraint {
7
+ /**
8
+ * @param element Element to constrain
9
+ * @param options Height configuration. Defaults to element's current height.
10
+ */
11
+ constructor(_private_element, options = {}) {
12
+ if (options.height !== undefined) {
13
+ assertValidPositiveNumber(options.height, "UIHeightConstraint.constructor.options.height");
14
+ }
15
+ super(_private_element.layer, options);
16
+ this._private_element = _private_element;
17
+ this._private_heightInternal = options.height ?? _private_element.height;
18
+ this.constraint = this.solverWrapper.createConstraint(new UIExpression(0, [[this._private_element.hVariable, 1]]), new UIExpression(this._private_heightInternal), this.relation, this.priority, this.isConstraintEnabled());
19
+ }
20
+ /** Current height in world units */
21
+ get height() {
22
+ return this._private_heightInternal;
23
+ }
24
+ /** Updates height */
25
+ set height(value) {
26
+ assertValidPositiveNumber(value, "UIHeightConstraint.height");
27
+ if (this._private_heightInternal !== value) {
28
+ this._private_heightInternal = value;
29
+ this.solverWrapper.setConstraintRHS(this.constraint, new UIExpression(value));
30
+ }
31
+ }
32
+ }
33
+
34
+ export { UIHeightConstraint };
@@ -0,0 +1,3 @@
1
+ const DEFAULT_ANCHOR = 0.5;
2
+
3
+ export { DEFAULT_ANCHOR };
@@ -0,0 +1,100 @@
1
+ import { assertValidNumber, assertValidConstraintArguments } from '../../miscellaneous/asserts.js';
2
+ import { isUIPlaneElement, isUIPointElement } from '../../miscellaneous/shared.js';
3
+ import { UIExpression } from '../../miscellaneous/UIExpression.js';
4
+ import { UISingleParameterConstraint } from '../UISingleParameterConstraint/UISingleParameterConstraint.js';
5
+ import { DEFAULT_ANCHOR } from './UIHorizontalDistanceConstraint.Internal.js';
6
+
7
+ /** Maintains horizontal distance between elements with configurable anchors */
8
+ class UIHorizontalDistanceConstraint extends UISingleParameterConstraint {
9
+ /**
10
+ * @param a First element
11
+ * @param b Second element
12
+ * @param options Distance configuration
13
+ */
14
+ constructor(_private_a, _private_b, options = {}) {
15
+ if (options.anchorA !== undefined) {
16
+ assertValidNumber(options.anchorA, "UIHorizontalDistanceConstraint.constructor.options.anchorA");
17
+ }
18
+ if (options.anchorB !== undefined) {
19
+ assertValidNumber(options.anchorB, "UIHorizontalDistanceConstraint.constructor.options.anchorB");
20
+ }
21
+ if (options.distance !== undefined) {
22
+ assertValidNumber(options.distance, "UIHorizontalDistanceConstraint.constructor.options.distance");
23
+ }
24
+ super(assertValidConstraintArguments(_private_a, _private_b, "UIHorizontalDistanceConstraint.constructor"), options);
25
+ this._private_a = _private_a;
26
+ this._private_b = _private_b;
27
+ this._private_anchorAInternal = options.anchorA ?? DEFAULT_ANCHOR;
28
+ this._private_anchorBInternal = options.anchorB ?? DEFAULT_ANCHOR;
29
+ this._private_distanceInternal = options.distance ?? 0;
30
+ this.constraint = this.solverWrapper.createConstraint(this._private_buildLHS(), new UIExpression(this._private_distanceInternal), this.relation, this.priority, this.isConstraintEnabled());
31
+ }
32
+ /** Current distance in world units */
33
+ get distance() {
34
+ return this._private_distanceInternal;
35
+ }
36
+ /** Anchor on element A (0 = left, 0.5 = center, 1 = right) */
37
+ get anchorA() {
38
+ return this._private_anchorAInternal;
39
+ }
40
+ /** Anchor on element B (0 = left, 0.5 = center, 1 = right) */
41
+ get anchorB() {
42
+ return this._private_anchorBInternal;
43
+ }
44
+ /** Updates distance */
45
+ set distance(value) {
46
+ assertValidNumber(value, "UIHorizontalDistanceConstraint.distance");
47
+ if (this._private_distanceInternal !== value) {
48
+ this._private_distanceInternal = value;
49
+ this.solverWrapper.setConstraintRHS(this.constraint, new UIExpression(this._private_distanceInternal));
50
+ }
51
+ }
52
+ /** Updates anchor on element A */
53
+ set anchorA(value) {
54
+ assertValidNumber(value, "UIHorizontalDistanceConstraint.anchorA");
55
+ if (this._private_anchorAInternal !== value) {
56
+ this._private_anchorAInternal = value;
57
+ this.solverWrapper.setConstraintLHS(this.constraint, this._private_buildLHS());
58
+ }
59
+ }
60
+ /** Updates anchor on element B */
61
+ set anchorB(value) {
62
+ assertValidNumber(value, "UIHorizontalDistanceConstraint.anchorB");
63
+ if (this._private_anchorBInternal !== value) {
64
+ this._private_anchorBInternal = value;
65
+ this.solverWrapper.setConstraintLHS(this.constraint, this._private_buildLHS());
66
+ }
67
+ }
68
+ /** Builds constraint expression for distance between anchored positions */
69
+ _private_buildLHS() {
70
+ let aExpression;
71
+ let bExpression;
72
+ if (isUIPlaneElement(this._private_a)) {
73
+ aExpression = new UIExpression(0, [
74
+ [this._private_a.xVariable, 1],
75
+ [this._private_a.wVariable, this._private_anchorAInternal],
76
+ ]);
77
+ }
78
+ else if (isUIPointElement(this._private_a)) {
79
+ aExpression = new UIExpression().plus(this._private_a.xVariable, 1);
80
+ }
81
+ else {
82
+ throw new Error("UIHorizontalDistanceConstraint.buildLHS.a: invalid element type");
83
+ }
84
+ if (isUIPlaneElement(this._private_b)) {
85
+ bExpression = new UIExpression(0, [
86
+ [this._private_b.xVariable, 1],
87
+ [this._private_b.wVariable, this._private_anchorBInternal],
88
+ ]);
89
+ }
90
+ else if (isUIPointElement(this._private_b)) {
91
+ bExpression = new UIExpression().plus(this._private_b.xVariable, 1);
92
+ }
93
+ else {
94
+ throw new Error("UIHorizontalDistanceConstraint.buildLHS.b: invalid element type");
95
+ }
96
+ return UIExpression.minus(bExpression, aExpression);
97
+ }
98
+ }
99
+
100
+ export { UIHorizontalDistanceConstraint };
@@ -0,0 +1,4 @@
1
+ const DEFAULT_ANCHOR = 0.5;
2
+ const DEFAULT_T = 0.5;
3
+
4
+ export { DEFAULT_ANCHOR, DEFAULT_T };