Skip to content

Commit 890654a

Browse files
committed
tamen
1 parent 97f0dfc commit 890654a

2 files changed

Lines changed: 65 additions & 4 deletions

File tree

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
"use client";
2+
3+
import { useCallback, useState } from "react";
4+
5+
import { cn } from "@/lib/utils";
6+
7+
const shellClass =
8+
"relative mx-auto w-full max-w-[320px] md:max-w-[480px] lg:max-w-[640px] md:w-[480px] lg:w-[640px] h-[240px] md:h-[360px] lg:h-[480px] overflow-hidden rounded-lg border-2 md:border-4 border-white bg-black transition-colors duration-300 hover:border-[#174BE5]";
9+
10+
export function ModelViewerFrame({
11+
iframeSrc,
12+
posterSrc,
13+
title,
14+
}: {
15+
iframeSrc: string;
16+
posterSrc: string;
17+
title: string;
18+
}) {
19+
const [iframeLoaded, setIframeLoaded] = useState(false);
20+
const [posterFailed, setPosterFailed] = useState(false);
21+
22+
const handleIframeLoad = useCallback(() => {
23+
setIframeLoaded(true);
24+
}, []);
25+
26+
return (
27+
<div className={shellClass}>
28+
{!iframeLoaded && !posterFailed && (
29+
<img
30+
src={posterSrc}
31+
alt=""
32+
decoding="async"
33+
onError={() => setPosterFailed(true)}
34+
className="pointer-events-none absolute inset-0 z-10 h-full w-full object-cover"
35+
/>
36+
)}
37+
{!iframeLoaded && posterFailed && (
38+
<div
39+
className="pointer-events-none absolute inset-0 z-10 flex items-center justify-center bg-zinc-950 text-[11px] sm:text-xs text-white/55"
40+
aria-live="polite"
41+
>
42+
Loading 3D viewer…
43+
</div>
44+
)}
45+
<iframe
46+
src={iframeSrc}
47+
title={title}
48+
onLoad={handleIframeLoad}
49+
className={cn(
50+
"absolute inset-0 h-full w-full opacity-0 transition-opacity duration-500",
51+
iframeLoaded && "opacity-100",
52+
)}
53+
/>
54+
</div>
55+
);
56+
}

app/(default)/(project)/TAMEn/page.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import {
3434
GeneralizationUnseenChart,
3535
RobustnessDisturbanceChart,
3636
} from "./chart/generalization-unseen";
37+
import { ModelViewerFrame } from "./model-viewer-frame";
3738

3839
const exo2 = Exo_2({
3940
subsets: ["latin"],
@@ -65,6 +66,10 @@ const policy_rollouts: { id: string; title: string; color: string }[] = [
6566
},
6667
];
6768

69+
/** Preview shown until the 3D iframe fires `load`. */
70+
const TAMEN_MODEL_VIEWER_POSTER =
71+
"https://ik.imagekit.io/7rgtwup0y/3dmodel.jpg";
72+
6873
const pageNavItems: { text: string; id: string }[] = [
6974
{ text: "Highlights", id: "highlights" },
7075
{ text: "Data Collection Modes", id: "data-collection-modes" },
@@ -565,11 +570,11 @@ export default function Home() {
565570
</b>{" "}
566571
now!
567572
</p>
568-
<iframe
569-
src="https://opendrivelab.github.io/TAMEn/3d_model/tamen_model.html"
573+
<ModelViewerFrame
574+
iframeSrc="https://opendrivelab.github.io/TAMEn/3d_model/tamen_model.html"
575+
posterSrc={TAMEN_MODEL_VIEWER_POSTER}
570576
title="TAMEn 3D model viewer"
571-
className="w-full max-w-[320px] md:max-w-[480px] lg:max-w-[640px] md:w-[480px] lg:w-[640px] h-[240px] md:h-[360px] lg:h-[480px] border-2 md:border-4 border-white hover:border-[#174BE5] transition-colors duration-300 rounded-lg mx-auto"
572-
></iframe>
577+
/>
573578
</div>
574579
</div>
575580
</div>

0 commit comments

Comments
 (0)