Use lookat to specify the direction of the camera, but the viewing frustum rotates

I have a camera, and I want to specify the orientation of the camera through the lookat method. The result is that the orientation of the camera is correct, but its viewing frustum will rotate itself. Can I disable its own rotation?

I need the frustum to be able to rotate up and down or left and right with the target parameter passed in by lookat, but I don’t want to get the above rotation effect. I don’t need the head of the cone to rotate as the target changes. Is there any solution?

lookAt function will always rotate the camera (or any Object3D) so that the local top direction matches the objects’ respective up vector (by default it’s the world Y axis).

If you don’t want this to happen, you need to use quaternion property to specify rotation of an object.

How can I achieve it with three.js? I don’t know much about this part, currently I only have the camera’s position and end point information

That will give you the camera forward vector but it’s not enough to completely define the camera orientation in space.

There is also the camera rotation around this forward vector, on the left/right/top/bottom plane.

To add that rotation you can use rotateZ and an angle in radians:

camera.rotateZ(0.5);

Quaternions contain all rotations but this probably a simpler way to do it.