A Vue 3 + TypeScript web application that creates stunning lenticular effect cards using multiple images. The app allows users to upload 2-5 images, crop them to a consistent aspect ratio, and view them with an interactive lenticular effect that responds to device tilt or manual controls.
- Multi-Image Support: Upload 2-5 images for complex lenticular effects
- Smart Cropping: Crop images to a mobile-optimized 3:4 portrait aspect ratio
- Dual Orientation Modes: Choose between vertical and horizontal lenticular effects
- Dual Control Modes:
- Auto mode using device gyroscope/accelerometer
- Manual mode with drag controls and sliders
- Real-time 3D Rendering: WebGL-based lenticular effect using Three.js
- Mobile-First Design: Responsive interface optimized for mobile devices with touch support
- High Performance: Optimized for smooth 60fps performance without browser crashes
- GIF Export: Generate and download animated GIFs of the lenticular effect
- Multi-language Support: Available in English and Traditional Chinese
- Progressive Web App: Works offline and can be installed on devices
- Frontend Framework: Vue 3 with Composition API
- Language: TypeScript
- 3D Graphics: Three.js with TresJS (Vue wrapper)
- Styling: Tailwind CSS v4
- Build Tool: Vite
- Device Sensors: DeviceOrientationEvent API
- GIF Generation: gif.js with web workers
- Internationalization: Vue I18n
Start Screen β Image Upload β Image Cropping β Lenticular Preview
β β β β
Mode Selection β Step-by-Step β 3:4 Portrait β Real-time Effect
- Lenticular orientation selection (Vertical/Horizontal)
- Visual preview of each orientation mode
- Seamless switching between effect directions
- Mode selection (Auto/Manual)
- Gyroscope permission handling
- App introduction and feature overview
- Language switcher (top-right corner)
- Drag & drop file upload
- File validation and preview
- Support for JPG, PNG, GIF formats
- Interactive crop area with 3:4 portrait aspect ratio constraint
- Touch-enabled drag to reposition, pinch corner to resize
- Visual grid overlay for composition guidance
- Outputs standardized 600x800px portrait images
- 3D canvas container with touch and mouse interaction handling
- Drag/swipe support for manual control
- Real-time tilt value display and status indicators
- Always-visible GIF download button
- WebGL shader-based lenticular effect
- Multi-texture blending based on viewing angle
- Parallax offset for depth perception
- Visual enhancement effects (shimmer, rainbow lines)
- Device orientation permission management
- Gyroscope data processing and normalization
- Cross-platform compatibility (iOS/Android)
- High-quality GIF generation with web workers
- Customizable quality settings (Basic/High)
- Adjustable duration and frame count
- Progress tracking with real-time updates
- Language selection dropdown
- Persistent language preference storage
- Globe icon for easy identification
The lenticular effect is achieved through a custom WebGL fragment shader that:
- Creates Fine Strips: Divides the image into very thin strips (0.005 width)
- Vertical strips for vertical lenticular effect
- Horizontal strips for horizontal lenticular effect
- Maps Tilt to Images: Converts device tilt (-1 to 1) to image selection
- Blends Between Images: Smoothly transitions between adjacent images
- Adds Visual Effects:
- Ridge lines perpendicular to strip direction (horizontal lines for vertical effect, vertical lines for horizontal effect)
- Shimmer effect for realistic light reflection
- Subtle rainbow effect on the ridges
- Parallax offset for depth perception
All images are processed to maintain a consistent 3:4 portrait aspect ratio:
- Why 3:4 Portrait?: Perfect for mobile viewing in both orientations
- Mobile First: Optimized for smartphone screens where most users interact
- Touch Friendly: Larger touch targets and better ergonomics
- Input: Any aspect ratio image
- Cropping: User selects 3:4 portrait area of interest
- Output: 600x800px standardized portrait images
- Display: 3.75x5 unit 3D plane maintaining proportions
Benefits of 3:4 Portrait over Landscape:
- Natural mobile viewing: Fits perfectly in portrait orientation
- Better thumb reach: Easier to interact with on phones
- Reduced scrolling: More content visible without scrolling
- Instagram-friendly: Matches popular social media formats
- Drag to Move: Touch and drag crop area to reposition
- Pinch to Resize: Touch corner handle and drag to resize
- Swipe Control: Horizontal swipe on lenticular card for manual effect
- Prevent Scrolling:
touch-action: noneprevents page scrolling during interaction
- Fixed Bottom Bars: Action buttons always visible and accessible
- Larger Touch Targets: 44px minimum touch targets for accessibility
- Visual Feedback: Clear hover states and active states for touch
- Responsive Layout: Adapts to different screen sizes and orientations
- Detects device orientation changes
- Maps gamma rotation (-90Β° to 90Β°) to tilt value (-1 to 1)
- Requires user permission on iOS 13+
- Provides hands-free interaction
- Touch/mouse drag interaction
- Slider control for precise adjustment
- Smooth return-to-center animation
- Works on all devices without permissions
- Web Workers: Uses dedicated workers for non-blocking GIF generation
- Quality Options: Basic (300Γ400px) and High (450Γ600px) quality settings
- Customizable Duration: 2-5 seconds with adjustable frame count (20-40 frames)
- Smooth Animation: Oscillating tilt motion for natural lenticular effect
- Progress Tracking: Real-time progress updates with detailed status
- Pre-loaded Images: Images cached before generation starts
- Optimized Rendering: Efficient canvas-based frame generation
- Memory Management: Proper cleanup to prevent memory leaks
- Error Handling: Graceful fallbacks for failed operations
- 60fps Throttling: Limited updates to ~60fps (16ms intervals) for smooth performance
- Texture Optimization: Reduced texture size to 512px with 70% JPEG compression
- Shader Efficiency: Simplified fragment shader with reduced mathematical complexity
- Geometry Optimization: Lower polygon count (32x32) for better performance
- Memory Management: Proper cleanup of WebGL resources and textures
- Crash Prevention: Optimized to prevent browser crashes from excessive tilting
- Memory Leak Prevention: Comprehensive cleanup of event listeners and resources
- Error Handling: Graceful fallback for texture loading failures
- Resource Limits: Capped texture sizes and geometry complexity
- Cross-Device Performance: Works smoothly on both high-end and low-end devices
- Battery Optimization: Reduced GPU usage extends battery life
- Touch Event Optimization: Passive event listeners where appropriate
- Responsive Scaling: Adapts performance to device capabilities
- Tilt Smoothing: Weighted averaging prevents jittery movements
- Deadzone Implementation: 2-degree deadzone prevents micro-movement triggers
- Buffer Management: Circular buffers for smooth value interpolation
- Animation Throttling: Optimized return-to-center animations
- Languages: English and Traditional Chinese (ηΉι«δΈζ)
- Persistent Preferences: Language choice saved to localStorage
- Complete Translation: All UI elements and messages translated
- Contextual Content: Appropriate content for each language
- Globe Icon: Clear visual indicator for language switching
- Dropdown Interface: Easy language selection with current language highlighted
- Seamless Switching: Instant language changes without page reload
- Node.js 18+
- npm or yarn
# Clone the repository
git clone <repository-url>
cd lenticular-effect-generator
# Install dependencies
npm install
# Start development server
npm run dev
# Build for production
npm run build- Start the App: Open in browser and click "Start Creating"
- Select Mode: Choose Auto (gyroscope) or Manual (drag) control
- Upload Images: Add 2-5 images using drag & drop or file picker
- Crop Images: Adjust the 3:4 portrait crop area for each image
- View Effect: Experience the lenticular effect with tilt or drag controls
- Export GIF: Generate and download animated GIF of your creation
To change the card aspect ratio, modify the CARD_ASPECT_RATIO constant in:
src/components/ImageCropper.vuesrc/components/LenticularPlane.vue
Popular alternatives:
16/10- Widescreen format1/1- Square format16/9- Video format
Customize the lenticular effect by modifying the fragment shader in LenticularPlane.vue:
stripWidth: Controls lenticular strip density (0.005 for performance)lineIntensity: Adjusts ridge visibility (0.15 for balance)shimmer: Controls light reflection effect (0.05 for subtlety)
Adjust performance settings in LenticularPlane.vue:
MAX_TEXTURE_SIZE: Maximum texture resolution (512px default)TILT_UPDATE_THROTTLE: Update frequency in milliseconds (16ms for 60fps)TILT_SMOOTHING_SAMPLES: Number of samples for smoothing (3 default)
Customize GIF export in GifGenerator.vue:
GIF_SETTINGS: Quality presets for Basic and High qualitytotalFrames: Default frame count (30 frames)gifDuration: Default animation duration (3 seconds)
The app uses Tailwind CSS for styling. Key design tokens:
- Color scheme: Slate/Purple gradient backgrounds
- Typography: Inter font family
- Spacing: 8px grid system
- Animations: Smooth transitions and micro-interactions
Add new languages by:
- Creating new locale files in
src/i18n/locales/ - Adding language options to
LanguageSwitcher.vue - Updating the language detection in
main.ts
- Chrome/Edge: Full support including gyroscope and touch
- Safari: Full support with permission prompts and touch
- Firefox: Manual mode with touch support (limited gyroscope)
- Mobile Browsers: Optimized experience with full touch controls
- Device Orientation: Only requested when Auto mode is selected
- File Access: Images processed locally, never uploaded to servers
- Storage: Language preference saved to localStorage only
- No Tracking: No analytics or user tracking implemented
- Ensure HTTPS connection (required for device sensors)
- Grant permission when prompted
- Try refreshing the page
- Fall back to Manual mode if issues persist
- Ensure you're touching the crop area or resize handle directly
- Try refreshing the page if touch events become unresponsive
- Check that browser supports touch events
- Browser Crashes: Fixed with performance optimizations in v1.3.0
- Slow Performance: Reduced texture quality automatically applied
- Memory Issues: Automatic cleanup prevents memory leaks
- GPU Overload: Shader complexity reduced for stability
- Slow Generation: High quality GIFs may take 1-2 minutes
- Generation Fails: Try reducing quality or frame count
- Large File Size: Use Basic quality for smaller files
- Browser Timeout: Refresh page and try again with lower settings
- Ensure viewport meta tag is present
- Check that bottom controls are visible
- Try rotating device if layout appears cramped
- Horizontal Lenticular Mode: Added support for horizontal lenticular effects alongside vertical mode
- Direction Selector: New component for choosing between vertical and horizontal orientations
- Proper Ridge Line Orientation: Fixed ridge lines to be perpendicular to lenticular strip direction
- Ridge Line Orientation: Fixed incorrect vertical ridge lines appearing in horizontal mode
- Shader Coordinate System: Corrected UV coordinate usage based on lenticular direction
- Visual Consistency: Ensured 3D preview matches GIF generation output
- GIF Export System: Generate and download animated GIFs of lenticular effects
- Multi-language Support: English and Traditional Chinese localization
- Improved UI Layout: Better button placement and visual hierarchy
- Enhanced Mobile Experience: Optimized touch interactions and responsive design
- Language Switcher: Globe icon in top-right corner on start page only
- Preview Page Layout: Title on left, "New Card" button on right
- Always-Visible GIF Button: Download GIF button always accessible at bottom
- Better Visual Feedback: Improved status indicators and progress displays
- Web Workers: GIF generation uses web workers for better performance
- Memory Optimization: Improved cleanup and resource management
- Error Handling: Better error recovery and user feedback
- Performance Monitoring: Real-time progress tracking for GIF generation
- Browser Crash Prevention: Comprehensive optimizations prevent crashes from excessive tilting
- 60fps Performance: Throttled updates ensure smooth 60fps performance
- Memory Management: Proper cleanup of WebGL resources and textures
- Shader Optimization: Simplified fragment shader reduces GPU load
- Texture Optimization: Reduced texture sizes and improved compression
- Error Handling: Graceful fallback for texture loading failures
- Resource Cleanup: Comprehensive disposal of Three.js resources
- Event Optimization: Passive event listeners and proper cleanup
- Cross-Device Compatibility: Optimized for both high-end and low-end devices
- Smooth Interactions: Eliminated jittery movements with tilt smoothing
- Battery Optimization: Reduced GPU usage extends device battery life
- Responsive Controls: Immediate feedback without performance lag
- Visual Quality: Maintained effect quality while improving performance
- Desktop Bottom Bar Visibility: Fixed bottom action buttons being cut off on desktop screens
- Mobile Aspect Ratio: Switched to 3:4 portrait ratio optimized for mobile devices
- Touch Controls: Added comprehensive touch support for drag-to-move and pinch-to-resize
- Control Mode Logic: Fixed confusing button behavior in mode selection
- TypeScript Errors: Resolved all compilation errors for better development experience
- Fixed Bottom Bars: Action buttons now always visible and accessible
- Touch-First Design: All interactions optimized for touch devices
- Portrait Aspect Ratio: 3:4 ratio perfect for mobile viewing
- Better Visual Feedback: Enhanced touch states and interaction indicators
- Improved Layout: Better spacing and organization for mobile interfaces
- Event Handling: Proper touch event management with passive listeners
- Memory Management: Better cleanup of event listeners and resources
- Performance: Optimized touch interactions and reduced layout thrashing
- Accessibility: Larger touch targets and better contrast ratios
This project is open source and available under the MIT License.