Jump to content

Scale on resize


vsh91
 Share

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?

Link to comment
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

Link to comment
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!

Link to comment
Share on other sites

  • 6 months later...
  • 9 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...