Skip to main content

Client Application

The Hyperscape client is a React-based web application with Three.js WebGPU rendering. It provides a modern MMORPG experience with VRM avatars, responsive UI panels, and real-time multiplayer.
Client code lives in packages/client/src/. The rendering systems are in packages/shared/src/systems/client/.

Architecture Overview


Entry Point

The client entry point is packages/client/src/index.tsx:

Authentication Flow

Authentication uses Privy for wallet-based login:

Screens

Login Screen

  • Wallet connection via Privy
  • Social login (email, Google)
  • Session persistence

Character Select Screen

  • List existing characters
  • Create new character
  • Character preview with VRM avatar

Game Client

  • Main game loop
  • World initialization
  • UI overlay rendering

UI Components

Unified Tooltip System (March 2026)

New Feature (PR #1102): Unified tooltip styling system with consistent behavior across all UI panels.
The tooltip system provides centralized style utilities for consistent tooltip appearance: Location: packages/client/src/ui/core/tooltip/tooltipStyles.ts Style Functions:
Usage Example:
Panels Using Unified Tooltips:
  • Inventory Panel
  • Equipment Panel
  • Bank Panel
  • Skills Panel
  • Prayer Panel
  • Spells Panel
  • Store Panel
  • Trade Panel
  • Duel Panel
  • Action Bar
  • Loot Window
Benefits:
  • Consistent visual language across all UI
  • Centralized style management
  • Easy theme customization
  • Reduced code duplication (~500 lines eliminated)

Core UI (CoreUI.tsx)

The main UI wrapper that renders HUD elements and game panels:

Game Panels

Located in packages/client/src/game/panels/:

HUD Components

Located in packages/client/src/game/hud/:
  • StatusBars.tsx - Health, prayer, run energy bars
  • XPProgressOrb.tsx - XP tracking orb with skill icons
  • ActionProgressBar.tsx - Skilling action progress
  • EntityContextMenu.tsx - Right-click context menus
  • Minimap.tsx - RS3/OSRS-accurate top-down map view with location icons
  • Nametags.ts - Entity name/level labels

Minimap System

The minimap provides RS3/OSRS-accurate navigation with location icons and entity tracking. Visual Standards (OSRS-accurate):
  • White dots: Other players
  • Yellow dots: NPCs, mobs, and buildings
  • Red dots: Ground items and loot
  • White square: Local player (distinct from other players)
  • Red flag: Destination marker (RS3-style)
Location Icons: The minimap displays icons for key locations instead of generic dots: Quest Icon States: Quest giver NPCs display state-aware icons based on quest progress:
Quest Status Synchronization: The minimap fetches quest statuses from the server and updates icons in real-time:
Icon Behavior:
  • Blue ”!”: NPC has at least one available quest (not started)
  • Blue ”?”: NPC has at least one quest in progress
  • No icon: All quests completed (shows bank/shop icon if NPC provides those services)
  • Icons disappear when all of an NPC’s quests are completed
NPC Configuration: Quest giver NPCs must have questIds field in their configuration:
The questIds field is passed through the spawn → network → client pipeline so the minimap can identify quest giver NPCs and display appropriate icons. Icon Detection: Icons are automatically assigned based on entity configuration:
Bug Fix (PR #885): Fixed broken NPC service detection cast. The services field is string[], not { types: string[] }. This also fixed bank/shop icon detection which was previously broken.
Size Hierarchy:
  • Entity dots: 6px diameter (compact for clarity)
  • Location icons: 12px diameter (prominent for navigation)
Rendering:
  • 3D terrain rendered via orthographic camera (throttled to ~15fps for performance)
  • 2D overlay canvas for entity pips and icons (60fps for smooth interaction)
  • Cached projection-view matrix keeps pips synced with throttled 3D render
  • Pre-allocated vectors avoid GC pressure in render loop
Features:
  • Click-to-move on minimap
  • Scroll to zoom (20-1000 tile extent)
  • Rotates with main camera (RS3-style)
  • Destination marker persists until reached
  • Resizable and collapsible
  • Edit mode support for UI customization

3D Graphics System

WebGPU Renderer

The graphics system uses Three.js with WebGPU for high-performance rendering:
WebGPU Required: All rendering uses TSL (Three Shading Language) which only works with WebGPU. There is no WebGL fallback. Requires Chrome 113+, Edge 113+, or Safari 18+ (macOS 15+). Check compatibility at webgpureport.org.Breaking Change (Feb 2026): WebGL fallback was completely removed. All shaders use TSL which only compiles to WebGPU. Users on browsers without WebGPU will see an error screen with upgrade instructions.
WebGPU Initialization Timeouts: The renderer includes timeout protection to detect GPU driver issues:
These timeouts help diagnose misconfigured GPU servers where WebGPU initialization hangs indefinitely.
Post-Processing Pipeline: The post-processing system uses TSL (Three Shading Language) for all effects:
Post-Processing Effects (TSL-based):
  • Bloom: Glow effects for magical items and particles
  • Tone Mapping: HDR to LDR conversion with auto-exposure
  • Color Grading: LUT-based color correction
  • Outline: Entity highlighting for hover/selection
Fix Applied (PR #829):
  • Issue: When LUT was “none” but hover triggered outline, stale LUT data leaked into rendering
  • Solution: Zero LUT intensity when disabled so outline-only rendering stays clean
  • Benefit: Entity highlights work correctly even when color grading is disabled

Rendering Pipeline

  1. Pre-render: Update matrices, frustum culling
  2. Shadow Pass: Render cascaded shadow maps (CSM)
  3. Main Pass: Render scene with deferred lighting
  4. Post-Processing: Bloom, tone mapping, color grading (TSL-based)
  5. UI Overlay: Render 2D React UI on top
All rendering uses WebGPU - there is no WebGL fallback path.

Model Loading & Transform Baking

The ModelCache system handles GLTF model loading with transform baking to prevent rendering issues:
Why Transform Baking? GLTF files can have transforms stored in various ways:
  • Position/rotation/scale properties
  • Baked into matrices
  • Non-decomposable transforms (shear)
Baking all transforms into vertex positions guarantees correct rendering regardless of how the GLTF was exported from Blender or other 3D tools. Quaternion Normalization: Entity rotations use quaternions with all four components (x, y, z, w):
This prevents “squished” or incorrectly rotated models that can occur when quaternion components are not properly normalized.

Camera System

Supports multiple camera modes:
Camera Initialization Fix (PR #829): The camera now correctly initializes with theta=Math.PI for standard third-person behind-the-player view. Previously, theta=0 placed the camera in front of the player, causing backwards movement on fresh load.

VRM Avatar System

Characters use VRM format avatars with humanoid bone mapping:

VRM Bone Mapping


Client Systems

Located in packages/shared/src/systems/client/:

Embedded Mode

For stream overlays and spectator views: