A retro-styled 3D CRT terminal with WebGL effects built with TypeScript and Vite.
- 3D WebGL Rendering: Terminal displayed on a 3D monitor with perspective camera
- CRT Effects: Authentic CRT monitor simulation with barrel distortion, scanlines, and phosphor glow
- Terminal Emulation: Powered by xterm.js with canvas renderer
- Clean Architecture: Dependency Inversion Principle (DIP) for terminal source abstraction
- TypeScript: Fully typed, modular codebase
- Vite: Fast development and optimized builds
The project follows SOLID principles with clear separation of concerns:
src/
├── core/ # Core application logic
│ ├── Application.ts # Main application orchestrator
│ └── ITerminalSource.ts # Interface for terminal abstraction (DIP)
├── terminal/ # Terminal implementation
│ └── XTermAdapter.ts # xterm.js adapter implementing ITerminalSource
├── rendering/ # WebGL rendering
│ ├── WebGLRenderer.ts # Main renderer class
│ ├── screenShader.ts # CRT screen shaders
│ └── bezelShader.ts # Monitor bezel shaders
├── geometry/ # 3D geometry definitions
│ └── CRTMonitor.ts # CRT monitor mesh generator
├── utils/ # Utility functions
│ ├── matrix.ts # Matrix math operations
│ └── shader.ts # Shader compilation helpers
├── main.ts # Application entry point
└── style.css # Global styles
- Node.js (v14 or higher)
- npm or yarn
npm installStart the development server:
npm run devThe app will be available at http://localhost:5173
Create a production build:
npm run buildThe built files will be in the dist directory.
Preview the production build locally:
npm run previewThe terminal and rendering are decoupled through the ITerminalSource interface:
- High-level module:
WebGLRendererdepends onITerminalSourceabstraction - Low-level module:
XTermAdapterimplementsITerminalSource - This allows easy swapping of terminal implementations without modifying the renderer
Each class has a single, well-defined responsibility:
Application: Orchestrates the application lifecycleWebGLRenderer: Handles WebGL renderingXTermAdapter: Manages terminal logicCRTMonitor: Generates 3D geometry
- Terminal logic is isolated in
terminal/ - Rendering logic is isolated in
rendering/ - Geometry generation is isolated in
geometry/ - Utilities are reusable and side-effect free
- TypeScript - Type-safe JavaScript
- Vite - Next-generation frontend tooling
- xterm.js - Terminal emulator for the web
- WebGL - 3D graphics API
ISC