Uruk EngineUruk EngineDocumentation

Documentation

Uruk Engine Editor

Browser-based game editor for Uruk — The First City

A web-based visual editor and prototype engine for an open-world action-adventure RPG set in ancient Mesopotamia (~3000 BCE). Built with React 19 + TypeScript + Three.js on the frontend, Express + tRPC on the backend. The editor is functional; the runtime engine is partially implemented with several subsystems at architecture-only or early-integration stage.

Maturity disclaimer: This is a prototype/vertical-slice project. It is not a shipping game engine. The subsystem maturity table below is the source of truth for what works, what is scaffolded, and what is placeholder.

Subsystem Maturity

Each subsystem is rated on a four-level scale:

LevelMeaning
FunctionalRuns in the editor, produces visible/measurable results, has tests
IntegratedWired into the runtime loop but limited in scope or fidelity
ArchitectureTypes, interfaces, and data structures exist; logic is stubbed or minimal
PlaceholderUI exists but the underlying system is not implemented
SubsystemMaturityWhat ExistsWhat Does Not Exist
Visual Editor (UI)FunctionalFull IDE layout: scene tree, viewport, inspector, timeline, asset browser, resizable panels, dark industrial theme
3D ViewportFunctionalThree.js scene with orbit controls, grid, sky, weather overlays, entity selection, gizmos, stats overlay. RenderGraph is the primary render path with compute cull, shadow, opaque, SSAO, bloom, color grading, and debug overlay passes. WebGPU backend available via THREE.WebGPURenderer with runtime detection and automatic fallback.Custom renderer not yet wired into Viewport. Post-processing GLSL shaders are WebGL2-only.
ECSFunctionalWorld, Entity, Component, System with typed registration, per-phase step loop, stats collectionNo archetype storage optimization. No parallel system execution.
World StreamingIntegratedStreamingManager with real cell lifecycle, proximity activation, memory budget caps, live minimap. 12 cells defined for Uruk city.Cell content is procedurally generated geometry. No LOD transitions. No async loading.
AI + NavigationIntegratedNavigationGraph with A* pathfinding (42 nodes). AgentRuntime with 8-state FSM, patrol route following, schedule execution, perception/suspicion.Agents not rendered as visible meshes. No navmesh. Perception is proximity-only.
PhysicsIntegratedPhysicsWorld with AABB/sphere/mesh colliders, trigger volumes, overlap detection, raycast, character controller, debug wireframe overlay.No rigid body dynamics. No broad-phase spatial hash. Detection only.
Render PipelineFunctional6-layer architecture with RenderGraph as primary path. TAA, CSM, post stack. Runtime backend selection (auto/webgl2/webgpu). GPU compute frustum culling with indirect draw buffer compaction.Custom renderer not yet integrated. Motion vectors not wired into TAA.
Runtime OrchestratorIntegratedSingle update() sequences streaming→AI→physics→render per frame. Game time with configurable scale.Subsystem integration is shallow — no cross-system queries.
Uruk AIFunctionalLLM-powered chat with 15+ action types (teleport, spawn, build, delete, select, weather, lighting, fog, camera). Undo/redo. Green action badges.Actions modify editor state, not runtime. No script generation.
Content SchemasFunctionalTyped definitions for WorldCell, NavNode, PatrolRoute, MissionZone, MissionDefinition, DialogueAsset, AIArchetype. ContentLoader with validation.Content is hardcoded TypeScript, not loaded from files.
Editor AuthoringFunctionalWorldEditor panel with Cell Editor, Patrol Route Editor, Mission Zone Editor. Edit properties, APPLY to live runtime.Changes are in-memory only, not persisted.
3D Studio (Forge 3D)FunctionalImage-to-3D pipeline via Tripo API, PBR texture extraction, auto-rigging, text-to-animate, GLB export.Depends on external Tripo API. No local 3D generation.
2D Character DesignerFunctionalText-to-2D generation with style controls, historical period presets (3500–1500 BCE), gallery, Send to 3D pipeline.Quality depends on AI model. No pose control.
Blueprint EditorArchitectureNode-graph canvas with 12 node types, pin-type validation, drag-and-drop, zoom/pan, execution preview.Blueprints do not execute. No code generation. Visual only.
Terrain SculptorArchitectureBrush tools, texture splatting, 3D wireframe preview.Operates on local heightmap, not connected to viewport. No export.
Multiplayer PreviewPlaceholderSession lobby UI, simulated peer cursors, chat overlay.No WebSocket server. All peers simulated locally.
Mission EditorFunctionalVisual node-graph with dependency arrows, draggable nodes, objective trees, chapter organization.Missions not connected to runtime triggers.
Cinematic SequencerFunctionalTimeline with keyframe tracks, camera/lighting/crowd/weather/dialogue tracks, playback controls.Sequencer data not connected to viewport camera. UI-only playback.
Desktop AppArchitectureElectron shell with main process, preload script, splash screen, build scripts.Not tested. No packaging CI.
AudioNot implementedNo audio system exists.
VRNot implementedNo WebXR integration. Status bar label is cosmetic.

