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): render spine when opening a project (ProjectStore path)
esengine6aa1742e9858
diff --git a/desktop/src/engine/EngineHost.ts b/desktop/src/engine/EngineHost.tsindex 1d50fd8aa..72b61db27 100644--- a/desktop/src/engine/EngineHost.ts+++ b/desktop/src/engine/EngineHost.ts@@ -13,8 +13,9 @@ import {setEditorMode,setPlayMode,} from 'esengine';-import type { App, ESEngineModule, ResourceDef, SubsystemStatus } from 'esengine';+import type { App, ESEngineModule, ResourceDef, SubsystemStatus, SceneData } from 'esengine';import { SceneLoader } from './SceneLoader';+import { loadEditorSpine } from './spineLoad';import { checkEngineBuild } from './EngineGuard';import type { ReadonlyWorldT, WorldT } from './schema';@@ -259,6 +260,21 @@ class EngineHostImpl {return this.app_ ? SceneLoader.loadInto(this.app_, sceneUrl, manifestUrl) : 0;}+ /**+ * Bind a scene's spine entities into the SpineManager so spine renders in the+ * viewport (the World already holds the SpineAnimation components). entityMap =+ * scene id → runtime entity; `toUrl` maps an asset ref to a fetchable URL. The+ * project transport (ProjectStore) drives this after Reconciler.adopt; the+ * dev/automation transport (SceneLoader.loadInto) calls loadEditorSpine itself.+ */+ async loadSpine(+ sceneData: SceneData,+ entityMap: Map<number, number>,+ toUrl: (ref: string) => string,+ ): Promise<void> {+ if (this.app_) await loadEditorSpine(this.app_, sceneData, entityMap, toUrl);+ }+private resize() {const canvas = this.canvas_;const parent = canvas?.parentElement;diff --git a/desktop/src/project/ProjectStore.ts b/desktop/src/project/ProjectStore.tsindex 0c5c808ba..368a851de 100644--- a/desktop/src/project/ProjectStore.ts+++ b/desktop/src/project/ProjectStore.ts@@ -233,6 +233,25 @@ class ProjectStoreImpl {Reconciler.adopt(expandedRaw, resolved);// Re-apply prefab-instance tags (adopt cleared them) so save can collapse.for (const { id, tag } of tags) SceneModel.setPrefabTag(id, tag);++ // Bind spine entities' skeletons/atlas/textures into the SpineManager so spine+ // renders in the viewport (the World holds the SpineAnimation components, but+ // spine assets load separately from Assets — REARCH_SPINE side modules). The+ // entityMap is the Reconciler's source→runtime binding; refs resolve through+ // the project's estella:// transport.+ const spineMap = new Map<number, number>();+ for (const e of expandedRaw.entities) {+ const id = (e as { id?: number }).id;+ if (id === undefined) continue;+ const rt = SceneModel.runtimeFor(id);+ if (rt !== undefined) spineMap.set(id, rt as number);+ }+ await EngineHost.loadSpine(expandedRaw, spineMap, (ref) =>+ ref.startsWith('@uuid:')+ ? `estella://project/${this.resolveRef(ref) ?? ''}`+ : `estella://project/${ref.replace(/^\//, '')}`,+ );+EngineHost.syncEditorViewToScene();this.store.setState({ project: { ...st, currentScene: rel } });}