@codexo/exojs 0.7.12 → 0.8.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 (219) hide show
  1. package/CHANGELOG.md +737 -0
  2. package/dist/esm/core/Application.d.ts +3 -1
  3. package/dist/esm/core/Application.js +7 -6
  4. package/dist/esm/core/Application.js.map +1 -1
  5. package/dist/esm/core/Scene.d.ts +30 -0
  6. package/dist/esm/core/Scene.js +56 -0
  7. package/dist/esm/core/Scene.js.map +1 -1
  8. package/dist/esm/core/SceneManager.js +2 -2
  9. package/dist/esm/core/SceneManager.js.map +1 -1
  10. package/dist/esm/debug/DebugOverlay.js +2 -2
  11. package/dist/esm/debug/DebugOverlay.js.map +1 -1
  12. package/dist/esm/debug/PointerStackLayer.js +1 -1
  13. package/dist/esm/debug/PointerStackLayer.js.map +1 -1
  14. package/dist/esm/index.js +32 -10
  15. package/dist/esm/index.js.map +1 -1
  16. package/dist/esm/input/ArcadeStickGamepadMapping.js +18 -19
  17. package/dist/esm/input/ArcadeStickGamepadMapping.js.map +1 -1
  18. package/dist/esm/input/Gamepad.d.ts +164 -62
  19. package/dist/esm/input/Gamepad.js +290 -134
  20. package/dist/esm/input/Gamepad.js.map +1 -1
  21. package/dist/esm/input/GamepadAxis.d.ts +120 -0
  22. package/dist/esm/input/GamepadAxis.js +106 -0
  23. package/dist/esm/input/GamepadAxis.js.map +1 -0
  24. package/dist/esm/input/GamepadButton.d.ts +110 -0
  25. package/dist/esm/input/GamepadButton.js +99 -0
  26. package/dist/esm/input/GamepadButton.js.map +1 -0
  27. package/dist/esm/input/GamepadDefinitions.js +4 -0
  28. package/dist/esm/input/GamepadDefinitions.js.map +1 -1
  29. package/dist/esm/input/GamepadMapping.d.ts +28 -24
  30. package/dist/esm/input/GamepadMapping.js +33 -16
  31. package/dist/esm/input/GamepadMapping.js.map +1 -1
  32. package/dist/esm/input/GamepadPromptLayouts.d.ts +10 -8
  33. package/dist/esm/input/GamepadPromptLayouts.js +21 -20
  34. package/dist/esm/input/GamepadPromptLayouts.js.map +1 -1
  35. package/dist/esm/input/GenericDualAnalogGamepadMapping.d.ts +6 -3
  36. package/dist/esm/input/GenericDualAnalogGamepadMapping.js +55 -46
  37. package/dist/esm/input/GenericDualAnalogGamepadMapping.js.map +1 -1
  38. package/dist/esm/input/InputBinding.d.ts +74 -0
  39. package/dist/esm/input/InputBinding.js +100 -0
  40. package/dist/esm/input/InputBinding.js.map +1 -0
  41. package/dist/esm/input/InputManager.d.ts +79 -33
  42. package/dist/esm/input/InputManager.js +229 -104
  43. package/dist/esm/input/InputManager.js.map +1 -1
  44. package/dist/esm/input/InteractionManager.d.ts +1 -1
  45. package/dist/esm/input/InteractionManager.js +13 -13
  46. package/dist/esm/input/InteractionManager.js.map +1 -1
  47. package/dist/esm/input/JoyConLeftGamepadMapping.d.ts +14 -9
  48. package/dist/esm/input/JoyConLeftGamepadMapping.js +39 -9
  49. package/dist/esm/input/JoyConLeftGamepadMapping.js.map +1 -1
  50. package/dist/esm/input/JoyConRightGamepadMapping.d.ts +14 -9
  51. package/dist/esm/input/JoyConRightGamepadMapping.js +35 -9
  52. package/dist/esm/input/JoyConRightGamepadMapping.js.map +1 -1
  53. package/dist/esm/input/Pointer.d.ts +84 -71
  54. package/dist/esm/input/Pointer.js +71 -71
  55. package/dist/esm/input/Pointer.js.map +1 -1
  56. package/dist/esm/input/SteamDeckGamepadMapping.d.ts +18 -0
  57. package/dist/esm/input/SteamDeckGamepadMapping.js +76 -0
  58. package/dist/esm/input/SteamDeckGamepadMapping.js.map +1 -0
  59. package/dist/esm/input/index.d.ts +7 -4
  60. package/dist/esm/input/types.d.ts +0 -76
  61. package/dist/esm/input/types.js +1 -80
  62. package/dist/esm/input/types.js.map +1 -1
  63. package/dist/esm/particles/ParticleSystem.d.ts +180 -83
  64. package/dist/esm/particles/ParticleSystem.js +446 -133
  65. package/dist/esm/particles/ParticleSystem.js.map +1 -1
  66. package/dist/esm/particles/distributions/BoxArea.d.ts +17 -0
  67. package/dist/esm/particles/distributions/BoxArea.js +48 -0
  68. package/dist/esm/particles/distributions/BoxArea.js.map +1 -0
  69. package/dist/esm/particles/distributions/CircleArea.d.ts +19 -0
  70. package/dist/esm/particles/distributions/CircleArea.js +33 -0
  71. package/dist/esm/particles/distributions/CircleArea.js.map +1 -0
  72. package/dist/esm/particles/distributions/ConeDirection.d.ts +28 -0
  73. package/dist/esm/particles/distributions/ConeDirection.js +44 -0
  74. package/dist/esm/particles/distributions/ConeDirection.js.map +1 -0
  75. package/dist/esm/particles/distributions/Constant.d.ts +17 -0
  76. package/dist/esm/particles/distributions/Constant.js +35 -0
  77. package/dist/esm/particles/distributions/Constant.js.map +1 -0
  78. package/dist/esm/particles/distributions/Curve.d.ts +30 -0
  79. package/dist/esm/particles/distributions/Curve.js +53 -0
  80. package/dist/esm/particles/distributions/Curve.js.map +1 -0
  81. package/dist/esm/particles/distributions/Distribution.d.ts +45 -0
  82. package/dist/esm/particles/distributions/Gradient.d.ts +40 -0
  83. package/dist/esm/particles/distributions/Gradient.js +72 -0
  84. package/dist/esm/particles/distributions/Gradient.js.map +1 -0
  85. package/dist/esm/particles/distributions/LineSegment.d.ts +15 -0
  86. package/dist/esm/particles/distributions/LineSegment.js +27 -0
  87. package/dist/esm/particles/distributions/LineSegment.js.map +1 -0
  88. package/dist/esm/particles/distributions/Range.d.ts +12 -0
  89. package/dist/esm/particles/distributions/Range.js +19 -0
  90. package/dist/esm/particles/distributions/Range.js.map +1 -0
  91. package/dist/esm/particles/distributions/VectorRange.d.ts +20 -0
  92. package/dist/esm/particles/distributions/VectorRange.js +31 -0
  93. package/dist/esm/particles/distributions/VectorRange.js.map +1 -0
  94. package/dist/esm/particles/distributions/index.d.ts +12 -0
  95. package/dist/esm/particles/gpu/ParticleGpuState.d.ts +57 -0
  96. package/dist/esm/particles/gpu/ParticleGpuState.js +508 -0
  97. package/dist/esm/particles/gpu/ParticleGpuState.js.map +1 -0
  98. package/dist/esm/particles/index.d.ts +2 -10
  99. package/dist/esm/particles/modules/AlphaFadeOverLifetime.d.ts +24 -0
  100. package/dist/esm/particles/modules/AlphaFadeOverLifetime.js +60 -0
  101. package/dist/esm/particles/modules/AlphaFadeOverLifetime.js.map +1 -0
  102. package/dist/esm/particles/modules/ApplyForce.d.ts +20 -0
  103. package/dist/esm/particles/modules/ApplyForce.js +48 -0
  104. package/dist/esm/particles/modules/ApplyForce.js.map +1 -0
  105. package/dist/esm/particles/modules/AttractToPoint.d.ts +27 -0
  106. package/dist/esm/particles/modules/AttractToPoint.js +73 -0
  107. package/dist/esm/particles/modules/AttractToPoint.js.map +1 -0
  108. package/dist/esm/particles/modules/BurstSpawn.d.ts +53 -0
  109. package/dist/esm/particles/modules/BurstSpawn.js +94 -0
  110. package/dist/esm/particles/modules/BurstSpawn.js.map +1 -0
  111. package/dist/esm/particles/modules/ColorOverLifetime.d.ts +22 -0
  112. package/dist/esm/particles/modules/ColorOverLifetime.js +65 -0
  113. package/dist/esm/particles/modules/ColorOverLifetime.js.map +1 -0
  114. package/dist/esm/particles/modules/ColorOverSpeed.d.ts +27 -0
  115. package/dist/esm/particles/modules/ColorOverSpeed.js +86 -0
  116. package/dist/esm/particles/modules/ColorOverSpeed.js.map +1 -0
  117. package/dist/esm/particles/modules/DeathModule.d.ts +24 -0
  118. package/dist/esm/particles/modules/DeathModule.js +25 -0
  119. package/dist/esm/particles/modules/DeathModule.js.map +1 -0
  120. package/dist/esm/particles/modules/Drag.d.ts +20 -0
  121. package/dist/esm/particles/modules/Drag.js +45 -0
  122. package/dist/esm/particles/modules/Drag.js.map +1 -0
  123. package/dist/esm/particles/modules/OrbitalForce.d.ts +28 -0
  124. package/dist/esm/particles/modules/OrbitalForce.js +65 -0
  125. package/dist/esm/particles/modules/OrbitalForce.js.map +1 -0
  126. package/dist/esm/particles/modules/RateSpawn.d.ts +41 -0
  127. package/dist/esm/particles/modules/RateSpawn.js +76 -0
  128. package/dist/esm/particles/modules/RateSpawn.js.map +1 -0
  129. package/dist/esm/particles/modules/RepelFromPoint.d.ts +24 -0
  130. package/dist/esm/particles/modules/RepelFromPoint.js +76 -0
  131. package/dist/esm/particles/modules/RepelFromPoint.js.map +1 -0
  132. package/dist/esm/particles/modules/RotateOverLifetime.d.ts +20 -0
  133. package/dist/esm/particles/modules/RotateOverLifetime.js +43 -0
  134. package/dist/esm/particles/modules/RotateOverLifetime.js.map +1 -0
  135. package/dist/esm/particles/modules/ScaleOverLifetime.d.ts +26 -0
  136. package/dist/esm/particles/modules/ScaleOverLifetime.js +59 -0
  137. package/dist/esm/particles/modules/ScaleOverLifetime.js.map +1 -0
  138. package/dist/esm/particles/modules/SpawnModule.d.ts +30 -0
  139. package/dist/esm/particles/modules/SpawnModule.js +31 -0
  140. package/dist/esm/particles/modules/SpawnModule.js.map +1 -0
  141. package/dist/esm/particles/modules/SpawnOnDeath.d.ts +24 -0
  142. package/dist/esm/particles/modules/SpawnOnDeath.js +47 -0
  143. package/dist/esm/particles/modules/SpawnOnDeath.js.map +1 -0
  144. package/dist/esm/particles/modules/Turbulence.d.ts +30 -0
  145. package/dist/esm/particles/modules/Turbulence.js +122 -0
  146. package/dist/esm/particles/modules/Turbulence.js.map +1 -0
  147. package/dist/esm/particles/modules/UpdateModule.d.ts +95 -0
  148. package/dist/esm/particles/modules/UpdateModule.js +66 -0
  149. package/dist/esm/particles/modules/UpdateModule.js.map +1 -0
  150. package/dist/esm/particles/modules/VelocityOverLifetime.d.ts +30 -0
  151. package/dist/esm/particles/modules/VelocityOverLifetime.js +84 -0
  152. package/dist/esm/particles/modules/VelocityOverLifetime.js.map +1 -0
  153. package/dist/esm/particles/modules/WgslContribution.d.ts +81 -0
  154. package/dist/esm/particles/modules/WgslContribution.js +34 -0
  155. package/dist/esm/particles/modules/WgslContribution.js.map +1 -0
  156. package/dist/esm/particles/modules/index.d.ts +22 -0
  157. package/dist/esm/rendering/webgl2/WebGl2ParticleRenderer.d.ts +9 -14
  158. package/dist/esm/rendering/webgl2/WebGl2ParticleRenderer.js +90 -61
  159. package/dist/esm/rendering/webgl2/WebGl2ParticleRenderer.js.map +1 -1
  160. package/dist/esm/rendering/webgl2/glsl/particle.vert.js +1 -1
  161. package/dist/esm/rendering/webgpu/WebGpuParticleRenderer.d.ts +9 -0
  162. package/dist/esm/rendering/webgpu/WebGpuParticleRenderer.js +107 -23
  163. package/dist/esm/rendering/webgpu/WebGpuParticleRenderer.js.map +1 -1
  164. package/dist/esm/rendering/webgpu/compute/WebGpuComputePipeline.d.ts +52 -0
  165. package/dist/esm/rendering/webgpu/compute/WebGpuStorageBuffer.d.ts +29 -0
  166. package/dist/esm/rendering/webgpu/compute/index.d.ts +3 -0
  167. package/dist/esm/resources/CacheFirstStrategy.d.ts +7 -4
  168. package/dist/esm/resources/CacheFirstStrategy.js +11 -8
  169. package/dist/esm/resources/CacheFirstStrategy.js.map +1 -1
  170. package/dist/esm/resources/CacheStrategy.d.ts +14 -6
  171. package/dist/esm/resources/Loader.d.ts +8 -3
  172. package/dist/esm/resources/Loader.js +19 -37
  173. package/dist/esm/resources/Loader.js.map +1 -1
  174. package/dist/esm/resources/NetworkOnlyStrategy.d.ts +3 -0
  175. package/dist/esm/resources/NetworkOnlyStrategy.js +8 -3
  176. package/dist/esm/resources/NetworkOnlyStrategy.js.map +1 -1
  177. package/dist/esm/resources/factories/ImageFactory.d.ts +2 -2
  178. package/dist/esm/resources/factories/ImageFactory.js.map +1 -1
  179. package/dist/esm/resources/factories/TextureFactory.d.ts +2 -2
  180. package/dist/esm/resources/factories/TextureFactory.js.map +1 -1
  181. package/dist/esm/resources/factories/VttFactory.d.ts +3 -3
  182. package/dist/esm/resources/factories/VttFactory.js +83 -6
  183. package/dist/esm/resources/factories/VttFactory.js.map +1 -1
  184. package/dist/exo.esm.js +4028 -1518
  185. package/dist/exo.esm.js.map +1 -1
  186. package/package.json +2 -1
  187. package/dist/esm/input/GamepadChannels.d.ts +0 -47
  188. package/dist/esm/input/GamepadChannels.js +0 -53
  189. package/dist/esm/input/GamepadChannels.js.map +0 -1
  190. package/dist/esm/input/GamepadControl.d.ts +0 -33
  191. package/dist/esm/input/GamepadControl.js +0 -42
  192. package/dist/esm/input/GamepadControl.js.map +0 -1
  193. package/dist/esm/input/Input.d.ts +0 -52
  194. package/dist/esm/input/Input.js +0 -90
  195. package/dist/esm/input/Input.js.map +0 -1
  196. package/dist/esm/particles/Particle.d.ts +0 -77
  197. package/dist/esm/particles/Particle.js +0 -143
  198. package/dist/esm/particles/Particle.js.map +0 -1
  199. package/dist/esm/particles/ParticleProperties.d.ts +0 -29
  200. package/dist/esm/particles/affectors/ColorAffector.d.ts +0 -30
  201. package/dist/esm/particles/affectors/ColorAffector.js +0 -55
  202. package/dist/esm/particles/affectors/ColorAffector.js.map +0 -1
  203. package/dist/esm/particles/affectors/ForceAffector.d.ts +0 -24
  204. package/dist/esm/particles/affectors/ForceAffector.js +0 -39
  205. package/dist/esm/particles/affectors/ForceAffector.js.map +0 -1
  206. package/dist/esm/particles/affectors/ParticleAffector.d.ts +0 -19
  207. package/dist/esm/particles/affectors/ScaleAffector.d.ts +0 -23
  208. package/dist/esm/particles/affectors/ScaleAffector.js +0 -38
  209. package/dist/esm/particles/affectors/ScaleAffector.js.map +0 -1
  210. package/dist/esm/particles/affectors/TorqueAffector.d.ts +0 -23
  211. package/dist/esm/particles/affectors/TorqueAffector.js +0 -37
  212. package/dist/esm/particles/affectors/TorqueAffector.js.map +0 -1
  213. package/dist/esm/particles/emitters/ParticleEmitter.d.ts +0 -19
  214. package/dist/esm/particles/emitters/ParticleOptions.d.ts +0 -62
  215. package/dist/esm/particles/emitters/ParticleOptions.js +0 -120
  216. package/dist/esm/particles/emitters/ParticleOptions.js.map +0 -1
  217. package/dist/esm/particles/emitters/UniversalEmitter.d.ts +0 -40
  218. package/dist/esm/particles/emitters/UniversalEmitter.js +0 -68
  219. package/dist/esm/particles/emitters/UniversalEmitter.js.map +0 -1
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@codexo/exojs",
3
3
  "description": "A TypeScript-first browser 2D runtime for games and interactive apps.",
