Question about camera rotation


#1

Hello,
Last time i started to learn some three,js (I must do something like city), but now I can’t make my camera turn in constant axis, can anybody help me?
W,A,S,D is move and Q,E is zoom in/out. On arrow left/right I wanted to have rotation but when I give it some zoom it breaks :frowning:

https://jsfiddle.net/f2Lommf5/11304/

And if anybody could help me with this mesh clipping on big zoom out

Thank You


#2

You’ve got to give your camera a larger value for its far clipping plane.

camera = new THREE.PerspectiveCamera( fov, aspect, near, far );

In your fiddle, you’re initiating your camera with a far value of 10, so everything that’s further than 10 units away gets clipped out of the frustrum. Try using a value of 50 or 100, to push the clipping further back.


#3

Thank you, but there is still problem with rotation :frowning: (Rotation is on arrows left/right), what have I done wrong?

Edit:
I know what’s wrong

camera.lookAt(camera.position.x , viewer.height , camera.position.z + 5);

the camera is looking ahead in one axis, when I rotate the camera, front of camera is on other axis…
How to make camera always looking ahead?