Architecture Overview
Hyperscape is built on a custom 3D multiplayer engine using Entity Component System (ECS) architecture. The engine lives inpackages/shared/ and provides:
- Entity Component System — Game object architecture
- Three.js Integration — 3D rendering (v0.180.0)
- PhysX Bindings — Physics simulation via WASM
- Real-time Networking — WebSocket multiplayer sync
- React UI Components — In-game interface
The engine is designed as a general-purpose 3D world engine. The RPG-specific code is conceptually isolated from core engine systems.
Core Package Structure
ECS Architecture
The game uses a strict Entity Component System pattern where:Components
Components are pure data containers attached to entities:Systems
Systems process entities and implement game logic:The World Class
TheWorld class is the central orchestrator that manages all entities, components, and systems:
Source:
packages/shared/src/core/World.tsEntity Types
The engine defines several entity types inentities/:
Entity Hierarchy
Type System
Hyperscape uses a modular type system with types split across multiple files:TypeScript Rules
Hyperscape enforces strict TypeScript rules:No any types
No any types
any is forbidden by ESLint. Use specific types, union types, or generic constraints instead.Prefer classes over interfaces
Prefer classes over interfaces
Classes provide runtime type information and better
instanceof checks.Use type assertions
Use type assertions
When you know the type from context, assert it confidently.
Use import type
Use import type
For type-only imports, use
import type to avoid circular dependencies.Build System
The engine uses Turbo for monorepo builds with dependency ordering:physx-js-webidl(PhysX WASM)shared(depends on physx)- All other packages (depend on shared)
Detailed Documentation
ECS Deep Dive
Deep dive into entities, components, systems, and the World class with full code examples.
Combat System
OSRS-accurate tick-based combat mechanics, damage formulas, and aggro system.
Skills & XP
RuneScape XP curves, leveling, combat level calculation, and skill requirements.
Tile Movement
Discrete tile-based movement, pathfinding, and OSRS melee range rules.