4
- "version": "0.7.12",
4
+ "version": "0.8.0",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist/esm/",
@@ -47,6 +47,7 @@
47
47
  "verify:exports": "tsx ./scripts/verify-exports.ts",
48
48
  "verify:package": "npm run build && npm run verify:exports && npm pack --dry-run --ignore-scripts",
49
49
  "verify:release": "npm run typecheck && npm run lint && npm test && npm run verify:package",
50
+ "release": "node ./scripts/release.mjs",
50
51
  "prepack": "npm run build",
51
52
  "typecheck": "tsc --noEmit",
52
53
  "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
@@ -1,47 +0,0 @@
1
- /**
2
- * Canonical channel identifiers for every control a standard gamepad can expose.
3
- *
4
- * Values are absolute offsets into the engine's shared {@link Float32Array} input
5
- * channel buffer — each member equals `ChannelOffset.Gamepads + localIndex`.
6
- * Use {@link Gamepad.resolveChannelOffset} to account for per-slot skew when
7
- * reading a specific gamepad's data.
8
- */
9
- export declare enum GamepadChannel {
10
- ButtonSouth = 512,
11
- ButtonWest = 513,
12
- ButtonEast = 514,
13
- ButtonNorth = 515,
14
- LeftShoulder = 516,
15
- RightShoulder = 517,
16
- LeftTrigger = 518,
17
- RightTrigger = 519,
18
- Select = 520,
19
- Start = 521,
20
- LeftStick = 522,
21
- RightStick = 523,
22
- DPadUp = 524,
23
- DPadDown = 525,
24
- DPadLeft = 526,
25
- DPadRight = 527,
26
- Guide = 528,
27
- Share = 529,
28
- Capture = 530,
29
- Touchpad = 531,
30
- Paddle1 = 532,
31
- LeftStickLeft = 533,
32
- LeftStickRight = 534,
33
- LeftStickUp = 535,
34
- LeftStickDown = 536,
35
- RightStickLeft = 537,
36
- RightStickRight = 538,
37
- RightStickUp = 539,
38
- RightStickDown = 540,
39
- AuxiliaryAxis0Negative = 541,
40
- AuxiliaryAxis0Positive = 542,
41
- AuxiliaryAxis1Negative = 543,
42
- AuxiliaryAxis1Positive = 544,
43
- AuxiliaryAxis2Negative = 545,
44
- AuxiliaryAxis2Positive = 546,
45
- AuxiliaryAxis3Negative = 547,
46
- AuxiliaryAxis3Positive = 548
47
- }
@@ -1,53 +0,0 @@
1
- import './types.js';
2
-
3
- /**
4
- * Canonical channel identifiers for every control a standard gamepad can expose.
5
- *
6
- * Values are absolute offsets into the engine's shared {@link Float32Array} input
7
- * channel buffer — each member equals `ChannelOffset.Gamepads + localIndex`.
8
- * Use {@link Gamepad.resolveChannelOffset} to account for per-slot skew when
9
- * reading a specific gamepad's data.
10
- */
11
- var GamepadChannel;
12
- (function (GamepadChannel) {
13
- GamepadChannel[GamepadChannel["ButtonSouth"] = 512] = "ButtonSouth";
14
- GamepadChannel[GamepadChannel["ButtonWest"] = 513] = "ButtonWest";
15
- GamepadChannel[GamepadChannel["ButtonEast"] = 514] = "ButtonEast";
16
- GamepadChannel[GamepadChannel["ButtonNorth"] = 515] = "ButtonNorth";
17
- GamepadChannel[GamepadChannel["LeftShoulder"] = 516] = "LeftShoulder";
18
- GamepadChannel[GamepadChannel["RightShoulder"] = 517] = "RightShoulder";
19
- GamepadChannel[GamepadChannel["LeftTrigger"] = 518] = "LeftTrigger";
20
- GamepadChannel[GamepadChannel["RightTrigger"] = 519] = "RightTrigger";
21
- GamepadChannel[GamepadChannel["Select"] = 520] = "Select";
22
- GamepadChannel[GamepadChannel["Start"] = 521] = "Start";
23
- GamepadChannel[GamepadChannel["LeftStick"] = 522] = "LeftStick";
24
- GamepadChannel[GamepadChannel["RightStick"] = 523] = "RightStick";
25
- GamepadChannel[GamepadChannel["DPadUp"] = 524] = "DPadUp";
26
- GamepadChannel[GamepadChannel["DPadDown"] = 525] = "DPadDown";
27
- GamepadChannel[GamepadChannel["DPadLeft"] = 526] = "DPadLeft";
28
- GamepadChannel[GamepadChannel["DPadRight"] = 527] = "DPadRight";
29
- GamepadChannel[GamepadChannel["Guide"] = 528] = "Guide";
30
- GamepadChannel[GamepadChannel["Share"] = 529] = "Share";
31
- GamepadChannel[GamepadChannel["Capture"] = 530] = "Capture";
32
- GamepadChannel[GamepadChannel["Touchpad"] = 531] = "Touchpad";
33
- GamepadChannel[GamepadChannel["Paddle1"] = 532] = "Paddle1";
34
- GamepadChannel[GamepadChannel["LeftStickLeft"] = 533] = "LeftStickLeft";
35
- GamepadChannel[GamepadChannel["LeftStickRight"] = 534] = "LeftStickRight";
36
- GamepadChannel[GamepadChannel["LeftStickUp"] = 535] = "LeftStickUp";
37
- GamepadChannel[GamepadChannel["LeftStickDown"] = 536] = "LeftStickDown";
38
- GamepadChannel[GamepadChannel["RightStickLeft"] = 537] = "RightStickLeft";
39
- GamepadChannel[GamepadChannel["RightStickRight"] = 538] = "RightStickRight";
40
- GamepadChannel[GamepadChannel["RightStickUp"] = 539] = "RightStickUp";
41
- GamepadChannel[GamepadChannel["RightStickDown"] = 540] = "RightStickDown";
42
- GamepadChannel[GamepadChannel["AuxiliaryAxis0Negative"] = 541] = "AuxiliaryAxis0Negative";
43
- GamepadChannel[GamepadChannel["AuxiliaryAxis0Positive"] = 542] = "AuxiliaryAxis0Positive";
44
- GamepadChannel[GamepadChannel["AuxiliaryAxis1Negative"] = 543] = "AuxiliaryAxis1Negative";
45
- GamepadChannel[GamepadChannel["AuxiliaryAxis1Positive"] = 544] = "AuxiliaryAxis1Positive";
46
- GamepadChannel[GamepadChannel["AuxiliaryAxis2Negative"] = 545] = "AuxiliaryAxis2Negative";
47
- GamepadChannel[GamepadChannel["AuxiliaryAxis2Positive"] = 546] = "AuxiliaryAxis2Positive";
48
- GamepadChannel[GamepadChannel["AuxiliaryAxis3Negative"] = 547] = "AuxiliaryAxis3Negative";
49
- GamepadChannel[GamepadChannel["AuxiliaryAxis3Positive"] = 548] = "AuxiliaryAxis3Positive";
50
- })(GamepadChannel || (GamepadChannel = {}));
51
-
52
- export { GamepadChannel };
53
- //# sourceMappingURL=GamepadChannels.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"GamepadChannels.js","s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AAA,wBAAA,CAAA,GAAA,GAAA,CAAA,GAAA,wBAAoD;AACpD,IAAA,cAAA,CAAA,cAAA,CAAA,wBAAA,CAAA,GAAA,GAAA,CAAA,GAAA,wBAAoD;AACpD,IAAA,cAAA,CAAA,cAAA,CAAA,wBAAA,CAAA,GAAA,GAAA,CAAA,GAAA,wBAAoD;AACpD,IAAA,cAAA,CAAA,cAAA,CAAA,wBAAA,CAAA,GAAA,GAAA,CAAA,GAAA,wBAAoD;AACpD,IAAA,cAAA,CAAA,cAAA,CAAA,wBAAA,CAAA,GAAA,GAAA,CAAA,GAAA,wBAAoD;AACpD,IAAA,cAAA,CAAA,cAAA,CAAA,wBAAA,CAAA,GAAA,GAAA,CAAA,GAAA,wBAAoD;AACpD,IAAA,cAAA,CAAA,cAAA,CAAA,wBAAA,CAAA,GAAA,GAAA,CAAA,GAAA,wBAAoD;AACpD,IAAA,cAAA,CAAA,cAAA,CAAA,wBAAA,CAAA,GAAA,GAAA,CAAA,GAAA,wBAAoD;AACxD,CAAC,EAtCW,cAAc,KAAd,cAAc,GAAA,EAAA,CAAA,CAAA;;;;"}
@@ -1,33 +0,0 @@
1
- import type { GamepadChannel } from './GamepadChannels';
2
- /**
3
- * Construction options for a single {@link GamepadControl}.
4
- * All fields are optional; defaults produce a plain pass-through control
5
- * with a 0.2 dead-zone.
6
- */
7
- export interface GamepadControlOptions {
8
- invert?: boolean;
9
- normalize?: boolean;
10
- threshold?: number;
11
- }
12
- /**
13
- * Represents a single mappable control — one button or one axis — on a physical gamepad.
14
- *
15
- * Stores the raw Gamepad API `index`, the target {@link GamepadChannel}, and the
16
- * transform parameters (`invert`, `normalize`, `threshold`) applied each frame
17
- * by {@link transformValue} before the value is written to the channel buffer.
18
- */
19
- export declare class GamepadControl {
20
- readonly index: number;
21
- readonly channel: GamepadChannel;
22
- readonly invert: boolean;
23
- readonly normalize: boolean;
24
- readonly threshold: number;
25
- constructor(index: number, channel: GamepadChannel, options?: GamepadControlOptions);
26
- /**
27
- * Applies the control's transform pipeline to a raw browser value.
28
- *
29
- * Pipeline: clamp to [-1, 1] → optional invert → optional normalize to [0, 1]
30
- * → dead-zone (returns 0 when the absolute result is at or below `threshold`).
31
- */
32
- transformValue(value: number): number;
33
- }
@@ -1,42 +0,0 @@
1
- import { clamp } from '../math/utils.js';
2
-
3
- /**
4
- * Represents a single mappable control — one button or one axis — on a physical gamepad.
5
- *
6
- * Stores the raw Gamepad API `index`, the target {@link GamepadChannel}, and the
7
- * transform parameters (`invert`, `normalize`, `threshold`) applied each frame
8
- * by {@link transformValue} before the value is written to the channel buffer.
9
- */
10
- class GamepadControl {
11
- index;
12
- channel;
13
- invert;
14
- normalize;
15
- threshold;
16
- constructor(index, channel, options = {}) {
17
- this.index = index;
18
- this.channel = channel;
19
- this.invert = options.invert ?? false;
20
- this.normalize = options.normalize ?? false;
21
- this.threshold = clamp(options.threshold ?? 0.2, 0, 1);
22
- }
23
- /**
24
- * Applies the control's transform pipeline to a raw browser value.
25
- *
26
- * Pipeline: clamp to [-1, 1] → optional invert → optional normalize to [0, 1]
27
- * → dead-zone (returns 0 when the absolute result is at or below `threshold`).
28
- */
29
- transformValue(value) {
30
- let result = clamp(value, -1, 1);
31
- if (this.invert) {
32
- result *= -1;
33
- }
34
- if (this.normalize) {
35
- result = (result + 1) / 2;
36
- }
37
- return result > this.threshold ? result : 0;
38
- }
39
- }
40
-
41
- export { GamepadControl };
42
- //# sourceMappingURL=GamepadControl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"GamepadControl.js","sources":["../../../../src/input/GamepadControl.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAeA;;;;;;AAMG;MACU,cAAc,CAAA;AACP,IAAA,KAAK;AACL,IAAA,OAAO;AACP,IAAA,MAAM;AACN,IAAA,SAAS;AACT,IAAA,SAAS;AAEzB,IAAA,WAAA,CAAmB,KAAa,EAAE,OAAuB,EAAE,UAAiC,EAAE,EAAA;AAC1F,QAAA,IAAI,CAAC,KAAK,GAAG,KAAK;AAClB,QAAA,IAAI,CAAC,OAAO,GAAG,OAAO;QACtB,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,KAAK;QACrC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,KAAK;AAC3C,QAAA,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,SAAS,IAAI,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;IAC1D;AAEA;;;;;AAKG;AACI,IAAA,cAAc,CAAC,KAAa,EAAA;QAC/B,IAAI,MAAM,GAAG,KAAK,CAAC,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;AAEhC,QAAA,IAAI,IAAI,CAAC,MAAM,EAAE;YACb,MAAM,IAAI,EAAE;QAChB;AAEA,QAAA,IAAI,IAAI,CAAC,SAAS,EAAE;YAChB,MAAM,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC;QAC7B;AAEA,QAAA,OAAO,MAAM,GAAG,IAAI,CAAC,SAAS,GAAG,MAAM,GAAG,CAAC;IAC/C;AACH;;;;"}
@@ -1,52 +0,0 @@
1
- import { Signal } from '@/core/Signal';
2
- import type { Keyboard } from '@/input/types';
3
- import type { GamepadChannel } from './GamepadChannels';
4
- /** Convenience options accepted by the {@link Input} constructor. */
5
- interface InputOptions {
6
- onStart?: () => void;
7
- onStop?: () => void;
8
- onActive?: () => void;
9
- onTrigger?: () => void;
10
- context?: object;
11
- threshold?: number;
12
- }
13
- /** Union of channel identifiers an {@link Input} can subscribe to. */
14
- export type InputChannel = GamepadChannel | Keyboard;
15
- /**
16
- * Bind one or more input channels (keyboard keys, gamepad buttons, gamepad
17
- * axes) to a set of high-level events: `onStart` (became active),
18
- * `onStop` (became inactive), `onActive` (per-frame while active), and
19
- * `onTrigger` (released within the threshold window — a "tap"). The current
20
- * raw value is the max across all subscribed channels.
21
- *
22
- * Construct ad-hoc, or via {@link InputManager.add}. Driven by the
23
- * {@link InputManager} update loop which feeds the unified channel buffer.
24
- *
25
- * @example
26
- * ```ts
27
- * const jump = new Input([Keyboard.Space, GamepadChannel.FaceA], {
28
- * onTrigger: () => player.jump(),
29
- * });
30
- * ```
31
- */
32
- export declare class Input {
33
- static triggerThreshold: number;
34
- private readonly channels;
35
- private readonly triggerTimer;
36
- private valueState;
37
- readonly onStart: Signal<[number]>;
38
- readonly onStop: Signal<[number]>;
39
- readonly onActive: Signal<[number]>;
40
- readonly onTrigger: Signal<[number]>;
41
- constructor(channels: Array<InputChannel> | InputChannel, { onStart, onStop, onActive, onTrigger, context, threshold }?: InputOptions);
42
- get activeChannels(): Set<number>;
43
- get value(): number;
44
- /**
45
- * Read the latest values from the unified channel buffer and dispatch
46
- * the appropriate Signals. Called once per frame by {@link InputManager}.
47
- * No-op for inputs not bound to any channel.
48
- */
49
- update(channels: Float32Array): this;
50
- destroy(): void;
51
- }
52
- export {};
@@ -1,90 +0,0 @@
1
- import { Signal } from '../core/Signal.js';
2
- import { Timer } from '../core/Timer.js';
3
- import { milliseconds } from '../core/utils.js';
4
-
5
- /**
6
- * Bind one or more input channels (keyboard keys, gamepad buttons, gamepad
7
- * axes) to a set of high-level events: `onStart` (became active),
8
- * `onStop` (became inactive), `onActive` (per-frame while active), and
9
- * `onTrigger` (released within the threshold window — a "tap"). The current
10
- * raw value is the max across all subscribed channels.
11
- *
12
- * Construct ad-hoc, or via {@link InputManager.add}. Driven by the
13
- * {@link InputManager} update loop which feeds the unified channel buffer.
14
- *
15
- * @example
16
- * ```ts
17
- * const jump = new Input([Keyboard.Space, GamepadChannel.FaceA], {
18
- * onTrigger: () => player.jump(),
19
- * });
20
- * ```
21
- */
22
- class Input {
23
- static triggerThreshold = 300;
24
- channels = new Set();
25
- triggerTimer;
26
- valueState = 0;
27
- onStart = new Signal();
28
- onStop = new Signal();
29
- onActive = new Signal();
30
- onTrigger = new Signal();
31
- constructor(channels, { onStart, onStop, onActive, onTrigger, context, threshold } = {}) {
32
- this.channels = new Set(Array.isArray(channels) ? channels : [channels]);
33
- this.triggerTimer = new Timer(milliseconds(threshold ?? Input.triggerThreshold));
34
- if (onStart) {
35
- this.onStart.add(onStart, context);
36
- }
37
- if (onStop) {
38
- this.onStop.add(onStop, context);
39
- }
40
- if (onActive) {
41
- this.onActive.add(onActive, context);
42
- }
43
- if (onTrigger) {
44
- this.onTrigger.add(onTrigger, context);
45
- }
46
- }
47
- get activeChannels() {
48
- return this.channels;
49
- }
50
- get value() {
51
- return this.valueState;
52
- }
53
- /**
54
- * Read the latest values from the unified channel buffer and dispatch
55
- * the appropriate Signals. Called once per frame by {@link InputManager}.
56
- * No-op for inputs not bound to any channel.
57
- */
58
- update(channels) {
59
- this.valueState = 0;
60
- for (const channel of this.channels) {
61
- this.valueState = Math.max(channels[channel], this.valueState);
62
- }
63
- if (this.valueState) {
64
- if (!this.triggerTimer.running) {
65
- this.triggerTimer.restart();
66
- this.onStart.dispatch(this.valueState);
67
- }
68
- this.onActive.dispatch(this.valueState);
69
- }
70
- else if (this.triggerTimer.running) {
71
- this.onStop.dispatch(this.valueState);
72
- if (!this.triggerTimer.expired) {
73
- this.onTrigger.dispatch(this.valueState);
74
- }
75
- this.triggerTimer.stop();
76
- }
77
- return this;
78
- }
79
- destroy() {
80
- this.channels.clear();
81
- this.triggerTimer.destroy();
82
- this.onStart.destroy();
83
- this.onStop.destroy();
84
- this.onActive.destroy();
85
- this.onTrigger.destroy();
86
- }
87
- }
88
-
89
- export { Input };
90
- //# sourceMappingURL=Input.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Input.js","sources":["../../../../src/input/Input.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAoBA;;;;;;;;;;;;;;;;AAgBG;MACU,KAAK,CAAA;AACP,IAAA,OAAO,gBAAgB,GAAG,GAAG;AAEnB,IAAA,QAAQ,GAAG,IAAI,GAAG,EAAU;AAC5B,IAAA,YAAY;IACrB,UAAU,GAAG,CAAC;AAEN,IAAA,OAAO,GAAG,IAAI,MAAM,EAAY;AA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GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC;QAClE;AAEA,QAAA,IAAI,IAAI,CAAC,UAAU,EAAE;AACjB,YAAA,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE;AAC5B,gBAAA,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE;gBAC3B,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC;YAC1C;YAEA,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC;QAC3C;AAAO,aAAA,IAAI,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE;YAClC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC;AAErC,YAAA,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE;gBAC5B,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC;YAC5C;AAEA,YAAA,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE;QAC5B;AAEA,QAAA,OAAO,IAAI;IACf;IAEO,OAAO,GAAA;AACV,QAAA,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE;AACrB,QAAA,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE;AAE3B,QAAA,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;AACtB,QAAA,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;AACrB,QAAA,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE;AACvB,QAAA,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE;IAC5B;;;;;"}
@@ -1,77 +0,0 @@
1
- import { Vector } from '@/math/Vector';
2
- import { Color } from '@/core/Color';
3
- import { Time } from '@/core/Time';
4
- import type { ParticleOptions } from './emitters/ParticleOptions';
5
- import type { ParticleProperties } from '@/particles/ParticleProperties';
6
- /**
7
- * Mutable per-instance state for a single live particle. Implements
8
- * {@link ParticleProperties} so affectors can mutate it through the shared
9
- * interface. Particles are pooled by {@link ParticleSystem}: expired instances
10
- * are moved to the graveyard and reused via {@link ParticleSystem.requestParticle}
11
- * rather than garbage-collected.
12
- *
13
- * Do not construct directly — use {@link ParticleSystem.requestParticle} to
14
- * obtain a recycled or fresh instance, then configure it through
15
- * {@link Particle.applyOptions}.
16
- */
17
- export declare class Particle implements ParticleProperties {
18
- private _totalLifetime;
19
- private _elapsedLifetime;
20
- private _position;
21
- private _velocity;
22
- private _scale;
23
- private _rotation;
24
- private _rotationSpeed;
25
- private _textureIndex;
26
- private _tint;
27
- get totalLifetime(): Time;
28
- set totalLifetime(totalLifetime: Time);
29
- get elapsedLifetime(): Time;
30
- set elapsedLifetime(elapsedLifetime: Time);
31
- get position(): Vector;
32
- set position(position: Vector);
33
- get velocity(): Vector;
34
- set velocity(velocity: Vector);
35
- get scale(): Vector;
36
- set scale(scale: Vector);
37
- get tint(): Color;
38
- set tint(tint: Color);
39
- get rotation(): number;
40
- set rotation(degrees: number);
41
- get rotationSpeed(): number;
42
- set rotationSpeed(rotationSpeed: number);
43
- get textureIndex(): number;
44
- set textureIndex(textureIndex: number);
45
- /**
46
- * Time remaining before this particle expires, returned via the shared
47
- * `Time.temp` scratch value — copy before storing if you need it beyond
48
- * the current frame.
49
- */
50
- get remainingLifetime(): Time;
51
- /**
52
- * Fraction of total lifetime already elapsed, in [0, 1]. Used by
53
- * {@link ColorAffector} as the interpolation factor for tint blending.
54
- */
55
- get elapsedRatio(): number;
56
- /** Fraction of total lifetime still remaining, in [0, 1]. */
57
- get remainingRatio(): number;
58
- /**
59
- * Returns `true` once `elapsedLifetime` exceeds `totalLifetime`. Expired
60
- * particles are moved to the graveyard by {@link ParticleSystem.update}
61
- * before affectors run.
62
- */
63
- get expired(): boolean;
64
- /**
65
- * Bulk-copies every field from `options` into this particle, replacing all
66
- * previous state. Called immediately after {@link ParticleSystem.requestParticle}
67
- * to configure a recycled particle for reuse.
68
- */
69
- applyOptions(options: ParticleOptions): this;
70
- /**
71
- * Destroys all owned value objects. Called by
72
- * {@link ParticleSystem.clearParticles} when the pool is flushed entirely.
73
- * Do not call on individual particles mid-simulation; let the system
74
- * recycle them via the graveyard instead.
75
- */
76
- destroy(): void;
77
- }
@@ -1,143 +0,0 @@
1
- import { Vector } from '../math/Vector.js';
2
- import { Color } from '../core/Color.js';
3
- import { Time } from '../core/Time.js';
4
- import { trimRotation } from '../math/utils.js';
5
-
6
- /**
7
- * Mutable per-instance state for a single live particle. Implements
8
- * {@link ParticleProperties} so affectors can mutate it through the shared
9
- * interface. Particles are pooled by {@link ParticleSystem}: expired instances
10
- * are moved to the graveyard and reused via {@link ParticleSystem.requestParticle}
11
- * rather than garbage-collected.
12
- *
13
- * Do not construct directly — use {@link ParticleSystem.requestParticle} to
14
- * obtain a recycled or fresh instance, then configure it through
15
- * {@link Particle.applyOptions}.
16
- */
17
- class Particle {
18
- _totalLifetime = Time.oneSecond.clone();
19
- _elapsedLifetime = Time.zero.clone();
20
- _position = Vector.zero.clone();
21
- _velocity = Vector.zero.clone();
22
- _scale = Vector.one.clone();
23
- _rotation = 0;
24
- _rotationSpeed = 0;
25
- _textureIndex = 0;
26
- _tint = Color.white.clone();
27
- get totalLifetime() {
28
- return this._totalLifetime;
29
- }
30
- set totalLifetime(totalLifetime) {
31
- this._totalLifetime.copy(totalLifetime);
32
- }
33
- get elapsedLifetime() {
34
- return this._elapsedLifetime;
35
- }
36
- set elapsedLifetime(elapsedLifetime) {
37
- this._elapsedLifetime.copy(elapsedLifetime);
38
- }
39
- get position() {
40
- return this._position;
41
- }
42
- set position(position) {
43
- this._position.copy(position);
44
- }
45
- get velocity() {
46
- return this._velocity;
47
- }
48
- set velocity(velocity) {
49
- this._velocity.copy(velocity);
50
- }
51
- get scale() {
52
- return this._scale;
53
- }
54
- set scale(scale) {
55
- this._scale.copy(scale);
56
- }
57
- get tint() {
58
- return this._tint;
59
- }
60
- set tint(tint) {
61
- this._tint.copy(tint);
62
- }
63
- get rotation() {
64
- return this._rotation;
65
- }
66
- set rotation(degrees) {
67
- this._rotation = trimRotation(degrees);
68
- }
69
- get rotationSpeed() {
70
- return this._rotationSpeed;
71
- }
72
- set rotationSpeed(rotationSpeed) {
73
- this._rotationSpeed = rotationSpeed;
74
- }
75
- get textureIndex() {
76
- return this._textureIndex;
77
- }
78
- set textureIndex(textureIndex) {
79
- this._textureIndex = textureIndex;
80
- }
81
- /**
82
- * Time remaining before this particle expires, returned via the shared
83
- * `Time.temp` scratch value — copy before storing if you need it beyond
84
- * the current frame.
85
- */
86
- get remainingLifetime() {
87
- return Time.temp.set(this._totalLifetime.milliseconds - this._elapsedLifetime.milliseconds);
88
- }
89
- /**
90
- * Fraction of total lifetime already elapsed, in [0, 1]. Used by
91
- * {@link ColorAffector} as the interpolation factor for tint blending.
92
- */
93
- get elapsedRatio() {
94
- return this._elapsedLifetime.milliseconds / this._totalLifetime.milliseconds;
95
- }
96
- /** Fraction of total lifetime still remaining, in [0, 1]. */
97
- get remainingRatio() {
98
- return this.remainingLifetime.milliseconds / this._totalLifetime.milliseconds;
99
- }
100
- /**
101
- * Returns `true` once `elapsedLifetime` exceeds `totalLifetime`. Expired
102
- * particles are moved to the graveyard by {@link ParticleSystem.update}
103
- * before affectors run.
104
- */
105
- get expired() {
106
- return this._elapsedLifetime.greaterThan(this._totalLifetime);
107
- }
108
- /**
109
- * Bulk-copies every field from `options` into this particle, replacing all
110
- * previous state. Called immediately after {@link ParticleSystem.requestParticle}
111
- * to configure a recycled particle for reuse.
112
- */
113
- applyOptions(options) {
114
- const { totalLifetime, elapsedLifetime, position, velocity, scale, tint, rotation, rotationSpeed, textureIndex, } = options;
115
- this._totalLifetime.copy(totalLifetime);
116
- this._elapsedLifetime.copy(elapsedLifetime);
117
- this._position.copy(position);
118
- this._velocity.copy(velocity);
119
- this._scale.copy(scale);
120
- this._tint.copy(tint);
121
- this._rotation = rotation;
122
- this._rotationSpeed = rotationSpeed;
123
- this._textureIndex = textureIndex;
124
- return this;
125
- }
126
- /**
127
- * Destroys all owned value objects. Called by
128
- * {@link ParticleSystem.clearParticles} when the pool is flushed entirely.
129
- * Do not call on individual particles mid-simulation; let the system
130
- * recycle them via the graveyard instead.
131
- */
132
- destroy() {
133
- this._totalLifetime.destroy();
134
- this._elapsedLifetime.destroy();
135
- this._position.destroy();
136
- this._velocity.destroy();
137
- this._scale.destroy();
138
- this._tint.destroy();
139
- }
140
- }
141
-
142
- export { Particle };
143
- //# sourceMappingURL=Particle.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Particle.js","sources":["../../../../src/particles/Particle.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AAOA;;;;;;;;;;AAUG;MACU,QAAQ,CAAA;AACT,IAAA,cAAc,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE;AACvC,IAAA,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;AACpC,IAAA,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE;AAC/B,IAAA,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE;AAC/B,IAAA,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE;IAC3B,SAAS,GAAG,CAAC;IACb,cAAc,GAAG,CAAC;IAClB,aAAa,GAAG,CAAC;AACjB,IAAA,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE;AAEnC,IAAA,IAAW,aAAa,GAAA;QACpB,OAAO,IAAI,CAAC,cAAc;IAC9B;IAEA,IAAW,aAAa,CAAC,aAAa,EAAA;AAClC,QAAA,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,aAAa,CAAC;IAC3C;AAEA,IAAA,IAAW,eAAe,GAAA;QACtB,OAAO,IAAI,CAAC,gBAAgB;IAChC;IAEA,IAAW,eAAe,CAAC,eAAe,EAAA;AACtC,QAAA,IAAI,CAAC,gBAAgB,CAAC,IAAI,CA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OAAO,GAAA;AACV,QAAA,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE;AAC7B,QAAA,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE;AAC/B,QAAA,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE;AACxB,QAAA,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE;AACxB,QAAA,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;AACrB,QAAA,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE;IACxB;AACH;;;;"}
@@ -1,29 +0,0 @@
1
- import type { Time } from '@/core/Time';
2
- import type { Vector } from '@/math/Vector';
3
- import type { Color } from '@/core/Color';
4
- /**
5
- * Shared property contract for both {@link Particle} (live instance) and
6
- * {@link ParticleOptions} (spawn configuration). Every field represents a
7
- * mutable, per-particle attribute that affectors and the system update each
8
- * tick.
9
- */
10
- export interface ParticleProperties {
11
- /** Total time the particle lives before expiring. */
12
- totalLifetime: Time;
13
- /** Time that has passed since the particle was spawned. */
14
- elapsedLifetime: Time;
15
- /** Position in the owning {@link ParticleSystem}'s local coordinate space. */
16
- position: Vector;
17
- /** Pixels-per-second movement vector applied by the system each tick. */
18
- velocity: Vector;
19
- /** Multiplicative scale applied to the particle sprite on both axes. */
20
- scale: Vector;
21
- /** Rotation in degrees, normalised to [0, 360) by {@link trimRotation}. */
22
- rotation: number;
23
- /** Degrees-per-second angular velocity accumulated by {@link TorqueAffector}. */
24
- rotationSpeed: number;
25
- /** Index into the atlas frame list used to choose the particle sprite. */
26
- textureIndex: number;
27
- /** RGBA tint blended onto the particle sprite, interpolated by {@link ColorAffector}. */
28
- tint: Color;
29
- }
@@ -1,30 +0,0 @@
1
- import type { ParticleAffector } from '@/particles/affectors/ParticleAffector';
2
- import type { Color } from '@/core/Color';
3
- import type { Particle } from '@/particles/Particle';
4
- import type { Time } from '@/core/Time';
5
- /**
6
- * Linearly interpolates a particle's {@link Particle.tint} from `fromColor`
7
- * to `toColor` over the particle's full lifetime. The blend factor is
8
- * {@link Particle.elapsedRatio} — 0 at birth, 1 at expiry — so the
9
- * transition is always proportional to how long the particle has lived
10
- * regardless of delta size.
11
- */
12
- export declare class ColorAffector implements ParticleAffector {
13
- private readonly _fromColor;
14
- private readonly _toColor;
15
- constructor(fromColor: Color, toColor: Color);
16
- get fromColor(): Color;
17
- set fromColor(color: Color);
18
- get toColor(): Color;
19
- set toColor(color: Color);
20
- setFromColor(color: Color): this;
21
- setToColor(color: Color): this;
22
- /**
23
- * Sets `particle.tint` to the RGBA value interpolated between
24
- * {@link fromColor} and {@link toColor} at the particle's current
25
- * {@link Particle.elapsedRatio}. `delta` is unused but required by the
26
- * {@link ParticleAffector} contract.
27
- */
28
- apply(particle: Particle, delta: Time): this;
29
- destroy(): void;
30
- }