Scene Management

Overview

The Scene system provides JSON-based serialization for saving/loading entire scenes, and snapshot/restore for play mode support in the editor.

Working with Scenes in the Editor

File Menu

ActionShortcutDescription
New SceneCtrl+NClears all entities and starts fresh
Open SceneCtrl+OOpens a .scene file from disk
Save SceneCtrl+SSaves to the current file path
Save Scene AsCtrl+Shift+SSave with a file dialog to choose location

Play Mode

When you press Play, the editor takes a snapshot of the current scene state. All changes made during play mode (physics, scripts, etc.) are temporary. When you press Stop, the scene is restored to its pre-play state.

Scene File Format

Scenes are stored as .scene JSON files:

{
  "version": 1,
  "entities": [
    {
      "name": "Player",
      "components": {
        "Transform": { "posX": 0, "posY": 0, "posZ": 0, ... },
        "ModelRenderer": { "model": "assets/Player.glb" },
        "Camera": { "fov": 45, "isMain": true }
      }
    }
  ]
}

Serialized Components

  • Transform (position, rotation, scale)
  • PointLight (color, intensity)
  • Camera (fov, near/far, projection type, isMain)
  • ModelRenderer (model asset path)

Integration Notes

  • Default serializers are registered automatically by the Engine constructor
  • The Scene system filters out internal Flecs entities (systems, observers, modules)
  • Scene file uses nlohmann/json for serialization
  • Play mode uses in-memory JSON strings for fast snapshot/restore