I’m looking to overlay a babylonjs scene on top of other HTML content, however when I match the size of the other content babylon loves(!#%&^&!@) resizing I believe the “FOV” is based on the height of the canvas… (yeah there is an option to change it to camera.fovMode = horz) however I don’t want that either… Would like ZERO perspective change so it should be independent of the size of the canvas…
Just like as if you made an HTML div width:100%; height:100%; overflow: auto;
Then resized the window, the content size of the div would stay the same, however the amount of ‘clipping’ area of the content became larger, without resizing the content of the div.
Resize the divider on that playground and you will see the scene skew. Resize the height of the window smaller and you’ll see the scene squish like a pancake. Both options are HORRIBLE Lets make the resize just clip the viewable area and not change the zoom, or dimensions of the objects in the scene… can someone show me how to do so?
I figure one bad solution is to make the canvas a larger size and then just put that in a scrollable div so the canvas never resizes so it doesn’t run into this problem, however then my best guess tells me babylon will have to render the entire scene even the offscreen content just to then clip it out of view… so I guess i need the canvas size to act like a left top aligned viewport to the scenes actual viewport
@Evgeni_Popov even closer! It’s almost perfect, now just gotta align top left, its prob something like orthTop += (starth - h) * ratio
orthBottom += (starth - h) * ratio
@Evgeni_Popov I touched up your fantastic work a tad and this seems to be the working solution… I’ll change this from onBeforeRenderObservable to the window resize event so it doesn’t have to keep calculating. Thanks a bunch!