A cinematic, interactive single-bulb web scene built with Vite and vanilla JavaScript.
Users can pull a hanging chain to toggle the chandelier bulb on and off. The experience is designed to feel physical, with spring-like motion, ambient lighting transitions, and responsive behavior across desktop, tablet, and mobile devices.
- Overview
- Key Features
- Tech Stack
- Project Structure
- Getting Started
- Available Scripts
- Accessibility and Input Support
- Responsive Design Notes
- Deployment
- Customization Guide
- Troubleshooting
- License
The Last Bulb renders a full-screen dark environment containing:
- A stylized chandelier-inspired fixture
- A single realistic bulb with glow states
- A pull-chain interaction model
- Dynamic ambient illumination and floor shadowing
When the chain is pulled and released, the bulb toggles state and the scene transitions between dark and illuminated moods.
- Interactive pull-chain control with physical-feeling motion
- Toggle behavior on pull-release threshold
- Smooth light-state transitions (off to on, on to off)
- Real-time chain swing and recovery animation
- Cinematic glow, halo, and floor-shadow treatment
- Keyboard, pointer, and touch support
- Responsive layout for multiple viewport sizes
- Reduced motion support for accessibility preferences
- Vercel-ready deployment configuration
- Runtime: Browser (ES Modules)
- Build Tool: Vite 8
- Language: Vanilla JavaScript (no framework)
- Styling: CSS (custom, component-like sectioning)
- Package Manager: npm
.
├─ public/
│ └─ favicon.svg
├─ src/
│ ├─ main.js
│ └─ style.css
├─ index.html
├─ package.json
├─ vercel.json
└─ README.md
- Node.js >= 20.19.0
- npm >= 10 (recommended)
npm installnpm run devVite will print a local URL (for example, http://127.0.0.1:5173).
Starts the Vite development server with hot reload.
Builds an optimized production bundle into the dist directory.
Serves the production build locally for final verification.
The interaction layer supports multiple input modes:
- Mouse or trackpad: drag the chain handle
- Touch devices: pull via touch drag
- Keyboard: focus the chain handle and use Enter, Space, or ArrowDown
Accessibility improvements include:
- Interactive handle exposed with button semantics
- Keyboard focus visibility
- ARIA pressed-state updates
- Reduced motion compatibility via prefers-reduced-motion
The scene includes breakpoint and viewport-height adaptations for:
- Large desktop screens
- Standard tablets
- Mobile portrait layouts
- Short-height viewports (small laptops or landscape phones)
Core visual elements (fixture, bulb, chain, and instruction text) scale and reposition to maintain composition quality and interaction usability.
This project includes a Vercel configuration file.
Configured values:
- Framework: vite
- Install Command: npm install
- Build Command: npm run build
- Output Directory: dist
- Push the repository to GitHub.
- Import the repository in Vercel.
- Confirm auto-detected settings (or use the values listed above).
- Deploy.
Adjust scene colors and gradients in src/style.css:
- Background mood gradients
- Bulb glow tones
- Fixture metal palette
- Shadow intensity
Adjust pull and motion behavior in src/main.js:
- toggleThreshold: pull distance needed to toggle
- maxPull: maximum drag distance
- swing damping/spring values for return animation
Update instructional text and ARIA labels in:
- index.html
- src/main.js
Ensure Node.js matches the engines requirement in package.json:
- Node >= 20.19.0
Try the following:
- Remove node_modules and reinstall dependencies.
- Run npm install.
- Run npm run dev again.
If your project path contains special shell characters (such as ampersand), npm lifecycle scripts may fail on Windows default shell.
Workaround:
npm config set script-shell "C:\\Program Files\\Git\\bin\\bash.exe"Then run install/build scripts again.
This project is currently licensed under ISC, as defined in package.json.
