-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: typing errors, linting, converted to Float32Array
- Loading branch information
Showing
7 changed files
with
218 additions
and
234 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 |
---|---|---|
@@ -1,68 +1,105 @@ | ||
'use client' | ||
"use client"; | ||
|
||
import { useGLTF } from '@react-three/drei' | ||
import { useFrame } from '@react-three/fiber' | ||
import * as THREE from 'three' | ||
import { useMemo, useRef, useState } from 'react' | ||
import { Line, useCursor, MeshDistortMaterial } from '@react-three/drei' | ||
import { useRouter } from 'next/navigation' | ||
import { useGLTF } from "@react-three/drei"; | ||
import { useFrame } from "@react-three/fiber"; | ||
import * as THREE from "three"; | ||
import { useMemo, useRef, useState } from "react"; | ||
import { Line, useCursor, MeshDistortMaterial } from "@react-three/drei"; | ||
import { useRouter } from "next/navigation"; | ||
|
||
export const Blob = ({ route = '/', ...props }) => { | ||
const router = useRouter() | ||
const [hovered, hover] = useState(false) | ||
useCursor(hovered) | ||
return ( | ||
<mesh | ||
onClick={() => router.push(route)} | ||
onPointerOver={() => hover(true)} | ||
onPointerOut={() => hover(false)} | ||
{...props}> | ||
<sphereGeometry args={[1, 64, 64]} /> | ||
<MeshDistortMaterial roughness={0} color={hovered ? 'hotpink' : '#1fb2f5'} /> | ||
</mesh> | ||
) | ||
} | ||
export const Blob = ({ route = "/", ...props }) => { | ||
const router = useRouter(); | ||
const [hovered, hover] = useState(false); | ||
useCursor(hovered); | ||
return ( | ||
<mesh | ||
onClick={() => router.push(route)} | ||
onPointerOver={() => hover(true)} | ||
onPointerOut={() => hover(false)} | ||
{...props} | ||
> | ||
<sphereGeometry args={[1, 64, 64]} /> | ||
<MeshDistortMaterial | ||
roughness={0} | ||
color={hovered ? "hotpink" : "#1fb2f5"} | ||
/> | ||
</mesh> | ||
); | ||
}; | ||
|
||
export const Logo = ({ route = '/blob', ...props }) => { | ||
const mesh = useRef(null) | ||
const router = useRouter() | ||
export const Logo = ({ route = "/blob", ...props }) => { | ||
const mesh = useRef<any>(null); | ||
const router = useRouter(); | ||
|
||
const [hovered, hover] = useState(false) | ||
const points = useMemo(() => new THREE.EllipseCurve(0, 0, 3, 1.15, 0, 2 * Math.PI, false, 0).getPoints(100), []) | ||
const [hovered, hover] = useState(false); | ||
const points = useMemo( | ||
() => | ||
new THREE.EllipseCurve( | ||
0, | ||
0, | ||
3, | ||
1.15, | ||
0, | ||
2 * Math.PI, | ||
false, | ||
0, | ||
).getPoints(100), | ||
[], | ||
); | ||
|
||
useCursor(hovered) | ||
useFrame((state, delta) => { | ||
const t = state.clock.getElapsedTime() | ||
mesh.current.rotation.y = Math.sin(t) * (Math.PI / 8) | ||
mesh.current.rotation.x = Math.cos(t) * (Math.PI / 8) | ||
mesh.current.rotation.z -= delta / 4 | ||
}) | ||
useCursor(hovered); | ||
useFrame((state, delta) => { | ||
const t = state.clock.getElapsedTime(); | ||
|
||
return ( | ||
<group ref={mesh} {...props}> | ||
{/* @ts-ignore */} | ||
<Line worldUnits points={points} color='#1fb2f5' lineWidth={0.15} /> | ||
{/* @ts-ignore */} | ||
<Line worldUnits points={points} color='#1fb2f5' lineWidth={0.15} rotation={[0, 0, 1]} /> | ||
{/* @ts-ignore */} | ||
<Line worldUnits points={points} color='#1fb2f5' lineWidth={0.15} rotation={[0, 0, -1]} /> | ||
<mesh onClick={() => router.push(route)} onPointerOver={() => hover(true)} onPointerOut={() => hover(false)}> | ||
<sphereGeometry args={[0.55, 64, 64]} /> | ||
<meshPhysicalMaterial roughness={0} color={hovered ? 'hotpink' : '#1fb2f5'} /> | ||
</mesh> | ||
</group> | ||
) | ||
} | ||
mesh.current.rotation.y = Math.sin(t) * (Math.PI / 8); | ||
mesh.current.rotation.x = Math.cos(t) * (Math.PI / 8); | ||
mesh.current.rotation.z -= delta / 4; | ||
}); | ||
|
||
return ( | ||
<group ref={mesh} {...props}> | ||
{/* @ts-ignore */} | ||
<Line worldUnits points={points} color="#1fb2f5" lineWidth={0.15} /> | ||
{/* @ts-ignore */} | ||
<Line | ||
worldUnits | ||
points={points} | ||
color="#1fb2f5" | ||
lineWidth={0.15} | ||
rotation={[0, 0, 1]} | ||
/> | ||
{/* @ts-ignore */} | ||
<Line | ||
worldUnits | ||
points={points} | ||
color="#1fb2f5" | ||
lineWidth={0.15} | ||
rotation={[0, 0, -1]} | ||
/> | ||
<mesh | ||
onClick={() => router.push(route)} | ||
onPointerOver={() => hover(true)} | ||
onPointerOut={() => hover(false)} | ||
> | ||
<sphereGeometry args={[0.55, 64, 64]} /> | ||
<meshPhysicalMaterial | ||
roughness={0} | ||
color={hovered ? "hotpink" : "#1fb2f5"} | ||
/> | ||
</mesh> | ||
</group> | ||
); | ||
}; | ||
|
||
export function Duck(props) { | ||
const { scene } = useGLTF('/duck.glb') | ||
export function Duck(props: any) { | ||
const { scene } = useGLTF("/duck.glb"); | ||
|
||
useFrame((state, delta) => (scene.rotation.y += delta)) | ||
useFrame((state, delta) => (scene.rotation.y += delta)); | ||
|
||
return <primitive object={scene} {...props} /> | ||
return <primitive object={scene} {...props} />; | ||
} | ||
export function Dog(props) { | ||
const { scene } = useGLTF('/dog.glb') | ||
export function Dog(props: any) { | ||
const { scene } = useGLTF("/dog.glb"); | ||
|
||
return <primitive object={scene} {...props} /> | ||
return <primitive object={scene} {...props} />; | ||
} |
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,16 +1,16 @@ | ||
'use client' | ||
"use client"; | ||
|
||
import { Canvas } from '@react-three/fiber' | ||
import { Preload } from '@react-three/drei' | ||
import { r3f } from '@/helpers/global' | ||
import { Canvas } from "@react-three/fiber"; | ||
import { Preload } from "@react-three/drei"; | ||
import { r3f } from "@/helpers/global"; | ||
|
||
export default function Scene({ ...props }) { | ||
// Everything defined in here will persist between route changes, only children are swapped | ||
return ( | ||
<Canvas {...props}> | ||
{/* @ts-ignore */} | ||
<r3f.Out /> | ||
<Preload all /> | ||
</Canvas> | ||
) | ||
// Everything defined in here will persist between route changes, only children are swapped | ||
return ( | ||
<Canvas {...props}> | ||
{/* @ts-ignore */} | ||
<r3f.Out /> | ||
<Preload all /> | ||
</Canvas> | ||
); | ||
} |
Oops, something went wrong.