Jump to content

Camera Bug Setting Position


ua4192
 Share

Recommended Posts

Hi again.

I am not sure if this is the correct section for reporting this problem, sorry if not.

:)

I have prepared this PG: http://www.babylonjs-playground.com/#2JBSNA#20

What I was trying to do was to set the basic views ( 6 face views from the Bounding Box of the selected mesh in the scene )

The idea was quite simple, but there are 2 views that are failing and the problem is very strange. My feeling is that there is something wrong in the camera.setPosition  function with the provided numbers. Have a look into the function set_camera() and you will see.

Just try to change the lines 73 and 74 to switch between different camera positions (camera_p1, camera_p2, ... , camera_p6)

camera_p1: ok

camera_p2: ok

camera_p3: ko (problem in setting camera position, X and Z are not recognized as numbers)

camera_p4: ko (problem in setting camera position, X and Z are not recognized as numbers)

camera_p5: ok

camera_p6: ok

Yesterday I was trying to find the problem but I was not able to.

This is driving me crazy!!!

:)

 

Best regards and many thanks as usual for you support.

This portal is the best!!!!

Link to comment
Share on other sites

Hi again.

 

I am sorry but there is a bug in camera.setPosition.

Sometimes the numbers you pass through the vector3 are not properly recognized by the command.

My first supposition was good.

Could you have a look into the babylon.jscode?

By noi I have resolved by adding a small value to the value (0.000000001) but this is not good.

 

Best regards

Link to comment
Share on other sites

Sure.

Here you can see:

http://www.babylonjs-playground.com/#2JBSNA#34

Try to set manually camera position to 5.046899795532227,-162.91392005903518, 70.27924661865235 and you will see that it doesn't work camera position (X and Y) are detedted as NaN

Try to uncomment line 68 and comment 67. You will see.

To switch between views coment again 68 and uncomment 67.  and change lines 74 and 75.

For views p1, p2, p4, p5 and p6 it works but it is random.

Best regards

Link to comment
Share on other sites

Hi.

Many thanks by the PG.  I will use camera in this way, much more elegant. ;)

But why sometimes numbers are not prerly recognized to set the camera position?

CAn you exaplin the bahaviour I faced in my example?

I continue not understanding where was my problem.

Best regards

Link to comment
Share on other sites

2 hours ago, ua4192 said:

CAn you exaplin the bahaviour I faced in my example?

I will give it  go.

When you set the camera target new values for alpha and beta are calculated. Alpha is calculated from  x and z values using trigonometry, by using the initial settings for position and target with x and z values equal then alpha is calculate from 0/0 which is indeterminate and gives a null result so the mesh cannot be displayed. When you set an initial target with x and z not the same as the x and z positions then an alpha can be calculated and because of the way the code is ordered, setting a new position with x and z the same as x and z in the target still allows alpha to be calculated. Hence setting camera.target = model first stops the problem with your camera setting. However it would still be possible to give the camera positions where the x and z values were the same as the current target position. It would always be possible to check for this and adjust as necessary. IMHO it is not possible to do this automatically in the BJS code because although you could avoid it by changing the x and z values slightly but would not know whether the users intention was to adjust x or z singularly or together or positively or negatively.

 

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