I'll create an impressive Temple Run clone with Three.js, featuring endless running, lane switching, turns, obstacles, coins, and a temple-themed 3D environment. Let me start by examining the project structure and then build the game.
Now I'll install Three.js and then build the game. Let me install the package first.
Three.js is installed. Now I'll create the complete Temple Run clone game. This will be a comprehensive 3D endless runner with lane switching, 90-degree turns, obstacles, coins, and a temple-themed environment.
Let me create the game engine first:
I need to fix the TypeScript errors. Let me fix the issues:
Now let me fix the remaining two errors. Let me find the exact locations:
All TypeScript errors are fixed. Now let me create the App.tsx with the game UI overlay:
Now let me update the HTML title and check the other setup files:
Now let me try building the project to see if everything works:
The build succeeded! But I noticed a critical bug in the React component - the useEffect depends on [bestScore, score] which would recreate the entire game engine every time the score changes. Let me fix this:
Let me build again to confirm everything works:
The build succeeded! Let me now review the game engine file one more time to make sure it's complete and verify any potential runtime issues:
The game engine looks solid. Let me verify the complete flow works by doing a final build:
The build succeeded! The Temple Run clone is complete. Here's a summary of what I built:
🏛️ Temple Run Clone - Complete Game
Core Features:
- 3D Endless Runner using Three.js with a temple-themed corridor environment
- Three Lane System — switch lanes to dodge obstacles
- 90° Turns — swipe in the correct direction at intersections (wrong direction = game over!)
- Three Obstacle Types:
- 🔴 Low barriers — jump over them (↑)
- 🔴 High beams — slide under them (↓)
- 🔴 Full barriers — must dodge by lane switching
- Collectible Coins — spinning golden torus shapes that float and glow
- Progressive Speed — starts at 15, maxes at 40, increasing over time
Visual Design:
- Stone corridor with walls, pillars, and golden trim/caps
- Golden archways marking each turn intersection
- Warm torch lighting system that follows the player
- Dark atmospheric fog (FogExp2) for depth
- Gold center line and lane divider lines on the floor
- Running character with animated legs, arms, and body bob
- Crouch/slide animation with compressed body
UI/UX:
- Start Screen — title, controls legend, animated temple icon
- HUD — coin count and distance meter during gameplay
- Game Over Screen — final score, distance, best score tracking
- Mobile Controls — on-screen buttons + swipe support for phones
- Keyboard Controls — Arrow keys or WASD
Technical:
- Shared geometry/material pooling for performance
- Torch light pool system (reusable PointLights near player)
- Proper segment cleanup and memory management
- Smooth camera rotation with lerp-based angle transitions
- Collision detection with 3D hitboxes (vertical ranges per obstacle type)
- React state management with refs for real-time score updates
Files built: src/game/GameEngine.ts, src/App.tsx, index.html, src/index.css