重新定义天体大小的展现逻辑
parent
14fb922cd2
commit
5b8cc1cf0c
|
|
@ -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())
|
||||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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<string | null | undefined>(undefined);
|
||||
const [loadError, setLoadError] = useState<boolean>(false);
|
||||
const [resourceScale, setResourceScale] = useState<number>(1.0);
|
||||
const [typeConfigs] = useSystemSetting('celestial_type_configs', null);
|
||||
|
||||
// Fetch model from backend API
|
||||
useEffect(() => {
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
/>
|
||||
))}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,10 @@ export function useSystemSetting<T>(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];
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue