mirror of
https://github.com/exogen/t2-mapper.git
synced 2026-01-19 20:25:01 +00:00
32 lines
676 B
TypeScript
32 lines
676 B
TypeScript
import { loadMission } from "@/src/loaders";
|
|
import { useQuery } from "@tanstack/react-query";
|
|
import { renderObject } from "./renderObject";
|
|
|
|
function useMission(name: string) {
|
|
return useQuery({
|
|
queryKey: ["mission", name],
|
|
queryFn: () => loadMission(name),
|
|
});
|
|
}
|
|
|
|
const DEFAULT_LIGHT_ARGS = [
|
|
"rgba(209, 237, 255, 1)",
|
|
"rgba(186, 200, 181, 1)",
|
|
2,
|
|
] as const;
|
|
|
|
export function Mission({ name }: { name: string }) {
|
|
const { data: mission } = useMission(name);
|
|
|
|
if (!mission) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<hemisphereLight args={DEFAULT_LIGHT_ARGS} />
|
|
{mission.objects.map((object, i) => renderObject(object, i))}
|
|
</>
|
|
);
|
|
}
|