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 (
); } // Room Component function Room({ avatarPosition }) { return ( ); } // Avatar Component function Avatar({ position }) { return ( ); } export default function App() { const [messages, setMessages] = useState([]); const [inputText, setInputText] = useState(''); const [avatarPosition, setAvatarPosition] = useState({ x: 0, y: 0 }); const [showCustomization, setShowCustomization] = useState(false); const [avatarColor, setAvatarColor] = useState('#8b5cf6'); const handleSendMessage = (e) => { e.preventDefault(); if (inputText.trim()) { setMessages([...messages, { text: inputText, sender: 'user' }]); setInputText(''); } }; const handleJoystickMove = (position) => { setAvatarPosition(position); }; return (
{/* Header */}

Io

Your AI Companion

{/* 3D Environment */}
{/* Joystick */}
{/* Customization Panel */} {showCustomization && (

Avatar Customization

setAvatarColor(e.target.value)} className="w-full" />
)}
{/* Chat Input */}
setInputText(e.target.value)} placeholder="Talk to me..." className="flex-1 p-3 rounded-full bg-gray-100 focus:outline-none focus:ring-2 focus:ring-purple-400" />
); }