calculateTbRadius method
dynamic
calculateTbRadius(
- Camera camera
Calculate the trackball radius so that gizmo's diamater will be 2/3 of the minimum side of the camera frustum @param {Camera} camera @returns {Number} The trackball radius
Implementation
calculateTbRadius(Camera camera) {
var distance = camera.position.distanceTo(_gizmos.position);
if (camera is PerspectiveCamera) {
var halfFovV = MathUtils.deg2rad * camera.fov * 0.5; //vertical fov/2 in radians
var halfFovH = Math.atan((camera.aspect) * Math.tan(halfFovV)); //horizontal fov/2 in radians
return Math.tan(Math.min(halfFovV, halfFovH)) * distance * radiusFactor;
} else if (camera is OrthographicCamera) {
return Math.min(camera.top, camera.right) * radiusFactor;
}
}