"use client"; import { useRef, useState } from "react"; import { Canvas, useFrame } from "@react-three/fiber"; import { Float, MeshDistortMaterial, Environment, ContactShadows, Lightformer, PerspectiveCamera } from "@react-three/drei"; import * as THREE from "three"; import { useTheme } from "next-themes"; function FloatingShape() { const mesh = useRef(null); const { theme, resolvedTheme } = useTheme(); const [hovered, setHovered] = useState(false); const currentTheme = theme === "system" ? resolvedTheme : theme; const isDark = currentTheme === "dark"; const color = isDark ? "#6366f1" : "#8b5cf6"; // primary or accent colors const emissive = isDark ? "#3730a3" : "#4c1d95"; // Animate on interaction useFrame((state) => { if (mesh.current) { mesh.current.rotation.x = THREE.MathUtils.lerp(mesh.current.rotation.x, hovered ? state.mouse.y * 0.5 : state.clock.getElapsedTime() * 0.2, 0.1); mesh.current.rotation.y = THREE.MathUtils.lerp(mesh.current.rotation.y, hovered ? state.mouse.x * 0.5 : state.clock.getElapsedTime() * 0.3, 0.1); } }); return ( setHovered(true)} onPointerOut={() => setHovered(false)} scale={hovered ? 1.1 : 1} > ); } export default function Hero3D() { const { theme, resolvedTheme } = useTheme(); const currentTheme = theme === "system" ? resolvedTheme : theme; const isDark = currentTheme === "dark"; return (
); }