"use client"; import { Float, MeshDistortMaterial, MeshTransmissionMaterial, } from "@react-three/drei"; import { Canvas, useFrame } from "@react-three/fiber"; import { useMemo, useRef } from "react"; import * as THREE from "three"; function GlassSphere({ position, scale = 1, }: { position: [number, number, number]; scale?: number; }) { const meshRef = useRef(null); useFrame((state) => { if (!meshRef.current) return; const t = state.clock.elapsedTime; meshRef.current.rotation.x = Math.sin(t * 0.3) * 0.2; meshRef.current.rotation.z = Math.cos(t * 0.2) * 0.1; }); return ( ); } function WireframeRing({ position, scale = 1, }: { position: [number, number, number]; scale?: number; }) { const meshRef = useRef(null); useFrame((state) => { if (!meshRef.current) return; const t = state.clock.elapsedTime; meshRef.current.rotation.x = t * 0.1; meshRef.current.rotation.y = t * 0.15; }); return ( ); } function DataStream({ count = 50 }: { count?: number }) { const pointsRef = useRef(null); const positions = useMemo(() => { const pos = new Float32Array(count * 3); for (let i = 0; i < count; i++) { const i3 = i * 3; // Create a spiral/helix pattern const angle = (i / count) * Math.PI * 8; const radius = 2 + Math.sin(angle * 0.5) * 0.5; pos[i3] = Math.cos(angle) * radius; pos[i3 + 1] = (i / count - 0.5) * 12; pos[i3 + 2] = Math.sin(angle) * radius; } return pos; }, [count]); useFrame((state) => { if (!pointsRef.current) return; const t = state.clock.elapsedTime; pointsRef.current.rotation.y = t * 0.05; const posAttr = pointsRef.current.geometry.getAttribute( "position", ) as THREE.BufferAttribute; const arr = posAttr.array as Float32Array; for (let i = 0; i < count; i++) { const i3 = i * 3; arr[i3 + 1] += 0.02; if (arr[i3 + 1] > 6) arr[i3 + 1] = -6; } posAttr.needsUpdate = true; }); return ( ); } interface FloatingElementsProps { variant?: "sphere" | "ring" | "data" | "combined"; className?: string; } export default function FloatingElements({ variant = "combined", className = "", }: FloatingElementsProps) { return (
{(variant === "sphere" || variant === "combined") && ( <> )} {(variant === "ring" || variant === "combined") && ( <> )} {(variant === "data" || variant === "combined") && ( )}
); }