feat: integrate GSAP for object animations and update package dependencies

This commit is contained in:
sayudhalw
2026-08-23 20:43:55 +07:00
parent cebdb9e921
commit ced9c2b65a
3 changed files with 20 additions and 7 deletions
+11 -7
View File
@@ -1,5 +1,6 @@
import './style.css'
import * as THREE from 'three'
import gsap from 'gsap'
// Canvas
const canvas = document.querySelector('canvas.webgl')
@@ -31,19 +32,22 @@ const renderer = new THREE.WebGLRenderer({
renderer.setSize(sizes.width, sizes.height)
// Clock
const clock = new THREE.Clock()
// const clock = new THREE.Clock()
gsap.to(mesh.position, { x: 2, duration: 1, delay: 1})
gsap.to(mesh.position, { x: 0, duration: 1, delay: 2})
// Animations
const tick = () => {
// Clock
const elapsedTime = clock.getElapsedTime()
// // Clock
// const elapsedTime = clock.getElapsedTime()
// Update objects
mesh.rotation.y = elapsedTime * Math.PI * 2
mesh.position.y = Math.sin(elapsedTime)
mesh.position.x = Math.cos(elapsedTime)
// // Update objects
// mesh.rotation.y = elapsedTime * Math.PI * 2
// mesh.position.y = Math.sin(elapsedTime)
// mesh.position.x = Math.cos(elapsedTime)
// camera.lookAt(mesh.position)
// Renderer
renderer.render(scene, camera)