This project simulates a cinematic "camera scan" animation for vertical infographics using React Three Fiber (R3F) and Three.js. It is designed to take a high-resolution portrait image, scan it from top to bottom, and then zoom out to a full 'cover' view.
- Portrait Optimization: Automatically detects image aspect ratio to scale the 3D mesh appropriately.
- Procedural Animation: A custom "Scroll & Zoom" camera rig that:
- Starts at the top of the image.
- Smoothly pans down to the bottom (reading phase).
- Zooms out to fit the entire image on screen (overview phase).
- Post-Processing: Uses
EffectComposerandBloomto add a subtle cinematic glow. - Dynamic Background: Clean, neutral studio environment.
- Node.js (v16+)
- npm
-
Clone the repository:
git clone https://github.com/statechangelabs/threejs-animation.git cd threejs-animation -
Install dependencies:
npm install
Start the development server:
npm run devOpen your browser to http://localhost:5173 (or the port shown in your terminal).
- Default View: On load, the app uses a placeholder infographic.
- Upload: Click the "Upload Image" button in the top-left UI to upload your own portrait/vertical image (e.g., a
.pngor.jpginfographic). - Animation: The 3D scene will automatically update the mesh dimensions and restart the camera animation loop.
src/App.tsx: Main entry point containing the logic.DashboardPlane: The 3D mesh that displays the image. Handles texture loading and aspect ratio calculation.ScrollZoomCameraRig: The animation controller that moves the camera based onuseFrameand time.
src/components/: (If applicable) Reusable R3F components.
- Vite: Build tool.
- React: UI Framework.
- Three.js & React Three Fiber: 3D rendering.
- Tailwind CSS: UI styling.
- @react-three/postprocessing: Visual effects.