Created
April 7, 2022 07:07
-
-
Save akella/292a54ef7d2a4dbccea2b52e76f5b403 to your computer and use it in GitHub Desktop.
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
import gsap from "gsap"; | |
move(orientation, position) { | |
this.isAnimated = true; | |
let temp = new THREE.Vector3(); | |
let start = new THREE.Spherical().setFromVector3(this.camera.position); | |
let finish = new THREE.Spherical().setFromVector3(position); | |
gsap.to(this.controls.target, { | |
duration: 2, | |
x: orientation.x, | |
y: orientation.y, | |
z: orientation.z, | |
ease: "power2.inOut", | |
onUpdate: () => { | |
this.controls.update(); | |
this.isAnimated = false; | |
}, | |
}); | |
gsap.to(start, { | |
duration: 2, | |
radius: finish.radius, | |
phi: finish.phi, | |
theta: finish.theta, | |
ease: "power2.inOut", | |
onUpdate: () => { | |
this.camera.position.copy(temp.setFromSpherical(start)); | |
}, | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment