-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add moving background to FE's layout (#97)
- Loading branch information
1 parent
f971955
commit d8e0a26
Showing
9 changed files
with
1,011 additions
and
798 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export { Layout } from './layout'; | ||
export { CenteredSpinner, InlineSpinner } from './spinner'; | ||
export { Layout } from './layout'; | ||
export { Pagination } from './pagination'; | ||
export { QuestionBadges } from './question-badges'; | ||
export { WithSkybox } from './skybox'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
import { Outlet } from 'react-router-dom'; | ||
import { Navbar } from './navbar'; | ||
import { Footer } from './footer'; | ||
import { WithSkybox } from './skybox'; | ||
|
||
export function Layout(): JSX.Element { | ||
return ( | ||
<div className="bg-primary h-screen flex flex-col"> | ||
<WithSkybox> | ||
<Navbar /> | ||
<div className="container m-auto"> | ||
<div className="m-4"> | ||
<Outlet /> | ||
</div> | ||
</div> | ||
<Footer /> | ||
</div> | ||
</WithSkybox> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { useRef } from 'react'; | ||
import { Canvas, useFrame, useLoader } from '@react-three/fiber'; | ||
import * as THREE from 'three'; | ||
import skyboxImage from './skybox.jpg'; | ||
|
||
interface Props { | ||
children: React.ReactNode; | ||
} | ||
|
||
export function WithSkybox({ children }: Props): JSX.Element { | ||
return ( | ||
<div className="h-screen"> | ||
<Canvas | ||
className="absolute top-0 left-0 w-full h-full z-0" | ||
camera={{ position: [0, 0, 0.1], fov: 75, near: 0.1 }} | ||
> | ||
<Skybox /> | ||
</Canvas> | ||
<div className="absolute top-0 left-0 w-full h-full flex flex-col z-1">{children}</div> | ||
</div> | ||
); | ||
} | ||
|
||
function Skybox(): JSX.Element { | ||
const sphereRef = useRef<THREE.Mesh>(null); | ||
const texture = useLoader(THREE.TextureLoader, skyboxImage); | ||
|
||
useFrame(() => { | ||
if (sphereRef.current) { | ||
sphereRef.current.rotation.y += 0.00033; // Adjust the speed as needed | ||
} | ||
}); | ||
|
||
return ( | ||
<mesh ref={sphereRef}> | ||
<sphereGeometry args={[500, 60, 40]} /> | ||
<meshBasicMaterial map={texture} side={THREE.BackSide} /> | ||
</mesh> | ||
); | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters