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
docs: The Editor guide (en + zh)
esengine7f98ba89e7ce
diff --git a/docs/astro/astro.config.mjs b/docs/astro/astro.config.mjsindex 7f66400ea..90298b7a8 100644--- a/docs/astro/astro.config.mjs+++ b/docs/astro/astro.config.mjs@@ -33,6 +33,7 @@ export default defineConfig({{ label: 'Introduction', translations: { 'zh-CN': '简介' }, slug: 'getting-started/introduction' },{ label: 'Installation', translations: { 'zh-CN': '安装' }, slug: 'getting-started/installation' },{ label: 'Quick Start', translations: { 'zh-CN': '快速上手' }, slug: 'getting-started/quick-start' },+ { label: 'The Editor', translations: { 'zh-CN': '编辑器' }, slug: 'guides/editor' },],},{diff --git a/docs/astro/src/content/docs/guides/editor.mdx b/docs/astro/src/content/docs/guides/editor.mdxnew file mode 100644index 000000000..f94fd0205--- /dev/null+++ b/docs/astro/src/content/docs/guides/editor.mdx@@ -0,0 +1,218 @@+---+title: The Editor+description: A tour of the Estella editor — the docked workspace, the viewport and its transform gizmos, building scenes with the Outliner and Details panels, the Content Browser, play-in-editor, the specialized asset editors, and project settings.+---++import { Aside } from '@astrojs/starlight/components';++The Estella editor is a desktop application (Electron + React) with a UE5-style+**dockable workspace**. You build scenes visually, tune components in an inspector,+paint tilemaps, wire node graphs, and **play the game right inside the editor** — in+an isolated runtime realm, so play never dirties your scene.++## Launching a project++When no project is open, the editor shows the **Launcher**:++- **Recent** — reopen a project you've worked on, with search and grid/list views.+- **New project** — pick a template, give it a name and location, and create it.++A project is a folder on disk. The pieces the editor cares about:++| Path | What it is |+|---|---|+| `project.esproject` | The project manifest — name, default scene, design resolution, enabled features (physics, rendering), packaging. Committed to version control. |+| `.esengine/workspace.json` | Editor-local state (last-opened scene, panel layout). Gitignored. |+| `assets/scenes/*.esscene` | Your scenes. |+| `assets/…` | Textures, materials, tilesets, and other assets, each with a `.meta` sidecar. |+| `src/components.ts` | Where you declare your project's components and behaviors. |+| `src/main.ts` | The startup entry — where you register systems. |++Assets are referenced portably by UUID (`@uuid:…`) rather than by path, so moving or+renaming a file doesn't break references.++## The workspace++The default layout, from the outside in:++- **Activity Bar** — the far-left icon rail (open side panels, project settings).+- **Menu Bar** — File · Edit · Entity · View · Build · Window · Help.+- **Toolbar** — Save, Undo/Redo, the transform tools, snapping, Show Grid, the **Play**+ controls, Show Gizmos, and Build.+- **Viewport** (center) — the live WebGL scene view.+- **World Outliner** (right) — the scene's entity hierarchy.+- **Details** (right) — the inspector for the current selection.+- **Content Browser** + **Output Log** (bottom tabs).+- **Status Bar** — edit mode, selection, cursor, FPS, draw calls, and the engine version.++Panels are dockable — drag a tab to re-arrange, split, or float it, and the layout is+saved automatically. You can also summon the Content Browser as a slide-up overlay+from anywhere with **Ctrl / ⌘ + Space** (the *Content Drawer*).++<Aside type="note">+ Play runs in a **separate realm** from the scene you're editing, so a running game+ can't mutate your edit-mode world. Stopping returns you to exactly the scene you had.+</Aside>++## The viewport++The viewport is where you place and manipulate entities.++**Navigation**++- **Pan** — drag with the middle or right mouse button.+- **Zoom** — scroll the mouse wheel (zooms toward the cursor).+- **Frame Selected** — press **F** to center and fit the selection.++**Selecting**++- **Click** an entity to select it; **Shift-click** to toggle it in a multi-selection.+- Drag on **empty space** to **marquee** box-select everything inside.+- Press **Esc** to cancel an in-progress drag, then to clear the selection.++**Transforming** — pick a tool from the toolbar (or its shortcut) and drag a gizmo+handle:++| Tool | Shortcut | Gizmo |+|---|---|---|+| Select | `Q` | Pick / marquee only, no transform handles. |+| Move | `W` | Axis arrows (X / Y) plus a center plane for free move. |+| Rotate | `E` | A rotation ring. |+| Scale | `R` | Axis boxes plus a uniform-scale center. |++Dragging a handle transforms the whole selection as one, about a shared pivot, and+each drag is a single undo step. **Alt-drag** a selection to duplicate it and drag the+copies. Nudge the selection with the **arrow keys** (one grid step; hold **Shift** for+×10).++**Snapping** — toggle snapping from the viewport's Snap dropdown and set the grid step,+rotation angle, and scale increment.++**Show Flags** — a viewport dropdown toggles the Grid, Gizmos, Colliders, and the perf+overlay, plus World/Local axis orientation and Pivot-vs-Center. Entities that don't+render — Cameras, `Light2D`, and colliders — are drawn as gizmos in edit mode (icon,+view rect, light reach/cone, collider outline) so you can see and place them.++## Building a scene++### Creating entities++There are several ways to add an entity:++- **Entity → Add Entity** (or the toolbar) drops a blank Transform entity.+- **Create…** opens a command-palette of entity templates: **Basic** (Empty), **2D**+ (Sprite, Camera, Particles, Light), and **UI** (Canvas plus the built-in UI widgets).+- **Right-click in the Outliner** for the same actions in context, plus folders,+ parenting, and prefab creation.+- **Drag from the Content Browser** — drop an image to spawn a Sprite, or a `.esprefab`+ to instantiate it.++### The World Outliner++The Outliner is the scene's hierarchy. You can:++- Reparent by dragging entities onto one another, and organize with **folders**.+- **Rename** with `F2`, **Duplicate** with Ctrl/⌘ + D, **Delete** with Delete.+- **Hide/Show** and **Lock/Unlock** entities (independent of whether the component is+ enabled at runtime).+- **Create Prefab** from a selection, then drop instances back into the scene.++### The Details panel++Details is the inspector for the selection. It lists every component on the entity and+its fields — driven by the engine's reflection metadata, so ranges, units, enums, and+tooltips come straight from the component definition. Add components, edit values, and+they're written back to the scene live. Details also serves as the **asset inspector**:+select an asset in the Content Browser to edit its import settings or, for a material,+its parameters.++## The Content Browser++The Content Browser is your project's asset explorer. Its **create** menu makes new+assets in place:++- New Scene, New Animation, New Input Map, New Material, New Material Graph,+ New State Machine, New Behavior Tree, New Folder.+- Context actions per asset type: **Create Tileset** (from a texture), **Create+ Tilemap** (from a tileset), **Create Material Instance** (from a material).++**Import** by dragging files in from Finder / Explorer, or via Import…. Each asset gets+a `.meta` sidecar the first time it's seen. Per-asset context actions include Rename,+Duplicate, Copy Path, Copy Reference, Show in Explorer, and Delete.++## Play-in-editor++The **Play** controls in the toolbar run your game:++- **Play** starts the game (the button becomes **Restart** while running); **Pause**+ and **Stop** do what they say.+- The play-mode dropdown chooses **Play In Viewport** (the game hosts over the viewport)+ or **Play In New Window** (a dedicated **Game** tab).+- Shortcuts: **F5** to play/toggle, **Esc** to stop.++Because play uses an isolated realm — the same runtime that ships your game — what you+see in play is what a player gets.++## Specialized editors++Double-click an asset in the Content Browser to open its editor in a document tab.++- **Sequencer** — a timeline / curve editor for keyframe animation. See+ [Timeline](/docs/guides/timeline/).+- **Tilemap painter** — tools for **brush, erase, rectangle, line, bucket, select,+ eyedropper**, and **terrain (autotile)**, plus stamp **flip-H / flip-V / rotate-90°**+ (`H` / `V` / `R` while a paint tool is active). See [Tilemaps](/docs/guides/tilemap/).+- **Tileset editor** — mark per-tile **collision** (box or polygon) and **terrain**+ membership for autotiling.+- **State Machine** (`.esfsm`) and **Behavior Tree** (`.esbt`) editors — visual graphs+ for AI. See [Gameplay AI](/docs/guides/ai/).+- **Material Graph** (`.esmatgraph`) — a node editor that compiles to a shader. See+ [Materials & Shaders](/docs/guides/material/).++The State Machine and Behavior Tree editors share a common node canvas: **middle-drag**+to pan, **wheel** to zoom toward the cursor, drag an output handle onto another node to+connect them, click to select a node or edge, **Delete** to remove it, and right-click+the canvas to add a node at the cursor.++## Project settings++Open settings with **Ctrl / ⌘ + ,** or the Activity Bar's gear. Settings are grouped:++- **Editor** — Appearance (accent color, UI scale), Viewport (grid, snapping, gizmos),+ **Keyboard Shortcuts** (every shortcut below is rebindable here), and Console.+- **Project** (saved into `project.esproject`):+ - **Physics** — enable, gravity, sixteen collision-layer names and a 16×16 collision+ matrix, plus solver tuning (fixed timestep, sub-steps, contact Hz/damping/push+ speed, sleeping, continuous collision). See [Physics](/docs/guides/physics/).+ - **Rendering** — named sorting layers that populate the inspector's layer dropdown.+ - **Packaging** — per-platform settings for WeChat, Desktop, and Playable exports.++## Keyboard shortcuts++`mod` is **⌘** on macOS and **Ctrl** elsewhere. All of these are rebindable under+Settings → Keyboard Shortcuts.++| Action | Shortcut |+|---|---|+| New Scene | `mod + N` |+| Open Project | `mod + O` |+| Save Scene | `mod + S` |+| Save Scene As | `mod + shift + S` |+| Undo / Redo | `mod + Z` / `mod + shift + Z` |+| Duplicate | `mod + D` |+| Copy / Cut / Paste | `mod + C` / `mod + X` / `mod + V` |+| Delete | `Delete` / `Backspace` |+| Select All | `mod + A` |+| Select / Move / Rotate / Scale tool | `Q` / `W` / `E` / `R` |+| Nudge selection (×10 with Shift) | Arrow keys |+| Frame Selected | `F` |+| Play / toggle · Stop | `F5` · `Esc` |+| Content Drawer | `Ctrl + Space` |+| Project Settings | `mod + ,` |++<Aside type="tip">+ For headless automation and AI agents, the editor also exposes an+ `EditorControlSurface` (load a scene, step the sim, read the scene tree/inspector,+ capture the viewport) over an MCP server — a developer/automation surface driven from+ scripts, separate from the visual editor above.+</Aside>diff --git a/docs/astro/src/content/docs/zh-cn/guides/editor.mdx b/docs/astro/src/content/docs/zh-cn/guides/editor.mdxnew file mode 100644index 000000000..8d887463d--- /dev/null+++ b/docs/astro/src/content/docs/zh-cn/guides/editor.mdx@@ -0,0 +1,190 @@+---+title: 编辑器+description: Estella 编辑器导览——可停靠工作区、视口与变换 gizmo、用 Outliner 和 Details 搭场景、内容浏览器、编辑器内运行、各专用资产编辑器,以及项目设置。+---++import { Aside } from '@astrojs/starlight/components';++Estella 编辑器是一个桌面应用(Electron + React),带 UE5 风格的**可停靠工作区**。你可视化地搭+场景、在检视器里调组件、绘制瓦片地图、连节点图,并**直接在编辑器里运行游戏**——在一个隔离的+运行时 realm 里,所以运行永远不会弄脏你的场景。++## 启动项目++没有项目打开时,编辑器显示 **启动器(Launcher)**:++- **最近** — 重新打开你做过的项目,带搜索和网格/列表视图。+- **新建项目** — 选一个模板,起名字、选位置,创建。++一个项目就是磁盘上的一个文件夹。编辑器关心的几块:++| 路径 | 是什么 |+|---|---|+| `project.esproject` | 项目清单——名字、默认场景、设计分辨率、启用的特性(物理、渲染)、打包。纳入版本控制。 |+| `.esengine/workspace.json` | 编辑器本地状态(上次打开的场景、面板布局)。被 gitignore。 |+| `assets/scenes/*.esscene` | 你的场景。 |+| `assets/…` | 纹理、材质、瓦片集等资产,每个带一个 `.meta` 边车文件。 |+| `src/components.ts` | 声明项目组件与行为的地方。 |+| `src/main.ts` | 启动入口——注册系统的地方。 |++资产按 UUID(`@uuid:…`)可移植地引用,而不是按路径,所以移动或重命名文件不会断掉引用。++## 工作区++从外到内的默认布局:++- **活动栏(Activity Bar)** — 最左侧的图标竖条(打开侧面板、项目设置)。+- **菜单栏** — 文件 · 编辑 · 实体 · 视图 · 构建 · 窗口 · 帮助。+- **工具栏** — 保存、撤销/重做、各变换工具、吸附、显示网格、**运行**控制、显示 gizmo、构建。+- **视口**(中央) — 实时 WebGL 场景视图。+- **World Outliner**(右) — 场景的实体层级。+- **Details**(右) — 当前选中项的检视器。+- **内容浏览器** + **输出日志**(底部标签)。+- **状态栏** — 编辑模式、选中项、光标、FPS、draw calls、引擎版本。++面板可停靠——拖动标签即可重排、拆分或浮动,布局会自动保存。你也能用 **Ctrl / ⌘ + Space** 从任+何地方把内容浏览器唤成上滑浮层(*内容抽屉*)。++<Aside type="note">+ 运行发生在与你正在编辑的场景**分离的 realm** 里,所以运行中的游戏无法改动你的编辑态世界。+ 停止后回到你原本那个场景,分毫不差。+</Aside>++## 视口++视口是你摆放和操作实体的地方。++**导航**++- **平移** — 按住鼠标中键或右键拖动。+- **缩放** — 滚动滚轮(朝光标缩放)。+- **聚焦选中** — 按 **F** 把选中项居中并适配。++**选择**++- **点击**实体选中;**Shift 点击**在多选里切换它。+- 在**空白处**拖动,**框选(marquee)**框内所有实体。+- 按 **Esc** 取消正在进行的拖动,再按清空选择。++**变换** — 从工具栏(或用快捷键)选一个工具,拖动 gizmo 手柄:++| 工具 | 快捷键 | Gizmo |+|---|---|---|+| 选择 | `Q` | 只做拾取/框选,无变换手柄。 |+| 移动 | `W` | 轴向箭头(X / Y)加一个自由移动的中心面。 |+| 旋转 | `E` | 一个旋转环。 |+| 缩放 | `R` | 轴向方块加一个等比缩放中心。 |++拖动手柄会把整个选择当作一体、绕共享轴心变换,每次拖动是一步撤销。**Alt 拖动**选择可复制它并+拖动副本。用**方向键**微移选择(一格;按 **Shift** 为 ×10)。++**吸附** — 从视口的吸附下拉里开关吸附,并设置网格步长、旋转角度和缩放增量。++**显示标志(Show Flags)** — 视口下拉可开关网格、gizmo、碰撞体和性能浮层,以及世界/本地轴朝向+和轴心/中心。不渲染的实体——相机、`Light2D`、碰撞体——在编辑模式下画成 gizmo(图标、视野矩形、+光照范围/锥、碰撞体轮廓),让你能看见并摆放它们。++## 搭建场景++### 创建实体++有好几种加实体的方式:++- **实体 → 添加实体**(或工具栏)放下一个空白 Transform 实体。+- **创建…** 打开一个实体模板的命令面板:**基础**(空)、**2D**(精灵、相机、粒子、光)、+ **UI**(画布加内置 UI 控件)。+- **在 Outliner 里右键**在上下文里做同样的事,外加文件夹、父子关系和预制体创建。+- **从内容浏览器拖拽** — 拖一张图生成精灵,或拖一个 `.esprefab` 实例化它。++### World Outliner++Outliner 是场景的层级。你可以:++- 把实体拖到彼此上重设父子,并用**文件夹**归类。+- 用 `F2` **重命名**、`mod + D` **复制**、`Delete` **删除**。+- **隐藏/显示**和**锁定/解锁**实体(与组件在运行时是否 enabled 解耦)。+- 从选择**创建预制体**,再把实例拖回场景。++### Details 面板++Details 是选中项的检视器。它列出实体上的每个组件及其字段——由引擎的反射元数据驱动,所以范围、+单位、枚举和 tooltip 都直接来自组件定义。加组件、改值,都会实时写回场景。Details 同时是**资产+检视器**:在内容浏览器里选中一个资产,即可编辑其导入设置,或(对材质)编辑其参数。++## 内容浏览器++内容浏览器是你项目的资产浏览器。它的**创建**菜单就地新建资产:++- 新建场景、新建动画、新建输入映射、新建材质、新建材质图、新建状态机、新建行为树、新建文件夹。+- 按资产类型的上下文动作:**创建瓦片集**(从纹理)、**创建瓦片地图**(从瓦片集)、+ **创建材质实例**(从材质)。++**导入**可从访达/资源管理器把文件拖进来,或用"导入…"。每个资产首次出现时会得到一个 `.meta`+边车。按资产的上下文动作包括重命名、复制、复制路径、复制引用、在文件管理器中显示、删除。++## 编辑器内运行++工具栏里的**运行**控制驱动你的游戏:++- **运行**启动游戏(运行时按钮变成**重启**);**暂停**和**停止**如其名。+- 运行模式下拉选择**在视口中运行**(游戏托管在视口上)或**在新窗口运行**(专门的 **Game** 标签)。+- 快捷键:**F5** 运行/切换,**Esc** 停止。++因为运行用的是隔离 realm——正是发布你游戏的那套运行时——你在运行里看到的,就是玩家会得到的。++## 专用编辑器++在内容浏览器里双击一个资产,即可在文档标签里打开它的编辑器。++- **Sequencer** — 关键帧动画的时间轴/曲线编辑器。见 [时间轴](/docs/zh-cn/guides/timeline/)。+- **瓦片地图画笔** — **画笔、擦除、矩形、直线、油漆桶、选区、吸管**和**地形(autotile)**等工具,+ 外加图章 **水平翻转 / 垂直翻转 / 旋转 90°**(画笔工具激活时按 `H` / `V` / `R`)。见+ [瓦片地图](/docs/zh-cn/guides/tilemap/)。+- **瓦片集编辑器** — 标记每瓦片的**碰撞**(盒或多边形)和**地形**归属以做 autotile。+- **状态机**(`.esfsm`)和**行为树**(`.esbt`)编辑器 — AI 的可视化图。见+ [游戏 AI](/docs/zh-cn/guides/ai/)。+- **材质图**(`.esmatgraph`) — 编译成着色器的节点编辑器。见+ [材质与着色器](/docs/zh-cn/guides/material/)。++状态机和行为树编辑器共享一块公共节点画布:**中键拖动**平移,**滚轮**朝光标缩放,把一个输出手柄+拖到另一个节点上连线,点击选中节点或边,**Delete** 删除,右键画布在光标处添加节点。++## 项目设置++用 **Ctrl / ⌘ + ,** 或活动栏的齿轮打开设置。设置分组:++- **编辑器** — 外观(强调色、UI 缩放)、视口(网格、吸附、gizmo)、**键盘快捷键**(下面每个快捷键+ 都能在这里重绑)、控制台。+- **项目**(存进 `project.esproject`):+ - **物理** — 启用、重力、十六个碰撞层名字和一个 16×16 碰撞矩阵,以及解算器调参(固定时间步、+ 子步、接触 Hz/阻尼/推出速度、允许睡眠、连续碰撞)。见 [物理](/docs/zh-cn/guides/physics/)。+ - **渲染** — 命名排序层,填充检视器里的层下拉。+ - **打包** — 微信、桌面、Playable 导出的每平台设置。++## 键盘快捷键++`mod` 在 macOS 上是 **⌘**,其他平台是 **Ctrl**。以下全部可在设置 → 键盘快捷键里重绑。++| 动作 | 快捷键 |+|---|---|+| 新建场景 | `mod + N` |+| 打开项目 | `mod + O` |+| 保存场景 | `mod + S` |+| 场景另存为 | `mod + shift + S` |+| 撤销 / 重做 | `mod + Z` / `mod + shift + Z` |+| 复制(duplicate) | `mod + D` |+| 拷贝 / 剪切 / 粘贴 | `mod + C` / `mod + X` / `mod + V` |+| 删除 | `Delete` / `Backspace` |+| 全选 | `mod + A` |+| 选择 / 移动 / 旋转 / 缩放 工具 | `Q` / `W` / `E` / `R` |+| 微移选择(按 Shift ×10) | 方向键 |+| 聚焦选中 | `F` |+| 运行/切换 · 停止 | `F5` · `Esc` |+| 内容抽屉 | `Ctrl + Space` |+| 项目设置 | `mod + ,` |++<Aside type="tip">+ 用于无头自动化和 AI 代理,编辑器还暴露了一个 `EditorControlSurface`(加载场景、步进模拟、读取+ 场景树/检视器、抓取视口),通过一个 MCP server 提供——这是一个由脚本驱动的开发/自动化面,与上面+ 的可视化编辑器分开。+</Aside>