Skip to content

feat: Add an interactive web example gallery deployed to GitHub Pages#117

Merged
spydon merged 8 commits into
mainfrom
web-examples
Jul 20, 2026
Merged

feat: Add an interactive web example gallery deployed to GitHub Pages#117
spydon merged 8 commits into
mainfrom
web-examples

Conversation

@spydon

@spydon spydon commented Jul 19, 2026

Copy link
Copy Markdown
Member

Stacked on #116 (which is stacked on #115).

What

The old browser examples return as a modern, single-page demo gallery running on the WebAssembly backend, with a GitHub Pages deployment.

Scenes (all draggable with the pointer via a mouse joint):

  • Pyramid and Domino tower (a bullet ball topples it)
  • Ball cage (zero gravity, kinematic spinning paddle, chain-loop cage)
  • Circle stress (320 balls in a container)
  • Blob (a soft body of distance-joint springs)
  • Bridge (revolute-joint planks under load)
  • Racer (wheel-joint car on rolling chain terrain, arrow keys to drive, following camera)

Presentation: dark theme, palette-tinted shapes through Box2D v3's per-shape custom colors, pill navigation with URL-hash deep links, hint bubble per scene, device-pixel-ratio aware canvas, fixed-timestep loop with an accumulator. Rendering goes through the public DebugDraw interface, so the gallery doubles as a demonstration of it.

Deploy: deploy-examples.yml builds with build_runner --release and publishes to GitHub Pages on pushes to main. One-time repo setup: enable the GitHub Actions source under Settings > Pages.

Testing

Built and verified locally in headless Chrome: all scenes render and simulate on the wasm backend (screenshots in the PR conversation), melos run format-check and dart analyze --fatal-infos green.

Base automatically changed from box2d-wasm to main July 20, 2026 19:17
spydon added 8 commits July 20, 2026 21:18
The old browser demos return as a single-page gallery on the WebAssembly
backend: pyramid, domino tower, ball cage, circle stress, blob, bridge,
and racer, rendered through a canvas DebugDraw with a dark palette. Every
scene supports dragging bodies with a mouse joint, the racer drives with
the arrow keys and a following camera, and scenes deep-link by URL hash.

deploy-examples.yml builds the gallery with build_runner on pushes to
main and publishes it to GitHub Pages (enable the GitHub Actions source
under Settings > Pages once).
The tower now uses the classic construction from the old demo: vertical
dominoes carrying horizontal planks level by level with braces at the
edges and tapering density, 25 levels tall. It stands perfectly still
until a heavy ball, launched two seconds in from a random side, height,
and speed, knocks it down. Verified deterministically on the VM: the top
of the tower keeps its height through the standing phase and falls from
y=34 to y=6 after impact.

Every scene also gains a Reset button in the header, which rebuilds the
current scene (and re-rolls the domino ball trajectory).
The car fell asleep after landing and setting a wheel joint's motor speed
does not wake sleeping bodies, so arrow keys appeared dead. The chassis
and wheels now have sleep disabled. Verified on the VM: after three
seconds of idling, two seconds of ArrowRight drives the car 14 meters.
Event listeners now register through a DomEvent enum instead of raw
strings, making the event names typo-proof at the call sites.
Every DOM event name is the lowercase of its camelCase Dart name, so the
constructor parameter goes away in favor of a name-based getter.
Deploying through the gh-pages branch works before the workflow reaches
the default branch, and materializing build_runner's symlinked packages
directory fixes the missing assets that broke both the artifact upload
(tar: File removed before we read it) and the branch deploy.
Shapes are now drawn from Shape.geometry with their body transforms, the
same pattern a game renderer such as flame_forge2d uses, with the camera
rectangle as an overlapAabb culling query. Joints still come from the
debug draw with shape drawing disabled. Shape colors travel through
userData, so the inline shape definitions gained explicit colors.
The header shows the flaming anvil next to the title and the SVG doubles
as the favicon, copied from design/only-logo.svg.
@spydon
spydon enabled auto-merge (squash) July 20, 2026 19:20
@spydon
spydon merged commit 664f944 into main Jul 20, 2026
8 checks passed
@spydon
spydon deleted the web-examples branch July 20, 2026 19:23
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.

2 participants