Nubsy Posted August 21, 2014 Share Posted August 21, 2014 Hello all! I'm trying, for fun, to recreate the 2D/3D environment from the game Fez. My roommate was playing it, and I thought it was awesome. My problem is that I don't quite understand what's going on with the ortho camera. So I've created a free camera, and set the mode to BABYLON.Camera.ORTHOGRAPHIC_CAMERA:camera = new BABYLON.FreeCamera("FreeCamera", new BABYLON.Vector3(0, 0, 0), scene);camera.mode = BABYLON.Camera.ORTHOGRAPHIC_CAMERA;And the camera view is flat on, like it should be. Except the cubes (drawn from/at the origin) I've made are really far away. The camera doesn't need to zoom at all, but it does need to be closer. I'm finding that there's not a whole lot of information about the ortho mode, other than there is an ortho mode. I guess I'm just looking for some basic info or examples using the orthographic mode. Thanks! Quote Link to comment Share on other sites More sharing options...
Temechon Posted August 22, 2014 Share Posted August 22, 2014 Hi there ! For an orthographic camera, you need to specify these values :camera.orthoTop;camera.orthoBottom;camera.orthoLeft;camera.orthoRight;Here is an example : http://www.babylonjs.com/playground/#JLPAE These values are the coordinates of a square representing the space displayed in your camera. If you want to zoom in, just reduce these values. Cheers, Nubsy and jonathanlurie 2 Quote Link to comment Share on other sites More sharing options...
Nubsy Posted August 22, 2014 Author Share Posted August 22, 2014 I do believe that is exactly what I wanted! Like I figured, I just didn't understand what those were actually doing. Thanks, man! Temechon 1 Quote Link to comment Share on other sites More sharing options...
guzuomuse Posted May 4, 2018 Share Posted May 4, 2018 On 8/22/2014 at 7:51 PM, Temechon said: For an orthographic camera, you need to specify these values @Temechon,can u tell me how to specify these values? i really need these. thank you!!! Quote Link to comment Share on other sites More sharing options...
Kesshi Posted May 4, 2018 Share Posted May 4, 2018 9 hours ago, guzuomuse said: @Temechon,can u tell me how to specify these values? i really need these. thank you!!! If you have a sphere with a diameter of 10 units, you have to use an ortho value of 5 to make it exactly fit to the view. camera.orthoTop = 5; //5 units to the top camera.orthoBottom = -5; //5 units to the bottom camera.orthoLeft = -5; //5 units to the left camera.orthoRight = 5; //5 units to the right Quote Link to comment Share on other sites More sharing options...
guzuomuse Posted May 7, 2018 Share Posted May 7, 2018 @Kesshi,you guide me on the right way! thanks! Quote Link to comment Share on other sites More sharing options...
Kerihobo Posted April 19, 2020 Share Posted April 19, 2020 (edited) On 5/5/2018 at 1:14 AM, Kesshi said: If you have a sphere with a diameter of 10 units, you have to use an ortho value of 5 to make it exactly fit to the view. camera.orthoTop = 5; //5 units to the top camera.orthoBottom = -5; //5 units to the bottom camera.orthoLeft = -5; //5 units to the left camera.orthoRight = 5; //5 units to the right I went ahead and did this anyway as in my 4:3 aspect-ratio game, attempting to remake Mario in BabylonJS, but is it correct that I should scale my horizontal & vertical properties based on the same aspect ratio? like instead of 8:8, I use 8:6 like this? var orthographicScaleX = 8; var orthographicScaleY = 6; this.camera.orthoTop = orthographicScaleY; this.camera.orthoBottom = -orthographicScaleY; this.camera.orthoLeft = -orthographicScaleX; this.camera.orthoRight = orthographicScaleX; Edited April 19, 2020 by Kerihobo code sample was making my question unclear. 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.