-
-
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.
- Loading branch information
Showing
10 changed files
with
503 additions
and
653 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
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
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 @@ | ||
'use client' | ||
|
||
import { Sphere } from '@react-three/drei' | ||
import { useFrame } from '@react-three/fiber' | ||
import React, { useRef } from 'react' | ||
import { pointsInner, pointsOuter } from '../utils' | ||
|
||
function Point({ position, color }) { | ||
return ( | ||
<Sphere position={position} args={[0.1, 10, 10]}> | ||
<meshStandardMaterial | ||
emissive={color} | ||
emissiveIntensity={0.5} | ||
roughness={0.5} | ||
color={color} | ||
/> | ||
</Sphere> | ||
) | ||
} | ||
|
||
export default function PointCircle() { | ||
const ref = useRef<any>(null) | ||
|
||
useFrame(({ clock }) => { | ||
if (ref.current?.rotation) { | ||
ref.current.rotation.z = clock.getElapsedTime() * 0.05 | ||
} | ||
}) | ||
|
||
return ( | ||
<group ref={ref}> | ||
{pointsInner.map(point => ( | ||
<Point key={point.idx} position={point.position} color={point.color} /> | ||
))} | ||
{pointsOuter.map(point => ( | ||
<Point key={point.idx} position={point.position} color={point.color} /> | ||
))} | ||
</group> | ||
) | ||
} |
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,76 @@ | ||
'use client' | ||
|
||
import { Canvas } from '@react-three/offscreen' | ||
import { motion } from 'framer-motion' | ||
import React, { lazy, useEffect, useState } from 'react' | ||
|
||
const PointCircle = lazy(() => import('./PointCircle')) | ||
|
||
// const worker = new Worker(new URL('./worker.tsx', import.meta.url), { | ||
// type: 'module', | ||
// }) | ||
|
||
// worker.onmessage = (event) => { | ||
// console.error('🍏 Message received from worker: ', event.data) | ||
// } | ||
|
||
// worker.onerror = (event) => { | ||
// if (event instanceof Event) { | ||
// console.error('🍎 Error message received from worker: ', event) | ||
// return event | ||
// } | ||
|
||
// console.error('🍎 Unexpected error: ', event) | ||
// throw event | ||
// } | ||
|
||
export default function Ring() { | ||
const [worker, setWorker] = useState<Worker>() | ||
|
||
useEffect(() => { | ||
const plusWorker = new Worker(new URL('./worker.tsx', import.meta.url), { | ||
type: 'module', | ||
}) | ||
if (typeof Worker !== 'undefined' && plusWorker) { | ||
setWorker(plusWorker) | ||
} | ||
|
||
plusWorker.onmessage = (event) => { | ||
console.error('🍏 Message received from worker: ', event.data) | ||
} | ||
|
||
plusWorker.onerror = (event) => { | ||
if (event instanceof Event) { | ||
console.error('🍎 Error message received from worker: ', event) | ||
return event | ||
} | ||
|
||
console.error('🍎 Unexpected error: ', event) | ||
throw event | ||
} | ||
|
||
return () => { | ||
plusWorker.terminate() | ||
} | ||
}, []) | ||
|
||
return ( | ||
<motion.div | ||
initial={{ opacity: 0 }} | ||
animate={{ opacity: 1 }} | ||
transition={{ duration: 3, ease: 'easeInOut' }} | ||
className="!absolute inset-0" | ||
> | ||
<Canvas | ||
worker={worker!} | ||
shadows | ||
fallback={<PointCircle />} | ||
camera={{ | ||
position: [10, -7.5, -5], | ||
}} | ||
style={{ height: '100vh' }} | ||
className="!absolute inset-0 bg-white dark:bg-slate-900" | ||
/> | ||
</motion.div> | ||
) | ||
} |
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,6 @@ | ||
'use client' | ||
|
||
import { render } from '@react-three/offscreen' | ||
import PointCircle from './PointCircle' | ||
|
||
render(<PointCircle />) |
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
Oops, something went wrong.