laymur 0.16.0 → 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 (247) 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/{dist/elements/UIElement/UIElement.Internal.d.ts → src/core/elements/UIElement/UIElement.Internal.ts} +7 -5
  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/layers/UIFullscreenLayer/UIFullscreenLayer.Internal.d.ts → src/core/layers/UIFullscreenLayer/UIFullscreenLayer.Internal.ts} +14 -11
  61. package/src/core/layers/UIFullscreenLayer/UIFullscreenLayer.ts +233 -0
  62. package/{dist/layers/UILayer/UILayer.Internal.d.ts → src/core/layers/UILayer/UILayer.Internal.ts} +15 -11
  63. package/src/core/layers/UILayer/UILayer.ts +156 -0
  64. package/src/core/miscellaneous/UIExpression.ts +142 -0
  65. package/src/core/miscellaneous/UIMode.ts +29 -0
  66. package/src/core/miscellaneous/UIOrientation.ts +18 -0
  67. package/src/core/miscellaneous/UIPriority.ts +63 -0
  68. package/src/core/miscellaneous/UIRelation.ts +39 -0
  69. package/src/core/miscellaneous/UITransparencyMode.ts +9 -0
  70. package/src/core/miscellaneous/area/UIArea.ts +5 -0
  71. package/src/core/miscellaneous/area/UIAreaCircle.ts +32 -0
  72. package/src/core/miscellaneous/area/UIAreaPolygon.ts +50 -0
  73. package/src/core/miscellaneous/area/UIAreaRectangle.ts +38 -0
  74. package/src/core/miscellaneous/area/UIAreaRoundedRectangle.ts +78 -0
  75. package/src/core/miscellaneous/asserts.ts +187 -0
  76. package/src/core/miscellaneous/canvas.ts +73 -0
  77. package/src/core/miscellaneous/color/UIColor.Internal.ts +89 -0
  78. package/src/core/miscellaneous/color/UIColor.ts +844 -0
  79. package/src/core/miscellaneous/computeTransform.ts +127 -0
  80. package/src/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.Internal.ts +235 -0
  81. package/src/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.ts +524 -0
  82. package/{dist/miscellaneous/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.Internal.d.ts → src/core/miscellaneous/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.Internal.ts} +10 -8
  83. package/src/core/miscellaneous/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.ts +448 -0
  84. package/src/core/miscellaneous/generic-plane/shared.ts +323 -0
  85. package/src/core/miscellaneous/insets/UIInsets.Internal.ts +9 -0
  86. package/src/core/miscellaneous/insets/UIInsets.ts +248 -0
  87. package/src/core/miscellaneous/mask-function/UIProgressMaskFunction.ts +24 -0
  88. package/src/core/miscellaneous/mask-function/UIProgressMaskFunctionCircular.ts +58 -0
  89. package/src/core/miscellaneous/mask-function/UIProgressMaskFunctionDirectional.ts +52 -0
  90. package/src/core/miscellaneous/math.ts +16 -0
  91. package/src/core/miscellaneous/micro/UIMicro.Internal.ts +33 -0
  92. package/src/core/miscellaneous/micro/UIMicro.ts +222 -0
  93. package/src/core/miscellaneous/resize-policy/UIResizePolicy.ts +8 -0
  94. package/src/core/miscellaneous/resize-policy/UIResizePolicyCover.ts +57 -0
  95. package/src/core/miscellaneous/resize-policy/UIResizePolicyCross.ts +65 -0
  96. package/src/core/miscellaneous/resize-policy/UIResizePolicyCrossInverted.ts +65 -0
  97. package/src/core/miscellaneous/resize-policy/UIResizePolicyFit.ts +57 -0
  98. package/src/core/miscellaneous/resize-policy/UIResizePolicyFixedHeight.ts +65 -0
  99. package/src/core/miscellaneous/resize-policy/UIResizePolicyFixedWidth.ts +65 -0
  100. package/src/core/miscellaneous/resize-policy/UIResizePolicyNone.ts +11 -0
  101. package/src/core/miscellaneous/shared.ts +73 -0
  102. package/{dist/miscellaneous/text-span/UITextSpan.Internal.d.ts → src/core/miscellaneous/text-span/UITextSpan.Internal.ts} +5 -4
  103. package/src/core/miscellaneous/text-span/UITextSpan.ts +43 -0
  104. package/src/core/miscellaneous/text-style/UITextStyle.Internal.ts +52 -0
  105. package/src/core/miscellaneous/text-style/UITextStyle.ts +479 -0
  106. package/src/core/miscellaneous/texture/UITextureView.Internal.ts +55 -0
  107. package/src/core/miscellaneous/texture/UITextureView.ts +308 -0
  108. package/src/core/miscellaneous/webglCapabilities.ts +129 -0
  109. package/src/core/shaders/UIImage.glsl +10 -0
  110. package/src/core/shaders/UINineSlice.glsl +53 -0
  111. package/src/core/shaders/UIProgress.glsl +15 -0
  112. package/src/core/shaders/UIProgressMaskFunctionCircular.glsl +13 -0
  113. package/src/core/shaders/UIProgressMaskFunctionDirectional.glsl +12 -0
  114. package/src/core/shaders/glsl.d.ts +27 -0
  115. package/src/core/wrappers/UIInputWrapper/UIInputWrapper.Internal.ts +23 -0
  116. package/src/core/wrappers/UIInputWrapper/UIInputWrapper.ts +124 -0
  117. package/src/core/wrappers/UISceneWrapper/UISceneWrapper.Internal.ts +22 -0
  118. package/src/core/wrappers/UISceneWrapper/UISceneWrapper.ts +101 -0
  119. package/src/core/wrappers/UISolverWrapper/UISolverWrapper.Internal.ts +58 -0
  120. package/src/core/wrappers/UISolverWrapper/UISolverWrapper.ts +605 -0
  121. package/src/particles/behaviorModules/UIBehaviorDirectionalGravity.ts +70 -0
  122. package/src/particles/behaviorModules/UIBehaviorModule.ts +20 -0
  123. package/src/particles/behaviorModules/UIBehaviorPointGravity.ts +173 -0
  124. package/src/particles/behaviorModules/UIBehaviorScaleOverLife.ts +104 -0
  125. package/src/particles/behaviorModules/UIBehaviorTorqueDamping.ts +75 -0
  126. package/src/particles/behaviorModules/UIBehaviorTorqueNoise.ts +115 -0
  127. package/src/particles/behaviorModules/UIBehaviorVelocityDamping.ts +77 -0
  128. package/src/particles/behaviorModules/UIBehaviorVelocityNoise.ts +118 -0
  129. package/src/particles/elements/UIEmitter.Internal.ts +22 -0
  130. package/src/particles/elements/UIEmitter.ts +313 -0
  131. package/src/particles/index.ts +18 -0
  132. package/src/particles/instancedParticle/UIInstancedParticle.Internal.ts +263 -0
  133. package/src/particles/instancedParticle/UIInstancedParticle.ts +138 -0
  134. package/src/particles/miscellaneous/miscellaneous.ts +115 -0
  135. package/src/particles/renderingModules/UIRenderingColorOverLife.ts +39 -0
  136. package/src/particles/renderingModules/UIRenderingColorOverVelocity.ts +49 -0
  137. package/src/particles/renderingModules/UIRenderingModule.ts +17 -0
  138. package/src/particles/renderingModules/UIRenderingTexture.ts +30 -0
  139. package/src/particles/shaders/UIRenderingColorOverLife.glsl +4 -0
  140. package/src/particles/shaders/UIRenderingColorOverVelocity.glsl +6 -0
  141. package/src/particles/shaders/UIRenderingTexture.glsl +4 -0
  142. package/src/particles/spawnModules/UISpawnModule.ts +22 -0
  143. package/src/particles/spawnModules/UISpawnOffset.ts +62 -0
  144. package/src/particles/spawnModules/UISpawnRandomLifetime.ts +68 -0
  145. package/src/particles/spawnModules/UISpawnRandomRotation.ts +60 -0
  146. package/src/particles/spawnModules/UISpawnRandomScale.ts +81 -0
  147. package/src/particles/spawnModules/UISpawnRandomTorque.ts +62 -0
  148. package/src/particles/spawnModules/UISpawnRandomVelocity.ts +92 -0
  149. package/src/particles/spawnModules/UISpawnRectangle.ts +81 -0
  150. package/tsconfig.json +29 -0
  151. package/dist/constraints/UIAspectConstraint/UIAspectConstraint.d.ts +0 -22
  152. package/dist/constraints/UIConstraint.d.ts +0 -12
  153. package/dist/constraints/UICustomConstraint.d.ts +0 -28
  154. package/dist/constraints/UIHeightConstraint/UIHeightConstraint.d.ts +0 -20
  155. package/dist/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.Internal.d.ts +0 -11
  156. package/dist/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.d.ts +0 -36
  157. package/dist/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.Internal.d.ts +0 -14
  158. package/dist/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.d.ts +0 -44
  159. package/dist/constraints/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.d.ts +0 -22
  160. package/dist/constraints/UISingleParameterConstraint/UISingleParameterConstraint.d.ts +0 -43
  161. package/dist/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.Internal.d.ts +0 -11
  162. package/dist/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.d.ts +0 -32
  163. package/dist/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.Internal.d.ts +0 -14
  164. package/dist/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.d.ts +0 -44
  165. package/dist/constraints/UIVerticalProportionConstraint/UIVerticalProportionConstraint.d.ts +0 -22
  166. package/dist/constraints/UIWidthConstraint/UIWidthConstraint.d.ts +0 -20
  167. package/dist/constraints/builders/UIConstraint2DBuilder.Internal.d.ts +0 -64
  168. package/dist/constraints/builders/UIConstraint2DBuilder.d.ts +0 -46
  169. package/dist/constraints/builders/UICoverConstraintBuilder.Internal.d.ts +0 -13
  170. package/dist/constraints/builders/UICoverConstraintBuilder.d.ts +0 -29
  171. package/dist/constraints/builders/UIFitConstraintBuilder.Internal.d.ts +0 -13
  172. package/dist/constraints/builders/UIFitConstraintBuilder.d.ts +0 -29
  173. package/dist/elements/UIAnchor/UIAnchor.Internal.d.ts +0 -9
  174. package/dist/elements/UIAnchor/UIAnchor.d.ts +0 -32
  175. package/dist/elements/UIAnimatedImage/UIAnimatedImage.Internal.d.ts +0 -27
  176. package/dist/elements/UIAnimatedImage/UIAnimatedImage.d.ts +0 -77
  177. package/dist/elements/UIDummy/UIDummy.Internal.d.ts +0 -30
  178. package/dist/elements/UIDummy/UIDummy.d.ts +0 -82
  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/UINineSlice/UINineSlice.Internal.d.ts +0 -23
  183. package/dist/elements/UINineSlice/UINineSlice.d.ts +0 -60
  184. package/dist/elements/UIProgress/UIProgress.Internal.d.ts +0 -14
  185. package/dist/elements/UIProgress/UIProgress.d.ts +0 -45
  186. package/dist/elements/UIScene/UIScene.Internal.d.ts +0 -43
  187. package/dist/elements/UIScene/UIScene.d.ts +0 -59
  188. package/dist/elements/UIText/UIText.Internal.d.ts +0 -26
  189. package/dist/elements/UIText/UIText.Measuring.d.ts +0 -50
  190. package/dist/elements/UIText/UIText.Rendering.d.ts +0 -20
  191. package/dist/elements/UIText/UIText.d.ts +0 -71
  192. package/dist/index.js +0 -9246
  193. package/dist/index.js.map +0 -1
  194. package/dist/index.min.js +0 -2
  195. package/dist/index.min.js.map +0 -1
  196. package/dist/layers/UIFullscreenLayer/UIFullscreenLayer.d.ts +0 -63
  197. package/dist/layers/UILayer/UILayer.d.ts +0 -49
  198. package/dist/miscellaneous/UIExpression.d.ts +0 -69
  199. package/dist/miscellaneous/UIMode.d.ts +0 -23
  200. package/dist/miscellaneous/UIOrientation.d.ts +0 -15
  201. package/dist/miscellaneous/UIPriority.d.ts +0 -32
  202. package/dist/miscellaneous/UIRelation.d.ts +0 -23
  203. package/dist/miscellaneous/UITransparencyMode.d.ts +0 -9
  204. package/dist/miscellaneous/area/UIArea.d.ts +0 -3
  205. package/dist/miscellaneous/area/UIAreaCircle.d.ts +0 -15
  206. package/dist/miscellaneous/area/UIAreaPolygon.d.ts +0 -12
  207. package/dist/miscellaneous/area/UIAreaRectangle.d.ts +0 -17
  208. package/dist/miscellaneous/area/UIAreaRoundedRectangle.d.ts +0 -21
  209. package/dist/miscellaneous/asserts.d.ts +0 -43
  210. package/dist/miscellaneous/canvas.d.ts +0 -31
  211. package/dist/miscellaneous/color/UIColor.Internal.d.ts +0 -7
  212. package/dist/miscellaneous/color/UIColor.d.ts +0 -234
  213. package/dist/miscellaneous/computeTransform.d.ts +0 -18
  214. package/dist/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.Internal.d.ts +0 -19
  215. package/dist/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.d.ts +0 -1
  216. package/dist/miscellaneous/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.d.ts +0 -1
  217. package/dist/miscellaneous/generic-plane/shared.d.ts +0 -38
  218. package/dist/miscellaneous/insets/UIInsets.Internal.d.ts +0 -11
  219. package/dist/miscellaneous/insets/UIInsets.d.ts +0 -48
  220. package/dist/miscellaneous/mask-function/UIProgressMaskFunction.d.ts +0 -9
  221. package/dist/miscellaneous/mask-function/UIProgressMaskFunctionCircular.d.ts +0 -21
  222. package/dist/miscellaneous/mask-function/UIProgressMaskFunctionDirectional.d.ts +0 -16
  223. package/dist/miscellaneous/math.d.ts +0 -5
  224. package/dist/miscellaneous/micro/UIMicro.Internal.d.ts +0 -31
  225. package/dist/miscellaneous/micro/UIMicro.d.ts +0 -59
  226. package/dist/miscellaneous/resize-policy/UIResizePolicy.d.ts +0 -3
  227. package/dist/miscellaneous/resize-policy/UIResizePolicyCover.d.ts +0 -22
  228. package/dist/miscellaneous/resize-policy/UIResizePolicyCross.d.ts +0 -22
  229. package/dist/miscellaneous/resize-policy/UIResizePolicyCrossInverted.d.ts +0 -22
  230. package/dist/miscellaneous/resize-policy/UIResizePolicyFit.d.ts +0 -22
  231. package/dist/miscellaneous/resize-policy/UIResizePolicyFixedHeight.d.ts +0 -22
  232. package/dist/miscellaneous/resize-policy/UIResizePolicyFixedWidth.d.ts +0 -22
  233. package/dist/miscellaneous/resize-policy/UIResizePolicyNone.d.ts +0 -5
  234. package/dist/miscellaneous/shared.d.ts +0 -46
  235. package/dist/miscellaneous/text-span/UITextSpan.d.ts +0 -14
  236. package/dist/miscellaneous/text-style/UITextStyle.Internal.d.ts +0 -48
  237. package/dist/miscellaneous/text-style/UITextStyle.d.ts +0 -85
  238. package/dist/miscellaneous/texture/UITextureView.Internal.d.ts +0 -49
  239. package/dist/miscellaneous/texture/UITextureView.d.ts +0 -67
  240. package/dist/miscellaneous/webglCapabilities.d.ts +0 -2
  241. package/dist/wrappers/UIInputWrapper/UIInputWrapper.Internal.d.ts +0 -17
  242. package/dist/wrappers/UIInputWrapper/UIInputWrapper.d.ts +0 -13
  243. package/dist/wrappers/UISceneWrapper/UISceneWrapper.Internal.d.ts +0 -13
  244. package/dist/wrappers/UISceneWrapper/UISceneWrapper.d.ts +0 -20
  245. package/dist/wrappers/UISolverWrapper/UISolverWrapper.Internal.d.ts +0 -49
  246. package/dist/wrappers/UISolverWrapper/UISolverWrapper.d.ts +0 -215
  247. /package/{dist/index.d.ts → src/core/index.ts} +0 -0
