import { useState, useRef, Suspense } from 'react'; import { MessageCircle, Menu, Settings, Plus, Palette } from 'lucide-react'; import { Canvas } from '@react-three/fiber'; import { OrbitControls, PerspectiveCamera, Environment, useGLTF } from '@react-three/drei'; // Virtual Joystick Component function Joystick({ onMove }) { const [isDragging, setIsDragging] = useState(false); const [position, setPosition] = useState({ x: 0, y: 0 }); const containerRef = useRef(); const knobRef = useRef(); const handleStart = (e) => { const touch = e.touches ? e.touches[0] : e; setIsDragging(true); updatePosition(touch); }; const handleMove = (e) => { if (!isDragging) return; const touch = e.touches ? e.touches[0] : e; updatePosition(touch); }; const updatePosition = (touch) => { const container = containerRef.current.getBoundingClientRect(); const centerX = container.width / 2; const centerY = container.height / 2; const x = touch.clientX - container.left - centerX; const y = touch.clientY - container.top - centerY; const radius = container.width / 2; const distance = Math.min(Math.sqrt(x * x + y * y), radius); const angle = Math.atan2(y, x); const newX = Math.cos(angle) * distance; const newY = Math.sin(angle) * distance; setPosition({ x: newX, y: newY }); onMove({ x: newX / radius, y: newY / radius }); }; const handleEnd = () => { setIsDragging(false); setPosition({ x: 0, y: 0 }); onMove({ x: 0, y: 0 }); }; return (
Your AI Companion