title: How to Fit Camera to Object
body: <p>Using three.js I have the following.</p>
  
  <ul>
  <li>A scene containing several Object3D instances</li>
  <li>Several predefined camera Vector3 positions</li>
  <li>A dynamic width/height of the canvas if the screen resizes</li>
  <li>A user can select an object (from above)</li>
  <li>A user can select a camera position (from above)</li>
  </ul>
  
  <p>Given an object being viewed and the camera position they have chosen how do I compute the final camera position to "best fit" the object on screen?</p>
  
  <p>If the camera positions are used "as is" on some screens the objects bleed over the edge of my viewport whilst others they appear smaller. I believe it is possible to fit the object to the camera frustum but haven't been able to find anything suitable.</p>