'use client'; /** * Cortex Core * Central processing element with pulsing golden glow * The focal point of the memory chip */ import { useRef, useMemo } from 'react'; import { useFrame } from '@react-three/fiber'; import { Html } from '@react-three/drei'; import * as THREE from 'three'; interface CortexCoreProps { position?: [number, number, number]; size?: number; activity?: number; // 0-1, affects pulse intensity showLabel?: boolean; } export function CortexCore({ position = [0, 0, 0], size = 2, activity = 0.5, showLabel = true, }: CortexCoreProps) { const coreRef = useRef(null); const glow1Ref = useRef(null); const glow2Ref = useRef(null); const glow3Ref = useRef(null); // Core material - bright gold center const coreMaterial = useMemo(() => { return new THREE.MeshStandardMaterial({ color: '#FFD700', emissive: '#FFD700', emissiveIntensity: 0.8, metalness: 0.3, roughness: 0.4, }); }, []); // Glow materials - progressively fainter const glowMaterials = useMemo(() => { return [ new THREE.MeshBasicMaterial({ color: '#FFD700', transparent: true, opacity: 0.4, side: THREE.BackSide, }), new THREE.MeshBasicMaterial({ color: '#FFB347', transparent: true, opacity: 0.2, side: THREE.BackSide, }), new THREE.MeshBasicMaterial({ color: '#FF8C00', transparent: true, opacity: 0.1, side: THREE.BackSide, }), ]; }, []); // Animate pulse useFrame((state) => { const time = state.clock.elapsedTime; const basePulse = Math.sin(time * 2) * 0.5 + 0.5; const activityBoost = activity * 0.3; // Core pulse if (coreRef.current) { const material = coreRef.current.material as THREE.MeshStandardMaterial; material.emissiveIntensity = 0.6 + basePulse * 0.4 + activityBoost; } // Glow layers pulse with phase offset if (glow1Ref.current) { const mat = glow1Ref.current.material as THREE.MeshBasicMaterial; mat.opacity = 0.3 + basePulse * 0.2 + activityBoost * 0.5; glow1Ref.current.scale.setScalar(1 + basePulse * 0.05); } if (glow2Ref.current) { const phase2 = Math.sin(time * 2 + 0.5) * 0.5 + 0.5; const mat = glow2Ref.current.material as THREE.MeshBasicMaterial; mat.opacity = 0.15 + phase2 * 0.1 + activityBoost * 0.3; glow2Ref.current.scale.setScalar(1 + phase2 * 0.03); } if (glow3Ref.current) { const phase3 = Math.sin(time * 2 + 1) * 0.5 + 0.5; const mat = glow3Ref.current.material as THREE.MeshBasicMaterial; mat.opacity = 0.08 + phase3 * 0.05 + activityBoost * 0.2; glow3Ref.current.scale.setScalar(1 + phase3 * 0.02); } }); return ( {/* Core block - rounded rectangle */} {/* Inner detail - circuit pattern */} {/* Glow layer 1 */} {/* Glow layer 2 */} {/* Glow layer 3 */} {/* Activity indicator dot */} {/* Label */} {showLabel && (
CORTEX CORE
)}
); } // Circuit pattern on core surface function CoreCircuitPattern({ size }: { size: number }) { const linesGeometry = useMemo(() => { const points: THREE.Vector3[] = []; const halfSize = size / 2; const z = 0.16; // Horizontal lines for (let i = -2; i <= 2; i++) { const y = i * 0.12; points.push(new THREE.Vector3(-halfSize * 0.7, y, z)); points.push(new THREE.Vector3(halfSize * 0.7, y, z)); } // Vertical lines for (let i = -4; i <= 4; i++) { const x = i * 0.18; points.push(new THREE.Vector3(x, -size * 0.2, z)); points.push(new THREE.Vector3(x, size * 0.2, z)); } return new THREE.BufferGeometry().setFromPoints(points); }, [size]); return ( ); } // Pulsing activity indicator function ActivityIndicator({ activity, size }: { activity: number; size: number }) { const dotRef = useRef(null); useFrame((state) => { if (dotRef.current) { const pulse = Math.sin(state.clock.elapsedTime * 4) * 0.5 + 0.5; const scale = 0.8 + pulse * 0.4 + activity * 0.3; dotRef.current.scale.setScalar(scale); const material = dotRef.current.material as THREE.MeshBasicMaterial; material.opacity = 0.6 + pulse * 0.4; } }); const isActive = activity > 0.1; return ( ); }