laymur 0.23.0 → 0.25.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 (316) hide show
  1. package/README.md +1 -1
  2. package/dist/core/constraints/UIAspectConstraint/UIAspectConstraint.Internal.d.ts +1 -1
  3. package/dist/core/constraints/UIAspectConstraint/UIAspectConstraint.Internal.js +1 -0
  4. package/dist/core/constraints/UIAspectConstraint/UIAspectConstraint.d.ts +3 -3
  5. package/dist/core/constraints/UIAspectConstraint/UIAspectConstraint.js +14 -16
  6. package/dist/core/constraints/UIConstraint.d.ts +22 -2
  7. package/dist/core/constraints/UIConstraint.js +26 -3
  8. package/dist/core/constraints/UICustomConstraint.d.ts +4 -4
  9. package/dist/core/constraints/UICustomConstraint.js +15 -15
  10. package/dist/core/constraints/UIHeightConstraint/UIHeightConstraint.Internal.d.ts +1 -1
  11. package/dist/core/constraints/UIHeightConstraint/UIHeightConstraint.Internal.js +1 -0
  12. package/dist/core/constraints/UIHeightConstraint/UIHeightConstraint.d.ts +3 -3
  13. package/dist/core/constraints/UIHeightConstraint/UIHeightConstraint.js +11 -13
  14. package/dist/core/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.Internal.d.ts +1 -1
  15. package/dist/core/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.Internal.js +1 -3
  16. package/dist/core/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.d.ts +3 -3
  17. package/dist/core/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.js +30 -30
  18. package/dist/core/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.Internal.d.ts +1 -1
  19. package/dist/core/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.Internal.js +2 -4
  20. package/dist/core/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.d.ts +3 -3
  21. package/dist/core/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.js +40 -39
  22. package/dist/core/constraints/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.Internal.d.ts +1 -1
  23. package/dist/core/constraints/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.Internal.js +1 -0
  24. package/dist/core/constraints/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.d.ts +3 -3
  25. package/dist/core/constraints/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.js +13 -15
  26. package/dist/core/constraints/UISingleParameterConstraint/UISingleParameterConstraint.Internal.d.ts +3 -3
  27. package/dist/core/constraints/UISingleParameterConstraint/UISingleParameterConstraint.Internal.js +1 -0
  28. package/dist/core/constraints/UISingleParameterConstraint/UISingleParameterConstraint.d.ts +13 -7
  29. package/dist/core/constraints/UISingleParameterConstraint/UISingleParameterConstraint.js +37 -30
  30. package/dist/core/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.Internal.d.ts +1 -1
  31. package/dist/core/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.Internal.js +1 -3
  32. package/dist/core/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.d.ts +3 -3
  33. package/dist/core/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.js +30 -30
  34. package/dist/core/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.Internal.d.ts +1 -1
  35. package/dist/core/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.Internal.js +2 -4
  36. package/dist/core/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.d.ts +3 -3
  37. package/dist/core/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.js +40 -39
  38. package/dist/core/constraints/UIVerticalProportionConstraint/UIVerticalProportionConstraint.Internal.d.ts +1 -1
  39. package/dist/core/constraints/UIVerticalProportionConstraint/UIVerticalProportionConstraint.Internal.js +1 -0
  40. package/dist/core/constraints/UIVerticalProportionConstraint/UIVerticalProportionConstraint.d.ts +3 -3
  41. package/dist/core/constraints/UIVerticalProportionConstraint/UIVerticalProportionConstraint.js +13 -15
  42. package/dist/core/constraints/UIWidthConstraint/UIWidthConstraint.Internal.d.ts +1 -1
  43. package/dist/core/constraints/UIWidthConstraint/UIWidthConstraint.Internal.js +1 -0
  44. package/dist/core/constraints/UIWidthConstraint/UIWidthConstraint.d.ts +3 -3
  45. package/dist/core/constraints/UIWidthConstraint/UIWidthConstraint.js +11 -13
  46. package/dist/core/constraints/builders/UIConstraint2DBuilder.Internal.d.ts +3 -3
  47. package/dist/core/constraints/builders/UIConstraint2DBuilder.Internal.js +1 -3
  48. package/dist/core/constraints/builders/UIConstraint2DBuilder.d.ts +11 -11
  49. package/dist/core/constraints/builders/UIConstraint2DBuilder.js +10 -13
  50. package/dist/core/constraints/builders/UICoverConstraintBuilder.Internal.d.ts +1 -1
  51. package/dist/core/constraints/builders/UICoverConstraintBuilder.Internal.js +1 -3
  52. package/dist/core/constraints/builders/UICoverConstraintBuilder.d.ts +7 -7
  53. package/dist/core/constraints/builders/UICoverConstraintBuilder.js +10 -13
  54. package/dist/core/constraints/builders/UIFitConstraintBuilder.Internal.d.ts +1 -1
  55. package/dist/core/constraints/builders/UIFitConstraintBuilder.Internal.js +1 -3
  56. package/dist/core/constraints/builders/UIFitConstraintBuilder.d.ts +7 -7
  57. package/dist/core/constraints/builders/UIFitConstraintBuilder.js +10 -13
  58. package/dist/core/elements/UIAnchor/UIAnchor.Internal.js +3 -5
  59. package/dist/core/elements/UIAnchor/UIAnchor.d.ts +23 -5
  60. package/dist/core/elements/UIAnchor/UIAnchor.js +42 -8
  61. package/dist/core/elements/UIAnimatedImage/UIAnimatedImage.Internal.d.ts +2 -2
  62. package/dist/core/elements/UIAnimatedImage/UIAnimatedImage.Internal.js +4 -6
  63. package/dist/core/elements/UIAnimatedImage/UIAnimatedImage.d.ts +10 -10
  64. package/dist/core/elements/UIAnimatedImage/UIAnimatedImage.js +108 -111
  65. package/dist/core/elements/UIDummy/UIDummy.Internal.d.ts +4 -4
  66. package/dist/core/elements/UIDummy/UIDummy.Internal.js +5 -8
  67. package/dist/core/elements/UIDummy/UIDummy.d.ts +19 -11
  68. package/dist/core/elements/UIDummy/UIDummy.js +59 -42
  69. package/dist/core/elements/UIElement/UIElement.Internal.d.ts +5 -5
  70. package/dist/core/elements/UIElement/UIElement.Internal.js +9 -12
  71. package/dist/core/elements/UIElement/UIElement.d.ts +11 -11
  72. package/dist/core/elements/UIElement/UIElement.js +57 -60
  73. package/dist/core/elements/UIGraphics/UIGraphics.Internal.d.ts +3 -3
  74. package/dist/core/elements/UIGraphics/UIGraphics.Internal.js +4 -7
  75. package/dist/core/elements/UIGraphics/UIGraphics.d.ts +7 -7
  76. package/dist/core/elements/UIGraphics/UIGraphics.js +44 -47
  77. package/dist/core/elements/UIImage/UIImage.Internal.d.ts +2 -2
  78. package/dist/core/elements/UIImage/UIImage.Internal.js +1 -0
  79. package/dist/core/elements/UIImage/UIImage.d.ts +9 -9
  80. package/dist/core/elements/UIImage/UIImage.js +21 -24
  81. package/dist/core/elements/UINineSlice/UINineSlice.Internal.d.ts +3 -3
  82. package/dist/core/elements/UINineSlice/UINineSlice.Internal.js +3 -5
  83. package/dist/core/elements/UINineSlice/UINineSlice.d.ts +12 -12
  84. package/dist/core/elements/UINineSlice/UINineSlice.js +71 -73
  85. package/dist/core/elements/UIProgress/UIProgress.Internal.d.ts +3 -4
  86. package/dist/core/elements/UIProgress/UIProgress.Internal.js +1 -3
  87. package/dist/core/elements/UIProgress/UIProgress.d.ts +10 -10
  88. package/dist/core/elements/UIProgress/UIProgress.js +59 -62
  89. package/dist/core/elements/UIScene/UIScene.Internal.d.ts +3 -3
  90. package/dist/core/elements/UIScene/UIScene.Internal.js +11 -14
  91. package/dist/core/elements/UIScene/UIScene.d.ts +8 -8
  92. package/dist/core/elements/UIScene/UIScene.js +68 -69
  93. package/dist/core/elements/UIText/UIText.Bidi.d.ts +2 -2
  94. package/dist/core/elements/UIText/UIText.Bidi.js +3 -5
  95. package/dist/core/elements/UIText/UIText.Interfaces.d.ts +6 -2
  96. package/dist/core/elements/UIText/UIText.Interfaces.js +1 -0
  97. package/dist/core/elements/UIText/UIText.Internal.d.ts +4 -4
  98. package/dist/core/elements/UIText/UIText.Internal.js +5 -7
  99. package/dist/core/elements/UIText/UIText.Measuring.d.ts +14 -7
  100. package/dist/core/elements/UIText/UIText.Measuring.js +115 -55
  101. package/dist/core/elements/UIText/UIText.Rendering.d.ts +3 -3
  102. package/dist/core/elements/UIText/UIText.Rendering.js +6 -9
  103. package/dist/core/elements/UIText/UIText.d.ts +28 -14
  104. package/dist/core/elements/UIText/UIText.js +181 -141
  105. package/dist/core/index.d.ts +55 -54
  106. package/dist/core/index.js +53 -0
  107. package/dist/core/layers/UIFullscreenLayer/UIFullscreenLayer.Internal.d.ts +4 -4
  108. package/dist/core/layers/UIFullscreenLayer/UIFullscreenLayer.Internal.js +2 -5
  109. package/dist/core/layers/UIFullscreenLayer/UIFullscreenLayer.d.ts +4 -4
  110. package/dist/core/layers/UIFullscreenLayer/UIFullscreenLayer.js +43 -42
  111. package/dist/core/layers/UILayer/UILayer.Internal.d.ts +2 -2
  112. package/dist/core/layers/UILayer/UILayer.Internal.js +4 -7
  113. package/dist/core/layers/UILayer/UILayer.d.ts +19 -4
  114. package/dist/core/layers/UILayer/UILayer.js +125 -62
  115. package/dist/core/miscellaneous/UIBlendMode.js +1 -3
  116. package/dist/core/miscellaneous/UIExpression.js +16 -19
  117. package/dist/core/miscellaneous/UIMode.js +3 -5
  118. package/dist/core/miscellaneous/UIOrientation.js +2 -4
  119. package/dist/core/miscellaneous/UIPriority.js +5 -8
  120. package/dist/core/miscellaneous/UIRelation.js +5 -8
  121. package/dist/core/miscellaneous/UITransparencyMode.js +1 -3
  122. package/dist/core/miscellaneous/area/UIArea.js +1 -3
  123. package/dist/core/miscellaneous/area/UIAreaCircle.d.ts +1 -1
  124. package/dist/core/miscellaneous/area/UIAreaCircle.js +3 -6
  125. package/dist/core/miscellaneous/area/UIAreaPolygon.d.ts +2 -2
  126. package/dist/core/miscellaneous/area/UIAreaPolygon.js +3 -6
  127. package/dist/core/miscellaneous/area/UIAreaRectangle.d.ts +1 -1
  128. package/dist/core/miscellaneous/area/UIAreaRectangle.js +3 -6
  129. package/dist/core/miscellaneous/area/UIAreaRoundedRectangle.d.ts +1 -1
  130. package/dist/core/miscellaneous/area/UIAreaRoundedRectangle.js +3 -6
  131. package/dist/core/miscellaneous/asserts.d.ts +30 -1
  132. package/dist/core/miscellaneous/asserts.js +87 -19
  133. package/dist/core/miscellaneous/canvas.js +13 -7
  134. package/dist/core/miscellaneous/color/UIColor.Internal.d.ts +1 -1
  135. package/dist/core/miscellaneous/color/UIColor.Internal.js +1 -3
  136. package/dist/core/miscellaneous/color/UIColor.d.ts +1 -1
  137. package/dist/core/miscellaneous/color/UIColor.js +202 -205
  138. package/dist/core/miscellaneous/computeTransform.d.ts +1 -1
  139. package/dist/core/miscellaneous/computeTransform.js +4 -7
  140. package/dist/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.Internal.d.ts +10 -5
  141. package/dist/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.Internal.js +63 -58
  142. package/dist/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.Layout.d.ts +52 -0
  143. package/dist/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.Layout.js +110 -0
  144. package/dist/core/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.js +181 -261
  145. package/dist/core/miscellaneous/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.Internal.d.ts +3 -3
  146. package/dist/core/miscellaneous/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.Internal.js +1 -0
  147. package/dist/core/miscellaneous/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.js +209 -115
  148. package/dist/core/miscellaneous/generic-plane/shared.d.ts +12 -12
  149. package/dist/core/miscellaneous/generic-plane/shared.js +28 -23
  150. package/dist/core/miscellaneous/insets/UIInsets.Internal.js +1 -3
  151. package/dist/core/miscellaneous/insets/UIInsets.d.ts +1 -1
  152. package/dist/core/miscellaneous/insets/UIInsets.js +96 -99
  153. package/dist/core/miscellaneous/mask-function/UIProgressMaskFunction.js +1 -3
  154. package/dist/core/miscellaneous/mask-function/UIProgressMaskFunctionCircular.d.ts +1 -1
  155. package/dist/core/miscellaneous/mask-function/UIProgressMaskFunctionCircular.js +14 -17
  156. package/dist/core/miscellaneous/mask-function/UIProgressMaskFunctionDirectional.d.ts +2 -2
  157. package/dist/core/miscellaneous/mask-function/UIProgressMaskFunctionDirectional.js +13 -16
  158. package/dist/core/miscellaneous/math.js +3 -5
  159. package/dist/core/miscellaneous/micro/UIMicro.Internal.js +6 -8
  160. package/dist/core/miscellaneous/micro/UIMicro.d.ts +1 -1
  161. package/dist/core/miscellaneous/micro/UIMicro.js +91 -94
  162. package/dist/core/miscellaneous/resize-policy/UIResizePolicy.js +1 -3
  163. package/dist/core/miscellaneous/resize-policy/UIResizePolicyCover.d.ts +1 -1
  164. package/dist/core/miscellaneous/resize-policy/UIResizePolicyCover.js +12 -15
  165. package/dist/core/miscellaneous/resize-policy/UIResizePolicyCross.d.ts +1 -1
  166. package/dist/core/miscellaneous/resize-policy/UIResizePolicyCross.js +13 -16
  167. package/dist/core/miscellaneous/resize-policy/UIResizePolicyCrossInverted.d.ts +1 -1
  168. package/dist/core/miscellaneous/resize-policy/UIResizePolicyCrossInverted.js +13 -16
  169. package/dist/core/miscellaneous/resize-policy/UIResizePolicyFit.d.ts +1 -1
  170. package/dist/core/miscellaneous/resize-policy/UIResizePolicyFit.js +12 -15
  171. package/dist/core/miscellaneous/resize-policy/UIResizePolicyFixedHeight.d.ts +1 -1
  172. package/dist/core/miscellaneous/resize-policy/UIResizePolicyFixedHeight.js +13 -16
  173. package/dist/core/miscellaneous/resize-policy/UIResizePolicyFixedWidth.d.ts +1 -1
  174. package/dist/core/miscellaneous/resize-policy/UIResizePolicyFixedWidth.js +13 -16
  175. package/dist/core/miscellaneous/resize-policy/UIResizePolicyNone.d.ts +1 -1
  176. package/dist/core/miscellaneous/resize-policy/UIResizePolicyNone.js +3 -6
  177. package/dist/core/miscellaneous/shared.d.ts +1 -1
  178. package/dist/core/miscellaneous/shared.js +4 -7
  179. package/dist/core/miscellaneous/text-span/UITextSpan.Internal.d.ts +1 -1
  180. package/dist/core/miscellaneous/text-span/UITextSpan.Internal.js +1 -0
  181. package/dist/core/miscellaneous/text-span/UITextSpan.d.ts +2 -2
  182. package/dist/core/miscellaneous/text-span/UITextSpan.js +10 -13
  183. package/dist/core/miscellaneous/text-style/UITextStyle.Internal.js +15 -17
  184. package/dist/core/miscellaneous/text-style/UITextStyle.d.ts +13 -2
  185. package/dist/core/miscellaneous/text-style/UITextStyle.js +222 -207
  186. package/dist/core/miscellaneous/texture/UITextureView.Internal.d.ts +7 -0
  187. package/dist/core/miscellaneous/texture/UITextureView.Internal.js +16 -6
  188. package/dist/core/miscellaneous/texture/UITextureView.d.ts +1 -1
  189. package/dist/core/miscellaneous/texture/UITextureView.js +113 -117
  190. package/dist/core/miscellaneous/webglCapabilities.js +3 -4
  191. package/dist/core/shaders/UIImage.d.ts +9 -0
  192. package/dist/core/shaders/UIImage.js +14 -0
  193. package/dist/core/shaders/UINineSlice.d.ts +11 -0
  194. package/dist/core/shaders/UINineSlice.js +57 -0
  195. package/dist/core/shaders/UIProgress.d.ts +14 -0
  196. package/dist/core/shaders/UIProgress.js +21 -0
  197. package/dist/core/shaders/UIProgressMaskFunctionCircular.d.ts +2 -0
  198. package/dist/core/shaders/UIProgressMaskFunctionCircular.js +16 -0
  199. package/dist/core/shaders/UIProgressMaskFunctionDirectional.d.ts +2 -0
  200. package/dist/core/shaders/UIProgressMaskFunctionDirectional.js +15 -0
  201. package/dist/core/wrappers/UIInputWrapper/UIInputWrapper.Internal.d.ts +4 -0
  202. package/dist/core/wrappers/UIInputWrapper/UIInputWrapper.Internal.js +1 -0
  203. package/dist/core/wrappers/UIInputWrapper/UIInputWrapper.d.ts +7 -1
  204. package/dist/core/wrappers/UIInputWrapper/UIInputWrapper.js +50 -47
  205. package/dist/core/wrappers/UISceneWrapper/UISceneWrapper.Internal.d.ts +5 -2
  206. package/dist/core/wrappers/UISceneWrapper/UISceneWrapper.Internal.js +1 -0
  207. package/dist/core/wrappers/UISceneWrapper/UISceneWrapper.d.ts +11 -3
  208. package/dist/core/wrappers/UISceneWrapper/UISceneWrapper.js +42 -26
  209. package/dist/core/wrappers/UISolverWrapper/UISolverWrapper.Internal.d.ts +5 -3
  210. package/dist/core/wrappers/UISolverWrapper/UISolverWrapper.Internal.js +1 -0
  211. package/dist/core/wrappers/UISolverWrapper/UISolverWrapper.d.ts +20 -4
  212. package/dist/core/wrappers/UISolverWrapper/UISolverWrapper.js +138 -117
  213. package/dist/debug/UIAspectDebug.d.ts +3 -3
  214. package/dist/debug/UIAspectDebug.js +64 -68
  215. package/dist/debug/UIConstraintDebug.d.ts +1 -1
  216. package/dist/debug/UIConstraintDebug.js +1 -0
  217. package/dist/debug/UIHeightDebug.d.ts +3 -3
  218. package/dist/debug/UIHeightDebug.js +63 -67
  219. package/dist/debug/UIHorizontalDistanceDebug.d.ts +3 -3
  220. package/dist/debug/UIHorizontalDistanceDebug.js +76 -81
  221. package/dist/debug/UIHorizontalInterpolationDebug.d.ts +3 -3
  222. package/dist/debug/UIHorizontalInterpolationDebug.js +74 -78
  223. package/dist/debug/UILayerDebug.d.ts +1 -1
  224. package/dist/debug/UILayerDebug.js +55 -64
  225. package/dist/debug/UIVerticalDistanceDebug.d.ts +3 -3
  226. package/dist/debug/UIVerticalDistanceDebug.js +76 -81
  227. package/dist/debug/UIVerticalInterpolationDebug.d.ts +3 -3
  228. package/dist/debug/UIVerticalInterpolationDebug.js +74 -78
  229. package/dist/debug/UIWidthDebug.d.ts +3 -3
  230. package/dist/debug/UIWidthDebug.js +63 -67
  231. package/dist/debug/index.d.ts +8 -8
  232. package/dist/debug/index.js +8 -8
  233. package/dist/debug/miscellaneous.js +8 -11
  234. package/dist/particles/behaviorModules/UIBehaviorDirectionalGravity.d.ts +3 -3
  235. package/dist/particles/behaviorModules/UIBehaviorDirectionalGravity.js +13 -16
  236. package/dist/particles/behaviorModules/UIBehaviorModule.d.ts +1 -1
  237. package/dist/particles/behaviorModules/UIBehaviorModule.js +1 -3
  238. package/dist/particles/behaviorModules/UIBehaviorPointGravity.d.ts +3 -3
  239. package/dist/particles/behaviorModules/UIBehaviorPointGravity.js +37 -40
  240. package/dist/particles/behaviorModules/UIBehaviorScaleOscillation.d.ts +41 -0
  241. package/dist/particles/behaviorModules/UIBehaviorScaleOscillation.js +87 -0
  242. package/dist/particles/behaviorModules/UIBehaviorScaleOverLife.d.ts +2 -2
  243. package/dist/particles/behaviorModules/UIBehaviorScaleOverLife.js +17 -20
  244. package/dist/particles/behaviorModules/UIBehaviorTorqueDamping.d.ts +2 -2
  245. package/dist/particles/behaviorModules/UIBehaviorTorqueDamping.js +13 -16
  246. package/dist/particles/behaviorModules/UIBehaviorTorqueNoise.d.ts +2 -2
  247. package/dist/particles/behaviorModules/UIBehaviorTorqueNoise.js +21 -24
  248. package/dist/particles/behaviorModules/UIBehaviorVelocityDamping.d.ts +2 -2
  249. package/dist/particles/behaviorModules/UIBehaviorVelocityDamping.js +13 -16
  250. package/dist/particles/behaviorModules/UIBehaviorVelocityNoise.d.ts +2 -2
  251. package/dist/particles/behaviorModules/UIBehaviorVelocityNoise.js +21 -24
  252. package/dist/particles/elements/UIEmitter.Internal.d.ts +2 -2
  253. package/dist/particles/elements/UIEmitter.Internal.js +6 -9
  254. package/dist/particles/elements/UIEmitter.d.ts +17 -11
  255. package/dist/particles/elements/UIEmitter.js +100 -88
  256. package/dist/particles/index.d.ts +20 -18
  257. package/dist/particles/index.js +19 -18
  258. package/dist/particles/instancedParticle/UIInstancedParticle.Internal.d.ts +1 -1
  259. package/dist/particles/instancedParticle/UIInstancedParticle.Internal.js +14 -15
  260. package/dist/particles/instancedParticle/UIInstancedParticle.d.ts +4 -1
  261. package/dist/particles/instancedParticle/UIInstancedParticle.js +40 -32
  262. package/dist/particles/miscellaneous/miscellaneous.d.ts +3 -3
  263. package/dist/particles/miscellaneous/miscellaneous.js +26 -27
  264. package/dist/particles/renderingModules/UIRenderingColorOverLife.d.ts +2 -2
  265. package/dist/particles/renderingModules/UIRenderingColorOverLife.js +5 -8
  266. package/dist/particles/renderingModules/UIRenderingColorOverVelocity.d.ts +2 -2
  267. package/dist/particles/renderingModules/UIRenderingColorOverVelocity.js +6 -9
  268. package/dist/particles/renderingModules/UIRenderingModule.js +1 -3
  269. package/dist/particles/renderingModules/UIRenderingTexture.d.ts +2 -2
  270. package/dist/particles/renderingModules/UIRenderingTexture.js +4 -7
  271. package/dist/particles/shaders/UIRenderingColorOverLife.d.ts +2 -0
  272. package/dist/particles/shaders/UIRenderingColorOverLife.js +7 -0
  273. package/dist/particles/shaders/UIRenderingColorOverVelocity.d.ts +9 -0
  274. package/dist/particles/shaders/UIRenderingColorOverVelocity.js +16 -0
  275. package/dist/particles/shaders/UIRenderingTexture.d.ts +2 -0
  276. package/dist/particles/shaders/UIRenderingTexture.js +7 -0
  277. package/dist/particles/spawnModules/UISpawnModule.d.ts +1 -1
  278. package/dist/particles/spawnModules/UISpawnModule.js +1 -3
  279. package/dist/particles/spawnModules/UISpawnOffset.d.ts +3 -3
  280. package/dist/particles/spawnModules/UISpawnOffset.js +12 -15
  281. package/dist/particles/spawnModules/UISpawnRandomLifetime.d.ts +2 -2
  282. package/dist/particles/spawnModules/UISpawnRandomLifetime.js +13 -16
  283. package/dist/particles/spawnModules/UISpawnRandomRotation.d.ts +2 -2
  284. package/dist/particles/spawnModules/UISpawnRandomRotation.js +13 -16
  285. package/dist/particles/spawnModules/UISpawnRandomScale.d.ts +2 -2
  286. package/dist/particles/spawnModules/UISpawnRandomScale.js +19 -22
  287. package/dist/particles/spawnModules/UISpawnRandomTorque.d.ts +2 -2
  288. package/dist/particles/spawnModules/UISpawnRandomTorque.js +13 -16
  289. package/dist/particles/spawnModules/UISpawnRandomVelocity.d.ts +2 -2
  290. package/dist/particles/spawnModules/UISpawnRandomVelocity.js +21 -24
  291. package/dist/particles/spawnModules/UISpawnRectangle.d.ts +3 -3
  292. package/dist/particles/spawnModules/UISpawnRectangle.js +21 -24
  293. package/package.json +13 -17
  294. package/dist/_virtual/2d.js +0 -3
  295. package/dist/_virtual/3d.js +0 -3
  296. package/dist/_virtual/4d.js +0 -3
  297. package/dist/_virtual/mod.js +0 -5
  298. package/dist/_virtual/mod2.js +0 -3
  299. package/dist/core/shaders/UIImage.glsl.js +0 -3
  300. package/dist/core/shaders/UINineSlice.glsl.js +0 -3
  301. package/dist/core/shaders/UIProgress.glsl.js +0 -3
  302. package/dist/core/shaders/UIProgressMaskFunctionCircular.glsl.js +0 -3
  303. package/dist/core/shaders/UIProgressMaskFunctionDirectional.glsl.js +0 -3
  304. package/dist/index.js +0 -52
  305. package/dist/node_modules/fast-simplex-noise/lib/2d.js +0 -93
  306. package/dist/node_modules/fast-simplex-noise/lib/3d.js +0 -142
  307. package/dist/node_modules/fast-simplex-noise/lib/4d.js +0 -196
  308. package/dist/node_modules/fast-simplex-noise/lib/mod.js +0 -24
  309. package/dist/node_modules/three/examples/jsm/lines/Line2.js +0 -56
  310. package/dist/node_modules/three/examples/jsm/lines/LineGeometry.js +0 -157
  311. package/dist/node_modules/three/examples/jsm/lines/LineMaterial.js +0 -691
  312. package/dist/node_modules/three/examples/jsm/lines/LineSegments2.js +0 -415
  313. package/dist/node_modules/three/examples/jsm/lines/LineSegmentsGeometry.js +0 -289
  314. package/dist/particles/shaders/UIRenderingColorOverLife.glsl.js +0 -3
  315. package/dist/particles/shaders/UIRenderingColorOverVelocity.glsl.js +0 -3
  316. package/dist/particles/shaders/UIRenderingTexture.glsl.js +0 -3
