Skip to main content

Architecture Overview

Hyperscape is built on a custom 3D multiplayer engine using Entity Component System (ECS) architecture. The engine lives in packages/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:
All game logic runs through systems, not entity methods. Entities are pure data containers.

Components

Components are pure data containers attached to entities:

Systems

Systems process entities and implement game logic:

The World Class

The World class is the central orchestrator that manages all entities, components, and systems:
Source: packages/shared/src/core/World.ts

Entity Types

The engine defines several entity types in entities/:

Entity Hierarchy


Type System

Hyperscape uses a modular type system with types split across multiple files:
New code should import from specific type files for better organization. All types are also re-exported from types/core/core.ts for backward compatibility.

TypeScript Rules

Hyperscape enforces strict TypeScript rules:
any is forbidden by ESLint. Use specific types, union types, or generic constraints instead.
Classes provide runtime type information and better instanceof checks.
When you know the type from context, assert it confidently.
For type-only imports, use import type to avoid circular dependencies.

Build System

The engine uses Turbo for monorepo builds with dependency ordering:
Build order is automatically handled:
  1. physx-js-webidl (PhysX WASM)
  2. shared (depends on physx)
  3. 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.