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
@@ -0,0 +1,313 @@
1
+ import type { WebGLRenderer } from "three";
2
+ import { Vector2 } from "three";
3
+ import type { UILayer } from "../../core";
4
+ import { UIAnchor } from "../../core/elements/UIAnchor/UIAnchor";
5
+ import type { UIAnchorOptions } from "../../core/elements/UIAnchor/UIAnchor.Internal";
6
+ import {
7
+ resolveGLSLTypeInfo,
8
+ type GLProperty,
9
+ type GLTypeInfo,
10
+ } from "../../core/miscellaneous/generic-plane/shared";
11
+ import { isUIModeVisible } from "../../core/miscellaneous/UIMode";
12
+ import type { UIBehaviorModule } from "../behaviorModules/UIBehaviorModule";
13
+ import { UIInstancedParticle } from "../instancedParticle/UIInstancedParticle";
14
+ import {
15
+ collectProperties,
16
+ collectUniforms,
17
+ } from "../instancedParticle/UIInstancedParticle.Internal";
18
+ import {
19
+ BUILTIN_OFFSET_AGE,
20
+ BUILTIN_OFFSET_POSITION_X,
21
+ BUILTIN_OFFSET_POSITION_Y,
22
+ BUILTIN_OFFSET_RANDOM_A,
23
+ BUILTIN_OFFSET_RANDOM_B,
24
+ BUILTIN_OFFSET_RANDOM_C,
25
+ BUILTIN_OFFSET_RANDOM_D,
26
+ BUILTIN_OFFSET_RANDOM_E,
27
+ BUILTIN_OFFSET_RANDOM_F,
28
+ BUILTIN_OFFSET_ROTATION,
29
+ BUILTIN_OFFSET_TORQUE,
30
+ BUILTIN_OFFSET_VELOCITY_X,
31
+ BUILTIN_OFFSET_VELOCITY_Y,
32
+ } from "../miscellaneous/miscellaneous";
33
+ import type { UIRenderingModule } from "../renderingModules/UIRenderingModule";
34
+ import type { UISpawnModule } from "../spawnModules/UISpawnModule";
35
+ import {
36
+ EMITTER_DEFAULT_AUTOMATICALLY_DESTROY_MODULES,
37
+ EMITTER_DEFAULT_CAPACITY_STEP,
38
+ EMITTER_DEFAULT_EXPECTED_CAPACITY,
39
+ EMITTER_DEFAULT_MODE,
40
+ ignoreInput,
41
+ type UIEmitterMode,
42
+ type UIEmitterPlayOptions,
43
+ } from "./UIEmitter.Internal";
44
+
45
+ export interface UIEmitterOptions extends UIAnchorOptions {
46
+ mode: UIEmitterMode;
47
+ expectedCapacity: number;
48
+ capacityStep: number;
49
+ automaticallyDestroyModules: boolean;
50
+ }
51
+
52
+ /**
53
+ * Particle emitter element.
54
+ *
55
+ * Spawns, updates, and renders particles using modular spawn/behavior/rendering pipeline.
56
+ */
57
+ export class UIEmitter extends UIAnchor {
58
+ /** Whether to call destroy() on all modules when emitter is destroyed */
59
+ public automaticallyDestroyModules: boolean;
60
+
61
+ private readonly mesh: UIInstancedParticle;
62
+ private readonly catcherHandler: number;
63
+
64
+ private emissionRate = 0;
65
+ private emissionAccumulator = 0;
66
+ private emissionDuration = Infinity;
67
+ private emissionElapsed = 0;
68
+
69
+ private modeInternal: UIEmitterMode;
70
+
71
+ /**
72
+ * @param layer - Layer containing this emitter
73
+ * @param spawnSequence - Modules that initialize new particles
74
+ * @param behaviorSequence - Modules that update particles each frame
75
+ * @param renderingSequence - Modules that control particle appearance
76
+ * @param options - Configuration options
77
+ */
78
+ constructor(
79
+ layer: UILayer,
80
+ private readonly spawnSequence: UISpawnModule[],
81
+ private readonly behaviorSequence: readonly UIBehaviorModule[],
82
+ private readonly renderingSequence: readonly UIRenderingModule[],
83
+ options: Partial<UIEmitterOptions> = {},
84
+ ) {
85
+ super(layer, options);
86
+
87
+ const collectedProperties: Record<string, GLTypeInfo> = {
88
+ builtin: resolveGLSLTypeInfo("Matrix4"),
89
+ // 0, 1 positionX, positionY
90
+ // 2, 3 velocityX, velocityY
91
+ // 4, 5 scaleX, scaleY
92
+ // 6, 7 rotation, torque
93
+ // 8, 9 lifetime, age
94
+ // 10, 11, 12 randomX, randomY, randomZ
95
+ // 13, 14, 16 reservedX, reservedY, reservedZ
96
+ };
97
+ collectProperties(collectedProperties, spawnSequence, "UIEmitter.constructor.spawnSequence:");
98
+ collectProperties(
99
+ collectedProperties,
100
+ behaviorSequence,
101
+ "UIEmitter.constructor.behaviorSequence",
102
+ );
103
+ collectProperties(
104
+ collectedProperties,
105
+ renderingSequence,
106
+ "UIEmitter.constructor.renderingSequence",
107
+ );
108
+
109
+ const collectedUniforms: Record<string, GLProperty> = {
110
+ origin: { value: new Vector2(), glslTypeInfo: resolveGLSLTypeInfo("Vector2") },
111
+ };
112
+ collectUniforms(
113
+ collectedUniforms,
114
+ renderingSequence,
115
+ "UIEmitter.constructor.renderingSequence",
116
+ );
117
+
118
+ const zIndex = 0;
119
+ this.catcherHandler = this.layer.inputWrapper.createInputCatcher(
120
+ ignoreInput,
121
+ ignoreInput,
122
+ ignoreInput,
123
+ zIndex,
124
+ );
125
+
126
+ this.mesh = new UIInstancedParticle(
127
+ this.renderingSequence.map((module) => module.source),
128
+ collectedUniforms,
129
+ collectedProperties,
130
+ options.expectedCapacity ?? EMITTER_DEFAULT_EXPECTED_CAPACITY,
131
+ options.capacityStep ?? EMITTER_DEFAULT_CAPACITY_STEP,
132
+ );
133
+ this.mesh.renderOrder = zIndex;
134
+
135
+ this.layer.signalRendering.on(this.onRendering);
136
+ this.layer.sceneWrapper.insertCustomObject(this.mesh);
137
+
138
+ this.automaticallyDestroyModules =
139
+ options.automaticallyDestroyModules ?? EMITTER_DEFAULT_AUTOMATICALLY_DESTROY_MODULES;
140
+ this.modeInternal = options.mode ?? EMITTER_DEFAULT_MODE;
141
+ }
142
+
143
+ /** Visibility mode */
144
+ public get mode(): UIEmitterMode {
145
+ return this.modeInternal;
146
+ }
147
+
148
+ /** Rendering order. Higher values draw on top */
149
+ public get zIndex(): number {
150
+ return this.layer.inputWrapper.getZIndex(this.catcherHandler);
151
+ }
152
+
153
+ /** Visibility mode */
154
+ public set mode(value: UIEmitterMode) {
155
+ if (this.modeInternal !== value) {
156
+ this.modeInternal = value;
157
+ this.mesh.visible = isUIModeVisible(value);
158
+ }
159
+ }
160
+
161
+ /** Rendering order. Higher values draw on top */
162
+ public set zIndex(value: number) {
163
+ this.layer.inputWrapper.setZIndex(this.catcherHandler, value);
164
+ }
165
+
166
+ /** Removes emitter and optionally destroys modules */
167
+ public override destroy(): void {
168
+ this.layer.signalRendering.off(this.onRendering);
169
+ this.layer.sceneWrapper.removeCustomObject(this.mesh);
170
+
171
+ if (this.automaticallyDestroyModules) {
172
+ for (const module of this.spawnSequence) {
173
+ module.destroy?.();
174
+ }
175
+ for (const module of this.behaviorSequence) {
176
+ module.destroy?.();
177
+ }
178
+ for (const module of this.renderingSequence) {
179
+ module.destroy?.();
180
+ }
181
+ }
182
+
183
+ super.destroy();
184
+ }
185
+
186
+ /**
187
+ * Spawns a specific number of particles immediately.
188
+ *
189
+ * @param count - Number of particles to create
190
+ */
191
+ public burst(count: number): void {
192
+ const instanceBegin = this.mesh.instanceCount;
193
+ this.mesh.createInstances(count);
194
+ const instanceEnd = this.mesh.instanceCount;
195
+
196
+ {
197
+ const { builtin } = this.mesh.propertyBuffers;
198
+ const { array, itemSize } = builtin;
199
+
200
+ for (let i = instanceBegin; i < instanceEnd; i++) {
201
+ const itemOffset = i * itemSize;
202
+ array[itemOffset + BUILTIN_OFFSET_RANDOM_A] = Math.random();
203
+ array[itemOffset + BUILTIN_OFFSET_RANDOM_B] = Math.random();
204
+ array[itemOffset + BUILTIN_OFFSET_RANDOM_C] = Math.random();
205
+ array[itemOffset + BUILTIN_OFFSET_RANDOM_D] = Math.random();
206
+ array[itemOffset + BUILTIN_OFFSET_RANDOM_E] = Math.random();
207
+ array[itemOffset + BUILTIN_OFFSET_RANDOM_F] = Math.random();
208
+ }
209
+
210
+ builtin.needsUpdate = true;
211
+ }
212
+
213
+ for (const spawnModule of this.spawnSequence) {
214
+ spawnModule.spawn(this.mesh.propertyBuffers, instanceBegin, instanceEnd);
215
+ }
216
+ }
217
+
218
+ /** Removes all active particles */
219
+ public clear(): void {
220
+ this.mesh.drop();
221
+ }
222
+
223
+ /**
224
+ * Starts continuous particle emission.
225
+ *
226
+ * @param rate - Particles per second
227
+ * @param options - Emission duration and other settings
228
+ */
229
+ public play(rate: number, options: Partial<UIEmitterPlayOptions> = {}): void {
230
+ this.emissionRate = rate;
231
+ this.emissionAccumulator = 0;
232
+ this.emissionDuration = options.duration ?? Infinity;
233
+ this.emissionElapsed = 0;
234
+ }
235
+
236
+ /** Stops continuous particle emission */
237
+ public stop(): void {
238
+ this.emissionRate = 0;
239
+ this.emissionAccumulator = 0;
240
+ this.emissionDuration = Infinity;
241
+ this.emissionElapsed = 0;
242
+ }
243
+
244
+ private readonly onRendering = (renderer: WebGLRenderer, deltaTime: number): void => {
245
+ {
246
+ const { builtin } = this.mesh.propertyBuffers;
247
+ const { array, itemSize } = builtin;
248
+
249
+ for (let i = 0; i < this.mesh.instanceCount; i++) {
250
+ array[i * itemSize + BUILTIN_OFFSET_AGE] += deltaTime;
251
+ }
252
+
253
+ builtin.needsUpdate = true;
254
+ this.mesh.removeDeadParticles();
255
+ }
256
+
257
+ if (this.emissionRate > 0) {
258
+ this.emissionElapsed += deltaTime;
259
+
260
+ if (this.emissionElapsed >= this.emissionDuration) {
261
+ this.stop();
262
+ } else {
263
+ this.emissionAccumulator += this.emissionRate * deltaTime;
264
+
265
+ const particlesToSpawn = Math.floor(this.emissionAccumulator);
266
+ if (particlesToSpawn > 0) {
267
+ this.burst(particlesToSpawn);
268
+ this.emissionAccumulator -= particlesToSpawn;
269
+ }
270
+ }
271
+ }
272
+
273
+ if (this.mesh.instanceCount === 0) {
274
+ return;
275
+ }
276
+
277
+ this.mesh.renderOrder = this.zIndex;
278
+ this.mesh.setOrigin(this.x, this.y);
279
+
280
+ {
281
+ const { propertyBuffers, instanceCount } = this.mesh;
282
+
283
+ for (const module of this.behaviorSequence) {
284
+ module.update(propertyBuffers, instanceCount, deltaTime);
285
+ }
286
+ }
287
+
288
+ const { builtin } = this.mesh.propertyBuffers;
289
+ const { array, itemSize } = builtin;
290
+
291
+ {
292
+ for (let i = 0; i < this.mesh.instanceCount; i++) {
293
+ const itemOffset = i * itemSize;
294
+ array[itemOffset + BUILTIN_OFFSET_POSITION_X] +=
295
+ array[itemOffset + BUILTIN_OFFSET_VELOCITY_X] * deltaTime;
296
+ array[itemOffset + BUILTIN_OFFSET_POSITION_Y] +=
297
+ array[itemOffset + BUILTIN_OFFSET_VELOCITY_Y] * deltaTime;
298
+ }
299
+
300
+ builtin.needsUpdate = true;
301
+ }
302
+
303
+ {
304
+ for (let i = 0; i < this.mesh.instanceCount; i++) {
305
+ const itemOffset = i * itemSize;
306
+ array[itemOffset + BUILTIN_OFFSET_ROTATION] +=
307
+ array[itemOffset + BUILTIN_OFFSET_TORQUE] * deltaTime;
308
+ }
309
+
310
+ builtin.needsUpdate = true;
311
+ }
312
+ };
313
+ }
@@ -0,0 +1,18 @@
1
+ export { UIBehaviorDirectionalGravity } from "./behaviorModules/UIBehaviorDirectionalGravity";
2
+ export { UIBehaviorPointGravity } from "./behaviorModules/UIBehaviorPointGravity";
3
+ export { UIBehaviorScaleOverLife } from "./behaviorModules/UIBehaviorScaleOverLife";
4
+ export { UIBehaviorTorqueDamping } from "./behaviorModules/UIBehaviorTorqueDamping";
5
+ export { UIBehaviorTorqueNoise } from "./behaviorModules/UIBehaviorTorqueNoise";
6
+ export { UIBehaviorVelocityDamping } from "./behaviorModules/UIBehaviorVelocityDamping";
7
+ export { UIBehaviorVelocityNoise } from "./behaviorModules/UIBehaviorVelocityNoise";
8
+ export { UIEmitter } from "./elements/UIEmitter";
9
+ export { UIRenderingColorOverLife } from "./renderingModules/UIRenderingColorOverLife";
10
+ export { UIRenderingColorOverVelocity } from "./renderingModules/UIRenderingColorOverVelocity";
11
+ export { UITextureRenderingModule } from "./renderingModules/UIRenderingTexture";
12
+ export { UISpawnOffset } from "./spawnModules/UISpawnOffset";
13
+ export { UISpawnRandomLifetime } from "./spawnModules/UISpawnRandomLifetime";
14
+ export { UISpawnRandomRotation } from "./spawnModules/UISpawnRandomRotation";
15
+ export { UISpawnRandomScale } from "./spawnModules/UISpawnRandomScale";
16
+ export { UISpawnRandomTorque } from "./spawnModules/UISpawnRandomTorque";
17
+ export { UISpawnRandomVelocity } from "./spawnModules/UISpawnRandomVelocity";
18
+ export { UISpawnRectangle } from "./spawnModules/UISpawnRectangle";
@@ -0,0 +1,263 @@
1
+ import {
2
+ BufferAttribute,
3
+ Float32BufferAttribute,
4
+ InstancedBufferGeometry,
5
+ ShaderMaterial,
6
+ } from "three";
7
+ import { UIColor } from "../../core";
8
+ import type { GLProperty, GLTypeInfo } from "../../core/miscellaneous/generic-plane/shared";
9
+ import {
10
+ resolveGLSLTypeInfo,
11
+ type UIProperty,
12
+ type UIPropertyName,
13
+ } from "../../core/miscellaneous/generic-plane/shared";
14
+ import { checkSRGBSupport } from "../../core/miscellaneous/webglCapabilities";
15
+
16
+ export const INSTANCED_PARTICLE_GEOMETRY = ((): InstancedBufferGeometry => {
17
+ const geometry = new InstancedBufferGeometry();
18
+
19
+ const indices = new Uint16Array([0, 2, 1, 2, 3, 1]);
20
+ geometry.setIndex(new BufferAttribute(indices, 1));
21
+
22
+ const positions = new Float32Array([-0.5, 0.5, 0, 0.5, 0.5, 0, -0.5, -0.5, 0, 0.5, -0.5, 0]);
23
+ geometry.setAttribute("position", new Float32BufferAttribute(positions, 3));
24
+
25
+ const uvs = new Float32Array([0, 1, 1, 1, 0, 0, 1, 0]);
26
+ geometry.setAttribute("uv", new Float32BufferAttribute(uvs, 2));
27
+
28
+ return geometry;
29
+ })();
30
+
31
+ export function collectProperties(
32
+ keeper: Record<string, GLTypeInfo>,
33
+ modules: readonly { requiredProperties?: Record<string, UIPropertyName> }[],
34
+ debugContext: string,
35
+ ): void {
36
+ for (const module of modules) {
37
+ if (module.requiredProperties === undefined) {
38
+ continue;
39
+ }
40
+
41
+ for (const key in module.requiredProperties) {
42
+ const existingTypeInfo = keeper[key] as GLTypeInfo | undefined;
43
+ const newTypeInfo = resolveGLSLTypeInfo(module.requiredProperties[key]);
44
+
45
+ if (existingTypeInfo === undefined) {
46
+ keeper[key] = newTypeInfo;
47
+ } else if (existingTypeInfo.glslTypeName !== newTypeInfo.glslTypeName) {
48
+ throw new Error(`${debugContext}: property conflict for "${key}"`);
49
+ }
50
+ }
51
+ }
52
+ }
53
+
54
+ export function collectUniforms(
55
+ keeper: Record<string, GLProperty>,
56
+ modules: readonly { requiredUniforms: Record<string, UIProperty> }[],
57
+ debugContext: string,
58
+ ): void {
59
+ for (const module of modules) {
60
+ for (const key in module.requiredUniforms) {
61
+ const value = module.requiredUniforms[key];
62
+ const existingGLProperty = keeper[key] as GLProperty | undefined;
63
+ const newPropertyTypeInfo = resolveGLSLTypeInfo(value);
64
+
65
+ if (existingGLProperty === undefined) {
66
+ keeper[key] = { value, glslTypeInfo: newPropertyTypeInfo };
67
+ } else if (
68
+ existingGLProperty.glslTypeInfo.glslTypeName !== newPropertyTypeInfo.glslTypeName
69
+ ) {
70
+ throw new Error(`${debugContext}: property conflict for "${key}"`);
71
+ }
72
+ }
73
+ }
74
+ }
75
+
76
+ export function buildParticleVertexShader(
77
+ uniformDeclarations: string[],
78
+ attributeDeclarations: string[],
79
+ varyingDeclarations: string[],
80
+ vertexAssignments: string[],
81
+ ): string {
82
+ return `
83
+
84
+ #define PARTICLE_POSITION_X a_builtin[0][0]
85
+ #define PARTICLE_POSITION_Y a_builtin[0][1]
86
+
87
+ #define PARTICLE_VELOCITY_X a_builtin[0][2]
88
+ #define PARTICLE_VELOCITY_Y a_builtin[0][3]
89
+
90
+ #define PARTICLE_SCALE_X a_builtin[1][0]
91
+ #define PARTICLE_SCALE_Y a_builtin[1][1]
92
+
93
+ #define PARTICLE_ROTATION a_builtin[1][2]
94
+ #define PARTICLE_TORQUE a_builtin[1][3]
95
+
96
+ #define PARTICLE_LIFETIME a_builtin[2][0]
97
+ #define PARTICLE_AGE a_builtin[2][1]
98
+
99
+ #define PARTICLE_RANDOM_A a_builtin[2][2]
100
+ #define PARTICLE_RANDOM_B a_builtin[2][3]
101
+ #define PARTICLE_RANDOM_C a_builtin[3][0]
102
+ #define PARTICLE_RANDOM_D a_builtin[3][1]
103
+ #define PARTICLE_RANDOM_E a_builtin[3][2]
104
+ #define PARTICLE_RANDOM_F a_builtin[3][3]
105
+
106
+ // User attributes
107
+ ${attributeDeclarations.join("\n")}
108
+
109
+ // Uniforms
110
+ ${uniformDeclarations.join("\n")}
111
+
112
+ // Builtin varyings
113
+ varying vec2 p_uv;
114
+
115
+ // User varyings
116
+ ${varyingDeclarations.join("\n")}
117
+
118
+ void main() {
119
+ ${vertexAssignments.join("\n")}
120
+
121
+ p_uv = uv;
122
+
123
+ vec2 transformedPosition = position.xy;
124
+ transformedPosition.x *= PARTICLE_SCALE_X;
125
+ transformedPosition.y *= PARTICLE_SCALE_Y;
126
+
127
+ float cosR = cos(PARTICLE_ROTATION);
128
+ float sinR = sin(PARTICLE_ROTATION);
129
+
130
+ transformedPosition = vec2(
131
+ transformedPosition.x * cosR - transformedPosition.y * sinR,
132
+ transformedPosition.x * sinR + transformedPosition.y * cosR
133
+ );
134
+
135
+ transformedPosition.x += PARTICLE_POSITION_X;
136
+ transformedPosition.y += PARTICLE_POSITION_Y;
137
+
138
+ transformedPosition += p_origin;
139
+ gl_Position = projectionMatrix * vec4(transformedPosition, position.z, 1.0);
140
+ }
141
+ `;
142
+ }
143
+
144
+ export function buildParticleFragmentShader(
145
+ uniformDeclarations: string[],
146
+ varyingDeclarations: string[],
147
+ sources: string[],
148
+ ): string {
149
+ const renamedSources = sources.map((source, index) => {
150
+ return source.replace(/vec4\s+draw\s*\(\s*\)/g, `vec4 draw${index}()`);
151
+ });
152
+
153
+ let drawCalls = "";
154
+ for (let i = 0; i < sources.length; i++) {
155
+ drawCalls += i !== 0 ? " * " : "";
156
+ drawCalls += `draw${i}()`;
157
+ }
158
+
159
+ return `
160
+ // Defines
161
+ #define PI 3.14159265359
162
+ #define SRGB_SUPPORTED ${checkSRGBSupport() ? "1" : "0"}
163
+
164
+ #define PARTICLE_POSITION_X p_builtin[0][0]
165
+ #define PARTICLE_POSITION_Y p_builtin[0][1]
166
+
167
+ #define PARTICLE_VELOCITY_X p_builtin[0][2]
168
+ #define PARTICLE_VELOCITY_Y p_builtin[0][3]
169
+
170
+ #define PARTICLE_SCALE_X p_builtin[1][0]
171
+ #define PARTICLE_SCALE_Y p_builtin[1][1]
172
+
173
+ #define PARTICLE_ROTATION p_builtin[1][2]
174
+ #define PARTICLE_TORQUE p_builtin[1][3]
175
+
176
+ #define PARTICLE_LIFETIME p_builtin[2][0]
177
+ #define PARTICLE_AGE p_builtin[2][1]
178
+
179
+ #define PARTICLE_RANDOM_A p_builtin[2][2]
180
+ #define PARTICLE_RANDOM_B p_builtin[2][3]
181
+ #define PARTICLE_RANDOM_C p_builtin[3][0]
182
+ #define PARTICLE_RANDOM_D p_builtin[3][1]
183
+ #define PARTICLE_RANDOM_E p_builtin[3][2]
184
+ #define PARTICLE_RANDOM_F p_builtin[3][3]
185
+
186
+ // Uniforms
187
+ ${uniformDeclarations.join("\n")}
188
+
189
+ // Builtin varyings
190
+ varying vec2 p_uv;
191
+
192
+ // User varyings
193
+ ${varyingDeclarations.join("\n")}
194
+
195
+ #include <alphahash_pars_fragment>
196
+
197
+ // sRGB decode helper
198
+ vec4 srgbTexture2D(sampler2D textureSampler, vec2 uv) {
199
+ #if SRGB_SUPPORTED
200
+ return texture2D(textureSampler, uv);
201
+ #else
202
+ vec4 textureValue = texture2D(textureSampler, uv);
203
+ return vec4(pow(textureValue.rgb, vec3(2.2)), textureValue.a);
204
+ #endif
205
+ }
206
+
207
+ // Source must define vec4 draw() function
208
+ ${renamedSources.join("\n")}
209
+
210
+ void main() {
211
+ vec4 diffuseColor = ${drawCalls};
212
+ if (diffuseColor.a < 0.0035) {
213
+ discard;
214
+ }
215
+ #ifdef USE_ALPHAHASH
216
+ if (diffuseColor.a < getAlphaHashThreshold(p_position)) {
217
+ discard;
218
+ }
219
+ #endif
220
+ gl_FragColor = linearToOutputTexel(diffuseColor);
221
+ }
222
+ `;
223
+ }
224
+
225
+ export function buildParticleMaterial(
226
+ sources: string[],
227
+ uniformProperties: Record<string, GLProperty>,
228
+ varyingProperties: Record<string, GLTypeInfo>,
229
+ ): ShaderMaterial {
230
+ const uniforms: Record<string, { value: unknown }> = {};
231
+
232
+ const uniformDeclarations: string[] = [];
233
+ const attributeDeclarations: string[] = [];
234
+ const varyingDeclarations: string[] = [];
235
+ const vertexAssignments: string[] = [];
236
+
237
+ for (const name in uniformProperties) {
238
+ const { value, glslTypeInfo } = uniformProperties[name];
239
+ uniforms[`p_${name}`] = { value: value instanceof UIColor ? value.toGLSLColor() : value };
240
+ uniformDeclarations.push(`uniform ${glslTypeInfo.glslTypeName} p_${name};`);
241
+ }
242
+
243
+ for (const name in varyingProperties) {
244
+ const { glslTypeName } = varyingProperties[name];
245
+ attributeDeclarations.push(`attribute ${glslTypeName} a_${name};`);
246
+ varyingDeclarations.push(`varying ${glslTypeName} p_${name};`);
247
+ vertexAssignments.push(`p_${name} = a_${name};`);
248
+ }
249
+
250
+ return new ShaderMaterial({
251
+ uniforms,
252
+ vertexShader: buildParticleVertexShader(
253
+ uniformDeclarations,
254
+ attributeDeclarations,
255
+ varyingDeclarations,
256
+ vertexAssignments,
257
+ ),
258
+ fragmentShader: buildParticleFragmentShader(uniformDeclarations, varyingDeclarations, sources),
259
+ transparent: true,
260
+ depthWrite: false,
261
+ depthTest: true,
262
+ });
263
+ }