From 0a814b2bbb1e65b9836e1a3a3a6b8e191d2b23a1 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Mar 2026 20:25:36 +0000 Subject: [PATCH] Fix collision preview showing phantom collisions on low-density tables MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit simulate() always pushes a StateUpdate at time=0 as the first replay entry. The first worker call correctly strips it, but subsequent calls included it in the data sent to the main thread. This StateUpdate contains snapshots of every circle, causing the collision preview renderer to show all balls at stale positions — appearing as desynchronized collision indicators that vanish before the actual collisions occur. Strip the StateUpdate from subsequent simulation batches, matching the behavior of the first batch. https://claude.ai/code/session_01RCdxNaKG7Rg4CRMh7kXu7z --- src/lib/simulation.worker.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib/simulation.worker.ts b/src/lib/simulation.worker.ts index fab921a..b52c35e 100644 --- a/src/lib/simulation.worker.ts +++ b/src/lib/simulation.worker.ts @@ -71,6 +71,7 @@ self.addEventListener('message', (event: MessageEvent) => { self.postMessage(response) } else { const simulatedResults = simulate(TABLE_WIDTH, TABLE_HEIGHT, time, circles) + simulatedResults.shift() // Remove the initial StateUpdate — not needed for subsequent batches const response: WorkerSimulationResponse = { type: ResponseMessageType.SIMULATION_DATA, payload: {