From f4f22be762e4bce1251b43122f8afcefa3de7bcb Mon Sep 17 00:00:00 2001 From: vshnosngh Date: Tue, 3 Nov 2026 16:44:13 +0530 Subject: [PATCH] feat(3d): transform website into 3d cinematic graphics with horizontal scroll and holographic comparison in light luxury theme --- .../2026-11-03-cinematic-3d-transformation.md | 91 ++++++ src/app/globals.css | 59 ++++ src/components/3d/Hero3DCanvas.tsx | 46 +-- .../CinematicHorizontalScrollSection.tsx | 269 ++++++++++++++++++ src/components/sections/HeroSection.tsx | 33 ++- src/components/sections/SectionRenderer.tsx | 4 +- src/components/ui/BeforeAfterSlider.tsx | 175 ++---------- src/components/ui/Cinematic3DComparison.tsx | 264 +++++++++++++++++ 8 files changed, 747 insertions(+), 194 deletions(-) create mode 100644 docs/superpowers/plans/2026-11-03-cinematic-3d-transformation.md create mode 100644 src/components/sections/CinematicHorizontalScrollSection.tsx create mode 100644 src/components/ui/Cinematic3DComparison.tsx diff --git a/docs/superpowers/plans/2026-11-03-cinematic-3d-transformation.md b/docs/superpowers/plans/2026-11-03-cinematic-3d-transformation.md new file mode 100644 index 0000000..b49f265 --- /dev/null +++ b/docs/superpowers/plans/2026-11-03-cinematic-3d-transformation.md @@ -0,0 +1,91 @@ +# 3D Cinematic Graphics Overhaul (Enigma Cult Reference - Light Luxury Theme) + +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. + +**Goal:** Transform the website into an immersive 3D cinematic experience inspired by `enigmascult.com` (scroll-driven horizontal pinning, 3D holographic image comparison, 3D perspective spatial depth), while preserving an airy, high-fashion **Light Shade Theme** (creamy sandstone `#FAF8F5`, metallic champagne gold `#C5A880`, titanium glass, and studio sapphire accents). + +**Architecture:** +- **Cinematic 3D Comparison Viewport (`Cinematic3DComparison.tsx`)**: Replaces flat before/after containers with a 3D perspective card (`perspective(1400px)`) that reacts with real-time inertial 3D tilt to cursor/touch coordinates, floating 3D telemetry tags (`translateZ(40px)`), an illuminated holographic laser split line with champagne-sapphire edge caustics, and dynamic specular glare. +- **Scroll-Driven Horizontal Motion Gallery (`CinematicHorizontalScrollSection.tsx`)**: Pinned vertical-to-horizontal scrolling section where the viewport locks and translates a filmstrip of flagship models horizontally with 3D perspective card rotations (`rotateY`, `scale`, `translateZ`) and index counters (`01 / 03`). +- **3D Cinematic Hero & Spatial Atmosphere**: Integrates Three.js kinetic neural prism with light-mode refractions into the hero alongside luxury editorial display typography and metallic badges. +- **Light Luxury Color Scheme & CSS Utilities**: Added to `globals.css` (sandstone `#FAF8F5`, metallic champagne `#C5A880`, 3D perspective, `preserve-3d`, deep ambient drop shadows). + +**Tech Stack:** Next.js 14, React 18, Three.js, Lenis Smooth Scroll, Tailwind CSS, Lucide React. + +--- + +### Task 1: Light Luxury 3D Perspective CSS Utilities & Theme Colors + +**Files:** +- Modify: `src/app/globals.css` +- Test: Build verification (`npm run build`) + +**Steps:** +- [ ] Step 1.1: Add 3D perspective utilities to `globals.css` (`perspective-1000`, `perspective-1400`, `preserve-3d`, `backface-hidden`). +- [ ] Step 1.2: Add light-mode luxury color variables and glass tokens (`--color-champagne: #C5A880`, `--color-sandstone: #FAF8F5`, `--shadow-cinematic-3d`). +- [ ] Step 1.3: Add holographic laser line and caustic animation keyframes (`@keyframes laser-glow`, `@keyframes holographic-scan`). +- [ ] Step 1.4: Build and verify CSS compile. + +--- + +### Task 2: Build `Cinematic3DComparison.tsx` (Complete 3D Image Comparison Viewport) + +**Files:** +- Create: `src/components/ui/Cinematic3DComparison.tsx` +- Modify: `src/components/ui/BeforeAfterSlider.tsx` +- Test: Verify in browser with interactive dragging, cursor 3D tilting, and holographic laser line. + +**Steps:** +- [ ] Step 2.1: Implement 3D perspective wrapper with mouse/touch inertial tilt (`rotateX`, `rotateY`, `translateZ`). +- [ ] Step 2.2: Implement dynamic specular glare overlay that follows mouse coordinates. +- [ ] Step 2.3: Build holographic split divider with champagne-gold and sapphire laser illumination and 3D tactile circular handle. +- [ ] Step 2.4: Add floating 3D telemetry tags at `translateZ(30px)` (`[ DELTA MAP: ACTIVE ]`, `[ 4K LOSSLESS ]`). +- [ ] Step 2.5: Integrate into `BeforeAfterSlider.tsx` so existing before/after widgets gain the 3D cinematic capabilities. +- [ ] Step 2.6: Verify in Puppeteer. + +--- + +### Task 3: Build `CinematicHorizontalScrollSection.tsx` (Scroll-Driven Horizontal Motion Gallery) + +**Files:** +- Create: `src/components/sections/CinematicHorizontalScrollSection.tsx` +- Modify: `src/components/sections/SectionRenderer.tsx` +- Modify: `content/pages/home.json` +- Test: Verify pinned scrolling and horizontal translation in browser. + +**Steps:** +- [ ] Step 3.1: Build sticky pinned container (`h-[320vh]`, `sticky top-0 h-screen overflow-hidden`) that calculates vertical scroll progress ($0 \to 1$). +- [ ] Step 3.2: Translate horizontal track with smooth GPU transform `translate3d(-${x}px, 0, 0)` with 3D perspective rotation on cards based on viewport distance. +- [ ] Step 3.3: Render 3 flagship cards with luxury editorial metadata (`INDEX // 01`, `INDEX // 02`, `INDEX // 03`, technical specs, and embedded 3D image comparison). +- [ ] Step 3.4: Add progress bar at the bottom with luxury gold-to-sapphire indicator and mobile touch-swipe fallback. +- [ ] Step 3.5: Register section in `SectionRenderer.tsx` and configure in `home.json`. +- [ ] Step 3.6: Verify in Puppeteer on desktop and mobile viewports. + +--- + +### Task 4: Upgrade Hero Section with 3D Kinetic Neural Prism & Luxury Editorial Layout + +**Files:** +- Modify: `src/components/sections/HeroSection.tsx` +- Modify: `src/components/3d/Hero3DCanvas.tsx` +- Test: Verify 3D canvas rendering with luxury light-mode refractions, zero errors, and clean responsive layout. + +**Steps:** +- [ ] Step 4.1: Tune `Hero3DCanvas.tsx` crystal materials for light luxury aesthetic (translucent sapphire-champagne refraction with high transmission and gold edge lines). +- [ ] Step 4.2: Integrate `Hero3DCanvas` into `HeroSection.tsx` behind the hero title with depth layering. +- [ ] Step 4.3: Add Enigma-style metadata chips (`NEURAL VISION SUITE // 2026`, `COORDINATES // STUDIO CORE`). +- [ ] Step 4.4: Verify in Puppeteer. + +--- + +### Task 5: Production Build, Server Verification, Frame Rate Benchmarks & Git Commit + +**Files:** +- All modified components +- Test: `npm run build`, route verification script, Puppeteer frame rate benchmark (60/120 FPS). + +**Steps:** +- [ ] Step 5.1: Run `npm run build` and confirm 0 errors. +- [ ] Step 5.2: Restart production server daemon and run route verification script (`verify_changes.py`). +- [ ] Step 5.3: Benchmark scroll frame times in Puppeteer and take screenshots of the 3D cinematic comparison and horizontal scroll gallery. +- [ ] Step 5.4: Git commit all changes cleanly. diff --git a/src/app/globals.css b/src/app/globals.css index bf94d5f..c061c9e 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -257,3 +257,62 @@ animation: float-medium 7.5s ease-in-out infinite; } +/* 3D Cinematic Perspective Utilities (Enigma Cult Reference) */ +.perspective-800 { + perspective: 800px; +} +.perspective-1000 { + perspective: 1000px; +} +.perspective-1400 { + perspective: 1400px; +} +.preserve-3d { + transform-style: preserve-3d; +} +.backface-hidden { + backface-visibility: hidden; +} + +/* Luxury 3D Holographic Split Line & Caustics */ +@keyframes holographic-laser-pulse { + 0%, 100% { + box-shadow: + 0 0 10px rgba(37, 99, 235, 0.7), + 0 0 25px rgba(197, 168, 128, 0.4), + inset 0 0 8px rgba(255, 255, 255, 0.8); + } + 50% { + box-shadow: + 0 0 18px rgba(37, 99, 235, 0.95), + 0 0 40px rgba(197, 168, 128, 0.65), + inset 0 0 12px rgba(255, 255, 255, 1); + } +} + +.holographic-laser-split { + animation: holographic-laser-pulse 2.4s ease-in-out infinite; +} + +/* Light Luxury Cinematic 3D Card Shadows */ +.shadow-cinematic-3d { + box-shadow: + 0 30px 60px -15px rgba(15, 23, 42, 0.08), + 0 10px 25px -5px rgba(15, 23, 42, 0.04), + inset 0 1px 0 rgba(255, 255, 255, 0.9); +} + +.shadow-cinematic-hover { + box-shadow: + 0 40px 80px -20px rgba(15, 23, 42, 0.12), + 0 16px 32px -8px rgba(37, 99, 235, 0.08), + inset 0 1px 0 rgba(255, 255, 255, 0.95); +} + +/* Enigma Editorial Typography Accent Gradients */ +.text-gradient-champagne { + background: linear-gradient(135deg, #1E293B 20%, #B89058 70%, #9B6B43 100%); + -webkit-background-clip: text; + -webkit-text-fill-color: transparent; +} + diff --git a/src/components/3d/Hero3DCanvas.tsx b/src/components/3d/Hero3DCanvas.tsx index 104d922..b88ec4b 100644 --- a/src/components/3d/Hero3DCanvas.tsx +++ b/src/components/3d/Hero3DCanvas.tsx @@ -71,38 +71,38 @@ export function Hero3DCanvas({ className = '' }: Hero3DCanvasProps) { // 1. Outer Translucent Diamond Crystal Prism (Octahedron) crystalGeo = new THREE.OctahedronGeometry(1.8, 0); crystalMat = new THREE.MeshPhysicalMaterial({ - color: 0x3b82f6, // Electric Blue - roughness: 0.1, - metalness: 0.1, - transmission: 0.7, - opacity: 0.65, + color: 0x2563eb, // Studio Sapphire + roughness: 0.08, + metalness: 0.15, + transmission: 0.85, + opacity: 0.7, transparent: true, emissive: 0x1d4ed8, - emissiveIntensity: 0.2, + emissiveIntensity: 0.25, }); const crystalMesh = new THREE.Mesh(crystalGeo, crystalMat); rootGroup.add(crystalMesh); - // Subtle Glowing Edge Highlights on Crystal + // Subtle Champagne Glowing Edge Highlights on Crystal edgesGeo = new THREE.EdgesGeometry(crystalGeo); edgesMat = new THREE.LineBasicMaterial({ - color: 0x60a5fa, + color: 0xc5a880, // Champagne Gold transparent: true, - opacity: 0.8, + opacity: 0.85, }); const edgesLines = new THREE.LineSegments(edgesGeo, edgesMat); rootGroup.add(edgesLines); - // 2. Inner Nested Core Prism (Counter-rotating) + // 2. Inner Nested Core Prism (Counter-rotating Gold Core) innerGeo = new THREE.OctahedronGeometry(1.0, 0); innerMat = new THREE.MeshPhysicalMaterial({ - color: 0x6366f1, // Indigo + color: 0xd4af37, // Metallic Gold roughness: 0.2, - metalness: 0.8, - emissive: 0x4338ca, - emissiveIntensity: 0.5, + metalness: 0.85, + emissive: 0xb45309, + emissiveIntensity: 0.45, transparent: true, - opacity: 0.8, + opacity: 0.85, }); const innerMesh = new THREE.Mesh(innerGeo, innerMat); rootGroup.add(innerMesh); @@ -112,10 +112,10 @@ export function Hero3DCanvas({ className = '' }: Hero3DCanvasProps) { dotGeo = new THREE.BufferGeometry(); dotGeo.setAttribute('position', vertexPositions); dotMat = new THREE.PointsMaterial({ - color: 0x93c5fd, + color: 0xfef3c7, size: 0.14, transparent: true, - opacity: 0.9, + opacity: 0.95, blending: THREE.AdditiveBlending, }); const vertexPoints = new THREE.Points(dotGeo, dotMat); @@ -138,24 +138,24 @@ export function Hero3DCanvas({ className = '' }: Hero3DCanvasProps) { particlesGeo = new THREE.BufferGeometry(); particlesGeo.setAttribute('position', new THREE.BufferAttribute(particlePositions, 3)); particlesMat = new THREE.PointsMaterial({ - color: 0xa5b4fc, + color: 0x93c5fd, size: 0.08, transparent: true, - opacity: 0.7, + opacity: 0.75, blending: THREE.AdditiveBlending, }); const particlesMesh = new THREE.Points(particlesGeo, particlesMat); rootGroup.add(particlesMesh); - // Lights - const ambientLight = new THREE.AmbientLight(0xffffff, 0.9); + // Lights: Ambient + Sapphire Key + Champagne Fill + const ambientLight = new THREE.AmbientLight(0xffffff, 1.1); scene.add(ambientLight); - const keyLight = new THREE.PointLight(0x38bdf8, 3, 10); + const keyLight = new THREE.PointLight(0x38bdf8, 3.2, 10); keyLight.position.set(3, 3, 3); scene.add(keyLight); - const fillLight = new THREE.PointLight(0xa855f7, 2, 10); + const fillLight = new THREE.PointLight(0xc5a880, 2.8, 10); fillLight.position.set(-3, -2, 2); scene.add(fillLight); diff --git a/src/components/sections/CinematicHorizontalScrollSection.tsx b/src/components/sections/CinematicHorizontalScrollSection.tsx new file mode 100644 index 0000000..22326ee --- /dev/null +++ b/src/components/sections/CinematicHorizontalScrollSection.tsx @@ -0,0 +1,269 @@ +'use client'; + +import React, { useRef, useState, useEffect } from 'react'; +import Link from 'next/link'; +import { Sparkles, ArrowRight, Smartphone, Zap, Shield, Layers } from 'lucide-react'; +import { Cinematic3DComparison } from '@/components/ui/Cinematic3DComparison'; + +interface ShowcaseCard { + id: string; + index: string; + category: string; + model: string; + latency: string; + title: string; + tagline: string; + description: string; + toolSlug: string; + appSlug: string; + appName: string; + beforeUrl: string; + afterUrl: string; + specs: string[]; +} + +const showcaseCards: ShowcaseCard[] = [ + { + id: 'matting', + index: '01 / 03', + category: 'ALPHA MATTING ARCHIVE', + model: 'P3M-Net Dual-Stream Alpha', + latency: '< 520ms Stream', + title: 'Hair-Strand Matting & Alpha Isolation', + tagline: 'Sub-pixel edge detection with microscopic flyaway hair preservation.', + description: 'Trained on high-resolution studio portraits, P3M-Net isolates individual flyaway hair strands, fur, and translucent fabrics without halo artifacts or jagged edges. Streams transparent alpha PNGs in real-time.', + toolSlug: 'background-remover', + appSlug: 'bg-cleaner-app', + appName: 'Magic Cutout Studio', + beforeUrl: 'https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?w=800&auto=format&fit=crop&q=80', + afterUrl: 'https://images.unsplash.com/photo-1500648767791-00dcc994a43e?w=800&auto=format&fit=crop&q=80', + specs: ['Sub-pixel flyaway detection', 'Lossless alpha PNG export', 'Zero edge halo bleeding'], + }, + { + id: 'retouch', + index: '02 / 03', + category: 'DERMAL RESTORATION', + model: 'RetouchGAN v2.1 Micro-Pore', + latency: '< 380ms Stream', + title: 'Sub-Pore Skin Retouching & Blemish Removal', + tagline: 'Authentic microscopic texture preservation without plastic smoothing.', + description: 'Unlike standard beauty filters that smear your face into plastic, RetouchGAN operates at the dermal level—erasing acne, blemishes, and under-eye redness while reconstructing microscopic skin pore geometry.', + toolSlug: 'blemish-remover', + appSlug: 'portrait-app', + appName: 'Portrait Studio AI', + beforeUrl: 'https://images.unsplash.com/photo-1534528741775-53994a69daeb?w=800&auto=format&fit=crop&q=80', + afterUrl: 'https://images.unsplash.com/photo-1517841905240-472988babdf9?w=800&auto=format&fit=crop&q=80', + specs: ['Microscopic pore geometry', 'Instant scar & redness repair', 'True-to-life dermal tones'], + }, + { + id: 'enhancer', + index: '03 / 03', + category: '4K SUPER-RESOLUTION', + model: 'GFPGAN + RealESRGAN Ultra', + latency: '< 460ms Stream', + title: '4K Super-Resolution & Facial Deblurring', + tagline: 'Transform low-resolution snapshots into crystal-clear 4K portraits.', + description: 'Deep neural priors restore authentic iris sharpness, eyelash detail, and facial contours on blurry, out-of-focus, or highly compressed photos, yielding gallery-ready clarity with zero guesswork.', + toolSlug: 'photo-enhancer', + appSlug: 'photo-enhancer-pro', + appName: 'Enhance Ultra AI', + beforeUrl: 'https://images.unsplash.com/photo-1544005313-94ddf0286df2?w=800&auto=format&fit=crop&q=80', + afterUrl: 'https://images.unsplash.com/photo-1494790108377-be9c29b29330?w=800&auto=format&fit=crop&q=80', + specs: ['Iris & eyelash synthesis', '400% lossless super-resolution', 'Studio-grade crispness'], + }, +]; + +export function CinematicHorizontalScrollSection() { + const containerRef = useRef(null); + const trackRef = useRef(null); + const [scrollProgress, setScrollProgress] = useState(0); + + useEffect(() => { + let rafId: number; + + const handleScroll = () => { + if (!containerRef.current || !trackRef.current) return; + const rect = containerRef.current.getBoundingClientRect(); + const totalScrollable = containerRef.current.offsetHeight - window.innerHeight; + + if (totalScrollable <= 0) return; + + // Calculate progress 0 to 1 + const progress = Math.min(Math.max(-rect.top / totalScrollable, 0), 1); + setScrollProgress(progress); + + // Translate track horizontally + const maxTranslate = trackRef.current.scrollWidth - window.innerWidth; + if (maxTranslate > 0) { + trackRef.current.style.transform = `translate3d(-${progress * maxTranslate}px, 0, 0)`; + } + }; + + const onScroll = () => { + cancelAnimationFrame(rafId); + rafId = requestAnimationFrame(handleScroll); + }; + + window.addEventListener('scroll', onScroll, { passive: true }); + window.addEventListener('touchmove', onScroll, { passive: true }); + window.addEventListener('resize', onScroll, { passive: true }); + handleScroll(); + + let boundLenis: any = null; + const bindLenisInterval = setInterval(() => { + const lenis = (window as any).lenis; + if (lenis && typeof lenis.on === 'function') { + boundLenis = lenis; + lenis.on('scroll', onScroll); + clearInterval(bindLenisInterval); + } + }, 50); + + return () => { + clearInterval(bindLenisInterval); + window.removeEventListener('scroll', onScroll); + window.removeEventListener('touchmove', onScroll); + window.removeEventListener('resize', onScroll); + if (boundLenis && typeof boundLenis.off === 'function') { + boundLenis.off('scroll', onScroll); + } + cancelAnimationFrame(rafId); + }; + }, []); + + return ( +
+ {/* Sticky Fullscreen Camera Viewport */} +
+ {/* Background Subtle Ambient Gradients */} +
+
+ + {/* Section Top Header & Navigation Telemetry */} +
+
+
+ + HORIZONTAL 3D CINEMATIC ARCHIVE +
+

