Skip to content

Editor Overview

The Editor module provides an in-engine editor built on ImGui, offering tools for scene editing, entity manipulation, and content creation within a unified development environment.

Architecture

The top-level class is Editor - a singleton accessed via Editor::init() and Editor::get(). It owns a LayerManager that holds the panel layers and a DockspaceOverlay that provides the menu bar and docking layout.

Panel System

Display NameImplementation Class
ViewportViewportLayer
Scene HierarchySceneHierarchyLayer
PropertiesPropertiesLayer
Content BrowserContentBrowserLayer
ConsoleConsoleLayer

The dockspace and menu bar are rendered by DockspaceOverlay, which is an overlay registered separately in LayerManager.

Layout System

The editor stores ImGui docking layout as an ini_settings string inside a Layout struct. DefaultLayout (extends Layout) provides a built-in layout with Scene Hierarchy (left), Viewport (center), Properties (right), and Console/Content Browser at the bottom as overlapping tabs.

Note: Layout loading via ImGui::LoadIniSettingsFromMemory() is currently commented out in DockspaceOverlay::start(), so the layout may not be applied at runtime.

Viewport

The viewport renders the scene to a framebuffer and displays it via an ImGui image.

Note: Gizmo interaction (translate/rotate/scale) is not yet implemented in ViewportLayer.

ImGui Integration

Built on immediate-mode UI:

Scene Hierarchy

Tree view of entities with selection and manipulation:

Properties Panel

Component inspection and editing via PropertiesLayer. Supported components displayed:

  • TransformComponent - Position, Rotation, Scale
  • MaterialComponent - Material settings
  • MeshComponent - Mesh and material
  • CameraComponent - Camera properties
  • RigidBodyComponent - Physics body properties
  • LightComponent - Light properties

The UI provides entity templates (Empty, Cube, Sphere, Capsule, Quad, Plane) via context menus in SceneHierarchyLayer.

Content Browser

Asset directory browsing via ContentBrowserLayer. Two-panel layout with a directory tree on the left and file grid on the right. The base directory is src/assets.

Supports drag-and-drop with "CONTENT_BROWSER_ITEM" payload, though integration with the Viewport is not confirmed in source.

Key Responsibilities

  • Scene Editing - Visual entity manipulation
  • Component Editing - Property inspection and modification
  • Asset Management - Browse project assets
  • Console & Debug - Log output and debugging tools

Editor Camera

The EditorCamera class (extends Object) exists in the module with an entity structure containing TransformComponent and CameraComponent. All movement keybindings (pan, rotate, zoom, orbit) are currently commented out and not yet implemented.

Keyboard Shortcuts

  • Delete: Delete selected entity (via context menu in SceneHierarchyLayer)

Note: The DockspaceOverlay menu bar provides File (Save, Exit), GameObject, Component, and Window menus. Specific keyboard shortcuts like Ctrl+S, Ctrl+D (duplicate), Ctrl+Z/Y (undo/redo), and gizmo mode shortcuts (W/E/R) are not implemented.

WebSocket Server Mode

When compiled with ASTRA_EDITOR_USOCKET, the editor runs in a headless remote mode. ImGui panels are bypassed entirely and the editor communicates via a uWebSockets SSL server on port 9001, publishing to three topics:

  • framebuffer - rendered frame data (1920x1080 RGBA via glReadPixels)
  • scene - serialized active scene (binary format)
  • logs - JSON-serialized log entries (level, message, line, timestamp, caller, file)

In this mode a timer-based loop drives the frame updates instead of the normal window event loop. The server also receives keyboard and mouse input from remote clients. SSL certificates required: misc/key.pem and misc/cert.pem with passphrase "1234".

Messages use a custom binary format: 4-byte topic length (big-endian) + topic string + payload.

Integration Points

  • Engine - Edits entities and components via ECS
  • Window - Receives input events
  • Project - Accesses asset paths
  • Renderer - Renders viewport framebuffer

For detailed implementation, see Editor Core Concepts.