I am using controllers to rotate an object around a center. I am using the following method to obtain the rotation angle of controllers and then use the angle to rotate the actual object. since I am using x and y of the mouse, the method is not smooth and the mouse pointer need to be moved along x, and y for theta. Is there another way to catch the angle shift around a center? Thank you.
function pointerLocation() {
var pointer = event.changedTouches ? event.changedTouches[ 0 ] : event;
var rect = renderer.domElement.getBoundingClientRect();
var x = ( pointer.clientX - rect.left ) / rect.width;
var y = ( pointer.clientY - rect.top ) / rect.height;
var pointerVector = new THREE.Vector3();
pointerVector.set( ( x * 2 ) - 1, - ( y * 2 ) + 1 ,0.5);
return pointerVector;
}
function onPointerDown(event) {
mouseBegin = pointerLocation();
}
function onPointerMove(event) {
mouseEnd = pointerLocation();
deltaTheta = (Math.atan2(mouseEnd.y,mouseEnd.x) - Math.atan2(mouseBegin.y,mouseBegin.x);
}