Skip to content

Fix Ballpit background not reacting to parameter change - #1013

Merged
DavidHDev merged 1 commit into
DavidHDev:mainfrom
DarkFalc0n:feat/fix-ballpit-background
Jul 28, 2026
Merged

Fix Ballpit background not reacting to parameter change#1013
DavidHDev merged 1 commit into
DavidHDev:mainfrom
DarkFalc0n:feat/fix-ballpit-background

Conversation

@DarkFalc0n

Copy link
Copy Markdown
Contributor

The Ballpit background did not react to parameter changes in Background Studio when props were updated.

Cause

The Ballpit component initialized the createBallpit physics/rendering instance once inside a mount useEffect, but had no mechanism or useEffect to listen to subsequent prop updates and sync them to the running instance, nor an updateConfig handler on the instance.

Changes

  • Live configuration updates: Added updateConfig method to createBallpit to handle dynamic prop updates. If count changes, it re-initializes the spheres buffer; for other parameters (e.g. colors, minSize, maxSize, size0), it updates the live config, colors, and physics sizes dynamically.
  • Prop sync effect: Added a useEffect hook in Ballpit component to sync updated props and followCursor to spheresInstanceRef (skipping initial render via isFirstRender ref).
  • Applied identically across all four variants: content (JS/CSS), tailwind (JS/TW), ts-default, ts-tailwind.
  • Synced the embedded source in the generated public/r/Ballpit-{JS,TS}-{CSS,TW}.json registry files.
useEffect(() => {
  if (isFirstRender.current) {
    isFirstRender.current = false;
    return;
  }
  if (spheresInstanceRef.current) {
    spheresInstanceRef.current.updateConfig({ followCursor, ...props });
  }
}, [props, followCursor]);

@DavidHDev
DavidHDev merged commit 6190995 into DavidHDev:main Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: Background Ballpit not reacting in Background Studio to parameter change.

2 participants