-
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.
Merge branch 'main' of github.com:mariussd/sandbox
- Loading branch information
Showing
8 changed files
with
113 additions
and
82 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
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,56 @@ | ||
import { Canvas, type MeshProps, useFrame } from "@react-three/fiber"; | ||
import { Float, ScrollControls, useScroll, Scroll } from "@react-three/drei"; | ||
import { useRef } from "react"; | ||
import { type LinksFunction } from "@remix-run/node"; | ||
import styles from "~/routes/three.scroll/styles/styles.css"; | ||
|
||
export const links: LinksFunction = () => [{ rel: "stylesheet", href: styles }]; | ||
|
||
const ScrollTest = () => { | ||
return ( | ||
<Canvas | ||
camera={{ | ||
fov: 45, | ||
near: 0.1, | ||
far: 200, | ||
position: [-6, 3, 6], | ||
}} | ||
> | ||
<directionalLight position={[1, 3, 2]} intensity={1.5} /> | ||
<ambientLight intensity={0.5} /> | ||
<ScrollControls damping={0.01} pages={5}> | ||
<Cube /> | ||
{/* <Scroll> | ||
<Cube></Cube> | ||
</Scroll>*/} | ||
</ScrollControls> | ||
</Canvas> | ||
); | ||
}; | ||
|
||
const Cube = () => { | ||
const ref = useRef<MeshProps>(); | ||
const scroll = useScroll(); | ||
|
||
const oldOffset = useRef(0); | ||
|
||
useFrame((state, delta) => { | ||
const scrollDirection = oldOffset.current - scroll.offset > 0 ? 1 : -1; | ||
|
||
ref.current.rotation.y += scroll.delta * 1.3 * scrollDirection; | ||
ref.current.rotation.z -= scroll.delta * 0.2 * -scrollDirection; | ||
|
||
oldOffset.current = scroll.offset; | ||
}); | ||
|
||
return ( | ||
<Float> | ||
<mesh ref={ref} scale={1.5}> | ||
<boxGeometry /> | ||
<meshStandardMaterial color="mediumpurple" /> | ||
</mesh> | ||
</Float> | ||
); | ||
}; | ||
|
||
export default ScrollTest; |
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,3 @@ | ||
body { | ||
background: #faf0e5; | ||
} |
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,17 @@ | ||
import { Canvas } from "@react-three/fiber"; | ||
import Experience from "./Experience.jsx"; | ||
|
||
const ThreeIndex = () => ( | ||
<Canvas | ||
camera={{ | ||
fov: 45, | ||
near: 0.1, | ||
far: 200, | ||
position: [-4, 3, 6], | ||
}} | ||
> | ||
<Experience /> | ||
</Canvas> | ||
); | ||
|
||
export default ThreeIndex; |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,4 @@ | |
overflow: hidden; | ||
border-radius: 30px; | ||
user-select: none; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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