A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
feat(editor): a project plugin may import the engine subpaths the editor is built on, so a game's generated ground shows in the viewport
yhh046173c9f891
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex a55fa14b2..772ad2fd0 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -16,6 +16,7 @@ published separately; it ships inside the editor.### Added+- **A game's generated ground shows in the editor.** An editor plugin may now import the engine subpaths the editor is built on (`esengine/terrain`, `esengine/worldgen`, `esengine/water`, `esengine/spline`, `esengine/tilemap`, `esengine/replication`), as the editor's own instances, so a project plugin can register the terrain provider its game registers and the viewport draws the ground the game will. New projects' `.gitignore` leaves `.esengine/plugins/` and `.esengine/platforms/` versioned, as the plugin page always said, and ignores the typings and the session.- **A lookup table is adopted as data.** A PNG shaped like a colour lookup table (N slices of N by N: 1024 by 32, 256 by 16, 4096 by 64) is given no compression, no mips, no sRGB decode and clamped edges when it is added to a project, where it used to take the picture defaults and answer wrongly until someone found why.- **An Outdoor Environment to create.** **Create → Rendering → Outdoor Environment** makes a sun, a sky light, a clock, a weather and a global volume with the sky (clouds that cast shadows), the haze (beams in their gaps) and a plain grade, already pointing at one another. It is the arrangement the Terrain & Water example uses, for the engine's scale of a hundred units to the metre.- **An Online 3D starter.** A template for a networked 3D game: a lit ground, a pawn per player predicted on its owner's screen and replicated to the others, a camera that follows your own, and a `server/` that runs the same project headless. The rules both ends agree on are one module, `src/shared/rules.ts`. `tools/check-arena-server.mjs` now takes `--project`, and runs against this template too.diff --git a/desktop b/desktopindex 1c57c4dbf..ab4adfe03 160000--- a/desktop+++ b/desktop@@ -1 +1 @@-Subproject commit 1c57c4dbffd9c347c4379d2c942cc685666b4c18+Subproject commit ab4adfe039abd6ef6513bbec435a1ab814ff9e08diff --git a/docs/astro/src/content/docs/extending/editor-plugins.mdx b/docs/astro/src/content/docs/extending/editor-plugins.mdxindex 54ff882d7..bbbdac904 100644--- a/docs/astro/src/content/docs/extending/editor-plugins.mdx+++ b/docs/astro/src/content/docs/extending/editor-plugins.mdx@@ -481,6 +481,29 @@ the editor's own work — so a slow overlay or command is visible rather thanmysterious.</Aside>+## What a plugin may import++A plugin runs in the editor's own realm and imports the editor's own instances, so what it registers is what the editor uses. It may import+`react`, `@estella/editor-api`, `esengine`, and the engine subpaths the editor is built on: `esengine/terrain`, `esengine/worldgen`,+`esengine/water`, `esengine/spline`, `esengine/tilemap` and `esengine/replication`. Anything else is a load error naming this list; bundle it into+the plugin instead.++### Show your game's generated ground in the editor++The editor does not run your game's scripts while you edit: it reads the declaration module for component schemas and nothing else. A terrain+provider a game registers (a `Terrain` with `provider: 'my-game:planet'`) is therefore not there in the viewport, and the terrain asks for a+provider that does not exist. A project plugin that imports the module registering it fixes that, with the same code in the editor as in the game:++```ts title=".esengine/plugins/my-game.ground/src/editor.ts"+import { definePlugin } from '@estella/editor-api';+import '../../../../../src/planet/terrain.ts'; // registerTerrainProvider(...), as the game does++export default definePlugin({ activate: () => {} });+```++The editor asks you once to trust the plugin, since it runs project code. The project's `.gitignore` leaves `.esengine/plugins/` out of the ignored+set (new projects are written that way), so the plugin travels with the project and the whole team sees the same ground.+## Where plugins live- **`<project>/.esengine/plugins/<id>/`** — versioned with the project and shareddiff --git a/docs/astro/src/content/docs/zh-cn/extending/editor-plugins.mdx b/docs/astro/src/content/docs/zh-cn/extending/editor-plugins.mdxindex a4ba68fc4..118951c77 100644--- a/docs/astro/src/content/docs/zh-cn/extending/editor-plugins.mdx+++ b/docs/astro/src/content/docs/zh-cn/extending/editor-plugins.mdx@@ -421,6 +421,27 @@ ctx.scene.transact('Rename Markers', () => {并排——所以慢的覆盖层或命令是看得见的,而不是一团迷雾。</Aside>+## 插件能引入什么++插件运行在编辑器自己的运行域里,引入的是编辑器自己的实例,所以它注册的东西就是编辑器在用的东西。可以引入 `react`、`@estella/editor-api`、+`esengine`,以及编辑器本身建立在其上的引擎子入口:`esengine/terrain`、`esengine/worldgen`、`esengine/water`、`esengine/spline`、+`esengine/tilemap` 和 `esengine/replication`。别的都会在加载时报错并列出这份清单;请把它打进插件里。++### 在编辑器里显示游戏生成的地面++编辑时编辑器不运行你的游戏脚本:它只读声明模块来取组件结构。游戏自己注册的地形提供器(`Terrain` 的 `provider: 'my-game:planet'`)因此在视口里+并不存在,地形要的提供器找不到。用一个项目插件引入注册它的模块即可,编辑器里和游戏里用同一份代码:++```ts title=".esengine/plugins/my-game.ground/src/editor.ts"+import { definePlugin } from '@estella/editor-api';+import '../../../../../src/planet/terrain.ts'; // registerTerrainProvider(...),和游戏里一样++export default definePlugin({ activate: () => {} });+```++因为它运行项目代码,编辑器会请你确认一次是否信任这个插件。项目的 `.gitignore` 不再忽略 `.esengine/plugins/`(新建项目就是这样写的),+所以插件随项目走,全队看到的是同一片地面。+## 插件放在哪- **`<项目>/.esengine/plugins/<id>/`**——随项目版本管理,与团队共享。通常放这里。