Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

feat: add panel, menu, gizmo and statusbar registration system

esengine373d9e5e7669
diff --git a/editor/src/context/EditorContext.ts b/editor/src/context/EditorContext.ts
new file mode 100644
index 000000000..5fead3752
--- /dev/null
+++ b/editor/src/context/EditorContext.ts
@@ -0,0 +1,38 @@
+import type { NativeFS } from '../scripting/types';
+import type { Editor } from '../Editor';
+
+export interface NativeShell {
+ openFile(path: string): Promise<void>;
+ openInEditor(projectPath: string, filePath: string): Promise<void>;
+ execute(
+ cmd: string,
+ args: string[],
+ cwd: string,
+ onOutput?: (stream: 'stdout' | 'stderr', data: string) => void
+ ): Promise<{ code: number }>;
+}
+
+export interface EditorContextConfig {
+ fs?: NativeFS;
+ invoke?: (cmd: string, args?: Record<string, unknown>) => Promise<unknown>;
+ shell?: NativeShell;
+}
+
+let ctx: EditorContextConfig = {};
+let editorInstance: Editor | null = null;
+
+export function setEditorContext(config: EditorContextConfig): void {
+ ctx = config;
+}
+
+export function getEditorContext(): EditorContextConfig {
+ return ctx;
+}
+
+export function setEditorInstance(editor: Editor): void {
+ editorInstance = editor;
+}
+
+export function getEditorInstance(): Editor | null {
+ return editorInstance;
+}
diff --git a/editor/src/gizmos/GizmoManager.ts b/editor/src/gizmos/GizmoManager.ts
new file mode 100644
index 000000000..39df5b630
--- /dev/null
+++ b/editor/src/gizmos/GizmoManager.ts
@@ -0,0 +1,100 @@
+import type { GizmoContext, GizmoDescriptor } from './GizmoRegistry';
+import { getGizmo, getAllGizmos } from './GizmoRegistry';
+
+export class GizmoManager {
+ private activeId_ = 'move';
+ private dragState_: { descriptor: GizmoDescriptor; data: unknown; startWorldX: number; startWorldY: number } | null = null;
+ private hoveredData_: unknown = null;
+ private context_: GizmoContext | null = null;
+
+ setContext(context: GizmoContext): void {
+ this.context_ = context;
+ }
+
+ setActive(id: string): void {
+ this.activeId_ = id;
+ }
+
+ getActiveId(): string {
+ return this.activeId_;
+ }
+
+ getActive(): GizmoDescriptor | null {
+ return getGizmo(this.activeId_) ?? null;
+ }
+
+ getAllGizmos(): GizmoDescriptor[] {
+ return getAllGizmos();
+ }
+
+ isDragging(): boolean {
+ return this.dragState_ !== null;
+ }
+
+ hitTest(worldX: number, worldY: number): { hit: boolean; data?: unknown } {
+ const gizmo = this.getActive();
+ if (!gizmo || !this.context_) return { hit: false };
+ return gizmo.hitTest(worldX, worldY, this.context_);
+ }
+
+ draw(): void {
+ const gizmo = this.getActive();
+ if (!gizmo || !this.context_) return;
+ gizmo.draw(this.context_);
+ }
+
+ onMouseDown(worldX: number, worldY: number): boolean {
+ const gizmo = this.getActive();
+ if (!gizmo || !this.context_) return false;
+
+ const result = gizmo.hitTest(worldX, worldY, this.context_);
+ if (!result.hit) return false;
+
+ this.dragState_ = {
+ descriptor: gizmo,
+ data: result.data,
+ startWorldX: worldX,
+ startWorldY: worldY,
+ };
+
+ gizmo.onDragStart?.(worldX, worldY, result.data, this.context_);
+ return true;
+ }
+
+ onMouseMove(worldX: number, worldY: number): void {
+ if (!this.context_) return;
+
+ if (this.dragState_) {
+ this.dragState_.descriptor.onDrag?.(worldX, worldY, this.dragState_.data, this.context_);
+ return;
+ }
+
+ const gizmo = this.getActive();
+ if (!gizmo) return;
+
+ const result = gizmo.hitTest(worldX, worldY, this.context_);
+ const newData = result.hit ? result.data : null;
+
+ if (newData !== this.hoveredData_) {
+ this.hoveredData_ = newData;
+ gizmo.onHover?.(worldX, worldY, newData, this.context_);
+ }
+ }
+
+ onMouseUp(worldX: number, worldY: number): void {
+ if (!this.dragState_ || !this.context_) return;
+
+ this.dragState_.descriptor.onDragEnd?.(worldX, worldY, this.dragState_.data, this.context_);
+ this.dragState_ = null;
+ }
+
+ getCursor(): string {
+ const gizmo = this.getActive();
+ if (!gizmo?.getCursor) return 'default';
+ return gizmo.getCursor(this.hoveredData_);
+ }
+
+ resetHover(): void {
+ this.hoveredData_ = null;
+ }
+}
diff --git a/editor/src/gizmos/GizmoRegistry.ts b/editor/src/gizmos/GizmoRegistry.ts
new file mode 100644
index 000000000..c7331b7d6
--- /dev/null
+++ b/editor/src/gizmos/GizmoRegistry.ts
@@ -0,0 +1,43 @@
+import type { EditorStore } from '../store/EditorStore';
+import type { EntityData } from '../types/SceneTypes';
+import type { Transform } from '../math/Transform';
+
+export interface GizmoContext {
+ store: EditorStore;
+ ctx: CanvasRenderingContext2D;
+ zoom: number;
+ screenToWorld(clientX: number, clientY: number): { worldX: number; worldY: number };
+ getWorldTransform(entityId: number): Transform;
+ getEntityBounds(entityData: EntityData): { width: number; height: number; offsetX?: number; offsetY?: number };
+ requestRender(): void;
+}
+
+export interface GizmoDescriptor {
+ id: string;
+ name: string;
+ icon: string;
+ shortcut?: string;
+ order?: number;
+
+ hitTest(worldX: number, worldY: number, ctx: GizmoContext): { hit: boolean; data?: unknown };
+ draw(ctx: GizmoContext): void;
+ onDragStart?(worldX: number, worldY: number, hitData: unknown, ctx: GizmoContext): void;
+ onDrag?(worldX: number, worldY: number, hitData: unknown, ctx: GizmoContext): void;
+ onDragEnd?(worldX: number, worldY: number, hitData: unknown, ctx: GizmoContext): void;
+ onHover?(worldX: number, worldY: number, hitData: unknown, ctx: GizmoContext): void;
+ getCursor?(hitData: unknown): string;
+}
+
+const gizmos = new Map<string, GizmoDescriptor>();
+
+export function registerGizmo(descriptor: GizmoDescriptor): void {
+ gizmos.set(descriptor.id, descriptor);
+}
+
+export function getGizmo(id: string): GizmoDescriptor | undefined {
+ return gizmos.get(id);
+}
+
+export function getAllGizmos(): GizmoDescriptor[] {
+ return Array.from(gizmos.values()).sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
+}
diff --git a/editor/src/gizmos/builtinGizmos.ts b/editor/src/gizmos/builtinGizmos.ts
new file mode 100644
index 000000000..e5a451c19
--- /dev/null
+++ b/editor/src/gizmos/builtinGizmos.ts
@@ -0,0 +1,790 @@
+import { registerGizmo, type GizmoContext, type GizmoDescriptor } from './GizmoRegistry';
+import { icons } from '../utils/icons';
+import { quatToEuler, eulerToQuat } from '../math/Transform';
+
+const GIZMO_COLORS = {
+ x: '#e74c3c',
+ y: '#2ecc71',
+ xy: '#f1c40f',
+ hover: '#ffffff',
+};
+
+const GIZMO_SIZE = 80;
+const GIZMO_HANDLE_SIZE = 10;
+
+type DragAxis = 'none' | 'x' | 'y' | 'xy';
+type RectHandle = 'none' | 'tl' | 'tr' | 'bl' | 'br' | 't' | 'b' | 'l' | 'r';
+
+function getSelectedEntityPosition(gctx: GizmoContext): { x: number; y: number; z: number } | null {
+ const entityData = gctx.store.getSelectedEntityData();
+ if (!entityData) return null;
+ return gctx.getWorldTransform(entityData.id).position;
+}
+
+function deepClone<T>(obj: T): T {
+ if (obj === null || typeof obj !== 'object') return obj;
+ return JSON.parse(JSON.stringify(obj));
+}
+
+function valuesEqual(a: unknown, b: unknown): boolean {
+ return JSON.stringify(a) === JSON.stringify(b);
+}
+
+function getSizeComponentType(entityData: { components: { type: string; data: any }[] }): 'UIRect' | 'Sprite' | null {
+ if (entityData.components.some(c => c.type === 'UIRect')) return 'UIRect';
+ if (entityData.components.some(c => c.type === 'Sprite')) return 'Sprite';
+ return null;
+}
+
+// =============================================================================
+// Select Gizmo
+// =============================================================================
+
+export function createSelectGizmo(): GizmoDescriptor {
+ return {
+ id: 'select',
+ name: 'Select',
+ icon: icons.pointer(14),
+ shortcut: 'q',
+ order: 0,
+ hitTest: () => ({ hit: false }),
+ draw: () => {},
+ };
+}
+
+// =============================================================================
+// Move Gizmo
+// =============================================================================
+
+interface MoveGizmoDragState {
+ startValue: { x: number; y: number; z: number };
+ originalValue: { x: number; y: number; z: number };
+ startWorldX: number;
+ startWorldY: number;
+}
+
+export function createMoveGizmo(): GizmoDescriptor {
+ let hoveredAxis: DragAxis = 'none';
+ let dragAxis: DragAxis = 'none';
+ let dragState: MoveGizmoDragState | null = null;
+
+ return {
+ id: 'move',
+ name: 'Move',
+ icon: icons.move(14),
+ shortcut: 'w',
+ order: 1,
+
+ hitTest(worldX, worldY, gctx) {
+ const pos = getSelectedEntityPosition(gctx);
+ if (!pos) return { hit: false };
+
+ const gizmoScale = GIZMO_SIZE / gctx.zoom;
+ const handleSize = GIZMO_HANDLE_SIZE / gctx.zoom;
+ const dx = worldX - pos.x;
+ const dy = worldY - pos.y;
+
+ if (Math.abs(dx) < handleSize * 2 && Math.abs(dy) < handleSize * 2) {
+ return { hit: true, data: 'xy' as DragAxis };
+ }
+ if (dx > 0 && dx < gizmoScale && Math.abs(dy) < handleSize) {
+ return { hit: true, data: 'x' as DragAxis };
+ }
+ if (dy > 0 && dy < gizmoScale && Math.abs(dx) < handleSize) {
+ return { hit: true, data: 'y' as DragAxis };
+ }
+ return { hit: false };
+ },
+
+ draw(gctx) {
+ const pos = getSelectedEntityPosition(gctx);
+ if (!pos) return;
+
+ const { ctx, zoom } = gctx;
+ ctx.save();
+ ctx.translate(pos.x, -pos.y);
+
+ const size = GIZMO_SIZE / zoom;
+ const lineWidth = 2 / zoom;
+ const handleSize = GIZMO_HANDLE_SIZE / zoom;
+ const arrowSize = 8 / zoom;
+
+ ctx.fillStyle = hoveredAxis === 'xy' ? GIZMO_COLORS.hover : GIZMO_COLORS.xy;
+ ctx.fillRect(-handleSize, -handleSize, handleSize * 2, handleSize * 2);
+
+ ctx.strokeStyle = hoveredAxis === 'x' ? GIZMO_COLORS.hover : GIZMO_COLORS.x;
+ ctx.lineWidth = lineWidth;
+ ctx.beginPath();
+ ctx.moveTo(0, 0);
+ ctx.lineTo(size, 0);
+ ctx.stroke();
+
+ ctx.fillStyle = hoveredAxis === 'x' ? GIZMO_COLORS.hover : GIZMO_COLORS.x;
+ ctx.beginPath();
+ ctx.moveTo(size, 0);
+ ctx.lineTo(size - arrowSize, -arrowSize / 2);
+ ctx.lineTo(size - arrowSize, arrowSize / 2);
+ ctx.closePath();
+ ctx.fill();
+
+ ctx.strokeStyle = hoveredAxis === 'y' ? GIZMO_COLORS.hover : GIZMO_COLORS.y;
+ ctx.beginPath();
+ ctx.moveTo(0, 0);
+ ctx.lineTo(0, -size);
+ ctx.stroke();
+
+ ctx.fillStyle = hoveredAxis === 'y' ? GIZMO_COLORS.hover : GIZMO_COLORS.y;
+ ctx.beginPath();
+ ctx.moveTo(0, -size);
+ ctx.lineTo(-arrowSize / 2, -size + arrowSize);
+ ctx.lineTo(arrowSize / 2, -size + arrowSize);
+ ctx.closePath();
+ ctx.fill();
+
+ ctx.restore();
+ },
+
+ onDragStart(worldX, worldY, hitData, gctx) {
+ dragAxis = hitData as DragAxis;
+ const entityData = gctx.store.getSelectedEntityData();
+ const transform = entityData?.components.find(c => c.type === 'LocalTransform');
+ if (transform) {
+ const value = transform.data.position as { x: number; y: number; z: number };
+ dragState = {
+ startValue: { ...value },
+ originalValue: { ...value },
+ startWorldX: worldX,
+ startWorldY: worldY,
+ };
+ }
+ },
+
+ onDrag(worldX, worldY, _hitData, gctx) {
+ const entity = gctx.store.selectedEntity;
+ if (entity === null || !dragState) return;
+
+ const dx = worldX - dragState.startWorldX;
+ const dy = worldY - dragState.startWorldY;
+
+ let newX = dragState.startValue.x;
+ let newY = dragState.startValue.y;
+
+ if (dragAxis === 'x' || dragAxis === 'xy') newX += dx;
+ if (dragAxis === 'y' || dragAxis === 'xy') newY += dy;
+
+ gctx.store.updatePropertyDirect(entity, 'LocalTransform', 'position', {
+ x: newX, y: newY, z: dragState.startValue.z,
+ });
+ gctx.requestRender();
+ },
+
+ onDragEnd(_worldX, _worldY, _hitData, gctx) {
+ const entity = gctx.store.selectedEntity;
+ if (entity === null || !dragState) { dragState = null; return; }
+
+ const entityData = gctx.store.getSelectedEntityData();
+ const transform = entityData?.components.find(c => c.type === 'LocalTransform');
+ if (transform) {
+ const currentValue = transform.data.position;
+ if (currentValue && !valuesEqual(dragState.originalValue, currentValue)) {
+ gctx.store.updateProperty(
+ entity, 'LocalTransform', 'position',
+ { ...dragState.originalValue }, deepClone(currentValue),
+ );
+ }
+ }
+ dragState = null;
+ dragAxis = 'none';
+ },
+
+ onHover(_worldX, _worldY, hitData, gctx) {
+ hoveredAxis = (hitData as DragAxis) ?? 'none';
+ gctx.requestRender();
+ },
+
+ getCursor(hitData) {
+ return hitData ? 'pointer' : 'default';
+ },
+ };
+}
+
+// =============================================================================
+// Rotate Gizmo
+// =============================================================================
+
+interface RotateGizmoDragState {
+ startEuler: { x: number; y: number; z: number };
+ originalQuat: { x: number; y: number; z: number; w: number };
+ startWorldX: number;
+ startWorldY: number;
+}
+
+export function createRotateGizmo(): GizmoDescriptor {
+ let hovered = false;
+ let dragState: RotateGizmoDragState | null = null;
+
+ return {
+ id: 'rotate',
+ name: 'Rotate',
+ icon: icons.rotateCw(14),
+ shortcut: 'e',
+ order: 2,
+
+ hitTest(worldX, worldY, gctx) {
+ const pos = getSelectedEntityPosition(gctx);
+ if (!pos) return { hit: false };
+
+ const gizmoScale = GIZMO_SIZE / gctx.zoom;
+ const handleSize = GIZMO_HANDLE_SIZE / gctx.zoom;
+ const dx = worldX - pos.x;
+ const dy = worldY - pos.y;
+ const dist = Math.sqrt(dx * dx + dy * dy);
+
+ if (Math.abs(dist - gizmoScale * 0.8) < handleSize * 2) {
+ return { hit: true, data: 'xy' };
+ }
+ return { hit: false };
+ },
+
+ draw(gctx) {
+ const pos = getSelectedEntityPosition(gctx);
+ if (!pos) return;
+
+ const { ctx, zoom } = gctx;
+ ctx.save();
+ ctx.translate(pos.x, -pos.y);
+
+ const size = GIZMO_SIZE / zoom;
+ const lineWidth = 2 / zoom;
+ const handleSize = GIZMO_HANDLE_SIZE / zoom;
+ const radius = size * 0.8;
+
+ const entityData = gctx.store.getSelectedEntityData();
+ const transform = entityData?.components.find(c => c.type === 'LocalTransform');
+ const quat = transform?.data.rotation as { x: number; y: number; z: number; w: number } ?? { x: 0, y: 0, z: 0, w: 1 };
+ const euler = quatToEuler(quat);
+ const angleRad = -euler.z * Math.PI / 180;
+
+ ctx.strokeStyle = 'rgba(100, 100, 100, 0.5)';
+ ctx.lineWidth = lineWidth;
+ ctx.beginPath();
+ ctx.moveTo(0, 0);
+ ctx.lineTo(radius, 0);
+ ctx.stroke();
+
+ ctx.strokeStyle = hovered ? GIZMO_COLORS.hover : GIZMO_COLORS.xy;
+ ctx.lineWidth = lineWidth * 1.5;
+ ctx.beginPath();
+ ctx.arc(0, 0, radius, 0, Math.PI * 2);
+ ctx.stroke();
+
+ ctx.strokeStyle = '#00aaff';
+ ctx.lineWidth = lineWidth * 2;
+ ctx.beginPath();
+ ctx.moveTo(0, 0);
+ ctx.lineTo(Math.cos(angleRad) * radius, Math.sin(angleRad) * radius);
+ ctx.stroke();
+
+ ctx.fillStyle = '#00aaff';
+ ctx.beginPath();
+ ctx.arc(Math.cos(angleRad) * radius, Math.sin(angleRad) * radius, handleSize, 0, Math.PI * 2);
+ ctx.fill();
+
+ ctx.restore();
+ },
+
+ onDragStart(worldX, worldY, _hitData, gctx) {
+ const entityData = gctx.store.getSelectedEntityData();
+ const transform = entityData?.components.find(c => c.type === 'LocalTransform');
+ if (transform) {
+ const quat = transform.data.rotation as { x: number; y: number; z: number; w: number };
+ dragState = {
+ startEuler: quatToEuler(quat ?? { x: 0, y: 0, z: 0, w: 1 }),
+ originalQuat: quat ? { ...quat } : { x: 0, y: 0, z: 0, w: 1 },
+ startWorldX: worldX,
+ startWorldY: worldY,
+ };
+ }
+ },
+
+ onDrag(worldX, worldY, _hitData, gctx) {
+ const entity = gctx.store.selectedEntity;
+ if (entity === null || !dragState) return;
+
+ const pos = getSelectedEntityPosition(gctx);
+ if (!pos) return;
+
+ const startAngle = Math.atan2(
+ dragState.startWorldY - pos.y,
+ dragState.startWorldX - pos.x,
+ );
+ const currentAngle = Math.atan2(worldY - pos.y, worldX - pos.x);
+ const deltaAngle = (currentAngle - startAngle) * (180 / Math.PI);
+
+ const newRotZ = dragState.startEuler.z + deltaAngle;
+ const quat = eulerToQuat({ x: 0, y: 0, z: newRotZ });
+ gctx.store.updatePropertyDirect(entity, 'LocalTransform', 'rotation', quat);
+ gctx.requestRender();
+ },
+
+ onDragEnd(_worldX, _worldY, _hitData, gctx) {
+ const entity = gctx.store.selectedEntity;
+ if (entity === null || !dragState) { dragState = null; return; }
+
+ const entityData = gctx.store.getSelectedEntityData();
+ const transform = entityData?.components.find(c => c.type === 'LocalTransform');
+ if (transform) {
+ const currentValue = transform.data.rotation;
+ if (currentValue && !valuesEqual(dragState.originalQuat, currentValue)) {
+ gctx.store.updateProperty(
+ entity, 'LocalTransform', 'rotation',
+ { ...dragState.originalQuat }, deepClone(currentValue),
+ );
+ }
+ }
+ dragState = null;
+ },
+
+ onHover(_worldX, _worldY, hitData, gctx) {
+ hovered = !!hitData;
+ gctx.requestRender();
+ },
+
+ getCursor(hitData) {
+ return hitData ? 'pointer' : 'default';
+ },
+ };
+}
+
+// =============================================================================
+// Scale Gizmo
+// =============================================================================
+
+interface ScaleGizmoDragState {
+ startValue: { x: number; y: number; z: number };
+ originalValue: { x: number; y: number; z: number };
+ startWorldX: number;
+ startWorldY: number;
+}
+
+export function createScaleGizmo(): GizmoDescriptor {
+ let hoveredAxis: DragAxis = 'none';
+ let dragAxis: DragAxis = 'none';
+ let dragState: ScaleGizmoDragState | null = null;
+
+ return {
+ id: 'scale',
+ name: 'Scale',
+ icon: icons.maximize(14),
+ shortcut: 'r',
+ order: 3,
+
+ hitTest(worldX, worldY, gctx) {
+ const pos = getSelectedEntityPosition(gctx);
+ if (!pos) return { hit: false };
+
+ const gizmoScale = GIZMO_SIZE / gctx.zoom;
+ const handleSize = GIZMO_HANDLE_SIZE / gctx.zoom;
+ const dx = worldX - pos.x;
+ const dy = worldY - pos.y;
+
+ if (Math.abs(dx) < handleSize * 2 && Math.abs(dy) < handleSize * 2) {
+ return { hit: true, data: 'xy' as DragAxis };
+ }
+ if (dx > 0 && dx < gizmoScale && Math.abs(dy) < handleSize) {
+ return { hit: true, data: 'x' as DragAxis };
+ }
+ if (dy > 0 && dy < gizmoScale && Math.abs(dx) < handleSize) {
+ return { hit: true, data: 'y' as DragAxis };
+ }
+ return { hit: false };
+ },
+
+ draw(gctx) {
+ const pos = getSelectedEntityPosition(gctx);
+ if (!pos) return;
+
+ const { ctx, zoom } = gctx;
+ ctx.save();
+ ctx.translate(pos.x, -pos.y);
+
+ const size = GIZMO_SIZE / zoom;
+ const lineWidth = 2 / zoom;
+ const handleSize = GIZMO_HANDLE_SIZE / zoom;
+
+ ctx.fillStyle = hoveredAxis === 'xy' ? GIZMO_COLORS.hover : GIZMO_COLORS.xy;
+ ctx.fillRect(-handleSize, -handleSize, handleSize * 2, handleSize * 2);
+
+ ctx.strokeStyle = hoveredAxis === 'x' ? GIZMO_COLORS.hover : GIZMO_COLORS.x;
+ ctx.lineWidth = lineWidth;
+ ctx.beginPath();
+ ctx.moveTo(0, 0);
+ ctx.lineTo(size, 0);
+ ctx.stroke();
+
+ ctx.fillStyle = hoveredAxis === 'x' ? GIZMO_COLORS.hover : GIZMO_COLORS.x;
+ ctx.fillRect(size - handleSize, -handleSize, handleSize * 2, handleSize * 2);
+
+ ctx.strokeStyle = hoveredAxis === 'y' ? GIZMO_COLORS.hover : GIZMO_COLORS.y;
+ ctx.beginPath();
+ ctx.moveTo(0, 0);
+ ctx.lineTo(0, -size);
+ ctx.stroke();
+
+ ctx.fillStyle = hoveredAxis === 'y' ? GIZMO_COLORS.hover : GIZMO_COLORS.y;
+ ctx.fillRect(-handleSize, -size - handleSize, handleSize * 2, handleSize * 2);
+
+ ctx.restore();
+ },
+
+ onDragStart(worldX, worldY, hitData, gctx) {
+ dragAxis = hitData as DragAxis;
+ const entityData = gctx.store.getSelectedEntityData();
+ const transform = entityData?.components.find(c => c.type === 'LocalTransform');
+ if (transform) {
+ const value = transform.data.scale as { x: number; y: number; z: number };
+ dragState = {
+ startValue: { ...value },
+ originalValue: { ...value },
+ startWorldX: worldX,
+ startWorldY: worldY,
+ };
+ }
+ },
+
+ onDrag(worldX, worldY, _hitData, gctx) {
+ const entity = gctx.store.selectedEntity;
+ if (entity === null || !dragState) return;
+
+ const dx = worldX - dragState.startWorldX;
+ const dy = worldY - dragState.startWorldY;
+ const scaleFactor = 0.01;
+
+ let newX = dragState.startValue.x;
+ let newY = dragState.startValue.y;
+
+ if (dragAxis === 'x' || dragAxis === 'xy') newX += dx * scaleFactor;
+ if (dragAxis === 'y' || dragAxis === 'xy') newY += dy * scaleFactor;
+
+ gctx.store.updatePropertyDirect(entity, 'LocalTransform', 'scale', {
+ x: Math.max(0.01, newX), y: Math.max(0.01, newY), z: dragState.startValue.z,
+ });
+ gctx.requestRender();
+ },
+
+ onDragEnd(_worldX, _worldY, _hitData, gctx) {
+ const entity = gctx.store.selectedEntity;
+ if (entity === null || !dragState) { dragState = null; return; }
+
+ const entityData = gctx.store.getSelectedEntityData();
+ const transform = entityData?.components.find(c => c.type === 'LocalTransform');
+ if (transform) {
+ const currentValue = transform.data.scale;
+ if (currentValue && !valuesEqual(dragState.originalValue, currentValue)) {
+ gctx.store.updateProperty(
+ entity, 'LocalTransform', 'scale',
+ { ...dragState.originalValue }, deepClone(currentValue),
+ );
+ }
+ }
+ dragState = null;
+ dragAxis = 'none';
+ },
+
+ onHover(_worldX, _worldY, hitData, gctx) {
+ hoveredAxis = (hitData as DragAxis) ?? 'none';
+ gctx.requestRender();
+ },
+
+ getCursor(hitData) {
+ return hitData ? 'pointer' : 'default';
+ },
+ };
+}
+
+// =============================================================================
+// Rect Gizmo
+// =============================================================================
+
+interface RectGizmoDragState {
+ startWorldX: number;
+ startWorldY: number;
+ startPos: { x: number; y: number };
+ startSize: { x: number; y: number };
+ originalPos: { x: number; y: number; z: number };
+ originalSize: { x: number; y: number };
+}
+
+function getRectHandleCursor(handle: RectHandle): string {
+ switch (handle) {
+ case 'tl': case 'br': return 'nwse-resize';
+ case 'tr': case 'bl': return 'nesw-resize';
+ case 't': case 'b': return 'ns-resize';
+ case 'l': case 'r': return 'ew-resize';
+ default: return 'default';
+ }
+}
+
+export function createRectGizmo(): GizmoDescriptor {
+ let hoveredHandle: RectHandle = 'none';
+ let activeHandle: RectHandle = 'none';
+ let dragState: RectGizmoDragState | null = null;
+
+ function getHandles(gctx: GizmoContext): { x: number; y: number; key: RectHandle }[] | null {
+ const entityData = gctx.store.getSelectedEntityData();
+ if (!entityData) return null;
+
+ const pos = getSelectedEntityPosition(gctx);
+ if (!pos) return null;
+
+ const worldTransform = gctx.getWorldTransform(entityData.id);
+ const bounds = gctx.getEntityBounds(entityData);
+
+ const w = bounds.width * Math.abs(worldTransform.scale.x);
+ const h = bounds.height * Math.abs(worldTransform.scale.y);
+ const halfW = w / 2;
+ const halfH = h / 2;
+
+ return [
+ { x: -halfW, y: halfH, key: 'tl' },
+ { x: halfW, y: halfH, key: 'tr' },
+ { x: -halfW, y: -halfH, key: 'bl' },
+ { x: halfW, y: -halfH, key: 'br' },
+ { x: 0, y: halfH, key: 't' },
+ { x: 0, y: -halfH, key: 'b' },
+ { x: -halfW, y: 0, key: 'l' },
+ { x: halfW, y: 0, key: 'r' },
+ ];
+ }
+
+ return {
+ id: 'rect',
+ name: 'Rect',
+ icon: icons.rect(14),
+ shortcut: 't',
+ order: 4,
+
+ hitTest(worldX, worldY, gctx) {
+ const entityData = gctx.store.getSelectedEntityData();
+ if (!entityData) return { hit: false };
+
+ const pos = getSelectedEntityPosition(gctx);
+ if (!pos) return { hit: false };
+
+ const worldTransform = gctx.getWorldTransform(entityData.id);
+ const bounds = gctx.getEntityBounds(entityData);
+
+ const w = bounds.width * Math.abs(worldTransform.scale.x);
+ const h = bounds.height * Math.abs(worldTransform.scale.y);
+ const offsetX = (bounds.offsetX ?? 0) * worldTransform.scale.x;
+ const offsetY = (bounds.offsetY ?? 0) * worldTransform.scale.y;
+ const halfW = w / 2;
+ const halfH = h / 2;
+
+ const handleSize = GIZMO_HANDLE_SIZE / gctx.zoom;
+ const dx = worldX - pos.x - offsetX;
+ const dy = worldY - pos.y - offsetY;
+
+ const handles: { x: number; y: number; key: RectHandle }[] = [
+ { x: -halfW, y: halfH, key: 'tl' },
+ { x: halfW, y: halfH, key: 'tr' },
+ { x: -halfW, y: -halfH, key: 'bl' },
+ { x: halfW, y: -halfH, key: 'br' },
+ { x: 0, y: halfH, key: 't' },
+ { x: 0, y: -halfH, key: 'b' },
+ { x: -halfW, y: 0, key: 'l' },
+ { x: halfW, y: 0, key: 'r' },
+ ];
+
+ for (const handle of handles) {
+ if (Math.abs(dx - handle.x) < handleSize * 1.5 &&
+ Math.abs(dy - handle.y) < handleSize * 1.5) {
+ return { hit: true, data: handle.key as RectHandle };
+ }
+ }
+ return { hit: false };
+ },
+
+ draw(gctx) {
+ const entityData = gctx.store.getSelectedEntityData();
+ if (!entityData) return;
+
+ const pos = getSelectedEntityPosition(gctx);
+ if (!pos) return;
+
+ const { ctx, zoom } = gctx;
+ ctx.save();
+ ctx.translate(pos.x, -pos.y);
+
+ const handleSize = GIZMO_HANDLE_SIZE / zoom;
+ const lineWidth = 2 / zoom;
+
+ const worldTransform = gctx.getWorldTransform(entityData.id);
+ const bounds = gctx.getEntityBounds(entityData);
+
+ const w = bounds.width * Math.abs(worldTransform.scale.x);
+ const h = bounds.height * Math.abs(worldTransform.scale.y);
+ const halfW = w / 2;
+ const halfH = h / 2;
+
+ ctx.strokeStyle = GIZMO_COLORS.xy;
+ ctx.lineWidth = lineWidth;
+ ctx.setLineDash([5 / zoom, 5 / zoom]);
+ ctx.strokeRect(-halfW, -halfH, w, h);
+ ctx.setLineDash([]);
+
+ const handles: { x: number; y: number; key: RectHandle }[] = [
+ { x: -halfW, y: -halfH, key: 'tl' },
+ { x: halfW, y: -halfH, key: 'tr' },
+ { x: -halfW, y: halfH, key: 'bl' },
+ { x: halfW, y: halfH, key: 'br' },
+ { x: 0, y: -halfH, key: 't' },
+ { x: 0, y: halfH, key: 'b' },
+ { x: -halfW, y: 0, key: 'l' },
+ { x: halfW, y: 0, key: 'r' },
+ ];
+
+ for (const handle of handles) {
+ const isHovered = hoveredHandle === handle.key;
+ const isCorner = ['tl', 'tr', 'bl', 'br'].includes(handle.key);
+
+ ctx.fillStyle = isHovered ? GIZMO_COLORS.hover : (isCorner ? GIZMO_COLORS.xy : GIZMO_COLORS.x);
+ ctx.fillRect(handle.x - handleSize, handle.y - handleSize, handleSize * 2, handleSize * 2);
+
+ ctx.strokeStyle = '#000';
+ ctx.lineWidth = 1 / zoom;
+ ctx.strokeRect(handle.x - handleSize, handle.y - handleSize, handleSize * 2, handleSize * 2);
+ }
+
+ ctx.restore();
+ },
+
+ onDragStart(worldX, worldY, hitData, gctx) {
+ activeHandle = hitData as RectHandle;
+ const entityData = gctx.store.getSelectedEntityData();
+ if (!entityData) return;
+
+ const transform = entityData.components.find(c => c.type === 'LocalTransform');
+ const pos = transform?.data.position as { x: number; y: number; z: number } ?? { x: 0, y: 0, z: 0 };
+
+ const sizeType = getSizeComponentType(entityData);
+ let size: { x: number; y: number };
+ if (sizeType) {
+ const comp = entityData.components.find(c => c.type === sizeType);
+ size = comp?.data.size as { x: number; y: number } ?? { x: 50, y: 50 };
+ } else {
+ const bounds = gctx.getEntityBounds(entityData);
+ size = { x: bounds.width, y: bounds.height };
+ }
+
+ dragState = {
+ startWorldX: worldX,
+ startWorldY: worldY,
+ startPos: { x: pos.x, y: pos.y },
+ startSize: { x: size.x, y: size.y },
+ originalPos: { ...pos },
+ originalSize: { x: size.x, y: size.y },
+ };
+ },
+
+ onDrag(worldX, worldY, _hitData, gctx) {
+ const entity = gctx.store.selectedEntity;
+ if (entity === null || !dragState) return;
+
+ const entityData = gctx.store.getSelectedEntityData();
+ if (!entityData) return;
+
+ const dx = worldX - dragState.startWorldX;
+ const dy = worldY - dragState.startWorldY;
+
+ let newWidth = dragState.startSize.x;
+ let newHeight = dragState.startSize.y;
+ let newPosX = dragState.startPos.x;
+ let newPosY = dragState.startPos.y;
+
+ switch (activeHandle) {
+ case 'r': newWidth += dx; newPosX += dx / 2; break;
+ case 'l': newWidth -= dx; newPosX += dx / 2; break;
+ case 't': newHeight += dy; newPosY += dy / 2; break;
+ case 'b': newHeight -= dy; newPosY += dy / 2; break;
+ case 'tr': newWidth += dx; newHeight += dy; newPosX += dx / 2; newPosY += dy / 2; break;
+ case 'tl': newWidth -= dx; newHeight += dy; newPosX += dx / 2; newPosY += dy / 2; break;
+ case 'br': newWidth += dx; newHeight -= dy; newPosX += dx / 2; newPosY += dy / 2; break;
+ case 'bl': newWidth -= dx; newHeight -= dy; newPosX += dx / 2; newPosY += dy / 2; break;
+ }
+
+ newWidth = Math.max(1, newWidth);
+ newHeight = Math.max(1, newHeight);
+
+ const sizeType = getSizeComponentType(entityData);
+ if (sizeType) {
+ gctx.store.updatePropertyDirect(entity, sizeType, 'size', { x: newWidth, y: newHeight });
+ }
+
+ const transform = entityData.components.find(c => c.type === 'LocalTransform');
+ if (transform) {
+ const pos = transform.data.position as { x: number; y: number; z: number };
+ gctx.store.updatePropertyDirect(entity, 'LocalTransform', 'position', {
+ x: newPosX, y: newPosY, z: pos?.z ?? 0,
+ });
+ }
+
+ gctx.requestRender();
+ },
+
+ onDragEnd(_worldX, _worldY, _hitData, gctx) {
+ const entity = gctx.store.selectedEntity;
+ if (entity === null || !dragState) { dragState = null; return; }
+
+ const entityData = gctx.store.getSelectedEntityData();
+ if (!entityData) { dragState = null; return; }
+
+ const sizeType = getSizeComponentType(entityData);
+ if (sizeType) {
+ const comp = entityData.components.find(c => c.type === sizeType)!;
+ const currentSize = comp.data.size as { x: number; y: number };
+ if (currentSize && !valuesEqual(dragState.originalSize, currentSize)) {
+ gctx.store.updateProperty(
+ entity, sizeType, 'size',
+ { ...dragState.originalSize }, { ...currentSize },
+ );
+ }
+ }
+
+ const transform = entityData.components.find(c => c.type === 'LocalTransform');
+ if (transform) {
+ const currentPos = transform.data.position as { x: number; y: number; z: number };
+ if (currentPos && !valuesEqual(dragState.originalPos, currentPos)) {
+ gctx.store.updateProperty(
+ entity, 'LocalTransform', 'position',
+ { ...dragState.originalPos }, { ...currentPos },
+ );
+ }
+ }
+
+ dragState = null;
+ activeHandle = 'none';
+ },
+
+ onHover(_worldX, _worldY, hitData, gctx) {
+ hoveredHandle = (hitData as RectHandle) ?? 'none';
+ gctx.requestRender();
+ },
+
+ getCursor(hitData) {
+ return getRectHandleCursor((hitData as RectHandle) ?? 'none');
+ },
+ };
+}
+
+// =============================================================================
+// Registration
+// =============================================================================
+
+export function registerBuiltinGizmos(): void {
+ registerGizmo(createSelectGizmo());
+ registerGizmo(createMoveGizmo());
+ registerGizmo(createRotateGizmo());
+ registerGizmo(createScaleGizmo());
+ registerGizmo(createRectGizmo());
+}
diff --git a/editor/src/gizmos/index.ts b/editor/src/gizmos/index.ts
new file mode 100644
index 000000000..041917c42
--- /dev/null
+++ b/editor/src/gizmos/index.ts
@@ -0,0 +1,10 @@
+export {
+ type GizmoContext,
+ type GizmoDescriptor,
+ registerGizmo,
+ getGizmo,
+ getAllGizmos,
+} from './GizmoRegistry';
+
+export { GizmoManager } from './GizmoManager';
+export { registerBuiltinGizmos } from './builtinGizmos';
diff --git a/editor/src/menus/MenuRegistry.ts b/editor/src/menus/MenuRegistry.ts
new file mode 100644
index 000000000..bf217c194
--- /dev/null
+++ b/editor/src/menus/MenuRegistry.ts
@@ -0,0 +1,68 @@
+export interface MenuDescriptor {
+ id: string;
+ label: string;
+ order?: number;
+}
+
+export interface MenuItemDescriptor {
+ id: string;
+ menu: string;
+ label: string;
+ icon?: string;
+ shortcut?: string;
+ separator?: boolean;
+ order?: number;
+ enabled?: () => boolean;
+ action: () => void;
+}
+
+export interface StatusbarItemDescriptor {
+ id: string;
+ position: 'left' | 'right';
+ order?: number;
+ render: (container: HTMLElement) => { dispose(): void; update?(): void };
+}
+
+const menus = new Map<string, MenuDescriptor>();
+const menuItems = new Map<string, MenuItemDescriptor[]>();
+const statusbarItems = new Map<string, StatusbarItemDescriptor>();
+
+export function registerMenu(descriptor: MenuDescriptor): void {
+ menus.set(descriptor.id, descriptor);
+ if (!menuItems.has(descriptor.id)) {
+ menuItems.set(descriptor.id, []);
+ }
+}
+
+export function registerMenuItem(item: MenuItemDescriptor): void {
+ const items = menuItems.get(item.menu);
+ if (items) {
+ items.push(item);
+ } else {
+ menuItems.set(item.menu, [item]);
+ }
+}
+
+export function registerStatusbarItem(item: StatusbarItemDescriptor): void {
+ statusbarItems.set(item.id, item);
+}
+
+export function getAllMenus(): MenuDescriptor[] {
+ return Array.from(menus.values()).sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
+}
+
+export function getMenuItems(menuId: string): MenuItemDescriptor[] {
+ return (menuItems.get(menuId) ?? []).sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
+}
+
+export function getAllStatusbarItems(): StatusbarItemDescriptor[] {
+ return Array.from(statusbarItems.values()).sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
+}
+
+export function getMenuItem(id: string): MenuItemDescriptor | undefined {
+ for (const items of menuItems.values()) {
+ const found = items.find(i => i.id === id);
+ if (found) return found;
+ }
+ return undefined;
+}
diff --git a/editor/src/menus/ShortcutManager.ts b/editor/src/menus/ShortcutManager.ts
new file mode 100644
index 000000000..1bfeb8602
--- /dev/null
+++ b/editor/src/menus/ShortcutManager.ts
@@ -0,0 +1,68 @@
+interface ShortcutBinding {
+ ctrl: boolean;
+ shift: boolean;
+ alt: boolean;
+ key: string;
+ action: () => void;
+}
+
+export class ShortcutManager {
+ private bindings_: ShortcutBinding[] = [];
+ private handler_: ((e: KeyboardEvent) => void) | null = null;
+
+ register(shortcut: string, action: () => void): () => void {
+ const binding = this.parseShortcut(shortcut, action);
+ this.bindings_.push(binding);
+ return () => {
+ const idx = this.bindings_.indexOf(binding);
+ if (idx >= 0) this.bindings_.splice(idx, 1);
+ };
+ }
+
+ attach(): void {
+ if (this.handler_) return;
+ this.handler_ = (e: KeyboardEvent) => this.handleKeyDown(e);
+ document.addEventListener('keydown', this.handler_);
+ }
+
+ detach(): void {
+ if (this.handler_) {
+ document.removeEventListener('keydown', this.handler_);
+ this.handler_ = null;
+ }
+ }
+
+ handleKeyDown(e: KeyboardEvent): boolean {
+ if (e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement) {
+ return false;
+ }
+
+ const ctrl = e.ctrlKey || e.metaKey;
+ const shift = e.shiftKey;
+ const alt = e.altKey;
+ const key = e.key.toLowerCase();
+
+ for (const binding of this.bindings_) {
+ if (binding.ctrl === ctrl &&
+ binding.shift === shift &&
+ binding.alt === alt &&
+ binding.key === key) {
+ e.preventDefault();
+ binding.action();
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private parseShortcut(shortcut: string, action: () => void): ShortcutBinding {
+ const parts = shortcut.toLowerCase().split('+').map(s => s.trim());
+ return {
+ ctrl: parts.includes('ctrl') || parts.includes('cmd'),
+ shift: parts.includes('shift'),
+ alt: parts.includes('alt'),
+ key: parts[parts.length - 1],
+ action,
+ };
+ }
+}
diff --git a/editor/src/menus/builtinStatusbar.ts b/editor/src/menus/builtinStatusbar.ts
new file mode 100644
index 000000000..11c58fd49
--- /dev/null
+++ b/editor/src/menus/builtinStatusbar.ts
@@ -0,0 +1,134 @@
+import { registerStatusbarItem } from './MenuRegistry';
+import { getPanelsByPosition } from '../panels/PanelRegistry';
+import { icons } from '../utils/icons';
+import type { Editor } from '../Editor';
+
+export function registerBuiltinStatusbarItems(editor: Editor): void {
+ const bottomPanels = getPanelsByPosition('bottom');
+
+ for (const panel of bottomPanels) {
+ const isPrimary = panel.defaultVisible;
+ registerStatusbarItem({
+ id: `toggle-${panel.id}`,
+ position: 'left',
+ order: panel.order ?? 0,
+ render: (container) => {
+ const btn = document.createElement('button');
+ btn.className = `es-statusbar-btn${isPrimary ? ' es-statusbar-btn-primary' : ''}`;
+ btn.dataset.bottomPanel = panel.id;
+ btn.innerHTML = `${panel.icon ?? ''}<span>${panel.title}</span>`;
+
+ if (isPrimary) {
+ btn.innerHTML += icons.chevronDown(10);
+ }
+
+ btn.addEventListener('click', () => editor.toggleBottomPanel(panel.id));
+ container.appendChild(btn);
+
+ return {
+ dispose() { btn.remove(); },
+ update() {
+ const isActive = editor.activeBottomPanelId === panel.id;
+ btn.classList.toggle('es-active', isActive);
+ },
+ };
+ },
+ });
+ }
+
+ registerStatusbarItem({
+ id: 'cmd-input',
+ position: 'left',
+ order: 100,
+ render: (container) => {
+ const wrapper = document.createElement('span');
+ wrapper.className = 'es-statusbar-cmd-wrapper';
+ wrapper.innerHTML = `
+ <div class="es-statusbar-divider"></div>
+ <span class="es-cmd-prompt">&gt;</span>
+ <input type="text" class="es-cmd-input" placeholder="pnpm install, npm run build..." />
+ `;
+ container.appendChild(wrapper);
+
+ const input = wrapper.querySelector('.es-cmd-input') as HTMLInputElement;
+ input?.addEventListener('keydown', (e) => {
+ if (e.key === 'Enter') {
+ const command = input.value.trim();
+ if (command) {
+ editor.executeCommand(command);
+ input.value = '';
+ }
+ }
+ });
+
+ return { dispose() { wrapper.remove(); } };
+ },
+ });
+
+ registerStatusbarItem({
+ id: 'undo',
+ position: 'right',
+ order: 0,
+ render: (container) => {
+ const btn = document.createElement('button');
+ btn.className = 'es-statusbar-btn';
+ btn.dataset.action = 'undo';
+ btn.title = 'Undo';
+ btn.innerHTML = '<span>Undo</span>';
+ btn.addEventListener('click', () => editor.store.undo());
+ container.appendChild(btn);
+
+ return { dispose() { btn.remove(); } };
+ },
+ });
+
+ registerStatusbarItem({
+ id: 'notifications',
+ position: 'right',
+ order: 10,
+ render: (container) => {
+ const wrapper = document.createElement('div');
+ wrapper.className = 'es-statusbar-icons';
+ wrapper.innerHTML = `
+ <button title="Notifications">${icons.list(12)}</button>
+ <button title="Extensions">${icons.grid(12)}</button>
+ <button title="Settings">${icons.settings(12)}</button>
+ `;
+ container.appendChild(wrapper);
+
+ return { dispose() { wrapper.remove(); } };
+ },
+ });
+
+ registerStatusbarItem({
+ id: 'save-status',
+ position: 'right',
+ order: 100,
+ render: (container) => {
+ const wrapper = document.createElement('span');
+ wrapper.innerHTML = `
+ <span class="es-status-indicator es-status-saved">
+ ${icons.check(12)}
+ <span>All Saved</span>
+ </span>
+ <div class="es-statusbar-divider"></div>
+ <span class="es-status-indicator">
+ <span>Version Control</span>
+ </span>
+ `;
+ container.appendChild(wrapper);
+
+ return {
+ dispose() { wrapper.remove(); },
+ update() {
+ const saved = wrapper.querySelector('.es-status-saved');
+ if (editor.store.isDirty) {
+ saved?.classList.add('es-hidden');
+ } else {
+ saved?.classList.remove('es-hidden');
+ }
+ },
+ };
+ },
+ });
+}
diff --git a/editor/src/menus/index.ts b/editor/src/menus/index.ts
new file mode 100644
index 000000000..19c700a96
--- /dev/null
+++ b/editor/src/menus/index.ts
@@ -0,0 +1,16 @@
+export {
+ type MenuDescriptor,
+ type MenuItemDescriptor,
+ type StatusbarItemDescriptor,
+ registerMenu,
+ registerMenuItem,
+ registerStatusbarItem,
+ getAllMenus,
+ getMenuItems,
+ getAllStatusbarItems,
+ getMenuItem,
+} from './MenuRegistry';
+
+export { ShortcutManager } from './ShortcutManager';
+export { registerBuiltinMenus } from './builtinMenus';
+export { registerBuiltinStatusbarItems } from './builtinStatusbar';
diff --git a/editor/src/panels/OutputPanel.ts b/editor/src/panels/OutputPanel.ts
new file mode 100644
index 000000000..9003b72aa
--- /dev/null
+++ b/editor/src/panels/OutputPanel.ts
@@ -0,0 +1,55 @@
+import type { PanelInstance } from './PanelRegistry';
+import { icons } from '../utils/icons';
+
+export class OutputPanel implements PanelInstance {
+ private container_: HTMLElement;
+ private contentEl_: HTMLElement | null = null;
+
+ constructor(container: HTMLElement) {
+ this.container_ = container;
+ this.render();
+ }
+
+ appendOutput(text: string, type: 'command' | 'stdout' | 'stderr' | 'error' | 'success'): void {
+ if (!this.contentEl_) return;
+
+ const empty = this.contentEl_.querySelector('.es-output-empty');
+ if (empty) empty.remove();
+
+ const line = document.createElement('div');
+ line.className = `es-output-line es-output-${type}`;
+ line.textContent = text;
+ this.contentEl_.appendChild(line);
+ this.contentEl_.scrollTop = this.contentEl_.scrollHeight;
+ }
+
+ clear(): void {
+ if (!this.contentEl_) return;
+ this.contentEl_.innerHTML = '<div class="es-output-empty">No output messages</div>';
+ }
+
+ dispose(): void {
+ this.container_.innerHTML = '';
+ }
+
+ private render(): void {
+ this.container_.innerHTML = `
+ <div class="es-output-panel">
+ <div class="es-output-header">
+ <span class="es-output-title">${icons.list(14)} Output</span>
+ <div class="es-output-actions">
+ <button class="es-btn es-btn-icon" data-action="clear-output" title="Clear">${icons.trash(12)}</button>
+ </div>
+ </div>
+ <div class="es-output-content">
+ <div class="es-output-empty">No output messages</div>
+ </div>
+ </div>
+ `;
+
+ this.contentEl_ = this.container_.querySelector('.es-output-content');
+
+ const clearBtn = this.container_.querySelector('[data-action="clear-output"]');
+ clearBtn?.addEventListener('click', () => this.clear());
+ }
+}
diff --git a/editor/src/panels/PanelRegistry.ts b/editor/src/panels/PanelRegistry.ts
new file mode 100644
index 000000000..ae47c13c1
--- /dev/null
+++ b/editor/src/panels/PanelRegistry.ts
@@ -0,0 +1,90 @@
+import type { App } from 'esengine';
+import type { EditorStore } from '../store/EditorStore';
+import type { EditorBridge } from '../bridge/EditorBridge';
+
+export type PanelPosition = 'left' | 'right' | 'center' | 'bottom';
+
+export interface PanelDescriptor {
+ id: string;
+ title: string;
+ icon?: string;
+ position: PanelPosition;
+ defaultVisible?: boolean;
+ order?: number;
+ factory: PanelFactory;
+}
+
+export type PanelFactory = (container: HTMLElement, store: EditorStore) => PanelInstance;
+
+export interface PanelInstance {
+ dispose(): void;
+ onShow?(): void;
+ onHide?(): void;
+}
+
+export interface Resizable {
+ resize(): void;
+}
+
+export interface BridgeAware {
+ setBridge(bridge: EditorBridge): void;
+}
+
+export interface AppAware {
+ setApp(app: App): void;
+}
+
+export interface AssetServerProvider {
+ readonly assetServer: unknown;
+}
+
+export interface AssetNavigable {
+ navigateToAsset(path: string): Promise<void>;
+}
+
+export interface OutputAppendable {
+ appendOutput(text: string, type: 'command' | 'stdout' | 'stderr' | 'error' | 'success'): void;
+ clear(): void;
+}
+
+export function isResizable(p: PanelInstance): p is PanelInstance & Resizable {
+ return typeof (p as any).resize === 'function';
+}
+
+export function isBridgeAware(p: PanelInstance): p is PanelInstance & BridgeAware {
+ return typeof (p as any).setBridge === 'function';
+}
+
+export function isAppAware(p: PanelInstance): p is PanelInstance & AppAware {
+ return typeof (p as any).setApp === 'function';
+}
+
+export function isAssetServerProvider(p: PanelInstance): p is PanelInstance & AssetServerProvider {
+ return 'assetServer' in p;
+}
+
+export function isAssetNavigable(p: PanelInstance): p is PanelInstance & AssetNavigable {
+ return typeof (p as any).navigateToAsset === 'function';
+}
+
+export function isOutputAppendable(p: PanelInstance): p is PanelInstance & OutputAppendable {
+ return typeof (p as any).appendOutput === 'function';
+}
+
+const panels = new Map<string, PanelDescriptor>();
+
+export function registerPanel(descriptor: PanelDescriptor): void {
+ panels.set(descriptor.id, descriptor);
+}
+
+export function getPanel(id: string): PanelDescriptor | undefined {
+ return panels.get(id);
+}
+
+export function getAllPanels(): PanelDescriptor[] {
+ return Array.from(panels.values()).sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
+}
+
+export function getPanelsByPosition(position: PanelPosition): PanelDescriptor[] {
+ return getAllPanels().filter(p => p.position === position);
+}
diff --git a/editor/src/panels/builtinPanels.ts b/editor/src/panels/builtinPanels.ts
new file mode 100644
index 000000000..f07808a82
--- /dev/null
+++ b/editor/src/panels/builtinPanels.ts
@@ -0,0 +1,66 @@
+import { registerPanel } from './PanelRegistry';
+import { HierarchyPanel } from './HierarchyPanel';
+import { InspectorPanel } from './InspectorPanel';
+import { SceneViewPanel } from './SceneViewPanel';
+import { ContentBrowserPanel } from './ContentBrowserPanel';
+import { OutputPanel } from './OutputPanel';
+import { icons } from '../utils/icons';
+
+export interface BuiltinPanelOptions {
+ projectPath?: string;
+ onOpenScene?: (path: string) => void;
+}
+
+export function registerBuiltinPanels(options: BuiltinPanelOptions): void {
+ registerPanel({
+ id: 'hierarchy',
+ title: 'Hierarchy',
+ icon: icons.list(14),
+ position: 'left',
+ order: 0,
+ defaultVisible: true,
+ factory: (c, s) => new HierarchyPanel(c, s),
+ });
+
+ registerPanel({
+ id: 'scene',
+ title: 'Scene',
+ position: 'center',
+ order: 0,
+ defaultVisible: true,
+ factory: (c, s) => new SceneViewPanel(c, s, { projectPath: options.projectPath }),
+ });
+
+ registerPanel({
+ id: 'inspector',
+ title: 'Inspector',
+ icon: icons.settings(14),
+ position: 'right',
+ order: 0,
+ defaultVisible: true,
+ factory: (c, s) => new InspectorPanel(c, s),
+ });
+
+ registerPanel({
+ id: 'content-browser',
+ title: 'Content Browser',
+ icon: icons.folder(14),
+ position: 'bottom',
+ order: 0,
+ defaultVisible: true,
+ factory: (c, s) => new ContentBrowserPanel(c, s, {
+ projectPath: options.projectPath,
+ onOpenScene: options.onOpenScene,
+ }),
+ });
+
+ registerPanel({
+ id: 'output',
+ title: 'Output',
+ icon: icons.list(14),
+ position: 'bottom',
+ order: 1,
+ defaultVisible: false,
+ factory: (c) => new OutputPanel(c),
+ });
+}
diff --git a/editor/src/panels/index.ts b/editor/src/panels/index.ts
index 89a55dee0..1a7782e8a 100644
--- a/editor/src/panels/index.ts
+++ b/editor/src/panels/index.ts
@@ -6,3 +6,28 @@
export { HierarchyPanel } from './HierarchyPanel';
export { InspectorPanel } from './InspectorPanel';
export { SceneViewPanel } from './SceneViewPanel';
+export { OutputPanel } from './OutputPanel';
+
+export {
+ type PanelPosition,
+ type PanelDescriptor,
+ type PanelFactory,
+ type PanelInstance,
+ type Resizable,
+ type BridgeAware,
+ type AppAware,
+ type AssetServerProvider,
+ type AssetNavigable,
+ type OutputAppendable,
+ registerPanel,
+ getPanel,
+ getAllPanels,
+ getPanelsByPosition,
+ isResizable,
+ isBridgeAware,
+ isAppAware,
+ isAssetServerProvider,
+ isAssetNavigable,
+ isOutputAppendable,
+} from './PanelRegistry';
+export { registerBuiltinPanels } from './builtinPanels';