- Add `pnpm build:rapier2d` command to automate Rapier2D WASM build process - Fix gen-src.mjs path to correctly locate thirdparty/rapier.js - Update init.ts to work with new wasm-pack web target (auto-initialization) - Fix behavior-tree-editor build config for asset-system dependency - Update README_CN.md and README.md with simplified build instructions
133 lines
3.0 KiB
Markdown
133 lines
3.0 KiB
Markdown
# ESEngine 编辑器
|
||
|
||
基于 Tauri 2.x + React 18 构建的跨平台桌面可视化编辑器。
|
||
|
||
## 环境要求
|
||
|
||
运行编辑器前,请确保已安装以下环境:
|
||
|
||
- **Node.js** >= 18.x
|
||
- **pnpm** >= 10.x
|
||
- **Rust** >= 1.70 (Tauri 和 WASM 构建需要)
|
||
- **wasm-pack** (构建 Rapier2D 物理引擎需要)
|
||
- **平台相关依赖**:
|
||
- **Windows**: Microsoft Visual Studio C++ Build Tools
|
||
- **macOS**: Xcode Command Line Tools (`xcode-select --install`)
|
||
- **Linux**: 参考 [Tauri 环境配置](https://tauri.app/v1/guides/getting-started/prerequisites)
|
||
|
||
### 安装 wasm-pack
|
||
|
||
```bash
|
||
# 使用 cargo 安装
|
||
cargo install wasm-pack
|
||
|
||
# 或使用官方安装脚本 (Linux/macOS)
|
||
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
|
||
```
|
||
|
||
## 快速开始
|
||
|
||
### 1. 克隆并安装
|
||
|
||
```bash
|
||
git clone https://github.com/esengine/esengine.git
|
||
cd esengine
|
||
pnpm install
|
||
```
|
||
|
||
### 2. 构建 Rapier2D WASM
|
||
|
||
编辑器依赖 Rapier2D 物理引擎的 WASM 产物。首次构建只需执行一条命令:
|
||
|
||
```bash
|
||
pnpm build:rapier2d
|
||
```
|
||
|
||
该命令会自动完成以下步骤:
|
||
1. 准备 Rust 项目
|
||
2. 构建 WASM
|
||
3. 复制产物到 `packages/physics/rapier2d/pkg`
|
||
4. 生成 TypeScript 源码
|
||
|
||
> **注意**:需要已安装 Rust 和 wasm-pack。
|
||
|
||
### 3. 构建编辑器
|
||
|
||
在项目根目录执行:
|
||
|
||
```bash
|
||
pnpm build:editor
|
||
```
|
||
|
||
### 4. 启动编辑器
|
||
|
||
```bash
|
||
cd packages/editor/editor-app
|
||
pnpm tauri:dev
|
||
```
|
||
|
||
## 可用脚本
|
||
|
||
| 脚本 | 说明 |
|
||
|------|------|
|
||
| `pnpm build:rapier2d` | 构建 Rapier2D WASM(首次构建必须执行)|
|
||
| `pnpm build:editor` | 构建编辑器及所有依赖 |
|
||
| `pnpm tauri:dev` | 开发模式运行编辑器(支持热重载)|
|
||
| `pnpm tauri:build` | 构建生产版本应用 |
|
||
| `pnpm build:sdk` | 构建 editor-runtime SDK |
|
||
|
||
## 项目结构
|
||
|
||
```
|
||
editor-app/
|
||
├── src/ # React 应用源码
|
||
│ ├── components/ # UI 组件
|
||
│ ├── panels/ # 编辑器面板
|
||
│ └── services/ # 核心服务
|
||
├── src-tauri/ # Tauri (Rust) 后端
|
||
├── public/ # 静态资源
|
||
└── scripts/ # 构建脚本
|
||
```
|
||
|
||
## 常见问题
|
||
|
||
### Rapier2D WASM 构建失败
|
||
|
||
**错误**: `Could not resolve "../pkg/rapier_wasm2d"`
|
||
|
||
**原因**: 缺少 Rapier2D 的 WASM 产物。
|
||
|
||
**解决方案**:
|
||
1. 确保已安装 `wasm-pack`:`cargo install wasm-pack`
|
||
2. 执行 `pnpm build:rapier2d`
|
||
3. 确认 `packages/physics/rapier2d/pkg/` 目录存在且包含 `rapier_wasm2d_bg.wasm` 文件
|
||
|
||
### 构建错误
|
||
|
||
```bash
|
||
pnpm clean
|
||
pnpm install
|
||
pnpm build:editor
|
||
```
|
||
|
||
### Rust/Tauri 错误
|
||
|
||
```bash
|
||
rustup update
|
||
```
|
||
|
||
### Windows 用户构建 WASM
|
||
|
||
`pnpm build:rapier2d` 脚本在 Windows 上可以直接运行。如果遇到问题:
|
||
1. 使用 Git Bash 或 WSL
|
||
2. 或从 [Releases](https://github.com/esengine/esengine/releases) 下载预编译的 WASM 产物
|
||
|
||
## 文档
|
||
|
||
- [ESEngine 文档](https://esengine.cn/)
|
||
- [Tauri 文档](https://tauri.app/)
|
||
|
||
## 许可证
|
||
|
||
MIT License
|