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
cube.quaternion.copy(camera.quaternion);

Something like this maybe ?

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

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

1 Like