Forum

Change camera viewport from height to width

22 June 2016 12:24 #10177
Hello everyone!

In our project we have made the canvas responsive and 16by9, but now we are considering to change to container fit, specially for portrait mobile.
I mean, for instance, instead of being 16:9 the canvas will look something crazy like 5:10.
But trying to do this makes the camera fit for height, and as it is wider than the allowed with, the 3D object gets cut.
We are thinking in making the camera fit the width, but also needing the extra taller canvas, so when the object rotates it doesn't get cut at the bottom or top.
Attached a couple of screenshots of what I'm trying to say.
Ideally the object looks "tiny" as in "cut.jpg" but can render at bottom as in "extrawidth.jpg".
Is there any easy way to make this happen??

Thanks in advance!

– Raul, Made in Me developer

23 June 2016 10:39 #10194
Attached a couple of screenshots of what I'm trying to say.
Ideally the object looks "tiny" as in "cut.jpg" but can render at bottom as in "extrawidth.jpg".
Is there any easy way to make this happen??
Hello!

For now all the supported camera types always fit height. With zooming allowed objects may get cut.
You can somehow reduce such situations playing with camera limits dynamically.

I am sorry but we don't fully understand your question.
Could you please provide us a little bit more details of your task
Blend4Web Team - developer
23 June 2016 10:57 #10195
Hello Konstantin,

Thank you for your response.
That's exactly what I thought, that the camera fits height.
What I'm trying to figure out is some way to render the shoe fitting the screen's width, but when rotating it pointing downwards it gets cut (like when zooming in), even though I still have extra screen height.

I can imagine some way to tell the camera viewport to be some rectangle taller than wider, taking profit of the screen size in portrait mode.
Of course this would require some kind of calculus to match the camera viewport to the current canvas dimensions .
For instance, an iPhone 6 in portrait mode could have, in theory, a canvas 375px width, ~600px height, but for our current 16by9 canvas it adjusts to 375px width, 0.5625*375 ~= 210px height.
But if I make the canvas full width and full height, the shoe renders outside the screen's width, instead of fitting inside, which is not desirable.
And if I maintain the 16by9 resolution, it renders properly from side to side, but it gets cut when pointing downwards.

Probably there is no easy solution to this, but worth asking you guys that have more experience in these matters.

Thanks again!
24 June 2016 18:10 #10215
Hello.

I hope the "m_camera.set_fov" method will be helpful for you. You should calculate the vertical camera angle using the canvas dimensions.

var cam = m_cam.get_active_camera();
m_camera.set_fov(cam, new_vert_angle);
Blend4Web developer
27 June 2016 11:39 #10234
Well, I suppose it should work.
I will try and notify you later.

Thanks!
 
Please register or log in to leave a reply.