Recommended Posts

Hello everyone, this is my first time posting here and I am incredibly new to babylon
.I've scoured the net looking for a solution to this problem with none yet.

I'm using engine.resize() on window resize listener and this seems to work when I resize the window vertically.

However, there seems to be no horizontal scaling available and when resizing the window horizontally, the image gets cut off instead of shrinking.

Anybody have a solution?

Share this post


Link to post
Share on other sites

Hey thank you for replying. I think the best example of what I am trying to do is from a previous project I was working on with three.js.

http://people.ucsc.edu/~vshahbaz/boardGame/strat_game.html

Notice that resizing with window in either the width or height will not cut out any of the graphics, but instead resize everything within the scene.

Now in comparison, this is how my resize function currently works in Babylon, http://www.babylonjs-playground.com/#1GM4YQ

Resizing the width of the window will not re-scale the objects within it but instead keep them center. The code I'm running is posted below and seems pretty standard for all graphical applications.

window.addEventListener('resize', function(){
	engine.resize();
});

Do you think the solution I posted in the picture can be converted from THREE to BABYLON? Considering that the engine.resize() code is abstracted so much, I'm having a lot of difficulty finding the variables or functions I can use to manually change scaling of the scene.

Another question I have is if I should even care about horizontal scaling, considering that this form of resizing seems pretty standard.

I hope this clarifies what I'm trying to achieve, I'm still pretty new to all this and my terminology might be off.

And thank you to anyone that's taking the time to read through this. Any form of potentially time saving knowledge is much appreciated.

resize_threejs.png

Share this post


Link to post
Share on other sites

Hi guys.  I built a little home demo (no playground gui in the way)... and yep, I see this.  BabylonJS (by default) scales the scene per the height of the canvas, and ignores the width.  Mesh on upper and lower screen edges... is always fine.  Mesh on far right or left... goes off-screen easily (using window corner-drag). 

I have not yet tried adjusting camera horizontal field-of-view (fov), but maybe I will experiment with that today.

I think camera.fovMode = camera.FOVMODE_VERTICAL_FIXED;   ...will do just the opposite.  Early tests on that... show that the far left/right mesh stay in view, but no promises for far top/bottom.  vsh actually needs a FOVMODE_BOTH_FIXED (doesn't yet exist or maybe not possible).   hmm.  Still thinking.  Interesting challenge!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Recently Browsing   0 members

    No registered users viewing this page.