How to keep the object always facing up?

I used three to place a car in the scene. I want to keep the front of my car facing the top of the browser when looking down, and the camera and car remain relatively still. But my code doesn’t seem to work

camera.position.set(target.position.x, target.position.y, target.position.z + 80);
camera.lookAt(target.position);
camera.up.set(0, 1, 0);

[…] keep the front of my car facing the top of the browser when looking down […]

[…] relatively still […]

Could you share an example / codepen of what you mean? :eyes: If you want an object / camera to continuously look at a certain point in world space, lookAt is all you’d really need (it’s not necessary to change the position or the up vector.)

I found that if I only use lookAt, my object is in the center of the screen, but its heading is not upward :rofl:

You can change the direction the object is looking by simply using a different target vector:

object.lookAt(new Vector3(0.0, 1.0, 0.0)); // Look Y-up
object.lookAt(new Vector3(0.0, -1.0, 0.0)); // Look Y-down

object.lookAt(new Vector3(0.0, 0.0, 1.0)); // Look Z-forward
object.lookAt(new Vector3(0.0, 0.0, -1.0)); // Look Z-back

object.lookAt(new Vector3(1.0, 0.0, 0.0)); // Look X-right
object.lookAt(new Vector3(-1.0, 0.0, 0.0)); // Look X-left

(Assuming object is at (0,0,0).)

I understand what you mean~

But my car :red_car: is always in motion, and what I expect is that the camera is looking in exactly the same direction as my car, and the heading is always upward.

my car :red_car: is always in motion […] and the heading is always upward.

Still finding it a bit hard to visualise, but if you want the camera to look the same direction as the car, you can then do (without lookAts):

camera.quaternion.copy(car.quaternion);

Quaternion describes the rotation of the object in 3D space - so if you copy car quaternion to the camera, they should be looking in the same direction :thinking:

(Also - why is the car heading upward :eyes: ?)