@@ -1,36 +1,25 @@
1
- import { Mesh, Vector3, Matrix4, InstancedBufferAttribute } from 'three';
2
- import { resolveGLSLTypeInfo, resolvePropertyUniform, cloneProperty, extractZIndexFromBuffer, cloneGLProperties, arePropertiesPartiallyCompatible } from '../shared.js';
3
- import { INITIAL_CAPACITY, INSTANCED_PLANE_GEOMETRY, buildMaterial, CAPACITY_STEP, buildEmptyInstancedBufferAttribute, writePropertyToArray, reconstructValue, copyBetweenBuffers, shiftBufferRegion } from './UIGenericInstancedPlane.Internal.js';
4
-
1
+ import { Mesh } from "three";
2
+ import { assertVertexAttributeBudget } from "../../asserts.js";
3
+ import { arePropertiesPartiallyCompatible, cloneGLProperties, resolvePropertyUniform, TRANSFORM_ZINDEX_OFFSET, } from "../shared.js";
4
+ import { BUILTIN_BLEND, BUILTIN_HSL, BUILTIN_TRANSFORM, BUILTIN_VISIBILITY, buildMaterial, buildPackedAttribute, buildPlaneLayout, CAPACITY_STEP, copyBetweenBuffers, INITIAL_CAPACITY, INSTANCED_PLANE_GEOMETRY, shiftBufferRegion, writePropertyToArray, } from "./UIGenericInstancedPlane.Internal.js";
5
+ import { packedAttributeName, resolvePackedField } from "./UIGenericInstancedPlane.Layout.js";
6
+ const TEMP_FIELD_VALUES = new Float32Array(16);
5
7
  /**
6
8
  * Instanced shader plane mesh for batched rendering.
7
9
  *
8
10
  * Operates on indices, not handlers. Registry manages handler->index mapping.
9
11
  * Elements are ordered by zIndex (ascending) within the buffer.
10
12
  *
13
+ * Per-instance data (the builtin transform, visibility, blend and HSL plus every instantiable
14
+ * property) is packed into as few vertex attributes as possible, see
15
+ * UIGenericInstancedPlane.Layout.ts. The zIndex is read back from the packed transform.
16
+ *
11
17
  * @internal
12
18
  */
