Skip to content

feat: terrain painting, prefab authoring, play-in-editor (PLAN §D/§E) — unpushed work#3

Merged
proggeramlug merged 3 commits into
mainfrom
feat/editor-paint-prefabs-playtest
Jul 15, 2026
Merged

feat: terrain painting, prefab authoring, play-in-editor (PLAN §D/§E) — unpushed work#3
proggeramlug merged 3 commits into
mainfrom
feat/editor-paint-prefabs-playtest

Conversation

@proggeramlug

Copy link
Copy Markdown
Contributor

These three commits existed only on one machine. They were committed to a
local main and never pushed — found while auditing what's outstanding across
the repos. The PLAN already marks this work ✅ DONE, which is true locally and
was invisible to everyone else.

commit what
90a9736 Prefab authoring (PLAN §E) — and a fix for the editor rendering no models at all (joinPath('.', x)'./x' made every model a grey box)
b5e6189 Play-in-editor: run the real game on the level you're looking at
8336186 Terrain painting (PLAN §D)

No changes of mine — pushing them as-is, via a branch/PR because that's the
convention every repo here uses.

Verified before pushing: the editor compiles clean against current engine
main, including the Color type/value split from Bloom-Engine/engine#102.

Why this matters beyond the three commits

The audit rated these features "DONE" from the PLAN. They were done — and one
disk failure from gone. Worth a look at whether anything else is sitting
committed-but-unpushed.

https://claude.ai/code/session_01J1UWgMcrTNvwWeXcJ1T3Fp

Ralph Kuepper added 3 commits July 12, 2026 21:21
## The bug that matters most here

`joinPath('.', 'assets/models')` returned `'./assets/models'`. The project file
lives in the CWD, so rootDir came out as '.', so the asset catalog was keyed
`'./assets/models/prop_tree.glb'` while every world file references
`'assets/models/prop_tree.glb'`.

Every model lookup missed. EVERY entity with a model rendered as a grey placeholder
cube -- all 88 trees, the building, every prop. The models loaded fine. Nothing
errored. The editor just quietly showed you a level made of boxes, which is
indistinguishable from "this level is made of boxes", and is exactly why it survived
this long. The editor was unusable for authoring and it was not obvious that it was.

'.' is not a directory component -- it is "here", and prefixing it produces a path
that is EQUIVALENT to the original but not EQUAL to it. The catalog is a Map; only
equal will do. Self-test pins the identity between catalog key and world modelRef.

## Prefab authoring (PLAN §E)

prefab-tool.ts had existed for weeks with ZERO call sites, because the UI it seemed
to need -- a parallel render path for children, a parallel selection model, parallel
gizmo handling -- was too big a job to start.

It needed none of that. A PrefabChild is an EntityData minus `name` and `userData`,
so while you edit a prefab its children simply ARE state.world.entities: the real
world is parked in a stash and the children are handed to the editor as the world.
Rendering, picking, the move/rotate/scale gizmos, delete, duplicate, snapping,
undo/redo -- all of it was already written against entities, and none of it needs to
know it is looking at a prefab.

- Prefabs tab: name field + "+ New Prefab"; "Edit <name>" for the selected prefab.
  No double-click: the UI context has no notion of one, and a hidden gesture is
  worse than a visible button.
- Ctrl+S saves the PREFAB, not the world -- saving the world from inside prefab mode
  would write the neutral authoring stage over the real level.
- ESC restores the world AND its undo history exactly. Prefab mode gets its own
  history; undoing past its start and landing in the world's edits would be
  indefensible.
- Cycle rejection is TRANSITIVE (A->B->C->A), enforced at the one place a cycle can
  be created, and it now SAYS so -- via a new transient status line. The editor had
  no way to tell you it had refused something, and a click that silently does
  nothing reads as a broken editor rather than a rule being enforced.
- Entering prefab mode frames the camera on the parts. Without it the camera stays
  pointed at a 200 m arena and a three-prop prefab is three pixels of dust.

87 self-tests pass (was 81). Verified in the running editor: the arena now renders
its actual trees, building and river instead of grey boxes; prefab mode shows its
parts in the outliner, saves *.prefab.json, and restores the world on exit.
A Play button in the toolbar (and Ctrl+R). Saves the level currently ON SCREEN --
not the one on disk; making you save first would defeat the point -- to a scratch
world, and launches the game on it via `--world <path>`.

The fly-cam shows you geometry. It cannot show you whether the spawners spawn,
whether the cover works, whether the arena has a shape -- the things a level actually
has to do. And if testing a level means "add it to a manifest, restart the game,
navigate the menu", it will not get tested often enough to matter.

Needed two things that did not exist: engine EN-048 (launchProcess -- Perry's
child_process.spawn COMPILES and then does nothing), and a `--world` override in the
shooter. `playCommand` in editor.project.json opts a project in; without it there is
no button, because a dead button is worse than no button.

Verified end to end: editor -> scratch world (204,275 bytes) -> game launched on it,
rendering the level the editor had just written.

Claude-Session: https://claude.ai/code/session_01V3MihNxaRwMR8GjMPvMkRb
Paint the ground. The layer list is in the brush panel; the layers are the world's
own `terrain.layers`, and the swatch beside each is the MASK colour the viewport
tints it with — the viewport shows coverage, the game shows the material.

- `paint` is a fifth brush kind. LMB paints, Shift+LMB erases.
- `+ Add layer` picks a texture from the project's textures dir (new `texturesDir`
  key, default `assets/textures`). The catalog lists textures without loading them
  — a splat layer only ever stores a path, and decoding forty 2K PNGs so a panel
  can print their names would be the most expensive no-op in the program.
- A splat is a PARTITION: painting grass in pushes everything else out, or the
  weights sum past 1 and a cell that is 90% grass AND 90% rock renders as a
  washed-out average of every texture at once. Erase drives the active layer to
  zero and does NOT push the others up, so coverage falls and the ground fades back
  to the game's procedural blend rather than to a bald patch.
- Undo snapshots EVERY layer, not just the one you were holding.
- Layers are rebuilt explicitly rather than with `.push()`/`.splice()`: they came
  from JSON.parse and get serialized back to disk (perry-quirks #2).

+29 self-test assertions (116 total), covering the partition invariant, undo of a
removed-but-painted layer, and the vertex-colour preview — including that adding an
unpainted layer changes nothing.

Claude-Session: https://claude.ai/code/session_01V3MihNxaRwMR8GjMPvMkRb
@proggeramlug proggeramlug merged commit 189d0da into main Jul 15, 2026
@proggeramlug proggeramlug deleted the feat/editor-paint-prefabs-playtest branch July 15, 2026 16:38
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@proggeramlug, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 55 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 15214583-6d72-419a-8c00-ae1a1488c10f

📥 Commits

Reviewing files that changed from the base of the PR and between 9df15a5 and 8336186.

📒 Files selected for processing (18)
  • PLAN.md
  • src/io/asset-catalog.ts
  • src/io/paths.ts
  • src/io/project.ts
  • src/main.ts
  • src/playtest/launch.ts
  • src/state/commands/terrain-paint.ts
  • src/state/editor-state.ts
  • src/tests/self-tests.ts
  • src/tools/brush-tool.ts
  • src/tools/place-tool.ts
  • src/tools/prefab-tool.ts
  • src/ui/layouts/asset-panel.ts
  • src/ui/layouts/brush-panel.ts
  • src/ui/layouts/inspector.ts
  • src/ui/layouts/status-bar.ts
  • src/ui/layouts/toolbar.ts
  • src/viewport/ray.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/editor-paint-prefabs-playtest

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

1 participant