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
+1
View File
@@ -12,6 +12,7 @@
"vite-plugin-restart": "^0.4.2" "vite-plugin-restart": "^0.4.2"
}, },
"dependencies": { "dependencies": {
"gsap": "~3.12.7",
"three": "^0.174.0" "three": "^0.174.0"
} }
} }
+8
View File
@@ -8,6 +8,9 @@ importers:
.: .:
dependencies: dependencies:
gsap:
specifier: ~3.12.7
version: 3.12.7
three: three:
specifier: ^0.174.0 specifier: ^0.174.0
version: 0.174.0 version: 0.174.0
@@ -352,6 +355,9 @@ packages:
engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}
os: [darwin] os: [darwin]
[email protected]:
resolution: {integrity: sha512-V4GsyVamhmKefvcAKaoy0h6si0xX7ogwBoBSs2CTJwt7luW0oZzC0LhdkyuKV8PJAXr7Yaj8pMjCKD4GJ+eEMg==}
[email protected]: [email protected]:
resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==} resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==}
engines: {node: '>=0.12.0'} engines: {node: '>=0.12.0'}
@@ -649,6 +655,8 @@ snapshots:
[email protected]: [email protected]:
optional: true optional: true
[email protected]: {}
[email protected]: {} [email protected]: {}
[email protected]: [email protected]:
+11 -7
View File
@@ -1,5 +1,6 @@
import './style.css' import './style.css'
import * as THREE from 'three' import * as THREE from 'three'
import gsap from 'gsap'
// Canvas // Canvas
const canvas = document.querySelector('canvas.webgl') const canvas = document.querySelector('canvas.webgl')
@@ -31,19 +32,22 @@ const renderer = new THREE.WebGLRenderer({
renderer.setSize(sizes.width, sizes.height) renderer.setSize(sizes.width, sizes.height)
// Clock // 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 // Animations
const tick = () => { const tick = () => {
// Clock // // Clock
const elapsedTime = clock.getElapsedTime() // const elapsedTime = clock.getElapsedTime()
// Update objects // // Update objects
mesh.rotation.y = elapsedTime * Math.PI * 2 // mesh.rotation.y = elapsedTime * Math.PI * 2
mesh.position.y = Math.sin(elapsedTime) // mesh.position.y = Math.sin(elapsedTime)
mesh.position.x = Math.cos(elapsedTime) // mesh.position.x = Math.cos(elapsedTime)
// camera.lookAt(mesh.position)
// Renderer // Renderer
renderer.render(scene, camera) renderer.render(scene, camera)