Three.js zoom to fit width of objects (ignoring height)

后端 未结 1 704
情歌与酒
情歌与酒 2020-12-06 18:31

I have a set of block objects, and I\'d like to set the perspective camera so that their entire width is fully visible (the height will be too big - that\'s OK, we\'re going

相关标签:
1条回答
  • 2020-12-06 19:09

    I was able to simplify this problem a lot, in my case...

    Since I knew the overall size of the objects, I was able to simply come up with a suitable distance through changing the camera's z position a few times and seeing what looked best.

    My real problem was that the same z position gave different widths, relative to the screen width, on different sized screens - due to the different aspect ratios.

    So all I did was divide my distance value by camera.aspect. Now the blocks take up the same proportion of the screen's width on all screen sizes :-)

    0 讨论(0)
提交回复
热议问题