The adapter architecture
vgai’s editor and host don’t depend on any one game’s internals. They depend on interfaces,
and games — first-party .vscn scenes or unmodified third-party three.js games — are peer
implementers of those interfaces.
The core interfaces
Section titled “The core interfaces”GameAdapter(packages/engine/src/adapter/game-adapter.ts) — the host⇄runtime lifecycle. A “game” is anything that mounts viamount(host): Promise<MountedGame>. TheMountedGameexposes the live scene + camera and lifecycle hooks (update/fixedUpdate/ setPaused/step) plus optional authoring/systems providers.HostContext(host-context.ts) — the neutral primitives the host provides (thethreeinstance, canvas, renderer, loop, assets, UI). Rapier/Colyseus are kept behind system adapters, not baked into the host.AuthoringAdapter(authoring.ts) — the editor’s authoring contract: hierarchy / selection / transform / inspector / structure / persistence, keyed by opaque string node ids. The editor UI never branches on which implementer it’s editing.
First-party implementers
Section titled “First-party implementers”vgai’s own content plugs into the same seams:
VgaiSceneGameAdapterwraps.vscnloading +setup()as aGameAdapter;fromSetup()adapts every existing example with zero edits.VgaiSceneAuthoringAdapterimplementsAuthoringAdapterby delegating to the editor’s existing store/scene logic — so the hierarchy/inspector/gizmo/save all route through it.
System adapters
Section titled “System adapters”Optional subsystem capability providers hang off MountedGame.systems
(system-adapter.ts) — the editor coordinates with a game’s systems without owning them:
Physics, Networking, Input, Asset, Animation, Navigation. First-party implementers wrap
Rapier, Colyseus, the input manager, the asset cache, AnimGraph, and the navmesh manager.
See also
Section titled “See also”- Ingesting unmodified games — the render-accessor trap + overlays.
- Editor Guide — the authoring surface that rides on
AuthoringAdapter.