feat(ui): add Three.js 3D neural prism, 3D tilt cards, cursor aura, and flagship banners
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
'use client';
|
||||
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
|
||||
export function CursorAura() {
|
||||
const [mounted, setMounted] = useState<boolean>(false);
|
||||
const posRef = useRef({ targetX: -500, targetY: -500, currentX: -500, currentY: -500 });
|
||||
const auraRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
// Only enable on pointer-fine (mouse/trackpad) and when not reduced-motion
|
||||
if (window.matchMedia('(pointer: coarse)').matches) return;
|
||||
if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) return;
|
||||
|
||||
setMounted(true);
|
||||
|
||||
const onMouseMove = (e: MouseEvent) => {
|
||||
posRef.current.targetX = e.clientX;
|
||||
posRef.current.targetY = e.clientY;
|
||||
};
|
||||
|
||||
window.addEventListener('mousemove', onMouseMove, { passive: true });
|
||||
|
||||
let animId: number;
|
||||
|
||||
const render = () => {
|
||||
const pos = posRef.current;
|
||||
// Damped lerp follower
|
||||
pos.currentX += (pos.targetX - pos.currentX) * 0.08;
|
||||
pos.currentY += (pos.targetY - pos.currentY) * 0.08;
|
||||
|
||||
if (auraRef.current) {
|
||||
auraRef.current.style.transform = `translate3d(${pos.currentX - 250}px, ${pos.currentY - 250}px, 0)`;
|
||||
}
|
||||
|
||||
animId = requestAnimationFrame(render);
|
||||
};
|
||||
|
||||
animId = requestAnimationFrame(render);
|
||||
|
||||
return () => {
|
||||
cancelAnimationFrame(animId);
|
||||
window.removeEventListener('mousemove', onMouseMove);
|
||||
};
|
||||
}, []);
|
||||
|
||||
if (!mounted) return null;
|
||||
|
||||
return (
|
||||
<div
|
||||
aria-hidden="true"
|
||||
className="pointer-events-none fixed inset-0 z-0 overflow-hidden hidden [@media(hover:hover)]:block"
|
||||
>
|
||||
<div
|
||||
ref={auraRef}
|
||||
className="absolute top-0 left-0 w-[500px] h-[500px] rounded-full will-change-transform opacity-60"
|
||||
style={{
|
||||
background:
|
||||
'radial-gradient(circle, rgba(59, 130, 246, 0.09) 0%, rgba(99, 102, 241, 0.05) 35%, rgba(168, 85, 247, 0.02) 60%, transparent 80%)',
|
||||
filter: 'blur(35px)',
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user