I set position
and fov
of my perspective camera
manually in THREE.JS. It behaves as expected. However, once I try to interact with the scene
later on, through the TrackBall Controls
, it just displays a black screen, no errors.
Relevant code:
var bbox = new THREE.Box3().setFromObject(scene);
var center = bbox.getCenter();
var size = bbox.getSize();
// update some controls properties
controls.target.set(center.x, center.y, center.z);
// position the camera on the y axis
camera.position.set(center.x, center.y - size.y, center.z);
// fit FOV
var dist = size.y / 2;
var fov = 2 * Math.atan( size.z / ( 2 * dist ) ) * ( 180 / Math.PI );
camera.fov = fov;
camera.updateProjectionMatrix();
Which step am I missing in order to be able to then interact properly with the scene
Thanks
==== EDITS
Working fiddle based on accepted answer: Fiddle