feat(ui): eliminate zoom effect with fixed 16:9 landscape aperture, add aiease-style interactive hero showcase with borderbeam and quick chips

This commit is contained in:
2026-11-04 18:22:18 +05:30
parent cd98c1a483
commit 6349eb1f71
20 changed files with 679 additions and 139 deletions
+412 -103
View File
@@ -1,81 +1,110 @@
'use client';
import React from 'react';
import React, { useState, useEffect, useRef } from 'react';
import Link from 'next/link';
import * as THREE from 'three';
import {
Sparkles,
ArrowRight,
Smartphone,
ShieldCheck,
LockKeyhole,
Zap,
Check,
Zap,
ArrowDown
Sliders,
ArrowDown,
UploadCloud,
Scissors,
Wand2,
Palette,
Layers,
LockKeyhole
} from 'lucide-react';
import { resolveLocalised, ToolItem, AppItem, VariantSpec } from '@/types';
import { TryItWidget } from './TryItWidget';
import { Hero3DCanvas } from '@/components/3d/Hero3DCanvas';
import { ToolItem, VariantSpec, resolveLocalised } from '@/types';
import { TextAnimate } from '@/components/magicui/text-animate';
import { GrainTransformShowcase } from '@/components/ui/GrainTransformShowcase';
import { BorderBeam } from '@/components/magicui/border-beam';
import { Particles } from '@/components/magicui/particles';
interface HeroSectionProps {
title?: any;
subtitle?: any;
title?: Record<string, string> | string;
badge?: Record<string, string> | string;
subtitle?: Record<string, string> | string;
primaryCta?: { label?: Record<string, string> | string; href?: string };
secondaryCta?: { label?: Record<string, string> | string; href?: string };
variant?: string;
badge?: any;
tryIt?: {
toolRef?: string;
ctaText?: string;
samplePresets?: Array<{ label: string; url: string; resultUrl?: string }>;
};
trustBadges?: Array<{ text: string; icon?: string }>;
primaryCta?: { label?: any; href?: string };
secondaryCta?: { label?: any; href?: string };
tool?: ToolItem | null;
homeApp?: AppItem | null;
tool?: ToolItem;
homeApp?: any;
variants?: VariantSpec[];
locale?: string;
}
const HERO_SHOWCASE_TABS = [
{
id: 'enhancer',
label: '4K Super-Resolution',
icon: Wand2,
badge: '4K RESTORATION',
beforeUrl: '/management/pages/home/media/landscape_enhancer_before.jpg',
afterUrl: '/management/pages/home/media/landscape_enhancer_after.jpg',
tagline: 'Sub-pore facial reconstruction & 4K crystal super-resolution.',
href: '/tools/photo-enhancer',
},
{
id: 'blemish',
label: 'Blemish & Pore Retouch',
icon: Sparkles,
badge: 'STUDIO RETOUCH',
beforeUrl: '/management/pages/home/media/landscape_blemish_before.jpg',
afterUrl: '/management/pages/home/media/landscape_blemish_after.jpg',
tagline: 'Erase acne, redness & blemishes while preserving authentic pores.',
href: '/tools/blemish-remover',
},
{
id: 'restore',
label: 'Vintage Photo Restore',
icon: Palette,
badge: 'ARCHIVAL AI',
beforeUrl: '/management/pages/home/media/landscape_restore_before.jpg',
afterUrl: '/management/pages/home/media/landscape_restore_after.jpg',
tagline: 'Repair severe scratches, faded contrast, and restore historical iris clarity.',
href: '/tools/old-photo-restorer',
},
{
id: 'teeth',
label: 'Teeth Whitener AI',
icon: Layers,
badge: 'SMILE ENHANCE',
beforeUrl: '/management/pages/home/media/landscape_teeth_before.jpg',
afterUrl: '/management/pages/home/media/landscape_teeth_after.jpg',
tagline: 'Brighten tooth enamel with natural luminosity and gum tone preservation.',
href: '/tools/teeth-whitener',
},
];
export function HeroSection({
title,
subtitle,
variant = 'centered',
badge,
tryIt,
trustBadges,
subtitle,
primaryCta,
secondaryCta,
tool,
homeApp,
variants = [],
locale = 'en',
}: HeroSectionProps) {
const resolvedSubtitle = resolveLocalised(subtitle, locale) || 'Studio-grade neural vision tools with zero sign-up and zero data retention. Process high-resolution portraits, precision cutouts, and 4K restorations directly in your browser.';
const resolvedBadge = resolveLocalised(badge, locale) || 'Next-Gen Neural AI Studio';
const resolvedBadge = resolveLocalised(badge, locale) || 'All-in-One Neural AI Studio';
const primaryCtaLabel = resolveLocalised(primaryCta?.label, locale, 'Explore Our Tools');
const primaryCtaHref = primaryCta?.href || '#our-tools';
const secondaryCtaLabel = resolveLocalised(secondaryCta?.label, locale, 'Recommended Apps');
const secondaryCtaHref = secondaryCta?.href || '#recommended-apps';
// Dedicated Tool Landing Hero (for /tools/[slug] SEO pages)
if (variant === 'toolHero' && tool) {
const categoryName = tool.category?.replace('-', ' ').toUpperCase() || 'AI TOOL';
const appName = homeApp ? resolveLocalised(homeApp.name, locale) : 'Mobile App';
const toolMedia = (tool as any).media;
const primaryExample = tool.content?.examples?.[0] || {
before: toolMedia?.before || `/management/pages/tools/${tool.slug}/media/before.jpg`,
after: toolMedia?.after || `/management/pages/tools/${tool.slug}/media/after.jpg`,
caption: 'Sub-pixel neural transformation details',
};
// Tool detail page hero
if (tool) {
return (
<section className="relative isolate overflow-hidden pt-28 pb-16 sm:pt-32 sm:pb-20 lg:pt-36 lg:pb-24 bg-[#FAF8F5] border-b border-slate-900/[0.07]">
<div className="absolute inset-x-0 top-0 h-[640px] bg-[radial-gradient(ellipse_at_75%_20%,rgba(87,132,220,0.12),transparent_50%),radial-gradient(ellipse_at_15%_0%,rgba(208,182,142,0.15),transparent_40%)] pointer-events-none" />
<div className="relative z-10 max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<nav aria-label="Breadcrumb" className="mb-5 flex items-center justify-center gap-2 text-xs font-medium text-slate-500">
<section className="relative overflow-hidden bg-white border-b border-slate-900/[0.08] pt-24 sm:pt-28 pb-12 sm:pb-16 px-4 sm:px-6 lg:px-10">
<div className="max-w-[1640px] mx-auto">
<nav className="flex items-center gap-2 text-xs font-mono text-slate-500 mb-8">
<Link href="/" className="hover:text-blue-700 transition-colors">Home</Link>
<span>/</span>
<Link href="/tools" className="hover:text-blue-700 transition-colors">Tools</Link>
@@ -84,9 +113,9 @@ export function HeroSection({
</nav>
<div className="text-center max-w-4xl mx-auto mb-10 sm:mb-12">
<div className="inline-flex items-center gap-2 rounded-full border border-blue-200/90 bg-white/90 px-4 py-1.5 text-xs font-semibold tracking-[0.14em] uppercase text-blue-800 shadow-sm backdrop-blur">
<div className="inline-flex items-center gap-2 px-3 py-1 rounded-full text-xs font-mono font-semibold tracking-wider uppercase text-blue-700 bg-blue-50 border border-blue-200">
<Sparkles className="w-3.5 h-3.5 text-blue-600" />
<span>{categoryName} • CRE NEURAL VISION 4.0</span>
<span>Studio Neural Tool</span>
</div>
<h1 className="mt-4 text-3xl sm:text-5xl lg:text-6xl font-display font-black tracking-tight text-slate-900 leading-[1.08]">
@@ -98,69 +127,56 @@ export function HeroSection({
</p>
<div className="mt-6 flex flex-wrap items-center justify-center gap-2 sm:gap-3 text-xs font-medium text-slate-600">
<span className="inline-flex items-center gap-1.5 px-3.5 py-1.5 rounded-full bg-white/90 border border-slate-200/80 shadow-2xs">
<Check className="w-3.5 h-3.5 text-blue-600" /> Lossless 4K Reconstruction
<span className="inline-flex items-center gap-1.5 px-3 py-1 rounded-full bg-slate-100">
<ShieldCheck className="h-3.5 w-3.5 text-emerald-600" />
<span>Zero Storage</span>
</span>
<span className="inline-flex items-center gap-1.5 px-3.5 py-1.5 rounded-full bg-white/90 border border-slate-200/80 shadow-2xs">
<Zap className="w-3.5 h-3.5 text-amber-500" /> &lt; 0.8s Inference
<span className="inline-flex items-center gap-1.5 px-3 py-1 rounded-full bg-slate-100">
<LockKeyhole className="h-3.5 w-3.5 text-blue-600" />
<span>Client-Side Processing</span>
</span>
<span className="inline-flex items-center gap-1.5 px-3.5 py-1.5 rounded-full bg-white/90 border border-slate-200/80 shadow-2xs">
<ShieldCheck className="w-3.5 h-3.5 text-emerald-600" /> 100% Private (Never Stored)
<span className="inline-flex items-center gap-1.5 px-3 py-1 rounded-full bg-slate-100">
<Check className="h-3.5 w-3.5 text-indigo-600" />
<span>Lossless Quality</span>
</span>
</div>
</div>
<div className="grid grid-cols-1 lg:grid-cols-12 gap-8 items-stretch max-w-7xl mx-auto" id="tool-studio">
<div className="lg:col-span-7 flex flex-col">
<TryItWidget
tool={tool}
homeApp={homeApp}
variants={variants}
locale={locale}
className="h-full flex flex-col justify-between"
/>
</div>
<div className="lg:col-span-5 flex flex-col" id="transformation-preview">
<div className="h-full rounded-3xl overflow-hidden border border-slate-900/[0.1] shadow-2xl bg-slate-950 flex flex-col justify-between min-h-[380px] sm:min-h-[460px]">
<GrainTransformShowcase
beforeUrl={primaryExample.before}
afterUrl={primaryExample.after}
beforeLabel="BEFORE"
afterLabel="AFTER"
/>
</div>
</div>
</div>
</div>
</section>
);
}
// Pure Front Page View (PRD & User Requirements):
// Clean, beautifully formatted typography + interactive 3D visuals strictly behind the text
// -------------------------------------------------------------
// High-Impact AI Ease Style Hero View
// -------------------------------------------------------------
return (
<section className="relative isolate min-h-[92vh] sm:min-h-[95vh] flex flex-col justify-center items-center text-center overflow-hidden bg-[#FAF8F5] pt-24 pb-16 px-4 sm:px-6 md:px-8 lg:px-10">
{/* 1. Interactive 3D WebGL Canvas & Particle Constellation Mounted Behind Text */}
<section className="relative isolate min-h-[96vh] flex flex-col justify-center items-center text-center overflow-hidden bg-[#FAF8F5] pt-24 pb-20 px-4 sm:px-6 md:px-8 lg:px-10">
{/* 1. Background MagicUI Particles */}
<Particles
className="absolute inset-0 -z-20 opacity-40"
quantity={60}
color="#3b82f6"
size={0.7}
/>
{/* 2. Interactive 3D WebGL Canvas Rotating Behind */}
<div className="absolute inset-0 -z-10 flex items-center justify-center pointer-events-none select-none overflow-hidden">
<div className="w-[580px] h-[580px] sm:w-[860px] sm:h-[860px] lg:w-[1100px] lg:h-[1100px] opacity-75 transform-gpu transition-opacity duration-1000">
<div className="w-[600px] h-[600px] sm:w-[900px] sm:h-[900px] lg:w-[1200px] lg:h-[1200px] opacity-60 transform-gpu transition-opacity duration-1000">
<Hero3DCanvas className="w-full h-full" />
</div>
</div>
{/* 2. Ambient Atmosphere Radial Glows */}
{/* 3. Ambient Atmospheric Glows */}
<div
className="absolute inset-0 -z-20 pointer-events-none"
className="absolute inset-0 -z-30 pointer-events-none"
style={{
background: 'radial-gradient(circle at 50% 45%, rgba(37,99,235,0.14) 0%, rgba(14,165,233,0.08) 35%, transparent 70%)',
background: 'radial-gradient(circle at 50% 35%, rgba(37,99,235,0.12) 0%, rgba(14,165,233,0.06) 40%, transparent 70%)',
}}
/>
<div
className="absolute inset-x-0 bottom-0 h-40 bg-gradient-to-t from-[#FAF8F5] to-transparent -z-10 pointer-events-none"
/>
<div className="absolute inset-x-0 bottom-0 h-44 bg-gradient-to-t from-[#FAF8F5] to-transparent -z-10 pointer-events-none" />
{/* 3. Front Page Content: Flawlessly Formatted, Luxurious Typography */}
<div className="relative z-10 max-w-6xl mx-auto flex flex-col items-center justify-center w-full">
{/* 4. Hero Content Container */}
<div className="relative z-10 max-w-[1640px] mx-auto flex flex-col items-center justify-center w-full">
{/* Subtle Elegant Pill Badge */}
<div className="inline-flex items-center gap-2 rounded-full border border-blue-500/20 bg-white/90 backdrop-blur-md px-4 py-1.5 text-xs font-mono font-medium tracking-wider uppercase text-blue-800 shadow-sm mb-6">
<span className="flex h-2 w-2 relative">
@@ -184,15 +200,34 @@ export function HeroSection({
</span>
</h1>
{/* Balanced, Readable Subtitle (Inter / SF Pro) */}
{/* Balanced, Readable Subtitle */}
<p className="mt-6 text-base sm:text-lg lg:text-xl text-slate-600 max-w-3xl mx-auto font-sans leading-relaxed text-pretty">
<TextAnimate animation="fadeIn" by="word" delay={0.25}>
{resolvedSubtitle}
</TextAnimate>
</p>
{/* Primary and Secondary Action Buttons */}
<div className="mt-10 flex flex-wrap items-center justify-center gap-4">
{/* Quick Feature Chips (aiease.ai style) */}
<div className="mt-7 flex flex-wrap items-center justify-center gap-2 text-xs font-mono font-semibold">
<Link href="/tools/background-remover" className="px-3.5 py-1.5 rounded-full bg-white/80 hover:bg-white text-slate-700 hover:text-blue-600 border border-slate-200/80 shadow-sm transition-all hover:scale-105">
🎯 Background Remover
</Link>
<Link href="/tools/photo-enhancer" className="px-3.5 py-1.5 rounded-full bg-white/80 hover:bg-white text-slate-700 hover:text-blue-600 border border-slate-200/80 shadow-sm transition-all hover:scale-105">
⚡ 4K Enhancer
</Link>
<Link href="/tools/blemish-remover" className="px-3.5 py-1.5 rounded-full bg-white/80 hover:bg-white text-slate-700 hover:text-blue-600 border border-slate-200/80 shadow-sm transition-all hover:scale-105">
✨ Blemish Cleaner
</Link>
<Link href="/tools/old-photo-restorer" className="px-3.5 py-1.5 rounded-full bg-white/80 hover:bg-white text-slate-700 hover:text-blue-600 border border-slate-200/80 shadow-sm transition-all hover:scale-105">
🎨 Vintage Restorer
</Link>
<Link href="/tools/cartoon-avatar" className="px-3.5 py-1.5 rounded-full bg-white/80 hover:bg-white text-slate-700 hover:text-blue-600 border border-slate-200/80 shadow-sm transition-all hover:scale-105">
🎭 Anime Avatar
</Link>
</div>
{/* Action Buttons */}
<div className="mt-8 flex flex-wrap items-center justify-center gap-4">
<a
href={primaryCtaHref}
className="group inline-flex items-center gap-3 rounded-full bg-gradient-to-r from-slate-950 via-slate-900 to-indigo-950 px-8 py-4 text-xs sm:text-sm font-bold text-white border border-white/15 shadow-xl shadow-slate-900/20 transition-all duration-300 hover:scale-[1.03] hover:from-blue-600 hover:to-indigo-600 active:scale-95"
@@ -209,8 +244,13 @@ export function HeroSection({
</a>
</div>
{/* ----------------------------------------------------------- */}
{/* HERO INTERACTIVE SHOWCASE CARD (AI Ease Style with 3D BorderBeam) */}
{/* ----------------------------------------------------------- */}
<HeroShowcaseCard />
{/* Trust Badges Strip */}
<div className="mt-9 flex flex-wrap items-center justify-center gap-3 sm:gap-4 text-xs font-medium text-slate-600 font-sans">
<div className="mt-12 flex flex-wrap items-center justify-center gap-3 sm:gap-4 text-xs font-medium text-slate-600 font-sans">
<span className="inline-flex items-center gap-1.5 px-3.5 py-1.5 rounded-full bg-white/80 border border-slate-200/70 shadow-sm">
<ShieldCheck className="h-4 w-4 text-emerald-600" />
<span>Zero-Storage Guarantee</span>
@@ -224,19 +264,288 @@ export function HeroSection({
<span>&lt; 0.8s Inference</span>
</span>
</div>
{/* Gentle Scroll Cue */}
<a
href="#our-tools"
aria-label="Scroll to our tools"
className="mt-14 inline-flex flex-col items-center gap-1.5 text-[11px] font-mono uppercase tracking-widest text-slate-500 hover:text-blue-600 transition-colors"
>
<span>Scroll to Explore</span>
<span className="w-4 h-7 rounded-full border border-slate-300 flex justify-center p-1">
<span className="w-1 h-1.5 rounded-full bg-blue-600 animate-bounce" />
</span>
</a>
</div>
</section>
);
}
// ---------------------------------------------------------------------
// Hero Showcase Card (Interactive Tabs + Live Slider + BorderBeam)
// ---------------------------------------------------------------------
function HeroShowcaseCard() {
const [activeTabIdx, setActiveTabIdx] = useState(0);
const [sliderPos, setSliderPos] = useState(50);
const [isHovered, setIsHovered] = useState(false);
const animRef = useRef<number | null>(null);
const activeTab = HERO_SHOWCASE_TABS[activeTabIdx];
// Smooth automatic oscillating sweep when not manually hovering
useEffect(() => {
let startTime = Date.now();
const animate = () => {
if (!isHovered) {
const elapsed = (Date.now() - startTime) / 1000;
const pos = 50 + Math.sin(elapsed * 1.8) * 22;
setSliderPos(pos);
}
animRef.current = requestAnimationFrame(animate);
};
animRef.current = requestAnimationFrame(animate);
return () => {
if (animRef.current) cancelAnimationFrame(animRef.current);
};
}, [isHovered]);
const handleMouseMove = (e: React.MouseEvent<HTMLDivElement>) => {
setIsHovered(true);
const rect = e.currentTarget.getBoundingClientRect();
const x = Math.max(0, Math.min(e.clientX - rect.left, rect.width));
const percent = Math.max(10, Math.min(90, (x / rect.width) * 100));
setSliderPos(percent);
};
const handleMouseLeave = () => {
setIsHovered(false);
};
return (
<div className="mt-12 w-full max-w-5xl mx-auto text-left">
{/* Interactive Tabs Header */}
<div className="flex items-center justify-center flex-wrap gap-2 mb-4">
{HERO_SHOWCASE_TABS.map((tab, idx) => {
const isActive = idx === activeTabIdx;
const Icon = tab.icon;
return (
<button
key={tab.id}
onClick={() => setActiveTabIdx(idx)}
className={`flex items-center gap-2 px-4 py-2 rounded-full text-xs font-bold transition-all duration-300 ${
isActive
? 'bg-slate-900 text-white shadow-md shadow-slate-900/15 scale-105'
: 'bg-white/80 hover:bg-white text-slate-700 hover:text-blue-600 border border-slate-200/80 shadow-sm'
}`}
>
<Icon className={`w-3.5 h-3.5 ${isActive ? 'text-cyan-400' : 'text-blue-600'}`} />
<span>{tab.label}</span>
</button>
);
})}
</div>
{/* Main Interactive Showcase Card with BorderBeam & 3D Perspective */}
<div className="relative rounded-3xl bg-slate-950 border border-slate-800 shadow-2xl overflow-hidden p-2 sm:p-3 transform-gpu transition-all duration-500 hover:shadow-blue-500/10">
{/* MagicUI BorderBeam Glow running around perimeter */}
<BorderBeam size={300} duration={10} colorFrom="#06b6d4" colorTo="#3b82f6" />
{/* Comparison Viewport */}
<div
onMouseMove={handleMouseMove}
onMouseLeave={handleMouseLeave}
className="relative w-full h-[320px] sm:h-[440px] lg:h-[480px] rounded-2xl overflow-hidden cursor-ew-resize select-none bg-slate-950"
>
{/* Before Image (Locked centered scale) */}
<img
src={activeTab.beforeUrl}
alt="Before"
className="absolute inset-0 w-full h-full object-cover pointer-events-none"
loading="eager"
/>
{/* After Image (Clipped via clip-path) */}
<img
src={activeTab.afterUrl}
alt="After"
className="absolute inset-0 w-full h-full object-cover pointer-events-none"
style={{
clipPath: `inset(0 ${100 - sliderPos}% 0 0)`,
}}
loading="eager"
/>
{/* Glowing Slider Line */}
<div
className="absolute top-0 bottom-0 w-0.5 bg-white shadow-[0_0_14px_rgba(255,255,255,1)] pointer-events-none z-20"
style={{ left: `${sliderPos}%` }}
>
<div className="absolute top-1/2 -translate-y-1/2 -translate-x-1/2 w-8 h-8 rounded-full bg-white shadow-xl border border-slate-200 flex items-center justify-center text-xs font-bold text-slate-900 pointer-events-none">
↔
</div>
</div>
{/* 4 Floating Corner Telemetry Badges */}
<div className="absolute top-4 left-4 z-30 pointer-events-none">
<span className="inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-[10px] font-mono font-bold tracking-wider uppercase bg-black/70 backdrop-blur-md text-cyan-400 border border-cyan-500/30 shadow-md">
<Sparkles className="w-3 h-3 text-cyan-400" />
{activeTab.badge}
</span>
</div>
<div className="absolute top-4 right-4 z-30 pointer-events-none">
<span className="inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-[10px] font-mono font-bold tracking-wider uppercase bg-black/70 backdrop-blur-md text-emerald-400 border border-emerald-500/30 shadow-md">
<Zap className="w-3 h-3 text-emerald-400" />
&lt; 0.8s Inference
</span>
</div>
<div className="absolute bottom-4 left-4 z-30 pointer-events-none">
<span className="inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-[10px] font-mono font-bold tracking-wider uppercase bg-black/70 backdrop-blur-md text-white border border-white/20 shadow-md">
<ShieldCheck className="w-3 h-3 text-emerald-400" />
Zero Cloud Retention
</span>
</div>
<div className="absolute bottom-4 right-4 z-30 pointer-events-none">
<span className="px-3 py-1 rounded-full text-[10px] font-mono font-bold tracking-wider uppercase bg-black/70 backdrop-blur-md text-white/90 border border-white/20 shadow-md">
AFTER | BEFORE
</span>
</div>
</div>
{/* Bottom Quick Action Bar */}
<div className="p-4 sm:p-5 flex flex-col sm:flex-row items-center justify-between gap-4 text-xs">
<p className="text-slate-300 font-sans">
<strong className="text-white font-semibold">{activeTab.label}:</strong> {activeTab.tagline}
</p>
<Link
href={activeTab.href}
className="flex-shrink-0 inline-flex items-center gap-2 px-5 py-2.5 rounded-full font-bold text-slate-900 bg-white hover:bg-cyan-400 transition-colors shadow-sm"
>
<UploadCloud className="w-4 h-4" />
<span>Try with Your Photo Free</span>
<ArrowRight className="w-3.5 h-3.5" />
</Link>
</div>
</div>
</div>
);
}
// -------------------------------------------------------------
// Interactive 3D WebGL Crystal Prism Background Canvas
// -------------------------------------------------------------
function Hero3DCanvas({ className }: { className?: string }) {
const containerRef = useRef<HTMLDivElement>(null);
useEffect(() => {
const container = containerRef.current;
if (!container) return;
let width = container.clientWidth || 600;
let height = container.clientHeight || 600;
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(45, width / height, 0.1, 100);
camera.position.z = 4.2;
let renderer: THREE.WebGLRenderer | null = null;
try {
renderer = new THREE.WebGLRenderer({ alpha: true, antialias: true });
renderer.setSize(width, height);
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2));
container.appendChild(renderer.domElement);
} catch (e) {
return;
}
// Geometry: Floating Octahedron Crystal Prism
const geometry = new THREE.OctahedronGeometry(1.65, 0);
const material = new THREE.MeshPhysicalMaterial({
color: 0x2563eb,
emissive: 0x1d4ed8,
emissiveIntensity: 0.15,
roughness: 0.25,
metalness: 0.1,
transmission: 0.85,
transparent: true,
opacity: 0.75,
ior: 1.5,
});
const crystal = new THREE.Mesh(geometry, material);
scene.add(crystal);
// Wireframe Cage
const wireGeo = new THREE.WireframeGeometry(geometry);
const wireMat = new THREE.LineBasicMaterial({
color: 0x93c5fd,
transparent: true,
opacity: 0.35,
});
const wireframe = new THREE.LineSegments(wireGeo, wireMat);
crystal.add(wireframe);
// Subtle Particle Constellation
const particleCount = 40;
const particleGeo = new THREE.BufferGeometry();
const posArray = new Float32Array(particleCount * 3);
for (let i = 0; i < particleCount * 3; i++) {
posArray[i] = (Math.random() - 0.5) * 6;
}
particleGeo.setAttribute('position', new THREE.BufferAttribute(posArray, 3));
const particleMat = new THREE.PointsMaterial({
size: 0.04,
color: 0x60a5fa,
transparent: true,
opacity: 0.5,
});
const particles = new THREE.Points(particleGeo, particleMat);
scene.add(particles);
// Studio Lights
const ambientLight = new THREE.AmbientLight(0xffffff, 0.85);
scene.add(ambientLight);
const pointLight = new THREE.PointLight(0x06b6d4, 3, 10);
pointLight.position.set(3, 3, 3);
scene.add(pointLight);
const pointLight2 = new THREE.PointLight(0x4f46e5, 2.5, 10);
pointLight2.position.set(-3, -2, 2);
scene.add(pointLight2);
let animId = 0;
let clock = new THREE.Clock();
const animate = () => {
animId = requestAnimationFrame(animate);
const elapsed = clock.getElapsedTime();
crystal.rotation.x = elapsed * 0.18;
crystal.rotation.y = elapsed * 0.25;
particles.rotation.y = elapsed * 0.05;
particles.rotation.x = elapsed * 0.03;
if (renderer) renderer.render(scene, camera);
};
animate();
const handleResize = () => {
if (!container || !renderer) return;
const w = container.clientWidth;
const h = container.clientHeight;
camera.aspect = w / h;
camera.updateProjectionMatrix();
renderer.setSize(w, h);
};
window.addEventListener('resize', handleResize);
return () => {
cancelAnimationFrame(animId);
window.removeEventListener('resize', handleResize);
if (renderer && renderer.domElement && container.contains(renderer.domElement)) {
container.removeChild(renderer.domElement);
}
geometry.dispose();
material.dispose();
renderer?.dispose();
};
}, []);
return <div ref={containerRef} className={className} />;
}