import { useRef, useMemo } from 'react'; import { useFrame } from '@react-three/fiber'; import { TextureLoader, DoubleSide, Mesh } from 'three'; export default function Flag({ isCelebrating }: { isCelebrating: boolean }) { const flagRef = useRef(null); const poleRef = useRef(null); // Create flag texture with text const texture = useMemo(() => { const canvas = document.createElement('canvas'); canvas.width = 512; canvas.height = 256; const ctx = canvas.getContext('2d')!; // Gradient background - Brand blue colors const gradient = ctx.createLinearGradient(0, 0, 512, 0); gradient.addColorStop(0, '#2E90FA'); gradient.addColorStop(1, '#84CAFF'); ctx.fillStyle = gradient; ctx.fillRect(0, 0, 512, 256); // Add text ctx.fillStyle = '#FFFFFF'; ctx.font = 'bold 40px Arial'; ctx.textAlign = 'center'; ctx.textBaseline = 'middle'; ctx.fillText('Freshyo for', 256, 100); ctx.fillText('mahabubnagar', 256, 160); // Add decorative border ctx.strokeStyle = '#FFFFFF'; ctx.lineWidth = 4; ctx.strokeRect(10, 10, 492, 236); const texture = new TextureLoader().load(canvas.toDataURL()); return texture; }, []); useFrame((state) => { if (flagRef.current) { const time = state.clock.getElapsedTime(); // Wave animation const waveIntensity = isCelebrating ? 0.3 : 0.1; flagRef.current.rotation.y = Math.sin(time * 3) * waveIntensity; flagRef.current.rotation.z = Math.sin(time * 2) * 0.05; } }); return ( {/* Flag Pole */} {/* Flag */} {/* Pole Top */} ); }