rotateCamera method
void
rotateCamera()
Implementation
void rotateCamera() {
moveDirection.setValues(_moveCurr.x - _movePrev.x, _moveCurr.y - _movePrev.y, 0);
double angle = moveDirection.length;
if (angle != 0) {
_eye.setFrom(scope.object.position).sub(scope.target);
eyeDirection.setFrom(_eye).normalize();
objectUpDirection.setFrom(scope.object.up).normalize();
objectSidewaysDirection
.cross2(objectUpDirection, eyeDirection)
.normalize();
objectUpDirection.setLength(_moveCurr.y - _movePrev.y);
objectSidewaysDirection.setLength(_moveCurr.x - _movePrev.x);
moveDirection.setFrom(objectUpDirection.add(objectSidewaysDirection));
axis.cross2(moveDirection, _eye).normalize();
angle *= scope.rotateSpeed;
quaternion.setFromAxisAngle(axis, angle);
_eye.applyQuaternion(quaternion);
scope.object.up.applyQuaternion(quaternion);
_lastAxis.setFrom(axis);
_lastAngle = angle;
} else if (!scope.staticMoving && _lastAngle != 0) {
_lastAngle *= math.sqrt(1.0 - scope.dynamicDampingFactor);
_eye.setFrom(scope.object.position).sub(scope.target);
quaternion.setFromAxisAngle(_lastAxis, _lastAngle);
_eye.applyQuaternion(quaternion);
scope.object.up.applyQuaternion(quaternion);
}
_movePrev.setFrom(_moveCurr);
}