'use client' import { useRef, useMemo } from 'react' import { Canvas, useFrame } from '@react-three/fiber' import { Float } from '@react-three/drei' import * as THREE from 'three' /* ─── Orbiting particles ─── */ function Particles({ count = 80 }: { count?: number }) { const mesh = useRef(null) const dummy = useMemo(() => new THREE.Object3D(), []) const particles = useMemo(() => { return Array.from({ length: count }, (_, i) => ({ radius: 1.8 + Math.random() * 1.4, speed: 0.15 + Math.random() * 0.3, offset: (i / count) * Math.PI * 2, y: (Math.random() - 0.5) * 2.5, size: 0.015 + Math.random() * 0.025, })) }, [count]) useFrame(({ clock }) => { if (!mesh.current) return const t = clock.getElapsedTime() particles.forEach((p, i) => { const angle = p.offset + t * p.speed dummy.position.set( Math.cos(angle) * p.radius, p.y + Math.sin(t * 0.5 + p.offset) * 0.3, Math.sin(angle) * p.radius ) dummy.scale.setScalar(p.size * (0.8 + Math.sin(t * 2 + p.offset) * 0.2)) dummy.updateMatrix() mesh.current!.setMatrixAt(i, dummy.matrix) }) mesh.current.instanceMatrix.needsUpdate = true }) return ( ) } /* ─── Orbital rings ─── */ function OrbitalRing({ radius, speed, tilt }: { radius: number; speed: number; tilt: number }) { const ref = useRef(null) useFrame(({ clock }) => { if (!ref.current) return ref.current.rotation.z = tilt ref.current.rotation.y = clock.getElapsedTime() * speed }) return ( ) } /* ─── Shield geometry ─── */ function ShieldMesh() { const ref = useRef(null) const shieldShape = useMemo(() => { const shape = new THREE.Shape() // Shield outline shape.moveTo(0, 1.3) shape.bezierCurveTo(0.6, 1.2, 1.0, 0.9, 1.0, 0.4) shape.bezierCurveTo(1.0, -0.2, 0.7, -0.8, 0, -1.3) shape.bezierCurveTo(-0.7, -0.8, -1.0, -0.2, -1.0, 0.4) shape.bezierCurveTo(-1.0, 0.9, -0.6, 1.2, 0, 1.3) return shape }, []) const extrudeSettings = useMemo(() => ({ depth: 0.15, bevelEnabled: true, bevelThickness: 0.03, bevelSize: 0.03, bevelSegments: 3, }), []) useFrame(({ clock }) => { if (!ref.current) return ref.current.rotation.y = Math.sin(clock.getElapsedTime() * 0.3) * 0.15 }) return ( {/* Shield body */} {/* Inner shield face */} {/* Shield edge glow */} {/* Center node */} {/* Network nodes */} {[ [0, 0.55, 0.1], [-0.35, -0.15, 0.1], [0.35, -0.15, 0.1], [0, -0.55, 0.1], ].map((pos, i) => ( ))} ) } /* ─── Data stream lines flowing around ─── */ function DataStreams({ count = 12 }: { count?: number }) { const ref = useRef(null) const streams = useMemo(() => { return Array.from({ length: count }, (_, i) => { const angle = (i / count) * Math.PI * 2 const radius = 2.0 + Math.random() * 0.5 const points = Array.from({ length: 20 }, (_, j) => { const t = j / 19 const a = angle + t * Math.PI * 0.5 return new THREE.Vector3( Math.cos(a) * radius * (1 - t * 0.3), (t - 0.5) * 3, Math.sin(a) * radius * (1 - t * 0.3) ) }) return { points, speed: 0.5 + Math.random() * 0.5 } }) }, [count]) useFrame(({ clock }) => { if (!ref.current) return ref.current.rotation.y = clock.getElapsedTime() * 0.05 }) return ( {streams.map((stream, i) => { const curve = new THREE.CatmullRomCurve3(stream.points) return ( ) })} ) } /* ─── Main scene ─── */ export function ShieldScene() { return (
) }