Skip to content

Instantly share code, notes, and snippets.

@geranyl
Created May 29, 2014 15:20
Show Gist options
  • Save geranyl/b14f6ec38e0d2f7f9799 to your computer and use it in GitHub Desktop.
Save geranyl/b14f6ec38e0d2f7f9799 to your computer and use it in GitHub Desktop.
Three.js camera stuff
var $curVideo = $('#cur-video');
var curVidWidth = parseInt($curVideo.attr('data-width'),10);
var curVidHeight = parseInt($curVideo.attr('data-height'),10);
var aspect = curVidWidth / curVidHeight;
camera = new THREE.PerspectiveCamera(45, aspect, 0.1, 10000);
var vFOV = camera.fov * Math.PI / 180;
var hFOV = 2 * Math.atan( Math.tan( vFOV / 2 ) * aspect );
var newZ = curVidHeight / (2* Math.tan(vFOV/2));
camera.position.z = newZ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment