import { useRef, useMemo } from 'react'; import { Canvas, useFrame } from '@react-three/fiber'; import { Float, MeshDistortMaterial, Sphere, Torus } from '@react-three/drei'; import * as THREE from 'three'; function Atom({ position, color, scale = 1 }: { position: [number, number, number]; color: string; scale?: number }) { const ref = useRef(null); useFrame((state) => { if (!ref.current) return; ref.current.rotation.x = Math.sin(state.clock.elapsedTime * 0.3) * 0.2; ref.current.rotation.y += 0.005; }); return ( ); } function Bond({ start, end, color }: { start: [number, number, number]; end: [number, number, number]; color: string }) { const ref = useRef(null); const midpoint = useMemo<[number, number, number]>(() => [ (start[0] + end[0]) / 2, (start[1] + end[1]) / 2, (start[2] + end[2]) / 2, ], [start, end]); const length = useMemo(() => { return Math.sqrt( (end[0] - start[0]) ** 2 + (end[1] - start[1]) ** 2 + (end[2] - start[2]) ** 2, ); }, [start, end]); const rotation = useMemo(() => { const dir = new THREE.Vector3(end[0] - start[0], end[1] - start[1], end[2] - start[2]).normalize(); const quat = new THREE.Quaternion().setFromUnitVectors(new THREE.Vector3(0, 1, 0), dir); const euler = new THREE.Euler().setFromQuaternion(quat); return [euler.x, euler.y, euler.z] as [number, number, number]; }, [start, end]); return ( ); } function Molecule({ position, rotationSpeed = 0.003 }: { position: [number, number, number]; rotationSpeed?: number }) { const groupRef = useRef(null); useFrame(() => { if (!groupRef.current) return; groupRef.current.rotation.y += rotationSpeed; groupRef.current.rotation.x += rotationSpeed * 0.5; }); return ( ); } function FloatingRing({ position, color, size = 1 }: { position: [number, number, number]; color: string; size?: number }) { const ref = useRef(null); useFrame((state) => { if (!ref.current) return; ref.current.rotation.x = Math.sin(state.clock.elapsedTime * 0.5) * 0.5 + Math.PI * 0.3; ref.current.rotation.z += 0.008; }); return ( ); } function Particles({ count = 60 }: { count?: number }) { const points = useMemo(() => { const positions = new Float32Array(count * 3); for (let i = 0; i < count; i++) { positions[i * 3] = (Math.random() - 0.5) * 12; positions[i * 3 + 1] = (Math.random() - 0.5) * 8; positions[i * 3 + 2] = (Math.random() - 0.5) * 6; } return positions; }, [count]); const ref = useRef(null); useFrame((state) => { if (!ref.current) return; ref.current.rotation.y = state.clock.elapsedTime * 0.02; ref.current.rotation.x = Math.sin(state.clock.elapsedTime * 0.05) * 0.1; }); return ( ); } function GlowSphere({ position, color }: { position: [number, number, number]; color: string }) { return ( ); } interface MoleculeSceneProps { className?: string; variant?: 'hero' | 'stage' | 'minimal'; } export default function MoleculeScene({ className, variant = 'hero' }: MoleculeSceneProps) { return (
{variant === 'hero' && ( <> )} {variant === 'stage' && ( <> )} {variant === 'minimal' && ( <> )}
); }