Jump to content

How to control an ORTHOGRAPHIC_CAMERA


chicagobob123
 Share

Recommended Posts

I set the mode to ORTHOGRAPHIC_CAMERA and wanted to move it around. This I thought would be easy just 

set the rotate.y to spin it or position.y to zoom in and out but I was wrong.

I rotated the camera 90 degrees in the X axis to have a top down view. And what I see rendered doesnt make any sense. The sphere is oblong.

You rotate the image (use shift Left or right arrow on the keyboard) and it keeps that the oblong view facing up. 
Another question is why is the rotational center so far off? Where is the axis? Here is some code to look at. 

 

https://www.babylonjs-playground.com/#21YCLG#17

 

To move around use keyboard Left arrow right arrow Up arrow down Arrow movement and shift left arrow and right arrow to rotate.

Mouse wheel for zoom in and out. 

Link to comment
Share on other sites

I have been working hard on this problem and its WAY harder than you think. The camera has quirks that I can not fix. There is no concept of elevation for zoom. 

Instead you have to make up your own elevation track your own zoom. 

Anyway.. 

These numbers are supposed to have a black background to them created by a dynamic texture. It works correctly when you use a regular camera. 

When I get a chance I will put it onto Playground. I have another issue as well so far with a particle thats black viewing from the ORTHOMODE

 

image.png.d6f5323f5f88dcdbca209ae0f4fb8948.png

 

Link to comment
Share on other sites

for (var i = 0; i < mscene.meshes.length; i++){
if (mscene.meshes.isVisible == false) continue;
var bounds = mscene.meshes.getBoundingInfo();

That's 99% your culprit, you get your min/max  x,y,z values based on different meshes in your scene. Or in other words: you are distorting your camera by using something like:

 

Left = -5

Right = +10

Top  = +6

Bottom = -9

 

You want to use instead:

scale = 5

Left  = - scale

Right = scale

Top = scale

Bottom = -scale

 

This will capture your "world" from -5 to +5 around the camera's position and "squeeze" it into it's output. If you use however different scales for x and y you will distort your output.

 

Edit: Here is a quick "fix" - Lines 171-173.

https://www.babylonjs-playground.com/#21YCLG#41

Link to comment
Share on other sites

  • 3 weeks later...

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