package/package.json CHANGED
@@ -1,35 +1,7 @@
1
1
  {
2
2
  "name": "laymur",
3
- "version": "0.16.0",
3
+ "version": "0.17.0",
4
4
  "description": "Constraint-based UI library for Three.js mobile advertisements",
5
- "scripts": {
6
- "clean": "rm -rf dist",
7
- "build": "npm run clean && rollup -c",
8
- "build:prod": "npm run clean && NODE_ENV=production rollup -c",
9
- "prepublishOnly": "npm run build:prod"
10
- },
11
- "main": "dist/index.js",
12
- "module": "dist/index.js",
13
- "types": "dist/index.d.ts",
14
- "exports": {
15
- ".": {
16
- "import": {
17
- "types": "./dist/index.d.ts",
18
- "development": "./dist/index.js",
19
- "production": "./dist/index.min.js",
20
- "default": "./dist/index.min.js"
21
- },
22
- "require": {
23
- "types": "./dist/index.d.ts",
24
- "default": "./dist/index.min.js"
25
- }
26
- },
27
- "./package.json": "./package.json"
28
- },
29
- "files": [
30
- "dist"
31
- ],
32
- "sideEffects": false,
33
5
  "keywords": [
34
6
  "ui",
35
7
  "three.js",
@@ -46,13 +18,29 @@
46
18
  "url": "git+https://github.com/jango-git/laymur.git"
47
19
  },
48
20
  "type": "module",
21
+ "sideEffects": false,
22
+ "scripts": {
23
+ "clean": "rm -rf dist",
24
+ "build": "npm run clean && rollup -c",
25
+ "prepublishOnly": "npm run build"
26
+ },
27
+ "exports": {
28
+ ".": {
29
+ "import": "./dist/index.js",
30
+ "types": "./dist/core/index.d.ts"
31
+ },
32
+ "./particles": {
33
+ "import": "./dist/particles/index.js",
34
+ "types": "./dist/particles/index.d.ts"
35
+ }
36
+ },
49
37
  "peerDependencies": {
50
- "three": ">=0.157.0 <0.180.0"
38
+ "three": ">=0.157.0 <0.180.0",
39
+ "@lume/kiwi": "^0.4.4",
40
+ "ferrsign": "^0.0.4"
51
41
  },
52
42
  "devDependencies": {
53
43
  "@rollup/plugin-node-resolve": "^16.0.1",
54
- "@rollup/plugin-replace": "^6.0.3",
55
- "@rollup/plugin-terser": "^0.4.4",
56
44
  "@types/node": "^25.0.2",
57
45
  "@types/three": "^0.157.0",
58
46
  "@typescript-eslint/eslint-plugin": "^8.32.0",
@@ -63,9 +51,5 @@
63
51
  "rollup-plugin-typescript2": "^0.36.0",
64
52
  "ts-transformer-minify-privates": "^1.0.0",
65
53
  "typescript": "^5.8.3"
66
- },
67
- "dependencies": {
68
- "@lume/kiwi": "^0.4.4",
69
- "ferrsign": "^0.0.4"
70
54
  }
71
55
  }
