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 Architecture

The client uses a clear separation between reusable UI primitives and game-specific code:

UI Design System (src/ui/)

Pure, reusable UI components and systems:
Anchor-Based Positioning: Windows use viewport anchors (Unity/Unreal-style) for responsive scaling:

Game-Specific Code (src/game/)

All game logic and components:

Core UI (CoreUI.tsx)

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

3D Graphics System

Renderer (WebGPU with WebGL Fallback)

The graphics system uses Three.js with WebGPU for high-performance rendering, with automatic WebGL fallback for environments that don’t support WebGPU (e.g., WKWebView in Tauri, older browsers):

Renderer Backend Detection

WebGL Fallback Features

When running on WebGL backend:
  • No TSL Post-Processing: Bloom, tone mapping, and color grading are disabled
  • Simplified Shadows: Single directional light instead of Cascaded Shadow Maps (CSM)
  • Auto Exposure: Still works (tone mapping exposure is renderer-agnostic)
  • Settings Panel: Displays “WebGL” instead of “WebGPU”
The WebGL fallback uses THREE.WebGPURenderer with forceWebGL: true instead of switching to THREE.WebGLRenderer. This keeps the codebase unified while supporting both backends.

Rendering Pipeline

  1. Pre-render: Update matrices, frustum culling
  2. Shadow Pass: Render cascaded shadow maps
  3. Main Pass: Render scene with deferred lighting
  4. Post-Processing: Bloom, tone mapping, effects (TSL-based)
  5. UI Overlay: Render 2D React UI on top

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:

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: