← Back to tutorials

Meet ForgeaX Engine

An AI-native game engine designed to maximize AI efficiency.

ForgeaX is a TypeScript game engine with AI agents as its primary users. Data, lifecycles, APIs, and tools serve one goal: help AI understand the system, act precisely, inspect results, and repair failures.

Efficiency is the goal; design is the method. Complete more verified game-development work with less context, fewer failed attempts, and shorter feedback cycles.

AI efficiency Design principles Architecture Get started Explore

AI efficiency

Efficiency means verified useful work, accounting for diagnosis and rework, context, and tool round trips.

Capability How it improves AI efficiency
Transparent renderingRHI-debug records and replays self-contained frames, exposing draw/dispatch work, bindings, resources, and pixels to locate incorrect inputs
Transparent runtime logic and dataECS makes components, queries, and schedules explicit; Remote queries live instances to locate failures from actual state
Authorable, traceable assetsScriptablePack / Pack generate content in TypeScript or declare it in JSON; stable GUIDs connect sources and artifacts, with repair routed through the producer
Reversible plugin changesNative Cordis unifies dependencies, activation, and cleanup; failed configuration updates can restore the last working Fiber
Measurable performance and resultsProfiler provides bounded CPU captures and offline comparison; Preview, browser captures, and project tests supply runtime evidence
CLI-first operationDevKit unifies forgeax discovery, JSON input/output, and persistent instances for repeatable, composable operations
Context on demandSkills, package contracts, and tool descriptions reveal only the knowledge needed for the task
Structured failure and recoveryResult and closed error unions provide codes, expectations, hints, and details; capabilities, execution tiers, and recovery state are explicit
Screenshots, structural checks, and real GPU execution answer different questions. CPU captures cannot substitute for GPU performance measurements.

Design principles

Compression is intelligence: reduce the concepts needed to understand local behavior. Avoid duplicate state, extra lifecycles, and implicit branches.

Design principle How ForgeaX applies it
AI is the primary userPrioritize discoverable, callable, verifiable machine contracts; AI usability takes precedence over human convention
One source of truthWorld owns game state, Renderer owns render projections, and source assets plus Meta own author facts; other layers consume or derive
Derive from declarationsMaterial paramSchema derives layouts; RenderGraph derives dependencies and lifetimes from accesses; project declarations generate the Catalog
Compose within domain boundariesPhysics, rendering, assets, and audio own their execution data; plugins assemble capabilities and ECS schedules frame work
Native lifecycle and unified cleanupCordis Context / Entry / Fiber manage capability existence; inject / provide / effect express dependencies, services, and cleanup
Explicit states and failuresClosed unions, structured errors, and reported capability absence and fallback reduce hidden branches
Prepare at build time, consume at runtimeImport, WGSL composition and reflection, and VFX compilation produce published content for runtime loading

See the AI-first design axiom and module ownership map for the full constraints.

Architecture

One authoritative World. Runtime assembles services, Render maintains render projections, and build tools produce resources.

Rendering and GPU

Subsystem Key design and responsibility Read more
Render / RenderGraphPersistent CPU projection and capability-gated GPU Scene; programmable pipelines and RenderFeatures; derived dependencies, usages, and lifetimes with raster / compute / copy passes executed in declaration orderRender · RenderGraph
Shader / MaterialSchema-derived parameter and binding layouts; WGSL composition, Naga validation and reflection; runtime lookup of content-addressed compiled artifactsShader · Compiler
GPU VFXGPU simulation and indirect rendering; code authoring and build-time compilation; particles, ribbons, trails, beams, billboards, and meshesVFX · VFX render
RHI / BackendsCapability-gated operations across browser WebGPU, wgpu WASM, and null backends; a spec-aligned, math-free interface with opaque handlesRHI · wgpu

ECS and multiple Workers

ECS World owns entities, components, relationships, resources, and time. Systems declare access and scheduling in Update / FixedUpdate. Scene owns hierarchy and transforms; State owns state-scoped entity lifetimes. Renderer consumes World changes into a persistent projection.

Execution tier Placement Constraints and scope
sharedEngine Worker plus persistent Kernel Worker poolRequires cross-origin isolation, SharedArrayBuffer, and related capabilities; only eligible numeric work runs in parallel
engine-workerWorld, Renderer, assets, and game plugins in one WorkerHost retains DOM, input, and audio; requires Worker rendering capabilities
main-serialWorld and Renderer on the main threadThe direct serial execution path
autoSelects an available tier from capabilitiesReports the actual selection and reason; explicitly requesting an unavailable tier returns an error
Multiple Workers preserve one logical World with serial structural changes, no live-object transfer, and no split RenderGraph. Partial shared writes require World rebuild. See App execution and the multithreaded example.

Text and scripted assets

Procedural generation and parameter reuse bring content into the code workflow. AI can generate assets in batches, edit text directly, review diffs, and validate automatically.

Authoring form Purpose
ScriptablePack · .pack.tsGenerate asset collections with functions, loops, and composition; reuse scene and geometry logic
Parameterized instancesIndependent package identity, parent source, and sparse overrides for reusable variants
Pack · .pack.jsonDeclare assets, references, and instance parameters for direct field editing and diff review
Imported assets and sidecarsExternal glTF / FBX / image sources and metadata share the identity and cooking path
Sources and artifacts are separate. .pack.ts executes at build time; runtime loads cooked content by stable GUID. Textures, models, and audio can still use binary sources. Repair source inputs, then cook again. See the Pack authoring contract.

Game and engine plugins

Game and engine plugins share native Cordis dependencies, activation, updates, and disposal.

Plugin layer Typical responsibility Composition
Project assemblyInstalled plugins, configuration, and realm placementforge.json.plugins[] declares Entries; DevKit generates a static Catalog for native Loader activation
Engine pluginsScene, input, physics, audio, and ECS capabilitiesNative inject / provide declare dependencies and services; effect registers contributions and their inverses
Game pluginsPlayer movement, camera, game UI, and gameplay systemsThe reference template combines children through definePluginGroup / usePlugin in assets/plugin.ts

Effects unwind when their Fiber exits. ECS schedules frame work; plugin assembly stays outside hot paths. See the plugin contract and game-3d root plugin.

Simulation and interaction

Subsystem Key design and responsibility Read more
NetworkingSessions own replication, ACKs, retries, baselines/deltas, and connection recovery; WebSocket supplies transportNet · WebSocket
PhysicsECS physics contracts separated from Rapier 2D / 3D backends; input synchronization, simulation stepping, and state writebackPhysics
Animation / SkinningRenderer-independent animation graphs, clips, and playback; Skin binding and joint-path resolutionAnimation · Skinning
Runtime intelligenceOptional provider-neutral Activity / Session; bounded output, cancellation, and polling; asynchronous services stay outside the ECS frame loopIntelligence
Input / UI / AudioFrozen frame-start input snapshots; Shadow DOM UI; realm-neutral audio intents played by Host Web AudioInput · UI · Audio

Get started

Install @forgeax/engine, use focused subpaths such as /ecs and /app, and operate through forgeax.

pnpm dlx @forgeax/engine project new my-game --template game-3d
cd my-game
pnpm exec forgeax help --tree --json
pnpm exec forgeax project check
pnpm exec forgeax dev start --headless false --json

game-3d is a third-person reference; empty is a minimal start. Read the generated README and skills. See Engine and the CLI guide.

Run and verify
pnpm exec forgeax dev status --json
pnpm exec forgeax dev capture --json
pnpm exec forgeax dev stop --json
pnpm exec forgeax project test
pnpm exec forgeax project package --format web-zip

Observations carry a revision; captures return PNG and report references. For entity lookup, camera control, and runtime identity constraints, see persistent live control.

Source and SDK

Toolchain versions are defined in .nvmrc, .pnpm-version, and .bun-version in the repository.

pnpm install
pnpm build:engine
pnpm test
Scenario Entry
Install the SDKpnpm dlx @forgeax/engine sdk install ./forgeax-sdk
SDK source/engine/Independent public source with .forgeax-public-distribution and prebuilt WASM; run the install/build commands above without private submodules
Full contributor checkoutClone with --recurse-submodules for authorized private asset access; run pnpm build for the complete application fleet
Single demo iterationpnpm build:app hello/triangle; broader acceptance follows the Smoke gate

The SDK includes built packages, templates, skills, and Engine source. See the SDK guide.

Explore

Entry Purpose
AGENTS.mdDesign axioms, module ownership, errors, source-work rules, and verification constraints
PackagesPackage READMEs defining APIs, lifecycles, and capability contracts
Schemas / CI guideMachine-readable contracts and verification workflows
Engine skillsTask-oriented capability discovery and operating paths
Apps / TemplatesExamples, regression scenarios, and game starting points
Forbidden City showcasepack.ts architecture, lighting, and continuous CLI inspection; visual quality remains a work in progress
This page is adapted from the engine README. Linked package contracts define precise capabilities and limitations.

License

The engine is licensed under Apache-2.0.

Make your first game →