# Freecamera oscillation on rotation about x axis

## Recommended Posts

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?

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

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

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

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

##### Share on other sites

Actually you should play with the target as freeCamera is target based.

Here is a sample you should appreciate:

http://www.babylonjs-playground.com/#RWIDA#2

##### Share on other sites

Hi John I'm not sure this is the solution you are looking for - but it is simple

PG Camera Rotation X

Just create a box - I called it "cambox" - make it the parent of the camera, then rotate the box around x.

cheers, gryff

##### Share on other sites

Thanks DK looked through freeCamera and targetCamera for any vector properties, never though about just a camera object.

Thanks gryff for the alternative.

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

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.