import { useRef } from 'react'; import { Canvas, useFrame } from '@react-three/fiber'; import { Sphere, Box, Torus, Float, Text3D, MeshDistortMaterial } from '@react-three/drei'; import { EffectComposer, Bloom, ChromaticAberration } from '@react-three/postprocessing'; import * as THREE from 'three'; function FloatingShape({ position, shape }: { position: [number, number, number], shape: 'sphere' | 'box' | 'torus' }) { const meshRef = useRef(null); useFrame((state) => { if (meshRef.current) { meshRef.current.rotation.x = Math.sin(state.clock.elapsedTime + position[0]) * 0.2; meshRef.current.rotation.y = Math.sin(state.clock.elapsedTime + position[1]) * 0.3; } }); const renderShape = () => { switch (shape) { case 'sphere': return ( ); case 'box': return ( ); case 'torus': return ( ); } }; return ( {renderShape()} ); } function WaveformBars() { const groupRef = useRef(null); const barsCount = 20; useFrame((state) => { if (groupRef.current) { groupRef.current.children.forEach((bar, index) => { const height = 1 + Math.sin(state.clock.elapsedTime * 3 + index * 0.3) * 0.5; bar.scale.y = height; }); } }); return ( {Array.from({ length: barsCount }, (_, i) => ( ))} ); } interface FloatingElementsProps { className?: string; showEffects?: boolean; } export default function FloatingElements({ className = "", showEffects = true }: FloatingElementsProps) { const shapes: Array<{ position: [number, number, number], shape: 'sphere' | 'box' | 'torus' }> = [ { position: [-3, 2, -2], shape: 'sphere' }, { position: [3, -1, -3], shape: 'box' }, { position: [-2, -2, -1], shape: 'torus' }, { position: [2, 3, -2], shape: 'sphere' }, { position: [-4, 0, -4], shape: 'box' }, { position: [4, -3, -1], shape: 'torus' }, ]; return (
{ try { gl.setPixelRatio(1); gl.domElement.addEventListener('webglcontextlost', (e) => (e as Event).preventDefault(), false); } catch {} }} > {shapes.map((item, index) => ( ))} {showEffects && ( )}
); }