Skip to content

Commit

Permalink
97 display 3d model of satellite on website (#452)
Browse files Browse the repository at this point in the history
* feat: rendering 3D model of satellite on website

* clean: unused code cleaned up

* clean: clean up

* fix: trying to fix dependancies
  • Loading branch information
Thibault authored and GitHub committed Jun 17, 2025
1 parent db7ab77 commit 0d0db8c
Show file tree
Hide file tree
Showing 14 changed files with 4,578 additions and 1,933 deletions.
Empty file added Build
Empty file.
Binary file modified backend/dbLocation.sqlite
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"multiple": false,
"required": false,
"allowedTypes": [
"images"
"images",
"files"
]
},
"projects": {
Expand Down
5,799 changes: 3,883 additions & 1,916 deletions frontend/package-lock.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
"@radix-ui/react-popover": "^1.0.7",
"@radix-ui/react-separator": "^1.0.3",
"@radix-ui/react-slot": "^1.0.2",
"@react-three/drei": "^9.56.14",
"@react-three/fiber": "^8.15.13",
"@strapi/blocks-react-renderer": "^1.0.0",
"@turf/boolean-point-in-polygon": "^6.5.0",
"@turf/helpers": "^6.5.0",
Expand Down Expand Up @@ -69,7 +71,7 @@
"shadcn-ui": "^0.8.0",
"tailwind-merge": "^2.2.0",
"tailwindcss-animate": "^1.0.7",
"three": "^0.161.0",
"three": "^0.150.1",
"topojson-client": "^3.1.0",
"vaul": "^0.9.0",
"zustand": "^4.5.2"
Expand Down
1 change: 1 addition & 0 deletions frontend/src/app/_homeComponents/SatDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ export default function SatDropdown() {
handleSelect(Number(num) as SatelliteNumber)
}
role="option"
aria-selected={satNum === selectedSatellite}
>
{satNumToEntry[satNum].name}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,6 @@ const OrbitDataGraph: React.FC<OrbitDataProps> = ({
return () => window.removeEventListener("resize", updateSize);
}, [handleChartScroll, months]);

console.log("orbitalData", orbitalData);

return (
<>
{orbitalData && (
Expand Down
24 changes: 15 additions & 9 deletions frontend/src/app/satellites/[satelliteSlug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { SatelliteNumber } from "@/lib/store";
import { graphql } from "@/lib/tada/graphql";
import { getClient } from "@/lib/ApolloClient";
import OrbitDataGraph from "./orbitDataGraph";
import Render3DMod from "../render3DMod";

export interface ProjectOrSatellite {
id: string;
Expand Down Expand Up @@ -64,12 +65,12 @@ export default async function SatelliteInfoPage({

// Get the satellite image
let satelliteImage = satAttributes?.satelliteImage?.data?.attributes?.url;

let imageURL = undefined;
if (STRAPI_URL && satelliteImage) {
imageURL = STRAPI_URL + satelliteImage;
}

console.log("satAttributes", satAttributes);
const is3DModel = (satelliteImage ?? "").endsWith(".glb");

return (
<>
Expand Down Expand Up @@ -119,16 +120,21 @@ export default async function SatelliteInfoPage({
) : null}
</div>
{/* Image container */}

<div className="w-full border-t-2 border-gray-600 xl:border-t-0">
<div className="flex h-full w-full items-center justify-center bg-black">
{imageURL ? (
<Image
src={imageURL}
alt={satAttributes?.name ?? ""}
width={1600} // Set according to the aspect ratio of the image
height={0}
className="p-2"
/>
is3DModel ? (
<Render3DMod url={imageURL} />
) : (
<Image
src={imageURL}
alt={satAttributes?.name ?? ""}
width={1600} // Set according to the aspect ratio of the image
height={0}
className="p-2"
/>
)
) : null}
</div>
</div>
Expand Down
24 changes: 24 additions & 0 deletions frontend/src/app/satellites/render3DMod.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"use client";
import React, { Suspense } from "react";
import { OrbitControls, useGLTF } from "@react-three/drei";
import { Canvas } from "@react-three/fiber";

function Model({ url }: { url: string }) {
const { scene } = useGLTF(url);

return <primitive object={scene} scale={0.002} />;
}
export default function Render3DMod({ url }: { url: string }) {
return (
<div className="flex h-[500px] w-full items-center justify-center bg-black">
<Canvas camera={{ position: [10, 10, 5] }}>
<ambientLight intensity={0.7} />
<directionalLight position={[10, 10, 10]} intensity={0.5} />
<Suspense fallback={null}>
<Model url={url} />
</Suspense>
<OrbitControls />
</Canvas>
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ export default function SatellitePassOverLocation() {
className="cursor-pointer p-2 text-white hover:bg-gray-700"
onClick={() => handleSelect(location)}
role="option"
aria-selected={location === selectedLocation}
>
{location.name} ({location.latitude + "° N"},{" "}
{location.longitude + "° E"})
Expand Down
Empty file added frontend@0.1.0
Empty file.
Empty file added next
Empty file.
Loading

0 comments on commit 0d0db8c

Please sign in to comment.