@@ -0,0 +1,52 @@
1
+ import { nodeResolve } from "@rollup/plugin-node-resolve";
2
+ import typescript from "rollup-plugin-typescript2";
3
+ import minifyPrivatesTransformer from "ts-transformer-minify-privates";
4
+ import { string } from "rollup-plugin-string";
5
+
6
+ const sharedPlugins = [
7
+ nodeResolve({ extensions: [".js", ".ts"] }),
8
+ {
9
+ name: "minify-shaders",
10
+ transform(code, id) {
11
+ if (/\.(glsl|fs|vs|frag|vert)$/.test(id)) {
12
+ return {
13
+ code: code
14
+ .replace(/\/\*[\s\S]*?\*\//g, "")
15
+ .replace(/\/\/[^\n]*/g, "")
16
+ .replace(/\s*([{}(),=;+\-*/<>])\s*/g, "$1")
17
+ .replace(/\s+/g, " ")
18
+ .trim(),
19
+ map: null,
20
+ };
21
+ }
22
+ },
23
+ },
24
+ string({
25
+ include: ["**/*.glsl", "**/*.fs", "**/*.vs", "**/*.frag", "**/*.vert"],
26
+ }),
27
+ typescript({
28
+ tsconfig: "tsconfig.json",
29
+ useTsconfigDeclarationDir: true,
30
+ transformers: [
31
+ (service) => ({
32
+ before: [minifyPrivatesTransformer.default(service.getProgram())],
33
+ after: [],
34
+ }),
35
+ ],
36
+ }),
37
+ ];
38
+
39
+ export default {
40
+ input: {
41
+ index: "src/core/index.ts",
42
+ "particles/index": "src/particles/index.ts",
43
+ },
44
+ output: {
45
+ dir: "dist",
46
+ format: "esm",
47
+ preserveModules: true,
48
+ preserveModulesRoot: "src",
49
+ },
50
+ external: ["three", "@lume/kiwi", "ferrsign"],
51
+ plugins: sharedPlugins,
52
+ };
@@ -1,6 +1,7 @@
1
1
  import type { UISingleParameterConstraintOptions } from "../UISingleParameterConstraint/UISingleParameterConstraint.Internal";
2
+
2
3
  /** Aspect constraint options */
3
4
  export interface UIAspectConstraintOptions extends UISingleParameterConstraintOptions {
4
- /** Target aspect ratio (width/height) */
5
- aspect: number;
5
+ /** Target aspect ratio (width/height) */
6
+ aspect: number;
6
7
  }
@@ -0,0 +1,60 @@
1
+ import { assertValidPositiveNumber } from "../../miscellaneous/asserts";
2
+ import type { UILayerElement, UIPlaneElement } from "../../miscellaneous/shared";
3
+ import { UIExpression } from "../../miscellaneous/UIExpression";
4
+ import { UISingleParameterConstraint } from "../UISingleParameterConstraint/UISingleParameterConstraint";
5
+ import type { UIAspectConstraintOptions } from "./UIAspectConstraint.Internal";
6
+
7
+ /** Maintains element aspect ratio (width = height * aspect) */
8
+ export class UIAspectConstraint extends UISingleParameterConstraint {
9
+ /** Solver constraint descriptor */
10
+ protected override readonly constraint: number;
11
+
12
+ /** Current aspect ratio */
13
+ private aspectInternal: number;
14
+
15
+ /**
16
+ * @param element Element to constrain
17
+ * @param options Aspect configuration. Defaults to element's current ratio.
18
+ */
19
+ constructor(
20
+ private readonly element: UIPlaneElement & UILayerElement,
21
+ options: Partial<UIAspectConstraintOptions> = {},
22
+ ) {
23
+ if (options.aspect !== undefined) {
24
+ assertValidPositiveNumber(options.aspect, "UIAspectConstraint.constructor.options.aspect");
25
+ }
26
+
27
+ super(element.layer, options);
28
+
29
+ this.aspectInternal = options.aspect ?? element.width / element.height;
30
+ this.constraint = this.solverWrapper.createConstraint(
31
+ this.buildLHS(),
32
+ new UIExpression(0),
33
+ this.relation,
34
+ this.priority,
35
+ this.isConstraintEnabled(),
36
+ );
37
+ }
38
+
39
+ /** Current aspect ratio (width/height) */
40
+ public get aspect(): number {
41
+ return this.aspectInternal;
42
+ }
43
+
44
+ /** Updates aspect ratio */
45
+ public set aspect(value: number) {
46
+ assertValidPositiveNumber(value, "UIAspectConstraint.aspect");
47
+ if (this.aspectInternal !== value) {
48
+ this.aspectInternal = value;
49
+ this.solverWrapper.setConstraintLHS(this.constraint, this.buildLHS());
50
+ }
51
+ }
52
+
53
+ /** Builds constraint expression: width - (height * aspect) = 0 */
54
+ private buildLHS(): UIExpression {
55
+ return new UIExpression(0, [
56
+ [this.element.wVariable, 1],
57
+ [this.element.hVariable, -this.aspectInternal],
58
+ ]);
59
+ }
60
+ }
@@ -0,0 +1,20 @@
1
+ import type { UILayer } from "../layers/UILayer/UILayer";
2
+ import type { UISolverWrapperView } from "../wrappers/UISolverWrapper/UISolverWrapper.Internal";
3
+
4
+ /** Base class for layout constraints */
5
+ export abstract class UIConstraint {
6
+ /** Optional constraint name */
7
+ public name: string;
8
+
9
+ /** Constraint solver wrapper */
10
+ protected readonly solverWrapper: UISolverWrapperView;
11
+
12
+ /** @param layer Layer containing this constraint */
13
+ constructor(
14
+ public readonly layer: UILayer,
15
+ name?: string,
16
+ ) {
17
+ this.solverWrapper = this.layer.solverWrapper;
18
+ this.name = name ?? "";
19
+ }
20
+ }
@@ -0,0 +1,62 @@
1
+ import type { UILayer } from "../layers/UILayer/UILayer";
2
+ import type { UIExpression } from "../miscellaneous/UIExpression";
3
+ import { UISingleParameterConstraint } from "./UISingleParameterConstraint/UISingleParameterConstraint";
4
+ import type { UISingleParameterConstraintOptions } from "./UISingleParameterConstraint/UISingleParameterConstraint.Internal";
5
+
6
+ /** Constraint with custom LHS and RHS expressions */
7
+ export class UICustomConstraint extends UISingleParameterConstraint {
8
+ /** Solver constraint descriptor */
9
+ protected override readonly constraint: number;
10
+ /** Left-hand side expression */
11
+ private lhsInternal: UIExpression;
12
+ /** Right-hand side expression */
13
+ private rhsInternal: UIExpression;
14
+
15
+ /**
16
+ * @param layer Layer containing this constraint
17
+ * @param lhs Left-hand side expression
18
+ * @param rhs Right-hand side expression
19
+ * @param options Constraint configuration
20
+ */
21
+ constructor(
22
+ layer: UILayer,
23
+ lhs: UIExpression,
24
+ rhs: UIExpression,
25
+ options: Partial<UISingleParameterConstraintOptions> = {},
26
+ ) {
27
+ super(layer, options);
28
+
29
+ this.lhsInternal = lhs;
30
+ this.rhsInternal = rhs;
31
+
32
+ this.constraint = this.solverWrapper.createConstraint(
33
+ this.lhsInternal,
34
+ this.rhsInternal,
35
+ this.relation,
36
+ this.priority,
37
+ this.isConstraintEnabled(),
38
+ );
39
+ }
40
+
41
+ /** Left-hand side expression */
42
+ public get lhs(): UIExpression {
43
+ return this.lhsInternal;
44
+ }
45
+
46
+ /** Right-hand side expression */
47
+ public get rhs(): UIExpression {
48
+ return this.rhsInternal;
49
+ }
50
+
51
+ /** Updates left-hand side expression */
52
+ public setLHS(value: UIExpression): void {
53
+ this.lhsInternal = value;
54
+ this.solverWrapper.setConstraintLHS(this.constraint, this.lhsInternal);
55
+ }
56
+
57
+ /** Updates right-hand side expression */
58
+ public setRHS(value: UIExpression): void {
59
+ this.rhsInternal = value;
60
+ this.solverWrapper.setConstraintRHS(this.constraint, this.rhsInternal);
61
+ }
62
+ }
@@ -1,6 +1,7 @@
1
1
  import type { UISingleParameterConstraintOptions } from "../UISingleParameterConstraint/UISingleParameterConstraint.Internal";
2
+
2
3
  /** Height constraint options */
3
4
  export interface UIHeightConstraintOptions extends UISingleParameterConstraintOptions {
4
- /** Target height in world units */
5
- height: number;
5
+ /** Target height in world units */
6
+ height: number;
6
7
  }
@@ -0,0 +1,52 @@
1
+ import { assertValidPositiveNumber } from "../../miscellaneous/asserts";
2
+ import type { UILayerElement, UIPlaneElement } from "../../miscellaneous/shared";
3
+ import { UIExpression } from "../../miscellaneous/UIExpression";
4
+ import { UISingleParameterConstraint } from "../UISingleParameterConstraint/UISingleParameterConstraint";
5
+ import type { UIHeightConstraintOptions } from "./UIHeightConstraint.Internal";
6
+
7
+ /** Fixes element height to constant value */
8
+ export class UIHeightConstraint extends UISingleParameterConstraint {
9
+ /** Solver constraint descriptor */
10
+ protected override readonly constraint: number;
11
+
12
+ /** Current height value */
13
+ private heightInternal: number;
14
+
15
+ /**
16
+ * @param element Element to constrain
17
+ * @param options Height configuration. Defaults to element's current height.
18
+ */
19
+ constructor(
20
+ private readonly element: UIPlaneElement & UILayerElement,
21
+ options: Partial<UIHeightConstraintOptions> = {},
22
+ ) {
23
+ if (options.height !== undefined) {
24
+ assertValidPositiveNumber(options.height, "UIHeightConstraint.constructor.options.height");
25
+ }
26
+
27
+ super(element.layer, options);
28
+
29
+ this.heightInternal = options.height ?? element.height;
30
+ this.constraint = this.solverWrapper.createConstraint(
31
+ new UIExpression(0, [[this.element.hVariable, 1]]),
32
+ new UIExpression(this.heightInternal),
33
+ this.relation,
34
+ this.priority,
35
+ this.isConstraintEnabled(),
36
+ );
37
+ }
38
+
39
+ /** Current height in world units */
40
+ public get height(): number {
41
+ return this.heightInternal;
42
+ }
43
+
44
+ /** Updates height */
45
+ public set height(value: number) {
46
+ assertValidPositiveNumber(value, "UIHeightConstraint.height");
47
+ if (this.heightInternal !== value) {
48
+ this.heightInternal = value;
49
+ this.solverWrapper.setConstraintRHS(this.constraint, new UIExpression(value));
50
+ }
51
+ }
52
+ }
@@ -0,0 +1,13 @@
1
+ import type { UISingleParameterConstraintOptions } from "../UISingleParameterConstraint/UISingleParameterConstraint.Internal";
2
+
3
+ export const DEFAULT_ANCHOR = 0.5;
4
+
5
+ /** Horizontal distance constraint options */
6
+ export interface UIHorizontalDistanceConstraintOptions extends UISingleParameterConstraintOptions {
7
+ /** Anchor on element A (0 = left, 0.5 = center, 1 = right) */
8
+ anchorA: number;
9
+ /** Anchor on element B (0 = left, 0.5 = center, 1 = right) */
10
+ anchorB: number;
11
+ /** Distance in world units */
12
+ distance: number;
13
+ }
@@ -0,0 +1,139 @@
1
+ import { assertValidConstraintArguments, assertValidNumber } from "../../miscellaneous/asserts";
2
+ import type { UIPlaneElement, UIPointElement } from "../../miscellaneous/shared";
3
+ import { isUIPlaneElement, isUIPointElement } from "../../miscellaneous/shared";
4
+ import { UIExpression } from "../../miscellaneous/UIExpression";
5
+ import { UISingleParameterConstraint } from "../UISingleParameterConstraint/UISingleParameterConstraint";
6
+ import type { UIHorizontalDistanceConstraintOptions } from "./UIHorizontalDistanceConstraint.Internal";
7
+ import { DEFAULT_ANCHOR } from "./UIHorizontalDistanceConstraint.Internal";
8
+
9
+ /** Maintains horizontal distance between elements with configurable anchors */
10
+ export class UIHorizontalDistanceConstraint extends UISingleParameterConstraint {
11
+ /** Solver constraint descriptor */
12
+ protected override readonly constraint: number;
13
+
14
+ /** Anchor on element A */
15
+ private anchorAInternal: number;
16
+ /** Anchor on element B */
17
+ private anchorBInternal: number;
18
+ /** Current distance */
19
+ private distanceInternal: number;
20
+
21
+ /**
22
+ * @param a First element
23
+ * @param b Second element
24
+ * @param options Distance configuration
25
+ */
26
+ constructor(
27
+ private readonly a: UIPointElement | UIPlaneElement,
28
+ private readonly b: UIPointElement | UIPlaneElement,
29
+ options: Partial<UIHorizontalDistanceConstraintOptions> = {},
30
+ ) {
31
+ if (options.anchorA !== undefined) {
32
+ assertValidNumber(
33
+ options.anchorA,
34
+ "UIHorizontalDistanceConstraint.constructor.options.anchorA",
35
+ );
36
+ }
37
+ if (options.anchorB !== undefined) {
38
+ assertValidNumber(
39
+ options.anchorB,
40
+ "UIHorizontalDistanceConstraint.constructor.options.anchorB",
41
+ );
42
+ }
43
+ if (options.distance !== undefined) {
44
+ assertValidNumber(
45
+ options.distance,
46
+ "UIHorizontalDistanceConstraint.constructor.options.distance",
47
+ );
48
+ }
49
+
50
+ super(
51
+ assertValidConstraintArguments(a, b, "UIHorizontalDistanceConstraint.constructor"),
52
+ options,
53
+ );
54
+
55
+ this.anchorAInternal = options.anchorA ?? DEFAULT_ANCHOR;
56
+ this.anchorBInternal = options.anchorB ?? DEFAULT_ANCHOR;
57
+ this.distanceInternal = options.distance ?? 0;
58
+
59
+ this.constraint = this.solverWrapper.createConstraint(
60
+ this.buildLHS(),
61
+ new UIExpression(this.distanceInternal),
62
+ this.relation,
63
+ this.priority,
64
+ this.isConstraintEnabled(),
65
+ );
66
+ }
67
+
68
+ /** Current distance in world units */
69
+ public get distance(): number {
70
+ return this.distanceInternal;
71
+ }
72
+
73
+ /** Anchor on element A (0 = left, 0.5 = center, 1 = right) */
74
+ public get anchorA(): number {
75
+ return this.anchorAInternal;
76
+ }
77
+
78
+ /** Anchor on element B (0 = left, 0.5 = center, 1 = right) */
79
+ public get anchorB(): number {
80
+ return this.anchorBInternal;
81
+ }
82
+
83
+ /** Updates distance */
84
+ public set distance(value: number) {
85
+ assertValidNumber(value, "UIHorizontalDistanceConstraint.distance");
86
+ if (this.distanceInternal !== value) {
87
+ this.distanceInternal = value;
88
+ this.solverWrapper.setConstraintRHS(this.constraint, new UIExpression(this.distanceInternal));
89
+ }
90
+ }
91
+
92
+ /** Updates anchor on element A */
93
+ public set anchorA(value: number) {
94
+ assertValidNumber(value, "UIHorizontalDistanceConstraint.anchorA");
95
+ if (this.anchorAInternal !== value) {
96
+ this.anchorAInternal = value;
97
+ this.solverWrapper.setConstraintLHS(this.constraint, this.buildLHS());
98
+ }
99
+ }
100
+
101
+ /** Updates anchor on element B */
102
+ public set anchorB(value: number) {
103
+ assertValidNumber(value, "UIHorizontalDistanceConstraint.anchorB");
104
+ if (this.anchorBInternal !== value) {
105
+ this.anchorBInternal = value;
106
+ this.solverWrapper.setConstraintLHS(this.constraint, this.buildLHS());
107
+ }
108
+ }
109
+
110
+ /** Builds constraint expression for distance between anchored positions */
111
+ private buildLHS(): UIExpression {
112
+ let aExpression: UIExpression;
113
+ let bExpression: UIExpression;
114
+
115
+ if (isUIPlaneElement(this.a)) {
116
+ aExpression = new UIExpression(0, [
117
+ [this.a.xVariable, 1],
118
+ [this.a.wVariable, this.anchorAInternal],
119
+ ]);
120
+ } else if (isUIPointElement(this.a)) {
121
+ aExpression = new UIExpression().plus(this.a.xVariable, 1);
122
+ } else {
123
+ throw new Error("UIHorizontalDistanceConstraint.buildLHS.a: invalid element type");
124
+ }
125
+
126
+ if (isUIPlaneElement(this.b)) {
127
+ bExpression = new UIExpression(0, [
128
+ [this.b.xVariable, 1],
129
+ [this.b.wVariable, this.anchorBInternal],
130
+ ]);
131
+ } else if (isUIPointElement(this.b)) {
132
+ bExpression = new UIExpression().plus(this.b.xVariable, 1);
133
+ } else {
134
+ throw new Error("UIHorizontalDistanceConstraint.buildLHS.b: invalid element type");
135
+ }
136
+
137
+ return UIExpression.minus(bExpression, aExpression);
138
+ }
139
+ }
@@ -0,0 +1,16 @@
1
+ import type { UISingleParameterConstraintOptions } from "../UISingleParameterConstraint/UISingleParameterConstraint.Internal";
2
+
3
+ export const DEFAULT_ANCHOR = 0.5;
4
+ export const DEFAULT_T = 0.5;
5
+
6
+ /** Horizontal interpolation constraint options */
7
+ export interface UIHorizontalInterpolationConstraintOptions extends UISingleParameterConstraintOptions {
8
+ /** Anchor on element A (0 = left, 0.5 = center, 1 = right) */
9
+ anchorA: number;
10
+ /** Anchor on element B (0 = left, 0.5 = center, 1 = right) */
11
+ anchorB: number;
12
+ /** Anchor on element C (0 = left, 0.5 = center, 1 = right) */
13
+ anchorC: number;
14
+ /** Interpolation factor (0 = A position, 1 = B position) */
15
+ t: number;
16
+ }