Created
May 29, 2014 15:20
-
-
Save geranyl/b14f6ec38e0d2f7f9799 to your computer and use it in GitHub Desktop.
Three.js camera stuff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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