Created
April 7, 2022 10:43
-
-
Save akella/dbbe8d7f8a0165f3cc4a688a9f8f34ae 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
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); | |
if(Math.abs(start.theta-finish.theta)>Math.PI){ | |
if( Math.abs(start.theta-finish.theta - 2*Math.PI) <Math.abs(start.theta-finish.theta + 2*Math.PI)){ | |
finish.theta +=2*Math.PI | |
} else{ | |
finish.theta -=2*Math.PI | |
} | |
} | |
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