Three.js calculate object distance required to fill screen

后端 未结 1 1385
隐瞒了意图╮
隐瞒了意图╮ 2021-01-25 22:54

I\'ve seen lots of questions on how to zoom the camera so an object fills the screen, but I\'m trying to move the object to fill the screen.

I\'ve been trying something

相关标签:
1条回答
  • 2021-01-25 23:33

    This works, not sure why..

        var vFOV = camera.fov * Math.PI / 180; 
        var ratio = 2 * Math.tan( vFOV / 2 );
        var screen = ratio * (window.innerWidth / window.innerHeight) ; 
        var size = getCompoundBoundingBox( object ).max.y;
        var dist = (size/screen) / 4; 
    
    0 讨论(0)
提交回复
热议问题