bevyengine / bevyengine/bevy

BSN editor infrastructure: write-back, asset catalog, persistent document - as implemented in Jackdaw

Open
#23,637 0 comments 8 reactions 1 assignee Claimed by @jbuehler23 View on GitHub
A-Scenes C-Design-Doc C-Feature D-Complex S-Needs-Goal
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
4d 8m
Merged PRs (30d)
147

Description

## Summary

Based on experimentation in [Jackdaw](https://github.com/jbuehler23/jackdaw) (a 3D editor I created before BSN), I've found several pieces of BSN infra needed for editor tooling that would benefit the ecosystem.

@cart's PR #23630 explicitly mentions "It is not yet possible to write a World to BSN" as a gap. The subsequent PRs I plan to raise helps to address that, and other related gaps.

## What we needed for a functioning BSN based editor in `Jackdaw`

1. **BSN write-back** - serialize ECS World to `.bsn` text (inverse of the `bsn!` macro)
2. **Default-diffing** - only emit non-default component fields (reduces noise, improves readability)
3. **Enum variant field serialization** - `ColliderConstructor::Sphere { radius: 2.5 }` not just `ColliderConstructor::Sphere` - this was raised in discord as a bug I believe, but I've already had a fix for this in `Jackdaw`
4. **Asset catalog** - shared named assets in `.bsn` format, referenced across scenes
5. **Handle path resolution** - bidirectional `Handle` <---> asset path conversion
6. **Persistent AST** - retain parsed BSN for live editing (this was raised by @pcwalton in #23576)
7. **`SceneDocument` / `SceneAssetCatalog` APIs** - my solution for ergonomic editing via `ScenePatch` instead of raw function calls

## Planned PRs (building blocks first, then API)

- [ ] BSN scene writer (`serialize_to_bsn`) - immediately necessary and beneficial, default-diffing for entity components and enum variant fields - #23639
- [ ] Fix enum struct variant application in dynamic BSN - PR in @pcwalton's branch: https://github.com/pcwalton/bevy/pull/21
- [ ] BSN asset catalog loading and serialization - https://github.com/bevyengine/bevy/pull/23648
- [ ] Persistent BSN AST and bidirectional sync
- [ ] `SceneDocument` API - editing via `ScenePatch`, load/save/spawn
- [ ] `SceneAssetCatalog` API - named shared asset management

## Context

I've been working on converting `Jackdaw` to a BSN editor (inspector edits, entity creation, hierarchy changes, etc) where we write through BSN, and the ECS is derived from it so we can render previews in the viewport and such. I tried to keep the solution as generic as possible in `Jackdaw` so that we can upstream and prepare for the wider bevy-editor buildout based on these enhancements

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.