13
- class UIGenericInstancedPlane extends Mesh {
19
+ export class UIGenericInstancedPlane extends Mesh {
14
20
  constructor(source, properties, transparency, initialCapacity = INITIAL_CAPACITY) {
15
21
  const uniformProperties = {};
16
- const varyingProperties = {
17
- instanceVisibility: {
18
- value: 1,
19
- glslTypeInfo: resolveGLSLTypeInfo("number"),
20
- },
21
- instanceTransform: {
22
- value: new Matrix4().identity(),
23
- glslTypeInfo: resolveGLSLTypeInfo("Matrix4"),
24
- },
25
- instanceBlend: {
26
- value: 1,
27
- glslTypeInfo: resolveGLSLTypeInfo("number"),
28
- },
29
- instanceHSL: {
30
- value: new Vector3(0, 1, 0),
31
- glslTypeInfo: resolveGLSLTypeInfo("Vector3"),
32
- },
33
- };
22
+ const varyingProperties = {};
34
23
  for (const name in properties) {
35
24
  const descriptor = properties[name];
36
25
  if (descriptor.glslTypeInfo.instantiable) {
@@ -40,213 +29,155 @@ class UIGenericInstancedPlane extends Mesh {
40
29
  uniformProperties[name] = descriptor;
41
30
  }
42
31
  }
32
+ const layout = buildPlaneLayout(varyingProperties);
43
33
  const instancedGeometry = INSTANCED_PLANE_GEOMETRY.clone();
44
- const shaderMaterial = buildMaterial(source, uniformProperties, varyingProperties, transparency);
34
+ const shaderMaterial = buildMaterial(source, uniformProperties, layout, transparency);
45
35
  super(instancedGeometry, shaderMaterial);
36
+ this.onBeforeRenderInternal = (renderer) => {
37
+ assertVertexAttributeBudget(renderer, this.vertexAttributeCount, this.vertexAttributeSubject);
38
+ };
46
39
  this.frustumCulled = false;
47
40
  this.matrixAutoUpdate = false;
48
41
  this.matrixWorldAutoUpdate = false;
49
42
  this.source = source;
50
43
  this.transparency = transparency;
51
- this._private_instancedGeometry = instancedGeometry;
52
- this._private_shaderMaterial = shaderMaterial;
53
- this._private_uniformProperties = uniformProperties;
54
- this._private_varyingProperties = varyingProperties;
55
- this._private_propertyBuffers = new Map();
56
- this._private_capacity = Math.max(Math.ceil(initialCapacity / CAPACITY_STEP) * CAPACITY_STEP, CAPACITY_STEP);
57
- this._private_instancesCountInternal = 0;
58
- this._private_instancedGeometry.instanceCount = 0;
59
- for (const name in this._private_varyingProperties) {
60
- const { value } = this._private_varyingProperties[name];
61
- const attribute = buildEmptyInstancedBufferAttribute(value, this._private_capacity);
62
- this._private_instancedGeometry.setAttribute(`a_${name}`, attribute);
63
- this._private_propertyBuffers.set(name, attribute);
64
- }
65
- for (const name in this._private_uniformProperties) {
66
- const { value } = this._private_uniformProperties[name];
67
- const uniform = resolvePropertyUniform(name, this._private_shaderMaterial);
44
+ this.instancedGeometry = instancedGeometry;
45
+ this.shaderMaterial = shaderMaterial;
46
+ this.properties = properties;
47
+ this.uniformProperties = uniformProperties;
48
+ this.layout = layout;
49
+ this.packedAttributes = [];
50
+ this.transformField = resolvePackedField(layout, BUILTIN_TRANSFORM);
51
+ this.visibilityField = resolvePackedField(layout, BUILTIN_VISIBILITY);
52
+ this.blendField = resolvePackedField(layout, BUILTIN_BLEND);
53
+ this.hslField = resolvePackedField(layout, BUILTIN_HSL);
54
+ const zIndexColumn = this.transformField.columns.find(({ sourceOffset, size }) => sourceOffset <= TRANSFORM_ZINDEX_OFFSET && TRANSFORM_ZINDEX_OFFSET < sourceOffset + size);
55
+ if (zIndexColumn === undefined) {
56
+ throw new Error(`UIGenericInstancedPlane.constructor: transform layout lacks the zIndex`);
57
+ }
58
+ this.zIndexAttributeIndex = zIndexColumn.attributeIndex;
59
+ this.zIndexComponentOffset =
60
+ zIndexColumn.componentOffset + TRANSFORM_ZINDEX_OFFSET - zIndexColumn.sourceOffset;
61
+ this.vertexAttributeCount =
62
+ Object.keys(INSTANCED_PLANE_GEOMETRY.attributes).length + layout.attributeSizes.length;
63
+ this.vertexAttributeSubject = `UIGenericInstancedPlane.onBeforeRender.properties (${Object.keys(varyingProperties).join(", ")})`;
64
+ this.onBeforeRender = this.onBeforeRenderInternal;
65
+ this.capacity = Math.max(Math.ceil(initialCapacity / CAPACITY_STEP) * CAPACITY_STEP, CAPACITY_STEP);
66
+ this.instancesCountInternal = 0;
67
+ this.instancedGeometry.instanceCount = 0;
68
+ for (let i = 0; i < layout.attributeSizes.length; i++) {
69
+ const attribute = buildPackedAttribute(layout.attributeSizes[i], this.capacity);
70
+ this.instancedGeometry.setAttribute(packedAttributeName(i), attribute);
71
+ this.packedAttributes.push(attribute);
72
+ }
73
+ for (const name in this.uniformProperties) {
74
+ const { value } = this.uniformProperties[name];
75
+ const uniform = resolvePropertyUniform(name, this.shaderMaterial);
68
76
  uniform.value = value;
69
77
  }
70
- this._private_shaderMaterial.uniformsNeedUpdate = true;
78
+ this.shaderMaterial.uniformsNeedUpdate = true;
71
79
  }
72
80
  /** Current number of active instances */
73
81
  get instancesCount() {
74
- return this._private_instancesCountInternal;
82
+ return this.instancesCountInternal;
75
83
  }
76
84
  /**
77
85
  * Insert instance at given index. Elements at [index..end) are shifted right.
78
86
  */
79
87
  insertAt(index, properties, transform, visibility, blend, hsl) {
80
- if (index < 0 || index > this._private_instancesCountInternal) {
81
- throw new Error(`UIGenericInstancedPlane.insertAt.index: out of bounds (index=${index}, count=${this._private_instancesCountInternal})`);
82
- }
83
- this._private_ensureCapacity(this._private_instancesCountInternal + 1);
84
- if (index < this._private_instancesCountInternal) {
85
- this._private_shiftBuffersRight(index, 1);
86
- }
87
- this._private_writeToBuffers(index, properties, transform, visibility, blend, hsl);
88
- this._private_instancesCountInternal++;
89
- this._private_instancedGeometry.instanceCount = this._private_instancesCountInternal;
88
+ if (index < 0 || index > this.instancesCountInternal) {
89
+ throw new Error(`UIGenericInstancedPlane.insertAt.index: out of bounds (index=${index}, count=${this.instancesCountInternal})`);
90
+ }
91
+ this.ensureCapacity(this.instancesCountInternal + 1);
92
+ if (index < this.instancesCountInternal) {
93
+ this.shiftBuffersRight(index, 1);
94
+ }
95
+ this.writeField(index, this.transformField, transform.elements);
96
+ this.writeVisibility(index, visibility);
97
+ this.writeBlend(index, blend);
98
+ this.writeHSL(index, hsl);
99
+ this.writeProperties(index, properties);
100
+ this.instancesCountInternal++;
101
+ this.instancedGeometry.instanceCount = this.instancesCountInternal;
90
102
  }
91
103
  /**
92
104
  * Remove instance at given index. Elements at [index+1..end) are shifted left.
93
105
  */
94
106
  removeAt(index) {
95
- if (index < 0 || index >= this._private_instancesCountInternal) {
96
- throw new Error(`UIGenericInstancedPlane.removeAt.index: out of bounds (index=${index}, count=${this._private_instancesCountInternal})`);
107
+ if (index < 0 || index >= this.instancesCountInternal) {
108
+ throw new Error(`UIGenericInstancedPlane.removeAt.index: out of bounds (index=${index}, count=${this.instancesCountInternal})`);
97
109
  }
98
- if (index < this._private_instancesCountInternal - 1) {
99
- this._private_shiftBuffersLeft(index + 1, 1);
110
+ if (index < this.instancesCountInternal - 1) {
111
+ this.shiftBuffersLeft(index + 1, 1);
100
112
  }
101
- this._private_instancesCountInternal--;
102
- this._private_instancedGeometry.instanceCount = this._private_instancesCountInternal;
113
+ this.instancesCountInternal--;
114
+ this.instancedGeometry.instanceCount = this.instancesCountInternal;
103
115
  }
104
116
  /** Update properties at given index */
105
117
  setPropertiesAt(index, properties) {
106
- if (index < 0 || index >= this._private_instancesCountInternal) {
107
- throw new Error(`UIGenericInstancedPlane.setPropertiesAt.index: out of bounds (index=${index}, count=${this._private_instancesCountInternal})`);
108
- }
109
- for (const name in properties) {
110
- const { value, glslTypeInfo } = properties[name];
111
- if (glslTypeInfo.instantiable) {
112
- const attribute = this._private_resolveAttribute(name);
113
- const offset = index * attribute.itemSize;
114
- writePropertyToArray(value, attribute.array, offset);
115
- attribute.needsUpdate = true;
116
- }
117
- else {
118
- const uniform = resolvePropertyUniform(name, this._private_shaderMaterial);
119
- uniform.value = value;
120
- this._private_shaderMaterial.uniformsNeedUpdate = true;
121
- }
118
+ if (index < 0 || index >= this.instancesCountInternal) {
119
+ throw new Error(`UIGenericInstancedPlane.setPropertiesAt.index: out of bounds (index=${index}, count=${this.instancesCountInternal})`);
122
120
  }
121
+ this.writeProperties(index, properties);
123
122
  }
124
123
  /** Update transform at given index */
125
124
  setTransformAt(index, transform) {
126
- if (index < 0 || index >= this._private_instancesCountInternal) {
127
- throw new Error(`UIGenericInstancedPlane.setTransformAt.index: out of bounds (index=${index}, count=${this._private_instancesCountInternal})`);
128
- }
129
- const attribute = this._private_resolveAttribute("instanceTransform");
130
- const array = attribute.array;
131
- const offset = index * 16;
132
- const elements = transform.elements;
133
- for (let j = 0; j < 16; j++) {
134
- array[offset + j] = elements[j];
125
+ if (index < 0 || index >= this.instancesCountInternal) {
126
+ throw new Error(`UIGenericInstancedPlane.setTransformAt.index: out of bounds (index=${index}, count=${this.instancesCountInternal})`);
135
127
  }
136
- attribute.needsUpdate = true;
128
+ this.writeField(index, this.transformField, transform.elements);
137
129
  }
138
130
  /** Update visibility at given index */
139
131
  setVisibilityAt(index, visible) {
140
- if (index < 0 || index >= this._private_instancesCountInternal) {
141
- throw new Error(`UIGenericInstancedPlane.setVisibilityAt.index: out of bounds (index=${index}, count=${this._private_instancesCountInternal})`);
132
+ if (index < 0 || index >= this.instancesCountInternal) {
133
+ throw new Error(`UIGenericInstancedPlane.setVisibilityAt.index: out of bounds (index=${index}, count=${this.instancesCountInternal})`);
142
134
  }
143
- const attribute = this._private_resolveAttribute("instanceVisibility");
144
- const array = attribute.array;
145
- array[index] = visible ? 1 : 0;
146
- attribute.needsUpdate = true;
135
+ this.writeVisibility(index, visible);
147
136
  }
148
137
  /** Update blend factor at given index (1 = normal over, 0 = additive) */
149
138
  setBlendAt(index, blend) {
150
- if (index < 0 || index >= this._private_instancesCountInternal) {
151
- throw new Error(`UIGenericInstancedPlane.setBlendAt.index: out of bounds (index=${index}, count=${this._private_instancesCountInternal})`);
139
+ if (index < 0 || index >= this.instancesCountInternal) {
140
+ throw new Error(`UIGenericInstancedPlane.setBlendAt.index: out of bounds (index=${index}, count=${this.instancesCountInternal})`);
152
141
  }
153
- const attribute = this._private_resolveAttribute("instanceBlend");
154
- const array = attribute.array;
155
- array[index] = blend;
156
- attribute.needsUpdate = true;
142
+ this.writeBlend(index, blend);
157
143
  }
158
144
  /** Update HSL adjustment at given index (hue in turns, saturation multiplier, lightness offset) */
159
145
  setHSLAt(index, hsl) {
160
- if (index < 0 || index >= this._private_instancesCountInternal) {
161
- throw new Error(`UIGenericInstancedPlane.setHSLAt.index: out of bounds (index=${index}, count=${this._private_instancesCountInternal})`);
162
- }
163
- const attribute = this._private_resolveAttribute("instanceHSL");
164
- const array = attribute.array;
165
- const offset = index * 3;
166
- array[offset] = hsl.h;
167
- array[offset + 1] = hsl.s;
168
- array[offset + 2] = hsl.l;
169
- attribute.needsUpdate = true;
170
- }
171
- /**
172
- * Extract complete instance data at given index.
173
- * Returns cloned data safe for external use.
174
- */
175
- extractDataAt(index) {
176
- if (index < 0 || index >= this._private_instancesCountInternal) {
177
- throw new Error(`UIGenericInstancedPlane.extractDataAt.index: out of bounds (index=${index}, count=${this._private_instancesCountInternal})`);
178
- }
179
- const properties = {};
180
- for (const name in this._private_uniformProperties) {
181
- const prop = this._private_uniformProperties[name];
182
- properties[name] = {
183
- value: cloneProperty(prop.value),
184
- glslTypeInfo: prop.glslTypeInfo,
185
- };
146
+ if (index < 0 || index >= this.instancesCountInternal) {
147
+ throw new Error(`UIGenericInstancedPlane.setHSLAt.index: out of bounds (index=${index}, count=${this.instancesCountInternal})`);
186
148
  }
187
- for (const name in this._private_varyingProperties) {
188
- if (name === "instanceVisibility" ||
189
- name === "instanceTransform" ||
190
- name === "instanceBlend" ||
191
- name === "instanceHSL") {
192
- continue;
193
- }
194
- const { value, glslTypeInfo } = this._private_varyingProperties[name];
195
- const attribute = this._private_propertyBuffers.get(name);
196
- const array = attribute.array;
197
- const offset = index * attribute.itemSize;
198
- properties[name] = {
199
- value: reconstructValue(value, array, offset),
200
- glslTypeInfo,
201
- };
202
- }
203
- const transformAttribute = this._private_propertyBuffers.get("instanceTransform");
204
- const transformArray = transformAttribute.array;
205
- const transform = new Matrix4();
206
- transform.fromArray(transformArray, index * 16);
207
- const visibilityAttribute = this._private_propertyBuffers.get("instanceVisibility");
208
- const visibilityArray = visibilityAttribute.array;
209
- const visibility = visibilityArray[index] >= 0.5;
210
- return {
211
- source: this.source,
212
- properties,
213
- transform,
214
- visibility,
215
- transparency: this.transparency,
216
- };
149
+ this.writeHSL(index, hsl);
217
150
  }
218
151
  /** Get zIndex at given index (from transform buffer) */
219
152
  getZIndexAt(index) {
220
- if (index < 0 || index >= this._private_instancesCountInternal) {
221
- throw new Error(`UIGenericInstancedPlane.getZIndexAt.index: out of bounds (index=${index}, count=${this._private_instancesCountInternal})`);
153
+ if (index < 0 || index >= this.instancesCountInternal) {
154
+ throw new Error(`UIGenericInstancedPlane.getZIndexAt.index: out of bounds (index=${index}, count=${this.instancesCountInternal})`);
222
155
  }
223
- const attribute = this._private_propertyBuffers.get("instanceTransform");
224
- return extractZIndexFromBuffer(attribute.array, index);
156
+ const attribute = this.packedAttributes[this.zIndexAttributeIndex];
157
+ return attribute.array[index * attribute.itemSize + this.zIndexComponentOffset];
225
158
  }
226
159
  /**
227
160
  * Merge another instanced plane into this one (append).
228
161
  * Other plane becomes empty after merge.
229
162
  */
230
163
  merge(other) {
231
- if (other._private_instancesCountInternal === 0) {
164
+ if (other.layout.signature !== this.layout.signature) {
165
+ throw new Error(`UIGenericInstancedPlane.merge.other: incompatible attribute layout`);
166
+ }
167
+ if (other.instancesCountInternal === 0) {
232
168
  return;
233
169
  }
234
- this._private_ensureCapacity(this._private_instancesCountInternal + other._private_instancesCountInternal);
235
- for (const [name, thisAttribute] of this._private_propertyBuffers) {
236
- const otherAttribute = other._private_propertyBuffers.get(name);
237
- if (!otherAttribute) {
238
- throw new Error(`UIGenericInstancedPlane.merge: missing attribute ${name} in source`);
239
- }
170
+ this.ensureCapacity(this.instancesCountInternal + other.instancesCountInternal);
171
+ for (let i = 0; i < this.packedAttributes.length; i++) {
172
+ const thisAttribute = this.packedAttributes[i];
240
173
  const itemSize = thisAttribute.itemSize;
241
- const srcArray = otherAttribute.array;
242
- const dstArray = thisAttribute.array;
243
- copyBetweenBuffers(srcArray, 0, dstArray, this._private_instancesCountInternal * itemSize, other._private_instancesCountInternal * itemSize);
174
+ copyBetweenBuffers(other.packedAttributes[i].array, 0, thisAttribute.array, this.instancesCountInternal * itemSize, other.instancesCountInternal * itemSize);
244
175
  thisAttribute.needsUpdate = true;
245
176
  }
246
- this._private_instancesCountInternal += other._private_instancesCountInternal;
247
- this._private_instancedGeometry.instanceCount = this._private_instancesCountInternal;
248
- other._private_instancesCountInternal = 0;
249
- other._private_instancedGeometry.instanceCount = 0;
177
+ this.instancesCountInternal += other.instancesCountInternal;
178
+ this.instancedGeometry.instanceCount = this.instancesCountInternal;
179
+ other.instancesCountInternal = 0;
180
+ other.instancedGeometry.instanceCount = 0;
250
181
  }
251
182
  /**
252
183
  * Split this plane at given index.
@@ -254,140 +185,129 @@ class UIGenericInstancedPlane extends Mesh {
254
185
  * This plane keeps elements [0..atIndex).
255
186
  */
256
187
  split(atIndex) {
257
- if (atIndex <= 0 || atIndex >= this._private_instancesCountInternal) {
258
- throw new Error(`UIGenericInstancedPlane.split.atIndex: must be in range (0, count) (atIndex=${atIndex}, count=${this._private_instancesCountInternal})`);
259
- }
260
- const tailCount = this._private_instancesCountInternal - atIndex;
261
- const newPlane = new UIGenericInstancedPlane(this.source, cloneGLProperties({
262
- ...this._private_uniformProperties,
263
- ...this._private_varyingProperties,
264
- }), this.transparency, tailCount);
265
- for (const [name, thisAttribute] of this._private_propertyBuffers) {
266
- const newAttribute = newPlane._private_propertyBuffers.get(name);
267
- if (!newAttribute) {
268
- throw new Error(`UIGenericInstancedPlane.split: missing attribute ${name} in new plane`);
269
- }
188
+ if (atIndex <= 0 || atIndex >= this.instancesCountInternal) {
189
+ throw new Error(`UIGenericInstancedPlane.split.atIndex: must be in range (0, count) (atIndex=${atIndex}, count=${this.instancesCountInternal})`);
190
+ }
191
+ const tailCount = this.instancesCountInternal - atIndex;
192
+ const newPlane = new UIGenericInstancedPlane(this.source, cloneGLProperties(this.properties), this.transparency, tailCount);
193
+ for (let i = 0; i < this.packedAttributes.length; i++) {
194
+ const thisAttribute = this.packedAttributes[i];
195
+ const newAttribute = newPlane.packedAttributes[i];
270
196
  const itemSize = thisAttribute.itemSize;
271
- const srcArray = thisAttribute.array;
272
- const dstArray = newAttribute.array;
273
- copyBetweenBuffers(srcArray, atIndex * itemSize, dstArray, 0, tailCount * itemSize);
197
+ copyBetweenBuffers(thisAttribute.array, atIndex * itemSize, newAttribute.array, 0, tailCount * itemSize);
274
198
  newAttribute.needsUpdate = true;
275
199
  }
276
- newPlane._private_instancesCountInternal = tailCount;
277
- newPlane._private_instancedGeometry.instanceCount = tailCount;
278
- this._private_instancesCountInternal = atIndex;
279
- this._private_instancedGeometry.instanceCount = atIndex;
200
+ newPlane.instancesCountInternal = tailCount;
201
+ newPlane.instancedGeometry.instanceCount = tailCount;
202
+ this.instancesCountInternal = atIndex;
203
+ this.instancedGeometry.instanceCount = atIndex;
280
204
  return newPlane;
281
205
  }
282
206
  /**
283
207
  * Check if this plane can accept elements with given parameters.
284
208
  */
285
209
  isCompatibleWith(source, properties, transparency) {
286
- if (this.source !== source) {
287
- return false;
288
- }
289
- if (this.transparency !== transparency) {
290
- return false;
291
- }
292
- const result = arePropertiesPartiallyCompatible({ ...this._private_uniformProperties, ...this._private_varyingProperties }, properties);
293
- return result;
210
+ return (this.source === source &&
211
+ this.transparency === transparency &&
212
+ arePropertiesPartiallyCompatible(this.properties, properties));
294
213
  }
295
- /** Get all properties configuration (for compatibility checks) */
296
- getProperties() {
297
- return { ...this._private_uniformProperties, ...this._private_varyingProperties };
214
+ /**
215
+ * Check if another plane can be merged into this one: same shader source and transparency, same
216
+ * attribute layout and the same uniform values.
217
+ */
218
+ canMerge(other) {
219
+ return (this.source === other.source &&
220
+ this.transparency === other.transparency &&
221
+ this.layout.signature === other.layout.signature &&
222
+ arePropertiesPartiallyCompatible(this.uniformProperties, other.uniformProperties) &&
223
+ arePropertiesPartiallyCompatible(other.uniformProperties, this.uniformProperties));
298
224
  }
299
225
  /** Remove all instances, reset to empty state */
300
226
  clearInstances() {
301
- this._private_instancesCountInternal = 0;
302
- this._private_instancedGeometry.instanceCount = 0;
227
+ this.instancesCountInternal = 0;
228
+ this.instancedGeometry.instanceCount = 0;
303
229
  }
304
230
  /** Dispose geometry, material, and clear buffers */
305
231
  destroy() {
306
- this._private_instancedGeometry.dispose();
307
- this._private_shaderMaterial.dispose();
308
- this._private_propertyBuffers.clear();
232
+ this.instancedGeometry.dispose();
233
+ this.shaderMaterial.dispose();
234
+ this.packedAttributes.length = 0;
309
235
  }
310
- _private_ensureCapacity(requiredCapacity) {
311
- if (requiredCapacity <= this._private_capacity) {
236
+ ensureCapacity(requiredCapacity) {
237
+ if (requiredCapacity <= this.capacity) {
312
238
  return;
313
239
  }
314
240
  const newCapacity = Math.ceil(requiredCapacity / CAPACITY_STEP) * CAPACITY_STEP;
315
- for (const [name, oldAttribute] of this._private_propertyBuffers) {
316
- const itemSize = oldAttribute.itemSize;
317
- const newArray = new Float32Array(newCapacity * itemSize);
318
- newArray.set(oldAttribute.array);
319
- const newAttribute = new InstancedBufferAttribute(newArray, itemSize);
320
- this._private_instancedGeometry.setAttribute(`a_${name}`, newAttribute);
321
- this._private_propertyBuffers.set(name, newAttribute);
322
- }
323
- this._private_capacity = newCapacity;
241
+ for (let i = 0; i < this.packedAttributes.length; i++) {
242
+ const oldAttribute = this.packedAttributes[i];
243
+ const newAttribute = buildPackedAttribute(oldAttribute.itemSize, newCapacity);
244
+ newAttribute.array.set(oldAttribute.array);
245
+ this.instancedGeometry.setAttribute(packedAttributeName(i), newAttribute);
246
+ this.packedAttributes[i] = newAttribute;
247
+ }
248
+ this.capacity = newCapacity;
249
+ // three.js caches the drawable instance count from the attribute sizes on the first render and
250
+ // only resets it on dispose; without this a grown plane keeps drawing the old capacity
251
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- private three.js field
252
+ this.instancedGeometry._maxInstanceCount = newCapacity;
324
253
  }
325
- _private_shiftBuffersRight(fromIndex, delta) {
326
- const elementsToMove = this._private_instancesCountInternal - fromIndex;
254
+ shiftBuffersRight(fromIndex, delta) {
255
+ const elementsToMove = this.instancesCountInternal - fromIndex;
327
256
  if (elementsToMove <= 0) {
328
257
  return;
329
258
  }
330
- for (const attribute of this._private_propertyBuffers.values()) {
259
+ for (const attribute of this.packedAttributes) {
331
260
  shiftBufferRegion(attribute.array, attribute.itemSize, fromIndex, elementsToMove, delta);
332
261
  attribute.needsUpdate = true;
333
262
  }
334
263
  }
335
- _private_shiftBuffersLeft(fromIndex, delta) {
336
- const elementsToMove = this._private_instancesCountInternal - fromIndex;
264
+ shiftBuffersLeft(fromIndex, delta) {
265
+ const elementsToMove = this.instancesCountInternal - fromIndex;
337
266
  if (elementsToMove <= 0) {
338
267
  return;
339
268
  }
340
- for (const attribute of this._private_propertyBuffers.values()) {
269
+ for (const attribute of this.packedAttributes) {
341
270
  shiftBufferRegion(attribute.array, attribute.itemSize, fromIndex, elementsToMove, -delta);
342
271
  attribute.needsUpdate = true;
343
272
  }
344
273
  }
345
- _private_writeToBuffers(index, properties, transform, visibility, blend, hsl) {
346
- const visibilityAttribute = this._private_resolveAttribute("instanceVisibility");
347
- visibilityAttribute.array[index] = visibility ? 1 : 0;
348
- visibilityAttribute.needsUpdate = true;
349
- const blendAttribute = this._private_resolveAttribute("instanceBlend");
350
- blendAttribute.array[index] = blend;
351
- blendAttribute.needsUpdate = true;
352
- const hslAttribute = this._private_resolveAttribute("instanceHSL");
353
- const hslArray = hslAttribute.array;
354
- const hslOffset = index * 3;
355
- hslArray[hslOffset] = hsl.h;
356
- hslArray[hslOffset + 1] = hsl.s;
357
- hslArray[hslOffset + 2] = hsl.l;
358
- hslAttribute.needsUpdate = true;
359
- const transformAttribute = this._private_resolveAttribute("instanceTransform");
360
- const transformArray = transformAttribute.array;
361
- const transformOffset = index * 16;
362
- const elements = transform.elements;
363
- for (let j = 0; j < 16; j++) {
364
- transformArray[transformOffset + j] = elements[j];
365
- }
366
- transformAttribute.needsUpdate = true;
274
+ writeProperties(index, properties) {
367
275
  for (const name in properties) {
368
276
  const { value, glslTypeInfo } = properties[name];
369
277
  if (glslTypeInfo.instantiable) {
370
- const attribute = this._private_propertyBuffers.get(name);
371
- if (attribute) {
372
- const offset = index * attribute.itemSize;
373
- writePropertyToArray(value, attribute.array, offset);
374
- attribute.needsUpdate = true;
375
- }
278
+ writePropertyToArray(value, TEMP_FIELD_VALUES, 0);
279
+ this.writeField(index, resolvePackedField(this.layout, name), TEMP_FIELD_VALUES);
376
280
  }
377
281
  else {
378
- const uniform = resolvePropertyUniform(name, this._private_shaderMaterial);
282
+ const uniform = resolvePropertyUniform(name, this.shaderMaterial);
379
283
  uniform.value = value;
380
- this._private_shaderMaterial.uniformsNeedUpdate = true;
284
+ this.shaderMaterial.uniformsNeedUpdate = true;
381
285
  }
382
286
  }
383
287
  }
384
- _private_resolveAttribute(name) {
385
- const attribute = this._private_propertyBuffers.get(name);
386
- if (attribute === undefined) {
387
- throw new Error(`UIGenericInstancedPlane.resolveAttribute.name: unknown attribute "${name}"`);
288
+ writeVisibility(index, visibility) {
289
+ TEMP_FIELD_VALUES[0] = visibility ? 1 : 0;
290
+ this.writeField(index, this.visibilityField, TEMP_FIELD_VALUES);
291
+ }
292
+ writeBlend(index, blend) {
293
+ TEMP_FIELD_VALUES[0] = blend;
294
+ this.writeField(index, this.blendField, TEMP_FIELD_VALUES);
295
+ }
296
+ writeHSL(index, hsl) {
297
+ TEMP_FIELD_VALUES[0] = hsl.h;
298
+ TEMP_FIELD_VALUES[1] = hsl.s;
299
+ TEMP_FIELD_VALUES[2] = hsl.l;
300
+ this.writeField(index, this.hslField, TEMP_FIELD_VALUES);
301
+ }
302
+ writeField(index, field, values) {
303
+ for (const { attributeIndex, componentOffset, sourceOffset, size } of field.columns) {
304
+ const attribute = this.packedAttributes[attributeIndex];
305
+ const array = attribute.array;
306
+ const offset = index * attribute.itemSize + componentOffset;
307
+ for (let i = 0; i < size; i++) {
308
+ array[offset + i] = values[sourceOffset + i];
309
+ }
310
+ attribute.needsUpdate = true;
388
311
  }
389
- return attribute;
390
312
  }
391
313
  }
392
-
393
- export { UIGenericInstancedPlane };
@@ -1,7 +1,7 @@
1
1
  import type { Matrix4 } from "three";
2
- import type { UITransparencyMode } from "../../UITransparencyMode";
3
- import type { GLProperty, HSLAdjustment } from "../shared";
4
- import type { UIGenericInstancedPlane } from "../UIGenericInstancedPlane/UIGenericInstancedPlane";
2
+ import type { UITransparencyMode } from "../../UITransparencyMode.js";
3
+ import type { GLProperty, HSLAdjustment } from "../shared.js";
4
+ import type { UIGenericInstancedPlane } from "../UIGenericInstancedPlane/UIGenericInstancedPlane.js";
5
5
  export interface PlaneDescriptor {
6
6
  mesh: UIGenericInstancedPlane;
7
7
  instanceIndex: number;