Repository Structure

text
client/                        ← React 19 + TypeScript editor frontend
  src/
    pages/                     ← Page-level components (Home, Studio3D, CharacterDesigner, etc.)
    components/editor/         ← Editor panels (Viewport, SceneTree, Inspector, Timeline, etc.)
    engine/                    ← Client-side engine subsystems
      core/ecs.ts              ← Entity Component System
      world/streamingManager.ts ← Cell-based world streaming
      ai/navigationGraph.ts    ← A* pathfinding on waypoint graph
      ai/agentRuntime.ts       ← AI agent state machine + patrol/schedule
      physics/physics.ts       ← Collision detection + trigger volumes
      renderer/renderPipeline.ts ← Multi-pass render pipeline
      runtime/runtimeOrchestrator.ts ← Per-frame subsystem sequencer
      content/contentTypes.ts  ← Typed content schemas
      content/urukProjectData.ts ← Default Uruk world data
    contexts/EditorContext.tsx  ← Central editor state
server/                        ← Express + tRPC backend
  routers.ts                   ← tRPC procedures (AI chat, 3D generation, content gen)
  aiPrompt.ts                  ← AI Co-Pilot system prompt + action schema
drizzle/                       ← MySQL database schema & migrations

Getting Started

bash
pnpm install
pnpm db:push
pnpm dev

The editor runs at the URL shown in the terminal output.

Tech Stack

LayerTechnology
FrontendReact 19, TypeScript, Tailwind CSS 4, Three.js r183
BackendExpress 4, tRPC 11, Node.js 22
DatabaseMySQL / TiDB, Drizzle ORM
3D RenderingThree.js r183 (WebGL2 + WebGPU dual backend), custom render graph + post stack
AIBuilt-in LLM API (Manus), Tripo 3D API, optional local inference
TestingVitest (189+ tests, 10 test files, 100% passing)

Tests

bash
pnpm test

189+ tests across 10 files covering: auth, AI co-pilot action parsing, 3D generation pipeline, character/animation management, blueprint logic, terrain operations, multiplayer session logic, streaming lifecycle, A* navigation, AI state machine, content validation, physics stats, mission zone triggers, runtime orchestration, renderer capabilities, render graph compilation, clustered lighting, post-processing stack, CSM cascade fitting, TAA jitter, streaming visibility, and renderer facade.

Known Limitations

The following are explicitly not implemented despite appearing in the UI or earlier documentation:

  • WebGPU custom render shaders — The WebGPU backend uses THREE.WebGPURenderer which auto-converts materials through the Three.js TSL node material system. No hand-written WGSL render/fragment shaders.
  • WebGPU indirect draw — The compute frustum culling pass reads results back to CPU and sets mesh.visible. No indirect draw buffer or GPU-driven draw call submission.
  • Bindless textures / mesh shaders — Not implemented. The WebGPU backend does not use any WebGPU-exclusive rendering features beyond compute.
  • SSR — No screen-space reflections. SSAO exists but uses a simplified kernel.
  • Authoritative multiplayer — The multiplayer page is a UI mockup with simulated peers. No WebSocket server exists.
  • VR / WebXR — The status bar shows "VR" but no WebXR integration exists.
  • Audio system — No audio engine, no spatial audio, no music playback.
  • Platform deployment — The editor runs in a browser. No native runtime for PC, console, or mobile.
  • Terrain export — The terrain sculptor operates on a local array and does not connect to the viewport scene.
  • Motion vectors — The TAA pass uses reprojection jitter but has no per-object motion vector generation.
  • Contact shadows / Occlusion queries — These passes exist as skeleton implementations but do not produce visual output.

WebGPU Backend Architecture

The WebGPU backend is a real, minimal implementation that renders the same scene through the WebGPU API path.

What Is Real

  • GPU device acquisition — navigator.gpu.requestAdapter() and adapter.requestDevice() are called through THREE.WebGPURenderer. A real GPUDevice is obtained.
  • Render path — renderer.render(scene, camera) executes through the WebGPU command encoder pipeline, not WebGL2.
  • Material auto-conversion — Three.js converts materials to its TSL node material system, which compiles to WGSL internally.
  • Backend detection — probeBackends() does a real async probe: checks navigator.gpu, requests an adapter, and reports adapter info.
  • Runtime selection — User can choose auto/webgl2/webgpu in Engine Settings. Preference persists in localStorage.
  • Safe fallback — If WebGPU init fails, the system falls back to WebGL2 automatically.
  • Status reporting — The Stats HUD and Status Bar show the actual active backend from the capability manifest.

