diff --git a/backend/check_sirius.py b/backend/check_sirius.py new file mode 100644 index 0000000..ea60479 --- /dev/null +++ b/backend/check_sirius.py @@ -0,0 +1,31 @@ +import asyncio +import sys +import os + +sys.path.append(os.path.join(os.getcwd(), "backend")) + +from app.database import AsyncSessionLocal +from sqlalchemy import select +from app.models.db.star_system import StarSystem +from app.models.db.celestial_body import CelestialBody + +async def check_sirius(): + async with AsyncSessionLocal() as session: + # Check Star Systems + print("Checking Star Systems:") + stmt = select(StarSystem).where(StarSystem.name.ilike('%Sirius%')) + result = await session.execute(stmt) + systems = result.scalars().all() + for s in systems: + print(f"System: {s.name} ({s.name_zh}), ID: {s.id}, Pos: {s.position_x}, {s.position_y}, {s.position_z}") + + # Check Celestial Bodies + print("\nChecking Celestial Bodies:") + stmt = select(CelestialBody).where(CelestialBody.name.ilike('%Sirius%')) + result = await session.execute(stmt) + bodies = result.scalars().all() + for b in bodies: + print(f"Body: {b.name} ({b.name_zh}), ID: {b.id}, Type: {b.type}, SystemID: {b.system_id}") + +if __name__ == "__main__": + asyncio.run(check_sirius()) diff --git a/frontend/src/components/CelestialBody.tsx b/frontend/src/components/CelestialBody.tsx index 049be32..f2707a9 100644 --- a/frontend/src/components/CelestialBody.tsx +++ b/frontend/src/components/CelestialBody.tsx @@ -11,13 +11,13 @@ import { calculateRenderPosition, getOffsetDescription } from '../utils/renderPo import { fetchBodyResources } from '../utils/api'; import { getCelestialSize } from '../config/celestialSizes'; import { createLabelTexture } from '../utils/labelTexture'; -import { useSystemSetting } from '../hooks/useSystemSetting'; interface CelestialBodyProps { body: CelestialBodyType; allBodies: CelestialBodyType[]; isSelected?: boolean; onBodySelect?: (body: CelestialBodyType) => void; + typeConfigs?: any; } // Planetary Rings component - handles texture-based rings @@ -487,10 +487,9 @@ function PlanetMesh({ body, size, emissive, emissiveIntensity, scaledPos, textur ); } -export function CelestialBody({ body, allBodies, isSelected = false, onBodySelect }: CelestialBodyProps) { +export function CelestialBody({ body, allBodies, isSelected = false, onBodySelect, typeConfigs }: CelestialBodyProps) { // Get the current position (use the first position for now) const position = body.positions[0]; - const [typeConfigs] = useSystemSetting('celestial_type_configs', null); if (!position) return null; diff --git a/frontend/src/components/Probe.tsx b/frontend/src/components/Probe.tsx index 8b53841..ab812d4 100644 --- a/frontend/src/components/Probe.tsx +++ b/frontend/src/components/Probe.tsx @@ -10,13 +10,13 @@ import type { CelestialBody } from '../types'; import { calculateRenderPosition, getOffsetDescription } from '../utils/renderPosition'; import { fetchBodyResources } from '../utils/api'; import { createLabelTexture } from '../utils/labelTexture'; -import { useSystemSetting } from '../hooks/useSystemSetting'; interface ProbeProps { body: CelestialBody; allBodies: CelestialBody[]; isSelected?: boolean; onBodySelect?: (body: CelestialBody) => void; + typeConfigs?: any; } // Separate component for each probe type to properly use hooks @@ -255,12 +255,11 @@ function ProbeFallback({ body, allBodies, isSelected = false, onBodySelect, type ); } -export function Probe({ body, allBodies, isSelected = false, onBodySelect }: ProbeProps) { +export function Probe({ body, allBodies, isSelected = false, onBodySelect, typeConfigs }: ProbeProps) { const position = body.positions[0]; const [modelPath, setModelPath] = useState(undefined); const [loadError, setLoadError] = useState(false); const [resourceScale, setResourceScale] = useState(1.0); - const [typeConfigs] = useSystemSetting('celestial_type_configs', null); // Fetch model from backend API useEffect(() => { diff --git a/frontend/src/components/Scene.tsx b/frontend/src/components/Scene.tsx index 2e6034b..d3afe8b 100644 --- a/frontend/src/components/Scene.tsx +++ b/frontend/src/components/Scene.tsx @@ -172,6 +172,7 @@ export function Scene({ bodies, selectedBody, trajectoryPositions = [], showOrbi allBodies={bodies} isSelected={selectedBody?.id === body.id} onBodySelect={onBodySelect} + typeConfigs={typeConfigs} /> ))} @@ -186,6 +187,7 @@ export function Scene({ bodies, selectedBody, trajectoryPositions = [], showOrbi allBodies={bodies} isSelected={selectedBody?.id === body.id} onBodySelect={onBodySelect} + typeConfigs={typeConfigs} /> ))} diff --git a/frontend/src/hooks/useSystemSetting.ts b/frontend/src/hooks/useSystemSetting.ts index 755bfd8..e3957b0 100644 --- a/frontend/src/hooks/useSystemSetting.ts +++ b/frontend/src/hooks/useSystemSetting.ts @@ -26,7 +26,10 @@ export function useSystemSetting(key: string, defaultValue: T): [T, boolean, }; fetchSetting(); - }, [key, defaultValue]); + // Disable exhaustive-deps because we don't want to re-fetch when defaultValue changes + // (defaultValue is often an inline object/array literal which would cause infinite loops) + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [key]); return [settingValue, loading, error]; }