import { CameraControls, useGLTF } from "@react-three/drei"; import { Canvas } from "@react-three/fiber"; import { Suspense, useRef } from "react"; import CameraRig from "./CameraRig"; import { FLY_AREA_CONFIG } from "./env"; import FlyInstances from "./FlyInstances"; import FlyLabels from "./FlyLabels"; import MapView from "./MapView"; import RoomScene from "./RoomScene"; import { ROOM_CONFIG } from "./roomLayout"; import { FLY_EXTENT_MM, type FlyInstanceData } from "./useFlyLayout"; import type { LiveFlyPositions } from "./useLiveFlyState"; // Close-up "hero shot" distance/height when a specific fly is selected, // derived from one fly's own size so every instance gets the same framing // regardless of where in the ground area it sits. Magnitudes match the // previous fixed diagonal offset's horizontal/vertical components, now // applied relative to each fly's own current heading (see CameraRig). const flyCamDist = Math.max(...FLY_EXTENT_MM) * 2.4; const FOCUS_BACK_MM = flyCamDist * Math.hypot(0.7, 0.9); const FOCUS_UP_MM = flyCamDist * 0.35; // Overview camera/far-plane scale still derives from the configured ground // area (not a single fly). const areaSize = Math.max(FLY_AREA_CONFIG.widthMm, FLY_AREA_CONFIG.depthMm); // Initial view: inside the room, in a free-floor corner, elevated partway // up toward the ceiling and looking back across the room toward the // center -- not floating outside the walls looking at the room as a // closed box from above. const INSIDE_WALL_MARGIN_MM = 300; const OVERVIEW = { position: [ -(ROOM_CONFIG.widthMm / 2 - INSIDE_WALL_MARGIN_MM), ROOM_CONFIG.wallHeightMm * 0.65, -(ROOM_CONFIG.depthMm / 2 - INSIDE_WALL_MARGIN_MM), ] as [number, number, number], target: [0, 0, 0] as [number, number, number], }; interface FlySceneProps { flies: FlyInstanceData[]; selectedFlyId: string | null; onSelectFly: (id: string | null) => void; livePositionsRef: React.RefObject; joystickRef: React.RefObject<{ x: number; y: number }>; wingSlidersRef: React.RefObject<{ left: number; right: number }>; } export default function FlyScene({ flies, selectedFlyId, onSelectFly, livePositionsRef, joystickRef, wingSlidersRef, }: FlySceneProps) { const controlsRef = useRef(null); return ( ); } useGLTF.preload("/models/fly.glb");