Overview
Hyperscape uses a CDN-based architecture for serving game assets (3D models, textures, audio, manifests). The system supports local development with Docker nginx, production deployment to Cloudflare R2, and automatic fallback for incomplete local caches. CDN code lives in:scripts/cdn.mjs- Local CDN Docker managementscripts/ensure-assets.mjs- Asset download and LFS handlingpackages/server/src/startup/config.ts- Manifest fetching and validation
Architecture
Local Development CDN
Docker nginx Setup
The local CDN runs in a Docker container serving frompackages/server/world/assets:
Starting the CDN
Asset Directory Structure
Manifest Validation
Required Manifests
The server validates that critical manifests exist before starting:Validation Flow
Production CDN Fallback
In development, if the local CDN is incomplete, the server automatically falls back to production:Asset Download
Automatic Download
Assets are automatically downloaded duringbun install:
Full Asset Detection
The script distinguishes between full assets and manifests-only:Git LFS Handling
Partial Directory Cleanup
If a partial/manifest-only directory exists, it’s removed before cloning:Production Deployment
Cloudflare R2
Production assets are deployed to Cloudflare R2:.github/workflows/deploy-cloudflare.yml
- Triggers on push to
mainbranch - Uploads assets to R2 bucket
- Sets
PUBLIC_CDN_URLenvironment variable
Environment Variables
CDN Verification
Test CDN health and asset availability:- Health check endpoint
- Music files (normal/combat)
- Manifest files
- Environment models and textures
Manifest Fetching
Server fetches manifests from CDN on startup:Caching Strategy
- Development: Skip fetch if required manifests exist locally
- Production: Always fetch from CDN
- Fallback: Use production CDN if localhost CDN incomplete
PhysX Assets
PhysX WASM runtime is copied to the CDN:Related Documentation
- Configuration - Environment variables
- Docker - Docker setup
- Deployment - Production deployment
- Manifests - Manifest file structure