fix(perf): make website ultra-lightweight, 0% idle CPU, and resolve text disappearance bug
This commit is contained in:
+35
-77
@@ -316,90 +316,48 @@
|
|||||||
-webkit-text-fill-color: transparent;
|
-webkit-text-fill-color: transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Universal 3D Cinematic Extruded Typography */
|
/* Guaranteed Text Visibility - Fix all text disappearance issues */
|
||||||
h1, h2, h3, h4, h5, h6, .font-display, .text-3d-chiseled {
|
.text-transparent,
|
||||||
transform-style: preserve-3d;
|
[class*="text-transparent"],
|
||||||
will-change: transform;
|
[class*="bg-clip-text"],
|
||||||
text-shadow:
|
.text-gradient-brand,
|
||||||
0 1px 0 #FFFFFF,
|
.text-gradient-cyan,
|
||||||
0 2px 0 #E5DCCE,
|
.text-gradient-champagne {
|
||||||
0 3px 1px #D6C7B2,
|
text-shadow: none !important;
|
||||||
0 4px 2px #C5B298,
|
filter: none !important;
|
||||||
0 6px 6px rgba(15, 23, 42, 0.12),
|
transform-style: flat !important;
|
||||||
0 12px 24px rgba(15, 23, 42, 0.08);
|
-webkit-text-fill-color: transparent !important;
|
||||||
|
-webkit-background-clip: text !important;
|
||||||
|
background-clip: text !important;
|
||||||
|
display: inline-block;
|
||||||
|
opacity: 1 !important;
|
||||||
|
visibility: visible !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 3D Extruded Stat Numbers & Metric Badges */
|
/* Crisp, Ultra-Lightweight Editorial Headings (Zero CPU load, Zero Disappearance) */
|
||||||
|
h1, h2, h3, h4, h5, h6, .text-3d-chiseled {
|
||||||
|
text-rendering: optimizeLegibility;
|
||||||
|
-webkit-font-smoothing: antialiased;
|
||||||
|
text-shadow: 0 1px 1px rgba(15, 23, 42, 0.06), 0 2px 4px rgba(15, 23, 42, 0.04);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Crisp Stat Numbers */
|
||||||
.stat-value, .stat-number, [data-stat] {
|
.stat-value, .stat-number, [data-stat] {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
transform-style: preserve-3d;
|
text-shadow: none !important;
|
||||||
will-change: transform;
|
filter: none !important;
|
||||||
filter:
|
|
||||||
drop-shadow(0 1px 0 #FFFFFF)
|
|
||||||
drop-shadow(0 2px 0 #E2D6C3)
|
|
||||||
drop-shadow(0 4px 2px rgba(197, 168, 128, 0.5))
|
|
||||||
drop-shadow(0 8px 18px rgba(37, 99, 235, 0.35));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 3D Kinetic Light Sweep Animation across Gradient Headings */
|
/* Lightweight Badge Styling (Zero Continuous CPU/GPU Spikes) */
|
||||||
@keyframes text-3d-shimmer {
|
.badge-3d, [class*="badge"] {
|
||||||
0% {
|
|
||||||
background-position: 0% center;
|
|
||||||
}
|
|
||||||
50% {
|
|
||||||
background-position: 100% center;
|
|
||||||
}
|
|
||||||
100% {
|
|
||||||
background-position: 0% center;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Continuous Organic 3D Floating Wave */
|
|
||||||
@keyframes text-3d-float-organic {
|
|
||||||
0%, 100% {
|
|
||||||
transform: perspective(900px) rotateX(0deg) rotateY(0deg) translateZ(14px);
|
|
||||||
}
|
|
||||||
25% {
|
|
||||||
transform: perspective(900px) rotateX(2.5deg) rotateY(-3deg) translateZ(24px);
|
|
||||||
}
|
|
||||||
50% {
|
|
||||||
transform: perspective(900px) rotateX(-2deg) rotateY(2.5deg) translateZ(16px);
|
|
||||||
}
|
|
||||||
75% {
|
|
||||||
transform: perspective(900px) rotateX(2deg) rotateY(1.8deg) translateZ(26px);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 3D Gradient Text Styling with Multi-Plane Depth */
|
|
||||||
.text-3d-gradient,
|
|
||||||
.text-transparent.bg-clip-text {
|
|
||||||
background-size: 200% auto;
|
|
||||||
animation: text-3d-shimmer 6s ease-in-out infinite;
|
|
||||||
display: inline-block;
|
|
||||||
transform-style: preserve-3d;
|
|
||||||
filter:
|
|
||||||
drop-shadow(0 1px 0 rgba(255, 255, 255, 0.95))
|
|
||||||
drop-shadow(0 2px 1px rgba(197, 168, 128, 0.55))
|
|
||||||
drop-shadow(0 5px 12px rgba(37, 99, 235, 0.32))
|
|
||||||
drop-shadow(0 14px 28px rgba(15, 23, 42, 0.1));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Continuous 3D Spatial Pulse for Badges & Telemetry */
|
|
||||||
@keyframes badge-3d-pulse {
|
|
||||||
0%, 100% {
|
|
||||||
transform: perspective(600px) translateZ(8px) rotateX(0deg) rotateY(0deg);
|
|
||||||
box-shadow: 0 4px 12px rgba(37, 99, 235, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.9);
|
|
||||||
}
|
|
||||||
50% {
|
|
||||||
transform: perspective(600px) translateZ(18px) rotateX(3.5deg) rotateY(-2deg);
|
|
||||||
box-shadow: 0 10px 24px rgba(37, 99, 235, 0.18), inset 0 1px 0 rgba(255, 255, 255, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.badge-3d, [class*="badge"]:not([data-no3d]) {
|
|
||||||
animation: badge-3d-pulse 4s ease-in-out infinite;
|
|
||||||
transform-style: preserve-3d;
|
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
|
box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), inset 0 1px 0 rgba(255, 255, 255, 0.85);
|
||||||
|
transition: transform 0.2s ease, box-shadow 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.badge-3d:hover {
|
||||||
|
transform: translateY(-1px);
|
||||||
|
box-shadow: 0 4px 8px -2px rgba(37, 99, 235, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.95);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import { Navbar } from '@/components/ui/Navbar';
|
|||||||
import { Footer } from '@/components/ui/Footer';
|
import { Footer } from '@/components/ui/Footer';
|
||||||
import { CursorAura } from '@/components/ui/CursorAura';
|
import { CursorAura } from '@/components/ui/CursorAura';
|
||||||
import { SmoothScroll } from '@/components/ui/SmoothScroll';
|
import { SmoothScroll } from '@/components/ui/SmoothScroll';
|
||||||
import { Cinematic3DTextEngine } from '@/components/ui/Cinematic3DTextEngine';
|
|
||||||
|
|
||||||
const sansFont = Plus_Jakarta_Sans({
|
const sansFont = Plus_Jakarta_Sans({
|
||||||
subsets: ['latin'],
|
subsets: ['latin'],
|
||||||
@@ -93,7 +92,6 @@ export default function RootLayout({
|
|||||||
<body className="min-h-screen flex flex-col antialiased selection:bg-blue-600 selection:text-white bg-[#FAF8F5] text-slate-900 relative">
|
<body className="min-h-screen flex flex-col antialiased selection:bg-blue-600 selection:text-white bg-[#FAF8F5] text-slate-900 relative">
|
||||||
<SmoothScroll />
|
<SmoothScroll />
|
||||||
<CursorAura />
|
<CursorAura />
|
||||||
<Cinematic3DTextEngine />
|
|
||||||
<Navbar config={config} currentLocale="en" />
|
<Navbar config={config} currentLocale="en" />
|
||||||
<main className="flex-1">{children}</main>
|
<main className="flex-1">{children}</main>
|
||||||
<Footer config={config} currentLocale="en" />
|
<Footer config={config} currentLocale="en" />
|
||||||
|
|||||||
@@ -38,11 +38,11 @@ export function Hero3DCanvas({ className = '' }: Hero3DCanvasProps) {
|
|||||||
|
|
||||||
// Geometries & Materials for cleanup
|
// Geometries & Materials for cleanup
|
||||||
let crystalGeo: THREE.OctahedronGeometry | null = null;
|
let crystalGeo: THREE.OctahedronGeometry | null = null;
|
||||||
let crystalMat: THREE.MeshPhysicalMaterial | null = null;
|
let crystalMat: THREE.MeshStandardMaterial | null = null;
|
||||||
let edgesGeo: THREE.EdgesGeometry | null = null;
|
let edgesGeo: THREE.EdgesGeometry | null = null;
|
||||||
let edgesMat: THREE.LineBasicMaterial | null = null;
|
let edgesMat: THREE.LineBasicMaterial | null = null;
|
||||||
let innerGeo: THREE.OctahedronGeometry | null = null;
|
let innerGeo: THREE.OctahedronGeometry | null = null;
|
||||||
let innerMat: THREE.MeshPhysicalMaterial | null = null;
|
let innerMat: THREE.MeshStandardMaterial | null = null;
|
||||||
let dotGeo: THREE.BufferGeometry | null = null;
|
let dotGeo: THREE.BufferGeometry | null = null;
|
||||||
let dotMat: THREE.PointsMaterial | null = null;
|
let dotMat: THREE.PointsMaterial | null = null;
|
||||||
let particlesGeo: THREE.BufferGeometry | null = null;
|
let particlesGeo: THREE.BufferGeometry | null = null;
|
||||||
@@ -56,11 +56,11 @@ export function Hero3DCanvas({ className = '' }: Hero3DCanvasProps) {
|
|||||||
|
|
||||||
renderer = new THREE.WebGLRenderer({
|
renderer = new THREE.WebGLRenderer({
|
||||||
alpha: true,
|
alpha: true,
|
||||||
antialias: true,
|
antialias: false,
|
||||||
powerPreference: 'high-performance',
|
powerPreference: 'default',
|
||||||
});
|
});
|
||||||
renderer.setSize(width, height);
|
renderer.setSize(width, height);
|
||||||
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2));
|
renderer.setPixelRatio(1); // 1x DPR saves massive GPU raster fillrate
|
||||||
renderer.outputColorSpace = THREE.SRGBColorSpace;
|
renderer.outputColorSpace = THREE.SRGBColorSpace;
|
||||||
container.appendChild(renderer.domElement);
|
container.appendChild(renderer.domElement);
|
||||||
|
|
||||||
@@ -68,17 +68,14 @@ export function Hero3DCanvas({ className = '' }: Hero3DCanvasProps) {
|
|||||||
const rootGroup = new THREE.Group();
|
const rootGroup = new THREE.Group();
|
||||||
scene.add(rootGroup);
|
scene.add(rootGroup);
|
||||||
|
|
||||||
// 1. Outer Translucent Diamond Crystal Prism (Octahedron)
|
// 1. Outer Translucent Diamond Crystal Prism (Octahedron - Standard Lightweight Material)
|
||||||
crystalGeo = new THREE.OctahedronGeometry(1.8, 0);
|
crystalGeo = new THREE.OctahedronGeometry(1.8, 0);
|
||||||
crystalMat = new THREE.MeshPhysicalMaterial({
|
crystalMat = new THREE.MeshStandardMaterial({
|
||||||
color: 0x2563eb, // Studio Sapphire
|
color: 0x2563eb, // Studio Sapphire
|
||||||
roughness: 0.08,
|
roughness: 0.2,
|
||||||
metalness: 0.15,
|
metalness: 0.1,
|
||||||
transmission: 0.85,
|
opacity: 0.45,
|
||||||
opacity: 0.7,
|
|
||||||
transparent: true,
|
transparent: true,
|
||||||
emissive: 0x1d4ed8,
|
|
||||||
emissiveIntensity: 0.25,
|
|
||||||
});
|
});
|
||||||
const crystalMesh = new THREE.Mesh(crystalGeo, crystalMat);
|
const crystalMesh = new THREE.Mesh(crystalGeo, crystalMat);
|
||||||
rootGroup.add(crystalMesh);
|
rootGroup.add(crystalMesh);
|
||||||
@@ -95,14 +92,12 @@ export function Hero3DCanvas({ className = '' }: Hero3DCanvasProps) {
|
|||||||
|
|
||||||
// 2. Inner Nested Core Prism (Counter-rotating Gold Core)
|
// 2. Inner Nested Core Prism (Counter-rotating Gold Core)
|
||||||
innerGeo = new THREE.OctahedronGeometry(1.0, 0);
|
innerGeo = new THREE.OctahedronGeometry(1.0, 0);
|
||||||
innerMat = new THREE.MeshPhysicalMaterial({
|
innerMat = new THREE.MeshStandardMaterial({
|
||||||
color: 0xd4af37, // Metallic Gold
|
color: 0xd4af37, // Metallic Gold
|
||||||
roughness: 0.2,
|
roughness: 0.3,
|
||||||
metalness: 0.85,
|
metalness: 0.7,
|
||||||
emissive: 0xb45309,
|
|
||||||
emissiveIntensity: 0.45,
|
|
||||||
transparent: true,
|
transparent: true,
|
||||||
opacity: 0.85,
|
opacity: 0.8,
|
||||||
});
|
});
|
||||||
const innerMesh = new THREE.Mesh(innerGeo, innerMat);
|
const innerMesh = new THREE.Mesh(innerGeo, innerMat);
|
||||||
rootGroup.add(innerMesh);
|
rootGroup.add(innerMesh);
|
||||||
|
|||||||
@@ -1,141 +0,0 @@
|
|||||||
'use client';
|
|
||||||
|
|
||||||
import React, { useEffect } from 'react';
|
|
||||||
|
|
||||||
export function Cinematic3DTextEngine() {
|
|
||||||
useEffect(() => {
|
|
||||||
// Check prefers-reduced-motion
|
|
||||||
if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) return;
|
|
||||||
|
|
||||||
let rafId: number;
|
|
||||||
let targetMouseX = 0;
|
|
||||||
let targetMouseY = 0;
|
|
||||||
let currentMouseX = 0;
|
|
||||||
let currentMouseY = 0;
|
|
||||||
|
|
||||||
let lastScrollY = window.scrollY || 0;
|
|
||||||
let targetScrollPitch = 0;
|
|
||||||
let currentScrollPitch = 0;
|
|
||||||
|
|
||||||
let clock = 0;
|
|
||||||
|
|
||||||
const handleMouseMove = (e: MouseEvent) => {
|
|
||||||
const vw = window.innerWidth;
|
|
||||||
const vh = window.innerHeight;
|
|
||||||
targetMouseX = (e.clientX / vw) * 2 - 1;
|
|
||||||
targetMouseY = (e.clientY / vh) * 2 - 1;
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleScroll = () => {
|
|
||||||
const sy = window.scrollY || 0;
|
|
||||||
const delta = sy - lastScrollY;
|
|
||||||
lastScrollY = sy;
|
|
||||||
targetScrollPitch = Math.max(Math.min(delta * 0.18, 7), -7);
|
|
||||||
};
|
|
||||||
|
|
||||||
window.addEventListener('mousemove', handleMouseMove, { passive: true });
|
|
||||||
window.addEventListener('scroll', handleScroll, { passive: true });
|
|
||||||
|
|
||||||
// Target headings, badges, card titles, and stats
|
|
||||||
const selector = [
|
|
||||||
'h1:not([data-no3d])',
|
|
||||||
'h2:not([data-no3d])',
|
|
||||||
'h3:not([data-no3d])',
|
|
||||||
'h4:not([data-no3d])',
|
|
||||||
'.font-display:not([data-no3d])',
|
|
||||||
'.stat-value:not([data-no3d])',
|
|
||||||
'.badge-3d:not([data-no3d])',
|
|
||||||
'[data-3d-text]',
|
|
||||||
].join(', ');
|
|
||||||
|
|
||||||
// Use IntersectionObserver to track visible elements with ZERO per-frame DOM reads
|
|
||||||
const visibleElements = new Set<HTMLElement>();
|
|
||||||
|
|
||||||
const observer = new IntersectionObserver(
|
|
||||||
(entries) => {
|
|
||||||
entries.forEach((entry) => {
|
|
||||||
const el = entry.target as HTMLElement;
|
|
||||||
if (entry.isIntersecting) {
|
|
||||||
visibleElements.add(el);
|
|
||||||
// Ensure inline elements can be 3D transformed
|
|
||||||
if (window.getComputedStyle(el).display === 'inline') {
|
|
||||||
el.style.display = 'inline-block';
|
|
||||||
}
|
|
||||||
el.style.transformStyle = 'preserve-3d';
|
|
||||||
el.style.willChange = 'transform';
|
|
||||||
} else {
|
|
||||||
visibleElements.delete(el);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
{ rootMargin: '100px 0px 100px 0px', threshold: 0 }
|
|
||||||
);
|
|
||||||
|
|
||||||
const allElements = document.querySelectorAll<HTMLElement>(selector);
|
|
||||||
allElements.forEach((el) => {
|
|
||||||
if (!el.closest('canvas') && !el.closest('[data-no3d-container]')) {
|
|
||||||
observer.observe(el);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const tick = () => {
|
|
||||||
clock += 0.024;
|
|
||||||
|
|
||||||
// Fast, responsive lerps (0.12 factor eliminates input lag)
|
|
||||||
currentMouseX += (targetMouseX - currentMouseX) * 0.12;
|
|
||||||
currentMouseY += (targetMouseY - currentMouseY) * 0.12;
|
|
||||||
currentScrollPitch += (targetScrollPitch - currentScrollPitch) * 0.15;
|
|
||||||
targetScrollPitch *= 0.85;
|
|
||||||
|
|
||||||
let idx = 0;
|
|
||||||
visibleElements.forEach((el) => {
|
|
||||||
idx++;
|
|
||||||
const phase = idx * 0.5;
|
|
||||||
const waveX = Math.sin(clock * 1.4 + phase) * 3.4;
|
|
||||||
const waveY = Math.cos(clock * 1.1 + phase) * 4.0;
|
|
||||||
const waveZ = Math.sin(clock * 1.8 + phase) * 6;
|
|
||||||
|
|
||||||
const tagName = el.tagName.toLowerCase();
|
|
||||||
let baseZ = 16;
|
|
||||||
let rotMultiplier = 1;
|
|
||||||
|
|
||||||
if (tagName === 'h1') {
|
|
||||||
baseZ = 32;
|
|
||||||
rotMultiplier = 1.3;
|
|
||||||
} else if (tagName === 'h2') {
|
|
||||||
baseZ = 24;
|
|
||||||
rotMultiplier = 1.15;
|
|
||||||
} else if (tagName === 'h3') {
|
|
||||||
baseZ = 18;
|
|
||||||
rotMultiplier = 1.0;
|
|
||||||
} else if (el.classList.contains('stat-value')) {
|
|
||||||
baseZ = 28;
|
|
||||||
rotMultiplier = 1.25;
|
|
||||||
} else if (tagName === 'h4') {
|
|
||||||
baseZ = 14;
|
|
||||||
rotMultiplier = 0.9;
|
|
||||||
}
|
|
||||||
|
|
||||||
const rotX = (-currentMouseY * 6 + currentScrollPitch + waveX) * rotMultiplier;
|
|
||||||
const rotY = (currentMouseX * 7 + waveY) * rotMultiplier;
|
|
||||||
const transZ = Math.max(baseZ + waveZ, 6);
|
|
||||||
|
|
||||||
// Batch write directly to GPU transform matrix (ZERO DOM READS!)
|
|
||||||
el.style.transform = `perspective(950px) rotateX(${rotX.toFixed(2)}deg) rotateY(${rotY.toFixed(2)}deg) translateZ(${transZ.toFixed(1)}px)`;
|
|
||||||
});
|
|
||||||
|
|
||||||
rafId = requestAnimationFrame(tick);
|
|
||||||
};
|
|
||||||
|
|
||||||
rafId = requestAnimationFrame(tick);
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
cancelAnimationFrame(rafId);
|
|
||||||
observer.disconnect();
|
|
||||||
window.removeEventListener('mousemove', handleMouseMove);
|
|
||||||
window.removeEventListener('scroll', handleScroll);
|
|
||||||
};
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
@@ -17,32 +17,44 @@ export function CursorAura() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let isMoving = false;
|
||||||
|
let animId: number = 0;
|
||||||
|
|
||||||
|
const render = () => {
|
||||||
|
const pos = posRef.current;
|
||||||
|
const dx = pos.targetX - pos.currentX;
|
||||||
|
const dy = pos.targetY - pos.currentY;
|
||||||
|
|
||||||
|
// Snappy lerp
|
||||||
|
pos.currentX += dx * 0.15;
|
||||||
|
pos.currentY += dy * 0.15;
|
||||||
|
|
||||||
|
if (auraRef.current) {
|
||||||
|
auraRef.current.style.transform = `translate3d(${pos.currentX - 200}px, ${pos.currentY - 200}px, 0)`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Automatically halt RAF loop when mouse stops to achieve 0% idle CPU
|
||||||
|
if (Math.abs(dx) > 0.5 || Math.abs(dy) > 0.5) {
|
||||||
|
animId = requestAnimationFrame(render);
|
||||||
|
} else {
|
||||||
|
isMoving = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const onMouseMove = (e: MouseEvent) => {
|
const onMouseMove = (e: MouseEvent) => {
|
||||||
posRef.current.targetX = e.clientX;
|
posRef.current.targetX = e.clientX;
|
||||||
posRef.current.targetY = e.clientY;
|
posRef.current.targetY = e.clientY;
|
||||||
|
|
||||||
|
if (!isMoving) {
|
||||||
|
isMoving = true;
|
||||||
|
animId = requestAnimationFrame(render);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
window.addEventListener('mousemove', onMouseMove, { passive: true });
|
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 () => {
|
return () => {
|
||||||
cancelAnimationFrame(animId);
|
if (animId) cancelAnimationFrame(animId);
|
||||||
window.removeEventListener('mousemove', onMouseMove);
|
window.removeEventListener('mousemove', onMouseMove);
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
@@ -56,11 +68,10 @@ export function CursorAura() {
|
|||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
ref={auraRef}
|
ref={auraRef}
|
||||||
className="absolute top-0 left-0 w-[500px] h-[500px] rounded-full will-change-transform opacity-60"
|
className="absolute top-0 left-0 w-[400px] h-[400px] rounded-full will-change-transform opacity-70"
|
||||||
style={{
|
style={{
|
||||||
background:
|
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%)',
|
'radial-gradient(circle, rgba(59, 130, 246, 0.08) 0%, rgba(99, 102, 241, 0.04) 40%, transparent 70%)',
|
||||||
filter: 'blur(35px)',
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import React, { useRef, useEffect } from 'react';
|
import React, { useRef, useState, useCallback } from 'react';
|
||||||
|
|
||||||
interface Kinetic3DTextProps {
|
interface Kinetic3DTextProps {
|
||||||
primaryText: string;
|
primaryText: string;
|
||||||
@@ -15,119 +15,58 @@ export function Kinetic3DText({
|
|||||||
subtitle,
|
subtitle,
|
||||||
className = '',
|
className = '',
|
||||||
}: Kinetic3DTextProps) {
|
}: Kinetic3DTextProps) {
|
||||||
|
const [tilt, setTilt] = useState({ rx: 0, ry: 0, active: false });
|
||||||
const containerRef = useRef<HTMLDivElement>(null);
|
const containerRef = useRef<HTMLDivElement>(null);
|
||||||
const headlineRef = useRef<HTMLHeadingElement>(null);
|
|
||||||
const shadowRef = useRef<HTMLDivElement>(null);
|
|
||||||
const subtitleRef = useRef<HTMLParagraphElement>(null);
|
|
||||||
|
|
||||||
useEffect(() => {
|
const handleMouseMove = useCallback((e: React.MouseEvent<HTMLDivElement>) => {
|
||||||
// Check prefers-reduced-motion
|
if (!containerRef.current) return;
|
||||||
if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) return;
|
const rect = containerRef.current.getBoundingClientRect();
|
||||||
|
const nx = (e.clientX - rect.left) / rect.width - 0.5;
|
||||||
|
const ny = (e.clientY - rect.top) / rect.height - 0.5;
|
||||||
|
setTilt({
|
||||||
|
rx: Math.max(Math.min(-ny * 10, 8), -8),
|
||||||
|
ry: Math.max(Math.min(nx * 12, 10), -10),
|
||||||
|
active: true,
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
let rafId: number;
|
const handleMouseLeave = useCallback(() => {
|
||||||
let targetRx = 0;
|
setTilt({ rx: 0, ry: 0, active: false });
|
||||||
let targetRy = 0;
|
|
||||||
let currentRx = 0;
|
|
||||||
let currentRy = 0;
|
|
||||||
let clock = 0;
|
|
||||||
|
|
||||||
const handleMouseMove = (e: MouseEvent) => {
|
|
||||||
const vw = window.innerWidth;
|
|
||||||
const vh = window.innerHeight;
|
|
||||||
// Normalized coordinates -1 to +1 centered on screen
|
|
||||||
const nx = (e.clientX / vw) * 2 - 1;
|
|
||||||
const ny = (e.clientY / vh) * 2 - 1;
|
|
||||||
|
|
||||||
targetRy = nx * 14; // Horizontal tilt up to 14 deg
|
|
||||||
targetRx = -ny * 12; // Vertical tilt up to 12 deg
|
|
||||||
};
|
|
||||||
|
|
||||||
const updateLoop = () => {
|
|
||||||
clock += 0.025;
|
|
||||||
|
|
||||||
// Inertial damping lerp for mouse response
|
|
||||||
currentRx += (targetRx - currentRx) * 0.085;
|
|
||||||
currentRy += (targetRy - currentRy) * 0.085;
|
|
||||||
|
|
||||||
// Autonomous continuous 3D breathing wave (always alive)
|
|
||||||
const waveRx = Math.sin(clock * 1.4) * 3.5;
|
|
||||||
const waveRy = Math.cos(clock * 1.1) * 4.2;
|
|
||||||
const waveZ = Math.sin(clock * 1.8) * 8;
|
|
||||||
|
|
||||||
const totalRx = currentRx + waveRx;
|
|
||||||
const totalRy = currentRy + waveRy;
|
|
||||||
|
|
||||||
if (containerRef.current) {
|
|
||||||
containerRef.current.style.transform = `perspective(1100px) rotateX(${totalRx.toFixed(2)}deg) rotateY(${totalRy.toFixed(2)}deg) translateZ(${waveZ.toFixed(1)}px)`;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (headlineRef.current) {
|
|
||||||
// Multi-tier parallax elevation
|
|
||||||
headlineRef.current.style.transform = `translateZ(42px) rotateX(${(totalRx * 0.3).toFixed(2)}deg)`;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (shadowRef.current) {
|
|
||||||
// Holographic blur shadow projected behind
|
|
||||||
shadowRef.current.style.transform = `translateZ(-28px) translate(${(totalRy * 1.8).toFixed(1)}px, ${(totalRx * 1.8).toFixed(1)}px) scale(1.05)`;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (subtitleRef.current) {
|
|
||||||
subtitleRef.current.style.transform = `translateZ(24px) rotateX(${(totalRx * 0.2).toFixed(2)}deg)`;
|
|
||||||
}
|
|
||||||
|
|
||||||
rafId = requestAnimationFrame(updateLoop);
|
|
||||||
};
|
|
||||||
|
|
||||||
window.addEventListener('mousemove', handleMouseMove, { passive: true });
|
|
||||||
rafId = requestAnimationFrame(updateLoop);
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
window.removeEventListener('mousemove', handleMouseMove);
|
|
||||||
cancelAnimationFrame(rafId);
|
|
||||||
};
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={`relative perspective-1000 select-none ${className}`}>
|
<div
|
||||||
{/* 3D Stereoscopic Kinetic Text Stage */}
|
ref={containerRef}
|
||||||
|
onMouseMove={handleMouseMove}
|
||||||
|
onMouseLeave={handleMouseLeave}
|
||||||
|
className={`relative select-none ${className}`}
|
||||||
|
style={{ perspective: 1000 }}
|
||||||
|
>
|
||||||
<div
|
<div
|
||||||
ref={containerRef}
|
className="transition-transform duration-200 ease-out"
|
||||||
className="preserve-3d will-change-transform"
|
style={{
|
||||||
|
transform: tilt.active
|
||||||
|
? `rotateX(${tilt.rx.toFixed(2)}deg) rotateY(${tilt.ry.toFixed(2)}deg)`
|
||||||
|
: 'rotateX(0deg) rotateY(0deg)',
|
||||||
|
transformStyle: 'preserve-3d',
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{/* Layer 1: Ambient 3D Text Holographic Depth Reflection */}
|
{/* Main Floating Headline (100% Visible, Crisp, Zero Disappearance) */}
|
||||||
<div
|
<h1 className="text-4xl sm:text-5xl lg:text-6xl xl:text-7xl font-display font-black text-slate-900 tracking-tight leading-[1.08] relative z-10">
|
||||||
ref={shadowRef}
|
<span className="inline-block text-slate-900">{primaryText}</span>{' '}
|
||||||
className="absolute inset-0 select-none pointer-events-none opacity-25 blur-lg will-change-transform"
|
|
||||||
aria-hidden="true"
|
|
||||||
>
|
|
||||||
<span className="text-4xl sm:text-5xl lg:text-6xl xl:text-7xl font-display font-black text-blue-600 leading-[1.08] tracking-tight block">
|
|
||||||
{primaryText} <br className="hidden sm:inline" />
|
|
||||||
{highlightText}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Layer 2: Main Floating 3D Headline with Chiseled Extrusion */}
|
|
||||||
<h1
|
|
||||||
ref={headlineRef}
|
|
||||||
className="text-4xl sm:text-5xl lg:text-6xl xl:text-7xl font-display font-black text-slate-900 tracking-tight leading-[1.08] relative z-10 preserve-3d will-change-transform text-3d-chiseled"
|
|
||||||
>
|
|
||||||
<span className="inline-block preserve-3d">{primaryText}</span>{' '}
|
|
||||||
<br className="hidden sm:inline" />
|
<br className="hidden sm:inline" />
|
||||||
{highlightText && (
|
{highlightText && (
|
||||||
<span className="relative inline-block mt-2 sm:mt-1 preserve-3d">
|
<span className="relative inline-block mt-1 sm:mt-0">
|
||||||
<span className="text-transparent bg-clip-text bg-gradient-to-r from-blue-700 via-indigo-600 to-amber-600 text-3d-gradient inline-block">
|
<span className="text-transparent bg-clip-text bg-gradient-to-r from-blue-700 via-indigo-600 to-amber-600 inline-block font-black">
|
||||||
{highlightText}
|
{highlightText}
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
{/* Layer 3: Elevated 3D Subtitle */}
|
{/* Subtitle (100% Visible & Crisp) */}
|
||||||
{subtitle && (
|
{subtitle && (
|
||||||
<p
|
<p className="mt-6 text-base sm:text-lg lg:text-xl text-slate-600 leading-relaxed max-w-2xl mx-auto font-normal">
|
||||||
ref={subtitleRef}
|
|
||||||
className="mt-6 text-base sm:text-lg lg:text-xl text-slate-600 leading-relaxed max-w-2xl mx-auto font-normal preserve-3d will-change-transform"
|
|
||||||
>
|
|
||||||
{subtitle}
|
{subtitle}
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user