Follow the camera vertical Y rotation

I do 3rd person controls for character using OrbitControls (like in the world of warcraft)
The character needs to be be rotated to look forward following the camera rotation when the right button is pressed.
While the left button is pressed, the camera will just rotate around the character (cube).
How to make the character (cube) rotate only along the vertical Y, ignoring rotations along the X-axis and Z-axis

this makes rotations on all axis, i need only vertical Y rotation

Something like this maybe ?

const vec = Vector3();
camera.getWorldDirection( vec );
vec.y = 0;
vec.add( character.position );
character.lookAt( vec );

Yes it works! Thanks!
Replaced only
const vec = Vector3()
const vec = new THREE.Vector3();

1 Like