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: add v0.5.0 guide pages and update existing docs
esengineb98bd0e91143
diff --git a/docs/astro/astro.config.mjs b/docs/astro/astro.config.mjsindex b640f661c..e45ec3fec 100644--- a/docs/astro/astro.config.mjs+++ b/docs/astro/astro.config.mjs@@ -89,6 +89,16 @@ export default defineConfig({{ label: 'Geometry & Meshes', translations: { 'zh-CN': '几何体与网格' }, slug: 'guides/geometry' },{ label: 'Physics', translations: { 'zh-CN': '物理' }, slug: 'guides/physics' },{ label: 'Editor Extensions', translations: { 'zh-CN': '编辑器扩展' }, slug: 'guides/editor-extensions' },+ { label: 'Plugins', translations: { 'zh-CN': '插件系统' }, slug: 'guides/plugins' },+ { label: 'Building', translations: { 'zh-CN': '构建' }, slug: 'guides/building' },+ {+ label: 'Platforms',+ translations: { 'zh-CN': '平台' },+ items: [+ { label: 'WeChat MiniGame', translations: { 'zh-CN': '微信小游戏' }, slug: 'guides/wechat' },+ { label: 'Playable Ads', translations: { 'zh-CN': '可玩广告' }, slug: 'guides/playable-ads' },+ ],+ },],},{diff --git a/docs/astro/src/content/docs/core-concepts/components.mdx b/docs/astro/src/content/docs/core-concepts/components.mdxindex 085baf728..a8f9fd806 100644--- a/docs/astro/src/content/docs/core-concepts/components.mdx+++ b/docs/astro/src/content/docs/core-concepts/components.mdx@@ -17,7 +17,7 @@ Position, rotation, and scale of an entity.| Property | Type | Description ||----------|------|-------------|-| `position` | Vec3 | World position `{ x, y, z }` |+| `position` | Vec3 | Local position `{ x, y, z }` || `rotation` | Quat | Quaternion `{ w, x, y, z }` || `scale` | Vec3 | Scale factor `{ x, y, z }` |@@ -31,9 +31,9 @@ View settings. At least one active camera is required to see anything. The edito| Property | Type | Description ||----------|------|-------------|-| `projectionType` | number | 0 = Perspective, 1 = Orthographic |+| `projectionType` | ProjectionType | `Orthographic` — use `ProjectionType.Perspective` (0) or `ProjectionType.Orthographic` (1) || `fov` | number | Field of view in degrees (perspective only) |-| `orthoSize` | number | Half-height in world units (orthographic only) |+| `orthoSize` | number | Half-height in world units (orthographic only). Default: `540` || `nearPlane` | number | Near clipping plane || `farPlane` | number | Far clipping plane || `isActive` | boolean | Whether this camera is used for rendering |@@ -43,7 +43,7 @@ View settings. At least one active camera is required to see anything. The edito| `viewportY` | number | Viewport bottom edge (0–1). Default: 0 || `viewportW` | number | Viewport width (0–1). Default: 1 || `viewportH` | number | Viewport height (0–1). Default: 1 |-| `clearFlags` | number | Buffer clear mode: 0=None, 1=Color, 2=Depth, 3=Both |+| `clearFlags` | ClearFlags | `ClearFlags.ColorAndDepth` (3) — `None` (0), `ColorOnly` (1), `DepthOnly` (2), `ColorAndDepth` (3) || `showFrustum` | boolean | Draw the camera frustum wireframe in the editor |### Canvas@@ -54,7 +54,7 @@ Display settings for the rendering surface.|----------|------|-------------|| `designResolution` | Vec2 | Design resolution `{ x, y }` || `pixelsPerUnit` | number | Pixels per world unit |-| `scaleMode` | number | How the canvas scales |+| `scaleMode` | ScaleMode | `ScaleMode.FixedHeight` (1) — `FixedWidth` (0), `FixedHeight` (1), `Expand` (2), `Shrink` (3), `Match` (4) || `matchWidthOrHeight` | number | Balance between width/height matching || `backgroundColor` | Color | Clear color RGBA |diff --git a/docs/astro/src/content/docs/core-concepts/queries.mdx b/docs/astro/src/content/docs/core-concepts/queries.mdxindex a60d9d9c6..83d3d01af 100644--- a/docs/astro/src/content/docs/core-concepts/queries.mdx+++ b/docs/astro/src/content/docs/core-concepts/queries.mdx@@ -59,7 +59,7 @@ query.forEach((entity, transform, sprite) => {### single-Get the one and only matching entity. Returns `null` if there are zero or more than one matches.+Get the first matching entity. Returns `null` if no entities match.```typescriptconst result = query.single();diff --git a/docs/astro/src/content/docs/core-concepts/systems.mdx b/docs/astro/src/content/docs/core-concepts/systems.mdxindex 26939286d..cdbc5c017 100644--- a/docs/astro/src/content/docs/core-concepts/systems.mdx+++ b/docs/astro/src/content/docs/core-concepts/systems.mdx@@ -57,7 +57,11 @@ addSystemToSchedule(Schedule.FixedUpdate, physicsSystem);| `FixedPostUpdate` | At fixed intervals, after FixedUpdate |<Aside type="note">- The Fixed schedules (`FixedPreUpdate`, `FixedUpdate`, `FixedPostUpdate`) run at a fixed timestep of 1/60s using an accumulator. In a single frame they may execute zero or multiple times depending on the frame duration. Use them for physics and other deterministic logic that requires consistent time steps.+ The Fixed schedules (`FixedPreUpdate`, `FixedUpdate`, `FixedPostUpdate`) run at a fixed timestep of 1/60s using an accumulator. In a single frame they may execute zero or multiple times depending on the frame duration, up to a maximum of **8 iterations** per frame. Use them for physics and other deterministic logic that requires consistent time steps.+</Aside>++<Aside type="note">+ Delta time is clamped to a maximum of **250ms** (0.25s). If a frame takes longer (e.g., due to a tab being inactive), the excess time is discarded to prevent large simulation jumps.</Aside>## System Parameters@@ -78,7 +82,7 @@ defineSystem([Commands()], (cmds) => {// Modify an existing entitycmds.entity(bullet)- .insert(Velocity, { linear: { x: 100, y: 0 } })+ .insert(Velocity, { linear: { x: 100, y: 0, z: 0 } }).remove(Sprite);// Despawn an entity@@ -191,6 +195,10 @@ addSystem(defineSystem());```+## Error Handling++Each system runs inside its own try/catch boundary. If a system throws an error, it is caught and logged to the console without crashing the entire game loop. Other systems continue to execute normally.+## Next Steps- [Queries](/microes/core-concepts/queries/) — query filters and iteration methodsdiff --git a/docs/astro/src/content/docs/getting-started/quick-start.mdx b/docs/astro/src/content/docs/getting-started/quick-start.mdxindex f2ec8dbef..7adae737b 100644--- a/docs/astro/src/content/docs/getting-started/quick-start.mdx+++ b/docs/astro/src/content/docs/getting-started/quick-start.mdx@@ -110,6 +110,8 @@ addSystemToSchedule(Schedule.FixedUpdate, system); // runs at fixed intervalsUse `Commands` when you need to create entities at runtime (e.g. bullets, particles):```typescript+import { addStartupSystem, defineSystem, Commands, Sprite, LocalTransform } from 'esengine';+addStartupSystem(defineSystem([Commands()],(cmds) => {diff --git a/docs/astro/src/content/docs/guides/assets.mdx b/docs/astro/src/content/docs/guides/assets.mdxindex c67d6c173..deae713bb 100644--- a/docs/astro/src/content/docs/guides/assets.mdx+++ b/docs/astro/src/content/docs/guides/assets.mdx@@ -88,10 +88,6 @@ Supports `.fnt` (BMFont text format) and `.bmfont` (JSON metadata) files. The lo| `getFont(path)` | `number \| undefined` | Get cached font handle, `undefined` if not loaded || `releaseFont(path)` | `void` | Release the font and its textures from memory |-<Aside type="note">- `loadAll` does not currently support bitmap fonts. Load them separately with `loadBitmapFont`.-</Aside>-## Prefab Loading```typescript@@ -129,40 +125,37 @@ const data = await assets.loadBinary('assets/tilemap.bin');## Batch Loading-Load multiple assets in parallel with `loadAll`:+Load all assets from an `AddressableManifest` in parallel with `loadAll`:```typescript-const bundle = await assets.loadAll({- textures: ['assets/bg.png', 'assets/player.png'],- spine: [{ skeleton: 'assets/hero.json', atlas: 'assets/hero.atlas' }],- json: ['assets/config.json'],-});+const manifest = await assets.loadJson('assets/addressable-manifest.json');+assets.setAddressableManifest(manifest);++const bundle = await assets.loadAll(manifest);// Access loaded assets from the bundle-const bgTex = bundle.textures.get('assets/bg.png');-const config = bundle.json.get('assets/config.json');+const bgTex = bundle.textures.get('bg');+const config = bundle.json.get('game-config');```-### AssetManifest+You can also load a subset of assets by label or group:-| Field | Type | Description |-|-------|------|-------------|-| `textures` | string[] | Texture image paths |-| `materials` | string[] | Material file paths (.esmaterial) |-| `spine` | SpineDescriptor[] | Spine skeleton/atlas pairs |-| `json` | string[] | JSON file paths |-| `text` | string[] | Text file paths |-| `binary` | string[] | Binary file paths |+```typescript+const bundle = await assets.loadByLabel('ui-sprites');+const levelBundle = await assets.loadGroup('level-1');+```### AssetBundle-The returned `AssetBundle` contains Maps keyed by path:+The returned `AssetBundle` contains Maps keyed by address (or path if no address is set):| Field | Type ||-------|------|| `textures` | `Map<string, TextureInfo>` || `materials` | `Map<string, LoadedMaterial>` || `spine` | `Map<string, SpineLoadResult>` |+| `fonts` | `Map<string, FontHandle>` |+| `prefabs` | `Map<string, PrefabData>` || `json` | `Map<string, unknown>` || `text` | `Map<string, string>` || `binary` | `Map<string, ArrayBuffer>` |@@ -207,7 +200,7 @@ Addressable assets let you load resources by logical address, label, or group in### Loading by Address```typescript-const texture = await assets.loadByAddress('player-idle');+const texture = await assets.load('player-idle');```### Loading by Label@@ -240,6 +233,38 @@ const manifest = await assets.loadJson('assets/addressable-manifest.json');assets.setAddressableManifest(manifest);```+### Manifest Format++The `AddressableManifest` has the following structure:++```typescript+interface AddressableManifest {+ version: '2.0';+ groups: Record<string, AddressableManifestGroup>;+}++interface AddressableManifestGroup {+ bundleMode: string;+ labels: string[];+ assets: Record<string, AddressableManifestAsset>;+}++interface AddressableManifestAsset {+ path: string;+ address?: string;+ type: AddressableAssetType;+ size: number;+ labels: string[];+ metadata?: {+ atlas?: string;+ atlasPage?: number;+ atlasFrame?: { x: number; y: number; width: number; height: number };+ };+}+```++Each group contains assets with their paths, optional addresses, labels, and type-specific metadata. Asset types include `texture`, `material`, `spine`, `bitmap-font`, `prefab`, `json`, `text`, `binary`, and `audio`.+<Aside type="note">Addressable addresses, labels, and groups are configured in the editor's Addressable panel. The manifest is generated automatically during build.</Aside>diff --git a/docs/astro/src/content/docs/guides/bitmap-text.mdx b/docs/astro/src/content/docs/guides/bitmap-text.mdxindex 8e56e196a..771079937 100644--- a/docs/astro/src/content/docs/guides/bitmap-text.mdx+++ b/docs/astro/src/content/docs/guides/bitmap-text.mdx@@ -21,7 +21,7 @@ The `BitmapText` component renders text using pre-baked bitmap font atlases (BMF| `align` | number | `0` | Horizontal alignment: 0=Left, 1=Center, 2=Right || `spacing` | number | `0` | Extra spacing between characters (pixels) || `layer` | number | `0` | Render layer for draw ordering |-| `font` | number | `0` | Font handle returned by `assets.loadBitmapFont()` |+| `font` | number | `INVALID_FONT` | Font handle returned by `assets.loadBitmapFont()` |## Font Formatsdiff --git a/docs/astro/src/content/docs/guides/building.mdx b/docs/astro/src/content/docs/guides/building.mdxnew file mode 100644index 000000000..d2e02cc18--- /dev/null+++ b/docs/astro/src/content/docs/guides/building.mdx@@ -0,0 +1,199 @@+---+title: Building+description: Building ESEngine projects for different platforms+---++import { Aside } from '@astrojs/starlight/components';++ESEngine projects can be built for two target platforms from the editor: **Playable Ads** (a single self-contained HTML file) and **WeChat MiniGame** (a directory structure ready for WeChat DevTools).++## Build Targets++| Platform | Output | Description |+|----------|--------|-------------|+| Playable Ads | Single `.html` file | All assets, WASM, and scripts inlined into one file. Designed for ad networks that require a single-file deliverable. |+| WeChat MiniGame | Directory | Contains `game.js`, `game.json`, `project.config.json`, scene files, and assets. Ready to open in WeChat DevTools. |++## Using the Build Panel++Open the **Build** panel from the editor toolbar. The panel has a three-column layout:++1. **Left sidebar** -- lists platforms and build configurations. Click a platform to filter, then select a configuration.+2. **Center detail** -- shows the selected configuration's settings: scenes, script defines, and platform-specific options.+3. **Right output** -- displays build history, status, output size, and actions (Open Folder, Preview).++### Creating a Build Configuration++Click **Add** in the toolbar to create a new configuration. Choose a name and target platform. The editor also provides pre-built **Templates** (accessible via the Templates button) for common setups like "Playable Production" or "WeChat Development".++### Running a Build++1. Select a configuration from the sidebar+2. Review the scenes list -- click **Add Current Scene** to include the scene currently open in the editor+3. Adjust platform-specific settings as needed+4. Click **Build** (or press `Cmd/Ctrl + B`)++Build progress and logs are displayed in real time via a toast notification. When complete, you can click **Open Folder** to navigate to the output.++<Aside type="tip">+ Use **Build All** to build every configuration in sequence. This is useful for producing both development and production builds at once.+</Aside>++## Build Configuration++Each configuration contains:++| Setting | Purpose |+|---------|---------|+| **Name** | Human-readable label for this configuration |+| **Platform** | Target platform: Playable Ads or WeChat MiniGame |+| **Scenes** | List of `.esscene` files to include in the build |+| **Script Defines** | Compile-time defines (e.g. `DEBUG`). Accessible in your scripts via `process.env.DEBUG`. |+| **Platform Settings** | Platform-specific options (see below) |++### Playable Ads Settings++| Setting | Description |+|---------|-------------|+| **Startup Scene** | Scene to load on startup (defaults to the first scene in the list) |+| **Development Build** | Include debug info in the output |+| **Minify Code** | Minify bundled JavaScript for smaller output |+| **Embed Fonts** | Inline font files into the HTML |+| **Output Path** | Where to write the output `.html` file (e.g. `build/playable.html`) |+| **Enable Built-in CTA** | Show a built-in "Install Now" call-to-action button |+| **CTA URL** | Destination URL when the CTA button is clicked |++<Aside type="note">+ Playable ads embed everything into a single HTML file -- WASM binary, textures, scene data, and scripts are all base64-encoded and inlined.+</Aside>++### WeChat MiniGame Settings++| Setting | Description |+|---------|-------------|+| **AppID** | WeChat MiniGame AppID. Use `touristappid` for testing without a registered app. |+| **Version** | Version string (e.g. `1.0.0`) |+| **Screen Orientation** | `Portrait` or `Landscape` |+| **Bundle Mode** | `Subpackage` (recommended), `Single Package`, or `Single File` |+| **Output Directory** | Where to write the output directory (e.g. `build/wechat`) |++## Asset Export Configuration++The build system determines which assets to include using three modes, configurable per folder in the editor:++| Mode | Behavior |+|------|----------|+| `auto` (default) | Only include assets that are referenced by scenes or prefabs in the build |+| `always` | Include all assets in the folder regardless of references |+| `exclude` | Never include assets from this folder |++Asset export modes are stored in `.esengine/asset-export.json`:++```json+{+ "version": "1.0",+ "folders": {+ "assets/ui": "always",+ "assets/debug": "exclude"+ }+}+```++Folders inherit their parent's mode. For example, if `assets/sprites` is set to `always`, all files under `assets/sprites/enemies/` are also included.++## Build Pipeline++When you click Build, the editor runs the following pipeline:++### 1. Asset Collection++The build scans scene files and recursively collects:++- Textures referenced by `Sprite`, `SpineRenderer`, and other components+- Materials and their shader dependencies+- Spine atlas files and their texture pages+- Bitmap font files and their glyph textures+- Nested prefabs and their transitive asset references++### 2. Atlas Packing++Referenced images are packed into texture atlas pages (max 2048x2048 by default). Scene data is rewritten to use atlas coordinates, so sprites automatically reference the packed atlas at runtime.++### 3. Material Compilation++`.esmaterial` files are compiled to JSON, resolving shader references and inlining property values.++### 4. Script Bundling++User scripts from the `src/` directory are compiled and bundled with esbuild. The `esengine` SDK is treated as an external module -- on Playable it is inlined, on WeChat it is loaded from `sdk.js`.++### 5. Platform Emission++The final output is produced for the target platform:++- **Playable Ads** -- assembles a single HTML file with all assets base64-encoded inline+- **WeChat MiniGame** -- writes a directory with `game.js`, `game.json`, `project.config.json`, scenes, assets, and WASM files++## Output Structure++### Playable Ads++```+build/+ playable.html # single self-contained file+```++### WeChat MiniGame++```+build/wechat/+ project.config.json # WeChat DevTools project config+ game.json # MiniGame manifest+ game.js # entry point (engine init + user scripts)+ esengine.js # WASM engine loader+ esengine.wasm # engine WASM binary+ sdk.js # SDK runtime+ spine.js / spine.wasm # Spine runtime (if Spine is enabled)+ physics.js / physics.wasm # physics engine (if physics is enabled)+ atlas_0.png # packed texture atlas pages+ asset-manifest.json # addressable asset manifest+ scenes/+ Level1.json # exported scene data+ assets/+ ... # non-packed asset files+```++## Addressable Manifest++Both platforms generate an `asset-manifest.json` that maps asset UUIDs to runtime paths. This enables the runtime to resolve assets by UUID or address and to reconstruct atlas frames from packed pages.++```json+{+ "version": "2.0",+ "groups": {+ "default": {+ "bundleMode": "together",+ "labels": [],+ "assets": {+ "uuid-1": {+ "path": "assets/sprites/player.png",+ "type": "texture",+ "size": 1024,+ "labels": ["character"]+ }+ }+ }+ }+}+```++## Project Settings++Build behavior is also influenced by project-level settings:++| Setting | Effect |+|---------|--------|+| Spine version | Includes Spine runtime WASM module in the build |+| Enable physics | Includes physics WASM module and generates physics config |+| Physics gravity | Sets the gravity vector in the physics config |+| Physics timestep | Sets the fixed simulation timestep |diff --git a/docs/astro/src/content/docs/guides/canvas.mdx b/docs/astro/src/content/docs/guides/canvas.mdxindex e41e9fb27..8b73f232f 100644--- a/docs/astro/src/content/docs/guides/canvas.mdx+++ b/docs/astro/src/content/docs/guides/canvas.mdx@@ -19,7 +19,7 @@ You can also add the `Canvas` component manually to any entity that has a `Camer|----------|------|---------|-------------|| `designResolution` | Vec2 | `{x: 1920, y: 1080}` | The reference resolution you design your game for || `pixelsPerUnit` | number | `100` | How many pixels equal one world unit |-| `scaleMode` | number | `1` | Scale strategy (see below) |+| `scaleMode` | ScaleMode | `FixedHeight` (1) | Scale strategy (see below). Import `ScaleMode` from `'esengine'` || `matchWidthOrHeight` | number | `0.5` | Blend factor for Match mode (0 = width, 1 = height) || `backgroundColor` | Color | `{r: 0, g: 0, b: 0, a: 1}` | Letterbox/pillarbox fill color |@@ -68,13 +68,13 @@ Blends between FixedWidth and FixedHeight based on `matchWidthOrHeight`. A valueQuery the `Canvas` component in a system:```typescript-import { defineSystem, addSystem, Query, Mut, Canvas } from 'esengine';+import { defineSystem, addSystem, Query, Mut, Canvas, ScaleMode } from 'esengine';addSystem(defineSystem([Query(Mut(Canvas))],(query) => {for (const [entity, canvas] of query) {- canvas.scaleMode = 4;+ canvas.scaleMode = ScaleMode.Match;canvas.matchWidthOrHeight = 0.5;}}diff --git a/docs/astro/src/content/docs/guides/custom-draw.mdx b/docs/astro/src/content/docs/guides/custom-draw.mdxindex c97434e09..0ee976436 100644--- a/docs/astro/src/content/docs/guides/custom-draw.mdx+++ b/docs/astro/src/content/docs/guides/custom-draw.mdx@@ -166,20 +166,21 @@ const primitives = Draw.getPrimitiveCount();```typescriptimport { registerDrawCallback, Draw } from 'esengine';-import { defineSystem, addSystem, Query, LocalTransform, Collider } from 'esengine';+import { defineSystem, addSystem, Query, LocalTransform } from 'esengine';+import { BoxCollider } from 'esengine/physics';-const colliders: Array<{ x: number; y: number; w: number; h: number }> = [];+const boxes: Array<{ x: number; y: number; w: number; h: number }> = [];addSystem(defineSystem(- [Query(LocalTransform, Collider)],+ [Query(LocalTransform, BoxCollider)],(query) => {- colliders.length = 0;+ boxes.length = 0;for (const [entity, transform, collider] of query) {- colliders.push({- x: transform.position.x,- y: transform.position.y,- w: collider.width,- h: collider.height,+ boxes.push({+ x: transform.position.x + collider.offset.x,+ y: transform.position.y + collider.offset.y,+ w: collider.halfExtents.x * 2,+ h: collider.halfExtents.y * 2,});}}@@ -187,7 +188,7 @@ addSystem(defineSystem(registerDrawCallback('debug-colliders', () => {const green = { r: 0, g: 1, b: 0, a: 0.5 };- for (const c of colliders) {+ for (const c of boxes) {Draw.rectOutline({ x: c.x, y: c.y },{ x: c.w, y: c.h },diff --git a/docs/astro/src/content/docs/guides/input.mdx b/docs/astro/src/content/docs/guides/input.mdxindex d111c51ff..d1ab4aef4 100644--- a/docs/astro/src/content/docs/guides/input.mdx+++ b/docs/astro/src/content/docs/guides/input.mdx@@ -172,3 +172,9 @@ addSystem(defineSystem(}));```++## Next Steps++- [UI & Text](/microes/guides/ui/) — UI interaction events (click, hover, press)+- [Physics](/microes/guides/physics/) — physics-driven movement and collision+- [Systems](/microes/core-concepts/systems/) — defining and scheduling systemsdiff --git a/docs/astro/src/content/docs/guides/materials.mdx b/docs/astro/src/content/docs/guides/materials.mdxindex 7195af791..b38f632c2 100644--- a/docs/astro/src/content/docs/guides/materials.mdx+++ b/docs/astro/src/content/docs/guides/materials.mdx@@ -207,7 +207,7 @@ Animate a uniform in a system to create a flashing effect:```typescriptimport { defineSystem, addSystem, Query, Mut, Res } from 'esengine';-import { Sprite, Material, BlendMode, Time } from 'esengine';+import { Sprite, Material, BlendMode, ShaderSources, Time } from 'esengine';const flashShader = Material.createShader(ShaderSources.SPRITE_VERTEX,diff --git a/docs/astro/src/content/docs/guides/playable-ads.mdx b/docs/astro/src/content/docs/guides/playable-ads.mdxnew file mode 100644index 000000000..970ec6ab5--- /dev/null+++ b/docs/astro/src/content/docs/guides/playable-ads.mdx@@ -0,0 +1,155 @@+---+title: Playable Ads+description: Building single-file HTML playable ads with ESEngine+---++import { Aside } from '@astrojs/starlight/components';++ESEngine can export your game as a single self-contained HTML file suitable for playable ad networks (Facebook, Google, Unity Ads, IronSource, AppLovin, etc.).++## Building a Playable Ad++### 1. Open the Build Panel++Open the **Build** panel from the editor toolbar. Select or create a Playable Ads configuration.++### 2. Configure Settings++| Setting | Description |+|---------|-------------|+| **Startup Scene** | Scene to load on startup (defaults to the first scene in the list) |+| **Development Build** | Include debug info -- useful for testing, disable for production |+| **Minify Code** | Minify JavaScript for smaller output. Enable for production builds. |+| **Embed Fonts** | Inline font files into the HTML |+| **Output Path** | Where to write the output file (e.g. `build/playable.html`) |+| **Enable Built-in CTA** | Show a built-in "Install Now" button |+| **CTA URL** | URL opened when the CTA button is clicked |++### 3. Add Scenes++Ensure your startup scene is listed in the Scenes section. Only assets referenced by scenes in the build are embedded in the output.++### 4. Click Build++Click **Build** or press `Cmd/Ctrl + B`. The editor will collect assets, pack textures, compile scripts, and assemble the single HTML file. Build progress and output size are shown in real time.++## How It Works++The playable ad build pipeline:++1. Bundles the WASM engine, SDK, and user scripts into inline `<script>` tags+2. Embeds all referenced assets (textures, Spine data, materials, prefabs) as base64 data URIs+3. Embeds the startup scene JSON and the addressable asset manifest+4. Produces a single `.html` file with zero external dependencies++At runtime, asset loading calls automatically resolve from the embedded data -- no code changes are needed compared to the web build.++## Testing the Output++After building:++1. Click **Open Folder** in the build output panel to find the HTML file+2. Open the `.html` file directly in a browser to test+3. Use browser DevTools to check console output and performance++<Aside type="tip">+ For a quick test, click **Preview** in the build output panel to open the HTML file directly.+</Aside>++You can also test with ad network preview tools:+- **Facebook**: [Playable Preview Tool](https://www.facebook.com/business/help/412951382532338)+- **Google**: Upload to Google Ads and use the preview function+- **Unity Ads**: Unity Ads dashboard preview++## CTA Button++The optional built-in CTA (Call To Action) button appears as a fixed-position "Install Now" button at the bottom of the screen. When enabled in the build settings:++- The button is hidden during loading and shown after the game starts+- Clicking it opens the CTA URL via MRAID (`mraid.open()`) if available, otherwise `window.open()`++<Aside type="tip">+ Most ad networks provide their own CTA mechanism. You can leave the built-in CTA disabled and use the network's SDK or MRAID API directly in your game scripts.+</Aside>++### MRAID Integration++[MRAID](https://www.iab.com/guidelines/mraid/) (Mobile Rich-media Ad Interface Definitions) is the standard API used by ad SDKs. The built-in CTA automatically uses MRAID when available.++For deeper MRAID integration (e.g., responding to `viewableChange` events), use a startup system in your scripts:++```typescript+import { addStartupSystem, defineSystem } from 'esengine';++addStartupSystem(defineSystem([], () => {+ const mraid = (window as any).mraid;+ if (!mraid) return;++ mraid.addEventListener('viewableChange', (viewable: boolean) => {+ if (viewable) {+ // ad became visible -- start gameplay+ }+ });+}));+```++## Asset Embedding++All assets referenced by the startup scene are automatically embedded:++- **Textures**: Encoded as `data:image/png;base64,...`+- **JSON files** (materials, prefabs, config): Encoded as `data:application/json;base64,...`+- **Spine data** (atlas, skeleton): Encoded as base64 data URIs+- **Texture atlases**: Atlas pages are embedded as PNG data URIs++<Aside type="note">+ Assets not referenced by the startup scene are not included. Use addressable groups with export mode "always" to force-include assets that are loaded dynamically at runtime.+</Aside>++## Spine & Physics Support++If your project uses Spine animations or Box2D physics, the respective WASM modules are automatically embedded as base64 and instantiated at runtime. No additional configuration is needed -- the build detects whether Spine or physics is enabled in your project settings.++## Size Optimization++Playable ad networks typically impose file size limits (2-5 MB). Tips for reducing output size:++1. **Minimize textures**: Use small, compressed PNG/JPG files. The atlas packer helps consolidate textures.+2. **Enable minification**: Turn on **Minify Code** in the build settings.+3. **Reduce scene complexity**: Fewer entities and components means smaller scene JSON.+4. **Remove unused asset references**: Only assets referenced by the startup scene are embedded. Remove references to assets you do not need.+5. **Optimize Spine data**: Use binary `.skel` files instead of JSON skeletons. Reduce the number of bones and animations.+6. **Consider disabling physics**: If your ad does not need physics, disabling it in project settings excludes the physics WASM module and saves significant size.++## Output Structure++The generated HTML follows this structure:++```html+<!DOCTYPE html>+<html>+<head>+ <meta name="ad.size" content="width=320,height=480">+ <style>/* fullscreen canvas + optional CTA styles */</style>+</head>+<body>+ <canvas id="canvas"></canvas>+ <script>/* WASM engine + SDK (inline) */</script>+ <script>/* Spine module (if used) */</script>+ <script>/* Physics module (if used) */</script>+ <script>/* User game code (compiled + bundled) */</script>+ <script>+ var __PA__ = { /* embedded assets as data URIs */ };+ var __SCENE__ = { /* startup scene JSON */ };+ var __MANIFEST__ = { /* addressable manifest */ };+ // ... initialization and scene loading+ </script>+</body>+</html>+```++## Next Steps++- [Building & Exporting](/microes/guides/building/) -- build pipeline overview+- [WeChat MiniGame](/microes/guides/wechat/) -- WeChat MiniGame builds+- [Asset Loading](/microes/guides/assets/) -- asset loading APIdiff --git a/docs/astro/src/content/docs/guides/plugins.mdx b/docs/astro/src/content/docs/guides/plugins.mdxnew file mode 100644index 000000000..66ff9faaa--- /dev/null+++ b/docs/astro/src/content/docs/guides/plugins.mdx@@ -0,0 +1,181 @@+---+title: Plugins+description: Extending ESEngine with the plugin system+---++import { Aside } from '@astrojs/starlight/components';++The **plugin system** organizes engine functionality into reusable modules. Each plugin provides a set of components, systems, and resources. ESEngine ships with several built-in plugins that are installed automatically -- you do not need to configure them.++## Built-in Plugins++When you create a project in the editor, all built-in plugins are active by default. They provide the components you see in the Inspector and the systems that drive engine behavior each frame.++### Core Plugins++| Plugin | What It Provides |+|--------|-----------------|+| Asset loading | `AssetServer` for loading textures, Spine data, prefabs, and other assets at runtime |+| Prefabs | `PrefabServer` for instantiating prefabs |+| Input | `InputState` with keyboard, mouse, and touch input -- cleared each frame |++### UI Plugins++| Plugin | Components |+|--------|-----------|+| Text | `Text` -- renders text content to sprite textures each frame |+| UI Mask | `UIMask` -- stencil-based masking for UI elements |+| UI Layout | `UIRect`, `ScreenSpace` -- anchored UI layout relative to camera |+| UI Interaction | `Interactable`, `Button`, `UIInteraction`, `UIEvents` -- pointer hit-testing and button states |+| Text Input | `TextInput` -- editable text fields with platform input |++All of these are active by default in every project. You can use their components directly from the editor's component picker -- no setup required.++## User Scripts++The primary way to extend your game is by writing TypeScript scripts in your project's `src/` directory. Scripts are automatically compiled and included in builds.++### Custom Components++Use `defineComponent()` to create components that appear in the editor's Inspector:++```typescript+import { defineComponent } from 'esengine';++const Health = defineComponent('Health', {+ hp: 100,+ maxHp: 100,+});+```++Once defined, `Health` appears in the editor's **Add Component** menu. You can add it to entities and edit its properties in the Inspector just like built-in components.++Use `defineTag()` for marker components with no data:++```typescript+import { defineTag } from 'esengine';++const Enemy = defineTag('Enemy');+```++### Systems++Use `defineSystem()` and `addSystem()` to add game logic that runs every frame:++```typescript+import { defineSystem, addSystem, Schedule } from 'esengine';++addSystem(defineSystem([], (world) => {+ // runs every frame during the Update phase+}));+```++You can also target a specific schedule phase:++```typescript+import { addSystemToSchedule, defineSystem, Schedule } from 'esengine';++addSystemToSchedule(Schedule.FixedUpdate, defineSystem([], (world) => {+ // runs at fixed timestep, ideal for physics logic+}));+```++For one-time initialization, use `addStartupSystem()`:++```typescript+import { addStartupSystem, defineSystem } from 'esengine';++addStartupSystem(defineSystem([], (world) => {+ // runs once when the game starts+}));+```++<Aside type="tip">+ Scripts in `src/` are automatically discovered by the build pipeline. You do not need to register them anywhere -- just create `.ts` files and they will be included.+</Aside>++### Resources++Resources are global singleton data that can be shared across systems:++```typescript+import { defineResource, addStartupSystem, defineSystem } from 'esengine';++const GameState = defineResource<{ score: number; level: number }>(+ { score: 0, level: 1 },+ 'GameState'+);++addStartupSystem(defineSystem([], (world) => {+ world.app.insertResource(GameState, { score: 0, level: 1 });+}));+```++## System Schedule++Systems run in a defined order each frame:++| Phase | When |+|-------|------|+| `Startup` | Once, when the game starts |+| `First` | Beginning of each frame |+| `FixedPreUpdate` | Before fixed-timestep update |+| `FixedUpdate` | Fixed-timestep update (physics) |+| `FixedPostUpdate` | After fixed-timestep update |+| `PreUpdate` | Before main update |+| `Update` | Main update (default for `addSystem`) |+| `PostUpdate` | After main update |+| `Last` | End of each frame |++## Advanced: Plugin Interface++<Aside type="note">+ This section is for advanced users who need to create reusable plugin packages. Most users can simply write scripts in `src/` as described above.+</Aside>++A plugin is an object implementing the `Plugin` interface:++```typescript+import { type Plugin, type App, defineResource, defineSystem, Schedule, registerComponent } from 'esengine';++const ScoreData = defineResource<{ value: number }>({ value: 0 }, 'Score');++const myPlugin: Plugin = {+ name: 'MyGamePlugin',+ build(app: App) {+ app.insertResource(ScoreData, { value: 0 });+ registerComponent('Health', { hp: 100, maxHp: 100 });+ app.addSystemToSchedule(Schedule.Update, defineSystem([], () => {+ // game logic+ }));+ },+};+```++Plugins can declare resource dependencies:++```typescript+const analyticsPlugin: Plugin = {+ name: 'AnalyticsPlugin',+ dependencies: [Assets],+ build(app: App) {+ const assets = app.getResource(Assets);+ // use asset server...+ },+};+```++### SDK Entry Points++For users building standalone applications without the editor, ESEngine provides two entry points:++- **`esengine`** -- full SDK with all UI plugins included+- **`esengine/core`** -- base SDK without UI plugins, for smaller bundles when UI is not needed++```typescript+import { createWebApp } from 'esengine/core';++const app = createWebApp(module, {+ plugins: [textPlugin, uiLayoutPlugin],+});+```diff --git a/docs/astro/src/content/docs/guides/prefabs.mdx b/docs/astro/src/content/docs/guides/prefabs.mdxindex b2b50a4fd..10949a42b 100644--- a/docs/astro/src/content/docs/guides/prefabs.mdx+++ b/docs/astro/src/content/docs/guides/prefabs.mdx@@ -25,7 +25,7 @@ Drag a `.esprefab` file from the content browser into the hierarchy panel. A new### Editing a Prefab-Double-click a `.esprefab` file in the content browser to enter **prefab edit mode**. The editor loads the prefab as a temporary scene where you can modify entities directly. Changes are saved back to the `.esprefab` file when you exit.+Double-click a `.esprefab` file in the content browser to enter **prefab edit mode**. The editor loads the prefab as a temporary scene where you can modify entities directly. Changes are saved back to the `.esprefab` file when you exit, and all instances in the current scene are automatically synced with the updated prefab.### Overrides@@ -39,7 +39,11 @@ Access these via right-click → **Prefab** on a prefab root entity.## Runtime API-Use the `Prefabs` resource to load and instantiate prefabs inside a system. It handles asset loading and entity creation in a single call:+Use the `Prefabs` resource to load and instantiate prefabs inside a system. It handles asset loading and entity creation in a single call.++<Aside type="note">+ The `Prefabs` resource is automatically available when using `createWebApp()` — the `PrefabsPlugin` is included by default.+</Aside>```typescriptimport { addStartupSystem, defineSystem, Res, Prefabs } from 'esengine';@@ -47,6 +51,7 @@ import { addStartupSystem, defineSystem, Res, Prefabs } from 'esengine';addStartupSystem(defineSystem([Res(Prefabs)],async (prefabs) => {+ // Accepts file paths or addressable addressesconst { root, entities } = await prefabs.instantiate('prefabs/Enemy.esprefab');}));@@ -99,14 +104,20 @@ const { root } = await prefabs.instantiate('prefabs/Enemy.esprefab', {### Nested Prefabs-Prefabs can contain references to other prefabs. When instantiating, nested prefabs are automatically loaded and flattened. This requires an `assetServer` in the options:+Prefabs can contain references to other prefabs. The high-level `prefabs.instantiate()` API handles nested prefabs automatically — all referenced prefabs are recursively loaded and flattened into a single entity tree. For advanced use cases, the low-level `instantiatePrefab()` function is available:```typescript+import { instantiatePrefab } from 'esengine';+const result = await instantiatePrefab(world, prefab, {assetServer: assets,});```+<Aside type="caution">+ Circular prefab references are automatically detected and skipped with an error log, preventing infinite recursion.+</Aside>+<Aside type="note">Prefab files are cached by the asset server. Loading the same `.esprefab` path multiple times returns the cached result.</Aside>diff --git a/docs/astro/src/content/docs/guides/render-texture.mdx b/docs/astro/src/content/docs/guides/render-texture.mdxindex 7ccd8413c..7effd7273 100644--- a/docs/astro/src/content/docs/guides/render-texture.mdx+++ b/docs/astro/src/content/docs/guides/render-texture.mdx@@ -38,7 +38,7 @@ import { RenderTexture, Draw } from 'esengine';RenderTexture.begin(rt, viewProjectionMatrix);-Draw.rect(0, 0, 100, 100, { r: 1, g: 0, b: 0, a: 1 });+Draw.rect({ x: 0, y: 0 }, { x: 100, y: 100 }, { r: 1, g: 0, b: 0, a: 1 });RenderTexture.end();```@@ -56,7 +56,7 @@ After rendering, `rt.textureId` holds the GPU texture ID. Use it anywhere a text```typescriptimport { Draw, Sprite } from 'esengine';-Draw.texture(rt.textureId, 0, 0, rt.width, rt.height);+Draw.texture({ x: 0, y: 0 }, { x: rt.width, y: rt.height }, rt.textureId);```You can also assign it to a Sprite's texture for entity-based rendering.diff --git a/docs/astro/src/content/docs/guides/rendering.mdx b/docs/astro/src/content/docs/guides/rendering.mdxindex 2c9e55198..3551b6c16 100644--- a/docs/astro/src/content/docs/guides/rendering.mdx+++ b/docs/astro/src/content/docs/guides/rendering.mdx@@ -17,7 +17,7 @@ A `Camera` component is required to see anything. The editor's default scene alr| Property | Type | Description ||----------|------|-------------|-| `projectionType` | number | 0 = Perspective, 1 = Orthographic |+| `projectionType` | ProjectionType | `ProjectionType.Perspective` (0), `ProjectionType.Orthographic` (1) || `fov` | number | Field of view in degrees (perspective only) || `orthoSize` | number | Half-height in world units (orthographic only) || `nearPlane` | number | Near clipping plane |@@ -29,12 +29,12 @@ A `Camera` component is required to see anything. The editor's default scene alr| `viewportY` | number | Viewport bottom edge (0–1). Default: 0 || `viewportW` | number | Viewport width (0–1). Default: 1 || `viewportH` | number | Viewport height (0–1). Default: 1 |-| `clearFlags` | number | Buffer clear mode: 0=None, 1=Color, 2=Depth, 3=Both |+| `clearFlags` | ClearFlags | `ClearFlags.None` (0), `ColorOnly` (1), `DepthOnly` (2), `ColorAndDepth` (3) || `showFrustum` | boolean | Draw the camera frustum wireframe in the editor |### Orthographic Camera-Best for 2D games. The `orthoSize` determines how much of the world is visible. Set `projectionType` to `1` in the inspector.+Best for 2D games. The `orthoSize` determines how much of the world is visible (default: `540`). Set `projectionType` to `ProjectionType.Orthographic` in the inspector. Import `ProjectionType` and `ClearFlags` from `'esengine'`.### Canvas Integration@@ -70,7 +70,7 @@ Multiple cameras can render simultaneously to different viewport regions. Each cCreate two Camera entities:- Main camera: viewport `(0, 0, 1, 1)`, `priority: 0`-- Minimap camera: viewport `(0.75, 0.75, 0.25, 0.25)`, `priority: 1`, `clearFlags: 3`+- Minimap camera: viewport `(0.75, 0.75, 0.25, 0.25)`, `priority: 1`, `clearFlags: ClearFlags.ColorAndDepth`The minimap renders in the top-right corner on top of the main view.diff --git a/docs/astro/src/content/docs/guides/scenes.mdx b/docs/astro/src/content/docs/guides/scenes.mdxindex faca2c3da..897177858 100644--- a/docs/astro/src/content/docs/guides/scenes.mdx+++ b/docs/astro/src/content/docs/guides/scenes.mdx@@ -111,7 +111,7 @@ You can spawn and despawn entities at runtime using `Commands`:import { defineSystem, addSystem, Commands, LocalTransform, Sprite } from 'esengine';addSystem(defineSystem(- [Commands],+ [Commands()],(commands) => {// Spawn a new entity with componentscommands.spawn()diff --git a/docs/astro/src/content/docs/guides/spine.mdx b/docs/astro/src/content/docs/guides/spine.mdxindex 3694b6870..e32a0ef64 100644--- a/docs/astro/src/content/docs/guides/spine.mdx+++ b/docs/astro/src/content/docs/guides/spine.mdx@@ -137,6 +137,10 @@ addSystem(defineSystem());```+## Multi-Texture Batching++Spine skeletons that use multiple atlas pages are automatically batched by the renderer. No additional configuration is needed — the C++ backend handles multi-texture setups transparently, keeping draw calls low even with complex multi-atlas characters.+<Aside type="tip">Spine rendering is handled by the C++ backend. The TypeScript side only sets component data — the engine handles loading, blending, and drawing automatically.</Aside>diff --git a/docs/astro/src/content/docs/guides/sprite.mdx b/docs/astro/src/content/docs/guides/sprite.mdxindex 8e98464f7..a1df27a39 100644--- a/docs/astro/src/content/docs/guides/sprite.mdx+++ b/docs/astro/src/content/docs/guides/sprite.mdx@@ -13,9 +13,9 @@ The `Sprite` component is the primary way to display 2D graphics. Add it to an e|----------|------|---------|-------------|| `texture` | number | `INVALID_TEXTURE` | Texture handle. No texture = solid color || `color` | Color | `{r:1, g:1, b:1, a:1}` | Tint color RGBA (0–1) |-| `size` | Vec2 | `{32, 32}` | Width and height in pixels |-| `uvOffset` | Vec2 | `{0, 0}` | Texture coordinate offset |-| `uvScale` | Vec2 | `{1, 1}` | Texture coordinate scale |+| `size` | Vec2 | `{x: 32, y: 32}` | Width and height in pixels |+| `uvOffset` | Vec2 | `{x: 0, y: 0}` | Texture coordinate offset |+| `uvScale` | Vec2 | `{x: 1, y: 1}` | Texture coordinate scale || `layer` | number | `0` | Render order (higher = on top) || `flipX` | boolean | `false` | Flip horizontally || `flipY` | boolean | `false` | Flip vertically |diff --git a/docs/astro/src/content/docs/guides/ui.mdx b/docs/astro/src/content/docs/guides/ui.mdxindex ece3e34dc..d8c04e411 100644--- a/docs/astro/src/content/docs/guides/ui.mdx+++ b/docs/astro/src/content/docs/guides/ui.mdx@@ -27,8 +27,8 @@ In the scene editor: create an entity → add `LocalTransform`, `Sprite`, `Text`| `fontFamily` | string | `'Arial'` | Font family name || `fontSize` | number | `24` | Font size in pixels || `color` | Color | `{r:1, g:1, b:1, a:1}` | Text color RGBA (0–1) |-| `align` | TextAlign | `Left` | Horizontal alignment |-| `verticalAlign` | TextVerticalAlign | `Top` | Vertical alignment |+| `align` | TextAlign | `Left` | Horizontal alignment (editor defaults to `Center`) |+| `verticalAlign` | TextVerticalAlign | `Top` | Vertical alignment (editor defaults to `Middle`) || `wordWrap` | boolean | `true` | Enable automatic word wrapping || `overflow` | TextOverflow | `Visible` | Overflow handling mode || `lineHeight` | number | `1.2` | Line height multiplier |@@ -162,10 +162,10 @@ addSystem(defineSystem([Res(Input), Query(Children, UIMask, ScrollList), Query(Mut(LocalTransform))],(input, maskQuery, childQuery) => {for (const [entity, children, mask, scroll] of maskQuery) {- const scrollDelta = input.getScrollDelta();+ const scroll = input.getScrollDelta();for (const child of children.entities) {const [, transform] = childQuery.get(child);- transform.position.y += scrollDelta * 20;+ transform.position.y += scroll.y * 20;}}}@@ -244,7 +244,7 @@ addSystem(defineSystem());```-**Event types:** `click`, `press`, `release`, `hover_enter`, `hover_exit`+**Event types:** `click`, `press`, `release`, `hover_enter`, `hover_exit`, `submit`, `change`### ScreenSpacediff --git a/docs/astro/src/content/docs/guides/wechat.mdx b/docs/astro/src/content/docs/guides/wechat.mdxnew file mode 100644index 000000000..7f40022b2--- /dev/null+++ b/docs/astro/src/content/docs/guides/wechat.mdx@@ -0,0 +1,164 @@+---+title: WeChat MiniGame+description: Building and deploying ESEngine games to WeChat MiniGame platform+---++import { Aside } from '@astrojs/starlight/components';++ESEngine supports building games for the WeChat MiniGame platform. The editor handles the entire build process, producing a project directory that you can open directly in WeChat DevTools.++## Prerequisites++Before building for WeChat, ensure you have:++1. **WeChat DevTools** installed ([download](https://developers.weixin.qq.com/miniprogram/dev/devtools/download.html))+2. A **WeChat MiniGame AppID** (optional for testing -- you can use `touristappid`)++## Building for WeChat++### 1. Open the Build Panel++Open the **Build** panel from the editor toolbar. Select or create a WeChat MiniGame configuration.++### 2. Configure Settings++| Setting | Description |+|---------|-------------|+| **AppID** | Your WeChat MiniGame AppID. Use `touristappid` for testing without a registered app. |+| **Version** | Version string (e.g. `1.0.0`) |+| **Screen Orientation** | `Portrait` or `Landscape` |+| **Bundle Mode** | `Subpackage` (recommended for most games), `Single Package`, or `Single File` |+| **Output Directory** | Where to write the build output (e.g. `build/wechat`) |++### 3. Add Scenes++Make sure the scenes you want to include are listed in the Scenes section. Click **Add Current Scene** to add the scene currently open in the editor.++### 4. Click Build++Click **Build** or press `Cmd/Ctrl + B`. The editor will:++1. Collect all assets referenced by your scenes+2. Pack textures into atlas pages+3. Compile materials and user scripts+4. Generate `game.js`, `game.json`, and `project.config.json`+5. Copy engine WASM files and SDK+6. Write the complete project to the output directory++Build progress is shown in real time.++## Opening in WeChat DevTools++After a successful build:++1. Open **WeChat DevTools**+2. Click **Import Project**+3. Navigate to your build output directory (e.g. `build/wechat`)+4. The AppID should auto-fill from `project.config.json`+5. Click **Import**++Your game should load and run in the simulator.++<Aside type="tip">+ After the build completes, click **Open Folder** in the editor's build output panel to quickly navigate to the output directory.+</Aside>++## Build Output++The build produces the following directory structure:++```+build/wechat/+ project.config.json # WeChat DevTools project config+ game.json # MiniGame config (orientation, subpackages)+ game.js # entry point (engine init + user scripts)+ esengine.js # WASM engine loader+ esengine.wasm # engine WASM binary+ sdk.js # ESEngine SDK runtime+ spine.js / spine.wasm # Spine runtime (if Spine is enabled)+ physics.js / physics.wasm # physics engine (if physics is enabled)+ asset-manifest.json # addressable asset manifest+ atlas_0.png, ... # packed texture atlases+ scenes/ # scene JSON files+ assets/ # game assets (textures, Spine data, etc.)+```++### What `game.js` Does++The generated `game.js` is the entry point for the MiniGame. It handles all platform-specific initialization automatically:++- Creates the canvas and sets up the correct resolution+- Loads the WASM engine using `WXWebAssembly.instantiate()`+- Registers the WebGL context with the engine+- Loads and runs your user scripts+- Loads the startup scene and begins the game loop++You do not need to modify `game.js` for normal usage.++## Platform Differences++WeChat MiniGame runs in a custom JavaScript runtime that differs from a standard browser:++- **No DOM**: There is no `document` or HTML elements. The canvas is provided by `wx.createCanvas()`.+- **No dynamic eval**: `eval()` and `new Function()` are blocked. The build handles this automatically.+- **Touch only**: Input comes from WeChat touch APIs. The SDK converts these to standard pointer events.+- **Custom file system**: Files are read via `wx.getFileSystemManager()` instead of HTTP fetch.++These differences are handled transparently by the build output. Your game scripts work the same way regardless of the target platform.++## Custom Extension Files++WeChat blocks access to files with unrecognized extensions by default. The build automatically generates the correct `packOptions.include` in `project.config.json` for all ESEngine file types (`.esmaterial`, `.esprefab`, `.atlas`, `.skel`, `.fnt`, `.bmfont`).++<Aside type="caution">+ If you add custom asset types with non-standard extensions, you may need to manually add them to `packOptions.include` in the generated `project.config.json`.+</Aside>++## Troubleshooting++### "permission denied" on File Read++This happens when WeChat blocks access to a file with an unrecognized extension. The build generates `packOptions.include` automatically, but if you added new asset types manually, verify the extension is listed:++```json+{+ "packOptions": {+ "include": [+ { "type": "suffix", "value": ".yourextension" }+ ]+ }+}+```++### "File not found"++The asset is not included in the build. Ensure it is either:+- Referenced by a scene or prefab (automatically included)+- In a folder with export mode set to `always` in the asset export configuration++### WebGL Context Errors++If you see `Failed to create WebGL context`, ensure the WeChat base library version supports WebGL 2. The build sets `libVersion` to `3.0.0` by default, but verify this in WeChat DevTools under **Project Settings > Base Library Version**.++### Blank Screen++- Check the WeChat DevTools console for error messages+- Ensure your scenes are listed in the build configuration+- Verify the output directory contains all expected files (especially `esengine.wasm` and `sdk.js`)++## Advanced: Customizing `game.js`++For advanced use cases (e.g., adding WeChat-specific APIs, analytics, or ad SDKs), you can modify the generated `game.js` after building. Key extension points:++- **Before scene loading**: Add initialization code after `SDK.flushPendingSystems(app)` but before scene loading+- **After scene loading**: Add code after `SDK.loadRuntimeScene(...)` but before `app.run()`++<Aside type="caution">+ Changes to `game.js` are overwritten on each build. If you need persistent customizations, keep a copy and merge changes after rebuilding.+</Aside>++## Next Steps++- [Building & Exporting](/microes/guides/building/) -- build pipeline overview+- [Playable Ads](/microes/guides/playable-ads/) -- single-file HTML builds for ad networks+- [Asset Loading](/microes/guides/assets/) -- asset loading APIdiff --git a/docs/astro/src/content/docs/zh/core-concepts/components.mdx b/docs/astro/src/content/docs/zh/core-concepts/components.mdxindex 5bb54b000..67e2ba191 100644--- a/docs/astro/src/content/docs/zh/core-concepts/components.mdx+++ b/docs/astro/src/content/docs/zh/core-concepts/components.mdx@@ -17,7 +17,7 @@ import { Aside } from '@astrojs/starlight/components';| 属性 | 类型 | 说明 ||------|------|------|-| `position` | Vec3 | 世界坐标 `{ x, y, z }` |+| `position` | Vec3 | 局部坐标 `{ x, y, z }` || `rotation` | Quat | 四元数 `{ w, x, y, z }` || `scale` | Vec3 | 缩放因子 `{ x, y, z }` |@@ -31,9 +31,9 @@ import { Aside } from '@astrojs/starlight/components';| 属性 | 类型 | 说明 ||------|------|------|-| `projectionType` | number | 0 = 透视,1 = 正交 |+| `projectionType` | ProjectionType | `Orthographic` — 使用 `ProjectionType.Perspective` (0) 或 `ProjectionType.Orthographic` (1) || `fov` | number | 视角角度(仅透视) |-| `orthoSize` | number | 半高世界单位(仅正交) |+| `orthoSize` | number | 半高世界单位(仅正交)。默认:`540` || `nearPlane` | number | 近裁剪面 || `farPlane` | number | 远裁剪面 || `isActive` | boolean | 是否用于渲染 |@@ -43,7 +43,7 @@ import { Aside } from '@astrojs/starlight/components';| `viewportY` | number | 视口底边缘(0–1)。默认:0 || `viewportW` | number | 视口宽度(0–1)。默认:1 || `viewportH` | number | 视口高度(0–1)。默认:1 |-| `clearFlags` | number | 缓冲区清除模式:0=无, 1=颜色, 2=深度, 3=两者 |+| `clearFlags` | ClearFlags | `ClearFlags.ColorAndDepth` (3) — `None` (0)、`ColorOnly` (1)、`DepthOnly` (2)、`ColorAndDepth` (3) || `showFrustum` | boolean | 在编辑器中显示相机视锥线框 |### Canvas@@ -54,7 +54,7 @@ import { Aside } from '@astrojs/starlight/components';|------|------|------|| `designResolution` | Vec2 | 设计分辨率 `{ x, y }` || `pixelsPerUnit` | number | 每世界单位像素数 |-| `scaleMode` | number | 画布缩放模式 |+| `scaleMode` | ScaleMode | `ScaleMode.FixedHeight` (1) — `FixedWidth` (0)、`FixedHeight` (1)、`Expand` (2)、`Shrink` (3)、`Match` (4) || `matchWidthOrHeight` | number | 宽高匹配平衡 || `backgroundColor` | Color | 清屏颜色 RGBA |diff --git a/docs/astro/src/content/docs/zh/core-concepts/queries.mdx b/docs/astro/src/content/docs/zh/core-concepts/queries.mdxindex 0a6c3c98f..158a198f5 100644--- a/docs/astro/src/content/docs/zh/core-concepts/queries.mdx+++ b/docs/astro/src/content/docs/zh/core-concepts/queries.mdx@@ -59,7 +59,7 @@ query.forEach((entity, transform, sprite) => {### single-获取唯一匹配的实体。如果有零个或多个匹配则返回 `null`。+获取第一个匹配的实体。如果没有匹配的实体则返回 `null`。```typescriptconst result = query.single();diff --git a/docs/astro/src/content/docs/zh/core-concepts/systems.mdx b/docs/astro/src/content/docs/zh/core-concepts/systems.mdxindex b7aafd9c1..45309f8cd 100644--- a/docs/astro/src/content/docs/zh/core-concepts/systems.mdx+++ b/docs/astro/src/content/docs/zh/core-concepts/systems.mdx@@ -57,7 +57,11 @@ addSystemToSchedule(Schedule.FixedUpdate, physicsSystem);| `FixedPostUpdate` | 固定间隔,FixedUpdate 之后 |<Aside type="note">- Fixed 系列调度(`FixedPreUpdate`、`FixedUpdate`、`FixedPostUpdate`)以 1/60s 固定步长运行,使用累加器驱动。一帧内可能执行零次或多次,取决于帧时长。适用于物理等需要一致时间步的确定性逻辑。+ Fixed 系列调度(`FixedPreUpdate`、`FixedUpdate`、`FixedPostUpdate`)以 1/60s 固定步长运行,使用累加器驱动。一帧内可能执行零次或多次,取决于帧时长,每帧最多执行 **8 次迭代**。适用于物理等需要一致时间步的确定性逻辑。+</Aside>++<Aside type="note">+ Delta time 被限制为最大 **250ms**(0.25s)。如果一帧用时更长(例如标签页不活跃),多余的时间会被丢弃以防止模拟出现大跳变。</Aside>## 系统参数@@ -78,7 +82,7 @@ defineSystem([Commands()], (cmds) => {// 修改已有实体cmds.entity(bullet)- .insert(Velocity, { linear: { x: 100, y: 0 } })+ .insert(Velocity, { linear: { x: 100, y: 0, z: 0 } }).remove(Sprite);// 销毁实体@@ -191,6 +195,10 @@ addSystem(defineSystem());```+## 错误处理++每个系统在独立的 try/catch 边界内运行。如果系统抛出错误,会被捕获并输出到控制台,不会导致整个游戏循环崩溃。其他系统继续正常执行。+## 下一步- [查询](/microes/zh/core-concepts/queries/) — 查询过滤器和迭代方法diff --git a/docs/astro/src/content/docs/zh/getting-started/quick-start.mdx b/docs/astro/src/content/docs/zh/getting-started/quick-start.mdxindex 242fc9982..d7866c428 100644--- a/docs/astro/src/content/docs/zh/getting-started/quick-start.mdx+++ b/docs/astro/src/content/docs/zh/getting-started/quick-start.mdx@@ -110,6 +110,8 @@ addSystemToSchedule(Schedule.FixedUpdate, system); // 固定间隔运行需要在运行时创建实体时(如子弹、粒子),使用 `Commands`:```typescript+import { addStartupSystem, defineSystem, Commands, Sprite, LocalTransform } from 'esengine';+addStartupSystem(defineSystem([Commands()],(cmds) => {diff --git a/docs/astro/src/content/docs/zh/guides/assets.mdx b/docs/astro/src/content/docs/zh/guides/assets.mdxindex 319b54dcf..ac511d767 100644--- a/docs/astro/src/content/docs/zh/guides/assets.mdx+++ b/docs/astro/src/content/docs/zh/guides/assets.mdx@@ -88,10 +88,6 @@ const fontHandle = await assets.loadBitmapFont('assets/my-font.fnt');| `getFont(path)` | `number \| undefined` | 获取已缓存的字体句柄,未加载则返回 `undefined` || `releaseFont(path)` | `void` | 从内存中释放字体及其纹理 |-<Aside type="note">- `loadAll` 目前不支持位图字体,需要使用 `loadBitmapFont` 单独加载。-</Aside>-## 预制体加载```typescript@@ -129,40 +125,37 @@ const data = await assets.loadBinary('assets/tilemap.bin');## 批量加载-使用 `loadAll` 并行加载多种资源:+使用 `loadAll` 从 `AddressableManifest` 并行加载所有资源:```typescript-const bundle = await assets.loadAll({- textures: ['assets/bg.png', 'assets/player.png'],- spine: [{ skeleton: 'assets/hero.json', atlas: 'assets/hero.atlas' }],- json: ['assets/config.json'],-});+const manifest = await assets.loadJson('assets/addressable-manifest.json');+assets.setAddressableManifest(manifest);++const bundle = await assets.loadAll(manifest);// 从 bundle 中访问已加载的资源-const bgTex = bundle.textures.get('assets/bg.png');-const config = bundle.json.get('assets/config.json');+const bgTex = bundle.textures.get('bg');+const config = bundle.json.get('game-config');```-### AssetManifest+也可以按标签或分组加载部分资源:-| 字段 | 类型 | 说明 |-|------|------|------|-| `textures` | string[] | 纹理图片路径 |-| `materials` | string[] | 材质文件路径(.esmaterial) |-| `spine` | SpineDescriptor[] | Spine 骨骼/图集对 |-| `json` | string[] | JSON 文件路径 |-| `text` | string[] | 文本文件路径 |-| `binary` | string[] | 二进制文件路径 |+```typescript+const bundle = await assets.loadByLabel('ui-sprites');+const levelBundle = await assets.loadGroup('level-1');+```### AssetBundle-返回的 `AssetBundle` 包含以路径为键的 Map:+返回的 `AssetBundle` 包含以地址(无地址时以路径)为键的 Map:| 字段 | 类型 ||------|------|| `textures` | `Map<string, TextureInfo>` || `materials` | `Map<string, LoadedMaterial>` || `spine` | `Map<string, SpineLoadResult>` |+| `fonts` | `Map<string, FontHandle>` |+| `prefabs` | `Map<string, PrefabData>` || `json` | `Map<string, unknown>` || `text` | `Map<string, string>` || `binary` | `Map<string, ArrayBuffer>` |@@ -207,7 +200,7 @@ Addressable 资产允许通过逻辑地址、标签或分组加载资源,而### 按地址加载```typescript-const texture = await assets.loadByAddress('player-idle');+const texture = await assets.load('player-idle');```### 按标签加载@@ -240,6 +233,38 @@ const manifest = await assets.loadJson('assets/addressable-manifest.json');assets.setAddressableManifest(manifest);```+### 清单格式++`AddressableManifest` 的结构如下:++```typescript+interface AddressableManifest {+ version: '2.0';+ groups: Record<string, AddressableManifestGroup>;+}++interface AddressableManifestGroup {+ bundleMode: string;+ labels: string[];+ assets: Record<string, AddressableManifestAsset>;+}++interface AddressableManifestAsset {+ path: string;+ address?: string;+ type: AddressableAssetType;+ size: number;+ labels: string[];+ metadata?: {+ atlas?: string;+ atlasPage?: number;+ atlasFrame?: { x: number; y: number; width: number; height: number };+ };+}+```++每个分组包含资产及其路径、可选地址、标签和类型特定的元数据。资产类型包括 `texture`、`material`、`spine`、`bitmap-font`、`prefab`、`json`、`text`、`binary` 和 `audio`。+<Aside type="note">Addressable 的地址、标签和分组在编辑器的 Addressable 面板中配置。清单在构建时自动生成。</Aside>diff --git a/docs/astro/src/content/docs/zh/guides/bitmap-text.mdx b/docs/astro/src/content/docs/zh/guides/bitmap-text.mdxindex 50cdd8d06..d5f6c3754 100644--- a/docs/astro/src/content/docs/zh/guides/bitmap-text.mdx+++ b/docs/astro/src/content/docs/zh/guides/bitmap-text.mdx@@ -21,7 +21,7 @@ import { Aside } from '@astrojs/starlight/components';| `align` | number | `0` | 水平对齐:0=左对齐,1=居中,2=右对齐 || `spacing` | number | `0` | 字符间额外间距(像素) || `layer` | number | `0` | 渲染层级,用于绘制排序 |-| `font` | number | `0` | `assets.loadBitmapFont()` 返回的字体句柄 |+| `font` | number | `INVALID_FONT` | `assets.loadBitmapFont()` 返回的字体句柄 |## 字体格式diff --git a/docs/astro/src/content/docs/zh/guides/building.mdx b/docs/astro/src/content/docs/zh/guides/building.mdxnew file mode 100644index 000000000..5b1d06177--- /dev/null+++ b/docs/astro/src/content/docs/zh/guides/building.mdx@@ -0,0 +1,199 @@+---+title: 构建+description: 将 ESEngine 项目构建到不同平台+---++import { Aside } from '@astrojs/starlight/components';++ESEngine 项目可以从编辑器构建到两个目标平台:**可玩广告**(单个自包含 HTML 文件)和**微信小游戏**(可直接在微信开发者工具中打开的目录结构)。++## 构建目标++| 平台 | 输出 | 说明 |+|------|------|------|+| 可玩广告 | 单个 `.html` 文件 | 所有资源、WASM 和脚本内联到一个文件中。适用于要求单文件交付的广告平台。 |+| 微信小游戏 | 目录 | 包含 `game.js`、`game.json`、`project.config.json`、场景文件和资源。可直接在微信开发者工具中打开。 |++## 使用构建面板++从编辑器工具栏打开**构建**面板。面板采用三栏布局:++1. **左侧边栏** — 列出平台和构建配置。点击平台进行筛选,然后选择一个配置。+2. **中间详情** — 显示所选配置的设置:场景列表、脚本定义和平台专属选项。+3. **右侧输出** — 显示构建历史、状态、输出大小和操作按钮(打开文件夹、预览)。++### 创建构建配置++点击工具栏中的**添加**来创建新配置。选择名称和目标平台。编辑器还提供了预置的**模板**(通过模板按钮访问),包含"可玩广告生产版"或"微信开发版"等常用配置。++### 执行构建++1. 从侧边栏选择一个配置+2. 检查场景列表——点击**添加当前场景**可以将编辑器中当前打开的场景加入列表+3. 根据需要调整平台专属设置+4. 点击**构建**(或按 `Cmd/Ctrl + B`)++构建进度和日志通过 Toast 通知实时显示。构建完成后,可以点击**打开文件夹**导航到输出位置。++<Aside type="tip">+ 使用**全部构建**可以依次构建所有配置。这在同时需要开发版和生产版构建时很有用。+</Aside>++## 构建配置++每个配置包含:++| 设置 | 作用 |+|------|------|+| **名称** | 此配置的可读标签 |+| **平台** | 目标平台:可玩广告或微信小游戏 |+| **场景** | 要包含在构建中的 `.esscene` 文件列表 |+| **脚本定义** | 编译时定义(如 `DEBUG`)。可在脚本中通过 `process.env.DEBUG` 访问。 |+| **平台设置** | 平台专属选项(见下文) |++### 可玩广告设置++| 设置 | 描述 |+|------|------|+| **启动场景** | 启动时加载的场景(默认为列表中的第一个场景) |+| **开发构建** | 在输出中包含调试信息 |+| **代码压缩** | 压缩打包后的 JavaScript 以减小体积 |+| **嵌入字体** | 将字体文件内联到 HTML 中 |+| **输出路径** | 输出 `.html` 文件的写入位置(如 `build/playable.html`) |+| **启用内置 CTA** | 显示内置的 "Install Now" 行动号召按钮 |+| **CTA URL** | 点击 CTA 按钮时打开的目标 URL |++<Aside type="note">+ 可玩广告将所有内容嵌入到单个 HTML 文件中——WASM 二进制、纹理、场景数据和脚本都以 base64 编码内联。+</Aside>++### 微信小游戏设置++| 设置 | 描述 |+|------|------|+| **AppID** | 微信小游戏 AppID。测试时可使用 `touristappid`(无需注册应用)。 |+| **版本** | 版本字符串(如 `1.0.0`) |+| **屏幕方向** | `竖屏`(Portrait)或 `横屏`(Landscape) |+| **打包模式** | `分包`(推荐)、`单包` 或 `单文件` |+| **输出目录** | 输出目录的写入位置(如 `build/wechat`) |++## 资源导出配置++构建系统通过三种模式决定包含哪些资源,可在编辑器中按文件夹配置:++| 模式 | 行为 |+|------|------|+| `auto`(默认) | 仅包含在构建场景或预制体中被引用的资源 |+| `always` | 无论是否被引用,始终包含该文件夹下所有资源 |+| `exclude` | 永不包含该文件夹下的资源 |++资源导出模式存储在 `.esengine/asset-export.json` 中:++```json+{+ "version": "1.0",+ "folders": {+ "assets/ui": "always",+ "assets/debug": "exclude"+ }+}+```++文件夹会继承父级的模式。例如,如果 `assets/sprites` 设为 `always`,`assets/sprites/enemies/` 下的所有文件也会被包含。++## 构建流程++点击构建后,编辑器会运行以下流水线:++### 1. 资源收集++构建扫描场景文件并递归收集:++- `Sprite`、`SpineRenderer` 等组件引用的纹理+- 材质及其着色器依赖+- Spine 图集文件及其纹理页+- 位图字体文件及其字形纹理+- 嵌套预制体及其传递性资源引用++### 2. 图集打包++引用的图片会被打包到纹理图集页中(默认最大 2048x2048)。场景数据会被重写为使用图集坐标,运行时精灵会自动引用打包后的图集。++### 3. 材质编译++`.esmaterial` 文件被编译为 JSON,解析着色器引用并内联属性值。++### 4. 脚本打包++`src/` 目录下的用户脚本通过 esbuild 编译打包。`esengine` SDK 作为外部模块处理——在可玩广告中内联,在微信小游戏中从 `sdk.js` 加载。++### 5. 平台输出++为目标平台生成最终产物:++- **可玩广告** — 将所有资源 base64 编码内联,组装成单个 HTML 文件+- **微信小游戏** — 写入包含 `game.js`、`game.json`、`project.config.json`、场景、资源和 WASM 文件的目录++## 输出结构++### 可玩广告++```+build/+ playable.html # 单个自包含文件+```++### 微信小游戏++```+build/wechat/+ project.config.json # 微信开发者工具项目配置+ game.json # 小游戏清单+ game.js # 入口文件(引擎初始化 + 用户脚本)+ esengine.js # WASM 引擎加载器+ esengine.wasm # 引擎 WASM 二进制+ sdk.js # SDK 运行时+ spine.js / spine.wasm # Spine 运行时(如果启用了 Spine)+ physics.js / physics.wasm # 物理引擎(如果启用了物理)+ atlas_0.png # 打包的纹理图集页+ asset-manifest.json # 可寻址资源清单+ scenes/+ Level1.json # 导出的场景数据+ assets/+ ... # 未打包的资源文件+```++## 可寻址清单++两个平台都会生成 `asset-manifest.json`,将资源 UUID 映射到运行时路径。这使运行时能够通过 UUID 或地址解析资源,并从打包的图集页中重建图集帧。++```json+{+ "version": "2.0",+ "groups": {+ "default": {+ "bundleMode": "together",+ "labels": [],+ "assets": {+ "uuid-1": {+ "path": "assets/sprites/player.png",+ "type": "texture",+ "size": 1024,+ "labels": ["character"]+ }+ }+ }+ }+}+```++## 项目设置++构建行为还受项目级设置的影响:++| 设置 | 效果 |+|------|------|+| Spine 版本 | 在构建中包含 Spine 运行时 WASM 模块 |+| 启用物理 | 在构建中包含物理 WASM 模块并生成物理配置 |+| 物理重力 | 在物理配置中设置重力向量 |+| 物理时间步 | 设置固定的物理模拟时间步长 |diff --git a/docs/astro/src/content/docs/zh/guides/canvas.mdx b/docs/astro/src/content/docs/zh/guides/canvas.mdxindex e245a999a..b49956c37 100644--- a/docs/astro/src/content/docs/zh/guides/canvas.mdx+++ b/docs/astro/src/content/docs/zh/guides/canvas.mdx@@ -19,7 +19,7 @@ import { Aside } from '@astrojs/starlight/components';|------|------|--------|------|| `designResolution` | Vec2 | `{x: 1920, y: 1080}` | 游戏设计基准分辨率 || `pixelsPerUnit` | number | `100` | 多少像素等于一个世界单位 |-| `scaleMode` | number | `1` | 缩放策略(见下文) |+| `scaleMode` | ScaleMode | `FixedHeight` (1) | 缩放策略(见下文)。从 `'esengine'` 导入 `ScaleMode` || `matchWidthOrHeight` | number | `0.5` | Match 模式的混合系数(0 = 宽度,1 = 高度) || `backgroundColor` | Color | `{r: 0, g: 0, b: 0, a: 1}` | 黑边填充颜色 |@@ -68,13 +68,13 @@ import { Aside } from '@astrojs/starlight/components';在系统中查询 `Canvas` 组件:```typescript-import { defineSystem, addSystem, Query, Mut, Canvas } from 'esengine';+import { defineSystem, addSystem, Query, Mut, Canvas, ScaleMode } from 'esengine';addSystem(defineSystem([Query(Mut(Canvas))],(query) => {for (const [entity, canvas] of query) {- canvas.scaleMode = 4;+ canvas.scaleMode = ScaleMode.Match;canvas.matchWidthOrHeight = 0.5;}}diff --git a/docs/astro/src/content/docs/zh/guides/custom-draw.mdx b/docs/astro/src/content/docs/zh/guides/custom-draw.mdxindex 32028963e..d11a8cf52 100644--- a/docs/astro/src/content/docs/zh/guides/custom-draw.mdx+++ b/docs/astro/src/content/docs/zh/guides/custom-draw.mdx@@ -166,20 +166,21 @@ const primitives = Draw.getPrimitiveCount();```typescriptimport { registerDrawCallback, Draw } from 'esengine';-import { defineSystem, addSystem, Query, LocalTransform, Collider } from 'esengine';+import { defineSystem, addSystem, Query, LocalTransform } from 'esengine';+import { BoxCollider } from 'esengine/physics';-const colliders: Array<{ x: number; y: number; w: number; h: number }> = [];+const boxes: Array<{ x: number; y: number; w: number; h: number }> = [];addSystem(defineSystem(- [Query(LocalTransform, Collider)],+ [Query(LocalTransform, BoxCollider)],(query) => {- colliders.length = 0;+ boxes.length = 0;for (const [entity, transform, collider] of query) {- colliders.push({- x: transform.position.x,- y: transform.position.y,- w: collider.width,- h: collider.height,+ boxes.push({+ x: transform.position.x + collider.offset.x,+ y: transform.position.y + collider.offset.y,+ w: collider.halfExtents.x * 2,+ h: collider.halfExtents.y * 2,});}}@@ -187,7 +188,7 @@ addSystem(defineSystem(registerDrawCallback('debug-colliders', () => {const green = { r: 0, g: 1, b: 0, a: 0.5 };- for (const c of colliders) {+ for (const c of boxes) {Draw.rectOutline({ x: c.x, y: c.y },{ x: c.w, y: c.h },diff --git a/docs/astro/src/content/docs/zh/guides/input.mdx b/docs/astro/src/content/docs/zh/guides/input.mdxindex 60baebc03..ac8d8e993 100644--- a/docs/astro/src/content/docs/zh/guides/input.mdx+++ b/docs/astro/src/content/docs/zh/guides/input.mdx@@ -172,3 +172,9 @@ addSystem(defineSystem(}));```++## 下一步++- [UI 与文本](/microes/zh/guides/ui/) — UI 交互事件(点击、悬停、按压)+- [物理](/microes/zh/guides/physics/) — 物理驱动的运动和碰撞+- [系统](/microes/zh/core-concepts/systems/) — 定义和调度系统diff --git a/docs/astro/src/content/docs/zh/guides/materials.mdx b/docs/astro/src/content/docs/zh/guides/materials.mdxindex 1c5297ca4..6be2a36b4 100644--- a/docs/astro/src/content/docs/zh/guides/materials.mdx+++ b/docs/astro/src/content/docs/zh/guides/materials.mdx@@ -207,7 +207,7 @@ sprite.material = loaded.handle;```typescriptimport { defineSystem, addSystem, Query, Mut, Res } from 'esengine';-import { Sprite, Material, BlendMode, Time } from 'esengine';+import { Sprite, Material, BlendMode, ShaderSources, Time } from 'esengine';const flashShader = Material.createShader(ShaderSources.SPRITE_VERTEX,diff --git a/docs/astro/src/content/docs/zh/guides/playable-ads.mdx b/docs/astro/src/content/docs/zh/guides/playable-ads.mdxnew file mode 100644index 000000000..820af23dc--- /dev/null+++ b/docs/astro/src/content/docs/zh/guides/playable-ads.mdx@@ -0,0 +1,155 @@+---+title: 可玩广告+description: 使用 ESEngine 构建单文件 HTML 可玩广告+---++import { Aside } from '@astrojs/starlight/components';++ESEngine 可以将游戏导出为单个自包含的 HTML 文件,适用于各种可玩广告网络(Facebook、Google、Unity Ads、IronSource、AppLovin 等)。++## 构建可玩广告++### 1. 打开构建面板++从编辑器工具栏打开**构建**面板,选择或创建一个可玩广告配置。++### 2. 配置设置++| 设置 | 描述 |+|------|------|+| **启动场景** | 启动时加载的场景(默认为列表中的第一个场景) |+| **开发构建** | 包含调试信息——便于测试,正式发布时应关闭 |+| **代码压缩** | 压缩 JavaScript 以减小体积。正式构建时应启用。 |+| **嵌入字体** | 将字体文件内联到 HTML 中 |+| **输出路径** | 输出文件的写入位置(如 `build/playable.html`) |+| **启用内置 CTA** | 显示内置的 "Install Now" 按钮 |+| **CTA URL** | 点击 CTA 按钮时打开的 URL |++### 3. 添加场景++确保启动场景已列在场景列表中。只有构建中场景引用的资源才会嵌入到输出文件中。++### 4. 点击构建++点击**构建**或按 `Cmd/Ctrl + B`。编辑器将收集资源、打包纹理、编译脚本,并组装单个 HTML 文件。构建进度和输出大小会实时显示。++## 工作原理++可玩广告的构建流程:++1. 将 WASM 引擎、SDK 和用户脚本打包为内联 `<script>` 标签+2. 将所有引用的资源(纹理、Spine 数据、材质、预制体)编码为 base64 数据 URI 嵌入+3. 嵌入启动场景 JSON 和可寻址资源清单+4. 生成一个没有任何外部依赖的 `.html` 文件++在运行时,资源加载调用会自动从嵌入数据中读取——与 Web 构建相比无需任何代码修改。++## 测试输出++构建完成后:++1. 点击构建输出面板中的**打开文件夹**找到 HTML 文件+2. 在浏览器中直接打开 `.html` 文件进行测试+3. 使用浏览器开发者工具检查控制台输出和性能++<Aside type="tip">+ 快速测试时,可以点击构建输出面板中的**预览**直接打开 HTML 文件。+</Aside>++你也可以使用广告网络的预览工具进行测试:+- **Facebook**:[可玩广告预览工具](https://www.facebook.com/business/help/412951382532338)+- **Google**:上传到 Google Ads 并使用预览功能+- **Unity Ads**:Unity Ads 后台预览++## CTA 按钮++可选的内置 CTA(行动号召)按钮会以固定定位显示在屏幕底部的 "Install Now" 按钮。在构建设置中启用后:++- 按钮在加载过程中隐藏,游戏启动后显示+- 点击时通过 MRAID(`mraid.open()`)打开 CTA URL,如果 MRAID 不可用则使用 `window.open()`++<Aside type="tip">+ 大多数广告网络会提供自己的 CTA 机制。你可以保持内置 CTA 关闭,在游戏脚本中直接使用广告网络的 SDK 或 MRAID API。+</Aside>++### MRAID 集成++[MRAID](https://www.iab.com/guidelines/mraid/)(Mobile Rich-media Ad Interface Definitions)是广告 SDK 使用的标准 API。内置 CTA 在 MRAID 可用时会自动使用它。++如果需要更深层次的 MRAID 集成(如响应 `viewableChange` 事件),可以在脚本中使用启动系统:++```typescript+import { addStartupSystem, defineSystem } from 'esengine';++addStartupSystem(defineSystem([], () => {+ const mraid = (window as any).mraid;+ if (!mraid) return;++ mraid.addEventListener('viewableChange', (viewable: boolean) => {+ if (viewable) {+ // 广告变为可见——开始游戏+ }+ });+}));+```++## 资源嵌入++启动场景引用的所有资源会被自动嵌入:++- **纹理**:编码为 `data:image/png;base64,...`+- **JSON 文件**(材质、预制体、配置):编码为 `data:application/json;base64,...`+- **Spine 数据**(图集、骨骼):编码为 base64 数据 URI+- **纹理图集**:图集页面嵌入为 PNG 数据 URI++<Aside type="note">+ 未被启动场景引用的资源不会被包含。使用可寻址资源组并将导出模式设为 "always" 可以强制包含运行时动态加载的资源。+</Aside>++## Spine 与物理支持++如果项目使用了 Spine 动画或 Box2D 物理,对应的 WASM 模块会被自动嵌入为 base64 并在运行时实例化。无需额外配置——构建会检测项目设置中是否启用了 Spine 或物理。++## 体积优化++可玩广告网络通常有文件大小限制(2-5 MB)。以下是减小输出体积的建议:++1. **压缩纹理**:使用小尺寸、压缩过的 PNG/JPG 文件。图集打包器可以帮助合并纹理。+2. **启用代码压缩**:在构建设置中开启**代码压缩**。+3. **简化场景**:更少的实体和组件意味着更小的场景 JSON。+4. **移除未使用的资源引用**:只有启动场景引用的资源会被嵌入,删除不需要的资源引用。+5. **优化 Spine 数据**:使用二进制 `.skel` 文件而非 JSON 骨骼。减少骨骼和动画数量。+6. **考虑禁用物理**:如果广告不需要物理效果,在项目设置中禁用物理可以排除物理 WASM 模块,显著减小体积。++## 输出结构++生成的 HTML 遵循以下结构:++```html+<!DOCTYPE html>+<html>+<head>+ <meta name="ad.size" content="width=320,height=480">+ <style>/* 全屏 canvas + 可选的 CTA 样式 */</style>+</head>+<body>+ <canvas id="canvas"></canvas>+ <script>/* WASM 引擎 + SDK(内联) */</script>+ <script>/* Spine 模块(如使用) */</script>+ <script>/* 物理模块(如使用) */</script>+ <script>/* 用户游戏代码(编译 + 打包) */</script>+ <script>+ var __PA__ = { /* 嵌入的资源数据 URI */ };+ var __SCENE__ = { /* 启动场景 JSON */ };+ var __MANIFEST__ = { /* 可寻址资源清单 */ };+ // ... 初始化和场景加载+ </script>+</body>+</html>+```++## 下一步++- [构建与导出](/microes/zh/guides/building/) -- 构建流水线概览+- [微信小游戏](/microes/zh/guides/wechat/) -- 微信小游戏构建+- [资源加载](/microes/zh/guides/assets/) -- 资源加载 APIdiff --git a/docs/astro/src/content/docs/zh/guides/plugins.mdx b/docs/astro/src/content/docs/zh/guides/plugins.mdxnew file mode 100644index 000000000..98e645a42--- /dev/null+++ b/docs/astro/src/content/docs/zh/guides/plugins.mdx@@ -0,0 +1,181 @@+---+title: 插件系统+description: 使用插件系统扩展 ESEngine+---++import { Aside } from '@astrojs/starlight/components';++**插件系统**将引擎功能组织为可复用的模块。每个插件提供一组组件、系统和资源。ESEngine 内置了多个插件,它们会自动安装——你无需手动配置。++## 内置插件++在编辑器中创建项目时,所有内置插件默认处于激活状态。它们提供了你在检查器(Inspector)中看到的组件,以及驱动引擎每帧行为的系统。++### 核心插件++| 插件 | 提供的功能 |+|------|-----------|+| 资源加载 | `AssetServer`,用于在运行时加载纹理、Spine 数据、预制体等资源 |+| 预制体 | `PrefabServer`,用于实例化预制体 |+| 输入 | `InputState`,包含键盘、鼠标和触摸输入——每帧末尾清除 |++### UI 插件++| 插件 | 组件 |+|------|------|+| 文本 | `Text` — 每帧将文本内容渲染为精灵纹理 |+| UI 遮罩 | `UIMask` — 基于模板测试的 UI 元素遮罩 |+| UI 布局 | `UIRect`、`ScreenSpace` — 相对于相机的锚点 UI 布局 |+| UI 交互 | `Interactable`、`Button`、`UIInteraction`、`UIEvents` — 指针命中测试和按钮状态 |+| 文本输入 | `TextInput` — 可编辑的文本输入框,使用平台原生输入 |++以上插件在每个项目中默认激活。你可以直接从编辑器的组件选择器中使用它们的组件——无需任何设置。++## 用户脚本++扩展游戏的主要方式是在项目的 `src/` 目录中编写 TypeScript 脚本。脚本会被自动编译并包含在构建产物中。++### 自定义组件++使用 `defineComponent()` 创建可在编辑器检查器中显示的组件:++```typescript+import { defineComponent } from 'esengine';++const Health = defineComponent('Health', {+ hp: 100,+ maxHp: 100,+});+```++定义后,`Health` 会出现在编辑器的**添加组件**菜单中。你可以像内置组件一样将其添加到实体并在检查器中编辑属性。++使用 `defineTag()` 创建无数据的标记组件:++```typescript+import { defineTag } from 'esengine';++const Enemy = defineTag('Enemy');+```++### 系统++使用 `defineSystem()` 和 `addSystem()` 添加每帧执行的游戏逻辑:++```typescript+import { defineSystem, addSystem, Schedule } from 'esengine';++addSystem(defineSystem([], (world) => {+ // 每帧在 Update 阶段执行+}));+```++你也可以指定特定的调度阶段:++```typescript+import { addSystemToSchedule, defineSystem, Schedule } from 'esengine';++addSystemToSchedule(Schedule.FixedUpdate, defineSystem([], (world) => {+ // 以固定时间步执行,适合物理逻辑+}));+```++对于一次性初始化,使用 `addStartupSystem()`:++```typescript+import { addStartupSystem, defineSystem } from 'esengine';++addStartupSystem(defineSystem([], (world) => {+ // 游戏启动时执行一次+}));+```++<Aside type="tip">+ `src/` 目录中的脚本会被构建流水线自动发现。你无需在任何地方注册它们——只需创建 `.ts` 文件即可被自动包含。+</Aside>++### 资源++资源是可在系统间共享的全局单例数据:++```typescript+import { defineResource, addStartupSystem, defineSystem } from 'esengine';++const GameState = defineResource<{ score: number; level: number }>(+ { score: 0, level: 1 },+ 'GameState'+);++addStartupSystem(defineSystem([], (world) => {+ world.app.insertResource(GameState, { score: 0, level: 1 });+}));+```++## 系统调度++系统按照定义的顺序在每帧中执行:++| 阶段 | 执行时机 |+|------|---------|+| `Startup` | 游戏启动时执行一次 |+| `First` | 每帧开始 |+| `FixedPreUpdate` | 固定时间步更新之前 |+| `FixedUpdate` | 固定时间步更新(物理) |+| `FixedPostUpdate` | 固定时间步更新之后 |+| `PreUpdate` | 主更新之前 |+| `Update` | 主更新(`addSystem` 的默认阶段) |+| `PostUpdate` | 主更新之后 |+| `Last` | 每帧结束 |++## 进阶:插件接口++<Aside type="note">+ 本节面向需要创建可复用插件包的高级用户。大多数用户只需按上述方式在 `src/` 中编写脚本即可。+</Aside>++插件是实现了 `Plugin` 接口的对象:++```typescript+import { type Plugin, type App, defineResource, defineSystem, Schedule, registerComponent } from 'esengine';++const ScoreData = defineResource<{ value: number }>({ value: 0 }, 'Score');++const myPlugin: Plugin = {+ name: 'MyGamePlugin',+ build(app: App) {+ app.insertResource(ScoreData, { value: 0 });+ registerComponent('Health', { hp: 100, maxHp: 100 });+ app.addSystemToSchedule(Schedule.Update, defineSystem([], () => {+ // 游戏逻辑+ }));+ },+};+```++插件可以声明资源依赖:++```typescript+const analyticsPlugin: Plugin = {+ name: 'AnalyticsPlugin',+ dependencies: [Assets],+ build(app: App) {+ const assets = app.getResource(Assets);+ // 使用资源服务器...+ },+};+```++### SDK 入口++对于不使用编辑器的独立应用开发者,ESEngine 提供两种入口:++- **`esengine`** — 完整 SDK,包含所有 UI 插件+- **`esengine/core`** — 基础 SDK,不含 UI 插件,适用于不需要 UI 时减小包体积++```typescript+import { createWebApp } from 'esengine/core';++const app = createWebApp(module, {+ plugins: [textPlugin, uiLayoutPlugin],+});+```diff --git a/docs/astro/src/content/docs/zh/guides/prefabs.mdx b/docs/astro/src/content/docs/zh/guides/prefabs.mdxindex 4a3ce2e24..a9576a48b 100644--- a/docs/astro/src/content/docs/zh/guides/prefabs.mdx+++ b/docs/astro/src/content/docs/zh/guides/prefabs.mdx@@ -25,7 +25,7 @@ import { Aside } from '@astrojs/starlight/components';### 编辑预制体-在内容浏览器中双击 `.esprefab` 文件进入**预制体编辑模式**。编辑器会将预制体加载为临时场景,你可以直接修改实体。退出时更改会保存回 `.esprefab` 文件。+在内容浏览器中双击 `.esprefab` 文件进入**预制体编辑模式**。编辑器会将预制体加载为临时场景,你可以直接修改实体。退出时更改会保存回 `.esprefab` 文件,当前场景中的所有实例会自动同步更新。### 属性覆盖@@ -39,7 +39,11 @@ import { Aside } from '@astrojs/starlight/components';## 运行时 API-使用 `Prefabs` 资源在系统中加载和实例化预制体,一次调用完成资源加载和实体创建:+使用 `Prefabs` 资源在系统中加载和实例化预制体,一次调用完成资源加载和实体创建。++<Aside type="note">+ 使用 `createWebApp()` 时 `Prefabs` 资源自动可用 — `PrefabsPlugin` 默认包含在内。+</Aside>```typescriptimport { addStartupSystem, defineSystem, Res, Prefabs } from 'esengine';@@ -47,6 +51,7 @@ import { addStartupSystem, defineSystem, Res, Prefabs } from 'esengine';addStartupSystem(defineSystem([Res(Prefabs)],async (prefabs) => {+ // 支持文件路径或 addressable 地址const { root, entities } = await prefabs.instantiate('prefabs/Enemy.esprefab');}));@@ -99,14 +104,20 @@ const { root } = await prefabs.instantiate('prefabs/Enemy.esprefab', {### 嵌套预制体-预制体可以包含对其他预制体的引用。实例化时,嵌套预制体会被自动加载并展开。这需要在选项中提供 `assetServer`:+预制体可以包含对其他预制体的引用。高层 `prefabs.instantiate()` API 自动处理嵌套预制体 — 所有引用的预制体会递归加载并展开为单一实体树。对于高级用例,可使用底层 `instantiatePrefab()` 函数:```typescript+import { instantiatePrefab } from 'esengine';+const result = await instantiatePrefab(world, prefab, {assetServer: assets,});```+<Aside type="caution">+ 循环预制体引用会被自动检测并跳过,同时输出错误日志,防止无限递归。+</Aside>+<Aside type="note">预制体文件由资源服务器缓存。多次加载同一 `.esprefab` 路径会返回缓存结果。</Aside>diff --git a/docs/astro/src/content/docs/zh/guides/render-texture.mdx b/docs/astro/src/content/docs/zh/guides/render-texture.mdxindex ca53934ca..50ca7351e 100644--- a/docs/astro/src/content/docs/zh/guides/render-texture.mdx+++ b/docs/astro/src/content/docs/zh/guides/render-texture.mdx@@ -38,7 +38,7 @@ import { RenderTexture, Draw } from 'esengine';RenderTexture.begin(rt, viewProjectionMatrix);-Draw.rect(0, 0, 100, 100, { r: 1, g: 0, b: 0, a: 1 });+Draw.rect({ x: 0, y: 0 }, { x: 100, y: 100 }, { r: 1, g: 0, b: 0, a: 1 });RenderTexture.end();```@@ -56,7 +56,7 @@ RenderTexture.end();```typescriptimport { Draw, Sprite } from 'esengine';-Draw.texture(rt.textureId, 0, 0, rt.width, rt.height);+Draw.texture({ x: 0, y: 0 }, { x: rt.width, y: rt.height }, rt.textureId);```也可以将其赋值给 Sprite 的 texture 用于基于实体的渲染。diff --git a/docs/astro/src/content/docs/zh/guides/rendering.mdx b/docs/astro/src/content/docs/zh/guides/rendering.mdxindex c976e251f..0f2e7187f 100644--- a/docs/astro/src/content/docs/zh/guides/rendering.mdx+++ b/docs/astro/src/content/docs/zh/guides/rendering.mdx@@ -17,7 +17,7 @@ ESEngine 使用基于组件的渲染系统。在场景编辑器中为实体添| 属性 | 类型 | 说明 ||------|------|------|-| `projectionType` | number | 0 = 透视,1 = 正交 |+| `projectionType` | ProjectionType | `ProjectionType.Perspective` (0)、`ProjectionType.Orthographic` (1) || `fov` | number | 视角角度(仅透视) || `orthoSize` | number | 半高世界单位(仅正交) || `nearPlane` | number | 近裁剪面 |@@ -29,12 +29,12 @@ ESEngine 使用基于组件的渲染系统。在场景编辑器中为实体添| `viewportY` | number | 视口底边缘(0–1)。默认:0 || `viewportW` | number | 视口宽度(0–1)。默认:1 || `viewportH` | number | 视口高度(0–1)。默认:1 |-| `clearFlags` | number | 缓冲区清除模式:0=无, 1=颜色, 2=深度, 3=两者 |+| `clearFlags` | ClearFlags | `ClearFlags.None` (0)、`ColorOnly` (1)、`DepthOnly` (2)、`ColorAndDepth` (3) || `showFrustum` | boolean | 在编辑器中显示相机视锥线框 |### 正交相机-2D 游戏最佳选择。`orthoSize` 决定可见的世界范围。在检查器中将 `projectionType` 设为 `1`。+2D 游戏最佳选择。`orthoSize` 决定可见的世界范围(默认:`540`)。在检查器中将 `projectionType` 设为 `ProjectionType.Orthographic`。从 `'esengine'` 导入 `ProjectionType` 和 `ClearFlags`。### Canvas 集成@@ -70,7 +70,7 @@ addSystem(defineSystem(创建两个 Camera 实体:- 主相机:视口 `(0, 0, 1, 1)`,`priority: 0`-- 小地图相机:视口 `(0.75, 0.75, 0.25, 0.25)`,`priority: 1`,`clearFlags: 3`+- 小地图相机:视口 `(0.75, 0.75, 0.25, 0.25)`,`priority: 1`,`clearFlags: ClearFlags.ColorAndDepth`小地图在右上角渲染,覆盖在主视图之上。diff --git a/docs/astro/src/content/docs/zh/guides/scenes.mdx b/docs/astro/src/content/docs/zh/guides/scenes.mdxindex 558d8e091..6bfb65bce 100644--- a/docs/astro/src/content/docs/zh/guides/scenes.mdx+++ b/docs/astro/src/content/docs/zh/guides/scenes.mdx@@ -111,7 +111,7 @@ addSystem(defineSystem(import { defineSystem, addSystem, Commands, LocalTransform, Sprite } from 'esengine';addSystem(defineSystem(- [Commands],+ [Commands()],(commands) => {// 生成一个带组件的新实体commands.spawn()diff --git a/docs/astro/src/content/docs/zh/guides/spine.mdx b/docs/astro/src/content/docs/zh/guides/spine.mdxindex 9c091b0da..c1600be53 100644--- a/docs/astro/src/content/docs/zh/guides/spine.mdx+++ b/docs/astro/src/content/docs/zh/guides/spine.mdx@@ -137,6 +137,10 @@ addSystem(defineSystem());```+## 多纹理批处理++使用多个图集页的 Spine 骨骼会被渲染器自动批处理。无需额外配置 — C++ 后端透明地处理多纹理情况,即使是复杂的多图集角色也能保持较低的 draw call。+<Aside type="tip">Spine 渲染由 C++ 后端处理。TypeScript 只负责设置组件数据 — 引擎自动处理加载、混合和绘制。</Aside>diff --git a/docs/astro/src/content/docs/zh/guides/sprite.mdx b/docs/astro/src/content/docs/zh/guides/sprite.mdxindex 5733e148a..85d042ca2 100644--- a/docs/astro/src/content/docs/zh/guides/sprite.mdx+++ b/docs/astro/src/content/docs/zh/guides/sprite.mdx@@ -13,9 +13,9 @@ import { Aside } from '@astrojs/starlight/components';|------|------|--------|------|| `texture` | number | `INVALID_TEXTURE` | 纹理句柄,无纹理 = 纯色 || `color` | Color | `{r:1, g:1, b:1, a:1}` | 着色 RGBA(0–1) |-| `size` | Vec2 | `{32, 32}` | 宽高(像素) |-| `uvOffset` | Vec2 | `{0, 0}` | 纹理坐标偏移 |-| `uvScale` | Vec2 | `{1, 1}` | 纹理坐标缩放 |+| `size` | Vec2 | `{x: 32, y: 32}` | 宽高(像素) |+| `uvOffset` | Vec2 | `{x: 0, y: 0}` | 纹理坐标偏移 |+| `uvScale` | Vec2 | `{x: 1, y: 1}` | 纹理坐标缩放 || `layer` | number | `0` | 渲染顺序(越大越靠前) || `flipX` | boolean | `false` | 水平翻转 || `flipY` | boolean | `false` | 垂直翻转 |diff --git a/docs/astro/src/content/docs/zh/guides/ui.mdx b/docs/astro/src/content/docs/zh/guides/ui.mdxindex a2720ee28..f8472edf0 100644--- a/docs/astro/src/content/docs/zh/guides/ui.mdx+++ b/docs/astro/src/content/docs/zh/guides/ui.mdx@@ -27,8 +27,8 @@ import { Aside } from '@astrojs/starlight/components';| `fontFamily` | string | `'Arial'` | 字体名称 || `fontSize` | number | `24` | 字号(像素) || `color` | Color | `{r:1, g:1, b:1, a:1}` | 文本颜色 RGBA(0–1) |-| `align` | TextAlign | `Left` | 水平对齐方式 |-| `verticalAlign` | TextVerticalAlign | `Top` | 垂直对齐方式 |+| `align` | TextAlign | `Left` | 水平对齐方式(编辑器默认为 `Center`) |+| `verticalAlign` | TextVerticalAlign | `Top` | 垂直对齐方式(编辑器默认为 `Middle`) || `wordWrap` | boolean | `true` | 启用自动换行 || `overflow` | TextOverflow | `Visible` | 溢出处理模式 || `lineHeight` | number | `1.2` | 行高倍率 |@@ -162,10 +162,10 @@ addSystem(defineSystem([Res(Input), Query(Children, UIMask, ScrollList), Query(Mut(LocalTransform))],(input, maskQuery, childQuery) => {for (const [entity, children, mask, scroll] of maskQuery) {- const scrollDelta = input.getScrollDelta();+ const scroll = input.getScrollDelta();for (const child of children.entities) {const [, transform] = childQuery.get(child);- transform.position.y += scrollDelta * 20;+ transform.position.y += scroll.y * 20;}}}@@ -244,7 +244,7 @@ addSystem(defineSystem());```-**事件类型:** `click`、`press`、`release`、`hover_enter`、`hover_exit`+**事件类型:** `click`、`press`、`release`、`hover_enter`、`hover_exit`、`submit`、`change`### ScreenSpace