Skip to content

Instantly share code, notes, and snippets.

View Kreshnik's full-sized avatar

Kreshnik Hasanaj Kreshnik

View GitHub Profile
@Kreshnik
Kreshnik / AnimateCamera.jsx
Created March 14, 2024 19:30 — forked from ektogamat/AnimateCamera.jsx
useGSAP with React Three Fiber Camera Animation
import { useThree } from '@react-three/fiber'
import { gsap } from 'gsap'
import { useGSAP } from '@gsap/react'
export default function AnimateCamera() {
// Accessing camera from Three.js
const { camera } = useThree()
useGSAP(() => { // The new hook will take care of context and life cicle.
gsap.fromTo( // Creates the animation