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(outliner): expose World Outliner model ops on EditorControlSurface
esengine50759c59faf5
diff --git a/desktop/src/engine/EditorControlSurface.ts b/desktop/src/engine/EditorControlSurface.tsindex 401d4ec0e..1844ddc1d 100644--- a/desktop/src/engine/EditorControlSurface.ts+++ b/desktop/src/engine/EditorControlSurface.ts@@ -145,6 +145,61 @@ export class EditorControlSurfaceImpl {this.s.commands.transact(label, fn);}+ // =========================================================================+ // Hierarchy & organization — the World Outliner's model operations, exposed+ // so the headless host + editor MCP drive the same undoable commands the UI+ // does. View state (expansion / sort / search) stays in the OutlinerController.+ // =========================================================================++ /** Re-parent an entity (transform hierarchy); `null` un-parents to the root. */+ setParent(id: EntityId, parent: EntityId | null): void {+ this.s.commands.setParent(id, parent);+ }+ /** Drag-reorder an entity before/after a sibling target (one undo step). */+ reorderEntity(id: EntityId, target: EntityId, before: boolean): void {+ this.s.commands.reorderEntity(id, target, before);+ }++ /** Create an explicit (initially empty) outliner folder. */+ createFolder(path: string): void {+ this.s.commands.createFolder(path);+ }+ /** Rename/move a folder (re-roots its descendants + entities). */+ renameFolder(oldPath: string, newPath: string): void {+ this.s.commands.renameFolder(oldPath, newPath);+ }+ /** Delete a folder, moving its contents up to the parent. */+ deleteFolder(path: string): void {+ this.s.commands.deleteFolder(path);+ }+ /** Move entities into a folder (`null` = scene root); un-parents them. */+ moveToFolder(ids: readonly EntityId[], path: string | null): void {+ this.s.commands.moveToFolder(ids, path);+ }+ /** An entity's folder path (`""` = scene root). */+ getEntityFolder(id: EntityId): string {+ return this.s.model.folderOf(id);+ }+ /** The scene's explicit folder list (incl. empties). */+ getSceneFolders(): string[] {+ return this.s.model.sceneFolders();+ }++ /** Set an entity's editor visibility (UE5 bHiddenInEditor; not gameplay enabled). */+ setEntityHidden(id: EntityId, hidden: boolean): void {+ this.s.commands.setEntityVisible(id, !hidden);+ }+ isEntityHidden(id: EntityId): boolean {+ return this.s.model.isHidden(id);+ }+ /** Lock/unlock an entity (blocks viewport picking/transform). */+ setEntityLocked(id: EntityId, locked: boolean): void {+ this.s.commands.setEntityLocked(id, locked);+ }+ isEntityLocked(id: EntityId): boolean {+ return this.s.model.isLocked(id);+ }+// =========================================================================// Queries — read-only reflection of the session's scene model (the truth)// =========================================================================diff --git a/desktop/tests/editor-control-surface.test.ts b/desktop/tests/editor-control-surface.test.tsindex 308126d9d..b69701686 100644--- a/desktop/tests/editor-control-surface.test.ts+++ b/desktop/tests/editor-control-surface.test.ts@@ -104,4 +104,25 @@ describe.skipIf(!HAS_WASM)('EditorControlSurface (headless World)', () => {it('captureViewport fails clearly without a render host', () => {expect(() => S.surface.captureViewport()).toThrow(/render host/);});++ it('outliner ops — folders / visibility / lock / reorder — round-trip + undo', () => {+ const a = S.surface.addEntity()!;+ const b = S.surface.addEntity()!;++ S.surface.createFolder('Enemies');+ expect(S.surface.getSceneFolders()).toContain('Enemies');+ S.surface.moveToFolder([a], 'Enemies');+ expect(S.surface.getEntityFolder(a)).toBe('Enemies');++ S.surface.setEntityHidden(a, true);+ expect(S.surface.isEntityHidden(a)).toBe(true);+ S.surface.setEntityLocked(b, true);+ expect(S.surface.isEntityLocked(b)).toBe(true);++ expect(S.model.entityOrder()).toEqual([a, b]);+ S.surface.reorderEntity(b, a, true); // b before a (one undo step)+ expect(S.model.entityOrder()).toEqual([b, a]);+ S.surface.undo();+ expect(S.model.entityOrder()).toEqual([a, b]);+ });});