diff --git a/src/components/Grid/index.jsx b/src/components/Grid/index.jsx index 9d137d6..711d026 100644 --- a/src/components/Grid/index.jsx +++ b/src/components/Grid/index.jsx @@ -1,6 +1,8 @@ import { useThree } from '@react-three/fiber' import { useAspect } from '@react-three/drei' import { Flex, Box } from '@react-three/flex' +import { animated, useSprings } from '@react-spring/three' +import { useRef } from 'react' import { Text } from '../Text' export function Grid({ @@ -13,11 +15,23 @@ export function Grid({ }) { const { size } = useThree() const [vpWidth, vpHeight] = useAspect(size.width, size.height) + const matRef = useRef() + const [springs, api] = useSprings(rowNumber * columnNumber, () => ({ + scale: [1, 1, 1], + opacity: 0.2, + loop: true, + config: { mass: 5, tension: 350, friction: 40 } + })) + + // useFrame(({ clock }) => { + // // sphereRef.current.rotation.y += -0.01; + // matRef.current.emissiveIntensity = Math.abs(Math.sin(clock.elapsedTime * 0.5)) + // }) return ( @@ -27,25 +41,47 @@ export function Grid({ flexWrap='wrap' width={columnNumber * boxWidth + columnNumber * (2 * boxMargin)} flexGrow={1}> - {[...Array(rowNumber * columnNumber).keys()].map((k, i) => ( - - - - - - - {text[i].content} - - - + {springs.map(({ scale, opacity }, i) => ( + + api.start((index) => { + if (index === i) { + return { scale: [1.1, 1.1, 1], opacity: 0.5 } + } + return { scale: [1, 1, 1], opacity: 0.2 } + }) + } + onPointerLeave={() => api.start(() => ({ scale: [1, 1, 1], opacity: 0.2 }))}> + + + + + {/* */} + {/* */} + + + {text[i].content} + + + + ))}