chicagobob123 Posted February 7, 2018 Share Posted February 7, 2018 You know how google earth goes between a ORTHOGRAPHIC_CAMERA street view to the 3D view. Well I want to do the same thing. Changing modes makes the view crazy. So how do you go about it? Whats the ABC's Thanks Quote Link to comment Share on other sites More sharing options...
Guest Posted February 8, 2018 Share Posted February 8, 2018 We will need some kind of repro in the PG to help Quote Link to comment Share on other sites More sharing options...
chicagobob123 Posted February 21, 2018 Author Share Posted February 21, 2018 This was a interesting subject. The ORTHOGRAPHIC_CAMERA view the ortho rectangle is square but your browser window is not. Since most monitors are wider than taller I used the width as a variable and the height an absolute value. So when you change the window you need to alter the width and height of the ORTHOGRAPHIC_CAMERA based view. What you see in the code below is how I keep the view square while changing the browser window size. // the canvas/window resize event handler window.addEventListener('resize',function() { // NOTE may have to be done all the time for correct guiAspectRatio // we need to resize the current view. if(scene.activeCamera.mode == BABYLON.Camera.ORTHOGRAPHIC_CAMERA) { var prevheight=scene.activeCamera.orthoTop-scene.activeCamera.orthoBottom; var width=document.getElementById('renderCanvas').clientWidth; var height=document.getElementById('renderCanvas').clientHeight; guiAspectRatio=width/height; var zoom=prevheight/groundDimension; height =groundDimension * zoom; height/=2; scene.activeCamera.orthoLeft = (-height * guiAspectRatio); scene.activeCamera.orthoRight = (height * guiAspectRatio); scene.activeCamera.orthoBottom = -height; scene.activeCamera.orthoTop = height; } engine.resize(); GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.