Skip to content

Conversation

@kube
Copy link
Collaborator

@kube kube commented Jan 23, 2026

🌟 What is the purpose of this PR?

Introduce a new PlaybackContext that handles viewing simulation frames at real-time speed based on dt, separate from the computation speed. This allows the simulation to be computed as fast as possible while the visualization plays back at the correct real-time speed.

🔗 Related links

🚫 Blocked by

Nothing

🔍 What does this change?

  • Create playback/context.ts with PlaybackContextValue type defining playback state and actions
  • Create playback/provider.tsx with requestAnimationFrame-based playback loop
  • Move currentViewedFrame from SimulationContext to PlaybackContext
  • Update all consumer components to use PlaybackContext for frame viewing
  • SimulationContext now only handles computation/generation of frames
  • PlaybackContext advances frames at real-time speed (60Hz max) based on dt

Pre-Merge Checklist 🚀

🚢 Has this modified a publishable library?

This PR:

  • modifies an npm-publishable library and I have added a changeset file(s)

📜 Does this require a change to the docs?

The changes in this PR:

  • are internal and do not require a docs change

🕸️ Does this require a change to the Turbo Graph?

The changes in this PR:

  • do not affect the execution graph

⚠️ Known issues

None

🐾 Next steps

None

🛡 What tests cover this?

  • No automated tests yet

❓ How to test this?

  1. Checkout the branch
  2. Run the petrinaut editor with yarn dev
  3. Create a simulation and run it
  4. Confirm that the visualization plays back at real-time speed based on dt rather than computation speed

📹 Demo

N/A

Introduce a new PlaybackContext that handles viewing simulation frames
at real-time speed based on dt, separate from the computation speed.

- Create playback/context.ts with PlaybackContextValue type
- Create playback/provider.tsx with requestAnimationFrame-based playback
- Move currentViewedFrame from SimulationContext to PlaybackContext
- Update all consumers to use PlaybackContext for frame viewing
- SimulationContext now only handles computation/generation of frames
- PlaybackContext advances frames at real-time speed (60Hz max)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Jan 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Review Updated (UTC)
hashdotdesign Ignored Ignored Preview Jan 23, 2026 2:17am
hashdotdesign-tokens Ignored Ignored Preview Jan 23, 2026 2:17am

@github-actions github-actions bot added area/libs Relates to first-party libraries/crates/packages (area) type/eng > frontend Owned by the @frontend team labels Jan 23, 2026
Copy link
Collaborator Author

kube commented Jan 23, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/infra Relates to version control, CI, CD or IaC (area) area/libs Relates to first-party libraries/crates/packages (area) type/eng > frontend Owned by the @frontend team

Development

Successfully merging this pull request may close these issues.

2 participants