Below is an updated README.md that reflects the major changes in the project:
LampCrusher2 is an interactive WebGL game that combines Three.js with a custom GPU rendering pipeline and physics engine. Inspired by classic animation, you control a lamp that must crush falling letters. The project features advanced rendering techniques including physically based lighting, shadow mapping, temporal anti-aliasing (TAA), and dynamic post‑processing effects. In addition, a custom physics engine handles realistic movement and collision responses, while a flexible asset loading system supports both glTF and legacy OBJ/MTL models.
- Project Overview
- Project Structure
- Prerequisites
- Installation
- Running the Project
- Usage
- Additional Resources
LampCrusher2 has evolved from a basic Three.js application into a full-fledged game that features:
- Advanced Rendering: A custom GPU pipeline with multiple render passes, physically based rendering (PBR), shadow mapping, and temporal anti-aliasing for high-quality visuals.
- Custom Physics Engine: Simulates gravity, collision detection using oriented bounding boxes (OBBs), and spring-based soft-body responses when the lamp crushes letters.
- Flexible Asset Loading: Supports modern glTF models (via GLTFLoader) alongside legacy OBJ/MTL assets.
- Dynamic User Interface: Includes start menus, mode selection, an in-game HUD for health, score, and time, and animated score popups.
- Multiple Game Modes: Offers various difficulty levels and a demo mode for testing.
The project is organized as follows:
LampCrusher2/
├── LICENSE # License file for the project
├── LampCrusher2.10x # Additional build or version file
├── README.md # This documentation file
├── REPORT.md # Project report and analysis
├── dist/ # Production build output folder
├── gpu.js # GPU modules for mesh and shader management
├── index.html # Main HTML file
├── lamp_crusher_two.js # Main game logic and scene setup
├── main.js # Additional game setup and initialization code
├── node_modules/ # Installed npm packages
├── package-lock.json # npm lock file for dependency versions
├── package.json # Project dependencies and scripts
├── physics_engine.js # Custom physics engine implementation
├── public/ # Static assets folder
│ └── assets/ # Contains models (glTF, FBX, Blend files), textures, icons, etc.
├── renderer.js # Main rendering pipeline and scene management
├── shaders.js # GLSL shader source definitions
├── ui.css # Styles for the user interface
├── ui.js # User interface code (menus, HUD, popups)
└── vite.config.js # Vite configuration for development/build
Note: The project has undergone significant changes—from a simple Three.js demo to an advanced WebGL game with custom physics, rendering, and UI modules.
- Node.js: Install Node.js (v12 or above is recommended) from nodejs.org.
- npm: Node Package Manager (bundled with Node.js).
-
Clone the Repository
git clone https://github.com/your_username/LampCrusher2.git cd LampCrusher2 -
Install Dependencies
Run the following command to install the required packages:
npm install
-
(Optional) Update Start Scripts
Ensure your
package.jsonincludes:"scripts": { "dev": "vite", "build": "vite build" }
-
Start the Local Server
In your terminal, run:
npm run dev
or
npx vite
-
Open the Application
Once Vite starts, it will output a URL (e.g.,
http://localhost:3000). Open this URL in your browser.Note: The project uses ES Modules and dynamic asset loading, so it must be served from a local server rather than opened directly from the filesystem.
To compile and optimize the project for deployment:
npm run buildThe output files will be placed in the dist/ folder. You can host these files on your preferred web server.
If you prefer not to use Vite, you can serve the project using a static server:
npx serve distOr
npm run serveThen open the provided URL (e.g., http://localhost:3000) in your browser.
-
Movement Controls:
- W/A/S/D: Move the lamp around the scene.
- Space Bar: Make the lamp jump.
- Mouse Movement: Controls camera rotation. Click the canvas to lock the pointer.
-
View Mode Toggle:
- V Key: Toggle between first-person view (camera attached to the lamp) and third-person view (camera orbits the lamp).
-
Game Modes:
- Start Menu & Mode Selection: Upon launch, select from multiple game modes (Easy, Normal, Hard, Harder, or Demo).
- Demo Mode: Press
Pto pause health decrease for testing purposes.
-
Asset Loading:
- The project now supports modern glTF models (loaded via GLTFLoader) along with legacy OBJ/MTL formats, offering greater flexibility in asset management.
-
Special Effects:
- Enjoy advanced visual effects such as PBR lighting, dynamic shadow mapping, TAA for smoother visuals, and custom smoke effects triggered during gameplay events.
- Three.js Documentation: threejs.org/docs
- Vite Documentation: vitejs.dev/guide
- Node.js: nodejs.org
- WebGL Guides: See MDN Web Docs for comprehensive WebGL resources.