I'm feeling a bit puzzled about this one :S
I've written a code that allows my camera to rotate only halfway. I can move the camera along half of a circle using mousemove events, but I actually want it to be able to complete a full rotation :)
onRotateCamera(event){
if(this.cameraDragged){
let radius:number = Math.round(Math.sqrt(this.camera.position.x * this.camera.position.x + this.camera.position.z * this.camera.position.z)*1000)/1000;
let delta:number = (this.cameraDragged.clientX - event.clientX) / 1000;
let angle:number = Math.round(Math.asin(this.camera.position.z/radius)*1000)/1000;
angle += delta;
this.camera.position.x = Math.round(radius * Math.cos( angle )*1000)/1000;
this.camera.position.z = Math.round(radius * Math.sin( angle )*1000)/1000;
this.camera.lookAt(this.scene.position);
}
}
The camera movement stops when this.camera.position.z/radius is either -1 or 1 :S Could someone assist me with fixing this issue? Thank you! :)