I have a three.js scene with a cuboid and an OrthographicCamera:
var scene = new THREE.Scene();
var aspect = canvas.width/canvas.height;
var size = 1000;
var camera = new THREE.OrthographicCamera(size * aspect / - 2, size * aspect / 2, size / 2, size / - 2, 1, 2000);
camera.position.x = -400;
camera.position.y = 200;
camera.position.z = 400;
camera.lookAt(new THREE.Vector3(0, 0, 0));
var box = new THREE.Mesh(
new THREE.BoxGeometry(someWidth, someHeight, someDepth),
new THREE.MeshLambertMaterial({ color: 0xffffff })
);
scene.add(box);
The size and proportions of the cuboid vary. How do I derive the camera properties from the cuboid, so that it fits neatly in the center of the camera view (with a small margin on all sides)?