Jump to content

Blender Orthographic Export


david028
 Share

Recommended Posts

@david028

The simplest method I've found is to define your own orthographic camera in BJS. Below is code I just striped from a recently delivered project:

        var camera = new BABYLON.FreeCamera("camera1", new BABYLON.Vector3(0, 100, 0), scene);
        self.camera = camera;

        camera.setTarget(BABYLON.Vector3.Zero());
        //camera.attachControl(canvas, false);    //Not needed unless debuging in camera or for some other reason.            
        camera.mode = BABYLON.Camera.ORTHOGRAPHIC_CAMERA;

        camera.orthoTop = 45;
        camera.orthoBottom = -45;
        camera.orthoLeft = -90;
        camera.orthoRight = 90;

Just remember to define the size of the viewport relative to your camera's position from the target (I highly recommend setting a target,) and/or it's position in space relative to the geometry you're rendering. This allows not only camera control, but any size in BJS world scale units that you wish your orhto view to be.

DB

 

Link to comment
Share on other sites

From a Blender perspective, no the Blender camera type is not translated into BJS camera mode.  Does not look loo big, but also you could just add:

scene.getActiveCamera().mode = BABYLON.Camera.ORTHOGRAPHIC_CAMERA

If camera mode is a valid property that can be put into a .babylon file, I could add it, but not before the end of the month.  As far as some of the other things @dbawel, is setting, I see no Blender properties to use for top, bottom, left, or right.  BJS Target is only translated from Blender track to constraint when the camera is arc rotate or follow.

In any case, I will not be changing 4.6.1.  Just left that around, but not updating.

Link to comment
Share on other sites

The orthographic camera in Blender lets you set a value for orthographic scale which it describes as similar to zoom. The higher the number the more of the scene is in view (zoomed out).

How would I go about getting the camera in BabylonJS to match what I have in Blender?

I am not sure where the values of 45 and 90 come from in @dbawels answer? Should these be set to the canvas width & height or the camera width & height from Blender?

Link to comment
Share on other sites

 @david028 -

As long as you set your camera at a far enough distance from your target mesh(s), the entire area within your canvas will be used to display the area defined by yur top, bottom, left, and right. So if you simply wanted to display a plane which has the dimensions of 180 X 90 which was necessary for my scene, I used valuesfrom -90 to 90 in X (180 world units), and values from -45 to 45 in Y (90 world units). This resulted in an ortographic viewport which fit my planar mesh perfectly. If you set up a playground scene, I and others can help you solve any additional parameters you might need to replicate an ortho view seen in 3D apps outside of the WebGL environment. Simply start with the settings above in a PG scene and test - and we can work from there quickly to accomplish whatever you might require. For me, the PG helped me to quickly understand all I needed to know about the ortho camera in BJS. I wish I could find the PG scene I built, but I cannot. However, if you are truly stuck on an aspect of this, then I can builtd you a PG scene. But it's always best to build yourself as you'll answer your own questions quickly.

DB

Link to comment
Share on other sites

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...