Expand description
Scene serialization helpers.
All scene I/O is project-relative when possible — saves and loads route
through crate::project_vfs::ProjectVfs so the editor uses the same
AssetService + FileLoader contract as a future runtime. The “Save As” /
“Open” file-dialog flows still accept arbitrary paths (that’s intentional —
you might want to open a scene from outside the current project) and fall
back to direct std::fs only in that case.
Constants§
- DEFAULT_
SCENE_ REL - Canonical relative path of the auto-created default scene.
Functions§
- auto_
load_ or_ create_ default_ scene - Auto-loads the project’s default scene (
assets/scenes/default.kscene), creating it from a Camera + Light template if it doesn’t exist yet. - create_
default_ 🔒scene_ in_ project - Spawns Main Camera + Directional Light entities, then saves the world to
the relative path inside the project (default
scenes/default.kscene). - load_
scene_ from_ path - Loads a scene from an absolute path. Used by the “Open…” dialog when
the user picks a file outside
<project>/assets/. - load_
scene_ in_ project - Loads a scene by its relative path under
<project>/assets/via the project’sAssetService::load_raw. Falls back to a fresh reindex + retry once if the path isn’t yet known to the VFS (e.g. just-saved). - rel_
inside_ project - If
abs_pathlives under<project>/assets/, returns the relative path in forward-slash form ready forload_scene_in_project. Otherwise returnsNone— callers should fall back toload_scene_from_path. - restore_
scene - Restores the world from a snapshot produced by
snapshot_scene. - save_
scene_ in_ project - Serializes the current world to a
.kscenefile atrel_path(relative to the project’sassets/root) via the project’sAssetService. Re- indexes on success so the new scene is immediately resolvable by UUID. - save_
scene_ in_ project_ with_ goal - Same as
save_scene_in_projectwith an explicit serialization goal. - save_
scene_ to_ path - Serializes the world to a
.ksceneat an absolute path. Used by the “Save As…” dialog when the user picks a destination outside<project>/assets/. Logs a warning so the divergence from VFS-managed I/O is visible. - save_
scene_ to_ path_ with_ goal - Same as
save_scene_to_pathwith an explicit serialization goal. - snapshot_
scene - Serializes the entire world to an in-memory byte buffer for play-mode
restore. Returns an empty
Vecon failure (caller logs and proceeds — the worst case is “Stop button leaves the live state in place”, which is preferable to a panic mid-play).