A modern 3D web application built with WebGPU, Entity Component System (ECS) architecture, and Svelte 5. Features a functional programming approach with real-time 3D rendering, orbit controls, and an interactive ECS entity inspector.
- ๐ฎ Real-time 3D Rendering - WebGPU-powered graphics with depth testing and lighting
- ๐๏ธ ECS Architecture - Clean separation of data (components) and logic (systems)
- ๐ฏ Orbit Controls - Mouse-driven camera controls (drag to rotate, scroll to zoom)
- ๐ Entity Inspector - Collapsible panel showing ECS structure with entity selection
- ๐ผ๏ธ Render Graph - Node-based system orchestrating GPU compute and render passes
- ๐ง๏ธ Procedural Erosion - GPU-accelerated terrain erosion simulation
- โก Functional Programming - Pure functions, immutable patterns, and closures
- ๐ Hot Module Reload - Development-friendly with proper resource cleanup
- ๐จ Modern UI - Dark theme with SF Mono typography and UnoCSS styling
The application displays:
- A colorful floating cube with different colored faces
- A wireframe grid ground plane
- Interactive orbit camera controls
- Real-time ECS entity/component visualization
- Svelte 5 - UI framework with runes syntax
- WebGPU - Modern graphics API
- TypeScript - Type safety and developer experience
- wgpu-matrix - WebGPU-optimized matrix operations
- WGSL - WebGPU Shading Language for vertex/fragment shaders
- UnoCSS - Utility-first CSS with Tailwind preset
- Vite - Fast build tool with HMR support
- pnpm - Efficient package manager
- Node.js 18+
- pnpm (recommended) or npm/yarn
- Modern Browser with WebGPU support:
- Chrome/Edge 113+
- Firefox with WebGPU enabled
- Safari Technology Preview
git clone <repository-url>
cd cascade
pnpm install
pnpm dev
The application will be available at http://localhost:5173
- Mouse drag - Rotate camera around the scene
- Mouse wheel - Zoom in/out
- Toggle button (top-left) - Show/hide ECS inspector panel
- Click entities in the panel to select and highlight dependencies
pnpm dev # Start development server with HMR
pnpm build # Build for production
pnpm preview # Preview production bu
8000
ild locally
pnpm exec tsc --noEmit # Strict compile-time type checking
โโโ docs/
โ โโโ styleguide.md # Comprehensive style guide
โโโ public/ # Static assets
โโโ src/
โ โโโ components/ # Svelte UI components
โ โ โโโ CanvasPanel.svelte
โ โ โโโ ECSPanel.svelte
โ โ โโโ PropertiesPanel.svelte
โ โ โโโ FloatingText.svelte
โ โ โโโ EntityCard.svelte
โ โ โโโ ComponentCard.svelte
โ โ โโโ PropertyEditor.svelte
โ โ โโโ BooleanEditor.svelte
โ โ โโโ NumberEditor.svelte
โ โ โโโ StringEditor.svelte
โ โโโ ecs/ # Entity Component System
โ โ โโโ components.ts # Component definitions
โ โ โโโ systems/ # System implementations
โ โ โโโ types.ts # ECS types
โ โโโ gpu/ # WebGPU utilities
โ โโโ shaders/ # WGSL shader files
โ โโโ utils/ # Helper functions
โ โโโ app.ts # Main application logic
โ โโโ main.ts # Entry point
โ โโโ scene.ts # 3D scene setup
โโโ package.json
โโโ README.md
The application follows a functional ECS architecture:
- Entities - Unique IDs representing objects in the scene
- Components - Pure data containers (Transform, Mesh, Camera, etc.)
- Systems - Pure functions that process components (Render, OrbitControls, etc.)
render3DSystem
- Forward rendering pipeline for scene geometryorbitControlsSystem
- Mouse-based camera controlsrenderGraphSystem
- Modular render graph orchestrating compute & render passeserosionSystem
- Procedural terrain erosion simulation example
- Minimal device initialization focused on ECS integration
- Proper resource cleanup for development (HMR-safe)
- Error handling and recovery for device loss scenarios
This project follows strict functional programming and ECS patterns. Please refer to the comprehensive style guide for detailed conventions:
๐ Style Guide
Key principles:
- Functional programming over classes
- Pure functions and immutable data
- Proper resource cleanup
- ECS architecture consistency
- TypeScript strict mode
Browser | Status | Notes |
---|---|---|
Chrome 113+ | โ Stable | Full support |
Edge 113+ | โ Stable | Full support |
Firefox | ๐ Experimental | Enable dom.webgpu.enabled in about:config |
Safari | ๐ Preview | Safari Technology Preview only |
- Open
about:config
- Search for
dom.webgpu.enabled
- Set to
true
- Restart Firefox
"WebGPU not supported" Error
- Ensure you're using a compatible browser version
- Check if WebGPU is enabled in browser settings
HMR Errors in Development
- The app includes proper cleanup for Hot Module Reload
- If you see WebGPU device errors, refresh the page
Performance Issues
- WebGPU requires a discrete GPU for optimal performance
- Integrated graphics may have limited performance
- Use browser DevTools to monitor WebGPU resource usage
- The ECS inspector helps debug entity/component relationships
- Console logs provide detailed initialization and error information
- Follow the Style Guide for coding conventions
- Maintain functional programming patterns
- Ensure proper resource cleanup in new systems
- Test HMR scenarios during development
- Use TypeScript strictly (no
any
types)
[Add your license here]
Happy coding! ๐
For detailed development patterns and conventions, see the Style Guide.