This is an AI-assisted demonstration project exploring the intersection of artificial intelligence and 3D web development. Using Claude Code and Test-Driven Development (TDD), this project showcases how AI can help build interactive 3D spaces with Three.js. The goal is to create an immersive card game environment while documenting the AI-driven development process.
Current Status: Story 1 Implementation - Basic Scene Setup & Performance Monitoring
- ✅ Three.js project with TypeScript configuration
- ✅ Basic 3D scene with camera, renderer, and lighting
- ✅ FPS counter/stats display for performance monitoring
- ✅ WebGL renderer with performance optimization flags
- ✅ Ambient and directional lighting
- ✅ Responsive canvas that fills the viewport
- ✅ 60 FPS baseline performance capability
All functionality was implemented following strict TDD principles:
- Tests written first
- Implementation to make tests pass
- Comprehensive test coverage (36 tests, 100% passing)
/home/maxwell/ai.three.js.demo/
├── index.html # Main HTML entry point with FPS display
├── package.json # Project dependencies and scripts
├── tsconfig.json # TypeScript configuration
├── vite.config.ts # Vite build and test configuration
└── src/
├── main.ts # Application entry point
├── Scene.ts # Three.js scene management class
├── Scene.test.ts # Scene unit tests (18 tests)
├── FPSCounter.ts # FPS monitoring class
├── FPSCounter.test.ts # FPS counter unit tests (18 tests)
└── test-setup.ts # WebGL mocking for tests
Manages the Three.js scene, camera, renderer, and lighting:
- Camera: PerspectiveCamera with 75° FOV, positioned at (0, 5, 10)
- Renderer: WebGLRenderer with antialiasing and high-performance settings
- Lighting:
- Ambient light (0xffffff, intensity 0.6)
- Directional light (0xffffff, intensity 0.8) at position (5, 10, 7.5)
- Responsive: Automatically handles window resize
- Performance: Optimized pixel ratio (max 2x)
Real-time performance monitoring:
- Tracks frames per second (FPS)
- Measures frame time in milliseconds
- Smooths readings using 60-frame rolling average
- Updates DOM display every second
- Provides immediate calculation for testing
npm run devOpens at http://localhost:3000 with hot reload
npm test # Watch mode
npm test -- --run # Single run
npm run test:ui # Visual test UInpm run buildOutput in /dist directory
npm run previewAll 36 tests pass successfully:
- Initialization and element references
- FPS calculation and accuracy
- Frame time measurement
- DOM updates and formatting
- Performance under load
- Resource cleanup
- Scene and camera initialization
- WebGL renderer configuration
- Lighting setup (ambient + directional)
- Camera positioning
- Responsive canvas resizing
- Render loop management
- Resource disposal
✅ 60 FPS Baseline: Scene maintains 60 FPS with basic setup
- Optimized WebGL renderer settings
- Efficient pixel ratio management
- Proper resource cleanup
- Three.js (v0.180.0) - 3D graphics library
- TypeScript (v5.9.3) - Type-safe JavaScript
- Vite (v7.1.12) - Build tool and dev server
- Vitest (v4.0.4) - Unit testing framework
- jsdom - DOM environment for testing
All acceptance criteria from Story 1 have been met:
- ✅ FPS meter visible on screen
- ✅ Scene renders at consistent 60 FPS capability
- ✅ TypeScript compilation works without errors
- ✅ All tests pass (36/36)
- ✅ Production build successful
Story 1 is complete. The foundation is ready for:
- Story 2: Table and Environment Setup
- Story 3: Camera System with Player POV Switching
- Additional stories as defined in the technical specification
- Used TDD methodology throughout
- Created comprehensive WebGL mocks for headless testing
- Separated test files from production build
- Achieved full test coverage of core functionality
- Separated Scene and FPSCounter into distinct, testable classes
- Used dependency injection pattern for DOM elements
- Implemented proper cleanup methods for resource management
- Followed TypeScript strict mode best practices
- Limited pixel ratio to 2x for retina displays
- Used high-performance WebGL context
- Implemented efficient FPS calculation with rolling average
- Proper disposal of Three.js resources
All implementation files with absolute paths:
Source Files:
/home/maxwell/ai.three.js.demo/src/main.ts/home/maxwell/ai.three.js.demo/src/Scene.ts/home/maxwell/ai.three.js.demo/src/FPSCounter.ts
Test Files:
/home/maxwell/ai.three.js.demo/src/Scene.test.ts/home/maxwell/ai.three.js.demo/src/FPSCounter.test.ts/home/maxwell/ai.three.js.demo/src/test-setup.ts
Configuration Files:
/home/maxwell/ai.three.js.demo/tsconfig.json/home/maxwell/ai.three.js.demo/vite.config.ts/home/maxwell/ai.three.js.demo/package.json
HTML:
/home/maxwell/ai.three.js.demo/index.html