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.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
feat(editor): modern-polish pass — gizmo feedback, debug toggles, select-all, status transform
esengineac0d89346bb4
diff --git a/desktop/src/commands/editorCommands.ts b/desktop/src/commands/editorCommands.tsindex e23dd0a98..54a77abe4 100644--- a/desktop/src/commands/editorCommands.ts+++ b/desktop/src/commands/editorCommands.ts@@ -163,6 +163,17 @@ commands.register({if (roots.length > 0) sel().selectMany(roots, roots[0]);},});+commands.register({+ id: 'edit.selectAll',+ label: 'Select All',+ category: 'Edit',+ keybinding: 'mod+a',+ isEnabled: () => SceneModel.entityOrder().length > 0,+ run: () => {+ const ids = SceneModel.entityOrder();+ if (ids.length) sel().selectMany(ids, ids[ids.length - 1]);+ },+});commands.register({id: 'entity.deselect',label: 'Deselect',@@ -239,6 +250,13 @@ commands.register({isChecked: () => editor().showGizmos,run: () => editor().toggleGizmos(),});+commands.register({+ id: 'view.toggleColliders',+ label: 'Show Colliders',+ category: 'View',+ isChecked: () => editor().showColliders,+ run: () => editor().toggleColliders(),+});commands.register({id: 'view.toggleSnapping',label: 'Snapping',diff --git a/desktop/src/engine/StatsStore.ts b/desktop/src/engine/StatsStore.tsindex 2ece658ad..5b9847bce 100644--- a/desktop/src/engine/StatsStore.ts+++ b/desktop/src/engine/StatsStore.ts@@ -2,18 +2,48 @@// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Teamimport { createStore } from 'zustand/vanilla';import { EngineHost } from './EngineHost';+import { SceneModel } from './SceneModel';+import { useSelection } from '@/store/selectionStore';++/** The lone-selected entity's transform for the status bar (rot in degrees). */+export interface SelTransform {+ x: number;+ y: number;+ rot: number;+}export interface StatsSnapshot {fps: number;entities: number;cursor: { x: number; y: number } | null;+ /** The transform of the single selected entity, or null (0 or >1 selected). */+ selection: SelTransform | null;+}++const round1 = (n: number) => Math.round(n * 10) / 10;++/** Sample the lone selection's transform from the model, or null. */+function sampleSelection(): SelTransform | null {+ const sel = useSelection.getState();+ if (sel.selectedIds.size !== 1 || sel.selectedId == null) return null;+ const e = SceneModel.entityBySource(sel.selectedId);+ const tf = e?.components.find((c) => c.type === 'Transform')?.data as+ | { position?: { x: number; y: number }; rotation?: { w: number; z: number } }+ | undefined;+ if (!tf?.position) return null;+ // 2D rotation lives on Z; recover the angle from the (w, z) quaternion.+ const rot = tf.rotation ? 2 * Math.atan2(tf.rotation.z, tf.rotation.w) * (180 / Math.PI) : 0;+ return { x: round1(tf.position.x), y: round1(tf.position.y), rot: round1(rot) };}+const selEq = (a: SelTransform | null, b: SelTransform | null): boolean =>+ a === b || (!!a && !!b && a.x === b.x && a.y === b.y && a.rot === b.rot);+// Live editor telemetry for the status bar: real FPS (measured here), live// entity count, and the viewport cursor's world position. Updated a few times// a second (not per frame) to avoid churning the status bar.class StatsStoreImpl {- private readonly store = createStore<StatsSnapshot>(() => ({ fps: 0, entities: 0, cursor: null }));+ private readonly store = createStore<StatsSnapshot>(() => ({ fps: 0, entities: 0, cursor: null, selection: null }));private running = false;private frames = 0;@@ -35,8 +65,9 @@ class StatsStoreImpl {this.frames = 0;this.windowStart = t;const cur = this.store.getState();- if (fps !== cur.fps || entities !== cur.entities) {- this.store.setState({ fps, entities });+ const selection = sampleSelection();+ if (fps !== cur.fps || entities !== cur.entities || !selEq(selection, cur.selection)) {+ this.store.setState({ fps, entities, selection });}}};diff --git a/desktop/src/layout/DockLayout.tsx b/desktop/src/layout/DockLayout.tsxindex 6267d7690..5d369ed49 100644--- a/desktop/src/layout/DockLayout.tsx+++ b/desktop/src/layout/DockLayout.tsx@@ -51,7 +51,7 @@ function buildDefaultLayout(api: DockviewReadyEvent['api']) {component: 'outliner',title: 'World Outliner',position: { referencePanel: 'viewport', direction: 'right' },- initialWidth: 340,+ initialWidth: 366, // --w-rightdock});api.addPanel({@@ -66,7 +66,7 @@ function buildDefaultLayout(api: DockviewReadyEvent['api']) {component: 'content',title: 'Content Browser',position: { referencePanel: 'viewport', direction: 'below' },- initialHeight: 240,+ initialHeight: 300,});// Output Log shares the bottom group as a sibling tab of the Content Browser.diff --git a/desktop/src/layout/MenuBar.tsx b/desktop/src/layout/MenuBar.tsxindex 215f70461..7d9d22c32 100644--- a/desktop/src/layout/MenuBar.tsx+++ b/desktop/src/layout/MenuBar.tsx@@ -99,6 +99,10 @@ export function MenuBar() {cmdItem('entity.cut'),cmdItem('entity.copy'),cmdItem('entity.paste'),+ cmdItem('entity.delete'),+ { sep: true },+ cmdItem('edit.selectAll'),+ cmdItem('entity.deselect'),],},{@@ -117,6 +121,7 @@ export function MenuBar() {items: [cmdItem('view.toggleGrid'),cmdItem('view.toggleGizmos'),+ cmdItem('view.toggleColliders'),cmdItem('view.toggleSnapping'),],},diff --git a/desktop/src/layout/StatusBar.tsx b/desktop/src/layout/StatusBar.tsxindex 96d24f1f9..2f32ded68 100644--- a/desktop/src/layout/StatusBar.tsx+++ b/desktop/src/layout/StatusBar.tsx@@ -36,6 +36,12 @@ export function StatusBar() {<span className="sitem">{selectedIds.size ? `${selectedIds.size} selected` : 'No selection'}</span>+ {stats.selection && (+ <span className="sitem mono" title="Selected transform (X, Y · rotation)">+ {stats.selection.x}, {stats.selection.y}+ <span className="smute"> · {stats.selection.rot}°</span>+ </span>+ )}</div><span className="sp" />diff --git a/desktop/src/panels/Viewport.tsx b/desktop/src/panels/Viewport.tsxindex bcb97d8c6..1925f360f 100644--- a/desktop/src/panels/Viewport.tsx+++ b/desktop/src/panels/Viewport.tsx@@ -21,7 +21,7 @@ import { StatsStore } from '@/engine/StatsStore';import type { ToolMode } from '@/types';import { resolveActiveTool, type EditorTool, type ToolContext, type PointerInput } from '@/tools';import { cursorTile } from '@/tools/tileTools';-import { GIZMO } from '@/tools/gizmo';+import { GIZMO, type GizmoAxis } from '@/tools/gizmo';import { Marquee } from '@/tools/marquee';// A React pointer event → the tool-facing PointerInput (no DOM coupling in tools).@@ -35,14 +35,22 @@ const toInput = (e: ReactPointerEvent): PointerInput => ({// gizmo.ts (GIZMO constants) so the handles a user aims at are the handles the tool// hit-tests. Screen y is down, so the world +Y handle points up (negative y). Only// move/rotate/scale render a gizmo; the select tool shows just the selection outline.-function GizmoOverlay({ tool }: { tool: ToolMode }) {+function GizmoOverlay({ tool, active }: { tool: ToolMode; active: GizmoAxis | null }) {const L = GIZMO.axisLen;const B = GIZMO.boxSize;const P = GIZMO.planeSize;+ // The grabbed handle reads "hot": a thicker stroke + full-opacity fill, so the+ // drag has the visual confirmation UE/Unity give. Axes light independently; the+ // center plane lights on the 'xy' (uniform) handle.+ const onX = active === 'x';+ const onY = active === 'y';+ const onXY = active === 'xy';+ const axW = (on: boolean) => (on ? 4 : 2.5);+ const planeOp = (on: boolean) => (on ? 1 : 0.85);if (tool === 'rotate') {return (<svg className="gizmo-svg" width="0" height="0" overflow="visible">- <circle cx="0" cy="0" r={GIZMO.ringRadius} fill="none" stroke="var(--run)" strokeWidth="2" />+ <circle cx="0" cy="0" r={GIZMO.ringRadius} fill="none" stroke="var(--run)" strokeWidth={active ? 3.5 : 2} /><circle cx="0" cy="0" r="2.5" fill="var(--star)" /></svg>);@@ -50,22 +58,22 @@ function GizmoOverlay({ tool }: { tool: ToolMode }) {if (tool === 'scale') {return (<svg className="gizmo-svg" width="0" height="0" overflow="visible">- <line x1="0" y1="0" x2={L} y2="0" stroke="var(--error)" strokeWidth="2.5" />- <rect x={L - B / 2} y={-B / 2} width={B} height={B} fill="var(--error)" />- <line x1="0" y1="0" x2="0" y2={-L} stroke="var(--run)" strokeWidth="2.5" />- <rect x={-B / 2} y={-L - B / 2} width={B} height={B} fill="var(--run)" />- <rect x={-P / 2} y={-P / 2} width={P} height={P} fill="var(--star)" opacity="0.85" />+ <line x1="0" y1="0" x2={L} y2="0" stroke="var(--error)" strokeWidth={axW(onX)} />+ <rect x={L - B / 2} y={-B / 2} width={B} height={B} fill="var(--error)" opacity={onX ? 1 : 0.95} />+ <line x1="0" y1="0" x2="0" y2={-L} stroke="var(--run)" strokeWidth={axW(onY)} />+ <rect x={-B / 2} y={-L - B / 2} width={B} height={B} fill="var(--run)" opacity={onY ? 1 : 0.95} />+ <rect x={-P / 2} y={-P / 2} width={P} height={P} fill="var(--star)" opacity={planeOp(onXY)} /></svg>);}// move (and any other) → axis arrows + a center plane squarereturn (<svg className="gizmo-svg" width="0" height="0" overflow="visible">- <line x1="0" y1="0" x2={L} y2="0" stroke="var(--error)" strokeWidth="2.5" />- <path d={`M${L} 0 L${L - 9} -4 L${L - 9} 4 Z`} fill="var(--error)" />- <line x1="0" y1="0" x2="0" y2={-L} stroke="var(--run)" strokeWidth="2.5" />- <path d={`M0 ${-L} L-4 ${-L + 9} L4 ${-L + 9} Z`} fill="var(--run)" />- <rect x={-P / 2} y={-P / 2} width={P} height={P} fill="var(--star)" opacity="0.85" />+ <line x1="0" y1="0" x2={L} y2="0" stroke="var(--error)" strokeWidth={axW(onX)} />+ <path d={`M${L} 0 L${L - 9} -4 L${L - 9} 4 Z`} fill="var(--error)" opacity={onX ? 1 : 0.95} />+ <line x1="0" y1="0" x2="0" y2={-L} stroke="var(--run)" strokeWidth={axW(onY)} />+ <path d={`M0 ${-L} L-4 ${-L + 9} L4 ${-L + 9} Z`} fill="var(--run)" opacity={onY ? 1 : 0.95} />+ <rect x={-P / 2} y={-P / 2} width={P} height={P} fill="var(--star)" opacity={planeOp(onXY)} /></svg>);}@@ -193,6 +201,8 @@ export function Viewport() {const tool = useEditorStore((s) => s.tool);const showGrid = useEditorStore((s) => s.showGrid);const showGizmos = useEditorStore((s) => s.showGizmos);+ const showColliders = useEditorStore((s) => s.showColliders);+ const activeGizmoAxis = useEditorStore((s) => s.activeGizmoAxis);const snapping = useEditorStore((s) => s.snapping);const snapStep = useEditorStore((s) => s.snapStep);const snapAngle = useEditorStore((s) => s.snapAngle);@@ -248,8 +258,8 @@ export function Viewport() {// circle) as a gizmo so you can see/tune collider shapes without entering Play.const colliderRefs = useRef(new Map<number, SVGSVGElement | null>());const colliderIds = useMemo(- () => (engine.status === 'ready' ? ViewportController.colliderIds() : []),- [structRev, engine.status],+ () => (engine.status === 'ready' && showColliders ? ViewportController.colliderIds() : []),+ [structRev, engine.status, showColliders],);// Mount the live engine canvas into the stage; it survives panel re-docking.@@ -615,6 +625,7 @@ export function Viewport() {<div className="dd-lbl">Show Flags</div><DdCheck on={showGrid} label="Grid" onClick={() => commands.run('view.toggleGrid')} /><DdCheck on={showGizmos} label="Gizmos" onClick={() => commands.run('view.toggleGizmos')} />+ <DdCheck on={showColliders} label="Colliders" onClick={() => commands.run('view.toggleColliders')} /></OvDropdown><span className="ov-divider" /><OvTool icon={Frame} label="Frame Selected (F)" kbd="F" onClick={() => commands.run('view.frameSelected')} />@@ -779,7 +790,7 @@ export function Viewport() {<div ref={tilePreviewRef} className="viewport__tilepreview" aria-hidden="true" /><div ref={gizmoRef} className="viewport__gizmo" aria-hidden="true">- <GizmoOverlay tool={tool} />+ <GizmoOverlay tool={tool} active={activeGizmoAxis} /></div>{engine.status !== 'ready' && (diff --git a/desktop/src/store/editorStore.ts b/desktop/src/store/editorStore.tsindex eb18826a3..3ae8645d2 100644--- a/desktop/src/store/editorStore.ts+++ b/desktop/src/store/editorStore.ts@@ -2,6 +2,7 @@// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Teamimport { create } from 'zustand';import type { ToolMode } from '@/types';+import type { GizmoAxis } from '@/tools/gizmo';// Global editor UI state (tools, viewport toggles, play state, launcher gate).// Entity selection lives in its own engine-anchored store — see selectionStore.ts;@@ -34,6 +35,8 @@ interface EditorState {// Viewport overlays.showGrid: boolean;showGizmos: boolean;+ /** Draw collider outlines in the viewport (off declutters a physics-heavy scene). */+ showColliders: boolean;snapping: boolean;// Grid-snap increment (world units) applied to Move while `snapping` is on. The// viewport snap dropdown picks from a fixed set (16 / 32 / 64); "off" flips@@ -44,8 +47,13 @@ interface EditorState {// 15° / 0.1 constants so they're user-tunable from the viewport snap menu.snapAngle: number;snapScale: number;+ /** Axis of the gizmo handle currently being dragged (null = none) — drives the+ * handle's active highlight. Set by the transform tool on grab, cleared on release. */+ activeGizmoAxis: GizmoAxis | null;+ setActiveGizmoAxis: (axis: GizmoAxis | null) => void;toggleGrid: () => void;toggleGizmos: () => void;+ toggleColliders: () => void;toggleSnapping: () => void;setSnapStep: (step: number) => void;setSnapAngle: (deg: number) => void;@@ -95,12 +103,16 @@ export const useEditorStore = create<EditorState>((set) => ({showGrid: true,showGizmos: true,+ showColliders: true,snapping: false,snapStep: 32,snapAngle: 15,snapScale: 0.1,+ activeGizmoAxis: null,+ setActiveGizmoAxis: (activeGizmoAxis) => set({ activeGizmoAxis }),toggleGrid: () => set((s) => ({ showGrid: !s.showGrid })),toggleGizmos: () => set((s) => ({ showGizmos: !s.showGizmos })),+ toggleColliders: () => set((s) => ({ showColliders: !s.showColliders })),toggleSnapping: () => set((s) => ({ snapping: !s.snapping })),setSnapStep: (snapStep) => set({ snapStep, snapping: true }),setSnapAngle: (snapAngle) => set({ snapAngle }),diff --git a/desktop/src/tools/transformTools.ts b/desktop/src/tools/transformTools.tsindex c8725c195..320904947 100644--- a/desktop/src/tools/transformTools.ts+++ b/desktop/src/tools/transformTools.ts@@ -216,6 +216,7 @@ function makeTransformTool(mode: ToolMode): EditorTool {const handle = hitTestGizmo(mode as GizmoMode, pc, cur);if (handle) {drag = beginDrag(kind, handle.axis, captureTargets(ids), pivotWorld, pc, p, cur);+ ed.setActiveGizmoAxis(handle.axis); // light up the grabbed handlectx.capture(p.pointerId);return true;}@@ -288,6 +289,7 @@ function makeTransformTool(mode: ToolMode): EditorTool {if (drag) {drag.tx.commit();drag = null;+ useEditorStore.getState().setActiveGizmoAxis(null);return;}if (marquee) {@@ -320,6 +322,7 @@ function makeTransformTool(mode: ToolMode): EditorTool {if (drag) {drag.tx.abort();drag = null;+ useEditorStore.getState().setActiveGizmoAxis(null);}Marquee.set(null);marquee = null;