Commit 5a53718
committed
feat(particle): implement rateOverDistance emission
Cherry-picked from #3011 (e2e parts dropped).
- Wire up EmissionModule.rateOverDistance: each frame accumulates the
delta of the emitter's world position and emits ratePerUnit × distance
particles (Unity-aligned).
- Sub-interval distance fragment carried across frames; floor-based
count instead of subtract-loop to avoid float drift dropping a particle
at exact boundaries.
- Distribute the N per-frame emissions spatially along
[lastPos → currentPos] in World simulation space, and interpolate
emit time the same way so age-driven modules (COL/SOL/FOL) render a
smooth gradient instead of a uniform block.
- Clamp _emit at the maxParticles budget and return the actual count,
so a setPosition teleport on a rateOverDistance emitter can't expand
into millions of no-op iterations.
- Reset baseline + accumulator on stop(StopEmitting*) so a play-after-
clear re-syncs from the current position.
Includes unit tests covering zero-rate, ratePerUnit × distance,
sub-interval accumulation across frames, static emitter, stop+clear
reset, spatial distribution, per-particle emit-time spacing, and
teleport-induced burst guard.1 parent 2ea4515 commit 5a53718
3 files changed
Lines changed: 454 additions & 34 deletions
File tree
- packages/core/src/particle
- modules
- tests/src/core/particle
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
236 | 236 | | |
237 | 237 | | |
238 | 238 | | |
| 239 | + | |
| 240 | + | |
239 | 241 | | |
240 | 242 | | |
241 | 243 | | |
242 | 244 | | |
243 | 245 | | |
244 | 246 | | |
245 | 247 | | |
| 248 | + | |
| 249 | + | |
246 | 250 | | |
247 | 251 | | |
248 | 252 | | |
| |||
258 | 262 | | |
259 | 263 | | |
260 | 264 | | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
288 | 295 | | |
289 | | - | |
290 | 296 | | |
| 297 | + | |
291 | 298 | | |
| 299 | + | |
292 | 300 | | |
293 | 301 | | |
294 | 302 | | |
| |||
832 | 840 | | |
833 | 841 | | |
834 | 842 | | |
835 | | - | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
836 | 850 | | |
837 | 851 | | |
838 | 852 | | |
| |||
864 | 878 | | |
865 | 879 | | |
866 | 880 | | |
867 | | - | |
| 881 | + | |
868 | 882 | | |
869 | 883 | | |
870 | 884 | | |
| |||
1023 | 1037 | | |
1024 | 1038 | | |
1025 | 1039 | | |
1026 | | - | |
| 1040 | + | |
1027 | 1041 | | |
1028 | 1042 | | |
1029 | 1043 | | |
| |||
1034 | 1048 | | |
1035 | 1049 | | |
1036 | 1050 | | |
1037 | | - | |
| 1051 | + | |
| 1052 | + | |
1038 | 1053 | | |
1039 | 1054 | | |
1040 | 1055 | | |
1041 | 1056 | | |
1042 | 1057 | | |
1043 | 1058 | | |
1044 | 1059 | | |
1045 | | - | |
| 1060 | + | |
1046 | 1061 | | |
1047 | 1062 | | |
1048 | 1063 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| 18 | + | |
| 19 | + | |
17 | 20 | | |
18 | 21 | | |
19 | 22 | | |
| |||
29 | 32 | | |
30 | 33 | | |
31 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
32 | 42 | | |
33 | 43 | | |
34 | 44 | | |
| |||
130 | 140 | | |
131 | 141 | | |
132 | 142 | | |
| 143 | + | |
133 | 144 | | |
134 | 145 | | |
135 | 146 | | |
| |||
147 | 158 | | |
148 | 159 | | |
149 | 160 | | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
150 | 170 | | |
151 | 171 | | |
152 | 172 | | |
| |||
171 | 191 | | |
172 | 192 | | |
173 | 193 | | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
174 | 253 | | |
175 | 254 | | |
176 | 255 | | |
| |||
0 commit comments