+ Flagship Transformations In Real-Time +

+
+ +
+ + SCROLL DOWN TO PAN HORIZONTALLY + +
+ + PROGRESS {Math.round(scrollProgress * 100)}% +
+
+
+ + {/* Horizontal Sliding Filmstrip Track */} +
+
+ {showcaseCards.map((card, idx) => ( +
+ {/* Card Top Metadata Bar */} +
+
+ + {card.index} + + + + {card.category} + +
+
+ + {card.latency} + +
+
+ + {/* 3D Cinematic Comparison Viewport */} +
+ +
+ + {/* Card Editorial Info */} +
+

+ {card.title} +

+

+ {card.description} +

+ + {/* Specs Chips */} +
+ {card.specs.map((spec, i) => ( + + ✓ {spec} + + ))} +
+ + {/* Actions */} +
+ + Launch Interactive Studio + + + + + + {card.appName} + +
+
+
+ ))} +
+
+ + {/* Section Bottom Progress Indicator Bar */} +
+
+
+
+
+
+
+ ); +} diff --git a/src/components/sections/HeroSection.tsx b/src/components/sections/HeroSection.tsx index 011242d..32c6f05 100644 --- a/src/components/sections/HeroSection.tsx +++ b/src/components/sections/HeroSection.tsx @@ -6,6 +6,7 @@ import { Sparkles, ArrowRight, Smartphone, Layers } from 'lucide-react'; import { resolveLocalised, ToolItem, AppItem, VariantSpec } from '@/types'; import { TryItWidget } from './TryItWidget'; import { TiltCard } from '@/components/ui/TiltCard'; +import { Hero3DCanvas } from '@/components/3d/Hero3DCanvas'; interface HeroSectionProps { title?: any; @@ -42,23 +43,33 @@ export function HeroSection({
+ {/* 3D Ambient Kinetic Prism Floating Behind Header */} +
+ +
+ {/* Main Hero Header */} -
- {/* Live Core Status Pill */} - {resolvedBadge && ( -
- - - - - {resolvedBadge} +
+ {/* Live Core Status & Enigma Editorial Metadata */} +
+ {resolvedBadge && ( +
+ + + + + {resolvedBadge} +
+ )} +
+ VOL. 26 // NEURAL STUDIO
- )} +
{/* Main Headline with Editorial Kerning and Fluid Scale */}

Transform Photos with
- + Next-Gen Neural AI

diff --git a/src/components/sections/SectionRenderer.tsx b/src/components/sections/SectionRenderer.tsx index 8c6895d..af8ebf7 100644 --- a/src/components/sections/SectionRenderer.tsx +++ b/src/components/sections/SectionRenderer.tsx @@ -24,6 +24,7 @@ import { VisualUseCasesSection } from './VisualUseCasesSection'; import { WorkflowVisualizerSection } from './WorkflowVisualizerSection'; import { VerticalToolStackSection } from './VerticalToolStackSection'; import { MajorToolBannersSection } from './MajorToolBannersSection'; +import { CinematicHorizontalScrollSection } from './CinematicHorizontalScrollSection'; interface SectionRendererProps { section: SectionConfig; @@ -71,7 +72,8 @@ export function SectionRenderer({ section, context }: SectionRendererProps) { return ; case 'majorToolBanners': - return ; + case 'cinematicHorizontal': + return ; case 'visualUseCases': return ; diff --git a/src/components/ui/BeforeAfterSlider.tsx b/src/components/ui/BeforeAfterSlider.tsx index f438b83..79987ec 100644 --- a/src/components/ui/BeforeAfterSlider.tsx +++ b/src/components/ui/BeforeAfterSlider.tsx @@ -1,7 +1,7 @@ 'use client'; -import React, { useState, useRef, useCallback, useEffect } from 'react'; -import { Eye, Sparkles } from 'lucide-react'; +import React from 'react'; +import { Cinematic3DComparison } from './Cinematic3DComparison'; interface BeforeAfterSliderProps { beforeUrl: string; @@ -11,172 +11,29 @@ interface BeforeAfterSliderProps { caption?: string; aspectRatio?: string; autoSlide?: boolean; + className?: string; } export function BeforeAfterSlider({ beforeUrl, afterUrl, - beforeLabel = 'Original', - afterLabel = 'CRE AI Result', + beforeLabel, + afterLabel, caption, aspectRatio = 'aspect-[4/3] sm:aspect-[16/10]', autoSlide = true, + className = '', }: BeforeAfterSliderProps) { - const [sliderPosition, setSliderPosition] = useState(50); - const [isDragging, setIsDragging] = useState(false); - const [isUserInteracting, setIsUserInteracting] = useState(false); - const containerRef = useRef(null); - const animFrameRef = useRef(null); - const resumeTimerRef = useRef(null); - const startTimeRef = useRef(Date.now()); - - // Auto-slide animation loop using RAF - useEffect(() => { - if (!autoSlide || isDragging || isUserInteracting) { - if (animFrameRef.current) cancelAnimationFrame(animFrameRef.current); - return; - } - - const animate = () => { - const elapsed = Date.now() - startTimeRef.current; - // Smooth sine wave between 24% and 76% (period ~4 seconds) - const newPos = 50 + 26 * Math.sin(elapsed * 0.0016); - setSliderPosition(newPos); - animFrameRef.current = requestAnimationFrame(animate); - }; - - animFrameRef.current = requestAnimationFrame(animate); - - return () => { - if (animFrameRef.current) cancelAnimationFrame(animFrameRef.current); - }; - }, [autoSlide, isDragging, isUserInteracting]); - - const handleMove = useCallback((clientX: number) => { - if (!containerRef.current) return; - const rect = containerRef.current.getBoundingClientRect(); - const x = Math.max(0, Math.min(clientX - rect.left, rect.width)); - const percent = Math.max(0, Math.min(100, (x / rect.width) * 100)); - setSliderPosition(percent); - }, []); - - const handleTouchMove = useCallback((e: TouchEvent) => { - if (!isDragging) return; - handleMove(e.touches[0].clientX); - }, [isDragging, handleMove]); - - const handleMouseMove = useCallback((e: MouseEvent) => { - if (!isDragging) return; - handleMove(e.clientX); - }, [isDragging, handleMove]); - - const handleMouseUp = useCallback(() => { - setIsDragging(false); - }, []); - - useEffect(() => { - if (isDragging) { - window.addEventListener('mousemove', handleMouseMove, { passive: true }); - window.addEventListener('mouseup', handleMouseUp); - window.addEventListener('touchmove', handleTouchMove, { passive: true }); - window.addEventListener('touchend', handleMouseUp); - } - return () => { - window.removeEventListener('mousemove', handleMouseMove); - window.removeEventListener('mouseup', handleMouseUp); - window.removeEventListener('touchmove', handleTouchMove); - window.removeEventListener('touchend', handleMouseUp); - }; - }, [isDragging, handleMouseMove, handleMouseUp, handleTouchMove]); - - const handleMouseEnter = () => { - setIsUserInteracting(true); - if (resumeTimerRef.current) clearTimeout(resumeTimerRef.current); - }; - - const handleMouseLeave = () => { - if (resumeTimerRef.current) clearTimeout(resumeTimerRef.current); - resumeTimerRef.current = setTimeout(() => { - setIsUserInteracting(false); - startTimeRef.current = Date.now(); - }, 2500); - }; - return ( -
-
{ - setIsDragging(true); - setIsUserInteracting(true); - }} - onTouchStart={() => { - setIsDragging(true); - setIsUserInteracting(true); - }} - className={`relative w-full ${aspectRatio} rounded-2xl sm:rounded-3xl overflow-hidden select-none cursor-ew-resize shadow-md border border-slate-900/[0.08] bg-slate-950 group`} - style={{ touchAction: 'pan-y' }} - > - {/* After Image (Background) */} - {/* eslint-disable-next-line @next/next/no-img-element */} - After result - - {/* Before Image (Clipped Left side) */} -
- {/* eslint-disable-next-line @next/next/no-img-element */} - Before result -
- - {/* Split Divider Line */} -
- {/* Center Circular Touch/Mouse Handle */} -
- - - -
-
- - {/* Floating Badges */} -
- - {beforeLabel} -
-
- - {afterLabel} -
- -
- - {caption && ( -

- {caption} -

- )} -
+ ); } diff --git a/src/components/ui/Cinematic3DComparison.tsx b/src/components/ui/Cinematic3DComparison.tsx new file mode 100644 index 0000000..2b9f04f --- /dev/null +++ b/src/components/ui/Cinematic3DComparison.tsx @@ -0,0 +1,264 @@ +'use client'; + +import React, { useState, useRef, useCallback, useEffect } from 'react'; +import { Eye, Sparkles, Scan, Activity } from 'lucide-react'; + +interface Cinematic3DComparisonProps { + beforeUrl: string; + afterUrl: string; + beforeLabel?: string; + afterLabel?: string; + caption?: string; + aspectRatio?: string; + autoSlide?: boolean; + maxTilt?: number; + className?: string; +} + +export function Cinematic3DComparison({ + beforeUrl, + afterUrl, + beforeLabel = 'RAW SOURCE', + afterLabel = 'AI RECONSTRUCTED', + caption, + aspectRatio = 'aspect-[4/3] sm:aspect-[16/10]', + autoSlide = true, + maxTilt = 7, + className = '', +}: Cinematic3DComparisonProps) { + const [sliderPosition, setSliderPosition] = useState(50); + const [isDragging, setIsDragging] = useState(false); + const [isUserInteracting, setIsUserInteracting] = useState(false); + const [tilt, setTilt] = useState({ rx: 0, ry: 0, glareX: 50, glareY: 50, active: false }); + + const containerRef = useRef(null); + const stageRef = useRef(null); + const animFrameRef = useRef(null); + const resumeTimerRef = useRef(null); + const startTimeRef = useRef(Date.now()); + + // Auto-slide smooth sine oscillation loop + useEffect(() => { + if (!autoSlide || isDragging || isUserInteracting) { + if (animFrameRef.current) cancelAnimationFrame(animFrameRef.current); + return; + } + + const animate = () => { + const elapsed = Date.now() - startTimeRef.current; + // Gentle cinematic oscillation between 28% and 72% + const newPos = 50 + 22 * Math.sin(elapsed * 0.0014); + setSliderPosition(newPos); + animFrameRef.current = requestAnimationFrame(animate); + }; + + animFrameRef.current = requestAnimationFrame(animate); + + return () => { + if (animFrameRef.current) cancelAnimationFrame(animFrameRef.current); + }; + }, [autoSlide, isDragging, isUserInteracting]); + + // Handle position calculation + const handleMove = useCallback((clientX: number) => { + if (!containerRef.current) return; + const rect = containerRef.current.getBoundingClientRect(); + const x = Math.max(0, Math.min(clientX - rect.left, rect.width)); + const percent = Math.max(0, Math.min(100, (x / rect.width) * 100)); + setSliderPosition(percent); + }, []); + + const handleTouchMove = useCallback((e: TouchEvent) => { + if (!isDragging) return; + handleMove(e.touches[0].clientX); + }, [isDragging, handleMove]); + + const handleMouseMove = useCallback((e: MouseEvent) => { + if (!isDragging) return; + handleMove(e.clientX); + }, [isDragging, handleMove]); + + const handleMouseUp = useCallback(() => { + setIsDragging(false); + }, []); + + useEffect(() => { + if (isDragging) { + window.addEventListener('mousemove', handleMouseMove, { passive: true }); + window.addEventListener('mouseup', handleMouseUp); + window.addEventListener('touchmove', handleTouchMove, { passive: true }); + window.addEventListener('touchend', handleMouseUp); + } + return () => { + window.removeEventListener('mousemove', handleMouseMove); + window.removeEventListener('mouseup', handleMouseUp); + window.removeEventListener('touchmove', handleTouchMove); + window.removeEventListener('touchend', handleMouseUp); + }; + }, [isDragging, handleMouseMove, handleMouseUp, handleTouchMove]); + + // 3D Spatial Tilt Tracking + const handleStageMouseMove = (e: React.MouseEvent) => { + if (!containerRef.current) return; + const rect = containerRef.current.getBoundingClientRect(); + const x = (e.clientX - rect.left) / rect.width; + const y = (e.clientY - rect.top) / rect.height; + + const rx = -(y - 0.5) * maxTilt * 2; + const ry = (x - 0.5) * maxTilt * 2; + + setTilt({ + rx, + ry, + glareX: x * 100, + glareY: y * 100, + active: true, + }); + }; + + const handleMouseEnter = () => { + setIsUserInteracting(true); + if (resumeTimerRef.current) clearTimeout(resumeTimerRef.current); + }; + + const handleMouseLeave = () => { + setTilt((prev) => ({ ...prev, rx: 0, ry: 0, active: false })); + if (resumeTimerRef.current) clearTimeout(resumeTimerRef.current); + resumeTimerRef.current = setTimeout(() => { + setIsUserInteracting(false); + startTimeRef.current = Date.now(); + }, 2800); + }; + + return ( +
+ {/* 3D Kinetic Tilt Stage */} +
{ + setIsDragging(true); + setIsUserInteracting(true); + }} + onTouchStart={() => { + setIsDragging(true); + setIsUserInteracting(true); + }} + className={`relative w-full ${aspectRatio} rounded-2xl sm:rounded-3xl overflow-hidden cursor-ew-resize preserve-3d transition-transform duration-200 ease-out shadow-cinematic-3d hover:shadow-cinematic-hover border border-slate-900/[0.08] bg-slate-950`} + style={{ + transform: tilt.active + ? `rotateX(${tilt.rx.toFixed(2)}deg) rotateY(${tilt.ry.toFixed(2)}deg) scale3d(1.015, 1.015, 1.015)` + : 'rotateX(0deg) rotateY(0deg) scale3d(1, 1, 1)', + touchAction: 'pan-y', + }} + > + {/* Layer 1: After Image (Full Reconstructed Neural Result) */} + {/* eslint-disable-next-line @next/next/no-img-element */} + AI Reconstructed result + + {/* Dynamic 3D Cursor Specular Light Glint */} +
+ + {/* Layer 2: Before Image (Clipped Left Side with Polygon Split) */} +
+ {/* eslint-disable-next-line @next/next/no-img-element */} + Original input +
+ + {/* Layer 3: Illuminated Holographic Laser Split Line (Champagne Gold + Electric Sapphire) */} +
+ {/* Subtle Vertical Caustic Glow Beam */} +
+ + {/* 3D Tactile Center Control Handle floating at translateZ */} +
+ {/* Outer Metallic Ring */} +
+ + {/* Inner Arrows SVG */} + + + +
+
+ + {/* Layer 4: Floating 3D Telemetry Badges (Floating at translateZ(32px)) */} +
+ + {beforeLabel} +
+ +
+ + {afterLabel} +
+ + {/* Lower Spatial Telemetry Chips (Enigma Archive Aesthetic) */} +
+
+ + DELTA DEPTH MAP +
+
+ + LOSSLESS 4K +
+
+ +
+ SCAN: {Math.round(sliderPosition)}% +
+
+ + {caption && ( +

+ {caption} +

+ )} +
+ ); +}