WebGPU-Exclusive Features (Three.js Layer)

  • GPU Compute Frustum Culling — Real WGSL compute shader that tests bounding spheres against 6 frustum planes on the GPU. Auto-enabled when WebGPU backend is active.
  • Indirect Draw Buffer Compaction — 3-pass WGSL compute (reset / compact / finalize). Produces a GPUBuffer with INDIRECT usage flag.
  • Backend-neutral render targets — All post-processing passes use THREE.RenderTarget (base class), compatible with both backends.
  • RenderGraph as primary path — The Viewport uses RenderGraph with compute cull, shadow, opaque, SSAO, bloom, color grading, and debug overlay passes.

Custom WebGPU Renderer (v6.0)

A fully custom WebGPU-native renderer exists alongside the Three.js integration layer. This renderer owns its own GPU device, resource management, pipeline caching, and WGSL shaders. It does NOT go through Three.js for rendering — it encodes GPU commands directly.

Foundation

ModuleDescription
webgpuDeviceManager.tsGPU device lifecycle, adapter selection, feature/limit detection, device lost recovery
webgpuResourceManager.tsGPU buffer pool (camera, object, material, light UBOs/SSBOs), texture/sampler cache
webgpuPipelineCache.tsShader module cache, bind group layout registry, render/compute pipeline factory
webgpuFrameContext.tsPer-frame command encoder, GPU timestamp queries, pass timing, draw call stats

Custom WGSL Shaders

ShaderDescription
depthPrepass.wgslDepth-only vertex shader with object SSBO transforms
opaquePBR.wgslFull PBR fragment shader: GGX, Schlick fresnel, Smith geometry, Cook-Torrance specular, Lambert diffuse, multi-light evaluation, shadow atlas sampling
motionVectors.wgslCurrent/previous frame MVP for temporal reprojection
fullscreenPost.wgslTonemapping (ACES/Reinhard/Uncharted2), exposure, vignette, gamma

Advanced Render Features

FeatureDescription
GPU-Driven Clustered Lighting16x9x24 clusters with exponential depth slicing. Compute build + assign shaders with atomic counters. Debug heatmap overlay.
GPU Culling SystemInstance-level frustum culling with visibility buffer and indirect draw compaction. HLOD proxy visibility and streaming cell residency checks.
Lumen-like Global IlluminationSSGI ray marching, DDGI probe grid (8x4x8 = 256 probes), temporal denoiser with variance-guided bilateral filter.
Nanite-like Virtual GeometryMeshlet builder (64 verts, 124 tris), cluster hierarchy LOD DAG, GPU LOD selection via screen-space error, cluster renderer.

Honesty note: The custom renderer systems are implemented as standalone modules with real WGSL shaders, real GPU buffer management, and real compute dispatches. However, they are NOT yet wired into the main Viewport render loop. Integrating the custom renderer requires a scene extraction bridge which is not yet built.

Code Path Proof

text
Viewport.tsx useEffect
  → probeBackends()              — real async GPU probe
  → selectBackend(preference)    — preference + availability
  → if webgpu:
      new WebGPUBackend()
      gpuBackend.init(canvas)     → dynamic import('three/webgpu')
                                  → new WebGPURenderer({ canvas })
      await gpuBackend.waitForInit()  → await renderer.init()  [real GPU device]
      → auto-enable ComputeFrustumCullPass in render graph
  → else:
      new THREE.WebGLRenderer()   [standard Three.js]
  → renderGraph.execute(renderer, scene, camera, dt, frame)
      → ComputeFrustumCullPass.execute()  (if enabled)
          → dispatchWorkgroups()  [real WGSL compute]
          → dispatchCompaction()  [3-pass indirect draw buffer]
          → mapAsync()  [readback, 1-frame latency]
      → ShadowPass.execute()
      → OpaquePass.execute()
          → renderer.render(scene, camera)  [dispatches to active backend]

Game World

Uruk — The First City is set in ancient Mesopotamia (~3000 BCE). The content data defines:

  • 12 world streaming cells covering the Uruk city districts
  • 42 navigation waypoints with A* pathfinding
  • 6 patrol routes for NPC guard/merchant/priest behaviors
  • 6 mission zones (circle and rect trigger volumes)
  • 3 mission definitions across 2 chapters
  • 2 branching dialogue trees
  • 6 AI archetypes (temple guard, merchant, priest, commoner, laborer, noble)

This content exists as typed TypeScript data. It is not loaded from asset files or a database.

License

Proprietary — All rights reserved.

← Back to Home

Uruk Engine © 2026