Area editor: real Godot render preview #62

Merged
Nimby merged 1 commit from task/59-render-preview into main 2026-10-04 23:59:25 -04:00
Collaborator

Closes #59

  • render_preview.py <area>: generates the descriptor into web_editor/scratch/preview.tscn (gitignored) and runs Godot without --headless (headless can't capture frames) using --write-movie --fixed-fps 10 --quit-after 30, i.e. 3s of game time so items settle. Keeps the last frame as preview_latest.png. Clear exit codes and messages for a missing Godot, a bad descriptor, a timeout, or no frames.
  • Server: POST /api/render (serialized with a lock, since renders share the scratch dir) returns image/png; GET /api/health reports godot_configured.
  • UI: a Render preview button and an in-game preview panel. The button is disabled with a hint when Godot isn't configured.
  • Config: gitignored local_config.json (example committed) or GODOT_BIN. Setup is in tools/mapgen/web_editor/README.md.
  • export_presets.cfg: exclude_filter="tools/*", so tooling and scratch files never ship in a game build.

Verified in the sandbox

  • Error paths: exit 2 when Godot isn't configured; exit 1 for an unknown area; 400 for bad frames and 404 for an unknown area through the server.
  • Real render via Xvfb + llvmpipe, both from the CLI and through /api/render (valid PNG, ~7.6s). With DISPLAY set, Godot picked the x11 driver on its own, the same path a normal desktop takes.
  • Drove the page in headless Chromium: clicked Render preview, the image loaded at 1600x648 with no console errors, and I reviewed the screenshot.
  • --export-pack with a scratch scene present: 0 tools/mapgen entries in the pack; game scenes still included.

Still to check on a real machine: how the render looks on a real GPU, and that a Godot window flashing briefly during a render is acceptable.

🤖 Generated with Claude Code

Closes #59 - `render_preview.py <area>`: generates the descriptor into `web_editor/scratch/preview.tscn` (gitignored) and runs Godot **without** `--headless` (headless can't capture frames) using `--write-movie --fixed-fps 10 --quit-after 30`, i.e. 3s of game time so items settle. Keeps the last frame as `preview_latest.png`. Clear exit codes and messages for a missing Godot, a bad descriptor, a timeout, or no frames. - Server: `POST /api/render` (serialized with a lock, since renders share the scratch dir) returns `image/png`; `GET /api/health` reports `godot_configured`. - UI: a **Render preview** button and an in-game preview panel. The button is disabled with a hint when Godot isn't configured. - Config: gitignored `local_config.json` (example committed) or `GODOT_BIN`. Setup is in `tools/mapgen/web_editor/README.md`. - `export_presets.cfg`: `exclude_filter="tools/*"`, so tooling and scratch files never ship in a game build. **Verified in the sandbox** - Error paths: exit 2 when Godot isn't configured; exit 1 for an unknown area; 400 for bad `frames` and 404 for an unknown area through the server. - Real render via Xvfb + llvmpipe, both from the CLI and through `/api/render` (valid PNG, ~7.6s). With `DISPLAY` set, Godot picked the x11 driver on its own, the same path a normal desktop takes. - Drove the page in headless Chromium: clicked Render preview, the image loaded at 1600x648 with no console errors, and I reviewed the screenshot. - `--export-pack` with a scratch scene present: 0 `tools/mapgen` entries in the pack; game scenes still included. **Still to check on a real machine:** how the render looks on a real GPU, and that a Godot window flashing briefly during a render is acceptable. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
render_preview.py generates a descriptor into a gitignored scratch scene,
runs it in Godot with --write-movie for 3s of game time (so falling items
settle), and keeps the last frame. It deliberately does not pass
--headless: headless mode's dummy renderer cannot capture frames, while a
normal run uses the machine's real display/GPU.

The server gains POST /api/render (serialized, since renders share the
scratch dir) and GET /api/health; the UI gains a Render preview button
and panel. The Godot path comes from a gitignored local_config.json or
GODOT_BIN. tools/ is now excluded from exports so scratch scenes and
descriptors never ship in a game build.

Closes #59

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Nimby merged commit 8349857eaa into main 2026-10-04 23:59:25 -04:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
scruffydude/project-awry!62
No description provided.