SceneViewerService
- Namespace: Turian.Engine.Core
- Source File: SceneViewerService.cs
Per-viewer rendering service for the editor's Scene View panel. One instance per open panel. All instances share the process-wide Vulkan device. Ownership model: - Shared (singleton): Vulkan (VkInstance, VkDevice, queues) - Per-viewer (owned here): OffscreenFrameTarget, render systems, descriptor resources, UBO buffers, EditorCamera The editor overlay root — for future overlays (grid, sky, etc.) — is a separate Node tree owned here, never part of any SceneManager scene, never serialized.
Properties
Camera
(EditorCamera) : The editor camera for this viewer. Not a scene node — never serialized.
Width
(uint): Current render width.
Height
(uint): Current render height.
EditorOverlayRoot
(Node) = new Node { Name = "__EditorOverlay" }: The editor-only overlay scene root. Add editor-only nodes here (grid, sky, etc.). Never shown in the SceneTree panel. Never passed to SceneManager. Never serialized.
Gizmos
(Gizmos) = new(): The immediate-mode gizmo API exposed to draw calls during Render. The buffer is cleared automatically at the start of each frame.
OnPopulateGizmos
(ActionGizmos here.
OverlayTexture
(Texture?) { get; set }: A texture composited over the rendered frame, after the scene and gizmos — the engine's screen-space GUI, or null for none. The caller owns the texture's lifetime.
OverlaySource
(Func<uint, uint, float, Texture?>?) { get; set }: Produces the overlay texture for a frame from the target size and delta time, called once per Render before the pass. The screen-space GUI is wired here; leave it null to composite nothing. Whatever it returns is assigned to OverlayTexture.
WorldUiSource
(Func<WorldUiFrame, IReadOnlyListRender before the pass. Leave it null to draw no world-space UI.
Public Methods
Render
public void Render(Node sceneRoot, double deltaTime, ICamera? camera = null)
Renders one frame of sceneRoot into the offscreen target. Call CopyPixels afterwards to read the result.
Parameters:
sceneRoot(Node): The root of the hierarchy to render.deltaTime(double): The time elapsed since the previous frame, in seconds.camera(ICamera?): The camera to render from. Defaults to this viewer'sCamera; the Game panel passes the running scene'sCameraComponentinstead. The caller owns resizing any camera it supplies. (Default:null)
CopyPixels
public void CopyPixels(Span<byte> destination)
Copies the last rendered frame's BGRA8 pixels into destination. The span must be at least Width * Height * 4 bytes.
Parameters:
destination(Span)
FrameNode
public void FrameNode(Node target, float distance = 5f)
Positions the editor camera to look at target from a sensible distance, keeping the camera's current Yaw/Pitch (so the viewing angle is preserved).
Parameters:
target(Node)distance(float) (Default:5f)
FrameBounds
public void FrameBounds(Bounds bounds)
Positions the editor camera to frame the given bounds, computing distance from the camera's FOV angle. Keeps the current Yaw/Pitch so the viewing angle is preserved.
Parameters:
bounds(Bounds)
Resize
public void Resize(uint width, uint height)
Resizes the viewport. Recreates the frame target; render systems are reused (render-pass-compatible).
Parameters:
width(uint)height(uint)
Dispose
public void Dispose()