outro anim + vid

This commit is contained in:
math-pixel
2026-06-03 01:45:43 +02:00
parent b1037d5107
commit 10b0d4fc16
6 changed files with 129 additions and 17 deletions
+55
View File
@@ -0,0 +1,55 @@
import { useEffect, useRef, useState } from "react";
const OUTRO_VIDEO_SRC = "/cinematics/outro.mp4";
/**
* Full-screen video overlay that plays once after the outro drone-shot
* cinematic ends. Triggered by the "outro-cinematic-complete" window event
* dispatched from GameCinematics.tsx.
*/
export function OutroVideoOverlay(): React.JSX.Element | null {
const [visible, setVisible] = useState(false);
const videoRef = useRef<HTMLVideoElement>(null);
useEffect(() => {
function handleCinematicComplete(): void {
setVisible(true);
}
window.addEventListener("outro-cinematic-complete", handleCinematicComplete);
return () => {
window.removeEventListener(
"outro-cinematic-complete",
handleCinematicComplete,
);
};
}, []);
useEffect(() => {
if (!visible) return;
void videoRef.current?.play();
}, [visible]);
if (!visible) return null;
return (
<div
style={{
position: "fixed",
inset: 0,
zIndex: 10000,
background: "#000",
display: "flex",
alignItems: "center",
justifyContent: "center",
}}
>
<video
ref={videoRef}
src={OUTRO_VIDEO_SRC}
style={{ width: "100%", height: "100%", objectFit: "cover" }}
playsInline
/>
</div>
);
}