Skip to content

fix(particles): report isPlaying() in sync with particle lifetime#8901

Merged
willeastcott merged 1 commit into
mainfrom
fix/particle-isplaying-sim-time
Jun 14, 2026
Merged

fix(particles): report isPlaying() in sync with particle lifetime#8901
willeastcott merged 1 commit into
mainfrom
fix/particle-isplaying-sim-time

Conversation

@willeastcott

Copy link
Copy Markdown
Contributor

Description

particlesystem.isPlaying() returned true long after a stopped or non-looping system's particles had visually died. endTime was the full "spawn every particle and outlive the last one" estimate (max(rate, rate2) * numParticles + lifetime) anchored to Date.now(). But after stop() (or loop = false) emission has already halted, so the only remaining work is the alive particles draining — at most lifetime. The wall clock also desynced the playing state under pause / timeScale.

This measures endTime on the emitter's own simulation clock (simTimeTotal, which only advances while ticking and not paused) and uses a lifetime budget once emission halts (stop() and the loop = false setter). Adds unit tests covering the isPlaying() state.

Verified against the issue's repro project (built against this branch): after Stop the label flips to "stopped" at ~5s (the lifetime) instead of ~11s, and the state now survives a pause correctly.

Fixes #2146

Checklist

  • I have read the contributing guidelines
  • My code follows the project's coding standards
  • This PR focuses on a single change

🤖 Generated with Claude Code

A stopped or non-looping emitter reported isPlaying() true long after its particles died: endTime used the full spawn-all-particles estimate (max(rate,rate2)*numParticles + lifetime) on a wall clock. After stop() only the already-alive particles drain, so the budget is at most lifetime, and the wall clock also desynced under pause/timeScale.

Measure endTime on the emitter's own simulation clock (simTimeTotal) and use a lifetime budget once emission halts (stop() and loop = false).

Fixes #2146

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@willeastcott willeastcott self-assigned this Jun 14, 2026
@willeastcott willeastcott merged commit 7833e65 into main Jun 14, 2026
9 checks passed
@willeastcott willeastcott deleted the fix/particle-isplaying-sim-time branch June 14, 2026 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Particle system isPlaying() returns false only long after the lifetime of the particles

1 participant