"use client"; import { Canvas, useFrame, useThree } from "@react-three/fiber"; import { useEffect, useMemo, useRef } from "react"; import * as THREE from "three"; type HeroSceneVariant = | "command" | "launch" | "rescue" | "signal" | "diagnostic" | "portrait"; function GridFloor() { const meshRef = useRef(null); useFrame((state) => { if (meshRef.current) { const material = meshRef.current.material as THREE.ShaderMaterial; if (material.uniforms) { material.uniforms.uTime.value = state.clock.elapsedTime; } } }); const gridShader = useMemo( () => ({ uniforms: { uTime: { value: 0 }, uColor: { value: new THREE.Color("#ccff00") }, }, vertexShader: ` varying vec2 vUv; varying vec3 vPosition; void main() { vUv = uv; vPosition = position; gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); } `, fragmentShader: ` uniform float uTime; uniform vec3 uColor; varying vec2 vUv; varying vec3 vPosition; void main() { vec2 grid = abs(fract(vPosition.xz * 0.5) - 0.5) / fwidth(vPosition.xz * 0.5); float line = min(grid.x, grid.y); float alpha = 1.0 - min(line, 1.0); // Distance fade float dist = length(vPosition.xz) * 0.08; alpha *= max(0.0, 1.0 - dist); alpha *= 0.12; // Pulse wave float wave = sin(length(vPosition.xz) * 0.3 - uTime * 0.8) * 0.5 + 0.5; alpha *= 0.5 + wave * 0.5; gl_FragColor = vec4(uColor, alpha); } `, }), [], ); return ( ); } function CameraRig() { const { camera } = useThree(); const mouseRef = useRef({ x: 0, y: 0 }); useFrame(() => { const targetX = mouseRef.current.x * 0.5; const targetY = mouseRef.current.y * 0.3 + 0.5; camera.position.x += (targetX - camera.position.x) * 0.02; camera.position.y += (targetY - camera.position.y) * 0.02; camera.lookAt(0, 0, 0); }); useEffect(() => { const handler = (e: MouseEvent) => { mouseRef.current.x = (e.clientX / window.innerWidth) * 2 - 1; mouseRef.current.y = -(e.clientY / window.innerHeight) * 2 + 1; }; window.addEventListener("mousemove", handler); return () => window.removeEventListener("mousemove", handler); }, []); return null; } export default function HeroScene({ variant, isVisible = true, }: { variant?: HeroSceneVariant; isVisible?: boolean; }) { void variant; return (
); }