Jump to content

Freecamera oscillation on rotation about x axis


JohnK
 Share

Recommended Posts

In this PG  http://www.babylonjs-playground.com/#RWIDA

by swapping comments around on lines 56 and 57 you can get the camera to rotate about either the x axis or the y axis.

 

When it is rotating about the y axis you see as I would expect the boxes rotating around the camera.

 

When it is rotating around the x axis the rotation is not continuous as it is for the y but swaps orientation at top and bottom of rotation giving an oscillating view.

 

Anybody know how to get a view of the boxes rotating around the camera continuously around the z axis by rotating the camera?

Link to comment
Share on other sites

Hello this is because the camera has a up vector = (0, 1, 0)

 

If you want to rotate around X, you may have to invert the up vector at some point

 

Tried to find out how to change the up vector to no avail. Have tried using camera.setTarget but have come across a problem that probably has the same cause.

 

This is my PG http://www.babylonjs-playground.com/#RWIDA#1

 

Have set coloured boxes along the axis as in this picture

post-14282-0-43040600-1444832465.jpg

 

Have then used setTarget() on the camera with various target vectors.

Setting the camera with the target for each of the axis vectors as expected you get

 

(1,0,0) black              (-1,0,0) white

(0,1,0) blue                (0,-1,0) violet

(0,0,1) green              (0,0,-1) red

 

For the target (1,0,1) you would expect to see between the green and black boxes with a little of each  TICK

For the target (-1,0,1) you would expect to see between the green and white boxes with a little of each  TICK

 

For the target (0,1,1) you would expect to see between the green and blue boxes with a little of each  TICK

For the target (0,1,-1) you would expect to see between the red and blue boxes with a little of each  TICK

 

So far so good for the XoZ and YoZ planes. Now for the XoY plane

 

For the target (1,1,0) you would expect to see between the black and blue boxes with a little of each  CROSS

You just get the black box

For the target (-1,1,0) you would expect to see between the white and blue boxes with a little of each  CROSS

You just get the white box.

 

Just when I thought I was beginning to understand !! B)

 

Will changing the up vector help with this? How do you change the up vector? Will my expectations ever line up with reality?

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