Sign in to follow this  
Nubsy

Ortho camera

Recommended Posts

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! 

Share this post


Link to post
Share on other sites

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, 

Share this post


Link to post
Share on other sites
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

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.