Skip to content

Instantly share code, notes, and snippets.

@akella
Created April 7, 2022 07:07
Show Gist options
  • Save akella/292a54ef7d2a4dbccea2b52e76f5b403 to your computer and use it in GitHub Desktop.
Save akella/292a54ef7d2a4dbccea2b52e76f5b403 to your computer and use it in GitHub Desktop.
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