UI in the scene graph
vgai’s visual UI editor stores UI in the scene — a ui field on the .vscn document
(packages/engine/src/scene/schema/ui.ts) — and renders it with one React runtime used both
in the editor (WYSIWYG) and at game time (SceneUI.tsx).
The node tree
Section titled “The node tree”A UI root is a canvas (space: screen or world-tracked) holding a nested tree:
- Containers —
box,grid,stack,scroll,panel,center,wrap,aspect,tab,sizebox. - Controls —
text,richtext,button,image,input,toggle,slider,dropdown,progress, andcomponent(a hand-authored React component).
Layout: anchor + offset over flexbox
Section titled “Layout: anchor + offset over flexbox”Each node has a layout mode:
flow— laid out by its parent container’s flexbox (directionrow/column[-reverse],justify,align,wrap,columnsfor grid; children setgrow/shrink/basis/alignSelf).absolute— anchored free placement: ananchor(edge fractions 0..1 of the parent) plus a pixeloffsetper edge. Equal anchors fix the size; split anchors stretch. Apivotsets the rotation/scale origin.
This is the Godot/Unity-style anchor model mapped directly onto CSS flexbox — no parallel unit system.
The shared runtime
Section titled “The shared runtime”The same SceneUI React renderer draws the tree in the editor preview and in the running game,
so what you author is what ships. (At game time it mounts into ctx.uiContainer — see
React HUD.)
See also
Section titled “See also”- Styling, theming & binding — make it look right and react to data.
- Visual editing & source sync — author it by direct manipulation.
- React HUD — the runtime surface.