Skip to main content

Module editor_scene

Module editor_scene 

Source

Structs§

EditorScene
OpenScene 🔒
One open scene tab: its own World, entity-asset tracking, hierarchy/inspector selection state, and viewport camera — everything that used to be a single set of fields directly on EditorScene before a project could have more than one scene open for editing at once. Kept fully loaded in memory for as long as its tab stays open (see EditorScene::open_scenes), unlike the old single-scene design, which discarded and reloaded a scene’s World from disk on every switch.

Enums§

EditorMode 🔒
Whether the editor is authoring the scene or running it live. Play snapshots the whole [World] and starts a [ScriptRuntime]; Stop restores the snapshot and drops the runtime (and every script’s state with it) — see EditorScene::start_play/[stop_play]. A whole-World snapshot (not just Transform) is what makes scripts that spawn/despawn/rename entities or attach scripts fully revert on Stop, the same way a Transform-only snapshot already made translate/rotate/scale revert. Always targets whichever tab was active when Play started — see EditorScene::switch_or_open_scene/[close_scene_tab] for why switching or closing tabs stops Play first.
LoadState 🔒
Where a load currently stands, so it can be spread across several frames instead of blocking the main thread for its whole duration.
PendingAction
What the editor scene should do with a project root on its first update, once a Renderer (and therefore GPU access for loading assets) is available. Set either by the menu scene handing off to a freshly-built EditorScene, or by the editor’s own File menu.
PlayConfirmAction 🔒
What the user chose in the pre-Play “unsaved changes” dialog (see draw_play_confirmation).

Constants§

CAMERA_GIZMO_ASPECT 🔒
Placeholder aspect ratio for the gizmo’s proportions — CameraComponent doesn’t store aspect (it’s viewport-derived, only meaningful once Play assigns a real camera), so the gizmo just assumes a common 16:9 shape.
CAMERA_GIZMO_DISTANCE 🔒
Fixed visual size for a camera entity’s frustum gizmo, in world units — deliberately not derived from the component’s real znear/zfar (which can be arbitrarily large), since the gizmo is an at-a-glance orientation indicator, not a literal clip-volume outline.
EXPORT_STATUS_DISPLAY 🔒
How long the last Export result stays in the overlay (see EditorScene::export_status) before it ages out on its own.
LOAD_BUDGET_PER_FRAME 🔒
Longest a single update is allowed to spend loading entity renderables before yielding a frame back to the event loop, so the loading screen keeps animating and the window stays responsive on a project with a lot of assets instead of freezing until it’s all done.
SCRIPT_ERROR_DISPLAY 🔒
How long a script error stays in the overlay (see EditorScene::script_errors) before it ages out on its own, so a one-off error doesn’t linger forever if the user doesn’t hit Stop.

Functions§

default_camera 🔒
The starting viewport camera every fresh [World] gets — extracted so EditorScene::opening and EditorScene::start_load (which each build a brand new World) don’t duplicate it.
draw_camera_gizmo 🔒
Draws an 8-line wireframe pyramid (eye to 4 far-plane corners, plus the far rectangle) representing component’s frustum at transform, projected through view_camera (the camera currently driving the viewport).
draw_loading_screen 🔒
draw_play_confirmation 🔒
Shown instead of the normal editor UI while EditorScene::play_confirmation is set — Play was requested while one or more tabs have unsaved edits. Lists which scenes are dirty so the choice is informed, then lets the user save everything first, play anyway (accepting that a scene.change(...) to one of these would load its last-saved, not current, contents), or cancel.
format_script_error 🔒
is_valid_rename_stem 🔒
Whether stem is safe to use as a single filename component in EditorScene::rename_scene/ EditorScene::rename_script — both come straight from a text field the user typed into, with no validation of their own. PathBuf::with_file_name doesn’t resolve or reject //\ or ./.., it just folds them into the resulting path verbatim — so an untrusted stem like "../../outside" would let project.root.join(&new_path) resolve outside the project entirely. Rejecting anything but a single normal path component here keeps every renamed scene/script path project-root-relative, matching every other path this module hands out.
spawn_budgeted 🔒
Spawns up to LOAD_BUDGET_PER_FRAME worth of remaining entities into world/ entity_assets, returning true once remaining is empty (the load is finished) — shared by the “New/Open Project” and “open an additional scene as a new tab” load paths.